diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 583986729d..7d846efaeb 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -patreon: Fabsol +patreon: CalamityMod \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1d485231df..673a87ca2b 100644 --- a/.gitignore +++ b/.gitignore @@ -305,3 +305,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk +*.slnx diff --git a/Backgrounds/AstralDesertSurfaceBGStyle.cs b/Backgrounds/AstralDesertSurfaceBGStyle.cs index d5ef0d60c7..d7585a1371 100644 --- a/Backgrounds/AstralDesertSurfaceBGStyle.cs +++ b/Backgrounds/AstralDesertSurfaceBGStyle.cs @@ -1,19 +1,15 @@ -using Microsoft.Xna.Framework.Graphics; -using System.Reflection; -using System; -using Terraria.Graphics.Effects; -using Terraria; -using Terraria.ModLoader; -using Microsoft.Xna.Framework; +using System; using CalamityMod.Skies; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; namespace CalamityMod.Backgrounds { public class AstralDesertSurfaceBGStyle : ModSurfaceBackgroundStyle { - 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; @@ -45,9 +41,9 @@ namespace CalamityMod.Backgrounds 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); + float screenOff = Main.instance.screenOff; + float scAdj = Main.instance.scAdj; + Color COSBMAplha = Main.ColorOfSurfaceBackgroundsModified; Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A); bool canBGDraw = false; if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen)) diff --git a/Backgrounds/AstralSnowSurfaceBGStyle.cs b/Backgrounds/AstralSnowSurfaceBGStyle.cs index 7300b8c7e3..fbbebf7119 100644 --- a/Backgrounds/AstralSnowSurfaceBGStyle.cs +++ b/Backgrounds/AstralSnowSurfaceBGStyle.cs @@ -1,20 +1,15 @@ -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; +using System; using CalamityMod.Skies; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; namespace CalamityMod.Backgrounds { public class AstralSnowSurfaceBGStyle : ModSurfaceBackgroundStyle { - 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; @@ -47,9 +42,9 @@ namespace CalamityMod.Backgrounds 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); + float screenOff = Main.instance.screenOff; + float scAdj = Main.instance.scAdj; + Color COSBMAplha = Main.ColorOfSurfaceBackgroundsModified; Color ColorOfSurfaceBackgroundsModified = new Color(63, 51, 90, COSBMAplha.A); bool canBGDraw = false; if ((!Main.remixWorld || (Main.gameMenu && !WorldGen.remixWorldGen)) && (!WorldGen.remixWorldGen || !WorldGen.drunkWorldGen)) diff --git a/Backgrounds/AstralSurfaceBGStyle.cs b/Backgrounds/AstralSurfaceBGStyle.cs index c32d475687..57838097ab 100644 --- a/Backgrounds/AstralSurfaceBGStyle.cs +++ b/Backgrounds/AstralSurfaceBGStyle.cs @@ -1,20 +1,16 @@ -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework; -using System.Reflection; -using System; -using Terraria.Graphics.Effects; -using Terraria; -using Terraria.ModLoader; +using System; using CalamityMod.Skies; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; namespace CalamityMod.Backgrounds { //this is just a blank background, so each custom background will draw over it public class AstralSurfaceBGStyle : ModSurfaceBackgroundStyle { - 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; @@ -50,9 +46,9 @@ namespace CalamityMod.Backgrounds 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); + float screenOff = Main.instance.screenOff; + float scAdj = Main.instance.scAdj; + Color COSBMAplha = Main.ColorOfSurfaceBackgroundsModified; 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)) diff --git a/Backgrounds/BasaltGullyBG.png b/Backgrounds/BasaltGullyBG.png new file mode 100644 index 0000000000..592d4b0dd6 Binary files /dev/null and b/Backgrounds/BasaltGullyBG.png differ diff --git a/Backgrounds/SunkenSeaBGStyle.cs b/Backgrounds/SunkenSeaBGStyle.cs index 11b86c7d67..75987a1497 100644 --- a/Backgrounds/SunkenSeaBGStyle.cs +++ b/Backgrounds/SunkenSeaBGStyle.cs @@ -10,23 +10,49 @@ namespace CalamityMod.Backgrounds private int SSBG2; private int SSBG3; + private int BGBG0; + private int BGBG1; + private int BGBG2; + private int BGBG3; + public override void SetStaticDefaults() { if (Main.dedServ) return; - SSBG0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG0"); - SSBG1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG1"); - SSBG2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG2"); - SSBG3 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG3"); + SSBG0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + SSBG1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + SSBG2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + SSBG3 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + + BGBG0 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + BGBG1 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BasaltGullyBG"); + BGBG2 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + BGBG3 = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BasaltGullyBG"); } public override void FillTextureArray(int[] textureSlots) { - textureSlots[0] = SSBG0; - textureSlots[1] = SSBG1; - textureSlots[2] = SSBG2; - textureSlots[3] = SSBG3; + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance()) || + Main.LocalPlayer.InModBiome(ModContent.GetInstance()) || + Main.LocalPlayer.InModBiome(ModContent.GetInstance()) || + Main.LocalPlayer.InModBiome()) + { + textureSlots[0] = SSBG0; + textureSlots[1] = SSBG1; + textureSlots[2] = SSBG2; + textureSlots[3] = SSBG3; + } + if (!Main.LocalPlayer.InModBiome(ModContent.GetInstance()) && + !Main.LocalPlayer.InModBiome(ModContent.GetInstance()) && + !Main.LocalPlayer.InModBiome(ModContent.GetInstance()) && + !Main.LocalPlayer.InModBiome()) + { + textureSlots[0] = BGBG0; + textureSlots[1] = BGBG1; + textureSlots[2] = BGBG2; + textureSlots[3] = BGBG3; + } } } } diff --git a/Backgrounds/SunkenSeaBurrowsBG.cs b/Backgrounds/SunkenSeaBurrowsBG.cs index bff3bd212f..b8de0ce754 100644 --- a/Backgrounds/SunkenSeaBurrowsBG.cs +++ b/Backgrounds/SunkenSeaBurrowsBG.cs @@ -1,15 +1,22 @@ -using Terraria; -using Terraria.ModLoader; +using CalamityMod.Graphics; +using CalamityMod.Systems.Graphic; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using ReLogic.Content; +using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Backgrounds { public class SunkenSeaBurrowsBG : ModSystem { + private static RenderTargetLease WaterDistortionTarget; + + private static bool CurrentlyRendering { get; set; } + public override void Load() { if (Main.dedServ) @@ -17,7 +24,15 @@ namespace CalamityMod.Backgrounds return; } + GeneralDrawLayerSystem.OnPrepareDraw += DrawToTarget; On_Main.DrawBackgroundBlackFill += On_Main_DrawBackgroundBlackFill; + + Main.QueueMainThreadAction(() => WaterDistortionTarget = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice)); + } + + public override void Unload() + { + GeneralDrawLayerSystem.OnPrepareDraw -= DrawToTarget; } /// @@ -33,72 +48,277 @@ namespace CalamityMod.Backgrounds { if (!Main.dedServ && Main.LocalPlayer.InModBiome()) { - for (int i = 0; i < Main.screenWidth / 16; i++) + int drawLimitX = Main.screenWidth / 16; + int drawLimitY = Main.screenHeight / 16; + Point drawPoint = (Main.screenPosition / 16).ToPoint(); + for (int i = 0; i < drawLimitX; i++) { - for (int j = 0; j < Main.screenWidth / 16; j++) + for (int j = 0; j < drawLimitY; j++) { - Point pos = (Main.screenPosition / 16).ToPoint() + new Point(i, j); - - if (Main.tile[pos.X, pos.Y].Slope != SlopeType.Solid) - { + Point pos = drawPoint + new Point(i, j); + if (!Main.tile[pos.X, pos.Y].HasTile && + Main.tile[pos.X, pos.Y].WallType == WallID.None) Lighting.AddLight(pos.X, pos.Y, TorchID.White, 0.1f); + } + } + } + if (!Main.dedServ && (Main.LocalPlayer.InModBiome(ModContent.GetInstance()))) + { + int drawLimitX = Main.screenWidth / 16; + int drawLimitY = Main.screenHeight / 16; + Point drawPoint = (Main.screenPosition / 16).ToPoint(); + for (int i = 0; i < drawLimitX; i++) + { + for (int j = 0; j < drawLimitY; j++) + { + Point pos = drawPoint + new Point(i, j); + if (!Main.tile[pos.X, pos.Y].HasTile && + Main.tile[pos.X, pos.Y].WallType == WallID.None && + Main.tile[pos.X, pos.Y].LiquidAmount == 0) + Lighting.AddLight(pos.X, pos.Y, TorchID.White, 0.2f); + } + } + } + if (!Main.dedServ && (Main.LocalPlayer.InModBiome(ModContent.GetInstance()))) + { + int drawLimitX = Main.screenWidth / 16; + int drawLimitY = Main.screenHeight / 16; + Point drawPoint = (Main.screenPosition / 16).ToPoint(); + for (int i = 0; i < drawLimitX; i++) + { + for (int j = 0; j < drawLimitY; j++) + { + Point pos = drawPoint + new Point(i, j); + if (!Main.tile[pos.X, pos.Y].HasTile && + Main.tile[pos.X, pos.Y].WallType == WallID.None) + Lighting.AddLight(pos.X, pos.Y, TorchID.White, 0.2f); + } + } + } + if (!Main.dedServ && (Main.LocalPlayer.InModBiome(ModContent.GetInstance()))) + { + int drawLimitX = Main.screenWidth / 16; + int drawLimitY = Main.screenHeight / 16; + Point drawPoint = (Main.screenPosition / 16).ToPoint(); + for (int i = 0; i < drawLimitX; i++) + { + for (int j = 0; j < drawLimitY; j++) + { + Point pos = drawPoint + new Point(i, j); + if (!Main.tile[pos.X, pos.Y].HasTile && + Main.tile[pos.X, pos.Y].WallType == WallID.None) + Lighting.AddLight(pos.X, pos.Y, TorchID.White, 0.2f); + } + } + } + if (!Main.dedServ && (Main.LocalPlayer.InModBiome(ModContent.GetInstance()))) + { + int drawLimitX = Main.screenWidth / 16; + int drawLimitY = Main.screenHeight / 16; + Point drawPoint = (Main.screenPosition / 16).ToPoint(); + for (int i = 0; i < drawLimitX; i++) + { + for (int j = 0; j < drawLimitY; j++) + { + Point pos = drawPoint + new Point(i, j); + if (pos.Y >= Main.maxTilesY - 450) + { + if (!Main.tile[pos.X, pos.Y].HasTile && + Main.tile[pos.X, pos.Y].WallType == WallID.None) + Lighting.AddLight(pos.X, pos.Y, TorchID.Red, 0.6f); } } } } } + private void DrawToTarget() + { + if (Main.gameMenu) + { + return; + } + + CurrentlyRendering = true; + + using (WaterDistortionTarget.Scope(clearColor: Color.Transparent)) + { + // 13MAY2025: fryzahh: Note that when other Sunken Sea backgrounds are implemented they should use this same system. + // Leaving this here for other programmers, in case I don't get to doing this myself. + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + DrawShoresBG(); + DrawBurrowsBG(); + + Main.spriteBatch.End(); + } + + CurrentlyRendering = false; + } + private void On_Main_DrawBackgroundBlackFill(On_Main.orig_DrawBackgroundBlackFill orig, Main self) { if (Main.gameMenu || Main.screenPosition.Y + Main.screenHeight < ((int)Main.worldSurface) * 16f) { orig(self); - return; } orig(self); - DrawBurrowsBG(); - } - - public static float Transparency; - - public static float TransitionSpeed => 0.02f; - - private static void DrawBurrowsBG() - { - if (Main.LocalPlayer.InModBiome(ModContent.GetInstance())) + // This won't render if the Wave Quality setting isn't turned off unfortunately, so don't bother running any of the shader + // rendering code if that setting is on. + if (Main.WaveQuality > 0 || !CalamityClientConfig.Instance.SunkenSeaBackgroundDistortion) { - Transparency += TransitionSpeed; - - if (Transparency > 1f) - { - Transparency = 1f; - } + DrawShoresBG(); + DrawBurrowsBG(); } else { - //make transparency immediately go down so it doesnt look weird, since vanilla underground backgrounds dont have the fade-in effect this background has + MiscShaderData distortionShader = GameShaders.Misc["CalamityMod:BasicTextureDistortion"]; + Asset distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Swirls"); + + // Apply a distortion shader to the Sunken Sea backgrounds to give them an underwater ripple-like effect. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, distortionShader.Shader, CalamityUtils.BackgroundMatrix); + + const float distortionXSpeed = -0.012f; + const float distortionYSpeed = 0.02f; + const float noiseScale = 0.075f; + const float noiseStrength = 0.035f; + Vector2 timeOffset = new Vector2(distortionXSpeed, distortionYSpeed) * Main.GlobalTimeWrappedHourly * noiseScale; + Vector2 noiseScaleStrength = new Vector2(noiseScale, noiseStrength); + distortionShader.Shader.Parameters["timeOffset"].SetValue(timeOffset); + distortionShader.Shader.Parameters["noiseScaleStrength"].SetValue(noiseScaleStrength); + distortionShader.SetShaderTexture(distortionTexture); + + Main.spriteBatch.Draw(WaterDistortionTarget.Target, new Rectangle(16, 16, Main.screenWidth, Main.screenHeight), Color.White); + } + } + + public static float Transparency; + public static float TransitionSpeed => 0.02f; + + private static void DrawShoresBG() + { + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance())) + { + Transparency += 1f; + + if (Transparency > 1f) + Transparency = 1f; + } + else + { + // Make transparency immediately go down so it doesnt look weird, since vanilla underground backgrounds dont have the fade-in effect this background has. Transparency -= 1f; if (Transparency < 0f) - { Transparency = 0f; - } } - //dont bother running any of the background drawing if the transparency is zero (meaning the background isnt actually active) - //also do not run any of the background drawing if you have the vanilla background config option turned off + // Don't bother running any of the background drawing if the transparency is zero (meaning the background isnt actually active). + // Also do not run any of the background drawing if you have the vanilla background config option turned off. if (Transparency > 0f && Main.BackgroundEnabled) { Vector2 vector = Main.screenPosition + new Vector2((Main.screenWidth >> 1), (Main.screenHeight >> 1)); float num = (Main.GameViewMatrix.Zoom.Y - 1f) * 0.5f * 200f; float Scale = 1.5f; + float playerDrawPosition = ((Main.LocalPlayer.Center.Y / 16f) - 90) * 16f; for (int Layers = 4; Layers >= 0; Layers--) { - //get each background texture + // Get each background texture. + Texture2D BGTexture = ModContent.Request("CalamityMod/Backgrounds/SunkenSeaShoresBG" + Layers).Value; + + Vector2 vector2 = new Vector2(BGTexture.Width, BGTexture.Height) * 0.5f; + float num2 = (Layers * 2 + 3f); + Vector2 vector3 = new Vector2(1f / num2); + Rectangle rectangle = new Rectangle(0, 0, BGTexture.Width, BGTexture.Height); + Vector2 zero = Vector2.Zero; + + switch (Layers) + { + case 0: + { + zero.Y += 200f; + break; + } + case 1: + { + zero.Y += 0f; + break; + } + case 2: + { + zero.Y += 0f; + break; + } + case 3: + { + zero.Y += 0f; + break; + } + case 4: + { + zero.Y += 0f; + break; + } + } + + vector2 *= Scale; + + zero.Y -= num; + float LoopWidth = Scale * rectangle.Width; + float LoopHeight = Scale * rectangle.Height; + int LoopX = (int)((vector.X * vector3.X - vector2.X + zero.X - (Main.screenWidth >> 1)) / LoopWidth); + int LoopY = (int)((vector.Y * vector3.Y - vector2.Y + zero.Y - (Main.screenWidth >> 1)) / LoopWidth); + + for (int i = LoopY - 2; i < LoopY + 4 + (int)(Main.screenWidth / LoopHeight); i++) + { + for (int j = LoopX - 2; j < LoopX + 4 + (int)(Main.screenWidth / LoopWidth); j++) + { + Vector2 drawPosition = (new Vector2(j * Scale * (rectangle.Width / vector3.X), playerDrawPosition) + vector2 - vector) * vector3 + vector - Main.screenPosition - vector2 + zero; + + var frame = rectangle; + var color = Color.White * Transparency; + + Main.spriteBatch.Draw(BGTexture, drawPosition, frame, color, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0f); + } + } + } + } + } + private static void DrawBurrowsBG() + { + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance())) + { + Transparency += 1f; + + if (Transparency > 1f) + Transparency = 1f; + } + else + { + // Make transparency immediately go down so it doesnt look weird, since vanilla underground backgrounds dont have the fade-in effect this background has. + Transparency -= 1f; + + if (Transparency < 0f) + Transparency = 0f; + } + + // Don't bother running any of the background drawing if the transparency is zero (meaning the background isnt actually active). + // Also do not run any of the background drawing if you have the vanilla background config option turned off. + if (Transparency > 0f && Main.BackgroundEnabled) + { + Vector2 vector = Main.screenPosition + new Vector2((Main.screenWidth >> 1), (Main.screenHeight >> 1)); + float num = (Main.GameViewMatrix.Zoom.Y - 1f) * 0.5f * 200f; + float Scale = 1.5f; + float playerDrawPosition = ((Main.LocalPlayer.Center.Y / 16f) - 90) * 16f; + + for (int Layers = 4; Layers >= 0; Layers--) + { + // Get each background texture. Texture2D BGTexture = ModContent.Request("CalamityMod/Backgrounds/SunkenSeaBurrowsBG" + Layers).Value; Vector2 vector2 = new Vector2(BGTexture.Width, BGTexture.Height) * 0.5f; @@ -148,7 +368,7 @@ namespace CalamityMod.Backgrounds { for (int j = LoopX - 2; j < LoopX + 4 + (int)(Main.screenWidth / LoopWidth); j++) { - Vector2 drawPosition = (new Vector2(j * Scale * (rectangle.Width / vector3.X), ((Main.LocalPlayer.Center.Y / 16f) - 90) * 16f) + vector2 - vector) * vector3 + vector - Main.screenPosition - vector2 + zero; + Vector2 drawPosition = (new Vector2(j * Scale * (rectangle.Width / vector3.X), playerDrawPosition) + vector2 - vector) * vector3 + vector - Main.screenPosition - vector2 + zero; var frame = rectangle; var color = Color.White * Transparency; diff --git a/Backgrounds/SunkenSeaBurrowsBG0.png b/Backgrounds/SunkenSeaBurrowsBG0.png index 26ad2b3f50..21e7232442 100644 Binary files a/Backgrounds/SunkenSeaBurrowsBG0.png and b/Backgrounds/SunkenSeaBurrowsBG0.png differ diff --git a/Backgrounds/SunkenSeaBurrowsBG1.png b/Backgrounds/SunkenSeaBurrowsBG1.png index 452e46c78c..9756095977 100644 Binary files a/Backgrounds/SunkenSeaBurrowsBG1.png and b/Backgrounds/SunkenSeaBurrowsBG1.png differ diff --git a/Backgrounds/SunkenSeaBurrowsBG2.png b/Backgrounds/SunkenSeaBurrowsBG2.png index 3eb8e53eb6..21e7232442 100644 Binary files a/Backgrounds/SunkenSeaBurrowsBG2.png and b/Backgrounds/SunkenSeaBurrowsBG2.png differ diff --git a/Backgrounds/SunkenSeaBurrowsBG3.png b/Backgrounds/SunkenSeaBurrowsBG3.png index 13524864b4..55795c777e 100644 Binary files a/Backgrounds/SunkenSeaBurrowsBG3.png and b/Backgrounds/SunkenSeaBurrowsBG3.png differ diff --git a/Backgrounds/SunkenSeaShoresBG0.png b/Backgrounds/SunkenSeaShoresBG0.png new file mode 100644 index 0000000000..272e84a3d0 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG0.png differ diff --git a/Backgrounds/SunkenSeaShoresBG1.png b/Backgrounds/SunkenSeaShoresBG1.png new file mode 100644 index 0000000000..0d7faa83b7 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG1.png differ diff --git a/Backgrounds/SunkenSeaShoresBG2.png b/Backgrounds/SunkenSeaShoresBG2.png new file mode 100644 index 0000000000..ddaffc2a82 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG2.png differ diff --git a/Backgrounds/SunkenSeaShoresBG3.png b/Backgrounds/SunkenSeaShoresBG3.png new file mode 100644 index 0000000000..e9668359e5 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG3.png differ diff --git a/Backgrounds/SunkenSeaShoresBG4.png b/Backgrounds/SunkenSeaShoresBG4.png new file mode 100644 index 0000000000..4922846eb0 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG4.png differ diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 226bf39ba5..bb11e63297 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -27,16 +27,16 @@ namespace CalamityMod.Balancing { public sealed class BalancingChangesManager : ModSystem { - internal static List UniversalBalancingChanges = null; internal static List NPCSpecificBalancingChanges = null; // Balancing changes in this method are sorted based on place in progression, NPC name (from A-Z), and strength of resistance in ascending order, in that level of priority. // For ease of change, changes that are not exclusive to one specific weapon are not bundled into one line if they share the same resistance factor. - // To give an example of this, Thanatos having a 50% resist to Chicken Cannon and Prismatic Breaker should be two distinct lines with a 0.5x factor instead of hamfisting them all - // into one single resist that may have to be split later. + // To give an example of this, Thanatos having a 50% resist to Chicken Cannon and Rancor should be two distinct lines with a 0.5x factor instead of hamfisting them all into + // one single resist that may have to be split later. public override void SetStaticDefaults() { // Dirty shorthand for true melee resists, because they're super common and other class resists aren't. + // If you add/change a true melee resist here, be sure to add/change the resist in CalamityGlobalNPC ModifyHitByItem as well. IBalancingRule ResistTrueMelee(float f) => new ClassResistBalancingRule(f, TrueMeleeDamageClass.Instance); // Declare specific filters. @@ -46,84 +46,41 @@ namespace CalamityMod.Balancing bool DragonRageFilter(Projectile p) => p.type == ProjectileType() || p.type == ProjectileType() || (p.type == ProjectileType() && p.CountsAsClass()); - // bool MonkStaffT3Filter(Projectile p) => - // p.type == ProjectileID.MonkStaffT3_AltShot || (p.type == ProjectileID.Electrosphere && Main.player[p.owner].ActiveItem().type == ItemID.MonkStaffT3); - - bool MushroomSpearFilter(Projectile p) => - p.type == ProjectileID.Mushroom && Main.player[p.owner].ActiveItem().type == ItemID.MushroomSpear; - - bool OrichalcumPetalFilter(Projectile p) => - p.type == ProjectileID.FlowerPetal && Main.player[p.owner].onHitPetal; - - bool SpectreMaskSetBonusFilter(Projectile p) => - p.type == ProjectileID.SpectreWrath && Main.player[p.owner].ghostHurt; - bool AotCThrowCombo(Projectile p) => p.type == ProjectileType() && (p.ai[0] == 2 || p.ai[0] == 3); bool HiveBeeFilter(Projectile p) => - p.type == ProjectileType() && Main.player[p.owner].ActiveItem().type == ItemType(); - - UniversalBalancingChanges = new List() - { - // Nerf Crystal bullet shards by 45% - // Currently crystal bullet projectiles deal 50% of the bullet's damage which is absurd in vanilla, this nerfs them to 27.5% - Do(new ProjectileResistBalancingRule(0.55f, ProjectileID.CrystalShard)), - - // Nerf Luminite Arrow trails by 50%. - Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.MoonlordArrowTrail)), - - // Nerf Seedler seeds by 25%. - Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.SeedlerNut, ProjectileID.SeedlerThorn)), - - // Nerf Cursed Dart flames by 50%. - Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.CursedDartFlame)), - - // Nerf Mushroom Spear projectiles by 50%. - Do(new ProjectileSpecificRequirementBalancingRule(0.5f, MushroomSpearFilter)), - - // Nerf Orichalcum armor set bonus petals by 25%. - Do(new ProjectileSpecificRequirementBalancingRule(0.75f, OrichalcumPetalFilter)), - - // Nerf Spectre Mask set bonus projectiles by 50%. - Do(new ProjectileSpecificRequirementBalancingRule(0.5f, SpectreMaskSetBonusFilter)), - - }; + p.type == ProjectileType() && Main.player[p.owner].HeldItem.type == ItemType(); NPCSpecificBalancingChanges = new List(); - #region Desert Scourge - // 25% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(DesertScourgeIDList.List, Do(ResistTrueMelee(0.8f)))); - #endregion - #region Crabulon - // 25% resist to true melee. + // 20% resist to true melee. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), ResistTrueMelee(0.8f))); #endregion - #region Brain of Cthulhu: Creepers - // 50% resist to true melee. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(ResistTrueMelee(0.5f)))); - - // 50% resist to Demon Scythe. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe)))); - #endregion - #region Eater of Worlds - // 50% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(EaterOfWorldsIDList.List, Do(ResistTrueMelee(0.5f)))); - // 50% resist to Demon Scythe. - NPCSpecificBalancingChanges.AddRange(Bundle(EaterOfWorldsIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.EaterOfWorlds, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe)))); // 40% resist to Sky Glaze. - NPCSpecificBalancingChanges.AddRange(Bundle(EaterOfWorldsIDList.List, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.EaterOfWorlds, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + + // 25% resist to true melee. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.EaterOfWorlds, Do(ResistTrueMelee(0.75f)))); + #endregion + + #region Brain of Cthulhu: Creepers + // 50% resist to Demon Scythe. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.DemonScythe)))); + + // 25% resist to true melee. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCID.Creeper, Do(ResistTrueMelee(0.75f)))); #endregion #region The Perforators // 50% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(PerforatorWormIDList.List, Do(ResistTrueMelee(0.5f)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Perforators, Do(ResistTrueMelee(0.5f)))); #endregion #region Wall of Flesh @@ -133,61 +90,58 @@ namespace CalamityMod.Balancing #region Aquatic Scourge // 50% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(AquaticScourgeIDList.List, Do(ResistTrueMelee(0.5f)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AquaticScourge, Do(ResistTrueMelee(0.5f)))); // 50% resist to Adamantite Throwing Axe's lightning. // Twisting Thunder and Gael's Greatsword use this projectile too, but they are far beyond progression, so who cares! - NPCSpecificBalancingChanges.AddRange(Bundle(AquaticScourgeIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.CultistBossLightningOrbArc)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AquaticScourge, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.CultistBossLightningOrbArc)))); // 50% resist to Dormant Brimseeker. - NPCSpecificBalancingChanges.AddRange(Bundle(AquaticScourgeIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AquaticScourge, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 50% resist to Mounted Scanner. - NPCSpecificBalancingChanges.AddRange(Bundle(AquaticScourgeIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AquaticScourge, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 40% resist to Cryophobia. - NPCSpecificBalancingChanges.AddRange(Bundle(AquaticScourgeIDList.List, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AquaticScourge, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); // 30% resist to Meowthrower. - NPCSpecificBalancingChanges.AddRange(Bundle(AquaticScourgeIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AquaticScourge, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); // 25% resist to Snowstorm Staff. - NPCSpecificBalancingChanges.AddRange(Bundle(AquaticScourgeIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AquaticScourge, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); #endregion #region The Destroyer // 50% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(ResistTrueMelee(0.5f)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Destroyer, Do(ResistTrueMelee(0.5f)))); // 50% resist to Adamantite Throwing Axe's lightning. // See Aquatic Scourge comment. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.CultistBossLightningOrbArc)))); - - // 50% resist to Aftershock's rocks. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Destroyer, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.CultistBossLightningOrbArc)))); // 50% resist to Dormant Brimseeker. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Destroyer, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 45% resist to Mounted Scanner. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(new ProjectileResistBalancingRule(0.55f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Destroyer, Do(new ProjectileResistBalancingRule(0.55f, ProjectileType())))); // 30% resist to Meowthrower. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Destroyer, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); // 25% resist to Avalanche's Ice Bombs and shards. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Destroyer, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); // 25% resist to Snowstorm Staff. - NPCSpecificBalancingChanges.AddRange(Bundle(DestroyerIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Destroyer, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); #endregion #region Astrum Aureus - // 30% resist to The Ballista's greatarrows. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 25% resist to true melee. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), ResistTrueMelee(0.75f))); - // 30% resist to Whitewater. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), Do(new ProjectileResistBalancingRule(0.7f, ProjectileType(), ProjectileType(), ProjectileType())))); + // 25% resist to The Ballista's greatarrows. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); #endregion #region Duke Fishron @@ -208,31 +162,22 @@ namespace CalamityMod.Balancing #region Ravager // 50% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(ResistTrueMelee(0.5f)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(ResistTrueMelee(0.5f)))); // 50% resist to Aegis Blade's explosions because the true melee resist ain't enough. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); - // 50% resist to Icicle Arrows. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); - - // 50% resist to Whitewater. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType(), ProjectileType(), ProjectileType())))); + // 40% resist to Icicle Arrows. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); // 35% resist to Flying Dragon. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.65f, ProjectileID.DD2SquireSonicBoom)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.65f, ProjectileID.DD2SquireSonicBoom)))); - // 30% resist to Aurora Blazer. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); - - // 30% resist to Flak Kraken. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); - - // 25% resist to Lucrecia. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); + // 20% resist to Aurora Blazer. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); // 20% resist to The Hive. - NPCSpecificBalancingChanges.AddRange(Bundle(RavagerIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ravager, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType(), ProjectileType())))); #endregion #region Lunatic Cultist @@ -251,37 +196,37 @@ namespace CalamityMod.Balancing #region Astrum Deus // 75% resist to Plaguenades. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.25f, ProjectileType(), ProjectileType())))); - - // 70% resist to Charged Blaster Cannon. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.3f, ProjectileID.ChargedBlasterLaser)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.25f, ProjectileType(), ProjectileType())))); // 70% resist to Stardust Dragon Staff. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.3f, ProjectileID.StardustDragon1, ProjectileID.StardustDragon2, ProjectileID.StardustDragon3, ProjectileID.StardustDragon4)))); - - // 55% resist to Flak Kraken. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.45f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.3f, ProjectileID.StardustDragon1, ProjectileID.StardustDragon2, ProjectileID.StardustDragon3, ProjectileID.StardustDragon4)))); // 50% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(ResistTrueMelee(0.5f)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(ResistTrueMelee(0.5f)))); + + // 50% resist to Charged Blaster Cannon. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.ChargedBlasterLaser)))); // 50% resist to Atlantis (Atlantis gaming!). - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); - - // 50% resist to Aurora Blazer. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 35% resist to Aerial Bane. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.65f, ProjectileID.DD2BetsyArrow)))); - - // 35% resist to Ballistic Poison Bomb's clouds. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.65f, ProjectileID.DD2BetsyArrow)))); // 35% resist to Icicle Arrows. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + + // 30% resist to Aurora Blazer. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + + // 30% resist to Flak Kraken. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + + // 20% resist to Ballistic Poison Bomb's clouds. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); // 20% resist to Cluster Rocket fragments. - NPCSpecificBalancingChanges.AddRange(Bundle(AstrumDeusIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileID.ClusterFragmentsI, ProjectileID.ClusterFragmentsII)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.8f, ProjectileID.ClusterFragmentsI, ProjectileID.ClusterFragmentsII)))); #endregion #region Moon Lord @@ -306,34 +251,37 @@ namespace CalamityMod.Balancing // 50% resist to Galactus Blade. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.5f, ProjectileType()))); + // 40% resist to Pristine Fury's alt fire. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.6f, ProjectileType()))); + // 40% resist to Stellar Torus Staff. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.6f, ProjectileType()))); #endregion #region Storm Weaver // 50% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(ResistTrueMelee(0.5f)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(ResistTrueMelee(0.5f)))); // 50% resist to Dazzling Stabber Staff. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 50% resist to Last Prism. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.LastPrismLaser)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.LastPrismLaser)))); // 50% resist to Legion of Celestia. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 50% resist to Pristine Fury's alt fire. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 50% resist to Tactician's Trump Card's explosions. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 40% resist to Devil's Sunrise's slashes. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); // 35% resist to Event Horizon. - NPCSpecificBalancingChanges.AddRange(Bundle(StormWeaverIDList.List, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.StormWeaver, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType(), ProjectileType())))); #endregion #region Old Duke @@ -343,22 +291,19 @@ namespace CalamityMod.Balancing #region The Devourer of Gods // 65% resist to Wave Pounder. - NPCSpecificBalancingChanges.AddRange(Bundle(DevourerOfGodsIDList.List, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); // 35% resist to Sulphuric Acid Cannon's explosions. - NPCSpecificBalancingChanges.AddRange(Bundle(DevourerOfGodsIDList.List, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); - - // 35% resist to Venusian Trident. - NPCSpecificBalancingChanges.AddRange(Bundle(DevourerOfGodsIDList.List, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); // 25% resist to Corinth Prime's grenades. - NPCSpecificBalancingChanges.AddRange(Bundle(DevourerOfGodsIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); // 20% resist to Valediction's typhoons; will catch Nuclear Fury as well but that doesn't matter. - NPCSpecificBalancingChanges.AddRange(Bundle(DevourerOfGodsIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); // 15% vulnerability to Time Bolt stealth strikes. - NPCSpecificBalancingChanges.AddRange(Bundle(DevourerOfGodsIDList.List, Do(new StealthStrikeBalancingRule(1.15f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new StealthStrikeBalancingRule(1.15f, ProjectileType())))); #endregion The Devourer of Gods #region Yharon @@ -370,32 +315,29 @@ namespace CalamityMod.Balancing #endregion #region Exo Mechs: Ares + // 35% resist to Devil's Devastation's slash. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + // 30% resist to Dynamic Pursuer. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType(), ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType(), ProjectileType(), ProjectileType())))); // 25% resist to Aetherflux Cannon. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); - - // 25% resist to Prismatic Breaker's deathray. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); // 20% resist to the Spin Throw part of the Ark of the Cosmos' combo. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileSpecificRequirementBalancingRule(0.8f, AotCThrowCombo)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileSpecificRequirementBalancingRule(0.8f, AotCThrowCombo)))); // 20% resist to Dragon Rage projectiles. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileSpecificRequirementBalancingRule(0.8f, DragonRageFilter)))); - - // 20% resist to Eclipse's Fall. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileSpecificRequirementBalancingRule(0.8f, DragonRageFilter)))); // 20% resist to Rancor. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); // 20% resist to Yharim's Crystal. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); // 20% resist to Zenith. - NPCSpecificBalancingChanges.AddRange(Bundle(AresIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileID.FinalFractal)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Ares, Do(new ProjectileResistBalancingRule(0.8f, ProjectileID.FinalFractal)))); #endregion #region Exo Mechs: Artemis and Apollo @@ -407,97 +349,70 @@ namespace CalamityMod.Balancing #region Exo Mechs: Thanatos // 65% resist to true melee. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(ResistTrueMelee(0.35f)))); - - // 65% resist to The Enforcer's projectiles. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(ResistTrueMelee(0.35f)))); // 65% resist to The Final Dawn's lunge. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); // 65% resist to Stellar Torus Staff. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); // 60% resist to Dynamic Pursuer. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.4f, ProjectileType(), ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.4f, ProjectileType(), ProjectileType(), ProjectileType())))); // 50% resist to Chicken Cannon. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); - - // 50% resist to Omicron's beam. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 50% resist to Rancor. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 50% resist to Vehemence's skulls. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 50% resist to Yharim's Crystal. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); - - // 45% resist to Prismatic Breaker's deathray. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.55f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); // 45% resist to Wrathwing's stealth strike fireballs. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.55f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.55f, ProjectileType())))); - // 30% resist to Eclipse's Fall. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 40% resist to Omicron's beam. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.6f, ProjectileType())))); - // 30% resist to Sirius. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); - - // 30% resist to Ultima's rays. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType())))); + // 35% resist to Prismatic Breaker's deathray. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); // 30% resist to Dragon Scales and The Wand's tornadoes. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType(), ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.7f, ProjectileType(), ProjectileType())))); // 25% resist to the Spin Throw part of the Ark of the Cosmos' combo. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, AotCThrowCombo)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, AotCThrowCombo)))); // 25% resist to Dragon Rage projectiles. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, DragonRageFilter)))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, DragonRageFilter)))); // 25% resist to Gael's Greatsword's big skulls. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, BigGaelsSkullFilter)))); - - // 25% resist to Mirror of Kalandra's Paradoxica minion. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileSpecificRequirementBalancingRule(0.75f, BigGaelsSkullFilter)))); // 25% resist to Zenith. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.FinalFractal)))); - - // 20% resist to The Anomaly's Nanogun's bomb explosions. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.FinalFractal)))); // 20% resist to Ariane's aura (Lilies of Finality). - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); - // 20% resist to Eradicator's beams. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); - - // 20% resist to Plasma Grenade and Dynamic Pursuer's explosions. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType(), ProjectileType(), ProjectileType())))); + // 20% resist to Mirror of Kalandra's Paradoxica minion. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); // 20% resist to Voltaic Climax / Void Vortex hitscan beams. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); // 15% resist to The Final Dawn's AoE sweep flames. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); - - // 15% resist to Dragon's Breath's beam of fire. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); - - // 15% resist to God Slayer Slugs. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); // 15% resist to Gruesome Eminence. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); - // 15% resist to Luminite Bullets. - NPCSpecificBalancingChanges.AddRange(Bundle(ThanatosIDList.List, Do(new ProjectileResistBalancingRule(0.85f, ProjectileID.MoonlordBullet)))); + // 15% resist to Ultima's rays. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.Thanatos, Do(new ProjectileResistBalancingRule(0.85f, ProjectileType())))); #endregion #region Supreme Calamitas: Brimstone Hearts @@ -509,9 +424,6 @@ namespace CalamityMod.Balancing // 30% resist to Surge Driver's alt click comets. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.7f, ProjectileType()))); - - // 20% resist to Executioner's Blade stealth strikes. - NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.8f, ProjectileType()))); #endregion #region Supreme Calamitas: Soul Seekers @@ -534,23 +446,12 @@ namespace CalamityMod.Balancing public override void Unload() { - UniversalBalancingChanges = null; NPCSpecificBalancingChanges = null; } public static void ApplyFromProjectile(NPC npc, ref NPC.HitModifiers modifiers, Projectile proj) { - // Apply universal balancing rules. - foreach (IBalancingRule[] balancingRules in UniversalBalancingChanges) - { - foreach (IBalancingRule balancingRule in balancingRules) - { - if (balancingRule.AppliesTo(npc, modifiers, proj)) - balancingRule.ApplyBalancingChange(npc, ref modifiers); - } - } - - // As well as rules specific to NPCs. + // Apply NPC-specific balancing rules. foreach (NPCBalancingChange balanceChange in NPCSpecificBalancingChanges) { if (npc.type != balanceChange.NPCType) diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index 590cc74fcd..ec3d67b330 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -21,7 +21,8 @@ internal const float VanillaFrogLegJumpSpeedBoost = 1.6f; // Altered jump speed boost provided by Amphibian Boots via global item UpdateAccessory - internal static readonly float AmphibianBootsJumpSpeedBoost = 1f; + //doze 23apr2025 - Undid nerf, it's now the same as frog leg. If it's a problem, maybe retier it? + internal static readonly float AmphibianBootsJumpSpeedBoost = 1.6f; // 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. @@ -50,6 +51,7 @@ #region Dashes and Dodges // Dash cooldowns (in frames) internal const int UniversalDashCooldown = 30; + internal const int UniversalSashDashCooldown = 30; internal const int UniversalShieldSlamCooldown = 30; internal const int UniversalShieldBonkCooldown = 30; internal const int OnShieldBonkCooldown = 30; @@ -70,8 +72,6 @@ internal static readonly int AmalgamDodgeCooldownMax = 5400; internal static readonly int MirrorDodgeCooldownMin = 1200; internal static readonly int MirrorDodgeCooldownMax = 5400; - internal static readonly int DaedalusReflectCooldownMin = 1200; - internal static readonly int DaedalusReflectCooldownMax = 5400; internal static readonly int EvolutionReflectCooldownMin = 1200; internal static readonly int EvolutionReflectCooldownMax = 5400; #endregion @@ -115,54 +115,22 @@ #endregion #region Life Steal - // Life steal cap + // Life steal cap (Maximum HP healed per instance of lifesteal) internal static readonly int LifeStealCap = 100; - - // Life steal accessories require a more strict cooldown due to their ease of use and global application - internal static readonly float LifeStealAccessoryCooldownMultiplier = 3f; - // Life steal cooldown multipliers used for armor set bonuses - internal static readonly float LifeStealSetBonusCooldownMultiplier = 2f; - internal static readonly float LifeStealReaverTankCooldownMultiplier = 4f; - - // The range was buffed in vanilla from 1200 to 3000 in 1.4.4, and I agree with that decision - internal static readonly float LifeStealRange = 3000f; - - // Life steal caps (aka, how much life steal the player is allowed before it goes on cooldown) - internal static readonly float LifeStealCap_Classic = 60f; - internal static readonly float LifeStealCap_Expert = 50f; - internal static readonly float LifeStealCap_Revengeance = 40f; - internal static readonly float LifeStealCap_Death = 30f; - - // Master nerfs the life steal cap by 10, resulting in 40 in non-Rev Master, 30 in Rev Master, and 20 in Death Master - internal static readonly float LifeStealCapReduction_Master = 10f; + // Base life steal caps from vanilla (aka, how much life steal the player is allowed before it goes on cooldown) + internal static readonly float LifeStealCap_Classic = 80f; + internal static readonly float LifeStealCap_Expert = 70f; // The base life steal cooldowns from vanilla internal static readonly float LifeStealRecoveryRate_Classic = 0.6f; internal static readonly float LifeStealRecoveryRate_Expert = 0.5f; - // The calculations below show the time (in frames) for 10 life steal cooldown to recover in each difficulty - // Classic: 10 / 0.2 = 50 - // Expert: 10 / 0.15 = 66.667 - // Revengeance: 10 / 0.125 = 80 - // Death: 10 / 0.1 = 100 - // Master: 10 / 0.1 = 100 - // Revengeance Master: 10 / 0.075 = 133.333 - // Death Master: 10 / 0.05 = 200 - // Nerfs the life steal recovery rate in Classic from 0.6/s to 0.2/s + // Nerfs the life steal recovery rate in Classic from 0.6 to 0.2 (36 HP/s to 12 HP/s) internal static readonly float LifeStealRecoveryRateReduction_Classic = 0.4f; - // Nerfs the life steal recovery rate in Expert from 0.5/s to 0.15/s + // Nerfs the life steal recovery rate in Expert from 0.5 to 0.15 (30 HP/s to 9 HP/s) internal static readonly float LifeStealRecoveryRateReduction_Expert = 0.35f; - - // Nerfs the life steal recovery rate in Revengeance from 0.5/s to 0.125/s - internal static readonly float LifeStealRecoveryRateReduction_Revengeance = 0.375f; - - // Nerfs the life steal recovery rate in Death from 0.5/s to 0.1/s - internal static readonly float LifeStealRecoveryRateReduction_Death = 0.4f; - - // Nerfs the life steal recovery rate in Master by 0.05/s, resulting in 0.1/s in non-Rev Master, 0.075/s in Rev Master, and 0.05/s in Death Master - internal static readonly float LifeStealRecoveryRateReduction_Master = 0.05f; #endregion #region Rogue Base Stats @@ -241,6 +209,16 @@ internal static readonly float TrueMeleeRipperReductionFactor = 0.5f; // True melee benefits less from rippers to prevent excessive melting. #endregion + #region Pierce Resistance + // Both of the below variables only apply when an NPC has universal pierce resistance enabled via attribute. + // Projectiles may be marked as exempt from this pierce resistance by using an attribute. + + /// Constant variable used to determine the percentage a projectile's damage is reduced by pierce resist on each hit. + public const float PierceResistHarshness = 0.12f; + /// Constant variable used to determine the maximum percentage a projectile's damage can be reduced by pierce resist. + public const float PierceResistCap = 0.8f; + #endregion + // TODO -- NPC classification is not done consistently with predictable thresholds. // These variables should be used in general to classify "enemies" vs "non-enemies" as well. // See NPCUtils.IsAnEnemy @@ -252,6 +230,13 @@ internal const int UnreasonableHealthThreshold = 25000000; // 25 million #endregion + #region Multiplayer Boss Health Scaling Overrides + // These values are used to replace the vanilla 1.35f and 1.9166666666666666f for the 2-player and 3-player cases, respectively. + // Editing them via reflection or otherwise will apply to newly spawned bosses during gameplay. + public static float ExpertHealthScalingOverride_2Players = 1.75f; + public static float ExpertHealthScalingOverride_3Players = 2.25f; + #endregion + // TODO -- Add all balance related constants here that don't belong in other files. // Review all constants and static readonlys in the entire mod to find things to add. } diff --git a/Balancing/BalancingRules.cs b/Balancing/BalancingRules.cs index 1a033282ab..1f042296c8 100644 --- a/Balancing/BalancingRules.cs +++ b/Balancing/BalancingRules.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using Terraria; using Terraria.ModLoader; diff --git a/BiomeManagers/AbyssLayer1Biome.cs b/BiomeManagers/AbyssLayer1Biome.cs index 8d852ea389..90b8a31632 100644 --- a/BiomeManagers/AbyssLayer1Biome.cs +++ b/BiomeManagers/AbyssLayer1Biome.cs @@ -1,5 +1,5 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Placeables.FurnitureAbyss; +using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Systems; using CalamityMod.Waters; using CalamityMod.World; @@ -48,7 +48,7 @@ namespace CalamityMod.BiomeManagers // Temporarily use sulphur for now public override ModWaterStyle WaterStyle => SulphuricDepthsWater.Instance; - public override int BiomeTorchItemType => ModContent.ItemType(); + public override int BiomeTorchItemType => ModContent.ItemType(); public override SceneEffectPriority Priority => SceneEffectPriority.Environment; public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer1Icon"; public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; diff --git a/BiomeManagers/AbyssLayer2Biome.cs b/BiomeManagers/AbyssLayer2Biome.cs index 7f520a6835..6afa10e76b 100644 --- a/BiomeManagers/AbyssLayer2Biome.cs +++ b/BiomeManagers/AbyssLayer2Biome.cs @@ -1,5 +1,5 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Placeables.FurnitureAbyss; +using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Systems; using CalamityMod.Waters; using CalamityMod.World; @@ -22,7 +22,7 @@ namespace CalamityMod.BiomeManagers } public override ModWaterStyle WaterStyle => UpperAbyssWater.Instance; - public override int BiomeTorchItemType => ModContent.ItemType(); + public override int BiomeTorchItemType => ModContent.ItemType(); public override SceneEffectPriority Priority => SceneEffectPriority.Environment; public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer2Icon"; public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer23"; diff --git a/BiomeManagers/AbyssLayer3Biome.cs b/BiomeManagers/AbyssLayer3Biome.cs index f9ad0fc426..f03fc82fa4 100644 --- a/BiomeManagers/AbyssLayer3Biome.cs +++ b/BiomeManagers/AbyssLayer3Biome.cs @@ -1,5 +1,5 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Placeables.FurnitureAbyss; +using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Systems; using CalamityMod.Waters; using CalamityMod.World; @@ -17,12 +17,17 @@ namespace CalamityMod.BiomeManagers { if (CalamityPlayer.areThereAnyDamnBosses) return Main.curMusic; - return CalamityMod.Instance.GetMusicFromMusicMod("AbyssLayer3") ?? MusicID.Hell; + + int? musicSlot = CalamityClientConfig.Instance.AbyssLayer3Alt ? + CalamityMod.Instance.GetMusicFromMusicMod("AbyssLayer3Alt") : + CalamityMod.Instance.GetMusicFromMusicMod("AbyssLayer3"); + + return musicSlot ?? MusicID.Hell; } } public override ModWaterStyle WaterStyle => MiddleAbyssWater.Instance; - public override int BiomeTorchItemType => ModContent.ItemType(); + public override int BiomeTorchItemType => ModContent.ItemType(); public override SceneEffectPriority Priority => SceneEffectPriority.Environment; public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer3Icon"; public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer23"; diff --git a/BiomeManagers/AbyssLayer4Biome.cs b/BiomeManagers/AbyssLayer4Biome.cs index 8a2de62e0e..8ade64a46e 100644 --- a/BiomeManagers/AbyssLayer4Biome.cs +++ b/BiomeManagers/AbyssLayer4Biome.cs @@ -1,5 +1,5 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Placeables.FurnitureAbyss; +using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Systems; using CalamityMod.Waters; using CalamityMod.World; @@ -22,7 +22,7 @@ namespace CalamityMod.BiomeManagers } public override ModWaterStyle WaterStyle => VoidWater.Instance; - public override int BiomeTorchItemType => ModContent.ItemType(); + public override int BiomeTorchItemType => ModContent.ItemType(); public override SceneEffectPriority Priority => SceneEffectPriority.Environment; public override string BestiaryIcon => "CalamityMod/BiomeManagers/AbyssLayer4Icon"; public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer4"; diff --git a/BiomeManagers/BasaltGullyBiome.cs b/BiomeManagers/BasaltGullyBiome.cs index 5f4b388829..f5642e3647 100644 --- a/BiomeManagers/BasaltGullyBiome.cs +++ b/BiomeManagers/BasaltGullyBiome.cs @@ -1,9 +1,33 @@ -using Terraria.ModLoader; +using CalamityMod.Systems; +using CalamityMod.Waters; +using Terraria.ID; +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Items.Placeables.Furniture; namespace CalamityMod.BiomeManagers { public class BasaltGullyBiome : ModBiome { + public override ModWaterStyle WaterStyle => SunkenSeaBurrowsWater.Instance; + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/SunkenSeaBGStyle"); + public override int BiomeTorchItemType => ModContent.ItemType(); + public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; + public override SceneEffectPriority Priority => SceneEffectPriority.Environment; + public override string BestiaryIcon => "CalamityMod/BiomeManagers/SunkenSeaIcon"; + // Placeholder until we get a dedicated Basalt Gully background + public override string BackgroundPath => "Terraria/Images/MapBG3"; + public override string MapBackground => "Terraria/Images/MapBG3"; + public override bool IsBiomeActive(Player player) + { + bool MoreThanShores = BiomeTileCounterSystem.SunkenSeaBasaltTiles > BiomeTileCounterSystem.SunkenSeaShoresTiles; + bool MoreThanReefs = BiomeTileCounterSystem.SunkenSeaBasaltTiles > BiomeTileCounterSystem.SunkenSeaReefsTiles; + bool MoreThanPolyp = BiomeTileCounterSystem.SunkenSeaBasaltTiles > BiomeTileCounterSystem.SunkenSeaPolypTiles; + bool MoreThanBurrows = BiomeTileCounterSystem.SunkenSeaBasaltTiles > BiomeTileCounterSystem.SunkenSeaBurrowsTiles; + bool MoreThanUnderground = BiomeTileCounterSystem.SunkenSeaShoresTiles > BiomeTileCounterSystem.UndergroundTiles; + + return BiomeTileCounterSystem.SunkenSeaBasaltTiles > 2500 && (MoreThanShores || MoreThanReefs || MoreThanPolyp || MoreThanBurrows); + } } } diff --git a/BiomeManagers/BestiaryCategories/AcidRainBiome.cs b/BiomeManagers/BestiaryCategories/AcidRainBiome.cs index 40b4708e6e..023354d2c2 100644 --- a/BiomeManagers/BestiaryCategories/AcidRainBiome.cs +++ b/BiomeManagers/BestiaryCategories/AcidRainBiome.cs @@ -1,6 +1,5 @@ //using CalamityMod.Systems; -using Terraria; -using Terraria.ID; + using Terraria.ModLoader; namespace CalamityMod.BiomeManagers diff --git a/BiomeManagers/BestiaryCategories/AstralCaveDesert.cs b/BiomeManagers/BestiaryCategories/AstralCaveDesert.cs index 8f7d2a9a30..a7d599d6c6 100644 --- a/BiomeManagers/BestiaryCategories/AstralCaveDesert.cs +++ b/BiomeManagers/BestiaryCategories/AstralCaveDesert.cs @@ -7,5 +7,6 @@ namespace CalamityMod.BiomeManagers.BestiaryCategories public override string BestiaryIcon => "CalamityMod/BiomeManagers/AstralCaveDesertIcon"; public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; } } diff --git a/BiomeManagers/BestiaryCategories/AstralDesert.cs b/BiomeManagers/BestiaryCategories/AstralDesert.cs index 29b0a3f907..12450ebde2 100644 --- a/BiomeManagers/BestiaryCategories/AstralDesert.cs +++ b/BiomeManagers/BestiaryCategories/AstralDesert.cs @@ -7,5 +7,6 @@ namespace CalamityMod.BiomeManagers.BestiaryCategories public override string BestiaryIcon => "CalamityMod/BiomeManagers/AstralDesertIcon"; public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; } } diff --git a/BiomeManagers/BestiaryCategories/AstralUnderground.cs b/BiomeManagers/BestiaryCategories/AstralUnderground.cs index 42d924fd5b..0b3c7b2090 100644 --- a/BiomeManagers/BestiaryCategories/AstralUnderground.cs +++ b/BiomeManagers/BestiaryCategories/AstralUnderground.cs @@ -7,5 +7,6 @@ namespace CalamityMod.BiomeManagers.BestiaryCategories public override string BestiaryIcon => "CalamityMod/BiomeManagers/UndergroundAstralIcon"; public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AstralBG"; } } diff --git a/BiomeManagers/BrimstoneCragsBiome.cs b/BiomeManagers/BrimstoneCragsBiome.cs index 4a621108bb..218c9c600e 100644 --- a/BiomeManagers/BrimstoneCragsBiome.cs +++ b/BiomeManagers/BrimstoneCragsBiome.cs @@ -16,7 +16,7 @@ namespace CalamityMod.BiomeManagers public override bool IsBiomeActive(Player player) { - return BiomeTileCounterSystem.BrimstoneCragTiles > 100 && player.ZoneUnderworldHeight; + return BiomeTileCounterSystem.BrimstoneCragTiles > 500 && player.ZoneUnderworldHeight; } } } diff --git a/BiomeManagers/ClamDenBiome.cs b/BiomeManagers/ClamDenBiome.cs new file mode 100644 index 0000000000..f4d06835a9 --- /dev/null +++ b/BiomeManagers/ClamDenBiome.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Systems; +using CalamityMod.Waters; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers +{ + public class ClamDenBiome : ModBiome + { + public override ModWaterStyle WaterStyle => SunkenSeaBurrowsWater.Instance; + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/SunkenSeaBGStyle"); + public override int BiomeTorchItemType => ModContent.ItemType(); + public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; + public override SceneEffectPriority Priority => SceneEffectPriority.Environment; + public override string BestiaryIcon => "CalamityMod/BiomeManagers/SunkenSeaIcon"; + // Placeholder until we get a dedicated Sunken Sea background + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + + // todo make this condition different than the normal burrows + public override bool IsBiomeActive(Player player) + { + bool MoreThanReefs = BiomeTileCounterSystem.SunkenSeaBurrowsTiles > BiomeTileCounterSystem.SunkenSeaReefsTiles; + bool MoreThanPolyp = BiomeTileCounterSystem.SunkenSeaBurrowsTiles > BiomeTileCounterSystem.SunkenSeaPolypTiles; + + return BiomeTileCounterSystem.SunkenSeaBurrowsTiles > 1000 && MoreThanReefs && MoreThanPolyp; + } + } +} diff --git a/BiomeManagers/FloralParadiseBiome.cs b/BiomeManagers/FloralParadiseBiome.cs deleted file mode 100644 index bfe9d45095..0000000000 --- a/BiomeManagers/FloralParadiseBiome.cs +++ /dev/null @@ -1,19 +0,0 @@ -using CalamityMod.Systems; -using CalamityMod.Waters; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.BiomeManagers -{ - public class FloralParadiseBiome : ModBiome - { - public override ModWaterStyle WaterStyle => FloralParadiseWater.Instance; - public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/FloralParadiseBGStyle"); - public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; - - public override bool IsBiomeActive(Player player) - { - return BiomeTileCounterSystem.FloralParadiseTiles >= 300; - } - } -} diff --git a/BiomeManagers/GleamingBurrowsBiome.cs b/BiomeManagers/GleamingBurrowsBiome.cs index 94bd09ac08..bfcc61c206 100644 --- a/BiomeManagers/GleamingBurrowsBiome.cs +++ b/BiomeManagers/GleamingBurrowsBiome.cs @@ -24,7 +24,7 @@ namespace CalamityMod.BiomeManagers bool MoreThanReefs = BiomeTileCounterSystem.SunkenSeaBurrowsTiles > BiomeTileCounterSystem.SunkenSeaReefsTiles; bool MoreThanPolyp = BiomeTileCounterSystem.SunkenSeaBurrowsTiles > BiomeTileCounterSystem.SunkenSeaPolypTiles; - return BiomeTileCounterSystem.SunkenSeaBurrowsTiles > 1000 && MoreThanReefs && MoreThanPolyp; + return BiomeTileCounterSystem.SunkenSeaBurrowsTiles > 3000 && MoreThanReefs && MoreThanPolyp; } } } diff --git a/BiomeManagers/PolypForestBiome.cs b/BiomeManagers/PolypForestBiome.cs index b440b5d7a9..564264d40e 100644 --- a/BiomeManagers/PolypForestBiome.cs +++ b/BiomeManagers/PolypForestBiome.cs @@ -24,7 +24,7 @@ namespace CalamityMod.BiomeManagers bool MoreThanReefs = BiomeTileCounterSystem.SunkenSeaPolypTiles > BiomeTileCounterSystem.SunkenSeaReefsTiles; bool MoreThanBurrows = BiomeTileCounterSystem.SunkenSeaPolypTiles > BiomeTileCounterSystem.SunkenSeaBurrowsTiles; - return BiomeTileCounterSystem.SunkenSeaPolypTiles > 1000 && MoreThanReefs && MoreThanBurrows; + return BiomeTileCounterSystem.SunkenSeaPolypTiles > 200 && MoreThanReefs && MoreThanBurrows; } } } diff --git a/BiomeManagers/RadiantReefsBiome.cs b/BiomeManagers/RadiantReefsBiome.cs index 7dd90a03fb..c613bfbf67 100644 --- a/BiomeManagers/RadiantReefsBiome.cs +++ b/BiomeManagers/RadiantReefsBiome.cs @@ -21,10 +21,12 @@ namespace CalamityMod.BiomeManagers public override bool IsBiomeActive(Player player) { - bool MoreThanBurrows = BiomeTileCounterSystem.SunkenSeaReefsTiles > BiomeTileCounterSystem.SunkenSeaBurrowsTiles; + bool MoreThanShores = BiomeTileCounterSystem.SunkenSeaReefsTiles > BiomeTileCounterSystem.SunkenSeaShoresTiles; bool MoreThanPolyp = BiomeTileCounterSystem.SunkenSeaReefsTiles > BiomeTileCounterSystem.SunkenSeaPolypTiles; + bool MoreThanBurrows = BiomeTileCounterSystem.SunkenSeaReefsTiles > BiomeTileCounterSystem.SunkenSeaBurrowsTiles; + bool MoreThanBasalt = BiomeTileCounterSystem.SunkenSeaReefsTiles > BiomeTileCounterSystem.SunkenSeaBasaltTiles; - return BiomeTileCounterSystem.SunkenSeaReefsTiles > 1000 && MoreThanBurrows && MoreThanPolyp; + return ((BiomeTileCounterSystem.SunkenSeaReefsTiles > 2000) && MoreThanBasalt && MoreThanBurrows && MoreThanPolyp && MoreThanShores); } } } diff --git a/BiomeManagers/SulphurousSeaBiome.cs b/BiomeManagers/SulphurousSeaBiome.cs index 0ca4be3feb..d5a03402cc 100644 --- a/BiomeManagers/SulphurousSeaBiome.cs +++ b/BiomeManagers/SulphurousSeaBiome.cs @@ -1,5 +1,4 @@ -using System.Security.Policy; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Systems; @@ -64,27 +63,32 @@ namespace CalamityMod.BiomeManagers public override bool IsBiomeActive(Player player) { Point point = player.Center.ToTileCoordinates(); + return BiomeTileCounterSystem.SulphurTiles >= 300 || IsInBiomePosition(point) && !player.Calamity().ZoneAbyss; + } + + public static bool IsInBiomePosition(Point tilePos) + { bool sulphurPosX = false; if (Abyss.AtLeftSideOfWorld) { - if (point.X < 435) + if (tilePos.X < 435) { sulphurPosX = true; } } else { - if (point.X > Main.maxTilesX - 435) + if (tilePos.X > Main.maxTilesX - 435) { sulphurPosX = true; } } if (Main.remixWorld) - return (BiomeTileCounterSystem.SulphurTiles >= 300 || (point.Y > SulphurousSea.YStart && point.Y < Main.UnderworldLayer && sulphurPosX && !WeakReferenceSupport.InAnySubworld())) && !player.Calamity().ZoneAbyss; + return tilePos.Y > SulphurousSea.YStart && tilePos.Y < Main.UnderworldLayer && sulphurPosX && !WeakReferenceSupport.InAnySubworld(); - return (BiomeTileCounterSystem.SulphurTiles >= 300 || (point.Y < (Main.rockLayer - Main.maxTilesY / 13) && sulphurPosX && !WeakReferenceSupport.InAnySubworld())) && !player.Calamity().ZoneAbyss; + return tilePos.Y < (Main.rockLayer - Main.maxTilesY / 13) && sulphurPosX && !WeakReferenceSupport.InAnySubworld(); } public override void SpecialVisuals(Player player, bool isActive) diff --git a/BiomeManagers/SunkenSeaBiome.cs b/BiomeManagers/SunkenSeaBiome.cs index 8db1305e22..02d7bf8488 100644 --- a/BiomeManagers/SunkenSeaBiome.cs +++ b/BiomeManagers/SunkenSeaBiome.cs @@ -1,12 +1,8 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; -using Terraria.Graphics.Light; -using Microsoft.Xna.Framework; using System; using Mono.Cecil.Cil; using MonoMod.Cil; -using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Systems; namespace CalamityMod.BiomeManagers diff --git a/BiomeManagers/TimelessShoresBiome.cs b/BiomeManagers/TimelessShoresBiome.cs index cb44c6cdc8..66e93668fd 100644 --- a/BiomeManagers/TimelessShoresBiome.cs +++ b/BiomeManagers/TimelessShoresBiome.cs @@ -21,10 +21,11 @@ namespace CalamityMod.BiomeManagers public override bool IsBiomeActive(Player player) { - bool MoreThanPolyp = BiomeTileCounterSystem.SunkenSeaShoresTiles > BiomeTileCounterSystem.SunkenSeaPolypTiles; bool MoreThanReefs = BiomeTileCounterSystem.SunkenSeaShoresTiles > BiomeTileCounterSystem.SunkenSeaReefsTiles; + bool MoreThanBasalt = BiomeTileCounterSystem.SunkenSeaShoresTiles > BiomeTileCounterSystem.SunkenSeaBasaltTiles; + bool MoreThanUnderground = BiomeTileCounterSystem.SunkenSeaShoresTiles > BiomeTileCounterSystem.UndergroundTiles; - return BiomeTileCounterSystem.SunkenSeaShoresTiles > 1000 && MoreThanPolyp && MoreThanReefs; + return (BiomeTileCounterSystem.SunkenSeaShoresTiles > 1200) && MoreThanReefs && MoreThanBasalt && MoreThanUnderground; } } } diff --git a/Buffs/Alcohol/AlcoholPoisoning.cs b/Buffs/Alcohol/AlcoholPoisoning.cs index 1461d14361..c1736b0e64 100644 --- a/Buffs/Alcohol/AlcoholPoisoning.cs +++ b/Buffs/Alcohol/AlcoholPoisoning.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Buffs.Alcohol diff --git a/Buffs/Alcohol/BloodyMaryBuff.cs b/Buffs/Alcohol/BloodyMaryBuff.cs index fab06df0f3..af35461b47 100644 --- a/Buffs/Alcohol/BloodyMaryBuff.cs +++ b/Buffs/Alcohol/BloodyMaryBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/BloodyMaryBuff.png b/Buffs/Alcohol/BloodyMaryBuff.png index 46cf3a0b57..40355f1d96 100644 Binary files a/Buffs/Alcohol/BloodyMaryBuff.png and b/Buffs/Alcohol/BloodyMaryBuff.png differ diff --git a/Buffs/Alcohol/CaribbeanRumBuff.cs b/Buffs/Alcohol/CaribbeanRumBuff.cs index f20c460c74..fcdb6422b6 100644 --- a/Buffs/Alcohol/CaribbeanRumBuff.cs +++ b/Buffs/Alcohol/CaribbeanRumBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/CaribbeanRumBuff.png b/Buffs/Alcohol/CaribbeanRumBuff.png index c3e5464b05..3996666a07 100644 Binary files a/Buffs/Alcohol/CaribbeanRumBuff.png and b/Buffs/Alcohol/CaribbeanRumBuff.png differ diff --git a/Buffs/Alcohol/CinnamonRollBuff.cs b/Buffs/Alcohol/CinnamonRollBuff.cs index 3d4daff7ea..bb724a3a52 100644 --- a/Buffs/Alcohol/CinnamonRollBuff.cs +++ b/Buffs/Alcohol/CinnamonRollBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/CinnamonRollBuff.png b/Buffs/Alcohol/CinnamonRollBuff.png index 8d9ff66e26..a1a2c0ae34 100644 Binary files a/Buffs/Alcohol/CinnamonRollBuff.png and b/Buffs/Alcohol/CinnamonRollBuff.png differ diff --git a/Buffs/Alcohol/CirrusVodkaBuff.cs b/Buffs/Alcohol/CirrusVodkaBuff.cs deleted file mode 100644 index cf33f6dd41..0000000000 --- a/Buffs/Alcohol/CirrusVodkaBuff.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Alcohol -{ - public class CirrusVodkaBuff : ModBuff - { - public override void SetStaticDefaults() - { - Main.debuff[Type] = true; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = false; - BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().cirrusVodka = true; - } - } -} diff --git a/Buffs/Alcohol/EverclearBuff.cs b/Buffs/Alcohol/EverclearBuff.cs index eed852d449..1629143a7f 100644 --- a/Buffs/Alcohol/EverclearBuff.cs +++ b/Buffs/Alcohol/EverclearBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/EverclearBuff.png b/Buffs/Alcohol/EverclearBuff.png index fde2031fa3..3f275ba54f 100644 Binary files a/Buffs/Alcohol/EverclearBuff.png and b/Buffs/Alcohol/EverclearBuff.png differ diff --git a/Buffs/Alcohol/EvergreenGinBuff.cs b/Buffs/Alcohol/EvergreenGinBuff.cs index 26f9f2d161..1821638bad 100644 --- a/Buffs/Alcohol/EvergreenGinBuff.cs +++ b/Buffs/Alcohol/EvergreenGinBuff.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Potions.Alcohol; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,12 +12,18 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().evergreenGin = true; + var cplayer = player.Calamity(); + cplayer.evergreenGin = true; + cplayer.SicknessDebuffMultiplier += EvergreenGin.DebuffBoost; + cplayer.WaterDebuffMultiplier += EvergreenGin.DebuffBoost; + cplayer.ElectricDebuffMultiplier -= EvergreenGin.DebuffLoss; + cplayer.HeatDebuffMultiplier -= EvergreenGin.DebuffLoss; } } } diff --git a/Buffs/Alcohol/EvergreenGinBuff.png b/Buffs/Alcohol/EvergreenGinBuff.png index 5e41d87eb6..f7e2133cd3 100644 Binary files a/Buffs/Alcohol/EvergreenGinBuff.png and b/Buffs/Alcohol/EvergreenGinBuff.png differ diff --git a/Buffs/Alcohol/FireballBuff.cs b/Buffs/Alcohol/FireballBuff.cs index aa2e9e9f96..99c877dc50 100644 --- a/Buffs/Alcohol/FireballBuff.cs +++ b/Buffs/Alcohol/FireballBuff.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Potions.Alcohol; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,12 +12,16 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().fireball = true; + var cplayer = player.Calamity(); + cplayer.fireball = true; + cplayer.HeatDebuffMultiplier += Fireball.DebuffBoost; + cplayer.SicknessDebuffMultiplier -= Fireball.DebuffLoss; } } } diff --git a/Buffs/Alcohol/FireballBuff.png b/Buffs/Alcohol/FireballBuff.png index 8887354d3f..a81dcc472f 100644 Binary files a/Buffs/Alcohol/FireballBuff.png and b/Buffs/Alcohol/FireballBuff.png differ diff --git a/Buffs/Alcohol/GrapeBeerBuff.cs b/Buffs/Alcohol/GrapeBeerBuff.cs index bc2c68c76f..83504af851 100644 --- a/Buffs/Alcohol/GrapeBeerBuff.cs +++ b/Buffs/Alcohol/GrapeBeerBuff.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Potions.Alcohol; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,12 +12,15 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().grapeBeer = true; + var cplayer = player.Calamity(); + cplayer.grapeBeer = true; + cplayer.critDamage -= GrapeBeer.CritLoss * 0.01f; } } } diff --git a/Buffs/Alcohol/GrapeBeerBuff.png b/Buffs/Alcohol/GrapeBeerBuff.png index d951249d12..258910c643 100644 Binary files a/Buffs/Alcohol/GrapeBeerBuff.png and b/Buffs/Alcohol/GrapeBeerBuff.png differ diff --git a/Buffs/Alcohol/ManhattanBuff.cs b/Buffs/Alcohol/ManhattanBuff.cs new file mode 100644 index 0000000000..e724375c25 --- /dev/null +++ b/Buffs/Alcohol/ManhattanBuff.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Potions.Alcohol; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Alcohol +{ + public class ManhattanBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; + BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + var cplayer = player.Calamity(); + cplayer.ColdDebuffMultiplier += Manhattan.DebuffBoost; + cplayer.WaterDebuffMultiplier -= Manhattan.DebuffLoss; + } + } +} diff --git a/Buffs/Alcohol/ManhattanBuff.png b/Buffs/Alcohol/ManhattanBuff.png new file mode 100644 index 0000000000..8d3c026da5 Binary files /dev/null and b/Buffs/Alcohol/ManhattanBuff.png differ diff --git a/Buffs/Alcohol/MargaritaBuff.cs b/Buffs/Alcohol/MargaritaBuff.cs index fb43c678dc..37299b4fb8 100644 --- a/Buffs/Alcohol/MargaritaBuff.cs +++ b/Buffs/Alcohol/MargaritaBuff.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Potions.Alcohol; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,12 +12,20 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().margarita = true; + var cplayer = player.Calamity(); + cplayer.margarita = true; + cplayer.HeatDebuffMultiplier -= Margarita.DebuffLoss; + cplayer.SicknessDebuffMultiplier -= Margarita.DebuffLoss; + cplayer.ColdDebuffMultiplier -= Margarita.DebuffLoss; + cplayer.WaterDebuffMultiplier -= Margarita.DebuffLoss; + cplayer.ElectricDebuffMultiplier -= Margarita.DebuffLoss; + cplayer.TypelessDebuffMultiplier -= Margarita.DebuffLoss; } } } diff --git a/Buffs/Alcohol/MargaritaBuff.png b/Buffs/Alcohol/MargaritaBuff.png index 068aebf1e0..94de724886 100644 Binary files a/Buffs/Alcohol/MargaritaBuff.png and b/Buffs/Alcohol/MargaritaBuff.png differ diff --git a/Buffs/Alcohol/MoonshineBuff.cs b/Buffs/Alcohol/MoonshineBuff.cs index d9ce511042..03faabe66d 100644 --- a/Buffs/Alcohol/MoonshineBuff.cs +++ b/Buffs/Alcohol/MoonshineBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/MoonshineBuff.png b/Buffs/Alcohol/MoonshineBuff.png index b079231309..028834ea24 100644 Binary files a/Buffs/Alcohol/MoonshineBuff.png and b/Buffs/Alcohol/MoonshineBuff.png differ diff --git a/Buffs/Alcohol/MoscowMuleBuff.cs b/Buffs/Alcohol/MoscowMuleBuff.cs index 577fe35a1c..21f7569480 100644 --- a/Buffs/Alcohol/MoscowMuleBuff.cs +++ b/Buffs/Alcohol/MoscowMuleBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/MoscowMuleBuff.png b/Buffs/Alcohol/MoscowMuleBuff.png index 4ba5245776..a9cf2f5a18 100644 Binary files a/Buffs/Alcohol/MoscowMuleBuff.png and b/Buffs/Alcohol/MoscowMuleBuff.png differ diff --git a/Buffs/Alcohol/OldFashionedBuff.cs b/Buffs/Alcohol/OldFashionedBuff.cs index 1f059a26d5..68820059d4 100644 --- a/Buffs/Alcohol/OldFashionedBuff.cs +++ b/Buffs/Alcohol/OldFashionedBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/OldFashionedBuff.png b/Buffs/Alcohol/OldFashionedBuff.png index 2b6e8fdaf0..a3ba916b88 100644 Binary files a/Buffs/Alcohol/OldFashionedBuff.png and b/Buffs/Alcohol/OldFashionedBuff.png differ diff --git a/Buffs/Alcohol/PurpleHazeBuff.cs b/Buffs/Alcohol/PurpleHazeBuff.cs new file mode 100644 index 0000000000..16aa30d53f --- /dev/null +++ b/Buffs/Alcohol/PurpleHazeBuff.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Alcohol +{ + public class PurpleHazeBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; + BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().purpleHaze = true; + } + } +} diff --git a/Buffs/Alcohol/CirrusVodkaBuff.png b/Buffs/Alcohol/PurpleHazeBuff.png similarity index 100% rename from Buffs/Alcohol/CirrusVodkaBuff.png rename to Buffs/Alcohol/PurpleHazeBuff.png diff --git a/Buffs/Alcohol/RedWineBuff.cs b/Buffs/Alcohol/RedWineBuff.cs index bad080168d..087086ca68 100644 --- a/Buffs/Alcohol/RedWineBuff.cs +++ b/Buffs/Alcohol/RedWineBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/RedWineBuff.png b/Buffs/Alcohol/RedWineBuff.png index a3e116c717..556b48d8fc 100644 Binary files a/Buffs/Alcohol/RedWineBuff.png and b/Buffs/Alcohol/RedWineBuff.png differ diff --git a/Buffs/Alcohol/RumBuff.cs b/Buffs/Alcohol/RumBuff.cs index dac1bd0d2a..ab842e0649 100644 --- a/Buffs/Alcohol/RumBuff.cs +++ b/Buffs/Alcohol/RumBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/RumBuff.png b/Buffs/Alcohol/RumBuff.png index 29f7cd9fda..e43b540c7a 100644 Binary files a/Buffs/Alcohol/RumBuff.png and b/Buffs/Alcohol/RumBuff.png differ diff --git a/Buffs/Alcohol/ScrewdriverBuff.cs b/Buffs/Alcohol/ScrewdriverBuff.cs index 1487717507..f8f97cd0fe 100644 --- a/Buffs/Alcohol/ScrewdriverBuff.cs +++ b/Buffs/Alcohol/ScrewdriverBuff.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Potions.Alcohol; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,12 +12,17 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { player.Calamity().screwdriver = true; + player.blockRange += 5; + player.tileSpeed += 1; + player.wallSpeed += 1; + player.GetDamage(DamageClass.Generic) *= 0.75f; } } } diff --git a/Buffs/Alcohol/ScrewdriverBuff.png b/Buffs/Alcohol/ScrewdriverBuff.png index 2c0984bc98..4d24f45ebd 100644 Binary files a/Buffs/Alcohol/ScrewdriverBuff.png and b/Buffs/Alcohol/ScrewdriverBuff.png differ diff --git a/Buffs/Alcohol/StarBeamRyeBuff.cs b/Buffs/Alcohol/StarBeamRyeBuff.cs index e8dde8ea60..50d6ac0bc8 100644 --- a/Buffs/Alcohol/StarBeamRyeBuff.cs +++ b/Buffs/Alcohol/StarBeamRyeBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/StarBeamRyeBuff.png b/Buffs/Alcohol/StarBeamRyeBuff.png index e678986953..f93dc9cfec 100644 Binary files a/Buffs/Alcohol/StarBeamRyeBuff.png and b/Buffs/Alcohol/StarBeamRyeBuff.png differ diff --git a/Buffs/Alcohol/TequilaBuff.cs b/Buffs/Alcohol/TequilaBuff.cs index ac8b8cb4c0..a2b307c605 100644 --- a/Buffs/Alcohol/TequilaBuff.cs +++ b/Buffs/Alcohol/TequilaBuff.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Potions.Alcohol; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,12 +12,16 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().tequila = true; + var cplayer = player.Calamity(); + cplayer.tequila = true; + cplayer.ElectricDebuffMultiplier += Tequila.DebuffBoost; + cplayer.ColdDebuffMultiplier -= Tequila.DebuffLoss; } } } diff --git a/Buffs/Alcohol/TequilaBuff.png b/Buffs/Alcohol/TequilaBuff.png index a6c233e3d1..ea4d7ed14a 100644 Binary files a/Buffs/Alcohol/TequilaBuff.png and b/Buffs/Alcohol/TequilaBuff.png differ diff --git a/Buffs/Alcohol/TequilaSunriseBuff.cs b/Buffs/Alcohol/TequilaSunriseBuff.cs index 1fd115ce63..af5a5f174a 100644 --- a/Buffs/Alcohol/TequilaSunriseBuff.cs +++ b/Buffs/Alcohol/TequilaSunriseBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/TequilaSunriseBuff.png b/Buffs/Alcohol/TequilaSunriseBuff.png index ef5bee8678..9d36c9250e 100644 Binary files a/Buffs/Alcohol/TequilaSunriseBuff.png and b/Buffs/Alcohol/TequilaSunriseBuff.png differ diff --git a/Buffs/Alcohol/Trippy.cs b/Buffs/Alcohol/Trippy.cs index 21b5357e8e..e791bdd796 100644 --- a/Buffs/Alcohol/Trippy.cs +++ b/Buffs/Alcohol/Trippy.cs @@ -1,14 +1,10 @@ -using CalamityMod.Items.Potions.Alcohol; -using Terraria; -using Terraria.Localization; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Buffs.Alcohol { public class Trippy : ModBuff { - public override LocalizedText Description => base.Description.WithFormatArgs(OddMushroom.DamageBoost.ToPercent()); - public override void SetStaticDefaults() { Main.debuff[Type] = false; diff --git a/Buffs/Alcohol/VodkaBuff.cs b/Buffs/Alcohol/VodkaBuff.cs index 851c0cecca..46eaee8329 100644 --- a/Buffs/Alcohol/VodkaBuff.cs +++ b/Buffs/Alcohol/VodkaBuff.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Potions.Alcohol; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,12 +12,20 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().vodka = true; + var cplayer = player.Calamity(); + cplayer.vodka = true; + cplayer.TypelessDebuffMultiplier += Vodka.DebuffBoost; + cplayer.HeatDebuffMultiplier -= Vodka.DebuffLoss; + cplayer.ColdDebuffMultiplier -= Vodka.DebuffLoss; + cplayer.SicknessDebuffMultiplier -= Vodka.DebuffLoss; + cplayer.WaterDebuffMultiplier -= Vodka.DebuffLoss; + cplayer.ElectricDebuffMultiplier -= Vodka.DebuffLoss; } } } diff --git a/Buffs/Alcohol/VodkaBuff.png b/Buffs/Alcohol/VodkaBuff.png index 485745f805..ba5666ddbc 100644 Binary files a/Buffs/Alcohol/VodkaBuff.png and b/Buffs/Alcohol/VodkaBuff.png differ diff --git a/Buffs/Alcohol/WhiskeyBuff.cs b/Buffs/Alcohol/WhiskeyBuff.cs index a496f75f18..66be5a8a0c 100644 --- a/Buffs/Alcohol/WhiskeyBuff.cs +++ b/Buffs/Alcohol/WhiskeyBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/WhiskeyBuff.png b/Buffs/Alcohol/WhiskeyBuff.png index 56f2662420..fce1a5403b 100644 Binary files a/Buffs/Alcohol/WhiskeyBuff.png and b/Buffs/Alcohol/WhiskeyBuff.png differ diff --git a/Buffs/Alcohol/WhiteWineBuff.cs b/Buffs/Alcohol/WhiteWineBuff.cs index c4781b20ef..eb47a1056f 100644 --- a/Buffs/Alcohol/WhiteWineBuff.cs +++ b/Buffs/Alcohol/WhiteWineBuff.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Buffs.Alcohol Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.persistentBuff[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } diff --git a/Buffs/Alcohol/WhiteWineBuff.png b/Buffs/Alcohol/WhiteWineBuff.png index 548844ed08..bfa64feecc 100644 Binary files a/Buffs/Alcohol/WhiteWineBuff.png and b/Buffs/Alcohol/WhiteWineBuff.png differ diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index c09847564f..9b1f59e913 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -14,14 +14,28 @@ namespace CalamityMod.Buffs public override void Update(int type, Player player, ref int buffIndex) { + // Globally remove summon tag buff stacking + // Other mods need to add to this list because we genuinely don't have any way to tell this + if (CalamityBuffSets.IsSummonTagBuff[type] && buffIndex > 0) + { + for (int i = buffIndex; i >= 0; i--) + { + if (player.buffTime[i] > 0) + { + int buffID = player.buffType[i]; + if (CalamityBuffSets.IsSummonTagBuff[buffID] && buffID != type) + { + player.DelBuff(i); + break; + } + } + } + } + if (type == BuffID.Archery) { player.arrowDamage *= 0.955f; } - else if (type == BuffID.Ironskin) - { - player.statDefense += CalamityUtils.GetScalingDefense(-1) - 8; - } else if (type == BuffID.MagicPower) { player.GetDamage() -= 0.1f; @@ -31,10 +45,6 @@ namespace CalamityMod.Buffs player.GetDamage() -= 0.02f; player.GetCritChance() -= 2; } - else if (type == BuffID.Panic) - { - player.moveSpeed -= 0.6f; - } else if (type == BuffID.SugarRush) { player.moveSpeed -= 0.1f; @@ -52,7 +62,8 @@ namespace CalamityMod.Buffs { player.statDefense += 4; player.GetCritChance() -= 2; - player.GetAttackSpeed() -= 0.1f; + player.GetAttackSpeed() -= 0.2f; + player.GetDamage() -= 0.1f; } else if (type == BuffID.WellFed) { @@ -79,9 +90,13 @@ namespace CalamityMod.Buffs { player.Calamity().shine = true; } - else if (type == BuffID.IceBarrier) + + // Star in a Bottle provides Mana Regeneration Potion effect and cancels out the usual effect if you don't have it + else if (type == BuffID.StarInBottle && !player.manaRegenBuff) { - player.endurance -= 0.1f; + player.manaRegenBuff = true; + player.manaRegenDelayBonus -= 0.5f; + player.manaRegenBonus -= 10; } // Beetle Shell DR is a full compensation, as the vanilla multiplicative DR is removed entirely. @@ -101,6 +116,19 @@ namespace CalamityMod.Buffs else if (type == BuffID.Rabies) { player.GetDamage() -= 0.2f; + + // Reimplementation of random debuff infliction; now occurs on a consistent timer and with a different debuff list + if (player.buffTime[buffIndex] % 600 == 300) + { + int debuffType = Main.rand.Next(4) switch + { + 0 => BuffID.Weak, + 1 => BuffID.Bleeding, + 2 => BuffID.Darkness, + _ => BuffID.BrokenArmor, + }; + player.AddBuff(debuffType, Main.rand.Next(90, 211)); + } } else if (type == BuffID.Werewolf) { @@ -110,30 +138,33 @@ namespace CalamityMod.Buffs public override void Update(int type, NPC npc, ref int buffIndex) { + // Globally remove summon tag debuff stacking, unless allowed in the SummonTag + // Other mods need to add to this list because otherwise we can't tell which IsATag buff is actually for whips + if (CalamityBuffSets.SummonTagDebuff.TryGetValue(type, out var tag1) && !tag1.AllowsWhipStacking && buffIndex > 0) + { + for (int i = buffIndex; i >= 0; i--) + { + if (npc.buffTime[i] > 0) + { + int buffID = npc.buffType[i]; + if (CalamityBuffSets.SummonTagDebuff.TryGetValue(buffID, out var tag2) && !tag2.AllowsWhipStacking && buffID != type) + { + npc.DelBuff(i); + break; + } + } + } + } + if (type == BuffID.Webbed) { - if (npc.Calamity().webbed < npc.buffTime[buffIndex]) - npc.Calamity().webbed = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().webbed; - npc.DelBuff(buffIndex); - buffIndex--; - } - else if (type == BuffID.Slow) - { - if (npc.Calamity().slowed < npc.buffTime[buffIndex]) - npc.Calamity().slowed = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().slowed; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().webbed = true; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.buffTime[buffIndex]; } if (type == BuffID.Electrified) { - if (npc.Calamity().electrified < npc.buffTime[buffIndex]) - npc.Calamity().electrified = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().electrified = true; } } @@ -174,18 +205,6 @@ namespace CalamityMod.Buffs tip = CalamityUtils.GetTextValue("Vanilla.BuffDescription.ChaosState"); break; - case BuffID.IceBarrier: - tip = tip.Replace("25", "15"); - break; - - case BuffID.Ironskin: - tip = tip.Replace("8", CalamityUtils.GetScalingDefense(-1).ToString()); - break; - - case BuffID.LeafCrystal: - tip = CalamityUtils.GetTextValue("Vanilla.BuffDescription.LeafCrystal"); - break; - case BuffID.MagicPower: tip = tip.Replace("20", "10"); break; @@ -219,6 +238,10 @@ namespace CalamityMod.Buffs tip = tip.Replace("45", "22.5"); break; + case BuffID.Rabies: + tip = CalamityUtils.GetTextValue("Vanilla.BuffDescription.Rabies"); + break; + case BuffID.SugarRush: tip = tip.Replace("20", "10"); break; @@ -227,10 +250,6 @@ namespace CalamityMod.Buffs tip = tip.Replace("25", "15"); break; - case BuffID.Warmth: - tip += "\n" + CalamityUtils.GetTextValue("Vanilla.BuffDescription.WarmthExtra"); - break; - case BuffID.WeaponImbueConfetti: tip = CalamityUtils.GetTextValue("Vanilla.BuffDescription.WeaponImbueConfetti"); break; diff --git a/Buffs/DamageOverTime/AstralInfectionDebuff.cs b/Buffs/DamageOverTime/AstralInfectionDebuff.cs index ba0bc276cf..f2245d91aa 100644 --- a/Buffs/DamageOverTime/AstralInfectionDebuff.cs +++ b/Buffs/DamageOverTime/AstralInfectionDebuff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +10,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class AstralInfectionDebuff : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 75, + SicknessDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +31,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().astralInfection < npc.buffTime[buffIndex]) - npc.Calamity().astralInfection = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().astralInfection = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/AuricRebuke.cs b/Buffs/DamageOverTime/AuricRebuke.cs index 3e465fa7a3..939e1c5fdf 100644 --- a/Buffs/DamageOverTime/AuricRebuke.cs +++ b/Buffs/DamageOverTime/AuricRebuke.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +10,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class AuricRebuke : ModBuff { + public static DebuffData debuffData = new DebuffData(DebuffData.DebuffBehavior.Electric) + { + EnemyLostRegen = 200, + ElectricDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +31,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().auricRebuke < npc.buffTime[buffIndex]) - npc.Calamity().auricRebuke = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().auricRebuke = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) @@ -47,12 +51,12 @@ namespace CalamityMod.Buffs.DamageOverTime GeneralParticleHandler.SpawnParticle(spark); } - Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 278, new Vector2(1.5f, 1.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.1f, 0.6f)); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.FireworksRGB, new Vector2(1.5f, 1.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.1f, 0.6f)); dust.color = Color.Lerp(Color.Cyan, Color.Lavender, Main.rand.NextFloat(0, 0.6f)); if (Main.rand.NextBool(6)) { - Dust dust2 = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 278, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.8f, 0.95f)); + Dust dust2 = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.FireworksRGB, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.8f, 0.95f)); dust2.color = Main.rand.NextBool(4) ? Color.Lavender : Color.Cyan; } } @@ -73,12 +77,12 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(npcSize, 278, new Vector2(1.5f, 1.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.1f, 0.6f)); + Dust dust = Dust.NewDustPerfect(npcSize, DustID.FireworksRGB, new Vector2(1.5f, 1.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.1f, 0.6f)); dust.color = Color.Lerp(Color.Cyan, Color.Lavender, Main.rand.NextFloat(0, 0.6f)); } if (Main.rand.NextBool(10)) { - Dust dust2 = Dust.NewDustPerfect(npcSize, 278, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.8f, 0.95f)); + Dust dust2 = Dust.NewDustPerfect(npcSize, DustID.FireworksRGB, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.8f, 0.95f)); dust2.color = Main.rand.NextBool(4) ? Color.Lavender : Color.Cyan; } } diff --git a/Buffs/DamageOverTime/BanishingFire.cs b/Buffs/DamageOverTime/BanishingFire.cs index 0e01549c42..23daa2a06f 100644 --- a/Buffs/DamageOverTime/BanishingFire.cs +++ b/Buffs/DamageOverTime/BanishingFire.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.DataStructures; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -6,12 +7,24 @@ namespace CalamityMod.Buffs.DamageOverTime { public class BanishingFire : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 4000, //This is the minimum DoT. Banishing Fire scales with max HP + HeatDebuffScaling = 1, //Unused in the method, but kept so other things can know this is a heat debuff + NPCLifeRegenMethod = BanishingFireNPCLifeRegen + }; + public static void BanishingFireNPCLifeRegen(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + int baseBanishingFireDoTValue = (int)npc.Calamity().ActiveHeatDebuffMultiplier.ApplyTo((npc.lifeMax >= 1000000 ? npc.lifeMax / 500 : debuffData.EnemyLostRegen)); + npc.Calamity().ApplyDPSDebuff(baseBanishingFireDoTValue, baseBanishingFireDoTValue / 5, ref npc.lifeRegen, ref damage); + } public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -21,10 +34,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().banishingFire < npc.buffTime[buffIndex]) - npc.Calamity().banishingFire = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().banishingFire = true; } } } diff --git a/Buffs/DamageOverTime/BrainRot.cs b/Buffs/DamageOverTime/BrainRot.cs index 6a2069e42b..c1f9a49ae2 100644 --- a/Buffs/DamageOverTime/BrainRot.cs +++ b/Buffs/DamageOverTime/BrainRot.cs @@ -1,4 +1,4 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +9,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class BrainRot : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 40, + SicknessDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +30,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().brainRot < npc.buffTime[buffIndex]) - npc.Calamity().brainRot = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().brainRot = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) @@ -45,7 +48,7 @@ namespace CalamityMod.Buffs.DamageOverTime } if (Main.rand.NextBool(4)) { - Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 18); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.CorruptGibs); dust.noGravity = true; dust.velocity = Vector2.Zero; dust.alpha = 90; diff --git a/Buffs/DamageOverTime/BrimstoneFlames.cs b/Buffs/DamageOverTime/BrimstoneFlames.cs index 95a2d128b1..b05c42232b 100644 --- a/Buffs/DamageOverTime/BrimstoneFlames.cs +++ b/Buffs/DamageOverTime/BrimstoneFlames.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using CalamityMod.DataStructures; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,25 +10,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class BrimstoneFlames : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 60, + HeatDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().bFlames = true; + player.Calamity().brimstoneFlames = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().bFlames < npc.buffTime[buffIndex]) - npc.Calamity().bFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().brimstoneFlames = true; } internal static void DrawEffects(PlayerDrawSet drawInfo, bool hasDebuffResistance = false) diff --git a/Buffs/DamageOverTime/BurningBlood.cs b/Buffs/DamageOverTime/BurningBlood.cs index e8d988b9a4..5f8e036feb 100644 --- a/Buffs/DamageOverTime/BurningBlood.cs +++ b/Buffs/DamageOverTime/BurningBlood.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,25 +10,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class BurningBlood : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 40, + SicknessDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().bBlood = true; + player.Calamity().burningBlood = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().bBlood < npc.buffTime[buffIndex]) - npc.Calamity().bBlood = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().burningBlood = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) @@ -54,7 +58,7 @@ namespace CalamityMod.Buffs.DamageOverTime { float rot = MathHelper.ToRadians(i * 280); Vector2 offset = new Vector2(0.1f, 0).RotatedBy(rot * Main.rand.NextFloat(0.08f, 0.05f)); - Dust dust2 = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot + offset, 5); + Dust dust2 = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot + offset, DustID.Blood); dust2.scale = Main.rand.NextFloat(0.6f, 0.7f); } } diff --git a/Buffs/DamageOverTime/CrushDepth.cs b/Buffs/DamageOverTime/CrushDepth.cs index b10bc709aa..63c9fa2ebc 100644 --- a/Buffs/DamageOverTime/CrushDepth.cs +++ b/Buffs/DamageOverTime/CrushDepth.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,25 +10,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class CrushDepth : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 100, + WaterDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().cDepth = true; + player.Calamity().crushDepth = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().cDepth < npc.buffTime[buffIndex]) - npc.Calamity().cDepth = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().crushDepth = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/Daybroken.cs b/Buffs/DamageOverTime/Daybroken.cs index 854ac4e535..947f6c2611 100644 --- a/Buffs/DamageOverTime/Daybroken.cs +++ b/Buffs/DamageOverTime/Daybroken.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.DataStructures; +using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; @@ -16,6 +17,7 @@ namespace CalamityMod.Buffs.DamageOverTime Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = DebuffData.Daybroken; } public override void Update(Player player, ref int buffIndex) @@ -23,13 +25,13 @@ namespace CalamityMod.Buffs.DamageOverTime player.Calamity().daybroken = true; } - internal static void DrawEffects(PlayerDrawSet drawInfo, bool reducedEffects) + internal static void DrawEffects(PlayerDrawSet drawInfo) { Player Player = drawInfo.drawPlayer; - if (Main.rand.Next(reducedEffects ? 8 : 4) < 3) + if (Main.rand.Next(4) < 3) { - Dust solarDust = Dust.NewDustDirect(Player.position, Player.width, Player.height, DustID.OrangeTorch, Player.velocity.X * 0.4f, Player.velocity.Y * 0.4f, reducedEffects ? 175 : 100, default, reducedEffects ? 2f : 3f); + Dust solarDust = Dust.NewDustDirect(Player.position, Player.width, Player.height, DustID.OrangeTorch, Player.velocity.X * 0.4f, Player.velocity.Y * 0.4f, 100, default, 3f); solarDust.noGravity = true; solarDust.velocity *= 2.8f; solarDust.velocity.Y -= 0.5f; diff --git a/Buffs/DamageOverTime/DemonicFlames.cs b/Buffs/DamageOverTime/DemonicFlames.cs index 7b35b79c72..7f6827f0bb 100644 --- a/Buffs/DamageOverTime/DemonicFlames.cs +++ b/Buffs/DamageOverTime/DemonicFlames.cs @@ -1,7 +1,7 @@ using System; +using CalamityMod.DataStructures; using CalamityMod.Dusts; using CalamityMod.Particles; -using CalamityMod.Projectiles.Pets; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -12,12 +12,25 @@ namespace CalamityMod.Buffs.DamageOverTime { public class DemonicFlames : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 60, //Unused in the method, this is the amount of DoT from Forbidden Oathblade demon flames + HeatDebuffScaling = 1, //Unused in the method, but kept so other things can know this is a heat debuff + NPCLifeRegenMethod = DemonFlamesNPCLifeRegen + }; + public static void DemonFlamesNPCLifeRegen(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + int baseDemonicFlamesDoTValue = (int)Math.Max(npc.Calamity().ActiveHeatDebuffMultiplier.ApplyTo(npc.Calamity().demonicFlamesBonusDamage), npc.Calamity().demonicFlamesBonusDamage); + npc.Calamity().ApplyDPSDebuff(baseDemonicFlamesDoTValue, baseDemonicFlamesDoTValue / 15, ref npc.lifeRegen, ref damage); + } public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; + } public override void Update(Player player, ref int buffIndex) @@ -27,10 +40,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().demonicFlames < npc.buffTime[buffIndex]) - npc.Calamity().demonicFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().demonicFlames = true; } internal static void DrawEffects(PlayerDrawSet drawInfo, bool hasDebuffResistance = false) @@ -68,7 +78,7 @@ namespace CalamityMod.Buffs.DamageOverTime for (int i = 0; i < 2; i++) { Vector2 sparkVel = new Vector2(Main.rand.NextFloat(-npc.width / 6, npc.width / 6), Main.rand.NextFloat(-npc.height / 20, -npc.height / 17)); - Particle sparks = new VelChangingSpark(npc.Center + new Vector2(Main.rand.NextFloat(-10f, 10f), npc.height / 2) + sparkVel * 0.5f, sparkVel + npc.velocity, new Vector2(-sparkVel.X * 0.5f, sparkVel.Y * 2) * 3.5f, "CalamityMod/Particles/SmallBloom", Main.rand.Next(13, 20 + 1), Main.rand.NextFloat(0.1f, 0.25f) * MathHelper.Lerp(Math.Max(npc.height, npc.width) / 120, 0.5f, 0.7f), (Main.rand.NextBool() ? Color.MediumOrchid : Color.BlueViolet) * 0.75f, new Vector2(0.7f, 1), true, false, 0, false, 0.3f, 0.055f); + Particle sparks = new VelChangingSpark(npc.Center + new Vector2(Main.rand.NextFloat(-10f, 10f), npc.height / 2) + sparkVel * 0.5f, sparkVel + npc.velocity, new Vector2(-sparkVel.X * 0.5f, sparkVel.Y * 2) * 3.5f, "CalamityMod/Particles/SmallBloom", Main.rand.Next(13, 20 + 1), Main.rand.NextFloat(0.1f, 0.25f) * MathHelper.Lerp(Math.Max(npc.height, npc.width) / 120, 0.5f, 0.7f), (Main.rand.NextBool() ? Color.MediumOrchid : Color.BlueViolet) * 0.75f, new Vector2(0.7f, 1), true, false, 0, false, 0.3f, 0.055f); GeneralParticleHandler.SpawnParticle(sparks); } } diff --git a/Buffs/DamageOverTime/Dragonfire.cs b/Buffs/DamageOverTime/Dragonfire.cs index 6314a32eef..bc3ff034b3 100644 --- a/Buffs/DamageOverTime/Dragonfire.cs +++ b/Buffs/DamageOverTime/Dragonfire.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +10,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class Dragonfire : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 960, + HeatDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +31,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().dragonFire < npc.buffTime[buffIndex]) - npc.Calamity().dragonFire = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().dragonFire = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/ElementalMix.cs b/Buffs/DamageOverTime/ElementalMix.cs index 6f64dace2c..d057dcd645 100644 --- a/Buffs/DamageOverTime/ElementalMix.cs +++ b/Buffs/DamageOverTime/ElementalMix.cs @@ -1,4 +1,4 @@ -using CalamityMod.Dusts; +using CalamityMod.DataStructures; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -10,12 +10,17 @@ namespace CalamityMod.Buffs.DamageOverTime { public class ElementalMix : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 400 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -25,10 +30,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().elementalMix < npc.buffTime[buffIndex]) - npc.Calamity().elementalMix = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().elementalMix = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/GodSlayerInferno.cs b/Buffs/DamageOverTime/GodSlayerInferno.cs index 9f892fb2b2..f7d799fafa 100644 --- a/Buffs/DamageOverTime/GodSlayerInferno.cs +++ b/Buffs/DamageOverTime/GodSlayerInferno.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,25 +10,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class GodSlayerInferno : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 500, + HeatDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().gsInferno = true; + player.Calamity().godSlayerInferno = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().gsInferno < npc.buffTime[buffIndex]) - npc.Calamity().gsInferno = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().godSlayerInferno = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/HadopelagicPressure.cs b/Buffs/DamageOverTime/HadopelagicPressure.cs index f4edd97b85..7cde6908ed 100644 --- a/Buffs/DamageOverTime/HadopelagicPressure.cs +++ b/Buffs/DamageOverTime/HadopelagicPressure.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,25 +10,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class HadopelagicPressure : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 400, + WaterDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().hPressure = true; + player.Calamity().hadopelagicPressure = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().hPressure < npc.buffTime[buffIndex]) - npc.Calamity().hPressure = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().hadopelagicPressure = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/HeavyBleeding.cs b/Buffs/DamageOverTime/HeavyBleeding.cs index 340845ce9e..48bc271513 100644 --- a/Buffs/DamageOverTime/HeavyBleeding.cs +++ b/Buffs/DamageOverTime/HeavyBleeding.cs @@ -1,6 +1,6 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,12 +10,17 @@ namespace CalamityMod.Buffs.DamageOverTime { public class HeavyBleeding : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 80 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -25,10 +30,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().heavybleeding < npc.buffTime[buffIndex]) - npc.Calamity().heavybleeding = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().heavyBleeding = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) { @@ -38,7 +40,7 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool(3)) { Vector2 randVel = new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); - Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 5, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); dust.noGravity = false; Particle spark = new AltSparkParticle(modPlayer.RandomDebuffVisualSpot, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); GeneralParticleHandler.SpawnParticle(spark); @@ -61,7 +63,7 @@ namespace CalamityMod.Buffs.DamageOverTime } else { - Dust dust = Dust.NewDustPerfect(npcSize, 5, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust dust = Dust.NewDustPerfect(npcSize, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); dust.noGravity = false; } if (Main.rand.NextBool(8)) diff --git a/Buffs/DamageOverTime/HolyFlames.cs b/Buffs/DamageOverTime/HolyFlames.cs index c4936b2e2a..84a60b5e22 100644 --- a/Buffs/DamageOverTime/HolyFlames.cs +++ b/Buffs/DamageOverTime/HolyFlames.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,25 +10,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class HolyFlames : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 300, + HeatDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().hFlames = true; + player.Calamity().holyFlames = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().hFlames < npc.buffTime[buffIndex]) - npc.Calamity().hFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().holyFlames = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/HolyInferno.cs b/Buffs/DamageOverTime/HolyInferno.cs index 1cf1741ee8..eaf25ad6a1 100644 --- a/Buffs/DamageOverTime/HolyInferno.cs +++ b/Buffs/DamageOverTime/HolyInferno.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.DataStructures; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -6,17 +7,24 @@ namespace CalamityMod.Buffs.DamageOverTime { public class HolyInferno : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 10000, //this is never applied to enemies + HeatDebuffScaling = 1, + GearCanModifyDebuff = false + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().hInferno = true; + player.Calamity().holyInferno = true; } } } diff --git a/Buffs/DamageOverTime/Laceration.cs b/Buffs/DamageOverTime/Laceration.cs index 621b51dfe4..2f77bebe8f 100644 --- a/Buffs/DamageOverTime/Laceration.cs +++ b/Buffs/DamageOverTime/Laceration.cs @@ -1,6 +1,6 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,12 +10,17 @@ namespace CalamityMod.Buffs.DamageOverTime { public class Laceration : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 400 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -25,10 +30,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().laceration < npc.buffTime[buffIndex]) - npc.Calamity().laceration = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().laceration = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) { @@ -38,7 +40,7 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool()) { Vector2 randVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); - Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 5, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); dust.noGravity = false; Particle spark = new AltSparkParticle(modPlayer.RandomDebuffVisualSpot, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); GeneralParticleHandler.SpawnParticle(spark); @@ -61,7 +63,7 @@ namespace CalamityMod.Buffs.DamageOverTime } else { - Dust dust = Dust.NewDustPerfect(npcSize, 5, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust dust = Dust.NewDustPerfect(npcSize, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); dust.noGravity = false; } if (Main.rand.NextBool(8)) diff --git a/Buffs/DamageOverTime/ManaBurn.cs b/Buffs/DamageOverTime/ManaBurn.cs index c14439fd3b..b02cbc32fb 100644 --- a/Buffs/DamageOverTime/ManaBurn.cs +++ b/Buffs/DamageOverTime/ManaBurn.cs @@ -1,52 +1,21 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Buffs.DamageOverTime { public class ManaBurn : ModBuff { + //as of now, this doesn't use the custom debuff system due to the debuff being a front for the actual effects in the Chaos Stone rework public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; } - - // Mana Burn's actual effects are controlled by CalamityPlayer code. - // However, every frame you have Mana Burn, it automatically scans for and removes Mana Sickness if you somehow have it simultaneously. - // This would only occur if other mods added Mana Burn to the player via esoteric means, as AddBuff is IL edited by Calamity. - // If found, it adds the remaining time of that Mana Sickness to Mana Burn, capping at its usual duration cap. public override void Update(Player player, ref int buffIndex) { player.Calamity().ManaBurn = true; - - int manaSicknessIndex = player.FindBuffIndex(BuffID.ManaSickness); - if (manaSicknessIndex != -1) - { - // Set the remaining duration of Mana Sickness to 1 frame so it disappears either this or the next frame. - // If it would disappear the next frame because it was already iterated over, then add 1 less frame of Mana Burn. - bool extraFrame = manaSicknessIndex < buffIndex; - int timeToAdd = player.buffTime[manaSicknessIndex] - (extraFrame ? 1 : 0); - player.buffTime[manaSicknessIndex] = 1; - - // Add that time to Mana Burn. - int newBuffTime = player.buffTime[buffIndex] + timeToAdd; - if (newBuffTime > Player.manaSickTimeMax) - newBuffTime = Player.manaSickTimeMax; - player.buffTime[buffIndex] = newBuffTime; - } - } - - public override bool ReApply(Player player, int time, int buffIndex) - { - // Logic copy pasted from Mana Sickness - player.buffTime[buffIndex] += time; - if (player.buffTime[buffIndex] > Player.manaSickTimeMax) - player.buffTime[buffIndex] = Player.manaSickTimeMax; - - // Skip vanilla re-apply logic - return true; } } } diff --git a/Buffs/DamageOverTime/MiracleBlight.cs b/Buffs/DamageOverTime/MiracleBlight.cs index df93272cbd..448b4616a7 100644 --- a/Buffs/DamageOverTime/MiracleBlight.cs +++ b/Buffs/DamageOverTime/MiracleBlight.cs @@ -1,7 +1,16 @@ -using CalamityMod.Particles; +using System.Collections.Generic; +using CalamityMod.DataStructures; +using CalamityMod.NPCs; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -9,12 +18,44 @@ namespace CalamityMod.Buffs.DamageOverTime { public class MiracleBlight : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 3000 + }; + + public static Asset ShaderTexture => field ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"); + + public static List ExcludedNPCsForShader => new() + { + // TODO: Remove this list if possible + + // List the reason why the NPC(s) are excluded :) + + // The particle sets break with the visuals and this is the easiest way to fix this that isn't stupidly complex. + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + + // Breaks with being behind tiles, and causes a funny interaction where his head goes behind his neck. + NPCID.MoonLordCore, + NPCID.MoonLordHand, + NPCID.MoonLordHead + }; + + public override void Load() + { + On_Main.DrawNPC += DrawForNPC; + } + public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +65,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().miracleBlight < npc.buffTime[buffIndex]) - npc.Calamity().miracleBlight = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().miracleBlight = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) @@ -44,7 +82,7 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool(2)) { - Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot, 66, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); + Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot, DustID.RainbowTorch, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.7f, 0.85f); dust.color = sparkColor; @@ -75,7 +113,7 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool(4)) { - Dust dust = Dust.NewDustPerfect(npcSize, 66, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); + Dust dust = Dust.NewDustPerfect(npcSize, DustID.RainbowTorch, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.7f, 0.85f) + (0.0000007f * npc.width * npc.height); dust.color = sparkColor; @@ -93,5 +131,44 @@ namespace CalamityMod.Buffs.DamageOverTime GeneralParticleHandler.SpawnParticle(exoEnergy); } } + + private static void DrawForNPC(On_Main.orig_DrawNPC orig, Main self, int iNPCIndex, bool behindTiles) + { + var npc = Main.npc[iNPCIndex]; + + if (!CalamityDrawParameterNPC.DrawingMiracleBlight[npc.whoAmI]) + { + orig(self, iNPCIndex, behindTiles); + return; + } + + if (ExcludedNPCsForShader.Contains(npc.type)) + { + orig(self, iNPCIndex, behindTiles); + return; + } + + using (Main.spriteBatch.Scope()) + { + using var lease = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); + using (lease.Scope(clearColor: Color.Transparent)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); + orig(self, iNPCIndex, behindTiles); + Main.spriteBatch.End(); + } + + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise); + + var blightShader = GameShaders.Misc["CalamityMod:MiracleBlight"]; + blightShader.UseImage1(ShaderTexture); + blightShader.UseOpacity(0.7f); + blightShader.Apply(); + + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, Color.White); + + Main.spriteBatch.End(); + } + } } } diff --git a/Buffs/DamageOverTime/Nightwither.cs b/Buffs/DamageOverTime/Nightwither.cs index a6d24f65c1..dbdbef4d02 100644 --- a/Buffs/DamageOverTime/Nightwither.cs +++ b/Buffs/DamageOverTime/Nightwither.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +10,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class Nightwither : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 200, + ColdDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,29 +31,26 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().nightwither < npc.buffTime[buffIndex]) - npc.Calamity().nightwither = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().nightwither = true; } - internal static void DrawEffects(PlayerDrawSet drawInfo, bool hasDebuffResistance = false) + internal static void DrawEffects(PlayerDrawSet drawInfo) { Player Player = drawInfo.drawPlayer; - if (Main.rand.NextBool(hasDebuffResistance ? 4 : 2)) + if (Main.rand.NextBool(2)) { Vector2 Vect = new Vector2(0f, Main.rand.NextBool(4) ? -5f : -9f).RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.1f, 1.9f); - CritSpark spark = new CritSpark(Player.Calamity().RandomDebuffVisualSpot, Vect, Main.rand.NextBool() ? Color.Cyan : Color.Turquoise, Color.PaleTurquoise, (hasDebuffResistance ? 0.4f : 0.8f), 15, 2f, 1.9f); + CritSpark spark = new CritSpark(Player.Calamity().RandomDebuffVisualSpot, Vect, Main.rand.NextBool() ? Color.Cyan : Color.Turquoise, Color.PaleTurquoise, 0.8f, 15, 2f, 1.9f); GeneralParticleHandler.SpawnParticle(spark); } - for (int i = 0; i < (hasDebuffResistance ? 1 : 2); i++) + for (int i = 0; i < 2; i++) { Vector2 dustCorner = Player.position - 2f * Vector2.One; Vector2 dustVel = Player.velocity + new Vector2(0f, Main.rand.NextFloat(-11f, -2f)); Dust moonDust = Dust.NewDustDirect(dustCorner, Player.width + 4, Player.height + 4, Main.rand.NextBool(4) ? 300 : 323, dustVel.X, dustVel.Y); moonDust.noGravity = true; - moonDust.scale = hasDebuffResistance ? Main.rand.NextFloat(0.3f, 0.3f) : Main.rand.NextFloat(0.5f, 0.5f); + moonDust.scale = Main.rand.NextFloat(0.5f, 0.5f); moonDust.alpha = 235; } } diff --git a/Buffs/DamageOverTime/Plague.cs b/Buffs/DamageOverTime/Plague.cs index f776337e36..45875dc587 100644 --- a/Buffs/DamageOverTime/Plague.cs +++ b/Buffs/DamageOverTime/Plague.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,25 +10,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class Plague : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 100, + SicknessDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().pFlames = true; + player.Calamity().plague = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().pFlames < npc.buffTime[buffIndex]) - npc.Calamity().pFlames = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().plague = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/RiptideDebuff.cs b/Buffs/DamageOverTime/RiptideDebuff.cs index 62816f8004..e68629fae6 100644 --- a/Buffs/DamageOverTime/RiptideDebuff.cs +++ b/Buffs/DamageOverTime/RiptideDebuff.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.DataStructures; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -8,25 +9,28 @@ namespace CalamityMod.Buffs.DamageOverTime { public class RiptideDebuff : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 30, + WaterDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().rTide = true; + player.Calamity().riptide = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().rTide < npc.buffTime[buffIndex]) - npc.Calamity().rTide = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().riptide = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) @@ -56,7 +60,7 @@ namespace CalamityMod.Buffs.DamageOverTime Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); if (Main.rand.NextBool(9)) { - Dust dust = Dust.NewDustPerfect(npcSize, 76, new Vector2(2f, 2f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust dust = Dust.NewDustPerfect(npcSize, DustID.Snow, new Vector2(2f, 2f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); dust.color = (Main.rand.NextBool(3) ? Color.LightBlue : Color.LightSkyBlue); } if (Main.rand.NextBool(8)) diff --git a/Buffs/DamageOverTime/SagePoison.cs b/Buffs/DamageOverTime/SagePoison.cs index 623c95a1a5..27cbd603f0 100644 --- a/Buffs/DamageOverTime/SagePoison.cs +++ b/Buffs/DamageOverTime/SagePoison.cs @@ -1,22 +1,57 @@ -using Terraria; +using CalamityMod.DataStructures; +using CalamityMod.Systems.Collections; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Buffs.DamageOverTime { public class SagePoison : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 50, + SicknessDebuffScaling = 1, + NPCLifeRegenMethod = SagePoisonPower + }; + + public static float ViridVanguardPoisonMultiplier => 2; + public static void SagePoisonPower(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + // The base DoT is multiplied by the amount of Viral Sprouts you have when applied + // See SageNeedle.cs for details + + //Reduce power of weakness/resistances but leave sickness debuff boosters at full power + //We first need to apply Irradiated as that isn't included in SicknessDebuffMultiplier due to needing to dynamically update if Irradiated is applied + StatModifier multiplier = npc.Calamity().SicknessDebuffMultiplier; + if (npc.Calamity().irradiated) + multiplier += npc.Calamity().scionsCurioEffected ? 1.75f : 1f; + + bool wormBoss = CalamityNPCTypeSets.DesertScourge.Contains(npc.type) || CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type) || CalamityNPCTypeSets.Perforators.Contains(npc.type) || + CalamityNPCTypeSets.AquaticScourge.Contains(npc.type) || CalamityNPCTypeSets.AstrumDeus.Contains(npc.type) || CalamityNPCTypeSets.StormWeaver.Contains(npc.type); + float NewWeaknessEffectiveness = 1.25f; //1.25x DPS instead of 2x - 1/4th the effectiveness + float NewWeaknessEffectivenessWorm = 1.125f; //1.125x DPS instead of 1.5x - 1/4th the effectiveness + float NewResistanceEffectiveness = 0.875f; // 0.875x instead of 0.5x - 1/4th the effectiveness + + if (npc.Calamity().VulnerableToSickness.HasValue) + if (npc.Calamity().VulnerableToSickness.Value) + multiplier *= (wormBoss ? NewWeaknessEffectivenessWorm : NewWeaknessEffectiveness); + else + multiplier *= NewResistanceEffectiveness; + + //Apply the DOT + int baseSagePoisonDoTValue = (int)multiplier.ApplyTo(npc.Calamity().sagePoisonDamage); + npc.Calamity().ApplyDPSDebuff(baseSagePoisonDoTValue, baseSagePoisonDoTValue / 5, ref npc.lifeRegen, ref damage); + } public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().sagePoisonTime < npc.buffTime[buffIndex]) - npc.Calamity().sagePoisonTime = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().sagePoison = true; } } } diff --git a/Buffs/DamageOverTime/SeaKingsAssurance.cs b/Buffs/DamageOverTime/SeaKingsAssurance.cs new file mode 100644 index 0000000000..accaf0bf21 --- /dev/null +++ b/Buffs/DamageOverTime/SeaKingsAssurance.cs @@ -0,0 +1,171 @@ +using System; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.DamageOverTime +{ + public class SeaKingsAssurance : ModBuff + { + public static Color BaseColor => new Color(31, 78, 155); + public static Color LightColor => new Color(31, 108, 225); + public static void Apply(NPC npc, Vector2 orig) + { + int stacks = 1; + if (npc.HasBuff()) + { + int buffTimer = npc.buffTime[npc.FindBuffIndex(ModContent.BuffType())]; + npc.buffTime[npc.FindBuffIndex(ModContent.BuffType())] += FramesPerStack; + npc.buffTime[npc.FindBuffIndex(ModContent.BuffType())] = ((int)Math.Ceiling((double)buffTimer / FramesPerStack) + 1) * FramesPerStack; + buffTimer = npc.buffTime[npc.FindBuffIndex(ModContent.BuffType())]; + stacks += ((int)Math.Ceiling((double)buffTimer / FramesPerStack)); + } + else + { + npc.AddBuff(ModContent.BuffType(), FramesPerStack); + } + + npc.GetGlobalNPC().StackGlow = 1f; + npc.GetGlobalNPC().StackScale = 1.2f; + + SoundStyle style = new SoundStyle("CalamityMod/Sounds/Item/WaterSplash1"); + SoundEngine.PlaySound(style.WithPitchOffset(1f + ((float)stacks / 6f)).WithVolumeScale(0.2f)); + + float sc = 0.05f + ((float)stacks * 0.06f); + + for (int i = 0; i < 5; i++) + { + float rot = Main.rand.NextFloat(MathHelper.TwoPi) + MathHelper.PiOver2; + if (orig != Vector2.Zero) + { + rot = orig.AngleTo(npc.Center) + MathHelper.PiOver2; + } + + GeneralParticleHandler.SpawnParticle(new CustomPulse( + npc.Center, (rot - MathHelper.PiOver2).ToRotationVector2() * 6f, Color.Lerp(BaseColor, LightColor, sc * 3f), "CalamityMod/Particles/ForwardSmear", new Vector2(Main.rand.NextFloat(0.015f, 0.1f), 0.1f), + rot, sc, sc * 2f, 8 + )); + } + + float range = 20 + ((float)stacks * 15f); + + if (orig == Vector2.Zero) + { + foreach (NPC npc2 in Main.npc) + { + if (npc2 != npc) + { + if (npc2.active && !npc2.friendly && !npc2.isLikeATownNPC) + { + if (npc2.Distance(npc.Center) < range) + { + Apply(npc2, npc.Center); + } + } + } + } + } + } + + /// + /// The number of frames per stack of this buff. + /// For instance, if the buff has less than one of this number's worth of time left, + /// it will count as one stack. + /// + public static int FramesPerStack => 60; + public static SoundStyle ImpactSound => new SoundStyle("CalamityMod/Sounds/Item/WaterSplash1"); + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.buffNoSave[Type] = true; + BuffID.Sets.LongerExpertDebuff[Type] = true; + } + + public override void Update(NPC npc, ref int buffIndex) + { + npc.buffTime[buffIndex] = Math.Min(npc.buffTime[buffIndex], 10 * FramesPerStack); + + npc.GetGlobalNPC().assuredStacks = (int)Math.Ceiling((double)(npc.buffTime[buffIndex] / FramesPerStack)); + } + } + + public class SeaKingsAssuranceNPC : GlobalNPC + { + public static readonly Asset Stacks = ModContent.Request("CalamityMod/ExtraTextures/AmidiasTrident_Stacks"); + + public override bool InstancePerEntity => true; + public int assuredStacks = 0; + public int StackFrame = 0; + public float StackRotation = 0f; + public float StackScale = 0f; + public float StackGlow = 0f; + public override void ResetEffects(NPC npc) + { + if (assuredStacks == 0) + { + StackScale *= 0.5f; + } + else + { + StackScale = MathHelper.Lerp(StackScale, 1f, 0.2f); + } + StackGlow *= 0.7f; + assuredStacks = 0; + base.ResetEffects(npc); + } + public override void DrawEffects(NPC npc, ref Color drawColor) + { + base.DrawEffects(npc, ref drawColor); + } + public override void UpdateLifeRegen(NPC npc, ref int damage) + { + } + public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + StackFrame = 0; + if (assuredStacks > 5) StackFrame = 1; + if (assuredStacks > 8) StackFrame = 2; + + Rectangle frame = Stacks.Frame(3, 1, StackFrame); + + if (StackFrame == 2) + { + StackRotation = MathHelper.Lerp(StackRotation, MathHelper.Pi, 0.2f); + } + else + { + StackRotation = MathHelper.Lerp(StackRotation, 0f, 0.1f); + } + + float offset = -28; + + for (int b = 0; b < CalamityGlobalNPC.moddedDebuffTextureList.Count; b++) + { + if (CalamityGlobalNPC.moddedDebuffTextureList[b].Item2.Invoke(npc)) + { + offset = -48; + } + } + + if (StackScale > 0.2f && assuredStacks > 2) + { + spriteBatch.Draw(Stacks.Value, npc.Top - Main.screenPosition + new Vector2(0, offset), frame, Color.White, StackRotation, frame.Size() / 2f, StackScale, SpriteEffects.None, 0f); + + for (int i = 0; i < 4; i++) + { + spriteBatch.Draw(Stacks.Value, npc.Top - Main.screenPosition + new Vector2(0, offset), frame, Color.White.MultiplyRGBA(new(StackGlow, StackGlow, StackGlow, 0f)), StackRotation, frame.Size() / 2f, StackScale, SpriteEffects.None, 0f); + } + } + else + { + StackRotation = 0f; + } + } + } +} diff --git a/Buffs/DamageOverTime/SeaKingsAssurance.png b/Buffs/DamageOverTime/SeaKingsAssurance.png new file mode 100644 index 0000000000..b7397c5c44 Binary files /dev/null and b/Buffs/DamageOverTime/SeaKingsAssurance.png differ diff --git a/Buffs/DamageOverTime/SearingLava.cs b/Buffs/DamageOverTime/SearingLava.cs index c17fff2bcf..ca5641a4ba 100644 --- a/Buffs/DamageOverTime/SearingLava.cs +++ b/Buffs/DamageOverTime/SearingLava.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.DataStructures; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Buffs.DamageOverTime @@ -6,17 +7,23 @@ namespace CalamityMod.Buffs.DamageOverTime [LegacyName("CragsLava")] public class SearingLava : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 40, + HeatDebuffScaling = 2 + }; public override void SetStaticDefaults() { Main.buffNoTimeDisplay[Type] = true; Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().cragsLava = true; + player.Calamity().searingLava = true; } } } diff --git a/Buffs/DamageOverTime/Shadowflame.cs b/Buffs/DamageOverTime/Shadowflame.cs index d97c8889ed..3b89427e23 100644 --- a/Buffs/DamageOverTime/Shadowflame.cs +++ b/Buffs/DamageOverTime/Shadowflame.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.DataStructures; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -17,6 +18,7 @@ namespace CalamityMod.Buffs.DamageOverTime Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = DebuffData.Shadowflame; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/DamageOverTime/ShellfishClaps.cs b/Buffs/DamageOverTime/ShellfishClaps.cs index 697a8f241b..c70408473c 100644 --- a/Buffs/DamageOverTime/ShellfishClaps.cs +++ b/Buffs/DamageOverTime/ShellfishClaps.cs @@ -1,23 +1,57 @@ -using Terraria; +using CalamityMod.Balancing; +using CalamityMod.DataStructures; +using CalamityMod.Projectiles.Summon; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Buffs.DamageOverTime { public class ShellfishClaps : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 150, //Damage per shellfish + NPCLifeRegenMethod = ShellfishStacking + }; + public static void ShellfishStacking(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + int projectileCount = 0; + int owner = 255; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && + p.ai[0] == 1f && p.ai[1] == npc.whoAmI) + { + owner = p.owner; + projectileCount++; + if (projectileCount >= 5) + { + projectileCount = 5; + break; + } + } + } + + Item heldItem = Main.player[owner].HeldItem; + int totalDamage = (int)Main.player[owner].GetTotalDamage().ApplyTo(debuffData.EnemyLostRegen); + + if (CalamityUtils.ShouldTriggerSummonPenalty(Main.player[owner], heldItem)) + totalDamage = (int)(totalDamage * BalancingConstants.SummonerCrossClassNerf); + + int totalDisplayedDamage = totalDamage / 5; + npc.Calamity().ApplyDPSDebuff(projectileCount * totalDamage, projectileCount * totalDisplayedDamage, ref npc.lifeRegen, ref damage); + } public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().shellfishVore < npc.buffTime[buffIndex]) - npc.Calamity().shellfishVore = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().shellfishStaffDebuff = true; } } } diff --git a/Buffs/DamageOverTime/Shred.cs b/Buffs/DamageOverTime/Shred.cs index d46d375305..bd168fd492 100644 --- a/Buffs/DamageOverTime/Shred.cs +++ b/Buffs/DamageOverTime/Shred.cs @@ -11,6 +11,8 @@ namespace CalamityMod.Buffs.DamageOverTime { public class Shred : ModBuff { + //This is not ported to the custom debuff system yet due to the complexities of it. + //I didn't want to break it! It will be done in a future PR internal const int StackFalloffFrames = 320; // This deals 600 DPS per stack, is boosted by ranged stats and can supercrit. diff --git a/Buffs/DamageOverTime/SnapClamDebuff.cs b/Buffs/DamageOverTime/SnapClamDebuff.cs index e11f1205a6..acf115c563 100644 --- a/Buffs/DamageOverTime/SnapClamDebuff.cs +++ b/Buffs/DamageOverTime/SnapClamDebuff.cs @@ -1,23 +1,45 @@ -using Terraria; +using CalamityMod.DataStructures; +using CalamityMod.Projectiles.Rogue; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Buffs.DamageOverTime { public class SnapClamDebuff : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 15, //Damage per shellfish + NPCLifeRegenMethod = ShellfishStacking + }; + public static void ShellfishStacking(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + + int projectileCount = 0; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.ai[0] == 1f && p.ai[1] == npc.whoAmI) + { + if (p.type == ModContent.ProjectileType()) + projectileCount += 2; + if (p.type == ModContent.ProjectileType()) + projectileCount++; + } + } + + npc.Calamity().ApplyDPSDebuff((int)(projectileCount * debuffData.EnemyLostRegen), projectileCount * 3, ref npc.lifeRegen, ref damage); + } public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().clamDebuff < npc.buffTime[buffIndex]) - npc.Calamity().clamDebuff = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().snapClamDebuff = true; } } } diff --git a/Buffs/DamageOverTime/StaticDischarge.cs b/Buffs/DamageOverTime/StaticDischarge.cs index aa7de883cd..5b88e5a0c0 100644 --- a/Buffs/DamageOverTime/StaticDischarge.cs +++ b/Buffs/DamageOverTime/StaticDischarge.cs @@ -1,4 +1,4 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +9,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class StaticDischarge : ModBuff { + public static DebuffData debuffData = new DebuffData(DebuffData.DebuffBehavior.Electric) + { + EnemyLostRegen = 5, + ElectricDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +30,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().staticDischarge < npc.buffTime[buffIndex]) - npc.Calamity().staticDischarge = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().staticDischarge = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) @@ -41,7 +44,7 @@ namespace CalamityMod.Buffs.DamageOverTime { if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 278, new Vector2(2f, 2f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.FireworksRGB, new Vector2(2f, 2f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); dust.color = (Main.rand.NextBool(3) ? Color.Yellow : Color.LightSkyBlue); } } @@ -54,7 +57,7 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool(4)) { - Dust dust = Dust.NewDustPerfect(npcSize, 278, new Vector2(2f, 2f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust dust = Dust.NewDustPerfect(npcSize, DustID.FireworksRGB, new Vector2(2f, 2f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); dust.color = (Main.rand.NextBool(3) ? Color.Yellow : Color.LightSkyBlue); } } diff --git a/Buffs/DamageOverTime/SulphuricPoisoning.cs b/Buffs/DamageOverTime/SulphuricPoisoning.cs index f71550c714..79c6a49b58 100644 --- a/Buffs/DamageOverTime/SulphuricPoisoning.cs +++ b/Buffs/DamageOverTime/SulphuricPoisoning.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +10,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class SulphuricPoisoning : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 240, + SicknessDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; // Acid Venom immunity is granted automatically if you are immune to Sulphuric Poisoning. BuffID.Sets.GrantImmunityWith[BuffID.Venom].Add(Type); @@ -33,10 +40,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().sulphurPoison < npc.buffTime[buffIndex]) - npc.Calamity().sulphurPoison = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().sulphurPoison = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/TrueVulnerabilityHex.cs b/Buffs/DamageOverTime/TrueVulnerabilityHex.cs index 72910c2fa8..cfeafcdb55 100644 --- a/Buffs/DamageOverTime/TrueVulnerabilityHex.cs +++ b/Buffs/DamageOverTime/TrueVulnerabilityHex.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using CalamityMod.DataStructures; +using CalamityMod.Dusts; using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Systems.Collections; @@ -12,11 +13,13 @@ namespace CalamityMod.Buffs.DamageOverTime { public class TrueVulnerabilityHex : ModBuff { - // The visual number displayed in ticks as the enemy takes damage. - public const int TickNumber = 666; - - // The exact amount True Vulnerability Hex reduces NPC life regen by. - public const int DPS = TickNumber * 6; // -3996 life regen, 1998 DPS + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 3996, //6x the tick size + HeatDebuffScaling = 1, + MinimumDamageTickSize = 666, //Vhex should always have ticks of 666 + MultiplierDamageTickSize = 0 + }; public override void SetStaticDefaults() { @@ -25,6 +28,7 @@ namespace CalamityMod.Buffs.DamageOverTime Main.buffNoSave[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) => player.Calamity().trueVHex = true; @@ -32,21 +36,14 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { CalamityGlobalNPC cgn = npc.Calamity(); - if (cgn.trueVulnerabilityHex < npc.buffTime[buffIndex]) - { - cgn.trueVulnerabilityHex = npc.buffTime[buffIndex]; - // Set the remaining time of the fire drawer to be exactly right. - if (cgn.VulnerabilityHexFireDrawer != null) - cgn.VulnerabilityHexFireDrawer.SetLifetime = cgn.VulnerabilityHexFireDrawer.LocalTimer + cgn.trueVulnerabilityHex; - } + //If this isn't here the drawcode gives an index out of bounds + if (npc.buffTime[buffIndex] > 1) + cgn.trueVulnerabilityHex = true; + if (cgn.VulnerabilityHexFireDrawer != null) + cgn.VulnerabilityHexFireDrawer.SetLifetime = cgn.VulnerabilityHexFireDrawer.LocalTimer + npc.buffTime[buffIndex]; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && cgn.debuffResistanceTimer <= 0) + cgn.debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.buffTime[buffIndex]; - // Apply immunity timer. - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && cgn.debuffResistanceTimer <= 0) - cgn.debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + cgn.trueVulnerabilityHex; - - // Destroy the vanilla buff, we don't use it. - npc.DelBuff(buffIndex); - buffIndex--; } internal static void DrawEffects(NPC npc, ref Color drawColor) diff --git a/Buffs/DamageOverTime/Vaporfied.cs b/Buffs/DamageOverTime/Vaporfied.cs index f4dd7d5fee..e10223020b 100644 --- a/Buffs/DamageOverTime/Vaporfied.cs +++ b/Buffs/DamageOverTime/Vaporfied.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs; +using CalamityMod.DataStructures; +using CalamityMod.NPCs; using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Terraria; @@ -10,12 +11,19 @@ namespace CalamityMod.Buffs.DamageOverTime { public class Vaporfied : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 30, + MinimumDamageTickSize = 6, + MultiplierDamageTickSize = 0 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -25,12 +33,9 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().vaporfied < npc.buffTime[buffIndex]) - npc.Calamity().vaporfied = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().vaporfied; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().vaporfied = true; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin +npc.buffTime[buffIndex]; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/DamageOverTime/VermillionFlux.cs b/Buffs/DamageOverTime/VermillionFlux.cs index f62f39c83c..ab64762903 100644 --- a/Buffs/DamageOverTime/VermillionFlux.cs +++ b/Buffs/DamageOverTime/VermillionFlux.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +10,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class VermillionFlux : ModBuff { + public static DebuffData debuffData = new DebuffData(DebuffData.DebuffBehavior.Electric) + { + EnemyLostRegen = 100, + ElectricDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +31,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().vermillionFlux < npc.buffTime[buffIndex]) - npc.Calamity().vermillionFlux = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().vermillionFlux = true; } internal static void DrawEffects(PlayerDrawSet drawInfo) @@ -57,7 +61,7 @@ namespace CalamityMod.Buffs.DamageOverTime } if (Main.rand.NextBool()) - Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 219, new Vector2(4f, 4f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.Fireworks, new Vector2(4f, 4f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); } } @@ -83,7 +87,7 @@ namespace CalamityMod.Buffs.DamageOverTime } if (Main.rand.NextBool(3)) - Dust.NewDustPerfect(npcSize, 219, new Vector2(4f, 4f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust.NewDustPerfect(npcSize, DustID.Fireworks, new Vector2(4f, 4f).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 0.7f), 0, default, Main.rand.NextFloat(0.2f, 0.6f)); Lighting.AddLight(npc.Center, Color.Red.ToVector3()); } diff --git a/Buffs/DamageOverTime/Voidfrost.cs b/Buffs/DamageOverTime/Voidfrost.cs index 8452f0b9cb..22f0ebda79 100644 --- a/Buffs/DamageOverTime/Voidfrost.cs +++ b/Buffs/DamageOverTime/Voidfrost.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,12 +10,18 @@ namespace CalamityMod.Buffs.DamageOverTime { public class Voidfrost : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 400, + ColdDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -24,10 +31,7 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().voidfrost < npc.buffTime[buffIndex]) - npc.Calamity().voidfrost = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().voidfrost = true; } internal static void DrawEffects(PlayerDrawSet drawInfo, bool hasDebuffResistance = false) diff --git a/Buffs/DamageOverTime/VulnerabilityHex.cs b/Buffs/DamageOverTime/VulnerabilityHex.cs index 45c6a98946..fcde0194fb 100644 --- a/Buffs/DamageOverTime/VulnerabilityHex.cs +++ b/Buffs/DamageOverTime/VulnerabilityHex.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using CalamityMod.DataStructures; +using CalamityMod.Dusts; using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Systems.Collections; @@ -12,11 +13,13 @@ namespace CalamityMod.Buffs.DamageOverTime { public class VulnerabilityHex : ModBuff { - // The visual number displayed in ticks as the enemy takes damage. - public const int TickNumber = 666; - - // The exact amount Vulnerability Hex reduces NPC life regen by. - public const int DPS = TickNumber * 4; // -2664 life regen, 1332 DPS + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 2664, //4x tick size + HeatDebuffScaling = 1, + MinimumDamageTickSize = 666, + MultiplierDamageTickSize = 0 + }; public const int CalamityDuration = 60; public const int AflameDuration = 120; @@ -28,6 +31,7 @@ namespace CalamityMod.Buffs.DamageOverTime Main.buffNoSave[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) => player.Calamity().vHex = true; @@ -35,21 +39,17 @@ namespace CalamityMod.Buffs.DamageOverTime public override void Update(NPC npc, ref int buffIndex) { CalamityGlobalNPC cgn = npc.Calamity(); - if (cgn.vulnerabilityHex < npc.buffTime[buffIndex]) - { - cgn.vulnerabilityHex = npc.buffTime[buffIndex]; - // Set the remaining time of the fire drawer to be exactly right. - if (cgn.VulnerabilityHexFireDrawer != null) - cgn.VulnerabilityHexFireDrawer.SetLifetime = cgn.VulnerabilityHexFireDrawer.LocalTimer + cgn.vulnerabilityHex; - } + + //If this isn't here the drawcode gives an index out of bounds + if (npc.buffTime[buffIndex] > 1) + cgn.vulnerabilityHex = true; + // Set the remaining time of the fire drawer to be exactly right. + if (cgn.VulnerabilityHexFireDrawer != null) + cgn.VulnerabilityHexFireDrawer.SetLifetime = cgn.VulnerabilityHexFireDrawer.LocalTimer + npc.buffTime[buffIndex]; // Apply immunity timer. - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && cgn.debuffResistanceTimer <= 0) - cgn.debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + cgn.vulnerabilityHex; - - // Destroy the vanilla buff, we don't use it. - npc.DelBuff(buffIndex); - buffIndex--; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && cgn.debuffResistanceTimer <= 0) + cgn.debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + +npc.buffTime[buffIndex]; } internal static void DrawEffects(PlayerDrawSet drawInfo) { diff --git a/Buffs/DamageOverTime/WeakBrimstoneFlames.cs b/Buffs/DamageOverTime/WeakBrimstoneFlames.cs index 026531e132..75bf7fdde9 100644 --- a/Buffs/DamageOverTime/WeakBrimstoneFlames.cs +++ b/Buffs/DamageOverTime/WeakBrimstoneFlames.cs @@ -1,16 +1,23 @@ -using Terraria; +using CalamityMod.DataStructures; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Buffs.DamageOverTime { public class WeakBrimstoneFlames : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 10, //This is never inflicted on enemies, this is just a token value + HeatDebuffScaling = 1, + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; Main.buffNoTimeDisplay[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) => player.Calamity().weakBrimstoneFlames = true; diff --git a/Buffs/Mounts/AlicornBuff.cs b/Buffs/Mounts/AlicornBuff.cs deleted file mode 100644 index 34dad87b5a..0000000000 --- a/Buffs/Mounts/AlicornBuff.cs +++ /dev/null @@ -1,21 +0,0 @@ -using CalamityMod.Items.Mounts; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Buffs.Mounts -{ - public class AlicornBuff : ModBuff - { - public override void SetStaticDefaults() - { - Main.buffNoTimeDisplay[Type] = true; - Main.buffNoSave[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - player.mount.SetMount(ModContent.MountType(), player); - player.buffTime[buffIndex] = 10; - player.Calamity().fab = true; - } - } -} diff --git a/Buffs/Mounts/AlicornBuff.png b/Buffs/Mounts/AlicornBuff.png deleted file mode 100644 index f821a3a2bb..0000000000 Binary files a/Buffs/Mounts/AlicornBuff.png and /dev/null differ diff --git a/Buffs/Mounts/BrimroseMount.cs b/Buffs/Mounts/BrimroseMount.cs index 787bc90c18..9b8cdac784 100644 --- a/Buffs/Mounts/BrimroseMount.cs +++ b/Buffs/Mounts/BrimroseMount.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Buffs.Mounts public override void Update(Player player, ref int buffIndex) { - player.mount.SetMount(ModContent.MountType(), player); + player.mount.SetMount(ModContent.MountType(), player); player.buffTime[buffIndex] = 10; } } diff --git a/Buffs/Mounts/MarniteLiftBuff.cs b/Buffs/Mounts/MarniteLiftBuff.cs index 9bb8b0917a..b943fa88cc 100644 --- a/Buffs/Mounts/MarniteLiftBuff.cs +++ b/Buffs/Mounts/MarniteLiftBuff.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Armor.MarniteArchitect; -using CalamityMod.Items.Mounts; using Terraria; using Terraria.ModLoader; diff --git a/Buffs/Pets/BurrowerBuff.cs b/Buffs/Pets/BurrowerBuff.cs new file mode 100644 index 0000000000..f582024ac6 --- /dev/null +++ b/Buffs/Pets/BurrowerBuff.cs @@ -0,0 +1,27 @@ +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class BurrowerBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.buffNoTimeDisplay[Type] = true; + Main.lightPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().burrowerPet = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.GetSource_Buff(buffIndex), player.Top, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 1f); + } + } + } +} diff --git a/Buffs/Pets/BurrowerBuff.png b/Buffs/Pets/BurrowerBuff.png new file mode 100644 index 0000000000..81bd98ffb1 Binary files /dev/null and b/Buffs/Pets/BurrowerBuff.png differ diff --git a/Buffs/Pets/FrostyBatBuff.cs b/Buffs/Pets/FrostyBatBuff.cs new file mode 100644 index 0000000000..b7a6b73091 --- /dev/null +++ b/Buffs/Pets/FrostyBatBuff.cs @@ -0,0 +1,28 @@ +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class FrostyBatBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.buffNoTimeDisplay[Type] = true; + Main.lightPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().frostyBat = true; + int proj = ModContent.ProjectileType(); + bool petProjectileNotSpawned = player.ownedProjectileCounts[proj] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, proj, 0, 0f, player.whoAmI, 0f, 0f); + } + } + } +} diff --git a/Buffs/Summon/FrostbatBuff.png b/Buffs/Pets/FrostyBatBuff.png similarity index 100% rename from Buffs/Summon/FrostbatBuff.png rename to Buffs/Pets/FrostyBatBuff.png diff --git a/Buffs/Pets/ReaverOrbBuff.cs b/Buffs/Pets/ReaverOrbBuff.cs deleted file mode 100644 index 3be4f5a02b..0000000000 --- a/Buffs/Pets/ReaverOrbBuff.cs +++ /dev/null @@ -1,35 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Typeless; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Pets -{ - public class ReaverOrbBuff : ModBuff - { - public override void SetStaticDefaults() - { - Main.buffNoTimeDisplay[Type] = true; - Main.buffNoSave[Type] = true; - //Main.persistentBuff[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - CalamityPlayer modPlayer = player.Calamity(); - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) - { - modPlayer.rOrb = true; - } - if (!modPlayer.rOrb) - { - player.DelBuff(buffIndex); - buffIndex--; - } - else - { - player.buffTime[buffIndex] = 18000; - } - } - } -} diff --git a/Buffs/Pets/ReaverOrbBuff.png b/Buffs/Pets/ReaverOrbBuff.png deleted file mode 100644 index 61a7e2e2d2..0000000000 Binary files a/Buffs/Pets/ReaverOrbBuff.png and /dev/null differ diff --git a/Buffs/Pets/ToastyBatBuff.cs b/Buffs/Pets/ToastyBatBuff.cs new file mode 100644 index 0000000000..c81630f94e --- /dev/null +++ b/Buffs/Pets/ToastyBatBuff.cs @@ -0,0 +1,28 @@ +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class ToastyBatBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.buffNoTimeDisplay[Type] = true; + Main.lightPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + player.Calamity().toastyBat = true; + int proj = ModContent.ProjectileType(); + bool petProjectileNotSpawned = player.ownedProjectileCounts[proj] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + { + Projectile.NewProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, proj, 0, 0f, player.whoAmI, 0f, 0f); + } + } + } +} diff --git a/Buffs/Summon/FlarebatBuff.png b/Buffs/Pets/ToastyBatBuff.png similarity index 100% rename from Buffs/Summon/FlarebatBuff.png rename to Buffs/Pets/ToastyBatBuff.png diff --git a/Buffs/Placeables/BlueCandleBuff.cs b/Buffs/Placeables/BlueCandleBuff.cs new file mode 100644 index 0000000000..a505abfa28 --- /dev/null +++ b/Buffs/Placeables/BlueCandleBuff.cs @@ -0,0 +1,32 @@ +using CalamityMod.Items.Placeables.Furniture; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Placeables +{ + public class BlueCandleBuff : ModBuff + { + public override void SetStaticDefaults() + { + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled + Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; + Main.buffNoSave[Type] = false; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; + } + + // Implementation is partially performed elsewhere using the blueCandle bool. + public override void Update(Player player, ref int buffIndex) + { + player.moveSpeed += WeightlessCandle.MoveSpeedBoost; + player.Calamity().blueCandle = true; + } + } +} diff --git a/Buffs/Placeables/CirrusBlueCandleBuff.png b/Buffs/Placeables/BlueCandleBuff.png similarity index 100% rename from Buffs/Placeables/CirrusBlueCandleBuff.png rename to Buffs/Placeables/BlueCandleBuff.png diff --git a/Buffs/Placeables/CirrusBlueCandleBuff.cs b/Buffs/Placeables/CirrusBlueCandleBuff.cs deleted file mode 100644 index 96900379fe..0000000000 --- a/Buffs/Placeables/CirrusBlueCandleBuff.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CalamityMod.Items.Placeables.Furniture; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Placeables -{ - public class CirrusBlueCandleBuff : ModBuff - { - public override void SetStaticDefaults() - { - // These settings are standard for a "opt-in eternal" buff, which has the following properties: - // - Is not removed on death - // - Saves with the player / is not removed on logout - // - Does not display its time - // - Never reduces its duration - // - Can be manually canceled - Main.pvpBuff[Type] = true; - Main.persistentBuff[Type] = true; - Main.buffNoSave[Type] = false; - Main.buffNoTimeDisplay[Type] = true; - BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; - } - - // Implementation is partially performed elsewhere using the blueCandle bool. - public override void Update(Player player, ref int buffIndex) - { - player.moveSpeed += WeightlessCandle.MoveSpeedBoost; - player.Calamity().blueCandle = true; - } - } -} diff --git a/Buffs/Placeables/CirrusPinkCandleBuff.cs b/Buffs/Placeables/CirrusPinkCandleBuff.cs deleted file mode 100644 index 9701a42348..0000000000 --- a/Buffs/Placeables/CirrusPinkCandleBuff.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Placeables -{ - public class CirrusPinkCandleBuff : ModBuff - { - public override void SetStaticDefaults() - { - // These settings are standard for a "opt-in eternal" buff, which has the following properties: - // - Is not removed on death - // - Saves with the player / is not removed on logout - // - Does not display its time - // - Never reduces its duration - // - Can be manually canceled - Main.pvpBuff[Type] = true; - Main.persistentBuff[Type] = true; - Main.buffNoSave[Type] = false; - Main.buffNoTimeDisplay[Type] = true; - BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; - } - - // Implementation is performed elsewhere using the pinkCandle bool. - public override void Update(Player player, ref int buffIndex) => player.Calamity().pinkCandle = true; - } -} diff --git a/Buffs/Placeables/CirrusPurpleCandleBuff.cs b/Buffs/Placeables/CirrusPurpleCandleBuff.cs deleted file mode 100644 index 1ac263a413..0000000000 --- a/Buffs/Placeables/CirrusPurpleCandleBuff.cs +++ /dev/null @@ -1,36 +0,0 @@ -using CalamityMod.Items.Placeables.Furniture; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Placeables -{ - public class CirrusPurpleCandleBuff : ModBuff - { - public override void SetStaticDefaults() - { - // These settings are standard for a "opt-in eternal" buff, which has the following properties: - // - Is not removed on death - // - Saves with the player / is not removed on logout - // - Does not display its time - // - Never reduces its duration - // - Can be manually canceled - Main.pvpBuff[Type] = true; - Main.persistentBuff[Type] = true; - Main.buffNoSave[Type] = false; - Main.buffNoTimeDisplay[Type] = true; - BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - // MultipliableFloats cannot be added to or reduced. - // To work around this, we get its current value, add what we want to that, - // then multiply it by the ratio between the two. - // A + B = A * ((A+B/A) - float currentEffectiveness = player.DefenseEffectiveness.Value; - float desiredEffectiveness = currentEffectiveness + ResilientCandle.DefenseRatioBonus; - player.DefenseEffectiveness *= desiredEffectiveness / currentEffectiveness; - } - } -} diff --git a/Buffs/Placeables/CirrusYellowCandleBuff.cs b/Buffs/Placeables/CirrusYellowCandleBuff.cs deleted file mode 100644 index 8728f074dc..0000000000 --- a/Buffs/Placeables/CirrusYellowCandleBuff.cs +++ /dev/null @@ -1,36 +0,0 @@ -using CalamityMod.Items.Placeables.Furniture; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.NPC; - -namespace CalamityMod.Buffs.Placeables -{ - public class CirrusYellowCandleBuff : ModBuff - { - public override void SetStaticDefaults() - { - // These settings are standard for a "opt-in eternal" buff, which has the following properties: - // - Is not removed on death - // - Saves with the player / is not removed on logout - // - Does not display its time - // - Never reduces its duration - // - Can be manually canceled - Main.pvpBuff[Type] = true; - Main.persistentBuff[Type] = true; - Main.buffNoSave[Type] = false; - Main.buffNoTimeDisplay[Type] = true; - BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; - } - - // Implementation is performed elsewhere using the yellowCandle bool. - public override void Update(Player player, ref int buffIndex) => player.Calamity().yellowCandle = true; - - // Yellow Candle is implemented as a dirty modifier. - internal static void ModifyHitInfo_Spite(ref HitInfo info) - { - int damageBoost = (int)(info.SourceDamage * SpitefulCandle.ExtraChipDamageRatio); - info.Damage += damageBoost; - } - } -} diff --git a/Buffs/Placeables/PinkCandleBuff.cs b/Buffs/Placeables/PinkCandleBuff.cs new file mode 100644 index 0000000000..5bdbbb661b --- /dev/null +++ b/Buffs/Placeables/PinkCandleBuff.cs @@ -0,0 +1,27 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Placeables +{ + public class PinkCandleBuff : ModBuff + { + public override void SetStaticDefaults() + { + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled + Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; + Main.buffNoSave[Type] = false; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; + } + + // Implementation is performed elsewhere using the pinkCandle bool. + public override void Update(Player player, ref int buffIndex) => player.Calamity().pinkCandle = true; + } +} diff --git a/Buffs/Placeables/CirrusPinkCandleBuff.png b/Buffs/Placeables/PinkCandleBuff.png similarity index 100% rename from Buffs/Placeables/CirrusPinkCandleBuff.png rename to Buffs/Placeables/PinkCandleBuff.png diff --git a/Buffs/Placeables/PurpleCandleBuff.cs b/Buffs/Placeables/PurpleCandleBuff.cs new file mode 100644 index 0000000000..e4d54e4bee --- /dev/null +++ b/Buffs/Placeables/PurpleCandleBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Placeables.Furniture; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Placeables +{ + public class PurpleCandleBuff : ModBuff + { + public override void SetStaticDefaults() + { + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled + Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; + Main.buffNoSave[Type] = false; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + // MultipliableFloats cannot be added to or reduced. + // To work around this, we get its current value, add what we want to that, + // then multiply it by the ratio between the two. + // A + B = A * ((A+B/A) + float currentEffectiveness = player.DefenseEffectiveness.Value; + float desiredEffectiveness = currentEffectiveness + ResilientCandle.DefenseRatioBonus; + player.DefenseEffectiveness *= desiredEffectiveness / currentEffectiveness; + } + } +} diff --git a/Buffs/Placeables/CirrusPurpleCandleBuff.png b/Buffs/Placeables/PurpleCandleBuff.png similarity index 100% rename from Buffs/Placeables/CirrusPurpleCandleBuff.png rename to Buffs/Placeables/PurpleCandleBuff.png diff --git a/Buffs/Placeables/YellowCandleBuff.cs b/Buffs/Placeables/YellowCandleBuff.cs new file mode 100644 index 0000000000..eee56221ff --- /dev/null +++ b/Buffs/Placeables/YellowCandleBuff.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Placeables.Furniture; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.NPC; + +namespace CalamityMod.Buffs.Placeables +{ + public class YellowCandleBuff + : ModBuff + { + public override void SetStaticDefaults() + { + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled + Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; + Main.buffNoSave[Type] = false; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; + } + + // Implementation is performed elsewhere using the yellowCandle bool. + public override void Update(Player player, ref int buffIndex) => player.Calamity().yellowCandle = true; + + // Yellow Candle is implemented as a dirty modifier. + internal static void ModifyHitInfo_Spite(ref HitInfo info) + { + int damageBoost = (int)(info.SourceDamage * SpitefulCandle.ExtraChipDamageRatio); + info.Damage += damageBoost; + } + } +} diff --git a/Buffs/Placeables/CirrusYellowCandleBuff.png b/Buffs/Placeables/YellowCandleBuff.png similarity index 100% rename from Buffs/Placeables/CirrusYellowCandleBuff.png rename to Buffs/Placeables/YellowCandleBuff.png diff --git a/Buffs/PopoBuff.cs b/Buffs/PopoBuff.cs index f5d8e36d54..4b433f99ae 100644 --- a/Buffs/PopoBuff.cs +++ b/Buffs/PopoBuff.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.Accessories.Vanity; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,11 +19,7 @@ namespace CalamityMod.Buffs public override void Update(Player player, ref int buffIndex) { CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.snowmanPrevious) - { - modPlayer.snowmanPower = true; - } - else + if (player.Transformation().Type != ModContent.ItemType()) { player.DelBuff(buffIndex); buffIndex--; diff --git a/Buffs/PopoNoselessBuff.cs b/Buffs/PopoNoselessBuff.cs index ed87c9db8d..fd284151e7 100644 --- a/Buffs/PopoNoselessBuff.cs +++ b/Buffs/PopoNoselessBuff.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.Accessories.Vanity; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,11 +18,8 @@ namespace CalamityMod.Buffs public override void Update(Player player, ref int buffIndex) { CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.snowmanPrevious) - { - modPlayer.snowmanPower = true; + if (player.Transformation().Type == ModContent.ItemType()) modPlayer.snowmanNoseless = true; - } else { player.DelBuff(buffIndex); diff --git a/Buffs/Potions/ShadowBuff.png b/Buffs/Potions/ShadowBuff.png index ed4141070a..bb0b1ed058 100644 Binary files a/Buffs/Potions/ShadowBuff.png and b/Buffs/Potions/ShadowBuff.png differ diff --git a/Buffs/StatBuffs/AbyssalDivingSuitBuff.cs b/Buffs/StatBuffs/AbyssalDivingSuitBuff.cs index 92cab6a912..68c5c642f7 100644 --- a/Buffs/StatBuffs/AbyssalDivingSuitBuff.cs +++ b/Buffs/StatBuffs/AbyssalDivingSuitBuff.cs @@ -21,12 +21,14 @@ namespace CalamityMod.Buffs.StatBuffs if (modPlayer.abyssalDivingSuitPrevious) { if (player.IsUnderwater()) + { + if (player.maxFallSpeed < 9f) + player.maxFallSpeed = 9f; player.gills = true; - modPlayer.abyssalDivingSuitPower = true; + } modPlayer.depthCharm = true; modPlayer.jellyfishNecklace = true; modPlayer.anechoicPlating = true; - modPlayer.ironBoots = true; player.arcticDivingGear = true; player.accFlipper = true; player.accDivingHelm = true; diff --git a/Buffs/StatBuffs/AbyssalDivingSuitPlates.cs b/Buffs/StatBuffs/AbyssalDivingSuitPlates.cs deleted file mode 100644 index b5deec51c2..0000000000 --- a/Buffs/StatBuffs/AbyssalDivingSuitPlates.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Accessories; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.StatBuffs -{ - public class AbyssalDivingSuitPlates : ModBuff - { - public override void SetStaticDefaults() - { - Main.buffNoTimeDisplay[Type] = true; - Main.debuff[Type] = false; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = true; - } - - public override void ModifyBuffText(ref string buffName, ref string tip, ref int rare) - { - tip = base.Description.Format((AbyssalDivingSuit.PlatesAllDamageReduction - Main.LocalPlayer.Calamity().abyssalDivingSuitPlateHits * AbyssalDivingSuit.PlatesHitDecay).ToPercent()); - } - - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().abyssalDivingSuitPlates = true; - } - } -} diff --git a/Buffs/StatBuffs/AbyssalDivingSuitPlates.png b/Buffs/StatBuffs/AbyssalDivingSuitPlates.png deleted file mode 100644 index a89877f9ad..0000000000 Binary files a/Buffs/StatBuffs/AbyssalDivingSuitPlates.png and /dev/null differ diff --git a/Buffs/StatBuffs/AbyssalMadness.cs b/Buffs/StatBuffs/AbyssalMadness.cs index 1851277c44..60f92a0141 100644 --- a/Buffs/StatBuffs/AbyssalMadness.cs +++ b/Buffs/StatBuffs/AbyssalMadness.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { - player.Calamity().omegaBlueHentai = true; + player.Calamity().omegaBlueAbyssalMadness = true; } } } diff --git a/Buffs/StatBuffs/AdrenalineMode.cs b/Buffs/StatBuffs/AdrenalineMode.cs index c74fdafa69..23871659dc 100644 --- a/Buffs/StatBuffs/AdrenalineMode.cs +++ b/Buffs/StatBuffs/AdrenalineMode.cs @@ -14,13 +14,13 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; + Main.buffNoTimeDisplay[Type] = true; // Consistency with Rage (Look at the bar instead) BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; } public override void Update(Player player, ref int buffIndex) { player.Calamity().adrenalineModeActive = true; - player.Calamity().AdrenalineTrail = true; } public override void ModifyBuffText(ref string buffName, ref string tip, ref int rare) diff --git a/Buffs/StatBuffs/AquaticHeartBuff.cs b/Buffs/StatBuffs/AquaticHeartBuff.cs index 344acacd15..5dde4436f3 100644 --- a/Buffs/StatBuffs/AquaticHeartBuff.cs +++ b/Buffs/StatBuffs/AquaticHeartBuff.cs @@ -20,14 +20,13 @@ namespace CalamityMod.Buffs.StatBuffs CalamityPlayer modPlayer = player.Calamity(); if (modPlayer.aquaticHeartPrevious) { - modPlayer.aquaticHeartPower = true; player.ignoreWater = NPC.downedBoss3; player.accFlipper = true; if (player.breath <= player.breathMax + 2 && !modPlayer.ZoneAbyss && NPC.downedBoss3) { player.breath = player.breathMax + 3; } - if (Main.myPlayer == player.whoAmI && player.wet && NPC.downedBoss3) + if (Main.myPlayer == player.whoAmI && player.Calamity().countsAsAnyWet && NPC.downedBoss3) { player.AddBuff(ModContent.BuffType(), 360); } diff --git a/Buffs/StatBuffs/BossEffects.cs b/Buffs/StatBuffs/BossEffects.cs index e32088eaa6..98d9c8035d 100644 --- a/Buffs/StatBuffs/BossEffects.cs +++ b/Buffs/StatBuffs/BossEffects.cs @@ -1,5 +1,4 @@ -using System.Text; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Buffs/StatBuffs/BrutalCarnage.cs b/Buffs/StatBuffs/BrutalCarnage.cs deleted file mode 100644 index bcb31db8f7..0000000000 --- a/Buffs/StatBuffs/BrutalCarnage.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Terraria; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.StatBuffs -{ - public class BrutalCarnage : ModBuff - { - public static float MeleeDamageBoost = 0.2f; - public override LocalizedText Description => base.Description.WithFormatArgs(MeleeDamageBoost.ToPercent()); - - public override void SetStaticDefaults() - { - Main.debuff[Type] = false; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().brutalCarnage = true; - } - } -} diff --git a/Buffs/StatBuffs/BrutalCarnage.png b/Buffs/StatBuffs/BrutalCarnage.png deleted file mode 100644 index 9b3ce4f18a..0000000000 Binary files a/Buffs/StatBuffs/BrutalCarnage.png and /dev/null differ diff --git a/Buffs/StatBuffs/ChiBuff.cs b/Buffs/StatBuffs/ChiBuff.cs index 51b9ef2629..d1c94aef0d 100644 --- a/Buffs/StatBuffs/ChiBuff.cs +++ b/Buffs/StatBuffs/ChiBuff.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { - player.Calamity().trinketOfChiBuff = true; + player.endurance += 0.08f; } } } diff --git a/Buffs/StatBuffs/Encased.cs b/Buffs/StatBuffs/Encased.cs index 34013fef8b..fc8282145b 100644 --- a/Buffs/StatBuffs/Encased.cs +++ b/Buffs/StatBuffs/Encased.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Buffs.StatBuffs { public class Encased : ModBuff { - public override LocalizedText Description => base.Description.WithFormatArgs(PermafrostsConcoction.EncasedDefenseBoost, PermafrostsConcoction.EncasedAllDamageReduction.ToPercent()); + public override LocalizedText Description => base.Description.WithFormatArgs(PermafrostsConcoction.EncasedDefenseBoost, PermafrostsConcoction.EncasedDamageReductionBoost.ToPercent()); public override void SetStaticDefaults() { diff --git a/Buffs/StatBuffs/FortunesFavor.cs b/Buffs/StatBuffs/FortunesFavor.cs new file mode 100644 index 0000000000..64b9d077ee --- /dev/null +++ b/Buffs/StatBuffs/FortunesFavor.cs @@ -0,0 +1,48 @@ +using CalamityMod.DataStructures; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatBuffs +{ + public class FortunesFavor : ModBuff + { + public static int FortunesFavorRegenBoost = 3; + + public override LocalizedText Description => base.Description.WithFormatArgs(FortunesFavorRegenBoost.ToRegenPerSecond()); + + public override void SetStaticDefaults() + { + Main.debuff[Type] = false; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().fortunesFavor = true; // Draw FX handled in CalamityPlayerDrawEffects as is standard for regen buffs + } + + public override void Update(NPC npc, ref int buffIndex) + { + npc.Calamity().fortunesFavor = true; + } + + internal static void DrawEffects(NPC npc, ref Color drawColor) + { + Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); + + if (Main.rand.NextBool(16)) + { + Particle Plus = new HealingPlus(npcSize, Main.rand.NextFloat(0.3f, 0.5f), new Vector2(0, Main.rand.NextFloat(-2f, -3.5f)) + npc.velocity, Color.Gold, Color.Goldenrod, Main.rand.Next(9, 13)); + GeneralParticleHandler.SpawnParticle(Plus); + } + Lighting.AddLight(npc.Center, Color.Gold.ToVector3() * 0.1f); + } + + } +} diff --git a/Buffs/StatBuffs/FortunesFavor.png b/Buffs/StatBuffs/FortunesFavor.png new file mode 100644 index 0000000000..4f8923c51f Binary files /dev/null and b/Buffs/StatBuffs/FortunesFavor.png differ diff --git a/Buffs/StatBuffs/HallowedRuneDefense.cs b/Buffs/StatBuffs/HallowedRuneDefense.cs index f307c99e49..75e9d6ad06 100644 --- a/Buffs/StatBuffs/HallowedRuneDefense.cs +++ b/Buffs/StatBuffs/HallowedRuneDefense.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Buffs.StatBuffs { public class HallowedRuneDefense : ModBuff { - public override LocalizedText Description => base.Description.WithFormatArgs(HallowedRune.DefenseBoost, HallowedRune.DamageReductionBoost.ToPercent()); + public override LocalizedText Description => base.Description.WithFormatArgs(HallowedRune.DefenseBoost); public override void SetStaticDefaults() { @@ -20,7 +20,6 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { player.statDefense += HallowedRune.DefenseBoost; - player.endurance += HallowedRune.DamageReductionBoost; // TODO -- is this applied too late to be affected by the DR softcap? } } } diff --git a/Buffs/StatBuffs/IceShieldBuff.cs b/Buffs/StatBuffs/IceShieldBuff.cs index b652f9f936..38b2f879da 100644 --- a/Buffs/StatBuffs/IceShieldBuff.cs +++ b/Buffs/StatBuffs/IceShieldBuff.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Buffs.StatBuffs { public class IceShieldBuff : ModBuff { - public override LocalizedText Description => base.Description.WithFormatArgs(AquaticHeart.IceShieldAllDamageReduction.ToPercent()); + public override LocalizedText Description => base.Description.WithFormatArgs(AquaticHeart.IceShieldDamageReductionBoost.ToPercent()); public override void SetStaticDefaults() { diff --git a/Buffs/StatBuffs/KamiBuff.cs b/Buffs/StatBuffs/KamiBuff.cs deleted file mode 100644 index 1f0a06c940..0000000000 --- a/Buffs/StatBuffs/KamiBuff.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Weapons.Typeless; -using Terraria; -using Terraria.Audio; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.StatBuffs -{ - public class KamiBuff : ModBuff - { - public override LocalizedText Description => base.Description.WithFormatArgs(YanmeisKnife.RunSpeedBoost.ToPercent()); - - public override void SetStaticDefaults() - { - Main.debuff[Type] = false; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = true; - } - - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().kamiBoost = true; - if (player.buffTime[buffIndex] == 1) - SoundEngine.PlaySound(YanmeisKnife.ExpireSound, player.Center); - } - } -} diff --git a/Buffs/StatBuffs/KamiBuff.png b/Buffs/StatBuffs/KamiBuff.png deleted file mode 100644 index 4fdc0fff94..0000000000 Binary files a/Buffs/StatBuffs/KamiBuff.png and /dev/null differ diff --git a/Buffs/StatBuffs/Mushy.cs b/Buffs/StatBuffs/Mushy.cs index 23ae4f785c..0ae91c9625 100644 --- a/Buffs/StatBuffs/Mushy.cs +++ b/Buffs/StatBuffs/Mushy.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -8,7 +9,7 @@ namespace CalamityMod.Buffs.StatBuffs { public class Mushy : ModBuff { - public static int DefenseBoost = 8; + public static int DefenseBoost = 5; public static int RegenBoost = 2; public override LocalizedText Description => base.Description.WithFormatArgs(DefenseBoost, RegenBoost.ToRegenPerSecond()); @@ -30,7 +31,7 @@ namespace CalamityMod.Buffs.StatBuffs if (Main.rand.NextBool(4)) { - Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot, 56, Vector2.Zero, 100, default, 0.9f); + Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot, DustID.BlueFairy, Vector2.Zero, 100, default, 0.9f); dust.noGravity = true; dust.velocity *= 0.5f; dust.velocity.Y -= 0.1f; diff --git a/Buffs/StatBuffs/PhantomicShield.cs b/Buffs/StatBuffs/PhantomicShield.cs index dc8d920fad..b44b498755 100644 --- a/Buffs/StatBuffs/PhantomicShield.cs +++ b/Buffs/StatBuffs/PhantomicShield.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Buffs.StatBuffs { public class PhantomicShield : ModBuff { - public override LocalizedText Description => base.Description.WithFormatArgs(PhantomicArtifact.DefenseBoost, PhantomicArtifact.DamageReductionBoost.ToPercent()); + public override LocalizedText Description => base.Description.WithFormatArgs(PhantomicArtifact.DefenseBoost); public override void SetStaticDefaults() { @@ -19,7 +19,6 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { - player.endurance += PhantomicArtifact.DamageReductionBoost; // TODO -- is this applied too late to be affected by the DR softcap? player.statDefense += PhantomicArtifact.DefenseBoost; } } diff --git a/Buffs/StatBuffs/RageMode.cs b/Buffs/StatBuffs/RageMode.cs index 393123c108..b80c438e4c 100644 --- a/Buffs/StatBuffs/RageMode.cs +++ b/Buffs/StatBuffs/RageMode.cs @@ -1,6 +1,5 @@ using CalamityMod.Balancing; using CalamityMod.CalPlayer; -using CalamityMod.Items.Accessories; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; diff --git a/Buffs/StatBuffs/SpiritDefense.cs b/Buffs/StatBuffs/SpiritDefense.cs index 664de50b2b..ad39d8d70d 100644 --- a/Buffs/StatBuffs/SpiritDefense.cs +++ b/Buffs/StatBuffs/SpiritDefense.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Buffs.StatBuffs { public class SpiritDefense : ModBuff { - public override LocalizedText Description => base.Description.WithFormatArgs(SpiritGlyph.DefenseBoost, SpiritGlyph.DamageReductionBoost.ToPercent()); + public override LocalizedText Description => base.Description.WithFormatArgs(SpiritGlyph.DefenseBoost); public override void SetStaticDefaults() { @@ -20,7 +20,6 @@ namespace CalamityMod.Buffs.StatBuffs public override void Update(Player player, ref int buffIndex) { player.statDefense += SpiritGlyph.DefenseBoost; - player.endurance += SpiritGlyph.DamageReductionBoost; // TODO -- is this applied too late to be affected by the DR softcap? } } } diff --git a/Buffs/StatBuffs/TarragonCloak.cs b/Buffs/StatBuffs/TarragonCloak.cs index bcd5138b3d..12e659b6e0 100644 --- a/Buffs/StatBuffs/TarragonCloak.cs +++ b/Buffs/StatBuffs/TarragonCloak.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.Items.Armor.Tarragon; +using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -7,8 +8,7 @@ namespace CalamityMod.Buffs.StatBuffs { public class TarragonCloak : ModBuff { - public static double ContactDamageReduction = 0.5D; - public override LocalizedText Description => base.Description.WithFormatArgs(ContactDamageReduction.ToPercent()); + public override LocalizedText Description => base.Description.WithFormatArgs(TarragonHeadMelee.CloakContactDamageReduction.ToPercent()); public override void SetStaticDefaults() { diff --git a/Buffs/StatDebuffs/AbsorberAffliction.cs b/Buffs/StatDebuffs/AbsorberAffliction.cs index f166ee030d..55df57f042 100644 --- a/Buffs/StatDebuffs/AbsorberAffliction.cs +++ b/Buffs/StatDebuffs/AbsorberAffliction.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using CalamityMod.DataStructures; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -8,19 +9,24 @@ namespace CalamityMod.Buffs.StatDebuffs { public class AbsorberAffliction : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 400, + SicknessDebuffScaling = 1, + MultiplierDamageTickSize = 1 / 20f + + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().absorberAffliction < npc.buffTime[buffIndex]) - npc.Calamity().absorberAffliction = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().absorberAffliction = true; } internal static void DrawEffects(NPC npc, ref Color drawColor) diff --git a/Buffs/StatDebuffs/ArmorCrunch.cs b/Buffs/StatDebuffs/ArmorCrunch.cs index d01829fdb0..6d8a7c61b3 100644 --- a/Buffs/StatDebuffs/ArmorCrunch.cs +++ b/Buffs/StatDebuffs/ArmorCrunch.cs @@ -22,15 +22,12 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().aCrunch < npc.buffTime[buffIndex]) - npc.Calamity().aCrunch = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().armorCrunch = true; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().aCrunch = true; + player.Calamity().armorCrunch = true; } } } diff --git a/Buffs/StatDebuffs/Crumbling.cs b/Buffs/StatDebuffs/Crumbling.cs index 2173cf756b..2539449caf 100644 --- a/Buffs/StatDebuffs/Crumbling.cs +++ b/Buffs/StatDebuffs/Crumbling.cs @@ -22,10 +22,7 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().crumble < npc.buffTime[buffIndex]) - npc.Calamity().crumble = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().crumble = true; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/DoGExtremeGravity.cs b/Buffs/StatDebuffs/DoGExtremeGravity.cs index dff7c395f3..1e72478486 100644 --- a/Buffs/StatDebuffs/DoGExtremeGravity.cs +++ b/Buffs/StatDebuffs/DoGExtremeGravity.cs @@ -1,4 +1,6 @@ -using Terraria; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -23,6 +25,18 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(Player player, ref int buffIndex) { player.Calamity().DoGExtremeGravity = true; + if (player.miscCounter % 10 == 0) + { + float halfWidth = player.width * 0.5f; + float halfHeight = player.height * 0.5f; + for (var i = 0; i < 1; i++) + { + var position = player.Center + new Vector2(Main.rand.NextFloat(-halfWidth, halfWidth), Main.rand.NextFloat(-halfHeight, halfHeight)); + Particle arrow = new StatChangeArrow(position, -(Vector2.UnitY * 5).RotatedByRandom(1f), MathHelper.PiOver2, Color.Fuchsia, Color.Fuchsia * 0f, 0.75f, 60); + ((StatChangeArrow)arrow).AffectedByGravity = true; + GeneralParticleHandler.SpawnParticle(arrow); + } + } } } } diff --git a/Buffs/StatDebuffs/Eutrophication.cs b/Buffs/StatDebuffs/Eutrophication.cs index 0f99d11480..eca32f09f7 100644 --- a/Buffs/StatDebuffs/Eutrophication.cs +++ b/Buffs/StatDebuffs/Eutrophication.cs @@ -25,12 +25,9 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().eutrophication < npc.buffTime[buffIndex]) - npc.Calamity().eutrophication = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().eutrophication; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().eutrophication = true; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.buffTime[buffIndex]; } internal static void DrawEffects(PlayerDrawSet drawInfo) diff --git a/Buffs/StatDebuffs/FrozenLungs.cs b/Buffs/StatDebuffs/FrozenLungs.cs index 4a7e8fb6ca..49d31a21bf 100644 --- a/Buffs/StatDebuffs/FrozenLungs.cs +++ b/Buffs/StatDebuffs/FrozenLungs.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(Player player, ref int buffIndex) { - player.Calamity().iCantBreathe = true; + player.Calamity().frozenLungs = true; } } } diff --git a/Buffs/StatDebuffs/GalvanicCorrosion.cs b/Buffs/StatDebuffs/GalvanicCorrosion.cs index d8b4a6e77c..018e738c30 100644 --- a/Buffs/StatDebuffs/GalvanicCorrosion.cs +++ b/Buffs/StatDebuffs/GalvanicCorrosion.cs @@ -18,12 +18,9 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().tesla < npc.buffTime[buffIndex]) - npc.Calamity().tesla = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().tesla; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().galvanicCorrosion = true; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.buffTime[buffIndex]; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/StatDebuffs/GlacialState.cs b/Buffs/StatDebuffs/GlacialState.cs index ffbb2a810b..dc312681fa 100644 --- a/Buffs/StatDebuffs/GlacialState.cs +++ b/Buffs/StatDebuffs/GlacialState.cs @@ -1,8 +1,6 @@ using CalamityMod.NPCs; using CalamityMod.Systems.Collections; -using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -18,34 +16,13 @@ namespace CalamityMod.Buffs.StatDebuffs BuffID.Sets.LongerExpertDebuff[Type] = true; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().gState = true; - } - public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().gState < npc.buffTime[buffIndex]) - npc.Calamity().gState = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().gState; + npc.Calamity().glacialState = true; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.buffTime[buffIndex]; npc.DelBuff(buffIndex); buffIndex--; } - - internal static void DrawEffects(PlayerDrawSet drawInfo) - { - Player Player = drawInfo.drawPlayer; - - if (Main.rand.NextBool(4)) - { - Dust d = Dust.NewDustDirect(Player.Center - 10 * Vector2.One, 20, 20, DustID.IcyMerman); - d.noGravity = Main.rand.NextBool(); - d.noLight = false; - d.velocity *= 0.2f; - d.velocity.Y -= Main.rand.NextFloat(0.4f, 0.6f); - d.scale = Main.rand.NextFloat(0.4f, 0.7f); - } - } } } diff --git a/Buffs/StatDebuffs/Irradiated.cs b/Buffs/StatDebuffs/Irradiated.cs index ca52ae932a..8244acd871 100644 --- a/Buffs/StatDebuffs/Irradiated.cs +++ b/Buffs/StatDebuffs/Irradiated.cs @@ -1,4 +1,6 @@ -using Terraria; +using CalamityMod.DataStructures; +using CalamityMod.Projectiles.Magic; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -6,6 +8,44 @@ namespace CalamityMod.Buffs.StatDebuffs { public class Irradiated : ModBuff { + public static DebuffData debuffData = new DebuffData() + { + EnemyLostRegen = 20, //Base irradiated DOT. This is changed with some application sources. + NPCLifeRegenMethod = IrradiatedNPCLifeRegen + }; + public static void IrradiatedNPCLifeRegen(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + var cnpc = npc.Calamity(); + int projectileCount = 0; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && + p.ai[0] == 1f && p.ai[1] == npc.whoAmI) + { + projectileCount++; + } + } + int baseIrradiatedDoTValue = (int)(cnpc.scionsCurioEffected ? (int)(debuffData.EnemyLostRegen * 1.5f) : debuffData.EnemyLostRegen); + if (cnpc.scionsCurioEffected) + { + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + if (player.active) + { + float playerRangedDamage = player.GetTotalDamage(DamageClass.Ranged).ApplyTo(baseIrradiatedDoTValue * (1 + player.GetTotalCritChance(DamageClass.Ranged) * 0.01f)); + if (playerRangedDamage > baseIrradiatedDoTValue && player.Calamity().scionsCurio) + { + baseIrradiatedDoTValue = (int)playerRangedDamage; + } + } + } + } + if (projectileCount > 0) + cnpc.ApplyDPSDebuff(projectileCount * baseIrradiatedDoTValue, projectileCount * 4, ref npc.lifeRegen, ref damage); + else + cnpc.ApplyDPSDebuff(baseIrradiatedDoTValue, baseIrradiatedDoTValue / 20, ref npc.lifeRegen, ref damage); + } public override void SetStaticDefaults() { Main.debuff[Type] = true; @@ -13,6 +53,7 @@ namespace CalamityMod.Buffs.StatDebuffs Main.buffNoSave[Type] = true; BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) @@ -22,10 +63,7 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().irradiated < npc.buffTime[buffIndex]) - npc.Calamity().irradiated = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().irradiated = true; } } } diff --git a/Buffs/StatDebuffs/KamiFlu.cs b/Buffs/StatDebuffs/KamiFlu.cs deleted file mode 100644 index a4f3908529..0000000000 --- a/Buffs/StatDebuffs/KamiFlu.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.NPCs; -using CalamityMod.Systems.Collections; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.StatDebuffs -{ - public class KamiFlu : ModBuff - { - public override void SetStaticDefaults() - { - Main.debuff[Type] = true; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = false; - } - - public override void Update(NPC npc, ref int buffIndex) - { - if (npc.Calamity().kamiFlu < npc.buffTime[buffIndex]) - npc.Calamity().kamiFlu = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().kamiFlu; - npc.DelBuff(buffIndex); - buffIndex--; - } - } -} diff --git a/Buffs/StatDebuffs/KamiFlu.png b/Buffs/StatDebuffs/KamiFlu.png deleted file mode 100644 index df7af84f98..0000000000 Binary files a/Buffs/StatDebuffs/KamiFlu.png and /dev/null differ diff --git a/Buffs/StatDebuffs/MarkedforDeath.cs b/Buffs/StatDebuffs/MarkedforDeath.cs index 3a0518630c..e7b836d7ee 100644 --- a/Buffs/StatDebuffs/MarkedforDeath.cs +++ b/Buffs/StatDebuffs/MarkedforDeath.cs @@ -16,10 +16,7 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().marked < npc.buffTime[buffIndex]) - npc.Calamity().marked = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().markedForDeath = true; } } } diff --git a/Buffs/StatDebuffs/NOU.cs b/Buffs/StatDebuffs/NOU.cs index 1682bb88c0..202d147d09 100644 --- a/Buffs/StatDebuffs/NOU.cs +++ b/Buffs/StatDebuffs/NOU.cs @@ -1,5 +1,4 @@ -using System; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Buffs/StatDebuffs/PearlAura.cs b/Buffs/StatDebuffs/PearlAura.cs index ed0232c4b2..2b0d1bf5bc 100644 --- a/Buffs/StatDebuffs/PearlAura.cs +++ b/Buffs/StatDebuffs/PearlAura.cs @@ -16,10 +16,7 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().pearlAura < npc.buffTime[buffIndex]) - npc.Calamity().pearlAura = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().pearlAura = true; } internal static void DrawEffects(NPC npc, ref Color drawColor) diff --git a/Buffs/StatDebuffs/ProfanedWeakness.cs b/Buffs/StatDebuffs/ProfanedWeakness.cs index e9d61ddd1a..399deb9bc1 100644 --- a/Buffs/StatDebuffs/ProfanedWeakness.cs +++ b/Buffs/StatDebuffs/ProfanedWeakness.cs @@ -16,10 +16,7 @@ namespace CalamityMod.Buffs.StatDebuffs } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().relicOfResilienceWeakness < npc.buffTime[buffIndex]) - npc.Calamity().relicOfResilienceWeakness = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().relicOfResilienceWeakness = true; } internal static void DrawEffects(NPC npc, ref Color drawColor) { diff --git a/Buffs/StatDebuffs/TemporalSadness.cs b/Buffs/StatDebuffs/TemporalSadness.cs index b3eb4099dc..943fefca48 100644 --- a/Buffs/StatDebuffs/TemporalSadness.cs +++ b/Buffs/StatDebuffs/TemporalSadness.cs @@ -16,12 +16,9 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().tSad < npc.buffTime[buffIndex]) - npc.Calamity().tSad = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().tSad; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().temporalSadness = true; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.buffTime[buffIndex]; } } } diff --git a/Buffs/StatDebuffs/TimeDistortion.cs b/Buffs/StatDebuffs/TimeDistortion.cs index 95a1cf23fa..3f84b4677e 100644 --- a/Buffs/StatDebuffs/TimeDistortion.cs +++ b/Buffs/StatDebuffs/TimeDistortion.cs @@ -18,12 +18,9 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().timeSlow < npc.buffTime[buffIndex]) - npc.Calamity().timeSlow = npc.buffTime[buffIndex]; - if ((EnemyImmunitiesList.Includes(npc.type) || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) - npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.Calamity().timeSlow; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().timeDistortion = true; + if ((CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[npc.type] || npc.boss) && npc.Calamity().debuffResistanceTimer <= 0) + npc.Calamity().debuffResistanceTimer = CalamityGlobalNPC.slowingDebuffResistanceMin + npc.buffTime[buffIndex]; } } } diff --git a/Buffs/StatDebuffs/Warped.cs b/Buffs/StatDebuffs/Warped.cs index fe16e114cf..56314f3682 100644 --- a/Buffs/StatDebuffs/Warped.cs +++ b/Buffs/StatDebuffs/Warped.cs @@ -1,4 +1,6 @@ -using Terraria; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,6 +20,18 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(Player player, ref int buffIndex) { player.Calamity().warped = true; + if (player.miscCounter % 10 == 0) + { + float halfWidth = player.width * 0.5f; + float halfHeight = player.height * 0.5f; + for (var i = 0; i < 1; i++) + { + var position = player.Center + new Vector2(Main.rand.NextFloat(-halfWidth, halfWidth), Main.rand.NextFloat(-halfHeight, halfHeight)); + Particle arrow = new StatChangeArrow(position, -(Vector2.UnitY * 5).RotatedByRandom(1f), -MathHelper.PiOver2, Color.Cyan, Color.Cyan * 0f, 0.75f, 60); + ((StatChangeArrow)arrow).AffectedByGravity = true; + GeneralParticleHandler.SpawnParticle(arrow); + } + } } } } diff --git a/Buffs/StatDebuffs/WhisperingDeath.cs b/Buffs/StatDebuffs/WhisperingDeath.cs index b1b0eac60b..04f29017ff 100644 --- a/Buffs/StatDebuffs/WhisperingDeath.cs +++ b/Buffs/StatDebuffs/WhisperingDeath.cs @@ -1,4 +1,5 @@ -using Terraria; +using CalamityMod.DataStructures; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -6,25 +7,28 @@ namespace CalamityMod.Buffs.StatDebuffs { public class WhisperingDeath : ModBuff { + // Whispering Death does not deal DoT, but is classified as a sickness debuff. + public static DebuffData debuffData = new DebuffData() + { + SicknessDebuffScaling = 1 + }; public override void SetStaticDefaults() { Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; BuffID.Sets.LongerExpertDebuff[Type] = true; + BuffDatasets.DebuffDataset[Type] = debuffData; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().wDeath = true; + player.Calamity().whisperingDeath = true; } public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().wDeath < npc.buffTime[buffIndex]) - npc.Calamity().wDeath = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().whisperingDeath = true; } } } diff --git a/Buffs/StatDebuffs/WitherDebuff.cs b/Buffs/StatDebuffs/WitherDebuff.cs index bc161eae70..57042bb708 100644 --- a/Buffs/StatDebuffs/WitherDebuff.cs +++ b/Buffs/StatDebuffs/WitherDebuff.cs @@ -20,10 +20,7 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(NPC npc, ref int buffIndex) { - if (npc.Calamity().wither < npc.buffTime[buffIndex]) - npc.Calamity().wither = npc.buffTime[buffIndex]; - npc.DelBuff(buffIndex); - buffIndex--; + npc.Calamity().wither = true; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/Summon/AqueousHunterDroneBuff.cs b/Buffs/Summon/AqueousHunterDroneBuff.cs new file mode 100644 index 0000000000..292d0df8e0 --- /dev/null +++ b/Buffs/Summon/AqueousHunterDroneBuff.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.DraedonsArsenal; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class AqueousHunterDroneBuff : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.aqueousHunterDrone; + } +} diff --git a/Buffs/Summon/AqueousHunterDroneBuff.png b/Buffs/Summon/AqueousHunterDroneBuff.png new file mode 100644 index 0000000000..728c691251 Binary files /dev/null and b/Buffs/Summon/AqueousHunterDroneBuff.png differ diff --git a/Buffs/Summon/BrimstoneElemental.cs b/Buffs/Summon/BrimstoneElemental.cs new file mode 100644 index 0000000000..7f2595443c --- /dev/null +++ b/Buffs/Summon/BrimstoneElemental.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.Summon; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class BrimstoneElemental : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.brimEleBuff; + } +} diff --git a/Buffs/Summon/BrimstoneWaifu.png b/Buffs/Summon/BrimstoneElemental.png similarity index 100% rename from Buffs/Summon/BrimstoneWaifu.png rename to Buffs/Summon/BrimstoneElemental.png diff --git a/Buffs/Summon/BrimstoneWaifu.cs b/Buffs/Summon/BrimstoneWaifu.cs deleted file mode 100644 index f6b12d5477..0000000000 --- a/Buffs/Summon/BrimstoneWaifu.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class BrimstoneWaifu : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.bWaifu; - } -} diff --git a/Buffs/Summon/BrittleStar.png b/Buffs/Summon/BrittleStar.png index 3ae1924e0d..30f00daabc 100644 Binary files a/Buffs/Summon/BrittleStar.png and b/Buffs/Summon/BrittleStar.png differ diff --git a/Buffs/Summon/CloudElemental.cs b/Buffs/Summon/CloudElemental.cs new file mode 100644 index 0000000000..b276cd9b57 --- /dev/null +++ b/Buffs/Summon/CloudElemental.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.Summon; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class CloudElemental : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.cloudEleBuff; + } +} diff --git a/Buffs/Summon/CloudyWaifu.png b/Buffs/Summon/CloudElemental.png similarity index 100% rename from Buffs/Summon/CloudyWaifu.png rename to Buffs/Summon/CloudElemental.png diff --git a/Buffs/Summon/CloudyWaifu.cs b/Buffs/Summon/CloudyWaifu.cs deleted file mode 100644 index 4b342af8c1..0000000000 --- a/Buffs/Summon/CloudyWaifu.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class CloudyWaifu : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.cWaifu; - } -} diff --git a/Buffs/Summon/EnchantedKnifeStaffBuff.cs b/Buffs/Summon/EnchantedKnifeStaffBuff.cs new file mode 100644 index 0000000000..1cff59dc11 --- /dev/null +++ b/Buffs/Summon/EnchantedKnifeStaffBuff.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.Summon; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class EnchantedKnifeStaffBuff : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.EnchantedKnifeStaffBool; + } +} diff --git a/Buffs/Summon/EnchantedKnifeStaffBuff.png b/Buffs/Summon/EnchantedKnifeStaffBuff.png new file mode 100644 index 0000000000..a0efadf188 Binary files /dev/null and b/Buffs/Summon/EnchantedKnifeStaffBuff.png differ diff --git a/Buffs/Summon/FlarebatBuff.cs b/Buffs/Summon/FlarebatBuff.cs deleted file mode 100644 index 7be2c4732c..0000000000 --- a/Buffs/Summon/FlarebatBuff.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class FlarebatBuff : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.FlarebatBool; - } -} diff --git a/Buffs/Summon/FrostbatBuff.cs b/Buffs/Summon/FrostbatBuff.cs deleted file mode 100644 index 6bc6421c8d..0000000000 --- a/Buffs/Summon/FrostbatBuff.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class FrostbatBuff : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.FrostbatBool; - } -} diff --git a/Buffs/Summon/HotE.cs b/Buffs/Summon/HotE.cs index 99bd030f4d..3e8eae1f10 100644 --- a/Buffs/Summon/HotE.cs +++ b/Buffs/Summon/HotE.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Buffs.Summon { CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.allWaifus) + if (!modPlayer.allElementals) { player.DelBuff(buffIndex); buffIndex--; diff --git a/Buffs/Summon/Mechworm.cs b/Buffs/Summon/Mechworm.cs deleted file mode 100644 index 56abef6ff2..0000000000 --- a/Buffs/Summon/Mechworm.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class Mechworm : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.mWorm; - } -} diff --git a/Buffs/Summon/ProfanedSoulGuardians.cs b/Buffs/Summon/ProfanedSoulGuardians.cs index 1c2222eada..8e9f098a40 100644 --- a/Buffs/Summon/ProfanedSoulGuardians.cs +++ b/Buffs/Summon/ProfanedSoulGuardians.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ModLoader; @@ -15,7 +16,7 @@ namespace CalamityMod.Buffs.Summon public override void Update(Player player, ref int buffIndex) { CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.pSoulGuardians || modPlayer.profanedCrystalBuffs) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 || modPlayer.profanedCrystalBuffs) { player.DelBuff(buffIndex); buffIndex--; diff --git a/Buffs/Summon/RareSandElemental.cs b/Buffs/Summon/RareSandElemental.cs new file mode 100644 index 0000000000..2748620ff6 --- /dev/null +++ b/Buffs/Summon/RareSandElemental.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.Summon; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class RareSandElemental : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.rareSandEleBuff; + } +} diff --git a/Buffs/Summon/SandyHealingWaifu.png b/Buffs/Summon/RareSandElemental.png similarity index 100% rename from Buffs/Summon/SandyHealingWaifu.png rename to Buffs/Summon/RareSandElemental.png diff --git a/Buffs/Summon/SandElemental.cs b/Buffs/Summon/SandElemental.cs new file mode 100644 index 0000000000..5b9f22d6bc --- /dev/null +++ b/Buffs/Summon/SandElemental.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.Summon; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class SandElemental : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.sandEleBuff; + } +} diff --git a/Buffs/Summon/SandyWaifu.png b/Buffs/Summon/SandElemental.png similarity index 100% rename from Buffs/Summon/SandyWaifu.png rename to Buffs/Summon/SandElemental.png diff --git a/Buffs/Summon/SandyHealingWaifu.cs b/Buffs/Summon/SandyHealingWaifu.cs deleted file mode 100644 index 9d57de49d4..0000000000 --- a/Buffs/Summon/SandyHealingWaifu.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class SandyHealingWaifu : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.dWaifu; - } -} diff --git a/Buffs/Summon/SandyWaifu.cs b/Buffs/Summon/SandyWaifu.cs deleted file mode 100644 index 383abea36f..0000000000 --- a/Buffs/Summon/SandyWaifu.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class SandyWaifu : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.sWaifu; - } -} diff --git a/Buffs/Summon/SarosPossessionBuff.cs b/Buffs/Summon/SarosPossessionBuff.cs index 74791c651f..16aae73c5f 100644 --- a/Buffs/Summon/SarosPossessionBuff.cs +++ b/Buffs/Summon/SarosPossessionBuff.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Summon; using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon diff --git a/Buffs/Summon/SeaSnailBuff.cs b/Buffs/Summon/SeaSnailBuff.cs index da471bc5ad..0e33241c44 100644 --- a/Buffs/Summon/SeaSnailBuff.cs +++ b/Buffs/Summon/SeaSnailBuff.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon diff --git a/Buffs/Summon/SolarGodSpiritBuff.cs b/Buffs/Summon/SolarGodSpiritBuff.cs index 1a35780269..ee623e1f5d 100644 --- a/Buffs/Summon/SolarGodSpiritBuff.cs +++ b/Buffs/Summon/SolarGodSpiritBuff.cs @@ -1,12 +1,12 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Summon; using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon { public class SolarGodSpiritBuff : BaseSummonBuff { - protected override int MinionProjectileType => ModContent.ProjectileType(); + protected override int MinionProjectileType => ModContent.ProjectileType(); - protected override ref bool MinionBool => ref BuffModdedOwner.SPG; + protected override ref bool MinionBool => ref BuffModdedOwner.vengefulSunMinion; } } diff --git a/Buffs/Summon/SolarSpirit.cs b/Buffs/Summon/SolarSpirit.cs index 1deef86122..dc569a6deb 100644 --- a/Buffs/Summon/SolarSpirit.cs +++ b/Buffs/Summon/SolarSpirit.cs @@ -1,12 +1,12 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Summon; using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon { public class SolarSpirit : BaseSummonBuff { - protected override int MinionProjectileType => ModContent.ProjectileType(); + protected override int MinionProjectileType => ModContent.ProjectileType(); - protected override ref bool MinionBool => ref BuffModdedOwner.SP; + protected override ref bool MinionBool => ref BuffModdedOwner.sunSpirit; } } diff --git a/Buffs/Summon/StarSwallowerBuff.cs b/Buffs/Summon/StarSwallowerBuff.cs deleted file mode 100644 index 63d8e3765b..0000000000 --- a/Buffs/Summon/StarSwallowerBuff.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.DraedonsArsenal; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class StarSwallowerBuff : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.starSwallowerPetFroge; - } -} diff --git a/Buffs/Summon/StarSwallowerBuff.png b/Buffs/Summon/StarSwallowerBuff.png deleted file mode 100644 index 8a0cbca503..0000000000 Binary files a/Buffs/Summon/StarSwallowerBuff.png and /dev/null differ diff --git a/Buffs/Summon/ViridVanguardBuff.cs b/Buffs/Summon/ViridVanguardBuff.cs index 51ea3391d7..68ca32a558 100644 --- a/Buffs/Summon/ViridVanguardBuff.cs +++ b/Buffs/Summon/ViridVanguardBuff.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Summon; using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon @@ -7,6 +7,6 @@ namespace CalamityMod.Buffs.Summon { protected override int MinionProjectileType => ModContent.ProjectileType(); - protected override ref bool MinionBool => ref BuffModdedOwner.ViridVanguard; + protected override ref bool MinionBool => ref BuffModdedOwner.viridVanguard; } } diff --git a/Buffs/Summon/VoidEaterMarionetteBuff.cs b/Buffs/Summon/VoidEaterMarionetteBuff.cs new file mode 100644 index 0000000000..8f85d23560 --- /dev/null +++ b/Buffs/Summon/VoidEaterMarionetteBuff.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.Summon; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class VoidEaterMarionetteBuff : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.hasVoidEaterMarionette; + } +} diff --git a/Buffs/Summon/Mechworm.png b/Buffs/Summon/VoidEaterMarionetteBuff.png similarity index 100% rename from Buffs/Summon/Mechworm.png rename to Buffs/Summon/VoidEaterMarionetteBuff.png diff --git a/Buffs/Summon/WaterElemental.cs b/Buffs/Summon/WaterElemental.cs new file mode 100644 index 0000000000..75db085d1e --- /dev/null +++ b/Buffs/Summon/WaterElemental.cs @@ -0,0 +1,12 @@ +using CalamityMod.Projectiles.Summon; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class WaterElemental : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.waterEleBuff; + } +} diff --git a/Buffs/Summon/WaterWaifu.png b/Buffs/Summon/WaterElemental.png similarity index 100% rename from Buffs/Summon/WaterWaifu.png rename to Buffs/Summon/WaterElemental.png diff --git a/Buffs/Summon/WaterWaifu.cs b/Buffs/Summon/WaterWaifu.cs deleted file mode 100644 index 413f5de434..0000000000 --- a/Buffs/Summon/WaterWaifu.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Summon -{ - public class WaterWaifu : BaseSummonBuff - { - protected override int MinionProjectileType => ModContent.ProjectileType(); - - protected override ref bool MinionBool => ref BuffModdedOwner.slWaifu; - } -} diff --git a/Buffs/Summon/Whips/CnidarianSummonTagBuff.cs b/Buffs/Summon/Whips/CnidarianSummonTagBuff.cs new file mode 100644 index 0000000000..37a2ea37e6 --- /dev/null +++ b/Buffs/Summon/Whips/CnidarianSummonTagBuff.cs @@ -0,0 +1,18 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon.Whips +{ + public class CnidarianSummonTagBuff : ModBuff + { + public override string Texture => "CalamityMod/Buffs/Summon/Whips/SentinalLash"; + + public override void SetStaticDefaults() + { + BuffID.Sets.IsATagBuff[Type] = true; + Main.debuff[Type] = true; + Main.buffNoSave[Type] = true; + } + } +} diff --git a/Buffs/Summon/Whips/ForbiddenStealthSummonTagBuff.cs b/Buffs/Summon/Whips/ForbiddenStealthSummonTagBuff.cs new file mode 100644 index 0000000000..a12222adde --- /dev/null +++ b/Buffs/Summon/Whips/ForbiddenStealthSummonTagBuff.cs @@ -0,0 +1,18 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon.Whips +{ + public class ForbiddenStealthSummonTagBuff : ModBuff + { + public override string Texture => "CalamityMod/Buffs/Summon/Whips/SentinalLash"; + + public override void SetStaticDefaults() + { + BuffID.Sets.IsATagBuff[Type] = true; + Main.debuff[Type] = true; + Main.buffNoSave[Type] = true; + } + } +} diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 3b86e87ff0..53e91a42c5 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4,9 +4,7 @@ using System.Linq; using CalamityMod.Balancing; using CalamityMod.BiomeManagers; using CalamityMod.Buffs; -using CalamityMod.Buffs.Alcohol; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.Placeables; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer.Dashes; @@ -15,6 +13,7 @@ using CalamityMod.DataStructures; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.FluidSimulation; +using CalamityMod.Graphics; using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; @@ -24,20 +23,28 @@ using CalamityMod.Items.Armor.Bloodflare; using CalamityMod.Items.Armor.Brimflame; using CalamityMod.Items.Armor.Daedalus; using CalamityMod.Items.Armor.Demonshade; +using CalamityMod.Items.Armor.DesertProwler; using CalamityMod.Items.Armor.Empyrean; using CalamityMod.Items.Armor.LunicCorps; using CalamityMod.Items.Armor.OmegaBlue; using CalamityMod.Items.Armor.PlagueReaper; +using CalamityMod.Items.Armor.Prismatic; using CalamityMod.Items.Armor.Silva; using CalamityMod.Items.Armor.SnowRuffian; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Armor.TitanHeart; using CalamityMod.Items.Armor.Victide; +using CalamityMod.Items.Armor.Wulfrum; using CalamityMod.Items.Dyes; +using CalamityMod.Items.Materials; using CalamityMod.Items.Mounts; using CalamityMod.Items.Mounts.Minecarts; using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Tools; +using CalamityMod.Items.Tools.ClimateChange; using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.DraedonsArsenal; @@ -45,20 +52,22 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.Items.Weapons.Typeless; using CalamityMod.NPCs; using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.Shortswords; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; using CalamityMod.Systems.Collections; +using CalamityMod.Systems.Mechanic; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -66,11 +75,16 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent; +using Terraria.GameContent.Creative; +using Terraria.GameContent.NetModules; using Terraria.GameInput; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; +using Terraria.Net; +using Terraria.WorldBuilding; +using static Terraria.Main; using static Terraria.ModLoader.ModContent; namespace CalamityMod.CalPlayer @@ -80,15 +94,16 @@ namespace CalamityMod.CalPlayer #region Variables #region No Category + /// + /// Increments by 1 for every frame this player has existed. + /// + internal ulong universalFrameTimer = 0; + /// If true, there is a boss NPC active in the world. Primary bool for checking effects that only occur if a boss is alive. public static bool areThereAnyDamnBosses = false; /// If true, there is an event actively occuring near the player. Solely used for preventing Silva Revive's cooldown from decreasing. public static bool areThereAnyDamnEvents = false; public float calamityBonusLuck = 0f; - /// Custom variable for tracking if the player has Potion Sickness. Used for adding Potion Sickness to the Cooldown Rack. - public bool potionSick = false; - /// Custom variable for tracking how long the player has had Potion Sickness. Solely used for triggering the aura effects of Life Jelly and its upgrades. - public int timePotionSick; public bool drawBossHPBar = true; public float stealthUIAlpha = 1f; public float SulphWaterUIOpacity = 1f; @@ -105,29 +120,17 @@ namespace CalamityMod.CalPlayer public static int chaosStateDuration = 900; /// Constant variable used for how long Chaos State is inflicted by Normality Relocator while a boss is alive. public static int chaosStateDuration_NR = 1200; - /// Used by Sky Stabber and Gods' Paranoia to delete spiky balls when using right-click. - public bool killSpikyBalls = false; - public float KameiTrailXScale = 0.1f; - public int KameiBladeUseDelay = 0; - /// Stores the positions of the player within the previous 4 frames. Used for drawing trail effects. - public Vector2[] OldPositions = new Vector2[4]; public double contactDamageReduction = 0D; public double projectileDamageReduction = 0D; public int hellbornShots = 0; - public int searedPanCounter = 0; - public int searedPanTimer = 0; - /// Used to get around the hardcoded Potion Sickness duration to allow Hadal Stew's reduced duration. - public int potionTimer = 0; - public bool cirrusDress = false; + public int garandShots = 0; /// If set to true, prevents all player dashes. Used by Ball and Chain, and Stygian Shield. public bool blockAllDashes = false; /// Used by Flamsteed Ring to reset the player's hitbox size after dismounting. public bool resetHeightandWidth = false; /// If set to true, completely disables ALL life regeneration effects. Used by Omega Blue armor. public bool noLifeRegen = false; - public bool reducedDaybrokenDamage = false; - public bool reducedNightwitherDamage = false; - public float rangedAmmoCost = 1f; + public float ammoCost = 1f; public float healingPotionMultiplier = 1f; /// /// Tracks whether or not the player is currently holding Gael's Greatsword.
@@ -156,7 +159,8 @@ namespace CalamityMod.CalPlayer public float blazingMouseAuraFade = 0f; /// /// General variable used for controlling the strength of screenshake this player is experiencing. Measured in pixels of offset that can be applied to the screen.
- /// When setting this, be sure to only set it if its current value is less than the value to set, to prevent overriding an ongoing stronger screenshake with a weaker one. + /// When setting this, be sure to only set it if its current value is less than the value to set, to prevent overriding an ongoing stronger screenshake with a weaker one.
+ /// A helper method exists which can automatically do this for you, . ///
public float GeneralScreenShakePower = 0f; /// Set to true when this player receives the Brimstone Locus from speaking to the Brimstone Witch for the first time. @@ -178,6 +182,59 @@ namespace CalamityMod.CalPlayer public int momentumCapacitorTime = 0; /// A multiplier on the player's movement speed applied while using Momentum Capacitor. public float momentumCapacitorBoost = 0f; + public enum FishingMinigames + { + None, + ScrapBobber, + NavystoneBobber, + SkylineBobber, + PerennialBobber, + ScoriaBobber, + DevourerofCods //Not a fishing minigame but uses the same code as the rest + } + public FishingMinigames SelectedFishingMinigame = FishingMinigames.None; + public bool countsAsAnyWet => (Player.armor[0].type == ItemID.FishBowl || Player.wetCount > 0 || Player.wet || Player.honeyWet || Player.lavaWet); + + /// + /// How many Starbursts the player has + /// + public int StratusStarburst = 0; + public int AvaliableStarburst = 0; + public static int MaxStratusStarburst = 100; + /// + /// Used for Halley's Inferno to generate starbursts + /// + public float HalleyAccuracyCounter = 0; + public float StarburstSpawnFrameCounter = 0; + /// + /// A cooldown for losing Starbursts over time, reset by holding Stratus items or having Sirius spawned + /// + public int StratusStarburstResetTimer = 0; + /// + /// Duration of Stratus Sphere's Starshield + /// + public int Starshield = 0; + + public List StarburstEntities = new(); + + public CombatText subtitletext = null; + public Color[] subtitleColors = new Color[] { Color.White, Color.White }; + public int DoGHeadHitCounter = 0; + + public StatModifier TypelessDebuffMultiplier = new(); + public StatModifier HeatDebuffMultiplier = new(); + public StatModifier ColdDebuffMultiplier = new(); + public StatModifier SicknessDebuffMultiplier = new(); + public StatModifier WaterDebuffMultiplier = new(); + public StatModifier ElectricDebuffMultiplier = new(); + + public int TimeHoldingMelee = 0; + public int TimeHoldingRanged = 0; + public int TimeHoldingMagic = 0; + public int TimeHoldingSummon = 0; + public int TimeHoldingRogue = 0; + public int TimeHoldingClassless = 0; + #endregion #region Speedrun Timer @@ -195,13 +252,14 @@ namespace CalamityMod.CalPlayer public int CurrentlyViewedChargerID = -1; public int CurrentlyViewedHologramID = -1; public int CurrentlyViewedCanvasID = -1; - public int CurrentlyViewedCanvasType = -1; // -1 = None. 0 = 2023. 1 = 2024. + public int CurrentlyViewedCanvasType = -1; public string CurrentlyViewedHologramText; #endregion #region External variables -- Not used by Calamity, only via Mod.Call or reflection + [Obsolete("No longer does anything in the new abyss light system")] public int externalAbyssLight = 0; - public float externalBreathLossMultBoost = 0f; + public float externalBreathTickBoost = 0f; public float externalFlightTimeMultBoost = 0f; @@ -246,7 +304,6 @@ namespace CalamityMod.CalPlayer public bool newPrincessInventory = false; public bool newSkeletonMerchantInventory = false; public bool newPermafrostInventory = false; - public bool newCirrusInventory = false; public bool newAmidiasInventory = false; public bool newBanditInventory = false; public bool newCalamitasInventory = false; @@ -257,8 +314,8 @@ namespace CalamityMod.CalPlayer public int arsenalCooldown = 0; public int killModeCooldown = 0; public bool demonSwordKillMode = false; - public bool exaltedKillMode => (demonSwordKillMode && Player.ActiveItem().type == ModContent.ItemType()); - public bool devilsDevastationKillMode => (demonSwordKillMode && Player.ActiveItem().type == ModContent.ItemType()); + public bool exaltedKillMode => (demonSwordKillMode && Player.HeldItem.type == ItemType()); + public bool devilsDevastationKillMode => (demonSwordKillMode && Player.HeldItem.type == ItemType()); /// /// Tracks Dragoon Drizzlefish's "gel feed" mechanic in Get fixed boi.
/// Consuming Gel adds 1 to this counter, up to a maximum of 6, and using the weapon has a random chance to decrement the counter.
@@ -268,6 +325,17 @@ namespace CalamityMod.CalPlayer public int deadSunCounter = 6; public int DragonsBreathAudioCooldown = 0; public int DragonsBreathAudioCooldown2 = 0; + public int darklightEnergy = 0; + public int darklightEnergyTimer = 0; + public bool darklightEnergyPaused = false; + public bool darklightEnergyMaxFXPlayed = false; + private int lucreciaParticleTimer = 0; + public int elementalMastery = 0; + public int elementalMasteryTimer = 0; + public bool elementalMasteryPaused = false; + public bool elementalMasterySFXPlayed = false; + public float unstableCastersGauntletVis = 0; + public int unstableCastersGauntletVisTimer = 0; public int PhotoAudioCooldown = 0; public int PhotoTimer = 90; /// Cooldown variable used to add a delay between Anahita's Arpeggio uses. @@ -281,6 +349,8 @@ namespace CalamityMod.CalPlayer public int evilSmasherBoost = 0; /// Cooldown variable for spawning Plague Tainted SMG's drones from left-click bullets. public int plagueTaintedSMGDroneCooldown = 0; + /// Cooldown variable which prevents using Firestorm Cannon or Spectralstorm Cannon during their overheat periods. + public int flareGunOverheat = 0; /// /// If true, this player's Brittle Star Staff minions are in their orbiting mode.
/// While in this mode, they orbit around the player, do not break on hits, and increase defense. @@ -300,18 +370,24 @@ namespace CalamityMod.CalPlayer public int GalaxyHammer = 0; /// Variable used to apply Ontological Despoiler's nerfs when continuously using a single firing mode. public bool despoilerNerf = false; + /// Variable used to trigger Molten Amputator's stealth effect on right-click. + public int amputatorBuff = 0; + /// Variable used to track the current fuel amount for Pristine Fury's right-click. + public int furyFuel = 1800; + public const int FuryFuelMax = 1800; + public float furyRefuelTimer = 0; + /// Variable used to track if Auger can do its big slash attack. + public bool buffedAuger = false; + public int rOfResilienceCooldown = 0; public int rOfResilienceEffect = 0; public int rOfResilienceOrbitOffset = 0; - /// - /// Variable which tracks how many shots Norfleet has fired. Used to determine when to recharge.
- /// Also used to trigger its "cheater" easter egg when attempting to fire more than 3 consecutive shots. - ///
+ /// Variable which tracks how many shots Norfleet has fired. Used to determine when to recharge. public int NorfleetCounter = 0; public int hideOfDeusMeleeBoostTimer = 0; /// /// The player's alcohol level. Increased by 1 for each alcohol the player has drank, 2 for Everclear.
- /// Is this value is greater than 3, the player is inflicted with Alcohol Poisoning. + /// If this value is greater than 3, the player is inflicted with Alcohol Poisoning. ///
public int alcoholPoisonLevel = 0; public int dashTimeMod; @@ -331,12 +407,8 @@ namespace CalamityMod.CalPlayer public int dragonRageHits = 0; /// Cooldown variable for Dragon Rage's fireball spawning to prevent spamming projectiles when hitting multiple enemies simultaneously. public int dragonRageCooldown = 0; - public float aquaticBoostMax = 10000f; - /// - /// Counter variable which controls Aquatic Emblem's stat boosts while underwater.
- /// This counter starts at , and is decremented by 2 for every frame the player remains underwater, reaching maximum boosts when it hits 0. - ///
- public float aquaticBoost = 0f; + /// Counter variable which controls Aquatic Emblem's stat boosts while underwater. + public float aquaticBoost = 0; public int galileoCooldown = 0; /// Used to track Prideful Hunter's Planar Ripper's movement speed boost, along with its visual effects. public int planarSpeedBoost = 0; @@ -359,8 +431,7 @@ namespace CalamityMod.CalPlayer public int murasamaHitCooldown = 0; public int giantShellPostHit = 0; public int tortShellPostHit = 0; - public int RustyMedallionCooldown = 0; - public int MiniSwamerCooldown = 0; + public int MiniSwarmerCooldown = 0; public float SulphWaterPoisoningLevel; public float holyInfernoFadeIntensity; public NPC unstableSelectedTarget; @@ -378,6 +449,10 @@ namespace CalamityMod.CalPlayer public bool canFireGodSlayerRangedProjectile = false; public bool canFireBloodflareMageProjectile = false; public bool canFireBloodflareRangedProjectile = false; + + public int consecutiveCaughtFish = 0; + public float WeakTimeFreezeUseTimer = 0; + public bool WeakTimeFreezeInUse = false; #endregion #region Sound @@ -401,7 +476,6 @@ namespace CalamityMod.CalPlayer public static readonly SoundStyle RogueStealthSound = new("CalamityMod/Sounds/Custom/RogueStealth"); public static readonly SoundStyle DefenseDamageSound = new("CalamityMod/Sounds/Custom/DefenseDamage"); - public static readonly SoundStyle BloodCritSound = new("CalamityMod/Sounds/Custom/BloodPactCrit"); public static readonly SoundStyle IjiDeathSound = new("CalamityMod/Sounds/Custom/IjiDies"); public static readonly SoundStyle DrownSound = new("CalamityMod/Sounds/Custom/AbyssDrown"); @@ -420,6 +494,18 @@ namespace CalamityMod.CalPlayer /// Note that the player's displayed stealth value is 100x the internal value. For example, a value of 0.1f means having 10 max stealth. ///
public float rogueStealthMax = 0f; + /// + /// Temporarily provides stealth even without Rogue armor. + /// Max stealth is set to temporaryStealthMax if it's 0. + /// + public int temporaryStealthTimer = 0; + /// + /// Amount of temporary max stealth provided by gear + /// 1f = 100 max steatlh + /// Duration is temporaryStealthTimer + /// Resets to 0.1f whenever timer ends + /// + public float temporaryStealthMax = 0.1f; /// A multiplier to the player's stealth generation when standing still. public float stealthGenStandstill = 1f; /// A multiplier to the player's stealth generation when moving. @@ -439,10 +525,10 @@ namespace CalamityMod.CalPlayer ///
public bool stealthStrike75Cost = false; /// - /// If true, stealth strikes only require 85% of the player's max stealth to perform.
+ /// If true, stealth strikes only require 90% of the player's max stealth to perform.
/// Used by Coin of Deceit. ///
- public bool stealthStrike85Cost = false; + public bool stealthStrike90Cost = false; /// If true, this player is wearing a rogue or all-class armor set. This bool is required in order to use rogue stealth. public bool wearingRogueArmor = false; /// The sum of the player's stealth generation boosts from accessory modifiers. @@ -454,7 +540,7 @@ namespace CalamityMod.CalPlayer /// This is obtained from a formula derived from the player's current stealth, the weapon's use time, and the player's stealth generation boosts. ///
public float stealthDamage = 0f; - /// An additional damage multiplier applied to rogue stealth strikes. Used by Filthy Glove and its upgrades, and Rotten Dogtooth. + /// An additional damage multiplier applied to rogue stealth strikes. Used by Filthy Glove, Rotten Dogtooth and their upgrades. public double bonusStealthDamage = 0; public float rogueVelocity = 1f; @@ -464,7 +550,6 @@ namespace CalamityMod.CalPlayer #region Mount public bool onyxExcavator = false; public bool rimehound = false; - public bool fab = false; public bool crysthamyr = false; public bool ExoChair = false; public AndromedaPlayerState andromedaState; @@ -476,6 +561,7 @@ namespace CalamityMod.CalPlayer #endregion #region Pet + public bool burrowerPet = false; public bool thirdSage = false; public bool perfmini = false; public bool akato = false; @@ -506,6 +592,8 @@ namespace CalamityMod.CalPlayer public bool pineapplePet = false; public bool eidolonSnailPet = false; public bool lordePet = false; + public bool frostyBat = false; + public bool toastyBat = false; #endregion #region Rage @@ -558,7 +646,6 @@ namespace CalamityMod.CalPlayer } } public bool adrenalineModeActive = false; - public bool AdrenalineTrail = false; /// The player's current Adrenaline level. Expressed as a percentage of maximum Adrenaline. public float adrenaline = 0f; public float adrenalineMax = 100f; // 0 to 100% by default @@ -629,7 +716,7 @@ namespace CalamityMod.CalPlayer #endregion #region Energy Shields - public bool HasAnyEnergyShield => roverDrive || lunicCorpsSet || ((pSoulArtifact && !profanedCrystal) || profanedCrystalBuffs) || sponge; + public bool HasAnyEnergyShield => roverDrive || lunicCorpsSet || ((pSoulArtifact && !profanedCrystal) || profanedCrystalBuffs) || sponge || Starshield > 0; public bool freeDodgeFromShieldAbsorption = false; public bool drawnAnyShieldThisFrame = false; @@ -643,6 +730,8 @@ namespace CalamityMod.CalPlayer public bool roverDrive = false; public bool roverDriveShieldVisible = false; + internal float roverDriveShieldPartialRechargeProgress = 0f; + internal bool playedRoverDriveShieldSound = false; // Lunic Corps shield is controlled by its armor set bool // Lunic Corps shield comes from an armor set and its visibility is non optional @@ -662,14 +751,24 @@ namespace CalamityMod.CalPlayer #endregion #region Abyss - /// The amount of breath lost on each tick while in the Abyss. - public float abyssBreathLossStat = 0; /// The rate at which breath is lost while in the Abyss. public float abyssBreathLossRateStat = 0; /// The rate at which health is decreased after running out of breath while in the Abyss. public int abyssLifeLostAtZeroBreathStat = 0; /// The amount which defense is reduced while in the Abyss. public int abyssDefenseLossStat = 0; + + //These stats are for the abyss darkness system. + public float abyssDarkness = 0f; + public float abyssPlayerGlowMultiplier = 1f; + public float abyssFlashlightWidthMultiplier = 1f; + + #endregion + + #region Light System + public float darknessIntensity = 0; + + public Vector2? lastDeerclopsPosition; #endregion #region Permanent Buff @@ -691,8 +790,6 @@ namespace CalamityMod.CalPlayer public bool tCloudberry = false; /// If true, the player has consumed Sacred Strawberry. public bool sStrawberry = false; - /// If true, the player has consumed Nimble Bounder. - public bool nimbleBounderBoost = false; public bool revJamDrop = false; /// If true, the player has consumed Mushroom Plasma Root. public bool rageBoostOne = false; @@ -720,20 +817,18 @@ namespace CalamityMod.CalPlayer public bool gladiatorSword = false; public int gladiatorTimer = 0; public bool unstableGraniteCore = false; - public bool regenator = false; - public float regenatorDamage = 0; + public bool regenerator = false; + public float regeneratorDamage = 0; public bool theBee = false; public bool arcFlashRing = false; public bool arcFlashRingVisual = false; + public int generalBandCooldown = 0; public bool bGlassBand = false; // Obsidian band public bool bGlassBandVisual = false; - public int bGlassbandCooldown = 0; public bool batholithBangle = false; // Granite band public bool batholithBangleVisual = false; - public int batholithBangleCooldown = 0; public bool protolithBangle = false; // Marble band public bool protolithBangleVisual = false; - public int protolithBangleCooldown = 0; /// Used to prevent dodges from triggering The Bee's full health damage reduction cooldown. public bool shouldTriggerBeeCooldown = false; public int theBeeCooldown = 0; @@ -746,6 +841,7 @@ namespace CalamityMod.CalPlayer public bool fishingStation = false; public bool rBrain = false; public bool bloodyWormTooth = false; + public bool ivDrip = false; /// NOT the primary Affliction variable, used instead for the Afflicted buff which is given to teammates. public bool afflicted = false; public bool chiRegen = false; @@ -762,15 +858,13 @@ namespace CalamityMod.CalPlayer public bool badgeOfBravery = false; public bool WarbanneroftheRighteous = false; public bool warbannerGlow = false; + public float warbannerDamageMult = 0; public bool tesla = false; public bool teslaVisuals = true; public bool cryogenSoul = false; public bool ascendantInsignia = false; public int ascendantInsigniaBuffTime = 0; public int ascendantInsigniaCooldown = 0; - public bool ascendantTrail = false; - public bool frozenWingsCold = false; - public bool flameWingsHeat = false; /// Used to toggle dust spawned while swinging, through accessory visibility. public bool magmaStoneVisuals = true; public bool eGauntlet = false; @@ -783,14 +877,14 @@ namespace CalamityMod.CalPlayer public int gloveLevel = 0; public bool alreadyHasFrogLeg = false; // Unused, intended to prevent Frog Leg tinker stacking public bool eTalisman = false; - /// Counter variable used for spawning Statis' Void Sash's scythes when dashing. - public int statisTimer = 0; + public bool lastDashWasTabi = false; + public bool statisNinjaBelt = false; + public bool voidSashVisuals = true; + public bool statisVoidSash = false; public bool nucleogenesis = false; public bool nuclearFuelRod = false; public bool nebulousCore = false; public bool deepDiver = false; - public bool abyssalDivingSuitPlates = false; - public int abyssalDivingSuitPlateHits = 0; public bool aquaticHeartWaterBuff = false; public bool aquaticHeartIce = false; public bool ilSpark = false; @@ -799,14 +893,25 @@ namespace CalamityMod.CalPlayer public int transformerCooldown = 0; public int transformerDelay = 0; public int transformerStoredKills = 0; + public int hookPullVisuals = 0; + public bool bloomStone = false; + public bool bloomStoneHookVisuals = false; + public int bloomStoneHealPool = 0; + public int bloomStoneTotalHeal = 0; + public float bloomStoneHealTimer = 0; + public float bloomStoneHealRate = 0; + public int bloomStoneBuffedHealRateTimer = 0; public bool hideOfDeus = false; public bool dAmulet = false; public bool rampartOfDeities = false; public bool gShell = false; public bool lAmbergris = false; + public bool lAmbergrisVisual = false; public bool tortShell = false; public bool absorber = false; + public bool hadLifeRegenHinderingDebuff = false; public bool alwaysHoneyRegen = false; + public float alwaysHoneyRegenAmount = 0; public bool honeyTurboRegen = false; public bool honeyDewHalveDebuffs = false; public bool livingDewHalveDebuffs = false; @@ -823,14 +928,16 @@ namespace CalamityMod.CalPlayer public float pulseRate = 1; public bool aAmpoule = false; public bool rOoze = false; + public float radiantOozeRegen = 0; + public float purityRegen = 0; public bool fBarrier = false; public bool aBrain = false; public bool amalgam = false; public bool raiderTalisman = false; - public float raiderCritLifespan = 0f; + public int raiderCritLifespan = 0; public int raiderSoundCooldown = 0; public bool gSabaton = false; - public int gSabatonHotkeyHoldTime = 0; + public int gSabatonHotkeyFallWindup = -1; public int gSabatonFall = 0; public bool gSabatonFalling = false; public int gSabatonTempJumpSpeed = 0; @@ -838,13 +945,11 @@ namespace CalamityMod.CalPlayer public bool sGlyph = false; public bool sRegen = false; public bool tracersDust = false; - public bool elysianWingsDust = false; - public bool tracersCelestial = false; - public bool tracersElysian = false; - public bool tracersSeraph = false; + public bool moonWalkers = false; + public bool voidStriders = false; + public bool seraphTracers = false; public bool frostFlare = false; public bool evolution = false; - public int evolutionLifeRegenCounter = 0; public bool nanotech = false; public bool deadshotBrooch = false; public bool shadowMinions = false; @@ -859,11 +964,11 @@ namespace CalamityMod.CalPlayer public bool cleansingjelly = false; public bool GrandGelatin = false; public int CleansingEffect = 0; + public bool spawnedJellyAura = false; public bool community = false; public bool shatteredCommunity = false; public bool fleshTotem = false; public bool bloodPact = false; - public bool bloodPactBoost = false; public bool bloodflareCore = false; public int bloodflareCoreRemainingHealOverTime = 0; @@ -872,6 +977,7 @@ namespace CalamityMod.CalPlayer public double chaliceDamagePointPartialProgress = 0D; public int chaliceBleedoutToApplyOnHurt = 0; public int chaliceHitOriginalDamage = 0; + public bool chaliceHeartStyle = false; public bool elementalHeart = false; public bool crownJewel = false; @@ -882,16 +988,14 @@ namespace CalamityMod.CalPlayer public int PurityHealSlowdownFrames = 0; public bool harpyRing = false; public bool angelTreads = false; - /// Counter variable used for automatically re-engaging Vortex armor's stealth with Vortex Booster. - public int vortexBoosterStealthDelay = 0; - /// Makes Flesh Knuckles and its upgrades increase the player's max health by 45. + /// Makes Flesh Knuckles and its upgrades increase the player's max health. public bool fleshKnuckles = false; public bool ironBoots = false; public bool depthCharm = false; public bool anechoicPlating = false; /// Used for increasing light level in the Abyss. public bool jellyfishNecklace = false; - /// Calamity's Fairy Boots effect; makes fairies spawn around you which give stats. + /// Calamity's Fairy Boots effect; makes fairies spawn around the player which give stats. public bool fairyBoots = false; /// Calamity's Flame Waker Boots effect; multiplies heat debuff damage and makes attacks inflict On Fire. public bool flameWakerBoots = false; @@ -905,17 +1009,26 @@ namespace CalamityMod.CalPlayer public bool sSpiritAmulet = false; public int sSpiritAmuletTimer = 0; public bool sSpiritAmuletVisual = false; - public bool lumenousAmulet = false; + public bool dOfTheDeep = false; + public int dOfTheDeepTimer = 0; + public bool dOfTheDeepVisual = false; + public int dOfTheDeepDefenseBuffMax = 420; + public int dOfTheDeepDefenseBuffTimer = 0; public bool oceanCrest = false; public bool aquaticEmblem = false; public bool spiritOrigin = false; public bool spiritOriginVanity = false; public int spiritOriginCritBoost = 0; + /// + /// The amount of bonus crit damage the player has. + /// At 0f, the player has regular crit damage. At 1f, the player has +100% crit damage. + /// + public float critDamage = 0; public bool darkSunRing = false; public bool crawCarapace = false; public bool baroclaw = false; - public bool HasIncreasedDashFirstFrame = false; public bool IsFirstDashFrame = true; + public int fallingBootVelCheckTimer = 0; public bool voidOfCalamity = false; public bool voidOfExtinction = false; public bool eArtifact = false; @@ -930,9 +1043,13 @@ namespace CalamityMod.CalPlayer public bool flameLickedShell = false; public int flameLickedShellParry = 0; public bool flameLickedShellEmpoweredParry = false; - public bool Pauldron = false; + public bool sPauldron = false; + public bool sPauldronVisual = false; public bool XykVisualsBlue = false; public bool XykVisualsOrange = false; + public Color XykFXColor = Color.Black; + public int XykWingTimer = 0; + public Color lightRGB = Color.Black; public bool manaOverloader = false; /// Used for allowing Calamity slimes to be affected by Royal Gel. public bool royalGel = false; @@ -953,16 +1070,16 @@ namespace CalamityMod.CalPlayer public bool jellyChargedBattery = false; /// General cooldown for accessories which spawn projectiles on minion hits. public float summonProjCooldown; - public bool sandWaifu = false; - public bool sandWaifuVanity = false; - public bool sandBoobWaifu = false; - public bool sandBoobWaifuVanity = false; - public bool cloudWaifu = false; - public bool cloudWaifuVanity = false; - public bool brimstoneWaifu = false; - public bool brimstoneWaifuVanity = false; - public bool sirenWaifu = false; - public bool sirenWaifuVanity = false; + public bool sandElemental = false; + public bool sandElementalVanity = false; + public bool rareSandElemental = false; + public bool rareSandElementalVanity = false; + public bool cloudElemental = false; + public bool cloudElementalVanity = false; + public bool brimElemental = false; + public bool brimElementalVanity = false; + public bool waterElemental = false; + public bool waterElementalVanity = false; public bool fungalClump = false; public bool fungalClumpVanity = false; public bool howlsHeart = false; @@ -996,6 +1113,9 @@ namespace CalamityMod.CalPlayer public bool veneratedLocket = false; public bool camper = false; public bool corrosiveSpine = false; + public bool scionsCurio = false; + public bool scionsCurioGotHit = false; + public bool scionsCurioVisuals = false; public bool miniOldDuke = false; public bool miniOldDukeVanity = false; public bool starbusterCore = false; @@ -1010,11 +1130,8 @@ namespace CalamityMod.CalPlayer /// Life regeneration is increased while between 600 and 720, with a 10 second cooldown afterwards represented by being below 600. ///
public int phantomicHeartRegen = 0; - public bool silvaWings = false; - public int silvaWingsLifeRegenTimer = 0; - /// General cooldown variable for spawning projectiles from wing bonus effects. Used by Soul of Cryogen, Harpy Wings, Tattered Fairy Wings, and Festive Wings. + /// General cooldown variable for spawning projectiles from wing bonus effects. Used by Soul of Cryogen, Tattered Fairy Wings, and Festive Wings. public int wingProjectileCooldown = 0; - public bool RustyMedallionDroplets = false; public bool noStupidNaturalARSpawns = false; /// Used for animating Void Concentration Staff's draw layer. public int voidFrameCounter = 0; @@ -1023,7 +1140,6 @@ namespace CalamityMod.CalPlayer public bool rottenDogTooth = false; public bool angelicAlliance = false; public int angelicActivate = -1; - public bool BloomStoneRegen = false; public bool ChaosStone = false; public bool CryoStone = false; public bool CryoStoneVanity = false; @@ -1034,9 +1150,11 @@ namespace CalamityMod.CalPlayer #region Armor Set public int ArmorSetBonusKeyHeldTimer; - /// Calamity's Silver armor set bonus; taking over 20 damage heals 10 health if you avoid damage for 2 seconds. + /// Calamity's Silver armor set bonus; taking over 20 damage heals 10 health if the player avoids damage for 2 seconds. public bool silverMedkit = false; public int silverMedkitTimer = 0; + /// Calamity's Tungsten armor set bonus; makes grappling hooks fly and retract faster. + public bool tungstenArmorHookBoost = false; /// Calamity's Gold armor set bonus; makes enemies drop Gold Coins. public bool goldArmorGoldDrops = false; /// Calamity's Mining armor set bonus; gives a chance for extra items to drop when mining ores. @@ -1049,7 +1167,7 @@ namespace CalamityMod.CalPlayer public int tornadoCooldown = 0; /// Calamity's Snow armor set bonus; reduces cold enemy damage and increases cold debuff damage. public bool eskimoSet = false; - /// Calamity's Rain armor set bonus; gives jump speed and makes jumps create a splash. + /// Calamity's Rain armor set bonus; increases jump speed and makes jumps create a damaging splash. public bool rainSet = false; /// Calamity's Meteor armor set bonus; makes all magic guns cost 33% mana instead of Space Gun costing 0 mana. public bool meteorSet = false; @@ -1057,8 +1175,12 @@ namespace CalamityMod.CalPlayer public bool necroSet = false; /// Calamity's Frost armor set bonus; gives a combined 20% damage boost split between melee and ranged based on distance from the closest enemy. public bool frostSet = false; - public bool victideSet = false; - public bool victideSummoner = false; + public bool victideBarrierSet = false; + public int victideBarrierHeal = 0; + public bool victideBarrierHead = false; + public bool victideBurrowSet = false; + public bool victideBurrowHead = false; + public bool victideSnailSet = false; public bool sulphurSet = false; public bool sulphurJump = false; public int sulphurBubbleCooldown = 0; @@ -1093,7 +1215,6 @@ namespace CalamityMod.CalPlayer public bool godSlayerDashHotKeyPressed = false; public bool SpeedBlasterDashStarted = false; public bool ataxiaBolt = false; - public bool ataxiaFire = false; public bool ataxiaVolley = false; public bool ataxiaBlaze = false; public bool hydrothermalSmoke = false; @@ -1108,19 +1229,15 @@ namespace CalamityMod.CalPlayer /// Demonshade Greaves' movement speed boost. public bool shadowSpeed = false; public bool dsSetBonus = false; - public bool auricBoost = false; public bool auricSetMelee = false; public bool daedalusReflect = false; public bool daedalusSplit = false; public bool titanHeartSet = false; public bool titanHeartMask = false; public bool titanHeartMantle = false; - public bool titanHeartBoots = false; public int titanCooldown = 0; public bool umbraphileSet = false; public bool reaverSpeed = false; - public bool reaverRegen = false; - public int reaverRegenCooldown = 0; public bool reaverDefense = false; public bool reaverExplore = false; public bool fathomSwarmer = false; @@ -1155,13 +1272,11 @@ namespace CalamityMod.CalPlayer public int silvaMageCooldown = 0; public bool silvaSummon = false; public bool hasSilvaEffect = false; - /// Constant variable representing the duration of Silva armor's revive, in frames. - public const int silvaReviveDuration = 300; - public int silvaCountdown = silvaReviveDuration; + public int silvaCountdown = SilvaArmor.ReviveDuration; public bool auricSet = false; public bool omegaBlueChestplate = false; public bool omegaBlueSet = false; - public bool omegaBlueHentai = false; + public bool omegaBlueAbyssalMadness = false; /// Aerospec armor's summoner set bonus minion. public bool valkyrie = false; /// Statigel armor's summoner set bonus minion. @@ -1220,26 +1335,24 @@ namespace CalamityMod.CalPlayer public bool alcoholPoisoning = false; public bool shadowflame = false; public bool daybroken = false; - public bool wDeath = false; + public bool whisperingDeath = false; public bool dragonFire = false; public bool vermillionFlux = false; public bool auricRebuke = false; public bool staticDischarge = false; public bool miracleBlight = false; - public bool aCrunch = false; + public bool armorCrunch = false; public bool crumble = false; public bool irradiated = false; - public bool bFlames = false; + public bool brimstoneFlames = false; public bool weakBrimstoneFlames = false; public bool demonicFlames = false; - public bool gsInferno = false; + public bool godSlayerInferno = false; public bool astralInfection = false; - /// Plague debuff. - public bool pFlames = false; - public bool hFlames = false; - public bool hInferno = false; - public bool gState = false; - public bool bBlood = false; + public bool plague = false; + public bool holyFlames = false; + public bool holyInferno = false; + public bool burningBlood = false; public bool brainRot = false; public bool heavybleeding = false; public bool laceration = false; @@ -1250,9 +1363,9 @@ namespace CalamityMod.CalPlayer public bool trueVHex = false; public bool DoGExtremeGravity = false; public bool warped = false; - public bool cDepth = false; - public bool rTide = false; - public bool hPressure = false; + public bool crushDepth = false; + public bool riptide = false; + public bool hadopelagicPressure = false; public bool fishAlert = false; public bool clamity = false; public bool NOU = false; @@ -1261,10 +1374,8 @@ namespace CalamityMod.CalPlayer public bool nightwither = false; public bool voidfrost = false; public bool eutrophication = false; - /// Frozen Lungs debuff. - public bool iCantBreathe = false; - /// Searing Lava debuff. - public bool cragsLava = false; + public bool frozenLungs = false; + public bool searingLava = false; public bool vaporfied = false; public bool banishingFire = false; public bool wither = false; @@ -1280,7 +1391,6 @@ namespace CalamityMod.CalPlayer #endregion #region Buff - public bool trinketOfChiBuff = false; public bool sandsWindBuff = false; public bool aeolianEarthBuff = false; public int chiBuffTimer = 0; @@ -1295,14 +1405,15 @@ namespace CalamityMod.CalPlayer public bool xWrath = false; public bool graxDefense = false; public bool encased = false; - public bool brutalCarnage = false; public bool omniscience = false; public bool zerg = false; public bool zen = false; public bool isNearbyBoss = false; public bool flaskBrimstone = false; - public bool cirrusVodka = false; + public bool purpleHaze = false; + public int purpleHazeStealthTimer = 0; public bool mushy = false; + public bool fortunesFavor = false; public bool PinkJellyRegen = false; public bool GreenJellyRegen = false; public bool AbsorberRegen = false; @@ -1327,7 +1438,9 @@ namespace CalamityMod.CalPlayer public bool baguette = false; public bool vodka = false; public bool redWine = false; + public float redWineStoredY = 0; public bool grapeBeer = false; + public int grapeBeerTimer = 0; public bool moonshine = false; public bool rum = false; public bool whiskey = false; @@ -1344,6 +1457,7 @@ namespace CalamityMod.CalPlayer public bool screwdriver = false; public bool moscowMule = false; public bool whiteWine = false; + public float whiteWineTimer = 0; public bool evergreenGin = false; public bool tranquilityCandle = false; public bool chaosCandle = false; @@ -1353,17 +1467,11 @@ namespace CalamityMod.CalPlayer public bool yellowCandle = false; /// If true, the player has consumed Odd Mushroom. Controls drawing its rainbow fake clones of NPCs and projectiles. public bool trippy = false; - /// - /// Used to control the number and position of Odd Mushroom's fake clones. There are three levels of severity.
- /// The first draws 4 clones in diagonals. The second draws 12 clones, 4 on diagonals and the other 8 surrounding them. The third draws 16 clones, arranged entirely around the player. - ///
- public int trippyLevel = 1; public bool amidiasBlessing = false; public bool bloodfinBoost = false; public int bloodfinTimer = 30; public bool hallowedRegen = false; public bool hallowedPower = false; - public bool kamiBoost = false; public bool avertorBonus = false; public bool divineBless = false; public bool infiniteFlight = false; @@ -1379,8 +1487,7 @@ namespace CalamityMod.CalPlayer #region Minion public bool wDroid = false; public bool resButterfly = false; - /// Staff of the Mechworm. - public bool mWorm = false; + public bool hasVoidEaterMarionette = false; public bool IceClasperBool = false; public bool magicHat = false; public bool herring = false; @@ -1398,13 +1505,12 @@ namespace CalamityMod.CalPlayer public bool brittleStar = false; public bool aquaticStar = false; /// Sun Spirit Staff. - public bool SP = false; + public bool sunSpirit = false; public bool dCreeper = false; - public bool bClot = false; public bool eAxe = false; public bool endoCooper = false; /// Vengeful Sun Staff. - public bool SPG = false; + public bool vengefulSunMinion = false; public bool sirius = false; /// Yharon's Kindle Staff. public bool aChicken = false; @@ -1424,21 +1530,21 @@ namespace CalamityMod.CalPlayer /// Enchanted Conch. public bool hCrab = false; /// Heart of the Elements. - public bool allWaifus = false; - /// Hearts of the Elements; however, the minions will not attack. - public bool allWaifusVanity = false; + public bool allElementals = false; + /// Heart of the Elements; however, the minions will not attack. + public bool allElementalsVanity = false; /// Silva armor's Silva Crystal. public bool sCrystal = false; /// Elemental in a Bottle. - public bool sWaifu = false; + public bool sandEleBuff = false; /// Rare Elemental in a Bottle. - public bool dWaifu = false; + public bool rareSandEleBuff = false; /// Eye of the Storm. - public bool cWaifu = false; + public bool cloudEleBuff = false; /// Rose Stone. - public bool bWaifu = false; + public bool brimEleBuff = false; /// Pearl of Enthrallment. - public bool slWaifu = false; + public bool waterEleBuff = false; public bool fClump = false; /// Demonshade armor's Red Devil. public bool rDevil = false; @@ -1453,8 +1559,6 @@ namespace CalamityMod.CalPlayer public bool victideSnail = false; /// Hydrothermic armor's Vent. public bool cSpirit = false; - /// Reaver armor's Reaver Orb. - public bool rOrb = false; /// Daedalus armor's Daedalus Crystal. public bool dCrystal = false; public bool endoHydra = false; @@ -1465,6 +1569,7 @@ namespace CalamityMod.CalPlayer public bool providenceStabber = false; public bool seashineSwordBuff = false; public bool saros = false; + public int sarosEclipseBeamUsage = 0; /// Fuel Cell Bundle. public bool plaguebringerMK2 = false; public bool igneousExaltation = false; @@ -1486,9 +1591,9 @@ namespace CalamityMod.CalPlayer public bool necrosteocytesDudes = false; public bool gammaHead = false; public bool tundraFlameBlossom = false; - public bool starSwallowerPetFroge = false; public bool snakeEyes = false; public bool poleWarper = false; + public bool aqueousHunterDrone = false; public bool causticDragon = false; public bool plaguebringerPatronSummon = false; public bool howlTrio = false; @@ -1498,7 +1603,12 @@ namespace CalamityMod.CalPlayer public bool deathstareEyeball = false; public bool witherBlossom = false; public bool flowersOfMortality = false; - public bool ViridVanguard = false; + public bool viridVanguard = false; + public bool ViridVanguardActiveAttackerThisFrame = false; + public float ViridVanguardRotation = 0; + public float ViridVanguardActiveCooldown = 0; + public float ViridVanguardRotationToAdd = 0; + public bool InvertExaltationLineRotationDirections = false; public bool sageSpirit = false; public bool fleshBall = false; public bool eyeOfNight = false; @@ -1510,17 +1620,27 @@ namespace CalamityMod.CalPlayer public bool KalandraMirror = false; public bool StellarTorus = false; public bool LiliesOfFinalityBool = false; - public bool FlarebatBool = false; - public bool FrostbatBool = false; + public bool EnchantedKnifeStaffBool = false; public bool AmphibiansGuitarBool = false; #endregion + #region Whip + public bool forceSummonTagCrit = false; //Forces whip multiplicative effects to function as crit chance + public bool forceSummonTagMultiplicative = false; //Forces whip multiplicative effects to function as multiplicative damage + + //Allows providing flat, crit, and multiplicative tag values on gear. These will apply on *any* minion or sentry hit, not just if the target is tagged. + public int bonusFlatTag = 0; + public float bonusCritTag = 0; + public float bonusMultTag = 0; + #endregion + #region Biome - public bool ZoneSunkenSea => ZoneTimelessShores || ZoneRadiantReefs || ZonePolypForest || ZoneGleamingBurrows || ZoneBasaltGully; + public bool ZoneSunkenSea => ZoneTimelessShores || ZoneRadiantReefs || ZonePolypForest || ZoneGleamingBurrows || ZoneClamDen || ZoneBasaltGully; public bool ZoneTimelessShores => Player.InModBiome(); public bool ZonePolypForest => Player.InModBiome(); public bool ZoneRadiantReefs => Player.InModBiome(); public bool ZoneGleamingBurrows => Player.InModBiome(); + public bool ZoneClamDen => Player.InModBiome(); public bool ZoneBasaltGully => Player.InModBiome(); public bool ZoneSulphur => Player.InModBiome(); @@ -1530,13 +1650,11 @@ namespace CalamityMod.CalPlayer public bool ZoneAbyssLayer3 => Player.InModBiome(); public bool ZoneAbyssLayer4 => Player.InModBiome(); - public bool ZoneFloralParadise => Player.InModBiome(); - public bool ZoneCalamity => Player.InModBiome(); public bool ZoneAstral => Player.InModBiome() && !ZoneAbyss; - public bool InAnyCalamityBiome => ZoneAbyss || ZoneCalamity || ZoneFloralParadise || ZoneSulphur || ZoneSunkenSea || ZoneAstral; + public bool InAnyCalamityBiome => ZoneAbyss || ZoneCalamity || ZoneSulphur || ZoneSunkenSea || ZoneAstral; public bool abyssDeath = false; public int abyssBreathCD; @@ -1544,33 +1662,19 @@ namespace CalamityMod.CalPlayer #endregion #region Transformation - public bool abyssalDivingSuitPrevious; public bool abyssalDivingSuit; - public bool abyssalDivingSuitHide; - public bool abyssalDivingSuitForce; - public bool abyssalDivingSuitPower; + public bool abyssalDivingSuitPrevious; public bool profanedCrystal; public int profanedCrystalStatePrevious; public bool profanedCrystalPrevious; public int profanedCrystalAnim; - public bool profanedCrystalForce; public bool profanedCrystalBuffs; - public bool profanedCrystalHide; - public KeyValuePair profanedCrystalWingCounter = new KeyValuePair(0, 10); - public KeyValuePair profanedCrystalAnimCounter = new KeyValuePair(0, 10); + public int pscState; public Color pscLerpColor = Color.White; public bool aquaticHeartPrevious; public bool aquaticHeart; - public bool aquaticHeartHide; - public bool aquaticHeartForce; - public bool aquaticHeartPower; - public bool snowmanPrevious; - public bool snowman; - public bool snowmanHide; - public bool snowmanForce; public bool snowmanNoseless; - public bool snowmanPower; public bool meldTransformationPrevious; public bool meldTransformation; public bool meldTransformationForce; @@ -1579,8 +1683,6 @@ namespace CalamityMod.CalPlayer public bool omegaBlueTransformation; public bool omegaBlueTransformationForce; public bool omegaBlueTransformationPower; - public bool ghostBracelet; - public bool punchCard; #endregion #region Calamitas Enchant Effects @@ -1660,6 +1762,7 @@ namespace CalamityMod.CalPlayer // This may seem like a scuffed setup, but a simple bool will have ordering issues when it comes to drawing. // Until ModSceneMetrics gets implemented, this works for now. public int BrimstoneLavaFountainCounter = 0; + public FireParticleSet ManaBurnFireDrawer = null; #endregion Draw Effects #region Draedon Summoning @@ -1672,8 +1775,19 @@ namespace CalamityMod.CalPlayer #region Mouse Controls Syncing public bool mouseRight = false; private bool oldMouseRight = false; - public Vector2 mouseWorld; - private Vector2 oldMouseWorld; + + public float oldGravDir = 1; + public float tempGravDir = 1; + public bool justChangedGravity = false; + + public Vector2 mouseWorld => Player.MountedCenter + mouseWorldDeltaFromPlayer; + public Vector2 mouseNormalFromPlayer => mouseRotationFromPlayer.ToRotationVector2(); + public Vector2 mouseWorldDeltaFromPlayer; + public float mouseRotationFromPlayer; + + private Vector2 oldMouseWorldDeltaFromPlayer; + private int mouseWorldPacketTimer = 0; + private const int MouseWorldPacketInterval = 2; /// /// Set this to true if you need to receive updates on right clicks from players and sync them in multiplayer.
@@ -1682,16 +1796,20 @@ namespace CalamityMod.CalPlayer public bool rightClickListener = false; /// /// Set this to true if you need to receive updates on the position of the player's mouse and sync them in multiplayer.
- /// Automatically resets itself after sending an update. + /// Automatically resets itself after sending an update.
+ /// This also update the rotation. ///
public bool mouseWorldListener = false; /// /// Set this to true if you need to receive updates on the rotation of the mouse to the player. This sends updates less frequently the tighter the tolerance of mouseWorldListener.
- /// Automatically resets itself after sending an update. + /// Automatically resets itself after sending an update.
+ /// This does NOT update the position. ///
public bool mouseRotationListener = false; - public bool syncMouseControls = false; + public bool syncMousePosition = false; + public bool syncMouseRotation = false; + public bool syncMouseRightClick = false; #endregion #endregion @@ -1708,7 +1826,6 @@ namespace CalamityMod.CalPlayer sStrawberry = false; pHeart = false; cShard = false; - nimbleBounderBoost = false; revJamDrop = false; rageBoostOne = false; rageBoostTwo = false; @@ -1742,7 +1859,6 @@ namespace CalamityMod.CalPlayer newPrincessInventory = false; newSkeletonMerchantInventory = false; newPermafrostInventory = false; - newCirrusInventory = false; newAmidiasInventory = false; newBanditInventory = false; newCalamitasInventory = false; @@ -1762,7 +1878,6 @@ namespace CalamityMod.CalPlayer boost.AddWithCondition("dragonFruit", sStrawberry); boost.AddWithCondition("phantomHeart", pHeart); boost.AddWithCondition("cometShard", cShard); - boost.AddWithCondition("nimbleBounder", nimbleBounderBoost); boost.AddWithCondition("revJam", revJamDrop); boost.AddWithCondition("rageOne", rageBoostOne); boost.AddWithCondition("rageTwo", rageBoostTwo); @@ -1796,7 +1911,6 @@ namespace CalamityMod.CalPlayer boost.AddWithCondition("newPrincessInventory", newPrincessInventory); boost.AddWithCondition("newSkeletonMerchantInventory", newSkeletonMerchantInventory); boost.AddWithCondition("newPermafrostInventory", newPermafrostInventory); - boost.AddWithCondition("newCirrusInventory", newCirrusInventory); boost.AddWithCondition("newAmidiasInventory", newAmidiasInventory); boost.AddWithCondition("newBanditInventory", newBanditInventory); boost.AddWithCondition("newCalamitasInventory", newCalamitasInventory); @@ -1854,7 +1968,6 @@ namespace CalamityMod.CalPlayer sStrawberry = boost.Contains("dragonFruit"); pHeart = boost.Contains("phantomHeart"); cShard = boost.Contains("cometShard"); - nimbleBounderBoost = boost.Contains("nimbleBounder"); revJamDrop = boost.Contains("revJam"); rageBoostOne = boost.Contains("rageOne"); rageBoostTwo = boost.Contains("rageTwo"); @@ -1888,7 +2001,6 @@ namespace CalamityMod.CalPlayer newPrincessInventory = boost.Contains("newPrincessInventory"); newSkeletonMerchantInventory = boost.Contains("newSkeletonMerchantInventory"); newPermafrostInventory = boost.Contains("newPermafrostInventory"); - newCirrusInventory = boost.Contains("newCirrusInventory"); newAmidiasInventory = boost.Contains("newAmidiasInventory"); newBanditInventory = boost.Contains("newBanditInventory"); newCalamitasInventory = boost.Contains("newCalamitasInventory"); @@ -1962,13 +2074,25 @@ namespace CalamityMod.CalPlayer #region ResetEffects public override void ResetEffects() { + if (!areThereAnyDamnBosses) + { + DoGHeadHitCounter = 0; + } + ViridVanguardActiveAttackerThisFrame = Main.projectile.Any(x => x.active && x.type == ModContent.ProjectileType() && x.owner == Player.whoAmI && x.ModProjectile().CurrentState == ViridVanguardBlade.ViridVanguardAIState.PhotonRipperZenithSlashes); + ViridVanguardRotation = MathHelper.WrapAngle(ViridVanguardRotation + ViridVanguardRotationToAdd); + ViridVanguardRotationToAdd = ViridVanguard.IdleCirclingSpeed; + + if (Player.HeldItem.type == ModContent.ItemType()) + { + if (ViridVanguardActiveCooldown > 0) + ViridVanguardActiveCooldown--; + } + else if (ViridVanguardActiveCooldown >= 0 && ViridVanguardActiveCooldown < ViridVanguard.ActiveAttackCooldown) + ViridVanguardActiveCooldown++; if (fleshKnuckles) - Player.statLifeMax2 += 45; - - int percentMaxLifeIncrease = 0; - if (ZoneAbyss && lumenousAmulet) - percentMaxLifeIncrease += 25; + Player.statLifeMax2 += 25; + int percentMaxLifeIncrease = 0; // Blood Pact and Chalice of the Blood God stack their HP bonuses if you want to equip both if (bloodPact) percentMaxLifeIncrease += 25; @@ -1976,7 +2100,7 @@ namespace CalamityMod.CalPlayer percentMaxLifeIncrease += 25; if (affliction || afflicted) - percentMaxLifeIncrease += 10; + percentMaxLifeIncrease += Affliction.MaxLifeBoostPercent; if (community) percentMaxLifeIncrease += (int)(TheCommunity.CalculatePower() * TheCommunity.HealthMultiplier); @@ -2007,8 +2131,6 @@ namespace CalamityMod.CalPlayer DashID = string.Empty; - externalAbyssLight = 0; - externalBreathLossMultBoost = 0f; externalBreathTickBoost = 0f; externalFlightTimeMultBoost = 0f; externalRageEnabled = externalAdrenalineEnabled = null; @@ -2019,6 +2141,81 @@ namespace CalamityMod.CalPlayer alcoholPoisonLevel = 0; noLifeRegen = false; + //Stratus Starburst amount management + + if (HalleyAccuracyCounter > HalleysInferno.MaxAccuracy) + HalleyAccuracyCounter = HalleysInferno.MaxAccuracy; + if (HalleyAccuracyCounter < 0) + HalleyAccuracyCounter = 0; + while (StarburstSpawnFrameCounter >= 1) + { + StratusStarburst++; + StarburstSpawnFrameCounter--; + } + if (Starshield > 0) + { + Starshield--; + StratusStarburstResetTimer = (int)MathHelper.Max(300,StratusStarburstResetTimer); + } + if (StratusStarburstResetTimer > 0) + StratusStarburstResetTimer--; + else if (StratusStarburst > 0) + StratusStarburst--; + if (StratusStarburst > MaxStratusStarburst) + StratusStarburst = MaxStratusStarburst; + var starpower = 0; + var avaliableStarpower = 0; + var oneCount = 0; + Vector2 starSpawnPos = Player.Center; + for (var i = 0; i < StarburstEntities.Count(); i++) + { + starpower += StarburstEntities[i].value; + if (StarburstEntities[i].AICooldown <= 0) + avaliableStarpower += StarburstEntities[i].value; + if (starpower > StratusStarburst) + { + var deadStar = StarburstEntities[i]; + starpower -= deadStar.value; + StarburstEntities.RemoveAt(i); + starSpawnPos = deadStar.Center; + i--; + continue; + } + if (StarburstEntities[i].value == 1) + oneCount++; + } + while (starpower < StratusStarburst) + { + StarburstEntities.Add(new(starSpawnPos)); + oneCount++; + starpower++; + avaliableStarpower++; + } + while (oneCount >= 10) + { + var bigStar = StarburstEntities.First(x => x.value == 1); + bigStar.value = 10; + for (var i = 0; i < 9; i++) + { + var star = StarburstEntities.Last(x => x.value == 1); + bigStar.MergeChildren.Add(star); + star.MergeTarget = bigStar; + StarburstEntities.Remove(star); + } + oneCount -= 10; + } + AvaliableStarburst = avaliableStarpower; + if (StratusStarburstResetTimer > 0) + { + if (cooldowns.TryGetValue(Starburst.ID, out var cooldown)) + { + cooldown.timeLeft = MaxStratusStarburst - StratusStarburst; + } + else + { + Player.AddCooldown(Starburst.ID, MaxStratusStarburst); + } + } // Shields. Has to intentionally be above resetting accessories and armor or the shields would clear instantly if (!roverDrive) RoverDriveShieldDurability = 0; @@ -2038,6 +2235,7 @@ namespace CalamityMod.CalPlayer perfmini = false; akato = false; yharonPet = false; + burrowerPet = false; leviPet = false; plaguebringerBab = false; rotomPet = false; @@ -2062,17 +2260,16 @@ namespace CalamityMod.CalPlayer pineapplePet = false; eidolonSnailPet = false; lordePet = false; + frostyBat = false; + toastyBat = false; onyxExcavator = false; rimehound = false; - fab = false; crysthamyr = false; ExoChair = false; miniOldDuke = false; miniOldDukeVanity = false; - abyssalDivingSuitPlates = false; - aquaticHeartWaterBuff = false; aquaticHeartIce = false; @@ -2097,7 +2294,6 @@ namespace CalamityMod.CalPlayer silvaSummon = false; auricSet = false; - auricBoost = false; auricSetMelee = false; GemTechSet = false; @@ -2110,7 +2306,7 @@ namespace CalamityMod.CalPlayer omegaBlueChestplate = false; omegaBlueSet = false; - omegaBlueHentai = false; + omegaBlueAbyssalMadness = false; molluskHelmet = false; molluskChest = false; @@ -2119,7 +2315,6 @@ namespace CalamityMod.CalPlayer ataxiaBolt = false; ataxiaGeyser = false; - ataxiaFire = false; ataxiaVolley = false; ataxiaBlaze = false; ataxiaMage = false; @@ -2129,7 +2324,6 @@ namespace CalamityMod.CalPlayer shadowSpeed = false; dsSetBonus = false; wearingRogueArmor = false; - cirrusDress = false; blockAllDashes = false; blazingCursorDamage = false; @@ -2141,13 +2335,17 @@ namespace CalamityMod.CalPlayer trinketOfChi = false; gladiatorSword = false; unstableGraniteCore = false; - regenator = false; + regenerator = false; deepDiver = false; theBee = false; arcFlashRing = false; arcFlashRingVisual = false; bGlassBand = false; bGlassBandVisual = false; + batholithBangle = false; // Granite band + batholithBangleVisual = false; + protolithBangle = false; // Marble band + protolithBangleVisual = false; aFossil = false; aPowder = false; fallingBlockProtection = false; @@ -2157,13 +2355,19 @@ namespace CalamityMod.CalPlayer fishingStation = false; rBrain = false; bloodyWormTooth = false; + ivDrip = false; vexation = false; badgeOfBravery = false; + // Clear the Warbanner "cooldown" if not wearing Warbanner. This has absolutely zero effect for a casual player, but is useful for resetting the cooldown's duration. + if (!WarbanneroftheRighteous) + cooldowns.Remove(WarbanneroftheRighteousBuff.ID); WarbanneroftheRighteous = false; warbannerGlow = false; ilSpark = false; transformer = false; transformerVisual = false; + bloomStone = false; + bloomStoneHookVisuals = false; hideOfDeus = false; dAmulet = false; rampartOfDeities = false; @@ -2171,12 +2375,12 @@ namespace CalamityMod.CalPlayer lAmbergris = false; tortShell = false; absorber = false; - alwaysHoneyRegen = false; - honeyTurboRegen = false; honeyDewHalveDebuffs = false; livingDewHalveDebuffs = false; aAmpoule = false; rOoze = false; + radiantOozeRegen = 0; + purityRegen = 0; fBarrier = false; aBrain = false; amalgam = false; @@ -2188,13 +2392,14 @@ namespace CalamityMod.CalPlayer teslaVisuals = true; cryogenSoul = false; ascendantInsignia = false; - ascendantTrail = false; - frozenWingsCold = false; - flameWingsHeat = false; magmaStoneVisuals = true; eGauntlet = false; eGauntletVisuals = true; gloveLevel = 0; + if (Player.dashDelay != -1) + statisNinjaBelt = false; + if (Player.dashDelay != -1) + statisVoidSash = false; alreadyHasFrogLeg = false; eTalisman = false; nucleogenesis = false; @@ -2211,6 +2416,7 @@ namespace CalamityMod.CalPlayer lifejelly = false; GrandGelatin = false; cleansingjelly = false; + spawnedJellyAura = false; community = false; shatteredCommunity = false; stressPills = false; @@ -2219,6 +2425,7 @@ namespace CalamityMod.CalPlayer bloodPact = false; bloodflareCore = false; chaliceOfTheBloodGod = false; + chaliceHeartStyle = false; chaliceBleedoutToApplyOnHurt = 0; // Resets every frame so it doesn't improperly carry over between hits elementalHeart = false; crownJewel = false; @@ -2240,7 +2447,7 @@ namespace CalamityMod.CalPlayer shieldOfTheOcean = false; normalityRelocator = false; flameLickedShell = false; - Pauldron = false; + sPauldron = false; XykVisualsBlue = false; XykVisualsOrange = false; manaOverloader = false; @@ -2254,12 +2461,10 @@ namespace CalamityMod.CalPlayer phantomicArtifact = false; hallowedRegen = false; hallowedPower = false; - kamiBoost = false; tracersDust = false; - elysianWingsDust = false; - tracersCelestial = false; - tracersElysian = false; - tracersSeraph = false; + moonWalkers = false; + voidStriders = false; + seraphTracers = false; ursaSergeant = false; ursaSergeantVisual = false; scuttlersJewel = false; @@ -2272,19 +2477,15 @@ namespace CalamityMod.CalPlayer starbusterCore = false; starTaintedGenerator = false; camper = false; - silvaWings = false; corrosiveSpine = false; - RustyMedallionDroplets = false; + scionsCurio = false; rottenDogTooth = false; angelicAlliance = false; - BloomStoneRegen = false; ChaosStone = false; CryoStone = false; CryoStoneVanity = false; voidField = false; copyrightInfringementShield = false; - reducedDaybrokenDamage = false; - reducedNightwitherDamage = false; daedalusReflect = false; daedalusSplit = false; @@ -2297,12 +2498,11 @@ namespace CalamityMod.CalPlayer lunicCorpsSet = false; lunicCorpsLegs = false; - rangedAmmoCost = 1f; + ammoCost = 1f; healingPotionMultiplier = 1f; avertorBonus = false; - reaverRegen = false; reaverSpeed = false; reaverDefense = false; reaverExplore = false; @@ -2315,13 +2515,14 @@ namespace CalamityMod.CalPlayer flameWakerBoots = false; hellfireTreads = false; sSpiritAmulet = false; - lumenousAmulet = false; + dOfTheDeep = false; oceanCrest = false; aquaticEmblem = false; if (!spiritOrigin) spiritOriginCritBoost = 0; spiritOrigin = false; spiritOriginVanity = false; + critDamage = 0; astralStarRain = false; @@ -2333,10 +2534,10 @@ namespace CalamityMod.CalPlayer forbiddenCirclet = false; silverMedkit = false; + tungstenArmorHookBoost = false; goldArmorGoldDrops = false; miningSet = false; - miningSetCooldown = 0; eskimoSet = false; rainSet = false; @@ -2344,8 +2545,11 @@ namespace CalamityMod.CalPlayer necroSet = false; frostSet = false; - victideSet = false; - victideSummoner = false; + victideBarrierSet = false; + victideBarrierHead = false; + victideBurrowSet = false; + victideBurrowHead = false; + victideSnailSet = false; sulphurSet = false; @@ -2356,7 +2560,6 @@ namespace CalamityMod.CalPlayer titanHeartSet = false; titanHeartMask = false; titanHeartMantle = false; - titanHeartBoots = false; umbraphileSet = false; plagueReaper = false; plaguebringerPatronSet = false; @@ -2415,27 +2618,26 @@ namespace CalamityMod.CalPlayer alcoholPoisoning = false; shadowflame = false; daybroken = false; - wDeath = false; + whisperingDeath = false; dragonFire = false; vermillionFlux = false; auricRebuke = false; staticDischarge = false; miracleBlight = false; - aCrunch = false; + armorCrunch = false; crumble = false; irradiated = false; - bFlames = false; + brimstoneFlames = false; witheredDebuff = false; absorberAffliction = false; weakBrimstoneFlames = false; demonicFlames = false; - gsInferno = false; + godSlayerInferno = false; astralInfection = false; - pFlames = false; - hFlames = false; - hInferno = false; - gState = false; - bBlood = false; + plague = false; + holyFlames = false; + holyInferno = false; + burningBlood = false; brainRot = false; heavybleeding = false; laceration = false; @@ -2445,9 +2647,9 @@ namespace CalamityMod.CalPlayer trueVHex = false; DoGExtremeGravity = false; warped = false; - cDepth = false; - rTide = false; - hPressure = false; + crushDepth = false; + riptide = false; + hadopelagicPressure = false; fishAlert = false; clamity = false; NOU = false; @@ -2457,14 +2659,20 @@ namespace CalamityMod.CalPlayer nightwither = false; voidfrost = false; eutrophication = false; - iCantBreathe = false; - cragsLava = false; + frozenLungs = false; + searingLava = false; vaporfied = false; banishingFire = false; wither = false; ManaBurn = false; - trinketOfChiBuff = false; + TypelessDebuffMultiplier = new(); + HeatDebuffMultiplier = new(); + ColdDebuffMultiplier = new(); + SicknessDebuffMultiplier = new(); + WaterDebuffMultiplier = new(); + ElectricDebuffMultiplier = new(); + sandsWindBuff = false; aeolianEarthBuff = false; corrEffigy = false; @@ -2474,7 +2682,6 @@ namespace CalamityMod.CalPlayer xWrath = false; graxDefense = false; encased = false; - brutalCarnage = false; omniscience = false; zerg = false; zen = false; @@ -2496,10 +2703,13 @@ namespace CalamityMod.CalPlayer trippy = false; amidiasBlessing = false; flaskBrimstone = false; - cirrusVodka = false; + purpleHaze = false; + if (purpleHazeStealthTimer > 0) + purpleHazeStealthTimer--; shine = false; anechoicCoating = false; mushy = false; + fortunesFavor = false; PinkJellyRegen = false; GreenJellyRegen = false; AbsorberRegen = false; @@ -2508,11 +2718,11 @@ namespace CalamityMod.CalPlayer bloodfinBoost = false; divineBless = false; - killSpikyBalls = false; - vodka = false; redWine = false; grapeBeer = false; + if (grapeBeerTimer > 0) + grapeBeerTimer--; moonshine = false; rum = false; whiskey = false; @@ -2537,10 +2747,12 @@ namespace CalamityMod.CalPlayer pinkCandle = false; yellowCandle = false; + SelectedFishingMinigame = FishingMinigames.None; + #region Minion Reset Effects wDroid = false; resButterfly = false; - mWorm = false; + hasVoidEaterMarionette = false; IceClasperBool = false; magicHat = false; herring = false; @@ -2553,27 +2765,26 @@ namespace CalamityMod.CalPlayer aSlime = false; brittleStar = false; aquaticStar = false; - SP = false; + sunSpirit = false; dCreeper = false; - bClot = false; eAxe = false; endoCooper = false; apexShark = false; gastricBelcher = false; hauntedDishes = false; stormjaw = false; - SPG = false; + vengefulSunMinion = false; sirius = false; aChicken = false; cLamp = false; pGuy = false; cEnergy = false; pSoulGuardians = false; - sWaifu = false; - dWaifu = false; - cWaifu = false; - bWaifu = false; - slWaifu = false; + sandEleBuff = false; + rareSandEleBuff = false; + cloudEleBuff = false; + brimEleBuff = false; + waterEleBuff = false; fClump = false; rDevil = false; aValkyrie = false; @@ -2584,21 +2795,20 @@ namespace CalamityMod.CalPlayer astralProbe = false; victideSnail = false; cSpirit = false; - rOrb = false; dCrystal = false; MutatedTruffleBool = false; - sandWaifu = false; - sandWaifuVanity = false; - sandBoobWaifu = false; - sandBoobWaifuVanity = false; - cloudWaifu = false; - cloudWaifuVanity = false; - brimstoneWaifu = false; - brimstoneWaifuVanity = false; - sirenWaifu = false; - sirenWaifuVanity = false; - allWaifus = false; - allWaifusVanity = false; + sandElemental = false; + sandElementalVanity = false; + rareSandElemental = false; + rareSandElementalVanity = false; + cloudElemental = false; + cloudElementalVanity = false; + brimElemental = false; + brimElementalVanity = false; + waterElemental = false; + waterElementalVanity = false; + allElementals = false; + allElementalsVanity = false; fungalClump = false; fungalClumpVanity = false; howlsHeart = false; @@ -2622,6 +2832,10 @@ namespace CalamityMod.CalPlayer voidAuraDamage = false; voidConcentrationAura = false; saros = false; + if (sarosEclipseBeamUsage > 300) + sarosEclipseBeamUsage = 300; + if (sarosEclipseBeamUsage > 0 && Player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + sarosEclipseBeamUsage--; virili = false; frostBlossom = false; cinderBlossom = false; @@ -2635,9 +2849,9 @@ namespace CalamityMod.CalPlayer necrosteocytesDudes = false; gammaHead = false; tundraFlameBlossom = false; - starSwallowerPetFroge = false; snakeEyes = false; poleWarper = false; + aqueousHunterDrone = false; causticDragon = false; plaguebringerPatronSummon = false; howlTrio = false; @@ -2647,7 +2861,7 @@ namespace CalamityMod.CalPlayer deathstareEyeball = false; witherBlossom = false; flowersOfMortality = false; - ViridVanguard = false; + viridVanguard = false; sageSpirit = false; fleshBall = false; eyeOfNight = false; @@ -2659,11 +2873,17 @@ namespace CalamityMod.CalPlayer KalandraMirror = false; StellarTorus = false; LiliesOfFinalityBool = false; - FlarebatBool = false; - FrostbatBool = false; + EnchantedKnifeStaffBool = false; AmphibiansGuitarBool = false; #endregion + //On GFB both are enabled to cause the game to pick between multiplicative and crit at random + forceSummonTagMultiplicative = (Main.zenithWorld ? true : false); + forceSummonTagCrit = (Main.zenithWorld ? true : false); + bonusFlatTag = 0; + bonusCritTag = 0; + bonusMultTag = 0; + /* Spawn blockers from back when they used to work by being favorited and not a toggleable item noStupidNaturalARSpawns = false disableVoodooSpawns = false; @@ -2674,32 +2894,24 @@ namespace CalamityMod.CalPlayer */ abyssalDivingSuitPrevious = abyssalDivingSuit; - abyssalDivingSuit = abyssalDivingSuitHide = abyssalDivingSuitForce = abyssalDivingSuitPower = false; + abyssalDivingSuit = false; - aquaticHeartPrevious = aquaticHeart; - aquaticHeart = aquaticHeartHide = aquaticHeartForce = aquaticHeartPower = false; + aquaticHeart = false; profanedCrystalStatePrevious = pscState; profanedCrystalPrevious = profanedCrystal; - profanedCrystal = profanedCrystalBuffs = profanedCrystalForce = profanedCrystalHide = false; + profanedCrystal = profanedCrystalBuffs = false; pscState = 0; pscLerpColor = Color.White; - snowmanPrevious = snowman; - snowman = snowmanHide = snowmanForce = snowmanPower = false; - meldTransformationPrevious = meldTransformation; meldTransformation = meldTransformationForce = meldTransformationPower = false; omegaBlueTransformationPrevious = omegaBlueTransformation; omegaBlueTransformation = omegaBlueTransformationForce = omegaBlueTransformationPower = false; - ghostBracelet = false; - punchCard = false; - rageModeActive = false; adrenalineModeActive = false; - AdrenalineTrail = false; RageDuration = BalancingConstants.DefaultRageDuration; RageDamageBoost = BalancingConstants.DefaultRageDamageBoost; @@ -2721,7 +2933,22 @@ namespace CalamityMod.CalPlayer infiniteFlight = false; - EnchantHeldItemEffects(Player, Player.Calamity(), Player.ActiveItem()); + noStupidNaturalARSpawns = false; + disableAnahitaSpawns = false; + disableHiveCystSpawns = false; + disableNaturalScourgeSpawns = false; + disablePerfCystSpawns = false; + disableVoodooSpawns = false; + + + #region Abyss + abyssDarkness = 0; + abyssPlayerGlowMultiplier = 1; + abyssFlashlightWidthMultiplier = 1; + darknessIntensity = MathHelper.Max(darknessIntensity-0.05f,0); + #endregion + + EnchantHeldItemEffects(Player, Player.Calamity(), Player.HeldItem); } #endregion @@ -2745,14 +2972,12 @@ namespace CalamityMod.CalPlayer public override void ModifyScreenPosition() { // CIT 08FEB2025: Photosensitivity config also disables screenshake - if (CalamityClientConfig.Instance.ScreenshakePower == 0 || CalamityClientConfig.Instance.Photosensitivity) - return; + bool allowScreenshake = CalamityClientConfig.Instance.ScreenshakePower > 0 && !CalamityClientConfig.Instance.Photosensitivity; - if (GeneralScreenShakePower > 0f) - { + if (GeneralScreenShakePower > 0f && allowScreenshake) Main.screenPosition += Main.rand.NextVector2Circular(GeneralScreenShakePower * CalamityClientConfig.Instance.ScreenshakePower, GeneralScreenShakePower * CalamityClientConfig.Instance.ScreenshakePower); - GeneralScreenShakePower = MathHelper.Clamp(GeneralScreenShakePower - 0.185f, 0f, 20f * CalamityClientConfig.Instance.ScreenshakePower); - } + + GeneralScreenShakePower = MathHelper.Clamp(GeneralScreenShakePower - 0.185f, 0f, 20f * CalamityClientConfig.Instance.ScreenshakePower); } #endregion @@ -2799,6 +3024,8 @@ namespace CalamityMod.CalPlayer #endregion #region Buffs, Debuffs, Counters, and Nonsense + if (Player.HeldItem.IsAir || Player.HeldItem.fishingPole == 0) + consecutiveCaughtFish = 0; heldGaelsLastFrame = false; gaelSwipes = 0; whitewaterHeal = 0; @@ -2815,16 +3042,20 @@ namespace CalamityMod.CalPlayer auralisAurora = 0; necroReviveCounter = -1; hideOfDeusTimer = 0; + bloomStoneHealPool = 0; + bloomStoneTotalHeal = 0; + bloomStoneHealTimer = 0; + bloomStoneHealRate = 0; murasamaHitCooldown = 0; - RustyMedallionCooldown = 0; SulphWaterPoisoningLevel = 0f; holyInfernoFadeIntensity = 0f; spiritOriginCritBoost = 0; + critDamage = 0f; rage = 0f; adrenaline = 0f; - raiderCritLifespan = 0f; + raiderCritLifespan = 0; raiderSoundCooldown = 0; - gSabatonHotkeyHoldTime = 0; + gSabatonHotkeyFallWindup = -1; gSabatonFall = 0; gSabatonFalling = false; gSabatonTempJumpSpeed = 0; @@ -2845,8 +3076,6 @@ namespace CalamityMod.CalPlayer rOfResilienceEffect = 0; demonSwordKillMode = false; - externalAbyssLight = 0; - externalBreathLossMultBoost = 0f; externalBreathTickBoost = 0f; externalFlightTimeMultBoost = 0f; externalColdImmunity = externalHeatImmunity = false; @@ -2859,11 +3088,9 @@ namespace CalamityMod.CalPlayer jetPackDirection = 0; andromedaCripple = 0; theBeeCooldown = 0; - killSpikyBalls = false; scuttlerCooldown = 0; rogueCrownCooldown = 0; wingProjectileCooldown = 0; - statisTimer = 0; hallowedRuneCooldown = 0; sulphurBubbleCooldown = 0; ladHearts = 0; @@ -2874,27 +3101,26 @@ namespace CalamityMod.CalPlayer alcoholPoisoning = false; shadowflame = false; daybroken = false; - wDeath = false; + whisperingDeath = false; dragonFire = false; vermillionFlux = false; auricRebuke = false; staticDischarge = false; miracleBlight = false; - aCrunch = false; + armorCrunch = false; crumble = false; irradiated = false; - bFlames = false; + brimstoneFlames = false; witheredDebuff = false; absorberAffliction = false; weakBrimstoneFlames = false; demonicFlames = false; - gsInferno = false; + godSlayerInferno = false; astralInfection = false; - pFlames = false; - hFlames = false; - hInferno = false; - gState = false; - bBlood = false; + plague = false; + holyFlames = false; + holyInferno = false; + burningBlood = false; brainRot = false; heavybleeding = false; laceration = false; @@ -2904,25 +3130,30 @@ namespace CalamityMod.CalPlayer trueVHex = false; DoGExtremeGravity = false; warped = false; - cDepth = false; - rTide = false; - hPressure = false; + crushDepth = false; + riptide = false; + hadopelagicPressure = false; fishAlert = false; clamity = false; NOU = false; snowmanNoseless = false; - abyssalDivingSuitPlateHits = 0; sulphurPoison = false; nightwither = false; voidfrost = false; eutrophication = false; - iCantBreathe = false; - cragsLava = false; + frozenLungs = false; + searingLava = false; vaporfied = false; banishingFire = false; wither = false; PurityHealSlowdownFrames = 0; ImmobilityDebuffImmunityTimer = 0; + TypelessDebuffMultiplier = new(); + HeatDebuffMultiplier = new(); + ColdDebuffMultiplier = new(); + SicknessDebuffMultiplier = new(); + WaterDebuffMultiplier = new(); + ElectricDebuffMultiplier = new(); #endregion #region Rogue @@ -2952,13 +3183,10 @@ namespace CalamityMod.CalPlayer hallowedPower = false; onyxExcavator = false; rimehound = false; - fab = false; crysthamyr = false; ExoChair = false; - abyssalDivingSuitPlates = false; aquaticHeartWaterBuff = false; aquaticHeartIce = false; - trinketOfChiBuff = false; sandsWindBuff = false; aeolianEarthBuff = false; chiBuffTimer = 0; @@ -2966,10 +3194,8 @@ namespace CalamityMod.CalPlayer crimEffigy = false; rRage = false; xWrath = false; - kamiBoost = false; graxDefense = false; encased = false; - brutalCarnage = false; omniscience = false; zerg = false; zen = false; @@ -2990,10 +3216,11 @@ namespace CalamityMod.CalPlayer sulphurskin = false; baguette = false; flaskBrimstone = false; - cirrusVodka = false; + purpleHaze = false; shine = false; anechoicCoating = false; mushy = false; + fortunesFavor = false; PinkJellyRegen = false; GreenJellyRegen = false; AbsorberRegen = false; @@ -3029,13 +3256,12 @@ namespace CalamityMod.CalPlayer pinkCandleHealFraction = 0D; yellowCandle = false; trippy = false; - trippyLevel = 1; amidiasBlessing = false; bloodfinBoost = false; bloodfinTimer = 0; healCounter = 300; danceOfLightCharge = 0; - rangedAmmoCost = 1f; + ammoCost = 1f; healingPotionMultiplier = 1f; avertorBonus = false; divineBless = false; @@ -3046,6 +3272,7 @@ namespace CalamityMod.CalPlayer #region Armor Set Bonuses silverMedkit = false; silverMedkitTimer = 0; + tungstenArmorHookBoost = false; goldArmorGoldDrops = false; miningSet = false; miningSetCooldown = 0; @@ -3056,13 +3283,12 @@ namespace CalamityMod.CalPlayer godSlayerThrowing = false; godSlayerDashHotKeyPressed = false; SpeedBlasterDashStarted = false; - auricBoost = false; auricSetMelee = false; silvaSet = false; silvaMage = false; silvaSummon = false; hasSilvaEffect = false; - silvaCountdown = silvaReviveDuration; + silvaCountdown = SilvaArmor.ReviveDuration; auricSet = false; GemTechSet = false; CobaltSet = false; @@ -3087,8 +3313,6 @@ namespace CalamityMod.CalPlayer lunicCorpsSet = false; lunicCorpsLegs = false; reaverSpeed = false; - reaverRegen = false; - reaverRegenCooldown = 0; reaverDefense = false; reaverExplore = false; shadeRegen = false; @@ -3096,7 +3320,6 @@ namespace CalamityMod.CalPlayer titanHeartSet = false; titanHeartMask = false; titanHeartMantle = false; - titanHeartBoots = false; titanCooldown = 0; umbraphileSet = false; fathomSwarmer = false; @@ -3114,7 +3337,6 @@ namespace CalamityMod.CalPlayer ataxiaMage = false; ataxiaBolt = false; ataxiaGeyser = false; - ataxiaFire = false; ataxiaVolley = false; ataxiaBlaze = false; hydrothermalSmoke = false; @@ -3128,7 +3350,10 @@ namespace CalamityMod.CalPlayer meteorSet = false; necroSet = false; frostSet = false; - victideSet = false; + victideBarrierSet = false; + victideBarrierHead = false; + victideBurrowSet = false; + victideBurrowHead = false; aeroSet = false; sulphurSet = false; statigelSet = false; @@ -3155,7 +3380,6 @@ namespace CalamityMod.CalPlayer fearmongerRegenFrames = 0; xerocSet = false; tracersDust = false; - elysianWingsDust = false; GemTechState.OnDeathEffects(); shieldOfTheOceanParry = 0; shieldOfTheOceanEmpoweredParry = false; @@ -3182,20 +3406,16 @@ namespace CalamityMod.CalPlayer CurrentlyViewedHologramText = string.Empty; #endregion - KameiBladeUseDelay = 0; - AdrenalineTrail = false; - ascendantTrail = false; evilSmasherBoost = 0; burningSeaBurnOut = 0; + flareGunOverheat = 0; hellbornShots = 0; - searedPanCounter = 0; - searedPanTimer = 0; - potionTimer = 0; + darklightEnergy = 0; + elementalMastery = 0; + garandShots = 0; persecutedEnchantSummonTimer = 0; momentumCapacitorTime = 0; momentumCapacitorBoost = 0f; - vortexBoosterStealthDelay = 0; - silvaWingsLifeRegenTimer = 0; LungingDown = false; chaliceBleedoutBuffer = 0D; @@ -3242,8 +3462,9 @@ namespace CalamityMod.CalPlayer if (Player.armor[i].type == itemID) return Player.armor[i]; } - return new Item(); + return ContentSamples.ItemsByType[itemID]; } + public Item FindAccessory() where T : ModItem => FindAccessory(ItemType()); public override void ProcessTriggers(TriggersSet triggersSet) { @@ -3253,14 +3474,14 @@ namespace CalamityMod.CalPlayer if (ascendantInsignia && Main.myPlayer == Player.whoAmI && CalamityKeybinds.AscendantInsigniaHotKey.JustPressed && ascendantInsigniaCooldown <= 0) { - var source = Player.GetSource_Accessory(FindAccessory(ItemType())); + var source = Player.GetSource_Accessory(FindAccessory()); Projectile.NewProjectile(source, Player.Center - Vector2.UnitY * 45f, Vector2.Zero, ProjectileType(), 0, 0f); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/AscendantActivate")); - ascendantInsigniaCooldown = 2400; - ascendantInsigniaBuffTime = 240; //4 seconds + ascendantInsigniaCooldown = AscendantInsignia.AbilityCooldown; + ascendantInsigniaBuffTime = AscendantInsignia.AbilityDuration; } - int numOfBlobs = Player.ownedProjectileCounts[ModContent.ProjectileType()]; + int numOfBlobs = Player.ownedProjectileCounts[ProjectileType()]; if (transformer && numOfBlobs > 0 && Main.myPlayer == Player.whoAmI && CalamityKeybinds.TransformerHotKey.JustPressed && transformerCooldown <= 0 && true) // Add check if projectiles are active { // Go fire all the blobs @@ -3271,7 +3492,7 @@ namespace CalamityMod.CalPlayer for (int x = 0; x < Main.maxProjectiles; x++) { Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.type == ModContent.ProjectileType()) + if (projectile.active && projectile.type == ProjectileType()) { projectile.localAI[0] = 5; } @@ -3284,21 +3505,23 @@ namespace CalamityMod.CalPlayer Particle orb2 = new CustomPulse(Player.Center, Vector2.Zero, Color.DodgerBlue, "CalamityMod/Particles/BloomRingThinLarge", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.2f, 20); GeneralParticleHandler.SpawnParticle(orb2); } - + } - //Only increment hotkey holdtime if not on ground, not mounted, not on rope, not hooked, not tongued, otherwise reset hold time to zero - if (CalamityKeybinds.GravistarSabatonHotkey.Current && gSabaton && Main.myPlayer == Player.whoAmI && (Player.velocity.Y != Player.oldVelocity.Y) && !Player.pulley && !Player.mount.Active && Player.grappling[0] == -1 && !Player.tongued) + //Only increment the slam if not on ground, not mounted, not on rope, not hooked, not tongued, otherwise reset slam time to zero + if (CalamityKeybinds.GravistarSabatonHotkey.JustPressed && gSabatonHotkeyFallWindup < 0) + gSabatonHotkeyFallWindup = 0; + if (gSabaton && gSabatonHotkeyFallWindup >= 0 && Main.myPlayer == Player.whoAmI && (Player.velocity.Y != 0) && !Player.pulley && !Player.mount.Active && Player.grappling[0] == -1 && !Player.tongued) { - gSabatonHotkeyHoldTime++; - if (gSabatonHotkeyHoldTime < 30 && gSabatonHotkeyHoldTime % 3f == 0) + gSabatonHotkeyFallWindup++; + if (gSabatonHotkeyFallWindup < 20 && gSabatonHotkeyFallWindup % 2f == 0) { SpawnGravistarParticle(); } } else if (Main.myPlayer == Player.whoAmI) { - gSabatonHotkeyHoldTime = 0; + gSabatonHotkeyFallWindup = -1; } if (CalamityKeybinds.NormalityRelocatorHotKey.JustPressed && normalityRelocator && Main.myPlayer == Player.whoAmI) @@ -3334,8 +3557,7 @@ namespace CalamityMod.CalPlayer } if (CalamityKeybinds.AngelicAllianceHotKey.JustPressed && angelicAlliance && Main.myPlayer == Player.whoAmI && !divineBless && !Player.HasCooldown(Cooldowns.DivineBless.ID)) { - int seconds = CalamityUtils.SecondsToFrames(15f); - Player.AddBuff(BuffType(), seconds, false); + Player.AddBuff(BuffType(), AngelicAlliance.DivineBlessDuration, false); SoundEngine.PlaySound(AngelicAlliance.ActivationSound, Player.Center); // Spawn an archangel for every minion you have @@ -3350,14 +3572,14 @@ namespace CalamityMod.CalPlayer angelAmt += 1f; } - var source = Player.GetSource_Accessory(FindAccessory(ItemType())); + var source = Player.GetSource_Accessory(FindAccessory()); for (int projIndex = 0; projIndex < angelAmt; projIndex++) { Projectile proj = Main.projectile[projIndex]; float start = 360f / angelAmt; Projectile.NewProjectile(source, new Vector2((int)(Player.Center.X + (Math.Sin(projIndex * start) * 300)), (int)(Player.Center.Y + (Math.Cos(projIndex * start) * 300))), Vector2.Zero, ProjectileType(), proj.damage / 10, proj.knockBack / 10f, Player.whoAmI, Main.rand.Next(180), projIndex * start); - Player.HealPlayer(2); + Player.HealPlayer(AngelicAlliance.HealPerAngelSpawned); } } if (CalamityKeybinds.SpectralVeilHotKey.JustPressed && spectralVeil && Main.myPlayer == Player.whoAmI && rogueStealth >= rogueStealthMax * 0.25f && @@ -3525,7 +3747,7 @@ namespace CalamityMod.CalPlayer //Furthermore, Enumerable#Any is lightweight and returns immediately if a single object matches it's predicate if (!Player.HasCooldown(ParryCooldown.ID) || Player.ownedProjectileCounts[ProjectileType()] == 0) { - GeneralScreenShakePower = 3.5f; + Player.SetScreenshake(3.5f); blazingCoreParry = 30; SoundEngine.PlaySound(BlazingCore.ParryActivateSound, Player.Center); var mySourceIsIMadeItUp = Player.GetSource_FromThis(); @@ -3539,14 +3761,14 @@ namespace CalamityMod.CalPlayer { if (!Player.HasCooldown(ParryCooldown.ID) || Player.ownedProjectileCounts[ProjectileType()] == 0) { - GeneralScreenShakePower = 2.5f; + Player.SetScreenshake(2.5f); SoundEngine.PlaySound(ProfanedGuardianDefender.RockShieldSpawnSound, Player.Center); flameLickedShellParry = FlameLickedShell.flameLickedParry; } } else if (shieldOfTheOcean && shieldOfTheOceanParry == 0) { - GeneralScreenShakePower = 2f; + Player.SetScreenshake(2f); SoundEngine.PlaySound(ShieldoftheOcean.TriggerSound, Player.Center); shieldOfTheOceanParry = ShieldoftheOcean.ParryTime; } @@ -3573,7 +3795,7 @@ namespace CalamityMod.CalPlayer if (Player.Calamity().SpeedBlasterDashStarted || (Player.dashDelay != 0 && (Player.Calamity().LastUsedDashID == SuperradiantSawDash.ID || Player.Calamity().LastUsedDashID == SpeedBlasterDash.ID))) { - Player.Calamity().DeferredDashID = Player.ActiveItem().type == ItemType() ? SuperradiantSawDash.ID : SpeedBlasterDash.ID; + Player.Calamity().DeferredDashID = Player.HeldItem.type == ItemType() ? SuperradiantSawDash.ID : SpeedBlasterDash.ID; Player.dash = 0; } @@ -3581,9 +3803,9 @@ namespace CalamityMod.CalPlayer if (CalamityKeybinds.RageHotKey.JustPressed) { // Gael's Greatsword replaces Rage Mode with an uber skull attack - if (!(Player.HasCooldown(Cooldowns.GaelsRage.ID)) && Player.ActiveItem().type == ItemType() && rage > 0f) + if (!(Player.HasCooldown(Cooldowns.GaelsRage.ID)) && Player.HeldItem.type == ItemType() && rage > 0f) { - SoundEngine.PlaySound(SilvaHeadSummon.DispelSound, Player.Center); + SoundEngine.PlaySound(SilvaArmor.DispelSound, Player.Center); for (int i = 0; i < 3; i++) Dust.NewDust(Player.position, 120, 120, DustID.Rain_BloodMoon, 0f, 0f, 100, default, 1.5f); @@ -3600,7 +3822,7 @@ namespace CalamityMod.CalPlayer } // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list - var source = Player.GetSource_ItemUse(Player.ActiveItem(), GaelsGreatsword.SkullsplosionEntitySourceContext); + var source = Player.GetSource_ItemUse(Player.HeldItem, GaelsGreatsword.SkullsplosionEntitySourceContext); float rageRatio = rage / rageMax; float baseDamage = rageRatio * GaelsGreatsword.SkullsplosionDamageMultiplier * GaelsGreatsword.BaseDamage; int damage = (int)Player.GetTotalDamage().ApplyTo(baseDamage); @@ -3718,20 +3940,48 @@ namespace CalamityMod.CalPlayer public override void ArmorSetBonusActivated() { // TODO -- It would be nice if triggerable set bonuses used interfaces instead of having to go through this large if chain. + if (victideBurrowSet) + { + if (cooldowns.TryGetValue(BubblyBurrow.ID, out CooldownInstance cd)) + { + // Return to normal if you have the ability active + if (cd.timeLeft > VictideHeadBurrow.BurrowCooldown) + { + cd.timeLeft = VictideHeadBurrow.BurrowCooldown + 1; + SyncCooldownDictionary(false); + } + } + else if (!Player.tongued && !Player.shimmering) + { + SoundEngine.PlaySound(SoundID.Item154, Player.Center); + if (Player.whoAmI == Main.myPlayer) + { + Player.AddCooldown(BubblyBurrow.ID, VictideHeadBurrow.BurrowCooldown + VictideHeadBurrow.BurrowDuration); + + var source = Player.GetSource_Misc("1"); + Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ProjectileType(), 0, 0f, Player.whoAmI); + } + } + } + if (victideBarrierSet && !Player.HasCooldown(WardingWave.ID)) + { + // Explosion and dash are handled in the VictideBarrier file + if (Player.whoAmI == Main.myPlayer) + Player.AddCooldown(WardingWave.ID, VictideHeadBarrier.BarrierCooldown); + } if (brimflameSet && !Player.HasCooldown(BrimflameFrenzy.ID)) { if (Player.whoAmI == Main.myPlayer) { if (brimflameFrenzy) { - brimflameFrenzy = false; Player.ClearBuff(BuffType()); + Player.AddCooldown(BrimflameFrenzy.ID, BrimflameCowl.FrenzyCooldown); } else { - brimflameFrenzy = true; - Player.AddBuff(BuffType(), 10 * 60, true); - SoundEngine.PlaySound(BrimflameScowl.ActivationSound, Player.Center); + Player.AddBuff(BuffType(), BrimflameCowl.FrenzyDuration, true); + SoundEngine.PlaySound(BrimflameCowl.ActivationSound, Player.Center); for (int i = 0; i < 36; i++) { Dust brimDust = Dust.NewDustDirect(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); @@ -3756,13 +4006,13 @@ namespace CalamityMod.CalPlayer { if (Player.whoAmI == Main.myPlayer) { - Player.AddBuff(BuffType(), 602, false); + Player.AddBuff(BuffType(), TarragonHeadMelee.CloakDuration, false); } } if (bloodflareRanged && !Player.HasCooldown(BloodflareRangedSet.ID)) { if (Player.whoAmI == Main.myPlayer) - Player.AddCooldown(BloodflareRangedSet.ID, 1800); + Player.AddCooldown(BloodflareRangedSet.ID, BloodflareHeadRanged.SoulCooldown); SoundEngine.PlaySound(BloodflareHeadRanged.ActivationSound, Player.Center); for (int d = 0; d < 64; d++) @@ -3786,8 +4036,8 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer) { var source = Player.GetSource_Misc("1"); - int damage = (int)(Player.GetTotalDamage().ApplyTo(300f)); - for (int i = 0; i < 16; i++) + int damage = (int)(Player.GetTotalDamage().ApplyTo(BloodflareHeadRanged.SoulDamage)); + for (int i = 0; i < BloodflareHeadRanged.SoulAmount; i++) { float ai1 = Main.rand.NextFloat() + 0.5f; Vector2 circleVel = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * Main.rand.NextFloat(5f, 8f); @@ -3801,9 +4051,9 @@ namespace CalamityMod.CalPlayer { if (Player.whoAmI == Main.myPlayer) { - Player.AddBuff(BuffType(), 300, false); + Player.AddBuff(BuffType(), OmegaBlueHelmet.MadnessDuration, false); } - Player.AddCooldown(OmegaBlue.ID, 1800); + Player.AddCooldown(OmegaBlue.ID, OmegaBlueHelmet.MadnessDuration + OmegaBlueHelmet.MadnessCooldown); SoundEngine.PlaySound(OmegaBlueHelmet.ActivationSound, Player.Center); for (int i = 0; i < 66; i++) { @@ -3836,26 +4086,26 @@ namespace CalamityMod.CalPlayer } if (Player.whoAmI == Main.myPlayer) { - Player.AddBuff(BuffType(), 600, false); + Player.AddBuff(BuffType(), DemonshadeHelm.EnrageDuration, false); } if (Main.netMode != NetmodeID.MultiplayerClient) { foreach (NPC npc in Main.ActiveNPCs) { if (!npc.friendly && !npc.dontTakeDamage && Vector2.Distance(Player.Center, npc.Center) <= 3000f) - npc.AddBuff(BuffType(), 600, false); + npc.AddBuff(BuffType(), DemonshadeHelm.EnrageDuration, false); } } } if (plagueReaper && !Player.HasCooldown(PlagueBlackout.ID)) { SoundEngine.PlaySound(PlagueReaperMask.ActivationSound, Player.Center); - Player.AddCooldown(PlagueBlackout.ID, 1800); + Player.AddCooldown(PlagueBlackout.ID, PlagueReaperMask.BlackoutDuration + PlagueReaperMask.BlackoutCooldown); } - if (forbiddenCirclet && forbiddenCooldown <= 0) + if (forbiddenCirclet && Player.ownedProjectileCounts[ProjectileType()] < 2) { - forbiddenCooldown = 45; - int stormMana = (int)(ForbiddenCirclet.manaCost * Player.manaCost); + forbiddenCooldown = ForbiddenCirclet.StormCooldown; + int stormMana = (int)(ForbiddenCirclet.StormManaCost * Player.manaCost); if (Player.statMana < stormMana) { if (Player.manaFlower) @@ -3865,26 +4115,83 @@ namespace CalamityMod.CalPlayer } if (Player.statMana >= stormMana && !Player.silence) { - var source = Player.GetSource_Misc("1"); + var source = Player.GetSource_ItemUse(FindAccessory()); Player.manaRegenDelay = (int)Player.maxRegenDelay; Player.statMana -= stormMana; // To compute Forbidden Circlet tornado damage, create a fake stat modifier on the spot which combines both classes. StatModifier forbidden = Player.GetTotalDamage().CombineWith(Player.GetDamage()); - int damage = (int)forbidden.ApplyTo(ForbiddenCirclet.tornadoBaseDmg); + int damage = (int)forbidden.ApplyTo(ForbiddenCirclet.StormDamage); - float kBack = Player.GetTotalKnockback().ApplyTo(ForbiddenCirclet.tornadoBaseKB); + float kBack = Player.GetTotalKnockback().ApplyTo(ForbiddenCirclet.StormKB); if (Player.whoAmI == Main.myPlayer) { - int mark = Projectile.NewProjectile(source, Player.ClampedMouseWorld(), Vector2.Zero, ProjectileType(), damage, kBack, Player.whoAmI); - if (mark.WithinBounds(Main.maxProjectiles)) - Main.projectile[mark].DamageType = DamageClass.Generic; + if (Player.ownedProjectileCounts[ProjectileType()] > 0) + { + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.owner != Player.whoAmI || proj.type != ProjectileType()) + continue; + proj.ai[0] = CircletTornado.Lifetime - CircletTornado.Fadetime + proj.ai[0] % 60f; + proj.netUpdate = true; + } + } + Vector2 tornadoPos = Player.ClampedMouseWorld(); + Projectile.NewProjectile(source, tornadoPos, Vector2.Zero, ProjectileType(), damage, kBack, Player.whoAmI); + + Vector2 diff = tornadoPos - Player.Center; + float distance = diff.Length(); + if (distance > 0f) + { + for (float i = 0f; i < distance; i += 15f) + { + Vector2 dustPos = Player.Center + diff * i / distance; + Dust trail = Dust.NewDustDirect(dustPos, 0, 0, DustID.Sandnado); + trail.position = dustPos; + trail.fadeIn = 0.5f; + trail.scale = 0.7f; + trail.velocity *= 0.4f; + trail.noLight = true; + } + } + for (int j = 0; j < 30; j++) + { + Dust cloud = Dust.NewDustDirect(tornadoPos, 0, 0, DustID.Sandnado); + cloud.position = tornadoPos; + cloud.fadeIn = 1f; + cloud.scale = 0.3f; + cloud.noLight = true; + } } } } if (prismaticSet && !Player.HasCooldown(PrismaticLaser.ID) && prismaticLasers <= 0) - prismaticLasers = CalamityUtils.SecondsToFrames(35f); + prismaticLasers = PrismaticHelmet.LaserDuration + PrismaticHelmet.LaserCooldown; + if (WulfrumHat.HasArmorSet(Player)) + { + //Only activate if no cooldown & available scrap. + if (cooldowns.TryGetValue(WulfrumBastion.ID, out CooldownInstance cd)) + { + // Quick dismount if activated again + if (cd.timeLeft > WulfrumHat.BastionCooldown && cd.timeLeft < WulfrumHat.BastionCooldown + WulfrumHat.BastionTime - 60 * 3) + { + cd.timeLeft = WulfrumHat.BastionCooldown + 1; + SyncCooldownDictionary(false); + } + } + + else if (Player.HasItem(ItemType())) + { + Player.ConsumeItem(ItemType()); + //I Thiiiinnnk there's no need to add mp syncing packets since cooldowns get auto synced right + Player.AddCooldown(WulfrumBastion.ID, WulfrumHat.BastionCooldown + WulfrumHat.BastionTime); + //Though do I need to sync that or is the player inventory auto synced? + WulfrumHat.DummyCannon.SetDefaults(ItemType()); + } + } + if (DesertProwlerHat.HasArmorSet(Player) && !Player.HasCooldown(SandsmokeBomb.ID)) + Player.AddCooldown(SandsmokeBomb.ID, DesertProwlerHat.SmokeCooldown + DesertProwlerHat.SmokeDuration); } #endregion @@ -3994,6 +4301,11 @@ namespace CalamityMod.CalPlayer // Putting this in GlobalItem will run multiple times for each slot, which this system already does, creating a slew of problems. VanillaArmorChangeManager.ApplyPotentialEffectsTo(Player); + // Nerf to the proc rate of Spectre Mask's set bonus souls + // Vanilla subtracts 6.6666665 from this counter per frame, this reduces it to 4 + if (Player.ghostDmg > 0) + Player.ghostDmg += 2.6666665f; + // If the config is enabled, vastly increase the player's base tile and wall placement speeds // This stacks with the Brick Layer and Portable Cement Mixer if (CalamityServerConfig.Instance.FasterTilePlacement) @@ -4004,100 +4316,59 @@ namespace CalamityMod.CalPlayer // Takes the movement speed bonus and uses it to increase run speed float accRunSpeedMin = Player.accRunSpeed * 0.5f; - Player.accRunSpeed += Player.accRunSpeed * moveSpeedBonus * 0.2f; + Player.accRunSpeed += Player.accRunSpeed * moveSpeedBonus * 0.16f; if (Player.accRunSpeed < accRunSpeedMin) Player.accRunSpeed = accRunSpeedMin; - //Life Jelly regen aura spawn when using a healing potion - if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && lifejelly && !GrandGelatin) - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ProjectileType(), 0, 0, Player.whoAmI); - - //Cleansing Jelly cleansing aura spawn when using a healing potion - if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && cleansingjelly && !GrandGelatin) - { - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ProjectileType(), 0, 0, Player.whoAmI); - } - //Grand Gellatin regen and cleansing aura spawn when using a healing potion - if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && GrandGelatin && !absorber) - { - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ProjectileType(), 0, 0, Player.whoAmI); - } - //Absorber's regen, cleansing, and buffing aura spawn when using a healing potion - if (timePotionSick == 1 && Player.whoAmI == Main.myPlayer && absorber) - { - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ProjectileType(), 0, 0, Player.whoAmI); - } - - if (snowman) + if (Player.Transformation().Type == ItemType()) { if (Player.whoAmI == Main.myPlayer && !snowmanNoseless) Player.AddBuff(BuffType(), 60, true); } - if (abyssalDivingSuit) - { - Player.AddBuff(BuffType(), 60, true); - if (Player.whoAmI == Main.myPlayer && !Player.HasCooldown(DivingPlatesBroken.ID)) - { - Player.AddBuff(BuffType(), 2); - } - if (Player.whoAmI == Main.myPlayer && Player.active && abyssalDivingSuitPlateHits < 3) - { - if (!Player.HasCooldown(DivingPlatesBreaking.ID)) - { - CooldownInstance plates = Player.AddCooldown(DivingPlatesBreaking.ID, 3); - plates.timeLeft = abyssalDivingSuitPlateHits; - } - else - { - CooldownInstance plates = cooldowns[DivingPlatesBreaking.ID]; - plates.timeLeft = abyssalDivingSuitPlateHits; - } - } - } + if (abyssalDivingSuit) + Player.AddBuff(BuffType(), 60, true); if (aquaticHeart) - { Player.AddBuff(BuffType(), 60, true); - } + if (aquaticHeart && NPC.downedBoss3) { if (Player.whoAmI == Main.myPlayer && !Player.HasCooldown(AquaticHeartIceShield.ID)) - { Player.AddBuff(BuffType(), 2); - } } + if (profanedCrystal) - { Player.AddBuff(BuffType(), 60, true); - } + if (gSabaton) { if (Player.whoAmI == Main.myPlayer) { - // While holding hotkey, but before slam, bring Y velocity closer to 0 - if (gSabatonHotkeyHoldTime < 30 && gSabatonHotkeyHoldTime != 0 && !gSabatonFalling) - { - Player.velocity.Y *= (60 - (gSabatonHotkeyHoldTime / 2f)) / 60f; - } + // While preparing slam, bring Y velocity closer to 0 + if (gSabatonHotkeyFallWindup < 20 && gSabatonHotkeyFallWindup != 0 && !gSabatonFalling) + Player.velocity.Y *= (60 - (gSabatonHotkeyFallWindup * 0.75f)) / 60f; + // Play sound a bit early so it goes in time with the fall - if (gSabatonHotkeyHoldTime == 15 && !gSabatonFalling) - { - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/GravistarCharge") { Volume = 0.3f }); - } + if (gSabatonHotkeyFallWindup == 5 && !gSabatonFalling) + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/GravistarCharge") { Volume = 0.3f }); + // 0.5 seconds passed, falling time - if (gSabatonHotkeyHoldTime == 30) + if (gSabatonHotkeyFallWindup == 20) { gSabatonFalling = true; Player.velocity.Y = 0.01f; } + // Cancel fall and don't give 'on ground' effects if on rope, on mount, grappled, or tongued // Also cancel fall if the player has upwards Y velocity (Goodbye Inner Tube cheese) if ((Player.gravDir == 1 && Player.velocity.Y < 0f) || (Player.gravDir == -1 && Player.velocity.Y > 1f) || Player.pulley || Player.mount.Active || Player.grappling[0] != -1 || Player.tongued) { gSabatonFall = 0; gSabatonFalling = false; + gSabatonHotkeyFallWindup = -1; } + if (gSabatonFalling) { SpawnGravistarParticle(); @@ -4108,20 +4379,23 @@ namespace CalamityMod.CalPlayer Player.maxFallSpeed = 40f; Player.gravity = 1.3f; + // If the player can fly during the fall, the physics gets a bit funky Player.controlJump = false; // Check if player hit some form of solid resistance (the ground) - if (Player.oldVelocity.Y == Player.velocity.Y) + if (0 == Player.velocity.Y) { - var source = Player.GetSource_Accessory(FindAccessory(ItemType())); - //Spawn explosion. ai[0] is used for transferring the recorded falling time + var source = Player.GetSource_Accessory(FindAccessory()); + // Spawn explosion. ai[0] is used for transferring the recorded falling time int damage = Player.CalcIntDamage(InterstellarStompers.SlamDamage); Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ProjectileType(), damage, 4f, Player.whoAmI, gSabatonFall); gSabatonFall = 0; gSabatonFalling = false; + gSabatonHotkeyFallWindup = -1; + // Temporary jump speed is granted for 40 frames gSabatonTempJumpSpeed = 40; } @@ -4132,17 +4406,21 @@ namespace CalamityMod.CalPlayer { gSabatonFall = 0; gSabatonFalling = false; + gSabatonHotkeyFallWindup = -1; } // Reset The Evolution's same projectile DR if unequipped or the cooldown ends if (!evolution || !Player.HasCooldown(GlobalDodge.ID)) projTypeJustHitBy = -1; - } + } #endregion #region PreUpdate public override void PreUpdate() { + // Increment the universal frame timer. + ++universalFrameTimer; + //Infinite flight granted by some boss attacks if (infiniteFlight) Player.wingTime = Player.wingTimeMax; @@ -4182,24 +4460,28 @@ namespace CalamityMod.CalPlayer if (Main.myPlayer == Player.whoAmI) { mouseRight = PlayerInput.Triggers.Current.MouseRight; - mouseWorld = Main.MouseWorld; + var worldPos = LockOnHelper.Enabled ? LockOnHelper.PredictedPosition : Main.MouseWorld; + mouseWorldDeltaFromPlayer = worldPos - Player.MountedCenter; + mouseRotationFromPlayer = mouseWorldDeltaFromPlayer.ToRotation(); if (rightClickListener && mouseRight != oldMouseRight) { oldMouseRight = mouseRight; - syncMouseControls = true; + syncMouseRightClick = true; rightClickListener = false; } - if (mouseWorldListener && Vector2.Distance(mouseWorld, oldMouseWorld) > 5f) + + if (mouseWorldListener && Vector2.Distance(mouseWorldDeltaFromPlayer, oldMouseWorldDeltaFromPlayer) > 5f) { - oldMouseWorld = mouseWorld; - syncMouseControls = true; + oldMouseWorldDeltaFromPlayer = mouseWorldDeltaFromPlayer; + syncMousePosition = true; mouseWorldListener = false; } - if (mouseRotationListener && Math.Abs((mouseWorld - Player.MountedCenter).ToRotation() - (oldMouseWorld - Player.MountedCenter).ToRotation()) > 0.15f) + + if (mouseRotationListener && Math.Abs((mouseWorldDeltaFromPlayer).ToRotation() - (oldMouseWorldDeltaFromPlayer).ToRotation()) > 0.15f) { - oldMouseWorld = mouseWorld; - syncMouseControls = true; + oldMouseWorldDeltaFromPlayer = mouseWorldDeltaFromPlayer; + syncMouseRotation = true; mouseRotationListener = false; } } @@ -4214,12 +4496,53 @@ namespace CalamityMod.CalPlayer { Player.ClearBuff(BuffID.WindPushed); } + if (Player.statMana < 0) + { + Player.AddBuff(BuffType(), 10); + } + else if (Player.HasBuff(BuffType())) + { + Player.ClearBuff(BuffType()); + } + } + #endregion + + #region OnExtraJumpStarted + public override void OnExtraJumpStarted(ExtraJump jump, ref bool playSound) + { + if (rainSet && Player.whoAmI == Main.myPlayer) + { + RainArmorSetChange.SpawnRainArmorJump(Player); + } } #endregion #region PreUpdateMovement public override void PreUpdateMovement() { + + // Rain armor set effects + if (rainSet) + { + if (Player.justJumped && Player.whoAmI == Main.myPlayer) + { + RainArmorSetChange.SpawnRainArmorJump(Player); + } + } + + //Multiply vertical speed + if (redWine) + { + if (Player.velocity.Y > 0.2f || Player.velocity.Y < -0.2f) + { + redWineStoredY = Player.velocity.Y; + Player.velocity.Y *= 1 + RedWine.VerticalSpeedBoost; + } + else + { + redWineStoredY = 0; + } + } // Remove acceleration when using the exo chair. if (Player.whoAmI == Main.myPlayer && ExoChair) { @@ -4253,6 +4576,158 @@ namespace CalamityMod.CalPlayer if (CalamityKeybinds.ExoChairSlowdownHotkey.Current) Player.velocity *= 0.5f; } + + foreach (var npc in Main.ActiveNPCs) + { + //This is the ravager rock pillar collision logic. It should only apply to rock pillars that are mostly opaque to ensure players don't get stopped by invisible pillars right when they spawn. + //This could also potentially be limited to only run with the pillar is stationary if desired. + if (npc.type == ModContent.NPCType() && npc.Opacity > 0.9f && npc.damage < 1) + { + bool LandedOnPlayer = false; + float origX = Player.velocity.X; + float origY = Player.velocity.Y; + npc.position += npc.velocity; + bool intersectPreVel = false; + Player.position += Player.velocity; + + if (Player.Hitbox.Intersects(npc.Hitbox)) + intersectPreVel = true; + Player.position -= Player.velocity; + if (intersectPreVel) + { + Player.position += npc.velocity; + if (Collision.SolidCollision(Player.position, Player.Hitbox.Width, Player.Hitbox.Height) || Main.npc.Any(x => x.active && x.type == ModContent.NPCType() && x.Opacity > 0.9f && x.whoAmI != npc.whoAmI && x.Hitbox.Intersects(Player.Hitbox))) + { + npc.damage = npc.defDamage; + npc.ai[0] = 1; + LandedOnPlayer = true; + Player.position -= npc.velocity; + } + } + npc.position -= npc.velocity; + + if (!LandedOnPlayer) + { + //Yes, testing intercepts on th X, Y, and X+Y individually has a purpose. It makes it far more stable and consistent. + bool intersectX = false; + Player.position.X += Player.velocity.X; + if (Player.Hitbox.Intersects(npc.Hitbox)) + intersectX = true; + Player.position.X -= Player.velocity.X; + bool intersectY = false; + Player.position.Y += Player.velocity.Y; + if (Player.Hitbox.Intersects(npc.Hitbox)) + intersectY = true; + Player.position.Y -= Player.velocity.Y; + bool intersect = false; + //We only bother checking the X+Y together if individually they return false. + //This accounts for moving diagonal onto a corner. + if (!intersectX && !intersectY) + { + Player.position += Player.velocity; + if (Player.Hitbox.Intersects(npc.Hitbox)) + intersect = true; + Player.position -= Player.velocity; + } + if (intersectX || intersect) + { + //This checks if the player is to the left of the pillar + if (Player.Center.X < npc.Center.X) + { + float playerEdge = Player.Hitbox.X + Player.Hitbox.Width; + float pillarEdge = npc.Hitbox.X; + float goalEdge = playerEdge + Player.velocity.X; + if (goalEdge > pillarEdge) + { + Player.velocity.X += pillarEdge - goalEdge; + if (Player.velocity.X < 0) + if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height)) + { + Player.position.X += Player.velocity.X; + Player.velocity.X = 0; + } + else + { + Player.velocity.X = origX; + } + } + } + //This is for if the player is to the right of the pillar + else + { + float playerEdge = Player.Hitbox.X; + float pillarEdge = npc.Hitbox.X + npc.Hitbox.Width; + float goalEdge = playerEdge + Player.velocity.X; + if (goalEdge < pillarEdge) + { + Player.velocity.X += pillarEdge - goalEdge; + if (Player.velocity.X > 0) + if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height)) + { + Player.position.X += Player.velocity.X; + Player.velocity.X = 0; + } + else + { + Player.velocity.X = origX; + } + } + } + } + //For the vertical axis, we don't distinguish between top and bottom, and always move players to the top + //This is so being placed inside a pillar teleports a player to the top, which applies primarily to teleporting or pillar spawning + //Additionally, this is set to only work when the pillar is stationary vertically to prevent janky interations when pillars are moving. + if ((intersectY || intersect)) + { + if (Player.Center.Y < npc.Center.Y) + { + float playerEdge = Player.Hitbox.Y + Player.Hitbox.Height; + float pillarEdge = npc.Hitbox.Y; + float goalEdge = playerEdge + Player.velocity.Y; + if (goalEdge > pillarEdge) + { + Player.velocity.Y += pillarEdge - goalEdge; + if (Player.velocity.Y < 0) + if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height)) + { + Player.position.Y += Player.velocity.Y; + Player.velocity.Y = 0; + } + else + { + Player.velocity.Y = origY; + } + } + } + else + { + float playerEdge = Player.Hitbox.Y; + float pillarEdge = npc.Hitbox.Y + npc.Hitbox.Height; + float goalEdge = playerEdge + Player.velocity.Y; + if (goalEdge < pillarEdge) + { + Player.velocity.Y += pillarEdge - goalEdge; + if (Player.velocity.Y > 0) + if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height)) + { + Player.position.Y += Player.velocity.Y; + Player.velocity.Y = 0; + } + else + { + Player.velocity.Y = origY; + } + } + } + } + //This is to guarantee we can stand on top of rock pillars instead of looking like we're "floating" on top of them. + if (intersectY && Player.velocity.Y < 0.25f && Player.velocity.Y > -0.25f) + { + Player.velocity.Y = 0; + } + } + } + } } #endregion @@ -4261,20 +4736,6 @@ namespace CalamityMod.CalPlayer { if (Player.whoAmI == Main.myPlayer && CalamityClientConfig.Instance.VanillaCooldownDisplay) { - if (Player.whoAmI == Main.myPlayer && Player.potionDelay != 0) - potionSick = true; - else - potionSick = false; - - if (!potionSick) - timePotionSick = 0; - else - timePotionSick++; - - // Add a cooldown display for potion sickness if the player has the vanilla counter ticking - if (potionSick && !Player.HasCooldown(PotionSickness.ID)) - Player.AddCooldown(PotionSickness.ID, Player.potionDelay, false); - if (cooldowns.TryGetValue(PotionSickness.ID, out CooldownInstance cd)) { if (Player.potionDelay != cd.timeLeft && cd.timeLeft > 0) @@ -4283,6 +4744,8 @@ namespace CalamityMod.CalPlayer if (cd.timeLeft > cd.duration) cd.duration = cd.timeLeft; // If the new cooldown is larger than the full duration, update, else keep it the same. } + else if (Player.whoAmI == Main.myPlayer && Player.potionDelay > 0) + Player.AddCooldown(PotionSickness.ID, Player.potionDelay, false); // Add a cooldown display for chaos state if the player has the vanilla counter ticking // This will make the cooldown look like vanilla Rod of Discord, as it wasn't applied by either Normality Relocator or Spectral Veil @@ -4303,15 +4766,7 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer) { float baseRecoveryRate = Main.expertMode ? BalancingConstants.LifeStealRecoveryRate_Expert : BalancingConstants.LifeStealRecoveryRate_Classic; - - float lifeStealRecoveryRateReduction = - CalamityWorld.death ? BalancingConstants.LifeStealRecoveryRateReduction_Death : - CalamityWorld.revenge ? BalancingConstants.LifeStealRecoveryRateReduction_Revengeance : - Main.expertMode ? BalancingConstants.LifeStealRecoveryRateReduction_Expert : - BalancingConstants.LifeStealRecoveryRateReduction_Classic; - - if (Main.masterMode) - lifeStealRecoveryRateReduction += BalancingConstants.LifeStealRecoveryRateReduction_Master; + float lifeStealRecoveryRateReduction = Main.expertMode ? BalancingConstants.LifeStealRecoveryRateReduction_Expert : BalancingConstants.LifeStealRecoveryRateReduction_Classic; float lifeStealRecoveryRate = baseRecoveryRate - lifeStealRecoveryRateReduction; if (Player.lifeSteal < -lifeStealRecoveryRate) @@ -4321,7 +4776,8 @@ namespace CalamityMod.CalPlayer Player.AddCooldown(LifeSteal.ID, duration); } } - + if (moonshine) + Player.statLifeMax2 = (int)(Player.statLifeMax2 * (1 + Moonshine.MaxLifePercentBoost)); ForceVariousEffects(); } #endregion @@ -4329,6 +4785,104 @@ namespace CalamityMod.CalPlayer #region PostUpdateEquips public override void PostUpdateEquips() { + + var item = Player.HeldItem; + if (!(item.IsAir || item.damage <= 0)) + { + if (item.DamageType.CountsAsClass(DamageClass.Melee)) + { + TimeHoldingMelee++; + if (TimeHoldingMelee > Whiskey.TimeToDischarge) + TimeHoldingMelee = (int)Whiskey.TimeToDischarge; + if (whiskey) + { + Player.GetDamage(DamageClass.Melee) += MathHelper.Lerp(Whiskey.MaxDamageBoost, Whiskey.MinDamageBoost, TimeHoldingMelee / Whiskey.TimeToDischarge); + } + } else + { + TimeHoldingMelee -= 2; + if (TimeHoldingMelee < 0) + TimeHoldingMelee = 0; + } + if (item.DamageType.CountsAsClass(DamageClass.Ranged)) + { + TimeHoldingRanged++; + if (TimeHoldingRanged > Whiskey.TimeToDischarge) + TimeHoldingRanged = (int)Whiskey.TimeToDischarge; + if (whiskey) + { + Player.GetDamage(DamageClass.Ranged) += MathHelper.Lerp(Whiskey.MaxDamageBoost, Whiskey.MinDamageBoost, TimeHoldingRanged / Whiskey.TimeToDischarge); + } + } + else + { + TimeHoldingRanged -= 2; + if (TimeHoldingRanged < 0) + TimeHoldingRanged = 0; + } + if (item.DamageType.CountsAsClass(DamageClass.Magic)) + { + TimeHoldingMagic++; + if (TimeHoldingMagic > Whiskey.TimeToDischarge) + TimeHoldingMagic = (int)Whiskey.TimeToDischarge; + if (whiskey) + { + Player.GetDamage(DamageClass.Magic) += MathHelper.Lerp(Whiskey.MaxDamageBoost, Whiskey.MinDamageBoost, TimeHoldingMagic / Whiskey.TimeToDischarge); + } + } + else + { + TimeHoldingMagic -= 2; + if (TimeHoldingMagic < 0) + TimeHoldingMagic = 0; + } + if (item.DamageType.CountsAsClass(DamageClass.Summon)) + { + TimeHoldingSummon++; + if (TimeHoldingSummon > Whiskey.TimeToDischarge) + TimeHoldingSummon = (int)Whiskey.TimeToDischarge; + if (whiskey) + { + Player.GetDamage(DamageClass.Summon) += MathHelper.Lerp(Whiskey.MaxDamageBoost, Whiskey.MinDamageBoost, TimeHoldingSummon / Whiskey.TimeToDischarge); + } + } + else + { + TimeHoldingSummon -= 2; + if (TimeHoldingSummon < 0) + TimeHoldingSummon = 0; + } + if (item.DamageType.CountsAsClass(RogueDamageClass.Instance)) + { + TimeHoldingRogue++; + if (TimeHoldingRogue > Whiskey.TimeToDischarge) + TimeHoldingRogue = (int)Whiskey.TimeToDischarge; + if (whiskey) + { + Player.GetDamage(RogueDamageClass.Instance) += MathHelper.Lerp(Whiskey.MaxDamageBoost, Whiskey.MinDamageBoost, TimeHoldingRogue / Whiskey.TimeToDischarge); + } + } + else + { + TimeHoldingRogue -= 2; + if (TimeHoldingRogue < 0) + TimeHoldingRogue = 0; + } + } else + { + if (TimeHoldingMelee-- < 0) + TimeHoldingMelee = 0; + if (TimeHoldingRanged-- < 0) + TimeHoldingRanged = 0; + if (TimeHoldingMagic-- < 0) + TimeHoldingMagic = 0; + if (TimeHoldingSummon-- < 0) + TimeHoldingSummon = 0; + if (TimeHoldingRogue-- < 0) + TimeHoldingRogue = 0; + } + + // PostUpdateMiscEffects runs after the cap has been applied. Do NOT put mining speed stuff there. // Ancient Chisel nerf (also affects Hand of Creation) if (Player.chiselSpeed) @@ -4356,6 +4910,30 @@ namespace CalamityMod.CalPlayer Lighting.AddLight(Player.Center, Light * (0.55f + (oceanCrestTimer * 0.0035f))); } + if (rampartOfDeities) + { + // Ice Barrier buff inherited from Frozen Turtle Shell + if (Player.statLife <= Player.statLifeMax2 * 0.5) + Player.AddBuff(BuffID.IceBarrier, 5); + + // Paladin's Shield application + if (Player.statLife > Player.statLifeMax2 * 0.25f) + { + Player.hasPaladinShield = true; + if (Player.whoAmI != Main.myPlayer && Player.miscCounter % 10 == 0) + { + var localPlayer = Main.LocalPlayer; + if (localPlayer.team == Player.team && Player.team != 0) + { + float teamPlayerXDist = Player.position.X - localPlayer.position.X; + float teamPlayerYDist = Player.position.Y - localPlayer.position.Y; + if ((float)Math.Sqrt(teamPlayerXDist * teamPlayerXDist + teamPlayerYDist * teamPlayerYDist) < 800f) + localPlayer.AddBuff(BuffID.PaladinsShield, 20); + } + } + } + } + // True melee damage from various vanilla equipment placed here. // Titan Glove and ALL upgrades. @@ -4386,43 +4964,140 @@ namespace CalamityMod.CalPlayer #endregion + public override void PostUpdate() + { + if (ZoneAbyss && Main.netMode != NetmodeID.Server) + { + //Main aura + EnhancedDarknessSystem.lights.Add(new(center: Player.Center, scale: 4 * abyssPlayerGlowMultiplier)); + + //Flashlight + //Due to being in postUpdate we need to adjust the mousepos for the player's movement that will have happened + var mouseworld = Main.MouseWorld + Player.position - Player.oldPosition; + EnhancedDarknessSystem.lights.Add(new(center: Player.Center + Player.DirectionTo(mouseworld) * 750f, rotation: Player.DirectionTo(mouseworld).ToRotation() - MathHelper.PiOver2, vectorScale: new Vector2(0.85f * abyssFlashlightWidthMultiplier, 0.75f), texture: Request("CalamityMod/Particles/BloomLineFade").Value)); + } + + if (lastDeerclopsPosition.HasValue) + { + //While deer is alive and the player is nearby, make it dark + if (Main.npc.Any(x => x.active && x.type == NPCID.Deerclops) && Player.DistanceSQ(lastDeerclopsPosition.Value) < 10240000) //3200^2, or 00 tiles + { + darknessIntensity = MathHelper.Min(Main.LocalPlayer.Calamity().darknessIntensity + 0.06f, 1f); ; + } + + //Add the main light circle for the arena + DeerclopsAI.ArenaTex ??= ModContent.Request(DeerclopsAI.ArenaTexPath); + EnhancedDarknessSystem.lights.Add(new(lastDeerclopsPosition.Value, scale: DeerclopsAI.borderScale, texture: DeerclopsAI.ArenaTex.Value)); + + //we draw light around the player when far away so they have some visibility, although very small. This is especially nice in multiplayer. we scale opacity with distance bc it looks better + EnhancedDarknessSystem.lights.Add(new EnhancedDarknessSystem.LightSource(scale: 0.75f, opacity: MathHelper.Clamp(Main.LocalPlayer.DistanceSQ(lastDeerclopsPosition.Value) / (409600 /*640^2*/), 0, 1))); + + if (darknessIntensity == 0) + { + lastDeerclopsPosition = null; + } + } + + //reset the stored Y value for red wine's increased vertical speed + if (redWine && (redWineStoredY > 0.2f || redWineStoredY < -0.2f) && (Player.velocity.Y > 0.2f || Player.velocity.Y < -0.2f)) + { + Player.velocity.Y = redWineStoredY; + } + + + if (subtitletext != null) + { + if (!subtitletext.active) + { + subtitletext = null; + } + else + { + subtitletext.position = Player.Center + new Vector2(-FontAssets.CombatText[subtitletext.crit ? 1 : 0].Value.MeasureString(subtitletext.text).X * 0.5f, 64); + subtitletext.color = Color.Lerp(subtitleColors[1], subtitleColors[0], subtitletext.lifeTime / 120f); + } + } + + // Relic of Convergence defense cut + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.HeldItem.type == ModContent.ItemType()) + Player.statDefense *= RelicOfConvergence.DefenseMultiplier; + + #region Managing time control + if (Main.netMode != NetmodeID.Server && Player == Main.LocalPlayer) + { + var power = CreativePowerManager.Instance.GetPower(); + double dayrate = CreativePowerManager.Instance.GetPower().TargetTimeRate; + if (CurrentFrameFlags.SleepingPlayersCount == CurrentFrameFlags.ActivePlayersCount && CurrentFrameFlags.SleepingPlayersCount > 0) + dayrate *= 5; + if (Main.IsFastForwardingTime()) + dayrate = 60; + double tileUpdate = 1; + double eventUpdate = 1; + SystemLoader.ModifyTimeRate(ref dayrate, ref tileUpdate, ref eventUpdate); + if (WeakTimeFreezeInUse) + { + if (!power.Enabled) + WeakTimeFreezeInUse = false; + else + { + if (WeakTimeFreezeUseTimer >= Bakidon.FreezeTime / Bakidon.RechargeMultiplier || Main.bloodMoon || Main.eclipse || Main.pumpkinMoon || Main.snowMoon) + { + + NetPacket packet = NetCreativePowersModule.PreparePacket(power.PowerId, 1); + packet.Writer.Write(false); + NetManager.Instance.SendToServerOrLoopback(packet); + WeakTimeFreezeInUse = false; + } + WeakTimeFreezeUseTimer += 1 * (float)dayrate; + } + } + else + { + if (WeakTimeFreezeUseTimer > 0) + WeakTimeFreezeUseTimer -= 1 * (float)dayrate; + else + WeakTimeFreezeUseTimer = 0; + } + } + #endregion + } public override void PostUpdateRunSpeeds() { #region SpeedBoosts if (!Player.mount.Active) { float runAccMult = 1f + - (lunicCorpsLegs ? 0.1f : 0f) + - (shadowSpeed ? 0.5f : 0f) + + (victideBurrowHead ? VictideHeadBurrow.MoveSpeedAccelerationBoost : 0f) + + (lunicCorpsLegs ? LunicCorpsBoots.MoveSpeedAccelerationBoost : 0f) + + (shadowSpeed ? DemonshadeGreaves.AccelerationBoost : 0f) + (stressPills ? 0.05f : 0f) + ((abyssalDivingSuit && Player.IsUnderwater()) ? 0.05f : 0f) + (aquaticHeartWaterBuff ? AquaticHeart.WaterSpeedBoost : 0f) + (laudanum && Player.HasBuff(BuffID.VortexDebuff) ? 0.15f : 0f) + ((frostFlare && Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) ? 0.15f : 0f) + (dragonScales ? 0.1f : 0f) + - (kamiBoost ? YanmeisKnife.RunAccelerationBoost : 0f) + (CobaltSet ? CobaltArmorSetChange.SpeedBoostSetBonusPercentage * 0.01f : 0f) + - (silvaSet ? 0.05f : 0f) + + (silvaSet ? SilvaArmor.AccelerationBoost : 0f) + (getSandCloakAccelBoost ? 0.75f : 0f) + - (nimbleBounderBoost ? NimbleBounder.AccelerationBoost : 0f) + - (ascendantInsignia ? 0.25f : 0f ) + // Added to Soaring Insignia's 1.25x multiplier to get 1.5x + (ascendantInsignia ? (AscendantInsignia.AccelerationBoost - 0.25f) : 0f) + // Subtracted 0.25 provided by Soaring Insignia + (statisNinjaBelt ? 0.6f : 0f) + + (statisVoidSash ? 0.85f : 0f) + (blueCandle ? WeightlessCandle.AccelerationBoost : 0f) + (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + //(exaltedKillMode ? 7f : devilsDevastationKillMode ? 11f : 0) + (hasteLevel * 0.05f); float runSpeedMult = 1f + - (lunicCorpsLegs ? 0.1f : 0f) + - (shadowSpeed ? 0.5f : 0f) + + (victideBurrowHead ? VictideHeadBurrow.MoveSpeedAccelerationBoost : 0f) + + (lunicCorpsLegs ? LunicCorpsBoots.MoveSpeedAccelerationBoost : 0f) + + (shadowSpeed ? DemonshadeGreaves.AccelerationBoost : 0f) + (stressPills ? 0.05f : 0f) + ((abyssalDivingSuit && Player.IsUnderwater()) ? 0.05f : 0f) + (aquaticHeartWaterBuff ? AquaticHeart.WaterSpeedBoost : 0f) + ((frostFlare && Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) ? 0.15f : 0f) + (dragonScales ? 0.1f : 0f) + - (kamiBoost ? YanmeisKnife.RunSpeedBoost : 0f) + (CobaltSet ? CobaltArmorSetChange.SpeedBoostSetBonusPercentage * 0.01f : 0f) + - (silvaSet ? 0.05f : 0f) + - (nimbleBounderBoost ? NimbleBounder.AccelerationBoost : 0f) + + (silvaSet ? SilvaArmor.AccelerationBoost : 0f) + (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + //(exaltedKillMode ? 0.4f : devilsDevastationKillMode ? 0.7f : 0) + (hasteLevel * 0.05f); @@ -4443,6 +5118,12 @@ namespace CalamityMod.CalPlayer else momentumCapacitorBoost = 0f; + if (victideBarrierHead) + { + Player.runAcceleration *= VictideHeadBarrier.RunAccelerationMult; + Player.runSlowdown *= VictideHeadBarrier.RunAccelerationMult; + } + Player.runAcceleration *= runAccMult; Player.maxRunSpeed *= runSpeedMult; } @@ -4467,6 +5148,8 @@ namespace CalamityMod.CalPlayer ModDashMovement(); } #endregion + + Player.oldVelocity = Player.velocity; // Apparently this value is not updated on its own, so we do it } #endregion @@ -4484,19 +5167,21 @@ namespace CalamityMod.CalPlayer public override void GetHealLife(Item item, bool quickHeal, ref int healValue) { healValue = (int)(healValue * healingPotionMultiplier); + if (bloomStone) + healValue = 0; } #endregion #region Get Weapon Damage And KB public override void ModifyWeaponDamage(Item item, ref StatModifier damage) { - if (item.CountsAsClass()) + if (item.CountsAsClass() && item.TryGetGlobalItem(out var rogueItem)) { // Apply weapon modifier stealth strike damage bonus // 01OCT2023: Ozzatron: This is a multiplicative bonus because it is a prefix. // It should be equivalent to x1.15 (or whatever multiplier) on the base damage of the weapon for stealth only. - if (item.Calamity().StealthStrikePrefixBonus != 0f && StealthStrikeAvailable()) - damage *= item.Calamity().StealthStrikePrefixBonus; // This number centers on 1f, so 1.15f = 1.15x damage. + if (rogueItem.StealthStrikePrefixBonus != 0f && StealthStrikeAvailable()) + damage *= rogueItem.StealthStrikePrefixBonus; // This number centers on 1f, so 1.15f = 1.15x damage. } } @@ -4505,32 +5190,14 @@ namespace CalamityMod.CalPlayer // Adding to StatModifier adds to the additive multiplier bool rogue = item.CountsAsClass(); - if (whiskey) - knockback += Whiskey.KnockbackBoost; - - if (tequila && Main.dayTime) - knockback += Tequila.KnockbackBoost; - - if (tequilaSunrise && Main.dayTime) - knockback += TequilaSunrise.KnockbackBoost; - if (moscowMule) knockback += MoscowMule.KnockbackBoost; - if (titanHeartMask && rogue) - knockback += 0.05f; - if (titanHeartMantle && rogue) - knockback += 0.05f; - - if (titanHeartBoots && rogue) - knockback += 0.05f; - - if (titanHeartSet && rogue) - knockback += 0.2f; + knockback += TitanHeartMantle.RogueKnockbackBoost; if (titanHeartSet && StealthStrikeAvailable() && rogue) - knockback += 1f; + knockback *= TitanHeartMask.StealthStrikeKnockbackMult; } #endregion @@ -4544,7 +5211,7 @@ namespace CalamityMod.CalPlayer #region Modify Mana Cost public override void ModifyManaCost(Item item, ref float reduce, ref float mult) { - if (MagicGunIDList.Includes(item.type) && meteorSet) + if (CalamityItemSets.MagicGun[item.type] && meteorSet) { mult *= 0.33f; } @@ -4703,13 +5370,19 @@ namespace CalamityMod.CalPlayer { if (bladeArmEnchant) return false; - + if (purpleHaze) + { + if (item.CountsAsClass() && StealthStrikeAvailable()) + { + purpleHazeStealthTimer = 300; + } + } if (veneratedLocket) { - var LocketSource = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + var LocketSource = Player.GetSource_Accessory(FindAccessory()); if (item.CountsAsClass()) { - if (!VeneratedLocketBanList.Includes(item.type)) + if (!CalamityItemSets.DisablesVeneratedLocketEffect[item.type]) { float veneratedCloneSpeed = item.shootSpeed; Vector2 realPlayerPos = Player.RotatedRelativePoint(Player.MountedCenter, true); @@ -4789,26 +5462,6 @@ namespace CalamityMod.CalPlayer } } } - - if (RustyMedallionDroplets && RustyMedallionCooldown <= 0) - { - if (item.CountsAsClass()) - { - var MedallionSource = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - int d = (int)Player.GetTotalDamage().ApplyTo(RustyMedallion.AcidDropBaseDamage); - - Vector2 mouse = Player.ClampedMouseWorld(); - Vector2 startingPosition = mouse - Vector2.UnitY.RotatedByRandom(0.3f) * 1250f; - Vector2 directionToMouse = (mouse - startingPosition).SafeNormalize(Vector2.UnitX); - int drop = Projectile.NewProjectile(MedallionSource, startingPosition, directionToMouse * 15f, ProjectileType(), d, 0f, Player.whoAmI, 3); - if (drop.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[drop].penetrate = 2; - Main.projectile[drop].DamageType = DamageClass.Generic; - } - RustyMedallionCooldown = RustyMedallion.AcidCreationCooldown; - } - } return true; } #endregion @@ -4821,59 +5474,26 @@ namespace CalamityMod.CalPlayer if (Player.isDisplayDollOrInanimate) { // Body - if (Player.armor[1].type == ModContent.ItemType()) + if (Player.armor[1].type == ItemType()) Player.body = EquipLoader.GetEquipSlot(Mod, "AuricTeslaBodyArmor", EquipType.Body); - else if (Player.armor[1].type == ModContent.ItemType()) + else if (Player.armor[1].type == ItemType()) Player.body = EquipLoader.GetEquipSlot(Mod, "DaedalusBreastplate", EquipType.Body); - else if (Player.armor[1].type == ModContent.ItemType()) + else if (Player.armor[1].type == ItemType()) Player.body = EquipLoader.GetEquipSlot(Mod, "EmpyreanCloak", EquipType.Body); - else if (Player.armor[1].type == ModContent.ItemType()) + else if (Player.armor[1].type == ItemType()) Player.body = EquipLoader.GetEquipSlot(Mod, "SnowRuffianChestplate", EquipType.Body); - else if (Player.armor[1].type == ModContent.ItemType()) + else if (Player.armor[1].type == ItemType()) Player.body = EquipLoader.GetEquipSlot(Mod, "VictideBreastplate", EquipType.Body); // Legs - if (Player.armor[2].type == ModContent.ItemType()) + if (Player.armor[2].type == ItemType()) Player.legs = EquipLoader.GetEquipSlot(Mod, "VictideGreaves", EquipType.Legs); // Set Bonus - if (Player.armor[0].type == ModContent.ItemType() - && Player.armor[1].type == ModContent.ItemType() - && Player.armor[2].type == ModContent.ItemType()) + if (Player.armor[0].type == ItemType() + && Player.armor[1].type == ItemType() + && Player.armor[2].type == ItemType()) snowRuffianSet = true; - - // Accessories - for (int i = 3; i < 8; i++) - { - Item vanity = Player.armor[i]; - - if (vanity.type == ModContent.ItemType()) - Player.GetModPlayer().transformationActive = true; - if (vanity.type == ModContent.ItemType()) - abyssalDivingSuitForce = true; - if (vanity.type == ModContent.ItemType()) - aquaticHeartForce = true; - if (vanity.type == ModContent.ItemType()) - Player.GetModPlayer().vanityEquipped = true; - if (vanity.type == ModContent.ItemType()) - ghostBracelet = true; - if (vanity.type == ModContent.ItemType()) - Player.GetModPlayer().vanityEquipped = true; - if (vanity.type == ModContent.ItemType()) - Player.GetModPlayer().vanityEquipped = true; - if (vanity.type == ModContent.ItemType()) - snowmanForce = true; - if (vanity.type == ModContent.ItemType()) - profanedCrystalForce = true; - if (vanity.type == ModContent.ItemType()) - punchCard = true; - if (vanity.type == ModContent.ItemType()) - Player.GetModPlayer().vanityEquipped = true; - if (vanity.type == ModContent.ItemType()) - Player.GetModPlayer().vanityEquipped = true; - if (vanity.type == ModContent.ItemType()) - Player.GetModPlayer().vanityEquipped = true; - } } if (Player.Calamity().andromedaState == AndromedaPlayerState.LargeRobot || @@ -4881,58 +5501,8 @@ namespace CalamityMod.CalPlayer { Player.head = EquipLoader.GetEquipSlot(Mod, "HeadlessEquipTexture", EquipType.Head); // To make the head invisible on the map. The map was having a hissy fit because of hitbox changes. } - else if ((profanedCrystal || profanedCrystalForce) && !profanedCrystalHide) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, Main.dayTime ? "ProfanedSoulCrystal" : "PscNightLegs", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "ProfanedSoulCrystal", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, Main.dayTime ? "ProfanedSoulCrystal" : "PscNightHead", EquipType.Head); - Player.wings = EquipLoader.GetEquipSlot(Mod, Main.dayTime ? "ProfanedSoulCrystal" : "PscNightWings", EquipType.Wings); - Player.face = -1; - - bool enrage = pscState >= (int)ProfanedSoulCrystal.ProfanedSoulCrystalState.Enraged; - - if (profanedCrystalWingCounter.Value == 0) - { - int key = profanedCrystalWingCounter.Key; - profanedCrystalWingCounter = new KeyValuePair(key == 3 ? 0 : key + 1, enrage ? 5 : 8); - } - - Player.wingFrame = profanedCrystalWingCounter.Key; - profanedCrystalWingCounter = new KeyValuePair(profanedCrystalWingCounter.Key, profanedCrystalWingCounter.Value - 1); - Player.armorEffectDrawOutlines = true; - if (profanedCrystalBuffs) - { - Player.armorEffectDrawShadow = true; - if (enrage) - { - Player.armorEffectDrawOutlinesForbidden = true; - } - } - } - else if ((snowmanPower || snowmanForce) && !snowmanHide) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "Popo", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "Popo", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, snowmanNoseless ? "PopoNoseless" : "Popo", EquipType.Head); - Player.face = -1; - } else if (AresExoskeleton.ArmExists(Player)) Player.body = EquipLoader.GetEquipSlot(Mod, "AresExoskeleton", EquipType.Body); - - else if ((abyssalDivingSuitPower || abyssalDivingSuitForce) && !abyssalDivingSuitHide) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "AbyssalDivingSuit", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "AbyssalDivingSuit", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "AbyssalDivingSuit", EquipType.Head); - Player.face = -1; - } - else if ((aquaticHeartPower || aquaticHeartForce) && !aquaticHeartHide) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "AquaticHeart", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "AquaticHeart", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "AquaticHeart", EquipType.Head); - Player.face = -1; - } else if (meldTransformationPower || meldTransformationForce) { Player.legs = EquipLoader.GetEquipSlot(Mod, "MeldTransformation", EquipType.Legs); @@ -4947,26 +5517,7 @@ namespace CalamityMod.CalPlayer if (hasOmegaBlueCooldown && cd.timeLeft > 1500) Player.head = EquipLoader.GetEquipSlot(Mod, "OmegaBlueTransformation", EquipType.Head); } - else - { - if (profanedCrystalWingCounter.Key != 1) - profanedCrystalWingCounter = new KeyValuePair(1, 7); - if (profanedCrystalAnimCounter.Key != 0) - profanedCrystalAnimCounter = new KeyValuePair(0, 10); - } - if (ghostBracelet) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "GhostBracelet", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "GhostBracelet", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "GhostBracelet", EquipType.Head); - } - if (punchCard) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "PunchCard", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "PunchCard", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "PunchCard", EquipType.Head); - } if (snowRuffianSet) { @@ -4976,7 +5527,7 @@ namespace CalamityMod.CalPlayer { if (!Player.mount.Active) { - Player.velocity.Y *= 0.9f; + Player.velocity.Y *= SnowRuffianMask.GlideFallSpeedMult; Player.wingFrame = 3; } Player.noFallDmg = true; @@ -5147,6 +5698,13 @@ namespace CalamityMod.CalPlayer private void NOULOL() { Player.ResetEffects(); + for (int j = 0; j < 1000; j++) + { + if (!Main.projectile[j].active || Main.projectile[j].owner != Player.whoAmI) + continue; + + Player.ownedProjectileCounts[Main.projectile[j].type]++; + } Player.head = -1; Player.body = -1; Player.legs = -1; @@ -5167,7 +5725,7 @@ namespace CalamityMod.CalPlayer #region Anomaly's Nanogun Kill Sound public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource) { - if (Player.whoAmI == Main.myPlayer && Player.ActiveItem().type == ItemType()) + if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ItemType()) { if (Main.rand.NextBool(20)) SoundEngine.PlaySound(IjiDeathSound, Player.Center); @@ -5197,13 +5755,6 @@ namespace CalamityMod.CalPlayer return false; } - - if ((CalamityWorld.death || BossRushEvent.BossRushActive) && areThereAnyDamnBosses) - { - chatText = CalamityUtils.GetTextValue("Vanilla.NurseChat.HealNotAllowed"); - return false; - } - return true; } @@ -5220,6 +5771,8 @@ namespace CalamityMod.CalPlayer if (price > 0) { + if (CalamityWorld.death) + price *= 2; if (areThereAnyDamnBosses) price *= 5; @@ -5258,13 +5811,13 @@ namespace CalamityMod.CalPlayer public override void PostNurseHeal(NPC nurse, int health, bool removeDebuffs, int price) { // Remove excess alcohol - if (removeDebuffs && alcoholPoisonLevel > (cirrusDress ? 5 : 3)) + if (removeDebuffs && alcoholPoisonLevel > 3) { List Alcohol = new List(); for (int i = 0; i < Player.MaxBuffs; i++) { int buff = Player.buffType[i]; - if (AlcoholsDict.TryGet(buff, out int level)) + if (CalamityBuffSets.AlcoholStrength.TryGetValue(buff, out int level)) Alcohol.Insert(0, new int[] { i, level }); } @@ -5277,7 +5830,7 @@ namespace CalamityMod.CalPlayer poison -= relation[1]; // Cancel the poison level Alcohol.RemoveAt(0); } - while (poison > (cirrusDress ? 5 : 3)); + while (poison > 3); } } #endregion @@ -5296,15 +5849,27 @@ namespace CalamityMod.CalPlayer stealthStrikeThisFrame = false; stealthStrikeHalfCost = false; stealthStrike75Cost = false; - stealthStrike85Cost = false; + stealthStrike90Cost = false; // stealthAcceleration only resets if you don't have either of the accelerator accessories equipped if (!darkGodSheath && !eclipseMirror) stealthAcceleration = 1f; + + if (temporaryStealthTimer > 0) + temporaryStealthTimer--; + else + temporaryStealthMax = 0.1f; } public void UpdateRogueStealth() { + if (temporaryStealthTimer > 0) + { + if (rogueStealthMax < temporaryStealthMax) + rogueStealthMax = temporaryStealthMax; + wearingRogueArmor = true; + } + // If the player un-equips rogue armor, then reset the sound so it'll play again when they re-equip it if (!wearingRogueArmor) { @@ -5339,7 +5904,7 @@ namespace CalamityMod.CalPlayer // This doesn't trigger stealth strike effects (ConsumeStealthStrike instead of StealthStrike) // so non-rogue weapons can't call lasers down from the sky and such. // Using any item which deals no damage or is a tool doesn't consume stealth. - Item it = Player.ActiveItem(); + Item it = Player.HeldItem; bool hasDamage = it.damage > 0; bool hasHitboxes = !it.noMelee || it.shoot > ProjectileID.None; bool isPickaxe = it.pick > 0; @@ -5350,16 +5915,16 @@ namespace CalamityMod.CalPlayer bool hasNonWeaponFunction = isPickaxe || isAxe || isHammer || isPlaced || isChannelable; bool playerUsingWeapon = hasDamage && hasHitboxes && !hasNonWeaponFunction; - // The Gem Tech armor's rogue crystal ensures that stealth is not consumed by non-rogue items. - if ((it.IsAir || !it.CountsAsClass()) && GemTechSet && GemTechState.IsRedGemActive) + // The Gem Tech armor's rogue crystal ensures that stealth is not consumed by non-rogue items. Forbidden Circlet does this for summon weapons + if ((it.IsAir || (!it.CountsAsClass()) && GemTechSet && GemTechState.IsRedGemActive) || (it.CountsAsClass() && forbiddenCirclet)) playerUsingWeapon = false; // Molten Amputator consumes stealth in a special way - if (it.type == ModContent.ItemType()) + if (it.type == ItemType()) playerUsingWeapon = false; // Shock Grenade consumes stealth in a special way - if (it.type == ModContent.ItemType()) + if (it.type == ItemType()) playerUsingWeapon = false; // Animation check depends on whether the item is "clockwork", like Clockwork Assault Rifle. @@ -5387,7 +5952,7 @@ namespace CalamityMod.CalPlayer return; // Hovering over an item will adjust the stealth bonus dynamically so that you see the correct damage for an item you put your cursor on. - Item it = !Main.HoverItem.IsAir ? Main.HoverItem : Player.ActiveItem(); + Item it = !Main.HoverItem.IsAir ? Main.HoverItem : Player.HeldItem; // The potential damage bonus from stealth is a complex equation based on the item's use time, // the player's averaged-together stealth generation stats, and max stealth. @@ -5491,8 +6056,8 @@ namespace CalamityMod.CalPlayer consumptionMult = 0.5f; else if (stealthStrike75Cost) consumptionMult = 0.75f; - else if (stealthStrike85Cost) - consumptionMult = 0.85f; + else if (stealthStrike90Cost) + consumptionMult = 0.9f; return rogueStealth >= rogueStealthMax * consumptionMult; } @@ -5519,7 +6084,7 @@ namespace CalamityMod.CalPlayer if (rogueStealth <= 0f) rogueStealth = 0f; } - else if (stealthStrike85Cost) + else if (stealthStrike90Cost) { rogueStealth -= 0.9f * stealthToLose; if (rogueStealth <= 0f) @@ -5534,7 +6099,7 @@ namespace CalamityMod.CalPlayer internal void rollBabSpears(int randAmt, bool chaseable) { - var source = Player.GetSource_ItemUse(Player.ActiveItem()); + var source = Player.GetSource_ItemUse(Player.HeldItem); if (Player.whoAmI == Main.myPlayer && !endoCooper && randAmt > 0 && Main.rand.NextBool(randAmt) && chaseable) { int spearsFired = 0; @@ -5563,61 +6128,6 @@ namespace CalamityMod.CalPlayer } } } - - private bool IsValidTransitionFrame(AnimationType currentAnim, AnimationType newAnim, int frame, int counter) //this exists so it doesn't loop through the entire walk/idle anim just to find one frame for switching. - { - bool result = newAnim != AnimationType.Jump && currentAnim != AnimationType.Jump; - if (currentAnim == AnimationType.Walk && newAnim == AnimationType.Idle) - { - result = counter <= 0 && (frame == 11 || frame == 15 || frame == 19); - } - else if (currentAnim == AnimationType.Idle && newAnim == AnimationType.Walk) - { - result = counter <= 0 && (frame == 2 || frame == 6); - } - return currentAnim != newAnim && result; //swapping to jumps should be instant, no need to check the counter here - } - - private int HandlePSCAnimationFrames(AnimationType newType) - { - int key = profanedCrystalAnimCounter.Key; //0-based indexing - int value = profanedCrystalAnimCounter.Value - 1; - AnimationType currentType = key < 8 ? AnimationType.Idle : key == 8 ? AnimationType.Jump : AnimationType.Walk; - - bool isInvalidTransFrame = !IsValidTransitionFrame(currentType, newType, key, value); //to make the transition between walk and idle frames less jarring and smoother - AnimationType type = isInvalidTransFrame ? newType : currentType; - int frameCount = type == AnimationType.Walk || (!profanedCrystalForce && Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) ? 7 : 10; - int lowerRange = type == AnimationType.Idle ? 0 : type == AnimationType.Jump ? 8 : 9; - int upperRange = type == AnimationType.Idle ? 7 : type == AnimationType.Jump ? 8 : 22; - if (value <= 0 || !isInvalidTransFrame) - { - value = frameCount; - if (key >= lowerRange && key < upperRange) - key++; - else - key = lowerRange; - } - profanedCrystalAnimCounter = new KeyValuePair(key, value); - return profanedCrystalAnimCounter.Key; - } - - public override void PostUpdate() //needs to be here else it doesn't work properly, otherwise i'd have stuck it with the wing anim stuffs - { - bool validEquipSlot = Player.legs == EquipLoader.GetEquipSlot(Mod, "ProfanedSoulCrystal", EquipType.Legs) || - Player.legs == EquipLoader.GetEquipSlot(Mod, "PscNightLegs", EquipType.Legs); - if (!profanedCrystalHide && (profanedCrystal || profanedCrystalForce) && validEquipSlot) - { - bool usingCarpet = Player.carpetTime > 0 && Player.controlJump; //doesn't make sense for carpet to use jump frame since you have solid ground - AnimationType animType = AnimationType.Walk; - if ((Player.sliding || Player.velocity.Y != 0 || Player.mount.Active || (Player.grappling[0] != -1 || !Player.CheckSolidGround()) || Player.GoingDownWithGrapple) && !usingCarpet) - animType = AnimationType.Jump; - else if (Player.velocity.X == 0 || usingCarpet) - animType = AnimationType.Idle; - int frame = HandlePSCAnimationFrames(animType); - Player.legFrame.Y = Player.legFrame.Height * frame; - } - } - #endregion #region Misc Stuff @@ -5627,6 +6137,9 @@ namespace CalamityMod.CalPlayer // It also starts the speedrun timer if applicable. public override void OnEnterWorld() { + if (CalamityClientConfig.Instance.StutterFix) + WorldGen.SectionTileFrameWithCheck(0, 0, Main.maxTilesX, Main.maxTilesY); + if (Main.netMode == NetmodeID.MultiplayerClient) EnterWorldSync(); @@ -5641,9 +6154,7 @@ namespace CalamityMod.CalPlayer // Set a random delay between 12 and 20 seconds. When this delay hits zero, startup messages display if (showStartupMessages) - { startMessageDisplayDelay = Main.rand.Next(CalamityUtils.SecondsToFrames(12), CalamityUtils.SecondsToFrames(20) + 1); - } } /// @@ -5690,12 +6201,12 @@ namespace CalamityMod.CalPlayer Player.HealEffect(-5); Player.statLife -= 5; if (Player.statLife <= 0) - Player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ManaConversionEnchant").Format(Player.name)), 1000, -1); + Player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ManaConversionEnchant").ToNetworkText(Player.name)), 1000, -1); } for (int i = 0; i < 8; i++) { - Dust life = Dust.NewDustPerfect(Player.Top + Main.rand.NextVector2Circular(Player.width * 0.5f, 6f), 267); + Dust life = Dust.NewDustPerfect(Player.Top + Main.rand.NextVector2Circular(Player.width * 0.5f, 6f), DustID.RainbowMk2); life.color = Color.Red; life.velocity = -Vector2.UnitY.RotatedByRandom(0.48f) * Main.rand.NextFloat(3f, 4.4f); life.scale = Main.rand.NextFloat(1.5f, 1.72f); @@ -5705,5 +6216,29 @@ namespace CalamityMod.CalPlayer } } #endregion + + #region Controls + // These are used to entirely disable player directional inputs while being able to read them for other features + public bool ShouldHideControls = false; + public bool pressedRight = false; + public bool pressedLeft = false; + public bool pressedUp = false; + public bool pressedDown = false; + public override void SetControls() + { + pressedRight = Player.controlRight; + pressedLeft = Player.controlLeft; + pressedUp = Player.controlUp; + pressedDown = Player.controlDown; + if (ShouldHideControls) + { + Player.controlLeft = false; + Player.controlUp = false; + Player.controlDown = false; + Player.controlRight = false; + } + ShouldHideControls = false; + } + #endregion } } diff --git a/CalPlayer/CalamityPlayerDashEffects.cs b/CalPlayer/CalamityPlayerDashEffects.cs index a2e591296b..35995aaf7c 100644 --- a/CalPlayer/CalamityPlayerDashEffects.cs +++ b/CalPlayer/CalamityPlayerDashEffects.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Balancing; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer.Dashes; using CalamityMod.EntitySources; using CalamityMod.Enums; @@ -66,6 +65,18 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI != Main.myPlayer) return; + if ((HasCustomDash && Player.dashDelay < 0 && UsedDash.dashTime < UsedDash.dashStartup)) + { + UsedDash.DashStartupEffects(Player); + UsedDash.dashTime++; + return; + } + else if (HasCustomDash && UsedDash.dashStartup > 0 && Player.dashDelay < 0 && UsedDash.dashTime == UsedDash.dashStartup) + { + if (DoADash(UsedDash.CalculateDashSpeed(Player), true)) + UsedDash.OnDashEffects(Player); + } + var source = new ProjectileSource_PlayerDashHit(Player); // Handle collision slam-through effects. @@ -91,7 +102,7 @@ namespace CalamityMod.CalPlayer // Duplicated from the way TML edits vanilla ram dash damage (and Shield of Cthulhu) int dashDamage = (int)Player.GetTotalDamage(hitContext.damageClass).ApplyTo(hitContext.BaseDamage); - + Projectile ram = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), n.Center, Vector2.Zero, ModContent.ProjectileType(), dashDamage, 0f, Player.whoAmI, n.whoAmI); ram.DamageType = hitContext.damageClass; @@ -102,6 +113,7 @@ namespace CalamityMod.CalPlayer } } } + UsedDash.dashTime++; } if (Player.dashDelay > 0) @@ -118,8 +130,10 @@ namespace CalamityMod.CalPlayer dashDelayToApply = BalancingConstants.UniversalShieldSlamCooldown; else if (UsedDash.CollisionType == DashCollisionType.ShieldBonk) dashDelayToApply = BalancingConstants.UniversalShieldBonkCooldown; - if (DashID == DeepDiverDash.ID) - dashDelayToApply = 23; + if (DashID == DeepDiverDash.ID || (evasionScarf && DashID == CounterScarfDash.ID)) + dashDelayToApply = (int)(dashDelayToApply * 0.75f); + if (DashID == StatisNinjaBeltDash.ID || DashID == StatisVoidSashDash.ID || Player.dashType == 1) + dashDelayToApply = BalancingConstants.UniversalSashDashCooldown; float dashSpeed = 12f; float dashSpeedDecelerationFactor = 0.985f; @@ -130,7 +144,7 @@ namespace CalamityMod.CalPlayer // Handle mid-dash effects. UsedDash.MidDashEffects(Player, ref dashSpeed, ref dashSpeedDecelerationFactor, ref runSpeedDecelerationFactor); - int VerticalOmnidashCap = DashID == GodslayerArmorDash.ID ? 120 : 25; + int VerticalOmnidashCap = DashID == GodslayerArmorDash.ID ? 75 : 25; if (UsedDash.IsOmnidirectional && VerticalOmnidashTimer < VerticalOmnidashCap) { VerticalOmnidashTimer++; @@ -144,9 +158,6 @@ namespace CalamityMod.CalPlayer if (HasCustomDash) { - // Vortex Booster automatically re-engages Vortex armor's stealth after a delay when dashing - if (Player.wingsLogic == (int)VanillaWingID.WingsVortex && Player.vortexStealthActive) - vortexBoosterStealthDelay = 60; Player.vortexStealthActive = false; // Decide the player's facing direction. @@ -185,7 +196,8 @@ namespace CalamityMod.CalPlayer } // Dash delay depends on the type of dash used. - Player.dashDelay = dashDelayToApply; + if (!(HasCustomDash && UsedDash.dashStartup > 0 && Player.dashDelay < 0 && UsedDash.dashTime <= UsedDash.dashStartup + 10)) + Player.dashDelay = dashDelayToApply; if (UsedDash.IsOmnidirectional) { @@ -221,20 +233,24 @@ namespace CalamityMod.CalPlayer // Handle first-frame effects. else if (HasCustomDash && !Player.mount.Active) { + UsedDash.dashTime = 0; if (DoADash(UsedDash.CalculateDashSpeed(Player))) - UsedDash.OnDashEffects(Player); + if (UsedDash.dashStartup <= 0) + UsedDash.OnDashEffects(Player); + else + UsedDash.OnDashStartupEffects(Player); } } - public bool HandleHorizontalDash(out DashDirection direction) + public bool HandleHorizontalDash(out DashDirection direction, bool forceDash = false) { direction = DashDirection.Directionless; bool dashWasExecuted = false; // If the manual hotkey is bound, standard Terraria dashes cannot be triggered by double tapping. - var manualDashHotkeys = CalamityKeybinds.DashHotkey.GetAssignedKeys(); + var manualDashHotkeys = CalamityKeybinds.DashHotkey.GetAssignedKeysOrEmpty(); bool manualHotkeyBound = (manualDashHotkeys?.Count ?? 0) > 0; - bool pressedManualHotkey = manualHotkeyBound && CalamityKeybinds.DashHotkey.JustPressed; + bool pressedManualHotkey = manualHotkeyBound && (CalamityKeybinds.DashHotkey.JustPressed || forceDash); int dashDirectionToUse = 0; @@ -416,9 +432,9 @@ namespace CalamityMod.CalPlayer return justDashed; } - public bool DoADash(float dashSpeed) + public bool DoADash(float dashSpeed, bool forceDash = false) { - bool justDashed; + bool justDashed = forceDash; bool omnidirectionalDash = UsedDash?.IsOmnidirectional ?? false; DashDirection direction; @@ -432,7 +448,14 @@ namespace CalamityMod.CalPlayer else if (omnidirectionalDash) justDashed = HandleOmnidirectionalDash(out direction); else - justDashed = HandleHorizontalDash(out direction); + justDashed = HandleHorizontalDash(out direction, forceDash); + + if (justDashed && !forceDash && UsedDash.dashStartup > 0) + { + Player.timeSinceLastDashStarted = 0; + Player.dashDelay = -1; + return justDashed; + } // Make dash movements happen if ready. if (justDashed) @@ -504,21 +527,6 @@ namespace CalamityMod.CalPlayer public void ModHorizontalMovement() { - if (Player.mount.Active && Player.mount.Type == ModContent.MountType() && Math.Abs(Player.velocity.X) > Player.mount.DashSpeed - Player.mount.RunSpeed / 2f) - { - Rectangle damageHitbox = Player.getRect(); - - if (Player.direction == 1) - damageHitbox.Offset(Player.width - 1, 0); - - damageHitbox.Width = 2; - damageHitbox.Inflate(6, 12); - float damage = Player.GetTotalDamage().ApplyTo(800f); - float knockback = 10f; - int NPCImmuneTime = 30; - int playerImmuneTime = 6; - DoMountDashDamage(damageHitbox, damage, knockback, NPCImmuneTime, playerImmuneTime); - } if (Player.mount.Active && Player.mount.Type == ModContent.MountType() && Math.Abs(Player.velocity.X) > Player.mount.RunSpeed) { @@ -584,7 +592,7 @@ namespace CalamityMod.CalPlayer if (myRect.Intersects(npcHitbox) && (n.noTileCollide || Collision.CanHit(Player.position, Player.width, Player.height, n.position, n.width, n.height))) { int hitDirection = Math.Sign(Player.velocity.X); - + // Use the player's facing direction as a fallback if they are not making any horizontal movement. if (hitDirection == 0) hitDirection = Player.direction; diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index eaaeda1189..732eb9e924 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -4,15 +4,21 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer.DrawLayers; +using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems.Collections; +using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -34,7 +40,14 @@ namespace CalamityMod.CalPlayer PlayerDrawLayers.Shoes.Hide(); } - if (drawInfo.drawPlayer.Calamity().andromedaState != AndromedaPlayerState.Inactive) + if (drawInfo.drawPlayer.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + foreach (var layer in PlayerDrawLayerLoader.Layers) + { + layer.Hide(); + } + } + else if (drawInfo.drawPlayer.Calamity().andromedaState != AndromedaPlayerState.Inactive) { foreach (var layer in PlayerDrawLayerLoader.Layers) { @@ -56,11 +69,174 @@ namespace CalamityMod.CalPlayer CalamityPlayer calamityPlayer = Player.Calamity(); - // Dust modifications while high. + if (Starshield > 0 && drawInfo.shadow == 0) + { + var color = Color.Lerp(Color.DeepSkyBlue, Color.LightSkyBlue, (StratusStarburst / (float)MaxStratusStarburst)); + var opacity = MathHelper.Min(MathHelper.Min(Starshield / 30f, 1f), (CalamityUtils.MinutesToFrames(10) - Starshield) / 30f); + float size = 80 + 32 * (StratusStarburst / (float)MaxStratusStarburst); + + Vector2 drawPosition = Player.Center + new Vector2(0, Player.gfxOffY) - Main.screenPosition; + + PixelationManager.AddPixelatedDrawer(drawLayer: Enums.GeneralDrawLayer.AfterProjectiles, drawAction: (matrix) => + { + #region AoE + //Draw the bloom circle + + Texture2D telegraphBase = StratusBlackHole.GetTransparentBloomTex(); + + //Draw the inner particles + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(0.5f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.2f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoiseHighContrast"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.DarkSlateBlue * opacity, 0, telegraphBase.Size() / 2f, size * 1.5f * opacity / telegraphBase.Width, 0, 0); + + //Draw the outer particles + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(0.25f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.1f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + telegraphBase = ModContent.Request("CalamityMod/Particles/HighResFoggyCircleHardEdge").Value; + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.SkyBlue * opacity, 0, telegraphBase.Size() / 2f, size * opacity / telegraphBase.Width, 0, 0); + Main.spriteBatch.ExitShaderRegion(matrix); + #endregion + }); + } + //DoG Boss Cursor + DevourerofGodsHead DoG = null; + foreach (var item in Main.ActiveNPCs) + { + if (item.type == ModContent.NPCType()) + { + DoG = item.ModNPC(); + break; + } + } + if (DoG != null && Main.mapStyle != 2 && !Main.hideUI) + { + int drawCount = calamityPlayer.trippy ? 4 : 1; + + for (int i = 0; i < drawCount; i++) + { + var rift = DoG.GetRiftLocation(); + bool drawingRift = rift != Vector2.Zero && !Main.zenithWorld; + + Vector2 targetCenter = drawingRift ? rift : DoG.NPC.Center; + float diffX = targetCenter.X - Player.Center.X; + float diffY = targetCenter.Y - Player.Center.Y; + + // Mirror the offset based on i's index + if (calamityPlayer.trippy) + { + switch (i) + { + case 0: diffX = -Math.Abs(diffX); diffY = -Math.Abs(diffY); break; // Top Left + case 1: diffX = Math.Abs(diffX); diffY = -Math.Abs(diffY); break; // Top Right + case 2: diffX = Math.Abs(diffX); diffY = Math.Abs(diffY); break; // Bottom Right + case 3: diffX = -Math.Abs(diffX); diffY = Math.Abs(diffY); break; // Bottom Left + } + } + + Vector2 virtualTargetPos = Player.Center + new Vector2(diffX, diffY); + float dist = Player.Distance(virtualTargetPos); + Vector2 directionToTarget = Player.DirectionTo(virtualTargetPos); + + if (drawingRift) + { + var tex = ModContent.Request("Terraria/Images/Extra_173").Value; + float opacity = 0.9f * Math.Clamp(MathHelper.Lerp(0, 1, (dist - 300) / 600), 0, 1); + + Color drawColor = calamityPlayer.trippy ? Main.DiscoColor : Color.White * 0.9f; + + Main.spriteBatch.Draw(tex, Player.Center + directionToTarget * 196 * Math.Min(dist / 2400f, 2) - Main.screenPosition, + null, drawColor * opacity, 0, tex.Size() / 2f, 0.9f, SpriteEffects.FlipHorizontally, 0); + } + else + { + var dis = Player.Distance(virtualTargetPos); + if ((DoG.NPC.ai[3] < 3 || !DoG.Phase2Started) && DoG.NPC.Opacity > 0.5f && !DoG.Dying && !drawInfo.drawPlayer.isDisplayDollOrInanimate) + { + int headIconIndex = -1; + DoG.BossHeadSlot(ref headIconIndex); + if (headIconIndex > -1) + { + var tex = TextureAssets.NpcHeadBoss[headIconIndex].Value; + + float baseRotation = DoG.NPC.rotation; + + if (calamityPlayer.trippy) + { + Vector2 rotVec = baseRotation.ToRotationVector2(); + switch (i) + { + case 0: + rotVec.X *= -1; + rotVec.Y *= -1; + break; + case 1: + rotVec.Y *= -1; + break; + case 2: + break; + case 3: + rotVec.X *= -1; + break; + } + baseRotation = rotVec.ToRotation(); + } + + float opacity = 0.9f * Math.Clamp(MathHelper.Lerp(0, 1, (dis - 600) / 300), 0, 1); + Color drawColor = calamityPlayer.trippy ? new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, (int)(255 * 0.9f)) : Color.White * 0.9f; + + Main.spriteBatch.Draw(tex, Player.Center + directionToTarget * 196 * Math.Min(dis / 2400f, 2) - Main.screenPosition, null, drawColor * opacity, baseRotation, tex.Size() / 2f, 1, SpriteEffects.None, 0); + } + } + } + } + } + + //Charge animation for Thread of Eradication + if (Player.HeldItem.type == ModContent.ItemType() && !Player.ItemTimeIsZero && drawInfo.shadow == 0f) + { + var color = Color.Fuchsia; + float scale = (1 - (Player.itemTime - 7) / 50f) * 0.2f; + if (Player.itemTime < 7) + { + scale = ((Player.itemTime) / 7f) * 0.2f; + } + if (Player.itemTime > 60) + { + scale = (1 - (Player.itemTime - 70) / 110f) * 0.5f; + if (Player.itemTime < 70) + { + scale = ((Player.itemTime - 60) / 10f) * 0.5f; + } + color = Color.Cyan; + } + + if (CalamityClientConfig.Instance.Photosensitivity) + color = color * 0.2f; + var bloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + var circleTex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Draw(bloomTex, Player.Center + (Vector2.UnitX * Player.direction).RotatedBy(Player.itemRotation) * (48 + scale * 96) - Main.screenPosition, null, color, 0, bloomTex.Size() * 0.5f, scale * 2.0f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(bloomTex, Player.Center + (Vector2.UnitX * Player.direction).RotatedBy(Player.itemRotation) * (48 + scale * 96) - Main.screenPosition, null, color, 0, bloomTex.Size() * 0.5f, scale * 2.0f, SpriteEffects.None, 0); + Main.spriteBatch.End(); + } + for (var i = 0; i < 5; i++) + Main.spriteBatch.Draw(circleTex, Player.Center + (Vector2.UnitX * Player.direction).RotatedBy(Player.itemRotation) * (48 + scale * 96) - Main.screenPosition, null, Color.Black * ((i + 1) / 5f) * (CalamityClientConfig.Instance.Photosensitivity ? 0.2f : 1f), 0, circleTex.Size() * 0.5f, scale * 2.2f * (0.5f + 0.5f * (1 - (i) / 5f)), SpriteEffects.None, 0); + } + + // Drawing for Odd Mushroom's clone effects if (calamityPlayer.trippy) { if (Main.myPlayer == Player.whoAmI) { + // Dust Rectangle screenArea = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 50, Main.screenWidth + 1000, Main.screenHeight + 100); int dustDrawn = 0; float maxShroomDust = Main.maxDustToDraw / 2; @@ -104,11 +280,129 @@ namespace CalamityMod.CalPlayer } } } + + // NPCs + foreach (NPC n in Main.ActiveNPCs) + { + Color rainbow = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); + Color alphaColor = n.GetAlpha(rainbow); + float RGBMult = 0.99f; + alphaColor.R = (byte)(alphaColor.R * RGBMult); + alphaColor.G = (byte)(alphaColor.G * RGBMult); + alphaColor.B = (byte)(alphaColor.B * RGBMult); + alphaColor.A = (byte)(alphaColor.A * RGBMult); + + for (int i = 0; i < 4; i++) + { + Vector2 position = n.position; + float distanceFromTargetX = Math.Abs(n.Center.X - Main.LocalPlayer.Center.X); + float distanceFromTargetY = Math.Abs(n.Center.Y - Main.LocalPlayer.Center.Y); + + switch (i) + { + case 0: + position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; + break; + + case 1: + position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; + break; + + case 2: + position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; + break; + + case 3: + position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; + break; + + default: + break; + } + + Vector2 posDiff = n.Center - position; + Main.instance.DrawNPCDirect(Main.spriteBatch, n, n.behindTiles, Main.screenPosition + posDiff); + } + } + + // Projectiles + foreach (Projectile p in Main.ActiveProjectiles) + { + Texture2D texture = TextureAssets.Projectile[p.type].Value; + Color rainbow = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); + Color alphaColor = p.GetAlpha(rainbow); + float RGBMult = 0.99f; + alphaColor.R = (byte)(alphaColor.R * RGBMult); + alphaColor.G = (byte)(alphaColor.G * RGBMult); + alphaColor.B = (byte)(alphaColor.B * RGBMult); + alphaColor.A = (byte)(alphaColor.A * RGBMult); + + Vector2 storedProjPos = p.Center; + for (int i = 0; i < 4; i++) + { + Vector2 position = p.position; + float distanceFromTargetX = Math.Abs(p.Center.X - Main.LocalPlayer.Center.X); + float distanceFromTargetY = Math.Abs(p.Center.Y - Main.LocalPlayer.Center.Y); + + switch (i) + { + case 0: + position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; + break; + + case 1: + position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; + break; + + case 2: + position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; + break; + + case 3: + position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; + position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; + break; + + default: + break; + } + + // Unfortunately unlike NPCs, there is no public function for drawing a projectile with a position parameter to spoof. + // So we have to spoof it by directly changing the projectile's position, then resetting it at the end. + p.Center = position; + Main.instance.DrawProjDirect(p); + } + + p.Center = storedProjPos; + } } } - else // This is such a stupid way to reset this but you can't just put it in ResetEffects + else { - calamityPlayer.trippyLevel = 1; + // Mana Burn VFX disabled when hih + if (Player.statMana < 0) + { + float compactness = Player.width * 0.6f; + if (compactness < 10f) + compactness = 10f; + float power = Player.height / 100f; + if (power > 2.75f) + power = 2.75f; + var color = Color.Blue; + if (ManaBurnFireDrawer is null || ManaBurnFireDrawer.LocalTimer >= ManaBurnFireDrawer.SetLifetime) + ManaBurnFireDrawer = new FireParticleSet(60 - (Player.statMana / 4), 1, color * 1.25f, color, compactness, power); + else + ManaBurnFireDrawer.DrawSet(Player.Bottom - Vector2.UnitY * (12f - Player.gfxOffY)); + } + else + ManaBurnFireDrawer = null; } // TODO -- rogue stealth visuals are an utter catastrophe and should be fully destroyed on next stealth rework @@ -126,7 +420,7 @@ namespace CalamityMod.CalPlayer } #region Flight Visuals - // Celestial Tracers, Elysian Tracers, Seraph Tracers + // Moon Walkers, Void Striders, Seraph Tracers if (calamityPlayer.tracersDust && drawInfo.shadow == 0f) { if (!Player.StandingStill() && !Player.mount.Active) @@ -140,21 +434,6 @@ namespace CalamityMod.CalPlayer } } } - - // Elysian Wings, Elysian TRACERS?! and SERAPH TRACERS?! - if (calamityPlayer.elysianWingsDust && drawInfo.shadow == 0f) - { - if (!Player.StandingStill() && !Player.mount.Active) - { - if (Main.rand.NextBool()) - { - Dust dust = Dust.NewDustDirect(drawInfo.Position - new Vector2(2f), Player.width + 4, Player.height + 4, DustID.GoldCoin, Player.velocity.X * 0.4f, Player.velocity.Y * 0.4f, 100, default, 1f); - dust.noGravity = true; - dust.velocity *= 0.5f; - drawInfo.DustCache.Add(dust.dustIndex); - } - } - } #endregion #region Armor Visuals @@ -213,10 +492,10 @@ namespace CalamityMod.CalPlayer if (calamityPlayer.auricRebuke && drawInfo.shadow == 0f) AuricRebuke.DrawEffects(drawInfo); - if (calamityPlayer.bBlood && drawInfo.shadow == 0f) + if (calamityPlayer.burningBlood && drawInfo.shadow == 0f) BurningBlood.DrawEffects(drawInfo); - if (calamityPlayer.bFlames && drawInfo.shadow == 0f) + if (calamityPlayer.brimstoneFlames && drawInfo.shadow == 0f) { bool resistsBrimstoneFlames = abaddon; // Looks weaker if you have Abaddon equipped BrimstoneFlames.DrawEffects(drawInfo, resistsBrimstoneFlames); @@ -225,12 +504,11 @@ namespace CalamityMod.CalPlayer if (calamityPlayer.brainRot && drawInfo.shadow == 0f) BrainRot.DrawEffects(drawInfo); - if (calamityPlayer.cDepth && drawInfo.shadow == 0f) + if (calamityPlayer.crushDepth && drawInfo.shadow == 0f) CrushDepth.DrawEffects(drawInfo); - // Daybroken's visual effects are reduced if the player resists it if (calamityPlayer.daybroken && drawInfo.shadow == 0f) - Daybroken.DrawEffects(drawInfo, reducedDaybrokenDamage); + Daybroken.DrawEffects(drawInfo); if (calamityPlayer.demonicFlames && drawInfo.shadow == 0f) DemonicFlames.DrawEffects(drawInfo); @@ -244,26 +522,17 @@ namespace CalamityMod.CalPlayer if (calamityPlayer.eutrophication && drawInfo.shadow == 0f) Eutrophication.DrawEffects(drawInfo); - if (calamityPlayer.gState && drawInfo.shadow == 0f) - { - // These lines cannot be moved to Glacial State's own file - r *= 0.13f; - g *= 0.66f; - - GlacialState.DrawEffects(drawInfo); - } - - if (calamityPlayer.gsInferno && drawInfo.shadow == 0f) + if (calamityPlayer.godSlayerInferno && drawInfo.shadow == 0f) GodSlayerInferno.DrawEffects(drawInfo); if (calamityPlayer.heavybleeding && drawInfo.shadow == 0f) HeavyBleeding.DrawEffects(drawInfo); // Holy Flames, Holy Inferno and Banishing Fire share the same visual effects - if (drawInfo.shadow == 0f && (calamityPlayer.hFlames || calamityPlayer.hInferno || calamityPlayer.banishingFire)) + if (drawInfo.shadow == 0f && (calamityPlayer.holyFlames || calamityPlayer.holyInferno || calamityPlayer.banishingFire)) HolyFlames.DrawEffects(drawInfo); - if (calamityPlayer.hPressure && drawInfo.shadow == 0f) + if (calamityPlayer.hadopelagicPressure && drawInfo.shadow == 0f) HadopelagicPressure.DrawEffects(drawInfo); // Icarus' Folly has visual effects but they are mutually exclusive with all Holy Flames variations to prevent visual clutter @@ -280,13 +549,13 @@ namespace CalamityMod.CalPlayer if (calamityPlayer.mushy && drawInfo.shadow == 0f) Mushy.DrawEffects(drawInfo); - if (calamityPlayer.nightwither && drawInfo.shadow == 0f) // Looks weaker if you have Moon Stone equipped - Nightwither.DrawEffects(drawInfo, reducedNightwitherDamage); + if (calamityPlayer.nightwither && drawInfo.shadow == 0f) + Nightwither.DrawEffects(drawInfo); - if (calamityPlayer.pFlames && drawInfo.shadow == 0f) + if (calamityPlayer.plague && drawInfo.shadow == 0f) Plague.DrawEffects(drawInfo); - if (calamityPlayer.rTide && drawInfo.shadow == 0f) + if (calamityPlayer.riptide && drawInfo.shadow == 0f) RiptideDebuff.DrawEffects(drawInfo); if (calamityPlayer.shadowflame && drawInfo.shadow == 0f) @@ -318,6 +587,16 @@ namespace CalamityMod.CalPlayer VulnerabilityHex.DrawEffects(drawInfo); #endregion + if (calamityPlayer.fortunesFavor && drawInfo.shadow == 0f) + { + if (Main.rand.NextBool(12)) + { + Vector2 plusPos = new Vector2(Player.position.X + Main.rand.NextFloat(-8f, 20f), Player.position.Y + Main.rand.NextFloat(-14f, 36f)); + + Particle Plus = new HealingPlus(plusPos, Main.rand.NextFloat(0.33f, 0.66f), new Vector2(0, Main.rand.NextFloat(-2f, -3.5f)) + Player.velocity, Color.Gold, Color.Goldenrod, Main.rand.Next(9, 13)); + GeneralParticleHandler.SpawnParticle(Plus); + } + } if (calamityPlayer.PinkJellyRegen && drawInfo.shadow == 0f) { if (Main.rand.NextBool(24)) @@ -342,6 +621,20 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(Plus); } } + if (calamityPlayer.bloomStoneBuffedHealRateTimer > 0 && drawInfo.shadow == 0f) + { + if (Main.rand.NextBool(10)) + { + MediumMistParticle pollenCloud = new(Player.Center, Main.rand.NextVector2Circular(1f, 1f), Color.Yellow, Color.Gold, 0.85f, 100f); + GeneralParticleHandler.SpawnParticle(pollenCloud); + } + if (Main.rand.NextBool(4)) + { + Dust pollenDust = Dust.NewDustDirect(Player.position, Player.width, Player.height, ModContent.DustType(), newColor: Color.Gold, Scale: 0.4f); + pollenDust.noLightEmittence = true; + pollenDust.noGravity = true; + } + } if (calamityPlayer.bloodfinBoost && drawInfo.shadow == 0f) { if (Main.rand.NextBool(3)) @@ -442,14 +735,14 @@ namespace CalamityMod.CalPlayer } #endregion Profaned Moonlight Dye Colors - #region Tanks/Backpacks + #region Vanity Accessories and Tanks/Backpacks public override void ModifyDrawInfo(ref PlayerDrawSet drawInfo) { if (drawInfo.shadow != 0f) return; Player drawPlayer = drawInfo.drawPlayer; - Item item = drawPlayer.ActiveItem(); + Item item = drawPlayer.HeldItem; if (!drawPlayer.frozen && (item.IsAir || item.type > ItemID.None) && diff --git a/CalPlayer/CalamityPlayerDrawParameters.cs b/CalPlayer/CalamityPlayerDrawParameters.cs index a270396544..b824990f60 100644 --- a/CalPlayer/CalamityPlayerDrawParameters.cs +++ b/CalPlayer/CalamityPlayerDrawParameters.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.LunicCorps; using CalamityMod.Packets; diff --git a/CalPlayer/CalamityPlayerFishing.cs b/CalPlayer/CalamityPlayerFishing.cs index 39f6fdc933..edd7792110 100644 --- a/CalPlayer/CalamityPlayerFishing.cs +++ b/CalPlayer/CalamityPlayerFishing.cs @@ -1,19 +1,25 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.Events; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Fishing; using CalamityMod.Items.Fishing.AstralCatches; using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.Fishing.FishingRods; using CalamityMod.Items.Fishing.SulphurCatches; using CalamityMod.Items.Fishing.SunkenSeaCatches; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureDriftwood; using CalamityMod.Items.SummonItems; +using CalamityMod.Items.Tools.ClimateChange; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.Particles; @@ -24,6 +30,7 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using Terraria.UI; namespace CalamityMod.CalPlayer { @@ -141,7 +148,7 @@ namespace CalamityMod.CalPlayer itemDrop = ModContent.ItemType(); else if (questFish == ModContent.ItemType() && attempt.uncommon) itemDrop = ModContent.ItemType(); - else if (grabBagFish && Main.hardMode) + else if (questFish == ModContent.ItemType() && attempt.uncommon) itemDrop = ModContent.ItemType(); else if (attempt.rare) { @@ -156,6 +163,10 @@ namespace CalamityMod.CalPlayer else itemDrop = ModContent.ItemType(); } + if (ZoneBasaltGully) + { + itemDrop = ModContent.ItemType(); + } return; } @@ -167,6 +178,39 @@ namespace CalamityMod.CalPlayer if (canSulphurFish && bait == ModContent.ItemType() && !BossRushEvent.BossRushActive) { CalamityGlobalNPC.OldDukeSpawn(Player.whoAmI, ModContent.NPCType(), bait); + itemDrop = -1; + return; + } + + if (attempt.playerFishingConditions.PoleItemType == ModContent.ItemType()) + { + if (Main.rand.NextBool(5)) + { + itemDrop = ModContent.ItemType(); + return; + } + if (Main.rand.NextBool(15)) + { + itemDrop = ModContent.ItemType(); + return; + } + + if (Main.rand.NextBool(50)) + { + switch (Main.rand.Next(3)) + { + case 0: + itemDrop = ModContent.ItemType(); + return; + case 1: + itemDrop = ModContent.ItemType(); + return; + case 2: + itemDrop = ModContent.ItemType(); + return; + } + return; + } } // Ignore catches if it's junk @@ -207,6 +251,49 @@ namespace CalamityMod.CalPlayer itemDrop = ModContent.ItemType(); return; } + //Rare abyss catches are replaced with abyss chest items post-skeletron + if (NPC.downedBoss3 && (ZoneAbyssLayer2 || ZoneAbyssLayer3 || ZoneAbyssLayer4) && attempt.rare) + { + switch (Main.rand.Next(10)) + { + case 0: + itemDrop = ModContent.ItemType(); + return; + case 1: + itemDrop = ModContent.ItemType(); + return; + case 2: + itemDrop = ModContent.ItemType(); + return; + case 3: + itemDrop = ModContent.ItemType(); + return; + case 4: + itemDrop = ModContent.ItemType(); + return; + case 5: + itemDrop = ModContent.ItemType(); + return; + case 6: + itemDrop = ModContent.ItemType(); + return; + case 7: + itemDrop = ModContent.ItemType(); + return; + case 8: + itemDrop = ModContent.ItemType(); + return; + case 9: + itemDrop = ModContent.ItemType(); + return; + } + } + + // Quest fish + if (sky && questFish == ModContent.ItemType() && attempt.uncommon) + itemDrop = ModContent.ItemType(); + if (Player.ZoneSnow && questFish == ModContent.ItemType() && attempt.uncommon) + itemDrop = ModContent.ItemType(); if (grabBagFish) { @@ -216,18 +303,8 @@ namespace CalamityMod.CalPlayer itemDrop = ModContent.ItemType(); else if (cavern) itemDrop = ModContent.ItemType(); - if (Main.hardMode) - { - // Fish of Light/Night are evenly split with Gemfish - if ((Player.ZoneCrimson || Player.ZoneCorrupt) && cavern && Main.rand.NextBool()) - itemDrop = ModContent.ItemType(); - else if (Player.ZoneHallow && cavern && Main.rand.NextBool()) - itemDrop = ModContent.ItemType(); - else if (Player.ZoneSnow) - itemDrop = ModContent.ItemType(); - else if (sky) - itemDrop = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); - } + if (Main.hardMode && sky) + itemDrop = ModContent.ItemType(); } // Increased chance of Enchanted Starfish if you don't have maximum mana @@ -284,6 +361,14 @@ namespace CalamityMod.CalPlayer if (Player.ZoneDesert && Main.rand.NextBool()) return; + int commonCatch = ModContent.ItemType(); + if (ZonePolypForest) + commonCatch = ModContent.ItemType(); + else if (ZoneGleamingBurrows) + commonCatch = ModContent.ItemType(); + else if (ZoneTimelessShores) + commonCatch = ModContent.ItemType(); + if (attempt.legendary) { List legendaryCatches = @@ -314,8 +399,10 @@ namespace CalamityMod.CalPlayer itemDrop = ModContent.ItemType(); else if (attempt.uncommon || attempt.rare) itemDrop = ModContent.ItemType(); + else if (Main.rand.NextBool()) // 50% chance the common fish is replaced with driftwood + itemDrop = ModContent.ItemType(); else - itemDrop = ModContent.ItemType(); + itemDrop = commonCatch; return; } // There is no complete fishing pool here, so most of it is vanilla default @@ -361,12 +448,12 @@ namespace CalamityMod.CalPlayer if (ZoneAbyss || ZoneSulphur) canSulphurFish = true; - Item item = Player.ActiveItem(); + Item item = Player.HeldItem; if (!canSulphurFish || item.fishingPole <= 0 || item.holdStyle != 1) fishingLevel = -1; - // If your bait is the Bloodworm, set the Fisherman's Pocket Guide to display Warning! - // This only happens when a fishing bobber projectile exists + // Set Fisherman's Pocket Guide to display "Warning!" with Bloodworm as bait + // This runs only while there is a fishing bobber; logic with no fishing bobber is handled in the ModifyDisplayParameters hook in the separate class below Player.displayedFishingInfo = Language.GetTextValue("GameUI.FishingWarning"); } } @@ -375,6 +462,10 @@ namespace CalamityMod.CalPlayer #region Modify Caught Fish public override void ModifyCaughtFish(Item fish) { + // Increases yeild of driftwood from the Sunken Sea + // ~7% chance that yeild is very high so that exhaustive fishing can allow for enough driftwood to make large builds + if (fish.type == ModContent.ItemType()) + fish.stack = ((Main.rand.NextBool(14) ? 20 : 1) * Main.rand.Next(8, 20 + 1)); // Increases the yield of potion ingredient fish with Alluring Bait if (alluringBait) { @@ -404,7 +495,29 @@ namespace CalamityMod.CalPlayer if (fishList.Contains(fish.type)) fish.stack += Main.rand.Next(1, 3 + 1); } + if (fish.type == ModContent.ItemType()) + fish.stack = Main.rand.Next(1, 6); } #endregion } + + public class BloodwormFishPowerWarning : GlobalInfoDisplay + { + // Set Fisherman's Pocket Guide to display "Warning!" with Bloodworm as bait + // This runs only while there is no fishing bobber; logic with a fishing bobber is handled in the GetFishingLevel hook above + public override void ModifyDisplayParameters(InfoDisplay currentDisplay, ref string displayValue, ref string displayName, ref Color displayColor, ref Color displayShadowColor) + { + if (currentDisplay == InfoDisplay.FishFinder) + { + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.owner == Main.myPlayer && p.bobber) + return; + } + + if (Main.LocalPlayer.GetFishingConditions().BaitItemType == ModContent.ItemType()) + displayValue = Language.GetTextValue("GameUI.FishingWarning"); + } + } + } } diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index a8f69fe751..6a03607d40 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -12,14 +12,20 @@ using CalamityMod.Dusts; using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.Aerospec; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.Daedalus; using CalamityMod.Items.Armor.Demonshade; +using CalamityMod.Items.Armor.Empyrean; +using CalamityMod.Items.Armor.GodSlayer; +using CalamityMod.Items.Armor.Hydrothermic; using CalamityMod.Items.Armor.LunicCorps; +using CalamityMod.Items.Armor.Reaver; using CalamityMod.Items.Armor.Silva; +using CalamityMod.Items.Armor.Sulphurous; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Armor.Victide; using CalamityMod.Items.Armor.Wulfrum; -using CalamityMod.Items.Mounts; -using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.VanillaArmorChanges; @@ -27,10 +33,12 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.NPCs; using CalamityMod.NPCs.Cryogen; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.Other; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; @@ -44,9 +52,12 @@ using Terraria.Audio; using Terraria.Chat; using Terraria.DataStructures; using Terraria.Graphics.Shaders; +using Terraria.GameContent.Creative; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Tools; namespace CalamityMod.CalPlayer { @@ -75,7 +86,7 @@ namespace CalamityMod.CalPlayer sVeilDust2.noLight = false; } - SoundEngine.PlaySound(SilvaHeadSummon.DispelSound, Player.Center); + SoundEngine.PlaySound(SilvaArmor.DispelSound, Player.Center); NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } @@ -133,7 +144,7 @@ namespace CalamityMod.CalPlayer NetMessage.SendData(MessageID.Dodge, -1, -1, null, Player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } - public void AbyssMirrorDodge(double dodgeDamageGateValuePercent, int dodgeDamageGateValue, int hitDamage) + public void AbyssMirrorDodge(double dodgeDamageGateValuePercent, int dodgeDamageGateValue, int hitDamage, Player.HurtInfo info) { double maxCooldownDurationDamagePercent = 0.5; int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); @@ -154,9 +165,9 @@ namespace CalamityMod.CalPlayer Player.GiveUniversalIFrames(abyssalMirrorDodgeIFrames, true); rogueStealth += 0.5f; - SoundEngine.PlaySound(SilvaHeadSummon.ActivationSound, Player.Center); + SoundEngine.PlaySound(SilvaArmor.ActivationSound, Player.Center); - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + var source = Player.GetSource_Accessory_OnHurt(FindAccessory(), info.DamageSource); for (int i = 0; i < 10; i++) { int damage = (int)Player.GetTotalDamage().ApplyTo(55); @@ -176,7 +187,7 @@ namespace CalamityMod.CalPlayer } } - public void EclipseMirrorDodge(double dodgeDamageGateValuePercent, int dodgeDamageGateValue, int hitDamage) + public void EclipseMirrorDodge(double dodgeDamageGateValuePercent, int dodgeDamageGateValue, int hitDamage, Player.HurtInfo info) { double maxCooldownDurationDamagePercent = 0.5; int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); @@ -199,7 +210,7 @@ namespace CalamityMod.CalPlayer rogueStealth += 0.5f; SoundEngine.PlaySound(SoundID.Item68, Player.Center); - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + var source = Player.GetSource_Accessory_OnHurt(FindAccessory(), info.DamageSource); int damage = (int)Player.GetTotalDamage().ApplyTo(2000); int eclipse = Projectile.NewProjectile(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Player.whoAmI); @@ -226,7 +237,7 @@ namespace CalamityMod.CalPlayer { for (int i = 0; i < 40; i++) { - Dust dust = Dust.NewDustPerfect(Player.Center + Utils.NextVector2Circular(Main.rand, 60f, 90f), 133); + Dust dust = Dust.NewDustPerfect(Player.Center + Utils.NextVector2Circular(Main.rand, 60f, 90f), DustID.Firework_Yellow); dust.velocity = Utils.NextVector2Circular(Main.rand, 4f, 4f); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.2f, 1.35f); @@ -243,7 +254,7 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), Main.zenithWorld ? Main.rand.Next(5000, 50000 + 1) : 0, 0, Player.whoAmI); } - if (hInferno) + if (holyInferno) { foreach (NPC n in Main.ActiveNPCs) { @@ -291,10 +302,10 @@ namespace CalamityMod.CalPlayer if (silvaSet && silvaCountdown > 0) { - if (silvaCountdown == silvaReviveDuration && !hasSilvaEffect) + if (silvaCountdown == SilvaArmor.ReviveDuration && !hasSilvaEffect) { - SoundEngine.PlaySound(SilvaHeadSummon.ActivationSound, Player.Center); - Player.AddBuff(ModContent.BuffType(), silvaReviveDuration); + SoundEngine.PlaySound(SilvaArmor.ActivationSound, Player.Center); + Player.AddBuff(ModContent.BuffType(), SilvaArmor.ReviveDuration); } hasSilvaEffect = true; @@ -331,6 +342,8 @@ namespace CalamityMod.CalPlayer Player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(3f)); Player.statLife = Player.statLifeMax2 * 3 / 10; + if (Player.statMana < 0) + Player.statMana = 0; SoundEngine.PlaySound(SoundID.Item92, Player.Center); @@ -350,7 +363,7 @@ namespace CalamityMod.CalPlayer { if (alcoholPoisoning) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AlcoholBig" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AlcoholBig" + Main.rand.Next(1, 2 + 1)).ToNetworkText(Player.name)); } if (vHex) { @@ -370,123 +383,123 @@ namespace CalamityMod.CalPlayer // if none of SCal's phases are detected somehow then it just uses the normal messages all the time } - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText(vHexKeyToUse).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText(vHexKeyToUse).ToNetworkText(Player.name)); } if (ZoneCalamity && Player.lavaWet) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.SearingLava" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.SearingLava" + Main.rand.Next(1, 2 + 1)).ToNetworkText(Player.name)); } - if (gsInferno) + if (godSlayerInferno) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.GodSlayerInferno" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.GodSlayerInferno" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (sulphurPoison) { if (!Main.rand.NextBool(4)) // 75% custom - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.SulphuricPoisoning" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.SulphuricPoisoning" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); else damageSource = PlayerDeathReason.ByOther(9); // 25% generic Poisoned death text } if (dragonFire) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Dragonfire" + Main.rand.Next(1, 4 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Dragonfire" + Main.rand.Next(1, 4 + 1)).ToNetworkText(Player.name)); } if (vermillionFlux) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.VermillionFlux" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.VermillionFlux" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (auricRebuke) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AuricRebuke" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AuricRebuke" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (staticDischarge) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.StaticDischarge" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.StaticDischarge" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (miracleBlight) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.MiracleBlight" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.MiracleBlight" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } - if (hInferno) + if (holyInferno) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HolyInferno").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HolyInferno").ToNetworkText(Player.name)); } - if (hFlames || banishingFire) + if (holyFlames || banishingFire) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HolyFlames" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HolyFlames" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (shadowflame) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Shadowflame").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Shadowflame").ToNetworkText(Player.name)); } if (daybroken) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Daybroken").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Daybroken").ToNetworkText(Player.name)); } - if (bBlood) + if (burningBlood) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BurningBlood" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BurningBlood" + Main.rand.Next(1, 2 + 1)).ToNetworkText(Player.name)); } if (brainRot) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BrainRot" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BrainRot" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (heavybleeding) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HeavyBleeding" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HeavyBleeding" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (laceration) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Laceration" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Laceration" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (elementalMix) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ElementalMix" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ElementalMix" + Main.rand.Next(1, 2 + 1)).ToNetworkText(Player.name)); } - if (cDepth) + if (crushDepth) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.CrushDepth" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.CrushDepth" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } - if (rTide) + if (riptide) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Riptide" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Riptide" + Main.rand.Next(1, 2 + 1)).ToNetworkText(Player.name)); } - if (hPressure) + if (hadopelagicPressure) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HadopelagicPressure" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HadopelagicPressure" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } - if (bFlames || weakBrimstoneFlames || demonicFlames) + if (brimstoneFlames || weakBrimstoneFlames || demonicFlames) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BrimstoneFlames" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BrimstoneFlames" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } - if (pFlames) + if (plague) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Plague" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Plague" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (astralInfection) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AstralInfection" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AstralInfection" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } if (nightwither) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Nightwither").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Nightwither").ToNetworkText(Player.name)); } if (vaporfied) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Vaporfied").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Vaporfied").ToNetworkText(Player.name)); } if (manaOverloader || ManaBurn) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ManaBurn").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ManaBurn").ToNetworkText(Player.name)); } if (witheredDebuff) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Withered").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Withered").ToNetworkText(Player.name)); } } - if (profanedCrystalBuffs && !profanedCrystalHide) + if (profanedCrystalBuffs && Player.Transformation().Type == ModContent.ItemType()) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ProfanedSoulCrystal").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ProfanedSoulCrystal").ToNetworkText(Player.name)); } // Leon Death Noise RE4 @@ -494,9 +507,27 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(LeonDeathNoiseRE4_ForGFB, Player.Center); if (NorfleetCounter > 3 && NorfleetCounter < 1000) - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Norfleet").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Norfleet").ToNetworkText(Player.name)); NorfleetCounter = 0; + if (damageSource.TryGetCausingEntity(out var Entity) && Entity is NPC && (Entity as NPC).type == ModContent.NPCType()) + { + var npc = Main.npc[damageSource.SourceNPCIndex]; + if (npc.ai[3] < 2) //Divinity Devourer + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.DivinityDevourer"+Main.rand.Next(1,4)).ToNetworkText(Player.name)); + } + else if (npc.ai[3] >= 3) + if (npc.life > npc.lifeMax / 4) //Dimensional Drive + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.DimensionalDrive").ToNetworkText(Player.name)); + } + else //Ultracosmic Maelstrom + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.UltracosmicMaelstrom" + Main.rand.Next(1, 3)).ToNetworkText(Player.name)); + } + } + if (NPC.AnyNPCs(ModContent.NPCType())) { if (sCalDeathCount < 51) @@ -510,6 +541,7 @@ namespace CalamityMod.CalPlayer #region Modify Hit NPC public override void ModifyHitNPCWithItem(Item item, NPC target, ref NPC.HitModifiers modifiers) { + modifiers.CritDamage += critDamage; // All Calamity multipliers are added together to prevent insane exponential stacking float totalDamageMult = 1f; @@ -532,7 +564,10 @@ namespace CalamityMod.CalPlayer // FinalDamage cannot be used for the intended effect because there is no way to access the actual damage of the hit CalamityGlobalNPC cgn = target.Calamity(); if (yellowCandle && cgn.DR < 0.99f && target.takenDamageMultiplier > 0.05f) - modifiers.ModifyHitInfo += CirrusYellowCandleBuff.ModifyHitInfo_Spite; + modifiers.ModifyHitInfo += YellowCandleBuff.ModifyHitInfo_Spite; + + if (Player.Calamity().scionsCurio && item.CountsAsClass()) + target.Calamity().scionsCurioEffected = true; // Frost Armor's rework gives +X% melee damage and +Y% ranged damage based on distance, where X+Y = 15. if (frostSet) @@ -591,6 +626,8 @@ namespace CalamityMod.CalPlayer { if (proj.npcProj || proj.trap) return; + + modifiers.CritDamage += critDamage; // All Calamity multipliers are added together to prevent insane exponential stacking float totalDamageMult = 1f; @@ -614,24 +651,15 @@ namespace CalamityMod.CalPlayer // FinalDamage cannot be used for the intended effect because there is no way to access the actual damage of the hit CalamityGlobalNPC cgn = target.Calamity(); if (yellowCandle && cgn.DR < 0.99f && target.takenDamageMultiplier > 0.05f) - modifiers.ModifyHitInfo += CirrusYellowCandleBuff.ModifyHitInfo_Spite; + modifiers.ModifyHitInfo += YellowCandleBuff.ModifyHitInfo_Spite; // Stealth strike damage multipliers are applied here. // TODO -- stealth should be its own damage class and this should be applied as player StealthDamage *= XYZ if (proj.Calamity().stealthStrike && proj.CountsAsClass()) modifiers.SourceDamage *= (float)bonusStealthDamage + 1; // Default bonusStealthDamage is 0, a 1 has to be added to take the damage of the weapon. - // Screwdriver adds 5% bonus damage to all piercing projectiles. - if (screwdriver) - { - if (proj.penetrate > 1 || proj.penetrate == -1) - modifiers.ScalingBonusDamage += Screwdriver.PiercingDamageBuff; - } - - // Calamity buffs Inferno Fork by 20%. This is multiplicative because it's supposed to be a buff to the weapon's base damage. - // However, because the weapon is coded like spaghetti, you have to multiply the explosion's damage too. - if (proj.type == ProjectileID.InfernoFriendlyBlast) - modifiers.SourceDamage *= 1.2f; + if (Player.Calamity().scionsCurio && proj.CountsAsClass()) + target.Calamity().scionsCurioEffected = true; // Frost Armor's rework gives +X% melee damage and +Y% ranged damage based on distance, where X+Y = 15. if (frostSet) @@ -696,9 +724,9 @@ namespace CalamityMod.CalPlayer bool isSummon = proj.CountsAsClass(); if (isSummon) { - Item heldItem = Player.ActiveItem(); + Item heldItem = Player.HeldItem; - if (CalamityUtils.ShouldTriggerSummonPenalty(Player, heldItem) && !DisabledSummonerNerfMinionList.Includes(proj.type)) + if (CalamityUtils.ShouldTriggerSummonPenalty(Player, heldItem) && !CalamityProjectileSets.MinionWhichIgnoresSummonerNerf[proj.type]) modifiers.FinalDamage *= BalancingConstants.SummonerCrossClassNerf; } } @@ -713,7 +741,7 @@ namespace CalamityMod.CalPlayer // Enemies deal less contact damage while sick, due to being weakened. if (npc.poisoned) { - float damageReductionFromPoison = npc.Calamity().irradiated > 0 ? 0.075f : 0.05f; + float damageReductionFromPoison = (float)((npc.Calamity().irradiated ? npc.Calamity().irradiatedContactBoost : 1) * 0.05f); if (npc.Calamity().VulnerableToSickness.HasValue) { if (npc.Calamity().VulnerableToSickness.Value) @@ -728,7 +756,7 @@ namespace CalamityMod.CalPlayer if (npc.venom) { - float damageReductionFromVenom = npc.Calamity().irradiated > 0 ? 0.075f : 0.05f; + float damageReductionFromVenom = (float)((npc.Calamity().irradiated ? npc.Calamity().irradiatedContactBoost : 1) * 0.05f); if (npc.Calamity().VulnerableToSickness.HasValue) { if (npc.Calamity().VulnerableToSickness.Value) @@ -741,9 +769,9 @@ namespace CalamityMod.CalPlayer modifiers.SourceDamage *= damageReductionFromVenom; } - if (npc.Calamity().astralInfection > 0) + if (npc.Calamity().astralInfection) { - float damageReductionFromAstralInfection = npc.Calamity().irradiated > 0 ? 0.075f : 0.05f; + float damageReductionFromAstralInfection = (float)((npc.Calamity().irradiated ? npc.Calamity().irradiatedContactBoost : 1) * 0.05f); if (npc.Calamity().VulnerableToSickness.HasValue) { if (npc.Calamity().VulnerableToSickness.Value) @@ -756,9 +784,9 @@ namespace CalamityMod.CalPlayer modifiers.SourceDamage *= damageReductionFromAstralInfection; } - if (npc.Calamity().pFlames > 0) + if (npc.Calamity().plague) { - float damageReductionFromPlague = npc.Calamity().irradiated > 0 ? 0.075f : 0.05f; + float damageReductionFromPlague = (float)((npc.Calamity().irradiated? npc.Calamity().irradiatedContactBoost : 1) * 0.05f); if (npc.Calamity().VulnerableToSickness.HasValue) { if (npc.Calamity().VulnerableToSickness.Value) @@ -771,9 +799,9 @@ namespace CalamityMod.CalPlayer modifiers.SourceDamage *= damageReductionFromPlague; } - if (npc.Calamity().wDeath > 0) + if (npc.Calamity().whisperingDeath) { - float damageReductionFromWhisperingDeath = npc.Calamity().irradiated > 0 ? 0.15f : 0.1f; + float damageReductionFromWhisperingDeath = (float)((npc.Calamity().irradiated ? npc.Calamity().irradiatedContactBoost : 1) * 0.1f); if (npc.Calamity().VulnerableToSickness.HasValue) { if (npc.Calamity().VulnerableToSickness.Value) @@ -796,47 +824,24 @@ namespace CalamityMod.CalPlayer // Can't have any cooldowns here because dodges grrrrr.... if (fleshTotem && !Player.HasCooldown(Cooldowns.FleshTotem.ID) && TotalEnergyShielding <= 0) - contactDamageReduction += 0.5; + modifiers.FinalDamage *= 0.5f; if (tarragonCloak && tarraMelee && !Player.HasCooldown(Cooldowns.TarragonCloak.ID)) - contactDamageReduction += Buffs.StatBuffs.TarragonCloak.ContactDamageReduction; + modifiers.FinalDamage *= (1f - TarragonHeadMelee.CloakContactDamageReduction); if (bloodflareMelee && bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID)) - contactDamageReduction += 0.5; + modifiers.FinalDamage *= (1f - BloodflareHeadMelee.FrenzyContactDamageReduction); - if (npc.Calamity().tSad > 0) - contactDamageReduction += 0.5; + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.HeldItem.type == ModContent.ItemType()) + modifiers.FinalDamage *= 0.5f; - if (eskimoSet) - { - if (npc.coldDamage) - contactDamageReduction += 0.1; - } - - if (trinketOfChiBuff) - contactDamageReduction += 0.04; - - // Fearmonger set provides 15% multiplicative DR that ignores caps during the Holiday Moons. - // To prevent abuse, this effect does not work if there are any bosses alive. - if (fearmongerSet && !areThereAnyDamnBosses && (Main.pumpkinMoon || Main.snowMoon)) - contactDamageReduction += 0.15; - - if (abyssalDivingSuitPlates) - contactDamageReduction += AbyssalDivingSuit.PlatesAllDamageReduction - abyssalDivingSuitPlateHits * AbyssalDivingSuit.PlatesHitDecay; - - if (aquaticHeartIce) - contactDamageReduction += AquaticHeart.IceShieldAllDamageReduction; - - if (encased) - contactDamageReduction += PermafrostsConcoction.EncasedAllDamageReduction; - - if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.ActiveItem().type == ModContent.ItemType()) - contactDamageReduction += 0.5; + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.HeldItem.type == ModContent.ItemType()) + modifiers.FinalDamage *= RelicOfConvergence.IncomingDamageMultiplier; bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability); if (theBee && theBeeCooldown <= 0 && lifeAndShieldCondition) { - contactDamageReduction += 0.5; + modifiers.FinalDamage *= 0.5f; shouldTriggerBeeCooldown = true; } @@ -851,49 +856,7 @@ namespace CalamityMod.CalPlayer // If the shield never breaks, you never lose full Adrenaline, meaning you keep the DR forever and are functionally immortal. // This intentionally gives Adrenaline much-needed anti-synergy with energy shields, because they make gaining Adrenaline much safer. if ((fullAdrenWithoutDH || usingNanomachinesWithDH) && TotalEnergyShielding <= 0) - contactDamageReduction += this.GetAdrenalineDR(); - } - - if (Player.mount.Active && (Player.mount.Type == ModContent.MountType() || Player.mount.Type == ModContent.MountType()) && Math.Abs(Player.velocity.X) > Player.mount.RunSpeed / 2f) - contactDamageReduction += 0.1; - - if (vHex) - contactDamageReduction -= 0.1; - - if (irradiated) - contactDamageReduction -= 0.1; - - if (corrEffigy) - contactDamageReduction -= CorruptionEffigy.DamageReductionLoss; - - // 10% is converted to 9%, 25% is converted to 20%, 50% is converted to 33%, 75% is converted to 43%, 100% is converted to 50% - if (contactDamageReduction > 0D) - { - if (aCrunch) - contactDamageReduction *= (double)ArmorCrunch.MultiplicativeDamageReductionPlayer; - if (crumble) - contactDamageReduction *= (double)Crumbling.MultiplicativeDamageReductionPlayer; - - // Contact damage reduction is reduced by DR Damage, which itself is proportional to defense damage - // In GFB, as defense damage is uncapped, DR damage is also uncapped. - int currentDefense = Player.GetCurrentDefense(false); - if (totalDefenseDamage > 0 && currentDefense > 0) - { - double drDamageRatio = CurrentDefenseDamage / (double)currentDefense; - if (!Main.getGoodWorld && drDamageRatio > 1D) - drDamageRatio = 1D; - - contactDamageReduction *= 1D - drDamageRatio; - if (!Main.getGoodWorld && contactDamageReduction < 0D) - contactDamageReduction = 0D; - } - - // Scale with base damage reduction - if (Player.endurance > 0) - contactDamageReduction *= 1f - Player.endurance; - - contactDamageReduction = 1D / (1D + contactDamageReduction); - modifiers.SourceDamage *= (float)contactDamageReduction; + modifiers.IncomingDamageMultiplier *= (1f - this.GetAdrenalineDR()); } if (Main.hardMode && Main.expertMode) @@ -908,13 +871,50 @@ namespace CalamityMod.CalPlayer #region Modify Hit By Proj public override void ModifyHitByProjectile(Projectile proj, ref Player.HurtModifiers modifiers) { - if (!ProjectileDestroyExceptionsList.Includes(proj.type) && proj.active && !proj.friendly && proj.hostile && proj.damage > 0) + //This goes first so it activated before dodges or any other effects, as these projectiles aren't supposed to "hit" the player, but just inflict debuffs + if (CalamityWorld.revenge) + { + if (proj.type == ProjectileID.CultistBossIceMist && proj.ai[1] == 1f) // Main ice mists only; no shards + { + Player.AddBuff(BuffID.Frozen, 120); + modifiers.Cancel(); + return; + } + else if (proj.type == ProjectileID.CultistBossIceMist && proj.ai[1] != 1f) // Ice Mist shards + { + Player.AddBuff(BuffID.Chilled, 240); + modifiers.Cancel(); + return; + } + } + if (proj.active && proj.hostile && modifiers.Dodgeable && proj.damage > 0) { double dodgeDamageGateValuePercent = 0.05; int dodgeDamageGateValue = (int)Math.Round(Player.statLifeMax2 * dodgeDamageGateValuePercent); + // This hook is applied before tML applies the vanilla difficulty multipliers. This means the "proj.damage" value here + // is usually significantly lower than the damage the projectile "actually" deals. + // To obtain the correct damage value for a cancelled hit, the corresponding multipliers are copied from tML + // to simulate the "actual" damage of the projectile. + // Note: Banner buffs, cold resistance, and modded modifiers are not included in this "actual" damage calculation, + // even though in real tML hooks they might be applied earlier than or together with difficulty multipliers. + int actualProjDamage = proj.damage; + if (!proj.reflected && !ProjectileID.Sets.PlayerHurtDamageIgnoresDifficultyScaling[proj.type]) + { + float damageMult = Main.GameModeInfo.EnemyDamageMultiplier; + if (Main.GameModeInfo.IsJourneyMode) + { + var power = CreativePowerManager.Instance.GetPower(); + if (power.GetIsUnlocked()) + damageMult = power.StrengthMultiplierToGiveNPCs; + } + + // in real tML, the factor 2 is applied in Projectile.Damage() + actualProjDamage = (int)Math.Floor(2 * damageMult * (float)actualProjDamage); + } + // Reflects count as dodges. They share the timer and can be disabled by Armageddon right click. - if (!disableAllDodges && !Player.HasCooldown(GlobalDodge.ID) && proj.damage >= dodgeDamageGateValue) + if (!disableAllDodges && !Player.HasCooldown(GlobalDodge.ID) && actualProjDamage >= dodgeDamageGateValue) { double maxCooldownDurationDamagePercent = 0.5; int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); @@ -923,24 +923,26 @@ namespace CalamityMod.CalPlayer if (maxCooldownDurationDamageValue <= 0) maxCooldownDurationDamageValue = 1; - float cooldownDurationScalar = MathHelper.Clamp((proj.damage - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); + float cooldownDurationScalar = MathHelper.Clamp((actualProjDamage - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); // The Evolution if (evolution) { - proj.hostile = false; - proj.friendly = true; - proj.damage *= 10; - proj.velocity *= -2f; - proj.extraUpdates += 1; - proj.penetrate = 1; + if (Player.whoAmI == Main.myPlayer) + { + var source = Player.GetSource_Accessory_OnHurt(FindAccessory(), modifiers.DamageSource); + int mirrorDamage = (int)MathHelper.Min(actualProjDamage, 1000) * 50; + for (var i = 0; i < 5; i++) + { + Projectile.NewProjectile(source, Player.Center + Vector2.UnitX.RotatedBy(MathHelper.TwoPi * (i / 10f)), Vector2.Zero, ModContent.ProjectileType(), mirrorDamage, 5, Main.myPlayer, 1); + } + } - // 17APR2024: Ozzatron: The Evolution is a reflect which also functions as a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. - int evolutionIFrames = Player.ComputeReflectIFrames(); + //Doze - This gives the same iframes as vanilla dodges, including accounting for cross necklace. + int evolutionIFrames = Player.ComputeDodgeIFrames(); Player.GiveUniversalIFrames(evolutionIFrames, true); modifiers.Cancel(); - evolutionLifeRegenCounter = 300; projTypeJustHitBy = proj.type; int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.EvolutionReflectCooldownMin, BalancingConstants.EvolutionReflectCooldownMax, cooldownDurationScalar); @@ -948,6 +950,22 @@ namespace CalamityMod.CalPlayer return; } + else if (daedalusReflect && !CalamityProjectileSets.ShouldNotBeReflected[proj.type] && !modifiers.PvP && !proj.friendly) + { + proj.hostile = false; + proj.friendly = true; + proj.damage = actualProjDamage; + proj.velocity *= -1f; + proj.penetrate = 1; + + // 17APR2024: Ozzatron: The Daedalus Reflect set bonus also functions as a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. + int daedalusReflectIFrames = Player.ComputeReflectIFrames(); + Player.GiveUniversalIFrames(daedalusReflectIFrames, true); + modifiers.Cancel(); + + int cooldownDuration = (int)MathHelper.Lerp(DaedalusHeadMelee.ReflectCooldownMin, DaedalusHeadMelee.ReflectCooldownMax, cooldownDurationScalar); + Player.AddCooldown(GlobalDodge.ID, cooldownDuration); + } } } @@ -956,7 +974,7 @@ namespace CalamityMod.CalPlayer Projectile pro = Main.projectile.AsEnumerable().Where(projectile => projectile.friendly && projectile.owner == Player.whoAmI && projectile.type == ModContent.ProjectileType()).First(); phantomicBulwarkCooldown = 1800; // 30 second cooldown pro.Kill(); - projectileDamageReduction += 0.2; + modifiers.FinalDamage *= 0.8f; } if (trueVHex) @@ -977,30 +995,23 @@ namespace CalamityMod.CalPlayer // Reduce damage from vanilla traps // Explosives - // 350 in normal, 450 in expert + // 350 damage if (proj.type == ProjectileID.Explosives) - modifiers.SourceDamage *= (Main.expertMode ? 0.225f : 0.35f); + modifiers.SourceDamage *= 0.7f; // Rolling Cacti - // 45 in normal, 65 in expert for cactus - // 30 in normal, 36 in expert for spikes + // 42 in normal, 84 in expert for cactus + // 36 in normal, 72 in expert for spikes else if (proj.type == ProjectileID.RollingCactus || proj.type == ProjectileID.RollingCactusSpike) - modifiers.SourceDamage *= (Main.expertMode ? 0.3f : 0.5f); + modifiers.SourceDamage *= 0.6f; - // Normal Boulders and Temple traps - if (Main.expertMode) + // Boulders + if (Main.expertMode && !areThereAnyDamnBosses) { - // 140 in normal, 182 in expert, 273 in master - if (proj.type == ProjectileID.Boulder || proj.type == ProjectileID.MiniBoulder) - modifiers.SourceDamage *= 0.65f; - - // 80 in normal, 100 in expert, 150 in master - else if (proj.type == ProjectileID.SpikyBallTrap || proj.type == ProjectileID.FlamethrowerTrap || proj.type == ProjectileID.FlamesTrap || proj.type == ProjectileID.PoisonDartTrap) - modifiers.SourceDamage *= 0.625f; - - // 120 in normal, 144 in expert, 216 in master - else if (proj.type == ProjectileID.SpearTrap) - modifiers.SourceDamage *= 0.6f; + // 140 in normal, 210 in expert, 315 in master for boulder + // 104 in normal, 156 in expert, 234 in master for mini boulder + if (proj.type == ProjectileID.Boulder || proj.type == ProjectileID.MiniBoulder || proj.type == ProjectileID.BouncyBoulder || proj.type == ProjectileID.LifeCrystalBoulder) + modifiers.SourceDamage *= 0.75f; } bool isFallingBlock = (proj.type == ProjectileID.SandBallFalling) || (proj.type == ProjectileID.SiltBall) || (proj.type == ProjectileID.AshBallFalling) || @@ -1013,15 +1024,11 @@ namespace CalamityMod.CalPlayer if (Player.Calamity().trapProtection && isIgnoredTrap) modifiers.Cancel(); - bool isReducedTrap = (proj.type == ProjectileID.Boulder) || (proj.type == ProjectileID.BouncyBoulder) || (proj.type == ProjectileID.LifeCrystalBoulder) || - (proj.type == ProjectileID.MiniBoulder) || (proj.type == ProjectileID.MoonBoulder) || (proj.type == ProjectileID.SpearTrap) || - (proj.type == ProjectileID.SpikyBallTrap) || (proj.type == ProjectileID.GeyserTrap) || (proj.type == ProjectileID.FlamethrowerTrap) || - (proj.type == ProjectileID.RollingCactus) || (proj.type == ProjectileID.RollingCactusSpike) || (proj.type == ProjectileID.Explosives) || - (proj.type == ProjectileID.TNTBarrel) || (proj.type == ProjectileID.Landmine) || (proj.type == ModContent.ProjectileType()) || (proj.type == ProjectileID.FlamesTrap); // Fun fact: flamethrower traps fire proj 188, NOT ProjectileID.FlamethrowerTrap :) + bool isReducedTrap = (proj.trap || proj.type == ProjectileID.RollingCactusSpike || proj.type == ProjectileID.Landmine) && !isIgnoredTrap; if (Player.Calamity().trapProtection && isReducedTrap) - modifiers.SourceDamage *= 0.35f; + modifiers.SourceDamage *= (1f - ArchaicPowder.TrapDamageReduction); - // Reduce damage dealt by rainbow trails depending on how faded they are. + // Reduce damage dealt by rainbow trails if (proj.type == ProjectileID.HallowBossLastingRainbow) { // Find the oldPos of the projectile that is intersecting the player hitbox. @@ -1036,11 +1043,10 @@ namespace CalamityMod.CalPlayer hitbox.X = (int)trailHitbox.X; hitbox.Y = (int)trailHitbox.Y; - // Adjust damage based on what part of the trail intersected the player hitbox. if (hitbox.Intersects(Player.Hitbox)) { if (k > startOfDamageFalloff) - modifiers.SourceDamage *= MathHelper.Lerp(0.4f, 1f, 1f - (k - startOfDamageFalloff) / (float)(trailLength - startOfDamageFalloff)); + modifiers.SourceDamage *= EmpressofLightAI.EverlastingRainbowTrailDamageMult; break; } @@ -1056,40 +1062,16 @@ namespace CalamityMod.CalPlayer if (evolution) { if (proj.type == projTypeJustHitBy) - projectileDamageReduction += 0.2; + modifiers.FinalDamage *= 0.75f; } - if (!ProjectileDestroyExceptionsList.Includes(proj.type) && proj.active && !proj.friendly && proj.hostile && proj.damage > 0) - { - // Daedalus Reflect counts as a reflect but doesn't actually stop you from taking damage - if (daedalusReflect && !disableAllDodges && !evolution && !Player.HasCooldown(GlobalDodge.ID)) - projectileDamageReduction += 0.5; - } - - if (trinketOfChiBuff) - projectileDamageReduction += 0.04; - - // Fearmonger set provides 15% multiplicative DR that ignores caps during the Holiday Moons. - // To prevent abuse, this effect does not work if there are any bosses alive. - if (fearmongerSet && !areThereAnyDamnBosses && (Main.pumpkinMoon || Main.snowMoon)) - projectileDamageReduction += 0.15; - - if (abyssalDivingSuitPlates) - projectileDamageReduction += AbyssalDivingSuit.PlatesAllDamageReduction - abyssalDivingSuitPlateHits * AbyssalDivingSuit.PlatesHitDecay; - - if (aquaticHeartIce) - projectileDamageReduction += AquaticHeart.IceShieldAllDamageReduction; - - if (encased) - projectileDamageReduction += PermafrostsConcoction.EncasedAllDamageReduction; - - if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.ActiveItem().type == ModContent.ItemType()) - projectileDamageReduction += 0.5; + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && Player.HeldItem.type == ModContent.ItemType()) + modifiers.FinalDamage *= 0.5f; bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability); if (theBee && theBeeCooldown <= 0 && lifeAndShieldCondition) { - projectileDamageReduction += 0.5; + modifiers.FinalDamage *= 0.5f; shouldTriggerBeeCooldown = true; } @@ -1104,12 +1086,9 @@ namespace CalamityMod.CalPlayer // If the shield never breaks, you never lose full Adrenaline, meaning you keep the DR forever and are functionally immortal. // This intentionally gives Adrenaline much-needed anti-synergy with energy shields, because they make gaining Adrenaline much safer. if ((fullAdrenWithoutDH || usingNanomachinesWithDH) && TotalEnergyShielding <= 0) - projectileDamageReduction += this.GetAdrenalineDR(); + modifiers.IncomingDamageMultiplier *= (1f - this.GetAdrenalineDR()); } - if (Player.mount.Active && (Player.mount.Type == ModContent.MountType() || Player.mount.Type == ModContent.MountType()) && Math.Abs(Player.velocity.X) > Player.mount.RunSpeed / 2f) - projectileDamageReduction += 0.1; - // Damage reduction from Shield of the High Ruler if facing the projectile that just hit. // If the projectile is in the exact center of the player on the X axis YOU GET NOTHING, GOOD DAY, SIR! if (copyrightInfringementShield) @@ -1119,53 +1098,14 @@ namespace CalamityMod.CalPlayer if (Player.direction == 1) { if (projectileRight) - projectileDamageReduction += 0.15; + modifiers.FinalDamage *= 0.85f; } else { if (projectileLeft) - projectileDamageReduction += 0.15; + modifiers.FinalDamage *= 0.85f; } } - - if (vHex) - projectileDamageReduction -= 0.1; - - if (irradiated) - projectileDamageReduction -= 0.1; - - if (corrEffigy) - projectileDamageReduction -= CorruptionEffigy.DamageReductionLoss; - - // 10% is converted to 9%, 25% is converted to 20%, 50% is converted to 33%, 75% is converted to 43%, 100% is converted to 50% - if (projectileDamageReduction > 0D) - { - if (aCrunch) - projectileDamageReduction *= (double)ArmorCrunch.MultiplicativeDamageReductionPlayer; - if (crumble) - projectileDamageReduction *= (double)Crumbling.MultiplicativeDamageReductionPlayer; - - // Projectile damage reduction is reduced by DR Damage, which itself is proportional to defense damage - int currentDefense = Player.GetCurrentDefense(false); - if (totalDefenseDamage > 0 && currentDefense > 0) - { - double drDamageRatio = CurrentDefenseDamage / (double)currentDefense; - if (drDamageRatio > 1D) - drDamageRatio = 1D; - - projectileDamageReduction *= 1D - drDamageRatio; - - if (projectileDamageReduction < 0D) - projectileDamageReduction = 0D; - } - - // Scale with base damage reduction - if (Player.endurance > 0) - projectileDamageReduction *= 1f - Player.endurance; - - projectileDamageReduction = 1D / (1D + projectileDamageReduction); - modifiers.SourceDamage *= (float)projectileDamageReduction; - } } #endregion @@ -1197,8 +1137,8 @@ namespace CalamityMod.CalPlayer Vector2 pushVel = Utils.DirectionTo(Player.Center, npc.Center) * 7; if (!npc.dontTakeDamage) { - int onHitDamage = (int)Player.GetBestClassDamage().ApplyTo(40); - Projectile revenge = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, 0f, Player.whoAmI, npc.whoAmI, pushVel.X, pushVel.Y); + int onHitDamage = (int)Player.GetBestClassDamage().ApplyTo(CrawCarapace.ThornsDamage); + Projectile.NewProjectile(Player.GetSource_Accessory_OnHurt(FindAccessory(), npc), npc.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, 0f, Player.whoAmI, npc.whoAmI, pushVel.X, pushVel.Y); } SoundEngine.PlaySound(SoundID.NPCHit33 with { Volume = 0.5f }, Player.Center); @@ -1222,9 +1162,9 @@ namespace CalamityMod.CalPlayer Vector2 pushVel = Utils.DirectionTo(Player.Center, npc.Center) * 15; if (!npc.dontTakeDamage) { - int onHitDamage = (int)Player.GetBestClassDamage().ApplyTo(250); - Projectile revenge = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, -1f, Player.whoAmI, npc.whoAmI, pushVel.X, pushVel.Y); - + int onHitDamage = (int)Player.GetBestClassDamage().ApplyTo(Baroclaw.ThornsDamage); + Projectile.NewProjectile(Player.GetSource_Accessory_OnHurt(FindAccessory(), npc), npc.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, -1f, Player.whoAmI, npc.whoAmI, pushVel.X, pushVel.Y); + npc.AddBuff(ModContent.BuffType(), 900); npc.AddBuff(ModContent.BuffType(), 900); } @@ -1244,7 +1184,7 @@ namespace CalamityMod.CalPlayer if (i % 3 == 0) { - Dust dust = Dust.NewDustPerfect(fxPos, 278, dustVel, 0, default, Main.rand.NextFloat(0.75f, 1.1f)); + Dust dust = Dust.NewDustPerfect(fxPos, DustID.FireworksRGB, dustVel, 0, default, Main.rand.NextFloat(0.75f, 1.1f)); dust.noGravity = true; dust.color = Color.Gold; dust.noGravity = false; @@ -1257,9 +1197,9 @@ namespace CalamityMod.CalPlayer Vector2 pushVel = Utils.DirectionTo(Player.Center, npc.Center) * 22; if (!npc.dontTakeDamage) { - int onHitDamage = (int)Player.GetBestClassDamage().ApplyTo(350); - Projectile revenge = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, -1, Player.whoAmI, npc.whoAmI, pushVel.X, pushVel.Y); - + int onHitDamage = (int)Player.GetBestClassDamage().ApplyTo(TheAbsorber.ThornsDamage); + Projectile.NewProjectile(Player.GetSource_Accessory_OnHurt(FindAccessory(), npc), npc.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, -1f, Player.whoAmI, npc.whoAmI, pushVel.X, pushVel.Y); + npc.AddBuff(ModContent.BuffType(), 900); } SoundEngine.PlaySound(AbsorberHit, Player.Center); @@ -1306,7 +1246,7 @@ namespace CalamityMod.CalPlayer if (Main.npc[proj.Calamity().ParentNPCIndex].active) { if (sulphurSet) - Main.npc[proj.Calamity().ParentNPCIndex].AddBuff(BuffID.Poisoned, 60); + Main.npc[proj.Calamity().ParentNPCIndex].AddBuff(BuffID.Poisoned, SulphurousHelmet.SetBonusPoisonDuration); if (ilSpark) Main.npc[proj.Calamity().ParentNPCIndex].Calamity().shocked = 120; } @@ -1369,134 +1309,61 @@ namespace CalamityMod.CalPlayer { Player.AddBuff(BuffID.BrokenArmor, 600); } - else if (proj.type == ProjectileID.DeathLaser || proj.type == ProjectileID.RocketSkeleton || proj.type == ProjectileID.BombSkeletronPrime) + else if (proj.type == ProjectileID.DesertDjinnCurse) { - Player.AddBuff(BuffID.OnFire, 180); - } - else if (proj.type == ProjectileID.Skull) - { - Player.AddBuff(BuffID.Weak, 180); - } - else if (proj.type == ProjectileID.CursedFlameHostile || proj.type == ProjectileID.EyeFire) - { - // Guaranteed Cursed Inferno for 1 second (vanilla also has a 68.75% chance of Cursed Inferno for 2 to 3 seconds) - Player.AddBuff(BuffID.CursedInferno, 60); - } - else if (proj.type == ProjectileID.Stinger || proj.type == ProjectileID.QueenBeeStinger) - { - // 66.6% chance of Poison for 3 seconds, 1 guaranteed second of Poison otherwise (vanilla also has a 33.3% chance of Poison for 10 seconds) - if (Main.rand.Next(3) > 0) - Player.AddBuff(BuffID.Poisoned, 180); - else - Player.AddBuff(BuffID.Poisoned, 60); - } - else if (proj.type == ProjectileID.PoisonSeedPlantera) - { - // 75% chance of Poison for 3 to 5 seconds, guaranteed Poison for 2 seconds (vanilla also has a 50% chance of Poison for 3 to 7 seconds) - if (Main.rand.Next(4) > 0) - Player.AddBuff(BuffID.Poisoned, Main.rand.Next(180, 301)); - else - Player.AddBuff(BuffID.Poisoned, 120); - } - else if (proj.type == ProjectileID.ThornBall) - { - Player.AddBuff(BuffID.Poisoned, 300); - } - else if (proj.type == ProjectileID.CultistBossFireBall) - { - Player.AddBuff(ModContent.BuffType(), 120); - } - else if (proj.type == ProjectileID.CultistBossIceMist) - { - if (!Player.frozen) - Player.AddBuff(BuffID.Frozen, 60); - - Player.AddBuff(BuffID.Chilled, 180); - } - else if (proj.type == ProjectileID.CultistBossLightningOrbArc) - { - Player.AddBuff(BuffID.Electrified, 120); - } - else if (proj.type == ProjectileID.AncientDoomProjectile) - { - Player.AddBuff(ModContent.BuffType(), 120); - } - else if (proj.type == ProjectileID.CultistBossFireBallClone) - { - Player.AddBuff(ModContent.BuffType(), 120); - } - else if (proj.type == ProjectileID.PhantasmalBolt || proj.type == ProjectileID.PhantasmalEye) - { - Player.AddBuff(ModContent.BuffType(), 60); - } - else if (proj.type == ProjectileID.PhantasmalSphere) - { - Player.AddBuff(ModContent.BuffType(), 120); - } - else if (proj.type == ProjectileID.PhantasmalDeathray) - { - Player.AddBuff(ModContent.BuffType(), 300); - } - else if ((proj.type == ProjectileID.FairyQueenLance || proj.type == ProjectileID.HallowBossRainbowStreak || proj.type == ProjectileID.HallowBossSplitShotCore) && NPC.ShouldEmpressBeEnraged()) - { - Player.AddBuff(ModContent.BuffType(), 60); - } - else if (proj.type == ProjectileID.HallowBossLastingRainbow && NPC.ShouldEmpressBeEnraged()) - { - Player.AddBuff(ModContent.BuffType(), 120); - } - else if (proj.type == ProjectileID.FairyQueenSunDance && NPC.ShouldEmpressBeEnraged()) - { - Player.AddBuff(ModContent.BuffType(), 180); + Player.AddBuff(BuffID.Cursed, 180); } else if (proj.type == ProjectileID.BloodNautilusShot) { - Player.AddBuff(ModContent.BuffType(), 120); + Player.AddBuff(ModContent.BuffType(), 240); } else if (proj.type == ProjectileID.BloodShot) { - Player.AddBuff(ModContent.BuffType(), 60); + Player.AddBuff(ModContent.BuffType(), 180); } else if (proj.type == ProjectileID.RuneBlast && Main.zenithWorld) { Player.AddBuff(ModContent.BuffType(), 600); } - } - // As these reflects do not cancel damage, they need to be in OnHit rather than ModifyHit - if (!ProjectileDestroyExceptionsList.Includes(proj.type) && proj.active && !proj.friendly && proj.hostile && hurtInfo.Damage > 0) - { - double dodgeDamageGateValuePercent = 0.05; - int dodgeDamageGateValue = (int)Math.Round(Player.statLifeMax2 * dodgeDamageGateValuePercent); - - // Reflects count as dodges. They share the timer and can be disabled by global dodge disabling effects. - if (!disableAllDodges && !Player.HasCooldown(GlobalDodge.ID) && proj.damage >= dodgeDamageGateValue) + if (CalamityWorld.revenge) { - double maxCooldownDurationDamagePercent = 0.5; - int maxCooldownDurationDamageValue = (int)Math.Round(Player.statLifeMax2 * (maxCooldownDurationDamagePercent - dodgeDamageGateValuePercent)); - - // Just in case... - if (maxCooldownDurationDamageValue <= 0) - maxCooldownDurationDamageValue = 1; - - float cooldownDurationScalar = MathHelper.Clamp((proj.damage - dodgeDamageGateValue) / (float)maxCooldownDurationDamageValue, 0f, 1f); - - if (daedalusReflect && !evolution) + if (proj.type == ProjectileID.CursedFlameHostile || proj.type == ProjectileID.EyeFire) { - proj.hostile = false; - proj.friendly = true; - proj.velocity *= -1f; - proj.penetrate = 1; - - // 17APR2024: Ozzatron: The Daedalus Reflect set bonus also functions as a dodge. It uses vanilla dodge iframes and benefits from Cross Necklace. - int daedalusReflectIFrames = Player.ComputeReflectIFrames(); - Player.GiveUniversalIFrames(daedalusReflectIFrames, true); - - int cooldownDuration = (int)MathHelper.Lerp(BalancingConstants.DaedalusReflectCooldownMin, BalancingConstants.DaedalusReflectCooldownMax, cooldownDurationScalar); - Player.AddCooldown(GlobalDodge.ID, cooldownDuration); + // Guaranteed Cursed Inferno for 1 second (vanilla also has a 68.75% chance of Cursed Inferno for 2 to 3 seconds) + Player.AddBuff(BuffID.CursedInferno, 60); + } + else if (proj.type == ProjectileID.ThornBall) + { + Player.AddBuff(BuffID.Venom, 120); + } + else if (proj.type == ProjectileID.CultistBossFireBall) + { + Player.AddBuff(ModContent.BuffType(), 180); + } + else if (proj.type == ProjectileID.CultistBossLightningOrbArc) + { + Player.AddBuff(BuffID.Electrified, 180); + } + else if (proj.type == ProjectileID.CultistBossFireBallClone) + { + Player.AddBuff(ModContent.BuffType(), 240); + } + else if (proj.type == ProjectileID.PhantasmalBolt || proj.type == ProjectileID.PhantasmalEye) + { + Player.AddBuff(ModContent.BuffType(), 120); + } + else if (proj.type == ProjectileID.PhantasmalSphere) + { + Player.AddBuff(ModContent.BuffType(), 180); + } + else if (proj.type == ProjectileID.PhantasmalDeathray) + { + Player.AddBuff(ModContent.BuffType(), 240); } } } + if (NPC.AnyNPCs(ModContent.NPCType())) { Player.AddBuff(ModContent.BuffType(), 15, true); @@ -1532,7 +1399,7 @@ namespace CalamityMod.CalPlayer { int seekerDamage = (int)Player.GetBestClassDamage().ApplyTo(15); - Projectile bee = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f), ModContent.ProjectileType(), seekerDamage, 0f, Player.whoAmI, -20, 30, 2); + Projectile bee = Projectile.NewProjectileDirect(Player.GetSource_Accessory_OnHurt(FindAccessory(), hurtInfo.DamageSource), Player.Center, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f), ModContent.ProjectileType(), seekerDamage, 0f, Player.whoAmI, -20, 30, 2); bee.ArmorPenetration = 35; bee.penetrate = 6; bee.extraUpdates = 2; @@ -1549,7 +1416,7 @@ namespace CalamityMod.CalPlayer { Particle spark2 = new LineParticle(Player.Center, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), false, 20, Main.rand.NextFloat(0.5f, 1.1f), Main.rand.NextBool() ? Color.Coral : Color.DarkTurquoise); GeneralParticleHandler.SpawnParticle(spark2); - Dust dust2 = Dust.NewDustPerfect(Player.Center, 267, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f)); + Dust dust2 = Dust.NewDustPerfect(Player.Center, DustID.RainbowMk2, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f)); dust2.scale = Main.rand.NextFloat(0.75f, 1.2f); dust2.noGravity = true; dust2.color = Main.rand.NextBool() ? Color.Coral : Color.DarkTurquoise; @@ -1563,7 +1430,7 @@ namespace CalamityMod.CalPlayer { float speed = 2f; int damage = 40; - int cloud = Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); + int cloud = Projectile.NewProjectile(Player.GetSource_Accessory_OnHurt(FindAccessory(), hurtInfo.DamageSource), Player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * speed, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); if (cloud.WithinBounds(Main.maxProjectiles)) Main.projectile[cloud].DamageType = DamageClass.Generic; } @@ -1610,7 +1477,7 @@ namespace CalamityMod.CalPlayer { int damage = Player.CalcIntDamage(InterstellarStompers.PassthroughDamage); - Projectile.NewProjectile(Player.GetSource_FromThis(), n.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Main.myPlayer); + Projectile.NewProjectile(Player.GetSource_Accessory(FindAccessory()), n.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Main.myPlayer); // 17APR2024: Ozzatron: Gravistar Sabaton gives iframes when passing through enemies for projectile safety. // This is a fixed and intentionally very low number of iframes, and is not boosted by Cross Necklace. @@ -1716,12 +1583,12 @@ namespace CalamityMod.CalPlayer { if (eclipseMirror) { - EclipseMirrorDodge(dodgeDamageGateValuePercent, dodgeDamageGateValue, actualDamageTaken); + EclipseMirrorDodge(dodgeDamageGateValuePercent, dodgeDamageGateValue, actualDamageTaken, info); return true; } else if (abyssalMirror) { - AbyssMirrorDodge(dodgeDamageGateValuePercent, dodgeDamageGateValue, actualDamageTaken); + AbyssMirrorDodge(dodgeDamageGateValuePercent, dodgeDamageGateValue, actualDamageTaken, info); return true; } } @@ -1740,11 +1607,17 @@ namespace CalamityMod.CalPlayer // Handles energy shields and Boss Rush, in that order modifiers.ModifyHurtInfo += ModifyHurtInfo_Calamity; - // TODO -- At some point it'd be nice to have a "TransformationPlayer" that has all the transformation sfx and visuals so their priorities can be more easily managed. #region Custom Hurt Sounds if (hurtSoundTimer == 0) { - if (roverDrive && RoverDriveShieldDurability > 0) + if(Player.Transformation().Type != -1 && Player.Transformation().currentTransformation.HurtSound(Player) != null) + { + var hurtSound = Player.Transformation().currentTransformation.HurtSound(Player).Value; + modifiers.DisableSound(); + SoundEngine.PlaySound(hurtSound.sound, Player.Center); + hurtSoundTimer = hurtSound.delay; + } + else if (roverDrive && RoverDriveShieldDurability > 0) { modifiers.DisableSound(); SoundEngine.PlaySound(RoverDrive.ShieldHurtSound, Player.Center); @@ -1762,42 +1635,12 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(TheSponge.ShieldHurtSound, Player.Center); hurtSoundTimer = 20; } - else if (((pSoulArtifact && !profanedCrystal) || profanedCrystalBuffs) && pSoulShieldDurability > 0) - { - modifiers.DisableSound(); - SoundEngine.PlaySound(ProfanedGuardianDefender.ShieldDeathSound); - hurtSoundTimer = 20; - } - else if ((profanedCrystal || profanedCrystalForce) && !profanedCrystalHide) - { - modifiers.DisableSound(); - SoundEngine.PlaySound(Providence.HurtSound, Player.Center); - hurtSoundTimer = 20; - } - else if ((abyssalDivingSuitPower || abyssalDivingSuitForce) && !abyssalDivingSuitHide) - { - modifiers.DisableSound(); - SoundEngine.PlaySound(SoundID.NPCHit4, Player.Center); //metal hit noise - hurtSoundTimer = 10; - } - else if (((aquaticHeartPower || aquaticHeartForce) && !aquaticHeartHide) || Player.GetModPlayer().vanityEquipped) - { - modifiers.DisableSound(); - SoundEngine.PlaySound(SoundID.FemaleHit, Player.Center); //female hit noise - hurtSoundTimer = 10; - } else if (titanHeartSet) { modifiers.DisableSound(); SoundEngine.PlaySound(NPCs.Astral.Atlas.HurtSound, Player.Center); hurtSoundTimer = 10; } - else if (Player.GetModPlayer().transformationActive) - { - modifiers.DisableSound(); - SoundEngine.PlaySound(SoundID.NPCHit4, Player.Center); - hurtSoundTimer = 10; - } else if (Player.GetModPlayer().wulfrumSet && (Player.name.ToLower() == "wagstaff" || Player.name.ToLower() == "john wulfrum")) { modifiers.DisableSound(); @@ -1909,10 +1752,13 @@ namespace CalamityMod.CalPlayer modifiers.DisableSound(); } - SoundEngine.PlaySound(Main.zenithWorld ? ShieldoftheOcean.ParrySoundGFB : ShieldoftheOcean.ParrySound, Player.Center); + SoundEngine.PlaySound(ShieldoftheOcean.ParrySound, Player.Center); Player.AddCooldown(ParryCooldown.ID, 1200, false, "shieldoftheocean"); ShieldoftheOcean.ActivateParry(Player); } + + if (Player.Calamity().scionsCurio) + scionsCurioGotHit = true; } private void ModifyHurtInfo_Calamity(ref Player.HurtInfo info) @@ -2078,6 +1924,27 @@ namespace CalamityMod.CalPlayer info.Damage -= spongeDamageBlocked; } + + //Stratus Starshield + if (Starshield > 0 && StratusStarburst > 0 && !shieldsFullyAbsorbedHit) + { + bool thisShieldCanFullyAbsorb = StratusStarburst >= info.Damage; + int damageblocked = Math.Min(StratusStarburst, info.Damage); + totalDamageBlocked += damageblocked; + StratusStarburst -= info.Damage; + shieldsTookHit = true; + if (StratusStarburst <= 0) + { + StratusStarburst = 0; + SoundEngine.PlaySound(SoundID.DD2_CrystalCartImpact, Player.Center); + Player.Calamity().GeneralScreenShakePower += anyShieldBroke ? 0.5f : 2f; + anyShieldBroke = true; + } + if (thisShieldCanFullyAbsorb) + shieldsFullyAbsorbedHit = true; + info.Damage -= damageblocked; + } + // If any shields took damage, there is some code that must be run. if (shieldsTookHit) { @@ -2141,10 +2008,9 @@ namespace CalamityMod.CalPlayer // Regardless of whether shields took damage, iterate over and stall all shield regen on ANY hit. // This applies even if you are hit while shields are fully down, or if you unequip any of the relevant items. { - // Rover Drive does not recharge while partially full, only when broken. - // If you are hit when recharging, though, that timer gets reset. - if (cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var roverDriveRechargeCD)) - roverDriveRechargeCD.timeLeft = RoverDrive.ShieldRechargeTime; + // Set Rover Drive's recharge delay to full. Override any existing cooldown instance. + if (roverDrive) + Player.AddCooldown(WulfrumRoverDriveRecharge.ID, RoverDrive.ShieldRechargeDelay, true); // Set the Lunic Corps Armor's recharge delay to full. Override any existing cooldown instance. if (lunicCorpsSet) @@ -2167,7 +2033,6 @@ namespace CalamityMod.CalPlayer nextHitDealsDefenseDamage = false; } } - // Chalice of the Blood God is implemented as a dirty modifier. // // Chalice of the Blood God does nothing to a hit that was just fully blocked by shields. @@ -2196,9 +2061,9 @@ namespace CalamityMod.CalPlayer bool hasIFrames = Player.HasIFrames(); // If the player was just hit by something capable of dealing defense damage, then apply defense damage. - // Bloodflare Core makes every hit deal defense damage (to enable its function). + // Bloodflare Core or Moonshine makes every hit deal defense damage (to enable its function). // Defense damage is not applied if the player has iframes or godmode. - bool hitCanApplyDefenseDamage = nextHitDealsDefenseDamage || bloodflareCore; + bool hitCanApplyDefenseDamage = nextHitDealsDefenseDamage || bloodflareCore || moonshine; bool defenseDamageShouldApply = hitCanApplyDefenseDamage && !hasIFrames && !Player.creativeGodMode; // 15AUG2024: Ozzatron: External flag which completely disables defense damage. This overrides Bloodflare Core. @@ -2206,19 +2071,25 @@ namespace CalamityMod.CalPlayer if (defenseDamageShouldApply && externalFlagsAppropriate) { + double specialDefenseDmgMinimum = 0; double halfDefense = Player.statDefense / 2.0; + if (bloodflareCore) + specialDefenseDmgMinimum += halfDefense; + if (moonshine) //Moonshine also halves defense damage recovery alongside forcing 50% of defense as defense damage + specialDefenseDmgMinimum += halfDefense; int netMitigation = hurtInfo.SourceDamage - hurtInfo.Damage; double standardDefenseDamage = netMitigation * defenseDamageRatio; - // Bloodflare Core overrides standard defense damage if it would be less than half of the player's total defense. - if (bloodflareCore && standardDefenseDamage < halfDefense) + // Bloodflare Core or Moonshine overrides standard defense damage if it would be less than half of the player's total defense. + // They stack together for 100% lost defense + if (specialDefenseDmgMinimum > 0 && standardDefenseDamage < specialDefenseDmgMinimum) { - // In this case, forcibly deal half of the player's total defense as defense damage. This ignores ratios. - DealDefenseDamage((int)halfDefense, true); + // In this case, forcibly deal the proportion of the player's total defense as defense damage. This ignores ratios. + DealDefenseDamage((int)specialDefenseDmgMinimum, true); // Set up Bloodflare Core's heal over time. Any in-progress heals are overwritten if they would have a shorter duration. - if (bloodflareCoreRemainingHealOverTime < halfDefense) - bloodflareCoreRemainingHealOverTime = (int)halfDefense; + if (bloodflareCore && bloodflareCoreRemainingHealOverTime < specialDefenseDmgMinimum) + bloodflareCoreRemainingHealOverTime = (int)specialDefenseDmgMinimum; // Play a sound and make dust to signify that defense has been shattered SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, Player.Center); @@ -2291,8 +2162,8 @@ namespace CalamityMod.CalPlayer if (RageEnabled) rageCombatFrames = BalancingConstants.RageCombatDelayTime; - // Regenator has been CANCLED on TWITTER.COM!!!! (Just keeping this here since it's a neat effect and I'll probably yoink it for something else later) - if (regenator && false) + // Regenerator has been CANCLED on TWITTER.COM!!!! (Just keeping this here since it's a neat effect and I'll probably yoink it for something else later) + /*if (regenerator) { // Projectile damage and count is based on source damage of the hit float hitPower = (hurtInfo.SourceDamage / (Player.statLifeMax2 * 0.5f)); @@ -2302,9 +2173,9 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < projCount; i++) { Vector2 vel = (MathHelper.TwoPi * i / projCount).ToRotationVector2() * (i % 2 == 0 ? 0.75f : 1f) * 10; - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, vel.RotatedBy(-0.2f * (i % 2 == 0 ? -1 : 1)), ModContent.ProjectileType(), projDamage, 0f, Player.whoAmI, 0, (i % 2 == 0 ? -1 : 1), -5); + Projectile.NewProjectile(Player.GetSource_Accessory_OnHurt(FindAccessory(), hurtInfo.DamageSource), Player.Center, vel.RotatedBy(-0.2f * (i % 2 == 0 ? -1 : 1)), ModContent.ProjectileType(), projDamage, 0f, Player.whoAmI, 0, (i % 2 == 0 ? -1 : 1), -5); } - } + }*/ // Hide of Astrum Deus' melee boost if (hideOfDeus) @@ -2334,9 +2205,15 @@ namespace CalamityMod.CalPlayer } } - if (daedalusAbsorb && Main.rand.NextBool(10)) + if (victideBarrierSet && !Player.HasCooldown(WardingWave.ID)) { - int healAmt = (int)(hurtInfo.Damage / 2D); + int healAmt = (int)(hurtInfo.Damage * VictideHeadBarrier.BarrierDamageAbsorptionPercent); + victideBarrierHeal += healAmt; + } + + if (daedalusAbsorb && Main.rand.NextBool(DaedalusHeadMagic.AbsorptionChanceDenominator)) + { + int healAmt = (int)(hurtInfo.Damage * DaedalusHeadMagic.DamageAbsorptionPercent); Player.HealPlayer(healAmt); } @@ -2369,7 +2246,7 @@ namespace CalamityMod.CalPlayer if (trinketOfChi) chiBuffTimer = 0; - if (amidiasBlessing && hurtInfo.Damage > 50) + if (amidiasBlessing && (chaliceOfTheBloodGod ? chaliceBleedoutToApplyOnHurt : hurtInfo.Damage) > 50) { Player.ClearBuff(ModContent.BuffType()); SoundEngine.PlaySound(SoundID.Item96, Player.Center); @@ -2415,50 +2292,10 @@ namespace CalamityMod.CalPlayer tortShellPostHit = 180; } - if (abyssalDivingSuitPlates && hurtInfo.Damage > 50) - { - if (abyssalDivingSuitPlateHits < 3) - abyssalDivingSuitPlateHits++; - - bool plateCDExists = cooldowns.TryGetValue(DivingPlatesBreaking.ID, out CooldownInstance plateDurability); - if (plateCDExists) - plateDurability.timeLeft = abyssalDivingSuitPlateHits; - - if (abyssalDivingSuitPlateHits >= 3) - { - SoundEngine.PlaySound(SoundID.NPCDeath14, Player.Center); - - if (plateCDExists) - cooldowns.Remove(DivingPlatesBreaking.ID); - - Player.AddCooldown(DivingPlatesBroken.ID, 10830); - - for (int d = 0; d < 20; d++) - { - Dust dust = Dust.NewDustDirect(Player.position, Player.width, Player.height, DustID.Smoke, 0f, 0f, 100, default, 2f); - dust.velocity *= 3f; - if (Main.rand.NextBool()) - { - dust.scale = 0.5f; - dust.fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int d = 0; d < 35; d++) - { - Dust fire = Dust.NewDustDirect(Player.position, Player.width, Player.height, DustID.Torch, 0f, 0f, 100, default, 3f); - fire.noGravity = true; - fire.velocity *= 5f; - fire = Dust.NewDustDirect(Player.position, Player.width, Player.height, DustID.Torch, 0f, 0f, 100, default, 2f); - fire.velocity *= 2f; - } - } - } - if (aquaticHeartIce) { SoundEngine.PlaySound(SoundID.NPCDeath7, Player.Center); - Player.AddCooldown(AquaticHeartIceShield.ID, CalamityUtils.SecondsToFrames(30)); + Player.AddCooldown(AquaticHeartIceShield.ID, AquaticHeart.IceShieldCooldown); for (int d = 0; d < 10; d++) { @@ -2482,15 +2319,15 @@ namespace CalamityMod.CalPlayer if (tarraMelee) { - Player.AddBuff(ModContent.BuffType(), 120); + Player.AddBuff(ModContent.BuffType(), TarragonHeadMelee.TarraLifeDuration); } else if (xerocSet) { - Player.AddBuff(ModContent.BuffType(), 180); + Player.AddBuff(ModContent.BuffType(), EmpyreanMask.WrathDuration); } else if (reaverDefense) { - Player.AddBuff(ModContent.BuffType(), 180); + Player.AddBuff(ModContent.BuffType(), ReaverHeadTank.ReaverRageDuration); } if (fBarrier || (aquaticHeart && NPC.downedBoss3)) @@ -2540,19 +2377,11 @@ namespace CalamityMod.CalPlayer { int duration = Main.rand.Next(300 + hurtInfo.Damage / 3, 480 + hurtInfo.Damage / 2); npc.AddBuff(BuffID.Confused, duration, false); - if (amalgam) - { - npc.AddBuff(BuffID.Venom, duration); - npc.AddBuff(ModContent.BuffType(), duration); - npc.AddBuff(ModContent.BuffType(), duration); - npc.AddBuff(ModContent.BuffType(), duration); - npc.AddBuff(ModContent.BuffType(), duration); - } } } // Spawn the harmless brain images that are actually projectiles - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + var source = Player.GetSource_Accessory_OnHurt(amalgam ? FindAccessory() : FindAccessory(), hurtInfo.DamageSource); Projectile.NewProjectile(source, Player.Center.X + Main.rand.Next(-40, 40), Player.Center.Y - Main.rand.Next(20, 60), Player.velocity.X * 0.3f, Player.velocity.Y * 0.3f, ProjectileID.BrainOfConfusion, 0, 0f, Player.whoAmI); } } @@ -2578,7 +2407,7 @@ namespace CalamityMod.CalPlayer // Drop some bones for visual effects if (!Main.dedServ && Player.wingTime > 0) { - var source = Player.GetSource_Accessory(FindAccessory(ItemID.BoneWings)); + var source = Player.GetSource_Accessory_OnHurt(FindAccessory(ItemID.BoneWings), hurtInfo.DamageSource); for (int i = 0; i < 6; i++) { Vector2 boneVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(1.5f, 2.5f); @@ -2598,6 +2427,10 @@ namespace CalamityMod.CalPlayer if (silverMedkit && hurtInfo.Damage >= SilverArmorSetChange.SetBonusMinimumDamageToHeal) silverMedkitTimer = SilverArmorSetChange.SetBonusHealTime; + //This goes before the canTriggerEffects check on purpose to match Honeycomb + if (dAmulet) + Player.AddBuff(BuffID.Honey, 300, false); + // Handle hit effects from the gem tech armor set. Player.Calamity().GemTechState.PlayerOnHitEffects((int)hurtInfo.Damage); @@ -2613,49 +2446,50 @@ namespace CalamityMod.CalPlayer Player.immuneTime += iFramesToAdd; // Similar handle to 1.4 Star Cloak: these hits ie. spikes or lava cannot activate hit effects - if (hurtInfo.CooldownCounter != -1 && hurtInfo.CooldownCounter != 1) + bool canTriggerHitEffects = hurtInfo.CooldownCounter == -1 || hurtInfo.CooldownCounter == 1; + if (!canTriggerHitEffects) return; - if (aeroSet && hurtInfo.Damage > 25) + if (aeroSet && hurtInfo.Damage > AerospecBreastplate.SetBonusHurtDamageThreshold) { // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_OnHurt(hurtInfo.DamageSource, AerospecBreastplate.FeatherEntitySourceContext); + int featherDamage = (int)Player.GetBestClassDamage().ApplyTo(AerospecBreastplate.SetBonusFeatherDamage); for (int n = 0; n < 4; n++) { - int featherDamage = (int)Player.GetBestClassDamage().ApplyTo(30); - CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), featherDamage, 1f, Player.whoAmI); } } if (hideOfDeus) { - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + var source = Player.GetSource_Accessory_OnHurt(FindAccessory(), hurtInfo.DamageSource); SoundEngine.PlaySound(SoundID.Item74, Player.Center); - int blazeDamage = (int)Player.GetBestClassDamage().ApplyTo(25); - int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(320); - + int blazeDamage = (int)Player.GetBestClassDamage().ApplyTo(HideofAstrumDeus.BlazeDamage); Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, 0f, 0f, ModContent.ProjectileType(), blazeDamage, 5f, Player.whoAmI, 0f, 1f); - for (int n = 0; n < 12; n++) - { - CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), astralStarDamage, 5f, Player.whoAmI); - } } // TODO -- Make Deific Amulet and Rampart of Deities' retaliation effects way cooler + // In the meantime, gave them homing astral star bees instead of the lame falling stars. + // This also serves to make the Honeycomb in Sweetheart Necklace make sense if (dAmulet) { - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - for (int n = 0; n < 3; n++) + var source = Player.GetSource_Accessory_OnHurt(FindAccessory(), hurtInfo.DamageSource); + int projAmount = (rampartOfDeities ? 12 : 6); + for (int n = 0; n < projAmount; n++) { - int baseDamage = 130 * (Main.masterMode ? 3 : Main.expertMode ? 2 : 1); - int deificStarDamage = (int)Player.GetBestClassDamage().ApplyTo(baseDamage); + int deificProjDamage = (int)(Player.GetBestClassDamage().ApplyTo(DeificAmulet.StarDamage) * (Player.strongBees ? 0.85f : 1f)); - Projectile star = CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileID.StarVeilStar, deificStarDamage, 4f, Player.whoAmI); - if (star.whoAmI.WithinBounds(Main.maxProjectiles)) + Projectile onHitProj = Main.projectile[Projectile.NewProjectile(source, Player.Center, new Vector2(0,-15 * (rampartOfDeities && n % 2 == 0 ? 0.75f: 1.25f)).RotatedBy(MathHelper.TwoPi/projAmount*n), ModContent.ProjectileType(), deificProjDamage, 4f, Player.whoAmI)]; + if (onHitProj.whoAmI.WithinBounds(Main.maxProjectiles)) { - star.DamageType = DamageClass.Generic; - star.usesLocalNPCImmunity = true; - star.localNPCHitCooldown = 5; + onHitProj.DamageType = DamageClass.Generic; + onHitProj.usesLocalNPCImmunity = true; + onHitProj.localNPCHitCooldown = 30; + onHitProj.tileCollide = false; + onHitProj.extraUpdates = 1; + onHitProj.Calamity().conditionalHomingRange = 600f; + if (Player.strongBees) + onHitProj.penetrate += 1; } } } @@ -2680,9 +2514,9 @@ namespace CalamityMod.CalPlayer { if (!(CalamityUtils.AnyProjectiles(ModContent.ProjectileType()) || CalamityUtils.AnyProjectiles(ModContent.ProjectileType()))) { - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + var source = Player.GetSource_Accessory_OnHurt(amalgam ? FindAccessory() : aBrain ? FindAccessory() : FindAccessory(), hurtInfo.DamageSource); int effectStrength = amalgam ? 3 : aBrain ? 2 : 1; - int effectDamage = amalgam ? 400 : aBrain ? 35 : 15; + int effectDamage = amalgam ? TheAmalgam.NimbusDamage : aBrain ? AmalgamatedBrain.NimbusDamage : RottenBrain.NimbusDamage; effectDamage = (int)Player.GetBestClassDamage().ApplyTo(effectDamage); Vector2 spawnerVelocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi / 40f) * 12.5f; @@ -2691,15 +2525,20 @@ namespace CalamityMod.CalPlayer } if (inkBomb && !abyssalMirror && !eclipseMirror) { - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - if (Player.whoAmI == Main.myPlayer && !Player.HasCooldown(Cooldowns.InkBomb.ID)) + if (Player.whoAmI == Main.myPlayer) { - Player.AddCooldown(Cooldowns.InkBomb.ID, CalamityUtils.SecondsToFrames(20)); - rogueStealth += 0.5f; + if (!Player.HasCooldown(Cooldowns.InkBomb.ID)) + { + Player.AddCooldown(Cooldowns.InkBomb.ID, CalamityUtils.SecondsToFrames(20)); + rogueStealth += 0.5f; + SoundEngine.PlaySound(SoundID.NPCDeath28 with { Volume = 2f }, Player.Center); + } + + var source = Player.GetSource_Accessory_OnHurt(FindAccessory(), hurtInfo.DamageSource); + SoundEngine.PlaySound(SoundID.Item1, Player.Center); for (int i = 0; i < 3; i++) { - SoundEngine.PlaySound(SoundID.Item61, Player.Center); - int ink = Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-0f, -4f), ModContent.ProjectileType(), 0, 0, Player.whoAmI); + int ink = Projectile.NewProjectile(source, Player.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 2f, ModContent.ProjectileType(), 0, 0, Player.whoAmI); if (ink.WithinBounds(Main.maxProjectiles)) Main.projectile[ink].DamageType = DamageClass.Generic; } @@ -2707,11 +2546,11 @@ namespace CalamityMod.CalPlayer } if (ataxiaBlaze) { - var fuckYouBitch = Player.GetSource_Misc("21"); + var fuckYouBitch = Player.GetSource_OnHurt(hurtInfo.DamageSource); if (hurtInfo.Damage > 0) { SoundEngine.PlaySound(SoundID.Item74, Player.Center); - int eDamage = (int)Player.GetBestClassDamage().ApplyTo(230); + int eDamage = (int)Player.GetBestClassDamage().ApplyTo(HydrothermicArmor.BlazeDamage); if (Player.whoAmI == Main.myPlayer) Projectile.NewProjectile(fuckYouBitch, Player.Center, Vector2.Zero, ModContent.ProjectileType(), eDamage, 1f, Player.whoAmI, 0f, 0f); @@ -2719,21 +2558,18 @@ namespace CalamityMod.CalPlayer } else if (daedalusShard) // Daedalus Ranged helm { - var source = Player.GetSource_Misc("22"); if (hurtInfo.Damage > 0) { SoundEngine.PlaySound(SoundID.Item27, Player.Center); - float spread = 45f * 0.0174f; - double startAngle = Math.Atan2(Player.velocity.X, Player.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - int sDamage = (int)Player.GetTotalDamage().ApplyTo(60); if (Player.whoAmI == Main.myPlayer) { - for (int i = 0; i < 16; i++) + var source = Player.GetSource_OnHurt(hurtInfo.DamageSource); + float offset = Main.rand.NextFloat(MathHelper.TwoPi); + int sDamage = (int)Player.GetTotalDamage().ApplyTo(DaedalusHeadRanged.ShardDamage); + for (int i = 0; i < 10; i++) { - Vector2 circleVel = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * Main.rand.NextFloat(5f, 8f); + Vector2 circleVel = ((MathHelper.TwoPi * i / 10f) + offset).ToRotationVector2() * Main.rand.NextFloat(5f, 8f); int shard = Projectile.NewProjectile(source, Player.Center, circleVel, ProjectileID.CrystalShard, sDamage, 1f, Player.whoAmI); if (shard.WithinBounds(Main.maxProjectiles)) Main.projectile[shard].DamageType = DamageClass.Generic; @@ -2741,28 +2577,17 @@ namespace CalamityMod.CalPlayer } } } - else if (reaverDefense) //Defense and DR Helm - { - var source = Player.GetSource_Misc("23"); - if (hurtInfo.Damage > 0) - { - int rDamage = (int)Player.GetBestClassDamage().ApplyTo(240); - - if (Player.whoAmI == Main.myPlayer) - Projectile.NewProjectile(source, Player.Center.X, Player.position.Y + 36f, 0f, -18f, ModContent.ProjectileType(), rDamage, 0f, Player.whoAmI, 0f, 0f); - } - } else if (godSlayerDamage) //god slayer melee helm { - var source = Player.GetSource_Misc("24"); - if (hurtInfo.Damage > 80) + var source = Player.GetSource_OnHurt(hurtInfo.DamageSource); + if (hurtInfo.Damage > GodSlayerHeadMelee.SetBonusHurtDamageThreshold) { SoundEngine.PlaySound(SoundID.Item73, Player.Center); float spread = 45f * 0.0174f; double startAngle = Math.Atan2(Player.velocity.X, Player.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int shrapnelDamage = Player.CalcIntDamage(675); + int shrapnelDamage = Player.CalcIntDamage(GodSlayerHeadMelee.DartDamage); if (Player.whoAmI == Main.myPlayer) { for (int i = 0; i < 4; i++) @@ -2782,7 +2607,7 @@ namespace CalamityMod.CalPlayer var source = Player.GetSource_OnHurt(hurtInfo.DamageSource, DemonshadeHelm.ShadowScytheEntitySourceContext); for (int l = 0; l < 2; l++) { - int shadowbeamDamage = (int)Player.GetBestClassDamage().ApplyTo(300); + int shadowbeamDamage = (int)Player.GetBestClassDamage().ApplyTo(DemonshadeHelm.BeamDamage); Projectile beam = CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.ShadowBeamFriendly, shadowbeamDamage, 7f, Player.whoAmI); if (beam.whoAmI.WithinBounds(Main.maxProjectiles)) @@ -2794,7 +2619,7 @@ namespace CalamityMod.CalPlayer } for (int l = 0; l < 5; l++) { - int scytheDamage = (int)Player.GetBestClassDamage().ApplyTo(500); + int scytheDamage = (int)Player.GetBestClassDamage().ApplyTo(DemonshadeHelm.ScytheDamage); Projectile scythe = CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 22f, ProjectileID.DemonScythe, scytheDamage, 7f, Player.whoAmI); if (scythe.whoAmI.WithinBounds(Main.maxProjectiles)) @@ -2829,7 +2654,7 @@ namespace CalamityMod.CalPlayer } if (Main.myPlayer == Player.whoAmI) { - Player.trashItem.SetDefaults(0, false); + Player.trashItem.SetDefaults(ItemID.None, false); if (Player.difficulty == PlayerDifficultyID.SoftCore || Player.difficulty == PlayerDifficultyID.Creative) { for (int i = 0; i < 59; i++) @@ -2849,7 +2674,7 @@ namespace CalamityMod.CalPlayer { NetMessage.SendData(MessageID.SyncItem, -1, -1, null, droppedLargeGem, 0f, 0f, 0f, 0, 0, 0); } - Player.inventory[i].SetDefaults(0, false); + Player.inventory[i].SetDefaults(ItemID.None, false); } } } @@ -2896,11 +2721,11 @@ namespace CalamityMod.CalPlayer if (abyssDeath) { SoundEngine.PlaySound(DrownSound, Player.Center); - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AbyssDrown" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AbyssDrown" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } else if (CalamityWorld.armageddon && areThereAnyDamnBosses) { - damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Armageddon").Format(Player.name)); + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Armageddon").ToNetworkText(Player.name)); } NetworkText deathText = damageSource.GetDeathText(Player.name); diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index d686181a32..9efb99e875 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -1,17 +1,20 @@ using System; using System.Linq; using CalamityMod.Buffs.Alcohol; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.Placeables; using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Cooldowns; +using CalamityMod.CalPlayer.Dashes; +using CalamityMod.DataStructures; using CalamityMod.Enums; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Accessories.Wings; +using CalamityMod.Items.Armor.Fearmonger; +using CalamityMod.Items.Armor.Reaver; +using CalamityMod.Items.Armor.Silva; +using CalamityMod.Items.Armor.Tarragon; using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Potions.Food; using CalamityMod.NPCs; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; @@ -96,45 +99,46 @@ namespace CalamityMod.CalPlayer } // Whispering Death sets positive regen to zero but doesn't actually deal any damage - ApplyDoTDebuff(wDeath, 0, laudanum); + ApplyDoTDebuff(whisperingDeath, 0, laudanum); ApplyDoTDebuff(irradiated, 4, purity); int sulphurDoT = 6 - (sulphurSet ? 2 : 0) - (sulphurskin ? 2 : 0) - (corrosiveSpine ? 2 : 0); ApplyDoTDebuff(sulphurPoison, sulphurDoT, purity); - ApplyDoTDebuff(rTide, 6, purity); + ApplyDoTDebuff(riptide, 6, purity); ApplyDoTDebuff(weakBrimstoneFlames, 7); - ApplyDoTDebuff(bBlood, 8, purity); + ApplyDoTDebuff(burningBlood, 8, purity); ApplyDoTDebuff(brainRot, 8, purity); - ApplyDoTDebuff(heavybleeding, 30, purity); - ApplyDoTDebuff(laceration, 40, purity); ApplyDoTDebuff(vaporfied, 8, purity); int staticDoT = ((Player.controlLeft || Player.controlRight) ? 12 : 3) / (eleResist ? 2 : 1); ApplyDoTDebuff(staticDischarge, staticDoT, purity); - ApplyDoTDebuff(bFlames, abaddon ? 10 : 30, purity); - ApplyDoTDebuff(demonicFlames, 33, purity); - ApplyDoTDebuff(daybroken, reducedDaybrokenDamage ? 20 : 40, purity); - ApplyDoTDebuff(nightwither, reducedNightwitherDamage ? 20 : 40, purity); - ApplyDoTDebuff(hFlames, 40, purity); - ApplyDoTDebuff(voidfrost, 40, purity); - ApplyDoTDebuff(vHex, 35); - ApplyDoTDebuff(trueVHex, 50); - ApplyDoTDebuff(cDepth, 18, purity); + ApplyDoTDebuff(heavybleeding, 16, purity); + ApplyDoTDebuff(crushDepth, 18, purity); ApplyDoTDebuff(astralInfection, 24, infectedJewel || hideOfDeus || purity); - ApplyDoTDebuff(hPressure, 40, purity); - ApplyDoTDebuff(pFlames, alchFlask ? 10 : 30, purity); - ApplyDoTDebuff(cragsLava, 30); ApplyDoTDebuff(shadowflame, 30, purity); - ApplyDoTDebuff(elementalMix, 50, purity); - ApplyDoTDebuff(banishingFire, 60); + ApplyDoTDebuff(brimstoneFlames, (int)MathF.Round(30 * (abaddon ? (1f - Abaddon.BrimstoneFlamesReduction) : 1f)), purity); + ApplyDoTDebuff(plague, (int)MathF.Round(30 * (abaddon ? (1f - AlchemicalDecanter.PlagueReduction) : 1f)), purity); + ApplyDoTDebuff(vHex, 30); // Has other effects + ApplyDoTDebuff(searingLava, 30); + ApplyDoTDebuff(demonicFlames, 33, purity); // Never inflicted on the player + ApplyDoTDebuff(laceration, 36, purity); + ApplyDoTDebuff(daybroken, 40, purity); + ApplyDoTDebuff(nightwither, 40, purity); + ApplyDoTDebuff(holyFlames, 40, purity); + ApplyDoTDebuff(voidfrost, 40, purity); + ApplyDoTDebuff(hadopelagicPressure, 40, purity); + // Profaned Soul Crystal turns you into Providence, a God, and you take more damage from God Slayer Inferno - ApplyDoTDebuff(gsInferno, profanedCrystalBuffs ? 60 : 50); - int fluxDoT = ((Player.controlLeft || Player.controlRight) ? 60 : 15) / (eleResist ? 2 : 1); + ApplyDoTDebuff(godSlayerInferno, profanedCrystalBuffs ? 50 : 40); + int fluxDoT = ((Player.controlLeft || Player.controlRight) ? 50 : 10) / (eleResist ? 2 : 1); ApplyDoTDebuff(vermillionFlux, fluxDoT); - int dragonfireDoT = ((Player.name == "JFL" || Player.name == "MrJFL") ? 240 : 60) / (dynamoStemCells ? 2 : 1); + ApplyDoTDebuff(elementalMix, 50, purity); // Never inflicted on the player + ApplyDoTDebuff(trueVHex, 50); + int dragonfireDoT = ((Player.name == "JFL" || Player.name == "MrJFL") ? 200 : 50) / (dynamoStemCells ? 2 : 1); ApplyDoTDebuff(dragonFire, dragonfireDoT); - int rebukeDoT = ((Player.controlLeft || Player.controlRight) ? 75 : 15) / (eleResist ? 2 : 1); + ApplyDoTDebuff(miracleBlight, 60); + ApplyDoTDebuff(banishingFire, 60); // Never inflicted on the player + int rebukeDoT = ((Player.controlLeft || Player.controlRight) ? 80 : 16) / (eleResist ? 2 : 1); ApplyDoTDebuff(auricRebuke, rebukeDoT); - ApplyDoTDebuff(miracleBlight, 80); // Slowly increase the sulphuric water poisoning effect. Once it's high enough, the player takes damage and the meter resets. bool nearSafeZone = false; @@ -178,7 +182,7 @@ namespace CalamityMod.CalPlayer if (SulphWaterPoisoningLevel >= 1f) { SulphWaterPoisoningLevel = 0f; - Player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.SulphurMeter").Format(Player.name)), Math.Min(Player.statLifeMax2 / 4, 150), 0); + Player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.SulphurMeter").ToNetworkText(Player.name)), Math.Min(Player.statLifeMax2 / 4, 150), 0); } } else @@ -189,37 +193,13 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < Player.MaxBuffs; l++) { int buff = Player.buffType[l]; - if (AlcoholsDict.TryGet(buff, out var level)) + if (CalamityBuffSets.AlcoholStrength.TryGetValue(buff, out int level)) alcoholPoisonLevel += level; } - if (vodka) - totalNegativeLifeRegen += Vodka.RegenLoss; - if (redWine) - totalNegativeLifeRegen += baguette ? Baguette.RedWineBuffedRegenLoss : RedWine.RegenLoss; - if (moonshine) - totalNegativeLifeRegen += Moonshine.RegenLoss; - if (fireball) - totalNegativeLifeRegen += Fireball.RegenLoss; + if (Player.Calamity().ivDrip) // +1 stack of poisoning while IV Drip is equipped + alcoholPoisonLevel++; if (everclear) totalNegativeLifeRegen += Everclear.RegenLoss; - if (bloodyMary) - totalNegativeLifeRegen += BloodyMary.RegenLoss; - if (tequila) - totalNegativeLifeRegen += Tequila.RegenLoss; - if (tequilaSunrise) - totalNegativeLifeRegen += TequilaSunrise.RegenLoss; - if (screwdriver) - totalNegativeLifeRegen += Screwdriver.RegenLoss; - if (margarita) - totalNegativeLifeRegen += Margarita.RegenLoss; - if (starBeamRye) - totalNegativeLifeRegen += StarBeamRye.RegenLoss; - if (moscowMule) - totalNegativeLifeRegen += MoscowMule.RegenLoss; - if (whiteWine) - totalNegativeLifeRegen += WhiteWine.RegenLoss; - if (evergreenGin) - totalNegativeLifeRegen += EvergreenGin.RegenLoss; // Blanket effect for all alcohols if (alcoholPoisonLevel > 0) @@ -232,7 +212,7 @@ namespace CalamityMod.CalPlayer Player.fishingSkill += 5; } - if (alcoholPoisonLevel > (cirrusDress ? 5 : 3)) + if (alcoholPoisonLevel > 3) { // Independently of Calamity's nerfs to Nebula life regen, it is disabled entirely by alcohol poisoning. Player.nebulaLevelLife = 0; @@ -249,12 +229,6 @@ namespace CalamityMod.CalPlayer } #endregion - if (manaOverloader) - { - if (Player.statMana > (int)(Player.statManaMax2 * 0.5)) - totalNegativeLifeRegen += 3; - } - if (brimflameFrenzy) { Player.manaRegen = 0; @@ -282,14 +256,9 @@ namespace CalamityMod.CalPlayer else witheredWeaponHoldTime = 0; - if (ManaBurn) + if (Player.statMana < 0) { - int debuffIndex = Player.FindBuffIndex(ModContent.BuffType()); - float debuffIntensity = debuffIndex == -1 ? 0f : Player.buffTime[debuffIndex] / (float)Player.manaSickTimeMax; - - totalNegativeLifeRegen += (int)(Math.Sqrt(debuffIntensity) * Math.Pow(6D, debuffIntensity + 1f)); - if (Player.lifeRegen > 0) - Player.lifeRegen = 0; + totalNegativeLifeRegen -= Player.statMana/100f * Items.Accessories.ChaosStone.LostRegenPer100Mana; } // @@ -298,32 +267,15 @@ namespace CalamityMod.CalPlayer // At the last second, Reaver defense helm reduces DoT debuffs by 20% if (reaverDefense) - totalNegativeLifeRegen = (int)(0.8f * totalNegativeLifeRegen); + totalNegativeLifeRegen -= (int)(totalNegativeLifeRegen * ReaverHeadTank.SetBonusDebuffDamageReduction); + if (tequilaSunrise) + totalNegativeLifeRegen = (int)(totalNegativeLifeRegen * TequilaSunrise.DoTMultiplier); Player.lifeRegen -= (int)totalNegativeLifeRegen; + bool hasLifeRegenHinderingDebuff = Player.lifeRegenTime == 0; + #region Life Regen That Works Even During DoT Debuffs - - // Honey Dew (and upgrades) - if (alwaysHoneyRegen) - { - // Exact copy of vanilla Honey behavior, but does not stack with actually standing in Honey - if (!Player.honey) - { - Player.lifeRegen += 2; - Player.lifeRegenTime += 1; - - // Grants +2 life regen if negative life regen would otherwise occur. - // However, this can't bring regen into the positives. - if (Player.lifeRegen < 0) - { - Player.lifeRegen += 2; - if (Player.lifeRegen > 0) - Player.lifeRegen = 0; - } - } - } - if (honeyDewHalveDebuffs) { // Tick down all sickness debuffs; this makes them expire 2x faster @@ -331,13 +283,13 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < Player.MaxBuffs; ++l) { int buffID = Player.buffType[l]; - if (Player.buffTime[l] <= 2) + if (Player.buffTime[l] <= 2 || BuffDatasets.DebuffDataset[buffID] is null) continue; - bool shouldHalveDuration = SicknessDebuffsList.Includes(buffID); + bool shouldHalveDuration = BuffDatasets.DebuffDataset[buffID].SicknessDebuffScaling > 0; if (livingDewHalveDebuffs) - shouldHalveDuration |= FireDebuffsList.Includes(buffID); + shouldHalveDuration |= BuffDatasets.DebuffDataset[buffID].HeatDebuffScaling > 0; if (purity) - shouldHalveDuration |= DebuffsList.Includes(buffID); + shouldHalveDuration |= CalamityBuffSets.IsDebuff[buffID]; if (shouldHalveDuration) --Player.buffTime[l]; @@ -346,7 +298,7 @@ namespace CalamityMod.CalPlayer if (divineBless) { - if (Player.whoAmI == Main.myPlayer && Player.miscCounter % 15 == 0) // Flat 4 health per second + if (Player.whoAmI == Main.myPlayer && Player.miscCounter % AngelicAlliance.DivineBlessFramesPerHeal == 0) // Flat 4 health per second { if (!noLifeRegen) Player.HealPlayer(1, HealTextType.None); @@ -381,10 +333,10 @@ namespace CalamityMod.CalPlayer } // Permafrost's Concoction increases life regen while afflicted with a fire debuff - if (permafrostsConcoction && Player.buffType.Any(FireDebuffsList.Includes)) + if (permafrostsConcoction && Player.buffType.Any(l => BuffDatasets.DebuffDataset[l] is not null && BuffDatasets.DebuffDataset[l].HeatDebuffScaling > 0)) { - if (Player.lifeRegenTime < 1800) - Player.lifeRegenTime = 1800; + if (Player.lifeRegenTime < 900) + Player.lifeRegenTime = 900; Player.lifeRegen += 6; } @@ -392,16 +344,18 @@ namespace CalamityMod.CalPlayer // Grant life regen based on missing health for Radiant Ooze, Ambrosial Ampule, and purity if (rOoze || aAmpoule || purity) { - float missingLifeRatio = (Player.statLifeMax2 - Player.statLife) / Player.statLifeMax2; - //Ambrosial Ampule and ooze give between 2 and 6 hp/s - float lifeRegenToGive = MathHelper.Lerp(4f, 12f, missingLifeRatio); - Player.lifeRegen += (int)lifeRegenToGive; + float missingLifeRatio = (Player.statLifeMax2 - Player.statLife) / (float)Player.statLifeMax2; + //Ambrosial Ampule and ooze give between 2 and 5 hp/s + int lifeRegenToGive = (int)Math.Round(MathHelper.Lerp(RadiantOoze.MinRegenBoost, RadiantOoze.MaxRegenBoost, missingLifeRatio));//Rounding is needed for it to ever actually give +5 hp/s, as the integer conversion would otherwise floor it. + Player.lifeRegen += lifeRegenToGive; + radiantOozeRegen += lifeRegenToGive / 2f; + purityRegen += lifeRegenToGive / 2f; } if (purity) { int intendedPurityDefense = 0; - int currentDebuffs = Player.buffType.Count(DebuffsList.List.Contains); + int currentDebuffs = Player.buffType.Count(i => CalamityBuffSets.IsDebuff[i]); if (currentDebuffs > 0) { // Healing rate is normally 5 HP/s (+1 every 12 frames) @@ -418,16 +372,14 @@ namespace CalamityMod.CalPlayer if (Player.miscCounter % healFrameCadence == healFrameCadence - 1) Player.Heal(1); - if (Player.lifeRegenTime < 1800) - Player.lifeRegenTime = 1800; - - intendedPurityDefense = 20 + (currentDebuffs - 1) * 8; + intendedPurityDefense = 15 + (currentDebuffs - 1) * 5; if (jewelBonusDefense < intendedPurityDefense) jewelBonusDefense = intendedPurityDefense; // Count up total frames spent healing for slowdown. if (PurityHealSlowdownFrames < 900) ++PurityHealSlowdownFrames; + purityRegen += (60 / (float)healFrameCadence); } // If the defense should be ticking down to some lower value, do that. @@ -455,14 +407,12 @@ namespace CalamityMod.CalPlayer // If the player has any debuffs, give the extra life regen and defense // More defense is given for each additional debuff int intendedJewelDefense = 0; - int currentDebuffs = Player.buffType.Count(DebuffsList.List.Contains); + int currentDebuffs = Player.buffType.Count(i => CalamityBuffSets.IsDebuff[i]); if (currentDebuffs > 0) { Player.lifeRegen += 4; - if (Player.lifeRegenTime < 1800) - Player.lifeRegenTime = 1800; - intendedJewelDefense = 16 + (currentDebuffs - 1) * 5; + intendedJewelDefense = 12 + (currentDebuffs - 1) * 4; if (jewelBonusDefense < intendedJewelDefense) jewelBonusDefense = intendedJewelDefense; } @@ -481,18 +431,24 @@ namespace CalamityMod.CalPlayer { Player.lifeRegen += 2; - // If any debuff is detected, provide even more life regen and massively accelerate it - if (Player.buffType.Any(DebuffsList.List.Contains)) - { + // If any debuff is detected, provide even more life regen + if (Player.buffType.Any(i => CalamityBuffSets.IsDebuff[i])) Player.lifeRegen += 3; - if (Player.lifeRegenTime < 1800) - Player.lifeRegenTime = 1800; + } + + //If a player had a life regen hindering debuff, add 30 seconds to their regen time when under Tequila Sunrise + //This stacks with all other post-debuff boosts due to Tequila Sunrise increasing DoT damage taken + if (tequilaSunrise) + { + if (hadLifeRegenHinderingDebuff && !hasLifeRegenHinderingDebuff) + { + Player.lifeRegenTime += 1800; } } #endregion // During Silva revive or God Slayer dash, all negative life regen is canceled - if ((silvaCountdown > 0 && hasSilvaEffect && silvaSet) || (DashID == GodSlayerDash.ID && Player.dashDelay < 0)) + if ((silvaCountdown > 0 && hasSilvaEffect && silvaSet) || (LastUsedDashID == GodslayerArmorDash.ID && Player.dashDelay < 0)) { if (Player.lifeRegen < 0) Player.lifeRegen = 0; @@ -523,7 +479,7 @@ namespace CalamityMod.CalPlayer Player.lifeRegenCount = 0; } - if (hInferno) + if (holyInferno) { Player.nebulaLevelLife = 0; @@ -562,18 +518,15 @@ namespace CalamityMod.CalPlayer // Chalice of the Blood God bleedout // The bleedout is applied by directly reducing the player's health. It is not canceled by anything. ChaliceOfTheBloodGod.HandleBleedout(Player); + + //Finally, update the state of hadLifeRegenHinderingDebuff for next frame. + hadLifeRegenHinderingDebuff = hasLifeRegenHinderingDebuff; } #endregion #region Update Life Regen public override void UpdateLifeRegen() { - if (rum) - Player.lifeRegen += Rum.RegenBoost; - - if (caribbeanRum) - Player.lifeRegen += CaribbeanRum.RegenBoost; - if (mushy) Player.lifeRegen += Mushy.RegenBoost; @@ -588,11 +541,14 @@ namespace CalamityMod.CalPlayer } if (tRegen) - Player.lifeRegen += 3; + Player.lifeRegen += TarragonHeadMelee.TarraLifeRegenBoost; if (sRegen) Player.lifeRegen += SpiritGlyph.RegenBoost; + if (fortunesFavor) + Player.lifeRegen += FortunesFavor.FortunesFavorRegenBoost; + if (PinkJellyRegen) Player.lifeRegen += LifeJelly.AuraRegenBoost; @@ -606,26 +562,21 @@ namespace CalamityMod.CalPlayer Player.lifeRegen += HallowedRune.RegenBoost; if (affliction || afflicted) - Player.lifeRegen += 1; + Player.lifeRegen += Affliction.RegenBoost; if (trinketOfChi || chiRegen) Player.lifeRegen += 2; - // Remember this is for 5 seconds after triggering a reflect with a long cooldown - if (evolutionLifeRegenCounter > 0) - { - Player.lifeRegen += 12; - if (Player.lifeRegenTime < 3600f) - Player.lifeRegenTime = 3600f; - } - if (darkSunRing) { if (Main.eclipse || Main.dayTime) Player.lifeRegen += Main.eclipse ? 2 : 4; } - if (phantomicHeartRegen <= 720 && phantomicHeartRegen >= 600) + if (silvaSet) + Player.lifeRegen += SilvaArmor.SetBonusRegenBoost; + + if (phantomicHeartRegen > 0 && phantomicHeartRegen < 1000) { Player.lifeRegen += PhantomicArtifact.RegenBoost; if (Main.rand.NextBool()) @@ -648,7 +599,7 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < Player.MaxBuffs; l++) { int hasBuff = Player.buffType[l]; - lesserEffect = AlcoholsDict.TryGet(hasBuff, out var a); + lesserEffect = CalamityBuffSets.AlcoholStrength.TryGetValue(hasBuff, out var a); } if (Player.lifeRegen < 0) Player.lifeRegen += lesserEffect ? 1 : regenBoost; @@ -663,40 +614,15 @@ namespace CalamityMod.CalPlayer Player.lifeRegen += 4; } - if (bloodflareSummon) - { - if (Player.statLife <= (int)(actualMaxLife * 0.5)) - Player.lifeRegen += 2; - } - if (fearmongerSet && fearmongerRegenFrames > 0) { - Player.lifeRegen += 7; + if (Player.lifeRegenTime < FearmongerGreathelm.MinionRegenTimeFloor) + Player.lifeRegenTime = FearmongerGreathelm.MinionRegenTimeFloor; - if (Player.lifeRegenTime < 1800) - Player.lifeRegenTime = 1800; - - Player.lifeRegenTime += 4; + Player.lifeRegen += FearmongerGreathelm.MinionRegenBoost; + Player.lifeRegenTime += FearmongerGreathelm.MinionRegenTimeBoost; } - if (silvaWings) - { - if (Player.velocity.Y == 0f || Player.wingTime == Player.wingTimeMax) - silvaWingsLifeRegenTimer = 0; - else - { - silvaWingsLifeRegenTimer++; - if (silvaWingsLifeRegenTimer > SilvaWings.LifeRegenTimerMax) - silvaWingsLifeRegenTimer = SilvaWings.LifeRegenTimerMax; - } - - // Life regen boost scales up to 8 HP/s based on how long you stay in the air without resetting flight time - int lifeRegenBoost = (int)MathHelper.Lerp(0f, 16f, silvaWingsLifeRegenTimer / (float)SilvaWings.LifeRegenTimerMax); - Player.lifeRegen += lifeRegenBoost; - } - else - silvaWingsLifeRegenTimer = 0; - if (pinkCandle && !noLifeRegen) { // Every frame, add up 1/60th of the healing value (0.4% max HP per second) @@ -711,124 +637,62 @@ namespace CalamityMod.CalPlayer else pinkCandleHealFraction = 0D; - if (reaverRegen && reaverRegenCooldown >= 60) + if (manaOverloader) { - reaverRegenCooldown = 0; - - if (Player.statLife != Player.statLifeMax2 && !noLifeRegen) - Player.HealPlayer(1, HealTextType.None); - } - - if (BloomStoneRegen) - { - float dayTimeCompletion = !Main.dayTime ? 1f : (float)(Main.time / Main.dayLength); - float regenBenefitFactor = MathHelper.SmoothStep(0.25f, 1f, Utils.GetLerpValue(0f, 0.24f, dayTimeCompletion, true) * Utils.GetLerpValue(1f, 0.76f, dayTimeCompletion, true)); - - Player.lifeRegen += (int)MathHelper.Lerp(2f, 6f, regenBenefitFactor); - Player.lifeRegenTime += (int)MathHelper.Lerp(1f, 3f, regenBenefitFactor); + float manaRatio = Player.statMana / (float)Player.statManaMax2; + Player.lifeRegen += (int)(MathF.Round(MathHelper.Lerp(4f, -4f, manaRatio)) * (Player.HasBuff(BuffID.ManaSickness) ? 0.5f : 1f)); } #region Standing Still Life Regen // Standing still healing bonuses (all are exclusive with vanilla Shiny Stone, but all function similarly) - if (!Player.shinyStone && Player.StandingStill() && Player.velocity.Y == 0 && Player.itemAnimation == 0) + if (!Player.shinyStone && Player.StandingStill() && Player.velocity.Y == 0 && Player.itemAnimation == 0 && (shadeRegen || cFreeze)) { - bool honeyDewWorking = honeyTurboRegen && Player.honeyWet; - bool anyStandingStillLifeRegen = shadeRegen || cFreeze || honeyDewWorking || aAmpoule || purity; - // Divides all negative life regen by two before applying any other effects. - if (anyStandingStillLifeRegen && Player.lifeRegen < 0) + if (Player.lifeRegen < 0) Player.lifeRegen /= 2; - // Spawn dust of some flavor while actually regenerating, aAmpule and purity have a slightly different looking style + // Spawn dust of some flavor while actually regenerating if (Player.lifeRegen > 0 && Player.statLife < actualMaxLife) { - int dustType = shadeRegen ? 173 : cFreeze ? 67 : honeyDewWorking ? DustID.Honey2 : aAmpoule ? 228 : purity ? 187 : -1; - bool dustSpawnRolled = Main.rand.Next(30000) < Player.lifeRegenTime || purity ? Main.rand.NextBool() : aAmpoule ? Main.rand.NextBool(4) : Main.rand.NextBool(30); + int dustType = shadeRegen ? 173 : 67; + bool dustSpawnRolled = Main.rand.Next(30000) < Player.lifeRegenTime ? Main.rand.NextBool() : Main.rand.NextBool(30); if (dustType != -1 && dustSpawnRolled) { - Dust regen = Dust.NewDustDirect(Player.position, Player.width, Player.height, dustType, 0f, 0f, purity || aAmpoule ? 80 : 200, default, purity || aAmpoule ? 0.5f : 1f); + Dust regen = Dust.NewDustDirect(Player.position, Player.width, Player.height, dustType, 0f, 0f, 200, default, 1f); regen.noGravity = true; regen.fadeIn = 1.3f; Vector2 velocity = CalamityUtils.RandomVelocity(100f, 50f, 100f, 0.04f); regen.velocity = velocity; velocity.Normalize(); - velocity *= purity || aAmpoule ? 55f : 34f; regen.position = Player.Center - velocity; } } // Actually apply "standing still" regeneration (the stats are granted even at full health) - float regenTimeNeededForTurboRegen = shadeRegen ? 40f : cFreeze ? 60f : honeyDewWorking ? 90f : aAmpoule ? 90f : purity ? 60f : -1f; + float regenTimeNeededForTurboRegen = shadeRegen ? 40f : 60f; - // 4 = vanilla Shiny Stone - int turboRegenPower = shadeRegen || cFreeze || purity ? 4 : honeyDewWorking || aAmpoule ? 3 : -1; + // After a brief delay determined by your form of standing still regen, min-cap life regen time at 900 / 3600. + if (Player.lifeRegenTime > regenTimeNeededForTurboRegen && Player.lifeRegenTime < 900f) + Player.lifeRegenTime = 900f; - if (turboRegenPower > 0) - { - // After a brief delay determined by your form of standing still regen, min-cap life regen time at 1800 / 3600. - if (Player.lifeRegenTime > regenTimeNeededForTurboRegen && Player.lifeRegenTime < 1800f) - Player.lifeRegenTime = 1800f; - - Player.lifeRegen += turboRegenPower; - Player.lifeRegenTime += turboRegenPower; - } + Player.lifeRegen += 4; + Player.lifeRegenTime += 4; } #endregion - // Life regen soft cap. - if (Player.statLife < actualMaxLife) + if (regenerator) // Gives special regen of it's own, but disables all regular life regen { - // The soft cap doesn't apply if the player is not moving and not using a weapon while having any of the following: - // Shiny Stone, Cosmic Freeze buff from the Cosmic Discharge, Demonshade Armor, Regenator, or The Camper. - int baseLifeRegenBoost = 4; - bool noLifeRegenCap = (Player.shinyStone || cFreeze || shadeRegen || camper || regenator) && - Player.StandingStill() && Player.itemAnimation == 0; - - if (!noLifeRegenCap) - { - // Calculate the % of HP the player has left. - float maxLifeRatio = Player.statLife / (float)actualMaxLife; - - // Calculate the ratio of the player's current max life relative to the starting HP of 100. - // This makes the soft cap far less harsh at lower amounts of max life. - // Ranges from 20 (at 100 max life) to 4 (at 500 max life) to 2 (at 1000 max life) to 1 (at greater than 2000 max life). - int lifeRegenSoftCapMax = 20; - int lifeRegenSoftCapMin = (int)Math.Round(100f / actualMaxLife * lifeRegenSoftCapMax); - - // The soft cap for life regen which ranges from 20 (at less than 5% HP) to 1 (at greater than or equal to 95% HP). - // This value is capped at a min and max amount. - int lifeRegenSoftCap = (int)MathHelper.Clamp((int)Math.Round((1f - maxLifeRatio) * lifeRegenSoftCapMax), lifeRegenSoftCapMin, lifeRegenSoftCapMax); - - // If life regen is greater than the calculated soft cap, reduce it. - if (Player.lifeRegen - baseLifeRegenBoost > lifeRegenSoftCap) - { - // The scalar used to calculate how much the life regen stat should be reduced by. - // Ranges from 1 (at 0% HP) to 2 (at 100% HP). - float lifeRegenScalar = 1f + maxLifeRatio; - - // Calculate the amount of life regen the player should get according to the soft cap and their current % HP remaining. - // The higher the player's % HP remaining the less life regen they get and vice versa. - int defLifeRegen = (int)((Player.lifeRegen - baseLifeRegenBoost) / lifeRegenScalar); - - // Set the player's life regen to the scaled amount. - Player.lifeRegen = baseLifeRegenBoost + defLifeRegen; - } - } - } - - if (regenator) // Gives special regen of it's own, but disables all regular life regen - { - if (Player.miscCounter % 7 == 0 && Player.statLife < (int)(Player.statLifeMax2 * 0.5f)) + if (Player.miscCounter % Regenerator.FramesPerHeal == 0 && Player.statLife < (int)(Player.statLifeMax2 * 0.5f)) Player.HealPlayer(1, HealTextType.None); // Boost life regen time quite a bit. // This is so that in events and such where small hits are common, your damage boost isn't completley negated if (Player.lifeRegenTime < 3600) - Player.lifeRegenTime += 10; + Player.lifeRegenTime += Regenerator.RegenTimeBoost; } else - regenatorDamage = 0; + regeneratorDamage = 0; if (toxicHeart) // Since it needs to know your life regen, it must be placed here { @@ -883,8 +747,8 @@ namespace CalamityMod.CalPlayer } } - // Regenator trades all positive regen for damage, and caps your health gain at 50% - if (regenator) + // Regenerator trades all positive regen for damage, and caps your health gain at 50% + if (regenerator) { int finalRegen = Player.lifeRegen + (int)Math.Round(regen * (Player.statLifeMax2 / 400f * 0.85f + 0.15f)); finalRegen = (int)Math.Max(finalRegen, 0); @@ -894,8 +758,8 @@ namespace CalamityMod.CalPlayer if (Player.palladiumRegen) finalRegen += 4; - regenatorDamage = (finalRegen * 1.75f) * 0.01f; - Player.GetDamage() += regenatorDamage; + regeneratorDamage = finalRegen * Regenerator.RegenToDamageRatio; + Player.GetDamage() += regeneratorDamage; if (Player.lifeRegen > 0) Player.lifeRegen = 0; @@ -904,11 +768,11 @@ namespace CalamityMod.CalPlayer if (Player.lifeRegenCount > 0) Player.lifeRegenCount = 0; - //Hard-lock the player's health to 50%. + //Hard-lock the player's health to a certain ratio. //No lifesteal, no regen, no healing pots - if (Player.statLife >= (int)(Player.statLifeMax2 * 0.5f)) + if (Player.statLife >= (int)(Player.statLifeMax2 * Regenerator.HealthRatioCap)) { - Player.statLife = (int)(Player.statLifeMax2 * 0.5f); + Player.statLife = (int)(Player.statLifeMax2 * Regenerator.HealthRatioCap); Player.moonLeech = true; healingPotionMultiplier = 0; } diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 64f5c79438..08124231a6 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3,9 +3,11 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Potions; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer.Dashes; using CalamityMod.Cooldowns; using CalamityMod.CustomRecipes; using CalamityMod.DataStructures; @@ -16,32 +18,33 @@ using CalamityMod.ExtraTextures; using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Ammo; +using CalamityMod.Items.Armor.Aerospec; +using CalamityMod.Items.Armor.Auric; using CalamityMod.Items.Armor.Bloodflare; using CalamityMod.Items.Armor.Brimflame; using CalamityMod.Items.Armor.DesertProwler; +using CalamityMod.Items.Armor.Empyrean; +using CalamityMod.Items.Armor.GodSlayer; using CalamityMod.Items.Armor.Hydrothermic; using CalamityMod.Items.Armor.LunicCorps; using CalamityMod.Items.Armor.OmegaBlue; +using CalamityMod.Items.Armor.PlagueReaper; using CalamityMod.Items.Armor.Prismatic; using CalamityMod.Items.Armor.Reaver; using CalamityMod.Items.Armor.Silva; using CalamityMod.Items.Armor.Tarragon; -using CalamityMod.Items.Armor.Wulfrum; using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Dyes; -using CalamityMod.Items.Fishing.FishingRods; using CalamityMod.Items.Mounts.Minecarts; -using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Potions.Food; using CalamityMod.Items.Tools; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Typeless; using CalamityMod.NPCs; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; @@ -55,6 +58,7 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Pets; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; @@ -65,10 +69,8 @@ using CalamityMod.Tiles.FurnitureAuric; using CalamityMod.Tiles.Ores; using CalamityMod.UI; using CalamityMod.World; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Mono.Cecil; using ReLogic.Content; using Terraria; using Terraria.Audio; @@ -78,6 +80,7 @@ using Terraria.GameContent.Events; using Terraria.GameInput; using Terraria.Graphics.Shaders; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; @@ -98,16 +101,6 @@ namespace CalamityMod.CalPlayer if (fearmongerRegenFrames > 0) fearmongerRegenFrames--; - // Go through the old positions for the player. - for (int i = Player.Calamity().OldPositions.Length - 1; i > 0; i--) - { - if (OldPositions[i - 1] == Vector2.Zero) - OldPositions[i - 1] = Player.position; - - OldPositions[i] = OldPositions[i - 1]; - } - OldPositions[0] = Player.position; - // Tile effects for touching tiles HandleTileEffects(); @@ -142,9 +135,6 @@ namespace CalamityMod.CalPlayer // Limits Limits(); - // This is used to increase horizontal velocity based on the player's movement speed stat. - moveSpeedBonus = Player.moveSpeed - 1f; - // Potions (Quick Buff && Potion Sickness) HandlePotions(); @@ -154,15 +144,15 @@ namespace CalamityMod.CalPlayer // Check if schematics are present on the mouse, for the sake of registering their recipes. CheckIfMouseItemIsSchematic(); - // Do environmental effects. - DoEnvironmentalEffects(); - // Handle Androomba's Right Click function AndroombaRightClick(); // Drawing parameters UpdateDrawingParameters(); + // Handle Lucrecia's passive energy effects + HandleLucreciaLineEffects(); + // Update all particle sets for items. // This must be done here instead of in the item logic because these sets are not properly instanced // in the global classes. Attempting to update them there will cause multiple updates to one set for multiple items. @@ -184,18 +174,48 @@ namespace CalamityMod.CalPlayer StandardSync(); } - if (syncMouseControls) + if (syncMouseRightClick) { - syncMouseControls = false; - MouseControlsSync(); + syncMouseRightClick = false; + MouseRightClickSync(); + } + + mouseWorldPacketTimer = Math.Min(mouseWorldPacketTimer + 1, MouseWorldPacketInterval); + if (mouseWorldPacketTimer >= MouseWorldPacketInterval) + { + if (syncMousePosition) + { + mouseWorldPacketTimer = 0; + syncMousePosition = false; + syncMouseRotation = false; // Rotation also get update on position packet + MousePositionSync(); + } + + if (syncMouseRotation) + { + mouseWorldPacketTimer = 0; + syncMouseRotation = false; + MouseRotationSync(); + } } } - if (Player.ActiveItem().type != ModContent.ItemType()) + if (Player.HeldItem.type != ModContent.ItemType()) saharaSlicersBolts = 0; + if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType() && (Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) && !Player.dead && !Main.mapFullscreen && !Player.mouseInterface) + { + int damage = (int)Player.GetTotalDamage().ApplyTo(Player.HeldItem.damage); + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType(), damage, Player.HeldItem.knockBack, Player.whoAmI); + } + if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType() && (Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) && !Player.dead && !Main.mapFullscreen && !Player.mouseInterface) + { + int damage = (int)Player.GetTotalDamage().ApplyTo(Player.HeldItem.damage); + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType(), damage, Player.HeldItem.knockBack, Player.whoAmI); + } + // De-equipping Gael's Greatsword deletes all rage. - if (Player.ActiveItem().type == ModContent.ItemType()) + if (Player.HeldItem.type == ModContent.ItemType()) heldGaelsLastFrame = true; else if (heldGaelsLastFrame) { @@ -203,6 +223,16 @@ namespace CalamityMod.CalPlayer rage = 0f; } + if (furyFuel < FuryFuelMax && furyRefuelTimer >= 0) + { + furyFuel += (int)furyRefuelTimer; + furyRefuelTimer = MathHelper.Lerp(furyRefuelTimer, 25, 0.01f); + if (furyFuel > FuryFuelMax) + furyFuel = FuryFuelMax; + } + else if (furyRefuelTimer < 0) + furyRefuelTimer++; + // De-equipping Draedon's Heart deletes all Adrenaline. if (!draedonsHeart && hadNanomachinesLastFrame) { @@ -213,20 +243,86 @@ namespace CalamityMod.CalPlayer // Apply stealth damage to rogue. Player.GetDamage() += stealthDamage; - //Slow the player down after any other speed modifiers might have been applied. - //Todo - Move this back to the wulfrum set class whenever statmodifiers are implemented for stats other than damage - if (WulfrumHat.PowerModeEngaged(Player, out _)) - Player.moveSpeed *= 0.8f; + if ((XykVisualsBlue || XykVisualsOrange)) + { + bool Orange = XykVisualsOrange; + Color effectColor = Orange ? Color.Gold : Color.DodgerBlue; + + float rate = Main.GlobalTimeWrappedHourly * 12; + List eColors = new List() + { + Orange ? new Color(248, 117, 52) : Color.DodgerBlue, + Orange ? Color.Gold : Color.Cyan, + Orange ? Color.Orange : Color.RoyalBlue + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + effectColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + bool rageOrAdren = (Player.Calamity().rageModeActive || Player.Calamity().adrenalineModeActive); + bool rageAndAdren = (Player.Calamity().rageModeActive && Player.Calamity().adrenalineModeActive); + Color attemptColor = (rageAndAdren ? new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB) : Player.Calamity().adrenalineModeActive ? Color.MediumSpringGreen : Player.Calamity().rageModeActive ? Color.Crimson : effectColor); + XykFXColor = Color.Lerp(XykFXColor, attemptColor, rageOrAdren ? 0.05f : 0.25f); + + + int maxWingPieces = 7; + int numOfActiveWings = 0; + foreach (Projectile p in Main.ActiveProjectiles) + if (p.type == ModContent.ProjectileType() && p.owner == Player.whoAmI && p.ai[1] == 0) + numOfActiveWings++; + bool spawnWings = numOfActiveWings < maxWingPieces && !Player.dead && Player.wingsLogic > 0 && ((!(Player.wingTime == Player.wingTimeMax && Player.velocity.Y == 0) && Player.wingTime > 0) || XykWingTimer >= 3); + if (spawnWings) + { + if (XykWingTimer >= 3) + { + int wingCount = numOfActiveWings; + Projectile wings = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Player.whoAmI, wingCount); + if (numOfActiveWings + 1 == maxWingPieces) + XykWingTimer = 0; + } + else + XykWingTimer++; + } + else + XykWingTimer = 0; + } // First Frame dash effects - bool dashStart = (Player.dashDelay == -1 && IsFirstDashFrame); + bool dashStart = (Player.dashDelay == -1 && ((!HasCustomDash && IsFirstDashFrame) || (HasCustomDash && UsedDash.DashTimeAdjustedForStartup == 1))); int dir = MathF.Sign(Player.velocity.X); + if (dashStart) + { + lastDashWasTabi = false; + } + if (((gShell && giantShellPostHit == 0) || (tortShell && tortShellPostHit == 0)) && dashStart) { Player.velocity.X *= 0.9f; } + // Tabi/Master Ninja Gear dash change + if (lastDashWasTabi) + { + Player.dashType = 1; + } + if (Player.dashType == 1 && !Player.Calamity().statisNinjaBelt && !Player.Calamity().statisVoidSash) + { + if (dashStart) + { + Player.velocity.X *= 2f; + lastDashWasTabi = true; + } + if (Player.dashDelay == -1) + { + Player.velocity.X *= 0.95f; + if (Player.timeSinceLastDashStarted > 12) + { + Player.velocity.X *= 0.75f; + } + } + } if ((devilsDevastationKillMode || exaltedKillMode) && !Player.mount.Active) { float fxScale = 1; @@ -292,53 +388,159 @@ namespace CalamityMod.CalPlayer Lighting.AddLight(Player.Center, Color.MediumOrchid.ToVector3()); } + // Restore flight time during Vortex stealth with Vortex Booster + if (Player.vortexStealthActive && Player.wingsLogic == (int)VanillaWingID.WingsVortex) + { + if (Player.wingTime > 0 && Player.miscCounter % 3 == 0) + Player.wingTime++; + } + + if (Player.HeldItem.type == ModContent.ItemType() && darklightEnergy > 0) + { + if (darklightEnergy == Lucrecia.MaxEnergy && !darklightEnergyPaused) + { + darklightEnergyPaused = true; + darklightEnergyTimer = 0; + } + + darklightEnergyTimer++; + + // If the energy is at max, pause for 180 ticks + if (darklightEnergyPaused) + { + if (darklightEnergyTimer >= 1 && !darklightEnergyMaxFXPlayed) + { + SoundStyle maxEnergyReached = new("CalamityMod/Sounds/Custom/AbilitySounds/DarklightEnergyCharged"); + SoundEngine.PlaySound(maxEnergyReached with { Volume = 0.9f }, Player.Center); + + for (int i = 0; i < 10; i++) // Circular ring of particles burst from player + { + float angle = MathHelper.TwoPi * (i / 10f); + Vector2 spawnDirection = angle.ToRotationVector2(); + Vector2 velocity = spawnDirection * 14f; + + CritSpark spark = new CritSpark(Player.Center + spawnDirection * 3f, velocity, Color.Lerp(Color.CornflowerBlue, Color.MediumPurple, Main.rand.NextFloat(1f)), Color.White * 0.33f, 1.2f, 12, 0.3f, 1.2f); + GeneralParticleHandler.SpawnParticle(spark); + } + darklightEnergyMaxFXPlayed = true; + } + + // If the pause is Done, resume decrementing. + if (darklightEnergyTimer >= 180) + { + darklightEnergyPaused = false; + darklightEnergyTimer = 0; + darklightEnergy--; + } + } + else // Decrementing + { + darklightEnergyMaxFXPlayed = false; + // Once every 20 ticks + if (darklightEnergyTimer >= 20) + { + darklightEnergy--; + darklightEnergyTimer = 0; + } + } + } + else + { + // Reset all energy variables when not holding the weapon + darklightEnergyTimer = 0; + darklightEnergyPaused = false; + darklightEnergy = 0; + } + + if (Player.HeldItem.type == ModContent.ItemType() && elementalMastery > 0) + { + if (elementalMastery == Lightspeed.MaxEnergy && !elementalMasteryPaused) + { + elementalMasteryPaused = true; + elementalMasteryTimer = 0; + } + + elementalMasteryTimer++; + + // If the mastery is at max, pause for 180 ticks + if (elementalMasteryPaused) + { + if (elementalMasteryTimer >= 1 && !elementalMasterySFXPlayed) + { + SoundStyle maxEnergyReached = new("CalamityMod/Sounds/Custom/AbilitySounds/DarklightEnergyCharged"); + SoundEngine.PlaySound(maxEnergyReached with { Volume = 0.9f }, Player.Center); + + for (int i = 0; i < 10; i++) // Circular ring of particles burst from player + { + float angle = MathHelper.TwoPi * (i / 10f); + Vector2 spawnDirection = angle.ToRotationVector2(); + Vector2 velocity = spawnDirection * 14f; + + CritSpark spark = new CritSpark(Player.Center + spawnDirection * 3f, velocity, Color.Lerp(Color.CornflowerBlue, Color.MediumPurple, Main.rand.NextFloat(1f)), Color.White * 0.33f, 1.2f, 12, 0.3f, 1.2f); + GeneralParticleHandler.SpawnParticle(spark); + } + elementalMasterySFXPlayed = true; + } + // If the pause is Done, resume decrementing. + if (elementalMasteryTimer >= 180) + { + elementalMasteryPaused = false; + elementalMasteryTimer = 0; + elementalMastery--; + } + } + else // Decrementing + { + elementalMasterySFXPlayed = false; + // Once every 30 ticks + if (elementalMasteryTimer >= 30) + { + elementalMastery--; + elementalMasteryTimer = 0; + } + } + } + else + { + // Reset all EM variables when not holding the weapon + elementalMasteryTimer = 0; + elementalMasteryPaused = false; + elementalMastery = 0; + } + + + if (Player.HeldItem.type == ModContent.ItemType() && unstableCastersGauntletVis < 100) + { + + unstableCastersGauntletVisTimer++; + // Gain 0.1% charge once every 4 ticks + if (unstableCastersGauntletVisTimer >= 4) + { + unstableCastersGauntletVis += 0.1f; + unstableCastersGauntletVisTimer = 0; + } + + } + if (unstableCastersGauntletVis >= 100) + unstableCastersGauntletVis = 100; + if (lAmbergris) { if (dashStart) { - Player.velocity.X *= 1.2f; + Player.velocity.X *= 2.2f; // +120% dash speed int damage = (int)Player.GetBestClassDamage().ApplyTo(LeviathanAmbergris.ambergrisDashDamage); - - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); } if (Player.miscCounter % 3 == 2 && Player.dashDelay > 0) // Reduced dash cooldown by 33% Player.dashDelay--; - if (Player.dashDelay == -1)// TODO: prevent working with special dashes, this was inconsitent with my old solution so I didn't keep it. not huge deal) - { - float numberOfDusts = 10f; - float rotFactor = 180f / numberOfDusts; - for (int i = 0; i < numberOfDusts; i++) - { - float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(Player.velocity.X * dir * 0.7f + 6f, 0).RotatedBy(rot * Main.rand.NextFloat(4f, 5f)); - Vector2 velOffset = Vector2.Zero; - Dust dust = Dust.NewDustPerfect(Player.Center + offset + Player.velocity, Main.rand.NextBool() ? 160 : 307, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - dust.alpha = 100; - dust.scale = (Player.velocity.X * dir * 0.08f); - } - if (Player.miscCounter % 4 == 0) - { - float sparkscale = (Player.velocity.X * dir * 0.07f); - Vector2 SparkVelocity1 = Player.velocity.RotatedBy(dir * 2, default) * 0.1f - Player.velocity / 2f; - LineParticle spark = new LineParticle(Player.Center + Player.velocity.RotatedBy(2f * dir) * 1.5f, SparkVelocity1, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); - GeneralParticleHandler.SpawnParticle(spark); - Vector2 SparkVelocity2 = Player.velocity.RotatedBy(dir * -2, default) * 0.1f - Player.velocity / 2f; - LineParticle spark2 = new LineParticle(Player.Center + Player.velocity.RotatedBy(-2f * dir) * 1.5f, SparkVelocity2, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); - GeneralParticleHandler.SpawnParticle(spark2); - } - if (Player.miscCounter % 4 == 0 && Player.velocity != Vector2.Zero) //every other frame spawn the hitbox - { - int damage = (int)Player.GetBestClassDamage().ApplyTo(LeviathanAmbergris.ambergrisDashDamage); - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Player.whoAmI); - } - } + if (Player.dashDelay == -1 && !(HasCustomDash && UsedDash.DashTimeAdjustedForStartup < 1)) + Player.velocity.X *= 0.9f; } - if (Pauldron) + if (sPauldron) { if (dashStart) { @@ -346,56 +548,17 @@ namespace CalamityMod.CalPlayer int damage = (int)Player.GetBestClassDamage().ApplyTo(SlagsplitterPauldron.PauldronSlamDamage); Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Player.whoAmI); } - if (Player.dashDelay == -1)// TODO: prevent working with special dashes, this was inconsitent with my old solution so I didn't keep it. not huge deal) + if (Player.dashDelay == -1) { - int damage = (int)Player.GetBestClassDamage().ApplyTo(SlagsplitterPauldron.PauldronSlamDamage); Player.endurance += 0.1f; - - float numberOfDusts = 10f; - float rotFactor = 180f / numberOfDusts; - for (int i = 0; i < numberOfDusts; i++) - { - float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(MathF.Min(Player.velocity.X * dir * 0.7f + 8f, 20f), 0).RotatedBy(rot * Main.rand.NextFloat(4f, 5f)); - Vector2 velOffset = Vector2.Zero; - Dust dust = Dust.NewDustPerfect(Player.Center + offset + Player.velocity, Main.rand.NextBool() ? 35 : 127, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - dust.alpha = 100; - dust.scale = MathF.Min(Player.velocity.X * dir * 0.08f, 1.2f); - } - float sparkscale = MathF.Min(Player.velocity.X * dir * 0.08f, 1.2f); - Vector2 SparkVelocity1 = Player.velocity.RotatedBy(dir * -3, default) * 0.1f - Player.velocity / 2f; - SparkParticle spark = new SparkParticle(Player.Center + Player.velocity.RotatedBy(2f * dir) * 1.5f, SparkVelocity1, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); - GeneralParticleHandler.SpawnParticle(spark); - Vector2 SparkVelocity2 = Player.velocity.RotatedBy(dir * 3, default) * 0.1f - Player.velocity / 2f; - SparkParticle spark2 = new SparkParticle(Player.Center + Player.velocity.RotatedBy(-2f * dir) * 1.5f, SparkVelocity2, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); - GeneralParticleHandler.SpawnParticle(spark2); - - if (Player.miscCounter % 6 == 0 && Player.velocity != Vector2.Zero) - { - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), SlagsplitterPauldron.PauldronSlamDamage, 0, Player.whoAmI); - } + Player.noKnockback = true; } + } if (XykVisualsBlue || XykVisualsOrange) { bool Orange = XykVisualsOrange; - Color effectColor = Orange ? Color.Gold : Color.DodgerBlue; - - float rate = Main.GlobalTimeWrappedHourly * 22; - List eColors = new List() - { - Orange ? Color.OrangeRed : Color.DodgerBlue, - Orange ? Color.Gold : Color.Cyan, - Orange ? Color.Orange : Color.RoyalBlue - }; - - int colorIndex = (int)(rate / 2 % eColors.Count); - Color currentColor = eColors[colorIndex]; - Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; - effectColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); if (dashStart) { @@ -403,18 +566,18 @@ namespace CalamityMod.CalPlayer SoundEngine.PlaySound(dash with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0f, 0.2f) + (Orange ? 0 : 0.2f) }, Player.Center); if (Orange) { - Particle spark1 = new CustomPulse(Player.Center, Vector2.Zero, effectColor, "CalamityMod/Particles/GlowSquareParticleBig", Vector2.One, MathHelper.PiOver4, 0.45f, 0.25f, 47); + Particle spark1 = new CustomPulse(Player.Center, Vector2.Zero, XykFXColor, "CalamityMod/Particles/GlowSquareParticleBig", Vector2.One, MathHelper.PiOver4, 0.45f, 0.25f, 47); GeneralParticleHandler.SpawnParticle(spark1); - Particle spark2 = new CustomPulse(Player.Center, Vector2.Zero, effectColor, "CalamityMod/Particles/GlowSquareParticleBig", Vector2.One, MathHelper.PiOver4, 0, 0.8f, 17); + Particle spark2 = new CustomPulse(Player.Center, Vector2.Zero, XykFXColor, "CalamityMod/Particles/GlowSquareParticleBig", Vector2.One, MathHelper.PiOver4, 0, 0.8f, 17); GeneralParticleHandler.SpawnParticle(spark2); } else { - Particle spark1 = new CustomPulse(Player.Center, Player.velocity * 0.3f, effectColor, "CalamityMod/Particles/BloomRing", new Vector2(0.4f, 1f), Player.velocity.ToRotation(), 0, 1f, 24); + Particle spark1 = new CustomPulse(Player.Center, Player.velocity * 0.3f, XykFXColor, "CalamityMod/Particles/BloomRing", new Vector2(0.4f, 1f), Player.velocity.ToRotation(), 0, 1f, 24); GeneralParticleHandler.SpawnParticle(spark1); - Particle spark2 = new CustomPulse(Player.Center, Player.velocity * 0.5f, effectColor, "CalamityMod/Particles/BloomRing", new Vector2(0.5f, 1f), Player.velocity.ToRotation(), 0, 0.75f, 17); + Particle spark2 = new CustomPulse(Player.Center, Player.velocity * 0.5f, XykFXColor, "CalamityMod/Particles/BloomRing", new Vector2(0.5f, 1f), Player.velocity.ToRotation(), 0, 0.75f, 17); GeneralParticleHandler.SpawnParticle(spark2); } } @@ -426,33 +589,35 @@ namespace CalamityMod.CalPlayer if (!Orange) { float sine = (float)Math.Sin(Player.miscCounter * 0.875f / MathHelper.Pi); + for (int i = -1; i <= 1; i += 2) + { + Vector2 offset = Player.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 18f * i; - Vector2 offset = Player.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 17f; - - Particle spark1 = new GlowSparkParticle(Player.Center + offset + SparkVelocity1, SparkVelocity1 * 2 * sparkscale1, false, 25, 0.04f * sparkscale1, effectColor * 0.9f, new Vector2(0.8f, 0.3f), true, false, 0.4f); - GeneralParticleHandler.SpawnParticle(spark1); - Particle spark2 = new GlowSparkParticle(Player.Center - offset + SparkVelocity1, SparkVelocity1 * 2 * sparkscale1, false, 25, 0.04f * sparkscale1, effectColor * 0.9f, new Vector2(1, 0.3f), true, false, 0.4f); - GeneralParticleHandler.SpawnParticle(spark2); + Particle spark1 = new CustomSpark(Player.Center + offset + SparkVelocity1, SparkVelocity1 * 2 * sparkscale1, "CalamityMod/Particles/BloomCircle", false, 15, 0.3f * sparkscale1, XykFXColor * 0.85f, new Vector2(0.9f, 1.4f), true, true, 0, shrinkSpeed: 0.2f, glowOpacity: 0.85f); + GeneralParticleHandler.SpawnParticle(spark1); + } } else { float sparkscale2 = MathF.Min(Player.velocity.X * dir * 0.07f, 1.1f); - Vector2 SparkVelocity2 = Player.velocity.RotatedBy(dir * 2.5f, default) * 0.1f - Player.velocity / 2f; - Particle spark = new LineParticle(Player.Center + (Player.velocity.SafeNormalize(Vector2.UnitX) * 15).RotatedBy(2f * dir) * 1.5f, SparkVelocity2, false, 10, sparkscale2, effectColor); - GeneralParticleHandler.SpawnParticle(spark); - Vector2 SparkVelocity3 = Player.velocity.RotatedBy(dir * -2.5f, default) * 0.1f - Player.velocity / 2f; - Particle spark2 = new LineParticle(Player.Center + (Player.velocity.SafeNormalize(Vector2.UnitX) * 15).RotatedBy(-2f * dir) * 1.5f, SparkVelocity3, false, 10, sparkscale2, effectColor); - GeneralParticleHandler.SpawnParticle(spark2); + for (int i = -1; i <= 1; i += 2) + { + Vector2 offset = Player.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * 17f * i; + + Particle spark1 = new CustomSpark(Player.Center + offset + SparkVelocity1, SparkVelocity1 * 2 * sparkscale1, "CalamityMod/Particles/BloomCircle", false, 20, 0.4f * sparkscale1, XykFXColor * 0.95f, new Vector2(0.3f, 1.2f), true, true, 0, shrinkSpeed: 0.2f, glowOpacity: 0.95f); + GeneralParticleHandler.SpawnParticle(spark1); + } } for (int i = 0; i < 2; i++) { - Dust dust = Dust.NewDustPerfect(Player.Center + Main.rand.NextVector2Circular(20, 30) + SparkVelocity1, 267, SparkVelocity1 * Main.rand.NextFloat(0.5f, 3f) * sparkscale1, 0, default, Main.rand.NextFloat(0.7f, 1.1f) * sparkscale1); + bool altDust = Main.rand.NextBool(3); + Dust dust = Dust.NewDustPerfect(Player.Center + Main.rand.NextVector2Circular(20, 30) + SparkVelocity1, altDust ? (Orange ? ModContent.DustType() : ModContent.DustType()) : ModContent.DustType(), SparkVelocity1 * Main.rand.NextFloat(0.5f, 3f) * sparkscale1, 0, default, Main.rand.NextFloat(1.5f, 1.9f) * sparkscale1); dust.noGravity = true; - dust.color = effectColor; - - Dust dust2 = Dust.NewDustPerfect(Player.Center + Main.rand.NextVector2Circular(20, 30) + SparkVelocity1, 10, SparkVelocity1 * Main.rand.NextFloat(0.5f, 3f) * sparkscale1, 0, default, Main.rand.NextFloat(0.9f, 1.4f) * sparkscale1); - dust2.noGravity = true; + dust.color = XykFXColor; + dust.fadeIn = altDust ? 0 : 2; + if (altDust) + dust.scale *= 0.5f; } } } @@ -467,10 +632,34 @@ namespace CalamityMod.CalPlayer } } + + if (cinnamonRoll) + { + if (dashStart) + Player.velocity.X *= 3; + else if (Player.dashDelay == -1) + Player.velocity.X *= 0.8f; + } + if (Player.dashDelay == -1) IsFirstDashFrame = false; else IsFirstDashFrame = true; + + // THIS MUST BE NEAR THE END OF PostUpdateMiscEffects SO ALL OTHER RUN SPEED IS DONE FIRST. DO NOT PUT ANY RUN SPEED AFTER THIS + + // Multiplies movement speed by 1.5x so that you don't feel like a snail in the early game. + // This applies to movement speed boosts as well as base speed to ensure they are actually worth their listed value compared to base speed + // + // Disabled while Overhaul is enabled, because Overhaul does very similar things to make movement more snappy + // 22JUN2025: Ozzatron: Disabled while Remnants is enabled, because Remnants has its own move speed reworks. + + bool ignoreSpeedConfig = ExternalMods.overhaul is not null || ExternalMods.remnants is not null; + if (!ignoreSpeedConfig && CalamityServerConfig.Instance.FasterBaseSpeed) + Player.moveSpeed *= BalancingConstants.DefaultMoveSpeedBoost; + + // This is used to increase horizontal velocity based on the player's movement speed stat. + moveSpeedBonus = Player.moveSpeed - 1f; } #endregion @@ -487,8 +676,8 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < Player.MaxBuffs; l++) { int hasBuff = Player.buffType[l]; - if (Player.buffTime[l] > 360 && hasBuff == BuffID.ShadowDodge) - Player.buffTime[l] = 360; + if (Player.buffTime[l] > 600 && hasBuff == BuffID.ShadowDodge) + Player.buffTime[l] = 600; } } @@ -532,13 +721,17 @@ namespace CalamityMod.CalPlayer { float rageGen = 0f; - // Shattered Community provides constant rage generation (stronger than Heart of Darkness). + // Shattered Community provides constant rage generation and overrides the value from Heart of Darkness. if (shatteredCommunity) { float scRageGen = rageMax * ShatteredCommunity.RagePerSecond / 60f; if (rageGen < scRageGen) rageGen = scRageGen; } + + // 26MAR2025: Ozzatron: Shattered Community and Heart of Darkness have equal rage generation now. + // It's easier to not change the code here to unify the cases, because there is no reason to. + // // Heart of Darkness grants constant rage generation. else if (heartOfDarkness) { @@ -554,6 +747,22 @@ namespace CalamityMod.CalPlayer if (heldGaelsLastFrame) rageDiff += rageMax * GaelsGreatsword.RagePerSecond / 60f; + float rate = Main.GlobalTimeWrappedHourly * 29; + List eColors = new List() + { + Color.PaleVioletRed, + Color.Coral, + Color.Khaki, + Color.PaleGreen, + Color.Turquoise, + Color.Violet + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + lightRGB = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + // Calculate and grant proximity rage. // Regular enemies can give up to 1x proximity rage. Bosses can give up to 3x. Multiple regular enemies don't stack. // Proximity rage is maxed out when within 10 blocks (160 pixels) of the enemy's hitbox. @@ -584,7 +793,7 @@ namespace CalamityMod.CalPlayer // If they're a boss, reduce the boss distance. // Boss distance will always be >= enemy distance, so there's no need to do another check. // Worm boss body and tail segments are not counted as bosses for this calculation. - if (npc.IsABoss() && !NoRageWormSegmentList.Includes(npc.type)) + if (npc.IsABoss() && !CalamityNPCSets.BossSegmentThatDoesNotGenerateRageFaster[npc.type]) bossDistance = hitboxEdgeDist; } } @@ -635,7 +844,8 @@ namespace CalamityMod.CalPlayer // Apply the rage change and cap rage in both directions. // Changes are only applied if the Rage mechanic is available. - if (RageEnabled) + // CIT 24NOV2025: Fixed an exploit which allowed Rage to persist forever if Revengeance is toggled off while active. + if (RageEnabled || rageDiff < 0f) { rage += rageDiff; if (rage < 0f) @@ -716,7 +926,10 @@ namespace CalamityMod.CalPlayer // Apply the adrenaline change and cap adrenaline in both directions. // Changes are only applied if the Adrenaline mechanic is available. - if (AdrenalineEnabled && adrenalinePauseTimer == 0) + // + // CIT 24NOV2025: Adrenaline cannot be exploited the same way as Rage, since difficulty cannot be changed while a boss is alive. + // Nevertheless, I will still give it the same exploit fix as Rage just in case there is some method to do it. + if ((AdrenalineEnabled || adrenalineDiff < 0f) && adrenalinePauseTimer == 0) { adrenaline += adrenalineDiff; if (adrenaline < 0f) @@ -749,7 +962,6 @@ namespace CalamityMod.CalPlayer int astralOreID = ModContent.TileType(); int auricOreID = ModContent.TileType(); int auricRepulserID = ModContent.TileType(); - int auricLandMineID = ModContent.TileType(); int scoriaOreID = ModContent.TileType(); int abyssKelpID = ModContent.TileType(); @@ -770,15 +982,15 @@ namespace CalamityMod.CalPlayer if (Player.velocity.Length() == 0f) return; - Dust dust = Dust.NewDustDirect(Player.Center, 16, 16, DustID.Firefly, 0.23255825f, 10f, 0, new Color(117, 55, 15), 1.5116279f); + Dust dust = Dust.NewDustDirect(Player.Center, 16, 16, DustID.Firefly, 0.2f, 0f, 0, new Color(117, 55, 15), Main.rand.NextFloat(1f, 2f)); dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } // Ores below here // Seraph Tracers give immunity to block contact effects - if (!tracersSeraph) + if (!seraphTracers) { // Astral Ore inflicts Astral Infection briefly on contact if (tile.TileType == astralOreID) @@ -793,7 +1005,7 @@ namespace CalamityMod.CalPlayer // Auric Rejection causes an electrical explosion that yeets the player a considerable distance // CIT 17AUG2024: Despite providing full invulnerability, Silva armor revive intentionally does not prevent Auric rejection's yeeting. // 25FEB2025 Ozzatron: Added external bool to control Auric Rejection immunity from the ore. - bool rejectionImmunity = auricSet || tracersSeraph || Player.creativeGodMode || externalAuricRejectionImmunity; + bool rejectionImmunity = auricSet || seraphTracers || Player.creativeGodMode || externalAuricRejectionImmunity; bool oreRejection = (tile.TileType == auricOreID) && !rejectionImmunity; // Repulsers always perform this effect because they are player-placed tiles made for this exact purpose @@ -814,22 +1026,11 @@ namespace CalamityMod.CalPlayer Player.velocity += yeetVec * auricRejectionKB; if (tile.TileType == auricOreID) { - Player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AuricRejection").Format(Player.name)), auricRejectionDamage, 0); + Player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AuricRejection").ToNetworkText(Player.name)), auricRejectionDamage, 0); Player.AddBuff(ModContent.BuffType(), 120); } SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ExoMechs/TeslaShoot1"), Player.Center); } - - if (tile.TileType == auricLandMineID) - { - SoundStyle explode = new("CalamityMod/Sounds/Item/DudFire"); - SoundEngine.PlaySound(explode with { Pitch = 0.8f }, touchedTile.ToWorldCoordinates()); - GenericSparkle sparker = new GenericSparkle(touchedTile.ToWorldCoordinates(), Vector2.Zero, Color.Goldenrod, Color.Gold, 2.5f, 9, Main.rand.NextFloat(-0.01f, 0.01f), 2.68f); - GeneralParticleHandler.SpawnParticle(sparker); - Player.RemoveAllIFrames(); - Projectile.NewProjectile(new EntitySource_TileInteraction(Player, touchedTile.X, touchedTile.Y), touchedTile.ToWorldCoordinates(), Vector2.Zero, ModContent.ProjectileType(), 40000, 0f); - WorldGen.KillTile(touchedTile.X, touchedTile.Y, noItem: true); - } } } private void HandleBlazingMouseEffects() @@ -871,9 +1072,12 @@ namespace CalamityMod.CalPlayer if (target.Calamity().cursorFocus >= CalamityGlobalNPC.cursorFocusMax) { - target.Calamity().trueVulnerabilityHex = target.Calamity().vulnerabilityHex >= 300 ? target.Calamity().vulnerabilityHex : 300; - target.Calamity().vulnerabilityHex = 0; - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/WeaponEnchant"), target.Center); + int vHexDuration = 0; + if (target.HasBuff()) + vHexDuration = target.buffTime[target.FindBuffIndex(ModContent.BuffType())]; + target.AddBuff(ModContent.BuffType(), vHexDuration <= 300 ? vHexDuration : 300); + target.RequestBuffRemoval(ModContent.BuffType()); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/WeaponEnchant"), target.Center); for (int i = 0; i < 18; i++) { @@ -897,15 +1101,19 @@ 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, target.whoAmI); + Projectile sigilStrike = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sigilDamage, 0f, Player.whoAmI, target.whoAmI, 255f); // Enable crits by setting the sigil's damage class to be whatever the player's strongest damage class is. sigilStrike.DamageType = Player.GetBestClass(); // Incinerate the target with either Vulnerability Hex or True Vulnerability Hex, depending on current cursor focus. // This adds 8 to the buff duration, which results in a net increase of 3 frames every time damage is dealt, due to damage occurring every 5 frames. - int buffToInflict = target.Calamity().trueVulnerabilityHex > 0 ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffToInflict, target.Calamity().trueVulnerabilityHex > 0 ? target.Calamity().trueVulnerabilityHex + 8 : target.Calamity().vulnerabilityHex < VulnerabilityHex.CalamityDuration ? VulnerabilityHex.CalamityDuration : target.Calamity().vulnerabilityHex + 8); + int buffToInflict = target.Calamity().trueVulnerabilityHex ? ModContent.BuffType() : ModContent.BuffType(); + if (!target.HasBuff(buffToInflict)) + target.AddBuff(buffToInflict, 52); + target.buffTime[target.FindBuffIndex(buffToInflict)] += 8; + if (target.buffTime[target.FindBuffIndex(buffToInflict)] < VulnerabilityHex.CalamityDuration) + target.buffTime[target.FindBuffIndex(buffToInflict)] = VulnerabilityHex.CalamityDuration; // Make some fancy dust to indicate damage is being done. for (int j = 0; j < 12; j++) @@ -922,6 +1130,14 @@ namespace CalamityMod.CalPlayer private void MiscEffects() { + //Mana Burn update + if (ManaBurnFireDrawer != null) + { + ManaBurnFireDrawer.LocalTimer = 0; + ManaBurnFireDrawer.RelativePower = MathHelper.Lerp(0.25f, 0.5f, -Player.statMana / (float)Player.statManaMax2); + ManaBurnFireDrawer.Update(); + } + // Update textures if (!Main.dedServ && Player.whoAmI == Main.myPlayer) { @@ -985,10 +1201,13 @@ namespace CalamityMod.CalPlayer DoGCartSegments = new DoGCartSegment[DoGCartSegments.Length]; // Dust on hand when holding the phosphorescent gauntlet. - if (Player.ActiveItem().type == ModContent.ItemType()) + if (Player.HeldItem.type == ModContent.ItemType()) PhosphorescentGauntletPunches.GenerateDustOnOwnerHand(Player); - - if (stealthUIAlpha > 0f && (rogueStealth <= 0f || rogueStealthMax <= 0f)) + if (temporaryStealthTimer > 0) + { + stealthUIAlpha = 1; + } + else if (stealthUIAlpha > 0f && (rogueStealth <= 0f || rogueStealthMax <= 0f)) { stealthUIAlpha -= 0.035f; stealthUIAlpha = MathHelper.Clamp(stealthUIAlpha, 0f, 1f); @@ -1078,34 +1297,14 @@ namespace CalamityMod.CalPlayer } } - // Life Steal nerf in difficulties above Expert - // Reduces the max possible life steal before the cooldown occurs (this mostly just nerfs how much life steal the player can get in bursts) - // Master Mode nerfs this by an additional 10 - float lifeStealCap = - CalamityWorld.death ? BalancingConstants.LifeStealCap_Death : - CalamityWorld.revenge ? BalancingConstants.LifeStealCap_Revengeance : - Main.expertMode ? BalancingConstants.LifeStealCap_Expert : - BalancingConstants.LifeStealCap_Classic; + if (brittleStar && brittleStarBuffMode) + Player.statDefense += 4 * Player.ownedProjectileCounts[ModContent.ProjectileType()]; - if (Main.masterMode) - lifeStealCap -= BalancingConstants.LifeStealCapReduction_Master; - - if (Player.lifeSteal > lifeStealCap) - Player.lifeSteal = lifeStealCap; - - // Normal Mode life steal recovery rate is 0.2/s - // Expert Mode life steal recovery rate is 0.15/s - // Revengeance Mode life steal recovery rate is 0.125/s - // Death Mode life steal recovery rate is 0.1/s - // Master Mode life steal recovery rate is nerfed by an additional 0.05/s - float lifeStealRecoveryRateReduction = - CalamityWorld.death ? BalancingConstants.LifeStealRecoveryRateReduction_Death : - CalamityWorld.revenge ? BalancingConstants.LifeStealRecoveryRateReduction_Revengeance : - Main.expertMode ? BalancingConstants.LifeStealRecoveryRateReduction_Expert : - BalancingConstants.LifeStealRecoveryRateReduction_Classic; - - if (Main.masterMode) - lifeStealRecoveryRateReduction += BalancingConstants.LifeStealRecoveryRateReduction_Master; + // Reduce the rate of recovery of the Lifesteal variable + // Classic Mode: 36 HP/s to 12 HP/s + // Expert Mode: 30 HP/s to 9 HP/s + float lifeStealRecoveryRateReduction = Main.expertMode ? BalancingConstants.LifeStealRecoveryRateReduction_Expert : BalancingConstants.LifeStealRecoveryRateReduction_Classic; + float lifeStealCap = Main.expertMode ? BalancingConstants.LifeStealCap_Expert : BalancingConstants.LifeStealCap_Classic; if (Player.lifeSteal < lifeStealCap) Player.lifeSteal -= lifeStealRecoveryRateReduction; @@ -1122,7 +1321,7 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < Player.MaxBuffs; l++) { int buffID = Player.buffType[l]; - if (Player.buffTime[l] > 2 && DebuffsList.Includes(buffID)) + if (Player.buffTime[l] > 2 && CalamityBuffSets.IsDebuff[buffID]) Player.buffTime[l]--; } } @@ -1136,7 +1335,7 @@ namespace CalamityMod.CalPlayer ProvidenceBurnEffectDrawer.ParticleSpawnRate = int.MaxValue; // If the player has holy inferno, cause the player to ignite into flames. - if (hInferno) + if (holyInferno) ProvidenceBurnEffectDrawer.ParticleSpawnRate = 1; // Otherwise, if the intensity is too weak, but still present, cause the player to release holy cinders. @@ -1157,11 +1356,11 @@ namespace CalamityMod.CalPlayer } ProvidenceBurnEffectDrawer.Update(); - if (hInferno && holyInfernoFadeIntensity < 1f) + if (holyInferno && holyInfernoFadeIntensity < 1f) { holyInfernoFadeIntensity = MathHelper.Clamp(holyInfernoFadeIntensity + 0.015f, 0f, 1f); } - else if (!hInferno && holyInfernoFadeIntensity > 0f) + else if (!holyInferno && holyInfernoFadeIntensity > 0f) { holyInfernoFadeIntensity = MathHelper.Clamp(holyInfernoFadeIntensity - 0.01f, 0f, 1f); } @@ -1183,7 +1382,7 @@ namespace CalamityMod.CalPlayer Player.AddBuff(ModContent.BuffType(), 2, false); } } - if (iCantBreathe) + if (frozenLungs) { if (Player.breath > 0 && Player.miscCounter % 2 == 0) Player.breath--; @@ -1270,19 +1469,21 @@ namespace CalamityMod.CalPlayer // Increase fall speed if (!Player.mount.Active) { - if (Player.IsUnderwater() && ironBoots) - Player.maxFallSpeed = 9f; - if (!Player.wet) { - if (cirrusDress) - Player.maxFallSpeed = 12f; if (aeroSet) - Player.maxFallSpeed = 15f; + Player.maxFallSpeed = AerospecBreastplate.SetBonusFallSpeed; if (Player.PortalPhysicsEnabled) Player.maxFallSpeed = 20f; } + if (Player.controlDown && !Player.controlJump && (ironBoots || gSabaton) && !gSabatonFalling) + { + Player.maxFallSpeed *= 2; //This ties Slimy Saddle. It is made viable by also allowing the player to move horizontal, unlike Saddle, and curbing existing vertical speed very fast + if (Player.gravDir == 1 ? Player.velocity.Y <= 0 : Player.velocity.Y >= 0) + Player.velocity.Y *= 0.7f; + } + if (LungingDown) { Player.maxFallSpeed = 80f; @@ -1301,10 +1502,6 @@ namespace CalamityMod.CalPlayer if (holdingDown && Player.ControlsEnabled() && notInLiquid && notOnRope && notGrappling && airborne && !Player.Calamity().gSabatonFalling) //Player cannot further increase their ridiculous gravity during a Gravistar Slam { Player.velocity.Y += Player.gravity * Player.gravDir * (BalancingConstants.HoldingDownGravityMultiplier - 1f); - if (Player.Calamity().gSabaton) - { - Player.maxFallSpeed *= 1.5f; - } if (Player.velocity.Y * Player.gravDir > Player.maxFallSpeed) Player.velocity.Y = Player.maxFallSpeed * Player.gravDir; } @@ -1312,10 +1509,16 @@ namespace CalamityMod.CalPlayer } else { - if (Player.mount.Type == MountID.Slime || Player.mount.Type == MountID.PogoStick) + if (Player.mount.Type == MountID.Slime) Player.velocity.X *= 0.91f; else if (Player.mount.Type == MountID.QueenSlime) Player.velocity.X *= 0.95f; + else if (Player.mount.Type == MountID.PogoStick) + { + if (Player.velocity.X > 10 || Player.velocity.X < -10) + Player.velocity.X *= 0.99f; //Stops infinite high-speed movement, but allows fun pogo movement tech still + Player.maxFallSpeed *= 0.75f; // 1.5x fall speed instead of 2x to counterbalance + } } // Increase Rope climb velocities, if enabled @@ -1403,7 +1606,7 @@ namespace CalamityMod.CalPlayer { if (!tentaclesPresent[i]) { - int damage = (int)Player.GetBestClassDamage().ApplyTo(390); + int damage = (int)Player.GetBestClassDamage().ApplyTo(OmegaBlueHelmet.TentacleDamage); var source = Player.GetSource_FromThis(OmegaBlueHelmet.TentacleEntitySourceContext); Vector2 vel = new Vector2(Main.rand.Next(-13, 14), Main.rand.Next(-13, 14)) * 0.25f; @@ -1412,25 +1615,10 @@ namespace CalamityMod.CalPlayer } } - float damageUp = 0.1f; - int critUp = 10; - if (omegaBlueHentai) + if (omegaBlueAbyssalMadness) { - damageUp *= 2f; - critUp *= 2; - } - Player.GetDamage() += damageUp; - Player.GetCritChance() += critUp; - } - - // Rain armor set effects - if (rainSet) - { - if (Player.jump == 15 && Player.whoAmI == Main.myPlayer) // This is technically the frame after you start jumping from the ground - { - bool rainBoost = Player.Center.Y < Main.worldSurface * 16.0 && Main.raining; - int damage = (int)Player.GetBestClassDamage().ApplyTo(30 * (rainBoost ? 2f : 1)); - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Vector2.UnitY * 26, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Main.myPlayer); + Player.GetDamage() += OmegaBlueHelmet.MadnessDamageBoost; + Player.GetCritChance() += OmegaBlueHelmet.MadnessCritBoost; } } @@ -1500,11 +1688,9 @@ namespace CalamityMod.CalPlayer // The fire boots debuff boosts if (hellfireTreads) - bootLevel = 2; + HeatDebuffMultiplier += 0.5f; else if (flameWakerBoots) - bootLevel = 1; - else - bootLevel = 0; + HeatDebuffMultiplier += 0.25f; if (rOfResilienceEffect > 0) rOfResilienceEffect--; @@ -1525,7 +1711,7 @@ namespace CalamityMod.CalPlayer } if (rOfResilienceEffect > 0) { - if (Player.Calamity().mouseRight && rOfResilienceCooldown == 0) + if (Player.Calamity().mouseRight && !Player.mouseInterface && rOfResilienceCooldown == 0) { int cooldownTime = (Player.Calamity().profanedSoulRelicBuff ? 300 : 600); rOfResilienceCooldown = cooldownTime; @@ -1601,9 +1787,10 @@ namespace CalamityMod.CalPlayer if (p.type == ModContent.ProjectileType() && p.owner == Player.whoAmI) { - float insanityValue = ((p.ai[1] % 10) + 1); + int blobNum = Player.ownedProjectileCounts[ModContent.ProjectileType()] + 1; + float insanityValue = (p.ai[1] % 10); if (p.ai[0] == layer) - p.ai[2] = insanityValue / CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), Player.whoAmI) * (angleMax) - (angleMax) / 2f; + p.ai[2] = (insanityValue / blobNum) * angleMax - angleMax / 2f; p.netUpdate = true; } @@ -1624,11 +1811,11 @@ namespace CalamityMod.CalPlayer projectile.damage = (int)(projectile.damage * 0.85f); projectile.friendly = true; } - + if (Vector2.Distance(Player.Center, projectile.Center) <= zoneSize && projectile.active && projectile.hostile && projectile.Calamity().TransformerTimer == 0 && (numOfBlobs < TheTransformer.blobCap || Main.zenithWorld) && transformerDelay == 0) { transformerDelay = 2; // 2 frame delay between projectile transformation - + projectile.Calamity().TransformerTimer = Main.zenithWorld ? 3 : 30; int layer = (int)(Utils.GetLerpValue(0, 10, numOfBlobs + 1) + 0.9f); @@ -1652,15 +1839,16 @@ namespace CalamityMod.CalPlayer if (p.type == ModContent.ProjectileType() && p.owner == Player.whoAmI) { - float insanityValue = ((p.ai[1] % 10) + 1); + int blobNum = Player.ownedProjectileCounts[ModContent.ProjectileType()] + 1; + float insanityValue = (p.ai[1] % 10); if (p.ai[0] == layer) - p.ai[2] = insanityValue / CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), Player.whoAmI) * (angleMax) - (angleMax) / 2f; + p.ai[2] = (insanityValue / blobNum) * angleMax - angleMax / 2f; p.netUpdate = true; index++; } } - + } } } @@ -1676,15 +1864,18 @@ namespace CalamityMod.CalPlayer Projectile projectile = null; if (Player.dashDelay == -1) // When the player dashes, make all the energies exit idle phase { + int energyCount = 0; for (int x = 0; x < Main.maxProjectiles; x++) { projectile = Main.projectile[x]; if (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.ai[2] == 0 && projectile.owner == Player.whoAmI) { projectile.ai[2] = 5; + energyCount++; } } - sSpiritAmuletTimer = -spawnTime; // The spawn cooldown after launching energies is twice as long + if (energyCount > 0) + sSpiritAmuletTimer = -spawnTime; // The spawn cooldown after launching energies is twice as long } int numOfEnergy = 0; for (int x = 0; x < Main.maxProjectiles; x++) // Get a count of energies in idle mode @@ -1698,7 +1889,7 @@ namespace CalamityMod.CalPlayer if (numOfEnergy < energyCap) { int energyDamage = (int)Player.GetBestClassDamage().ApplyTo(22); - Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(Math.PI), ModContent.ProjectileType(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy); + Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(MathHelper.TwoPi), ModContent.ProjectileType(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy); if (numOfEnergy + 1 == energyCap && Player.Calamity().sSpiritAmuletVisual) { SoundStyle transform = new("CalamityMod/Sounds/Item/WaterSplash1"); @@ -1706,7 +1897,7 @@ namespace CalamityMod.CalPlayer for (int i = 0; i <= 14; i++) { - Vector2 vel = (Vector2.One * 5).RotatedByRandom(Math.PI) * Main.rand.NextFloat(0.4f, 1.2f); + Vector2 vel = (Vector2.One * 5).RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.4f, 1.2f); Dust dust2 = Dust.NewDustPerfect(Player.Center, ModContent.DustType(), vel); dust2.scale = Main.rand.NextFloat(0.8f, 1.4f); @@ -1726,6 +1917,155 @@ namespace CalamityMod.CalPlayer } } + if (ironBoots) + { + if (Player.controlDown && !Player.controlJump) + { + if (Player.gravDir == 1 ? Player.velocity.Y > 0 : Player.velocity.Y < 0) + fallingBootVelCheckTimer++; + + if (Player.velocity.Y == 0 && fallingBootVelCheckTimer > 10) + { + float power = Utils.Remap(fallingBootVelCheckTimer, 10, 40, 0.1f, 1); + float scaledPower = (float)Math.Pow(power, 3); + int damage = (int)Player.GetBestClassDamage().ApplyTo(1500 * scaledPower); // Damage scales down thrice + Vector2 playerFeet = Player.Center + Vector2.UnitY * 26 * Player.gravDir; + + float blastSize = 120 * power; + float minMultiplier = 0.1f; + int hitsToMinMult = 6; + int debuff = ModContent.BuffType(); + int debuffTime = (int)(300 * power); + Projectile blast = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), playerFeet, Vector2.Zero, ModContent.ProjectileType(), (int)(damage), -25 * power, Player.whoAmI, blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff; + blast.localAI[1] = debuffTime; + blast.timeLeft = 5; + + int particleNumber = (int)Math.Max(15 * power, 2); + for (int i = -particleNumber; i <= particleNumber; i++) + { + Particle sparks = new AltSparkParticle(playerFeet, (Vector2.UnitX * (5 + Math.Abs(i)) * Math.Sign(i)).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1) * power, false, Main.rand.Next(17, 30 + 1), Main.rand.NextFloat(0.2f, 0.8f), Main.rand.NextBool() ? Color.Lerp(Color.Gold, Color.Silver, 0.3f) : Color.Silver); + GeneralParticleHandler.SpawnParticle(sparks); + } + + SoundStyle sound = new("CalamityMod/Sounds/NPCHit/ExoHit3"); + SoundEngine.PlaySound(sound with { Volume = 0.6f * power, Pitch = Main.rand.NextFloat(0.6f, 0.8f) }, playerFeet); + + Player.SetScreenshake(4 * scaledPower); + fallingBootVelCheckTimer = 0; + } + } + + if (Player.gravDir == 1 ? Player.velocity.Y <= 0 : Player.velocity.Y >= 0) + fallingBootVelCheckTimer = 0; + } + + if (dOfTheDeep) + { + if (dOfTheDeepDefenseBuffTimer > 0) + { + int maxDefense = 10; + int givenDefense = (int)Utils.Remap(dOfTheDeepDefenseBuffTimer, 0, dOfTheDeepDefenseBuffMax * 0.5f, 0, maxDefense); + Player.statDefense += givenDefense; + dOfTheDeepDefenseBuffTimer--; + } + + int spawnTime = 150; // Time between energy spawns + int energyCap = 3; // Max number of energies that can be alive at a time + + Projectile projectile = null; + if (Player.dashDelay == -1 && dOfTheDeepTimer > 0) // When the player dashes, make all the energies exit idle phase + { + int energyCount = 0; + for (int x = 0; x < Main.maxProjectiles; x++) + { + projectile = Main.projectile[x]; + if (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.ai[2] == 0 && projectile.owner == Player.whoAmI) + { + projectile.ai[2] = 5; + energyCount++; + } + } + if (energyCount > 0) + dOfTheDeepTimer = (int)(-spawnTime * 0.5f); // The spawn cooldown after launching energies is longer + } + int numOfEnergy = 0; + for (int x = 0; x < Main.maxProjectiles; x++) // Get a count of energies in idle mode + { + projectile = Main.projectile[x]; + if (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.ai[2] == 0 && projectile.owner == Player.whoAmI) + numOfEnergy++; + } + if (dOfTheDeepTimer >= spawnTime) + { + if (numOfEnergy < energyCap) + { + int energyDamage = (int)Player.GetBestClassDamage().ApplyTo(400); + int energyType = (numOfEnergy % 3); + Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(MathHelper.TwoPi), ModContent.ProjectileType(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy); + energy.localAI[2] = energyType; + if (numOfEnergy + 1 == energyCap && Player.Calamity().dOfTheDeepVisual) + { + SoundStyle max = new("CalamityMod/Sounds/Item/WaterSplash1"); + SoundEngine.PlaySound(max with { Volume = 0.35f, Pitch = 0.8f, MaxInstances = -1 }, Player.Center); + + for (int i = 0; i <= 14; i++) + { + Vector2 vel = (Vector2.One * 5).RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.4f, 1.2f); + + Dust dust2 = Dust.NewDustPerfect(Player.Center, ModContent.DustType(), vel); + dust2.scale = Main.rand.NextFloat(0.8f, 1.4f); + dust2.noGravity = false; + dust2.alpha = 180; + dust2.color = Main.rand.NextBool() ? Color.Turquoise : Color.Aquamarine; + dust2.noLight = true; + dust2.noLightEmittence = true; + } + } + } + dOfTheDeepTimer = 0; + } + else if (!Player.dead) + { + dOfTheDeepTimer++; + } + } + if (hookPullVisuals > 0) + { + if (bloomStone && Player.Calamity().bloomStoneHookVisuals) // Visual flowers while being pulled + { + Vector2 spawnPos = Player.Center + Main.rand.NextVector2Circular(20f, 20f); + float fade = (float)Math.Pow(Utils.GetLerpValue(0, 30, hookPullVisuals, true), 2); + + Particle trail = new CustomSpark(Player.Center, -Player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(5f, 8f), + "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(7, 10 + 1), 0.65f, + Color.Lerp(Color.HotPink, Color.Gold, Utils.GetLerpValue(60, 30, hookPullVisuals, true)) * 0.75f * fade, new Vector2(1f, 0.7f), true, shrinkSpeed: 0.6f); + GeneralParticleHandler.SpawnParticle(trail); + + if (Main.rand.NextBool(3)) + { + Particle floweyFromHitGameUndertale = new CustomSpark(spawnPos, -Player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(5f, 8f), + "CalamityMod/Particles/MiniFlower", false, Main.rand.Next(25, 28 + 1), Main.rand.NextFloat(2.3f, 2.6f) * fade, + Color.Lerp(Color.HotPink, Color.Plum, Main.rand.NextFloat(0, 0.65f)), new Vector2(1f, 1f), true, extraRotation: Main.rand.NextFloat(0, MathHelper.TwoPi)); + GeneralParticleHandler.SpawnParticle(floweyFromHitGameUndertale); + } + if (Main.rand.NextBool()) + { + Dust pollenDust = Dust.NewDustPerfect(Player.Center + Main.rand.NextVector2Circular(20f, 20f), ModContent.DustType()); + pollenDust.noLightEmittence = true; + pollenDust.noGravity = true; + pollenDust.scale = Main.rand.NextFloat(0.9f, 1.4f); + pollenDust.color = Color.Lerp(Color.Gold, Color.HotPink, Utils.GetLerpValue(60, 30, hookPullVisuals, true)); + pollenDust.velocity = -Player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(2f, 5f); + pollenDust.fadeIn = -0.5f * fade; + } + } + + hookPullVisuals--; + if (Player.velocity.Length() < 6) + hookPullVisuals = 0; + } + if (unstableGraniteCore) { zapActivity += 1; @@ -1846,7 +2186,7 @@ namespace CalamityMod.CalPlayer SyncCooldownRemoval(Main.dedServ, expiredCooldowns); // Grant the player 5 seconds of immunity to immobilizing debuffs after an immobilizing debuff wears off. - if (Player.stoned || Player.frozen || Player.webbed || gState) + if (Player.stoned || Player.frozen || Player.webbed) { ImmobilityDebuffImmunityTimer = ImmobilityDebuffImmunityTimerMax; } @@ -1856,11 +2196,12 @@ namespace CalamityMod.CalPlayer Player.buffImmune[BuffID.Stoned] = true; Player.buffImmune[BuffID.Frozen] = true; Player.buffImmune[BuffID.Webbed] = true; - Player.buffImmune[ModContent.BuffType()] = true; } if (arsenalCooldown > 0) arsenalCooldown--; + if (Main.zenithWorld) + arsenalCooldown = 0; if (killModeCooldown > 0) killModeCooldown--; if (ascendantInsigniaCooldown > 0 && ascendantInsigniaBuffTime <= 0) @@ -1879,14 +2220,14 @@ namespace CalamityMod.CalPlayer --fullRageSoundCountdownTimer; if (plagueTaintedSMGDroneCooldown > 0) plagueTaintedSMGDroneCooldown--; + if (flareGunOverheat > 0) + flareGunOverheat--; if (momentumCapacitorTime > 0) --momentumCapacitorTime; if (phantomicHeartRegen > 0 && phantomicHeartRegen < 1000) phantomicHeartRegen--; if (phantomicBulwarkCooldown > 0) phantomicBulwarkCooldown--; - if (KameiBladeUseDelay > 0) - KameiBladeUseDelay--; if (galileoCooldown > 0) galileoCooldown--; if (gladiatorTimer > 0) @@ -1901,18 +2242,12 @@ namespace CalamityMod.CalPlayer raiderSoundCooldown--; if (astralStarRainCooldown > 0) astralStarRainCooldown--; - if (AbaddonCooldown > 0) - AbaddonCooldown--; if (VoidCooldown > 0) VoidCooldown--; if (ursaSergeantCooldown > 0) ursaSergeantCooldown--; - if (bGlassbandCooldown > 0) - bGlassbandCooldown--; - if (batholithBangleCooldown > 0) - batholithBangleCooldown--; - if (protolithBangleCooldown > 0) - protolithBangleCooldown--; + if (generalBandCooldown > 0) + generalBandCooldown--; if (AlchFlaskCooldown > 0) AlchFlaskCooldown--; if (tarraRangedCooldown > 0) @@ -1931,6 +2266,49 @@ namespace CalamityMod.CalPlayer jetPackDash--; if (theBeeCooldown > 0) theBeeCooldown--; + + if (bloomStoneTotalHeal > 0) + { + float healRateDiv = (Player.statLife >= Player.statLifeMax ? 5 : // 5 times as slow if at max hp already (overheal prevention) + bloomStoneBuffedHealRateTimer > 0 ? Utils.Remap(bloomStoneBuffedHealRateTimer, 90, 0, 0.5f, 1f, true) // 2 times faster if pollen buffed, scales back down to regular speed as the buff fades + : 1); // Regular speed + bloomStoneHealRate = 1 / healRateDiv; + + if (!bloomStone) // If you take it off, all your healing is instantly gone + bloomStoneTotalHeal = 0; + + float secondsOfHealing = 16; // Number of seconds healing occurs over at base, this can be met slower or faster depending on heal rate + if (bloomStoneHealTimer >= 60) // heal the player a portion of their potion every second + { + int healAmount = (int)(Math.Max(Math.Min(bloomStoneHealPool, (int)(bloomStoneTotalHeal / secondsOfHealing)), 1)); + Player.HealPlayer(healAmount); + bloomStoneHealPool -= healAmount; // Subtract the amount healed from the pool until it's empty + + // Special specifically programmed interaction with Chalice of the Blood God: Healing over time clears bits of the bleedout buffer. + if (chaliceOfTheBloodGod && chaliceBleedoutBuffer > 0D) + { + float amountOfBleedToClear = ChaliceOfTheBloodGod.HealingPotionRatioForBufferClear * healAmount; + chaliceBleedoutBuffer -= amountOfBleedToClear; + // Display text indicating that healing was applied to the bleedout buffer. + if (!Main.dedServ) + { + string text = $"(+{amountOfBleedToClear})"; + 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); + } + } + + if (bloomStoneHealPool == 0) // When you're out of healing, reset values + { + bloomStoneTotalHeal = 0; + } + bloomStoneHealTimer = 0; + } + bloomStoneHealTimer += bloomStoneHealRate; + } + if (bloomStoneBuffedHealRateTimer > 0) + bloomStoneBuffedHealRateTimer--; + if (summonProjCooldown > 0f) summonProjCooldown -= 1f; if (ataxiaDmg > 0f) @@ -1943,20 +2321,10 @@ namespace CalamityMod.CalPlayer xerocDmg = 0f; if (hideOfDeusMeleeBoostTimer > 0) hideOfDeusMeleeBoostTimer--; - if (evolutionLifeRegenCounter > 0) - evolutionLifeRegenCounter--; if (hurtSoundTimer > 0) hurtSoundTimer--; if (wingProjectileCooldown > 0) wingProjectileCooldown--; - if (vortexBoosterStealthDelay > 0) - { - vortexBoosterStealthDelay--; - if (vortexBoosterStealthDelay == 1) - Player.vortexStealthActive = true; - } - if (statisTimer > 0 && Player.dashDelay >= 0) - statisTimer = 0; if (hallowedRuneCooldown > 0) hallowedRuneCooldown--; if (sulphurBubbleCooldown > 0) @@ -2010,23 +2378,32 @@ namespace CalamityMod.CalPlayer } } } - if (Player.miscCounter % 20 == 0) + if (Player.miscCounter % HydrothermicHeadRanged.FlareCooldown == 0) canFireAtaxiaRangedProjectile = true; - if (Player.miscCounter % 100 == 0) - canFireBloodflareMageProjectile = true; - if (Player.miscCounter % 120 == 0) + if (Player.miscCounter % HydrothermicHeadRogue.VolleyCooldown == 0) canFireAtaxiaRogueProjectile = true; - if (Player.miscCounter % 150 == 0) - { - canFireGodSlayerRangedProjectile = true; + if (Player.miscCounter % BloodflareHeadMagic.GhostBoltCooldown == 0) + canFireBloodflareMageProjectile = true; + if (Player.miscCounter % BloodflareHeadRanged.BloodBombCooldown == 0) canFireBloodflareRangedProjectile = true; + if (Player.miscCounter % GodSlayerHeadRanged.ShrapnelRoundCooldown == 0) + canFireGodSlayerRangedProjectile = true; + + if (auralisAuroraCounter > 300) + { + for (int i = -1; i <= 1; i += 2) + { + GlowSquareParticle fancySquares = new(Player.Center, Vector2.Zero, false, 2, 6.25f, new Color(92, 89, 251), true, MathHelper.ToRadians(auralisAuroraCounter * 2f * i)); + GeneralParticleHandler.SpawnParticle(fancySquares); + } + auralisAuroraCounter++; + } + + if (auralisAuroraCounter > 1500) + { + auralisAuroraCounter = 0; + auralisAuroraCooldown = CalamityUtils.SecondsToFrames(30f); } - if (reaverRegenCooldown < 60 && reaverRegen) - reaverRegenCooldown++; - else - reaverRegenCooldown = 0; - if (auralisAurora > 0) - auralisAurora--; if (auralisAuroraCooldown > 0) auralisAuroraCooldown--; @@ -2107,16 +2484,16 @@ namespace CalamityMod.CalPlayer if (miningSetCooldown > 0) miningSetCooldown--; - if (RustyMedallionCooldown > 0) - RustyMedallionCooldown--; - if (MiniSwamerCooldown > 0) - MiniSwamerCooldown--; + if (MiniSwarmerCooldown > 0) + MiniSwarmerCooldown--; // God Slayer Armor dash debuff immunity - if (DashID == GodSlayerDash.ID && Player.dashDelay < 0) + if (LastUsedDashID == GodslayerArmorDash.ID && Player.dashDelay < 0) { - foreach (int debuff in DebuffsList.List) - Player.buffImmune[debuff] = true; + for (int d = 0; d < Player.buffImmune.Length; d++) + { + Player.buffImmune[d] |= CalamityBuffSets.IsDebuff[d]; + } } // Shield of the High Ruler @@ -2176,7 +2553,7 @@ namespace CalamityMod.CalPlayer if (necroReviveCounter >= NecroArmorSetChange.PostMortemDuration * 60) { - Player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.NecroRevive").Format(Player.name)), 1000, -1); + Player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.NecroRevive").ToNetworkText(Player.name)), 1000, -1); necroReviveCounter = -1; } else if (necroReviveCounter % 60 == 59) @@ -2187,8 +2564,11 @@ namespace CalamityMod.CalPlayer if (silvaCountdown > 0 && hasSilvaEffect && silvaSet) { // You become immune to all debuffs - foreach (int debuff in DebuffsList.List) - Player.buffImmune[debuff] = true; + foreach (int debuff in Player.buffType) + { + if (CalamityBuffSets.IsDebuff[debuff]) + Player.buffImmune[debuff] = true; + } // Prevent thorns effects from being abused during invincibility Player.thorns = 0f; @@ -2196,8 +2576,8 @@ namespace CalamityMod.CalPlayer silvaCountdown -= 1; if (silvaCountdown <= 0) { - SoundEngine.PlaySound(SilvaHeadSummon.DispelSound, Player.Center); - Player.AddCooldown(SilvaRevive.ID, CalamityUtils.SecondsToFrames(5 * 60)); + SoundEngine.PlaySound(SilvaArmor.DispelSound, Player.Center); + Player.AddCooldown(SilvaRevive.ID, SilvaArmor.ReviveCooldown); } for (int j = 0; j < 2; j++) @@ -2215,7 +2595,7 @@ namespace CalamityMod.CalPlayer } if (!Player.HasCooldown(SilvaRevive.ID) && hasSilvaEffect && silvaCountdown <= 0 && !areThereAnyDamnBosses && !areThereAnyDamnEvents) { - silvaCountdown = 480; + silvaCountdown = SilvaArmor.ReviveDuration; hasSilvaEffect = false; } @@ -2227,7 +2607,7 @@ namespace CalamityMod.CalPlayer { tarraDefenseTime = 600; if (Player.whoAmI == Main.myPlayer) - Player.AddCooldown(Cooldowns.TarragonCloak.ID, CalamityUtils.SecondsToFrames(30)); + Player.AddCooldown(Cooldowns.TarragonCloak.ID, TarragonHeadMelee.CloakCooldown); } for (int j = 0; j < 2; j++) @@ -2253,11 +2633,11 @@ namespace CalamityMod.CalPlayer if (tarragonImmunity && !disableAllDodges) Player.GiveUniversalIFrames(2, true); - if (tarraThrowingCrits >= 50) + if (tarraThrowingCrits >= TarragonHeadRogue.CritsToActivateImmunity) { tarraThrowingCrits = 0; if (Player.whoAmI == Main.myPlayer && !disableAllDodges) - Player.AddBuff(ModContent.BuffType(), 150, false); + Player.AddBuff(ModContent.BuffType(), TarragonHeadRogue.ImmunityDuration, false); } for (int l = 0; l < Player.MaxBuffs; l++) @@ -2265,11 +2645,10 @@ namespace CalamityMod.CalPlayer int buffID = Player.buffType[l]; if (Player.buffTime[l] <= 2 && buffID == ModContent.BuffType()) if (Player.whoAmI == Main.myPlayer) - Player.AddCooldown(Cooldowns.TarragonImmunity.ID, CalamityUtils.SecondsToFrames(25)); + Player.AddCooldown(Cooldowns.TarragonImmunity.ID, TarragonHeadRogue.ImmunityCooldown); - bool shouldAffect = DebuffsList.Includes(buffID); - if (shouldAffect) - Player.GetDamage() += 0.1f; + if (CalamityBuffSets.IsDebuff[buffID]) + Player.GetDamage() += TarragonHeadRogue.RogueDamageBoostWhileDebuffed; } } @@ -2287,7 +2666,7 @@ namespace CalamityMod.CalPlayer { bloodflareMeleeHits = 0; if (Player.whoAmI == Main.myPlayer) - Player.AddBuff(ModContent.BuffType(), 302, false); + Player.AddBuff(ModContent.BuffType(), BloodflareHeadMelee.FrenzyDuration, false); } if (bloodflareFrenzy) @@ -2296,11 +2675,11 @@ namespace CalamityMod.CalPlayer { int hasBuff = Player.buffType[l]; if (Player.buffTime[l] <= 2 && hasBuff == ModContent.BuffType() && Player.whoAmI == Main.myPlayer) - Player.AddCooldown(BloodflareFrenzy.ID, CalamityUtils.SecondsToFrames(30)); + Player.AddCooldown(BloodflareFrenzy.ID, BloodflareHeadMelee.FrenzyCooldown); } - Player.GetCritChance() += 25; - Player.GetDamage() += 0.25f; + Player.GetCritChance() += BloodflareHeadMelee.FrenzyMeleeCritBoost; + Player.GetDamage() += BloodflareHeadMelee.FrenzyMeleeDamageBoost; for (int j = 0; j < 2; j++) { @@ -2317,12 +2696,22 @@ namespace CalamityMod.CalPlayer } } - // Raider Talisman bonus - if (raiderTalisman && !StealthStrikeAvailable() && raiderCritLifespan > 0f) - Player.GetCritChance() += RaidersTalisman.RaiderBonus; + if (brimflameFrenzy) + { + Player.GetDamage() += BrimflameCowl.FrenzyMagicDamageBoost; - if (kamiBoost) - Player.GetDamage() += YanmeisKnife.DamageBoost; + for (int l = 0; l < Player.MaxBuffs; l++) + { + if (Player.buffTime[l] <= 2 && Player.buffType[l] == ModContent.BuffType() && Player.whoAmI == Main.myPlayer) + Player.AddCooldown(BrimflameFrenzy.ID, BrimflameCowl.FrenzyCooldown); + } + } + + // Raider Talisman bonus + if (raiderTalisman && !vampiricTalisman && !StealthStrikeAvailable() && raiderCritLifespan > 0f) + Player.GetCritChance() += RaidersTalisman.RaiderBonus; + if (vampiricTalisman && !StealthStrikeAvailable() && raiderCritLifespan > 0f) + Player.GetCritChance() += VampiricTalisman.RaiderBonus; if (avertorBonus) Player.GetDamage() += 0.1f; @@ -2337,7 +2726,7 @@ namespace CalamityMod.CalPlayer if (Player.isNearFairy()) { Player.lifeRegen += 4; - Player.statDefense += 10; + Player.statDefense += 6; Player.moveSpeed += 0.1f; } } @@ -2347,22 +2736,14 @@ namespace CalamityMod.CalPlayer { Player.moveSpeed += TheAbsorber.MoveSpeedBoost; Player.jumpSpeedBoost += TheAbsorber.JumpSpeedBoost; - Player.thorns += TheAbsorber.ThornsBoost; - } - - // Nimble Bounder bonus - if (nimbleBounderBoost) - { - Player.moveSpeed += NimbleBounder.MoveSpeedBoost; - Player.jumpSpeedBoost += NimbleBounder.JumpSpeedBoost; } // Affliction bonus if (affliction || afflicted) { - Player.endurance += 0.07f; - Player.statDefense += 13; - Player.GetDamage() += 0.1f; + Player.endurance += Affliction.DamageReductionBoost; + Player.statDefense += Affliction.DefenseBoost; + Player.GetDamage() += Affliction.DamageBoost; } float[] light = new float[3]; @@ -2374,6 +2755,7 @@ namespace CalamityMod.CalPlayer } if (aquaticHeartIce) { + Player.endurance += AquaticHeart.IceShieldDamageReductionBoost; light[0] += 0.35f; light[1] += 1f; light[2] += 1.25f; @@ -2401,13 +2783,14 @@ namespace CalamityMod.CalPlayer // Permafrost's Concoction bonuses/debuffs if (permafrostsConcoction) { - Player.manaCost *= 0.85f; + Player.manaCost -= 0.15f; Player.statManaMax2 += 50; } if (encased) { Player.statDefense += PermafrostsConcoction.EncasedDefenseBoost; + Player.endurance += PermafrostsConcoction.EncasedDamageReductionBoost; Player.frozen = true; Player.velocity.X = 0f; Player.velocity.Y = -0.4f; // Should negate gravity @@ -2418,7 +2801,6 @@ namespace CalamityMod.CalPlayer Player.buffImmune[BuffID.Frozen] = true; Player.buffImmune[BuffID.Chilled] = true; - Player.buffImmune[ModContent.BuffType()] = true; } // Cosmic Discharge Cosmic Freeze buff, gives surrounding enemies the Glacial State debuff @@ -2446,7 +2828,7 @@ namespace CalamityMod.CalPlayer } // Vortex Armor nerf - if (Player.vortexStealthActive && Player.ActiveItem().type != ItemID.PsychoKnife) + if (Player.vortexStealthActive && Player.HeldItem.type != ItemID.PsychoKnife) { Player.GetDamage() -= (1f - Player.stealth) * 0.4f; // Change 80 to 40 Player.GetCritChance() -= (int)((1f - Player.stealth) * 5f); // Change 20 to 15 @@ -2531,23 +2913,19 @@ namespace CalamityMod.CalPlayer // Plagued Fuel Pack and Blunder Booster effects if (jetPackDash > 0 && Player.whoAmI == Main.myPlayer) { - int velocityAmt = blunderBooster ? 35 : 25; - int velocityMult = jetPackDash > 1 ? velocityAmt : 5; - Player.velocity = new Vector2(jetPackDirection, -1) * velocityMult; + int velocityMult = (int)((blunderBooster ? 35 : 25) * Utils.GetLerpValue(-4, 5, jetPackDash, true)); + Player.velocity = new Vector2(jetPackDirection, -1f) * velocityMult; if (blunderBooster) { - int lightningCount = Main.rand.Next(5, 7); + int lightningCount = 4; var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); for (int i = 0; i < lightningCount; i++) { - Vector2 lightningVel = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1)); - lightningVel.Normalize(); - lightningVel *= Main.rand.NextFloat(1f, 2f); - int damage = (int)Player.GetTotalDamage().ApplyTo(30); + Vector2 lightningVel = Player.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.3f) * Main.rand.NextFloat(7f, 10f); + int damage = (int)Player.GetTotalDamage().ApplyTo(35); int projectile = Projectile.NewProjectile(source, Player.Center, lightningVel, ModContent.ProjectileType(), damage, 0, Player.whoAmI, Main.rand.Next(2), 0f); - Main.projectile[projectile].timeLeft = Main.rand.Next(180, 240); if (projectile.WithinBounds(Main.maxProjectiles)) Main.projectile[projectile].DamageType = DamageClass.Generic; } @@ -2562,17 +2940,14 @@ namespace CalamityMod.CalPlayer } else if (plaguedFuelPack) { - int numClouds = Main.rand.Next(8, 10); + int numClouds = 3; var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); for (int i = 0; i < numClouds; i++) { - Vector2 cloudVelocity = new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1)); - cloudVelocity.Normalize(); - cloudVelocity *= Main.rand.NextFloat(0f, 1f); - int damage = (int)Player.GetTotalDamage().ApplyTo(20); + Vector2 cloudVelocity = Player.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.3f) * Main.rand.NextFloat(5f, 7f); + int damage = (int)Player.GetTotalDamage().ApplyTo(30); int projectile = Projectile.NewProjectile(source, Player.Center, cloudVelocity, ModContent.ProjectileType(), damage, 0, Player.whoAmI, 0, 0); - Main.projectile[projectile].timeLeft = Main.rand.Next(180, 240); if (projectile.WithinBounds(Main.maxProjectiles)) Main.projectile[projectile].DamageType = DamageClass.Generic; } @@ -2591,44 +2966,44 @@ namespace CalamityMod.CalPlayer if (!ascendantInsignia && ascendantInsigniaBuffTime > 0) { ascendantInsigniaBuffTime = 0; - ascendantInsigniaCooldown = 2400; - Player.AddCooldown(AscendEffect.ID, 2400); + ascendantInsigniaCooldown = AscendantInsignia.AbilityCooldown; + Player.AddCooldown(AscendEffect.ID, AscendantInsignia.AbilityCooldown); } if (!brimflameSet && brimflameFrenzy) { brimflameFrenzy = false; Player.ClearBuff(ModContent.BuffType()); - Player.AddCooldown(BrimflameFrenzy.ID, BrimflameScowl.CooldownLength); + Player.AddCooldown(BrimflameFrenzy.ID, BrimflameCowl.FrenzyCooldown); } if (!bloodflareMelee && bloodflareFrenzy) { bloodflareFrenzy = false; Player.ClearBuff(ModContent.BuffType()); - Player.AddCooldown(BloodflareFrenzy.ID, CalamityUtils.SecondsToFrames(30)); + Player.AddCooldown(BloodflareFrenzy.ID, BloodflareHeadMelee.FrenzyCooldown); } if (!tarraMelee && tarragonCloak) { tarragonCloak = false; Player.ClearBuff(ModContent.BuffType()); - Player.AddCooldown(Cooldowns.TarragonCloak.ID, CalamityUtils.SecondsToFrames(30)); + Player.AddCooldown(Cooldowns.TarragonCloak.ID, TarragonHeadMelee.CloakCooldown); } if (!tarraThrowing && tarragonImmunity) { tarragonImmunity = false; Player.ClearBuff(ModContent.BuffType()); - Player.AddCooldown(Cooldowns.TarragonImmunity.ID, CalamityUtils.SecondsToFrames(25)); + Player.AddCooldown(Cooldowns.TarragonImmunity.ID, TarragonHeadRogue.ImmunityCooldown); } bool hasOmegaBlueCooldown = cooldowns.TryGetValue(OmegaBlue.ID, out CooldownInstance omegaBlueCD); - if (!omegaBlueSet && hasOmegaBlueCooldown && omegaBlueCD.timeLeft > 1500) + if (!omegaBlueSet && hasOmegaBlueCooldown && omegaBlueCD.timeLeft > OmegaBlueHelmet.MadnessCooldown) { Player.ClearBuff(ModContent.BuffType()); - omegaBlueCD.timeLeft = 1500; + omegaBlueCD.timeLeft = OmegaBlueHelmet.MadnessCooldown; } bool hasKillMode = cooldowns.TryGetValue(KillMode.ID, out CooldownInstance killModeCD); - if (hasKillMode && killModeCD.timeLeft > KillMode.cooldownMax && !(Player.ActiveItem().type == ModContent.ItemType() || Player.ActiveItem().type == ModContent.ItemType() || Player.ActiveItem().type == ModContent.ItemType())) + if (hasKillMode && killModeCD.timeLeft > KillMode.cooldownMax && !(Player.HeldItem.type == ModContent.ItemType() || Player.HeldItem.type == ModContent.ItemType() || Player.HeldItem.type == ModContent.ItemType())) { killModeCD.timeLeft = KillMode.cooldownMax - 1; Player.Calamity().killModeCooldown = KillMode.cooldownMax - 1; @@ -2636,19 +3011,19 @@ namespace CalamityMod.CalPlayer } bool hasPlagueBlackoutCD = cooldowns.TryGetValue(PlagueBlackout.ID, out CooldownInstance plagueBlackoutCD); - if (!plagueReaper && hasPlagueBlackoutCD && plagueBlackoutCD.timeLeft > 1500) - plagueBlackoutCD.timeLeft = 1500; + if (!plagueReaper && hasPlagueBlackoutCD && plagueBlackoutCD.timeLeft > PlagueReaperMask.BlackoutCooldown) + plagueBlackoutCD.timeLeft = PlagueReaperMask.BlackoutCooldown; - if (!prismaticSet && prismaticLasers > 1800) + if (!prismaticSet && prismaticLasers > PrismaticHelmet.LaserCooldown) { - prismaticLasers = 1800; - Player.AddCooldown(PrismaticLaser.ID, 1800); + prismaticLasers = PrismaticHelmet.LaserCooldown; + Player.AddCooldown(PrismaticLaser.ID, PrismaticHelmet.LaserCooldown); } if (!angelicAlliance && divineBless) { divineBless = false; Player.ClearBuff(ModContent.BuffType()); - Player.AddCooldown(Cooldowns.DivineBless.ID, CalamityUtils.SecondsToFrames(60)); + Player.AddCooldown(Cooldowns.DivineBless.ID, AngelicAlliance.DivineBlessCooldown); } // Armageddon's Dodge Disable feature puts Shadow Dodge/Holy Protection on permanent cooldown @@ -2660,35 +3035,10 @@ namespace CalamityMod.CalPlayer } #endregion - #region Biome Effects - public void DrawPollenInFloralParadise() - { - if (!ZoneFloralParadise || !Main.rand.NextBool(7) || Main.dedServ) - return; - - for (int i = 0; i < 15; i++) - { - Vector2 dustSpawnPosition = Player.Center + Main.rand.NextVector2Square(-360f, 360f); - dustSpawnPosition.Y += 200f; - Tile tile = CalamityUtils.ParanoidTileRetrieval((int)(dustSpawnPosition.X / 16f), (int)(dustSpawnPosition.Y / 16f)); - if (WorldGen.SolidTile(tile) || tile.LiquidAmount > 0) - continue; - - Dust pollen = Dust.NewDustPerfect(dustSpawnPosition, 261); - pollen.velocity = Main.rand.NextVector2Circular(0.4f, 0.4f); - pollen.scale = Main.rand.NextFloat(0.8f, 1f); - pollen.fadeIn = 2f; - pollen.color = Color.YellowGreen; - pollen.noGravity = true; - break; - } - } - #endregion Biome Effects - #region Abyss Effects private void AbyssEffects() { - int lightStrength = Player.GetCurrentAbyssLightLevel(); + Player.SetAbyssLightLevels(); if (ZoneAbyss) { @@ -2706,42 +3056,7 @@ namespace CalamityMod.CalPlayer double depthRatioFromAbyssLayer1 = playerAbyssDepthFromLayer1 / totalAbyssDepthFromLayer1; // Darkness strength scales smoothly with how deep you are. - float darknessStrength = (float)depthRatio; - - // Reduce the power of abyss darkness based on your light level. - float multiplier = 1f; - switch (lightStrength) - { - case 0: - break; - case 1: - multiplier = 0.85f; - break; - case 2: - multiplier = 0.7f; - break; - case 3: - multiplier = 0.55f; - break; - case 4: - multiplier = 0.4f; - break; - case 5: - multiplier = 0.25f; - break; - case 6: - multiplier = 0.15f; - break; - case 7: - multiplier = 0.1f; - break; - default: - multiplier = 0.05f; - break; - } - - // Modify darkness variable - caveDarkness = darknessStrength * multiplier; + darknessIntensity = abyssDarkness + (float)depthRatio * 3; // Nebula Headcrab darkness effect if (!Player.headcovered) @@ -2752,36 +3067,7 @@ namespace CalamityMod.CalPlayer } // Breath lost while at zero breath - double breathLoss = Main.remixWorld ? (point.Y < abyssLevel1 ? 50D * depthRatioFromAbyssLayer1 : 0D) : (point.Y > abyssLevel1 ? 50D * depthRatioFromAbyssLayer1 : 0D); - - // Breath Loss Multiplier, depending on gear - // 27AUG2024: Ozzatron: fixed this being subtractive like mining speed. now doesn't stack exponentially - // It is now a multiplier for the time it takes to lose any unit amount of breath - double breathLossTimeMult = 1D + - (Player.gills ? 0.2 : 0D) + // 1.2 - (oceanCrest ? 0.2 : 0D) + // 1.2 - (victideSet ? 0.2 : 0D) + // 1.2 - (Player.accDivingHelm ? 0.25 : 0D) + // 1.25 - (Player.arcticDivingGear ? 0.25 : 0D) + // 1.25 - (aquaticEmblem ? 0.25 : 0D) + // 1.25 - (Player.accMerman ? 0.3 : 0D) + // 1.3 - (reaverExplore ? 0.3 : 0D) + // 1.3 - ((aquaticHeart && NPC.downedBoss3) ? 0.3 : 0D) + // 1.3 - (abyssalDivingSuit ? 0.3 : 0D) + // 1.3 - externalBreathLossMultBoost; - - // Invert the breath loss time multiplier, to get the multiplier for the speed at which breath is actually lost - double breathLossMult = 1D / breathLossTimeMult; - - // Limit the multiplier to 5% - if (breathLossMult < 0.05) - breathLossMult = 0.05; - - // Reduce breath lost while at zero breath, depending on gear - breathLoss *= breathLossTimeMult; - - // Record the final breath loss for the stat meter - abyssBreathLossStat = (float)breathLoss; + double breathLoss = Main.remixWorld ? (point.Y < abyssLevel1 ? 1D : 0D) : (point.Y > abyssLevel1 ? 1D : 0D); // Defense loss int defenseLoss = (int)(120D * depthRatio); @@ -2802,24 +3088,8 @@ namespace CalamityMod.CalPlayer // Record the final defense reduction for the stat meter abyssDefenseLossStat = defenseLoss; - // Bleed effect based on abyss layer - if (ZoneAbyssLayer4) - { - Player.bleed = true; - } - else if (ZoneAbyssLayer3) - { - if (!abyssalDivingSuit) - Player.bleed = true; - } - else if (ZoneAbyssLayer2) - { - if (!depthCharm) - Player.bleed = true; - } - // Ticks (frames) until breath is deducted from the breath meter - double tick = 12D * (1D - depthRatio); + double tick = 10D * (1D - depthRatio); // Prevent 0 if (tick < 1D) @@ -2827,16 +3097,16 @@ namespace CalamityMod.CalPlayer // Tick (frame) multiplier, depending on gear double tickMult = 1D + - (Player.gills ? 4D : 0D) + // 5 - (oceanCrest ? 4D : 0D) + // 5 - (Player.ignoreWater ? 5D : 0D) + // 10 - (Player.accDivingHelm ? 10D : 0D) + // 20 - (Player.arcticDivingGear ? 10D : 0D) + // 30 - (aquaticEmblem ? 10D : 0D) + // 40 - (Player.accMerman ? 15D : 0D) + // 55 - (victideSet ? 5D : 0D) + // 60 - ((aquaticHeart && NPC.downedBoss3) ? 15D : 0D) + // 75 - (abyssalDivingSuit ? 15D : 0D) + // 90 + (Player.gills ? 2D : 0D) + + (oceanCrest ? 2D : 0D) + + (Player.ignoreWater ? 3D : 0D) + + (Player.accDivingHelm ? 5D : 0D) + + (Player.arcticDivingGear ? 5D : 0D) + + (aquaticEmblem ? 5D : 0D) + + (Player.accMerman ? 8D : 0D) + + (victideBurrowHead ? 2D : 0D) + + ((aquaticHeart && NPC.downedBoss3) ? 8D : 0D) + + (abyssalDivingSuit ? 8D : 0D) + externalBreathTickBoost; // Limit the multiplier to 50 @@ -2850,9 +3120,11 @@ namespace CalamityMod.CalPlayer abyssBreathLossRateStat = (float)tick; float resistanceSlowdownFactor = 1f; + if (hadopelagicPressure) + resistanceSlowdownFactor -= abyssalDivingSuit ? 0.2f : 0.5f; // Reduce breath over ticks (frames) - abyssBreathCD++; + abyssBreathCD++; if (abyssBreathCD >= (int)(tick * resistanceSlowdownFactor)) { // Reset modded breath variable @@ -2861,17 +3133,14 @@ namespace CalamityMod.CalPlayer // Reduce breath if (Player.breath > 0) { - Player.breath -= (int)(cDepth && !depthCharm ? breathLoss + 1D : breathLoss); - - if (hPressure) - resistanceSlowdownFactor -= (int)(!abyssalDivingSuit ? 1.2f : 0.5f); + Player.breath -= (int)(crushDepth && !depthCharm ? breathLoss + 1D : breathLoss); } } // If breath is greater than 0 and player has gills or is merfolk, balance out the effects by reducing breath if (Player.breath > 0) { - if (Player.gills || Player.merman) + if (Player.gills || Player.merman || Player.accMerman) Player.breath -= 3; } @@ -2880,8 +3149,8 @@ namespace CalamityMod.CalPlayer // Resistance to life loss at zero breath int lifeLossAtZeroBreathResist = 0 + - (depthCharm ? 3 : 0) + - (abyssalDivingSuit ? 6 : 0); + (depthCharm ? 4 : 0) + + (abyssalDivingSuit ? 5 : 0); // Reduce life loss, depending on gear lifeLossAtZeroBreath -= lifeLossAtZeroBreathResist; @@ -2914,7 +3183,7 @@ namespace CalamityMod.CalPlayer abyssDeath = false; // Signus headcrab darkness - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.zenithWorld) { if (CalamityGlobalNPC.signus != -1) { @@ -2927,26 +3196,6 @@ namespace CalamityMod.CalPlayer // Reduce the power of Signus darkness based on your light level. float multiplier = 1f; - switch (Main.LocalPlayer.GetCurrentAbyssLightLevel()) - { - case 0: - break; - case 1: - case 2: - multiplier = 0.75f; - break; - case 3: - case 4: - multiplier = 0.5f; - break; - case 5: - case 6: - multiplier = 0.25f; - break; - default: - multiplier = 0f; - break; - } float signusDarkness = signusLifeRatio * multiplier; darkRatio = MathHelper.Clamp(signusDarkness, 0f, 1f); @@ -3005,15 +3254,14 @@ namespace CalamityMod.CalPlayer // Aquatic Emblem bonus if (aquaticEmblem) { - if (Player.IsUnderwater() && Player.wet && !Player.lavaWet && !Player.honeyWet && - !Player.mount.Active) + if (countsAsAnyWet && !Player.lavaWet && !Player.honeyWet) { - if (aquaticBoost > 0f) + if (aquaticBoost < AquaticEmblem.TimeToReachMaxBoost) { - aquaticBoost -= 2f; - if (aquaticBoost <= 0f) + aquaticBoost++; + if (aquaticBoost > AquaticEmblem.TimeToReachMaxBoost) { - aquaticBoost = 0f; + aquaticBoost = AquaticEmblem.TimeToReachMaxBoost; if (Main.netMode == NetmodeID.MultiplayerClient) NetMessage.SendData(MessageID.PlayerStealth, -1, -1, null, Player.whoAmI, 0f, 0f, 0f, 0, 0, 0); } @@ -3021,20 +3269,21 @@ namespace CalamityMod.CalPlayer } else { - aquaticBoost += 2f; - if (aquaticBoost > aquaticBoostMax) - aquaticBoost = aquaticBoostMax; - if (Player.mount.Active) - aquaticBoost = aquaticBoostMax; + aquaticBoost--; + if (aquaticBoost <= 0f) + aquaticBoost = 0f; + } + //Because mounts are unchanged by move speed we also don'y let them have the defense. + if (!Player.mount.Active) + { + Player.statDefense += (int)Utils.Remap(aquaticBoost, 0, AquaticEmblem.TimeToReachMaxBoost, 0, AquaticEmblem.MaxDefenseBoost); + Player.moveSpeed -= Utils.Remap(aquaticBoost, 0, AquaticEmblem.TimeToReachMaxBoost, 0, AquaticEmblem.MaxMoveSpeedReduction); } - - Player.statDefense += (int)((1f - aquaticBoost * 0.0001f) * 50f); - Player.moveSpeed -= (1f - aquaticBoost * 0.0001f) * 0.1f; } else - aquaticBoost = aquaticBoostMax; + aquaticBoost = 0f; - if (Player.ActiveItem().type == ModContent.ItemType() && Player.StandingStill(0.1f)) + if (Player.HeldItem.type == ModContent.ItemType() && Player.StandingStill(0.1f)) { if (auralisStealthCounter < 300f) auralisStealthCounter++; @@ -3059,33 +3308,18 @@ namespace CalamityMod.CalPlayer int chargeDuration = CalamityUtils.SecondsToFrames(5f); int auroraDuration = CalamityUtils.SecondsToFrames(20f); - if (usingScope && auralisAuroraCounter < chargeDuration + auroraDuration) + if (usingScope && auralisAuroraCounter < chargeDuration && auralisAuroraCooldown == 0) auralisAuroraCounter++; - if (auralisAuroraCounter > chargeDuration + auroraDuration) - { - auralisAuroraCounter = 0; - auralisAuroraCooldown = CalamityUtils.SecondsToFrames(30f); - } - else if (auralisAuroraCounter > chargeDuration) - { - for (int i = -1; i <= 1; i += 2) - { - GlowSquareParticle fancySquares = new(Player.Center, Vector2.Zero, false, 2, 6.25f, new Color(92, 89, 251), true, MathHelper.ToRadians(auralisAuroraCounter * 2f * i)); - GeneralParticleHandler.SpawnParticle(fancySquares); - } - } if (auralisAuroraCounter > 0 && auralisAuroraCounter < chargeDuration && !usingScope) auralisAuroraCounter--; - - if (auralisAuroraCounter > chargeDuration && auralisAuroraCounter < chargeDuration + auroraDuration && !usingScope) - auralisAuroraCounter = 0; } else { auralisStealthCounter = 0f; - auralisAuroraCounter = 0; + if (auralisAuroraCounter > 0 && auralisAuroraCounter < 300) + auralisAuroraCounter--; } if (auralisAuroraCooldown > 0) { @@ -3160,21 +3394,6 @@ namespace CalamityMod.CalPlayer if (AdamantiteSet) Player.statDefense += AdamantiteSetDefenseBoost; - // Warmth makes Chilled, Frozen, and Glacial State tick down 3x as fast - if (Player.HasBuff(BuffID.Warmth)) - { - for (int b = 0; b < Player.MaxBuffs; b++) - { - if (Player.buffType[b] == BuffID.Chilled || Player.buffType[b] == BuffID.Frozen || Player.buffType[b] == ModContent.BuffType()) - { - if (Player.buffTime[b] > 3) - { - Player.buffTime[b] -= 2; - } - } - } - } - if (astralInjection) { if (Player.statMana < Player.statManaMax2) @@ -3193,9 +3412,9 @@ namespace CalamityMod.CalPlayer } if (xWrath) - { - Player.GetDamage() += 0.1f; - Player.GetCritChance() += 5; + { + Player.GetDamage() += EmpyreanMask.WrathRogueDamageBoost; + Player.GetCritChance() += EmpyreanMask.WrathRogueCritBoost; } if (graxDefense) @@ -3205,11 +3424,6 @@ namespace CalamityMod.CalPlayer Player.GetDamage() += Grax.DamageBoost; } - if (brutalCarnage) - { - Player.GetDamage() += BrutalCarnage.MeleeDamageBoost; - } - // Trinket of Chi bonus if (trinketOfChi) { @@ -3227,7 +3441,7 @@ namespace CalamityMod.CalPlayer Player.GetDamage() += 0.12f; Player.GetKnockback() += 1.2f; if (Main.eclipse || !Main.dayTime) - Player.statDefense += Main.eclipse ? 10 : 20; + Player.statDefense += Main.eclipse ? 8 : 16; } if (AbsorberRegen) @@ -3274,7 +3488,7 @@ namespace CalamityMod.CalPlayer if (tortShellPostHit > 0) { - Player.statDefense -= 8; + Player.statDefense -= 6; tortShellPostHit--; } else @@ -3320,97 +3534,75 @@ namespace CalamityMod.CalPlayer --bloodflareCoreRemainingHealOverTime; } - // Multiplies base movement speed by 1.5x so that you don't feel like a snail in the early game - // Disabled while Overhaul is enabled, because Overhaul does very similar things to make movement more snappy - if (ExternalMods.overhaul is null && CalamityServerConfig.Instance.FasterBaseSpeed) - Player.maxRunSpeed *= BalancingConstants.DefaultMoveSpeedBoost; // Reduce how slow Chilled makes the player, because it's cancerous right now // The moveSpeed multiplier for Chilled in vanilla is 0.75, so we just multiply by 1.166667 here to make it 0.875, effectively cutting the reduction in half if (Player.chilled) Player.moveSpeed *= 1f + (1f / 6f); - if (cirrusDress) - Player.moveSpeed -= 0.2f; - - if (cirrusVodka) - Player.GetDamage() += CirrusVodka.DamageBoost; - - if (vodka) + if (purpleHazeStealthTimer > 0) { - Player.GetDamage() += Vodka.DamageBoost; - Player.GetCritChance() += Vodka.CritBoost; - } - - if (moonshine) - { - Player.statDefense += Moonshine.DefenseBoost; - Player.endurance += Moonshine.DamageReductionBoost; - } - - if (rum) - Player.moveSpeed += Rum.MoveSpeedBoost; - - if (whiskey) - { - Player.GetDamage() += Whiskey.DamageBoost; - Player.GetCritChance() += Whiskey.CritBoost; + //this is so janky looking but it's the only way I could get it to work properly + if (!(StealthStrikeAvailable() && Player.HeldItem.DamageType == RogueDamageClass.Instance)) + Player.GetDamage(DamageClass.Generic) += PurpleHaze.DamageBoost; + else + stealthDamage -= PurpleHaze.StealthDamageLoss; } if (everclear) Player.GetDamage() += Everclear.DamageBoost; - if (bloodyMary) - { - if (Main.bloodMoon) - { - Player.GetDamage() += BloodyMary.DamageBoost; - Player.moveSpeed += BloodyMary.MoveSpeedBoost; - } - } - - if (tequila) - { - if (Main.dayTime) - { - Player.statDefense += Tequila.DefenseBoost; - Player.GetCritChance() += Tequila.CritBoost; - } - } - - if (tequilaSunrise) - { - if (Main.dayTime) - { - Player.statDefense += TequilaSunrise.DefenseBoost; - Player.GetCritChance() += TequilaSunrise.CritBoost; - } - } if (caribbeanRum) - Player.moveSpeed += CaribbeanRum.MoveSpeedBoost; - - if (cinnamonRoll) { - Player.manaRegenDelayBonus += CinnamonRoll.ManaRegenDelayBonus; - Player.manaRegenBonus += CinnamonRoll.ManaRegenBonus; + Player.gravity *= CaribbeanRum.GravityMultiplier; + Player.moveSpeed += CaribbeanRum.MoveSpeedBoost; } if (starBeamRye) { - Player.GetDamage() += StarBeamRye.MagicDamageBoost; - Player.manaCost *= (1f - StarBeamRye.ManaCostReduction); - Player.statManaMax2 += StarBeamRye.MaxManaBoost; - } - - if (moscowMule) - { - Player.GetDamage() += MoscowMule.DamageBoost; - Player.GetCritChance() += MoscowMule.CritBoost; + Player.manaFlower = false; + Player.ClearBuff(ModContent.BuffType()); + if (!Player.manaSick) + { + Player.manaRegenCount -= Player.manaRegen; + Player.manaRegenDelay = 0; + Player.manaRegenCount += 20; // 20 mana per second, even while using an item + if (Player.HeldItem.mana > 0) + { + Player.GetDamage() += 0.5f + MathHelper.Max(0.1f,Player.HeldItem.mana / (float)Player.HeldItem.useTime); + } + Player.GetDamage() -= 0.5f; + } } if (whiteWine) - Player.GetDamage() += WhiteWine.MagicDamageBoost; + { + Player.wingTimeMax = (int)(Player.wingTimeMax * (1f - WhiteWine.FlightTimeLoss)); + + float bonus = 0f; + float MaxDistance = 640f; + NPC closestTarget = Player.Center.ClosestNPCAt(MaxDistance * 7); // extra range is to account for bonus range from massive targets + if (closestTarget != null) + { + float generousHitboxWidth = Math.Max(closestTarget.Hitbox.Width / 2f, closestTarget.Hitbox.Height / 2f) + 100; // Adds some room so max bonus isnt when you're ON the hitbox + bonus = Utils.Remap(Utils.Distance(Player.Center, closestTarget.Center), MaxDistance + generousHitboxWidth, generousHitboxWidth, 0, 1, true); + } + else + bonus = 0; + whiteWineTimer += bonus * WhiteWine.FlightTimeRecoveryAmount; + while (whiteWineTimer > 1) + { + if (Player.wingTime < Player.wingTimeMax) + Player.wingTime++; + whiteWineTimer--; + } + } + + if (redWine) + { + Player.wingTimeMax = (int)(Player.wingTimeMax * (1f - RedWine.FlightTimeLoss)); + } if (giantPearl) { @@ -3430,43 +3622,30 @@ namespace CalamityMod.CalPlayer } } - if (HighTestFishingPoleList.Includes(Player.ActiveItem().type)) + if (CalamityItemSets.FishingPoleThatNeverBreaks[Player.HeldItem.type]) Player.accFishingLine = true; if (planarSpeedBoost != 0) { - if (Player.ActiveItem().type != ModContent.ItemType()) + if (Player.HeldItem.type != ModContent.ItemType()) planarSpeedBoost = 0; } if (evilSmasherBoost > 0) { - if (Player.ActiveItem().type != ModContent.ItemType()) + if (Player.HeldItem.type != ModContent.ItemType()) evilSmasherBoost = 0; } - if (searedPanCounter > 0) - { - if (Player.ActiveItem().type != ModContent.ItemType()) - { - searedPanCounter = 0; - searedPanTimer = 0; - } - else if (searedPanTimer < SearedPan.ConsecutiveHitOpening) - searedPanTimer++; - else - searedPanCounter = 0; - } // Flight time boosts double flightTimeMult = 1D + (harpyRing ? 0.2 : 0D) + - (reaverSpeed ? 0.1 : 0D) + - (angelTreads ? 0.1 : 0D) + + (reaverSpeed ? ReaverHeadMobility.SetBonusFlightBoost : 0D) + + (angelTreads ? AngelTreads.FlightTimeBoost : 0D) + (blueCandle ? WeightlessCandle.WingTimeBoost : 0D) + (soaring ? SoaringPotion.FlightBoost : 0D) + - (prismaticGreaves ? 0.1 : 0D) + - (plagueReaper ? 0.05 : 0D) + - (ascendantInsignia ? 0.17 : 0D) + // Added to soaring insignia's flight to get 50% - (Player.empressBrooch ? 0.33 : 0D) + + (prismaticGreaves ? PrismaticGreaves.FlightTimeBoost : 0D) + + (plagueReaper ? PlagueReaperMask.SetBonusFlightTimeBoost : 0D) + + (ascendantInsignia ? AscendantInsignia.FlightTimeBoost : Player.empressBrooch ? 0.33D : 0D) + externalFlightTimeMultBoost; if (community) @@ -3485,7 +3664,7 @@ namespace CalamityMod.CalPlayer // Reaver Tank set nuke flight time if (reaverDefense) - flightTimeMult -= 0.3f; + flightTimeMult -= ReaverHeadTank.SetBonusMobilityReduction; // Increase wing time if (Player.wingTimeMax > 0) @@ -3537,24 +3716,12 @@ namespace CalamityMod.CalPlayer } if (tarraSet) - { - if (!tarraMelee) - Player.calmed = true; Player.lifeMagnet = true; - } - if (wDeath && !laudanum && !purity) + if (whisperingDeath && !laudanum && !purity) Player.GetDamage() -= 0.2f; - if (astralInfection && !(infectedJewel || hideOfDeus || purity)) - Player.GetDamage() -= 0.1f; - - if (pFlames && !purity) - { - Player.GetDamage() -= 0.1f; - } - - if (aCrunch && !laudanum && !purity) + if (armorCrunch && !laudanum && !purity) { Player.statDefense -= ArmorCrunch.DefenseReduction; Player.endurance *= ArmorCrunch.MultiplicativeDamageReductionPlayer; @@ -3565,14 +3732,6 @@ namespace CalamityMod.CalPlayer Player.statDefense -= RemsRevenge.WitherDefenseReduction; } - if (gState) - { - Player.velocity.X *= 0.5f; - Player.velocity.Y += 0.05f; - if (Player.velocity.Y > 15f) - Player.velocity.Y = 15f; - } - if (eutrophication && !purity) Player.velocity = Vector2.Zero; @@ -3580,15 +3739,15 @@ namespace CalamityMod.CalPlayer Player.velocity *= 0.98f; if (molluskHelmet) - Player.velocity.X *= 0.994f; + Player.velocity.X *= 0.996f; if (molluskChest) - Player.velocity.X *= 0.994f; + Player.velocity.X *= 0.996f; if (molluskLegs) - Player.velocity.X *= 0.994f; + Player.velocity.X *= 0.996f; - if ((warped || caribbeanRum) && !Player.slowFall && !Player.mount.Active) + if ((warped) && !Player.slowFall && !Player.mount.Active) { - float velocityYMultiplier = (warped && Main.getGoodWorld) ? 1.02f : 1.01f; + float velocityYMultiplier = 1.01f; Player.velocity.Y *= velocityYMultiplier; } @@ -3614,27 +3773,40 @@ namespace CalamityMod.CalPlayer } if (manaOverloader) - Player.GetDamage() += 0.06f; + { + float manaRatio = Player.statMana / (float)Player.statManaMax2; + Player.GetDamage() += MathHelper.Lerp(0.05f, 0.15f, manaRatio); + } if (bloodyWormTooth) { Player.GetDamage() += 0.1f; } + // While making the rogue update verify if we should allow these to stack again - Shade if (filthyGlove) { bonusStealthDamage += nanotech ? 0.05f : 0.08f; } + if (rottenDogTooth && !nanotech) + { + bonusStealthDamage += 0.08f; + } + if (sandsWindBuff) { Player.GetDamage() += PrimordialEarth.BuffDamageBoost; Player.statDefense += PrimordialEarth.BuffDefenseBoost; + Player.manaRegenDelayBonus += 1; + Player.manaRegenBonus += 50 + (int)(400 * (float)Math.Pow((1 - ((float)Player.statMana / (float)Player.statManaMax2)), 2)); } if (aeolianEarthBuff) { Player.GetDamage() += PrimordialAncient.BuffDamageBoost; Player.endurance += PrimordialAncient.BuffDamageReductionBoost; + Player.manaRegenDelayBonus += 1; + Player.manaRegenBonus += 75 + (int)(600 * (float)Math.Pow((1 - ((float)Player.statMana / (float)Player.statManaMax2)), 2)); } if (frostFlare) @@ -3647,58 +3819,50 @@ namespace CalamityMod.CalPlayer if (Player.statLife > (int)(Player.statLifeMax2 * 0.5)) Player.GetDamage() += 0.1f; if (Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) - Player.statDefense += 20; + Player.statDefense += 15; } if (vexation) { - if (Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) - Player.GetDamage() += 0.2f; + Player.GetDamage() += 0.3f * (1 - Player.statLife / (float)Player.statLifeMax2); } if (ataxiaBlaze) { - if (Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) + if (Player.statLife <= (int)(Player.statLifeMax2 * HydrothermicArmor.InfernoHealthThreshold)) Player.AddBuff(BuffID.Inferno, 2); } if (bloodflareThrowing) { - if (Player.statLife > (int)(Player.statLifeMax2 * 0.8)) - { - Player.GetCritChance() += 5; - Player.statDefense += 30; - } - else - Player.GetDamage() += 0.1f; + if (Player.statLife > (int)(Player.statLifeMax2 * BloodflareHeadRogue.DefenseBoostHealthThreshold)) + Player.statDefense += BloodflareHeadRogue.DefenseBoostAboveHealthThreshold; } if (bloodflareSummon) { - if (Player.statLife >= (int)(Player.statLifeMax2 * 0.9)) - Player.GetDamage() += 0.1f; - else if (Player.statLife <= (int)(Player.statLifeMax2 * 0.5)) - Player.statDefense += 20; + if (Player.statLife <= (int)(Player.statLifeMax2 * BloodflareHeadSummon.DefenseBoostHealthThreshold)) + Player.statDefense += BloodflareHeadSummon.DefenseBoostBelowHealthThreshold; if (bloodflareSummonTimer > 0) bloodflareSummonTimer--; if (Player.whoAmI == Main.myPlayer && bloodflareSummonTimer <= 0) { - bloodflareSummonTimer = 900; + bloodflareSummonTimer = BloodflareHeadSummon.MineCooldown; // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_FromThis(BloodflareHeadSummon.GhostMineEntitySourceContext); for (int I = 0; I < 3; I++) { float ai1 = I * 120; - int damage = (int)Player.CalcIntDamage(3750); + int damage = (int)Player.CalcIntDamage(BloodflareHeadSummon.MineDamage); int projectile = Projectile.NewProjectile(source, Player.Center.X + (float)(Math.Sin(I * 120) * 550), Player.Center.Y + (float)(Math.Cos(I * 120) * 550), 0f, 0f, ModContent.ProjectileType(), damage, 1f, Player.whoAmI, ai1, 0f); if (projectile.WithinBounds(Main.maxProjectiles)) { - Main.projectile[projectile].originalDamage = 3750; + Main.projectile[projectile].originalDamage = BloodflareHeadSummon.MineDamage; Main.projectile[projectile].DamageType = DamageClass.Generic; } } @@ -3714,36 +3878,35 @@ namespace CalamityMod.CalPlayer } if (Player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - int damage = (int)Player.GetTotalDamage().ApplyTo(600); + int baseDmg = auricSet ? AuricTeslaHeadSummon.CrystalDamage : SilvaHeadSummon.CrystalDamage; + int damage = (int)Player.GetTotalDamage().ApplyTo(baseDmg); var p = Projectile.NewProjectile(source, Player.Center.X, Player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, -20f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 600; + Main.projectile[p].originalDamage = baseDmg; } } if (ascendantInsignia && ascendantInsigniaBuffTime > 0) { - ascendantTrail = true; infiniteFlight = true; if (ascendantInsigniaBuffTime == 1) - Player.AddCooldown(AscendEffect.ID, 2400); + Player.AddCooldown(AscendEffect.ID, AscendantInsignia.AbilityCooldown); ascendantInsigniaBuffTime--; } if (abyssalDivingSuit && !Player.IsUnderwater()) { - float moveSpeedLoss = (3 - abyssalDivingSuitPlateHits) * 0.2f; - Player.moveSpeed -= moveSpeedLoss; + Player.moveSpeed -= 0.6f; } if (godSlayerThrowing) { if (Player.statLife >= Player.statLifeMax2) { - Player.GetCritChance() += 10; - Player.GetDamage() += 0.1f; - rogueVelocity += 0.1f; + Player.GetDamage() += GodSlayerHeadRogue.RogueDamageBoostAtFullHealth; + Player.GetCritChance() += GodSlayerHeadRogue.RogueCritBoostAtFullHealth; + rogueVelocity += GodSlayerHeadRogue.RogueVelocityBoostAtFullHealth; } } @@ -3759,7 +3922,7 @@ namespace CalamityMod.CalPlayer // If the timer rolls over, it's time to deal damage. Only run this code for the client which is wearing the armor. if (tarraLifeAuraTimer == 0 && Player.whoAmI == Main.myPlayer) { - int damage = (int)Player.CalcDamage(120); + int damage = (int)Player.CalcDamage(TarragonHeadSummon.AuraDamage); // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_FromThis(TarragonHeadSummon.LifeAuraEntitySourceContext); @@ -3776,59 +3939,21 @@ namespace CalamityMod.CalPlayer } } - // Navy Fishing Rod's electric aura when in-use - if (Player.ActiveItem().type == ModContent.ItemType() && Player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) - { - const int FramesPerHit = 120; - - // Constantly increment the timer every frame. - navyRodAuraTimer = (navyRodAuraTimer + 1) % FramesPerHit; - - // If the timer rolls over, it's time to deal damage. Only run this code for the client which is holding the fishing rod, - if (navyRodAuraTimer == 0 && Player.whoAmI == Main.myPlayer) - { - const int BaseDamage = 10; - int damage = (int)Player.GetBestClassDamage().ApplyTo(BaseDamage); - var source = Player.GetSource_ItemUse(Player.ActiveItem()); - float range = 200f; - - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) - continue; - - if (Vector2.Distance(Player.Center, npc.Center) <= range) - Projectile.NewProjectile(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)) - { - Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); - Projectile spark = Projectile.NewProjectileDirect(source, npc.Center, velocity, ModContent.ProjectileType(), damage / 2, 0f, Player.whoAmI); - spark.localNPCHitCooldown = -2; - spark.timeLeft = 30; - } - } - } - } - // Inferno potion boost if (ataxiaBlaze && Player.inferno) { - const int FramesPerHit = 30; - // Constantly increment the timer every frame. - hydrothermicInfernoTimer = (hydrothermicInfernoTimer + 1) % FramesPerHit; + hydrothermicInfernoTimer = (hydrothermicInfernoTimer + 1) % HydrothermicArmor.InfernoHitRate; // Only run this code for the client which is wearing the armor. // Brimstone flames is applied every single frame, but direct damage is only dealt twice per second. if (Player.whoAmI == Main.myPlayer) { - int damage = (int)Player.GetBestClassDamage().ApplyTo(50); + int damage = (int)Player.GetBestClassDamage().ApplyTo(HydrothermicArmor.InfernoDamage); // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_FromThis(HydrothermicArmor.InfernoPotionEntitySourceContext); - float range = 300f; + float range = HydrothermicArmor.InfernoRange; foreach (NPC npc in Main.ActiveNPCs) { @@ -3861,15 +3986,9 @@ namespace CalamityMod.CalPlayer Player.npcTypeNoAggro[ModContent.NPCType()] = true; } - if (dArtifact) - Player.GetDamage() *= 1.2f; - - if (trippy) - Player.GetDamage() += OddMushroom.DamageBoost; - if (eArtifact) { - Player.manaCost *= 0.75f; + Player.manaCost -= 0.25f; Player.maxMinions++; } @@ -3881,7 +4000,9 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI == Main.myPlayer) { var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - if (Player.FindBuffIndex(ModContent.BuffType()) == -1) + if (Player.HasBuff(ModContent.BuffType())) + Player.buffTime[Player.FindBuffIndex(ModContent.BuffType())] = 3600; + else Player.AddBuff(ModContent.BuffType(), 3600, true); pSoulGuardians = true; @@ -4080,66 +4201,27 @@ namespace CalamityMod.CalPlayer } } - if (prismaticLasers > 1800 && Player.whoAmI == Main.myPlayer) + if (prismaticLasers > PrismaticHelmet.LaserCooldown && Player.whoAmI == Main.myPlayer) { - float shootSpeed = 18f; - int dmg = (int)Player.GetTotalDamage().ApplyTo(30); - - Vector2 startPos = Player.RotatedRelativePoint(Player.MountedCenter, true); - - // 14NOV2024: Ozzatron: clamped mouse position is inappropriate to apply here due to excessive use of decompiled vanilla shitcode - Vector2 velocity = Main.MouseWorld - startPos; - if (Player.gravDir == -1f) - { - velocity.Y = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - startPos.Y; - } - float travelDist = velocity.Length(); - if ((float.IsNaN(velocity.X) && float.IsNaN(velocity.Y)) || (velocity.X == 0f && velocity.Y == 0f)) - { - velocity.X = Player.direction; - velocity.Y = 0f; - travelDist = shootSpeed; - } - else - { - travelDist = shootSpeed / travelDist; - } + int dmg = (int)Player.GetTotalDamage().ApplyTo(PrismaticHelmet.LaserDamage); // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list var source = Player.GetSource_FromThis(PrismaticHelmet.LaserEntitySourceContext); int laserAmt = Main.rand.Next(2); for (int index = 0; index < laserAmt; index++) { - startPos = new Vector2(Player.Center.X + (Main.rand.Next(201) * -(float)Player.direction) + (Main.mouseX + Main.screenPosition.X - Player.position.X), Player.MountedCenter.Y - 600f); - startPos.X = (startPos.X + Player.Center.X) / 2f + Main.rand.Next(-200, 201); - startPos.Y -= 100 * index; - velocity.X = Main.mouseX + Main.screenPosition.X - startPos.X; - velocity.Y = Main.mouseY + Main.screenPosition.Y - startPos.Y; - if (velocity.Y < 0f) - { - velocity.Y *= -1f; - } - if (velocity.Y < 20f) - { - velocity.Y = 20f; - } - travelDist = velocity.Length(); - travelDist = shootSpeed / travelDist; - velocity.X *= travelDist; - velocity.Y *= travelDist; - velocity.X += Main.rand.Next(-50, 51) * 0.02f; - velocity.Y += Main.rand.Next(-50, 51) * 0.02f; - int laser = Projectile.NewProjectile(source, startPos, velocity, ModContent.ProjectileType(), dmg, 4f, Player.whoAmI, 0f, 0f); - Main.projectile[laser].localNPCHitCooldown = 5; - if (laser.WithinBounds(Main.maxProjectiles)) - Main.projectile[laser].DamageType = DamageClass.Generic; + Vector2 newPos = new Vector2(Player.ClampedMouseWorld().X + Main.rand.NextFloat(-240f, 240f), Player.MountedCenter.Y - 960f); + Vector2 newVel = (Player.ClampedMouseWorld() + Main.rand.NextVector2CircularEdge(24f, 24f) - newPos).SafeNormalize(Vector2.Zero) * 18f; + Projectile laser = Projectile.NewProjectileDirect(source, newPos, newVel, ModContent.ProjectileType(), dmg, 4f, Player.whoAmI); + laser.localNPCHitCooldown = 5; + laser.DamageType = DamageClass.Generic; } SoundEngine.PlaySound(SoundID.Item12, Player.Center); } - if (prismaticLasers == 1800) + if (prismaticLasers == PrismaticHelmet.LaserCooldown) { // At the exact moment the lasers stop, set the cooldown to appear - Player.AddCooldown(PrismaticLaser.ID, 1800); + Player.AddCooldown(PrismaticLaser.ID, PrismaticHelmet.LaserCooldown); } if (prismaticLasers == 1) { @@ -4185,7 +4267,7 @@ namespace CalamityMod.CalPlayer angelicActivate = -1; if (angelicActivate == 1) - Player.AddCooldown(Cooldowns.DivineBless.ID, CalamityUtils.SecondsToFrames(60)); + Player.AddCooldown(Cooldowns.DivineBless.ID, AngelicAlliance.DivineBlessCooldown); } if (theBee && Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability)) @@ -4206,7 +4288,7 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < Player.MaxBuffs; l++) { int buffID = Player.buffType[l]; - if (AmalgamBuffList.Includes(buffID)) + if (CalamityBuffSets.BuffedByAmalgam[buffID]) { if (amalgam) { @@ -4223,7 +4305,7 @@ namespace CalamityMod.CalPlayer else { // Reset buff persistence if Amalgam is removed. - if (Main.persistentBuff[buffID] && !PersistentBuffList.Includes(buffID)) + if (Main.persistentBuff[buffID] && !CalamityBuffSets.IsPersistentBuff[buffID]) Main.persistentBuff[buffID] = false; } } @@ -4236,7 +4318,7 @@ namespace CalamityMod.CalPlayer // Laudanum removes immunity to debuffs that it counters, so that you can get inflicted with them int[] buffsAffected = [ModContent.BuffType(), ModContent.BuffType(), BuffID.VortexDebuff, BuffID.Ichor, BuffID.Bleeding, BuffID.Chilled, BuffID.BrokenArmor, BuffID.Weak, BuffID.Slow, BuffID.Confused, BuffID.Cursed, BuffID.Silenced, BuffID.Blackout, BuffID.Darkness]; - + for (int i = 0; i < buffsAffected.Length; i++) Player.buffImmune[buffsAffected[i]] = false; @@ -4271,7 +4353,7 @@ namespace CalamityMod.CalPlayer // Also gives acceleration, which is done in PostUpdateRunSpeeds break; case BuffID.Ichor: - Player.statDefense += 40; // +25 net defense + Player.statDefense += 20; // +10 net defense break; case BuffID.Bleeding: Player.bleed = false; @@ -4289,7 +4371,7 @@ namespace CalamityMod.CalPlayer case BuffID.Weak: Player.GetDamage() += 0.051f; // Cancel melee damage nerf, add 10% all damage Player.GetDamage() += 0.1f; - Player.statDefense += 14; // +10 net defense + Player.statDefense += 10; // +6 net defense Player.moveSpeed += 0.25f; // +15% net move speed break; case BuffID.Slow: @@ -4298,7 +4380,7 @@ namespace CalamityMod.CalPlayer break; case BuffID.Confused: Player.confused = false; - Player.statDefense += 50; + Player.statDefense += 15; break; case BuffID.Cursed: Player.cursed = false; @@ -4342,9 +4424,94 @@ namespace CalamityMod.CalPlayer // Gem Tech stats based on gems. GemTechState.ProvideGemBoosts(); + + // Add any multiplicative damage bonuses here + float multiplicativeDamage = 1; + if (dArtifact) + multiplicativeDamage += 0.2f; + if (WarbanneroftheRighteous) + multiplicativeDamage += warbannerDamageMult; + if (multiplicativeDamage != 1) + Player.GetDamage() *= multiplicativeDamage; } #endregion + #region Lucrecia Line Effects + + public void HandleLucreciaLineEffects() + { + int lucreciaItemID = ModContent.ItemType(); + int lightspeedItemID = ModContent.ItemType(); + + if (Player.HeldItem.type == lucreciaItemID && darklightEnergy > 0) + { + lucreciaParticleTimer--; + + // If the timer is at or below zero, spawn a particle. + if (lucreciaParticleTimer <= 0) + { + // Reset the timer (spawn rate depends on energy) + lucreciaParticleTimer = (int)(20 - 15 * (darklightEnergy / 60)); + + float radius = Main.rand.NextFloat(160f, 190f); // Distance from center + float spawnAngle = Main.rand.NextFloat(MathHelper.TwoPi); // Random angle along the whole radius + + Vector2 spawnPosition = Player.Center + spawnAngle.ToRotationVector2() * radius; + + // Scale opacity with energy + float opacity = darklightEnergy / (float)Lucrecia.MaxEnergy; + Color color = Main.rand.NextBool() ? Color.MediumPurple : Color.CornflowerBlue; + color *= opacity * 0.5f; + + if (darklightEnergy >= 100) + { + color *= 2.4f; // Way brighter + } + + Vector2 dummyVelocity = Vector2.Zero; // We dont want the argument where this is used to have influence on the actual path + float rotationSpeed = 0.04f; + + var particle = new RoundedStarParticle(spawnPosition, dummyVelocity, color with { A = 0 }, Main.rand.NextFloat(0.05f, 0.065f), Main.rand.Next(30, 60), rotationSpeed, 1f, true, Player.Center, Player.whoAmI); + GeneralParticleHandler.SpawnParticle(particle); + } + } + + if (Player.HeldItem.type == lightspeedItemID && elementalMastery > 0) + { + lucreciaParticleTimer--; + + // If the timer is at or below zero, spawn a particle. + if (lucreciaParticleTimer <= 0) + { + // Reset the timer (spawn rate depends on energy) + lucreciaParticleTimer = (int)(20 - 15 * (elementalMastery / 60)); + + float radius = Main.rand.NextFloat(160f, 190f); // Distance from center + float spawnAngle = Main.rand.NextFloat(MathHelper.TwoPi); // Random angle along the whole radius + + Vector2 spawnPosition = Player.Center + spawnAngle.ToRotationVector2() * radius; + + // Scale opacity with energy + float opacity = elementalMastery / (float)Lightspeed.MaxEnergy; + Color color = Main.rand.NextBool() ? Color.Aqua : Color.OrangeRed; + color *= opacity * 0.5f; + + if (elementalMastery >= 100) + { + color *= 2.4f; // Way brighter + } + + Vector2 dummyVelocity = Vector2.Zero; // We dont want the argument where this is used to have influence on the actual path + float rotationSpeed = 0.04f; + + var particle = new RoundedStarParticle(spawnPosition, dummyVelocity, color with { A = 0 }, Main.rand.NextFloat(0.05f, 0.065f), Main.rand.Next(30, 60), rotationSpeed, 1f, true, Player.Center, Player.whoAmI); + GeneralParticleHandler.SpawnParticle(particle); + } + } + } + #endregion + + #region Energy Shields private void EnergyShields() { @@ -4536,7 +4703,10 @@ namespace CalamityMod.CalPlayer { if (cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out var cdDurability)) cdDurability.timeLeft = 0; - // if (cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var cdRecharge)) cdRecharge.timeLeft = 0; + + // As Rover Drive's shield can be left in a partially recharged state, this is for safety. + // If the player does not have the accessory equipped for even one frame, discharge all shields. + RoverDriveShieldDurability = 0; } // Stuff to do if the Rover Drive is equipped @@ -4544,16 +4714,38 @@ namespace CalamityMod.CalPlayer { // If the Rover Drive shield is discharged and hasn't started its recharge delay, start that. if (RoverDriveShieldDurability == 0 && !cooldowns.ContainsKey(WulfrumRoverDriveRecharge.ID)) - Player.AddCooldown(WulfrumRoverDriveRecharge.ID, RoverDrive.ShieldRechargeTime); + Player.AddCooldown(WulfrumRoverDriveRecharge.ID, RoverDrive.ShieldRechargeDelay); - // If the shield has greater than zero durability but that durability is not on the cooldown rack, - // add it to the cooldown rack and play a sound of the shield turning on. + // If the shield has greater than zero durability but that durability is not on the cooldown rack, add it to the cooldown rack. if (RoverDriveShieldDurability > 0 && !cooldowns.ContainsKey(WulfrumRoverDriveDurability.ID)) { CooldownInstance durabilityCooldown = Player.AddCooldown(WulfrumRoverDriveDurability.ID, RoverDrive.ShieldDurabilityMax); durabilityCooldown.timeLeft = RoverDriveShieldDurability; } + // If the shield has greater than zero durability and isn't in its recharge delay, actively replenish shield points. + // Play a sound on the first frame this occurs. + if (RoverDriveShieldDurability > 0 && !cooldowns.ContainsKey(WulfrumRoverDriveRecharge.ID)) + { + if (!playedRoverDriveShieldSound) + SoundEngine.PlaySound(RoverDrive.ActivationSound, Player.Center); + playedRoverDriveShieldSound = true; + + // This number is not an integer, and stores exact per-frame recharge progress. + roverDriveShieldPartialRechargeProgress += RoverDrive.ShieldDurabilityMax / (float)RoverDrive.TotalShieldRechargeTime; + + // Floor the value to get whole number of shield points recharged this frame. + int pointsActuallyRecharged = (int)MathF.Floor(roverDriveShieldPartialRechargeProgress); + + // Give those points to the real shield durability, capping the result. Then remove them from recharge progress. + RoverDriveShieldDurability = Math.Min(RoverDriveShieldDurability + pointsActuallyRecharged, RoverDrive.ShieldDurabilityMax); + roverDriveShieldPartialRechargeProgress -= pointsActuallyRecharged; + + // Update the cooldown rack's durability indicator. + if (cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out var cdDurability)) + cdDurability.timeLeft = RoverDriveShieldDurability; + } + // Add light if this shield is currently active if (RoverDriveShieldDurability > 0 && !shieldAddedLight) { @@ -4603,7 +4795,7 @@ namespace CalamityMod.CalPlayer { totalDefenseDamage = 0; defenseDamageRecoveryFrames = 0; - totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; + totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime * (moonshine ? 2 : 1); defenseDamageDelayFrames = 0; } } @@ -4634,112 +4826,19 @@ namespace CalamityMod.CalPlayer // Multiplicative defense reductions. // These are done last because they need to be after the defense lower cap at 0. - if (cirrusVodka) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * CirrusVodka.DefenseLossPercent); - } - - if (vodka) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * Vodka.DefenseLossPercent); - } - - if (grapeBeer) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * GrapeBeer.DefenseLossPercent); - } - - if (rum) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * Rum.DefenseLossPercent); - } - - if (whiskey) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * Whiskey.DefenseLossPercent); - } - if (everclear) { if (Player.statDefense > 0) Player.statDefense -= (int)(Player.statDefense * Everclear.DefenseLossPercent); } - - if (bloodyMary) - { - if (Main.bloodMoon) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * BloodyMary.DefenseLossPercent); - } - } - - if (caribbeanRum) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * CaribbeanRum.DefenseLossPercent); - } - - if (cinnamonRoll) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * CinnamonRoll.DefenseLossPercent); - } - - if (margarita) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * Margarita.DefenseLossPercent); - } - - if (starBeamRye) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * StarBeamRye.DefenseLossPercent); - } - - if (whiteWine) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * WhiteWine.DefenseLossPercent); - } - - if (Player.HasBuff(BuffID.Tipsy)) - { - if (Player.statDefense > 0) - Player.statDefense -= (int)(Player.statDefense * 0.05); - } - if (DesertProwlerHat.ShroudedInSmoke(Player, out _)) - Player.statDefense -= (int)(Player.statDefense * 0.75); + Player.statDefense -= (int)(Player.statDefense * DesertProwlerHat.SmokeDefenseMult); } #endregion #region Limits private void Limits() { - // TODO -- what is Forbidden Circlet actually supposed to do? - if (forbiddenCirclet) - { - ref StatModifier summon = ref Player.GetDamage(); - ref StatModifier rogue = ref Player.GetDamage(); - float boostToSummonFromRogue = 0f; - float boostToRogueFromSummon = 0f; - - if (summon.Additive < rogue.Additive) - boostToSummonFromRogue = rogue.Additive - summon.Additive; - if (rogue.Additive < summon.Additive) - boostToRogueFromSummon = summon.Additive - rogue.Additive; - - summon += boostToSummonFromRogue; - rogue += boostToRogueFromSummon; - } - // 10% is converted to 9%, 25% is converted to 20%, 50% is converted to 33%, 75% is converted to 43%, 100% is converted to 50% if (Player.endurance > 0f) Player.endurance = 1f - (1f / (1f + Player.endurance)); @@ -4779,13 +4878,13 @@ namespace CalamityMod.CalPlayer { if (CalamityClientConfig.Instance.WikiStatusMessage) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.WikiStatus1"); - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.WikiStatus2"); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Misc.WikiStatus1"); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Misc.WikiStatus2"); } if (CalamityClientConfig.Instance.VCMMStatusMessage && !ExternalMods.VCMMAvailable) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.VCMMStatus"); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Misc.VCMMStatus"); } } @@ -4952,36 +5051,19 @@ namespace CalamityMod.CalPlayer #region Potion Handling private void HandlePotions() { - // Hadal Stew - if (potionTimer > 0) - potionTimer--; - if (potionTimer > 0 && Player.potionDelay == 0) - Player.potionDelay = potionTimer; - if (potionTimer == 1) - { - // Reduced duration than normal - int duration = HadalStew.SicknessDuration; - if (Player.pStone) - duration = (int)(duration * 0.75); - Player.ClearBuff(BuffID.PotionSickness); - Player.AddBuff(BuffID.PotionSickness, duration); - } - if (PlayerInput.Triggers.JustPressed.QuickBuff) { for (int i = 0; i < Main.InventorySlotsTotal; ++i) { Item item = Player.inventory[i]; - if (Player.potionDelay > 0 || potionTimer > 0) + if (Player.potionDelay > 0) break; if (item is null || item.stack <= 0) continue; if (item.type == ModContent.ItemType()) CalamityUtils.ConsumeItemViaQuickBuff(Player, item, HadalStew.BuffType, HadalStew.BuffDuration, true); - if (item.type == ModContent.ItemType()) - CalamityUtils.ConsumeItemViaQuickBuff(Player, item, Margarita.BuffType, CalamityUtils.MinutesToFrames(Margarita.MinuteDuration), false); } } } diff --git a/CalPlayer/CalamityPlayerNetcode.cs b/CalPlayer/CalamityPlayerNetcode.cs index 0981541481..447b4b51d1 100644 --- a/CalPlayer/CalamityPlayerNetcode.cs +++ b/CalPlayer/CalamityPlayerNetcode.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.IO; using System.Linq; using CalamityMod.Cooldowns; using CalamityMod.Packets; @@ -26,10 +25,19 @@ namespace CalamityMod.CalPlayer DefenseDamageSyncPacket.Send(this); } - internal void MouseControlsSync() + internal void MousePositionSync() + { + MousePositionSyncPacket.Send(this); + } + + internal void MouseRotationSync() + { + MouseRotationSyncPacket.Send(this); + } + + internal void MouseRightClickSync() { RightClickSyncPacket.Send(this); - MousePositionSyncPacket.Send(this); } #endregion diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 699a106462..c321b322d5 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -5,12 +5,23 @@ using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.Summon.Whips; using CalamityMod.Cooldowns; using CalamityMod.Dusts; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Reaver; +using CalamityMod.Items.Armor; +using CalamityMod.Items.Armor.Astral; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.Fearmonger; +using CalamityMod.Items.Armor.Hydrothermic; +using CalamityMod.Items.Armor.Plaguebringer; +using CalamityMod.Items.Armor.Silva; +using CalamityMod.Items.Armor.SnowRuffian; +using CalamityMod.Items.Armor.Sulphurous; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Armor.TitanHeart; +using CalamityMod.Items.Armor.Umbraphile; using CalamityMod.Items.Fishing.AstralCatches; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; @@ -26,12 +37,10 @@ using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; -using Mono.Cecil; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; using static Terraria.ModLoader.ModContent; namespace CalamityMod.CalPlayer @@ -58,6 +67,10 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI != Main.myPlayer) return; + // Apply this to player equippable sources ie. Orichalcum set bonus petal spawns + // Do not apply if this effect is an extension of a weapon ie. Pearl God round effect as it will mess up Old Fashioned + var source = Player.GetSource_OnHit(target); + // Handle on-hit melee effects for the gem tech armor set. if (item.CountsAsClass()) GemTechState.MeleeOnHitEffects(target); @@ -72,7 +85,6 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffType(), VulnerabilityHex.AflameDuration); target.Calamity().IncreasedColdEffects_EskimoSet = eskimoSet; - target.Calamity().IncreasedColdEffects_FrozenWings = frozenWingsCold; target.Calamity().IncreasedColdEffects_CryoStone = CryoStone; target.Calamity().IncreasedElectricityEffects_Unused = false; @@ -80,22 +92,19 @@ namespace CalamityMod.CalPlayer target.Calamity().IncreasedHeatEffects_Fireball = fireball; target.Calamity().IncreasedHeatEffects_CinnamonRoll = cinnamonRoll; target.Calamity().IncreasedHeatEffects_FireBoots = bootLevel; - target.Calamity().IncreasedHeatEffects_FlameWings = flameWingsHeat; target.Calamity().IncreasedSicknessEffects_ToxicHeart = toxicHeart; target.Calamity().IncreasedWaterEffects_Amulet1 = sSpiritAmulet; - target.Calamity().IncreasedWaterEffects_Amulet2 = false; + target.Calamity().IncreasedWaterEffects_Amulet2 = dOfTheDeep; target.Calamity().IncreasedSicknessAndWaterEffects_EvergreenGin = evergreenGin; target.Calamity().IncreasedSicknessAndWaterEffects_CorrosiveSpine = corrosiveSpine; + target.Calamity().IncreasedDebuffEffects_Amalgam = amalgam; + switch (item.type) { - case ItemID.DeathSickle: - target.AddBuff(BuffType(), 120); - break; - case ItemID.InfluxWaver: target.AddBuff(BuffID.Electrified, 300); break; @@ -106,7 +115,7 @@ namespace CalamityMod.CalPlayer break; case ItemID.FieryGreatsword: - target.AddBuff(BuffID.OnFire3, 180); + target.AddBuff(BuffID.OnFire3, 90); break; case ItemID.IceSickle: @@ -140,20 +149,48 @@ namespace CalamityMod.CalPlayer bool targetIsDummy = target.type == NPCID.TargetDummy || target.type == NPCType(); ItemLifesteal(target, item, damageDone); - ItemOnHit(item, damageDone, target.Center, hit.Crit, target.IsAnEnemy(false, true), targetIsDummy); - NPCDebuffs(target, item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass()); + ItemOnHit(item, damageDone, target, hit.Crit, target.IsAnEnemy(false, true), targetIsDummy); + NPCDebuffs(target, item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass(), item.CountsAsClass(), hit.Crit); // Ursa Sergeant slash cooldown is reset on kill if (ursaSergeant && target.life <= 0 && target.realLife == -1) ursaSergeantCooldown = (int)MathHelper.Clamp(ursaSergeantCooldown - 180, 0, 300); - if (bGlassBand && bGlassbandCooldown == 0) + + if (generalBandCooldown == 0) { - var source = item.GetSource_FromThis(); - int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); - Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; - Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); - bGlassbandCooldown = BlackGlassBand.cooldown; + int cooldown = 0; + if (bGlassBand) + { + int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); + Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; + Projectile.NewProjectile(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); + if (cooldown < BlackGlassBand.cooldown) + cooldown = BlackGlassBand.cooldown; + } + if (protolithBangle && item.DamageType == DamageClass.Ranged) + { + int damage = (int)Player.GetBestClassDamage().ApplyTo(ProtolithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Ranged; + if (cooldown < ProtolithBangle.cooldown) + cooldown = ProtolithBangle.cooldown; + } + if (batholithBangle && item.DamageType == DamageClass.Magic) + { + int damage = (int)Player.GetBestClassDamage().ApplyTo(BatholithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Magic; + if (cooldown < BatholithBangle.cooldown) + cooldown = BatholithBangle.cooldown; + } + + if (cooldown > 0) // Check if a band effect went off, and apply the highest cooldown + { + generalBandCooldown = cooldown; + Player.AddCooldown(GenericBandCooldown.ID, cooldown); + } } + if (luxorsGift) luxorHit = true; @@ -165,13 +202,13 @@ namespace CalamityMod.CalPlayer // Arc Flash Ring lightning strike (Remember to change the one for projectile hits if applicable when you change this one!) // This one has a lot less limits than the projectile one, but that's because vanilla broadsword code is limiting (wow so surprising) - if (arcFlashRing && (Main.rand.Next(0, 100) < 6)) + bool spawnChance = (Main.rand.Next(100) < ArcFlashRing.LightningSpawnPercent); + if (arcFlashRing && spawnChance) { - var source = item.GetSource_FromThis(); - int damage = (int)((hit.Damage * 4f) * (hit.Crit ? 0.5f : 1)); // 400% damage (uneffected by crits) - Vector2 position = target.Center + new Vector2(0, -750); + int damage = (int)(hit.Damage * ArcFlashRing.LightningDamageMult * (hit.Crit ? 0.5f : 1) / (Player.Calamity().adrenalineModeActive ? Player.Calamity().GetAdrenalineDamage() + 1 : 1)); // 400% damage (uneffected by crits and adrenaline) - Projectile.NewProjectile(source, position, new Vector2(0, 10), ProjectileType(), damage, 0f, Player.whoAmI, target.whoAmI); + Projectile bolt = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, 0f, Player.whoAmI, target.whoAmI); + bolt.DamageType = hit.DamageType; } // Shattered Community tracks all damage dealt with Rage Mode (ignoring dummies). @@ -189,6 +226,9 @@ namespace CalamityMod.CalPlayer if (Player.whoAmI != Main.myPlayer) return; + // Apply this to player equippable sources ie. Orichalcum set bonus petal spawns + // Do not apply if this effect is an extension of a weapon ie. Pearl God round effect as it will mess up Old Fashioned + var source = Player.GetSource_OnHit(target); CalamityGlobalNPC cgn = target.Calamity(); // Handle on-hit melee effects for the gem tech armor set. @@ -203,27 +243,32 @@ namespace CalamityMod.CalPlayer if (proj.type != ProjectileType()) MythrilArmorSetChange.OnHitEffects(target, damageDone, Player); - if (witheringWeaponEnchant) + if (moscowMule) + { + var center = Player.Center; + if (proj.IsMinionOrSentryRelated) + center = proj.Center; + Vector2 launchVel = Utils.DirectionTo(center, target.Center); + target.MoveNPC(launchVel, proj.knockBack, true); + } + + if (moscowMule || bloodyMary) + { + if (!(PierceResistNPC.exemptProjectiles.Contains(proj.type) || (PierceResistNPC.singleHitboxExemptProjectiles.ContainsKey(proj.type) && PierceResistNPC.singleHitboxExemptProjectiles[proj.type]))) + { + proj.damage = (int)(proj.damage * (moscowMule ? 0.8f : 1f) * (bloodyMary ? 0.75f : 1f)); + } + + } + + if (witheringWeaponEnchant) witheringDamageDone += (int)(damageDone * (hit.Crit ? 2D : 1D)); - - cgn.IncreasedColdEffects_EskimoSet = eskimoSet; - cgn.IncreasedColdEffects_FrozenWings = frozenWingsCold; - cgn.IncreasedColdEffects_CryoStone = CryoStone; - - cgn.IncreasedElectricityEffects_Unused = false; - - cgn.IncreasedHeatEffects_Fireball = fireball; - cgn.IncreasedHeatEffects_CinnamonRoll = cinnamonRoll; - cgn.IncreasedHeatEffects_FireBoots = bootLevel; - cgn.IncreasedHeatEffects_FlameWings = flameWingsHeat; - - cgn.IncreasedSicknessEffects_ToxicHeart = toxicHeart; - - cgn.IncreasedWaterEffects_Amulet1 = sSpiritAmulet; - cgn.IncreasedWaterEffects_Amulet2 = false; - - cgn.IncreasedSicknessAndWaterEffects_EvergreenGin = evergreenGin; - cgn.IncreasedSicknessAndWaterEffects_CorrosiveSpine = corrosiveSpine; + cgn.TypelessDebuffMultiplier = TypelessDebuffMultiplier; + cgn.HeatDebuffMultiplier = HeatDebuffMultiplier; + cgn.ColdDebuffMultiplier = ColdDebuffMultiplier; + cgn.SicknessDebuffMultiplier = SicknessDebuffMultiplier; + cgn.WaterDebuffMultiplier = WaterDebuffMultiplier; + cgn.ElectricDebuffMultiplier = ElectricDebuffMultiplier; switch (proj.type) { @@ -247,10 +292,6 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffType(), 180); break; - case ProjectileID.DeathSickle: - target.AddBuff(BuffType(), 60); - break; - case ProjectileID.ButchersChainsaw: case ProjectileID.MechanicalPiranha: target.AddBuff(BuffType(), 180); @@ -316,15 +357,45 @@ namespace CalamityMod.CalPlayer // Ursa Sergeant slash cooldown is reset on kill if (ursaSergeant && target.life <= 0 && target.realLife == -1) ursaSergeantCooldown = (int)MathHelper.Clamp(ursaSergeantCooldown - UrsaSergeant.CooldownReducedPerKill, 0, UrsaSergeant.MaxCooldown); - if (bGlassBand && bGlassbandCooldown == 0) + + if (generalBandCooldown == 0) { - var source = proj.GetSource_FromThis(); - int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); - Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; - Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); - bGlassbandCooldown = BlackGlassBand.cooldown; + int cooldown = 0; + // NOTE: Apparently Pulse Pistol/Pulse Rifle projectiles will set spawned projectiles here to inherit the proj ID??? + // No clue why this happens or how to fix it, but it just breaks using multiple band types together on these two weapons + if (bGlassBand) + { + int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); + Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; + Projectile.NewProjectile(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); + if (cooldown < BlackGlassBand.cooldown) + cooldown = BlackGlassBand.cooldown; + } + if (protolithBangle && proj.DamageType == DamageClass.Ranged) + { + int damage = (int)Player.GetBestClassDamage().ApplyTo(ProtolithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Ranged; + if (cooldown < ProtolithBangle.cooldown) + cooldown = ProtolithBangle.cooldown; + } + if (batholithBangle && proj.DamageType == DamageClass.Magic) + { + int damage = (int)Player.GetBestClassDamage().ApplyTo(BatholithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Magic; + if (cooldown < BatholithBangle.cooldown) + cooldown = BatholithBangle.cooldown; + } + + if (cooldown > 0) // Check if a band effect went off, and apply the highest cooldown + { + generalBandCooldown = cooldown; + Player.AddCooldown(GenericBandCooldown.ID, cooldown); + } } - if (luxorsGift && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType()) + + if (luxorsGift && proj.type != ProjectileType() && proj.type != ProjectileType() && proj.type != ProjectileType() && proj.type != ProjectileType() && proj.type != ProjectileType() && proj.type != ProjectileType()) luxorHit = true; // Transformer gives +2 blobs on kill, which are stored then given to you one by one (so it can't spawn more than one on a single frame) @@ -335,28 +406,30 @@ namespace CalamityMod.CalPlayer CalamityGlobalProjectile globalProj = proj.Calamity(); // Arc Flash Ring lightning strike (Remember to change the one for item hits if applicable when you change this one!) - // Minions ignore the chance penalty on penetration - bool spawnChance = (Main.rand.Next(0, 100) < MathHelper.Clamp(6 - proj.numHits, (proj.minion ? 6 : 1), 6)); - if (arcFlashRing && spawnChance && proj.type != ProjectileType() && globalProj.spawnArcFlash) + bool spawnChance = (Main.rand.Next(0, 100) < ArcFlashRing.LightningSpawnPercent); + if (arcFlashRing && spawnChance && proj.type != ProjectileType()) { proj.active = true; // Okay so if a projectile manually kills itself on hit, it totally breaks the bolts. to prevent this we set them to active - var source = proj.GetSource_FromThis(); - int damage = (int)((hit.Damage * 4f) * (hit.Crit ? 0.5f : 1)); // 400% damage (uneffected by crits) - Vector2 position = target.Center + new Vector2(0, -750); + int damage = (int)(hit.Damage * ArcFlashRing.LightningDamageMult * (hit.Crit ? 0.5f : 1) / (Player.Calamity().adrenalineModeActive ? Player.Calamity().GetAdrenalineDamage() + 1 : 1)); // 400% damage (uneffected by crits and adrenaline) - Projectile bolt = Projectile.NewProjectileDirect(source, position, new Vector2(0, 10), ProjectileType(), damage, 0f, Player.whoAmI, target.whoAmI); + Projectile bolt = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, 0f, Player.whoAmI, target.whoAmI, (globalProj.showArcFlash ? 0 : 1)); bolt.DamageType = hit.DamageType; - globalProj.spawnArcFlash = false; - // This is really only used for long lasting projectiles and contact damage minions - globalProj.arcFlashCooldown = 90; + globalProj.showArcFlash = false; + // This is really only used for piercing and long lasting projectiles so they dont flood the screen with bolts + globalProj.arcFlashCooldown = 30; + } + + if (forbiddenCirclet && globalProj.stealthStrike) + { + target.AddBuff(BuffType(), ForbiddenCirclet.TagDuration); } if (!proj.npcProj && !proj.trap && proj.friendly) { - if (plaguebringerCarapace && FriendlyBeesList.Includes(proj.type)) - target.AddBuff(BuffType(), 300); + if (plaguebringerPatronSet && CalamityProjectileSets.IsFriendlyBeeProjectile[proj.type]) + target.AddBuff(BuffType(), PlaguebringerVisor.BeePlagueDuration); // All projectiles fired from Soma Prime are marked using CalamityGlobalProjectile CalamityGlobalProjectile cgp = proj.Calamity(); @@ -439,14 +512,14 @@ namespace CalamityMod.CalPlayer } for (int i = 0; i <= 12; i++) { - Dust dust2 = Dust.NewDustPerfect(proj.Center, 278, new Vector2(4, 4).RotatedByRandom(100f) * Main.rand.NextFloat(0.1f, 2.9f)); + Dust dust2 = Dust.NewDustPerfect(proj.Center, DustID.FireworksRGB, new Vector2(4, 4).RotatedByRandom(100f) * Main.rand.NextFloat(0.1f, 2.9f)); dust2.noGravity = false; dust2.scale = Main.rand.NextFloat(0.3f, 0.9f); dust2.color = Color.Turquoise; } int onHitDamage = Player.CalcIntDamage(0.2f * proj.damage); - Projectile shock = Projectile.NewProjectileDirect(proj.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, 0f, Player.whoAmI, target.whoAmI); + Projectile shock = Projectile.NewProjectileDirect(proj.GetSource_FromThis(), target.Center, Vector2.Zero, ProjectileType(), onHitDamage, 0f, Player.whoAmI, target.whoAmI); shock.DamageType = proj.DamageType; SoundStyle hitSound = new("CalamityMod/Sounds/Item/ElectricHit"); SoundEngine.PlaySound(hitSound with { Volume = 0.2f, Pitch = 0.7f, PitchVariance = 0.2f }, proj.Center); @@ -478,24 +551,24 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(subTrail); } - int pearls = (int)(MathHelper.Clamp(7 - (int)(proj.numHits * 0.5f), 2, 7)); + int pearls = (int)MathHelper.Clamp(7 - (int)(proj.numHits * 0.5f), 2, 7); for (int k = 0; k < pearls; k++) { Vector2 velocity = new Vector2(1, 1).RotatedByRandom(100) * Main.rand.NextFloat(0.7f, 1.2f); PearlParticle subTrail = new PearlParticle(Position + velocity * 11f, velocity * 10, true, 50, 0.85f, color, 0.95f, Main.rand.NextFloat(2, -2), true); GeneralParticleHandler.SpawnParticle(subTrail); } - int dusts = (int)(MathHelper.Clamp(10 - (int)(proj.numHits * 0.5f), 2, 10)); + int dusts = (int)MathHelper.Clamp(10 - (int)(proj.numHits * 0.5f), 2, 10); for (int i = 0; i <= dusts; i++) { - Dust dust2 = Dust.NewDustPerfect(Position, 278, new Vector2(5, 5).RotatedByRandom(100f) * Main.rand.NextFloat(0.1f, 2.9f)); + Dust dust2 = Dust.NewDustPerfect(Position, DustID.FireworksRGB, new Vector2(5, 5).RotatedByRandom(100f) * Main.rand.NextFloat(0.1f, 2.9f)); dust2.noGravity = false; dust2.scale = Main.rand.NextFloat(0.3f, 0.8f); dust2.color = color; } int onHitDamage = Player.CalcIntDamage(0.2f * proj.damage); - Projectile blast = Projectile.NewProjectileDirect(proj.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, 0f, Player.whoAmI, target.whoAmI); + Projectile blast = Projectile.NewProjectileDirect(proj.GetSource_FromThis(), target.Center, Vector2.Zero, ProjectileType(), onHitDamage, 0f, Player.whoAmI, target.whoAmI); blast.DamageType = proj.DamageType; SoundStyle hitSound = new("CalamityMod/Sounds/Item/HadalUrnClose"); @@ -513,11 +586,7 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(orb); } - int heal = (int)Math.Round(hit.Damage * 0.035); - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Main.player[proj.owner], heal, ProjectileType(), BalancingConstants.LifeStealRange); + Main.player[proj.owner].SpawnLifeStealProjectile(target, proj, ProjectileType(), (int)Math.Round(hit.Damage * 0.035)); } if ((cgp.betterLifeBullet1 || cgp.betterLifeBullet2) && proj.numHits == 0) @@ -533,21 +602,17 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(orb); } - int heal = (int)Math.Round(hit.Damage * 0.01); - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - for (int i = 0; i <= 2; i++) { - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Main.player[proj.owner], heal, ProjectileType(), BalancingConstants.LifeStealRange); + Main.player[proj.owner].SpawnLifeStealProjectile(target, proj, ProjectileType(), (int)Math.Round(hit.Damage * 0.01), 0.75f); } } bool targetIsDummy = target.type == NPCID.TargetDummy || target.type == NPCType(); ProjLifesteal(target, proj, damageDone, hit.Crit); - ProjOnHit(proj, target.Center, hit.Crit, target.IsAnEnemy(false), targetIsDummy); - NPCDebuffs(target, proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), true, proj.noEnchantments); + ProjOnHit(proj, target, hit.Crit, target.IsAnEnemy(false), targetIsDummy); + NPCDebuffs(target, proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), hit.Crit, true, proj.noEnchantments); // Shattered Community tracks all damage dealt with Rage Mode (ignoring dummies). if (targetIsDummy) @@ -560,28 +625,26 @@ namespace CalamityMod.CalPlayer #endregion #region Item - public void ItemOnHit(Item item, int damage, Vector2 position, bool crit, bool npcCheck, bool targetIsDummy) + public void ItemOnHit(Item item, int damage, NPC target, bool crit, bool npcCheck, bool targetIsDummy) { - var source = Player.GetSource_ItemUse(item); + Vector2 position = target.Center; + var source = Player.GetSource_OnHit(target); if (!item.CountsAsClass() && Player.meleeEnchant == 7) Projectile.NewProjectile(source, position, Player.velocity, ProjectileID.ConfettiMelee, 0, 0f, Player.whoAmI); - if (reaverDefense) - Player.lifeRegenTime += 1; - if (npcCheck) { if (item.CountsAsClass() && hideOfDeus && hideOfDeusTimer == 0) { hideOfDeusTimer = 10; - int bulwarkStarDamage = (int)Player.GetTotalDamage().ApplyTo(320); + int bulwarkStarDamage = (int)Player.GetTotalDamage().ApplyTo(HideofAstrumDeus.StarDamage); for (int n = 0; n < 3; n++) CalamityUtils.ProjectileRain(source, Player.Center, 400f, 100f, 500f, 800f, 29f, ProjectileType(), bulwarkStarDamage, 5f, Player.whoAmI); } if (astralStarRain && crit && astralStarRainCooldown <= 0) { - astralStarRainCooldown = 60; + astralStarRainCooldown = AstralHelm.StarRainCooldown; for (int n = 0; n < 3; n++) { int projectileType = Utils.SelectRandom(Main.rand, new int[] @@ -592,7 +655,7 @@ namespace CalamityMod.CalPlayer ProjectileID.StarCannonStar }); - int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(120); + int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(AstralHelm.StarDamage); Projectile star = CalamityUtils.ProjectileRain(source, position, 400f, 100f, 500f, 800f, 12f, projectileType, astralStarDamage, 5f, Player.whoAmI); if (star.whoAmI.WithinBounds(Main.maxProjectiles)) @@ -605,15 +668,13 @@ namespace CalamityMod.CalPlayer { if (npcCheck) { - if (ataxiaGeyser && Player.ownedProjectileCounts[ProjectileType()] < 3) + if (ataxiaGeyser && Player.ownedProjectileCounts[ProjectileType()] < HydrothermicHeadMelee.GeyserCountLimit) { - // Ataxia True Melee Geysers: 15%, softcap starts at 300 base damage - int geyserDamage = CalamityUtils.DamageSoftCap(damage * 0.15, 45); - - Projectile.NewProjectile(source, position, Vector2.Zero, ProjectileType(), geyserDamage, 2f, Player.whoAmI, 0f, 0f); + int geyserDamage = CalamityUtils.DamageSoftCap(damage * HydrothermicHeadMelee.GeyserDamageRatio, HydrothermicHeadMelee.GeyserDamageSoftcap); + Projectile.NewProjectile(source, position, Vector2.Zero, ProjectileType(), geyserDamage, 2f, Player.whoAmI); } - if (bloodflareMelee && item.CountsAsClass() && bloodflareMeleeHits < 15 && !bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID)) + if (bloodflareMelee && item.CountsAsClass() && bloodflareMeleeHits < BloodflareHeadMelee.HitsToActivateFrenzy && !bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID)) bloodflareMeleeHits++; } } @@ -621,10 +682,11 @@ namespace CalamityMod.CalPlayer #endregion #region Proj On Hit - public void ProjOnHit(Projectile proj, Vector2 position, bool crit, bool npcCheck, bool targetIsDummy) + public void ProjOnHit(Projectile proj, NPC target, bool crit, bool npcCheck, bool targetIsDummy) { CalamityGlobalProjectile modProj = proj.Calamity(); - var source = proj.GetSource_FromThis(); + Vector2 position = target.Center; + var source = Player.GetSource_OnHit(target); bool hasClass = proj.CountsAsClass() || proj.CountsAsClass() || proj.CountsAsClass() || proj.CountsAsClass() || proj.CountsAsClass(); //flask of party affects all types of weapons, !proj.CountsAsClass() is to prevent double flask effects @@ -647,14 +709,11 @@ namespace CalamityMod.CalPlayer if (theBee && lifeAndShieldCondition) SoundEngine.PlaySound(SoundID.Item110, proj.Center); - if (reaverDefense) - Player.lifeRegenTime += 1; - if (npcCheck) { if (astralStarRain && crit && astralStarRainCooldown <= 0) { - astralStarRainCooldown = 60; + astralStarRainCooldown = AstralHelm.StarRainCooldown; for (int n = 0; n < 3; n++) { int projectileType = Utils.SelectRandom(Main.rand, new int[] @@ -665,7 +724,7 @@ namespace CalamityMod.CalPlayer ProjectileID.StarCannonStar }); - int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(120); + int astralStarDamage = (int)Player.GetBestClassDamage().ApplyTo(AstralHelm.StarDamage); Projectile star = CalamityUtils.ProjectileRain(source, position, 400f, 100f, 500f, 800f, 25f, projectileType, astralStarDamage, 5f, Player.whoAmI); if (star.whoAmI.WithinBounds(Main.maxProjectiles)) @@ -691,29 +750,26 @@ namespace CalamityMod.CalPlayer if (ursaSergeant && ursaSergeantCooldown <= 0) { ursaSergeantCooldown = UrsaSergeant.MaxCooldown; - int ursaSlashdamage = (int)Player.GetBestClassDamage().ApplyTo(UrsaSergeant.BaseSwipeDamage); - Projectile.NewProjectile(source, position, Vector2.Zero, ProjectileType(), ursaSlashdamage, 0f, Player.whoAmI); } if (proj.CountsAsClass()) - MeleeOnHit(proj, modProj, position, crit, npcCheck, targetIsDummy); + MeleeOnHit(proj, modProj, target, crit, npcCheck, targetIsDummy); if (proj.CountsAsClass()) - RangedOnHit(proj, modProj, position, crit, npcCheck); + RangedOnHit(proj, modProj, target, crit, npcCheck); if (proj.CountsAsClass()) - MagicOnHit(proj, modProj, position, crit, npcCheck); + MagicOnHit(proj, modProj, target, crit, npcCheck); if (proj.CountsAsClass() && !proj.CountsAsClass()) - SummonOnHit(proj, modProj, position, crit, npcCheck); + SummonOnHit(proj, modProj, target, crit, npcCheck); if (proj.CountsAsClass()) - RogueOnHit(proj, modProj, position, crit, npcCheck); + RogueOnHit(proj, modProj, target, crit, npcCheck); } #region Melee - private void MeleeOnHit(Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck, bool targetIsDummy) + private void MeleeOnHit(Projectile proj, CalamityGlobalProjectile modProj, NPC target, bool crit, bool npcCheck, bool targetIsDummy) { - var source = proj.GetSource_FromThis(); - Item heldItem = Player.ActiveItem(); + var source = Player.GetSource_OnHit(target); if (proj.IsTrueMelee()) { @@ -736,26 +792,27 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(source, proj.Center, Vector2.Zero, ProjectileType(), geyserDamage, 0f, Player.whoAmI, 0f, 0f); } - if (bloodflareMelee && proj.IsTrueMelee() && bloodflareMeleeHits < 15 && !bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID)) + if (bloodflareMelee && proj.IsTrueMelee() && bloodflareMeleeHits < BloodflareHeadMelee.HitsToActivateFrenzy && !bloodflareFrenzy && !Player.HasCooldown(BloodflareFrenzy.ID)) bloodflareMeleeHits++; } } #endregion #region Ranged - private void RangedOnHit(Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + private void RangedOnHit(Projectile proj, CalamityGlobalProjectile modProj, NPC target, bool crit, bool npcCheck) { - var source = proj.GetSource_FromThis(); + Vector2 position = target.Center; + var source = Player.GetSource_OnHit(target); if (npcCheck) { if (tarraRanged && proj.CountsAsClass() && tarraRangedCooldown <= 0) { - tarraRangedCooldown = 60; + tarraRangedCooldown = TarragonHeadRanged.OnHitEffectCooldown; for (int l = 0; l < 2; l++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int leafDamage = (int)(0.25f * proj.damage); + int leafDamage = CalamityUtils.DamageSoftCap((int)(proj.damage * TarragonHeadRanged.LeafDamageRatio), TarragonHeadRanged.LeafDamageSoftcap); int leaf = Projectile.NewProjectile(source, position, velocity, ProjectileID.Leaf, leafDamage, 0f, Player.whoAmI); if (leaf.WithinBounds(Main.maxProjectiles)) { @@ -768,17 +825,18 @@ namespace CalamityMod.CalPlayer for (int projCount = 0; projCount < 2; projCount++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int energyDamage = (int)(0.33f * proj.damage); + int energyDamage = CalamityUtils.DamageSoftCap((int)(proj.damage * TarragonHeadRanged.EnergyDamageRatio), TarragonHeadRanged.EnergyDamageSoftcap); Projectile.NewProjectile(source, proj.Center, velocity, ProjectileType(), energyDamage, 0f, proj.owner); } } } } - if (dynamoStemCells && MiniSwamerCooldown <= 0 && proj.CountsAsClass()) + if (dynamoStemCells && MiniSwarmerCooldown <= 0 && proj.CountsAsClass()) { - MiniSwamerCooldown = DynamoStemCells.MiniSwamerCooldown; - - Vector2 velocity = proj.velocity.SafeNormalize(Vector2.UnitY) * 19; + MiniSwarmerCooldown = DynamoStemCells.MiniSwarmerCooldown; + Vector2 directionToMouse = Main.MouseWorld - Player.Center; + directionToMouse.Normalize(); + Vector2 velocity = directionToMouse * 19; int MiniSwamerDamage = (int)Player.GetTotalDamage().ApplyTo(DynamoStemCells.MiniSwamerDamage); Projectile.NewProjectile(source, Player.Center, velocity, ProjectileType(), MiniSwamerDamage, 2f, proj.owner); } @@ -786,15 +844,16 @@ namespace CalamityMod.CalPlayer #endregion #region Magic - private void MagicOnHit(Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + private void MagicOnHit(Projectile proj, CalamityGlobalProjectile modProj, NPC target, bool crit, bool npcCheck) { - var source = proj.GetSource_FromThis(); + Vector2 position = target.Center; + var source = Player.GetSource_OnHit(target); if (ataxiaMage && ataxiaDmg <= 0) { - int orbDamage = (int)(proj.damage * 0.6f); - - CalamityUtils.SpawnOrb(proj, orbDamage, ProjectileType(), 800f, 20f); - int cooldown = (int)(orbDamage * 0.5); + int orbDamage = (int)(proj.damage * HydrothermicHeadMagic.OrbDamageRatio); + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 20f, 20f, 1f); + Projectile.NewProjectile(source, proj.Center, velocity, ProjectileType(), orbDamage, 0f, proj.owner); + int cooldown = (int)(orbDamage * HydrothermicHeadMagic.OrbDamageCooldownMult); ataxiaDmg += cooldown; } if (tarraMage && crit) @@ -805,9 +864,8 @@ namespace CalamityMod.CalPlayer { if (bloodflareMage && bloodflareMageCooldown <= 0 && crit) { - bloodflareMageCooldown = 120; - // Bloodflare Mage Explosion: 50%, softcap starts at 500 base damage to not overly punish slow weapons - int bloodflareFireballDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.5, 250); + bloodflareMageCooldown = BloodflareHeadMagic.BloodsplosionCooldown; + int bloodflareFireballDamage = CalamityUtils.DamageSoftCap(proj.damage * BloodflareHeadMagic.BloodsplosionDamageRatio, BloodflareHeadMagic.BloodsplosionDamageSoftcap); int fire = Projectile.NewProjectile(source, position, Vector2.Zero, ProjectileType(), bloodflareFireballDamage, 0f, Player.whoAmI, 0f, 0f, 1f); if (fire.WithinBounds(Main.maxProjectiles)) @@ -819,22 +877,20 @@ namespace CalamityMod.CalPlayer } if (silvaMage && silvaMageCooldown <= 0 && (proj.penetrate == 1 || proj.timeLeft <= 5)) { - silvaMageCooldown = 300; + silvaMageCooldown = SilvaHeadMagic.BurstCooldown; SoundEngine.PlaySound(SoundID.Zombie103, proj.Center); //So scuffed, just because zombie sounds werent ported normally - // Silva Mage Blasts: 800 + 60%, softcap on the whole combined thing starts at 1400 - int silvaBurstDamage = CalamityUtils.DamageSoftCap(800.0 + 0.6 * proj.damage, 1400); + int silvaBurstDamage = CalamityUtils.DamageSoftCap(SilvaHeadMagic.BurstDamage + proj.damage * SilvaHeadMagic.BurstDamageRatio, SilvaHeadMagic.BurstDamageSoftcap); Projectile.NewProjectile(source, proj.Center, Vector2.Zero, ProjectileType(), silvaBurstDamage, 8f, Player.whoAmI); } } #endregion #region Summon - private void SummonOnHit(Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + private void SummonOnHit(Projectile proj, CalamityGlobalProjectile modProj, NPC target, bool crit, bool npcCheck) { - var source = proj.GetSource_FromThis(); + Vector2 position = target.Center; + var source = Player.GetSource_OnHit(target); - if (npcCheck) - { if (phantomicArtifact) { int restoreBuff = BuffType(); @@ -846,23 +902,23 @@ namespace CalamityMod.CalPlayer empowerBuff, shieldBuff }); - Player.AddBuff(buffType, 60); + Player.AddBuff(buffType, 120); if (buffType == restoreBuff) { - if (phantomicHeartRegen == 1000 && Player.ownedProjectileCounts[ProjectileType()] == 0 && Main.rand.NextBool(20)) + if (phantomicHeartRegen == 1000 && Player.ownedProjectileCounts[ProjectileType()] == 0) { - Vector2 target = proj.Center; - target.Y += Main.rand.Next(-50, 50); - target.X += Main.rand.Next(-50, 50); - Projectile.NewProjectile(source, target, Vector2.Zero, ProjectileType(), 0, 0f, Player.whoAmI); + Vector2 spawnPos = proj.Center; + spawnPos.Y += Main.rand.Next(-50, 50); + spawnPos.X += Main.rand.Next(-50, 50); + Projectile.NewProjectile(source, spawnPos, Vector2.Zero, ProjectileType(), 0, 0f, Player.whoAmI); } } else if (buffType == empowerBuff) { - if (Player.ownedProjectileCounts[ProjectileType()] < 3 && Main.rand.NextBool(10)) + if (Player.ownedProjectileCounts[ProjectileType()] < 3 && Main.rand.NextBool(4)) { int damage = (int)Player.GetTotalDamage().ApplyTo(100); - Projectile.NewProjectile(source, proj.position, proj.velocity, ProjectileType(), damage, 1f, Player.whoAmI); + Projectile.NewProjectile(source, Player.Center, new Vector2(Player.velocity.X,Player.velocity.Y-10).RotatedByRandom(0.3f), ProjectileType(), damage, 1f, Player.whoAmI); } } else @@ -879,7 +935,7 @@ namespace CalamityMod.CalPlayer BuffType(), BuffType() }); - Player.AddBuff(buffType, 60); + Player.AddBuff(buffType, 120); } else if (sGlyph) { @@ -889,16 +945,15 @@ namespace CalamityMod.CalPlayer BuffType(), BuffType() }); - Player.AddBuff(buffType, 60); + Player.AddBuff(buffType, 120); } - } - // Fearmonger set gains +10 frames (max 90) of regen when any minion lands any hit + // Fearmonger set gains regen duration when any minion lands any hit if (fearmongerSet) { - fearmongerRegenFrames += 10; - if (fearmongerRegenFrames > 90) - fearmongerRegenFrames = 90; + fearmongerRegenFrames += FearmongerGreathelm.RegenBoostDurationPerHit; + if (fearmongerRegenFrames > FearmongerGreathelm.RegenBoostDurationLimit) + fearmongerRegenFrames = FearmongerGreathelm.RegenBoostDurationLimit; } //Priorities: Nucleogenesis => Starbuster Core => Nuclear Rod => Jelly-Charged Battery @@ -946,10 +1001,13 @@ namespace CalamityMod.CalPlayer if (hallowedRuneCooldown <= 0) { hallowedRuneCooldown = 180; - Vector2 spawnPosition = position - new Vector2(0f, 920f).RotatedByRandom(0.3f); + for (var i = 0; i < 3; i++) + { + Vector2 spawnPosition = position - new Vector2(0f, 920f).RotatedByRandom(0.3f); float speed = Main.rand.NextFloat(17f, 23f); int hallowedDamage = (int)Player.GetTotalDamage().ApplyTo(50); - Projectile.NewProjectile(source, spawnPosition, Vector2.Normalize(position - spawnPosition) * speed, ProjectileType(), hallowedDamage, 3f, proj.owner); + Projectile.NewProjectile(source, spawnPosition, Vector2.Normalize(position - spawnPosition) * speed, ProjectileType(), hallowedDamage, 3f, proj.owner); + } } } } @@ -957,9 +1015,10 @@ namespace CalamityMod.CalPlayer #endregion #region Rogue - private void RogueOnHit(Projectile proj, CalamityGlobalProjectile modProj, Vector2 position, bool crit, bool npcCheck) + private void RogueOnHit(Projectile proj, CalamityGlobalProjectile modProj, NPC target, bool crit, bool npcCheck) { - var spawnSource = proj.GetSource_FromThis(); + Vector2 position = target.Center; + var spawnSource = Player.GetSource_OnHit(target); int Type = ProjectileType(); if (modProj.stealthStrike && dragonScales && Main.projectile.Count(proj => proj.type == Type && proj.active) < 1) { @@ -1023,7 +1082,7 @@ namespace CalamityMod.CalPlayer { Vector2 source = new Vector2(position.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); Vector2 velocity = (position - source) / 40f; - int damage = (int)Player.GetTotalDamage().ApplyTo(95); + int damage = (int)Player.GetTotalDamage().ApplyTo(110); Projectile.NewProjectile(spawnSource, source, velocity, ProjectileType(), damage, 3f, proj.owner); } } @@ -1064,32 +1123,15 @@ namespace CalamityMod.CalPlayer rogueCrownCooldown = spawnedFeathers ? 15 : 60; } - if (forbiddenCirclet && modProj.stealthStrike && forbiddenCooldown <= 0 && modProj.stealthStrikeHitCount < 3) - { - for (int index2 = 0; index2 < 6; index2++) - { - float xVector = Main.rand.Next(-35, 36) * 0.02f; - float yVector = Main.rand.Next(-35, 36) * 0.02f; - xVector *= 10f; - yVector *= 10f; - int damage = (int)Player.GetTotalDamage().ApplyTo(40); - - int eater = Projectile.NewProjectile(spawnSource, proj.Center.X, proj.Center.Y, xVector, yVector, ProjectileType(), damage, proj.knockBack, proj.owner); - if (eater.WithinBounds(Main.maxProjectiles)) - Main.projectile[eater].DamageType = DamageClass.Generic; - forbiddenCooldown = 15; - } - } - if (titanHeartSet && modProj.stealthStrike && titanCooldown <= 0 && modProj.stealthStrikeHitCount < 3) { - int damage = (int)Player.GetTotalDamage().ApplyTo(40); + int damage = (int)Player.GetTotalDamage().ApplyTo(TitanHeartMask.ExplosionDamage); Projectile.NewProjectile(spawnSource, proj.Center, Vector2.Zero, ProjectileType(), damage, proj.knockBack, proj.owner, 1f, 0f); SoundEngine.PlaySound(SoundID.Item14, proj.Center); - for (int dustexplode = 0; dustexplode < 180; dustexplode++) + for (int dustexplode = 0; dustexplode < 120; dustexplode++) { - Vector2 dustd = Vector2.One.RotatedBy(MathHelper.ToRadians(dustexplode * 2)) * 1.7f; + Vector2 dustd = Vector2.One.RotatedBy(MathHelper.ToRadians(dustexplode * 3)) * 1.7f; Dust dust = Dust.NewDustPerfect(proj.Center, Main.rand.NextBool() ? DustType() : DustType(), dustd, Alpha: 100); dust.noGravity = true; } @@ -1099,6 +1141,8 @@ namespace CalamityMod.CalPlayer if (raiderTalisman && modProj.stealthStrike) { raiderCritLifespan = CalamityUtils.SecondsToFrames(RaidersTalisman.RaiderCooldown); + // TO DO: Add nanotech here + Player.AddCooldown(RaiderBoost.ID, raiderCritLifespan, true, vampiricTalisman ? "Bloodfeast" : "default"); if (raiderSoundCooldown <= 0) { SoundEngine.PlaySound(RaidersTalisman.StealthHitSound, Player.Center); @@ -1111,9 +1155,7 @@ namespace CalamityMod.CalPlayer // Umbraphile cannot trigger off of itself. It is guaranteed on stealth strikes and 20% chance otherwise. if (umbraphileSet && ((modProj.stealthStrike && modProj.stealthStrikeHitCount < 3) || Main.rand.NextBool(5))) { - // Umbraphile Rogue Blasts: 20%, softcap starts at 50 base damage - int umbraBlastDamage = CalamityUtils.DamageSoftCap(proj.damage * 0.20, 50); - + int umbraBlastDamage = CalamityUtils.DamageSoftCap(proj.damage * UmbraphileHood.ExplosionDamageRatio, UmbraphileHood.ExplosionDamageSoftcap); Projectile.NewProjectile(spawnSource, proj.Center, Vector2.Zero, ProjectileType(), umbraBlastDamage, 0f, Player.whoAmI); } if (electricianGlove && modProj.stealthStrike && modProj.stealthStrikeHitCount < 3) @@ -1138,7 +1180,7 @@ namespace CalamityMod.CalPlayer #endregion #region Debuffs - public void NPCDebuffs(NPC target, bool melee, bool ranged, bool magic, bool summon, bool rogue, bool whip, bool proj = false, bool noFlask = false) + public void NPCDebuffs(NPC target, bool melee, bool ranged, bool magic, bool summon, bool rogue, bool whip, bool crit, bool proj = false, bool noFlask = false) { if (melee && !noFlask) // Prevents Deep Sea Dumbell from snagging true melee debuff memes { @@ -1146,10 +1188,6 @@ namespace CalamityMod.CalPlayer { CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); } - if (ataxiaFire) - { - CalamityUtils.Inflict246DebuffsNPC(target, BuffID.OnFire3, 4f); - } } if ((melee || rogue || whip) && !noFlask) { @@ -1194,21 +1232,18 @@ namespace CalamityMod.CalPlayer } if (titanHeartMask) { - target.AddBuff(BuffType(), 120); + target.AddBuff(BuffType(), TitanHeartMask.OnHitDebuffDuration); } } - if (summon) + if (summon && !whip) { - if (pSoulArtifact && !profanedCrystal) + if (profanedCrystal && DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs) + target.AddBuff(BuffType(), 600); + else if (pSoulArtifact) target.AddBuff(BuffType(), 300); - if (profanedCrystal && (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs)) - { - target.AddBuff(BuffType(), 600); - } - if (divineBless) - target.AddBuff(BuffType(), 60); + target.AddBuff(BuffType(), AngelicAlliance.BanishingFireDuration); if (shadowMinions) target.AddBuff(BuffID.ShadowFlame, 180); @@ -1229,23 +1264,25 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffType(), 180); } } - if (voidOfExtinction) - CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); + if (amalgam) + { + target.AddBuff(BuffID.Daybreak, 120); + target.AddBuff(BuffType(), 120); + target.AddBuff(BuffType(), 120); + target.AddBuff(BuffType(), 120); + target.AddBuff(BuffType(), 120); + } if (frostFlare) CalamityUtils.Inflict246DebuffsNPC(target, BuffID.Frostburn2); if (omegaBlueChestplate) target.AddBuff(BuffType(), 180); if (sulphurSet) - target.AddBuff(BuffID.Poisoned, 60); - if (ilSpark && Player.IsUnderwater()) + target.AddBuff(BuffID.Poisoned, SulphurousHelmet.SetBonusPoisonDuration); + if (ilSpark && Player.Calamity().countsAsAnyWet) { int duration = 60; target.AddBuff(BuffType(), duration); } - if (lumenousAmulet) - { - CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); - } if (corrosiveSpine) { target.AddBuff(BuffType(), 120); @@ -1256,12 +1293,11 @@ namespace CalamityMod.CalPlayer } if (vexation) { - if ((Player.armor[0].type == ItemType() || Player.armor[0].type == ItemType() || - Player.armor[0].type == ItemType()) && Player.armor[1].type == ItemType() && - Player.armor[2].type == ItemType()) - { - target.AddBuff(BuffID.Venom, 120, false); - } + target.AddBuff(BuffID.Venom, 120, false); + } + if (snowRuffianSet && ranged && crit) + { + target.AddBuff(BuffID.Frostburn, SnowRuffianMask.SetBonusFrostburnDuration, false); } } #endregion @@ -1270,140 +1306,56 @@ namespace CalamityMod.CalPlayer public void ProjLifesteal(NPC target, Projectile proj, int damage, bool crit) { CalamityGlobalProjectile modProj = proj.Calamity(); - - if (bloodflareSet && !target.IsAnEnemy(false) && !Player.moonLeech && target.lifeMax > 5) + if (target.IsAnEnemy(false)) { - if ((target.life < target.lifeMax * 0.5) && bloodflareHeartTimer <= 0) + if (bloodflareSet && !Player.moonLeech) { - bloodflareHeartTimer = 300; - Item.NewItem(target.GetSource_Loot(), target.Hitbox, ItemID.Heart); - } - } - - if (gladiatorSword && target.IsAnEnemy(false) && target.life <= 0 && target.Calamity().gladiatorOnKill && target.lifeMax > 5) - { - float healPower = 10 * Utils.GetLerpValue(300, 0, gladiatorTimer, true); - target.Calamity().gladiatorOnKill = false; - if (healPower >= 1) - { - Projectile.NewProjectile(Player.GetSource_FromThis(), target.Center, target.velocity * 0.5f, ProjectileType(), 0, 0, -1, (int)healPower); - gladiatorTimer = 300; - } - } - - if (Main.LocalPlayer.lifeSteal > 0f && !Player.moonLeech && target.lifeMax > 5) - { - // Increases the degree to which Spectre Healing set contributes to the lifesteal cap - if (Player.ghostHeal && proj.CountsAsClass()) - { - // This doesn't use Math.Round because it doesn't in vanilla - float cooldownMult = 0.2f; - cooldownMult -= proj.numHits * 0.05f; - if (cooldownMult < 0f) - cooldownMult = 0f; - - float cooldown = damage * cooldownMult; - Main.LocalPlayer.lifeSteal -= cooldown; + if ((target.life < target.lifeMax * 0.5) && bloodflareHeartTimer <= 0) + { + bloodflareHeartTimer = 300; + Item.NewItem(target.GetSource_Loot(), target.Hitbox, ItemID.Heart); + } } - if (vampiricTalisman && proj.CountsAsClass() && crit) + if (gladiatorSword && target.life <= 0 && target.Calamity().gladiatorOnKill) { - int heal = (int)Math.Round(damage * 0.015); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (CalamityGlobalProjectile.CanSpawnLifeStealProjectile(1f, heal)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange, BalancingConstants.LifeStealAccessoryCooldownMultiplier); + float healPower = 10 * Utils.GetLerpValue(300, 0, gladiatorTimer, true); + target.Calamity().gladiatorOnKill = false; + if (healPower >= 1) + { + Projectile.NewProjectile(Player.GetSource_OnHit(target), target.Center, target.velocity * 0.5f, ProjectileType(), 0, 0, -1, (int)healPower); + gladiatorTimer = 300; + } } - if (bloodyGlove && proj.CountsAsClass() && modProj.stealthStrike) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, 2, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange, BalancingConstants.LifeStealAccessoryCooldownMultiplier); - - if (target.IsAnEnemy(false)) + if (vampiricTalisman && proj.CountsAsClass() && crit && proj.numHits <1) { - if (bloodflareThrowing && proj.CountsAsClass() && crit) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, 2, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange, BalancingConstants.LifeStealSetBonusCooldownMultiplier); + int heal = (int)Math.Round(damage * 0.008); + if (heal > 2) + heal = 2; - if (bloodflareMelee && proj.IsTrueMelee()) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, 2, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange, BalancingConstants.LifeStealSetBonusCooldownMultiplier); + Player.SpawnLifeStealProjectile(target, proj, ProjectileID.VampireHeal, heal, (raiderCritLifespan > 0 && !proj.Calamity().stealthStrike) ? 1.3f : 1.6f); } - if (proj.CountsAsClass() && Player.ActiveItem().CountsAsClass()) + if (bloodyGlove && proj.CountsAsClass() && modProj.stealthStrike && proj.numHits < 1) + //Nanotech has the same heal as Electrician's glove + Player.SpawnLifeStealProjectile(target, proj, ProjectileID.VampireHeal, electricianGlove ? 10 : 5, 2f); + + if (bloodflareThrowing && proj.CountsAsClass() && crit) + Player.SpawnLifeStealProjectile(target, proj, ProjectileID.VampireHeal, 2, 1.5f); + + if (proj.CountsAsClass() && Player.HeldItem.CountsAsClass()) { if (manaOverloader) { - double healMult = 0.2; - healMult -= proj.numHits * healMult * 0.25; - int heal = (int)Math.Round(damage * healMult * (Player.statMana / (double)Player.statManaMax2)); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (CalamityGlobalProjectile.CanSpawnLifeStealProjectile(healMult, heal)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, heal, ProjectileType(), BalancingConstants.LifeStealRange, BalancingConstants.LifeStealAccessoryCooldownMultiplier); + double healMult = 0.1D - proj.numHits * 0.025D; + Player.SpawnLifeStealProjectile(target, proj, ProjectileType(), (int)Math.Round(damage * healMult), 1.5f); } - } - if (silvaSet) - { - double healMult = 0.1; - healMult -= proj.numHits * healMult * 0.5; - int heal = (int)Math.Round(damage * healMult); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (CalamityGlobalProjectile.CanSpawnLifeStealProjectile(healMult, heal)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, heal, ProjectileType(), BalancingConstants.LifeStealRange, BalancingConstants.LifeStealSetBonusCooldownMultiplier); - } - else if (proj.CountsAsClass() && Player.ActiveItem().CountsAsClass()) - { - if (tarraMage) + if (ataxiaMage) { - double healMult = 0.1; - healMult -= proj.numHits * healMult * 0.5; - int heal = (int)Math.Round(damage * healMult); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (CalamityGlobalProjectile.CanSpawnLifeStealProjectile(healMult, heal)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, heal, ProjectileType(), BalancingConstants.LifeStealRange, BalancingConstants.LifeStealSetBonusCooldownMultiplier); - } - else if (ataxiaMage) - { - double healMult = 0.1; - healMult -= proj.numHits * healMult * 0.5; - int heal = (int)Math.Round(damage * healMult); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (CalamityGlobalProjectile.CanSpawnLifeStealProjectile(healMult, heal)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, heal, ProjectileType(), BalancingConstants.LifeStealRange, BalancingConstants.LifeStealSetBonusCooldownMultiplier); - } - } - - if (reaverDefense) - { - double healMult = 0.1; - healMult -= proj.numHits * healMult * 0.5; - int heal = (int)Math.Round(damage * healMult); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (CalamityGlobalProjectile.CanSpawnLifeStealProjectile(healMult, heal)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, heal, ProjectileType(), BalancingConstants.LifeStealRange, BalancingConstants.LifeStealReaverTankCooldownMultiplier); - } - - if (proj.CountsAsClass()) - { - if (xerocSet && xerocDmg <= 0 && Player.ownedProjectileCounts[ProjectileType()] < 3 && Player.ownedProjectileCounts[ProjectileType()] < 3) - { - double healMult = 0.1; - healMult -= proj.numHits * healMult * 0.5; - int heal = (int)Math.Round(damage * healMult); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (CalamityGlobalProjectile.CanSpawnLifeStealProjectile(healMult, heal)) - CalamityGlobalProjectile.SpawnLifeStealProjectile(proj, Player, heal, ProjectileType(), BalancingConstants.LifeStealRange, BalancingConstants.LifeStealSetBonusCooldownMultiplier); + double healMult = HydrothermicHeadMagic.OrbHealingRatio - proj.numHits * HydrothermicHeadMagic.OrbHealingRatioLossPerPierce; + Player.SpawnLifeStealProjectile(target, proj, ProjectileType(), (int)Math.Round(damage * healMult), HydrothermicHeadMagic.OrbHealingCooldownMult); } } } @@ -1411,89 +1363,25 @@ namespace CalamityMod.CalPlayer public void ItemLifesteal(NPC target, Item item, int damage) { - if (bloodflareSet && target.IsAnEnemy(false) && target.lifeMax > 5) + if (target.IsAnEnemy(false)) { - if ((target.life < target.lifeMax * 0.5) && bloodflareHeartTimer <= 0) + if (bloodflareSet) { - bloodflareHeartTimer = 300; - Item.NewItem(target.GetSource_Loot(), target.Hitbox, ItemID.Heart); - } - } - - if (bloodflareMelee && item.CountsAsClass() && target.lifeMax > 5) - { - if (target.IsAnEnemy(false) && Main.LocalPlayer.lifeSteal > 0f && !Player.moonLeech) - { - int heal = 4; - if (!Main.LocalPlayer.moonLeech) + if ((target.life < target.lifeMax * 0.5) && bloodflareHeartTimer <= 0) { - Main.LocalPlayer.lifeSteal -= heal * BalancingConstants.LifeStealSetBonusCooldownMultiplier; - - float lowestHealthCheck = 0f; - int healTarget = Player.whoAmI; - foreach (Player otherPlayer in Main.ActivePlayers) - { - 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 = otherPlayer.whoAmI; - } - } - } - - // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list - var source = Player.GetSource_FromThis(ReaverHeadTank.HealOrbEntitySourceContext); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ProjectileID.VampireHeal, 0, 0f, Player.whoAmI, healTarget, heal); + bloodflareHeartTimer = 300; + Item.NewItem(target.GetSource_Loot(), target.Hitbox, ItemID.Heart); } } - } - if (gladiatorSword && target.IsAnEnemy(false) && target.life <= 0 && target.Calamity().gladiatorOnKill && target.lifeMax > 5) - { - float healPower = 10 * Utils.GetLerpValue(300, 0, gladiatorTimer, true); - target.Calamity().gladiatorOnKill = false; - if (healPower >= 1) + if (gladiatorSword && target.life <= 0 && target.Calamity().gladiatorOnKill) { - Projectile.NewProjectile(Player.GetSource_FromThis(), target.Center, target.velocity * 0.5f, ProjectileType(), 0, 0, -1, (int)healPower); - gladiatorTimer = 300; - } - } - - if (reaverDefense) - { - if (Main.LocalPlayer.lifeSteal > 0f && !Player.moonLeech && target.lifeMax > 5) - { - double healMult = 0.1; - int heal = (int)Math.Round(damage * healMult); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (heal > 0 && !Main.LocalPlayer.moonLeech) + float healPower = 10 * Utils.GetLerpValue(300, 0, gladiatorTimer, true); + target.Calamity().gladiatorOnKill = false; + if (healPower >= 1) { - Main.LocalPlayer.lifeSteal -= heal * BalancingConstants.LifeStealReaverTankCooldownMultiplier; - - float lowestHealthCheck = 0f; - int healTarget = Player.whoAmI; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player otherPlayer = Main.player[i]; - if (otherPlayer.active && !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 = otherPlayer.whoAmI; - } - } - } - - // https://github.com/tModLoader/tModLoader/wiki/IEntitySource#detailed-list - var source = Player.GetSource_FromThis(ReaverHeadTank.HealOrbEntitySourceContext); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ProjectileType(), 0, 0f, Player.whoAmI, healTarget, heal); + Projectile.NewProjectile(Player.GetSource_OnHit(target), target.Center, target.velocity * 0.5f, ProjectileType(), 0, 0, -1, (int)healPower); + gladiatorTimer = 300; } } } @@ -1531,7 +1419,7 @@ namespace CalamityMod.CalPlayer Vector2 velocity = Main.npc[targetIdx].DirectionFrom(spawnPos); velocity *= speed; - var source = player.GetSource_ItemUse(player.ActiveItem()); + var source = player.GetSource_ItemUse(player.HeldItem); int projectile = Projectile.NewProjectile(source, spawnPos, velocity, type, damage, knockback, player.whoAmI, targetIdx, 0f); Main.projectile[projectile].extraUpdates += extraUpdateAmt; } diff --git a/CalPlayer/Dashes/AsgardianAegisDash.cs b/CalPlayer/Dashes/AsgardianAegisDash.cs index e3797e4f2d..4549748e7a 100644 --- a/CalPlayer/Dashes/AsgardianAegisDash.cs +++ b/CalPlayer/Dashes/AsgardianAegisDash.cs @@ -8,19 +8,25 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Graphics.Shaders; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.CalPlayer.Dashes { public class AsgardianAegisDash : PlayerDashEffect { - public static new string ID => "Asgardian Aegis"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.ShieldSlam; public override bool IsOmnidirectional => false; public int Time = 0; public bool PostHit = false; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 23.3f; public override void OnDashEffects(Player player) @@ -29,26 +35,39 @@ namespace CalamityMod.CalPlayer.Dashes PostHit = false; } + public override void DashStartupEffects(Player player) + { + player.velocity *= 0.9f; + } + public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { Time += 2; float radiusFactor = MathHelper.Lerp(0f, 1f, Utils.GetLerpValue(2f, 2.5f, Time, true)); - for (int i = 0; i < 3; i++) + if (DashTimeAdjustedForStartup <= 18) { - float offsetRotationAngle = player.velocity.ToRotation() + Time / 5f; - float radius = (15f + (float)Math.Cos(Time / 3f) * 12f) * radiusFactor; - Vector2 dustPosition = player.Center - player.velocity * 2; - dustPosition += offsetRotationAngle.ToRotationVector2().RotatedBy(i / 5f * MathHelper.TwoPi) * radius; - Dust dust = Dust.NewDustPerfect(dustPosition, Main.rand.NextBool(5) ? 181 : 295); - dust.alpha = 220; - dust.noGravity = true; - dust.velocity = player.velocity * 0.8f; - dust.scale = Main.rand.NextFloat(1.7f, 2.0f); - dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); - Dust dust2 = Dust.NewDustPerfect(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) + (player.velocity * 1.5f), Main.rand.NextBool(8) ? 180 : 295, -player.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.7f, 1.9f)); - dust2.alpha = 170; - dust2.noGravity = true; - dust2.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + for (int d = 0; d < 2; d++) + { + Dust hFlameDust = Dust.NewDustPerfect(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.2f), Main.rand.NextBool(8) ? 180 : 295, -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.8f, 2.8f)); + hFlameDust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + hFlameDust.noGravity = hFlameDust.type == 180 ? false : true; + hFlameDust.fadeIn = 0.5f; + if (hFlameDust.type == 180) + { + hFlameDust.scale = Main.rand.NextFloat(0.8f, 1.2f); + hFlameDust.velocity += new Vector2(0, -2.5f) * Main.rand.NextFloat(0.8f, 1.2f); + } + + Dust dust = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Circular(6, 6) - player.velocity * 2, DustID.FrostStaff); + dust.velocity = -player.velocity * Main.rand.NextFloat(0.6f, 1.4f); + dust.scale = Main.rand.NextFloat(0.9f, 1.4f); + dust.noGravity = true; + if (d < 1) + { + Particle spark = new CustomSpark(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.2f), -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 17, Main.rand.NextFloat(1.15f, 1.25f), Main.rand.NextBool() ? Color.Fuchsia : Color.Cyan, new Vector2(1.3f, 0.5f), true, false, 0, false, false, Main.rand.NextFloat(0.4f, 0.5f)); + GeneralParticleHandler.SpawnParticle(spark); + } + } } // Dash at a faster speed than the default value. @@ -57,9 +76,11 @@ namespace CalamityMod.CalPlayer.Dashes public override void OnHitEffects(Player player, NPC npc, IEntitySource source, ref DashHitContext hitContext) { + if (DashTimeAdjustedForStartup > 18) + return; if (!PostHit) { - player.Calamity().GeneralScreenShakePower = 5f; + player.SetScreenshake(5f); PostHit = true; } diff --git a/CalPlayer/Dashes/AsgardsValorDash.cs b/CalPlayer/Dashes/AsgardsValorDash.cs index 34262feeae..eab4578223 100644 --- a/CalPlayer/Dashes/AsgardsValorDash.cs +++ b/CalPlayer/Dashes/AsgardsValorDash.cs @@ -1,9 +1,6 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Enums; using CalamityMod.Items.Accessories; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -16,43 +13,52 @@ namespace CalamityMod.CalPlayer.Dashes { public class AsgardsValorDash : PlayerDashEffect { - public static new string ID => "Asgard's Valor"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.ShieldSlam; public override bool IsOmnidirectional => false; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 16.9f; - public override void OnDashEffects(Player player) + public override void DashStartupEffects(Player player) { - // Nothing + player.velocity *= 0.9f; } public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { + + // Dash at a faster speed than the default value. + dashSpeed = 12.5f; // Spawn fire dust around the player's body. - for (int d = 0; d < 4; d++) + if (DashTimeAdjustedForStartup > 14) + return; + for (int d = 0; d < 3; d++) { Dust holyFireDashDust = Dust.NewDustDirect(player.position + Vector2.UnitY * 4f, player.width, player.height - 8, Main.rand.NextBool() ? 296 : 158, 0f, 0f, 0, default, 1.2f); holyFireDashDust.velocity = -player.velocity * Main.rand.NextFloat(0.1f, 0.75f); - holyFireDashDust.scale *= Main.rand.NextFloat(1f, 1.2f); + holyFireDashDust.scale *= Main.rand.NextFloat(2f, 2.4f); holyFireDashDust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); holyFireDashDust.noGravity = true; if (Main.rand.NextBool()) holyFireDashDust.fadeIn = 0.1f; } - if (Main.rand.NextBool(3)) - { - Vector2 dustPosition = player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.7f); - Dust dust = Dust.NewDustPerfect(dustPosition, 222, -player.velocity * Main.rand.NextFloat(0.15f, 0.4f), 0, default, 0.5f); - dust.noGravity = false; - dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); - } + Vector2 dustPosition = player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.7f); + Dust dust = Dust.NewDustPerfect(dustPosition, DustID.FireworkFountain_Yellow, -player.velocity * Main.rand.NextFloat(0.15f, 0.4f), 0, default, 0.5f); + dust.noGravity = false; + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); } public override void OnHitEffects(Player player, NPC npc, IEntitySource source, ref DashHitContext hitContext) { + if (DashTimeAdjustedForStartup > 14) + return; // Define hit context variables. int hitDirection = player.direction; if (player.velocity.X != 0f) @@ -71,16 +77,16 @@ namespace CalamityMod.CalPlayer.Dashes for (int k = 0; k < Dusts; k++) { Vector2 velocity = spinningPoint.RotatedBy(radians * k); - Dust dust = Dust.NewDustPerfect(npc.Center, 296, velocity * 3f, 0, default, 2.5f); + Dust dust = Dust.NewDustPerfect(npc.Center, DustID.CrimsonTorch, velocity * 3f, 0, default, 2.5f); dust.noGravity = true; dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); - Dust dust2 = Dust.NewDustPerfect(npc.Center, 158, velocity * 5f, 0, default, 2.2f); + Dust dust2 = Dust.NewDustPerfect(npc.Center, DustID.OrangeTorch, velocity * 5f, 0, default, 2.2f); dust2.noGravity = true; dust2.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); dust2.color = Color.Salmon; - Dust dust3 = Dust.NewDustPerfect(npc.Center, 169, velocity * 7f, 0, default, 1.9f); + Dust dust3 = Dust.NewDustPerfect(npc.Center, DustID.IchorTorch, velocity * 7f, 0, default, 1.9f); dust3.noGravity = true; dust3.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); dust3.color = Color.SandyBrown; @@ -88,7 +94,7 @@ namespace CalamityMod.CalPlayer.Dashes } for (int k = 0; k < 5; k++) { - Dust dust = Dust.NewDustPerfect(npc.Center, 222, new Vector2(0, -3.5f).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.8f, 1.4f), 0, default, 1.2f); + Dust dust = Dust.NewDustPerfect(npc.Center, DustID.FireworkFountain_Yellow, new Vector2(0, -3.5f).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.8f, 1.4f), 0, default, 1.2f); dust.noGravity = false; dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); } diff --git a/CalPlayer/Dashes/CounterScarfDash.cs b/CalPlayer/Dashes/CounterScarfDash.cs index ad2f8027e2..95506c0ed7 100644 --- a/CalPlayer/Dashes/CounterScarfDash.cs +++ b/CalPlayer/Dashes/CounterScarfDash.cs @@ -8,13 +8,18 @@ namespace CalamityMod.CalPlayer.Dashes { public class CounterScarfDash : PlayerDashEffect { - public static new string ID => "Counter Scarf"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.NoCollision; public override bool IsOmnidirectional => false; - public override float CalculateDashSpeed(Player player) => player.Calamity().evasionScarf ? 16.3f : 15f; + public override void Load() + { + ID = DashID; + } + + public override float CalculateDashSpeed(Player player) => player.Calamity().evasionScarf ? 19f : 15f; public override void OnDashEffects(Player player) { diff --git a/CalPlayer/Dashes/DeepDiverDash.cs b/CalPlayer/Dashes/DeepDiverDash.cs index d28627ac48..09ebe45eed 100644 --- a/CalPlayer/Dashes/DeepDiverDash.cs +++ b/CalPlayer/Dashes/DeepDiverDash.cs @@ -1,25 +1,29 @@ using System; using CalamityMod.Enums; using CalamityMod.Items.Accessories; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Particles; -using Terraria.Audio; namespace CalamityMod.CalPlayer.Dashes { public class DeepDiverDash : PlayerDashEffect { - public static new string ID => "Deep Diver"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.ShieldSlam; public override bool IsOmnidirectional => false; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 20f; public int Time = 0; diff --git a/CalPlayer/Dashes/DefaultDash.cs b/CalPlayer/Dashes/DefaultDash.cs index 8194e287a5..0d51f35746 100644 --- a/CalPlayer/Dashes/DefaultDash.cs +++ b/CalPlayer/Dashes/DefaultDash.cs @@ -6,12 +6,17 @@ namespace CalamityMod.CalPlayer.Dashes { public class DefaultDash : PlayerDashEffect { - public static new string ID => "Default Dash"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.NoCollision; public override bool IsOmnidirectional => false; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 1f; public override void OnHitEffects(Player player, NPC npc, IEntitySource source, ref DashHitContext hitContext) diff --git a/CalPlayer/Dashes/ElysianAegisDash.cs b/CalPlayer/Dashes/ElysianAegisDash.cs index 8ff41a5806..f8b25eaeaf 100644 --- a/CalPlayer/Dashes/ElysianAegisDash.cs +++ b/CalPlayer/Dashes/ElysianAegisDash.cs @@ -8,18 +8,25 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Graphics.Shaders; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.CalPlayer.Dashes { public class ElysianAegisDash : PlayerDashEffect { - public static new string ID => "Elysian Aegis"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.ShieldSlam; public override bool IsOmnidirectional => false; public bool PostHit = false; + + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 21.5f; public override void OnDashEffects(Player player) @@ -27,41 +34,50 @@ namespace CalamityMod.CalPlayer.Dashes PostHit = false; } + public override void DashStartupEffects(Player player) + { + player.velocity *= 0.9f; + } + public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { - for (int d = 0; d < 4; d++) - { - Dust hFlameDust = Dust.NewDustPerfect(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.2f), Main.rand.NextBool(8) ? 222 : 162, -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.8f, 2.8f)); - hFlameDust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); - hFlameDust.noGravity = hFlameDust.type == 222 ? false : true; - hFlameDust.fadeIn = 0.5f; - if (hFlameDust.type == 222) - { - hFlameDust.scale = Main.rand.NextFloat(0.8f, 1.2f); - hFlameDust.velocity += new Vector2(0, -2.5f) * Main.rand.NextFloat(0.8f, 1.2f); - } - if (hFlameDust.type == 180) - hFlameDust.scale = Main.rand.NextFloat(1.6f, 2.2f); - Dust dust = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Circular(6, 6) - player.velocity * 2, 228); - dust.velocity = -player.velocity * Main.rand.NextFloat(0.6f, 1.4f); - dust.scale = Main.rand.NextFloat(0.9f, 1.4f); - dust.noGravity = true; - if (d < 1) + if (DashTimeAdjustedForStartup <= 16) + for (int d = 0; d < 4; d++) { - Particle spark = new CustomSpark(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.2f), -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 17, Main.rand.NextFloat(1.15f, 1.25f), Main.rand.NextBool(4) ? Color.Khaki : Color.Orange, new Vector2(1.3f, 0.5f), true, false, 0, false, false, Main.rand.NextFloat(0.4f, 0.5f)); - GeneralParticleHandler.SpawnParticle(spark); + Dust hFlameDust = Dust.NewDustPerfect(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.2f), Main.rand.NextBool(8) ? 222 : 162, -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.8f, 2.8f)); + hFlameDust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + hFlameDust.noGravity = hFlameDust.type == 222 ? false : true; + hFlameDust.fadeIn = 0.5f; + if (hFlameDust.type == 222) + { + hFlameDust.scale = Main.rand.NextFloat(0.8f, 1.2f); + hFlameDust.velocity += new Vector2(0, -2.5f) * Main.rand.NextFloat(0.8f, 1.2f); + } + if (hFlameDust.type == 180) + hFlameDust.scale = Main.rand.NextFloat(1.6f, 2.2f); + + Dust dust = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Circular(6, 6) - player.velocity * 2, DustID.GoldFlame); + dust.velocity = -player.velocity * Main.rand.NextFloat(0.6f, 1.4f); + dust.scale = Main.rand.NextFloat(0.9f, 1.4f); + dust.noGravity = true; + if (d < 1) + { + Particle spark = new CustomSpark(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.2f), -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 17, Main.rand.NextFloat(1.15f, 1.25f), Main.rand.NextBool(4) ? Color.Khaki : Color.Orange, new Vector2(1.3f, 0.5f), true, false, 0, false, false, Main.rand.NextFloat(0.4f, 0.5f)); + GeneralParticleHandler.SpawnParticle(spark); + } } - } // Dash at a faster speed than the default value. dashSpeed = 14f; } public override void OnHitEffects(Player player, NPC npc, IEntitySource source, ref DashHitContext hitContext) { + if (DashTimeAdjustedForStartup > 16) + return; if (!PostHit) { - player.Calamity().GeneralScreenShakePower = 3.5f; + player.SetScreenshake(3.5f); PostHit = true; } float particleScale = Main.rand.NextFloat(0.45f, 0.55f); diff --git a/CalPlayer/Dashes/GodslayerArmorDash.cs b/CalPlayer/Dashes/GodslayerArmorDash.cs index 5452bc59ae..eb9c5f921a 100644 --- a/CalPlayer/Dashes/GodslayerArmorDash.cs +++ b/CalPlayer/Dashes/GodslayerArmorDash.cs @@ -10,15 +10,14 @@ using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.CalPlayer.Dashes { public class GodslayerArmorDash : PlayerDashEffect { - public static new string ID => "Godslayer Armor"; - - public static int GodslayerCooldown = 45; + public static new string ID { get; private set; } public SlotId GSDashSlot; @@ -32,7 +31,12 @@ namespace CalamityMod.CalPlayer.Dashes public float Size = 2.2f; public bool SoundOnce = true; - public override float CalculateDashSpeed(Player player) => 40f; + public override void Load() + { + ID = DashID; + } + + public override float CalculateDashSpeed(Player player) => 32f; public override void OnDashEffects(Player player) { @@ -46,7 +50,7 @@ namespace CalamityMod.CalPlayer.Dashes for (int i = 0; i <= 15; i++) { - Dust dust = Dust.NewDustPerfect(player.position, 181, -player.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(3.1f, 3.9f)); + Dust dust = Dust.NewDustPerfect(player.position, DustID.GiantCursedSkullBolt, -player.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(3.1f, 3.9f)); dust.noGravity = false; } } @@ -59,14 +63,21 @@ namespace CalamityMod.CalPlayer.Dashes Time++; Size -= 0.01f; + const int totalDashTime = 75; + // Constantly update the player's velocity direction. + float progress = MathHelper.Clamp(Time / (float)totalDashTime, 0f, 1f); + float ease = 1f - (float)Math.Pow(1f - progress, 0.2f); + float finalSpeed = MathHelper.Lerp(32f, 11f, ease); + Vector2 dashVel = Main.MouseWorld - player.Center; - dashVel = dashVel.SafeNormalize(Vector2.UnitX) * CalculateDashSpeed(player); - player.velocity = dashVel; + Vector2 targetDirection = player.velocity.ToRotation().AngleTowards(dashVel.ToRotation(), 0.175f).ToRotationVector2(); + player.velocity = targetDirection * finalSpeed; // Fall way, way, faster than usual. player.maxFallSpeed = 50f; - if (Time < 115) + + if (Time < 75) { Particle jaws = new Jaws(player.Center + player.velocity * 0.5f, player.velocity, Color.Fuchsia, new Vector2(0.8f, 1f), player.velocity.ToRotation() + MathHelper.PiOver2, Size, Size, 2); GeneralParticleHandler.SpawnParticle(jaws); @@ -100,21 +111,22 @@ namespace CalamityMod.CalPlayer.Dashes GeneralParticleHandler.SpawnParticle(spark2); } - if (Time > 115 && Time < 200) + if (Time > 75 && Time < 78) { Particle pulse = new DirectionalPulseRing(player.Center - player.velocity * 0.52f, player.velocity / 1.5f, Color.Fuchsia, new Vector2(1f, 2f), player.velocity.ToRotation(), 0.82f, 0.32f, 60); GeneralParticleHandler.SpawnParticle(pulse); Particle pulse2 = new DirectionalPulseRing(player.Center - player.velocity * 0.40f, player.velocity / 1.5f * 0.9f, Color.Aqua, new Vector2(0.8f, 1.5f), player.velocity.ToRotation(), 0.58f, 0.28f, 50); GeneralParticleHandler.SpawnParticle(pulse2); - Time = 222; + + Time = 95; } // Dash at a much, much faster speed than the default value. - dashSpeed = 40f; + dashSpeed = finalSpeed; runSpeedDecelerationFactor = 0.8f; // Cooldown for God Slayer Armor dash. - player.AddCooldown(Cooldowns.GodSlayerDash.ID, CalamityUtils.SecondsToFrames(GodslayerCooldown)); + player.AddCooldown(Cooldowns.GodSlayerDash.ID, GodSlayerChestplate.DashCooldown); player.Calamity().godSlayerDashHotKeyPressed = false; } @@ -141,14 +153,14 @@ namespace CalamityMod.CalPlayer.Dashes // Define damage parameters. hitContext.damageClass = player.GetBestClass(); - hitContext.BaseDamage = 3000; - hitContext.BaseKnockback = 15f; + hitContext.BaseDamage = GodSlayerChestplate.DashDamage; + hitContext.BaseKnockback = GodSlayerChestplate.DashKnockback; // God Slayer Dash intentionally does not use the vanilla function for collision attack iframes. // This is because its immunity is meant to be completely consistent and not subject to vanilla anticheese. hitContext.PlayerImmunityFrames = GodSlayerChestplate.DashIFrames; - npc.AddBuff(ModContent.BuffType(), 300); + npc.AddBuff(ModContent.BuffType(), GodSlayerChestplate.DashGodSlayerInfernoDuration); } } } diff --git a/CalPlayer/Dashes/OrnateShieldDash.cs b/CalPlayer/Dashes/OrnateShieldDash.cs index 9c94df600a..255ea849fe 100644 --- a/CalPlayer/Dashes/OrnateShieldDash.cs +++ b/CalPlayer/Dashes/OrnateShieldDash.cs @@ -12,30 +12,36 @@ namespace CalamityMod.CalPlayer.Dashes { public class OrnateShieldDash : PlayerDashEffect { - public static new string ID => "Ornate Shield"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.ShieldSlam; public override bool IsOmnidirectional => false; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 16.9f; - public override void OnDashEffects(Player player) + public override void DashStartupEffects(Player player) { - //nothing left, could add a sound or other effect if we want later + player.velocity *= 0.9f; } public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { - for (int d = 0; d < 3; d++) - { - Dust iceDashDust = Dust.NewDustPerfect(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.7f), Main.rand.NextBool(8) ? 223 : 180, -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 0.8f)); - iceDashDust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); - iceDashDust.noGravity = true; - iceDashDust.fadeIn = 0.5f; - if (iceDashDust.type == 180) - iceDashDust.scale = Main.rand.NextFloat(1.6f, 2.2f); - } + if (DashTimeAdjustedForStartup <= 12) + for (int d = 0; d < 3; d++) + { + Dust iceDashDust = Dust.NewDustPerfect(player.Center + new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-15f, 15f)) - (player.velocity * 1.7f), Main.rand.NextBool(8) ? 223 : 180, -player.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 0.8f)); + iceDashDust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + iceDashDust.noGravity = true; + iceDashDust.fadeIn = 0.5f; + if (iceDashDust.type == 180) + iceDashDust.scale = Main.rand.NextFloat(1.6f, 2.2f); + } // Dash at a faster speed than the default value. dashSpeed = 12.5f; @@ -43,6 +49,8 @@ namespace CalamityMod.CalPlayer.Dashes public override void OnHitEffects(Player player, NPC npc, IEntitySource source, ref DashHitContext hitContext) { + if (DashTimeAdjustedForStartup > 12) + return; // Define hit context variables. int hitDirection = player.direction; if (player.velocity.X != 0f) diff --git a/CalPlayer/Dashes/PlaguebringerArmorDash.cs b/CalPlayer/Dashes/PlaguebringerArmorDash.cs index df2248ff57..5b9bc2bdf9 100644 --- a/CalPlayer/Dashes/PlaguebringerArmorDash.cs +++ b/CalPlayer/Dashes/PlaguebringerArmorDash.cs @@ -1,6 +1,6 @@ using System; using CalamityMod.Enums; -using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor.Plaguebringer; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -12,12 +12,17 @@ namespace CalamityMod.CalPlayer.Dashes { public class PlaguebringerArmorDash : PlayerDashEffect { - public static new string ID => "Plaguebringer Armor"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.NoCollision; public override bool IsOmnidirectional => false; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 19f; public override void OnDashEffects(Player player) @@ -61,12 +66,12 @@ namespace CalamityMod.CalPlayer.Dashes if (player.velocity.X != 0f) hitDirection = Math.Sign(player.velocity.X); hitContext.HitDirection = hitDirection; - hitContext.PlayerImmunityFrames = AsgardsValor.ShieldSlamIFrames; + hitContext.PlayerImmunityFrames = PlaguebringerVisor.PlagueDashIFrames; // Define damage parameters. hitContext.damageClass = DamageClass.Summon; - hitContext.BaseDamage = 50; - hitContext.BaseKnockback = 3f; + hitContext.BaseDamage = PlaguebringerVisor.PlagueDashDamage; + hitContext.BaseKnockback = PlaguebringerVisor.PlagueDashKnockback; } } } diff --git a/CalPlayer/Dashes/PlayerDashEffect.cs b/CalPlayer/Dashes/PlayerDashEffect.cs index 4ea5d0a336..30e515cd7f 100644 --- a/CalPlayer/Dashes/PlayerDashEffect.cs +++ b/CalPlayer/Dashes/PlayerDashEffect.cs @@ -1,25 +1,53 @@ using CalamityMod.Enums; using Terraria; using Terraria.DataStructures; +using Terraria.ModLoader; namespace CalamityMod.CalPlayer.Dashes { - public abstract class PlayerDashEffect + public abstract class PlayerDashEffect : ModType { // For the sake of easy access without the need for stored instances, this property is defined as static instead of abstract. // Derived classes should use the new keyword on this member to define their own version of it. public static string ID { get; } + public int dashTime { get; set; } + public virtual int dashStartup => 0; + public virtual string DashID => field ??= FullName; + + public int DashTimeAdjustedForStartup => dashTime - dashStartup; public abstract DashCollisionType CollisionType { get; } public abstract bool IsOmnidirectional { get; } public abstract float CalculateDashSpeed(Player player); - + /// + /// Effects that happen once when the main dash starts + /// + /// public virtual void OnDashEffects(Player player) { } + /// + /// Effects that happen once when the dash startup starts + /// This does not run on dashes without set startup + /// + /// + + public virtual void OnDashStartupEffects(Player player) { } + /// + /// Effects that run during the dash startup time + /// This does not run on dashes without set startup + /// + /// + public virtual void DashStartupEffects(Player player) { } public virtual void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { } public virtual void OnHitEffects(Player player, NPC npc, IEntitySource source, ref DashHitContext hitContext) { } + + protected sealed override void Register() + { + ModTypeLookup.Register(this); + PlayerDashManager.DashIdentificationTable[DashID] = this; + } } } diff --git a/CalPlayer/Dashes/PlayerDashManager.cs b/CalPlayer/Dashes/PlayerDashManager.cs index 38fa36d109..20206a2abf 100644 --- a/CalPlayer/Dashes/PlayerDashManager.cs +++ b/CalPlayer/Dashes/PlayerDashManager.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using Terraria; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod.CalPlayer.Dashes { @@ -30,7 +28,7 @@ namespace CalamityMod.CalPlayer.Dashes //PlayerDashEffect, then don't add the dash and stop the method. if (DashIdentificationTable == null || dashEffect.GetType().IsAbstract) return; - string id = (string)dashEffect.GetType().GetProperty("ID").GetValue(null); + string id = dashEffect.DashID; //This chunk of the code only executes if the dash isn't already added and //the dash id isn't empty. @@ -38,22 +36,8 @@ namespace CalamityMod.CalPlayer.Dashes { DashIdentificationTable[id] = dashEffect; } - } - public override void OnModLoad() - { - DashIdentificationTable = new(); - ReflectionHelper.IterateCalamityTypes(action: type => - { - string id = (string)type.GetProperty("ID").GetValue(null); - - PlayerDashEffect dashEffect = (PlayerDashEffect)Activator.CreateInstance(type); - DashIdentificationTable[id] = dashEffect; - }); - } - - public override void Unload() { DashIdentificationTable = null; diff --git a/CalPlayer/Dashes/SpeedBlasterDash.cs b/CalPlayer/Dashes/SpeedBlasterDash.cs index 22772ab180..8a692edb69 100644 --- a/CalPlayer/Dashes/SpeedBlasterDash.cs +++ b/CalPlayer/Dashes/SpeedBlasterDash.cs @@ -11,11 +11,16 @@ namespace CalamityMod.CalPlayer.Dashes { public class SpeedBlasterDash : PlayerDashEffect { - public static new string ID => "Speed Blaster"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.NoCollision; public override bool IsOmnidirectional => true; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 30f; public override void OnDashEffects(Player player) diff --git a/CalPlayer/Dashes/StatisNinjaBeltDash.cs b/CalPlayer/Dashes/StatisNinjaBeltDash.cs index a0253e7f77..3c63a6a313 100644 --- a/CalPlayer/Dashes/StatisNinjaBeltDash.cs +++ b/CalPlayer/Dashes/StatisNinjaBeltDash.cs @@ -1,57 +1,75 @@ -using CalamityMod.Enums; +using CalamityMod.Dusts; +using CalamityMod.Enums; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.CalPlayer.Dashes { public class StatisNinjaBeltDash : PlayerDashEffect { - public static new string ID => "Statis' Ninja Belt"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.NoCollision; public override bool IsOmnidirectional => false; public int Time = 0; - public override float CalculateDashSpeed(Player player) => 20f; + public override void Load() + { + ID = DashID; + } + + public override float CalculateDashSpeed(Player player) => (48f); public override void OnDashEffects(Player player) { + Time = 0; - for (int i = 0; i < 12; i++) + for (int i = 0; i < 15; i++) { - Vector2 smokePos = player.Center + new Vector2(Main.rand.Next(-player.width, player.width), Main.rand.Next(-player.height, player.height)) * 0.8f; - Vector2 smokeVel = Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(1.25f, 1.75f); - HeavySmokeParticle onDashSmoke = new(smokePos, smokeVel, Color.Gray, 30, 0.5f, 0.75f, 0.2f * Main.rand.NextFloatDirection()); - GeneralParticleHandler.SpawnParticle(onDashSmoke); + Vector2 intenededVel = (MathHelper.TwoPi * i / 15f).ToRotationVector2() * 1.5f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(player.velocity.ToRotation()); + Vector2 fxPlace = player.Center + fxVel.RotatedBy(player.velocity.ToRotation()) + player.velocity.SafeNormalize(Vector2.UnitX) * 60; + + Color dustColor = Main.rand.NextBool() ? Color.Purple : Color.DarkSlateBlue; + + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(fxPlace, dustStyle, (fxVel - player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(4, 5)) * Main.rand.NextFloat(1.2f, 1.5f)); + dust2.scale = Main.rand.NextFloat(1.6f, 2.3f) * 1.8f; + dust2.color = dustColor; + dust2.noGravity = true; + dust2.fadeIn = 1.5f; } } public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { Time++; - if (Time % 3 == 0) + for (int i = 0; i < 2; i++) { - int colorType = Main.rand.Next(3); - Color smokeColor = Color.White; - switch (colorType) - { - case 0: - smokeColor = Color.Gray; - break; - case 1: - smokeColor = new Color(28, 75, 163); - break; - case 2: - smokeColor = new Color(195, 0, 255); - break; - } - - Vector2 smokePos = player.Center - (player.velocity * 1.25f) + Main.rand.NextVector2Circular(10, 20); - float smokeScale = player.velocity.X * 0.045f; - HeavySmokeParticle midDashSmoke = new(smokePos, player.velocity * 0.2f, smokeColor, 20, smokeScale, 0.75f, 0.2f * Main.rand.NextFloatDirection(), true); + HeavySmokeParticle midDashSmoke = new(player.Center + Main.rand.NextVector2Circular(15, 15), -player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(5, 9), Main.rand.NextBool() ? Color.Purple : Color.DarkSlateBlue, 16, Main.rand.NextFloat(0.7f, 0.9f), 0.55f, 0.2f * Main.rand.NextFloatDirection(), true); GeneralParticleHandler.SpawnParticle(midDashSmoke); } + + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Circular(15, 15), dustStyle, player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(5, 9)); + dust2.scale = Main.rand.NextFloat(0.9f, 1.7f); + dust2.color = Main.rand.NextBool() ? Color.Purple : Color.DarkSlateBlue; + dust2.noGravity = true; + dust2.fadeIn = 0.5f; + + player.velocity.X *= 0.93f; + + if (player.velocity.X > 140) + { + player.velocity.X = 140; + } + if (player.velocity.X < -140) + { + player.velocity.X = -140; + } + if (Time > 8) + player.velocity.X *= 0.5f; } } } diff --git a/CalPlayer/Dashes/StatisVoidSashDash.cs b/CalPlayer/Dashes/StatisVoidSashDash.cs index e1931be364..0f0bb87d3a 100644 --- a/CalPlayer/Dashes/StatisVoidSashDash.cs +++ b/CalPlayer/Dashes/StatisVoidSashDash.cs @@ -1,61 +1,114 @@ -using CalamityMod.Enums; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Rogue; +using System; +using CalamityMod.Dusts; +using CalamityMod.Enums; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Accessories; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.CalPlayer.Dashes { public class StatisVoidSashDash : PlayerDashEffect { - public static new string ID => "Statis' Void Sash"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.NoCollision; public override bool IsOmnidirectional => false; public int Time = 0; - public bool AngleSwap = true; + public Vector2 aimVel; + public bool strongVisuals = true; - public override float CalculateDashSpeed(Player player) => 25.4f; + public override void Load() + { + ID = DashID; + } + + public override float CalculateDashSpeed(Player player) => (64f); public override void OnDashEffects(Player player) { + + strongVisuals = player.Calamity().voidSashVisuals; Time = 0; + aimVel = player.velocity; + + if (strongVisuals) + { + SoundStyle sound = StatisVoidSash.VoidDash; + SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, player.Center); + for (int i = 0; i < 40; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / 40f).ToRotationVector2() * 3f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(player.velocity.ToRotation()); + Vector2 fxPlace = player.Center + fxVel.RotatedBy(player.velocity.ToRotation()) + player.velocity.SafeNormalize(Vector2.UnitX) * 60; + + SignusMetaball.SpawnParticle(fxPlace, fxVel - player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(6, 9), 60f * Main.rand.NextFloat(0.7f, 1), 60, new Vector2(1.8f, 0.9f), 0.06f, 0); + } + } + for (int i = 0; i < 30; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / 30f).ToRotationVector2() * 3f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2f).RotatedBy(player.velocity.ToRotation()); + Vector2 fxPlace = player.Center + fxVel.RotatedBy(player.velocity.ToRotation()) + player.velocity.SafeNormalize(Vector2.UnitX) * 60; + + Color dustColor = Main.rand.NextBool(3) ? Color.Indigo : Color.DarkOrchid; + + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(fxPlace, dustStyle, (fxVel - player.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(6, 9)) * Main.rand.NextFloat(1.2f, 1.5f)); + dust2.scale = Main.rand.NextFloat(1.6f, 2.3f) * 2.3f; + dust2.color = dustColor; + dust2.noGravity = true; + dust2.fadeIn = 1.5f; + } } public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { Time++; - if (Time % 3 == 0) - { - Vector2 trailPos = player.Center - (player.velocity * 2) + Main.rand.NextVector2Circular(10, 20); - float trailScale = player.velocity.X * player.direction * 0.08f; - Color trailColor = Main.rand.NextBool(3) ? Color.Indigo : Color.DarkOrchid; - Particle Trail = new SparkParticle(trailPos, player.velocity * 0.2f, false, 35, trailScale, trailColor); - GeneralParticleHandler.SpawnParticle(Trail); - } + aimVel = Vector2.Lerp(aimVel, player.velocity, 0.2f); - // Periodically release scythes. - player.Calamity().statisTimer++; - if (Main.myPlayer == player.whoAmI && player.Calamity().statisTimer % 5 == 0) - { - int scytheDamage = (int)player.GetBestClassDamage().ApplyTo(250); + float fxFade = Utils.GetLerpValue(5, 15, Math.Abs(aimVel.X), true); - int scythe = Projectile.NewProjectile(player.GetSource_FromAI(), player.Center, player.velocity.RotatedBy(player.direction * (AngleSwap ? 30 : -30), default) * 0.1f - player.velocity / 2f, ModContent.ProjectileType(), scytheDamage, 5f, player.whoAmI); ; - if (scythe.WithinBounds(Main.maxProjectiles)) + Vector2 trailPos = player.Center - (aimVel * 2) + Main.rand.NextVector2Circular(10, 20); + float trailScale = 1 * fxFade; + Color trailColor = Main.rand.NextBool(3) ? Color.Indigo : Color.DarkOrchid; + + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(trailPos, dustStyle, aimVel.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(9, 15)); + dust2.scale = Main.rand.NextFloat(0.9f, 1.7f); + dust2.color = trailColor; + dust2.noGravity = true; + dust2.fadeIn = 0.5f; + + if (strongVisuals) + { + SignusMetaball.SpawnParticle(player.Center + Main.rand.NextVector2Circular(20, 20), -aimVel.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(5, 15), 120f * Main.rand.NextFloat(0.7f, 1f), 60, new Vector2(0.8f, 1.2f), 0.08f, 0); + + int dir = MathF.Sign(aimVel.X); + Vector2 safeVel = aimVel.SafeNormalize(Vector2.UnitX); + float sparkscale2 = 0.35f * Math.Max(fxFade, 0.5f); + for (int i = -1; i <= 1; i += 2) { - Main.projectile[scythe].DamageType = DamageClass.Generic; - Main.projectile[scythe].usesIDStaticNPCImmunity = true; - Main.projectile[scythe].idStaticNPCHitCooldown = 10; + Vector2 fxVelocity = safeVel.RotatedBy(dir * MathHelper.ToRadians(75) * -i) - safeVel * 3; + Vector2 fxPlace = player.Center + (safeVel * 35).RotatedBy(-0.2f * dir * i) * 1.5f; + + SignusMetaball.SpawnParticle(fxPlace, fxVelocity * Main.rand.NextFloat(5, 8), 50f * Main.rand.NextFloat(0.7f, 1f), 8, new Vector2(0.8f, 1.2f), 0.18f, 0); } - - AngleSwap = !AngleSwap; - } - - // Dash at a faster speed than the default value. - dashSpeed = 14f; + player.velocity.X *= 0.95f; + if (player.velocity.X > 140) + { + player.velocity.X = 140; + } + if (player.velocity.X < -140) + { + player.velocity.X = -140; + } + if (Time > 10) + player.velocity.X *= 0.5f; } } } diff --git a/CalPlayer/Dashes/SuperradiantSawDash.cs b/CalPlayer/Dashes/SuperradiantSawDash.cs index a434d8d652..fdeb0442dc 100644 --- a/CalPlayer/Dashes/SuperradiantSawDash.cs +++ b/CalPlayer/Dashes/SuperradiantSawDash.cs @@ -1,20 +1,23 @@ using CalamityMod.Enums; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; namespace CalamityMod.CalPlayer.Dashes { public class SuperradiantSawDash : PlayerDashEffect { - public static new string ID => "Superradiant Slaughterer"; + public static new string ID { get; private set; } public override DashCollisionType CollisionType => DashCollisionType.NoCollision; public override bool IsOmnidirectional => true; + public override void Load() + { + ID = DashID; + } + public override float CalculateDashSpeed(Player player) => 36f; public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) diff --git a/CalPlayer/DrawLayers/AdrenalineTrailLayer.cs b/CalPlayer/DrawLayers/AdrenalineTrailLayer.cs deleted file mode 100644 index 8524e8de6a..0000000000 --- a/CalPlayer/DrawLayers/AdrenalineTrailLayer.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.VanillaArmorChanges; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.CalPlayer.DrawLayers -{ - public class AdrenalineTrailLayer : PlayerDrawLayer - { - public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.LastVanillaLayer); - public int Time = 0; - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead) - return false; - - return drawPlayer.Calamity().AdrenalineTrail; - } - - protected override void Draw(ref PlayerDrawSet drawInfo) - { - Time++; - Player drawPlayer = drawInfo.drawPlayer; - List existingDrawData = drawInfo.DrawDataCache; - float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); - for (float i = 0; i < drawPlayer.Calamity().OldPositions.Length; i += 0.9f) - { - float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; - float scale = MathHelper.Lerp(1.1f, 0.1f, completionRatio); - float opacity = MathHelper.Lerp(0.5f, 0.3f, completionRatio) * movementSpeedInterpolant; - List afterimages = new List(); - for (int j = 0; j < existingDrawData.Count; j++) - { - var drawData = existingDrawData[j]; - Vector2 extraPosition = (Time % 6 == 0 ? new Vector2(Main.rand.NextFloat(-10f, 10f), Main.rand.NextFloat(-10f, 10f)) : Vector2.Zero); - drawData.position = existingDrawData[j].position - drawPlayer.position + drawPlayer.oldPosition + extraPosition; - drawData.color = new Color(0, 255, 201) * opacity; - drawData.scale = new Vector2(scale); - afterimages.Add(drawData); - } - drawInfo.DrawDataCache.InsertRange(0, afterimages); - } - } - } -} diff --git a/CalPlayer/DrawLayers/AscendedTrailLayer.cs b/CalPlayer/DrawLayers/AscendedTrailLayer.cs deleted file mode 100644 index 3ec0408121..0000000000 --- a/CalPlayer/DrawLayers/AscendedTrailLayer.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.VanillaArmorChanges; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.CalPlayer.DrawLayers -{ - public class AscendantTrailLayer : PlayerDrawLayer - { - public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.LastVanillaLayer); - - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail) - return false; - - return drawPlayer.Calamity().ascendantTrail; - } - - protected override void Draw(ref PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - List existingDrawData = drawInfo.DrawDataCache; - float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); - for (float i = 0f; i < drawPlayer.Calamity().OldPositions.Length; i += 1.2f) - { - float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; - float scale = MathHelper.Lerp(1f, 0.7f, completionRatio); - float opacity = MathHelper.Lerp(0.18f, 0.06f, completionRatio) * movementSpeedInterpolant; - List afterimages = new List(); - for (int j = 0; j < existingDrawData.Count; j++) - { - var drawData = existingDrawData[j]; - drawData.position = existingDrawData[j].position - drawPlayer.position + drawPlayer.oldPosition; - drawData.color = Color.Khaki * opacity; - drawData.scale = new Vector2(scale); - afterimages.Add(drawData); - } - drawInfo.DrawDataCache.InsertRange(0, afterimages); - } - } - } -} diff --git a/CalPlayer/DrawLayers/AuralisAuroraLayer.cs b/CalPlayer/DrawLayers/AuralisAuroraLayer.cs index a6f4a4ba87..5c6629042b 100644 --- a/CalPlayer/DrawLayers/AuralisAuroraLayer.cs +++ b/CalPlayer/DrawLayers/AuralisAuroraLayer.cs @@ -17,7 +17,7 @@ namespace CalamityMod.CalPlayer.DrawLayers return false; Player drawPlayer = drawInfo.drawPlayer; - return !(drawPlayer.Calamity().auralisAuroraCooldown < 300 || drawPlayer.Calamity().auralisAuroraCooldown > 0); + return !(drawPlayer.Calamity().auralisAuroraCounter < 300 || drawPlayer.Calamity().auralisAuroraCounter > 1500); } protected override void Draw(ref PlayerDrawSet drawInfo) diff --git a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs b/CalPlayer/DrawLayers/AuricSetTrailLayer.cs deleted file mode 100644 index 985f590c07..0000000000 --- a/CalPlayer/DrawLayers/AuricSetTrailLayer.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.VanillaArmorChanges; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.CalPlayer.DrawLayers -{ - public class AuricSetTrailLayer : PlayerDrawLayer - { - public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.LastVanillaLayer); - - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail || drawPlayer.Calamity().ascendantTrail) - return false; - - return drawPlayer.Calamity().auricSet; - } - - protected override void Draw(ref PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - List existingDrawData = drawInfo.DrawDataCache; - float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); - for (float i = 0f; i < drawPlayer.Calamity().OldPositions.Length; i += 1.7f) - { - float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; - float scale = MathHelper.Lerp(1f, 0.6f, completionRatio); - float opacity = MathHelper.Lerp(0.12f, 0.03f, completionRatio) * movementSpeedInterpolant; - List afterimages = new List(); - for (int j = 0; j < existingDrawData.Count; j++) - { - var drawData = existingDrawData[j]; - drawData.position = existingDrawData[j].position - drawPlayer.position + drawPlayer.oldPosition; - drawData.color = new Color(105, 209, 248) * opacity; - drawData.scale = new Vector2(scale); - afterimages.Add(drawData); - } - drawInfo.DrawDataCache.InsertRange(0, afterimages); - } - } - } -} diff --git a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs b/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs deleted file mode 100644 index 6c348fd81c..0000000000 --- a/CalPlayer/DrawLayers/CobaltSetTrailLayer.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.VanillaArmorChanges; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.CalPlayer.DrawLayers -{ - public class CobaltSetTrailLayer : PlayerDrawLayer - { - public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.LastVanillaLayer); - - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead || drawPlayer.Calamity().AdrenalineTrail || drawPlayer.Calamity().ascendantTrail) - return false; - - return drawPlayer.Calamity().CobaltSet; - } - - protected override void Draw(ref PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - List existingDrawData = drawInfo.DrawDataCache; - float movementSpeedInterpolant = CobaltArmorSetChange.CalculateMovementSpeedInterpolant(drawPlayer); - for (int i = 0; i < drawPlayer.Calamity().OldPositions.Length; i++) - { - float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; - float scale = MathHelper.Lerp(1f, 0.5f, completionRatio); - float opacity = MathHelper.Lerp(0.23f, 0.07f, completionRatio) * movementSpeedInterpolant; - List afterimages = new List(); - for (int j = 0; j < existingDrawData.Count; j++) - { - var drawData = existingDrawData[j]; - drawData.position = existingDrawData[j].position - drawPlayer.position + drawPlayer.oldPosition; - drawData.color = new Color(100, 164, 219) * opacity; - drawData.color.B = (byte)(drawData.color.B * 1.4); - drawData.scale = new Vector2(scale); - afterimages.Add(drawData); - } - drawInfo.DrawDataCache.InsertRange(0, afterimages); - } - } - } -} diff --git a/CalPlayer/DrawLayers/CombHairSparkleLayer.cs b/CalPlayer/DrawLayers/CombHairSparkleLayer.cs index 18ca428d85..923c28d79c 100644 --- a/CalPlayer/DrawLayers/CombHairSparkleLayer.cs +++ b/CalPlayer/DrawLayers/CombHairSparkleLayer.cs @@ -1,10 +1,7 @@ using CalamityMod.Items.Accessories.Vanity; -using System; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -60,10 +57,14 @@ namespace CalamityMod.CalPlayer.DrawLayers { for (int j = TopRange; j <= BottomRange; j++) { + Tile tile = Main.tile[i, j]; + if (!tile.HasTile || !TileID.Sets.IsAContainer[tile.TileType] || TileID.Sets.BasicDresser[tile.TileType]) + continue; + int PotentialChest = Chest.FindChestByGuessing(i, j); - if (PotentialChest != -1 && !TileID.Sets.BasicDresser[Main.tile[i, j].TileType]) + if (PotentialChest != -1) { - // Adjust position ot the center of the chest + // Adjust position to the center of the chest Chest chest = Main.chest[PotentialChest]; Vector2 chestCenter = new Vector2(chest.x + 1, chest.y + 1) * 16f; float distance = Vector2.Distance(chestCenter, drawPlayer.MountedCenter); diff --git a/CalPlayer/DrawLayers/EncasementParryLayer.cs b/CalPlayer/DrawLayers/EncasementParryLayer.cs index c0ffbb8c29..b366846963 100644 --- a/CalPlayer/DrawLayers/EncasementParryLayer.cs +++ b/CalPlayer/DrawLayers/EncasementParryLayer.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; diff --git a/CalPlayer/DrawLayers/ForbiddenSignLayer.cs b/CalPlayer/DrawLayers/ForbiddenSignLayer.cs index 288ee55479..86e2ac60be 100644 --- a/CalPlayer/DrawLayers/ForbiddenSignLayer.cs +++ b/CalPlayer/DrawLayers/ForbiddenSignLayer.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,7 +12,7 @@ namespace CalamityMod.CalPlayer.DrawLayers { public class ForbiddenSignLayer : PlayerDrawLayer { - public override Position GetDefaultPosition() => new BeforeParent(PlayerDrawLayers.Skin); + public override Position GetDefaultPosition() => new BeforeParent(PlayerDrawLayers.ForbiddenSetRing); public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) { @@ -23,45 +24,37 @@ namespace CalamityMod.CalPlayer.DrawLayers protected override void Draw(ref PlayerDrawSet drawInfo) { Player drawPlayer = drawInfo.drawPlayer; - SpriteEffects spriteEffects; - if (drawPlayer.direction == 1) - spriteEffects = SpriteEffects.None; - else spriteEffects = SpriteEffects.FlipHorizontally; - - if (drawPlayer.gravDir != 1f) - spriteEffects |= SpriteEffects.FlipVertically; - - int dyeShader = 0; - if (drawPlayer.dye[1] != null) - dyeShader = drawPlayer.dye[1].dye; - - Color baseColor = drawPlayer.GetImmuneAlphaPure(Lighting.GetColor((int)drawInfo.Center.X / 16, (int)drawInfo.Center.Y / 16, Color.White), drawInfo.shadow); - Color color = Color.Lerp(baseColor, Color.White, 0.7f); + Color color = Color.Lerp(drawInfo.colorArmorBody, Color.White, 0.7f); Texture2D texture = TextureAssets.Extra[ExtrasID.ForbiddenSign].Value; Texture2D glowmask = TextureAssets.GlowMask[GlowMaskID.ForbiddenSign].Value; - float offsetY = (float)Math.Sin(drawPlayer.miscCounter / 300f * MathHelper.TwoPi) * 6f; - float sinusoidalTime = (float)Math.Cos(drawPlayer.miscCounter / 75f * MathHelper.TwoPi); - Color afterimageColor = new Color(80, 70, 40, 0) * (sinusoidalTime * 0.5f + 0.5f) * 0.8f; - float gravCheckOffset = drawPlayer.gravDir != 1f ? -20f : 20f; + int offsetY = (int)(MathF.Sin(drawPlayer.miscCounter / 300f * MathHelper.TwoPi) * 6f); + float shadowMult = MathF.Cos(drawPlayer.miscCounter / 75f * MathHelper.TwoPi) * 4f; + Color afterimageColor = new Color(80, 70, 40, 0) * (shadowMult * 0.125f + 0.5f) * 0.8f; - Vector2 position = new Vector2(drawInfo.Center.X - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, drawInfo.Center.Y + drawPlayer.height - drawPlayer.bodyFrame.Height + 4f) + drawPlayer.bodyPosition; - position += new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2) + new Vector2(-drawPlayer.direction * 10, offsetY - gravCheckOffset); - position -= Main.screenPosition + drawPlayer.Size * 0.5f; + if (drawPlayer.ownedProjectileCounts[ModContent.ProjectileType()] > 1) + { + offsetY = 0; + shadowMult = 2f; + afterimageColor = new Color(80, 70, 40, 0) * 0.3f; + color = color.MultiplyRGB(new Color(0.5f, 0.5f, 1f)); + } + + Vector2 drawPos = drawInfo.Position + drawPlayer.bodyPosition - Main.screenPosition; + drawPos += new Vector2(drawPlayer.width * 0.5f - drawPlayer.direction * 10f, drawPlayer.height - drawPlayer.bodyFrame.Height * 0.5f + 4f + drawPlayer.gravDir * (offsetY - 20f)); // Draw the original sign. - DrawData drawData = new(texture, position, null, color, drawPlayer.bodyRotation, texture.Size() * 0.5f, 1f, spriteEffects, 0) + DrawData drawData = new(texture, drawPos, null, color, drawPlayer.bodyRotation, texture.Size() * 0.5f, 1f, drawInfo.playerEffect) { - shader = dyeShader + shader = drawInfo.cBody }; drawInfo.DrawDataCache.Add(drawData); // Draw 4 semi-transparent copies. - float timeX4 = sinusoidalTime * 4f; Vector2 origin = texture.Size() * 0.5f; for (float i = 0f; i < 4f; i++) { float angle = MathHelper.PiOver2 * i; - drawData = new(glowmask, position + angle.ToRotationVector2() * timeX4, null, afterimageColor, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0); + drawData = new(glowmask, drawPos + angle.ToRotationVector2() * shadowMult, null, afterimageColor, drawPlayer.bodyRotation, origin, 1f, drawInfo.playerEffect); drawInfo.DrawDataCache.Add(drawData); } } diff --git a/CalPlayer/DrawLayers/HatExtensionLayer.cs b/CalPlayer/DrawLayers/HatExtensionLayer.cs index 7b512ea262..bab41f5cb3 100644 --- a/CalPlayer/DrawLayers/HatExtensionLayer.cs +++ b/CalPlayer/DrawLayers/HatExtensionLayer.cs @@ -1,9 +1,7 @@ -using CalamityMod.Items.Accessories.Vanity; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.CalPlayer.DrawLayers @@ -16,16 +14,19 @@ namespace CalamityMod.CalPlayer.DrawLayers protected override void Draw(ref PlayerDrawSet drawInfo) { - //Todo : Make this work even for accessories by somehow checking for the players.head equipslot's item instead of the head item. Player drawPlayer = drawInfo.drawPlayer; - Item headItem = drawPlayer.armor[0]; - if (drawPlayer.armor[10].type > ItemID.None) - headItem = drawPlayer.armor[10]; + if (drawPlayer.head == -1) + return; - if (ModContent.GetModItem(headItem.type) is IExtendedHat extendedHatDrawer) + if (EquipLoader.GetEquipTexture(EquipType.Head, drawPlayer.head) == null) + return; + + ModItem headItem = EquipLoader.GetEquipTexture(EquipType.Head, drawPlayer.head).Item; + + if (headItem is IExtendedHat extendedHatDrawer) { - string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.ModItem.Name; + string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.Name; int equipSlot = EquipLoader.GetEquipSlot(Mod, equipSlotName, EquipType.Head); if (extendedHatDrawer.PreDrawExtension(drawInfo) && !drawInfo.drawPlayer.dead && equipSlot == drawPlayer.head) diff --git a/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs b/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs index 9d364b2ec0..b97c623b53 100644 --- a/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs +++ b/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Items.Weapons.Magic; @@ -10,7 +9,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.UI; @@ -35,6 +33,8 @@ namespace CalamityMod.CalPlayer.DrawLayers if (itemType < ItemID.Count) return; + Color color = new Color(250, 250, 250, heldItem.alpha); + // This is ugly and I don't give a fuck. // If you want it to look better, do it yourself. Texture2D glowMask = default; @@ -52,18 +52,16 @@ namespace CalamityMod.CalPlayer.DrawLayers 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()) - glowMask = ModContent.Request("CalamityMod/Items/Weapons/Ranged/DeathwindGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/HyperdeathRiftScepterGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/Ranged/ThreadOfEradicationGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/EssenceFlayerGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Summon/EtherealSubjugatorGlow").Value; - else if (itemType == ModContent.ItemType()) - glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/ExcelsusGlow").Value; - else if (itemType == ModContent.ItemType()) - glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/IridescentExcaliburGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/MawOfInfinityGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/FatesRevealGlow").Value; else if (itemType == ModContent.ItemType()) @@ -75,7 +73,10 @@ namespace CalamityMod.CalPlayer.DrawLayers else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/SummonItems/NecroplasmicBeaconGlow").Value; else if (itemType == ModContent.ItemType()) + { + color = Color.Lerp(Color.White, drawPlayer.Calamity().lightRGB, 0.75f) with { A = 0 }; glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/OrderbringerGlow").Value; + } else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/PhotosynthesisGlow").Value; else if (itemType == ModContent.ItemType()) @@ -84,18 +85,14 @@ namespace CalamityMod.CalPlayer.DrawLayers 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/DraedonsArsenal/GaussRifleGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/SoulPiercerGlow").Value; - else if (itemType == ModContent.ItemType()) - glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/StarburstShivGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/LightspeedGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/SubsumingVortexSmallGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/TerrorBladeGlow").Value; - else if (itemType == ModContent.ItemType()) - 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()) @@ -136,7 +133,7 @@ namespace CalamityMod.CalPlayer.DrawLayers drawInfo.itemColor = drawInfo.itemColor.MultiplyRGBA(new Color(Vector4.Lerp(Vector4.One, new Vector4(0f, 0.12f, 0.16f, 0f), 1f - stealth))); } - bool inUse = drawPlayer.itemAnimation > 0 && heldItem.useStyle != 0; + bool inUse = drawPlayer.itemAnimation > 0 && heldItem.useStyle != ItemUseStyleID.None; bool visuallyHeld = heldItem.holdStyle != 0 && !drawPlayer.pulley; if (!drawPlayer.CanVisuallyHoldItem(heldItem)) visuallyHeld = false; @@ -144,7 +141,6 @@ namespace CalamityMod.CalPlayer.DrawLayers if (drawInfo.shadow != 0f || drawPlayer.frozen || !(inUse || visuallyHeld) || itemType <= 0 || drawPlayer.dead || heldItem.noUseGraphic || (drawPlayer.wet && heldItem.noWet) || (drawPlayer.happyFunTorchTime && drawPlayer.inventory[drawPlayer.selectedItem].createTile == TileID.Torches && drawPlayer.itemAnimation == 0)) return; - Color color = new Color(250, 250, 250, heldItem.alpha); Vector2 originOffset = Vector2.Zero; // Use to adjust glow mask draw offset and color. diff --git a/CalPlayer/DrawLayers/IBulkyArmor.cs b/CalPlayer/DrawLayers/IBulkyArmor.cs index 076611fcad..2e18809256 100644 --- a/CalPlayer/DrawLayers/IBulkyArmor.cs +++ b/CalPlayer/DrawLayers/IBulkyArmor.cs @@ -1,6 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; +using Terraria; /// /// Interface that can be used by chestplates to appear extra bulky, by drawing partly over the players helmet with an extra layer diff --git a/CalPlayer/DrawLayers/IDrawArmOverShoulderpad.cs b/CalPlayer/DrawLayers/IDrawArmOverShoulderpad.cs index d4ce3f3ef5..976d04cca9 100644 --- a/CalPlayer/DrawLayers/IDrawArmOverShoulderpad.cs +++ b/CalPlayer/DrawLayers/IDrawArmOverShoulderpad.cs @@ -1,6 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; +using Terraria; /// /// Interface that can be used by chestplates that need their front arm (when walking) to go over the shoulderpads diff --git a/CalPlayer/DrawLayers/IHideFrontArm.cs b/CalPlayer/DrawLayers/IHideFrontArm.cs index 440dc4452e..26189e730d 100644 --- a/CalPlayer/DrawLayers/IHideFrontArm.cs +++ b/CalPlayer/DrawLayers/IHideFrontArm.cs @@ -1,6 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; +using Terraria; /// /// Interface that can be used by items that need to hide the players front arm when held. diff --git a/CalPlayer/DrawLayers/MountsAboveOwnerLayer.cs b/CalPlayer/DrawLayers/MountsAboveOwnerLayer.cs index d0c1cdcc9b..06a652df22 100644 --- a/CalPlayer/DrawLayers/MountsAboveOwnerLayer.cs +++ b/CalPlayer/DrawLayers/MountsAboveOwnerLayer.cs @@ -13,7 +13,7 @@ namespace CalamityMod.CalPlayer.DrawLayers { Player drawPlayer = drawInfo.drawPlayer; CalamityPlayer modPlayer = drawPlayer.Calamity(); - return drawPlayer.mount != null && (modPlayer.fab || modPlayer.crysthamyr || modPlayer.onyxExcavator); + return drawPlayer.mount != null && (modPlayer.crysthamyr || modPlayer.onyxExcavator); } protected override void Draw(ref PlayerDrawSet drawInfo) diff --git a/CalPlayer/DrawLayers/UnstableCastersGauntletLayer.cs b/CalPlayer/DrawLayers/UnstableCastersGauntletLayer.cs new file mode 100644 index 0000000000..8b3ac02a8c --- /dev/null +++ b/CalPlayer/DrawLayers/UnstableCastersGauntletLayer.cs @@ -0,0 +1,38 @@ +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class UnstableCastersGauntletLayer : PlayerDrawLayer + { + public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.HandOnAcc); + + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) => drawInfo.drawPlayer.HeldItem.ModItem is UnstableCastersGauntlet; + + protected override void Draw(ref PlayerDrawSet drawInfo) + { + // Thanks YuH. + + Vector2 bodyPos = new Vector2((int)(drawInfo.Position.X - Main.screenPosition.X - drawInfo.drawPlayer.bodyFrame.Width / 2 + drawInfo.drawPlayer.width / 2), (int)(drawInfo.Position.Y - Main.screenPosition.Y + drawInfo.drawPlayer.height - drawInfo.drawPlayer.bodyFrame.Height + 4f)) + drawInfo.drawPlayer.bodyPosition + new Vector2(drawInfo.drawPlayer.bodyFrame.Width / 2, drawInfo.drawPlayer.bodyFrame.Height / 2); + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/UnstableCastersGauntlet_HandsOn").Value; + Vector2 position = bodyPos + drawInfo.frontShoulderOffset + (new Vector2(-5 * (!drawInfo.playerEffect.HasFlag(SpriteEffects.FlipHorizontally) ? 1 : -1), 0f)); + + // Apply offset + Vector2 value = Main.OffsetsPlayerHeadgear[drawInfo.drawPlayer.bodyFrame.Y / drawInfo.drawPlayer.bodyFrame.Height]; + value.Y -= 2f; + position += value * -drawInfo.playerEffect.HasFlag(SpriteEffects.FlipVertically).ToDirectionInt(); + + Vector2 origin = drawInfo.bodyVect + drawInfo.frontShoulderOffset + (new Vector2(-5 * (!drawInfo.playerEffect.HasFlag(SpriteEffects.FlipHorizontally) ? 1 : -1), 0f)); + if (drawInfo.compFrontArmFrame.X / drawInfo.compFrontArmFrame.Width >= 7) + { + position += new Vector2((!drawInfo.playerEffect.HasFlag(SpriteEffects.FlipHorizontally)) ? 1 : (-1), (!drawInfo.playerEffect.HasFlag(SpriteEffects.FlipVertically)) ? 1 : (-1)); + } + + DrawData drawData = new DrawData(texture, position, drawInfo.compFrontArmFrame, Color.White * (1f - drawInfo.shadow), drawInfo.compositeFrontArmRotation, origin, 1f, drawInfo.playerEffect, 0); + drawInfo.DrawDataCache.Add(drawData); + } + } +} diff --git a/CalPlayer/DrawLayers/WingsofRebirthLayer.cs b/CalPlayer/DrawLayers/WingsofRebirthLayer.cs new file mode 100644 index 0000000000..6eaeef33b6 --- /dev/null +++ b/CalPlayer/DrawLayers/WingsofRebirthLayer.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; + +namespace CalamityMod.CalPlayer.DrawLayers +{ + public class WingsofRebirthLayer : PlayerDrawLayer + { + public static Asset yharwingTexture; + + public override void Load() + { + yharwingTexture = ModContent.Request("CalamityMod/Items/Accessories/Wings/WingsofRebirth_Wings_Real"); + } + + public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.Wings); + + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) => drawInfo.drawPlayer.wings == EquipLoader.GetEquipSlot(Mod, "WingsofRebirth", EquipType.Wings); + + protected override void Draw(ref PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + + if (drawPlayer.dead) + return; + Texture2D texture = yharwingTexture.Value; + Vector2 Position = drawInfo.Position; + Vector2 pos = new Vector2((int)(Position.X - Main.screenPosition.X + (drawPlayer.width / 2) - (2 * drawPlayer.direction)), (int)(Position.Y - Main.screenPosition.Y + (drawPlayer.height / 2 + drawPlayer.HeightOffsetVisual / 2f) - 2f * drawPlayer.gravDir)); + Color lightColor = Lighting.GetColor((int)drawPlayer.Center.X / 16, (int)drawPlayer.Center.Y / 16, Color.White); + Color color = lightColor * (1 - drawInfo.shadow); + DrawData d = new DrawData(texture, pos, texture.Frame(1, 9, 0, drawInfo.drawPlayer.wingFrame), color, 0f, new Vector2(texture.Width / 2, texture.Height / 18), 1f, drawInfo.playerEffect, 0); + d.shader = drawInfo.drawPlayer.cWings; + drawInfo.DrawDataCache.Add(d); + } + } +} diff --git a/CalPlayer/DrawLayers/YanmeiKnifeTrailLayer.cs b/CalPlayer/DrawLayers/YanmeiKnifeTrailLayer.cs deleted file mode 100644 index 0b1ed520c6..0000000000 --- a/CalPlayer/DrawLayers/YanmeiKnifeTrailLayer.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.CalPlayer.DrawLayers -{ - public class YanmeiKnifeTrail : PlayerDrawLayer - { - public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.BackAcc); - - public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - if (drawInfo.shadow != 0f || drawPlayer.dead) - return false; - - return drawPlayer.Calamity().kamiBoost; - } - - protected override void Draw(ref PlayerDrawSet drawInfo) - { - Player drawPlayer = drawInfo.drawPlayer; - List existingDrawData = drawInfo.DrawDataCache; - for (int i = 0; i < drawPlayer.Calamity().OldPositions.Length; i++) - { - float completionRatio = i / (float)drawPlayer.Calamity().OldPositions.Length; - float scale = MathHelper.Lerp(1f, 0.5f, completionRatio); - float opacity = MathHelper.Lerp(0.25f, 0.08f, completionRatio); - List afterimages = new List(); - for (int j = 0; j < existingDrawData.Count; j++) - { - var drawData = existingDrawData[j]; - drawData.position = existingDrawData[j].position - drawPlayer.position + drawPlayer.oldPosition; - drawData.color = Color.Cyan * opacity; - drawData.color.G = (byte)(drawData.color.G * 1.6); - drawData.color.B = (byte)(drawData.color.B * 1.2); - drawData.scale = new Vector2(scale); - afterimages.Add(drawData); - } - drawInfo.DrawDataCache.InsertRange(0, afterimages); - } - } - } -} diff --git a/CalPlayer/PlayerEnvironmentEffects.cs b/CalPlayer/PlayerEnvironmentEffects.cs deleted file mode 100644 index e440513db4..0000000000 --- a/CalPlayer/PlayerEnvironmentEffects.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.CalPlayer -{ - public partial class CalamityPlayer : ModPlayer - { - public void DoEnvironmentalEffects() - { - CreateLilyglowInFloralParadise(); - } - - public void CreateLilyglowInFloralParadise() - { - // Don't do anything if the player is not in the floral paradise of if this code is called by anyone other than the player. - if (!ZoneFloralParadise || Main.myPlayer != Player.whoAmI) - return; - - if (!Main.rand.NextBool(12)) - return; - - for (int tries = 0; tries < 50; tries++) - { - Vector2 potentialSpawnPosition = Player.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(200f, 800f); - if (Collision.SolidCollision(potentialSpawnPosition, 1, 1)) - continue; - - Vector2 spawnVelocity = -Vector2.UnitY.RotatedByRandom(0.82f) * Main.rand.NextFloat(0.5f, 1.35f); - Projectile.NewProjectile(new EntitySource_WorldEvent(), potentialSpawnPosition, spawnVelocity, ModContent.ProjectileType(), 0, 0f, Player.whoAmI); - break; - } - } - } -} diff --git a/CalamityConditions.cs b/CalamityConditions.cs index 7d7f2705c8..8fdfb0d11e 100644 --- a/CalamityConditions.cs +++ b/CalamityConditions.cs @@ -21,14 +21,6 @@ namespace CalamityMod 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 @@ -42,7 +34,7 @@ namespace CalamityMod // public static readonly Condition DownedDesertScourge = Create("Drops.DownedDS", () => DownedBossSystem.downedDesertScourge); - public static readonly Condition DownedCrabulon = Create("Drops.DownedCrabulon", () => DownedBossSystem.downedDesertScourge); + public static readonly Condition DownedCrabulon = Create("Drops.DownedCrabulon", () => DownedBossSystem.downedCrabulon); 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); diff --git a/CalamityConfig.cs b/CalamityConfig.cs index ffe552857b..3935c1af0a 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -1,13 +1,13 @@ using System.ComponentModel; -using System.Reflection; using System.Runtime.Serialization; +using CalamityMod.Enums; +using CalamityMod.Systems; using CalamityMod.UI; using CalamityMod.UI.DraedonsArsenal; using CalamityMod.UI.Rippers; using CalamityMod.UI.SulphurousWaterMeter; using Terraria; using Terraria.Localization; -using Terraria.ModLoader; using Terraria.ModLoader.Config; namespace CalamityMod @@ -27,39 +27,17 @@ namespace CalamityMod ParticleLimit = (int)Utils.Clamp(ParticleLimit, MinParticleLimit, MaxParticleLimit); } - internal static void SaveConfig() - { - // There is no current way to manually save a mod configuration file in tModLoader. - // The method which saves mod config files is private in ConfigManager, so reflection is used to invoke it. - try - { - MethodInfo saveMethodInfo = typeof(ConfigManager).GetMethod("Save", BindingFlags.Static | BindingFlags.NonPublic); - if (saveMethodInfo is not null) - saveMethodInfo.Invoke(null, [Instance]); - else - CalamityMod.Instance.Logger.Error("TML ConfigManager.Save reflection failed. Method signature has changed. Notify Calamity Devs if you see this in your log."); - } - catch - { - CalamityMod.Instance.Logger.Error("An error occurred while manually saving Calamity mod configuration. This may be due to a complex mod conflict. It is safe to ignore this error."); - } - } - - #region Multi-Threading Settings - [Header("Multithreading")] - - [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 2f)] - [DefaultValue(0f)] - [Increment(1f)] - [DrawTicks] - public float SunkenSeaMultiThreading { get; set; } - #endregion - #region Graphics Changes [Header("Graphics")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + public bool DisableGravityScreenSwap { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool TextEffects { get; set; } + [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] public bool Afterimages { get; set; } @@ -72,6 +50,14 @@ namespace CalamityMod [DefaultValue(true)] public bool EnableVanillaTextureEdits { get; set; } + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool SunkenSeaBackgroundDistortion { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool FancyBackgroundVisuals { get; set; } + private const int MinParticleLimit = 500; private const int MaxParticleLimit = 10000; @@ -97,6 +83,10 @@ namespace CalamityMod [Range(0.0f, 1.0f)] public float EnergyShieldOpacity { get; set; } + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(TileBlendingQuality.Normal)] + public TileBlendingQuality TileTextureBlendingQuality { get; set; } + #endregion #region UI Changes @@ -123,12 +113,8 @@ namespace CalamityMod public bool DebuffDisplay { get; set; } [BackgroundColor(192, 54, 64, 192)] - [SliderColor(224, 165, 56, 128)] - [Range(0f, 2f)] - [DefaultValue(2f)] - [Increment(1f)] - [DrawTicks] - public float CooldownDisplay { get; set; } + [DefaultValue(CooldownDisplayOptions.Full)] + public CooldownDisplayOptions CooldownDisplay { get; set; } [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] @@ -254,25 +240,21 @@ namespace CalamityMod public float FlightBarPosY { get; set; } #endregion - #region Music Events - [Header("MusicEvents")] + #region Music Toggles + [Header("MusicToggles")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] - public bool Interlude1 { get; set; } - - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - public bool Interlude2 { get; set; } - - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - public bool Interlude3 { get; set; } + public bool Interludes { get; set; } [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] public bool DevourerofGodsEulogy { get; set; } + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + public bool AbyssLayer3Alt { get; set; } + #endregion #region General Gameplay Changes @@ -281,6 +263,14 @@ namespace CalamityMod [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] public bool FasterFallHotkey { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(SetBonusDoubleTapOptions.Auto)] + public SetBonusDoubleTapOptions SetBonusDoubleTap { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + public bool StutterFix { get; set; } #endregion } @@ -312,6 +302,11 @@ namespace CalamityMod [Header("Gameplay")] #region General Gameplay Changes + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool SimplifyAccessoryReforge { get; set; } + [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] public bool RemoveReforgeRNG { get; set; } diff --git a/CalamityKeybinds.cs b/CalamityKeybinds.cs index c09e181762..f50b60e5b4 100644 --- a/CalamityKeybinds.cs +++ b/CalamityKeybinds.cs @@ -19,6 +19,8 @@ namespace CalamityMod public static ModKeybind RageHotKey { get; private set; } public static ModKeybind SpectralVeilHotKey { get; private set; } public static ModKeybind TransformerHotKey { get; private set; } + public static ModKeybind SwitchGravityHotkey {get; private set;} + public static ModKeybind ExpandDebuffInfo { get; private set; } public override void Load() { @@ -38,6 +40,8 @@ namespace CalamityMod RageHotKey = KeybindLoader.RegisterKeybind(Mod, "RageMode", "V"); SpectralVeilHotKey = KeybindLoader.RegisterKeybind(Mod, "SpectralVeilTeleport", "Z"); TransformerHotKey = KeybindLoader.RegisterKeybind(Mod, "TransformerHotKey", "K"); + SwitchGravityHotkey = KeybindLoader.RegisterKeybind(Mod, "GravitySwapOverride", "T"); + ExpandDebuffInfo = KeybindLoader.RegisterKeybind(Mod, "ExpandDebuffInfo", "LeftControl"); } public override void Unload() @@ -57,6 +61,7 @@ namespace CalamityMod RageHotKey = null; SpectralVeilHotKey = null; TransformerHotKey = null; + ExpandDebuffInfo = null; } } } diff --git a/CalamityMod.cs b/CalamityMod.cs index 04444e41f5..ec7526c385 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -1,16 +1,15 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Runtime.CompilerServices; using CalamityMod.FluidSimulation; using CalamityMod.Items; +using CalamityMod.MainMenu; using CalamityMod.Particles; using CalamityMod.Projectiles; +using log4net; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -using Terraria.ModLoader.Config; [assembly: InternalsVisibleTo("CalTestHelpers")] [assembly: InternalsVisibleTo("InfernumMode")] @@ -19,10 +18,6 @@ namespace CalamityMod public class CalamityMod : Mod { #region External Flags - // External flag to disable non-Revengeance boss AI edits - // This can be edited by other mods using reflection to prevent compatibility issues - public static bool ExternalFlag_DisableNonRevBossAI = false; - // External flag to disable Defense Damage // This can be edited by other mods using reflection if desired // Note that this flag trumps Bloodflare Core and will stop that accessory from working properly. @@ -33,11 +28,14 @@ namespace CalamityMod internal static CalamityMod Instance => _Instance ??= ModContent.GetInstance(); private static CalamityMod _Instance; + // This should not be named as 'Logger' as it hides Instance Property 'Logger' + internal static ILog Log => Instance.Logger; + #region Load public override void Load() { // Initialize the EnemyStats struct as early as it is safe to do so - NPCStats.Load(); + NPCStats.LoadDebuffs(); // Initialize Calamity Balance, since it is tightly coupled with the remaining systems CalamityGlobalItem.LoadTweaks(); @@ -50,12 +48,18 @@ namespace CalamityMod Main.QueueMainThreadAction(() => Main.OnPreDraw += PrepareRenderTargets); } } + + public override void PostSetupContent() + { + // Force open certain ModMenus for various reasons and the added flair of "Hey! Something big has happened! Check it out!" + CalamityMainMenu_Sunken.ForceMenuStyle(); + } #endregion #region Unload public override void Unload() { - NPCStats.Unload(); + NPCStats.UnloadDebuffs(); CalamityGlobalItem.UnloadTweaks(); CalamityGlobalProjectile.UnloadTweaks(); diff --git a/CalamityMod.csproj b/CalamityMod.csproj index 5aadf21dce..a6d337d349 100644 --- a/CalamityMod.csproj +++ b/CalamityMod.csproj @@ -1,13 +1,33 @@ - + + - CalamityMod - net8.0 - AnyCPU latest + + - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index b40c85cbda..cb7eafed84 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -1,114 +1,56 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices.JavaScript; -using CalamityMod.Events; -using CalamityMod.Items; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.NPCs; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.Providence; -using CalamityMod.NPCs.TownNPCs; using CalamityMod.Packets; -using CalamityMod.Systems; -using CalamityMod.TileEntities; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod { public class CalamityNetcode : ModSystem { - private static CalamityPacket[] _PacketRegistry; + private static List _PacketHandlers = []; - public override void OnModLoad() + internal static ushort RegisterHandler(CalamityPacket handler) { - _PacketRegistry = new CalamityPacket[256]; // This should allow to use 0-255 range (full byte range) + var id = (ushort)_PacketHandlers.Count; + _PacketHandlers.Add(handler); + return id; + } - ReflectionHelper.IterateEveryModsTypes(action: type => - { - try - { - if (Activator.CreateInstance(type) is not CalamityPacket packetHandler) - return; + internal static void WriteHandlerNetID(BinaryWriter packet, ushort netID) + { + if (_PacketHandlers.Count > 256) + packet.Write(netID); + else + packet.Write((byte)netID); + } - var msgType = packetHandler.MessageType; - var existingHandler = _PacketRegistry[msgType]; - if (existingHandler != null) - { - CalamityMod.Instance.Logger.Error($"Packet instance has already registered by other type!" + - $" [Failed On: '{type.FullName}'" + - $" Current Owner: '{existingHandler.GetType().FullName}'," + - $" msgTypeToRegister: '{msgType}']"); - return; - } - - _PacketRegistry[packetHandler.MessageType] = packetHandler; - - var instanceProperty = type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic); - if (instanceProperty is not null) - { - if (instanceProperty.PropertyType.IsAssignableFrom(type)) - { - instanceProperty.SetValue(null, packetHandler); - packetHandler._Prop_Static_Instance = instanceProperty; // We saving this for Unload Steps - } - else - { - CalamityMod.Instance.Logger.Error($"Packet instance's 'Instance' property is not asssignable with given type!" + - $" [Failed On: '{type.FullName}']"); - } - } - - // We should not print error message if "Instance" property is missing - // Addons still can assign them with OnLoaded overload, and it's up to their implementation - // Still, Calamity's Standard is having "Instance" property for every packet types - - packetHandler.OnLoaded(); - } - catch (Exception e) - { - CalamityMod.Instance.Logger.Error($"Exception was thrown while loading for Packets! {e}"); - return; - } - }); + internal static ushort ReadHandlerNetID(BinaryReader packet) + { + if (_PacketHandlers.Count > 256) + return packet.ReadUInt16(); + else + return packet.ReadByte(); } public override void OnModUnload() { - if (_PacketRegistry is not null) - { - foreach (var packetHandler in _PacketRegistry) - { - if (packetHandler is null) - continue; - - packetHandler.OnUnloaded(); - packetHandler._Prop_Static_Instance?.SetValue(null, null); - packetHandler._Prop_Static_Instance = null; - } - - _PacketRegistry = null; - } + _PacketHandlers = null; } public static void HandlePacket(Mod mod, BinaryReader reader, int whoAmI) { try { - CalamityModMessageType msgType = (CalamityModMessageType)reader.ReadByte(); - var packetHandler = _PacketRegistry[(byte)msgType]; + var netID = ReadHandlerNetID(reader); + var packetHandler = _PacketHandlers[netID]; if (packetHandler is not null) { - packetHandler.HandlePacket(in reader, whoAmI); + packetHandler.HandlePacket(reader, whoAmI); } else { @@ -117,18 +59,18 @@ namespace CalamityMod // Throw an exception now instead of allowing the network stream to corrupt. // - CalamityMod.Instance.Logger.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}."); + CalamityMod.Log.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {netID}."); throw new Exception("Failed to parse Calamity packet: Invalid Calamity packet ID."); } } catch (Exception e) { if (e is EndOfStreamException eose) - CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: Packet was too short, missing data, or otherwise corrupt.", eose); + CalamityMod.Log.Error("Failed to parse Calamity packet: Packet was too short, missing data, or otherwise corrupt.", eose); else if (e is ObjectDisposedException ode) - CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: Packet reader disposed or destroyed.", ode); + CalamityMod.Log.Error("Failed to parse Calamity packet: Packet reader disposed or destroyed.", ode); else if (e is IOException ioe) - CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: An unknown I/O error occurred.", ioe); + CalamityMod.Log.Error("Failed to parse Calamity packet: An unknown I/O error occurred.", ioe); else throw; // this either will crash the game or be caught by TML's packet policing } @@ -184,14 +126,6 @@ namespace CalamityMod NetMessage.SendData(MessageID.SyncNPC, toClient, ignoreClient, null, npcWhoAmI); } - public static void SyncCalamityWorldDifficulties(int sender) - { - if (Main.netMode == NetmodeID.SinglePlayer) - return; - - SyncDifficultiesPacket.Send(); - } - public static void NewNPC_ClientSide(Vector2 spawnPosition, int npcType, Player player) { if (Main.netMode == NetmodeID.SinglePlayer) @@ -205,84 +139,4 @@ namespace CalamityMod } } } - - public enum CalamityModMessageType : byte - { - // Player mechanic syncs - DefenseDamageSync, // TODO -- this can't be synced every 60 frames, it needs to be synced when the player gets hit, or every time it heals up - RageSync, // TODO -- this can't be synced every 60 frames, it needs to be synced every time the player is - AdrenalineSync, // TODO -- this can't be synced every 60 frames, it needs to be synced every time the player is - CooldownAddition, - CooldownRemoval, - SyncCooldownDictionary, - - // Syncs for specific bosses or entities - SyncDestroyerLaserColor, - SyncCalamityNPCAIArray, - SyncVanillaNPCLocalAIArray, - SpawnSuperDummy, - DeleteAllSuperDummies, - SyncAndroombaSolution, - SyncAndroombaAI, - SyncSlabCrabAI, - PlaceAltCritter, - ProvidenceDyeConditionSync, // TODO -- this packetstorms if you hit Provi with spam weapons. It should ONLY send a packet if the status changes. - PSCChallengeSync, // TODO -- once you've failed the PSC challenge this packetstorms - - // General things for entities - SpawnNPCOnPlayer, - SpawnBossOnPosition, - SyncNPCMotionDataToServer, - SyncNPCPosAndRotOnly, - SyncNPCDemonicFlamesDamage, - SyncNPCDemonSwordImpales, - - // Tile Entities - PowerCellFactory, - ChargingStationStandard, - ChargingStationItemChange, - Turret, - LabHologramProjector, - UpdateCodebreakerConstituents, - UpdateCodebreakerContainedStuff, - UpdateCodebreakerDecryptCountdown, - UnlockAbyssChests, - UpdateCanvasPainting, - - // Draedon Summoner - CodebreakerSummonStuff, - ExoMechSelection, - - // Boss Rush - BossRushStage, - BossRushStartTimer, - BossRushEndTimer, - EndBossRush, - BRHostileProjKillSync, // TODO -- Simplify this. Only one packet needs be sent: "kill all hostile projectiles for N frames". - - // Acid Rain - AcidRainSync, - AcidRainOldDukeSummonSync, - EncounteredOldDukeSync, - - // Mouse Controls syncs - RightClickSync, - MousePositionSync, - - // World state sync - SyncDifficulties, - - // Music events - MusicEventSyncRequest, - MusicEventSyncResponse, - - // Bandit Reforge Refund - BanditStolenMoneySync, - WantToRefundReforges, - - // Player Draw Effect Parameters - SyncPlayerDrawParameter, - - Reserved = 150 - } } diff --git a/ChatTags/CalamityBuffTagHandler.cs b/ChatTags/CalamityBuffTagHandler.cs new file mode 100644 index 0000000000..d8f36a5862 --- /dev/null +++ b/ChatTags/CalamityBuffTagHandler.cs @@ -0,0 +1,82 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using ReLogic.Graphics; + +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.UI.Chat; + +namespace CalamityMod.ChatTags +{ + public sealed class CalamityBuffTagHandler : AbstractTagHandler + { + public sealed class Snippet(int buffId) : TextSnippet + { + private const float IconSize = 26f; + + public int BuffId => buffId; + + // TODO: Include check for config option when it gets added. + public bool DrawIcon => true; + + public override bool UniqueDraw(bool justCheckingString, out Vector2 size, SpriteBatch spriteBatch, Vector2 position = new Vector2(), Color color = new Color(), float scale = 1) + { + size = new Vector2(GetStringLength(FontAssets.MouseText.Value), IconSize); + + if (!justCheckingString && (color.R != 0 || color.G != 0 || color.B != 0)) + { + // Avoid re-drawing the icon when drawing borders. + if (DrawIcon) + { + // Tomat: I would love to support + // BuffLoader.[Pre/Post]Draw here, but it's not vaible + // because: + // 1. Main.DrawBuffIcon relies on LocalPlayer's buffs, + // 2. we can't control the source or destination + // rectangles. + + if (Main.netMode != NetmodeID.Server && !Main.dedServ) + { + var texture = TextureAssets.Buff[BuffId]; + spriteBatch.Draw(texture.Value, new Rectangle((int)position.X, (int)position.Y - 2, (int)IconSize, (int)IconSize), null, Color.White); + } + + position.X += IconSize; + } + + var buffColor = CalamityUtils.GetDebuffTooltipNameColor(buffId); + var name = $"{(DrawIcon ? " " : "")}{Lang.GetBuffName(buffId)}"; + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.MouseText.Value, name, position, buffColor, 0f, Vector2.Zero, new Vector2(scale)); + } + return true; + } + + public override float GetStringLength(DynamicSpriteFont font) + { + float iconSize = !DrawIcon ? 0f : IconSize + font.MeasureString(" ").X; + float size = iconSize + font.MeasureString(Lang.GetBuffName(buffId)).X; + return size * Scale; + } + } + + protected override string[] TagNames { get; } = ["cbuff"]; + + public override TextSnippet Parse(string text, Color baseColor = new(), string options = null) + { + if (int.TryParse(text, out int buffId) && buffId >= 0 && buffId < BuffLoader.BuffCount) + { + return new Snippet(buffId); + } + + if (BuffID.Search.TryGetId(text, out buffId)) + { + return new Snippet(buffId); + } + + return new TextSnippet(text); + } + } +} diff --git a/ChatTags/ILoadableTagHandler.cs b/ChatTags/ILoadableTagHandler.cs new file mode 100644 index 0000000000..d16406de29 --- /dev/null +++ b/ChatTags/ILoadableTagHandler.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; + +using Terraria.ModLoader; +using Terraria.UI.Chat; + +namespace CalamityMod.ChatTags +{ + // Tomat: Adapted from NIGHTSHADE (ILoadableTagHandler), but I'm + // granting us this to use here. + /// + /// Abstracted implementation of with autoloading + /// capabilities for defining chat tags like modded content. + /// + /// The chat tag for loading. + public abstract class AbstractTagHandler : ITagHandler, ILoadable + where TSelf : AbstractTagHandler, new() + { + /// + /// Aliases for the tag. + /// + protected abstract string[] TagNames { get; } + + /// + public abstract TextSnippet Parse(string text, Color baseColor = new(), string options = null); + + public virtual void Load(Mod mod) + { + ChatManager.Register(TagNames); + } + + public virtual void Unload() + { + // No need to un-register the tag. ChatManager gets reinitialized + // by tML in response to modders having adding tags previously, + // anyway. + } + } +} diff --git a/Cooldowns/ArsenalPower.cs b/Cooldowns/ArsenalPower.cs index d61c4bce55..488565d0bb 100644 --- a/Cooldowns/ArsenalPower.cs +++ b/Cooldowns/ArsenalPower.cs @@ -2,7 +2,6 @@ using Terraria; using Terraria.Audio; using Terraria.Localization; -using static CalamityMod.CalamityUtils; namespace CalamityMod.Cooldowns { @@ -15,7 +14,13 @@ namespace CalamityMod.Cooldowns public override Color OutlineColor => Color.White; public override Color CooldownStartColor => Color.Sienna; public override Color CooldownEndColor => Color.LightSlateGray; + public override void Tick() + { + if (Main.zenithWorld) + instance.timeLeft = -1; + + } - public override SoundStyle? EndSound => new("CalamityMod/Sounds/Item/ArsenalOffCooldown"); + public override SoundStyle? EndSound => (Main.zenithWorld ? null : new("CalamityMod/Sounds/Item/ArsenalOffCooldown")); } } diff --git a/Cooldowns/AscendEffect.cs b/Cooldowns/AscendEffect.cs index 645945c14c..2bad018e0e 100644 --- a/Cooldowns/AscendEffect.cs +++ b/Cooldowns/AscendEffect.cs @@ -1,8 +1,6 @@ using Microsoft.Xna.Framework; -using Terraria; using Terraria.Audio; using Terraria.Localization; -using static CalamityMod.CalamityUtils; namespace CalamityMod.Cooldowns { diff --git a/Cooldowns/BubblyBurrow.cs b/Cooldowns/BubblyBurrow.cs new file mode 100644 index 0000000000..0ff4d6f13b --- /dev/null +++ b/Cooldowns/BubblyBurrow.cs @@ -0,0 +1,78 @@ +using System; +using CalamityMod.Items.Armor.Victide; +using CalamityMod.UI; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.Localization; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class BubblyBurrow : CooldownHandler + { + public bool PowerActive => instance.timeLeft > VictideHeadBurrow.BurrowCooldown; + public float PowerPercent => (instance.timeLeft - VictideHeadBurrow.BurrowCooldown) / (float)VictideHeadBurrow.BurrowDuration; + + public static new string ID => "BubblyBurrow"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText("UI.Cooldowns.BubblyBurrow" + (PowerActive ? "Active" : "Cooldown")); + public override string Texture => PowerActive ? "CalamityMod/Cooldowns/BubblyBurrow" : "CalamityMod/Cooldowns/BubblyBurrowCooldown"; + public override string OutlineTexture => "CalamityMod/Cooldowns/BubblyBurrowOutline"; + public override string OverlayTexture => "CalamityMod/Cooldowns/BubblyBurrowOverlay"; + public override Color OutlineColor => new Color(158, 158, 255); + public override Color CooldownStartColor => PowerActive ? Color.Lerp(new Color(255, 170, 204), new Color(72, 125, 204), PowerPercent) : new Color(72, 125, 204); + public override Color CooldownEndColor => PowerActive ? Color.Lerp(new Color(255, 170, 204), new Color(97, 255, 255), PowerPercent) : new Color(97, 255, 255); + public override SoundStyle? EndSound => SoundID.Item85; + + public override void OnCompleted() + { + Vector2 playerVelocity = instance.player.velocity / 8f; + if (!Main.dedServ) + { + for (int i = 0; i < 16; i++) + { + Vector2 bubblePos = instance.player.MountedCenter + Main.rand.NextVector2Circular(50f, 50f); + Vector2 bubbleSpeed = Main.rand.NextVector2Circular(1f, 1f) + playerVelocity; + Gore bubble = Gore.NewGoreDirect(instance.player.GetSource_Misc("1"), bubblePos, bubbleSpeed, 411, Main.rand.NextFloat(0.8f, 1.6f)); + bubble.timeLeft = 24 + Main.rand.Next(13); + bubble.type = 411; + } + } + } + + //Charge down at first, and then charge back up + private float AdjustedCompletion => CooldownRackUI.DebugFullDisplay ? CooldownRackUI.DebugForceCompletion : PowerActive ? PowerPercent : 1 - (instance.timeLeft / (float)VictideHeadBurrow.BurrowCooldown); + + public override void ApplyBarShaders(float opacity) + { + //Use the adjusted completion + GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].Apply(); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = Request(Texture).Value; + Texture2D outline = Request(OutlineTexture).Value; + Texture2D overlay = Request(OverlayTexture).Value; + + //Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + //Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + //Draw the small overlay + int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion); + Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); + spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + } + } +} diff --git a/Cooldowns/BubblyBurrow.png b/Cooldowns/BubblyBurrow.png new file mode 100644 index 0000000000..21b3a91620 Binary files /dev/null and b/Cooldowns/BubblyBurrow.png differ diff --git a/Cooldowns/BubblyBurrowCooldown.png b/Cooldowns/BubblyBurrowCooldown.png new file mode 100644 index 0000000000..2fd459cd2e Binary files /dev/null and b/Cooldowns/BubblyBurrowCooldown.png differ diff --git a/Cooldowns/BubblyBurrowOutline.png b/Cooldowns/BubblyBurrowOutline.png new file mode 100644 index 0000000000..76c2b5b9f7 Binary files /dev/null and b/Cooldowns/BubblyBurrowOutline.png differ diff --git a/Cooldowns/BubblyBurrowOverlay.png b/Cooldowns/BubblyBurrowOverlay.png new file mode 100644 index 0000000000..5327154aa6 Binary files /dev/null and b/Cooldowns/BubblyBurrowOverlay.png differ diff --git a/Cooldowns/CooldownHandler.cs b/Cooldowns/CooldownHandler.cs index 1d8edf5baf..2b7ee32f27 100644 --- a/Cooldowns/CooldownHandler.cs +++ b/Cooldowns/CooldownHandler.cs @@ -9,11 +9,16 @@ using Terraria.ModLoader; namespace CalamityMod.Cooldowns { - public class CooldownHandler + public abstract class CooldownHandler : ModType { public static string ID => null; public CooldownInstance instance; + protected sealed override void Register() + { + ModTypeLookup.Register(this); + } + #region Gameplay Behavior /// /// This method runs once every frame while the cooldown instance is active. diff --git a/Cooldowns/CooldownInstance.cs b/Cooldowns/CooldownInstance.cs index ca8d98120a..44f6687745 100644 --- a/Cooldowns/CooldownInstance.cs +++ b/Cooldowns/CooldownInstance.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Cooldowns // It is possible this cooldown does not exist. If this occurs, log it, even though it will be (mostly) harmless. if (cd is null) { - CalamityMod.Instance.Logger.Warn($"Cooldown \"{id}\" loaded from NBT, but was not found. This cooldown will not be applied to the player."); + CalamityMod.Log.Warn($"Cooldown \"{id}\" loaded from NBT, but was not found. This cooldown will not be applied to the player."); return; } @@ -51,7 +51,7 @@ namespace CalamityMod.Cooldowns if (netID != registeredNetID) { // Log when this occurs, even though it should be harmless. - CalamityMod.Instance.Logger.Warn($"Cooldown \"{id}\" loaded from NBT with discrepant netID {netID}. This cooldown was registered with netID {registeredNetID}"); + CalamityMod.Log.Warn($"Cooldown \"{id}\" loaded from NBT with discrepant netID {netID}. This cooldown was registered with netID {registeredNetID}"); netID = registeredNetID; } player = p; diff --git a/Cooldowns/CooldownRegistry.cs b/Cooldowns/CooldownRegistry.cs index d74cf6cd11..b697488611 100644 --- a/Cooldowns/CooldownRegistry.cs +++ b/Cooldowns/CooldownRegistry.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod.Cooldowns { @@ -12,18 +12,16 @@ namespace CalamityMod.Cooldowns // Indexed by ushort netID. Contains every registered cooldown. // Cooldowns are given netIDs when they are registered. // Cooldowns are useless until they are registered. - public static Cooldown[] registry; + public static Cooldown[] registry = new Cooldown[defaultSize]; private const ushort defaultSize = 256; private static ushort nextCDNetID = 0; - private static Dictionary nameToNetID = null; + private static Dictionary nameToNetID = new Dictionary(defaultSize); - public override void Load() + #region Unused manual registration left here as backup + /*public override void Load() { - registry = new Cooldown[defaultSize]; - nameToNetID = new Dictionary(defaultSize); - - #region Unused manual registration left here as backup + // Vanilla cooldowns represented by the interface //var potionSickness = Register(PotionSickness.ID); //var chaosState = Register(ChaosState.ID); @@ -57,33 +55,30 @@ namespace CalamityMod.Cooldowns //var tarragonCloak = Register(TarragonCloak.ID); //var tarragonImmunity = Register(TarragonImmunity.ID); //var universeSplitter = Register(UniverseSplitter.ID); - #endregion - } + + }*/ + #endregion - public override void OnModLoad() + public override void ResizeArrays() { - Type baseHandlerType = typeof(CooldownHandler); - foreach (Mod mod in ModLoader.Mods) + var cooldowns = ModContent.GetContent(); + var count = cooldowns.Count(); + Array.Resize(ref registry, count); + + MethodInfo registerBaseMethod = typeof(CooldownRegistry).GetMethod(nameof(Register), BindingFlags.Public | BindingFlags.Static); + foreach (var cooldown in cooldowns) { - foreach (Type type in AssemblyManager.GetLoadableTypes(mod.Code)) - { - if (type.IsSubclassOf(baseHandlerType) && !type.IsAbstract && type != baseHandlerType) - { - //Get the static property ID of the handler - string handlerID = (string)type.GetProperty("ID").GetValue(null); + var type = cooldown.GetType(); - //If for whatever reason the ID is not set, create an ID from the mod and handler name - if (handlerID == null) - handlerID = mod.Name + "_" + type.Name; + //Get the static property ID of the handler + string handlerID = (string)type.GetProperty("ID").GetValue(null); - //Use reflection to call the method. You can't use the type as the generic type argument of register here - MethodInfo methodInfo = typeof(CooldownRegistry).GetMethod("Register", BindingFlags.Public | BindingFlags.Static); - Type[] genericArguments = new Type[] { type }; + //If for whatever reason the ID is not set, create an ID from the mod and handler name + handlerID ??= cooldown.FullName; - MethodInfo genericRegister = methodInfo.MakeGenericMethod(genericArguments); - genericRegister.Invoke(null, new object[] { handlerID }); - } - } + //Use reflection to call the method. You can't use the type as the generic type argument of register here + MethodInfo genericRegister = registerBaseMethod.MakeGenericMethod(typeArguments: [type]); + genericRegister.Invoke(null, [handlerID]); } } @@ -118,6 +113,7 @@ namespace CalamityMod.Cooldowns registry[cd.netID] = cd; ++nextCDNetID; + // TODO: Cooldown resizes are not really needed now. Leaving it here just in case. // If the end of the array is reached, double its size. if (nextCDNetID == currentMaxID && currentMaxID < ushort.MaxValue) { diff --git a/Cooldowns/DaawnlightSpiritOriginExtraCrit.cs b/Cooldowns/DaawnlightSpiritOriginExtraCrit.cs index 84f3cfd089..b751a90295 100644 --- a/Cooldowns/DaawnlightSpiritOriginExtraCrit.cs +++ b/Cooldowns/DaawnlightSpiritOriginExtraCrit.cs @@ -1,4 +1,5 @@ -using CalamityMod.CalPlayer; +using System; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -15,7 +16,7 @@ namespace CalamityMod.Cooldowns // If the player doesn't have DSO, this cooldown should not appear. public override bool ShouldDisplay => instance.player.GetModPlayer().spiritOrigin; - private float ExtraCritChance => instance.player.GetModPlayer().spiritOriginCritBoost; + private float ExtraCritChance => Math.Min(instance.player.GetModPlayer().spiritOriginCritBoost, CritHardCap); private float TextXOffset => (ExtraCritChance > 99 ? -24 : ExtraCritChance > 9 ? -20 : -16) * TextScale; private Vector2 TextPosition => new(TextXOffset , 25); diff --git a/Cooldowns/DarklightEnergy.cs b/Cooldowns/DarklightEnergy.cs new file mode 100644 index 0000000000..f4b04d6af7 --- /dev/null +++ b/Cooldowns/DarklightEnergy.cs @@ -0,0 +1,71 @@ +using System; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.Localization; +using static CalamityMod.CalamityUtils; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class DarklightEnergy : CooldownHandler + { + private float AdjustedCompletion => instance.timeLeft / (float)Lucrecia.MaxEnergy; + private Color TextColor => Color.MediumPurple; + private Color TextBorderColor = Color.AntiqueWhite; + + public static new string ID => "DarklightEnergy"; + public override bool CanTickDown => false; + public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType(); + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => $"CalamityMod/Cooldowns/{ID}"; + public override string OutlineTexture => $"CalamityMod/Cooldowns/{ID}Outline"; + public override string OverlayTexture => $"CalamityMod/Cooldowns/{ID}Overlay"; + + public override Color OutlineColor => Color.SlateGray; + public override Color CooldownStartColor => Color.Lerp(Color.Purple, Color.SlateGray, instance.Completion); + public override Color CooldownEndColor => Color.Lerp(Color.DarkBlue, Color.SlateGray, instance.Completion); + + public override void ApplyBarShaders(float opacity) + { + // Use the adjusted completion + GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].Apply(); + } + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + + Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f); + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = Request(Texture).Value; + Texture2D outline = Request(OutlineTexture).Value; + Texture2D overlay = Request(OverlayTexture).Value; + + // Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the small overlay + int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion); + Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); + spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f); + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale); + } + } +} diff --git a/Cooldowns/DarklightEnergy.png b/Cooldowns/DarklightEnergy.png new file mode 100644 index 0000000000..b304337332 Binary files /dev/null and b/Cooldowns/DarklightEnergy.png differ diff --git a/Cooldowns/DarklightEnergyOutline.png b/Cooldowns/DarklightEnergyOutline.png new file mode 100644 index 0000000000..af6bbe9b85 Binary files /dev/null and b/Cooldowns/DarklightEnergyOutline.png differ diff --git a/Cooldowns/DarklightEnergyOverlay.png b/Cooldowns/DarklightEnergyOverlay.png new file mode 100644 index 0000000000..1623d75cba Binary files /dev/null and b/Cooldowns/DarklightEnergyOverlay.png differ diff --git a/Cooldowns/DivingSuitBreakingPlates.png b/Cooldowns/DivingSuitBreakingPlates.png deleted file mode 100644 index ba4481c8c4..0000000000 Binary files a/Cooldowns/DivingSuitBreakingPlates.png and /dev/null differ diff --git a/Cooldowns/DivingSuitBrokenPlates.png b/Cooldowns/DivingSuitBrokenPlates.png deleted file mode 100644 index 8e1026c057..0000000000 Binary files a/Cooldowns/DivingSuitBrokenPlates.png and /dev/null differ diff --git a/Cooldowns/DivingSuitBrokenPlatesOutline.png b/Cooldowns/DivingSuitBrokenPlatesOutline.png deleted file mode 100644 index 64eecea7e1..0000000000 Binary files a/Cooldowns/DivingSuitBrokenPlatesOutline.png and /dev/null differ diff --git a/Cooldowns/DivingSuitBrokenPlatesOverlay.png b/Cooldowns/DivingSuitBrokenPlatesOverlay.png deleted file mode 100644 index 82a575537e..0000000000 Binary files a/Cooldowns/DivingSuitBrokenPlatesOverlay.png and /dev/null differ diff --git a/Cooldowns/DivingSuitCooldowns.cs b/Cooldowns/DivingSuitCooldowns.cs deleted file mode 100644 index 9895bc155e..0000000000 --- a/Cooldowns/DivingSuitCooldowns.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Localization; -using static CalamityMod.CalamityUtils; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Cooldowns -{ - public class DivingPlatesBreaking : CooldownHandler - { - private static Color phase0Color = new Color(147, 218, 183); - private static Color phase1Color = new Color(233, 190, 134); - private static Color phase2Color = new Color(220, 111, 94); - private static Color ringColorLerpStart = new Color(160, 174, 174); - private static Color ringColorLerpEnd = new Color(192, 11, 107); - - public static new string ID => "DivingPlatesBreaking"; - public override bool CanTickDown => !instance.player.Calamity().abyssalDivingSuit; - public override bool ShouldDisplay => instance.player.Calamity().abyssalDivingSuit; - public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}"); - public override string Texture => "CalamityMod/Cooldowns/DivingSuitBreakingPlates"; - public override string OutlineTexture => "CalamityMod/Cooldowns/DivingSuitBrokenPlatesOutline"; - public override string OverlayTexture => "CalamityMod/Cooldowns/DivingSuitBrokenPlatesOverlay"; - public override Color OutlineColor - { - get - { - if (instance.timeLeft == 0) - return phase0Color; - else if (instance.timeLeft == 1) - return phase1Color; - return phase2Color; - } - } - public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); - public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); - - public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) - { - Texture2D sprite = Request(Texture).Value; - Texture2D outline = Request(OutlineTexture).Value; - - //Draw the outline - spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); - //Draw the icon - spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); - - DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (3 - instance.timeLeft).ToString(), position + new Vector2(-3, -3) * scale, CooldownStartColor, Color.Black, scale); - } - } - - public class DivingPlatesBroken : CooldownHandler - { - private static Color ringColorLerpStart = new Color(91, 121, 150); - private static Color ringColorLerpEnd = new Color(30, 50, 77); - - public static new string ID => "DivingPlatesBroken"; - public override bool ShouldDisplay => true; - public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}"); - public override string Texture => "CalamityMod/Cooldowns/DivingSuitBrokenPlates"; - public override Color OutlineColor => new Color(194, 173, 146); - public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); - public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); - - public override void OnCompleted() => instance.player.Calamity().abyssalDivingSuitPlateHits = 0; - } -} diff --git a/Cooldowns/ElementalMastery.cs b/Cooldowns/ElementalMastery.cs new file mode 100644 index 0000000000..01c5e09549 --- /dev/null +++ b/Cooldowns/ElementalMastery.cs @@ -0,0 +1,71 @@ +using System; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.Localization; +using static CalamityMod.CalamityUtils; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class ElementalMastery : CooldownHandler + { + private float AdjustedCompletion => instance.timeLeft / (float) Lightspeed.MaxEnergy; + private Color TextColor => Color.AliceBlue; + private Color TextBorderColor = Color.AntiqueWhite; + + public static new string ID => "ElementalMastery"; + public override bool CanTickDown => false; + public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType(); + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => $"CalamityMod/Cooldowns/{ID}"; + public override string OutlineTexture => $"CalamityMod/Cooldowns/{ID}Outline"; + public override string OverlayTexture => $"CalamityMod/Cooldowns/{ID}Overlay"; + + public override Color OutlineColor => Color.SlateGray; + public override Color CooldownStartColor => Color.Lerp(Color.OrangeRed, Color.SlateGray, instance.Completion); + public override Color CooldownEndColor => Color.Lerp(Color.AliceBlue, Color.SlateGray, instance.Completion); + + public override void ApplyBarShaders(float opacity) + { + // Use the adjusted completion + GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].Apply(); + } + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + + Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f); + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = Request(Texture).Value; + Texture2D outline = Request(OutlineTexture).Value; + Texture2D overlay = Request(OverlayTexture).Value; + + // Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the small overlay + int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion); + Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); + spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + Vector2 textOffset = new Vector2(instance.timeLeft > 9 ? -11f : -6f, 10f); + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + textOffset * scale, TextColor, TextBorderColor, scale); + } + } +} diff --git a/Cooldowns/ElementalMastery.png b/Cooldowns/ElementalMastery.png new file mode 100644 index 0000000000..fb98df7f28 Binary files /dev/null and b/Cooldowns/ElementalMastery.png differ diff --git a/Cooldowns/ElementalMasteryOutline.png b/Cooldowns/ElementalMasteryOutline.png new file mode 100644 index 0000000000..775f2540bb Binary files /dev/null and b/Cooldowns/ElementalMasteryOutline.png differ diff --git a/Cooldowns/ElementalMasteryOverlay.png b/Cooldowns/ElementalMasteryOverlay.png new file mode 100644 index 0000000000..d52f950391 Binary files /dev/null and b/Cooldowns/ElementalMasteryOverlay.png differ diff --git a/Cooldowns/FlameShellParry.png b/Cooldowns/FlameShellParry.png new file mode 100644 index 0000000000..1de70227c2 Binary files /dev/null and b/Cooldowns/FlameShellParry.png differ diff --git a/Cooldowns/FlameShellParryOutline.png b/Cooldowns/FlameShellParryOutline.png new file mode 100644 index 0000000000..6caa5c1762 Binary files /dev/null and b/Cooldowns/FlameShellParryOutline.png differ diff --git a/Cooldowns/FlameShellParryOverlay.png b/Cooldowns/FlameShellParryOverlay.png new file mode 100644 index 0000000000..4a34ae3a0c Binary files /dev/null and b/Cooldowns/FlameShellParryOverlay.png differ diff --git a/Cooldowns/FuryFuel.cs b/Cooldowns/FuryFuel.cs new file mode 100644 index 0000000000..a44ab22975 --- /dev/null +++ b/Cooldowns/FuryFuel.cs @@ -0,0 +1,38 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Localization; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class FuryFuel : CooldownHandler + { + public float CompletionPercentage => MathF.Round(instance.Completion * 100); + private bool IsEmpty => CompletionPercentage == 100; + private float TextXOffset => -5.4f; + private Vector2 TextPosition => new(TextXOffset, 15); + private Color TextColor => Color.White; + private Color TextBorderColor = Color.Violet; + + public static new string ID => "FuryFuel"; + public override bool CanTickDown => false; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType(); + public override string Texture => "CalamityMod/Cooldowns/" + ID; + + public override Color CooldownStartColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.Purple, Color.SlateGray, instance.Completion); + public override Color CooldownEndColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.Orchid, Color.SlateGray, instance.Completion); + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawCompact(spriteBatch, position, opacity, scale); + } + } +} diff --git a/Cooldowns/FuryFuel.png b/Cooldowns/FuryFuel.png new file mode 100644 index 0000000000..6820cf90a0 Binary files /dev/null and b/Cooldowns/FuryFuel.png differ diff --git a/Cooldowns/FuryFuelOutline.png b/Cooldowns/FuryFuelOutline.png new file mode 100644 index 0000000000..9f65a9db98 Binary files /dev/null and b/Cooldowns/FuryFuelOutline.png differ diff --git a/Cooldowns/FuryFuelOverlay.png b/Cooldowns/FuryFuelOverlay.png new file mode 100644 index 0000000000..834115ddfb Binary files /dev/null and b/Cooldowns/FuryFuelOverlay.png differ diff --git a/Cooldowns/GaelsRage.cs b/Cooldowns/GaelsRage.cs index 203f4c598d..1c7717674e 100644 --- a/Cooldowns/GaelsRage.cs +++ b/Cooldowns/GaelsRage.cs @@ -1,6 +1,4 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; +using Microsoft.Xna.Framework; using Terraria.Localization; namespace CalamityMod.Cooldowns diff --git a/Cooldowns/GenericBandCooldown.cs b/Cooldowns/GenericBandCooldown.cs new file mode 100644 index 0000000000..09dc29a690 --- /dev/null +++ b/Cooldowns/GenericBandCooldown.cs @@ -0,0 +1,16 @@ +using Microsoft.Xna.Framework; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class GenericBandCooldown : CooldownHandler + { + public static new string ID => "BandCooldown"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/GenericBandCooldown"; + public override Color OutlineColor => Color.White; + public override Color CooldownStartColor => Color.SlateGray; + public override Color CooldownEndColor => Color.Gray; + } +} diff --git a/Cooldowns/GenericBandCooldown.png b/Cooldowns/GenericBandCooldown.png new file mode 100644 index 0000000000..afdfd5d97a Binary files /dev/null and b/Cooldowns/GenericBandCooldown.png differ diff --git a/Cooldowns/GenericBandCooldownOutline.png b/Cooldowns/GenericBandCooldownOutline.png new file mode 100644 index 0000000000..ece251f504 Binary files /dev/null and b/Cooldowns/GenericBandCooldownOutline.png differ diff --git a/Cooldowns/GenericBandCooldownOverlay.png b/Cooldowns/GenericBandCooldownOverlay.png new file mode 100644 index 0000000000..f89301304d Binary files /dev/null and b/Cooldowns/GenericBandCooldownOverlay.png differ diff --git a/Cooldowns/HellbornShots.cs b/Cooldowns/HellbornShots.cs index b421fc8b98..15f525bcc9 100644 --- a/Cooldowns/HellbornShots.cs +++ b/Cooldowns/HellbornShots.cs @@ -1,14 +1,8 @@ using System; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; using Terraria.GameContent; -using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.Localization; using static Terraria.ModLoader.ModContent; diff --git a/Cooldowns/KillMode.cs b/Cooldowns/KillMode.cs index 6735a94ae1..d80832e0ab 100644 --- a/Cooldowns/KillMode.cs +++ b/Cooldowns/KillMode.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.Localization; using static Terraria.ModLoader.ModContent; diff --git a/Cooldowns/M1GarandShots.cs b/Cooldowns/M1GarandShots.cs new file mode 100644 index 0000000000..200f8d1c05 --- /dev/null +++ b/Cooldowns/M1GarandShots.cs @@ -0,0 +1,43 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using Terraria.Localization; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class M1GarandShots : CooldownHandler + { + public float CompletionPercentage => MathF.Round(instance.Completion * 100); + private bool IsEmpty => CompletionPercentage == 100; + private float TextXOffset => -5.4f; + private Vector2 TextPosition => new(TextXOffset, 15); + private Color TextColor => Color.Silver; + private Color TextBorderColor = Color.DarkGoldenrod; + + public static new string ID => "M1GarandShots"; + public override bool CanTickDown => false; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override bool ShouldDisplay => instance.player.HeldItem.type == ItemType(); + public override string Texture => "CalamityMod/Cooldowns/" + ID; + + public override Color CooldownStartColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.DarkGoldenrod, Color.SlateGray, instance.Completion); + public override Color CooldownEndColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.LightGoldenrodYellow, Color.SlateGray, instance.Completion); + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.player.Calamity().garandShots.ToString(), position + TextPosition, TextColor, TextBorderColor); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawCompact(spriteBatch, position, opacity, scale); + + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.player.Calamity().garandShots.ToString(), position + TextPosition, TextColor, TextBorderColor); + } + } +} diff --git a/Cooldowns/M1GarandShots.png b/Cooldowns/M1GarandShots.png new file mode 100644 index 0000000000..b50e512ae9 Binary files /dev/null and b/Cooldowns/M1GarandShots.png differ diff --git a/Cooldowns/M1GarandShotsOutline.png b/Cooldowns/M1GarandShotsOutline.png new file mode 100644 index 0000000000..495f87eb5c Binary files /dev/null and b/Cooldowns/M1GarandShotsOutline.png differ diff --git a/Cooldowns/M1GarandShotsOverlay.png b/Cooldowns/M1GarandShotsOverlay.png new file mode 100644 index 0000000000..4d8b9e04e8 Binary files /dev/null and b/Cooldowns/M1GarandShotsOverlay.png differ diff --git a/Cooldowns/OceanShieldParry.png b/Cooldowns/OceanShieldParry.png new file mode 100644 index 0000000000..37027d530c Binary files /dev/null and b/Cooldowns/OceanShieldParry.png differ diff --git a/Cooldowns/OceanShieldParryOutline.png b/Cooldowns/OceanShieldParryOutline.png new file mode 100644 index 0000000000..19d632eb2f Binary files /dev/null and b/Cooldowns/OceanShieldParryOutline.png differ diff --git a/Cooldowns/OceanShieldParryOverlay.png b/Cooldowns/OceanShieldParryOverlay.png new file mode 100644 index 0000000000..30c0030cd3 Binary files /dev/null and b/Cooldowns/OceanShieldParryOverlay.png differ diff --git a/Cooldowns/PanaceaCooldown.cs b/Cooldowns/PanaceaCooldown.cs new file mode 100644 index 0000000000..cc2e416f71 --- /dev/null +++ b/Cooldowns/PanaceaCooldown.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using Terraria.Audio; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class PanaceaCooldown : CooldownHandler + { + public static new string ID => "Panacea"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/PanaceaCooldown"; + public override Color OutlineColor => new Color(122, 198, 255); + public override Color CooldownStartColor => new Color(0, 128, 255); + public override Color CooldownEndColor => new Color(0, 255, 255); + public override SoundStyle? EndSound => new("CalamityMod/Sounds/Custom/AbilitySounds/PotionSicknessOver"); + } +} diff --git a/Cooldowns/PanaceaCooldown.png b/Cooldowns/PanaceaCooldown.png new file mode 100644 index 0000000000..290132735c Binary files /dev/null and b/Cooldowns/PanaceaCooldown.png differ diff --git a/Cooldowns/PanaceaCooldownOutline.png b/Cooldowns/PanaceaCooldownOutline.png new file mode 100644 index 0000000000..f31edcf0b4 Binary files /dev/null and b/Cooldowns/PanaceaCooldownOutline.png differ diff --git a/Cooldowns/PanaceaCooldownOverlay.png b/Cooldowns/PanaceaCooldownOverlay.png new file mode 100644 index 0000000000..7d72fd3769 Binary files /dev/null and b/Cooldowns/PanaceaCooldownOverlay.png differ diff --git a/Cooldowns/ParryCooldown.cs b/Cooldowns/ParryCooldown.cs index c226732eb7..fa400a7016 100644 --- a/Cooldowns/ParryCooldown.cs +++ b/Cooldowns/ParryCooldown.cs @@ -30,17 +30,14 @@ namespace CalamityMod.Cooldowns cooldownColorStart = new Color(181, 136, 177); cooldownColorEnd = new Color(255, 194, 161); break; - - //readd if spritework for the cooldown is done at a later point - /*case "flamelickedshell": - skinTexture = "FlameLickedShellParry"; + case "flamelickedshell": + skinTexture = "FlameShellParry"; outlineColor = new Color(211, 124, 93); - cooldownColorStart = Color.Lerp(new Color(107, 6, 6), new Color(228, 78, 78), 1 - (instance?.Completion ?? 0)); - cooldownColorEnd = Color.Lerp(new Color(107, 6, 6), new Color(228, 78, 78), 1 - (instance?.Completion ?? 0)); - break;*/ + cooldownColorStart = new Color(107, 6, 6); + cooldownColorEnd = new Color(228, 78, 78); + break; case "shieldoftheocean": - // skinTexture = "ShieldOfTheOceanParry"; - skinTexture = "ParryCooldown"; + skinTexture = "OceanShieldParry"; outlineColor = Color.White; cooldownColorStart = new Color(233, 111, 165); cooldownColorEnd = new Color(105, 139, 148); diff --git a/Cooldowns/RaiderBoost.cs b/Cooldowns/RaiderBoost.cs new file mode 100644 index 0000000000..79bb9ae02d --- /dev/null +++ b/Cooldowns/RaiderBoost.cs @@ -0,0 +1,45 @@ +using Microsoft.Xna.Framework; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class RaiderBoost : CooldownHandler + { + public static new string ID => "RaidersBoost"; + + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + + public override string Texture => "CalamityMod/Cooldowns/" + skinTexture; + public override Color OutlineColor => outlineColor; + public override Color CooldownStartColor => Color.Lerp(cooldownColorStart, cooldownColorEnd, 1 - instance.Completion); + public override Color CooldownEndColor => Color.Lerp(cooldownColorStart, cooldownColorEnd, 1 - instance.Completion); + + //It's the same cooldown with different skins each time, basically. + public string skinTexture; + public Color outlineColor; + public Color cooldownColorStart; + public Color cooldownColorEnd; + + public RaiderBoost() : this("") { } + public RaiderBoost(string skin) + { + switch (skin) + { + case "Bloodfeast": + skinTexture = "VampiricTalismanBoost"; + outlineColor = new Color(143, 27, 27); + cooldownColorStart = new Color(133, 5, 5); + cooldownColorEnd = new Color(255, 0, 0); + break; + + default: + skinTexture = "RaiderBoost"; + outlineColor = new Color(122, 97, 77); + cooldownColorStart = new Color(168, 122, 86); + cooldownColorEnd = new Color(74, 60, 49); + break; + } + } + } +} diff --git a/Cooldowns/RaiderBoost.png b/Cooldowns/RaiderBoost.png new file mode 100644 index 0000000000..9e34eeb520 Binary files /dev/null and b/Cooldowns/RaiderBoost.png differ diff --git a/Cooldowns/RaiderBoostOutline.png b/Cooldowns/RaiderBoostOutline.png new file mode 100644 index 0000000000..f2964069b8 Binary files /dev/null and b/Cooldowns/RaiderBoostOutline.png differ diff --git a/Cooldowns/RaiderBoostOverlay.png b/Cooldowns/RaiderBoostOverlay.png new file mode 100644 index 0000000000..630cad2d91 Binary files /dev/null and b/Cooldowns/RaiderBoostOverlay.png differ diff --git a/Cooldowns/SpeedBlasterBoost.cs b/Cooldowns/SpeedBlasterBoost.cs index b12f4dd065..c512de19a8 100644 --- a/Cooldowns/SpeedBlasterBoost.cs +++ b/Cooldowns/SpeedBlasterBoost.cs @@ -1,8 +1,5 @@ using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; using Terraria.Localization; -using static CalamityMod.CalamityUtils; namespace CalamityMod.Cooldowns { diff --git a/Cooldowns/Starburst.cs b/Cooldowns/Starburst.cs new file mode 100644 index 0000000000..d91bd2f585 --- /dev/null +++ b/Cooldowns/Starburst.cs @@ -0,0 +1,51 @@ +using System; +using System.Windows.Markup; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.Localization; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class Starburst : CooldownHandler + { + public float CompletionPercentage => MathF.Round(instance.Completion * 100); + private bool IsEmpty => CompletionPercentage == 100; + private float TextXOffset => -5.4f; + private Vector2 TextPosition => new(TextXOffset, 15); + private Color TextColor => Color.Lerp(Color.LightSkyBlue,Color.White,(MathF.Sin(Main.GlobalTimeWrappedHourly)+1)*0.5f); + private Color TextBorderColor = Color.DarkSlateBlue; + + public static new string ID => "Starburst"; + public override bool CanTickDown => false; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override bool ShouldDisplay => instance.player.Calamity().StratusStarburstResetTimer > 0; + public override string Texture => "CalamityMod/Cooldowns/" + ID; + + public override Color CooldownStartColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.SkyBlue, Color.DeepSkyBlue, instance.Completion); + public override Color CooldownEndColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.SkyBlue, Color.DeepSkyBlue, instance.Completion); + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + var value = CalamityPlayer.MaxStratusStarburst - instance.timeLeft; + float Xoffset = value > 9 ? value > 99 ? -12.5f : -10f : -5; + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (value).ToString(), position + new Vector2(Xoffset, 4) * scale, TextColor, TextBorderColor, scale); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawCompact(spriteBatch, position, opacity, scale); + + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, MathHelper.Min(instance.player.Calamity().StratusStarburst, CalamityPlayer.MaxStratusStarburst).ToString(), position + TextPosition, TextColor, TextBorderColor); + } + } +} diff --git a/Cooldowns/Starburst.png b/Cooldowns/Starburst.png new file mode 100644 index 0000000000..c26c15edbc Binary files /dev/null and b/Cooldowns/Starburst.png differ diff --git a/Cooldowns/StarburstOutline.png b/Cooldowns/StarburstOutline.png new file mode 100644 index 0000000000..e6ef26af23 Binary files /dev/null and b/Cooldowns/StarburstOutline.png differ diff --git a/Cooldowns/StarburstOverlay.png b/Cooldowns/StarburstOverlay.png new file mode 100644 index 0000000000..1411fa6ccc Binary files /dev/null and b/Cooldowns/StarburstOverlay.png differ diff --git a/Cooldowns/SuperradiantSawBoost.cs b/Cooldowns/SuperradiantSawBoost.cs index 17371e2aa1..0fa9363e0d 100644 --- a/Cooldowns/SuperradiantSawBoost.cs +++ b/Cooldowns/SuperradiantSawBoost.cs @@ -1,6 +1,4 @@ using Microsoft.Xna.Framework; -using System; -using Terraria; using Terraria.Localization; namespace CalamityMod.Cooldowns diff --git a/Cooldowns/VampiricTalismanBoost.png b/Cooldowns/VampiricTalismanBoost.png new file mode 100644 index 0000000000..fa87b4b68c Binary files /dev/null and b/Cooldowns/VampiricTalismanBoost.png differ diff --git a/Cooldowns/VampiricTalismanBoostOutline.png b/Cooldowns/VampiricTalismanBoostOutline.png new file mode 100644 index 0000000000..7cf25cffc7 Binary files /dev/null and b/Cooldowns/VampiricTalismanBoostOutline.png differ diff --git a/Cooldowns/VampiricTalismanBoostOverlay.png b/Cooldowns/VampiricTalismanBoostOverlay.png new file mode 100644 index 0000000000..85ed189dba Binary files /dev/null and b/Cooldowns/VampiricTalismanBoostOverlay.png differ diff --git a/Cooldowns/WarbanneroftheRighteousBuff.cs b/Cooldowns/WarbanneroftheRighteousBuff.cs index 78ddea9b66..fddaf7839f 100644 --- a/Cooldowns/WarbanneroftheRighteousBuff.cs +++ b/Cooldowns/WarbanneroftheRighteousBuff.cs @@ -1,24 +1,16 @@ -using System; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.GameContent; -using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.Localization; -using static Terraria.ModLoader.ModContent; namespace CalamityMod.Cooldowns { public class WarbanneroftheRighteousBuff : CooldownHandler { - public float CompletionPercentage => Utils.GetLerpValue(80, 0, instance.timeLeft); + public float CompletionPercentage => Utils.GetLerpValue(70, 0, instance.timeLeft); private bool IsEmpty => CompletionPercentage == 0; - private float TextXOffset => (instance.timeLeft <= 20 ? -11 : -18f); + private float TextXOffset => instance.timeLeft <= 20 ? -11f : -18f; private Vector2 TextPosition => new(TextXOffset, 15); private Color TextColor => Color.White; private Color TextBorderColor => Color.Black; @@ -36,14 +28,14 @@ namespace CalamityMod.Cooldowns { base.DrawExpanded(spriteBatch, position, opacity, scale); - CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (-instance.timeLeft + 20).ToString() + "%", position + TextPosition, TextColor, TextBorderColor); + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (-instance.timeLeft + 15).ToString() + "%", position + TextPosition, TextColor, TextBorderColor); } public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) { base.DrawCompact(spriteBatch, position, opacity, scale); - CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (-instance.timeLeft + 20).ToString() + "%", position + TextPosition, TextColor, TextBorderColor); + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, (-instance.timeLeft + 15).ToString() + "%", position + TextPosition, TextColor, TextBorderColor); } } } diff --git a/Cooldowns/WardingWave.cs b/Cooldowns/WardingWave.cs new file mode 100644 index 0000000000..dd18e02873 --- /dev/null +++ b/Cooldowns/WardingWave.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class WardingWave : CooldownHandler + { + public static new string ID => "WardingWave"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText("UI.Cooldowns.WardingWave"); + public override string Texture => "CalamityMod/Cooldowns/WardingWave"; + public override Color OutlineColor => new Color(158, 158, 255); + public override Color CooldownStartColor => new Color(72, 125, 204); + public override Color CooldownEndColor => new Color(255, 170, 204); + public override SoundStyle? EndSound => SoundID.Item85; + } +} diff --git a/Cooldowns/WardingWave.png b/Cooldowns/WardingWave.png new file mode 100644 index 0000000000..3f5e446cc0 Binary files /dev/null and b/Cooldowns/WardingWave.png differ diff --git a/Cooldowns/WardingWaveOutline.png b/Cooldowns/WardingWaveOutline.png new file mode 100644 index 0000000000..676bef5365 Binary files /dev/null and b/Cooldowns/WardingWaveOutline.png differ diff --git a/Cooldowns/WardingWaveOverlay.png b/Cooldowns/WardingWaveOverlay.png new file mode 100644 index 0000000000..357b1a5fcf Binary files /dev/null and b/Cooldowns/WardingWaveOverlay.png differ diff --git a/Cooldowns/WulfrumBastion.cs b/Cooldowns/WulfrumBastion.cs index c86f277c1b..3920a3def9 100644 --- a/Cooldowns/WulfrumBastion.cs +++ b/Cooldowns/WulfrumBastion.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; +using Terraria.ID; using Terraria.Localization; using static Terraria.ModLoader.ModContent; @@ -33,7 +34,7 @@ namespace CalamityMod.Cooldowns for (int i = 0; i < 6; i++) { Vector2 dustDirection = Main.rand.NextVector2CircularEdge(1f, 1f); - Dust d = Dust.NewDustPerfect(instance.player.Center + dustDirection * Main.rand.NextFloat(0.4f, 10f), 226, dustDirection * Main.rand.NextFloat(1f, 4f), 100, Color.Transparent, Main.rand.NextFloat(0.8f, 1.2f)); + Dust d = Dust.NewDustPerfect(instance.player.Center + dustDirection * Main.rand.NextFloat(0.4f, 10f), DustID.Electric, dustDirection * Main.rand.NextFloat(1f, 4f), 100, Color.Transparent, Main.rand.NextFloat(0.8f, 1.2f)); d.noGravity = true; d.noLight = true; d.fadeIn = 1f; diff --git a/Cooldowns/WulfrumRoverDriveCooldowns.cs b/Cooldowns/WulfrumRoverDriveCooldowns.cs index e4c6485992..9df995f04a 100644 --- a/Cooldowns/WulfrumRoverDriveCooldowns.cs +++ b/Cooldowns/WulfrumRoverDriveCooldowns.cs @@ -91,12 +91,14 @@ namespace CalamityMod.Cooldowns public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); + public override void Tick() => instance.player.Calamity().playedRoverDriveShieldSound = false; + // Rover Drive shields are recharged as a side effect of the cooldown completing client side public override void OnCompleted() { CalamityPlayer modPlayer = instance.player.Calamity(); - if (modPlayer.roverDrive) - modPlayer.RoverDriveShieldDurability = RoverDrive.ShieldDurabilityMax; + if (modPlayer.RoverDriveShieldDurability <= 0) + modPlayer.RoverDriveShieldDurability = 1; } public override SoundStyle? EndSound => RoverDrive.ActivationSound; public override bool ShouldPlayEndSound => instance.player.Calamity().roverDrive; diff --git a/CustomRecipes/ArsenalTierGatedRecipe.cs b/CustomRecipes/ArsenalTierGatedRecipe.cs index 84f83c9513..345171a1ba 100644 --- a/CustomRecipes/ArsenalTierGatedRecipe.cs +++ b/CustomRecipes/ArsenalTierGatedRecipe.cs @@ -1,5 +1,4 @@ using System; -using Terraria; using Terraria.Localization; namespace CalamityMod.CustomRecipes diff --git a/CustomRecipes/SchematicRecipe.cs b/CustomRecipes/SchematicRecipe.cs index 5882318223..0363382e87 100644 --- a/CustomRecipes/SchematicRecipe.cs +++ b/CustomRecipes/SchematicRecipe.cs @@ -1,5 +1,4 @@ using System; -using Terraria; using Terraria.Localization; namespace CalamityMod.CustomRecipes diff --git a/DataStructures/Attunement.cs b/DataStructures/Attunement.cs index 683b8a49b1..9599aea147 100644 --- a/DataStructures/Attunement.cs +++ b/DataStructures/Attunement.cs @@ -1,10 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Enums; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; @@ -508,11 +505,7 @@ namespace CalamityMod.DataStructures { if (Procced) { - if (!player.moonLeech) - { - player.HealPlayer(OmegaBiomeBlade.SuperPogoAttunement_PassiveLifeSteal); - } - + player.DoLifestealDirect(null, OmegaBiomeBlade.SuperPogoAttunement_PassiveLifeSteal); Procced = false; } } @@ -577,7 +570,7 @@ namespace CalamityMod.DataStructures item.shootSpeed = 12f; item.UseSound = null; item.noMelee = true; - item.reuseDelay = 30; + item.reuseDelay = 12; } } @@ -602,7 +595,7 @@ namespace CalamityMod.DataStructures item.shootSpeed = 12f; item.UseSound = null; item.noMelee = true; - item.reuseDelay = 30; + item.reuseDelay = 12; } } @@ -653,7 +646,7 @@ namespace CalamityMod.DataStructures item.shootSpeed = 12f; item.UseSound = null; item.noMelee = true; - item.reuseDelay = 30; + item.reuseDelay = 12; } } diff --git a/DataStructures/DebuffData.cs b/DataStructures/DebuffData.cs new file mode 100644 index 0000000000..743b703740 --- /dev/null +++ b/DataStructures/DebuffData.cs @@ -0,0 +1,440 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.WorldBuilding; + +namespace CalamityMod.DataStructures +{ + [ReinitializeDuringResizeArrays] + public static class BuffDatasets + { + public static DebuffData[] DebuffDataset = BuffID.Sets.Factory.CreateNamedSet("DebuffData") + .Description("Stores DebuffData for a particular debuff") + .RegisterCustomSet(null, + BuffID.OnFire, DebuffData.OnFire, + BuffID.OnFire3, DebuffData.Hellfire, + BuffID.CursedInferno, DebuffData.CursedInferno, + BuffID.ShadowFlame, DebuffData.Shadowflame, + BuffID.Daybreak, DebuffData.Daybroken, + BuffID.Burning, DebuffData.Burning, + BuffID.Frostburn, DebuffData.Frostburn, + BuffID.Frostburn2, DebuffData.Frostbite, + BuffID.Poisoned, DebuffData.Poisoned, + BuffID.Venom, DebuffData.AcidVenom, + BuffID.Electrified, DebuffData.Electrified, + BuffID.Oiled, DebuffData.Oiled + ); + } + public class DebuffData + { + /// + /// Determines the behavior of the debuff. + /// + public enum DebuffBehavior + { + Default, + Electric + } + #region DebuffData data + /// + /// UNIMPLEMENTED. WILL BE DONE IN A FUTURE PR + /// Amount of life regen lost by a player under this debuff + /// For debuffs with unique scaling, this should usually be the "base" amount. + /// Defaults to 0 + /// + public float PlayerLostRegen = 0; + + /// + /// Amount of life regen lost by an enemy under this debuff. + /// For debuffs with unique scaling, this should usually be the "base" amount. + /// Defaults to 0 + /// + public float EnemyLostRegen = 0; + + /// + /// This is used to cancel Vanilla DoT damage on enemies and allow using Calamity's own instead. + /// + public int EnemyVanillaRegenToCancelOut = 0; + + /// + /// The minimum size of damage ticks from this debuff on an enemy. + /// Ticks can be larger than this due to MultiplierDamageTickSize + /// Defaults to 1 + /// + public int MinimumDamageTickSize = 1; + + /// + /// The size of damage ticks from this debuff on an enemy + /// This is based on the applied regen of the debuff, and will cause the tick to scale with amplifiers + /// Ticks can be larger than this due to MinimumDamageTickSize + /// Defaults to 0.25f + /// + public float MultiplierDamageTickSize = 0.25f; + + /// + /// How much this benefits from heat debuff amplifiers. + /// Default is 0, which means it does not benefit. + /// + public float HeatDebuffScaling = 0; + /// + /// How much this benefits from sickness debuff amplifiers. + /// Default is 0, which means it does not benefit. + /// + public float SicknessDebuffScaling = 0; + /// + /// How much this benefits from cold debuff amplifiers. + /// Default is 0, which means it does not benefit. + /// + public float ColdDebuffScaling = 0; + /// + /// How much this benefits from water debuff amplifiers. + /// Default is 0, which means it does not benefit. + /// + public float WaterDebuffScaling = 0; + /// + /// How much this benefits from electric debuff amplifiers. + /// Default is 0, which means it does not benefit. + /// + public float ElectricDebuffScaling = 0; + + /// + /// UNIMPLEMENTED. WILL BE DONE IN A FUTURE PR + /// Whether or not this debuff should draw above inflicted NPCs. + /// Defaults to TRUE + /// + public bool DrawAboveNPC = true; + + /// + /// UNIMPLEMENTED. WILL BE DONE IN A FUTURE PR + /// Whether or not gear can modify the debuff effects such as duration or damage on the player. + /// + public bool GearCanModifyDebuff = true; + + /// + /// UNIMPLEMENTED. WILL BE DONE IN A FUTURE PR + /// How much alcohol this counts as. + /// Default is 0, most alcohol is 1, and Everclear is 2 + /// + public float AlcoholLevel = 0f; + + /// + /// UNIMPLEMENTED. WILL BE DONE IN A FUTURE PR + /// The UpdatePlayerLifeRegen code to run. Defaults to just applying DoT + /// + public UpdatePlayerLifeRegen PlayerUpdateMethod; + + /// + /// The UpdateNPCLifeRegen code to run. Defaults to just applying DoT + /// Parameters of the method should be (NPC npc, int buffType, ref int buffIndex, ref int damage) + /// + public UpdateNPCLifeRegen NPCLifeRegenMethod; + + public DebuffData() + { + PlayerUpdateMethod = DefaultUpdateOnPlayer; + NPCLifeRegenMethod = BaseUpdateNPCLifeRegen; + } + /// + /// Allows using DebuffBehavior to determine preset behavior + /// "electric" causes debuffs to scale 4x when moving + /// Uses default behavior if no known key is inputed + /// + /// This determines the type of behavior of the debuff + public DebuffData(DebuffBehavior behavior) + { + + PlayerUpdateMethod = DefaultUpdateOnPlayer; + if (behavior == DebuffBehavior.Electric) + NPCLifeRegenMethod = ElectricDebuffNPCLifeRegen; + else + NPCLifeRegenMethod = BaseUpdateNPCLifeRegen; + } + + /// + /// UNIMPLEMENTED. WILL BE IN A FUTURE PR + /// This is the code that should be run when updating the buff on a player. + /// Use for DoT damage. Other effects should be in the ModBuff class, or wherever appropriate. + /// + /// + public delegate void UpdatePlayerLifeRegen(Player player, int buffType, ref int buffIndex, ref int damage); + + /// + /// This is the code that should be run when updating life regen on NPC + /// Use for DoT damage. Other effects should be in the ModBuff class, or wherever appropriate. + /// + /// + public delegate void UpdateNPCLifeRegen(NPC npc, int buffType, ref int buffIndex, ref int damage); + + /// + /// Applies a scaling amount to a StatModifer + /// + /// + /// + /// + public static StatModifier ApplyScalingToStatModifer(StatModifier Modifer, float scaling) + { + StatModifier output = new(); + output += (Modifer.Additive-1) * scaling; + output *= 1 + (Modifer.Multiplicative-1) * scaling; + output.Base = Modifer.Base * scaling; + output.Flat = Modifer.Flat * scaling; + return output; + } + /// + /// Applies a scaling amount to a StatModifier but ensures all changes end up positive + /// + /// + /// + /// + public static StatModifier ForceModifierPositiveWithScaling(StatModifier Modifer, float scaling) + { + StatModifier output = new(); + output += MathHelper.Max((Modifer.Additive - 1) * scaling,0); + output *= MathHelper.Max(1 + (Modifer.Multiplicative - 1) * scaling,1); + output.Base = MathHelper.Max(Modifer.Base * scaling,0); + output.Flat = MathHelper.Max(Modifer.Flat * scaling, 0); + return output; + } + + /// + /// UNIMPLEMENTED. WILL BE IN A FUTURE PR + /// The default debuff DoT functionality on a player + /// + public void DefaultUpdateOnPlayer(Player player, int buffType, ref int buffIndex, ref int damage) + { + + } + + /// + /// The default debuff DoT functionality on enemies. + /// + public void BaseUpdateNPCLifeRegen(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + var cnpc = npc.Calamity(); + float totalDPS = EnemyLostRegen; + StatModifier totalScaling = + HeatDebuffScaling + ColdDebuffScaling + SicknessDebuffScaling + WaterDebuffScaling + ElectricDebuffScaling != 0 + ? + ApplyScalingToStatModifer(cnpc.ActiveHeatDebuffMultiplier, HeatDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveColdDebuffMultiplier, ColdDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveSicknessDebuffMultiplier, SicknessDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveWaterDebuffMultiplier, WaterDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveElectricDebuffMultiplier, ElectricDebuffScaling) + )))) + : + cnpc.ActiveTypelessDebuffMultiplier; + + //Ensure at least 25% effectiveness + if (totalScaling.Multiplicative <= 0.25f) + totalScaling.Multiplicative = 0.25f; + if (totalScaling.Additive < 0.25f) + totalScaling.Additive = 0.25f; + + totalDPS = totalScaling.ApplyTo(totalDPS); + var totalDPSAdjusted = totalDPS-EnemyVanillaRegenToCancelOut; + npc.Calamity().ApplyDPSDebuff((int)(totalDPSAdjusted), (int)Math.Max(totalDPS*MultiplierDamageTickSize,MinimumDamageTickSize), ref npc.lifeRegen, ref damage); + } + /// + /// DoT functionality that takes into account Electric debuff's 4x DPS when moving + /// + /// + /// + /// + /// + public void ElectricDebuffNPCLifeRegen(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + var cnpc = npc.Calamity(); + float totalDPS = EnemyLostRegen; + StatModifier totalScaling = + HeatDebuffScaling + ColdDebuffScaling + SicknessDebuffScaling + WaterDebuffScaling + ElectricDebuffScaling != 0 + ? + ApplyScalingToStatModifer(cnpc.ActiveHeatDebuffMultiplier, HeatDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveColdDebuffMultiplier, ColdDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveSicknessDebuffMultiplier, SicknessDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveWaterDebuffMultiplier, WaterDebuffScaling) + .CombineWith(ApplyScalingToStatModifer(cnpc.ActiveElectricDebuffMultiplier, ElectricDebuffScaling) + )))) + : + cnpc.ActiveTypelessDebuffMultiplier; + + //Ensure at least 25% effectiveness + if (totalScaling.Multiplicative <= 0.25f) + totalScaling.Multiplicative = 0.25f; + if (totalScaling.Additive < 0.25f) + totalScaling.Additive = 0.25f; + + totalDPS = totalScaling.ApplyTo(totalDPS); + totalDPS *= (npc.velocity.X == 0 ? 1 : 4); + totalDPS -= EnemyVanillaRegenToCancelOut * (npc.velocity.X == 0 ? 1 : 5); //Vanilla Electrified is 5x when moving, not 4x + npc.Calamity().ApplyDPSDebuff((int)(totalDPS), (int)Math.Max(totalDPS * MultiplierDamageTickSize, MinimumDamageTickSize), ref npc.lifeRegen, ref damage); + } + #region Special Regen Functions + /// + /// 18OCT2023: Ozzatron: im not gonna sugarcoat it
+ /// Vanilla debuff damage from Daybreak impales scales linearly up to 8 for 800 DPS.
+ /// Instead of allowing this entire 800 DPS to be multiplied by heat weakness + heat DoT bonuses, additional Daybreak spears beyond the first do not contribute to weaknesses or resistances.
+ /// This also stops Daybreak's DPS from being utterly shafted by heat resistance.
+ /// As no other weapon can stack Daybroken, this has no effect on other weapons (they count as "1 Daybreak spear") + ///
+ /// + /// + /// + /// + public static void DaybrokenRegen(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + var cnpc = npc.Calamity(); + int numImpaledSpears = 0; + foreach (Projectile k in Main.ActiveProjectiles) + { + if (k.type == ProjectileID.Daybreak && k.ai[0] == 1f && k.ai[1] == npc.whoAmI) + numImpaledSpears++; + } + + // If there are no Daybreak impaled spears, Daybroken has 1x potency (it was applied some other way) + int adjustedSpears = Math.Max(1, numImpaledSpears); + int baseDaybreakDoTValue = (int)(npc.Calamity().ActiveHeatDebuffMultiplier.ApplyTo(Daybroken.EnemyLostRegen) + (Daybroken.EnemyLostRegen * (adjustedSpears - 1))); + int totalDPSAdjusted = baseDaybreakDoTValue - Daybroken.EnemyVanillaRegenToCancelOut*numImpaledSpears; + if (numImpaledSpears == 0) + { + totalDPSAdjusted -= Daybroken.EnemyVanillaRegenToCancelOut; + } + npc.Calamity().ApplyDPSDebuff(totalDPSAdjusted, (int)Math.Max(baseDaybreakDoTValue * Daybroken.MultiplierDamageTickSize, Daybroken.MinimumDamageTickSize), ref npc.lifeRegen, ref damage); + } + /// + /// Apply Oiled DoT. + /// + public static void OiledNPCMethod(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + var cnpc = npc.Calamity(); + double totalDPS = ApplyScalingToStatModifer(cnpc.ActiveHeatDebuffMultiplier,Oiled.HeatDebuffScaling).ApplyTo(Oiled.EnemyLostRegen); + if (totalDPS <= 0) + return; + npc.Calamity().ApplyDPSDebuff((int)(totalDPS), damage+(int)Math.Max(totalDPS * Oiled.MultiplierDamageTickSize, Oiled.MinimumDamageTickSize), ref npc.lifeRegen, ref damage); + } + /// + /// Has Dryad's Bane scale with Calamity's town NPC buffs + /// + public static void DryadsBaneNPCMethod(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + // Buffs match 1:1 with Town NPC buffs + // See CalamityGlobalTownNPC: BuffTownNPC + float buffedDryadsBaneMult = 0f + + (NPC.downedMoonlord ? 0.6f : 0f) + + (DownedBossSystem.downedProvidence ? 0.2f : 0f) + + (DownedBossSystem.downedPolterghast ? 0.2f : 0f) + + (DownedBossSystem.downedDoG ? 0.2f : 0f) + + (DownedBossSystem.downedYharon ? 0.2f : 0f) + + (DownedBossSystem.downedExoMechs ? 0.6f : 0f) + + (DownedBossSystem.downedCalamitas ? 0.6f : 0f); + if (Main.expertMode) + buffedDryadsBaneMult *= Main.GameModeInfo.TownNPCDamageMultiplier; + int buffedDryadsBaneDoTValue = 2 * (int)(4 * buffedDryadsBaneMult); + npc.lifeRegen -= buffedDryadsBaneDoTValue; + + // Scales damage tick if greater than the vanilla amount + float vanillaDryadsBaneMult = 1f + + (NPC.downedBoss1 ? 0.1f : 0f) + + (NPC.downedBoss2 ? 0.1f : 0f) + + (NPC.downedBoss3 ? 0.1f : 0f) + + (NPC.downedQueenBee ? 0.1f : 0f) + + (Main.hardMode ? 0.4f : 0f) + + (NPC.downedMechBoss1 ? 0.15f : 0f) + + (NPC.downedMechBoss1 ? 0.15f : 0f) + + (NPC.downedMechBoss1 ? 0.15f : 0f) + + (NPC.downedPlantBoss ? 0.15f : 0f) + + (NPC.downedGolemBoss ? 0.15f : 0f) + + (NPC.downedAncientCultist ? 0.15f : 0f); + if (Main.expertMode) + vanillaDryadsBaneMult *= Main.GameModeInfo.TownNPCDamageMultiplier; + int totalDryadsBaneDoTValue = 2 * (int)(4 * vanillaDryadsBaneMult) + buffedDryadsBaneDoTValue; + if (damage < totalDryadsBaneDoTValue / 6) + damage = totalDryadsBaneDoTValue / 6; + } + + #endregion + #endregion + + #region Vanilla debuff stats + public static DebuffData OnFire = new DebuffData() + { + EnemyLostRegen = 12, + EnemyVanillaRegenToCancelOut = 12, + HeatDebuffScaling = 1 + }; + public static DebuffData Hellfire = new DebuffData() + { + EnemyLostRegen = 30, + EnemyVanillaRegenToCancelOut = 30, + HeatDebuffScaling = 1 + }; + public static DebuffData CursedInferno = new DebuffData() + { + EnemyLostRegen = 48, + EnemyVanillaRegenToCancelOut = 48, + HeatDebuffScaling = 1 + }; + public static DebuffData Shadowflame = new DebuffData() + { + EnemyLostRegen = 60, + EnemyVanillaRegenToCancelOut = 60, + HeatDebuffScaling = 1 + }; + public static DebuffData Daybroken = new DebuffData() + { + EnemyLostRegen = 200, + EnemyVanillaRegenToCancelOut = 200, + HeatDebuffScaling = 1, + NPCLifeRegenMethod = DaybrokenRegen + }; + // Provided purely to classify it as a heat debuff + public static DebuffData Burning = new DebuffData() + { + HeatDebuffScaling = 1 + }; + public static DebuffData Frostburn = new DebuffData() + { + EnemyLostRegen = 16, + EnemyVanillaRegenToCancelOut = 16, + ColdDebuffScaling = 1 + }; + public static DebuffData Frostbite = new DebuffData() + { + EnemyLostRegen = 50, + EnemyVanillaRegenToCancelOut = 50, + ColdDebuffScaling = 1 + }; + public static DebuffData Poisoned = new DebuffData() + { + EnemyLostRegen = 12, + EnemyVanillaRegenToCancelOut = 12, + SicknessDebuffScaling = 1 + }; + public static DebuffData AcidVenom = new DebuffData() + { + EnemyLostRegen = 60, + EnemyVanillaRegenToCancelOut = 60, + SicknessDebuffScaling = 1 + }; + public static DebuffData Electrified = new DebuffData(DebuffBehavior.Electric) + { + EnemyLostRegen = 21, + EnemyVanillaRegenToCancelOut = 8, + ElectricDebuffScaling = 1 + }; + public static DebuffData Oiled = new DebuffData() + { + EnemyLostRegen = 50, //This is how much DPS Oiled does when applied alongside a valid debuff + EnemyVanillaRegenToCancelOut = 50, + HeatDebuffScaling = 2, //Oiled scales twice as hard with heat debuff scaling to reward debuff builds who use such a rare and difficult to apply debuff. + NPCLifeRegenMethod = OiledNPCMethod + }; + public static DebuffData DryadsBane = new DebuffData() + { + EnemyLostRegen = 8, //This is not used in the method, serves as a token amount for anything that may need to interface in the future. + NPCLifeRegenMethod = DryadsBaneNPCMethod + }; + #endregion + } +} diff --git a/DataStructures/GemTechArmorState.cs b/DataStructures/GemTechArmorState.cs index 9ec1260c35..19274a48c6 100644 --- a/DataStructures/GemTechArmorState.cs +++ b/DataStructures/GemTechArmorState.cs @@ -1,7 +1,5 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Accessories; +using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.GemTech; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; @@ -67,17 +65,17 @@ namespace CalamityMod.DataStructures // Calculate the gem that should be lost. // The accessory check is to catch the edge-case of the Shield of Cthulhu // having melee damage for some godforsaken reason. - if (!Owner.ActiveItem().IsAir && !Owner.ActiveItem().accessory) + if (!Owner.HeldItem.IsAir && !Owner.HeldItem.accessory) { - if (Owner.ActiveItem().CountsAsClass()) + if (Owner.HeldItem.CountsAsClass()) GemThatShouldBeLost = GemTechArmorGemType.Melee; - if (Owner.ActiveItem().CountsAsClass()) + if (Owner.HeldItem.CountsAsClass()) GemThatShouldBeLost = GemTechArmorGemType.Ranged; - if (Owner.ActiveItem().CountsAsClass()) + if (Owner.HeldItem.CountsAsClass()) GemThatShouldBeLost = GemTechArmorGemType.Magic; - if (Owner.ActiveItem().CountsAsClass()) + if (Owner.HeldItem.CountsAsClass()) GemThatShouldBeLost = GemTechArmorGemType.Summoner; - if (Owner.ActiveItem().CountsAsClass()) + if (Owner.HeldItem.CountsAsClass()) GemThatShouldBeLost = GemTechArmorGemType.Rogue; } @@ -128,7 +126,7 @@ namespace CalamityMod.DataStructures MeleeCrystalCountdown--; // Make the crystal fire countdown go down faster if holding a true melee item. - if (Owner.ActiveItem().IsTrueMelee()) + if (Owner.HeldItem.IsTrueMelee()) MeleeCrystalCountdown--; // Ensure the crystal cooldown does not go below 0 due to the second decrement. @@ -153,7 +151,7 @@ namespace CalamityMod.DataStructures for (int i = 0; i < 14; i++) { Vector2 shootVelocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(0.5f, 3.25f); - Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.ActiveItem()), target.Center, shootVelocity, ModContent.ProjectileType(), damage, 0f, OwnerIndex); + Projectile.NewProjectile(Owner.GetSource_OnHit(target), target.Center, shootVelocity, ModContent.ProjectileType(), damage, 0f, OwnerIndex); } MeleeCrystalCountdown = GemTechHeadgear.MeleeShardDelay; @@ -173,7 +171,7 @@ namespace CalamityMod.DataStructures shootVelocity = shootVelocity.SafeNormalize(Vector2.UnitY) * 6f; spawnPosition -= shootVelocity.SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(15f, 50f); - Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.ActiveItem()), spawnPosition, shootVelocity, ModContent.ProjectileType(), damage, 0f, OwnerIndex); + Projectile.NewProjectile(Owner.GetSource_OnHit(target), spawnPosition, shootVelocity, ModContent.ProjectileType(), damage, 0f, OwnerIndex); } public void OnItemUseEffects(Item item) @@ -277,7 +275,7 @@ namespace CalamityMod.DataStructures gemDamage = CalamityUtils.DamageSoftCap(gemDamage, GemTechHeadgear.GemDamageSoftcapThreshold); if (Main.myPlayer == OwnerIndex) - Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.ActiveItem()), gemPosition, Vector2.Zero, ModContent.ProjectileType(), gemDamage, 0f, OwnerIndex, 0f, (int)GemThatShouldBeLost); + Projectile.NewProjectile(Owner.GetSource_ItemUse(Owner.HeldItem), gemPosition, Vector2.Zero, ModContent.ProjectileType(), gemDamage, 0f, OwnerIndex, 0f, (int)GemThatShouldBeLost); } } @@ -314,6 +312,7 @@ namespace CalamityMod.DataStructures if (IsGreenGemActive) { + Owner.Calamity().ammoCost *= GemTechHeadgear.RangedAmmoReduction; Owner.GetCritChance() += (int)(GemTechHeadgear.RangedCritBoost * 100f); Owner.GetDamage() += GemTechHeadgear.RangedDamageBoost; } @@ -348,7 +347,7 @@ namespace CalamityMod.DataStructures Owner.lifeRegen += GemTechHeadgear.AllGemsWeaponUseLifeRegenBoost; } - if (!Owner.ActiveItem().IsAir && !Owner.ActiveItem().CountsAsClass()) + if (!Owner.HeldItem.IsAir && !Owner.HeldItem.CountsAsClass()) Owner.manaRegen += GemTechHeadgear.NonMagicItemManaRegenBoost; } @@ -375,7 +374,7 @@ namespace CalamityMod.DataStructures for (int i = 0; i < 12; i++) { - Dust energyPuff = Dust.NewDustPerfect(CalculateGemPosition(gemType), 267); + Dust energyPuff = Dust.NewDustPerfect(CalculateGemPosition(gemType), DustID.RainbowMk2); energyPuff.velocity = (MathHelper.TwoPi * i / 12f).ToRotationVector2() * 5f; energyPuff.color = GetColorFromGemType(gemType); energyPuff.scale = 1.125f; diff --git a/DataStructures/HeapDict.cs b/DataStructures/HeapDict.cs new file mode 100644 index 0000000000..8516bdde75 --- /dev/null +++ b/DataStructures/HeapDict.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; + +namespace CalamityMod.DataStructures +{ + /// + /// A is a Dictionary-like data structure + /// that also keeps its entries in a binary-heap ordered by (The priority).
+ /// This allows for O(log n) retrievals of the with the lowest + /// (Thanks to the MinHeap/PriorityQueue structure) and O(1) lookups of any element (Thanks to the Dictionary structure).
+ /// This data structure is specially useful for graph algorithms where getting the minimum element is a constant process, like A*.
+ /// It essentially combines a and a into one data structure. + ///
+ /// + /// + public class HeapDict where TValue : IComparable + { + private readonly Dictionary _indexMap = []; + private readonly List<(TKey Key, TValue Value)> _heap = []; + + public int Count => _heap.Count; + + public void Add(TKey key, TValue value) + { + if (_indexMap.TryGetValue(key, out int index)) + { + TValue oldValue = _heap[index].Value; + _heap[index] = (key, value); + + int cmp = value.CompareTo(oldValue); + if (cmp < 0) + HeapifyUp(index); + else if (cmp > 0) + HeapifyDown(index); + } + else + { + _heap.Add((key, value)); + index = _heap.Count - 1; + _indexMap[key] = index; + HeapifyUp(index); + } + } + + public (TKey, TValue) PopMin() + { + if (_heap.Count == 0) + throw new InvalidOperationException("Heap is empty"); + + var min = _heap[0]; + var last = _heap[^1]; + _heap[0] = last; + _indexMap[last.Key] = 0; + _heap.RemoveAt(_heap.Count - 1); + _indexMap.Remove(min.Key); + if (_heap.Count > 0) + HeapifyDown(0); + + return min; + } + + public (TKey, TValue) PeekMin() + { + if (_heap.Count == 0) + throw new InvalidOperationException("Heap is empty"); + + return _heap[0]; + } + + private void HeapifyUp(int index) + { + while (index > 0) + { + int parent = (index - 1) / 2; + if (_heap[index].Value.CompareTo(_heap[parent].Value) >= 0) + break; + + Swap(index, parent); + index = parent; + } + } + + private void HeapifyDown(int index) + { + int lastIndex = _heap.Count - 1; + while (true) + { + int left = 2 * index + 1; + int right = 2 * index + 2; + int smallest = index; + + if (left <= lastIndex && _heap[left].Value.CompareTo(_heap[smallest].Value) < 0) + smallest = left; + + if (right <= lastIndex && _heap[right].Value.CompareTo(_heap[smallest].Value) < 0) + smallest = right; + + if (smallest == index) + break; + + Swap(index, smallest); + index = smallest; + } + } + + private void Swap(int i, int j) + { + (_heap[i], _heap[j]) = (_heap[j], _heap[i]); + _indexMap[_heap[i].Key] = i; + _indexMap[_heap[j].Key] = j; + } + + public bool ContainsKey(TKey key) => _indexMap.ContainsKey(key); + + public TValue GetValue(TKey key) => _heap[_indexMap[key]].Value; + } +} diff --git a/DataStructures/IDyeableShaderRenderer.cs b/DataStructures/IDyeableShaderRenderer.cs index cb63c9937f..260d7df569 100644 --- a/DataStructures/IDyeableShaderRenderer.cs +++ b/DataStructures/IDyeableShaderRenderer.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework.Graphics; -using Terraria; namespace CalamityMod.DataStructures { diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs deleted file mode 100644 index e1ebbd3f93..0000000000 --- a/DataStructures/NPCStats.cs +++ /dev/null @@ -1,876 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.NPCs.AcidRain; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crabulon; -using CalamityMod.NPCs.Cryogen; -using CalamityMod.NPCs.DesertScourge; -using CalamityMod.NPCs.DevourerofGods; -using CalamityMod.NPCs.ExoMechs.Apollo; -using CalamityMod.NPCs.ExoMechs.Ares; -using CalamityMod.NPCs.ExoMechs.Artemis; -using CalamityMod.NPCs.ExoMechs.Thanatos; -using CalamityMod.NPCs.HiveMind; -using CalamityMod.NPCs.Leviathan; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.Perforator; -using CalamityMod.NPCs.PlaguebringerGoliath; -using CalamityMod.NPCs.Polterghast; -using CalamityMod.NPCs.PrimordialWyrm; -using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.NPCs.Providence; -using CalamityMod.NPCs.Ravager; -using CalamityMod.NPCs.Signus; -using CalamityMod.NPCs.SlimeGod; -using CalamityMod.NPCs.StormWeaver; -using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.NPCs.Yharon; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod -{ - // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. - public static partial class NPCStats - { - private const double ExpertContactVanillaMultiplier = 2D; - private const double MasterContactVanillaMultiplier = 3D; - private const double NormalProjectileVanillaMultiplier = 2D; - private const double ExpertProjectileVanillaMultiplier = 4D; - private const double MasterProjectileVanillaMultiplier = 6D; - - #region Enemy Stats Container Struct - internal partial struct EnemyStats - { - public static SortedDictionary ExpertDamageMultiplier; - public static SortedDictionary ContactDamageValues; - public static SortedDictionary, int[]> ProjectileDamageValues; - }; - #endregion - - #region Stat Retrieval Methods - public static void GetNPCDamage(this NPC npc) - { - double damageAdjustment = GetExpertDamageMultiplier(npc) * (Main.masterMode ? MasterContactVanillaMultiplier : ExpertContactVanillaMultiplier); - - // Safety check: If for some reason the contact damage array is not initialized yet, set the NPC's damage to 1. - bool exists = EnemyStats.ContactDamageValues.TryGetValue(npc.type, out int[] contactDamage); - if (!exists) - npc.damage = 1; - - int normalDamage = contactDamage[0]; - int expertDamage = contactDamage[1] == -1 ? -1 : (int)Math.Round(contactDamage[1] / damageAdjustment); - int revengeanceDamage = contactDamage[2] == -1 ? -1 : (int)Math.Round(contactDamage[2] / damageAdjustment); - int deathDamage = contactDamage[3] == -1 ? -1 : (int)Math.Round(contactDamage[3] / damageAdjustment); - int masterDamage = contactDamage[4] == -1 ? -1 : (int)Math.Round(contactDamage[4] / damageAdjustment); - - // If the assigned value would be -1, don't actually assign it. This allows for conditionally disabling the system. - int damageToUse = Main.masterMode ? masterDamage : CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; - if (damageToUse != -1) - npc.damage = damageToUse; - } - - // Gets the amount of damage a given projectile should do from this NPC. - // Automatically compensates for Terraria's internal spaghetti scaling. - public static int GetProjectileDamage(this NPC npc, int projType) - { - double damageAdjustment = Main.masterMode ? MasterProjectileVanillaMultiplier : Main.expertMode ? ExpertProjectileVanillaMultiplier : NormalProjectileVanillaMultiplier; - - // Safety check: If for some reason the projectile damage array is not initialized yet, return 1. - bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npc.type, projType), out int[] projectileDamage); - if (!exists) - return 1; - - int normalDamage = (int)Math.Round(projectileDamage[0] / damageAdjustment); - int expertDamage = (int)Math.Round(projectileDamage[1] / damageAdjustment); - int revengeanceDamage = (int)Math.Round(projectileDamage[2] / damageAdjustment); - int deathDamage = (int)Math.Round(projectileDamage[3] / damageAdjustment); - int masterDamage = (int)Math.Round(projectileDamage[4] / damageAdjustment); - - int damageToUse = Main.masterMode ? masterDamage : CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; - - return damageToUse; - } - - // Gets the amount of damage this projectile should do from a given NPC. - // Automatically compensates for Terraria's internal spaghetti scaling. - public static int GetProjectileDamage(this Projectile projectile, int npcType) - { - double damageAdjustment = Main.masterMode ? MasterProjectileVanillaMultiplier : Main.expertMode ? ExpertProjectileVanillaMultiplier : NormalProjectileVanillaMultiplier; - - // Safety check: If for some reason the projectile damage array is not initialized yet, return 1. - bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npcType, projectile.type), out int[] projectileDamage); - if (!exists) - return 1; - - int normalDamage = (int)Math.Round(projectileDamage[0] / damageAdjustment); - int expertDamage = (int)Math.Round(projectileDamage[1] / damageAdjustment); - int revengeanceDamage = (int)Math.Round(projectileDamage[2] / damageAdjustment); - int deathDamage = (int)Math.Round(projectileDamage[3] / damageAdjustment); - int masterDamage = (int)Math.Round(projectileDamage[4] / damageAdjustment); - - int damageToUse = Main.masterMode ? masterDamage : CalamityWorld.death ? deathDamage : CalamityWorld.revenge ? revengeanceDamage : Main.expertMode ? expertDamage : normalDamage; - - return damageToUse; - } - - // Gets the raw amount of damage a projectile should do from this NPC. - // That is, this doesn't adjust the value to compensate for Terraria's internal spaghetti scaling. - public static int GetProjectileDamageNoScaling(this NPC npc, int projType) - { - bool exists = EnemyStats.ProjectileDamageValues.TryGetValue(new Tuple(npc.type, projType), out int[] projectileDamage); - return !exists ? 1 // Base case for safety, in case the array is not initialized yet. - : Main.masterMode ? projectileDamage[4] - : CalamityWorld.death ? projectileDamage[3] - : CalamityWorld.revenge ? projectileDamage[2] - : Main.expertMode ? projectileDamage[1] - : projectileDamage[0]; - } - - /// - /// Gets the Expert/Master Mode damage multiplier for the specified boss NPC. - /// Useful for determining the base damage a boss NPC should have prior to being run through the Expert/Master scaling code. - /// - /// The NPC you want to get the damage multiplier for - /// Whether Master Mode is enabled or not - /// - public static double GetExpertDamageMultiplier(this NPC npc, bool? master = null) - { - bool exists = EnemyStats.ExpertDamageMultiplier.TryGetValue(npc.type, out double damageMult); - return exists ? damageMult : 1D; - } - #endregion - - #region Load/Unload - internal static void Load() - { - LoadEnemyStats(); - LoadDebuffs(); - } - internal static void Unload() - { - UnloadEnemyStats(); - UnloadDebuffs(); - } - - // A static function, called exactly once, which initializes the EnemyStats struct at a predictable time. - // This is necessary to ensure this dictionary is populated as early as possible. - internal static void LoadEnemyStats() - { - EnemyStats.ExpertDamageMultiplier = new SortedDictionary - { - { NPCID.KingSlime, 0.8 }, - - { ModContent.NPCType(), 1.1 }, - - { ModContent.NPCType(), 0.8 }, - - { NPCID.EaterofWorldsHead, 1.1 }, - { NPCID.EaterofWorldsBody, 0.8 }, - { NPCID.EaterofWorldsTail, 0.8 }, - - { NPCID.BrainofCthulhu, 0.9 }, - - { ModContent.NPCType(), 0.9 }, - - { ModContent.NPCType(), 0.9 }, - - { NPCID.QueenBee, 0.9 }, - { NPCID.Bee, 0.6 }, - { NPCID.BeeSmall, 0.6 }, - - { NPCID.SkeletronHead, 1.1 }, - { NPCID.SkeletronHand, 1.1 }, - - { NPCID.WallofFlesh, 1.5 }, - { NPCID.WallofFleshEye, 1.5 }, - - { ModContent.NPCType(), 1.15 }, - - { NPCID.Spazmatism, 0.85 }, - { NPCID.Retinazer, 0.85 }, - { ModContent.NPCType(), 0.85 }, - - { ModContent.NPCType(), 1.1 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { NPCID.TheDestroyer, 2 }, - { NPCID.TheDestroyerBody, 0.85 }, - { NPCID.TheDestroyerTail, 0.85 }, - - { ModContent.NPCType(), 0.8 }, - - { NPCID.SkeletronPrime, 0.85 }, - { ModContent.NPCType(), 0.85 }, - { NPCID.PrimeCannon, 0.85 }, - { NPCID.PrimeLaser, 0.85 }, - { NPCID.PrimeSaw, 0.85 }, - { NPCID.PrimeVice, 0.85 }, - - { ModContent.NPCType(), 0.8 }, - - { NPCID.Plantera, 1.15 }, - { NPCID.PlanterasTentacle, 1.15 }, - { ModContent.NPCType(), 1.15 }, - - { NPCID.HallowBoss, 0.6875 }, - - { ModContent.NPCType(), 1.2 }, - { ModContent.NPCType(), 0.8 }, - { NPCID.DetonatingBubble, 0.75 }, - - { ModContent.NPCType(), 1.1 }, - - { NPCID.Golem, 0.8 }, - { NPCID.GolemHead, 0.8 }, - { NPCID.GolemFistLeft, 0.8 }, - { NPCID.GolemFistRight, 0.8 }, - - { ModContent.NPCType(), 0.9 }, - - { NPCID.DukeFishron, 0.7 }, - { NPCID.Sharkron, 0.75 }, - { NPCID.Sharkron2, 0.75 }, - - { ModContent.NPCType(), 0.8 }, - - { NPCID.CultistDragonHead, 0.75 }, - { NPCID.CultistDragonBody1, 0.75 }, - { NPCID.CultistDragonBody2, 0.75 }, - { NPCID.CultistDragonBody3, 0.75 }, - { NPCID.CultistDragonBody4, 0.75 }, - { NPCID.CultistDragonTail, 0.75 }, - { NPCID.AncientDoom, 0.75 }, - { NPCID.AncientLight, 0.75 }, - - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.9 }, - - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.9 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.85 }, - { ModContent.NPCType(), 0.85 }, - - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - - { ModContent.NPCType(), 0.8 } - }; - - EnemyStats.ContactDamageValues = new SortedDictionary - { - { 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, 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, 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, 114 } }, - { ModContent.NPCType(), new int[] { 21, 28, 32, 36, 63 } }, - { ModContent.NPCType(), new int[] { 12, 16, 20, 24, 36 } }, - - { NPCID.EyeofCthulhu, new int[] { - 24, // 36 in phase 2 - 30, // 45 in phase 2 - 40, // 48 in phase 2, 56 in phase 3 - 50, // 60 in phase 2, 70 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, 63 } }, // In phase 2: 26, 34, 44, 55, 82 - - { 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, 165 } }, - { NPCID.EaterofWorldsBody, new int[] { 18, 24, 32, 40, 60 } }, - { 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, 162 } }, - { NPCID.Creeper, new int[] { 24, 36, 66, 96, 144 } }, - - { 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, 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, 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 - 165 } }, // 215 while spinning - { NPCID.SkeletronHand, new int[] { 32, 44, 77, 110, 165 } }, - - { NPCID.Deerclops, new int[] { 20, 40, 50, 60, 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, 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, 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, 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 } }, - - { ModContent.NPCType(), new int[] { 90, 138, 161, 184, 276 } }, - { ModContent.NPCType(), new int[] { 80, 120, 138, 156, 240 } }, - - { NPCID.Spazmatism, new int[] { - 70, // 105 in phase 2 - 102, // 153 in phase 2 - 119, // 178 in phase 2 - 136, // 204 in phase 2 - 204 } }, // 306 in phase 2 - { NPCID.Retinazer, new int[] { - 55, // 83 in phase 2 - 85, // 127 in phase 2 - 102, // 153 in phase 2 - 119, // 178 in phase 2 - 153 } }, // 229 in phase 2 - { ModContent.NPCType(), new int[] { - 62, // 93 in phase 2 - 94, // 141 in phase 2 - 110, // 165 in phase 2 - 128, // 192 in phase 2 - 178 } }, // 267 in phase 2 - - { ModContent.NPCType(), new int[] { 110, 176, 187, 198, 330 } }, - { 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, 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, 240 } }, - - { NPCID.SkeletronPrime, new int[] { - 50, // 100 while spinning - 85, // 170 while spinning - 102, // 204 while spinning - 119, // 238 while spinning - 153 } }, // 306 while spinning - { ModContent.NPCType(), new int[] { - 50, // 100 while spinning - 85, // 170 while spinning - 102, // 204 while spinning - 119, // 238 while spinning - 153 } }, // 306 while spinning - { NPCID.PrimeVice, new int[] { 70, 102, 136, 170, 255 } }, - { NPCID.PrimeSaw, new int[] { 70, 102, 136, 170, 255 } }, - { 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, 288 } }, - { ModContent.NPCType(), new int[] { 80, 120, 138, 156, 240 } }, - { ModContent.NPCType(), new int[] { 85, 130, 150, 170, 255 } }, - - { NPCID.Plantera, new int[] { - 70, // 98 in phase 2 - 100, // 140 in phase 2 - 138, // 193 in phase 2 - 176, // 246 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 } }, - - { NPCID.HallowBoss, new int[] { 80, // 120 during charge - 110, // 165 during charge - 143, // 215 during charge - 176, // 264 during charge - 264 } }, // 396 during charge - - { ModContent.NPCType(), new int[] { 140, 216, 240, 264, 414 } }, - { ModContent.NPCType(), new int[] { - 75, // 113 during charge - 112, // 168 during charge - 136, // 204 during charge - 160, // 240 during charge - 240 } }, // 360 during charge - { ModContent.NPCType(), new int[] { 70, 110, 126, 142, 210 } }, - { 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, 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, 378 } }, - { ModContent.NPCType(), new int[] { 120, 180, 210, 240, 360 } }, - { 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 - 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, 336 } }, - - { NPCID.CultistDragonHead, new int[] { 120, 180, 210, 240, 360 } }, - { NPCID.CultistDragonBody1, new int[] { 60, 90, 105, 120, 180 } }, - { NPCID.CultistDragonBody2, new int[] { 60, 90, 105, 120, 180 } }, - { NPCID.CultistDragonBody3, new int[] { 60, 90, 105, 120, 180 } }, - { NPCID.CultistDragonBody4, new int[] { 60, 90, 105, 120, 180 } }, - { NPCID.CultistDragonTail, new int[] { 60, 90, 105, 120, 180 } }, - { NPCID.AncientCultistSquidhead, new int[] { 120, 180, 210, 240, 360 } }, - { 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, 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 } }, - { ModContent.NPCType(), new int[] { 100, 200, 220, 240, 300 } }, - { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 300 } }, - - { ModContent.NPCType(), new int[] { 170, 256, 288, 320, 504 } }, - { ModContent.NPCType(), new int[] { 145, 220, 242, 264, 435 } }, - - { ModContent.NPCType(), new int[] { 240, 360, 396, 432, 720 } }, - { ModContent.NPCType(), new int[] { 175, 260, 288, 316, 525 } }, - - { ModContent.NPCType(), new int[] { 240, 360, 396, 432, 720 } }, - { ModContent.NPCType(), new int[] { 125, 192, 224, 256, 372 } }, - { ModContent.NPCType(), new int[] { 105, 160, 192, 224, 312 } }, - - { ModContent.NPCType(), new int[] { 210, 315, 351, 387, 621 } }, - { ModContent.NPCType(), new int[] { 175, 260, 288, 316, 525 } }, - { ModContent.NPCType(), new int[] { 190, 280, 300, 320, 570 } }, - - { ModContent.NPCType(), new int[] { - 160, // 192 in phase 2, 224 in phase 3 - 240, // 288 in phase 2, 336 in phase 3 - 264, // 317 in phase 2, 370 in phase 3 - 288, // 346 in phase 2, 403 in phase 3 - 480 } }, // 576 in phase 2, 672 in phase 3 - { ModContent.NPCType(), new int[] { 224, 336, 370, 403, 672 } }, - - { ModContent.NPCType(), new int[] { - 192, // 211 in phase 2, 230 in phase 3 - 288, // 317 in phase 2, 346 in phase 3 - 324, // 356 in phase 2, 389 in phase 3 - 360, // 396 in phase 2, 432 in phase 3 - 567 } }, // 624 in phase 2, 680 in phase 3 - { ModContent.NPCType(), new int[] { 192, 288, 328, 368, 576 } }, - { ModContent.NPCType(), new int[] { 192, 288, 328, 368, 576 } }, - - { ModContent.NPCType(), new int[] { 470, 700, 750, 800, 1410 } }, - { ModContent.NPCType(), new int[] { 250, 374, 425, 476, 714 } }, - { ModContent.NPCType(), new int[] { 204, 306, 340, 374, 612 } }, - { ModContent.NPCType(), new int[] { 240, 360, 396, 432, 720 } }, - { ModContent.NPCType(), new int[] { 175, 260, 290, 320, 525 } }, - { ModContent.NPCType(), new int[] { 135, 200, 230, 260, 405 } }, - - { ModContent.NPCType(), new int[] { 300, 448, 480, 512, 900 } }, - - { ModContent.NPCType(), new int[] { 340, 512, 544, 576, 1020 } }, - - { ModContent.NPCType(), new int[] { 340, 512, 544, 576, 1020 } }, - { ModContent.NPCType(), new int[] { 320, 480, 512, 544, 960 } }, - - { ModContent.NPCType(), new int[] { 375, 560, 592, 624, 1116 } }, - { ModContent.NPCType(), new int[] { 320, 480, 512, 544, 960 } }, - { ModContent.NPCType(), new int[] { 320, 480, 512, 544, 960 } }, - { ModContent.NPCType(), new int[] { 270, 400, 424, 448, 804 } }, - - { ModContent.NPCType(), new int[] { 535, 800, 850, 900, 1596 } } - }; - - EnemyStats.ProjectileDamageValues = new SortedDictionary, int[]> - { - { 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(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, - - { 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, 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, 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, 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, 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, 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, 126 } }, - - { 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, 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, 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[] { 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[] { 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, 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, 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, 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, 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 - 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, ModContent.ProjectileType()), 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[] { 50, 108, 132, 156, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, - - { 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, 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, 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 } }, // Split shots: 72, 120, 144, 168, 252 - { 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, 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, 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, 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, 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, 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[] { 60, 120, 140, 180, 270 } }, - { new Tuple(NPCID.Golem, ProjectileID.EyeBeam), new int[] { 80, 140, 172, 204, 306 } }, - { new Tuple(NPCID.GolemHead, ProjectileID.Fireball), new int[] { 60, 120, 140, 180, 270 } }, - { 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, 140, 180, 270 } }, - { 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, 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, 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, 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, 300 } }, - - { 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, 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, 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, 318 } }, - - { 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, 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 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 248, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 248, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 320, 352, 384, 480 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 207, 315 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 276, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 207, 315 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 248, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 35, 50, 50, 0, 0 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 300, 332, 364, 600 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 312, 450 } }, // Split holy fire does: 113, 198, 216, 234, 338 - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 248, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 248, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 35, 50, 50, 0, 0 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 276, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 207, 315 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 276, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 207, 315 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 268, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 276, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 276, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 400, 440, 480, 600 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 150, 264, 288, 312, 450 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.FrostWave), new int[] { 150, 264, 288, 312, 450 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 276, 304, 332, 480 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrb), new int[] { 150, 264, 288, 312, 450 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 312, 450 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 312, 450 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 276, 304, 332, 480 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 288, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 352, 510 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 150, 264, 288, 312, 450 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 264, 420 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 264, 420 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 352, 510 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 420, 460, 500, 840 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 352, 510 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 316, 348, 380, 540 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 170, 296, 324, 352, 510 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 316, 348, 380, 540 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 200, 340, 376, 412, 600 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 180, 316, 348, 380, 540 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 520, 548, 576, 900 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 464, 660 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 464, 660 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 464, 660 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 220, 384, 424, 464, 660 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 468, 484, 500, 840 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 468, 484, 500, 840 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 508, 528, 548, 900 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 592, 624, 656, 1050 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 468, 484, 500, 840 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 468, 484, 500, 840 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 468, 484, 500, 840 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 468, 484, 500, 840 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 250, 440, 464, 488, 750 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 508, 528, 548, 900 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 280, 468, 484, 500, 840 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 592, 624, 656, 1050 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 508, 528, 548, 900 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 300, 508, 528, 548, 900 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 240, 408, 432, 456, 720 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 608, 640, 672, 1200 } }, - - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossIceMist), new int[] { 400, 600, 632, 664, 1200 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 500, 752, 788, 824, 1500 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.AncientDoomProjectile), new int[] { 400, 600, 632, 664, 1200 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossFireBallClone), new int[] { 400, 600, 632, 664, 1200 } } - }; - } - - // Destroys the EnemyStats struct to save memory because mod assemblies will not be fully unloaded until TML 1.4. - internal static void UnloadEnemyStats() - { - EnemyStats.ExpertDamageMultiplier = null; - EnemyStats.ContactDamageValues = null; - EnemyStats.ProjectileDamageValues = null; - } - #endregion - } -} diff --git a/DataStructures/SummonTag.cs b/DataStructures/SummonTag.cs new file mode 100644 index 0000000000..7a8a42dd31 --- /dev/null +++ b/DataStructures/SummonTag.cs @@ -0,0 +1,180 @@ +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.DataStructures +{ + /// + /// This is used to store summon tag stats so they can be applied automatically. + /// + public class SummonTag + { + #region SummonTag data + /// + /// Flat tag damage from this summon tag + /// + public int FlatTagDamage = 0; + + /// + /// This is tag damage that isn't added to the tooltip. Used for removing Vanilla whip tag damage. + /// + public int UnlistedTagDamage = 0; + + /// + /// Multiplicative tag damage from this summon tag. Stacks additively with other tags. + /// + public float MultiplicativeTagDamage = 0; + + /// + /// This is tag damage that isn't added to the tooltip. Used for removing Firecracker whip damage. + /// + public float UnlistedMultiplicativeTagDamage = 0; + + /// + /// Tag critical strike chance from this stummon tag. Stacks additively with other tags. + /// + public float TagCritChance = 0; + + /// + /// How much the Critical Strike damage multiplier should be adjusted with this tag. Stacks additively with other tags. + /// + public float TagCritDamage = 0; + + /// + /// UNIMPLEMENTED. Need to add animation frame support before using. + /// What the texture for the tag effect should be. + /// + public Asset TagTexture; + + /// + /// What item inflicted this tag + /// + public int TagItem = -1; + + /// + /// The ModifyHitByProjectileTag code to run. Defaults to just applying the tag effects. + /// + public ModifyHitByProjectileTag TagModifyHitEffects; + + /// + /// Disable to stop tooltips from drawing automatically, for things that change TagModifyHitEffects + /// + public bool AutoDrawTooltip = true; + + /// + /// Setting to true allows this tag to be used alongside other tag effects. + /// + public bool AllowsWhipStacking = false; + + /// + /// The OnHitByProjectile code to run when this tag is applied. Defaults to nothing. + /// + public OnHitByProjectile TagOnHit = BlankOnHit; + public SummonTag() + { + TagModifyHitEffects = ApplyTagModifyHit; + } + + public SummonTag(int itemType) + { + TagItem = itemType; + TagModifyHitEffects = ApplyTagModifyHit; + } + + /// + /// A modified version of ModifyHitByProjectile that incorporates tag damage multipliers and tag critical chance. + /// This delegate is used for TagModifyHitEffects + /// + /// + /// + /// + /// + /// + public delegate void ModifyHitByProjectileTag(Projectile proj, NPC npc, ref NPC.HitModifiers modifiers, ref float tagDamageMult, ref float critChance); + + /// + /// This delegate is used for TagOnHit + /// + /// + /// + /// + /// + public delegate void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitInfo hit, int damageDone); + + /// + /// The default tag damage functionality + /// + public void ApplyTagModifyHit(Projectile proj, NPC npc, ref NPC.HitModifiers modifiers, ref float tagDamageMult, ref float critChance) + { + modifiers.FlatBonusDamage += (FlatTagDamage + UnlistedTagDamage) * tagDamageMult; + modifiers.ScalingBonusDamage += (MultiplicativeTagDamage + UnlistedMultiplicativeTagDamage) * tagDamageMult; + critChance += TagCritChance; + modifiers.CritDamage += TagCritDamage; + } + + /// + /// Blank tag damage functionality + /// + public static void BlankTagModifyHit(Projectile proj, NPC npc, ref NPC.HitModifiers modifiers, ref float tagDamageMult, ref float critChance) + { + } + /// + /// This is replaced by custom tag on hit effects. Does nothing. + /// + public static void BlankOnHit(NPC npc, Projectile projectile, NPC.HitInfo hit, int damagedone) { } + #endregion + + #region Vanilla whip stats + public static SummonTag LeatherWhip = new SummonTag(ItemID.BlandWhip) + { + FlatTagDamage = 2, + UnlistedTagDamage = -4 //Negative value cancels out vanilla tag damage + }; + public static SummonTag Snapthorn = new SummonTag(ItemID.ThornWhip) + { + FlatTagDamage = 1, + UnlistedTagDamage = -6 //Negative value cancels out vanilla tag damage + }; + public static SummonTag SpinalTap = new SummonTag(ItemID.BoneWhip) + { + FlatTagDamage = 4, + UnlistedTagDamage = -7 //Negative value cancels out vanilla tag damage + }; + public static SummonTag Firecracker = new SummonTag(ItemID.FireWhip) + { + TagCritChance = 1f, //Since we make firecracker do 2x damage, I make this apply as a crit for the ability to proc crit accessories and for visual style points + UnlistedMultiplicativeTagDamage = -1.75f, //Cancels out the vanilla firecracker tag damage + AutoDrawTooltip = false + }; + public static SummonTag CoolWhip = new SummonTag(ItemID.CoolWhip) + { + FlatTagDamage = 6, + UnlistedTagDamage = -6 //Negative value cancels out vanilla tag damage + }; + public static SummonTag Durendal = new SummonTag(ItemID.SwordWhip) + { + FlatTagDamage = 4, + TagCritChance = 0.05f, + UnlistedTagDamage = -9 //Negative value cancels out vanilla tag damage + }; + public static SummonTag MorningStar = new SummonTag(ItemID.MaceWhip) + { + TagCritChance = 0.13f, + UnlistedTagDamage = -8 //Negative value cancels out vanilla tag damage + }; + public static SummonTag DarkHarvest = new SummonTag(ItemID.ScytheWhip) + { + FlatTagDamage = 10, + UnlistedTagDamage = -10, //Negative value cancels out vanilla tag damage + //This has a unique on hit effect from vanilla. + }; + public static SummonTag Kaleidoscope = new SummonTag(ItemID.RainbowWhip) + { + FlatTagDamage = 8, + TagCritChance = 0.10f, + UnlistedTagDamage = -20 //Negative value cancels out vanilla tag damage + }; + #endregion + } +} diff --git a/Debugging/SpritebatchDebug.cs b/Debugging/SpritebatchDebug.cs new file mode 100644 index 0000000000..0a5eed8654 --- /dev/null +++ b/Debugging/SpritebatchDebug.cs @@ -0,0 +1,89 @@ +using System; +using System.Diagnostics; +using System.Reflection; +using System.Reflection.Emit; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using MonoMod.RuntimeDetour; +using MonoMod.RuntimeDetour.HookGen; +using Terraria.ModLoader; + +namespace CalamityMod.Debugging +{ + public static class SpritebatchDebug + { + public static string Trace { get; set; } + } + + [Autoload(false)] + public class SpritebatchDebugInitializer : ILoadable + { + private static Hook _beginHook; + private static Hook _endHook; + + public void Load(Mod mod) + { + MethodInfo begin = typeof(SpriteBatch).GetMethod( + nameof(SpriteBatch.Begin), + BindingFlags.Public | BindingFlags.Instance, + binder: null, + types: new[] + { + typeof(SpriteSortMode), + typeof(BlendState), + typeof(SamplerState), + typeof(DepthStencilState), + typeof(RasterizerState), + typeof(Effect), + typeof(Matrix) + }, + modifiers: null); + MethodInfo end = typeof(SpriteBatch).GetMethod(nameof(SpriteBatch.End), BindingFlags.Public | BindingFlags.Instance); + + Debug.Assert(begin != null); + Debug.Assert(end != null); + + _beginHook = new Hook(begin, Begin_Impl); + _endHook = new Hook(end, End_Impl); + } + + private static void Begin_Impl(Action orig, SpriteBatch self, SpriteSortMode sortMode, + BlendState blendState, + SamplerState samplerState, + DepthStencilState depthStencilState, + RasterizerState rasterizerState, + Effect effect, + Matrix transformMatrix) + { + if (self.beginCalled) ModLoader.GetMod(nameof(CalamityMod)).Logger.Debug("[SPRITEBATCH DEBUG] Begin was last called here: " + SpritebatchDebug.Trace); + SpritebatchDebug.Trace = Environment.StackTrace; + + orig(self, sortMode, + blendState, + samplerState, + depthStencilState, + rasterizerState, + effect, + transformMatrix); + } + + private static void End_Impl(Action orig, SpriteBatch self) + { + if (!self.beginCalled) ModLoader.GetMod(nameof(CalamityMod)).Logger.Debug("[SPRITEBATCH DEBUG] Doesn't seem like Begin was called. Here's the last end call: " + SpritebatchDebug.Trace); + SpritebatchDebug.Trace = Environment.StackTrace; + + orig(self); + } + + public void Unload() + { + _beginHook.Dispose(); + _endHook.Dispose(); + } + } +} diff --git a/Dialogues/DialogueLoader.cs b/Dialogues/DialogueLoader.cs new file mode 100644 index 0000000000..60b906a873 --- /dev/null +++ b/Dialogues/DialogueLoader.cs @@ -0,0 +1,302 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using CalamityMod.UI.DialogueDisplay; +using CalamityMod.Utilities; +using MonoMod.Cil; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Dialogues; + +internal record DialogueTextDataEntry( + Mod ProviderMod, + string FilePath, + string DialogueKey, + DialogueTextData Data + ); + +internal partial class DialogueLoader : ModSystem +{ + private const string DialogueFilePrefix = "Dialogue."; + + private static readonly Dictionary _DialogueLookup = []; + private static readonly Dictionary _Watchers = []; + + public override void Load() + { + _DialogueLookup.Clear(); + + var method = typeof(LocalizationLoader).GetMethod(nameof(LocalizationLoader.ExtractLocalizationFiles), BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); + if (method != null) + { + MonoModHooks.Modify(method, ExtractDialogueFilesPatch); + } + } + + public override void PostSetupContent() + { + foreach (var mod in ModLoader.Mods) + { + if (mod.File == null) + continue; + + var path = mod.SourceFolder; + if (!Directory.Exists(path)) + continue; + + var watcher = new MainThreadedFileSystemWatcher() + { + Path = path, + Filter = "*.json", + FileNameFilter = CalamityDialogueFileRegex(), + NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite, + IncludeSubdirectories = true + }; + watcher.Changed += (arg) => + { + HandleFileUpdate(mod, arg.FullPath); + }; + watcher.Renamed += (arg) => + { + HandleFileUpdate(mod, arg.FullPath); + }; + watcher.EnableRaisingEvents = true; + _Watchers[mod] = watcher; + } + } + + public override void Unload() + { + _DialogueLookup.Clear(); + + foreach (var watcher in _Watchers.Values) + { + watcher.EnableRaisingEvents = false; + watcher.Dispose(); + } + + _Watchers.Clear(); + } + + private static void ExtractDialogueFilesPatch(ILContext il) + { + var cursor = new ILCursor(il); + + int pathLdloc = -1; + int modLdloc = -1; + if (!cursor.TryGotoNext(MoveType.After, + i => i.MatchLdloc(out modLdloc), // Mod mod + i => i.MatchLdloc(out pathLdloc), // string path + i => i.MatchCallOrCallvirt(out _), // GameCulture ActiveCulture + i => i.MatchCallOrCallvirt(typeof(LocalizationLoader), nameof(LocalizationLoader.UpdateLocalizationFilesForMod)))) + { + CalamityMod.Log.ILFailure("Force Extract Dialogue Files", $"Unable to locate {nameof(LocalizationLoader.UpdateLocalizationFilesForMod)} call"); + } + + if (modLdloc == -1) + { + CalamityMod.Log.ILFailure("Force Extract Dialogue Files", $"Unable to locate ldloc index for mod"); + } + + if (pathLdloc == -1) + { + CalamityMod.Log.ILFailure("Force Extract Dialogue Files", $"Unable to locate ldloc index for path"); + } + + cursor.EmitLdloc(modLdloc); + cursor.EmitLdloc(pathLdloc); + cursor.EmitDelegate((Mod mod, string basePath) => + { + foreach (var entry in GetDialogueTextEntries(mod, GameCulture.DefaultCulture, skipDeserializeData: true)) + { + try + { + var destFilePath = Path.Combine(basePath, entry.FilePath); + var destDir = Path.GetDirectoryName(destFilePath); + if (!Directory.Exists(destDir)) Directory.CreateDirectory(destDir); + + using var stream = mod.File.GetStream(entry.FilePath); + using var fileStream = File.OpenWrite(destFilePath); + using var writer = new StreamWriter(fileStream, Encoding.UTF8); + using var reader = new StreamReader(stream, Encoding.UTF8); + writer.Write(reader.ReadToEnd()); + } + catch (Exception e) + { + CalamityMod.Log.Error($"Error while exporting DialogueTextData entry ({mod.Name}::{entry.FilePath}): {e}"); + } + } + }); + } + + public static bool TryGetDialogue(string dialogueKey, out DialogueTextData data) + { + if (_DialogueLookup.TryGetValue(dialogueKey, out var entry)) + { + data = entry.Data; + return true; + } + + data = null; + return false; + } + + public override void OnLocalizationsLoaded() + { + _DialogueLookup.Clear(); + + // Mods should be sorted by dependency order. + foreach (var entry in GetDialogueTextEntiresForAllMods(GameCulture.DefaultCulture)) + { + if (_DialogueLookup.TryGetValue(entry.DialogueKey, out var oldEntry)) + { + if (entry.Data.Revision != oldEntry.Data.Revision) + { + CalamityMod.Log.Warn($"Dialogue Localization was detected but revision mismatches. This will not be applied! : '{entry.ProviderMod.Name}::{entry.FilePath}'"); + continue; + } + } + + _DialogueLookup[entry.DialogueKey] = entry; + } + + var activeCulture = LanguageManager.Instance.ActiveCulture; + if (activeCulture == GameCulture.DefaultCulture) + return; + + foreach (var entry in GetDialogueTextEntiresForAllMods(activeCulture)) + { + var mod = entry.ProviderMod; + + if (!_DialogueLookup.TryGetValue(entry.DialogueKey, out var oldEntry)) + { + CalamityMod.Log.Warn($"Dialogue Localization was detected but original Dialogue file does not exist. This will not be applied! : '{mod.Name}::{entry.FilePath}'"); + continue; + } + + // Skip if entry is from same file. + if (oldEntry.ProviderMod == entry.ProviderMod && oldEntry.FilePath == entry.FilePath) + { + continue; + } + + if (oldEntry.Data.Revision != entry.Data.Revision) + { + CalamityMod.Log.Warn($"Dialogue Localization was detected but revision mismatches. This will not be applied! : '{mod.Name}::{entry.FilePath}'"); + continue; + } + + _DialogueLookup[entry.DialogueKey] = entry; + } + } + + private static void HandleFileUpdate(Mod mod, string filePath) + { + if (!TryGetDialogueFileInfo(filePath, out _, out _, out var dialogueKey)) + return; + + if (!_DialogueLookup.TryGetValue(dialogueKey, out var existingEntry)) + return; + + if (existingEntry.ProviderMod != mod) + return; + + try + { + using var stream = new StreamReader(File.OpenRead(filePath), Encoding.UTF8); + _DialogueLookup[dialogueKey] = existingEntry with + { + Data = JsonSerializer.Deserialize(stream.BaseStream) + }; + + var hotreloadedMessage = $"Dialogue entry has been hot reloaded: '{dialogueKey}', from source: '{filePath}'"; + CalamityMod.Log.Info(hotreloadedMessage); + if (!Main.gameMenu) Main.NewText(hotreloadedMessage); + } + catch (Exception e) + { + CalamityMod.Log.Error($"Error while hot reloading DialogueTextData entry ({filePath}): {e}"); + } + } + + private static IEnumerable GetDialogueTextEntiresForAllMods(GameCulture targetCulture, bool skipDeserializeData = false) + { + return ModLoader.Mods + .Where(mod => mod.File != null) + .SelectMany(mod => GetDialogueTextEntries(mod, targetCulture, skipDeserializeData)); + } + + private static IEnumerable GetDialogueTextEntries(Mod mod, GameCulture targetCulture, bool skipDeserializeData = false) + { + if (mod == null) + yield break; + + if (mod.File == null) + yield break; + + foreach (var file in mod.File) + { + if (!TryGetDialogueFileInfo(file.Name, out var culture, out var prefix, out var dialogueKey)) + continue; + + if (culture != targetCulture) + continue; + + DialogueTextData data = null; + if (!skipDeserializeData) + { + try + { + using var stream = new StreamReader(mod.File.GetStream(file), Encoding.UTF8); + data = JsonSerializer.Deserialize(stream.BaseStream); + } + catch (Exception e) + { + CalamityMod.Log.Error($"Error while reading DialogueTextData entry ({mod.Name}::{file.Name}): {e}"); + } + } + + if (data != null || skipDeserializeData) + { + yield return new DialogueTextDataEntry(mod, file.Name, dialogueKey, data); + } + } + } + + private static bool TryGetDialogueFileInfo(string filePath, out GameCulture culture, out string prefix, out string dialogueKey) + { + if (!Path.GetExtension(filePath).Equals(".json", StringComparison.InvariantCultureIgnoreCase)) + goto EXIT_INVALID; + + if (!LocalizationLoader.TryGetCultureAndPrefixFromPath(filePath, out culture, out prefix)) + goto EXIT_INVALID; + + string fileName = Path.GetFileNameWithoutExtension(filePath); + if (fileName.StartsWith($"{prefix}_{DialogueFilePrefix}", StringComparison.InvariantCultureIgnoreCase)) + { + dialogueKey = fileName[$"{prefix}_{DialogueFilePrefix}".Length..]; + return true; + } + else if (fileName.StartsWith(DialogueFilePrefix, StringComparison.InvariantCultureIgnoreCase)) + { + dialogueKey = fileName[DialogueFilePrefix.Length..]; + return true; + } + +EXIT_INVALID: + culture = null; + prefix = null; + dialogueKey = null; + return false; + } + + [GeneratedRegex(@"Dialogue\..+?\.jsonc?$", RegexOptions.IgnoreCase)] + private static partial Regex CalamityDialogueFileRegex(); +} diff --git a/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Death.json b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Death.json new file mode 100644 index 0000000000..3e92c78a0f --- /dev/null +++ b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Death.json @@ -0,0 +1,54 @@ +{ + "Revision": 1, + "DefaultColor": "6383FF", + "DefaultSpeaker": "DevourerOfGods", + "AlignType": 1, + "TextDelay": 2, + "BasePunctuationDelay": { + "Delay": 10, + "ForceSet": false, + "Locks": false + }, + "PunctuationDelayCap": 30, + "PunctuationDelays": { + "!": { + "Delay": 20, + "ForceSet": true, + "Locks": true + }, + "?": { + "Delay": 20, + "ForceSet": true, + "Locks": true + } + }, + "Pages": [ + { + "TextDelay": 0, + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Tasteless [Pause(0.25)]slop.]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Delicious... A feast worthy of a god!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):And [Shaking:STAY] dead!]]" + ] + }, + { + "TextDelay": 0, + "Lines": [ + "[Shaking:[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):WEAK.]]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):[Shaking:PATHETIC.] ALL THAT RUNNING JUST TO DIE TO A [Shaking:SINGLE TOUCH?!]]]" + ] + } + ] +} diff --git a/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Head.json b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Head.json new file mode 100644 index 0000000000..c7448406c9 --- /dev/null +++ b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Head.json @@ -0,0 +1,95 @@ +{ + "Revision": 1, + "DefaultColor": "6383FF", + "DefaultSpeaker": "DevourerOfGods", + "AlignType": 1, + "TextDelay": 2, + "BasePunctuationDelay": { + "Delay": 10, + "ForceSet": false, + "Locks": false + }, + "PunctuationDelayCap": 30, + "PunctuationDelays": { + "!": { + "Delay": 20, + "ForceSet": true, + "Locks": true + }, + "?": { + "Delay": 20, + "ForceSet": true, + "Locks": true + } + }, + "Pages": [ + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Fall to your knees, worm!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Let's see how much longer you'll last...]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Getting tired yet?]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):You'll fall, just like the others!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Give up! It'll be easier for both of us!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Let me end you already!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):This is starting to get ridiculous...!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):How are you doing this?!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Are you playing me for a fool?!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):Why won't you [Shaking:DIE?!]]]" + ] + }, + { + "TextDelay": 0, + "Lines": [ + "[Shaking:[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):FALL!]]]" + ] + }, + { + "TextDelay": 0, + "Lines": [ + "[Shaking:[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):BEGONE!]]]" + ] + }, + { + "TextDelay": 0, + "Lines": [ + "[Shaking:[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):DIE!]]]" + ] + } + ] +} diff --git a/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Phases.json b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Phases.json new file mode 100644 index 0000000000..3ae52d8b17 --- /dev/null +++ b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Phases.json @@ -0,0 +1,48 @@ +{ + "Revision": 1, + "DefaultColor": "6383FF", + "DefaultSpeaker": "DevourerOfGods", + "AlignType": 1, + "TextDelay": 2, + "BasePunctuationDelay": { + "Delay": 10, + "ForceSet": false, + "Locks": false + }, + "PunctuationDelayCap": 30, + "PunctuationDelays": { + "!": { + "Delay": 20, + "ForceSet": true, + "Locks": true + }, + "?": { + "Delay": 20, + "ForceSet": true, + "Locks": true + } + }, + "Pages": [ + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):You are no god...]]", + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):But I shall feast upon your essence regardless!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):You've done better than most, but don't get cocky!]]" + ] + }, + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):It's not over yet, kid!]]" + ] + }, + { + "Lines": [ + "[Colors(2, 0.5, 00FFFF, FF00FF):[Shaking:[Scale(1.5):A]]][Colors(2, 0.5, FF00FF, 00FFFF):[Shaking(5):[Scale(2): [Pause(0.33)]GOD]]][Colors(2, 0.5, 00FFFF, FF00FF):[Shaking:[Scale(1.5): DOES NOT FEAR]]][Colors(2, 0.5, FF00FF, 00FFFF):[Shaking(5):[Scale(2): [Pause(0.33)]DEATH!]]]" + ] + } + ] +} \ No newline at end of file diff --git a/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Running.json b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Running.json new file mode 100644 index 0000000000..de35cd7052 --- /dev/null +++ b/Dialogues/en-US/Dialogue.Mods.CalamityMod.DevourerOfGods.Running.json @@ -0,0 +1,37 @@ +{ + "Revision": 1, + "DefaultColor": "6383FF", + "DefaultSpeaker": "DevourerOfGods", + "AlignType": 1, + "TextDelay": 2, + "BasePunctuationDelay": { + "Delay": 10, + "ForceSet": false, + "Locks": false + }, + "PunctuationDelayCap": 30, + "PunctuationDelays": { + "!": { + "Delay": 20, + "ForceSet": true, + "Locks": true + }, + "?": { + "Delay": 20, + "ForceSet": true, + "Locks": true + } + }, + "Pages": [ + { + "Lines": [ + "[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):You can't run forever!]]" + ] + }, + { + "Lines": [ + "[Shaking:[Scale(1.5):[Colors(2, 0.5, 00FFFF, FF00FF):WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?!]]]" + ] + } + ] +} diff --git a/Dusts/CinderBlossomDust.cs b/Dusts/CinderBlossomDust.cs index 167d6c6310..91e1b7eca8 100644 --- a/Dusts/CinderBlossomDust.cs +++ b/Dusts/CinderBlossomDust.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Dusts diff --git a/Dusts/DiamondDust.cs b/Dusts/DiamondDust.cs new file mode 100644 index 0000000000..3b34857b02 --- /dev/null +++ b/Dusts/DiamondDust.cs @@ -0,0 +1,99 @@ +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class DiamondDust : ModDust + { + public static Asset GlowDiamond { get; private set; } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + GlowDiamond = ModContent.Request("CalamityMod/Particles/SquareRotated"); + } + + public override void OnSpawn(Dust dust) + { + dust.scale *= Main.rand.NextFloat(0.8f, 1f); + } + + public override bool Update(Dust dust) + { + dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; + + dust.velocity *= 0.96f; + if (dust.noGravity) + dust.scale -= 0.045f; + else + { + dust.scale -= 0.03f; + dust.velocity.Y += Main.rand.NextFloat(0.1f, 0.35f); + } + + float light = MathHelper.Clamp(dust.scale * 0.8f, 0f, 1f); + if (!dust.noLightEmittence) + Lighting.AddLight(dust.position, dust.color.ToVector3() * light); + + if (dust.scale <= 0) + dust.active = false; + + dust.position += dust.velocity; + dust.fadeIn++; // Fade in is used for the time strech instead + + return false; + } + + public override bool PreDraw(Dust dust) + { + // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash + float squashLerp = Utils.GetLerpValue(10, 25, dust.fadeIn, true); + Vector2 squash = new Vector2(MathHelper.Lerp(1, 0.3f, squashLerp), MathHelper.Lerp(1, 7f, squashLerp)); + + // Glow Orb + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha) * (i == 0 ? 1f : 0.7f), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.08f * (i == 0 ? 0.7f : 1), SpriteEffects.None, 0); + } + return false; + } + } + + public class DiamondDustPixelated : DiamondDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + public static void DrawPixelated(Dust dust) + { + // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash + float squashLerp = Utils.GetLerpValue(10, 25, dust.fadeIn, true); + Vector2 squash = new Vector2(MathHelper.Lerp(1, 0.3f, squashLerp), MathHelper.Lerp(1, 7f, squashLerp)); + + // Glow Orb + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha) * (i == 0 ? 1f : 0.7f), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.08f * (i == 0 ? 0.7f : 1), SpriteEffects.None, 0); + } + } + } +} diff --git a/Dusts/LightDust.cs b/Dusts/LightDust.cs index d0f83ba587..6e5338861a 100644 --- a/Dusts/LightDust.cs +++ b/Dusts/LightDust.cs @@ -1,6 +1,9 @@ using System; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +11,19 @@ namespace CalamityMod.Dusts { public class LightDust : ModDust { + public static Asset SolidCircle { get; private set; } + + public static Asset BloomCircle { get; private set; } + + public override void Load() + { + if (Main.dedServ) + return; + + SolidCircle = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle"); + BloomCircle = ModContent.Request("CalamityMod/Particles/BloomCircle"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -28,21 +44,37 @@ namespace CalamityMod.Dusts return true; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - Texture2D solidCenter = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); if (!dust.noLight) - { - Main.EntitySpriteDraw(solidCenter, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, solidCenter.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); - } + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); return false; } } + + public class LightDustPixelated : LightDust + { + public override string Texture => "CalamityMod/Dusts/LightDust"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + if (!dust.noLight) + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + } + } } diff --git a/Dusts/SquareDust.cs b/Dusts/SquareDust.cs new file mode 100644 index 0000000000..7c25502b6a --- /dev/null +++ b/Dusts/SquareDust.cs @@ -0,0 +1,96 @@ +using System; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class SquareDust : ModDust + { + public static Asset GlowSquare { get; private set; } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + GlowSquare = ModContent.Request("CalamityMod/Particles/GlowSquareParticleThick"); + } + + public override void OnSpawn(Dust dust) + { + dust.scale *= Main.rand.NextFloat(0.8f, 1f); + dust.rotation = Main.rand.NextFloat(-5, 5); + } + + public override bool Update(Dust dust) + { + float fadeSpeed = (dust.fadeIn + 1); + float rotDir = Math.Sign(dust.rotation); + dust.rotation += 0.04f * dust.scale * rotDir; + dust.velocity *= 0.96f * fadeSpeed; + if (dust.noGravity) + dust.scale -= 0.045f * fadeSpeed; + else + { + dust.scale -= 0.03f * fadeSpeed; + dust.velocity.Y += Main.rand.NextFloat(0.1f, 0.35f) * fadeSpeed; + } + + float light = MathHelper.Clamp(dust.scale * 0.8f, 0f, 1f); + if (!dust.noLightEmittence) + Lighting.AddLight(dust.position, dust.color.ToVector3() * light); + + if (dust.scale <= 0) + dust.active = false; + + dust.position += dust.velocity; + + return false; + } + public override bool PreDraw(Dust dust) + { + Vector2 squash = Vector2.One; + + // Glow Orb + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0f); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.095f, SpriteEffects.None, 0f); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0f); + } + return false; + } + } + + public class SquareDustPixelated : SquareDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Vector2 squash = Vector2.One; + + // Glow Orb + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0f); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.095f, SpriteEffects.None, 0f); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Dusts/SquashDust.cs b/Dusts/SquashDust.cs new file mode 100644 index 0000000000..8adfb2beaa --- /dev/null +++ b/Dusts/SquashDust.cs @@ -0,0 +1,97 @@ +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class SquashDust : ModDust + { + public static Asset SolidCircle { get; private set; } + + public static Asset BloomCircle { get; private set; } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (Main.dedServ) + return; + + SolidCircle = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle"); + BloomCircle = ModContent.Request("CalamityMod/Particles/BloomCircle"); + } + + public override void OnSpawn(Dust dust) + { + dust.scale *= Main.rand.NextFloat(0.8f, 1f); + } + + public override bool Update(Dust dust) + { + float fadeSpeed = (dust.fadeIn + 1); + dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; + dust.velocity *= 0.96f; + if (dust.noGravity) + dust.scale -= 0.045f * fadeSpeed; + else + { + dust.scale -= 0.03f * fadeSpeed; + dust.velocity.Y += Main.rand.NextFloat(0.1f, 0.35f) * fadeSpeed; + } + + float light = MathHelper.Clamp(dust.scale * 0.8f, 0f, 1f); + if (!dust.noLightEmittence) + Lighting.AddLight(dust.position, dust.color.ToVector3() * light); + + if (dust.scale <= 0) + dust.active = false; + + dust.position += dust.velocity; + + return false; + } + + public override bool PreDraw(Dust dust) + { + Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)); + + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); + if (!dust.noLight) + { + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + } + return false; + } + } + + public class SquashDustPixelated : SquashDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)); + + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); + if (!dust.noLight) + { + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + } + } + } +} diff --git a/Dusts/SquashDustHollow.cs b/Dusts/SquashDustHollow.cs new file mode 100644 index 0000000000..ec82d5aa67 --- /dev/null +++ b/Dusts/SquashDustHollow.cs @@ -0,0 +1,95 @@ +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class SquashDustHollow : ModDust + { + public static Asset BloomRing { get; private set; } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + BloomRing = ModContent.Request("CalamityMod/Particles/BloomRing"); + } + + public override void OnSpawn(Dust dust) + { + dust.scale *= Main.rand.NextFloat(0.8f, 1f); + } + + public override bool Update(Dust dust) + { + dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; + dust.velocity *= 0.96f; + if (dust.noGravity) + dust.scale -= 0.045f; + else + { + dust.scale -= 0.03f; + dust.velocity.Y += Main.rand.NextFloat(0.1f, 0.35f); + } + + float light = MathHelper.Clamp(dust.scale * 0.8f, 0f, 1f); + if (!dust.noLightEmittence) + Lighting.AddLight(dust.position, dust.color.ToVector3() * light); + + if (dust.scale <= 0) + dust.active = false; + + dust.position += dust.velocity; + + return false; + } + + public override bool PreDraw(Dust dust) + { + // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash + Vector2 squash = Vector2.Lerp(new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)), Vector2.One, dust.fadeIn); + + // Glow Orb + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + } + return false; + } + } + + public class SquashDustHollowPixelated : SquashDustHollow + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash + Vector2 squash = Vector2.Lerp(new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)), Vector2.One, dust.fadeIn); + + // Glow Orb + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + } + } + } +} diff --git a/Dusts/SquashDustTileTouch.cs b/Dusts/SquashDustTileTouch.cs new file mode 100644 index 0000000000..d27889266e --- /dev/null +++ b/Dusts/SquashDustTileTouch.cs @@ -0,0 +1,77 @@ +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; + +namespace CalamityMod.Dusts +{ + public class SquashDustTileTouch : SquashDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void OnSpawn(Dust dust) + { + dust.scale *= Main.rand.NextFloat(0.8f, 1f); + } + + public override bool Update(Dust dust) + { + bool touchedTiles = false; + int size = 2; + + if (Collision.SolidCollision(dust.position, size, size)) + { + touchedTiles = true; + dust.velocity = Vector2.Zero; + } + + float fadeSpeed = (dust.fadeIn + 1); // For this dust, fadeIn is used to increase the power of gravity if it's active, otherwise it makes it's lifetime change + dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; + dust.velocity *= 0.96f; + if (dust.noGravity) + dust.scale -= 0.045f * (touchedTiles ? 0.4f : 1) * fadeSpeed; + else + { + dust.scale -= 0.03f * (touchedTiles ? 0.4f : 1); + dust.velocity.Y += Main.rand.NextFloat(0.1f, 0.35f) * fadeSpeed; + } + + float light = MathHelper.Clamp(dust.scale * 0.8f, 0f, 1f); + if (!dust.noLightEmittence) + Lighting.AddLight(dust.position, dust.color.ToVector3() * light); + + if (dust.scale <= 0) + dust.active = false; + + if (!touchedTiles) + dust.position += dust.velocity; + + return false; + } + } + + public class SquashDustTileTouchPixelated : SquashDustTileTouch + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)); + + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); + if (!dust.noLight) + { + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + } + } + } +} diff --git a/Dusts/TerraSigilDust.cs b/Dusts/TerraSigilDust.cs new file mode 100644 index 0000000000..79fb8adf26 --- /dev/null +++ b/Dusts/TerraSigilDust.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class TerraSigilDust : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.noLight = true; + dust.rotation = Main.rand.NextFloat(MathHelper.TwoPi); + dust.fadeIn = 1f; + // Randomly select one of the three variants + dust.frame = new Rectangle(0, Main.rand.Next(3) * 12, 10, 12); + } + + public override bool Update(Dust dust) + { + dust.velocity.Y += 0.2f; + dust.velocity *= 0.983f; + dust.position += dust.velocity; + + dust.alpha += 1; + if (dust.alpha > 255) + { + dust.active = false; + } + return false; + } + } +} diff --git a/Dusts/TerraSigilDust.png b/Dusts/TerraSigilDust.png new file mode 100644 index 0000000000..25e53dd753 Binary files /dev/null and b/Dusts/TerraSigilDust.png differ diff --git a/Dusts/UnstableDust.cs b/Dusts/UnstableDust.cs new file mode 100644 index 0000000000..82f42fbfb5 --- /dev/null +++ b/Dusts/UnstableDust.cs @@ -0,0 +1,96 @@ +using System; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class UnstableDust : ModDust + { + public static Asset GlowStar { get; private set; } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + GlowStar = ModContent.Request("CalamityMod/Particles/FullStar"); + } + + public override void OnSpawn(Dust dust) + { + dust.scale *= Main.rand.NextFloat(0.8f, 1f); + dust.rotation = Main.rand.NextFloat(-5, 5); + } + + public override bool Update(Dust dust) + { + float rotDir = Math.Sign(dust.rotation); + dust.rotation += 0.5f * dust.scale * rotDir; + dust.velocity *= 0.96f; + if (dust.noGravity) + dust.scale -= 0.045f; + else + { + dust.scale -= 0.03f; + dust.velocity.Y += Main.rand.NextFloat(0.1f, 0.35f); + } + + float light = MathHelper.Clamp(dust.scale * 0.8f, 0f, 1f); + if (!dust.noLightEmittence) + Lighting.AddLight(dust.position, dust.color.ToVector3() * light); + + if (dust.scale <= 0) + dust.active = false; + + dust.position += dust.velocity; + // dust.fadeIn is used to change the shake intensity, -2 will negate it + dust.position += Main.rand.NextVector2Circular(dust.fadeIn + 2, dust.fadeIn + 2); + + return false; + } + + public override bool PreDraw(Dust dust) + { + Vector2 squash = new Vector2(0.4f, 1); + float texScaling = 6; + + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.1f * texScaling, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.04f * texScaling, SpriteEffects.None, 0); + if (!dust.noLight) + { + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.025f * texScaling, SpriteEffects.None, 0); + } + return false; + } + } + + public class UnstableDustPixelated : UnstableDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Vector2 squash = new Vector2(0.4f, 1); + float texScaling = 6; + + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.1f * texScaling, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.04f * texScaling, SpriteEffects.None, 0); + if (!dust.noLight) + { + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.025f * texScaling, SpriteEffects.None, 0); + } + } + } +} diff --git a/Dusts/VoidDust.cs b/Dusts/VoidDust.cs index 793f7b826d..e66a8f3bf4 100644 --- a/Dusts/VoidDust.cs +++ b/Dusts/VoidDust.cs @@ -1,6 +1,9 @@ using System; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +11,19 @@ namespace CalamityMod.Dusts { public class VoidDust : ModDust { + public static Asset SolidCircle { get; private set; } + + public static Asset BloomCircle { get; private set; } + + public override void Load() + { + if (Main.dedServ) + return; + + SolidCircle = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle"); + BloomCircle = ModContent.Request("CalamityMod/Particles/BloomCircle"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -28,20 +44,41 @@ namespace CalamityMod.Dusts return true; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - Texture2D solidCenter = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; if (!dust.noLight) { - Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); } - Main.EntitySpriteDraw(solidCenter, dustCenter - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, solidCenter.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); return false; } } + + public class VoidDustPixelated : VoidDust + { + public override string Texture => "CalamityMod/Dusts/VoidDust"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + if (!dust.noLight) + { + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + } + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + } + } } diff --git a/Dusts/VoidDustInverted.cs b/Dusts/VoidDustInverted.cs index d5df7d199f..4c30aec8d8 100644 --- a/Dusts/VoidDustInverted.cs +++ b/Dusts/VoidDustInverted.cs @@ -1,6 +1,9 @@ using System; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +11,22 @@ namespace CalamityMod.Dusts { public class VoidDustInverted : ModDust { + public static Asset SolidCircle { get; private set; } + + public static Asset BloomCircle { get; private set; } + + public static Asset SmallBloomCircle { get; private set; } + + public override void Load() + { + if (Main.dedServ) + return; + + SolidCircle = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle"); + BloomCircle = ModContent.Request("CalamityMod/Particles/BloomCircle"); + SmallBloomCircle = ModContent.Request("CalamityMod/Particles/SmallBloom"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -28,23 +47,39 @@ namespace CalamityMod.Dusts return true; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D solidCenter = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; - Texture2D bloom2 = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/SmallBloom").Value; - - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Black * 0.4f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.068f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * 0.4f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.068f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.057f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.057f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(bloom2, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom2.Size() * 0.5f, dust.scale * 0.07f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.07f, SpriteEffects.None, 0); if (!dust.noLight) - Main.EntitySpriteDraw(solidCenter, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.75f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, solidCenter.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.75f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); return false; } } + + public class VoidDustInvertedPixelated : VoidDustInverted + { + public override string Texture => "CalamityMod/Dusts/VoidDustInverted"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * 0.4f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.068f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.057f, SpriteEffects.None, 0); + + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.07f, SpriteEffects.None, 0); + if (!dust.noLight) + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.75f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + } + } } diff --git a/Dusts/WaterSplash/AstralSplash.cs b/Dusts/WaterSplash/AstralSplash.cs index 6fcb24f6c3..75e1d16dd1 100644 --- a/Dusts/WaterSplash/AstralSplash.cs +++ b/Dusts/WaterSplash/AstralSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class AstralSplash : SplashDust { diff --git a/Dusts/WaterSplash/BasaltGullyLavaSplash.cs b/Dusts/WaterSplash/BasaltGullyLavaSplash.cs new file mode 100644 index 0000000000..81d5a03dc1 --- /dev/null +++ b/Dusts/WaterSplash/BasaltGullyLavaSplash.cs @@ -0,0 +1,9 @@ +using Microsoft.Xna.Framework; + +namespace CalamityMod.Dusts.WaterSplash +{ + public class BasaltGullyLavaSplash : LavaSplashDust + { + public override Vector3 LightColor => new(0.98f, 0.286f, 0.286f); + } +} diff --git a/Dusts/WaterSplash/BasaltGullyLavaSplash.png b/Dusts/WaterSplash/BasaltGullyLavaSplash.png new file mode 100644 index 0000000000..6fc3a83f98 Binary files /dev/null and b/Dusts/WaterSplash/BasaltGullyLavaSplash.png differ diff --git a/Dusts/WaterSplash/BasaltGullySplash.cs b/Dusts/WaterSplash/BasaltGullySplash.cs index cfacf07640..2ba33cb8af 100644 --- a/Dusts/WaterSplash/BasaltGullySplash.cs +++ b/Dusts/WaterSplash/BasaltGullySplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class BasaltGullySplash : SplashDust { diff --git a/Dusts/WaterSplash/CragsLavaSplash.cs b/Dusts/WaterSplash/CragsLavaSplash.cs index 907f65c969..2e28fa83a1 100644 --- a/Dusts/WaterSplash/CragsLavaSplash.cs +++ b/Dusts/WaterSplash/CragsLavaSplash.cs @@ -1,178 +1,9 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics.PackedVector; -using System; -using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Dusts.WaterSplash { - public class CragsLavaSplash : ModDust - { - public override void OnSpawn(Dust dust) - { - dust.velocity *= 0.1f; - dust.velocity.Y = -0.5f; - } - - public override bool Update(Dust dust) - { - if (dust.scale > 10f) - { - dust.active = false; - } - Dust.lavaBubbles++; - dust.position += dust.velocity; - if (!dust.noGravity) - { - dust.velocity.Y += 0.1f; - } - if (dust.noGravity) - { - dust.scale += 0.03f; - if (dust.scale < 1f) - { - dust.velocity.Y += 0.075f; - } - dust.velocity.X *= 1.08f; - if (dust.velocity.X > 0f) - { - dust.rotation += 0.01f; - } - else - { - dust.rotation -= 0.01f; - } - float num109 = dust.scale * 0.6f; - if (num109 > 1f) - { - num109 = 1f; - } - Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f + 1f), num109 * (2.5f / 4), num109 * (1.1f / 4), num109 * (0.1f / 4)); - } - else - { - if (!Collision.WetCollision(new Vector2(dust.position.X, dust.position.Y - 8f), 4, 4)) - { - dust.scale = 0f; - } - else - { - dust.alpha += Main.rand.Next(2); - if (dust.alpha > 255) - { - dust.scale = 0f; - } - dust.velocity.Y = -0.5f; - dust.alpha++; - dust.scale -= 0.01f; - dust.velocity.Y = -0.2f; - dust.velocity.X += (float)Main.rand.Next(-10, 10) * 0.002f; - if ((double)dust.velocity.X < -0.25) - { - dust.velocity.X = -0.25f; - } - if ((double)dust.velocity.X > 0.25) - { - dust.velocity.X = 0.25f; - } - } - float num3 = dust.scale * 0.3f + 0.4f; - if (num3 > 1f) - { - num3 = 1f; - } - Lighting.AddLight((int)(dust.position.X / 16f), (int)(dust.position.Y / 16f), num3 * (2.5f / 4), num3 * (1.1f / 4), num3 * (0.1f / 4)); - } - dust.rotation += dust.velocity.X * 0.5f; - if (dust.fadeIn > 0f && dust.fadeIn < 100f) - { - dust.scale += 0.03f; - if (dust.scale > dust.fadeIn) - { - dust.fadeIn = 0f; - } - } - dust.scale -= 0.01f; - if (dust.noGravity) - { - dust.velocity *= 0.92f; - if (dust.fadeIn == 0f) - { - dust.scale -= 0.04f; - } - } - if (dust.position.Y > Main.screenPosition.Y + (float)Main.screenHeight) - { - dust.active = false; - } - float num17 = 0.1f; - if ((double)Dust.dCount == 0.5) - { - dust.scale -= 0.001f; - } - if ((double)Dust.dCount == 0.6) - { - dust.scale -= 0.0025f; - } - if ((double)Dust.dCount == 0.7) - { - dust.scale -= 0.005f; - } - if ((double)Dust.dCount == 0.8) - { - dust.scale -= 0.01f; - } - if ((double)Dust.dCount == 0.9) - { - dust.scale -= 0.02f; - } - if ((double)Dust.dCount == 0.5) - { - num17 = 0.11f; - } - if ((double)Dust.dCount == 0.6) - { - num17 = 0.13f; - } - if ((double)Dust.dCount == 0.7) - { - num17 = 0.16f; - } - if ((double)Dust.dCount == 0.8) - { - num17 = 0.22f; - } - if ((double)Dust.dCount == 0.9) - { - num17 = 0.25f; - } - if (dust.scale < num17) - { - dust.active = false; - } - return false; - } - - public override Color? GetAlpha(Dust dust, Color lightColor) - { - float num = (float)(255 - dust.alpha) / 255f; - int num4; - int num3; - int num2; - num = (num + 3f) / 4f; - num4 = (int)((int)lightColor.R * num); - num3 = (int)((int)lightColor.G * num); - num2 = (int)((int)lightColor.B * num); - int num6 = lightColor.A - dust.alpha; - if (num6 < 0) - { - num6 = 0; - } - if (num6 > 255) - { - num6 = 255; - } - return new Color(num4, num3, num2, num6); - } - } + public class CragsLavaSplash : LavaSplashDust + { + public override Vector3 LightColor => new(0.95f, 0.41f, 0.41f); + } } diff --git a/Dusts/WaterSplash/LavaSplashDust.cs b/Dusts/WaterSplash/LavaSplashDust.cs new file mode 100644 index 0000000000..516f5dcc72 --- /dev/null +++ b/Dusts/WaterSplash/LavaSplashDust.cs @@ -0,0 +1,146 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts.WaterSplash +{ + public abstract class LavaSplashDust : ModDust + { + public abstract Vector3 LightColor { get; } + + public override void OnSpawn(Dust dust) + { + dust.velocity *= 0.1f; + dust.velocity.Y = -0.5f; + } + + public override bool Update(Dust dust) + { + if (dust.scale > 10f) + { + dust.active = false; + } + Dust.lavaBubbles++; + dust.position += dust.velocity; + if (!dust.noGravity) + { + dust.velocity.Y += 0.1f; + } + if (dust.noGravity) + { + dust.scale += 0.03f; + if (dust.scale < 1f) + { + dust.velocity.Y += 0.075f; + } + dust.velocity.X *= 1.08f; + dust.rotation += (dust.velocity.X > 0f) ? 0.01f : -0.01f; + + float intensity = Math.Min(dust.scale * 0.6f, 1.0f); + + int tileX = (int)(dust.position.X / 16f); + int tileY = (int)(dust.position.Y / 16f + 1f); + Lighting.AddLight(tileX, tileY, intensity * LightColor.X, intensity * LightColor.Y, intensity * LightColor.Z); + } + else + { + if (!Collision.WetCollision(new Vector2(dust.position.X, dust.position.Y - 8f), 4, 4)) + { + dust.scale = 0f; + } + else + { + dust.alpha += Main.rand.Next(2); + if (dust.alpha > 255) + { + dust.scale = 0f; + } + dust.velocity.Y = -0.5f; + dust.alpha++; + dust.scale -= 0.01f; + dust.velocity.Y = -0.2f; + dust.velocity.X += Main.rand.Next(-10, 10) * 0.002f; + if (dust.velocity.X < -0.25f) + { + dust.velocity.X = -0.25f; + } + if (dust.velocity.X > 0.25f) + { + dust.velocity.X = 0.25f; + } + } + + float intensity = dust.scale * 0.3f + 0.4f; + if (intensity > 1f) + { + intensity = 1f; + } + + int tileX = (int)(dust.position.X / 16f); + int tileY = (int)(dust.position.Y / 16f); + Lighting.AddLight(tileX, tileY, intensity * LightColor.X, intensity * LightColor.Y, intensity * LightColor.Z); + } + dust.rotation += dust.velocity.X * 0.5f; + if (dust.fadeIn > 0f && dust.fadeIn < 100f) + { + dust.scale += 0.03f; + if (dust.scale > dust.fadeIn) + { + dust.fadeIn = 0f; + } + } + dust.scale -= 0.01f; + if (dust.noGravity) + { + dust.velocity *= 0.92f; + if (dust.fadeIn == 0f) + { + dust.scale -= 0.04f; + } + } + if (dust.position.Y > Main.screenPosition.Y + Main.screenHeight) + { + dust.active = false; + } + + dust.scale -= Dust.dCount switch + { + 0.5f => 0.001f, + 0.6f => 0.0025f, + 0.7f => 0.005f, + 0.8f => 0.01f, + 0.9f => 0.02f, + _ => 0.0f, + }; + + float despawnScaleThreshold = Dust.dCount switch + { + 0.5f => 0.11f, + 0.6f => 0.13f, + 0.7f => 0.16f, + 0.8f => 0.22f, + 0.9f => 0.25f, + _ => 0.1f + }; + + if (dust.scale < despawnScaleThreshold) + { + dust.active = false; + } + return false; + } + + public override Color? GetAlpha(Dust dust, Color lightColor) + { + float colorIntensity = (255 - dust.alpha) / 255f; + colorIntensity = (colorIntensity + 3f) / 4f; + + int R = (int)(lightColor.R * colorIntensity); + int G = (int)(lightColor.G * colorIntensity); + int B = (int)(lightColor.B * colorIntensity); + int alpha = lightColor.A - dust.alpha; + return new Color(R, G, B, alpha); + } + } +} diff --git a/Dusts/WaterSplash/MiddleAbyssSplash.cs b/Dusts/WaterSplash/MiddleAbyssSplash.cs index 319e596446..bc5ff8b76c 100644 --- a/Dusts/WaterSplash/MiddleAbyssSplash.cs +++ b/Dusts/WaterSplash/MiddleAbyssSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class MiddleAbyssSplash : SplashDust { diff --git a/Dusts/WaterSplash/SplashDust.cs b/Dusts/WaterSplash/SplashDust.cs index f74eac1125..1d055734d0 100644 --- a/Dusts/WaterSplash/SplashDust.cs +++ b/Dusts/WaterSplash/SplashDust.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Dusts.WaterSplash @@ -7,7 +8,7 @@ namespace CalamityMod.Dusts.WaterSplash { public override void SetStaticDefaults() { - UpdateType = 33; + UpdateType = DustID.Water; } public override void OnSpawn(Dust dust) diff --git a/Dusts/WaterSplash/SulphuricDepthsSplash.cs b/Dusts/WaterSplash/SulphuricDepthsSplash.cs index 840863230f..d5d648de23 100644 --- a/Dusts/WaterSplash/SulphuricDepthsSplash.cs +++ b/Dusts/WaterSplash/SulphuricDepthsSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class SulphuricDepthsSplash : SplashDust { diff --git a/Dusts/WaterSplash/SulphuricSplash.cs b/Dusts/WaterSplash/SulphuricSplash.cs index 0cd8705c76..acf1adce86 100644 --- a/Dusts/WaterSplash/SulphuricSplash.cs +++ b/Dusts/WaterSplash/SulphuricSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class SulphuricSplash : SplashDust { diff --git a/Dusts/WaterSplash/SunkenSeaBurrowsSplash.cs b/Dusts/WaterSplash/SunkenSeaBurrowsSplash.cs index 1565575956..787b100dee 100644 --- a/Dusts/WaterSplash/SunkenSeaBurrowsSplash.cs +++ b/Dusts/WaterSplash/SunkenSeaBurrowsSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class SunkenSeaBurrowsSplash : SplashDust { diff --git a/Dusts/WaterSplash/SunkenSeaPolypSplash.cs b/Dusts/WaterSplash/SunkenSeaPolypSplash.cs index 0bf3151240..0ab875665c 100644 --- a/Dusts/WaterSplash/SunkenSeaPolypSplash.cs +++ b/Dusts/WaterSplash/SunkenSeaPolypSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class SunkenSeaPolypSplash : SplashDust { diff --git a/Dusts/WaterSplash/SunkenSeaReefsSplash.cs b/Dusts/WaterSplash/SunkenSeaReefsSplash.cs index d2e707e0a6..fdc184103d 100644 --- a/Dusts/WaterSplash/SunkenSeaReefsSplash.cs +++ b/Dusts/WaterSplash/SunkenSeaReefsSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class SunkenSeaReefsSplash : SplashDust { diff --git a/Dusts/WaterSplash/SunkenSeaShoresSplash.cs b/Dusts/WaterSplash/SunkenSeaShoresSplash.cs index 3864ebca8b..479bcf326f 100644 --- a/Dusts/WaterSplash/SunkenSeaShoresSplash.cs +++ b/Dusts/WaterSplash/SunkenSeaShoresSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class SunkenSeaShoresSplash : SplashDust { diff --git a/Dusts/WaterSplash/UpperAbyssSplash.cs b/Dusts/WaterSplash/UpperAbyssSplash.cs index 715e5467b6..cf2941bd51 100644 --- a/Dusts/WaterSplash/UpperAbyssSplash.cs +++ b/Dusts/WaterSplash/UpperAbyssSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class UpperAbyssSplash : SplashDust { diff --git a/Dusts/WaterSplash/VoidSplash.cs b/Dusts/WaterSplash/VoidSplash.cs index 0e046fa962..b066c1e58f 100644 --- a/Dusts/WaterSplash/VoidSplash.cs +++ b/Dusts/WaterSplash/VoidSplash.cs @@ -1,7 +1,4 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Dusts.WaterSplash +namespace CalamityMod.Dusts.WaterSplash { public class VoidSplash : SplashDust { diff --git a/Effects/ArsenalEffects.cs b/Effects/ArsenalEffects.cs new file mode 100644 index 0000000000..c0a21645a7 --- /dev/null +++ b/Effects/ArsenalEffects.cs @@ -0,0 +1,27 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria.ModLoader; + +namespace CalamityMod.Effects +{ + public class ArsenalEffects + { + public static int ArsenalDust = 278; // Colorable firework dust, simple and effective. Most visuals use a mix of the energy respective dust and this + + // Plasma + public static int ArsenalPlasmaDust = ModContent.DustType(); + public static Color ArsenalPlasmaColor = new Color(154, 255, 0); + // Laser + public static int ArsenalLaserDust = ModContent.DustType(); + public static Color ArsenalLaserColor = Color.Lerp(Color.Crimson, Color.Red, 0.45f); + // Pulse + public static int ArsenalPulseDust = ModContent.DustType(); + public static Color ArsenalPulseColor = Color.Lerp(Color.DarkOrchid, Color.Magenta, 0.35f); + // Electric + public static int ArsenalElectricDust = ModContent.DustType(); + public static Color ArsenalElectricColor = Color.Lerp(Color.Aqua, Color.Aquamarine, 0.35f); + // Gauss + public static int ArsenalGaussDust = ModContent.DustType(); + public static Color ArsenalGaussColor = Color.Lerp(Color.Yellow, Color.Goldenrod, 0.25f); + } +} diff --git a/Effects/BasicTextureDistortionShader.fx b/Effects/BasicTextureDistortionShader.fx new file mode 100644 index 0000000000..a9e45abb3a --- /dev/null +++ b/Effects/BasicTextureDistortionShader.fx @@ -0,0 +1,20 @@ +sampler baseTexture : register(s0); +sampler distortionTexture : register(s1); + +float2 timeOffset; +float2 noiseScaleStrength; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR +{ + float2 distortedCoords = coords * noiseScaleStrength.x + timeOffset; + float distortion = tex2D(distortionTexture, distortedCoords).r * noiseScaleStrength.y; + return tex2D(baseTexture, coords + distortion) * sampleColor.a; +} + +technique Technique1 +{ + pass DistortionPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/BasicTextureDistortionShader.xnb b/Effects/BasicTextureDistortionShader.xnb new file mode 100644 index 0000000000..b556cca62c Binary files /dev/null and b/Effects/BasicTextureDistortionShader.xnb differ diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 2a5c4cd5f2..5dd18a0419 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -1,7 +1,6 @@ using CalamityMod.Skies; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using Terraria; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ModLoader; @@ -16,123 +15,123 @@ namespace CalamityMod.Effects internal const string CalamityShaderPrefix = "CalamityMod:"; // made by boffin. Source code not available. Creates fog in the astral infection - internal static Effect AstralFogShader; + internal static Asset AstralFogShader; // - // All below shaders created by Dominic Karma + // All below shaders created by Lucille Karma // - #region Dominic's Shaders + #region Lucille's Shaders // The Dance of Light's Blinding Light - internal static Effect DanceOfLightBlindingShader; + internal static Asset DanceOfLightBlindingShader; // Calamity accessory - internal static Effect CalamityAccessoryMouseShader; + internal static Asset CalamityAccessoryMouseShader; // Subsuming Vortex tentacles - internal static Effect SubsumingVortexTentacleShader; + internal static Asset SubsumingVortexTentacleShader; // Draedon teleporting shader - internal static Effect DraedonTeleportShader; + internal static Asset DraedonTeleportShader; // UNKNOWN -- PROBABLY UNUSED - internal static Effect LightDistortionShader; + internal static Asset LightDistortionShader; // Phaseslayer red energy trail - internal static Effect PhaseslayerRipShader; + internal static Asset PhaseslayerRipShader; // Generic UV-fade streak trail shader. Used by many things? - internal static Effect FadedUVMapStreakShader; + internal static Asset FadedUVMapStreakShader; // Generic flaming streak trail shader. Used by many things? - internal static Effect FlameStreakShader; + internal static Asset FlameStreakShader; // Generic solid trail shader. Used by many things? - internal static Effect FadingSolidTrailShader; + internal static Asset FadingSolidTrailShader; - // Scarlet Devil main spear glowing trail. BEWARE: Is reused by many other items! - internal static Effect ScarletDevilShader; + // Typical projectile javelin glowing trail. BEWARE: Is used by many items! + internal static Asset ScarletDevilShader; // Yharon border flame pillar trail. - internal static Effect BordernadoFireShader; + internal static Asset BordernadoFireShader; // Photon Ripper hardlight teeth trail shader - internal static Effect PrismCrystalShader; + internal static Asset PrismCrystalShader; // Generic flame trail. BEWARE: Reused by Apollo, Artemis, Cosmilamp, Gem Tech broken gems, and Persecuted enchant portal demons - internal static Effect ImpFlameTrailShader; + internal static Asset ImpFlameTrailShader; // Supreme Witch, Calamitas' force field (which is her visual hitbox) - internal static Effect SCalShieldShader; + internal static Asset SCalShieldShader; // Rancor's alchemical / satanic circle which floats near the player. The laser is emitted from here - internal static Effect RancorMagicCircleShader; + internal static Asset RancorMagicCircleShader; // Generic colored glow shader. BEWARE: Used by about a billion things, including Ares telegraphs, the Biome Blade line, etc. - internal static Effect BasicTintShader; + internal static Asset BasicTintShader; // Generic "pie chart" shader that renders only certain arc sectors of things. Used for the Cooldown Rack and various other visuals. - internal static Effect CircularBarShader; + internal static Asset CircularBarShader; // Cooldown Rack shader used to draw the cooldown's icon appropriately. - internal static Effect CircularBarSpriteShader; + internal static Asset CircularBarSpriteShader; // Devourer of Gods' death animation where he disintegrates into purple energy stuff. - internal static Effect DoGDisintegrationShader; + internal static Asset DoGDisintegrationShader; // Art Attack's main projectile trail shader (Visually designed to match Paper Mario) - internal static Effect ArtAttackTrailShader; + internal static Asset ArtAttackTrailShader; // Generic AoE telegraph. Used for Ares' nukes to denote their area of effect. - internal static Effect CircularAoETelegraph; + internal static Asset CircularAoETelegraph; // Clips a sprite along a fixed plane. Used by Stream Gouge to have half-spears come out of portals. - internal static Effect IntersectionClipShader; + internal static Asset IntersectionClipShader; // Was previously used by Dom's Bladecrest Oathsword. Appears to govern the swing animation. - internal static Effect LocalLinearTransformationShader; + internal static Asset LocalLinearTransformationShader; - // UNUSED -- Probably leftover from Dominic's experiments with applying shaders to primitives (arbitrary GPU-rendered triangles) - internal static Effect BasicPrimitiveShader; + // UNUSED -- Probably leftover from Lucille's experiments with applying shaders to primitives (arbitrary GPU-rendered triangles) + internal static Asset BasicPrimitiveShader; // Artemis Ohio Beam. Also used by get fixed boi Nuclear Terror's "G-FUEL BEAM" - internal static Effect ArtemisLaserShader; + internal static Asset ArtemisLaserShader; // Exoblade's melee slash trails. Also used by Terratomere - internal static Effect ExobladeSlashShader; + internal static Asset ExobladeSlashShader; // Exoblade's projectile on-hit "anime slash marks". Also used by Terratomere - internal static Effect ExobladePierceShader; + internal static Asset ExobladePierceShader; // Used by Subsuming Vortex's various vortices. Draws the main vortices. BEWARE: Reused by Burning Sea's fireball. - internal static Effect ExoVortexShader; + internal static Asset ExoVortexShader; // Used by Subsuming Vortex's small vortices. Draws the trailing energy tendrils. - internal static Effect SideStreakTrailShader; + internal static Asset SideStreakTrailShader; // Used by Heavenly Gale's hardlight arrows. - internal static Effect HeavenlyGaleTrailShader; + internal static Asset HeavenlyGaleTrailShader; // Used by Heavenly Gale's exo lightning strikes. Also used by Stormfront Razor lightning. - internal static Effect HeavenlyGaleLightningShader; + internal static Asset HeavenlyGaleLightningShader; // Used in the Codebreaker on Draedon's sprite while communicating with him. - internal static Effect BlueStaticShader; + internal static Asset BlueStaticShader; // Used by Acid Eels, presumably to have their snaking movements look more smooth. - internal static Effect PrimTextureOverlayShader; + internal static Asset PrimTextureOverlayShader; // Used as a default for primitive drawing when no specific shader is supplied. This shader simply renders the vertex color data without modification. - internal static Effect StandardPrimitiveShader; + internal static Asset StandardPrimitiveShader; // Used by Devourer of Gods. Renders the portal that he escapes through at the end of phase 1. - internal static Effect DoGPortalShader; + internal static Asset DoGPortalShader; // Used to render all-encompassing fog in the Floral Paradise biome. - internal static Effect FogShader; + internal static Asset FogShader; // Used to render background water features in the Floral Paradise biome. - internal static Effect WaterfallShader; + internal static Asset WaterfallShader; // Metaballs. See the MetaballManager class for comments on how this system works. // These shaders are leveraged to render the results of the metaball simulation to the screen. @@ -140,11 +139,17 @@ namespace CalamityMod.Effects // The "Additive" shader actually FUSES the particles into their blobby mess. // // Backing textures vary. The primary use of this system is Gruesome Eminence. - internal static Effect MetaballEdgeShader; - internal static Effect AdditiveMetaballEdgeShader; + internal static Asset MetaballEdgeShader; + internal static Asset AdditiveMetaballEdgeShader; // Used to render the results of Navier-Stokes fluid simulations. - internal static Effect FluidShaders; + internal static Asset FluidShaders; + + // Used by projectiles fired by the Sylvestaff. + internal static Asset SylvestaffProjectileShader; + + // Used by the ribbons on the Sylvestaff. + internal static Asset SylvestaffRibbonShader; #endregion // @@ -154,25 +159,25 @@ namespace CalamityMod.Effects #region Iban's Shaders // Used by Coral Spout and Titanium Railgun while charging to indicate current projectile spread. - internal static Effect SpreadTelegraph; + internal static Asset SpreadTelegraph; // Used by Wulfrum Screwdriver and Titanium Railgun. Renders a pixelly "laser sight". - internal static Effect PixelatedSightLine; + internal static Asset PixelatedSightLine; // Used by the Wulfrum Treasure Pinger to highlight tiles in range - internal static Effect WulfrumTilePing; + internal static Asset WulfrumTilePing; // Used by the Wulfrum Scaffold Kit to highlight locations where Scaffold tiles will be placed - internal static Effect WulfrumScaffoldSelection; + internal static Asset WulfrumScaffoldSelection; // Used to render the Rover Drive's force field around the player - internal static Effect RoverDriveShield; + internal static Asset RoverDriveShield; // UNUSED -- Probably leftover from Iban's work on the Biome Blade and Ark lines. - internal static Effect RotateSprite; + internal static Asset RotateSprite; // Used on Exoblade to draw the sword swinging dramatically. This was the edit Iban made to Dom's Exoblade. - internal static Effect SwingSprite; + internal static Asset SwingSprite; #endregion // @@ -181,14 +186,14 @@ namespace CalamityMod.Effects #region Ozz's Shaders // Used on players and NPCs when they have the Miracle Blight debuff. - internal static Effect MiracleBlight; + internal static Asset MiracleBlight; #endregion #region Aqua's Shaders - internal static Effect CircularGradientWithEdge; - internal static Effect GaleforceArrowTrailShader; - internal static Effect WavyOpacity; - internal static Effect HellBall; + internal static Asset CircularGradientWithEdge; + internal static Asset GaleforceArrowTrailShader; + internal static Asset WavyOpacity; + internal static Asset HellBall; #endregion // @@ -197,32 +202,86 @@ namespace CalamityMod.Effects // #region Amber's Shaders - internal static Effect PrimitiveClearShader; - internal static Effect HolyInfernoShader; - internal static Effect DeerclopsShadowShader; + internal static Asset PrimitiveClearShader; + internal static Asset HolyInfernoShader; #endregion #region YuH's Shaders - internal static Effect TeslaTrailShader; + internal static Asset TeslaTrailShader; #endregion + #region Doze's Shaders + /// + /// The shader used for Abyss's custom light system. + /// Basically works by turning textures into an opacity mask + /// + internal static Asset DozeLightingShader; + /// + /// Flips the screen. Used for Gravity Globe. + /// + internal static Asset FlipScreenShader; + /// + /// Distorts a texture towards the center based on a provided noisemap. Meant to emulate the Terraria Otherworld barrier effects. + /// Opacity is the intensity of this distortion, and Saturation is the speed the noisemap moves at. + /// + internal static Asset OtherworldBarrierDistortionShader; + #endregion + + // + // All below shaders were created by fryzahh + // + #region fryzahh's Shaders + // A simple shader which distorts an image using a provided texture of choice. + internal static Asset BasicTextureDistortionShader; + + // The underwater rays seen at the top of the Sunken Sea Mod Menu. + internal static Asset UnderwaterRaysShader; + + // The blowing wind-like effect seen in the background during DoG's fight. + internal static Asset DoGDistortionWindsShader; + + // The rolling fog clouds seen behind the Distortion Winds effect during DoG's fight. + internal static Asset DoGBackgroundFogShader; + + // Allows a texture to control its opacity from the edges to the center in the shape of a circle. + internal static Asset CircularOpacityShader; + + // The shader effect imposed onto the static crack textures seen during DoG's fight. Fades out the texture from its edges to its center and + // allows it to lerp between two colors depending on the brightness of individual pixels along the sampled texture. + internal static Asset DoGRealityCrackShader; + + // The distorted circular effect seen emanating from the distortion rift during DoG's fight. + internal static Asset DoGRiftAuraShader; + #endregion + + #region Big E's Shaders + internal static Asset RadialBlur; + + internal static Asset SeaPrismColorBlendingShader; + internal static Asset Dissolve; + + internal static Asset BrainOfCthulhuForcefield; + #endregion + + internal static Asset SunkenSeaMenuLogoWater; + public override void PostSetupContent() { AssetRepository calAss = CalamityMod.Instance.Assets; // Shorthand to load shaders immediately. // Strings provided to LoadShader are the .xnb file paths. - Effect LoadShader(string path) => calAss.Request($"{ShaderPath}{path}", AssetRequestMode.ImmediateLoad).Value; + Asset LoadShader(string path) => calAss.Request($"{ShaderPath}{path}", AssetRequestMode.ImmediateLoad); // // Loading and registering each individual compiled shader for use. // AstralFogShader = LoadShader("AstralFogShader"); - var astralPassReg = new AstralScreenShaderData(new Ref(AstralFogShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f); + var astralPassReg = new AstralScreenShaderData(AstralFogShader, "AstralPass").UseColor(0.18f, 0.08f, 0.24f); RegisterSceneFilter(astralPassReg, "Astral", EffectPriority.VeryHigh); - #region Loading Dominic's Shaders + #region Loading Lucille's Shaders DanceOfLightBlindingShader = LoadShader("LightBurstShader"); RegisterScreenShader(DanceOfLightBlindingShader, "BurstPass", "LightBurst"); @@ -345,6 +404,12 @@ namespace CalamityMod.Effects // This shader is not registered with the game but is invoked directly to render the results of fluid simulation. FluidShaders = LoadShader("FluidShaders"); + + SylvestaffProjectileShader = LoadShader("SylvestaffProjectileShader"); + RegisterMiscShader(SylvestaffProjectileShader, "TrailPass", "SylvestaffProjectile"); + + SylvestaffRibbonShader = LoadShader("SylvestaffRibbonShader"); + RegisterMiscShader(SylvestaffRibbonShader, "AutoloadPass", "SylvestaffRibbon"); #endregion #region Loading Iban's Shaders @@ -399,24 +464,70 @@ namespace CalamityMod.Effects HolyInfernoShader = LoadShader("ScreenShaders/HolyInfernoShader"); RegisterMiscShader(HolyInfernoShader, "InfernoPass", "HolyInfernoShader"); - DeerclopsShadowShader = LoadShader("ScreenShaders/DeerclopsShadowShader"); - RegisterMiscShader(DeerclopsShadowShader, "ShadowPass", "DeerclopsShadowShader"); - #endregion #region Loading YuH's Shaders TeslaTrailShader = LoadShader("TeslaTrail"); RegisterMiscShader(TeslaTrailShader, "TrailPass", "TeslaTrail"); #endregion + + #region Loading Doze's Shaders + DozeLightingShader = LoadShader("DozeLightingShader"); + RegisterMiscShader(DozeLightingShader, "ShadowPass", "DozeLightingShader"); + + FlipScreenShader = LoadShader("ScreenShaders/FlipScreen"); + RegisterScreenShader(FlipScreenShader, "FlipTheScreen", "FlipScreen",EffectPriority.VeryHigh); + + OtherworldBarrierDistortionShader = LoadShader("OtherworldBarrierDistortion"); + RegisterMiscShader(OtherworldBarrierDistortionShader, "DistortionPass", "OtherworldBarrierDistortion"); + #endregion + + #region Loading fryzahh's Shaders + BasicTextureDistortionShader = LoadShader("BasicTextureDistortionShader"); + RegisterMiscShader(BasicTextureDistortionShader, "DistortionPass", "BasicTextureDistortion"); + + UnderwaterRaysShader = LoadShader("UnderwaterRaysShader"); + RegisterMiscShader(UnderwaterRaysShader, "UnderwaterRayPass", "UnderwaterRays"); + + DoGDistortionWindsShader = LoadShader("DoGDistortionWindsShader"); + RegisterMiscShader(DoGDistortionWindsShader, "DistortionWindsPass", "DoGDistortionWinds"); + + DoGBackgroundFogShader = LoadShader("DoGBackgroundFogShader"); + RegisterMiscShader(DoGBackgroundFogShader, "DoGFogPass", "DoGBackgroundFog"); + + CircularOpacityShader = LoadShader("CircularOpacityShader"); + RegisterMiscShader(CircularOpacityShader, "CircularOpacityPass", "CircularOpacity"); + + DoGRealityCrackShader = LoadShader("DoGRealityCrackShader"); + RegisterMiscShader(DoGRealityCrackShader, "DoGRealityCrackPass", "DoGRealityCrack"); + + DoGRiftAuraShader = LoadShader("DoGRiftAuraShader"); + RegisterMiscShader(DoGRiftAuraShader, "DoGRiftAuraPass", "DoGRiftAura"); + #endregion + + #region Loading Big E's Shaders + RadialBlur = LoadShader("ScreenShaders/RadialBlur"); + RegisterScreenShader(RadialBlur, "RadialBlurPass", "RadialBlurShader"); + + SeaPrismColorBlendingShader = LoadShader("SeaPrismColorBlending"); + RegisterMiscShader(SeaPrismColorBlendingShader, "SeaPrismBlendingPass", "SeaPrismColorBlending"); + + Dissolve = LoadShader("Dissolve"); + RegisterMiscShader(Dissolve, "DissolvePass", "Dissolve"); + + BrainOfCthulhuForcefield = LoadShader("ScreenShaders/BrainOfCthulhuForcefield"); + RegisterScreenShader(BrainOfCthulhuForcefield, "BoCShieldPass", "BrainOfCthulhuForcefield"); + #endregion + + SunkenSeaMenuLogoWater = LoadShader("UI/SunkenSeaMenuLogoWater"); } // Shorthand to register a loaded shader in Terraria's graphics engine // All shaders registered this way are accessible under GameShaders.Misc // They will use the prefix described above - private static void RegisterMiscShader(Effect shader, string passName, string registrationName) + private static void RegisterMiscShader(Asset shader, string passName, string registrationName) { - Ref shaderPointer = new(shader); - MiscShaderData passParamRegistration = new(shaderPointer, passName); + MiscShaderData passParamRegistration = new(shader, passName); GameShaders.Misc[$"{CalamityShaderPrefix}{registrationName}"] = passParamRegistration; } @@ -430,10 +541,9 @@ namespace CalamityMod.Effects // Shorthand to register a loaded shader in Terraria's graphics engine // All shaders registered this way are accessible under Filters.Scene // They will use the prefix described above - private static void RegisterScreenShader(Effect shader, string passName, string registrationName, EffectPriority priority = EffectPriority.High) + private static void RegisterScreenShader(Asset shader, string passName, string registrationName, EffectPriority priority = EffectPriority.High) { - Ref shaderPointer = new(shader); - ScreenShaderData passParamRegistration = new(shaderPointer, passName); + ScreenShaderData passParamRegistration = new(shader, passName); RegisterSceneFilter(passParamRegistration, registrationName, priority); } } diff --git a/Effects/CircularOpacityShader.fx b/Effects/CircularOpacityShader.fx new file mode 100644 index 0000000000..64ca9b6163 --- /dev/null +++ b/Effects/CircularOpacityShader.fx @@ -0,0 +1,32 @@ +sampler baseTexture : register(s0); + +float opacityCutoffValue; +float fadeoutPower; +float overallOpacity; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + + float2 polarCoords = float2(polarAngle, distanceToCenter); + float4 color = tex2D(baseTexture, coords); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + color.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + return color * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass CircularOpacityPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/CircularOpacityShader.xnb b/Effects/CircularOpacityShader.xnb new file mode 100644 index 0000000000..143430cf37 Binary files /dev/null and b/Effects/CircularOpacityShader.xnb differ diff --git a/Effects/Dissolve.fx b/Effects/Dissolve.fx new file mode 100644 index 0000000000..db24dcb69b --- /dev/null +++ b/Effects/Dissolve.fx @@ -0,0 +1,38 @@ +sampler baseTexture : register(s0); +sampler noiseTexture : register(s1); + +float noiseScale; +float dissolveIntensity; +float2 sampleOffset; +float4 transitionColor; +float transitionOffset; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR +{ + float4 color = tex2D(baseTexture, coords) * sampleColor; + + // Sample noise texture for dithering + float noise = tex2D(noiseTexture, (coords * noiseScale) + sampleOffset).r; + + if (dissolveIntensity > noise) + { + if (dissolveIntensity - transitionOffset < noise) + { + float a = color.a; + color = transitionColor; + color.a = a; + } + else + color.a = 0; + } + + return color; +} + +technique Technique1 +{ + pass DissolvePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dissolve.xnb b/Effects/Dissolve.xnb new file mode 100644 index 0000000000..454b0bdaa2 Binary files /dev/null and b/Effects/Dissolve.xnb differ diff --git a/Effects/DoGBackgroundFogShader.fx b/Effects/DoGBackgroundFogShader.fx new file mode 100644 index 0000000000..898dcfd1be --- /dev/null +++ b/Effects/DoGBackgroundFogShader.fx @@ -0,0 +1,67 @@ +sampler cloudsTexture : register(s0); +sampler distortionTexture : register(s1); +sampler erosionTexture : register(s2); + +float time; +float overallOpacity; +float distortionStrength; +float mainNoiseTextureScale; +float distortionTextureScale; +float erosionTextureScale; +float erosionMin; +float gradientPrecision; + +float2 pixelationFactor; +float2 worldOffset; + +float3 darkerPixelColor; +float3 brighterPixelColor; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelation. + coords = round(coords * pixelationFactor) / pixelationFactor; + + // Stretch the coords out to better mimic a blowing wind effect. + coords *= float2(0.95, 1.05); + + // Move with the player in the world. + coords += worldOffset; + + // Calculate the distortion that'll be applied to our base noise coordinates. + float2 distortedCoords = coords + float2(time * -0.03, time * -0.01) * distortionTextureScale; + float distortion = tex2D(distortionTexture, distortedCoords).r * distortionStrength; + + // Calculate the base noise colors. + float2 adjustedCoords = (coords + distortion) * mainNoiseTextureScale; + float4 scrollingNoise1 = tex2D(cloudsTexture, adjustedCoords + float2(time * -0.065, 0)); + float4 scrollingNoise2 = tex2D(cloudsTexture, adjustedCoords + float2(time * -0.015, 0)); + + // Multiply the red values of the noise maps together to get the horizontal brightness of both noise maps. + float combinedBrightness = scrollingNoise1.r * scrollingNoise2.r; + + // Lerp between the two colors based on the brightness of a pixel. + float3 colorFromBrightness = lerp(darkerPixelColor, brighterPixelColor, combinedBrightness); + + // Erode the final output to break up the entire effect slightly. + float erosionColor = tex2D(erosionTexture, adjustedCoords + float2(time * -0.07, time * -0.02) * erosionTextureScale); + float erosionMax = erosionMin + 1; + float erosion = smoothstep(erosionMin, erosionMax, erosionColor.r); + + float4 finalColor = (float4(colorFromBrightness, 1) * (scrollingNoise1 + scrollingNoise2)); + finalColor *= erosion; + + // Apply posterization. + finalColor = round(finalColor * gradientPrecision) / gradientPrecision; + + return finalColor * overallOpacity; + +} + +technique Technique1 +{ + pass DoGFogPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/DoGBackgroundFogShader.xnb b/Effects/DoGBackgroundFogShader.xnb new file mode 100644 index 0000000000..55719fcf22 Binary files /dev/null and b/Effects/DoGBackgroundFogShader.xnb differ diff --git a/Effects/DoGDisintegration.fx b/Effects/DoGDisintegration.fx index 7473ea481a..3e0f61e541 100644 --- a/Effects/DoGDisintegration.fx +++ b/Effects/DoGDisintegration.fx @@ -1,39 +1,35 @@ -sampler uImage0 : register(s0); -sampler uImage1 : register(s1); -float3 uColor; -float3 uSecondaryColor; -float uOpacity : register(C0); -float uSaturation; -float uRotation; -float uTime; -float4 uSourceRect; -float2 uWorldPosition; -float uDirection; -float3 uLightSource; -float2 uImageSize0; -float2 uImageSize1; -float4 uShaderSpecificData; +sampler baseTexture : register(s0); +sampler disintegrationTexture : register(s1); + +float disintegrationProgress : register(C0); +float disintegrationScale; +float2 worldPosition; +float2 pixelSize; // This shader is largely based on code used for ExampleMod's cool death animation thing; it is suprisingly useful for this use case. float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 { - float4 color = tex2D(uImage0, coords); + float4 color = tex2D(baseTexture, coords); if (!any(color)) return color; - float fade = pow(saturate(1 - uOpacity), 0.7); - float4 color1 = tex2D(uImage1, float2(coords.x, frac(coords.y + uSaturation * 0.11)) * 0.3); + coords += worldPosition; + coords = round(coords * pixelSize) / pixelSize; + + float disintegration = pow(saturate(1 - disintegrationProgress), 0.7); + float2 disintegrationCoords = coords * disintegrationScale; + float4 disintegrationColor = tex2D(disintegrationTexture, disintegrationCoords); - float readRed = fade * 1.05; - - if (color1.r > readRed) + float disappearThreshold = disintegration * 1.05; + if (disintegrationColor.r > disappearThreshold) { color.rgba = 0; } - else if (color1.b > fade) + else if (disintegrationColor.b > disintegration) { color = float4(1, 105.0 / 255, 180.0 / 255, 1); } + return color; } @@ -41,6 +37,6 @@ technique Technique1 { pass DisintegrationPass { - PixelShader = compile ps_2_0 PixelShaderFunction(); + PixelShader = compile ps_3_0 PixelShaderFunction(); } } \ No newline at end of file diff --git a/Effects/DoGDisintegration.xnb b/Effects/DoGDisintegration.xnb index bbc4f237f3..a841c844da 100644 Binary files a/Effects/DoGDisintegration.xnb and b/Effects/DoGDisintegration.xnb differ diff --git a/Effects/DoGDistortionWindsShader.fx b/Effects/DoGDistortionWindsShader.fx new file mode 100644 index 0000000000..85270ead68 --- /dev/null +++ b/Effects/DoGDistortionWindsShader.fx @@ -0,0 +1,76 @@ +sampler mainWindTexture : register(s0); +sampler windHighlightsTexture : register(s1); +sampler distortionTexture : register(s2); +sampler erosionTexture : register(s3); + +float time; +float overallOpacity; +float distortionStrength; +float mainNoiseTextureScale; +float distortionTextureScale; +float erosionTextureScale; +float erosionMin; +float gradientPrecision; + +float2 pixelationFactor; +float2 worldOffset; + +float3 darkerPixelColor; +float3 brighterPixelColor; +float3 highlightsColor; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelation. + coords = round(coords * pixelationFactor) / pixelationFactor; + + // Stretch the coords out to better mimic a blowing wind effect. + coords *= float2(0.25, 1.25); + + // Distort the coords in a sine wave so that they bend up and down. + coords.y += sin(coords.x * 10 + time) * 0.25; + + // Move with the player in the world. + coords += worldOffset; + + // Calculate the distortion that'll be applied to our base noise coordinates. + float2 distortedCoords = coords + float2(time * -0.18, 0) * distortionTextureScale; + float distortion = tex2D(distortionTexture, distortedCoords).r * distortionStrength; + + // Calculate the base noise colors. + float2 adjustedCoords = (coords + distortion) * mainNoiseTextureScale; + float4 scrollingNoise1 = tex2D(mainWindTexture, adjustedCoords + float2(time * -0.092, 0)); + float4 scrollingNoise2 = tex2D(mainWindTexture, adjustedCoords + float2(time * -0.031, 0)); + + // Multiply the red values of the noise maps together to get the horizontal brightness of both noise maps. + float combinedBrightness = scrollingNoise1.r * scrollingNoise2.r; + + // Lerp between the two colors based on the brightness of a pixel. + float3 colorFromBrightness = lerp(darkerPixelColor, brighterPixelColor, combinedBrightness); + + // Sample another texture to be used as highlights alongside the two noise textures. + float4 highlightNoise = tex2D(windHighlightsTexture, adjustedCoords + float2(time * -0.115, 0)); + float4 windHighlights = highlightNoise * float4(highlightsColor, 1); + + // Erode the final output to break up the entire effect slightly. + float erosionColor = tex2D(erosionTexture, adjustedCoords + float2(time * -0.087, 0) * erosionTextureScale); + float erosionMax = erosionMin + 1; + float erosion = smoothstep(erosionMin, erosionMax, erosionColor.r); + + float4 finalColor = (float4(colorFromBrightness, 1) * (scrollingNoise1 + scrollingNoise2)) + (windHighlights * 2.25); + finalColor *= erosion; + + // Apply posterization. + finalColor = round(finalColor * gradientPrecision) / gradientPrecision; + + return finalColor * overallOpacity; + +} + +technique Technique1 +{ + pass DistortionWindsPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/DoGDistortionWindsShader.xnb b/Effects/DoGDistortionWindsShader.xnb new file mode 100644 index 0000000000..d28e773884 Binary files /dev/null and b/Effects/DoGDistortionWindsShader.xnb differ diff --git a/Effects/DoGRealityCrackShader.fx b/Effects/DoGRealityCrackShader.fx new file mode 100644 index 0000000000..2c9f7b0c28 --- /dev/null +++ b/Effects/DoGRealityCrackShader.fx @@ -0,0 +1,54 @@ +sampler baseTexture : register(s0); + +float overallOpacity; +float opacityCutoffValue; +float fadeoutPower; +float minBrightnessValue; +float gradientPrecision; + +float3 brighterPixelColor; +float3 darkerPixelColor; + +float InverseLerp(float from, float to, float value) +{ + return (value - from) / (to - from); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + + float2 polarCoords = float2(polarAngle, distanceToCenter); + float4 color = tex2D(baseTexture, coords); + + // Get the horizontal brightness of the sampled texture and apply coloration. + float brightness = (color.r + color.g + color.b) / 3; + float brightnessRatio = InverseLerp(minBrightnessValue, 1, brightness); + float3 colorFromBrightness = lerp(darkerPixelColor, brighterPixelColor, brightnessRatio); + + float4 coloredSample = color * float4(colorFromBrightness, 1); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + coloredSample.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + // Apply optional posterization. + /*if (gradientPrecision > 0) + finalColor = round(finalColor * gradientPrecision) / gradientPrecision; + */ + return coloredSample * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass DoGRealityCrackPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} + diff --git a/Effects/DoGRealityCrackShader.xnb b/Effects/DoGRealityCrackShader.xnb new file mode 100644 index 0000000000..fb989a9310 Binary files /dev/null and b/Effects/DoGRealityCrackShader.xnb differ diff --git a/Effects/DoGRiftAuraShader.fx b/Effects/DoGRiftAuraShader.fx new file mode 100644 index 0000000000..6d6439cf93 --- /dev/null +++ b/Effects/DoGRiftAuraShader.fx @@ -0,0 +1,62 @@ +sampler baseTexture : register(s0); +sampler distortionTexture : register(s1); + +float time; +float overallOpacity; +float distortionStrength; +float opacityCutoffValue; +float fadeoutPower; +float minBrightnessValue; +float gradientPrecision; +float2 pixelSize; +float3 brighterPixelColor; + +float InverseLerp(float from, float to, float value) +{ + return (value - from) / (to - from); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelate. + coords = round(coords * pixelSize) / pixelSize; + + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + float2 polarCoords = float2(polarAngle, distanceToCenter); + + // Apply distortion to the main texture. + float distortion = tex2D(distortionTexture, polarCoords + float2(time * 0.017, time * -0.026)).r * distortionStrength; + float2 baseCoords = coords * distortion; + baseCoords *= 0.4; + float4 color = tex2D(baseTexture, baseCoords); + + // Get the horizontal brightness of the sampled texture and apply coloration. + float brightness = (color.r + color.g + color.b) / 3; + float brightnessRatio = InverseLerp(minBrightnessValue, 1, brightness); + float3 colorFromBrightness = lerp(float3(0, 0, 0), brighterPixelColor, brightnessRatio); + + float4 coloredSample = color * float4(colorFromBrightness, 1); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing/decreasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + coloredSample.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + // Apply optional posterization. + if (gradientPrecision > 0) + coloredSample = round(coloredSample * gradientPrecision) / gradientPrecision; + + return coloredSample * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass DoGRiftAuraPass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} diff --git a/Effects/DoGRiftAuraShader.xnb b/Effects/DoGRiftAuraShader.xnb new file mode 100644 index 0000000000..1042c87024 Binary files /dev/null and b/Effects/DoGRiftAuraShader.xnb differ diff --git a/Effects/DozeLightingShader.fx b/Effects/DozeLightingShader.fx new file mode 100644 index 0000000000..21375981f2 --- /dev/null +++ b/Effects/DozeLightingShader.fx @@ -0,0 +1,15 @@ +sampler uImage0 : register(s0); +float uOpacity; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 baseColor = tex2D(uImage0, coords); + return float4(0, 0, 0, (1 - baseColor.x) * uOpacity); +} +technique Technique1 +{ + pass ShadowPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/DozeLightingShader.xnb b/Effects/DozeLightingShader.xnb new file mode 100644 index 0000000000..5016f55158 Binary files /dev/null and b/Effects/DozeLightingShader.xnb differ diff --git a/Effects/Dyes/InvisibleDyeShader.fx b/Effects/Dyes/InvisibleDyeShader.fx new file mode 100644 index 0000000000..e1b691da39 --- /dev/null +++ b/Effects/Dyes/InvisibleDyeShader.fx @@ -0,0 +1,33 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float2 uTargetPosition; +float4 uLegacyArmorSourceRect; +float2 uLegacyArmorSheetSize; + +float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + color.rgb *= 0; + color.a = 0; + return color; +} + +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/InvisibleDyeShader.xnb b/Effects/Dyes/InvisibleDyeShader.xnb new file mode 100644 index 0000000000..738b0c2935 Binary files /dev/null and b/Effects/Dyes/InvisibleDyeShader.xnb differ diff --git a/Effects/Metaballs/MetaballEdgeShader.fx b/Effects/Metaballs/MetaballEdgeShader.fx index 3f04f11485..53e278d2d1 100644 --- a/Effects/Metaballs/MetaballEdgeShader.fx +++ b/Effects/Metaballs/MetaballEdgeShader.fx @@ -6,6 +6,7 @@ float2 layerSize; float2 layerOffset; float4 edgeColor; float2 singleFrameScreenOffset; +float4 layerColor; // The usage of these two methods seemingly prevents imprecision problems for some reason. float2 convertToScreenCoords(float2 coords) @@ -43,8 +44,8 @@ float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD float conditionOpacityFactor = 1 - saturate(leftHasNoAlpha + rightHasNoAlpha + topHasNoAlpha + bottomHasNoAlpha); // Calculate layer colors. - float4 layerColor = tex2D(overlayTexture, (coords + layerOffset + singleFrameScreenOffset) * screenSize / layerSize); - float4 defaultColor = layerColor * tex2D(metaballContents, coords) * sampleColor; + float4 layerCalcedColor = tex2D(overlayTexture, (coords + layerOffset + singleFrameScreenOffset) * screenSize / layerSize); + float4 defaultColor = layerCalcedColor * tex2D(metaballContents, coords) * sampleColor * layerColor; // Lastly, use the aforementioned condition to switch between the colors. If conditionOpacityFactor is 1, the default color is // zeroed out and the edge is toggled, and vice versa. diff --git a/Effects/Metaballs/MetaballEdgeShader.xnb b/Effects/Metaballs/MetaballEdgeShader.xnb index 6ee03aac55..9b1a53c7b8 100644 Binary files a/Effects/Metaballs/MetaballEdgeShader.xnb and b/Effects/Metaballs/MetaballEdgeShader.xnb differ diff --git a/Effects/OtherworldBarrierDistortion.fx b/Effects/OtherworldBarrierDistortion.fx new file mode 100644 index 0000000000..9f854ad59a --- /dev/null +++ b/Effects/OtherworldBarrierDistortion.fx @@ -0,0 +1,52 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; //Opacity works as the intensity of the filter +float uSaturation; //Saturation works as the speed of the noise movement +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float4 uShaderSpecificData; + +float4 AdjustPixelPosition(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Drift to offset the noisemap. X multiplier is a prime number to ensure the "loop time" of this is very high, it takes 100 uTime to return to the original state + float2 drift = float2(0.23 * uTime * uSaturation, uTime * uSaturation); + + //This is the uv distance from the center of the texture + float2 uvOffsetFromCenter = (coords - 0.5); + + float angle = atan2(uvOffsetFromCenter.y, uvOffsetFromCenter.x) / (2 * 3.1415926); + float dist = length(uvOffsetFromCenter); + float2 polarUV = float2(angle, dist); + + // Gets the offset from the red channel of whatever pixel this should get from the noisemap. This is fine because the noisemap is greyscale. + float offsetToHave = tex2D(uImage1, polarUV + drift).x; + + //This mask is to prevent weird stretching effects at the edge of the texture + float2 modifiedCoords = coords + uvOffsetFromCenter * offsetToHave * uOpacity; + float mask = step(0, modifiedCoords.x) * step(modifiedCoords.y, 1) * + step(0, modifiedCoords.y) * step(modifiedCoords.x, 1); + + // This makes a greyscale image designed for additve use transparent for non-additve use. + // I would like to be able to draw directly additive, but I have been unable to make that work and this has worked well. + float4 distortedColor = tex2D(uImage0, modifiedCoords); + distortedColor.a = distortedColor.x; + + return distortedColor * sampleColor * mask; +} + + +technique Technique1 +{ + pass DistortionPass + { + PixelShader = compile ps_2_0 AdjustPixelPosition(); + } +} \ No newline at end of file diff --git a/Effects/OtherworldBarrierDistortion.xnb b/Effects/OtherworldBarrierDistortion.xnb new file mode 100644 index 0000000000..d933cce2e5 Binary files /dev/null and b/Effects/OtherworldBarrierDistortion.xnb differ diff --git a/Effects/ScreenShaders/BrainOfCthulhuForcefield.fx b/Effects/ScreenShaders/BrainOfCthulhuForcefield.fx new file mode 100644 index 0000000000..1cb2bd9f55 --- /dev/null +++ b/Effects/ScreenShaders/BrainOfCthulhuForcefield.fx @@ -0,0 +1,149 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +sampler uImage2 : register(s2); +sampler uImage3 : register(s3); +texture voronoi; +sampler2D voronoiSampler = sampler_state +{ + texture = ; + magfilter = LINEAR; + minfilter = LINEAR; + mipfilter = LINEAR; + AddressU = wrap; + AddressV = wrap; +}; + +texture depthNoise; +sampler2D noiseSampler = sampler_state +{ + texture = ; + magfilter = LINEAR; + minfilter = LINEAR; + mipfilter = LINEAR; + AddressU = wrap; + AddressV = wrap; +}; + +float3 uColor; +float3 uSecondaryColor; +float2 uScreenResolution; +float2 uScreenPosition; +float2 uTargetPosition; +float2 uDirection; +float uOpacity; +float uTime; +float uIntensity; +float uProgress; +float2 uImageSize1; +float2 uImageSize2; +float2 uImageSize3; +float2 uImageOffset; +float uSaturation; +float4 uSourceRect; +float2 uZoom; + +float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 +{ + float resolutionRatio = uScreenResolution.x / uScreenResolution.y; + + float screenScale = 1080.0 / min(uScreenResolution.x, uScreenResolution.y); + + float pixelSize = 0.002 * uZoom; + float2 aspectCorrectedCoords = coords; + aspectCorrectedCoords.x *= resolutionRatio; + float2 pixelatedCoords = floor(aspectCorrectedCoords / pixelSize) * pixelSize + pixelSize * 0.5; + pixelatedCoords.x /= resolutionRatio; + + float radius = uProgress * screenScale * resolutionRatio; + + float4 baseColor = (1, 1, 1, 1); + baseColor.rgb = uColor; + + float4 edgeColor = (1, 1, 1, 1); + edgeColor.rgb = uSecondaryColor; + + float2 center = (uDirection - (0.5, 0.5)) * 2; + center.x *= resolutionRatio; + + float2 correctedCoords = (pixelatedCoords - (0.5, 0.5)) * 2; + correctedCoords.x *= resolutionRatio; + float2 correctedTrueCoords = (coords - (0.5, 0.5)) * 2; + correctedTrueCoords.x *= resolutionRatio; + + float2 centerOffset = center - correctedCoords; + float angle = atan2(centerOffset.y, centerOffset.x); + float dist = length(centerOffset); + float2 polarUV = float2(angle, dist); + + float2 voronoiUV = float2(angle / (2 * 3.14159), dist - (uTime / 4)); + float voronoiValue = tex2D(voronoiSampler, voronoiUV).r; + + float sin1 = sin((uTime * 9) + (angle * 8)) / 132 + 0.5; + float sin2 = sin((-uTime * 3) + (angle * 16)) / 124 + 0.5; + float sin3 = sin((uTime * 6) + (angle * 6)) / 116 + 0.5; + + float voronoiStrength = 0.025; + + radius += sin1 + sin2 + sin3; + radius += voronoiValue * voronoiStrength; + radius -= 1.5; + + if (dist < radius) + { + float normalizedDist = dist / radius; + float distortionStrength = 0.15 * uOpacity; + float distortionFalloff = pow(normalizedDist, 3); + float sphericalOffset = (1.0 - normalizedDist) * distortionStrength * distortionFalloff; + float2 distortionDirection = normalize(center - correctedCoords); + float2 distortedCoords = coords + (distortionDirection * sphericalOffset * normalizedDist); + + float distDiff = (radius - dist) / radius; + if (distDiff > 0.5) + distDiff = 1; + else + distDiff *= 2; + float l = lerp(0, pow(1 - distDiff, 5), uOpacity); + + float baseWave = dist / uZoom * 50 - uTime * 7; + float angleWave = sin(angle * 12 - uTime * 4) * 0.3; + float wave = pow(max(0, sin(baseWave + angleWave)), 3) * 0.8; + + float waveFade = pow(normalizedDist, 3); + float waveIntensity = wave * waveFade * 0.7; + + float perspectiveScale = 1.0 + (normalizedDist * 3.0); + float2 noiseUV = float2( + polarUV.x / (2 * 3.14159), + polarUV.y * (perspectiveScale / uZoom.x) / 5 - (uTime * 0.2) + ); + float noiseValue = tex2D(noiseSampler, noiseUV).r; + + float noiseFade = pow(normalizedDist, 2) * 0.333; //controls overall intensity + float depthNoise = noiseValue * noiseFade; + + float4 baseTexture = tex2D(uImage0, distortedCoords); + float4 shieldColor = lerp(baseTexture, edgeColor, l); + float4 depthColor = float4(depthNoise, depthNoise, depthNoise, 0); + depthColor.rgb = lerp(edgeColor, (1, 1, 1, 1), 0.33); + depthColor *= depthNoise; + + return shieldColor + + (baseColor * waveIntensity * uOpacity) + + depthColor * uOpacity; + } + else if (dist < radius + 0.01) + { + float4 brightEdgeColor = lerp(edgeColor, (1, 1, 1, 1), 0.4); + return brightEdgeColor; + } + + return tex2D(uImage0, coords); +} + +technique Technique1 +{ + pass BoCShieldPass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ScreenShaders/BrainOfCthulhuForcefield.xnb b/Effects/ScreenShaders/BrainOfCthulhuForcefield.xnb new file mode 100644 index 0000000000..e094b881dd Binary files /dev/null and b/Effects/ScreenShaders/BrainOfCthulhuForcefield.xnb differ diff --git a/Effects/ScreenShaders/DeerclopsShadowShader.fx b/Effects/ScreenShaders/DeerclopsShadowShader.fx deleted file mode 100644 index 47273956fe..0000000000 --- a/Effects/ScreenShaders/DeerclopsShadowShader.fx +++ /dev/null @@ -1,52 +0,0 @@ -float minRadius; -float maxRadius; -float maxOpacity; - -float2 screenPosition; -float2 screenSize; -float2 anchorPoint; - -float InverseLerp(float a, float b, float t) -{ - return saturate((t - a) / (b - a)); -} - -float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 uv : TEXCOORD0) : COLOR0 -{ - float2 worldUV = screenPosition + screenSize * uv; - float2 deerclopsUV = anchorPoint / screenSize; - float worldDistance = distance(worldUV, anchorPoint); - - // Get the distance to the pixel from Deerclops - float distToDeerclops = distance(anchorPoint, worldUV); - // And get the correct opacity based on it. - float opacity = InverseLerp(0, maxRadius, distToDeerclops); - - // Define the border and mix the shadow and light for a smoother transition - bool border = worldDistance < minRadius && opacity > 0; - float colorMult = 1; - - if (worldDistance > minRadius && worldDistance < maxRadius) - opacity = lerp(opacity, maxOpacity, InverseLerp(minRadius, maxRadius, distToDeerclops)); - - opacity = clamp(opacity, 0, maxOpacity); - - if (border) - { - colorMult = InverseLerp(minRadius * 0.94, minRadius, worldDistance); - } - - // If the color multi has not been changed (not border pixel) and opacity is 0 OR it's within - if (colorMult == 1 && (opacity == 0 || worldDistance < minRadius)) - return sampleColor; - - return float4(0, 0, 0, 1) * colorMult * opacity; -} - -technique Technique1 -{ - pass ShadowPass - { - PixelShader = compile ps_2_0 PixelShaderFunction(); - } -} \ No newline at end of file diff --git a/Effects/ScreenShaders/DeerclopsShadowShader.xnb b/Effects/ScreenShaders/DeerclopsShadowShader.xnb deleted file mode 100644 index 8703cff449..0000000000 Binary files a/Effects/ScreenShaders/DeerclopsShadowShader.xnb and /dev/null differ diff --git a/Effects/ScreenShaders/FlipScreen.fx b/Effects/ScreenShaders/FlipScreen.fx new file mode 100644 index 0000000000..39ad44126c --- /dev/null +++ b/Effects/ScreenShaders/FlipScreen.fx @@ -0,0 +1,38 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +sampler uImage2 : register(s2); +sampler uImage3 : register(s3); +float3 uColor; +float3 uSecondaryColor; +float2 uScreenResolution; +float2 uScreenPosition; +float2 uTargetPosition; +float2 uDirection; +float uOpacity; +float uTime; +float uIntensity; +float uProgress; +float2 uImageSize1; +float2 uImageSize2; +float2 uImageSize3; +float2 uImageOffset; +float uSaturation; +float4 uSourceRect; +float2 uZoom; + +float4 FilterMyShader(float2 coords : TEXCOORD0) : COLOR0 +{ + float2 newCoords; + newCoords.x = coords.x; + newCoords.y = 1 - coords.y; + float4 color = tex2D(uImage0, newCoords); + return color; +} + +technique Technique1 +{ + pass FlipTheScreen + { + PixelShader = compile ps_2_0 FilterMyShader(); + } +} \ No newline at end of file diff --git a/Effects/ScreenShaders/FlipScreen.xnb b/Effects/ScreenShaders/FlipScreen.xnb new file mode 100644 index 0000000000..842a5d7873 Binary files /dev/null and b/Effects/ScreenShaders/FlipScreen.xnb differ diff --git a/Effects/ScreenShaders/RadialBlur.fx b/Effects/ScreenShaders/RadialBlur.fx new file mode 100644 index 0000000000..6e14567163 --- /dev/null +++ b/Effects/ScreenShaders/RadialBlur.fx @@ -0,0 +1,50 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +sampler uImage2 : register(s2); +sampler uImage3 : register(s3); +float3 uColor; +float3 uSecondaryColor; +float2 uScreenResolution; +float2 uScreenPosition; +float2 uTargetPosition; +float2 uDirection; +float uOpacity; +float uTime; +float uIntensity; +float uProgress; +float2 uImageSize1; +float2 uImageSize2; +float2 uImageSize3; +float2 uImageOffset; +float uSaturation; +float4 uSourceRect; +float2 uZoom; + +float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 +{ + float2 pixelCoords = coords; + + float2 dir = uDirection - pixelCoords; + float2 blur = dir * uIntensity * 0.005; + float4 baseColor = 0; + float2 sampleUV = coords; + + for (int i = 0; i < uSaturation; i++) + { + baseColor += tex2D(uImage0, sampleUV); + sampleUV += blur; + + if (i > 20) + break; + } + + return baseColor / uSaturation; +} + +technique Technique1 +{ + pass RadialBlurPass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ScreenShaders/RadialBlur.xnb b/Effects/ScreenShaders/RadialBlur.xnb new file mode 100644 index 0000000000..65c07ec30c Binary files /dev/null and b/Effects/ScreenShaders/RadialBlur.xnb differ diff --git a/Effects/SeaPrismColorBlending.fx b/Effects/SeaPrismColorBlending.fx new file mode 100644 index 0000000000..6b941440ad --- /dev/null +++ b/Effects/SeaPrismColorBlending.fx @@ -0,0 +1,69 @@ +sampler baseTexture : register(s0); +sampler greenTexture : register(s1); +sampler purpleTexture : register(s2); +sampler glintTexture : register(s3); + +float time; +float2 screenOffset; +float2 offscreenOffset; +float diagonalScreenLength; +bool doGlint; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0, float4 screenPos : VPOS) : COLOR +{ + // Calculate world position + float2 worldPos = screenPos.xy + screenOffset - offscreenOffset; + + // Sample all three textures + float4 blueColor = tex2D(baseTexture, coords); + float4 purpleColor = tex2D(purpleTexture, coords); + float4 greenColor = tex2D(greenTexture, coords); + float4 glintColor = tex2D(glintTexture, coords); + + // Calculate fade values + float fade1 = (sin(time * 0.2) + 1.0) / 2.0; + float fade2 = (sin(time * 0.1 + worldPos.x * 0.005 - worldPos.y * 0.003) + 1.0) / 2.0; + + // Blend the colors + float4 result = blueColor; + result.rgb = lerp(result.rgb, greenColor.rgb, greenColor.a * fade1); + result.rgb = lerp(result.rgb, purpleColor.rgb, purpleColor.a * fade2); + + if(doGlint) + { + // Calculate glint effect + float2 projPos = screenPos.xy - offscreenOffset; + float projection = (screenPos.x / 2.0) - (screenPos.y / 2.0); + + // Define glint beam centers + float beamCenter1 = diagonalScreenLength * 0.05; + float beamCenter2 = diagonalScreenLength * 0.5; + float beamCenter3 = diagonalScreenLength * 1.05; + + // Calculate glint strength for each beam + float dist1 = abs(projection - beamCenter1); + float dist2 = abs(projection - beamCenter2); + float dist3 = abs(projection - beamCenter3); + + float strength1 = saturate(1.0 - dist1 / 100.0); + float strength2 = saturate(1.0 - dist2 / 100.0); + float strength3 = saturate(1.0 - dist3 / 100.0); + + float totalGlintStrength = max(strength1, max(strength2, strength3)); + + // Apply glint + result.rgb = lerp(result.rgb, glintColor.rgb, glintColor.a * totalGlintStrength); + + //Additive Blend Version (VERY BRIGHT) + //result.rgb = lerp(result.rgb, result.rgb + glintColor.rgb, glintColor.a * totalGlintStrength); + } + return result * sampleColor; +} + +technique Technique1 +{ + pass SeaPrismBlendingPass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/SeaPrismColorBlending.xnb b/Effects/SeaPrismColorBlending.xnb new file mode 100644 index 0000000000..2a5812d348 Binary files /dev/null and b/Effects/SeaPrismColorBlending.xnb differ diff --git a/Effects/StormlionEffects.cs b/Effects/StormlionEffects.cs new file mode 100644 index 0000000000..0f754ef3b3 --- /dev/null +++ b/Effects/StormlionEffects.cs @@ -0,0 +1,24 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Effects +{ + public class StormlionEffects + { + // Energy + public static int EnergyDust = ModContent.DustType(); + public static Color EnergyColor = new Color(5, 187, 177); + // Flesh + public static int FleshDust = 192; + public static Color FleshColor = new Color(171, 113, 91); + + // Sounds + public static readonly SoundStyle Hit = new("CalamityMod/Sounds/NPCHit/StormlionAltHit"); + public static readonly SoundStyle Killed = new("CalamityMod/Sounds/NPCKilled/StormlionAltDeath"); + public static readonly SoundStyle Attack = new("CalamityMod/Sounds/Custom/StormlionAltShoot"); + public static readonly SoundStyle Idle1 = new("CalamityMod/Sounds/Custom/StormlionAltIdle1"); + public static readonly SoundStyle Idle2 = new("CalamityMod/Sounds/Custom/StormlionAltIdle2"); + } +} diff --git a/Effects/SylvestaffProjectileShader.fx b/Effects/SylvestaffProjectileShader.fx new file mode 100644 index 0000000000..728a0f6a9a --- /dev/null +++ b/Effects/SylvestaffProjectileShader.fx @@ -0,0 +1,76 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; +float4 uShaderSpecificData; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float3 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float3 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput) 0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + // Account for texture distortion artifacts. + coords.y = (coords.y - 0.5) / input.TextureCoordinates.z + 0.5; + + float bump = sin(coords.y * 3.141); + + // Calculate the amount of additive glow for this pixel, using a combination of a scrolling texture and an extreme + // exponential squash of the prior 0-1-0 bump, creating a "center" to the glow and ensuring that the + // ray doesn't look like just a scrolling gradient. + float streakColor = tex2D(uImage1, coords + float2(uTime * -2.75, 0)); + float glow = streakColor.r + pow(bump, 20) * 0.4; + + // Determine opacity based on a weaker exponential squash of the bump in order to create faded horizontal edges. + float opacity = pow(bump, 5); + + // Apply glow. + opacity += glow * opacity; + + return color * opacity; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/SylvestaffProjectileShader.xnb b/Effects/SylvestaffProjectileShader.xnb new file mode 100644 index 0000000000..06bc3ffb44 Binary files /dev/null and b/Effects/SylvestaffProjectileShader.xnb differ diff --git a/Effects/SylvestaffRibbonShader.fx b/Effects/SylvestaffRibbonShader.fx new file mode 100644 index 0000000000..3474df6d49 --- /dev/null +++ b/Effects/SylvestaffRibbonShader.fx @@ -0,0 +1,89 @@ +sampler noiseTextureA : register(s1); + +float pixelationFactor; +float uSaturation; +float4 uShaderSpecificData; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float3 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float3 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput) 0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +float QuadraticBump(float x) +{ + return x * (4 - x * 4); +} + +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = 1; + float2 coords = input.TextureCoordinates; + coords.y = (coords.y - 0.5) / input.TextureCoordinates.z + 0.5; + + float feelerColorStart = 0.61; + float colorSpacingFactor = 1.9; + float4 outlineColor = float4(91, 114, 119, 255) / 255; + + float erasePixelInterpolant = coords.x - 0.9 - distance(coords.y, 0.5) * 0.1; + + // Band 1: Outline color. + color = lerp(color, outlineColor, coords.x >= feelerColorStart); + + // Band 2: Pink. + float pinkStart = feelerColorStart + colorSpacingFactor * 0.01; + color = lerp(color, float4(221, 150, 179, 255) / 255, coords.x >= pinkStart); + + // Band 3: Outline color. + float outlineAStart = pinkStart + colorSpacingFactor * 0.04; + color = lerp(color, outlineColor, coords.x >= outlineAStart); + + // Band 4: Blue. + float blueStart = outlineAStart + colorSpacingFactor * 0.01; + color = lerp(color, float4(48, 117, 222, 255) / 255, coords.x >= blueStart); + + // Band 5: Baby blue. + float babyBlueStart = blueStart + colorSpacingFactor * 0.04; + color = lerp(color, float4(167, 222, 255, 255) / 255, coords.x >= babyBlueStart); + + // Add an outline to the ends of the feeler. + float horizontalDistanceFromCenter = distance(coords.y, 0.5); + color = lerp(color, outlineColor, horizontalDistanceFromCenter >= 0.3); + color = lerp(color, outlineColor, erasePixelInterpolant >= -0.02); + + float permittedDirection = sign(uSaturation); + float direction = sign(dot(input.Position.xy - uShaderSpecificData.xy, uShaderSpecificData.zw)); + erasePixelInterpolant *= direction == permittedDirection || coords.x < 0.5; + + return color * (erasePixelInterpolant < 0) * input.Color; +} + +technique Technique1 +{ + pass AutoloadPass + { + VertexShader = compile vs_3_0 VertexShaderFunction(); + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} diff --git a/Effects/SylvestaffRibbonShader.xnb b/Effects/SylvestaffRibbonShader.xnb new file mode 100644 index 0000000000..d6848767d4 Binary files /dev/null and b/Effects/SylvestaffRibbonShader.xnb differ diff --git a/Effects/UI/SunkenSeaMenuLogoWater.fxc b/Effects/UI/SunkenSeaMenuLogoWater.fxc new file mode 100644 index 0000000000..917617be13 Binary files /dev/null and b/Effects/UI/SunkenSeaMenuLogoWater.fxc differ diff --git a/Effects/UI/SunkenSeaMenuLogoWater.hlsl b/Effects/UI/SunkenSeaMenuLogoWater.hlsl new file mode 100644 index 0000000000..234d3e0f49 --- /dev/null +++ b/Effects/UI/SunkenSeaMenuLogoWater.hlsl @@ -0,0 +1,76 @@ +/* Originally written for NIGHTSHADE for use as the liquid shader in the orb + * health and mana UIs: + * https://github.com/gold-meridian/nightshade-mod/blob/df037a103cb25dac8d36622515b3793f2b10ac3f/src/Nightshade/Assets/Shaders/UI/OrbFluidFillShader.hlsl + * + * Originally authored by Blockaroz and adapted by Tomat. + */ + +#include "../pixelation.h" + +sampler uImage0 : register(s0); + +texture uTexture0; +sampler tex0 = sampler_state +{ + texture = ; + magfilter = POINT; + minfilter = POINT; + mipfilter = POINT; + AddressU = wrap; + AddressV = wrap; +}; + +texture uBubbleTexture; +sampler bubbleTex = sampler_state +{ + texture = ; + magfilter = POINT; + minfilter = POINT; + mipfilter = POINT; + AddressU = wrap; + AddressV = wrap; +}; + +float2 uImageSize; +float uTime; +float uFillAmount; +float4 uFillColor; +float4 uEdgeColor; +float4 uLineColor; +float uWaveStrength; +float uWaveOffset; +float uSubtract; + +float4 main(float2 uv : TEXCOORD0, float4 baseColor : COLOR0) : COLOR0 +{ + float4 image = tex2D(uImage0, uv); + + uv = normalize_with_pixelation(uv * uImageSize, 2, uImageSize); + float2 center = uv * 2 - 1; + float distFromCenter = length(center); + + float2 uvForNoise = uv * uImageSize / 128; + + float4 bubbles = tex2D(bubbleTex, uvForNoise + float2(uTime / 10, uTime / 6)); + float4 bubbles2 = tex2D(bubbleTex, uvForNoise + float2((bubbles.r - 0.5) * 0.5, uTime / 10)); + float4 noise = tex2D(tex0, uvForNoise + float2(uTime / 6 + (bubbles.r - 0.5) * 0.05, (bubbles2.r - 0.5) * 0.1)); + uv.y = lerp(uv.y, uv.y, 0.15); + + float fillAmount = 1.0f - uFillAmount; + float bumpLine = 0.2f * (smoothstep(0.9f, 1.0f, uFillAmount) - smoothstep(0.1f, 0.0f, uFillAmount)); + float height = uv.y + (sin(3.1415 * ((uv.x * uImageSize.x / 100 + uWaveOffset) * 1.5 - uTime)) + length(bubbles.rgb)) * uWaveStrength / uImageSize.y + bumpLine - (fillAmount + 2.0f / uImageSize.y); + float edgeGlow = pow(distFromCenter * 0.8 + (uv.y + height - 0.33f) * 0.2, (1 + length(noise.rgb)) * uSubtract) * (distFromCenter * 1.5 + 1 - length(noise.rgb)); + + float topCut = smoothstep(-1.5 / uImageSize.y, 0.5 / uImageSize.y, height); + float topLine = smoothstep(1.8 / uImageSize.y, 0, height) * 1.5 * sqrt(1 - distFromCenter) - (bubbles2 - bubbles) * (1 - height) * 0.2; + + return ((lerp(uFillColor - 0.3 * topCut * uSubtract, uEdgeColor * 0.9, clamp(edgeGlow * length(image.rgb) / 2, 0, 1.3)) + topLine * 2 * uLineColor) * topCut) * image; +} + +technique Technique1 +{ + pass WaterShader + { + PixelShader = compile ps_3_0 main(); + } +} \ No newline at end of file diff --git a/Effects/UnderwaterRaysShader.fx b/Effects/UnderwaterRaysShader.fx new file mode 100644 index 0000000000..652afbcca4 --- /dev/null +++ b/Effects/UnderwaterRaysShader.fx @@ -0,0 +1,48 @@ +sampler baseTexture : register(s0); + +float time; +float fadeOutMargin; +float overallOpacity; +float pixelationAmount; +float scrollSpeedX; +float scrollSpeedY; +float2 noiseScale; +float3 rayColor; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelation. + coords = round(coords * pixelationAmount) / pixelationAmount; + + // Distort the coords into a sine wave. + coords.y += sin(coords.x + time * 0.25) * 0.05; + + // Get the correct scale for our two noise maps. + float2 scaledCoords = coords * noiseScale; + + // Calculate the offsets for each noise map. + float2 noiseOffset1 = float2(time * scrollSpeedX, time * scrollSpeedY); + float2 noiseOffset2 = float2(time * -scrollSpeedX, time * -scrollSpeedY); + + // Calculate the colors of the two noise maps. + float4 noiseTexture1 = tex2D(baseTexture, scaledCoords + noiseOffset1); + float4 noiseTexture2 = tex2D(baseTexture, scaledCoords + noiseOffset2); + + // Add the noise maps together to layer them over each other. + // Ensure to add them at 50% intensity to avoid making a super bright effect. + float combinedNoise = (noiseTexture1.r * 0.5) + (noiseTexture2.r * 0.5); + + // Fade out at a certain margin. + float opacity = (1 - (coords.y * 2 - fadeOutMargin)); + + return (float4(rayColor, 1) * combinedNoise * opacity) * overallOpacity; + +} + +technique Technique1 +{ + pass UnderwaterRayPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/UnderwaterRaysShader.xnb b/Effects/UnderwaterRaysShader.xnb new file mode 100644 index 0000000000..9faf1094f5 Binary files /dev/null and b/Effects/UnderwaterRaysShader.xnb differ diff --git a/Effects/pixelation.h b/Effects/pixelation.h new file mode 100644 index 0000000000..60dae6f5fc --- /dev/null +++ b/Effects/pixelation.h @@ -0,0 +1,40 @@ +#ifndef PIXELATION_HLSL +#define PIXELATION_HLSL + +/** + * Applies pixelation to the given coordinates based on a defined pixel size and + * outputs the normalized coordinates. + * + * @param coords The coordinates within the resolution space. + * @param pixel_size The size of each pixel block. + * @param resolution The resolution with which to normalize the coords by. + * @return The normalized, pixelated texture coordinates. + */ +float2 normalize_with_pixelation(float2 coords, float pixel_size, float2 resolution) +{ + return floor(coords / pixel_size) / (resolution / pixel_size); +} + +float2 pixelate(float2 coords, float pixel_size) +{ + return floor(coords / pixel_size) * pixel_size; +} + +/** + * Quantizes the input color to a given resolution. + * + * @param color The input color. + * @param color_resolution The resolution of quantization. + * @return The quantized color. + */ +float3 quantize_color(float3 color, float3 color_resolution) +{ + return floor(color * color_resolution) / (color_resolution - 1.0f); +} + +float4 quantize_color_with_alpha(float4 color, float4 color_resolution) +{ + return floor(color * color_resolution) / (color_resolution - 1.0f); +} + +#endif // PIXELATION_HLSL \ No newline at end of file diff --git a/Enums/ConvertType.cs b/Enums/ConvertType.cs deleted file mode 100644 index ebea6267a6..0000000000 --- a/Enums/ConvertType.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CalamityMod -{ - public enum ConvertType - { - Pure, - Corrupt, - Crimson, - Hallow - } -} diff --git a/Enums/CooldownDisplayOptions.cs b/Enums/CooldownDisplayOptions.cs new file mode 100644 index 0000000000..2c6f90eadd --- /dev/null +++ b/Enums/CooldownDisplayOptions.cs @@ -0,0 +1,9 @@ +namespace CalamityMod.Enums +{ + public enum CooldownDisplayOptions + { + Full, + Compact, + Hidden + } +} diff --git a/Enums/GeneralDrawLayer.cs b/Enums/GeneralDrawLayer.cs new file mode 100644 index 0000000000..b7cc6cd797 --- /dev/null +++ b/Enums/GeneralDrawLayer.cs @@ -0,0 +1,21 @@ +using System; + +namespace CalamityMod.Enums +{ + /// + /// A general collection of points in Terraria's overall draw order that graphical systems in the mod draw to. + /// + [Flags] + public enum GeneralDrawLayer + { + BeforeAllTiles = 1 << 0, + BeforeSolidTiles = 1 << 1, + BeforeNPCs = 1 << 2, + AfterNPCs = 1 << 3, + BeforeProjectiles = 1 << 4, + AfterProjectiles = 1 << 5, + AfterPlayers = 1 << 6, + AfterDusts = 1 << 7, + AfterEverything = 1 << 8, + } +} diff --git a/Enums/HerbType.cs b/Enums/HerbType.cs new file mode 100644 index 0000000000..42e672407e --- /dev/null +++ b/Enums/HerbType.cs @@ -0,0 +1,13 @@ +namespace CalamityMod +{ + public enum HerbType + { + Daybloom, + Moonglow, + Blinkroot, + Deathweed, + Waterleaf, + Fireblossom, + Shiverthorn + } +} diff --git a/Enums/PlanterBoxType.cs b/Enums/PlanterBoxType.cs new file mode 100644 index 0000000000..60447d4ac5 --- /dev/null +++ b/Enums/PlanterBoxType.cs @@ -0,0 +1,14 @@ +namespace CalamityMod +{ + public enum PlanterBoxType + { + Daybloom, + Moonglow, + Deathweed, + DeathweedCrimson, + Blinkroot, + Waterleaf, + Shiverthorn, + Fireblossom + } +} diff --git a/Enums/SetBonusDoubleTapOptions.cs b/Enums/SetBonusDoubleTapOptions.cs new file mode 100644 index 0000000000..34f919ebc1 --- /dev/null +++ b/Enums/SetBonusDoubleTapOptions.cs @@ -0,0 +1,9 @@ +namespace CalamityMod.Enums +{ + public enum SetBonusDoubleTapOptions + { + On, + Auto, + Off + } +} diff --git a/Enums/SunkenSeaBiomeFlags.cs b/Enums/SunkenSeaBiomeFlags.cs index 60de02c354..061c88f079 100644 --- a/Enums/SunkenSeaBiomeFlags.cs +++ b/Enums/SunkenSeaBiomeFlags.cs @@ -15,5 +15,6 @@ namespace CalamityMod.Enums PolypForest = 8, GleamingBurrows = 16, BasaltGully = 32, + ClamDen = 64 } } diff --git a/Enums/VanillaWingID.cs b/Enums/VanillaWingID.cs index 1604736eea..5e050247a1 100644 --- a/Enums/VanillaWingID.cs +++ b/Enums/VanillaWingID.cs @@ -12,7 +12,7 @@ BoneWings = 8, FlameWings = 9, FrozenWings = 10, - SpectreWings = 11, + GhostWings = 11, // Spectre Wings SteampunkWings = 12, LeafWings = 13, BatWings = 14, diff --git a/Events/AcidRainEvent.cs b/Events/AcidRainEvent.cs index d408942aa2..f52dc92a84 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -102,7 +102,7 @@ namespace CalamityMod.Events /// Broadcasts some text from a given localization key. ///
/// The key to write - public static void BroadcastEventText(string localizationKey) => CalamityUtils.DisplayLocalizedText(localizationKey, TextColor); + public static void BroadcastEventText(string localizationKey) => CalamityUtils.BroadcastLocalizedText(localizationKey, TextColor); public static int NeededEnemyKills { @@ -181,7 +181,7 @@ namespace CalamityMod.Events ///
public static void TryStartEvent(bool forceRain = false) { - if (AcidRainEventIsOngoing || (!NPC.downedBoss1 && !Main.hardMode && !DownedBossSystem.downedAquaticScourge) || BossRushEvent.BossRushActive) + if (AcidRainEventIsOngoing || (!NPC.downedBoss1 && !Main.hardMode && !DownedBossSystem.downedAquaticScourge && !DownedBossSystem.downedPolterghast) || BossRushEvent.BossRushActive || Terraria.GameContent.Creative.CreativePowerManager.Instance.GetPower().Enabled) return; int playerCount = Main.CurrentFrameFlags.ActivePlayersCount; @@ -243,7 +243,6 @@ namespace CalamityMod.Events if (inNaturalSeaPosition && player.Calamity().ZoneSulphur) { // Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea) - // You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!! HasStartedAcidicDownpour = true; CalamityNetcode.SyncWorld(); break; diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index d3bf603ee5..959fac537d 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -33,6 +33,7 @@ using CalamityMod.NPCs.Signus; using CalamityMod.NPCs.SlimeGod; using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; using CalamityMod.NPCs.Yharon; using CalamityMod.Packets; using CalamityMod.Projectiles.Typeless; @@ -151,8 +152,7 @@ namespace CalamityMod.Events DownedBossSystem.startedBossRushAtLeastOnce = true; }, permittedNPCs: new int[] { NPCID.BlueSlime, NPCID.YellowSlime, NPCID.PurpleSlime, NPCID.RedSlime, NPCID.GreenSlime, NPCID.RedSlime, - NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType(), - ModContent.NPCType(), ModContent.NPCType() }), + NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType()}), new Boss(ModContent.NPCType(), spawnContext: type => { @@ -164,7 +164,7 @@ namespace CalamityMod.Events ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), - new Boss(NPCID.EyeofCthulhu, TimeChangeContext.Night, permittedNPCs: new int[] { NPCID.ServantofCthulhu, ModContent.NPCType() }), + new Boss(NPCID.EyeofCthulhu, TimeChangeContext.Night, permittedNPCs: new int[] { NPCID.ServantofCthulhu }), new Boss(ModContent.NPCType(), TimeChangeContext.Day, type => { @@ -176,9 +176,9 @@ namespace CalamityMod.Events new Boss(NPCID.EaterofWorldsHead, permittedNPCs: new int[] { NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, NPCID.VileSpitEaterOfWorlds }), - new Boss(NPCID.BrainofCthulhu, permittedNPCs: NPCID.Creeper), + new Boss(NPCID.BrainofCthulhu, permittedNPCs: new int[] { NPCID.Creeper, ModContent.NPCType(), ModContent.NPCType() }), - new Boss(ModContent.NPCType(), permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), + new Boss(ModContent.NPCType(), permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), new Boss(ModContent.NPCType(), permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), @@ -213,8 +213,7 @@ namespace CalamityMod.Events { NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, NPCID.Spazmatism); NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, NPCID.Retinazer); - NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, ModContent.NPCType()); - }, permittedNPCs: new int[] { NPCID.Retinazer, ModContent.NPCType() }), + }, permittedNPCs: new int[] { NPCID.Retinazer }), new Boss(ModContent.NPCType(), TimeChangeContext.Day, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), @@ -222,7 +221,7 @@ namespace CalamityMod.Events new Boss(ModContent.NPCType(), TimeChangeContext.Day, permittedNPCs: ModContent.NPCType()), - new Boss(NPCID.SkeletronPrime, TimeChangeContext.Night, permittedNPCs: new int[] { ModContent.NPCType(), NPCID.PrimeCannon, NPCID.PrimeSaw, NPCID.PrimeVice, NPCID.PrimeLaser, NPCID.Probe }), + new Boss(NPCID.SkeletronPrime, TimeChangeContext.Night, permittedNPCs: new int[] { NPCID.PrimeCannon, NPCID.PrimeSaw, NPCID.PrimeVice, NPCID.PrimeLaser }), new Boss(ModContent.NPCType(), TimeChangeContext.Night, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), @@ -309,7 +308,7 @@ namespace CalamityMod.Events NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, type); }, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), - new Boss(ModContent.NPCType(), permittedNPCs: new int[] { ModContent.NPCType() }), + new Boss(ModContent.NPCType(), permittedNPCs: new int[] { ModContent.NPCType() }), new Boss(ModContent.NPCType(), TimeChangeContext.Day, type => { @@ -374,7 +373,7 @@ namespace CalamityMod.Events SoundEngine.PlaySound(DevourerofGodsHead.SpawnSound, player.Center); NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, type); - }, usesSpecialSound: true, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), + }, usesSpecialSound: true, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType() }), new Boss(ModContent.NPCType(), spawnContext: type => { diff --git a/ExtraJumps/GravityJump.cs b/ExtraJumps/GravityJump.cs new file mode 100644 index 0000000000..3a4e37d850 --- /dev/null +++ b/ExtraJumps/GravityJump.cs @@ -0,0 +1,45 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.ExtraJumps +{ + public class GravityJump : ExtraJump + { + public override Position GetDefaultPosition() => BeforeBottleJumps; + public override float GetDurationMultiplier(Player player) => 3f; + public override void UpdateHorizontalSpeeds(Player player) + { + player.runAcceleration *= 2f; + player.maxRunSpeed *= 4f; + } + + public override void OnStarted(Player player, ref bool playSound) + { + playSound = true; + if (player.wingsLogic <= 0) { + player.velocity.Y *= player.slowFall ? 2.0f : 2.75f; + } else { + player.velocity.Y *= 1.7f; + } + player.StopExtraJumpInProgress(); + for (int i = 0; i < 3; i++) + { + Vector2 position = player.Center; + Vector2 velocity = (Vector2.UnitY * -(2.5f + 2f*i)) * player.gravDir; + int lifetime = 120; + float scale = MathHelper.Lerp(0.05f,0.1f,i/3f); + Color color = new Color(94,229,163); + Vector2 stretch = new Vector2(0.5f,1.5f); + float shrink = -0.3f; + Particle boostRing = new CustomSpark(position, velocity, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false,lifetime,scale,color,stretch,shrinkSpeed: shrink); + GeneralParticleHandler.SpawnParticle(boostRing); + } + } + public override void ShowVisuals(Player player) + { + player.StopExtraJumpInProgress(); + } + } +} diff --git a/ExtraJumps/StatigelJump.cs b/ExtraJumps/StatigelJump.cs index a933dc82ef..e3fd591e74 100644 --- a/ExtraJumps/StatigelJump.cs +++ b/ExtraJumps/StatigelJump.cs @@ -7,7 +7,7 @@ namespace CalamityMod.ExtraJumps { public class StatigelJump : ExtraJump { - public override Position GetDefaultPosition() => BeforeBottleJumps; + public override Position GetDefaultPosition() => new Before(BlizzardInABottle); public override float GetDurationMultiplier(Player player) => 1.25f; // Values equivalent to the Fart in a Jar diff --git a/ExtraJumps/SulphurJump.cs b/ExtraJumps/SulphurJump.cs index eef2cbb6c1..53def3b415 100644 --- a/ExtraJumps/SulphurJump.cs +++ b/ExtraJumps/SulphurJump.cs @@ -1,5 +1,5 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Armor.Sulphurous; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -46,7 +46,7 @@ namespace CalamityMod.ExtraJumps if (modPlayer.sulphurBubbleCooldown <= 0) { var source = player.GetSource_Misc("0"); - int damage = (int)player.GetTotalDamage().ApplyTo(20); + int damage = (int)player.GetTotalDamage().ApplyTo(SulphurousHelmet.BubbleDamage); int bubble = Projectile.NewProjectile(source, new Vector2(player.position.X, player.position.Y + (player.gravDir == -1f ? 20 : -20)), Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1f, 0f); if (bubble.WithinBounds(Main.maxProjectiles)) diff --git a/ExtraTextures/AmidiasTrident_Stacks.png b/ExtraTextures/AmidiasTrident_Stacks.png new file mode 100644 index 0000000000..461c2d64a9 Binary files /dev/null and b/ExtraTextures/AmidiasTrident_Stacks.png differ diff --git a/ExtraTextures/BasicMess.png b/ExtraTextures/BasicMess.png new file mode 100644 index 0000000000..1e752bf91a Binary files /dev/null and b/ExtraTextures/BasicMess.png differ diff --git a/ExtraTextures/Bestiary/DesertNuisance_Bestiary.png b/ExtraTextures/Bestiary/DesertNuisance_Bestiary.png deleted file mode 100644 index c592bad6ce..0000000000 Binary files a/ExtraTextures/Bestiary/DesertNuisance_Bestiary.png and /dev/null differ diff --git a/ExtraTextures/Bestiary/DesertPest_Bestiary.png b/ExtraTextures/Bestiary/DesertPest_Bestiary.png deleted file mode 100644 index a2641ce82d..0000000000 Binary files a/ExtraTextures/Bestiary/DesertPest_Bestiary.png and /dev/null differ diff --git a/ExtraTextures/Bestiary/DesertScourge_Bestiary.png b/ExtraTextures/Bestiary/DesertScourge_Bestiary.png deleted file mode 100644 index 4b36bd6565..0000000000 Binary files a/ExtraTextures/Bestiary/DesertScourge_Bestiary.png and /dev/null differ diff --git a/ExtraTextures/Bestiary/SlimeGod_Bestiary.png b/ExtraTextures/Bestiary/SlimeGod_Bestiary.png deleted file mode 100644 index dbe7056e82..0000000000 Binary files a/ExtraTextures/Bestiary/SlimeGod_Bestiary.png and /dev/null differ diff --git a/ExtraTextures/BloomCirclePinpoint.png b/ExtraTextures/BloomCirclePinpoint.png new file mode 100644 index 0000000000..49c2dcdb60 Binary files /dev/null and b/ExtraTextures/BloomCirclePinpoint.png differ diff --git a/ExtraTextures/ChadPrime.png b/ExtraTextures/ChadPrime.png deleted file mode 100644 index 3bbc5902b0..0000000000 Binary files a/ExtraTextures/ChadPrime.png and /dev/null differ diff --git a/ExtraTextures/ChadPrimeHeadGlow.png b/ExtraTextures/ChadPrimeHeadGlow.png deleted file mode 100644 index e8b25ba236..0000000000 Binary files a/ExtraTextures/ChadPrimeHeadGlow.png and /dev/null differ diff --git a/ExtraTextures/ChadPrime_Head_Boss.png b/ExtraTextures/ChadPrime_Head_Boss.png deleted file mode 100644 index 313edebc2c..0000000000 Binary files a/ExtraTextures/ChadPrime_Head_Boss.png and /dev/null differ diff --git a/ExtraTextures/CrackedGlass_Glowing.png b/ExtraTextures/CrackedGlass_Glowing.png new file mode 100644 index 0000000000..82f6aef934 Binary files /dev/null and b/ExtraTextures/CrackedGlass_Glowing.png differ diff --git a/ExtraTextures/ExtraTextureRefs.cs b/ExtraTextures/ExtraTextureRefs.cs index bc86cb89a7..7eaf854a40 100644 --- a/ExtraTextures/ExtraTextureRefs.cs +++ b/ExtraTextures/ExtraTextureRefs.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.GameContent; @@ -19,11 +14,6 @@ namespace CalamityMod.ExtraTextures public static Asset DestroyerHeadGlowmask; public static Asset DestroyerBodyGlowmask; public static Asset DestroyerTailGlowmask; - public static Asset ProbeGlowmask; - - // Master Rev+ Skeletron Prime - public static Asset ChadPrime; - public static Asset ChadPrimeEyeGlowmask; // WoF, These are not "exactly" the ExtraTextures. But public static Asset WallOfFleshEyeGlowmask; @@ -44,16 +34,6 @@ namespace CalamityMod.ExtraTextures public static Asset CircularSmearFire2; public static Asset CircularSmearFire3; - // Boss Heads - // I know it's not exactly a Texture2D but it belongs to ExtraTextures. - public static int BossHeadIndex_ChadPrime; - - public override void Load() - { - string chadPrimeIconPath = "CalamityMod/ExtraTextures/ChadPrime_Head_Boss"; - BossHeadIndex_ChadPrime = CalamityMod.Instance.AddBossHeadTexture(chadPrimeIconPath, -1); - } - // TODO: - Every other ExtraTextures Reference could be move in here public override void OnModLoad() @@ -62,11 +42,6 @@ namespace CalamityMod.ExtraTextures DestroyerBodyGlowmask = ModContent.Request("CalamityMod/ExtraTextures/VanillaBossGlowmasks/DestroyerBodyGlow", AssetRequestMode.AsyncLoad); DestroyerTailGlowmask = ModContent.Request("CalamityMod/ExtraTextures/VanillaBossGlowmasks/DestroyerTailGlow", AssetRequestMode.AsyncLoad); - ProbeGlowmask = ModContent.Request("CalamityMod/ExtraTextures/VanillaBossGlowmasks/ProbeGlow", AssetRequestMode.AsyncLoad); - - ChadPrime = ModContent.Request("CalamityMod/ExtraTextures/ChadPrime", AssetRequestMode.AsyncLoad); - ChadPrimeEyeGlowmask = ModContent.Request("CalamityMod/ExtraTextures/ChadPrimeHeadGlow", AssetRequestMode.AsyncLoad); - WallOfFleshEyeGlowmask = ModContent.Request("CalamityMod/ExtraTextures/VanillaBossGlowmasks/WallOfFleshEyeTelegraphGlow", AssetRequestMode.AsyncLoad); WallOfFleshDemonSickleTexture = ModContent.Request("CalamityMod/Projectiles/Melee/ForbiddenOathbladeProjectile", AssetRequestMode.AsyncLoad); diff --git a/Tiles/Plates/CinderplatePulse.png b/ExtraTextures/GreyscaleGradients/CinderplatePulse.png similarity index 100% rename from Tiles/Plates/CinderplatePulse.png rename to ExtraTextures/GreyscaleGradients/CinderplatePulse.png diff --git a/Tiles/Plates/ElumplatePulse.png b/ExtraTextures/GreyscaleGradients/ElumplatePulse.png similarity index 100% rename from Tiles/Plates/ElumplatePulse.png rename to ExtraTextures/GreyscaleGradients/ElumplatePulse.png diff --git a/ExtraTextures/GreyscaleGradients/GreyscaleGradient.cs b/ExtraTextures/GreyscaleGradients/GreyscaleGradient.cs new file mode 100644 index 0000000000..0e8bc34611 --- /dev/null +++ b/ExtraTextures/GreyscaleGradients/GreyscaleGradient.cs @@ -0,0 +1,49 @@ +using Terraria.ModLoader; + +namespace CalamityMod.ExtraTextures.GreyscaleGradients +{ + internal class GreyscaleGradient : ILoadable + { + public string BasePath => "CalamityMod/ExtraTextures/GreyscaleGradients/"; + + public static GrayscaleTexture1D CinderplatePulse { get; private set; } + public static GrayscaleTexture1D ElumplatePulse { get; private set; } + public static GrayscaleTexture1D HavocplatePulse { get; private set; } + public static GrayscaleTexture1D NavyplatePulse { get; private set; } + public static GrayscaleTexture1D OnyxplatePulse { get; private set; } + public static GrayscaleTexture1D PlagueContainmentCellsPulse { get; private set; } + + public static GrayscaleTexture2D BlobbyNoise { get; private set; } + + public void Load(Mod mod) + { + CinderplatePulse = new($"{BasePath}{nameof(CinderplatePulse)}"); + ElumplatePulse = new($"{BasePath}{nameof(ElumplatePulse)}"); + HavocplatePulse = new($"{BasePath}{nameof(HavocplatePulse)}"); + NavyplatePulse = new($"{BasePath}{nameof(NavyplatePulse)}"); + OnyxplatePulse = new($"{BasePath}{nameof(OnyxplatePulse)}"); + PlagueContainmentCellsPulse = new($"{BasePath}{nameof(PlagueContainmentCellsPulse)}"); + + BlobbyNoise = new($"{BasePath}{nameof(BlobbyNoise)}"); + } + + public void Unload() + { + CinderplatePulse?.Unload(); + ElumplatePulse?.Unload(); + HavocplatePulse?.Unload(); + NavyplatePulse?.Unload(); + OnyxplatePulse?.Unload(); + PlagueContainmentCellsPulse?.Unload(); + BlobbyNoise?.Unload(); + + CinderplatePulse = null; + ElumplatePulse = null; + HavocplatePulse = null; + NavyplatePulse = null; + OnyxplatePulse = null; + PlagueContainmentCellsPulse = null; + BlobbyNoise = null; + } + } +} diff --git a/Tiles/Plates/HavocplatePulse.png b/ExtraTextures/GreyscaleGradients/HavocplatePulse.png similarity index 100% rename from Tiles/Plates/HavocplatePulse.png rename to ExtraTextures/GreyscaleGradients/HavocplatePulse.png diff --git a/ExtraTextures/GreyscaleGradients/MeltyNoiseHighContrast.png b/ExtraTextures/GreyscaleGradients/MeltyNoiseHighContrast.png new file mode 100644 index 0000000000..5755d5971d Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/MeltyNoiseHighContrast.png differ diff --git a/Tiles/Plates/NavyplatePulse.png b/ExtraTextures/GreyscaleGradients/NavyplatePulse.png similarity index 100% rename from Tiles/Plates/NavyplatePulse.png rename to ExtraTextures/GreyscaleGradients/NavyplatePulse.png diff --git a/Tiles/Plates/OnyxplatePulse.png b/ExtraTextures/GreyscaleGradients/OnyxplatePulse.png similarity index 100% rename from Tiles/Plates/OnyxplatePulse.png rename to ExtraTextures/GreyscaleGradients/OnyxplatePulse.png diff --git a/ExtraTextures/GreyscaleGradients/Pebbles.png b/ExtraTextures/GreyscaleGradients/Pebbles.png new file mode 100644 index 0000000000..5f05401249 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/Pebbles.png differ diff --git a/Tiles/Plates/PlagueContainmentCellsPulse.png b/ExtraTextures/GreyscaleGradients/PlagueContainmentCellsPulse.png similarity index 100% rename from Tiles/Plates/PlagueContainmentCellsPulse.png rename to ExtraTextures/GreyscaleGradients/PlagueContainmentCellsPulse.png diff --git a/ExtraTextures/GreyscaleGradients/RealisticClouds.png b/ExtraTextures/GreyscaleGradients/RealisticClouds.png new file mode 100644 index 0000000000..cb1edf311b Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/RealisticClouds.png differ diff --git a/ExtraTextures/GreyscaleGradients/Smudges2.png b/ExtraTextures/GreyscaleGradients/Smudges2.png new file mode 100644 index 0000000000..fcdefedba1 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/Smudges2.png differ diff --git a/ExtraTextures/GreyscaleGradients/Swirls.png b/ExtraTextures/GreyscaleGradients/Swirls.png new file mode 100644 index 0000000000..da2c4380b0 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/Swirls.png differ diff --git a/ExtraTextures/Miscellaneous/NuclearTorrent.png b/ExtraTextures/Miscellaneous/NuclearTorrent.png new file mode 100644 index 0000000000..14d160d3d5 Binary files /dev/null and b/ExtraTextures/Miscellaneous/NuclearTorrent.png differ diff --git a/ExtraTextures/SimpleStar.png b/ExtraTextures/SimpleStar.png new file mode 100644 index 0000000000..15fe40013a Binary files /dev/null and b/ExtraTextures/SimpleStar.png differ diff --git a/ExtraTextures/SimpleWings.png b/ExtraTextures/SimpleWings.png new file mode 100644 index 0000000000..fa4704dda1 Binary files /dev/null and b/ExtraTextures/SimpleWings.png differ diff --git a/ExtraTextures/SkeletronPrime2HeadGlow.png b/ExtraTextures/SkeletronPrime2HeadGlow.png deleted file mode 100644 index 7054e2945d..0000000000 Binary files a/ExtraTextures/SkeletronPrime2HeadGlow.png and /dev/null differ diff --git a/ExtraTextures/Trails/FabstaffStreak.png b/ExtraTextures/Trails/SylvestaffStreak.png similarity index 100% rename from ExtraTextures/Trails/FabstaffStreak.png rename to ExtraTextures/Trails/SylvestaffStreak.png diff --git a/ExtraTextures/UI/CrystalTextGlow.png b/ExtraTextures/UI/CrystalTextGlow.png new file mode 100644 index 0000000000..e4dd498b65 Binary files /dev/null and b/ExtraTextures/UI/CrystalTextGlow.png differ diff --git a/ExtraTextures/UI/CrystalTextSparkle.png b/ExtraTextures/UI/CrystalTextSparkle.png new file mode 100644 index 0000000000..7703b63a83 Binary files /dev/null and b/ExtraTextures/UI/CrystalTextSparkle.png differ diff --git a/ExtraTextures/UI/Glint.png b/ExtraTextures/UI/Glint.png new file mode 100644 index 0000000000..9d0ed2aebd Binary files /dev/null and b/ExtraTextures/UI/Glint.png differ diff --git a/ExtraTextures/VanillaBossGlowmasks/ProbeGlow.png b/ExtraTextures/VanillaBossGlowmasks/ProbeGlow.png deleted file mode 100644 index c0105e82e4..0000000000 Binary files a/ExtraTextures/VanillaBossGlowmasks/ProbeGlow.png and /dev/null differ diff --git a/FluidSimulation/FluidField.cs b/FluidSimulation/FluidField.cs index eed9ca02fe..213307ced2 100644 --- a/FluidSimulation/FluidField.cs +++ b/FluidSimulation/FluidField.cs @@ -1,11 +1,10 @@ using System; using CalamityMod.Effects; using CalamityMod.Graphics; -using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.FluidSimulation @@ -14,11 +13,11 @@ namespace CalamityMod.FluidSimulation // Please do not change this system too much without contacting me first. -Dominic public class FluidField : IDisposable { - internal ManagedRenderTarget TemporaryAuxilaryTarget; + internal RenderTargetLease TemporaryAuxilaryTarget; - internal ManagedRenderTarget DivergenceField; + internal RenderTargetLease DivergenceField; - internal ManagedRenderTarget DivergencePoissonField; + internal RenderTargetLease DivergencePoissonField; internal FluidFieldState VelocityField; @@ -26,7 +25,7 @@ namespace CalamityMod.FluidSimulation internal FluidFieldState ColorField; - internal ManagedRenderTarget OutputTarget; + internal RenderTargetLease OutputTarget; public float Viscosity; @@ -73,8 +72,7 @@ namespace CalamityMod.FluidSimulation } // A surface format of Vector4 is used here to allow for both 0-1 ranged colors and other things at the same time. - public RenderTarget2D FluidCreateCondition(int screen, int height) => - new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); + public static RenderTargetDescriptor FluidDescriptor => new RenderTargetDescriptor(SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents, true); internal FluidField(int size, float scale, float viscosity, float diffusionFactor, float dissipationFactor) { @@ -88,31 +86,31 @@ namespace CalamityMod.FluidSimulation DensityField = new(size); ColorField = new(size); - TemporaryAuxilaryTarget = new(false, FluidCreateCondition, false); + TemporaryAuxilaryTarget = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, FluidDescriptor); - DivergenceField = new(false, FluidCreateCondition, false); - DivergencePoissonField = new(false, FluidCreateCondition, false); + DivergenceField = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, FluidDescriptor); + DivergencePoissonField = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, FluidDescriptor); - OutputTarget = new(false, FluidCreateCondition, false); + OutputTarget = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, FluidDescriptor); } internal void ApplyThingToTarget(RenderTarget2D currentField, Action shaderPreparationsAction) { - Main.instance.GraphicsDevice.SetRenderTarget(TemporaryAuxilaryTarget); - Main.instance.GraphicsDevice.Clear(Color.Transparent); + using (TemporaryAuxilaryTarget.Scope(clearColor: Color.Transparent)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); + shaderPreparationsAction(); + Main.spriteBatch.Draw(currentField, currentField.Bounds, Color.White); + Main.spriteBatch.End(); + } - shaderPreparationsAction(); - Main.spriteBatch.Draw(currentField, currentField.Bounds, Color.White); - Main.spriteBatch.End(); - - currentField.CopyContentsFrom(TemporaryAuxilaryTarget); + currentField.CopyContentsFrom(TemporaryAuxilaryTarget.Target); } internal void FlushQueueToTarget(FluidFieldState field) { - ApplyThingToTarget(field.NextState, () => + ApplyThingToTarget(field.NextState.Target, () => { int batchIndex = 0; int pixelCount = field.PendingChanges.Count; @@ -169,14 +167,14 @@ namespace CalamityMod.FluidSimulation internal void CalculateDiffusion(float diffusionFactor, FluidFieldState field, bool colors = false) { diffusionFactor *= DeltaTime * Size; - ApplyThingToTarget(field.NextState, () => + ApplyThingToTarget(field.NextState.Target, () => { - Main.instance.GraphicsDevice.Textures[1] = field.PreviousState; - CalamityShaders.FluidShaders.Parameters["size"].SetValue(Size); - CalamityShaders.FluidShaders.Parameters["diffusionFactor"].SetValue(diffusionFactor); - CalamityShaders.FluidShaders.Parameters["handlingColors"].SetValue(colors); - CalamityShaders.FluidShaders.Parameters["dissipationFactor"].SetValue(DissipationFactor); - CalamityShaders.FluidShaders.CurrentTechnique.Passes["DiffusionPass"].Apply(); + Main.instance.GraphicsDevice.Textures[1] = field.PreviousState.Target; + CalamityShaders.FluidShaders.Value.Parameters["size"].SetValue(Size); + CalamityShaders.FluidShaders.Value.Parameters["diffusionFactor"].SetValue(diffusionFactor); + CalamityShaders.FluidShaders.Value.Parameters["handlingColors"].SetValue(colors); + CalamityShaders.FluidShaders.Value.Parameters["dissipationFactor"].SetValue(DissipationFactor); + CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["DiffusionPass"].Apply(); }); } @@ -186,44 +184,43 @@ namespace CalamityMod.FluidSimulation { Main.instance.GraphicsDevice.Textures[1] = currentField; Main.instance.GraphicsDevice.Textures[2] = velocities; - CalamityShaders.FluidShaders.Parameters["size"].SetValue(Size); - CalamityShaders.FluidShaders.Parameters["deltaTime"].SetValue(DeltaTime); - CalamityShaders.FluidShaders.Parameters["handlingColors"].SetValue(colors); - CalamityShaders.FluidShaders.CurrentTechnique.Passes["AdvectionPass"].Apply(); + CalamityShaders.FluidShaders.Value.Parameters["size"].SetValue(Size); + CalamityShaders.FluidShaders.Value.Parameters["deltaTime"].SetValue(DeltaTime); + CalamityShaders.FluidShaders.Value.Parameters["handlingColors"].SetValue(colors); + CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["AdvectionPass"].Apply(); }); } internal void ClearDivergence(RenderTarget2D velocities) { // Calculate divergence. - ApplyThingToTarget(DivergenceField, () => + ApplyThingToTarget(DivergenceField.Target, () => { Main.instance.GraphicsDevice.Textures[2] = velocities; - CalamityShaders.FluidShaders.Parameters["size"].SetValue(Size); - CalamityShaders.FluidShaders.CurrentTechnique.Passes["InitializeDivergencePass"].Apply(); + CalamityShaders.FluidShaders.Value.Parameters["size"].SetValue(Size); + CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["InitializeDivergencePass"].Apply(); }); // Clear the Poisson values and then calculate them, for use in the divergence clearance pass. - Main.instance.GraphicsDevice.SetRenderTarget(DivergencePoissonField); - Main.instance.GraphicsDevice.Clear(Color.Transparent); + using (DivergencePoissonField.Scope(clearColor: Color.Transparent)) { } for (int i = 0; i < GaussSeidelIterations; i++) { - ApplyThingToTarget(DivergencePoissonField, () => + ApplyThingToTarget(DivergencePoissonField.Target, () => { - Main.instance.GraphicsDevice.Textures[1] = DivergencePoissonField; + Main.instance.GraphicsDevice.Textures[1] = DivergencePoissonField.Target; Main.instance.GraphicsDevice.Textures[2] = velocities; - Main.instance.GraphicsDevice.Textures[4] = DivergenceField; - CalamityShaders.FluidShaders.Parameters["size"].SetValue(Size); - CalamityShaders.FluidShaders.CurrentTechnique.Passes["PerformPoissonIterationPass"].Apply(); + Main.instance.GraphicsDevice.Textures[4] = DivergenceField.Target; + CalamityShaders.FluidShaders.Value.Parameters["size"].SetValue(Size); + CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["PerformPoissonIterationPass"].Apply(); }); } ApplyThingToTarget(velocities, () => { Main.instance.GraphicsDevice.Textures[1] = velocities; - Main.instance.GraphicsDevice.Textures[3] = DivergencePoissonField; - CalamityShaders.FluidShaders.CurrentTechnique.Passes["ClearDivergencePass"].Apply(); + Main.instance.GraphicsDevice.Textures[3] = DivergencePoissonField.Target; + CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["ClearDivergencePass"].Apply(); }); } @@ -257,36 +254,34 @@ namespace CalamityMod.FluidSimulation { CalculateDiffusion(Viscosity, VelocityField); if (!ShouldSkipDivergenceClearingStep) - ClearDivergence(VelocityField.NextState); + ClearDivergence(VelocityField.NextState.Target); - CalculateAdvection(VelocityField.NextState, VelocityField.PreviousState, VelocityField.PreviousState); + CalculateAdvection(VelocityField.NextState.Target, VelocityField.PreviousState.Target, VelocityField.PreviousState.Target); if (!ShouldSkipDivergenceClearingStep) - ClearDivergence(VelocityField.NextState); + ClearDivergence(VelocityField.NextState.Target); } internal void UpdateDensityFields() { CalculateDiffusion(DiffusionFactor, DensityField); DensityField.SwapState(); - CalculateAdvection(DensityField.PreviousState, DensityField.NextState, VelocityField.NextState); + CalculateAdvection(DensityField.PreviousState.Target, DensityField.NextState.Target, VelocityField.NextState.Target); CalculateDiffusion(DiffusionFactor, ColorField, true); ColorField.SwapState(); - CalculateAdvection(ColorField.PreviousState, ColorField.NextState, VelocityField.NextState, true); + CalculateAdvection(ColorField.PreviousState.Target, ColorField.NextState.Target, VelocityField.NextState.Target, true); } public void UpdateOutputTarget() { - Main.instance.GraphicsDevice.SetRenderTarget(OutputTarget); - Main.instance.GraphicsDevice.Clear(Color.Transparent); - - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); - Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState; - CalamityShaders.FluidShaders.CurrentTechnique.Passes["DrawFluidPass"].Apply(); - Main.spriteBatch.Draw(DensityField.NextState, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, 0, 0f); - Main.spriteBatch.End(); - - Main.instance.GraphicsDevice.SetRenderTarget(null); + using (OutputTarget.Scope(clearColor: Color.Transparent)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); + Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState.Target; + CalamityShaders.FluidShaders.Value.CurrentTechnique.Passes["DrawFluidPass"].Apply(); + Main.spriteBatch.Draw(DensityField.NextState.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, 0, 0f); + Main.spriteBatch.End(); + } } public void Dispose() @@ -323,9 +318,9 @@ namespace CalamityMod.FluidSimulation Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, drawPerspective); - shaderPreparations?.Invoke(OutputTarget); + shaderPreparations?.Invoke(OutputTarget.Target); - Main.spriteBatch.Draw(OutputTarget, drawPosition, null, Color.White, 0f, OutputTarget.Size * 0.5f, Scale, 0, 0f); + Main.spriteBatch.Draw(OutputTarget.Target, drawPosition, null, Color.White, 0f, OutputTarget.Target.Size() * 0.5f, Scale, 0, 0f); Main.spriteBatch.End(); if (needsToCallEnd) diff --git a/FluidSimulation/FluidFieldState.cs b/FluidSimulation/FluidFieldState.cs index 9dfa619573..0e9da15fbb 100644 --- a/FluidSimulation/FluidFieldState.cs +++ b/FluidSimulation/FluidFieldState.cs @@ -1,17 +1,17 @@ using System.Collections.Generic; using CalamityMod.Graphics; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; namespace CalamityMod.FluidSimulation { // Calculations for these are done primarily on the GPU in shaders for performance-sake. public class FluidFieldState { - public ManagedRenderTarget PreviousState; + public RenderTargetLease PreviousState; - public ManagedRenderTarget NextState; + public RenderTargetLease NextState; public Queue PendingChanges = new(); @@ -21,9 +21,6 @@ namespace CalamityMod.FluidSimulation public void SwapState() => Utils.Swap(ref PreviousState, ref NextState); - public RenderTarget2D FieldColorCreateCondition(int screen, int height) => - new(Main.instance.GraphicsDevice, Size, Size, true, FieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents); - public FluidFieldState(int size, SurfaceFormat fieldContents = SurfaceFormat.Color) { if (Main.dedServ) @@ -32,8 +29,9 @@ namespace CalamityMod.FluidSimulation Size = size; FieldContents = fieldContents; - PreviousState = new(false, FieldColorCreateCondition, false); - NextState = new(false, FieldColorCreateCondition, false); + var descriptor = new RenderTargetDescriptor(FieldContents, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents, true); + PreviousState = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, descriptor); + NextState = RenderTargetPool.Shared.Rent(Main.instance.GraphicsDevice, Size, Size, descriptor); } } } diff --git a/Fonts/CodebreakerDialog.xnb b/Fonts/CodebreakerDialog.xnb index eef588aef5..fad15220ba 100644 Binary files a/Fonts/CodebreakerDialog.xnb and b/Fonts/CodebreakerDialog.xnb differ diff --git a/Fonts/Flexure.xnb b/Fonts/Flexure.xnb new file mode 100644 index 0000000000..5aaf31cd8c Binary files /dev/null and b/Fonts/Flexure.xnb differ diff --git a/Fonts/FontAssetSystem.cs b/Fonts/FontAssetSystem.cs new file mode 100644 index 0000000000..2feccc13bf --- /dev/null +++ b/Fonts/FontAssetSystem.cs @@ -0,0 +1,31 @@ +using ReLogic.Content; +using ReLogic.Graphics; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Fonts +{ + public sealed class FontAssetSystem : ModSystem + { + public static Asset MouseText => FontAssets.MouseText; + + public static Asset ItemStack => FontAssets.ItemStack; + + public static Asset DeathText => FontAssets.DeathText; + + public static Asset CombatText => FontAssets.CombatText[0]; + + public static Asset CombatTextCrit => FontAssets.CombatText[1]; + + public static Asset CodebreakerDialog => field ??= GetFont("Fonts/CodebreakerDialog"); + + public static Asset Impact => field ??= GetFont("Fonts/Impact"); + + public static Asset Flexure => field ??= GetFont("Fonts/Flexure"); + + private static Asset GetFont(string path) + { + return ModContent.GetInstance().Assets.Request(path, AssetRequestMode.ImmediateLoad); + } + } +} diff --git a/Fonts/Impact.xnb b/Fonts/Impact.xnb new file mode 100644 index 0000000000..862941c829 Binary files /dev/null and b/Fonts/Impact.xnb differ diff --git a/Fonts/Wingdings.xnb b/Fonts/Wingdings.xnb deleted file mode 100644 index a487f2746c..0000000000 Binary files a/Fonts/Wingdings.xnb and /dev/null differ diff --git a/ForegroundDrawing/LoopingTextures/LoopingTextureForeground.cs b/ForegroundDrawing/LoopingTextures/LoopingTextureForeground.cs new file mode 100644 index 0000000000..06047201fc --- /dev/null +++ b/ForegroundDrawing/LoopingTextures/LoopingTextureForeground.cs @@ -0,0 +1,121 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.ForegroundDrawing.LoopingTextures +{ + public abstract class LoopingTextureForeground : ModSystem + { + public virtual string Texture => "CalamityMod/ExtraTextures/Miscellaneous/NuclearTorrent"; + + /// + /// How much the effect has moved. Increments by Speed. + /// + float Progress = 0f; + + /// + /// The speed at which Progress is incremented every frame. + /// + public virtual float Speed => 60f; + + /// + /// How opaque the visual is. Caps out at IntensityMaximum. + /// + public float Intensity = 0f; + + /// + /// How opaque the visual can become before capping out. + /// + public virtual float IntensityMaximum => 0.15f; + + /// + /// Current parallax. + /// + Vector2 Parallax = Vector2.Zero; + + /// + /// Current parallax depth. + /// + public virtual Vector2 ParallaxDepth => Vector2.Zero; + + /// + /// When true, the Intensity will increase until it caps out. If false it will decrease until it hits 0. + /// + /// Whether or not the visual is active. + public virtual bool DoesThisShow() + { + return false; + } + + public override void PostDrawTiles() + { + if (DoesThisShow()) + { + Intensity = MathHelper.Lerp(Intensity, IntensityMaximum, 0.1f); + } + else + { + Intensity = MathHelper.Lerp(Intensity, 0, 0.1f); + } + + Intensity = MathHelper.Clamp(Intensity, 0f, 1f); + + Parallax += Main.LocalPlayer.velocity * ParallaxDepth; + + Progress += Speed; + + Main.spriteBatch.Begin(); + Draw(); + PostDraw(); + Main.spriteBatch.End(); + + Update(); + } + + public override void PostUpdateEverything() + { + Update(); + } + + /// + /// Extra drawing logic can be placed here. + /// + public virtual void PostDraw() + { + + } + + /// + /// Called every frame. Run behavior such as particle effects here. + /// + public virtual void Update() + { + + } + + /// + /// Override this to replace existing drawing logic. Only recommended if you know what you're doing. + /// + public virtual void Draw() + { + var tex = ModContent.Request(Texture); + + for (var i = -4; i < 14; i++) + { + float wid = tex.Width(); + float hei = tex.Height(); + + var rect = new Rectangle(0, 0, (int)wid, (int)hei); + + var rot = -Main.WindForVisuals; + + var col = new Color(Intensity, Intensity, Intensity, 0f); + + Main.EntitySpriteDraw(tex.Value, new Vector2(Parallax.X % wid, 0).RotatedBy(rot) + new Vector2(tex.Width() * i, 0).RotatedBy(rot), rect, col, rot, new Vector2(0, (hei - Progress) % hei), 1, SpriteEffects.None); + Main.EntitySpriteDraw(tex.Value, new Vector2(Parallax.X % wid, 0).RotatedBy(rot) + new Vector2(tex.Width() * i, -hei).RotatedBy(rot), rect, col, rot, new Vector2(0, (hei - Progress) % hei), 1, SpriteEffects.None); + Main.EntitySpriteDraw(tex.Value, new Vector2(Parallax.X % wid, 0).RotatedBy(rot) + new Vector2(tex.Width() * i, -hei * 2).RotatedBy(rot), rect, col, rot, new Vector2(0, (hei - Progress) % hei), 1, SpriteEffects.None); + } + } + } +} diff --git a/ForegroundDrawing/LoopingTextures/NuclearTorrentForeground.cs b/ForegroundDrawing/LoopingTextures/NuclearTorrentForeground.cs new file mode 100644 index 0000000000..2959b22ec5 --- /dev/null +++ b/ForegroundDrawing/LoopingTextures/NuclearTorrentForeground.cs @@ -0,0 +1,107 @@ +using System.Collections.Generic; +using CalamityMod.NPCs.OldDuke; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.ForegroundDrawing.LoopingTextures +{ + public class NuclearTorrentPlayer : ModPlayer + { + public bool ShouldDisplayTorrentMonolith = false; + public override void ResetEffects() + { + ShouldDisplayTorrentMonolith = false; + } + } + public class NuclearTorrentForeground : LoopingTextureForeground + { + public override Vector2 ParallaxDepth => new Vector2(1f, 1f); + + public override float IntensityMaximum => 0.045f; + + public static List Raindrops = new List(); + + public class NuclearRaindrop + { + public Vector2 Position; + public Vector2 Velocity; + + public NuclearRaindrop(Vector2 pos, Vector2 vel) + { + Position = pos; + Velocity = vel; + } + + public void Update(NuclearRaindrop drop, NuclearTorrentForeground foreground) + { + drop.Position += drop.Velocity; + drop.Position -= Main.LocalPlayer.velocity; + + drop.Velocity = new Vector2(0, 20).RotatedBy(-Main.windSpeedCurrent); + + if (drop.Position.Y > Main.screenHeight + 200) + { + RemoveDrop(drop); + } + } + + public void Draw(NuclearRaindrop drop, NuclearTorrentForeground foreground) + { + Asset tex = ModContent.Request("CalamityMod/ForegroundDrawing/LoopingTextures/NuclearTorrentRaindrop"); + + float intensity = foreground.Intensity / foreground.IntensityMaximum / 4f; + + Main.EntitySpriteDraw(tex.Value, drop.Position, tex.Frame(), Color.White.MultiplyRGBA(new Color(intensity, intensity, intensity, intensity)), Vector2.Zero.AngleTo(drop.Velocity) - MathHelper.ToRadians(90f), tex.Size() / 2, new Vector2(1f, 4f), SpriteEffects.None); + } + } + + public static void RemoveDrop(NuclearRaindrop drop) + { + Raindrops.Remove(drop); + } + + public bool ShouldDisplayDuringOldDuke() => NPC.CountNPCS(ModContent.NPCType()) > 0 && Main.LocalPlayer.Calamity().ZoneSulphur && !CalamityServerConfig.Instance.BossesStopWeather; + + public override bool DoesThisShow() => ShouldDisplayDuringOldDuke() || Main.LocalPlayer.GetModPlayer().ShouldDisplayTorrentMonolith; + + public override void Update() + { + if (NPC.CountNPCS(ModContent.NPCType()) > 0) + { + int duke = NPC.FindFirstNPC(ModContent.NPCType()); + + Main.windSpeedCurrent = MathHelper.Lerp(Main.windSpeedCurrent, MathHelper.ToRadians(50f), 0.005f); + + foreach (Rain rain in Main.rain) + { + rain.velocity = new Vector2(0, 15).RotatedBy(-Main.windSpeedCurrent); + rain.rotation = Vector2.Zero.AngleTo(rain.velocity) + MathHelper.PiOver2; + } + } + + NuclearRaindrop dr = new NuclearRaindrop(new Vector2(Main.screenWidth / 2f, -100) + new Vector2(Main.rand.NextFloat(-Main.screenWidth, Main.screenWidth), -Main.screenWidth * 0.65f).RotatedBy(-Main.windSpeedCurrent), + new Vector2(0, 20).RotatedBy(-Main.windSpeedCurrent)); + Raindrops.Add(dr); + + for (int i = 0; i < Raindrops.Count; i++) + { + NuclearRaindrop drop = Raindrops[i]; + + drop.Update(drop, this); + } + } + + public override void PostDraw() + { + for (int i = 0; i < Raindrops.Count; i++) + { + NuclearRaindrop drop = Raindrops[i]; + + drop.Draw(drop, this); + } + } + } +} diff --git a/ForegroundDrawing/LoopingTextures/NuclearTorrentRaindrop.png b/ForegroundDrawing/LoopingTextures/NuclearTorrentRaindrop.png new file mode 100644 index 0000000000..428091be12 Binary files /dev/null and b/ForegroundDrawing/LoopingTextures/NuclearTorrentRaindrop.png differ diff --git a/Gores/Abyss/AbyssPot1.png b/Gores/Abyss/AbyssPot1.png new file mode 100644 index 0000000000..f61b152031 Binary files /dev/null and b/Gores/Abyss/AbyssPot1.png differ diff --git a/Gores/Abyss/AbyssPot2.png b/Gores/Abyss/AbyssPot2.png new file mode 100644 index 0000000000..3161ceab31 Binary files /dev/null and b/Gores/Abyss/AbyssPot2.png differ diff --git a/Gores/Abyss/AbyssPot3.png b/Gores/Abyss/AbyssPot3.png new file mode 100644 index 0000000000..e2b2a0bc35 Binary files /dev/null and b/Gores/Abyss/AbyssPot3.png differ diff --git a/Gores/Abyss/AbyssPot4.png b/Gores/Abyss/AbyssPot4.png new file mode 100644 index 0000000000..9a79f015e8 Binary files /dev/null and b/Gores/Abyss/AbyssPot4.png differ diff --git a/Gores/Abyss/AbyssPot5.png b/Gores/Abyss/AbyssPot5.png new file mode 100644 index 0000000000..e6f7d58bde Binary files /dev/null and b/Gores/Abyss/AbyssPot5.png differ diff --git a/Gores/Abyss/AbyssPot6.png b/Gores/Abyss/AbyssPot6.png new file mode 100644 index 0000000000..2a01b0ddfb Binary files /dev/null and b/Gores/Abyss/AbyssPot6.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateL1.png b/Gores/Abyss/PirateCrate/PirateCrateL1.png new file mode 100644 index 0000000000..3939d42a5c Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateL1.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateL2.png b/Gores/Abyss/PirateCrate/PirateCrateL2.png new file mode 100644 index 0000000000..69800697bb Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateL2.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateL3.png b/Gores/Abyss/PirateCrate/PirateCrateL3.png new file mode 100644 index 0000000000..62349bb13b Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateL3.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateM1.png b/Gores/Abyss/PirateCrate/PirateCrateM1.png new file mode 100644 index 0000000000..7b8fcc7dbb Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateM1.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateM2.png b/Gores/Abyss/PirateCrate/PirateCrateM2.png new file mode 100644 index 0000000000..76be32af00 Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateM2.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateM3.png b/Gores/Abyss/PirateCrate/PirateCrateM3.png new file mode 100644 index 0000000000..00bfd9bb1b Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateM3.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateR1.png b/Gores/Abyss/PirateCrate/PirateCrateR1.png new file mode 100644 index 0000000000..cd6a3b5653 Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateR1.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateR2.png b/Gores/Abyss/PirateCrate/PirateCrateR2.png new file mode 100644 index 0000000000..db5c8ad99c Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateR2.png differ diff --git a/Gores/Abyss/PirateCrate/PirateCrateR3.png b/Gores/Abyss/PirateCrate/PirateCrateR3.png new file mode 100644 index 0000000000..da3b6b0e50 Binary files /dev/null and b/Gores/Abyss/PirateCrate/PirateCrateR3.png differ diff --git a/Gores/ArmoredDigger/ArmoredDiggerBody.png b/Gores/ArmoredDigger/ArmoredDiggerBody.png deleted file mode 100644 index 082eb57526..0000000000 Binary files a/Gores/ArmoredDigger/ArmoredDiggerBody.png and /dev/null differ diff --git a/Gores/ArmoredDigger/ArmoredDiggerBody2.png b/Gores/ArmoredDigger/ArmoredDiggerBody2.png deleted file mode 100644 index a7a22f0697..0000000000 Binary files a/Gores/ArmoredDigger/ArmoredDiggerBody2.png and /dev/null differ diff --git a/Gores/ArmoredDigger/ArmoredDiggerHead.png b/Gores/ArmoredDigger/ArmoredDiggerHead.png deleted file mode 100644 index 7debb48e29..0000000000 Binary files a/Gores/ArmoredDigger/ArmoredDiggerHead.png and /dev/null differ diff --git a/Gores/ArmoredDigger/ArmoredDiggerHead2.png b/Gores/ArmoredDigger/ArmoredDiggerHead2.png deleted file mode 100644 index c1fe479da5..0000000000 Binary files a/Gores/ArmoredDigger/ArmoredDiggerHead2.png and /dev/null differ diff --git a/Gores/ArmoredDigger/ArmoredDiggerTail.png b/Gores/ArmoredDigger/ArmoredDiggerTail.png deleted file mode 100644 index 6a30219a5b..0000000000 Binary files a/Gores/ArmoredDigger/ArmoredDiggerTail.png and /dev/null differ diff --git a/Gores/ArmoredDigger/ArmoredDiggerTail2.png b/Gores/ArmoredDigger/ArmoredDiggerTail2.png deleted file mode 100644 index 616e848530..0000000000 Binary files a/Gores/ArmoredDigger/ArmoredDiggerTail2.png and /dev/null differ diff --git a/Gores/BlindedAngler/BlindAnglerGore1.png b/Gores/BlindedAngler/BlindAnglerGore1.png deleted file mode 100644 index 8becc53bd0..0000000000 Binary files a/Gores/BlindedAngler/BlindAnglerGore1.png and /dev/null differ diff --git a/Gores/BlindedAngler/BlindAnglerGore2.png b/Gores/BlindedAngler/BlindAnglerGore2.png deleted file mode 100644 index 833c94b601..0000000000 Binary files a/Gores/BlindedAngler/BlindAnglerGore2.png and /dev/null differ diff --git a/Gores/BlindedAngler/BlindAnglerGore3.png b/Gores/BlindedAngler/BlindAnglerGore3.png deleted file mode 100644 index a4c5766fdb..0000000000 Binary files a/Gores/BlindedAngler/BlindAnglerGore3.png and /dev/null differ diff --git a/Gores/BlindedAngler/BlindAnglerGore4.png b/Gores/BlindedAngler/BlindAnglerGore4.png deleted file mode 100644 index 2002e2a9ee..0000000000 Binary files a/Gores/BlindedAngler/BlindAnglerGore4.png and /dev/null differ diff --git a/Gores/BloodlettingServant1.png b/Gores/BloodlettingServant1.png deleted file mode 100644 index d7522171eb..0000000000 Binary files a/Gores/BloodlettingServant1.png and /dev/null differ diff --git a/Gores/BloodlettingServant2.png b/Gores/BloodlettingServant2.png deleted file mode 100644 index 391c59a4a7..0000000000 Binary files a/Gores/BloodlettingServant2.png and /dev/null differ diff --git a/Gores/BloodlettingServant3.png b/Gores/BloodlettingServant3.png deleted file mode 100644 index a4da81ae9f..0000000000 Binary files a/Gores/BloodlettingServant3.png and /dev/null differ diff --git a/Gores/BloodlettingServant4.png b/Gores/BloodlettingServant4.png deleted file mode 100644 index ddece78bac..0000000000 Binary files a/Gores/BloodlettingServant4.png and /dev/null differ diff --git a/Gores/Clam/Clam1.png b/Gores/Clam/Clam1.png deleted file mode 100644 index ba0409ad2a..0000000000 Binary files a/Gores/Clam/Clam1.png and /dev/null differ diff --git a/Gores/Clam/Clam2.png b/Gores/Clam/Clam2.png deleted file mode 100644 index 691e235b12..0000000000 Binary files a/Gores/Clam/Clam2.png and /dev/null differ diff --git a/Gores/Clam/Clam3.png b/Gores/Clam/Clam3.png deleted file mode 100644 index 400b4afe58..0000000000 Binary files a/Gores/Clam/Clam3.png and /dev/null differ diff --git a/Gores/Deconstructors/DeconstructorMK1_Body.png b/Gores/Deconstructors/DeconstructorMK1_Body.png new file mode 100644 index 0000000000..8cf7ae2134 Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_Body.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_Body2.png b/Gores/Deconstructors/DeconstructorMK1_Body2.png new file mode 100644 index 0000000000..9e692e8c90 Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_Body2.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_BodyAlt2_1.png b/Gores/Deconstructors/DeconstructorMK1_BodyAlt2_1.png new file mode 100644 index 0000000000..f3b5e8d1ee Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_BodyAlt2_1.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_BodyAlt2_2.png b/Gores/Deconstructors/DeconstructorMK1_BodyAlt2_2.png new file mode 100644 index 0000000000..b5bdccdc44 Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_BodyAlt2_2.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_BodyAlt_1.png b/Gores/Deconstructors/DeconstructorMK1_BodyAlt_1.png new file mode 100644 index 0000000000..e95aa036c9 Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_BodyAlt_1.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_BodyAlt_2.png b/Gores/Deconstructors/DeconstructorMK1_BodyAlt_2.png new file mode 100644 index 0000000000..f62caef49a Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_BodyAlt_2.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_Head.png b/Gores/Deconstructors/DeconstructorMK1_Head.png new file mode 100644 index 0000000000..23ba93b19e Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_Head.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_Head2.png b/Gores/Deconstructors/DeconstructorMK1_Head2.png new file mode 100644 index 0000000000..6900ed2884 Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_Head2.png differ diff --git a/Gores/Deconstructors/DeconstructorMK1_Tail.png b/Gores/Deconstructors/DeconstructorMK1_Tail.png new file mode 100644 index 0000000000..6ca67e4985 Binary files /dev/null and b/Gores/Deconstructors/DeconstructorMK1_Tail.png differ diff --git a/Gores/EutrophicRay/RayGore1.png b/Gores/EutrophicRay/RayGore1.png deleted file mode 100644 index 3ace444fd4..0000000000 Binary files a/Gores/EutrophicRay/RayGore1.png and /dev/null differ diff --git a/Gores/EutrophicRay/RayGore2.png b/Gores/EutrophicRay/RayGore2.png deleted file mode 100644 index 3ff64c48fd..0000000000 Binary files a/Gores/EutrophicRay/RayGore2.png and /dev/null differ diff --git a/Gores/EutrophicRay/RayGore3.png b/Gores/EutrophicRay/RayGore3.png deleted file mode 100644 index 777469c5cd..0000000000 Binary files a/Gores/EutrophicRay/RayGore3.png and /dev/null differ diff --git a/Gores/EutrophicRay/RayGore4.png b/Gores/EutrophicRay/RayGore4.png deleted file mode 100644 index 8764f51981..0000000000 Binary files a/Gores/EutrophicRay/RayGore4.png and /dev/null differ diff --git a/Gores/FrostcrushValariGore1.png b/Gores/FrostcrushValariGore1.png index dd5419f07c..f3e39318e5 100644 Binary files a/Gores/FrostcrushValariGore1.png and b/Gores/FrostcrushValariGore1.png differ diff --git a/Gores/FrostcrushValariGore2.png b/Gores/FrostcrushValariGore2.png index 0e8d76aeb7..315133d8fe 100644 Binary files a/Gores/FrostcrushValariGore2.png and b/Gores/FrostcrushValariGore2.png differ diff --git a/Gores/FrostcrushValariGore3.png b/Gores/FrostcrushValariGore3.png new file mode 100644 index 0000000000..5552210d32 Binary files /dev/null and b/Gores/FrostcrushValariGore3.png differ diff --git a/Gores/FrostcrushValariGore4.png b/Gores/FrostcrushValariGore4.png new file mode 100644 index 0000000000..94f39153c5 Binary files /dev/null and b/Gores/FrostcrushValariGore4.png differ diff --git a/Gores/FrostcrushValariGore5.png b/Gores/FrostcrushValariGore5.png new file mode 100644 index 0000000000..2ad19060cc Binary files /dev/null and b/Gores/FrostcrushValariGore5.png differ diff --git a/Gores/PrismTurtle/PrismTurtleGore1.png b/Gores/PrismTurtle/PrismTurtleGore1.png deleted file mode 100644 index 1446f7794a..0000000000 Binary files a/Gores/PrismTurtle/PrismTurtleGore1.png and /dev/null differ diff --git a/Gores/PrismTurtle/PrismTurtleGore2.png b/Gores/PrismTurtle/PrismTurtleGore2.png deleted file mode 100644 index b2fd0ca380..0000000000 Binary files a/Gores/PrismTurtle/PrismTurtleGore2.png and /dev/null differ diff --git a/Gores/PrismTurtle/PrismTurtleGore3.png b/Gores/PrismTurtle/PrismTurtleGore3.png deleted file mode 100644 index 45487321c7..0000000000 Binary files a/Gores/PrismTurtle/PrismTurtleGore3.png and /dev/null differ diff --git a/Gores/PrismTurtle/PrismTurtleGore4.png b/Gores/PrismTurtle/PrismTurtleGore4.png deleted file mode 100644 index be6c485878..0000000000 Binary files a/Gores/PrismTurtle/PrismTurtleGore4.png and /dev/null differ diff --git a/Gores/PrismTurtle/PrismTurtleGore5.png b/Gores/PrismTurtle/PrismTurtleGore5.png deleted file mode 100644 index 55d6e76bee..0000000000 Binary files a/Gores/PrismTurtle/PrismTurtleGore5.png and /dev/null differ diff --git a/Gores/SeaFloaty/SeaFloatyGore1.png b/Gores/SeaFloaty/SeaFloatyGore1.png deleted file mode 100644 index f168424afd..0000000000 Binary files a/Gores/SeaFloaty/SeaFloatyGore1.png and /dev/null differ diff --git a/Gores/SeaFloaty/SeaFloatyGore2.png b/Gores/SeaFloaty/SeaFloatyGore2.png deleted file mode 100644 index 2d117496cd..0000000000 Binary files a/Gores/SeaFloaty/SeaFloatyGore2.png and /dev/null differ diff --git a/Gores/SeaFloaty/SeaFloatyGore3.png b/Gores/SeaFloaty/SeaFloatyGore3.png deleted file mode 100644 index e6d79b947c..0000000000 Binary files a/Gores/SeaFloaty/SeaFloatyGore3.png and /dev/null differ diff --git a/Gores/SeaSerpent/SeaSerpentGore1.png b/Gores/SeaSerpent/SeaSerpentGore1.png deleted file mode 100644 index 828fc5cab8..0000000000 Binary files a/Gores/SeaSerpent/SeaSerpentGore1.png and /dev/null differ diff --git a/Gores/SeaSerpent/SeaSerpentGore2.png b/Gores/SeaSerpent/SeaSerpentGore2.png deleted file mode 100644 index e34333cc3a..0000000000 Binary files a/Gores/SeaSerpent/SeaSerpentGore2.png and /dev/null differ diff --git a/Gores/SeaSerpent/SeaSerpentGore3.png b/Gores/SeaSerpent/SeaSerpentGore3.png deleted file mode 100644 index 0835dffcf4..0000000000 Binary files a/Gores/SeaSerpent/SeaSerpentGore3.png and /dev/null differ diff --git a/Gores/SeaSerpent/SeaSerpentGore4.png b/Gores/SeaSerpent/SeaSerpentGore4.png deleted file mode 100644 index fc0b44b6b2..0000000000 Binary files a/Gores/SeaSerpent/SeaSerpentGore4.png and /dev/null differ diff --git a/Gores/SeaSerpent/SeaSerpentGore5.png b/Gores/SeaSerpent/SeaSerpentGore5.png deleted file mode 100644 index c39cf01434..0000000000 Binary files a/Gores/SeaSerpent/SeaSerpentGore5.png and /dev/null differ diff --git a/Gores/SkeletronPrimes_RevMaster/ChadPrime1.png b/Gores/SkeletronPrimes_RevMaster/ChadPrime1.png deleted file mode 100644 index 07f2e01333..0000000000 Binary files a/Gores/SkeletronPrimes_RevMaster/ChadPrime1.png and /dev/null differ diff --git a/Gores/SkeletronPrimes_RevMaster/ChadPrime2.png b/Gores/SkeletronPrimes_RevMaster/ChadPrime2.png deleted file mode 100644 index 303ac4ccde..0000000000 Binary files a/Gores/SkeletronPrimes_RevMaster/ChadPrime2.png and /dev/null differ diff --git a/Gores/SkeletronPrimes_RevMaster/SkeletronPrime2_1.png b/Gores/SkeletronPrimes_RevMaster/SkeletronPrime2_1.png deleted file mode 100644 index 860fd8b8c2..0000000000 Binary files a/Gores/SkeletronPrimes_RevMaster/SkeletronPrime2_1.png and /dev/null differ diff --git a/Gores/SkeletronPrimes_RevMaster/SkeletronPrime2_2.png b/Gores/SkeletronPrimes_RevMaster/SkeletronPrime2_2.png deleted file mode 100644 index 613ee6e5e1..0000000000 Binary files a/Gores/SkeletronPrimes_RevMaster/SkeletronPrime2_2.png and /dev/null differ diff --git a/Gores/SulphSeaGen/AbyssPotGore1.png b/Gores/SulphSeaGen/AbyssPotGore1.png deleted file mode 100644 index cd19852002..0000000000 Binary files a/Gores/SulphSeaGen/AbyssPotGore1.png and /dev/null differ diff --git a/Gores/SulphSeaGen/AbyssPotGore2.png b/Gores/SulphSeaGen/AbyssPotGore2.png deleted file mode 100644 index 9554ae7280..0000000000 Binary files a/Gores/SulphSeaGen/AbyssPotGore2.png and /dev/null differ diff --git a/Gores/SunkenSea/AlphaSeaMinnow/AlphaSeaMinnow.png b/Gores/SunkenSea/AlphaSeaMinnow/AlphaSeaMinnow.png new file mode 100644 index 0000000000..cd988d9708 Binary files /dev/null and b/Gores/SunkenSea/AlphaSeaMinnow/AlphaSeaMinnow.png differ diff --git a/Gores/SunkenSea/AlphaSeaMinnow/AlphaSeaMinnow2.png b/Gores/SunkenSea/AlphaSeaMinnow/AlphaSeaMinnow2.png new file mode 100644 index 0000000000..2461161b43 Binary files /dev/null and b/Gores/SunkenSea/AlphaSeaMinnow/AlphaSeaMinnow2.png differ diff --git a/Gores/SunkenSea/CarrionSwallower/CarrionSwallower.png b/Gores/SunkenSea/CarrionSwallower/CarrionSwallower.png new file mode 100644 index 0000000000..9ce1fb9f9a Binary files /dev/null and b/Gores/SunkenSea/CarrionSwallower/CarrionSwallower.png differ diff --git a/Gores/SunkenSea/CarrionSwallower/CarrionSwallower2.png b/Gores/SunkenSea/CarrionSwallower/CarrionSwallower2.png new file mode 100644 index 0000000000..219840d43c Binary files /dev/null and b/Gores/SunkenSea/CarrionSwallower/CarrionSwallower2.png differ diff --git a/Gores/SunkenSea/Clam/Clam.png b/Gores/SunkenSea/Clam/Clam.png new file mode 100644 index 0000000000..d2f7dec5ff Binary files /dev/null and b/Gores/SunkenSea/Clam/Clam.png differ diff --git a/Gores/SunkenSea/Clam/Clam2.png b/Gores/SunkenSea/Clam/Clam2.png new file mode 100644 index 0000000000..1238322962 Binary files /dev/null and b/Gores/SunkenSea/Clam/Clam2.png differ diff --git a/Gores/SunkenSea/Clam/ClamAlgae.png b/Gores/SunkenSea/Clam/ClamAlgae.png new file mode 100644 index 0000000000..96c5fb5605 Binary files /dev/null and b/Gores/SunkenSea/Clam/ClamAlgae.png differ diff --git a/Gores/SunkenSea/Clam/ClamAlgae2.png b/Gores/SunkenSea/Clam/ClamAlgae2.png new file mode 100644 index 0000000000..7895573ce5 Binary files /dev/null and b/Gores/SunkenSea/Clam/ClamAlgae2.png differ diff --git a/Gores/SunkenSea/Clam/ClamCoral.png b/Gores/SunkenSea/Clam/ClamCoral.png new file mode 100644 index 0000000000..7d64bc4018 Binary files /dev/null and b/Gores/SunkenSea/Clam/ClamCoral.png differ diff --git a/Gores/SunkenSea/Clam/ClamCoral2.png b/Gores/SunkenSea/Clam/ClamCoral2.png new file mode 100644 index 0000000000..27c956b19a Binary files /dev/null and b/Gores/SunkenSea/Clam/ClamCoral2.png differ diff --git a/Gores/SunkenSea/EutrophicRay/EutrophicRay.png b/Gores/SunkenSea/EutrophicRay/EutrophicRay.png new file mode 100644 index 0000000000..396aceb7a2 Binary files /dev/null and b/Gores/SunkenSea/EutrophicRay/EutrophicRay.png differ diff --git a/Gores/SunkenSea/EutrophicRay/EutrophicRay2.png b/Gores/SunkenSea/EutrophicRay/EutrophicRay2.png new file mode 100644 index 0000000000..e1510c0c33 Binary files /dev/null and b/Gores/SunkenSea/EutrophicRay/EutrophicRay2.png differ diff --git a/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl.png b/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl.png new file mode 100644 index 0000000000..be01961e7c Binary files /dev/null and b/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl.png differ diff --git a/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl2.png b/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl2.png new file mode 100644 index 0000000000..dc669f674f Binary files /dev/null and b/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl2.png differ diff --git a/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl3.png b/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl3.png new file mode 100644 index 0000000000..1944fd7519 Binary files /dev/null and b/Gores/SunkenSea/GIldedAxolotl/GildedAxolotl3.png differ diff --git a/Gores/SunkenSea/Grubbolt/Grubbolt.png b/Gores/SunkenSea/Grubbolt/Grubbolt.png new file mode 100644 index 0000000000..6acea8d8a5 Binary files /dev/null and b/Gores/SunkenSea/Grubbolt/Grubbolt.png differ diff --git a/Gores/SunkenSea/Grubbolt/Grubbolt2.png b/Gores/SunkenSea/Grubbolt/Grubbolt2.png new file mode 100644 index 0000000000..e71263436b Binary files /dev/null and b/Gores/SunkenSea/Grubbolt/Grubbolt2.png differ diff --git a/Gores/SunkenSea/Haunted Chum and Sea Remains/FesteringRemains.png b/Gores/SunkenSea/Haunted Chum and Sea Remains/FesteringRemains.png new file mode 100644 index 0000000000..196d767516 Binary files /dev/null and b/Gores/SunkenSea/Haunted Chum and Sea Remains/FesteringRemains.png differ diff --git a/Gores/SunkenSea/Haunted Chum and Sea Remains/HauntedChum.png b/Gores/SunkenSea/Haunted Chum and Sea Remains/HauntedChum.png new file mode 100644 index 0000000000..589fe2d828 Binary files /dev/null and b/Gores/SunkenSea/Haunted Chum and Sea Remains/HauntedChum.png differ diff --git a/Gores/SunkenSea/Haunted Chum and Sea Remains/HauntedChum2.png b/Gores/SunkenSea/Haunted Chum and Sea Remains/HauntedChum2.png new file mode 100644 index 0000000000..b1c7e2f0d5 Binary files /dev/null and b/Gores/SunkenSea/Haunted Chum and Sea Remains/HauntedChum2.png differ diff --git a/Gores/SunkenSea/Jellyghoul/Jellyghoul.png b/Gores/SunkenSea/Jellyghoul/Jellyghoul.png new file mode 100644 index 0000000000..afc08ef7ae Binary files /dev/null and b/Gores/SunkenSea/Jellyghoul/Jellyghoul.png differ diff --git a/Gores/SunkenSea/Jellyghoul/Jellyghoul2.png b/Gores/SunkenSea/Jellyghoul/Jellyghoul2.png new file mode 100644 index 0000000000..f1681462d6 Binary files /dev/null and b/Gores/SunkenSea/Jellyghoul/Jellyghoul2.png differ diff --git a/Gores/SunkenSea/LazarusLampfish/LazarusLampfish.png b/Gores/SunkenSea/LazarusLampfish/LazarusLampfish.png new file mode 100644 index 0000000000..b26b49cce2 Binary files /dev/null and b/Gores/SunkenSea/LazarusLampfish/LazarusLampfish.png differ diff --git a/Gores/SunkenSea/LazarusLampfish/LazarusLampfish2.png b/Gores/SunkenSea/LazarusLampfish/LazarusLampfish2.png new file mode 100644 index 0000000000..d006f89e46 Binary files /dev/null and b/Gores/SunkenSea/LazarusLampfish/LazarusLampfish2.png differ diff --git a/Gores/SunkenSea/LazarusLampfish/LazarusLampfish3.png b/Gores/SunkenSea/LazarusLampfish/LazarusLampfish3.png new file mode 100644 index 0000000000..cb1508e0a9 Binary files /dev/null and b/Gores/SunkenSea/LazarusLampfish/LazarusLampfish3.png differ diff --git a/Gores/SunkenSea/Leerslug/Leerslug.png b/Gores/SunkenSea/Leerslug/Leerslug.png new file mode 100644 index 0000000000..fdcaefa78d Binary files /dev/null and b/Gores/SunkenSea/Leerslug/Leerslug.png differ diff --git a/Gores/SunkenSea/Leerslug/Leerslug2.png b/Gores/SunkenSea/Leerslug/Leerslug2.png new file mode 100644 index 0000000000..f012792a94 Binary files /dev/null and b/Gores/SunkenSea/Leerslug/Leerslug2.png differ diff --git a/Gores/SunkenSea/Mirage Newt/MirageNewt.png b/Gores/SunkenSea/Mirage Newt/MirageNewt.png new file mode 100644 index 0000000000..ce4272b30d Binary files /dev/null and b/Gores/SunkenSea/Mirage Newt/MirageNewt.png differ diff --git a/Gores/SunkenSea/Mirage Newt/MirageNewt2.png b/Gores/SunkenSea/Mirage Newt/MirageNewt2.png new file mode 100644 index 0000000000..930ce9bc14 Binary files /dev/null and b/Gores/SunkenSea/Mirage Newt/MirageNewt2.png differ diff --git a/Gores/SunkenSea/Mirage Newt/MirageNewt3.png b/Gores/SunkenSea/Mirage Newt/MirageNewt3.png new file mode 100644 index 0000000000..11bd14750f Binary files /dev/null and b/Gores/SunkenSea/Mirage Newt/MirageNewt3.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodBlack.png b/Gores/SunkenSea/Pearlpod/PearlpodBlack.png new file mode 100644 index 0000000000..d42d44e8c6 Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodBlack.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodBlack2.png b/Gores/SunkenSea/Pearlpod/PearlpodBlack2.png new file mode 100644 index 0000000000..eef9f665db Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodBlack2.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodBlack3.png b/Gores/SunkenSea/Pearlpod/PearlpodBlack3.png new file mode 100644 index 0000000000..8791d0d210 Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodBlack3.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodPink.png b/Gores/SunkenSea/Pearlpod/PearlpodPink.png new file mode 100644 index 0000000000..a8d03fe1cd Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodPink.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodPink2.png b/Gores/SunkenSea/Pearlpod/PearlpodPink2.png new file mode 100644 index 0000000000..78f672c130 Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodPink2.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodPink3.png b/Gores/SunkenSea/Pearlpod/PearlpodPink3.png new file mode 100644 index 0000000000..a6c8cf5905 Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodPink3.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodWhite.png b/Gores/SunkenSea/Pearlpod/PearlpodWhite.png new file mode 100644 index 0000000000..c1a450765f Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodWhite.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodWhite2.png b/Gores/SunkenSea/Pearlpod/PearlpodWhite2.png new file mode 100644 index 0000000000..1737b77bd2 Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodWhite2.png differ diff --git a/Gores/SunkenSea/Pearlpod/PearlpodWhite3.png b/Gores/SunkenSea/Pearlpod/PearlpodWhite3.png new file mode 100644 index 0000000000..f8a8f168c5 Binary files /dev/null and b/Gores/SunkenSea/Pearlpod/PearlpodWhite3.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoi.png b/Gores/SunkenSea/PodobooKoi/PodobooKoi.png new file mode 100644 index 0000000000..e68deb05db Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoi.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoi2.png b/Gores/SunkenSea/PodobooKoi/PodobooKoi2.png new file mode 100644 index 0000000000..fc6e678e33 Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoi2.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoiBubbleEyed.png b/Gores/SunkenSea/PodobooKoi/PodobooKoiBubbleEyed.png new file mode 100644 index 0000000000..93cc02efad Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoiBubbleEyed.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoiBubbleEyed2.png b/Gores/SunkenSea/PodobooKoi/PodobooKoiBubbleEyed2.png new file mode 100644 index 0000000000..3b35ea59fd Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoiBubbleEyed2.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoiComet.png b/Gores/SunkenSea/PodobooKoi/PodobooKoiComet.png new file mode 100644 index 0000000000..09c8dec8b4 Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoiComet.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoiComet2.png b/Gores/SunkenSea/PodobooKoi/PodobooKoiComet2.png new file mode 100644 index 0000000000..0194fe04d5 Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoiComet2.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoiOranda.png b/Gores/SunkenSea/PodobooKoi/PodobooKoiOranda.png new file mode 100644 index 0000000000..c163524603 Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoiOranda.png differ diff --git a/Gores/SunkenSea/PodobooKoi/PodobooKoiOranda2.png b/Gores/SunkenSea/PodobooKoi/PodobooKoiOranda2.png new file mode 100644 index 0000000000..3935aa8309 Binary files /dev/null and b/Gores/SunkenSea/PodobooKoi/PodobooKoiOranda2.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaGreen.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaGreen.png new file mode 100644 index 0000000000..b655a527e7 Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaGreen.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaGreen2.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaGreen2.png new file mode 100644 index 0000000000..324aeffd13 Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaGreen2.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaPurple.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaPurple.png new file mode 100644 index 0000000000..aae3859aa8 Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaPurple.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaPurple2.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaPurple2.png new file mode 100644 index 0000000000..9383cdba77 Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaPurple2.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaRed.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaRed.png new file mode 100644 index 0000000000..e86217d5f9 Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaRed.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaRed2.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaRed2.png new file mode 100644 index 0000000000..3a341d76ff Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaRed2.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaTurquoise.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaTurquoise.png new file mode 100644 index 0000000000..fe815bf047 Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaTurquoise.png differ diff --git a/Gores/SunkenSea/PolypPanasea/PolypPanaseaTurquoise2.png b/Gores/SunkenSea/PolypPanasea/PolypPanaseaTurquoise2.png new file mode 100644 index 0000000000..17defd1d2f Binary files /dev/null and b/Gores/SunkenSea/PolypPanasea/PolypPanaseaTurquoise2.png differ diff --git a/Gores/SunkenSea/Polyperil/PolyperilBlue.png b/Gores/SunkenSea/Polyperil/PolyperilBlue.png new file mode 100644 index 0000000000..ce61222b72 Binary files /dev/null and b/Gores/SunkenSea/Polyperil/PolyperilBlue.png differ diff --git a/Gores/SunkenSea/Polyperil/PolyperilGreen.png b/Gores/SunkenSea/Polyperil/PolyperilGreen.png new file mode 100644 index 0000000000..8b57639463 Binary files /dev/null and b/Gores/SunkenSea/Polyperil/PolyperilGreen.png differ diff --git a/Gores/SunkenSea/Polyperil/PolyperilPink.png b/Gores/SunkenSea/Polyperil/PolyperilPink.png new file mode 100644 index 0000000000..6ba55362c1 Binary files /dev/null and b/Gores/SunkenSea/Polyperil/PolyperilPink.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue.png new file mode 100644 index 0000000000..567f027535 Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue2.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue2.png new file mode 100644 index 0000000000..9f64e00f3c Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue2.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue3.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue3.png new file mode 100644 index 0000000000..e7551a56e2 Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyBlue3.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen.png new file mode 100644 index 0000000000..b152a273f6 Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen2.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen2.png new file mode 100644 index 0000000000..43f50afc97 Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen2.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen3.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen3.png new file mode 100644 index 0000000000..652ad65b71 Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyGreen3.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink.png new file mode 100644 index 0000000000..c81d50f4e2 Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink2.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink2.png new file mode 100644 index 0000000000..f6f9f468ae Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink2.png differ diff --git a/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink3.png b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink3.png new file mode 100644 index 0000000000..71a419fafc Binary files /dev/null and b/Gores/SunkenSea/PrismaticGuppy/PrismaticGuppyPink3.png differ diff --git a/Gores/SunkenSea/Prismback/Prismback.png b/Gores/SunkenSea/Prismback/Prismback.png new file mode 100644 index 0000000000..0d5ea0d78a Binary files /dev/null and b/Gores/SunkenSea/Prismback/Prismback.png differ diff --git a/Gores/SunkenSea/Prismback/Prismback2.png b/Gores/SunkenSea/Prismback/Prismback2.png new file mode 100644 index 0000000000..4b5dc72a4e Binary files /dev/null and b/Gores/SunkenSea/Prismback/Prismback2.png differ diff --git a/Gores/SunkenSea/Prismback/Prismback3.png b/Gores/SunkenSea/Prismback/Prismback3.png new file mode 100644 index 0000000000..52857340b8 Binary files /dev/null and b/Gores/SunkenSea/Prismback/Prismback3.png differ diff --git a/Gores/SunkenSea/Probesnout/Probesnout1.png b/Gores/SunkenSea/Probesnout/Probesnout.png similarity index 100% rename from Gores/SunkenSea/Probesnout/Probesnout1.png rename to Gores/SunkenSea/Probesnout/Probesnout.png diff --git a/Gores/SunkenSea/Probesnout/ProbesnoutGold1.png b/Gores/SunkenSea/Probesnout/ProbesnoutGold1.png deleted file mode 100644 index d31b36eb5b..0000000000 Binary files a/Gores/SunkenSea/Probesnout/ProbesnoutGold1.png and /dev/null differ diff --git a/Gores/SunkenSea/Probesnout/ProbesnoutGold2.png b/Gores/SunkenSea/Probesnout/ProbesnoutGold2.png deleted file mode 100644 index 03ffdc3538..0000000000 Binary files a/Gores/SunkenSea/Probesnout/ProbesnoutGold2.png and /dev/null differ diff --git a/Gores/SunkenSea/Probesnout/ProbesnoutGold3.png b/Gores/SunkenSea/Probesnout/ProbesnoutGold3.png deleted file mode 100644 index 6bef3c6981..0000000000 Binary files a/Gores/SunkenSea/Probesnout/ProbesnoutGold3.png and /dev/null differ diff --git a/Gores/SunkenSea/Probesnout/ProbesnoutGold4.png b/Gores/SunkenSea/Probesnout/ProbesnoutGold4.png deleted file mode 100644 index 3585353385..0000000000 Binary files a/Gores/SunkenSea/Probesnout/ProbesnoutGold4.png and /dev/null differ diff --git a/Gores/SunkenSea/Scavenger/Scavenger.png b/Gores/SunkenSea/Scavenger/Scavenger.png new file mode 100644 index 0000000000..4be4f6e5b4 Binary files /dev/null and b/Gores/SunkenSea/Scavenger/Scavenger.png differ diff --git a/Gores/SunkenSea/Scavenger/Scavenger2.png b/Gores/SunkenSea/Scavenger/Scavenger2.png new file mode 100644 index 0000000000..fc36e784b8 Binary files /dev/null and b/Gores/SunkenSea/Scavenger/Scavenger2.png differ diff --git a/Gores/SunkenSea/Scavenger/Scavenger3.png b/Gores/SunkenSea/Scavenger/Scavenger3.png new file mode 100644 index 0000000000..f37a521d25 Binary files /dev/null and b/Gores/SunkenSea/Scavenger/Scavenger3.png differ diff --git a/Gores/SunkenSea/SeaFloaty/SeaFloaty.png b/Gores/SunkenSea/SeaFloaty/SeaFloaty.png new file mode 100644 index 0000000000..38c0343762 Binary files /dev/null and b/Gores/SunkenSea/SeaFloaty/SeaFloaty.png differ diff --git a/Gores/SunkenSea/SeaMinnow/SeaMinnow.png b/Gores/SunkenSea/SeaMinnow/SeaMinnow.png new file mode 100644 index 0000000000..f3594a41e9 Binary files /dev/null and b/Gores/SunkenSea/SeaMinnow/SeaMinnow.png differ diff --git a/Gores/SunkenSea/SeaMinnow/SeaMinnow2.png b/Gores/SunkenSea/SeaMinnow/SeaMinnow2.png new file mode 100644 index 0000000000..b244fbf9a8 Binary files /dev/null and b/Gores/SunkenSea/SeaMinnow/SeaMinnow2.png differ diff --git a/Gores/SunkenSea/Searslug/Searslug.png b/Gores/SunkenSea/Searslug/Searslug.png new file mode 100644 index 0000000000..50919d11d2 Binary files /dev/null and b/Gores/SunkenSea/Searslug/Searslug.png differ diff --git a/Gores/SunkenSea/Searslug/Searslug2.png b/Gores/SunkenSea/Searslug/Searslug2.png new file mode 100644 index 0000000000..5cecafe7eb Binary files /dev/null and b/Gores/SunkenSea/Searslug/Searslug2.png differ diff --git a/Gores/SunkenSea/Sharkoon/Sharkoon.png b/Gores/SunkenSea/Sharkoon/Sharkoon.png new file mode 100644 index 0000000000..f970a5057d Binary files /dev/null and b/Gores/SunkenSea/Sharkoon/Sharkoon.png differ diff --git a/Gores/SunkenSea/Sharkoon/Sharkoon5.png b/Gores/SunkenSea/Sharkoon/Sharkoon5.png new file mode 100644 index 0000000000..68e7fdcc27 Binary files /dev/null and b/Gores/SunkenSea/Sharkoon/Sharkoon5.png differ diff --git a/Gores/SunkenSea/Sharkoon/Sharkoon1.png b/Gores/SunkenSea/Sharkoon/Sharkoon6.png similarity index 100% rename from Gores/SunkenSea/Sharkoon/Sharkoon1.png rename to Gores/SunkenSea/Sharkoon/Sharkoon6.png diff --git a/Gores/SunkenSea/Sharkoon/SharkoonSmall1.png b/Gores/SunkenSea/Sharkoon/SharkoonSmall.png similarity index 100% rename from Gores/SunkenSea/Sharkoon/SharkoonSmall1.png rename to Gores/SunkenSea/Sharkoon/SharkoonSmall.png diff --git a/Gores/SunkenSea/Shoreskipper/Shoreskipper.png b/Gores/SunkenSea/Shoreskipper/Shoreskipper.png new file mode 100644 index 0000000000..cf34b7503a Binary files /dev/null and b/Gores/SunkenSea/Shoreskipper/Shoreskipper.png differ diff --git a/Gores/SunkenSea/Shoreskipper/Shoreskipper2.png b/Gores/SunkenSea/Shoreskipper/Shoreskipper2.png new file mode 100644 index 0000000000..bea9f285b7 Binary files /dev/null and b/Gores/SunkenSea/Shoreskipper/Shoreskipper2.png differ diff --git a/Gores/SunkenSea/Steampod/Steampod.png b/Gores/SunkenSea/Steampod/Steampod.png new file mode 100644 index 0000000000..002b1e52fa Binary files /dev/null and b/Gores/SunkenSea/Steampod/Steampod.png differ diff --git a/Gores/SunkenSea/Steampod/Steampod2.png b/Gores/SunkenSea/Steampod/Steampod2.png new file mode 100644 index 0000000000..502f50e75f Binary files /dev/null and b/Gores/SunkenSea/Steampod/Steampod2.png differ diff --git a/Gores/SunkenSea/Steampod/Steampod3.png b/Gores/SunkenSea/Steampod/Steampod3.png new file mode 100644 index 0000000000..871c61b10a Binary files /dev/null and b/Gores/SunkenSea/Steampod/Steampod3.png differ diff --git a/Gores/SunkenSea/StormlionSentry/StormlionSentry.png b/Gores/SunkenSea/StormlionSentry/StormlionSentry.png new file mode 100644 index 0000000000..dc5d98002b Binary files /dev/null and b/Gores/SunkenSea/StormlionSentry/StormlionSentry.png differ diff --git a/Gores/SunkenSea/StormlionSentry/StormlionSentry2.png b/Gores/SunkenSea/StormlionSentry/StormlionSentry2.png new file mode 100644 index 0000000000..6adb6639e4 Binary files /dev/null and b/Gores/SunkenSea/StormlionSentry/StormlionSentry2.png differ diff --git a/Gores/SunkenSea/StormlionSentry/StormlionSentry3.png b/Gores/SunkenSea/StormlionSentry/StormlionSentry3.png new file mode 100644 index 0000000000..aa97a735b4 Binary files /dev/null and b/Gores/SunkenSea/StormlionSentry/StormlionSentry3.png differ diff --git a/Gores/WaterDroplet/BasaltGullyLavaDroplet.cs b/Gores/WaterDroplet/BasaltGullyLavaDroplet.cs new file mode 100644 index 0000000000..d11e87ee5d --- /dev/null +++ b/Gores/WaterDroplet/BasaltGullyLavaDroplet.cs @@ -0,0 +1,11 @@ +using Microsoft.Xna.Framework; + +namespace CalamityMod.Gores.WaterDroplet +{ + public class BasaltGullyLavaDroplet : LiquidDropletGore + { + public override bool lavaDroplet => true; + + public override Vector3 lavaColor => new Vector3(2.5f, 1.3f, 0.1f); + } +} diff --git a/Gores/WaterDroplet/BasaltGullyLavaDroplet.png b/Gores/WaterDroplet/BasaltGullyLavaDroplet.png new file mode 100644 index 0000000000..fa76dba55c Binary files /dev/null and b/Gores/WaterDroplet/BasaltGullyLavaDroplet.png differ diff --git a/Gores/WyvernWeapons/ClamorNoctusBody.png b/Gores/WyvernWeapons/ClamorNoctusBody.png deleted file mode 100644 index fed1db2d2e..0000000000 Binary files a/Gores/WyvernWeapons/ClamorNoctusBody.png and /dev/null differ diff --git a/Gores/WyvernWeapons/ClamorNoctusHead.png b/Gores/WyvernWeapons/ClamorNoctusHead.png deleted file mode 100644 index 7ab312edd3..0000000000 Binary files a/Gores/WyvernWeapons/ClamorNoctusHead.png and /dev/null differ diff --git a/Gores/WyvernWeapons/ClamorNoctusTail.png b/Gores/WyvernWeapons/ClamorNoctusTail.png deleted file mode 100644 index 02d8c84a0c..0000000000 Binary files a/Gores/WyvernWeapons/ClamorNoctusTail.png and /dev/null differ diff --git a/Graphics/EnhancedDarknessSystem.cs b/Graphics/EnhancedDarknessSystem.cs new file mode 100644 index 0000000000..f300ee70fb --- /dev/null +++ b/Graphics/EnhancedDarknessSystem.cs @@ -0,0 +1,133 @@ +using System.Collections.Generic; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.Graphics.Light; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics +{ + public class EnhancedDarknessSystem : ModSystem + { + + private static Asset _defaultTexture; + public class LightSource + { + + public Texture2D texture = _defaultTexture.Value; + public float scale = 1; + public Vector2 vectorScale = Vector2.One; + public Vector2 center = Main.LocalPlayer.Center; + public float rotation = 0; + public float opacity = 1; + public Color color = Color.White; + public int lifetime = 1; + public Rectangle? frame = null; + public LightSource() { } + + // This constructor only gives the most common arguments. Frame, Color, lifetime, etc. must be set in curly braces afterwards to prevent this constructor getting too unwieldy. + public LightSource(Vector2? center = null, Texture2D texture = null, float scale = 1, float rotation = 0, Vector2? vectorScale = null, float opacity = 1) + { + this.texture = texture ?? ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + this.scale = scale; + this.vectorScale = vectorScale ?? Vector2.One; + this.center = center ?? Main.LocalPlayer.Center; + this.rotation = rotation; + this.opacity = opacity; + } + } + + public static List lights = new(); + public override void Load() + { + On_OverlayManager.Draw += DrawShadowOverlay; + On_LightingEngine.UpdateLightDecay += AdjustTransmissiveness; + _defaultTexture = ModContent.Request("CalamityMod/Particles/BloomCircle"); + } + + private void DrawShadowOverlay(On_OverlayManager.orig_Draw orig, OverlayManager self, SpriteBatch spriteBatch, RenderLayers layer, bool beginSpriteBatch) + { + orig(self, spriteBatch, layer, beginSpriteBatch); + + //This ensures that the shadows only draw + // - In the world + // - Right before UI is drawn (and right before the hideUI check), as that's where RenderLayers.All is drawn + // - + if (Main.gameMenu || layer != RenderLayers.All || Main.LocalPlayer.Calamity().darknessIntensity <= 0) + return; + var mp = Main.LocalPlayer.Calamity(); + + var device = Main.instance.GraphicsDevice; + using var lease = RenderTargetPool.Shared.Rent( + device, + Main.screenWidth, + Main.screenHeight, + RenderTargetDescriptor.Default + ); + + using (lease.Scope(clearColor: Color.Black)) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + foreach (var item in lights) + { + Main.spriteBatch.Draw(item.texture, (item.center - Main.screenPosition), item.frame, item.color * item.opacity, item.rotation, item.frame is null ? item.texture.Size() * 0.5f : item.frame.Value.Size(), item.vectorScale * item.scale, SpriteEffects.None, 0); + } + Main.spriteBatch.End(); + } + + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + var shader = GameShaders.Misc["CalamityMod:DozeLightingShader"]; + shader.UseOpacity(mp.darknessIntensity); + shader.Apply(); + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, 0, 0); + spriteBatch.End(); + } + } + + + private const float VanillaWaterLightMult = 0.91f; //Vanilla water light multiplier. + private void AdjustTransmissiveness(On_LightingEngine.orig_UpdateLightDecay orig, LightingEngine self) + { + orig(self); + + var mp = Main.LocalPlayer.Calamity(); + LightMap map = self._workingLightMap; + if (mp.ZoneAbyss) + { + //This converts the light decay amount from the amount it normally is in water into the amount it normally is in air, depending on the intensity of the abyss darkness. + //This is to offset the abyss darkness system to make the parts that are supposed to be visible easier to see. + //Dividing by 0.91 brings the water back to 100% transmissiveness with the original color + map.LightDecayThroughWater = Vector3.Lerp(map.LightDecayThroughWater, (map.LightDecayThroughWater / VanillaWaterLightMult) * 0.95f, MathHelper.Clamp(mp.darknessIntensity, 0, 1)); + } + } + + public override void OnWorldUnload() + { + lights.Clear(); + } + + public override void PreUpdateEntities() + { + //Every frame, the light sources are determined by what was added on that frame only. Therefore, we reset the light list every frame. + //Lifetime is provided to smooth out things that don't run every frame consistently to prevent flickering, such as the abyss torches. + for (var i = 0; i < lights.Count; i++) + { + var item = lights[i]; + item.lifetime--; + if (item.lifetime <= 0) + { + lights.Remove(item); + i--; + } + } + } + + } +} diff --git a/Graphics/ManagedRenderTarget.cs b/Graphics/ManagedRenderTarget.cs index f69b815ca7..47f563979f 100644 --- a/Graphics/ManagedRenderTarget.cs +++ b/Graphics/ManagedRenderTarget.cs @@ -1,114 +1,138 @@ using System; +using System.Collections.Generic; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -namespace CalamityMod.Graphics +namespace CalamityMod.Graphics; + +internal sealed class ManagedRenderTargetPool : RenderTargetPool { - /// - /// Wrapper class for that safely handles resizing, unloading and auto-disposal if not currently in use to save - /// on GPU memory. - /// - public class ManagedRenderTarget : IDisposable + public new static ManagedRenderTargetPool Shared { get; } = new(); + + private static readonly List managedTargets = []; + + public override RenderTargetLease Rent(GraphicsDevice device, int width, int height, RenderTargetDescriptor descriptor) { - private RenderTarget2D target; + throw new InvalidOperationException("ManagedRenderTargetPool does not support directly leasing targets"); + } - public readonly RenderTargetCreationCondition CreationCondition; + public RenderTargetLease Register(ManagedRenderTarget managedTarget) + { + managedTargets.Add(managedTarget); + return new RenderTargetLease(managedTarget.CreationCondition(Main.screenWidth, Main.screenHeight), this); + } - public readonly bool ShouldResetUponScreenResize; + public override void Return(RenderTargetLease lease) + { + lease.Target.Dispose(); + } - public readonly bool ShouldAutoDispose; - - public bool WaitingForFirstInitialization + public void Return(ManagedRenderTarget managedRt, bool preserveCollection) + { + if (!preserveCollection) { - get; - private set; - } = true; - - public bool IsUninitialized => target is null || target.IsDisposed; - - public bool IsDisposed - { - get; - private set; + _ = managedTargets.Remove(managedRt); } - /// - /// The actual instance that the wrapper contains. - /// - public RenderTarget2D Target + Return(managedRt.lease); + } + + public override void Dispose() + { + foreach (var target in managedTargets) { - get + target.Dispose(preserveCollection: true); + } + + managedTargets.Clear(); + } + + internal void ResizeTargets() + { + foreach (var target in managedTargets) + { + if (target.ShouldResetUponScreenResize) { - if (IsUninitialized) - { - target = CreationCondition(Main.screenWidth, Main.screenHeight); - WaitingForFirstInitialization = false; - IsDisposed = false; - } - - TimeSinceLastAccessed = 0; - return target; + target.lease.Target.Dispose(); + target.lease.Target = target.CreationCondition(Main.screenWidth, Main.screenHeight); } - private set => target = value; } - - public int Width => Target.Width; - - public int Height => Target.Height; - - public Vector2 Size => new(Width, Height); - - /// - /// How many frames since this target has been gotten. Used to dispose of unused targets for the sake of performance. - /// - public int TimeSinceLastAccessed; - - public delegate RenderTarget2D RenderTargetCreationCondition(int screenWidth, int screenHeight); - - // For some reason, adding more arguments to this constructor causes really low end pcs to crash in FNA. I cannot figure out why, so do not use them. - public static RenderTarget2D CreateScreenSizedTarget(int screenWidth, int screenHeight) => new(Main.instance.GraphicsDevice, screenWidth, screenHeight); - - public ManagedRenderTarget(bool shouldResetUponScreenResize, RenderTargetCreationCondition creationCondition, bool shouldAutoDispose = true) - { - ShouldResetUponScreenResize = shouldResetUponScreenResize; - CreationCondition = creationCondition; - ShouldAutoDispose = shouldAutoDispose; - RenderTargetManager.ManagedTargets.Add(this); - } - - /// - /// Sets the current render target to the provided one. - /// - /// The render target to swap to - /// The color to clear the screen with. Transparent by default - public void SwapTo(Color? flushColor = null) => Target.SwapTo(flushColor); - - /// - /// Automatically called by , do not call! - /// - public void Dispose() - { - if (IsDisposed) - return; - - IsDisposed = true; - target?.Dispose(); - GC.SuppressFinalize(this); - } - - /// - /// Automatically called by , do not call! - /// - public void Recreate(int screenWidth, int screenHeight) - { - Dispose(); - IsDisposed = false; - - target = CreationCondition(screenWidth, screenHeight); - TimeSinceLastAccessed = 0; - } - - public static implicit operator RenderTarget2D(ManagedRenderTarget target) => target.Target; } } + +[Obsolete("ManagedRenderTarget is obsolete; developers should use RenderTarget2Ds and RenderTargetLeases")] +public class ManagedRenderTarget : IDisposable +{ + internal RenderTargetLease lease; + + public readonly RenderTargetCreationCondition CreationCondition; + + public readonly bool ShouldResetUponScreenResize; + + public readonly bool ShouldAutoDispose; + + public bool WaitingForFirstInitialization => false; + + public bool IsUninitialized => false; + + public bool IsDisposed + { + get; + private set; + } + + /// + /// The actual instance that the wrapper contains. + /// + public RenderTarget2D Target => lease.Target; + + public int Width => Target.Width; + + public int Height => Target.Height; + + public Vector2 Size => new(Width, Height); + + public int TimeSinceLastAccessed; + + public delegate RenderTarget2D RenderTargetCreationCondition(int screenWidth, int screenHeight); + + [Obsolete("use ScreenspaceTargetPool")] + public static RenderTarget2D CreateScreenSizedTarget(int screenWidth, int screenHeight) => new(Main.instance.GraphicsDevice, screenWidth, screenHeight); + + public ManagedRenderTarget(bool shouldResetUponScreenResize, RenderTargetCreationCondition creationCondition, bool shouldAutoDispose = true) + { + ShouldResetUponScreenResize = shouldResetUponScreenResize; + CreationCondition = creationCondition; + ShouldAutoDispose = shouldAutoDispose; + lease = ManagedRenderTargetPool.Shared.Register(this); + } + + /// + /// Sets the current render target to the provided one. + /// + /// The render target to swap to + /// The color to clear the screen with. Transparent by default + [Obsolete("Use RenderTargetScope")] + public void SwapTo(Color? flushColor = null) => Target.SwapTo(flushColor); + + public void Dispose() + { + Dispose(preserveCollection: false); + } + + public void Dispose(bool preserveCollection) + { + if (IsDisposed) + return; + + IsDisposed = true; + ManagedRenderTargetPool.Shared.Return(this, preserveCollection); + } + + // Does nothing + public void Recreate(int screenWidth, int screenHeight) { } + + public static implicit operator RenderTarget2D(ManagedRenderTarget target) => target.Target; +} diff --git a/Graphics/Metaballs/BigRipLayer.png b/Graphics/Metaballs/BigRipLayer.png new file mode 100644 index 0000000000..e1750b1a28 Binary files /dev/null and b/Graphics/Metaballs/BigRipLayer.png differ diff --git a/Graphics/Metaballs/BigRipMetaball.cs b/Graphics/Metaballs/BigRipMetaball.cs new file mode 100644 index 0000000000..9235e5aa26 --- /dev/null +++ b/Graphics/Metaballs/BigRipMetaball.cs @@ -0,0 +1,124 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class BigRipMetaball : Metaball + { + public class Particle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public Texture2D TextureToUse = null; + + public float rotation = 0; + + public Vector2 Scale = Vector2.One; + + public float SizeScaling = 0.85f; + public int CurrentFrame = 0; + public int MaxFrames = 1; + + public int ShrinkDelay = 15; + public int TimeAlive = 0; + public Particle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + TimeAlive++; + Center += Velocity; + Velocity *= 0.96f; + if (ShrinkDelay < TimeAlive || (TimeAlive > 1 && SizeScaling <= 0)) + Scale.X *= SizeScaling; + } + } + + public override bool FixedToScreen => true; + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + public static Asset LayerAsset + { + get; + private set; + } + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/BigRipLayer", AssetRequestMode.ImmediateLoad); + } + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => new Color(239, 111, 85) * 0.5f; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Scale.X <= 0.05f); + } + + public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + Particle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.Zero; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (Particle particle in Particles) + { + var texture2d = particle.TextureToUse ?? tex; + Vector2 drawPosition = particle.Center - Main.screenPosition; + var modScale = particle.Scale; + if (particle.TimeAlive < 5) + modScale.X *= 0.25f + 0.75f * particle.TimeAlive / 5f; + Vector2 scale = modScale * particle.Size / texture2d.Height; + var frame = texture2d.Frame(1, particle.MaxFrames, 0, particle.CurrentFrame); + Vector2 origin = frame.Size() * 0.5f; + Main.spriteBatch.Draw(texture2d, drawPosition, frame, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/BloodBoilerMetaball.cs b/Graphics/Metaballs/BloodBoilerMetaball.cs index 86bf43c440..42fce30903 100644 --- a/Graphics/Metaballs/BloodBoilerMetaball.cs +++ b/Graphics/Metaballs/BloodBoilerMetaball.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -48,7 +49,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override Color EdgeColor => Color.Red with { A = 0 }; @@ -72,12 +73,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/BloodBoilerMetaball2.cs b/Graphics/Metaballs/BloodBoilerMetaball2.cs index a6034d5219..2786575f77 100644 --- a/Graphics/Metaballs/BloodBoilerMetaball2.cs +++ b/Graphics/Metaballs/BloodBoilerMetaball2.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -48,7 +49,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override Color EdgeColor => Color.Red with { A = 0 }; @@ -72,12 +73,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/BloodLayer.png b/Graphics/Metaballs/BloodLayer.png new file mode 100644 index 0000000000..ca6a3fdfb8 Binary files /dev/null and b/Graphics/Metaballs/BloodLayer.png differ diff --git a/Graphics/Metaballs/BloodMetaball.cs b/Graphics/Metaballs/BloodMetaball.cs new file mode 100644 index 0000000000..24eb5e6452 --- /dev/null +++ b/Graphics/Metaballs/BloodMetaball.cs @@ -0,0 +1,124 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class BloodMetaball : Metaball + { + public class Particle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public Texture2D TextureToUse = null; + + public float rotation = 0; + + public Vector2 Scale = Vector2.One; + + public float SizeScaling = 0.85f; + public int CurrentFrame = 0; + public int MaxFrames = 1; + + public int ShrinkDelay = 45; + public int TimeAlive = 0; + public Particle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + TimeAlive++; + Center += Velocity; + Velocity *= 0.96f; + if (ShrinkDelay < TimeAlive) + Size *= SizeScaling; + } + } + + //public override bool IgnoreFPS => true; + + public override bool FixedToScreen => false; + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + public static Asset LayerAsset + { + get; + private set; + } + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/BloodLayer", AssetRequestMode.ImmediateLoad); + } + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => new Color(67, 17, 17); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + Particle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.0005f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (Particle particle in Particles) + { + var texture2d = particle.TextureToUse ?? tex; + Vector2 drawPosition = particle.Center - Main.screenPosition; + var modScale = particle.Scale; + Vector2 scale = modScale * particle.Size / texture2d.Width; + var frame = texture2d.Frame(1, particle.MaxFrames, 0, particle.CurrentFrame); + Vector2 origin = frame.Size() * 0.5f; + Main.spriteBatch.Draw(texture2d, drawPosition, frame, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/CalamitasLayer.png b/Graphics/Metaballs/CalamitasLayer.png new file mode 100644 index 0000000000..0400de2758 Binary files /dev/null and b/Graphics/Metaballs/CalamitasLayer.png differ diff --git a/Graphics/Metaballs/CalamitasMetaball.cs b/Graphics/Metaballs/CalamitasMetaball.cs new file mode 100644 index 0000000000..85b9a64b5c --- /dev/null +++ b/Graphics/Metaballs/CalamitasMetaball.cs @@ -0,0 +1,117 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class CalamitasMetaball : Metaball + { + public class Particle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public Texture2D TextureToUse = null; + + public float rotation = 0; + + public float SizeScaling = 0.85f; + + public Vector2 Scale = Vector2.One; + bool firstFrame = true; + + public Particle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Center += Velocity; + Velocity *= 0.96f; + if (firstFrame) + firstFrame = false; + else + Size *= SizeScaling; + } + } + public override bool IgnoreFPS => true; + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + public static Asset LayerAsset + { + get; + private set; + } + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/CalamitasLayer", AssetRequestMode.ImmediateLoad); + } + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => Color.Lerp(Color.Crimson, Color.Black, 0f); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + Particle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (Particle particle in Particles) + { + var texture2d = particle.TextureToUse ?? tex; + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = texture2d.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / texture2d.Width; + Main.spriteBatch.Draw(texture2d, drawPosition, null, Color.White, particle.rotation, origin, particle.Scale*scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/CataclysmLayer.png b/Graphics/Metaballs/CataclysmLayer.png new file mode 100644 index 0000000000..5b6abec04d Binary files /dev/null and b/Graphics/Metaballs/CataclysmLayer.png differ diff --git a/Graphics/Metaballs/CataclysmMetaball.cs b/Graphics/Metaballs/CataclysmMetaball.cs new file mode 100644 index 0000000000..59221f3d51 --- /dev/null +++ b/Graphics/Metaballs/CataclysmMetaball.cs @@ -0,0 +1,115 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class CataclysmMetaball : Metaball + { + public class Particle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public Texture2D TextureToUse = null; + + public float rotation = 0; + + public float SizeScaling = 0.85f; + bool firstFrame = true; + + public Particle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Center += Velocity; + Velocity *= 0.96f; + if (firstFrame) + firstFrame = false; + else + Size *= SizeScaling; + } + } + public override bool IgnoreFPS => true; + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + public static Asset LayerAsset + { + get; + private set; + } + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/CataclysmLayer", AssetRequestMode.ImmediateLoad); + } + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => new Color(255,0,229); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + Particle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (Particle particle in Particles) + { + var texture2d = particle.TextureToUse ?? tex; + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = texture2d.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / texture2d.Width; + Main.spriteBatch.Draw(texture2d, drawPosition, null, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/CatastropheLayer.png b/Graphics/Metaballs/CatastropheLayer.png new file mode 100644 index 0000000000..92633afc57 Binary files /dev/null and b/Graphics/Metaballs/CatastropheLayer.png differ diff --git a/Graphics/Metaballs/CatastropheMetaball.cs b/Graphics/Metaballs/CatastropheMetaball.cs new file mode 100644 index 0000000000..399af76ad4 --- /dev/null +++ b/Graphics/Metaballs/CatastropheMetaball.cs @@ -0,0 +1,117 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class CatastropheMetaball : Metaball + { + public class Particle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public Texture2D TextureToUse = null; + + public float rotation = 0; + + public float SizeScaling = 0.85f; + bool firstFrame = true; + + public Particle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + if (firstFrame) + { + firstFrame = false; + return; + } + Center += Velocity; + Velocity *= 0.96f; + Size *= SizeScaling; + } + } + public override bool IgnoreFPS => true; + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + public static Asset LayerAsset + { + get; + private set; + } + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/CatastropheLayer", AssetRequestMode.ImmediateLoad); + } + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => new Color(0,255,255); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + Particle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (Particle particle in Particles) + { + var texture2d = particle.TextureToUse ?? tex; + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = texture2d.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / texture2d.Width; + Main.spriteBatch.Draw(texture2d, drawPosition, null, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/DoGDistortionMetaball.cs b/Graphics/Metaballs/DoGDistortionMetaball.cs new file mode 100644 index 0000000000..0c23deb9ae --- /dev/null +++ b/Graphics/Metaballs/DoGDistortionMetaball.cs @@ -0,0 +1,107 @@ +using System.Collections.Generic; +using CalamityMod.Effects; +using CalamityMod.Enums; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Systems.Graphic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class DoGDistortionMetaball : Metaball + { + public class DistortionParticle(Vector2 center, Vector2 velocity, float size, bool square = false, float rotation = 0f) + { + public Vector2 Center = center; + + public Vector2 Velocity = velocity; + + public float Size = size; + + public bool Square = square; + + public float Rotation = rotation; + + public void Update() + { + Center += Velocity; + Velocity *= 0.96f; + Size *= 0.91f; + } + } + + public static List Particles { get; private set; } = []; + + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; + + public override bool AnythingToDraw => Particles.Count > 0 || CalamityUtils.AnyProjectiles(ModContent.ProjectileType()); + + public override Color EdgeColor => new(136, 26, 186); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size, bool square = false, float rotation = 0f) => + Particles.Add(new(position, velocity, size, square, rotation)); + + public override void Update() + { + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public override void PrepareShaderForTarget(int layerIndex) + { + var metaballShader = CalamityShaders.MetaballEdgeShader; + var gd = Main.instance.GraphicsDevice; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 layerScrollOffset = Main.screenPosition / screenSize + CalculateManualOffsetForLayer(layerIndex); + if (FixedToScreen) + layerScrollOffset = Vector2.Zero; + + metaballShader.Value.Parameters["layerSize"]?.SetValue(DoGVisualsManager.DistortionForegroundContentsTarget.Target.Size()); + metaballShader.Value.Parameters["screenSize"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(layerScrollOffset); + metaballShader.Value.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4()); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize); + + gd.Textures[1] = DoGVisualsManager.DistortionForegroundContentsTarget.Target; + gd.SamplerStates[1] = SamplerState.LinearWrap; + + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); + } + + public override void DrawInstances() + { + Texture2D metaballTexture = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + Texture2D squareTexture = ModContent.Request("CalamityMod/Particles/Square").Value; + + foreach (DistortionParticle particle in Particles) + { + Texture2D textureToUse = particle.Square ? squareTexture : metaballTexture; + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = textureToUse.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / textureToUse.Size(); + Main.spriteBatch.Draw(textureToUse, drawPosition, null, Color.White, particle.Rotation, origin, scale, SpriteEffects.None, 0f); + } + + foreach (Projectile proj in Main.ActiveProjectiles) + { + if (proj.type == ModContent.ProjectileType()) + { + Color lightColor = Color.White; + proj.ModProjectile.PreDraw(ref lightColor); + } + } + } + } +} diff --git a/Graphics/Metaballs/DragonsBreathMetaball.cs b/Graphics/Metaballs/DragonsBreathMetaball.cs index e041506bb2..f134656a39 100644 --- a/Graphics/Metaballs/DragonsBreathMetaball.cs +++ b/Graphics/Metaballs/DragonsBreathMetaball.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -68,7 +69,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override void Update() { @@ -90,12 +91,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/DragonsBreathMetaball2.cs b/Graphics/Metaballs/DragonsBreathMetaball2.cs index c07f13e894..bd18795fa2 100644 --- a/Graphics/Metaballs/DragonsBreathMetaball2.cs +++ b/Graphics/Metaballs/DragonsBreathMetaball2.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -68,7 +69,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override void Update() { @@ -90,12 +91,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/GalaxyMetaball.cs b/Graphics/Metaballs/GalaxyMetaball.cs index 4d93ed1020..3d7643888f 100644 --- a/Graphics/Metaballs/GalaxyMetaball.cs +++ b/Graphics/Metaballs/GalaxyMetaball.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs @@ -56,7 +56,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeNPCs; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeNPCs; public override Color EdgeColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f); diff --git a/Graphics/Metaballs/GruesomeMetaball.cs b/Graphics/Metaballs/GruesomeMetaball.cs index 0c281d7e5f..4c2a76fb60 100644 --- a/Graphics/Metaballs/GruesomeMetaball.cs +++ b/Graphics/Metaballs/GruesomeMetaball.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs @@ -56,7 +56,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override Color EdgeColor => new(61, 6, 2); diff --git a/Graphics/Metaballs/Metaball.cs b/Graphics/Metaballs/Metaball.cs index be9d5556bf..eec99c5832 100644 --- a/Graphics/Metaballs/Metaball.cs +++ b/Graphics/Metaballs/Metaball.cs @@ -1,17 +1,18 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; +using CalamityMod.Enums; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs { public abstract class Metaball : ModType { - internal List LayerTargets = new(); + internal List LayerTargets = new(); /// /// Required utility that is used to determine whether this metaball has anything to draw.

@@ -33,7 +34,7 @@ namespace CalamityMod.Graphics.Metaballs /// /// The draw layer in which metaballs should be drawn. /// - public abstract MetaballDrawLayer DrawContext + public abstract GeneralDrawLayer DrawLayer { get; } @@ -46,6 +47,16 @@ namespace CalamityMod.Graphics.Metaballs get; } + /// + /// Colors for the layers to draw with. Defaults to white when unset. + /// + public virtual List LayerColors { get; set; } = []; + + /// + /// Whether the metaball runs Update based on the draw cycle or the game update cycle + /// + public virtual bool IgnoreFPS => false; + /// /// Whether the layer overlay contents from should be fixed to the screen.

/// When true, the texture will be statically drawn to the screen with no respect for world position. @@ -96,18 +107,19 @@ namespace CalamityMod.Graphics.Metaballs layerScrollOffset = Vector2.Zero; // Supply shader parameter values. - metaballShader.Parameters["layerSize"]?.SetValue(layerTexture.Size()); - metaballShader.Parameters["screenSize"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(layerScrollOffset); - metaballShader.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4()); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize); + metaballShader.Value.Parameters["layerSize"]?.SetValue(layerTexture.Size()); + metaballShader.Value.Parameters["screenSize"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(layerScrollOffset); + metaballShader.Value.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4()); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize); + metaballShader.Value.Parameters["layerColor"]?.SetValue(LayerColors.Count() > layerIndex ? LayerColors[layerIndex] : Color.White.ToVector4()); // Supply the metaball's layer texture to the graphics device so that the shader can read it. gd.Textures[1] = layerTexture; gd.SamplerStates[1] = SamplerState.LinearWrap; // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } /// @@ -134,7 +146,7 @@ namespace CalamityMod.Graphics.Metaballs // Load render targets. int layerCount = Layers.Count(); for (int i = 0; i < layerCount; i++) - LayerTargets.Add(new(true, ManagedRenderTarget.CreateScreenSizedTarget)); + LayerTargets.Add(ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (width, height) => (width + 4, height + 4))); }); } diff --git a/Graphics/Metaballs/MetaballDrawLayer.cs b/Graphics/Metaballs/MetaballDrawLayer.cs deleted file mode 100644 index d061aabe61..0000000000 --- a/Graphics/Metaballs/MetaballDrawLayer.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CalamityMod.Graphics.Metaballs -{ - public enum MetaballDrawLayer - { - BeforeNPCs, - BeforeProjectiles, - AfterProjectiles, - } -} diff --git a/Graphics/Metaballs/MetaballManager.cs b/Graphics/Metaballs/MetaballManager.cs index 832785925e..95be12e03f 100644 --- a/Graphics/Metaballs/MetaballManager.cs +++ b/Graphics/Metaballs/MetaballManager.cs @@ -1,5 +1,8 @@ using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,12 +14,11 @@ namespace CalamityMod.Graphics.Metaballs { internal static readonly List metaballs = new(); - public override void OnModLoad() + public override void Load() { // Prepare event subscribers. - RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareMetaballTargets; - On_Main.DrawProjectiles += DrawMetaballsAfterProjectiles; - On_Main.DrawNPCs += DrawMetaballsBeforeNPCs; + GeneralDrawLayerSystem.OnPrepareDraw += PrepareMetaballTargets; + GeneralDrawLayerSystem.OnDrawLayer += DrawMetaballs; } public override void OnModUnload() @@ -35,6 +37,17 @@ namespace CalamityMod.Graphics.Metaballs metaball.ClearInstances(); } + public override void PostUpdateEverything() + { + + var activeMetaballs = metaballs.Where(m => m.AnythingToDraw); + foreach (Metaball metaball in activeMetaballs) + { + if (metaball.IgnoreFPS) + metaball.Update(); + } + } + private void PrepareMetaballTargets() { // Get a list of all metaballs currently in use. @@ -45,91 +58,74 @@ namespace CalamityMod.Graphics.Metaballs return; // Prepare the sprite batch for drawing. Metaballs may restart the sprite batch via PrepareSpriteBatch if their implementation requires it. - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); var gd = Main.instance.GraphicsDevice; foreach (Metaball metaball in activeMetaballs) { // Update the metaball collection. - if (!Main.gamePaused) + if (!Main.gamePaused && !metaball.IgnoreFPS) metaball.Update(); // Prepare the sprite batch in accordance to the needs of the metaball instance. By default this does nothing, metaball.PrepareSpriteBatch(Main.spriteBatch); // Draw the raw contents of the metaball to each of its render targets. - foreach (ManagedRenderTarget target in metaball.LayerTargets) + foreach (var target in metaball.LayerTargets) { - gd.SetRenderTarget(target); - gd.Clear(Color.Transparent); - metaball.DrawInstances(); + using (target.Scope(clearColor: Color.Transparent)) + { + // -2,-2 is to account for the border appplying at screen edge. We need this to draw off-screen. + // We directly adjust screen position so that drawing in the metaball functions works as expected + var offset = new Vector2(-2, -2); + Main.screenPosition += offset; + metaball.DrawInstances(); + Main.screenPosition -= offset; - // Flush metaball contents to its render target and reset the sprite batch for the next iteration. - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + // Flush metaball contents to its render target and reset the sprite batch for the next iteration. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); + } } } - // Return to the backbuffer and end the sprite batch. - gd.SetRenderTarget(null); Main.spriteBatch.End(); } - private void DrawMetaballsAfterProjectiles(On_Main.orig_DrawProjectiles orig, Main self) - { - if (AnyActiveMetaballsAtLayer(MetaballDrawLayer.BeforeProjectiles)) - { - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - DrawMetaballs(MetaballDrawLayer.BeforeProjectiles); - Main.spriteBatch.End(); - } - - orig(self); - - if (AnyActiveMetaballsAtLayer(MetaballDrawLayer.AfterProjectiles)) - { - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - DrawMetaballs(MetaballDrawLayer.AfterProjectiles); - Main.spriteBatch.End(); - } - } - - private void DrawMetaballsBeforeNPCs(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) - { - if (!behindTiles && AnyActiveMetaballsAtLayer(MetaballDrawLayer.BeforeNPCs)) - { - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - DrawMetaballs(MetaballDrawLayer.BeforeNPCs); - Main.spriteBatch.ExitShaderRegion(); - } - orig(self, behindTiles); - } - /// /// Checks if a metaball of a given layering type is currently in use. This is used to minimize needless restarts when there is nothing to draw. /// /// The metaball layer type to check against. - internal static bool AnyActiveMetaballsAtLayer(MetaballDrawLayer layerType) => - metaballs.Any(m => m.AnythingToDraw && m.DrawContext == layerType); + internal static bool AnyActiveMetaballsAtLayer(GeneralDrawLayer layerType) => + metaballs.Any(m => m.AnythingToDraw && m.DrawLayer == layerType); /// - /// Draws all metaballs of a given . Used for layer ordering reasons. + /// Draws all metaballs of a given . Used for layer ordering reasons. /// /// The layer type to draw with. - public static void DrawMetaballs(MetaballDrawLayer layerType) + private static void DrawMetaballs(GeneralDrawLayer layerType) { - foreach (Metaball metaball in metaballs.Where(m => m.DrawContext == layerType && m.AnythingToDraw)) + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise); + + foreach (Metaball metaball in metaballs.Where(m => m.DrawLayer == layerType && m.AnythingToDraw)) { for (int i = 0; i < metaball.LayerTargets.Count; i++) { + // -2,-2 is to account for the border appplying at screen edge. We need this to draw off-screen. + // We directly adjust screen position so that drawing in the metaball functions works as expected + var offset = new Vector2(-2, -2); + Main.screenPosition += offset; // Prepare shaders for the given layer target. metaball.PrepareShaderForTarget(i); + Main.screenPosition -= offset; // Draw the metaball's raw contents with the shader. - Main.spriteBatch.Draw(metaball.LayerTargets[i], Main.screenLastPosition - Main.screenPosition, Color.White); + Main.spriteBatch.Draw(metaball.LayerTargets[i].Target, offset, Color.White); + } } + + Main.spriteBatch.End(); } } } diff --git a/Graphics/Metaballs/PaintMetaballs.cs b/Graphics/Metaballs/PaintMetaballs.cs index 0501af90ff..704fd06e90 100644 --- a/Graphics/Metaballs/PaintMetaballs.cs +++ b/Graphics/Metaballs/PaintMetaballs.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -64,7 +65,7 @@ namespace CalamityMod.Graphics.Metaballs public override bool AnythingToDraw => Particles.Any(); - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override IEnumerable Layers { @@ -86,12 +87,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public void SpawnParticle(Vector2 position, float size) => @@ -110,7 +111,7 @@ namespace CalamityMod.Graphics.Metaballs { // Draw with additive blending. Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); } public override void DrawInstances() diff --git a/Graphics/Metaballs/PhotoMetaball.cs b/Graphics/Metaballs/PhotoMetaball.cs index 6d3447dd90..d831e44c4b 100644 --- a/Graphics/Metaballs/PhotoMetaball.cs +++ b/Graphics/Metaballs/PhotoMetaball.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; -using CalamityMod.Rarities; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -54,7 +54,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public Color sparkColor; public int Time = 0; @@ -91,12 +91,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/PhotoMetaball2.cs b/Graphics/Metaballs/PhotoMetaball2.cs index f1cdc7737f..59b2c81aa8 100644 --- a/Graphics/Metaballs/PhotoMetaball2.cs +++ b/Graphics/Metaballs/PhotoMetaball2.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; -using CalamityMod.Rarities; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -54,7 +54,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public Color sparkColor; public int Time; @@ -92,12 +92,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/PhotoMetaball3.cs b/Graphics/Metaballs/PhotoMetaball3.cs index cfb21ea60d..e5ff5c9194 100644 --- a/Graphics/Metaballs/PhotoMetaball3.cs +++ b/Graphics/Metaballs/PhotoMetaball3.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; -using CalamityMod.Rarities; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -47,7 +47,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public Color sparkColor; public int Time = 0; @@ -87,12 +87,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/PhotoMetaball4.cs b/Graphics/Metaballs/PhotoMetaball4.cs index 2df1a25d8b..e9c5adc160 100644 --- a/Graphics/Metaballs/PhotoMetaball4.cs +++ b/Graphics/Metaballs/PhotoMetaball4.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; -using CalamityMod.Rarities; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -47,7 +47,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public Color sparkColor; public int Time; @@ -86,12 +86,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); diff --git a/Graphics/Metaballs/RancorLavaMetaball.cs b/Graphics/Metaballs/RancorLavaMetaball.cs index ef0d3c6124..54e2bb51ea 100644 --- a/Graphics/Metaballs/RancorLavaMetaball.cs +++ b/Graphics/Metaballs/RancorLavaMetaball.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Effects; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -44,7 +45,7 @@ namespace CalamityMod.Graphics.Metaballs public override bool AnythingToDraw => Particles.Any(); - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override IEnumerable Layers { @@ -68,12 +69,12 @@ namespace CalamityMod.Graphics.Metaballs Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); // Supply shader parameter values. - metaballShader.Parameters["screenArea"]?.SetValue(screenSize); - metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); - metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); // Apply the metaball shader. - metaballShader.CurrentTechnique.Passes[0].Apply(); + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); } public static void SpawnParticle(Vector2 position, float size) => @@ -92,7 +93,7 @@ namespace CalamityMod.Graphics.Metaballs { // Draw with additive blending. Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Main.Transform); } public override void DrawInstances() diff --git a/Graphics/Metaballs/ScalArenaLayerSmoke.png b/Graphics/Metaballs/ScalArenaLayerSmoke.png new file mode 100644 index 0000000000..6aabbaea1f Binary files /dev/null and b/Graphics/Metaballs/ScalArenaLayerSmoke.png differ diff --git a/Graphics/Metaballs/ScalArenaLayerWave.png b/Graphics/Metaballs/ScalArenaLayerWave.png new file mode 100644 index 0000000000..3b7204c2d7 Binary files /dev/null and b/Graphics/Metaballs/ScalArenaLayerWave.png differ diff --git a/Graphics/Metaballs/ScalArenaMetaball.cs b/Graphics/Metaballs/ScalArenaMetaball.cs new file mode 100644 index 0000000000..c7a1039e74 --- /dev/null +++ b/Graphics/Metaballs/ScalArenaMetaball.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using CalamityMod.NPCs.SupremeCalamitas; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class ScalArenaMetaball : Metaball + { + public class Particle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public Texture2D TextureToUse = null; + + public float rotation = 0; + + public float SizeScaling = 0.85f; + public int CurrentFrame = 0; + public int MaxFrames = 1; + public Vector2 Scale = Vector2.One; + public int Age = 0; + public Particle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Age++; + Center += Velocity; + Velocity *= 0.96f; + if (Age > 1) + Size *= SizeScaling; + } + } + + public override bool IgnoreFPS => true; + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + private static Asset MainLayer; + private static Texture2D WavyLineLayer; //Not wrapped in Asset<> as we need to edit the texutre post-loading. + public override IEnumerable Layers + { + get + { + yield return MainLayer.Value; + yield return WavyLineLayer; + } + } + + public override List LayerColors => [Color.White.ToVector4(), EdgeColor.ToVector4()]; + public override void Load() + { + if (Main.dedServ) + return; + + MainLayer = ModContent.Request($"CalamityMod/Graphics/Metaballs/ScalArenaLayerSmoke", AssetRequestMode.ImmediateLoad); + WavyLineLayer = ModContent.Request($"CalamityMod/Graphics/Metaballs/ScalArenaLayerWave", AssetRequestMode.ImmediateLoad).Value; + + } + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeNPCs; + + public override Color EdgeColor => SupremeCalamitas.CurrentColor; + + public override void Update() + { + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f && p.Age > 1); + } + + public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + Particle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + switch (layerIndex) + { + case 0: + return new Vector2(MathF.Sin(Main.GlobalTimeWrappedHourly*0.03f)*10,MathF.Cos(Main.GlobalTimeWrappedHourly* 0.1f) * 17); + case 1: + return Vector2.UnitY * Main.GlobalTimeWrappedHourly * 0.03f; + } + return Vector2.Zero; + } + + bool hasRunTextureCorrection = false; + public override void PrepareSpriteBatch(SpriteBatch spriteBatch) + { + //This only runs once per game session. I put it here as load-related functions use multithreading and therefore don't support drawing functions used here. + //This converts the layer texture into a transparent version, as-if it was additive. Since it's all greyscale, we can just use the red channel from the original in the calculations. + if (!hasRunTextureCorrection) + { + var BaseArray = new Color[WavyLineLayer.Width * WavyLineLayer.Height]; + var ColorArray = new Color[WavyLineLayer.Width * WavyLineLayer.Height]; + WavyLineLayer.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color((int)BaseArray[i].R, (int)BaseArray[i].R, (int)BaseArray[i].R, (int)BaseArray[i].R); + } + WavyLineLayer.SetData(ColorArray); + hasRunTextureCorrection = true; + } + base.PrepareSpriteBatch(spriteBatch); + } + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (Particle particle in Particles) + { + var texture2d = particle.TextureToUse ?? tex; + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 scale = particle.Scale * particle.Size / texture2d.Width; + var frame = texture2d.Frame(1, particle.MaxFrames, 0, particle.CurrentFrame); + Vector2 origin = frame.Size() * 0.5f; + Main.spriteBatch.Draw(texture2d, drawPosition, frame, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/SeekersLayer.png b/Graphics/Metaballs/SeekersLayer.png new file mode 100644 index 0000000000..f50fbe061b Binary files /dev/null and b/Graphics/Metaballs/SeekersLayer.png differ diff --git a/Graphics/Metaballs/SeekersMetaball.cs b/Graphics/Metaballs/SeekersMetaball.cs new file mode 100644 index 0000000000..a0658bb66d --- /dev/null +++ b/Graphics/Metaballs/SeekersMetaball.cs @@ -0,0 +1,118 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class SeekersMetaball : Metaball + { + public class Particle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public Texture2D TextureToUse = null; + + public float rotation = 0; + + public float SizeScaling = 0.85f; + bool firstFrame = true; + public int CurrentFrame = 0; + public int MaxFrames = 1; + public Particle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Center += Velocity; + Velocity *= 0.96f; + if (firstFrame) + firstFrame = false; + else + Size *= SizeScaling; + } + } + + public override bool IgnoreFPS => true; + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + public static Asset LayerAsset + { + get; + private set; + } + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/SeekersLayer", AssetRequestMode.ImmediateLoad); + } + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => new Color(255,106,0); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + Particle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (Particle particle in Particles) + { + var texture2d = particle.TextureToUse ?? tex; + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 scale = Vector2.One * particle.Size / texture2d.Width; + var frame = texture2d.Frame(1, particle.MaxFrames, 0, particle.CurrentFrame); + Vector2 origin = frame.Size() * 0.5f; + Main.spriteBatch.Draw(texture2d, drawPosition, frame, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/SignusLayer.png b/Graphics/Metaballs/SignusLayer.png new file mode 100644 index 0000000000..d28069a497 Binary files /dev/null and b/Graphics/Metaballs/SignusLayer.png differ diff --git a/Graphics/Metaballs/SignusMetaball.cs b/Graphics/Metaballs/SignusMetaball.cs new file mode 100644 index 0000000000..c0179a8ebc --- /dev/null +++ b/Graphics/Metaballs/SignusMetaball.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class SignusMetaball : Metaball + { + public Color borderColor = Color.Purple; + public Vector2 goalDir = Vector2.Zero; + public Vector2 scrollDir = Vector2.Zero; + public class CosmicParticle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + public Vector2 BaseSquash = Vector2.One; + public float Rotation; + public float ShrinkSpeed = 0; + public int Lifetime; + public float SquashPower = 0; + public int time = 0; + + public CosmicParticle(Vector2 center, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0) + { + Center = center; + Velocity = velocity; + Size = size; + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + BaseSquash = squash; + Lifetime = lifetime; + ShrinkSpeed = shrinkSpeed; + SquashPower = velocitySquash; + } + + public void Update() + { + Center += Velocity; + Velocity *= 0.95f; + if ((float)time / (float)Lifetime > 0.5f) + { + Size *= 0.94f; + } + BaseSquash.X *= (1 - 0.2f * ShrinkSpeed); + BaseSquash.Y *= (1 + 0.2f * ShrinkSpeed); + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + time++; + } + } + public static Asset LayerAsset + { + get; + private set; + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeNPCs; + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/SignusLayer", AssetRequestMode.ImmediateLoad); + } + + public override void Update() + { + if (goalDir == Vector2.Zero) + goalDir = Vector2.One.RotatedByRandom(Math.PI); + if ((int)(Main.GlobalTimeWrappedHourly * 50) % 5 == 0) + { + goalDir = goalDir.RotatedByRandom(0.13f); + } + scrollDir = Vector2.Lerp(scrollDir, goalDir, 0.01f); + + float rate = Main.GlobalTimeWrappedHourly * 19; + List colors = new List() + { + Color.Purple, + Color.BlueViolet, + Color.DarkViolet + }; + + int colorIndex = (int)(rate / 2 % colors.Count); + Color currentColor = colors[colorIndex]; + Color nextColor = colors[(colorIndex + 1) % colors.Count]; + borderColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + public override Color EdgeColor => borderColor with { A = 0 }; + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0) => + Particles.Add(new(position, velocity, size, lifetime, squash, shrinkSpeed, velocitySquash)); + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return scrollDir * 0.5f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicMess").Value; + + foreach (CosmicParticle particle in Particles) + { + Vector2 squash = Vector2.Lerp(particle.BaseSquash, new Vector2(Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 2.5f)), particle.SquashPower); + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, particle.Rotation, origin, squash * scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/StarsmokeBlueLayer.png b/Graphics/Metaballs/StarsmokeBlueLayer.png new file mode 100644 index 0000000000..77691f5acd Binary files /dev/null and b/Graphics/Metaballs/StarsmokeBlueLayer.png differ diff --git a/Graphics/Metaballs/StarsmokeLayer.png b/Graphics/Metaballs/StarsmokeLayer.png new file mode 100644 index 0000000000..8b14723cbc Binary files /dev/null and b/Graphics/Metaballs/StarsmokeLayer.png differ diff --git a/Graphics/Metaballs/StarsmokeMetaball.cs b/Graphics/Metaballs/StarsmokeMetaball.cs new file mode 100644 index 0000000000..3bdfa5e22d --- /dev/null +++ b/Graphics/Metaballs/StarsmokeMetaball.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class StarsmokeMetaball : Metaball + { + public Color borderColor = Color.Purple; + public Vector2 goalDir = Vector2.Zero; + public Vector2 scrollDir = Vector2.Zero; + public class StarsmokeParticle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + public Vector2 BaseSquash = Vector2.One; + public float Rotation; + public float ShrinkSpeed = 0; + public int Lifetime; + public float SquashPower = 0; + public int time = 0; + + public StarsmokeParticle(Vector2 center, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0) + { + Center = center; + Velocity = velocity; + Size = size; + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + BaseSquash = squash; + Lifetime = lifetime; + ShrinkSpeed = shrinkSpeed; + SquashPower = velocitySquash; + } + + public void Update() + { + float sine = (float)Math.Sin(time * 0.15f * SquashPower) * 0.8f; + Center += Velocity; + Velocity *= 0.96f; + Velocity += Velocity.RotatedBy(0.36f * sine * SquashPower * (Math.Sign(ShrinkSpeed))) * 0.02f; + if ((float)time / (float)Lifetime > 0.8f) + { + Size *= 0.9f; + } + BaseSquash.X *= (1 - 0.2f * ShrinkSpeed); + BaseSquash.Y *= (1 + 0.2f * ShrinkSpeed); + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + time++; + } + } + public static Asset LayerAsset + { + get; + private set; + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeNPCs; + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Particles/GlowSquareParticleBig", AssetRequestMode.ImmediateLoad); + } + + public override void Update() + { + if (goalDir == Vector2.Zero) + goalDir = Vector2.One.RotatedByRandom(Math.PI); + if ((int)(Main.GlobalTimeWrappedHourly * 50) % 5 == 0) + { + goalDir = goalDir.RotatedByRandom(0.13f); + } + scrollDir = Vector2.Lerp(scrollDir, goalDir, 0.01f); + + float rate = Main.GlobalTimeWrappedHourly * 19; + List colors = new List() + { + new Color (192, 10, 111), + Color.Coral, + Color.DarkOrange + }; + + int colorIndex = (int)(rate / 2 % colors.Count); + Color currentColor = colors[colorIndex]; + Color nextColor = colors[(colorIndex + 1) % colors.Count]; + borderColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + public override Color EdgeColor => borderColor with { A = 0 } * 0.3f; + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0) => + Particles.Add(new(position, velocity, size, lifetime, squash, shrinkSpeed, velocitySquash)); + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return scrollDir * 0.5f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/StarsmokeMetaball2").Value; + + foreach (StarsmokeParticle particle in Particles) + { + float sine = (float)Math.Sin(particle.time * 0.2f) * 0.5f; + float lifetimeVal = 1 - (particle.time / particle.Lifetime); + Vector2 altSquash = new Vector2(1f + 1 * (1 + sine) * lifetimeVal, 1f + 1 * (1 - sine) * lifetimeVal); + Vector2 squash = Vector2.Lerp(particle.BaseSquash, new Vector2(Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 2.5f)), particle.SquashPower); + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, particle.Rotation, origin, squash * scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/StarsmokeMetaball1.png b/Graphics/Metaballs/StarsmokeMetaball1.png new file mode 100644 index 0000000000..522a9295d6 Binary files /dev/null and b/Graphics/Metaballs/StarsmokeMetaball1.png differ diff --git a/Graphics/Metaballs/StarsmokeMetaball2.png b/Graphics/Metaballs/StarsmokeMetaball2.png new file mode 100644 index 0000000000..ed5443bca0 Binary files /dev/null and b/Graphics/Metaballs/StarsmokeMetaball2.png differ diff --git a/Graphics/Metaballs/StreamGougeMetaball.cs b/Graphics/Metaballs/StreamGougeMetaball.cs index 0f31626192..d13ebc9af9 100644 --- a/Graphics/Metaballs/StreamGougeMetaball.cs +++ b/Graphics/Metaballs/StreamGougeMetaball.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs @@ -56,7 +56,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.AfterProjectiles; public override Color EdgeColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f); diff --git a/Graphics/Metaballs/VoidGeneratorMetaball.cs b/Graphics/Metaballs/VoidGeneratorMetaball.cs index 69029411f3..a21754f651 100644 --- a/Graphics/Metaballs/VoidGeneratorMetaball.cs +++ b/Graphics/Metaballs/VoidGeneratorMetaball.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -26,7 +27,7 @@ namespace CalamityMod.Graphics.Metaballs } } - public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; public override Color EdgeColor => Color.Lerp(Color.Purple, Color.Black, 0.75f); diff --git a/Graphics/Primitives/IPixelatedPrimitiveRenderer.cs b/Graphics/Primitives/IPixelatedPrimitiveRenderer.cs index 7270d3e93a..f40c983f56 100644 --- a/Graphics/Primitives/IPixelatedPrimitiveRenderer.cs +++ b/Graphics/Primitives/IPixelatedPrimitiveRenderer.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Enums; +using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Graphics.Primitives { @@ -10,11 +11,11 @@ namespace CalamityMod.Graphics.Primitives /// /// The layer to render the primitive(s) to. /// - PixelationPrimitiveLayer LayerToRenderTo => PixelationPrimitiveLayer.BeforeProjectiles; + GeneralDrawLayer LayerToRenderTo => GeneralDrawLayer.BeforeProjectiles; /// /// Render primitives that use pixelation here. /// - void RenderPixelatedPrimitives(SpriteBatch spriteBatch); + void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer); } } diff --git a/Graphics/Primitives/PixelationPrimitiveLayer.cs b/Graphics/Primitives/PixelationPrimitiveLayer.cs deleted file mode 100644 index 1ed0348bc8..0000000000 --- a/Graphics/Primitives/PixelationPrimitiveLayer.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.Xna.Framework.Graphics; - -namespace CalamityMod.Graphics.Primitives -{ - /// - /// Controls what layer the renders to. - /// - public enum PixelationPrimitiveLayer - { - BeforeNPCs, - AfterNPCs, - BeforeProjectiles, - AfterProjectiles - } -} diff --git a/Graphics/Primitives/PrimitivePixelationSystem.cs b/Graphics/Primitives/PrimitivePixelationSystem.cs index 19d5fb1b5c..582591c4a0 100644 --- a/Graphics/Primitives/PrimitivePixelationSystem.cs +++ b/Graphics/Primitives/PrimitivePixelationSystem.cs @@ -1,5 +1,8 @@ using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -10,15 +13,23 @@ namespace CalamityMod.Graphics.Primitives public class PrimitivePixelationSystem : ModSystem { #region Fields/Properties - private static ManagedRenderTarget PixelationTarget_BeforeNPCs; + private static RenderTargetLease PixelationTarget_BeforeAllTiles; - private static ManagedRenderTarget PixelationTarget_AfterNPCs; + private static RenderTargetLease PixelationTarget_BeforeSolidTiles; - private static ManagedRenderTarget PixelationTarget_BeforeProjectiles; + private static RenderTargetLease PixelationTarget_BeforeNPCs; - private static ManagedRenderTarget PixelationTarget_AfterProjectiles; + private static RenderTargetLease PixelationTarget_AfterNPCs; - private static RenderTarget2D CreatePixelTarget(int width, int height) => new(Main.instance.GraphicsDevice, width / 2, height / 2); + private static RenderTargetLease PixelationTarget_BeforeProjectiles; + + private static RenderTargetLease PixelationTarget_AfterProjectiles; + + private static RenderTargetLease PixelationTarget_AfterPlayers; + + private static RenderTargetLease PixelationTarget_AfterDusts; + + private static RenderTargetLease PixelationTarget_AfterEverything; /// /// Whether the system is currently rendering any primitives. @@ -33,36 +44,60 @@ namespace CalamityMod.Graphics.Primitives #region Loading public override void Load() { - On_Main.CheckMonoliths += DrawToTargets; - On_Main.DoDraw_DrawNPCsOverTiles += DrawTarget_NPCs; - On_Main.DrawProjectiles += DrawTarget_Projectiles; + if (Main.dedServ) + return; - PixelationTarget_BeforeNPCs = new(true, CreatePixelTarget); - PixelationTarget_AfterNPCs = new(true, CreatePixelTarget); - PixelationTarget_BeforeProjectiles = new(true, CreatePixelTarget); - PixelationTarget_AfterProjectiles = new(true, CreatePixelTarget); + Main.QueueMainThreadAction(() => + { + PixelationTarget_BeforeAllTiles = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_BeforeSolidTiles = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_BeforeNPCs = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_AfterNPCs = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_BeforeProjectiles = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_AfterProjectiles = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_AfterPlayers = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_AfterDusts = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + PixelationTarget_AfterEverything = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2)); + }); + + GeneralDrawLayerSystem.OnDrawLayer += DrawTargetScaled; + GeneralDrawLayerSystem.OnPrepareDraw += DrawToTargets; + //On_Main.DrawBackgroundBlackFill += DrawTarget_BeforeAllTiles; + //On_Main.DoDraw_Tiles_Solid += DrawTarget_BeforeSolidTiles; + //On_Main.DoDraw_DrawNPCsOverTiles += DrawTarget_NPCs; + //On_Main.DrawProjectiles += DrawTarget_Projectiles; + //On_Main.DrawPlayers_AfterProjectiles += DrawTarget_Players; + //On_Main.DrawDust += DrawTarget_AfterDusts; + //On_Main.DrawInfernoRings += DrawTarget_AfterEverything; } public override void Unload() { - On_Main.CheckMonoliths -= DrawToTargets; - On_Main.DoDraw_DrawNPCsOverTiles -= DrawTarget_NPCs; + if (Main.dedServ) + return; + + GeneralDrawLayerSystem.OnDrawLayer -= DrawTargetScaled; + GeneralDrawLayerSystem.OnPrepareDraw -= DrawToTargets; } #endregion #region Drawing To Targets - private void DrawToTargets(On_Main.orig_CheckMonoliths orig) + private void DrawToTargets() { if (Main.gameMenu) { - orig(); return; } + var beforeAllTiles = new List(); + var beforeSolidTiles = new List(); var beforeNPCs = new List(); var afterNPCs = new List(); var beforeProjectiles = new List(); var afterProjectiles = new List(); + var afterPlayers = new List(); + var afterDusts = new List(); + var afterEverything = new List(); // Check every active projectile. foreach (Projectile projectile in Main.ActiveProjectiles) @@ -70,14 +105,24 @@ namespace CalamityMod.Graphics.Primitives // 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.ModProjectile != null && projectile.ModProjectile is IPixelatedPrimitiveRenderer pixelPrimitiveProjectile) { - var listToUse = pixelPrimitiveProjectile.LayerToRenderTo switch - { - PixelationPrimitiveLayer.BeforeNPCs => beforeNPCs, - PixelationPrimitiveLayer.AfterNPCs => afterNPCs, - PixelationPrimitiveLayer.BeforeProjectiles => beforeProjectiles, - _ => afterProjectiles - }; - listToUse.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeAllTiles)) + beforeAllTiles.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeSolidTiles)) + beforeSolidTiles.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeNPCs)) + beforeNPCs.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterNPCs)) + afterNPCs.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeProjectiles)) + beforeProjectiles.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterProjectiles)) + afterProjectiles.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterPlayers)) + afterPlayers.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterDusts)) + afterDusts.Add(pixelPrimitiveProjectile); + if (pixelPrimitiveProjectile.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterEverything)) + afterEverything.Add(pixelPrimitiveProjectile); } } @@ -87,68 +132,84 @@ namespace CalamityMod.Graphics.Primitives // 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.ModNPC != null && npc.ModNPC is IPixelatedPrimitiveRenderer pixelPrimitiveNPC) { - var listToUse = pixelPrimitiveNPC.LayerToRenderTo switch - { - PixelationPrimitiveLayer.BeforeNPCs => beforeNPCs, - PixelationPrimitiveLayer.AfterNPCs => afterNPCs, - PixelationPrimitiveLayer.BeforeProjectiles => beforeProjectiles, - _ => afterProjectiles - }; - listToUse.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeAllTiles)) + beforeAllTiles.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeSolidTiles)) + beforeSolidTiles.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeNPCs)) + beforeNPCs.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterNPCs)) + afterNPCs.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.BeforeProjectiles)) + beforeProjectiles.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterProjectiles)) + afterProjectiles.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterPlayers)) + afterPlayers.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterDusts)) + afterDusts.Add(pixelPrimitiveNPC); + if (pixelPrimitiveNPC.LayerToRenderTo.HasFlag(GeneralDrawLayer.AfterEverything)) + afterEverything.Add(pixelPrimitiveNPC); } } CurrentlyRendering = true; - DrawPrimsToRenderTarget(PixelationTarget_BeforeNPCs, beforeNPCs); - DrawPrimsToRenderTarget(PixelationTarget_AfterNPCs, afterNPCs); - DrawPrimsToRenderTarget(PixelationTarget_BeforeProjectiles, beforeProjectiles); - DrawPrimsToRenderTarget(PixelationTarget_AfterProjectiles, afterProjectiles); - - Main.instance.GraphicsDevice.SetRenderTarget(null); + DrawPrimsToRenderTarget(PixelationTarget_BeforeAllTiles.Target, GeneralDrawLayer.BeforeAllTiles, beforeAllTiles); + DrawPrimsToRenderTarget(PixelationTarget_BeforeSolidTiles.Target, GeneralDrawLayer.BeforeSolidTiles, beforeSolidTiles); + DrawPrimsToRenderTarget(PixelationTarget_BeforeNPCs.Target, GeneralDrawLayer.BeforeNPCs, beforeNPCs); + DrawPrimsToRenderTarget(PixelationTarget_AfterNPCs.Target, GeneralDrawLayer.AfterNPCs, afterNPCs); + DrawPrimsToRenderTarget(PixelationTarget_BeforeProjectiles.Target, GeneralDrawLayer.BeforeProjectiles, beforeProjectiles); + DrawPrimsToRenderTarget(PixelationTarget_AfterProjectiles.Target, GeneralDrawLayer.AfterProjectiles, afterProjectiles); + DrawPrimsToRenderTarget(PixelationTarget_AfterPlayers.Target, GeneralDrawLayer.AfterPlayers, afterPlayers); + DrawPrimsToRenderTarget(PixelationTarget_AfterDusts.Target, GeneralDrawLayer.AfterDusts, afterDusts); + DrawPrimsToRenderTarget(PixelationTarget_AfterEverything.Target, GeneralDrawLayer.AfterEverything, afterEverything); CurrentlyRendering = false; - orig(); } - private static void DrawPrimsToRenderTarget(RenderTarget2D renderTarget, List pixelPrimitives) + private static void DrawPrimsToRenderTarget(RenderTarget2D renderTarget, GeneralDrawLayer layer, List pixelPrimitives) { // Swap to the target regardless, in order to clear any leftover content from last frame. Not doing this results in the final frame lingering once it stops rendering. - renderTarget.SwapTo(); - if (pixelPrimitives.Any()) + using (renderTarget.Scope(clearColor: Color.Transparent)) { - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null); + if (pixelPrimitives.Any()) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null); - foreach (var pixelPrimitiveDrawer in pixelPrimitives) - pixelPrimitiveDrawer.RenderPixelatedPrimitives(Main.spriteBatch); + foreach (var pixelPrimitiveDrawer in pixelPrimitives) + pixelPrimitiveDrawer.RenderPixelatedPrimitives(Main.spriteBatch, layer); - Main.spriteBatch.End(); + Main.spriteBatch.End(); + } } } #endregion #region Target Drawing - private void DrawTarget_NPCs(On_Main.orig_DoDraw_DrawNPCsOverTiles orig, Main self) - { - DrawTargetScaled(PixelationTarget_BeforeNPCs); - orig(self); - DrawTargetScaled(PixelationTarget_AfterNPCs); - } - - private void DrawTarget_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) - { - DrawTargetScaled(PixelationTarget_BeforeProjectiles); - orig(self); - DrawTargetScaled(PixelationTarget_AfterProjectiles); - } - - private static void DrawTargetScaled(ManagedRenderTarget target) + private static void DrawTargetScaled(GeneralDrawLayer drawLayer) { Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(ReturnAssociatedRenderTarget(drawLayer), Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); Main.spriteBatch.End(); } + + private static RenderTarget2D ReturnAssociatedRenderTarget(GeneralDrawLayer drawLayer) + { + return drawLayer switch + { + GeneralDrawLayer.BeforeAllTiles => PixelationTarget_BeforeAllTiles.Target, + GeneralDrawLayer.BeforeSolidTiles => PixelationTarget_BeforeSolidTiles.Target, + GeneralDrawLayer.BeforeNPCs => PixelationTarget_BeforeNPCs.Target, + GeneralDrawLayer.AfterNPCs => PixelationTarget_AfterNPCs.Target, + GeneralDrawLayer.BeforeProjectiles => PixelationTarget_BeforeProjectiles.Target, + GeneralDrawLayer.AfterProjectiles => PixelationTarget_AfterProjectiles.Target, + GeneralDrawLayer.AfterPlayers => PixelationTarget_AfterPlayers.Target, + GeneralDrawLayer.AfterDusts => PixelationTarget_AfterDusts.Target, + _ => PixelationTarget_AfterEverything.Target + }; + } #endregion } } diff --git a/Graphics/Primitives/PrimitiveRenderer.cs b/Graphics/Primitives/PrimitiveRenderer.cs index 66fa36a79d..8c9a78f382 100644 --- a/Graphics/Primitives/PrimitiveRenderer.cs +++ b/Graphics/Primitives/PrimitiveRenderer.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -18,7 +17,7 @@ namespace CalamityMod.Graphics.Primitives /// The third controls how many points are created for the trail, and the fourth determines whether the primitive is subsequently rendered. /// /// If you wish to use pixelation, you MUST make the NPC/Projectile inherit and use instead of predraw..
- /// You can also optionally specify a render layer with . It is by default. + /// You can also optionally specify a render layer with . It is by default. ///
[Autoload(Side = ModSide.Client)] public sealed class PrimitiveRenderer : ModSystem @@ -30,20 +29,46 @@ namespace CalamityMod.Graphics.Primitives private static PrimitiveSettings MainSettings; + private static PrimitiveTopology ActiveTopology; + private static Vector2[] MainPositions; + private static Vector2[] MainTangents; + + private static Vector2[] MainNormals; + private static VertexPosition2DColorTexture[] MainVertices; private static short[] MainIndices; + private static VertexPositionColor[] WireframeVertices; + + private static int WireframeVertexCount; + + private static BasicEffect WireframeEffect; + + private static int[] NonSmoothIndexScratch; + + private static short StartCapCenterIndex; + + private static short EndCapCenterIndex; + private const short MaxPositions = 1000; private const short MaxVertices = 3072; private const short MaxIndices = 8192; + private static readonly List ControlPointsCache = new(MaxPositions); + private static short PositionsIndex; + private static float[] MainCompletionRatios; + + private static float TotalTrailLength; + + public const float Epsilon = 1e-6f; + private static short VerticesIndex; private static short IndicesIndex; @@ -55,8 +80,40 @@ namespace CalamityMod.Graphics.Primitives MainPositions = new Vector2[MaxPositions]; MainVertices = new VertexPosition2DColorTexture[MaxVertices]; MainIndices = new short[MaxIndices]; + MainCompletionRatios = new float[MaxPositions]; + MainTangents = new Vector2[MaxPositions]; + MainNormals = new Vector2[MaxPositions]; + WireframeVertices = new VertexPositionColor[MaxPositions * 8]; + NonSmoothIndexScratch = new int[MaxPositions]; VertexBuffer ??= new DynamicVertexBuffer(Main.instance.GraphicsDevice, VertexPosition2DColorTexture.VertexDeclaration2D, MaxVertices, BufferUsage.WriteOnly); IndexBuffer ??= new DynamicIndexBuffer(Main.instance.GraphicsDevice, IndexElementSize.SixteenBits, MaxIndices, BufferUsage.WriteOnly); + WireframeEffect ??= new BasicEffect(Main.instance.GraphicsDevice) + { + VertexColorEnabled = true, + TextureEnabled = false, + LightingEnabled = false + }; + }); + } + + public override void OnModUnload() + { + Main.QueueMainThreadAction(() => + { + MainPositions = null; + MainVertices = null; + MainIndices = null; + MainCompletionRatios = null; + MainTangents = null; + MainNormals = null; + WireframeVertices = null; + NonSmoothIndexScratch = null; + VertexBuffer?.Dispose(); + VertexBuffer = null; + IndexBuffer?.Dispose(); + IndexBuffer = null; + WireframeEffect?.Dispose(); + WireframeEffect = null; }); } @@ -92,21 +149,27 @@ namespace CalamityMod.Graphics.Primitives return; // Return if too many to draw anything, - if (positions.Length >= MaxPositions) + if (positions.Length > MaxPositions) return; + int desiredPointCount = pointsToCreate ?? positions.Length; + desiredPointCount = Math.Clamp(desiredPointCount, 2, MaxPositions); + + MainSettings = settings; + ActiveTopology = settings.CapStyle != PrimitiveCapStyle.None ? PrimitiveTopology.TriangleList : settings.Topology; + // IF this is false, a correct position trail could not be made and rendering should not continue. - if (!AssignPointsRectangleTrail(positions, settings, pointsToCreate ?? positions.Length)) + if (!AssignPointsRectangleTrail(positions, settings, desiredPointCount)) return; // A trail with only one point or less has nothing to connect to, and therefore, can't make a trail. - if (MainPositions.Length <= 2) + AssignCompletionData(); + + if (PositionsIndex <= 2) return; - MainSettings = settings; - AssignVerticesRectangleTrail(); - AssignIndicesRectangleTrail(); + AssignIndices(); // Else render without wasting resources creating a set. PrivateRender(); @@ -115,7 +178,15 @@ namespace CalamityMod.Graphics.Primitives private static void PrivateRender() { - if (IndicesIndex % 6 != 0 || VerticesIndex <= 3) + if (VerticesIndex <= 3) + return; + + if (ActiveTopology == PrimitiveTopology.TriangleList) + { + if (IndicesIndex < 6 || IndicesIndex % 3 != 0) + return; + } + else if (ActiveTopology == PrimitiveTopology.TriangleStrip && IndicesIndex < 4) return; // Perform screen culling, for performance reasons. @@ -125,7 +196,7 @@ namespace CalamityMod.Graphics.Primitives Matrix view; Matrix projection; - if (MainSettings.Pixelate) + if (MainSettings.Pixelate || MainSettings.UseUnscaledMatrices) CalcuatePixelatedPerspectiveMatrices(out view, out projection); else CalamityUtils.CalculatePerspectiveMatricies(out view, out projection); @@ -139,7 +210,13 @@ namespace CalamityMod.Graphics.Primitives Main.instance.GraphicsDevice.SetVertexBuffer(VertexBuffer); Main.instance.GraphicsDevice.Indices = IndexBuffer; - Main.instance.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VerticesIndex, 0, IndicesIndex / 3); + + PrimitiveType primitiveType = ActiveTopology == PrimitiveTopology.TriangleStrip ? PrimitiveType.TriangleStrip : PrimitiveType.TriangleList; + int primitiveCount = primitiveType == PrimitiveType.TriangleStrip ? Math.Max(IndicesIndex - 2, 0) : IndicesIndex / 3; + Main.instance.GraphicsDevice.DrawIndexedPrimitives(primitiveType, 0, 0, VerticesIndex, 0, primitiveCount); + + if (MainSettings.DebugWireframe && WireframeEffect != null && TryBuildWireframeGeometry(MainSettings.WireframeColor, out int lineCount)) + DrawWireframe(view, projection, lineCount); } #endregion @@ -151,140 +228,599 @@ namespace CalamityMod.Graphics.Primitives { PositionsIndex = 0; - // Would like to remove this, but unsure how else to properly ensure that none are zero. - positions = positions.Where(originalPosition => originalPosition != Vector2.Zero).ToArray(); + int validCount = 0; + for (int i = 0; i < positions.Length; i++) + { + if (positions[i] == Vector2.Zero) + continue; - if (positions.Length <= 2) + NonSmoothIndexScratch[validCount++] = i; + } + + if (validCount <= 2) return false; - // Remap the original positions across a certain length. + int lastIndex = validCount - 1; + float inversePointCount = 1f / (pointsToCreate - 1); + float lastIndexFloat = lastIndex; + + // Remap the original positions across a certain length without additional allocations. for (int i = 0; i < pointsToCreate; i++) { - float completionRatio = i / (float)(pointsToCreate - 1f); - int currentIndex = (int)(completionRatio * (positions.Length - 1)); - Vector2 currentPoint = positions[currentIndex]; - Vector2 nextPoint = positions[(currentIndex + 1) % positions.Length]; + float completionRatio = i * inversePointCount; + float scaledIndex = completionRatio * lastIndexFloat; + int currentIndex = (int)scaledIndex; + int nextIndex = Math.Min(currentIndex + 1, lastIndex); + float localInterpolant = scaledIndex - currentIndex; - // 29FEB2024: Ozzatron: offset function needs to apply even in cases where smoothing is off. - Vector2 finalPos = Vector2.Lerp(currentPoint, nextPoint, completionRatio * (positions.Length - 1) % 0.99999f) - Main.screenPosition; + Vector2 currentPoint = positions[NonSmoothIndexScratch[currentIndex]]; + Vector2 nextPoint = positions[NonSmoothIndexScratch[nextIndex]]; + Vector2 interpolatedWorld = Vector2.Lerp(currentPoint, nextPoint, localInterpolant); + Vector2 finalPos = interpolatedWorld - Main.screenPosition; if (settings.OffsetFunction != null) - finalPos += settings.OffsetFunction(completionRatio); + finalPos += settings.OffsetFunction(completionRatio, interpolatedWorld); - MainPositions[PositionsIndex] = finalPos; - PositionsIndex++; + MainPositions[PositionsIndex++] = finalPos; } return true; } - // Due to the first point being manually added, points should be added starting at the second position instead of the first. - PositionsIndex = 1; + PositionsIndex = 0; // Create the control points for the spline. - List controlPoints = new(); + List controlPoints = ControlPointsCache; + controlPoints.Clear(); for (int i = 0; i < positions.Length; i++) { - // Don't incorporate points that are zeroed out. - // They are almost certainly a result of incomplete oldPos arrays. if (positions[i] == Vector2.Zero) continue; float completionRatio = i / (float)positions.Length; Vector2 offset = -Main.screenPosition; if (settings.OffsetFunction != null) - offset += settings.OffsetFunction(completionRatio); + offset += settings.OffsetFunction(completionRatio, positions[i]); controlPoints.Add(positions[i] + offset); } - // Avoid stupid index errors. - if (controlPoints.Count <= 4) + int controlCount = controlPoints.Count; + if (controlCount <= 1) + { + controlPoints.Clear(); return false; + } + + int segmentCount = controlCount - 1; + + if (settings.SmoothingSegments > 0) + { + int segmentsPerEdge = Math.Max(1, settings.SmoothingSegments); + PrimitiveSmoothingType smoothingType = settings.SmoothingType; + + for (int segment = 0; segment < segmentCount; segment++) + { + Vector2 p0 = controlPoints[Math.Max(segment - 1, 0)]; + Vector2 p1 = controlPoints[segment]; + Vector2 p2 = controlPoints[segment + 1]; + Vector2 p3 = controlPoints[Math.Min(segment + 2, controlCount - 1)]; + + for (int step = segment == 0 ? 0 : 1; step <= segmentsPerEdge; step++) + { + if (PositionsIndex >= MaxPositions - 1) + { + controlPoints.Clear(); + return true; + } + + float localT = step / (float)segmentsPerEdge; + Vector2 point = EvaluateCurve(smoothingType, p0, p1, p2, p3, localT, settings); + MainPositions[PositionsIndex++] = point; + } + } + + controlPoints.Clear(); + return true; + } + + // Legacy behaviour: sample based on requested point count using Catmull-Rom style interpolation. + PositionsIndex = 1; + float controlCountMinusOne = controlCount - 1f; + PrimitiveSmoothingType legacyType = settings.SmoothingType; for (int j = 0; j < pointsToCreate; j++) { + if (PositionsIndex >= MaxPositions - 1) + break; + float splineInterpolant = j / (float)pointsToCreate; - float localSplineInterpolant = splineInterpolant * (controlPoints.Count - 1f) % 1f; - int localSplineIndex = (int)(splineInterpolant * (controlPoints.Count - 1f)); + float positionOnCurve = splineInterpolant * controlCountMinusOne; + int localSplineIndex = (int)positionOnCurve; + float localSplineInterpolant = positionOnCurve - localSplineIndex; - Vector2 farLeft; - Vector2 left = controlPoints[localSplineIndex]; - Vector2 right = controlPoints[localSplineIndex + 1]; - Vector2 farRight; + Vector2 p0 = controlPoints[Math.Max(localSplineIndex - 1, 0)]; + Vector2 p1 = controlPoints[localSplineIndex]; + Vector2 p2 = controlPoints[Math.Min(localSplineIndex + 1, controlCount - 1)]; + Vector2 p3 = controlPoints[Math.Min(localSplineIndex + 2, controlCount - 1)]; - // Special case: If the spline attempts to access the previous/next index but the index is already at the very beginning/end, simply - // cheat a little bit by creating a phantom point that's mirrored from the previous one. - if (localSplineIndex <= 0) - { - Vector2 mirrored = left * 2f - right; - farLeft = mirrored; - } - else - farLeft = controlPoints[localSplineIndex - 1]; - - if (localSplineIndex >= controlPoints.Count - 2) - { - Vector2 mirrored = right * 2f - left; - farRight = mirrored; - } - else - farRight = controlPoints[localSplineIndex + 2]; - - MainPositions[PositionsIndex] = Vector2.CatmullRom(farLeft, left, right, farRight, localSplineInterpolant); + MainPositions[PositionsIndex] = EvaluateCurve(legacyType, p0, p1, p2, p3, localSplineInterpolant, settings); PositionsIndex++; } - // Manually insert the front and end points. - MainPositions[0] = controlPoints.First(); - MainPositions[PositionsIndex] = controlPoints.Last(); + MainPositions[0] = controlPoints[0]; + MainPositions[PositionsIndex] = controlPoints[controlCount - 1]; PositionsIndex++; + controlPoints.Clear(); return true; } + private static void AssignCompletionData() + { + TotalTrailLength = 0f; + + if (PositionsIndex <= 0) + return; + + MainCompletionRatios[0] = 0f; + + for (int i = 1; i < PositionsIndex; i++) + { + float segmentLength = Vector2.Distance(MainPositions[i], MainPositions[i - 1]); + TotalTrailLength += segmentLength; + MainCompletionRatios[i] = TotalTrailLength; + } + + if (PositionsIndex <= 0) + return; + + if (TotalTrailLength > Epsilon) + { + float inverseTotal = 1f / TotalTrailLength; + int lastIndex = PositionsIndex - 1; + + if (System.Numerics.Vector.IsHardwareAccelerated && PositionsIndex - 1 >= System.Numerics.Vector.Count) + { + var scale = new System.Numerics.Vector(inverseTotal); + int i = 1; + int upperBound = lastIndex - System.Numerics.Vector.Count + 1; + for (; i <= upperBound; i += System.Numerics.Vector.Count) + { + var values = new System.Numerics.Vector(MainCompletionRatios, i); + (values * scale).CopyTo(MainCompletionRatios, i); + } + + for (; i <= lastIndex; i++) + MainCompletionRatios[i] *= inverseTotal; + } + else + { + for (int i = 1; i < PositionsIndex; i++) + MainCompletionRatios[i] *= inverseTotal; + } + + MainCompletionRatios[PositionsIndex - 1] = 1f; + } + else + { + for (int i = 1; i < PositionsIndex; i++) + MainCompletionRatios[i] = 0f; + } + } + private static void AssignVerticesRectangleTrail() { VerticesIndex = 0; + StartCapCenterIndex = -1; + EndCapCenterIndex = -1; + ComputeFrameData(); for (int i = 0; i < PositionsIndex; i++) { - float completionRatio = (i - 1f) / (float)(PositionsIndex - 1); - float widthAtVertex = MainSettings.WidthFunction(completionRatio); - Color vertexColor = MainSettings.ColorFunction(completionRatio); - Vector2 currentPosition = MainPositions[i]; - Vector2 directionToAhead = i == PositionsIndex - 1 ? (MainPositions[i] - MainPositions[i - 1]).SafeNormalize(Vector2.Zero) : (MainPositions[i + 1] - MainPositions[i]).SafeNormalize(Vector2.Zero); - Vector2 leftCurrentTextureCoord = new(completionRatio, 0.5f - widthAtVertex * 0.5f); - Vector2 rightCurrentTextureCoord = new(completionRatio, 0.5f + widthAtVertex * 0.5f); + float completionRatio = GetCompletionRatioForIndex(i); + float widthAtVertex = Math.Max(MainSettings.WidthFunction(completionRatio, MainPositions[i]), 0f); + Color vertexColor = MainSettings.ColorFunction(completionRatio, MainPositions[i]); + float textureU = ComputeTextureCoordinateForIndex(i, completionRatio); - // Point 90 degrees away from the direction towards the next point, and use it to mark the edges of the rectangle. - // This doesn't use RotatedBy for the sake of performance (there can potentially be a lot of trail points). - Vector2 sideDirection = new(-directionToAhead.Y, directionToAhead.X); - - Vector2 left = currentPosition - sideDirection * widthAtVertex; - Vector2 right = currentPosition + sideDirection * widthAtVertex; + ComputeEdgePositions(i, widthAtVertex, out Vector2 left, out Vector2 right, out float effectiveHalfWidth); // Override the initial vertex positions if requested. if (i == 0 && MainSettings.InitialVertexPositionsOverride.HasValue && MainSettings.InitialVertexPositionsOverride.Value.Item1 != Vector2.Zero && MainSettings.InitialVertexPositionsOverride.Value.Item2 != Vector2.Zero) { left = MainSettings.InitialVertexPositionsOverride.Value.Item1; right = MainSettings.InitialVertexPositionsOverride.Value.Item2; + effectiveHalfWidth = Math.Max(Vector2.Distance(left, right) * 0.5f, Epsilon); } - // What this is doing, at its core, is defining a rectangle based on two triangles. - // These triangles are defined based on the width of the strip at that point. - // The resulting rectangles combined are what make the trail itself. - MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord, widthAtVertex); + // Guard against degenerate width + effectiveHalfWidth = Math.Max(effectiveHalfWidth, Epsilon); + + Vector2 leftCurrentTextureCoord = new Vector2(textureU, 0.5f - effectiveHalfWidth * 0.5f); + Vector2 rightCurrentTextureCoord = new Vector2(textureU, 0.5f + effectiveHalfWidth * 0.5f); + + MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord, effectiveHalfWidth); VerticesIndex++; - MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord, widthAtVertex); + MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord, effectiveHalfWidth); VerticesIndex++; } + + AddCaps(); + } + + private static void AddCaps() + { + if (MainSettings.CapStyle == PrimitiveCapStyle.None || PositionsIndex <= 0) + return; + + if (ActiveTopology == PrimitiveTopology.TriangleStrip) + return; + + StartCapCenterIndex = TryCreateCapVertex(0); + if (PositionsIndex > 1) + EndCapCenterIndex = TryCreateCapVertex(PositionsIndex - 1); + } + + private static short TryCreateCapVertex(int positionIndex) + { + if (VerticesIndex >= MaxVertices - 1) + return -1; + + int leftVertexIndex = positionIndex * 2; + int rightVertexIndex = leftVertexIndex + 1; + if (rightVertexIndex >= VerticesIndex) + return -1; + + ref readonly VertexPosition2DColorTexture leftVertex = ref MainVertices[leftVertexIndex]; + ref readonly VertexPosition2DColorTexture rightVertex = ref MainVertices[rightVertexIndex]; + + Vector2 centerPosition = MainPositions[positionIndex]; + Color centerColor = Color.Lerp(leftVertex.Color, rightVertex.Color, 0.5f); + float centerHalfWidth = Math.Max(Math.Max(leftVertex.TextureCoordinates.Z, rightVertex.TextureCoordinates.Z), Epsilon); + float centerU = (leftVertex.TextureCoordinates.X + rightVertex.TextureCoordinates.X) * 0.5f; + Vector2 centerTexcoord = new(centerU, 0.5f); + + short newVertexIndex = VerticesIndex; + MainVertices[VerticesIndex++] = new VertexPosition2DColorTexture(centerPosition, centerColor, centerTexcoord, centerHalfWidth); + return newVertexIndex; + } + + private static float GetCompletionRatioForIndex(int index) + { + if (PositionsIndex <= 0) + return 0f; + + if (index <= 0) + return MainCompletionRatios[0]; + + if (index >= PositionsIndex) + return MainCompletionRatios[PositionsIndex - 1]; + + return MainCompletionRatios[index]; + } + + private static float ComputeTextureCoordinateForIndex(int index, float completionRatio) + { + float clampedCompletion = MathHelper.Clamp(completionRatio, 0f, 1f); + + if (MainSettings.TextureCoordinateFunction != null) + return MainSettings.TextureCoordinateFunction(clampedCompletion); + + float cycleLength = MainSettings.TextureCycleLength; + if (Math.Abs(cycleLength) <= Epsilon) + cycleLength = cycleLength >= 0f ? 1f : -1f; + + switch (MainSettings.TextureCoordinateMode) + { + case PrimitiveTextureMode.Distance: + float distance = clampedCompletion * TotalTrailLength + MainSettings.TextureScrollOffset; + return distance / cycleLength; + + default: + return clampedCompletion * cycleLength + MainSettings.TextureScrollOffset; + } } - private static void AssignIndicesRectangleTrail() + private static void ComputeFrameData() { + if (PositionsIndex <= 0) + return; + + Vector2 fallbackTangent = Vector2.UnitX; + + for (int i = 0; i < PositionsIndex; i++) + { + Vector2 tangent = ComputeTangent(i, fallbackTangent); + tangent = tangent.SafeNormalize(fallbackTangent.SafeNormalize(Vector2.UnitX)); + MainTangents[i] = tangent; + fallbackTangent = tangent; + } + + Vector2 previousNormal = Vector2.Zero; + + for (int i = 0; i < PositionsIndex; i++) + { + Vector2 tangent = MainTangents[i]; + if (tangent.LengthSquared() <= Epsilon) + tangent = fallbackTangent.SafeNormalize(Vector2.UnitX); + + Vector2 baseNormal = new Vector2(-tangent.Y, tangent.X); + Vector2 normal; + + if (MainSettings.FrameTransportMode == PrimitiveFrameTransportMode.ParallelTransport && i > 0 && previousNormal.LengthSquared() > Epsilon) + { + Vector2 previousTangent = MainTangents[i - 1]; + float cosine = MathHelper.Clamp(Vector2.Dot(previousTangent, tangent), -1f, 1f); + float sine = Cross(previousTangent, tangent); + Vector2 transported = new Vector2( + cosine * previousNormal.X - sine * previousNormal.Y, + sine * previousNormal.X + cosine * previousNormal.Y + ); + normal = transported; + } + else + normal = baseNormal; + + if (normal.LengthSquared() <= Epsilon) + normal = previousNormal.LengthSquared() > Epsilon ? previousNormal : baseNormal; + + normal = normal.SafeNormalize(previousNormal.LengthSquared() > Epsilon ? previousNormal : Vector2.UnitY); + MainNormals[i] = normal; + previousNormal = normal; + } + } + + private static Vector2 ComputeTangent(int index, Vector2 fallback) + { + int last = PositionsIndex - 1; + Vector2 tangent; + + if (PositionsIndex <= 1) + { + tangent = fallback; + } + else if (index <= 0) + { + tangent = MainPositions[1] - MainPositions[0]; + } + else if (index >= last) + { + tangent = MainPositions[last] - MainPositions[last - 1]; + } + else + { + Vector2 forward = MainPositions[index + 1] - MainPositions[index]; + Vector2 backward = MainPositions[index] - MainPositions[index - 1]; + tangent = forward + backward; + + if (tangent.LengthSquared() <= Epsilon) + tangent = forward.LengthSquared() >= backward.LengthSquared() ? forward : backward; + } + + if (tangent.LengthSquared() <= Epsilon) + tangent = fallback.LengthSquared() > Epsilon ? fallback : Vector2.UnitX; + + return tangent; + } + + private static Vector2 EvaluateCurve(PrimitiveSmoothingType type, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t, PrimitiveSettings settings) + { + t = MathHelper.Clamp(t, 0f, 1f); + + switch (type) + { + case PrimitiveSmoothingType.Linear: + return Vector2.Lerp(p1, p2, t); + + case PrimitiveSmoothingType.Cardinal: + { + float tension = MathHelper.Clamp(settings.SmoothingTension, -1f, 1f); + float scale = (1f - tension) * 0.5f; + Vector2 m0 = (p2 - p0) * scale; + Vector2 m1 = (p3 - p1) * scale; + return EvaluateHermiteSpan(p1, p2, m0, m1, t); + } + + case PrimitiveSmoothingType.Hermite: + { + Vector2 m0 = 0.5f * (p2 - p0); + Vector2 m1 = 0.5f * (p3 - p1); + return EvaluateHermiteSpan(p1, p2, m0, m1, t); + } + + case PrimitiveSmoothingType.CubicBezier: + { + Vector2 handle1 = p1 + (p2 - p0) / 3f; + Vector2 handle2 = p2 - (p3 - p1) / 3f; + return EvaluateBezierSpan(p1, handle1, handle2, p2, t); + } + + default: + return Vector2.CatmullRom(p0, p1, p2, p3, t); + } + } + + private static Vector2 EvaluateHermiteSpan(Vector2 start, Vector2 end, Vector2 tangentStart, Vector2 tangentEnd, float t) + { + float t2 = t * t; + float t3 = t2 * t; + float h00 = 2f * t3 - 3f * t2 + 1f; + float h10 = t3 - 2f * t2 + t; + float h01 = -2f * t3 + 3f * t2; + float h11 = t3 - t2; + return h00 * start + h10 * tangentStart + h01 * end + h11 * tangentEnd; + } + + private static Vector2 EvaluateBezierSpan(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t) + { + float u = 1f - t; + float u2 = u * u; + float u3 = u2 * u; + float t2 = t * t; + float t3 = t2 * t; + return u3 * p0 + 3f * u2 * t * p1 + 3f * u * t2 * p2 + t3 * p3; + } + + private static void ComputeEdgePositions(int index, float halfWidth, out Vector2 left, out Vector2 right, out float effectiveHalfWidth) + { + Vector2 currentPosition = MainPositions[index]; + + if (halfWidth <= 0f) + { + left = currentPosition; + right = currentPosition; + effectiveHalfWidth = Epsilon; + return; + } + + Vector2 defaultNormal = MainNormals[index]; + if (defaultNormal.LengthSquared() <= Epsilon) + defaultNormal = Vector2.UnitY; + + if (MainSettings.JoinStyle == PrimitiveJoinStyle.Flat || PositionsIndex <= 2 || index == 0 || index == PositionsIndex - 1) + { + Vector2 offset = defaultNormal * halfWidth; + left = currentPosition - offset; + right = currentPosition + offset; + effectiveHalfWidth = halfWidth; + return; + } + + Vector2 prevNormal = MainNormals[Math.Max(index - 1, 0)]; + if (prevNormal.LengthSquared() <= Epsilon) + prevNormal = defaultNormal; + + Vector2 nextNormal = MainNormals[Math.Min(index + 1, PositionsIndex - 1)]; + if (nextNormal.LengthSquared() <= Epsilon) + nextNormal = defaultNormal; + + switch (MainSettings.JoinStyle) + { + case PrimitiveJoinStyle.Smooth: + { + Vector2 averageNormal = (prevNormal + defaultNormal + nextNormal) * (1f / 3f); + if (averageNormal.LengthSquared() <= Epsilon) + averageNormal = defaultNormal; + + Vector2 offset = averageNormal.SafeNormalize(defaultNormal) * halfWidth; + left = currentPosition - offset; + right = currentPosition + offset; + effectiveHalfWidth = halfWidth; + return; + } + + case PrimitiveJoinStyle.Miter: + { + Vector2 prev = prevNormal.SafeNormalize(defaultNormal); + Vector2 next = nextNormal.SafeNormalize(defaultNormal); + Vector2 miter = prev + next; + if (miter.LengthSquared() <= Epsilon) + miter = defaultNormal; + + miter = miter.SafeNormalize(defaultNormal); + float denom = Vector2.Dot(miter, next); + if (Math.Abs(denom) < Epsilon) + denom = denom >= 0f ? Epsilon : -Epsilon; + + float miterLength = halfWidth / denom; + float maxLength = halfWidth * MainSettings.JoinMiterLimit; + miterLength = MathHelper.Clamp(miterLength, -maxLength, maxLength); + Vector2 offset = miter * miterLength; + left = currentPosition - offset; + right = currentPosition + offset; + effectiveHalfWidth = Math.Max(Math.Abs(miterLength), Epsilon); + return; + } + + default: + { + Vector2 offset = defaultNormal * halfWidth; + left = currentPosition - offset; + right = currentPosition + offset; + effectiveHalfWidth = halfWidth; + return; + } + } + } + + private static bool TryBuildWireframeGeometry(Color lineColor, out int lineCount) + { + lineCount = 0; + + if (WireframeVertices == null) + return false; + + int segments = PositionsIndex - 1; + if (segments <= 0) + return false; + + WireframeVertexCount = 0; + + for (int i = 0; i < segments; i++) + { + int currentLeft = i * 2; + int currentRight = currentLeft + 1; + int nextLeft = currentLeft + 2; + int nextRight = nextLeft + 1; + + AddWireframeLineFromIndices(currentLeft, nextLeft, lineColor); + AddWireframeLineFromIndices(currentRight, nextRight, lineColor); + } + + for (int i = 0; i < PositionsIndex; i++) + { + int leftIndex = i * 2; + AddWireframeLineFromIndices(leftIndex, leftIndex + 1, lineColor); + } + + lineCount = WireframeVertexCount / 2; + return lineCount > 0; + } + + private static void AddWireframeLineFromIndices(int startVertexIndex, int endVertexIndex, Color color) + { + if (WireframeVertexCount + 1 >= WireframeVertices.Length) + return; + + int vertexCount = VerticesIndex; + if (startVertexIndex >= vertexCount || endVertexIndex >= vertexCount) + return; + + ref readonly VertexPosition2DColorTexture start = ref MainVertices[startVertexIndex]; + ref readonly VertexPosition2DColorTexture end = ref MainVertices[endVertexIndex]; + WireframeVertices[WireframeVertexCount++] = new VertexPositionColor(new Vector3(start.Position, 0f), color); + WireframeVertices[WireframeVertexCount++] = new VertexPositionColor(new Vector3(end.Position, 0f), color); + } + + private static void DrawWireframe(Matrix view, Matrix projection, int lineCount) + { + if (lineCount <= 0 || WireframeEffect == null) + return; + + WireframeEffect.World = Matrix.Identity; + WireframeEffect.View = view; + WireframeEffect.Projection = projection; + + var device = Main.instance.GraphicsDevice; + foreach (EffectPass pass in WireframeEffect.CurrentTechnique.Passes) + { + pass.Apply(); + device.DrawUserPrimitives(PrimitiveType.LineList, WireframeVertices, 0, lineCount); + } + } + + private static void AssignIndices() + { + IndicesIndex = 0; + + if (ActiveTopology == PrimitiveTopology.TriangleStrip) + { + for (short i = 0; i < VerticesIndex && IndicesIndex < MaxIndices; i++) + MainIndices[IndicesIndex++] = i; + return; + } + // What this is doing is basically representing each point on the vertices list as // indices. These indices should come together to create a tiny rectangle that acts // as a segment on the trail. This is achieved here by splitting the indices (or rather, points) // into 2 triangles, which requires 6 points. // The logic here basically determines which indices are connected together. - IndicesIndex = 0; - for (short i = 0; i < PositionsIndex - 2; i++) + for (short i = 0; i < PositionsIndex - 2 && IndicesIndex + 5 < MaxIndices; i++) { short connectToIndex = (short)(i * 2); MainIndices[IndicesIndex] = connectToIndex; @@ -305,6 +841,37 @@ namespace CalamityMod.Graphics.Primitives MainIndices[IndicesIndex] = (short)(connectToIndex + 3); IndicesIndex++; } + + AppendCapTriangles(); + } + + private static void AppendCapTriangles() + { + if (MainSettings.CapStyle == PrimitiveCapStyle.None) + return; + + if (PositionsIndex <= 0) + return; + + if (StartCapCenterIndex >= 0) + AddTriangle((short)(StartCapCenterIndex), 0, 1); + + if (EndCapCenterIndex >= 0) + { + short leftIndex = (short)((PositionsIndex - 1) * 2); + short rightIndex = (short)(leftIndex + 1); + AddTriangle(leftIndex, rightIndex, EndCapCenterIndex); + } + } + + private static void AddTriangle(short i0, short i1, short i2) + { + if (IndicesIndex + 2 >= MaxIndices) + return; + + MainIndices[IndicesIndex++] = i0; + MainIndices[IndicesIndex++] = i1; + MainIndices[IndicesIndex++] = i2; } private static void CalcuatePixelatedPerspectiveMatrices(out Matrix viewMatrix, out Matrix projectionMatrix) @@ -313,6 +880,8 @@ namespace CalamityMod.Graphics.Primitives projectionMatrix = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1, 1); viewMatrix = Matrix.Identity; } + + private static float Cross(Vector2 a, Vector2 b) => a.X * b.Y - a.Y * b.X; #endregion } } diff --git a/Graphics/Primitives/PrimitiveSettings.cs b/Graphics/Primitives/PrimitiveSettings.cs index bbee27c4a7..ebc4b51fcd 100644 --- a/Graphics/Primitives/PrimitiveSettings.cs +++ b/Graphics/Primitives/PrimitiveSettings.cs @@ -1,8 +1,125 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; using Terraria.Graphics.Shaders; namespace CalamityMod.Graphics.Primitives { + /// + /// Controls how U texture coordinates are generated for primitive ribbons. + /// + public enum PrimitiveTextureMode + { + /// + /// U coordinates run from 0 to 1 across the full trail length. This matches the legacy behavior. + /// + Normalized, + + /// + /// U coordinates advance according to distance along the trail. One full texture cycle occurs every pixels. + /// + Distance + } + + /// + /// Controls how adjacent segments are joined together when expanding points into quads. + /// + public enum PrimitiveJoinStyle + { + /// + /// Legacy behavior. Each segment is expanded using its forward direction only. + /// + Flat, + + /// + /// Uses the averaged tangent of neighbouring segments to smooth corners. + /// + Smooth, + + /// + /// Uses a mitered join to keep width continuous around sharp corners. + /// + Miter + } + + /// + /// Determines how intermediate sample points are generated for smoothing. + /// + public enum PrimitiveSmoothingType + { + /// + /// Classic Catmull-Rom interpolation between points. + /// + CatmullRom, + + /// + /// Cardinal spline interpolation with configurable tension. + /// + Cardinal, + + /// + /// Straight-line interpolation between neighbouring points. + /// + Linear, + + /// + /// Cubic Hermite interpolation using central difference tangents. + /// + Hermite, + + /// + /// Cubic Bezier interpolation using Catmull-Rom handles. + /// + CubicBezier + } + + /// + /// Selects how orientation frames propagate along the trail. + /// + public enum PrimitiveFrameTransportMode + { + /// + /// Derives the normal from the instantaneous tangent (legacy behaviour). + /// + Basic, + + /// + /// Uses parallel transport to minimise twisting. + /// + ParallelTransport + } + + /// + /// Determines the topology used when submitting geometry to the GPU. + /// + public enum PrimitiveTopology + { + /// + /// Expands geometry into independent triangles (legacy behaviour). + /// + TriangleList, + + /// + /// Connects geometry using a continuous triangle strip. + /// + TriangleStrip + } + + /// + /// Controls how the start and end of the primitive are capped. + /// + public enum PrimitiveCapStyle + { + /// + /// Leaves the ribbon open (legacy behaviour). + /// + None, + + /// + /// Adds a flat triangular cap across the ribbon ends. + /// + Flat + } + /// /// Contains all the various options to use when creating a primitive trail. New members can be added freely without breaking existing implementations. /// @@ -14,21 +131,21 @@ namespace CalamityMod.Graphics.Primitives ///
/// The current position along the trail as a 0-1 interlopant value. /// The width for the current point. - public delegate float VertexWidthFunction(float trailLengthInterpolant); + public delegate float VertexWidthFunction(float trailLengthInterpolant, Vector2 vertexPosition); /// /// A delegate to dynamically determine the color of the trail at each position. /// /// The current position along the trail as a 0-1 interlopant value. /// The color for the current point. - public delegate Color VertexColorFunction(float trailLengthInterpolant); + public delegate Color VertexColorFunction(float trailLengthInterpolant, Vector2 vertexPosition); /// /// A delegate to dynamically determine the offset of the trail at each position. /// /// The current position along the trail as a 0-1 interlopant value. /// The offset for the current point. - public delegate Vector2 VertexOffsetFunction(float trailLengthInterpolant); + public delegate Vector2 VertexOffsetFunction(float trailLengthInterpolant, Vector2 vertexPosition); #endregion #region Instance Fields @@ -57,6 +174,12 @@ namespace CalamityMod.Graphics.Primitives ///
public readonly bool Pixelate; + /// + /// Whether to use unscaled perspective matrices when rendering the primitives. Recommended only when the system is being used outside of its typical context + /// i.e. rendering primitives in the background via a CustomSky. + /// + public readonly bool UseUnscaledMatrices; + /// /// The shader to apply when rendering. /// @@ -66,6 +189,76 @@ namespace CalamityMod.Graphics.Primitives /// An optional override to force the trail to use the provided positions as the side positions of the initial vertex. They are the left and right positions respectively. ///
public readonly (Vector2, Vector2)? InitialVertexPositionsOverride; + + /// + /// Determines how U texture coordinates are generated. + /// + public readonly PrimitiveTextureMode TextureCoordinateMode; + + /// + /// Controls the scale of generated U coordinates. In this is a multiplier, in this is the distance (in pixels) for one full texture cycle. + /// + public readonly float TextureCycleLength; + + /// + /// Adds an additional offset to the generated U coordinate. In distance mode this value is interpreted in pixels. + /// + public readonly float TextureScrollOffset; + + /// + /// Allows overriding the automatically generated U coordinate with a custom function. Receives the normalized completion ratio (0-1) and should return the desired U coordinate. + /// + public readonly Func TextureCoordinateFunction; + + /// + /// Determines how consecutive segments are joined together when expanding into quads. + /// + public readonly PrimitiveJoinStyle JoinStyle; + + /// + /// Maximum multiplier applied to miter joins to keep spikes under control. + /// + public readonly float JoinMiterLimit; + + /// + /// If true, a debug wireframe will be rendered on top of the primitive. + /// + public readonly bool DebugWireframe; + + /// + /// The color used for the optional wireframe overlay. + /// + public readonly Color WireframeColor; + + /// + /// Determines the interpolation style when smoothing the provided point list. + /// + public readonly PrimitiveSmoothingType SmoothingType; + + /// + /// Controls how many intermediate subdivisions are generated per control segment when smoothing. Set to 0 for automatic distribution. + /// + public readonly int SmoothingSegments; + + /// + /// Additional tension used by smoothing functions that support it (e.g. Cardinal splines). + /// + public readonly float SmoothingTension; + + /// + /// Determines how normals are transported along the curve. + /// + public readonly PrimitiveFrameTransportMode FrameTransportMode; + + /// + /// Chooses the primitive topology when submitting geometry to the GPU. + /// + public readonly PrimitiveTopology Topology; + + /// + /// Determines how the ribbon is capped at its extremities. + /// + public readonly PrimitiveCapStyle CapStyle; #endregion /// @@ -77,8 +270,23 @@ namespace CalamityMod.Graphics.Primitives /// Whether to use smoothening when generating the vertex positions from the provided ones. Recommended to be enabled. /// Whether to pixelate the primitives. Recommended to be enabled if the effect was designed with this in mind. /// The shader to apply when rendering the primitives. + /// Whether to use unscaled perspective matrices when rendering primitives. Recommended when using this system outside of its typical context; i.e. rendering primitives in the background via a CustomSky. /// An optional override to force the trail to use the provided positions as the side positions of the initial vertex. They are the left and right positions respectively and should be in screen space. - public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, (Vector2, Vector2)? initialVertexPositionsOverride = null) + /// Determines how U texture coordinates are generated. + /// Controls how fast U coordinates advance. Acts as a multiplier in normalized mode, or the distance per cycle in distance mode. + /// Adds an offset to generated U coordinates. Interpreted in pixels when using distance mode. + /// Optional override that receives the completion ratio and returns a custom U coordinate. + /// Determines how neighbouring segments are joined when expanding into quads. + /// Maximum multiplier applied to miter joins to prevent spikes. Only used when is . + /// When true, draws a wireframe overlay useful for debugging primitive geometry. + /// Optional override for the wireframe color. If null, a vivid green is used. + /// Determines the interpolation style used when smoothing the control points. + /// When greater than zero, specifies the number of subdivisions created per control edge. + /// Optional tension parameter used by certain smoothing types such as cardinal splines. + /// Controls how frame orientation is propagated along the curve. + /// Specifies the primitive topology used when submitting geometry. + /// Selects how the ribbon's start and end are capped. + public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, bool useUnscaledMatrices = false, (Vector2, Vector2)? initialVertexPositionsOverride = null, PrimitiveTextureMode textureCoordinateMode = PrimitiveTextureMode.Normalized, float textureCycleLength = 1f, float textureScrollOffset = 0f, Func textureCoordinateFunction = null, PrimitiveJoinStyle joinStyle = PrimitiveJoinStyle.Smooth, float joinMiterLimit = 4f, bool debugWireframe = false, Color? wireframeColor = null, PrimitiveSmoothingType smoothingType = PrimitiveSmoothingType.CatmullRom, int smoothingSegments = 0, float smoothingTension = 0f, PrimitiveFrameTransportMode frameTransportMode = PrimitiveFrameTransportMode.ParallelTransport, PrimitiveTopology topology = PrimitiveTopology.TriangleStrip, PrimitiveCapStyle capStyle = PrimitiveCapStyle.None) { WidthFunction = widthFunction; ColorFunction = colorFunction; @@ -86,7 +294,22 @@ namespace CalamityMod.Graphics.Primitives Smoothen = smoothen; Pixelate = pixelate; Shader = shader; + UseUnscaledMatrices = useUnscaledMatrices; InitialVertexPositionsOverride = initialVertexPositionsOverride; + TextureCoordinateMode = textureCoordinateMode; + TextureCycleLength = Math.Abs(textureCycleLength) <= PrimitiveRenderer.Epsilon ? 1f : textureCycleLength; + TextureScrollOffset = textureScrollOffset; + TextureCoordinateFunction = textureCoordinateFunction; + JoinStyle = joinStyle; + JoinMiterLimit = Math.Max(joinMiterLimit, 1f); + DebugWireframe = debugWireframe; + WireframeColor = wireframeColor ?? Color.LimeGreen; + SmoothingType = smoothingType; + SmoothingSegments = Math.Max(smoothingSegments, 0); + SmoothingTension = smoothingTension; + FrameTransportMode = frameTransportMode; + Topology = topology; + CapStyle = PrimitiveCapStyle.Flat; } } } diff --git a/Graphics/RenderTargetManager.cs b/Graphics/RenderTargetManager.cs index 5c4888044c..52dd844c8c 100644 --- a/Graphics/RenderTargetManager.cs +++ b/Graphics/RenderTargetManager.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; @@ -9,10 +9,9 @@ namespace CalamityMod.Graphics /// /// Manager class that handles all created instances of /// + [Obsolete("ManagedRenderTarget is obsolete; developers should use RenderTarget2Ds and RenderTargetLeases")] public class RenderTargetManager : ModSystem { - internal static List ManagedTargets = new(); - public delegate void RenderTargetUpdateDelegate(); /// @@ -25,70 +24,19 @@ namespace CalamityMod.Graphics /// public const int TimeBeforeAutoDispose = 600; - internal static void ResetTargetSizes(Vector2 screenSize) - { - foreach (ManagedRenderTarget target in ManagedTargets) - { - // Don't attempt to recreate targets that are already initialized or shouldn't be recreated. - if (target is null || target.IsDisposed || target.WaitingForFirstInitialization) - continue; - - Main.QueueMainThreadAction(() => - { - target.Recreate((int)screenSize.X, (int)screenSize.Y); - }); - } - } - - internal static void DisposeOfTargets() - { - if (ManagedTargets is null) - return; - - Main.QueueMainThreadAction(() => - { - foreach (ManagedRenderTarget target in ManagedTargets) - target?.Dispose(); - ManagedTargets.Clear(); - }); - } - public override void OnModLoad() { - ManagedTargets = new(); Main.OnPreDraw += HandleTargetUpdateLoop; - Main.OnResolutionChanged += ResetTargetSizes; } public override void OnModUnload() { - DisposeOfTargets(); Main.OnPreDraw -= HandleTargetUpdateLoop; - Main.OnResolutionChanged -= ResetTargetSizes; - - if (RenderTargetUpdateLoopEvent != null) - { - foreach (var subscription in RenderTargetUpdateLoopEvent.GetInvocationList()) - RenderTargetUpdateLoopEvent -= (RenderTargetUpdateDelegate)subscription; - } + RenderTargetUpdateLoopEvent = null; } private void HandleTargetUpdateLoop(GameTime obj) { - // Auto-disposal of targets that havent been used in a while, to stop them hogging GPU memory. - if (ManagedTargets != null) - { - foreach (ManagedRenderTarget target in ManagedTargets) - { - if (target == null || target.IsDisposed || !target.ShouldAutoDispose) - continue; - - if (target.TimeSinceLastAccessed >= TimeBeforeAutoDispose) - target.Dispose(); - else - target.TimeSinceLastAccessed++; - } - } RenderTargetUpdateLoopEvent?.Invoke(); } } diff --git a/Graphics/Renderers/BaseRenderer.cs b/Graphics/Renderers/BaseRenderer.cs index 8cdfa0ae6d..0d570acfd5 100644 --- a/Graphics/Renderers/BaseRenderer.cs +++ b/Graphics/Renderers/BaseRenderer.cs @@ -1,79 +1,91 @@ using System; +using CalamityMod.Enums; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Graphics.Renderers +namespace CalamityMod.Graphics.Renderers; + +/// +/// A class to handle drawing a visual effect to a rendertarget, then drawing the target to the screen at selected layer. +/// +[Obsolete("BaseRenderer is obsolete; developers should explore other avenues for rendering")] +public abstract class BaseRenderer : ModType { + #region Fields/Properties /// - /// A class to handle drawing a visual effect to a rendertarget, then drawing the target to the screen at selected layer. + /// The layer that the target should be drawn at. /// - public abstract class BaseRenderer : ModType + public abstract GeneralDrawLayer Layer { get; } + + /// + /// Whether the target should draw and be drawn to this frame. + /// + public abstract bool ShouldDraw { get; } + + /// + /// The target that the visual is drawn to. Automatically handled. + /// + public RenderTargetLease MainTarget { - #region Fields/Properties - /// - /// The layer that the target should be drawn at. - /// - public abstract DrawLayer Layer { get; } - - /// - /// Whether the target should draw and be drawn to this frame. - /// - public abstract bool ShouldDraw { get; } - - /// - /// The target that the visual is drawn to. Automatically handled. - /// - public ManagedRenderTarget MainTarget - { - get; - private set; - } - #endregion - - #region Methods - protected sealed override void Register() - { - ModTypeLookup.Register(this); - - if (RendererManager.Renderers.Contains(this)) - throw new Exception($"Renderer '{Name}' has already been registered!"); - - RendererManager.Renderers.Add(this); - } - - - public sealed override void SetupContent() => SetStaticDefaults(); - - public sealed override void SetStaticDefaults() => MainTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget); - - /// - /// Called from . - /// - public virtual void PreUpdate() - { - - } - - /// - /// Called from . - /// - public virtual void PostUpdate() - { - - } - - /// - /// Draw whatever needed to the target here. - /// - /// - public abstract void DrawToTarget(SpriteBatch spriteBatch); - - /// - /// Draw the target here. By default, just draws the target. - /// - /// - public virtual void DrawTarget(SpriteBatch spriteBatch) => spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White); - #endregion + get; + private set; } + #endregion + + #region Methods + protected sealed override void Register() + { + ModTypeLookup.Register(this); + + if (RendererManager.Renderers.Contains(this)) + throw new Exception($"Renderer '{Name}' has already been registered!"); + + RendererManager.Renderers.Add(this); + } + + + public sealed override void SetupContent() => SetStaticDefaults(); + + public sealed override void SetStaticDefaults() + { + if (!Main.dedServ) + { + Main.QueueMainThreadAction(() => + { + MainTarget = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); + }); + } + } + + /// + /// Called from . + /// + public virtual void PreUpdate() + { + + } + + /// + /// Called from . + /// + public virtual void PostUpdate() + { + + } + + /// + /// Draw whatever needed to the target here. + /// + /// + public abstract void DrawToTarget(SpriteBatch spriteBatch); + + /// + /// Draw the target here. By default, just draws the target. + /// + /// + public virtual void DrawTarget(SpriteBatch spriteBatch) => spriteBatch.Draw(MainTarget.Target, Vector2.Zero, Color.White); + #endregion } diff --git a/Graphics/Renderers/CalamityRenderers/DeerclopsShadowRenderer.cs b/Graphics/Renderers/CalamityRenderers/DeerclopsShadowRenderer.cs deleted file mode 100644 index ac4203ca1b..0000000000 --- a/Graphics/Renderers/CalamityRenderers/DeerclopsShadowRenderer.cs +++ /dev/null @@ -1,72 +0,0 @@ -using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Shaders; - -namespace CalamityMod.Graphics.Renderers.CalamityRenderers -{ - public class DeerclopsShadowRenderer : BaseRenderer - { - #region Fields/Properties - - public override DrawLayer Layer => DrawLayer.AfterEverything; - - public static NPC Deerclops => Main.npc[NPC.deerclopsBoss]; - - // Should only draw if not in the main menu, deerclops is active or the border is fading post-death, - // It's rev+ and the boolean for drawing the border is true. - public override bool ShouldDraw => !Main.gameMenu && DeerclopsAI.borderScalar > 0f && DeerclopsAI.shouldDrawEnrageBorder; - #endregion - - #region Methods - public override void DrawToTarget(SpriteBatch spriteBatch) - { - bool shouldDraw; - var deerclopsInactive = false; - if (NPC.deerclopsBoss >= 0 && NPC.deerclopsBoss.WithinBounds(Main.npc.Length)) - { - shouldDraw = Deerclops.HasValidTarget; - } - else - { - shouldDraw = DeerclopsAI.borderScalar > 0f; - deerclopsInactive = true; - } - - if (shouldDraw) - { - var minRadius = DeerclopsAI.innerBorder; - var maxRadius = DeerclopsAI.outerBorder; - - // Begin drawing the shadow - var blackTile = TextureAssets.MagicPixel; - - var shader = GameShaders.Misc["CalamityMod:DeerclopsShadowShader"].Shader; - shader.Parameters["minRadius"].SetValue(minRadius); - shader.Parameters["maxRadius"].SetValue(maxRadius); - shader.Parameters["anchorPoint"].SetValue(DeerclopsAI.lastDeerclopsPosition); - shader.Parameters["screenPosition"].SetValue(Main.screenPosition); - shader.Parameters["screenSize"].SetValue(Main.ScreenSize.ToVector2()); - shader.Parameters["maxOpacity"].SetValue(DeerclopsAI.borderScalar); - - spriteBatch.EnterShaderRegion(BlendState.NonPremultiplied, shader); - Rectangle rekt = new(Main.screenWidth / 2, Main.screenHeight / 2, Main.screenWidth, Main.screenHeight); - spriteBatch.Draw(blackTile.Value, rekt, null, default, 0f, blackTile.Value.Size() * 0.5f, 0, 0f); - - // Shadow drawing complete - spriteBatch.ExitShaderRegion(); - } - - if (deerclopsInactive) - { - // Push the border away and fade out when deerclops is deadge - DeerclopsAI.borderScalar = MathHelper.Clamp(DeerclopsAI.borderScalar - 0.015f, 0f, 1f); - DeerclopsAI.innerBorder += 30f; - DeerclopsAI.outerBorder += 30f; - } - } - #endregion - } -} diff --git a/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs b/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs index 3b4b977c61..60479a2908 100644 --- a/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs +++ b/Graphics/Renderers/CalamityRenderers/DyeableShadersRenderer.cs @@ -1,26 +1,27 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using CalamityMod.DataStructures; +using CalamityMod.Enums; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; -using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Graphics.Renderers.CalamityRenderers { public class DyeableShadersRenderer : BaseRenderer { #region Fields/Properties - public static Dictionary Targets + public static Dictionary Targets { get; private set; } - public static Dictionary Dyes + public static Dictionary Dyes { get; private set; @@ -28,7 +29,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers private static List RenderersToDrawThisFrame; - public override DrawLayer Layer => DrawLayer.Player; + public override GeneralDrawLayer Layer => GeneralDrawLayer.AfterPlayers; // This ignores MainTarget, and handles its own targets, so always call the draw methods. public override bool ShouldDraw => true; @@ -55,65 +56,51 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers } #endregion - #region Detour Stuff - internal static void FindDyesDetour(On_Player.orig_UpdateItemDye orig, Player self, bool isNotInVanitySlot, bool isSetToHidden, Item armorItem, Item dyeItem) + #region Hooks + [Autoload(Side = ModSide.Client)] + private class ItemUpdateHooks : GlobalItem { - orig(self, isNotInVanitySlot, isSetToHidden, armorItem, dyeItem); + public override bool InstancePerEntity => false; - if (Main.dedServ) - return; + public override void UpdateItemDye(Item item, Player player, int dye, bool hideVisual) + { + if (item.ModItem is not IDyeableShaderRenderer drawer) + return; - if (armorItem.ModItem is not IDyeableShaderRenderer drawer) - return; + // Store the dye and player in the slot. + drawer.OwnerPlayer = player?.whoAmI ?? Main.maxPlayers; + Dyes[drawer] = dye; + } - // Store the dye and player in the slot. - drawer.OwnerPlayer = self?.whoAmI ?? Main.maxPlayers; - Dyes[drawer] = GameShaders.Armor.GetShaderFromItemId(dyeItem.type); - } + public override void UpdateVanity(Item item, Player player) + { + CheckIfEquipIsValid(item, false); + } - internal static void CheckVanityDetour(On_Player.orig_ApplyEquipVanity_Item orig, Player self, Item currentItem) - { - orig(self, currentItem); + public override void UpdateAccessory(Item item, Player player, bool hideVisual) + { + CheckIfEquipIsValid(item, hideVisual); + } - if (Main.dedServ) - return; + public override void UpdateArmorSet(Player player, string set) + { + // Check each armor piece in the same manner as tMod. + // If the entire set is equipped, and it is a renderer, it will be marked as valid. + Item head = player.armor[0]; + Item body = player.armor[1]; + Item legs = player.armor[2]; - CheckIfEquipIsValid(currentItem, false); - } - - internal static void CheckAccessoryDetour(On_Player.orig_ApplyEquipFunctional orig, Player self, Item currentItem, bool hideVisual) - { - orig(self, currentItem, hideVisual); - - if (Main.dedServ) - return; - - CheckIfEquipIsValid(currentItem, hideVisual); - } - - internal static void CheckArmorSetsDetour(On_Player.orig_UpdateArmorSets orig, Player self, int i) - { - orig(self, i); - - if (Main.dedServ) - return; - - // Check each armor piece in the same manner as tMod. - // If the entire set is equipped, and it is a renderer, it will be marked as valid. - Item head = self.armor[0]; - Item body = self.armor[1]; - Item legs = self.armor[2]; - - if (head.ModItem != null && head.ModItem.IsArmorSet(head, body, legs) && head.ModItem is IDyeableShaderRenderer renderer) - MarkAsValid(renderer); + if (head.ModItem != null && head.ModItem.IsArmorSet(head, body, legs) && head.ModItem is IDyeableShaderRenderer renderer) + MarkAsValid(renderer); - if (body.ModItem != null && body.ModItem.IsArmorSet(head, body, legs) && body.ModItem is IDyeableShaderRenderer renderer2) - MarkAsValid(renderer2); + if (body.ModItem != null && body.ModItem.IsArmorSet(head, body, legs) && body.ModItem is IDyeableShaderRenderer renderer2) + MarkAsValid(renderer2); - if (legs.ModItem != null && legs.ModItem.IsArmorSet(head, body, legs) && legs.ModItem is IDyeableShaderRenderer renderer3) - MarkAsValid(renderer3); + if (legs.ModItem != null && legs.ModItem.IsArmorSet(head, body, legs) && legs.ModItem is IDyeableShaderRenderer renderer3) + MarkAsValid(renderer3); + } } private static void CheckIfEquipIsValid(Item item, bool hideVisual) @@ -145,7 +132,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers { // If it doesn't have a dictonary entry, create one. if (!Targets.ContainsKey(renderer)) - Main.QueueMainThreadAction(() => Targets[renderer] = new(true, ManagedRenderTarget.CreateScreenSizedTarget)); + Main.QueueMainThreadAction(() => Targets[renderer] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice)); }); // Mark this item as drawable this frame. @@ -178,8 +165,10 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers continue; // Swap to the assosiated target and call the interface method. - target.SwapTo(); - renderer.DrawDyeableShader(spriteBatch); + using (target.Scope(clearColor: Color.Transparent)) + { + renderer.DrawDyeableShader(spriteBatch); + } } } @@ -192,22 +181,24 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers if (RenderersToDrawThisFrame.Count <= 0) return; - var matrix = Main.GameViewMatrix.TransformationMatrix; - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, matrix, () => + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise); + + foreach (var renderer in RenderersToDrawThisFrame) { - foreach (var renderer in RenderersToDrawThisFrame) - { - if (!Targets.TryGetValue(renderer, out var target)) - continue; + if (!Targets.TryGetValue(renderer, out var target)) + continue; - // If it is dyeable, and a dye exists, apply it. This has null safety, as dyeShader can be null here. - if (renderer.ShaderIsDyeable && Dyes.TryGetValue(renderer, out var dyeShader)) - dyeShader?.Apply(null, new(target, Vector2.Zero, new Rectangle(0, 0, target.Width, target.Height), Color.White)); + // If it is dyeable, and a dye exists, apply it. This has null safety, as dyeShader can be null here. + if (renderer.ShaderIsDyeable && Dyes.TryGetValue(renderer, out var dyeID) && dyeID > 0) + GameShaders.Armor.Apply(dyeID, null, new(target.Target, Vector2.Zero, new Rectangle(0, 0, target.Target.Width, target.Target.Height), Color.White)); - // Draw the assosiated target that has been drawn to. - spriteBatch.Draw(target, Vector2.Zero, Color.White with { A = 0 }); - } - }); + // Draw the assosiated target that has been drawn to. + spriteBatch.Draw(target.Target, Vector2.Zero, Color.White with { A = 0 }); + } + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); } #endregion } diff --git a/Graphics/Renderers/CalamityRenderers/HolyInfernoRenderer.cs b/Graphics/Renderers/CalamityRenderers/HolyInfernoRenderer.cs deleted file mode 100644 index 800ad701fe..0000000000 --- a/Graphics/Renderers/CalamityRenderers/HolyInfernoRenderer.cs +++ /dev/null @@ -1,93 +0,0 @@ -using CalamityMod.NPCs; -using CalamityMod.NPCs.Providence; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Graphics.Renderers.CalamityRenderers -{ - public class HolyInfernoRenderer : BaseRenderer - { - #region Fields/Properties - - public override DrawLayer Layer => DrawLayer.BeforeTiles; - - public static Providence Provi - { - get - { - if (!Main.npc.IndexInRange(CalamityGlobalNPC.holyBoss)) - return null; - if (Main.npc[CalamityGlobalNPC.holyBoss].type != ModContent.NPCType()) - return null; - - if (Main.npc[CalamityGlobalNPC.holyBoss].ModNPC is not null && - Main.npc[CalamityGlobalNPC.holyBoss].ModNPC is Providence provi) - return provi; - - return null; - } - } - - //Should only draw if not in the main menu, provi is active and the boolean for drawing the border is true. - public override bool ShouldDraw => !Main.gameMenu && CalamityGlobalNPC.holyBoss != -1 && - Main.npc[CalamityGlobalNPC.holyBoss].active && Providence.shouldDrawInfernoBorder; - #endregion - - #region Methods - public override void DrawToTarget(SpriteBatch spriteBatch) - { - var npc = Main.npc[CalamityGlobalNPC.holyBoss]; - var borderDistance = Providence.borderRadius; - if (!npc.HasValidTarget) - return; - - var target = Main.LocalPlayer; - var holyInfernoIntensity = target.Calamity().holyInfernoFadeIntensity; - var prov = Provi; - if (prov == null) - return; - - //Begin drawing the inferno - var blackTile = TextureAssets.MagicPixel; - var diagonalNoise = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise"); - var upwardPerlinNoise = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Perlin"); - var upwardNoise = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise"); - - var maxOpacity = 1f; - if (prov.Dying) - { - //Death animation timer ends at 345f. - maxOpacity = MathHelper.Lerp(1f, 0f, Utils.GetLerpValue(0f, 344f, prov.DeathAnimationTimer)); - } - - var shader = GameShaders.Misc["CalamityMod:HolyInfernoShader"].Shader; - shader.Parameters["colorMult"].SetValue(Main.IsItDay() ? 7.35f : 7.65f); //I want you to know it took considerable restraint to deliberately misspell colour. - shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); - shader.Parameters["radius"].SetValue(borderDistance); - shader.Parameters["anchorPoint"].SetValue(npc.Center); - shader.Parameters["screenPosition"].SetValue(Main.screenPosition); - shader.Parameters["screenSize"].SetValue(Main.ScreenSize.ToVector2()); - shader.Parameters["burnIntensity"].SetValue(holyInfernoIntensity); - shader.Parameters["playerPosition"].SetValue(target.Center); - shader.Parameters["maxOpacity"].SetValue(maxOpacity); - shader.Parameters["day"].SetValue(Main.IsItDay()); - - spriteBatch.GraphicsDevice.Textures[1] = diagonalNoise.Value; - spriteBatch.GraphicsDevice.Textures[2] = upwardNoise.Value; - spriteBatch.GraphicsDevice.Textures[3] = upwardPerlinNoise.Value; - - //Manual end begin for the sampler state - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, shader, Main.GameViewMatrix.TransformationMatrix); - Rectangle rekt = new(Main.screenWidth / 2, Main.screenHeight / 2, Main.screenWidth, Main.screenHeight); - spriteBatch.Draw(blackTile.Value, rekt, null, default, 0f, blackTile.Value.Size() * 0.5f, 0, 0f); - //Inferno drawing complete - spriteBatch.ExitShaderRegion(); - } - #endregion - } -} diff --git a/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs b/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs deleted file mode 100644 index 98871deb15..0000000000 --- a/Graphics/Renderers/CalamityRenderers/MiracleBlightRenderer.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs; -using CalamityMod.NPCs.ExoMechs.Ares; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Graphics.Renderers.CalamityRenderers -{ - public class MiracleBlightRenderer : BaseRenderer - { - #region Fields/Properties - /// - /// Add NPCs to this if they break with the miracle blight shader. - /// - public static List ExcludedNPCs => new() - { - // List the reason why the NPC(s) are excluded :) - - // The particle sets break with the visuals and this is the easiest way to fix this that isn't stupidly complex. - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType(), - - // Breaks with being behind tiles, and causes a funny interaction where his head goes behind his neck. - NPCID.MoonLordCore, - NPCID.MoonLordHand, - NPCID.MoonLordHead - }; - - /// - /// Used to determine whether the npc should return true in predraw or not, for exclusively drawing to the drawer target. - /// - public static bool ActuallyDoPreDraw - { - get; - private set; - } - - public override DrawLayer Layer => DrawLayer.NPC; - - // Unsure whether its more performant to always draw, or to check if any NPC actually has the debuff. - public override bool ShouldDraw => true; - #endregion - - #region Methods - /// - /// Checks if the provided npc is eligible to be drawn with the miracle blight visual effect. - /// - /// The NPC to check - /// If the NPC is eligible - public static bool ValidToDraw(NPC npc) - { - // Do not draw inactive npcs, or ones with weird MP types less than or equal to 0. - if (!npc.active || npc.type <= NPCID.None) - return false; - - if (!CalamityDrawParameterNPC.DrawingMiracleBlight[npc.whoAmI]) - return false; - - return true; - } - - public override void DrawToTarget(SpriteBatch spriteBatch) - { - // Indicate that NPCs with miracle blight should draw. - ActuallyDoPreDraw = true; - - // Draw every npc to a single target that should have the miracle blight visual. - 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(npc.whoAmI)) - break; - - if (ValidToDraw(npc)) - Main.instance.DrawNPC(npc.whoAmI, npc.behindTiles); - } - - // Indicate that NPCs with miracle blight should no longer draw. - ActuallyDoPreDraw = false; - } - - public override void DrawTarget(SpriteBatch spriteBatch) - { - // Apply the shader and draw the target. - var blightShader = GameShaders.Misc["CalamityMod:MiracleBlight"]; - blightShader.SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"), 1); - blightShader.UseOpacity(0.7f); - blightShader.Apply(); - - Main.spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White); - } - #endregion - } -} diff --git a/Graphics/Renderers/RendererManager.cs b/Graphics/Renderers/RendererManager.cs index a4b0132ce1..225e743a61 100644 --- a/Graphics/Renderers/RendererManager.cs +++ b/Graphics/Renderers/RendererManager.cs @@ -1,9 +1,12 @@ using System.Collections.Generic; using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Graphics.Renderers @@ -24,16 +27,9 @@ namespace CalamityMod.Graphics.Renderers if (Main.dedServ) return; - Main.QueueMainThreadAction(() => - { - // This hooks here, because doing it any sooner causes the screen position to be a frame behind. - On_Main.CheckMonoliths += DrawToTargets; - On_Main.DrawNPCs += DrawNPCRenderers; - On_Main.DrawProjectiles += DrawProjectileRenderers; - On_Main.DrawPlayers_AfterProjectiles += DrawPlayerRenderers; - On_Main.DrawBackgroundBlackFill += DrawBeforeTileRenderers; - On_Main.DrawInfernoRings += DrawAfterEverythingRenderers; - }); + // This hooks here, because doing it any sooner causes the screen position to be a frame behind. + GeneralDrawLayerSystem.OnDrawLayer += DrawRendererAtLayer; + GeneralDrawLayerSystem.OnPrepareDraw += DrawToTargets; } public override void Unload() @@ -43,24 +39,13 @@ namespace CalamityMod.Graphics.Renderers // Clear the cached renderers, so they can be readded on mod loading when initialized. Renderers.Clear(); - - Main.QueueMainThreadAction(() => - { - // Supposed to be auto-unloaded, but considering TMods poor track record with actually doing this, manually unload them. - On_Main.CheckMonoliths -= DrawToTargets; - On_Main.DrawNPCs -= DrawNPCRenderers; - On_Main.DrawProjectiles -= DrawProjectileRenderers; - On_Main.DrawPlayers_AfterProjectiles -= DrawPlayerRenderers; - On_Main.DrawBackgroundBlackFill -= DrawBeforeTileRenderers; - On_Main.DrawInfernoRings -= DrawAfterEverythingRenderers; - }); } #endregion #region Updating public override void PreUpdateEntities() { - if (Main.netMode is NetmodeID.Server) + if (Main.dedServ) return; foreach (var renderer in Renderers) @@ -69,7 +54,7 @@ namespace CalamityMod.Graphics.Renderers public override void PostUpdateEverything() { - if (Main.netMode is NetmodeID.Server) + if (Main.dedServ) return; foreach (var renderer in Renderers) @@ -78,10 +63,22 @@ namespace CalamityMod.Graphics.Renderers #endregion #region Drawing - private void DrawToTargets(On_Main.orig_CheckMonoliths orig) + private static void DrawRendererAtLayer(GeneralDrawLayer drawLayer) { - orig(); + var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer == drawLayer); + if (renderers.Any()) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); + foreach (var renderer in renderers) + renderer.DrawTarget(Main.spriteBatch); + + Main.spriteBatch.End(); + } + } + + private void DrawToTargets() + { if (Main.gameMenu || Main.dedServ) return; @@ -96,91 +93,22 @@ namespace CalamityMod.Graphics.Renderers if (!renderer.ShouldDraw) continue; - var matrix = Main.GameViewMatrix.TransformationMatrix; - Main.spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.AlphaBlend, null, matrix, () => + using (Main.spriteBatch.Scope()) + using (renderer.MainTarget.Scope(clearColor: Color.Transparent)) { - renderer.MainTarget.SwapTo(Color.Transparent); + Main.spriteBatch.Begin( + SpriteSortMode.Deferred, + BlendState.AlphaBlend, + SamplerState.PointClamp, + DepthStencilState.None, + Main.Rasterizer, + null, + Main.GameViewMatrix.TransformationMatrix + ); renderer.DrawToTarget(Main.spriteBatch); - }); + Main.spriteBatch.End(); + } } - - Main.instance.GraphicsDevice.SetRenderTarget(null); - } - - private void DrawNPCRenderers(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) - { - orig(self, behindTiles); - - if (behindTiles) - return; - - var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer is DrawLayer.NPC); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); - - foreach (var renderer in renderers) - renderer.DrawTarget(Main.spriteBatch); - - Main.spriteBatch.ExitShaderRegion(); - } - - private void DrawProjectileRenderers(On_Main.orig_DrawProjectiles orig, Main self) - { - orig(self); - - var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer is DrawLayer.Projectile); - - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); - - foreach (var renderer in renderers) - renderer.DrawTarget(Main.spriteBatch); - - Main.spriteBatch.End(); - } - - private void DrawPlayerRenderers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) - { - orig(self); - - var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer is DrawLayer.Player); - - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); - - foreach (var renderer in renderers) - renderer.DrawTarget(Main.spriteBatch); - - Main.spriteBatch.End(); - } - - private void DrawBeforeTileRenderers(On_Main.orig_DrawBackgroundBlackFill orig, Main self) - { - var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer is DrawLayer.BeforeTiles); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); - - foreach (var renderer in renderers) - renderer.DrawTarget(Main.spriteBatch); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.Transform); - - orig(self); - } - - private void DrawAfterEverythingRenderers(On_Main.orig_DrawInfernoRings orig, Main self) - { - var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer is DrawLayer.AfterEverything); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise); - foreach (var renderer in renderers) - renderer.DrawTarget(Main.spriteBatch); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.Transform); - orig(self); } #endregion } diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs index 5018cee4bb..bb03985b48 100644 --- a/ILEditing/BalancingILChanges.cs +++ b/ILEditing/BalancingILChanges.cs @@ -1,6 +1,8 @@ using System; using CalamityMod.Balancing; using CalamityMod.Enums; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; using Mono.Cecil.Cil; using MonoMod.Cil; using Terraria; @@ -79,17 +81,6 @@ namespace CalamityMod.ILEditing } cursor.Remove(); cursor.Emit(OpCodes.Ldc_R4, 0.5f); // Decrease to 0.5f. - - // CIT 22SEP2024: Removed the edit intended to decrease Frog Leg's jump speed boost, - // as it was not doing anything due to vanilla changing how Frog Leg's jump speed boost is applied. - - // Remove the jump height addition from the Werewolf buff (Moon Charm). - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(2))) - { - LogFailure("Jump Height Boost Fixes", "Could not locate Moon Charm jump height boost value."); - return; - } - cursor.Next.Operand = 0; } private const float VanillaBaseJumpSpeed = 5.01f; @@ -115,16 +106,12 @@ namespace CalamityMod.ILEditing private static void RunSpeedAdjustments(ILContext il) { var cursor = new ILCursor(il); - float asphaltTopSpeedMultiplier = 1.75f; // +75%. Vanilla is +250% + float asphaltTopSpeedMultiplier = 2.25f; // +125%. Vanilla is +250% float asphaltSlowdown = 1f; // Vanilla is 2f. This should actually make asphalt faster. - // Dunerider Boots multiply all run stats by 1.75f in vanilla - float duneRiderBootsMultiplier = 1.25f; // Change to 1.25f - // Multiplied by 0.6 on frozen slime, for +26% acceleration // Multiplied by 0.7 on ice, for +47% acceleration float iceSkateAcceleration = 2.1f; - float iceSkateTopSpeed = 1f; // no boost at all // // ASPHALT @@ -153,22 +140,6 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldc_R4, asphaltSlowdown); } - // - // DUNERIDER BOOTS + SAND BLOCKS - // - { - // Find the multiplier for Dunerider Boots on Sand Blocks. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.75f))) - { - LogFailure("Run Speed Adjustments", "Could not locate the Dunerdier Boots multiplier."); - return; - } - - // Massively reduce the increased speed of Dunerider Boots while on Sand Blocks. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, duneRiderBootsMultiplier); - } - // // ICE SKATES + FROZEN SLIME BLOCKS // @@ -183,17 +154,6 @@ namespace CalamityMod.ILEditing // Massively reduce the acceleration bonus of Ice Skates on Frozen Slime Blocks. cursor.Remove(); cursor.Emit(OpCodes.Ldc_R4, iceSkateAcceleration); - - // Find the top speed multiplier of Ice Skates on Frozen Slime Blocks. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f))) - { - LogFailure("Run Speed Adjustments", "Could not locate Ice Skates + Frozen Slime Block top speed multiplier."); - return; - } - - // Make Ice Skates give no top speed boost whatsoever on Frozen Slime Blocks. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, iceSkateTopSpeed); } // @@ -210,17 +170,6 @@ namespace CalamityMod.ILEditing // Massively reduce the acceleration bonus of Ice Skates on Ice Blocks. cursor.Remove(); cursor.Emit(OpCodes.Ldc_R4, iceSkateAcceleration); - - // Find the top speed multiplier of Ice Skates on Ice Blocks. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f))) - { - LogFailure("Run Speed Adjustments", "Could not locate Ice Skates + Ice Block top speed multiplier."); - return; - } - - // Make Ice Skates give no top speed boost whatsoever on Ice Blocks. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, iceSkateTopSpeed); } } @@ -241,18 +190,7 @@ namespace CalamityMod.ILEditing } 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. + // Second: 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."); @@ -392,84 +330,6 @@ namespace CalamityMod.ILEditing } #endregion - #region Item Prefix Changes - private static void PrefixChanges(On_Player.orig_GrantPrefixBenefits orig, Player self, Item item) - { - orig(self, item); - // Hard / Guarding / Armored / Warding give 0.25% / 0.5% / 0.75% / 1% DR - if (item.prefix == PrefixID.Hard) - { - /* Prehardmode = 1 - * Hardmode = 2 - * Post-Moon Lord = 3 - * Post-DoG = 4 - */ - - if (DownedBossSystem.downedDoG) - self.statDefense += 3; - else if (NPC.downedMoonlord) - self.statDefense += 2; - else if (Main.hardMode) - self.statDefense += 1; - - self.endurance += 0.0025f; - } - if (item.prefix == PrefixID.Guarding) - { - /* Prehardmode = 2 - * Hardmode = 3 - * Post-Moon Lord = 4 - * Post-DoG = 5 - */ - - if (DownedBossSystem.downedDoG) - self.statDefense += 3; - else if (NPC.downedMoonlord) - self.statDefense += 2; - else if (Main.hardMode) - self.statDefense += 1; - - self.endurance += 0.005f; - } - if (item.prefix == PrefixID.Armored) - { - /* Prehardmode = 3 - * Hardmode = 4 - * Post-Moon Lord = 5 - * Post-DoG = 6 - */ - - if (DownedBossSystem.downedDoG) - self.statDefense += 3; - else if (NPC.downedMoonlord) - self.statDefense += 2; - else if (Main.hardMode) - self.statDefense += 1; - - self.endurance += 0.0075f; - } - if (item.prefix == PrefixID.Warding) - { - /* Prehardmode = 4 - * Hardmode = 5 - * Post-Moon Lord = 6 - * Post-DoG = 7 - */ - - if (DownedBossSystem.downedDoG) - self.statDefense += 3; - else if (NPC.downedMoonlord) - self.statDefense += 2; - else if (Main.hardMode) - self.statDefense += 1; - self.endurance += 0.01f; - } - - if (item.prefix == PrefixID.Lucky) - self.Calamity().calamityBonusLuck += 0.05f; - } - #endregion - #region Damage Variance Dampening and Luck Removal private static int AdjustDamageVariance(On_Main.orig_DamageVar_float_int_float orig, float dmg, int percent, float luck) { @@ -501,7 +361,7 @@ namespace CalamityMod.ILEditing private static void VanillaBossResistChanges(ILContext il) { // This IL edit accomplishes two things: - // 1. Reduces Expert+ Eater of Worlds' resist to explosives from 80% to 60%. + // 1. Reduces Expert+ Eater of Worlds' resist to explosives from 80% to 66%. // 2. Effectively removes Lunatic Cultist's resistance to homing projectiles. var cursor = new ILCursor(il); @@ -514,17 +374,15 @@ namespace CalamityMod.ILEditing return; } } - if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchDiv())) + if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdcR4(5f))) { LogFailure("Reduce EoW Grenade Resist", "Could not move to the resist factor."); return; } - // Remove the division instruction, then pop the 5 off the stack to destroy it. Replace it with loading a 0.4 and then multiplying by it. - cursor.Remove(); + // Pop the 5 off the stack, and replace it with a 3. cursor.EmitPop(); - cursor.EmitLdcR4(0.4f); - cursor.EmitMul(); + cursor.EmitLdcR4(3f); // Now, move to the Cultist resist which is right below it. if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdsfld(typeof(ProjectileID.Sets), "CultistIsResistantTo"))) @@ -563,30 +421,13 @@ namespace CalamityMod.ILEditing #region UpdateBuffs Balancing Changes private static void UpdateBuffsBalancingChanges(ILContext il) { - // This IL edit accomplishes four things: - // 1. Nerf Sharpening Station's armor penetration boost from 12 to 5. - // 2. Nerf Beetle Scale Mail's set bonus Beetle Might melee speed from 10% per stack to 5%. - // 3. Nerf Nebula armor's Damage and Life Boosters (Mana Boosters are not handled in this method). - // 4. Remove the ability for Feral Bite to randomly inflict debuffs. + // This IL edit accomplishes three things: + // 1. Nerf Beetle Scale Mail's set bonus Beetle Might melee speed from 10% per stack to 5%. + // 2. Nerf Nebula armor's Damage and Life Boosters (Mana Boosters are not handled in this method). + // 3. Remove the vanilla implementation of Feral Bite inflicting random debuffs. var cursor = new ILCursor(il); - // First, find the code which applies Sharpened's armor penetration buff. - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(BuffID.Sharpened))) - { - LogFailure("Sharpening Station Nerf", "Could not locate the Sharpened buff ID."); - return; - } - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(12f))) // The amount of armor penetration to grant. - { - LogFailure("Sharpening Station Nerf", "Could not locate the amount of armor penetration granted."); - return; - } - - // Replace the value entirely. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, BalancingConstants.SharpeningStationArmorPenetration); - - // Next, move to Beetle Scale Mail's melee speed boost from Beetle Might buff. + // First, move to Beetle Scale Mail's melee speed boost from Beetle Might buff. if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(BuffID.BeetleMight1))) { LogFailure("Beetle Scale Mail Nerf", "Could not locate the Beetle Might buff ID."); @@ -642,7 +483,7 @@ namespace CalamityMod.ILEditing // There are multiple branches pointing to this instruction, so it cannot be removed. Instead, swap its value directly. cursor.Next.Operand = BalancingConstants.NebulaDamagePerBooster; - // Finally, removing Feral Bite's debuffs. + // Finally, removing Feral Bite's vanilla debuff infliction. // Find the random debuff duration multiplier for the debuffs inflicted by Feral Bite. if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.01f))) // The 0.01f random debuff duration multiplier. { @@ -651,23 +492,78 @@ namespace CalamityMod.ILEditing } // Remove and change to 0f, this makes the random debuffs from Feral Bite have 0 duration. + // Calamity reimplements a different version of this in CalamityGlobalBuff.Update cursor.Remove(); cursor.Emit(OpCodes.Ldc_R4, 0f); } #endregion - #region Vortex Booster Keeps Vortex Stealth When Dashing - private static void VortexBoosterKeepsVortexStealthWhenDashing(On_Player.orig_DashMovement orig, Player self) + #region Shield of Cthulhu Buffs + private static void DashMovementEdits(On_Player.orig_DashMovement orig, Player self) { - // Allows for Vortex Booster to automatically re-engage Vortex armor's stealth after a delay when dashing - bool vortexStealth = self.vortexStealthActive; - orig(self); - - if (self.wingsLogic == (int)VanillaWingID.WingsVortex) + //This is a modified version of Vanilla's Shield of Cthulhu dash collision checks + //This is done to be able to adjust values as needed. Here we change the iframe amount and recoil velocity + if (self.dash == 2 && self.eocDash > 0 && self.eocHit < 0) { - if (vortexStealth && !self.vortexStealthActive) - self.Calamity().vortexBoosterStealthDelay = 60; + Rectangle DashHitbox = new Rectangle((int)(self.position.X + self.velocity.X * 0.5 - 4.0), (int)(self.position.Y + self.velocity.Y * 0.5 - 4.0), self.width + 8, self.height + 8); + for (int i = 0; i < 200; i++) + { + NPC hitNPC = Main.npc[i]; + if (!hitNPC.active || hitNPC.dontTakeDamage || hitNPC.friendly || (hitNPC.aiStyle == NPCAIStyleID.Fairy && !(hitNPC.ai[2] <= 1f)) || !self.CanNPCBeHitByPlayerOrPlayerProjectile(hitNPC)) + { + continue; + } + Rectangle npcHitbox = hitNPC.getRect(); + if (DashHitbox.Intersects(npcHitbox) && (hitNPC.noTileCollide || self.CanHit(hitNPC))) + { + float dmg = self.GetTotalDamage(DamageClass.Melee).ApplyTo(self.Calamity().copyrightInfringementShield ? 300f : 30f); + float kb = self.GetTotalKnockback(DamageClass.Melee).ApplyTo(self.Calamity().copyrightInfringementShield ? 12f : 9f); + bool crit = false; + if (Main.rand.Next(100) < self.GetTotalCritChance(DamageClass.Melee)) + { + crit = true; + } + int direction = self.direction; + if (self.velocity.X < 0f) + { + direction = -1; + } + if (self.velocity.X > 0f) + { + direction = 1; + } + self.eocHit = i; + if (self.whoAmI == Main.myPlayer) + { + self.ApplyDamageToNPC(hitNPC, (int)dmg, kb, direction, crit, DamageClass.Melee); + } + self.eocDash = 10; + self.dashDelay = BalancingConstants.OnShieldBonkCooldown; + self.velocity.X = -direction * 9; + self.velocity.Y = -4f; + self.GiveImmuneTimeForCollisionAttack(8); //This is normally 4 in vanilla + int heldDir = 0; + if (self.controlLeft) + heldDir--; + if (self.controlRight) + heldDir++; + int dirSum = Math.Abs(direction + heldDir); + switch (dirSum) + { + case 0: //Holding in direction of recoil + self.velocity.X *= 1.75f; + break; + case 1: //Neutral direction + self.velocity.X *= 1.5f; + break; + case 2: //Holding in direction of enemy + self.velocity.X *= 1.25f; + break; + } + } + } } + orig(self); } #endregion @@ -697,9 +593,9 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldc_I4, (int)VanillaWingID.WingsStardust); cursor.Emit(OpCodes.Bne_Un, label); - cursor.Emit(OpCodes.Ldc_R4, 900f); + cursor.Emit(OpCodes.Ldc_R4, 960f); cursor.Emit(OpCodes.Stloc, 4); - cursor.Emit(OpCodes.Ldc_R4, 900f); + cursor.Emit(OpCodes.Ldc_R4, 960f); cursor.Emit(OpCodes.Stloc, 5); cursor.MarkLabel(label); @@ -719,26 +615,18 @@ namespace CalamityMod.ILEditing } #endregion - #region Solar Wings Change to Solar Flare Armor Dash - private static void SolarWingsDashChange(ILContext il) + #region Solar Wings Change to Solar Flare Armor + private static bool SolarWingsDashChange(On_Player.orig_ConsumeSolarFlare orig, Player self) { - // Make Solar Wings always allow using Solar Flare armor's dash. - var cursor = new ILCursor(il); - - // Genuinely how the fuck is this the only OR opcode in the entire method - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchOr())) + // Solar Wings restore flight time when Solar Flare armor's shield explodes + // This can trigger from either ramming enemies or taking damage + if (orig(self)) { - LogFailure("Solar Dash Change", "Could not locate the OR opcode."); - return; + if (self.wingsLogic == (int)VanillaWingID.WingsSolar) + self.wingTime += 60; + return true; } - - // Add an additional check for if the player is wearing Solar Wings. - cursor.Emit(OpCodes.Ldarg_0); - cursor.Emit(OpCodes.Ldfld, typeof(Player).GetField("wingsLogic")); - cursor.Emit(OpCodes.Ldc_I4, (int)VanillaWingID.WingsSolar); - cursor.EmitCeq(); - // Then OR it. - cursor.EmitOr(); + return false; } #endregion @@ -786,5 +674,17 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.And); } #endregion + + #region Make GFB Nurse Meteor Undodgeable + private static bool GFBNurseMeteorUndodgeable(On_Projectile.orig_IsDamageDodgable orig, Projectile self) + { + // Make the Leviathan meteor that spawns when talking to the Nurse in GFB undodgeable + // Unfortunately the Dodgeable value in HurtModifiers cannot be set in the hook, thus On editing a vanilla function + if (self.type == ModContent.ProjectileType() && self.damage == 9999) + return false; + else + return orig(self); + } + #endregion } } diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 8a366bd53a..0e39b0ffa5 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -1,34 +1,39 @@ -using System; -using System.Reflection; -using CalamityMod.Graphics.Renderers.CalamityRenderers; -using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.DraedonStructures; using CalamityMod.Tiles.FurnitureExo; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; +using Terraria.GameContent.Biomes; using Terraria.GameContent.Drawing; using Terraria.GameContent.Events; using Terraria.GameContent.ItemDropRules; -using Terraria.GameContent.Liquid; using Terraria.GameContent.UI.Elements; using Terraria.GameContent.UI.States; -using Terraria.Graphics.Light; +using Terraria.GameInput; +using Terraria.Graphics.CameraModifiers; using Terraria.Map; using Terraria.ModLoader; namespace CalamityMod.ILEditing { - public partial class ILChanges : ModSystem + public partial class ILChanges : ILoadable { + void ILoadable.Load(Mod mod) + { + ManipulatorManager.ApplyEdits += ApplyEdits; + } + + void ILoadable.Unload() + { + // (2023/07) Manually unloading IL hooks is no longer necessary as TML should automatically do it for you. + // https://discord.com/channels/103110554649894912/445276626352209920/1099856743820959855 (links to TML server) + } + /// /// Loads all IL Editing changes in the mod. /// - public override void OnModLoad() + private static void ApplyEdits(ManipulatorContext ctx) { - // Wrap the vanilla town NPC spawning function in a delegate so that it can be tossed around and called at will. - var updateTime = typeof(Main).GetMethod("UpdateTime_SpawnTownNPCs", BindingFlags.Static | BindingFlags.NonPublic); - VanillaSpawnTownNPCs = Delegate.CreateDelegate(typeof(Action), updateTime) as Action; - // Cache the six lab door tile types for efficiency. labDoorOpen = ModContent.TileType(); labDoorClosed = ModContent.TileType(); @@ -41,17 +46,10 @@ namespace CalamityMod.ILEditing IL_Main.DoDraw += CustomDoDrawChanges; On_Main.DrawCursor += UseCoolFireCursorEffect; On_Main.SortDrawCacheWorms += DrawFusableParticles; - On_Main.DrawInfernoRings += DrawForegroundParticles; On_TileDrawing.Draw += ClearTilePings; On_CommonCode.ModifyItemDropFromNPC += ColorBlightedGel; On_MoonlordDeathDrama.RequestLight += DisableFlashesWithPhotosensitivityConfig; - // Graphics (dyeable shader stuff) - On_Player.UpdateItemDye += DyeableShadersRenderer.FindDyesDetour; - On_Player.ApplyEquipFunctional += DyeableShadersRenderer.CheckAccessoryDetour; - On_Player.ApplyEquipVanity_Item += DyeableShadersRenderer.CheckVanityDetour; - On_Player.UpdateArmorSets += DyeableShadersRenderer.CheckArmorSetsDetour; - // Graphics (ModPlant stuff) IL_TileDrawing.DrawSingleTile += DisableCullingForTreeAndCactus; IL_TileDrawing.DrawTrees += DrawTreeGlowMask; @@ -60,18 +58,19 @@ namespace CalamityMod.ILEditing // NPC behavior IL_Main.UpdateTime += PermitNighttimeTownNPCSpawning; On_Main.UpdateTime_SpawnTownNPCs += AlterTownNPCSpawnRate; - On_NPC.ShouldEmpressBeEnraged += AllowEmpressToEnrageInBossRush; - On_NPC.DoDeathEvents += PreventVanillaBossDeathsInBossRush; + IL_NPC.DoDeathEvents += PreventVanillaBossDeathsInBossRush; + On_NPC.NPCLoot += PreventDiabolistLootLogic; IL_Player.CollectTaxes += MakeTaxCollectorUseful; // Mechanics / features - On_NPC.ApplyTileCollision += AllowTriggeredFallthrough; + On_NPC.ApplyTileCollision += AllowFusionFeederToDigThroughSand; IL_Player.ApplyEquipFunctional += ScopesRequireVisibilityToZoom; IL_Player.Hurt_PlayerDeathReason_int_int_refHurtInfo_bool_bool_int_bool_float_float_float += DodgeMechanicAdjustments; On_Player.PutHallowedArmorSetBonusOnCooldown += AddHolyProtectionCooldown; IL_Player.DashMovement += FixAllDashMechanics; - On_Player.DashMovement += VortexBoosterKeepsVortexStealthWhenDashing; + On_Player.DashMovement += DashMovementEdits; On_Player.DoCommonDashHandle += ApplyDashKeybind; + On_Player.KeyDoubleTap += DisableDoubleTapOnConfig; IL_Player.GiveImmuneTimeForCollisionAttack += MakeShieldSlamIFramesConsistent; IL_Player.Update_NPCCollision += NerfShieldOfCthulhuBonkSafety; On_WorldGen.OpenDoor += OpenDoor_LabDoorOverride; @@ -79,61 +78,23 @@ namespace CalamityMod.ILEditing On_Item.AffixName += IncorporateEnchantmentInAffix; On_Projectile.NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float_float += IncorporateExtraProjectileVariables; On_Player.ApplyDamageToNPC += ApplyOldFashionedDamageToMiscHits; - // TODO -- This should be unnecessary. There is now a TML hook for platform collision for ModNPCs. - On_NPC.Collision_DecideFallThroughPlatforms += EnableCalamityBossPlatformCollision; IL_Wiring.HitWireSingle += AddTwinklersToStatue; - On_Player.UpdateItemDye += FindCalamityItemDyeShader; On_AWorldListItem.GetDifficulty += GetDifficultyOverride; On_Item.GetShimmered += ShimmerEffectEdits; On_Player.Teleport += TPOverride; - On_NPC.SpawnBoss += TripletsSpawnTextOverride; - On_NPC.DoDeathEvents_BeforeLoot += PreventFoveanatorDefeatMessageIfNotKilledLast; - On_NPC.DoDeathEvents_CelebrateBossDeath += TripletsDefeatTextOverride; On_TileDrawing.DrawSingleTile += GlowMaskTileRender; - On_Main.DoUpdate_HandleChat += SpawnPunchCard; On_Player.PlaceThing_CannonBall += AllowCannonJellyfishUse; + On_Player.ItemCheck_ReleaseCritter += ReleaseCritterVariant; + On_Player.IsItemSlotUnlockedAndUsable += MasterModeCelestialOnionCheck; + On_Projectile.AI_007_GrapplingHooks += AllowHooksToGrabArenabox; + On_Collision.SolidCollision_Vector2_int_int += ArenaCollision_Vector2_int_int; + On_Collision.SolidCollision_Vector2_int_int_bool += ArenaCollision_Vector2_int_int_bool; + On_Collision.TileCollision += ArenaCollision_TileCollision; // Mana Burn (Chaos Stone) and Chalice of the Blood God - IL_Player.ApplyLifeAndOrMana += ManaSicknessAndChaliceBufferHeal; - - //LavaStyles - if (ExternalMods.biomeLava == null) - { - //Rendering/Drawing - IL_Main.DoDraw += DoDrawLavas; - IL_Main.RenderWater += RenderLavas; - IL_Main.RenderBackground += RenderLavaBackgrounds; - IL_Main.DrawCapture += DrawLavatoCapture; - IL_TileDrawing.Draw += AddTileLiquidDrawing; - - //Blocking - IL_LiquidRenderer.DrawNormalLiquids += BlockLavaDrawing; - On_TileDrawing.DrawTile_LiquidBehindTile += BlockLavaDrawingForSlopes; - On_TileDrawing.DrawPartialLiquid += BlockLavaDrawingForSlopes2; - On_WaterfallManager.DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects += LavafallRemover; - IL_Main.oldDrawWater += BlockRetroLightingLava; - - //Replacing - IL_LiquidRenderer.InternalPrepareDraw += LavaBubbleReplacer; - IL_TileDrawing.EmitLiquidDrops += LavaDropletReplacer; - IL_NPC.Collision_WaterCollision += SplashEntityLava; - IL_Projectile.Update += SplashEntityLava; - IL_Item.MoveInWorld += SplashEntityLava; - IL_Player.Update += SplashEntityLava; - IL_Player.Update += PlayerDebuffEdit; - - //Other - On_WaterfallManager.Draw += LavaFallRedrawer; - On_WaterfallManager.StylizeColor += WaterfallGlowmaskEditor; - - //Waterfall light - On_WaterfallManager.AddLight += LavafallLightEditor; - } - - // Liquid Lighting and alpha (Liquid Viusuals) - IL_TileLightScanner.GetTileLight += ApplyLiquidEmit; - IL_LiquidRenderer.DrawNormalLiquids += LiquidDrawColors; //Liquid Light - IL_TileDrawing.DrawTile_LiquidBehindTile += LiquidSlopeDrawColors; + IL_Player.ApplyLifeAndOrMana += ChaliceBufferHeal; + On_Player.CheckMana_int_bool_bool += AllowNegativeCheckMana; + On_Player.CheckMana_Item_int_bool_bool += AllowNegativeCheckMana; // Custom grappling On_Player.GrappleMovement += CustomGrappleMovementCheck; @@ -147,45 +108,41 @@ namespace CalamityMod.ILEditing IL_Projectile.Damage += VanillaBossResistChanges; IL_Projectile.AI_099_2 += LimitTerrarianProjectiles; IL_Projectile.AI_120_StardustGuardian += StardustGuardianAttackBuffs; - IL_Player.UpdateArmorSets += SolarWingsDashChange; + On_Player.ConsumeSolarFlare += SolarWingsDashChange; + On_Projectile.IsDamageDodgable += GFBNurseMeteorUndodgeable; IL_Player.UpdateBuffs += UpdateBuffsBalancingChanges; IL_Player.ApplyVanillaHurtEffectModifiers += RemoveBeetleAndSolarFlareMultiplicativeDR; // Movement speed balance IL_Player.UpdateJumpHeight += FixJumpHeightBoosts; - IL_Player.Update += BaseJumpSpeedAdjustment; - IL_Player.Update += RunSpeedAdjustments; - IL_Player.Update += NerfOverpoweredRunAccelerationSources; // Soaring Insignia, Magiluminescence, and Shadow Armor + ctx.PlayerUpdate.Add(BaseJumpSpeedAdjustment); + ctx.PlayerUpdate.Add(RunSpeedAdjustments); + ctx.PlayerUpdate.Add(NerfOverpoweredRunAccelerationSources); // Soaring Insignia, Magiluminescence, and Shadow Armor IL_Player.WingMovement += RemoveSoaringInsigniaInfiniteWingTime; // Life regen and mana regen balance IL_Player.UpdateLifeRegen += UpdateLifeRegenBalancingChanges; IL_Player.UpdateManaRegen += UpdateManaRegenBalancingChanges; - IL_Player.Update += ManaRegenDelayAdjustment; - - // Item prefix changes - On_Player.GrantPrefixBenefits += PrefixChanges; + ctx.PlayerUpdate.Add(ManaRegenDelayAdjustment); // Debuff balancing IL_Projectile.StatusPlayer += RemoveFrozenInflictionFromDeerclopsIceSpikes; // World generation - IL_WorldGen.Pyramid += ReplacePharaohSetInPyramids; IL_WorldGen.GrowLivingTree += BlockLivingTreesNearOcean; On_WorldGen.SmashAltar += PreventSmashAltarCode; IL_WorldGen.hardUpdateWorld += AdjustChlorophyteSpawnRate; IL_WorldGen.Chlorophyte += AdjustChlorophyteSpawnLimits; IL_UIWorldCreation.SetDefaultOptions += ChangeDefaultWorldSize; IL_UIWorldCreation.AddWorldSizeOptions += SwapSmallDescriptionKey; - IL_UIWorldCreation.AddWorldDifficultyOptions += SwapMasterModeDescriptionKey; - Terraria.IO.On_WorldFile.ClearTempTiles += ClearModdedTempTiles; On_WorldGen.MakeDungeon += LimitDungeonEntranceXPosition; IL_WorldGen.DungeonHalls += LimitDungeonHallsXPosition; - IL_WorldGen.MakeDungeon += ChangeDungeonSpikeQuantities; - Terraria.GameContent.Biomes.On_JunglePass.GenerateFinishingTouches += AddStohne; // Removal of vanilla stupidity IL_Player.StatusFromNPC += RemoveExpertBrainRandomDebuffs; + On_NPC.HitEffect_HitInfo += PreventLavaSlimeLavaDrop; + IL_NPC.StrikeNPC_HitInfo_bool_bool += LetDetonatingBubblesTakeDamage; + IL_PunchCameraModifier.Update += PunchCameraUsesScreenshakeConfig; IL_Player.ItemCheck_EmitUseVisuals += MakeMagmaStoneFireGauntletDustToggleable; IL_Projectile.EmitEnchantmentVisualsAt += MakeMagmaStoneFireGauntletProjectileDustToggleable; IL_Sandstorm.HasSufficientWind += DecreaseSandstormWindSpeedRequirement; @@ -193,50 +150,46 @@ namespace CalamityMod.ILEditing On_NPC.SlimeRainSpawns += PreventBossSlimeRainSpawns; On_ShimmerTransforms.IsItemTransformLocked += AdjustShimmerRequirements; On_Projectile.AI_015_Flails += FlailsNoLongerAffectedByPlayerVelocity; + IL_Projectile.AI_061_FishingBobber += WhitelistVictideBobber; + On_Player.ItemCheck_CheckFishingBobbers += PreventVictideBobberFromJamming; IL_Projectile.CanExplodeTile += MakeMeteoriteExplodable; - IL_Main.UpdateWindyDayState += MakeWindyDayMusicPlayLessOften; IL_Main.UpdateTime_StartNight += BloodMoonsRequire200MaxLife; IL_WorldGen.AttemptFossilShattering += PreventFossilShattering; On_Player.GetPickaxeDamage += RemoveHellforgePickaxeRequirement; - IL_Player.Update += PreventUFODismountInWater; - On_Player.GetAnglerReward += ImproveAnglerRewards; + ctx.PlayerUpdate.Add(PreventUFODismountInWater); + + On_Player.GetAnglerReward_MainReward += AddMoreGuaranteedAnglerRewards; + On_Player.GetAnglerReward_Bait += ImproveAnglerBaitReward; + On_Player.GetAnglerReward_Money += ImproveAnglerMoneyReward; IL_Player.TileInteractionsUse += RemovePowerCellPlanteraLock; On_Player.ItemCheck_CheckCanUse += RemoveUseLocks; On_Player.ItemCheck_UseEventItems += ApplyCelestialSigilChanges; IL_Main.DrawInfoAccs += RemoveDamageConditionFromRadar; - On_ShopHelper.ApplyNpcRelationshipEffect += AllowMultipleLikedNPCs; + //On_ShopHelper.ApplyNpcRelationshipEffect += AllowMultipleLikedNPCs; - // Fix vanilla bugs exposed by Calamity mechanics - IL_NPC.NPCLoot += FixSplittingWormBannerDrops; - On_NPC.PlayerInteraction += FixSplittingWormInteraction; + On_Player.UpdateControlHolds += DelayGravity; + On_PlayerInput.SetZoom_MouseInWorld += GravityMouse; + On_Main.DrawPlayerChatBubbles += UI_Unflip_Start; + On_Main.DrawInterface += UI_Unflip_End; // Fix vanilla not accounting for spritebatch modification in held projectile drawing On_PlayerDrawLayers.DrawHeldProj += FixHeldProjectileBlendState; // 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; + // Fix vanilla behaviour of not calling CheckDead for NPCs that realLife is set + IL_NPC.StrikeNPC_HitInfo_bool_bool += EnsureCheckDeadOnSegments; + //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 //Wulfrum armor hooks on Player.KeyDoubleTap and DrawPendingMouseText to activate its set bonus and spoof the mouse text to display the stats of the activated weapon if shift is held //HeldOnlyItem detours Player.dropItemCheck, ItemSlot.Draw (Sb, itemarray, int, int, vector2, color) and ItemSlot.LeftClick_ItemArray to make its stuff work } - - /// - /// Unloads all IL Editing changes in the mod. - /// - public override void OnModUnload() - { - // (2023/07) Manually unloading IL hooks is no longer necessary as TML should automatically do it for you. - // https://discord.com/channels/103110554649894912/445276626352209920/1099856743820959855 (links to TML server) - - VanillaSpawnTownNPCs = null; - labDoorOpen = labDoorClosed = aLabDoorOpen = aLabDoorClosed = exoDoorClosed = exoDoorOpen = -1; - } } } diff --git a/ILEditing/ILHelperMethods.cs b/ILEditing/ILHelperMethods.cs index fe90e30043..09d87c77f9 100644 --- a/ILEditing/ILHelperMethods.cs +++ b/ILEditing/ILHelperMethods.cs @@ -1,14 +1,7 @@ -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Systems; -using CalamityMod.Waters; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework; using MonoMod.Cil; using Terraria; using Terraria.Audio; -using Terraria.Graphics; using Terraria.ID; namespace CalamityMod.ILEditing @@ -65,66 +58,7 @@ namespace CalamityMod.ILEditing return true; } - public static void SelectSulphuricWaterColor(int x, int y, ref VertexColors initialColor, bool isSlope) - { - if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) - { - Color cleanWaterColor = new(10, 62, 193); - Point closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.Keys.OrderBy(t => t.ToVector2().DistanceSQ(new(x, y))).First(); - List points = new() - { - new Vector2(x - 0.5f, y - 0.5f), - new Vector2(x + 0.5f, y - 0.5f), - new Vector2(x - 0.5f, y + 0.5f), - new Vector2(x + 0.5f, y + 0.5f), - }; - - float lerpAmt = (1f - SulphuricWaterSafeZoneSystem.NearbySafeTiles[closestSafeZone]) * 21f; - for (int i = 0; i < 4; i++) - { - float distanceToClosest = points[i].Distance(closestSafeZone.ToVector2()); - float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + lerpAmt, true); - switch (i) - { - case 0: - initialColor.TopLeftColor = Color.Lerp(initialColor.TopLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - case 1: - initialColor.TopRightColor = Color.Lerp(initialColor.TopRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - case 2: - initialColor.BottomLeftColor = Color.Lerp(initialColor.BottomLeftColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - case 3: - initialColor.BottomRightColor = Color.Lerp(initialColor.BottomRightColor, cleanWaterColor, 1f - acidicWaterInterpolant); - break; - - default: - break; - } - } - } - - if (isSlope) - { - initialColor.TopLeftColor *= 1f / 3; - initialColor.TopRightColor *= 1f / 3; - initialColor.BottomLeftColor *= 1f / 3; - initialColor.BottomRightColor *= 1f / 3; - } - else - { - initialColor.TopLeftColor *= 0.4f; - initialColor.TopRightColor *= 0.4f; - initialColor.BottomLeftColor *= 0.4f; - initialColor.BottomRightColor *= 0.4f; - } - } - - public static void DumpToLog(ILContext il) => CalamityMod.Instance.Logger.Debug(il.ToString()); - public static void LogFailure(string name, string reason) => CalamityMod.Instance.Logger.Warn($"IL edit \"{name}\" failed! {reason}"); + public static void DumpToLog(ILContext il) => CalamityMod.Log.Debug(il.ToString()); + public static void LogFailure(string name, string reason) => CalamityMod.Log.ILFailure(name, reason); } } diff --git a/ILEditing/ManipulatorBatch.cs b/ILEditing/ManipulatorBatch.cs new file mode 100644 index 0000000000..e90509debe --- /dev/null +++ b/ILEditing/ManipulatorBatch.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using MonoMod.Cil; + +namespace CalamityMod.ILEditing; + +/// +/// Simple helper object to capture multiple IL edits to apply in a single +/// pass to avoid additional overhead. +/// +/// +/// Since multiple edits are applied at once, a failure from one edit will +/// cause every edit to fail. Use with caution. +/// +internal sealed class ManipulatorBatch : IDisposable +{ + public required Action ManipulatorProvider { get; init; } + + private readonly List manipulators = []; + + /// + /// Adds a manipulator to be applied when this object is disposed. + /// + public void Add(ILContext.Manipulator manipulator) + { + manipulators.Add(manipulator); + } + + /// + /// Applies the queued manipulators. + /// + public void Dispose() + { + var theManipulators = manipulators; + + ManipulatorProvider?.Invoke( + il => + { + foreach (var manipulator in theManipulators) + { + manipulator?.Invoke(il); + } + } + ); + } + + /// + /// Initializes a batch from + /// + /// + /// + public static ManipulatorBatch From(Action manipulatorProvider) + { + ArgumentNullException.ThrowIfNull(manipulatorProvider); + + return new ManipulatorBatch { ManipulatorProvider = manipulatorProvider }; + } +} diff --git a/ILEditing/ManipulatorManager.cs b/ILEditing/ManipulatorManager.cs new file mode 100644 index 0000000000..21d060030a --- /dev/null +++ b/ILEditing/ManipulatorManager.cs @@ -0,0 +1,51 @@ +#nullable enable + +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.ILEditing; + +internal readonly record struct ManipulatorContext( + ManipulatorBatch PlayerUpdate +); + +/// +/// +/// +internal sealed class ManipulatorManager : ModSystem +{ + private static bool hasAppliedEdits; + private static event Action? WrappedApplyEdits; + + public static event Action ApplyEdits + { + add + { + if (hasAppliedEdits) + { + throw new InvalidOperationException("Cannot add to ApplyEdits after edits have already been applied! Call it earlier."); + } + + WrappedApplyEdits += value; + } + + // No reason to actually use this, but we're contractually obligated to. + remove + { + WrappedApplyEdits -= value; + } + } + + public override void OnModLoad() + { + base.OnModLoad(); + + hasAppliedEdits = true; + + using var playerUpdate = ManipulatorBatch.From(manipulator => IL_Player.Update += manipulator); + var ctx = new ManipulatorContext(playerUpdate); + + WrappedApplyEdits?.Invoke(ctx); + } +} diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index 8563814c11..38e435b56e 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -1,15 +1,13 @@ using System; using System.Linq; -using System.Reflection; using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; using CalamityMod.DataStructures; +using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.FluidSimulation; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.Wulfrum; using CalamityMod.Items.Critters; using CalamityMod.Items.Dyes; @@ -18,46 +16,38 @@ using CalamityMod.Items.Potions.Alcohol; using CalamityMod.NPCs; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.Astral; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.DraedonLabThings; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.Packets; using CalamityMod.Particles; using CalamityMod.Projectiles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; +using CalamityMod.Systems.Collections; +using CalamityMod.Systems.Mechanic; using CalamityMod.Tiles; +using CalamityMod.Utilities.Daybreak; using CalamityMod.Walls; -using CalamityMod.Waterfalls; -using CalamityMod.World; +using CalamityMod.Walls.UnsafeWalls; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Mono.Cecil.Cil; using MonoMod.Cil; -using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.Chat; using Terraria.DataStructures; using Terraria.GameContent; -using Terraria.GameContent.Achievements; -using Terraria.GameContent.Biomes; using Terraria.GameContent.Drawing; using Terraria.GameContent.Events; -using Terraria.GameContent.Liquid; using Terraria.GameContent.UI.Elements; using Terraria.GameInput; -using Terraria.Graphics; -using Terraria.Graphics.Capture; using Terraria.Graphics.Light; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.UI.Gamepad; -using Terraria.WorldBuilding; namespace CalamityMod.ILEditing { @@ -70,48 +60,8 @@ namespace CalamityMod.ILEditing private static int exoDoorOpen = -1; private static int exoDoorClosed = -1; - // Holds the vanilla game function which spawns town NPCs, wrapped in a delegate for reflection purposes. - // This function is (optionally) invoked manually in an IL edit to enable NPCs to spawn at night. - private static Action VanillaSpawnTownNPCs; - //private static readonly MethodInfo textureGetValueMethod = typeof(Asset).GetMethod("get_Value", BindingFlags.Public | BindingFlags.Instance); - #region Punch Card Spawning Command - private static void SpawnPunchCard(Terraria.On_Main.orig_DoUpdate_HandleChat orig) - { - // Any of these conditions should result in normal behaviour - if (!Main.drawingPlayerChat || Main.CurrentInputTextTakerOverride != null || Main.editSign || PlayerInput.UsingGamepad) - { - orig(); - return; - } - - // Allow only one pick up of the card this way per player (also don't give it to dead people) - Player player = Main.LocalPlayer; - if (player.Calamity().spawnedPunchCard || player.dead || !player.active) - { - orig(); - return; - } - - // Find 2 specific sets of text from the live chat box (as the player is typing) - // Gives the item to you and abruptly shuts the chat box down if both parts are found - string text = Main.chatText.ToLower(); - string prefix = "Items.Accessories.PunchCard.SpawnText"; - if ((text.Contains(CalamityUtils.GetTextValue($"{prefix}1")) || text.Contains(CalamityUtils.GetTextValue($"{prefix}1Alt"))) && text.Contains(CalamityUtils.GetTextValue($"{prefix}2"))) - { - player.QuickSpawnItem(Player.GetSource_None(), ModContent.ItemType(), 1); - player.Calamity().spawnedPunchCard = true; - Main.chatText = ""; - Main.ClosePlayerChat(); - Main.chatRelease = false; - SoundEngine.PlaySound(SoundID.MenuClose); - return; - } - orig(); - } - #endregion - #region Dash Fixes and Improvements private static void MakeShieldSlamIFramesConsistent(ILContext il) { @@ -159,26 +109,7 @@ namespace CalamityMod.ILEditing // This will occur precisely when the player has no vanilla OR Calamity dash items equipped. cursor.Emit(OpCodes.Or); - // - // SHIELD OF CTHULHU - // - - // Move to Shield of Cthulhu's code by finding its function call for iframes. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCall("GiveImmuneTimeForCollisionAttack"))) - { - LogFailure("Vanilla Dash Fixes", "Could not locate function call for Shield of Cthulhu iframes."); - return; - } - - if (!cursor.TryGotoPrev(MoveType.AfterLabel, i => i.MatchLdcI4(30))) - { - LogFailure("Vanilla Dash Fixes", "Could not locate amount of frames of dash cooldown applied on impact with Shield of Cthulhu."); - return; - } - - // Remove the instruction and replace it with one which gives Calamity's (customizable) amount of dash cooldown. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, BalancingConstants.OnShieldBonkCooldown); + // CIT 22JUL2025: Shield of Cthulhu bonk is reimplemented in a separate On edit; removed the change made to it via this IL edit. // // SOLAR FLARE ARMOR @@ -280,7 +211,7 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldc_I4, 10 - BalancingConstants.ShieldOfCthulhuBonkNoCollideFrames); } - private static void ApplyDashKeybind(Terraria.On_Player.orig_DoCommonDashHandle orig, Player self, out int dir, out bool dashing, Player.DashStartAction dashStartAction) + private static void ApplyDashKeybind(On_Player.orig_DoCommonDashHandle orig, Player self, out int dir, out bool dashing, Player.DashStartAction dashStartAction) { // we feasting multiplayer bugs if (self.whoAmI != Main.myPlayer) @@ -320,7 +251,7 @@ namespace CalamityMod.ILEditing return; } - if (CalamityKeybinds.DashHotkey.GetAssignedKeys().Count == 0) + if (CalamityKeybinds.DashHotkey.GetAssignedKeysOrEmpty().Count == 0) orig(self, out dir, out dashing, dashStartAction); else { @@ -329,50 +260,81 @@ namespace CalamityMod.ILEditing self.dashTime = 0; } } - #endregion - #region Allow Empress to Enrage in Boss Rush - private static bool AllowEmpressToEnrageInBossRush(Terraria.On_NPC.orig_ShouldEmpressBeEnraged orig) + private static void DisableDoubleTapOnConfig(On_Player.orig_KeyDoubleTap orig, Player self, int keyDir) { - if (BossRushEvent.BossRushActive) - return true; + if (self.whoAmI != Main.myPlayer) + { + orig(self, keyDir); + return; + } - return orig(); + if ((CalamityKeybinds.ArmorSetBonusHotKey.GetAssignedKeysOrEmpty().Count != 0 && CalamityClientConfig.Instance.SetBonusDoubleTap == SetBonusDoubleTapOptions.Auto) || CalamityClientConfig.Instance.SetBonusDoubleTap == SetBonusDoubleTapOptions.Off) + return; + + orig(self, keyDir); } #endregion #region Prevent Vanilla Bosses From Being Marked as Defeated in Boss Rush - private static void PreventVanillaBossDeathsInBossRush(On_NPC.orig_DoDeathEvents orig, NPC self, Player closestPlayer) + private static void PreventVanillaBossDeathsInBossRush(ILContext il) { - // Aside from setting the boss' downed bool, DoDeathEvents also handles the following tasks: - // Advancing Slime Rain, spawning Dungeon Spirits, advancing invasion kills, spawning Wall of Flesh's loot box, dropping boss potions and hearts, and sending the boss defeated message. - // The first three do not matter at all in Boss Rush. Wall of Flesh's loot box not spawning is also a positive, so that it doesn't clutter the Underworld. - // Dropping potions is worthless at this point, and Boss Rush is already a horribly balanced hellscape as is, so I'm not worried about hearts. - // As for the last one, well, if anyone actually notices that and cares about it, then I suppose we could make a more sophisticated IL edit. - if (BossRushEvent.BossRushActive) + // GOAL: Prevent vanilla boss defeated flags from getting set during Boss Rush. + // All of this is handled within a switch case directly in the DoDeathEvents function. + // Thus, the objective here is to add a branch past the entire switch case if it is Boss Rush. + var cursor = new ILCursor(il); + + // Move to the point right before the switch case. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall("SpawnOnPlayer"))) + { + LogFailure("Prevent Vanilla Defeated Flags in Boss Rush", "Could not move to before the switch case."); return; + } - orig(self, closestPlayer); + // Define a branch label, load the Boss Rush check, and create the branch if it is true. + var label = il.DefineLabel(); + cursor.Emit(OpCodes.Ldsfld, typeof(BossRushEvent).GetField("BossRushActive")); + cursor.Emit(OpCodes.Brtrue, label); + + // Move to after the switch case to place the label. + for (int i = 0; i < 2; i++) + { + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall("SpawnBoss"))) + { + LogFailure("Prevent Vanilla Defeated Flags in Boss Rush", "Could not move to after the switch case."); + return; + } + } + if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdarg0())) + { + LogFailure("Prevent Vanilla Defeated Flags in Boss Rush", "Could not move to after the switch case."); + return; + } + cursor.MarkLabel(label); } - #endregion Prevent Vanilla Bosses From Being Marked as Defeated in Boss Rush + #endregion - #region Enabling of Triggered NPC Platform Fallthrough - // Why this isn't a mechanism provided by TML itself or vanilla itself is beyond me. - private static void AllowTriggeredFallthrough(Terraria.On_NPC.orig_ApplyTileCollision orig, NPC self, bool fall, Vector2 cPosition, int cWidth, int cHeight) + #region Enabling of Fusion Feeder Sand Digging + private static void AllowFusionFeederToDigThroughSand(On_NPC.orig_ApplyTileCollision orig, NPC self, bool fall, Vector2 cPosition, int cWidth, int cHeight) { if (self.active && self.type == ModContent.NPCType()) { self.velocity = Collision.AdvancedTileCollision(TileID.Sets.ForAdvancedCollision.ForSandshark, cPosition, self.velocity, cWidth, cHeight, fall, fall, 1); return; } - var isNpcValid = self.TryGetGlobalNPC(out CalamityGlobalNPC npc); //why the fuck this errors is anybody's guess, it absolutely shouldn't and yet it does - if (isNpcValid && self.active && npc.ShouldFallThroughPlatforms) - fall = true; - orig(self, fall, cPosition, cWidth, cHeight); } #endregion + #region Prevent Diabolists from Dropping Stuff in GFB Before Plantera + private static void PreventDiabolistLootLogic(On_NPC.orig_NPCLoot orig, NPC self) + { + if (self.type == NPCID.DiabolistWhite && Main.getGoodWorld && !NPC.downedPlantBoss) + return; + orig(self); + } + #endregion + #region Town NPC Spawning Improvements private static void PermitNighttimeTownNPCSpawning(ILContext il) { @@ -381,22 +343,20 @@ namespace CalamityMod.ILEditing var cursor = new ILCursor(il); cursor.EmitDelegate(() => { - // A cached delegate is used here instead of direct reflection for performance reasons - // since UpdateTime is called every frame. if (Main.dayTime || CalamityServerConfig.Instance.TownNPCsSpawnAtNight) - VanillaSpawnTownNPCs(); + Main.UpdateTime_SpawnTownNPCs(); }); - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt
("UpdateTime_SpawnTownNPCs"))) + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt
(nameof(Main.UpdateTime_SpawnTownNPCs)))) { - CalamityMod.Instance.Logger.Warn("Town NPC spawn editing code failed."); + CalamityMod.Log.Warn("Town NPC spawn editing code failed."); return; } cursor.Emit(OpCodes.Ret); } - private static void AlterTownNPCSpawnRate(Terraria.On_Main.orig_UpdateTime_SpawnTownNPCs orig) + private static void AlterTownNPCSpawnRate(On_Main.orig_UpdateTime_SpawnTownNPCs orig) { double oldWorldRate = Main.desiredWorldTilesUpdateRate; Main.desiredWorldTilesUpdateRate *= CalamityServerConfig.Instance.TownNPCSpawnRateMultiplier; @@ -481,7 +441,7 @@ namespace CalamityMod.ILEditing #endregion #region Custom Gate Door Logic - private static bool OpenDoor_LabDoorOverride(Terraria.On_WorldGen.orig_OpenDoor orig, int i, int j, int direction) + private static bool OpenDoor_LabDoorOverride(On_WorldGen.orig_OpenDoor orig, int i, int j, int direction) { Tile tile = Main.tile[i, j]; @@ -497,7 +457,7 @@ namespace CalamityMod.ILEditing return orig(i, j, direction); } - private static bool CloseDoor_LabDoorOverride(Terraria.On_WorldGen.orig_CloseDoor orig, int i, int j, bool forced) + private static bool CloseDoor_LabDoorOverride(On_WorldGen.orig_CloseDoor orig, int i, int j, bool forced) { Tile tile = Main.tile[i, j]; @@ -514,20 +474,8 @@ namespace CalamityMod.ILEditing } #endregion - #region Platform Collision Checks for Grounded Bosses - private static bool EnableCalamityBossPlatformCollision(Terraria.On_NPC.orig_Collision_DecideFallThroughPlatforms orig, NPC self) - { - if ((self.type == ModContent.NPCType() || self.type == ModContent.NPCType() || self.type == ModContent.NPCType() || - self.type == ModContent.NPCType() || self.type == ModContent.NPCType()) && - self.target >= 0 && Main.player[self.target].position.Y > self.position.Y + self.height) - return true; - - return orig(self); - } - #endregion - #region Incorporate Enchantments in Item Names - private static string IncorporateEnchantmentInAffix(Terraria.On_Item.orig_AffixName orig, Item self) + private static string IncorporateEnchantmentInAffix(On_Item.orig_AffixName orig, Item self) { string result = orig(self); @@ -543,7 +491,7 @@ namespace CalamityMod.ILEditing #endregion #region Apply Projectile Variables Upon Creation - private static int IncorporateExtraProjectileVariables(Terraria.On_Projectile.orig_NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float_float orig, IEntitySource spawnSource, float x, float y, float xSpeed, float ySpeed, int type, int damage, float knockback, int owner, float ai0, float ai1, float ai2) + private static int IncorporateExtraProjectileVariables(On_Projectile.orig_NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float_float orig, IEntitySource spawnSource, float x, float y, float xSpeed, float ySpeed, int type, int damage, float knockback, int owner, float ai0, float ai1, float ai2) { // This is unfortunately not something that can be done via SetDefaults since owner is set // after that method is called. Doing it directly when the projectile is spawned appears to be the only reasonable way. @@ -594,7 +542,7 @@ namespace CalamityMod.ILEditing // This only applies to minions spawned by weapon uses, preventing other minions such as Luxor's Gift from exploding if (projectile.minion && spawnSource is EntitySource_ItemUse useSource && useSource.Item is Item weapon && weapon.useAnimation > 0) { - CalamityPlayer.EnchantHeldItemEffects(player, player.Calamity(), player.ActiveItem()); + CalamityPlayer.EnchantHeldItemEffects(player, player.Calamity(), player.HeldItem); if (player.Calamity().explosiveMinionsEnchant) calProj.ExplosiveEnchantCountdown = CalamityGlobalProjectile.ExplosiveEnchantTime; } @@ -611,7 +559,7 @@ namespace CalamityMod.ILEditing #endregion #region Apply Old Fashioned Damage to Miscellanous Hits - private static void ApplyOldFashionedDamageToMiscHits(Terraria.On_Player.orig_ApplyDamageToNPC orig, Player self, NPC npc, int damage, float knockback, int direction, bool crit = false, DamageClass? damageType = null, bool damageVariation = false) + private static void ApplyOldFashionedDamageToMiscHits(On_Player.orig_ApplyDamageToNPC orig, Player self, NPC npc, int damage, float knockback, int direction, bool crit = false, DamageClass? damageType = null, bool damageVariation = false) { if (self.Calamity().oldFashioned) damage = (int)(damage * OldFashioned.DamageBoostMultiplier); @@ -620,7 +568,7 @@ namespace CalamityMod.ILEditing #endregion #region Chaos Stone and Chalice of the Blood God - private static void ManaSicknessAndChaliceBufferHeal(ILContext il) + private static void ChaliceBufferHeal(ILContext il) { ILCursor cursor = new ILCursor(il); @@ -650,7 +598,8 @@ namespace CalamityMod.ILEditing if (modPlayer is null) return; - if (modPlayer.chaliceOfTheBloodGod && modPlayer.chaliceBleedoutBuffer > 0D) + // CIT 17MAY2025: Bleedout clear has a special interaction with Bloom Stone handled elsewhere; do not run this if wearing Bloom Stone + if (modPlayer.chaliceOfTheBloodGod && modPlayer.chaliceBleedoutBuffer > 0D && !modPlayer.bloomStone) { // 20FEB2024: Ozzatron: to prevent abuse, buffer clearing is now 50% of the potion instead of 50% of your buffer float amountOfBleedToClear = ChaliceOfTheBloodGod.HealingPotionRatioForBufferClear * player.GetHealLife(potion, true); @@ -667,36 +616,39 @@ namespace CalamityMod.ILEditing } } }); + } + #endregion - // - // The following section enables Mana Burn for Chaos Stone by conditionally replacing Mana Sickness. - // - - // Start by finding the vanilla code which applies Mana Sickness (buff ID 94). - if (!cursor.TryGotoNext(c => c.MatchLdcI4(BuffID.ManaSickness))) + #region Chaos Stone Mana Burn changes + private static bool AllowNegativeCheckMana(On_Player.orig_CheckMana_int_bool_bool orig, Player self, int amount, bool pay, bool blockQuickMana) + { + if (self.Calamity().ChaosStone) { - LogFailure("Conditionally Replace Mana Sickness", "Could not locate the mana sickness buff ID."); - return; + if (pay) + self.statMana -= amount; + if (self.statMana < -self.statManaMax2) + self.statMana = -self.statManaMax2; + return true; } + return orig(self, amount, pay, blockQuickMana); + } - // Remove the constant buff ID. - cursor.Remove(); - - // Load the player onto the stack for use in the following delegate. - cursor.Emit(OpCodes.Ldarg_0); - - // Emit code which checks for the Chaos Stone. If equipped, the player gets Mana Burn instead of Mana Sickness. - cursor.EmitDelegate>(player => + private static bool AllowNegativeCheckMana(On_Player.orig_CheckMana_Item_int_bool_bool orig, Player self, Item item, int amount, bool pay, bool blockQuickMana) + { + if (self.Calamity().ChaosStone) { - if (!player.active || !player.Calamity().ChaosStone) - return BuffID.ManaSickness; - return ModContent.BuffType(); - }); + if (pay) + self.statMana -= item.mana; + if (self.statMana < -self.statManaMax2) + self.statMana = -self.statManaMax2; + return true; + } + return orig(self, item, amount, pay, blockQuickMana); } #endregion #region Fire Cursor Effect for the Calamity Accessory - private static void UseCoolFireCursorEffect(Terraria.On_Main.orig_DrawCursor orig, Vector2 bonus, bool smart) + private static void UseCoolFireCursorEffect(On_Main.orig_DrawCursor orig, Vector2 bonus, bool smart) { Player player = Main.LocalPlayer; @@ -843,22 +795,12 @@ namespace CalamityMod.ILEditing #region Custom DoDraw Changes private static void CustomDoDrawChanges(ILContext il) { - // This IL edit accomplishes two things: - // 1. Calls a helper function for drawing the fog in the Floral Paradise. - // 2. Allows for drawing additive blend projectiles using IAdditiveDrawer. + // Allows for drawing additive blend projectiles using IAdditiveDrawer. ILCursor cursor = new ILCursor(il); - // First, Floral Paradise fog. + // Move before the place we want to inject code. if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt
("DrawInfernoRings"))) return; - - cursor.EmitDelegate(() => - { - if (!Main.dedServ && BiomeTileCounterSystem.FloralParadiseTiles > 0) - DrawFog(Utils.GetLerpValue(0f, 250f, BiomeTileCounterSystem.FloralParadiseTiles, true)); - }); - - // Then, additive drawing. if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall("Draw"))) return; @@ -883,32 +825,10 @@ namespace CalamityMod.ILEditing Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); }); } - - private static void DrawFog(float intensity) - { - Main.spriteBatch.EnterShaderRegion(); - WaterfallRenderer.DrawWaterfalls(); - - Texture2D fogTexture = ModContent.Request("Terraria/Images/Misc/Perlin").Value; - Vector2 scale = new Vector2(Main.screenWidth, Main.screenHeight) / fogTexture.Size(); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - GameShaders.Misc["CalamityMod:Fog"].UseOpacity(intensity * 0.74f); - GameShaders.Misc["CalamityMod:Fog"].UseColor(Color.Lerp(Color.Lime, Color.Black, 0.85f)); - GameShaders.Misc["CalamityMod:Fog"].UseSaturation(1.67f); - GameShaders.Misc["CalamityMod:Fog"].Shader.Parameters["fogMovementSpeed"].SetValue(1.75f); - GameShaders.Misc["CalamityMod:Fog"].Apply(); - - Main.spriteBatch.Draw(fogTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(); - } #endregion #region General Particle Rendering - private static void DrawFusableParticles(Terraria.On_Main.orig_SortDrawCacheWorms orig, Main self) + private static void DrawFusableParticles(On_Main.orig_SortDrawCacheWorms orig, Main self) { DeathAshParticle.DrawAll(); @@ -918,11 +838,6 @@ namespace CalamityMod.ILEditing orig(self); } - private static void DrawForegroundParticles(Terraria.On_Main.orig_DrawInfernoRings orig, Main self) - { - GeneralParticleHandler.DrawAllParticles(Main.spriteBatch); - orig(self); - } #endregion #region Disable Moon Lord Style Flashes With Photosensitivity Config @@ -936,632 +851,29 @@ namespace CalamityMod.ILEditing } #endregion - #region Lava Style Edits - //Nine Layers of Hell brought to you by LIONEIGHTCAKE!! - //All new liquid rendering for lava can be found in Systems/LavaRendering.cs - - //To save on time, a LOT of the edits are from the BiomeLava mod (owned by myself, lion8cake). Obv every edit has been changed to reflect - //Calamity's style of IL edits and to remove any unnessesary edits not relivant to calamity. In the loading of the detours and edits - //BiomeLava is a check for whether they load or not. If BiomeLava is active all ModLavaStyles will be turned into ModCalls for BiomeLava. - - #region Lava Rendering - private static void DoDrawLavas(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdsfld
("drawToScreen"), i => i.MatchBrfalse(out _), i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchCall
("DrawWaters"))) - { - LogFailure("DoDraw Lava", "Could not locate the drawing of Background Waters"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLavas(isBackground: true); - }); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdsfld
("drawToScreen"), i => i.MatchBrfalse(out _), i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchCall
("DrawWaters"))) - { - LogFailure("DoDraw Lava", "Could not locate the drawing of Waters"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLavas(); - }); - } - - private static void RenderLavas(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchCall
("DrawWaters"))) - { - LogFailure("Render Lava", "Could not locate the drawing of Waters"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLavas(); - }); - } - - private static void RenderLavaBackgrounds(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchCall
("DrawWaters"))) - { - LogFailure("Render Lava Backgroumds", "Could not locate the drawing of Background Waters"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLavas(isBackground: true); - }); - } - - private static void DrawLavatoCapture(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdsfld
("liquidAlpha"), i => i.MatchCall(out _), i => i.MatchStloc2())) - { - LogFailure("Draw lavas to captures", "Could not locate the saving of water alphas"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.LavaAlpha.CopyTo(LavaRenderingSystem.AlphaSave, 0); - }); - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(0), i => i.MatchStloc(34), i => i.MatchBr(out _), i => i.MatchLdloc(34), i => i.MatchLdcI4(1), i => i.MatchBeq(out _))) - { - LogFailure("Draw lavas to captures", "Could not locate the resetting of water alphas"); - return; - } - cursor.EmitLdloc(8); - cursor.EmitDelegate((CaptureBiome biome) => { - for (int i = 0; i < 1; i++) - { - LavaRenderingSystem.LavaAlpha[i] = ((i == LavaRenderingSystem.LavaStyle) ? 1f : 0f); - } - }); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchLdsfld
("waterStyle"), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall
("DrawLiquid"))) - { - LogFailure("Draw lavas to captures", "Could not locate the background of liquid capture drawing"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLiquid(bg: true, LavaRenderingSystem.LavaStyle); - }); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(1), i => i.MatchLdsfld
("bloodMoon"), i => i.MatchBrtrue(out _), i => i.MatchLdloc(8), i => i.MatchLdfld("WaterStyle"), i => i.MatchBr(out _), i => i.MatchLdcI4(9), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall
("DrawLiquid"))) - { - LogFailure("Draw lavas to captures", "Could not locate the second background of liquid capture drawing"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLiquid(bg: true, LavaRenderingSystem.LavaStyle); - }); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchLdsfld
("waterStyle"), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall
("DrawLiquid"))) - { - LogFailure("Draw lavas to captures", "Could not locate the liquid capture drawing"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLiquid(bg: false, LavaRenderingSystem.LavaStyle); - }); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdcI4(0), i => i.MatchLdloc(8), i => i.MatchLdfld("WaterStyle"), i => i.MatchLdcR4(1), i => i.MatchLdcI4(1), i => i.MatchCall
("DrawLiquid"))) - { - LogFailure("Draw lavas to captures", "Could not locate the second liquid capture drawing"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.Instance.DrawLiquid(bg: false, LavaRenderingSystem.LavaStyle); - }); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdloc2(), i => i.MatchStsfld
("liquidAlpha"))) - { - LogFailure("Draw lavas to captures", "Could not locate water style value returner"); - return; - } - cursor.EmitDelegate(() => { - LavaRenderingSystem.AlphaSave.CopyTo(LavaRenderingSystem.LavaAlpha, 0); - }); - } - - private void AddTileLiquidDrawing(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg0(), i => i.MatchLdarg1(), i => i.MatchLdcI4(0), i => i.MatchLdarg(out _), i => i.MatchLdloc1(), i => i.MatchLdloc2(), i => i.MatchLdloc(12), i => i.MatchLdloc(13), i => i.MatchLdloc(14), i => i.MatchCall("DrawTile_LiquidBehindTile"))) - { - LogFailure("Tile Lava Drawing", "Could not locate the drawing of Liquid Behind Tile drawing"); - return; - } - cursor.EmitLdloc1(); - cursor.EmitLdloc2(); - cursor.EmitLdloc(12); - cursor.EmitLdloc(13); - cursor.EmitLdloc(14); - cursor.EmitDelegate((Vector2 unscaledPosition, Vector2 vector, int j, int i, Tile tile) => { - LavaRenderingSystem.Instance.DrawTile_LiquidBehindTile(solidLayer: false, inFrontOfPlayers: false, -1, unscaledPosition, vector, j, i, tile); - }); - } - #endregion - - #region Lava Blocking - private void BlockLavaDrawing(ILContext il) - { - //This edit to DrawNormalLiquids makes lavas in normal and white lighting draw with an alpha and with new textures - //If the parameter for the waterstyle is more than the max waterstyles then its subtracted by the max water style count and thats the lava style ID - ILCursor cursor = new ILCursor(il); - - //Continue if statement, basically - //if the liquid being drawn is lava and the water style is greater than the max water styles or if the liquid is water and less than the max water styles then the draw code is ran - //otherwise the loop/s are continued for the next liquid - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(4), i => i.MatchBr(out _), i => i.MatchLdloc(2), i => i.MatchLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic), "IsVisible"))) - { - LogFailure("Liquid Renderer Drawing", "Could not locate the IsVisible boolean check"); - return; - } - cursor.EmitLdarg3(); - cursor.EmitLdloc2(); //Initiated Liquid Draw Cache (needed for the Type parameter) - cursor.EmitLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type")); - cursor.EmitDelegate>((IsVisible, style, type) => IsVisible && ((type == 1 && style >= LavaRenderingSystem.Instance.WaterStyleMaxCount + 1) || (type != 1 && style <= LavaRenderingSystem.Instance.WaterStyleMaxCount))); - - //Lava alpha color, if the liquid drawn is lava, multiply num by the water alpha - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdloc(2), i => i.MatchLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type")), i => i.MatchStloc(8))) - { - LogFailure("Liquid Renderer Drawing", "Could not locate creation of the local variable num2 (the liquid type holder variable)"); - return; - } - cursor.EmitLdloc(8); - cursor.EmitLdloca(7); - cursor.EmitLdarg(4); - cursor.EmitDelegate((int num2, ref float num, float globalAlpha) => - { - if (num2 == LiquidID.Lava) - { - num *= globalAlpha; - } - }); - - //Conditionally replace the liquid texture whether the liquid is lava or water - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCallvirt(typeof(Asset).GetMethod("get_Value", BindingFlags.Public | BindingFlags.Instance)))) - { - LogFailure("Liquid Renderer Drawing", "Could not locate the Texture2D array of liquids"); - return; - } - cursor.EmitLdarg3(); - cursor.EmitLdloc2(); //Initiated Liquid Draw Cache (needed for the Type parameter) - cursor.EmitLdfld(typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type")); - cursor.EmitDelegate>((initialTexture, style, type) => - (style >= LavaRenderingSystem.Instance.WaterStyleMaxCount + 1 && type == LiquidID.Lava) - ? LavaRenderingSystem.Textures.liquid[style - LavaRenderingSystem.Instance.WaterStyleMaxCount - 1].Value - : initialTexture - ); - } - - private void BlockLavaDrawingForSlopes(On_TileDrawing.orig_DrawTile_LiquidBehindTile orig, TileDrawing self, bool solidLayer, bool inFrontOfPlayers, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY, Tile tileCache) - { - if (tileCache.LiquidType == LiquidID.Lava) - return; - - Tile tile = Main.tile[tileX + 1, tileY]; - if (tile.LiquidType == LiquidID.Lava) - return; - - Tile tile2 = Main.tile[tileX - 1, tileY]; - if (tile2.LiquidType == LiquidID.Lava) - return; - - Tile tile3 = Main.tile[tileX, tileY - 1]; - if (tile3.LiquidType == LiquidID.Lava) - return; - - Tile tile4 = Main.tile[tileX, tileY + 1]; - if (tile4.LiquidType == LiquidID.Lava) - return; - - orig.Invoke(self, solidLayer, inFrontOfPlayers, waterStyleOverride, screenPosition, screenOffset, tileX, tileY, tileCache); - } - - private void BlockLavaDrawingForSlopes2(On_TileDrawing.orig_DrawPartialLiquid orig, TileDrawing self, bool behindBlocks, Tile tileCache, ref Vector2 position, ref Rectangle liquidSize, int liquidType, ref VertexColors colors) - { - if (liquidType == 1) - { - return; - } - orig.Invoke(self, behindBlocks, tileCache, ref position, ref liquidSize, liquidType, ref colors); - } - - private void LavafallRemover(On_WaterfallManager.orig_DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects orig, WaterfallManager self, int waterfallType, int x, int y, float opacity, Vector2 position, Rectangle sourceRect, Color color, SpriteEffects effects) - { - if (waterfallType == 1) - { - return; - } - orig.Invoke(self, waterfallType, x, y, opacity, position, sourceRect, color, effects); - } - - private void BlockRetroLightingLava(ILContext il) - { - ILCursor cursor = new ILCursor(il); - ILLabel target = cursor.DefineLabel(); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCgt(), i => i.MatchLdarg1(), i => i.MatchOr(), i => i.MatchBrfalse(out target))) - { - LogFailure("old Drawing Waters", "Could not locate the if statement that contains the check for liquid types, amounts and wether the liquid has a bg (arg1) or not"); - return; - } - if (target == null) - { - LogFailure("old Drawing Waters", "The BrFalse returned null, the boolean check getting was unsuccessful"); - return; - } - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdindU1(), i => i.MatchSub(), i => i.MatchConvR4(), i => i.MatchStloc(14))) - { - LogFailure("old Drawing Waters", "Could not locate the num3 local variable creation to put the if check after"); - return; - } - cursor.EmitLdloc(12); - cursor.EmitLdloc(11); - cursor.EmitDelegate((int i, int j) => { - return Main.tile[i, j].LiquidType == LiquidID.Lava; - }); - cursor.EmitBrtrue(target); - } - #endregion - - #region Lava Replacing - private void LavaBubbleReplacer(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(16), i => i.MatchLdcI4(16), i => i.MatchLdcI4(35))) - { - LogFailure("Ambient lava bubble replacer", "Could not locate the bubble newdust parameters"); - return; - } - cursor.EmitDelegate>(type => LavaRenderingSystem.dustLava()); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(16), i => i.MatchLdcI4(8), i => i.MatchLdcI4(35))) - { - LogFailure("Ambient lava bubble replacer", "Could not locate the surface bubble newdust parameters"); - return; - } - cursor.EmitDelegate>(type2 => LavaRenderingSystem.dustLava()); - } - - private void LavaDropletReplacer(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdarg(out _), i => i.MatchLdcI4(374), i => i.MatchBneUn(out _), i => i.MatchLdcI4(716))) - { - LogFailure("Ambient lava droplet replacer", "Could not locate the lava droplet newgore parameters"); - return; - } - cursor.EmitDelegate>(type => LavaRenderingSystem.goreLava()); - } - - private void SplashEntityLava(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("width"), i => i.MatchLdcI4(12), i => i.MatchAdd(), i => i.MatchLdcI4(24), i => i.MatchLdcI4(35))) - { - LogFailure("Entity Lava Splashing (Item, Projectile, NPC, Player)", "Could not locate the first lava bubble splashing"); - return; - } - cursor.EmitDelegate>(type => LavaRenderingSystem.dustLava()); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("width"), i => i.MatchLdcI4(12), i => i.MatchAdd(), i => i.MatchLdcI4(24), i => i.MatchLdcI4(35))) - { - LogFailure("Entity Lava Splashing (Item, Projectile, NPC, Player)", "Could not locate the second lava bubble splashing"); - return; - } - cursor.EmitDelegate>(type2 => LavaRenderingSystem.dustLava()); - } - - private void PlayerDebuffEdit(ILContext il) - { - //Injects code directly at the position where the OnFire debuff is handled - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdarg0(), i => i.MatchLdcI4(24), i => i.MatchLdloc(161), i => i.MatchLdcI4(1), i => i.MatchLdcI4(0), i => i.MatchCall("AddBuff"))) - { - LogFailure("Player Update Lava Debuff", "Could not locate the infliction of the On Fire! debuff inside the Player Update code"); - return; - } - cursor.EmitLdarg0(); - cursor.EmitLdloc(161); - cursor.EmitDelegate((Player player, int onFiretime) => - { - LavaStylesLoader.InflictDebuff(player, LavaRenderingSystem.LavaStyle, onFiretime); - }); - } - #endregion - - #region Other - private Color WaterfallGlowmaskEditor(On_WaterfallManager.orig_StylizeColor orig, float alpha, int maxSteps, int waterfallType, int y, int s, Tile tileCache, Color aColor) - { - if (LavaRenderingSystem.LavaStyle != 0 && !LavaStylesLoader.Get(LavaRenderingSystem.LavaStyle).LavafallGlowmask()) - { - return aColor; - } - else - { - return orig.Invoke(alpha, maxSteps, waterfallType, y, s, tileCache, aColor); - } - } - - private void LavaFallRedrawer(On_WaterfallManager.orig_Draw orig, WaterfallManager self, SpriteBatch spriteBatch) - { - orig.Invoke(self, spriteBatch); - LavaRenderingSystem.Instance.InitialDrawLavafall(self); - } - #endregion - - #endregion - - #region Liquid Visuals - //Contains all liquid light and liquid alpha (seethrough-ability) - private static void ApplyLiquidEmit(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchRet())) - { - LogFailure("Liquid Light Emit", "ret instruction is missing????? how is this even possible?????"); - return; - } - - cursor.EmitLdloc0(); // This should be tile - cursor.EmitLdarg1(); // x - cursor.EmitLdarg2(); // y - cursor.EmitLdarg3(); // ref OutputColor - cursor.EmitDelegate((Tile tile, int x, int y, ref Vector3 lightColor) => - { - if (tile.HasTile || tile.LiquidAmount <= 0) - return; - - if (tile.LiquidType == LiquidID.Water) - { - float R = 0f; - float G = 0f; - float B = 0f; - CalamityWaterLoader.ModifyLightSetup(in tile, x, y, Main.waterStyle, ref R, ref G, ref B); - - lightColor.X = Math.Max(lightColor.X, R); - lightColor.Y = Math.Max(lightColor.Y, G); - lightColor.Z = Math.Max(lightColor.Z, B); - } - else if (tile.LiquidType == LiquidID.Lava && ExternalMods.biomeLava == null) - { - Vector3 lavaLight = new Vector3(0.55f, 0.33f, 0.11f); - - float R = LavaRenderingSystem.LavaStyle == 0 ? lavaLight.X : 0f; - float G = LavaRenderingSystem.LavaStyle == 0 ? lavaLight.Y : 0f; - float B = LavaRenderingSystem.LavaStyle == 0 ? lavaLight.Z : 0f; - LavaStylesLoader.ModifyLightSetup(x, y, LavaRenderingSystem.LavaStyle, ref R, ref G, ref B); - - for (int styleIndex = 0; styleIndex < LavaStylesLoader.TotalCount; styleIndex++) - { - if (LavaRenderingSystem.LavaAlpha[styleIndex] > 0f && styleIndex != LavaRenderingSystem.LavaStyle) - { - float r = styleIndex == 0 ? lavaLight.X : 0f; - float g = styleIndex == 0 ? lavaLight.Y : 0f; - float b = styleIndex == 0 ? lavaLight.Z : 0f; - LavaStylesLoader.ModifyLightSetup(x, y, styleIndex, ref r, ref g, ref b); - - float r2 = LavaRenderingSystem.LavaStyle == 0 ? lavaLight.X : 0f; - float g2 = LavaRenderingSystem.LavaStyle == 0 ? lavaLight.Y : 0f; - float b2 = LavaRenderingSystem.LavaStyle == 0 ? lavaLight.Z : 0f; - LavaStylesLoader.ModifyLightSetup(x, y, LavaRenderingSystem.LavaStyle, ref r2, ref g2, ref b2); - - R = float.Lerp(r, r2, LavaRenderingSystem.LavaAlpha[LavaRenderingSystem.LavaStyle]); - G = float.Lerp(g, g2, LavaRenderingSystem.LavaAlpha[LavaRenderingSystem.LavaStyle]); - B = float.Lerp(b, b2, LavaRenderingSystem.LavaAlpha[LavaRenderingSystem.LavaStyle]); - } - } - - if (R != 0.0f || G != 0.0f || B != 0.0f) - { - float colorManipulator = (float)(270 - Main.mouseTextColor) / 900f; - R += colorManipulator; - G += colorManipulator; - B += colorManipulator; - } - - lightColor.X = Math.Max(lightColor.X, R); - lightColor.Y = Math.Max(lightColor.Y, G); - lightColor.Z = Math.Max(lightColor.Z, B); - } - }); - } - - private static void LavafallLightEditor(On_WaterfallManager.orig_AddLight orig, int waterfallType, int x, int y) - { - if (waterfallType == 1) - { - float r = 0.55f; - float g = 0.33f; - float b = 0.11f; - LavaStylesLoader.ModifyLightSetup(x, y, LavaRenderingSystem.LavaStyle, ref r, ref g, ref b); - if (!(r == 0 && g == 0 && b == 0)) - { - float r8; - float num3 = (r8 = (r + (float)(270 - Main.mouseTextColor) / 900f) * 0.4f); - float g8 = num3 * g; - float b8 = num3 * b; - Lighting.AddLight(x, y, r8, g8, b8); - } - return; - } - orig.Invoke(waterfallType, x, y); - } - - private static void LiquidDrawColors(ILContext il) - { - ILCursor cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.Before, c => c.MatchLdarg2(), c => c.MatchLdloc3(), c => c.MatchLdloc(4), c => c.MatchCall
("DrawTileInWater"))) - { - LogFailure("Liquid Draw Colors", "Could not locate the liquid vertex colors for drawing"); - return; - } - - cursor.Emit(OpCodes.Ldloc_3); - cursor.Emit(OpCodes.Ldloc, 4); - cursor.Emit(OpCodes.Ldloc_2); - cursor.Emit(OpCodes.Ldfld, typeof(LiquidRenderer).GetNestedType("LiquidDrawCache", BindingFlags.NonPublic).GetRuntimeField("Type")); - cursor.Emit(OpCodes.Ldloca, 9); - - cursor.EmitDelegate((int x, int y, int liquidType, ref VertexColors initialColor) => - { - if (liquidType == LiquidID.Water) - { - CalamityWaterLoader.DrawColorSetup(x, y, Main.waterStyle, ref initialColor); - } - else if (liquidType == LiquidID.Lava && ExternalMods.biomeLava == null) - { - LavaStylesLoader.DrawColorSetup(x, y, LavaRenderingSystem.LavaStyle, ref initialColor); - } - }); - } - - private static void LiquidSlopeDrawColors(ILContext il) - { - ILCursor cursor = new ILCursor(il); - - var loaderGetMethod = typeof(LoaderManager) - .GetMethod(nameof(LoaderManager.Get)) - .MakeGenericMethod([typeof(WaterStylesLoader)]); - if (loaderGetMethod is null) - { - LogFailure("Liquid Slope Draw Colors", "Cannot find \"LoaderManager.Get\" Method"); - return; - } - - var getTotalCountGetter = typeof(Loader) - .GetProperty("TotalCount", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) - .GetMethod; - if (getTotalCountGetter is null) - { - LogFailure("Liquid Slope Draw Colors", "Cannot find \"Loader.TotalCount (internal)\" Method"); - return; - } - - if (!cursor.TryGotoNext(MoveType.After, - c => c.MatchCall(loaderGetMethod), - c => c.MatchCallOrCallvirt(getTotalCountGetter))) - { - LogFailure("Liquid Slope Draw Colors", "Could not locate the liquid slope vertex colors for drawing"); - return; - } - - // callvirt Loader.TotalCount - // [We are here] - // stloc.s totalCount - - // Starts from callvirt (ret: int) - // Stack now have TotalCount and about to pop by local variable, so: - cursor.EmitLdarg(8); // Push tileCache - cursor.EmitLdarg(6); // Push tileX - cursor.EmitLdarg(7); // Push tileY - cursor.EmitLdloca(14); // Push Color* - cursor.EmitDelegate((Tile tileCache, int x, int y, ref VertexColors initialColor) => - { - // TODO: Properly handle Transition between styles - // That will require extra il injection to achieve - if (tileCache.LiquidType == LiquidID.Water) - CalamityWaterLoader.DrawColorSetup(x, y, Main.waterStyle, ref initialColor, true); - - // Known Issue: Sloped Lava Rendering actually does not work on here! (It's been a case even before edited in 2024/08/30) - // Reason: Flag6 is "IsWater" flag, and since we don't modified that behaviour "yet" it will never be triggered here - // Fix this when there will be new lava style with dynamic color changes - else if (tileCache.LiquidType == LiquidID.Lava) - LavaStylesLoader.DrawColorSetup(x, y, LavaRenderingSystem.LavaStyle, ref initialColor); - }); - - // And now remaining TotalCount is now could pass to local variable - - #region Intended Result for Reference - // callvirt Loader.TotalCount push 1 - // - // ldarg 8 (tileCache) push 1 - // ldarg 6 (tileX) push 1 - // ldarg 7 (tileY) push 1 - // ldloca 14 (vertices) push 1 - // call ModdedDelegate pop 4 - // - // stloc.s totalCount pop 1 - #endregion - } - #endregion - #region Statue Additions - /// - /// Change the following code sequence in Wiring.HitWireSingle - /// num8 = (int) Utils.SelectRandom(Main.rand, new short[2] - /// { - /// 355, - /// 358 - /// }); - /// - /// to - /// - /// var arr = new short[2] - /// { - /// 355, - /// 358 - /// }); - /// arr = arr.ToList().Add(id).ToArray(); - /// num8 = Utils.SelectRandom(Main.rand, arr); - /// - /// - /// private static void AddTwinklersToStatue(ILContext il) { - // obtain a cursor positioned before the first instruction of the method - // the cursor is used for navigating and modifying the il - var c = new ILCursor(il); + // Allow Twinklers to be spawned by the Firefly Statue. + var cursor = new ILCursor(il); - // the exact location for this hook is very complex to search for due to the hook instructions not being unique, and buried deep in control flow - // switch statements are sometimes compiled to if-else chains, and debug builds litter the code with no-ops and redundant locals - - // in general you want to search using structure and function rather than numerical constants which may change across different versions or compile settings - // using local variable indices is almost always a bad idea - - // we can search for - // switch (*) - // case 54: - // Utils.SelectRandom * - - // in general you'd want to look for a specific switch variable, or perhaps the containing switch (type) { case 105: - // but the generated IL is really variable and hard to match in this case - - // we'll just use the fact that there are no other switch statements with case 54, followed by a SelectRandom - - ILLabel[] targets = null; - while (c.TryGotoNext(i => i.MatchSwitch(out targets))) + // Move to the method which randomly selects an NPC for the Statue to spawn. This is the second call of the method in this function. + for (int i = 0; i < 2; i++) { - // some optimising compilers generate a sub so that all the switch cases start at 0 - // ldc.i4.s 51 - // sub - // switch - int offset = 0; - if (c.Prev.MatchSub() && c.Prev.Previous.MatchLdcI4(out offset)) + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCall(typeof(Utils), nameof(Utils.SelectRandom)))) { - ; + LogFailure("Add Twinkler to Firefly Statue", "Could not move to the SelectRandom method."); + return; } - - // get the label for case 54: if it exists - int case54Index = 54 - offset; - if (case54Index < 0 || case54Index >= targets.Length || !(targets[case54Index] is ILLabel target)) - { - continue; - } - - // move the cursor to case 54: - c.GotoLabel(target); - // there's lots of extra checks we could add here to make sure we're at the right spot, such as not encountering any branching instructions - c.GotoNext(i => i.MatchCall(typeof(Utils), nameof(Utils.SelectRandom))); - - // goto next positions us before the instruction we searched for, so we can insert our array modifying code right here - c.EmitDelegate>(arr => - { - // resize the array and add our custom firefly - Array.Resize(ref arr, arr.Length + 1); - arr[arr.Length - 1] = (short)ModContent.NPCType(); - return arr; - }); - - // hook applied successfully - return; } - // couldn't find the right place to insert - throw new Exception("Hook location not found, switch(*) { case 54: ..."); + // Emit a delegate which resizes the array and adds Twinkler to it. + cursor.EmitDelegate>(arr => + { + Array.Resize(ref arr, arr.Length + 1); + arr[arr.Length - 1] = (short)ModContent.NPCType(); + return arr; + }); } #endregion @@ -1569,21 +881,21 @@ namespace CalamityMod.ILEditing private static void MakeTaxCollectorUseful(ILContext il) { ILCursor cursor = new(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall("buyPrice"))) + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall(nameof(Item.buyPrice)))) { LogFailure("Tax Collector Money Boosts", "Could not locate the amount of money to collect per town NPC."); return; } cursor.Emit(OpCodes.Pop); - cursor.Emit(OpCodes.Call, "get_TotalTaxesPerNPC"); + cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalTownNPC.TotalTaxesPerNPC)}"); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall("buyPrice"))) + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall(nameof(Item.buyPrice)))) { LogFailure("Tax Collector Money Boosts", "Could not locate the maximum amount of money to collect."); return; } cursor.Emit(OpCodes.Pop); - cursor.Emit(OpCodes.Call, "get_TaxesToCollectLimit"); + cursor.Emit(OpCodes.Call, $"get_{nameof(CalamityGlobalTownNPC.TaxesToCollectLimit)}"); } #endregion @@ -1621,7 +933,7 @@ namespace CalamityMod.ILEditing /// /// Determines if the custom grapple movement should take place or not. Useful for hooks that only do movement tricks in some cases /// - private static void CustomGrappleMovementCheck(Terraria.On_Player.orig_GrappleMovement orig, Player self) + private static void CustomGrappleMovementCheck(On_Player.orig_GrappleMovement orig, Player self) { WulfrumPackPlayer mp = self.GetModPlayer(); @@ -1634,7 +946,7 @@ namespace CalamityMod.ILEditing /// /// This is called right before the game decides wether or not to update the players velocity based on "real" physics (aka not tongued or hooked or with a pulley) /// - private static void CustomGrapplePreDefaultMovement(Terraria.On_Player.orig_UpdatePettingAnimal orig, Player self) + private static void CustomGrapplePreDefaultMovement(On_Player.orig_UpdatePettingAnimal orig, Player self) { orig(self); @@ -1658,7 +970,7 @@ namespace CalamityMod.ILEditing /// Used before the player steps up a half tile. If we don't do that, players that are grappled but don't use hook movement won't be able to go over tiles. /// The hook cache is reset in PreUpdateMovement ///
- private static void CustomGrapplePreStepUp(Terraria.On_Player.orig_SlopeDownMovement orig, Player self) + private static void CustomGrapplePreStepUp(On_Player.orig_SlopeDownMovement orig, Player self) { orig(self); @@ -1672,9 +984,9 @@ namespace CalamityMod.ILEditing } /// - /// This is done to put the hook if it was cacehd during the frame instruction. + /// This is done to put the hook if it was cached during the frame instruction. /// - private static void CustomGrapplePostFrame(Terraria.On_Player.orig_PlayerFrame orig, Player self) + private static void CustomGrapplePostFrame(On_Player.orig_PlayerFrame orig, Player self) { orig(self); WulfrumPackPlayer mp = self.GetModPlayer(); @@ -1689,16 +1001,6 @@ namespace CalamityMod.ILEditing } #endregion - #region Find Calamity Item Dye Shader - - internal static void FindCalamityItemDyeShader(Terraria.On_Player.orig_UpdateItemDye orig, Player self, bool isNotInVanitySlot, bool isSetToHidden, Item armorItem, Item dyeItem) - { - orig(self, isNotInVanitySlot, isSetToHidden, armorItem, dyeItem); - if (armorItem.type == ModContent.ItemType()) - self.Calamity().CalamityFireDyeShader = GameShaders.Armor.GetShaderFromItemId(dyeItem.type); - } - #endregion - #region Scopes Require Visibility to Zoom private static void ScopesRequireVisibilityToZoom(ILContext il) { @@ -1724,7 +1026,7 @@ namespace CalamityMod.ILEditing #endregion #region Custom world selection difficulties - internal static void GetDifficultyOverride(Terraria.GameContent.UI.Elements.On_AWorldListItem.orig_GetDifficulty orig, AWorldListItem self, out string expertText, out Color gameModeColor) + internal static void GetDifficultyOverride(On_AWorldListItem.orig_GetDifficulty orig, AWorldListItem self, out string expertText, out Color gameModeColor) { // Run the original code and pull out the original text and text color orig(self, out expertText, out gameModeColor); @@ -1759,29 +1061,10 @@ namespace CalamityMod.ILEditing #endregion #region Shimmer effect edits - public static void ShimmerEffectEdits(Terraria.On_Item.orig_GetShimmered orig, Item self) + public static void ShimmerEffectEdits(On_Item.orig_GetShimmered orig, Item self) { - // Don't keep the original stack amount when shimmering Cirrus' Vodka into Crystal Heart Vodka - if (self.type == ModContent.ItemType()) - { - self.SetDefaults(ModContent.ItemType()); - self.shimmered = true; - self.shimmerWet = true; - self.wet = true; - self.velocity *= 0.1f; - if (Main.netMode == 0) - { - Item.ShimmerEffect(self.Center); - } - else - { - NetMessage.SendData(146, -1, -1, null, 0, (int)self.Center.X, (int)self.Center.Y); - NetMessage.SendData(145, -1, -1, null, self.whoAmI, 1f); - } - AchievementsHelper.NotifyProgressionEvent(27); - } // Make Plagued Containment Bricks turn into Plagued Nanodroids if shimmered before defeating Golem - else if (self.type == ModContent.ItemType()) + if (self.type == ModContent.ItemType()) { if (NPC.downedGolemBoss) orig(self); @@ -1794,7 +1077,7 @@ namespace CalamityMod.ILEditing droids.velocity = -self.velocity.RotatedByRandom(MathHelper.Pi / 20f) * 2f; droids.netUpdate = true; droids.shimmerTransparency = 1f; - NetMessage.SendData(146, -1, -1, null, 2, droids.whoAmI); + NetMessage.SendData(MessageID.ShimmerActions, -1, -1, null, 2, droids.whoAmI); } self.TurnToAir(); @@ -1807,8 +1090,8 @@ namespace CalamityMod.ILEditing } else { - NetMessage.SendData(146, -1, -1, null, 0, (int)self.Center.X, (int)self.Center.Y); - NetMessage.SendData(145, -1, -1, null, self.whoAmI, 1f); + NetMessage.SendData(MessageID.ShimmerActions, -1, -1, null, 0, (int)self.Center.X, (int)self.Center.Y); + NetMessage.SendData(MessageID.SyncItemsWithShimmer, -1, -1, null, self.whoAmI, 1f); } } } @@ -1821,7 +1104,7 @@ namespace CalamityMod.ILEditing #region Block Abyss from Teleportation Potions - public static void TPOverride(Terraria.On_Player.orig_Teleport orig, Player self, Vector2 newPos, int Style = 0, int extraInfo = 0) + public static void TPOverride(On_Player.orig_Teleport orig, Player self, Vector2 newPos, int Style = 0, int extraInfo = 0) { // Grab the tile from where the potion wants to teleport Tile t = CalamityUtils.ParanoidTileRetrieval(newPos.ToTileCoordinates().X, newPos.ToTileCoordinates().Y); @@ -1829,7 +1112,7 @@ namespace CalamityMod.ILEditing if (Style == 2) { // Check if it's an Abyss wall - if (t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType()) + if (CalamityTileSets.IsAbyssWall[t.WallType]) { // If an Abyss wall is detected, try to find another teleportation location bool canSpawn = false; @@ -1858,81 +1141,20 @@ namespace CalamityMod.ILEditing // Potion of Return triggers Jared if used in the Abyss if (Style == 8) { - if (t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType() || t.WallType == ModContent.WallType()) + if (CalamityTileSets.IsAbyssWall[t.WallType]) self.AddBuff(BuffID.ChaosState, 2); } } } #endregion - #region Revengeance Master Mode Twins Shenanigans - public static void TripletsSpawnTextOverride(Terraria.On_NPC.orig_SpawnBoss orig, int x, int y, int type, int targetPlayerIndex) - { - if (CalamityWorld.death && type == NPCID.Retinazer) - { - int retinazerIndex = NPC.NewNPC(NPC.GetBossSpawnSource(targetPlayerIndex), x, y, type, 1); - if (retinazerIndex == 200) - { - return; - } - Main.npc[retinazerIndex].target = targetPlayerIndex; - Main.npc[retinazerIndex].timeLeft *= 20; - - if (Main.dedServ && retinazerIndex < 200) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, retinazerIndex); - } - - AchievementsHelper.CheckMechaMayhem(); - - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.TripletsBossText", new Color(175, 75, 255)); - return; - } - else - { - orig(x, y, type, targetPlayerIndex); - } - } - - public static void PreventFoveanatorDefeatMessageIfNotKilledLast(On_NPC.orig_DoDeathEvents_BeforeLoot orig, NPC self, Player closestPlayer) - { - if (CalamityWorld.death && self.type == ModContent.NPCType() && (NPC.AnyNPCs(NPCID.Spazmatism) || NPC.AnyNPCs(NPCID.Retinazer))) - { - self.value = 0f; - self.boss = false; - return; - } - else - { - orig(self, closestPlayer); - } - } - - public static void TripletsDefeatTextOverride(On_NPC.orig_DoDeathEvents_CelebrateBossDeath orig, NPC self, string typeName) - { - bool correctNPCType = self.type == NPCID.Retinazer || self.type == NPCID.Spazmatism || self.type == ModContent.NPCType(); - if (CalamityWorld.death && correctNPCType) - { - if (Main.netMode == NetmodeID.SinglePlayer) - Main.NewText(Language.GetTextValue("Announcement.HasBeenDefeated_Plural", CalamityUtils.GetTextValue("Status.Boss.TripletsDefeatName")), 175, 75, 255); - else if (Main.dedServ) - ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasBeenDefeated_Plural", NetworkText.FromKey("Mods.CalamityMod.Status.Boss.TripletsDefeatName")), new Color(175, 75, 255)); - return; - } - else - { - orig(self, typeName); - } - } - #endregion - #region Optimized GlowMask Rendering on Tile private static void GlowMaskTileRender(On_TileDrawing.orig_DrawSingleTile orig, TileDrawing self, TileDrawInfo drawData, bool solidLayer, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY) { orig(self, drawData, solidLayer, waterStyleOverride, screenPosition, screenOffset, tileX, tileY); var type = drawData.typeCache; - if (type < 0 || type >= GlowMaskTile.LookupLength) + if (type >= GlowMaskTile.LookupLength) return; var glowMaskTile = GlowMaskTile.InstanceLookup[type]; @@ -1990,7 +1212,7 @@ namespace CalamityMod.ILEditing #endregion #region Allow Cannons to use jellyfish - public static void AllowCannonJellyfishUse(Terraria.On_Player.orig_PlaceThing_CannonBall orig, Player self) + public static void AllowCannonJellyfishUse(On_Player.orig_PlaceThing_CannonBall orig, Player self) { // Check if the player is holding a jelly if (self.HeldItem.type == ModContent.ItemType()) @@ -2100,63 +1322,6 @@ namespace CalamityMod.ILEditing } #endregion - #region Add Stohne to the Jungle - public static void AddStohne(Terraria.GameContent.Biomes.On_JunglePass.orig_GenerateFinishingTouches orig, JunglePass self, GenerationProgress progress, int oldX, int oldY) - { - int anchorX = oldX; - int anchorY = oldY; - double worldScale = (double)Main.maxTilesX / 4200.0 * 1.5; - // Generate mud - for (int i = 0; (double)i <= 20.0 * worldScale; i++) - { - progress.Set((60.0 + (double)i / worldScale) * 0.01); - anchorX += WorldGen.genRand.Next((int)(-5.0 * worldScale), (int)(6.0 * worldScale)); - anchorY += WorldGen.genRand.Next((int)(-5.0 * worldScale), (int)(6.0 * worldScale)); - WorldGen.TileRunner(anchorX, anchorY, WorldGen.genRand.Next(40, 100), WorldGen.genRand.Next(300, 500), TileID.Mud); - } - for (int j = 0; (double)j <= 10.0 * worldScale; j++) - { - progress.Set((80.0 + (double)j / worldScale * 2.0) * 0.01); - anchorX = oldX + WorldGen.genRand.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale)); - anchorY = oldY + WorldGen.genRand.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale)); - while (anchorX < 1 || anchorX >= Main.maxTilesX - 1 || anchorY < 1 || anchorY >= Main.maxTilesY - 1 || Main.tile[anchorX, anchorY].TileType != TileID.Mud) - { - anchorX = oldX + WorldGen.genRand.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale)); - anchorY = oldY + WorldGen.genRand.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale)); - } - for (int k = 0; (double)k < 8.0 * worldScale; k++) - { - anchorX += WorldGen.genRand.Next(-30, 31); - anchorY += WorldGen.genRand.Next(-30, 31); - int type = -1; - if (WorldGen.genRand.NextBool(7)) - { - type = -2; - } - WorldGen.TileRunner(anchorX, anchorY, WorldGen.genRand.Next(10, 20), WorldGen.genRand.Next(30, 70), type); - } - } - int stoneType = ModContent.TileType(); - for (int l = 0; (double)l <= 300.0 * worldScale; l++) - { - anchorX = oldX + WorldGen.genRand.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale)); - anchorY = oldY + WorldGen.genRand.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale)); - while (anchorX < 1 || anchorX >= Main.maxTilesX - 1 || anchorY < 1 || anchorY >= Main.maxTilesY - 1 || Main.tile[anchorX, anchorY].TileType != 59) - { - anchorX = oldX + WorldGen.genRand.Next((int)(-600.0 * worldScale), (int)(600.0 * worldScale)); - anchorY = oldY + WorldGen.genRand.Next((int)(-200.0 * worldScale), (int)(200.0 * worldScale)); - } - WorldGen.TileRunner(anchorX, anchorY, WorldGen.genRand.Next(4, 10), WorldGen.genRand.Next(5, 30), stoneType); - // Generate Gems - if (WorldGen.genRand.NextBool(4)) - { - int gem = WorldGen.genRand.Next(63, 69); - WorldGen.TileRunner(anchorX + WorldGen.genRand.Next(-1, 2), anchorY + WorldGen.genRand.Next(-1, 2), WorldGen.genRand.Next(3, 7), WorldGen.genRand.Next(4, 8), gem); - } - } - } - #endregion - #region Hellscape for GlowMask ModPlants #region Tree Trunk / Cactus GlowMask @@ -2287,7 +1452,7 @@ namespace CalamityMod.ILEditing LogFailure("GlowMask Tree Rendering", "Unable to Locate Ldfld for Point::X"); return; } - + if (!cursor.Next.MatchStloc(out var xLocaIdx)) { LogFailure("GlowMask Tree Rendering", "Unable to Locate Stloc Index for Point::X"); @@ -2485,5 +1650,314 @@ namespace CalamityMod.ILEditing #endregion #endregion + + #region Sunken Sea critter variants + public static void ReleaseCritterVariant(On_Player.orig_ItemCheck_ReleaseCritter orig, Player player, Item item) + { + int mouseX = Main.mouseX + (int)Main.screenPosition.X; + int mouseY = Main.mouseY + (int)Main.screenPosition.Y; + int tileX = mouseX / 16; + int tileY = mouseY / 16; + if (item.makeNPC == ModContent.NPCType()) + { + if (!WorldGen.SolidTile(tileX, tileY)) + { + int colorType = (int)BabyGhostBell.JellyColor.Blue; + if (item.type == ModContent.ItemType()) + { + colorType = (int)BabyGhostBell.JellyColor.Green; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)BabyGhostBell.JellyColor.Pink; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)BabyGhostBell.JellyColor.Radiant; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)BabyGhostBell.JellyColor.Gold; + } + player.ApplyItemTime(item); + + if (Main.netMode == NetmodeID.SinglePlayer) + { + int n = NPC.NewNPC(player.GetSource_ReleaseEntity(), mouseX, mouseY, item.makeNPC); + Main.npc[n].ai[1] = colorType; + Main.npc[n].catchItem = item.type; + Main.npc[n].releaseOwner = (short)player.whoAmI; + } + else + { + PlaceAltCritterPacket.Send(player, mouseX, mouseY, item, colorType); + } + } + } + else if (item.makeNPC == ModContent.NPCType()) + { + if (!WorldGen.SolidTile(tileX, tileY)) + { + int colorType = (int)PolypPanasea.FishColor.Red; + if (item.type == ModContent.ItemType()) + { + colorType = (int)PolypPanasea.FishColor.Green; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)PolypPanasea.FishColor.Turquoise; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)PolypPanasea.FishColor.Purple; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)PolypPanasea.FishColor.Radiant; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)PolypPanasea.FishColor.Gold; + } + player.ApplyItemTime(item); + + if (Main.netMode == NetmodeID.SinglePlayer) + { + int n = NPC.NewNPC(player.GetSource_ReleaseEntity(), mouseX, mouseY, item.makeNPC); + Main.npc[n].ai[1] = colorType; + Main.npc[n].catchItem = item.type; + Main.npc[n].releaseOwner = (short)player.whoAmI; + } + else + { + PlaceAltCritterPacket.Send(player, mouseX, mouseY, item, colorType); + } + } + } + else if (item.makeNPC == ModContent.NPCType()) + { + if (!WorldGen.SolidTile(tileX, tileY)) + { + int colorType = (int)PrismaticGuppy.FishColor.Blue; + if (item.type == ModContent.ItemType()) + { + colorType = (int)PrismaticGuppy.FishColor.Green; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)PrismaticGuppy.FishColor.Pink; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)PrismaticGuppy.FishColor.Radiant; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)PrismaticGuppy.FishColor.Gold; + } + + player.ApplyItemTime(item); + + if (Main.netMode == NetmodeID.SinglePlayer) + { + int n = NPC.NewNPC(player.GetSource_ReleaseEntity(), mouseX, mouseY, item.makeNPC); + Main.npc[n].ai[1] = colorType; + Main.npc[n].catchItem = item.type; + Main.npc[n].releaseOwner = (short)player.whoAmI; + } + else + { + PlaceAltCritterPacket.Send(player, mouseX, mouseY, item, colorType); + } + } + } + else if (item.makeNPC == ModContent.NPCType()) + { + if (!WorldGen.SolidTile(tileX, tileY)) + { + int colorType = (int)Slugbun.SlugSkin.Reef; + if (item.type == ModContent.ItemType()) + { + colorType = (int)Slugbun.SlugSkin.Polyp; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)Slugbun.SlugSkin.Burrows; + } + if (item.type == ModContent.ItemType()) + { + colorType = (int)Slugbun.SlugSkin.Radiant; + } + player.ApplyItemTime(item); + + if (Main.netMode == NetmodeID.SinglePlayer) + { + int n = NPC.NewNPC(player.GetSource_ReleaseEntity(), mouseX, mouseY, item.makeNPC, ai1: colorType); + Main.npc[n].catchItem = item.type; + Main.npc[n].releaseOwner = (short)player.whoAmI; + } + else + { + PlaceAltCritterPacket.Send(player, mouseX, mouseY, item, colorType); + } + } + } + else + { + orig(player, item); + } + } + #endregion + + #region Make Celestial Onion give the Master Mode slot + public static bool MasterModeCelestialOnionCheck(On_Player.orig_IsItemSlotUnlockedAndUsable orig, Player self, int slot) + { + if ((slot == 9 || slot == 19) && self.Calamity().extraAccessoryML && !Main.gameMenu) + { + return true; + } + return orig(self, slot); + } + #endregion + + #region Allow Grappling Hooks to grab arena walls + public static void AllowHooksToGrabArenabox(On_Projectile.orig_AI_007_GrapplingHooks orig, Projectile self) + { + if (Main.player[self.owner].dead || Main.player[self.owner].stoned || Main.player[self.owner].webbed || Main.player[self.owner].frozen) + { + self.Kill(); + return; + } + static bool Vector2PointCollision(Vector2 position, Vector2 size, Vector2 point) + { + return (point.X >= position.X && point.X <= position.X + size.X && point.Y >= position.Y && point.Y <= position.Y + size.Y); + } + + bool intersectingWall = false; + if (self.Calamity().arenaBox is not null) + { + var box = self.Calamity().arenaBox; + if (ArenaWallSystem.ActiveBoxes.Contains(box)) + { + self.Center = box.TopLeft + box.Size * self.Calamity().arenaBoxPosition; + } + else + { + self.Calamity().arenaBox = null; + } + } + if (ArenaWallSystem.ActiveBoxes.Count > 0) + { + foreach (var box in ArenaWallSystem.ActiveBoxes) + { + if (!Vector2PointCollision(box.TopLeft, box.Size, self.Center) && Vector2PointCollision(box.TopLeft - new Vector2(box.borderThickness), box.Size + new Vector2(box.borderThickness) * 2, self.Center)) + { + if (self.ai[0] == 0) + { + if (Main.myPlayer == self.owner) + { + if (self.type == ProjectileID.QueenSlimeHook) + { + Main.player[self.owner].DoQueenSlimeHookTeleport(self.Center); + } + NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, self.owner); + } + SoundEngine.PlaySound(SoundID.DD2_EtherianPortalSpawnEnemy with { Volume = 0.75f }, self.Center); + self.ai[0] = 2; + self.velocity = Vector2.Zero; + self.Calamity().arenaBoxPosition = new Vector2(Utils.Remap(self.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, false), Utils.Remap(self.Center.Y, box.TopLeft.Y, box.BottomRight.Y, 0, 1, false)); + self.Calamity().arenaBox = box; + } + if (self.ai[0] == 2) //don't run this if the hook is returning! + { + self.rotation = self.DirectionFrom(Main.player[self.owner].Center).ToRotation() + MathHelper.PiOver2; + intersectingWall = true; + + if (Main.player[self.owner].grapCount < 10) + { + Main.player[self.owner].grappling[Main.player[self.owner].grapCount] = self.whoAmI; + Main.player[self.owner].grapCount++; + } + } + } + } + } + if (!intersectingWall) + orig(self); + } + #endregion + + #region Arena Collision for other things + + private static bool ArenaCollision_Vector2_int_int_bool(On_Collision.orig_SolidCollision_Vector2_int_int_bool orig, Vector2 Position, int Width, int Height, bool acceptTopSurfaces) + { + if (ArenaWallSystem.ActiveBoxes.Count > 0) + { + foreach (var item in ArenaWallSystem.ActiveBoxes) + { + if (item.Vector2PairInWall(Position, new(Width, Height))) + return true; + } + } + return orig(Position, Width, Height, acceptTopSurfaces); + } + + private static bool ArenaCollision_Vector2_int_int(On_Collision.orig_SolidCollision_Vector2_int_int orig, Vector2 Position, int Width, int Height) + { + if (ArenaWallSystem.ActiveBoxes.Count > 0) + { + foreach (var item in ArenaWallSystem.ActiveBoxes) + { + if (item.Vector2PairInWall(Position, new(Width, Height))) + return true; + } + } + return orig(Position, Width, Height); + } + + + private static Vector2 ArenaCollision_TileCollision(On_Collision.orig_TileCollision orig, Vector2 Position, Vector2 Velocity, int Width, int Height, bool fallThrough, bool fall2, int gravDir) + { + Velocity = orig(Position, Velocity, Width, Height, fallThrough, fall2, gravDir); + if (ArenaWallSystem.ActiveBoxes.Count > 0 && Velocity != Vector2.Zero) + { + foreach (var item in ArenaWallSystem.ActiveBoxes) + { + var oldVel = Velocity; + if (item.InnerEffect(Position, new Vector2(Width, Height))) + Velocity = ArenaCollisionLogic(item, Position, Width, Height, Velocity); + var dif = (oldVel - Velocity).Length(); + } + } + return Velocity; + } + + private static Vector2 ArenaCollisionLogic(ArenaWallSystem.Box box, Vector2 Position, int Width, int Height, Vector2 Velocity) + { + var originalVelocity = Velocity; + var originalTopLeft = Position; + var originalBottomRight = Position + new Vector2(Height, Width); + Position += originalVelocity; + + if (Position.X < box.TopLeft.X) + { + Velocity.X = box.TopLeft.X - originalTopLeft.X; + } + if (Position.X + Width > box.BottomRight.X) + { + Velocity.X = box.BottomRight.X - originalBottomRight.X; + } + if (Position.Y < box.TopLeft.Y) + { + Velocity.Y = box.TopLeft.Y - originalTopLeft.Y; + } + + if (Position.Y + Height > box.BottomRight.Y) + { + Velocity.Y = box.BottomRight.Y - originalBottomRight.Y; + } + return Velocity; + } + #endregion } } diff --git a/ILEditing/NetProtectionILChanges.cs b/ILEditing/NetProtectionILChanges.cs index 6ba19e43a5..29d6340bc7 100644 --- a/ILEditing/NetProtectionILChanges.cs +++ b/ILEditing/NetProtectionILChanges.cs @@ -28,7 +28,6 @@ namespace CalamityMod.ILEditing _ModNames = ModLoader.Mods.Select(mod => mod.Name).ToArray(); On_NPC.NewNPC += NewNPCRule; - On_NetMessage.SendData += SendDataRule; } public override void OnModUnload() @@ -40,26 +39,26 @@ namespace CalamityMod.ILEditing { if (Main.netMode == NetmodeID.MultiplayerClient) { - CalamityMod.Instance.Logger.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NPC.NewNPC)} was called from a Multiplayer Client"); - CalamityMod.Instance.Logger.Error(GetSimplifiedStackTrace()); + CalamityMod.Log.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NPC.NewNPC)} was called from a Multiplayer Client"); + CalamityMod.Log.Error(GetSimplifiedStackTrace()); return Main.maxNPCs; } return orig(source, X, Y, Type, Start, ai0, ai1, ai2, ai3, Target); } - private static void SendDataRule(On_NetMessage.orig_SendData orig, int msgType, int remoteClient, int ignoreClient, NetworkText text, int number, float number2, float number3, float number4, int number5, int number6, int number7) + public override bool HijackSendData(int whoAmI, int msgType, int remoteClient, int ignoreClient, NetworkText text, int number, float number2, float number3, float number4, int number5, int number6, int number7) { // Sending SyncNPC as Client will cause Server to not read their bytes // So we simply stop that from happening if (msgType == MessageID.SyncNPC && Main.netMode == NetmodeID.MultiplayerClient) { - CalamityMod.Instance.Logger.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NetMessage.SendData)} ({nameof(MessageID.SyncNPC)}) was called from a Multiplayer Client"); - CalamityMod.Instance.Logger.Error(GetSimplifiedStackTrace()); - return; + CalamityMod.Log.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NetMessage.SendData)} ({nameof(MessageID.SyncNPC)}) was called from a Multiplayer Client"); + CalamityMod.Log.Error(GetSimplifiedStackTrace()); + return true; } - orig(msgType, remoteClient, ignoreClient, text, number, number2, number3, number4, number5, number6, number7); + return base.HijackSendData(whoAmI, msgType, remoteClient, ignoreClient, text, number, number2, number3, number4, number5, number6, number7); } #region Simplified StackTrace Util Method diff --git a/ILEditing/VanillaBugfixingILChanges.cs b/ILEditing/VanillaBugfixingILChanges.cs index 69df735490..ec2e4b5902 100644 --- a/ILEditing/VanillaBugfixingILChanges.cs +++ b/ILEditing/VanillaBugfixingILChanges.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.NPCs; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework.Graphics; using Mono.Cecil.Cil; using MonoMod.Cil; @@ -7,60 +6,15 @@ using Terraria; using Terraria.DataStructures; using Terraria.Graphics.Renderers; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.ILEditing { public partial class ILChanges { - #region Fixing Splitting Worm Banner Spam in Deathmode - // CONTEXT FOR FIX: In Death Mode, normal worms are capable of splitting similarly to the Eater of Worlds. This, as expected, comes with problems with loot dropping, as you can kill multiple - // head segments from the same original worm. TML allows us to safely handle this with its drop hooks. Unfortunately, however, this does not apply to banner dropping logic based on total kills or - // for bestiary registrations. - // As such, we must IL Edit the vanilla drop method to stop it from registering kills based on worms that can still be split. This references the same blocking logic as the aforementioned hooks. - private static void FixSplittingWormBannerDrops(ILContext il) - { - var cursor = new ILCursor(il); - - // Find the first return in the method. This will be marked as a label to jump to if the splitting loot check is failed, effectively terminating any and all - // loot code, including banners and bestiary stuff. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchRet())) - { - LogFailure("Splitting worm banner spam fix", "Could not locate the first method return."); - } - - // Save the ret as a place to return to. - ILLabel ret = cursor.MarkLabel(); - - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(0))) - { - LogFailure("Splitting worm banner spam fix", "Could not locate the closest player storage."); - return; - } - - // Load the NPC caller onto the stack. - cursor.Emit(OpCodes.Ldarg_0); - cursor.EmitDelegate>(npc => CalamityGlobalNPC.SplittingWormLootBlockWrapper(npc, CalamityMod.Instance)); - - // If the block is false (indicating the drop logic should stop), return the method early. - cursor.Emit(OpCodes.Brfalse, ret); - } - #endregion Fixing Splitting Worm Banner Spam in Deathmode - - #region Fixing Splitting Worm Interaction in Deathmode - // CONTEXT FOR FIX: In Death Mode, normal worms are capable of splitting similarly to the Eater of Worlds. This comes with problems with bestiary entries. The entries are incremented only when - // the killed npc is the head segment and it has been interacted at least once. These two conditions may be violated because NPC.NPCLoot only triggers once because of the above fix. - // The fix for former condition is in CalamityGlobalNPCLoot.OnKill. For the latter condition, NPC.PlayerInteraction should broadcast interaction to every other worm segments. - // This is already done for vanilla worm enemies like EOW. - private static void FixSplittingWormInteraction(On_NPC.orig_PlayerInteraction orig, NPC npc, int player) - { - orig(npc, player); - CalamityGlobalNPC.SplittingWormBroadcastInteractionWrapper(npc, player); - } - #endregion - #region Fixing Vanilla Not Accounting For Spritebatch Modification in Held Projectiles private static bool HasLoggedHeldProjectileBlendStateCatch = false; - private void FixHeldProjectileBlendState(On_PlayerDrawLayers.orig_DrawHeldProj orig, PlayerDrawSet drawinfo, Projectile proj) + private static void FixHeldProjectileBlendState(On_PlayerDrawLayers.orig_DrawHeldProj orig, PlayerDrawSet drawinfo, Projectile proj) { orig(drawinfo, proj); @@ -84,13 +38,13 @@ namespace CalamityMod.ILEditing #endregion #region Fix Vanilla Not Accounting For Multiple Bobbers When Fishing With Truffle Worm - private void FixTruffleWormFishing(ILContext il) + private static void FixTruffleWormFishing(ILContext il) { var cursor = new ILCursor(il); // Initialize a flag variable whether truffle worm was used. il.Method.Body.Variables.Add(new VariableDefinition(il.Module.TypeSystem.Boolean)); - byte truffleWormUsed = (byte) (il.Method.Body.Variables.Count - 1); + byte truffleWormUsed = (byte)(il.Method.Body.Variables.Count - 1); cursor.Emit(OpCodes.Ldc_I4_0); cursor.Emit(OpCodes.Stloc_S, truffleWormUsed); @@ -129,5 +83,30 @@ namespace CalamityMod.ILEditing cursor.MarkLabel(loopEnd); } #endregion + + #region Fix Vanilla does not call CheckDead when NPC has realLife + private static void EnsureCheckDeadOnSegments(ILContext il) + { + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.After, + i => i.MatchLdfld(nameof(NPC.realLife)), + i => i.MatchLdelemRef(), + i => i.MatchCallOrCallvirt(nameof(NPC.checkDead)) + )) + { + LogFailure("EnsureCheckDeadOnSegments", "Could not locate the checkDead instruction sets"); + return; + } + + cursor.EmitLdarg0(); + cursor.EmitDelegate((NPC npc) => + { + if (npc.life <= 0 && CalamityNPCSets.DoCheckDeadRegardlessRealLife[npc.type]) + { + NPCLoader.CheckDead(npc); + } + }); + } + #endregion } } diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index d75d3e67bd..8b11dcb9e3 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -4,20 +4,21 @@ using System.Reflection; using CalamityMod.Events; using CalamityMod.Items.Fishing; using CalamityMod.Items.Materials; -using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Walls; +using CalamityMod.World; using Microsoft.Xna.Framework; using Mono.Cecil.Cil; using MonoMod.Cil; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.GameContent.Drawing; -using Terraria.GameContent.Personalities; +using Terraria.GameContent.ItemDropRules; +using Terraria.GameInput; +using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; @@ -25,6 +26,7 @@ namespace CalamityMod.ILEditing { public partial class ILChanges { + [Obsolete("Use 'Main.instance.TilesRenderer.Wind' Instead. This property is included in the Calamity source code only for historic value.", error: true)] public static WindGrid Windgrid { get; @@ -124,10 +126,12 @@ namespace CalamityMod.ILEditing #endregion Reforge Requirement Relaxation #region Prevention of Slime Rain Spawns When Near Bosses - private static void PreventBossSlimeRainSpawns(Terraria.On_NPC.orig_SlimeRainSpawns orig, int plr) + private static void PreventBossSlimeRainSpawns(On_NPC.orig_SlimeRainSpawns orig, int plr) { - if (!Main.player[plr].Calamity().isNearbyBoss && CalamityServerConfig.Instance.BossZen) - orig(plr); + if (CalamityServerConfig.Instance.BossZen && Main.player[plr].Calamity().isNearbyBoss) + return; + + orig(plr); } #endregion Prevention of Slime Rain Spawns When Near Bosses @@ -144,10 +148,93 @@ namespace CalamityMod.ILEditing return; } - // Remove the Expert Mode check, and in its place put a check for the Zenith seed (Get fixed boi). - // Note from CIT: I originally removed these entirely; restoring it in GFB was Fabsol's idea. - cursor.Emit(OpCodes.Pop); - cursor.Emit(OpCodes.Ldsfld, typeof(Main).GetField("zenithWorld")); + // AND with 0, so that Expert Mode is never considered active. + // Calamity implements something more sinister in GFB :) + cursor.Emit(OpCodes.Ldc_I4_0); + cursor.Emit(OpCodes.And); + } + #endregion + + #region Prevent Lava Slime Dropping Lava + private static void PreventLavaSlimeLavaDrop(On_NPC.orig_HitEffect_HitInfo orig, NPC self, NPC.HitInfo hit) + { + if (self.type != NPCID.LavaSlime || !CalamityServerConfig.Instance.RemoveLavaDropsFromLavaSlimes) + { + orig(self, hit); + return; + } + + int tileX = (int)(self.Center.X / 16); + int tileY = (int)(self.Center.Y / 16); + Tile tile = Framing.GetTileSafely(tileX, tileY); + if (tile.LiquidAmount != 0) + { + orig(self, hit); + return; + } + + byte originalAmount = tile.LiquidAmount; + tile.LiquidAmount = 255; + orig(self, hit); + tile.LiquidAmount = originalAmount; + } + #endregion + + #region Disable Detonating Bubble StrikeNPC Hardcoded Override + private static void LetDetonatingBubblesTakeDamage(ILContext il) + { + // In vanilla's StrikeNPC function, Detonating Bubbles have a hardcoded type check which sets the damage of the strike to 0. + // This IL edit disables that type check in Death Mode. + var cursor = new ILCursor(il); + + // Go to the point after the check for the Detonating Bubble NPC ID. + if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdcR8(0.0))) + { + LogFailure("Let Detonating Bubbles Take Damage in Death", "Could not move after the NPC type check."); + return; + } + + // Define the label. + var label = il.DefineLabel(); + + // Add a branch if it is Death Mode. + cursor.Emit(OpCodes.Ldsfld, typeof(CalamityWorld).GetField("death")); + cursor.Emit(OpCodes.Brtrue, label); + + // Move to the point after Detonating Bubble changes are implemented to place the branch label. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStfld("dontTakeDamage"))) + { + LogFailure("Let Detonating Bubbles Take Damage in Death", "Could not move to after the Detonating Bubble logic."); + return; + } + if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdarg0())) + { + LogFailure("Let Detonating Bubbles Take Damage in Death", "Could not move to after the Detonating Bubble logic."); + return; + } + cursor.MarkLabel(label); + } + #endregion + + #region Make PunchCameraModifier Affected by Screenshake Config + private static void PunchCameraUsesScreenshakeConfig(ILContext il) + { + // Allow the screenshake from PunchCameraModifier to scale based on our screenshake power config. + var cursor = new ILCursor(il); + + // There are 3 local variables that control the strength of the screenshake in separate ways, but they all get multiplied together at the end. + // Thus it doesn't matter at all which one is multiplied to. Here I chose num2. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc2())) + { + LogFailure("Make PunchCameraModifier Affected by Screenshake Config", "Could not move to the location to inject code."); + return; + } + + // Emit a delegate which grabs the value of the screenshake config. Then multiply the local variable by it. + cursor.Emit(OpCodes.Ldloc_1); + cursor.EmitDelegate>(() => CalamityClientConfig.Instance.ScreenshakePower); + cursor.Emit(OpCodes.Mul); + cursor.Emit(OpCodes.Stloc_1); } #endregion @@ -175,34 +262,6 @@ namespace CalamityMod.ILEditing } #endregion - #region Make Windy Day Music Play Less Often - private static void MakeWindyDayMusicPlayLessOften(ILContext il) - { - // Make windy day theme only play when the wind speed is over 0.5f instead of 0.4f and make it stop when the wind dies down to below 0.44f instead of 0.34f. - var cursor = new ILCursor(il); - - FieldInfo _minWindField = typeof(Main).GetField("_minWind", BindingFlags.NonPublic | BindingFlags.Static); - - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdsfld(_minWindField))) // The min wind speed check that stops the windy day theme when the wind dies down enough. - { - LogFailure("Make Windy Day Music Play Less Often", "Could not locate the _minWind variable."); - return; - } - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 0.44f); // Change to 0.44f. - - FieldInfo _maxWindField = typeof(Main).GetField("_maxWind", BindingFlags.NonPublic | BindingFlags.Static); - - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdsfld(_maxWindField))) // The max wind speed check that causes the windy day theme to play. - { - LogFailure("Make Windy Day Music Play Less Often", "Could not locate the _maxWind variable."); - return; - } - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 0.5f); // Change to 0.5f. - } - #endregion Make Windy Day Music Play Less Often - #region Change Blood Moon Max HP Requirements private static void BloodMoonsRequire200MaxLife(ILContext il) { @@ -242,13 +301,15 @@ namespace CalamityMod.ILEditing LogFailure("Prevent Fossil Shattering", "Could not locate the Desert Fossil Tile ID variable."); return; } + + // Remove this value and replace it with a large number that will never be a valid tile ID. cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, TileID.PixelBox); // Change to Pixel Box because it cannot be obtained in-game without cheating. + cursor.Emit(OpCodes.Ldc_I4, 40000); } #endregion #region Remove Hellforge Pickaxe Requirement - private static int RemoveHellforgePickaxeRequirement(Terraria.On_Player.orig_GetPickaxeDamage orig, Player self, int x, int y, int pickPower, int hitBufferIndex, Tile tileTarget) + private static int RemoveHellforgePickaxeRequirement(On_Player.orig_GetPickaxeDamage orig, Player self, int x, int y, int pickPower, int hitBufferIndex, Tile tileTarget) { if (tileTarget.TileType == TileID.Hellforge) pickPower = 65; @@ -266,9 +327,58 @@ namespace CalamityMod.ILEditing } #endregion - #region Fix Chlorophyte Crystal Attacking Where it Shouldn't - // TODO -- Finish this - #endregion Fix Chlorophyte Crystal Attacking Where it Shouldn't + #region Allow Victide Bobber to Exist + private static void WhitelistVictideBobber(ILContext il) + { + var cursor = new ILCursor(il); + + // Find the label which skips the "flag = true" that kills the projectile + ILLabel flagStorage = null; + if (!cursor.TryGotoNext(MoveType.After, x => x.MatchBeq(out flagStorage))) + { + LogFailure("Allow Victide Bobber to Exist", "Failed to properly navigate label to direct to"); + return; + } + + // Properly perform the skip if the projectile type is the Victide Bobber + cursor.Emit(OpCodes.Ldarg_0); + cursor.Emit(OpCodes.Ldfld, typeof(Projectile).GetField("type")); + cursor.Emit(OpCodes.Ldc_I4, ModContent.ProjectileType()); + cursor.Emit(OpCodes.Beq_S, flagStorage); + } + #endregion + + #region Prevent Victide Bobber from Jammming + private static bool PreventVictideBobberFromJamming(On_Player.orig_ItemCheck_CheckFishingBobbers orig, Player self, bool canUse) + { + // Run through the original stuff + canUse = orig(self, canUse); + + int bobberCount = 0; + foreach (Projectile proj in Main.ActiveProjectiles) + { + if (proj.active && proj.owner == self.whoAmI && proj.bobber) + { + bobberCount++; + if (proj.type == ModContent.ProjectileType()) + { + // Go back to casting if there's nothing loaded + if (proj.ai[1] == 0f) + proj.ai[0] = 0f; + + // Allow you to still use the fishing rod + canUse = true; + } + } + } + + // Unless.. you have a bobber already that's NOT Victide, then back to disabling + if (canUse && bobberCount > 1) + canUse = false; + + return canUse; + } + #endregion #region Prevent UFO Mount from Dismounting in Water private static void PreventUFODismountInWater(ILContext il) @@ -302,7 +412,7 @@ namespace CalamityMod.ILEditing #endregion Prevent UFO Mount from Dismounting in Water #region Color Blighted Gel - private static void ColorBlightedGel(Terraria.GameContent.ItemDropRules.On_CommonCode.orig_ModifyItemDropFromNPC orig, NPC npc, int itemIndex) + private static void ColorBlightedGel(On_CommonCode.orig_ModifyItemDropFromNPC orig, NPC npc, int itemIndex) { orig(npc, itemIndex); @@ -328,628 +438,134 @@ namespace CalamityMod.ILEditing #endregion Color Blighted Gel #region Improve Angler Quest Rewards - private static void ImproveAnglerRewards(Terraria.On_Player.orig_GetAnglerReward orig, Player self, NPC angler, int questItemType) + private static void AddMoreGuaranteedAnglerRewards(On_Player.orig_GetAnglerReward_MainReward orig, Player self, List rewardItems, IEntitySource source, int questsDone, float rarityReduction, int questItemType, ref GetItemSettings anglerRewardSettings) { - orig(self, angler, questItemType); - - EntitySource_Gift source = new EntitySource_Gift(angler); - int questsDone = self.anglerQuestsFinished; - float rarityReduction = 1f; - rarityReduction = (questsDone <= 50) ? (rarityReduction - questsDone * 0.01f) : ((questsDone <= 100) ? (0.5f - (questsDone - 50) * 0.005f) : ((questsDone > 150) ? 0.15f : (0.25f - (questsDone - 100) * 0.002f))); - rarityReduction *= 0.9f; - rarityReduction *= (float)(self.currentShoppingSettings.PriceAdjustment + 1.0) / 2f; - - if (rarityReduction < 0.1f) - rarityReduction = 0.1f; - - List rewardItems = new List(); - - GetItemSettings anglerRewardSettings = GetItemSettings.NPCEntityToPlayerInventorySettings; - + // Adds several new guaranteed rewards for specific quests. + // These will replace the item that would have dropped via vanilla logic. Item item = new Item(); + item.type = ItemID.None; + List checkingList = []; - // GUARANTEED REWARDS - - // BAIT switch (questsDone) { - case 0: - case 1: - case 2: - case 3: - case 4: - item = new Item(); - item.SetDefaults(ItemID.Stinkbug); - item.stack = Main.rand.Next(2, 6); + case 3: // High Test Fishing Line + checkingList.Add(ItemID.HighTestFishingLine); + if (self.DropAnglerAccByMissing(checkingList, 1f, out _, out int highTest)) + item.SetDefaults(highTest); break; - - case 5: - case 6: - case 7: - case 8: - case 9: - item = new Item(); - item.SetDefaults(ItemID.ApprenticeBait); - item.stack = Main.rand.Next(2, 6); + case 6: // Fisherman's Pocket Guide + checkingList.Add(ItemID.FishermansGuide); + if (self.DropAnglerAccByMissing(checkingList, 1f, out _, out int fishGuide)) + item.SetDefaults(fishGuide); break; - - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - item = new Item(); - item.SetDefaults(Main.rand.NextBool() ? ItemID.Worm : ItemID.Maggot); - item.stack = Main.rand.Next(2, 6); + case 10: // Angler armor + Item vest = new Item(ItemID.AnglerVest); // Vanilla has a guaranteed reward for Angler Hat here. Calamity makes the other two pieces drop as well. + rewardItems.Add(vest); + Item pants = new Item(ItemID.AnglerPants); // This intentionally does not set the item variable, to allow vanilla logic to drop the Angler Hat. + rewardItems.Add(pants); break; - - case 16: - case 17: - case 18: - case 19: - case 20: - item = new Item(); - item.SetDefaults(ItemID.JourneymanBait); - item.stack = Main.rand.Next(2, 6); + case 11: // Weather Radio + checkingList.Add(ItemID.WeatherRadio); + if (self.DropAnglerAccByMissing(checkingList, 1f, out _, out int radio)) + item.SetDefaults(radio); break; - - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - item = new Item(); - item.SetDefaults(Main.rand.NextBool() ? ItemID.EnchantedNightcrawler : ItemID.Buggy); - item.stack = Main.rand.Next(2, 6); + case 14: // Sextant + checkingList.Add(ItemID.Sextant); + if (self.DropAnglerAccByMissing(checkingList, 1f, out _, out int sextant)) + item.SetDefaults(sextant); break; - - case 27: - case 28: - case 29: - case 30: - item = new Item(); - item.SetDefaults(ItemID.MasterBait); - item.stack = Main.rand.Next(2, 6); + case 15: // Tackle Box + checkingList.Add(ItemID.TackleBox); + if (self.DropAnglerAccByMissing(checkingList, 1f, out _, out int tackle)) + item.SetDefaults(tackle); break; - - default: - item = new Item(); - item.SetDefaults(ModContent.ItemType()); - item.stack = Main.rand.Next(2, 6); + case 20: // Angler Earring + checkingList.Add(ItemID.AnglerEarring); + if (self.DropAnglerAccByMissing(checkingList, 1f, out _, out int earring)) + item.SetDefaults(earring); break; - } - - item.position = self.Center; - Item item2 = self.GetItem(self.whoAmI, item, anglerRewardSettings); - rewardItems.Add(item2); - - // COINS - switch (questsDone) - { - case 0: - case 1: - case 2: - case 3: - case 4: - item = new Item(); - item.SetDefaults(ItemID.GoldCoin); - break; - - case 5: - case 6: - case 7: - case 8: - case 9: - item = new Item(); - item.SetDefaults(ItemID.GoldCoin); - item.stack = 2; - item = new Item(); - item.SetDefaults(ItemID.SilverCoin); - item.stack = 50; - break; - - case 10: - case 11: - case 12: - case 13: - case 14: - item = new Item(); - item.SetDefaults(ItemID.GoldCoin); - item.stack = 4; - break; - - case 15: - case 16: - case 17: - case 18: - case 19: - item = new Item(); - item.SetDefaults(ItemID.GoldCoin); - item.stack = 6; - break; - - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 29: - item = new Item(); - item.SetDefaults(ItemID.GoldCoin); - item.stack = 8; - break; - - default: - item = new Item(); - item.SetDefaults(ItemID.GoldCoin); - item.stack = 10; - break; - } - - item.position = self.Center; - item2 = self.GetItem(self.whoAmI, item, anglerRewardSettings); - rewardItems.Add(item2); - - // PRIMARY ITEMS - switch (questsDone) - { - case 0: - case 1: - item = new Item(); - item.SetDefaults(ModContent.ItemType()); - rewardItems.Add(item); - break; - - case 2: - item = new Item(); - item.SetDefaults(ModContent.ItemType()); - item.stack = Main.rand.Next(4, 10); - rewardItems.Add(item); - break; - - case 3: - item = new Item(); - item.SetDefaults(ItemID.HighTestFishingLine); - rewardItems.Add(item); - break; - - case 4: - item = new Item(); - item.SetDefaults(ItemID.FishHook); - rewardItems.Add(item); - break; - - case 5: - item = new Item(); - item.SetDefaults(ItemID.FuzzyCarrot); - rewardItems.Add(item); - break; - - case 6: - item = new Item(); - item.SetDefaults(ItemID.FishermansGuide); - rewardItems.Add(item); - break; - - case 7: - item = new Item(); - item.SetDefaults(ItemID.FishCostumeMask); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.FishCostumeShirt); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.FishCostumeFinskirt); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ModContent.ItemType()); - rewardItems.Add(item); - break; - - case 8: - item = new Item(); - item.SetDefaults(ItemID.FishMinecart); - rewardItems.Add(item); - break; - - case 9: - item = new Item(); - item.SetDefaults(ItemID.SailfishBoots); - rewardItems.Add(item); - break; - - case 10: - item = new Item(); - item.SetDefaults(ItemID.AnglerHat); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.AnglerVest); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.AnglerPants); - rewardItems.Add(item); - break; - - case 11: - item = new Item(); - item.SetDefaults(ItemID.WeatherRadio); - rewardItems.Add(item); - break; - - case 12: - item = new Item(); - item.SetDefaults(ItemID.FishingBobber); - rewardItems.Add(item); - break; - - case 13: - item = new Item(); - item.SetDefaults(ItemID.SeashellHairpin); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.MermaidAdornment); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.MermaidTail); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ModContent.ItemType()); - rewardItems.Add(item); - break; - - case 14: - item = new Item(); - item.SetDefaults(ItemID.Sextant); - rewardItems.Add(item); - break; - - case 15: - item = new Item(); - item.SetDefaults(ItemID.TackleBox); - rewardItems.Add(item); - break; - - case 16: - item = new Item(); - item.SetDefaults(ItemID.SuperAbsorbantSponge); - rewardItems.Add(item); - break; - - case 17: - item = new Item(); - item.SetDefaults(ItemID.LavaFishingHook); - rewardItems.Add(item); - break; - - case 18: - item = new Item(); - item.SetDefaults(ItemID.MagicConch); - rewardItems.Add(item); - break; - - case 19: - item = new Item(); - item.SetDefaults(ItemID.DemonConch); - rewardItems.Add(item); - break; - - case 20: - item = new Item(); - item.SetDefaults(ItemID.AnglerEarring); - rewardItems.Add(item); - break; - - case 21: - item = new Item(); - item.SetDefaults(ItemID.HoneyAbsorbantSponge); - rewardItems.Add(item); - break; - - case 22: - item = new Item(); - item.SetDefaults(ItemID.HotlineFishingHook); - rewardItems.Add(item); - break; - - case 23: - item = new Item(); - item.SetDefaults(ItemID.FrogLeg); - rewardItems.Add(item); - break; - - case 24: - item = new Item(); - item.SetDefaults(ItemID.SuperheatedBlood); - rewardItems.Add(item); - break; - - case 25: - item = new Item(); - item.SetDefaults(ItemID.BottomlessBucket); - rewardItems.Add(item); - break; - - case 26: - item = new Item(); + case 26: // Enchanted Sundial item.SetDefaults(ItemID.Sundial); - rewardItems.Add(item); break; - - case 27: - item = new Item(); - item.SetDefaults(ItemID.BottomlessHoneyBucket); - rewardItems.Add(item); - break; - - case 28: - item = new Item(); + case 28: // Golden Bug Net item.SetDefaults(ItemID.GoldenBugNet); - rewardItems.Add(item); break; - - case 29: - item = new Item(); - item.SetDefaults(ItemID.BottomlessLavaBucket); - rewardItems.Add(item); - break; - - case 30: - item = new Item(); - item.SetDefaults(ItemID.GoldenFishingRod); - rewardItems.Add(item); + default: break; } - // RANDOM DROPS + // If the quest is of a number that gives a guaranteed reward from Calamity, add it to the reward pool and skip vanilla logic. + if (item.type > ItemID.None) + rewardItems.Add(item); + else + orig(self, rewardItems, source, questsDone, rarityReduction, questItemType, ref anglerRewardSettings); + } - // Angling Kits - if (Main.rand.NextBool((int)(12f * rarityReduction)) && questsDone > 30) + private static void ImproveAnglerBaitReward(On_Player.orig_GetAnglerReward_Bait orig, Player self, List rewardItems, IEntitySource source, int questsDone, float rarityReduction, ref GetItemSettings anglerRewardSettings) + { + // Improves the bait reward given for Angler quests in three ways: + // 1. Makes bait reward be guaranteed. + // 2. Adds the ability for Grand Marquis Bait to be dropped. + // 3. Increases the amount of bait dropped. + // This entirely replaces the vanilla logic. + + Item bait = new Item(); + if (Main.rand.NextBool((int)(15f * rarityReduction))) + bait.SetDefaults(ModContent.ItemType()); + else if (Main.rand.NextBool((int)(10f * rarityReduction))) + bait.SetDefaults(ItemID.MasterBait); + else if (Main.rand.NextBool((int)(5f * rarityReduction))) + bait.SetDefaults(ItemID.JourneymanBait); + else + bait.SetDefaults(ItemID.ApprenticeBait); + + bait.stack = 2; + if (Main.rand.Next(10) <= questsDone) + bait.stack++; + if (Main.rand.Next(20) <= questsDone) + bait.stack++; + if (Main.rand.Next(30) <= questsDone) + bait.stack++; + if (Main.rand.Next(40) <= questsDone) + bait.stack++; + if (Main.rand.Next(50) <= questsDone) + bait.stack++; + + rewardItems.Add(bait); + } + + private static void ImproveAnglerMoneyReward(On_Player.orig_GetAnglerReward_Money orig, Player self, List rewardItems, IEntitySource source, int questsDone, float rarityReduction, ref GetItemSettings anglerRewardSettings) + { + // Improves the logic for giving money to the player from Angler quests. + // This is accomplished via a higher starting amount, reduced variance, and not truncating off Silver Coins if giving Gold Coins. + // This entirely replaces the vanilla logic. + + int moneyDrop = (questsDone + 70) / 2; // Vanilla uses 50 + moneyDrop = (int)(moneyDrop * Main.rand.NextFloat(1f, 2f)); // Vanilla is 0.75x-3x + moneyDrop = (int)(moneyDrop * 1.5f); // Vanilla then arbitrarily multiplies the value by 1.5x + if (Main.hardMode) + moneyDrop *= 2; + if (Main.expertMode) + moneyDrop *= 2; + if (moneyDrop > 1000) + moneyDrop = 1000; // Vanilla has a cap of 10 Gold Coins, or 1000 Silver Coins. + + // moneyDrop now contains the number of SILVER Coins to drop. + // Determine the number of Gold Coins to drop, if any. + if (moneyDrop >= 100) { - item = new Item(); - item.SetDefaults(Main.hardMode ? ModContent.ItemType() : ModContent.ItemType()); - rewardItems.Add(item); - } - - // Golden Fishing Rod - if (Main.rand.NextBool((int)(500f * rarityReduction)) && questsDone > 30) - { - item = new Item(); - item.SetDefaults(ItemID.GoldenFishingRod); - rewardItems.Add(item); - } - - // Hotline Fishing Hook - if (Main.rand.NextBool((int)(200f * rarityReduction)) && questsDone > 22) - { - item = new Item(); - item.SetDefaults(ItemID.HotlineFishingHook); - rewardItems.Add(item); - } - - // Angler Set - if (Main.rand.NextBool((int)(150f * rarityReduction)) && questsDone > 10) - { - item = new Item(); - item.SetDefaults(ItemID.AnglerHat); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.AnglerVest); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.AnglerPants); - rewardItems.Add(item); - } - - // Mermaid Set - if (Main.rand.NextBool((int)(150f * rarityReduction)) && questsDone > 13) - { - item = new Item(); - item.SetDefaults(ItemID.SeashellHairpin); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.MermaidAdornment); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.MermaidTail); - rewardItems.Add(item); - } - - // Fish Set - if (Main.rand.NextBool((int)(150f * rarityReduction)) && questsDone > 7) - { - item = new Item(); - item.SetDefaults(ItemID.FishCostumeMask); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.FishCostumeShirt); - rewardItems.Add(item); - item = new Item(); - item.SetDefaults(ItemID.FishCostumeFinskirt); - rewardItems.Add(item); - } - - // Fin Wings - if (Main.rand.NextBool((int)(140f * rarityReduction)) && Main.hardMode && questsDone > 10) - { - item = new Item(); - item.SetDefaults(ItemID.FinWings); - rewardItems.Add(item); - } - - // Bottomless Water Bucket - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 25) - { - item = new Item(); - item.SetDefaults(ItemID.BottomlessBucket); - rewardItems.Add(item); - } - - // Bottomless Honey Bucket - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 27) - { - item = new Item(); - item.SetDefaults(ItemID.BottomlessHoneyBucket); - rewardItems.Add(item); - } - - // Bottomless Lava Bucket - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 29) - { - item = new Item(); - item.SetDefaults(ItemID.BottomlessLavaBucket); - rewardItems.Add(item); - } - - // Magic Conch - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 18) - { - item = new Item(); - item.SetDefaults(ItemID.MagicConch); - rewardItems.Add(item); - } - - // Demon Conch - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 19) - { - item = new Item(); - item.SetDefaults(ItemID.DemonConch); - rewardItems.Add(item); - } - - // Super Absorbant Sponge - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 16) - { - item = new Item(); - item.SetDefaults(ItemID.SuperAbsorbantSponge); - rewardItems.Add(item); - } - - // Honey Absorbant Sponge - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 21) - { - item = new Item(); - item.SetDefaults(ItemID.SuperAbsorbantSponge); - rewardItems.Add(item); - } - - // Golden Bug Net - if (Main.rand.NextBool((int)(140f * rarityReduction)) && questsDone > 28) - { - item = new Item(); - item.SetDefaults(ItemID.GoldenBugNet); - rewardItems.Add(item); - } - - // Fish Hook - if (Main.rand.NextBool((int)(120f * rarityReduction)) && questsDone > 4) - { - item = new Item(); - item.SetDefaults(ItemID.FishHook); - rewardItems.Add(item); - } - - // Minecarp - if (Main.rand.NextBool((int)(120f * rarityReduction)) && questsDone > 8) - { - item = new Item(); - item.SetDefaults(ItemID.FishMinecart); - rewardItems.Add(item); - } - - // Lava Shark - if (Main.rand.NextBool((int)(120f * rarityReduction)) && questsDone > 24) - { - item = new Item(); - item.SetDefaults(ItemID.SuperheatedBlood); - rewardItems.Add(item); - } - - // High Test Fishing Line - if (Main.rand.NextBool((int)(80f * rarityReduction)) && questsDone > 3) - { - item = new Item(); - item.SetDefaults(ItemID.HighTestFishingLine); - rewardItems.Add(item); - } - - // Angler Earring - if (Main.rand.NextBool((int)(80f * rarityReduction)) && questsDone > 20) - { - item = new Item(); - item.SetDefaults(ItemID.AnglerEarring); - rewardItems.Add(item); - } - - // Lavaproof Fishing Hook - if (Main.rand.NextBool((int)(80f * rarityReduction)) && questsDone > 17) - { - item = new Item(); - item.SetDefaults(ItemID.LavaFishingHook); - rewardItems.Add(item); - } - - // Tackle Box - if (Main.rand.NextBool((int)(80f * rarityReduction)) && questsDone > 15) - { - item = new Item(); - item.SetDefaults(ItemID.TackleBox); - rewardItems.Add(item); - } - - // Fisherman's Pocket Guide - if (Main.rand.NextBool((int)(60f * rarityReduction)) && questsDone > 6) - { - item = new Item(); - item.SetDefaults(ItemID.FishermansGuide); - rewardItems.Add(item); - } - - // Weather Radio - if (Main.rand.NextBool((int)(60f * rarityReduction)) && questsDone > 11) - { - item = new Item(); - item.SetDefaults(ItemID.WeatherRadio); - rewardItems.Add(item); - } - - // Sextant - if (Main.rand.NextBool((int)(60f * rarityReduction)) && questsDone > 14) - { - item = new Item(); - item.SetDefaults(ItemID.Sextant); - rewardItems.Add(item); - } - - // Fishing Bobber - if (Main.rand.NextBool((int)(50f * rarityReduction)) && questsDone > 12) - { - item = new Item(); - item.SetDefaults(ItemID.FishingBobber); - rewardItems.Add(item); - } - - PlayerLoader.AnglerQuestReward(self, rarityReduction, rewardItems); - - foreach (Item rewardItem in rewardItems) - { - rewardItem.position = self.Center; - - Item getItem = self.GetItem(self.whoAmI, rewardItem, GetItemSettings.NPCEntityToPlayerInventorySettings); - - if (getItem.stack > 0) - { - int number = Item.NewItem(source, (int)self.position.X, (int)self.position.Y, self.width, self.height, getItem.type, getItem.stack, noBroadcast: false, 0, noGrabDelay: true); - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncItem, -1, -1, null, number, 1f); - } + int goldDrop = moneyDrop / 100; + Item gold = new Item(); + gold.SetDefaults(ItemID.GoldCoin); + gold.stack = goldDrop; + rewardItems.Add(gold); } + // Now the Silver Coins to drop. + int silverDrop = moneyDrop % 100; + Item silver = new Item(); + silver.SetDefaults(ItemID.SilverCoin); + silver.stack = silverDrop; + rewardItems.Add(silver); } #endregion @@ -963,7 +579,7 @@ namespace CalamityMod.ILEditing 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) { @@ -1017,7 +633,7 @@ namespace CalamityMod.ILEditing var cursor = new ILCursor(il); if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("magmaStone"))) // Flag for if Magma Stone is equipped. Fire Gauntlet also uses this. { - LogFailure("Make Magma Stone & Fire Gauntlet Dust Toggleable", "Could not locate the magma stone variable."); + LogFailure("Make Magma Stone & Fire Gauntlet Dust Toggleable", "Could not locate the Magma Stone variable."); return; } // Load the player itself onto the stack so that it becomes an argument for the following delegate. @@ -1062,7 +678,7 @@ namespace CalamityMod.ILEditing } // Remove the instruction and replace with 1 (true). This effectively removes the requirement for defeating Plantera. - // The only requirements for summoning Golems with Power Cells are now: 1) Golem is not alive, and 2) The world is in Hardmode. + // The only requirements for summoning Golem with Power Cells are now: 1) Golem is not alive, and 2) The world is in Hardmode. cursor.EmitPop(); cursor.Emit(OpCodes.Ldc_I4_1); } @@ -1115,7 +731,7 @@ namespace CalamityMod.ILEditing return; } - // branch is used for exit condition. So setting ble.s opcode to nop will remove the condition + // Branch is used for exit condition. So setting ble.s opcode to nop will remove the condition cursor.Prev.OpCode = OpCodes.Nop; // After that we pop NPC.damage and 0 from stack @@ -1124,14 +740,17 @@ namespace CalamityMod.ILEditing } #endregion - #region Multiple NPC Happiness support for Cirrus - private static void AllowMultipleLikedNPCs(On_ShopHelper.orig_ApplyNpcRelationshipEffect orig, ShopHelper self, int npcType, AffectionLevel affectionLevel) + #region Multiple NPC Happiness support + // Currently unused as the one NPC who used it was removed. However it is very likely it'll be used again in the future, so this code is being kept. + /*private static void AllowMultipleLikedNPCs(On_ShopHelper.orig_ApplyNpcRelationshipEffect orig, ShopHelper self, int npcType, AffectionLevel affectionLevel) { FieldInfo npcTalkField = typeof(ShopHelper).GetField("_currentNPCBeingTalkedTo", BindingFlags.Instance | BindingFlags.NonPublic); NPC talkedNPC = (NPC)npcTalkField.GetValue(self); - // Allow Cirrus to have things to say about multiple NPCs with the same happiness level - if (talkedNPC.type == ModContent.NPCType()) + int npcTypee = 0; + + // Allow the given NPC to have things to say about multiple NPCs with the same happiness level + if (talkedNPC.type == npcTypee) { MethodInfo addReportField = typeof(ShopHelper).GetMethod("AddHappinessReportText", BindingFlags.Instance | BindingFlags.NonPublic); @@ -1153,6 +772,95 @@ namespace CalamityMod.ILEditing { orig(self, npcType, affectionLevel); } + }*/ + #endregion + + #region Allow Disabling Gravity Swap Visual and Allow Gravity Keybind + private static void DelayGravity(On_Player.orig_UpdateControlHolds orig, Player Player) + { + var cplay = Player.Calamity(); + if (CalamityKeybinds.SwitchGravityHotkey.GetAssignedKeysOrEmpty().Count != 0 && (Player.gravControl || Player.gravControl2) && !Player.mount.Active) + { + if (Player.controlUp && Player.releaseUp) + { + Player.gravDir *= -1; + } + if (CalamityKeybinds.SwitchGravityHotkey.JustPressed) + { + Player.gravDir *= -1; + Player.fallStart = (int)(Player.position.Y / 16f); + Player.jump = 0; + SoundEngine.PlaySound(SoundID.Item8, Player.position); + } + + if (Player.forcedGravity > 0) + { + Player.gravDir = -1f; + } + } + + if (cplay.justChangedGravity) + { + Player.gravDir = cplay.oldGravDir; + } + cplay.justChangedGravity = cplay.oldGravDir != Player.gravDir; + + cplay.oldGravDir = Player.gravDir; + if (Main.netMode != NetmodeID.Server && !Main.gameMenu && CalamityClientConfig.Instance.DisableGravityScreenSwap) + { + if (Player.gravDir == -1) + { + if (!Filters.Scene["CalamityMod:FlipScreen"].IsActive()) + { + Filters.Scene.Activate("CalamityMod:FlipScreen"); + Filters.Scene["CalamityMod:FlipScreen"].Opacity = 1f; + + } + } + else + { + if (Filters.Scene["CalamityMod:FlipScreen"].IsActive()) + { + Filters.Scene["CalamityMod:FlipScreen"].Opacity = 0f; + Filters.Scene.Deactivate("CalamityMod:FlipScreen"); + + } + } + } + if (cplay.justChangedGravity) + { + Player.gravDir *= -1; + } + orig(Player); + } + + private static void GravityMouse(On_PlayerInput.orig_SetZoom_MouseInWorld orig) + { + orig(); + if (!Main.gameMenu && Filters.Scene["CalamityMod:FlipScreen"].IsActive())//((Main.LocalPlayer.gravDir == -1 && !Main.LocalPlayer.Calamity().justChangedGravity) || (Main.LocalPlayer.Calamity().oldGravDir == -1 && Main.LocalPlayer.Calamity().justChangedGravity)) + { + var center = Main.screenHeight / 2; + Main.mouseY = center - (Main.mouseY - center); + } + ; + } + private static void UI_Unflip_Start(On_Main.orig_DrawPlayerChatBubbles orig, Main self) + { + if (!Main.gameMenu && (Filters.Scene["CalamityMod:FlipScreen"].IsActive() || Main.LocalPlayer.Calamity().justChangedGravity)) + { + Main.LocalPlayer.Calamity().tempGravDir = Main.LocalPlayer.gravDir; + Main.LocalPlayer.gravDir = 1; + } + orig(self); + } + + private static void UI_Unflip_End(On_Main.orig_DrawInterface orig, Main self, GameTime gameTime) + { + orig(self, gameTime); + if (!Main.gameMenu && Filters.Scene["CalamityMod:FlipScreen"].IsActive()) + { + Main.LocalPlayer.gravDir = Main.LocalPlayer.Calamity().tempGravDir; + } } #endregion diff --git a/ILEditing/WorldgenILChanges.cs b/ILEditing/WorldgenILChanges.cs index b6ca1da325..6a11c74bec 100644 --- a/ILEditing/WorldgenILChanges.cs +++ b/ILEditing/WorldgenILChanges.cs @@ -1,13 +1,10 @@ using System; -using System.Linq; -using CalamityMod.Systems; using CalamityMod.World; using Microsoft.Xna.Framework; using Mono.Cecil.Cil; using MonoMod.Cil; using Terraria; using Terraria.GameContent.UI.States; -using Terraria.ID; using Terraria.WorldBuilding; namespace CalamityMod.ILEditing @@ -33,28 +30,6 @@ namespace CalamityMod.ILEditing set; } - #region Replacement of Pharaoh Set in Pyramids - // Note: There is no need to replace the other Pharaoh piece, due to how the vanilla code works. - // The other Pharaoh vanity piece is added automatically if the mask is found in the chest. - private static void ReplacePharaohSetInPyramids(ILContext il) - { - var cursor = new ILCursor(il); - - // Find the instruction which loads in the item ID of the Pharaoh's Mask. - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(ItemID.PharaohsMask))) - { - LogFailure("Pharaoh Set Pyramid Replacement", "Could not locate the Pharaoh's Mask item ID."); - return; - } - - // Replace the Pharaoh's Mask with the Amber Hook. - // THIS INT CAST IS MANDATORY. DO NOT REMOVE IT. - // In TML's DLL, despite item IDs being shorts (16 bits), the hardcoded 848 here is a 32-bit integer literal. - // As such, it must be replaced with a 32-bit integer literal or the branches of the switch will misalign and the IL edit fails. - cursor.Next.Operand = (int)ItemID.AmberHook; - } - #endregion Replacement of Pharaoh Set in Pyramids - #region Fixing of Living Tree/Sulphurous Sea Interactions private static void BlockLivingTreesNearOcean(ILContext il) { @@ -66,7 +41,7 @@ namespace CalamityMod.ILEditing #endregion Fixing of Living Tree/Sulphurous Sea Interactions #region Removal of Hardmode Ore Generation from Evil Altars - private static void PreventSmashAltarCode(Terraria.On_WorldGen.orig_SmashAltar orig, int i, int j) + private static void PreventSmashAltarCode(On_WorldGen.orig_SmashAltar orig, int i, int j) { if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework) return; @@ -135,10 +110,8 @@ namespace CalamityMod.ILEditing return; } - // Pop original value off. + // Pop original value off. Push '2' to the stack. c.Emit(OpCodes.Pop); - - // Push '2' to the stack. c.Emit(OpCodes.Ldc_I4_2); // OBJECTIVE 2 @@ -161,7 +134,7 @@ namespace CalamityMod.ILEditing } #endregion - #region Change World Generation Descriptions + #region Change Small World Description /// /// Changes the description of Small worlds to serve as a warning. /// @@ -181,50 +154,12 @@ namespace CalamityMod.ILEditing // Emit our new string "Mods.CalamityMod.UI.SmallWorldWarning". c.Emit(OpCodes.Ldstr, "Mods.CalamityMod.UI.SmallWorldWarning"); - - - } - - /// - /// Changes the description of Master Mode to mention boss changes. - /// - private static void SwapMasterModeDescriptionKey(ILContext il) - { - // Swap vanilla's Master Mode description string (UI.WorldDescriptionMaster) with Calamity's edited version (Mods.CalamityMod.UI.WorldMaster). - var cursor = new ILCursor(il); - - // Move to after the string. - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdstr("UI.WorldDescriptionMaster"))) - { - LogFailure("Change Master Mode Description", "Could not match string \"UI.WorldDescriptionMaster\"."); - return; - } - - // Pop this value off, then replace it with Calamity's new string. - cursor.EmitPop(); - cursor.Emit(OpCodes.Ldstr, "Mods.CalamityMod.UI.WorldMaster"); - } - #endregion - - #region Clear temporary modded tiles - private static void ClearModdedTempTiles(Terraria.IO.On_WorldFile.orig_ClearTempTiles orig) - { - orig(); - - for (int i = 0; i < Main.maxTilesX; i++) - { - for (int j = 0; j < Main.maxTilesY; j++) - { - if (TempTilesManagerSystem.TemporaryTileIDs.Contains(Main.tile[i, j].TileType)) - WorldGen.KillTile(i, j); - } - } } #endregion #region Prevent Abyss/Dungeon Interactions - private void LimitDungeonEntranceXPosition(On_WorldGen.orig_MakeDungeon orig, int x, int y) + private static void LimitDungeonEntranceXPosition(On_WorldGen.orig_MakeDungeon orig, int x, int y) { // Ensure that the base X position stays within its required bounds. x = Utils.Clamp(x, DungeonBaseXLimit, Main.maxTilesX - DungeonBaseXLimit); @@ -273,77 +208,5 @@ namespace CalamityMod.ILEditing } #endregion Prevent Abyss/Dungeon Interactions - - #region Change Dungeon Spike Quantities - - /// - /// Makes dungeon spikes more infrequent in the dungeon under normal circumstances. - /// - private static void ChangeDungeonSpikeQuantities(ILContext il) - { - var c = new ILCursor(il); - - /* The code being altered is as follows: - * int num16 = Main.maxTilesX / 100; - * if (WorldGen.getGoodWorldGen) - * { - * num16 *= 3; - * } - * - * The desired change is to halve num16 under typical circumstances but leave them unchanged on the meme seeds (Except for GFB, where it's even more ridiculous). - * This should result in the following logical output via this edit: - * - * int num16 = Main.maxTilesX / 200; - * if (WorldGen.getGoodWorldGen) - * { - * num16 *= 6; - * } - * if (Main.zenithWorld) - * { - * num16 *= 4; - * } - */ - - // WorldGen.getGoodWorldGen is only used once in this method, and as such is a reliable entrypoint for getting near the above code. - if (!c.TryGotoNext(MoveType.After, x => x.MatchLdsfld("getGoodWorldGen"))) - { - LogFailure("Change Dungeon Spike Quantities", "Could not match the load of Worldgen.getGoodWorldGen."); - return; - } - - // Go back to find the local index of num16, being sure to go right before it's stored. - if (!c.TryGotoPrev(MoveType.Before, x => x.MatchStloc(out _))) - { - LogFailure("Change Dungeon Spike Quantities", "Could not match the storage of num16."); - return; - } - - // Since we're right before the storage of num16, that means that its exact number is right above and available for manipulation. - // This will be accomplished via a division by 2 for the default condition and respective multiplications for the meme seeds. - // The reason this isn't done in a single multiplication/division is as a means of avoiding the annoyances of casting to floats and back. - - // Divide by two. - c.Emit(OpCodes.Ldc_I4_2); - c.Emit(OpCodes.Div); - - // Multiply by factors relative to the meme seed. - c.EmitDelegate(() => - { - int frequencyFactor = 1; - - // Undo the division by 2 in the FTW seed. It will be given the *= 3 after the placement of these edits. - if (WorldGen.getGoodWorldGen) - frequencyFactor *= 2; - - // GFB, where good game design dies. - if (Main.zenithWorld) - frequencyFactor *= 4; - - return frequencyFactor; - }); - c.Emit(OpCodes.Mul); - } - - #endregion Change Dungeon Spike Quantities } } diff --git a/Items/Accessories/Abaddon.cs b/Items/Accessories/Abaddon.cs index a0d0fe0025..6f3dfd0ba5 100644 --- a/Items/Accessories/Abaddon.cs +++ b/Items/Accessories/Abaddon.cs @@ -1,5 +1,6 @@ using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -9,7 +10,11 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; - public static int AbaddonExploDamage = 90; + public static int CritBoost = 8; + public static float BrimstoneFlamesReduction = 0.5f; + public static int AbaddonExploDamage = 25; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(CritBoost, BrimstoneFlamesReduction.ToPercent()); + public override void SetDefaults() { Item.width = 26; @@ -22,7 +27,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().abaddon = true; - player.GetCritChance() += 8; + player.GetCritChance() += CritBoost; } } } diff --git a/Items/Accessories/AbyssalDivingSuit.cs b/Items/Accessories/AbyssalDivingSuit.cs index 51803181a3..74ed843a5f 100644 --- a/Items/Accessories/AbyssalDivingSuit.cs +++ b/Items/Accessories/AbyssalDivingSuit.cs @@ -1,30 +1,26 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Items.BaseItems; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class AbyssalDivingSuit : ModItem, ILocalizedModType + public class AbyssalDivingSuit : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public static double PlatesAllDamageReduction = 0.15D; - public static double PlatesHitDecay = 0.03D; + public override string AssetPath => "CalamityMod/Items/Accessories/"; + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "AbyssalDivingSuit", null), + (EquipType.Body, "AbyssalDivingSuit", null), + (EquipType.Legs, "AbyssalDivingSuit", null), + (EquipType.Face, null, null), //results in setting this equip slot to -1 + ]; - public override void Load() - { - // All code below runs only if we're not loading on a server - if (!Main.dedServ) - { - // Add equip textures - EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Head}", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Body}", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, $"{Texture}_{EquipType.Legs}", EquipType.Legs, this); - } - } + public override (SoundStyle sound, int delay)? HurtSound(Player p) => (SoundID.NPCHit4, 10); public override void SetDefaults() { @@ -33,42 +29,18 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; - - if (!Main.dedServ) - { - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } } - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.abyssalDivingSuit = true; - if (hideVisual) - modPlayer.abyssalDivingSuitHide = true; - } - - public override void UpdateVanity(Player player) - { - player.Calamity().abyssalDivingSuitHide = false; - player.Calamity().abyssalDivingSuitForce = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) => player.Calamity().abyssalDivingSuit = true; public override void AddRecipes() { CreateRecipe(). AddIngredient(). AddIngredient(). - AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(15). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/AbyssalMirror.cs b/Items/Accessories/AbyssalMirror.cs index 40e9b7a0eb..e4113351d0 100644 --- a/Items/Accessories/AbyssalMirror.cs +++ b/Items/Accessories/AbyssalMirror.cs @@ -1,8 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -11,6 +11,12 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; public bool HasFlavorTooltip => true; + + public static int AggroReduction = 450; + public static float StandingStealthRegenBoost = 0.25f; + public static float MovingStealthRegenBoost = 0.12f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(StandingStealthRegenBoost.ToPercent(), MovingStealthRegenBoost.ToPercent()); + public override void SetDefaults() { Item.width = 30; @@ -23,10 +29,10 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.stealthGenStandstill += 0.25f; - modPlayer.stealthGenMoving += 0.12f; + modPlayer.stealthGenStandstill += StandingStealthRegenBoost; + modPlayer.stealthGenMoving += MovingStealthRegenBoost; modPlayer.abyssalMirror = true; - player.aggro -= 450; + player.aggro -= AggroReduction; } public override void AddRecipes() diff --git a/Items/Accessories/AeroStone.cs b/Items/Accessories/AeroStone.cs index 93676815e0..c1a23a6579 100644 --- a/Items/Accessories/AeroStone.cs +++ b/Items/Accessories/AeroStone.cs @@ -4,6 +4,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -12,6 +13,9 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; + public static int FlightTimeBoostFlat = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(FlightTimeBoostFlat.FramesToSeconds()); + public override void SetStaticDefaults() { Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(4, 8)); @@ -30,7 +34,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().aeroStone = true; - player.wingTimeMax += 50; + player.wingTimeMax += FlightTimeBoostFlat; } public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) diff --git a/Items/Accessories/Affliction.cs b/Items/Accessories/Affliction.cs index be8a8b917a..86ed0eb959 100644 --- a/Items/Accessories/Affliction.cs +++ b/Items/Accessories/Affliction.cs @@ -4,7 +4,7 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -12,6 +12,14 @@ namespace CalamityMod.Items.Accessories public class Affliction : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int RegenBoost = 1; + public static int MaxLifeBoostPercent = 10; + public static float DamageReductionBoost = 0.07f; + public static int DefenseBoost = 9; + public static float DamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenBoost.ToRegenPerSecond(), MaxLifeBoostPercent, DamageReductionBoost.ToPercent(), DefenseBoost, DamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 38; @@ -19,6 +27,7 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Accessories/AlchemicalDecanter.cs b/Items/Accessories/AlchemicalDecanter.cs new file mode 100644 index 0000000000..a463957cae --- /dev/null +++ b/Items/Accessories/AlchemicalDecanter.cs @@ -0,0 +1,43 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class AlchemicalDecanter : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + + public static float PlagueReduction = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(PlagueReduction.ToPercent()); + + public override void SetDefaults() + { + Item.width = 26; + Item.height = 26; + Item.value = CalamityGlobalItem.RarityYellowBuyPrice; + Item.rare = ItemRarityID.Yellow; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.alchFlask = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.BottledWater). + AddIngredient(ItemID.HoneyComb). + AddIngredient(ItemID.BeeWax, 8). + AddIngredient(15). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Accessories/AlchemicalFlask.png b/Items/Accessories/AlchemicalDecanter.png similarity index 100% rename from Items/Accessories/AlchemicalFlask.png rename to Items/Accessories/AlchemicalDecanter.png diff --git a/Items/Accessories/AlchemicalFlask.cs b/Items/Accessories/AlchemicalFlask.cs deleted file mode 100644 index aea37c1bf8..0000000000 --- a/Items/Accessories/AlchemicalFlask.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class AlchemicalFlask : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.width = 26; - Item.height = 26; - Item.value = CalamityGlobalItem.RarityYellowBuyPrice; - Item.rare = ItemRarityID.Yellow; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.alchFlask = true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.BottledWater). - AddIngredient(ItemID.HoneyComb). - AddIngredient(ItemID.BeeWax, 8). - AddIngredient(15). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Accessories/AlluringBait.cs b/Items/Accessories/AlluringBait.cs index 786435906e..d31ed4b4d0 100644 --- a/Items/Accessories/AlluringBait.cs +++ b/Items/Accessories/AlluringBait.cs @@ -1,5 +1,6 @@ using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -7,6 +8,10 @@ namespace CalamityMod.Items.Accessories public class AlluringBait : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int FishingPowerBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(FishingPowerBoost); + public override void SetDefaults() { Item.width = 26; @@ -19,7 +24,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().alluringBait = true; - player.fishingSkill += 10; + player.fishingSkill += FishingPowerBoost; } } } diff --git a/Items/Accessories/AmalgamatedBrain.cs b/Items/Accessories/AmalgamatedBrain.cs index a823f93126..642fcd0085 100644 --- a/Items/Accessories/AmalgamatedBrain.cs +++ b/Items/Accessories/AmalgamatedBrain.cs @@ -1,9 +1,7 @@ -using CalamityMod.Balancing; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Magic; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -11,6 +9,9 @@ namespace CalamityMod.Items.Accessories public class AmalgamatedBrain : ModItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Accessories"; + + public static int NimbusDamage => CalamityUtils.ScaleWithDifficulty(18); + public override void SetDefaults() { Item.width = 34; @@ -18,6 +19,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -26,7 +28,6 @@ namespace CalamityMod.Items.Accessories modPlayer.rBrain = true; // Handles shaderain cloud spawning on hit modPlayer.aBrain = true; player.brainOfConfusionItem = Item; - player.GetDamage() += 0.05f; } public override void AddRecipes() diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index 90779b1ac3..8cd7145e58 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -1,8 +1,10 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -10,6 +12,10 @@ namespace CalamityMod.Items.Accessories public class AmbrosialAmpoule : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int MaxLifeBoost = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifeBoost, RadiantOoze.MinRegenBoost.ToRegenPerSecond(), RadiantOoze.MaxRegenBoost.ToRegenPerSecond()); + public override void SetDefaults() { Item.width = 20; @@ -22,13 +28,14 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - player.statLifeMax2 += 50; + player.statLifeMax2 += MaxLifeBoost; + if (!player.HasBuff(BuffID.Honey)) + player.AddBuff(BuffID.Honey, 2); // bool left in for abyss light purposes and life regen effects modPlayer.aAmpoule = true; - // Inherits all effects of Honey Dew and Living Dew (except standing regen is not honey exclusive anymore) - modPlayer.alwaysHoneyRegen = true; + // Inherits all effects of Honey Dew and Living Dew modPlayer.honeyDewHalveDebuffs = true; modPlayer.livingDewHalveDebuffs = true; @@ -37,6 +44,15 @@ namespace CalamityMod.Items.Accessories Lighting.AddLight(player.Center, new Vector3(1.2f, 1.2f, 0.72f)); } + public override void ModifyTooltips(List list) + { + var player = Main.LocalPlayer; + if (player != null) + { + list.FindAndReplace("[REGEN]", player.Calamity().radiantOozeRegen.ToString("0.##")); + } + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/AncientFossil.cs b/Items/Accessories/AncientFossil.cs index 6293e34145..ef73c7adbe 100644 --- a/Items/Accessories/AncientFossil.cs +++ b/Items/Accessories/AncientFossil.cs @@ -1,5 +1,6 @@ using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -7,6 +8,10 @@ namespace CalamityMod.Items.Accessories public class AncientFossil : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static float MiningSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MiningSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 26; @@ -18,7 +23,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.pickSpeed -= 0.1f; + player.pickSpeed -= MiningSpeedBoost; player.Calamity().aFossil = true; player.Calamity().fallingBlockProtection = true; } diff --git a/Items/Accessories/AngelTreads.cs b/Items/Accessories/AngelTreads.cs index bf1b3b87a0..c75f44b7f4 100644 --- a/Items/Accessories/AngelTreads.cs +++ b/Items/Accessories/AngelTreads.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -10,6 +11,13 @@ namespace CalamityMod.Items.Accessories public class AngelTreads : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static float RunningSpeed = 7.5f; // 6.75 from Lightning-Terraspark + public static float MoveSpeedBoost = 0.12f; + public static float FlightTimeBoost = 0.1f; + public static int LavaImmunityTime = 420; // Identical to Terraspark Boots and upgrades prior + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent(), FlightTimeBoost.ToPercent(), LavaImmunityTime.FramesToSeconds()); + public override void SetDefaults() { Item.width = 32; @@ -23,14 +31,14 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.angelTreads = true; - player.accRunSpeed = 7.5f; + player.accRunSpeed = RunningSpeed; player.rocketBoots = player.vanityRocketBoots = 3; - player.moveSpeed += 0.12f; + player.moveSpeed += MoveSpeedBoost; player.iceSkate = true; player.waterWalk = true; player.fireWalk = true; - player.lavaMax += 240; - player.buffImmune[BuffID.OnFire] = true; + player.lavaMax += LavaImmunityTime; + player.lavaRose = true; } public override void UpdateVanity(Player player) diff --git a/Items/Accessories/AngelicAlliance.cs b/Items/Accessories/AngelicAlliance.cs index e1b1cdfc06..e0cc74a488 100644 --- a/Items/Accessories/AngelicAlliance.cs +++ b/Items/Accessories/AngelicAlliance.cs @@ -6,6 +6,7 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.Audio; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -16,6 +17,18 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/AngelicAllianceActivation"); + // This accessory is insane. wtf. - Iris + public static int MinionSlotBoost = 2; + public static float TotalSummonDamageBoost = 0.15f; // this is partially all-class -- this number represents the whole thing + public static float DamageBoost = 0.08f; + public static int RegenBoostDuringFlight = 4; + public static int DivineBlessDuration = CalamityUtils.SecondsToFrames(15); + public static int DivineBlessCooldown = CalamityUtils.SecondsToFrames(60); + public static int HealPerAngelSpawned = 2; + public static int BanishingFireDuration = CalamityUtils.SecondsToFrames(1); + public static int DivineBlessFramesPerHeal = 15; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, TotalSummonDamageBoost.ToPercent(), DamageBoost.ToPercent(), RegenBoostDuringFlight.ToRegenPerSecond(), DivineBlessDuration.FramesToSeconds(), HealPerAngelSpawned, (60 / (float)DivineBlessFramesPerHeal).Round(), (DivineBlessCooldown / 3600f).Round()); + public override void SetDefaults() { Item.width = 56; @@ -32,11 +45,11 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.angelicAlliance = true; - player.GetDamage() += 0.08f; - player.GetDamage() += 0.07f; //7% + 8% = 15% - player.maxMinions += 2; + player.GetDamage() += DamageBoost; + player.GetDamage() += TotalSummonDamageBoost - DamageBoost; + player.maxMinions += MinionSlotBoost; if (player.wingTime < player.wingTimeMax) - player.lifeRegen += 4; + player.lifeRegen += RegenBoostDuringFlight; } public override void AddRecipes() diff --git a/Items/Accessories/AquaticEmblem.cs b/Items/Accessories/AquaticEmblem.cs index 7171d7c9d2..dbe9935d5d 100644 --- a/Items/Accessories/AquaticEmblem.cs +++ b/Items/Accessories/AquaticEmblem.cs @@ -1,6 +1,7 @@ using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -8,6 +9,12 @@ namespace CalamityMod.Items.Accessories public class AquaticEmblem : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int MaxDefenseBoost = 20; + public static float MaxMoveSpeedReduction = 0.1f; + public static int TimeToReachMaxBoost = CalamityUtils.SecondsToFrames(10); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(TimeToReachMaxBoost.FramesToSeconds(), MaxDefenseBoost, MaxMoveSpeedReduction.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -15,6 +22,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -26,7 +34,7 @@ namespace CalamityMod.Items.Accessories player.npcTypeNoAggro[NPCID.PinkJellyfish] = true; player.npcTypeNoAggro[NPCID.Crab] = true; player.npcTypeNoAggro[NPCID.Squid] = true; - if (player.IsUnderwater()) + if (player.Calamity().countsAsAnyWet) player.gills = true; } } diff --git a/Items/Accessories/AquaticHeart.cs b/Items/Accessories/AquaticHeart.cs index 5c5f1de826..be830a8235 100644 --- a/Items/Accessories/AquaticHeart.cs +++ b/Items/Accessories/AquaticHeart.cs @@ -1,45 +1,33 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.Items.BaseItems; using Terraria; +using Terraria.Audio; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { [LegacyName("SirensHeart")] - public class AquaticHeart : ModItem, ILocalizedModType + public class AquaticHeart : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; public static float WaterSpeedBoost = 0.15f; - public static double IceShieldAllDamageReduction = 0.2D; + public static float IceShieldDamageReductionBoost = 0.2f; + public static int IceShieldCooldown = CalamityUtils.SecondsToFrames(30); + public static LocalizedText FullTooltip => CalamityUtils.GetText("Items.Accessories.AquaticHeart.FullTooltip").WithFormatArgs(WaterSpeedBoost.ToPercent(), IceShieldDamageReductionBoost.ToPercent(), IceShieldCooldown.FramesToSeconds()); - public override void Load() - { - // All code below runs only if we're not loading on a server - if (!Main.dedServ) - { - // Add equip textures - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/AquaticTrans_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/AquaticTrans_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/AquaticTrans_Legs", EquipType.Legs, this); - } - } + public override string AssetPath => "CalamityMod/Items/Accessories/"; + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "AquaticTrans", null), + (EquipType.Body, "AquaticTrans", null), + (EquipType.Legs, "AquaticTrans", null), + (EquipType.Face, null, null), //results in setting this equip slot to -1 + ]; - public override void SetStaticDefaults() - { - if (!Main.dedServ) - { - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } - } + public override (SoundStyle sound, int delay)? HurtSound(Player p) => (SoundID.FemaleHit, 10); public override void SetDefaults() { @@ -50,23 +38,11 @@ namespace CalamityMod.Items.Accessories Item.rare = ItemRarityID.LightRed; } - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.aquaticHeart = true; - if (hideVisual) - modPlayer.aquaticHeartHide = true; - } - - public override void UpdateVanity(Player player) - { - player.Calamity().aquaticHeartHide = false; - player.Calamity().aquaticHeartForce = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) => player.Calamity().aquaticHeart = true; public override void ModifyTooltips(List tooltips) { - string statusTooltip = this.GetLocalizedValue(NPC.downedBoss3 ? "FullTooltip" : "LockedTooltip"); + string statusTooltip = NPC.downedBoss3 ? FullTooltip.ToString() : this.GetLocalizedValue("LockedTooltip"); tooltips.FindAndReplace("[STATUS]", statusTooltip); } } diff --git a/Items/Accessories/ArcFlashRing.cs b/Items/Accessories/ArcFlashRing.cs index ab5618118d..32d8fbc0c0 100644 --- a/Items/Accessories/ArcFlashRing.cs +++ b/Items/Accessories/ArcFlashRing.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -11,6 +12,11 @@ namespace CalamityMod.Items.Accessories public class ArcFlashRing : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int LightningSpawnPercent = 5; + public static float LightningDamageMult = 3f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(LightningSpawnPercent, LightningDamageMult); + public override void SetDefaults() { Item.width = 56; @@ -18,6 +24,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/ArchaicPowder.cs b/Items/Accessories/ArchaicPowder.cs index 0a6598e7c6..bb6f6d5597 100644 --- a/Items/Accessories/ArchaicPowder.cs +++ b/Items/Accessories/ArchaicPowder.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Placeables.Crags; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -9,10 +10,15 @@ namespace CalamityMod.Items.Accessories public class ArchaicPowder : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static float MiningSpeedBoost = 0.25f; + public static float TrapDamageReduction = 0.65f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MiningSpeedBoost.ToPercent(), TrapDamageReduction.ToPercent()); + public override void SetDefaults() { - Item.width = 20; - Item.height = 20; + Item.width = 56; + Item.height = 34; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; @@ -20,7 +26,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.pickSpeed -= 0.3f; + player.pickSpeed -= MiningSpeedBoost; player.Calamity().aPowder = true; player.Calamity().fallingBlockProtection = true; player.Calamity().trapProtection = true; @@ -29,7 +35,7 @@ namespace CalamityMod.Items.Accessories if (player.chiselSpeed) player.pickSpeed += 0.15f; if (player.Calamity().aFossil) - player.pickSpeed += 0.1f; + player.pickSpeed += AncientFossil.MiningSpeedBoost; } public override void AddRecipes() diff --git a/Items/Accessories/ArchaicPowder.png b/Items/Accessories/ArchaicPowder.png index aacf76a64a..d67144dcb2 100644 Binary files a/Items/Accessories/ArchaicPowder.png and b/Items/Accessories/ArchaicPowder.png differ diff --git a/Items/Accessories/AscendantInsignia.cs b/Items/Accessories/AscendantInsignia.cs index 307cc2620b..cd3b024632 100644 --- a/Items/Accessories/AscendantInsignia.cs +++ b/Items/Accessories/AscendantInsignia.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; -using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -15,6 +13,16 @@ namespace CalamityMod.Items.Accessories public class AscendantInsignia : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + // These values override Soaring Insignia's + public static double FlightTimeBoost = 0.5D; + public static float MoveSpeedBoost = 0.15f; + public static float JumpSpeedBoost = 0.75f; // NOTE: Tooltip shares this number with move speed % as they're equal + public static float AccelerationBoost = 0.5f; + public static int AbilityDuration = CalamityUtils.SecondsToFrames(4); + public static int AbilityCooldown = CalamityUtils.SecondsToFrames(40); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(FlightTimeBoost.ToPercent(), MoveSpeedBoost.ToPercent(), (1f + AccelerationBoost).Round(), AbilityDuration.FramesToSeconds(), AbilityCooldown.FramesToSeconds()); + public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.AscendantInsigniaHotKey); public override void SetDefaults() { @@ -23,6 +31,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.accessory = true; Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -30,8 +39,8 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.ascendantInsignia = true; player.empressBrooch = true; - player.moveSpeed += 0.05f; - player.jumpSpeedBoost += 0.25f; + player.moveSpeed += MoveSpeedBoost; + player.jumpSpeedBoost += JumpSpeedBoost - 0.5f; } public override void AddRecipes() @@ -41,7 +50,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(5). AddIngredient(5). AddIngredient(ItemID.SoulofFlight, 10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/AsgardianAegis.cs b/Items/Accessories/AsgardianAegis.cs index 064400cf16..c9bf0aa08d 100644 --- a/Items/Accessories/AsgardianAegis.cs +++ b/Items/Accessories/AsgardianAegis.cs @@ -1,29 +1,26 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { [AutoloadEquip(EquipType.Shield)] - public class AsgardianAegis : ModItem, ILocalizedModType, IHoldShiftTooltipItem + public class AsgardianAegis : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; public Color? TooltipExtensionColor => new(195, 223, 255); - public const int ShieldSlamDamage = 900; + public const int ShieldSlamDamage = 1000; public const float ShieldSlamKnockback = 15f; public const int ShieldSlamIFrames = 12; - public const int RamExplosionDamage = 450; + public const int RamExplosionDamage = 300; public const float RamExplosionKnockback = 20f; public override void SetDefaults() @@ -31,64 +28,17 @@ namespace CalamityMod.Items.Accessories Item.width = 60; Item.height = 54; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 12; + Item.defense = 6; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - - // Asgardian Aegis ram dash modPlayer.DashID = AsgardianAegisDash.ID; player.dashType = 0; - - // Inherited Ankh Shield effects player.noKnockback = true; - player.fireWalk = true; - player.buffImmune[BuffID.Weak] = true; - player.buffImmune[BuffID.BrokenArmor] = true; - player.buffImmune[BuffID.Bleeding] = true; - player.buffImmune[BuffID.Poisoned] = true; - player.buffImmune[BuffID.Slow] = true; - player.buffImmune[BuffID.Confused] = true; - player.buffImmune[BuffID.Silenced] = true; - player.buffImmune[BuffID.Cursed] = true; - player.buffImmune[BuffID.Darkness] = true; - player.buffImmune[BuffID.WindPushed] = true; - player.buffImmune[BuffID.Stoned] = true; - - // Additional debuff immunities (Counterparts, similar debuffs to vanilla Ankh Shield debuffs, or upgrades thereof) - player.buffImmune[ModContent.BuffType()] = true; // "Stronger" Broken Armor - player.buffImmune[ModContent.BuffType()] = true; // Counterpart to Burning Blood - player.buffImmune[ModContent.BuffType()] = true; // "Stronger" Bleeding - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[BuffID.Venom] = true; // "Stronger" Poisoned - player.buffImmune[ModContent.BuffType()] = true; // "Stronger" Poisoned - player.buffImmune[BuffID.Webbed] = true; // "Stronger" Slow - player.buffImmune[BuffID.Blackout] = true; // "Stronger" Darkness - - // Additional debuff immunities (Everything from Ornate Shield + Asgard's Valor) - player.buffImmune[BuffID.OnFire] = true; - player.buffImmune[BuffID.OnFire3] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[BuffID.Chilled] = true; - player.buffImmune[BuffID.Frozen] = true; - player.buffImmune[BuffID.Frostburn] = true; - player.buffImmune[BuffID.Frostburn2] = true; - - // Additional debuff immunities (Everything from Elysian Aegis + thematic counterparts) - player.buffImmune[BuffID.CursedInferno] = true; - player.buffImmune[BuffID.ShadowFlame] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[ModContent.BuffType()] = true; - - // Immune to God Slayer Inferno itself - player.buffImmune[ModContent.BuffType()] = true; } public override void AddRecipes() diff --git a/Items/Accessories/AsgardsValor.cs b/Items/Accessories/AsgardsValor.cs index 5478959941..9e450205d1 100644 --- a/Items/Accessories/AsgardsValor.cs +++ b/Items/Accessories/AsgardsValor.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; @@ -10,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { [AutoloadEquip(EquipType.Shield)] - public class AsgardsValor : ModItem, ILocalizedModType, IHoldShiftTooltipItem + public class AsgardsValor : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; @@ -26,49 +25,24 @@ namespace CalamityMod.Items.Accessories Item.height = 48; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 8; // we buff Ankh Shield to 8 + Item.defense = 4; Item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - - // Asgard's Valor ram dash modPlayer.DashID = AsgardsValorDash.ID; player.dashType = 0; - - // Inherited Ankh Shield effects player.noKnockback = true; - player.fireWalk = true; - player.buffImmune[BuffID.Weak] = true; - player.buffImmune[BuffID.BrokenArmor] = true; - player.buffImmune[BuffID.Bleeding] = true; - player.buffImmune[BuffID.Poisoned] = true; - player.buffImmune[BuffID.Slow] = true; - player.buffImmune[BuffID.Confused] = true; - player.buffImmune[BuffID.Silenced] = true; - player.buffImmune[BuffID.Cursed] = true; - player.buffImmune[BuffID.Darkness] = true; - player.buffImmune[BuffID.WindPushed] = true; - player.buffImmune[BuffID.Stoned] = true; - - // Additional debuff immunities (Everything from Ornate Shield + fiery stuff) - player.buffImmune[BuffID.OnFire] = true; - player.buffImmune[BuffID.OnFire3] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[BuffID.Chilled] = true; - player.buffImmune[BuffID.Frozen] = true; - player.buffImmune[BuffID.Frostburn] = true; - player.buffImmune[BuffID.Frostburn2] = true; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.AnkhShield). AddIngredient(). AddIngredient(). + AddIngredient(ItemID.HallowedBar, 5). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/AsgardsValor_Shield.png b/Items/Accessories/AsgardsValor_Shield.png index ea83064192..320b309ddd 100644 Binary files a/Items/Accessories/AsgardsValor_Shield.png and b/Items/Accessories/AsgardsValor_Shield.png differ diff --git a/Items/Accessories/AuricSoulArtifact.cs b/Items/Accessories/AuricSoulArtifact.cs index f20364b034..9ff5405c94 100644 --- a/Items/Accessories/AuricSoulArtifact.cs +++ b/Items/Accessories/AuricSoulArtifact.cs @@ -3,8 +3,8 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories Item.width = 28; Item.height = 28; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(5). AddIngredient(25). AddIngredient(25). - AddTile(TileID.DemonAltar). + AddTile(). Register(); } } diff --git a/Items/Accessories/BadgeofBravery.cs b/Items/Accessories/BadgeofBravery.cs index 8f68dd37c7..14d252e5f0 100644 --- a/Items/Accessories/BadgeofBravery.cs +++ b/Items/Accessories/BadgeofBravery.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Accessories CreateRecipe(). AddIngredient(ItemID.WarriorEmblem). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/Baroclaw.cs b/Items/Accessories/Baroclaw.cs index bbc971ac6a..579a0c61c4 100644 --- a/Items/Accessories/Baroclaw.cs +++ b/Items/Accessories/Baroclaw.cs @@ -9,6 +9,9 @@ namespace CalamityMod.Items.Accessories public class Baroclaw : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int ThornsDamage => CalamityUtils.ScaleWithDifficulty(150); + public override void SetDefaults() { Item.width = 40; @@ -22,7 +25,6 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.baroclaw = true; - player.thorns += 2.5f; } public override void AddRecipes() { diff --git a/Items/Accessories/BatholithBangle.cs b/Items/Accessories/BatholithBangle.cs new file mode 100644 index 0000000000..ef0d8c630f --- /dev/null +++ b/Items/Accessories/BatholithBangle.cs @@ -0,0 +1,39 @@ +using CalamityMod.CalPlayer; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class BatholithBangle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public static int cooldown = 600; + public static int damage = 225; + public override void SetDefaults() + { + Item.width = 36; + Item.height = 28; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.batholithBangle = true; + modPlayer.batholithBangleVisual = !hideVisual; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddRecipeGroup("Boss2Material", 15). + AddIngredient(ItemID.Granite, 45). + AddIngredient(ItemID.Amber, 3). + AddIngredient(ItemID.FallenStar, 5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/BatholithBangle.png b/Items/Accessories/BatholithBangle.png new file mode 100644 index 0000000000..bd19ef3e43 Binary files /dev/null and b/Items/Accessories/BatholithBangle.png differ diff --git a/Items/Accessories/BlackGlassBand.cs b/Items/Accessories/BlackGlassBand.cs index e5bd9dc238..ff767add74 100644 --- a/Items/Accessories/BlackGlassBand.cs +++ b/Items/Accessories/BlackGlassBand.cs @@ -8,8 +8,8 @@ namespace CalamityMod.Items.Accessories public class BlackGlassBand : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public static int cooldown = 420; - public static int damage = 40; + public static int cooldown = 300; + public static int damage = 32; public override void SetDefaults() { Item.width = 30; @@ -27,9 +27,9 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { CreateRecipe(). - AddRecipeGroup("AnyGoldBar", 5). - AddIngredient(ItemID.Diamond, 2). - AddIngredient(ItemID.Obsidian, 25). + AddRecipeGroup("AnyGoldBar", 8). + AddIngredient(ItemID.Diamond, 3). + AddIngredient(ItemID.Obsidian, 35). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index c7e084615f..7a6bd7980a 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -35,11 +34,13 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().blazingCore = true; + player.noKnockback = true; } public static void HandleStars(Player player) diff --git a/Items/Accessories/BloodPact.cs b/Items/Accessories/BloodPact.cs index deb11f3734..dd97b8121d 100644 --- a/Items/Accessories/BloodPact.cs +++ b/Items/Accessories/BloodPact.cs @@ -16,13 +16,14 @@ namespace CalamityMod.Items.Accessories Item.rare = ItemRarityID.Yellow; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.bloodPact = true; // This applies the +25% health boost. - modPlayer.healingPotionMultiplier += 0.25f; + modPlayer.healingPotionMultiplier += 0.33f; //Grants immunity to most Bleeding debuffs player.buffImmune[BuffID.Bleeding] = true; player.buffImmune[ModContent.BuffType()] = true; diff --git a/Items/Accessories/BloodflareCore.cs b/Items/Accessories/BloodflareCore.cs index 0cc9b6c92a..d045c257a9 100644 --- a/Items/Accessories/BloodflareCore.cs +++ b/Items/Accessories/BloodflareCore.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.bloodflareCore = true; + player.noKnockback = true; } } } diff --git a/Items/Accessories/BloodstainedGlove.cs b/Items/Accessories/BloodstainedGlove.cs index 075af22adf..2c38d71e68 100644 --- a/Items/Accessories/BloodstainedGlove.cs +++ b/Items/Accessories/BloodstainedGlove.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -24,15 +23,5 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.bloodyGlove = true; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 2). - AddIngredient(6). - AddIngredient(ItemID.Vertebrae, 2). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Accessories/BloodyWormScarf.cs b/Items/Accessories/BloodyWormScarf.cs index 8399ef805a..94f56a3c97 100644 --- a/Items/Accessories/BloodyWormScarf.cs +++ b/Items/Accessories/BloodyWormScarf.cs @@ -13,10 +13,11 @@ namespace CalamityMod.Items.Accessories { Item.width = 26; Item.height = 42; - Item.defense = 7; + Item.defense = 3; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/BloodyWormTooth.cs b/Items/Accessories/BloodyWormTooth.cs index 4c6ef7f45c..f81bb96832 100644 --- a/Items/Accessories/BloodyWormTooth.cs +++ b/Items/Accessories/BloodyWormTooth.cs @@ -12,10 +12,11 @@ namespace CalamityMod.Items.Accessories { Item.width = 12; Item.height = 15; - Item.defense = 7; + Item.defense = 3; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -30,7 +31,8 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddTile(TileID.TinkerersWorkbench). AddCondition(Condition.InGraveyard). - Register(); + Register() + .DisableDecraft(); } } } diff --git a/Items/Accessories/BloomStone.cs b/Items/Accessories/BloomStone.cs index 6858aaff91..bd36d30f54 100644 --- a/Items/Accessories/BloomStone.cs +++ b/Items/Accessories/BloomStone.cs @@ -22,101 +22,10 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.25f, 0.4f, 0.2f); - // Provide life benefits if the player is standing on ground and has typical gravity. - int x = (int)player.Center.X / 16; - int y = (int)(player.Bottom.Y - 1f) / 16; - Tile groundTile = CalamityUtils.ParanoidTileRetrieval(x, y + 1); - bool groundTileIsSolid = groundTile.HasUnactuatedTile && (Main.tileSolid[groundTile.TileType] || Main.tileSolidTop[groundTile.TileType]); - if (groundTileIsSolid && player.gravDir == 1f) - modPlayer.BloomStoneRegen = true; - - // Flower boots effects. - if (player.whoAmI == Main.myPlayer && player.velocity.Y == 0f && player.grappling[0] == -1) - { - Tile walkTile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (!walkTile.HasTile && walkTile.LiquidAmount == 0 && groundTile != null && WorldGen.SolidTile(groundTile)) - { - walkTile.TileFrameY = 0; - walkTile.Get().Slope = SlopeType.Solid; - walkTile.Get().IsHalfBlock = false; - // On dirt blocks, there's a small chance to grow a dye plant. - if (groundTile.TileType == TileID.Dirt) - { - if (Main.rand.NextBool(1000)) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.DyePlants; - walkTile.TileFrameX = (short)(34 * Main.rand.Next(0, 13)); - while (walkTile.TileFrameX == 144) - walkTile.TileFrameX = (short)(34 * Main.rand.Next(0, 13)); - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - - // On grass, grow flowers. - if (groundTile.TileType == TileID.Grass) - { - if (Main.rand.NextBool()) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.Plants; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 11)); - - while (walkTile.TileFrameX == 144) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 11)); - } - else - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.Plants2; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 21)); - - while (walkTile.TileFrameX == 144) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 21)); - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - - // On hallowed grass, grow hallowed flowers. - else if (groundTile.TileType == TileID.HallowedGrass) - { - if (Main.rand.NextBool()) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.HallowedPlants; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(4, 7)); - while (walkTile.TileFrameX == 90) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(4, 7)); - } - else - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.HallowedPlants2; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(2, 8)); - while (walkTile.TileFrameX == 90) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(2, 8)); - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - - // On jungle grass, grow jungle flowers. - else if (groundTile.TileType == TileID.JungleGrass) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.JunglePlants2; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(9, 17)); - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - } - } + modPlayer.healingPotionMultiplier += 0.5f; + modPlayer.bloomStone = true; + modPlayer.bloomStoneHookVisuals = true; } + public override void UpdateVanity(Player player) => player.Calamity().bloomStoneHookVisuals = true; } } diff --git a/Items/Accessories/BlunderBooster.cs b/Items/Accessories/BlunderBooster.cs index f702b21117..1a1b2bac13 100644 --- a/Items/Accessories/BlunderBooster.cs +++ b/Items/Accessories/BlunderBooster.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Accessories CreateRecipe(). AddIngredient(). AddIngredient(8). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/Calamity.cs b/Items/Accessories/Calamity.cs index 3499c1c552..14c7c7566f 100644 --- a/Items/Accessories/Calamity.cs +++ b/Items/Accessories/Calamity.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -29,9 +30,10 @@ namespace CalamityMod.Items.Accessories { Item.width = 44; Item.height = 108; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.accessory = true; + Item.expert = true; } public override void UpdateVanity(Player player) @@ -46,6 +48,8 @@ namespace CalamityMod.Items.Accessories player.Calamity().blazingCursorVisuals = true; } + public override void UpdateItemDye(Player player, int dye, bool hideVisual) => player.Calamity().CalamityFireDyeShader = GameShaders.Armor.GetSecondaryShader(dye, player); + public override void UpdateEquip(Player player) => player.Calamity().blazingCursorVisuals = true; public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) diff --git a/Items/Accessories/ChaliceOfTheBloodGod.cs b/Items/Accessories/ChaliceOfTheBloodGod.cs index 622a89f0a2..53a8a5026d 100644 --- a/Items/Accessories/ChaliceOfTheBloodGod.cs +++ b/Items/Accessories/ChaliceOfTheBloodGod.cs @@ -42,7 +42,8 @@ namespace CalamityMod.Items.Accessories Item.width = Item.height = 32; Item.accessory = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -62,6 +63,7 @@ namespace CalamityMod.Items.Accessories // Health boost intentionally stacks with Blood Pact. // This accessory's bleedout buffer clearing effect intentionally stacks with Blood Pact's healing potion boost. modPlayer.chaliceOfTheBloodGod = true; + modPlayer.chaliceHeartStyle = !hideVisual; } public override void AddRecipes() @@ -99,7 +101,7 @@ namespace CalamityMod.Items.Accessories // If this reduces the player's health to zero, make sure they actually die. if (player.statLife <= 0) { - player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ChaliceOfTheBloodGod" + Main.rand.Next(1, 18 + 1)).Format(player.name)), modPlayer.chaliceBleedoutBuffer, 0, false); + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ChaliceOfTheBloodGod" + Main.rand.Next(1, 18 + 1)).ToNetworkText(player.name)), modPlayer.chaliceBleedoutBuffer, 0, false); } } @@ -137,7 +139,7 @@ namespace CalamityMod.Items.Accessories { // Death message changes depending on whether it was the last few drips of an "honored" bleed, or attempting to cheat by removing the accessory. string deathMessageKey = modPlayer.chaliceOfTheBloodGod ? "Status.Death.ChaliceOfTheBloodGodClose" : "Status.Death.ChaliceOfTheBloodGodUnequip"; - player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText(deathMessageKey).Format(player.name)), modPlayer.chaliceBleedoutBuffer, 0, false); + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText(deathMessageKey).ToNetworkText(player.name)), modPlayer.chaliceBleedoutBuffer, 0, false); } } diff --git a/Items/Accessories/ChaosStone.cs b/Items/Accessories/ChaosStone.cs index 89b7f583a6..e339d2c5f8 100644 --- a/Items/Accessories/ChaosStone.cs +++ b/Items/Accessories/ChaosStone.cs @@ -1,13 +1,25 @@ -using Terraria; +using System.Collections.Generic; +using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { public class ChaosStone : ModItem, ILocalizedModType { + public static float LostRegenPer100Mana => 8; + public static float DamageMultPer100Mana => 0.03f; public new string LocalizationCategory => "Items.Accessories"; + public override void ModifyTooltips(List tooltips) + { + + var regenAmount = Main.LocalPlayer.statManaMax2 == 0 ? 0 : (int)((Main.LocalPlayer.statManaMax2 / 100f) * LostRegenPer100Mana) * 0.5f; + var dmgAmount = Main.LocalPlayer.statManaMax2 == 0 ? 0 : ((Main.LocalPlayer.statManaMax2 / 100f) * DamageMultPer100Mana * 100); + tooltips.FindAndReplaceAll("[REGEN]", regenAmount.ToString("0.#")); + tooltips.FindAndReplaceAll("[DAMAGE]", dmgAmount.ToString("0.#")); + } public override void SetStaticDefaults() { Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(8, 7)); diff --git a/Items/Accessories/CleansingJelly.cs b/Items/Accessories/CleansingJelly.cs index 298278de0b..f59074872b 100644 --- a/Items/Accessories/CleansingJelly.cs +++ b/Items/Accessories/CleansingJelly.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.Localization; diff --git a/Items/Accessories/CoinofDeceit.cs b/Items/Accessories/CoinofDeceit.cs index 694429bc96..1b9ac86cd6 100644 --- a/Items/Accessories/CoinofDeceit.cs +++ b/Items/Accessories/CoinofDeceit.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().stealthStrike85Cost = true; + player.Calamity().stealthStrike90Cost = true; player.GetCritChance() += 6; } diff --git a/Items/Accessories/CorrosiveSpine.cs b/Items/Accessories/CorrosiveSpine.cs index f9bc1fde4a..cf72391472 100644 --- a/Items/Accessories/CorrosiveSpine.cs +++ b/Items/Accessories/CorrosiveSpine.cs @@ -1,6 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Rogue; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,7 +14,6 @@ namespace CalamityMod.Items.Accessories Item.height = 46; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 4; Item.accessory = true; } @@ -25,6 +22,8 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.corrosiveSpine = true; player.moveSpeed += 0.05f; + modPlayer.WaterDebuffMultiplier += 0.25f; + modPlayer.SicknessDebuffMultiplier += 0.25f; } } } diff --git a/Items/Accessories/CorruptFlask.cs b/Items/Accessories/CorruptFlask.cs deleted file mode 100644 index db6a38b7fb..0000000000 --- a/Items/Accessories/CorruptFlask.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class CorruptFlask : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.width = 20; - Item.height = 20; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.buffImmune[ModContent.BuffType()] = true; - if (player.ZoneCorrupt) - { - player.statDefense += 6; - player.endurance += 0.04f; - } - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.VilePowder, 15). - AddIngredient(ItemID.RottenChunk, 10). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Accessories/CounterScarf.cs b/Items/Accessories/CounterScarf.cs index 1f36cadfd2..0d211b9d97 100644 --- a/Items/Accessories/CounterScarf.cs +++ b/Items/Accessories/CounterScarf.cs @@ -14,16 +14,12 @@ namespace CalamityMod.Items.Accessories { Item.width = 30; Item.height = 38; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.value = Item.buyPrice(gold: 20); // Sold by Clothier Item.rare = ItemRarityID.Orange; Item.accessory = true; } - - public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().dodgeScarf; - public override void UpdateAccessory(Player player, bool hideVisual) { - player.GetDamage() += 0.1f; CalamityPlayer modPlayer = player.Calamity(); modPlayer.dodgeScarf = true; modPlayer.DashID = CounterScarfDash.ID; diff --git a/Items/Accessories/CrawCarapace.cs b/Items/Accessories/CrawCarapace.cs index fcb357da8a..63f99afc7e 100644 --- a/Items/Accessories/CrawCarapace.cs +++ b/Items/Accessories/CrawCarapace.cs @@ -8,6 +8,9 @@ namespace CalamityMod.Items.Accessories public class CrawCarapace : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int ThornsDamage => CalamityUtils.ScaleWithDifficulty(20); + public override void SetDefaults() { Item.width = 28; @@ -21,7 +24,6 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.crawCarapace = true; - player.thorns += 0.25f; } } } diff --git a/Items/Accessories/CrimsonFlask.cs b/Items/Accessories/CrimsonFlask.cs deleted file mode 100644 index dc1d4c038c..0000000000 --- a/Items/Accessories/CrimsonFlask.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class CrimsonFlask : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.width = 20; - Item.height = 20; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.buffImmune[ModContent.BuffType()] = true; - if (player.ZoneCrimson) - { - player.statDefense += 6; - player.endurance += 0.04f; - } - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.ViciousPowder, 15). - AddIngredient(ItemID.Vertebrae, 10). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Accessories/CrownJewel.cs b/Items/Accessories/CrownJewel.cs index 1c85ffd2fe..9c4b4cfca5 100644 --- a/Items/Accessories/CrownJewel.cs +++ b/Items/Accessories/CrownJewel.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 26; Item.height = 26; - Item.defense = 4; + Item.defense = 1; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; Item.accessory = true; diff --git a/Items/Accessories/CryoStone.cs b/Items/Accessories/CryoStone.cs index bf6e2deb08..687768b0c5 100644 --- a/Items/Accessories/CryoStone.cs +++ b/Items/Accessories/CryoStone.cs @@ -23,7 +23,11 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; } - public override void UpdateAccessory(Player player, bool hideVisual) => player.Calamity().CryoStone = true; + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.Calamity().CryoStone = true; + player.Calamity().ColdDebuffMultiplier += 0.5f; + } public override void UpdateVanity(Player player) => player.Calamity().CryoStoneVanity = true; } diff --git a/Items/Accessories/DaawnlightSpiritOrigin.cs b/Items/Accessories/DaawnlightSpiritOrigin.cs index e5a655113b..2fbb970c79 100644 --- a/Items/Accessories/DaawnlightSpiritOrigin.cs +++ b/Items/Accessories/DaawnlightSpiritOrigin.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Accessories // "Despite the seemingly insane numbers here, I think this item might actually be underpowered" // hindsight: the item was not underpowered. Ozzatron 05NOV2021 - // Memes 03SEP2024: Old comments kept for record. + // 03SEP2024: Old comments kept for record. #region Balancing Variables @@ -58,6 +58,11 @@ namespace CalamityMod.Items.Accessories // Special search radius for coin ricoshots that only applies to DSO targets. public static readonly float RicoshotSearchDistance = 2800f; + /// + /// The maximum amount of extra critical strike chance you can get from this accessory. + /// + public static readonly int CritHardCap = 100; + #endregion public override void SetDefaults() @@ -115,7 +120,7 @@ namespace CalamityMod.Items.Accessories modPlayer.spiritOriginCritBoost = currentCritBoost; // Actually give the crit boost as a direct increase to ranged critical strike chance. - player.GetCritChance() += modPlayer.spiritOriginCritBoost; + player.GetCritChance() += Math.Min(modPlayer.spiritOriginCritBoost, CritHardCap); // Display the current crit boost on a cooldown. if (modPlayer.cooldowns.TryGetValue(DaawnlightSpiritOriginExtraCrit.ID, out var cooldown)) @@ -147,7 +152,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(15). AddIngredient(ItemID.LunarBar, 10). AddIngredient(4). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/DarkSunRing.cs b/Items/Accessories/DarkSunRing.cs index 030506fa76..e86eea2a52 100644 --- a/Items/Accessories/DarkSunRing.cs +++ b/Items/Accessories/DarkSunRing.cs @@ -29,16 +29,17 @@ namespace CalamityMod.Items.Accessories Item.width = 42; Item.height = 60; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 10; + Item.defense = 4; Item.lifeRegen = 1; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.darkSunRing = true; + player.noKnockback = true; } public override void AddRecipes() diff --git a/Items/Accessories/DeadshotBrooch.cs b/Items/Accessories/DeadshotBrooch.cs index d017624cdf..16e3459913 100644 --- a/Items/Accessories/DeadshotBrooch.cs +++ b/Items/Accessories/DeadshotBrooch.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().deadshotBrooch = true; - player.Calamity().rangedAmmoCost *= 0.8f; + player.Calamity().ammoCost *= 0.8f; player.GetDamage() += 0.12f; player.GetCritChance() += 7; } diff --git a/Items/Accessories/DeificAmulet.cs b/Items/Accessories/DeificAmulet.cs index b79a6ea9c4..32593b0266 100644 --- a/Items/Accessories/DeificAmulet.cs +++ b/Items/Accessories/DeificAmulet.cs @@ -1,9 +1,13 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using System.IO; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Accessories { @@ -12,6 +16,7 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public static readonly int MaxBonusIFrames = 30; + public static int StarDamage => CalamityUtils.ScaleWithDifficulty(130); public override void SetDefaults() { @@ -22,20 +27,61 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; } + #region Toggleable Panic Necklace + + bool panicNecklaceEnabled = true; + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplace("[TOGGLE]", panicNecklaceEnabled ? this.GetLocalizedValue("ToggleEffect") : ""); + } + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + panicNecklaceEnabled = !panicNecklaceEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("panic", panicNecklaceEnabled); + } + + public override void LoadData(TagCompound tag) + { + panicNecklaceEnabled = tag.GetBool("panic"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(panicNecklaceEnabled); + } + + public override void NetReceive(BinaryReader reader) + { + panicNecklaceEnabled = reader.ReadBoolean(); + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, panicNecklaceEnabled); + } + #endregion + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); player.longInvince = true; modPlayer.dAmulet = true; + player.panic = panicNecklaceEnabled; } public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.StarVeil). + AddIngredient(ItemID.SweetheartNecklace). AddIngredient(10). - AddIngredient(15). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.TinkerersWorkbench). Register(); } } diff --git a/Items/Accessories/DeificAmulet.png b/Items/Accessories/DeificAmulet.png index 5556bbee2d..8dc07eb339 100644 Binary files a/Items/Accessories/DeificAmulet.png and b/Items/Accessories/DeificAmulet.png differ diff --git a/Items/Accessories/DiamondOfTheDeep.cs b/Items/Accessories/DiamondOfTheDeep.cs new file mode 100644 index 0000000000..ee6c3d8e97 --- /dev/null +++ b/Items/Accessories/DiamondOfTheDeep.cs @@ -0,0 +1,46 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Abyss; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + [LegacyName("LumenousAmulet")] + [AutoloadEquip(EquipType.Neck)] + public class DiamondOfTheDeep : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public override void SetDefaults() + { + Item.width = 26; + Item.height = 26; + Item.value = CalamityGlobalItem.RarityLimeBuyPrice; + Item.rare = ItemRarityID.Lime; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.dOfTheDeep = true; + modPlayer.dOfTheDeepVisual = !hideVisual; + modPlayer.WaterDebuffMultiplier += 0.75f; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(10). + AddIngredient(5). + AddIngredient(10). + AddIngredient(5). + AddIngredient(10). + AddIngredient(5). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Accessories/LumenousAmulet.png b/Items/Accessories/DiamondOfTheDeep.png similarity index 100% rename from Items/Accessories/LumenousAmulet.png rename to Items/Accessories/DiamondOfTheDeep.png diff --git a/Items/Accessories/LumenousAmulet_Neck.png b/Items/Accessories/DiamondOfTheDeep_Neck.png similarity index 100% rename from Items/Accessories/LumenousAmulet_Neck.png rename to Items/Accessories/DiamondOfTheDeep_Neck.png diff --git a/Items/Accessories/DimensionalSoulArtifact.cs b/Items/Accessories/DimensionalSoulArtifact.cs index e449c12a33..b8541a3f47 100644 --- a/Items/Accessories/DimensionalSoulArtifact.cs +++ b/Items/Accessories/DimensionalSoulArtifact.cs @@ -3,8 +3,8 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Accessories Item.width = 28; Item.height = 28; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; } @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(5). AddIngredient(25). AddIngredient(25). - AddTile(TileID.DemonAltar). + AddTile(). Register(); } } diff --git a/Items/Accessories/DraedonsHeart.cs b/Items/Accessories/DraedonsHeart.cs index abbe1e35a3..66d5d7aa9a 100644 --- a/Items/Accessories/DraedonsHeart.cs +++ b/Items/Accessories/DraedonsHeart.cs @@ -42,9 +42,10 @@ namespace CalamityMod.Items.Accessories Item.width = 52; Item.height = 68; Item.accessory = true; - Item.defense = 48; + Item.defense = 20; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -57,6 +58,7 @@ namespace CalamityMod.Items.Accessories modPlayer.adrenaline = 0f; modPlayer.draedonsHeart = true; + player.noKnockback = true; modPlayer.hadNanomachinesLastFrame = true; modPlayer.AdrenalineDuration = NanomachinesDuration; modPlayer.contactDamageReduction += ContactDamageReduction; diff --git a/Items/Accessories/DragonScales.cs b/Items/Accessories/DragonScales.cs index 766939ee78..5bc10a0e90 100644 --- a/Items/Accessories/DragonScales.cs +++ b/Items/Accessories/DragonScales.cs @@ -2,7 +2,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -17,8 +16,8 @@ namespace CalamityMod.Items.Accessories { Item.width = 32; Item.height = 34; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.value = Item.buyPrice(platinum: 15); // Sold by Bandit + Item.rare = ModContent.RarityType(); Item.accessory = true; } diff --git a/Items/Accessories/DynamoStemCells.cs b/Items/Accessories/DynamoStemCells.cs index dfd9f7fe01..35a09913aa 100644 --- a/Items/Accessories/DynamoStemCells.cs +++ b/Items/Accessories/DynamoStemCells.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; @@ -13,7 +11,7 @@ namespace CalamityMod.Items.Accessories public class DynamoStemCells : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public const int MiniSwamerCooldown = 180; + public const int MiniSwarmerCooldown = 180; public static int MiniSwamerDamage = 1000; public override void SetStaticDefaults() { @@ -28,6 +26,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/EclipseMirror.cs b/Items/Accessories/EclipseMirror.cs index 056d43cdfc..5c1f638a15 100644 --- a/Items/Accessories/EclipseMirror.cs +++ b/Items/Accessories/EclipseMirror.cs @@ -3,7 +3,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Accessories Item.width = 30; Item.height = 46; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.accessory = true; } diff --git a/Items/Accessories/EldritchSoulArtifact.cs b/Items/Accessories/EldritchSoulArtifact.cs index 5bb6405a7c..0e1299f0ed 100644 --- a/Items/Accessories/EldritchSoulArtifact.cs +++ b/Items/Accessories/EldritchSoulArtifact.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(5). AddIngredient(25). AddIngredient(25). - AddTile(TileID.DemonAltar). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/ElementalGauntlet.cs b/Items/Accessories/ElementalGauntlet.cs index d28518d7fb..8076f1727e 100644 --- a/Items/Accessories/ElementalGauntlet.cs +++ b/Items/Accessories/ElementalGauntlet.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Accessories Item.height = 38; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/ElementalinaBottle.cs b/Items/Accessories/ElementalinaBottle.cs new file mode 100644 index 0000000000..0ea04c9cac --- /dev/null +++ b/Items/Accessories/ElementalinaBottle.cs @@ -0,0 +1,60 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + [LegacyName("WifeinaBottle")] + public class ElementalinaBottle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public const int ElementalDamage = 45; + + public override void SetDefaults() + { + Item.width = 20; + Item.height = 26; + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; + Item.accessory = true; + } + + public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().elementalHeart; + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.sandElemental = true; + SpawnElemental(player); + } + + public override void UpdateVanity(Player player) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.sandElementalVanity = true; + SpawnElemental(player); + } + + public void SpawnElemental(Player player) + { + if (player.whoAmI == Main.myPlayer) + { + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + { + player.AddBuff(ModContent.BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + int damage = (int)player.GetTotalDamage().ApplyTo(ElementalDamage); + + var p = Projectile.NewProjectileDirect(player.GetSource_Accessory(Item), player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer); + p.originalDamage = ElementalDamage; + } + } + } + } +} diff --git a/Items/Accessories/WifeinaBottle.png b/Items/Accessories/ElementalinaBottle.png similarity index 100% rename from Items/Accessories/WifeinaBottle.png rename to Items/Accessories/ElementalinaBottle.png diff --git a/Items/Accessories/ElysianAegis.cs b/Items/Accessories/ElysianAegis.cs index 192f3565f2..89722b2b07 100644 --- a/Items/Accessories/ElysianAegis.cs +++ b/Items/Accessories/ElysianAegis.cs @@ -1,26 +1,24 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.CalPlayer.Dashes; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { [AutoloadEquip(EquipType.Shield)] - public class ElysianAegis : ModItem, ILocalizedModType, IHoldShiftTooltipItem + public class ElysianAegis : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; public bool HasFlavorTooltip => true; public Color? TooltipExtensionColor => new(195, 223, 255); - public const int ShieldSlamDamage = 400; + public const int ShieldSlamDamage = 500; public const float ShieldSlamKnockback = 12f; public const int ShieldSlamIFrames = 12; - public const int RamExplosionDamage = 200; + public const int RamExplosionDamage = 100; public const float RamExplosionKnockback = 15f; public override void SetDefaults() @@ -29,30 +27,16 @@ namespace CalamityMod.Items.Accessories Item.height = 42; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); - Item.defense = 10; + Item.defense = 5; Item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - - // Elysian Aegis ram dash modPlayer.DashID = ElysianAegisDash.ID; player.dashType = 0; - - // Vaguely inherited Ankh Shield effects I guess player.noKnockback = true; - player.fireWalk = true; - - // Debuff immunities - player.buffImmune[BuffID.OnFire] = true; - player.buffImmune[BuffID.OnFire3] = true; - player.buffImmune[BuffID.CursedInferno] = true; - player.buffImmune[BuffID.ShadowFlame] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[ModContent.BuffType()] = true; } } } diff --git a/Items/Accessories/EnchantedPearl.png b/Items/Accessories/EnchantedPearl.png index db3018d0fe..1dcc3798c7 100644 Binary files a/Items/Accessories/EnchantedPearl.png and b/Items/Accessories/EnchantedPearl.png differ diff --git a/Items/Accessories/EtherealExtorter.cs b/Items/Accessories/EtherealExtorter.cs index c963385ea8..98ee31e460 100644 --- a/Items/Accessories/EtherealExtorter.cs +++ b/Items/Accessories/EtherealExtorter.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories Item.width = 28; Item.height = 32; Item.accessory = true; - Item.value = CalamityGlobalItem.RarityYellowBuyPrice; + Item.value = Item.buyPrice(platinum: 1); // Sold by Bandit Item.rare = ItemRarityID.Yellow; } diff --git a/Items/Accessories/EtherealTalisman.cs b/Items/Accessories/EtherealTalisman.cs index 84cb1fa4bb..b3c6331489 100644 --- a/Items/Accessories/EtherealTalisman.cs +++ b/Items/Accessories/EtherealTalisman.cs @@ -1,10 +1,14 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using System.IO; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Accessories { @@ -17,21 +21,60 @@ namespace CalamityMod.Items.Accessories Item.height = 32; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); + } + #region Toggleable Mana Flower + + bool manaFlowerEnabled = true; + public override void ModifyTooltips(List tooltips) + { + if (!manaFlowerEnabled) + tooltips.RemoveAll(x => x.Name == "Tooltip3"); + } + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + manaFlowerEnabled = !manaFlowerEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("manaFlower", manaFlowerEnabled); } + public override void LoadData(TagCompound tag) + { + manaFlowerEnabled = tag.GetBool("manaFlower"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(manaFlowerEnabled); + } + + public override void NetReceive(BinaryReader reader) + { + manaFlowerEnabled = reader.ReadBoolean(); + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, manaFlowerEnabled); + } + #endregion public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.eTalisman = true; player.manaMagnet = true; - if (!hideVisual) + if (manaFlowerEnabled) player.manaFlower = true; player.statManaMax2 += 150; player.GetDamage() += 0.15f; - player.manaCost *= 0.9f; + player.manaCost -= 0.1f; player.GetCritChance() += 5; } diff --git a/Items/Accessories/EvasionScarf.cs b/Items/Accessories/EvasionScarf.cs index cf9f6bdeef..02ee2fdc81 100644 --- a/Items/Accessories/EvasionScarf.cs +++ b/Items/Accessories/EvasionScarf.cs @@ -20,11 +20,8 @@ namespace CalamityMod.Items.Accessories Item.Calamity().donorItem = true; } - public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().dodgeScarf; - public override void UpdateAccessory(Player player, bool hideVisual) { - player.GetDamage() += 0.15f; CalamityPlayer modPlayer = player.Calamity(); modPlayer.dodgeScarf = true; modPlayer.evasionScarf = true; diff --git a/Items/Accessories/EyeoftheStorm.cs b/Items/Accessories/EyeoftheStorm.cs index d787a45479..3a270de644 100644 --- a/Items/Accessories/EyeoftheStorm.cs +++ b/Items/Accessories/EyeoftheStorm.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -34,12 +33,12 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.cloudWaifu = true; + modPlayer.cloudElemental = true; if (player.whoAmI == Main.myPlayer) { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) + if (player.FindBuffIndex(ModContent.BuffType()) == -1) { - player.AddBuff(ModContent.BuffType(), 3600, true); + player.AddBuff(ModContent.BuffType(), 3600, true); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { @@ -55,12 +54,12 @@ namespace CalamityMod.Items.Accessories public override void UpdateVanity(Player player) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.cloudWaifuVanity = true; + modPlayer.cloudElementalVanity = true; if (player.whoAmI == Main.myPlayer) { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) + if (player.FindBuffIndex(ModContent.BuffType()) == -1) { - player.AddBuff(ModContent.BuffType(), 3600, true); + player.AddBuff(ModContent.BuffType(), 3600, true); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { diff --git a/Items/Accessories/FeatherCrown.cs b/Items/Accessories/FeatherCrown.cs index c422418d78..01132959e8 100644 --- a/Items/Accessories/FeatherCrown.cs +++ b/Items/Accessories/FeatherCrown.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Accessories AddRecipeGroup("AnyGoldCrown"). AddIngredient(6). AddIngredient(ItemID.Feather, 8). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Accessories/FilthyGlove.cs b/Items/Accessories/FilthyGlove.cs index 905d4c0ccb..d73661f248 100644 --- a/Items/Accessories/FilthyGlove.cs +++ b/Items/Accessories/FilthyGlove.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -24,15 +23,5 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.filthyGlove = true; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.DemoniteBar, 2). - AddIngredient(6). - AddIngredient(ItemID.RottenChunk, 2). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Accessories/FlameLickedShell.cs b/Items/Accessories/FlameLickedShell.cs index 4637cba6cc..3b47623fee 100644 --- a/Items/Accessories/FlameLickedShell.cs +++ b/Items/Accessories/FlameLickedShell.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using CalamityMod.CalPlayer; using CalamityMod.Dusts; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -26,12 +24,14 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.flameLickedShell = true; + player.noKnockback = true; } public static void handleParry(Player player) diff --git a/Items/Accessories/FungalClump.cs b/Items/Accessories/FungalClump.cs index b7a5cb048e..985e81bef8 100644 --- a/Items/Accessories/FungalClump.cs +++ b/Items/Accessories/FungalClump.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ID; @@ -20,6 +19,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/GiantPearl.cs b/Items/Accessories/GiantPearl.cs index 86de98ed56..7852f765ac 100644 --- a/Items/Accessories/GiantPearl.cs +++ b/Items/Accessories/GiantPearl.cs @@ -1,7 +1,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Accessories/GiantShell.cs b/Items/Accessories/GiantShell.cs index 52297d4d96..fe575c6fd1 100644 --- a/Items/Accessories/GiantShell.cs +++ b/Items/Accessories/GiantShell.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 30; Item.height = 28; - Item.defense = 6; + Item.defense = 5; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; Item.accessory = true; diff --git a/Items/Accessories/GiantTortoiseShell.cs b/Items/Accessories/GiantTortoiseShell.cs index 579d15d32f..9551ffbb81 100644 --- a/Items/Accessories/GiantTortoiseShell.cs +++ b/Items/Accessories/GiantTortoiseShell.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 46; Item.height = 30; - Item.defense = 15; + Item.defense = 10; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; Item.accessory = true; diff --git a/Items/Accessories/GladiatorsLocket.cs b/Items/Accessories/GladiatorsLocket.cs index c7b583cea5..104e8933bc 100644 --- a/Items/Accessories/GladiatorsLocket.cs +++ b/Items/Accessories/GladiatorsLocket.cs @@ -1,8 +1,4 @@ using System; -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +10,8 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.width = 42; - Item.height = 36; + Item.width = 48; + Item.height = 54; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; diff --git a/Items/Accessories/GladiatorsLocket.png b/Items/Accessories/GladiatorsLocket.png index d2e1c67d65..372792ae48 100644 Binary files a/Items/Accessories/GladiatorsLocket.png and b/Items/Accessories/GladiatorsLocket.png differ diff --git a/Items/Accessories/GloveofPrecision.cs b/Items/Accessories/GloveofPrecision.cs index 9cb6f21173..81a152d40d 100644 --- a/Items/Accessories/GloveofPrecision.cs +++ b/Items/Accessories/GloveofPrecision.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.gloveOfPrecision = true; player.GetDamage() += 0.10f; - player.GetCritChance() += 15; + player.GetCritChance() += 10; modPlayer.rogueVelocity += 0.15f; player.GetAttackSpeed() -= 0.15f; } diff --git a/Items/Accessories/GrandGelatin.cs b/Items/Accessories/GrandGelatin.cs index 1bf8309fd9..d00de8a399 100644 --- a/Items/Accessories/GrandGelatin.cs +++ b/Items/Accessories/GrandGelatin.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.Localization; @@ -14,7 +13,7 @@ namespace CalamityMod.Items.Accessories public static float MoveSpeedBoost = 0.12f; public static float JumpSpeedBoost = 0.6f; // Both 12% so we only need just one in the tooltip public static int AuraLifetime = 1800; - public static int AuraRegenBoost = 6; + public static int AuraRegenBoost = 4; public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent(), AuraLifetime.FramesToSeconds(), AuraRegenBoost.ToRegenPerSecond()); public override void SetDefaults() diff --git a/Items/Accessories/HallowedRune.cs b/Items/Accessories/HallowedRune.cs index 360aa5df98..2630de753f 100644 --- a/Items/Accessories/HallowedRune.cs +++ b/Items/Accessories/HallowedRune.cs @@ -9,8 +9,7 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public static int RegenBoost = 3; - public static int DefenseBoost = 8; - public static float DamageReductionBoost = 0.04f; + public static int DefenseBoost = 5; public static float SummonDamageBoost = 0.1f; public override void SetDefaults() diff --git a/Items/Accessories/HarpyRing.cs b/Items/Accessories/HarpyRing.cs index 927a30b43a..e6af6589cf 100644 --- a/Items/Accessories/HarpyRing.cs +++ b/Items/Accessories/HarpyRing.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(2). AddIngredient(ItemID.SunplateBlock, 2). AddIngredient(ItemID.Feather, 5). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Accessories/HeartofDarkness.cs b/Items/Accessories/HeartofDarkness.cs index 41c8bcedcd..ad0586e27c 100644 --- a/Items/Accessories/HeartofDarkness.cs +++ b/Items/Accessories/HeartofDarkness.cs @@ -1,9 +1,6 @@ using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -13,7 +10,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; // The percentage of a full Rage bar that is gained every second with Heart of Darkness equipped. - public const float RagePerSecond = 0.01f; + public const float RagePerSecond = 0.02f; public override void SetStaticDefaults() { diff --git a/Items/Accessories/HeartoftheElements.cs b/Items/Accessories/HeartoftheElements.cs index 8ea3582908..948499ad65 100644 --- a/Items/Accessories/HeartoftheElements.cs +++ b/Items/Accessories/HeartoftheElements.cs @@ -1,8 +1,6 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; -using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -36,7 +34,7 @@ namespace CalamityMod.Items.Accessories public override bool CanEquipAccessory(Player player, int slot, bool modded) { CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.brimstoneWaifu || modPlayer.sandWaifu || modPlayer.sandBoobWaifu || modPlayer.cloudWaifu || modPlayer.sirenWaifu) + if (modPlayer.brimElemental || modPlayer.sandElemental || modPlayer.rareSandElemental || modPlayer.cloudElemental || modPlayer.waterElemental) { return false; } @@ -49,7 +47,7 @@ namespace CalamityMod.Items.Accessories Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, Main.DiscoR / 255f, Main.DiscoG / 255f, Main.DiscoB / 255f); CalamityPlayer modPlayer = player.Calamity(); - modPlayer.allWaifus = true; + modPlayer.allElementals = true; modPlayer.elementalHeart = true; int brimmy = ProjectileType(); @@ -113,7 +111,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateVanity(Player player) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.allWaifusVanity = true; + modPlayer.allElementalsVanity = true; // modPlayer.elementalHeart = true; int brimmy = ProjectileType(); @@ -178,11 +176,12 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(). + AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(). AddIngredient(). + AddIngredient(ItemID.FragmentStardust, 6). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Accessories/HideofAstrumDeus.cs b/Items/Accessories/HideofAstrumDeus.cs index 45526da47c..d73eca4c00 100644 --- a/Items/Accessories/HideofAstrumDeus.cs +++ b/Items/Accessories/HideofAstrumDeus.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +8,10 @@ namespace CalamityMod.Items.Accessories public class HideofAstrumDeus : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int BlazeDamage => CalamityUtils.ScaleWithDifficulty(50); + public static int StarDamage => 75; + public override void SetDefaults() { Item.width = 26; @@ -16,6 +19,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityCyanBuyPrice; Item.rare = ItemRarityID.Cyan; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -24,7 +28,6 @@ namespace CalamityMod.Items.Accessories modPlayer.hideOfDeus = true; if (modPlayer.hideOfDeusMeleeBoostTimer > 0) player.GetDamage() += 0.3f; - player.thorns += 0.75f; } } } diff --git a/Items/Accessories/HoneyDew.cs b/Items/Accessories/HoneyDew.cs index 5411c27755..cedef67539 100644 --- a/Items/Accessories/HoneyDew.cs +++ b/Items/Accessories/HoneyDew.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,17 +12,17 @@ namespace CalamityMod.Items.Accessories { Item.width = 20; Item.height = 20; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; Item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { - player.statLifeMax2 += 30; + player.statLifeMax2 += 10; + if (!player.HasBuff(BuffID.Honey)) + player.AddBuff(BuffID.Honey, 2); CalamityPlayer modPlayer = player.Calamity(); - modPlayer.alwaysHoneyRegen = true; - modPlayer.honeyTurboRegen = true; modPlayer.honeyDewHalveDebuffs = true; } diff --git a/Items/Accessories/HowlsHeart.cs b/Items/Accessories/HowlsHeart.cs index 8fdf7cac32..3ce9519e09 100644 --- a/Items/Accessories/HowlsHeart.cs +++ b/Items/Accessories/HowlsHeart.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories Item.height = 26; Item.accessory = true; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; + Item.value = Item.buyPrice(gold: 20); // Sold by Wizard Item.rare = ItemRarityID.LightRed; Item.Calamity().donorItem = true; } diff --git a/Items/Accessories/IVDripOnTheRocks.cs b/Items/Accessories/IVDripOnTheRocks.cs new file mode 100644 index 0000000000..aebb7705d0 --- /dev/null +++ b/Items/Accessories/IVDripOnTheRocks.cs @@ -0,0 +1,42 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Rarities; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class IVDripOnTheRocks : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public static readonly float DamageBoostMultiplier = 1.25f; // Same as Old Fashioned but can be changed at any time + public static readonly float DamageReductionMultiplier = 0.75f; // Same as Old Fashioned but can be changed at any time + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DamageBoostMultiplier).ToString("N2"), (DamageReductionMultiplier).ToString("N2")); public override void SetDefaults() + { + Item.width = 58; + Item.height = 60; + Item.value = CalamityGlobalItem.RarityLimeBuyPrice; + Item.rare = ItemRarityID.Lime; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.ivDrip = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(6). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Accessories/IVDripOnTheRocks.png b/Items/Accessories/IVDripOnTheRocks.png new file mode 100644 index 0000000000..b2736f4dac Binary files /dev/null and b/Items/Accessories/IVDripOnTheRocks.png differ diff --git a/Items/Accessories/InfectedJewel.cs b/Items/Accessories/InfectedJewel.cs index c5c18c08f6..7746446c7f 100644 --- a/Items/Accessories/InfectedJewel.cs +++ b/Items/Accessories/InfectedJewel.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 26; Item.height = 26; - Item.defense = 6; + Item.defense = 4; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; Item.accessory = true; diff --git a/Items/Accessories/InkBomb.cs b/Items/Accessories/InkBomb.cs index 6ed93531bb..5f7a6cad05 100644 --- a/Items/Accessories/InkBomb.cs +++ b/Items/Accessories/InkBomb.cs @@ -8,6 +8,9 @@ namespace CalamityMod.Items.Accessories public class InkBomb : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int InkDamage => CalamityUtils.ScaleWithDifficulty(16); + public override void SetDefaults() { Item.width = 22; @@ -21,6 +24,8 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.inkBomb = true; + modPlayer.stealthGenStandstill += 0.07f; + modPlayer.stealthGenMoving += 0.07f; } } } diff --git a/Items/Accessories/InterstellarStompers.cs b/Items/Accessories/InterstellarStompers.cs index 992c2d701c..2f82b292fb 100644 --- a/Items/Accessories/InterstellarStompers.cs +++ b/Items/Accessories/InterstellarStompers.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.accessory = true; Item.rare = ItemRarityID.Lime; + Item.expert = true; } public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.GravistarSabatonHotkey); diff --git a/Items/Accessories/IronBoots.cs b/Items/Accessories/IronBoots.cs index a87ec69437..5e50b0a3b2 100644 --- a/Items/Accessories/IronBoots.cs +++ b/Items/Accessories/IronBoots.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.ironBoots = true; + player.noFallDmg = true; } } } diff --git a/Items/Accessories/JellyChargedBattery.png b/Items/Accessories/JellyChargedBattery.png index e389aad9f4..8edc8c65a6 100644 Binary files a/Items/Accessories/JellyChargedBattery.png and b/Items/Accessories/JellyChargedBattery.png differ diff --git a/Items/Accessories/LeviathanAmbergris.cs b/Items/Accessories/LeviathanAmbergris.cs index a50bfc0663..50ae2b6ba1 100644 --- a/Items/Accessories/LeviathanAmbergris.cs +++ b/Items/Accessories/LeviathanAmbergris.cs @@ -1,6 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,7 +8,7 @@ namespace CalamityMod.Items.Accessories public class LeviathanAmbergris : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public static int ambergrisDashDamage = 90; + public static int ambergrisDashDamage = 650; public override void SetDefaults() { Item.width = 20; @@ -18,12 +16,14 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.accessory = true; Item.rare = ItemRarityID.Lime; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.lAmbergris = true; + modPlayer.lAmbergrisVisual = !hideVisual; } } } diff --git a/Items/Accessories/LifeJelly.cs b/Items/Accessories/LifeJelly.cs index 00020facef..276c9bf725 100644 --- a/Items/Accessories/LifeJelly.cs +++ b/Items/Accessories/LifeJelly.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.Localization; diff --git a/Items/Accessories/LivingDew.cs b/Items/Accessories/LivingDew.cs index bc76e4a498..ca84090d44 100644 --- a/Items/Accessories/LivingDew.cs +++ b/Items/Accessories/LivingDew.cs @@ -20,12 +20,12 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.statLifeMax2 += 50; + player.statLifeMax2 += 25; + if (!player.HasBuff(BuffID.Honey)) + player.AddBuff(BuffID.Honey, 2); // Inherits all effects of Honey Dew CalamityPlayer modPlayer = player.Calamity(); - modPlayer.alwaysHoneyRegen = true; - modPlayer.honeyTurboRegen = true; modPlayer.honeyDewHalveDebuffs = true; modPlayer.livingDewHalveDebuffs = true; } diff --git a/Items/Accessories/LumenousAmulet.cs b/Items/Accessories/LumenousAmulet.cs deleted file mode 100644 index 7b07d0c8f0..0000000000 --- a/Items/Accessories/LumenousAmulet.cs +++ /dev/null @@ -1,41 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - [AutoloadEquip(EquipType.Neck)] - public class LumenousAmulet : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.width = 26; - Item.height = 26; - Item.value = CalamityGlobalItem.RarityLimeBuyPrice; - Item.rare = ItemRarityID.Lime; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.lumenousAmulet = true; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[ModContent.BuffType()] = true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(15). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Accessories/LuxorsGift.cs b/Items/Accessories/LuxorsGift.cs index aeeda7a03d..d051683737 100644 --- a/Items/Accessories/LuxorsGift.cs +++ b/Items/Accessories/LuxorsGift.cs @@ -1,14 +1,7 @@ -using System; -using CalamityMod.CalPlayer; -using CalamityMod.Cooldowns; -using CalamityMod.NPCs; -using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; diff --git a/Items/Accessories/ManaPolarizer.cs b/Items/Accessories/ManaPolarizer.cs index 95e449d742..73fc472501 100644 --- a/Items/Accessories/ManaPolarizer.cs +++ b/Items/Accessories/ManaPolarizer.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/MarniteRepulsionShield.cs b/Items/Accessories/MarniteRepulsionShield.cs index 8f20c5926b..094772ac70 100644 --- a/Items/Accessories/MarniteRepulsionShield.cs +++ b/Items/Accessories/MarniteRepulsionShield.cs @@ -1,16 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using static CalamityMod.CalamityUtils; namespace CalamityMod.Items.Accessories { @@ -27,7 +19,7 @@ namespace CalamityMod.Items.Accessories Item.rare = ItemRarityID.Blue; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.accessory = true; - Item.defense = 4; + Item.defense = 3; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -92,6 +84,8 @@ namespace CalamityMod.Items.Accessories Projectile.tileCollide = false; Projectile.ArmorPenetration = 20; Projectile.netImportant = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -115,7 +109,7 @@ namespace CalamityMod.Items.Accessories for (int i = 0; i < 5; i++) { - Dust dust = Dust.NewDustPerfect(dustOrigin, 229, dustVelocity, 120, Scale: Main.rand.NextFloat(0.6f, 1f)); + Dust dust = Dust.NewDustPerfect(dustOrigin, DustID.Vortex, dustVelocity, 120, Scale: Main.rand.NextFloat(0.6f, 1f)); dust.noGravity = true; dustOrigin += dustOriginOffset; } diff --git a/Items/Accessories/Nanotech.cs b/Items/Accessories/Nanotech.cs index 7d73cda868..844359471b 100644 --- a/Items/Accessories/Nanotech.cs +++ b/Items/Accessories/Nanotech.cs @@ -3,13 +3,13 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { public class Nanotech : ModItem, ILocalizedModType { + //The stealth damage boost is handled in CalamityPlayer for some reason, maybe someone didn't want em to stack? public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { @@ -17,14 +17,13 @@ namespace CalamityMod.Items.Accessories Item.height = 46; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.nanotech = true; - modPlayer.raiderTalisman = true; modPlayer.electricianGlove = true; modPlayer.filthyGlove = true; modPlayer.bloodyGlove = true; @@ -36,7 +35,6 @@ namespace CalamityMod.Items.Accessories { CreateRecipe(). AddIngredient(). - AddIngredient(). AddIngredient(). AddIngredient(). AddIngredient(4). diff --git a/Items/Accessories/NavystoneBobber.cs b/Items/Accessories/NavystoneBobber.cs new file mode 100644 index 0000000000..e78241dccd --- /dev/null +++ b/Items/Accessories/NavystoneBobber.cs @@ -0,0 +1,38 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + internal class NavystoneBobber : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override string Texture => "CalamityMod/Projectiles/Typeless/NavyBobber"; + public override void SetDefaults() + { + Item.width = 9; + Item.height = 9; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.accFishingBobber = true; + player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.NavystoneBobber; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.FishingBobber). + AddIngredient(). + AddIngredient(5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index fe23201469..7033bda892 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -1,10 +1,8 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -18,7 +16,8 @@ namespace CalamityMod.Items.Accessories Item.height = 14; Item.accessory = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void Update(ref float gravity, ref float maxFallSpeed) diff --git a/Items/Accessories/NecklaceofVexation.cs b/Items/Accessories/NecklaceofVexation.cs index 8b0b948c8a..39d4b09ccd 100644 --- a/Items/Accessories/NecklaceofVexation.cs +++ b/Items/Accessories/NecklaceofVexation.cs @@ -1,4 +1,5 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; @@ -32,5 +33,12 @@ namespace CalamityMod.Items.Accessories AddTile(TileID.MythrilAnvil). Register(); } + + public override void ModifyTooltips(List list) + { + var player = Main.LocalPlayer; + if (player != null) + list.FindAndReplace("[DAMAGE]", (0.3f * (1 - player.statLife / (float)player.statLifeMax2)).ToPercent()); + } } } diff --git a/Items/Accessories/Nucleogenesis.cs b/Items/Accessories/Nucleogenesis.cs index 229c3e33fe..1f3dfd4288 100644 --- a/Items/Accessories/Nucleogenesis.cs +++ b/Items/Accessories/Nucleogenesis.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Accessories Item.height = 52; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/OccultSkullCrown.cs b/Items/Accessories/OccultSkullCrown.cs index 96480eb4f3..989c1bde9e 100644 --- a/Items/Accessories/OccultSkullCrown.cs +++ b/Items/Accessories/OccultSkullCrown.cs @@ -32,8 +32,8 @@ namespace CalamityMod.Items.Accessories Item.width = 82; Item.height = 62; Item.defense = 5; - Item.rare = ModContent.RarityType(); - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.accessory = true; Item.SetRevExclusive(); } @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddIngredient(). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/OceanCrest.cs b/Items/Accessories/OceanCrest.cs index 9266827683..26d97b69d3 100644 --- a/Items/Accessories/OceanCrest.cs +++ b/Items/Accessories/OceanCrest.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/OldDie.cs b/Items/Accessories/OldDie.cs index 96197e4a51..d2c8cc43f7 100644 --- a/Items/Accessories/OldDie.cs +++ b/Items/Accessories/OldDie.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories Item.width = 24; Item.height = 26; Item.rare = ItemRarityID.Orange; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.value = Item.buyPrice(gold: 20); // Sold by Bandit Item.accessory = true; } diff --git a/Items/Accessories/OldDukeScales.cs b/Items/Accessories/OldDukeScales.cs index 9e38022feb..3bc1c42ab0 100644 --- a/Items/Accessories/OldDukeScales.cs +++ b/Items/Accessories/OldDukeScales.cs @@ -1,6 +1,5 @@ using CalamityMod.Cooldowns; using CalamityMod.Rarities; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ModLoader; @@ -23,12 +22,14 @@ namespace CalamityMod.Items.Accessories Item.accessory = true; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) { OldDukeScalesPlayer modPlayer = player.GetModPlayer(); modPlayer.OldDukeScalesOn = true; + player.noKnockback = true; } } diff --git a/Items/Accessories/OrnateShield.cs b/Items/Accessories/OrnateShield.cs index 2b12a2aa69..30e331049d 100644 --- a/Items/Accessories/OrnateShield.cs +++ b/Items/Accessories/OrnateShield.cs @@ -20,21 +20,14 @@ namespace CalamityMod.Items.Accessories Item.height = 32; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 4; // This has a ram dash, it should give a bit less defense due to how good it is + Item.defense = 2; Item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { - // Ornate Shield ram dash player.Calamity().DashID = OrnateShieldDash.ID; player.dashType = 0; - - // Cold debuff immunities (Do not fear, this accessory is post Cryogen!) - player.buffImmune[BuffID.Chilled] = true; - player.buffImmune[BuffID.Frozen] = true; - player.buffImmune[BuffID.Frostburn] = true; - player.buffImmune[BuffID.Frostburn2] = true; } public override void AddRecipes() diff --git a/Items/Accessories/PearlofEnthrallment.cs b/Items/Accessories/PearlofEnthrallment.cs index 53a38c6c5a..e077129fdf 100644 --- a/Items/Accessories/PearlofEnthrallment.cs +++ b/Items/Accessories/PearlofEnthrallment.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -37,13 +36,13 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.sirenWaifu = true; + modPlayer.waterElemental = true; if (player.whoAmI == Main.myPlayer) { var source = player.GetSource_Accessory(Item); - if (player.FindBuffIndex(ModContent.BuffType()) == -1) + if (player.FindBuffIndex(ModContent.BuffType()) == -1) { - player.AddBuff(ModContent.BuffType(), 3600, true); + player.AddBuff(ModContent.BuffType(), 3600, true); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { @@ -59,13 +58,13 @@ namespace CalamityMod.Items.Accessories public override void UpdateVanity(Player player) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.sirenWaifuVanity = true; + modPlayer.waterElementalVanity = true; if (player.whoAmI == Main.myPlayer) { var source = player.GetSource_Accessory(Item); - if (player.FindBuffIndex(ModContent.BuffType()) == -1) + if (player.FindBuffIndex(ModContent.BuffType()) == -1) { - player.AddBuff(ModContent.BuffType(), 3600, true); + player.AddBuff(ModContent.BuffType(), 3600, true); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { diff --git a/Items/Accessories/PerennialBobber.cs b/Items/Accessories/PerennialBobber.cs new file mode 100644 index 0000000000..0705e28791 --- /dev/null +++ b/Items/Accessories/PerennialBobber.cs @@ -0,0 +1,37 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + internal class PerennialBobber : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override string Texture => "CalamityMod/Projectiles/Typeless/FeralDoubleBobber"; + public override void SetDefaults() + { + Item.width = 9; + Item.height = 9; + Item.value = CalamityGlobalItem.RarityLimeBuyPrice; + Item.rare = ItemRarityID.Lime; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.accFishingBobber = true; + player.fishingSkill += (int)((player.statLifeMax2 - player.statLife) * 0.25f); + player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.PerennialBobber; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.FishingBobber). + AddIngredient(5). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Accessories/PermafrostsConcoction.cs b/Items/Accessories/PermafrostsConcoction.cs index 7b849b028e..2ca906ba88 100644 --- a/Items/Accessories/PermafrostsConcoction.cs +++ b/Items/Accessories/PermafrostsConcoction.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories internal static readonly int EncasedIFrames = 90; public static int EncasedDefenseBoost = 30; - public static double EncasedAllDamageReduction = 0.3D; + public static float EncasedDamageReductionBoost = 0.3f; public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() diff --git a/Items/Accessories/PhantomicArtifact.cs b/Items/Accessories/PhantomicArtifact.cs index 15ea7c2134..ab6f1b20eb 100644 --- a/Items/Accessories/PhantomicArtifact.cs +++ b/Items/Accessories/PhantomicArtifact.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Items.Accessories public static int RegenBoost = 2; public static int DefenseBoost = 10; - public static float DamageReductionBoost = 0.05f; public static float SummonDamageBoost = 0.1f; public override void SetStaticDefaults() @@ -45,7 +44,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(5). AddIngredient(25). AddIngredient(20). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/PlanebreakersPouch.cs b/Items/Accessories/PlanebreakersPouch.cs index 20902eceda..11de8740a1 100644 --- a/Items/Accessories/PlanebreakersPouch.cs +++ b/Items/Accessories/PlanebreakersPouch.cs @@ -4,7 +4,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Accessories Item.height = 32; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) @@ -29,7 +28,7 @@ namespace CalamityMod.Items.Accessories player.magicQuiver = true; CalamityPlayer modPlayer = player.Calamity(); modPlayer.deadshotBrooch = true; - modPlayer.rangedAmmoCost *= 0.8f; + modPlayer.ammoCost *= 0.8f; } public override void ModifyTooltips(List tooltips) => tooltips.IntegrateHotkey(CalamityKeybinds.AmmoCycleHotkey); diff --git a/Items/Accessories/ProfanedSoulArtifact.cs b/Items/Accessories/ProfanedSoulArtifact.cs index 01232cb368..9d965f53bb 100644 --- a/Items/Accessories/ProfanedSoulArtifact.cs +++ b/Items/Accessories/ProfanedSoulArtifact.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.DataStructures; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Rarities; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -16,7 +16,6 @@ using Terraria.DataStructures; using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; -using static CalamityMod.Items.Accessories.ProfanedSoulCrystal; namespace CalamityMod.Items.Accessories { @@ -106,7 +105,7 @@ namespace CalamityMod.Items.Accessories AddIngredient(5). AddIngredient(25). AddIngredient(25). - AddTile(TileID.DemonAltar). + AddTile(TileID.MythrilAnvil). Register(); } @@ -168,8 +167,9 @@ namespace CalamityMod.Items.Accessories shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3()); shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3()); - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, Matrix.Identity, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, shieldEffect, Main.Transform); // Fetch shield heat overlay texture (this is the neutrons fed to the shader) HeatTex ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2"); Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition; @@ -183,13 +183,13 @@ namespace CalamityMod.Items.Accessories Vector2 origin = shieldFrame.Size() * 0.5f; Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, shieldColor * 0.5f, player.fullRotation, origin, shieldScale, SpriteEffects.None, 0f); Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, secondaryEdgeColor * 0.5f, player.fullRotation, origin, shieldScale * 0.95f, SpriteEffects.None, 0f); Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, shieldColor * 0.5f, player.fullRotation, origin, shieldScale, SpriteEffects.None, 0f); Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, secondaryEdgeColor * 0.5f, player.fullRotation, origin, shieldScale * 0.95f, SpriteEffects.None, 0f); Main.spriteBatch.End(); - }); + } modPlayer.drawnAnyShieldThisFrame = true; } } diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index 546e685553..f551bca324 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -5,7 +5,11 @@ using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.Summon.Whips; using CalamityMod.CalPlayer; using CalamityMod.DataStructures; +using CalamityMod.Items.BaseItems; using CalamityMod.Items.Materials; +using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Providence; +using CalamityMod.Particles; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -14,16 +18,17 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { //Developer item, dedicatee: Mishiro Usui/Amber Sienna - public class ProfanedSoulCrystal : ModItem, ILocalizedModType, IDyeableShaderRenderer + public class ProfanedSoulCrystal : TransformationAccessory, ILocalizedModType, IDyeableShaderRenderer { - public static string[] contributorNames = new[] { "IbanPlay", "Chen", "Nincity", "Amber", "Mishiro", "LordMetarex", "Memes" }; - public static int ShieldDurabilityMax = 125; + public static string[] contributorNames = new[] { "IbanPlay", "Chen", "Nincity", "Amber", "Mishiro", "LordMetarex" }; + public static int ShieldDurabilityMax = 100; public new string LocalizationCategory => "Items.Accessories"; public static int ShieldRechargeDelay = CalamityUtils.SecondsToFrames(5); @@ -31,6 +36,26 @@ namespace CalamityMod.Items.Accessories public const int maxMinionRequirement = 10; public const int maxPscAnimTime = 120; + public static SummonTag SummonTag = new() { MultiplicativeTagDamage = 0.2f, TagModifyHitEffects = ApplyTagModifyHit, AutoDrawTooltip = false }; + + public static void ApplyTagModifyHit(Projectile proj, NPC npc, ref NPC.HitModifiers modifiers, ref float tagDamageMult, ref float critChance) + { + if (Main.player[proj.owner].Calamity().pscState >= (int)ProfanedSoulCrystalState.Buffs) + { + var empowered = Main.player[proj.owner].Calamity().pscState == (int)ProfanedSoulCrystalState.Empowered; + //20% is balanced for non empowered, while 40% helps ensure psc remains balanced at empowered tier + //Some PSC projectiles receive a reduced amount of benefit from this, for balancing purposes + modifiers.ScalingBonusDamage += (empowered ? 0.4f : SummonTag.MultiplicativeTagDamage) * tagDamageMult; + if (!Main.dedServ) + { + var color = ProvUtils.GetColorBasedOnEnrage(!Main.dayTime, 0); + float power = Math.Min(npc.height / 100f, 3f); + var position = new Vector2(Main.rand.NextFloat(npc.Left.X, npc.Right.X), Main.rand.NextFloat(npc.Top.Y, npc.Bottom.Y)); + var particle = new FlameParticle(position, 50, 0.25f, power, color * (Main.dayTime ? 1f : 1.25f), color * (Main.dayTime ? 1.25f : 1f)); + GeneralParticleHandler.SpawnParticle(particle); + } + } + } // Interface stuff. public int OwnerPlayer { get; set; } @@ -81,7 +106,7 @@ namespace CalamityMod.Items.Accessories if (ignoreNoBuffs && (!DownedBossSystem.downedCalamitas || !DownedBossSystem.downedExoMechs || (player.maxMinions - player.slotsMinions) < maxMinionRequirement) || - player.Calamity().profanedCrystalForce || !player.HasBuff()) + player.Transformation().Type == ModContent.ItemType() || !player.HasBuff()) { return ProfanedSoulCrystalState.Vanity; //failsafe for vanity } @@ -155,28 +180,22 @@ namespace CalamityMod.Items.Accessories * Projectiles transformed are ONLY affected by alldamage and summon damage bonuses, likewise the weapon's base damage/usetime is NOT taken into account. * The on-hit effect for the whip is in globalnpc */ - public override void Load() + public override string AssetPath => "CalamityMod/Items/Accessories/"; + + public override (EquipType Type, string AssetName, string EquipName)[] EquipSlots => + [ + (EquipType.Head, "ProfanedSoulTrans", null), + (EquipType.Body, "ProfanedSoulTrans", null), + (EquipType.Legs, "ProfanedSoulTrans", null), + (EquipType.Wings, "ProfanedSoulTrans", null), + (EquipType.Head, "ProfanedSoulTransNight", "PscNightHead"), + (EquipType.Legs, "ProfanedSoulTransNight", "PscNightLegs"), + (EquipType.Wings, "ProfanedSoulTransNight", "PscNightWings"), + (EquipType.Face, null, null), //results in setting this equip slot to -1 + ]; + + public override void ArmorIDSets() { - if (Main.dedServ) - return; - - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/ProfanedSoulTransHead", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/ProfanedSoulTransHeadNight", EquipType.Head, this, "PscNightHead"); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/ProfanedSoulTransBody", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/ProfanedSoulTransLegs", EquipType.Legs, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/ProfanedSoulTransLegsNight", EquipType.Legs, this, "PscNightLegs"); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Wings/ProfanedSoulTransWings", EquipType.Wings, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Wings/ProfanedSoulTransWingsNight", EquipType.Wings, this, "PscNightWings"); - } - - public override void SetStaticDefaults() - { - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(8, 4)); - ItemID.Sets.AnimatesAsSoul[Type] = true; - - if (Main.dedServ) - return; - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; @@ -190,8 +209,20 @@ namespace CalamityMod.Items.Accessories ArmorIDs.Legs.Sets.OverridesLegs[equipSlotNightLegs] = true; } + public override (SoundStyle sound, int delay)? HurtSound(Player p) => (p.Calamity().pSoulShieldDurability > 0 ? ProfanedGuardianDefender.ShieldDeathSound : Providence.HurtSound, 20); + + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(8, 4)); + ItemID.Sets.AnimatesAsSoul[Type] = true; + + base.SetStaticDefaults(); + } + public override void SetDefaults() { + SummonTag.TagItem = Item.type; + SummonTag.TagTexture = TextureAssets.Item[Type]; Item.width = 50; Item.height = 50; Item.accessory = true; @@ -200,10 +231,7 @@ namespace CalamityMod.Items.Accessories Item.Calamity().devItem = true; } - public override bool CanAccessoryBeEquippedWith(Item equippedItem, Item incomingItem, Player player) - { - return incomingItem.type != ModContent.ItemType(); - } + public override bool CanAccessoryBeEquippedWith(Item equippedItem, Item incomingItem, Player player) => incomingItem.type != ModContent.ItemType(); public override void ModifyTooltips(List tooltips) { @@ -235,12 +263,30 @@ namespace CalamityMod.Items.Accessories } } + public override bool CustomSetEquipType(Player player, EquipType type, Mod mod, string name) + { + switch (type) + { + case EquipType.Legs: + player.legs = EquipLoader.GetEquipSlot(Mod, Main.dayTime ? "ProfanedSoulCrystal" : "PscNightLegs", type); + return true; + case EquipType.Head: + player.head = EquipLoader.GetEquipSlot(Mod, Main.dayTime ? "ProfanedSoulCrystal" : "PscNightHead", type); + return true; + case EquipType.Wings: + player.wings = EquipLoader.GetEquipSlot(Mod, Main.dayTime ? "ProfanedSoulCrystal" : "PscNightWings", type); + return true; + } + return false; + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.pSoulArtifact = true; modPlayer.profanedCrystal = true; + if (!modPlayer.profanedCrystalPrevious && player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) { modPlayer.pSoulShieldDurability = 1; @@ -250,23 +296,15 @@ namespace CalamityMod.Items.Accessories if (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs) player.Calamity().profanedSoulRelicBuff = true; - modPlayer.profanedCrystalHide = hideVisual || modPlayer.profanedCrystalAnim > 0; modPlayer.pSoulShieldVisible = !hideVisual; DetermineTransformationEligibility(player); } - public override void UpdateVanity(Player player) - { - player.Calamity().profanedCrystalHide = false; - player.Calamity().profanedCrystalForce = true; - } - internal static void DetermineTransformationEligibility(Player player) { //short circuit immediately if profanedcrystalbuffs has already been set - - if (!player.Calamity().profanedCrystalBuffs && player.Calamity().profanedCrystalAnim == -1 && DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs && (player.maxMinions - player.slotsMinions) >= maxMinionRequirement && !player.Calamity().profanedCrystalForce && player.HasBuff()) + if (!player.Calamity().profanedCrystalBuffs && player.Calamity().profanedCrystalAnim == -1 && DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs && (player.maxMinions - player.slotsMinions) >= maxMinionRequirement && player.HasBuff()) { player.Calamity().profanedCrystalBuffs = true; player.Calamity().pscState = (int)GetPscStateFor(player); //update psc state, default is 0 which is the same as the int value of vanity @@ -510,6 +548,86 @@ namespace CalamityMod.Items.Accessories return false; } + public override void TransformFrameEffects(Player player) + { + bool enrage = player.Calamity().pscState >= (int)ProfanedSoulCrystal.ProfanedSoulCrystalState.Enraged; + + if (profanedCrystalWingCounter.Value == 0) + { + int key = profanedCrystalWingCounter.Key; + profanedCrystalWingCounter = new KeyValuePair(key == 3 ? 0 : key + 1, enrage ? 5 : 8); + } + + player.wingFrame = profanedCrystalWingCounter.Key; + profanedCrystalWingCounter = new KeyValuePair(profanedCrystalWingCounter.Key, profanedCrystalWingCounter.Value - 1); + player.armorEffectDrawOutlines = true; + if (player.Calamity().profanedCrystalBuffs) + { + player.armorEffectDrawShadow = true; + if (enrage) + { + player.armorEffectDrawOutlinesForbidden = true; + } + } + } + + public KeyValuePair profanedCrystalWingCounter = new KeyValuePair(1, 10); + public KeyValuePair profanedCrystalAnimCounter = new KeyValuePair(0, 10); + + private bool IsValidTransitionFrame(AnimationType currentAnim, AnimationType newAnim, int frame, int counter) //this exists so it doesn't loop through the entire walk/idle anim just to find one frame for switching. + { + bool result = newAnim != AnimationType.Jump && currentAnim != AnimationType.Jump; + if (currentAnim == AnimationType.Walk && newAnim == AnimationType.Idle) + { + result = counter <= 0 && (frame == 11 || frame == 15 || frame == 19); + } + else if (currentAnim == AnimationType.Idle && newAnim == AnimationType.Walk) + { + result = counter <= 0 && (frame == 2 || frame == 6); + } + return currentAnim != newAnim && result; //swapping to jumps should be instant, no need to check the counter here + } + + private int HandlePSCAnimationFrames(Player player, AnimationType newType) + { + int key = profanedCrystalAnimCounter.Key; //0-based indexing + int value = profanedCrystalAnimCounter.Value - 1; + AnimationType currentType = key < 8 ? AnimationType.Idle : key == 8 ? AnimationType.Jump : AnimationType.Walk; + + bool isInvalidTransFrame = !IsValidTransitionFrame(currentType, newType, key, value); //to make the transition between walk and idle frames less jarring and smoother + AnimationType type = isInvalidTransFrame ? newType : currentType; + int frameCount = type == AnimationType.Walk || (player.Calamity().profanedCrystal && player.statLife <= (int)(player.statLifeMax2 * 0.5)) ? 7 : 10; + int lowerRange = type == AnimationType.Idle ? 0 : type == AnimationType.Jump ? 8 : 9; + int upperRange = type == AnimationType.Idle ? 7 : type == AnimationType.Jump ? 8 : 22; + if (value <= 0 || !isInvalidTransFrame) + { + value = frameCount; + if (key >= lowerRange && key < upperRange) + key++; + else + key = lowerRange; + } + profanedCrystalAnimCounter = new KeyValuePair(key, value); + return profanedCrystalAnimCounter.Key; + } + + public override void TransformPostUpdate(Player player) + { + bool validEquipSlot = player.legs == EquipLoader.GetEquipSlot(Mod, "ProfanedSoulCrystal", EquipType.Legs) || + player.legs == EquipLoader.GetEquipSlot(Mod, "PscNightLegs", EquipType.Legs); + if (player.Transformation().Type == ModContent.ItemType() && validEquipSlot) + { + bool usingCarpet = player.carpetTime > 0 && player.controlJump; //doesn't make sense for carpet to use jump frame since you have solid ground + AnimationType animType = AnimationType.Walk; + if ((player.sliding || player.velocity.Y != 0 || player.mount.Active || (player.grappling[0] != -1 || !player.CheckSolidGround()) || player.GoingDownWithGrapple) && !usingCarpet) + animType = AnimationType.Jump; + else if (player.velocity.X == 0 || usingCarpet) + animType = AnimationType.Idle; + int frame = HandlePSCAnimationFrames(player, animType); + player.legFrame.Y = player.legFrame.Height * frame; + } + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/ProfanedSoulTransHeadNight.png b/Items/Accessories/ProfanedSoulTransNight_Head.png similarity index 100% rename from Items/Accessories/ProfanedSoulTransHeadNight.png rename to Items/Accessories/ProfanedSoulTransNight_Head.png diff --git a/Items/Accessories/ProfanedSoulTransLegsNight.png b/Items/Accessories/ProfanedSoulTransNight_Legs.png similarity index 100% rename from Items/Accessories/ProfanedSoulTransLegsNight.png rename to Items/Accessories/ProfanedSoulTransNight_Legs.png diff --git a/Items/Accessories/Wings/ProfanedSoulTransWingsNight.png b/Items/Accessories/ProfanedSoulTransNight_Wings.png similarity index 100% rename from Items/Accessories/Wings/ProfanedSoulTransWingsNight.png rename to Items/Accessories/ProfanedSoulTransNight_Wings.png diff --git a/Items/Accessories/ProfanedSoulTransBody.png b/Items/Accessories/ProfanedSoulTrans_Body.png similarity index 100% rename from Items/Accessories/ProfanedSoulTransBody.png rename to Items/Accessories/ProfanedSoulTrans_Body.png diff --git a/Items/Accessories/ProfanedSoulTransHead.png b/Items/Accessories/ProfanedSoulTrans_Head.png similarity index 100% rename from Items/Accessories/ProfanedSoulTransHead.png rename to Items/Accessories/ProfanedSoulTrans_Head.png diff --git a/Items/Accessories/ProfanedSoulTransLegs.png b/Items/Accessories/ProfanedSoulTrans_Legs.png similarity index 100% rename from Items/Accessories/ProfanedSoulTransLegs.png rename to Items/Accessories/ProfanedSoulTrans_Legs.png diff --git a/Items/Accessories/Wings/ProfanedSoulTransWings.png b/Items/Accessories/ProfanedSoulTrans_Wings.png similarity index 100% rename from Items/Accessories/Wings/ProfanedSoulTransWings.png rename to Items/Accessories/ProfanedSoulTrans_Wings.png diff --git a/Items/Accessories/ProtolithBangle.cs b/Items/Accessories/ProtolithBangle.cs new file mode 100644 index 0000000000..70274095b3 --- /dev/null +++ b/Items/Accessories/ProtolithBangle.cs @@ -0,0 +1,39 @@ +using CalamityMod.CalPlayer; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class ProtolithBangle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public static int cooldown = 420; + public static int damage = 68; + public override void SetDefaults() + { + Item.width = 34; + Item.height = 34; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.protolithBangle = true; + modPlayer.protolithBangleVisual = !hideVisual; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddRecipeGroup("Boss2Material", 15). + AddIngredient(ItemID.Marble, 45). + AddIngredient(ItemID.Ruby, 3). + AddIngredient(ItemID.Lens, 5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/ProtolithBangle.png b/Items/Accessories/ProtolithBangle.png new file mode 100644 index 0000000000..0fc9477145 Binary files /dev/null and b/Items/Accessories/ProtolithBangle.png differ diff --git a/Items/Accessories/QuiverofNihility.cs b/Items/Accessories/QuiverofNihility.cs index 11717b66cd..9efd1466f7 100644 --- a/Items/Accessories/QuiverofNihility.cs +++ b/Items/Accessories/QuiverofNihility.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Accessories AddRecipeGroup("AnyQuiver"). AddIngredient(5). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/Radiance.cs b/Items/Accessories/Radiance.cs index 68b3b5836c..7fbffc9bb8 100644 --- a/Items/Accessories/Radiance.cs +++ b/Items/Accessories/Radiance.cs @@ -1,4 +1,5 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -11,7 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { [LegacyName("AstralArcanum", "Purity")] - public class Radiance : ModItem, ILocalizedModType + public class Radiance : ModItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Accessories"; public override void SetStaticDefaults() @@ -24,22 +25,23 @@ namespace CalamityMod.Items.Accessories { Item.width = 18; Item.height = 44; - Item.defense = 8; + Item.defense = 5; Item.accessory = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); player.statLifeMax2 += 70; + if (!player.HasBuff(BuffID.Honey)) + player.AddBuff(BuffID.Honey, 2); // Abyss light, debuff near-immunity, life regen effects, and massively enhances debuff halving modPlayer.purity = true; // Inherits effects from Honey Dew and Living Dew - modPlayer.alwaysHoneyRegen = true; modPlayer.honeyDewHalveDebuffs = true; modPlayer.livingDewHalveDebuffs = true; @@ -48,6 +50,17 @@ namespace CalamityMod.Items.Accessories Lighting.AddLight(player.Center, new Vector3(1.32f, 1.32f, 1.82f)); } + + public override void ModifyTooltips(List list) + { + var player = Main.LocalPlayer; + if (player != null) + { + list.FindAndReplace("[REGEN]", player.Calamity().purityRegen.ToString("0.##")); + list.FindAndReplace("[DEFENSE]", player.Calamity().jewelBonusDefense.ToString()); + } + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/RadiantOoze.cs b/Items/Accessories/RadiantOoze.cs index 42f5a8a1de..6c5173059b 100644 --- a/Items/Accessories/RadiantOoze.cs +++ b/Items/Accessories/RadiantOoze.cs @@ -1,8 +1,10 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -10,6 +12,11 @@ namespace CalamityMod.Items.Accessories public class RadiantOoze : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int MinRegenBoost = 4; + public static int MaxRegenBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinRegenBoost.ToRegenPerSecond(), MaxRegenBoost.ToRegenPerSecond()); + public override void SetDefaults() { Item.width = 20; @@ -31,6 +38,15 @@ namespace CalamityMod.Items.Accessories Lighting.AddLight(player.Center, new Vector3(1f, 1f, 0.6f)); } + public override void ModifyTooltips(List list) + { + var player = Main.LocalPlayer; + if (player != null) + { + list.FindAndReplace("[REGEN]", (player.Calamity().radiantOozeRegen).ToString("0.##")); + } + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/RaidersTalisman.cs b/Items/Accessories/RaidersTalisman.cs index 7ded8661aa..775a842fa1 100644 --- a/Items/Accessories/RaidersTalisman.cs +++ b/Items/Accessories/RaidersTalisman.cs @@ -9,8 +9,8 @@ namespace CalamityMod.Items.Accessories public class RaidersTalisman : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public const float RaiderBonus = 10f; - public const int RaiderCooldown = 10; + public const float RaiderBonus = 15f; + public const int RaiderCooldown = 10; //seconds public static readonly SoundStyle StealthHitSound = new("CalamityMod/Sounds/Custom/RaidersTalismanStealthHit"); public override void SetDefaults() diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index 2ac41f439d..a36913d189 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -1,11 +1,15 @@ -using System; +using System.Collections.Generic; +using System.IO; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Accessories { @@ -13,16 +17,56 @@ namespace CalamityMod.Items.Accessories public class RampartofDeities : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + public override void SetDefaults() { Item.width = 64; Item.height = 62; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 12; + Item.defense = 8; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } + #region Toggleable Panic Necklace + + bool panicNecklaceEnabled = true; + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplace("[TOGGLE]", panicNecklaceEnabled ? this.GetLocalizedValue("ToggleEffect") : ""); + } + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + panicNecklaceEnabled = !panicNecklaceEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("panic", panicNecklaceEnabled); + } + + public override void LoadData(TagCompound tag) + { + panicNecklaceEnabled = tag.GetBool("panic"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(panicNecklaceEnabled); + } + + public override void NetReceive(BinaryReader reader) + { + panicNecklaceEnabled = reader.ReadBoolean(); + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, panicNecklaceEnabled); + } + #endregion public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); @@ -31,32 +75,15 @@ namespace CalamityMod.Items.Accessories player.longInvince = true; modPlayer.dAmulet = true; - // Large hit iframe effect taken from Seraph Tracers - modPlayer.rampartOfDeities = true; + //Panic Necklace effect if enabled + player.panic = panicNecklaceEnabled; - // Ice Barrier buff inherited from Frozen Turtle Shell - if (player.statLife <= player.statLifeMax2 * 0.5) - player.AddBuff(BuffID.IceBarrier, 5); + // Large hit iframe effect taken from Seraph Tracers + // IceBarrier and PaladinsShield effects are defined in CalPlayer.PostUpdateEquips + modPlayer.rampartOfDeities = true; // Knockback immunity inherited from Paladin's Shield player.noKnockback = true; - - // Paladin's Shield application - if (player.statLife > player.statLifeMax2 * 0.25f) - { - player.hasPaladinShield = true; - if (player.whoAmI != Main.myPlayer && player.miscCounter % 10 == 0) - { - int myPlayer = Main.myPlayer; - if (Main.player[myPlayer].team == player.team && player.team != 0) - { - float teamPlayerXDist = player.position.X - Main.player[myPlayer].position.X; - float teamPlayerYDist = player.position.Y - Main.player[myPlayer].position.Y; - if ((float)Math.Sqrt(teamPlayerXDist * teamPlayerXDist + teamPlayerYDist * teamPlayerYDist) < 800f) - Main.player[myPlayer].AddBuff(BuffID.PaladinsShield, 20); - } - } - } } public override void AddRecipes() diff --git a/Items/Accessories/RareElementalinaBottle.cs b/Items/Accessories/RareElementalinaBottle.cs new file mode 100644 index 0000000000..6dafdf72e7 --- /dev/null +++ b/Items/Accessories/RareElementalinaBottle.cs @@ -0,0 +1,82 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + [LegacyName("WifeinaBottlewithBoobs")] // Yes, that was the actual name. + public class RareElementalinaBottle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + + // Hold on... isn't this the HEALER elemental?? + public static int ElementalDamage = 45; + + public override void SetDefaults() + { + Item.width = 20; + Item.height = 26; + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; + Item.accessory = true; + } + + public override bool CanEquipAccessory(Player player, int slot, bool modded) + { + CalamityPlayer modPlayer = player.Calamity(); + if (modPlayer.elementalHeart) + { + return false; + } + return true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.rareSandElemental = true; + if (player.whoAmI == Main.myPlayer) + { + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + { + player.AddBuff(ModContent.BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + var source = player.GetSource_Accessory(Item); + int damage = (int)player.GetTotalDamage().ApplyTo(ElementalDamage); + + Projectile sandy = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); + sandy.originalDamage = ElementalDamage; + } + } + } + + public override void UpdateVanity(Player player) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.rareSandElementalVanity = true; + if (player.whoAmI == Main.myPlayer) + { + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + { + player.AddBuff(ModContent.BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + var source = player.GetSource_Accessory(Item); + + // 08DEC2023: Ozzatron: Rare Sand Elementals spawned with... Hold on a second. Why the fuck are we doing damage calculations when the accessory is in vanity?! + int damage = (int)player.GetTotalDamage().ApplyTo(ElementalDamage); + + Projectile sandy = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); + sandy.originalDamage = ElementalDamage; + } + } + } + } +} diff --git a/Items/Accessories/WifeinaBottlewithBoobs.png b/Items/Accessories/RareElementalinaBottle.png similarity index 100% rename from Items/Accessories/WifeinaBottlewithBoobs.png rename to Items/Accessories/RareElementalinaBottle.png diff --git a/Items/Accessories/ReaperToothNecklace.cs b/Items/Accessories/ReaperToothNecklace.cs index 5c94e7fa60..d8d417f8bc 100644 --- a/Items/Accessories/ReaperToothNecklace.cs +++ b/Items/Accessories/ReaperToothNecklace.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Rarities; using Terraria; using Terraria.ID; diff --git a/Items/Accessories/Regenator.cs b/Items/Accessories/Regenator.cs deleted file mode 100644 index f8bdcbf180..0000000000 --- a/Items/Accessories/Regenator.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Microsoft.Xna.Framework; -using Terraria.Localization; -using System.Collections.Generic; -using System; - -namespace CalamityMod.Items.Accessories -{ - public class Regenator : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.width = 34; - Item.height = 56; - Item.value = CalamityGlobalItem.RarityLimeBuyPrice; - Item.rare = ItemRarityID.Lime; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.regenator = true; - player.longInvince = true; // Gives better iframes because god help you if you end up getting hit twice - } - - public override void ModifyTooltips(List list) - { - if (Main.LocalPlayer != null) - list.FindAndReplace("[DAMAGE]", (Main.LocalPlayer.Calamity().regenatorDamage).ToPercent()); - } - } -} diff --git a/Items/Accessories/Regenerator.cs b/Items/Accessories/Regenerator.cs new file mode 100644 index 0000000000..dc1bc73dd3 --- /dev/null +++ b/Items/Accessories/Regenerator.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using CalamityMod.CalPlayer; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + [LegacyName("Regenator")] + public class Regenerator : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + + public static float HealthRatioCap = 0.5f; + public static int FramesPerHeal = 8; + public static int RegenTimeBoost = 4; // on top of +1/s regular increment + public static float RegenToDamageRatio = 0.015f; // per regen point + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(HealthRatioCap.ToPercent(), (60 / (float)FramesPerHeal).Round()); + + public override void SetDefaults() + { + Item.width = 34; + Item.height = 56; + Item.value = CalamityGlobalItem.RarityLimeBuyPrice; + Item.rare = ItemRarityID.Lime; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.regenerator = true; + player.longInvince = true; // Gives better iframes because god help you if you end up getting hit twice + } + + public override void ModifyTooltips(List list) + { + if (Main.LocalPlayer != null) + list.FindAndReplace("[DAMAGE]", (Main.LocalPlayer.Calamity().regeneratorDamage).ToPercent()); + } + } +} diff --git a/Items/Accessories/Regenator.png b/Items/Accessories/Regenerator.png similarity index 100% rename from Items/Accessories/Regenator.png rename to Items/Accessories/Regenerator.png diff --git a/Items/Accessories/RogueEmblem.cs b/Items/Accessories/RogueEmblem.cs index e418c24675..3b6904d7e3 100644 --- a/Items/Accessories/RogueEmblem.cs +++ b/Items/Accessories/RogueEmblem.cs @@ -30,6 +30,18 @@ namespace CalamityMod.Items.Accessories r.AddIngredient(ItemID.SoulofFright, 5); r.AddTile(TileID.TinkerersWorkbench); r.Register(); + + // Sort after recipe with Summoner Emblem as ingredient + // There is no sort after last of X so this process needs to be manual + for (int i = 0; i < Recipe.maxRecipes; i++) + { + Recipe s = Main.recipe[i]; + if (s.createItem.type == ItemID.AvengerEmblem && s.HasIngredient(ItemID.SummonerEmblem)) + { + r.SortAfter(s); + break; + } + } } } } diff --git a/Items/Accessories/RoseStone.cs b/Items/Accessories/RoseStone.cs index e92c7f11de..be56ae478a 100644 --- a/Items/Accessories/RoseStone.cs +++ b/Items/Accessories/RoseStone.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ID; @@ -35,13 +34,13 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.brimstoneWaifu = true; + modPlayer.brimElemental = true; if (player.whoAmI == Main.myPlayer) { var source = player.GetSource_Accessory(Item); - if (player.FindBuffIndex(ModContent.BuffType()) == -1) + if (player.FindBuffIndex(ModContent.BuffType()) == -1) { - player.AddBuff(ModContent.BuffType(), 3600, true); + player.AddBuff(ModContent.BuffType(), 3600, true); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { @@ -58,13 +57,13 @@ namespace CalamityMod.Items.Accessories public override void UpdateVanity(Player player) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.brimstoneWaifuVanity = true; + modPlayer.brimElementalVanity = true; if (player.whoAmI == Main.myPlayer) { var source = player.GetSource_Accessory(Item); - if (player.FindBuffIndex(ModContent.BuffType()) == -1) + if (player.FindBuffIndex(ModContent.BuffType()) == -1) { - player.AddBuff(ModContent.BuffType(), 3600, true); + player.AddBuff(ModContent.BuffType(), 3600, true); } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { diff --git a/Items/Accessories/RottenBrain.cs b/Items/Accessories/RottenBrain.cs index 8f2dd3ad50..a7524744d6 100644 --- a/Items/Accessories/RottenBrain.cs +++ b/Items/Accessories/RottenBrain.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Magic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +8,9 @@ namespace CalamityMod.Items.Accessories public class RottenBrain : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int NimbusDamage => CalamityUtils.ScaleWithDifficulty(8); + public override void SetDefaults() { Item.width = 34; @@ -16,13 +18,13 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.rBrain = true; - player.GetDamage() += 0.05f; } public override void AddRecipes() @@ -31,7 +33,8 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddTile(TileID.TinkerersWorkbench). AddCondition(Condition.InGraveyard). - Register(); + Register() + .DisableDecraft(); } } } diff --git a/Items/Accessories/RottenDogtooth.cs b/Items/Accessories/RottenDogtooth.cs index 7dad00cdc3..d38dba206d 100644 --- a/Items/Accessories/RottenDogtooth.cs +++ b/Items/Accessories/RottenDogtooth.cs @@ -8,7 +8,6 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; internal const int ArmorCrunchDebuffTime = 150; - internal const float StealthStrikeDamageMultiplier = 0.08f; public override void SetDefaults() { Item.width = 14; @@ -21,7 +20,6 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().rottenDogTooth = true; - player.Calamity().bonusStealthDamage += StealthStrikeDamageMultiplier; } } } diff --git a/Items/Accessories/RoverDrive.cs b/Items/Accessories/RoverDrive.cs index 387cfa5b86..e133fd4605 100644 --- a/Items/Accessories/RoverDrive.cs +++ b/Items/Accessories/RoverDrive.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using CalamityMod.CalPlayer; using CalamityMod.DataStructures; using CalamityMod.Items.Materials; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -11,6 +12,7 @@ using Terraria; using Terraria.Audio; using Terraria.Graphics.Effects; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -25,10 +27,9 @@ namespace CalamityMod.Items.Accessories public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/Custom/RoverDriveBreak") { Volume = 0.75f }; public static int ShieldDurabilityMax = 20; - public static int ShieldRechargeTime = CalamityUtils.SecondsToFrames(10); - - // While active, Rover Drive gives 10 defense - public static int ShieldDefenseBoost = 10; + public static int ShieldRechargeDelay = CalamityUtils.SecondsToFrames(10); + public static int TotalShieldRechargeTime = CalamityUtils.SecondsToFrames(5); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(ShieldDurabilityMax, ShieldRechargeDelay.FramesToSeconds(), TotalShieldRechargeTime.FramesToSeconds()); // Interface stuff. public int OwnerPlayer { get; set; } @@ -64,8 +65,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - Item.width = 38; - Item.height = 26; + Item.width = 34; + Item.height = 30; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; Item.accessory = true; @@ -78,9 +79,6 @@ namespace CalamityMod.Items.Accessories modPlayer.roverDrive = true; modPlayer.roverDriveShieldVisible = !hideVisual; - - if (modPlayer.RoverDriveShieldDurability > 0) - player.statDefense += ShieldDefenseBoost; } // In vanity, provides a visual shield but no actual functionality @@ -161,14 +159,16 @@ namespace CalamityMod.Items.Accessories shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3()); shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3()); - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, Matrix.Identity, () => + using (spriteBatch.Scope()) { + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, shieldEffect, Main.Transform); // Fetch shield noise overlay texture (this is the techy overlay fed to the shader) NoiseTex ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/TechyNoise"); Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition; Texture2D tex = NoiseTex.Value; spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0); - }); + spriteBatch.End(); + } modPlayer.drawnAnyShieldThisFrame = true; } diff --git a/Items/Accessories/RoverDrive.png b/Items/Accessories/RoverDrive.png index dc5b42b8ba..6ee7811338 100644 Binary files a/Items/Accessories/RoverDrive.png and b/Items/Accessories/RoverDrive.png differ diff --git a/Items/Accessories/RustyMedallion.cs b/Items/Accessories/RustyMedallion.cs deleted file mode 100644 index b7d0e8f3a1..0000000000 --- a/Items/Accessories/RustyMedallion.cs +++ /dev/null @@ -1,33 +0,0 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class RustyMedallion : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public const int AcidDropBaseDamage = 9; - - // BAD Minishark! You will NOT become stupid sleeper agent item! - public const int AcidCreationCooldown = 25; - - public override void SetDefaults() - { - Item.width = 18; - Item.height = 32; - Item.rare = ItemRarityID.Blue; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.RustyMedallionDroplets = true; - player.buffImmune[ModContent.BuffType()] = true; - } - } -} diff --git a/Items/Accessories/RustyMedallion.png b/Items/Accessories/RustyMedallion.png deleted file mode 100644 index 398cd2132d..0000000000 Binary files a/Items/Accessories/RustyMedallion.png and /dev/null differ diff --git a/Items/Accessories/SandCloak.cs b/Items/Accessories/SandCloak.cs index d4188317bb..bfe585034b 100644 --- a/Items/Accessories/SandCloak.cs +++ b/Items/Accessories/SandCloak.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +7,9 @@ namespace CalamityMod.Items.Accessories public class SandCloak : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int SandVeilDefenseBoost = 4; + public override void SetDefaults() { Item.width = 30; diff --git a/Items/Accessories/SandSharkToothNecklace.cs b/Items/Accessories/SandSharkToothNecklace.cs index c18875f349..48c7b5d494 100644 --- a/Items/Accessories/SandSharkToothNecklace.cs +++ b/Items/Accessories/SandSharkToothNecklace.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.GetDamage() += 0.06f; + player.GetDamage() += 0.1f; player.GetArmorPenetration() += 10; } diff --git a/Items/Accessories/ScionsCurio.cs b/Items/Accessories/ScionsCurio.cs new file mode 100644 index 0000000000..8cad959d1f --- /dev/null +++ b/Items/Accessories/ScionsCurio.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Items.Accessories +{ + public class ScionsCurio : ModItem, ILocalizedModType + { + public static int postHitDamage = 45; + public new string LocalizationCategory => "Items.Accessories"; + public override void SetDefaults() + { + Item.width = 32; + Item.height = 38; + Item.rare = ItemRarityID.Blue; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.scionsCurio = true; + modPlayer.scionsCurioVisuals = !hideVisual; + + if (player.ownedProjectileCounts[ProjectileType()] < 1 && !player.dead) + { + Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI); + } + } + } +} diff --git a/Items/Accessories/ScionsCurio.png b/Items/Accessories/ScionsCurio.png new file mode 100644 index 0000000000..2cfb850e84 Binary files /dev/null and b/Items/Accessories/ScionsCurio.png differ diff --git a/Items/Accessories/ScoriaBobber.cs b/Items/Accessories/ScoriaBobber.cs new file mode 100644 index 0000000000..7ad5e649d2 --- /dev/null +++ b/Items/Accessories/ScoriaBobber.cs @@ -0,0 +1,37 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + internal class ScoriaBobber : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override string Texture => "CalamityMod/Projectiles/Typeless/RiftReelerBobber"; + public override void SetDefaults() + { + Item.width = 9; + Item.height = 9; + Item.value = CalamityGlobalItem.RarityYellowBuyPrice; + Item.rare = ItemRarityID.Yellow; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.accFishingBobber = true; + player.accLavaFishing = true; + player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.ScoriaBobber; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.FishingBobber). + AddIngredient(5). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Accessories/ScrapBobber.cs b/Items/Accessories/ScrapBobber.cs new file mode 100644 index 0000000000..81a7444885 --- /dev/null +++ b/Items/Accessories/ScrapBobber.cs @@ -0,0 +1,34 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + internal class ScrapBobber : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override string Texture => "CalamityMod/Projectiles/Typeless/WulfrumBobber"; + public override void SetDefaults() + { + Item.width = 9; + Item.height = 9; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.ScrapBobber; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/SeaSpiritAmulet.cs b/Items/Accessories/SeaSpiritAmulet.cs index 74f6b94a0c..53b7568177 100644 --- a/Items/Accessories/SeaSpiritAmulet.cs +++ b/Items/Accessories/SeaSpiritAmulet.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -25,6 +24,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.sSpiritAmulet = true; modPlayer.sSpiritAmuletVisual = !hideVisual; + modPlayer.WaterDebuffMultiplier += 0.35f; } } } diff --git a/Items/Accessories/SeaSpiritAmulet.png b/Items/Accessories/SeaSpiritAmulet.png index ba8223206f..081aa62376 100644 Binary files a/Items/Accessories/SeaSpiritAmulet.png and b/Items/Accessories/SeaSpiritAmulet.png differ diff --git a/Items/Accessories/ShatteredCommunity.cs b/Items/Accessories/ShatteredCommunity.cs index 90455d11b0..79f3bd16ea 100644 --- a/Items/Accessories/ShatteredCommunity.cs +++ b/Items/Accessories/ShatteredCommunity.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using CalamityMod.CalPlayer; using CalamityMod.Rarities; using CalamityMod.World; diff --git a/Items/Accessories/ShieldoftheHighRuler.cs b/Items/Accessories/ShieldoftheHighRuler.cs index e7e7fb50d7..c824ecf196 100644 --- a/Items/Accessories/ShieldoftheHighRuler.cs +++ b/Items/Accessories/ShieldoftheHighRuler.cs @@ -24,13 +24,14 @@ namespace CalamityMod.Items.Accessories Item.width = 36; Item.height = 38; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 30; + Item.damage = 300; Item.knockBack = 9f; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; - Item.defense = 6; + Item.defense = 4; Item.accessory = true; + Item.expert = true; } public override bool MeleePrefix() => false; diff --git a/Items/Accessories/ShieldoftheOcean.cs b/Items/Accessories/ShieldoftheOcean.cs index cacb484ead..02daf35a01 100644 --- a/Items/Accessories/ShieldoftheOcean.cs +++ b/Items/Accessories/ShieldoftheOcean.cs @@ -1,8 +1,9 @@ -using CalamityMod.Buffs.DamageOverTime; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; -using System.Collections.Generic; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -15,7 +16,6 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public static readonly SoundStyle TriggerSound = new("CalamityMod/Sounds/Custom/MossMine"); public static readonly SoundStyle ParrySound = new("CalamityMod/Sounds/Custom/BubbleCracklePop"); - public static readonly SoundStyle ParrySoundGFB = new("CalamityMod/Sounds/Custom/GFB/OceanShieldParryGFB"); public const int ParryTime = 30; // These damage values scale in Expert and Master. public const int ShoveFallBaseDamage = 80; @@ -58,10 +58,8 @@ namespace CalamityMod.Items.Accessories } // GFB changes: - // Different sound when parrying. // Larger radius for pushing away enemies. // Enemies are pushed much faster. - // Damage is multiplied by 10. public static void ActivateParry(Player player) { bool empowered = player.Calamity().shieldOfTheOceanEmpoweredParry; @@ -73,8 +71,10 @@ namespace CalamityMod.Items.Accessories continue; // Inflict Riptide on empowered parries. + // Doze - I gave all parry accessories long debuff infliction times due to the lack of weapons that inflict debuffs for a decent time, and the scarcity of using the parry + // Most common vanilla debuffs have a way to inflict them for 15, 20, or even 30 seconds if (empowered) - npc.AddBuff(ModContent.BuffType(), 300); + npc.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(15)); // If the NPC can be moved, violently shove them away. Make them susceptible to fall damage on empowered parries. // Otherwise, simply deal a large amount of damage to them if empowered. @@ -84,11 +84,12 @@ namespace CalamityMod.Items.Accessories Vector2 shoveVelocity = Utils.DirectionTo(player.Center, npc.Center) * (Main.zenithWorld ? 35f : 12.5f) - Vector2.UnitY * 6f; npc.MoveNPC(Vector2.Normalize(shoveVelocity), shoveVelocity.Length(), true); - int scaledFallDamage = ShoveFallBaseDamage * (Main.masterMode ? 3 : Main.expertMode ? 2 : 1) * (Main.zenithWorld ? 10 : 1); + int scaledFallDamage = CalamityUtils.ScaleWithDifficulty(ShoveFallBaseDamage); + var flungNPC = npc.GetGlobalNPC(); if (empowered) - npc.FlungNPC().ApplyCollisionDamage(npc, player, scaledFallDamage, shoveVelocity * 0.5f, 5f, true); + flungNPC.ApplyCollisionDamage(npc, player, scaledFallDamage, shoveVelocity * 0.5f, 5f, true); else - npc.FlungNPC().ApplyForcedVelocity(npc, player, shoveVelocity * 0.5f, true); + flungNPC.ApplyForcedVelocity(npc, player, shoveVelocity * 0.5f, true); for (int i = -1; i <= 1; i++) { @@ -101,7 +102,7 @@ namespace CalamityMod.Items.Accessories { if (empowered) { - int scaledImmuneDamage = ImmuneToShoveBaseDamage * (Main.masterMode ? 3 : Main.expertMode ? 2 : 1) * (Main.zenithWorld ? 10 : 1); + int scaledImmuneDamage = CalamityUtils.ScaleWithDifficulty(ImmuneToShoveBaseDamage) * (Main.zenithWorld ? 10 : 1); Projectile.NewProjectile(player.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), scaledImmuneDamage, 0f, player.whoAmI, npc.whoAmI); } diff --git a/Items/Accessories/SigilofCalamitas.cs b/Items/Accessories/SigilofCalamitas.cs index eb3ff6f32b..94c5dd7487 100644 --- a/Items/Accessories/SigilofCalamitas.cs +++ b/Items/Accessories/SigilofCalamitas.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories player.manaMagnet = true; player.statManaMax2 += 100; player.GetDamage() += 0.15f; - player.manaCost *= 0.9f; + player.manaCost -= 0.1f; } public override void AddRecipes() diff --git a/Items/Accessories/SkylineBobber.cs b/Items/Accessories/SkylineBobber.cs new file mode 100644 index 0000000000..47a9fea7a3 --- /dev/null +++ b/Items/Accessories/SkylineBobber.cs @@ -0,0 +1,37 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Fishing +{ + internal class SkylineBobber : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override string Texture => "CalamityMod/Projectiles/Typeless/HeronBobber"; + public override void SetDefaults() + { + Item.width = 9; + Item.height = 9; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.accFishingBobber = true; + player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.SkylineBobber; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.FishingBobber). + AddIngredient(5). + AddIngredient(ItemID.Feather). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/SlagsplitterPauldron.cs b/Items/Accessories/SlagsplitterPauldron.cs index 57f9ef5984..0bce37c59f 100644 --- a/Items/Accessories/SlagsplitterPauldron.cs +++ b/Items/Accessories/SlagsplitterPauldron.cs @@ -1,12 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Crags; -using CalamityMod.Projectiles.Typeless; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -16,7 +11,7 @@ namespace CalamityMod.Items.Accessories public class SlagsplitterPauldron : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public static int PauldronSlamDamage = 170; + public static int PauldronSlamDamage = 330; public override void SetDefaults() { Item.width = 54; @@ -29,7 +24,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.Pauldron = true; + modPlayer.sPauldron = true; + modPlayer.sPauldronVisual = !hideVisual; } public override void AddRecipes() diff --git a/Items/Accessories/SpectralVeil.cs b/Items/Accessories/SpectralVeil.cs index c2c749190f..3cc01929cb 100644 --- a/Items/Accessories/SpectralVeil.cs +++ b/Items/Accessories/SpectralVeil.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.accessory = true; + Item.expert = true; } public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.SpectralVeilHotKey); diff --git a/Items/Accessories/SpiritGlyph.cs b/Items/Accessories/SpiritGlyph.cs index 2d1d84ad2f..c190df2877 100644 --- a/Items/Accessories/SpiritGlyph.cs +++ b/Items/Accessories/SpiritGlyph.cs @@ -11,8 +11,7 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public static int RegenBoost = 2; - public static int DefenseBoost = 6; - public static float DamageReductionBoost = 0.03f; + public static int DefenseBoost = 3; public static float SummonDamageBoost = 0.1f; public override void SetDefaults() diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index 804eaeac5d..bb95d2b0ca 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -19,7 +19,6 @@ namespace CalamityMod.Items.Accessories Item.height = 26; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; - Item.accessory = true; } public override void UpdateInventory(Player player) @@ -37,7 +36,7 @@ namespace CalamityMod.Items.Accessories Item heldItem = null; if (player.selectedItem >= 0 && player.selectedItem < Main.InventorySlotsTotal) - heldItem = player.ActiveItem(); + heldItem = player.HeldItem; static string OnePlace(float f) => f.ToString("n1"); static string TwoPlaces(float f) => f.ToString("n2"); @@ -153,13 +152,13 @@ namespace CalamityMod.Items.Accessories } } - // If ranged, or any direct subclass thereof, display ranged ammo consumption - if (dc == DamageClass.Ranged || dc.GetModifierInheritance(DamageClass.Ranged).Equals(StatInheritanceData.Full)) - stats2 += "\n" + this.GetLocalization("RangedStats").Format(TwoPlaces(100f * player.GetRangedAmmoCostReduction())); + // If held item uses ammo, display ammo consumption + if (heldItem.useAmmo > 0) + stats2 += "\n" + this.GetLocalization("AmmoStats").Format(OnePlace(100f * player.GetAmmoCostReduction())); - // If magic, or any direct subclass thereof, display mana stats - if (dc == DamageClass.Magic || dc == DamageClass.MagicSummonHybrid || dc.GetModifierInheritance(DamageClass.Magic).Equals(StatInheritanceData.Full)) - stats2 += "\n" + this.GetLocalization("MagicStats").Format(TwoPlaces(100f * player.manaCost), player.manaRegen); + // If held item uses mana, display mana stats + if (heldItem.mana > 0) + stats2 += "\n" + this.GetLocalization("ManaStats").Format(OnePlace(100f * player.manaCost), player.manaRegen); // If summon, or any direct subclass thereof, AND NOT A WHIP, display minion/sentry slots if (dc != DamageClass.SummonMeleeSpeed && (dc == DamageClass.Summon || dc.GetModifierInheritance(DamageClass.Summon).Equals(StatInheritanceData.Full))) @@ -168,7 +167,7 @@ namespace CalamityMod.Items.Accessories // If whip, show whip range float whipRange = player.whipRangeMultiplier - 1f; if (dc == DamageClass.SummonMeleeSpeed || dc.GetModifierInheritance(DamageClass.SummonMeleeSpeed).Equals(StatInheritanceData.Full)) - stats2 += "\n" + this.GetLocalization("WhipStats").Format(Sign(whipRange) + TwoPlaces(100f * whipRange)); + stats2 += "\n" + this.GetLocalization("WhipStats").Format(Sign(whipRange) + OnePlace(100f * whipRange)); // If throwing or rogue, display rogue stats. float rogueVelocity = modPlayer.rogueVelocity - 1f; @@ -178,7 +177,7 @@ namespace CalamityMod.Items.Accessories (int)(100f * modPlayer.rogueStealthMax), TwoPlaces(60f * player.GetStandingStealthRegen()), TwoPlaces(60f * player.GetMovingStealthRegen()), - Sign(rogueVelocity) + TwoPlaces(100f * rogueVelocity)); + Sign(rogueVelocity) + OnePlace(100f * rogueVelocity)); } // If tool, add tool range @@ -199,7 +198,7 @@ namespace CalamityMod.Items.Accessories } list.FindAndReplace("[ITEMS]", stats2); - float moveSpeedBoost = player.moveSpeed - 1f; + float moveSpeedBoost = CalamityServerConfig.Instance.FasterBaseSpeed ? (player.moveSpeed / BalancingConstants.DefaultMoveSpeedBoost) - 1f : player.moveSpeed - 1f; float wingFlightTime = player.wingTimeMax; // Does not use NormalizedLuck. Presents the player's luck exactly as it is used by the game engine. // NormalizedLuck is only used in one place: the Wizard's luck report. Which is entirely obsoleted by this Meter. @@ -222,8 +221,9 @@ namespace CalamityMod.Items.Accessories // Detailed Abyss stats only render if the player is in the Abyss. string stats4 = "\n" + (!modPlayer.ZoneAbyss ? this.GetLocalizedValue("AbyssStatsHidden") : this.GetLocalization("AbyssStats").Format( - player.GetCurrentAbyssLightLevel(), - TwoPlaces(modPlayer.abyssBreathLossStat), + modPlayer.abyssDarkness, + modPlayer.abyssPlayerGlowMultiplier, + modPlayer.abyssFlashlightWidthMultiplier, TwoPlaces(modPlayer.abyssBreathLossRateStat), modPlayer.abyssLifeLostAtZeroBreathStat, modPlayer.abyssDefenseLossStat)); diff --git a/Items/Accessories/StatisCurse.cs b/Items/Accessories/StatisCurse.cs index efe65bb8df..5e6decb0b0 100644 --- a/Items/Accessories/StatisCurse.cs +++ b/Items/Accessories/StatisCurse.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Accessories CreateRecipe(). AddIngredient(). AddIngredient(). - AddIngredient(ItemID.FragmentStardust, 10). + AddIngredient(ItemID.FragmentStardust, 6). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Accessories/StatisNinjaBelt.cs b/Items/Accessories/StatisNinjaBelt.cs index 3b5dca0d99..b8f26b85fb 100644 --- a/Items/Accessories/StatisNinjaBelt.cs +++ b/Items/Accessories/StatisNinjaBelt.cs @@ -1,10 +1,14 @@ -using CalamityMod.CalPlayer.Dashes; +using System.Collections.Generic; +using System.IO; +using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Accessories { @@ -25,23 +29,63 @@ namespace CalamityMod.Items.Accessories Item.rare = ItemRarityID.Purple; Item.accessory = true; } + #region Toggleable Tiger Gear + + bool toggleEnabled = true; + + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + toggleEnabled = !toggleEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("toggleEffect", toggleEnabled); + } + + public override void LoadData(TagCompound tag) + { + toggleEnabled = tag.GetBool("toggleEffect"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(toggleEnabled); + } + + public override void NetReceive(BinaryReader reader) + { + toggleEnabled = reader.ReadBoolean(); + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled); + } + #endregion + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplace("[TOGGLE]", toggleEnabled ? this.GetLocalizedValue("ToggleEffect") : ""); + base.ModifyTooltips(tooltips); + } public override void UpdateAccessory(Player player, bool hideVisual) { player.autoJump = true; player.jumpSpeedBoost += 1.6f; + player.moveSpeed += 0.1f; player.noFallDmg = true; player.blackBelt = true; player.dashType = 0; player.Calamity().DashID = StatisNinjaBeltDash.ID; - player.spikedBoots = 2; + if (toggleEnabled) + player.spikedBoots = 2; player.accFlipper = true; - player.hasMagiluminescence = true; + player.Calamity().statisNinjaBelt = true; player.MountedCenter.ToTileCoordinates(); - DelegateMethods.v3_1 = new Vector3(0.8f, 0.5f, 1f); - Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 20f, DelegateMethods.CastLightOpen); - Utils.PlotTileLine(player.Left, player.Right, 20f, DelegateMethods.CastLightOpen); } public override void AddRecipes() @@ -51,20 +95,18 @@ namespace CalamityMod.Items.Accessories CreateRecipe(). AddIngredient(ItemID.MasterNinjaGear). AddIngredient(ItemID.FrogFlipper). - AddIngredient(ItemID.Magiluminescence). - AddIngredient(50). + AddIngredient(25). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); CreateRecipe(). AddIngredient(ItemID.Tabi). AddIngredient(ItemID.BlackBelt). AddIngredient(ItemID.FrogGear). - AddIngredient(ItemID.Magiluminescence). - AddIngredient(50). + AddIngredient(25). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/StatisVoidSash.cs b/Items/Accessories/StatisVoidSash.cs index f68a1bc362..870570d09a 100644 --- a/Items/Accessories/StatisVoidSash.cs +++ b/Items/Accessories/StatisVoidSash.cs @@ -1,4 +1,6 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using System.IO; +using CalamityMod.CalPlayer; using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; using CalamityMod.Rarities; @@ -6,10 +8,12 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Accessories { @@ -17,6 +21,9 @@ namespace CalamityMod.Items.Accessories public class StatisVoidSash : ModItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Accessories"; + + public static SoundStyle VoidDash = new ("CalamityMod/Sounds/Item/VoidDash"); + public override void SetStaticDefaults() { Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(8, 3)); @@ -29,26 +36,68 @@ namespace CalamityMod.Items.Accessories Item.height = 32; Item.accessory = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); + } + #region Toggleable Tiger Gear + + bool toggleEnabled = true; + + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + toggleEnabled = !toggleEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("toggleEffect", toggleEnabled); } + public override void LoadData(TagCompound tag) + { + toggleEnabled = tag.GetBool("toggleEffect"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(toggleEnabled); + } + + public override void NetReceive(BinaryReader reader) + { + toggleEnabled = reader.ReadBoolean(); + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled); + } + #endregion + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplace("[TOGGLE]", toggleEnabled ? this.GetLocalizedValue("ToggleEffect") : ""); + base.ModifyTooltips(tooltips); + } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); + + modPlayer.voidSashVisuals = !hideVisual; + player.autoJump = true; player.jumpSpeedBoost += 1.6f; + player.moveSpeed += 0.2f; player.noFallDmg = true; player.blackBelt = true; modPlayer.DashID = StatisVoidSashDash.ID; player.dashType = 0; - player.spikedBoots = 2; + if (toggleEnabled) + player.spikedBoots = 2; player.accFlipper = true; - player.hasMagiluminescence = true; + player.Calamity().statisVoidSash = true; player.MountedCenter.ToTileCoordinates(); - DelegateMethods.v3_1 = new Vector3(0.8f, 0.5f, 1f); - Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 20f, DelegateMethods.CastLightOpen); - Utils.PlotTileLine(player.Left, player.Right, 20f, DelegateMethods.CastLightOpen); } public override void AddRecipes() diff --git a/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs b/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs index 5c1034b6db..a287e37757 100644 --- a/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs +++ b/Items/Accessories/SupremeBaitTackleBoxFishingStation.cs @@ -24,14 +24,12 @@ namespace CalamityMod.Items.Accessories player.accTackleBox = true; player.accLavaFishing = true; player.Calamity().fishingStation = true; - player.sonarPotion = true; } public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.LavaproofTackleBag). - AddIngredient(ItemID.SonarPotion, 5). AddIngredient(ItemID.MasterBait, 5). AddIngredient(5). AddTile(TileID.Anvils). diff --git a/Items/Accessories/TheAbsorber.cs b/Items/Accessories/TheAbsorber.cs index 2b2e35e978..08416580fe 100644 --- a/Items/Accessories/TheAbsorber.cs +++ b/Items/Accessories/TheAbsorber.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Accessories public static float MoveSpeedBoost = 0.12f; public static float JumpSpeedBoost = 0.6f; // Both 12% so we only need just one in the tooltip - public static float ThornsBoost = 3.5f; + public static int ThornsDamage => CalamityUtils.ScaleWithDifficulty(200); public static int AuraLifetime = 1800; - public static int AuraRegenBoost = 6; + public static int AuraRegenBoost = 4; public static float AuraDamageBoost = 0.08f; public static float AuraDamageReductionBoost = 0.05f; public static float DamageTakenHealedPercent = 0.05f; @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 20; Item.height = 24; - Item.defense = 10; + Item.defense = 6; Item.value = CalamityGlobalItem.RarityRedBuyPrice; Item.rare = ItemRarityID.Red; Item.accessory = true; diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index a799be70a3..fdea11a01a 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -1,6 +1,5 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; @@ -15,6 +14,9 @@ namespace CalamityMod.Items.Accessories public class TheAmalgam : ModItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Accessories"; + + public static int NimbusDamage => CalamityUtils.ScaleWithDifficulty(200); + public override void SetStaticDefaults() { Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(9, 6)); @@ -27,7 +29,8 @@ namespace CalamityMod.Items.Accessories Item.height = 34; Item.accessory = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = RarityType(); + Item.rare = RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -36,19 +39,23 @@ namespace CalamityMod.Items.Accessories modPlayer.rBrain = true; // Handles shaderain cloud spawning on hit modPlayer.amalgam = true; player.brainOfConfusionItem = Item; - player.GetDamage() += 0.15f; + modPlayer.HeatDebuffMultiplier += 3f; + modPlayer.ColdDebuffMultiplier += 3f; + modPlayer.SicknessDebuffMultiplier += 3f; + modPlayer.WaterDebuffMultiplier += 3f; + modPlayer.ElectricDebuffMultiplier += 3f; } public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(5). AddIngredient(4). - AddIngredient(5). - AddIngredient(10). - AddIngredient(15). + AddIngredient(ItemID.LunarBar, 10). + AddIngredient(ItemID.FragmentSolar, 10). AddIngredient(15). + AddIngredient(15). + AddIngredient(8). AddTile(). Register(); } diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index b6f793c7e2..6f41d35859 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Items.Accessories Item.rare = ItemRarityID.Yellow; Item.accessory = true; Item.defense = 10; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -62,18 +63,18 @@ namespace CalamityMod.Items.Accessories { if (npc.IsAnEnemy() && !npc.dontTakeDamage && Vector2.Distance(player.Center, npc.Center) <= range) { - int campingFireDamage = (int)player.GetBestClassDamage().ApplyTo(Main.rand.Next(20, 41)); + int campingFireDamage = (int)player.GetBestClassDamage().ApplyTo(Main.rand.Next(100, 121)); Projectile.NewProjectile(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), campingFireDamage, 0f, player.whoAmI, npc.whoAmI); } } } - if (player.ActiveItem() != null && !player.ActiveItem().IsAir && player.ActiveItem().stack > 0) + if (player.HeldItem != null && !player.HeldItem.IsAir && player.HeldItem.stack > 0) { - bool summon = player.ActiveItem().CountsAsClass(); - bool rogue = player.ActiveItem().CountsAsClass(); - bool melee = player.ActiveItem().CountsAsClass(); - bool ranged = player.ActiveItem().CountsAsClass(); - bool magic = player.ActiveItem().CountsAsClass(); + bool summon = player.HeldItem.CountsAsClass(); + bool rogue = player.HeldItem.CountsAsClass(); + bool melee = player.HeldItem.CountsAsClass(); + bool ranged = player.HeldItem.CountsAsClass(); + bool magic = player.HeldItem.CountsAsClass(); if (summon) { player.GetKnockback() += 0.1f; diff --git a/Items/Accessories/TheCommunity.cs b/Items/Accessories/TheCommunity.cs index 7aeffc057c..b2931c9bb6 100644 --- a/Items/Accessories/TheCommunity.cs +++ b/Items/Accessories/TheCommunity.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CalPlayer; -using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -109,6 +108,10 @@ namespace CalamityMod.Items.Accessories public override void ModifyTooltips(List list) { + var ThankYouTooltip = list.FirstOrDefault(x => x.Name == "Tooltip2" && x.Mod == "Terraria"); + if (ThankYouTooltip != null) + ThankYouTooltip.OverrideColor = Main.DiscoColor; + float power = CalculatePower(); string statList = this.GetLocalization("StatsList").Format( (DamageMultiplier * power * 100).ToString("N1"), diff --git a/Items/Accessories/TheEvolution.cs b/Items/Accessories/TheEvolution.cs index 7f0dff4b8a..5b90135f40 100644 --- a/Items/Accessories/TheEvolution.cs +++ b/Items/Accessories/TheEvolution.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/TheSponge.cs b/Items/Accessories/TheSponge.cs index e6e56b2c1d..22ec9c272c 100644 --- a/Items/Accessories/TheSponge.cs +++ b/Items/Accessories/TheSponge.cs @@ -5,6 +5,7 @@ using CalamityMod.DataStructures; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -15,6 +16,7 @@ using Terraria.DataStructures; using Terraria.GameContent; using Terraria.Graphics.Effects; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -32,13 +34,11 @@ namespace CalamityMod.Items.Accessories public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/RoverDriveActivate") { Volume = 0.85f }; public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/Custom/RoverDriveBreak") { Volume = 0.75f }; - public static int ShieldDurabilityMax = 180; - public static int ShieldRechargeDelay = CalamityUtils.SecondsToFrames(9); // was 6 - public static int TotalShieldRechargeTime = CalamityUtils.SecondsToFrames(6); - - // While active, The Sponge gives 30 defense and 10% DR - public static int ShieldActiveDefense = 30; + public static int ShieldDurabilityMax = 120; public static float ShieldActiveDamageReduction = 0.1f; + public static int ShieldRechargeDelay = CalamityUtils.SecondsToFrames(8); // Was 6, then was 9 + public static int TotalShieldRechargeTime = CalamityUtils.SecondsToFrames(10); // Was 6 + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(ShieldDurabilityMax, ShieldActiveDamageReduction.ToPercent(), ShieldRechargeDelay.FramesToSeconds(), TotalShieldRechargeTime.FramesToSeconds()); public int OwnerPlayer { get; set; } public float RenderDepth => IDyeableShaderRenderer.SpongeShieldDepth; @@ -80,20 +80,18 @@ namespace CalamityMod.Items.Accessories Item.height = 20; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.accessory = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); modPlayer.sponge = true; + player.noKnockback = true; modPlayer.spongeShieldVisible = !hideVisual; if (modPlayer.SpongeShieldDurability > 0) - { - player.statDefense += ShieldActiveDefense; player.endurance += ShieldActiveDamageReduction; - } } // In vanity, provides a visual shield but no actual functionality @@ -234,14 +232,16 @@ namespace CalamityMod.Items.Accessories shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3()); shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3()); - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, Matrix.Identity, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, shieldEffect, Main.Transform); // Fetch shield noise overlay texture (this is the polygons fed to the shader) NoiseTex ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"); Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition; Texture2D tex = NoiseTex.Value; Main.spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0); - }); + Main.spriteBatch.End(); + } modPlayer.drawnAnyShieldThisFrame = true; } diff --git a/Items/Accessories/TheTransformer.cs b/Items/Accessories/TheTransformer.cs index eb41891dc2..fb3ba3f541 100644 --- a/Items/Accessories/TheTransformer.cs +++ b/Items/Accessories/TheTransformer.cs @@ -2,7 +2,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -20,8 +19,8 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void ModifyTooltips(List list) { - list.IntegrateHotkey(CalamityKeybinds.TransformerHotKey); list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal"))); + list.IntegrateHotkey(CalamityKeybinds.TransformerHotKey); } public override void SetStaticDefaults() { @@ -57,10 +56,10 @@ namespace CalamityMod.Items.Accessories AddIngredient(10). AddRecipeGroup("AnyMythrilBar", 5). AddIngredient(2). - AddIngredient(2). AddIngredient(2). - AddIngredient(ItemID.SoulofNight, 3). + AddIngredient(2). AddIngredient(ItemID.SoulofLight, 3). + AddIngredient(ItemID.SoulofNight, 3). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index 97daa1e8cb..d945124645 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -1,11 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; -using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -21,6 +16,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -28,6 +24,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.toxicHeart = true; modPlayer.toxicHeartVisuals = !hideVisual; + modPlayer.SicknessDebuffMultiplier += 0.5f; } } } diff --git a/Items/Accessories/TrinketofChi.cs b/Items/Accessories/TrinketofChi.cs index aaba2c7446..0730b3c78a 100644 --- a/Items/Accessories/TrinketofChi.cs +++ b/Items/Accessories/TrinketofChi.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Accessories public class TrinketofChi : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - internal const int ChiBuffTimerMax = 300; + internal const int ChiBuffTimerMax = 600; public override void SetDefaults() { diff --git a/Items/Accessories/UnholyTonic.cs b/Items/Accessories/UnholyTonic.cs new file mode 100644 index 0000000000..38c3be3023 --- /dev/null +++ b/Items/Accessories/UnholyTonic.cs @@ -0,0 +1,39 @@ +using CalamityMod.Buffs.DamageOverTime; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class UnholyTonic : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public override void SetDefaults() + { + Item.width = 20; + Item.height = 20; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.buffImmune[ModContent.BuffType()] = true; + if (player.ZoneCorrupt) + { + player.statDefense += 6; + player.endurance += 0.04f; + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.VilePowder, 15). + AddIngredient(ItemID.RottenChunk, 10). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/CorruptFlask.png b/Items/Accessories/UnholyTonic.png similarity index 100% rename from Items/Accessories/CorruptFlask.png rename to Items/Accessories/UnholyTonic.png diff --git a/Items/Accessories/UnstableGraniteCore.cs b/Items/Accessories/UnstableGraniteCore.cs index c6c5779487..178ce5ca83 100644 --- a/Items/Accessories/UnstableGraniteCore.cs +++ b/Items/Accessories/UnstableGraniteCore.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - Item.width = 40; - Item.height = 44; + Item.width = 46; + Item.height = 48; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; diff --git a/Items/Accessories/UnstableGraniteCore.png b/Items/Accessories/UnstableGraniteCore.png index 309d3cfa45..02230f0bca 100644 Binary files a/Items/Accessories/UnstableGraniteCore.png and b/Items/Accessories/UnstableGraniteCore.png differ diff --git a/Items/Accessories/VampiricTalisman.cs b/Items/Accessories/VampiricTalisman.cs index 4f6d09983b..eb0800a9db 100644 --- a/Items/Accessories/VampiricTalisman.cs +++ b/Items/Accessories/VampiricTalisman.cs @@ -3,11 +3,22 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; namespace CalamityMod.Items.Accessories { - public class VampiricTalisman : ModItem, ILocalizedModType + public class VampiricTalisman : ModItem, ILocalizedModType, IHoldShiftTooltipItem { + internal const int ArmorCrunchDebuffTime = 150; + internal const int HeavyBleedingDebuffTime = 300; + public const float RaiderBonus = 15f; + + public bool ShowExtensionIndicator => false; + + // Easter egg has a special tooltip key and color. + public string TooltipExtensionKey => "YearningForBlood"; + public Color? TooltipExtensionColor => Color.Red; + public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { @@ -22,14 +33,21 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.vampiricTalisman = true; - player.GetDamage() += 0.12f; + modPlayer.raiderTalisman = true; + modPlayer.rottenDogTooth = true; + + //get fixed boi funny + if (Main.zenithWorld) + player.lifeRegen -= 10; //Never ending thirst } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). + AddIngredient(). AddIngredient(10). + AddIngredient(ItemID.BrokenBatWing). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs b/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs index 32ca98b5e7..abcdf74751 100644 --- a/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs +++ b/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs @@ -1,7 +1,6 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Items.BaseItems; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -19,35 +18,19 @@ namespace CalamityMod.Items.Accessories.Vanity [LegacyName("WulfrumHeadMelee")] [LegacyName("WulfrumHood")] [LegacyName("WulfrumHeadMagic")] - public class AbandonedWulfrumHelmet : ModItem, ILocalizedModType + public class AbandonedWulfrumHelmet : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/AbandonedWulfrumHelmet_HeadSet", EquipType.Head, name: "WulfrumOldSetHead"); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/AbandonedWulfrumHelmet_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/AbandonedWulfrumHelmet_Legs", EquipType.Legs, this); - } - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "AbandonedWulfrumHelmetTrans", "WulfrumOldSetHead"), + (EquipType.Body, "AbandonedWulfrumHelmet", null), + (EquipType.Legs, "AbandonedWulfrumHelmet", null), + (EquipType.Face, null, null), //results in setting this equip slot to -1 + ]; + public override bool ShouldHideAccessories => true; - public override void SetStaticDefaults() - { - - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, "WulfrumOldSetHead", EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (SoundStyle sound, int delay)? HurtSound(Player p) => (SoundID.NPCHit4, 10); public override void SetDefaults() { @@ -61,7 +44,6 @@ namespace CalamityMod.Items.Accessories.Vanity public override void UpdateVanity(Player player) { - player.GetModPlayer().transformationActive = true; player.GetModPlayer().vanityEquipped = true; } @@ -69,7 +51,6 @@ namespace CalamityMod.Items.Accessories.Vanity { if (!hideVisual) { - player.GetModPlayer().transformationActive = true; player.GetModPlayer().vanityEquipped = true; } } @@ -78,31 +59,10 @@ namespace CalamityMod.Items.Accessories.Vanity public class WulfrumTransformationPlayer : ModPlayer { public bool vanityEquipped = false; - public bool transformationActive = false; - public bool forceHelmetOn = false; public override void ResetEffects() { vanityEquipped = false; - transformationActive = false; - forceHelmetOn = false; - } - - public override void FrameEffects() - { - if (forceHelmetOn || transformationActive) - { - Player.head = EquipLoader.GetEquipSlot(Mod, "WulfrumOldSetHead", EquipType.Head); - Player.face = -1; - } - - if (transformationActive) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "AbandonedWulfrumHelmet", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "AbandonedWulfrumHelmet", EquipType.Body); - - Player.HideAccessories(); - } } } } diff --git a/Items/Accessories/Vanity/AbandonedWulfrumHelmet_HeadSet.png b/Items/Accessories/Vanity/AbandonedWulfrumHelmetTrans_Head.png similarity index 100% rename from Items/Accessories/Vanity/AbandonedWulfrumHelmet_HeadSet.png rename to Items/Accessories/Vanity/AbandonedWulfrumHelmetTrans_Head.png diff --git a/Items/Accessories/Vanity/CrystalHeartVodka.cs b/Items/Accessories/Vanity/CrystalHeartVodka.cs deleted file mode 100644 index ada7c260f7..0000000000 --- a/Items/Accessories/Vanity/CrystalHeartVodka.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories.Vanity -{ - public class CrystalHeartVodka : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Fabsol_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Fabsol_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Fabsol_Legs", EquipType.Legs, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Fabsol_Back", EquipType.Back, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } - - public override void SetDefaults() - { - Item.width = 22; - Item.height = 30; - Item.accessory = true; - - // Same as Cirrus' Vodka, due to the obtainment method being shimmering Cirrus' Vodka. - Item.value = Item.sellPrice(silver: 30); - Item.rare = ItemRarityID.LightRed; - - Item.vanity = true; - Item.Calamity().devItem = true; - } - - public override void UpdateVanity(Player player) - { - player.GetModPlayer().vanityEquipped = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (!hideVisual) - player.GetModPlayer().vanityEquipped = true; - } - } - - public class CrystalHeartVodkaPlayer : ModPlayer - { - public bool vanityEquipped = false; - - public override void ResetEffects() - { - vanityEquipped = false; - } - - public override void FrameEffects() - { - if (vanityEquipped) - { - Player.back = EquipLoader.GetEquipSlot(Mod, "CrystalHeartVodka", EquipType.Back); - Player.legs = EquipLoader.GetEquipSlot(Mod, "CrystalHeartVodka", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "CrystalHeartVodka", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "CrystalHeartVodka", EquipType.Head); - - //Player.HideAccessories(); - } - } - } -} diff --git a/Items/Accessories/Vanity/CrystalHeartVodka.png b/Items/Accessories/Vanity/CrystalHeartVodka.png deleted file mode 100644 index d0faf45977..0000000000 Binary files a/Items/Accessories/Vanity/CrystalHeartVodka.png and /dev/null differ diff --git a/Items/Accessories/Vanity/Fabsol_Back.png b/Items/Accessories/Vanity/Fabsol_Back.png deleted file mode 100644 index 1563280bdc..0000000000 Binary files a/Items/Accessories/Vanity/Fabsol_Back.png and /dev/null differ diff --git a/Items/Accessories/Vanity/Fabsol_Body.png b/Items/Accessories/Vanity/Fabsol_Body.png deleted file mode 100644 index d98fdec79c..0000000000 Binary files a/Items/Accessories/Vanity/Fabsol_Body.png and /dev/null differ diff --git a/Items/Accessories/Vanity/Fabsol_Head.png b/Items/Accessories/Vanity/Fabsol_Head.png deleted file mode 100644 index bf96b48a95..0000000000 Binary files a/Items/Accessories/Vanity/Fabsol_Head.png and /dev/null differ diff --git a/Items/Accessories/Vanity/Fabsol_Legs.png b/Items/Accessories/Vanity/Fabsol_Legs.png deleted file mode 100644 index 1156798b60..0000000000 Binary files a/Items/Accessories/Vanity/Fabsol_Legs.png and /dev/null differ diff --git a/Items/Accessories/Vanity/GhostBracelet.cs b/Items/Accessories/Vanity/GhostBracelet.cs index 18bb48b9c6..d664f0665b 100644 --- a/Items/Accessories/Vanity/GhostBracelet.cs +++ b/Items/Accessories/Vanity/GhostBracelet.cs @@ -1,38 +1,19 @@ -using Terraria; +using CalamityMod.Items.BaseItems; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Vanity { [LegacyName("RedBow")] - public class GhostBracelet : ModItem, ILocalizedModType + public class GhostBracelet : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Dandy_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Dandy_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Dandy_Legs", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Dandy", null), + (EquipType.Body, "Dandy", null), + (EquipType.Legs, "Dandy", null), + ]; public override void SetDefaults() { @@ -45,19 +26,6 @@ namespace CalamityMod.Items.Accessories.Vanity Item.Calamity().devItem = true; } - public override void UpdateVanity(Player player) - { - player.Calamity().ghostBracelet = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (!hideVisual) - { - player.Calamity().ghostBracelet = true; - } - } - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/Vanity/GoldenBomb.cs b/Items/Accessories/Vanity/GoldenBomb.cs index cef27a6ceb..8f7360b95b 100644 --- a/Items/Accessories/Vanity/GoldenBomb.cs +++ b/Items/Accessories/Vanity/GoldenBomb.cs @@ -1,37 +1,18 @@ -using Terraria; +using CalamityMod.Items.BaseItems; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Vanity { - public class GoldenBomb : ModItem, ILocalizedModType + public class GoldenBomb : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Mihaii_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Mihaii_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Mihaii_Legs", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Mihaii", null), + (EquipType.Body, "Mihaii", null), + (EquipType.Legs, "Mihaii", null), + ]; public override void SetDefaults() { @@ -43,38 +24,5 @@ namespace CalamityMod.Items.Accessories.Vanity Item.vanity = true; Item.Calamity().devItem = true; } - - public override void UpdateVanity(Player player) - { - player.GetModPlayer().vanityEquipped = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (!hideVisual) - { - player.GetModPlayer().vanityEquipped = true; - } - } - } - - public class GoldenBombPlayer : ModPlayer - { - public bool vanityEquipped = false; - - public override void ResetEffects() - { - vanityEquipped = false; - } - - public override void FrameEffects() - { - if (vanityEquipped) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "GoldenBomb", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "GoldenBomb", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "GoldenBomb", EquipType.Head); - } - } } } diff --git a/Items/Accessories/Vanity/HapuFruit.cs b/Items/Accessories/Vanity/HapuFruit.cs index 65b1948303..608e9634dc 100644 --- a/Items/Accessories/Vanity/HapuFruit.cs +++ b/Items/Accessories/Vanity/HapuFruit.cs @@ -1,42 +1,19 @@ -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; +using CalamityMod.Items.BaseItems; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Vanity { - public class HapuFruit : ModItem, ILocalizedModType + public class HapuFruit : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Heart_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Heart_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Heart_Legs", EquipType.Legs, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Heart_Back", EquipType.Back, this); - } - } - - public override void SetStaticDefaults() - { - - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Heart", null), + (EquipType.Body, "Heart", null), + (EquipType.Legs, "Heart", null), + (EquipType.Back, "Heart", null) + ]; public override void SetDefaults() { @@ -48,41 +25,5 @@ namespace CalamityMod.Items.Accessories.Vanity Item.vanity = true; Item.Calamity().devItem = true; } - - public override void UpdateVanity(Player player) - { - player.GetModPlayer().vanityEquipped = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (!hideVisual) - { - player.GetModPlayer().vanityEquipped = true; - } - } - } - - public class HapuFruitPlayer : ModPlayer - { - public bool vanityEquipped = false; - - public override void ResetEffects() - { - vanityEquipped = false; - } - - public override void FrameEffects() - { - if (vanityEquipped) - { - Player.back = EquipLoader.GetEquipSlot(Mod, "HapuFruit", EquipType.Back); - Player.legs = EquipLoader.GetEquipSlot(Mod, "HapuFruit", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "HapuFruit", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "HapuFruit", EquipType.Head); - - //Player.HideAccessories(); - } - } } } diff --git a/Items/Accessories/Vanity/LucisSight.cs b/Items/Accessories/Vanity/LucisSight.cs new file mode 100644 index 0000000000..df711e8b14 --- /dev/null +++ b/Items/Accessories/Vanity/LucisSight.cs @@ -0,0 +1,28 @@ +using CalamityMod.Items.BaseItems; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories.Vanity +{ + public class LucisSight : TransformationAccessory, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Face, "LucisSight", null), + ]; + + public override void SetDefaults() + { + Item.width = 28; + Item.height = 18; + Item.value = Item.buyPrice(gold: 10); // Sold by Steampunker + Item.rare = ItemRarityID.Pink; + Item.accessory = true; + Item.vanity = true; + Item.Calamity().donorItem = true; + } + } +} diff --git a/Items/Accessories/Vanity/LucisSight.png b/Items/Accessories/Vanity/LucisSight.png new file mode 100644 index 0000000000..47aa49c9a1 Binary files /dev/null and b/Items/Accessories/Vanity/LucisSight.png differ diff --git a/Items/Accessories/Vanity/LucisSight_Face.png b/Items/Accessories/Vanity/LucisSight_Face.png new file mode 100644 index 0000000000..b56c28cf6e Binary files /dev/null and b/Items/Accessories/Vanity/LucisSight_Face.png differ diff --git a/Items/Accessories/Vanity/OracleHeadphones.cs b/Items/Accessories/Vanity/OracleHeadphones.cs index 47645f8084..a48d0489b1 100644 --- a/Items/Accessories/Vanity/OracleHeadphones.cs +++ b/Items/Accessories/Vanity/OracleHeadphones.cs @@ -1,39 +1,19 @@ -using Terraria; +using CalamityMod.Items.BaseItems; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Vanity { - public class OracleHeadphones : ModItem, ILocalizedModType + public class OracleHeadphones : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Mishiro_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Mishiro_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Mishiro_Legs", EquipType.Legs, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Mishiro_Back", EquipType.Back, this); - } - } - - public override void SetStaticDefaults() - { - - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Mishiro", null), + (EquipType.Body, "Mishiro", null), + (EquipType.Legs, "Mishiro", null), + (EquipType.Back, "Mishiro", null) + ]; public override void SetDefaults() { @@ -45,41 +25,5 @@ namespace CalamityMod.Items.Accessories.Vanity Item.vanity = true; Item.Calamity().devItem = true; } - - public override void UpdateVanity(Player player) - { - player.GetModPlayer().vanityEquipped = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (!hideVisual) - { - player.GetModPlayer().vanityEquipped = true; - } - } - } - - public class OracleHeadphonesPlayer : ModPlayer - { - public bool vanityEquipped = false; - - public override void ResetEffects() - { - vanityEquipped = false; - } - - public override void FrameEffects() - { - if (vanityEquipped) - { - Player.back = EquipLoader.GetEquipSlot(Mod, "OracleHeadphones", EquipType.Back); - Player.legs = EquipLoader.GetEquipSlot(Mod, "OracleHeadphones", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "OracleHeadphones", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "OracleHeadphones", EquipType.Head); - - //Player.HideAccessories(); - } - } } } diff --git a/Items/Accessories/Vanity/Popo.cs b/Items/Accessories/Vanity/Popo.cs index 66fe6d0f3c..92a8cd69bf 100644 --- a/Items/Accessories/Vanity/Popo.cs +++ b/Items/Accessories/Vanity/Popo.cs @@ -1,61 +1,40 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Items.BaseItems; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Vanity { - public class Popo : ModItem, ILocalizedModType + public class Popo : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Popo_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/PopoNoseless_Head", EquipType.Head, name: "PopoNoseless"); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Popo_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Popo_Legs", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Popo", null), + (EquipType.Head, "PopoNoseless", "PopoNoseless"), + (EquipType.Body, "Popo", null), + (EquipType.Legs, "Popo", null), + (EquipType.Face, null, null), //results in setting this equip slot to -1 + ]; public override void SetDefaults() { Item.width = 36; Item.height = 44; Item.accessory = true; - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.value = Item.buyPrice(platinum: 5); // Sold by Archmage Item.rare = ItemRarityID.Pink; Item.Calamity().devItem = true; } - public override void UpdateVanity(Player player) + public override bool CustomSetEquipType(Player player, EquipType type, Mod mod, string name) { - player.Calamity().snowmanHide = false; - player.Calamity().snowmanForce = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.snowman = true; - if (hideVisual) + if (type == EquipType.Head) { - modPlayer.snowmanHide = true; + player.head = EquipLoader.GetEquipSlot(Mod, player.Calamity().snowmanNoseless ? "PopoNoseless" : "Popo", EquipType.Head); + return true; } + return false; } } } diff --git a/Items/Accessories/Vanity/PunchCard.cs b/Items/Accessories/Vanity/PunchCard.cs deleted file mode 100644 index 40ac2b7d48..0000000000 --- a/Items/Accessories/Vanity/PunchCard.cs +++ /dev/null @@ -1,70 +0,0 @@ -using CalamityMod.UI; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories.Vanity -{ - public class PunchCard : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Shayy_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Shayy_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Shayy_Legs", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } - - public override void SetDefaults() - { - Item.width = 42; - Item.height = 38; - Item.accessory = true; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Purple; - Item.vanity = true; - Item.Calamity().devItem = true; - Item.useAnimation = Item.useTime = 20; - Item.useStyle = ItemUseStyleID.HoldUp; - } - - public override bool? UseItem(Player player) - { - if (Main.myPlayer == player.whoAmI) - PopupGUIManager.FlipActivityOfGUIWithType(typeof(PunchCardGUI)); - return true; - } - - public override void UpdateVanity(Player player) - { - player.Calamity().punchCard = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (!hideVisual) - { - player.Calamity().punchCard = true; - } - } - } -} diff --git a/Items/Accessories/Vanity/PunchCard.png b/Items/Accessories/Vanity/PunchCard.png deleted file mode 100644 index 51e56a5319..0000000000 Binary files a/Items/Accessories/Vanity/PunchCard.png and /dev/null differ diff --git a/Items/Accessories/Vanity/SharkyPlush.cs b/Items/Accessories/Vanity/SharkyPlush.cs index 77efd68e44..e1ea600ca7 100644 --- a/Items/Accessories/Vanity/SharkyPlush.cs +++ b/Items/Accessories/Vanity/SharkyPlush.cs @@ -1,39 +1,19 @@ -using System; -using Terraria; +using CalamityMod.Items.BaseItems; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Vanity { - public class SharkyPlush : ModItem, ILocalizedModType + public class SharkyPlush : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Shark_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Shark_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Shark_Legs", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Shark", null), + (EquipType.Body, "Shark", null), + (EquipType.Legs, "Shark", null), + ]; public override void SetDefaults() { @@ -45,38 +25,5 @@ namespace CalamityMod.Items.Accessories.Vanity Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.Calamity().devItem = true; } - - public override void UpdateVanity(Player player) - { - player.GetModPlayer().vanityEquipped = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (!hideVisual) - { - player.GetModPlayer().vanityEquipped = true; - } - } - } - - public class SharkyPlushPlayer : ModPlayer - { - public bool vanityEquipped = false; - - public override void ResetEffects() - { - vanityEquipped = false; - } - - public override void FrameEffects() - { - if (vanityEquipped) - { - Player.legs = EquipLoader.GetEquipSlot(Mod, "SharkyPlush", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "SharkyPlush", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "SharkyPlush", EquipType.Head); - } - } } } diff --git a/Items/Accessories/Vanity/Shayy_Body.png b/Items/Accessories/Vanity/Shayy_Body.png deleted file mode 100644 index 56fbab6258..0000000000 Binary files a/Items/Accessories/Vanity/Shayy_Body.png and /dev/null differ diff --git a/Items/Accessories/Vanity/Shayy_Head.png b/Items/Accessories/Vanity/Shayy_Head.png deleted file mode 100644 index 25b28f865a..0000000000 Binary files a/Items/Accessories/Vanity/Shayy_Head.png and /dev/null differ diff --git a/Items/Accessories/Vanity/Shayy_Legs.png b/Items/Accessories/Vanity/Shayy_Legs.png deleted file mode 100644 index 270b56183d..0000000000 Binary files a/Items/Accessories/Vanity/Shayy_Legs.png and /dev/null differ diff --git a/Items/Accessories/Vanity/Xyk_Body2.png b/Items/Accessories/Vanity/Xyk2_Body.png similarity index 100% rename from Items/Accessories/Vanity/Xyk_Body2.png rename to Items/Accessories/Vanity/Xyk2_Body.png diff --git a/Items/Accessories/Vanity/Xyk_Head2.png b/Items/Accessories/Vanity/Xyk2_Head.png similarity index 100% rename from Items/Accessories/Vanity/Xyk_Head2.png rename to Items/Accessories/Vanity/Xyk2_Head.png diff --git a/Items/Accessories/Vanity/Xyk_Legs2.png b/Items/Accessories/Vanity/Xyk2_Legs.png similarity index 100% rename from Items/Accessories/Vanity/Xyk_Legs2.png rename to Items/Accessories/Vanity/Xyk2_Legs.png diff --git a/Items/Accessories/Vanity/Xyk_Arms.png b/Items/Accessories/Vanity/Xyk_Arms.png deleted file mode 100644 index f7bb6a0d07..0000000000 Binary files a/Items/Accessories/Vanity/Xyk_Arms.png and /dev/null differ diff --git a/Items/Accessories/Vanity/XyksBlessingBlue.cs b/Items/Accessories/Vanity/XyksBlessingBlue.cs index 520a9f3202..3c0954a148 100644 --- a/Items/Accessories/Vanity/XyksBlessingBlue.cs +++ b/Items/Accessories/Vanity/XyksBlessingBlue.cs @@ -1,61 +1,42 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.BaseItems; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; +using Terraria.GameContent.NetModules; using Terraria.ModLoader; +using Terraria.Net; namespace CalamityMod.Items.Accessories.Vanity { - public class XyksBlessingBlue : ModItem, ILocalizedModType + public class XyksBlessingBlue : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Xyk_Head", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Xyk_Body", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Xyk_Legs", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = false; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Xyk", null), + (EquipType.Body, "Xyk", null), + (EquipType.Legs, "Xyk", null), + (EquipType.Wings, null, null), //results in setting this equip slot to -1 + ]; public override void SetDefaults() { Item.width = 36; Item.height = 34; Item.accessory = true; - Item.consumable = true; Item.vanity = true; Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.Calamity().devItem = true; } public override bool CanRightClick() => true; - - public override void ModifyItemLoot(ItemLoot itemLoot) + public override void RightClick(Player player) { - itemLoot.Add(ModContent.ItemType()); + player.PutItemInInventoryFromItemUsage(ModContent.ItemType(), 1); } public override void UpdateVanity(Player player) { - player.GetModPlayer().vanityEquipped = true; CalamityPlayer modPlayer = player.Calamity(); modPlayer.XykVisualsBlue = true; } @@ -64,29 +45,25 @@ namespace CalamityMod.Items.Accessories.Vanity { if (!hideVisual) { - player.GetModPlayer().vanityEquipped = true; CalamityPlayer modPlayer = player.Calamity(); modPlayer.XykVisualsBlue = true; } } - } - public class XyksBlessingBluePlayer : ModPlayer - { - public bool vanityEquipped = false; - - public override void ResetEffects() + // Also research the other variant + public override void OnResearched(bool fullyResearched) { - vanityEquipped = false; - } - - public override void FrameEffects() - { - if (vanityEquipped) + if (fullyResearched) { - Player.legs = EquipLoader.GetEquipSlot(Mod, "XyksBlessingBlue", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "XyksBlessingBlue", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "XyksBlessingBlue", EquipType.Head); + if (!Main.ServerSideCharacter) + { + Main.LocalPlayerCreativeTracker.ItemSacrifices.RegisterItemSacrifice(ModContent.ItemType(), 1); + } + else + { + NetPacket packet = NetCreativeUnlocksPlayerReportModule.SerializeSacrificeRequest(ModContent.ItemType(), 1); + NetManager.Instance.SendToServerOrLoopback(packet); + } } } } diff --git a/Items/Accessories/Vanity/XyksBlessingOrange.cs b/Items/Accessories/Vanity/XyksBlessingOrange.cs index b2908d3a7b..940278db9e 100644 --- a/Items/Accessories/Vanity/XyksBlessingOrange.cs +++ b/Items/Accessories/Vanity/XyksBlessingOrange.cs @@ -1,61 +1,42 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.BaseItems; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; +using Terraria.GameContent.NetModules; using Terraria.ModLoader; +using Terraria.Net; namespace CalamityMod.Items.Accessories.Vanity { - public class XyksBlessingOrange : ModItem, ILocalizedModType + public class XyksBlessingOrange : TransformationAccessory, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Xyk_Head2", EquipType.Head, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Xyk_Body2", EquipType.Body, this); - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Accessories/Vanity/Xyk_Legs2", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - - int equipSlotHead = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Head); - ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = true; - - int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = false; - ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; - - int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; - } + public override (EquipType, string, string)[] EquipSlots => + [ + (EquipType.Head, "Xyk2", null), + (EquipType.Body, "Xyk2", null), + (EquipType.Legs, "Xyk2", null), + (EquipType.Wings, null, null), //results in setting this equip slot to -1 + ]; public override void SetDefaults() { Item.width = 36; Item.height = 34; Item.accessory = true; - Item.consumable = true; Item.vanity = true; Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.Calamity().devItem = true; } public override bool CanRightClick() => true; - - public override void ModifyItemLoot(ItemLoot itemLoot) + public override void RightClick(Player player) { - itemLoot.Add(ModContent.ItemType()); + player.PutItemInInventoryFromItemUsage(ModContent.ItemType(), 1); } public override void UpdateVanity(Player player) { - player.GetModPlayer().vanityEquipped = true; CalamityPlayer modPlayer = player.Calamity(); modPlayer.XykVisualsOrange = true; } @@ -64,29 +45,25 @@ namespace CalamityMod.Items.Accessories.Vanity { if (!hideVisual) { - player.GetModPlayer().vanityEquipped = true; CalamityPlayer modPlayer = player.Calamity(); modPlayer.XykVisualsOrange = true; } } - } - public class XyksBlessingOrangePlayer : ModPlayer - { - public bool vanityEquipped = false; - - public override void ResetEffects() + // Also research the other variant + public override void OnResearched(bool fullyResearched) { - vanityEquipped = false; - } - - public override void FrameEffects() - { - if (vanityEquipped) + if (fullyResearched) { - Player.legs = EquipLoader.GetEquipSlot(Mod, "XyksBlessingOrange", EquipType.Legs); - Player.body = EquipLoader.GetEquipSlot(Mod, "XyksBlessingOrange", EquipType.Body); - Player.head = EquipLoader.GetEquipSlot(Mod, "XyksBlessingOrange", EquipType.Head); + if (!Main.ServerSideCharacter) + { + Main.LocalPlayerCreativeTracker.ItemSacrifices.RegisterItemSacrifice(ModContent.ItemType(), 1); + } + else + { + NetPacket packet = NetCreativeUnlocksPlayerReportModule.SerializeSacrificeRequest(ModContent.ItemType(), 1); + NetManager.Instance.SendToServerOrLoopback(packet); + } } } } diff --git a/Items/Accessories/VeneratedLocket.cs b/Items/Accessories/VeneratedLocket.cs index 6be445c5ee..0f8e1ef708 100644 --- a/Items/Accessories/VeneratedLocket.cs +++ b/Items/Accessories/VeneratedLocket.cs @@ -1,6 +1,5 @@ using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -12,8 +11,8 @@ namespace CalamityMod.Items.Accessories { Item.width = 50; Item.height = 58; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.value = Item.buyPrice(platinum: 10); // Sold by Bandit + Item.rare = ModContent.RarityType(); Item.accessory = true; } diff --git a/Items/Accessories/ViciousTonic.cs b/Items/Accessories/ViciousTonic.cs new file mode 100644 index 0000000000..70908f43dd --- /dev/null +++ b/Items/Accessories/ViciousTonic.cs @@ -0,0 +1,39 @@ +using CalamityMod.Buffs.DamageOverTime; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class ViciousTonic : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public override void SetDefaults() + { + Item.width = 20; + Item.height = 20; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.buffImmune[ModContent.BuffType()] = true; + if (player.ZoneCrimson) + { + player.statDefense += 6; + player.endurance += 0.04f; + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.ViciousPowder, 15). + AddIngredient(ItemID.Vertebrae, 10). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/CrimsonFlask.png b/Items/Accessories/ViciousTonic.png similarity index 100% rename from Items/Accessories/CrimsonFlask.png rename to Items/Accessories/ViciousTonic.png diff --git a/Items/Accessories/VoidofCalamity.cs b/Items/Accessories/VoidofCalamity.cs index adbefc4037..7289ae6af2 100644 --- a/Items/Accessories/VoidofCalamity.cs +++ b/Items/Accessories/VoidofCalamity.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ID; @@ -18,6 +17,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/VoidofExtinction.cs b/Items/Accessories/VoidofExtinction.cs index a0bf58d13f..7be242b9da 100644 --- a/Items/Accessories/VoidofExtinction.cs +++ b/Items/Accessories/VoidofExtinction.cs @@ -1,10 +1,8 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -12,10 +10,10 @@ namespace CalamityMod.Items.Accessories public class VoidofExtinction : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public const int FireProjectiles = 2; - public const float FireAngleSpread = 120; - public int FireCountdown = 0; - public static int VoidExploDamage = 150; + + public static int CritBoost = 13; + public static int VoidExploDamage = 40; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(CritBoost, Abaddon.BrimstoneFlamesReduction.ToPercent()); public override void SetDefaults() { @@ -41,7 +39,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.voidOfExtinction = true; modPlayer.abaddon = true; - player.GetCritChance() += 13; + player.GetCritChance() += CritBoost; } } diff --git a/Items/Accessories/WarbanneroftheRighteous.cs b/Items/Accessories/WarbanneroftheRighteous.cs index cfc15ce1ec..60899e5cd8 100644 --- a/Items/Accessories/WarbanneroftheRighteous.cs +++ b/Items/Accessories/WarbanneroftheRighteous.cs @@ -1,16 +1,11 @@ using System; -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Mono.Cecil; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -26,8 +21,8 @@ namespace CalamityMod.Items.Accessories public class WarbanneroftheRighteous : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - internal const float MaxBonus = 0.8f; - internal const float MaxDistance = 350f; + internal const float MaxBonus = 0.3f; + internal const float MaxDistance = 700f; public override void SetStaticDefaults() { @@ -42,6 +37,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; Item.accessory = true; + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -57,22 +53,15 @@ namespace CalamityMod.Items.Accessories } int maxValue = (int)(MaxBonus * 100); - float bonus = CalculateBonus(player) - 0.6f; - float displayBonus = (int)((bonus + 0.6f) * 100); // Should range from 0 to the maxValue + float bonus = CalculateBonus(player) - 0.15f; + float displayBonus = (int)((bonus + 0.15f) * 100); // Should range from 0 to the maxValue if (player.Calamity().cooldowns.TryGetValue(WarbanneroftheRighteousBuff.ID, out var cooldown)) - { cooldown.timeLeft = maxValue - (int)displayBonus; - } else - { player.AddCooldown(WarbanneroftheRighteousBuff.ID, maxValue); - } - if (bonus > 0) - player.GetDamage() += bonus; - else - player.GetDamage() += bonus; + player.Calamity().warbannerDamageMult = bonus; int targetCount = 0; foreach (NPC npc in Main.ActiveNPCs) // More targets gradually reduces the burn damage for ALL targets @@ -83,10 +72,10 @@ namespace CalamityMod.Items.Accessories for (int index = 0; index < Main.npc.Length; index++) { NPC nPC = Main.npc[index]; - float generousHitboxWidth = Math.Max(nPC.Hitbox.Width / 2f, nPC.Hitbox.Height / 2f) + (100 + 80 * Utils.GetLerpValue(0, 200, Math.Max(nPC.Hitbox.Width / 2f, nPC.Hitbox.Height / 2f))); // Adds some room so max bonus isnt when you're ON the hitbox + float generousHitboxWidth = Math.Max(nPC.Hitbox.Width / 2f, nPC.Hitbox.Height / 2f) + 100; // Adds some room so max bonus isnt when you're ON the hitbox float intensity = Utils.Remap(Utils.Distance(player.Center, nPC.Center), MaxDistance + generousHitboxWidth, generousHitboxWidth, 1, 3, true); // We have to have this seperate from bonus, otherwise all effected enemies take damage based on the closest enemy - if (Utils.Distance(nPC.Center, player.Center) < MaxDistance + generousHitboxWidth && (nPC.IsAnEnemy(true, true, false) || nPC.type == ModContent.NPCType()) && nPC.CanBeChasedBy()) + if (Utils.Distance(nPC.Center, player.Center) < MaxDistance + generousHitboxWidth && (nPC.IsAnEnemy(true, true, false) || nPC.type == ModContent.NPCType()) && !nPC.dontTakeDamage) { float minDamageMult = 0.35f; int maxTargets = 25; @@ -98,16 +87,16 @@ namespace CalamityMod.Items.Accessories { modNPC.warbannerBurnDirection = Utils.DirectionTo(player.Center, nPC.Center); modNPC.warbannerBurnMarked = true; - modNPC.warbannerBurnTimer = 2; + modNPC.warbannerBurnTimer = 180; } if (modNPC.warbannerBurnMarked) { modNPC.warbannerBurnIntensity = intensity; modNPC.warbannerBurnDirection = Utils.DirectionTo(player.Center, nPC.Center); - int burnDamage = (int)player.GetBestClassDamage().ApplyTo(47 * damageMult); // There is up to a 3x multiplier on this damage depending on distance from the enemy + int burnDamage = (int)player.GetBestClassDamage().ApplyTo(15 * damageMult); // There is up to a 3x multiplier on this damage depending on distance from the enemy modNPC.warbannerBurnDamage = burnDamage; modNPC.warbannerBurnStacks++; - modNPC.warbannerBurnTimer++; + modNPC.warbannerBurnTimer = 180; modNPC.warbannerBurnHideEffects = hideVisual; } } @@ -121,7 +110,7 @@ namespace CalamityMod.Items.Accessories NPC closestTarget = player.Center.ClosestNPCAt(MaxDistance * 7); // extra range is to account for bonus range from massive targets if (closestTarget != null) { - float generousHitboxWidth = Math.Max(closestTarget.Hitbox.Width / 2f, closestTarget.Hitbox.Height / 2f) + (100 + 80 * Utils.GetLerpValue(0, 200, Math.Max(closestTarget.Hitbox.Width / 2f, closestTarget.Hitbox.Height / 2f))); // Adds some room so max bonus isnt when you're ON the hitbox + float generousHitboxWidth = Math.Max(closestTarget.Hitbox.Width / 2f, closestTarget.Hitbox.Height / 2f) + 100; // Adds some room so max bonus isnt when you're ON the hitbox bonus = Utils.Remap(Utils.Distance(player.Center, closestTarget.Center), MaxDistance + generousHitboxWidth, generousHitboxWidth, 0, MaxBonus, true); } else diff --git a/Items/Accessories/WifeinaBottle.cs b/Items/Accessories/WifeinaBottle.cs deleted file mode 100644 index 9a6e0d1919..0000000000 --- a/Items/Accessories/WifeinaBottle.cs +++ /dev/null @@ -1,60 +0,0 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class WifeinaBottle : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public const int ElementalDamage = 45; - - public override void SetDefaults() - { - Item.width = 20; - Item.height = 26; - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; - Item.accessory = true; - } - - public override bool CanEquipAccessory(Player player, int slot, bool modded) => !player.Calamity().elementalHeart; - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.sandWaifu = true; - SpawnElemental(player); - } - - public override void UpdateVanity(Player player) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.sandWaifuVanity = true; - SpawnElemental(player); - } - - public void SpawnElemental(Player player) - { - if (player.whoAmI == Main.myPlayer) - { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - int damage = (int)player.GetTotalDamage().ApplyTo(ElementalDamage); - - var p = Projectile.NewProjectileDirect(player.GetSource_Accessory(Item), player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer); - p.originalDamage = ElementalDamage; - } - } - } - } -} diff --git a/Items/Accessories/WifeinaBottlewithBoobs.cs b/Items/Accessories/WifeinaBottlewithBoobs.cs deleted file mode 100644 index 9c07ecc7ef..0000000000 --- a/Items/Accessories/WifeinaBottlewithBoobs.cs +++ /dev/null @@ -1,82 +0,0 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class WifeinaBottlewithBoobs : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - - // Hold on... isn't this the HEALER elemental?? - public static int ElementalDamage = 45; - - public override void SetDefaults() - { - Item.width = 20; - Item.height = 26; - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; - Item.accessory = true; - } - - public override bool CanEquipAccessory(Player player, int slot, bool modded) - { - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.elementalHeart) - { - return false; - } - return true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.sandBoobWaifu = true; - if (player.whoAmI == Main.myPlayer) - { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - var source = player.GetSource_Accessory(Item); - int damage = (int)player.GetTotalDamage().ApplyTo(ElementalDamage); - - Projectile sandy = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); - sandy.originalDamage = ElementalDamage; - } - } - } - - public override void UpdateVanity(Player player) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.sandBoobWaifuVanity = true; - if (player.whoAmI == Main.myPlayer) - { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - var source = player.GetSource_Accessory(Item); - - // 08DEC2023: Ozzatron: Rare Sand Elementals spawned with... Hold on a second. Why the fuck are we doing damage calculations when the accessory is in vanity?! - int damage = (int)player.GetTotalDamage().ApplyTo(ElementalDamage); - - Projectile sandy = Projectile.NewProjectileDirect(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer, 0f, 0f); - sandy.originalDamage = ElementalDamage; - } - } - } - } -} diff --git a/Items/Accessories/Wings/AureateBooster.cs b/Items/Accessories/Wings/AureateBooster.cs index d9ac581d6b..b2f0dce8a1 100644 --- a/Items/Accessories/Wings/AureateBooster.cs +++ b/Items/Accessories/Wings/AureateBooster.cs @@ -19,6 +19,10 @@ namespace CalamityMod.Items.Accessories.Wings public override float MaxAscentSpeed => 2.5f; public override float BaseAscent => 0.125f; + // How powerful the acceleration increase is while pressing UP + // This also affects the flight time tick rate + public static float BoostPower = 1.5f; + public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(120, 8f, 1.5f); public override void SetDefaults() @@ -32,6 +36,8 @@ namespace CalamityMod.Items.Accessories.Wings public override void UpdateAccessory(Player player, bool hideVisual) { + player.DisableWingFlapSound(); + if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { player.rocketDelay2--; @@ -81,7 +87,19 @@ namespace CalamityMod.Items.Accessories.Wings } } } - player.noFallDmg = true; + } + + public override void AdditionalFlightMovement(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) + { + if (player.TryingToHoverUp) + { + ascentWhenFalling *= BoostPower; + ascentWhenRising *= BoostPower; + maxCanAscendMultiplier *= BoostPower; + maxAscentMultiplier *= BoostPower; + constantAscend *= BoostPower; + player.wingTime -= BoostPower - 1f; + } } public override void AddRecipes() diff --git a/Items/Accessories/Wings/BaseWings.cs b/Items/Accessories/Wings/BaseWings.cs index 0526175386..780b9224f3 100644 --- a/Items/Accessories/Wings/BaseWings.cs +++ b/Items/Accessories/Wings/BaseWings.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Text; using CalamityMod.Balancing; -using Microsoft.Xna.Framework.Input; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -51,16 +50,33 @@ namespace CalamityMod.Items.Accessories.Wings public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { + if (Item.wingSlot == -1) return; ascentWhenFalling = BonusAscentWhileFalling; ascentWhenRising = BonusAscentWhileRising; maxCanAscendMultiplier = RisingSpeedThreshold; maxAscentMultiplier = MaxAscentSpeed; constantAscend = BaseAscent; + + AdditionalFlightMovement(player, ref ascentWhenFalling, ref ascentWhenRising, ref maxCanAscendMultiplier, ref maxAscentMultiplier, ref constantAscend); } + /// + /// Addition for any deviations in regular wing movement.
+ /// This is typically for UP boost or hovers. + ///
+ public virtual void AdditionalFlightMovement(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { } + public override void ModifyTooltips(List list) { - WingStats stats = ArmorIDs.Wing.Sets.Stats[Item.wingSlot]; + if (Item.wingSlot == -1) return; + WingStats stats = new(); + if (Item.type == ModContent.ItemType()) + stats = ArmorIDs.Wing.Sets.Stats[MoonWalkers.wingSlot]; + else if (Item.type == ModContent.ItemType()) + stats = ArmorIDs.Wing.Sets.Stats[VoidStriders.wingSlot]; + else if (Item.type == ModContent.ItemType()) + stats = ArmorIDs.Wing.Sets.Stats[SeraphTracers.wingSlot]; + else stats = ArmorIDs.Wing.Sets.Stats[Item.wingSlot]; int time = stats.FlyTime; float run = stats.AccRunSpeedOverride; float rAcc = stats.AccRunAccelerationMult * 0.08f; @@ -72,11 +88,11 @@ namespace CalamityMod.Items.Accessories.Wings sb.Append('\n'); sb.Append(CalamityUtils.GetText($"Common.WingStats").Format(time.FramesToSeconds(), run.ToMph(), (MaxAscentSpeed * baseJumpSpeed).ToMph())); sb.Append('\n'); - if (Main.keyState.IsKeyDown(Keys.LeftShift)) + if (Main.keyState.PressingShift()) { sb.Append(CalamityUtils.GetText($"Common.WingStatsAcceleration").Format(rAcc.ToMphps(), BaseAscent.ToMphps(), (BaseAscent + BonusAscentWhileRising).ToMphps(), (RisingSpeedThreshold * baseJumpSpeed).ToMph(), - (BaseAscent + BonusAscentWhileRising + BonusAscentWhileFalling).ToMphps())); + (BaseAscent + BonusAscentWhileFalling).ToMphps())); if (hover) { sb.Append('\n'); diff --git a/Items/Accessories/Wings/DrewsWings.cs b/Items/Accessories/Wings/DrewsWings.cs deleted file mode 100644 index f9ab4abe57..0000000000 --- a/Items/Accessories/Wings/DrewsWings.cs +++ /dev/null @@ -1,52 +0,0 @@ -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories.Wings -{ - [AutoloadEquip(EquipType.Wings)] - public class DrewsWings : BaseWings - { - public override float BonusAscentWhileFalling => 1f; - public override float BonusAscentWhileRising => 0.17f; - public override float RisingSpeedThreshold => 1.2f; - public override float MaxAscentSpeed => 3.25f; - public override float BaseAscent => 0.15f; - - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(361, 11.5f, 2.9f); - - public override void SetDefaults() - { - base.SetDefaults(); - Item.width = 22; - Item.height = 20; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) - { - int dustXOffset = 4; - if (player.direction == 1) - { - dustXOffset = -40; - } - int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, DustID.GemDiamond, 0f, 0f, 100, default, 2.4f); - Main.dust[flightDust].noGravity = true; - Main.dust[flightDust].velocity *= 0.3f; - if (Main.rand.NextBool(10)) - { - Main.dust[flightDust].fadeIn = 2f; - } - Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); - } - player.noFallDmg = true; - } - } -} diff --git a/Items/Accessories/Wings/DrewsWings.png b/Items/Accessories/Wings/DrewsWings.png deleted file mode 100644 index bd8707e1c3..0000000000 Binary files a/Items/Accessories/Wings/DrewsWings.png and /dev/null differ diff --git a/Items/Accessories/Wings/DrewsWings_Wings.png b/Items/Accessories/Wings/DrewsWings_Wings.png deleted file mode 100644 index 131487a6d7..0000000000 Binary files a/Items/Accessories/Wings/DrewsWings_Wings.png and /dev/null differ diff --git a/Items/Accessories/Wings/ElysianWings.cs b/Items/Accessories/Wings/ElysianWings.cs index fde3249493..6c0a213294 100644 --- a/Items/Accessories/Wings/ElysianWings.cs +++ b/Items/Accessories/Wings/ElysianWings.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Particles; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -14,13 +12,13 @@ namespace CalamityMod.Items.Accessories.Wings [AutoloadEquip(EquipType.Wings)] public class ElysianWings : BaseWings { - public override float BonusAscentWhileFalling => 0.85f; - public override float BonusAscentWhileRising => 0.15f; - public override float RisingSpeedThreshold => 1f; + public override float BonusAscentWhileFalling => 1f; + public override float BonusAscentWhileRising => 0.17f; + public override float RisingSpeedThreshold => 1.2f; public override float MaxAscentSpeed => 3f; - public override float BaseAscent => 0.135f; + public override float BaseAscent => 0.15f; - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(240, 9.5f, 2.7f); + public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(240, 10f, 3f); public override void SetDefaults() { @@ -35,12 +33,6 @@ namespace CalamityMod.Items.Accessories.Wings public override void UpdateAccessory(Player player, bool hideVisual) { - CalamityPlayer modPlayer = player.Calamity(); - player.moveSpeed += 0.1f; - player.lavaImmune = true; - player.noFallDmg = true; - modPlayer.elysianWingsDust = false; - if (!hideVisual) DrawWingEffects(player); } diff --git a/Items/Accessories/Wings/ExodusWings.cs b/Items/Accessories/Wings/ExodusWings.cs index 0401431942..015f195b2d 100644 --- a/Items/Accessories/Wings/ExodusWings.cs +++ b/Items/Accessories/Wings/ExodusWings.cs @@ -6,7 +6,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -72,7 +71,6 @@ namespace CalamityMod.Items.Accessories.Wings } player.wingTimeMax = 180; - player.noFallDmg = true; } public override void AddRecipes() diff --git a/Items/Accessories/Wings/HadalMantle.cs b/Items/Accessories/Wings/HadalMantle.cs index a9d0f3958a..23778456c2 100644 --- a/Items/Accessories/Wings/HadalMantle.cs +++ b/Items/Accessories/Wings/HadalMantle.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Armor.Hydrothermic; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -13,13 +12,13 @@ namespace CalamityMod.Items.Accessories.Wings [LegacyName("DiscordianWings")] public class HadalMantle : BaseWings { - public override float BonusAscentWhileFalling => 0.6f; - public override float BonusAscentWhileRising => 0.12f; - public override float RisingSpeedThreshold => 0.7f; - public override float MaxAscentSpeed => 1.75f; - public override float BaseAscent => 0.11f; + public override float BonusAscentWhileFalling => 0.75f; + public override float BonusAscentWhileRising => 0.15f; + public override float RisingSpeedThreshold => 1f; + public override float MaxAscentSpeed => 1.805f; + public override float BaseAscent => 0.125f; - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(180, 7.75f, 1.5f); + public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(150, 8f, 2f); public override void SetDefaults() { @@ -48,7 +47,6 @@ namespace CalamityMod.Items.Accessories.Wings } Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } - player.noFallDmg = true; } public override void AddRecipes() diff --git a/Items/Accessories/Wings/HadarianWings.cs b/Items/Accessories/Wings/HadarianWings.cs index e75b85cba5..4cf304b5c3 100644 --- a/Items/Accessories/Wings/HadarianWings.cs +++ b/Items/Accessories/Wings/HadarianWings.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -14,12 +12,12 @@ namespace CalamityMod.Items.Accessories.Wings public class HadarianWings : BaseWings { public override float BonusAscentWhileFalling => 0.8f; - public override float BonusAscentWhileRising => 0.155f; - public override float RisingSpeedThreshold => 1.05f; - public override float MaxAscentSpeed => 2.55f; - public override float BaseAscent => 0.13f; + public override float BonusAscentWhileRising => 0.15f; + public override float RisingSpeedThreshold => 1f; + public override float MaxAscentSpeed => 2f; + public override float BaseAscent => 0.135f; - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(90, 9f, 1.75f, true, 11.6f, 11.6f); + public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(108, 9f, 2f, true, 11.6f, 11.6f); public override void SetDefaults() { @@ -34,18 +32,6 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0) { - bool hovering = player.TryingToHoverDown && !player.merman; - if (hovering) - { - player.velocity.Y *= 0.2f; - if (player.velocity.Y > -2f && player.velocity.Y < 2f) - { - // I can't get the player to have zero y velocity (setting it to 0 doesn't work and I tried a lot of numbers) - player.velocity.Y = 0.105f; - } - player.wingTime += 0.75f; - } - if (player.velocity.Y != 0f && !hideVisual) { float xOffset = 4f; @@ -53,7 +39,7 @@ namespace CalamityMod.Items.Accessories.Wings { xOffset = -40f; } - if (!hovering || Main.rand.NextBool(3)) + if (!player.TryingToHoverDown || Main.rand.NextBool(3)) { int idx = Dust.NewDust(new Vector2(player.Center.X + xOffset, player.Center.Y - 15f), 30, 30, ModContent.DustType(), 0f, 0f, 100, default, 1.75f); Main.dust[idx].noGravity = true; @@ -66,7 +52,21 @@ namespace CalamityMod.Items.Accessories.Wings } } } - player.noFallDmg = true; + } + + public override void AdditionalFlightMovement(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) + { + if (player.TryingToHoverDown && player.controlJump && player.wingTime > 0f && !player.merman) + { + player.wingTime += 0.5f; + player.velocity.Y *= 0.8f; + if (player.velocity.Y > -2f && player.velocity.Y < 1f) + player.velocity.Y = 1E-05f; + + ascentWhenFalling *= 0f; + ascentWhenRising *= 0f; + constantAscend *= 0f; + } } } } diff --git a/Items/Accessories/Wings/MOAB.cs b/Items/Accessories/Wings/MOAB.cs index 904c7565bc..4603a286db 100644 --- a/Items/Accessories/Wings/MOAB.cs +++ b/Items/Accessories/Wings/MOAB.cs @@ -1,10 +1,14 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using System.IO; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Accessories.Wings { @@ -17,7 +21,15 @@ namespace CalamityMod.Items.Accessories.Wings public override float MaxAscentSpeed => 2.5f; public override float BaseAscent => 0.125f; - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(75, 6.5f, 1f); + public static int wingSlot = 0; + // How powerful the acceleration increase is while pressing UP + // This also affects the flight time tick rate + public static float BoostPower = 2f; + public override void SetStaticDefaults() + { + ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(75, 6.5f, 1f); + wingSlot = Item.wingSlot; + } public override void SetDefaults() { @@ -27,10 +39,59 @@ namespace CalamityMod.Items.Accessories.Wings Item.value = CalamityGlobalItem.RarityLightPurpleBuyPrice; Item.rare = ItemRarityID.LightPurple; } + #region Toggleable Wings + bool toggleEnabled + { + get { return Item.wingSlot != -1; } + set + { + if (value) + Item.wingSlot = wingSlot; + else + Item.wingSlot = -1; + } + } + public override void ModifyTooltips(List tooltips) + { + if (!toggleEnabled) + tooltips.RemoveAll(x => x.Name == "Tooltip0"); + base.ModifyTooltips(tooltips); + } + + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + toggleEnabled = !toggleEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("toggleEffect", toggleEnabled); + } + public override void LoadData(TagCompound tag) + { + toggleEnabled = tag.GetBool("toggleEffect"); + } + public override void NetSend(BinaryWriter writer) + { + writer.Write(toggleEnabled); + } + public override void NetReceive(BinaryReader reader) + { + toggleEnabled = reader.ReadBoolean(); + } + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled); + } + #endregion public override void UpdateAccessory(Player player, bool hideVisual) { - if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) + player.DisableWingFlapSound(); + + if (toggleEnabled && player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { player.rocketDelay2--; if (player.rocketDelay2 <= 0) @@ -90,13 +151,25 @@ namespace CalamityMod.Items.Accessories.Wings player.GetJumpState(ExtraJump.BlizzardInABottle).Enable(); player.jumpBoost = true; player.autoJump = true; - player.noFallDmg = true; player.jumpSpeedBoost += 1.6f; // Mirrors the +5% luck from Lucky Horseshoe (vanilla behavior). player.Calamity().calamityBonusLuck += 0.05f; } + public override void AdditionalFlightMovement(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) + { + if (player.TryingToHoverUp) + { + ascentWhenFalling *= BoostPower; + ascentWhenRising *= BoostPower; + maxCanAscendMultiplier *= BoostPower; + maxAscentMultiplier *= BoostPower; + constantAscend *= BoostPower; + player.wingTime -= BoostPower - 1f; + } + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/Wings/MOAB.png b/Items/Accessories/Wings/MOAB.png index ecafba2594..742a5ede38 100644 Binary files a/Items/Accessories/Wings/MOAB.png and b/Items/Accessories/Wings/MOAB.png differ diff --git a/Items/Accessories/Wings/MoonWalkers.cs b/Items/Accessories/Wings/MoonWalkers.cs new file mode 100644 index 0000000000..7915738b80 --- /dev/null +++ b/Items/Accessories/Wings/MoonWalkers.cs @@ -0,0 +1,154 @@ +using System.Collections.Generic; +using System.IO; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Items.Accessories.Wings +{ + [AutoloadEquip(EquipType.Wings, EquipType.Shoes)] + [LegacyName("InfinityBoots", "TracersCelestial")] + public class MoonWalkers : BaseWings + { + public override float BonusAscentWhileFalling => 0.75f; + public override float BonusAscentWhileRising => 0.15f; + public override float RisingSpeedThreshold => 1f; + public override float MaxAscentSpeed => 2.5f; + public override float BaseAscent => 0.125f; + + public static int wingSlot = 0; + + public override void SetStaticDefaults() { + ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(160, 9f, 2.6f); + wingSlot = Item.wingSlot; + } + + public override void SetDefaults() + { + base.SetDefaults(); + Item.width = 36; + Item.height = 40; + Item.value = CalamityGlobalItem.RarityRedBuyPrice; + Item.rare = ItemRarityID.Red; + } + #region Toggleable Wings + bool toggleEnabled + { + get { return Item.wingSlot != -1; } + set + { + if (value) + Item.wingSlot = wingSlot; + else + Item.wingSlot = -1; + } + } + public override void ModifyTooltips(List tooltips) + { + if (!toggleEnabled) + tooltips.RemoveAll(x => x.Name == "Tooltip0"); + base.ModifyTooltips(tooltips); + } + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + toggleEnabled = !toggleEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("toggleEffect", toggleEnabled); + } + public override void LoadData(TagCompound tag) + { + toggleEnabled = tag.GetBool("toggleEffect"); + } + public override void NetSend(BinaryWriter writer) + { + writer.Write(toggleEnabled); + } + public override void NetReceive(BinaryReader reader) + { + toggleEnabled = reader.ReadBoolean(); + } + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Item.SetNameOverride(CalamityUtils.GetTextValue($"Items.Accessories.Wings.MoonWalkers.{(toggleEnabled ? "DisplayName" : "TreadsName")}")); + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled); + } + public override void UpdateInventory(Player player) + { + } + #endregion + public override void UpdateAccessory(Player player, bool hideVisual) + { + if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual && toggleEnabled) + { + int dustXOffset = 4; + if (player.direction == 1) + { + dustXOffset = -40; + } + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, DustID.TerraBlade, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; + if (Main.rand.NextBool(10)) + { + Main.dust[flightDust].fadeIn = 2f; + } + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + } + CalamityPlayer modPlayer = player.Calamity(); + player.accRunSpeed = 8f; + player.moveSpeed += 0.14f; + player.iceSkate = true; + player.waterWalk = true; + player.fireWalk = true; + player.lavaImmune = true; + player.buffImmune[BuffID.OnFire] = true; + player.noFallDmg = true; + if (!toggleEnabled) //Both these effects just boost flight time, but we don't want Tracers to boost it's own flight time when functioning as wings. All other Angel Tread effects are covered above. + { + player.rocketBoots = player.vanityRocketBoots = 4; + modPlayer.angelTreads = true; + } + modPlayer.tracersDust = !hideVisual && toggleEnabled; + modPlayer.moonWalkers = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(ItemID.SoulofFlight,20). + AddIngredient(ItemID.LunarBar, 5). + AddTile(TileID.LunarCraftingStation). + Register(); + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + var tex = TextureAssets.Item[Type].Value; + frame = tex.Frame(2, 1, toggleEnabled ? 0 : 1); + spriteBatch.Draw(tex, position, frame, Color.White, 0, frame.Size() * 0.5f, Main.inventoryScale * 0.8f, SpriteEffects.None, 0); + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + + var tex = TextureAssets.Item[Type].Value; + var frame = tex.Frame(2, 1, toggleEnabled ? 0 : 1); + spriteBatch.Draw(tex, Item.Center - Main.screenPosition, frame, lightColor, rotation, frame.Size() * 0.5f, scale, SpriteEffects.None, 0); + return false; + } + } +} diff --git a/Items/Accessories/Wings/MoonWalkers.png b/Items/Accessories/Wings/MoonWalkers.png new file mode 100644 index 0000000000..ccb6df8508 Binary files /dev/null and b/Items/Accessories/Wings/MoonWalkers.png differ diff --git a/Items/Accessories/Wings/TracersCelestial_Shoes.png b/Items/Accessories/Wings/MoonWalkers_Shoes.png similarity index 100% rename from Items/Accessories/Wings/TracersCelestial_Shoes.png rename to Items/Accessories/Wings/MoonWalkers_Shoes.png diff --git a/Items/Accessories/Wings/MoonWalkers_Wings.png b/Items/Accessories/Wings/MoonWalkers_Wings.png new file mode 100644 index 0000000000..e19d9343bb Binary files /dev/null and b/Items/Accessories/Wings/MoonWalkers_Wings.png differ diff --git a/Items/Accessories/Wings/SeraphTracers.cs b/Items/Accessories/Wings/SeraphTracers.cs new file mode 100644 index 0000000000..4d712708e9 --- /dev/null +++ b/Items/Accessories/Wings/SeraphTracers.cs @@ -0,0 +1,137 @@ +using System.Collections.Generic; +using System.IO; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Items.Accessories.Wings +{ + [AutoloadEquip(EquipType.Wings)] + [LegacyName("CelestialTracers", "TracersSeraph")] + public class SeraphTracers : BaseWings + { + public override float BonusAscentWhileFalling => 0.95f; + public override float BonusAscentWhileRising => 0.16f; + public override float RisingSpeedThreshold => 1.2f; + public override float MaxAscentSpeed => 2.9f; + public override float BaseAscent => 0.145f; + + public static int wingSlot = 0; + + public override void SetStaticDefaults() + { + ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(250, 11f, 2.8f); + wingSlot = Item.wingSlot; + } + public override void SetDefaults() + { + base.SetDefaults(); + Item.width = 36; + Item.height = 32; + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.rare = ModContent.RarityType(); + } + #region Toggleable Wings + bool toggleEnabled + { + get { return Item.wingSlot != -1; } + set + { + if (value) + Item.wingSlot = wingSlot; + else + Item.wingSlot = -1; + } + } + public override void ModifyTooltips(List tooltips) + { + if (!toggleEnabled) + tooltips.RemoveAll(x => x.Name == "Tooltip0"); + base.ModifyTooltips(tooltips); + } + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + toggleEnabled = !toggleEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("toggleEffect", toggleEnabled); + } + public override void LoadData(TagCompound tag) + { + toggleEnabled = tag.GetBool("toggleEffect"); + } + public override void NetSend(BinaryWriter writer) + { + writer.Write(toggleEnabled); + } + public override void NetReceive(BinaryReader reader) + { + toggleEnabled = reader.ReadBoolean(); + } + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Item.SetNameOverride(CalamityUtils.GetTextValue($"Items.Accessories.Wings.SeraphTracers.{(toggleEnabled ? "DisplayName" : "TreadsName")}")); + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled); + } + #endregion + + public override void UpdateAccessory(Player player, bool hideVisual) + { + if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual && toggleEnabled) + { + int dustXOffset = 4; + if (player.direction == 1) + { + dustXOffset = -40; + } + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, DustID.GemDiamond, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; + if (Main.rand.NextBool(10)) + { + Main.dust[flightDust].fadeIn = 2f; + } + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + } + CalamityPlayer modPlayer = player.Calamity(); + player.accRunSpeed = 9f; + player.moveSpeed += 0.18f; + player.iceSkate = true; + player.waterWalk = true; + player.fireWalk = true; + player.lavaImmune = true; + player.buffImmune[BuffID.OnFire] = true; + player.noFallDmg = true; + if (!toggleEnabled) //Both these effects just boost flight time, but we don't want Tracers to boost it's own flight time when functioning as wings. All other Angel Tread effects are covered above. + { + player.rocketBoots = player.vanityRocketBoots = 2; + modPlayer.angelTreads = true; + } + modPlayer.tracersDust = !hideVisual && toggleEnabled; + modPlayer.seraphTracers = true; // Grants immunity to Auric Rejection and other walk-on-block effects + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(5). + AddIngredient(3). + AddTile(). + Register(); + } + } +} diff --git a/Items/Accessories/Wings/SeraphTracers.png b/Items/Accessories/Wings/SeraphTracers.png new file mode 100644 index 0000000000..3d36a37708 Binary files /dev/null and b/Items/Accessories/Wings/SeraphTracers.png differ diff --git a/Items/Accessories/Wings/TracersSeraph_Wings.png b/Items/Accessories/Wings/SeraphTracers_Wings.png similarity index 100% rename from Items/Accessories/Wings/TracersSeraph_Wings.png rename to Items/Accessories/Wings/SeraphTracers_Wings.png diff --git a/Items/Accessories/Wings/SilvaWings.cs b/Items/Accessories/Wings/SilvaWings.cs index 0a7fefdd0f..ef7f77b57e 100644 --- a/Items/Accessories/Wings/SilvaWings.cs +++ b/Items/Accessories/Wings/SilvaWings.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Armor.Silva; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -21,8 +20,6 @@ namespace CalamityMod.Items.Accessories.Wings public override float MaxAscentSpeed => 3.2f; public override float BaseAscent => 0.145f; - public const int LifeRegenTimerMax = 900; - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(270, 10.5f, 2.8f); public override void SetDefaults() @@ -31,13 +28,11 @@ namespace CalamityMod.Items.Accessories.Wings Item.width = 22; Item.height = 20; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UpdateAccessory(Player player, bool hideVisual) { - player.Calamity().silvaWings = true; - if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { int dustXOffset = 4; @@ -54,7 +49,6 @@ namespace CalamityMod.Items.Accessories.Wings } Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } - player.noFallDmg = true; } public override void AddRecipes() diff --git a/Items/Accessories/Wings/SkylineWings.cs b/Items/Accessories/Wings/SkylineWings.cs index 0c29d76343..cd56fbaa3f 100644 --- a/Items/Accessories/Wings/SkylineWings.cs +++ b/Items/Accessories/Wings/SkylineWings.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -20,11 +19,6 @@ namespace CalamityMod.Items.Accessories.Wings Item.rare = ItemRarityID.Orange; } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.noFallDmg = true; - } - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Accessories/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index 9d4219fac8..310123dc78 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -29,6 +28,7 @@ namespace CalamityMod.Items.Accessories.Wings Item.height = 26; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; + Item.expert = true; } public override void Update(ref float gravity, ref float maxFallSpeed) @@ -42,7 +42,6 @@ namespace CalamityMod.Items.Accessories.Wings { CalamityPlayer modPlayer = player.Calamity(); modPlayer.cryogenSoul = true; - player.noFallDmg = true; if (modPlayer.wingProjectileCooldown <= 0) { if (player.controlJump && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) diff --git a/Items/Accessories/Wings/StarlightWings.cs b/Items/Accessories/Wings/StarlightWings.cs index 472dab84a3..b255d4609c 100644 --- a/Items/Accessories/Wings/StarlightWings.cs +++ b/Items/Accessories/Wings/StarlightWings.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Armor.Daedalus; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -41,7 +40,6 @@ namespace CalamityMod.Items.Accessories.Wings } Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } - player.noFallDmg = true; } public override void AddRecipes() diff --git a/Items/Accessories/Wings/TarragonWings.cs b/Items/Accessories/Wings/TarragonWings.cs index 7692df6166..7a1d17a559 100644 --- a/Items/Accessories/Wings/TarragonWings.cs +++ b/Items/Accessories/Wings/TarragonWings.cs @@ -1,5 +1,4 @@ using CalamityMod.Dusts; -using CalamityMod.Items.Armor.Tarragon; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Accessories.Wings public override float MaxAscentSpeed => 3f; public override float BaseAscent => 0.135f; - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(250, 9.5f, 2.5f); + public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(270, 9.5f, 2.5f); public override void SetDefaults() { @@ -33,9 +32,6 @@ namespace CalamityMod.Items.Accessories.Wings public override void UpdateAccessory(Player player, bool hideVisual) { - player.statDefense += 15; - player.lifeRegen += 2; - if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { int dustXOffset = 4; @@ -52,7 +48,6 @@ namespace CalamityMod.Items.Accessories.Wings } Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } - player.noFallDmg = true; } public override void AddRecipes() @@ -60,7 +55,7 @@ namespace CalamityMod.Items.Accessories.Wings CreateRecipe(). AddIngredient(ItemID.SoulofFlight, 20). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Accessories/Wings/TracersCelestial.cs b/Items/Accessories/Wings/TracersCelestial.cs deleted file mode 100644 index 2c6198dd03..0000000000 --- a/Items/Accessories/Wings/TracersCelestial.cs +++ /dev/null @@ -1,92 +0,0 @@ -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories.Wings -{ - [AutoloadEquip(EquipType.Wings, EquipType.Shoes)] - [LegacyName("InfinityBoots", "SeraphTracers")] - public class TracersCelestial : BaseWings - { - public override float BonusAscentWhileFalling => 0.75f; - public override float BonusAscentWhileRising => 0.15f; - public override float RisingSpeedThreshold => 1f; - public override float MaxAscentSpeed => 2.5f; - public override float BaseAscent => 0.125f; - - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(160, 9f, 2.6f); - - public override void SetDefaults() - { - base.SetDefaults(); - Item.width = 36; - Item.height = 32; - Item.value = CalamityGlobalItem.RarityRedBuyPrice; - Item.rare = ItemRarityID.Red; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) - { - int dustXOffset = 4; - if (player.direction == 1) - { - dustXOffset = -40; - } - int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, DustID.TerraBlade, 0f, 0f, 100, default, 2.4f); - Main.dust[flightDust].noGravity = true; - Main.dust[flightDust].velocity *= 0.3f; - if (Main.rand.NextBool(10)) - { - Main.dust[flightDust].fadeIn = 2f; - } - Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); - } - CalamityPlayer modPlayer = player.Calamity(); - player.accRunSpeed = 8f; - player.moveSpeed += 0.14f; - player.iceSkate = true; - player.waterWalk = true; - player.fireWalk = true; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; - player.noFallDmg = true; - modPlayer.tracersDust = !hideVisual; - modPlayer.tracersCelestial = true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddRecipeGroup("AnyWings"). - AddIngredient(ItemID.LunarBar, 5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - CalamityUtils.DrawInventoryCustomScale( - spriteBatch, - texture: TextureAssets.Item[Type].Value, - position, - frame, - drawColor, - itemColor, - origin, - scale, - wantedScale: 0.9f, - drawOffset: new(1f, 0f) - ); - return false; - } - } -} diff --git a/Items/Accessories/Wings/TracersCelestial.png b/Items/Accessories/Wings/TracersCelestial.png deleted file mode 100644 index ceb770eb52..0000000000 Binary files a/Items/Accessories/Wings/TracersCelestial.png and /dev/null differ diff --git a/Items/Accessories/Wings/TracersCelestial_Wings.png b/Items/Accessories/Wings/TracersCelestial_Wings.png deleted file mode 100644 index a45ea45837..0000000000 Binary files a/Items/Accessories/Wings/TracersCelestial_Wings.png and /dev/null differ diff --git a/Items/Accessories/Wings/TracersElysian.cs b/Items/Accessories/Wings/TracersElysian.cs deleted file mode 100644 index 403641dcdf..0000000000 --- a/Items/Accessories/Wings/TracersElysian.cs +++ /dev/null @@ -1,97 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories.Wings -{ - [AutoloadEquip(EquipType.Wings)] - [LegacyName("ElysianTracers")] - public class TracersElysian : BaseWings - { - public override float BonusAscentWhileFalling => 0.85f; - public override float BonusAscentWhileRising => 0.15f; - public override float RisingSpeedThreshold => 1.1f; - public override float MaxAscentSpeed => 2.7f; - public override float BaseAscent => 0.135f; - - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(220, 10f, 2.7f); - - public override void SetDefaults() - { - base.SetDefaults(); - Item.width = 36; - Item.height = 32; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) - { - int dustXOffset = 4; - if (player.direction == 1) - { - dustXOffset = -40; - } - int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, Main.rand.NextBool() ? 206 : 173, 0f, 0f, 100, default, 2.4f); - Main.dust[flightDust].noGravity = true; - Main.dust[flightDust].velocity *= 0.3f; - if (Main.rand.NextBool(10)) - { - Main.dust[flightDust].fadeIn = 2f; - } - Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); - } - CalamityPlayer modPlayer = player.Calamity(); - player.accRunSpeed = 8.5f; - player.moveSpeed += 0.16f; - player.iceSkate = true; - player.waterWalk = true; - player.fireWalk = true; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; - player.noFallDmg = true; - modPlayer.tracersDust = !hideVisual; - modPlayer.elysianWingsDust = !hideVisual; - modPlayer.tracersElysian = true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(5). - AddIngredient(4). - AddTile(). - Register(); - } - - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - CalamityUtils.DrawInventoryCustomScale( - spriteBatch, - texture: TextureAssets.Item[Type].Value, - position, - frame, - drawColor, - itemColor, - origin, - scale, - wantedScale: 0.9f, - drawOffset: new(1f, 0f) - ); - return false; - } - } -} diff --git a/Items/Accessories/Wings/TracersElysian.png b/Items/Accessories/Wings/TracersElysian.png deleted file mode 100644 index 4bb21bbcbf..0000000000 Binary files a/Items/Accessories/Wings/TracersElysian.png and /dev/null differ diff --git a/Items/Accessories/Wings/TracersSeraph.cs b/Items/Accessories/Wings/TracersSeraph.cs deleted file mode 100644 index b157d040ac..0000000000 --- a/Items/Accessories/Wings/TracersSeraph.cs +++ /dev/null @@ -1,96 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories.Wings -{ - [AutoloadEquip(EquipType.Wings)] - [LegacyName("CelestialTracers")] - public class TracersSeraph : BaseWings - { - public override float BonusAscentWhileFalling => 0.95f; - public override float BonusAscentWhileRising => 0.16f; - public override float RisingSpeedThreshold => 1.2f; - public override float MaxAscentSpeed => 2.9f; - public override float BaseAscent => 0.145f; - - public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(250, 11f, 2.8f); - - public override void SetDefaults() - { - base.SetDefaults(); - Item.width = 36; - Item.height = 32; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) - { - int dustXOffset = 4; - if (player.direction == 1) - { - dustXOffset = -40; - } - int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, DustID.GemDiamond, 0f, 0f, 100, default, 2.4f); - Main.dust[flightDust].noGravity = true; - Main.dust[flightDust].velocity *= 0.3f; - if (Main.rand.NextBool(10)) - { - Main.dust[flightDust].fadeIn = 2f; - } - Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); - } - CalamityPlayer modPlayer = player.Calamity(); - player.accRunSpeed = 9f; - player.moveSpeed += 0.18f; - player.iceSkate = true; - player.waterWalk = true; - player.fireWalk = true; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; - player.noFallDmg = true; - modPlayer.tracersDust = !hideVisual; - modPlayer.elysianWingsDust = !hideVisual; - modPlayer.tracersSeraph = true; // Grants immunity to Auric Rejection and other walk-on-block effects - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(5). - AddTile(). - Register(); - } - - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - CalamityUtils.DrawInventoryCustomScale( - spriteBatch, - texture: TextureAssets.Item[Type].Value, - position, - frame, - drawColor, - itemColor, - origin, - scale, - wantedScale: 0.8f, - drawOffset: new(1f, 0f) - ); - return false; - } - } -} diff --git a/Items/Accessories/Wings/TracersSeraph.png b/Items/Accessories/Wings/TracersSeraph.png deleted file mode 100644 index 1608a8dc7c..0000000000 Binary files a/Items/Accessories/Wings/TracersSeraph.png and /dev/null differ diff --git a/Items/Accessories/Wings/VoidStriders.cs b/Items/Accessories/Wings/VoidStriders.cs new file mode 100644 index 0000000000..5dd34f3139 --- /dev/null +++ b/Items/Accessories/Wings/VoidStriders.cs @@ -0,0 +1,140 @@ +using System.Collections.Generic; +using System.IO; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Items.Accessories.Wings +{ + [AutoloadEquip(EquipType.Wings)] + [LegacyName("ElysianTracers", "TracersElysian")] + public class VoidStriders : BaseWings + { + public override float BonusAscentWhileFalling => 0.85f; + public override float BonusAscentWhileRising => 0.15f; + public override float RisingSpeedThreshold => 1.1f; + public override float MaxAscentSpeed => 2.7f; + public override float BaseAscent => 0.135f; + + public static int wingSlot = 0; + public override void SetStaticDefaults() + { + ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(200, 10f, 2.7f); + wingSlot = Item.wingSlot; + } + + public override void SetDefaults() + { + base.SetDefaults(); + Item.width = 36; + Item.height = 32; + Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + Item.rare = ModContent.RarityType(); + } + #region Toggleable Wings + bool toggleEnabled + { + get { return Item.wingSlot != -1; } + set + { + if (value) + Item.wingSlot = wingSlot; + else + Item.wingSlot = -1; + } + } + public override void ModifyTooltips(List tooltips) + { + if (!toggleEnabled) + tooltips.RemoveAll(x => x.Name == "Tooltip0"); + base.ModifyTooltips(tooltips); + } + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + toggleEnabled = !toggleEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("toggleEffect", toggleEnabled); + } + public override void LoadData(TagCompound tag) + { + toggleEnabled = tag.GetBool("toggleEffect"); + } + public override void NetSend(BinaryWriter writer) + { + writer.Write(toggleEnabled); + } + public override void NetReceive(BinaryReader reader) + { + toggleEnabled = reader.ReadBoolean(); + } + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Item.SetNameOverride(CalamityUtils.GetTextValue($"Items.Accessories.Wings.VoidStriders.{(toggleEnabled ? "DisplayName" : "TreadsName")}")); + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled); + } + public override void UpdateInventory(Player player) + { + } + #endregion + public override void UpdateAccessory(Player player, bool hideVisual) + { + if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual && toggleEnabled) + { + int dustXOffset = 4; + if (player.direction == 1) + { + dustXOffset = -40; + } + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, Main.rand.NextBool() ? 206 : 173, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; + if (Main.rand.NextBool(10)) + { + Main.dust[flightDust].fadeIn = 2f; + } + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + } + CalamityPlayer modPlayer = player.Calamity(); + player.accRunSpeed = 8.5f; + player.moveSpeed += 0.16f; + player.iceSkate = true; + player.waterWalk = true; + player.fireWalk = true; + player.lavaImmune = true; + player.buffImmune[BuffID.OnFire] = true; + player.noFallDmg = true; + player.socialShadowRocketBoots = true; + if (!toggleEnabled) //Both these effects just boost flight time, but we don't want Tracers to boost it's own flight time when functioning as wings. All other Angel Tread effects are covered above. + { + player.rocketBoots = player.vanityRocketBoots = 1; + modPlayer.angelTreads = true; + } + modPlayer.tracersDust = !hideVisual && toggleEnabled; + modPlayer.voidStriders = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(3). + AddIngredient(3). + AddIngredient(3). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} diff --git a/Items/Accessories/Wings/VoidStriders.png b/Items/Accessories/Wings/VoidStriders.png new file mode 100644 index 0000000000..86bc3b4e8e Binary files /dev/null and b/Items/Accessories/Wings/VoidStriders.png differ diff --git a/Items/Accessories/Wings/TracersElysian_Wings.png b/Items/Accessories/Wings/VoidStriders_Wings.png similarity index 100% rename from Items/Accessories/Wings/TracersElysian_Wings.png rename to Items/Accessories/Wings/VoidStriders_Wings.png diff --git a/Items/Accessories/Wings/WingsofRebirth.cs b/Items/Accessories/Wings/WingsofRebirth.cs new file mode 100644 index 0000000000..ffa88d1934 --- /dev/null +++ b/Items/Accessories/Wings/WingsofRebirth.cs @@ -0,0 +1,92 @@ +using CalamityMod.Dusts; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories.Wings +{ + // The equip sprite is actually blank as a custom draw layer is used to draw the real sprites without any base sprites conflicting + [LegacyName("DrewsWings")] + [AutoloadEquip(EquipType.Wings)] + public class WingsofRebirth : BaseWings + { + public override float BonusAscentWhileFalling => 1f; + public override float BonusAscentWhileRising => 0.17f; + public override float RisingSpeedThreshold => 1.2f; + public override float MaxAscentSpeed => 3.25f; + public override float BaseAscent => 0.15f; + + public override void SetStaticDefaults() => ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(360, 11.5f, 2.9f); + + public override void SetDefaults() + { + base.SetDefaults(); + Item.width = 22; + Item.height = 20; + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.rare = ModContent.RarityType(); + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) + { + int dustXOffset = 4; + if (player.direction == 1) + { + dustXOffset = -40; + } + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; + if (Main.rand.NextBool(10)) + { + Main.dust[flightDust].fadeIn = 2f; + } + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + } + } + + public override bool WingUpdate(Player player, bool inUse) + { + if (player.controlJump && player.wingTime > 0 && player.velocity.Y != 0) + { + int frameRate = 5; // FPS + int maxFrames = 9; // Total frames + player.wingFrameCounter++; + // Start flight animation with frame 7 + if (player.wingFrame == 0) + { + player.wingFrame = 7; + } + // Animation + if (player.wingFrameCounter % frameRate == 0) + { + player.wingFrame++; + } + // Reset frames + if (player.wingFrame >= maxFrames) + { + player.wingFrameCounter = 0; + player.wingFrame = 1; + } + } + else + { + player.wingFrameCounter = 0; + player.wingFrame = 0; // On ground + if (player.velocity.Y != 0) + { + player.wingFrame = 2; // Falling + if (player.controlJump && player.velocity.Y > 0) + player.wingFrame = 1; // Gliding + } + } + return true; + } + } +} diff --git a/Items/Accessories/Wings/WingsofRebirth.png b/Items/Accessories/Wings/WingsofRebirth.png new file mode 100644 index 0000000000..ee575d23ab Binary files /dev/null and b/Items/Accessories/Wings/WingsofRebirth.png differ diff --git a/Items/Accessories/Wings/WingsofRebirth_Wings.png b/Items/Accessories/Wings/WingsofRebirth_Wings.png new file mode 100644 index 0000000000..08ddcaa27a Binary files /dev/null and b/Items/Accessories/Wings/WingsofRebirth_Wings.png differ diff --git a/Items/Accessories/Wings/WingsofRebirth_Wings_Real.png b/Items/Accessories/Wings/WingsofRebirth_Wings_Real.png new file mode 100644 index 0000000000..df66a0fb83 Binary files /dev/null and b/Items/Accessories/Wings/WingsofRebirth_Wings_Real.png differ diff --git a/Items/Accessories/WulfrumAcrobaticsPack.cs b/Items/Accessories/WulfrumAcrobaticsPack.cs index 9bd60529f1..b9f1911f34 100644 --- a/Items/Accessories/WulfrumAcrobaticsPack.cs +++ b/Items/Accessories/WulfrumAcrobaticsPack.cs @@ -1,14 +1,15 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using CalamityMod.DataStructures; using CalamityMod.Items.Materials; +using CalamityMod.Packets; using CalamityMod.Projectiles.Typeless; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.GameContent.UI; using Terraria.GameInput; using Terraria.ID; using Terraria.ModLoader; @@ -24,7 +25,6 @@ namespace CalamityMod.Items.Accessories public static readonly SoundStyle GrabSound = new("CalamityMod/Sounds/Custom/WulfrumHookGrapple") { Volume = 0.7f, MaxInstances = 1, SoundLimitBehavior = SoundLimitBehavior.ReplaceOldest }; public static readonly SoundStyle ReleaseSound = new("CalamityMod/Sounds/Custom/WulfrumHookDisengage") { Volume = 0.7f, MaxInstances = 1, SoundLimitBehavior = SoundLimitBehavior.ReplaceOldest }; - public override void SetDefaults() { Item.width = 20; @@ -34,21 +34,26 @@ namespace CalamityMod.Items.Accessories Item.rare = ItemRarityID.Blue; } + public override bool CanUseItem(Player player) + { + return player.TryGetModPlayer(out var mp) && mp.hookCooldown <= 0; + } + public override void UpdateAccessory(Player player, bool hideVisual) { player.moveSpeed += 0.08f; player.GetModPlayer().WulfrumPackEquipped = true; player.GetModPlayer().PackItem = Item; - + player.maxFallSpeed *= 1.25f; Lighting.AddLight(player.Center, Color.Lerp(Color.DeepSkyBlue, Color.GreenYellow, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) * 0.5f + 0.5f).ToVector3()); } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.Chain, 2). - AddIngredient(6). + AddIngredient(5). AddIngredient(). + AddIngredient(ItemID.Chain, 2). AddTile(TileID.Anvils). Register(); } @@ -74,14 +79,15 @@ namespace CalamityMod.Items.Accessories } //Prevent players with a wulfrum pack to spawn any non-wulfrum hooks. + /* public override void OnSpawn(Projectile projectile, IEntitySource source) { Player owner = Main.player[projectile.owner]; - if (projectile.aiStyle == 7 && projectile.type != ProjectileType() && owner.GetModPlayer().WulfrumPackEquipped && projectile.type != ProjectileID.TrackHook) + if (projectile.aiStyle == ProjAIStyleID.Hook && projectile.type != ProjectileType() && owner.GetModPlayer().WulfrumPackEquipped && projectile.type != ProjectileID.TrackHook) { projectile.active = false; } - } + }*/ } public class WulfrumPackPlayer : ModPlayer @@ -108,7 +114,7 @@ namespace CalamityMod.Items.Accessories /// /// The index of the grapple projectile currently grappled. /// - public int Grapple = 0; + public int Grapple = -1; /// /// The length of the current rope. Determined when the grapple lands. /// @@ -124,7 +130,7 @@ namespace CalamityMod.Items.Accessories /// /// Is the player grappled? /// - public bool Grappled => WulfrumPackEquipped && Main.projectile[Grapple].active && Main.projectile[Grapple].ModProjectile is WulfrumHook hook && hook.State == WulfrumHook.HookState.Grappling; + public bool Grappled => WulfrumPackEquipped && Grapple > -1 && Main.projectile[Grapple].active && Main.projectile[Grapple].ModProjectile is WulfrumHook hook && hook.State == WulfrumHook.HookState.Grappling; public bool GrappleMovementDisabled { get @@ -132,7 +138,7 @@ namespace CalamityMod.Items.Accessories if (!Grappled) return false; - if (!PlayerOnGround) + if (!PlayerOnGround || !obeyGravity) return false; if ((Player.Center - Main.projectile[Grapple].Center).Length() > SwingLength) @@ -142,25 +148,195 @@ namespace CalamityMod.Items.Accessories } } + public bool obeyGravity => !(Player.miscEquips[4].type == ItemID.AntiGravityHook); + public bool strongerReel => Player.miscEquips[4].type == ItemID.StaticHook; public Vector2 CurrentPosition; public Vector2 OldPosition; public List Segments; - public static int SimulationResolution = 3; - public static int HookUpdates = 3; - public static float GrappleVelocity = 17f; - public static float ReturnVelocity = 5f; - public static float MaxHopVelocity = 4f; //The maximum velocity at which the player gets any amount of vertical boost from hopping out of the hook - public static int SafetySteps = 3; - public static float SafetyHookAngle = MathHelper.PiOver2 * 1.2f; - public static float SafetyHookAngleResolution = 50f; + //Hook stats + /// + /// This is the length when using Grappling Hook. Faster hooks get more length, and slower ones get less. + /// + public const float BaseMaxLength = 600; + /// + /// This is the launch velocity when using Grappling Hook. Faster hooks get more speed, and slower ones get less. + /// + public const float BaseLaunchVelocity = 17f; + /// + /// This is the return velocity when using Grappling Hook. + /// The ratio between this and BaseLaunchVelocity will be the same regardless of hook + /// + public const float BaseReturnVelocity = 5f; + /// + /// This is how much of the equipped hook's launch speed is factored into the Acro Pack hook speed + /// All other stat changes are based off the ratio of the base launch velocity and actual launch velocity + /// Increase this to make the difference between hooks more obvious, and lower it to make the difference less obvious + /// Note: The base stats balance around having Grappling Hook equipped + /// + public const float HookSpeedFactor = 0.5f; + /// + /// How quickly you reel in/out with UP and DOWN + /// + public const float ReelSpeed = 4f; + /// + /// How quickly you reel in with Static Hook equipped + /// + public const float StaticHookReelSpeed = 6f; + /// + /// How much stronger the player manually swinging should be with antigrav hook equipped + /// + public const float AntiGravSwingModifier = 2f; + + public const int SimulationResolution = 5; + public const int HookUpdates = 3; + public const float MaxHopVelocity = 3f; //The maximum velocity at which the player gets any amount of vertical boost from hopping out of the hook + public const int SafetySteps = 3; + public const float SafetyHookAngle = MathHelper.PiOver2 * 1.2f; + public const float SafetyHookAngleResolution = 50f; + + + public float ActualLaunchVelocity + { + get + { + float hookSpeed = 0; + Item hook = Player.miscEquips[4]; + if (!hook.IsAir) + { + hookSpeed = hook.shootSpeed; + } + return BaseLaunchVelocity + (-11.5f + hookSpeed) * HookSpeedFactor; + } + } + public float HookSpeedRatio + { + get + { + return ActualLaunchVelocity / BaseLaunchVelocity; + } + } + public float ActualMaxLength + { + get + { + return BaseMaxLength * HookSpeedRatio; + } + } + public float ActualReturnVelocity + { + get + { + return BaseReturnVelocity * HookSpeedRatio; + } + } public bool PlayerOnGround => Collision.SolidCollision(Player.position + Vector2.UnitY * 2f * Player.gravDir, Player.width, Player.height, false); + public override void Load() + { + base.Load(); + + // On_Player.QuickGrapple_GetItemToUse += QuickGrapple_GetItemToUse_PrioritizeAcrobaticsPack; + On_Player.QuickGrapple += QuickGrapple_UseCustomGrapple; + } + + private static void QuickGrapple_UseCustomGrapple(On_Player.orig_QuickGrapple orig, Player self) + { + if (!self.TryGetModPlayer(out var mp) || !mp.WulfrumPackEquipped) + { + orig(self); + return; + } + + if (mp.hookCooldown > 0) + { + return; + } + + if (self.frozen || self.tongued || self.webbed || self.stoned || self.dead) + { + return; + } + + if (PlayerInput.GrappleAndInteractAreShared) + { + if (Main.HoveringOverAnNPC || Main.SmartInteractShowingGenuine || Main.SmartInteractShowingFake || (WiresUI.Settings.DrawToolModeUI && PlayerInput.UsingGamepad)) + { + return; + } + + var ctrlTile = self.controlUseTile; + var ctrlItem = self.controlUseItem; + if (!ctrlTile && !ctrlItem) + { + return; + } + + var tile = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY); + if ((tile.HasTile && (tile.TileType is 4 or 33 or 372 or 174 or 646 or 49)) || (self.HeldItem.type == ItemID.PortalGun && PlayerInput.UsingGamepad)) + { + return; + } + } + + if (self.noItems) + { + return; + } + + if (self.mount.Active) + { + self.mount.Dismount(self); + } + + self.UpdateBlacklistedTilesForGrappling(); + + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.owner != self.whoAmI || proj.aiStyle != ProjAIStyleID.Hook || proj.type == ProjectileType()) + { + continue; + } + + proj.Kill(); + } + + if (Main.projectile.Count(n => n.active && n.owner == self.whoAmI && n.type == ProjectileType()) <= 1) + { + SoundEngine.PlaySound(WulfrumAcrobaticsPack.ShootSound, self.Center); + + // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction + Vector2 velocity = (Main.MouseWorld - self.Center).SafeNormalize(Vector2.One) * mp.ActualLaunchVelocity; + Projectile.NewProjectile(self.GetSource_ItemUse(mp.PackItem), self.Center, velocity, ProjectileType(), 0, 0, self.whoAmI); + + float angleToRightBelow = velocity.AngleBetween(Vector2.UnitY); + if (angleToRightBelow < MathHelper.PiOver2) //Put a cooldown on hooking down below. + { + int extraCooldown = (int)(Utils.GetLerpValue(MathHelper.PiOver2, 0f, angleToRightBelow) * 15); //Get more cooldown the straightest down youre aiming + mp.hookCooldown = 15 + extraCooldown; + } + } + } + + /* + private static Item QuickGrapple_GetItemToUse_PrioritizeAcrobaticsPack(On_Player.orig_QuickGrapple_GetItemToUse orig, Player self) + { + if (self.TryGetModPlayer(out var mPlayer) && mPlayer.WulfrumPackEquipped && mPlayer.PackItem is not null) + { + return mPlayer.PackItem; + } + + return orig(self); + } + */ + public override void ResetEffects() { WulfrumPackEquipped = false; PackItem = null; + if (Grapple >= 0) + Player.GoingDownWithGrapple = true; //This causes the player to fall through platforms when grappled. Used to fix a weird bug when grappling and standing on a platform. if (hookCooldown > 0) hookCooldown--; @@ -210,7 +386,10 @@ namespace CalamityMod.Items.Accessories } hookCache = -1; - + if (!obeyGravity) + { + Player.gravity = -1f; //Disable player gravity with Anti-Grav hook + } if (Grappled) { if ((Main.projectile[Grapple].Center - Player.Center).Length() > SwingLength + 80f) @@ -221,11 +400,15 @@ namespace CalamityMod.Items.Accessories else SimulateMovement(Main.projectile[Grapple]); } + else + { + Grapple = -1; + } } public void SimulateMovement(Projectile grapple) { - Segments = VerletSimulatedSegment.SimpleSimulation(Segments, SwingLength / SimulationResolution, 50, 0.3f * Player.gravDir); + Segments = VerletSimulatedSegment.SimpleSimulation(Segments, SwingLength / SimulationResolution, 50, (obeyGravity ? 0.3f * Player.gravDir : 0)); Vector2 CurrentPosition; @@ -237,44 +420,85 @@ namespace CalamityMod.Items.Accessories //Dust doost = Dust.NewDustPerfect(CurrentPosition, 1, Vector2.Zero); //doost.noGravity = true; } - - if (!GrappleMovementDisabled) { - CurrentPosition = Segments[SimulationResolution].position; - Player.velocity = CurrentPosition - Player.Center; - - //let the player swing themselves around if they are under the hook. - if (Player.gravDir * (Player.Center.Y - Segments[0].position.Y) > 0) + if (obeyGravity) { - float swing = 0; - if (Math.Sign(Player.velocity.X) < 0) + + CurrentPosition = Segments[SimulationResolution].position; + Player.velocity = CurrentPosition - Player.Center; + + //let the player swing themselves around if they are under the hook. + if (Player.gravDir * (Player.Center.Y - Segments[0].position.Y) > 0) { - if (Player.controlLeft) - swing -= 0.1f; + float swing = 0; - else if (Player.controlRight) - swing += 0.1f; + if (Math.Sign(Player.velocity.X) < 0) + { + if (Player.controlLeft) + swing -= 0.1f; + + else if (Player.controlRight) + swing += 0.1f; + } + + else if (Math.Sign(Player.velocity.X) > 0) + { + if (Player.controlRight) + swing += 0.1f; + + else if (Player.controlLeft) + swing -= 0.1f; + } + + Player.velocity.X += swing; } - else if (Math.Sign(Player.velocity.X) > 0) + else if (Math.Abs(Player.Center.X - Segments[0].position.X) < 30f && Math.Abs(Player.velocity.X) < 1) { - if (Player.controlRight) - swing += 0.1f; - - else if (Player.controlLeft) - swing -= 0.1f; + Player.velocity.X = Player.velocity.X == 0 ? 1.5f : 1.5f * Math.Sign(Player.velocity.X); } - - Player.velocity.X += swing; } - else if (Math.Abs(Player.Center.X - Segments[0].position.X) < 30f && Math.Abs(Player.velocity.X) < 1) + else { - Player.velocity.X = Player.velocity.X == 0 ? 1.5f : 1.5f * Math.Sign(Player.velocity.X); - } + if (Player.grappling[0] > -1) + { + var Hook = Main.projectile[Player.grappling[0]]; + if (Hook != null) + { + if (Player.controlRight) + Player.velocity.X += 0.3f; + else if (Player.controlLeft) + Player.velocity.X -= 0.3f; + Player.velocity -= Player.Center.DirectionTo(Hook.Center); + var estimatedPos = Player.Center + Player.velocity; + var estimatedDir = Hook.Center.DirectionTo(estimatedPos); + var goalPos = Hook.Center + estimatedDir * SwingLength; + var estimatedPosLocked = Hook.Center + Hook.Center.DirectionTo(Player.Center) * SwingLength; + if (estimatedPosLocked.Distance(estimatedPos) < 2) + { + estimatedPos = estimatedPosLocked; + } + var dis = Hook.Center.Distance(estimatedPos); + if (dis > SwingLength && dis < 1000f) + { + var dis2 = Math.Min(Player.Center.Distance(goalPos), SwingLength * 3f); + if (dis2 > 0) + { + Player.velocity = Player.Center.DirectionTo(goalPos) * dis2; + } + + } + + + if (Player.velocity.Length() < 1.5f) + Player.direction = Hook.Center.X > Player.Center.X ? 1 : -1; + } + } + } } if (Grappled) @@ -304,7 +528,10 @@ namespace CalamityMod.Items.Accessories bool playerCrossedSides = Math.Sign(Segments[SimulationResolution].oldPosition.X - Segments[0].position.X) != Math.Sign(Segments[SimulationResolution].position.X - Segments[0].position.X); float swingSpeed = (Segments[SimulationResolution].oldPosition - Segments[SimulationResolution].position).Length(); if (swingSpeed > 6f && playerCrossedSides) - SoundEngine.PlaySound(CommonCalamitySounds.LouderSwingWoosh with { Volume = CommonCalamitySounds.LouderSwingWoosh.Volume * (Math.Clamp((swingSpeed - 6f) / 12f, 0, 1)) }, Player.Center); + { + SoundStyle swing = new SoundStyle("CalamityMod/Sounds/Custom/LoudSwingWoosh") with { Volume = Math.Clamp((swingSpeed - 6f) / 12f, 0, 1) }; + SoundEngine.PlaySound(swing, Player.Center); + } } } @@ -341,7 +568,7 @@ namespace CalamityMod.Items.Accessories for (float angle = -halfSpread; angle < halfSpread; angle += SafetyHookAngle / SafetyHookAngleResolution) { - for (int i = 0; i < (int)(WulfrumHook.MaxReach / 16f); i++) + for (int i = 0; i < (int)(ActualMaxLength / 16f); i++) { Vector2 checkSpot = Player.Center + (-Vector2.UnitY * Player.gravDir * i * 16f).RotatedBy(angle); Point tilePos = checkSpot.ToSafeTileCoordinates(); @@ -391,11 +618,11 @@ namespace CalamityMod.Items.Accessories { float score = 0.0001f; - if (distance < 2 * WulfrumHook.MaxReach / 3f) - score += distance / (2 * WulfrumHook.MaxReach / 3f); + if (distance < 2 * ActualMaxLength / 3f) + score += distance / (2 * ActualMaxLength / 3f); else - score += 1 - (distance - (2 * WulfrumHook.MaxReach / 3f)) / (WulfrumHook.MaxReach / 3f); + score += 1 - (distance - (2 * ActualMaxLength / 3f)) / (ActualMaxLength / 3f); score += (1 - Math.Abs(angle) / (SafetyHookAngle / 2f)) * 0.5f; @@ -407,13 +634,14 @@ namespace CalamityMod.Items.Accessories if (!WulfrumPackEquipped) return; - //Shoot a new hook + //Shoot a new hook + /* 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 foreach (Projectile p in Main.ActiveProjectiles) { - if (p.owner != Player.whoAmI || p.aiStyle != 7 || p.type == ProjectileType()) + if (p.owner != Player.whoAmI || p.aiStyle != ProjAIStyleID.Hook || p.type == ProjectileType()) continue; p.Kill(); @@ -426,7 +654,7 @@ namespace CalamityMod.Items.Accessories if (Player.whoAmI == Main.myPlayer) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 velocity = (Main.MouseWorld - Player.Center).SafeNormalize(Vector2.One) * GrappleVelocity; + Vector2 velocity = (Main.MouseWorld - Player.Center).SafeNormalize(Vector2.One) * ActualLaunchVelocity; Projectile.NewProjectile(Player.GetSource_ItemUse(PackItem), Player.Center, velocity, ProjectileType(), 0, 0, Player.whoAmI); float angleToRightBelow = velocity.AngleBetween(Vector2.UnitY); @@ -438,10 +666,32 @@ namespace CalamityMod.Items.Accessories } } } + */ + + bool setControlUpFalse = false; + if (Grappled && triggersSet.Up) + { + SwingLength -= (strongerReel ? StaticHookReelSpeed : ReelSpeed); + Player.controlUp = false; //This is required to stop the player from bouncing off platforms when falling down and reeling in. Also prevents gravity swapping while hooked. + setControlUpFalse = true; + } + + if (triggersSet.Down) //Static Hook doesn't effect this speed because it would be faster than your fall speed and feel janky. + { + float length = ActualMaxLength; + if (SwingLength < length) + { + SwingLength += (ReelSpeed); + if (SwingLength > length) + SwingLength = length; + } + } //Jumping out of the hook if (triggersSet.Jump && Player.releaseJump) { + var syncData = new WulfrumAcrobaticsJumpSync.Data(); + foreach (Projectile p in Main.ActiveProjectiles) { if (p.owner != Player.whoAmI || p.type != ProjectileType()) @@ -450,10 +700,11 @@ namespace CalamityMod.Items.Accessories //Only clear hooks that are attached to stuff if (p.ModProjectile is WulfrumHook claw && claw.State == WulfrumHook.HookState.Grappling) { - float angleToUpright = (Player.Center - p.Center).AngleBetween(-Vector2.UnitY); bool canJumpOffHook = angleToUpright > MathHelper.PiOver2 || Player.Distance(p.Center) < 38;// Don't do any jump stuff if the player is jumping from above the hook. + syncData = syncData with { CanJumpOffHook = canJumpOffHook }; + if (canJumpOffHook) { Vector2 velocityBoost = Vector2.Zero; @@ -462,6 +713,8 @@ namespace CalamityMod.Items.Accessories if ((Math.Sign(Player.velocity.X) < 0 && Player.controlLeft) || (Math.Sign(Player.velocity.X) > 0 && Player.controlRight)) { velocityBoost += Player.velocity * 0.15f; + if (velocityBoost.Y < 0) //This causes upward velocity to be increased by more. Not needed, but just feels good. + velocityBoost.Y *= 2; } //Additionally^2, if the player isnt moving very fast, make them do a straight up hop. //Don't do the hop if the player isnt moving at all though because thats handled by vanilla. @@ -469,10 +722,15 @@ namespace CalamityMod.Items.Accessories { velocityBoost -= Vector2.UnitY * Player.jumpSpeed * (1 - (float)Math.Pow(Player.velocity.Length() / MaxHopVelocity, 5f)); } + //If the player is moving fast enough, don't jump out of the hook. This is to maintain vertical momentum when releasing grapple while swinging. + if (Player.velocity.Length() < 8f) + { + Player.jump = Player.jumpHeight / 2; + } Player.velocity += velocityBoost; - Player.jump = Player.jumpHeight / 2; + Player.releaseJump = false; } else @@ -483,10 +741,32 @@ namespace CalamityMod.Items.Accessories SoundEngine.PlaySound(WulfrumAcrobaticsPack.ReleaseSound, p.Center); p.Kill(); - + Player.grapCount = 0; } } + if (Main.netMode == NetmodeID.MultiplayerClient) + { + WulfrumAcrobaticsJumpSync.Send( + syncData with + { + PlayerWhoAmI = (byte)Player.whoAmI, + SwingLength = SwingLength, + PlayerVelocity = Player.velocity, + PlayerJump = Player.jump, + SetControlUpFalse = setControlUpFalse, + } + ); + } + } + else + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + WulfrumAcrobaticsLengthSync.Send( + new WulfrumAcrobaticsLengthSync.Data((byte)Player.whoAmI, SwingLength, setControlUpFalse) + ); + } } } @@ -503,4 +783,179 @@ namespace CalamityMod.Items.Accessories } } } + + internal sealed class WulfrumAcrobaticsSync : CalamityPacket + { + public static WulfrumAcrobaticsSync Instance { get; private set; } + + public static void Send(Player player, WulfrumPackPlayer mPlayer, Projectile proj, int toClient = -1, int ignoreClient = -1) + { + Send( + (byte)player.whoAmI, + mPlayer.SwingLength, + mPlayer.OldPosition, + proj.Center, + (byte)proj.whoAmI + ); + } + + private static void Send( + byte playerWhoAmI, + float swingLength, + Vector2 playerOldPos, + Vector2 projCenter, + byte projWhoAmI, + int toClient = -1, + int ignoreClient = -1 + ) + { + var packet = Instance.CreateBasePacket(); + packet.Write(playerWhoAmI); + packet.Write(swingLength); + packet.WriteVector2(playerOldPos); + packet.WriteVector2(projCenter); + packet.Write(projWhoAmI); + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var playerWhoAmI = packet.ReadByte(); + var swingLength = packet.ReadSingle(); + var playerOldPos = packet.ReadVector2(); + var projCenter = packet.ReadVector2(); + var projWhoAmI = packet.ReadByte(); + + if (Main.player[playerWhoAmI].TryGetModPlayer(out var mPlayer)) + { + mPlayer.SwingLength = swingLength; + mPlayer.OldPosition = playerOldPos; + mPlayer.SetSegments(projCenter); + mPlayer.Grapple = projWhoAmI; + } + + if (Main.netMode == NetmodeID.Server) + { + Send( + playerWhoAmI, + swingLength, + playerOldPos, + projCenter, + projWhoAmI, + ignoreClient: sender + ); + } + } + } + + internal sealed class WulfrumAcrobaticsJumpSync : CalamityPacket + { + public readonly record struct Data( + byte PlayerWhoAmI, + float SwingLength, + bool CanJumpOffHook, + Vector2 PlayerVelocity, + int PlayerJump, + bool SetControlUpFalse + ); + + public static WulfrumAcrobaticsJumpSync Instance { get; private set; } + + public static void Send(Data data, int toClient = -1, int ignoreClient = -1) + { + var packet = Instance.CreateBasePacket(); + packet.Write(data.PlayerWhoAmI); + packet.Write(data.SwingLength); + packet.Write(data.CanJumpOffHook); + packet.WriteVector2(data.PlayerVelocity); + packet.Write(data.PlayerJump); + packet.Write(data.SetControlUpFalse); + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var playerWhoAmI = packet.ReadByte(); + var swingLength = packet.ReadSingle(); + var canJumpOffHook = packet.ReadBoolean(); + var playerVelocity = packet.ReadVector2(); + var playerJump = packet.ReadInt32(); + var setControlUpFalse = packet.ReadBoolean(); + + var player = Main.player[playerWhoAmI]; + if (player.TryGetModPlayer(out var mPlayer)) + { + mPlayer.SwingLength = swingLength; + } + + if (canJumpOffHook) + { + player.jump = playerJump; + player.velocity = playerVelocity; + } + else + { + player.releaseJump = false; + } + + if (setControlUpFalse) + { + player.controlUp = false; + } + + if (Main.netMode == NetmodeID.Server) + { + Send( + new Data(playerWhoAmI, swingLength, canJumpOffHook, playerVelocity, playerJump, setControlUpFalse), + ignoreClient: sender + ); + } + } + } + + internal sealed class WulfrumAcrobaticsLengthSync : CalamityPacket + { + public readonly record struct Data( + byte PlayerWhoAmI, + float SwingLength, + bool SetControlUpFalse + ); + + public static WulfrumAcrobaticsLengthSync Instance { get; private set; } + + public static void Send(Data data, int toClient = -1, int ignoreClient = -1) + { + var packet = Instance.CreateBasePacket(); + packet.Write(data.PlayerWhoAmI); + packet.Write(data.SwingLength); + packet.Write(data.SetControlUpFalse); + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var playerWhoAmI = packet.ReadByte(); + var swingLength = packet.ReadSingle(); + var setControlUpFalse = packet.ReadBoolean(); + + var player = Main.player[playerWhoAmI]; + if (player.TryGetModPlayer(out var mPlayer)) + { + mPlayer.SwingLength = swingLength; + } + + if (setControlUpFalse) + { + player.controlUp = false; + } + + if (Main.netMode == NetmodeID.Server) + { + Send( + new Data(playerWhoAmI, swingLength, setControlUpFalse), + ignoreClient: sender + ); + } + } + } } diff --git a/Items/Accessories/WulfrumBattery.cs b/Items/Accessories/WulfrumBattery.cs index efa3e9f2ac..d351c8173d 100644 --- a/Items/Accessories/WulfrumBattery.cs +++ b/Items/Accessories/WulfrumBattery.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Items.Accessories { public override void AI(Projectile projectile) { - if (!projectile.npcProj && !projectile.trap && projectile.minion && !ProjectileID.Sets.MinionShot[projectile.type] && Main.player[projectile.owner].GetModPlayer().battery) + if (!projectile.npcProj && !projectile.trap && (projectile.minion||projectile.sentry) && !ProjectileID.Sets.MinionShot[projectile.type] && !ProjectileID.Sets.SentryShot[projectile.type] && Main.player[projectile.owner].GetModPlayer().battery) { float lightMult = 1f; if (Lighting.UpdateEveryFrame) //The light loks wayyy too bright in retro/trippy @@ -79,7 +79,7 @@ namespace CalamityMod.Items.Accessories { float size = (projectile.Hitbox.Size() / 2f).Length(); - Dust zapDust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * size, 66, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(0.5f, 1.3f)); + Dust zapDust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * size, DustID.RainbowTorch, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(0.5f, 1.3f)); zapDust.noGravity = true; zapDust.color = Main.rand.NextBool() ? Color.SkyBlue : Color.LightGreen; zapDust.velocity = projectile.velocity * 0.2f; diff --git a/Items/Accessories/WulfrumBattery.png b/Items/Accessories/WulfrumBattery.png index ada5ddef24..f2559fc5f6 100644 Binary files a/Items/Accessories/WulfrumBattery.png and b/Items/Accessories/WulfrumBattery.png differ diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 83d180aa84..c505001aa1 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -1,10 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Typeless; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -18,10 +15,11 @@ namespace CalamityMod.Items.Accessories { Item.width = 20; Item.height = 22; - Item.defense = 15; // Why did this give 30 defense? This thing really needs a rework lol + Item.defense = 12; Item.accessory = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); + Item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) @@ -29,6 +27,7 @@ namespace CalamityMod.Items.Accessories var source = player.GetSource_Accessory(Item); player.moveSpeed += 0.15f; player.GetDamage() += 0.15f; + player.noKnockback = true; if (!player.StandingStill()) { dragonTimer--; diff --git a/Items/AlicornonaStick.cs b/Items/AlicornonaStick.cs deleted file mode 100644 index 1a0dda3f93..0000000000 --- a/Items/AlicornonaStick.cs +++ /dev/null @@ -1,104 +0,0 @@ -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.Other; -using CalamityMod.Particles; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items -{ - public class AlicornonaStick : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Misc"; - public override void SetDefaults() - { - Item.width = 42; - Item.height = 50; - Item.holdStyle = 6; - Item.value = 0; - Item.rare = ModContent.RarityType(); - } - - public override void HoldItem(Player player) - { - 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.ActiveNPCs) - { - if (!npc.dontTakeDamage && npc.type != ModContent.NPCType()) - { - if (itemRect.Intersects(npc.getRect())) - { - int damage = npc.SimpleStrikeNPC((int)(npc.lifeMax / 200), player.direction, true); - SoundEngine.PlaySound(Projectiles.Summon.CnidarianJellyfishOnTheString.SlapSound with { Volume = 2, MaxInstances = 200 }, npc.Center); - if (!Main.dedServ) - { - BloodShed(itemRect, npc, damage, player); - } - } - } - } - } - - public void BloodShed(Rectangle hitBox, NPC target, int damage, Player player) - { - // this is violence but exaggerated - float damageInterpolant = Utils.GetLerpValue(950f, 2000f, damage, true); - - Vector2 impactPoint = Vector2.Lerp(hitBox.Center.ToVector2(), target.Center, 0.65f); - Vector2 bloodSpawnPosition = target.Center + Main.rand.NextVector2Circular(target.width, target.height) * 0.04f; - Vector2 splatterDirection = (new Vector2(bloodSpawnPosition.X * player.direction, bloodSpawnPosition.Y)).SafeNormalize(Vector2.UnitY); - - // Emit blood if the target is organic. - if (target.Organic()) - { - for (int i = 0; i < 16; i++) - { - int bloodLifetime = Main.rand.Next(22, 36); - float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); - Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); - bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); - - if (Main.rand.NextBool(20)) - bloodScale *= 2f; - - Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.81f) * Main.rand.NextFloat(11f, 23f); - bloodVelocity.Y -= 12f; - BloodParticle blood = new BloodParticle(bloodSpawnPosition, bloodVelocity, bloodLifetime, bloodScale, bloodColor); - GeneralParticleHandler.SpawnParticle(blood); - } - for (int i = 0; i < 9; i++) - { - float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); - Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); - Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.9f) * Main.rand.NextFloat(9f, 14.5f); - BloodParticle2 blood = new BloodParticle2(bloodSpawnPosition, bloodVelocity, 20, bloodScale, bloodColor); - GeneralParticleHandler.SpawnParticle(blood); - } - } - - // Emit sparks if the target is not organic. - else - { - for (int i = 0; i < 16; i++) - { - int sparkLifetime = Main.rand.Next(22, 36); - float sparkScale = Main.rand.NextFloat(0.8f, 1f) + damageInterpolant * 0.85f; - Color sparkColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.7f)); - sparkColor = Color.Lerp(sparkColor, Color.Orange, Main.rand.NextFloat()); - - if (Main.rand.NextBool(10)) - sparkScale *= 2f; - - Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); - sparkVelocity.Y -= 6f; - SparkParticle spark = new SparkParticle(impactPoint, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); - GeneralParticleHandler.SpawnParticle(spark); - } - } - } - } -} diff --git a/Items/AlicornonaStick.png b/Items/AlicornonaStick.png deleted file mode 100644 index b09e99c934..0000000000 Binary files a/Items/AlicornonaStick.png and /dev/null differ diff --git a/Items/Ammo/AstralSolution.cs b/Items/Ammo/AstralSolution.cs index 4026fbb514..99c8168680 100644 --- a/Items/Ammo/AstralSolution.cs +++ b/Items/Ammo/AstralSolution.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Typeless; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -20,10 +19,5 @@ namespace CalamityMod.Items.Ammo { itemGroup = ContentSamples.CreativeHelper.ItemGroup.Solutions; } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - return !(player.itemAnimation < player.ActiveItem().useAnimation - 3); - } } } diff --git a/Items/Ammo/BloodRune.cs b/Items/Ammo/BloodRune.cs index e12165c861..e815c4d747 100644 --- a/Items/Ammo/BloodRune.cs +++ b/Items/Ammo/BloodRune.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Ammo Item.consumable = true; Item.knockBack = 10f; Item.value = Item.buyPrice(gold: 1); // Sold by Archmage - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 0f; diff --git a/Items/Ammo/BloodfireArrow.cs b/Items/Ammo/BloodfireArrow.cs index 6c44ff4334..6fd88990ef 100644 --- a/Items/Ammo/BloodfireArrow.cs +++ b/Items/Ammo/BloodfireArrow.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 14; Item.height = 36; - Item.damage = 30; + Item.damage = 19; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Ammo { CreateRecipe(333). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Ammo/BloodfireBullet.cs b/Items/Ammo/BloodfireBullet.cs index 490e39bf4b..91630337cb 100644 --- a/Items/Ammo/BloodfireBullet.cs +++ b/Items/Ammo/BloodfireBullet.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 14; Item.height = 30; - Item.damage = 27; + Item.damage = 17; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Ammo { CreateRecipe(333). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Ammo/BubonicRound.png b/Items/Ammo/BubonicRound.png index 0e2796dffc..230853d588 100644 Binary files a/Items/Ammo/BubonicRound.png and b/Items/Ammo/BubonicRound.png differ diff --git a/Items/Ammo/ElysianArrow.cs b/Items/Ammo/ElysianArrow.cs index 72545034d4..52dcc7ba58 100644 --- a/Items/Ammo/ElysianArrow.cs +++ b/Items/Ammo/ElysianArrow.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 22; Item.height = 36; - Item.damage = 17; + Item.damage = 15; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Ammo CreateRecipe(150). AddIngredient(ItemID.HolyArrow, 150). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Ammo/FlashRound.cs b/Items/Ammo/FlashRound.cs index fbd7778605..488ad4ead5 100644 --- a/Items/Ammo/FlashRound.cs +++ b/Items/Ammo/FlashRound.cs @@ -18,23 +18,23 @@ namespace CalamityMod.Items.Ammo { Item.width = 12; Item.height = 18; - Item.damage = 5; + Item.damage = 6; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; - Item.knockBack = 1.15f; - Item.value = Item.sellPrice(copper: 2); + Item.knockBack = 6f; + Item.value = Item.sellPrice(copper: 1); Item.rare = ItemRarityID.Blue; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; + Item.shootSpeed = 10f; Item.ammo = AmmoID.Bullet; } public override void AddRecipes() { - CreateRecipe(10). - AddIngredient(ItemID.Grenade). - AddIngredient(ItemID.Glass, 3). + CreateRecipe(70). + AddRecipeGroup("AnyCopperBar", 1). + AddIngredient(ItemID.Glass, 1). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Ammo/GodSlayerSlug.cs b/Items/Ammo/GodSlayerSlug.cs index da4a0261d5..7c2e134d17 100644 --- a/Items/Ammo/GodSlayerSlug.cs +++ b/Items/Ammo/GodSlayerSlug.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Items.Ammo { Item.width = 22; Item.height = 22; - Item.damage = 28; + Item.damage = 18; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; Item.knockBack = 3f; Item.value = Item.sellPrice(copper: 28); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 6f; Item.ammo = ItemID.MusketBall; @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Ammo public override void AddRecipes() { CreateRecipe(999). - AddIngredient(ItemID.EmptyBullet, 999). + AddIngredient(ItemID.MoonlordBullet, 999). AddIngredient(). AddTile(). Register(); diff --git a/Items/Ammo/HallowPointRound.cs b/Items/Ammo/HallowPointRound.cs index c3316d90fa..725c8dab0a 100644 --- a/Items/Ammo/HallowPointRound.cs +++ b/Items/Ammo/HallowPointRound.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Ammo CreateRecipe(100). AddIngredient(ItemID.EmptyBullet, 100). AddIngredient(ItemID.HallowedBar). - AddTile(TileID.MythrilAnvil). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Ammo/HolyFireBullet.cs b/Items/Ammo/HolyFireBullet.cs index 068b149d82..f92a3dbda8 100644 --- a/Items/Ammo/HolyFireBullet.cs +++ b/Items/Ammo/HolyFireBullet.cs @@ -10,18 +10,16 @@ namespace CalamityMod.Items.Ammo public class HolyFireBullet : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Ammo"; - internal const float ExplosionMultiplier = 0.275f; public static readonly SoundStyle Explosion = new("CalamityMod/Sounds/Item/HolyFireBulletExplosion") { PitchVariance = 0.2f, Volume = 0.6f }; public override void SetStaticDefaults() { Item.ResearchUnlockCount = 99; } - public override void SetDefaults() { Item.width = 22; Item.height = 22; - Item.damage = 20; + Item.damage = 19; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; @@ -35,10 +33,10 @@ namespace CalamityMod.Items.Ammo public override void AddRecipes() { - CreateRecipe(100). - AddIngredient(ItemID.ExplodingBullet, 100). + CreateRecipe(333). + AddIngredient(ItemID.ExplodingBullet, 333). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Ammo/HyperiusBullet.cs b/Items/Ammo/HyperiusBullet.cs index 135be89269..7d7083766f 100644 --- a/Items/Ammo/HyperiusBullet.cs +++ b/Items/Ammo/HyperiusBullet.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -8,20 +9,18 @@ namespace CalamityMod.Items.Ammo { public class HyperiusBullet : ModItem, ILocalizedModType { + public static float overflowEfficency = 1.2f; // Multiplier applied to overflow damage done by other damage sources + public static readonly SoundStyle hit = new("CalamityMod/Sounds/Item/HyperiusOverflow"); public new string LocalizationCategory => "Items.Ammo"; - - public static int SplitBulletBonusDamage = 16; - public override void SetStaticDefaults() { Item.ResearchUnlockCount = 99; } - public override void SetDefaults() { Item.width = 24; Item.height = 30; - Item.damage = 13; + Item.damage = 12; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; @@ -35,8 +34,8 @@ namespace CalamityMod.Items.Ammo public override void AddRecipes() { - CreateRecipe(150). - AddIngredient(ItemID.MusketBall, 150). + CreateRecipe(333). + AddIngredient(ItemID.MusketBall, 333). AddIngredient(). AddTile(TileID.MythrilAnvil). Register(); diff --git a/Items/Ammo/MortarRound.cs b/Items/Ammo/MortarRound.cs index 51aff1f16b..2510619ad2 100644 --- a/Items/Ammo/MortarRound.cs +++ b/Items/Ammo/MortarRound.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 20; Item.height = 14; - Item.damage = 20; + Item.damage = 8; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; diff --git a/Items/Ammo/RubberMortarRound.cs b/Items/Ammo/RubberMortarRound.cs index 1b751ed01c..1d09a5521e 100644 --- a/Items/Ammo/RubberMortarRound.cs +++ b/Items/Ammo/RubberMortarRound.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 20; Item.height = 14; - Item.damage = 20; + Item.damage = 8; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; diff --git a/Items/Ammo/SproutingArrow.cs b/Items/Ammo/SproutingArrow.cs index d8006c98eb..5b6cf0d8c0 100644 --- a/Items/Ammo/SproutingArrow.cs +++ b/Items/Ammo/SproutingArrow.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 22; Item.height = 36; - Item.damage = 15; + Item.damage = 14; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; diff --git a/Items/Ammo/VanquisherArrow.cs b/Items/Ammo/VanquisherArrow.cs index efc4a9ff33..e530952681 100644 --- a/Items/Ammo/VanquisherArrow.cs +++ b/Items/Ammo/VanquisherArrow.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 22; Item.height = 46; - Item.damage = 30; + Item.damage = 16; Item.DamageType = DamageClass.Ranged; Item.maxStack = Item.CommonMaxStack; Item.consumable = true; @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Ammo Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 0.1f; Item.ammo = AmmoID.Arrow; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/AntiCystOintment.cs b/Items/AntiCystOintment.cs deleted file mode 100644 index c3c9cd3b4d..0000000000 --- a/Items/AntiCystOintment.cs +++ /dev/null @@ -1,98 +0,0 @@ -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() - { - Item.width = 44; - Item.height = 34; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; - } - - public override bool CanRightClick() => true; - - public override void RightClick(Player player) - { - if (player.Calamity().disablePerfCystSpawns == true) - player.Calamity().disablePerfCystSpawns = false; - else - player.Calamity().disablePerfCystSpawns = true; - state = player.Calamity().disablePerfCystSpawns; - - Item.RestoreConsumedItemByRightClick(); - } - - /* - 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(). - AddIngredient(ItemID.CrimtaneBar, 5). - AddIngredient(ItemID.BottledWater). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/AntiTumorOintment.cs b/Items/AntiTumorOintment.cs deleted file mode 100644 index 63f9807f27..0000000000 --- a/Items/AntiTumorOintment.cs +++ /dev/null @@ -1,98 +0,0 @@ -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() - { - Item.width = 44; - Item.height = 34; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; - } - - public override bool CanRightClick() => true; - - public override void RightClick(Player player) - { - if (player.Calamity().disableHiveCystSpawns == true) - player.Calamity().disableHiveCystSpawns = false; - else - player.Calamity().disableHiveCystSpawns = true; - state = player.Calamity().disableHiveCystSpawns; - - Item.RestoreConsumedItemByRightClick(); - } - /* - 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() - { - CreateRecipe(). - AddIngredient(ItemID.DemoniteBar, 5). - AddIngredient(ItemID.BottledWater). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Armor/Aerospec/AerospecBreastplate.cs b/Items/Armor/Aerospec/AerospecBreastplate.cs index 0379cb9b0f..97e9ae7fbd 100644 --- a/Items/Armor/Aerospec/AerospecBreastplate.cs +++ b/Items/Armor/Aerospec/AerospecBreastplate.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Aerospec @@ -11,6 +12,15 @@ namespace CalamityMod.Items.Armor.Aerospec public new string LocalizationCategory => "Items.Armor.PreHardmode"; internal static string FeatherEntitySourceContext => "SetBonus_Calamity_Aerospec"; + public static float DamageBoost = 0.03f; + public static int CritBoost = 3; // NOTE: Tooltip shares this number with damage % as they're equal + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent()); + + // Common Set Bonus + public static int SetBonusHurtDamageThreshold = 25; + public static int SetBonusFeatherDamage => CalamityUtils.ScaleWithDifficulty(15); + public static float SetBonusFallSpeed = 15f; + public override void SetDefaults() { Item.width = 18; @@ -22,8 +32,8 @@ namespace CalamityMod.Items.Armor.Aerospec public override void UpdateEquip(Player player) { - player.GetDamage() += 0.03f; - player.GetCritChance() += 3; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; } public override void AddRecipes() @@ -32,7 +42,7 @@ namespace CalamityMod.Items.Armor.Aerospec AddIngredient(11). AddIngredient(ItemID.SunplateBlock, 8). AddIngredient(ItemID.Feather, 2). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Armor/Aerospec/AerospecHat.cs b/Items/Armor/Aerospec/AerospecHat.cs deleted file mode 100644 index b423f48d9b..0000000000 --- a/Items/Armor/Aerospec/AerospecHat.cs +++ /dev/null @@ -1,60 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Aerospec -{ - [AutoloadEquip(EquipType.Head)] - public class AerospecHat : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.defense = 3; //15 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.aeroSet = true; - player.noFallDmg = true; - player.moveSpeed += 0.05f; - player.manaCost -= 0.08f; - player.GetCritChance() += 5; - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.1f; - player.statManaMax2 += 30; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(ItemID.SunplateBlock, 3). - AddIngredient(ItemID.Feather). - AddTile(TileID.SkyMill). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Aerospec/AerospecHeadMagic.cs b/Items/Armor/Aerospec/AerospecHeadMagic.cs new file mode 100644 index 0000000000..5dda2d7b17 --- /dev/null +++ b/Items/Armor/Aerospec/AerospecHeadMagic.cs @@ -0,0 +1,65 @@ +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Aerospec +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AerospecHat")] + public class AerospecHeadMagic : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int MaxManaBoost = 30; + public static float MagicDamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, MagicDamageBoost.ToPercent()); + + // Set Bonus + public static float SetBonusManaCostReduction = 0.08f; + public static float SetBonusMoveSpeedBoost = 0.05f; + public static int SetBonusMagicCritBoost = 5; // NOTE: Tooltip shares this number with move speed % as they're equal + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.defense = 3; //15 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusManaCostReduction.ToPercent(), SetBonusMoveSpeedBoost.ToPercent(), AerospecBreastplate.SetBonusHurtDamageThreshold); + var modPlayer = player.Calamity(); + modPlayer.aeroSet = true; + player.noFallDmg = true; + player.moveSpeed += SetBonusMoveSpeedBoost; + player.manaCost -= SetBonusManaCostReduction; + player.GetCritChance() += SetBonusMagicCritBoost; + } + + public override void UpdateEquip(Player player) + { + player.GetDamage() += MagicDamageBoost; + player.statManaMax2 += MaxManaBoost; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.SunplateBlock, 3). + AddIngredient(ItemID.Feather). + AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Aerospec/AerospecHat.png b/Items/Armor/Aerospec/AerospecHeadMagic.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHat.png rename to Items/Armor/Aerospec/AerospecHeadMagic.png diff --git a/Items/Armor/Aerospec/AerospecHat_Head.png b/Items/Armor/Aerospec/AerospecHeadMagic_Head.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHat_Head.png rename to Items/Armor/Aerospec/AerospecHeadMagic_Head.png diff --git a/Items/Armor/Aerospec/AerospecHeadMelee.cs b/Items/Armor/Aerospec/AerospecHeadMelee.cs new file mode 100644 index 0000000000..f59f2bd760 --- /dev/null +++ b/Items/Armor/Aerospec/AerospecHeadMelee.cs @@ -0,0 +1,60 @@ +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Aerospec +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AerospecHelm")] + public class AerospecHeadMelee : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float MeleeDamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent()); + + // Set Bonus + public static float SetBonusMoveSpeedBoost = 0.05f; + public static int SetBonusMeleeCritBoost = 5; // NOTE: Tooltip shares this number with move speed % as they're equal + public static int SetBonusAggroBoost = 300; + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.defense = 7; //20 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMoveSpeedBoost.ToPercent(), AerospecBreastplate.SetBonusHurtDamageThreshold); + var modPlayer = player.Calamity(); + modPlayer.aeroSet = true; + player.noFallDmg = true; + player.moveSpeed += SetBonusMoveSpeedBoost; + player.GetCritChance() += SetBonusMeleeCritBoost; + player.aggro += SetBonusAggroBoost; + } + + public override void UpdateEquip(Player player) => player.GetDamage() += MeleeDamageBoost; + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.SunplateBlock, 3). + AddIngredient(ItemID.Feather). + AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Aerospec/AerospecHelm.png b/Items/Armor/Aerospec/AerospecHeadMelee.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHelm.png rename to Items/Armor/Aerospec/AerospecHeadMelee.png diff --git a/Items/Armor/Aerospec/AerospecHelm_Head.png b/Items/Armor/Aerospec/AerospecHeadMelee_Head.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHelm_Head.png rename to Items/Armor/Aerospec/AerospecHeadMelee_Head.png diff --git a/Items/Armor/Aerospec/AerospecHeadRanged.cs b/Items/Armor/Aerospec/AerospecHeadRanged.cs new file mode 100644 index 0000000000..b7689e72e5 --- /dev/null +++ b/Items/Armor/Aerospec/AerospecHeadRanged.cs @@ -0,0 +1,58 @@ +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Aerospec +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AerospecHood")] + public class AerospecHeadRanged : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float RangedDamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent()); + + // Set Bonus + public static float SetBonusMoveSpeedBoost = 0.05f; + public static int SetBonusRangedCritBoost = 5; // NOTE: Tooltip shares this number with move speed % as they're equal + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.defense = 5; //18 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMoveSpeedBoost.ToPercent(), AerospecBreastplate.SetBonusHurtDamageThreshold); + var modPlayer = player.Calamity(); + modPlayer.aeroSet = true; + player.noFallDmg = true; + player.moveSpeed += SetBonusMoveSpeedBoost; + player.GetCritChance() += SetBonusRangedCritBoost; + } + + public override void UpdateEquip(Player player) => player.GetDamage() += RangedDamageBoost; + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.SunplateBlock, 3). + AddIngredient(ItemID.Feather). + AddTile(TileID.Anvils). + SortAfterFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Aerospec/AerospecHood.png b/Items/Armor/Aerospec/AerospecHeadRanged.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHood.png rename to Items/Armor/Aerospec/AerospecHeadRanged.png diff --git a/Items/Armor/Aerospec/AerospecHood_Head.png b/Items/Armor/Aerospec/AerospecHeadRanged_Head.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHood_Head.png rename to Items/Armor/Aerospec/AerospecHeadRanged_Head.png diff --git a/Items/Armor/Aerospec/AerospecHeadRogue.cs b/Items/Armor/Aerospec/AerospecHeadRogue.cs new file mode 100644 index 0000000000..6d4b986512 --- /dev/null +++ b/Items/Armor/Aerospec/AerospecHeadRogue.cs @@ -0,0 +1,72 @@ +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Aerospec +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AerospecHeadgear")] + public class AerospecHeadRogue : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float RogueDamageBoost = 0.1f; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 0.8f; + public static float SetBonusMoveSpeedBoost = 0.05f; + public static int SetBonusRogueCritBoost = 5; // NOTE: Tooltip shares this number with move speed % as they're equal + + public override void SetStaticDefaults() + { + if (!Main.dedServ) + ArmorIDs.Head.Sets.DrawFullHair[Item.headSlot] = true; + } + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.defense = 4; //17 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), SetBonusMoveSpeedBoost.ToPercent(), AerospecBreastplate.SetBonusHurtDamageThreshold); + var modPlayer = player.Calamity(); + modPlayer.aeroSet = true; + modPlayer.rogueStealthMax += SetBonusRogueStealth; + player.noFallDmg = true; + player.moveSpeed += SetBonusMoveSpeedBoost; + player.GetCritChance() += SetBonusRogueCritBoost; + player.Calamity().wearingRogueArmor = true; + } + + public override void UpdateEquip(Player player) + { + player.GetDamage() += RogueDamageBoost; + player.moveSpeed += MoveSpeedBoost; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.SunplateBlock, 3). + AddIngredient(ItemID.Feather). + AddTile(TileID.Anvils). + SortAfterFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Aerospec/AerospecHeadgear.png b/Items/Armor/Aerospec/AerospecHeadRogue.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHeadgear.png rename to Items/Armor/Aerospec/AerospecHeadRogue.png diff --git a/Items/Armor/Aerospec/AerospecHeadgear_Head.png b/Items/Armor/Aerospec/AerospecHeadRogue_Head.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHeadgear_Head.png rename to Items/Armor/Aerospec/AerospecHeadRogue_Head.png diff --git a/Items/Armor/Aerospec/AerospecHeadSummon.cs b/Items/Armor/Aerospec/AerospecHeadSummon.cs new file mode 100644 index 0000000000..34e32fa38e --- /dev/null +++ b/Items/Armor/Aerospec/AerospecHeadSummon.cs @@ -0,0 +1,83 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Aerospec +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AerospecHelmet")] + public class AerospecHeadSummon : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float SummonDamageBoost = 0.1f; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(SummonDamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 1; + public static float SetBonusSummonDamageBoost = 0.11f; + public static int ValkyrieDamage = 20; + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.defense = 2; //13 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent(), AerospecBreastplate.SetBonusHurtDamageThreshold); + var modPlayer = player.Calamity(); + modPlayer.valkyrie = true; + modPlayer.aeroSet = true; + player.noFallDmg = true; + if (player.whoAmI == Main.myPlayer) + { + var source = player.GetSource_ItemUse(Item); + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + { + player.AddBuff(ModContent.BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + var damage = (int)player.GetTotalDamage().ApplyTo(ValkyrieDamage); + + var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); + if (Main.projectile.IndexInRange(p)) + Main.projectile[p].originalDamage = ValkyrieDamage; + } + } + player.GetDamage() += SetBonusSummonDamageBoost; + player.maxMinions += SetBonusMinionSlotBoost; + } + + public override void UpdateEquip(Player player) + { + player.moveSpeed += MoveSpeedBoost; + player.GetDamage() += SummonDamageBoost; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.SunplateBlock, 3). + AddIngredient(ItemID.Feather). + AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Aerospec/AerospecHelmet.png b/Items/Armor/Aerospec/AerospecHeadSummon.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHelmet.png rename to Items/Armor/Aerospec/AerospecHeadSummon.png diff --git a/Items/Armor/Aerospec/AerospecHelmet_Head.png b/Items/Armor/Aerospec/AerospecHeadSummon_Head.png similarity index 100% rename from Items/Armor/Aerospec/AerospecHelmet_Head.png rename to Items/Armor/Aerospec/AerospecHeadSummon_Head.png diff --git a/Items/Armor/Aerospec/AerospecHeadgear.cs b/Items/Armor/Aerospec/AerospecHeadgear.cs deleted file mode 100644 index 2caf137da0..0000000000 --- a/Items/Armor/Aerospec/AerospecHeadgear.cs +++ /dev/null @@ -1,67 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Aerospec -{ - [AutoloadEquip(EquipType.Head)] - public class AerospecHeadgear : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetStaticDefaults() - { - if (!Main.dedServ) - ArmorIDs.Head.Sets.DrawFullHair[Item.headSlot] = true; - } - - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.defense = 4; //17 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.aeroSet = true; - modPlayer.rogueStealthMax += 0.8f; - player.noFallDmg = true; - player.moveSpeed += 0.05f; - player.GetCritChance() += 5; - player.Calamity().wearingRogueArmor = true; - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.1f; - player.moveSpeed += 0.05f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(ItemID.SunplateBlock, 3). - AddIngredient(ItemID.Feather). - AddTile(TileID.SkyMill). - SortAfterFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Aerospec/AerospecHelm.cs b/Items/Armor/Aerospec/AerospecHelm.cs deleted file mode 100644 index d8303c5fee..0000000000 --- a/Items/Armor/Aerospec/AerospecHelm.cs +++ /dev/null @@ -1,59 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Aerospec -{ - [AutoloadEquip(EquipType.Head)] - public class AerospecHelm : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.defense = 7; //20 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.aeroSet = true; - player.noFallDmg = true; - player.moveSpeed += 0.05f; - player.GetCritChance() += 5; - player.aggro += 300; - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.1f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(ItemID.SunplateBlock, 3). - AddIngredient(ItemID.Feather). - AddTile(TileID.SkyMill). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Aerospec/AerospecHelmet.cs b/Items/Armor/Aerospec/AerospecHelmet.cs deleted file mode 100644 index 4147feed8f..0000000000 --- a/Items/Armor/Aerospec/AerospecHelmet.cs +++ /dev/null @@ -1,81 +0,0 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Summon; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Aerospec -{ - [AutoloadEquip(EquipType.Head)] - public class AerospecHelmet : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public static int ValkyrieDamage = 20; - - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.defense = 2; //13 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.valkyrie = true; - modPlayer.aeroSet = true; - player.noFallDmg = true; - if (player.whoAmI == Main.myPlayer) - { - var source = player.GetSource_ItemUse(Item); - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - var damage = (int)player.GetTotalDamage().ApplyTo(ValkyrieDamage); - - var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = ValkyrieDamage; - } - } - player.GetDamage() += 0.11f; - player.maxMinions++; - } - - public override void UpdateEquip(Player player) - { - player.moveSpeed += 0.05f; - player.GetDamage() += 0.1f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(ItemID.SunplateBlock, 3). - AddIngredient(ItemID.Feather). - AddTile(TileID.SkyMill). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Aerospec/AerospecHood.cs b/Items/Armor/Aerospec/AerospecHood.cs deleted file mode 100644 index e452f6a125..0000000000 --- a/Items/Armor/Aerospec/AerospecHood.cs +++ /dev/null @@ -1,58 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Aerospec -{ - [AutoloadEquip(EquipType.Head)] - public class AerospecHood : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.defense = 5; //18 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.aeroSet = true; - player.noFallDmg = true; - player.moveSpeed += 0.05f; - player.GetCritChance() += 5; - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.1f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(ItemID.SunplateBlock, 3). - AddIngredient(ItemID.Feather). - AddTile(TileID.SkyMill). - SortAfterFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Aerospec/AerospecLeggings.cs b/Items/Armor/Aerospec/AerospecLeggings.cs index 2cb02ee477..f035355c2f 100644 --- a/Items/Armor/Aerospec/AerospecLeggings.cs +++ b/Items/Armor/Aerospec/AerospecLeggings.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Aerospec @@ -9,6 +10,10 @@ namespace CalamityMod.Items.Armor.Aerospec public class AerospecLeggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float MoveSpeedBoost = 0.12f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -18,10 +23,7 @@ namespace CalamityMod.Items.Armor.Aerospec Item.defense = 6; } - public override void UpdateEquip(Player player) - { - player.moveSpeed += 0.12f; - } + public override void UpdateEquip(Player player) => player.moveSpeed += MoveSpeedBoost; public override void AddRecipes() { @@ -29,7 +31,7 @@ namespace CalamityMod.Items.Armor.Aerospec AddIngredient(7). AddIngredient(ItemID.SunplateBlock, 4). AddIngredient(ItemID.Feather, 2). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Armor/Astral/AstralBreastplate.cs b/Items/Armor/Astral/AstralBreastplate.cs index 0efb6e01dc..1e8a002664 100644 --- a/Items/Armor/Astral/AstralBreastplate.cs +++ b/Items/Armor/Astral/AstralBreastplate.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Astral @@ -9,6 +10,12 @@ namespace CalamityMod.Items.Armor.Astral public class AstralBreastplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MaxManaBoost = 80; + public static float AmmoReduction = 0.75f; + public static float DamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, DamageBoost.ToPercent(), (1f - AmmoReduction).ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -20,9 +27,10 @@ namespace CalamityMod.Items.Armor.Astral public override void UpdateEquip(Player player) { - player.statLifeMax2 += 20; - player.statManaMax2 += 80; - player.GetDamage() += 0.07f; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.statManaMax2 += MaxManaBoost; + player.GetDamage() += DamageBoost; } public override void AddRecipes() diff --git a/Items/Armor/Astral/AstralHelm.cs b/Items/Armor/Astral/AstralHelm.cs index 35c40f89a9..39e9bb66d6 100644 --- a/Items/Armor/Astral/AstralHelm.cs +++ b/Items/Armor/Astral/AstralHelm.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Astral @@ -10,6 +10,18 @@ namespace CalamityMod.Items.Armor.Astral public class AstralHelm : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float DamageBoost = 0.05f; + public static int CritBoost = 15; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 3; + public static float SetBonusDamageBoost = 0.1f; + public static int SetBonusCritBoost = 10; // NOTE: Tooltip shares this number with damage % as they're equal + public static int StarRainCooldown = CalamityUtils.SecondsToFrames(1); + public static int StarDamage = 120; + public override void SetDefaults() { Item.width = 18; @@ -31,20 +43,20 @@ namespace CalamityMod.Items.Armor.Astral public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusDamageBoost.ToPercent(), StarRainCooldown.FramesToSeconds()); var modPlayer = player.Calamity(); modPlayer.astralStarRain = true; modPlayer.omniscience = true; - player.GetDamage() += 0.1f; - player.maxMinions += 3; - player.GetCritChance() += 10; + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusDamageBoost; + player.GetCritChance() += SetBonusCritBoost; player.Calamity().wearingRogueArmor = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.05f; - player.GetCritChance() += 10; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Astral/AstralLeggings.cs b/Items/Armor/Astral/AstralLeggings.cs index 3a717b7f0c..ec9a0d4f04 100644 --- a/Items/Armor/Astral/AstralLeggings.cs +++ b/Items/Armor/Astral/AstralLeggings.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Astral @@ -9,6 +10,11 @@ namespace CalamityMod.Items.Armor.Astral public class AstralLeggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float DamageBoost = 0.1f; + public static float MoveSpeedBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -20,8 +26,8 @@ namespace CalamityMod.Items.Armor.Astral public override void UpdateEquip(Player player) { - player.moveSpeed += 0.15f; - player.GetDamage() += 0.05f; + player.GetDamage() += DamageBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Auric/AuricTeslaBodyArmor.cs b/Items/Armor/Auric/AuricTeslaBodyArmor.cs index caa5cbe2cc..85a854995b 100644 --- a/Items/Armor/Auric/AuricTeslaBodyArmor.cs +++ b/Items/Armor/Auric/AuricTeslaBodyArmor.cs @@ -1,4 +1,4 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; using CalamityMod.Items.Armor.Bloodflare; using CalamityMod.Items.Armor.GodSlayer; using CalamityMod.Items.Armor.Silva; @@ -6,8 +6,9 @@ using CalamityMod.Items.Armor.Tarragon; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Auric @@ -15,7 +16,18 @@ namespace CalamityMod.Items.Armor.Auric [AutoloadEquip(EquipType.Body)] public class AuricTeslaBodyArmor : ModItem, ILocalizedModType { + public static int setBonusTooltipNumber = 0; //Set this to zero so the first Shift pressed will increment it to 1. + public static bool holdingShift = false; + public static Color tooltipTarragonColor = new(194, 255, 194); + public static Color tooltipBloodflareColor = new(255, 195, 194); + public static Color tooltipSilvaColor = new(246, 255, 194); + public static Color tooltipGodslayerColor = new(204, 194, 255); public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.16f; + public static int CritBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + public override void Load() { // All code below runs only if we're not loading on a server @@ -31,16 +43,27 @@ namespace CalamityMod.Items.Armor.Auric Item.width = 38; Item.height = 34; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 48; - Item.rare = ModContent.RarityType(); + Item.defense = 44; + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - var modPlayer = player.Calamity(); - player.statLifeMax2 += 100; - player.GetDamage() += 0.08f; - player.GetCritChance() += 5; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + } + + public override void ModifyTooltips(List tooltips) + { + //This just runs the ModifyTooltips for whatever helmet is equipped if a full auric set is equipped; but runs it on this item's tooltips. + //This is a simple way to copy the tooltip edits for the set bonuses and have it adapt to helmet type. + //If we ever add a way for auricSet to be TRUE without a helmet on, this will need to be changed. + //If the helmet's ModifyTooltips is changed to do more than just the Set Bonus, their Set Bonus modification should be moved into it's own method, and have that called both here and in the helmet's ModifyTooltips. + //Alternatively, their ModifyTooltips could simply return early if the item ID doesn't match the helmet type. + if (Main.LocalPlayer.Calamity().auricSet) + { + Main.LocalPlayer.armor[0].ModItem.ModifyTooltips(tooltips); + } } public override void AddRecipes() diff --git a/Items/Armor/Auric/AuricTeslaCuisses.cs b/Items/Armor/Auric/AuricTeslaCuisses.cs index 1cb579a498..82d63d49bb 100644 --- a/Items/Armor/Auric/AuricTeslaCuisses.cs +++ b/Items/Armor/Auric/AuricTeslaCuisses.cs @@ -1,13 +1,19 @@ -using CalamityMod.Items.Armor.Bloodflare; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Items.Armor.Bloodflare; using CalamityMod.Items.Armor.GodSlayer; using CalamityMod.Items.Armor.Silva; using CalamityMod.Items.Armor.Tarragon; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Armor.Auric { @@ -15,21 +21,79 @@ namespace CalamityMod.Items.Armor.Auric public class AuricTeslaCuisses : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.12f; + public static int CritBoost = 10; + public static float MoveSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost, MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 44; - Item.rare = ModContent.RarityType(); + Item.defense = 42; + Item.rare = ModContent.RarityType(); } + #region Toggleable Magic Carpet + + bool toggleEnabled = true; + + public override bool CanRightClick() => Main.keyState.PressingShift(); + public override void RightClick(Player player) + { + toggleEnabled = !toggleEnabled; + Item.NetStateChanged(); + } + public override bool ConsumeItem(Player player) => false; + public override void SaveData(TagCompound tag) + { + tag.Add("toggleEffect", toggleEnabled); + } + + public override void LoadData(TagCompound tag) + { + toggleEnabled = tag.GetBool("toggleEffect"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(toggleEnabled); + } + + public override void NetReceive(BinaryReader reader) + { + toggleEnabled = reader.ReadBoolean(); + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled); + } +#endregion public override void UpdateEquip(Player player) { - player.moveSpeed += 0.1f; - player.carpet = true; - player.GetDamage() += 0.12f; - player.GetCritChance() += 5; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; + player.carpet = toggleEnabled; + } + + public override void ModifyTooltips(List tooltips) + { + //This just runs the ModifyTooltips for whatever helmet is equipped if a full auric set is equipped; but runs it on this item's tooltips. + //This is a simple way to copy the tooltip edits for the set bonuses and have it adapt to helmet type. + //If we ever add a way for auricSet to be TRUE without a helmet on, this will need to be changed. + //If the helmet's ModifyTooltips is changed to do more than just the Set Bonus, their Set Bonus modification should be moved into it's own method, and have that called both here and in the helmet's ModifyTooltips. + //Alternatively, their ModifyTooltips could simply return early if the item ID doesn't match the helmet type. + if (Main.LocalPlayer.Calamity().auricSet) + { + Main.LocalPlayer.armor[0].ModItem.ModifyTooltips(tooltips); + } + + if (!toggleEnabled) + tooltips.RemoveAll(x => x.Name == "Tooltip2"); } public override void AddRecipes() diff --git a/Items/Armor/Auric/AuricTeslaHeadMagic.cs b/Items/Armor/Auric/AuricTeslaHeadMagic.cs new file mode 100644 index 0000000000..7231f09ff0 --- /dev/null +++ b/Items/Armor/Auric/AuricTeslaHeadMagic.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.Silva; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.Items.Armor.Bloodflare.BloodflareHeadMagic; +using static CalamityMod.Items.Armor.Silva.SilvaArmor; + +namespace CalamityMod.Items.Armor.Auric +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AuricTeslaWireHemmedVisage")] + public class AuricTeslaHeadMagic : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static int MaxManaBoost = 100; + public static float ManaCostReduction = 0.2f; + public static float MagicDamageBoost = 0.22f; + public static int MagicCritBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost); + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.defense = 24; // 110 + Item.rare = ModContent.RarityType(); + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawOutlines = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalizedValue("SetBonus"); + var modPlayer = player.Calamity(); + modPlayer.tarraSet = true; + modPlayer.tarraMage = true; + modPlayer.bloodflareSet = true; + modPlayer.bloodflareMage = true; + modPlayer.silvaSet = true; + modPlayer.silvaMage = true; + modPlayer.auricSet = true; + player.crimsonRegen = true; // Inherited from Bloodflare + } + + public override void ModifyTooltips(List tooltips) + { + ref var holdingShift = ref AuricTeslaBodyArmor.holdingShift; + ref var setBonusTooltipNumber = ref AuricTeslaBodyArmor.setBonusTooltipNumber; + if (Main.keyState.PressingShift()) + { + if (!holdingShift) + { + holdingShift = true; + setBonusTooltipNumber++; + if (setBonusTooltipNumber > 3) setBonusTooltipNumber = 1; + } + foreach (TooltipLine line in tooltips) + { + if (line.Name == "SetBonus") + { + Color[] armorColors = { AuricTeslaBodyArmor.tooltipTarragonColor, AuricTeslaBodyArmor.tooltipBloodflareColor, AuricTeslaBodyArmor.tooltipSilvaColor }; + var LocalizedText = this.GetLocalization($"SetBonus{setBonusTooltipNumber}"); + line.Text = (setBonusTooltipNumber == 3 ? LocalizedText.Format(SetBonusRegenBoost.ToRegenPerSecond(), AccelerationBoost.ToPercent(), ReviveDuration.FramesToSeconds(), (ReviveCooldown / 60).FramesToSeconds()) + : setBonusTooltipNumber == 2 ? LocalizedText.Format(GhostBoltCooldown.FramesToSeconds(), BloodsplosionCooldown.FramesToSeconds()) + : LocalizedText.Format()); + line.OverrideColor = armorColors[setBonusTooltipNumber - 1]; + } + } + } + else + { + holdingShift = false; + } + } + public override void UpdateEquip(Player player) + { + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddIngredient(12). + AddTile(). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Auric/AuricTeslaWireHemmedVisage.png b/Items/Armor/Auric/AuricTeslaHeadMagic.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaWireHemmedVisage.png rename to Items/Armor/Auric/AuricTeslaHeadMagic.png diff --git a/Items/Armor/Auric/AuricTeslaWireHemmedVisage_Head.png b/Items/Armor/Auric/AuricTeslaHeadMagic_Head.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaWireHemmedVisage_Head.png rename to Items/Armor/Auric/AuricTeslaHeadMagic_Head.png diff --git a/Items/Armor/Auric/AuricTeslaHeadMelee.cs b/Items/Armor/Auric/AuricTeslaHeadMelee.cs new file mode 100644 index 0000000000..33839d713e --- /dev/null +++ b/Items/Armor/Auric/AuricTeslaHeadMelee.cs @@ -0,0 +1,114 @@ +using System.Collections.Generic; +using CalamityMod.CalPlayer.Dashes; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.GodSlayer; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.Items.Armor.Bloodflare.BloodflareHeadMelee; +using static CalamityMod.Items.Armor.GodSlayer.GodSlayerHeadMelee; +using static CalamityMod.Items.Armor.Tarragon.TarragonHeadMelee; + +namespace CalamityMod.Items.Armor.Auric +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AuricTeslaHelm")] + [LegacyName("AuricTeslaRoyalHelm")] + public class AuricTeslaHeadMelee : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float MeleeDamageBoost = 0.12f; + public static float MeleeSpeedBoost = 0.28f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent(), MeleeSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusAggroBoost = 1200; + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.defense = 54; // 140 + Item.rare = ModContent.RarityType(); + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawOutlines = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalizedValue("SetBonus"); + var modPlayer = player.Calamity(); + modPlayer.tarraSet = true; + modPlayer.tarraMelee = true; + modPlayer.bloodflareSet = true; + modPlayer.bloodflareMelee = true; + modPlayer.godSlayer = true; + modPlayer.godSlayerDamage = true; + modPlayer.auricSet = true; + modPlayer.auricSetMelee = true; + player.crimsonRegen = true; // Inherited from Bloodflare + player.aggro += SetBonusAggroBoost; + + if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) + modPlayer.DeferredDashID = GodslayerArmorDash.ID; + } + + public override void UpdateEquip(Player player) + { + player.GetDamage() += MeleeDamageBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; + } + + public override void ModifyTooltips(List tooltips) + { + ref var holdingShift = ref AuricTeslaBodyArmor.holdingShift; + ref var setBonusTooltipNumber = ref AuricTeslaBodyArmor.setBonusTooltipNumber; + if (Main.keyState.PressingShift()) + { + if (!holdingShift) + { + holdingShift = true; + setBonusTooltipNumber++; + if (setBonusTooltipNumber > 3) setBonusTooltipNumber = 1; + } + foreach (TooltipLine line in tooltips) + { + if (line.Name == "SetBonus") + { + Color[] armorColors = { AuricTeslaBodyArmor.tooltipTarragonColor, AuricTeslaBodyArmor.tooltipBloodflareColor, AuricTeslaBodyArmor.tooltipGodslayerColor }; + var LocalizedText = CalamityUtils.GetTextFromModItem(Type, $"SetBonus{setBonusTooltipNumber}"); + line.Text = (setBonusTooltipNumber == 3 ? LocalizedText.Format(SetBonusHurtDamageThreshold, CalamityKeybinds.GodSlayerDashHotKey.TooltipHotkeyString(), GodSlayerChestplate.DashCooldown.FramesToSeconds()) + : setBonusTooltipNumber == 2 ? LocalizedText.Format(HitsToActivateFrenzy, FrenzyDuration.FramesToSeconds(), FrenzyMeleeDamageBoost.ToPercent(), FrenzyContactDamageReduction.ToPercent(), FrenzyCooldown.FramesToSeconds()) + : LocalizedText.Format(TarraLifeRegenBoost.ToRegenPerSecond(), CalamityUtils.GetArmorSetBonusKey(), CloakDuration.FramesToSeconds(), CloakCooldown.FramesToSeconds())); + line.OverrideColor = armorColors[setBonusTooltipNumber - 1]; + } + } + } + else + { + holdingShift = false; + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddIngredient(12). + AddTile(). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Auric/AuricTeslaRoyalHelm.png b/Items/Armor/Auric/AuricTeslaHeadMelee.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaRoyalHelm.png rename to Items/Armor/Auric/AuricTeslaHeadMelee.png diff --git a/Items/Armor/Auric/AuricTeslaRoyalHelm_Head.png b/Items/Armor/Auric/AuricTeslaHeadMelee_Head.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaRoyalHelm_Head.png rename to Items/Armor/Auric/AuricTeslaHeadMelee_Head.png diff --git a/Items/Armor/Auric/AuricTeslaHeadRanged.cs b/Items/Armor/Auric/AuricTeslaHeadRanged.cs new file mode 100644 index 0000000000..fa54b263bd --- /dev/null +++ b/Items/Armor/Auric/AuricTeslaHeadRanged.cs @@ -0,0 +1,110 @@ +using System.Collections.Generic; +using CalamityMod.CalPlayer.Dashes; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.GodSlayer; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.Items.Armor.Bloodflare.BloodflareHeadRanged; +using static CalamityMod.Items.Armor.GodSlayer.GodSlayerHeadRanged; + +namespace CalamityMod.Items.Armor.Auric +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AuricTeslaHoodedFacemask")] + public class AuricTeslaHeadRanged : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RangedDamageBoost = 0.22f; + public static int RangedCritBoost = 20; + public static float AmmoReduction = 0.7f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), RangedCritBoost, (1f - AmmoReduction).ToPercent()); + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.defense = 39; // 125 + Item.rare = ModContent.RarityType(); + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawOutlines = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalizedValue("SetBonus"); + var modPlayer = player.Calamity(); + modPlayer.tarraSet = true; + modPlayer.tarraRanged = true; + modPlayer.bloodflareSet = true; + modPlayer.bloodflareRanged = true; + modPlayer.godSlayer = true; + modPlayer.godSlayerRanged = true; + modPlayer.auricSet = true; + player.crimsonRegen = true; // Inherited from Bloodflare + + if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) + modPlayer.DeferredDashID = GodslayerArmorDash.ID; + } + + public override void UpdateEquip(Player player) + { + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; + } + + public override void ModifyTooltips(List tooltips) + { + ref var holdingShift = ref AuricTeslaBodyArmor.holdingShift; + ref var setBonusTooltipNumber = ref AuricTeslaBodyArmor.setBonusTooltipNumber; + if (Main.keyState.PressingShift()) + { + if (!holdingShift) + { + holdingShift = true; + setBonusTooltipNumber++; + if (setBonusTooltipNumber > 3) setBonusTooltipNumber = 1; + } + foreach (TooltipLine line in tooltips) + { + if (line.Name == "SetBonus") + { + Color[] armorColors = { AuricTeslaBodyArmor.tooltipTarragonColor, AuricTeslaBodyArmor.tooltipBloodflareColor, AuricTeslaBodyArmor.tooltipGodslayerColor }; + var LocalizedText = CalamityUtils.GetTextFromModItem(Type, $"SetBonus{setBonusTooltipNumber}"); + line.Text = (setBonusTooltipNumber == 3 ? LocalizedText.Format(ShrapnelRoundCooldown.FramesToSeconds(), CalamityKeybinds.GodSlayerDashHotKey.TooltipHotkeyString(), GodSlayerChestplate.DashCooldown.FramesToSeconds()) + : setBonusTooltipNumber == 2 ? LocalizedText.Format(CalamityUtils.GetArmorSetBonusKey(), SoulCooldown.FramesToSeconds(), BloodBombCooldown.FramesToSeconds()) + : LocalizedText.Format()); + line.OverrideColor = armorColors[setBonusTooltipNumber - 1]; + } + } + } + else + { + holdingShift = false; + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddIngredient(12). + AddTile(). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Auric/AuricTeslaHoodedFacemask.png b/Items/Armor/Auric/AuricTeslaHeadRanged.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaHoodedFacemask.png rename to Items/Armor/Auric/AuricTeslaHeadRanged.png diff --git a/Items/Armor/Auric/AuricTeslaHoodedFacemask_Head.png b/Items/Armor/Auric/AuricTeslaHeadRanged_Head.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaHoodedFacemask_Head.png rename to Items/Armor/Auric/AuricTeslaHeadRanged_Head.png diff --git a/Items/Armor/Auric/AuricTeslaHeadRogue.cs b/Items/Armor/Auric/AuricTeslaHeadRogue.cs new file mode 100644 index 0000000000..6e73e4e0cc --- /dev/null +++ b/Items/Armor/Auric/AuricTeslaHeadRogue.cs @@ -0,0 +1,115 @@ +using System.Collections.Generic; +using CalamityMod.CalPlayer.Dashes; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.GodSlayer; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.Items.Armor.Bloodflare.BloodflareHeadRogue; +using static CalamityMod.Items.Armor.GodSlayer.GodSlayerHeadRogue; +using static CalamityMod.Items.Armor.Tarragon.TarragonHeadRogue; + +namespace CalamityMod.Items.Armor.Auric +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AuricTeslaPlumedHelm")] + public class AuricTeslaHeadRogue : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RogueDamageBoost = 0.17f; + public static int RogueCritBoost = 10; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.3f; + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.defense = 34; // 120 + Item.rare = ModContent.RarityType(); + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawOutlines = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth()); + var modPlayer = player.Calamity(); + modPlayer.tarraSet = true; + modPlayer.tarraThrowing = true; + modPlayer.bloodflareSet = true; + modPlayer.bloodflareThrowing = true; + modPlayer.godSlayer = true; + modPlayer.godSlayerThrowing = true; + modPlayer.auricSet = true; + modPlayer.rogueStealthMax += SetBonusRogueStealth; + modPlayer.wearingRogueArmor = true; + player.crimsonRegen = true; // Inherited from Bloodflare + + if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) + modPlayer.DeferredDashID = GodslayerArmorDash.ID; + } + + public override void UpdateEquip(Player player) + { + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; + } + + public override void ModifyTooltips(List tooltips) + { + ref var holdingShift = ref AuricTeslaBodyArmor.holdingShift; + ref var setBonusTooltipNumber = ref AuricTeslaBodyArmor.setBonusTooltipNumber; + if (Main.keyState.PressingShift()) + { + if (!holdingShift) + { + holdingShift = true; + setBonusTooltipNumber++; + if (setBonusTooltipNumber > 3) setBonusTooltipNumber = 1; + } + foreach (TooltipLine line in tooltips) + { + if (line.Name == "SetBonus") + { + Color[] armorColors = { AuricTeslaBodyArmor.tooltipTarragonColor, AuricTeslaBodyArmor.tooltipBloodflareColor, AuricTeslaBodyArmor.tooltipGodslayerColor }; + var LocalizedText = CalamityUtils.GetTextFromModItem(Type, $"SetBonus{setBonusTooltipNumber}"); + line.Text = (setBonusTooltipNumber == 3 ? LocalizedText.Format(RogueDamageBoostAtFullHealth.ToPercent(), SetBonusHurtDamageThreshold, CalamityKeybinds.GodSlayerDashHotKey.TooltipHotkeyString(), GodSlayerChestplate.DashCooldown.FramesToSeconds()) + : setBonusTooltipNumber == 2 ? LocalizedText.Format(DefenseBoostAboveHealthThreshold, DefenseBoostHealthThreshold.ToPercent()) + : LocalizedText.Format(CritsToActivateImmunity, ImmunityDuration.FramesToSeconds(), ImmunityCooldown.FramesToSeconds(), RogueDamageBoostWhileDebuffed.ToPercent())); + line.OverrideColor = armorColors[setBonusTooltipNumber - 1]; + } + } + } + else + { + holdingShift = false; + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddIngredient(12). + AddTile(). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Auric/AuricTeslaPlumedHelm.png b/Items/Armor/Auric/AuricTeslaHeadRogue.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaPlumedHelm.png rename to Items/Armor/Auric/AuricTeslaHeadRogue.png diff --git a/Items/Armor/Auric/AuricTeslaPlumedHelm_Head.png b/Items/Armor/Auric/AuricTeslaHeadRogue_Head.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaPlumedHelm_Head.png rename to Items/Armor/Auric/AuricTeslaHeadRogue_Head.png diff --git a/Items/Armor/Auric/AuricTeslaHeadSummon.cs b/Items/Armor/Auric/AuricTeslaHeadSummon.cs new file mode 100644 index 0000000000..afe538c9a8 --- /dev/null +++ b/Items/Armor/Auric/AuricTeslaHeadSummon.cs @@ -0,0 +1,111 @@ +using System.Collections.Generic; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.Silva; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Materials; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.Items.Armor.Bloodflare.BloodflareHeadSummon; +using static CalamityMod.Items.Armor.Silva.SilvaArmor; + +namespace CalamityMod.Items.Armor.Auric +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("AuricTeslaSpaceHelmet")] + public class AuricTeslaHeadSummon : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static int MinionSlotBoost = 2; + public static float SummonDamageBoost = 0.32f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 4; + public static float SetBonusSummonDamageBoost = 0.55f; + public static int CrystalDamage = 500; + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.defense = 18; // 104 + Item.rare = ModContent.RarityType(); + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawOutlines = true; + + public override void UpdateArmorSet(Player player) + { + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent()); + var modPlayer = player.Calamity(); + modPlayer.tarraSet = true; + modPlayer.tarraSummon = true; + modPlayer.bloodflareSet = true; + modPlayer.bloodflareSummon = true; + modPlayer.silvaSet = true; + modPlayer.silvaSummon = true; + modPlayer.auricSet = true; + modPlayer.WearingPostMLSummonerSet = true; + player.crimsonRegen = true; // Inherited from Bloodflare + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; + } + + public override void UpdateEquip(Player player) + { + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; + } + + public override void ModifyTooltips(List tooltips) + { + ref var holdingShift = ref AuricTeslaBodyArmor.holdingShift; + ref var setBonusTooltipNumber = ref AuricTeslaBodyArmor.setBonusTooltipNumber; + if (Main.keyState.PressingShift()) + { + if (!holdingShift) + { + holdingShift = true; + setBonusTooltipNumber++; + if (setBonusTooltipNumber > 3) setBonusTooltipNumber = 1; + } + foreach (TooltipLine line in tooltips) + { + if (line.Name == "SetBonus") + { + Color[] armorColors = { AuricTeslaBodyArmor.tooltipTarragonColor, AuricTeslaBodyArmor.tooltipBloodflareColor, AuricTeslaBodyArmor.tooltipSilvaColor }; + var LocalizedText = this.GetLocalization($"SetBonus{setBonusTooltipNumber}"); + line.Text = (setBonusTooltipNumber == 3 ? LocalizedText.Format(SetBonusRegenBoost.ToRegenPerSecond(), AccelerationBoost.ToPercent(), ReviveDuration.FramesToSeconds(), (ReviveCooldown / 60).FramesToSeconds()) + : setBonusTooltipNumber == 2 ? LocalizedText.Format(DefenseBoostBelowHealthThreshold, DefenseBoostHealthThreshold.ToPercent()) + : LocalizedText.Format()); + line.OverrideColor = armorColors[setBonusTooltipNumber - 1]; + } + } + } + else + { + holdingShift = false; + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddIngredient(12). + AddTile(). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Auric/AuricTeslaSpaceHelmet.png b/Items/Armor/Auric/AuricTeslaHeadSummon.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaSpaceHelmet.png rename to Items/Armor/Auric/AuricTeslaHeadSummon.png diff --git a/Items/Armor/Auric/AuricTeslaSpaceHelmet_Head.png b/Items/Armor/Auric/AuricTeslaHeadSummon_Head.png similarity index 100% rename from Items/Armor/Auric/AuricTeslaSpaceHelmet_Head.png rename to Items/Armor/Auric/AuricTeslaHeadSummon_Head.png diff --git a/Items/Armor/Auric/AuricTeslaHoodedFacemask.cs b/Items/Armor/Auric/AuricTeslaHoodedFacemask.cs deleted file mode 100644 index db0aaa3a4e..0000000000 --- a/Items/Armor/Auric/AuricTeslaHoodedFacemask.cs +++ /dev/null @@ -1,77 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.CalPlayer.Dashes; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Bloodflare; -using CalamityMod.Items.Armor.GodSlayer; -using CalamityMod.Items.Armor.Tarragon; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Auric -{ - [AutoloadEquip(EquipType.Head)] - public class AuricTeslaHoodedFacemask : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PostMoonLord"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 40; //132 - Item.rare = ModContent.RarityType(); - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawOutlines = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus"); - var modPlayer = player.Calamity(); - modPlayer.tarraSet = true; - modPlayer.tarraRanged = true; - modPlayer.bloodflareSet = true; - modPlayer.bloodflareRanged = true; - modPlayer.godSlayer = true; - modPlayer.godSlayerRanged = true; - modPlayer.auricSet = true; - player.thorns += 3f; - player.ignoreWater = true; - player.crimsonRegen = true; - - if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) - modPlayer.DeferredDashID = GodslayerArmorDash.ID; - } - - public override void UpdateEquip(Player player) - { - var modPlayer = player.Calamity(); - modPlayer.auricBoost = true; - player.GetDamage() += 0.3f; - player.GetCritChance() += 30; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(). - AddIngredient(12). - AddTile(). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Auric/AuricTeslaPlumedHelm.cs b/Items/Armor/Auric/AuricTeslaPlumedHelm.cs deleted file mode 100644 index 69eaa3d741..0000000000 --- a/Items/Armor/Auric/AuricTeslaPlumedHelm.cs +++ /dev/null @@ -1,79 +0,0 @@ -using CalamityMod.CalPlayer.Dashes; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Bloodflare; -using CalamityMod.Items.Armor.GodSlayer; -using CalamityMod.Items.Armor.Tarragon; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Auric -{ - [AutoloadEquip(EquipType.Head)] - public class AuricTeslaPlumedHelm : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PostMoonLord"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 34; //132 - Item.rare = ModContent.RarityType(); - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawOutlines = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus"); - var modPlayer = player.Calamity(); - modPlayer.tarraSet = true; - modPlayer.tarraThrowing = true; - modPlayer.bloodflareSet = true; - modPlayer.bloodflareThrowing = true; - modPlayer.godSlayer = true; - modPlayer.godSlayerThrowing = true; - modPlayer.auricSet = true; - modPlayer.rogueStealthMax += 1.3f; - modPlayer.wearingRogueArmor = true; - player.thorns += 3f; - player.ignoreWater = true; - player.crimsonRegen = true; - - if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) - modPlayer.DeferredDashID = GodslayerArmorDash.ID; - } - - public override void UpdateEquip(Player player) - { - var modPlayer = player.Calamity(); - modPlayer.auricBoost = true; - player.GetDamage() += 0.2f; - player.GetCritChance() += 20; - player.moveSpeed += 0.05f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(). - AddIngredient(12). - AddTile(). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Auric/AuricTeslaRoyalHelm.cs b/Items/Armor/Auric/AuricTeslaRoyalHelm.cs deleted file mode 100644 index 078a350ff0..0000000000 --- a/Items/Armor/Auric/AuricTeslaRoyalHelm.cs +++ /dev/null @@ -1,81 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.CalPlayer.Dashes; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Bloodflare; -using CalamityMod.Items.Armor.GodSlayer; -using CalamityMod.Items.Armor.Tarragon; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Auric -{ - [AutoloadEquip(EquipType.Head)] - [LegacyName("AuricTeslaHelm")] - public class AuricTeslaRoyalHelm : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PostMoonLord"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 54; //132 - Item.rare = ModContent.RarityType(); - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawOutlines = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus"); - var modPlayer = player.Calamity(); - player.GetAttackSpeed() += 0.28f; - modPlayer.tarraSet = true; - modPlayer.tarraMelee = true; - modPlayer.bloodflareSet = true; - modPlayer.bloodflareMelee = true; - modPlayer.godSlayer = true; - modPlayer.godSlayerDamage = true; - modPlayer.auricSet = true; - modPlayer.auricSetMelee = true; - player.thorns += 3f; - player.ignoreWater = true; - player.crimsonRegen = true; - player.aggro += 1200; - - if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) - modPlayer.DeferredDashID = GodslayerArmorDash.ID; - } - - public override void UpdateEquip(Player player) - { - var modPlayer = player.Calamity(); - modPlayer.auricBoost = true; - player.GetDamage() += 0.2f; - player.GetCritChance() += 10; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(). - AddIngredient(12). - AddTile(). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Auric/AuricTeslaSpaceHelmet.cs b/Items/Armor/Auric/AuricTeslaSpaceHelmet.cs deleted file mode 100644 index fdc49f0a7a..0000000000 --- a/Items/Armor/Auric/AuricTeslaSpaceHelmet.cs +++ /dev/null @@ -1,77 +0,0 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Bloodflare; -using CalamityMod.Items.Armor.Silva; -using CalamityMod.Items.Armor.Tarragon; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Summon; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Auric -{ - [AutoloadEquip(EquipType.Head)] - public class AuricTeslaSpaceHelmet : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PostMoonLord"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 12; //132 - Item.rare = ModContent.RarityType(); - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawOutlines = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus"); - var modPlayer = player.Calamity(); - modPlayer.tarraSet = true; - modPlayer.tarraSummon = true; - modPlayer.bloodflareSet = true; - modPlayer.bloodflareSummon = true; - modPlayer.silvaSet = true; - modPlayer.silvaSummon = true; - modPlayer.auricSet = true; - modPlayer.WearingPostMLSummonerSet = true; - player.thorns += 3f; - player.ignoreWater = true; - player.crimsonRegen = true; - player.GetDamage() += 0.75f; - player.maxMinions += 6; - } - - public override void UpdateEquip(Player player) - { - var modPlayer = player.Calamity(); - modPlayer.auricBoost = true; - player.GetDamage() += 0.15f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(). - AddIngredient(12). - AddTile(). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Auric/AuricTeslaWireHemmedVisage.cs b/Items/Armor/Auric/AuricTeslaWireHemmedVisage.cs deleted file mode 100644 index 18993c56ec..0000000000 --- a/Items/Armor/Auric/AuricTeslaWireHemmedVisage.cs +++ /dev/null @@ -1,75 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Bloodflare; -using CalamityMod.Items.Armor.Silva; -using CalamityMod.Items.Armor.Tarragon; -using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Auric -{ - [AutoloadEquip(EquipType.Head)] - public class AuricTeslaWireHemmedVisage : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PostMoonLord"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 24; //132 - Item.rare = ModContent.RarityType(); - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawOutlines = true; - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus"); - var modPlayer = player.Calamity(); - modPlayer.tarraSet = true; - modPlayer.tarraMage = true; - modPlayer.bloodflareSet = true; - modPlayer.bloodflareMage = true; - modPlayer.silvaSet = true; - modPlayer.silvaMage = true; - modPlayer.auricSet = true; - player.thorns += 3f; - player.ignoreWater = true; - player.crimsonRegen = true; - } - - public override void UpdateEquip(Player player) - { - var modPlayer = player.Calamity(); - modPlayer.auricBoost = true; - player.manaCost *= 0.8f; - player.GetDamage() += 0.3f; - player.GetCritChance() += 20; - player.statManaMax2 += 100; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(). - AddIngredient(12). - AddTile(). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Bloodflare/BloodflareBodyArmor.cs b/Items/Armor/Bloodflare/BloodflareBodyArmor.cs index 7139b25e18..5dcf752f3e 100644 --- a/Items/Armor/Bloodflare/BloodflareBodyArmor.cs +++ b/Items/Armor/Bloodflare/BloodflareBodyArmor.cs @@ -2,6 +2,7 @@ using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Bloodflare @@ -10,20 +11,24 @@ namespace CalamityMod.Items.Armor.Bloodflare public class BloodflareBodyArmor : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.12f; + public static int CritBoost = 8; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.defense = 35; + Item.defense = 36; Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.statLifeMax2 += 40; - player.GetDamage() += 0.12f; - player.GetCritChance() += 8; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; } public override void AddRecipes() @@ -31,7 +36,7 @@ namespace CalamityMod.Items.Armor.Bloodflare CreateRecipe(). AddIngredient(16). AddIngredient(4). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Armor/Bloodflare/BloodflareCuisses.cs b/Items/Armor/Bloodflare/BloodflareCuisses.cs index a34517488d..b037201ed0 100644 --- a/Items/Armor/Bloodflare/BloodflareCuisses.cs +++ b/Items/Armor/Bloodflare/BloodflareCuisses.cs @@ -2,6 +2,7 @@ using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Bloodflare @@ -10,20 +11,26 @@ namespace CalamityMod.Items.Armor.Bloodflare public class BloodflareCuisses : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.1f; + public static int CritBoost = 7; + public static float MoveSpeedBoost = 0.17f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost, MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.defense = 29; + Item.defense = 28; Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.moveSpeed += 0.17f; - player.GetDamage() += 0.1f; - player.GetCritChance() += 7; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() @@ -31,7 +38,7 @@ namespace CalamityMod.Items.Armor.Bloodflare CreateRecipe(). AddIngredient(13). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Armor/Bloodflare/BloodflareHeadMagic.cs b/Items/Armor/Bloodflare/BloodflareHeadMagic.cs index f3da4ef71c..a61f3e79c9 100644 --- a/Items/Armor/Bloodflare/BloodflareHeadMagic.cs +++ b/Items/Armor/Bloodflare/BloodflareHeadMagic.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Bloodflare @@ -12,40 +12,49 @@ namespace CalamityMod.Items.Armor.Bloodflare public class BloodflareHeadMagic : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static int MaxManaBoost = 100; + public static float ManaCostReduction = 0.17f; + public static float MagicDamageBoost = 0.2f; + public static int MagicCritBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost); + + // Set Bonus + public static int GhostBoltCooldown = CalamityUtils.SecondsToFrames(1.67f); + public static double GhostBoltDamageRatio = 1.3D; + public static int GhostBoltonDamageSoftcap = 2600; + public static int BloodsplosionCooldown = CalamityUtils.SecondsToFrames(2); + public static double BloodsplosionDamageRatio = 0.5D; + public static int BloodsplosionDamageSoftcap = 250; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.defense = 22; //85 + Item.defense = 18; // 82 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadowSubtle = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadowSubtle = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.bloodflareSet = true; modPlayer.bloodflareMage = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(GhostBoltCooldown.FramesToSeconds(), BloodsplosionCooldown.FramesToSeconds()); player.crimsonRegen = true; } public override void UpdateEquip(Player player) { - player.manaCost *= 0.83f; - player.GetDamage() += 0.2f; - player.GetCritChance() += 10; - player.statManaMax2 += 100; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; } public override void AddRecipes() @@ -53,7 +62,7 @@ namespace CalamityMod.Items.Armor.Bloodflare CreateRecipe(). AddIngredient(11). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Bloodflare/BloodflareHeadMelee.cs b/Items/Armor/Bloodflare/BloodflareHeadMelee.cs index 542373cdbc..bf15e2dad8 100644 --- a/Items/Armor/Bloodflare/BloodflareHeadMelee.cs +++ b/Items/Armor/Bloodflare/BloodflareHeadMelee.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Bloodflare @@ -12,40 +12,49 @@ namespace CalamityMod.Items.Armor.Bloodflare public class BloodflareHeadMelee : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float MeleeDamageBoost = 0.1f; + public static int MeleeCritBoost = 5; + public static float MeleeSpeedBoost = 0.18f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent(), MeleeCritBoost, MeleeSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusAggroBoost = 900; + public static int HitsToActivateFrenzy = 15; + public static float FrenzyMeleeDamageBoost = 0.25f; + public static int FrenzyMeleeCritBoost = 25; // NOTE: Tooltip shares this number with damage % as they're equal + public static float FrenzyContactDamageReduction = 0.5f; + public static int FrenzyDuration = CalamityUtils.SecondsToFrames(5); + public static int FrenzyCooldown = CalamityUtils.SecondsToFrames(30); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.defense = 49; //85 + Item.defense = 44; // 108 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadowSubtle = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadowSubtle = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); - player.GetAttackSpeed() += 0.18f; modPlayer.bloodflareSet = true; modPlayer.bloodflareMelee = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.aggro += SetBonusAggroBoost; + player.setBonus = this.GetLocalization("SetBonus").Format(HitsToActivateFrenzy, FrenzyDuration.FramesToSeconds(), FrenzyMeleeDamageBoost.ToPercent(), FrenzyContactDamageReduction.ToPercent(), FrenzyCooldown.FramesToSeconds()); player.crimsonRegen = true; - player.aggro += 900; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 5; + player.GetDamage() += MeleeDamageBoost; + player.GetCritChance() += MeleeCritBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; } public override void AddRecipes() @@ -53,7 +62,7 @@ namespace CalamityMod.Items.Armor.Bloodflare CreateRecipe(). AddIngredient(11). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Bloodflare/BloodflareHeadRanged.cs b/Items/Armor/Bloodflare/BloodflareHeadRanged.cs index a1bef0cca6..79d94d6d44 100644 --- a/Items/Armor/Bloodflare/BloodflareHeadRanged.cs +++ b/Items/Armor/Bloodflare/BloodflareHeadRanged.cs @@ -1,9 +1,9 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.Audio; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Bloodflare @@ -15,39 +15,47 @@ namespace CalamityMod.Items.Armor.Bloodflare public new string LocalizationCategory => "Items.Armor.PostMoonLord"; public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/BloodflareRangerActivation"); + public static float RangedDamageBoost = 0.1f; + public static float AmmoReduction = 0.75f; + public static int RangedCritBoost = 10; // NOTE: Tooltip shares this number with damage % as they're equal + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), (1f - AmmoReduction).ToPercent()); + + // Set Bonus + public static int SoulCooldown = CalamityUtils.SecondsToFrames(30); + public static int SoulDamage = 300; + public static int SoulAmount = 16; + public static int BloodBombCooldown = CalamityUtils.SecondsToFrames(2.5f); + public static double BloodBombDamageRatio = 0.8D; + public static int BloodBombDamageSoftcap = 120; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.defense = 34; //85 + Item.defense = 30; // 94 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadowSubtle = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadowSubtle = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.bloodflareSet = true; modPlayer.bloodflareRanged = true; - var hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey) + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(CalamityUtils.GetArmorSetBonusKey(), SoulCooldown.FramesToSeconds(), BloodBombCooldown.FramesToSeconds()); player.crimsonRegen = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() @@ -55,7 +63,7 @@ namespace CalamityMod.Items.Armor.Bloodflare CreateRecipe(). AddIngredient(11). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Bloodflare/BloodflareHeadRogue.cs b/Items/Armor/Bloodflare/BloodflareHeadRogue.cs index 75e086447a..1eb93b9746 100644 --- a/Items/Armor/Bloodflare/BloodflareHeadRogue.cs +++ b/Items/Armor/Bloodflare/BloodflareHeadRogue.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Bloodflare @@ -12,41 +12,46 @@ namespace CalamityMod.Items.Armor.Bloodflare public class BloodflareHeadRogue : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RogueDamageBoost = 0.15f; + public static int RogueCritBoost = 10; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.2f; + public static int DefenseBoostAboveHealthThreshold = 30; + public static float DefenseBoostHealthThreshold = 0.8f; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.defense = 28; //85 + Item.defense = 26; // 90 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadowSubtle = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadowSubtle = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.bloodflareSet = true; modPlayer.bloodflareThrowing = true; - modPlayer.rogueStealthMax += 1.2f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), DefenseBoostAboveHealthThreshold, DefenseBoostHealthThreshold.ToPercent()); player.crimsonRegen = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; - player.moveSpeed += 0.05f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() @@ -54,7 +59,7 @@ namespace CalamityMod.Items.Armor.Bloodflare CreateRecipe(). AddIngredient(11). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Bloodflare/BloodflareHeadSummon.cs b/Items/Armor/Bloodflare/BloodflareHeadSummon.cs index 0aa577c5bb..22204e8e7c 100644 --- a/Items/Armor/Bloodflare/BloodflareHeadSummon.cs +++ b/Items/Armor/Bloodflare/BloodflareHeadSummon.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Bloodflare @@ -14,24 +14,30 @@ namespace CalamityMod.Items.Armor.Bloodflare public new string LocalizationCategory => "Items.Armor.PostMoonLord"; internal static string GhostMineEntitySourceContext => "SetBonus_Calamity_BloodflareSummon"; + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.3f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 2; + public static float SetBonusSummonDamageBoost = 0.3f; + public static int MineDamage = 3750; + public static int MineCooldown = 900; + public static int DefenseBoostBelowHealthThreshold = 20; + public static float DefenseBoostHealthThreshold = 0.5f; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.defense = 16; //85 + Item.defense = 12; // 76 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadowSubtle = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadowSubtle = true; public override void UpdateArmorSet(Player player) { @@ -39,15 +45,16 @@ namespace CalamityMod.Items.Armor.Bloodflare modPlayer.bloodflareSet = true; modPlayer.bloodflareSummon = true; modPlayer.WearingPostMLSummonerSet = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent(), DefenseBoostBelowHealthThreshold, DefenseBoostHealthThreshold.ToPercent()); player.crimsonRegen = true; - player.GetDamage() += 0.5f; - player.maxMinions += 3; + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.05f; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; } public override void AddRecipes() @@ -55,7 +62,7 @@ namespace CalamityMod.Items.Armor.Bloodflare CreateRecipe(). AddIngredient(11). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Brimflame/BrimflameBoots.cs b/Items/Armor/Brimflame/BrimflameBoots.cs index e7b55aacd2..76732610d6 100644 --- a/Items/Armor/Brimflame/BrimflameBoots.cs +++ b/Items/Armor/Brimflame/BrimflameBoots.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Brimflame @@ -9,19 +10,24 @@ namespace CalamityMod.Items.Armor.Brimflame public class BrimflameBoots : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float MagicDamageBoost = 0.05f; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MagicDamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 15; + Item.defense = 13; } public override void UpdateEquip(Player player) { - player.moveSpeed += 0.05f; - player.GetDamage() += 0.05f; + player.GetDamage() += MagicDamageBoost; + player.moveSpeed += MoveSpeedBoost; player.fireWalk = true; } diff --git a/Items/Armor/Brimflame/BrimflameCowl.cs b/Items/Armor/Brimflame/BrimflameCowl.cs new file mode 100644 index 0000000000..753d63d6ab --- /dev/null +++ b/Items/Armor/Brimflame/BrimflameCowl.cs @@ -0,0 +1,77 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Brimflame +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("BrimflameScowl")] + public class BrimflameCowl : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.Hardmode"; + public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/BrimflameAbility"); + + public static int MaxManaBoost = 80; + public static float ManaCostReduction = 0.1f; + public static float MagicDamageBoost = 0.1f; + public static int MagicCritBoost = 10; // NOTE: Tooltip shares this number with damage % as they're equal + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent()); + + // Set Bonus + public static float SetBonusMagicDamageBoost = 0.08f; + public static int SetBonusMagicCritBoost = 8; // NOTE: Tooltip shares this number with damage % as they're equal + public static float FrenzyMagicDamageBoost = 0.4f; + public static int FrenzyDuration = CalamityUtils.SecondsToFrames(10); + public static int FrenzyCooldown = CalamityUtils.SecondsToFrames(30); + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityLimeBuyPrice; + Item.rare = ItemRarityID.Lime; + Item.defense = 12; + } + + public override void UpdateEquip(Player player) + { + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.buffImmune[ModContent.BuffType()] = true; + player.buffImmune[BuffID.OnFire] = true; + player.buffImmune[BuffID.Frostburn] = true; + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadowSubtle = true; + + public override void UpdateArmorSet(Player player) + { + var modPlayer = player.Calamity(); + modPlayer.brimflameSet = true; + player.GetDamage() += SetBonusMagicDamageBoost; + player.GetCritChance() += SetBonusMagicCritBoost; + Color AbilityBriefColor = Color.Lerp(new Color(250, 202, 140), new Color(227, 79, 79), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMagicDamageBoost.ToPercent(), AbilityBriefColor.Hex3(), CalamityUtils.GetArmorSetBonusKey(), FrenzyDuration.FramesToSeconds(), FrenzyMagicDamageBoost.ToPercent(), FrenzyCooldown.FramesToSeconds()); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(2). + AddTile(TileID.MythrilAnvil). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Brimflame/BrimflameScowl.png b/Items/Armor/Brimflame/BrimflameCowl.png similarity index 100% rename from Items/Armor/Brimflame/BrimflameScowl.png rename to Items/Armor/Brimflame/BrimflameCowl.png diff --git a/Items/Armor/Brimflame/BrimflameScowl_Head.png b/Items/Armor/Brimflame/BrimflameCowl_Head.png similarity index 100% rename from Items/Armor/Brimflame/BrimflameScowl_Head.png rename to Items/Armor/Brimflame/BrimflameCowl_Head.png diff --git a/Items/Armor/Brimflame/BrimflameRobes.cs b/Items/Armor/Brimflame/BrimflameRobes.cs index 8e2ba2b87b..e729bb80ae 100644 --- a/Items/Armor/Brimflame/BrimflameRobes.cs +++ b/Items/Armor/Brimflame/BrimflameRobes.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Brimflame @@ -9,9 +10,13 @@ namespace CalamityMod.Items.Armor.Brimflame public class BrimflameRobes : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float MagicDamageBoost = 0.07f; + public static int MagicCritBoost = 7; // NOTE: Tooltip shares this number with damage % as they're equal + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MagicDamageBoost.ToPercent()); + public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -27,13 +32,13 @@ namespace CalamityMod.Items.Armor.Brimflame Item.height = 18; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 15; + Item.defense = 16; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.05f; - player.GetCritChance() += 5; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Brimflame/BrimflameScowl.cs b/Items/Armor/Brimflame/BrimflameScowl.cs deleted file mode 100644 index 24be230104..0000000000 --- a/Items/Armor/Brimflame/BrimflameScowl.cs +++ /dev/null @@ -1,94 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using CalamityMod.Cooldowns; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Brimflame -{ - [AutoloadEquip(EquipType.Head)] - public class BrimflameScowl : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.Hardmode"; - public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/AngelicAllianceActivation"); - - // TODO -- what the fuck is this? this is not how you implement a set bonus - private bool frenzy = false; - public static int CooldownLength = 1800; - - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityLimeBuyPrice; - Item.rare = ItemRarityID.Lime; - Item.defense = 11; - } - - private void UpdateFrenzy(Player player) - { - var modPlayer = player.Calamity(); - if (!frenzy) - { - if (modPlayer.brimflameFrenzy) - frenzy = true; - } - else - { - if (!modPlayer.brimflameFrenzy) - { - frenzy = false; - player.AddCooldown(BrimflameFrenzy.ID, CooldownLength); - } - } - - if (frenzy) - player.GetDamage() += 0.4f; - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.05f; - player.GetCritChance() += 5; - player.statManaMax2 += 80; - player.manaCost *= 0.9f; - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[BuffID.OnFire] = true; - player.buffImmune[BuffID.Frostburn] = true; - UpdateFrenzy(player); - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadowSubtle = true; - } - - public override void UpdateArmorSet(Player player) - { - var modPlayer = player.Calamity(); - modPlayer.brimflameSet = true; - player.GetDamage() += 0.15f; - player.GetCritChance() += 15; - var hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddIngredient(2). - AddTile(TileID.MythrilAnvil). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/CirrusDress.cs b/Items/Armor/CirrusDress.cs deleted file mode 100644 index 4436d3cea4..0000000000 --- a/Items/Armor/CirrusDress.cs +++ /dev/null @@ -1,58 +0,0 @@ -using CalamityMod.Rarities; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor -{ - [AutoloadEquip(EquipType.Body)] - public class CirrusDress : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.Hardmode"; - /* How to obtain - * 1 - Have alcohol poisoning - * 2 - Visit the Stylist while Cirrus is alive in the world - * 3 - Open her shop to find the dress - */ - - public override void Load() - { - if (!Main.dedServ) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Armor/CirrusDress_Legs", EquipType.Legs, this); - } - } - - public override void SetStaticDefaults() - { - - if (Main.dedServ) - return; - int equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); - ArmorIDs.Body.Sets.HidesHands[equipSlot] = true; - } - - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; - Item.rare = ModContent.RarityType(); - Item.Calamity().devItem = true; - Item.defense = 8; - } - - public override void UpdateEquip(Player player) - { - player.Calamity().cirrusDress = true; - player.GetDamage() += 0.05f; - player.GetCritChance() += 5; - } - - public override void SetMatch(bool male, ref int equipSlot, ref bool robes) - { - robes = true; - equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); - } - } -} diff --git a/Items/Armor/CirrusDress.png b/Items/Armor/CirrusDress.png deleted file mode 100644 index 8bd29e2f48..0000000000 Binary files a/Items/Armor/CirrusDress.png and /dev/null differ diff --git a/Items/Armor/CirrusDress_Body.png b/Items/Armor/CirrusDress_Body.png deleted file mode 100644 index 779ae0e094..0000000000 Binary files a/Items/Armor/CirrusDress_Body.png and /dev/null differ diff --git a/Items/Armor/CirrusDress_Legs.png b/Items/Armor/CirrusDress_Legs.png deleted file mode 100644 index 42e4842b43..0000000000 Binary files a/Items/Armor/CirrusDress_Legs.png and /dev/null differ diff --git a/Items/Armor/Daedalus/DaedalusBreastplate.cs b/Items/Armor/Daedalus/DaedalusBreastplate.cs index 9b81c403db..fd2394ccd7 100644 --- a/Items/Armor/Daedalus/DaedalusBreastplate.cs +++ b/Items/Armor/Daedalus/DaedalusBreastplate.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Daedalus @@ -9,6 +10,10 @@ namespace CalamityMod.Items.Armor.Daedalus public class DaedalusBreastplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float DamageBoost = 0.08f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent()); + public override void Load() { if (Main.dedServ) @@ -23,14 +28,10 @@ namespace CalamityMod.Items.Armor.Daedalus Item.height = 18; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 19; //41 + Item.defense = 19; } - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.03f; - player.GetCritChance() += 3; - } + public override void UpdateEquip(Player player) => player.GetDamage() += DamageBoost; public override void AddRecipes() { diff --git a/Items/Armor/Daedalus/DaedalusHeadMagic.cs b/Items/Armor/Daedalus/DaedalusHeadMagic.cs index 1601c041ce..d169b687ba 100644 --- a/Items/Armor/Daedalus/DaedalusHeadMagic.cs +++ b/Items/Armor/Daedalus/DaedalusHeadMagic.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Daedalus @@ -11,19 +11,27 @@ namespace CalamityMod.Items.Armor.Daedalus public class DaedalusHeadMagic : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MaxManaBoost = 80; + public static float ManaCostReduction = 0.1f; + public static float MagicDamageBoost = 0.13f; + public static int MagicCritBoost = 7; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost); + + // Set Bonus + public static int AbsorptionChanceDenominator = 10; + public static float DamageAbsorptionPercent = 0.5f; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 5; //35 + Item.defense = 5; // 39 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -33,18 +41,17 @@ namespace CalamityMod.Items.Armor.Daedalus public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(AbsorptionChanceDenominator.GetChanceFromDenominator(), DamageAbsorptionPercent.ToPercent()); var modPlayer = player.Calamity(); modPlayer.daedalusAbsorb = true; - player.GetDamage() += 0.05f; } public override void UpdateEquip(Player player) { - player.manaCost *= 0.9f; - player.GetDamage() += 0.13f; - player.GetCritChance() += 7; - player.statManaMax2 += 60; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Daedalus/DaedalusHeadMelee.cs b/Items/Armor/Daedalus/DaedalusHeadMelee.cs index 1b63761a78..db0b4c87ef 100644 --- a/Items/Armor/Daedalus/DaedalusHeadMelee.cs +++ b/Items/Armor/Daedalus/DaedalusHeadMelee.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Daedalus @@ -11,19 +11,27 @@ namespace CalamityMod.Items.Armor.Daedalus public class DaedalusHeadMelee : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float MeleeDamageBoost = 0.1f; + public static int MeleeCritBoost = 10; // NOTE: Tooltip shares this number with damage % as they're equal + public static float MeleeSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent(), MeleeSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusAggroBoost = 500; + public static int ReflectCooldownMin = CalamityUtils.SecondsToFrames(20); + public static int ReflectCooldownMax = CalamityUtils.SecondsToFrames(90); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 21; //51 + Item.defense = 21; // 55 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -36,14 +44,14 @@ namespace CalamityMod.Items.Armor.Daedalus player.setBonus = this.GetLocalizedValue("SetBonus"); var modPlayer = player.Calamity(); modPlayer.daedalusReflect = true; - player.GetAttackSpeed() += 0.1f; - player.aggro += 500; + player.aggro += SetBonusAggroBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.15f; - player.GetCritChance() += 10; + player.GetDamage() += MeleeDamageBoost; + player.GetCritChance() += MeleeCritBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Daedalus/DaedalusHeadRanged.cs b/Items/Armor/Daedalus/DaedalusHeadRanged.cs index bf2f380bd3..5a62695eb4 100644 --- a/Items/Armor/Daedalus/DaedalusHeadRanged.cs +++ b/Items/Armor/Daedalus/DaedalusHeadRanged.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Daedalus @@ -11,19 +11,25 @@ namespace CalamityMod.Items.Armor.Daedalus public class DaedalusHeadRanged : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RangedDamageBoost = 0.13f; + public static int RangedCritBoost = 7; + public static float AmmoReduction = 0.8f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), RangedCritBoost, (1f - AmmoReduction).ToPercent()); + + // Set Bonus + public static int ShardDamage => CalamityUtils.ScaleWithDifficulty(30); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 9; //39 + Item.defense = 9; // 43 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -36,14 +42,14 @@ namespace CalamityMod.Items.Armor.Daedalus player.setBonus = this.GetLocalizedValue("SetBonus"); var modPlayer = player.Calamity(); modPlayer.daedalusShard = true; - player.GetDamage() += 0.05f; } public override void UpdateEquip(Player player) { - player.ammoCost80 = true; - player.GetDamage() += 0.13f; - player.GetCritChance() += 7; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Daedalus/DaedalusHeadRogue.cs b/Items/Armor/Daedalus/DaedalusHeadRogue.cs index b6324b20b7..5b4c79a506 100644 --- a/Items/Armor/Daedalus/DaedalusHeadRogue.cs +++ b/Items/Armor/Daedalus/DaedalusHeadRogue.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Daedalus @@ -11,19 +11,29 @@ namespace CalamityMod.Items.Armor.Daedalus public class DaedalusHeadRogue : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.13f; + public static int RogueCritBoost = 5; + public static float RogueVelocityBoost = 0.15f; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, RogueVelocityBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.05f; + public static int ShardCountLimit = 15; + public static double ShardDamageRatio = 0.25D; + public static int ShardDamageSoftcap = 30; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 7; //37 + Item.defense = 7; // 41 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -33,20 +43,19 @@ namespace CalamityMod.Items.Armor.Daedalus public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth()); var modPlayer = player.Calamity(); modPlayer.daedalusSplit = true; - modPlayer.rogueStealthMax += 1.05f; - player.GetDamage() += 0.05f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; } public override void UpdateEquip(Player player) { - player.Calamity().rogueVelocity += 0.15f; - player.GetDamage() += 0.13f; - player.GetCritChance() += 7; - player.moveSpeed += 0.05f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.Calamity().rogueVelocity += RogueVelocityBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Daedalus/DaedalusHeadSummon.cs b/Items/Armor/Daedalus/DaedalusHeadSummon.cs index a772d58d53..ec516460a0 100644 --- a/Items/Armor/Daedalus/DaedalusHeadSummon.cs +++ b/Items/Armor/Daedalus/DaedalusHeadSummon.cs @@ -1,11 +1,10 @@ using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Daedalus @@ -15,6 +14,14 @@ namespace CalamityMod.Items.Armor.Daedalus public class DaedalusHeadSummon : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 1; + public static float SetBonusSummonDamageBoost = 0.1f; public static int CrystalDamage = 95; public override void SetDefaults() @@ -23,13 +30,10 @@ namespace CalamityMod.Items.Armor.Daedalus Item.height = 18; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 3; //33 + Item.defense = 3; // 37 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -39,7 +43,7 @@ namespace CalamityMod.Items.Armor.Daedalus public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent()); var modPlayer = player.Calamity(); modPlayer.daedalusCrystal = true; if (player.whoAmI == Main.myPlayer) @@ -57,13 +61,14 @@ namespace CalamityMod.Items.Armor.Daedalus p.originalDamage = CrystalDamage; } } - player.GetDamage() += 0.2f; - player.maxMinions += 2; + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.05f; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; } public override void AddRecipes() diff --git a/Items/Armor/Daedalus/DaedalusLeggings.cs b/Items/Armor/Daedalus/DaedalusLeggings.cs index 023629f0c4..0d45fae2e7 100644 --- a/Items/Armor/Daedalus/DaedalusLeggings.cs +++ b/Items/Armor/Daedalus/DaedalusLeggings.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Daedalus @@ -9,19 +10,24 @@ namespace CalamityMod.Items.Armor.Daedalus public class DaedalusLeggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int CritBoost = 8; + public static float MoveSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(CritBoost, MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 15; //41 + Item.defense = 15; } public override void UpdateEquip(Player player) { - player.GetCritChance() += 3; - player.moveSpeed += 0.1f; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Demonshade/DemonshadeBreastplate.cs b/Items/Armor/Demonshade/DemonshadeBreastplate.cs index dec634e4f4..7972b7cb58 100644 --- a/Items/Armor/Demonshade/DemonshadeBreastplate.cs +++ b/Items/Armor/Demonshade/DemonshadeBreastplate.cs @@ -1,9 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Demonshade @@ -14,6 +13,13 @@ namespace CalamityMod.Items.Armor.Demonshade public new string LocalizationCategory => "Items.Armor.PostMoonLord"; public string FrontArmTexture => "CalamityMod/Items/Armor/Demonshade/DemonshadeBreastplate_Arms"; + public static int MaxManaBoost = 200; + public static float AmmoReduction = 0.7f; + public static float DamageBoost = 0.15f; + public static int CritBoost = 15; // NOTE: Tooltip shares this number with damage % as they're equal + public static float MeleeSpeedBoost = 0.25f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, DamageBoost.ToPercent(), MeleeSpeedBoost.ToPercent(), (1f - AmmoReduction).ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -28,12 +34,11 @@ namespace CalamityMod.Items.Armor.Demonshade { var modPlayer = player.Calamity(); modPlayer.shadeRegen = true; - player.thorns += 100f; - player.statLifeMax2 += 200; - player.statManaMax2 += 200; - player.GetDamage() += 0.15f; - player.GetCritChance() += 15; - player.GetAttackSpeed() += 0.25f; + modPlayer.ammoCost *= AmmoReduction; + player.statManaMax2 += MaxManaBoost; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Demonshade/DemonshadeGreaves.cs b/Items/Armor/Demonshade/DemonshadeGreaves.cs index 013b25a960..1afb8f1d2c 100644 --- a/Items/Armor/Demonshade/DemonshadeGreaves.cs +++ b/Items/Armor/Demonshade/DemonshadeGreaves.cs @@ -1,5 +1,4 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; @@ -11,6 +10,11 @@ namespace CalamityMod.Items.Armor.Demonshade public class DemonshadeGreaves : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + // Shadow Speed... (elusive) + public static float MoveSpeedBoost = 0.3f; + public static float AccelerationBoost = 0.5f; + public override void SetDefaults() { Item.width = 18; @@ -26,7 +30,7 @@ namespace CalamityMod.Items.Armor.Demonshade { var modPlayer = player.Calamity(); modPlayer.shadowSpeed = true; - player.moveSpeed += 0.3f; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Demonshade/DemonshadeHelm.cs b/Items/Armor/Demonshade/DemonshadeHelm.cs index 2e854e84d2..ed2f083749 100644 --- a/Items/Armor/Demonshade/DemonshadeHelm.cs +++ b/Items/Armor/Demonshade/DemonshadeHelm.cs @@ -1,7 +1,5 @@ using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -9,6 +7,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.DataStructures; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Demonshade @@ -20,7 +19,18 @@ namespace CalamityMod.Items.Armor.Demonshade public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/DemonshadeEnrage"); internal static string ShadowScytheEntitySourceContext => "SetBonus_Calamity_Demonshade"; + public static int MinionSlotBoost = 2; + public static float DamageBoost = 0.3f; + public static int CritBoost = 15; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, DamageBoost.ToPercent(), CritBoost); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 8; + public static float SetBonusSummonDamageBoost = 1f; public static int DevilDamage = 1000; + public static int BeamDamage => CalamityUtils.ScaleWithDifficulty(300); + public static int ScytheDamage => CalamityUtils.ScaleWithDifficulty(500); + public static int EnrageDuration = CalamityUtils.SecondsToFrames(10); public static float MultDamageBoost = 0.5f; public static double MultDamageTakenBoost = 0.25D; @@ -34,10 +44,7 @@ namespace CalamityMod.Items.Armor.Demonshade Item.Calamity().devItem = true; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -47,8 +54,7 @@ namespace CalamityMod.Items.Armor.Demonshade public override void UpdateArmorSet(Player player) { - var hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey, (1f + MultDamageBoost).Round(), (1D + MultDamageTakenBoost).Round()); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent(), CalamityUtils.GetArmorSetBonusKey(), EnrageDuration.FramesToSeconds(), (1f + MultDamageBoost).Round(), (1D + MultDamageTakenBoost).Round()); var modPlayer = player.Calamity(); modPlayer.dsSetBonus = true; modPlayer.wearingRogueArmor = true; @@ -69,14 +75,15 @@ namespace CalamityMod.Items.Armor.Demonshade devil.originalDamage = DevilDamage; } } - player.GetDamage() += 1f; - player.maxMinions += 10; + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.3f; - player.GetCritChance() += 15; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; } public override void AddRecipes() diff --git a/Items/Armor/DesertProwler/DesertProwlerSet.cs b/Items/Armor/DesertProwler/DesertProwlerSet.cs index 7d7bcd3c06..1e77e617e4 100644 --- a/Items/Armor/DesertProwler/DesertProwlerSet.cs +++ b/Items/Armor/DesertProwler/DesertProwlerSet.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; -using CalamityMod.Dusts; using CalamityMod.Items.Materials; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; using ReLogic.Utilities; @@ -27,12 +22,19 @@ namespace CalamityMod.Items.Armor.DesertProwler public static readonly SoundStyle SmokeBombEndSound = new("CalamityMod/Sounds/Custom/AbilitySounds/DesertProwlerSmokeBombEnd"); public static readonly SoundStyle CDResetSound = new("CalamityMod/Sounds/Custom/AbilitySounds/DesertProwlerCDReset"); - public static int FlatDamageBonus = 1; - public static int SmokeCooldown = 25 * 60; - public static int SmokeDuration = 5 * 60; - public static int LightsOutReset = (int)(1.5f * 60); + public static int RogueCritBoost = 4; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueCritBoost); + + // Set Bonus + public static float SetBonusRogueStealth = 0.5f; + public static float SmokeMoveSpeedMult = 1.5f; + public static float SmokeDefenseMult = 0.75f; + public static float SmokeAggroMult = 0.5f; + public static int SmokeCooldown = CalamityUtils.SecondsToFrames(25); + public static int SmokeDuration = CalamityUtils.SecondsToFrames(5); + public static int LightsOutReset = CalamityUtils.SecondsToFrames(2); public static int FreeCrit = 200; - public static int BonusDamageCap = 100; + public static int BonusDamageCap = 200; public static bool ShroudedInSmoke(Player player, out CooldownInstance cd) { @@ -41,32 +43,13 @@ namespace CalamityMod.Items.Armor.DesertProwler return (hasSmokebombCD && cd.timeLeft > SmokeCooldown); } - public override void Load() - { - Terraria.On_Player.KeyDoubleTap += ActivateSetBonus; - } - - private void ActivateSetBonus(Terraria.On_Player.orig_KeyDoubleTap orig, Player player, int keyDir) - { - if (keyDir == (Main.ReversedUpDownArmorSetBonuses ? 1 : 0) && HasArmorSet(player) && !player.mount.Active) - { - // The set bonus can only be activated if the player does not have the cooldown. - if (!player.Calamity().cooldowns.TryGetValue(SandsmokeBomb.ID, out CooldownInstance cd)) - { - player.AddCooldown(SandsmokeBomb.ID, SmokeCooldown + SmokeDuration); - } - } - - orig(player, keyDir); - } - public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 1; //6 + Item.defense = 2; // 9 } public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ItemType() && legs.type == ItemType(); @@ -78,8 +61,10 @@ namespace CalamityMod.Items.Armor.DesertProwler public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalization("SetBonus").Format(FlatDamageBonus); //More gets edited in elsewhere - player.GetDamage().Flat += FlatDamageBonus; + Color AbilityBriefColor = Color.Lerp(new Color(255, 229, 156), new Color(233, 225, 198), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), AbilityBriefColor.Hex3(), CalamityUtils.GetArmorSetBonusKey(), FreeCrit, BonusDamageCap, LightsOutReset.FramesToSeconds()); //More gets edited in elsewhere + player.Calamity().wearingRogueArmor = true; + player.Calamity().rogueStealthMax += SetBonusRogueStealth; DesertProwlerPlayer armorPlayer = player.GetModPlayer(); armorPlayer.desertProwlerSet = true; @@ -89,9 +74,9 @@ namespace CalamityMod.Items.Armor.DesertProwler if (cd.timeLeft == SmokeCooldown + SmokeDuration) armorPlayer.SetBonusStartEffect(); - player.moveSpeed *= 1.5f; + player.moveSpeed *= SmokeMoveSpeedMult; player.invis = true; - player.aggro = (int)(player.aggro * 0.5f); + player.aggro = (int)(player.aggro * SmokeAggroMult); player.noKnockback = true; for (int i = 0; i < 2; i++) @@ -155,37 +140,10 @@ namespace CalamityMod.Items.Armor.DesertProwler dhusvtt.fadeIn = 1f; Vector2 dustVelocity = dustDirection.RotatedBy(MathHelper.PiOver2) * 0.04f * dustDistance; dhusvtt.velocity = dustVelocity; - } } - public static void ModifySetTooltips(ModItem item, List tooltips) - { - if (HasArmorSet(Main.LocalPlayer)) - { - int setBonusIndex = tooltips.FindIndex(x => x.Name == "SetBonus" && x.Mod == "Terraria"); - - if (setBonusIndex != -1) - { - string dir = Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN"); - TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("AbilityBrief").Format(dir)); - setBonus1.OverrideColor = Color.Lerp(new Color(255, 229, 156), new Color(233, 225, 198), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f)); - tooltips.Insert(setBonusIndex + 1, setBonus1); - - TooltipLine setBonus2 = new TooltipLine(item.Mod, "CalamityMod:SetBonus2", CalamityUtils.GetTextFromModItem("AbilityDescription").Format(FreeCrit, BonusDamageCap, LightsOutReset / 60f)); - setBonus2.OverrideColor = new Color(204, 181, 72); - tooltips.Insert(setBonusIndex + 2, setBonus2); - } - } - } - - public override void ModifyTooltips(List tooltips) => ModifySetTooltips(this, tooltips); - - public override void UpdateEquip(Player player) - { - player.GetCritChance() += 4; - player.ammoCost80 = true; - } + public override void UpdateEquip(Player player) => player.GetCritChance() += RogueCritBoost; public override void AddRecipes() { @@ -203,6 +161,9 @@ namespace CalamityMod.Items.Armor.DesertProwler public new string LocalizationCategory => "Items.Armor.PreHardmode"; public string BulkTexture => "CalamityMod/Items/Armor/DesertProwler/DesertProwlerShirt_Bulk"; + public static float RogueDamageBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent()); + public override void SetStaticDefaults() { if (Main.dedServ) @@ -220,15 +181,10 @@ namespace CalamityMod.Items.Armor.DesertProwler Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 3; + Item.defense = 4; } - public override void ModifyTooltips(List tooltips) => DesertProwlerHat.ModifySetTooltips(this, tooltips); - - public override void UpdateEquip(Player player) - { - player.GetCritChance() += 5; - } + public override void UpdateEquip(Player player) => player.GetDamage() += RogueDamageBoost; public override void AddRecipes() { @@ -245,19 +201,23 @@ namespace CalamityMod.Items.Armor.DesertProwler public class DesertProwlerPants : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int RogueCritBoost = 4; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueCritBoost); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 2; + Item.defense = 3; } - public override void ModifyTooltips(List tooltips) => DesertProwlerHat.ModifySetTooltips(this, tooltips); + public override void UpdateEquip(Player player) { + player.GetCritChance() += RogueCritBoost; player.buffImmune[BuffID.WindPushed] = true; - player.moveSpeed += 0.1f; } public override void AddRecipes() @@ -272,9 +232,6 @@ namespace CalamityMod.Items.Armor.DesertProwler public class DesertProwlerPlayer : ModPlayer { - public static int BastionShootDamage = 10; - public static float BastionShootSpeed = 18f; - public static int BastionShootTime = 10; internal SlotId SmokeBombSoundSlot; public bool desertProwlerSet = false; @@ -377,55 +334,63 @@ namespace CalamityMod.Items.Armor.DesertProwler public int ExtraCrit = 0; public override bool InstancePerEntity => true; + // This should be okay since we can't handle projectiles with altering ClassType in OnSpawn hook anyways + public override bool AppliesToEntity(Projectile entity, bool lateInstantiation) + { + if (entity.DamageType.CountsAsClass(RogueDamageClass.Instance)) return true; + return false; + } + public override void OnSpawn(Projectile projectile, IEntitySource source) { - if (projectile.damage > 0 && !Main.gameMenu) + if (Main.gameMenu) + return; + + if (projectile.damage <= 0 || projectile.owner < 0) + return; + + if (!DesertProwlerHat.ShroudedInSmoke(Main.player[projectile.owner], out var _)) + return; + + int critPool = DesertProwlerHat.FreeCrit; + int achievedDamage = projectile.damage; + + //Increase the crit cance of the projectile for as long as theres free crits to be handed out. + //Only increase the crit chance if the additional 100% damage wouldnt make the projectile deal more than the damage cap + while (critPool >= 100) { - if (projectile.owner >= 0 && DesertProwlerHat.ShroudedInSmoke(Main.player[projectile.owner], out var cd) && projectile.DamageType.CountsAsClass(DamageClass.Ranged)) + if (achievedDamage + projectile.damage <= DesertProwlerHat.BonusDamageCap) { - int critPool = DesertProwlerHat.FreeCrit; + ExtraCrit += 100; + critPool -= 100; - int achievedDamage = projectile.damage; + achievedDamage += projectile.damage; + } - //Increase the crit cance of the projectile for as long as theres free crits to be handed out. - //Only increase the crit chance if the additional 100% damage wouldnt make the projectile deal more than the damage cap - while (critPool >= 100) + else + { + //Don't do anything to projectiles that reached the damage cap + if (achievedDamage < DesertProwlerHat.BonusDamageCap) { - if (achievedDamage + projectile.damage <= DesertProwlerHat.BonusDamageCap) - { - ExtraCrit += 100; - critPool -= 100; + //Give some compensation crit if there's still some crit left but adding one full 100% crit chance would make the projectile go over the damage cap + //For example, if the free crit was 200%, the projectile dealt 40 damage, and the damage cap was 100. + //The projectile would get one layer of extra crit, bringing it to 80 damage, but we still have 100% crit leftover + //Adding an extra layer of crit would make the projectile deal 120 damage, which we do not want. + //To compensate for the 20 potential damage loss, we instead add 20/40 crit, making it have 50% extra crit - achievedDamage += projectile.damage; - } - - else - { - //Don't do anything to projectiles that reached the damage cap - if (achievedDamage < DesertProwlerHat.BonusDamageCap) - { - //Give some compensation crit if there's still some crit left but adding one full 100% crit chance would make the projectile go over the damage cap - //For example, if the free crit was 200%, the projectile dealt 40 damage, and the damage cap was 100. - //The projectile would get one layer of extra crit, bringing it to 80 damage, but we still have 100% crit leftover - //Adding an extra layer of crit would make the projectile deal 120 damage, which we do not want. - //To compensate for the 20 potential damage loss, we instead add 20/40 crit, making it have 50% extra crit - - int remainingDamageTilCap = DesertProwlerHat.BonusDamageCap - achievedDamage; - ExtraCrit += (int)(100 * remainingDamageTilCap / (float)projectile.damage); - } - - //Avoid infinite loops - break; - } + int remainingDamageTilCap = DesertProwlerHat.BonusDamageCap - achievedDamage; + ExtraCrit += (int)(100 * remainingDamageTilCap / (float)projectile.damage); } - projectile.CritChance += ExtraCrit; - - projectile.Calamity().supercritHits = 1; - LightsOut = true; - Main.player[projectile.owner].GetModPlayer().stopSmokeBomb = true; + //Avoid infinite loops + break; } } + + projectile.CritChance += ExtraCrit; + projectile.Calamity().supercritHits = 1; + LightsOut = true; + Main.player[projectile.owner].GetModPlayer().stopSmokeBomb = true; } public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Items/Armor/Empyrean/EmpyreanCloak.cs b/Items/Armor/Empyrean/EmpyreanCloak.cs index bf80cf38b8..4d16ffe959 100644 --- a/Items/Armor/Empyrean/EmpyreanCloak.cs +++ b/Items/Armor/Empyrean/EmpyreanCloak.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Empyrean @@ -10,6 +11,11 @@ namespace CalamityMod.Items.Armor.Empyrean public class EmpyreanCloak : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RogueDamageBoost = 0.12f; + public static int RogueCritBoost = 8; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost); + public override void Load() { if (!Main.dedServ) @@ -21,7 +27,6 @@ namespace CalamityMod.Items.Armor.Empyrean public override void SetStaticDefaults() { - if (!Main.dedServ) { var equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); @@ -36,14 +41,13 @@ namespace CalamityMod.Items.Armor.Empyrean Item.height = 18; Item.value = CalamityGlobalItem.RarityRedBuyPrice; Item.rare = ItemRarityID.Red; - Item.defense = 27; + Item.defense = 24; } public override void UpdateEquip(Player player) { - player.statLifeMax2 += 20; - player.GetCritChance() += 7; - player.GetDamage() += 0.07f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Empyrean/EmpyreanCuisses.cs b/Items/Armor/Empyrean/EmpyreanCuisses.cs index 9480df2faf..ff7916ea14 100644 --- a/Items/Armor/Empyrean/EmpyreanCuisses.cs +++ b/Items/Armor/Empyrean/EmpyreanCuisses.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Empyrean @@ -10,20 +11,26 @@ namespace CalamityMod.Items.Armor.Empyrean public class EmpyreanCuisses : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RogueDamageBoost = 0.08f; + public static int RogueCritBoost = 8; // NOTE: Tooltip shares this number with damage % as they're equal + public static float MoveSpeedBoost = 0.2f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityRedBuyPrice; Item.rare = ItemRarityID.Red; - Item.defense = 24; + Item.defense = 20; } public override void UpdateEquip(Player player) { - player.GetCritChance() += 5; - player.GetDamage() += 0.05f; - player.moveSpeed += 0.15f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Empyrean/EmpyreanMask.cs b/Items/Armor/Empyrean/EmpyreanMask.cs index 87b20de371..18a2b1abd4 100644 --- a/Items/Armor/Empyrean/EmpyreanMask.cs +++ b/Items/Armor/Empyrean/EmpyreanMask.cs @@ -1,8 +1,8 @@ -using CalamityMod.Buffs.StatBuffs; -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.StatBuffs; using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Empyrean @@ -12,6 +12,20 @@ namespace CalamityMod.Items.Armor.Empyrean public class EmpyreanMask : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RogueDamageBoost = 0.12f; + public static int RogueCritBoost = 7; + public static float RogueVelocityBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, RogueVelocityBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.15f; + public static int WrathDuration = CalamityUtils.SecondsToFrames(3); + public static float PermanentWrathHealthRatio = 0.5f; + public static float WrathRogueDamageBoost = 0.1f; + public static int WrathRogueCritBoost = 5; + // There's 10 or so different magic numbers polluting CalamityPlayerOnHit for each projectile. I'm not adding it. - Iris + public override void Load() { if (!Main.dedServ) @@ -25,7 +39,6 @@ namespace CalamityMod.Items.Armor.Empyrean public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -45,13 +58,10 @@ namespace CalamityMod.Items.Armor.Empyrean Item.height = 18; Item.value = CalamityGlobalItem.RarityRedBuyPrice; Item.rare = ItemRarityID.Red; - Item.defense = 20; //71 + Item.defense = 16; // 60 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -65,20 +75,18 @@ namespace CalamityMod.Items.Armor.Empyrean { var modPlayer = player.Calamity(); modPlayer.xerocSet = true; - modPlayer.rogueStealthMax += 1.15f; - player.setBonus = this.GetLocalizedValue("SetBonus"); - if (player.statLife <= (int)(player.statLifeMax2 * 0.5)) + modPlayer.rogueStealthMax += SetBonusRogueStealth; + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth()); + if (player.statLife <= (int)(player.statLifeMax2 * PermanentWrathHealthRatio)) player.AddBuff(ModContent.BuffType(), 2); - player.GetDamage() += 0.09f; - modPlayer.rogueVelocity += 0.09f; modPlayer.wearingRogueArmor = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.11f; - player.GetCritChance() += 11; - player.moveSpeed += 0.05f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.Calamity().rogueVelocity += RogueVelocityBoost; } public override void AddRecipes() diff --git a/Items/Armor/FathomSwarmer/FathomSwarmerBoots.cs b/Items/Armor/FathomSwarmer/FathomSwarmerBoots.cs index 33257e3b8b..1727744f85 100644 --- a/Items/Armor/FathomSwarmer/FathomSwarmerBoots.cs +++ b/Items/Armor/FathomSwarmer/FathomSwarmerBoots.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Placeables.Abyss; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.FathomSwarmer @@ -10,6 +11,11 @@ namespace CalamityMod.Items.Armor.FathomSwarmer public class FathomSwarmerBoots : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float SummonDamageBoost = 0.08f; + public static float SubmergedMoveSpeedBoost = 0.4f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(SummonDamageBoost.ToPercent(), SubmergedMoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -21,19 +27,16 @@ namespace CalamityMod.Items.Armor.FathomSwarmer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.08f; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) + player.GetDamage() += SummonDamageBoost; + if (player.Calamity().countsAsAnyWet) { - player.moveSpeed += 0.4f; + player.moveSpeed += SubmergedMoveSpeedBoost; } player.ignoreWater = true; if (player.wingTime <= 0) //ignore flippers while the player can fly player.accFlipper = true; } - - - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Armor/FathomSwarmer/FathomSwarmerBreastplate.cs b/Items/Armor/FathomSwarmer/FathomSwarmerBreastplate.cs index be0e044c58..66e7ff78d1 100644 --- a/Items/Armor/FathomSwarmer/FathomSwarmerBreastplate.cs +++ b/Items/Armor/FathomSwarmer/FathomSwarmerBreastplate.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Placeables.Abyss; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.FathomSwarmer @@ -10,9 +11,13 @@ namespace CalamityMod.Items.Armor.FathomSwarmer public class FathomSwarmerBreastplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -33,9 +38,8 @@ namespace CalamityMod.Items.Armor.FathomSwarmer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.endurance += 0.06f; - player.maxMinions += 1; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; player.Calamity().fathomSwarmerBreastplate = true; } diff --git a/Items/Armor/FathomSwarmer/FathomSwarmerVisage.cs b/Items/Armor/FathomSwarmer/FathomSwarmerVisage.cs index 5902d4e52b..f6da56b0e4 100644 --- a/Items/Armor/FathomSwarmer/FathomSwarmerVisage.cs +++ b/Items/Armor/FathomSwarmer/FathomSwarmerVisage.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.FathomSwarmer @@ -11,6 +11,18 @@ namespace CalamityMod.Items.Armor.FathomSwarmer public class FathomSwarmerVisage : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.08f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 2; + public static float SetBonusSummonDamageBoost = 0.1f; + public static float SetBonusSubmergedSummonDamageBoost = 0.2f; + public static int SetBonusSubmergedDefenseBoost = 10; + public static int SetBonusSubmergedRegenBoost = 5; + public override void SetDefaults() { Item.width = 18; @@ -20,43 +32,37 @@ namespace CalamityMod.Items.Armor.FathomSwarmer Item.defense = 8; //41 +10 underwater } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void PreUpdateVanitySet(Player player) - { - player.Calamity().fathomSwarmerTail = true; - } + public override void PreUpdateVanitySet(Player player) => player.Calamity().fathomSwarmerTail = true; public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent(), SetBonusSubmergedSummonDamageBoost.ToPercent(), SetBonusSubmergedDefenseBoost, SetBonusSubmergedRegenBoost.ToRegenPerSecond()); var modPlayer = player.Calamity(); modPlayer.fathomSwarmer = true; player.spikedBoots = 2; - player.maxMinions += 2; - player.GetDamage() += 0.1f; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; + if (modPlayer.countsAsAnyWet) { - player.GetDamage() += 0.2f; - player.statDefense += 10; - player.lifeRegen += 5; + player.GetDamage() += SetBonusSubmergedSummonDamageBoost; + player.statDefense += SetBonusSubmergedDefenseBoost; + player.lifeRegen += SetBonusSubmergedRegenBoost; } } public override void UpdateEquip(Player player) { var modPlayer = player.Calamity(); - player.GetDamage() += 0.08f; - player.maxMinions += 1; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; if (player.breath <= player.breathMax + 2 && !modPlayer.ZoneAbyss) { player.breath = player.breathMax + 3; } modPlayer.fathomSwarmerVisage = true; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) + if (player.Calamity().countsAsAnyWet) { Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.3f, 0.9f, 1.35f); } diff --git a/Items/Armor/Fearmonger/FearmongerGreathelm.cs b/Items/Armor/Fearmonger/FearmongerGreathelm.cs index 180a8fbbbd..395471447f 100644 --- a/Items/Armor/Fearmonger/FearmongerGreathelm.cs +++ b/Items/Armor/Fearmonger/FearmongerGreathelm.cs @@ -1,10 +1,10 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Fearmonger @@ -13,45 +13,52 @@ namespace CalamityMod.Items.Armor.Fearmonger public class FearmongerGreathelm : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static int MaxManaBoost = 60; + public static float ManaCostReduction = 0.1f; + public static float SummonDamageBoost = 0.2f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 2; + public static int RegenBoostDurationPerHit = CalamityUtils.SecondsToFrames(0.17f); + public static int RegenBoostDurationLimit = CalamityUtils.SecondsToFrames(1.5f); + public static int MinionRegenBoost = 5; + public static int MinionRegenTimeBoost = 4; + public static int MinionRegenTimeFloor = 900; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 38; // 132 total - Item.rare = ModContent.RarityType(); + Item.defense = 35; // 125 + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.statManaMax2 += 60; - player.GetDamage() += 0.1f; - player.manaCost *= 0.9f; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += SummonDamageBoost; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawOutlines = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawOutlines = true; public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, MinionRegenBoost.ToRegenPerSecond()); - // This bool encompasses cross-class nerf immunity, colossal life regen on minion attack, and the holiday moon DR + // This bool encompasses cross-class nerf immunity and colossal life regen on minion attack // TODO -- Fearmonger life regen from minion attacks needs some sort of cool visual effect player.Calamity().fearmongerSet = true; // All-class armors count as rogue sets, but don't grant stealth bonuses player.Calamity().wearingRogueArmor = true; player.Calamity().WearingPostMLSummonerSet = true; - player.GetDamage() += 0.2f; - player.maxMinions += 2; + player.maxMinions += SetBonusMinionSlotBoost; int[] immuneDebuffs = { BuffID.OnFire, @@ -67,7 +74,6 @@ namespace CalamityMod.Items.Armor.Fearmonger ModContent.BuffType(), BuffID.Chilled, BuffID.Frozen, - ModContent.BuffType(), }; for (var i = 0; i < immuneDebuffs.Length; ++i) player.buffImmune[immuneDebuffs[i]] = true; diff --git a/Items/Armor/Fearmonger/FearmongerGreaves.cs b/Items/Armor/Fearmonger/FearmongerGreaves.cs index 027cf9af45..fa54151a89 100644 --- a/Items/Armor/Fearmonger/FearmongerGreaves.cs +++ b/Items/Armor/Fearmonger/FearmongerGreaves.cs @@ -3,6 +3,7 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Fearmonger @@ -11,21 +12,24 @@ namespace CalamityMod.Items.Armor.Fearmonger public class FearmongerGreaves : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.1f; + public static float MoveSpeedBoost = 0.2f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 44; - Item.rare = ModContent.RarityType(); + Item.defense = 42; + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.06f; - player.GetKnockback() += 0.5f; - player.moveSpeed += 0.1f; - player.panic = true; + player.GetDamage() += DamageBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Fearmonger/FearmongerPlateMail.cs b/Items/Armor/Fearmonger/FearmongerPlateMail.cs index 5226b1d0d7..768d743c3e 100644 --- a/Items/Armor/Fearmonger/FearmongerPlateMail.cs +++ b/Items/Armor/Fearmonger/FearmongerPlateMail.cs @@ -3,6 +3,7 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Fearmonger @@ -11,21 +12,28 @@ namespace CalamityMod.Items.Armor.Fearmonger public class FearmongerPlateMail : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.1f; + public static int CritBoost = 5; + public static int MaxLifeBoost = 100; + public static float DamageReductionBoost = 0.08f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost, MaxLifeBoost, DamageReductionBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 50; - Item.rare = ModContent.RarityType(); + Item.defense = 48; + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.statLifeMax2 += 100; - player.endurance += 0.08f; - player.GetDamage() += 0.05f; - player.GetCritChance() += 5; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.statLifeMax2 += MaxLifeBoost; + player.endurance += DamageReductionBoost; } public override void AddRecipes() diff --git a/Items/Armor/ForbiddenCirclet.cs b/Items/Armor/ForbiddenCirclet.cs index f5566fca6f..b4e1b3c222 100644 --- a/Items/Armor/ForbiddenCirclet.cs +++ b/Items/Armor/ForbiddenCirclet.cs @@ -1,6 +1,11 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.Summon.Whips; +using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Systems.Collections; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor @@ -9,14 +14,50 @@ namespace CalamityMod.Items.Armor public class ForbiddenCirclet : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; - public const int manaCost = 60; - public const int tornadoBaseDmg = 80; - public const float tornadoBaseKB = 1f; + + public static float SummonDamageBoost = 0.1f; + public static float RogueVelocityBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(SummonDamageBoost.ToPercent(), RogueVelocityBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 0.4f; + public static int TagDuration = CalamityUtils.SecondsToFrames(10); + public static int StormManaCost = 60; + public static int StormCooldown = 45; + public static int StormDamage = 60; + public static float StormKB = 1f; + public static int EaterSpawnCount = 6; + public static int EaterSpawnCooldown = 15; + public static int EaterDamage = 40; + + public static SummonTag summonTag = new SummonTag() + { + //These tag damage fields determine the damage of the spawned eater. The resulting number from each is added together + //So, 0.5 multiplicative and 10 flat would make the damage be 50% of the spawning hit's damage, plus 10 more. + //If you want entirely flt, set multiplicative to 0. If you want entirely multiplicative, set flat to 0. + MultiplicativeTagDamage = 0.25f, + FlatTagDamage = 5, + AllowsWhipStacking = true, + TagOnHit = tagOnHit, + TagModifyHitEffects = SummonTag.BlankTagModifyHit, + AutoDrawTooltip = false + }; + + public static void tagOnHit(NPC npc, Projectile projectile, NPC.HitInfo hit, int damageDone) + { + if (Main.rand.NextBool(5)) + { + int damage = (int)Main.player[projectile.owner].GetBestClassDamage().ApplyTo(damageDone * summonTag.MultiplicativeTagDamage) + summonTag.FlatTagDamage; + Projectile.NewProjectile(projectile.GetSource_OnHit(npc), npc.Center, Main.rand.NextVector2Circular(5f, 5f), ModContent.ProjectileType(), damage, 3, projectile.owner); + } + } public override void SetStaticDefaults() { if (!Main.dedServ) ArmorIDs.Head.Sets.DrawFullHair[Item.headSlot] = true; + summonTag.TagItem = Type; + CalamityBuffSets.SummonTagDebuff.Add(ModContent.BuffType(),summonTag); } public override void SetDefaults() @@ -30,10 +71,7 @@ namespace CalamityMod.Items.Armor Item.Calamity().donorItem = true; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ItemID.AncientBattleArmorShirt && legs.type == ItemID.AncientBattleArmorPants; - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ItemID.AncientBattleArmorShirt && legs.type == ItemID.AncientBattleArmorPants; public override void ArmorSetShadows(Player player) { @@ -43,19 +81,18 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - int stormMana = (int)(manaCost * player.manaCost); - string hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey, stormMana); + int stormMana = (int)(StormManaCost * player.manaCost); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), CalamityUtils.GetArmorSetBonusKey(), stormMana); CalamityPlayer modPlayer = player.Calamity(); modPlayer.forbiddenCirclet = true; - modPlayer.rogueStealthMax += 0.4f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.Calamity().rogueVelocity += 0.15f; + player.GetDamage() += SummonDamageBoost; + player.Calamity().rogueVelocity += RogueVelocityBoost; } public override void AddRecipes() diff --git a/Items/Armor/GemTech/GemTechBodyArmor.cs b/Items/Armor/GemTech/GemTechBodyArmor.cs index 7b76249015..29e83fc015 100644 --- a/Items/Armor/GemTech/GemTechBodyArmor.cs +++ b/Items/Armor/GemTech/GemTechBodyArmor.cs @@ -2,8 +2,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.GemTech @@ -18,7 +16,7 @@ namespace CalamityMod.Items.Armor.GemTech Item.height = 32; Item.defense = 31; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Armor/GemTech/GemTechHeadgear.cs b/Items/Armor/GemTech/GemTechHeadgear.cs index b35d684234..2feef341da 100644 --- a/Items/Armor/GemTech/GemTechHeadgear.cs +++ b/Items/Armor/GemTech/GemTechHeadgear.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; -using static Microsoft.Xna.Framework.Input.Keys; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Armor.GemTech @@ -29,6 +25,7 @@ namespace CalamityMod.Items.Armor.GemTech public const float MeleeSpeedBoost = 0.26f; public const int MaxFlechettes = 8; + public static float RangedAmmoReduction = 0.7f; public const float RangedDamageBoost = 0.5f; public const float RangedCritBoost = 0.16f; @@ -61,14 +58,12 @@ namespace CalamityMod.Items.Armor.GemTech Item.height = 32; Item.defense = 14; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = RarityType(); + Item.rare = RarityType(); Item.Calamity().donorItem = true; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ItemType() && legs.type == ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ItemType() && legs.type == ItemType(); + public static bool HasArmorSet(Player player) => player.armor[0].type == ItemType() && player.armor[1].type == ItemType() && player.armor[2].type == ItemType(); public override void UpdateArmorSet(Player player) @@ -80,7 +75,8 @@ namespace CalamityMod.Items.Armor.GemTech if (player.Calamity().GemTechState.IsYellowGemActive) player.GetAttackSpeed() += MeleeSpeedBoost; - player.setBonus = "Mucho Texto"; //Replaced below + Color AbilityBriefColor = Color.Lerp(Color.White, Main.DiscoColor, 0.3f); + player.setBonus = this.GetLocalization("AbilityBrief").Format(AbilityBriefColor.Hex3()); // Added below } public static void ModifySetTooltips(ModItem item, List tooltips) @@ -91,24 +87,22 @@ namespace CalamityMod.Items.Armor.GemTech if (setBonusIndex != -1) { - tooltips[setBonusIndex].Text = CalamityUtils.GetTextValueFromModItem("AbilityBrief"); - tooltips[setBonusIndex].OverrideColor = Color.Lerp(Color.White, Main.DiscoColor, 0.3f); - - if (!Main.keyState.IsKeyDown(LeftShift)) + if (!Main.keyState.PressingShift()) { + setBonusIndex++; TooltipLine briefDescription = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextValueFromModItem("AbilityDescription")); briefDescription.OverrideColor = Color.Lerp(Color.White, Main.DiscoColor, 0.5f); - tooltips.Insert(setBonusIndex + 1, briefDescription); + tooltips.Insert(setBonusIndex, briefDescription); - TooltipLine itemDisplay = new TooltipLine(item.Mod, "CalamityMod:ExpandedDisplay", CalamityUtils.GetTextValue("Misc.ShiftToExpand")); - itemDisplay.OverrideColor = new Color(190, 190, 190); - tooltips.Add(itemDisplay); + setBonusIndex++; + TooltipLine holdShiftIndicator = new TooltipLine(item.Mod, IHoldShiftTooltipItem.ExtensionIndicatorTooltipID, CalamityUtils.GetTextValue("Misc.ShiftToExpand")); + holdShiftIndicator.OverrideColor = IHoldShiftTooltipItem.DefaultExtensionIndicatorColor; + tooltips.Insert(setBonusIndex, holdShiftIndicator); } - else { setBonusIndex++; - TooltipLine largerDescription = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("GeneralGemInfo").Format(GemBreakDamageLowerBound, GemDamage, GemRegenTime / 60)); + TooltipLine largerDescription = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("GeneralGemInfo").Format(GemBreakDamageLowerBound, GemDamage, GemRegenTime.FramesToSeconds())); largerDescription.OverrideColor = Color.Lerp(Color.White, Main.DiscoColor, 0.5f); tooltips.Insert(setBonusIndex, largerDescription); @@ -138,15 +132,12 @@ namespace CalamityMod.Items.Armor.GemTech tooltips.Insert(setBonusIndex, purpleGemTooltip); setBonusIndex++; - string pinkLifeRegenString = (0.5f * BaseGemLifeRegenBoost).ToString("n1"); - TooltipLine pinkGemTooltip = new TooltipLine(item.Mod, "CalamityMod:SetBonus7", CalamityUtils.GetTextFromModItem("PinkGemInfo").Format(BaseGemDefenseBoost, pinkLifeRegenString)); + TooltipLine pinkGemTooltip = new TooltipLine(item.Mod, "CalamityMod:SetBonus7", CalamityUtils.GetTextFromModItem("PinkGemInfo").Format(BaseGemDefenseBoost, BaseGemLifeRegenBoost.ToRegenPerSecond())); pinkGemTooltip.OverrideColor = new Color(255, 115, 206); tooltips.Insert(setBonusIndex, pinkGemTooltip); setBonusIndex++; - string baseLifeRegenString = (0.5f * AllGemsWeaponUseLifeRegenBoost).ToString("n1"); - string multiclassLifeRegenString = (0.5f * AllGemsMultiWeaponUseLifeRegenBoost).ToString("n1"); - TooltipLine liferegenTooltip = new TooltipLine(item.Mod, "CalamityMod:SetBonus8", CalamityUtils.GetTextFromModItem("GemBonusInfo").Format(baseLifeRegenString, AllGemsLifeRegenBoostTime / 60, multiclassLifeRegenString, AllGemsMultiWeaponLifeRegenBoostTime / 60f)); + TooltipLine liferegenTooltip = new TooltipLine(item.Mod, "CalamityMod:SetBonus8", CalamityUtils.GetTextFromModItem("GemBonusInfo").Format(AllGemsWeaponUseLifeRegenBoost.ToRegenPerSecond(), AllGemsLifeRegenBoostTime.FramesToSeconds(), AllGemsMultiWeaponUseLifeRegenBoost.ToRegenPerSecond(), AllGemsMultiWeaponLifeRegenBoostTime.FramesToSeconds())); liferegenTooltip.OverrideColor = new Color(230, 230, 230); tooltips.Insert(setBonusIndex, liferegenTooltip); } diff --git a/Items/Armor/GemTech/GemTechSchynbaulds.cs b/Items/Armor/GemTech/GemTechSchynbaulds.cs index cc5f3f3323..a7d5c0fa54 100644 --- a/Items/Armor/GemTech/GemTechSchynbaulds.cs +++ b/Items/Armor/GemTech/GemTechSchynbaulds.cs @@ -2,8 +2,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.GemTech @@ -18,7 +16,7 @@ namespace CalamityMod.Items.Armor.GemTech Item.height = 26; Item.defense = 24; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Armor/GodSlayer/GodSlayerChestplate.cs b/Items/Armor/GodSlayer/GodSlayerChestplate.cs index fae0a56ad4..5230c288c0 100644 --- a/Items/Armor/GodSlayer/GodSlayerChestplate.cs +++ b/Items/Armor/GodSlayer/GodSlayerChestplate.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.GodSlayer @@ -11,24 +11,31 @@ namespace CalamityMod.Items.Armor.GodSlayer public class GodSlayerChestplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; - public const int DashIFrames = 12; + + public static float DamageBoost = 0.15f; + public static int CritBoost = 11; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + + // Common Set Bonus + public static int DashCooldown = CalamityUtils.SecondsToFrames(45); + public static int DashDamage = 3000; + public static float DashKnockback = 15f; + public static int DashIFrames = 12; + public static int DashGodSlayerInfernoDuration = CalamityUtils.SecondsToFrames(5); public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 41; - Item.rare = ModContent.RarityType(); + Item.defense = 40; + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - var modPlayer = player.Calamity(); - player.thorns += 0.5f; - player.statLifeMax2 += 60; - player.GetDamage() += 0.11f; - player.GetCritChance() += 6; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; } public override void AddRecipes() diff --git a/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs b/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs index f03824f29d..76d20bfa39 100644 --- a/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs +++ b/Items/Armor/GodSlayer/GodSlayerHeadMelee.cs @@ -1,9 +1,10 @@ -using CalamityMod.CalPlayer; -using CalamityMod.CalPlayer.Dashes; +using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.GodSlayer @@ -13,35 +14,39 @@ namespace CalamityMod.Items.Armor.GodSlayer public class GodSlayerHeadMelee : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float MeleeDamageBoost = 0.1f; + public static int MeleeCritBoost = 5; + public static float MeleeSpeedBoost = 0.2f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent(), MeleeCritBoost, MeleeSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusAggroBoost = 1000; + public static int SetBonusHurtDamageThreshold = 80; + public static int DartDamage => CalamityUtils.ScaleWithDifficulty(350); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 48; //96 - Item.rare = ModContent.RarityType(); + Item.defense = 50; // 120 + Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); - player.GetAttackSpeed() += 0.2f; modPlayer.godSlayer = true; modPlayer.godSlayerDamage = true; var hotkey = CalamityKeybinds.GodSlayerDashHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextFromModItem("CommonSetBonus").Format(hotkey, GodslayerArmorDash.GodslayerCooldown); - player.thorns += 2.5f; - player.aggro += 1000; + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusHurtDamageThreshold, hotkey, GodSlayerChestplate.DashCooldown.FramesToSeconds()); + player.setBonus = player.setBonus.Replace("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); + player.aggro += SetBonusAggroBoost; if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) { @@ -52,8 +57,9 @@ namespace CalamityMod.Items.Armor.GodSlayer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.14f; - player.GetCritChance() += 7; + player.GetDamage() += MeleeDamageBoost; + player.GetCritChance() += MeleeCritBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/GodSlayer/GodSlayerHeadRanged.cs b/Items/Armor/GodSlayer/GodSlayerHeadRanged.cs index 0807eb0f7a..1c5617ac58 100644 --- a/Items/Armor/GodSlayer/GodSlayerHeadRanged.cs +++ b/Items/Armor/GodSlayer/GodSlayerHeadRanged.cs @@ -1,9 +1,10 @@ -using CalamityMod.CalPlayer; -using CalamityMod.CalPlayer.Dashes; +using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.GodSlayer @@ -13,24 +14,29 @@ namespace CalamityMod.Items.Armor.GodSlayer public class GodSlayerHeadRanged : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RangedDamageBoost = 0.1f; + public static int RangedCritBoost = 12; + public static float AmmoReduction = 0.7f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), RangedCritBoost, (1f - AmmoReduction).ToPercent()); + + // Set Bonus + public static int ShrapnelRoundCooldown = CalamityUtils.SecondsToFrames(2.5f); + public static double ShrapnelRoundDamageRatio = 1D; + public static int ShrapnelRoundDamageSoftcap = 800; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 35; //96 - Item.rare = ModContent.RarityType(); + Item.defense = 35; // 105 + Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; public override void UpdateArmorSet(Player player) { @@ -38,8 +44,8 @@ namespace CalamityMod.Items.Armor.GodSlayer modPlayer.godSlayer = true; modPlayer.godSlayerRanged = true; var hotkey = CalamityKeybinds.GodSlayerDashHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextFromModItem("CommonSetBonus").Format(hotkey, GodslayerArmorDash.GodslayerCooldown); - + player.setBonus = this.GetLocalization("SetBonus").Format(ShrapnelRoundCooldown.FramesToSeconds(), hotkey, GodSlayerChestplate.DashCooldown.FramesToSeconds()); + player.setBonus = player.setBonus.Replace("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) { modPlayer.DeferredDashID = GodslayerArmorDash.ID; @@ -49,8 +55,10 @@ namespace CalamityMod.Items.Armor.GodSlayer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.14f; - player.GetCritChance() += 14; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/GodSlayer/GodSlayerHeadRogue.cs b/Items/Armor/GodSlayer/GodSlayerHeadRogue.cs index a83dde4503..b5d0b638f5 100644 --- a/Items/Armor/GodSlayer/GodSlayerHeadRogue.cs +++ b/Items/Armor/GodSlayer/GodSlayerHeadRogue.cs @@ -1,9 +1,10 @@ -using CalamityMod.CalPlayer; -using CalamityMod.CalPlayer.Dashes; +using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.GodSlayer @@ -13,35 +14,43 @@ namespace CalamityMod.Items.Armor.GodSlayer public class GodSlayerHeadRogue : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RogueDamageBoost = 0.1f; + public static int RogueCritBoost = 12; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.2f; + public static float RogueDamageBoostAtFullHealth = 0.1f; + public static int RogueCritBoostAtFullHealth = 10; // NOTE: Tooltip shares this number with damage % as they're equal + public static float RogueVelocityBoostAtFullHealth = 0.1f; // NOTE: Tooltip shares this number with damage % as they're equal + public static int SetBonusHurtDamageThreshold = 80; + public static int ExtraIFrames = 30; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 29; //96 - Item.rare = ModContent.RarityType(); + Item.defense = 30; // 100 + Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.godSlayer = true; modPlayer.godSlayerThrowing = true; - modPlayer.rogueStealthMax += 1.2f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; var hotkey = CalamityKeybinds.GodSlayerDashHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextFromModItem("CommonSetBonus").Format(hotkey, GodslayerArmorDash.GodslayerCooldown); - + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), RogueDamageBoostAtFullHealth.ToPercent(), SetBonusHurtDamageThreshold, hotkey, GodSlayerChestplate.DashCooldown.FramesToSeconds()); + player.setBonus = player.setBonus.Replace("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); if (modPlayer.godSlayerDashHotKeyPressed || (player.dashDelay != 0 && modPlayer.LastUsedDashID == GodslayerArmorDash.ID)) { modPlayer.DeferredDashID = GodslayerArmorDash.ID; @@ -51,9 +60,9 @@ namespace CalamityMod.Items.Armor.GodSlayer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.14f; - player.GetCritChance() += 14; - player.moveSpeed += 0.05f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/GodSlayer/GodSlayerLeggings.cs b/Items/Armor/GodSlayer/GodSlayerLeggings.cs index 2e74e4c676..e5dade9642 100644 --- a/Items/Armor/GodSlayer/GodSlayerLeggings.cs +++ b/Items/Armor/GodSlayer/GodSlayerLeggings.cs @@ -2,6 +2,7 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.GodSlayer @@ -10,20 +11,26 @@ namespace CalamityMod.Items.Armor.GodSlayer public class GodSlayerLeggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.11f; + public static int CritBoost = 11; // NOTE: Tooltip shares this number with damage % as they're equal + public static float MoveSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 35; - Item.rare = ModContent.RarityType(); + Item.defense = 30; + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.moveSpeed += 0.05f; - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Hydrothermic/HydrothermicArmor.cs b/Items/Armor/Hydrothermic/HydrothermicArmor.cs index b1801d6c38..6e4f64d76f 100644 --- a/Items/Armor/Hydrothermic/HydrothermicArmor.cs +++ b/Items/Armor/Hydrothermic/HydrothermicArmor.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Hydrothermic @@ -13,6 +14,16 @@ namespace CalamityMod.Items.Armor.Hydrothermic internal static string VanitySmokeEntitySourceContext => "SetBonus_Calamity_Hydrothermic_Vanity"; internal static string InfernoPotionEntitySourceContext => "SetBonus_Calamity_Hydrothermic_InfernoPotionBoost"; + public static float DamageBoost = 0.13f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent()); + + // Common Set Bonus + public static int BlazeDamage => CalamityUtils.ScaleWithDifficulty(115); + public static float InfernoHealthThreshold = 0.5f; + public static int InfernoHitRate = 30; + public static int InfernoDamage = 50; + public static float InfernoRange = 300f; + public override void SetDefaults() { Item.width = 18; @@ -24,9 +35,9 @@ namespace CalamityMod.Items.Armor.Hydrothermic public override void UpdateEquip(Player player) { - player.statLifeMax2 += 20; - player.GetDamage() += 0.08f; - player.GetCritChance() += 4; + player.GetDamage() += DamageBoost; + player.lavaImmune = true; + player.buffImmune[BuffID.OnFire] = true; } public override void AddRecipes() diff --git a/Items/Armor/Hydrothermic/HydrothermicHeadMagic.cs b/Items/Armor/Hydrothermic/HydrothermicHeadMagic.cs index 6bf014726a..a6a9ad4c88 100644 --- a/Items/Armor/Hydrothermic/HydrothermicHeadMagic.cs +++ b/Items/Armor/Hydrothermic/HydrothermicHeadMagic.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Hydrothermic @@ -11,6 +11,20 @@ namespace CalamityMod.Items.Armor.Hydrothermic public class HydrothermicHeadMagic : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MaxManaBoost = 100; + public static float ManaCostReduction = 0.15f; + public static float MagicDamageBoost = 0.12f; + public static int MagicCritBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost); + + // Set Bonus + public static double OrbDamageRatio = 0.6D; + public static float OrbDamageCooldownMult = 0.5f; + public static double OrbHealingRatio = 0.1D; + public static double OrbHealingRatioLossPerPierce = 0.05D; + public static float OrbHealingCooldownMult = 1.25f; + public override void SetDefaults() { Item.width = 18; @@ -20,10 +34,7 @@ namespace CalamityMod.Items.Armor.Hydrothermic Item.defense = 9; //45 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -33,21 +44,18 @@ namespace CalamityMod.Items.Armor.Hydrothermic public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(HydrothermicArmor.InfernoHealthThreshold.ToPercent()); var modPlayer = player.Calamity(); modPlayer.ataxiaBlaze = true; modPlayer.ataxiaMage = true; - player.GetDamage() += 0.05f; - player.manaCost *= 0.85f; } public override void UpdateEquip(Player player) { - player.statManaMax2 += 100; - player.GetDamage() += 0.12f; - player.GetCritChance() += 10; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Hydrothermic/HydrothermicHeadMelee.cs b/Items/Armor/Hydrothermic/HydrothermicHeadMelee.cs index c72ee844af..dad4af3e81 100644 --- a/Items/Armor/Hydrothermic/HydrothermicHeadMelee.cs +++ b/Items/Armor/Hydrothermic/HydrothermicHeadMelee.cs @@ -1,17 +1,28 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Hydrothermic { [AutoloadEquip(EquipType.Head)] [LegacyName("AtaxiaHelm")] - public class HydrothermicHeadMelee : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float MeleeDamageBoost = 0.12f; + public static int MeleeCritBoost = 10; + public static float MeleeSpeedBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent(), MeleeCritBoost, MeleeSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusAggroBoost = 700; + public static int GeyserCountLimit = 3; + public static double GeyserDamageRatio = 0.15D; + public static int GeyserDamageSoftcap = 45; + public override void SetDefaults() { Item.width = 18; @@ -21,10 +32,7 @@ namespace CalamityMod.Items.Armor.Hydrothermic Item.defense = 33; //67 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -34,22 +42,18 @@ namespace CalamityMod.Items.Armor.Hydrothermic public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(HydrothermicArmor.InfernoHealthThreshold.ToPercent()); var modPlayer = player.Calamity(); modPlayer.ataxiaBlaze = true; modPlayer.ataxiaGeyser = true; - player.GetAttackSpeed() += 0.15f; - player.aggro += 700; + player.aggro += SetBonusAggroBoost; } public override void UpdateEquip(Player player) { - var modPlayer = player.Calamity(); - modPlayer.ataxiaFire = true; - player.GetDamage() += 0.17f; - player.GetCritChance() += 10; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; + player.GetDamage() += MeleeDamageBoost; + player.GetCritChance() += MeleeCritBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Hydrothermic/HydrothermicHeadRanged.cs b/Items/Armor/Hydrothermic/HydrothermicHeadRanged.cs index 2a34472a13..4aaa9d6e2c 100644 --- a/Items/Armor/Hydrothermic/HydrothermicHeadRanged.cs +++ b/Items/Armor/Hydrothermic/HydrothermicHeadRanged.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Hydrothermic @@ -11,6 +11,16 @@ namespace CalamityMod.Items.Armor.Hydrothermic public class HydrothermicHeadRanged : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RangedDamageBoost = 0.12f; + public static int RangedCritBoost = 10; + public static float AmmoReduction = 0.75f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), RangedCritBoost, (1f - AmmoReduction).ToPercent()); + + // Set Bonus + public static int FlareCooldown = CalamityUtils.SecondsToFrames(0.33f); + public static double FlareDamageRatio = 0.25D; + public override void SetDefaults() { Item.width = 18; @@ -20,10 +30,7 @@ namespace CalamityMod.Items.Armor.Hydrothermic Item.defense = 15; //53 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -33,20 +40,18 @@ namespace CalamityMod.Items.Armor.Hydrothermic public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(FlareCooldown.FramesToSeconds(), HydrothermicArmor.InfernoHealthThreshold.ToPercent()); var modPlayer = player.Calamity(); modPlayer.ataxiaBlaze = true; modPlayer.ataxiaBolt = true; - player.GetDamage() += 0.05f; } public override void UpdateEquip(Player player) { - player.ammoCost75 = true; - player.GetDamage() += 0.12f; - player.GetCritChance() += 10; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Hydrothermic/HydrothermicHeadRogue.cs b/Items/Armor/Hydrothermic/HydrothermicHeadRogue.cs index 67b16fb6b9..c64bfd93f5 100644 --- a/Items/Armor/Hydrothermic/HydrothermicHeadRogue.cs +++ b/Items/Armor/Hydrothermic/HydrothermicHeadRogue.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Hydrothermic @@ -11,6 +11,19 @@ namespace CalamityMod.Items.Armor.Hydrothermic public class HydrothermicHeadRogue : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.12f; + public static int RogueCritBoost = 10; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.1f; + public static int VolleyCooldown = CalamityUtils.SecondsToFrames(2); + public static int VolleyDamage = 50; // Damage + (projectile damage) * Damage Ratio + public static double VolleyDamageRatio = 0.15D; + public static int VolleyDamageSoftcap = 90; + public override void SetDefaults() { Item.width = 18; @@ -20,10 +33,7 @@ namespace CalamityMod.Items.Armor.Hydrothermic Item.defense = 12; //49 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -33,22 +43,19 @@ namespace CalamityMod.Items.Armor.Hydrothermic public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), VolleyCooldown.FramesToSeconds(), HydrothermicArmor.InfernoHealthThreshold.ToPercent()); var modPlayer = player.Calamity(); modPlayer.ataxiaBlaze = true; modPlayer.ataxiaVolley = true; - modPlayer.rogueStealthMax += 1.1f; - player.GetDamage() += 0.05f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.12f; - player.GetCritChance() += 10; - player.moveSpeed += 0.05f; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs b/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs index 8b736ec857..a13dce4e57 100644 --- a/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs +++ b/Items/Armor/Hydrothermic/HydrothermicHeadSummon.cs @@ -1,10 +1,9 @@ using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Hydrothermic @@ -14,6 +13,14 @@ namespace CalamityMod.Items.Armor.Hydrothermic public class HydrothermicHeadSummon : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 1; + public static float SetBonusSummonDamageBoost = 0.25f; public static int VentDamage = 190; public override void SetDefaults() @@ -25,10 +32,7 @@ namespace CalamityMod.Items.Armor.Hydrothermic Item.defense = 6; //40 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -38,7 +42,7 @@ namespace CalamityMod.Items.Armor.Hydrothermic public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent(), HydrothermicArmor.InfernoHealthThreshold.ToPercent()); var modPlayer = player.Calamity(); modPlayer.ataxiaBlaze = true; modPlayer.chaosSpirit = true; @@ -58,16 +62,14 @@ namespace CalamityMod.Items.Armor.Hydrothermic Main.projectile[p].originalDamage = VentDamage; } } - player.GetDamage() += 0.4f; - player.maxMinions += 2; + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.05f; - player.GetKnockback() += 1.5f; - player.lavaImmune = true; - player.buffImmune[BuffID.OnFire] = true; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; } public override void AddRecipes() diff --git a/Items/Armor/Hydrothermic/HydrothermicSubligar.cs b/Items/Armor/Hydrothermic/HydrothermicSubligar.cs index 7fc86d2269..2dcac69f9c 100644 --- a/Items/Armor/Hydrothermic/HydrothermicSubligar.cs +++ b/Items/Armor/Hydrothermic/HydrothermicSubligar.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Hydrothermic @@ -10,6 +11,11 @@ namespace CalamityMod.Items.Armor.Hydrothermic public class HydrothermicSubligar : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int CritBoost = 9; + public static float MoveSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(CritBoost, MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -21,8 +27,8 @@ namespace CalamityMod.Items.Armor.Hydrothermic public override void UpdateEquip(Player player) { - player.GetCritChance() += 5; - player.moveSpeed += 0.1f; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/LunicCorps/LunicCorpsBoots.cs b/Items/Armor/LunicCorps/LunicCorpsBoots.cs index 6844341d52..f80fe1dbed 100644 --- a/Items/Armor/LunicCorps/LunicCorpsBoots.cs +++ b/Items/Armor/LunicCorps/LunicCorpsBoots.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.LunicCorps @@ -9,6 +10,11 @@ namespace CalamityMod.Items.Armor.LunicCorps public class LunicCorpsBoots : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int RangedCritBoost = 7; + public static float MoveSpeedAccelerationBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedCritBoost, MoveSpeedAccelerationBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -22,8 +28,8 @@ namespace CalamityMod.Items.Armor.LunicCorps public override void UpdateEquip(Player player) { player.Calamity().lunicCorpsLegs = true; - player.moveSpeed += 0.15f; - player.GetCritChance() += 5; + player.GetCritChance() += RangedCritBoost; + player.moveSpeed += MoveSpeedAccelerationBoost; } public override void AddRecipes() diff --git a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs index 8f3b9717c3..df58432cc3 100644 --- a/Items/Armor/LunicCorps/LunicCorpsHelmet.cs +++ b/Items/Armor/LunicCorps/LunicCorpsHelmet.cs @@ -2,6 +2,7 @@ using CalamityMod.CalPlayer; using CalamityMod.DataStructures; using CalamityMod.Items.Materials; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,6 +11,7 @@ using Terraria; using Terraria.Audio; using Terraria.Graphics.Effects; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.LunicCorps @@ -25,8 +27,12 @@ namespace CalamityMod.Items.Armor.LunicCorps public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/RoverDriveActivate") { Volume = 0.85f }; public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/Custom/RoverDriveBreak") { Volume = 0.75f }; - public static int ShieldDurabilityMax = 50; + public static float NonArrowDamageBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(NonArrowDamageBoost.ToPercent()); + // Set Bonus + public static float SetBonusJumpSpeedBoost = 1f; + public static int ShieldDurabilityMax = 50; // The following two values taken directly from Halo 3: // https://www.halopedia.org/Energy_shielding#Gameplay public static int ShieldRechargeDelay = CalamityUtils.SecondsToFrames(5); @@ -72,29 +78,25 @@ namespace CalamityMod.Items.Armor.LunicCorps Item.Calamity().donorItem = true; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.lunicCorpsSet = true; + Color AbilityBriefColor = Color.Lerp(new Color(240, 207, 60), new Color(70, 205, 251), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); // The localization is formatted strangely, but attempting to put the {0} on its own line will leave a blank space if given an empty string string adrenTooltip = CalamityWorld.revenge ? "\n" + this.GetLocalizedValue("ShieldAdren") : ""; - player.setBonus = this.GetLocalization("SetBonus").Format(adrenTooltip); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusJumpSpeedBoost.ToJumpSpeedPercent(), AbilityBriefColor.Hex3(), ShieldDurabilityMax, adrenTooltip, ShieldRechargeDelay.FramesToSeconds(), TotalShieldRechargeTime.FramesToSeconds()); - player.bulletDamage += 0.15f; - player.specialistDamage += 0.15f; - - player.jumpSpeedBoost += 1f; + player.jumpSpeedBoost += SetBonusJumpSpeedBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.15f; + player.bulletDamage += NonArrowDamageBoost; + player.specialistDamage += NonArrowDamageBoost; player.nightVision = true; player.detectCreature = true; } @@ -169,14 +171,16 @@ namespace CalamityMod.Items.Armor.LunicCorps shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3()); shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3()); - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, Matrix.Identity, () => + using (spriteBatch.Scope()) { + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, shieldEffect, Main.Transform); // Fetch shield noise overlay texture (this is the polygons fed to the shader) NoiseTex ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes2"); Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition; Texture2D tex = NoiseTex.Value; spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0); - }); + spriteBatch.End(); + } modPlayer.drawnAnyShieldThisFrame = true; } diff --git a/Items/Armor/LunicCorps/LunicCorpsVest.cs b/Items/Armor/LunicCorps/LunicCorpsVest.cs index 0eabd12224..5ddd112b9f 100644 --- a/Items/Armor/LunicCorps/LunicCorpsVest.cs +++ b/Items/Armor/LunicCorps/LunicCorpsVest.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.LunicCorps @@ -10,6 +11,12 @@ namespace CalamityMod.Items.Armor.LunicCorps public class LunicCorpsVest : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RangedDamageBoost = 0.15f; + public static int RangedCritBoost = 15; // NOTE: Tooltip shares this number with damage % as they're equal + public static float AmmoReduction = 0.75f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), (1f - AmmoReduction).ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -22,8 +29,10 @@ namespace CalamityMod.Items.Armor.LunicCorps public override void UpdateEquip(Player player) { - player.GetDamage() += 0.05f; - player.GetCritChance() += 15; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs b/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs index bc1b1eaadc..cf19c73804 100644 --- a/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs +++ b/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs @@ -2,22 +2,15 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Buffs.Mounts; -using CalamityMod.CalPlayer; -using CalamityMod.Cooldowns; -using CalamityMod.Items.Accessories.Vanity; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.GameInput; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; -using static Microsoft.Xna.Framework.Input.Keys; using static Terraria.ModLoader.ModContent; @@ -32,8 +25,13 @@ namespace CalamityMod.Items.Armor.MarniteArchitect public static readonly SoundStyle LiftGoAwaySound = new("CalamityMod/Sounds/Item/MarniteLiftUnsummon"); public static readonly SoundStyle LiftHummSound = new("CalamityMod/Sounds/Item/MarniteLiftHumm") { IsLooped = true }; + public static int TileRangeBoost = 5; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(TileRangeBoost); + + // Set Bonus public static float LiftRaiseSpeed = 2f; public static float MaxLiftHeight = 138f; + public static float LiftHeightOffset = 22f; // Height of the lift itself minus the foot offset; 138 + 22 = 160 (10 tiles) public override void Load() { @@ -55,7 +53,7 @@ namespace CalamityMod.Items.Armor.MarniteArchitect Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 1; + Item.defense = 4; } private void ActivateLift(Terraria.On_Player.orig_QuickMount orig, Player self) @@ -86,7 +84,8 @@ namespace CalamityMod.Items.Armor.MarniteArchitect public override void UpdateArmorSet(Player player) { - player.setBonus = "Marnite Lift"; //Replaced below + Color AbilityBriefColor = Color.Lerp(new Color(255, 243, 161), new Color(137, 162, 255), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(AbilityBriefColor.Hex3(), (MaxLiftHeight + LiftHeightOffset).ToTiles()); player.GetModPlayer().setEquipped = true; } @@ -95,32 +94,11 @@ namespace CalamityMod.Items.Armor.MarniteArchitect //Tile range is a static variable did you know that? That's quite funny. I assume it's just because its not like other players would need to know about the players reach if (Main.myPlayer == player.whoAmI) { - Player.tileRangeX += 5; - Player.tileRangeY += 5; //Extendo grip also increases vertical tile range by one less than horizontal <-- This is silly lmao + Player.tileRangeX += TileRangeBoost; + Player.tileRangeY += TileRangeBoost; //Extendo grip also increases vertical tile range by one less than horizontal <-- This is silly lmao } } - public static void ModifySetTooltips(ModItem item, List tooltips) - { - if (HasArmorSet(Main.LocalPlayer)) - { - int setBonusIndex = tooltips.FindIndex(x => x.Name == "SetBonus" && x.Mod == "Terraria"); - - if (setBonusIndex != -1) - { - tooltips[setBonusIndex].Text = CalamityUtils.GetTextValueFromModItem("AbilityBrief"); - tooltips[setBonusIndex].OverrideColor = Color.Lerp(new Color(255, 243, 161), new Color(137, 162, 255), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f)); - - TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextValueFromModItem("AbilityDescription")); - setBonus1.OverrideColor = new Color(145, 197, 239); - tooltips.Insert(setBonusIndex + 1, setBonus1); - } - - } - } - public override void ModifyTooltips(List tooltips) => ModifySetTooltips(this, tooltips); - - public override void AddRecipes() { CreateRecipe(). @@ -136,6 +114,10 @@ namespace CalamityMod.Items.Armor.MarniteArchitect public class MarniteArchitectToga : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float PlacementSpeedBoost = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(PlacementSpeedBoost.ToPercent()); + public override void Load() { if (Main.dedServ) @@ -143,30 +125,21 @@ namespace CalamityMod.Items.Armor.MarniteArchitect EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Armor/MarniteArchitect/MarniteArchitectToga_Legs", EquipType.Legs, this); } - public override void SetStaticDefaults() - { - if (Main.dedServ) - return; - } - public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 2; + Item.defense = 5; } public override void UpdateEquip(Player player) { - player.tileSpeed += 0.5f; - player.wallSpeed += 0.5f; + player.tileSpeed += PlacementSpeedBoost; + player.wallSpeed += PlacementSpeedBoost; } - public override void ModifyTooltips(List tooltips) => MarniteArchitectHeadgear.ModifySetTooltips(this, tooltips); - - public override void AddRecipes() { CreateRecipe(). @@ -383,7 +356,7 @@ namespace CalamityMod.Items.Armor.MarniteArchitect if (Main.rand.NextFloat() > (centerDistance / MarniteArchitectHeadgear.MaxLiftHeight) * 0.6f && Main.rand.NextBool()) { float scale = 1.2f - (centerDistance / MarniteArchitectHeadgear.MaxLiftHeight) * 0.7f; - Dust dust = Dust.NewDustPerfect(player.Bottom + Vector2.UnitY * centerDistance + Vector2.UnitX * Main.rand.Next(-16, 16), 31, new Vector2((Main.rand.NextFloat(-8, 8) * scale) - player.velocity.X, Main.rand.NextFloat(-1, 1)), 120, Scale: scale * 1.5f); + Dust dust = Dust.NewDustPerfect(player.Bottom + Vector2.UnitY * centerDistance + Vector2.UnitX * Main.rand.Next(-16, 16), DustID.Smoke, new Vector2((Main.rand.NextFloat(-8, 8) * scale) - player.velocity.X, Main.rand.NextFloat(-1, 1)), 120, Scale: scale * 1.5f); } } @@ -391,7 +364,7 @@ namespace CalamityMod.Items.Armor.MarniteArchitect { float speedRotation = player.velocity.X * 0.03f; - Dust dust = Dust.NewDustPerfect(player.Bottom + Vector2.UnitX.RotatedBy(speedRotation) * Main.rand.Next(-6, 6) + Vector2.UnitY.RotatedBy(speedRotation) * -2f, 229, Vector2.UnitY.RotatedBy(speedRotation) * Main.rand.NextFloat(1f, 3f), 120, Scale: Main.rand.NextFloat(0.6f, 1f)); + Dust dust = Dust.NewDustPerfect(player.Bottom + Vector2.UnitX.RotatedBy(speedRotation) * Main.rand.Next(-6, 6) + Vector2.UnitY.RotatedBy(speedRotation) * -2f, DustID.Vortex, Vector2.UnitY.RotatedBy(speedRotation) * Main.rand.NextFloat(1f, 3f), 120, Scale: Main.rand.NextFloat(0.6f, 1f)); dust.noGravity = true; } } diff --git a/Items/Armor/Mollusk/MolluskShelleggings.cs b/Items/Armor/Mollusk/MolluskShelleggings.cs index 607fdb87d5..1a2fc00f6a 100644 --- a/Items/Armor/Mollusk/MolluskShelleggings.cs +++ b/Items/Armor/Mollusk/MolluskShelleggings.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Placeables.SunkenSea; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Mollusk @@ -10,6 +11,11 @@ namespace CalamityMod.Items.Armor.Mollusk public class MolluskShelleggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float DamageBoost = 0.06f; + public static int CritBoost = 4; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + public override void SetDefaults() { Item.width = 22; @@ -21,8 +27,8 @@ namespace CalamityMod.Items.Armor.Mollusk public override void UpdateEquip(Player player) { - player.GetDamage() += 0.06f; - player.GetCritChance() += 4; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; player.Calamity().molluskLegs = true; } diff --git a/Items/Armor/Mollusk/MolluskShellmet.cs b/Items/Armor/Mollusk/MolluskShellmet.cs index 180be5c2c6..53aca94f7a 100644 --- a/Items/Armor/Mollusk/MolluskShellmet.cs +++ b/Items/Armor/Mollusk/MolluskShellmet.cs @@ -1,12 +1,11 @@ using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Mollusk @@ -15,6 +14,13 @@ namespace CalamityMod.Items.Armor.Mollusk public class MolluskShellmet : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float DamageBoost = 0.05f; + public static int CritBoost = 4; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + + // Set Bonus + public static float SetBonusDR = 0.1f; public static int ShellfishDamage = 140; public override void SetDefaults() @@ -29,8 +35,8 @@ namespace CalamityMod.Items.Armor.Mollusk public override void UpdateEquip(Player player) { player.ignoreWater = true; - player.GetDamage() += 0.05f; - player.GetCritChance() += 4; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; player.Calamity().molluskHelmet = true; } @@ -41,8 +47,8 @@ namespace CalamityMod.Items.Armor.Mollusk public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); - player.endurance += 0.1f; + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusDR.ToPercent()); + player.endurance += SetBonusDR; player.maxMinions += 4; // These are allocated for the Shellfish minions; there is no net change in minion slots. if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Armor/Mollusk/MolluskShellplate.cs b/Items/Armor/Mollusk/MolluskShellplate.cs index 881bed8097..cd0470e9d7 100644 --- a/Items/Armor/Mollusk/MolluskShellplate.cs +++ b/Items/Armor/Mollusk/MolluskShellplate.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Placeables.SunkenSea; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Mollusk @@ -10,6 +11,11 @@ namespace CalamityMod.Items.Armor.Mollusk public class MolluskShellplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float DamageBoost = 0.06f; + public static int CritBoost = 5; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + public override void SetDefaults() { Item.width = 30; @@ -21,8 +27,8 @@ namespace CalamityMod.Items.Armor.Mollusk public override void UpdateEquip(Player player) { - player.GetDamage() += 0.06f; - player.GetCritChance() += 5; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; player.Calamity().molluskChest = true; } diff --git a/Items/Armor/OmegaBlue/OmegaBlueChestplate.cs b/Items/Armor/OmegaBlue/OmegaBlueChestplate.cs index 86e43aab19..4eb7dc362e 100644 --- a/Items/Armor/OmegaBlue/OmegaBlueChestplate.cs +++ b/Items/Armor/OmegaBlue/OmegaBlueChestplate.cs @@ -1,9 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.OmegaBlue @@ -12,6 +11,12 @@ namespace CalamityMod.Items.Armor.OmegaBlue public class OmegaBlueChestplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float AmmoReduction = 0.75f; + public static float DamageBoost = 0.18f; + public static int CritBoost = 12; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost, (1f - AmmoReduction).ToPercent()); + public override void SetStaticDefaults() { if (Main.dedServ) @@ -35,8 +40,9 @@ namespace CalamityMod.Items.Armor.OmegaBlue public override void UpdateEquip(Player player) { var modPlayer = player.Calamity(); - player.GetDamage() += 0.12f; - player.GetCritChance() += 8; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + modPlayer.ammoCost *= AmmoReduction; modPlayer.omegaBlueChestplate = true; modPlayer.noLifeRegen = true; } @@ -47,7 +53,7 @@ namespace CalamityMod.Items.Armor.OmegaBlue AddIngredient(5). AddIngredient(18). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Armor/OmegaBlue/OmegaBlueHelmet.cs b/Items/Armor/OmegaBlue/OmegaBlueHelmet.cs index f431d2621b..7e881b56ac 100644 --- a/Items/Armor/OmegaBlue/OmegaBlueHelmet.cs +++ b/Items/Armor/OmegaBlue/OmegaBlueHelmet.cs @@ -1,12 +1,11 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Cooldowns; +using System; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.OmegaBlue @@ -19,6 +18,18 @@ namespace CalamityMod.Items.Armor.OmegaBlue public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/OmegaBlueAbility"); + public static float DamageBoost = 0.12f; + public static int CritBoost = 14; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 2; + public static int TentacleDamage = 350; + public static float MadnessDamageBoost = 0.1f; + public static int MadnessCritBoost = 10; + public static int MadnessDuration = CalamityUtils.SecondsToFrames(5); + public static int MadnessCooldown = CalamityUtils.SecondsToFrames(25); + public override void Load() { if (!Main.dedServ) @@ -48,14 +59,11 @@ namespace CalamityMod.Items.Armor.OmegaBlue { player.ignoreWater = true; - player.GetDamage() += 0.12f; - player.GetCritChance() += 8; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -66,12 +74,11 @@ namespace CalamityMod.Items.Armor.OmegaBlue public override void UpdateArmorSet(Player player) { - var hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey); + Color AbilityBriefColor = Color.Lerp(new Color(255, 229, 61), new Color(110, 173, 237), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, AbilityBriefColor.Hex3(), CalamityUtils.GetArmorSetBonusKey(), MadnessDuration.FramesToSeconds(), MadnessDamageBoost.ToPercent(), MadnessCooldown.FramesToSeconds()); var mp = player.Calamity(); - player.GetArmorPenetration() += 15; - player.maxMinions += 2; + player.maxMinions += SetBonusMinionSlotBoost; mp.wearingRogueArmor = true; mp.omegaBlueSet = true; mp.WearingPostMLSummonerSet = true; @@ -93,7 +100,7 @@ namespace CalamityMod.Items.Armor.OmegaBlue AddIngredient(3). AddIngredient(12). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/OmegaBlue/OmegaBlueTentacles.cs b/Items/Armor/OmegaBlue/OmegaBlueTentacles.cs index 54f1cbbf0a..60637a499a 100644 --- a/Items/Armor/OmegaBlue/OmegaBlueTentacles.cs +++ b/Items/Armor/OmegaBlue/OmegaBlueTentacles.cs @@ -1,8 +1,8 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.OmegaBlue @@ -12,6 +12,12 @@ namespace CalamityMod.Items.Armor.OmegaBlue public class OmegaBlueTentacles : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.16f; + public static int CritBoost = 12; + public static float MoveSpeedBoost = 0.12f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost, MoveSpeedBoost.ToPercent()); + public override void SetStaticDefaults() { if (Main.dedServ) @@ -33,9 +39,9 @@ namespace CalamityMod.Items.Armor.OmegaBlue public override void UpdateEquip(Player player) { - player.GetDamage() += 0.12f; - player.GetCritChance() += 12; - player.moveSpeed += 0.12f; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() @@ -44,7 +50,7 @@ namespace CalamityMod.Items.Armor.OmegaBlue AddIngredient(4). AddIngredient(15). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Armor/PlagueReaper/PlagueReaperMask.cs b/Items/Armor/PlagueReaper/PlagueReaperMask.cs index c483c15e15..6d682efa1f 100644 --- a/Items/Armor/PlagueReaper/PlagueReaperMask.cs +++ b/Items/Armor/PlagueReaper/PlagueReaperMask.cs @@ -1,11 +1,11 @@ -using CalamityMod.CalPlayer; +using System; using CalamityMod.Cooldowns; using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.PlagueReaper @@ -16,64 +16,56 @@ namespace CalamityMod.Items.Armor.PlagueReaper public new string LocalizationCategory => "Items.Armor.Hardmode"; public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/PlagueReaperAbility"); + public static float RangedDamageBoost = 0.1f; + public static int RangedCritBoost = 8; + public static float AmmoReduction = 0.75f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), RangedCritBoost, (1f - AmmoReduction).ToPercent()); + + // Set Bonus + public static float SetBonusFlightTimeBoost = 0.05f; + public static float SetBonusPlaguedRangedDamageMult = 1.1f; + public static float BlackoutRangedDamageBoost = 0.6f; + public static int BlackoutRangedCritBoost = 20; + public static int BlackoutDuration = CalamityUtils.SecondsToFrames(5); + public static int BlackoutCooldown = CalamityUtils.SecondsToFrames(25); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; - Item.defense = 11; + Item.defense = 11; // 44 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawOutlines = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawOutlines = true; public override void UpdateArmorSet(Player player) { - var hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey); + Color AbilityBriefColor = Color.Lerp(new Color(79, 100, 95), new Color(109, 209, 130), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusFlightTimeBoost.ToPercent(), SetBonusPlaguedRangedDamageMult, AbilityBriefColor.Hex3(), CalamityUtils.GetArmorSetBonusKey(), BlackoutRangedDamageBoost.ToPercent(), BlackoutRangedCritBoost, BlackoutDuration.FramesToSeconds(), BlackoutCooldown.FramesToSeconds()); var modPlayer = player.Calamity(); modPlayer.plagueReaper = true; - player.ammoCost75 = true; var hasPlagueBlackoutCD = modPlayer.cooldowns.TryGetValue(PlagueBlackout.ID, out var cd); - if (hasPlagueBlackoutCD && cd.timeLeft > 1500) + if (hasPlagueBlackoutCD && cd.timeLeft > BlackoutCooldown) { player.blind = true; player.headcovered = true; player.blackout = true; - player.GetDamage() += 0.6f; //60% ranged dmg and 20% crit - player.GetCritChance() += 20; - } - - if (player.whoAmI == Main.myPlayer) - { - var source = player.GetSource_Accessory(Item); - if (player.immune) - { - if (player.miscCounter % 10 == 0) - { - var damage = (int)player.GetTotalDamage().ApplyTo(40); - - var cinder = CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 22f, ModContent.ProjectileType(), damage, 4f, player.whoAmI); - if (cinder.whoAmI.WithinBounds(Main.maxProjectiles)) - cinder.DamageType = DamageClass.Generic; - } - } + player.GetDamage() += BlackoutRangedDamageBoost; + player.GetCritChance() += BlackoutRangedCritBoost; } } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 8; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/PlagueReaper/PlagueReaperStriders.cs b/Items/Armor/PlagueReaper/PlagueReaperStriders.cs index 72f7fb5256..5eab566b5e 100644 --- a/Items/Armor/PlagueReaper/PlagueReaperStriders.cs +++ b/Items/Armor/PlagueReaper/PlagueReaperStriders.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.PlagueReaper @@ -9,6 +10,11 @@ namespace CalamityMod.Items.Armor.PlagueReaper public class PlagueReaperStriders : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int RangedCritBoost = 8; + public static float MoveSpeedBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedCritBoost, MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -20,8 +26,8 @@ namespace CalamityMod.Items.Armor.PlagueReaper public override void UpdateEquip(Player player) { - player.GetCritChance() += 3; - player.moveSpeed += 0.15f; + player.GetCritChance() += RangedCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/PlagueReaper/PlagueReaperVest.cs b/Items/Armor/PlagueReaper/PlagueReaperVest.cs index 1016e203d4..c94900de0e 100644 --- a/Items/Armor/PlagueReaper/PlagueReaperVest.cs +++ b/Items/Armor/PlagueReaper/PlagueReaperVest.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.PlagueReaper @@ -10,6 +11,10 @@ namespace CalamityMod.Items.Armor.PlagueReaper public class PlagueReaperVest : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RangedDamageBoost = 0.16f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -21,8 +26,7 @@ namespace CalamityMod.Items.Armor.PlagueReaper public override void UpdateEquip(Player player) { - player.GetDamage() += 0.15f; - player.GetCritChance() += 5; + player.GetDamage() += RangedDamageBoost; player.buffImmune[ModContent.BuffType()] = true; } diff --git a/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs b/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs index dc7245ce1a..43566922ae 100644 --- a/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs +++ b/Items/Armor/Plaguebringer/PlaguebringerCarapace.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Plaguebringer @@ -11,6 +12,11 @@ namespace CalamityMod.Items.Armor.Plaguebringer public class PlaguebringerCarapace : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + public override void SetStaticDefaults() { if (Main.dedServ) @@ -26,7 +32,7 @@ namespace CalamityMod.Items.Armor.Plaguebringer { Item.width = 18; Item.height = 18; - Item.defense = 17; + Item.defense = 13; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; @@ -35,7 +41,8 @@ namespace CalamityMod.Items.Armor.Plaguebringer public override void UpdateEquip(Player player) { player.Calamity().plaguebringerCarapace = true; - player.GetDamage() += 0.15f; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; player.buffImmune[ModContent.BuffType()] = true; } @@ -43,7 +50,7 @@ namespace CalamityMod.Items.Armor.Plaguebringer { CreateRecipe(). AddIngredient(ItemID.BeeBreastplate). - AddIngredient(2). + AddIngredient(2). AddIngredient(7). AddIngredient(7). AddTile(TileID.MythrilAnvil). diff --git a/Items/Armor/Plaguebringer/PlaguebringerPistons.cs b/Items/Armor/Plaguebringer/PlaguebringerPistons.cs index 488bf88d8c..1ae9a366f0 100644 --- a/Items/Armor/Plaguebringer/PlaguebringerPistons.cs +++ b/Items/Armor/Plaguebringer/PlaguebringerPistons.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Plaguebringer @@ -9,11 +10,17 @@ namespace CalamityMod.Items.Armor.Plaguebringer public class PlaguebringerPistons : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.15f; + public static float MoveSpeedBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; - Item.defense = 8; + Item.defense = 10; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; @@ -21,8 +28,9 @@ namespace CalamityMod.Items.Armor.Plaguebringer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.15f; - player.moveSpeed += 0.15f; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; + player.moveSpeed += MoveSpeedBoost; //Flower Boots code if (player.whoAmI == Main.myPlayer && player.velocity.Y == 0f && player.grappling[0] == -1) diff --git a/Items/Armor/Plaguebringer/PlaguebringerVisor.cs b/Items/Armor/Plaguebringer/PlaguebringerVisor.cs index 92ed645a33..df326df8c0 100644 --- a/Items/Armor/Plaguebringer/PlaguebringerVisor.cs +++ b/Items/Armor/Plaguebringer/PlaguebringerVisor.cs @@ -1,10 +1,10 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer.Dashes; using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Plaguebringer @@ -13,14 +13,23 @@ namespace CalamityMod.Items.Armor.Plaguebringer public class PlaguebringerVisor : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; - public const int PlagueDashIFrames = 12; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int PlagueDashDamage = 50; + public static float PlagueDashKnockback = 3f; + public static int PlagueDashIFrames = 12; public static int BeeMinionDamage = 25; + public static int BeePlagueDuration = CalamityUtils.SecondsToFrames(5); public override void SetDefaults() { Item.width = 18; Item.height = 18; - Item.defense = 7; // 32 total + Item.defense = 9; // 32 total Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; @@ -28,19 +37,13 @@ namespace CalamityMod.Items.Armor.Plaguebringer public override void UpdateEquip(Player player) { - player.GetDamage() += 0.15f; - player.statLifeMax2 += 20; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; public override void UpdateArmorSet(Player player) { @@ -49,7 +52,6 @@ namespace CalamityMod.Items.Armor.Plaguebringer player.Calamity().plaguebringerPatronSet = true; player.Calamity().DashID = PlaguebringerArmorDash.ID; player.dashType = 0; - player.maxMinions += 3; if (player.whoAmI == Main.myPlayer) { var source = player.GetSource_ItemUse(Item); diff --git a/Items/Armor/Prismatic/PrismaticGreaves.cs b/Items/Armor/Prismatic/PrismaticGreaves.cs index ea73d76edf..8a6458fd51 100644 --- a/Items/Armor/Prismatic/PrismaticGreaves.cs +++ b/Items/Armor/Prismatic/PrismaticGreaves.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Prismatic @@ -11,6 +12,14 @@ namespace CalamityMod.Items.Armor.Prismatic public class PrismaticGreaves : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float MagicDamageBoost = 0.1f; + public static int MagicCritBoost = 12; + public static float NonMagicDamageDecrease = 0.2f; + public static float FlightTimeBoost = 0.1f; + public static float JumpSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MagicDamageBoost.ToPercent(), MagicCritBoost, NonMagicDamageDecrease.ToPercent(), FlightTimeBoost.ToPercent(), JumpSpeedBoost.ToJumpSpeedPercent()); + public override void SetDefaults() { Item.width = 18; @@ -25,11 +34,11 @@ namespace CalamityMod.Items.Armor.Prismatic public override void UpdateEquip(Player player) { player.Calamity().prismaticGreaves = true; - player.GetDamage() += 0.1f; - player.GetCritChance() += 12; - player.jumpSpeedBoost += 0.1f; - player.GetDamage() -= 0.2f; - player.GetDamage() += 0.2f; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; + player.jumpSpeedBoost += JumpSpeedBoost; + player.GetDamage() -= NonMagicDamageDecrease; + player.GetDamage() += NonMagicDamageDecrease; } public override void AddRecipes() @@ -39,7 +48,7 @@ namespace CalamityMod.Items.Armor.Prismatic AddIngredient(5). AddIngredient(6). AddIngredient(ItemID.Nanites, 300). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Armor/Prismatic/PrismaticHelmet.cs b/Items/Armor/Prismatic/PrismaticHelmet.cs index fa39d36891..0088ea45b8 100644 --- a/Items/Armor/Prismatic/PrismaticHelmet.cs +++ b/Items/Armor/Prismatic/PrismaticHelmet.cs @@ -1,8 +1,11 @@ -using CalamityMod.Items.Materials; +using System; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Prismatic @@ -12,21 +15,32 @@ namespace CalamityMod.Items.Armor.Prismatic { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; internal static string LaserEntitySourceContext => "SetBonus_Calamity_Prismatic"; + + public static int MaxManaBoost = 80; + public static float ManaCostReduction = 0.15f; + public static float MagicDamageBoost = 0.15f; + public static int MagicCritBoost = 12; + public static float NonMagicDamageDecrease = 0.2f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost, NonMagicDamageDecrease.ToPercent()); + + // Set Bonus + public static int ManaRegenBonus = 8; + public static int LaserDamage = 30; + public static int LaserDuration = CalamityUtils.SecondsToFrames(5); + public static int LaserCooldown = CalamityUtils.SecondsToFrames(30); + public override void SetDefaults() { Item.width = 18; Item.height = 18; - Item.defense = 18; //71 + Item.defense = 18; // 72 Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -37,20 +51,20 @@ namespace CalamityMod.Items.Armor.Prismatic public override void UpdateArmorSet(Player player) { player.Calamity().prismaticSet = true; - player.statManaMax2 += 40; - player.manaCost *= 0.85f; - player.manaRegenBonus += 8; - var hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey); + player.manaRegenBonus += ManaRegenBonus; + Color AbilityBriefColor = Color.Lerp(new Color(255, 106, 246), new Color(148, 145, 243), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(AbilityBriefColor.Hex3(), CalamityUtils.GetArmorSetBonusKey(), LaserDuration.FramesToSeconds(), LaserCooldown.FramesToSeconds()); } public override void UpdateEquip(Player player) { player.Calamity().prismaticHelmet = true; - player.GetDamage() -= 0.2f; - player.GetDamage() += 0.2f; - player.GetDamage() += 0.18f; - player.GetCritChance() += 12; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; + player.GetDamage() -= NonMagicDamageDecrease; + player.GetDamage() += NonMagicDamageDecrease; } public override void AddRecipes() @@ -60,7 +74,7 @@ namespace CalamityMod.Items.Armor.Prismatic AddIngredient(5). AddIngredient(4). AddIngredient(ItemID.Nanites, 300). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Prismatic/PrismaticRegalia.cs b/Items/Armor/Prismatic/PrismaticRegalia.cs index fbb6023108..0df8c6ea13 100644 --- a/Items/Armor/Prismatic/PrismaticRegalia.cs +++ b/Items/Armor/Prismatic/PrismaticRegalia.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Prismatic @@ -11,9 +12,16 @@ namespace CalamityMod.Items.Armor.Prismatic public class PrismaticRegalia : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float MagicDamageBoost = 0.15f; + public static int MagicCritBoost = 15; // NOTE: Tooltip shares this number with damage % as they're equal + public static float NonMagicDamageDecrease = 0.2f; + public static int RocketChanceDenominator = 20; + public static float RocketDamageRatio = 0.25f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MagicDamageBoost.ToPercent(), NonMagicDamageDecrease.ToPercent(), RocketChanceDenominator.GetChanceFromDenominator()); + public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -37,12 +45,10 @@ namespace CalamityMod.Items.Armor.Prismatic public override void UpdateEquip(Player player) { player.Calamity().prismaticRegalia = true; - player.statLifeMax2 += 20; - player.statManaMax2 += 40; - player.GetDamage() += 0.12f; - player.GetCritChance() += 15; - player.GetDamage() -= 0.2f; - player.GetDamage() += 0.2f; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; + player.GetDamage() -= NonMagicDamageDecrease; + player.GetDamage() += NonMagicDamageDecrease; } public override void AddRecipes() @@ -52,7 +58,7 @@ namespace CalamityMod.Items.Armor.Prismatic AddIngredient(5). AddIngredient(8). AddIngredient(ItemID.Nanites, 300). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Reaver/ReaverCuisses.cs b/Items/Armor/Reaver/ReaverCuisses.cs index 56c540e454..f44835ab63 100644 --- a/Items/Armor/Reaver/ReaverCuisses.cs +++ b/Items/Armor/Reaver/ReaverCuisses.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Reaver @@ -9,20 +10,20 @@ namespace CalamityMod.Items.Armor.Reaver public class ReaverCuisses : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float MoveSpeedBoost = 0.12f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 22; Item.height = 18; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 14; + Item.defense = 18; } - public override void UpdateEquip(Player player) - { - player.GetCritChance() += 5; - player.moveSpeed += 0.12f; - } + public override void UpdateEquip(Player player) => player.moveSpeed += MoveSpeedBoost; public override void AddRecipes() { diff --git a/Items/Armor/Reaver/ReaverHeadExplore.cs b/Items/Armor/Reaver/ReaverHeadExplore.cs index 116c8e422e..26598da235 100644 --- a/Items/Armor/Reaver/ReaverHeadExplore.cs +++ b/Items/Armor/Reaver/ReaverHeadExplore.cs @@ -1,10 +1,8 @@ -using CalamityMod.Buffs.Pets; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Typeless; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Reaver @@ -14,19 +12,26 @@ namespace CalamityMod.Items.Armor.Reaver public class ReaverHeadExplore : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float MiningSpeedBoost = 0.2f; + public static float PlacementSpeedBoost = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MiningSpeedBoost.ToPercent(), PlacementSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusAggroReduction = 400; + public static int SetBonusTileRangeBoost = 7; + public static int SetBonusGrabRangeBoost = 246; // (2.625 + 15.375 = 18 tiles) + public override void SetDefaults() { Item.width = 22; Item.height = 22; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 7; + Item.defense = 6; // 48 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -36,30 +41,24 @@ namespace CalamityMod.Items.Armor.Reaver public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusTileRangeBoost); var modPlayer = player.Calamity(); modPlayer.reaverExplore = true; modPlayer.wearingRogueArmor = true; player.findTreasure = true; - player.aggro -= 200; - if (player.IsUnderwater()) + player.aggro -= SetBonusAggroReduction; + if (player.Calamity().countsAsAnyWet) player.gills = true; + DelegateMethods.v3_1 = new Vector3(1f, 1f, 1f); + Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 20f, DelegateMethods.CastLightOpen); + Utils.PlotTileLine(player.Left, player.Right, 20f, DelegateMethods.CastLightOpen); + if (player.whoAmI == Main.myPlayer) { - var source = player.GetSource_ItemUse(Item); - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - Projectile.NewProjectile(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); - } - // These are static variables. Awesome - Player.tileRangeX += 7; - Player.tileRangeY += 7; + Player.tileRangeX += SetBonusTileRangeBoost; + Player.tileRangeY += SetBonusTileRangeBoost; } } @@ -67,9 +66,9 @@ namespace CalamityMod.Items.Armor.Reaver { player.ignoreWater = true; player.lavaImmune = true; - player.pickSpeed -= 0.2f; - player.tileSpeed += 0.5f; - player.wallSpeed += 0.5f; + player.pickSpeed -= MiningSpeedBoost; + player.tileSpeed += PlacementSpeedBoost; + player.wallSpeed += PlacementSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Reaver/ReaverHeadMobility.cs b/Items/Armor/Reaver/ReaverHeadMobility.cs index f6f861a712..ec0e3a7efd 100644 --- a/Items/Armor/Reaver/ReaverHeadMobility.cs +++ b/Items/Armor/Reaver/ReaverHeadMobility.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Reaver @@ -11,20 +11,25 @@ namespace CalamityMod.Items.Armor.Reaver public class ReaverHeadMobility : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; - //Jump/Flight Boosts and Movement Speed Helm + + public static float MoveSpeedBoost = 0.15f; + public static float JumpSpeedBoost = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent(), JumpSpeedBoost.ToJumpSpeedPercent()); + + public static float SetBonusFlightBoost = 0.1f; + public static float SetBonusHookBoost = 0.5f; + public static int SetBonusDashDelayReductionInterval = 3; + public override void SetDefaults() { Item.width = 24; Item.height = 28; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 13; //46 + Item.defense = 13; // 55 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -37,17 +42,17 @@ namespace CalamityMod.Items.Armor.Reaver var modPlayer = player.Calamity(); modPlayer.reaverSpeed = true; modPlayer.wearingRogueArmor = true; - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusFlightBoost.ToPercent(), SetBonusHookBoost.ToPercent(), (1 / (float)SetBonusDashDelayReductionInterval).ToPercent()); player.noFallDmg = true; player.autoJump = true; - if (player.miscCounter % 3 == 2 && player.dashDelay > 0) + if (player.miscCounter % SetBonusDashDelayReductionInterval == 1 && player.dashDelay > 0) player.dashDelay--; } public override void UpdateEquip(Player player) { - player.jumpSpeedBoost += 0.5f; - player.moveSpeed += 0.15f; + player.moveSpeed += MoveSpeedBoost; + player.jumpSpeedBoost += JumpSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Reaver/ReaverHeadTank.cs b/Items/Armor/Reaver/ReaverHeadTank.cs index 0aff26f2c8..8d84aede61 100644 --- a/Items/Armor/Reaver/ReaverHeadTank.cs +++ b/Items/Armor/Reaver/ReaverHeadTank.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Reaver @@ -13,23 +13,28 @@ namespace CalamityMod.Items.Armor.Reaver public new string LocalizationCategory => "Items.Armor.Hardmode"; internal static string HealOrbEntitySourceContext => "SetBonus_Calamity_ReaverTank"; + public static int MaxLifeBoost = 50; + public static int RegenBoost = 8; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifeBoost, RegenBoost.ToRegenPerSecond()); + + // Set Bonus + public static int SetBonusAggroBoost = 600; + public static float SetBonusDebuffDamageReduction = 0.2f; + public static float SetBonusMobilityReduction = 0.3f; + public static int ReaverRageDuration = CalamityUtils.SecondsToFrames(5); public static int ReaverRageDefenseBoost = 5; public static float ReaverRageDamageBoost = 0.1f; - //Defense and DR Helm public override void SetDefaults() { Item.width = 28; Item.height = 30; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 30; //63 => 73 w/ set bonus (+5 w/ Reaver Rage) + Item.defense = 28; // 70 (75 with Reaver Rage) } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -40,22 +45,17 @@ namespace CalamityMod.Items.Armor.Reaver public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); - player.thorns += 0.33f; - player.moveSpeed -= 0.3f; - player.statDefense += 10; - player.lifeRegen += 3; - player.aggro += 600; + player.moveSpeed -= SetBonusMobilityReduction; + player.aggro += SetBonusAggroBoost; modPlayer.reaverDefense = true; modPlayer.wearingRogueArmor = true; - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusDebuffDamageReduction.ToPercent(), SetBonusMobilityReduction.ToPercent(), ReaverRageDuration.FramesToSeconds()); } public override void UpdateEquip(Player player) { - player.GetDamage() -= 0.3f; - player.endurance += 0.15f; - player.Calamity().reaverRegen = true; - player.statLifeMax2 += 50; + player.statLifeMax2 += MaxLifeBoost; + player.lifeRegen += RegenBoost; } public override void AddRecipes() diff --git a/Items/Armor/Reaver/ReaverScaleMail.cs b/Items/Armor/Reaver/ReaverScaleMail.cs index 4b4f5a5f6d..90cba4743e 100644 --- a/Items/Armor/Reaver/ReaverScaleMail.cs +++ b/Items/Armor/Reaver/ReaverScaleMail.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Reaver @@ -9,9 +10,12 @@ namespace CalamityMod.Items.Armor.Reaver public class ReaverScaleMail : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float DamageReductionBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageReductionBoost.ToPercent()); + public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -27,15 +31,10 @@ namespace CalamityMod.Items.Armor.Reaver Item.height = 22; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 19; + Item.defense = 24; } - public override void UpdateEquip(Player player) - { - player.statLifeMax2 += 20; - player.GetDamage() += 0.09f; - player.GetCritChance() += 4; - } + public override void UpdateEquip(Player player) => player.endurance += DamageReductionBoost; public override void AddRecipes() { diff --git a/Items/Armor/Silva/SilvaArmor.cs b/Items/Armor/Silva/SilvaArmor.cs index 0aa94e0c19..6c7104676c 100644 --- a/Items/Armor/Silva/SilvaArmor.cs +++ b/Items/Armor/Silva/SilvaArmor.cs @@ -3,7 +3,8 @@ using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; +using Terraria.Audio; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Silva @@ -12,20 +13,32 @@ namespace CalamityMod.Items.Armor.Silva public class SilvaArmor : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/SilvaActivation"); + public static readonly SoundStyle DispelSound = new("CalamityMod/Sounds/Custom/AbilitySounds/SilvaDispel"); + + public static float DamageBoost = 0.15f; + public static int CritBoost = 11; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost); + + // Common Set Bonus + public static int SetBonusRegenBoost = 6; + public static float AccelerationBoost = 0.05f; + public static int ReviveDuration = CalamityUtils.SecondsToFrames(5); + public static int ReviveCooldown = CalamityUtils.SecondsToFrames(5 * 60); + public override void SetDefaults() { Item.width = 24; Item.height = 24; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 44; - Item.rare = ModContent.RarityType(); + Item.defense = 38; + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.statLifeMax2 += 80; - player.GetDamage() += 0.12f; - player.GetCritChance() += 8; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Silva/SilvaHeadMagic.cs b/Items/Armor/Silva/SilvaHeadMagic.cs index 468d54a814..1b6ae86e25 100644 --- a/Items/Armor/Silva/SilvaHeadMagic.cs +++ b/Items/Armor/Silva/SilvaHeadMagic.cs @@ -1,11 +1,11 @@ -using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; +using static CalamityMod.Items.Armor.Silva.SilvaArmor; namespace CalamityMod.Items.Armor.Silva { @@ -14,39 +14,46 @@ namespace CalamityMod.Items.Armor.Silva public class SilvaHeadMagic : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static int MaxManaBoost = 100; + public static float ManaCostReduction = 0.19f; + public static float MagicDamageBoost = 0.18f; + public static int MagicCritBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost); + + // Set Bonus + public static int BurstCooldown = CalamityUtils.SecondsToFrames(5); + public static int BurstDamage = 800; // Damage + (projectile damage) * Damage Ratio + public static double BurstDamageRatio = 0.6D; + public static int BurstDamageSoftcap = 1400; + public override void SetDefaults() { Item.width = 24; Item.height = 22; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 21; //110 - Item.rare = ModContent.RarityType(); + Item.defense = 24; // 90 + Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.silvaSet = true; modPlayer.silvaMage = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRegenBoost.ToRegenPerSecond(), AccelerationBoost.ToPercent(), ReviveDuration.FramesToSeconds(), (ReviveCooldown / 60).FramesToSeconds()); } public override void UpdateEquip(Player player) { - player.manaCost *= 0.81f; - player.GetDamage() += 0.23f; - player.GetCritChance() += 13; - player.statManaMax2 += 100; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Silva/SilvaHeadSummon.cs b/Items/Armor/Silva/SilvaHeadSummon.cs index d6d3c29800..356c625801 100644 --- a/Items/Armor/Silva/SilvaHeadSummon.cs +++ b/Items/Armor/Silva/SilvaHeadSummon.cs @@ -1,15 +1,11 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.Audio; -using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; +using static CalamityMod.Items.Armor.Silva.SilvaArmor; namespace CalamityMod.Items.Armor.Silva { @@ -19,27 +15,28 @@ namespace CalamityMod.Items.Armor.Silva { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; internal static string SilvaCrystalEntitySourceContext => "SetBonus_Calamity_SilvaSummon"; - public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/AbilitySounds/SilvaActivation"); - public static readonly SoundStyle DispelSound = new("CalamityMod/Sounds/Custom/AbilitySounds/SilvaDispel"); + + public static int MinionSlotBoost = 2; + public static float SummonDamageBoost = 0.3f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 3; + public static float SetBonusSummonDamageBoost = 0.4f; + public static int CrystalDamage = 380; public override void SetDefaults() { Item.width = 28; Item.height = 24; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 13; //110 - Item.rare = ModContent.RarityType(); + Item.defense = 18; // 84 + Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; public override void UpdateArmorSet(Player player) { @@ -47,12 +44,16 @@ namespace CalamityMod.Items.Armor.Silva modPlayer.silvaSet = true; modPlayer.silvaSummon = true; modPlayer.WearingPostMLSummonerSet = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - player.GetDamage() += 0.65f; - player.maxMinions += 5; + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent(), SetBonusRegenBoost.ToRegenPerSecond(), AccelerationBoost.ToPercent(), ReviveDuration.FramesToSeconds(), (ReviveCooldown / 60).FramesToSeconds()); + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; } - public override void UpdateEquip(Player player) => player.GetDamage() += 0.1f; + public override void UpdateEquip(Player player) + { + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; + } public override void AddRecipes() { diff --git a/Items/Armor/Silva/SilvaLeggings.cs b/Items/Armor/Silva/SilvaLeggings.cs index 9a7be46dde..9faf9d6353 100644 --- a/Items/Armor/Silva/SilvaLeggings.cs +++ b/Items/Armor/Silva/SilvaLeggings.cs @@ -3,7 +3,7 @@ using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Silva @@ -12,20 +12,26 @@ namespace CalamityMod.Items.Armor.Silva public class SilvaLeggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.11f; + public static int CritBoost = 11; // NOTE: Tooltip shares this number with damage % as they're equal + public static float MoveSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 22; Item.height = 18; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 39; - Item.rare = ModContent.RarityType(); + Item.defense = 28; + Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.moveSpeed += 0.1f; - player.GetDamage() += 0.12f; - player.GetCritChance() += 12; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs b/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs index c9cc263a73..eb8c2b383c 100644 --- a/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs +++ b/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs @@ -1,5 +1,6 @@ using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.SnowRuffian @@ -8,6 +9,10 @@ namespace CalamityMod.Items.Armor.SnowRuffian public class SnowRuffianChestplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int RangedCritBoost = 4; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedCritBoost); + public override void Load() { if (Main.dedServ) @@ -19,7 +24,6 @@ namespace CalamityMod.Items.Armor.SnowRuffian public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -35,18 +39,16 @@ namespace CalamityMod.Items.Armor.SnowRuffian Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 4; //9 + Item.defense = 5; //12 } - public override void UpdateEquip(Player player) - { - player.GetCritChance() += 3; - } + public override void UpdateEquip(Player player) => player.GetCritChance() += RangedCritBoost; public override void AddRecipes() { CreateRecipe(). - AddRecipeGroup("AnySnowBlock", 60). + AddIngredient(ItemID.BorealWood, 20). + AddIngredient(ItemID.Silk, 6). AddIngredient(ItemID.FlinxFur, 2). AddTile(TileID.Anvils). Register(); diff --git a/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs b/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs index 5e4137d56e..8c1bbf66ac 100644 --- a/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs +++ b/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs @@ -1,5 +1,6 @@ using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.SnowRuffian @@ -8,24 +9,26 @@ namespace CalamityMod.Items.Armor.SnowRuffian public class SnowRuffianGreaves : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int RangedCritBoost = 4; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedCritBoost); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 3; //9 + Item.defense = 4; //12 } - public override void UpdateEquip(Player player) - { - player.moveSpeed += 0.05f; - } + public override void UpdateEquip(Player player) => player.GetCritChance() += RangedCritBoost; public override void AddRecipes() { CreateRecipe(). - AddRecipeGroup("AnySnowBlock", 40). + AddIngredient(ItemID.BorealWood, 15). + AddIngredient(ItemID.Silk, 5). AddIngredient(ItemID.FlinxFur). AddTile(TileID.Anvils). Register(); diff --git a/Items/Armor/SnowRuffian/SnowRuffianMask.cs b/Items/Armor/SnowRuffian/SnowRuffianMask.cs index c05014c4cb..bff6f97d86 100644 --- a/Items/Armor/SnowRuffian/SnowRuffianMask.cs +++ b/Items/Armor/SnowRuffian/SnowRuffianMask.cs @@ -1,6 +1,6 @@ -using CalamityMod.CalPlayer; -using Terraria; +using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.SnowRuffian @@ -9,8 +9,13 @@ namespace CalamityMod.Items.Armor.SnowRuffian public class SnowRuffianMask : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; - private bool shouldBoost = false; + public static int RangedCritBoost = 4; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedCritBoost); + + // Set Bonus + public static float GlideFallSpeedMult = 0.9f; + public static int SetBonusFrostburnDuration = CalamityUtils.SecondsToFrames(3); public override void Load() { @@ -26,70 +31,33 @@ namespace CalamityMod.Items.Armor.SnowRuffian Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 2; //9 + Item.defense = 3; // 12 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.snowRuffianSet = true; - modPlayer.rogueStealthMax += 0.5f; - player.setBonus = this.GetLocalizedValue("SetBonus"); - player.GetDamage() += 0.05f; - player.Calamity().wearingRogueArmor = true; - - if (player.controlJump) - { - player.noFallDmg = true; - player.UpdateJumpHeight(); - if (shouldBoost && !player.mount.Active) - { - player.velocity.X *= 1.1f; - shouldBoost = false; - } - - } - else if (!shouldBoost && player.velocity.Y == 0) - { - shouldBoost = true; - } + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusFrostburnDuration.FramesToSeconds()); } - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.02f; - } + public override void UpdateEquip(Player player) => player.GetCritChance() += RangedCritBoost; public override void AddRecipes() { CreateRecipe(). - AddRecipeGroup("AnySnowBlock", 20). + AddIngredient(ItemID.BorealWood, 10). + AddIngredient(ItemID.Silk, 4). AddIngredient(ItemID.FlinxFur). AddTile(TileID.Anvils). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } } + public class SnowRuffianWings : EquipTexture { - public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) - { - ascentWhenFalling = 0.5f; - ascentWhenRising = 0f; - maxCanAscendMultiplier = 0f; - maxAscentMultiplier = 0f; - constantAscend = 0f; - } - - public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration) - { - speed = 2f; - acceleration *= 1.25f; - } } } diff --git a/Items/Armor/Statigel/StatigelArmor.cs b/Items/Armor/Statigel/StatigelArmor.cs index 0ff1c28e1f..61f1107a57 100644 --- a/Items/Armor/Statigel/StatigelArmor.cs +++ b/Items/Armor/Statigel/StatigelArmor.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Statigel @@ -10,9 +10,16 @@ namespace CalamityMod.Items.Armor.Statigel public class StatigelArmor : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int CritBoost = 5; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(CritBoost); + + // Common Set Bonus + public static float SetBonusJumpSpeedBoost = 0.6f; + public static float SetBonusJumpHeightPercentBoost = 0.3334f; + public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -31,14 +38,14 @@ namespace CalamityMod.Items.Armor.Statigel Item.defense = 10; } - public override void UpdateEquip(Player player) => player.GetCritChance() += 5; + public override void UpdateEquip(Player player) => player.GetCritChance() += CritBoost; public override void AddRecipes() { CreateRecipe(). AddIngredient(12). AddIngredient(12). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Armor/Statigel/StatigelGreaves.cs b/Items/Armor/Statigel/StatigelGreaves.cs index ce2b1d9665..ecb28cc6d6 100644 --- a/Items/Armor/Statigel/StatigelGreaves.cs +++ b/Items/Armor/Statigel/StatigelGreaves.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Statigel @@ -10,6 +10,11 @@ namespace CalamityMod.Items.Armor.Statigel public class StatigelGreaves : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float DamageBoost = 0.05f; + public static float MoveSpeedBoost = 0.05f; // NOTE: Tooltip shares this number with damage % as they're equal + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -21,8 +26,8 @@ namespace CalamityMod.Items.Armor.Statigel public override void UpdateEquip(Player player) { - player.GetDamage() += 0.05f; - player.moveSpeed += 0.05f; + player.GetDamage() += DamageBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() @@ -30,7 +35,7 @@ namespace CalamityMod.Items.Armor.Statigel CreateRecipe(). AddIngredient(7). AddIngredient(7). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Armor/Statigel/StatigelHeadMagic.cs b/Items/Armor/Statigel/StatigelHeadMagic.cs index e4c60df6fc..c89fd173f6 100644 --- a/Items/Armor/Statigel/StatigelHeadMagic.cs +++ b/Items/Armor/Statigel/StatigelHeadMagic.cs @@ -1,8 +1,8 @@ using CalamityMod.ExtraJumps; using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Statigel @@ -12,6 +12,13 @@ namespace CalamityMod.Items.Armor.Statigel public class StatigelHeadMagic : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int MaxManaBoost = 40; + public static float ManaCostReduction = 0.1f; + public static float MagicDamageBoost = 0.1f; + public static int MagicCritBoost = 7; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost); + public override void SetDefaults() { Item.width = 18; @@ -21,27 +28,24 @@ namespace CalamityMod.Items.Armor.Statigel Item.defense = 5; //22 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { - player.setBonus = CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = CalamityUtils.GetTextFromModItem("CommonSetBonus").Format(StatigelArmor.SetBonusJumpSpeedBoost.ToJumpSpeedPercent()); var modPlayer = player.Calamity(); modPlayer.statigelSet = true; player.GetJumpState().Enable(); - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; + Player.jumpHeight += (int)(StatigelArmor.SetBonusJumpHeightPercentBoost * 15); + player.jumpSpeedBoost += StatigelArmor.SetBonusJumpSpeedBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 7; - player.manaCost *= 0.9f; - player.statManaMax2 += 40; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; + player.manaCost -= ManaCostReduction; + player.statManaMax2 += MaxManaBoost; } public override void AddRecipes() @@ -49,7 +53,7 @@ namespace CalamityMod.Items.Armor.Statigel CreateRecipe(). AddIngredient(5). AddIngredient(5). - AddTile(). + AddTile(TileID.Solidifier). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Statigel/StatigelHeadMelee.cs b/Items/Armor/Statigel/StatigelHeadMelee.cs index 078d4805df..f6c99987d2 100644 --- a/Items/Armor/Statigel/StatigelHeadMelee.cs +++ b/Items/Armor/Statigel/StatigelHeadMelee.cs @@ -1,8 +1,8 @@ using CalamityMod.ExtraJumps; using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Statigel @@ -12,6 +12,15 @@ namespace CalamityMod.Items.Armor.Statigel public class StatigelHeadMelee : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float MeleeDamageBoost = 0.1f; + public static float MeleeSpeedBoost = 0.1f; // NOTE: Tooltip shares this number with damage % as they're equal + public static int MeleeCritBoost = 7; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent(), MeleeCritBoost); + + // Set Bonus + public static int SetBonusAggroBoost = 400; + public override void SetDefaults() { Item.width = 18; @@ -21,27 +30,24 @@ namespace CalamityMod.Items.Armor.Statigel Item.defense = 9; //27 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(StatigelArmor.SetBonusJumpSpeedBoost.ToJumpSpeedPercent()); var modPlayer = player.Calamity(); modPlayer.statigelSet = true; player.GetJumpState().Enable(); - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; - player.aggro += 400; + Player.jumpHeight += (int)(StatigelArmor.SetBonusJumpHeightPercentBoost * 15); + player.jumpSpeedBoost += StatigelArmor.SetBonusJumpSpeedBoost; + player.aggro += SetBonusAggroBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 7; - player.GetAttackSpeed() += 0.1f; + player.GetDamage() += MeleeDamageBoost; + player.GetCritChance() += MeleeCritBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; } public override void AddRecipes() @@ -49,7 +55,7 @@ namespace CalamityMod.Items.Armor.Statigel CreateRecipe(). AddIngredient(5). AddIngredient(5). - AddTile(). + AddTile(TileID.Solidifier). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Statigel/StatigelHeadRanged.cs b/Items/Armor/Statigel/StatigelHeadRanged.cs index 25820004c8..980989d6c0 100644 --- a/Items/Armor/Statigel/StatigelHeadRanged.cs +++ b/Items/Armor/Statigel/StatigelHeadRanged.cs @@ -1,8 +1,8 @@ using CalamityMod.ExtraJumps; using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Statigel @@ -12,6 +12,11 @@ namespace CalamityMod.Items.Armor.Statigel public class StatigelHeadRanged : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float RangedDamageBoost = 0.1f; + public static int RangedCritBoost = 7; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), RangedCritBoost); + public override void SetDefaults() { Item.width = 18; @@ -21,25 +26,22 @@ namespace CalamityMod.Items.Armor.Statigel Item.defense = 7; //25 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { - player.setBonus = CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = CalamityUtils.GetTextFromModItem("CommonSetBonus").Format(StatigelArmor.SetBonusJumpSpeedBoost.ToJumpSpeedPercent()); var modPlayer = player.Calamity(); modPlayer.statigelSet = true; player.GetJumpState().Enable(); - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; + Player.jumpHeight += (int)(StatigelArmor.SetBonusJumpHeightPercentBoost * 15); + player.jumpSpeedBoost += StatigelArmor.SetBonusJumpSpeedBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 7; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() @@ -47,7 +49,7 @@ namespace CalamityMod.Items.Armor.Statigel CreateRecipe(). AddIngredient(5). AddIngredient(5). - AddTile(). + AddTile(TileID.Solidifier). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Statigel/StatigelHeadRogue.cs b/Items/Armor/Statigel/StatigelHeadRogue.cs index fab0c20533..747b2bb836 100644 --- a/Items/Armor/Statigel/StatigelHeadRogue.cs +++ b/Items/Armor/Statigel/StatigelHeadRogue.cs @@ -1,8 +1,8 @@ using CalamityMod.ExtraJumps; using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Statigel @@ -12,6 +12,15 @@ namespace CalamityMod.Items.Armor.Statigel public class StatigelHeadRogue : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float RogueDamageBoost = 0.1f; + public static int RogueCritBoost = 7; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 0.9f; + public override void SetDefaults() { Item.width = 18; @@ -21,28 +30,25 @@ namespace CalamityMod.Items.Armor.Statigel Item.defense = 6; //23 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), StatigelArmor.SetBonusJumpSpeedBoost.ToJumpSpeedPercent()); var modPlayer = player.Calamity(); modPlayer.statigelSet = true; player.GetJumpState().Enable(); - modPlayer.rogueStealthMax += 0.9f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; + Player.jumpHeight += (int)(StatigelArmor.SetBonusJumpHeightPercentBoost * 15); + player.jumpSpeedBoost += StatigelArmor.SetBonusJumpSpeedBoost; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 7; - player.moveSpeed += 0.05f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() @@ -50,7 +56,7 @@ namespace CalamityMod.Items.Armor.Statigel CreateRecipe(). AddIngredient(5). AddIngredient(5). - AddTile(). + AddTile(TileID.Solidifier). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Statigel/StatigelHeadSummon.cs b/Items/Armor/Statigel/StatigelHeadSummon.cs index 44b9d4b2f4..758ec5d5ba 100644 --- a/Items/Armor/Statigel/StatigelHeadSummon.cs +++ b/Items/Armor/Statigel/StatigelHeadSummon.cs @@ -1,12 +1,11 @@ using CalamityMod.Buffs.Summon; using CalamityMod.ExtraJumps; using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Statigel @@ -16,6 +15,13 @@ namespace CalamityMod.Items.Armor.Statigel public class StatigelHeadSummon : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static float SetBonusSummonDamageBoost = 0.15f; public static int SlimeDamage = 18; public override void SetDefaults() @@ -27,22 +33,18 @@ namespace CalamityMod.Items.Armor.Statigel Item.defense = 4; //20 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusSummonDamageBoost.ToPercent(), StatigelArmor.SetBonusJumpSpeedBoost.ToJumpSpeedPercent()); var modPlayer = player.Calamity(); modPlayer.statigelSet = true; modPlayer.slimeGod = true; player.GetJumpState().Enable(); - Player.jumpHeight += 5; - player.jumpSpeedBoost += 0.6f; - player.GetDamage() += 0.18f; - player.maxMinions++; + Player.jumpHeight += (int)(StatigelArmor.SetBonusJumpHeightPercentBoost * 15); + player.jumpSpeedBoost += StatigelArmor.SetBonusJumpSpeedBoost; + player.GetDamage() += SetBonusSummonDamageBoost; if (player.whoAmI == Main.myPlayer) { var source = player.GetSource_Accessory(Item); @@ -66,7 +68,8 @@ namespace CalamityMod.Items.Armor.Statigel public override void UpdateEquip(Player player) { - player.GetKnockback() += 1.5f; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; } public override void AddRecipes() @@ -74,7 +77,7 @@ namespace CalamityMod.Items.Armor.Statigel CreateRecipe(). AddIngredient(5). AddIngredient(5). - AddTile(). + AddTile(TileID.Solidifier). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Sulphurous/SulphurousBreastplate.cs b/Items/Armor/Sulphurous/SulphurousBreastplate.cs index bf6118be31..e28b61c5e4 100644 --- a/Items/Armor/Sulphurous/SulphurousBreastplate.cs +++ b/Items/Armor/Sulphurous/SulphurousBreastplate.cs @@ -1,7 +1,8 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Sulphurous @@ -11,6 +12,10 @@ namespace CalamityMod.Items.Armor.Sulphurous public class SulphurousBreastplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float RogueDamageBoost = 0.06f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 24; @@ -20,11 +25,7 @@ namespace CalamityMod.Items.Armor.Sulphurous Item.rare = ItemRarityID.Green; } - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.06f; - player.GetCritChance() += 4; - } + public override void UpdateEquip(Player player) => player.GetDamage() += RogueDamageBoost; public override void AddRecipes() { diff --git a/Items/Armor/Sulphurous/SulphurousHelmet.cs b/Items/Armor/Sulphurous/SulphurousHelmet.cs index 2f3b5b0f9f..cb3d8d98f2 100644 --- a/Items/Armor/Sulphurous/SulphurousHelmet.cs +++ b/Items/Armor/Sulphurous/SulphurousHelmet.cs @@ -1,9 +1,9 @@ -using CalamityMod.CalPlayer; -using CalamityMod.ExtraJumps; +using CalamityMod.ExtraJumps; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Sulphurous @@ -13,6 +13,15 @@ namespace CalamityMod.Items.Armor.Sulphurous public class SulphurousHelmet : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int RogueCritBoost = 6; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueCritBoost); + + // Set Bonus + public static int SetBonusPoisonDuration = CalamityUtils.SecondsToFrames(1); + public static float SetBonusRogueStealth = 0.65f; + public static int BubbleDamage = 20; + public override void SetDefaults() { Item.width = 26; @@ -29,20 +38,18 @@ namespace CalamityMod.Items.Armor.Sulphurous public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), SetBonusPoisonDuration.FramesToSeconds()); var modPlayer = player.Calamity(); modPlayer.sulphurSet = true; player.GetJumpState().Enable(); - modPlayer.rogueStealthMax += 0.65f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; - player.ignoreWater = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.04f; - player.GetCritChance() += 2; - if (player.IsUnderwater()) + player.GetCritChance() += RogueCritBoost; + if (player.Calamity().countsAsAnyWet) player.gills = true; } diff --git a/Items/Armor/Sulphurous/SulphurousLeggings.cs b/Items/Armor/Sulphurous/SulphurousLeggings.cs index ada7ef2a1b..b9ed660705 100644 --- a/Items/Armor/Sulphurous/SulphurousLeggings.cs +++ b/Items/Armor/Sulphurous/SulphurousLeggings.cs @@ -1,7 +1,8 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Sulphurous @@ -11,6 +12,10 @@ namespace CalamityMod.Items.Armor.Sulphurous public class SulphurousLeggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float RogueDamageBoost = 0.04f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 22; @@ -20,10 +25,7 @@ namespace CalamityMod.Items.Armor.Sulphurous Item.rare = ItemRarityID.Green; } - public override void UpdateEquip(Player player) - { - player.moveSpeed += Collision.DrownCollision(player.position, player.width, player.height, player.gravDir) ? 0.35f : 0.1f; - } + public override void UpdateEquip(Player player) => player.GetDamage() += RogueDamageBoost; public override void AddRecipes() { diff --git a/Items/Armor/Tarragon/TarragonBreastplate.cs b/Items/Armor/Tarragon/TarragonBreastplate.cs index 0596b39c82..f51bbea2a2 100644 --- a/Items/Armor/Tarragon/TarragonBreastplate.cs +++ b/Items/Armor/Tarragon/TarragonBreastplate.cs @@ -2,6 +2,7 @@ using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Tarragon @@ -10,21 +11,28 @@ namespace CalamityMod.Items.Armor.Tarragon public class TarragonBreastplate : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.12f; + public static int CritBoost = 8; + public static int RegenBoost = 4; + public static float DamageReductionBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost, RegenBoost.ToRegenPerSecond(), DamageReductionBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; - Item.lifeRegen = 3; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.defense = 37; + Item.defense = 36; Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.statLifeMax2 += 40; - player.GetDamage() += 0.1f; - player.GetCritChance() += 5; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.lifeRegen += RegenBoost; + player.endurance += DamageReductionBoost; } public override void AddRecipes() @@ -32,7 +40,7 @@ namespace CalamityMod.Items.Armor.Tarragon CreateRecipe(). AddIngredient(15). AddIngredient(18). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Armor/Tarragon/TarragonHeadMagic.cs b/Items/Armor/Tarragon/TarragonHeadMagic.cs index d51fa12857..5081997c12 100644 --- a/Items/Armor/Tarragon/TarragonHeadMagic.cs +++ b/Items/Armor/Tarragon/TarragonHeadMagic.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Tarragon @@ -12,19 +12,27 @@ namespace CalamityMod.Items.Armor.Tarragon public class TarragonHeadMagic : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static int MaxManaBoost = 100; + public static float ManaCostReduction = 0.15f; + public static float MagicDamageBoost = 0.15f; + public static int MagicCritBoost = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, ManaCostReduction.ToPercent(), MagicDamageBoost.ToPercent(), MagicCritBoost); + + // Set Bonus + public static int CritsToSpawnLeaves = 5; + public static float LeafDamageRatio = 0.2f; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.defense = 10; //98 + Item.defense = 16; // 76 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -37,16 +45,15 @@ namespace CalamityMod.Items.Armor.Tarragon var modPlayer = player.Calamity(); modPlayer.tarraSet = true; modPlayer.tarraMage = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalizedValue("SetBonus"); } public override void UpdateEquip(Player player) { - player.manaCost *= 0.85f; - player.GetDamage() += 0.15f; - player.GetCritChance() += 10; - player.endurance += 0.1f; - player.statManaMax2 += 100; + player.statManaMax2 += MaxManaBoost; + player.manaCost -= ManaCostReduction; + player.GetDamage() += MagicDamageBoost; + player.GetCritChance() += MagicCritBoost; } public override void AddRecipes() @@ -54,7 +61,7 @@ namespace CalamityMod.Items.Armor.Tarragon CreateRecipe(). AddIngredient(7). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Tarragon/TarragonHeadMelee.cs b/Items/Armor/Tarragon/TarragonHeadMelee.cs index 94f2ae5883..ee44143770 100644 --- a/Items/Armor/Tarragon/TarragonHeadMelee.cs +++ b/Items/Armor/Tarragon/TarragonHeadMelee.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Tarragon @@ -12,19 +12,30 @@ namespace CalamityMod.Items.Armor.Tarragon public class TarragonHeadMelee : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float MeleeDamageBoost = 0.1f; + public static int MeleeCritBoost = 5; + public static float MeleeSpeedBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MeleeDamageBoost.ToPercent(), MeleeCritBoost, MeleeSpeedBoost.ToPercent()); + + // Set Bonus + public static int SetBonusAggroBoost = 800; + public static int TarraLifeDuration = CalamityUtils.SecondsToFrames(5); + public static int TarraLifeRegenBoost = 3; + public static float CloakContactDamageReduction = 0.5f; + public static int CloakDuration = CalamityUtils.SecondsToFrames(10); + public static int CloakCooldown = CalamityUtils.SecondsToFrames(30); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.defense = 33; //98 + Item.defense = 40; // 100 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -37,17 +48,15 @@ namespace CalamityMod.Items.Armor.Tarragon var modPlayer = player.Calamity(); modPlayer.tarraSet = true; modPlayer.tarraMelee = true; - player.GetAttackSpeed() += 0.15f; - player.aggro += 800; - var hotkey = CalamityKeybinds.ArmorSetBonusHotKey.TooltipHotkeyString(); - player.setBonus = this.GetLocalization("SetBonus").Format(hotkey) + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.aggro += SetBonusAggroBoost; + player.setBonus = this.GetLocalization("SetBonus").Format(TarraLifeRegenBoost.ToRegenPerSecond(), CalamityUtils.GetArmorSetBonusKey(), CloakDuration.FramesToSeconds(), CloakCooldown.FramesToSeconds()); } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.12f; - player.GetCritChance() += 7; - player.endurance += 0.1f; + player.GetDamage() += MeleeDamageBoost; + player.GetCritChance() += MeleeCritBoost; + player.GetAttackSpeed() += MeleeSpeedBoost; } public override void AddRecipes() @@ -55,7 +64,7 @@ namespace CalamityMod.Items.Armor.Tarragon CreateRecipe(). AddIngredient(7). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Tarragon/TarragonHeadRanged.cs b/Items/Armor/Tarragon/TarragonHeadRanged.cs index 7d29dbab8a..b066013fdc 100644 --- a/Items/Armor/Tarragon/TarragonHeadRanged.cs +++ b/Items/Armor/Tarragon/TarragonHeadRanged.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Tarragon @@ -12,19 +12,29 @@ namespace CalamityMod.Items.Armor.Tarragon public class TarragonHeadRanged : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RangedDamageBoost = 0.1f; + public static int RangedCritBoost = 7; + public static float AmmoReduction = 0.75f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent(), RangedCritBoost, (1f - AmmoReduction).ToPercent()); + + // Set Bonus + public static int OnHitEffectCooldown = CalamityUtils.SecondsToFrames(1); + public static float LeafDamageRatio = 0.25f; + public static int LeafDamageSoftcap = 150; + public static float EnergyDamageRatio = 0.33f; + public static int EnergyDamageSoftcap = 200; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.defense = 21; //98 + Item.defense = 28; // 88 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -37,14 +47,15 @@ namespace CalamityMod.Items.Armor.Tarragon var modPlayer = player.Calamity(); modPlayer.tarraSet = true; modPlayer.tarraRanged = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalizedValue("SetBonus"); } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; - player.endurance += 0.1f; + var modPlayer = player.Calamity(); + modPlayer.ammoCost *= AmmoReduction; + player.GetDamage() += RangedDamageBoost; + player.GetCritChance() += RangedCritBoost; } public override void AddRecipes() @@ -52,7 +63,7 @@ namespace CalamityMod.Items.Armor.Tarragon CreateRecipe(). AddIngredient(7). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Tarragon/TarragonHeadRogue.cs b/Items/Armor/Tarragon/TarragonHeadRogue.cs index 91f8785758..70adc74719 100644 --- a/Items/Armor/Tarragon/TarragonHeadRogue.cs +++ b/Items/Armor/Tarragon/TarragonHeadRogue.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Tarragon @@ -12,19 +12,29 @@ namespace CalamityMod.Items.Armor.Tarragon public class TarragonHeadRogue : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float RogueDamageBoost = 0.1f; + public static int RogueCritBoost = 7; + public static float MoveSpeedBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, MoveSpeedBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.15f; + public static int CritsToActivateImmunity = 50; + public static int ImmunityDuration = CalamityUtils.SecondsToFrames(2.5f); + public static int ImmunityCooldown = CalamityUtils.SecondsToFrames(25); + public static float RogueDamageBoostWhileDebuffed = 0.1f; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.defense = 15; //98 + Item.defense = 24; // 84 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -37,17 +47,16 @@ namespace CalamityMod.Items.Armor.Tarragon var modPlayer = player.Calamity(); modPlayer.tarraSet = true; modPlayer.tarraThrowing = true; - modPlayer.rogueStealthMax += 1.15f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), CritsToActivateImmunity, ImmunityDuration.FramesToSeconds(), ImmunityCooldown.FramesToSeconds(), RogueDamageBoostWhileDebuffed.ToPercent()); } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; - player.moveSpeed += 0.05f; - player.endurance += 0.1f; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() @@ -55,7 +64,7 @@ namespace CalamityMod.Items.Armor.Tarragon CreateRecipe(). AddIngredient(7). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Tarragon/TarragonHeadSummon.cs b/Items/Armor/Tarragon/TarragonHeadSummon.cs index ebaadb2a02..875953b77a 100644 --- a/Items/Armor/Tarragon/TarragonHeadSummon.cs +++ b/Items/Armor/Tarragon/TarragonHeadSummon.cs @@ -1,8 +1,8 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Tarragon @@ -14,19 +14,25 @@ namespace CalamityMod.Items.Armor.Tarragon public new string LocalizationCategory => "Items.Armor.PostMoonLord"; internal static string LifeAuraEntitySourceContext => "SetBonus_Calamity_Tarragon"; + public static int MinionSlotBoost = 1; + public static float SummonDamageBoost = 0.25f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost, SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int SetBonusMinionSlotBoost = 2; + public static float SetBonusSummonDamageBoost = 0.3f; + public static int AuraDamage = 120; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.defense = 3; //98 + Item.defense = 10; // 70 Item.rare = ModContent.RarityType(); } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void ArmorSetShadows(Player player) { @@ -40,15 +46,15 @@ namespace CalamityMod.Items.Armor.Tarragon modPlayer.tarraSet = true; modPlayer.tarraSummon = true; modPlayer.WearingPostMLSummonerSet = true; - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - player.GetDamage() += 0.5f; - player.maxMinions += 3; + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusMinionSlotBoost, SetBonusSummonDamageBoost.ToPercent()); + player.maxMinions += SetBonusMinionSlotBoost; + player.GetDamage() += SetBonusSummonDamageBoost; } public override void UpdateEquip(Player player) { - player.endurance += 0.1f; - player.GetDamage() += 0.05f; + player.maxMinions += MinionSlotBoost; + player.GetDamage() += SummonDamageBoost; } public override void AddRecipes() @@ -56,7 +62,7 @@ namespace CalamityMod.Items.Armor.Tarragon CreateRecipe(). AddIngredient(7). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } diff --git a/Items/Armor/Tarragon/TarragonLeggings.cs b/Items/Armor/Tarragon/TarragonLeggings.cs index 4aeeca59c1..0b9a6fad3c 100644 --- a/Items/Armor/Tarragon/TarragonLeggings.cs +++ b/Items/Armor/Tarragon/TarragonLeggings.cs @@ -2,6 +2,7 @@ using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Tarragon @@ -10,20 +11,26 @@ namespace CalamityMod.Items.Armor.Tarragon public class TarragonLeggings : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PostMoonLord"; + + public static float DamageBoost = 0.08f; + public static int CritBoost = 8; // NOTE: Tooltip shares this number with damage % as they're equal + public static float MoveSpeedBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.defense = 32; + Item.defense = 24; Item.rare = ModContent.RarityType(); } public override void UpdateEquip(Player player) { - player.moveSpeed += 0.1f; - player.GetDamage() += 0.08f; - player.GetCritChance() += 8; + player.GetDamage() += DamageBoost; + player.GetCritChance() += CritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() @@ -31,7 +38,7 @@ namespace CalamityMod.Items.Armor.Tarragon CreateRecipe(). AddIngredient(11). AddIngredient(12). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Armor/TitanHeart/TitanHeartBoots.cs b/Items/Armor/TitanHeart/TitanHeartBoots.cs index ae7ef7e9f4..b8582f38bb 100644 --- a/Items/Armor/TitanHeart/TitanHeartBoots.cs +++ b/Items/Armor/TitanHeart/TitanHeartBoots.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.TitanHeart @@ -10,21 +10,20 @@ namespace CalamityMod.Items.Armor.TitanHeart public class TitanHeartBoots : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.07f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; - Item.defense = 14; + Item.defense = 10; } - public override void UpdateEquip(Player player) - { - player.Calamity().titanHeartBoots = true; - player.Calamity().rogueVelocity += 0.1f; - player.GetDamage() += 0.04f; - } + public override void UpdateEquip(Player player) => player.GetDamage() += RogueDamageBoost; public override void AddRecipes() { diff --git a/Items/Armor/TitanHeart/TitanHeartMantle.cs b/Items/Armor/TitanHeart/TitanHeartMantle.cs index fbd3c17cd5..141c1848bb 100644 --- a/Items/Armor/TitanHeart/TitanHeartMantle.cs +++ b/Items/Armor/TitanHeart/TitanHeartMantle.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.TitanHeart @@ -10,9 +10,13 @@ namespace CalamityMod.Items.Armor.TitanHeart public class TitanHeartMantle : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.1f; + public static float RogueKnockbackBoost = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueKnockbackBoost.ToPercent()); + public override void SetStaticDefaults() { - if (Main.dedServ) return; @@ -28,13 +32,13 @@ namespace CalamityMod.Items.Armor.TitanHeart Item.height = 18; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; - Item.defense = 17; + Item.defense = 14; } public override void UpdateEquip(Player player) { player.Calamity().titanHeartMantle = true; - player.GetDamage() += 0.05f; + player.GetDamage() += RogueDamageBoost; } public override void AddRecipes() diff --git a/Items/Armor/TitanHeart/TitanHeartMask.cs b/Items/Armor/TitanHeart/TitanHeartMask.cs index 03b99c9fa4..a368e457bc 100644 --- a/Items/Armor/TitanHeart/TitanHeartMask.cs +++ b/Items/Armor/TitanHeart/TitanHeartMask.cs @@ -1,8 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.TitanHeart @@ -11,27 +10,34 @@ namespace CalamityMod.Items.Armor.TitanHeart public class TitanHeartMask : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.07f; + public static float RogueVelocityBoost = 0.1f; + public static int OnHitDebuffDuration = CalamityUtils.SecondsToFrames(2); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueVelocityBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1f; + public static float StealthStrikeKnockbackMult = 2f; + public static int ExplosionDamage = 40; + public override void SetDefaults() { Item.width = 18; Item.height = 18; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; - Item.defense = 12; //43 + Item.defense = 8; // 32 } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); public override void UpdateArmorSet(Player player) { - player.setBonus = this.GetLocalizedValue("SetBonus"); + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth(), StealthStrikeKnockbackMult); var modPlayer = player.Calamity(); modPlayer.titanHeartSet = true; - player.GetDamage() += 0.10f; - modPlayer.rogueStealthMax += 1f; + modPlayer.rogueStealthMax += SetBonusRogueStealth; modPlayer.wearingRogueArmor = true; player.noKnockback = true; } @@ -40,7 +46,8 @@ namespace CalamityMod.Items.Armor.TitanHeart { var modPlayer = player.Calamity(); modPlayer.titanHeartMask = true; - player.GetDamage() += 0.05f; + player.GetDamage() += RogueDamageBoost; + modPlayer.rogueVelocity += RogueVelocityBoost; } public override void AddRecipes() diff --git a/Items/Armor/Umbraphile/UmbraphileBoots.cs b/Items/Armor/Umbraphile/UmbraphileBoots.cs index e48dd4b34e..859cb449dc 100644 --- a/Items/Armor/Umbraphile/UmbraphileBoots.cs +++ b/Items/Armor/Umbraphile/UmbraphileBoots.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Umbraphile @@ -9,6 +10,12 @@ namespace CalamityMod.Items.Armor.Umbraphile public class UmbraphileBoots : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.09f; + public static int RogueCritBoost = 6; + public static float MoveSpeedBoost = 0.2f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueCritBoost, MoveSpeedBoost.ToPercent()); + public override void SetDefaults() { Item.width = 22; @@ -20,9 +27,9 @@ namespace CalamityMod.Items.Armor.Umbraphile public override void UpdateEquip(Player player) { - player.moveSpeed += 0.2f; - player.GetDamage() += 0.09f; - player.GetCritChance() += 6; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Umbraphile/UmbraphileHood.cs b/Items/Armor/Umbraphile/UmbraphileHood.cs index 0c5da98a99..281d7703de 100644 --- a/Items/Armor/Umbraphile/UmbraphileHood.cs +++ b/Items/Armor/Umbraphile/UmbraphileHood.cs @@ -1,7 +1,7 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Umbraphile @@ -10,6 +10,16 @@ namespace CalamityMod.Items.Armor.Umbraphile public class UmbraphileHood : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.08f; + public static float RogueVelocityBoost = 0.1f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent(), RogueVelocityBoost.ToPercent()); + + // Set Bonus + public static float SetBonusRogueStealth = 1.1f; + public static double ExplosionDamageRatio = 0.2D; + public static int ExplosionDamageSoftcap = 50; + public override void SetDefaults() { Item.width = 22; @@ -19,29 +29,23 @@ namespace CalamityMod.Items.Armor.Umbraphile Item.defense = 10; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; public override void UpdateArmorSet(Player player) { var modPlayer = player.Calamity(); modPlayer.umbraphileSet = true; - modPlayer.rogueStealthMax += 1.1f; - player.setBonus = this.GetLocalizedValue("SetBonus"); + modPlayer.rogueStealthMax += SetBonusRogueStealth; + player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusRogueStealth.ToStealth()); player.Calamity().wearingRogueArmor = true; } public override void UpdateEquip(Player player) { - player.GetDamage() += 0.08f; - player.Calamity().rogueVelocity += 0.1f; + player.GetDamage() += RogueDamageBoost; + player.Calamity().rogueVelocity += RogueVelocityBoost; } public override void AddRecipes() diff --git a/Items/Armor/Umbraphile/UmbraphileRegalia.cs b/Items/Armor/Umbraphile/UmbraphileRegalia.cs index f281752294..46a9661e5e 100644 --- a/Items/Armor/Umbraphile/UmbraphileRegalia.cs +++ b/Items/Armor/Umbraphile/UmbraphileRegalia.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Umbraphile @@ -9,6 +10,11 @@ namespace CalamityMod.Items.Armor.Umbraphile public class UmbraphileRegalia : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.Hardmode"; + + public static float RogueDamageBoost = 0.1f; + public static int RogueCritBoost = 10; // NOTE: Tooltip shares this number with damage % as they're equal + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RogueDamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 38; @@ -20,8 +26,8 @@ namespace CalamityMod.Items.Armor.Umbraphile public override void UpdateEquip(Player player) { - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; + player.GetDamage() += RogueDamageBoost; + player.GetCritChance() += RogueCritBoost; } public override void AddRecipes() diff --git a/Items/Armor/Vanity/AncientGodSlayerChestplate.cs b/Items/Armor/Vanity/AncientGodSlayerChestplate.cs index 448662c671..114cf3b989 100644 --- a/Items/Armor/Vanity/AncientGodSlayerChestplate.cs +++ b/Items/Armor/Vanity/AncientGodSlayerChestplate.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Armor.Vanity Item.height = 20; Item.vanity = true; Item.value = Item.sellPrice(gold: 12); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } } } diff --git a/Items/Armor/Vanity/AncientGodSlayerHelm.cs b/Items/Armor/Vanity/AncientGodSlayerHelm.cs index 04f3f01831..d1f4295763 100644 --- a/Items/Armor/Vanity/AncientGodSlayerHelm.cs +++ b/Items/Armor/Vanity/AncientGodSlayerHelm.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Armor.Vanity Item.height = 20; Item.vanity = true; Item.value = Item.sellPrice(gold: 15); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool IsArmorSet(Item head, Item body, Item legs) diff --git a/Items/Armor/Vanity/AncientGodSlayerLeggings.cs b/Items/Armor/Vanity/AncientGodSlayerLeggings.cs index 58956bdeed..f36ed19d5a 100644 --- a/Items/Armor/Vanity/AncientGodSlayerLeggings.cs +++ b/Items/Armor/Vanity/AncientGodSlayerLeggings.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Armor.Vanity Item.height = 20; Item.vanity = true; Item.value = Item.sellPrice(gold: 9); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } } } diff --git a/Items/Armor/Vanity/BrimstoneElementalMask.cs b/Items/Armor/Vanity/BrimstoneElementalMask.cs new file mode 100644 index 0000000000..5fd09e0622 --- /dev/null +++ b/Items/Armor/Vanity/BrimstoneElementalMask.cs @@ -0,0 +1,28 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Vanity +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("BrimstoneWaifuMask")] + public class BrimstoneElementalMask : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.Vanity"; + public override void SetStaticDefaults() + { + + if (!Main.dedServ) + ArmorIDs.Head.Sets.DrawHead[Item.headSlot] = false; + } + + public override void SetDefaults() + { + Item.width = 30; + Item.height = 28; + Item.rare = ItemRarityID.Blue; + Item.value = Item.sellPrice(silver: 75); + Item.vanity = true; + } + } +} diff --git a/Items/Armor/Vanity/BrimstoneWaifuMask.png b/Items/Armor/Vanity/BrimstoneElementalMask.png similarity index 100% rename from Items/Armor/Vanity/BrimstoneWaifuMask.png rename to Items/Armor/Vanity/BrimstoneElementalMask.png diff --git a/Items/Armor/Vanity/BrimstoneWaifuMask_Head.png b/Items/Armor/Vanity/BrimstoneElementalMask_Head.png similarity index 100% rename from Items/Armor/Vanity/BrimstoneWaifuMask_Head.png rename to Items/Armor/Vanity/BrimstoneElementalMask_Head.png diff --git a/Items/Armor/Vanity/BrimstoneWaifuMask.cs b/Items/Armor/Vanity/BrimstoneWaifuMask.cs deleted file mode 100644 index f71c4a3de6..0000000000 --- a/Items/Armor/Vanity/BrimstoneWaifuMask.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Vanity -{ - [AutoloadEquip(EquipType.Head)] - public class BrimstoneWaifuMask : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.Vanity"; - public override void SetStaticDefaults() - { - - if (!Main.dedServ) - ArmorIDs.Head.Sets.DrawHead[Item.headSlot] = false; - } - - public override void SetDefaults() - { - Item.width = 30; - Item.height = 28; - Item.rare = ItemRarityID.Blue; - Item.value = Item.sellPrice(silver: 75); - Item.vanity = true; - } - } -} diff --git a/Items/Armor/Vanity/GodSlayerHornedHelm.cs b/Items/Armor/Vanity/GodSlayerHornedHelm.cs index 0a003faafb..f295b9b6a5 100644 --- a/Items/Armor/Vanity/GodSlayerHornedHelm.cs +++ b/Items/Armor/Vanity/GodSlayerHornedHelm.cs @@ -1,6 +1,6 @@ using CalamityMod.Items.Armor.GodSlayer; -using CalamityMod.Rarities; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Vanity @@ -14,18 +14,12 @@ namespace CalamityMod.Items.Armor.Vanity Item.width = 18; Item.height = 18; Item.vanity = true; - Item.value = Item.buyPrice(gold: 8); // Sold by Clothier - Item.rare = ModContent.RarityType(); + Item.value = Item.buyPrice(gold: 10); // Sold by Clothier + Item.rare = ItemRarityID.Blue; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; } } diff --git a/Items/Armor/Vanity/GodSlayerVisage.cs b/Items/Armor/Vanity/GodSlayerVisage.cs index 1c42f8c041..614eddf72f 100644 --- a/Items/Armor/Vanity/GodSlayerVisage.cs +++ b/Items/Armor/Vanity/GodSlayerVisage.cs @@ -1,6 +1,6 @@ using CalamityMod.Items.Armor.GodSlayer; -using CalamityMod.Rarities; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Vanity @@ -14,18 +14,12 @@ namespace CalamityMod.Items.Armor.Vanity Item.width = 18; Item.height = 18; Item.vanity = true; - Item.value = Item.buyPrice(gold: 8); // Sold by Clothier - Item.rare = ModContent.RarityType(); + Item.value = Item.buyPrice(gold: 10); // Sold by Clothier + Item.rare = ItemRarityID.Blue; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; } } diff --git a/Items/Armor/Vanity/LucisBoots.cs b/Items/Armor/Vanity/LucisBoots.cs new file mode 100644 index 0000000000..da9ce01a0c --- /dev/null +++ b/Items/Armor/Vanity/LucisBoots.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Vanity +{ + [AutoloadEquip(EquipType.Legs)] + public class LucisBoots : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.Vanity"; + + public override void SetDefaults() + { + Item.width = 28; + Item.height = 20; + Item.value = Item.buyPrice(gold: 10); // Sold by Steampunker + Item.rare = ItemRarityID.Pink; + Item.vanity = true; + Item.Calamity().donorItem = true; + } + } +} diff --git a/Items/Armor/Vanity/LucisBoots.png b/Items/Armor/Vanity/LucisBoots.png new file mode 100644 index 0000000000..2b91e15ca4 Binary files /dev/null and b/Items/Armor/Vanity/LucisBoots.png differ diff --git a/Items/Armor/Vanity/LucisBoots_Legs.png b/Items/Armor/Vanity/LucisBoots_Legs.png new file mode 100644 index 0000000000..cb73585b17 Binary files /dev/null and b/Items/Armor/Vanity/LucisBoots_Legs.png differ diff --git a/Items/Armor/Vanity/LucisHairstyle.cs b/Items/Armor/Vanity/LucisHairstyle.cs new file mode 100644 index 0000000000..6af1251c18 --- /dev/null +++ b/Items/Armor/Vanity/LucisHairstyle.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Vanity +{ + [AutoloadEquip(EquipType.Head)] + public class LucisHairstyle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.Vanity"; + + public override void SetDefaults() + { + Item.width = 28; + Item.height = 20; + Item.value = Item.buyPrice(gold: 10); // Sold by Steampunker + Item.rare = ItemRarityID.Pink; + Item.vanity = true; + Item.Calamity().donorItem = true; // Donor: xAqult (Sprites made by Gote) + } + } +} diff --git a/Items/Armor/Vanity/LucisHairstyle.png b/Items/Armor/Vanity/LucisHairstyle.png new file mode 100644 index 0000000000..5808d53012 Binary files /dev/null and b/Items/Armor/Vanity/LucisHairstyle.png differ diff --git a/Items/Armor/Vanity/LucisHairstyle_Head.png b/Items/Armor/Vanity/LucisHairstyle_Head.png new file mode 100644 index 0000000000..682ad154ba Binary files /dev/null and b/Items/Armor/Vanity/LucisHairstyle_Head.png differ diff --git a/Items/Armor/Vanity/LucisMilitaryUniform.cs b/Items/Armor/Vanity/LucisMilitaryUniform.cs new file mode 100644 index 0000000000..c2fde13007 --- /dev/null +++ b/Items/Armor/Vanity/LucisMilitaryUniform.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Vanity +{ + [AutoloadEquip(EquipType.Body)] + public class LucisMilitaryUniform : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.Vanity"; + + public override void SetDefaults() + { + Item.width = 26; + Item.height = 20; + Item.value = Item.buyPrice(gold: 10); // Sold by Steampunker + Item.rare = ItemRarityID.Pink; + Item.vanity = true; + Item.Calamity().donorItem = true; + } + } +} diff --git a/Items/Armor/Vanity/LucisMilitaryUniform.png b/Items/Armor/Vanity/LucisMilitaryUniform.png new file mode 100644 index 0000000000..d8017d98d0 Binary files /dev/null and b/Items/Armor/Vanity/LucisMilitaryUniform.png differ diff --git a/Items/Armor/Vanity/LucisMilitaryUniform_Body.png b/Items/Armor/Vanity/LucisMilitaryUniform_Body.png new file mode 100644 index 0000000000..dcdee4ba2a Binary files /dev/null and b/Items/Armor/Vanity/LucisMilitaryUniform_Body.png differ diff --git a/Items/Armor/Vanity/OldHunterSet.cs b/Items/Armor/Vanity/OldHunterSet.cs index 475720b465..d55caa9bce 100644 --- a/Items/Armor/Vanity/OldHunterSet.cs +++ b/Items/Armor/Vanity/OldHunterSet.cs @@ -1,6 +1,4 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Armor.DesertProwler; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Armor.DesertProwler; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Armor/Vanity/SilvaHelm.cs b/Items/Armor/Vanity/SilvaHelm.cs index b5875fd67e..00f2de8e62 100644 --- a/Items/Armor/Vanity/SilvaHelm.cs +++ b/Items/Armor/Vanity/SilvaHelm.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Armor.Silva; -using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,18 +14,12 @@ namespace CalamityMod.Items.Armor.Vanity Item.width = 24; Item.height = 20; Item.vanity = true; - Item.value = Item.buyPrice(gold: 8); // Sold by Clothier - Item.rare = ModContent.RarityType(); + Item.value = Item.buyPrice(gold: 10); // Sold by Clothier + Item.rare = ItemRarityID.Blue; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; } } diff --git a/Items/Armor/Vanity/SilvaHornedHelm.cs b/Items/Armor/Vanity/SilvaHornedHelm.cs index 7440f939ce..141b7f2d74 100644 --- a/Items/Armor/Vanity/SilvaHornedHelm.cs +++ b/Items/Armor/Vanity/SilvaHornedHelm.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Armor.Silva; -using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,18 +14,12 @@ namespace CalamityMod.Items.Armor.Vanity Item.width = 26; Item.height = 24; Item.vanity = true; - Item.value = Item.buyPrice(gold: 8); // Sold by Clothier - Item.rare = ModContent.RarityType(); + Item.value = Item.buyPrice(gold: 10); // Sold by Clothier + Item.rare = ItemRarityID.Blue; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; } } diff --git a/Items/Armor/Vanity/SilvaMask.cs b/Items/Armor/Vanity/SilvaMask.cs index ad4ec9902f..571e1e864c 100644 --- a/Items/Armor/Vanity/SilvaMask.cs +++ b/Items/Armor/Vanity/SilvaMask.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Armor.Silva; -using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,18 +14,12 @@ namespace CalamityMod.Items.Armor.Vanity Item.width = 24; Item.height = 26; Item.vanity = true; - Item.value = Item.buyPrice(gold: 8); // Sold by Clothier - Item.rare = ModContent.RarityType(); + Item.value = Item.buyPrice(gold: 10); // Sold by Clothier + Item.rare = ItemRarityID.Blue; } - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - public override void ArmorSetShadows(Player player) - { - player.armorEffectDrawShadow = true; - } + public override void ArmorSetShadows(Player player) => player.armorEffectDrawShadow = true; } } diff --git a/Items/Armor/Vanity/TheCommandersCap.cs b/Items/Armor/Vanity/TheCommandersCap.cs index 5340bc723e..a2719e113e 100644 --- a/Items/Armor/Vanity/TheCommandersCap.cs +++ b/Items/Armor/Vanity/TheCommandersCap.cs @@ -1,7 +1,5 @@ -using CalamityMod.NPCs.TownNPCs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Armor/Vanity/TheFormalFootwear.cs b/Items/Armor/Vanity/TheFormalFootwear.cs index 33fa080b6c..1d21d4e906 100644 --- a/Items/Armor/Vanity/TheFormalFootwear.cs +++ b/Items/Armor/Vanity/TheFormalFootwear.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Vanity diff --git a/Items/Armor/Vanity/VictideCoralTurban.cs b/Items/Armor/Vanity/VictideCoralTurban.cs new file mode 100644 index 0000000000..fa645616be --- /dev/null +++ b/Items/Armor/Vanity/VictideCoralTurban.cs @@ -0,0 +1,20 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Vanity +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("VictideVisage", "VictideHeadRanged")] + public class VictideCoralTurban : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.Vanity"; + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.vanity = true; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Armor/Victide/VictideHeadRanged.png b/Items/Armor/Vanity/VictideCoralTurban.png similarity index 100% rename from Items/Armor/Victide/VictideHeadRanged.png rename to Items/Armor/Vanity/VictideCoralTurban.png diff --git a/Items/Armor/Victide/VictideHeadRanged_Head.png b/Items/Armor/Vanity/VictideCoralTurban_Head.png similarity index 100% rename from Items/Armor/Victide/VictideHeadRanged_Head.png rename to Items/Armor/Vanity/VictideCoralTurban_Head.png diff --git a/Items/Armor/Vanity/VictideShellmet.cs b/Items/Armor/Vanity/VictideShellmet.cs new file mode 100644 index 0000000000..a9656c5ab3 --- /dev/null +++ b/Items/Armor/Vanity/VictideShellmet.cs @@ -0,0 +1,20 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Vanity +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("VictideHelm", "VictideHeadMelee")] + public class VictideShellmet : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Armor.Vanity"; + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.vanity = true; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Armor/Victide/VictideHeadMelee.png b/Items/Armor/Vanity/VictideShellmet.png similarity index 100% rename from Items/Armor/Victide/VictideHeadMelee.png rename to Items/Armor/Vanity/VictideShellmet.png diff --git a/Items/Armor/Victide/VictideHeadMelee_Head.png b/Items/Armor/Vanity/VictideShellmet_Head.png similarity index 100% rename from Items/Armor/Victide/VictideHeadMelee_Head.png rename to Items/Armor/Vanity/VictideShellmet_Head.png diff --git a/Items/Armor/Victide/VictideBreastplate.cs b/Items/Armor/Victide/VictideBreastplate.cs index 43e1c6649b..9c7c4f70b3 100644 --- a/Items/Armor/Victide/VictideBreastplate.cs +++ b/Items/Armor/Victide/VictideBreastplate.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Victide @@ -11,6 +12,10 @@ namespace CalamityMod.Items.Armor.Victide public new string LocalizationCategory => "Items.Armor.PreHardmode"; public string BulkTexture => "CalamityMod/Items/Armor/Victide/VictideBreastplate_Bulk"; + public static int RegenBoost = 2; + + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenBoost.ToRegenPerSecond()); + public override void Load() { if (!Main.dedServ) @@ -22,7 +27,6 @@ namespace CalamityMod.Items.Armor.Victide public override void SetStaticDefaults() { - if (!Main.dedServ) { var equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); @@ -37,18 +41,12 @@ namespace CalamityMod.Items.Armor.Victide Item.height = 18; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.defense = 5; //9 + Item.defense = 4; } public override void UpdateEquip(Player player) { - player.endurance += 0.05f; - player.GetCritChance() += 5; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - player.statDefense += 5; - player.endurance += 0.1f; - } + player.lifeRegen += RegenBoost; } public override void AddRecipes() diff --git a/Items/Armor/Victide/VictideGreaves.cs b/Items/Armor/Victide/VictideGreaves.cs index 6e96d6af32..d31857818d 100644 --- a/Items/Armor/Victide/VictideGreaves.cs +++ b/Items/Armor/Victide/VictideGreaves.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Armor.Victide @@ -10,9 +11,13 @@ namespace CalamityMod.Items.Armor.Victide public class VictideGreaves : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float MoveSpeedBoost = 0.1f; + + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent()); + public override void SetStaticDefaults() { - if (!Main.dedServ) { var equipSlot = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Legs); @@ -26,12 +31,12 @@ namespace CalamityMod.Items.Armor.Victide Item.height = 18; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.defense = 4; //9 + Item.defense = 3; } public override void UpdateEquip(Player player) { - player.moveSpeed += Collision.DrownCollision(player.position, player.width, player.height, player.gravDir) ? 0.3f : 0.08f; + player.moveSpeed += MoveSpeedBoost; } public override void AddRecipes() diff --git a/Items/Armor/Victide/VictideHeadBarrier.cs b/Items/Armor/Victide/VictideHeadBarrier.cs new file mode 100644 index 0000000000..4049099c85 --- /dev/null +++ b/Items/Armor/Victide/VictideHeadBarrier.cs @@ -0,0 +1,76 @@ +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Victide +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("VictideMask", "VictideHeadMagic")] + public class VictideHeadBarrier : ModItem, ILocalizedModType // Defense/Mobility set + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int RegenBoost = 2; + public static float RunAccelerationMult = 1.75f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenBoost.ToRegenPerSecond(), RunAccelerationMult.Round()); + + // Set Bonus + public static int BarrierCooldown = CalamityUtils.SecondsToFrames(8); + public static int BarrierDefenseBoost = 6; + public static float BarrierDamageAbsorptionPercent = 0.1f; + public static int BarrierFramesPerHeal = 15; + public static int BarrierDamage = 50; + public static float BarrierExplosionKB = 8f; + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.defense = 5; // 12 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void UpdateArmorSet(Player player) + { + Color AbilityBriefColor = Color.Lerp(new Color(97, 200, 255), new Color(255, 170, 204), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(AbilityBriefColor.Hex3(), BarrierDefenseBoost, BarrierDamageAbsorptionPercent.ToPercent(), CalamityUtils.GetArmorSetBonusKey(), BarrierCooldown.FramesToSeconds()); + player.Calamity().victideBarrierSet = true; + + if (!player.HasCooldown(WardingWave.ID)) + { + player.statDefense += BarrierDefenseBoost; + + if (player.whoAmI == Main.myPlayer && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + // Damage will be set once explosion goes off + var source = player.GetSource_ItemUse(Item); + Projectile.NewProjectile(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + } + } + } + + public override void UpdateEquip(Player player) + { + player.lifeRegen += RegenBoost; + player.Calamity().victideBarrierHead = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(3). + AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Victide/VictideHeadMagic.png b/Items/Armor/Victide/VictideHeadBarrier.png similarity index 100% rename from Items/Armor/Victide/VictideHeadMagic.png rename to Items/Armor/Victide/VictideHeadBarrier.png diff --git a/Items/Armor/Victide/VictideHeadMagic_Head.png b/Items/Armor/Victide/VictideHeadBarrier_Head.png similarity index 100% rename from Items/Armor/Victide/VictideHeadMagic_Head.png rename to Items/Armor/Victide/VictideHeadBarrier_Head.png diff --git a/Items/Armor/Victide/VictideHeadBurrow.cs b/Items/Armor/Victide/VictideHeadBurrow.cs new file mode 100644 index 0000000000..5618cd3570 --- /dev/null +++ b/Items/Armor/Victide/VictideHeadBurrow.cs @@ -0,0 +1,63 @@ +using System; +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Victide +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("VictideHeadgear", "VictideHeadRogue")] + public class VictideHeadBurrow : ModItem, ILocalizedModType // Mobility/Utility set + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float MoveSpeedAccelerationBoost = 0.15f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedAccelerationBoost.ToPercent()); + + // Set Bonus + public static float BaseBurrowSpeed = 9f; // 46 mph + public static float SubmergedBurrowSpeed = 12f; // 61 mph + public static float BaseAcceleration = 0.4f; // For reference, base player running acceleration is 0.08 + public static int BurrowDuration = CalamityUtils.SecondsToFrames(7); + public static int BurrowCooldown = CalamityUtils.SecondsToFrames(30); + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.defense = 3; // 10 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void UpdateArmorSet(Player player) + { + Color AbilityBriefColor = Color.Lerp(new Color(97, 200, 255), new Color(255, 170, 204), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(AbilityBriefColor.Hex3(), CalamityUtils.GetArmorSetBonusKey(), BurrowDuration.FramesToSeconds(), BurrowCooldown.FramesToSeconds()); + player.Calamity().victideBurrowSet = true; + player.ignoreWater = true; + } + + public override void UpdateEquip(Player player) + { + player.Calamity().victideBurrowHead = true; + player.moveSpeed += MoveSpeedAccelerationBoost; + if (player.Calamity().countsAsAnyWet) + player.gills = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(3). + AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Victide/VictideHeadRogue.png b/Items/Armor/Victide/VictideHeadBurrow.png similarity index 100% rename from Items/Armor/Victide/VictideHeadRogue.png rename to Items/Armor/Victide/VictideHeadBurrow.png diff --git a/Items/Armor/Victide/VictideHeadRogue_Head.png b/Items/Armor/Victide/VictideHeadBurrow_Head.png similarity index 100% rename from Items/Armor/Victide/VictideHeadRogue_Head.png rename to Items/Armor/Victide/VictideHeadBurrow_Head.png diff --git a/Items/Armor/Victide/VictideHeadMagic.cs b/Items/Armor/Victide/VictideHeadMagic.cs deleted file mode 100644 index 87d322f52f..0000000000 --- a/Items/Armor/Victide/VictideHeadMagic.cs +++ /dev/null @@ -1,55 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Victide -{ - [AutoloadEquip(EquipType.Head)] - [LegacyName("VictideMask")] - public class VictideHeadMagic : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.defense = 2; //9 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.victideSet = true; - player.ignoreWater = true; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - player.GetDamage() += 0.1f; - player.lifeRegen += 3; - } - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.05f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(3). - AddTile(TileID.Anvils). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Victide/VictideHeadMelee.cs b/Items/Armor/Victide/VictideHeadMelee.cs deleted file mode 100644 index 9c97518add..0000000000 --- a/Items/Armor/Victide/VictideHeadMelee.cs +++ /dev/null @@ -1,56 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Victide -{ - [AutoloadEquip(EquipType.Head)] - [LegacyName("VictideHelm")] - public class VictideHeadMelee : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.defense = 4; //11 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.victideSet = true; - player.ignoreWater = true; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - player.GetDamage() += 0.1f; - player.lifeRegen += 3; - } - player.aggro += 200; - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.05f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(3). - AddTile(TileID.Anvils). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Victide/VictideHeadRanged.cs b/Items/Armor/Victide/VictideHeadRanged.cs deleted file mode 100644 index 068abd2914..0000000000 --- a/Items/Armor/Victide/VictideHeadRanged.cs +++ /dev/null @@ -1,55 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Victide -{ - [AutoloadEquip(EquipType.Head)] - [LegacyName("VictideVisage")] - public class VictideHeadRanged : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.defense = 3; //10 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.victideSet = true; - player.ignoreWater = true; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - player.GetDamage() += 0.1f; - player.lifeRegen += 3; - } - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.05f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(3). - AddTile(TileID.Anvils). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Victide/VictideHeadRogue.cs b/Items/Armor/Victide/VictideHeadRogue.cs deleted file mode 100644 index 1ebfa59ea6..0000000000 --- a/Items/Armor/Victide/VictideHeadRogue.cs +++ /dev/null @@ -1,57 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Victide -{ - [AutoloadEquip(EquipType.Head)] - [LegacyName("VictideHeadgear")] - public class VictideHeadRogue : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.defense = 3; //10 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.victideSet = true; - modPlayer.rogueStealthMax += 0.6f; - modPlayer.wearingRogueArmor = true; - player.ignoreWater = true; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - player.GetDamage() += 0.1f; - player.lifeRegen += 3; - } - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.05f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(3). - AddTile(TileID.Anvils). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Victide/VictideHeadSnail.cs b/Items/Armor/Victide/VictideHeadSnail.cs new file mode 100644 index 0000000000..b47058994c --- /dev/null +++ b/Items/Armor/Victide/VictideHeadSnail.cs @@ -0,0 +1,72 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Armor.Victide +{ + [AutoloadEquip(EquipType.Head)] + [LegacyName("VictideHelmet", "VictideHeadSummon")] + public class VictideHeadSnail : ModItem, ILocalizedModType // Utility/Fishing set + { + public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int FishingPowerBoost = 5; + public static int AggroReduction = 200; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(FishingPowerBoost); + + // Set Bonus + public static int SetBonusGrabRangeBoost = 102; // (2.625 + 6.375 = 9 tiles) + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.defense = 1; // 8 + } + + public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); + + public override void UpdateArmorSet(Player player) + { + Color AbilityBriefColor = Color.Lerp(new Color(97, 200, 255), new Color(255, 170, 204), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(AbilityBriefColor.Hex3()); + player.Calamity().victideSnailSet = true; + if (player.whoAmI == Main.myPlayer) + { + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + { + player.AddBuff(ModContent.BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + var source = player.GetSource_ItemUse(Item); + Vector2 position = player.Center + Vector2.UnitY * (player.gfxOffY - 60f) * player.gravDir; + Projectile.NewProjectile(source, position, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + } + } + } + + public override void UpdateEquip(Player player) + { + player.fishingSkill += FishingPowerBoost; + player.aggro -= AggroReduction; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(3). + AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). + Register(); + } + } +} diff --git a/Items/Armor/Victide/VictideHeadSummon.png b/Items/Armor/Victide/VictideHeadSnail.png similarity index 100% rename from Items/Armor/Victide/VictideHeadSummon.png rename to Items/Armor/Victide/VictideHeadSnail.png diff --git a/Items/Armor/Victide/VictideHeadSummon_Head.png b/Items/Armor/Victide/VictideHeadSnail_Head.png similarity index 100% rename from Items/Armor/Victide/VictideHeadSummon_Head.png rename to Items/Armor/Victide/VictideHeadSnail_Head.png diff --git a/Items/Armor/Victide/VictideHeadSummon.cs b/Items/Armor/Victide/VictideHeadSummon.cs deleted file mode 100644 index 3d2d7683ce..0000000000 --- a/Items/Armor/Victide/VictideHeadSummon.cs +++ /dev/null @@ -1,79 +0,0 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Armor.Victide -{ - [AutoloadEquip(EquipType.Head)] - [LegacyName("VictideHelmet")] - public class VictideHeadSummon : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public static int SnailDamage = 7; - - public override void SetDefaults() - { - Item.width = 18; - Item.height = 18; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.defense = 1; //8 - } - - public override bool IsArmorSet(Item head, Item body, Item legs) - { - return body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); - } - - public override void UpdateArmorSet(Player player) - { - player.setBonus = this.GetLocalizedValue("SetBonus") + "\n" + CalamityUtils.GetTextValueFromModItem("CommonSetBonus"); - var modPlayer = player.Calamity(); - modPlayer.victideSet = true; - modPlayer.victideSummoner = true; - player.maxMinions++; - if (player.whoAmI == Main.myPlayer) - { - if (player.FindBuffIndex(ModContent.BuffType()) == -1) - { - player.AddBuff(ModContent.BuffType(), 3600, true); - } - var source = player.GetSource_ItemUse(Item); - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - int minionDamage = (int)player.GetTotalDamage().ApplyTo(SnailDamage); - - var p = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), minionDamage, 0f, Main.myPlayer, 0f, 0f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = SnailDamage; - } - } - player.ignoreWater = true; - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - { - player.GetDamage() += 0.1f; - player.lifeRegen += 3; - } - } - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.1f; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(3). - AddTile(TileID.Anvils). - SortBeforeFirstRecipesOf(ModContent.ItemType()). - Register(); - } - } -} diff --git a/Items/Armor/Wulfrum/WulfrumFusionCannon.cs b/Items/Armor/Wulfrum/WulfrumFusionCannon.cs index ef33cd5453..38f7708f38 100644 --- a/Items/Armor/Wulfrum/WulfrumFusionCannon.cs +++ b/Items/Armor/Wulfrum/WulfrumFusionCannon.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Cooldowns; using CalamityMod.Items.BaseItems; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -68,7 +67,7 @@ namespace CalamityMod.Items.Armor.Wulfrum if (!WulfrumHat.HasArmorSet(player)) { Item.type = ItemID.None; - Item.SetDefaults(0); + Item.SetDefaults(ItemID.None); Item.stack = 0; Main.mouseItem = new Item(); diff --git a/Items/Armor/Wulfrum/WulfrumSet.cs b/Items/Armor/Wulfrum/WulfrumSet.cs index 69987f14d2..4d3f16e4b3 100644 --- a/Items/Armor/Wulfrum/WulfrumSet.cs +++ b/Items/Armor/Wulfrum/WulfrumSet.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using CalamityMod.Cooldowns; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Materials; @@ -11,7 +10,6 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using static Microsoft.Xna.Framework.Input.Keys; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Armor.Wulfrum @@ -36,11 +34,16 @@ namespace CalamityMod.Items.Armor.Wulfrum public static readonly SoundStyle SetBreakSound = new("CalamityMod/Sounds/Custom/AbilitySounds/WulfrumBastionBreak"); public static readonly SoundStyle SetBreakSoundSafe = new("CalamityMod/Sounds/Custom/AbilitySounds/WulfrumBastionBreakSafely"); - public static int MinionSlotBoost = 1; - public static int BastionBuildTime = (int)(0.55f * 60); - public static int BastionTime = 30 * 60; - public static int TimeLostPerHit = 2 * 60; - public static int BastionCooldown = 20 * 60; + public static float SummonDamageBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(SummonDamageBoost.ToPercent()); + + // Set Bonus + public static int BastionDefenseBoost = 12; + public static float BastionDRBoost = 0.1f; + public static int BastionBuildTime = CalamityUtils.SecondsToFrames(0.55f); + public static int BastionTime = CalamityUtils.SecondsToFrames(30); + public static int TimeLostPerHit = CalamityUtils.SecondsToFrames(2); + public static int BastionCooldown = CalamityUtils.SecondsToFrames(20); internal static Item DummyCannon = new Item(); //Used for the attack swap. Basically we force the player to hold a fake item. @@ -58,8 +61,7 @@ namespace CalamityMod.Items.Armor.Wulfrum EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Armor/Wulfrum/WulfrumHat_FemaleHead", EquipType.Head, name: "WulfrumHatFemale"); } - Terraria.On_Player.KeyDoubleTap += ActivateSetBonus; - Terraria.On_Main.DrawPendingMouseText += SpoofMouseItem; + On_Main.DrawPendingMouseText += SpoofMouseItem; } public override void Unload() @@ -68,42 +70,15 @@ namespace CalamityMod.Items.Armor.Wulfrum DummyCannon = null; } - private void ActivateSetBonus(Terraria.On_Player.orig_KeyDoubleTap orig, Player player, int keyDir) - { - if (keyDir == (Main.ReversedUpDownArmorSetBonuses ? 1 : 0) && HasArmorSet(player) && !player.mount.Active) - { - //Only activate if no cooldown & available scrap. - if (player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out CooldownInstance cd)) - { - if (cd.timeLeft > BastionCooldown && cd.timeLeft < BastionCooldown + BastionTime - 60 * 3) - { - cd.timeLeft = BastionCooldown + 1; - player.Calamity().SyncCooldownDictionary(false); - } - } - - else if (player.HasItem(ItemType())) - { - player.ConsumeItem(ItemType()); - //I Thiiiinnnk there's no need to add mp syncing packets since cooldowns get auto synced right. - player.AddCooldown(WulfrumBastion.ID, BastionCooldown + BastionTime); - //Though do i need to sync that or is the player inventory auto synced? - DummyCannon.SetDefaults(ItemType()); - } - } - - orig(player, keyDir); - } - //Replaces the tooltip of the armor set with the fusion cannon if the player holds shift - private void SpoofMouseItem(Terraria.On_Main.orig_DrawPendingMouseText orig) + private void SpoofMouseItem(On_Main.orig_DrawPendingMouseText orig) { var player = Main.LocalPlayer; if (DummyCannon.IsAir && !Main.gameMenu) DummyCannon.SetDefaults(ItemType()); - if (IsPartOfSet(Main.HoverItem) && HasArmorSet(player) && Main.keyState.IsKeyDown(LeftShift)) + if (IsPartOfSet(Main.HoverItem) && HasArmorSet(player) && Main.keyState.PressingShift()) { Main.HoverItem = DummyCannon.Clone(); Main.hoverItemName = DummyCannon.Name; @@ -118,6 +93,7 @@ namespace CalamityMod.Items.Armor.Wulfrum Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; + Item.defense = 1; } public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ItemType() && legs.type == ItemType(); @@ -133,8 +109,9 @@ namespace CalamityMod.Items.Armor.Wulfrum armorPlayer.wulfrumSet = true; - player.setBonus = this.GetLocalization("SetBonus").Format(MinionSlotBoost); //The cooler part of the set bonus happens in modifytooltips because i can't recolor it otherwise. Madge - player.maxMinions += MinionSlotBoost; + Color AbilityBriefColor = Color.Lerp(new Color(194, 255, 67), new Color(112, 244, 244), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 3f)); + player.setBonus = this.GetLocalization("SetBonus").Format(AbilityBriefColor.Hex3(), CalamityUtils.GetArmorSetBonusKey(), BastionTime.FramesToSeconds(), TimeLostPerHit.FramesToSeconds()); + if (PowerModeEngaged(player, out var cd)) { if (cd.timeLeft == BastionCooldown + BastionTime) @@ -143,12 +120,13 @@ namespace CalamityMod.Items.Armor.Wulfrum } //Stats - player.statDefense += 13; - player.endurance += 0.05f; //10% Dr in total with the chestplate + player.statDefense += BastionDefenseBoost; + player.endurance += BastionDRBoost; - //Can't account for previous fullbody transformations but at this point, whatever. + //Can't account for previous fullbody transformations but at this point, whatever + bool transformed = player.Transformation().Type == ItemType(); Item headItem = player.armor[10].type != ItemID.None ? player.armor[10] : player.armor[0]; - bool hatVisible = !transformationPlayer.transformationActive && headItem.type == ItemType(); + bool hatVisible = !transformed && headItem.type == ItemType(); //Spawn the hat if (cd.timeLeft == BastionCooldown + BastionTime - (int)(BastionBuildTime * 0.9f) && hatVisible) @@ -159,11 +137,9 @@ namespace CalamityMod.Items.Armor.Wulfrum //Visuals if (cd.timeLeft < BastionCooldown + BastionTime - BastionBuildTime) - player.GetModPlayer().transformationActive = true; - else if (cd.timeLeft <= BastionCooldown + BastionTime - (int)(BastionBuildTime * 0.9f)) - player.GetModPlayer().forceHelmetOn = true; + player.Transformation().Type = ItemType(); - //Swapping the arm. + //Swapping the arm if (DummyCannon.IsAir) DummyCannon.SetDefaults(ItemType()); @@ -176,7 +152,7 @@ namespace CalamityMod.Items.Armor.Wulfrum Main.mouseItem = DummyCannon; } - //Slot 58 is the "fake" slot thats used for the item the player is holding in their mouse. + //Slot 58 is the "fake" slot thats used for the item the player is holding in their mouse player.inventory[58] = DummyCannon; player.selectedItem = 58; } @@ -188,6 +164,9 @@ namespace CalamityMod.Items.Armor.Wulfrum Main.mouseItem = new Item(); DummyCannon.TurnToAir(); + + if (player.Transformation().Type == ItemType() && player.Transformation().currentTransformation.IsForced) + player.Transformation().currentTransformation.IsForced = false; } } @@ -195,8 +174,8 @@ namespace CalamityMod.Items.Armor.Wulfrum { SoundEngine.PlaySound(SetActivationSound); - //Do'nt do the effect ifthe player is already using the wulfrum vanity lol. - bool transformedAlready = player.GetModPlayer().transformationActive; + //Don't do the effect if the player is already using the wulfrum vanity lol + bool transformedAlready = player.Transformation().Type == ItemType(); if (!transformedAlready) { @@ -221,41 +200,7 @@ namespace CalamityMod.Items.Armor.Wulfrum GeneralParticleHandler.SpawnParticle(gun); } - public static void ModifySetTooltips(ModItem item, List tooltips) - { - if (HasArmorSet(Main.LocalPlayer)) - { - int setBonusIndex = tooltips.FindIndex(x => x.Name == "SetBonus" && x.Mod == "Terraria"); - - if (setBonusIndex != -1) - { - string dir = Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN"); - TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("AbilityBrief").Format(dir)); - setBonus1.OverrideColor = Color.Lerp(new Color(194, 255, 67), new Color(112, 244, 244), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f)); - tooltips.Insert(setBonusIndex + 1, setBonus1); - - int AmmoItem = ItemType(); - string AmmoDisplay = $"[i:{AmmoItem}] {CalamityUtils.GetItemName(AmmoItem)}"; - TooltipLine setBonus2 = new TooltipLine(item.Mod, "CalamityMod:SetBonus2", CalamityUtils.GetTextFromModItem("AbilityDescription").Format(AmmoDisplay)); - setBonus2.OverrideColor = new Color(110, 192, 93); - tooltips.Insert(setBonusIndex + 2, setBonus2); - - if (!Main.keyState.IsKeyDown(LeftShift)) - { - TooltipLine itemDisplay = new TooltipLine(item.Mod, "CalamityMod:ArmorItemDisplay", CalamityUtils.GetTextValueFromModItem("ShiftToExpand")); - itemDisplay.OverrideColor = new Color(190, 190, 190); - tooltips.Add(itemDisplay); - } - } - - } - } - public override void ModifyTooltips(List tooltips) => ModifySetTooltips(this, tooltips); - - public override void UpdateEquip(Player player) - { - player.GetDamage() += 0.1f; - } + public override void UpdateEquip(Player player) => player.GetDamage() += SummonDamageBoost; public override void AddRecipes() { @@ -272,6 +217,10 @@ namespace CalamityMod.Items.Armor.Wulfrum public class WulfrumJacket : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static int MinionSlotBoost = 1; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinionSlotBoost); + public override void SetStaticDefaults() { if (!Main.dedServ) @@ -291,14 +240,12 @@ namespace CalamityMod.Items.Armor.Wulfrum Item.defense = 2; } - public override void ModifyTooltips(List tooltips) => WulfrumHat.ModifySetTooltips(this, tooltips); - - public override void UpdateEquip(Player player) => player.endurance += 0.05f; + public override void UpdateEquip(Player player) => player.maxMinions += MinionSlotBoost; public override void AddRecipes() { CreateRecipe(). - AddIngredient(12). + AddIngredient(10). AddIngredient(). AddTile(TileID.Anvils). Register(); @@ -310,6 +257,10 @@ namespace CalamityMod.Items.Armor.Wulfrum public class WulfrumOveralls : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Armor.PreHardmode"; + + public static float SummonDamageBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(SummonDamageBoost.ToPercent()); + public override void SetDefaults() { Item.width = 18; @@ -324,11 +275,8 @@ namespace CalamityMod.Items.Armor.Wulfrum ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlot] = true; } } - public override void ModifyTooltips(List tooltips) => WulfrumHat.ModifySetTooltips(this, tooltips); - public override void UpdateEquip(Player player) - { - player.moveSpeed += 0.05f; - } + + public override void UpdateEquip(Player player) => player.GetDamage() += SummonDamageBoost; public override void AddRecipes() { @@ -343,10 +291,6 @@ namespace CalamityMod.Items.Armor.Wulfrum public class WulfrumArmorPlayer : ModPlayer { - public static int BastionShootDamage = 10; - public static float BastionShootSpeed = 18f; - public static int BastionShootTime = 10; - public bool wulfrumSet = false; public override void ResetEffects() @@ -365,7 +309,7 @@ namespace CalamityMod.Items.Armor.Wulfrum { SetBonusEndEffect(true); if (!Player.GetModPlayer().vanityEquipped) - Player.GetModPlayer().transformationActive = false; + Player.Transformation().currentTransformation = null; } } diff --git a/Items/BaseItems/CustomUseProjItem.cs b/Items/BaseItems/CustomUseProjItem.cs index c06d360a19..17d1481111 100644 --- a/Items/BaseItems/CustomUseProjItem.cs +++ b/Items/BaseItems/CustomUseProjItem.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items.BaseItems diff --git a/Items/BaseItems/HeldOnlyItem.cs b/Items/BaseItems/HeldOnlyItem.cs index 10c21c5113..e7cd85529a 100644 --- a/Items/BaseItems/HeldOnlyItem.cs +++ b/Items/BaseItems/HeldOnlyItem.cs @@ -1,9 +1,6 @@ -using CalamityMod.Items.Materials; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -16,21 +13,6 @@ namespace CalamityMod.Items.BaseItems { public virtual bool VisibleInUI => false; - public override void Load() - { - Terraria.On_Player.dropItemCheck += DontDropCoolStuff; - Terraria.UI.On_ItemSlot.LeftClick_ItemArray_int_int += LockMouseToSpecialItem; - Terraria.UI.On_ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += DrawSpecial; - } - private void DrawSpecial(Terraria.UI.On_ItemSlot.orig_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color orig, SpriteBatch sb, Item[] inv, int context, int slot, Vector2 position, Color color) - { - if (inv[slot].ModItem is HeldOnlyItem && !(inv[slot].ModItem as HeldOnlyItem).VisibleInUI) - return; - - else - orig(sb, inv, context, slot, position, color); - } - public override void PostUpdate() { //Die if in the world @@ -40,19 +22,40 @@ namespace CalamityMod.Items.BaseItems public override bool CanPickup(Player player) => false; - private void LockMouseToSpecialItem(Terraria.UI.On_ItemSlot.orig_LeftClick_ItemArray_int_int orig, Item[] inv, int context, int slot) - { - if (!(Main.mouseItem.ModItem is HeldOnlyItem)) - orig(inv, context, slot); - } - - //https://media.discordapp.net/attachments/458432092301295618/993675527539916850/unknown.png - private void DontDropCoolStuff(Terraria.On_Player.orig_dropItemCheck orig, Terraria.Player self) - { - if (!(Main.mouseItem.ModItem is HeldOnlyItem)) - orig(self); - } - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) => false; + + #region Hooks + private sealed class HeldOnlyItemHooks : ModSystem + { + public override void Load() + { + Terraria.On_Player.dropItemCheck += DontDropCoolStuff; + Terraria.UI.On_ItemSlot.LeftClick_ItemArray_int_int += LockMouseToSpecialItem; + Terraria.UI.On_ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += DrawSpecial; + } + + private static void DrawSpecial(Terraria.UI.On_ItemSlot.orig_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color orig, SpriteBatch sb, Item[] inv, int context, int slot, Vector2 position, Color color) + { + if (inv[slot].ModItem is HeldOnlyItem heldOnlyItem && !heldOnlyItem.VisibleInUI) + return; + + else + orig(sb, inv, context, slot, position, color); + } + + private static void LockMouseToSpecialItem(Terraria.UI.On_ItemSlot.orig_LeftClick_ItemArray_int_int orig, Item[] inv, int context, int slot) + { + if (Main.mouseItem.ModItem is not HeldOnlyItem) + orig(inv, context, slot); + } + + //https://media.discordapp.net/attachments/458432092301295618/993675527539916850/unknown.png + private static void DontDropCoolStuff(Terraria.On_Player.orig_dropItemCheck orig, Terraria.Player self) + { + if (Main.mouseItem.ModItem is not HeldOnlyItem) + orig(self); + } + } + #endregion } } diff --git a/Items/BaseItems/TransformationAccessory.cs b/Items/BaseItems/TransformationAccessory.cs new file mode 100644 index 0000000000..dc76f2aaff --- /dev/null +++ b/Items/BaseItems/TransformationAccessory.cs @@ -0,0 +1,305 @@ +using Terraria.DataStructures; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using System.Linq; +using System; +using Microsoft.Xna.Framework; +using Terraria.Audio; + +namespace CalamityMod.Items.BaseItems +{ + public abstract class TransformationAccessory : ModItem + { + public bool IsForced = false; + + public virtual string AssetPath => "CalamityMod/Items/Accessories/Vanity/"; + + public virtual (EquipType Type, string AssetName, string EquipName)[] EquipSlots => []; + + public virtual float Priority => 1; + + public virtual Func ShouldTransform => (player) => true; + + public virtual bool ShouldHideAccessories => false; + + public virtual (SoundStyle sound, int delay)? HurtSound(Player p) => null; + + public virtual void ModifyDrawInfo(ref PlayerDrawSet drawInfo) { } + + public virtual void ArmorIDSets() + { + if (EquipSlots.Any(s => s.Type == EquipType.Head)) + { + string name = EquipSlots.First(s => s.Type == EquipType.Head).EquipName; + int equipSlotHead = EquipLoader.GetEquipSlot(Mod, name ?? Name, EquipType.Head); + ArmorIDs.Head.Sets.DrawHead[equipSlotHead] = false; + } + + if (EquipSlots.Any(s => s.Type == EquipType.Body)) + { + string name = EquipSlots.First(s => s.Type == EquipType.Body).EquipName; + int equipSlotBody = EquipLoader.GetEquipSlot(Mod, name ?? Name, EquipType.Body); + ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; + ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; + } + + if (EquipSlots.Any(s => s.Type == EquipType.Legs)) + { + string name = EquipSlots.First(s => s.Type == EquipType.Legs).EquipName; + int equipSlotLegs = EquipLoader.GetEquipSlot(Mod, name ?? Name, EquipType.Legs); + ArmorIDs.Legs.Sets.HidesBottomSkin[equipSlotLegs] = true; + } + } + + public virtual bool CustomSetEquipType(Player player, EquipType type, Mod mod, string name) => false; + + public virtual void TransformFrameEffects(Player player) { } + + public virtual void TransformPostUpdate(Player player) { } + + public override void Load() + { + if (Main.netMode != NetmodeID.Server) + { + foreach (var v in EquipSlots) + { + if (v.AssetName == null) + continue; + EquipLoader.AddEquipTexture(Mod, AssetPath + v.AssetName + "_" + v.Type.ToString(), v.Type, this, v.EquipName); + } + } + } + + public override void SetStaticDefaults() + { + if (Main.netMode == NetmodeID.Server) + return; + + ArmorIDSets(); + } + } + + public class TransformationPlayer : ModPlayer + { + public override void Load() + { + On_Player.ResetVisibleAccessories += ResetTransformation; + On_Player.UpdateVisibleAccessory += SetTransformationItem; + } + + internal TransformationAccessory currentTransformation = null; + internal TransformationAccessory previousTransformation = null; + internal int previousHighest = -1; + internal int currentHighest = -1; + + public int Type + { + get => currentTransformation == null ? -1 : currentTransformation.Type; + + set + { + ModItem item = ModContent.GetModItem(value); + if (item != null && item is TransformationAccessory trans) + { + currentTransformation = trans; + currentTransformation.IsForced = true; + } + else + currentTransformation = null; + } + } + + private void ResetTransformation(On_Player.orig_ResetVisibleAccessories orig, Player self) + { + orig(self); + + if (!self.dead) + Reset(self); + else + { + TransformationAccessory trans = self.Transformation().currentTransformation = self.Transformation().previousTransformation; + if (trans is not null) + EquipTransformation(trans, self, Mod); + } + } + + private static void Reset(Player p) + { + p.Transformation().previousHighest = p.Transformation().currentHighest; + p.Transformation().currentHighest = -1; + + if (p.Transformation().currentTransformation != null && !p.Transformation().currentTransformation.IsForced) + { + p.Transformation().previousTransformation = p.Transformation().currentTransformation; + p.Transformation().currentTransformation = null; + } + } + + private void SetTransformationItem(On_Player.orig_UpdateVisibleAccessory orig, Player self, int itemSlot, Item item, bool modded) + { + orig(self, itemSlot, item, modded); + + if (self.Transformation().currentTransformation == null || !self.Transformation().currentTransformation.IsForced) + { + if (item.ModItem is TransformationAccessory transformation && transformation.ShouldTransform.Invoke(self) && (currentTransformation == null || transformation.Priority >= currentTransformation.Priority)) + self.Transformation().currentTransformation = transformation; + } + + if (self.Transformation().currentHighest < itemSlot) + self.Transformation().currentHighest = itemSlot; + + if (self.Transformation().currentTransformation != null && itemSlot == self.Transformation().previousHighest) // last item slot, can set equip slots to our transformation if one is equipped + { + TransformationAccessory trans = self.Transformation().currentTransformation; + EquipTransformation(trans, self, Mod); + } + } + + public override void UpdateAutopause() + { + if (currentTransformation != null) + { + if (!currentTransformation.CustomSetEquipType(Player, EquipType.Head, Mod, currentTransformation.Name)) + { + var (Type, AssetName, EquipName) = currentTransformation.EquipSlots.First(v => v.Type == EquipType.Head); + string name = (EquipName == null && AssetName == null) ? null : EquipName ?? currentTransformation.Name; + SetEquipSlot(Player, EquipType.Head, Mod, name); + } + } + + Reset(Player); + } + + public override void ModifyDrawInfo(ref PlayerDrawSet drawInfo) + { + if (currentTransformation != null) + { + currentTransformation.ModifyDrawInfo(ref drawInfo); + + if (currentTransformation.EquipSlots.Any(s => s.Type == EquipType.Head)) + { + drawInfo.headGlowMask = -1; + drawInfo.helmetOffset = Vector2.Zero; + } + + if (currentTransformation.EquipSlots.Any(s => s.Type == EquipType.Body)) + { + drawInfo.bodyGlowMask = -1; + } + + if (currentTransformation.EquipSlots.Any(s => s.Type == EquipType.Legs)) + { + drawInfo.legsGlowMask = -1; + drawInfo.legsOffset = Vector2.Zero; + } + } + } + + public override void FrameEffects() + { + if (currentTransformation != null) + { + currentTransformation.TransformFrameEffects(Player); + + if (currentTransformation.ShouldHideAccessories) + Player.HideAccessories(); + } + } + + public override void PostUpdate() + { + currentTransformation?.TransformPostUpdate(Player); + } + + public static void SetEquipSlot(Player player, EquipType type, Mod mod, string name) + { + switch (type) + { + case EquipType.Head: + player.head = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Body: + player.body = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Legs: + player.legs = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.HandsOn: + player.handon = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.HandsOff: + player.handoff = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Back: + player.back = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Front: + player.front = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Shoes: + player.shoe = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Waist: + player.waist = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Wings: + player.wings = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Shield: + player.shield = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Neck: + player.neck = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Face: + player.face = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Balloon: + player.balloon = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + case EquipType.Beard: + player.beard = name == null ? -1 : EquipLoader.GetEquipSlot(mod, name, type); + break; + } + } + + public static int GetEquipSlot(Player player, EquipType type) => type switch + { + EquipType.Head => player.head, + EquipType.Body => player.body, + EquipType.Legs => player.legs, + EquipType.HandsOn => player.handon, + EquipType.HandsOff => player.handoff, + EquipType.Back => player.back, + EquipType.Front => player.front, + EquipType.Shoes => player.shoe, + EquipType.Waist => player.waist, + EquipType.Wings => player.wings, + EquipType.Shield => player.shield, + EquipType.Neck => player.neck, + EquipType.Face => player.face, + EquipType.Balloon => player.balloon, + EquipType.Beard => player.beard, + _ => -1, + }; + + public static void EquipTransformation(TransformationAccessory trans, Player self, Mod mod) + { + bool[] list = new bool[15]; + foreach (var (Type, AssetName, EquipName) in trans.EquipSlots) + { + string name = AssetName == null ? null : EquipName ?? trans.Name; + if (!trans.CustomSetEquipType(self, Type, mod, name) && !list[(int)Type]) + { + SetEquipSlot(self, Type, mod, name); + list[(int)Type] = true; + } + } + if (trans.ShouldHideAccessories) + self.HideAccessories(); + } + + public static EquipTexture GetEquipTexture(Player p, EquipType type) => EquipLoader.GetEquipTexture(type, GetEquipSlot(p, type)); + } +} diff --git a/Items/BleachBall.cs b/Items/BleachBall.cs deleted file mode 100644 index 3efe36e8fd..0000000000 --- a/Items/BleachBall.cs +++ /dev/null @@ -1,100 +0,0 @@ -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() - { - Item.width = 38; - Item.height = 46; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; - } - - public override bool CanRightClick() => true; - - public override void RightClick(Player player) - { - if (player.Calamity().disableNaturalScourgeSpawns == true) - player.Calamity().disableNaturalScourgeSpawns = false; - else - player.Calamity().disableNaturalScourgeSpawns = true; - state = player.Calamity().disableNaturalScourgeSpawns; - - Item.RestoreConsumedItemByRightClick(); - } - - /* - 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() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(ItemID.CalmingPotion). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/BrokenWaterFilter.cs b/Items/BrokenWaterFilter.cs deleted file mode 100644 index ffb03203aa..0000000000 --- a/Items/BrokenWaterFilter.cs +++ /dev/null @@ -1,90 +0,0 @@ -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() - { - Item.width = 32; - Item.height = 34; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; - } - - public override bool CanRightClick() => true; - - public override void RightClick(Player player) - { - if (player.Calamity().noStupidNaturalARSpawns == true) - player.Calamity().noStupidNaturalARSpawns = false; - else - player.Calamity().noStupidNaturalARSpawns = true; - state = player.Calamity().noStupidNaturalARSpawns; - - Item.RestoreConsumedItemByRightClick(); - } - - /* - 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); - } - } -} diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 49c79cc472..0d0e8efdcf 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -6,21 +6,29 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Enums; using CalamityMod.Events; +using CalamityMod.ExtraJumps; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Ammo; +using CalamityMod.Items.Armor.Bloodflare; +using CalamityMod.Items.Armor.GodSlayer; +using CalamityMod.Items.Armor.Hydrothermic; +using CalamityMod.Items.Armor.Prismatic; +using CalamityMod.Items.Armor.Reaver; +using CalamityMod.Items.Armor.Tarragon; +using CalamityMod.Items.Armor.Victide; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Tools; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.Other; using CalamityMod.NPCs.TownNPCs; -using CalamityMod.Packets; using CalamityMod.Particles; +using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; @@ -28,7 +36,6 @@ using CalamityMod.Systems.Collections; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.UI; using CalamityMod.UI.CalamitasEnchants; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -38,7 +45,7 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; -using Terraria.Utilities; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items { @@ -46,16 +53,18 @@ namespace CalamityMod.Items { public override bool InstancePerEntity => true; - // TODO -- split out a separate GlobalItem for rogue behavior? - /// Tracks the stealth strike damage modifier for this item, derived from its prefix. - internal float StealthStrikePrefixBonus; + private BitsByte flag0 = 0; #region Chargeable Item Variables /// /// If set to true, this item will consume on use.
/// Be sure to also set and . ///
- public bool UsesCharge = false; + public bool UsesCharge + { + get => flag0[0]; + set => flag0[0] = value; + } /// The current charge value of this item. public float Charge = 0f; /// The maximum charge value of this item. Should only be set if is set to true. @@ -79,7 +88,11 @@ namespace CalamityMod.Items #region Enchantment Variables /// If set to true, this item cannot receive enchantments from the Brimstone Witch. - public bool CannotBeEnchanted = false; + public bool CannotBeEnchanted + { + get => flag0[1]; + set => flag0[1] = value; + } /// Stores the current enchantment placed on this item. If set to null, this item has no enchantment. public Enchantment? AppliedEnchantment = null; /// @@ -108,35 +121,32 @@ namespace CalamityMod.Items /// Set to true if this item can only be obtained in Revengeance Mode.
/// Adds "Revengeance" to the bottom of the item's tooltip. ///
- public bool revengeanceItem = false; + public bool revengeanceItem + { + get => flag0[2]; + set => flag0[2] = value; + } /// /// Set to true if this item is dedicated to a Patreon donator.
/// Adds "- Donor Item -" to the bottom of the item's tooltip. ///
- public bool donorItem = false; + public bool donorItem + { + get => flag0[3]; + set => flag0[3] = value; + } /// /// Set to true if this item is dedicated to a Calamity developer.
/// Adds "- Dev Item -" to the bottom of the item's tooltip. ///
- public bool devItem = false; - /// - /// If true, this item can fire projectiles with point-blank damage.
- /// Also adds a tooltip line to the bottom of the item's tooltip. - ///
- public bool canFirePointBlankShots = false; - /// - /// If set to a value greater than 1, applies a multiplier to the item's grab range.
- /// Used by coin items spawned from hitting ricoshot coins. - ///
- public float grabRangeMultiplier = 1f; + public bool devItem + { + get => flag0[4]; + set => flag0[4] = value; + } public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64); - public CalamityGlobalItem() - { - StealthStrikePrefixBonus = 0f; - } - // Ozzatron 21MAY2022: This function is required by TML 1.4's new clone behavior. // This behavior is sadly mandatory because there are a few places in vanilla Terraria which use cloning. // Most notably: reforging and item tooltips. @@ -148,8 +158,8 @@ namespace CalamityMod.Items { CalamityGlobalItem myClone = (CalamityGlobalItem)base.Clone(item, itemClone); - // Rogue - myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus; + // BitFlags + myClone.flag0 = flag0; // Charge (Draedon's Arsenal) myClone.UsesCharge = UsesCharge; @@ -159,17 +169,9 @@ namespace CalamityMod.Items myClone.ChargePerAltUse = ChargePerAltUse; // Enchantments - myClone.CannotBeEnchanted = CannotBeEnchanted; myClone.AppliedEnchantment = AppliedEnchantment.HasValue ? AppliedEnchantment.Value : null; myClone.DischargeEnchantExhaustion = DischargeEnchantExhaustion; - // Miscellaneous - myClone.revengeanceItem = revengeanceItem; - myClone.donorItem = donorItem; - myClone.devItem = devItem; - myClone.canFirePointBlankShots = canFirePointBlankShots; - myClone.grabRangeMultiplier = grabRangeMultiplier; - return myClone; } @@ -179,32 +181,53 @@ namespace CalamityMod.Items SetStaticDefaults_ShimmerRecipes(); #region Vanilla Wing Tweaks - // 170 -> 240 flight time - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.BoneWings].FlyTime = 240; - // 170 -> 200 flight time - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.MothronWings].FlyTime = 200; + // Shorthand to make looking at this easier + WingStats[] stats = ArmorIDs.Wing.Sets.Stats; + // 130 -> 160 flight time, 6.75 -> 7.5 horizontal speed + stats[(int)VanillaWingID.HarpyWings].FlyTime = 160; + stats[(int)VanillaWingID.HarpyWings].AccRunSpeedOverride = 7.5f; + // 6.75 -> 9 horizontal speed, 1 -> 1.5 acceleration multiplier + stats[(int)VanillaWingID.FrozenWings].AccRunSpeedOverride = 9f; + stats[(int)VanillaWingID.FrozenWings].AccRunAccelerationMult = 1.5f; + // 160 -> 130 flight time + stats[(int)VanillaWingID.FlameWings].FlyTime = 130; + // 160 -> 180 flight time, 7.5 -> 6.25 horizontal speed + stats[(int)VanillaWingID.BatWings].FlyTime = 180; + stats[(int)VanillaWingID.BatWings].AccRunSpeedOverride = 6.25f; + // 1 -> 1.5 acceleration multiplier + stats[(int)VanillaWingID.ButterflyWings].AccRunAccelerationMult = 1.5f; + + // 170 -> 240 flight time + stats[(int)VanillaWingID.BoneWings].FlyTime = 240; + // 160 -> 170 flight time, 7.5 -> 9 horizontal speed, 1 -> 1.5 acceleration multiplier + stats[(int)VanillaWingID.LeafWings].FlyTime = 170; + stats[(int)VanillaWingID.LeafWings].AccRunSpeedOverride = 9f; + stats[(int)VanillaWingID.LeafWings].AccRunAccelerationMult = 1.5f; + // (Spectre Wings) 1 -> 2 acceleration multiplier + stats[(int)VanillaWingID.GhostWings].AccRunAccelerationMult = 2f; + + // 170 -> 210 flight time + stats[(int)VanillaWingID.BeetleWings].FlyTime = 210; + // 180 -> 210 flight time + stats[(int)VanillaWingID.TatteredFairyWings].FlyTime = 210; // (Empress Wings) 150 -> 120 flight time - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.RainbowWings].FlyTime = 120; + stats[(int)VanillaWingID.RainbowWings].FlyTime = 120; // 12 -> 10.8 hover stats - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.BejeweledValkyrieWing].DownHoverSpeedOverride = 10.8f; // (Lazure) - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.BejeweledValkyrieWing].DownHoverAccelerationMult = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.Yoraiz0rWings].DownHoverSpeedOverride = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.Yoraiz0rWings].DownHoverAccelerationMult = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.SkiphsWings].DownHoverSpeedOverride = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.SkiphsWings].DownHoverAccelerationMult = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.BetsyWings].DownHoverSpeedOverride = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.BetsyWings].DownHoverAccelerationMult = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.WingsVortex].DownHoverSpeedOverride = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.WingsVortex].DownHoverAccelerationMult = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.WingsNebula].DownHoverSpeedOverride = 10.8f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.WingsNebula].DownHoverAccelerationMult = 10.8f; + stats[(int)VanillaWingID.BejeweledValkyrieWing].DownHoverSpeedOverride = 10.8f; // (Lazure) + stats[(int)VanillaWingID.BejeweledValkyrieWing].DownHoverAccelerationMult = 10.8f; + stats[(int)VanillaWingID.Yoraiz0rWings].DownHoverSpeedOverride = 10.8f; + stats[(int)VanillaWingID.Yoraiz0rWings].DownHoverAccelerationMult = 10.8f; + stats[(int)VanillaWingID.SkiphsWings].DownHoverSpeedOverride = 10.8f; + stats[(int)VanillaWingID.SkiphsWings].DownHoverAccelerationMult = 10.8f; + stats[(int)VanillaWingID.BetsyWings].DownHoverSpeedOverride = 10.8f; + stats[(int)VanillaWingID.BetsyWings].DownHoverAccelerationMult = 10.8f; - // (Celestial Starboard) 4.5 -> 2.75 acceleration multiplier, 16 -> 11.6 hover stats - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.LongRainbowTrailWings].AccRunAccelerationMult = 2.75f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.LongRainbowTrailWings].DownHoverSpeedOverride = 11.6f; - ArmorIDs.Wing.Sets.Stats[(int)VanillaWingID.LongRainbowTrailWings].DownHoverAccelerationMult = 11.6f; + // (Celestial Starboard) 4.5 -> 2.75 acceleration multiplier, 16 -> 12 hover stats + stats[(int)VanillaWingID.LongRainbowTrailWings].AccRunAccelerationMult = 2.75f; + stats[(int)VanillaWingID.LongRainbowTrailWings].DownHoverSpeedOverride = 12f; + stats[(int)VanillaWingID.LongRainbowTrailWings].DownHoverAccelerationMult = 12f; #endregion } @@ -214,6 +237,10 @@ namespace CalamityMod.Items if (item.accessory) CannotBeEnchanted = true; + // Music boxes are pre-boss and sold from the Merchant, so they should now use the blue rarity. + if (item.type == ItemID.MusicBox || item.createTile == TileID.MusicBoxes || ItemID.Sets.ShimmerTransformToItem[item.type] == ItemID.MusicBox) + item.rare = ItemRarityID.Blue; + // Modified Pearlwood items are now Light Red. if (item.type == ItemID.PearlwoodBow || item.type == ItemID.PearlwoodHammer || item.type == ItemID.PearlwoodSword) item.rare = ItemRarityID.LightRed; @@ -232,10 +259,10 @@ namespace CalamityMod.Items // Zenith rarity if (item.type == ItemID.Zenith) - item.rare = ModContent.RarityType(); + item.rare = RarityType(); - // Make most expert items no longer expert because they drop in all modes now. - switch (item.type) + // CIT 16OCT2025: Following overwhelming dev vote, Expert+ drops are NOT available in Classic + /*switch (item.type) { case ItemID.RoyalGel: case ItemID.EoCShield: @@ -260,7 +287,7 @@ namespace CalamityMod.Items case ItemID.LongRainbowTrailWings: item.expert = false; break; - } + }*/ // Allow Souls to be used as ammo for SHPC. if (item.type == ItemID.SoulofLight || item.type == ItemID.SoulofNight || item.type == ItemID.SoulofFlight || item.type == ItemID.SoulofMight || item.type == ItemID.SoulofSight || item.type == ItemID.SoulofFright) @@ -270,7 +297,7 @@ namespace CalamityMod.Items } // Increase how much health Mushrooms heal. - if (item.type == ItemID.Mushroom && item.healLife == 15) + if (item.type == ItemID.Mushroom && item.healLife < 25) item.healLife = 25; // Allow Beam Sword to change direction when it fires, because vanilla disables it for some reason. @@ -315,9 +342,9 @@ namespace CalamityMod.Items if (Main.myPlayer == player.whoAmI && player.Calamity().cursedSummonsEnchant) { - if (NPC.CountNPCS(ModContent.NPCType()) < 2) + if (NPC.CountNPCS(NPCType()) < 2) { - CalamityNetcode.NewNPC_ClientSide(mouse, ModContent.NPCType(), player); + CalamityNetcode.NewNPC_ClientSide(mouse, NPCType(), player); SoundEngine.PlaySound(SoundID.DD2_DarkMageSummonSkeleton, mouse); } } @@ -328,7 +355,7 @@ namespace CalamityMod.Items // // Traitorous has been reworked to be a guaranteed effect below 25% mana, which removes all your remaining mana bool belowManaThreshold = player.statMana < player.statManaMax2 * 0.25f; - bool traitorousAlreadyInPlay = player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; + bool traitorousAlreadyInPlay = player.ownedProjectileCounts[ProjectileType()] > 0; if (Main.myPlayer == player.whoAmI && player.Calamity().manaMonsterEnchant && !traitorousAlreadyInPlay && belowManaThreshold) { // Calculate how much damage to deal based on how much mana was consumed @@ -338,7 +365,7 @@ namespace CalamityMod.Items // Spawn the Mana Monster Vector2 shootVelocity = player.SafeDirectionTo(mouse, -Vector2.UnitY).RotatedByRandom(0.07f) * Main.rand.NextFloat(4f, 5f); - Projectile.NewProjectile(source, player.Center + shootVelocity, shootVelocity, ModContent.ProjectileType(), monsterDamage, 0f, player.whoAmI); + Projectile.NewProjectile(source, player.Center + shootVelocity, shootVelocity, ProjectileType(), monsterDamage, 0f, player.whoAmI); // Set the player's mana to zero. player.statMana = 0; @@ -351,10 +378,8 @@ namespace CalamityMod.Items modPlayer.canFireBloodflareMageProjectile = false; if (player.whoAmI == Main.myPlayer) { - // Bloodflare Mage Bolt: 130%, soft cap starts at 2000 base damage - int bloodflareBoltDamage = CalamityUtils.DamageSoftCap(damage * 1.3, 2600); - - Projectile.NewProjectile(playerSource, position, velocity, ModContent.ProjectileType(), bloodflareBoltDamage, 1f, player.whoAmI); + int bloodflareBoltDamage = CalamityUtils.DamageSoftCap(damage * BloodflareHeadMagic.GhostBoltDamageRatio, BloodflareHeadMagic.GhostBoltonDamageSoftcap); + Projectile.NewProjectile(playerSource, position, velocity, ProjectileType(), bloodflareBoltDamage, 1f, player.whoAmI); } } } @@ -365,22 +390,19 @@ namespace CalamityMod.Items modPlayer.canFireBloodflareRangedProjectile = false; if (player.whoAmI == Main.myPlayer) { - // Bloodflare Ranged Bloodsplosion: 80%, soft cap starts at 150 base damage - // This is intentionally extremely low because this effect can be grossly overpowered with sniper rifles and the like. - int bloodsplosionDamage = CalamityUtils.DamageSoftCap(damage * 0.8, 120); - - Projectile.NewProjectile(playerSource, position, velocity, ModContent.ProjectileType(), bloodsplosionDamage, 2f, player.whoAmI); + int bloodsplosionDamage = CalamityUtils.DamageSoftCap(damage * BloodflareHeadRanged.BloodBombDamageRatio, BloodflareHeadRanged.BloodBombDamageSoftcap); + Projectile.NewProjectile(playerSource, position, velocity, ProjectileType(), bloodsplosionDamage, 2f, player.whoAmI); } } } if (modPlayer.tarraMage && !item.channel) { - if (modPlayer.tarraCrits >= 5 && player.whoAmI == Main.myPlayer) + if (modPlayer.tarraCrits >= TarragonHeadMagic.CritsToSpawnLeaves && player.whoAmI == Main.myPlayer) { modPlayer.tarraCrits = 0; // Tarragon Mage Leaves: (8-10) x 20%, soft cap starts at 200 base damage int leafAmt = 8 + Main.rand.Next(3); // 8, 9, or 10 - int leafDamage = (int)(damage * 0.2f); + int leafDamage = (int)(damage * TarragonHeadMagic.LeafDamageRatio); for (int l = 0; l < leafAmt; l++) { @@ -404,8 +426,8 @@ namespace CalamityMod.Items modPlayer.canFireAtaxiaRangedProjectile = false; if (player.whoAmI == Main.myPlayer) { - int ataxiaFlareDamage = (int)(damage * 0.25f); - Projectile.NewProjectile(playerSource, position, velocity * 1.25f, ModContent.ProjectileType(), ataxiaFlareDamage, 2f, player.whoAmI); + int ataxiaFlareDamage = (int)(damage * HydrothermicHeadRanged.FlareDamageRatio); + Projectile.NewProjectile(playerSource, position, velocity * 1.25f, ProjectileType(), ataxiaFlareDamage, 2f, player.whoAmI); } } } @@ -416,10 +438,8 @@ namespace CalamityMod.Items modPlayer.canFireGodSlayerRangedProjectile = false; if (player.whoAmI == Main.myPlayer) { - // God Slayer Ranged Shrapnel: 100%, soft cap starts at 800 base damage - int shrapnelRoundDamage = CalamityUtils.DamageSoftCap(damage, 800); - - Projectile.NewProjectile(playerSource, position, velocity * 1.25f, ModContent.ProjectileType(), shrapnelRoundDamage, 2f, player.whoAmI); + int shrapnelRoundDamage = CalamityUtils.DamageSoftCap(damage * GodSlayerHeadRanged.ShrapnelRoundDamageRatio, GodSlayerHeadRanged.ShrapnelRoundDamageSoftcap); + Projectile.NewProjectile(playerSource, position, velocity * 1.25f, ProjectileType(), shrapnelRoundDamage, 2f, player.whoAmI); } } } @@ -428,10 +448,8 @@ namespace CalamityMod.Items if (item.CountsAsClass() && !item.channel) { modPlayer.canFireAtaxiaRogueProjectile = false; - int flareID = ModContent.ProjectileType(); - - // Hydrothermic Rogue Flares: 6 x (50 + 15%), soft cap starts at 90 base damage - int flareDamage = CalamityUtils.DamageSoftCap(50 + damage * 0.15, 90); + int flareID = ProjectileType(); + int flareDamage = CalamityUtils.DamageSoftCap(HydrothermicHeadRogue.VolleyDamage + damage * HydrothermicHeadRogue.VolleyDamageRatio, HydrothermicHeadRogue.VolleyDamageSoftcap); if (player.whoAmI == Main.myPlayer) { @@ -444,24 +462,9 @@ namespace CalamityMod.Items } } } - if (modPlayer.victideSet) - { - if ((item.CountsAsClass() || item.CountsAsClass() || item.CountsAsClass() || - item.CountsAsClass() || item.CountsAsClass()) && - Main.rand.NextBool(10) && !item.channel) - { - if (player.whoAmI == Main.myPlayer) - { - // Victide All-class Seashells: 200%, soft cap starts at 46 base damage - int seashellDamage = CalamityUtils.DamageSoftCap(damage * 2, 46); - - Projectile.NewProjectile(playerSource, position, velocity * 1.25f, ModContent.ProjectileType(), seashellDamage, 1f, player.whoAmI); - } - } - } if (modPlayer.prismaticRegalia) { - if (item.CountsAsClass() && Main.rand.NextBool(20) && !item.channel) + if (item.CountsAsClass() && Main.rand.NextBool(PrismaticRegalia.RocketChanceDenominator) && !item.channel) { if (player.whoAmI == Main.myPlayer) { @@ -470,7 +473,7 @@ namespace CalamityMod.Items if (i != 0) { Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); - int rocket = Projectile.NewProjectile(playerSource, position, perturbedSpeed, ModContent.ProjectileType(), (int)(damage * 0.25), 2f, player.whoAmI, 0, 12f); + int rocket = Projectile.NewProjectile(playerSource, position, perturbedSpeed, ProjectileType(), (int)(damage * PrismaticRegalia.RocketDamageRatio), 2f, player.whoAmI, 0, 12f); //First extra value is rocket type which I just used 0 to get the default, second is the velocity I went with my gut feeling and got quite close to Scorpio's velocity with Rockets I if (rocket.WithinBounds(Main.maxProjectiles)) Main.projectile[rocket].DamageType = DamageClass.Generic; @@ -479,6 +482,7 @@ namespace CalamityMod.Items } } } + return true; } #endregion @@ -489,13 +493,10 @@ namespace CalamityMod.Items tag.Add("charge", Charge); tag.Add("enchantmentID", AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0); tag.Add("DischargeEnchantExhaustion", DischargeEnchantExhaustion); - tag.Add("canFirePointBlankShots", canFirePointBlankShots); } public override void LoadData(Item item, TagCompound tag) { - canFirePointBlankShots = tag.GetBool("canFirePointBlankShots"); - // Changed charge from int to float. If an old charge int is present, load that instead. if (tag.ContainsKey("Charge")) Charge = tag.GetInt("Charge"); @@ -514,11 +515,6 @@ namespace CalamityMod.Items public override void NetSend(Item item, BinaryWriter writer) { - BitsByte flags = new BitsByte(); - flags[0] = canFirePointBlankShots; - // rip, no other flags. what a byte. - - writer.Write(flags); writer.Write(Charge); writer.Write(AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0); writer.Write(DischargeEnchantExhaustion); @@ -526,9 +522,6 @@ namespace CalamityMod.Items public override void NetReceive(Item item, BinaryReader reader) { - BitsByte flags = reader.ReadByte(); - canFirePointBlankShots = flags[0]; - Charge = reader.ReadSingle(); Enchantment? savedEnchantment = EnchantmentManager.FindByID(reader.ReadInt32()); @@ -544,20 +537,23 @@ namespace CalamityMod.Items #endregion #region Pickup Item Changes + public override bool CanPickup(Item item, Player player) + { + // Prevent Mana Stars from being picked up while wielding Ion Blaster or Apoctosis Array + if (item.type == ItemID.Star || item.type == ItemID.SoulCake || item.type == ItemID.SugarPlum) + { + if (player.HeldItem.type == ItemType() || player.HeldItem.type == ItemType()) + return false; + } + return base.CanPickup(item, player); + } + public override bool OnPickup(Item item, Player player) { if (item.type == ItemID.Heart || item.type == ItemID.CandyApple || item.type == ItemID.CandyCane) // On heart pickup { - bool boostedHeart = player.Calamity().photosynthesis; - if (boostedHeart) - { + if (player.Calamity().photosynthesis) player.HealPlayer(PhotosynthesisPotion.IncreasedHeartHeal); - } - } - if (item.type == ItemID.Star || item.type == ItemID.SoulCake || item.type == ItemID.SugarPlum) // On star pickup - { - if (player.ActiveItem().type == ModContent.ItemType() || player.ActiveItem().type == ModContent.ItemType()) - return false; } return true; } @@ -569,25 +565,63 @@ namespace CalamityMod.Items // Clear Evil Smasher buffs if not holding Evil Smasher if (player.Calamity().evilSmasherBoost > 0) { - if (item.type != ModContent.ItemType()) + if (item.type != ItemType()) player.Calamity().evilSmasherBoost = 0; } + + if (player.Calamity().ChaosStone && item.mana == 0 && !player.ItemTimeIsZero) + { + player.manaRegenDelay = player.maxRegenDelay; + } } public override bool? UseItem(Item item, Player player) { + var modPlayer = player.Calamity(); + if (Main.zenithWorld && item.type == ItemID.RodOfHarmony) { - if (NPC.AnyNPCs(ModContent.NPCType())) + if (NPC.AnyNPCs(NPCType())) { //one hour of NOU when using rod of harmony while LORDE is alive - player.AddBuff(ModContent.BuffType(), 3600 * 60); + player.AddBuff(BuffType(), 3600 * 60); } } // Give 1 minute of Mushy buff when consuming Mushrooms with Fungal Symbiote equipped. if (item.type == ItemID.Mushroom && player.Calamity().fungalSymbiote) - player.AddBuff(ModContent.BuffType(), 3600); + player.AddBuff(BuffType(), 3600); + + // Healing item interactions + if (item.healLife > 0) + { + // Jelly aura spawning + // This runs twice per use for whatever reason so we need a stopping player variable + if (player.whoAmI == Main.myPlayer && !modPlayer.spawnedJellyAura) + { + if (modPlayer.absorber) + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0, player.whoAmI); + else if (modPlayer.GrandGelatin) + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0, player.whoAmI); + else + { + if (modPlayer.cleansingjelly) + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0, player.whoAmI); + if (modPlayer.lifejelly) + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0, player.whoAmI); + } + modPlayer.spawnedJellyAura = true; + } + + // Trigger Bloom Stone's heal over time from healing items + if (modPlayer.bloomStone) + { + // Temporarily disable Bloom Stone so that GetHealLife doesn't return 0 + modPlayer.bloomStone = false; + modPlayer.bloomStoneTotalHeal = modPlayer.bloomStoneHealPool = player.GetHealLife(item); + modPlayer.bloomStone = true; + } + } // Staff/Axe of Regrowth growing Calamity grass if (item.type == ItemID.StaffofRegrowth || item.type == ItemID.AcornAxe) @@ -595,22 +629,22 @@ namespace CalamityMod.Items Tile tile = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY); Tile tileAbove = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY - 1); - if (tile.HasTile && !tileAbove.HasTile && tileAbove.LiquidAmount == 0 && tile.TileType == ModContent.TileType() && player.IsInTileInteractionRange(Player.tileTargetX, Player.tileTargetY, TileReachCheckSettings.Simple)) + if (tile.HasTile && !tileAbove.HasTile && tileAbove.LiquidAmount == 0 && tile.TileType == TileType() && player.IsInTileInteractionRange(Player.tileTargetX, Player.tileTargetY, TileReachCheckSettings.Simple)) { - Main.tile[Player.tileTargetX, Player.tileTargetY].TileType = (ushort)ModContent.TileType(); + Main.tile[Player.tileTargetX, Player.tileTargetY].TileType = (ushort)TileType(); SoundEngine.PlaySound(SoundID.Dig, player.Center); return true; } - else if (tile.HasTile && tile.TileType == ModContent.TileType() && player.IsInTileInteractionRange(Player.tileTargetX, Player.tileTargetY, TileReachCheckSettings.Simple)) + else if (tile.HasTile && tile.TileType == TileType() && player.IsInTileInteractionRange(Player.tileTargetX, Player.tileTargetY, TileReachCheckSettings.Simple)) { - Main.tile[Player.tileTargetX, Player.tileTargetY].TileType = (ushort)ModContent.TileType(); + Main.tile[Player.tileTargetX, Player.tileTargetY].TileType = (ushort)TileType(); SoundEngine.PlaySound(SoundID.Dig, player.Center); return true; } } - + return base.UseItem(item, player); } @@ -620,42 +654,7 @@ namespace CalamityMod.Items { return false; } - if (player.ActiveItem().type == ModContent.ItemType()) - { - bool hasBlades = false; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI && p.localAI[1] == 0f) - { - hasBlades = true; - break; - } - } - if (hasBlades) - { - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.ModProjectile is IgneousBlade) - { - if (p.ModProjectile().Firing) - continue; - } - if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI && p.localAI[1] == 0f) - { - p.rotation = MathHelper.PiOver2 + MathHelper.PiOver4; - // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - 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; - } - } - } - return false; - } - if (player.ActiveItem().type == ModContent.ItemType() && player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) + if (player.HeldItem.type == ItemType() && player.ownedProjectileCounts[ProjectileType()] == 0) { foreach (Projectile p in Main.ActiveProjectiles) { @@ -670,13 +669,13 @@ namespace CalamityMod.Items } return false; } - if (player.ActiveItem().type == ModContent.ItemType()) + if (player.HeldItem.type == ItemType()) { bool canContinue = true; int count = 0; foreach (Projectile p in Main.ActiveProjectiles) { - if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI) + if (p.type == ProjectileType() && p.owner == player.whoAmI) { if (p.ai[1] > 1f) { @@ -700,13 +699,13 @@ namespace CalamityMod.Items float angleVariance = MathHelper.TwoPi / pointyThingyAmount; float angle = 0f; - var source = player.GetSource_ItemUse(player.ActiveItem()); + var source = player.GetSource_ItemUse(player.HeldItem); for (int i = 0; i < pointyThingyAmount; i++) { if (Main.projectile.Length == Main.maxProjectiles) break; int GlacialEmbraceDamage = (int)player.GetTotalDamage().ApplyTo(80); - int projj = Projectile.NewProjectile(source, mouse, Vector2.Zero, ModContent.ProjectileType(), GlacialEmbraceDamage, 1f, player.whoAmI, angle, 2f); + int projj = Projectile.NewProjectile(source, mouse, Vector2.Zero, ProjectileType(), GlacialEmbraceDamage, 1f, player.whoAmI, angle, 2f); Main.projectile[projj].originalDamage = 80; angle += angleVariance; @@ -733,7 +732,11 @@ namespace CalamityMod.Items if (PopupGUIManager.AnyGUIsActive) return false; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && + // Can't use anything while burrowing + if (player.ownedProjectileCounts[ProjectileType()] > 0) + return false; + + if (player.ownedProjectileCounts[ProjectileType()] > 0 && (item.damage > 0 || item.ammo != AmmoID.None)) { return false; // Don't use weapons if you're charging with a spear @@ -745,7 +748,7 @@ namespace CalamityMod.Items return base.CanUseItem(item, player); // Conversion for Andromeda - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + if (player.ownedProjectileCounts[ProjectileType()] > 0) { if (item.type == ItemID.WireKite) return false; @@ -801,10 +804,6 @@ namespace CalamityMod.Items // Handle general use-item effects for the Gem Tech Armor. player.Calamity().GemTechState.OnItemUseEffects(item); - if (item.type == ItemID.MonkStaffT1 || AutoreusableSpearsList.Includes(item.type)) - { - return player.ownedProjectileCounts[item.shoot] <= 0; - } if (item.type == ItemID.RodofDiscord) { if (player.chaosState) @@ -885,7 +884,6 @@ namespace CalamityMod.Items // 10% charge = 83% damage // 0% charge = 41.33% damage // - // Fabsol - I changed this formula because it was bad and confusing, and I had promised to do so a while ago. internal float ChargeDamageFormula() { float x = MathHelper.Clamp(ChargeRatio, 0f, 1f); @@ -894,12 +892,39 @@ namespace CalamityMod.Items } #endregion - #region ModifyHitNPC + #region Hit NPC public override void ModifyHitNPC(Item item, Player player, NPC target, ref NPC.HitModifiers modifiers) { // This assume all items with a damage hit is a weapon. There appears to be no edge cases for this thus far if (player.Calamity().oldFashioned) modifiers.SourceDamage *= OldFashioned.DamageReductionMultiplier; + if (player.Calamity().ivDrip) + modifiers.SourceDamage *= IVDripOnTheRocks.DamageReductionMultiplier; + } + + public override void OnHitNPC(Item item, Player player, NPC target, NPC.HitInfo hit, int damageDone) + { + // Hyperius Overflow + if (target.Calamity().hyperiusMarked) + { + int damage = 0; + if (target.Calamity().hyperiusDamage < damageDone) + damage = damageDone - target.Calamity().hyperiusDamage; + else + damage = damageDone; + target.Calamity().hyperiusDamage -= damage; + + // Spawn overflow hit + Projectile overflow = Projectile.NewProjectileDirect(target.GetSource_FromThis(), target.Center, Vector2.Zero, ProjectileType(), (int)(damage * HyperiusBullet.overflowEfficency), 0, player.whoAmI, target.whoAmI); + overflow.DamageType = item.DamageType; + overflow.ArmorPenetration = item.ArmorPenetration; // Takes the armor pen from what did the hit + + if (target.Calamity().hyperiusDamage <= 0) + { + target.Calamity().hyperiusDamage = 0; + target.Calamity().hyperiusMarked = false; + } + } } #endregion @@ -916,18 +941,6 @@ namespace CalamityMod.Items return "MagicHat"; if (head.type == ItemID.CrystalNinjaHelmet && body.type == ItemID.CrystalNinjaChestplate && legs.type == ItemID.CrystalNinjaLeggings) return "CrystalAssassin"; - if (head.type == ItemID.SquireGreatHelm && body.type == ItemID.SquirePlating && legs.type == ItemID.SquireGreaves) - return "SquireTier2"; - if (head.type == ItemID.HuntressWig && body.type == ItemID.HuntressJerkin && legs.type == ItemID.HuntressPants) - return "HuntressTier2"; - if (head.type == ItemID.ApprenticeHat && body.type == ItemID.ApprenticeRobe && legs.type == ItemID.ApprenticeTrousers) - return "ApprenticeTier2"; - if (head.type == ItemID.SquireAltHead && body.type == ItemID.SquireAltShirt && legs.type == ItemID.SquireAltPants) - return "SquireTier3"; - if (head.type == ItemID.HuntressAltHead && body.type == ItemID.HuntressAltShirt && legs.type == ItemID.HuntressAltPants) - return "HuntressTier3"; - if (head.type == ItemID.ApprenticeAltHead && body.type == ItemID.ApprenticeAltShirt && legs.type == ItemID.ApprenticeAltPants) - return "ApprenticeTier3"; if (head.type == ItemID.SpectreHood && body.type == ItemID.SpectreRobe && legs.type == ItemID.SpectrePants) return "SpectreHealing"; if (head.type == ItemID.SolarFlareHelmet && body.type == ItemID.SolarFlareBreastplate && legs.type == ItemID.SolarFlareLeggings) @@ -935,6 +948,11 @@ namespace CalamityMod.Items return ""; } + public override void ModifyItemScale(Item item, Player player, ref float scale) + { + if (item.CountsAsClass() && player.HasBuff(BuffID.Tipsy)) + scale += 0.15f; + } public override void UpdateArmorSet(Player player, string set) { CalamityPlayer modPlayer = player.Calamity(); @@ -957,44 +975,6 @@ namespace CalamityMod.Items modPlayer.rogueStealthMax += 0.9f; modPlayer.wearingRogueArmor = true; } - else if (set == "SquireTier2") - { - player.lifeRegen += 3; - player.GetDamage() += 0.15f; - player.GetCritChance() += 10; - player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.SquireTier2")}"; - } - else if (set == "HuntressTier2") - { - player.GetDamage() += 0.1f; - player.GetDamage() += 0.1f; - player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.HuntressTier2")}"; - } - else if (set == "ApprenticeTier2") - { - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; - player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.ApprenticeTier2")}"; - } - else if (set == "SquireTier3") - { - player.lifeRegen += 6; - player.GetDamage() += 0.1f; - player.GetCritChance() += 15; - player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.SquireTier3")}"; - } - else if (set == "HuntressTier3") - { - player.GetDamage() += 0.1f; - player.GetDamage() += 0.1f; - player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.HuntressTier3")}"; - } - else if (set == "ApprenticeTier3") - { - player.GetDamage() += 0.15f; - player.GetCritChance() += 15; - player.setBonus += $"\n{CalamityUtils.GetTextValue("Vanilla.Armor.SetBonus.ApprenticeTier3")}"; - } else if (set == "SpectreHealing") { player.GetDamage() += 0.4f; @@ -1058,69 +1038,71 @@ namespace CalamityMod.Items player.GetAttackSpeed() += 0.05f; break; - case ItemID.SquireGreatHelm: - player.lifeRegen -= 3; - break; - case ItemID.SquirePlating: - player.GetDamage() -= 0.1f; - break; case ItemID.SquireGreaves: - player.GetDamage() -= 0.1f; - player.GetCritChance() -= 10; + player.GetDamage() -= 0.05f; + break; + + case ItemID.HuntressWig: + player.GetCritChance() += 5; break; case ItemID.HuntressJerkin: - player.GetDamage() -= 0.1f; - player.GetDamage() -= 0.15f; - player.GetCritChance() += 5; - break; - case ItemID.HuntressPants: + player.GetDamage() -= 0.05f; player.GetDamage() -= 0.05f; break; case ItemID.ApprenticeHat: - player.GetDamage() -= 0.05f; + player.GetDamage() -= 0.1f; break; + case ItemID.ApprenticeRobe: - player.GetDamage() -= 0.1f; - break; - case ItemID.ApprenticeTrousers: player.GetDamage() -= 0.05f; - player.GetCritChance() -= 15; + player.GetDamage() += 0.05f; + break; + + case ItemID.ApprenticeTrousers: + player.GetCritChance() -= 5; + break; + + case ItemID.ShroomiteBreastplate: + player.GetDamage() -= 0.05f; + player.GetCritChance() -= 5; break; case ItemID.SquireAltHead: player.GetDamage() += 0.05f; player.GetDamage() += 0.05f; break; + case ItemID.SquireAltShirt: - player.lifeRegen -= 6; - player.GetDamage() -= 0.15f; - break; - case ItemID.SquireAltPants: player.GetDamage() -= 0.1f; - player.GetCritChance() -= 20; + break; + + case ItemID.SquireAltPants: + player.GetCritChance() -= 5; + player.GetDamage() -= 0.05f; break; case ItemID.HuntressAltShirt: - player.GetDamage() -= 0.15f; - player.GetDamage() -= 0.15f; + player.GetDamage() -= 0.05f; + player.GetDamage() -= 0.05f; break; + case ItemID.HuntressAltPants: player.GetDamage() -= 0.05f; - player.GetCritChance() -= 5; break; case ItemID.ApprenticeAltHead: player.GetDamage() -= 0.05f; player.GetDamage() -= 0.05f; break; + case ItemID.ApprenticeAltShirt: - player.GetDamage() -= 0.1f; + player.GetDamage() -= 0.05f; break; + case ItemID.ApprenticeAltPants: - player.GetDamage() -= 0.1f; - player.GetCritChance() -= 25; + player.GetCritChance() -= 10; break; case ItemID.SolarFlareHelmet: @@ -1140,10 +1122,6 @@ namespace CalamityMod.Items { CalamityPlayer modPlayer = player.Calamity(); - // Obsidian Skull and its upgrades make you immune to On Fire! - if (item.type == ItemID.ObsidianSkull || item.type == ItemID.ObsidianHorseshoe || item.type == ItemID.ObsidianShield || item.type == ItemID.ObsidianWaterWalkingBoots || item.type == ItemID.LavaWaders || item.type == ItemID.ObsidianSkullRose || item.type == ItemID.MoltenCharm || item.type == ItemID.LavaSkull || item.type == ItemID.MoltenSkullRose || item.type == ItemID.AnkhShield) - player.buffImmune[BuffID.OnFire] = true; - // Ankh Shield Mighty Wind immunity. if (item.type == ItemID.AnkhShield) player.buffImmune[BuffID.WindPushed] = true; @@ -1163,17 +1141,6 @@ namespace CalamityMod.Items player.buffImmune[BuffID.OnFire] = true; } - // Reduced Nightwither and Holy Flames damage. - if (item.type == ItemID.MoonStone) - modPlayer.reducedNightwitherDamage = true; - if (item.type == ItemID.SunStone) - modPlayer.reducedDaybrokenDamage = true; - if (item.type == ItemID.CelestialStone || item.type == ItemID.CelestialShell) - { - modPlayer.reducedDaybrokenDamage = true; - modPlayer.reducedNightwitherDamage = true; - } - if (item.type == ItemID.FairyBoots) modPlayer.fairyBoots = true; @@ -1185,18 +1152,18 @@ namespace CalamityMod.Items if (item.type == ItemID.ArcaneFlower) player.GetDamage() += 0.05f; + + if (item.type == ItemID.EyeoftheGolem) + { + player.Calamity().critDamage += 0.15f; + } if (item.type == ItemID.SniperScope) { - player.GetDamage() -= 0.03f; - player.GetCritChance() -= 3; + player.GetDamage() -= 0.1f; //Total 0% damage + player.GetCritChance() += 2; //Total 12% crit + player.Calamity().critDamage += 0.15f; } - if (item.type == ItemID.MagicQuiver) - player.arrowDamage -= 0.05f; - - if (item.type == ItemID.MoltenQuiver) - player.arrowDamage -= 0.03f; - if (item.type == ItemID.FireGauntlet) { player.GetDamage() += 0.02f; @@ -1286,103 +1253,68 @@ namespace CalamityMod.Items player.GetAttackSpeed() -= 0.1f; } - if (item.type == ItemID.TerrasparkBoots) - player.buffImmune[BuffID.OnFire] = true; - - else if (item.type == ItemID.FinWings) // Boosted water abilities, faster fall in water + if (item.type == ItemID.GravityGlobe) { - if (player.IsUnderwater()) - player.gills = true; - player.ignoreWater = true; - player.noFallDmg = true; - if (!player.mount.Active) + player.GetJumpState().Enable(); + if (player.Calamity().justChangedGravity) { - if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) - player.maxFallSpeed = 12f; + player.GetJumpState().Available = true; } + if (player.wingsLogic <= 0 && player.velocity.Y != 0 && player.maxRunSpeed < 8) + { + player.maxRunSpeed = 5f; + } + player.jumpSpeedBoost += 1.6f; + if (player.controlDown) + player.maxFallSpeed *= 1.5f; + else + player.maxFallSpeed *= 1.2f; } - else if (item.type == ItemID.BeeWings) // Honey buff + + if (item.type == ItemID.DemonWings && !player.mount.Active) + player.maxFallSpeed *= 1.3f; + + if (item.type == ItemID.BeeWings && !player.mount.Active && !player.controlDown) { - player.AddBuff(BuffID.Honey, 2); - player.noFallDmg = true; + player.gravity *= 0.6f; + player.maxFallSpeed *= 0.6f; } - else if (item.type == ItemID.ButterflyWings) // Boost to mana regen + + if (item.type == ItemID.FinWings) + player.ignoreWater = true; + + // Spawns ornaments which refreshes flight time upon pickup + else if (item.type == ItemID.FestiveWings) { - player.manaRegen = (int)(player.manaRegen * 1.25f); - player.noFallDmg = true; - } - else if (item.type == ItemID.BatWings) // Greatly increases vision - { - player.noFallDmg = true; - player.nightVision = false; // Does not stack with Night Owl; actual effect is handled in LightingEffectsSystem - } - else if (item.type == ItemID.HarpyWings) - { - player.moveSpeed += 0.1f; - player.noFallDmg = true; - } - else if (item.type == ItemID.FrozenWings) // Increases cold debuff damage - { - player.noFallDmg = true; - player.Calamity().frozenWingsCold = true; - } - else if (item.type == ItemID.FlameWings) // Increases heat debuff damage - { - player.noFallDmg = true; - player.Calamity().flameWingsHeat = true; - } - else if (item.type == ItemID.LeafWings) // Bonus to defensive stats - { - player.noFallDmg = true; - player.statDefense += 10; - player.AddBuff(BuffID.DryadsWard, 2); // Dryad's Blessing - } - else if (item.type == ItemID.FestiveWings) // Drop homing christmas tree bulbs while in flight - { - player.noFallDmg = true; if (modPlayer.wingProjectileCooldown <= 0) { var source = player.GetSource_Accessory(item); - if (player.controlJump && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) + if (player.controlJump && player.jump == 0 && player.velocity.Y != 0f && player.wingTime > 0f && !player.mount.Active && !player.mount.Cart) { - int ornamentDamage = (int)player.GetBestClassDamage().ApplyTo(50); - int p = Projectile.NewProjectile(source, player.Center, Vector2.UnitY * 2f, ProjectileID.OrnamentFriendly, ornamentDamage, 5f, player.whoAmI); + Vector2 ornamentPos = player.Center + Vector2.UnitY.RotatedByRandom(MathHelper.ToRadians(105f)) * Main.rand.NextFloat(-512f, -320f); + + int p = Projectile.NewProjectile(source, ornamentPos, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[p].DamageType = DamageClass.Generic; - Main.projectile[p].Calamity().lineColor = 1; - modPlayer.wingProjectileCooldown = 15; - } + modPlayer.wingProjectileCooldown = 90; } } } - else if (item.type == ItemID.TatteredFairyWings) // Leave a trail of damaging fairy dust while in flight + // Leaves a trail of black fairy dust which reduces flight time to any player that touches it + else if (item.type == ItemID.TatteredFairyWings) { - player.noFallDmg = true; if (modPlayer.wingProjectileCooldown <= 0) { var source = player.GetSource_Accessory(item); - if (player.controlJump && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) + if (player.controlJump && player.jump == 0 && player.velocity.Y != 0f && player.wingTime > 0f && !player.mount.Active && !player.mount.Cart) { - int fairyDustDamage = (int)player.GetBestClassDamage().ApplyTo(35); Vector2 fairyDustVel = Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(0.08f, 0.2f); - int p = Projectile.NewProjectile(source, player.Center, fairyDustVel, ModContent.ProjectileType(), fairyDustDamage, 0f, player.whoAmI); + int p = Projectile.NewProjectile(source, player.Center, fairyDustVel, ProjectileType(), 0, 0f, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) - modPlayer.wingProjectileCooldown = 10; + modPlayer.wingProjectileCooldown = 8; } } } - else if (item.type == ItemID.FishronWings || item.type == ItemID.BetsyWings || item.type == ItemID.Yoraiz0rWings || - item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || item.type == ItemID.LokisWings || - item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || item.type == ItemID.BejeweledValkyrieWing || - item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || item.type == ItemID.WillsWings || - item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings || item.type == ItemID.CreativeWings || - item.type == ItemID.FoodBarbarianWings || item.type == ItemID.GroxTheGreatWings || item.type == ItemID.GhostarsWings || - item.type == ItemID.SafemanWings || item.type == ItemID.RainbowWings || item.type == ItemID.LongRainbowTrailWings) - { - player.noFallDmg = true; - } if (item.type == ItemID.JellyfishNecklace || item.type == ItemID.JellyfishDivingGear || item.type == ItemID.ArcticDivingGear) modPlayer.jellyfishNecklace = true; @@ -1390,9 +1322,6 @@ namespace CalamityMod.Items if (item.type == ItemID.FleshKnuckles || item.type == ItemID.BerserkerGlove || item.type == ItemID.HeroShield) modPlayer.fleshKnuckles = true; - if (item.type == ItemID.WormScarf) - player.endurance -= 0.03f; - if (item.type == ItemID.RoyalGel) modPlayer.royalGel = true; @@ -1408,11 +1337,11 @@ namespace CalamityMod.Items public override void HorizontalWingSpeeds(Item item, Player player, ref float speed, ref float acceleration) { CalamityPlayer modPlayer = player.Calamity(); - float moveSpeedBoost = modPlayer.moveSpeedBonus * 0.1f; + float moveSpeedBoost = modPlayer.moveSpeedBonus * 0.06f; float flightSpeedMult = 1f + (modPlayer.soaring ? SoaringPotion.FlightBoost : 0f) + - (modPlayer.reaverSpeed ? 0.1f : 0f) + + (modPlayer.reaverSpeed ? ReaverHeadMobility.SetBonusFlightBoost : 0f) + moveSpeedBoost; float flightAccMult = 1f + moveSpeedBoost; @@ -1423,28 +1352,59 @@ namespace CalamityMod.Items flightAccMult = MathHelper.Clamp(flightAccMult, 0.5f, 1.5f); acceleration *= flightAccMult; } + + public override void VerticalWingSpeeds(Item item, Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) + { + switch (item.type) + { + case ItemID.AngelWings: + maxAscentMultiplier *= 1.3f; + constantAscend *= 1.5f; + break; + case ItemID.DemonWings: + ascentWhenFalling *= 2f; + ascentWhenRising *= 2f; + maxCanAscendMultiplier *= 2f; + break; + case ItemID.FlameWings: + maxAscentMultiplier *= 1.2f; + constantAscend *= 1.35f; + break; + case ItemID.ButterflyWings: + maxAscentMultiplier *= 0.9f; + constantAscend *= 5f; + break; + case ItemID.GhostWings: + maxAscentMultiplier *= 0.904f; + constantAscend *= 5f; + break; + default: + break; + } + } #endregion #region GrabChanges public override void GrabRange(Item item, Player player, ref int grabRange) { // First, apply the grab range multiplier. - if (grabRangeMultiplier > 1f) - grabRange = (int)(grabRangeMultiplier * grabRange); + if (item.TryGetGlobalItem(out var grabRangeItem) && grabRangeItem.grabRangeMultiplier > 1f) + grabRange = (int)(grabRangeItem.grabRangeMultiplier * grabRange); - // Then, if wearing the appropriate Reaver armor, add 246 flat item grab range. (2.625 + 15.375 = 18 tiles) - // For reference, Treasure Magnet adds 150 (2.625 + 9.375 = 12 tiles) + // Then, apply flat grab range boosts. if (player.Calamity().reaverExplore) - grabRange += 246; + grabRange += ReaverHeadExplore.SetBonusGrabRangeBoost; + if (player.Calamity().victideSnailSet) + grabRange += VictideHeadSnail.SetBonusGrabRangeBoost; - // Nebula boosters have greater pickup range while using Nebula Mantle. - if (player.wingsLogic == (int)VanillaWingID.WingsNebula && ItemID.Sets.NebulaPickup[item.type]) - grabRange *= 2; + // Nebula boosters have greater pickup range while hovering with Nebula Mantle. + if (player.wingsLogic == (int)VanillaWingID.WingsNebula && player.wingTime > 0f && player.controlJump && player.TryingToHoverDown && ItemID.Sets.NebulaPickup[item.type]) + grabRange *= 3; } #endregion #region Ammo - public override bool CanConsumeAmmo(Item weapon, Item ammo, Player player) => Main.rand.NextFloat() <= player.Calamity().rangedAmmoCost; + public override bool CanConsumeAmmo(Item weapon, Item ammo, Player player) => Main.rand.NextFloat() <= player.Calamity().ammoCost; public static bool HasEnoughAmmo(Player player, Item item, int ammoConsumed) { @@ -1517,7 +1477,7 @@ namespace CalamityMod.Items dontConsumeAmmo = true; if (player.ammoCost75 && Main.rand.NextBool(4)) dontConsumeAmmo = true; - if (Main.rand.NextFloat() > player.Calamity().rangedAmmoCost) + if (Main.rand.NextFloat() > player.Calamity().ammoCost) dontConsumeAmmo = true; if (!dontConsumeAmmo && itemAmmo.consumable) @@ -1535,7 +1495,7 @@ namespace CalamityMod.Items #region PostUpdate public override void PostUpdate(Item item) { - if (ItemsForcedInsideWorldList.Includes(item.type)) + if (CalamityItemSets.ItemForcedInsideWorld[item.type]) CalamityUtils.ForceItemIntoWorld(item); } #endregion @@ -1554,12 +1514,12 @@ namespace CalamityMod.Items Texture2D itemTexture = TextureAssets.Item[item.type].Value; Rectangle itemFrame = (Main.itemAnimations[item.type] == null) ? itemTexture.Frame() : Main.itemAnimations[item.type].GetFrame(itemTexture); - if (!EnchantmentManager.ItemUpgradeRelationship.ContainsKey(item.type) || !Main.LocalPlayer.InventoryHas(ModContent.ItemType())) + if (!EnchantmentManager.ItemUpgradeRelationship.ContainsKey(item.type) || !Main.LocalPlayer.InventoryHas(ItemType())) return true; // Draw all particles. float currentPower = 0f; - int calamitasNPCIndex = NPC.FindFirstNPC(ModContent.NPCType()); + int calamitasNPCIndex = NPC.FindFirstNPC(NPCType()); if (calamitasNPCIndex != -1) currentPower = Utils.GetLerpValue(11750f, 1000f, Main.LocalPlayer.Distance(Main.npc[calamitasNPCIndex].Center), true); @@ -1577,85 +1537,26 @@ namespace CalamityMod.Items private static int cachedForgeID = -1; public override void OnCreated(Item item, ItemCreationContext context) { - // ChoosePrefix also happens on craft so go reset it here too - storedPrefix = -1; - // 05JUL2024: Ozzatron: Register the usage of Draedon's Forge for the purposes of his dialogue. // This was moved out of an On edit in the DraedonsForge item for Magic Storage compatibility. Player p = Main.LocalPlayer; if (cachedForgeID < 0) - cachedForgeID = ModContent.TileType(); + cachedForgeID = TileType(); if (context is RecipeItemCreationContext && p.adjTile[cachedForgeID]) p.Calamity().HasCraftedDraedonsForge = true; } #endregion - #region Reforge Mechanic Rework - private static int storedPrefix = -1; - public override void PreReforge(Item item) - { - StealthStrikePrefixBonus = 0f; - storedPrefix = item.prefix; - } - - // Ozzatron 31AUG2022: total rework to the reforge rework for mod compatibility - // you can now disable the rework with config in case it isn't enough to solve your conflicts - // removed data saved on items; reforging is now a coalescing flowchart that has no RNG - public override int ChoosePrefix(Item item, UnifiedRandom rand) - { - if (storedPrefix == -1 && item.CountsAsClass() && (item.maxStack == 1 || item.AllowReforgeForStackableItem)) - { - // Crafting (or first reforge of) a rogue weapon has a 75% chance for a random modifier, this check is done by vanilla - // Negative modifiers have a 66.66% chance of being voided, Annoying modifier is intentionally ignored by vanilla - int prefix = CalamityUtils.RandomRoguePrefix(); - bool keepPrefix = !CalamityUtils.NegativeRoguePrefix(prefix) || Main.rand.NextBool(3); - return keepPrefix ? prefix : 0; - } - - if (!CalamityServerConfig.Instance.RemoveReforgeRNG || Main.gameMenu || storedPrefix == -1) - return -1; - - // Pick a prefix using the new system. - return CalamityUtils.GetReworkedReforge(item, rand, storedPrefix); - } - - public override void PostReforge(Item item) - { - storedPrefix = -1; - // Bandit steals 20% of the total price of the reforge if she's around. - if (NPC.AnyNPCs(ModContent.NPCType())) - { - // Calculate the item's reforge cost. - int value = item.value; - Player p = Main.LocalPlayer; - ItemLoader.ReforgePrice(item, ref value, ref p.discountAvailable); - - // Steal 20% of that money. - int stolen = value / 5; - CalamityWorld.MoneyStolenByBandit += stolen; - - // Increment the reforge counter to allow the Bandit to refund - // Also triggers Tinkerer dialogue that hints to the player that money is being stolen - CalamityWorld.Reforges++; - - if (Main.netMode == NetmodeID.MultiplayerClient) - { - BanditStolenMoneySyncPacket.Send(stolen); - } - } - } - #endregion - #region Rarity Price Table // Base numeric rarity pricing guide. private static readonly int Rarity0BuyPrice = Item.buyPrice(0, 0, 50, 0); private static readonly int Rarity1BuyPrice = Item.buyPrice(0, 1, 0, 0); private static readonly int Rarity2BuyPrice = Item.buyPrice(0, 2, 0, 0); - private static readonly int Rarity3BuyPrice = Item.buyPrice(0, 4, 0, 0); - private static readonly int Rarity4BuyPrice = Item.buyPrice(0, 12, 0, 0); - private static readonly int Rarity5BuyPrice = Item.buyPrice(0, 24, 0, 0); - private static readonly int Rarity6BuyPrice = Item.buyPrice(0, 36, 0, 0); - private static readonly int Rarity7BuyPrice = Item.buyPrice(0, 48, 0, 0); + private static readonly int Rarity3BuyPrice = Item.buyPrice(0, 5, 0, 0); + private static readonly int Rarity4BuyPrice = Item.buyPrice(0, 10, 0, 0); + private static readonly int Rarity5BuyPrice = Item.buyPrice(0, 20, 0, 0); + private static readonly int Rarity6BuyPrice = Item.buyPrice(0, 35, 0, 0); + private static readonly int Rarity7BuyPrice = Item.buyPrice(0, 45, 0, 0); private static readonly int Rarity8BuyPrice = Item.buyPrice(0, 60, 0, 0); private static readonly int Rarity9BuyPrice = Item.buyPrice(0, 80, 0, 0); private static readonly int Rarity10BuyPrice = Item.buyPrice(1, 0, 0, 0); // Highest raw rarity used by vanilla items (ML drops) @@ -1725,17 +1626,17 @@ namespace CalamityMod.Items return RarityBuyPriceArray[rarity]; // Calamity rarities aren't guaranteed to have the monotonic IDs, so they're handled directly. - if (rarity == ModContent.RarityType()) + if (rarity == RarityType()) return RarityTurquoiseBuyPrice; - if (rarity == ModContent.RarityType()) + if (rarity == RarityType()) return RarityPureGreenBuyPrice; - if (rarity == ModContent.RarityType()) + if (rarity == RarityType()) return RarityDarkBlueBuyPrice; - if (rarity == ModContent.RarityType()) + if (rarity == RarityType()) return RarityVioletBuyPrice; - if (rarity == ModContent.RarityType()) + if (rarity == RarityType()) return RarityHotPinkBuyPrice; - if (rarity == ModContent.RarityType()) + if (rarity == RarityType()) return RarityCalamityRedBuyPrice; // Return 0 if it's not a progression based or other mod's rarity diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index ae6727df34..0d8d83a5e4 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; using CalamityMod.Enums; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Fishing; using CalamityMod.Items.Materials; using CalamityMod.Items.PermanentBoosters; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Items.Potions; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; @@ -31,17 +30,17 @@ namespace CalamityMod.Items { #region Boss Treasure Bags case ItemID.KingSlimeBossBag: - loot.DefineConditionalDropSet(DropHelper.NotRemix).Add(ItemID.Katana, 3); // 33% Katana - loot.DefineConditionalDropSet(DropHelper.Remix).Add(ItemID.Keybrand, 3); // 33% Keybrand in Remix + loot.DefineConditionalDropSet(DropHelper.NotRemix).Add(ItemID.Katana, DropHelper.BagWeaponDropRateInt); // 33% Katana + loot.DefineConditionalDropSet(DropHelper.Remix).Add(ItemID.Keybrand, DropHelper.BagWeaponDropRateInt); // 33% Keybrand in Remix - loot.Add(new CommonDrop(ModContent.ItemType(), 10)); // 10% Crown Jewel + loot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); // 33% Crown Jewel loot.AddRevBagAccessories(); loot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); break; case ItemID.EyeOfCthulhuBossBag: - loot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateInt); // 33% Deathstare Rod - loot.Add(ModContent.ItemType(), 10); // 10% Teardrop Cleaver + loot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); // 33% Deathstare Rod + loot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); // 33% Teardrop Cleaver loot.AddRevBagAccessories(); loot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); break; @@ -51,8 +50,8 @@ namespace CalamityMod.Items // We don't care. case ItemID.EaterOfWorldsBossBag: var eowRevLCR = loot.DefineConditionalDropSet(DropHelper.If(() => CalamityWorld.revenge)); - eowRevLCR.Add(ItemID.DemoniteOre, 1, 90, 135); // 100% 90-135 Demonite Ore - eowRevLCR.Add(ItemID.ShadowScale, 1, 35, 55); // 100% 35-55 Shadow Scale + eowRevLCR.Add(ItemID.DemoniteOre, 1, 70, 90); // 100% 70-90 Demonite Ore + eowRevLCR.Add(ItemID.ShadowScale, 1, 20, 30); // 100% 20-30 Shadow Scale loot.AddRevBagAccessories(); loot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); break; @@ -62,11 +61,9 @@ namespace CalamityMod.Items // This can theoretically be exploited by killing the boss on Expert, then turning on Rev to open the bags. // We don't care. case ItemID.BrainOfCthulhuBossBag: - // BoC drops less partial loot than EoW - // However, sell price is overall higher despite the lower yield var bocRevLCR = loot.DefineConditionalDropSet(DropHelper.If(() => CalamityWorld.revenge)); - bocRevLCR.Add(ItemID.CrimtaneOre, 1, 80, 120); // 100% 80-120 Crimtane Ore - bocRevLCR.Add(ItemID.TissueSample, 1, 25, 40); // 100% 25-40 Tissue Sample + bocRevLCR.Add(ItemID.CrimtaneOre, 1, 70, 90); // 100% 70-90 Crimtane Ore + bocRevLCR.Add(ItemID.TissueSample, 1, 20, 30); // 100% 20-30 Tissue Sample loot.AddRevBagAccessories(); loot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); break; @@ -95,7 +92,7 @@ namespace CalamityMod.Items ModContent.ItemType(), }; loot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, queenBeeWeapons)); - loot.Add(ModContent.ItemType(), 10); // 10% The Bee + loot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); // 33% The Bee loot.Add(ItemID.Stinger, 1, 8, 12); // 100% 8-12 Stinger loot.AddRevBagAccessories(); loot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -107,6 +104,7 @@ namespace CalamityMod.Items int[] wofWeapons = new int[] { ItemID.BreakerBlade, + ModContent.ItemType(), ItemID.ClockworkAssaultRifle, ModContent.ItemType(), ItemID.LaserRifle, @@ -115,7 +113,6 @@ namespace CalamityMod.Items ModContent.ItemType() }; loot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, wofWeapons)); - loot.Add(ModContent.ItemType(), 10); // 10% Carnage int[] emblems = new int[] { @@ -147,7 +144,6 @@ namespace CalamityMod.Items case ItemID.TwinsBossBag: loot.Remove(FindHallowedBars(loot)); loot.AddIf(DropHelper.HallowedBarsCondition, ItemID.HallowedBar, 1, 20, 35); - loot.Add(ModContent.ItemType(), 10); // 10% Arbalest loot.AddRevBagAccessories(); loot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); break; @@ -174,7 +170,7 @@ namespace CalamityMod.Items loot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, planteraWeapons)); loot.Add(ModContent.ItemType(), 10); // 10% Blossom Flux loot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); - loot.Add(ModContent.ItemType(), 1, 30, 35); + loot.Add(ModContent.ItemType(), 1, 40, 50); loot.AddRevBagAccessories(); loot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); break; @@ -236,7 +232,6 @@ namespace CalamityMod.Items ItemID.FairyQueenRangedItem, // Eventide ItemID.FairyQueenMagicItem, // Nightglow ItemID.SparkleGuitar, // Stellar Tune - ItemID.EmpressBlade, // Terraprisma ItemID.RainbowWhip, // Kaleidoscope ItemID.RainbowWings, // Empress Wings have a pathetically low drop rate. }; @@ -282,23 +277,34 @@ namespace CalamityMod.Items loot.AddHardmodeOresToCrates(HardmodeCrateType.Mythril); break; - // Non-crafted underground Gold Chest loot @ 20%; Individually 5% case ItemID.GoldenCrate: - loot.Add(new OneFromOptionsNotScaledWithLuckDropRule(5, 1, - ItemID.FlareGun, - ItemID.Mace, - ItemID.BandofRegeneration, - ItemID.ShoeSpikes)); // Climbing Claws is in Wooden/Pearlwood (vanilla) in case you're curious + RemoveBaitFromGoldenCrates(loot); + loot.Add(NewGoldenCrateBaitRule); + loot.Add(UndergroundChestLootRule); break; case ItemID.GoldenCrateHard: RemoveHardmodeOresFromStandardCrates(loot); loot.AddHardmodeOresToCrates(HardmodeCrateType.Titanium); - loot.Add(new OneFromOptionsNotScaledWithLuckDropRule(5, 1, - ItemID.FlareGun, - ItemID.Mace, - ItemID.BandofRegeneration, - ItemID.ShoeSpikes)); + RemoveBaitFromGoldenCrates(loot); + loot.Add(NewGoldenCrateBaitRule); + loot.Add(UndergroundChestLootRule); + break; + + // 2-5 Essences of Eleum @ 50% + // This is our equivalent to Souls of Light/Night + case ItemID.FrozenCrateHard: + RemoveHardmodeOresFromBiomeCrates(loot); + loot.AddHardmodeOresToCrates(HardmodeCrateType.Biome); + loot.Add(ModContent.ItemType(), 2, 2, 5); + break; + + // 2-5 Essences of Sunlight @ 50% + // This is our equivalent to Souls of Light/Night + case ItemID.FloatingIslandFishingCrateHard: + RemoveHardmodeOresFromBiomeCrates(loot); + loot.AddHardmodeOresToCrates(HardmodeCrateType.Biome); + loot.Add(ModContent.ItemType(), 2, 2, 5); break; case ItemID.CorruptFishingCrateHard: @@ -306,8 +312,6 @@ namespace CalamityMod.Items case ItemID.HallowedFishingCrateHard: case ItemID.DungeonFishingCrateHard: case ItemID.JungleFishingCrateHard: - case ItemID.FloatingIslandFishingCrateHard: - case ItemID.FrozenCrateHard: case ItemID.LavaCrateHard: case ItemID.OasisCrateHard: case ItemID.OceanCrateHard: @@ -541,6 +545,34 @@ namespace CalamityMod.Items } } } + + private static void RemoveBaitFromGoldenCrates(ItemLoot loot) + { + List rules = loot.Get(false); + IItemDropRule toRemove = null; + + foreach (IItemDropRule rule in rules) + if (rule is CommonDrop c && c.itemId == ItemID.MasterBait) + toRemove = c; + + if (toRemove is not null) + loot.Remove(toRemove); + } + + // Replaced bait rules for Golden/Titanium Crates + // Vanilla: 3-7 Master Bait @ 66.67% + // Calamity: 3-7 Master Bait @ 33.33% OR 3-7 Grand Marquis Bait @ 16.67% + private static IItemDropRule NewGoldenCrateBaitRule => ItemDropRule.SequentialRulesNotScalingWithLuck(2, + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 3, 3, 7), + ItemDropRule.NotScalingWithLuck(ItemID.MasterBait, 1, 3, 7)); + + // Non-crafted underground Gold Chest loot for Golden/Titanium Crates @ 25%; Individually 5% + private static IItemDropRule UndergroundChestLootRule => new OneFromOptionsNotScaledWithLuckDropRule(4, 1, + ItemID.FlareGun, + ItemID.Mace, + ItemID.BandofRegeneration, + ItemID.ShoeSpikes, + ModContent.ItemType()); // Climbing Claws is in Wooden/Pearlwood (vanilla) in case you're curious #endregion #region Goodie Bag Bat Hook diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 298f055625..388bec75f7 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using CalamityMod.Balancing; +using CalamityMod.ChatTags; using CalamityMod.CustomRecipes; +using CalamityMod.DataStructures; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.Demonshade; -using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Tools; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Magic; @@ -15,16 +17,18 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Prefixes; +using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; using Terraria; using Terraria.DataStructures; +using Terraria.GameInput; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.UI.Chat; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Items { @@ -143,23 +147,16 @@ namespace CalamityMod.Items // Modify all vanilla tooltips before appending mod mechanics (if any). ModifyVanillaTooltips(item, tooltips); - // Adds "Does extra damage to enemies shot at point-blank range" to weapons capable of it. - if (canFirePointBlankShots) - { - LocalizedText lineText = CalamityUtils.GetText("Misc.PointBlank"); - TooltipLine line = new TooltipLine(Mod, "CalamityMod:PointBlankTooltip", lineText.Value); - tooltips.Insert(++lastTooltipIndex, line); - } - // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the tooltip list. EnchantmentTooltips(item, tooltips); + WhipAutomaticTooltips(item, tooltips, ref lastTooltipIndex); // In GFB, replace all instances of "rogue" with "rouge". - string[] rogueKey = new string[] { CalamityUtils.GetTextValue($"Misc.GFBRogueUppercase"), CalamityUtils.GetTextValue($"Misc.GFBRogueLowercase") }; - string[] rougeKey = new string[] { CalamityUtils.GetTextValue($"Misc.GFBRougeUppercase"), CalamityUtils.GetTextValue($"Misc.GFBRougeLowercase") }; + string[] rogueKey = [CalamityUtils.GetTextValue($"Misc.GFBRogueUppercase"), CalamityUtils.GetTextValue($"Misc.GFBRogueLowercase")]; + string[] rougeKey = [CalamityUtils.GetTextValue($"Misc.GFBRougeUppercase"), CalamityUtils.GetTextValue($"Misc.GFBRougeLowercase")]; for (int n = 0; n < rogueKey.Length; n++) { - if (Main.zenithWorld && rogueKey[n]!="") + if (Main.zenithWorld && rogueKey[n] != "") { tooltips.FindAndReplace(rogueKey[n], rougeKey[n]); } @@ -185,7 +182,7 @@ namespace CalamityMod.Items // Original code lifted from Iban's extended armor tooltips. if (item.ModItem is IHoldShiftTooltipItem holdShiftItem) { - bool holdingShift = Main.keyState.IsKeyDown(Keys.LeftShift); + bool holdingShift = Main.keyState.PressingShift(); // If holding SHIFT, actually display the extended tooltip. if (holdingShift && firstTooltipIndex != -1) @@ -280,20 +277,88 @@ namespace CalamityMod.Items TooltipLine donorLine = new TooltipLine(Mod, "CalamityMod:DonorItem", coloredText); tooltips.Insert(++difficultyTooltipIndex, donorLine); } + + var buffIdsInTooltip = new HashSet(); + + foreach (var tooltip in tooltips) + { + // Parse the tags of each line of text to find our buff tags' + // snippets (since they store the buff IDs). + var snippets = ChatManager.ParseMessage(tooltip.Text, Color.White); + foreach (var snippet in snippets) + { + if (snippet is CalamityBuffTagHandler.Snippet buffSnippet) + { + buffIdsInTooltip.Add(buffSnippet.BuffId); + } + } + } + + if (buffIdsInTooltip.Count > 0) + { + bool showTheTip = false; + bool foundDebuff = false; + foreach (int buffId in buffIdsInTooltip) + { + string tooltipKey = ""; + if (buffId < BuffID.Count) + { + tooltipKey = $"Mods.Terraria.Buffs.{BuffID.Search.GetName(buffId)}.ItemTooltip"; + } + else + { + var modBuff = BuffLoader.GetBuff(buffId); + tooltipKey = $"Mods.{modBuff.Mod.Name}.Buffs.{modBuff.Name}.ItemTooltip"; + } + + if (!Language.Exists(tooltipKey)) + { + continue; + } + + var text = Language.GetTextValue(tooltipKey); + if (string.IsNullOrWhiteSpace(text)) + { + continue; + } + + foundDebuff = true; + if (!PlayerInput.Triggers.Current.SmartCursor) + { + showTheTip = true; + break; + } + + tooltips.Insert(++lastTooltipIndex, new TooltipLine(Mod, "CalamityMod:AltExpandTooltip" + buffId, $"[cbuff:{buffId}]\n{text}")); + } + + if (showTheTip) + { + var str = PlayerInput.CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus["SmartCursor"].First().ToString(); + tooltips.Insert(++lastTooltipIndex, (new TooltipLine(Mod, "CalamityMod:AltExpandTooltip", CalamityUtils.GetTextValue("Misc.AltExpand").Replace("{0}", str)))); + tooltips[lastTooltipIndex].OverrideColor = new Color(170, 170, 170); + } + else if (foundDebuff) + { + foreach (var item1 in tooltips) + { + if (item1.Name.Contains("Tooltip") && !item1.Name.Contains("AltExpandTooltip")) + item1.Hide(); + } + } + } } #endregion #region Rarity Coloration private static void ApplyRarityColor(Item item, TooltipLine nameLine) { - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = Color.Lerp(Color.Red, Color.White, (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) + if (item.type == ModContent.ItemType()) nameLine.OverrideColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); // Developer items - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(Main.DiscoR, 100, 255); + if (item.type == ModContent.ItemType()) + nameLine.OverrideColor = new Color(249, 197, 255); if (item.type == ModContent.ItemType()) nameLine.OverrideColor = new Color(0, 0, 255); if (item.type == ModContent.ItemType()) @@ -302,8 +367,8 @@ namespace CalamityMod.Items nameLine.OverrideColor = new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); if (item.type == ModContent.ItemType()) nameLine.OverrideColor = ShatteredCommunity.GetRarityColor(); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(132, 37, 147), new Color(0, 255, 0), 5f); //alternates purple and neon green + if (item.type == ModContent.ItemType()) + nameLine.OverrideColor = ShatteredCommunity.GetRarityColor(); if (item.type == ModContent.ItemType()) nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(255, 166, 0), new Color(25, 250, 25), 6f); //alternates between emerald green and amber (BanditHueh) if (item.type == ModContent.ItemType()) @@ -411,6 +476,47 @@ namespace CalamityMod.Items } #endregion + #region Whip Tooltips + private void WhipAutomaticTooltips(Item item, IList tooltips, ref int lastTooltipIndex) + { + // Multiplicative tag changes + string FlatTagTooltip(int dmg) => (CalamityUtils.GetText($"Common.SummonTagDamageFlat").Format(dmg.ToString())); + string MultTagTooltip(float mult) => (CalamityUtils.GetText($"Common.SummonTagDamageMult").Format((mult + 1).ToString("0.##"))); + string CritTagTooltip(float crit) => (CalamityUtils.GetText($"Common.SummonTagCrit").Format((crit * 100).ToString("0.#"))); + + Dictionary TagByItem = new(); + foreach (SummonTag tag1 in CalamityBuffSets.SummonTagDebuff.Values) + { + if (tag1.TagItem > -1) TagByItem.Add(tag1.TagItem, tag1); + } + if (TagByItem.TryGetValue(item.type, out SummonTag tag)) + { + if (!tag.AutoDrawTooltip) return; + var modPlayer = Main.LocalPlayer.Calamity(); + if (tag.FlatTagDamage != 0) + { + TooltipLine line = new TooltipLine(Mod, "CalamityMod:FlatSummonTag", FlatTagTooltip(tag.FlatTagDamage)); + tooltips.Insert(++lastTooltipIndex, line); + } + if (!modPlayer.forceSummonTagCrit && (tag.MultiplicativeTagDamage != 0 || (modPlayer.forceSummonTagMultiplicative && tag.TagCritChance != 0))) + { + TooltipLine line = new TooltipLine(Mod, "CalamityMod:MultiplicativeSummonTag", MultTagTooltip(tag.MultiplicativeTagDamage + (modPlayer.forceSummonTagMultiplicative ? tag.TagCritChance : 0))); + tooltips.Insert(++lastTooltipIndex, line); + } + if (!modPlayer.forceSummonTagMultiplicative && (tag.TagCritChance != 0 || (modPlayer.forceSummonTagCrit && tag.MultiplicativeTagDamage != 0))) + { + TooltipLine line = new TooltipLine(Mod, "CalamityMod:CritSummonTag", CritTagTooltip(tag.TagCritChance + (modPlayer.forceSummonTagCrit ? tag.MultiplicativeTagDamage : 0))); + tooltips.Insert(++lastTooltipIndex, line); + } + if (modPlayer.forceSummonTagMultiplicative && modPlayer.forceSummonTagCrit) //when both tag and crit are forced, swaps between the two + { + TooltipLine line = new TooltipLine(Mod, "CalamityMod:CritSummonTag", ((int)(Main.GlobalTimeWrappedHourly / 5) % 2 == 0 ? CritTagTooltip(tag.MultiplicativeTagDamage + tag.TagCritChance) : MultTagTooltip(tag.MultiplicativeTagDamage + tag.TagCritChance))); + tooltips.Insert(++lastTooltipIndex, line); + } + } + } + #endregion + #region Vanilla Item Tooltip Modification private static void ModifyVanillaTooltips(Item item, IList tooltips) { @@ -456,7 +562,7 @@ namespace CalamityMod.Items LocalizedText GetAddedTooltip(string key) => CalamityUtils.GetText($"Vanilla.AddedTooltip.{key}"); #endregion - // Exact life regen descriptions + // Applies to various item categories to clarify exact regen effects #region Life Regen Clarity Tooltips bool isCampfire = item.type == ItemID.Campfire || item.type == ItemID.CursedCampfire || item.type == ItemID.DemonCampfire || item.type == ItemID.FrozenCampfire || item.type == ItemID.IchorCampfire || item.type == ItemID.RainbowCampfire || item.type == ItemID.UltraBrightCampfire || item.type == ItemID.BoneCampfire || item.type == ItemID.DesertCampfire || item.type == ItemID.CoralCampfire || item.type == ItemID.CorruptCampfire || item.type == ItemID.CrimsonCampfire || item.type == ItemID.HallowedCampfire || item.type == ItemID.JungleCampfire || item.type == ItemID.MushroomCampfire || item.type == ItemID.ShimmerCampfire; if (isCampfire) @@ -486,93 +592,50 @@ namespace CalamityMod.Items if (item.type == ItemID.HamBat) EditTooltipByNum(1, (line) => line.Text = EditedTooltip("HamBat")); - if (item.type == ItemID.AegisCrystal) + if (item.type == ItemID.AegisCrystal) // Vital Crystal EditTooltipByNum(0, (line) => line.Text = EditedTooltip("AegisCrystal")); + + if (item.type == ItemID.SquireGreatHelm) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireGreatHelm")); + + if (item.type == ItemID.SquireAltShirt) // Valhalla Knight's Breastplate + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireAltShirt")); + + if (item.type == ItemID.SolarFlareHelmet || item.type == ItemID.SolarFlareBreastplate || item.type == ItemID.SolarFlareLeggings) + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("SolarFlarePieces")); #endregion - // Numerous random tooltip edits which don't fit into another category - #region Various Tooltip Edits + // Applies to various item categories which carry their light/breath effects into the Abyss + #region Abyss Light/Breath + // +1 to Abyss light level + if (item.type == ItemID.JellyfishNecklace || + item.type == ItemID.MiningHelmet || item.type == ItemID.UltrabrightHelmet) + EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssGlow")); + if (item.type == ItemID.JellyfishDivingGear) + EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssGlow")); - // Lilies of Finality 512 edit - if (item.type == ModContent.ItemType()) - EditTooltipByName("Damage", (line) => line.Text = LiliesOfFinality.TheNumber + Language.GetTextValue("LegacyTooltip.53")); + // +2 to Abyss light level + if (item.type == ItemID.ShinePotion) + EditTooltipByName("BuffTime", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssGlow")); - // Apparently 612 is a homestuck reference - if (item.type == ModContent.ItemType()) - EditTooltipByName("AxePower", (line) => line.Text = line.Text.Replace("610%", "612%")); + // Moderate breath boost + if (item.type == ItemID.DivingHelmet) + EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel2")); + if (item.type == ItemID.ArcticDivingGear) + EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel1") + "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel2")); - // Master Mode items also drop in Revengeance - // Only affects vanilla and Calamity items - if (item.master && (item.type < ItemID.Count || item.ModItem?.Mod is CalamityMod)) - EditTooltipByName("Master", (line) => line.Text = EditedTooltip("MasterExclusive")); + // Great breath boost + if (item.type == ItemID.GillsPotion) + EditTooltipByName("BuffTime", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel3")); - // Add a tooltip about Slimed's effects - if (item.type == ItemID.SlimeGun) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("SlimeGun")); - // Replace the meme tooltip with a useful one. - if (item.type == ItemID.GelBalloon) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("GelBalloon")); - - // Flesh Knuckles giving extra max life. - if (item.type == ItemID.FleshKnuckles || item.type == ItemID.HeroShield || item.type == ItemID.BerserkerGlove) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("FleshKnucklesLine")); - - // Rod of Discord cannot be used multiple times to hurt yourself - if (item.type == ItemID.RodofDiscord) - EditTooltipByNum(1, (line) => line.Text += AddedTooltip("RodofDiscord")); - - // Indicate that the Ankh Shield provides sandstorm wind push immunity - if (item.type == ItemID.AnkhShield) - { - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("AnkhShield1")); - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("AnkhShield2")); - } - - // If Early Hardmode Rework is enabled: Remind users that ores will NOT spawn when an altar is smashed. - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && (item.type == ItemID.Pwnhammer || item.type == ItemID.Hammush)) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("Pwnhammer")); - - // Warmth Potion reduces debuff durations - if (item.type == ItemID.WarmthPotion) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("WarmthPotion")); - - // Nerfed Archery Potion tooltip - if (item.type == ItemID.ArcheryPotion) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ArcheryPotion")); - - // Buffed Ironskin Potion tooltip - if (item.type == ItemID.IronskinPotion) - EditTooltipByNum(0, (line) => line.Text = GetEditedTooltip("IronskinPotion").Format(CalamityUtils.GetScalingDefense(-1))); - - // Nerfed Swiftness Potion tooltip - if (item.type == ItemID.SwiftnessPotion) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); - - // Hand Warmer has a side bonus with Snow armor - if (item.type == ItemID.HandWarmer) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("HandWarmer")); - - // Golden Fishing Rod inherently contains High Test Fishing Line - if (item.type == ItemID.GoldenFishingRod) - EditTooltipByName("NeedsBait", (line) => line.Text += AddedTooltip("GoldenFishingRod")); - - // Information about graveyards - // 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 += AddedTooltip("Tombstones")); - - // Modify item speed tooltips to use a new scale designed to more accurately reflect practical distributions of item speeds. - // Due to the higher complexity of the action, the actual logic is delegated to its own method. - // I think this fits the miscellaneous category? Not seeing anything like this elsewhere. - Tomat - EditTooltipByName("Speed", (line) => RedistributeSpeedTooltips(item, line)); - - if (item.healLife > 0 && Main.LocalPlayer.Calamity().healingPotionMultiplier != 1f) - EditTooltipByName("HealLife", (line) => line.Text = Language.GetOrRegister("CommonItemTooltip.RestoresLife").Format((int)(item.healLife * Main.LocalPlayer.Calamity().healingPotionMultiplier))); + if (item.type == ItemID.NeptunesShell || item.type == ItemID.MoonShell) + EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel3")); + if (item.type == ItemID.CelestialShell) + EditTooltipByNum(4, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel3")); #endregion - // For boss summon item clarity - #region Boss Summon Clarity Tooltips + // Spawn, despawn, and enrage conditions + Non-consumable line + #region Boss Summons if (item.type == ItemID.Abeemination) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("Abeemination")); @@ -611,220 +674,190 @@ namespace CalamityMod.Items if (item.type == ItemID.WormFood) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("WormFood")); + + if (item.type == ItemID.SlimeCrown || item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.WormFood || item.type == ItemID.BloodySpine || item.type == ItemID.Abeemination || item.type == ItemID.DeerThing + || item.type == ItemID.QueenSlimeCrystal || item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalWorm || item.type == ItemID.MechanicalSkull || item.type == ItemID.CelestialSigil) + EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.NotConsumable")); #endregion + // Whip tag is dynamically generated for all whips based on the SummonTagDebuffDict, so we'll remove the vanilla tag tootlips. + #region Whip Tag removal + // Additive tag changes + if (item.type == ItemID.BlandWhip) + EditTooltipByNum(0, (line) => line.Text = string.Empty); + if (item.type == ItemID.ThornWhip) + EditTooltipByNum(0, (line) => line.Text = string.Empty); + if (item.type == ItemID.BoneWhip) + EditTooltipByNum(0, (line) => line.Text = string.Empty); + if (item.type == ItemID.CoolWhip) + EditTooltipByNum(0, (line) => line.Text = string.Empty); + if (item.type == ItemID.SwordWhip) + EditTooltipByNum(0, (line) => line.Text = string.Empty); + if (item.type == ItemID.MaceWhip) + { + EditTooltipByNum(0, (line) => line.Text = string.Empty); + EditTooltipByNum(1, (line) => line.Text = string.Empty); + } + if (item.type == ItemID.RainbowWhip) + { + EditTooltipByNum(0, (line) => line.Text = string.Empty); + EditTooltipByNum(1, (line) => line.Text = string.Empty); + } + #endregion + + #region Accessories // Brain of Confusion, Black Belt and Master Ninja Gear have guaranteed dodges with a fixed cooldown. - #region Guaranteed Dodge Tooltips if (item.type == ItemID.BlackBelt) EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BeltDodgeCooldownMin / 60, BalancingConstants.BeltDodgeCooldownMax / 60)); if (item.type == ItemID.MasterNinjaGear) EditTooltipByNum(1, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BeltDodgeCooldownMin / 60, BalancingConstants.BeltDodgeCooldownMax / 60)); - if (item.type == ItemID.BrainOfConfusion) EditTooltipByNum(0, (line) => line.Text = CalamityUtils.GetText("Vanilla.DodgeInfo").Format(BalancingConstants.BrainDodgeCooldownMin / 60, BalancingConstants.BrainDodgeCooldownMax / 60)); - #endregion - - // Weapon changes - #region Weapon changes - // Aerial Bane is no longer the real bane of aerial enemies (50% dmg bonus removed) - if (item.type == ItemID.DD2BetsyBow) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("DD2BetsyBow")); - - // Death Sickle inflict Whispering Death - if (item.type == ItemID.DeathSickle) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("DeathSickle")); - #endregion - - // Light pets, accessories, and other items which boost the player's Abyss light stat - #region Abyss Light Tooltips - // +1 to Abyss light level - if (item.type == ItemID.CrimsonHeart || item.type == ItemID.ShadowOrb || item.type == ItemID.MagicLantern || item.type == ItemID.JellyfishNecklace || - item.type == ItemID.MiningHelmet || item.type == ItemID.UltrabrightHelmet) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel1")); - if (item.type == ItemID.JellyfishDivingGear || item.type == ItemID.Magiluminescence) - EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel1")); - - // +2 to Abyss light level - if (item.type == ItemID.ShinePotion) - EditTooltipByName("BuffTime", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel2")); - if (item.type == ItemID.FairyBell || item.type == ItemID.DD2PetGhost) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel2")); - - // +3 to Abyss light level - if (item.type == ItemID.WispinaBottle || item.type == ItemID.PumpkingPetItem || item.type == ItemID.GolemPetItem || item.type == ItemID.FairyQueenPetItem) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel3")); - if (item.type == ItemID.SuspiciousLookingTentacle) - EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel3")); - #endregion - - // Accessories and other items which boost the player's ability to breathe in the Abyss - #region Abyss Breath Tooltips - - // Moderate breath boost - if (item.type == ItemID.DivingHelmet) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel2")); - if (item.type == ItemID.ArcticDivingGear) - EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssLightLevel1") + "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel2")); - - // Great breath boost - if (item.type == ItemID.GillsPotion) - EditTooltipByName("BuffTime", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel3")); - - if (item.type == ItemID.NeptunesShell || item.type == ItemID.MoonShell) - EditTooltipByNum(1, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel3")); - if (item.type == ItemID.CelestialShell) - EditTooltipByNum(4, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.AbyssBreathLevel3")); - #endregion - - // Flasks apply to Rogue weapons - #region Rogue Flask Tooltips - if (item.type == ItemID.FlaskofCursedFlames) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofCursedFlames")); - if (item.type == ItemID.FlaskofFire) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofFire")); - if (item.type == ItemID.FlaskofGold) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofGold")); - if (item.type == ItemID.FlaskofIchor) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofIchor")); - if (item.type == ItemID.FlaskofNanites) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofNanites")); - // party flask is unique because it affects ALL projectiles in Calamity, not just "also rogue ones" - if (item.type == ItemID.FlaskofParty) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofParty")); - if (item.type == ItemID.FlaskofPoison) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofPoison")); - if (item.type == ItemID.FlaskofVenom) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofVenom")); - #endregion - - // Rebalances to vanilla item stats - #region Vanilla Item Rebalance Tooltips - - // Various mining speed nerfs - if (item.type == ItemID.MiningPotion) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); + // Nerfed Ancient Chisel and its upgrade. if (item.type == ItemID.AncientChisel) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); - if (item.type == ItemID.HandOfCreation) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); - // Frozen Turtle Shell rebalance. - if (item.type == ItemID.FrozenTurtleShell) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); - - if (item.type == ItemID.FrozenShield) - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("25%", "15%")); - - // Ale and Sake rebalance and Alcohol Poisoning. - if (item.type == ItemID.Ale || item.type == ItemID.Sake) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("AleSake")); - - //Flame Waker Boots buff. - if (item.type == ItemID.FlameWakerBoots) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlameWakerBoots")); - - // Hellfire Treads buff. - if (item.type == ItemID.HellfireTreads) - EditTooltipByNum(2, (line) => line.Text += AddedTooltip("HellfireTreads")); - - // Fairy Boots buff. - if (item.type == ItemID.FairyBoots) - EditTooltipByNum(2, (line) => line.Text += AddedTooltip("FairyBoots")); - - // Reduced Nightwither and Daybroken damage, and melee speed removal. + // Melee speed removed from the Celestial Stone line. if (item.type == ItemID.MoonStone) - { - EditTooltipByNum(2, (line) => line.Text += AddedTooltip("MoonStone")); EditTooltipByNum(1, (line) => line.Text = EditedTooltip("SunMoonStones")); - } if (item.type == ItemID.SunStone) - { - EditTooltipByNum(2, (line) => line.Text += AddedTooltip("SunStone")); EditTooltipByNum(1, (line) => line.Text = EditedTooltip("SunMoonStones")); - } if (item.type == ItemID.CelestialStone) - { - EditTooltipByNum(2, (line) => line.Text += AddedTooltip("CelestialStone")); EditTooltipByNum(0, (line) => line.Text = EditedTooltip("CelestialStoneShell")); - } if (item.type == ItemID.CelestialShell) - { - EditTooltipByNum(4, (line) => line.Text += AddedTooltip("CelestialStone")); EditTooltipByNum(2, (line) => line.Text = EditedTooltip("CelestialStoneShell")); + + // Feral Claws line melee speed and true melee damage changes + if (item.type == ItemID.FeralClaws) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("12%", "10%")); + if (item.type == ItemID.TitanGlove) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("TitanGloveLine")); + if (item.type == ItemID.PowerGlove) + { + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("PowerGlove")); + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("TitanGloveLine")); + } + if (item.type == ItemID.BerserkerGlove) + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("BerserkerGlove")); + if (item.type == ItemID.MechanicalGlove) + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("MechanicalGlove") + AddedTooltip("TitanGloveLine")); + if (item.type == ItemID.FireGauntlet) + { + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FireGauntlet1")); + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("FireGauntlet2") + AddedTooltip("TitanGloveLine")); + } + + // Yoyo Glove/Bag apply a 0.5x damage multiplier on the second yoyo + if (item.type == ItemID.YoyoBag || item.type == ItemID.YoYoGlove) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("YoyoGlove")); + + // Molten Quiver sets Hellfire on all arrows. + if (item.type == ItemID.MoltenQuiver) + EditTooltipByNum(2, (line) => line.Text = EditedTooltip("MoltenQuiver")); + + // Eye of the Golem gains a new effect, also applies to specifically Sniper Scope. + if (item.type == ItemID.EyeoftheGolem) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("EyeoftheGolem")); + + // Scope effects can now be visibility toggled. + if (item.type == ItemID.RifleScope) + { + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("RifleScope1")); + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("RifleScope2")); + } + if (item.type == ItemID.ReconScope) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("RifleScope")); + if (item.type == ItemID.SniperScope) + { + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("SniperScope")); + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("RifleScope")); + EditTooltipByNum(1, (line) => line.Text += AddedTooltip("EyeoftheGolem")); } // Mana Flower tinker buffs. if (item.type == ItemID.MagnetFlower) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MagnetFlower")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("8%", "10%")); if (item.type == ItemID.ArcaneFlower || item.type == ItemID.ManaCloak) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ArcaneFlowerManaCloak")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("8%", "12%")); if (item.type == ItemID.ArcaneFlower) EditTooltipByNum(2, (line) => line.Text += AddedTooltip("ArcaneFlower")); - // Magiluminescence nerf and clear explanation of what it actually does. + // Magiluminescence nerf and clarify the movement effects given. if (item.type == ItemID.Magiluminescence) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("Magiluminescence")); - // Frog Leg and all upgrades get clear explanations of what they actually do. + // Frog Leg and its upgrades clarify the amount of jump speed given. if (item.type == ItemID.FrogLeg) EditTooltipByNum(0, (line) => line.Text = GetEditedTooltip("FrogLeg").Format(BalancingConstants.VanillaFrogLegJumpSpeedBoost.ToJumpSpeedPercent())); - if (item.type == ItemID.FrogFlipper || item.type == ItemID.FrogWebbing) EditTooltipByNum(1, (line) => line.Text = GetEditedTooltip("FrogLeg").Format(BalancingConstants.VanillaFrogLegJumpSpeedBoost.ToJumpSpeedPercent())); - if (item.type == ItemID.FrogGear) EditTooltipByNum(2, (line) => line.Text = GetEditedTooltip("FrogLeg").Format(BalancingConstants.VanillaFrogLegJumpSpeedBoost.ToJumpSpeedPercent())); - if (item.type == ItemID.AmphibianBoots) EditTooltipByNum(1, (line) => line.Text = GetEditedTooltip("FrogLeg").Format(BalancingConstants.AmphibianBootsJumpSpeedBoost.ToJumpSpeedPercent())); - // Soaring Insignia nerf and clear explanation of what it actually does. + // Soaring Insignia nerf and clarify the movement effects given. if (item.type == ItemID.EmpressFlightBooster) { EditTooltipByNum(0, (line) => line.Text = EditedTooltip("EmpressFlightBooster1")); EditTooltipByNum(1, (line) => line.Text = EditedTooltip("EmpressFlightBooster2")); } - // Rifle Scope visibility change - if (item.type == ItemID.RifleScope) + // Reworked Gravity Globe + if (item.type == ItemID.GravityGlobe) + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("GravityGlobe")); + + // Flame Waker Boots now has a functional effect which inherits to Hellfire Treads. + if (item.type == ItemID.FlameWakerBoots) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlameWakerBoots")); + if (item.type == ItemID.HellfireTreads) + EditTooltipByNum(2, (line) => line.Text += AddedTooltip("HellfireTreads")); + + // Fairy Boots gains a new functional effect. + if (item.type == ItemID.FairyBoots) + EditTooltipByNum(2, (line) => line.Text += AddedTooltip("FairyBoots")); + + // Ankh Shield now provides sandstorm wind push immunity. + if (item.type == ItemID.AnkhShield) + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("AnkhShield")); + + // Flesh Knuckles now gives increased max life. + if (item.type == ItemID.FleshKnuckles || item.type == ItemID.HeroShield || item.type == ItemID.BerserkerGlove) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("FleshKnucklesLine")); + + // Hand Warmer now has a side bonus with Snow armor. + if (item.type == ItemID.HandWarmer) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("HandWarmer")); + #endregion + + #region Pre-Hardmode Armor + // Gladiator + if (item.type == ItemID.GladiatorHelmet) + EditTooltipByName("Defense", (line) => line.Text += "\n" + CalamityUtils.GetText("Common.RogueDamage").Format(GladiatorArmorSetChange.HelmetRogueDamageBoostPercent)); + if (item.type == ItemID.GladiatorBreastplate) + EditTooltipByName("Defense", (line) => line.Text += "\n" + CalamityUtils.GetText("Common.RogueCrit").Format(GladiatorArmorSetChange.ChestplateRogueCritBoostPercent)); + if (item.type == ItemID.GladiatorLeggings) + EditTooltipByName("Defense", (line) => line.Text += "\n" + CalamityUtils.GetText("Common.RogueVelocity").Format(GladiatorArmorSetChange.LeggingRogueVelocityBoostPercent)); + + // Jungle + if (item.type == ItemID.JungleHat || item.type == ItemID.AncientCobaltHelmet) { - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("RifleScope1")); - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("RifleScope2")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("40", "20")); + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("6%", "3%")); } + if (item.type == ItemID.JunglePants || item.type == ItemID.AncientCobaltLeggings) + EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("6%", "3%")); - // Sniper Scope rebalance and visibility change - if (item.type == ItemID.SniperScope) + // Crimson + if (item.type == ItemID.CrimsonHelmet || item.type == ItemID.CrimsonScalemail || item.type == ItemID.CrimsonGreaves) { - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("SniperScope")); - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("RifleScope")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("3%", "6%")); + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("CrimsonArmorPieces")); } - // Recon Scope visibility change - if (item.type == ItemID.ReconScope) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("RifleScope")); - - - // Magic Quiver - if (item.type == ItemID.MagicQuiver) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MagicQuiver")); - - // Molten Quiver - if (item.type == ItemID.MoltenQuiver) - { - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MoltenQuiver1")); - EditTooltipByNum(2, (line) => line.Text = EditedTooltip("MoltenQuiver2")); - } - - // Magic Power Potion nerf - if (item.type == ItemID.MagicPowerPotion) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MagicPowerPotion")); - - // Featherfall Potion being stupid broken with Aero Stone - if (item.type == ItemID.FeatherfallPotion) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("FeatherfallPotion")); - // Magic Hat nerf if (item.type == ItemID.MagicHat) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MagicHat")); @@ -852,145 +885,12 @@ namespace CalamityMod.Items EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("15%", "9%")); } - // Worm Scarf only gives 14% DR instead of 17% - if (item.type == ItemID.WormScarf) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("17%", "14%")); - - // Feral Claws line melee speed and true melee damage changes - if (item.type == ItemID.FeralClaws) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("12%", "10%")); - - if (item.type == ItemID.TitanGlove) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("TitanGloveLine")); - - if (item.type == ItemID.PowerGlove) - { - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("PowerGlove")); - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("TitanGloveLine")); - } - - if (item.type == ItemID.BerserkerGlove) - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("BerserkerGlove")); - - if (item.type == ItemID.MechanicalGlove) - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("MechanicalGlove") + AddedTooltip("TitanGloveLine")); - - if (item.type == ItemID.FireGauntlet) - { - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FireGauntlet1")); - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("FireGauntlet2") + AddedTooltip("TitanGloveLine")); - } - - // On Fire! debuff immunities - if (item.type == ItemID.ObsidianSkull || item.type == ItemID.ObsidianSkullRose || item.type == ItemID.MoltenCharm) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ObsidianSkullLine")); - - if (item.type == ItemID.ObsidianHorseshoe || item.type == ItemID.ObsidianShield || item.type == ItemID.ObsidianWaterWalkingBoots || item.type == ItemID.LavaSkull || item.type == ItemID.MoltenSkullRose) - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("ObsidianSkullLine")); - - if (item.type == ItemID.LavaWaders) - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("LavaWaders")); - - if (item.type == ItemID.TerrasparkBoots) - EditTooltipByNum(3, (line) => line.Text = EditedTooltip("LavaWaders")); - - // Ozzatron 23NOV2023: Removed tooltip edits for Magma Skull and Molten Skull Rose, as they were invalid after vanilla tooltip changes. - - // Yoyo Glove/Bag apply a 0.5x damage multiplier on the second yoyo - if (item.type == ItemID.YoyoBag || item.type == ItemID.YoYoGlove) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("YoyoGlove")); - //Gi 10% melee speed into 10% jump speed replacement if (item.type == ItemID.Gi) EditTooltipByNum(1, (line) => line.Text = EditedTooltip("Gi")); #endregion - // Pre-Hardmode ore armor tooltip edits - #region Pre-Hardmode Ore Armor - // Copper - if (item.type == ItemID.CopperHelmet) - AddTooltip("CopperHelmet"); - if (item.type == ItemID.CopperChainmail) - AddTooltip("CopperChainmail"); - if (item.type == ItemID.CopperGreaves) - AddTooltip("CopperGreaves"); - - // Tin - if (item.type == ItemID.TinHelmet) - AddTooltip("TinHelmet"); - if (item.type == ItemID.TinChainmail) - AddTooltip("TinChainmail"); - if (item.type == ItemID.TinGreaves) - AddTooltip("TinGreaves"); - - // Iron - if (item.type == ItemID.IronHelmet || item.type == ItemID.AncientIronHelmet || item.type == ItemID.IronChainmail || item.type == ItemID.IronGreaves) - AddTooltip("IronPieces"); - - // Lead - if (item.type == ItemID.LeadHelmet || item.type == ItemID.LeadChainmail || item.type == ItemID.LeadGreaves) - AddTooltip("LeadPieces"); - - // Silver - if (item.type == ItemID.SilverHelmet) - AddTooltip("SilverHelmet"); - if (item.type == ItemID.SilverChainmail) - AddTooltip("SilverChainmail"); - if (item.type == ItemID.SilverGreaves) - AddTooltip("SilverGreaves"); - - // Tungsten - if (item.type == ItemID.TungstenHelmet) - AddTooltip("TungstenHelmet"); - if (item.type == ItemID.TungstenChainmail) - AddTooltip("TungstenChainmail"); - if (item.type == ItemID.TungstenGreaves) - AddTooltip("TungstenGreaves"); - - // Gold - if (item.type == ItemID.GoldHelmet || item.type == ItemID.AncientGoldHelmet) - AddTooltip("GoldHelmet"); - if (item.type == ItemID.GoldChainmail) - AddTooltip("GoldChainmail"); - if (item.type == ItemID.GoldGreaves) - AddTooltip("GoldGreaves"); - - // Platinum - if (item.type == ItemID.PlatinumHelmet) - AddTooltip("PlatinumHelmet"); - if (item.type == ItemID.PlatinumChainmail) - AddTooltip("PlatinumChainmail"); - if (item.type == ItemID.PlatinumGreaves) - AddTooltip("PlatinumGreaves"); - - // Jungle - if (item.type == ItemID.JungleHat || item.type == ItemID.AncientCobaltHelmet) - { - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("40", "20")); - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("6%", "3%")); - } - if (item.type == ItemID.JunglePants || item.type == ItemID.AncientCobaltLeggings) - EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("6%", "3%")); - - // Crimson - if (item.type == ItemID.CrimsonHelmet || item.type == ItemID.CrimsonScalemail || item.type == ItemID.CrimsonGreaves) - { - EditTooltipByNum(0, (line) => - { - string newTooltip = line.Text.Replace("3%", "6%"); - // Chest piece has 2 regen instead of 1 - newTooltip += item.type == ItemID.CrimsonScalemail ? AddedTooltip("CrimsonBreastplate") : AddedTooltip("CrimsonOtherPieces"); - line.Text = newTooltip; - }); - } - - // Meteor - if (item.type == ItemID.MeteorHelmet || item.type == ItemID.MeteorSuit || item.type == ItemID.MeteorLeggings) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("9%", "8%")); - #endregion - - // Hardmode armor tooltip edits - #region Hardmode Ore Armor + #region Hardmode Armor // Cobalt if (item.type == ItemID.CobaltHat) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("40", $"{CobaltArmorSetChange.MaxManaBoost + 40}")); @@ -1017,11 +917,13 @@ namespace CalamityMod.Items if (item.type == ItemID.TitaniumMask) EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("9%", "14%")); + // Shroomite + if (item.type == ItemID.ShroomiteBreastplate) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("13%", "8%")); + // Solar Flare if (item.type == ItemID.SolarFlareHelmet) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("26%", "20%")); - if (item.type == ItemID.SolarFlareHelmet || item.type == ItemID.SolarFlareBreastplate || item.type == ItemID.SolarFlareLeggings) - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("SolarFlarePieces")); // Vortex if (item.type == ItemID.VortexHelmet) @@ -1031,35 +933,16 @@ namespace CalamityMod.Items } #endregion - // DD2 armor tooltip edits #region DD2 Armor - // Reduce DD2 armor piece bonuses because they're overpowered, and clarify life regen boosts - // Squire armor - if (item.type == ItemID.SquireGreatHelm) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireGreatHelm")); - if (item.type == ItemID.SquirePlating) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquirePlating")); + // Nerf sets that are too strong if (item.type == ItemID.SquireGreaves) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireGreaves")); - // Monk armor - if (item.type == ItemID.MonkBrows) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MonkBrows")); - if (item.type == ItemID.MonkShirt) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MonkShirt")); - if (item.type == ItemID.MonkPants) - { - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MonkPants1")); - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("MonkPants2")); - } - - // Huntress armor + if (item.type == ItemID.HuntressWig) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("10%", "15%")); if (item.type == ItemID.HuntressJerkin) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("HuntressJerkin")); - if (item.type == ItemID.HuntressPants) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("HuntressPants")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("20%", "15%")); - // Apprentice armor if (item.type == ItemID.ApprenticeHat) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeHat")); if (item.type == ItemID.ApprenticeRobe) @@ -1067,13 +950,33 @@ namespace CalamityMod.Items if (item.type == ItemID.ApprenticeTrousers) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeTrousers")); - // Valhalla Knight armor if (item.type == ItemID.SquireAltHead) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireAltHead")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("10%", "15%")); if (item.type == ItemID.SquireAltShirt) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireAltShirt")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("30%", "20%")); if (item.type == ItemID.SquireAltPants) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireAltPants")); + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("20%", "15%")); + + if (item.type == ItemID.HuntressAltShirt) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "20%")); + if (item.type == ItemID.HuntressAltPants) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "20%")); + + if (item.type == ItemID.ApprenticeAltHead) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("15%", "10%")); + if (item.type == ItemID.ApprenticeAltShirt) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "20%")); + if (item.type == ItemID.ApprenticeAltPants) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); + + // Tweaks into Rogue + // Monk armor + if (item.type == ItemID.MonkBrows) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MonkBrows")); + if (item.type == ItemID.MonkShirt) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MonkShirt")); + if (item.type == ItemID.MonkPants) + EditTooltipByNum(1, (line) => line.Text = EditedTooltip("MonkPants")); // Shinobi Infiltrator armor if (item.type == ItemID.MonkAltHead) @@ -1085,66 +988,65 @@ namespace CalamityMod.Items } if (item.type == ItemID.MonkAltPants) EditTooltipByNum(0, (line) => line.Text = EditedTooltip("MonkAltPants")); - - // Red Riding armor - if (item.type == ItemID.HuntressAltShirt) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("HuntressAltShirt")); - if (item.type == ItemID.HuntressAltPants) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("HuntressAltPants")); - - // Dark Artist armor - if (item.type == ItemID.ApprenticeAltHead) - EditTooltipByNum(1, (line) => line.Text = EditedTooltip("ApprenticeAltHead")); - if (item.type == ItemID.ApprenticeAltShirt) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeAltShirt")); - if (item.type == ItemID.ApprenticeAltPants) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeAltPants")); #endregion - // Non-consumable boss summon items - #region Vanilla Boss Summon Non-consumable Tooltips - if (item.type == ItemID.SlimeCrown || item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.BloodMoonStarter || item.type == ItemID.GoblinBattleStandard || - item.type == ItemID.WormFood || item.type == ItemID.BloodySpine || item.type == ItemID.Abeemination || item.type == ItemID.DeerThing || item.type == ItemID.QueenSlimeCrystal || - item.type == ItemID.PirateMap || item.type == ItemID.SnowGlobe || item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalWorm || item.type == ItemID.MechanicalSkull || - item.type == ItemID.NaughtyPresent || item.type == ItemID.PumpkinMoonMedallion || item.type == ItemID.SolarTablet || item.type == ItemID.SolarTablet || item.type == ItemID.CelestialSigil) - EditTooltipByNum(0, (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.NotConsumable")); - #endregion - - // Add mentions of what Calamity ores vanilla pickaxes can mine - #region Pickaxe New Ore Tooltips - if (item.type == ItemID.GoldPickaxe || item.type == ItemID.PlatinumPickaxe) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("GoldPickaxe")); - - if (item.type == ItemID.Picksaw) - EditTooltipByNum(0, (line) => line.Text += AddedTooltip("Picksaw")); - - if (item.type == ItemID.SolarFlarePickaxe || item.type == ItemID.VortexPickaxe || item.type == ItemID.NebulaPickaxe || item.type == ItemID.StardustPickaxe) - EditTooltipByName("Material", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.CanMineUelibloom")); - - if (item.type == ItemID.SolarFlareDrill || item.type == ItemID.VortexDrill || item.type == ItemID.NebulaDrill || item.type == ItemID.StardustDrill) - EditTooltipByName("TileBoost", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.CanMineUelibloom")); - #endregion - - // Rebalances and information about vanilla set bonuses #region Vanilla Set Bonus Tooltips - EditTooltipByName("SetBonus", (line) => VanillaArmorChangeManager.ApplySetBonusTooltipChanges(item, ref line.Text)); - // Gladiator - if (item.type == ItemID.GladiatorHelmet) - EditTooltipByName("Defense", (line) => line.Text += "\n" +CalamityUtils.GetText("Common.RogueDamage").Format(GladiatorArmorSetChange.HelmetRogueDamageBoostPercent)); - if (item.type == ItemID.GladiatorBreastplate) - EditTooltipByName("Defense", (line) => line.Text += "\n" +CalamityUtils.GetText("Common.RogueCrit").Format(GladiatorArmorSetChange.ChestplateRogueCritBoostPercent)); - if (item.type == ItemID.GladiatorLeggings) - EditTooltipByName("Defense", (line) => line.Text += "\n" +CalamityUtils.GetText("Common.RogueVelocity").Format(GladiatorArmorSetChange.LeggingRogueVelocityBoostPercent)); - // Forbidden (UNLESS you are wearing the Circlet, which is Summon/Rogue and does not get this line) if ((item.type == ItemID.AncientBattleArmorHat || item.type == ItemID.AncientBattleArmorShirt || item.type == ItemID.AncientBattleArmorPants) && !Main.LocalPlayer.Calamity().forbiddenCirclet) - EditTooltipByName("SetBonus", (line) => line.Text = CalamityUtils.GetText($"Vanilla.Armor.SetBonus.Forbidden").Format(Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN"))); + EditTooltipByName("SetBonus", (line) => line.Text = CalamityUtils.GetText($"Vanilla.Armor.SetBonus.Forbidden").Format(CalamityUtils.GetArmorSetBonusKey())); + + // Vortex (hotkey spoof) + if (item.type == ItemID.VortexHelmet || item.type == ItemID.VortexBreastplate || item.type == ItemID.VortexLeggings) + EditTooltipByName("SetBonus", (line) => line.Text = CalamityUtils.GetText($"Vanilla.Armor.SetBonus.Vortex").Format(CalamityUtils.GetArmorSetBonusKey())); + #endregion + + #region Potions + // Nerfed Archery Potion + if (item.type == ItemID.ArcheryPotion) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ArcheryPotion")); + + // Nerfed Swiftness Potion + if (item.type == ItemID.SwiftnessPotion) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); + + // Nerfed Magic Power Potion + if (item.type == ItemID.MagicPowerPotion) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("20%", "10%")); + + // Nerfed Mining Potion + if (item.type == ItemID.MiningPotion) + EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); + + // Ale and Sake rebalance and Alcohol Poisoning. + if (item.type == ItemID.Ale || item.type == ItemID.Sake) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("AleSake")); + + // Featherfall Potion being stupid broken with Aero Stone + if (item.type == ItemID.FeatherfallPotion) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("FeatherfallPotion")); + + // Flasks apply to Rogue weapons (Party applies to all) + if (item.type == ItemID.FlaskofCursedFlames) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofCursedFlames")); + if (item.type == ItemID.FlaskofFire) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofFire")); + if (item.type == ItemID.FlaskofGold) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofGold")); + if (item.type == ItemID.FlaskofIchor) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofIchor")); + if (item.type == ItemID.FlaskofNanites) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofNanites")); + if (item.type == ItemID.FlaskofParty) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofParty")); + if (item.type == ItemID.FlaskofPoison) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofPoison")); + if (item.type == ItemID.FlaskofVenom) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("FlaskofVenom")); #endregion - // Provide the full stats of every vanilla yoyo #region Yoyo Stat Tooltips // This function is shorthand for appending a stat sheet to a yoyo. void AddYoyoStats(float d, float r, float s) @@ -1197,7 +1099,6 @@ namespace CalamityMod.Items AddYoyoStats(-1f, 400f, 36f); #endregion - // Provide the full stats of every vanilla set of wings #region Wing Stat Tooltips // This function produces a "stat sheet" for a pair of wings from the raw stats. @@ -1214,9 +1115,9 @@ namespace CalamityMod.Items sb.Append('\n'); sb.Append(CalamityUtils.GetText($"Common.WingStats").Format(time.FramesToSeconds(), run.ToMph(), (tMax * baseJumpSpeed).ToMph())); sb.Append('\n'); - if (Main.keyState.IsKeyDown(Keys.LeftShift)) + if (Main.keyState.PressingShift()) { - sb.Append(CalamityUtils.GetText($"Common.WingStatsAcceleration").Format(rAcc.ToMphps(), asc.ToMphps(), (asc + rise).ToMphps(), (rMax * baseJumpSpeed).ToMph(), (asc + rise + fall).ToMphps())); + sb.Append(CalamityUtils.GetText($"Common.WingStatsAcceleration").Format(rAcc.ToMphps(), asc.ToMphps(), (asc + rise).ToMphps(), (rMax * baseJumpSpeed).ToMph(), (asc + fall).ToMphps())); if (hover) { sb.Append('\n'); @@ -1225,7 +1126,7 @@ namespace CalamityMod.Items } else sb.Append($"[c/B8B8B8:{CalamityUtils.GetTextValue("UI.HoldShiftTooltipExtensionIndicator")}]"); - + if (extraKey != null) { sb.Append('\n'); @@ -1241,16 +1142,16 @@ namespace CalamityMod.Items AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); if (item.type == ItemID.AngelWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.95f, 0.15f); if (item.type == ItemID.DemonWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); + AddWingStats(item.wingSlot, 1f, 0.2f, 1f, 1.5f, 0.1f, "DemonWings"); if (item.type == ItemID.Jetpack) AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); if (item.type == ItemID.ButterflyWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.35f, 0.5f); if (item.type == ItemID.FairyWings) AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); @@ -1259,19 +1160,19 @@ namespace CalamityMod.Items AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f, "BeeWings"); if (item.type == ItemID.HarpyWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f, "HarpyWings"); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); if (item.type == ItemID.BoneWings) AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.66f, 0.1f, "BoneWings"); if (item.type == ItemID.FlameWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f, "FlameWings"); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.8f, 0.135f); if (item.type == ItemID.FrozenWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f, "FrozenWings"); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); if (item.type == ItemID.GhostWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.66f, 0.1f); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.5f); if (item.type == ItemID.BeetleWings) AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.66f, 0.1f); @@ -1286,10 +1187,10 @@ namespace CalamityMod.Items AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.805f, 0.1f); if (item.type == ItemID.LeafWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f, "LeafWings"); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); if (item.type == ItemID.BatWings) - AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f, "BatWings"); + AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); // All developer wings have identical stats and no special effects if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || @@ -1343,7 +1244,6 @@ namespace CalamityMod.Items AddWingStats(item.wingSlot, 0.95f, 0.15f, 1f, 4.5f, 0.1f); #endregion - // Provide the full stats of every vanilla grappling hook #region Grappling Hook Stat Tooltips // This function is shorthand for appending a stat sheet to a grappling hook. @@ -1460,38 +1360,76 @@ namespace CalamityMod.Items #endregion - // Beyond this point all code only applies to accessories. Skip it all if the item is not an accessory. - if (!item.accessory) - return; + // Add mentions of what Calamity ores vanilla pickaxes can mine + #region Pickaxe New Ore Tooltips + if (item.type == ItemID.GoldPickaxe || item.type == ItemID.PlatinumPickaxe) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("GoldPickaxe")); - // Display the stat changes to vanilla prefixes - #region Accessory Prefix Rebalance Tooltips + if (item.type == ItemID.Picksaw) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("Picksaw")); - // Turns a number into a string of increased DR. - string DRString(float percent) => "\n" + GetAddedTooltip("DefensePrefix").Format(percent.ToString()); + if (item.type == ItemID.SolarFlarePickaxe || item.type == ItemID.VortexPickaxe || item.type == ItemID.NebulaPickaxe || item.type == ItemID.StardustPickaxe) + EditTooltipByName("Material", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.CanMineUelibloom")); - switch (item.prefix) - { - case PrefixID.Hard: - EditTooltipByName("PrefixAccDefense", - (line) => line.Text = line.Text.Replace("1", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.25f)); - return; - case PrefixID.Guarding: - EditTooltipByName("PrefixAccDefense", - (line) => line.Text = line.Text.Replace("2", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.5f)); - return; - case PrefixID.Armored: - EditTooltipByName("PrefixAccDefense", - (line) => line.Text = line.Text.Replace("3", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.75f)); - return; - case PrefixID.Warding: - EditTooltipByName("PrefixAccDefense", - (line) => line.Text = line.Text.Replace("4", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(1f)); - return; - case PrefixID.Lucky: - EditTooltipByName("PrefixAccCritChance", (line) => line.Text += AddedTooltip("LuckyPrefix")); - return; - } + if (item.type == ItemID.SolarFlareDrill || item.type == ItemID.VortexDrill || item.type == ItemID.NebulaDrill || item.type == ItemID.StardustDrill) + EditTooltipByName("TileBoost", (line) => line.Text += "\n" + CalamityUtils.GetTextValue("Common.CanMineUelibloom")); + #endregion + + // Numerous random tooltip edits which don't fit into another category + #region Miscellaneous Tooltip Edits + // Apparently 612 is a homestuck reference + if (item.type == ModContent.ItemType()) + EditTooltipByName("AxePower", (line) => line.Text = line.Text.Replace("610%", "612%")); + + // Master Mode items also drop in Revengeance + // Only affects vanilla and Calamity items + if (item.master && (item.type < ItemID.Count || item.ModItem?.Mod is CalamityMod)) + EditTooltipByName("Master", (line) => line.Text = EditedTooltip("MasterExclusive")); + + // Add a tooltip about Slimed's effects + if (item.type == ItemID.SlimeGun) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("SlimeGun")); + // Replace the meme tooltip with a useful one. + if (item.type == ItemID.GelBalloon) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("GelBalloon")); + + // Aerial Bane is no longer the real bane of aerial enemies (50% dmg bonus removed) + if (item.type == ItemID.DD2BetsyBow) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("DD2BetsyBow")); + + // Rod of Discord cannot be used multiple times to hurt yourself + if (item.type == ItemID.RodofDiscord) + EditTooltipByNum(1, (line) => line.Text += AddedTooltip("RodofDiscord")); + + // If Early Hardmode Rework is enabled: Remind users that ores will NOT spawn when an altar is smashed. + if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && (item.type == ItemID.Pwnhammer || item.type == ItemID.Hammush)) + EditTooltipByNum(0, (line) => line.Text += AddedTooltip("Pwnhammer")); + + // Golden Fishing Rod inherently contains High Test Fishing Line + if (item.type == ItemID.GoldenFishingRod) + EditTooltipByName("NeedsBait", (line) => line.Text += AddedTooltip("GoldenFishingRod")); + + // Information about graveyards + // 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 += AddedTooltip("Tombstones")); + + // Modify item speed tooltips to use a new scale designed to more accurately reflect practical distributions of item speeds. + // Due to the higher complexity of the action, the actual logic is delegated to its own method. + // I think this fits the miscellaneous category? Not seeing anything like this elsewhere. - Tomat + EditTooltipByName("Speed", (line) => RedistributeSpeedTooltips(item, line)); + + if (item.healLife > 0 && Main.LocalPlayer.Calamity().healingPotionMultiplier != 1f) + EditTooltipByName("HealLife", (line) => line.Text = Language.GetOrRegister("CommonItemTooltip.RestoresLife").Format((int)(item.healLife * Main.LocalPlayer.Calamity().healingPotionMultiplier))); + + // Ancient Manipulator also crafts stuff with Astral Bars + if (item.type == ItemID.LunarCraftingStation) + EditTooltipByNum(0, (line) => line.Text = EditedTooltip("LunarCraftingStation")); + + // Replace the double tap line if double tap dash is overridden + if ((item.type == ItemID.EoCShield || item.type == ItemID.Tabi) && CalamityKeybinds.DashHotkey.GetAssignedKeysOrEmpty().Count != 0) + EditTooltipByNum(1, (line) => line.Text = CalamityUtils.GetText("Vanilla.DashKey").Format(CalamityKeybinds.DashHotkey.TooltipHotkeyString())); #endregion } #endregion @@ -1550,6 +1488,128 @@ namespace CalamityMod.Items #region Enchanted Rarity Text Drawing public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) { + if (line.Name == "ItemName" && line.Mod == "Terraria" && item.type == ModContent.ItemType()) + { + Color rarityColor = Color.White; + Vector2 basePosition = new Vector2(line.X, line.Y); + + float rate = Main.GlobalTimeWrappedHourly * 6; + List eColors = new List() + { + Color.DodgerBlue, + Color.Cyan, + Color.RoyalBlue + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + Vector2 backScale = line.BaseScale; + Color backColor = usedColor; + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, null, Main.UIScaleMatrix); + + int draws = 20; + for (int i = 0; i < draws; i++) + { + Vector2 backPosition = basePosition + (MathHelper.TwoPi * i / 20f).ToRotationVector2() * (3.5f); + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, backPosition, backColor, line.Rotation, line.Origin, backScale, line.MaxWidth, line.Spread); + } + Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D square = ModContent.Request("CalamityMod/Particles/BloomRing").Value; + + Vector2 drawPosition = basePosition; + Color drawColor = backColor; + Vector2 rotationPoint = texture.Size() * 0.5f; + int length = line.Text.Length; + for (int i = 0; i < 8; i++) + { + Main.EntitySpriteDraw(texture, basePosition + Vector2.UnitX * length * 4 + Vector2.UnitY * 23 + Vector2.UnitX * (i % 2 == 0 ? -10 * i : 10 * i), null, drawColor, (MathHelper.PiOver2), rotationPoint, new Vector2(0.3f - 0.02f * i, 1 + 0.35f * i) * 0.3f * Main.rand.NextFloat(0.9f, 1f), SpriteEffects.None); + } + for (int i = 0; i < 10; i++) + { + float sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * (0 + i * 0.8f) / MathHelper.Pi); + float sine2 = (float)Math.Sin(Main.GlobalTimeWrappedHourly * (5) / MathHelper.Pi); + float squareSine = (float)Math.Sin(i * 2.5f / MathHelper.Pi); + float clockSine = (float)Math.Sin((float)Math.Pow(Utils.GetLerpValue(0, 110, ((int)(Main.GlobalTimeWrappedHourly * (60 + i * 2)) % 120)), 5)); + Vector2 weirdPos = Vector2.UnitX * 53 * i * (Utils.GetLerpValue(20, 0, i, true)) + Vector2.UnitY * -23 * squareSine * sine2 + new Vector2(5, 10); + for (int t = 0; t < 3; t++) + Main.EntitySpriteDraw(square, basePosition + weirdPos, null, drawColor * (1 - 0.03f * i), 0, square.Size() * 0.5f, (1.2f - 0.07f * t) * new Vector2(1, 1) * (0.25f * ((float)Math.Pow(Utils.GetLerpValue(11, 0, i, true), 3) + 0.2f)), SpriteEffects.None); + for (int t = 0; t < 3; t++) + Main.EntitySpriteDraw(texture, basePosition + weirdPos, null, drawColor * (1 - 0.03f * i), 0, texture.Size() * 0.5f, (0.65f - 0.07f * t) * new Vector2(1, 1) * (0.25f * ((float)Math.Pow(Utils.GetLerpValue(11, 0, i, true), 3) + 0.2f)), SpriteEffects.None); + } + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); + + // Draw the front text as usual. + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, basePosition, rarityColor, line.Rotation, line.Origin, line.BaseScale, line.MaxWidth, line.Spread); + + return false; + } + if (line.Name == "ItemName" && line.Mod == "Terraria" && item.type == ModContent.ItemType()) + { + Color rarityColor = Color.White; + Vector2 basePosition = new Vector2(line.X, line.Y); + + float rate = Main.GlobalTimeWrappedHourly * 6; + List eColors = new List() + { + new Color(248, 117, 52), + Color.Gold, + Color.Orange + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + Vector2 backScale = line.BaseScale; + Color backColor = usedColor; + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, null, Main.UIScaleMatrix); + + int draws = 20; + for (int i = 0; i < draws; i++) + { + Vector2 backPosition = basePosition + (MathHelper.TwoPi * i / 20f).ToRotationVector2() * (3.5f); + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, backPosition, backColor, line.Rotation, line.Origin, backScale, line.MaxWidth, line.Spread); + } + Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D texture2 = ModContent.Request("CalamityMod/Particles/SquareRotated").Value; + Texture2D square = ModContent.Request("CalamityMod/Particles/GlowSquareParticleThick").Value; + + Vector2 drawPosition = basePosition; + Color drawColor = backColor; + Vector2 rotationPoint = texture.Size() * 0.5f; + int length = line.Text.Length; + for (int i = 0; i < 8; i++) + { + Main.EntitySpriteDraw(texture, basePosition + Vector2.UnitX * length * 4 + Vector2.UnitY * 23 + Vector2.UnitX * (i % 2 == 0 ? -10 * i : 10 * i), null, drawColor, (MathHelper.PiOver2), rotationPoint, new Vector2(0.3f - 0.02f * i, 1 + 0.35f * i) * 0.3f * Main.rand.NextFloat(0.9f, 1f), SpriteEffects.None); + } + for (int i = 0; i < 10; i++) + { + float sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * (0 + i * 0.8f) / MathHelper.Pi); + float squareSine = (float)Math.Sin(i * 2.5f / MathHelper.Pi); + float clockSine = (float)Math.Sin((float)Math.Pow(Utils.GetLerpValue(0, 110, ((int)(Main.GlobalTimeWrappedHourly * (60 + i * 2)) % 120)), 5)); + Vector2 weirdPos = Vector2.UnitX * 53 * i * (Utils.GetLerpValue(20, 0, i, true)) + Vector2.UnitY * 23 * squareSine + Vector2.UnitY * 5.5f * sine + new Vector2(5, 10); + for (int t = 0; t < 3; t++) + Main.EntitySpriteDraw(square, basePosition + weirdPos, null, drawColor * (1 - 0.03f * i), clockSine * MathHelper.PiOver2 + MathHelper.PiOver4, square.Size() * 0.5f, (1 - 0.07f * t) * new Vector2(1, 1) * (0.25f * ((float)Math.Pow(Utils.GetLerpValue(11, 0, i, true), 3) + 0.2f)), SpriteEffects.None); + for (int t = 0; t < 3; t++) + Main.EntitySpriteDraw(texture2, basePosition + weirdPos, null, drawColor * (1 - 0.03f * i), clockSine * MathHelper.PiOver2, texture2.Size() * 0.5f, (0.6f - 0.07f * t) * new Vector2(1, 1) * (0.25f * ((float)Math.Pow(Utils.GetLerpValue(11, 0, i, true), 3) + 0.2f)), SpriteEffects.None); + } + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); + + // Draw the front text as usual. + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, basePosition, rarityColor, line.Rotation, line.Origin, line.BaseScale, line.MaxWidth, line.Spread); + + return false; + } // Special enchantment line color. if (line.Name == "ItemName" && line.Mod == "Terraria" && item.IsEnchanted()) { @@ -1576,6 +1636,197 @@ namespace CalamityMod.Items return false; } + // IV Drip tooltip FX + if (line.Mod == "Terraria" && item.type == ModContent.ItemType() && line.Name == "Tooltip4") + { + Vector2 basePosition = new Vector2(line.X, line.Y); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, null, Main.UIScaleMatrix); + + for (int i = 0; i < 3; i++) // Draw 3 lines of differing opacity, color, and displacement. + { + float timer = (float)Math.Sin(Main.GlobalTimeWrappedHourly + 1f) / 2f; + + float angle = (Main.GlobalTimeWrappedHourly * 2f) + (i * MathHelper.TwoPi / 3f); + float radius = timer * (3f + i * 6f); + Vector2 offset = new Vector2((float)Math.Cos(angle) * 1.7f, (float)Math.Sin(angle) * 1f) * radius; // Offset in an elliptical pattern + Vector2 pos = basePosition + offset; + + Color color = MulticolorLerp(Math.Abs(timer + (i * 0.2f)) % 1f, Color.LightBlue, Color.LightGreen, (i == 3) ? Color.Blue : (i == 2) ? Color.Red : Color.White); + float opacity = 1f - (i * 0.2f); + float rotation = line.Rotation + (timer * (Main.GlobalTimeWrappedHourly * 0.00001f)); // This precision is intended + + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, pos, color * opacity, rotation, line.Origin, line.BaseScale, line.MaxWidth, line.Spread); + } + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); + + return false; + } + if (line.Mod == "Terraria" && item.type == ModContent.ItemType() && (line.Name == "Tooltip1" || line.Name == "Tooltip2" || line.Name == "Tooltip4" || line.Name == "Tooltip5" || line.Name == "Tooltip7")) + { + Color rarityColor = Color.Black; + Vector2 basePosition = new Vector2(line.X, line.Y); + Vector2 backScale = line.BaseScale; + Player Owner = Main.LocalPlayer; + if (Owner is null) + return false; + + float sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 5 / MathHelper.Pi); + int draws = 20; + Color usedColor = Color.White; + if (line.Name == "Tooltip1" || line.Name == "Tooltip4" || line.Name == "Tooltip7") // Give the shifting color to the lines that need it + { + float rate = (Main.GlobalTimeWrappedHourly * 3); + List eColors = new List() + { + Owner.shirtColor, + Color.Lerp(Owner.shirtColor, Color.Black, 0.15f), + Color.Lerp(Owner.shirtColor, Color.White, 0.05f), + Color.Lerp(Owner.shirtColor, Color.White, 0.25f) + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + usedColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); + if (Owner.shirtColor == Color.White) + usedColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + } + + if (line.Name == "Tooltip5") // Shaky black outline + { + for (int i = 0; i < 4; i++) + { + Vector2 shake = Main.rand.NextVector2Circular(5, 5); + Vector2 backPosition = basePosition + shake; + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, backPosition, rarityColor, line.Rotation, line.Origin, backScale, line.MaxWidth, line.Spread); + } + } + if (line.Name == "Tooltip2" || line.Name == "Tooltip5") // Negative lines (inverted colors) + { + for (int i = 0; i < draws; i++) + { + Color clr = (line.Name == "Tooltip5") ? Color.Lerp(Color.White, Color.Black, sine) : Color.White; + Vector2 backPosition = basePosition + (MathHelper.TwoPi * i / draws).ToRotationVector2() * (1.5f + 0.2f * sine); + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, backPosition, clr with { A = 0 }, line.Rotation, line.Origin, backScale, line.MaxWidth, line.Spread); + } + Color clr2 = (line.Name == "Tooltip5") ? Color.Lerp(Color.Black, Color.White, sine) : Color.Black; + ChatManager.DrawColorCodedString(Main.spriteBatch, line.Font, line.Text, basePosition, clr2, line.Rotation, line.Origin, backScale); + return false; + + } + else if (line.Name == "Tooltip4") // Double outline + { + for (int i = 0; i < draws; i++) + { + Vector2 backPosition = basePosition + (MathHelper.TwoPi * i / draws).ToRotationVector2() * (4.5f + 0.2f * sine); + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, backPosition, usedColor with { A = 0 }, line.Rotation, line.Origin, backScale, line.MaxWidth, line.Spread); + } + for (int i = 0; i < draws; i++) + { + Vector2 backPosition = basePosition + (MathHelper.TwoPi * i / draws).ToRotationVector2() * (2.5f + 0.2f * sine); + ChatManager.DrawColorCodedString(Main.spriteBatch, line.Font, line.Text, backPosition, Color.Black, line.Rotation, line.Origin, backScale); + } + + ChatManager.DrawColorCodedString(Main.spriteBatch, line.Font, line.Text, basePosition, Color.White, line.Rotation, line.Origin, backScale); + return false; + } + if (line.Name == "Tooltip7") // Dark horizon thing + { + Texture2D texture = ModContent.Request("CalamityMod/Particles/Light").Value; + + Vector2 drawPosition = basePosition; + Color drawColor = Color.Black; + Vector2 rotationPoint = texture.Size() * 0.5f; + for (int i = 0; i < 6; i++) + { + int length = line.Text.Length; + Main.EntitySpriteDraw(texture, basePosition + Vector2.UnitX * length * 4 + Vector2.UnitY * 10 + Vector2.UnitX * (i % 2 == 0 ? -7 * i : 7 * i), null, usedColor with { A = 0 }, (MathHelper.PiOver2), rotationPoint, new Vector2(0.9f - 0.085f * i, 1 + 2.7f * i * 1f) * 0.7f * Main.rand.NextFloat(0.95f, 1f), SpriteEffects.None); + Main.EntitySpriteDraw(texture, basePosition + Vector2.UnitX * length * 4 + Vector2.UnitY * 10 + Vector2.UnitX * (i % 2 == 0 ? -7 * i : 7 * i), null, drawColor, (MathHelper.PiOver2), rotationPoint, new Vector2(0.9f - 0.05f * i, 1 + 4.5f * i * 1f) * 0.55f * Main.rand.NextFloat(0.95f, 1f), SpriteEffects.None); + } + + for (int i = 0; i < draws; i++) + { + Vector2 backPosition = basePosition + (MathHelper.TwoPi * i / draws).ToRotationVector2() * (1.5f); + ChatManager.DrawColorCodedString(Main.spriteBatch, line.Font, line.Text, backPosition, usedColor with { A = 0 } * 0.6f, line.Rotation, line.Origin, backScale); + } + ChatManager.DrawColorCodedString(Main.spriteBatch, line.Font, line.Text, basePosition, Color.Black, line.Rotation, line.Origin, backScale); + return false; + } + if (line.Name == "Tooltip1") + { + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, basePosition, usedColor, line.Rotation, line.Origin, backScale, line.MaxWidth, line.Spread); + return false; + } + + // Draw the front text as usual as a backup just in case. + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, basePosition, Color.White, line.Rotation, line.Origin, line.BaseScale, line.MaxWidth, line.Spread); + + return false; + } + + // Rainbow effect originally made for Orderbringer because it used to have a special rarity + // But why did it have one in the first place?? + // Might be used for Miracle stuff later or something idk + /*if (line.Name == "ItemName" && line.Mod == "Terraria" && item.type == ModContent.ItemType()) + { + Color rarityColor = Color.White; + Vector2 basePosition = new Vector2(line.X, line.Y); + + float rate = Main.GlobalTimeWrappedHourly * 29; + List eColors = new List() + { + Color.PaleVioletRed, + Color.Coral, + Color.Khaki, + Color.PaleGreen, + Color.Turquoise, + Color.Violet + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + + float sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3 / MathHelper.Pi); + sine = (float)Math.Pow(MathHelper.Lerp(sine, 0, 0.35f), 5); + Vector2 backScale = line.BaseScale; + Color backColor = usedColor; + Vector2 shake = Main.rand.NextVector2Circular(15, 15) * sine; + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, null, Main.UIScaleMatrix); + + int draws = 20; + for (int i = 0; i < draws; i++) + { + shake = Main.rand.NextVector2Circular(15, 15) * sine; + Vector2 backPosition = basePosition + (MathHelper.TwoPi * i / 20f).ToRotationVector2() * (5 + 0.5f * sine); + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, shake * 4 + backPosition, backColor, line.Rotation, line.Origin, backScale, line.MaxWidth, line.Spread); + } + Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + Vector2 drawPosition = basePosition; + Color drawColor = backColor; + Vector2 rotationPoint = texture.Size() * 0.5f; + for (int i = 0; i < 6; i++) + { + int length = line.Text.Length; + Main.EntitySpriteDraw(texture, basePosition + Vector2.UnitX * length * 4 + Vector2.UnitY * 10 + Vector2.UnitX * (i % 2 == 0 ? -7 * i : 7 * i), null, drawColor, (MathHelper.PiOver2), rotationPoint, new Vector2(1 - 0.05f * i * (1 + 0.2f * -sine), 1 + 0.75f * i * (1 + 0.2f * sine) * 1f) * 0.3f * Main.rand.NextFloat(0.9f, 1f), SpriteEffects.None); + } + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); + + // Draw the front text as usual. + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, shake + basePosition, rarityColor, line.Rotation, line.Origin, line.BaseScale, line.MaxWidth, line.Spread); + + return false; + }*/ return true; } #endregion diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 9a134872a1..23720f97f6 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -2,10 +2,10 @@ using CalamityMod.Balancing; using CalamityMod.Items.Accessories; using CalamityMod.Items.Fishing.AstralCatches; -using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.Items.Weapons.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -26,12 +26,12 @@ namespace CalamityMod.Items internal static void LoadTweaks() { - // Various shorthands for items which receive very simple changes, such as setting one flag. + // Various shorthands for items which receive very simple changes, or are repeated multiple times. IItemTweak[] trueMelee = Do(TrueMelee); IItemTweak[] trueMeleeNoSpeed = Do(TrueMeleeNoSpeed); - IItemTweak[] pointBlank = Do(PointBlank); - IItemTweak[] autoReuse = Do(AutoReuse); - IItemTweak[] nonConsumableBossSummon = Do(MaxStack(1), NotConsumable, UseTimeExact(10)); + IItemTweak[] nonConsumableBossSummon = Do(MaxStack(1), NotConsumable); + IItemTweak[] phaseblade = Do(UseTurn, DamageExact(36)); + IItemTweak[] phasesaber = Do(DamageExact(132)); // SORTING NOTES: // 1. Sort tweaks by categories first, then sort by the internal name in alphabetical order. Navigate through categories and names using the search function. @@ -40,8 +40,8 @@ namespace CalamityMod.Items currentTweaks = new SortedDictionary { #region CATEGORY 1: Weapon Balancing - { ItemID.AdamantiteGlaive, Do(AutoReuse, TrueMelee, DamageExact(69), UseExact(7), ShootSpeedExact(18f)) }, - { ItemID.AdamantiteRepeater, Do(PointBlank, UseExact(14)) }, + { ItemID.AdamantiteGlaive, Do(TrueMelee, DamageExact(69), UseExact(7), ShootSpeedExact(18f)) }, + { ItemID.AdamantiteRepeater, Do(UseExact(14)) }, { ItemID.AdamantiteSword, Do(UseTurn, DamageExact(75), UseExact(7)) }, { ItemID.AmberStaff, Do(UseTimeExact(15), UseAnimationExact(45), ReuseDelayExact(15)) }, { ItemID.AmethystStaff, Do(ManaExact(2)) }, @@ -54,276 +54,247 @@ namespace CalamityMod.Items { ItemID.BeeGun, Do(DamageExact(11), ManaExact(4)) }, { ItemID.BeeKeeper, Do(UseTurn, DamageExact(32)) }, { ItemID.Beenade, Do(DamageExact(11), UseTimeExact(22), ShootSpeedExact(10f)) }, - { ItemID.BeesKnees, Do(PointBlank, DamageExact(21), UseExact(38)) }, + { ItemID.BeesKnees, Do(DamageExact(21), UseExact(38)) }, { ItemID.Bladetongue, Do(UseTurn, UseRatio(0.8f), DamageExact(120)) }, { ItemID.BlizzardStaff, Do(DamageExact(41), ManaExact(7)) }, - { ItemID.BloodyMachete, Do(AutoReuse, DamageExact(24)) }, - { ItemID.Blowgun, Do(PointBlank, DamageExact(40), ShootSpeedExact(15f)) }, - { ItemID.BluePhaseblade, Do(AutoReuse, UseTurn, DamageExact(48)) }, - { ItemID.BluePhasesaber, Do(DamageExact(132)) }, - { ItemID.BoneSword, Do(AutoReuse, UseTurn, DamageExact(25)) }, + { ItemID.BloodyMachete, Do(DamageExact(24)) }, + { ItemID.Blowgun, Do(DamageExact(40), ShootSpeedExact(15f)) }, + { ItemID.BluePhaseblade, phaseblade }, + { ItemID.BluePhasesaber, phasesaber }, + { ItemID.BoneSword, Do(UseTurn, DamageExact(25)) }, { ItemID.BookofSkulls, Do(DamageExact(27), ManaExact(13), ShootSpeedExact(5.5f)) }, { ItemID.BookStaff, Do(ManaExact(14)) }, // Tome of Infinite Wisdom - { ItemID.Boomstick, Do(PointBlank, DamageExact(11)) }, - { ItemID.BreakerBlade, Do(AutoReuse, UseTurn, DamageExact(140)) }, - { ItemID.CandyCornRifle, Do(PointBlank, DamageExact(66)) }, - { ItemID.Cascade, Do(AutoReuse, DamageExact(31)) }, + { ItemID.Boomstick, Do(DamageExact(11)) }, + { ItemID.BreakerBlade, Do(UseTurn, DamageExact(140)) }, + { ItemID.CandyCornRifle, Do(DamageExact(66)) }, + { ItemID.Cascade, Do(DamageExact(31)) }, { ItemID.ChainGuillotines, Do(DamageExact(100)) }, - { ItemID.ChainGun, Do(PointBlank, DamageExact(35)) }, - { ItemID.ChainKnife, Do(AutoReuse, DamageRatio(1.34f)) }, // Uses ratios due to remix seed + { ItemID.ChainGun, Do(DamageExact(35)) }, + { ItemID.ChainKnife, Do(DamageRatio(1.34f)) }, // Uses ratios due to remix seed { ItemID.ChlorophyteClaymore, Do(UseMeleeSpeed, DamageExact(180), UseExact(45), ShootSpeedExact(22f)) }, - { ItemID.ChlorophytePartisan, Do(AutoReuse, UseMeleeSpeed, DamageExact(98)) }, + { ItemID.ChlorophytePartisan, Do(UseMeleeSpeed, DamageExact(95)) }, { ItemID.ChlorophyteSaber, Do(UseMeleeSpeed, DamageExact(92), UseExact(10)) }, - { ItemID.ChristmasTreeSword, Do(AutoReuse, UseTurn, UseMeleeSpeed, DamageExact(80), UseExact(30)) }, + { ItemID.ChristmasTreeSword, Do(UseTurn, UseMeleeSpeed, DamageExact(80), UseExact(30)) }, { ItemID.ClingerStaff, Do(DamageExact(63)) }, - { ItemID.ClockworkAssaultRifle, Do(PointBlank, DamageExact(21)) }, - { ItemID.CobaltNaginata, Do(AutoReuse, TrueMelee, DamageExact(55), UseExact(9), ShootSpeedExact(12f)) }, - { ItemID.CobaltRepeater, Do(PointBlank, UseExact(18)) }, - { ItemID.CobaltSword, Do(UseTurn, DamageExact(60), UseExact(9)) }, - { ItemID.Code2, Do(AutoReuse, DamageExact(43)) }, - { ItemID.CorruptYoyo, Do(AutoReuse, DamageExact(20)) }, // Malaise - { ItemID.CrimsonYoyo, Do(AutoReuse, DamageExact(20)) }, // Artery + { ItemID.ClockworkAssaultRifle, Do(DamageExact(21)) }, + { ItemID.CobaltNaginata, Do(TrueMelee, DamageExact(55), UseExact(9), ShootSpeedExact(12f)) }, + { ItemID.CobaltRepeater, Do(UseExact(18)) }, + { ItemID.CobaltSword, Do(DamageExact(60), UseExact(9)) }, + { ItemID.Code2, Do(DamageExact(43)) }, + { ItemID.CoinGun, Do(UseExact(12)) }, + { ItemID.CorruptYoyo, Do(DamageExact(20)) }, // Malaise + { ItemID.CrimsonYoyo, Do(DamageExact(20)) }, // Artery { ItemID.CrystalBullet, Do(DamageExact(6)) }, { ItemID.CrystalDart, Do(DamageExact(20)) }, - { ItemID.CrystalSerpent, Do(DamageExact(45)) }, { ItemID.CrystalStorm, Do(DamageExact(40)) }, + { ItemID.CrystalVileShard, Do(DamageExact(35)) }, { ItemID.CursedArrow, Do(DamageExact(14)) }, { ItemID.CursedDart, Do(DamageExact(25)) }, { ItemID.Cutlass, Do(UseRatio(0.9f), DamageExact(90)) }, { ItemID.DaedalusStormbow, Do(DamageExact(30)) }, - { ItemID.DaoofPow, Do(DamageExact(85)) }, - { ItemID.DarkLance, Do(AutoReuse, TrueMelee, DamageExact(40)) }, - { ItemID.DartRifle, Do(PointBlank, DamageExact(58)) }, - { ItemID.DayBreak, Do(DamageExact(125), UseExact(20)) }, + { ItemID.DaoofPow, Do(DamageExact(85)) }, // Displays as 170 damage + { ItemID.DarkLance, Do(TrueMelee, DamageExact(40)) }, + { ItemID.DartRifle, Do(DamageExact(58)) }, + { ItemID.DayBreak, Do(DamageExact(125), UseExact(22)) }, { ItemID.DD2BetsyBow, Do(DamageExact(42)) }, // Aerial Bane's ridiculous multiplier is removed, so this compensates for that { ItemID.DD2SquireBetsySword, Do(UseMeleeSpeed, DamageExact(150)) }, // Flying Dragon - { ItemID.DD2SquireDemonSword, Do(DamageExact(110), UseExact(25)) }, // Brand of the Inferno - { ItemID.DeathSickle, Do(UseMeleeSpeed, DamageExact(82), ShootSpeedExact(15f)) }, - { ItemID.DemonBow, Do(PointBlank, DamageExact(12), AutoReuse) }, - { ItemID.DemonScythe, Do(AutoReuse, DamageExact(33)) }, - { ItemID.DyeTradersScimitar, Do(AutoReuse, UseTurn, DamageExact(24)) }, // Exotic Scimitar - { ItemID.ElectrosphereLauncher, Do(DamageExact(44)) }, + { ItemID.DeadlySphereStaff, Do(DamageExact(50)) }, + { ItemID.DeathSickle, Do(UseMeleeSpeed, DamageExact(65), ShootSpeedExact(15f)) }, + { ItemID.DemonBow, Do(DamageExact(12)) }, + { ItemID.DemonScythe, Do(DamageExact(28)) }, + { ItemID.DyeTradersScimitar, Do(UseTurn, DamageExact(24)) }, // Exotic Scimitar { ItemID.ElfMelter, Do(ShootSpeedDelta(+5f)) }, { ItemID.EmeraldStaff, Do(DamageExact(27)) }, - { ItemID.EmpressBlade, Do(AutoReuse, DamageExact(60), UseExact(20)) }, // Terraprisma + { ItemID.EmpressBlade, Do(DamageExact(68)) }, // Terraprisma { ItemID.EnchantedBoomerang, Do(DamageExact(24)) }, { ItemID.EnchantedSword, Do(UseMeleeSpeed, DamageExact(30), ShootSpeedExact(15f)) }, { ItemID.EndlessMusketPouch, Do(DamageExact(8)) }, - { ItemID.Excalibur, Do(TrueMelee, DamageExact(220), UseExact(24)) }, + { ItemID.Excalibur, Do(TrueMelee, DamageExact(170)) }, { ItemID.FairyQueenMagicItem, Do(DamageExact(54)) }, // Nightglow { ItemID.FalconBlade, Do(UseTurn, UseExact(13)) }, { ItemID.FireworksLauncher, Do(DamageExact(50), UseExact(25)) }, // Celebration - { ItemID.Flairon, Do(DamageExact(65)) }, - { ItemID.Flamarang, Do(DamageExact(40)) }, - { ItemID.Flamelash, Do(DamageExact(40)) }, + { ItemID.Flamarang, Do(DamageExact(37)) }, + { ItemID.Flamelash, Do(DamageExact(36), ManaExact(18)) }, { ItemID.Flamethrower, Do(DamageExact(21), ShootSpeedDelta(+3f)) }, - { ItemID.FlowerofFire, Do(AutoReuse, ManaExact(7), UseRatio(0.88f), DamageRatio(0.7f)) }, // Uses ratios due to remix seed - { ItemID.FlowerofFrost, Do(AutoReuse, ManaExact(7), UseExact(22), DamageExact(70), ShootSpeedExact(14)) }, + { ItemID.FlowerofFire, Do(ManaExact(7), DamageRatio(0.78f)) }, // Uses ratios due to remix seed + { ItemID.FlowerofFrost, Do(ManaExact(7), UseExact(22), DamageExact(70), ShootSpeedExact(14)) }, { ItemID.FlyingKnife, Do(DamageExact(53)) }, { ItemID.Frostbrand, Do(UseMeleeSpeed, DamageExact(88)) }, - { ItemID.FrostStaff, Do(DamageExact(160), UseExact(37), ShootSpeedExact(20f)) }, // has 1 extra update - { ItemID.Gatligator, Do(PointBlank, UseExact(6)) }, - { ItemID.GoldCoin, Do(DamageExact(75)) }, // For Coin Gun - { ItemID.GoldShortsword, Do(AutoReuse, TrueMelee, DamageExact(17)) }, + { ItemID.Gatligator, Do(UseExact(6)) }, + { ItemID.GoldShortsword, Do(TrueMelee, DamageExact(17)) }, { ItemID.GolemFist, Do(DamageExact(150)) }, - { ItemID.Gradient, Do(AutoReuse, DamageExact(39)) }, - { ItemID.GreenPhaseblade, Do(AutoReuse, UseTurn, DamageExact(48)) }, - { ItemID.GreenPhasesaber, Do(DamageExact(132)) }, - { ItemID.GrenadeLauncher, Do(DamageExact(112)) }, - { ItemID.Gungnir, Do(AutoReuse, TrueMelee, DamageExact(144), ShootSpeedExact(7f)) }, - { ItemID.HallowedRepeater, Do(PointBlank, UseExact(12)) }, - { ItemID.Handgun, Do(PointBlank, UseExact(20)) }, - { ItemID.HellwingBow, Do(PointBlank, DamageExact(16)) }, + { ItemID.Gradient, Do(DamageExact(39)) }, + { ItemID.GreenPhaseblade, phaseblade }, + { ItemID.GreenPhasesaber, phasesaber }, + { ItemID.GrenadeLauncher, Do(DamageExact(105)) }, + { ItemID.Gungnir, Do(TrueMelee, DamageExact(130), ShootSpeedExact(7f)) }, + { ItemID.HallowedRepeater, Do(UseExact(12)) }, + { ItemID.Handgun, Do(UseExact(20)) }, { ItemID.HighVelocityBullet, Do(DamageExact(13)) }, - { ItemID.HiveFive, Do(AutoReuse, DamageExact(27)) }, - { ItemID.HornetStaff, Do(AutoReuse, DamageExact(18), UseExact(30)) }, + { ItemID.HiveFive, Do(DamageExact(27)) }, + { ItemID.HornetStaff, Do(DamageExact(18)) }, { ItemID.IceBlade, Do(UseMeleeSpeed) }, { ItemID.IceBoomerang, Do(UseExact(25), ShootSpeedExact(9)) }, - { ItemID.IceRod, Do(UseExact(6), DamageExact(30), ShootSpeedExact(20)) }, - { ItemID.IceSickle, Do(AutoReuse, UseMeleeSpeed, DamageExact(75), ShootSpeedExact(20f)) }, + { ItemID.IceRod, Do(UseExact(6), ShootSpeedExact(20)) }, + { ItemID.IceSickle, Do(UseMeleeSpeed, DamageExact(75), ShootSpeedExact(20f)) }, { ItemID.IchorArrow, Do(DamageExact(13)) }, { ItemID.IchorBullet, Do(DamageExact(11)) }, - { ItemID.ImpStaff, Do(AutoReuse, UseExact(30), DamageExact(25)) }, - { ItemID.InfernoFork, Do(DamageExact(99), ShootSpeedExact(11)) }, + { ItemID.ImpStaff, Do(DamageExact(25)) }, + { ItemID.InfernoFork, Do(DamageExact(83), ShootSpeedExact(11)) }, { ItemID.InfluxWaver, Do(UseMeleeSpeed, DamageExact(80), UseExact(25)) }, - { ItemID.IronShortsword, Do(AutoReuse, TrueMelee, DamageExact(10)) }, + { ItemID.IronShortsword, Do(TrueMelee, DamageExact(10)) }, { ItemID.Keybrand, Do(UseTurn) }, - { ItemID.Kraken, Do(AutoReuse, DamageExact(85)) }, { ItemID.KOCannon, Do(DamageRatio(2.65f)) }, // Uses ratios due to remix seed + { ItemID.Kraken, Do(DamageExact(65)) }, { ItemID.LaserMachinegun, Do(DamageExact(49)) }, { ItemID.LaserRifle, Do(DamageExact(46), UseExact(10), ManaExact(4)) }, { ItemID.LastPrism, Do(DamageExact(57), ManaExact(10)) }, - { ItemID.LeadShortsword, Do(AutoReuse, TrueMelee, DamageExact(11)) }, - { ItemID.LightDisc, Do(DamageExact(98), ShootSpeedExact(18)) }, - { ItemID.LunarFlareBook, Do(DamageExact(120)) }, + { ItemID.LeadShortsword, Do(TrueMelee, DamageExact(11)) }, + { ItemID.LeafBlower, Do(DamageExact(61)) }, + { ItemID.LightDisc, Do(DamageExact(80), ShootSpeedExact(18)) }, + { ItemID.LunarFlareBook, Do(DamageExact(110)) }, { ItemID.MagicalHarp, Do(DamageExact(50), ShootSpeedExact(12f)) }, - { ItemID.MagicDagger, Do(DamageRatio(1.8f), UseRatio(1.88f), ShootSpeedExact(30)) }, // Uses ratios due to remix seed { ItemID.MagicMissile, Do(DamageExact(23), ManaExact(10), UseAnimationExact(20), UseTimeExact(10)) }, - { ItemID.MagnetSphere, Do(DamageExact(52)) }, - { ItemID.Marrow, Do(PointBlank, DamageExact(69)) }, - { ItemID.MedusaHead, Do(ManaExact(6), DamageExact(48)) }, + { ItemID.Marrow, Do(DamageExact(60)) }, + { ItemID.MedusaHead, Do(ManaExact(6), DamageExact(75)) }, { ItemID.Meowmere, Do(UseMeleeSpeed, DamageExact(240)) }, { ItemID.MeteorStaff, Do(DamageExact(58), ManaExact(7), ShootSpeedExact(13f)) }, { ItemID.MiniNukeI, Do(DamageExact(90)) }, { ItemID.MiniNukeII, Do(DamageExact(90)) }, - { ItemID.Minishark, Do(PointBlank, DamageExact(4)) }, - { ItemID.MoltenFury, Do(PointBlank, UseExact(29), AutoReuse) }, + { ItemID.Minishark, Do(DamageExact(4)) }, + { ItemID.MoltenFury, Do(UseExact(28)) }, { ItemID.MonkStaffT1, Do(TrueMeleeNoSpeed, DamageExact(83)) }, // Sleepy Octopod - { ItemID.MonkStaffT2, Do(AutoReuse, TrueMelee, DamageExact(90)) }, // Ghastly Glaive + { ItemID.MonkStaffT2, Do(TrueMelee, DamageExact(90)) }, // Ghastly Glaive { ItemID.MonkStaffT3, Do(DamageExact(225)) }, // Sky Dragon's Fury - { ItemID.MoonlordBullet, Do(DamageExact(19)) }, // Luminite Bullet - { ItemID.MoonlordTurretStaff, Do(DamageExact(50), UseExact(15)) }, // Lunar Portal Staff + { ItemID.MoonlordBullet, Do(DamageExact(17)) }, // Luminite Bullet + { ItemID.MoonlordTurretStaff, Do(DamageExact(50)) }, // Lunar Portal Staff { ItemID.Muramasa, Do(CritDelta(+10)) }, - { ItemID.MushroomSpear, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(100)) }, - { ItemID.Musket, Do(PointBlank, DamageExact(22)) }, - { ItemID.MythrilHalberd, Do(AutoReuse, TrueMelee, DamageExact(65), UseExact(8), ShootSpeedExact(15f)) }, - { ItemID.MythrilRepeater, Do(PointBlank, UseExact(16)) }, + { ItemID.MushroomSpear, Do(TrueMelee, UseRatio(0.8f), DamageExact(100)) }, + { ItemID.Musket, Do(DamageExact(22)) }, + { ItemID.MythrilHalberd, Do(TrueMelee, DamageExact(65), UseExact(8), ShootSpeedExact(15f)) }, + { ItemID.MythrilRepeater, Do(UseExact(16)) }, { ItemID.MythrilSword, Do(UseTurn, DamageExact(70), UseExact(8)) }, - { ItemID.NettleBurst, Do(ManaExact(10), DamageExact(70)) }, + { ItemID.NailGun, Do(DamageExact(77)) }, + { ItemID.NettleBurst, Do(ManaExact(10), DamageExact(65)) }, { ItemID.NightsEdge, Do(TrueMelee, DamageExact(45)) }, - { ItemID.NorthPole, Do(AutoReuse, UseMeleeSpeed) }, - { ItemID.OrangePhaseblade, Do(AutoReuse, UseTurn, DamageExact(48)) }, - { ItemID.OrangePhasesaber, Do(DamageExact(132)) }, - { ItemID.OrichalcumHalberd, Do(AutoReuse, TrueMelee, DamageExact(128), ShootSpeedExact(6f)) }, - { ItemID.OrichalcumRepeater, Do(PointBlank, DamageExact(48)) }, + { ItemID.NorthPole, Do(UseMeleeSpeed) }, + { ItemID.OrangePhaseblade, phaseblade }, + { ItemID.OrangePhasesaber, phasesaber }, + { ItemID.OrichalcumHalberd, Do(TrueMelee, DamageExact(128), ShootSpeedExact(6f)) }, + { ItemID.OrichalcumRepeater, Do(DamageExact(48)) }, { ItemID.OrichalcumSword, Do(UseTurn, DamageExact(175)) }, - { ItemID.PainterPaintballGun, Do(PointBlank, DamageExact(8)) }, - { ItemID.PaladinsHammer, Do(DamageExact(100), ShootSpeedExact(23)) }, - { ItemID.PalladiumPike, Do(AutoReuse, TrueMelee, DamageExact(120), ShootSpeedExact(5.4f)) }, - { ItemID.PalladiumRepeater, Do(PointBlank, DamageExact(45)) }, - { ItemID.PalladiumSword, Do(UseTurn, DamageExact(150)) }, - { ItemID.PearlwoodBow, Do(AutoReuse, PointBlank, DamageExact(32)) }, + { ItemID.PaladinsHammer, Do(DamageExact(95), ShootSpeedExact(28)) }, + { ItemID.PalladiumPike, Do(TrueMelee, DamageExact(120), ShootSpeedExact(5.4f)) }, + { ItemID.PalladiumRepeater, Do(DamageExact(45)) }, + { ItemID.PalladiumSword, Do(DamageExact(150)) }, + { ItemID.PearlwoodBow, Do(DamageExact(32)) }, { ItemID.PearlwoodSword, Do(UseTurn, DamageExact(45)) }, { ItemID.PewMaticHorn, Do(DamageExact(25), ShootSpeedExact(15)) }, - { ItemID.Phantasm, Do(PointBlank, DamageExact(48)) }, - { ItemID.PhoenixBlaster, Do(AutoReuse, PointBlank, UseExact(20)) }, - { ItemID.PiranhaGun, Do(DamageExact(48)) }, - { ItemID.PlatinumBow, Do(PointBlank, DamageExact(12)) }, - { ItemID.PlatinumCoin, Do(DamageExact(150)) }, // For Coin Gun - { ItemID.PlatinumShortsword, Do(AutoReuse, TrueMelee, DamageExact(18)) }, + { ItemID.PhoenixBlaster, Do(UseExact(20)) }, + { ItemID.PlatinumShortsword, Do(TrueMelee, DamageExact(18)) }, { ItemID.PoisonStaff, Do(DamageExact(57)) }, { ItemID.PossessedHatchet, Do(DamageExact(135)) }, - { ItemID.PrincessWeapon, Do(DamageExact(90)) }, // Resonance Scepter + { ItemID.PrincessWeapon, Do(DamageExact(80)) }, // Resonance Scepter { ItemID.PsychoKnife, Do(UseTurn, UseExact(11), DamageExact(200)) }, { ItemID.PurpleClubberfish, Do(UseTurn, KnockbackExact(10f)) }, - { ItemID.PurplePhaseblade, Do(AutoReuse, UseTurn, DamageExact(48)) }, - { ItemID.PurplePhasesaber, Do(DamageExact(132)) }, - { ItemID.PygmyStaff, Do(AutoReuse, UseExact(20), DamageExact(70)) }, - { ItemID.QuadBarrelShotgun, Do(PointBlank, DamageExact(11)) }, + { ItemID.PurplePhaseblade, phaseblade }, + { ItemID.PurplePhasesaber, phasesaber }, + { ItemID.PygmyStaff, Do(DamageExact(63)) }, { ItemID.RainbowGun, Do(DamageExact(60), ManaExact(40)) }, - { ItemID.RainbowRod, Do(DamageExact(40), ManaExact(13)) }, - { ItemID.Rally, Do(AutoReuse, DamageExact(18)) }, - { ItemID.RavenStaff, Do(AutoReuse, UseExact(20), DamageExact(36)) }, + { ItemID.RainbowRod, Do(DamageExact(40), ManaExact(13), KnockbackExact(8f)) }, + { ItemID.Rally, Do(DamageExact(18)) }, + { ItemID.RavenStaff, Do(DamageExact(36)) }, { ItemID.RazorbladeTyphoon, Do(DamageExact(103)) }, { ItemID.Razorpine, Do(DamageExact(40)) }, - { ItemID.RedPhaseblade, Do(AutoReuse, UseTurn, DamageExact(48)) }, - { ItemID.RedPhasesaber, Do(DamageExact(132)) }, - { ItemID.RedRyder, Do(PointBlank, DamageExact(24)) }, - { ItemID.RedsYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats - { ItemID.RocketLauncher, Do(DamageExact(70)) }, - { ItemID.Sandgun, Do(PointBlank, DamageExact(22), UseExact(20)) }, + { ItemID.RedPhaseblade, phaseblade }, + { ItemID.RedPhasesaber, phasesaber }, + { ItemID.RedRyder, Do(DamageExact(24)) }, + { ItemID.RedsYoyo, Do(DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats + { ItemID.RocketLauncher, Do(DamageExact(60), ShootSpeedExact(9)) }, + { ItemID.Sandgun, Do(DamageExact(22), UseExact(20)) }, { ItemID.SapphireStaff, Do(DamageExact(25)) }, - { ItemID.Seedler, Do(UseMeleeSpeed, DamageExact(75), ShootSpeedDelta(+4f)) }, + { ItemID.ScourgeoftheCorruptor, Do(DamageExact(63)) }, + { ItemID.Seedler, Do(UseMeleeSpeed, DamageExact(45), ShootSpeedExact(16)) }, { ItemID.ShadowbeamStaff, Do(DamageExact(100)) }, - { ItemID.ShadowFlameBow, Do(PointBlank, DamageExact(55)) }, + { ItemID.ShadowFlameBow, Do(DamageExact(55)) }, { ItemID.ShadowFlameHexDoll, Do(DamageExact(40), ShootSpeedExact(30)) }, { ItemID.ShadowFlameKnife, Do(DamageExact(50)) }, { ItemID.SharpTears, Do(DamageExact(49)) }, // Blood Thorn - { ItemID.Shotgun, Do(PointBlank, DamageExact(36), AutoReuse) }, + { ItemID.Shotgun, Do(DamageExact(36)) }, { ItemID.Shroomerang, Do(ShootSpeedExact(11)) }, { ItemID.SilverBullet, Do(DamageExact(8)) }, - { ItemID.SilverShortsword, Do(AutoReuse, TrueMelee, DamageExact(14)) }, - { ItemID.SkyFracture, Do(DamageExact(54), ShootSpeedExact(30f)) }, + { ItemID.SilverShortsword, Do(TrueMelee, DamageExact(14)) }, + { ItemID.SkyFracture, Do(DamageExact(46)) }, { ItemID.SlapHand, Do(UseTurn, DamageExact(120)) }, - { ItemID.Smolstar, Do(DamageExact(9), AutoReuse, UseExact(25)) }, // Blade Staff - { ItemID.SniperRifle, Do(PointBlank, DamageExact(215)) }, + { ItemID.Smolstar, Do(DamageExact(9)) }, // Blade Staff + { ItemID.SniperRifle, Do(DamageExact(200), UseExact(40)) }, { ItemID.SolarEruption, Do(DamageExact(122)) }, { ItemID.SoulDrain, Do(DamageExact(38)) }, // Life Drain - { ItemID.SpaceGun, Do(DamageExact(25)) }, - { ItemID.Spear, Do(AutoReuse, TrueMelee, DamageExact(14)) }, - { ItemID.SpectreStaff, Do(DamageExact(78)) }, + { ItemID.SpaceGun, Do(DamageExact(23)) }, + { ItemID.Spear, Do(TrueMelee, DamageExact(14)) }, + { ItemID.SpectreStaff, Do(DamageExact(72)) }, { ItemID.SpiritFlame, Do(UseExact(20), ManaExact(11), ShootSpeedExact(2f)) }, { ItemID.StaffofEarth, Do(DamageExact(150)) }, - { ItemID.StarCannon, Do(DamageExact(25)) }, - { ItemID.StardustDragonStaff, Do(AutoReuse, DamageExact(20), UseExact(19)) }, - { ItemID.StormTigerStaff, Do(AutoReuse, DamageExact(49), UseExact(20)) }, // Desert Tiger Staff - { ItemID.StylistKilLaKillScissorsIWish, Do(AutoReuse, UseTurn, DamageExact(21)) }, // Stylish Scissors + { ItemID.StarCannon, Do(UseExact(18)) }, + { ItemID.StardustDragonStaff, Do(DamageExact(20)) }, + { ItemID.StormTigerStaff, Do(DamageExact(49)) }, // Desert Tiger Staff + { ItemID.StylistKilLaKillScissorsIWish, Do(UseTurn, DamageExact(21)) }, // Stylish Scissors { ItemID.Stynger, Do(DamageExact(75)) }, - { ItemID.Swordfish, Do(AutoReuse, TrueMelee, DamageExact(24)) }, - { ItemID.TacticalShotgun, Do(PointBlank, DamageExact(41)) }, - { ItemID.TaxCollectorsStickOfDoom, Do(AutoReuse, UseTurn, UseRatio(0.8f), DamageExact(70)) }, // Classy Cane - { ItemID.TendonBow, Do(PointBlank, DamageExact(17), AutoReuse) }, - { ItemID.TerraBlade, Do(DamageExact(92)) }, + { ItemID.SuperStarCannon, Do(DamageExact(55)) }, + { ItemID.Swordfish, Do(TrueMelee, DamageExact(24)) }, + { ItemID.TacticalShotgun, Do(DamageExact(34)) }, + { ItemID.TaxCollectorsStickOfDoom, Do(UseTurn, UseRatio(0.8f), DamageExact(70)) }, // Classy Cane + { ItemID.TendonBow, Do(DamageExact(17)) }, + { ItemID.TerraBlade, Do(DamageExact(95)) }, { ItemID.Terragrim, Do(TrueMeleeNoSpeed, DamageExact(13)) }, // Vanilla damage 190. After fixing iframes so yoyo and shots can hit simultaneously, // Terrarian is extremely overpowered and requires a heavy nerf. - { ItemID.Terrarian, Do(AutoReuse, DamageExact(90)) }, - { ItemID.TheEyeOfCthulhu, Do(AutoReuse, DamageExact(90)) }, + { ItemID.Terrarian, Do(DamageExact(90)) }, + { ItemID.TheEyeOfCthulhu, Do(DamageExact(80)) }, { ItemID.TheMeatball, Do(DamageExact(24)) }, - { ItemID.TheRottedFork, Do(AutoReuse, TrueMelee, DamageExact(20)) }, - { ItemID.TheUndertaker, Do(PointBlank, AutoReuse, DamageExact(15)) }, - { ItemID.ThunderSpear, Do(AutoReuse, UseMeleeSpeed) }, // Storm Spear + { ItemID.TheRottedFork, Do(TrueMelee, DamageExact(20)) }, + { ItemID.TheUndertaker, Do(DamageExact(15)) }, + { ItemID.ThunderSpear, Do(UseMeleeSpeed) }, // Storm Spear { ItemID.ThunderStaff, Do(DamageExact(18)) }, //Thunder Zapper - { ItemID.TitaniumRepeater, Do(PointBlank, DamageExact(52)) }, + { ItemID.TitaniumRepeater, Do(DamageExact(52)) }, { ItemID.TitaniumSword, Do(UseTurn, DamageExact(192)) }, - { ItemID.TitaniumTrident, Do(AutoReuse, TrueMelee, DamageExact(144), ShootSpeedExact(6.5f)) }, + { ItemID.TitaniumTrident, Do(TrueMelee, DamageExact(144), ShootSpeedExact(6.5f)) }, { ItemID.TopazStaff, Do(ManaExact(2)) }, + { ItemID.ToxicFlask, Do(DamageExact(62), UseExact(33), ManaExact(20)) }, { ItemID.Toxikarp, Do(UseExact(9)) }, - { ItemID.Trident, Do(AutoReuse, TrueMelee, DamageExact(20)) }, + { ItemID.Trident, Do(TrueMelee, DamageExact(20)) }, { ItemID.Trimarang, Do(DamageExact(24)) }, { ItemID.TrueExcalibur, Do(TrueMelee, DamageExact(112)) }, { ItemID.TrueNightsEdge, Do(DamageExact(105)) }, - { ItemID.Tsunami, Do(PointBlank, DamageExact(45)) }, + { ItemID.Tsunami, Do(DamageExact(45)) }, { ItemID.TungstenBullet, Do(DamageExact(8)) }, - { ItemID.TungstenShortsword, Do(AutoReuse, TrueMelee, DamageExact(15)) }, + { ItemID.TungstenShortsword, Do(TrueMelee, DamageExact(15)) }, { ItemID.UnholyArrow, Do(DamageExact(11)) }, { ItemID.UnholyTrident, Do(ManaRatio(0.78f), DamageRatio(0.91f)) }, // Uses ratios due to remix seed + { ItemID.Uzi, Do(UseExact(8)) }, { ItemID.VampireKnives, Do(DamageExact(38)) }, - { ItemID.ValkyrieYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats - { ItemID.VenomStaff, Do(DamageExact(55)) }, - { ItemID.VenusMagnum, Do(PointBlank, DamageExact(65)) }, - { ItemID.WaspGun, Do(UseExact(11), DamageExact(58)) }, + { ItemID.ValkyrieYoyo, Do(DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats + { ItemID.VenomStaff, Do(UseExact(27)) }, + { ItemID.WaspGun, Do(DamageExact(44)) }, { ItemID.WaterBolt, Do(DamageExact(23)) }, - { ItemID.WhitePhaseblade, Do(AutoReuse, UseTurn, DamageExact(48)) }, - { ItemID.WhitePhasesaber, Do(DamageExact(132)) }, + { ItemID.WhitePhaseblade, phaseblade }, + { ItemID.WhitePhasesaber, phasesaber }, { ItemID.WoodenBoomerang, Do(DamageExact(16), Value(Item.sellPrice(copper: 20))) }, - { ItemID.Yelets, Do(AutoReuse, DamageExact(53)) }, - { ItemID.YellowPhaseblade, Do(AutoReuse, UseTurn, DamageExact(48)) }, - { ItemID.YellowPhasesaber, Do(DamageExact(132)) }, + { ItemID.Yelets, Do(DamageExact(53)) }, + { ItemID.YellowPhaseblade, phaseblade }, + { ItemID.YellowPhasesaber, phasesaber }, { ItemID.Zenith, Do(DamageExact(210)) }, - { ItemID.ZombieArm, Do(AutoReuse, UseTurn, KnockbackExact(12f)) }, + { ItemID.ZombieArm, Do(UseTurn, KnockbackExact(12f)) }, #endregion #region CATEGORY 2: Defense Balancing - { ItemID.AncientHallowedGreaves, Do(DefenseDelta(+2)) }, - { ItemID.AncientHallowedPlateMail, Do(DefenseDelta(+3)) }, - { ItemID.AnkhShield, Do(DefenseDelta(+4)) }, // 8 total - { ItemID.CobaltShield, Do(DefenseDelta(+3)) }, // 4 total - { ItemID.EoCShield, Do(DefenseDelta(+1)) }, // Shield of Cthulhu - { ItemID.FrozenShield, Do(DefenseDelta(+4)) }, // 10 total (plus the Frozen Turtle Shell DR effect) - { ItemID.FrozenTurtleShell, Do(DefenseExact(6)) }, - { ItemID.HallowedGreaves, Do(DefenseDelta(+2)) }, - { ItemID.HallowedPlateMail, Do(DefenseDelta(+3)) }, - { ItemID.HeroShield, Do(DefenseDelta(+5)) }, // 15 total (plus increased max life) - { ItemID.LavaSkull, Do(DefenseExact(4)) }, // Magma Skull - { ItemID.MoltenCharm, Do(DefenseExact(4)) }, //Magma Charm - { ItemID.MoltenSkullRose, Do(DefenseExact(8)) }, - { ItemID.ObsidianShield, Do(DefenseDelta(+4)) }, // 6 total - { ItemID.ObsidianSkull, Do(DefenseDelta(+1)) }, // 2 total - { ItemID.ObsidianSkullRose, Do(DefenseExact(4)) }, - { ItemID.OrichalcumBreastplate, Do(DefenseDelta(+3)) }, - { ItemID.OrichalcumHeadgear, Do(DefenseDelta(+2)) }, - { ItemID.OrichalcumHelmet, Do(DefenseDelta(+3)) }, - { ItemID.OrichalcumLeggings, Do(DefenseDelta(+4)) }, - { ItemID.OrichalcumMask, Do(DefenseDelta(+3)) }, - { ItemID.PaladinsShield, Do(DefenseDelta(+2)) }, // 8 total - { ItemID.PalladiumBreastplate, Do(DefenseDelta(+3)) }, - { ItemID.PalladiumHeadgear, Do(DefenseDelta(+2)) }, - { ItemID.PalladiumHelmet, Do(DefenseDelta(+3)) }, - { ItemID.PalladiumMask, Do(DefenseDelta(+1)) }, - { ItemID.PalladiumLeggings, Do(DefenseDelta(+3)) }, - { ItemID.Shackle, Do(DefenseDelta(+2)) }, // 3 total - { ItemID.SquireAltHead, Do(DefenseDelta(-2)) }, + { ItemID.LavaSkull, Do(DefenseExact(3)) }, // Magma Skull + { ItemID.MoltenCharm, Do(DefenseExact(3)) }, //Magma Charm + { ItemID.MoltenSkullRose, Do(DefenseExact(4)) }, + { ItemID.ObsidianSkull, Do(DefenseExact(2)) }, + { ItemID.ObsidianSkullRose, Do(DefenseExact(3)) }, + { ItemID.Shackle, Do(DefenseExact(3)) }, + { ItemID.SquireAltHead, Do(DefenseDelta(-2)) }, // Valhalla Knight set { ItemID.SquireAltPants, Do(DefenseDelta(-3)) }, { ItemID.SquireAltShirt, Do(DefenseDelta(-3)) }, { ItemID.SquireGreatHelm, Do(DefenseDelta(-1)) }, @@ -332,292 +303,162 @@ namespace CalamityMod.Items #endregion #region CATEGORY 3: Tool Balancing - { ItemID.AcornAxe, Do(AxePower(125)) }, // Axe of Regrowth - { ItemID.AdamantiteChainsaw, Do(TrueMeleeNoSpeed, AxePower(90), UseTimeExact(4), TileBoostExact(+0), DamageExact(75)) }, - { ItemID.AdamantiteDrill, Do(TrueMeleeNoSpeed, PickPower(180), UseTimeExact(4), TileBoostExact(+1), DamageExact(32)) }, - { ItemID.AdamantitePickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, + { ItemID.AcornAxe, Do(AxePower(100)) }, // Axe of Regrowth + { ItemID.AdamantiteChainsaw, Do(TrueMeleeNoSpeed, AxePower(90), TileBoostExact(+0), DamageExact(75)) }, + { ItemID.AdamantiteDrill, Do(TrueMeleeNoSpeed, TileBoostExact(+1), DamageExact(32)) }, + { ItemID.AdamantitePickaxe, Do(TileBoostExact(+1)) }, { ItemID.AdamantiteWaraxe, Do(AxePower(160), UseTimeExact(10), TileBoostExact(+1)) }, - { ItemID.BloodLustCluster, Do(AxePower(100), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.BonePickaxe, Do(PickPower(55), UseTimeExact(6)) }, - { ItemID.BorealWoodHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.ButchersChainsaw, Do(TrueMeleeNoSpeed, AxePower(150), UseTimeExact(3), TileBoostExact(+0)) }, + { ItemID.BloodLustCluster, Do(AxePower(100), UseTimeExact(13)) }, + { ItemID.BonePickaxe, Do(UseTimeExact(6)) }, + { ItemID.BorealWoodHammer, Do(HammerPower(25), UseTimeExact(11)) }, + { ItemID.ButchersChainsaw, Do(TrueMeleeNoSpeed, UseTimeExact(3), TileBoostExact(+0)) }, { ItemID.CactusPickaxe, Do(PickPower(34), UseTimeExact(9)) }, - { ItemID.CnadyCanePickaxe, Do(PickPower(55), UseTimeExact(9), TileBoostExact(+1)) }, // Candy Cane Pickaxe - { ItemID.ChlorophyteChainsaw, Do(TrueMeleeNoSpeed, AxePower(120), UseTimeExact(3), TileBoostExact(+0), DamageExact(112)) }, - { ItemID.ChlorophyteDrill, Do(TrueMeleeNoSpeed, PickPower(200), UseTimeExact(4), TileBoostExact(+2), DamageExact(43)) }, - { ItemID.ChlorophyteGreataxe, Do(AxePower(165), UseTimeExact(7), TileBoostExact(+2)) }, - { ItemID.ChlorophyteJackhammer, Do(TrueMeleeNoSpeed, HammerPower(90), UseTimeExact(5), TileBoostExact(+0)) }, - { ItemID.ChlorophytePickaxe, Do(PickPower(200), UseTimeExact(7), TileBoostExact(+2)) }, - { ItemID.ChlorophyteWarhammer, Do(HammerPower(90), UseTimeExact(8), TileBoostExact(+2)) }, - { ItemID.CobaltChainsaw, Do(TrueMeleeNoSpeed, AxePower(70), UseTimeExact(4), TileBoostExact(-1), DamageExact(51)) }, + { ItemID.CnadyCanePickaxe, Do(UseTimeExact(9), TileBoostExact(+1)) }, // Candy Cane Pickaxe + { ItemID.ChlorophyteChainsaw, Do(TrueMeleeNoSpeed, AxePower(120), UseTimeExact(3), DamageExact(112)) }, + { ItemID.ChlorophyteDrill, Do(TrueMeleeNoSpeed, TileBoostExact(+2), DamageExact(43)) }, + { ItemID.ChlorophyteGreataxe, Do(AxePower(165), TileBoostExact(+2)) }, + { ItemID.ChlorophyteJackhammer, Do(TrueMeleeNoSpeed, UseTimeExact(5)) }, + { ItemID.ChlorophytePickaxe, Do(TileBoostExact(+2)) }, + { ItemID.ChlorophyteWarhammer, Do(UseTimeExact(8), TileBoostExact(+2)) }, + { ItemID.CobaltChainsaw, Do(TrueMeleeNoSpeed, UseTimeExact(4), DamageExact(51)) }, { ItemID.CobaltDrill, Do(TrueMeleeNoSpeed, PickPower(130), UseTimeExact(5), DamageExact(21)) }, { ItemID.CobaltPickaxe, Do(PickPower(130), UseTimeExact(9)) }, - { ItemID.CobaltWaraxe, Do(AxePower(125), UseTimeExact(12), TileBoostExact(+0)) }, + { ItemID.CobaltWaraxe, Do(AxePower(125), UseTimeExact(12)) }, { ItemID.CopperAxe, Do(AxePower(50), UseTimeExact(16), TileBoostExact(+0)) }, - { ItemID.CopperHammer, Do(HammerPower(35), UseTimeExact(12), TileBoostExact(+0)) }, - { ItemID.CopperPickaxe, Do(PickPower(35), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.DeathbringerPickaxe, Do(PickPower(70), UseTimeExact(10)) }, - { ItemID.Drax, Do(TrueMeleeNoSpeed, PickPower(200), AxePower(110), UseTimeExact(4), TileBoostExact(+1), DamageExact(80)) }, - { ItemID.EbonwoodHammer, Do(HammerPower(25), UseTimeExact(9), TileBoostExact(+0)) }, - { ItemID.FleshGrinder, Do(HammerPower(70), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.GoldAxe, Do(AxePower(80), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.GoldHammer, Do(HammerPower(60), UseTimeExact(9), TileBoostExact(+0)) }, - { ItemID.GoldPickaxe, Do(PickPower(55), UseTimeExact(9)) }, - { ItemID.Hammush, Do(HammerPower(85), UseTimeExact(10), TileBoostExact(+1)) }, - { ItemID.IronAxe, Do(AxePower(60), UseTimeExact(15), TileBoostExact(+0)) }, - { ItemID.IronHammer, Do(HammerPower(45), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.IronPickaxe, Do(PickPower(40), UseTimeExact(8)) }, + { ItemID.CopperHammer, Do(UseTimeExact(12), TileBoostExact(+0)) }, + { ItemID.CopperPickaxe, Do(UseTimeExact(10), TileBoostExact(+0)) }, + { ItemID.DeathbringerPickaxe, Do(UseTimeExact(10)) }, + { ItemID.Drax, Do(TrueMeleeNoSpeed, TileBoostExact(+1), DamageExact(80)) }, + { ItemID.EbonwoodHammer, Do(HammerPower(25), UseTimeExact(9)) }, + { ItemID.FleshGrinder, Do(HammerPower(70), UseTimeExact(13)) }, + { ItemID.GoldAxe, Do(AxePower(80), UseTimeExact(14)) }, + { ItemID.GoldHammer, Do(HammerPower(60), UseTimeExact(9)) }, + { ItemID.GoldPickaxe, Do(UseTimeExact(9)) }, + { ItemID.Hammush, Do(UseTimeExact(10), TileBoostExact(+1)) }, + { ItemID.IronAxe, Do(AxePower(60), UseTimeExact(15)) }, + { ItemID.IronHammer, Do(HammerPower(45), UseTimeExact(11)) }, + { ItemID.IronPickaxe, Do(UseTimeExact(8)) }, { ItemID.LaserDrill, Do(PickPower(220), AxePower(120), UseTimeExact(4), DamageExact(54)) }, - { ItemID.LeadAxe, Do(AxePower(60), UseTimeExact(15), TileBoostExact(+0)) }, - { ItemID.LeadHammer, Do(HammerPower(45), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.LeadAxe, Do(AxePower(60), UseTimeExact(15)) }, + { ItemID.LeadHammer, Do(HammerPower(45), UseTimeExact(11)) }, { ItemID.LeadPickaxe, Do(PickPower(40), UseTimeExact(8)) }, - { ItemID.LucyTheAxe, Do(AxePower(150), UseExact(13), TileBoostExact(+1)) }, - { ItemID.LunarHamaxeNebula, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.LunarHamaxeSolar, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.LunarHamaxeStardust, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.LunarHamaxeVortex, Do(HammerPower(100), AxePower(175), UseTimeExact(5), TileBoostExact(+4)) }, - { ItemID.MeteorHamaxe, Do(HammerPower(70), AxePower(100), UseTimeExact(16), TileBoostExact(+0)) }, - { ItemID.MoltenHamaxe, Do(HammerPower(75), AxePower(125), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.MoltenPickaxe, Do(PickPower(100), UseTimeExact(10)) }, - { ItemID.MythrilChainsaw, Do(TrueMeleeNoSpeed, AxePower(80), UseTimeExact(4), TileBoostExact(-1), DamageExact(63)) }, + { ItemID.LucyTheAxe, Do(UseExact(13), TileBoostExact(+1)) }, + { ItemID.LunarHamaxeNebula, Do(AxePower(175), UseTimeExact(5)) }, + { ItemID.LunarHamaxeSolar, Do(AxePower(175), UseTimeExact(5)) }, + { ItemID.LunarHamaxeStardust, Do(AxePower(175), UseTimeExact(5)) }, + { ItemID.LunarHamaxeVortex, Do(AxePower(175), UseTimeExact(5)) }, + { ItemID.MeteorHamaxe, Do(HammerPower(70)) }, + { ItemID.MoltenHamaxe, Do(HammerPower(75), AxePower(125)) }, + { ItemID.MoltenPickaxe, Do(UseTimeExact(10)) }, + { ItemID.MythrilChainsaw, Do(TrueMeleeNoSpeed, AxePower(80), UseTimeExact(4), DamageExact(63)) }, { ItemID.MythrilDrill, Do(TrueMeleeNoSpeed, PickPower(160), UseTimeExact(4), DamageExact(26)) }, { ItemID.MythrilPickaxe, Do(PickPower(160), UseTimeExact(8)) }, - { ItemID.MythrilWaraxe, Do(AxePower(140), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.NebulaDrill, Do(TrueMeleeNoSpeed, PickPower(225), UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, - { ItemID.NebulaPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, + { ItemID.MythrilWaraxe, Do(AxePower(140), UseTimeExact(11)) }, + { ItemID.NebulaDrill, Do(TrueMeleeNoSpeed, UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, { ItemID.NightmarePickaxe, Do(PickPower(66), UseTimeExact(9)) }, - { ItemID.OrichalcumChainsaw, Do(TrueMeleeNoSpeed, AxePower(80), UseTimeExact(4), TileBoostExact(-1), DamageExact(63)) }, + { ItemID.OrichalcumChainsaw, Do(TrueMeleeNoSpeed, AxePower(80), UseTimeExact(4), DamageExact(63)) }, { ItemID.OrichalcumDrill, Do(TrueMeleeNoSpeed, PickPower(160), UseTimeExact(4), DamageExact(26)) }, { ItemID.OrichalcumPickaxe, Do(PickPower(160), UseTimeExact(8)) }, - { ItemID.OrichalcumWaraxe, Do(AxePower(140), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.PalladiumChainsaw, Do(TrueMeleeNoSpeed, AxePower(70), UseTimeExact(4), TileBoostExact(-1), DamageExact(51)) }, - { ItemID.PalladiumDrill, Do(TrueMeleeNoSpeed, PickPower(130), UseTimeExact(5), DamageExact(21)) }, - { ItemID.PalladiumPickaxe, Do(PickPower(130), UseTimeExact(9)) }, - { ItemID.PalladiumWaraxe, Do(AxePower(125), UseTimeExact(12), TileBoostExact(+0)) }, - { ItemID.PalmWoodHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, - { ItemID.PearlwoodHammer, Do(HammerPower(25), UseTimeExact(4), UseAnimationExact(20), DamageExact(36), TileBoostExact(+0)) }, - { ItemID.PickaxeAxe, Do(PickPower(200), AxePower(110), UseTimeExact(7), TileBoostExact(+1)) }, - { ItemID.Picksaw, Do(PickPower(210), AxePower(125), UseTimeExact(6), TileBoostExact(+1)) }, - { ItemID.PlatinumAxe, Do(AxePower(80), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.PlatinumHammer, Do(HammerPower(60), UseTimeExact(9), TileBoostExact(+0)) }, + { ItemID.OrichalcumWaraxe, Do(AxePower(140), UseTimeExact(11)) }, + { ItemID.PalladiumChainsaw, Do(TrueMeleeNoSpeed, AxePower(70), UseTimeExact(4), DamageExact(51)) }, + { ItemID.PalladiumDrill, Do(TrueMeleeNoSpeed, UseTimeExact(5), DamageExact(21)) }, + { ItemID.PalladiumPickaxe, Do(UseTimeExact(9)) }, + { ItemID.PalladiumWaraxe, Do(AxePower(125)) }, + { ItemID.PalmWoodHammer, Do(HammerPower(25), UseTimeExact(11)) }, + { ItemID.PearlwoodHammer, Do(HammerPower(25), UseTimeExact(4), UseAnimationExact(20), DamageExact(36)) }, + { ItemID.PickaxeAxe, Do(TileBoostExact(+1)) }, + { ItemID.PlatinumAxe, Do(AxePower(80), UseTimeExact(14)) }, + { ItemID.PlatinumHammer, Do(HammerPower(60), UseTimeExact(9)) }, { ItemID.PlatinumPickaxe, Do(PickPower(55), UseTimeExact(9)) }, - { ItemID.Pwnhammer, Do(HammerPower(80), UseTimeExact(11), TileBoostExact(+1)) }, - { ItemID.ReaverShark, Do(PickPower(65), UseTimeExact(16)) }, - { ItemID.RichMahoganyHammer, Do(HammerPower(25), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.Rockfish, Do(HammerPower(50), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.SawtoothShark, Do(TrueMeleeNoSpeed, AxePower(45), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.ShadewoodHammer, Do(HammerPower(25), UseTimeExact(9), TileBoostExact(+0)) }, - { ItemID.ShroomiteDiggingClaw, Do(PickPower(200), AxePower(125), UseTimeExact(4), TileBoostExact(-1)) }, - { ItemID.SilverAxe, Do(AxePower(70), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.SilverHammer, Do(HammerPower(55), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.SilverPickaxe, Do(PickPower(50), UseTimeExact(11)) }, - { ItemID.SolarFlareDrill, Do(TrueMeleeNoSpeed, PickPower(225), UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, - { ItemID.SolarFlarePickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, - { ItemID.SpectreHamaxe, Do(HammerPower(90), AxePower(170), TileBoostExact(+4)) }, - { ItemID.SpectrePickaxe, Do(PickPower(200), TileBoostExact(+4)) }, - { ItemID.StardustDrill, Do(TrueMeleeNoSpeed, PickPower(225), UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, - { ItemID.StardustPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, - { ItemID.TheAxe, Do(HammerPower(100), AxePower(175), UseTimeExact(7), TileBoostExact(+1)) }, - { ItemID.TheBreaker, Do(HammerPower(70), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.TinAxe, Do(AxePower(50), UseTimeExact(16), TileBoostExact(+0)) }, - { ItemID.TinHammer, Do(HammerPower(35), UseTimeExact(12), TileBoostExact(+0)) }, - { ItemID.TinPickaxe, Do(PickPower(35), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.TitaniumChainsaw, Do(TrueMeleeNoSpeed, AxePower(90), UseTimeExact(4), TileBoostExact(+0), DamageExact(75)) }, - { ItemID.TitaniumDrill, Do(TrueMeleeNoSpeed, PickPower(180), UseTimeExact(4), TileBoostExact(+1), DamageExact(32)) }, + { ItemID.Pwnhammer, Do(UseTimeExact(11), TileBoostExact(+1)) }, + { ItemID.RichMahoganyHammer, Do(HammerPower(25), UseTimeExact(10)) }, + { ItemID.Rockfish, Do(HammerPower(50), UseTimeExact(10)) }, + { ItemID.SawtoothShark, Do(TrueMeleeNoSpeed, AxePower(45)) }, + { ItemID.ShadewoodHammer, Do(HammerPower(25), UseTimeExact(9)) }, + { ItemID.SilverAxe, Do(AxePower(70), UseTimeExact(14)) }, + { ItemID.SilverHammer, Do(HammerPower(55), UseTimeExact(10)) }, + { ItemID.SilverPickaxe, Do(PickPower(50)) }, + { ItemID.SolarFlareDrill, Do(TrueMeleeNoSpeed, UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, + { ItemID.SpectreHamaxe, Do(AxePower(170), TileBoostExact(+4)) }, + { ItemID.SpectrePickaxe, Do(TileBoostExact(+4)) }, + { ItemID.StardustDrill, Do(TrueMeleeNoSpeed, UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, + { ItemID.TheBreaker, Do(HammerPower(70), UseTimeExact(13)) }, + { ItemID.TinAxe, Do(AxePower(50), UseTimeExact(16)) }, + { ItemID.TinHammer, Do(HammerPower(35), UseTimeExact(12)) }, + { ItemID.TinPickaxe, Do(UseTimeExact(10)) }, + { ItemID.TitaniumChainsaw, Do(TrueMeleeNoSpeed, AxePower(90), TileBoostExact(+0), DamageExact(75)) }, + { ItemID.TitaniumDrill, Do(TrueMeleeNoSpeed, PickPower(180), TileBoostExact(+1), DamageExact(32)) }, { ItemID.TitaniumPickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, { ItemID.TitaniumWaraxe, Do(AxePower(160), UseTimeExact(10), TileBoostExact(+1)) }, - { ItemID.TungstenAxe, Do(AxePower(70), UseTimeExact(14), TileBoostExact(+0)) }, - { ItemID.TungstenHammer, Do(HammerPower(55), UseTimeExact(10), TileBoostExact(+0)) }, - { ItemID.TungstenPickaxe, Do(PickPower(50), UseTimeExact(11)) }, - { ItemID.VortexDrill, Do(TrueMeleeNoSpeed, PickPower(225), UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, - { ItemID.VortexPickaxe, Do(PickPower(225), UseTimeExact(6), TileBoostExact(+4)) }, - { ItemID.WarAxeoftheNight, Do(AxePower(100), UseTimeExact(13), TileBoostExact(+0)) }, - { ItemID.WoodenHammer, Do(HammerPower(25), UseTimeExact(11), TileBoostExact(+0)) }, + { ItemID.TungstenAxe, Do(AxePower(70), UseTimeExact(14)) }, + { ItemID.TungstenHammer, Do(HammerPower(55), UseTimeExact(10)) }, + { ItemID.TungstenPickaxe, Do(UseTimeExact(11)) }, + { ItemID.VortexDrill, Do(TrueMeleeNoSpeed, UseTimeExact(3), TileBoostExact(+4), DamageExact(95)) }, + { ItemID.WarAxeoftheNight, Do(AxePower(100), UseTimeExact(13)) }, + { ItemID.WoodenHammer, Do(UseTimeExact(11), TileBoostExact(+0)) }, #endregion #region CATEGORY 4: True Melee support { ItemID.Arkhalis, trueMeleeNoSpeed }, - { ItemID.CopperShortsword, Do(AutoReuse, TrueMelee) }, - { ItemID.Gladius, Do(AutoReuse, TrueMelee) }, + { ItemID.CopperShortsword, trueMelee }, + { ItemID.Gladius, trueMelee }, { ItemID.HallowJoustingLance, trueMelee }, { ItemID.JoustingLance, trueMelee }, { ItemID.NebulaChainsaw, trueMeleeNoSpeed }, - { ItemID.ObsidianSwordfish, Do(AutoReuse, TrueMelee) }, + { ItemID.ObsidianSwordfish, trueMelee }, { ItemID.PiercingStarlight, trueMelee }, // Starlight { ItemID.Ruler, trueMelee }, { ItemID.ShadowJoustingLance, trueMelee }, { ItemID.SolarFlareChainsaw, trueMeleeNoSpeed }, { ItemID.StardustChainsaw, trueMeleeNoSpeed }, { ItemID.TheHorsemansBlade, trueMelee }, - { ItemID.TinShortsword, Do(AutoReuse, TrueMelee) }, + { ItemID.TinShortsword, trueMelee }, { ItemID.VortexChainsaw, trueMeleeNoSpeed }, #endregion - #region CATEGORY 5: Point Blank support - { ItemID.Blowpipe, pointBlank }, - { ItemID.BorealWoodBow, pointBlank }, - { ItemID.ChlorophyteShotbow, pointBlank }, - { ItemID.CopperBow, pointBlank }, - { ItemID.DartPistol, pointBlank }, - { ItemID.DD2PhoenixBow, pointBlank }, // Phantom Phoenix - { ItemID.EbonwoodBow, pointBlank }, - { ItemID.FairyQueenRangedItem, pointBlank }, //Eventide - { ItemID.FlintlockPistol, pointBlank }, - { ItemID.FlareGun, Do(PointBlank, Value(Item.sellPrice(silver: 10))) }, - { ItemID.GoldBow, pointBlank }, - { ItemID.Harpoon, pointBlank }, - { ItemID.IceBow, pointBlank }, - { ItemID.IronBow, pointBlank }, - { ItemID.LeadBow, pointBlank }, - { ItemID.Megashark, pointBlank }, - { ItemID.OnyxBlaster, pointBlank }, - { ItemID.PalmWoodBow, pointBlank }, - { ItemID.PulseBow, pointBlank }, - { ItemID.Revolver, Do(PointBlank, AutoReuse) }, - { ItemID.RichMahoganyBow, pointBlank }, - { ItemID.SDMG, pointBlank }, - { ItemID.ShadewoodBow, pointBlank }, - { ItemID.SilverBow, pointBlank }, - { ItemID.SnowballCannon, pointBlank }, - { ItemID.StakeLauncher, pointBlank }, - { ItemID.TinBow, pointBlank }, - { ItemID.TungstenBow, pointBlank }, - { ItemID.Uzi, pointBlank }, - { ItemID.VortexBeater, pointBlank }, - { ItemID.WoodenBow, pointBlank }, + #region CATEGORY 5: UseTurn + { ItemID.BladeofGrass, Do(UseTurn) }, + { ItemID.BloodButcherer, Do(UseTurn) }, + { ItemID.BorealWoodSword, Do(UseTurn) }, + { ItemID.CactusSword, Do(UseTurn) }, + { ItemID.CandyCaneSword, Do(UseTurn) }, + { ItemID.CopperBroadsword, Do(UseTurn) }, + { ItemID.EbonwoodSword, Do(UseTurn) }, + { ItemID.FieryGreatsword, Do(UseTurn) }, // Volcano + { ItemID.GoldBroadsword, Do(UseTurn) }, + { ItemID.IronBroadsword, Do(UseTurn) }, + { ItemID.LeadBroadsword, Do(UseTurn) }, + { ItemID.LightsBane, Do(UseTurn) }, + { ItemID.PalmWoodSword, Do(UseTurn) }, + { ItemID.PlatinumBroadsword, Do(UseTurn) }, + { ItemID.RichMahoganySword, Do(UseTurn) }, + { ItemID.ShadewoodSword, Do(UseTurn) }, + { ItemID.SilverBroadsword, Do(UseTurn) }, + { ItemID.TinBroadsword, Do(UseTurn) }, + { ItemID.TungstenBroadsword, Do(UseTurn) }, + { ItemID.WoodenSword, Do(UseTurn) }, #endregion - #region CATEGORY 6: Summoner Quality of Life - { ItemID.AbigailsFlower, autoReuse }, - { ItemID.BabyBirdStaff, Do(AutoReuse, UseExact(35)) }, // Finch Staff - { ItemID.BlandWhip, autoReuse }, // Leather Whip - { ItemID.BoneWhip, autoReuse }, // Spinal Tap - { ItemID.CoolWhip, autoReuse }, - { ItemID.DD2BallistraTowerT1Popper, autoReuse }, // Ballista Tier 1 - { ItemID.DD2BallistraTowerT2Popper, Do(AutoReuse, UseExact(25)) }, // Ballista Tier 2 - { ItemID.DD2BallistraTowerT3Popper, Do(AutoReuse, UseExact(20)) }, // Ballista Tier 3 - { ItemID.DD2ExplosiveTrapT1Popper, autoReuse }, // Explosive Trap Tier 1 - { ItemID.DD2ExplosiveTrapT2Popper, Do(AutoReuse, UseExact(25)) }, // Explosive Trap Tier 2 - { ItemID.DD2ExplosiveTrapT3Popper, Do(AutoReuse, UseExact(20)) }, // Explosive Trap Tier 3 - { ItemID.DD2FlameburstTowerT1Popper, autoReuse }, // Flameburst Tier 1 - { ItemID.DD2FlameburstTowerT2Popper, Do(AutoReuse, UseExact(25)) }, // Flameburst Tier 2 - { ItemID.DD2FlameburstTowerT3Popper, Do(AutoReuse, UseExact(20)) }, // Flameburst Tier 3 - { ItemID.DD2LightningAuraT1Popper, autoReuse }, // Lightning Aura Tier 1 - { ItemID.DD2LightningAuraT2Popper, Do(AutoReuse, UseExact(25)) }, // Lightning Aura Tier 2 - { ItemID.DD2LightningAuraT3Popper, Do(AutoReuse, UseExact(20)) }, // Lightning Aura Tier 3 - { ItemID.DeadlySphereStaff, Do(AutoReuse, UseExact(20)) }, - { ItemID.FireWhip, autoReuse }, // Firecracker - { ItemID.FlinxStaff, Do(AutoReuse, UseExact(35)) }, - { ItemID.MaceWhip, autoReuse }, // Morning Star - { ItemID.OpticStaff, Do(AutoReuse, UseExact(25)) }, - { ItemID.PirateStaff, Do(AutoReuse, UseExact(25)) }, - { ItemID.QueenSpiderStaff, Do(UseExact(25)) }, - { ItemID.RainbowCrystalStaff, Do(UseExact(15)) }, - { ItemID.RainbowWhip, autoReuse }, // Kaleidoscope - { ItemID.SanguineStaff, Do(AutoReuse, UseExact(25)) }, - { ItemID.ScytheWhip, autoReuse }, // Dark Harvest - { ItemID.SlimeStaff, Do(AutoReuse, UseExact(30)) }, - { ItemID.SpiderStaff, Do(AutoReuse, UseExact(25)) }, - { ItemID.StaffoftheFrostHydra, Do(UseExact(20)) }, - { ItemID.StardustCellStaff, Do(AutoReuse, UseExact(20)) }, - { ItemID.SwordWhip, autoReuse }, // Durendal - { ItemID.TempestStaff, Do(AutoReuse, UseExact(20)) }, - { ItemID.ThornWhip, autoReuse }, // Snapthorn - { ItemID.VampireFrogStaff, Do(AutoReuse, UseExact(30)) }, - { ItemID.XenoStaff, Do(AutoReuse, UseExact(20)) }, - #endregion - - #region CATEGORY 7: Other Quality of Life (AutoReuse / UseTurn) - { ItemID.Amarok, autoReuse }, - { ItemID.BatBat, autoReuse }, - { ItemID.BladeofGrass, Do(AutoReuse, UseTurn) }, - { ItemID.BloodButcherer, Do(AutoReuse, UseTurn) }, - { ItemID.BorealWoodSword, Do(AutoReuse, UseTurn) }, - { ItemID.CactusSword, Do(AutoReuse, UseTurn) }, - { ItemID.CandyCaneSword, Do(AutoReuse, UseTurn) }, - { ItemID.Chik, autoReuse }, - { ItemID.Code1, autoReuse }, - { ItemID.CopperBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.EbonwoodSword, Do(AutoReuse, UseTurn) }, - { ItemID.FieryGreatsword, Do(AutoReuse, UseTurn) }, // Volcano - { ItemID.FormatC, autoReuse }, - { ItemID.GoldBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.HelFire, autoReuse }, - { ItemID.IronBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.JungleYoyo, autoReuse }, // Amazon - { ItemID.LifeCrystal, autoReuse }, - { ItemID.LeadBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.LifeFruit, autoReuse }, - { ItemID.LightsBane, Do(AutoReuse, UseTurn) }, - { ItemID.ManaCrystal, autoReuse }, - { ItemID.PalmWoodSword, Do(AutoReuse, UseTurn) }, - { ItemID.PaperAirplaneA, autoReuse }, - { ItemID.PaperAirplaneB, autoReuse }, // White Paper Airplane - { ItemID.PlatinumBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.RichMahoganySword, Do(AutoReuse, UseTurn) }, - { ItemID.ShadewoodSword, Do(AutoReuse, UseTurn) }, - { ItemID.SilverBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.Starfury, autoReuse }, - { ItemID.TentacleSpike, autoReuse }, - { ItemID.TinBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.TragicUmbrella, autoReuse }, - { ItemID.TungstenBroadsword, Do(AutoReuse, UseTurn) }, - { ItemID.Umbrella, autoReuse }, - { ItemID.Valor, autoReuse }, - { ItemID.WandofFrosting, autoReuse }, - { ItemID.WandofSparking, autoReuse }, - { ItemID.WeatherPain, autoReuse }, - { ItemID.WoodenSword, Do(AutoReuse, UseTurn) }, - { ItemID.WoodYoyo, autoReuse }, - { ItemID.ZapinatorGray, autoReuse }, - { ItemID.ZapinatorOrange, autoReuse }, - #endregion - - #region CATEGORY 8: Non-consumable Quality of Life + #region CATEGORY 6: Summoning Item Quality of Life { ItemID.Abeemination, nonConsumableBossSummon }, - { ItemID.BloodMoonStarter, nonConsumableBossSummon }, // Bloody Tear { ItemID.BloodySpine, nonConsumableBossSummon }, { ItemID.CelestialSigil, nonConsumableBossSummon }, { ItemID.DeerThing, nonConsumableBossSummon }, - { ItemID.GoblinBattleStandard, nonConsumableBossSummon }, { ItemID.MechanicalEye, nonConsumableBossSummon }, { ItemID.MechanicalSkull, nonConsumableBossSummon }, { ItemID.MechanicalWorm, nonConsumableBossSummon }, { ItemID.MechdusaSummon, nonConsumableBossSummon }, // Ocram's Razor - { ItemID.NaughtyPresent, nonConsumableBossSummon }, - { ItemID.PirateMap, nonConsumableBossSummon }, - { ItemID.PumpkinMoonMedallion, nonConsumableBossSummon }, { ItemID.QueenSlimeCrystal, nonConsumableBossSummon }, // Gelatin Crystal { ItemID.SlimeCrown, nonConsumableBossSummon }, - { ItemID.SnowGlobe, nonConsumableBossSummon }, - { ItemID.SolarTablet, nonConsumableBossSummon }, { ItemID.SuspiciousLookingEye, nonConsumableBossSummon }, { ItemID.WormFood, nonConsumableBossSummon }, #endregion - #region CATEGORY 9: Sell Prices - { ItemID.Apple, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Apricot, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Banana, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.BlackCurrant, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.BloodOrange, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Cherry, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Coconut, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Dragonfruit, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Elderberry, Do(Value(Item.sellPrice(copper: 40))) }, + #region CATEGORY 7: Sell Prices { ItemID.EncumberingStone, Do(Worthless) }, + { ItemID.FlareGun, Do(Value(Item.sellPrice(silver: 10))) }, { ItemID.GlowingMushroom, Do(Worthless) }, - { ItemID.Grapefruit, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Lemon, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Mango, Do(Value(Item.sellPrice(copper: 40))) }, { ItemID.Mushroom, Do(Worthless) }, - { ItemID.Peach, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Pineapple, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Plum, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Pomegranate, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Rambutan, Do(Value(Item.sellPrice(copper: 40))) }, - { 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) }, @@ -707,19 +548,6 @@ namespace CalamityMod.Items internal static IItemTweak AttackSpeedRatio(float f) => new AttackSpeedRatioRule(f); #endregion - #region Auto Reuse - internal class AutoReuseRule : IItemTweak - { - internal readonly bool flag = true; - - public AutoReuseRule(bool ar) => flag = ar; - public bool AppliesTo(Item it) => IsUsable(it); - public void ApplyTweak(Item it) => it.autoReuse = flag; - } - internal static IItemTweak AutoReuse => new AutoReuseRule(true); - internal static IItemTweak NoAutoReuse => new AutoReuseRule(false); - #endregion - #region Axe Power // Uses the values shown by Terraria, which are multiplied by 5, not the internal values internal class AxePowerRule : IItemTweak @@ -1043,15 +871,6 @@ namespace CalamityMod.Items internal static IItemTweak PickPower(int p) => new PickPowerRule(p); #endregion - #region Point Blank - internal class PointBlankRule : IItemTweak - { - public bool AppliesTo(Item it) => true; - public void ApplyTweak(Item it) => it.Calamity().canFirePointBlankShots = true; - } - internal static IItemTweak PointBlank => new PointBlankRule(); - #endregion - #region Scale (True Melee) internal class ScaleDeltaRule : IItemTweak { @@ -1404,15 +1223,14 @@ namespace CalamityMod.Items var shimmerTransmute = ItemID.Sets.ShimmerTransformToItem; // Note: Making Luminite Ore -> Astral Ore makes Deus almost completely skippable with no (recipe-related) downsides. - + // Adding Cryonic Ore to the shimmer chain has the same issue. shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); shimmerTransmute[ModContent.ItemType()] = ItemID.LunarOre; shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); shimmerTransmute[ModContent.ItemType()] = shimmerTransmute[ItemID.LunarOre]; - shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); - shimmerTransmute[ModContent.ItemType()] = shimmerTransmute[ItemID.ChlorophyteOre]; + shimmerTransmute[ModContent.ItemType()] = shimmerTransmute[ItemID.ChlorophyteOre]; shimmerTransmute[ModContent.ItemType()] = shimmerTransmute[ItemID.CobaltOre]; //shimmerTransmute[ItemID.LunarOre] = ModContent.ItemType(); @@ -1420,6 +1238,9 @@ namespace CalamityMod.Items shimmerTransmute[ItemID.ChlorophyteOre] = ModContent.ItemType(); shimmerTransmute[ItemID.CobaltOre] = ModContent.ItemType(); + // Note: Not a part of the "main" ore shimmer chain + shimmerTransmute[ModContent.ItemType()] = ItemID.Hellstone; + //Fuck vanilla's stupid Giant Shelly, Crawdad, and Salamander exclusivity shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); @@ -1433,14 +1254,6 @@ namespace CalamityMod.Items shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); - - //Profaned Guardian Drop Swap - shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); - shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); - shimmerTransmute[ModContent.ItemType()] = ModContent.ItemType(); - - //Calamity Permanent Upgrades - shimmerTransmute[ItemID.FrogLeg] = ModContent.ItemType(); } #endregion } diff --git a/Items/Critters/AndroombaItem.cs b/Items/Critters/AndroombaItem.cs index 9b93f5ba7d..50d6a6c197 100644 --- a/Items/Critters/AndroombaItem.cs +++ b/Items/Critters/AndroombaItem.cs @@ -1,8 +1,6 @@ using CalamityMod.NPCs.TownNPCs; using CalamityMod.Rarities; using Terraria; -using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Critters diff --git a/Items/Critters/BabyGhostBellGoldItem.png b/Items/Critters/BabyGhostBellGoldItem.png index a62694c074..8108a2f5c5 100644 Binary files a/Items/Critters/BabyGhostBellGoldItem.png and b/Items/Critters/BabyGhostBellGoldItem.png differ diff --git a/Items/Critters/BabyGhostBellGreenItem.png b/Items/Critters/BabyGhostBellGreenItem.png index b4309e1033..a2266ddb83 100644 Binary files a/Items/Critters/BabyGhostBellGreenItem.png and b/Items/Critters/BabyGhostBellGreenItem.png differ diff --git a/Items/Critters/BabyGhostBellItem.cs b/Items/Critters/BabyGhostBellItem.cs index 620dc56777..7ab5230d19 100644 --- a/Items/Critters/BabyGhostBellItem.cs +++ b/Items/Critters/BabyGhostBellItem.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Packets; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,7 +10,6 @@ namespace CalamityMod.Items.Critters public new string LocalizationCategory => "Items.Misc"; public override void SetStaticDefaults() { - On_Player.ItemCheck_ReleaseCritter += ReleaseColoredGhostBell; Item.ResearchUnlockCount = 5; } @@ -22,54 +20,5 @@ namespace CalamityMod.Items.Critters Item.value = Item.sellPrice(silver: 10); Item.rare = ItemRarityID.Green; } - - // Since all Baby Ghost Bell variants are a single NPC type, this needs to be done in order for each item to spawn the correct color - public static void ReleaseColoredGhostBell(On_Player.orig_ItemCheck_ReleaseCritter orig, Player player, Item item) - { - if (item.makeNPC == ModContent.NPCType()) - { - int mouseX = Main.mouseX + (int)Main.screenPosition.X; - int mouseY = Main.mouseY + (int)Main.screenPosition.Y; - int tileX = mouseX / 16; - int tileY = mouseY / 16; - if (!WorldGen.SolidTile(tileX, tileY)) - { - int colorType = (int)BabyGhostBell.JellyColor.Blue; - if (item.type == ModContent.ItemType()) - { - colorType = (int)BabyGhostBell.JellyColor.Green; - } - if (item.type == ModContent.ItemType()) - { - colorType = (int)BabyGhostBell.JellyColor.Red; - } - if (item.type == ModContent.ItemType()) - { - colorType = (int)BabyGhostBell.JellyColor.Radiant; - } - if (item.type == ModContent.ItemType()) - { - colorType = (int)BabyGhostBell.JellyColor.Gold; - } - player.ApplyItemTime(item); - - if (Main.netMode == NetmodeID.SinglePlayer) - { - int n = NPC.NewNPC(player.GetSource_ReleaseEntity(), mouseX, mouseY, item.makeNPC); - Main.npc[n].ai[1] = colorType; - Main.npc[n].catchItem = item.type; - Main.npc[n].releaseOwner = (short)player.whoAmI; - } - else - { - PlaceAltCritterPacket.Send(player, mouseX, mouseY, item, colorType); - } - } - } - else - { - orig(player, item); - } - } } } diff --git a/Items/Critters/BabyGhostBellItem.png b/Items/Critters/BabyGhostBellItem.png index df7b9dc7ef..da84e29584 100644 Binary files a/Items/Critters/BabyGhostBellItem.png and b/Items/Critters/BabyGhostBellItem.png differ diff --git a/Items/Critters/BabyGhostBellPinkItem.cs b/Items/Critters/BabyGhostBellPinkItem.cs new file mode 100644 index 0000000000..c7e026fb6f --- /dev/null +++ b/Items/Critters/BabyGhostBellPinkItem.cs @@ -0,0 +1,24 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Items.Critters +{ + public class BabyGhostBellPinkItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.bait = 20; + Item.value = Item.sellPrice(silver: 10); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/BabyGhostBellPinkItem.png b/Items/Critters/BabyGhostBellPinkItem.png new file mode 100644 index 0000000000..5fdd7c08b8 Binary files /dev/null and b/Items/Critters/BabyGhostBellPinkItem.png differ diff --git a/Items/Critters/BabyGhostBellRadiantItem.png b/Items/Critters/BabyGhostBellRadiantItem.png index 1f6c79cebc..856633e38a 100644 Binary files a/Items/Critters/BabyGhostBellRadiantItem.png and b/Items/Critters/BabyGhostBellRadiantItem.png differ diff --git a/Items/Critters/BabyGhostBellRedItem.cs b/Items/Critters/BabyGhostBellRedItem.cs deleted file mode 100644 index 5614894572..0000000000 --- a/Items/Critters/BabyGhostBellRedItem.cs +++ /dev/null @@ -1,24 +0,0 @@ -using CalamityMod.NPCs.SunkenSea; -using Terraria; -using Terraria.ModLoader; -using Terraria.ID; - -namespace CalamityMod.Items.Critters -{ - public class BabyGhostBellRedItem : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Misc"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 5; - } - - public override void SetDefaults() - { - Item.DefaultToCapturedCritter(ModContent.NPCType()); - Item.bait = 20; - Item.value = Item.sellPrice(silver: 10); - Item.rare = ItemRarityID.Green; - } - } -} diff --git a/Items/Critters/BabyGhostBellRedItem.png b/Items/Critters/BabyGhostBellRedItem.png deleted file mode 100644 index 9b414d1ab7..0000000000 Binary files a/Items/Critters/BabyGhostBellRedItem.png and /dev/null differ diff --git a/Items/Critters/GildedAxolotlItem.cs b/Items/Critters/GildedAxolotlItem.cs new file mode 100644 index 0000000000..61bf55c30f --- /dev/null +++ b/Items/Critters/GildedAxolotlItem.cs @@ -0,0 +1,27 @@ +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Rarities; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class GildedAxolotlItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(gold: 1); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/GildedAxolotlItem.png b/Items/Critters/GildedAxolotlItem.png new file mode 100644 index 0000000000..47dc612fd3 Binary files /dev/null and b/Items/Critters/GildedAxolotlItem.png differ diff --git a/Items/Critters/NanodroidDysfunctionalItem.cs b/Items/Critters/NanodroidDysfunctionalItem.cs index aa6e247799..4057e68f5b 100644 --- a/Items/Critters/NanodroidDysfunctionalItem.cs +++ b/Items/Critters/NanodroidDysfunctionalItem.cs @@ -1,7 +1,6 @@ using CalamityMod.NPCs.DraedonLabThings; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Critters diff --git a/Items/Critters/NanodroidItem.cs b/Items/Critters/NanodroidItem.cs index 61f4721b10..da84550c6b 100644 --- a/Items/Critters/NanodroidItem.cs +++ b/Items/Critters/NanodroidItem.cs @@ -1,7 +1,6 @@ using CalamityMod.NPCs.DraedonLabThings; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Critters diff --git a/Items/Critters/NanodroidPlagueGreenItem.cs b/Items/Critters/NanodroidPlagueGreenItem.cs index a53d200185..1d7b99debc 100644 --- a/Items/Critters/NanodroidPlagueGreenItem.cs +++ b/Items/Critters/NanodroidPlagueGreenItem.cs @@ -1,7 +1,6 @@ using CalamityMod.NPCs.DraedonLabThings; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Critters diff --git a/Items/Critters/NanodroidPlagueRedItem.cs b/Items/Critters/NanodroidPlagueRedItem.cs index 5932247cb6..c6ea0e3615 100644 --- a/Items/Critters/NanodroidPlagueRedItem.cs +++ b/Items/Critters/NanodroidPlagueRedItem.cs @@ -1,7 +1,6 @@ using CalamityMod.NPCs.DraedonLabThings; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Critters diff --git a/Items/Critters/PearlpodBlackItem.png b/Items/Critters/PearlpodBlackItem.png index e12ceb5a8a..892ff72678 100644 Binary files a/Items/Critters/PearlpodBlackItem.png and b/Items/Critters/PearlpodBlackItem.png differ diff --git a/Items/Critters/PearlpodGoldItem.cs b/Items/Critters/PearlpodGoldItem.cs deleted file mode 100644 index fb84d69a99..0000000000 --- a/Items/Critters/PearlpodGoldItem.cs +++ /dev/null @@ -1,24 +0,0 @@ -using CalamityMod.NPCs.SunkenSea; -using Terraria; -using Terraria.ModLoader; -using Terraria.ID; - -namespace CalamityMod.Items.Critters -{ - public class PearlpodGoldItem : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Misc"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 5; - } - - public override void SetDefaults() - { - Item.DefaultToCapturedCritter(ModContent.NPCType()); - Item.bait = 50; - Item.value = Item.sellPrice(gold: 10); - Item.rare = ItemRarityID.Green; - } - } -} diff --git a/Items/Critters/PearlpodGoldItem.png b/Items/Critters/PearlpodGoldItem.png deleted file mode 100644 index b4813c7bd3..0000000000 Binary files a/Items/Critters/PearlpodGoldItem.png and /dev/null differ diff --git a/Items/Critters/PearlpodItem.png b/Items/Critters/PearlpodItem.png index abddeb22ff..bd60b5c6ad 100644 Binary files a/Items/Critters/PearlpodItem.png and b/Items/Critters/PearlpodItem.png differ diff --git a/Items/Critters/PearlpodPinkItem.png b/Items/Critters/PearlpodPinkItem.png index 20bf35cddd..c65355ec5e 100644 Binary files a/Items/Critters/PearlpodPinkItem.png and b/Items/Critters/PearlpodPinkItem.png differ diff --git a/Items/Critters/PolypPanaseaItem.cs b/Items/Critters/PolypPanaseaItem.cs index 24baf8def9..3ad9b72764 100644 --- a/Items/Critters/PolypPanaseaItem.cs +++ b/Items/Critters/PolypPanaseaItem.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Packets; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,7 +10,6 @@ namespace CalamityMod.Items.Critters public new string LocalizationCategory => "Items.Misc"; public override void SetStaticDefaults() { - On_Player.ItemCheck_ReleaseCritter += ReleaseColoredPanasea; Item.ResearchUnlockCount = 5; } @@ -21,58 +19,5 @@ namespace CalamityMod.Items.Critters Item.value = Item.sellPrice(silver: 10); Item.rare = ItemRarityID.Green; } - - // Since all Polyp Panasea variants are a single NPC type, this needs to be done in order for each item to spawn the correct color - public static void ReleaseColoredPanasea(On_Player.orig_ItemCheck_ReleaseCritter orig, Player player, Item item) - { - if (item.makeNPC == ModContent.NPCType()) - { - int mouseX = Main.mouseX + (int)Main.screenPosition.X; - int mouseY = Main.mouseY + (int)Main.screenPosition.Y; - int tileX = mouseX / 16; - int tileY = mouseY / 16; - if (!WorldGen.SolidTile(tileX, tileY)) - { - int colorType = (int)PolypPanasea.FishColor.Red; - if (item.type == ModContent.ItemType()) - { - colorType = (int)PolypPanasea.FishColor.Green; - } - if (item.type == ModContent.ItemType()) - { - colorType = (int)PolypPanasea.FishColor.Turquoise; - } - if (item.type == ModContent.ItemType()) - { - colorType = (int)PolypPanasea.FishColor.Purple; - } - if (item.type == ModContent.ItemType()) - { - colorType = (int)PolypPanasea.FishColor.Radiant; - } - if (item.type == ModContent.ItemType()) - { - colorType = (int)PolypPanasea.FishColor.Gold; - } - player.ApplyItemTime(item); - - if (Main.netMode == NetmodeID.SinglePlayer) - { - int n = NPC.NewNPC(player.GetSource_ReleaseEntity(), mouseX, mouseY, item.makeNPC); - Main.npc[n].ai[1] = colorType; - Main.npc[n].catchItem = item.type; - Main.npc[n].releaseOwner = (short)player.whoAmI; - } - else - { - PlaceAltCritterPacket.Send(player, mouseX, mouseY, item, colorType); - } - } - } - else - { - orig(player, item); - } - } } } diff --git a/Items/Critters/PrismaticGuppyBlue2Item.png b/Items/Critters/PrismaticGuppyBlue2Item.png new file mode 100644 index 0000000000..b737e98181 Binary files /dev/null and b/Items/Critters/PrismaticGuppyBlue2Item.png differ diff --git a/Items/Critters/PrismaticGuppyBlue3Item.png b/Items/Critters/PrismaticGuppyBlue3Item.png new file mode 100644 index 0000000000..0470416d07 Binary files /dev/null and b/Items/Critters/PrismaticGuppyBlue3Item.png differ diff --git a/Items/Critters/PrismaticGuppyBlueItem.png b/Items/Critters/PrismaticGuppyBlueItem.png new file mode 100644 index 0000000000..e69ad0f093 Binary files /dev/null and b/Items/Critters/PrismaticGuppyBlueItem.png differ diff --git a/Items/Critters/PrismaticGuppyGold2Item.png b/Items/Critters/PrismaticGuppyGold2Item.png new file mode 100644 index 0000000000..175ddf0a05 Binary files /dev/null and b/Items/Critters/PrismaticGuppyGold2Item.png differ diff --git a/Items/Critters/PrismaticGuppyGold3Item.png b/Items/Critters/PrismaticGuppyGold3Item.png new file mode 100644 index 0000000000..aa8226a0cc Binary files /dev/null and b/Items/Critters/PrismaticGuppyGold3Item.png differ diff --git a/Items/Critters/PrismaticGuppyGoldItem.png b/Items/Critters/PrismaticGuppyGoldItem.png new file mode 100644 index 0000000000..255ef49b6e Binary files /dev/null and b/Items/Critters/PrismaticGuppyGoldItem.png differ diff --git a/Items/Critters/PrismaticGuppyGreen2Item.png b/Items/Critters/PrismaticGuppyGreen2Item.png new file mode 100644 index 0000000000..e725beff26 Binary files /dev/null and b/Items/Critters/PrismaticGuppyGreen2Item.png differ diff --git a/Items/Critters/PrismaticGuppyGreen3Item.png b/Items/Critters/PrismaticGuppyGreen3Item.png new file mode 100644 index 0000000000..e98484e833 Binary files /dev/null and b/Items/Critters/PrismaticGuppyGreen3Item.png differ diff --git a/Items/Critters/PrismaticGuppyGreenItem.png b/Items/Critters/PrismaticGuppyGreenItem.png new file mode 100644 index 0000000000..5bf82e62d6 Binary files /dev/null and b/Items/Critters/PrismaticGuppyGreenItem.png differ diff --git a/Items/Critters/PrismaticGuppyItem.cs b/Items/Critters/PrismaticGuppyItem.cs new file mode 100644 index 0000000000..eb48ba859f --- /dev/null +++ b/Items/Critters/PrismaticGuppyItem.cs @@ -0,0 +1,183 @@ +using System.IO; +using CalamityMod.NPCs.SunkenSea; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Items.Critters +{ + public abstract class PrismaticGuppyItem : ModItem, ILocalizedModType + { + public int shapeVariant = 0; + public abstract Texture2D CubicTexture { get; } + public abstract Texture2D AngelicTexture { get; } + + public new string LocalizationCategory => "Items.Misc"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(silver: 20); // they sell for more + Item.rare = ItemRarityID.Green; + } + + public override void OnSpawn(IEntitySource source) + { + if (source is EntitySource_Caught catchEntity) + { + if (catchEntity.Entity is NPC n) + { + if (n.type == ModContent.NPCType()) + { + shapeVariant = (int)n.ai[2]; + } + } + } + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D tex = TextureAssets.Item[Item.type].Value; + switch (shapeVariant) + { + case 1: + tex = CubicTexture; + break; + case 2: + tex = AngelicTexture; + break; + } + spriteBatch.Draw(tex, Item.Center - Main.screenPosition, null, lightColor, rotation, tex.Size() / 2, scale, SpriteEffects.None, 0f); + return false; + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D tex = TextureAssets.Item[Item.type].Value; + switch (shapeVariant) + { + case 1: + tex = CubicTexture; + break; + case 2: + tex = AngelicTexture; + break; + } + spriteBatch.Draw(tex, position, null, drawColor, 0, tex.Size() / 2, scale, SpriteEffects.None, 0f); + return false; + } + + public override void SaveData(TagCompound tag) + { + tag.Add("shapeVariant", shapeVariant); + } + + public override void LoadData(TagCompound tag) + { + shapeVariant = tag.GetInt("shapeVariant"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(shapeVariant); + } + + public override void NetReceive(BinaryReader reader) + { + shapeVariant = reader.ReadInt32(); + } + } + + // RIP "Throwing these in an aquarium would be insanity" flavor text + [LegacyName("PrismaticGuppy")] + public class PrismaticGuppyBlueItem : PrismaticGuppyItem + { + public override Texture2D AngelicTexture => angelicTex.Value; + public override Texture2D CubicTexture => cubicTex.Value; + + public static Asset angelicTex; + public static Asset cubicTex; + public override void Load() + { + cubicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyBlue2Item"); + angelicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyBlue3Item"); + } + } + + public class PrismaticGuppyPinkItem : PrismaticGuppyItem + { + public override Texture2D AngelicTexture => angelicTex.Value; + public override Texture2D CubicTexture => cubicTex.Value; + + public static Asset angelicTex; + public static Asset cubicTex; + public override void Load() + { + cubicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyPink2Item"); + angelicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyPink3Item"); + } + } + + public class PrismaticGuppyGreenItem : PrismaticGuppyItem + { + public override Texture2D AngelicTexture => angelicTex.Value; + public override Texture2D CubicTexture => cubicTex.Value; + + public static Asset angelicTex; + public static Asset cubicTex; + public override void Load() + { + cubicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyGreen2Item"); + angelicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyGreen3Item"); + } + } + + public class PrismaticGuppyGoldItem : PrismaticGuppyItem + { + public override Texture2D AngelicTexture => angelicTex.Value; + public override Texture2D CubicTexture => cubicTex.Value; + + public static Asset angelicTex; + public static Asset cubicTex; + public override void Load() + { + cubicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyGold2Item"); + angelicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyGold3Item"); + } + public override void SetDefaults() + { + base.SetDefaults(); + Item.value = Item.sellPrice(gold: 15); // base guppies are said to sell for a lot already + } + } + + public class PrismaticGuppyRadiantItem : PrismaticGuppyItem + { + public override Texture2D AngelicTexture => angelicTex.Value; + public override Texture2D CubicTexture => cubicTex.Value; + + public static Asset angelicTex; + public static Asset cubicTex; + public override void Load() + { + cubicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyRadiant2Item"); + angelicTex = ModContent.Request("CalamityMod/Items/Critters/PrismaticGuppyRadiant3Item"); + } + public override void SetDefaults() + { + base.SetDefaults(); + Item.value = Item.sellPrice(gold: 15); // base guppies are said to sell for a lot already + } + } +} diff --git a/Items/Critters/PrismaticGuppyPink2Item.png b/Items/Critters/PrismaticGuppyPink2Item.png new file mode 100644 index 0000000000..0596565655 Binary files /dev/null and b/Items/Critters/PrismaticGuppyPink2Item.png differ diff --git a/Items/Critters/PrismaticGuppyPink3Item.png b/Items/Critters/PrismaticGuppyPink3Item.png new file mode 100644 index 0000000000..f0c5839dfb Binary files /dev/null and b/Items/Critters/PrismaticGuppyPink3Item.png differ diff --git a/Items/Critters/PrismaticGuppyPinkItem.png b/Items/Critters/PrismaticGuppyPinkItem.png new file mode 100644 index 0000000000..8100ed4f6a Binary files /dev/null and b/Items/Critters/PrismaticGuppyPinkItem.png differ diff --git a/Items/Critters/PrismaticGuppyRadiant2Item.png b/Items/Critters/PrismaticGuppyRadiant2Item.png new file mode 100644 index 0000000000..ecceded340 Binary files /dev/null and b/Items/Critters/PrismaticGuppyRadiant2Item.png differ diff --git a/Items/Critters/PrismaticGuppyRadiant3Item.png b/Items/Critters/PrismaticGuppyRadiant3Item.png new file mode 100644 index 0000000000..b07ef47455 Binary files /dev/null and b/Items/Critters/PrismaticGuppyRadiant3Item.png differ diff --git a/Items/Critters/PrismaticGuppyRadiantItem.png b/Items/Critters/PrismaticGuppyRadiantItem.png new file mode 100644 index 0000000000..f9aa73873b Binary files /dev/null and b/Items/Critters/PrismaticGuppyRadiantItem.png differ diff --git a/Items/Critters/ProbesnoutGoldItem.cs b/Items/Critters/ProbesnoutGoldItem.cs new file mode 100644 index 0000000000..ea7ccc7523 --- /dev/null +++ b/Items/Critters/ProbesnoutGoldItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class ProbesnoutGoldItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(gold: 10); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/ProbesnoutGoldItem.png b/Items/Critters/ProbesnoutGoldItem.png new file mode 100644 index 0000000000..fc1d99790a Binary files /dev/null and b/Items/Critters/ProbesnoutGoldItem.png differ diff --git a/Items/Critters/ProbesnoutItem.cs b/Items/Critters/ProbesnoutItem.cs new file mode 100644 index 0000000000..e8a0d6ae6e --- /dev/null +++ b/Items/Critters/ProbesnoutItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class ProbesnoutItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(silver: 10); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/ProbesnoutItem.png b/Items/Critters/ProbesnoutItem.png new file mode 100644 index 0000000000..3e82f75c69 Binary files /dev/null and b/Items/Critters/ProbesnoutItem.png differ diff --git a/Items/Critters/RepairUnitItem.cs b/Items/Critters/RepairUnitItem.cs index ec9980cff3..793cbe4594 100644 --- a/Items/Critters/RepairUnitItem.cs +++ b/Items/Critters/RepairUnitItem.cs @@ -1,7 +1,6 @@ using CalamityMod.NPCs.DraedonLabThings; using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Critters diff --git a/Items/Critters/SeaFloatyItem.cs b/Items/Critters/SeaFloatyItem.cs new file mode 100644 index 0000000000..b313de7f03 --- /dev/null +++ b/Items/Critters/SeaFloatyItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class SeaFloatyItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(gold: 3); // These things are actually painful to catch, they can get a 300% value boost + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/SeaFloatyItem.png b/Items/Critters/SeaFloatyItem.png new file mode 100644 index 0000000000..83dc6f5920 Binary files /dev/null and b/Items/Critters/SeaFloatyItem.png differ diff --git a/Items/Critters/SearslugItem.cs b/Items/Critters/SearslugItem.cs new file mode 100644 index 0000000000..46f154ddde --- /dev/null +++ b/Items/Critters/SearslugItem.cs @@ -0,0 +1,25 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Items.Critters +{ + public class SearslugItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + ItemID.Sets.IsLavaBait[Type] = true; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.bait = 30; + Item.value = Item.sellPrice(silver: 30); + Item.rare = ItemRarityID.Orange; + } + } +} diff --git a/Items/Critters/SearslugItem.png b/Items/Critters/SearslugItem.png new file mode 100644 index 0000000000..31a39cfa0f Binary files /dev/null and b/Items/Critters/SearslugItem.png differ diff --git a/Items/Critters/ShoreskipperItem.cs b/Items/Critters/ShoreskipperItem.cs new file mode 100644 index 0000000000..7eaf1fd339 --- /dev/null +++ b/Items/Critters/ShoreskipperItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Items.Critters +{ + public class ShoreskipperItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(silver: 5); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/ShoreskipperItem.png b/Items/Critters/ShoreskipperItem.png new file mode 100644 index 0000000000..24722e85da Binary files /dev/null and b/Items/Critters/ShoreskipperItem.png differ diff --git a/Items/Critters/ShroombleItem.cs b/Items/Critters/ShroombleItem.cs index f3489575cf..c880096d7c 100644 --- a/Items/Critters/ShroombleItem.cs +++ b/Items/Critters/ShroombleItem.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs.NormalNPCs; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Critters diff --git a/Items/Critters/SlugbunBurrowsItem.cs b/Items/Critters/SlugbunBurrowsItem.cs new file mode 100644 index 0000000000..616608a04c --- /dev/null +++ b/Items/Critters/SlugbunBurrowsItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class SlugbunBurrowsItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(silver: 10); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/SlugbunBurrowsItem.png b/Items/Critters/SlugbunBurrowsItem.png new file mode 100644 index 0000000000..5f03039d24 Binary files /dev/null and b/Items/Critters/SlugbunBurrowsItem.png differ diff --git a/Items/Critters/SlugbunItem.cs b/Items/Critters/SlugbunItem.cs new file mode 100644 index 0000000000..fd7c1898a2 --- /dev/null +++ b/Items/Critters/SlugbunItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class SlugbunItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(silver: 10); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/SlugbunItem.png b/Items/Critters/SlugbunItem.png new file mode 100644 index 0000000000..81d4609d92 Binary files /dev/null and b/Items/Critters/SlugbunItem.png differ diff --git a/Items/Critters/SlugbunPolypItem.cs b/Items/Critters/SlugbunPolypItem.cs new file mode 100644 index 0000000000..9b43f3d9fe --- /dev/null +++ b/Items/Critters/SlugbunPolypItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class SlugbunPolypItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(silver: 10); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/SlugbunPolypItem.png b/Items/Critters/SlugbunPolypItem.png new file mode 100644 index 0000000000..6c8a1c45e7 Binary files /dev/null and b/Items/Critters/SlugbunPolypItem.png differ diff --git a/Items/Critters/SlugbunRadiantItem.cs b/Items/Critters/SlugbunRadiantItem.cs new file mode 100644 index 0000000000..e1ada3b71d --- /dev/null +++ b/Items/Critters/SlugbunRadiantItem.cs @@ -0,0 +1,23 @@ +using CalamityMod.NPCs.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class SlugbunRadiantItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Misc"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + } + + public override void SetDefaults() + { + Item.DefaultToCapturedCritter(ModContent.NPCType()); + Item.value = Item.sellPrice(gold: 10); + Item.rare = ItemRarityID.Green; + } + } +} diff --git a/Items/Critters/SlugbunRadiantItem.png b/Items/Critters/SlugbunRadiantItem.png new file mode 100644 index 0000000000..60cc5c9cd1 Binary files /dev/null and b/Items/Critters/SlugbunRadiantItem.png differ diff --git a/Items/DifficultyItems/BallAndChain.cs b/Items/DifficultyItems/BallAndChain.cs deleted file mode 100644 index 46062dabac..0000000000 --- a/Items/DifficultyItems/BallAndChain.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.DifficultyItems -{ - public class BallAndChain : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Misc"; - public override void SetDefaults() - { - Item.width = 32; - Item.height = 50; - Item.rare = ItemRarityID.Blue; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther; - } - - public override bool CanUseItem(Player player) => false; - - public override void UpdateInventory(Player player) - { - if (Item.favorited) - player.Calamity().blockAllDashes = true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddRecipeGroup("IronBar", 10). - AddIngredient(ItemID.Chain). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/DifficultyItems/BallAndChain.png b/Items/DifficultyItems/BallAndChain.png deleted file mode 100644 index 7ca87bdef9..0000000000 Binary files a/Items/DifficultyItems/BallAndChain.png and /dev/null differ diff --git a/Items/DraedonMisc/AuricQuantumCoolingCell.cs b/Items/DraedonMisc/AuricQuantumCoolingCell.cs index fd51d616ec..b4e00f59bd 100644 --- a/Items/DraedonMisc/AuricQuantumCoolingCell.cs +++ b/Items/DraedonMisc/AuricQuantumCoolingCell.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Rarities; @@ -27,7 +26,7 @@ namespace CalamityMod.Items.DraedonMisc Item.consumable = true; Item.useStyle = ItemUseStyleID.Swing; Item.useAnimation = Item.useTime = 15; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5, true); diff --git a/Items/DraedonMisc/EncryptedSchematicHell.cs b/Items/DraedonMisc/EncryptedSchematicHell.cs index 69f3014040..b1a660bfa0 100644 --- a/Items/DraedonMisc/EncryptedSchematicHell.cs +++ b/Items/DraedonMisc/EncryptedSchematicHell.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CustomRecipes; -using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Rarities; @@ -52,7 +51,7 @@ namespace CalamityMod.Items.DraedonMisc meleeDisplay.OverrideColor = new Color(201, 41, 255); list.Insert(insertIndex + 1, meleeDisplay); - int rangedItem = ModContent.ItemType(); + int rangedItem = ModContent.ItemType(); TooltipLine rangedDisplay = new TooltipLine(this.Mod, "CalamityMod:RangedDisplay", $"[i:{rangedItem}] {CalamityUtils.GetItemName(rangedItem)}"); rangedDisplay.OverrideColor = new Color(255, 64, 31); list.Insert(insertIndex + 2, rangedDisplay); diff --git a/Items/DraedonMisc/EncryptedSchematicIce.cs b/Items/DraedonMisc/EncryptedSchematicIce.cs index f77253fff3..f2c970ae34 100644 --- a/Items/DraedonMisc/EncryptedSchematicIce.cs +++ b/Items/DraedonMisc/EncryptedSchematicIce.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CustomRecipes; -using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Rarities; diff --git a/Items/DraedonMisc/EncryptedSchematicJungle.cs b/Items/DraedonMisc/EncryptedSchematicJungle.cs index a4eec184c9..e625fca109 100644 --- a/Items/DraedonMisc/EncryptedSchematicJungle.cs +++ b/Items/DraedonMisc/EncryptedSchematicJungle.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CustomRecipes; -using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.PlaceableTurrets; using CalamityMod.Items.SummonItems; @@ -59,12 +58,12 @@ namespace CalamityMod.Items.DraedonMisc meleeDisplay.OverrideColor = new Color(149, 243, 43); list.Insert(insertIndex + 1, meleeDisplay); - int rangedItem = ModContent.ItemType(); + int rangedItem = ModContent.ItemType(); TooltipLine rangedDisplay = new TooltipLine(this.Mod, "CalamityMod:RangedDisplay", $"[i:{rangedItem}] {CalamityUtils.GetItemName(rangedItem)}"); rangedDisplay.OverrideColor = new Color(236, 255, 31); list.Insert(insertIndex + 2, rangedDisplay); - int mageItem = ModContent.ItemType(); + int mageItem = ModContent.ItemType(); TooltipLine mageDisplay = new TooltipLine(this.Mod, "CalamityMod:MageDisplay", $"[i:{mageItem}] {CalamityUtils.GetItemName(mageItem)}"); mageDisplay.OverrideColor = new Color(255, 64, 31); list.Insert(insertIndex + 3, mageDisplay); diff --git a/Items/DraedonMisc/EncryptedSchematicPlanetoid.cs b/Items/DraedonMisc/EncryptedSchematicPlanetoid.cs index bc6eed8da8..0c226aa2ab 100644 --- a/Items/DraedonMisc/EncryptedSchematicPlanetoid.cs +++ b/Items/DraedonMisc/EncryptedSchematicPlanetoid.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CustomRecipes; -using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.PlaceableTurrets; using CalamityMod.Items.SummonItems; @@ -59,12 +58,12 @@ namespace CalamityMod.Items.DraedonMisc meleeDisplay.OverrideColor = new Color(31, 242, 245); list.Insert(insertIndex + 1, meleeDisplay); - int rangedItem = ModContent.ItemType(); + int rangedItem = ModContent.ItemType(); TooltipLine rangedDisplay = new TooltipLine(this.Mod, "CalamityMod:RangedDisplay", $"[i:{rangedItem}] {CalamityUtils.GetItemName(rangedItem)}"); rangedDisplay.OverrideColor = new Color(149, 243, 43); list.Insert(insertIndex + 2, rangedDisplay); - int mageItem = ModContent.ItemType(); + int mageItem = ModContent.ItemType(); TooltipLine mageDisplay = new TooltipLine(this.Mod, "CalamityMod:MageDisplay", $"[i:{mageItem}] {CalamityUtils.GetItemName(mageItem)}"); mageDisplay.OverrideColor = new Color(236, 255, 31); list.Insert(insertIndex + 3, mageDisplay); @@ -74,7 +73,7 @@ namespace CalamityMod.Items.DraedonMisc summonDisplay.OverrideColor = new Color(255, 64, 31); list.Insert(insertIndex + 4, summonDisplay); - int rogueItem = ModContent.ItemType(); + int rogueItem = ModContent.ItemType(); TooltipLine rogueDisplay = new TooltipLine(this.Mod, "CalamityMod:RogueDisplay", $"[i:{rogueItem}] {CalamityUtils.GetItemName(rogueItem)}"); rogueDisplay.OverrideColor = new Color(201, 41, 255); list.Insert(insertIndex + 5, rogueDisplay); diff --git a/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs b/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs index 01e8c386a2..b1d255b530 100644 --- a/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs +++ b/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CustomRecipes; -using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.PlaceableTurrets; using CalamityMod.Items.Weapons.DraedonsArsenal; @@ -61,12 +60,12 @@ namespace CalamityMod.Items.DraedonMisc int insertIndex = list.FindIndex(x => x.Name == "Tooltip2" && x.Mod == "Terraria"); if (insertIndex != -1) { - int meleeItem = ModContent.ItemType(); + int meleeItem = ModContent.ItemType(); TooltipLine meleeDisplay = new TooltipLine(this.Mod, "CalamityMod:MeleeDisplay", $"[i:{meleeItem}] {CalamityUtils.GetItemName(meleeItem)}"); meleeDisplay.OverrideColor = new Color(236, 255, 31); list.Insert(insertIndex + 1, meleeDisplay); - int rangedItem = ModContent.ItemType(); + int rangedItem = ModContent.ItemType(); TooltipLine rangedDisplay = new TooltipLine(this.Mod, "CalamityMod:RangedDisplay", $"[i:{rangedItem}] {CalamityUtils.GetItemName(rangedItem)}"); rangedDisplay.OverrideColor = new Color(31, 242, 245); list.Insert(insertIndex + 2, rangedDisplay); @@ -76,12 +75,12 @@ namespace CalamityMod.Items.DraedonMisc mageDisplay.OverrideColor = new Color(201, 41, 255); list.Insert(insertIndex + 3, mageDisplay); - int summonItem = ModContent.ItemType(); + int summonItem = ModContent.ItemType(); TooltipLine summonDisplay = new TooltipLine(this.Mod, "CalamityMod:SummonDisplay", $"[i:{summonItem}] {CalamityUtils.GetItemName(summonItem)}"); summonDisplay.OverrideColor = new Color(149, 243, 43); list.Insert(insertIndex + 4, summonDisplay); - int rogueItem = ModContent.ItemType(); + int rogueItem = ModContent.ItemType(); TooltipLine rogueDisplay = new TooltipLine(this.Mod, "CalamityMod:RogueDisplay", $"[i:{rogueItem}] {CalamityUtils.GetItemName(rogueItem)}"); rogueDisplay.OverrideColor = new Color(255, 64, 31); list.Insert(insertIndex + 5, rogueDisplay); diff --git a/Items/DraedonMisc/VoltageRegulationSystem.cs b/Items/DraedonMisc/VoltageRegulationSystem.cs index 149fc0e488..08079cd86a 100644 --- a/Items/DraedonMisc/VoltageRegulationSystem.cs +++ b/Items/DraedonMisc/VoltageRegulationSystem.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.DraedonMisc AddIngredient(5). AddIngredient(ItemID.LunarBar, 5). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(4, out Func condition), condition). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/DummyTooltipItem/DummyTooltipItem.cs b/Items/DummyTooltipItem/DummyTooltipItem.cs index 52811da4d3..89db4494c9 100644 --- a/Items/DummyTooltipItem/DummyTooltipItem.cs +++ b/Items/DummyTooltipItem/DummyTooltipItem.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Dyes/AcidRainDye.cs b/Items/Dyes/AcidRainDye.cs index 33055f6e63..86890dbd84 100644 --- a/Items/Dyes/AcidRainDye.cs +++ b/Items/Dyes/AcidRainDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/AerialiteDye.cs b/Items/Dyes/AerialiteDye.cs index 4f5e74492d..3009e23f44 100644 --- a/Items/Dyes/AerialiteDye.cs +++ b/Items/Dyes/AerialiteDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/AstralBlueDye.cs b/Items/Dyes/AstralBlueDye.cs index 6a96176db9..35b71b4c0e 100644 --- a/Items/Dyes/AstralBlueDye.cs +++ b/Items/Dyes/AstralBlueDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/AstralDye.cs b/Items/Dyes/AstralDye.cs index 05e9285039..70d5dca3bb 100644 --- a/Items/Dyes/AstralDye.cs +++ b/Items/Dyes/AstralDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Placeables.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/AstralOrangeDye.cs b/Items/Dyes/AstralOrangeDye.cs index ae734bbaf9..bb1b630d71 100644 --- a/Items/Dyes/AstralOrangeDye.cs +++ b/Items/Dyes/AstralOrangeDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/AstralSwirlDye.cs b/Items/Dyes/AstralSwirlDye.cs index 4276257b75..07e644f43d 100644 --- a/Items/Dyes/AstralSwirlDye.cs +++ b/Items/Dyes/AstralSwirlDye.cs @@ -1,10 +1,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/AuricDye.cs b/Items/Dyes/AuricDye.cs index f328847496..adcb1bd0f8 100644 --- a/Items/Dyes/AuricDye.cs +++ b/Items/Dyes/AuricDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 2, silver: 50); } diff --git a/Items/Dyes/BloodflareDye.cs b/Items/Dyes/BloodflareDye.cs index 9e3c4e3f13..b3891e3062 100644 --- a/Items/Dyes/BloodflareDye.cs +++ b/Items/Dyes/BloodflareDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; diff --git a/Items/Dyes/BlueCosmicFlameDye.cs b/Items/Dyes/BlueCosmicFlameDye.cs index a322c53232..5a20cbccc8 100644 --- a/Items/Dyes/BlueCosmicFlameDye.cs +++ b/Items/Dyes/BlueCosmicFlameDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 1, silver: 50); } diff --git a/Items/Dyes/BlueStatigelDye.cs b/Items/Dyes/BlueStatigelDye.cs index 7fb215af92..83eee3424a 100644 --- a/Items/Dyes/BlueStatigelDye.cs +++ b/Items/Dyes/BlueStatigelDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/BrimflameDye.cs b/Items/Dyes/BrimflameDye.cs index 72e2f22529..889043f0c2 100644 --- a/Items/Dyes/BrimflameDye.cs +++ b/Items/Dyes/BrimflameDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Placeables.Crags; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/CalamitousDye.cs b/Items/Dyes/CalamitousDye.cs index 01312c1b6d..89c33691ea 100644 --- a/Items/Dyes/CalamitousDye.cs +++ b/Items/Dyes/CalamitousDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 2, silver: 50); } diff --git a/Items/Dyes/CeaselessDye.cs b/Items/Dyes/CeaselessDye.cs index f8b547bf63..36af9ee160 100644 --- a/Items/Dyes/CeaselessDye.cs +++ b/Items/Dyes/CeaselessDye.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; diff --git a/Items/Dyes/CosmiliteDye.cs b/Items/Dyes/CosmiliteDye.cs index c881cde6b3..517e00835d 100644 --- a/Items/Dyes/CosmiliteDye.cs +++ b/Items/Dyes/CosmiliteDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 1, silver: 50); } diff --git a/Items/Dyes/CryonicDye.cs b/Items/Dyes/CryonicDye.cs index 564245000e..f082fb27d3 100644 --- a/Items/Dyes/CryonicDye.cs +++ b/Items/Dyes/CryonicDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/DaedalusDye.cs b/Items/Dyes/DaedalusDye.cs index 0fa359e4b8..92734832d3 100644 --- a/Items/Dyes/DaedalusDye.cs +++ b/Items/Dyes/DaedalusDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/DefiledFlameDye.cs b/Items/Dyes/DefiledFlameDye.cs index 5fbdb3315d..30fbad12f5 100644 --- a/Items/Dyes/DefiledFlameDye.cs +++ b/Items/Dyes/DefiledFlameDye.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; diff --git a/Items/Dyes/DragonSoulDye.cs b/Items/Dyes/DragonSoulDye.cs index 036526c584..8cca47d49b 100644 --- a/Items/Dyes/DragonSoulDye.cs +++ b/Items/Dyes/DragonSoulDye.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 2, silver: 50); } diff --git a/Items/Dyes/ElementalDye.cs b/Items/Dyes/ElementalDye.cs index 6940ca7fb3..e6c133aa94 100644 --- a/Items/Dyes/ElementalDye.cs +++ b/Items/Dyes/ElementalDye.cs @@ -1,10 +1,7 @@ -using CalamityMod.Items.Materials; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/EndothermicDye.cs b/Items/Dyes/EndothermicDye.cs index 169a151228..96c769f18d 100644 --- a/Items/Dyes/EndothermicDye.cs +++ b/Items/Dyes/EndothermicDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 1, silver: 50); } diff --git a/Items/Dyes/ExoDye.cs b/Items/Dyes/ExoDye.cs index ec2b61ece3..1080879443 100644 --- a/Items/Dyes/ExoDye.cs +++ b/Items/Dyes/ExoDye.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -23,7 +22,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 2, silver: 50); } diff --git a/Items/Dyes/HairDye/AdrenalineHairDye.cs b/Items/Dyes/HairDye/AdrenalineHairDye.cs index 3e4b4da9c3..7b780b8e3c 100644 --- a/Items/Dyes/HairDye/AdrenalineHairDye.cs +++ b/Items/Dyes/HairDye/AdrenalineHairDye.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Dyes.HairDye Item.consumable = true; Item.maxStack = Item.CommonMaxStack; - Item.value = Item.buyPrice(gold: 7, silver: 50); // Sold by Stylist + Item.value = Item.buyPrice(gold: 5); // Sold by Stylist Item.rare = ItemRarityID.Green; } } diff --git a/Items/Dyes/HairDye/RageHairDye.cs b/Items/Dyes/HairDye/RageHairDye.cs index 54df4cc38b..4266039761 100644 --- a/Items/Dyes/HairDye/RageHairDye.cs +++ b/Items/Dyes/HairDye/RageHairDye.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Dyes.HairDye Item.consumable = true; Item.maxStack = Item.CommonMaxStack; - Item.value = Item.buyPrice(gold: 7, silver: 50); // Sold by Stylist + Item.value = Item.buyPrice(gold: 5); // Sold by Stylist Item.rare = ItemRarityID.Green; } } diff --git a/Items/Dyes/HairDye/WingTimeHairDye.cs b/Items/Dyes/HairDye/WingTimeHairDye.cs index 272b2b41f0..45f444b2bd 100644 --- a/Items/Dyes/HairDye/WingTimeHairDye.cs +++ b/Items/Dyes/HairDye/WingTimeHairDye.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Dyes.HairDye Item.consumable = true; Item.maxStack = Item.CommonMaxStack; - Item.value = Item.buyPrice(gold: 7, silver: 50); // Sold by Stylist + Item.value = Item.buyPrice(gold: 5); // Sold by Stylist Item.rare = ItemRarityID.Green; } } diff --git a/Items/Dyes/InvisibleDye.cs b/Items/Dyes/InvisibleDye.cs new file mode 100644 index 0000000000..f575c787a2 --- /dev/null +++ b/Items/Dyes/InvisibleDye.cs @@ -0,0 +1,76 @@ +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class InvisibleDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(Mod.Assets.Request("Effects/Dyes/InvisibleDyeShader"), "DyePass"); + + public override void SafeSetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + } + + public override void SafeSetDefaults() + { + Item.rare = ItemRarityID.Blue; + Item.value = Item.sellPrice(silver: 20); + } + + #region On Edit Hell To Actually Make Player Body Not Draw + public override void Load() + { + On_PlayerDrawLayers.DrawPlayer_21_Head += StopHeadDrawing; + On_PlayerDrawLayers.DrawPlayer_12_Skin += StopBodyAndLegDrawing; + On_PlayerDrawLayers.DrawPlayer_13_Leggings += StopLegClothesDrawing; + On_PlayerDrawLayers.DrawPlayer_17_Torso += StopBodyClothesDrawing; + On_PlayerDrawLayers.DrawPlayer_12_SkinComposite_BackArmShirt += StopCompositeArmDrawing; + On_PlayerDrawLayers.DrawPlayer_28_ArmOverItem += StopBackArmAndUndershirtDrawing; + } + + private static void StopHeadDrawing(On_PlayerDrawLayers.orig_DrawPlayer_21_Head orig, ref PlayerDrawSet drawInfo) + { + if (drawInfo.drawPlayer.cHead == GameShaders.Armor.GetShaderIdFromItemId(ModContent.ItemType())) + return; + orig(ref drawInfo); + } + private static void StopBodyAndLegDrawing(On_PlayerDrawLayers.orig_DrawPlayer_12_Skin orig, ref PlayerDrawSet drawInfo) + { + if (drawInfo.drawPlayer.cBody == GameShaders.Armor.GetShaderIdFromItemId(ModContent.ItemType())) + drawInfo.hidesTopSkin = true; + if (drawInfo.drawPlayer.cLegs == GameShaders.Armor.GetShaderIdFromItemId(ModContent.ItemType())) + drawInfo.hidesBottomSkin = true; + orig(ref drawInfo); + } + private static void StopLegClothesDrawing(On_PlayerDrawLayers.orig_DrawPlayer_13_Leggings orig, ref PlayerDrawSet drawInfo) + { + if (drawInfo.drawPlayer.cLegs == GameShaders.Armor.GetShaderIdFromItemId(ModContent.ItemType())) + return; + orig(ref drawInfo); + } + private static void StopBodyClothesDrawing(On_PlayerDrawLayers.orig_DrawPlayer_17_Torso orig, ref PlayerDrawSet drawInfo) + { + if (drawInfo.drawPlayer.cBody == GameShaders.Armor.GetShaderIdFromItemId(ModContent.ItemType())) + return; + orig(ref drawInfo); + } + private static void StopCompositeArmDrawing(On_PlayerDrawLayers.orig_DrawPlayer_12_SkinComposite_BackArmShirt orig, ref PlayerDrawSet drawInfo) + { + if (drawInfo.drawPlayer.cBody == GameShaders.Armor.GetShaderIdFromItemId(ModContent.ItemType())) + return; + orig(ref drawInfo); + } + private static void StopBackArmAndUndershirtDrawing(On_PlayerDrawLayers.orig_DrawPlayer_28_ArmOverItem orig, ref PlayerDrawSet drawInfo) + { + if (drawInfo.drawPlayer.cBody == GameShaders.Armor.GetShaderIdFromItemId(ModContent.ItemType())) + return; + orig(ref drawInfo); + } + #endregion + } +} diff --git a/Items/Dyes/InvisibleDye.png b/Items/Dyes/InvisibleDye.png new file mode 100644 index 0000000000..debd5eea5c Binary files /dev/null and b/Items/Dyes/InvisibleDye.png differ diff --git a/Items/Dyes/LivingShardDye.cs b/Items/Dyes/LivingShardDye.cs index 45ec13a2be..ee55338e43 100644 --- a/Items/Dyes/LivingShardDye.cs +++ b/Items/Dyes/LivingShardDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/MeldDye.cs b/Items/Dyes/MeldDye.cs index 20c714dcef..7fc49ed139 100644 --- a/Items/Dyes/MeldDye.cs +++ b/Items/Dyes/MeldDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/NecromanticDye.cs b/Items/Dyes/NecromanticDye.cs index 0d9dcd5c13..895556317a 100644 --- a/Items/Dyes/NecromanticDye.cs +++ b/Items/Dyes/NecromanticDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/NecroplasmicDye.cs b/Items/Dyes/NecroplasmicDye.cs index a96be1ce35..4dacd03720 100644 --- a/Items/Dyes/NecroplasmicDye.cs +++ b/Items/Dyes/NecroplasmicDye.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; diff --git a/Items/Dyes/NightmareDye.cs b/Items/Dyes/NightmareDye.cs index 7687519061..6224c1cd05 100644 --- a/Items/Dyes/NightmareDye.cs +++ b/Items/Dyes/NightmareDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 1, silver: 50); } diff --git a/Items/Dyes/PinkCosmicFlameDye.cs b/Items/Dyes/PinkCosmicFlameDye.cs index 0c89581f22..2fc65e4e22 100644 --- a/Items/Dyes/PinkCosmicFlameDye.cs +++ b/Items/Dyes/PinkCosmicFlameDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 1, silver: 50); } diff --git a/Items/Dyes/PinkStatigelDye.cs b/Items/Dyes/PinkStatigelDye.cs index c7e54b0dc1..61d1a7a0a9 100644 --- a/Items/Dyes/PinkStatigelDye.cs +++ b/Items/Dyes/PinkStatigelDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/PlagueGooDye.cs b/Items/Dyes/PlagueGooDye.cs index b7faf81f87..0375767c73 100644 --- a/Items/Dyes/PlagueGooDye.cs +++ b/Items/Dyes/PlagueGooDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.TreasureBags.MiscGrabBags; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/PlaguePlateDye.cs b/Items/Dyes/PlaguePlateDye.cs index c1737cb01a..c15aae6f2d 100644 --- a/Items/Dyes/PlaguePlateDye.cs +++ b/Items/Dyes/PlaguePlateDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/ProfanedCrystalDye.cs b/Items/Dyes/ProfanedCrystalDye.cs index 2febd2a736..dbac9ad894 100644 --- a/Items/Dyes/ProfanedCrystalDye.cs +++ b/Items/Dyes/ProfanedCrystalDye.cs @@ -1,12 +1,9 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.FurnitureProfaned; +using CalamityMod.Items.Placeables.FurnitureProfaned; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/ProfanedFlameDye.cs b/Items/Dyes/ProfanedFlameDye.cs index 21e4860381..5170ee340b 100644 --- a/Items/Dyes/ProfanedFlameDye.cs +++ b/Items/Dyes/ProfanedFlameDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/ProfanedMoonlightDye.cs b/Items/Dyes/ProfanedMoonlightDye.cs index b8c22da571..7b19417b60 100644 --- a/Items/Dyes/ProfanedMoonlightDye.cs +++ b/Items/Dyes/ProfanedMoonlightDye.cs @@ -1,9 +1,7 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/ProfanedRockDye.cs b/Items/Dyes/ProfanedRockDye.cs index d64f6ccb4e..453a937d93 100644 --- a/Items/Dyes/ProfanedRockDye.cs +++ b/Items/Dyes/ProfanedRockDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/ReaverDye.cs b/Items/Dyes/ReaverDye.cs index 79c887818b..7656aecb9f 100644 --- a/Items/Dyes/ReaverDye.cs +++ b/Items/Dyes/ReaverDye.cs @@ -1,11 +1,9 @@ using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/ScoriaDye.cs b/Items/Dyes/ScoriaDye.cs index 4059c25a39..aca8d2b7ef 100644 --- a/Items/Dyes/ScoriaDye.cs +++ b/Items/Dyes/ScoriaDye.cs @@ -1,12 +1,9 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Items.TreasureBags.MiscGrabBags; +using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Dyes/ShadowspecDye.cs b/Items/Dyes/ShadowspecDye.cs index 9b91514cae..7b99761c9e 100644 --- a/Items/Dyes/ShadowspecDye.cs +++ b/Items/Dyes/ShadowspecDye.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; diff --git a/Items/Dyes/SilvaDye.cs b/Items/Dyes/SilvaDye.cs index acf21b7865..94dadc6197 100644 --- a/Items/Dyes/SilvaDye.cs +++ b/Items/Dyes/SilvaDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/SlimeGodDye.cs b/Items/Dyes/SlimeGodDye.cs index 572c7d40f5..c5c7fc2546 100644 --- a/Items/Dyes/SlimeGodDye.cs +++ b/Items/Dyes/SlimeGodDye.cs @@ -1,10 +1,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.Dyes { diff --git a/Items/Dyes/StratusDye.cs b/Items/Dyes/StratusDye.cs index 788bcdcf42..b63feeef7f 100644 --- a/Items/Dyes/StratusDye.cs +++ b/Items/Dyes/StratusDye.cs @@ -3,7 +3,6 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; diff --git a/Items/Dyes/SwirlingCosmicFlameDye.cs b/Items/Dyes/SwirlingCosmicFlameDye.cs index 1fcab18fea..12f1d84a3f 100644 --- a/Items/Dyes/SwirlingCosmicFlameDye.cs +++ b/Items/Dyes/SwirlingCosmicFlameDye.cs @@ -1,7 +1,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Dyes public override void SafeSetDefaults() { - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = Item.sellPrice(gold: 1, silver: 50); } diff --git a/Items/Dyes/TarragonDye.cs b/Items/Dyes/TarragonDye.cs index a5384efa72..d6193e134f 100644 --- a/Items/Dyes/TarragonDye.cs +++ b/Items/Dyes/TarragonDye.cs @@ -1,13 +1,10 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Items.TreasureBags.MiscGrabBags; +using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes @@ -16,6 +13,10 @@ namespace CalamityMod.Items.Dyes { public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(Mod.Assets.Request("Effects/Dyes/TarragonDyeShader"), "DyePass"). UseColor(new Color(20, 117, 70)).UseSecondaryColor(new Color(28, 255, 55)).UseImage(Request("CalamityMod/ExtraTextures/GreyscaleGradients/Bark")); + public override void SafeSetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + } public override void SafeSetDefaults() { diff --git a/Items/Dyes/WulfrumDye.cs b/Items/Dyes/WulfrumDye.cs index e5c0125349..8ba542df38 100644 --- a/Items/Dyes/WulfrumDye.cs +++ b/Items/Dyes/WulfrumDye.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Dyes diff --git a/Items/Fishing/AstralCatches/UrsaSergeant.cs b/Items/Fishing/AstralCatches/UrsaSergeant.cs index 343875047f..82616a1b1e 100644 --- a/Items/Fishing/AstralCatches/UrsaSergeant.cs +++ b/Items/Fishing/AstralCatches/UrsaSergeant.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,8 +17,8 @@ namespace CalamityMod.Items.Fishing.AstralCatches { Item.width = 36; Item.height = 26; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; - Item.rare = ItemRarityID.LightRed; + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; Item.accessory = true; } diff --git a/Items/Fishing/BaseQuestFish.cs b/Items/Fishing/BaseQuestFish.cs index c2131da27a..7cf3ed426d 100644 --- a/Items/Fishing/BaseQuestFish.cs +++ b/Items/Fishing/BaseQuestFish.cs @@ -1,5 +1,4 @@ -using System.Text.RegularExpressions; -using Terraria.ID; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -15,7 +14,7 @@ namespace CalamityMod.Items.Fishing public virtual LocalizedText Location => LocalizedText.Empty; public new string LocalizationCategory => "Items.Fishing"; - public override LocalizedText Tooltip => Location; + public override LocalizedText Tooltip => CalamityUtils.GetText($"Items.Fishing.LocationTooltip").WithFormatArgs(Location); public override void SetStaticDefaults() { @@ -34,7 +33,7 @@ namespace CalamityMod.Items.Fishing public override void AnglerQuestChat(ref string description, ref string catchLocation) { description = this.GetLocalizedValue("QuestDescription"); - catchLocation = Location.ToString().Replace("'", string.Empty); + catchLocation = Location.ToString(); } } } diff --git a/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs b/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs index 9f73c7efe0..07e7f4cb50 100644 --- a/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs +++ b/Items/Fishing/BrimstoneCragCatches/Bloodfin.cs @@ -11,11 +11,11 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { public new string LocalizationCategory => "Items.Fishing"; - public static int RegenBoost = 5; - public static int RegenTimeBoost = 10; + public static int RegenBoost = 4; + public static int RegenTimeBoost = 4; public static int DebuffedRegenBoost = 10; // Does not stack with above - public static int DebuffedRegenTimeFloor = 1800; + public static int DebuffedRegenTimeFloor = 900; public static double ExtraRegenHealthThreshold = 0.75D; public static int FramesForExtraRegen = 30; diff --git a/Items/Fishing/BrimstoneCragCatches/Brimlish.cs b/Items/Fishing/BrimstoneCragCatches/Brimlish.cs index c87b275e4c..42199677ca 100644 --- a/Items/Fishing/BrimstoneCragCatches/Brimlish.cs +++ b/Items/Fishing/BrimstoneCragCatches/Brimlish.cs @@ -1,5 +1,4 @@ using Terraria.Localization; -using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { diff --git a/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs b/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs index 3542661795..bbf1466626 100644 --- a/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs +++ b/Items/Fishing/BrimstoneCragCatches/BrimstoneCrate.cs @@ -1,4 +1,6 @@ -using CalamityMod.Tiles.Crags; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Tiles.Crags; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -40,6 +42,17 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { + // 20-50 Scorched Bones @ 33.33% + // This is our equivalent to Bamboo + itemLoot.Add(ModContent.ItemType(), 3, 20, 50); + + // 2-5 Essences of Havoc @ 50% + // This is our equivalent to Souls of Light/Night + itemLoot.Add(ModContent.ItemType(), 2, 2, 5); + + // Slagfire Douser @ 10% + itemLoot.Add(ModContent.ItemType(), 10, 1, 1); + itemLoot.AddBiomeCrateLootRules(); } } diff --git a/Items/Fishing/BrimstoneCragCatches/Havocfish.cs b/Items/Fishing/BrimstoneCragCatches/Havocfish.cs index fd0a4060a8..5f7c052b3c 100644 --- a/Items/Fishing/BrimstoneCragCatches/Havocfish.cs +++ b/Items/Fishing/BrimstoneCragCatches/Havocfish.cs @@ -1,36 +1,13 @@ -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; +using Terraria; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.BrimstoneCragCatches { [LegacyName("ChaoticFish")] - public class Havocfish : ModItem, ILocalizedModType + public class Havocfish : BaseQuestFish { - public new string LocalizationCategory => "Items.Fishing"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 30; - Item.height = 28; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.value = Item.sellPrice(silver: 10); - Item.rare = ItemRarityID.Green; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.GoodieBags; - } - - public override bool CanRightClick() => true; - public override void ModifyItemLoot(ItemLoot itemLoot) => itemLoot.Add(ModContent.ItemType(), 1, 5, 10); + public override bool QuestCondition => Main.hardMode; + public override LocalizedText Location => CalamityUtils.GetText("Items.Fishing.CaughtInBrimstoneCrag"); } } diff --git a/Items/Fishing/BrimstoneCragCatches/Havocfish.png b/Items/Fishing/BrimstoneCragCatches/Havocfish.png index baea579f0a..3505b6f839 100644 Binary files a/Items/Fishing/BrimstoneCragCatches/Havocfish.png and b/Items/Fishing/BrimstoneCragCatches/Havocfish.png differ diff --git a/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs b/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs index ea62747e86..6d58c05f02 100644 --- a/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs +++ b/Items/Fishing/BrimstoneCragCatches/SlagCrate.cs @@ -1,4 +1,6 @@ -using CalamityMod.Tiles.Crags; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Tiles.Crags; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -30,6 +32,13 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override bool CanRightClick() => true; public override void ModifyItemLoot(ItemLoot itemLoot) { + // 20-50 Scorched Bones @ 33.33% + // This is our equivalent to Bamboo + itemLoot.Add(ModContent.ItemType(), 3, 20, 50); + + // Slagfire Douser @ 10% + itemLoot.Add(ModContent.ItemType(), 10, 1, 1); + itemLoot.AddBiomeCrateLootRules(false); } } diff --git a/Items/Fishing/FishingRods/EarlyBloomRod.cs b/Items/Fishing/FishingRods/EarlyBloomRod.cs index fa92d6cf33..417a8f5c16 100644 --- a/Items/Fishing/FishingRods/EarlyBloomRod.cs +++ b/Items/Fishing/FishingRods/EarlyBloomRod.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -27,11 +28,6 @@ namespace CalamityMod.Items.Fishing.FishingRods Item.rare = ModContent.RarityType(); } - public override void HoldItem(Player player) - { - player.accFishingLine = true; - } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { for (int i = 0; i < 6; i++) @@ -52,7 +48,7 @@ namespace CalamityMod.Items.Fishing.FishingRods CreateRecipe(). AddIngredient(ItemID.WoodFishingPole). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Fishing/FishingRods/FeralDoubleRod.cs b/Items/Fishing/FishingRods/FeralDoubleRod.cs index cf8ad0dc8e..46f766c8fb 100644 --- a/Items/Fishing/FishingRods/FeralDoubleRod.cs +++ b/Items/Fishing/FishingRods/FeralDoubleRod.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Fishing/FishingRods/HeronRod.cs b/Items/Fishing/FishingRods/HeronRod.cs index d7be7cc7ba..63f0aeb0d8 100644 --- a/Items/Fishing/FishingRods/HeronRod.cs +++ b/Items/Fishing/FishingRods/HeronRod.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -41,7 +42,7 @@ namespace CalamityMod.Items.Fishing.FishingRods CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.SunplateBlock, 3). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Fishing/FishingRods/NavyFishingRod.cs b/Items/Fishing/FishingRods/NavyFishingRod.cs index 686b065a72..9d1e09eda6 100644 --- a/Items/Fishing/FishingRods/NavyFishingRod.cs +++ b/Items/Fishing/FishingRods/NavyFishingRod.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; diff --git a/Items/Fishing/FishingRods/RiftReeler.cs b/Items/Fishing/FishingRods/RiftReeler.cs index 4de6da68e1..da0bc6e2f1 100644 --- a/Items/Fishing/FishingRods/RiftReeler.cs +++ b/Items/Fishing/FishingRods/RiftReeler.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -34,9 +35,9 @@ namespace CalamityMod.Items.Fishing.FishingRods public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int i = 0; i < Main.rand.Next(3, 6); i++) //3 to 5 bobbers + for (int i = 0; i < 4; i++) //4 bobbers { - Projectile.NewProjectile(source, position, velocity.RotatedByRandom(MathHelper.ToRadians(18f)), type, 0, 0f, player.whoAmI, ai2: Main.rand.Next(2)); + Projectile.NewProjectile(source, position, velocity.RotatedByRandom(MathHelper.ToRadians(45f)), type, 10, 1f, player.whoAmI, ai2: Main.rand.Next(2)); } return false; } @@ -47,7 +48,7 @@ namespace CalamityMod.Items.Fishing.FishingRods if (bobber.ai[2] == 0f) lineColor = new Color(255, 165, 0, 100); else - lineColor = new Color(0, 206, 209, 100); + lineColor = new Color(200, 206, 209, 100); } public override void AddRecipes() diff --git a/Items/Fishing/FishingRods/SlurperPole.cs b/Items/Fishing/FishingRods/SlurperPole.cs index cac04d7307..325841b117 100644 --- a/Items/Fishing/FishingRods/SlurperPole.cs +++ b/Items/Fishing/FishingRods/SlurperPole.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Typeless; +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -28,7 +29,6 @@ namespace CalamityMod.Items.Fishing.FishingRods Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; } - public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor) { lineOriginOffset = new Vector2(45f, -43f); diff --git a/Items/Fishing/FishingRods/TheDevourerofCods.cs b/Items/Fishing/FishingRods/TheDevourerofCods.cs index c05b8bb2ec..4d2de64f1f 100644 --- a/Items/Fishing/FishingRods/TheDevourerofCods.cs +++ b/Items/Fishing/FishingRods/TheDevourerofCods.cs @@ -1,4 +1,9 @@ -using CalamityMod.Items.Materials; +using System.Collections.Generic; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Fishing.AstralCatches; +using CalamityMod.Items.Fishing.BrimstoneCragCatches; +using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -12,6 +17,24 @@ namespace CalamityMod.Items.Fishing.FishingRods { public class TheDevourerofCods : ModItem, ILocalizedModType { + public static List FishToEat = new List() + { + ItemID.Bass, + ItemID.AtlanticCod, + ItemID.Flounder, + ItemID.NeonTetra, + ItemID.RedSnapper, + ItemID.RockLobster, + ItemID.Salmon, + ItemID.Shrimp, + ItemID.Trout, + ItemID.Tuna, + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; public new string LocalizationCategory => "Items.Fishing"; public override void SetStaticDefaults() { @@ -30,14 +53,21 @@ namespace CalamityMod.Items.Fishing.FishingRods Item.shootSpeed = 20f; Item.shoot = ModContent.ProjectileType(); Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void HoldItem(Player player) { + if (player.Calamity().SelectedFishingMinigame == CalamityPlayer.FishingMinigames.None) + player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.DevourerofCods; player.accFishingLine = true; } + public override void UpdateEquip(Player player) + { + player.Calamity().SelectedFishingMinigame = CalamityPlayer.FishingMinigames.DevourerofCods; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { for (int i = 0; i < 10; i++) diff --git a/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs b/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs index 74ef5cc142..d789304590 100644 --- a/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs +++ b/Items/Fishing/FishingRods/VerstaltiteFishingRod.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -29,7 +30,6 @@ namespace CalamityMod.Items.Fishing.FishingRods Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; } - public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor) { lineOriginOffset = new Vector2(43f, -36f); diff --git a/Items/Fishing/FishingRods/WulfrumRod.cs b/Items/Fishing/FishingRods/WulfrumRod.cs index d7309b4449..fe6708af6e 100644 --- a/Items/Fishing/FishingRods/WulfrumRod.cs +++ b/Items/Fishing/FishingRods/WulfrumRod.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -28,13 +29,13 @@ namespace CalamityMod.Items.Fishing.FishingRods public override void ModifyFishingLine(Projectile bobber, ref Vector2 lineOriginOffset, ref Color lineColor) { lineOriginOffset = new Vector2(35f, -27f); - lineColor = new Color(200, 200, 200, 100); + lineColor = Color.Lerp(Color.GreenYellow, Color.DeepSkyBlue, Main.player[bobber.owner].Calamity().consecutiveCaughtFish / 5f); } public override void AddRecipes() { CreateRecipe(). - AddIngredient(6). + AddIngredient(5). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Fishing/FishofEleum.cs b/Items/Fishing/FishofEleum.cs index 604c6816c2..c5f4cd2dde 100644 --- a/Items/Fishing/FishofEleum.cs +++ b/Items/Fishing/FishofEleum.cs @@ -1,35 +1,11 @@ -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria; +using Terraria.Localization; namespace CalamityMod.Items.Fishing { - public class FishofEleum : ModItem, ILocalizedModType + public class FishofEleum : BaseQuestFish { - public new string LocalizationCategory => "Items.Fishing"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 30; - Item.height = 28; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.value = Item.sellPrice(silver: 10); - Item.rare = ItemRarityID.Green; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.GoodieBags; - } - - public override bool CanRightClick() => true; - public override void ModifyItemLoot(ItemLoot itemLoot) => itemLoot.Add(ModContent.ItemType(), 1, 5, 10); + public override bool QuestCondition => Main.hardMode; + public override LocalizedText Location => CalamityUtils.GetText("Items.Fishing.CaughtInSnow"); } } diff --git a/Items/Fishing/FishofEleum.png b/Items/Fishing/FishofEleum.png index 0ad6566d78..3a58e44ed0 100644 Binary files a/Items/Fishing/FishofEleum.png and b/Items/Fishing/FishofEleum.png differ diff --git a/Items/Fishing/FishofFlight.png b/Items/Fishing/FishofFlight.png index 77d5a45afc..d782893eaf 100644 Binary files a/Items/Fishing/FishofFlight.png and b/Items/Fishing/FishofFlight.png differ diff --git a/Items/Fishing/FishofLight.cs b/Items/Fishing/FishofLight.cs deleted file mode 100644 index 23a1d31680..0000000000 --- a/Items/Fishing/FishofLight.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Fishing -{ - public class FishofLight : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Fishing"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 34; - Item.height = 34; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.value = Item.sellPrice(silver: 10); - Item.rare = ItemRarityID.Orange; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.GoodieBags; - } - - public override bool CanRightClick() => true; - public override void ModifyItemLoot(ItemLoot itemLoot) => itemLoot.Add(ItemID.SoulofLight, 1, 2, 5); - } -} diff --git a/Items/Fishing/FishofLight.png b/Items/Fishing/FishofLight.png deleted file mode 100644 index f5e002f90e..0000000000 Binary files a/Items/Fishing/FishofLight.png and /dev/null differ diff --git a/Items/Fishing/FishofNight.cs b/Items/Fishing/FishofNight.cs deleted file mode 100644 index 2ebc006bec..0000000000 --- a/Items/Fishing/FishofNight.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Fishing -{ - public class FishofNight : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Fishing"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 34; - Item.height = 34; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.value = Item.sellPrice(silver: 10); - Item.rare = ItemRarityID.Orange; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.GoodieBags; - } - - public override bool CanRightClick() => true; - public override void ModifyItemLoot(ItemLoot itemLoot) => itemLoot.Add(ItemID.SoulofNight, 1, 2, 5); - } -} diff --git a/Items/Fishing/FishofNight.png b/Items/Fishing/FishofNight.png deleted file mode 100644 index 1087149c14..0000000000 Binary files a/Items/Fishing/FishofNight.png and /dev/null differ diff --git a/Items/Fishing/GlimmeringGemfish.cs b/Items/Fishing/GlimmeringGemfish.cs index b9921dc101..104d5559ac 100644 --- a/Items/Fishing/GlimmeringGemfish.cs +++ b/Items/Fishing/GlimmeringGemfish.cs @@ -62,13 +62,13 @@ namespace CalamityMod.Items.Fishing if (aquamarine is not null) itemLoot.Add(aquamarine.Type, 4, gemMin, gemMax); else - CalamityMod.Instance.Logger.Warn("Could not find Thorium Aquamarine gem. This item will not be added to Glimmering Gemfish."); + CalamityMod.Log.Warn("Could not find Thorium Aquamarine gem. This item will not be added to Glimmering Gemfish."); var opal = thorium.Find("Opal"); if (opal is not null) itemLoot.Add(opal.Type, 4, gemMin, gemMax); else - CalamityMod.Instance.Logger.Warn("Could not find Thorium Opal gem. This item will not be added to Glimmering Gemfish."); + CalamityMod.Log.Warn("Could not find Thorium Opal gem. This item will not be added to Glimmering Gemfish."); } public override void ModifyTooltips(List list) diff --git a/Items/Fishing/GrandMarquisBait.cs b/Items/Fishing/GrandMarquisBait.cs index 21b68505b6..b9eb6d833e 100644 --- a/Items/Fishing/GrandMarquisBait.cs +++ b/Items/Fishing/GrandMarquisBait.cs @@ -1,6 +1,4 @@ -using CalamityMod.NPCs.AcidRain; -using CalamityMod.Rarities; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Fishing/Spadefish.cs b/Items/Fishing/Spadefish.cs index 481b516ad1..a7c0df913e 100644 --- a/Items/Fishing/Spadefish.cs +++ b/Items/Fishing/Spadefish.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Fishing diff --git a/Items/Fishing/StuffedFish.cs b/Items/Fishing/StuffedFish.cs index 1c179ef7e2..658d83fb17 100644 --- a/Items/Fishing/StuffedFish.cs +++ b/Items/Fishing/StuffedFish.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Items.Fishing itemLoot.Add(marineKelpSeeds.Type, 10, seedMin, seedMax); } else - CalamityMod.Instance.Logger.Warn("Could not find either Marine Kelp or Marine Kelp Seeds from Thorium. These items will not be added to Stuffed Fish."); + CalamityMod.Log.Warn("Could not find either Marine Kelp or Marine Kelp Seeds from Thorium. These items will not be added to Stuffed Fish."); // Ozzatron 30DEC2022: It is unlikely SoA will ever be ported to 1.4 and beyond. Commenting this out indefinitely. /* @@ -133,7 +133,7 @@ namespace CalamityMod.Items.Fishing } catch { - CalamityMod.Instance.Logger.Debug("One of the items in this file got renamed internally. Please report this in the #bugs-read-pins channel of the official Calamity discord server."); + CalamityMod.Log.Debug("One of the items in this file got renamed internally. Please report this in the #bugs-read-pins channel of the official Calamity discord server."); } } */ diff --git a/Items/Fishing/SulphurCatches/HydrothermalCrate.cs b/Items/Fishing/SulphurCatches/HydrothermalCrate.cs index 8aa67f0bd6..eb343ed2e4 100644 --- a/Items/Fishing/SulphurCatches/HydrothermalCrate.cs +++ b/Items/Fishing/SulphurCatches/HydrothermalCrate.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Tools.ClimateChange; +using CalamityMod.Items.Tools.SpawnBlocker; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -55,7 +56,7 @@ namespace CalamityMod.Items.Fishing.SulphurCatches ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType() + ModContent.ItemType() )); // Ancient Treasure Chest Loot @ 100%; Individually 10% diff --git a/Items/Fishing/SulphurCatches/SulphurousCrate.cs b/Items/Fishing/SulphurCatches/SulphurousCrate.cs index 692e01abdb..e50e4940d0 100644 --- a/Items/Fishing/SulphurCatches/SulphurousCrate.cs +++ b/Items/Fishing/SulphurCatches/SulphurousCrate.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Items.Tools.SpawnBlocker; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Tiles.Abyss; using Terraria; @@ -48,7 +49,7 @@ namespace CalamityMod.Items.Fishing.SulphurCatches ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType() + ModContent.ItemType() )); itemLoot.AddBiomeCrateLootRules(false); diff --git a/Items/Fishing/SunbeamFish.cs b/Items/Fishing/SunbeamFish.cs index 31bfb3b70b..5848a1f3be 100644 --- a/Items/Fishing/SunbeamFish.cs +++ b/Items/Fishing/SunbeamFish.cs @@ -1,35 +1,11 @@ -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria; +using Terraria.Localization; namespace CalamityMod.Items.Fishing { - public class SunbeamFish : ModItem, ILocalizedModType + public class SunbeamFish : BaseQuestFish { - public new string LocalizationCategory => "Items.Fishing"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 30; - Item.height = 28; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.value = Item.sellPrice(silver: 10); - Item.rare = ItemRarityID.Green; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.GoodieBags; - } - - public override bool CanRightClick() => true; - public override void ModifyItemLoot(ItemLoot itemLoot) => itemLoot.Add(ModContent.ItemType(), 1, 5, 10); + public override bool QuestCondition => Main.hardMode; + public override LocalizedText Location => CalamityUtils.GetText("Items.Fishing.CaughtInSpace"); } } diff --git a/Items/Fishing/SunbeamFish.png b/Items/Fishing/SunbeamFish.png index 934161fe30..facbc7ebf4 100644 Binary files a/Items/Fishing/SunbeamFish.png and b/Items/Fishing/SunbeamFish.png differ diff --git a/Items/Fishing/SunkenSeaCatches/CoralskinFoolfish.cs b/Items/Fishing/SunkenSeaCatches/CoralskinFoolfish.cs new file mode 100644 index 0000000000..28f3a54bcf --- /dev/null +++ b/Items/Fishing/SunkenSeaCatches/CoralskinFoolfish.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Fishing.SunkenSeaCatches +{ + public class CoralskinFoolfish : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 32; + Item.height = 36; + Item.maxStack = Item.CommonMaxStack; + Item.value = Item.sellPrice(silver: 5); + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Fish; + } + } +} diff --git a/Items/Fishing/SunkenSeaCatches/CoralskinFoolfish.png b/Items/Fishing/SunkenSeaCatches/CoralskinFoolfish.png new file mode 100644 index 0000000000..bae900260f Binary files /dev/null and b/Items/Fishing/SunkenSeaCatches/CoralskinFoolfish.png differ diff --git a/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs b/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs index 308fe9e4d2..c3b72b6b32 100644 --- a/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs @@ -1,3 +1,4 @@ +using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Tiles.SunkenSea; using Terraria; using Terraria.GameContent.ItemDropRules; @@ -37,9 +38,13 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches { ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), - ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) })); + // 4-10 Prism Shards @ 50% + // This is our equivalent to Crystal Shards/Ichor + itemLoot.Add(ModContent.ItemType(), 2, 4, 10); + itemLoot.AddBiomeCrateLootRules(false); } } diff --git a/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs b/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs index bff850cbf8..57c836111d 100644 --- a/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs +++ b/Items/Fishing/SunkenSeaCatches/EutrophicSandfish.cs @@ -1,5 +1,4 @@ using Terraria.Localization; -using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { diff --git a/Items/Fishing/SunkenSeaCatches/GleamingCucumber.cs b/Items/Fishing/SunkenSeaCatches/GleamingCucumber.cs new file mode 100644 index 0000000000..b1bfd29d2a --- /dev/null +++ b/Items/Fishing/SunkenSeaCatches/GleamingCucumber.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Fishing.SunkenSeaCatches +{ + public class GleamingCucumber : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 32; + Item.height = 36; + Item.maxStack = Item.CommonMaxStack; + Item.value = Item.sellPrice(silver: 5); + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Fish; + } + } +} diff --git a/Items/Fishing/SunkenSeaCatches/GleamingCucumber.png b/Items/Fishing/SunkenSeaCatches/GleamingCucumber.png new file mode 100644 index 0000000000..156adc559c Binary files /dev/null and b/Items/Fishing/SunkenSeaCatches/GleamingCucumber.png differ diff --git a/Items/Fishing/SunkenSeaCatches/MoltenFishron.cs b/Items/Fishing/SunkenSeaCatches/MoltenFishron.cs new file mode 100644 index 0000000000..f41ff91868 --- /dev/null +++ b/Items/Fishing/SunkenSeaCatches/MoltenFishron.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Fishing.SunkenSeaCatches +{ + public class MoltenFishron : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 32; + Item.height = 36; + Item.maxStack = Item.CommonMaxStack; + Item.value = Item.sellPrice(silver: 7, copper: 50); + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Fish; + } + } +} diff --git a/Items/Fishing/SunkenSeaCatches/MoltenFishron.png b/Items/Fishing/SunkenSeaCatches/MoltenFishron.png new file mode 100644 index 0000000000..f306c72875 Binary files /dev/null and b/Items/Fishing/SunkenSeaCatches/MoltenFishron.png differ diff --git a/Items/Fishing/SunkenSeaCatches/PrismCrate.cs b/Items/Fishing/SunkenSeaCatches/PrismCrate.cs index 57b33bb787..357fc7c928 100644 --- a/Items/Fishing/SunkenSeaCatches/PrismCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/PrismCrate.cs @@ -1,3 +1,4 @@ +using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Tiles.SunkenSea; using Terraria; using Terraria.GameContent.ItemDropRules; @@ -38,9 +39,13 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches { ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50), - ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) + ItemDropRule.NotScalingWithLuck(ModContent.ItemType(), 1, 20, 50) })); + // 4-10 Prism Shards @ 50% + // This is our equivalent to Crystal Shards/Ichor + itemLoot.Add(ModContent.ItemType(), 2, 4, 10); + itemLoot.AddBiomeCrateLootRules(); } } diff --git a/Items/Fishing/SunkenSeaCatches/PrismaticGuppy.cs b/Items/Fishing/SunkenSeaCatches/PrismaticGuppy.cs deleted file mode 100644 index a3710b6d73..0000000000 --- a/Items/Fishing/SunkenSeaCatches/PrismaticGuppy.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Fishing.SunkenSeaCatches -{ - public class PrismaticGuppy : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Fishing"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 3; - ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 30; - Item.height = 28; - Item.maxStack = Item.CommonMaxStack; - Item.value = Item.sellPrice(silver: 5); - Item.rare = ItemRarityID.Green; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.Fish; - } - } -} diff --git a/Items/Fishing/SunkenSeaCatches/PrismaticGuppy.png b/Items/Fishing/SunkenSeaCatches/PrismaticGuppy.png deleted file mode 100644 index 9d9615c91c..0000000000 Binary files a/Items/Fishing/SunkenSeaCatches/PrismaticGuppy.png and /dev/null differ diff --git a/Items/Fishing/SunkenSeaCatches/Serpentuna.cs b/Items/Fishing/SunkenSeaCatches/Serpentuna.cs index 49c8f2bbe1..1decc33e86 100644 --- a/Items/Fishing/SunkenSeaCatches/Serpentuna.cs +++ b/Items/Fishing/SunkenSeaCatches/Serpentuna.cs @@ -1,6 +1,5 @@ using Terraria; using Terraria.Localization; -using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { diff --git a/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs b/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs index 10d3c10150..1598f50cea 100644 --- a/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs +++ b/Items/Fishing/SunkenSeaCatches/SparklingEmpress.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches Item.damage = 11; Item.DamageType = DamageClass.Magic; Item.mana = 3; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 8; Item.knockBack = 0.25f; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 5f; diff --git a/Items/Fishing/SunkenSeaCatches/SpecularSturgeon.cs b/Items/Fishing/SunkenSeaCatches/SpecularSturgeon.cs new file mode 100644 index 0000000000..1a1ffa6fe4 --- /dev/null +++ b/Items/Fishing/SunkenSeaCatches/SpecularSturgeon.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Fishing.SunkenSeaCatches +{ + public class SpecularSturgeon : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 32; + Item.height = 36; + Item.maxStack = Item.CommonMaxStack; + Item.value = Item.sellPrice(silver: 5); + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Fish; + } + } +} diff --git a/Items/Fishing/SunkenSeaCatches/SpecularSturgeon.png b/Items/Fishing/SunkenSeaCatches/SpecularSturgeon.png new file mode 100644 index 0000000000..e43f598d86 Binary files /dev/null and b/Items/Fishing/SunkenSeaCatches/SpecularSturgeon.png differ diff --git a/Items/Fishing/SunkenSeaCatches/Squidoom.cs b/Items/Fishing/SunkenSeaCatches/Squidoom.cs new file mode 100644 index 0000000000..4daece1bdc --- /dev/null +++ b/Items/Fishing/SunkenSeaCatches/Squidoom.cs @@ -0,0 +1,30 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Fishing.SunkenSeaCatches +{ + public class Squidoom : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Fishing"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 32; + Item.height = 36; + Item.maxStack = Item.CommonMaxStack; + Item.value = Item.sellPrice(silver: 5); + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Fish; + } + } +} diff --git a/Items/Fishing/SunkenSeaCatches/Squidoom.png b/Items/Fishing/SunkenSeaCatches/Squidoom.png new file mode 100644 index 0000000000..c165b54de4 Binary files /dev/null and b/Items/Fishing/SunkenSeaCatches/Squidoom.png differ diff --git a/Items/Fishing/SunkenSeaCatches/SurfClam.cs b/Items/Fishing/SunkenSeaCatches/SurfClam.cs index a5f1258d61..6a02fce6ac 100644 --- a/Items/Fishing/SunkenSeaCatches/SurfClam.cs +++ b/Items/Fishing/SunkenSeaCatches/SurfClam.cs @@ -1,5 +1,4 @@ using Terraria.Localization; -using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.SunkenSeaCatches { diff --git a/Items/GrabRangeGlobalItem.cs b/Items/GrabRangeGlobalItem.cs new file mode 100644 index 0000000000..8236179656 --- /dev/null +++ b/Items/GrabRangeGlobalItem.cs @@ -0,0 +1,37 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items; + +internal sealed class GrabRangeGlobalItem : GlobalItem +{ + /// + /// If set to a value greater than 1, applies a multiplier to the item's grab range.
+ /// Used by coin items spawned from hitting ricoshot coins. + ///
+ public float grabRangeMultiplier = 1f; + + public override bool InstancePerEntity => true; + + public override bool AppliesToEntity(Item entity, bool lateInstantiation) + { + return entity.type switch + { + ItemID.CopperCoin + or ItemID.SilverCoin + or ItemID.GoldCoin + or ItemID.PlatinumCoin => true, + _ => false, + }; + } + + public override GlobalItem Clone(Item item, Item itemClone) + { + GrabRangeGlobalItem myClone = (GrabRangeGlobalItem)base.Clone(item, itemClone); + myClone.grabRangeMultiplier = grabRangeMultiplier; + return myClone; + } + + // GrabRange hook is Placed in CalamityGlobalItem for sake of ordering +} diff --git a/Items/IHoldShiftTooltipItem.cs b/Items/IHoldShiftTooltipItem.cs index 8ef0a22b79..28938b7a60 100644 --- a/Items/IHoldShiftTooltipItem.cs +++ b/Items/IHoldShiftTooltipItem.cs @@ -2,7 +2,7 @@ namespace CalamityMod.Items { - // This interface is used on items where you can hold Left SHIFT for an expanded tooltip. + // This interface is used on items where you can hold SHIFT for an expanded tooltip. // All actual implementation of this behavior is done in CalamityGlobalItemTooltip. public interface IHoldShiftTooltipItem { @@ -52,7 +52,7 @@ namespace CalamityMod.Items #endregion /// - /// Whether holding Left SHIFT for the tooltip extension hides the normal tooltip. Typically this is false. + /// Whether holding SHIFT for the tooltip extension hides the normal tooltip. Typically this is false. /// public virtual bool HidesNormalTooltip => false; diff --git a/Items/LoreItems/LoreAbyss.cs b/Items/LoreItems/LoreAbyss.cs index a6f51943a2..b12fcdfecd 100644 --- a/Items/LoreItems/LoreAbyss.cs +++ b/Items/LoreItems/LoreAbyss.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreAquaticScourge.cs b/Items/LoreItems/LoreAquaticScourge.cs index 80f1ea0560..59eb8a3466 100644 --- a/Items/LoreItems/LoreAquaticScourge.cs +++ b/Items/LoreItems/LoreAquaticScourge.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreArchmage.cs b/Items/LoreItems/LoreArchmage.cs index 7891f9cb3c..9ef85f4a73 100644 --- a/Items/LoreItems/LoreArchmage.cs +++ b/Items/LoreItems/LoreArchmage.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreAstralInfection.cs b/Items/LoreItems/LoreAstralInfection.cs index 8f34560423..dd46dc0ba1 100644 --- a/Items/LoreItems/LoreAstralInfection.cs +++ b/Items/LoreItems/LoreAstralInfection.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreAstrumAureus.cs b/Items/LoreItems/LoreAstrumAureus.cs index 638cbf19f1..67352aae8e 100644 --- a/Items/LoreItems/LoreAstrumAureus.cs +++ b/Items/LoreItems/LoreAstrumAureus.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreAstrumDeus.cs b/Items/LoreItems/LoreAstrumDeus.cs index ca3edbba33..50b02ba744 100644 --- a/Items/LoreItems/LoreAstrumDeus.cs +++ b/Items/LoreItems/LoreAstrumDeus.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreAwakening.cs b/Items/LoreItems/LoreAwakening.cs index 4d5c076f49..b86105668a 100644 --- a/Items/LoreItems/LoreAwakening.cs +++ b/Items/LoreItems/LoreAwakening.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; namespace CalamityMod.Items.LoreItems { diff --git a/Items/LoreItems/LoreAzafure.cs b/Items/LoreItems/LoreAzafure.cs index 7f1e484d2e..179b7a2bea 100644 --- a/Items/LoreItems/LoreAzafure.cs +++ b/Items/LoreItems/LoreAzafure.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreBloodMoon.cs b/Items/LoreItems/LoreBloodMoon.cs index ec7a3217bd..804462f451 100644 --- a/Items/LoreItems/LoreBloodMoon.cs +++ b/Items/LoreItems/LoreBloodMoon.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreBrainofCthulhu.cs b/Items/LoreItems/LoreBrainofCthulhu.cs index 8e19c9333a..3626a652ac 100644 --- a/Items/LoreItems/LoreBrainofCthulhu.cs +++ b/Items/LoreItems/LoreBrainofCthulhu.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreBrimstoneElemental.cs b/Items/LoreItems/LoreBrimstoneElemental.cs index c34c9eef6e..513620bda8 100644 --- a/Items/LoreItems/LoreBrimstoneElemental.cs +++ b/Items/LoreItems/LoreBrimstoneElemental.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreCalamitas.cs b/Items/LoreItems/LoreCalamitas.cs index d6631d6b8c..bc024f9682 100644 --- a/Items/LoreItems/LoreCalamitas.cs +++ b/Items/LoreItems/LoreCalamitas.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.LoreItems Item.width = 20; Item.height = 20; Item.consumable = false; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void AddRecipes() diff --git a/Items/LoreItems/LoreCalamitasClone.cs b/Items/LoreItems/LoreCalamitasClone.cs index 632799c87a..dc059447c8 100644 --- a/Items/LoreItems/LoreCalamitasClone.cs +++ b/Items/LoreItems/LoreCalamitasClone.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreCeaselessVoid.cs b/Items/LoreItems/LoreCeaselessVoid.cs index af2cf17213..a10cb45a55 100644 --- a/Items/LoreItems/LoreCeaselessVoid.cs +++ b/Items/LoreItems/LoreCeaselessVoid.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreCorruption.cs b/Items/LoreItems/LoreCorruption.cs index 47be6ac825..fe100506c0 100644 --- a/Items/LoreItems/LoreCorruption.cs +++ b/Items/LoreItems/LoreCorruption.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreCrabulon.cs b/Items/LoreItems/LoreCrabulon.cs index 1b327232ce..278fc8ee8e 100644 --- a/Items/LoreItems/LoreCrabulon.cs +++ b/Items/LoreItems/LoreCrabulon.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreCrimson.cs b/Items/LoreItems/LoreCrimson.cs index e1b02ae34e..a7da600546 100644 --- a/Items/LoreItems/LoreCrimson.cs +++ b/Items/LoreItems/LoreCrimson.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreCynosure.cs b/Items/LoreItems/LoreCynosure.cs index a3bcad0756..e0f22a398e 100644 --- a/Items/LoreItems/LoreCynosure.cs +++ b/Items/LoreItems/LoreCynosure.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.LoreItems Item.width = 20; Item.height = 20; Item.consumable = false; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void AddRecipes() diff --git a/Items/LoreItems/LoreDesertScourge.cs b/Items/LoreItems/LoreDesertScourge.cs index 6ef621a9a3..bda2ff92df 100644 --- a/Items/LoreItems/LoreDesertScourge.cs +++ b/Items/LoreItems/LoreDesertScourge.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreDestroyer.cs b/Items/LoreItems/LoreDestroyer.cs index 41dcfb47d9..7d2d2d36ed 100644 --- a/Items/LoreItems/LoreDestroyer.cs +++ b/Items/LoreItems/LoreDestroyer.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreDevourerofGods.cs b/Items/LoreItems/LoreDevourerofGods.cs index 04ca63eed8..b86155f484 100644 --- a/Items/LoreItems/LoreDevourerofGods.cs +++ b/Items/LoreItems/LoreDevourerofGods.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.LoreItems Item.width = 20; Item.height = 20; Item.consumable = false; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void AddRecipes() diff --git a/Items/LoreItems/LoreDragonfolly.cs b/Items/LoreItems/LoreDragonfolly.cs index d23a23311d..5d59b6896d 100644 --- a/Items/LoreItems/LoreDragonfolly.cs +++ b/Items/LoreItems/LoreDragonfolly.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreDukeFishron.cs b/Items/LoreItems/LoreDukeFishron.cs index 5ddb9ba12a..a4a650402b 100644 --- a/Items/LoreItems/LoreDukeFishron.cs +++ b/Items/LoreItems/LoreDukeFishron.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreEaterofWorlds.cs b/Items/LoreItems/LoreEaterofWorlds.cs index eee2f8a643..904b4a0349 100644 --- a/Items/LoreItems/LoreEaterofWorlds.cs +++ b/Items/LoreItems/LoreEaterofWorlds.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreEmpressofLight.cs b/Items/LoreItems/LoreEmpressofLight.cs index 36905f353e..5cc85a586a 100644 --- a/Items/LoreItems/LoreEmpressofLight.cs +++ b/Items/LoreItems/LoreEmpressofLight.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; namespace CalamityMod.Items.LoreItems { diff --git a/Items/LoreItems/LoreExoMechs.cs b/Items/LoreItems/LoreExoMechs.cs index caeab5e015..e198a77bac 100644 --- a/Items/LoreItems/LoreExoMechs.cs +++ b/Items/LoreItems/LoreExoMechs.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.LoreItems Item.width = 20; Item.height = 20; Item.consumable = false; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } diff --git a/Items/LoreItems/LoreEyeofCthulhu.cs b/Items/LoreItems/LoreEyeofCthulhu.cs index 400a18f4fa..288ca0a0a1 100644 --- a/Items/LoreItems/LoreEyeofCthulhu.cs +++ b/Items/LoreItems/LoreEyeofCthulhu.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreGolem.cs b/Items/LoreItems/LoreGolem.cs index 5b46f6cc0e..5735ec90fd 100644 --- a/Items/LoreItems/LoreGolem.cs +++ b/Items/LoreItems/LoreGolem.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreHiveMind.cs b/Items/LoreItems/LoreHiveMind.cs index ab3f45df22..e9efc8ac96 100644 --- a/Items/LoreItems/LoreHiveMind.cs +++ b/Items/LoreItems/LoreHiveMind.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreKingSlime.cs b/Items/LoreItems/LoreKingSlime.cs index 876b61d992..e415934bc5 100644 --- a/Items/LoreItems/LoreKingSlime.cs +++ b/Items/LoreItems/LoreKingSlime.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreLeviathanAnahita.cs b/Items/LoreItems/LoreLeviathanAnahita.cs index ea507492ed..a16dcac4d9 100644 --- a/Items/LoreItems/LoreLeviathanAnahita.cs +++ b/Items/LoreItems/LoreLeviathanAnahita.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreMechs.cs b/Items/LoreItems/LoreMechs.cs index 6c1eb400ea..b18266ec4f 100644 --- a/Items/LoreItems/LoreMechs.cs +++ b/Items/LoreItems/LoreMechs.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreOldDuke.cs b/Items/LoreItems/LoreOldDuke.cs index d677a62ec2..dcbb76b649 100644 --- a/Items/LoreItems/LoreOldDuke.cs +++ b/Items/LoreItems/LoreOldDuke.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LorePerforators.cs b/Items/LoreItems/LorePerforators.cs index 7005b5cbc9..08969d1132 100644 --- a/Items/LoreItems/LorePerforators.cs +++ b/Items/LoreItems/LorePerforators.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LorePlaguebringerGoliath.cs b/Items/LoreItems/LorePlaguebringerGoliath.cs index fe10078868..d1023e95db 100644 --- a/Items/LoreItems/LorePlaguebringerGoliath.cs +++ b/Items/LoreItems/LorePlaguebringerGoliath.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LorePlantera.cs b/Items/LoreItems/LorePlantera.cs index b550bdeb1e..09493e60cb 100644 --- a/Items/LoreItems/LorePlantera.cs +++ b/Items/LoreItems/LorePlantera.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LorePolterghast.cs b/Items/LoreItems/LorePolterghast.cs index 3f8d8afee8..46c9466ec0 100644 --- a/Items/LoreItems/LorePolterghast.cs +++ b/Items/LoreItems/LorePolterghast.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LorePrelude.cs b/Items/LoreItems/LorePrelude.cs index 7db1fe7f93..6d7f76cc4d 100644 --- a/Items/LoreItems/LorePrelude.cs +++ b/Items/LoreItems/LorePrelude.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreProfanedGuardians.cs b/Items/LoreItems/LoreProfanedGuardians.cs index 759796f540..8578ab3f89 100644 --- a/Items/LoreItems/LoreProfanedGuardians.cs +++ b/Items/LoreItems/LoreProfanedGuardians.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreProvidence.cs b/Items/LoreItems/LoreProvidence.cs index d1870d448c..fc24a2de8d 100644 --- a/Items/LoreItems/LoreProvidence.cs +++ b/Items/LoreItems/LoreProvidence.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreQueenBee.cs b/Items/LoreItems/LoreQueenBee.cs index b5cf40ac40..b410ac2497 100644 --- a/Items/LoreItems/LoreQueenBee.cs +++ b/Items/LoreItems/LoreQueenBee.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreQueenSlime.cs b/Items/LoreItems/LoreQueenSlime.cs index db2dc74ee0..e485d744ea 100644 --- a/Items/LoreItems/LoreQueenSlime.cs +++ b/Items/LoreItems/LoreQueenSlime.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; namespace CalamityMod.Items.LoreItems { diff --git a/Items/LoreItems/LoreRavager.cs b/Items/LoreItems/LoreRavager.cs index 6c04fdbda9..8ec3a53199 100644 --- a/Items/LoreItems/LoreRavager.cs +++ b/Items/LoreItems/LoreRavager.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreRequiem.cs b/Items/LoreItems/LoreRequiem.cs index fcd196ac39..72d3c8b63c 100644 --- a/Items/LoreItems/LoreRequiem.cs +++ b/Items/LoreItems/LoreRequiem.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreSignus.cs b/Items/LoreItems/LoreSignus.cs index 1d36cba0c0..4e4c9702d3 100644 --- a/Items/LoreItems/LoreSignus.cs +++ b/Items/LoreItems/LoreSignus.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreSkeletron.cs b/Items/LoreItems/LoreSkeletron.cs index 6d32a35e8a..37b1d2072a 100644 --- a/Items/LoreItems/LoreSkeletron.cs +++ b/Items/LoreItems/LoreSkeletron.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreSkeletronPrime.cs b/Items/LoreItems/LoreSkeletronPrime.cs index 28d1e14861..fa29a7d453 100644 --- a/Items/LoreItems/LoreSkeletronPrime.cs +++ b/Items/LoreItems/LoreSkeletronPrime.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreSlimeGod.cs b/Items/LoreItems/LoreSlimeGod.cs index 14c9502154..2c647d95b5 100644 --- a/Items/LoreItems/LoreSlimeGod.cs +++ b/Items/LoreItems/LoreSlimeGod.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreStormWeaver.cs b/Items/LoreItems/LoreStormWeaver.cs index bf3876ea33..e349894d69 100644 --- a/Items/LoreItems/LoreStormWeaver.cs +++ b/Items/LoreItems/LoreStormWeaver.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreSulphurSea.cs b/Items/LoreItems/LoreSulphurSea.cs index 383f33e51d..9667571d23 100644 --- a/Items/LoreItems/LoreSulphurSea.cs +++ b/Items/LoreItems/LoreSulphurSea.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/LoreItems/LoreTwins.cs b/Items/LoreItems/LoreTwins.cs index 00ef8d4beb..c7fc10b02c 100644 --- a/Items/LoreItems/LoreTwins.cs +++ b/Items/LoreItems/LoreTwins.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreUnderworld.cs b/Items/LoreItems/LoreUnderworld.cs index 0e9092a044..be6f068ead 100644 --- a/Items/LoreItems/LoreUnderworld.cs +++ b/Items/LoreItems/LoreUnderworld.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreWallofFlesh.cs b/Items/LoreItems/LoreWallofFlesh.cs index 79f4f93d84..8cda673a16 100644 --- a/Items/LoreItems/LoreWallofFlesh.cs +++ b/Items/LoreItems/LoreWallofFlesh.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems diff --git a/Items/LoreItems/LoreYharon.cs b/Items/LoreItems/LoreYharon.cs index 274e3a1d2c..e087890234 100644 --- a/Items/LoreItems/LoreYharon.cs +++ b/Items/LoreItems/LoreYharon.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Rarities; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.LoreItems Item.width = 20; Item.height = 20; Item.consumable = false; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void AddRecipes() diff --git a/Items/Materials/AncientBoneDust.png b/Items/Materials/AncientBoneDust.png index bfc4a93b0a..8412048c41 100644 Binary files a/Items/Materials/AncientBoneDust.png and b/Items/Materials/AncientBoneDust.png differ diff --git a/Items/Materials/AnodizedWulfrumMetal.cs b/Items/Materials/AnodizedWulfrumMetal.cs new file mode 100644 index 0000000000..6dfcdf503f --- /dev/null +++ b/Items/Materials/AnodizedWulfrumMetal.cs @@ -0,0 +1,37 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Materials +{ + public class AnodizedWulfrumMetal : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Materials"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 25; + } + + public override void SetDefaults() + { + Item.width = 18; + Item.height = 18; + Item.maxStack = Item.CommonMaxStack; + Item.value = Item.sellPrice(copper: 10); + Item.rare = ItemRarityID.Blue; + Item.ammo = Item.type; + } + public override void AddRecipes() + { + CreateRecipe(1). + AddIngredient(). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + //Added to avoid making the recipes really repetitive and nonsensical. It also makes the new metal color make sense. Adds a bit of flavor to the Wulfrum Recipes + //Uses Stormlion Manible because in order to anodize a metal you must use a current, the other option was a Power Cell but I feel Stormlion Mandible needed more uses + //More uses are planned for other blocks and furniture for wulfrum that use this new metal color and gives a bit more depth to the set + } +} diff --git a/Items/Materials/AnodizedWulfrumMetal.png b/Items/Materials/AnodizedWulfrumMetal.png new file mode 100644 index 0000000000..0e901b9399 Binary files /dev/null and b/Items/Materials/AnodizedWulfrumMetal.png differ diff --git a/Items/Materials/AscendantSpiritEssence.cs b/Items/Materials/AscendantSpiritEssence.cs index 731d9c31c9..4a4e6c3f24 100644 --- a/Items/Materials/AscendantSpiritEssence.cs +++ b/Items/Materials/AscendantSpiritEssence.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Materials Item.height = 54; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(gold: 6); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) { @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Materials AddIngredient(5). AddIngredient(5). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Materials/AshesofAnnihilation.cs b/Items/Materials/AshesofAnnihilation.cs index 5b3565422d..38efcdd53a 100644 --- a/Items/Materials/AshesofAnnihilation.cs +++ b/Items/Materials/AshesofAnnihilation.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Materials Item.height = 56; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(gold: 6, silver: 66, copper: 66); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public void DrawPulsingAfterimage(SpriteBatch spriteBatch, Vector2 baseDrawPosition, Rectangle frame, float baseScale) { diff --git a/Items/Materials/AstralBar.cs b/Items/Materials/AstralBar.cs index d9b21326f3..c216053063 100644 --- a/Items/Materials/AstralBar.cs +++ b/Items/Materials/AstralBar.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Items.Materials Item.ResearchUnlockCount = 25; ItemID.Sets.SortingPriorityMaterials[Type] = 99; // Luminite ItemID.Sets.AnimatesAsSoul[Type] = true; + ItemTrader.ChlorophyteExtractinator.AddOption_OneWay(Type, 1, ItemID.MeteoriteBar, 1); Main.RegisterItemAnimation(Type, new DrawAnimationVertical(5, 12)); } diff --git a/Items/Materials/AuricBar.cs b/Items/Materials/AuricBar.cs index c16a1a60e2..e380657ca7 100644 --- a/Items/Materials/AuricBar.cs +++ b/Items/Materials/AuricBar.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; using CalamityMod.Tiles; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -32,7 +31,7 @@ namespace CalamityMod.Items.Materials ItemID.Sets.SortingPriorityMaterials[Type] = 120; ItemID.Sets.AnimatesAsSoul[Type] = true; ItemID.Sets.ItemNoGravity[Type] = true; - Main.RegisterItemAnimation(Type, new DrawAnimationVertical(5, 12)); + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(5, 4)); } public override void Unload() @@ -44,7 +43,7 @@ namespace CalamityMod.Items.Materials { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 7); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UseStyle(Player player, Rectangle heldItemFrame) @@ -94,7 +93,7 @@ namespace CalamityMod.Items.Materials CreateRecipe(5). AddIngredient(50). AddIngredient(). - AddTile(). + AddTile(TileID.AdamantiteForge). Register(); } } diff --git a/Items/Materials/AuricBar.png b/Items/Materials/AuricBar.png index 3f6b3f271a..80a05befba 100644 Binary files a/Items/Materials/AuricBar.png and b/Items/Materials/AuricBar.png differ diff --git a/Items/Materials/AuricBar_Glow.png b/Items/Materials/AuricBar_Glow.png index d80546d13a..fb946adc28 100644 Binary files a/Items/Materials/AuricBar_Glow.png and b/Items/Materials/AuricBar_Glow.png differ diff --git a/Items/Materials/BloodOrb.cs b/Items/Materials/BloodOrb.cs index 35716b0f34..f5cc0493f7 100644 --- a/Items/Materials/BloodOrb.cs +++ b/Items/Materials/BloodOrb.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Materials Item.height = 28; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(copper: 40); - Item.rare = ItemRarityID.Blue; + Item.rare = ItemRarityID.Green; } public override void Update(ref float gravity, ref float maxFallSpeed) @@ -30,13 +30,5 @@ namespace CalamityMod.Items.Materials brightness *= Main.essScale; Lighting.AddLight((int)((Item.position.X + (Item.width / 2)) / 16f), (int)((Item.position.Y + (Item.height / 2)) / 16f), 0.75f * brightness, 0f, 0f); } - - public override void AddRecipes() - { - CreateRecipe(10). - AddIngredient(ItemID.BloodMoonStarter). - Register() - .DisableDecraft(); - } } } diff --git a/Items/Materials/BloodSample.cs b/Items/Materials/BloodSample.cs deleted file mode 100644 index 5576926d81..0000000000 --- a/Items/Materials/BloodSample.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Materials -{ - public class BloodSample : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Materials"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 25; - ItemID.Sets.SortingPriorityMaterials[Type] = 68; // Sturdy Fossil - ItemTrader.ChlorophyteExtractinator.AddOption_OneWay(Type, 1, ModContent.ItemType(), 1); - } - - public override void SetDefaults() - { - Item.width = 26; - Item.height = 34; - Item.maxStack = Item.CommonMaxStack; - Item.value = Item.sellPrice(silver: 2); - Item.rare = ItemRarityID.Orange; - - Item.MakeUsableWithChlorophyteExtractinator(); - } - } -} diff --git a/Items/Materials/BloodSample.png b/Items/Materials/BloodSample.png deleted file mode 100644 index 421a652516..0000000000 Binary files a/Items/Materials/BloodSample.png and /dev/null differ diff --git a/Items/Materials/BloodstoneCore.cs b/Items/Materials/BloodstoneCore.cs index d15ca6a99a..2e5607f957 100644 --- a/Items/Materials/BloodstoneCore.cs +++ b/Items/Materials/BloodstoneCore.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Materials AddIngredient(5). AddIngredient(). AddIngredient(). - AddTile(TileID.AdamantiteForge). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Materials/CosmiliteBar.cs b/Items/Materials/CosmiliteBar.cs index d402b78f8e..3bc6ddbe7c 100644 --- a/Items/Materials/CosmiliteBar.cs +++ b/Items/Materials/CosmiliteBar.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -22,8 +21,8 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 3); - Item.rare = ModContent.RarityType(); + Item.value = Item.sellPrice(gold: 2); + Item.rare = ModContent.RarityType(); } public override void Update(ref float gravity, ref float maxFallSpeed) diff --git a/Items/Materials/DarksunFragment.cs b/Items/Materials/DarksunFragment.cs index 902ceb0fa1..b0b48fd1d6 100644 --- a/Items/Materials/DarksunFragment.cs +++ b/Items/Materials/DarksunFragment.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Materials Item.height = 32; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(silver: 60); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) diff --git a/Items/Materials/DubiousPlating.cs b/Items/Materials/DubiousPlating.cs index 9566a41fdf..a6ac4b4cb3 100644 --- a/Items/Materials/DubiousPlating.cs +++ b/Items/Materials/DubiousPlating.cs @@ -1,6 +1,5 @@ using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Materials diff --git a/Items/Materials/EndothermicEnergy.cs b/Items/Materials/EndothermicEnergy.cs index 27a69c8c20..955f818970 100644 --- a/Items/Materials/EndothermicEnergy.cs +++ b/Items/Materials/EndothermicEnergy.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Materials Item.height = 38; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(silver: 40); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) diff --git a/Items/Materials/ExoPrism.cs b/Items/Materials/ExoPrism.cs index 732cae5900..5b8c11ad99 100644 --- a/Items/Materials/ExoPrism.cs +++ b/Items/Materials/ExoPrism.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Materials Item.height = 52; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(gold: 7); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public void DrawBackAfterimage(SpriteBatch spriteBatch, Vector2 baseDrawPosition, Rectangle frame, float baseScale) { diff --git a/Items/Materials/GrandScale.png b/Items/Materials/GrandScale.png index 88e26c49ac..a50f8cbc7f 100644 Binary files a/Items/Materials/GrandScale.png and b/Items/Materials/GrandScale.png differ diff --git a/Items/Materials/InfectedArmorPlating.png b/Items/Materials/InfectedArmorPlating.png index edaf2ea071..c68c72f36d 100644 Binary files a/Items/Materials/InfectedArmorPlating.png and b/Items/Materials/InfectedArmorPlating.png differ diff --git a/Items/Materials/MiracleMatter.cs b/Items/Materials/MiracleMatter.cs index 18963320e2..4f7392b898 100644 --- a/Items/Materials/MiracleMatter.cs +++ b/Items/Materials/MiracleMatter.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Materials Item.height = 80; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(platinum: 1); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public void DrawBackAfterimage(SpriteBatch spriteBatch, Vector2 baseDrawPosition, Rectangle frame, Vector2 origin, float baseScale) diff --git a/Items/Materials/MysteriousCircuitry.cs b/Items/Materials/MysteriousCircuitry.cs index 3b715e6510..44a0c4adc7 100644 --- a/Items/Materials/MysteriousCircuitry.cs +++ b/Items/Materials/MysteriousCircuitry.cs @@ -1,6 +1,5 @@ using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Materials diff --git a/Items/Materials/NightmareFuel.cs b/Items/Materials/NightmareFuel.cs index 01c020e757..883a1541a4 100644 --- a/Items/Materials/NightmareFuel.cs +++ b/Items/Materials/NightmareFuel.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Materials Item.height = 36; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(silver: 40); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) diff --git a/Items/Materials/PerennialBar.cs b/Items/Materials/PerennialBar.cs index 50553376a8..03e2eacb08 100644 --- a/Items/Materials/PerennialBar.cs +++ b/Items/Materials/PerennialBar.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Tiles; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Materials/PlagueCellCanister.png b/Items/Materials/PlagueCellCanister.png index eec218c7b2..2f63b08e28 100644 Binary files a/Items/Materials/PlagueCellCanister.png and b/Items/Materials/PlagueCellCanister.png differ diff --git a/Items/Materials/PlasmaDriveCore.cs b/Items/Materials/PlasmaDriveCore.cs index 8614b23bca..33a3d367fd 100644 --- a/Items/Materials/PlasmaDriveCore.cs +++ b/Items/Materials/PlasmaDriveCore.cs @@ -5,7 +5,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Materials diff --git a/Items/Materials/ReaperTooth.cs b/Items/Materials/ReaperTooth.cs index 18da80744a..57f13b3639 100644 --- a/Items/Materials/ReaperTooth.cs +++ b/Items/Materials/ReaperTooth.cs @@ -1,6 +1,5 @@ using CalamityMod.Rarities; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Materials diff --git a/Items/Materials/RottenMatter.cs b/Items/Materials/RottenMatter.cs deleted file mode 100644 index bd79bb3508..0000000000 --- a/Items/Materials/RottenMatter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Materials -{ - [LegacyName("TrueShadowScale")] - public class RottenMatter : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Materials"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 25; - ItemID.Sets.SortingPriorityMaterials[Type] = 65; // Crimtane Ore - ItemTrader.ChlorophyteExtractinator.AddOption_OneWay(Type, 1, ModContent.ItemType(), 1); - } - - public override void SetDefaults() - { - Item.width = 28; - Item.height = 32; - Item.maxStack = Item.CommonMaxStack; - Item.value = Item.sellPrice(silver: 2); - Item.rare = ItemRarityID.Orange; - - Item.MakeUsableWithChlorophyteExtractinator(); - } - } -} diff --git a/Items/Materials/RottenMatter.png b/Items/Materials/RottenMatter.png deleted file mode 100644 index b3b9fb798f..0000000000 Binary files a/Items/Materials/RottenMatter.png and /dev/null differ diff --git a/Items/Materials/SeaRemains.cs b/Items/Materials/SeaRemains.cs index ff70b1ad9f..c042437c7f 100644 --- a/Items/Materials/SeaRemains.cs +++ b/Items/Materials/SeaRemains.cs @@ -19,16 +19,15 @@ namespace CalamityMod.Items.Materials Item.width = 30; Item.height = 24; Item.maxStack = Item.CommonMaxStack; - Item.value = Item.sellPrice(silver: 36); + Item.value = Item.sellPrice(silver: 6); Item.rare = ItemRarityID.Green; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(2). - AddIngredient(ItemID.Coral, 2). - AddIngredient(ItemID.Starfish, 2). - AddIngredient(ItemID.Seashell, 2). + AddIngredient(1). + //AddIngredient(2). + AddIngredient(3). AddTile(TileID.Furnaces). Register(); } diff --git a/Items/Materials/SuspiciousScrap.cs b/Items/Materials/SuspiciousScrap.cs index ad7cf40862..d3350c8644 100644 --- a/Items/Materials/SuspiciousScrap.cs +++ b/Items/Materials/SuspiciousScrap.cs @@ -1,5 +1,4 @@ using CalamityMod.Rarities; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -25,11 +24,16 @@ namespace CalamityMod.Items.Materials Item.value = Item.sellPrice(copper: 4); Item.rare = ModContent.RarityType(); } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { Texture2D tex = TextureAssets.Item[Type].Value; Vector2 positionDisplace = new Vector2(32, 32) * scale; - Rectangle variant = new Rectangle(CalamityWorld.OreTypes[0] == TileID.Tin ? 0 : 32, CalamityWorld.OreTypes[1] == TileID.Lead ? 0 : 32, 30, 30); + Rectangle variant = new Rectangle( + WorldGen.SavedOreTiers.Copper == TileID.Copper ? 32 : 0, + WorldGen.SavedOreTiers.Iron == TileID.Iron ? 32 : 0, + 30, 30 + ); spriteBatch.Draw(tex, position + positionDisplace, variant, drawColor, 0f, origin, scale * 2f, 0f, 0f); return false; } @@ -37,7 +41,11 @@ namespace CalamityMod.Items.Materials public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) { Texture2D tex = TextureAssets.Item[Type].Value; - Rectangle variant = new Rectangle(CalamityWorld.OreTypes[0] == TileID.Tin ? 0 : 32, CalamityWorld.OreTypes[1] == TileID.Lead ? 0 : 32, 30, 30); + Rectangle variant = new Rectangle( + WorldGen.SavedOreTiers.Copper == TileID.Copper ? 32 : 0, + WorldGen.SavedOreTiers.Iron == TileID.Iron ? 32 : 0, + 30, 30 + ); Vector2 positionDisplace = new Vector2(16, 16) * scale; spriteBatch.Draw(tex, Item.position + positionDisplace - Main.screenPosition, variant, lightColor, rotation, variant.Size() / 2f, scale, 0f, 0f); diff --git a/Items/Materials/UelibloomBar.cs b/Items/Materials/UelibloomBar.cs index 43dcea8267..222ed535dc 100644 --- a/Items/Materials/UelibloomBar.cs +++ b/Items/Materials/UelibloomBar.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Rarities; -using CalamityMod.Tiles; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Materials/WillOWisp.cs b/Items/Materials/WillOWisp.cs new file mode 100644 index 0000000000..c923fab47b --- /dev/null +++ b/Items/Materials/WillOWisp.cs @@ -0,0 +1,81 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Materials +{ + public class WillOWisp : ModItem, ILocalizedModType + { + public int textureVariant = 0; + + public static Asset altTexture = null; + public new string LocalizationCategory => "Items.Materials"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 25; + ItemID.Sets.SortingPriorityMaterials[Type] = 60; // Meteorite + } + + public override void SetDefaults() + { + Item.width = 20; + Item.height = 26; + Item.maxStack = Item.CommonMaxStack; + Item.value = Item.sellPrice(silver: 1); + Item.rare = ItemRarityID.Green; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Material; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + var tex = textureVariant == 0 ? TextureAssets.Item[Type] : CalamityUtils.GetTextureEfficient(ref altTexture, "CalamityMod/Items/Materials/WillOWisp2"); + float rotationAmount = 0.25f; + float rotationSpeedMult = 0.033f; + spriteBatch.Draw(tex.Value, Item.Center - Main.screenPosition, null, lightColor, rotation + (rotationAmount * (float)Math.Sin(Item.whoAmI + Main.timeForVisualEffects * rotationSpeedMult)), tex.Size() / 2, scale, SpriteEffects.None, 0); + return false; + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + if (textureVariant == 0) + return true; + else + { + var tex = CalamityUtils.GetTextureEfficient(ref altTexture, "CalamityMod/Items/Materials/WillOWisp2"); + spriteBatch.Draw(tex.Value, position, null, drawColor, 0, tex.Size() / 2, scale, SpriteEffects.None, 0); + return false; + } + } + public override void OnSpawn(IEntitySource source) + { + textureVariant = Main.rand.NextBool().ToInt(); + } + public override void Update(ref float gravity, ref float maxFallSpeed) + { + + if (Collision.SolidCollision(Item.position, Item.width, Item.height + CalamityUtils.TilesToPixels(3), true)) + gravity *= 0.2f; + maxFallSpeed *= 0.1f; + if (Collision.SolidCollision(Item.position, Item.width, Item.height + CalamityUtils.TilesToPixels(2), true)) + gravity *= -1; + Item.velocity.X /= 0.95f; + Item.velocity.X *= 0.975f; + if (Main.rand.NextBool(10)) + { + var d = Dust.NewDustDirect(Item.position, Item.width, Item.height, DustID.Obsidian, newColor: Color.Red, Scale: 0.9f); + d.velocity *= 1f; + d.noGravity = true; + } + } + } +} diff --git a/Items/Materials/WillOWisp.png b/Items/Materials/WillOWisp.png new file mode 100644 index 0000000000..1c20a1c44b Binary files /dev/null and b/Items/Materials/WillOWisp.png differ diff --git a/Items/Materials/WillOWisp2.png b/Items/Materials/WillOWisp2.png new file mode 100644 index 0000000000..678e703357 Binary files /dev/null and b/Items/Materials/WillOWisp2.png differ diff --git a/Items/Materials/WulfrumMetalScrap.cs b/Items/Materials/WulfrumMetalScrap.cs index b2140ca6ec..16a60a5e7d 100644 --- a/Items/Materials/WulfrumMetalScrap.cs +++ b/Items/Materials/WulfrumMetalScrap.cs @@ -1,12 +1,12 @@ -using CalamityMod.Cooldowns; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Wulfrum; +using CalamityMod.Items.Accessories; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using static CalamityMod.CalamityUtils; namespace CalamityMod.Items.Materials { @@ -15,6 +15,10 @@ namespace CalamityMod.Items.Materials { public new string LocalizationCategory => "Items.Materials"; + public int textureVariant = 0; + + public static Asset altTexture = null; + public override void SetStaticDefaults() { Item.ResearchUnlockCount = 25; @@ -35,10 +39,34 @@ namespace CalamityMod.Items.Materials itemGroup = ContentSamples.CreativeHelper.ItemGroup.Material; } + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + if (textureVariant == 0) + return true; + else + { + spriteBatch.Draw(altTexture.Value, Item.Center - Main.screenPosition, null, lightColor, rotation, altTexture.Size() / 2, scale, SpriteEffects.None, 0); + return false; + } + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + if (textureVariant == 0) + return true; + else + { + spriteBatch.Draw(altTexture.Value, position, null, drawColor, 0, altTexture.Size() / 2, scale, SpriteEffects.None, 0); + return false; + } + } + public override void OnSpawn(IEntitySource source) { if (source is EntitySource_Loot) { + textureVariant = Main.rand.NextBool().ToInt(); + if (Main.rand.NextBool()) return; @@ -67,7 +95,11 @@ namespace CalamityMod.Items.Materials } } - public override void Load() => Terraria.On_Item.CanFillEmptyAmmoSlot += AvoidDefaultingToAmmoSlot; + public override void Load() + { + Terraria.On_Item.CanFillEmptyAmmoSlot += AvoidDefaultingToAmmoSlot; + altTexture = ModContent.Request(Texture + "2"); + } private bool AvoidDefaultingToAmmoSlot(Terraria.On_Item.orig_CanFillEmptyAmmoSlot orig, Item self) { diff --git a/Items/Materials/WulfrumMetalScrap.png b/Items/Materials/WulfrumMetalScrap.png index 384f3c9372..b5718218e9 100644 Binary files a/Items/Materials/WulfrumMetalScrap.png and b/Items/Materials/WulfrumMetalScrap.png differ diff --git a/Items/Materials/WulfrumMetalScrap2.png b/Items/Materials/WulfrumMetalScrap2.png new file mode 100644 index 0000000000..91c1805f0d Binary files /dev/null and b/Items/Materials/WulfrumMetalScrap2.png differ diff --git a/Items/Materials/YharonSoulFragment.cs b/Items/Materials/YharonSoulFragment.cs index 542fe37019..f6e256e3c5 100644 --- a/Items/Materials/YharonSoulFragment.cs +++ b/Items/Materials/YharonSoulFragment.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Materials Item.height = 14; Item.maxStack = Item.CommonMaxStack; Item.value = Item.sellPrice(gold: 5); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } } } diff --git a/Items/Mounts/AlicornMount.cs b/Items/Mounts/AlicornMount.cs deleted file mode 100644 index 195d4ab52a..0000000000 --- a/Items/Mounts/AlicornMount.cs +++ /dev/null @@ -1,152 +0,0 @@ -using CalamityMod.Buffs.Mounts; -using CalamityMod.CalPlayer; -using CalamityMod.NPCs.TownNPCs; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Mounts -{ - public class AlicornMount : ModMount - { - public override void SetStaticDefaults() - { - MountData.spawnDust = 234; - MountData.spawnDustNoGravity = true; - MountData.buff = ModContent.BuffType(); - - // Horizontal movement - MountData.runSpeed = 5.6f; - MountData.dashSpeed = 17.6f; - MountData.swimSpeed = 4f; - MountData.acceleration = 0.4f; - - // Vertical movement - MountData.fallDamage = 0f; - MountData.fatigueMax = int.MaxValue; - MountData.flightTimeMax = int.MaxValue; - MountData.jumpSpeed = 9.21f; - - // Frames and offsets - MountData.totalFrames = 15; - MountData.heightBoost = 34; - int baseYOffset = 30; - int[] array = new int[MountData.totalFrames]; - for (int l = 0; l < array.Length; l++) - array[l] = baseYOffset; - - array[1] = array[3] = array[5] = array[7] = array[12] = baseYOffset - 2; - MountData.playerYOffsets = array; - MountData.playerHeadOffset = 36; - MountData.bodyFrame = 3; - MountData.xOffset = -4; - MountData.yOffset = 6; - MountData.standingFrameCount = 1; - MountData.standingFrameDelay = 12; - MountData.standingFrameStart = 0; - MountData.runningFrameCount = 8; - MountData.runningFrameDelay = 42; - MountData.runningFrameStart = 1; - MountData.flyingFrameCount = 6; - MountData.flyingFrameDelay = 4; - MountData.flyingFrameStart = 9; - MountData.inAirFrameCount = 1; - MountData.inAirFrameDelay = 12; - MountData.inAirFrameStart = 10; - MountData.idleFrameCount = 1; - MountData.idleFrameDelay = 12; - MountData.idleFrameStart = 5; - MountData.idleFrameLoop = true; - MountData.swimFrameCount = MountData.inAirFrameCount; - MountData.swimFrameDelay = MountData.inAirFrameDelay; - MountData.swimFrameStart = MountData.inAirFrameStart; - if (!Main.dedServ) - { - MountData.frontTextureExtra = ModContent.Request("CalamityMod/Items/Mounts/AlicornMountExtra"); - MountData.textureWidth = MountData.backTexture.Width(); - MountData.textureHeight = MountData.backTexture.Height(); - } - } - - public override void SetMount(Player player, ref bool skipDust) - { - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.type == ModContent.NPCType()) - { - npc.active = false; - npc.netUpdate = true; - break; - } - } - } - - public override void Dismount(Player player, ref bool skipDust) - { - bool anyPlayerOnFabMount = false; - foreach (Player player2 in Main.ActivePlayers) - { - // The player that is dismounting is technically not on the mount anymore. - if (player2.Calamity().fab && player2.whoAmI != player.whoAmI) - { - anyPlayerOnFabMount = true; - break; - } - } - - // Spawn Cirrus if no other players are on the Alicorn mount. - if (!anyPlayerOnFabMount) - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.NewNPC(NPC.GetSource_TownSpawn(), (int)player.Center.X, (int)player.Center.Y, ModContent.NPCType()); - } - } - } - - public override void UpdateEffects(Player player) - { - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.cirrusVodka) - player.GetDamage() += 0.1f; - - if (player.velocity.Length() > 9f) - { - int rand = Main.rand.Next(2); - bool momo = false; - if (rand == 1) - { - momo = true; - } - Color meme; - if (momo) - { - meme = new Color(255, 68, 242); - } - else - { - meme = new Color(25, 105, 255); - } - Rectangle rect = player.getRect(); - int dust = Dust.NewDust(new Vector2(rect.X, rect.Y), rect.Width, rect.Height, DustID.BoneTorch, 0, 0, 0, meme); - Main.dust[dust].noGravity = true; - } - - if (player.velocity.Y != 0f) - { - if (player.mount.PlayerOffset == 28) - { - if (!player.flapSound) - SoundEngine.PlaySound(SoundID.Item32, player.Center); - player.flapSound = true; - } - else - player.flapSound = false; - } - } - } -} diff --git a/Items/Mounts/AlicornMountExtra.png b/Items/Mounts/AlicornMountExtra.png deleted file mode 100644 index b544a94ba8..0000000000 Binary files a/Items/Mounts/AlicornMountExtra.png and /dev/null differ diff --git a/Items/Mounts/AlicornMount_Back.png b/Items/Mounts/AlicornMount_Back.png deleted file mode 100644 index fcb20c4308..0000000000 Binary files a/Items/Mounts/AlicornMount_Back.png and /dev/null differ diff --git a/Items/Mounts/AlicornMount_Front.png b/Items/Mounts/AlicornMount_Front.png deleted file mode 100644 index 821fd8bbfc..0000000000 Binary files a/Items/Mounts/AlicornMount_Front.png and /dev/null differ diff --git a/Items/Mounts/BUMBLEDOGE.cs b/Items/Mounts/BUMBLEDOGE.cs index 1cbc9c4b3d..44e72e781d 100644 --- a/Items/Mounts/BUMBLEDOGE.cs +++ b/Items/Mounts/BUMBLEDOGE.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Mounts diff --git a/Items/Mounts/Brimrose.cs b/Items/Mounts/Brimrose.cs index f23f2c5298..0368904f0e 100644 --- a/Items/Mounts/Brimrose.cs +++ b/Items/Mounts/Brimrose.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Mounts Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item3; Item.noMelee = true; - Item.mountType = ModContent.MountType(); + Item.mountType = ModContent.MountType(); Item.value = Item.sellPrice(gold: 5); Item.rare = ItemRarityID.Yellow; @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Mounts CreateRecipe(). AddIngredient(5). AddIngredient(20). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Mounts/BrimroseChair.cs b/Items/Mounts/BrimroseChair.cs new file mode 100644 index 0000000000..c0db6da4be --- /dev/null +++ b/Items/Mounts/BrimroseChair.cs @@ -0,0 +1,67 @@ +using CalamityMod.Buffs.Mounts; +using CalamityMod.Dusts; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Mounts +{ + public class BrimroseChair : ModMount + { + public override void SetStaticDefaults() + { + MountData.spawnDust = (int)CalamityDusts.Brimstone; + MountData.spawnDustNoGravity = true; + MountData.buff = ModContent.BuffType(); + + // Horizontal movement + MountData.runSpeed = 12f; + MountData.dashSpeed = 12f; + MountData.acceleration = 0.2f; + + // Vertical movement + MountData.fallDamage = 0f; + MountData.fatigueMax = int.MaxValue; + MountData.flightTimeMax = int.MaxValue; + MountData.jumpSpeed = 4f; + MountData.blockExtraJumps = true; + MountData.usesHover = true; + + // Frames and offsets + MountData.totalFrames = 4; + MountData.heightBoost = 0; + int[] array = new int[MountData.totalFrames]; + for (int l = 0; l < array.Length; l++) + array[l] = 0; + + MountData.playerYOffsets = array; + MountData.playerHeadOffset = 18; + MountData.bodyFrame = 3; + MountData.xOffset = 0; + MountData.yOffset = 6; + MountData.standingFrameCount = 4; + MountData.standingFrameDelay = 4; + MountData.standingFrameStart = 0; + MountData.runningFrameCount = 4; + MountData.runningFrameDelay = 16; + MountData.runningFrameStart = 0; + MountData.flyingFrameCount = 4; + MountData.flyingFrameDelay = 4; + MountData.flyingFrameStart = 0; + MountData.inAirFrameCount = 4; + MountData.inAirFrameDelay = 4; + MountData.inAirFrameStart = 0; + MountData.idleFrameCount = 4; + MountData.idleFrameDelay = 8; + MountData.idleFrameStart = 0; + MountData.idleFrameLoop = true; + MountData.swimFrameCount = 4; + MountData.swimFrameDelay = 4; + MountData.swimFrameStart = 0; + if (!Main.dedServ) + { + MountData.textureWidth = MountData.backTexture.Width(); + MountData.textureHeight = MountData.backTexture.Height(); + } + } + } +} diff --git a/Items/Mounts/PhuppersChair_Back.png b/Items/Mounts/BrimroseChair_Back.png similarity index 100% rename from Items/Mounts/PhuppersChair_Back.png rename to Items/Mounts/BrimroseChair_Back.png diff --git a/Items/Mounts/PhuppersChair_Front.png b/Items/Mounts/BrimroseChair_Front.png similarity index 100% rename from Items/Mounts/PhuppersChair_Front.png rename to Items/Mounts/BrimroseChair_Front.png diff --git a/Items/Mounts/DraedonGamerChairMount.cs b/Items/Mounts/DraedonGamerChairMount.cs index adc03e7738..5f962ff74d 100644 --- a/Items/Mounts/DraedonGamerChairMount.cs +++ b/Items/Mounts/DraedonGamerChairMount.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Mounts diff --git a/Items/Mounts/Minecarts/DoGCartMount.cs b/Items/Mounts/Minecarts/DoGCartMount.cs index 3132669334..14f523d967 100644 --- a/Items/Mounts/Minecarts/DoGCartMount.cs +++ b/Items/Mounts/Minecarts/DoGCartMount.cs @@ -28,10 +28,11 @@ namespace CalamityMod.Items.Mounts.Minecarts MountData.idleFrameDelay = 10; MountData.idleFrameStart = 0; - // These are more powerful than the Cart Upgrade Kit (20f and 0.1f respectively) and using it will reduce the cart speed to that - // We can IL edit this now but we can also wait for TML to add support for the kit (copefully soon) - MountData.runSpeed = 22f; - MountData.acceleration = 0.16f; + // Stat balancing + MountData.runSpeed = 20.0f; + MountData.acceleration = 0.1f; + MountData.MinecartUpgradeRunSpeed = 22.0f; + MountData.MinecartUpgradeAcceleration = 0.16f; if (!Main.dedServ) { @@ -46,7 +47,7 @@ namespace CalamityMod.Items.Mounts.Minecarts offsetDirection *= new Vector2(Main.rand.NextBool().ToDirectionInt(), 1f) * 13f; dustPosition += offsetDirection; - Dust spark = Dust.NewDustPerfect(dustPosition, 234); + Dust spark = Dust.NewDustPerfect(dustPosition, DustID.BoneTorch); spark.velocity = Main.rand.NextVector2Circular(4f, 4f); spark.velocity.X *= Main.rand.NextFloat(0.25f, 1f); spark.velocity.Y -= Main.rand.NextFloat(1.25f, 3f); diff --git a/Items/Mounts/Minecarts/TheCartofGods.cs b/Items/Mounts/Minecarts/TheCartofGods.cs index ae22235184..28178c0b3f 100644 --- a/Items/Mounts/Minecarts/TheCartofGods.cs +++ b/Items/Mounts/Minecarts/TheCartofGods.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Mounts.Minecarts Item.mountType = ModContent.MountType(); Item.value = Item.sellPrice(gold: 30); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Mounts/OnyxExcavator.cs b/Items/Mounts/OnyxExcavator.cs index 402c49a00d..4f052d08e9 100644 --- a/Items/Mounts/OnyxExcavator.cs +++ b/Items/Mounts/OnyxExcavator.cs @@ -1,34 +1,53 @@ using System; using System.Collections.Generic; using CalamityMod.Buffs.Mounts; -using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -//using Terraria.GameContent.Achievements; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Mounts { + // TODO: + // - don't render the player's arm + // - don't allow items to be used at all (like vanilla DCU) + // - drill animation speed is independent of mount movement speed and always maxed when picking at least one tile + // - separate animation for the drill coming out of the bottom when it digs down public class OnyxExcavator : ModMount { + public static List OnyxExcavatorImmuneTiles = null; + public override void SetStaticDefaults() { - MountData.spawnDust = 109; + // 05JAN2026: Ozzatron: Onyx Excavator blacklist is now public and modifiable in a semi-sane way. + // Also removed the Abyss tiles from the blacklist because now that the drill respects tile durability, it's fine. + OnyxExcavatorImmuneTiles = + [ + // ModContent.TileType(), + // ModContent.TileType(), + // ModContent.TileType(), + // ModContent.TileType(), + TileID.DemonAltar, + TileID.ElderCrystalStand, + ]; + + // Dust that spawns upon mounting or unmounting + MountData.spawnDust = DustID.Orichalcum; MountData.spawnDustNoGravity = true; MountData.buff = ModContent.BuffType(); // Horizontal movement - MountData.runSpeed = 5.5f; + MountData.runSpeed = 4.5f; MountData.swimSpeed = 0.5f; - MountData.acceleration = 0.2f; + MountData.acceleration = 0.1f; // Vertical movement - MountData.fallDamage = 0f; + // 22JAN2026: Ozzatron: Onyx Excavator Drill does not make you immune to fall damage and blocks double jumps MountData.jumpHeight = 5; MountData.jumpSpeed = 3f; + MountData.blockExtraJumps = true; // Frames and offsets MountData.totalFrames = 6; @@ -37,18 +56,19 @@ namespace CalamityMod.Items.Mounts for (int l = 0; l < array.Length; l++) array[l] = 6; - array[1] = 4; - array[5] = 4; + // 22JAN2026: Ozzatron: removed copy pasted code that made the player's head bob like Unicorn MountData.playerYOffsets = array; MountData.playerHeadOffset = 10; MountData.bodyFrame = 3; MountData.xOffset = 10; MountData.yOffset = -1; //done + MountData.standingFrameCount = 1; MountData.standingFrameDelay = 12; MountData.standingFrameStart = 0; MountData.runningFrameCount = 6; - MountData.runningFrameDelay = 36; //36 + // 22JAN2026: Ozzatron: vastly increased animation speed so the drill and wheels spin at appropriate speeds + MountData.runningFrameDelay = 12; //36 MountData.runningFrameStart = MountData.standingFrameStart; MountData.inAirFrameCount = MountData.standingFrameCount; MountData.inAirFrameDelay = MountData.standingFrameDelay; @@ -60,31 +80,40 @@ namespace CalamityMod.Items.Mounts MountData.swimFrameCount = MountData.inAirFrameCount; MountData.swimFrameDelay = MountData.inAirFrameDelay; MountData.swimFrameStart = MountData.inAirFrameStart; + if (!Main.dedServ) { - MountData.backTextureExtra = ModContent.Request("CalamityMod/Items/Mounts/OnyxExcavatorExtra"); - MountData.frontTextureExtra = ModContent.Request("CalamityMod/Items/Mounts/OnyxExcavatorExtra2"); + // 22JAN2026: Ozzatron: Drill itself was rendering behind the mount instead of in front of it + MountData.frontTexture = ModContent.Request("CalamityMod/Items/Mounts/OnyxExcavatorExtra2"); + MountData.frontTextureExtra = ModContent.Request("CalamityMod/Items/Mounts/OnyxExcavatorExtra"); MountData.textureWidth = MountData.backTexture.Width(); MountData.textureHeight = MountData.backTexture.Height(); } } + public override void Unload() => OnyxExcavatorImmuneTiles = null; + public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity) { bool speed = Math.Abs(velocity.X) > mountedPlayer.mount.RunSpeed / 2f; float direction = Math.Sign(mountedPlayer.velocity.X); + Lighting.AddLight(mountedPlayer.Center, 0.5f, 0.5f, 0.4f); + if (speed && velocity.Y == 0f) { - for (int i = 0; i < 2; i++) + // 22JAN2026: Ozzatron: significantly improved dust to be far less obnoxious when traveling at speed + // looks more like it's shaking off rust as it drives around + if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustDirect(mountedPlayer.BottomLeft, mountedPlayer.width, 6, DustID.Ghost, 0f, 0f, 0, default, 1f); + Dust dust = Dust.NewDustDirect(mountedPlayer.BottomLeft, mountedPlayer.width, 6, DustID.RedMoss, 0f, 0f, 0, default, 1f); dust.velocity = new Vector2(velocity.X * 0.15f, Main.rand.NextFloat() * -2f); dust.noLight = true; dust.scale = 0.2f + Main.rand.NextFloat() * 0.8f; dust.fadeIn = 0.5f + Main.rand.NextFloat() * 1f; dust.shader = GameShaders.Armor.GetSecondaryShader(mountedPlayer.cMount, mountedPlayer); } + if (mountedPlayer.cMount == 0) { mountedPlayer.position += new Vector2(direction * 24f, 0f); @@ -95,83 +124,136 @@ namespace CalamityMod.Items.Mounts return true; } + /// + /// Attempts to wield the Onyx Excavator to drill the tile at the given position. + /// + /// The player using the Onyx Excavator. + /// The position of the target tile. + /// The power of the player's best pickaxe. + /// Whether the Onyx Excavator successfully mined this tile. + private static bool OnyxExcavateTile(Player player, Point targetPos, int pickPower) + { + int x = targetPos.X; + int y = targetPos.Y; + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + + // Startup exclusion checks. + if (!tile.HasTile || player.noBuilding || Main.tileContainer[tile.TileType]) + return false; + if (OnyxExcavatorImmuneTiles.Contains(tile.TileType)) + return false; + + // This function contains all CanKillTile checks and manipulates AchievementsHelper.CurrentlyMining for us. + // It also sends appropriate packets in multiplayer. + player.PickTile(x, y, pickPower); + return true; + } + public override void UseAbility(Player player, Vector2 mousePosition, bool toggleOn) { - if (Main.mouseLeft && !player.mouseInterface && !Main.blockMouse) + // Only evaluate drilling on the drill-owning client + if (Main.myPlayer != player.whoAmI) + return; + + // Any drilling requires holding LMB. + bool holdingMouse = Main.mouseLeft && !player.mouseInterface && !Main.blockMouse; + if (!holdingMouse) + return; + + // Drilling horizontally takes precedence, but if no controls are input, the player will not dig. + bool canDrillHorizontally = player.controlLeft || player.controlRight; + bool canDrillDown = player.controlDown; + if (!canDrillHorizontally && !canDrillDown) + return; + + // Onyx Excavator Drill assumes you have an unreforged Copper Pickaxe if you have no pickaxes. + Item bestPick = player.GetBestPick() ?? ContentSamples.ItemsByType[ItemID.CopperPickaxe]; + int pickPower = bestPick.pick; + int digCadence = bestPick.useTime; + + // If the cadence does not match the use time of the pickaxe that is being mimicked, do nothing. + var cgp = player.Calamity(); + if (cgp.universalFrameTimer % (ulong)digCadence != 0) + return; + + Point[] drillTargets = null; + + // Drilling horizontally takes precedence. + // If you want to drill straight down, you need to hold down without left or right. + if (canDrillHorizontally) { - if (Main.myPlayer == player.whoAmI) - { - int highestPickPower = player.GetBestPickPower(); + // Determine mining direction based on the player's facing. + // At extremely low velocities, the drill intentionally drills at closer positions. + // This is so if you're parked against a wall it doesn't drill through the first layer from a standstill. + float xVel = player.velocity.X; + float absVel = Math.Abs(xVel); + int direction = absVel < 0.1f ? player.direction : Math.Sign(xVel); + int xTileOffset = absVel > 0.5f ? 2 : 1; - float direction = Math.Sign(player.velocity.X); - if (Math.Abs(direction) < 0.1f) - direction = player.direction == 1 ? 0.1f : -0.1f; - float yOffset = 12f; - float xOffset = 40f; - Vector2 source = player.Center + new Vector2(direction * xOffset, yOffset); - int mineHeight = 3; - int xRight = (int)(source.X / 16 - mineHeight); - int xLeft = (int)(source.X / 16 + mineHeight); - int yTop = (int)(source.Y / 16 - mineHeight); - int yBottom = (int)(source.Y / 16 + mineHeight); - if (xRight < 0) - { - xRight = 0; - } - if (xLeft > Main.maxTilesX) - { - xLeft = Main.maxTilesX; - } - if (yTop < 0) - { - yTop = 0; - } - if (yBottom > Main.maxTilesY) - { - yBottom = Main.maxTilesY; - } - //AchievementsHelper.CurrentlyMining = true; - for (int x = xRight; x <= xLeft; x++) - { - for (int y = yTop; y <= yBottom; y++) - { - source.Y -= 2f; - Vector2 tileVec = new Vector2(Math.Abs(x - source.X / 16f), Math.Abs(y - source.Y / 16f)); - float tileDist = tileVec.Length(); - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + // These are offset so they're always correct when getting floored by integer division + int playerLeadingEdgeX = direction == -1 ? player.Hitbox.Left + 2 : player.Hitbox.Right - 2; + int bottomTileCenterY = player.Hitbox.Bottom - 8; + int drillLeadingEdgeX = playerLeadingEdgeX + direction * 16 * xTileOffset; - int pickReq = tile.GetRequiredPickPower(x, y); + // Forms the following pattern: + // |X + // |XX + // |XX + // |X + Vector2 drillOrigin = new(drillLeadingEdgeX, bottomTileCenterY); + Vector2 drillOneUp = drillOrigin + new Vector2(0f, -16f); + Vector2 drillTwoUp = drillOrigin + new Vector2(0f, -32f); + Vector2 drillThreeUp = drillOrigin + new Vector2(0f, -48f); + Vector2 drillFrontLower = drillOrigin + new Vector2(16f * direction, -16f); + Vector2 drillFrontUpper = drillOrigin + new Vector2(16f * direction, -32f); - if (tileDist < mineHeight) - { - bool t = 1 == 1; - bool f = 1 == 2; - bool canBreakTileCheck = TileLoader.CanKillTile(x, y, tile.TileType, ref t) && TileLoader.CanKillTile(x, y, tile.TileType, ref f); - List tileExcludeList = new List() - { - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - TileID.DemonAltar, - TileID.ElderCrystalStand - }; - - if (tile.HasTile && !player.noBuilding && !Main.tileContainer[tile.TileType] && - tileExcludeList.TrueForAll(z => tile.TileType != z) && pickReq <= highestPickPower && canBreakTileCheck) - { - WorldGen.KillTile(x, y, false, false, false); - if (!Main.tile[x, y].HasTile && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y, 0f, 0, 0, 0); - } - } - } - } - } - //AchievementsHelper.CurrentlyMining = false; - } + drillTargets = + [ + drillOrigin.ToSafeTileCoordinates(), + drillOneUp.ToSafeTileCoordinates(), + drillTwoUp.ToSafeTileCoordinates(), + drillThreeUp.ToSafeTileCoordinates(), + drillFrontLower.ToSafeTileCoordinates(), + drillFrontUpper.ToSafeTileCoordinates(), + ]; } + + else if(canDrillDown) + { + // Nothing needs to be considered. Simply dig straight down. Players are 2 tiles wide so this will always work. + int playerLeftEdgeX = player.Hitbox.Left + 2; + int playerRightEdgeX = player.Hitbox.Right - 2; + int drillLeadingEdgeY = player.Hitbox.Bottom + 8; + + // Two horizontal lines of four tiles each, covering the bottom part of the mount and the floor beneath it. + Vector2 drillLeftNear = new(playerLeftEdgeX, drillLeadingEdgeY); + Vector2 drillRightNear = new(playerRightEdgeX, drillLeadingEdgeY); + Vector2 drillLeftFar = drillLeftNear + new Vector2(-16f, 0f); + Vector2 drillRightFar = drillRightNear + new Vector2(16f, 0f); + Vector2 mountLeftNear = drillLeftNear + new Vector2(0f, -16f); + Vector2 mountRightNear = drillRightNear + new Vector2(0f, -16f); + Vector2 mountLeftFar = drillLeftFar + new Vector2(0f, -16f); + Vector2 mountRightFar = drillRightFar + new Vector2(0f, -16f); + + drillTargets = + [ + mountLeftNear.ToSafeTileCoordinates(), + mountRightNear.ToSafeTileCoordinates(), + mountLeftFar.ToSafeTileCoordinates(), + mountRightFar.ToSafeTileCoordinates(), + drillLeftNear.ToSafeTileCoordinates(), + drillRightNear.ToSafeTileCoordinates(), + drillLeftFar.ToSafeTileCoordinates(), + drillRightFar.ToSafeTileCoordinates(), + ]; + } + + if (drillTargets is null) + return; + + // Execute drilling on all intended target tiles. + foreach (Point p in drillTargets) + OnyxExcavateTile(player, p, pickPower); } } } diff --git a/Items/Mounts/PhuppersChair.cs b/Items/Mounts/PhuppersChair.cs deleted file mode 100644 index ba514b1f01..0000000000 --- a/Items/Mounts/PhuppersChair.cs +++ /dev/null @@ -1,68 +0,0 @@ -using CalamityMod.Buffs.Mounts; -using CalamityMod.Dusts; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Mounts -{ - public class PhuppersChair : ModMount - { - public override void SetStaticDefaults() - { - MountData.spawnDust = (int)CalamityDusts.Brimstone; - MountData.spawnDustNoGravity = true; - MountData.buff = ModContent.BuffType(); - - // Horizontal movement - MountData.runSpeed = 12f; - MountData.dashSpeed = 12f; - MountData.acceleration = 0.2f; - - // Vertical movement - MountData.fallDamage = 0f; - MountData.fatigueMax = int.MaxValue; - MountData.flightTimeMax = int.MaxValue; - MountData.jumpSpeed = 4f; - MountData.blockExtraJumps = true; - MountData.usesHover = true; - - // Frames and offsets - MountData.totalFrames = 4; - MountData.heightBoost = 0; - int[] array = new int[MountData.totalFrames]; - for (int l = 0; l < array.Length; l++) - array[l] = 0; - - MountData.playerYOffsets = array; - MountData.playerHeadOffset = 18; - MountData.bodyFrame = 3; - MountData.xOffset = 0; - MountData.yOffset = 6; - MountData.standingFrameCount = 4; - MountData.standingFrameDelay = 4; - MountData.standingFrameStart = 0; - MountData.runningFrameCount = 4; - MountData.runningFrameDelay = 16; - MountData.runningFrameStart = 0; - MountData.flyingFrameCount = 4; - MountData.flyingFrameDelay = 4; - MountData.flyingFrameStart = 0; - MountData.inAirFrameCount = 4; - MountData.inAirFrameDelay = 4; - MountData.inAirFrameStart = 0; - MountData.idleFrameCount = 4; - MountData.idleFrameDelay = 8; - MountData.idleFrameStart = 0; - MountData.idleFrameLoop = true; - MountData.swimFrameCount = 4; - MountData.swimFrameDelay = 4; - MountData.swimFrameStart = 0; - if (!Main.dedServ) - { - MountData.textureWidth = MountData.backTexture.Width(); - MountData.textureHeight = MountData.backTexture.Height(); - } - } - } -} diff --git a/Items/Mounts/PrincessSpiritinaBottle.cs b/Items/Mounts/PrincessSpiritinaBottle.cs deleted file mode 100644 index 26dec65edd..0000000000 --- a/Items/Mounts/PrincessSpiritinaBottle.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Mounts -{ - [LegacyName("Fabsol")] - public class PrincessSpiritinaBottle : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Mounts"; - public override void SetDefaults() - { - Item.width = 16; - Item.height = 16; - Item.useAnimation = Item.useTime = 20; - Item.useStyle = ItemUseStyleID.Swing; - Item.UseSound = SoundID.Item3; - Item.noMelee = true; - Item.mountType = ModContent.MountType(); - - Item.value = Item.sellPrice(gold: 5); - Item.rare = ItemRarityID.Yellow; - Item.Calamity().devItem = true; - } - } -} diff --git a/Items/Mounts/PrincessSpiritinaBottle.png b/Items/Mounts/PrincessSpiritinaBottle.png deleted file mode 100644 index 485a6245d0..0000000000 Binary files a/Items/Mounts/PrincessSpiritinaBottle.png and /dev/null differ diff --git a/Items/Mounts/SquishyBean.cs b/Items/Mounts/SquishyBean.cs index f7b1b676ee..7a9aa3470f 100644 --- a/Items/Mounts/SquishyBean.cs +++ b/Items/Mounts/SquishyBean.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.Mounts; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Mounts @@ -85,7 +84,6 @@ namespace CalamityMod.Items.Mounts player.gravity = 1f; player.maxFallSpeed = 20f; } - player.noFallDmg = true; } } } diff --git a/Items/PermanentBoosters/CelestialOnion.cs b/Items/PermanentBoosters/CelestialOnion.cs index 255737a155..ac90fc609c 100644 --- a/Items/PermanentBoosters/CelestialOnion.cs +++ b/Items/PermanentBoosters/CelestialOnion.cs @@ -1,7 +1,9 @@ -using CalamityMod.CalPlayer; -using CalamityMod.World; +using System.Collections.Generic; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.PermanentBoosters @@ -23,7 +25,26 @@ namespace CalamityMod.Items.PermanentBoosters Item.rare = ItemRarityID.Red; } - public override bool CanUseItem(Player player) => !(Main.masterMode && player.extraAccessory) && !player.Calamity().extraAccessoryML; + public static bool HasConsumedBefore(Player player) + { + return (Main.masterMode && player.extraAccessory) || player.Calamity().extraAccessoryML; + } + + public override bool CanUseItem(Player player) + { + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.CelestialOnionText"; + Color messageColor = Color.LightSlateGray; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -45,20 +66,11 @@ namespace CalamityMod.Items.PermanentBoosters } return true; } - } - public class CelestialOnionAccessorySlot : ModAccessorySlot - { - // Celestial Onion does not work in Master Mode. - public override bool IsEnabled() + public override void ModifyTooltips(List list) { - // GetModPlayer will throw an index error in this step of the loading process for whatever reason - // We prematurely stop it from getting to that point - if (!Player.active || Main.masterMode) - return false; - - return Player.Calamity().extraAccessoryML; + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } - public override bool IsHidden() => IsEmpty && !IsEnabled(); } } diff --git a/Items/PermanentBoosters/CometShard.cs b/Items/PermanentBoosters/CometShard.cs index c0f69da352..3511bc45e1 100644 --- a/Items/PermanentBoosters/CometShard.cs +++ b/Items/PermanentBoosters/CometShard.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; @@ -35,7 +34,28 @@ namespace CalamityMod.Items.PermanentBoosters Item.rare = ItemRarityID.LightRed; } - public override bool CanUseItem(Player player) => player.ConsumedManaCrystals == Player.ManaCrystalMax; + public static bool HasConsumedBefore(Player player) => player.Calamity().cShard; + + public override bool CanUseItem(Player player) + { + if (player.ConsumedManaCrystals != Player.ManaCrystalMax) + { + return false; + } + + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.CometShardText"; + Color messageColor = Color.SkyBlue; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -46,9 +66,6 @@ namespace CalamityMod.Items.PermanentBoosters player.itemTime = Item.useTime; if (modPlayer.cShard) { - string key = "Mods.CalamityMod.Misc.CometShardText"; - Color messageColor = Color.SkyBlue; - CalamityUtils.DisplayLocalizedText(key, messageColor); return null; } @@ -60,10 +77,8 @@ namespace CalamityMod.Items.PermanentBoosters public override void ModifyTooltips(List list) { - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); - - if (line != null && Main.LocalPlayer.Calamity().cShard) - line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText"); + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } public override void AddRecipes() diff --git a/Items/PermanentBoosters/Ectoheart.cs b/Items/PermanentBoosters/Ectoheart.cs index 805e79a9d5..ef5a4eb0c1 100644 --- a/Items/PermanentBoosters/Ectoheart.cs +++ b/Items/PermanentBoosters/Ectoheart.cs @@ -1,4 +1,5 @@ -using CalamityMod.Balancing; +using System.Collections.Generic; +using CalamityMod.Balancing; using CalamityMod.CalPlayer; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -30,7 +31,18 @@ namespace CalamityMod.Items.PermanentBoosters Item.SetRevExclusive(); } - public override bool CanUseItem(Player player) => !player.Calamity().adrenalineBoostThree; + public static bool HasConsumedBefore(Player player) => player.Calamity().adrenalineBoostThree; + + public override bool CanUseItem(Player player) + { + if (HasConsumedBefore(player)) + { + // Refuse Text can be added on here + return false; + } + + return true; + } public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { @@ -62,5 +74,11 @@ namespace CalamityMod.Items.PermanentBoosters } return true; } + + public override void ModifyTooltips(List list) + { + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip("Tooltip0"); + } } } diff --git a/Items/PermanentBoosters/ElectrolyteGelPack.cs b/Items/PermanentBoosters/ElectrolyteGelPack.cs index 6cb0062b24..33f3420af2 100644 --- a/Items/PermanentBoosters/ElectrolyteGelPack.cs +++ b/Items/PermanentBoosters/ElectrolyteGelPack.cs @@ -1,4 +1,5 @@ -using CalamityMod.Balancing; +using System.Collections.Generic; +using CalamityMod.Balancing; using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; @@ -25,7 +26,18 @@ namespace CalamityMod.Items.PermanentBoosters Item.SetRevExclusive(); } - public override bool CanUseItem(Player player) => !player.Calamity().adrenalineBoostOne; + public static bool HasConsumedBefore(Player player) => player.Calamity().adrenalineBoostOne; + + public override bool CanUseItem(Player player) + { + if (HasConsumedBefore(player)) + { + // Refuse Text can be added on here + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -37,5 +49,11 @@ namespace CalamityMod.Items.PermanentBoosters } return true; } + + public override void ModifyTooltips(List list) + { + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip("Tooltip0"); + } } } diff --git a/Items/PermanentBoosters/EtherealCore.cs b/Items/PermanentBoosters/EtherealCore.cs index 42da23b4b1..4f5d4438ce 100644 --- a/Items/PermanentBoosters/EtherealCore.cs +++ b/Items/PermanentBoosters/EtherealCore.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; @@ -35,7 +34,28 @@ namespace CalamityMod.Items.PermanentBoosters Item.rare = ItemRarityID.Red; } - public override bool CanUseItem(Player player) => player.ConsumedManaCrystals == Player.ManaCrystalMax; + public static bool HasConsumedBefore(Player player) => player.Calamity().eCore; + + public override bool CanUseItem(Player player) + { + if (player.ConsumedManaCrystals != Player.ManaCrystalMax) + { + return false; + } + + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.EtherealCoreText"; + Color messageColor = Color.MediumVioletRed; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -46,9 +66,6 @@ namespace CalamityMod.Items.PermanentBoosters player.itemTime = Item.useTime; if (modPlayer.eCore) { - string key = "Mods.CalamityMod.Misc.EtherealCoreText"; - Color messageColor = Color.MediumVioletRed; - CalamityUtils.DisplayLocalizedText(key, messageColor); return null; } @@ -60,10 +77,8 @@ namespace CalamityMod.Items.PermanentBoosters public override void ModifyTooltips(List list) { - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); - - if (line != null && Main.LocalPlayer.Calamity().eCore) - line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText"); + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } public override void AddRecipes() diff --git a/Items/PermanentBoosters/InfernalBlood.cs b/Items/PermanentBoosters/InfernalBlood.cs index 0cc4bad22c..da468f6379 100644 --- a/Items/PermanentBoosters/InfernalBlood.cs +++ b/Items/PermanentBoosters/InfernalBlood.cs @@ -1,4 +1,5 @@ -using CalamityMod.Balancing; +using System.Collections.Generic; +using CalamityMod.Balancing; using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; @@ -25,7 +26,18 @@ namespace CalamityMod.Items.PermanentBoosters Item.SetRevExclusive(); } - public override bool CanUseItem(Player player) => !player.Calamity().rageBoostTwo; + public static bool HasConsumedBefore(Player player) => player.Calamity().rageBoostTwo; + + public override bool CanUseItem(Player player) + { + if (HasConsumedBefore(player)) + { + // Refuse Text can be added on here + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -37,5 +49,11 @@ namespace CalamityMod.Items.PermanentBoosters } return true; } + + public override void ModifyTooltips(List list) + { + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip("Tooltip0"); + } } } diff --git a/Items/PermanentBoosters/MiracleFruit.cs b/Items/PermanentBoosters/MiracleFruit.cs index 974b0cbc05..bd12178cf9 100644 --- a/Items/PermanentBoosters/MiracleFruit.cs +++ b/Items/PermanentBoosters/MiracleFruit.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; @@ -37,7 +36,28 @@ namespace CalamityMod.Items.PermanentBoosters Item.rare = ItemRarityID.Yellow; } - public override bool CanUseItem(Player player) => player.ConsumedLifeFruit == Player.LifeFruitMax; + public static bool HasConsumedBefore(Player player) => player.Calamity().mFruit; + + public override bool CanUseItem(Player player) + { + if (player.ConsumedLifeFruit != Player.LifeFruitMax) + { + return false; + } + + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.MiracleFruitText"; + Color messageColor = Color.DeepSkyBlue; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -47,9 +67,6 @@ namespace CalamityMod.Items.PermanentBoosters player.itemTime = Item.useTime; if (modPlayer.mFruit) { - string key = "Mods.CalamityMod.Misc.MiracleFruitText"; - Color messageColor = Color.DeepSkyBlue; - CalamityUtils.DisplayLocalizedText(key, messageColor); return null; } @@ -61,16 +78,14 @@ namespace CalamityMod.Items.PermanentBoosters public override void ModifyTooltips(List list) { - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); - - if (line != null && Main.LocalPlayer.Calamity().mFruit) - line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText"); + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.LifeFruit, 5). + AddIngredient(ItemID.LifeFruit). AddIngredient(5). AddIngredient(12). AddTile(TileID.MythrilAnvil). diff --git a/Items/PermanentBoosters/MushroomPlasmaRoot.cs b/Items/PermanentBoosters/MushroomPlasmaRoot.cs index 543543f06e..9ce3c1812b 100644 --- a/Items/PermanentBoosters/MushroomPlasmaRoot.cs +++ b/Items/PermanentBoosters/MushroomPlasmaRoot.cs @@ -1,4 +1,5 @@ -using CalamityMod.Balancing; +using System.Collections.Generic; +using CalamityMod.Balancing; using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; @@ -25,7 +26,18 @@ namespace CalamityMod.Items.PermanentBoosters Item.SetRevExclusive(); } - public override bool CanUseItem(Player player) => !player.Calamity().rageBoostOne; + public static bool HasConsumedBefore(Player player) => player.Calamity().rageBoostOne; + + public override bool CanUseItem(Player player) + { + if (HasConsumedBefore(player)) + { + // Refuse Text can be added on here + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -37,5 +49,11 @@ namespace CalamityMod.Items.PermanentBoosters } return true; } + + public override void ModifyTooltips(List list) + { + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip("Tooltip0"); + } } } diff --git a/Items/PermanentBoosters/NimbleBounder.cs b/Items/PermanentBoosters/NimbleBounder.cs deleted file mode 100644 index e4919d1dfb..0000000000 --- a/Items/PermanentBoosters/NimbleBounder.cs +++ /dev/null @@ -1,53 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Rarities; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Items.PermanentBoosters -{ - public class NimbleBounder : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Misc"; - - public static float MoveSpeedBoost = 0.05f; - public static float JumpSpeedBoost = 0.25f; // This also amounts to 5% so the tooltip is shared with movement speed - public static float AccelerationBoost = 0.1f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent(), AccelerationBoost.ToPercent()); - - public override void SetDefaults() - { - Item.width = 20; - Item.height = 20; - Item.consumable = true; - Item.useAnimation = Item.useTime = 30; - Item.UseSound = SoundID.Zombie13; // frog sfx - Item.useStyle = ItemUseStyleID.HoldUp; - // Same price as Frog Leg, which is used to shimmer into it - Item.value = Item.sellPrice(gold: 1); - Item.rare = ModContent.RarityType(); - Item.stack = Item.CommonMaxStack; - Item.Calamity().devItem = true; - } - - public override bool CanUseItem(Player player) => !player.Calamity().nimbleBounderBoost; - - public override bool? UseItem(Player player) - { - if (player.itemAnimation > 0 && player.itemTime == 0) - { - player.itemTime = Item.useTime; - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.nimbleBounderBoost = true; - } - return true; - } - - // Gives a purple light when dropped as an item - public override void PostUpdate() - { - Lighting.AddLight((int)((Item.position.X + Item.width / 2) / 16f), (int)((Item.position.Y + Item.height / 2) / 16f), 0.51f, 0.14f, 0.57f); - } - } -} diff --git a/Items/PermanentBoosters/NimbleBounder.png b/Items/PermanentBoosters/NimbleBounder.png deleted file mode 100644 index a329a79c57..0000000000 Binary files a/Items/PermanentBoosters/NimbleBounder.png and /dev/null differ diff --git a/Items/PermanentBoosters/PhantomHeart.cs b/Items/PermanentBoosters/PhantomHeart.cs index 2ec582f5fd..bfa46677c1 100644 --- a/Items/PermanentBoosters/PhantomHeart.cs +++ b/Items/PermanentBoosters/PhantomHeart.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; @@ -36,7 +35,28 @@ namespace CalamityMod.Items.PermanentBoosters Item.rare = ModContent.RarityType(); } - public override bool CanUseItem(Player player) => player.ConsumedManaCrystals == Player.ManaCrystalMax; + public static bool HasConsumedBefore(Player player) => player.Calamity().pHeart; + + public override bool CanUseItem(Player player) + { + if (player.ConsumedManaCrystals != Player.ManaCrystalMax) + { + return false; + } + + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.PhantomHeartText"; + Color messageColor = Color.Pink; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -47,9 +67,6 @@ namespace CalamityMod.Items.PermanentBoosters player.itemTime = Item.useTime; if (modPlayer.pHeart) { - string key = "Mods.CalamityMod.Misc.PhantomHeartText"; - Color messageColor = Color.Pink; - CalamityUtils.DisplayLocalizedText(key, messageColor); return null; } @@ -61,10 +78,8 @@ namespace CalamityMod.Items.PermanentBoosters public override void ModifyTooltips(List list) { - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); - - if (line != null && Main.LocalPlayer.Calamity().pHeart) - line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText"); + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } public override void AddRecipes() @@ -72,7 +87,7 @@ namespace CalamityMod.Items.PermanentBoosters CreateRecipe(). AddIngredient(5). AddIngredient(25). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/PermanentBoosters/RedLightningContainer.cs b/Items/PermanentBoosters/RedLightningContainer.cs index 4690fe9d63..fc31d34e87 100644 --- a/Items/PermanentBoosters/RedLightningContainer.cs +++ b/Items/PermanentBoosters/RedLightningContainer.cs @@ -1,4 +1,5 @@ -using CalamityMod.Balancing; +using System.Collections.Generic; +using CalamityMod.Balancing; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -29,7 +30,18 @@ namespace CalamityMod.Items.PermanentBoosters Item.SetRevExclusive(); } - public override bool CanUseItem(Player player) => !player.Calamity().rageBoostThree; + public static bool HasConsumedBefore(Player player) => player.Calamity().rageBoostThree; + + public override bool CanUseItem(Player player) + { + if (HasConsumedBefore(player)) + { + // Refuse Text can be added on here + return false; + } + + return true; + } public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { @@ -61,5 +73,11 @@ namespace CalamityMod.Items.PermanentBoosters } return true; } + + public override void ModifyTooltips(List list) + { + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip("Tooltip0"); + } } } diff --git a/Items/PermanentBoosters/SacredStrawberry.cs b/Items/PermanentBoosters/SacredStrawberry.cs index d6e040021e..96e4dd00f7 100644 --- a/Items/PermanentBoosters/SacredStrawberry.cs +++ b/Items/PermanentBoosters/SacredStrawberry.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; @@ -37,10 +36,31 @@ namespace CalamityMod.Items.PermanentBoosters Item.UseSound = UseSound; Item.useStyle = ItemUseStyleID.HoldUp; Item.value = Item.sellPrice(gold: 48); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } - public override bool CanUseItem(Player player) => player.ConsumedLifeFruit == Player.LifeFruitMax; + public static bool HasConsumedBefore(Player player) => player.Calamity().sStrawberry; + + public override bool CanUseItem(Player player) + { + if (player.ConsumedLifeFruit != Player.LifeFruitMax) + { + return false; + } + + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.SacredStrawberryText"; + Color messageColor = Color.SpringGreen; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -50,9 +70,6 @@ namespace CalamityMod.Items.PermanentBoosters player.itemTime = Item.useTime; if (modPlayer.sStrawberry) { - string key = "Mods.CalamityMod.Misc.SacredStrawberryText"; - Color messageColor = Color.SpringGreen; - CalamityUtils.DisplayLocalizedText(key, messageColor); return null; } @@ -64,16 +81,14 @@ namespace CalamityMod.Items.PermanentBoosters public override void ModifyTooltips(List list) { - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); - - if (line != null && Main.LocalPlayer.Calamity().sStrawberry) - line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText"); + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.LifeFruit, 5). + AddIngredient(ItemID.LifeFruit). AddIngredient(5). AddIngredient(). AddTile(). diff --git a/Items/PermanentBoosters/SanguineTangerine.cs b/Items/PermanentBoosters/SanguineTangerine.cs index 1348fda9fe..473b2b825b 100644 --- a/Items/PermanentBoosters/SanguineTangerine.cs +++ b/Items/PermanentBoosters/SanguineTangerine.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; @@ -38,7 +37,28 @@ namespace CalamityMod.Items.PermanentBoosters Item.rare = ItemRarityID.LightPurple; } - public override bool CanUseItem(Player player) => player.ConsumedLifeFruit == Player.LifeFruitMax; + public static bool HasConsumedBefore(Player player) => player.Calamity().sTangerine; + + public override bool CanUseItem(Player player) + { + if (player.ConsumedLifeFruit != Player.LifeFruitMax) + { + return false; + } + + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.SanguineTangerineText"; + Color messageColor = Color.Orange; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -48,9 +68,6 @@ namespace CalamityMod.Items.PermanentBoosters player.itemTime = Item.useTime; if (modPlayer.sTangerine) { - string key = "Mods.CalamityMod.Misc.SanguineTangerineText"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); return null; } @@ -62,16 +79,14 @@ namespace CalamityMod.Items.PermanentBoosters public override void ModifyTooltips(List list) { - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); - - if (line != null && Main.LocalPlayer.Calamity().sTangerine) - line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText"); + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.LifeFruit, 5). + AddIngredient(ItemID.LifeFruit). AddIngredient(10). AddIngredient(ItemID.SoulofFright, 5). AddIngredient(ItemID.SoulofMight, 5). diff --git a/Items/PermanentBoosters/StarlightFuelCell.cs b/Items/PermanentBoosters/StarlightFuelCell.cs index 7b84032f63..1cb8acc2e3 100644 --- a/Items/PermanentBoosters/StarlightFuelCell.cs +++ b/Items/PermanentBoosters/StarlightFuelCell.cs @@ -1,4 +1,5 @@ -using CalamityMod.Balancing; +using System.Collections.Generic; +using CalamityMod.Balancing; using CalamityMod.CalPlayer; using Terraria; using Terraria.ID; @@ -25,7 +26,18 @@ namespace CalamityMod.Items.PermanentBoosters Item.SetRevExclusive(); } - public override bool CanUseItem(Player player) => !player.Calamity().adrenalineBoostTwo; + public static bool HasConsumedBefore(Player player) => player.Calamity().adrenalineBoostTwo; + + public override bool CanUseItem(Player player) + { + if (HasConsumedBefore(player)) + { + // Refuse Text can be added on here + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -37,5 +49,11 @@ namespace CalamityMod.Items.PermanentBoosters } return true; } + + public override void ModifyTooltips(List list) + { + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip("Tooltip0"); + } } } diff --git a/Items/PermanentBoosters/TaintedCloudberry.cs b/Items/PermanentBoosters/TaintedCloudberry.cs index 67207446de..93bcaf634f 100644 --- a/Items/PermanentBoosters/TaintedCloudberry.cs +++ b/Items/PermanentBoosters/TaintedCloudberry.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; @@ -39,7 +38,28 @@ namespace CalamityMod.Items.PermanentBoosters Item.rare = ModContent.RarityType(); } - public override bool CanUseItem(Player player) => player.ConsumedLifeFruit == Player.LifeFruitMax; + public static bool HasConsumedBefore(Player player) => player.Calamity().tCloudberry; + + public override bool CanUseItem(Player player) + { + if (player.ConsumedLifeFruit != Player.LifeFruitMax) + { + return false; + } + + if (HasConsumedBefore(player)) + { + if (player.whoAmI == Main.myPlayer) + { + string key = "Mods.CalamityMod.Misc.TaintedCloudberryText"; + Color messageColor = Color.Turquoise; + Main.NewText(Language.GetTextValue(key), messageColor); + } + return false; + } + + return true; + } public override bool? UseItem(Player player) { @@ -49,9 +69,6 @@ namespace CalamityMod.Items.PermanentBoosters player.itemTime = Item.useTime; if (modPlayer.tCloudberry) { - string key = "Mods.CalamityMod.Misc.TaintedCloudberryText"; - Color messageColor = Color.Turquoise; - CalamityUtils.DisplayLocalizedText(key, messageColor); return null; } @@ -63,19 +80,17 @@ namespace CalamityMod.Items.PermanentBoosters public override void ModifyTooltips(List list) { - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1"); - - if (line != null && Main.LocalPlayer.Calamity().tCloudberry) - line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText"); + if (HasConsumedBefore(Main.LocalPlayer)) + list.AddConsumedTooltip(); } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.LifeFruit, 5). + AddIngredient(ItemID.LifeFruit). AddIngredient(10). AddIngredient(8). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Pets/AbyssShellFossil.cs b/Items/Pets/AbyssShellFossil.cs index d53bc07968..da2b049427 100644 --- a/Items/Pets/AbyssShellFossil.cs +++ b/Items/Pets/AbyssShellFossil.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.Pets; using CalamityMod.Projectiles.Pets; -using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Items/Pets/BrimstoneJewel.cs b/Items/Pets/BrimstoneJewel.cs index 0156aab59e..a6b9e00e61 100644 --- a/Items/Pets/BrimstoneJewel.cs +++ b/Items/Pets/BrimstoneJewel.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.Pets; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Pets @@ -15,7 +14,7 @@ namespace CalamityMod.Items.Pets { Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); Item.value = Item.sellPrice(gold: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Pets/BurrowerController.cs b/Items/Pets/BurrowerController.cs new file mode 100644 index 0000000000..2a84238557 --- /dev/null +++ b/Items/Pets/BurrowerController.cs @@ -0,0 +1,48 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Pets +{ + public class BurrowerController : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Pets"; + public override void SetDefaults() + { + Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); + Item.rare = ItemRarityID.Green; + Item.value = Item.sellPrice(gold: 3); + Item.UseSound = ThanatosHead.ThanatosHitSoundClosed; + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(Item.buffType, 3600, true); + } + } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryCustomScale( + spriteBatch, + texture: TextureAssets.Item[Type].Value, + position, + frame, + drawColor, + itemColor, + origin, + scale, + wantedScale: 0.8f, + drawOffset: new(0f, 0f) + ); + return false; + } + } +} diff --git a/Items/Pets/BurrowerController.png b/Items/Pets/BurrowerController.png new file mode 100644 index 0000000000..10e9b1849b Binary files /dev/null and b/Items/Pets/BurrowerController.png differ diff --git a/Items/Pets/CosmicPlushie.cs b/Items/Pets/CosmicPlushie.cs index 8de7642381..67f8e4a4c2 100644 --- a/Items/Pets/CosmicPlushie.cs +++ b/Items/Pets/CosmicPlushie.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Pets Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); Item.UseSound = SoundID.Meowmere; Item.value = Item.sellPrice(gold: 7); // Terry reference - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().devItem = true; } diff --git a/Items/Pets/ForgottenDragonEgg.cs b/Items/Pets/ForgottenDragonEgg.cs index ef80bee193..61d57f3831 100644 --- a/Items/Pets/ForgottenDragonEgg.cs +++ b/Items/Pets/ForgottenDragonEgg.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.Pets; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Pets @@ -15,7 +14,7 @@ namespace CalamityMod.Items.Pets { Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); Item.value = Item.sellPrice(gold: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Pets/FoxDrive.cs b/Items/Pets/FoxDrive.cs index bdd6efc790..9bca715113 100644 --- a/Items/Pets/FoxDrive.cs +++ b/Items/Pets/FoxDrive.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.Pets; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Pets @@ -16,7 +15,7 @@ namespace CalamityMod.Items.Pets Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); Item.expert = true; Item.value = Item.sellPrice(gold: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().devItem = true; } diff --git a/Items/Pets/FrostyBatBottle.cs b/Items/Pets/FrostyBatBottle.cs new file mode 100644 index 0000000000..b97b627ce1 --- /dev/null +++ b/Items/Pets/FrostyBatBottle.cs @@ -0,0 +1,46 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Pets +{ + public class FrostyBatBottle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Pets"; + public override void SetDefaults() + { + Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); + Item.rare = ItemRarityID.Green; + Item.value = Item.sellPrice(gold: 3); + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(Item.buffType, 3600, true); + } + } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryCustomScale( + spriteBatch, + texture: TextureAssets.Item[Type].Value, + position, + frame, + drawColor, + itemColor, + origin, + scale, + wantedScale: 1.3f, + drawOffset: new(0f, 0f) + ); + return false; + } + } +} diff --git a/Items/Pets/FrostyBatBottle.png b/Items/Pets/FrostyBatBottle.png new file mode 100644 index 0000000000..52d2b8df6e Binary files /dev/null and b/Items/Pets/FrostyBatBottle.png differ diff --git a/Items/Pets/HermitsBoxofOneHundredMedicines.cs b/Items/Pets/HermitsBoxofOneHundredMedicines.cs index c6888f7d9b..77c70516f2 100644 --- a/Items/Pets/HermitsBoxofOneHundredMedicines.cs +++ b/Items/Pets/HermitsBoxofOneHundredMedicines.cs @@ -2,9 +2,7 @@ using CalamityMod.Projectiles.Pets; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Pets diff --git a/Items/Pets/Levi.cs b/Items/Pets/Levi.cs index 567418d2f4..1b71cf00a3 100644 --- a/Items/Pets/Levi.cs +++ b/Items/Pets/Levi.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.Pets; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Pets @@ -15,7 +14,7 @@ namespace CalamityMod.Items.Pets { Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); Item.value = Item.sellPrice(gold: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().devItem = true; } diff --git a/Items/Pets/McNuggets.cs b/Items/Pets/McNuggets.cs index 9ec90e2e81..c33ad2bf60 100644 --- a/Items/Pets/McNuggets.cs +++ b/Items/Pets/McNuggets.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.Pets; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Pets @@ -15,7 +14,7 @@ namespace CalamityMod.Items.Pets { Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); Item.value = Item.sellPrice(gold: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void UseStyle(Player player, Rectangle heldItemFrame) diff --git a/Items/Pets/ToastyBatBottle.cs b/Items/Pets/ToastyBatBottle.cs new file mode 100644 index 0000000000..a9c70d9d67 --- /dev/null +++ b/Items/Pets/ToastyBatBottle.cs @@ -0,0 +1,46 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Pets +{ + public class ToastyBatBottle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Pets"; + public override void SetDefaults() + { + Item.DefaultToVanitypet(ModContent.ProjectileType(), ModContent.BuffType()); + Item.rare = ItemRarityID.Orange; + Item.value = Item.sellPrice(gold: 3); + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.whoAmI == Main.myPlayer && player.itemTime == 0) + { + player.AddBuff(Item.buffType, 3600, true); + } + } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryCustomScale( + spriteBatch, + texture: TextureAssets.Item[Type].Value, + position, + frame, + drawColor, + itemColor, + origin, + scale, + wantedScale: 1.3f, + drawOffset: new(0f, 0f) + ); + return false; + } + } +} diff --git a/Items/Pets/ToastyBatBottle.png b/Items/Pets/ToastyBatBottle.png new file mode 100644 index 0000000000..b762076bee Binary files /dev/null and b/Items/Pets/ToastyBatBottle.png differ diff --git a/Items/Placeables/Abyss/PlantyMush.cs b/Items/Placeables/Abyss/PlantyMush.cs index e747501a43..f8cbb474b3 100644 --- a/Items/Placeables/Abyss/PlantyMush.cs +++ b/Items/Placeables/Abyss/PlantyMush.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Abyss diff --git a/Items/Placeables/Abyss/PyreMantleMolten.cs b/Items/Placeables/Abyss/PyreMantleMolten.cs index c33d644406..ef8467e683 100644 --- a/Items/Placeables/Abyss/PyreMantleMolten.cs +++ b/Items/Placeables/Abyss/PyreMantleMolten.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Abyss diff --git a/Items/Placeables/Abyss/SulphurousSand.cs b/Items/Placeables/Abyss/SulphurousSand.cs index e2b44467ba..59087ec75f 100644 --- a/Items/Placeables/Abyss/SulphurousSand.cs +++ b/Items/Placeables/Abyss/SulphurousSand.cs @@ -12,8 +12,7 @@ namespace CalamityMod.Items.Placeables.Abyss Item.ResearchUnlockCount = 100; ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - // +5 flat damage, equal to other sand variants - ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } public override void SetDefaults() diff --git a/Items/Placeables/Astral/AstralGrassSeeds.cs b/Items/Placeables/Astral/AstralGrassSeeds.cs index 526e3af882..18acbb6bcd 100644 --- a/Items/Placeables/Astral/AstralGrassSeeds.cs +++ b/Items/Placeables/Astral/AstralGrassSeeds.cs @@ -29,16 +29,22 @@ namespace CalamityMod.Items.Placeables.Astral Item.value = Item.buyPrice(silver: 20); // Sold by Dryad; equal to Hallowed Seeds } - public override bool? UseItem(Player player) + public override bool? UseItem(Player player) => true; + + public override bool ConsumeItem(Player player) { - var tile = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY); + var tileX = Player.tileTargetX; + var tileY = Player.tileTargetY; + var tile = Framing.GetTileSafely(tileX, tileY); - if (tile.HasTile && tile.TileType == ModContent.TileType() && player.IsInTileInteractionRange(Player.tileTargetX, Player.tileTargetY, TileReachCheckSettings.Simple)) + if (tile.HasTile && tile.TileType == ModContent.TileType() && player.IsInTileInteractionRange(tileX, tileY, TileReachCheckSettings.Simple)) { - Main.tile[Player.tileTargetX, Player.tileTargetY].TileType = (ushort)ModContent.TileType(); - + tile.TileType = (ushort)ModContent.TileType(); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileSquare(player.whoAmI, tileX, tileY); + } SoundEngine.PlaySound(SoundID.Dig, player.Center); - return true; } diff --git a/Items/Placeables/Astral/AstralMonolith.cs b/Items/Placeables/Astral/AstralMonolith.cs deleted file mode 100644 index df2a693ba4..0000000000 --- a/Items/Placeables/Astral/AstralMonolith.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CalamityMod.Items.Placeables.FurnitureMonolith; -using CalamityMod.Items.Placeables.Walls; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.Astral -{ - public class AstralMonolith : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.Wood; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - // It's not really wood... but it comes from trees! - itemGroup = ContentSamples.CreativeHelper.ItemGroup.Wood; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddTile(TileID.WorkBenches). - DisableDecraft(). - Register(); - - CreateRecipe(). - AddIngredient(2). - DisableDecraft(). - Register(); - } - } -} diff --git a/Items/Placeables/Astral/AstralSand.cs b/Items/Placeables/Astral/AstralSand.cs index 1ddc465fb5..a7e732363b 100644 --- a/Items/Placeables/Astral/AstralSand.cs +++ b/Items/Placeables/Astral/AstralSand.cs @@ -13,8 +13,7 @@ namespace CalamityMod.Items.Placeables.Astral Item.ResearchUnlockCount = 100; ItemTrader.ChlorophyteExtractinator.AddOption_OneWay(Type, 1, ItemID.SandBlock, 1); - // +5 flat damage, equal to other sand variants - ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } public override void SetDefaults() diff --git a/Items/Placeables/Astral/CelestialRemains.cs b/Items/Placeables/Astral/CelestialRemains.cs index 5c5a398db9..1ac5969a51 100644 --- a/Items/Placeables/Astral/CelestialRemains.cs +++ b/Items/Placeables/Astral/CelestialRemains.cs @@ -108,32 +108,32 @@ namespace CalamityMod.Items.Placeables.Astral resultType = ItemID.Amber; resultStack = Main.rand.Next(1, 21); } - else if (val < 81.78f) + else if (val < 81.78f && Main.hardMode) { resultType = ItemID.PalladiumOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 83.03f) + else if (val < 83.03f && Main.hardMode) { resultType = ItemID.CobaltOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 85.03f) + else if (val < 85.03f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.CobaltOre : ItemID.MythrilOre : ItemID.MythrilOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 87.03f) + else if (val < 87.03f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.PalladiumOre : ItemID.OrichalcumOre : ItemID.OrichalcumOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 88.78f) + else if (val < 88.78f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.CobaltOre : !twoMechsDowned ? ItemID.MythrilOre : ItemID.AdamantiteOre : ItemID.AdamantiteOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 89.53f) + else if (val < 89.53f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.PalladiumOre : !twoMechsDowned ? ItemID.OrichalcumOre : ItemID.TitaniumOre : ItemID.TitaniumOre; resultStack = Main.rand.Next(1, 17); diff --git a/Items/Placeables/Astral/NovaeSlag.cs b/Items/Placeables/Astral/NovaeSlag.cs index b78942be81..116e17712e 100644 --- a/Items/Placeables/Astral/NovaeSlag.cs +++ b/Items/Placeables/Astral/NovaeSlag.cs @@ -97,32 +97,32 @@ namespace CalamityMod.Items.Placeables.Astral resultType = ItemID.Amber; resultStack = Main.rand.Next(1, 21); } - else if (val < 78.78f) + else if (val < 78.78f && Main.hardMode) { resultType = ItemID.PalladiumOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 81.03f) + else if (val < 81.03f && Main.hardMode) { resultType = ItemID.CobaltOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 83.03f) + else if (val < 83.03f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.CobaltOre : ItemID.MythrilOre : ItemID.MythrilOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 85.03f) + else if (val < 85.03f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.PalladiumOre : ItemID.OrichalcumOre : ItemID.OrichalcumOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 86.78f) + else if (val < 86.78f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.CobaltOre : !twoMechsDowned ? ItemID.MythrilOre : ItemID.AdamantiteOre : ItemID.AdamantiteOre; resultStack = Main.rand.Next(1, 17); } - else if (val < 88.53f) + else if (val < 88.53f && Main.hardMode) { resultType = CalamityServerConfig.Instance.EarlyHardmodeProgressionRework ? !NPC.downedMechBossAny ? ItemID.PalladiumOre : !twoMechsDowned ? ItemID.OrichalcumOre : ItemID.TitaniumOre : ItemID.TitaniumOre; resultStack = Main.rand.Next(1, 17); diff --git a/Items/Placeables/Banners/ArmoredDiggerBanner.cs b/Items/Placeables/Banners/ArmoredDiggerBanner.cs deleted file mode 100644 index f035d46d06..0000000000 --- a/Items/Placeables/Banners/ArmoredDiggerBanner.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace CalamityMod.Items.Placeables.Banners -{ - public class ArmoredDiggerBanner : BaseBanner - { - public override int BannerTileStyle => 77; - public override int BannerKillRequirement => 25; - } -} diff --git a/Items/Placeables/Banners/BabyGhostBellBanner.png b/Items/Placeables/Banners/BabyGhostBellBanner.png index 6c1997b3b2..28922c83c1 100644 Binary files a/Items/Placeables/Banners/BabyGhostBellBanner.png and b/Items/Placeables/Banners/BabyGhostBellBanner.png differ diff --git a/Items/Placeables/Banners/BurrowerBanner.cs b/Items/Placeables/Banners/BurrowerBanner.cs new file mode 100644 index 0000000000..0b5abd9db3 --- /dev/null +++ b/Items/Placeables/Banners/BurrowerBanner.cs @@ -0,0 +1,8 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class BurrowerBanner : BaseBanner + { + public override int BannerTileStyle => 77; + public override int BannerKillRequirement => 25; + } +} diff --git a/Items/Placeables/Banners/ArmoredDiggerBanner.png b/Items/Placeables/Banners/BurrowerBanner.png similarity index 100% rename from Items/Placeables/Banners/ArmoredDiggerBanner.png rename to Items/Placeables/Banners/BurrowerBanner.png diff --git a/Items/Placeables/Banners/CarrionSwallowerBanner.cs b/Items/Placeables/Banners/CarrionSwallowerBanner.cs new file mode 100644 index 0000000000..90902798cf --- /dev/null +++ b/Items/Placeables/Banners/CarrionSwallowerBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class CarrionSwallowerBanner : BaseBanner + { + public override int BannerTileStyle => 131; + } +} diff --git a/Items/Placeables/Banners/CarrionSwallowerBanner.png b/Items/Placeables/Banners/CarrionSwallowerBanner.png new file mode 100644 index 0000000000..06ec2f37d3 Binary files /dev/null and b/Items/Placeables/Banners/CarrionSwallowerBanner.png differ diff --git a/Items/Placeables/Banners/ClamBanner.png b/Items/Placeables/Banners/ClamBanner.png index 74b65932d9..1aab94c02e 100644 Binary files a/Items/Placeables/Banners/ClamBanner.png and b/Items/Placeables/Banners/ClamBanner.png differ diff --git a/Items/Placeables/Banners/EutrophicRayBanner.png b/Items/Placeables/Banners/EutrophicRayBanner.png index 64815b0761..9ea5ff141d 100644 Binary files a/Items/Placeables/Banners/EutrophicRayBanner.png and b/Items/Placeables/Banners/EutrophicRayBanner.png differ diff --git a/Items/Placeables/Banners/GhostBellBanner.png b/Items/Placeables/Banners/GhostBellBanner.png index 74dcd77ed3..a9b012f504 100644 Binary files a/Items/Placeables/Banners/GhostBellBanner.png and b/Items/Placeables/Banners/GhostBellBanner.png differ diff --git a/Items/Placeables/Banners/GildedAxolotlBanner.cs b/Items/Placeables/Banners/GildedAxolotlBanner.cs new file mode 100644 index 0000000000..1c91822889 --- /dev/null +++ b/Items/Placeables/Banners/GildedAxolotlBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class GildedAxolotlBanner : BaseBanner + { + public override int BannerTileStyle => 132; + } +} diff --git a/Items/Placeables/Banners/GildedAxolotlBanner.png b/Items/Placeables/Banners/GildedAxolotlBanner.png new file mode 100644 index 0000000000..9fe9cd10c0 Binary files /dev/null and b/Items/Placeables/Banners/GildedAxolotlBanner.png differ diff --git a/Items/Placeables/Banners/GrubboltBanner.png b/Items/Placeables/Banners/GrubboltBanner.png new file mode 100644 index 0000000000..6c9733e5e4 Binary files /dev/null and b/Items/Placeables/Banners/GrubboltBanner.png differ diff --git a/Items/Placeables/Banners/HauntedChumBanner.cs b/Items/Placeables/Banners/HauntedChumBanner.cs new file mode 100644 index 0000000000..5613395082 --- /dev/null +++ b/Items/Placeables/Banners/HauntedChumBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class HauntedChumBanner : BaseBanner + { + public override int BannerTileStyle => 134; + } +} diff --git a/Items/Placeables/Banners/HauntedChumBanner.png b/Items/Placeables/Banners/HauntedChumBanner.png new file mode 100644 index 0000000000..711d5fa40f Binary files /dev/null and b/Items/Placeables/Banners/HauntedChumBanner.png differ diff --git a/Items/Placeables/Banners/JellyghoulBanner.cs b/Items/Placeables/Banners/JellyghoulBanner.cs new file mode 100644 index 0000000000..760cf5c86b --- /dev/null +++ b/Items/Placeables/Banners/JellyghoulBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class JellyghoulBanner : BaseBanner + { + public override int BannerTileStyle => 135; + } +} diff --git a/Items/Placeables/Banners/JellyghoulBanner.png b/Items/Placeables/Banners/JellyghoulBanner.png new file mode 100644 index 0000000000..01ded98a8a Binary files /dev/null and b/Items/Placeables/Banners/JellyghoulBanner.png differ diff --git a/Items/Placeables/Banners/KelpieSeadragonBanner.cs b/Items/Placeables/Banners/KelpieSeadragonBanner.cs new file mode 100644 index 0000000000..a3048b0a20 --- /dev/null +++ b/Items/Placeables/Banners/KelpieSeadragonBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class KelpieSeadragonBanner : BaseBanner + { + public override int BannerTileStyle => 136; + } +} diff --git a/Items/Placeables/Banners/KelpieSeadragonBanner.png b/Items/Placeables/Banners/KelpieSeadragonBanner.png new file mode 100644 index 0000000000..6a08e30355 Binary files /dev/null and b/Items/Placeables/Banners/KelpieSeadragonBanner.png differ diff --git a/Items/Placeables/Banners/LazarusLampfishBanner.cs b/Items/Placeables/Banners/LazarusLampfishBanner.cs new file mode 100644 index 0000000000..64ea4ba955 --- /dev/null +++ b/Items/Placeables/Banners/LazarusLampfishBanner.cs @@ -0,0 +1,10 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Banners +{ + [LegacyName("BlindedAnglerBanner")] + public class LazarusLampfishBanner : BaseBanner + { + public override int BannerTileStyle => 104; + } +} diff --git a/Items/Placeables/Banners/LazarusLampfishBanner.png b/Items/Placeables/Banners/LazarusLampfishBanner.png new file mode 100644 index 0000000000..e6d468d0e6 Binary files /dev/null and b/Items/Placeables/Banners/LazarusLampfishBanner.png differ diff --git a/Items/Placeables/Banners/LeerslugBanner.cs b/Items/Placeables/Banners/LeerslugBanner.cs new file mode 100644 index 0000000000..16370c2bec --- /dev/null +++ b/Items/Placeables/Banners/LeerslugBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class LeerslugBanner : BaseBanner + { + public override int BannerTileStyle => 137; + } +} diff --git a/Items/Placeables/Banners/LeerslugBanner.png b/Items/Placeables/Banners/LeerslugBanner.png new file mode 100644 index 0000000000..a4eaf2a916 Binary files /dev/null and b/Items/Placeables/Banners/LeerslugBanner.png differ diff --git a/Items/Placeables/Banners/LostShoalBanner.cs b/Items/Placeables/Banners/LostShoalBanner.cs new file mode 100644 index 0000000000..b63af3b21d --- /dev/null +++ b/Items/Placeables/Banners/LostShoalBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class LostShoalBanner : BaseBanner + { + public override int BannerTileStyle => 138; + } +} diff --git a/Items/Placeables/Banners/LostShoalBanner.png b/Items/Placeables/Banners/LostShoalBanner.png new file mode 100644 index 0000000000..7c9a0febca Binary files /dev/null and b/Items/Placeables/Banners/LostShoalBanner.png differ diff --git a/Items/Placeables/Banners/MirageNewtBanner.png b/Items/Placeables/Banners/MirageNewtBanner.png new file mode 100644 index 0000000000..1424910e5c Binary files /dev/null and b/Items/Placeables/Banners/MirageNewtBanner.png differ diff --git a/Items/Placeables/Banners/PanaseaBanner.png b/Items/Placeables/Banners/PanaseaBanner.png new file mode 100644 index 0000000000..8c85af80ca Binary files /dev/null and b/Items/Placeables/Banners/PanaseaBanner.png differ diff --git a/Items/Placeables/Banners/PearlpodBanner.cs b/Items/Placeables/Banners/PearlpodBanner.cs new file mode 100644 index 0000000000..bf3ba1b781 --- /dev/null +++ b/Items/Placeables/Banners/PearlpodBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class PearlpodBanner : BaseBanner + { + public override int BannerTileStyle => 141; + } +} diff --git a/Items/Placeables/Banners/PearlpodBanner.png b/Items/Placeables/Banners/PearlpodBanner.png new file mode 100644 index 0000000000..e341098eb2 Binary files /dev/null and b/Items/Placeables/Banners/PearlpodBanner.png differ diff --git a/Items/Placeables/Banners/PodobooKoiBanner.cs b/Items/Placeables/Banners/PodobooKoiBanner.cs new file mode 100644 index 0000000000..14ac5680a0 --- /dev/null +++ b/Items/Placeables/Banners/PodobooKoiBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class PodobooKoiBanner : BaseBanner + { + public override int BannerTileStyle => 143; + } +} diff --git a/Items/Placeables/Banners/PodobooKoiBanner.png b/Items/Placeables/Banners/PodobooKoiBanner.png new file mode 100644 index 0000000000..c2b67aa9cc Binary files /dev/null and b/Items/Placeables/Banners/PodobooKoiBanner.png differ diff --git a/Items/Placeables/Banners/PolyperilBanner.cs b/Items/Placeables/Banners/PolyperilBanner.cs new file mode 100644 index 0000000000..6bc04212fd --- /dev/null +++ b/Items/Placeables/Banners/PolyperilBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class PolyperilBanner : BaseBanner + { + public override int BannerTileStyle => 144; + } +} diff --git a/Items/Placeables/Banners/PolyperilBanner.png b/Items/Placeables/Banners/PolyperilBanner.png new file mode 100644 index 0000000000..bd04faf38e Binary files /dev/null and b/Items/Placeables/Banners/PolyperilBanner.png differ diff --git a/Items/Placeables/Banners/PrismBackBanner.png b/Items/Placeables/Banners/PrismBackBanner.png index 1f467b4d74..cc05ba7917 100644 Binary files a/Items/Placeables/Banners/PrismBackBanner.png and b/Items/Placeables/Banners/PrismBackBanner.png differ diff --git a/Items/Placeables/Banners/PrismaticGuppyBanner.cs b/Items/Placeables/Banners/PrismaticGuppyBanner.cs new file mode 100644 index 0000000000..583fa7aa71 --- /dev/null +++ b/Items/Placeables/Banners/PrismaticGuppyBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class PrismaticGuppyBanner : BaseBanner + { + public override int BannerTileStyle => 145; + } +} diff --git a/Items/Placeables/Banners/PrismaticGuppyBanner.png b/Items/Placeables/Banners/PrismaticGuppyBanner.png new file mode 100644 index 0000000000..7c2acc6c4b Binary files /dev/null and b/Items/Placeables/Banners/PrismaticGuppyBanner.png differ diff --git a/Items/Placeables/Banners/ProbesnoutBanner.png b/Items/Placeables/Banners/ProbesnoutBanner.png index 40c40de9f3..331b966302 100644 Binary files a/Items/Placeables/Banners/ProbesnoutBanner.png and b/Items/Placeables/Banners/ProbesnoutBanner.png differ diff --git a/Items/Placeables/Banners/SandProwlerBanner.cs b/Items/Placeables/Banners/SandProwlerBanner.cs new file mode 100644 index 0000000000..9fef623265 --- /dev/null +++ b/Items/Placeables/Banners/SandProwlerBanner.cs @@ -0,0 +1,10 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Banners +{ + [LegacyName("SeaSerpentBanner")] + public class SandProwlerBanner : BaseBanner + { + public override int BannerTileStyle => 106; + } +} diff --git a/Items/Placeables/Banners/SandProwlerBanner.png b/Items/Placeables/Banners/SandProwlerBanner.png new file mode 100644 index 0000000000..c440619fe1 Binary files /dev/null and b/Items/Placeables/Banners/SandProwlerBanner.png differ diff --git a/Items/Placeables/Banners/ScavengerBanner.cs b/Items/Placeables/Banners/ScavengerBanner.cs new file mode 100644 index 0000000000..3c38808a7d --- /dev/null +++ b/Items/Placeables/Banners/ScavengerBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class ScavengerBanner : BaseBanner + { + public override int BannerTileStyle => 146; + } +} diff --git a/Items/Placeables/Banners/ScavengerBanner.png b/Items/Placeables/Banners/ScavengerBanner.png new file mode 100644 index 0000000000..4d894c8707 Binary files /dev/null and b/Items/Placeables/Banners/ScavengerBanner.png differ diff --git a/Items/Placeables/Banners/SeaFloatyBanner.png b/Items/Placeables/Banners/SeaFloatyBanner.png index 1578c3e4dc..3f38042d8a 100644 Binary files a/Items/Placeables/Banners/SeaFloatyBanner.png and b/Items/Placeables/Banners/SeaFloatyBanner.png differ diff --git a/Items/Placeables/Banners/SeaMinnowBanner.png b/Items/Placeables/Banners/SeaMinnowBanner.png index aa6eebf84f..2419202e4b 100644 Binary files a/Items/Placeables/Banners/SeaMinnowBanner.png and b/Items/Placeables/Banners/SeaMinnowBanner.png differ diff --git a/Items/Placeables/Banners/SeaSerpentBanner.cs b/Items/Placeables/Banners/SeaSerpentBanner.cs deleted file mode 100644 index ef12cc3ebc..0000000000 --- a/Items/Placeables/Banners/SeaSerpentBanner.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace CalamityMod.Items.Placeables.Banners -{ - public class SeaSerpentBanner : BaseBanner - { - public override int BannerTileStyle => 106; - } -} diff --git a/Items/Placeables/Banners/SeaSerpentBanner.png b/Items/Placeables/Banners/SeaSerpentBanner.png deleted file mode 100644 index e384093d74..0000000000 Binary files a/Items/Placeables/Banners/SeaSerpentBanner.png and /dev/null differ diff --git a/Items/Placeables/Banners/SearslugBanner.cs b/Items/Placeables/Banners/SearslugBanner.cs new file mode 100644 index 0000000000..0d16292aac --- /dev/null +++ b/Items/Placeables/Banners/SearslugBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class SearslugBanner : BaseBanner + { + public override int BannerTileStyle => 147; + } +} diff --git a/Items/Placeables/Banners/SearslugBanner.png b/Items/Placeables/Banners/SearslugBanner.png new file mode 100644 index 0000000000..1851a2640f Binary files /dev/null and b/Items/Placeables/Banners/SearslugBanner.png differ diff --git a/Items/Placeables/Banners/SharkoonBanner.png b/Items/Placeables/Banners/SharkoonBanner.png index 6dcf32bad3..e42d222bd7 100644 Binary files a/Items/Placeables/Banners/SharkoonBanner.png and b/Items/Placeables/Banners/SharkoonBanner.png differ diff --git a/Items/Placeables/Banners/ShoreskipperBanner.cs b/Items/Placeables/Banners/ShoreskipperBanner.cs new file mode 100644 index 0000000000..441b371120 --- /dev/null +++ b/Items/Placeables/Banners/ShoreskipperBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class ShoreskipperBanner : BaseBanner + { + public override int BannerTileStyle => 148; + } +} diff --git a/Items/Placeables/Banners/ShoreskipperBanner.png b/Items/Placeables/Banners/ShoreskipperBanner.png new file mode 100644 index 0000000000..c08cb19213 Binary files /dev/null and b/Items/Placeables/Banners/ShoreskipperBanner.png differ diff --git a/Items/Placeables/Banners/SlugbunBanner.cs b/Items/Placeables/Banners/SlugbunBanner.cs new file mode 100644 index 0000000000..ebdb7624cd --- /dev/null +++ b/Items/Placeables/Banners/SlugbunBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class SlugbunBanner : BaseBanner + { + public override int BannerTileStyle => 149; + } +} diff --git a/Items/Placeables/Banners/SlugbunBanner.png b/Items/Placeables/Banners/SlugbunBanner.png new file mode 100644 index 0000000000..c7f6060a39 Binary files /dev/null and b/Items/Placeables/Banners/SlugbunBanner.png differ diff --git a/Items/Placeables/Banners/SteampodBanner.cs b/Items/Placeables/Banners/SteampodBanner.cs new file mode 100644 index 0000000000..f62212ebc6 --- /dev/null +++ b/Items/Placeables/Banners/SteampodBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class SteampodBanner : BaseBanner + { + public override int BannerTileStyle => 150; + } +} diff --git a/Items/Placeables/Banners/SteampodBanner.png b/Items/Placeables/Banners/SteampodBanner.png new file mode 100644 index 0000000000..a503c69f5b Binary files /dev/null and b/Items/Placeables/Banners/SteampodBanner.png differ diff --git a/Items/Placeables/Banners/StormlionBanner.png b/Items/Placeables/Banners/StormlionBanner.png index 23afbabbfa..e15ff2bc86 100644 Binary files a/Items/Placeables/Banners/StormlionBanner.png and b/Items/Placeables/Banners/StormlionBanner.png differ diff --git a/Items/Placeables/Banners/StormlionScoutBanner.png b/Items/Placeables/Banners/StormlionScoutBanner.png new file mode 100644 index 0000000000..8eda3688b6 Binary files /dev/null and b/Items/Placeables/Banners/StormlionScoutBanner.png differ diff --git a/Items/Placeables/Banners/StormlionSentryBanner.cs b/Items/Placeables/Banners/StormlionSentryBanner.cs new file mode 100644 index 0000000000..62ba388dca --- /dev/null +++ b/Items/Placeables/Banners/StormlionSentryBanner.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Items.Placeables.Banners +{ + public class StormlionSentryBanner : BaseBanner + { + public override int BannerTileStyle => 142; + } +} diff --git a/Items/Placeables/Banners/StormlionSentryBanner.png b/Items/Placeables/Banners/StormlionSentryBanner.png new file mode 100644 index 0000000000..67bab5c7e6 Binary files /dev/null and b/Items/Placeables/Banners/StormlionSentryBanner.png differ diff --git a/Items/Placeables/Crags/CinderBlossomSeeds.cs b/Items/Placeables/Crags/CinderBlossomSeeds.cs index 0d0506283a..4455e74a82 100644 --- a/Items/Placeables/Crags/CinderBlossomSeeds.cs +++ b/Items/Placeables/Crags/CinderBlossomSeeds.cs @@ -29,17 +29,23 @@ namespace CalamityMod.Items.Placeables.Crags Item.value = Item.buyPrice(silver: 1, copper: 50); // Sold by Dryad; equal to Ash Grass Seeds } - public override bool? UseItem(Player player) + public override bool? UseItem(Player player) => true; + + public override bool ConsumeItem(Player player) { - var tile = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY); - var tileAbove = Framing.GetTileSafely(Player.tileTargetX, Player.tileTargetY - 1); + var tileX = Player.tileTargetX; + var tileY = Player.tileTargetY; + var tile = Framing.GetTileSafely(tileX, tileY); + var tileAbove = Framing.GetTileSafely(tileX, tileY - 1); if (tile.HasTile && !tileAbove.HasTile && tileAbove.LiquidAmount == 0 && tile.TileType == ModContent.TileType() && player.IsInTileInteractionRange(Player.tileTargetX, Player.tileTargetY, TileReachCheckSettings.Simple)) { - Main.tile[Player.tileTargetX, Player.tileTargetY].TileType = (ushort)ModContent.TileType(); - + tile.TileType = (ushort)ModContent.TileType(); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileSquare(player.whoAmI, tileX, tileY); + } SoundEngine.PlaySound(SoundID.Dig, player.Center); - return true; } diff --git a/Items/Placeables/Crags/ScorchedBone.cs b/Items/Placeables/Crags/ScorchedBone.cs index fe3a24f2be..e42fb66015 100644 --- a/Items/Placeables/Crags/ScorchedBone.cs +++ b/Items/Placeables/Crags/ScorchedBone.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Tiles.Crags; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/Crags/ScorchedRemains.cs b/Items/Placeables/Crags/ScorchedRemains.cs index 71d1dcee55..8c43df8bc8 100644 --- a/Items/Placeables/Crags/ScorchedRemains.cs +++ b/Items/Placeables/Crags/ScorchedRemains.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Crags { diff --git a/Items/Placeables/Crags/SpineSapling.cs b/Items/Placeables/Crags/SpineSapling.cs index f267ec6cc3..ba77a0ff98 100644 --- a/Items/Placeables/Crags/SpineSapling.cs +++ b/Items/Placeables/Crags/SpineSapling.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Crags diff --git a/Items/Placeables/DraedonStructures/AgedLaboratoryDoorItem.cs b/Items/Placeables/DraedonStructures/AgedLaboratoryDoorItem.cs index 1695104f5d..6f9a3de666 100644 --- a/Items/Placeables/DraedonStructures/AgedLaboratoryDoorItem.cs +++ b/Items/Placeables/DraedonStructures/AgedLaboratoryDoorItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.DraedonStructures; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/AgedSecurityChest.cs b/Items/Placeables/DraedonStructures/AgedSecurityChest.cs index b6aeef20a6..bdedb1a46b 100644 --- a/Items/Placeables/DraedonStructures/AgedSecurityChest.cs +++ b/Items/Placeables/DraedonStructures/AgedSecurityChest.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.DraedonStructures; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/AgedBiolightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/AgedBiolightItem.cs index e3ad0a0963..88252e3031 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/AgedBiolightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/AgedBiolightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/AgedBlacklightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/AgedBlacklightItem.cs index 01fe0c1414..e2d62aad2a 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/AgedBlacklightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/AgedBlacklightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/AgedCinderlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/AgedCinderlightItem.cs index 6ba967638c..ce65bf0a01 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/AgedCinderlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/AgedCinderlightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/AgedFlamelightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/AgedFlamelightItem.cs index e8115a6183..adf01accd5 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/AgedFlamelightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/AgedFlamelightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/AgedFloodlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/AgedFloodlightItem.cs index 14e217ff4d..4e77f5f00a 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/AgedFloodlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/AgedFloodlightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/AgedFrostlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/AgedFrostlightItem.cs index b2dafd8ec7..0918087488 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/AgedFrostlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/AgedFrostlightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/AgedLablightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/AgedLablightItem.cs index fe90044853..137dda907b 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/AgedLablightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/AgedLablightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/CagedBiolightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/CagedBiolightItem.cs index 5c5b4d1c24..cf33075036 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/CagedBiolightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/CagedBiolightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/CagedBlacklightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/CagedBlacklightItem.cs index 200edbe195..fcef43c927 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/CagedBlacklightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/CagedBlacklightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/CagedCinderlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/CagedCinderlightItem.cs index 9ba814cd9d..4a7e47f6a5 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/CagedCinderlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/CagedCinderlightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/CagedFlamelightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/CagedFlamelightItem.cs index d152d30995..b127343a3a 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/CagedFlamelightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/CagedFlamelightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/CagedFloodlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/CagedFloodlightItem.cs index 6cc84ad544..3161e1bb4f 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/CagedFloodlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/CagedFloodlightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/CagedFrostlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/CagedFrostlightItem.cs index d5a579cba8..07c9d84f45 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/CagedFrostlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/CagedFrostlightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/CagedLablightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/CagedLablightItem.cs index ac37e89196..b6e0beaf41 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/CagedLablightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/CagedLablightItem.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBiolightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBiolightItem.cs index 796752ee72..0107813250 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBiolightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBiolightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBlacklightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBlacklightItem.cs index 276fc58bf5..e520705d59 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBlacklightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedBlacklightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedCinderlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedCinderlightItem.cs index f8062177b3..234de65bc7 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedCinderlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedCinderlightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFlamelightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFlamelightItem.cs index a32273a837..23f0fa7b04 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFlamelightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFlamelightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFloodlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFloodlightItem.cs index 733fcb20af..ae1b3cfe21 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFloodlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFloodlightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFrostlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFrostlightItem.cs index c3bec4b0d2..60a2a3feec 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFrostlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedFrostlightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedLablightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedLablightItem.cs index fe72387478..5d04897736 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniAgedLablightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniAgedLablightItem.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures.CagedLights; +using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBiolightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBiolightItem.cs index 598f78e7ce..4d19f14456 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBiolightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBiolightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBlacklightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBlacklightItem.cs index 3be35ae9c9..708dae7571 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBlacklightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedBlacklightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedCinderlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedCinderlightItem.cs index c4500df24d..dde2aa4308 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedCinderlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedCinderlightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFlamelightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFlamelightItem.cs index 3855d7833a..cf340e6514 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFlamelightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFlamelightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFloodlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFloodlightItem.cs index 7b61923a07..956a0c30bd 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFloodlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFloodlightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFrostlightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFrostlightItem.cs index 3541de0379..820eb06644 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFrostlightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedFrostlightItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; diff --git a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedLablightItem.cs b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedLablightItem.cs index 01ec2238dd..ce03f6e8ec 100644 --- a/Items/Placeables/DraedonStructures/CagedLights/MiniCagedLablightItem.cs +++ b/Items/Placeables/DraedonStructures/CagedLights/MiniCagedLablightItem.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Plates; using CalamityMod.Tiles.DraedonStructures.CagedLights; using Terraria; using Terraria.ID; diff --git a/Items/Placeables/DraedonStructures/ChargingStationItem.cs b/Items/Placeables/DraedonStructures/ChargingStationItem.cs index 8e2c01a78b..f182447bcd 100644 --- a/Items/Placeables/DraedonStructures/ChargingStationItem.cs +++ b/Items/Placeables/DraedonStructures/ChargingStationItem.cs @@ -1,7 +1,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.DraedonStructures; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.DraedonStructures diff --git a/Items/Placeables/DraedonStructures/LaboratoryDoorItem.cs b/Items/Placeables/DraedonStructures/LaboratoryDoorItem.cs index 57ab558052..1485a4f742 100644 --- a/Items/Placeables/DraedonStructures/LaboratoryDoorItem.cs +++ b/Items/Placeables/DraedonStructures/LaboratoryDoorItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.DraedonStructures; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/LaboratoryShelf.cs b/Items/Placeables/DraedonStructures/LaboratoryShelf.cs index f520782130..1deedffecb 100644 --- a/Items/Placeables/DraedonStructures/LaboratoryShelf.cs +++ b/Items/Placeables/DraedonStructures/LaboratoryShelf.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.DraedonStructures { public class LaboratoryShelf : ModItem, ILocalizedModType diff --git a/Items/Placeables/DraedonStructures/PowerCellFactoryItem.cs b/Items/Placeables/DraedonStructures/PowerCellFactoryItem.cs index 6b6f27ba49..9f554737f8 100644 --- a/Items/Placeables/DraedonStructures/PowerCellFactoryItem.cs +++ b/Items/Placeables/DraedonStructures/PowerCellFactoryItem.cs @@ -1,7 +1,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.DraedonStructures; using Terraria; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Placeables/DraedonStructures/RustedShelf.cs b/Items/Placeables/DraedonStructures/RustedShelf.cs index 7ae47aec6c..5c2e3a1da2 100644 --- a/Items/Placeables/DraedonStructures/RustedShelf.cs +++ b/Items/Placeables/DraedonStructures/RustedShelf.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.DraedonStructures { public class RustedShelf : ModItem, ILocalizedModType diff --git a/Items/Placeables/DraedonStructures/SecurityChest.cs b/Items/Placeables/DraedonStructures/SecurityChest.cs index 6c8cf6e194..6c89a47b10 100644 --- a/Items/Placeables/DraedonStructures/SecurityChest.cs +++ b/Items/Placeables/DraedonStructures/SecurityChest.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.DraedonStructures; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FloralParadise/AlgalSlateItem.cs b/Items/Placeables/FloralParadise/AlgalSlateItem.cs deleted file mode 100644 index e0673c2ca8..0000000000 --- a/Items/Placeables/FloralParadise/AlgalSlateItem.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CalamityMod.Tiles.FloralParadise; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FloralParadise -{ - public class AlgalSlateItem : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - } -} diff --git a/Items/Placeables/FloralParadise/AlgalSlateItem.png b/Items/Placeables/FloralParadise/AlgalSlateItem.png deleted file mode 100644 index a589261603..0000000000 Binary files a/Items/Placeables/FloralParadise/AlgalSlateItem.png and /dev/null differ diff --git a/Items/Placeables/FloralParadise/PeatItem.cs b/Items/Placeables/FloralParadise/PeatItem.cs deleted file mode 100644 index ea762c6b88..0000000000 --- a/Items/Placeables/FloralParadise/PeatItem.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CalamityMod.Tiles.FloralParadise; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FloralParadise -{ - public class PeatItem : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - } -} diff --git a/Items/Placeables/FloralParadise/PeatItem.png b/Items/Placeables/FloralParadise/PeatItem.png deleted file mode 100644 index 2c060a37a8..0000000000 Binary files a/Items/Placeables/FloralParadise/PeatItem.png and /dev/null differ diff --git a/Items/Placeables/FloralParadise/PeatMossItem.cs b/Items/Placeables/FloralParadise/PeatMossItem.cs deleted file mode 100644 index 40acf1915c..0000000000 --- a/Items/Placeables/FloralParadise/PeatMossItem.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CalamityMod.Tiles.FloralParadise; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FloralParadise -{ - public class PeatMossItem : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - } -} diff --git a/Items/Placeables/FloralParadise/PeatMossItem.png b/Items/Placeables/FloralParadise/PeatMossItem.png deleted file mode 100644 index e7b019ef74..0000000000 Binary files a/Items/Placeables/FloralParadise/PeatMossItem.png and /dev/null differ diff --git a/Items/Placeables/FloralParadise/ScintillatingBloom.cs b/Items/Placeables/FloralParadise/ScintillatingBloom.cs deleted file mode 100644 index 51516aaee2..0000000000 --- a/Items/Placeables/FloralParadise/ScintillatingBloom.cs +++ /dev/null @@ -1,19 +0,0 @@ -using CalamityMod.Tiles.FloralParadise; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FloralParadise -{ - public class ScintillatingBloom : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - } -} diff --git a/Items/Placeables/FloralParadise/ScintillatingBloom.png b/Items/Placeables/FloralParadise/ScintillatingBloom.png deleted file mode 100644 index 12b82912c8..0000000000 Binary files a/Items/Placeables/FloralParadise/ScintillatingBloom.png and /dev/null differ diff --git a/Items/Placeables/Furniture/AbyssTreasureChest.cs b/Items/Placeables/Furniture/AbyssTreasureChest.cs index 05068c4abf..59fd1202f6 100644 --- a/Items/Placeables/Furniture/AbyssTreasureChest.cs +++ b/Items/Placeables/Furniture/AbyssTreasureChest.cs @@ -1,7 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Abyss; -using Terraria; -using Terraria.ID; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture diff --git a/Items/Placeables/Furniture/AstralBeaconItem.cs b/Items/Placeables/Furniture/AstralBeaconItem.cs index 97e7a66d44..0d65f56b47 100644 --- a/Items/Placeables/Furniture/AstralBeaconItem.cs +++ b/Items/Placeables/Furniture/AstralBeaconItem.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Astral; using CalamityMod.Items.Potions; using CalamityMod.Tiles.Astral; using Terraria; @@ -24,7 +23,7 @@ namespace CalamityMod.Items.Placeables.Furniture AddIngredient(5). AddIngredient(20). AddIngredient(30). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/Furniture/AstralChest.cs b/Items/Placeables/Furniture/AstralChest.cs index 7355cbe01e..f5926c1529 100644 --- a/Items/Placeables/Furniture/AstralChest.cs +++ b/Items/Placeables/Furniture/AstralChest.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Astral; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture diff --git a/Items/Placeables/Furniture/CausticTorch.cs b/Items/Placeables/Furniture/CausticTorch.cs new file mode 100644 index 0000000000..4eabfcb52e --- /dev/null +++ b/Items/Placeables/Furniture/CausticTorch.cs @@ -0,0 +1,49 @@ +using CalamityMod.Items.Placeables.Abyss; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Furniture +{ + public class CausticTorch : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.Torches[Type] = true; + ItemID.Sets.SingleUseInGamepad[Type] = true; + ItemID.Sets.WaterTorches[Type] = true; + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.ShimmerTorch; + } + + public override void SetDefaults() + { + Item.DefaultToTorch(ModContent.TileType(), 0, true); + } + + public override void HoldItem(Player player) + { + if (Main.rand.NextBool(player.itemAnimation > 0 ? 10 : 20)) + { + Dust.NewDust(new Vector2(player.itemLocation.X + 16f * player.direction, player.itemLocation.Y - 14f * player.gravDir), 4, 4, DustID.t_LivingWood); + } + Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true); + Lighting.AddLight(position, 1f, 1.35f, 0.3f); + } + + public override void PostUpdate() + { + Lighting.AddLight((int)((Item.position.X + Item.width / 2) / 16f), (int)((Item.position.Y + Item.height / 2) / 16f), 1f, 1.35f, 0.3f); + } + + public override void AddRecipes() + { + CreateRecipe(3). + AddIngredient(ItemID.Torch, 3). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CausticTorch.png b/Items/Placeables/Furniture/CausticTorch.png new file mode 100644 index 0000000000..55354c16ad Binary files /dev/null and b/Items/Placeables/Furniture/CausticTorch.png differ diff --git a/Items/Placeables/Furniture/CausticTorch_Flame.png b/Items/Placeables/Furniture/CausticTorch_Flame.png new file mode 100644 index 0000000000..0f5b254659 Binary files /dev/null and b/Items/Placeables/Furniture/CausticTorch_Flame.png differ diff --git a/Items/Placeables/Furniture/CirrusCouch.cs b/Items/Placeables/Furniture/CirrusCouch.cs deleted file mode 100644 index c2b66c79ed..0000000000 --- a/Items/Placeables/Furniture/CirrusCouch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.Furniture -{ - public class CirrusCouch : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 2, silver: 50); - } - } -} diff --git a/Items/Placeables/Furniture/CirrusCouch.png b/Items/Placeables/Furniture/CirrusCouch.png deleted file mode 100644 index 3d0e1a4ba3..0000000000 Binary files a/Items/Placeables/Furniture/CirrusCouch.png and /dev/null differ diff --git a/Items/Placeables/Furniture/CorruptionEffigy.cs b/Items/Placeables/Furniture/CorruptionEffigy.cs index a658682879..f4518459b6 100644 --- a/Items/Placeables/Furniture/CorruptionEffigy.cs +++ b/Items/Placeables/Furniture/CorruptionEffigy.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs b/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs index 2c39b76899..02e98bce76 100644 --- a/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs +++ b/Items/Placeables/Furniture/CraftingStations/AltarOfTheAccursedItem.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 40); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -30,7 +30,8 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations AddIngredient(30). AddIngredient(5). AddIngredient(). - AddTile(). + //Not Cosmic Anvil so if people *really* want do do Scal pre-moon lord it is possible. + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Placeables/Furniture/CraftingStations/AncientAltar.cs b/Items/Placeables/Furniture/CraftingStations/AncientAltar.cs deleted file mode 100644 index 5af066ec73..0000000000 --- a/Items/Placeables/Furniture/CraftingStations/AncientAltar.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Crags; -using CalamityMod.Items.Placeables.Ores; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.Furniture.CraftingStations -{ - public class AncientAltar : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.CraftingObjects; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddIngredient(5). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs b/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs index f59ea00466..b745ef6630 100644 --- a/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs +++ b/Items/Placeables/Furniture/CraftingStations/AshenAltar.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Crags; +using CalamityMod.Items.Placeables.Crags; using CalamityMod.Items.Placeables.FurnitureAshen; using Terraria; using Terraria.ID; diff --git a/Items/Placeables/Furniture/CraftingStations/BotanicPlanter.cs b/Items/Placeables/Furniture/CraftingStations/BotanicPlanter.cs deleted file mode 100644 index 63ab5d8089..0000000000 --- a/Items/Placeables/Furniture/CraftingStations/BotanicPlanter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.Furniture.CraftingStations -{ - public class BotanicPlanter : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.CraftingObjects; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(20). - AddIngredient(ItemID.JungleSpores, 5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Placeables/Furniture/CraftingStations/CosmicAnvilItem.cs b/Items/Placeables/Furniture/CraftingStations/CosmicAnvilItem.cs index 585d31e782..55da90cc1e 100644 --- a/Items/Placeables/Furniture/CraftingStations/CosmicAnvilItem.cs +++ b/Items/Placeables/Furniture/CraftingStations/CosmicAnvilItem.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 60); - Item.rare = ModContent.RarityType(); + Item.value = Item.sellPrice(gold: 50); + Item.rare = ModContent.RarityType(); } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) diff --git a/Items/Placeables/Furniture/CraftingStations/DraedonsForge.cs b/Items/Placeables/Furniture/CraftingStations/DraedonsForge.cs index 8f6217f917..6c812e8cfd 100644 --- a/Items/Placeables/Furniture/CraftingStations/DraedonsForge.cs +++ b/Items/Placeables/Furniture/CraftingStations/DraedonsForge.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(platinum: 4); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations AddIngredient(ItemID.LunarCraftingStation). AddIngredient(15). AddIngredient(12). - AddIngredient(25). + AddIngredient(15). Register(); } } diff --git a/Items/Placeables/Furniture/CraftingStations/EffulgentManipulator.cs b/Items/Placeables/Furniture/CraftingStations/EffulgentManipulator.cs deleted file mode 100644 index da3038d601..0000000000 --- a/Items/Placeables/Furniture/CraftingStations/EffulgentManipulator.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CalamityMod.Items.Placeables.FurnitureSilva; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.Furniture.CraftingStations -{ - [LegacyName("SilvaBasin")] - public class EffulgentManipulator : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.CraftingObjects; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddRecipeGroup("AnyGoldBar", 5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.cs b/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.cs deleted file mode 100644 index b403fe488c..0000000000 --- a/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.cs +++ /dev/null @@ -1,35 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.Furniture.CraftingStations -{ - [LegacyName("EutrophicCrafting")] - public class EutrophicShelf : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 50); // This is too easy to craft to sell for 2 gold - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.CraftingObjects; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddIngredient(5). - AddIngredient(5). - AddIngredient(3). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Placeables/Furniture/CraftingStations/MonolithAmalgam.cs b/Items/Placeables/Furniture/CraftingStations/MonolithAmalgam.cs deleted file mode 100644 index 1f3116f9b6..0000000000 --- a/Items/Placeables/Furniture/CraftingStations/MonolithAmalgam.cs +++ /dev/null @@ -1,30 +0,0 @@ -using CalamityMod.Items.Placeables.Astral; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.Furniture.CraftingStations -{ - [LegacyName("MonolithCrafting")] - public class MonolithAmalgam : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.CraftingObjects; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(20). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Placeables/Furniture/CraftingStations/PlagueInfuser.cs b/Items/Placeables/Furniture/CraftingStations/PlagueInfuser.cs index 016e210fb8..8fb585473e 100644 --- a/Items/Placeables/Furniture/CraftingStations/PlagueInfuser.cs +++ b/Items/Placeables/Furniture/CraftingStations/PlagueInfuser.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations public override void AddRecipes() { CreateRecipe(). - AddRecipeGroup("IronBar", 10). AddIngredient(20). + AddIngredient(6). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Placeables/Furniture/CraftingStations/ProfanedCrucible.cs b/Items/Placeables/Furniture/CraftingStations/ProfanedCrucible.cs index 67c0ddf555..dc9fb777f9 100644 --- a/Items/Placeables/Furniture/CraftingStations/ProfanedCrucible.cs +++ b/Items/Placeables/Furniture/CraftingStations/ProfanedCrucible.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Placeables.Furniture.CraftingStations CreateRecipe(). AddIngredient(10). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Placeables/Furniture/CraftingStations/StaticRefiner.cs b/Items/Placeables/Furniture/CraftingStations/StaticRefiner.cs deleted file mode 100644 index 105adef50b..0000000000 --- a/Items/Placeables/Furniture/CraftingStations/StaticRefiner.cs +++ /dev/null @@ -1,30 +0,0 @@ -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.Furniture.CraftingStations -{ - public class StaticRefiner : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.CraftingObjects; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.Solidifier). - AddIngredient(5). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Placeables/Furniture/CraftingStations/WulfrumLabstationItem.cs b/Items/Placeables/Furniture/CraftingStations/WulfrumLabstationItem.cs deleted file mode 100644 index 5f1ebc1011..0000000000 --- a/Items/Placeables/Furniture/CraftingStations/WulfrumLabstationItem.cs +++ /dev/null @@ -1,29 +0,0 @@ -using CalamityMod.Items.Placeables.FurnitureWulfrum; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.Furniture.CraftingStations -{ - public class WulfrumLabstationItem : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 1); // This is REALLY too easy to craft to sell for 2 gold - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.CraftingObjects; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(20). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Placeables/Furniture/CrimsonEffigy.cs b/Items/Placeables/Furniture/CrimsonEffigy.cs index 4d1633714f..3a69a53431 100644 --- a/Items/Placeables/Furniture/CrimsonEffigy.cs +++ b/Items/Placeables/Furniture/CrimsonEffigy.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.png b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.png deleted file mode 100644 index 87e86d9bcb..0000000000 Binary files a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.png and /dev/null differ diff --git a/Items/Placeables/Furniture/GloomTorch.cs b/Items/Placeables/Furniture/GloomTorch.cs index 04c3af2328..7d1e2624c3 100644 --- a/Items/Placeables/Furniture/GloomTorch.cs +++ b/Items/Placeables/Furniture/GloomTorch.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Placeables.Furniture Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true); if (!killTorch) - Lighting.AddLight(position, 0.9f, 1.2f, 0.3f); + Lighting.AddLight(position, 0.5f, 0.75f, 1.2f); } public override void PostUpdate() diff --git a/Items/Placeables/Furniture/KelpTorch.cs b/Items/Placeables/Furniture/KelpTorch.cs new file mode 100644 index 0000000000..6fb44176f5 --- /dev/null +++ b/Items/Placeables/Furniture/KelpTorch.cs @@ -0,0 +1,49 @@ +using CalamityMod.Items.Placeables.Abyss; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Furniture +{ + public class KelpTorch : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.Torches[Type] = true; + ItemID.Sets.SingleUseInGamepad[Type] = true; + ItemID.Sets.WaterTorches[Type] = true; + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.ShimmerTorch; + } + + public override void SetDefaults() + { + Item.DefaultToTorch(ModContent.TileType(), 0, true); + } + + public override void HoldItem(Player player) + { + if (Main.rand.NextBool(player.itemAnimation > 0 ? 10 : 20)) + { + Dust.NewDust(new Vector2(player.itemLocation.X + 16f * player.direction, player.itemLocation.Y - 14f * player.gravDir), 4, 4, DustID.Sunflower); + } + Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true); + Lighting.AddLight(position, 1.5f, 1.35f, 0.3f); + } + + public override void PostUpdate() + { + Lighting.AddLight((int)((Item.position.X + Item.width / 2) / 16f), (int)((Item.position.Y + Item.height / 2) / 16f), 1.5f, 1.35f, 0.3f); + } + + public override void AddRecipes() + { + CreateRecipe(3). + AddIngredient(ItemID.Torch, 3). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/KelpTorch.png b/Items/Placeables/Furniture/KelpTorch.png new file mode 100644 index 0000000000..46deffc2ca Binary files /dev/null and b/Items/Placeables/Furniture/KelpTorch.png differ diff --git a/Items/Placeables/Furniture/KelpTorch_Flame.png b/Items/Placeables/Furniture/KelpTorch_Flame.png new file mode 100644 index 0000000000..7c58581149 Binary files /dev/null and b/Items/Placeables/Furniture/KelpTorch_Flame.png differ diff --git a/Items/Placeables/Furniture/Monoliths/AstralProjector.cs b/Items/Placeables/Furniture/Monoliths/AstralProjector.cs index 7029bff471..b36d59a964 100644 --- a/Items/Placeables/Furniture/Monoliths/AstralProjector.cs +++ b/Items/Placeables/Furniture/Monoliths/AstralProjector.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using CalamityMod.Tiles.Furniture.Monoliths; using Terraria; using Terraria.ID; diff --git a/Items/Placeables/Furniture/Monoliths/BlueDistortedMonolith.cs b/Items/Placeables/Furniture/Monoliths/BlueDistortedMonolith.cs index 62d4f385a0..ad6896a6d3 100644 --- a/Items/Placeables/Furniture/Monoliths/BlueDistortedMonolith.cs +++ b/Items/Placeables/Furniture/Monoliths/BlueDistortedMonolith.cs @@ -3,7 +3,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.Furniture.Monoliths; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture.Monoliths { @@ -13,8 +12,8 @@ namespace CalamityMod.Items.Placeables.Furniture.Monoliths public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 45); - Item.rare = ModContent.RarityType(); + Item.value = Item.sellPrice(gold: 30); + Item.rare = ModContent.RarityType(); Item.accessory = true; Item.vanity = true; } diff --git a/Items/Placeables/Furniture/Monoliths/BossRushMonolith.cs b/Items/Placeables/Furniture/Monoliths/BossRushMonolith.cs index daabf04afb..c2aec8391a 100644 --- a/Items/Placeables/Furniture/Monoliths/BossRushMonolith.cs +++ b/Items/Placeables/Furniture/Monoliths/BossRushMonolith.cs @@ -1,7 +1,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.Monoliths; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture.Monoliths { diff --git a/Items/Placeables/Furniture/Monoliths/DraconicIncense.cs b/Items/Placeables/Furniture/Monoliths/DraconicIncense.cs index ece5bf1f44..57b1c4a78e 100644 --- a/Items/Placeables/Furniture/Monoliths/DraconicIncense.cs +++ b/Items/Placeables/Furniture/Monoliths/DraconicIncense.cs @@ -3,7 +3,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.Furniture.Monoliths; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture.Monoliths { @@ -14,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Furniture.Monoliths { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 75); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.accessory = true; Item.vanity = true; } diff --git a/Items/Placeables/Furniture/Monoliths/ExoObelisk.cs b/Items/Placeables/Furniture/Monoliths/ExoObelisk.cs index f06a7b6e33..1052ae2e79 100644 --- a/Items/Placeables/Furniture/Monoliths/ExoObelisk.cs +++ b/Items/Placeables/Furniture/Monoliths/ExoObelisk.cs @@ -3,7 +3,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.Furniture.Monoliths; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture.Monoliths { @@ -14,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Furniture.Monoliths { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 1); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.accessory = true; Item.vanity = true; } diff --git a/Items/Placeables/Furniture/Monoliths/OldDukeMonolith.cs b/Items/Placeables/Furniture/Monoliths/OldDukeMonolith.cs new file mode 100644 index 0000000000..4d3d7874cd --- /dev/null +++ b/Items/Placeables/Furniture/Monoliths/OldDukeMonolith.cs @@ -0,0 +1,35 @@ +using CalamityMod.ForegroundDrawing.LoopingTextures; +using CalamityMod.Tiles.Furniture.Monoliths; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.Furniture.Monoliths +{ + public class OldDukeMonolith : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.buyPrice(gold: 25); // Sold by Archmage + Item.rare = ItemRarityID.Pink; + Item.accessory = true; + Item.vanity = true; + } + + public override void UpdateEquip(Player player) + { + if (player.whoAmI == Main.myPlayer) + { + player.GetModPlayer().ShouldDisplayTorrentMonolith = true; + } + } + public override void UpdateVanity(Player player) + { + if (player.whoAmI == Main.myPlayer) + { + player.GetModPlayer().ShouldDisplayTorrentMonolith = true; + } + } + } +} diff --git a/Items/Placeables/Furniture/Monoliths/OldDukeMonolith.png b/Items/Placeables/Furniture/Monoliths/OldDukeMonolith.png new file mode 100644 index 0000000000..8d4672a17e Binary files /dev/null and b/Items/Placeables/Furniture/Monoliths/OldDukeMonolith.png differ diff --git a/Items/Placeables/Furniture/Monoliths/PlagueHumidifier.cs b/Items/Placeables/Furniture/Monoliths/PlagueHumidifier.cs index 2fc5f5d879..a6d4860134 100644 --- a/Items/Placeables/Furniture/Monoliths/PlagueHumidifier.cs +++ b/Items/Placeables/Furniture/Monoliths/PlagueHumidifier.cs @@ -1,6 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.Furniture.Monoliths; using Terraria; using Terraria.ID; diff --git a/Items/Placeables/Furniture/Monoliths/PurpleDistortedMonolith.cs b/Items/Placeables/Furniture/Monoliths/PurpleDistortedMonolith.cs index c5b5d93424..ef0113537c 100644 --- a/Items/Placeables/Furniture/Monoliths/PurpleDistortedMonolith.cs +++ b/Items/Placeables/Furniture/Monoliths/PurpleDistortedMonolith.cs @@ -3,7 +3,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.Furniture.Monoliths; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture.Monoliths { @@ -13,8 +12,8 @@ namespace CalamityMod.Items.Placeables.Furniture.Monoliths public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 45); - Item.rare = ModContent.RarityType(); + Item.value = Item.sellPrice(gold: 30); + Item.rare = ModContent.RarityType(); Item.accessory = true; Item.vanity = true; } diff --git a/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs b/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs new file mode 100644 index 0000000000..e0225466c7 --- /dev/null +++ b/Items/Placeables/Furniture/Paintings/AmidiasPainting.cs @@ -0,0 +1,19 @@ +using CalamityMod.Tiles.Furniture.Paintings; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Furniture.Paintings +{ + public class AmidiasPainting : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.width = 52; + Item.height = 34; + Item.value = Item.buyPrice(gold: 1); + } + } +} diff --git a/Items/Placeables/Furniture/Paintings/AmidiasPainting.png b/Items/Placeables/Furniture/Paintings/AmidiasPainting.png new file mode 100644 index 0000000000..2d555e093f Binary files /dev/null and b/Items/Placeables/Furniture/Paintings/AmidiasPainting.png differ diff --git a/Items/Placeables/Furniture/CalamityCanvas.png b/Items/Placeables/Furniture/Paintings/CalamityCanvas.png similarity index 100% rename from Items/Placeables/Furniture/CalamityCanvas.png rename to Items/Placeables/Furniture/Paintings/CalamityCanvas.png diff --git a/Items/Placeables/Furniture/CalamityCanvas2023.cs b/Items/Placeables/Furniture/Paintings/CalamityCanvas2023.cs similarity index 77% rename from Items/Placeables/Furniture/CalamityCanvas2023.cs rename to Items/Placeables/Furniture/Paintings/CalamityCanvas2023.cs index 5c9b994545..4fd06a5b87 100644 --- a/Items/Placeables/Furniture/CalamityCanvas2023.cs +++ b/Items/Placeables/Furniture/Paintings/CalamityCanvas2023.cs @@ -1,13 +1,13 @@ -using CalamityMod.Tiles.Furniture; +using CalamityMod.Tiles.Furniture.Paintings; using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.Furniture +namespace CalamityMod.Items.Placeables.Furniture.Paintings { public class CalamityCanvas2023 : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Placeables"; - public override string Texture => "CalamityMod/Items/Placeables/Furniture/CalamityCanvas"; + public override string Texture => "CalamityMod/Items/Placeables/Furniture/Paintings/CalamityCanvas"; public override void SetDefaults() { diff --git a/Items/Placeables/Furniture/CalamityCanvas2024.cs b/Items/Placeables/Furniture/Paintings/CalamityCanvas2024.cs similarity index 77% rename from Items/Placeables/Furniture/CalamityCanvas2024.cs rename to Items/Placeables/Furniture/Paintings/CalamityCanvas2024.cs index 8174002573..6d6428c3a6 100644 --- a/Items/Placeables/Furniture/CalamityCanvas2024.cs +++ b/Items/Placeables/Furniture/Paintings/CalamityCanvas2024.cs @@ -1,14 +1,14 @@ -using CalamityMod.Tiles.Furniture; +using CalamityMod.Tiles.Furniture.Paintings; using Terraria; using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.Furniture +namespace CalamityMod.Items.Placeables.Furniture.Paintings { public class CalamityCanvas2024 : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Placeables"; - public override string Texture => "CalamityMod/Items/Placeables/Furniture/CalamityCanvas"; + public override string Texture => "CalamityMod/Items/Placeables/Furniture/Paintings/CalamityCanvas"; public override void SetDefaults() { diff --git a/Items/Placeables/Furniture/Paintings/ForgivenessPainting.cs b/Items/Placeables/Furniture/Paintings/ForgivenessPainting.cs new file mode 100644 index 0000000000..1d6c192d94 --- /dev/null +++ b/Items/Placeables/Furniture/Paintings/ForgivenessPainting.cs @@ -0,0 +1,19 @@ +using CalamityMod.Tiles.Furniture.Paintings; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Furniture.Paintings +{ + public class ForgivenessPainting : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.width = 32; + Item.height = 32; + Item.value = Item.buyPrice(gold: 15); + } + } +} diff --git a/Items/Placeables/Furniture/Paintings/ForgivenessPainting.png b/Items/Placeables/Furniture/Paintings/ForgivenessPainting.png new file mode 100644 index 0000000000..a8627f069b Binary files /dev/null and b/Items/Placeables/Furniture/Paintings/ForgivenessPainting.png differ diff --git a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs b/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs similarity index 91% rename from Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs rename to Items/Placeables/Furniture/Paintings/ThankYouPainting.cs index 0969ede8cc..dc9d66908a 100644 --- a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs +++ b/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.Linq; -using CalamityMod.Tiles.Furniture.DevPaintings; +using CalamityMod.Tiles.Furniture.Paintings; using Terraria; -using Terraria.ID; using Terraria.ModLoader; -using static Microsoft.Xna.Framework.Input.Keys; -namespace CalamityMod.Items.Placeables.Furniture.DevPaintings +namespace CalamityMod.Items.Placeables.Furniture.Paintings { public class ThankYouPainting : ModItem, ILocalizedModType { @@ -24,7 +22,7 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings public override void ModifyTooltips(List tooltips) { - if (!Main.keyState.IsKeyDown(LeftShift)) + if (!Main.keyState.PressingShift()) return; string tooltip = ""; @@ -51,13 +49,12 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings public static IList devList = new List() { - "Fabsol, the mod's founder and owner", // Fabsol gets a line to himself - "Altix", - "Angel", + "Altixal", "apotofkoolaid", - "AquaSG", "Atalya", "Ben-TK", + "Big E", + "CDMusic", "Cei", "CongratsIsTrash", "Cooper", @@ -65,33 +62,28 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "CrabBar", "Dandy", "Dia", + "Done", "dozezoze", - "enamoured", "ENNWAY", "Flowaria", "Fluffy", + "fryzahh", "HaguriHat", - "Heart Plus Up!", - "Hugekraken", - "Lilac Olligoci", + "jasper", "LordMetarex", - "Memes", - "Mercutio 'Merkalto' Takle", - "Mishiro Usui", + "math2", "Moonburn", - "Nycro", "Ozzatron", "Piky", "PokerFace", - "Poroboros", "Raesh", - "Shade", - "SharZz", - "Shayy", - "Spider Prov", + "Sagittariod", "StipulateVenus", + "Sunny", + "_tofu", + "Tomat", "Triangle", - "Uncle Danny", + "TYESKI (Universe)", "Xyk", "YuH", // Former devs @@ -102,13 +94,13 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "Alphi", "Altalyra", "Amadis", + "AquaSG", "AstroKnight", "Blast", "Blastitle", "Blockaroz", "Boffin", "Bravioli", - "CDMusic", "Chetto", "Chill Dude", "Cobalion", @@ -116,14 +108,15 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "DarkTiny", "Demik", "DM Dokuro", - "Done", "Doog", "drh", "dwshin", "DylanDoe21", "Earth", "EchoDuck", + "Eddie Spaghetti", "Ein", + "enamoured", "Enreden", "Epsilon", "Fargowilta", @@ -133,7 +126,9 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "GramOfSalt", "Graydee", "Grox the Great", + "Heart Plus Up!", "Hectique", + "Hugekraken", "Huggles", "Ian-1KV", "IbanPlay", @@ -146,25 +141,30 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "L0st", "Leon", "Leviathan", + "Lilac Olligoci", "Lompl Allimath", "Lucille Karma", "MarieArk", + "Mercutio 'Merkalto' Takle", + "Mihaii", "Minecat", + "Mishiro Usui", "Mrrp", "Nao", "Neverglide", "Nincity", "Niorin", "Nitro", + "Nycro", "NyctoDarkMatter", "PaleoStar", "Pbtopacio", "Phantasmal Deathray", "Phupperbat", "Pinkie Poss", - "pixlgray", "Poly", "Popo", + "Poroboros", "President Waluigi", "Puff", "Purple Necromancer", @@ -172,11 +172,14 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "Runefield", "Sargassum", "sentri", + "Shade", + "SharZz", "Shucks", "Silver-Lord of Ash", "SixteenInMono", "Skeletony", "Sok", + "Spider Prov", "spooktacular", "Spoopyro", "Svante", @@ -186,9 +189,10 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "ThousandFields", "TikiWiki", "Tinymanx", - "Tomat", "Trivaxy", + "Tobias", "Uberransy", + "Uncle Danny", "Vaikyia", "Vladimier", "Yatagarasu", diff --git a/Items/Placeables/Furniture/Paintings/ThankYouPainting.png b/Items/Placeables/Furniture/Paintings/ThankYouPainting.png new file mode 100644 index 0000000000..157df9cb45 Binary files /dev/null and b/Items/Placeables/Furniture/Paintings/ThankYouPainting.png differ diff --git a/Items/Placeables/Furniture/ResilientCandle.cs b/Items/Placeables/Furniture/ResilientCandle.cs index 49ee32a22d..0bb9adab8a 100644 --- a/Items/Placeables/Furniture/ResilientCandle.cs +++ b/Items/Placeables/Furniture/ResilientCandle.cs @@ -16,8 +16,7 @@ namespace CalamityMod.Items.Placeables.Furniture public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 20); + Item.value = Item.buyPrice(gold: 25); // Sold by Wizard Item.rare = ItemRarityID.Pink; } } diff --git a/Items/Placeables/Furniture/RustyChest.cs b/Items/Placeables/Furniture/RustyChest.cs index 7607d96e02..7c58e05514 100644 --- a/Items/Placeables/Furniture/RustyChest.cs +++ b/Items/Placeables/Furniture/RustyChest.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.Abyss; +using CalamityMod.Tiles.Abyss; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/Furniture/SpitefulCandle.cs b/Items/Placeables/Furniture/SpitefulCandle.cs index 8f8eee2c9a..1c6cf59f01 100644 --- a/Items/Placeables/Furniture/SpitefulCandle.cs +++ b/Items/Placeables/Furniture/SpitefulCandle.cs @@ -16,8 +16,7 @@ namespace CalamityMod.Items.Placeables.Furniture public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 20); + Item.value = Item.buyPrice(gold: 25); // Sold by Wizard Item.rare = ItemRarityID.Pink; } } diff --git a/Items/Placeables/Furniture/SunkenIdol.cs b/Items/Placeables/Furniture/SunkenIdol.cs index 0fe4362991..9b04d0b7a8 100644 --- a/Items/Placeables/Furniture/SunkenIdol.cs +++ b/Items/Placeables/Furniture/SunkenIdol.cs @@ -1,5 +1,4 @@ using CalamityMod.Tiles.Furniture; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture diff --git a/Items/Placeables/Furniture/ThaumaticChair.cs b/Items/Placeables/Furniture/ThaumaticChair.cs index c5934ebc44..e1b69e7f27 100644 --- a/Items/Placeables/Furniture/ThaumaticChair.cs +++ b/Items/Placeables/Furniture/ThaumaticChair.cs @@ -5,7 +5,7 @@ using CalamityMod.Items.Placeables.FurnitureAncient; using CalamityMod.Items.Placeables.FurnitureAshen; using CalamityMod.Items.Placeables.FurnitureBotanic; using CalamityMod.Items.Placeables.FurnitureCosmilite; -using CalamityMod.Items.Placeables.FurnitureEutrophic; +using CalamityMod.Items.Placeables.FurnitureNavystone; using CalamityMod.Items.Placeables.FurnitureExo; using CalamityMod.Items.Placeables.FurnitureMarnite; using CalamityMod.Items.Placeables.FurnitureMonolith; @@ -22,7 +22,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.Furniture @@ -34,7 +33,7 @@ namespace CalamityMod.Items.Placeables.Furniture { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 10); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } @@ -47,7 +46,7 @@ namespace CalamityMod.Items.Placeables.Furniture AddIngredient(). AddIngredient(). AddIngredient(). - AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(). AddIngredient(). diff --git a/Items/Placeables/Furniture/ThermalTorch.cs b/Items/Placeables/Furniture/ThermalTorch.cs new file mode 100644 index 0000000000..5921c6547b --- /dev/null +++ b/Items/Placeables/Furniture/ThermalTorch.cs @@ -0,0 +1,49 @@ +using CalamityMod.Items.Placeables.Abyss; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Furniture +{ + public class ThermalTorch : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.Torches[Type] = true; + ItemID.Sets.SingleUseInGamepad[Type] = true; + ItemID.Sets.WaterTorches[Type] = true; + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.ShimmerTorch; + } + + public override void SetDefaults() + { + Item.DefaultToTorch(ModContent.TileType(), 0, true); + } + + public override void HoldItem(Player player) + { + if (Main.rand.NextBool(player.itemAnimation > 0 ? 10 : 20)) + { + Dust.NewDust(new Vector2(player.itemLocation.X + 16f * player.direction, player.itemLocation.Y - 14f * player.gravDir), 4, 4, DustID.DynastyShingle_Red); + } + Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true); + Lighting.AddLight(position, 1.8f, 0f, 0f); + } + + public override void PostUpdate() + { + Lighting.AddLight((int)((Item.position.X + Item.width / 2) / 16f), (int)((Item.position.Y + Item.height / 2) / 16f), 1.8f, 0f, 0f); + } + + public override void AddRecipes() + { + CreateRecipe(3). + AddIngredient(ItemID.Torch, 3). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/ThermalTorch.png b/Items/Placeables/Furniture/ThermalTorch.png new file mode 100644 index 0000000000..96ee455c8f Binary files /dev/null and b/Items/Placeables/Furniture/ThermalTorch.png differ diff --git a/Items/Placeables/Furniture/ThermalTorch_Flame.png b/Items/Placeables/Furniture/ThermalTorch_Flame.png new file mode 100644 index 0000000000..48f4aec2c9 Binary files /dev/null and b/Items/Placeables/Furniture/ThermalTorch_Flame.png differ diff --git a/Items/Placeables/Furniture/VigorousCandle.cs b/Items/Placeables/Furniture/VigorousCandle.cs index 8d8408d64d..e203002839 100644 --- a/Items/Placeables/Furniture/VigorousCandle.cs +++ b/Items/Placeables/Furniture/VigorousCandle.cs @@ -16,8 +16,7 @@ namespace CalamityMod.Items.Placeables.Furniture public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 20); + Item.value = Item.buyPrice(gold: 25); // Sold by Wizard Item.rare = ItemRarityID.Pink; } } diff --git a/Items/Placeables/Furniture/VoidTorch.cs b/Items/Placeables/Furniture/VoidTorch.cs new file mode 100644 index 0000000000..a51c3c983c --- /dev/null +++ b/Items/Placeables/Furniture/VoidTorch.cs @@ -0,0 +1,50 @@ +using CalamityMod.Items.Placeables.Abyss; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.Furniture +{ + [LegacyName("AbyssTorch")] + public class VoidTorch : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.Torches[Type] = true; + ItemID.Sets.SingleUseInGamepad[Type] = true; + ItemID.Sets.WaterTorches[Type] = true; + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.ShimmerTorch; + } + + public override void SetDefaults() + { + Item.DefaultToTorch(ModContent.TileType(), 0, true); + } + + public override void HoldItem(Player player) + { + if (Main.rand.NextBool(player.itemAnimation > 0 ? 10 : 20)) + { + Dust.NewDust(new Vector2(player.itemLocation.X + 16f * player.direction, player.itemLocation.Y - 14f * player.gravDir), 4, 4, DustID.DungeonSpirit); + } + Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true); + Lighting.AddLight(position, 0.5f, 0.5f, 2f); + } + + public override void PostUpdate() + { + Lighting.AddLight((int)((Item.position.X + Item.width / 2) / 16f), (int)((Item.position.Y + Item.height / 2) / 16f), 0.5f, 0.5f, 2f); + } + + public override void AddRecipes() + { + CreateRecipe(3). + AddIngredient(ItemID.Torch, 3). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureAbyss/AbyssTorch.png b/Items/Placeables/Furniture/VoidTorch.png similarity index 100% rename from Items/Placeables/FurnitureAbyss/AbyssTorch.png rename to Items/Placeables/Furniture/VoidTorch.png diff --git a/Items/Placeables/FurnitureAbyss/AbyssTorch_Flame.png b/Items/Placeables/Furniture/VoidTorch_Flame.png similarity index 100% rename from Items/Placeables/FurnitureAbyss/AbyssTorch_Flame.png rename to Items/Placeables/Furniture/VoidTorch_Flame.png diff --git a/Items/Placeables/Furniture/WeightlessCandle.cs b/Items/Placeables/Furniture/WeightlessCandle.cs index 7edb2ebd30..834e56cb4d 100644 --- a/Items/Placeables/Furniture/WeightlessCandle.cs +++ b/Items/Placeables/Furniture/WeightlessCandle.cs @@ -18,8 +18,7 @@ namespace CalamityMod.Items.Placeables.Furniture public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 20); + Item.value = Item.buyPrice(gold: 25); // Sold by Wizard Item.rare = ItemRarityID.Pink; } } diff --git a/Items/Placeables/Furniture/WulfrumLureItem.cs b/Items/Placeables/Furniture/WulfrumLureItem.cs index 4d0318c02b..191ac33c77 100644 --- a/Items/Placeables/Furniture/WulfrumLureItem.cs +++ b/Items/Placeables/Furniture/WulfrumLureItem.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture; using Terraria; using Terraria.ID; @@ -27,7 +26,7 @@ namespace CalamityMod.Items.Placeables.Furniture { CreateRecipe(). AddIngredient(5). - AddIngredient(). + AddIngredient(). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Placeables/Furniture/ZenithThrone.cs b/Items/Placeables/Furniture/ZenithThrone.cs index 4f09cfeb9d..cd98471793 100644 --- a/Items/Placeables/Furniture/ZenithThrone.cs +++ b/Items/Placeables/Furniture/ZenithThrone.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Placeables.Furniture { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 10); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Placeables/FurnitureAbyss/AbyssBathtub.cs b/Items/Placeables/FurnitureAbyss/AbyssBathtub.cs index 746d0e297e..4614f9935c 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssBathtub.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssBathtub.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss diff --git a/Items/Placeables/FurnitureAbyss/AbyssChair.cs b/Items/Placeables/FurnitureAbyss/AbyssChair.cs index 041a8b3ff4..924beb1170 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssChair.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssChair.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss diff --git a/Items/Placeables/FurnitureAbyss/AbyssChest.cs b/Items/Placeables/FurnitureAbyss/AbyssChest.cs index 1450ae8b25..59c63f8be4 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssChest.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssChest.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss { diff --git a/Items/Placeables/FurnitureAbyss/AbyssDoor.cs b/Items/Placeables/FurnitureAbyss/AbyssDoor.cs index 45da43cc3c..71ae63a2ad 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssDoor.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAbyss; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss diff --git a/Items/Placeables/FurnitureAbyss/AbyssDresser.cs b/Items/Placeables/FurnitureAbyss/AbyssDresser.cs index 87b4e8646d..2f6afa0495 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssDresser.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssDresser.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss diff --git a/Items/Placeables/FurnitureAbyss/AbyssTable.cs b/Items/Placeables/FurnitureAbyss/AbyssTable.cs index ad44758ca9..a48a2d50ad 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssTable.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssTable.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss diff --git a/Items/Placeables/FurnitureAbyss/AbyssTorch.cs b/Items/Placeables/FurnitureAbyss/AbyssTorch.cs deleted file mode 100644 index b30c3a0747..0000000000 --- a/Items/Placeables/FurnitureAbyss/AbyssTorch.cs +++ /dev/null @@ -1,50 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureAbyss -{ - public class AbyssTorch : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - ItemID.Sets.Torches[Type] = true; - ItemID.Sets.SingleUseInGamepad[Type] = true; - ItemID.Sets.WaterTorches[Type] = true; - ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.ShimmerTorch; - } - - public override void SetDefaults() - { - Item.DefaultToTorch(ModContent.TileType(), 0, true); - } - - public override void HoldItem(Player player) - { - if (Main.rand.NextBool(player.itemAnimation > 0 ? 10 : 20)) - { - Dust.NewDust(new Vector2(player.itemLocation.X + 16f * player.direction, player.itemLocation.Y - 14f * player.gravDir), 4, 4, DustID.DungeonSpirit); - } - Vector2 position = player.RotatedRelativePoint(new Vector2(player.itemLocation.X + 12f * player.direction + player.velocity.X, player.itemLocation.Y - 14f + player.velocity.Y), true); - Lighting.AddLight(position, 0.5f, 0.5f, 2f); - } - - public override void PostUpdate() - { - Lighting.AddLight((int)((Item.position.X + Item.width / 2) / 16f), (int)((Item.position.Y + Item.height / 2) / 16f), 0.5f, 0.5f, 2f); - } - - public override void AddRecipes() - { - CreateRecipe(3). - AddIngredient(ItemID.Torch, 3). - AddIngredient(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureAbyss/AbyssWorkBench.cs b/Items/Placeables/FurnitureAbyss/AbyssWorkBench.cs index 6c9d3f0cc4..f0a2f86973 100644 --- a/Items/Placeables/FurnitureAbyss/AbyssWorkBench.cs +++ b/Items/Placeables/FurnitureAbyss/AbyssWorkBench.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss diff --git a/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs b/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs index 68783747b7..9664e4b9bd 100644 --- a/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs +++ b/Items/Placeables/FurnitureAbyss/SmoothAbyssGravelPlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAbyss { public class SmoothAbyssGravelPlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/Abyss/Acidwood.cs b/Items/Placeables/FurnitureAcidwood/Acidwood.cs similarity index 85% rename from Items/Placeables/Abyss/Acidwood.cs rename to Items/Placeables/FurnitureAcidwood/Acidwood.cs index 629a1cdfe9..fd46f782d0 100644 --- a/Items/Placeables/Abyss/Acidwood.cs +++ b/Items/Placeables/FurnitureAcidwood/Acidwood.cs @@ -1,10 +1,9 @@ -using CalamityMod.Items.Placeables.FurnitureAcidwood; -using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Tiles.Abyss; +using CalamityMod.Items.Placeables.Walls; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Tiles.FurnitureAcidwood; -namespace CalamityMod.Items.Placeables.Abyss +namespace CalamityMod.Items.Placeables.FurnitureAcidwood { public class Acidwood : ModItem, ILocalizedModType { diff --git a/Items/Placeables/Abyss/Acidwood.png b/Items/Placeables/FurnitureAcidwood/Acidwood.png similarity index 100% rename from Items/Placeables/Abyss/Acidwood.png rename to Items/Placeables/FurnitureAcidwood/Acidwood.png diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodBathtub.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodBathtub.cs index f15a5227ee..d0ecf79149 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodBathtub.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodBathtub.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodBed.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodBed.cs index e61ccfb84f..988f10830c 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodBed.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodBed.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodBench.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodBench.cs index 919aea0947..4071330ab4 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodBench.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodBench.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodBookcase.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodBookcase.cs index f2a1521ac5..70eef1c72c 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodBookcase.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodBookcase.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodCandelabra.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodCandelabra.cs index fe4ed8718e..fe86619244 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodCandelabra.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodCandelabra.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodCandle.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodCandle.cs index 300407d9b5..848ed712dd 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodCandle.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodCandle.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodChair.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodChair.cs index 11fadfcaf1..b2df677185 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodChair.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodChair.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodChandelier.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodChandelier.cs index de95cd8330..d64e7c81d4 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodChandelier.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodChandelier.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodChest.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodChest.cs index 241a06a06d..2f8e9fef6d 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodChest.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodChest.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodClock.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodClock.cs index 02cc1bd896..94878b4a12 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodClock.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodClock.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodDoor.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodDoor.cs index a9720a578f..a021463101 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodDoor.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodDoor.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodDresser.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodDresser.cs index 37c243a570..13ba1a71a7 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodDresser.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodDresser.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodLamp.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodLamp.cs index 66fee6755c..a32a15c207 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodLamp.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodLamp.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodLantern.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodLantern.cs index faab32ce88..c4deb7ec6c 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodLantern.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodLantern.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodPiano.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodPiano.cs index abee7f866a..e8593a2878 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodPiano.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodPiano.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodPlatform.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodPlatform.cs index 82847c538d..daecde097d 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodPlatform.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodPlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; -using Terraria.ID; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAcidwood diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodSink.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodSink.cs index b064681ded..3bb4cc7232 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodSink.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodSink.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodTable.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodTable.cs index 5caef65bd6..ff18d02967 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodTable.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodTable.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureAcidwood/AcidwoodWorkBench.cs b/Items/Placeables/FurnitureAcidwood/AcidwoodWorkBench.cs index cf82ea1060..956f834059 100644 --- a/Items/Placeables/FurnitureAcidwood/AcidwoodWorkBench.cs +++ b/Items/Placeables/FurnitureAcidwood/AcidwoodWorkBench.cs @@ -1,7 +1,5 @@ -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Tiles.FurnitureAcidwood; +using CalamityMod.Tiles.FurnitureAcidwood; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAcidwood { diff --git a/Items/Placeables/FurnitureAncient/AncientAltar.cs b/Items/Placeables/FurnitureAncient/AncientAltar.cs new file mode 100644 index 0000000000..1209703db3 --- /dev/null +++ b/Items/Placeables/FurnitureAncient/AncientAltar.cs @@ -0,0 +1,24 @@ +using CalamityMod.Items.Placeables.Crags; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureAncient +{ + public class AncientAltar : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(gold: 2); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddIngredient(5). + AddTile(ModContent.TileType()). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CraftingStations/AncientAltar.png b/Items/Placeables/FurnitureAncient/AncientAltar.png similarity index 100% rename from Items/Placeables/Furniture/CraftingStations/AncientAltar.png rename to Items/Placeables/FurnitureAncient/AncientAltar.png diff --git a/Items/Placeables/FurnitureAncient/AncientBasin.cs b/Items/Placeables/FurnitureAncient/AncientBasin.cs index 13ce692fbb..03057985c5 100644 --- a/Items/Placeables/FurnitureAncient/AncientBasin.cs +++ b/Items/Placeables/FurnitureAncient/AncientBasin.cs @@ -1,10 +1,6 @@ - -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Crags; -using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Items.Placeables.Crags; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAncient @@ -23,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient CreateRecipe(). AddIngredient(10). AddIngredient(5). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientBathtub.cs b/Items/Placeables/FurnitureAncient/AncientBathtub.cs index 6e4f0a4bf1..e85975926f 100644 --- a/Items/Placeables/FurnitureAncient/AncientBathtub.cs +++ b/Items/Placeables/FurnitureAncient/AncientBathtub.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Crags; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAncient @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient { CreateRecipe(). AddIngredient(14). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientBed.cs b/Items/Placeables/FurnitureAncient/AncientBed.cs index 09a2cc6c59..91b7f8f97f 100644 --- a/Items/Placeables/FurnitureAncient/AncientBed.cs +++ b/Items/Placeables/FurnitureAncient/AncientBed.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientBookcase.cs b/Items/Placeables/FurnitureAncient/AncientBookcase.cs index ff4c9d256c..f68aa1ae4e 100644 --- a/Items/Placeables/FurnitureAncient/AncientBookcase.cs +++ b/Items/Placeables/FurnitureAncient/AncientBookcase.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientChair.cs b/Items/Placeables/FurnitureAncient/AncientChair.cs index 2d72d10df0..b73811e151 100644 --- a/Items/Placeables/FurnitureAncient/AncientChair.cs +++ b/Items/Placeables/FurnitureAncient/AncientChair.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Crags; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAncient @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient { CreateRecipe(). AddIngredient(4). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientChandelier.cs b/Items/Placeables/FurnitureAncient/AncientChandelier.cs index 8868fe6ff2..3c603f551d 100644 --- a/Items/Placeables/FurnitureAncient/AncientChandelier.cs +++ b/Items/Placeables/FurnitureAncient/AncientChandelier.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientDoor.cs b/Items/Placeables/FurnitureAncient/AncientDoor.cs index 6182a586f9..fb52f3c4a7 100644 --- a/Items/Placeables/FurnitureAncient/AncientDoor.cs +++ b/Items/Placeables/FurnitureAncient/AncientDoor.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAncient; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAncient @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient { CreateRecipe(). AddIngredient(6). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientDresser.cs b/Items/Placeables/FurnitureAncient/AncientDresser.cs index 7724410586..54a391f0e4 100644 --- a/Items/Placeables/FurnitureAncient/AncientDresser.cs +++ b/Items/Placeables/FurnitureAncient/AncientDresser.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Crags; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAncient @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient { CreateRecipe(). AddIngredient(16). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientLamp.cs b/Items/Placeables/FurnitureAncient/AncientLamp.cs index ae71b05abc..9f61fda5fe 100644 --- a/Items/Placeables/FurnitureAncient/AncientLamp.cs +++ b/Items/Placeables/FurnitureAncient/AncientLamp.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientLantern.cs b/Items/Placeables/FurnitureAncient/AncientLantern.cs index 6dc360c7b1..74bcc5acfc 100644 --- a/Items/Placeables/FurnitureAncient/AncientLantern.cs +++ b/Items/Placeables/FurnitureAncient/AncientLantern.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientMonolith.cs b/Items/Placeables/FurnitureAncient/AncientMonolith.cs index afa334c193..992edc8224 100644 --- a/Items/Placeables/FurnitureAncient/AncientMonolith.cs +++ b/Items/Placeables/FurnitureAncient/AncientMonolith.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientPipeOrgan.cs b/Items/Placeables/FurnitureAncient/AncientPipeOrgan.cs index 8b31f31ee6..24651e8b78 100644 --- a/Items/Placeables/FurnitureAncient/AncientPipeOrgan.cs +++ b/Items/Placeables/FurnitureAncient/AncientPipeOrgan.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientSink.cs b/Items/Placeables/FurnitureAncient/AncientSink.cs index 5c80b977c8..11d515986b 100644 --- a/Items/Placeables/FurnitureAncient/AncientSink.cs +++ b/Items/Placeables/FurnitureAncient/AncientSink.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.LavaBucket). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientSofa.cs b/Items/Placeables/FurnitureAncient/AncientSofa.cs index 3b3465f326..2cef2b30a7 100644 --- a/Items/Placeables/FurnitureAncient/AncientSofa.cs +++ b/Items/Placeables/FurnitureAncient/AncientSofa.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Silk, 2). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientTable.cs b/Items/Placeables/FurnitureAncient/AncientTable.cs index 84a5e49443..8c44a489f4 100644 --- a/Items/Placeables/FurnitureAncient/AncientTable.cs +++ b/Items/Placeables/FurnitureAncient/AncientTable.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Crags; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAncient @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAncient/AncientWorkBench.cs b/Items/Placeables/FurnitureAncient/AncientWorkBench.cs index feec1ee3dd..cb888df2f6 100644 --- a/Items/Placeables/FurnitureAncient/AncientWorkBench.cs +++ b/Items/Placeables/FurnitureAncient/AncientWorkBench.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Crags; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAncient @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAncient { CreateRecipe(). AddIngredient(10). - AddTile(). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureAshen/AshenAccentSlab.cs b/Items/Placeables/FurnitureAshen/AshenAccentSlab.cs index e397346234..564be3ac74 100644 --- a/Items/Placeables/FurnitureAshen/AshenAccentSlab.cs +++ b/Items/Placeables/FurnitureAshen/AshenAccentSlab.cs @@ -1,8 +1,5 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen { diff --git a/Items/Placeables/FurnitureAshen/AshenBasin.cs b/Items/Placeables/FurnitureAshen/AshenBasin.cs index a2cb5e7ae9..0ee07525f7 100644 --- a/Items/Placeables/FurnitureAshen/AshenBasin.cs +++ b/Items/Placeables/FurnitureAshen/AshenBasin.cs @@ -1,8 +1,6 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Crags; +using CalamityMod.Items.Placeables.Crags; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/AshenBathtub.cs b/Items/Placeables/FurnitureAshen/AshenBathtub.cs index 684e92aa0f..e1c0801ef3 100644 --- a/Items/Placeables/FurnitureAshen/AshenBathtub.cs +++ b/Items/Placeables/FurnitureAshen/AshenBathtub.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/AshenChair.cs b/Items/Placeables/FurnitureAshen/AshenChair.cs index c076c3f706..09dabaaba6 100644 --- a/Items/Placeables/FurnitureAshen/AshenChair.cs +++ b/Items/Placeables/FurnitureAshen/AshenChair.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/AshenChest.cs b/Items/Placeables/FurnitureAshen/AshenChest.cs index b57f465f33..8b9289136b 100644 --- a/Items/Placeables/FurnitureAshen/AshenChest.cs +++ b/Items/Placeables/FurnitureAshen/AshenChest.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen { diff --git a/Items/Placeables/FurnitureAshen/AshenDoor.cs b/Items/Placeables/FurnitureAshen/AshenDoor.cs index 2cbebe0ec9..9a6b3571ef 100644 --- a/Items/Placeables/FurnitureAshen/AshenDoor.cs +++ b/Items/Placeables/FurnitureAshen/AshenDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAshen; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/AshenDresser.cs b/Items/Placeables/FurnitureAshen/AshenDresser.cs index 1de01a7d18..f219a9141e 100644 --- a/Items/Placeables/FurnitureAshen/AshenDresser.cs +++ b/Items/Placeables/FurnitureAshen/AshenDresser.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/AshenPlatform.cs b/Items/Placeables/FurnitureAshen/AshenPlatform.cs index c326b2c714..93e7568cb7 100644 --- a/Items/Placeables/FurnitureAshen/AshenPlatform.cs +++ b/Items/Placeables/FurnitureAshen/AshenPlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen { diff --git a/Items/Placeables/FurnitureAshen/AshenSlab.cs b/Items/Placeables/FurnitureAshen/AshenSlab.cs index b5a18e5c4c..30c48b003a 100644 --- a/Items/Placeables/FurnitureAshen/AshenSlab.cs +++ b/Items/Placeables/FurnitureAshen/AshenSlab.cs @@ -1,7 +1,5 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Walls; +using CalamityMod.Items.Placeables.Walls; using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/AshenTable.cs b/Items/Placeables/FurnitureAshen/AshenTable.cs index ffb10ca242..696736692d 100644 --- a/Items/Placeables/FurnitureAshen/AshenTable.cs +++ b/Items/Placeables/FurnitureAshen/AshenTable.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/AshenWorkBench.cs b/Items/Placeables/FurnitureAshen/AshenWorkBench.cs index 36de02ed3c..f0a8d26636 100644 --- a/Items/Placeables/FurnitureAshen/AshenWorkBench.cs +++ b/Items/Placeables/FurnitureAshen/AshenWorkBench.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAshen/SmoothBrimstoneSlag.cs b/Items/Placeables/FurnitureAshen/SmoothBrimstoneSlag.cs index 8e5965c1f0..b054e8ceb7 100644 --- a/Items/Placeables/FurnitureAshen/SmoothBrimstoneSlag.cs +++ b/Items/Placeables/FurnitureAshen/SmoothBrimstoneSlag.cs @@ -1,7 +1,5 @@ using CalamityMod.Items.Placeables.Crags; using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAshen diff --git a/Items/Placeables/FurnitureAuric/ActivatedAuricPanel.cs b/Items/Placeables/FurnitureAuric/ActivatedAuricPanel.cs index 46a0beec3e..e369079a54 100644 --- a/Items/Placeables/FurnitureAuric/ActivatedAuricPanel.cs +++ b/Items/Placeables/FurnitureAuric/ActivatedAuricPanel.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricAbsorber.cs b/Items/Placeables/FurnitureAuric/AuricAbsorber.cs index 00b972f984..55c2490f55 100644 --- a/Items/Placeables/FurnitureAuric/AuricAbsorber.cs +++ b/Items/Placeables/FurnitureAuric/AuricAbsorber.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricConsole.cs b/Items/Placeables/FurnitureAuric/AuricConsole.cs index 7f55077b37..32c90e735d 100644 --- a/Items/Placeables/FurnitureAuric/AuricConsole.cs +++ b/Items/Placeables/FurnitureAuric/AuricConsole.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricDisplay.cs b/Items/Placeables/FurnitureAuric/AuricDisplay.cs index 6a5f43a2b8..44e0a1b505 100644 --- a/Items/Placeables/FurnitureAuric/AuricDisplay.cs +++ b/Items/Placeables/FurnitureAuric/AuricDisplay.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricLandMine.cs b/Items/Placeables/FurnitureAuric/AuricLandMine.cs index 2b512a453e..eb3c2cd940 100644 --- a/Items/Placeables/FurnitureAuric/AuricLandMine.cs +++ b/Items/Placeables/FurnitureAuric/AuricLandMine.cs @@ -9,10 +9,18 @@ namespace CalamityMod.Items.Placeables.FurnitureAuric public class AuricLandMine : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + // Did you know Land Mines can be placed on Weapon Racks? Yeah, me neither. + ItemID.Sets.CanBePlacedOnWeaponRacks[Type] = true; + } + public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 1); + Item.mech = true; } public override void AddRecipes() diff --git a/Items/Placeables/FurnitureAuric/AuricPanel.cs b/Items/Placeables/FurnitureAuric/AuricPanel.cs index 14261d6144..21fe8d1f03 100644 --- a/Items/Placeables/FurnitureAuric/AuricPanel.cs +++ b/Items/Placeables/FurnitureAuric/AuricPanel.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.Ores; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricPlatform.cs b/Items/Placeables/FurnitureAuric/AuricPlatform.cs index 234940a20e..7a2883e87f 100644 --- a/Items/Placeables/FurnitureAuric/AuricPlatform.cs +++ b/Items/Placeables/FurnitureAuric/AuricPlatform.cs @@ -1,5 +1,4 @@ using CalamityMod.Tiles.FurnitureAuric; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric diff --git a/Items/Placeables/FurnitureAuric/AuricReinforcedCrate.cs b/Items/Placeables/FurnitureAuric/AuricReinforcedCrate.cs index 7834d9ea8c..1f4177c89d 100644 --- a/Items/Placeables/FurnitureAuric/AuricReinforcedCrate.cs +++ b/Items/Placeables/FurnitureAuric/AuricReinforcedCrate.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric diff --git a/Items/Placeables/FurnitureAuric/AuricRepulserPanel.cs b/Items/Placeables/FurnitureAuric/AuricRepulserPanel.cs index fac7b6bb34..0fce615d99 100644 --- a/Items/Placeables/FurnitureAuric/AuricRepulserPanel.cs +++ b/Items/Placeables/FurnitureAuric/AuricRepulserPanel.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricScreen.cs b/Items/Placeables/FurnitureAuric/AuricScreen.cs index dda6a8624f..0257dcca18 100644 --- a/Items/Placeables/FurnitureAuric/AuricScreen.cs +++ b/Items/Placeables/FurnitureAuric/AuricScreen.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricServer.cs b/Items/Placeables/FurnitureAuric/AuricServer.cs index e2e370b72a..9dd2fb3eee 100644 --- a/Items/Placeables/FurnitureAuric/AuricServer.cs +++ b/Items/Placeables/FurnitureAuric/AuricServer.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricTerminal.cs b/Items/Placeables/FurnitureAuric/AuricTerminal.cs index e5b11805f2..4549ff7280 100644 --- a/Items/Placeables/FurnitureAuric/AuricTerminal.cs +++ b/Items/Placeables/FurnitureAuric/AuricTerminal.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureAuric/AuricToilet.cs b/Items/Placeables/FurnitureAuric/AuricToilet.cs index 9e2c3ef59f..0afe2dac0d 100644 --- a/Items/Placeables/FurnitureAuric/AuricToilet.cs +++ b/Items/Placeables/FurnitureAuric/AuricToilet.cs @@ -6,7 +6,6 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureAuric { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 40); - Item.rare = ModContent.RarityType(); // Most special shitter gets most preferential treatment + Item.rare = ModContent.RarityType(); // Most special shitter gets most preferential treatment } public override void AddRecipes() diff --git a/Items/Placeables/FurnitureAuric/ExoAuricPanel.cs b/Items/Placeables/FurnitureAuric/ExoAuricPanel.cs index 29435f297e..107a706f14 100644 --- a/Items/Placeables/FurnitureAuric/ExoAuricPanel.cs +++ b/Items/Placeables/FurnitureAuric/ExoAuricPanel.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureAuric; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureAuric { diff --git a/Items/Placeables/FurnitureBasalt/BasaltSlab.cs b/Items/Placeables/FurnitureBasalt/BasaltSlab.cs new file mode 100644 index 0000000000..3d8c486135 --- /dev/null +++ b/Items/Placeables/FurnitureBasalt/BasaltSlab.cs @@ -0,0 +1,28 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureBasalt +{ + public class BasaltSlab : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(1). + AddTile(TileID.WorkBenches). + DisableDecraft(). + Register(); + } + + } +} diff --git a/Items/Placeables/FurnitureBasalt/BasaltSlab.png b/Items/Placeables/FurnitureBasalt/BasaltSlab.png new file mode 100644 index 0000000000..a40c5e3054 Binary files /dev/null and b/Items/Placeables/FurnitureBasalt/BasaltSlab.png differ diff --git a/Items/Placeables/FurnitureBotanic/BotanicBathtub.cs b/Items/Placeables/FurnitureBotanic/BotanicBathtub.cs index 60c180e58a..1d96384344 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicBathtub.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicBathtub.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic { CreateRecipe(). AddIngredient(14). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicBed.cs b/Items/Placeables/FurnitureBotanic/BotanicBed.cs index 1acb0c3b02..64837600df 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicBed.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicBed.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicBench.cs b/Items/Placeables/FurnitureBotanic/BotanicBench.cs index 466cedef84..3243e7685c 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicBench.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicBench.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicBookcase.cs b/Items/Placeables/FurnitureBotanic/BotanicBookcase.cs index b648886bd6..5df3f6447d 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicBookcase.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicBookcase.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicCandelabra.cs b/Items/Placeables/FurnitureBotanic/BotanicCandelabra.cs index 0e6140697e..9882cb9439 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicCandelabra.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicCandelabra.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Torch, 3). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicCandle.cs b/Items/Placeables/FurnitureBotanic/BotanicCandle.cs index 00abbcf2e1..98f5339b80 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicCandle.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicCandle.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicChair.cs b/Items/Placeables/FurnitureBotanic/BotanicChair.cs index b09dc4e440..2fff20fd3e 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicChair.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicChair.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic { CreateRecipe(). AddIngredient(4). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicChandelier.cs b/Items/Placeables/FurnitureBotanic/BotanicChandelier.cs index 136936f5d5..d44cc1e876 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicChandelier.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicChandelier.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicChest.cs b/Items/Placeables/FurnitureBotanic/BotanicChest.cs index ea8c94157f..a9b254b455 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicChest.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicChest.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(8). AddRecipeGroup("IronBar", 2). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicClock.cs b/Items/Placeables/FurnitureBotanic/BotanicClock.cs index 8687c3d0d0..a87deb2033 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicClock.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicClock.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicDoor.cs b/Items/Placeables/FurnitureBotanic/BotanicDoor.cs index 2994122832..ab09bfafce 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicDoor.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicDoor.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureBotanic; +using CalamityMod.Tiles.FurnitureBotanic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic { CreateRecipe(). AddIngredient(6). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicDresser.cs b/Items/Placeables/FurnitureBotanic/BotanicDresser.cs index bae1342b7f..79247abadc 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicDresser.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicDresser.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic { CreateRecipe(). AddIngredient(16). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicLamp.cs b/Items/Placeables/FurnitureBotanic/BotanicLamp.cs index e1721c14f0..f8bcda29e2 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicLamp.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicLamp.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicLantern.cs b/Items/Placeables/FurnitureBotanic/BotanicLantern.cs index 016f715296..1963d22aff 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicLantern.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicLantern.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicPiano.cs b/Items/Placeables/FurnitureBotanic/BotanicPiano.cs index bcb626d113..ecd0162e39 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicPiano.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicPiano.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicPlanter.cs b/Items/Placeables/FurnitureBotanic/BotanicPlanter.cs new file mode 100644 index 0000000000..c06b0e6e63 --- /dev/null +++ b/Items/Placeables/FurnitureBotanic/BotanicPlanter.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureBotanic +{ + public class BotanicPlanter : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(gold: 2); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(20). + AddIngredient(ItemID.JungleSpores, 5). + AddTile(TileID.LivingLoom). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CraftingStations/BotanicPlanter.png b/Items/Placeables/FurnitureBotanic/BotanicPlanter.png similarity index 100% rename from Items/Placeables/Furniture/CraftingStations/BotanicPlanter.png rename to Items/Placeables/FurnitureBotanic/BotanicPlanter.png diff --git a/Items/Placeables/FurnitureBotanic/BotanicPlatform.cs b/Items/Placeables/FurnitureBotanic/BotanicPlatform.cs index 2f56f85648..0a9e547d9a 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicPlatform.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicPlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic { diff --git a/Items/Placeables/FurnitureBotanic/BotanicSink.cs b/Items/Placeables/FurnitureBotanic/BotanicSink.cs index 7b2d93382e..843c235a7d 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicSink.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicSink.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureBotanic @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.HoneyBucket). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicTable.cs b/Items/Placeables/FurnitureBotanic/BotanicTable.cs index 72801307f6..6124b5b28e 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicTable.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicTable.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureBotanic/BotanicWorkBench.cs b/Items/Placeables/FurnitureBotanic/BotanicWorkBench.cs index 677b7876fc..2e7a72c0bc 100644 --- a/Items/Placeables/FurnitureBotanic/BotanicWorkBench.cs +++ b/Items/Placeables/FurnitureBotanic/BotanicWorkBench.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureBotanic { CreateRecipe(). AddIngredient(10). - AddTile(). + AddTile(TileID.LivingLoom). Register(); } } diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs index 2f6776e8bd..530a5cf096 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteBasin.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureCosmilite; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteBathtub.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteBathtub.cs index 15f7759b6d..931dc8fac0 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteBathtub.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteBathtub.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteChair.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteChair.cs index 6b97568af9..71187b0c63 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteChair.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteChair.cs @@ -1,7 +1,6 @@  using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteChest.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteChest.cs index e2deef1caa..d6987c28bd 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteChest.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteChest.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite { diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteDoor.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteDoor.cs index 81010699b8..443628b52b 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteDoor.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureCosmilite; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteDresser.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteDresser.cs index 54d5eea0b2..de953b9322 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteDresser.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteDresser.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite diff --git a/Items/Placeables/FurnitureCosmilite/CosmilitePlatform.cs b/Items/Placeables/FurnitureCosmilite/CosmilitePlatform.cs index b828855938..4f8c5dc70e 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmilitePlatform.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmilitePlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite { diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteTable.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteTable.cs index 334a90f945..26a8fd696f 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteTable.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteTable.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite { diff --git a/Items/Placeables/FurnitureCosmilite/CosmiliteWorkBench.cs b/Items/Placeables/FurnitureCosmilite/CosmiliteWorkBench.cs index 8e83081205..c9b23cbec0 100644 --- a/Items/Placeables/FurnitureCosmilite/CosmiliteWorkBench.cs +++ b/Items/Placeables/FurnitureCosmilite/CosmiliteWorkBench.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureCosmilite diff --git a/Items/Placeables/FurnitureDriftwood/Driftwood.cs b/Items/Placeables/FurnitureDriftwood/Driftwood.cs new file mode 100644 index 0000000000..0c707086a7 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/Driftwood.cs @@ -0,0 +1,31 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class Driftwood : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.Wood; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Wood; + } + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(4). + AddTile(TileID.WorkBenches). + DisableDecraft(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/Driftwood.png b/Items/Placeables/FurnitureDriftwood/Driftwood.png new file mode 100644 index 0000000000..b32a47fe74 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/Driftwood.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBaroqueCello.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodBaroqueCello.cs new file mode 100644 index 0000000000..a2303f00b4 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodBaroqueCello.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodBaroqueCello : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(ItemID.Silk, 4). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBaroqueCello.png b/Items/Placeables/FurnitureDriftwood/DriftwoodBaroqueCello.png new file mode 100644 index 0000000000..d212716b57 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodBaroqueCello.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBathtub.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodBathtub.cs new file mode 100644 index 0000000000..ac39166de7 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodBathtub.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodBathtub : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBathtub.png b/Items/Placeables/FurnitureDriftwood/DriftwoodBathtub.png new file mode 100644 index 0000000000..73c7b19ed4 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodBathtub.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBed.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodBed.cs new file mode 100644 index 0000000000..c454b544ba --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodBed.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodBed : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 4); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(ItemID.Silk, 5). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBed.png b/Items/Placeables/FurnitureDriftwood/DriftwoodBed.png new file mode 100644 index 0000000000..39ef943058 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodBed.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBookcase.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodBookcase.cs new file mode 100644 index 0000000000..75262bb181 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodBookcase.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodBookcase : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(20). + AddIngredient(ItemID.Book, 10). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodBookcase.png b/Items/Placeables/FurnitureDriftwood/DriftwoodBookcase.png new file mode 100644 index 0000000000..8014290409 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodBookcase.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodCandelabra.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodCandelabra.cs new file mode 100644 index 0000000000..9607ced5bd --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodCandelabra.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodCandelabra : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 3); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.Torch, 3). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodCandelabra.png b/Items/Placeables/FurnitureDriftwood/DriftwoodCandelabra.png new file mode 100644 index 0000000000..cf0798c369 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodCandelabra.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodCandle.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodCandle.cs new file mode 100644 index 0000000000..73c626ca3a --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodCandle.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodCandle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodCandle.png b/Items/Placeables/FurnitureDriftwood/DriftwoodCandle.png new file mode 100644 index 0000000000..4bb35c5f2a Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodCandle.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodChair.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodChair.cs new file mode 100644 index 0000000000..93e885ebff --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodChair.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodChair : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodChair.png b/Items/Placeables/FurnitureDriftwood/DriftwoodChair.png new file mode 100644 index 0000000000..ec6e9bd9ee Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodChair.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodChandelier.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodChandelier.cs new file mode 100644 index 0000000000..3f870612bc --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodChandelier.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodChandelier : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch, 4). + AddIngredient(ItemID.Chain). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodChandelier.png b/Items/Placeables/FurnitureDriftwood/DriftwoodChandelier.png new file mode 100644 index 0000000000..59ca9bc75a Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodChandelier.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodChest.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodChest.cs new file mode 100644 index 0000000000..bcd42fbad1 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodChest.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodChest : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddRecipeGroup("IronBar", 2). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodChest.png b/Items/Placeables/FurnitureDriftwood/DriftwoodChest.png new file mode 100644 index 0000000000..1d0b01e9f3 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodChest.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodDoor.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodDoor.cs new file mode 100644 index 0000000000..f5c74eb36e --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodDoor.cs @@ -0,0 +1,25 @@ +using CalamityMod.Tiles.FurnitureDriftwood; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodDoor : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 40); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodDoor.png b/Items/Placeables/FurnitureDriftwood/DriftwoodDoor.png new file mode 100644 index 0000000000..ed03fbc288 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodDoor.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodDresser.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodDresser.cs new file mode 100644 index 0000000000..428db3eed3 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodDresser.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodDresser : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(16). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodDresser.png b/Items/Placeables/FurnitureDriftwood/DriftwoodDresser.png new file mode 100644 index 0000000000..0e10813c48 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodDresser.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodLamp.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodLamp.cs new file mode 100644 index 0000000000..ac43a98610 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodLamp.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodLamp : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.Torch). + AddIngredient(3). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodLamp.png b/Items/Placeables/FurnitureDriftwood/DriftwoodLamp.png new file mode 100644 index 0000000000..fdcf21b3c4 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodLamp.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodLantern.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodLantern.cs new file mode 100644 index 0000000000..f5079b0628 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodLantern.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodLantern : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodLantern.png b/Items/Placeables/FurnitureDriftwood/DriftwoodLantern.png new file mode 100644 index 0000000000..952adc2cf2 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodLantern.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodPlatform.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodPlatform.cs new file mode 100644 index 0000000000..2e9de515b9 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodPlatform.cs @@ -0,0 +1,22 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodPlatform : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(2). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodPlatform.png b/Items/Placeables/FurnitureDriftwood/DriftwoodPlatform.png new file mode 100644 index 0000000000..1bd785cc73 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodPlatform.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodSink.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodSink.cs new file mode 100644 index 0000000000..fd0611b600 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodSink.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodSink : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.WaterBucket). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodSink.png b/Items/Placeables/FurnitureDriftwood/DriftwoodSink.png new file mode 100644 index 0000000000..2ff5b161f6 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodSink.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodSofa.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodSofa.cs new file mode 100644 index 0000000000..1467dbb811 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodSofa.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodSofa : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.Silk, 2). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodSofa.png b/Items/Placeables/FurnitureDriftwood/DriftwoodSofa.png new file mode 100644 index 0000000000..77730724c1 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodSofa.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodSundial.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodSundial.cs new file mode 100644 index 0000000000..ec18d48383 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodSundial.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodSundial : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddRecipeGroup("IronBar", 3). + AddIngredient(ItemID.Glass, 6). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodSundial.png b/Items/Placeables/FurnitureDriftwood/DriftwoodSundial.png new file mode 100644 index 0000000000..959cb779c9 Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodSundial.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodTable.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodTable.cs new file mode 100644 index 0000000000..4b78fc7402 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodTable.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodTable : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodTable.png b/Items/Placeables/FurnitureDriftwood/DriftwoodTable.png new file mode 100644 index 0000000000..a6db8a185b Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodTable.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodToilet.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodToilet.cs new file mode 100644 index 0000000000..e6bf0d7aaf --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodToilet.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodToilet : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodToilet.png b/Items/Placeables/FurnitureDriftwood/DriftwoodToilet.png new file mode 100644 index 0000000000..65321ca8fb Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodToilet.png differ diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodWorkBench.cs b/Items/Placeables/FurnitureDriftwood/DriftwoodWorkBench.cs new file mode 100644 index 0000000000..0250ae9083 --- /dev/null +++ b/Items/Placeables/FurnitureDriftwood/DriftwoodWorkBench.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureDriftwood +{ + public class DriftwoodWorkBench : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureDriftwood/DriftwoodWorkBench.png b/Items/Placeables/FurnitureDriftwood/DriftwoodWorkBench.png new file mode 100644 index 0000000000..e8125c908e Binary files /dev/null and b/Items/Placeables/FurnitureDriftwood/DriftwoodWorkBench.png differ diff --git a/Items/Placeables/FurnitureEutrophic/AncientSmoothNavystone.cs b/Items/Placeables/FurnitureEutrophic/AncientSmoothNavystone.cs deleted file mode 100644 index 5fe203a28e..0000000000 --- a/Items/Placeables/FurnitureEutrophic/AncientSmoothNavystone.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.Walls; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class AncientSmoothNavystone : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - - /*public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddTile(TileID.WorkBenches). - DisableDecraft(). - Register(); - }*/ - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBathtub.cs b/Items/Placeables/FurnitureEutrophic/EutrophicBathtub.cs deleted file mode 100644 index 657e022d09..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicBathtub.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicBathtub : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(14). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBed.cs b/Items/Placeables/FurnitureEutrophic/EutrophicBed.cs deleted file mode 100644 index dd9074f28f..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicBed.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicBed : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 4); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(15). - AddIngredient(ItemID.Silk, 5). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBench.cs b/Items/Placeables/FurnitureEutrophic/EutrophicBench.cs deleted file mode 100644 index 20f4da4428..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicBench.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicBench : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(8). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBookcase.cs b/Items/Placeables/FurnitureEutrophic/EutrophicBookcase.cs deleted file mode 100644 index 6ad2fb84a5..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicBookcase.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicBookcase : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(20). - AddIngredient(ItemID.Book, 10). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicCandelabra.cs b/Items/Placeables/FurnitureEutrophic/EutrophicCandelabra.cs deleted file mode 100644 index 8351687fae..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicCandelabra.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicCandelabra : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 3); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(ItemID.Torch, 3). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicCandle.cs b/Items/Placeables/FurnitureEutrophic/EutrophicCandle.cs deleted file mode 100644 index e159fc7cfc..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicCandle.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicCandle : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddIngredient(ItemID.Torch). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicChair.cs b/Items/Placeables/FurnitureEutrophic/EutrophicChair.cs deleted file mode 100644 index 6d0b102069..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicChair.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicChair : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 30); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicChandelier.cs b/Items/Placeables/FurnitureEutrophic/EutrophicChandelier.cs deleted file mode 100644 index ab029ab282..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicChandelier.cs +++ /dev/null @@ -1,28 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicChandelier : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 1); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddIngredient(ItemID.Torch, 4). - AddIngredient(ItemID.Chain). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicChest.cs b/Items/Placeables/FurnitureEutrophic/EutrophicChest.cs deleted file mode 100644 index eb9f034571..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicChest.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicChest : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 1); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(8). - AddRecipeGroup("IronBar", 2). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicClock.cs b/Items/Placeables/FurnitureEutrophic/EutrophicClock.cs deleted file mode 100644 index 30bc7622c0..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicClock.cs +++ /dev/null @@ -1,28 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicClock : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddRecipeGroup("IronBar", 3). - AddIngredient(ItemID.Glass, 6). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicDoor.cs b/Items/Placeables/FurnitureEutrophic/EutrophicDoor.cs deleted file mode 100644 index 12b9a49e24..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicDoor.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureEutrophic; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicDoor : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 40); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(6). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicDresser.cs b/Items/Placeables/FurnitureEutrophic/EutrophicDresser.cs deleted file mode 100644 index cc508f17c8..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicDresser.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicDresser : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 1); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(16). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicLamp.cs b/Items/Placeables/FurnitureEutrophic/EutrophicLamp.cs deleted file mode 100644 index 7b366fb21a..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicLamp.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicLamp : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 1); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(3). - AddIngredient(ItemID.Torch). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicLantern.cs b/Items/Placeables/FurnitureEutrophic/EutrophicLantern.cs deleted file mode 100644 index 04a0ff5d2c..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicLantern.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicLantern : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 30); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(6). - AddIngredient(ItemID.Torch). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicPiano.cs b/Items/Placeables/FurnitureEutrophic/EutrophicPiano.cs deleted file mode 100644 index 40ef588135..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicPiano.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicPiano : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(15). - AddIngredient(ItemID.Bone, 4). - AddIngredient(ItemID.Book). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.cs b/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.cs deleted file mode 100644 index f1ccad62a8..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.cs +++ /dev/null @@ -1,25 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicPlatform : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 200; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - - public override void AddRecipes() - { - CreateRecipe(2). - AddIngredient(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicSink.cs b/Items/Placeables/FurnitureEutrophic/EutrophicSink.cs deleted file mode 100644 index 9eab014730..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicSink.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicSink : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(6). - AddIngredient(ItemID.WaterBucket). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicTable.cs b/Items/Placeables/FurnitureEutrophic/EutrophicTable.cs deleted file mode 100644 index e615b230a4..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicTable.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicTable : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(8). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicWorkBench.cs b/Items/Placeables/FurnitureEutrophic/EutrophicWorkBench.cs deleted file mode 100644 index 74c10dc6db..0000000000 --- a/Items/Placeables/FurnitureEutrophic/EutrophicWorkBench.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class EutrophicWorkBench : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetDefaults() - { - Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(copper: 30); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddTile(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureEutrophic/SmoothNavystone.cs b/Items/Placeables/FurnitureEutrophic/SmoothNavystone.cs deleted file mode 100644 index 19a4f66101..0000000000 --- a/Items/Placeables/FurnitureEutrophic/SmoothNavystone.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Items.Placeables.Walls; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.FurnitureEutrophic -{ - public class SmoothNavystone : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddTile(TileID.WorkBenches). - Register(); - CreateRecipe(). - AddIngredient(4). - AddTile(TileID.WorkBenches). - DisableDecraft(). - Register(); - } - } -} diff --git a/Items/Placeables/FurnitureExo/ExoBathtub.cs b/Items/Placeables/FurnitureExo/ExoBathtub.cs index b254e0bbe1..492a2bf095 100644 --- a/Items/Placeables/FurnitureExo/ExoBathtub.cs +++ b/Items/Placeables/FurnitureExo/ExoBathtub.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoChair.cs b/Items/Placeables/FurnitureExo/ExoChair.cs index 9da13bf756..7a474bb7f5 100644 --- a/Items/Placeables/FurnitureExo/ExoChair.cs +++ b/Items/Placeables/FurnitureExo/ExoChair.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoChest.cs b/Items/Placeables/FurnitureExo/ExoChest.cs index 5fab9f1e52..44f02efca5 100644 --- a/Items/Placeables/FurnitureExo/ExoChest.cs +++ b/Items/Placeables/FurnitureExo/ExoChest.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoConsole.cs b/Items/Placeables/FurnitureExo/ExoConsole.cs index df9a00c943..3b79393471 100644 --- a/Items/Placeables/FurnitureExo/ExoConsole.cs +++ b/Items/Placeables/FurnitureExo/ExoConsole.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoDisplay.cs b/Items/Placeables/FurnitureExo/ExoDisplay.cs index 72bc9dba6e..55349ed4e1 100644 --- a/Items/Placeables/FurnitureExo/ExoDisplay.cs +++ b/Items/Placeables/FurnitureExo/ExoDisplay.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoDoor.cs b/Items/Placeables/FurnitureExo/ExoDoor.cs index b5e2cb3af4..f06d454d70 100644 --- a/Items/Placeables/FurnitureExo/ExoDoor.cs +++ b/Items/Placeables/FurnitureExo/ExoDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoDresser.cs b/Items/Placeables/FurnitureExo/ExoDresser.cs index 64a84d9df3..97fd044bf2 100644 --- a/Items/Placeables/FurnitureExo/ExoDresser.cs +++ b/Items/Placeables/FurnitureExo/ExoDresser.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoPlatform.cs b/Items/Placeables/FurnitureExo/ExoPlatform.cs index af83c714bc..d150b79bdd 100644 --- a/Items/Placeables/FurnitureExo/ExoPlatform.cs +++ b/Items/Placeables/FurnitureExo/ExoPlatform.cs @@ -1,5 +1,4 @@ using CalamityMod.Tiles.FurnitureExo; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo diff --git a/Items/Placeables/FurnitureExo/ExoPrismPlatform.cs b/Items/Placeables/FurnitureExo/ExoPrismPlatform.cs index ce5d169e79..f080ddf7f4 100644 --- a/Items/Placeables/FurnitureExo/ExoPrismPlatform.cs +++ b/Items/Placeables/FurnitureExo/ExoPrismPlatform.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo diff --git a/Items/Placeables/FurnitureExo/ExoScreen.cs b/Items/Placeables/FurnitureExo/ExoScreen.cs index 5c7414f37f..732c9fa543 100644 --- a/Items/Placeables/FurnitureExo/ExoScreen.cs +++ b/Items/Placeables/FurnitureExo/ExoScreen.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoServer.cs b/Items/Placeables/FurnitureExo/ExoServer.cs index ced965dfd3..b35bfa00a8 100644 --- a/Items/Placeables/FurnitureExo/ExoServer.cs +++ b/Items/Placeables/FurnitureExo/ExoServer.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoTable.cs b/Items/Placeables/FurnitureExo/ExoTable.cs index cccf60e6dc..9ec94fec69 100644 --- a/Items/Placeables/FurnitureExo/ExoTable.cs +++ b/Items/Placeables/FurnitureExo/ExoTable.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoTerminal.cs b/Items/Placeables/FurnitureExo/ExoTerminal.cs index 40e05a1984..4ada117e51 100644 --- a/Items/Placeables/FurnitureExo/ExoTerminal.cs +++ b/Items/Placeables/FurnitureExo/ExoTerminal.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoToilet.cs b/Items/Placeables/FurnitureExo/ExoToilet.cs index 7732f0e68e..61a366c246 100644 --- a/Items/Placeables/FurnitureExo/ExoToilet.cs +++ b/Items/Placeables/FurnitureExo/ExoToilet.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureExo/ExoWorkBench.cs b/Items/Placeables/FurnitureExo/ExoWorkBench.cs index 8d9d1c745a..6565759b71 100644 --- a/Items/Placeables/FurnitureExo/ExoWorkBench.cs +++ b/Items/Placeables/FurnitureExo/ExoWorkBench.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureExo; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureExo { diff --git a/Items/Placeables/FurnitureMarnite/MarniteBathtub.cs b/Items/Placeables/FurnitureMarnite/MarniteBathtub.cs index c74ae9cd78..80168f3385 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteBathtub.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteBathtub.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite { CreateRecipe(). AddIngredient(4). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteBed.cs b/Items/Placeables/FurnitureMarnite/MarniteBed.cs index 75e39a9129..4be20619b4 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteBed.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteBed.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Silk, 5). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteBookcase.cs b/Items/Placeables/FurnitureMarnite/MarniteBookcase.cs index d86b858582..aed7429b33 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteBookcase.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteBookcase.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Book, 10). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteCandelabra.cs b/Items/Placeables/FurnitureMarnite/MarniteCandelabra.cs index 0fd009c5c7..0289cc47ef 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteCandelabra.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteCandelabra.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureMarnite/MarniteCandle.cs b/Items/Placeables/FurnitureMarnite/MarniteCandle.cs index 9e0d07a83d..c828b1220a 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteCandle.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteCandle.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureMarnite/MarniteChair.cs b/Items/Placeables/FurnitureMarnite/MarniteChair.cs index ddadfe66f3..616efc51dd 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteChair.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteChair.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureMarnite/MarniteChandelier.cs b/Items/Placeables/FurnitureMarnite/MarniteChandelier.cs index a7d2ebea32..8839ba69af 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteChandelier.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteChandelier.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch, 4). - AddTile(TileID.WorkBenches). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteChest.cs b/Items/Placeables/FurnitureMarnite/MarniteChest.cs index d20a98e9fc..b6041af4d1 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteChest.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteChest.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite diff --git a/Items/Placeables/FurnitureMarnite/MarniteClock.cs b/Items/Placeables/FurnitureMarnite/MarniteClock.cs index 2a65849521..9e3791fd29 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteClock.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteClock.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite @@ -20,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite AddIngredient(4). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteDoor.cs b/Items/Placeables/FurnitureMarnite/MarniteDoor.cs index 11eedc0a2a..b4728daaf6 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteDoor.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteDoor.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; +using CalamityMod.Tiles.FurnitureMarnite; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureMarnite/MarniteDresser.cs b/Items/Placeables/FurnitureMarnite/MarniteDresser.cs index 7eee4ef299..398f23c45e 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteDresser.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteDresser.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite { CreateRecipe(). AddIngredient(4). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteLamp.cs b/Items/Placeables/FurnitureMarnite/MarniteLamp.cs index bd6f6612b2..830be1c590 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteLamp.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteLamp.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureMarnite/MarniteLantern.cs b/Items/Placeables/FurnitureMarnite/MarniteLantern.cs index 3379507792..8a0bca1014 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteLantern.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteLantern.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureMarnite/MarniteLight.cs b/Items/Placeables/FurnitureMarnite/MarniteLight.cs index 4785695df4..a226b144a7 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteLight.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteLight.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.FurnitureMarnite; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurnitureMarnite/MarniteOrgan.cs b/Items/Placeables/FurnitureMarnite/MarniteOrgan.cs index d4e8f381f4..34f306ff26 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteOrgan.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteOrgan.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite @@ -20,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite AddIngredient(1). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteSink.cs b/Items/Placeables/FurnitureMarnite/MarniteSink.cs index e6bcad01ca..6fcfd08e03 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteSink.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteSink.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite diff --git a/Items/Placeables/FurnitureMarnite/MarniteSofa.cs b/Items/Placeables/FurnitureMarnite/MarniteSofa.cs index f754aaf8a8..681697de37 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteSofa.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteSofa.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Silk, 2). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteToilet.cs b/Items/Placeables/FurnitureMarnite/MarniteToilet.cs index 9d91fac578..62313370fb 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteToilet.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteToilet.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite { CreateRecipe(). AddIngredient(6). - AddTile(TileID.WorkBenches). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/MarniteWorkBench.cs b/Items/Placeables/FurnitureMarnite/MarniteWorkBench.cs index 631e7ede23..c492374eb5 100644 --- a/Items/Placeables/FurnitureMarnite/MarniteWorkBench.cs +++ b/Items/Placeables/FurnitureMarnite/MarniteWorkBench.cs @@ -1,7 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMarnite; -using Terraria; -using Terraria.ID; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite @@ -19,7 +16,6 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite { CreateRecipe(). AddIngredient(4). - AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMarnite/PolishedMarniteBlock.cs b/Items/Placeables/FurnitureMarnite/PolishedMarniteBlock.cs index 156984f82d..385e5b8f69 100644 --- a/Items/Placeables/FurnitureMarnite/PolishedMarniteBlock.cs +++ b/Items/Placeables/FurnitureMarnite/PolishedMarniteBlock.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMarnite public override void AddRecipes() { - CreateRecipe(). + CreateRecipe(4). AddIngredient(ItemID.Marble, 2). AddIngredient(ItemID.Granite, 2). AddRecipeGroup(RecipeSystem.AnyGoldOre, 1). diff --git a/Items/Placeables/FurnitureMarnite/PolishedMarnitePlatform.cs b/Items/Placeables/FurnitureMarnite/PolishedMarnitePlatform.cs index ae848f862f..2c95bbb66e 100644 --- a/Items/Placeables/FurnitureMarnite/PolishedMarnitePlatform.cs +++ b/Items/Placeables/FurnitureMarnite/PolishedMarnitePlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMarnite { public class PolishedMarnitePlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurnitureMonolith/AstralMonolith.cs b/Items/Placeables/FurnitureMonolith/AstralMonolith.cs new file mode 100644 index 0000000000..6099bc63ff --- /dev/null +++ b/Items/Placeables/FurnitureMonolith/AstralMonolith.cs @@ -0,0 +1,38 @@ +using CalamityMod.Items.Placeables.Walls; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureMonolith +{ + public class AstralMonolith : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.Wood; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + // It's not really wood... but it comes from trees! + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Wood; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + DisableDecraft(). + Register(); + + CreateRecipe(). + AddIngredient(2). + DisableDecraft(). + Register(); + } + } +} diff --git a/Items/Placeables/Astral/AstralMonolith.png b/Items/Placeables/FurnitureMonolith/AstralMonolith.png similarity index 100% rename from Items/Placeables/Astral/AstralMonolith.png rename to Items/Placeables/FurnitureMonolith/AstralMonolith.png diff --git a/Items/Placeables/FurnitureMonolith/MonolithAmalgam.cs b/Items/Placeables/FurnitureMonolith/MonolithAmalgam.cs new file mode 100644 index 0000000000..9159be660e --- /dev/null +++ b/Items/Placeables/FurnitureMonolith/MonolithAmalgam.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureMonolith +{ + [LegacyName("MonolithCrafting")] + public class MonolithAmalgam : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(gold: 2); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(20). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CraftingStations/MonolithAmalgam.png b/Items/Placeables/FurnitureMonolith/MonolithAmalgam.png similarity index 100% rename from Items/Placeables/Furniture/CraftingStations/MonolithAmalgam.png rename to Items/Placeables/FurnitureMonolith/MonolithAmalgam.png diff --git a/Items/Placeables/FurnitureMonolith/MonolithBathtub.cs b/Items/Placeables/FurnitureMonolith/MonolithBathtub.cs index 180e480867..49ef6a49bc 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithBathtub.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithBathtub.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -18,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith { CreateRecipe(). AddIngredient(14). - AddTile(). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithBed.cs b/Items/Placeables/FurnitureMonolith/MonolithBed.cs index 1d333de777..8a1b1ec394 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithBed.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithBed.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithBench.cs b/Items/Placeables/FurnitureMonolith/MonolithBench.cs index 8498b4de74..49b5aa28c6 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithBench.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithBench.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -18,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithBookcase.cs b/Items/Placeables/FurnitureMonolith/MonolithBookcase.cs index c2c7c915d8..81a341fa2c 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithBookcase.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithBookcase.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithCandelabra.cs b/Items/Placeables/FurnitureMonolith/MonolithCandelabra.cs index 70090c243b..4d6bf96f51 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithCandelabra.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithCandelabra.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Torch, 3). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithCandle.cs b/Items/Placeables/FurnitureMonolith/MonolithCandle.cs index f76318e634..46fda6ba38 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithCandle.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithCandle.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithChair.cs b/Items/Placeables/FurnitureMonolith/MonolithChair.cs index 25bd448184..c53cf251e1 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithChair.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithChair.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -18,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith { CreateRecipe(). AddIngredient(4). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithChandelier.cs b/Items/Placeables/FurnitureMonolith/MonolithChandelier.cs index e3a72a15c7..8dee5ee1f0 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithChandelier.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithChandelier.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -20,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithChest.cs b/Items/Placeables/FurnitureMonolith/MonolithChest.cs index 6192e86422..a5b2f09dcc 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithChest.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithChest.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(8). AddRecipeGroup("IronBar", 2). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithClock.cs b/Items/Placeables/FurnitureMonolith/MonolithClock.cs index 8878384da9..f9ae1bbe7d 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithClock.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithClock.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -20,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithDoor.cs b/Items/Placeables/FurnitureMonolith/MonolithDoor.cs index 0f01131333..3a5e12201d 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithDoor.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithDoor.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureMonolith; +using CalamityMod.Tiles.FurnitureMonolith; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith { CreateRecipe(). AddIngredient(6). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithDresser.cs b/Items/Placeables/FurnitureMonolith/MonolithDresser.cs index 1c1d788560..ee8510fef2 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithDresser.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithDresser.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -18,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith { CreateRecipe(). AddIngredient(16). - AddTile(). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithLamp.cs b/Items/Placeables/FurnitureMonolith/MonolithLamp.cs index 2b9635cdad..1b363f8fd0 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithLamp.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithLamp.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithLantern.cs b/Items/Placeables/FurnitureMonolith/MonolithLantern.cs index 63692653c1..e39e46348e 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithLantern.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithLantern.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithPiano.cs b/Items/Placeables/FurnitureMonolith/MonolithPiano.cs index 2c6238a177..d0b8437439 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithPiano.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithPiano.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -20,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithPlatform.cs b/Items/Placeables/FurnitureMonolith/MonolithPlatform.cs index 8eca34c5db..7a73c09e14 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithPlatform.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithPlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith { public class MonolithPlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurnitureMonolith/MonolithSink.cs b/Items/Placeables/FurnitureMonolith/MonolithSink.cs index 65f6164663..e20ab97137 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithSink.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithSink.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.WaterBucket). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithTable.cs b/Items/Placeables/FurnitureMonolith/MonolithTable.cs index af80d2f04d..26d90a6e59 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithTable.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithTable.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith @@ -18,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureMonolith/MonolithWorkBench.cs b/Items/Placeables/FurnitureMonolith/MonolithWorkBench.cs index 7aab4573e8..8aaab39138 100644 --- a/Items/Placeables/FurnitureMonolith/MonolithWorkBench.cs +++ b/Items/Placeables/FurnitureMonolith/MonolithWorkBench.cs @@ -1,7 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureMonolith { @@ -18,7 +15,6 @@ namespace CalamityMod.Items.Placeables.FurnitureMonolith { CreateRecipe(). AddIngredient(10). - AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.cs new file mode 100644 index 0000000000..7b2973b788 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBathtub")] + public class AncientNavystoneBathtub : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBathtub.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicBathtub.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.cs new file mode 100644 index 0000000000..5d1983e817 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBed")] + public class AncientNavystoneBed : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 4); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(ItemID.Silk, 5). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBed.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicBed.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.cs new file mode 100644 index 0000000000..c379c39a3a --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBench")] + public class AncientNavystoneBench : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBench.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicBench.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.cs new file mode 100644 index 0000000000..e03002c751 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBookcase")] + public class AncientNavystoneBookcase : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(20). + AddIngredient(ItemID.Book, 10). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicBookcase.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicBookcase.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.cs new file mode 100644 index 0000000000..2a414bb7c6 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicCandelabra")] + public class AncientNavystoneCandelabra : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 3); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.Torch, 3). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicCandelabra.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicCandelabra.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.cs new file mode 100644 index 0000000000..8ff56d8e36 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicCandle")] + public class AncientNavystoneCandle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicCandle.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicCandle.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.cs new file mode 100644 index 0000000000..a3774a6d0a --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicChair")] + public class AncientNavystoneChair : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicChair.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicChair.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.cs new file mode 100644 index 0000000000..2b6ab0a2a4 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.cs @@ -0,0 +1,27 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicChandelier")] + public class AncientNavystoneChandelier : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch, 4). + AddIngredient(ItemID.Chain). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicChandelier.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicChandelier.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.cs new file mode 100644 index 0000000000..7009df94de --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicChest")] + public class AncientNavystoneChest : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddRecipeGroup("IronBar", 2). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicChest.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicChest.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.cs new file mode 100644 index 0000000000..e30cf5ab66 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.cs @@ -0,0 +1,27 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicClock")] + public class AncientNavystoneClock : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddRecipeGroup("IronBar", 3). + AddIngredient(ItemID.Glass, 6). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicClock.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicClock.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoor.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoor.cs new file mode 100644 index 0000000000..b5a9885608 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoor.cs @@ -0,0 +1,26 @@ +using CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicDoor")] + public class AncientNavystoneDoor : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 40); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicDoor.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoor.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicDoor.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoor.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.cs new file mode 100644 index 0000000000..d390c268ed --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicDresser")] + public class AncientNavystoneDresser : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(16). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicDresser.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicDresser.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.cs new file mode 100644 index 0000000000..f6bab5302e --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicLamp")] + public class AncientNavystoneLamp : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(3). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicLamp.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicLamp.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.cs new file mode 100644 index 0000000000..0c1e5246d0 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicLantern")] + public class AncientNavystoneLantern : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicLantern.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicLantern.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.cs new file mode 100644 index 0000000000..230be08cee --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicPiano")] + public class AncientNavystonePiano : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(ItemID.Bone, 4). + AddIngredient(ItemID.Book). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicPiano.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicPiano.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.cs new file mode 100644 index 0000000000..114b3c4f53 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.cs @@ -0,0 +1,23 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicPlatform")] + public class AncientNavystonePlatform : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(2). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicPlatform.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicPlatform.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.cs new file mode 100644 index 0000000000..bfbdac488a --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicSink")] + public class AncientNavystoneSink : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.WaterBucket). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicSink.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicSink.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.cs new file mode 100644 index 0000000000..7bac125d01 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicTable")] + public class AncientNavystoneTable : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicTable.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicTable.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.cs new file mode 100644 index 0000000000..d2629e1440 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicWorkBench")] + public class AncientNavystoneWorkBench : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/EutrophicWorkBench.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/EutrophicWorkBench.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.cs new file mode 100644 index 0000000000..09c8f2ffdc --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.cs @@ -0,0 +1,24 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + public class AncientSmoothNavystone : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + /*public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + DisableDecraft(). + Register(); + }*/ + } +} diff --git a/Items/Placeables/FurnitureEutrophic/AncientSmoothNavystone.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/AncientSmoothNavystone.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.png diff --git a/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.cs b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.cs new file mode 100644 index 0000000000..bb40af0be1 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.cs @@ -0,0 +1,30 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicCrafting")] + public class EutrophicShelf : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 50); // This is too easy to craft to sell for 2 gold + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddIngredient(5). + AddIngredient(5). + AddIngredient(3). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CraftingStations/EutrophicShelf.png b/Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.png similarity index 100% rename from Items/Placeables/Furniture/CraftingStations/EutrophicShelf.png rename to Items/Placeables/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.png diff --git a/Items/Placeables/FurnitureNavystone/NavystoneBathtub.cs b/Items/Placeables/FurnitureNavystone/NavystoneBathtub.cs new file mode 100644 index 0000000000..6c133f72a4 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneBathtub.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneBathtub : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneBathtub.png b/Items/Placeables/FurnitureNavystone/NavystoneBathtub.png new file mode 100644 index 0000000000..d096c1edb4 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneBathtub.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneBed.cs b/Items/Placeables/FurnitureNavystone/NavystoneBed.cs new file mode 100644 index 0000000000..f740d34abe --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneBed.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneBed : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 4); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(ItemID.Silk, 5). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneBed.png b/Items/Placeables/FurnitureNavystone/NavystoneBed.png new file mode 100644 index 0000000000..6336a84e7d Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneBed.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneBookcase.cs b/Items/Placeables/FurnitureNavystone/NavystoneBookcase.cs new file mode 100644 index 0000000000..77c1ae9bf4 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneBookcase.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneBookcase : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(20). + AddIngredient(ItemID.Book, 10). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneBookcase.png b/Items/Placeables/FurnitureNavystone/NavystoneBookcase.png new file mode 100644 index 0000000000..29cde351e8 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneBookcase.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneCandelabra.cs b/Items/Placeables/FurnitureNavystone/NavystoneCandelabra.cs new file mode 100644 index 0000000000..84befccc4b --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneCandelabra.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneCandelabra : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 3); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.Torch, 3). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneCandelabra.png b/Items/Placeables/FurnitureNavystone/NavystoneCandelabra.png new file mode 100644 index 0000000000..f238bbc491 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneCandelabra.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneCandle.cs b/Items/Placeables/FurnitureNavystone/NavystoneCandle.cs new file mode 100644 index 0000000000..9b196a1789 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneCandle.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneCandle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneCandle.png b/Items/Placeables/FurnitureNavystone/NavystoneCandle.png new file mode 100644 index 0000000000..3bbac4d65c Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneCandle.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneChair.cs b/Items/Placeables/FurnitureNavystone/NavystoneChair.cs new file mode 100644 index 0000000000..4a6ff4354b --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneChair.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneChair : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneChair.png b/Items/Placeables/FurnitureNavystone/NavystoneChair.png new file mode 100644 index 0000000000..bfb86147f9 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneChair.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneChandelier.cs b/Items/Placeables/FurnitureNavystone/NavystoneChandelier.cs new file mode 100644 index 0000000000..ee99e2cf46 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneChandelier.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneChandelier : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch, 4). + AddIngredient(ItemID.Chain). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneChandelier.png b/Items/Placeables/FurnitureNavystone/NavystoneChandelier.png new file mode 100644 index 0000000000..e62c1e7c0e Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneChandelier.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneChest.cs b/Items/Placeables/FurnitureNavystone/NavystoneChest.cs new file mode 100644 index 0000000000..eff3e5b755 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneChest.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneChest : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddRecipeGroup("IronBar", 2). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneChest.png b/Items/Placeables/FurnitureNavystone/NavystoneChest.png new file mode 100644 index 0000000000..3628fc230d Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneChest.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneClock.cs b/Items/Placeables/FurnitureNavystone/NavystoneClock.cs new file mode 100644 index 0000000000..af20ad163f --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneClock.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneClock : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddRecipeGroup("IronBar", 3). + AddIngredient(ItemID.Glass, 6). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneClock.png b/Items/Placeables/FurnitureNavystone/NavystoneClock.png new file mode 100644 index 0000000000..ccd6909fe6 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneClock.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneDoor.cs b/Items/Placeables/FurnitureNavystone/NavystoneDoor.cs new file mode 100644 index 0000000000..3426fedb6d --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneDoor.cs @@ -0,0 +1,25 @@ +using CalamityMod.Tiles.FurnitureNavystone; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneDoor : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 40); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneDoor.png b/Items/Placeables/FurnitureNavystone/NavystoneDoor.png new file mode 100644 index 0000000000..3aeeedfb40 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneDoor.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneDresser.cs b/Items/Placeables/FurnitureNavystone/NavystoneDresser.cs new file mode 100644 index 0000000000..2fb130f9ed --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneDresser.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneDresser : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(16). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneDresser.png b/Items/Placeables/FurnitureNavystone/NavystoneDresser.png new file mode 100644 index 0000000000..24ed7def97 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneDresser.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneLamp.cs b/Items/Placeables/FurnitureNavystone/NavystoneLamp.cs new file mode 100644 index 0000000000..4c5b8c7043 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneLamp.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneLamp : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(3). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneLamp.png b/Items/Placeables/FurnitureNavystone/NavystoneLamp.png new file mode 100644 index 0000000000..a058c3e769 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneLamp.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneLantern.cs b/Items/Placeables/FurnitureNavystone/NavystoneLantern.cs new file mode 100644 index 0000000000..17641e78b4 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneLantern.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneLantern : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.Torch). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneLantern.png b/Items/Placeables/FurnitureNavystone/NavystoneLantern.png new file mode 100644 index 0000000000..a88ffc2099 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneLantern.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneLyre.cs b/Items/Placeables/FurnitureNavystone/NavystoneLyre.cs new file mode 100644 index 0000000000..1831ad5256 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneLyre.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneLyre : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(ItemID.Bone, 4). + AddIngredient(ItemID.Book). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneLyre.png b/Items/Placeables/FurnitureNavystone/NavystoneLyre.png new file mode 100644 index 0000000000..1dc721d732 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneLyre.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystonePlatform.cs b/Items/Placeables/FurnitureNavystone/NavystonePlatform.cs new file mode 100644 index 0000000000..3f0dbc4725 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystonePlatform.cs @@ -0,0 +1,22 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystonePlatform : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(2). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystonePlatform.png b/Items/Placeables/FurnitureNavystone/NavystonePlatform.png new file mode 100644 index 0000000000..926737cb55 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystonePlatform.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneSink.cs b/Items/Placeables/FurnitureNavystone/NavystoneSink.cs new file mode 100644 index 0000000000..90f041fe34 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneSink.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneSink : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.WaterBucket). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneSink.png b/Items/Placeables/FurnitureNavystone/NavystoneSink.png new file mode 100644 index 0000000000..dc2dbdd522 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneSink.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneTable.cs b/Items/Placeables/FurnitureNavystone/NavystoneTable.cs new file mode 100644 index 0000000000..046ec3f237 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneTable.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneTable : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneTable.png b/Items/Placeables/FurnitureNavystone/NavystoneTable.png new file mode 100644 index 0000000000..4dd36e89c9 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneTable.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneToilet.cs b/Items/Placeables/FurnitureNavystone/NavystoneToilet.cs new file mode 100644 index 0000000000..36566b77df --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneToilet.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneToilet : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneToilet.png b/Items/Placeables/FurnitureNavystone/NavystoneToilet.png new file mode 100644 index 0000000000..1ab7abf58e Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneToilet.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneTriclinium.cs b/Items/Placeables/FurnitureNavystone/NavystoneTriclinium.cs new file mode 100644 index 0000000000..0229e067b3 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneTriclinium.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneTriclinium : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.Sawmill). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneTriclinium.png b/Items/Placeables/FurnitureNavystone/NavystoneTriclinium.png new file mode 100644 index 0000000000..b760662708 Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneTriclinium.png differ diff --git a/Items/Placeables/FurnitureNavystone/NavystoneWorkBench.cs b/Items/Placeables/FurnitureNavystone/NavystoneWorkBench.cs new file mode 100644 index 0000000000..8c5af8590b --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/NavystoneWorkBench.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class NavystoneWorkBench : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureNavystone/NavystoneWorkBench.png b/Items/Placeables/FurnitureNavystone/NavystoneWorkBench.png new file mode 100644 index 0000000000..6e12e7b36a Binary files /dev/null and b/Items/Placeables/FurnitureNavystone/NavystoneWorkBench.png differ diff --git a/Items/Placeables/FurnitureNavystone/PolishedNavystoneBrick.cs b/Items/Placeables/FurnitureNavystone/PolishedNavystoneBrick.cs new file mode 100644 index 0000000000..e78073a46b --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/PolishedNavystoneBrick.cs @@ -0,0 +1,25 @@ +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Items.Placeables.SunkenSea; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class PolishedNavystoneBrick : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(2). + AddTile(TileID.Furnaces). + Register(); + } + } +} diff --git a/Items/Placeables/SunkenSea/PolishedNavystoneBrick.png b/Items/Placeables/FurnitureNavystone/PolishedNavystoneBrick.png similarity index 100% rename from Items/Placeables/SunkenSea/PolishedNavystoneBrick.png rename to Items/Placeables/FurnitureNavystone/PolishedNavystoneBrick.png diff --git a/Items/Placeables/FurnitureNavystone/SmoothNavystone.cs b/Items/Placeables/FurnitureNavystone/SmoothNavystone.cs new file mode 100644 index 0000000000..737345d1a8 --- /dev/null +++ b/Items/Placeables/FurnitureNavystone/SmoothNavystone.cs @@ -0,0 +1,33 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.Walls; +using CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureNavystone +{ + public class SmoothNavystone : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + DisableDecraft(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureEutrophic/SmoothNavystone.png b/Items/Placeables/FurnitureNavystone/SmoothNavystone.png similarity index 100% rename from Items/Placeables/FurnitureEutrophic/SmoothNavystone.png rename to Items/Placeables/FurnitureNavystone/SmoothNavystone.png diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.cs index 36312630cf..65070a845f 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBathtub.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { CreateRecipe(). AddIngredient(14). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.cs index f3140813d1..353a1c5f8c 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBed.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBookcase.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBookcase.cs index d3df9dcdc5..f3ff94fd47 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyBookcase.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyBookcase.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandelabra.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandelabra.cs index 11c794c0f6..033e29b840 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandelabra.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandelabra.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Torch, 3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandle.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandle.cs index ba12961307..d6a2c55a98 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandle.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyCandle.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.cs index d2d7338feb..133d1339f9 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChair.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { CreateRecipe(). AddIngredient(4). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChandelier.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChandelier.cs index 3de2820561..d90850b4d3 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChandelier.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChandelier.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.cs index 88192ef233..d3f1b0136c 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyChest.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(8). AddRecipeGroup("IronBar", 2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyClock.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyClock.cs index f0ff836923..1a7282ccef 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyClock.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyClock.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyDoor.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyDoor.cs index 2a3a1e7b02..b6508de82b 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyDoor.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyDoor.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { CreateRecipe(). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyDresser.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyDresser.cs index 61a8967584..f347347fb4 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyDresser.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyDresser.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { CreateRecipe(). AddIngredient(16). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyLamp.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyLamp.cs index 65d2590d83..3970db46da 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyLamp.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyLamp.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyLantern.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyLantern.cs index 41dcfc2525..1833b7a940 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyLantern.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyLantern.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyPiano.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyPiano.cs index d84715b21d..208c7a75d3 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyPiano.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyPiano.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.cs index fc3ffa045e..af959245db 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyPlatform.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { [LegacyName("OccultPlatform")] diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.cs index 75ced4a50f..da49bd9456 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlySink.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.WaterBucket). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlySofa.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlySofa.cs index 3e992a78d7..b95b3622d4 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlySofa.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlySofa.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Silk, 2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Sawmill). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyStone.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyStone.cs index 718a840b8c..3e7acb41e0 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyStone.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyStone.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly AddIngredient(). AddIngredient(). AddIngredient(ItemID.Silk, 10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.AdamantiteForge). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyTable.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyTable.cs index d390b64ae9..8517f93ef5 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyTable.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyTable.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { CreateRecipe(). AddIngredient(8). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.WorkBenches). Register(); } } diff --git a/Items/Placeables/FurnitureOtherworldly/OtherworldlyWorkBench.cs b/Items/Placeables/FurnitureOtherworldly/OtherworldlyWorkBench.cs index 2cf9018b78..d51e824351 100644 --- a/Items/Placeables/FurnitureOtherworldly/OtherworldlyWorkBench.cs +++ b/Items/Placeables/FurnitureOtherworldly/OtherworldlyWorkBench.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { @@ -17,7 +16,6 @@ namespace CalamityMod.Items.Placeables.FurnitureOtherworldly { CreateRecipe(). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). Register(); } } diff --git a/Items/Placeables/FurniturePlagued/PlaguedContainmentBrick.cs b/Items/Placeables/FurniturePlagued/PlaguedContainmentBrick.cs index bb539251e8..6796adcccc 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedContainmentBrick.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedContainmentBrick.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Walls; using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlateBathtub.cs b/Items/Placeables/FurniturePlagued/PlaguedPlateBathtub.cs index dc67b0f1e2..56e7216f24 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlateBathtub.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlateBathtub.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlateChair.cs b/Items/Placeables/FurniturePlagued/PlaguedPlateChair.cs index f20bfd836e..13cc66166f 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlateChair.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlateChair.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlateChandelier.cs b/Items/Placeables/FurniturePlagued/PlaguedPlateChandelier.cs index 3150ed37ad..9f74354d60 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlateChandelier.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlateChandelier.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlateChest.cs b/Items/Placeables/FurniturePlagued/PlaguedPlateChest.cs index 6bd91adc4f..ae66b971b2 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlateChest.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlateChest.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlateDoor.cs b/Items/Placeables/FurniturePlagued/PlaguedPlateDoor.cs index 21b167c47f..197464664e 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlateDoor.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlateDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurniturePlaguedPlate; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlateDresser.cs b/Items/Placeables/FurniturePlagued/PlaguedPlateDresser.cs index e993268b04..011de32532 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlateDresser.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlateDresser.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlatePlatform.cs b/Items/Placeables/FurniturePlagued/PlaguedPlatePlatform.cs index a8839a64f8..83f928baa7 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlatePlatform.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlatePlatform.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { public class PlaguedPlatePlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurniturePlagued/PlaguedPlateTable.cs b/Items/Placeables/FurniturePlagued/PlaguedPlateTable.cs index 52c11a4d27..deb1fd6b25 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedPlateTable.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedPlateTable.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { diff --git a/Items/Placeables/FurniturePlagued/PlaguedWorkBench.cs b/Items/Placeables/FurniturePlagued/PlaguedWorkBench.cs index 6e5008a177..991ea2b7cb 100644 --- a/Items/Placeables/FurniturePlagued/PlaguedWorkBench.cs +++ b/Items/Placeables/FurniturePlagued/PlaguedWorkBench.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurniturePlaguedPlate; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurniturePlagued { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedBathtub.cs b/Items/Placeables/FurnitureProfaned/ProfanedBathtub.cs index 7401ff9a32..53dbdc0ff4 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedBathtub.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedBathtub.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedBench.cs b/Items/Placeables/FurnitureProfaned/ProfanedBench.cs index bc3d988a6a..99a6374143 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedBench.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedBench.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedChair.cs b/Items/Placeables/FurnitureProfaned/ProfanedChair.cs index 1d102fb16d..a930a83aa6 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedChair.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedChair.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedChest.cs b/Items/Placeables/FurnitureProfaned/ProfanedChest.cs index fc4f6afaf0..9894ea6c6a 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedChest.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedChest.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedCrystal.cs b/Items/Placeables/FurnitureProfaned/ProfanedCrystal.cs index 2100d817a9..6202b9a5e6 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedCrystal.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedCrystal.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureProfaned CreateRecipe(50). AddIngredient(ItemID.Glass, 50). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.AdamantiteForge). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/FurnitureProfaned/ProfanedDoor.cs b/Items/Placeables/FurnitureProfaned/ProfanedDoor.cs index cc3cc0edfc..6c9903780c 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedDoor.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureProfaned; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedDresser.cs b/Items/Placeables/FurnitureProfaned/ProfanedDresser.cs index ef44ffbe53..64d01680bf 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedDresser.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedDresser.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedPlatform.cs b/Items/Placeables/FurnitureProfaned/ProfanedPlatform.cs index 9594b0fea9..931382311b 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedPlatform.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedPlatform.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { public class ProfanedPlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurnitureProfaned/ProfanedRock.cs b/Items/Placeables/FurnitureProfaned/ProfanedRock.cs index 7a5b532e7c..bb3ca2015c 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedRock.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedRock.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureProfaned CreateRecipe(50). AddRecipeGroup("AnyStoneBlock", 50). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.AdamantiteForge). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/FurnitureProfaned/ProfanedSlab.cs b/Items/Placeables/FurnitureProfaned/ProfanedSlab.cs index c3d7fc12d3..f91de46d0a 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedSlab.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedSlab.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureProfaned { CreateRecipe(5). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.AdamantiteForge). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/FurnitureProfaned/ProfanedTable.cs b/Items/Placeables/FurnitureProfaned/ProfanedTable.cs index 5f2d142261..e9b868bca5 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedTable.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedTable.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/ProfanedWorkBench.cs b/Items/Placeables/FurnitureProfaned/ProfanedWorkBench.cs index 4be7af9875..97a04066df 100644 --- a/Items/Placeables/FurnitureProfaned/ProfanedWorkBench.cs +++ b/Items/Placeables/FurnitureProfaned/ProfanedWorkBench.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureProfaned; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureProfaned { diff --git a/Items/Placeables/FurnitureProfaned/RunicProfanedBrick.cs b/Items/Placeables/FurnitureProfaned/RunicProfanedBrick.cs index b975aced10..1e8e4c6e6e 100644 --- a/Items/Placeables/FurnitureProfaned/RunicProfanedBrick.cs +++ b/Items/Placeables/FurnitureProfaned/RunicProfanedBrick.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureProfaned CreateRecipe(5). AddIngredient(4). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.AdamantiteForge). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/FurnitureRunestone/RunestoneTerracotta.cs b/Items/Placeables/FurnitureRunestone/RunestoneTerracotta.cs new file mode 100644 index 0000000000..dc3a3ca126 --- /dev/null +++ b/Items/Placeables/FurnitureRunestone/RunestoneTerracotta.cs @@ -0,0 +1,26 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureRunestone +{ + public class RunestoneTerracotta : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + //public override void AddRecipes() + //{ + // CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + //} + + } +} diff --git a/Items/Placeables/FurnitureRunestone/RunestoneTerracotta.png b/Items/Placeables/FurnitureRunestone/RunestoneTerracotta.png new file mode 100644 index 0000000000..32329b4f68 Binary files /dev/null and b/Items/Placeables/FurnitureRunestone/RunestoneTerracotta.png differ diff --git a/Items/Placeables/FurnitureSacrilegious/MonolithOfTheAccursed.cs b/Items/Placeables/FurnitureSacrilegious/MonolithOfTheAccursed.cs index 5e31836e98..5bf0a81081 100644 --- a/Items/Placeables/FurnitureSacrilegious/MonolithOfTheAccursed.cs +++ b/Items/Placeables/FurnitureSacrilegious/MonolithOfTheAccursed.cs @@ -2,7 +2,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { @@ -13,7 +12,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { Item.DefaultToPlaceableTile(ModContent.TileType()); Item.value = Item.sellPrice(gold: 1); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.accessory = true; Item.vanity = true; } diff --git a/Items/Placeables/FurnitureSacrilegious/OccultPlatformItem.cs b/Items/Placeables/FurnitureSacrilegious/OccultPlatformItem.cs index c59182ad6c..ccdfd41f48 100644 --- a/Items/Placeables/FurnitureSacrilegious/OccultPlatformItem.cs +++ b/Items/Placeables/FurnitureSacrilegious/OccultPlatformItem.cs @@ -1,5 +1,4 @@ using CalamityMod.Tiles.FurnitureSacrilegious; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousBathtub.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousBathtub.cs index 9055b46e21..b94b4d91ee 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousBathtub.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousBathtub.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousBench.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousBench.cs index 376060634c..b83335e967 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousBench.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousBench.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousChair.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousChair.cs index ff313d9ef1..342dc01198 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousChair.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousChair.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousChest.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousChest.cs index 78345310da..c2945fe29f 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousChest.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousChest.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousDoor.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousDoor.cs index e4c05e2136..ce305986cb 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousDoor.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousDresser.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousDresser.cs index 2299f9070d..9aa2ac9dad 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousDresser.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousDresser.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousTable.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousTable.cs index 0c9fe5f09f..7ec08090de 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousTable.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousTable.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureSacrilegious/SacrilegiousWorkBench.cs b/Items/Placeables/FurnitureSacrilegious/SacrilegiousWorkBench.cs index fe6b642038..90cf1fc55f 100644 --- a/Items/Placeables/FurnitureSacrilegious/SacrilegiousWorkBench.cs +++ b/Items/Placeables/FurnitureSacrilegious/SacrilegiousWorkBench.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureSacrilegious; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSacrilegious { diff --git a/Items/Placeables/FurnitureShellstone/ShellTrimBrick.cs b/Items/Placeables/FurnitureShellstone/ShellTrimBrick.cs new file mode 100644 index 0000000000..5045c596a8 --- /dev/null +++ b/Items/Placeables/FurnitureShellstone/ShellTrimBrick.cs @@ -0,0 +1,28 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureShellstone +{ + public class ShellTrimBrick : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + //public override void AddRecipes() + //{ + // CreateRecipe(). + // AddIngredient(). + // AddTile(TileID.HeavyWorkBench). + // Register(); + // CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + //} + } +} diff --git a/Items/Placeables/FurnitureShellstone/ShellTrimBrick.png b/Items/Placeables/FurnitureShellstone/ShellTrimBrick.png new file mode 100644 index 0000000000..532dc11562 Binary files /dev/null and b/Items/Placeables/FurnitureShellstone/ShellTrimBrick.png differ diff --git a/Items/Placeables/FurnitureShellstone/ShellstoneSlab.cs b/Items/Placeables/FurnitureShellstone/ShellstoneSlab.cs new file mode 100644 index 0000000000..294482fc1d --- /dev/null +++ b/Items/Placeables/FurnitureShellstone/ShellstoneSlab.cs @@ -0,0 +1,30 @@ +using CalamityMod.Items.Placeables.Walls; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Items.Placeables.SunkenSea; +namespace CalamityMod.Items.Placeables.FurnitureShellstone +{ + public class ShellstoneSlab : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + DisableDecraft(). + Register(); + } + } +} diff --git a/Items/Placeables/SunkenSea/ShellstoneSlab.png b/Items/Placeables/FurnitureShellstone/ShellstoneSlab.png similarity index 100% rename from Items/Placeables/SunkenSea/ShellstoneSlab.png rename to Items/Placeables/FurnitureShellstone/ShellstoneSlab.png diff --git a/Items/Placeables/FurnitureSilva/SilvaBasin.cs b/Items/Placeables/FurnitureSilva/SilvaBasin.cs new file mode 100644 index 0000000000..b91fdbffef --- /dev/null +++ b/Items/Placeables/FurnitureSilva/SilvaBasin.cs @@ -0,0 +1,26 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureSilva +{ + [LegacyName("EffulgentManipulator")] + public class SilvaBasin : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(gold: 2); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddRecipeGroup("AnyGoldBar", 5). + AddTile(TileID.GlassKiln). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CraftingStations/EffulgentManipulator.png b/Items/Placeables/FurnitureSilva/SilvaBasin.png similarity index 100% rename from Items/Placeables/Furniture/CraftingStations/EffulgentManipulator.png rename to Items/Placeables/FurnitureSilva/SilvaBasin.png diff --git a/Items/Placeables/FurnitureSilva/SilvaBathtub.cs b/Items/Placeables/FurnitureSilva/SilvaBathtub.cs index 1334cde423..a109f09a06 100644 --- a/Items/Placeables/FurnitureSilva/SilvaBathtub.cs +++ b/Items/Placeables/FurnitureSilva/SilvaBathtub.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva { CreateRecipe(). AddIngredient(14). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaBed.cs b/Items/Placeables/FurnitureSilva/SilvaBed.cs index 3d0c73f109..404bcd9a4f 100644 --- a/Items/Placeables/FurnitureSilva/SilvaBed.cs +++ b/Items/Placeables/FurnitureSilva/SilvaBed.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaBench.cs b/Items/Placeables/FurnitureSilva/SilvaBench.cs index 333fed0272..e8bca0877e 100644 --- a/Items/Placeables/FurnitureSilva/SilvaBench.cs +++ b/Items/Placeables/FurnitureSilva/SilvaBench.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaBookcase.cs b/Items/Placeables/FurnitureSilva/SilvaBookcase.cs index f036b18c6e..68a8246dc2 100644 --- a/Items/Placeables/FurnitureSilva/SilvaBookcase.cs +++ b/Items/Placeables/FurnitureSilva/SilvaBookcase.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaCandelabra.cs b/Items/Placeables/FurnitureSilva/SilvaCandelabra.cs index 92ae20f92e..7c9074d375 100644 --- a/Items/Placeables/FurnitureSilva/SilvaCandelabra.cs +++ b/Items/Placeables/FurnitureSilva/SilvaCandelabra.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Torch, 3). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaCandle.cs b/Items/Placeables/FurnitureSilva/SilvaCandle.cs index b5bedb72c0..ae43368e18 100644 --- a/Items/Placeables/FurnitureSilva/SilvaCandle.cs +++ b/Items/Placeables/FurnitureSilva/SilvaCandle.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaChair.cs b/Items/Placeables/FurnitureSilva/SilvaChair.cs index 276ece5d5b..4135573921 100644 --- a/Items/Placeables/FurnitureSilva/SilvaChair.cs +++ b/Items/Placeables/FurnitureSilva/SilvaChair.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva { CreateRecipe(). AddIngredient(4). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaChandelier.cs b/Items/Placeables/FurnitureSilva/SilvaChandelier.cs index a10990fdd0..7c7821ca93 100644 --- a/Items/Placeables/FurnitureSilva/SilvaChandelier.cs +++ b/Items/Placeables/FurnitureSilva/SilvaChandelier.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaChest.cs b/Items/Placeables/FurnitureSilva/SilvaChest.cs index dc123f5db8..3128e30199 100644 --- a/Items/Placeables/FurnitureSilva/SilvaChest.cs +++ b/Items/Placeables/FurnitureSilva/SilvaChest.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(8). AddRecipeGroup("IronBar", 2). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaClock.cs b/Items/Placeables/FurnitureSilva/SilvaClock.cs index f4afb5cf0e..a4dc909210 100644 --- a/Items/Placeables/FurnitureSilva/SilvaClock.cs +++ b/Items/Placeables/FurnitureSilva/SilvaClock.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaDoor.cs b/Items/Placeables/FurnitureSilva/SilvaDoor.cs index 703348131f..00be5801df 100644 --- a/Items/Placeables/FurnitureSilva/SilvaDoor.cs +++ b/Items/Placeables/FurnitureSilva/SilvaDoor.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureSilva; +using CalamityMod.Tiles.FurnitureSilva; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva { CreateRecipe(). AddIngredient(6). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaDresser.cs b/Items/Placeables/FurnitureSilva/SilvaDresser.cs index 7f149b01f1..158e6b4aef 100644 --- a/Items/Placeables/FurnitureSilva/SilvaDresser.cs +++ b/Items/Placeables/FurnitureSilva/SilvaDresser.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva { CreateRecipe(). AddIngredient(16). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaLamp.cs b/Items/Placeables/FurnitureSilva/SilvaLamp.cs index 336d5e4d8e..3533568656 100644 --- a/Items/Placeables/FurnitureSilva/SilvaLamp.cs +++ b/Items/Placeables/FurnitureSilva/SilvaLamp.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaLantern.cs b/Items/Placeables/FurnitureSilva/SilvaLantern.cs index bcd188b58c..b00e828229 100644 --- a/Items/Placeables/FurnitureSilva/SilvaLantern.cs +++ b/Items/Placeables/FurnitureSilva/SilvaLantern.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaPiano.cs b/Items/Placeables/FurnitureSilva/SilvaPiano.cs index 619ac5cdc8..9c86fa732b 100644 --- a/Items/Placeables/FurnitureSilva/SilvaPiano.cs +++ b/Items/Placeables/FurnitureSilva/SilvaPiano.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaPlatform.cs b/Items/Placeables/FurnitureSilva/SilvaPlatform.cs index b83a3a955e..4093c06ea2 100644 --- a/Items/Placeables/FurnitureSilva/SilvaPlatform.cs +++ b/Items/Placeables/FurnitureSilva/SilvaPlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva { public class SilvaPlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurnitureSilva/SilvaSink.cs b/Items/Placeables/FurnitureSilva/SilvaSink.cs index 56e6f60507..d38592c3a1 100644 --- a/Items/Placeables/FurnitureSilva/SilvaSink.cs +++ b/Items/Placeables/FurnitureSilva/SilvaSink.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.WaterBucket). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaTable.cs b/Items/Placeables/FurnitureSilva/SilvaTable.cs index 8b0175b74c..3942997069 100644 --- a/Items/Placeables/FurnitureSilva/SilvaTable.cs +++ b/Items/Placeables/FurnitureSilva/SilvaTable.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureSilva/SilvaWorkBench.cs b/Items/Placeables/FurnitureSilva/SilvaWorkBench.cs index 4311048e5d..94d89ebd47 100644 --- a/Items/Placeables/FurnitureSilva/SilvaWorkBench.cs +++ b/Items/Placeables/FurnitureSilva/SilvaWorkBench.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureSilva @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva { CreateRecipe(). AddIngredient(10). - AddTile(). + AddTile(TileID.GlassKiln). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StaticRefiner.cs b/Items/Placeables/FurnitureStatigel/StaticRefiner.cs new file mode 100644 index 0000000000..3cb6680fe6 --- /dev/null +++ b/Items/Placeables/FurnitureStatigel/StaticRefiner.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureStatigel +{ + public class StaticRefiner : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(gold: 2); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.Solidifier). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CraftingStations/StaticRefiner.png b/Items/Placeables/FurnitureStatigel/StaticRefiner.png similarity index 100% rename from Items/Placeables/Furniture/CraftingStations/StaticRefiner.png rename to Items/Placeables/FurnitureStatigel/StaticRefiner.png diff --git a/Items/Placeables/FurnitureStatigel/StatigelBathtub.cs b/Items/Placeables/FurnitureStatigel/StatigelBathtub.cs index 3f7fc58b21..ca8371c398 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelBathtub.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelBathtub.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel { CreateRecipe(). AddIngredient(14). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelBed.cs b/Items/Placeables/FurnitureStatigel/StatigelBed.cs index cafa39bbcf..522abe259c 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelBed.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelBed.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelBlock.cs b/Items/Placeables/FurnitureStatigel/StatigelBlock.cs index d28fcccc64..6cbc71256f 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelBlock.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelBlock.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria.ID; using Terraria.ModLoader; @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel { CreateRecipe(25). AddIngredient(). - AddTile(). + AddTile(TileID.Solidifier). Register(); CreateRecipe(). AddIngredient(2). diff --git a/Items/Placeables/FurnitureStatigel/StatigelBookcase.cs b/Items/Placeables/FurnitureStatigel/StatigelBookcase.cs index 148c98fbc4..3ece311866 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelBookcase.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelBookcase.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelCandelabra.cs b/Items/Placeables/FurnitureStatigel/StatigelCandelabra.cs index 4cab592c8a..18869b8b4a 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelCandelabra.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelCandelabra.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Torch, 3). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelCandle.cs b/Items/Placeables/FurnitureStatigel/StatigelCandle.cs index 2b615e086a..5b9c4b484f 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelCandle.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelCandle.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelChair.cs b/Items/Placeables/FurnitureStatigel/StatigelChair.cs index 5a67a9131a..b788147405 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelChair.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelChair.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel { CreateRecipe(). AddIngredient(4). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelChandelier.cs b/Items/Placeables/FurnitureStatigel/StatigelChandelier.cs index 08014dcb98..52188951e8 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelChandelier.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelChandelier.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelChest.cs b/Items/Placeables/FurnitureStatigel/StatigelChest.cs index 751521bc2a..f13a3d54d8 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelChest.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelChest.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(8). AddRecipeGroup("IronBar", 2). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelClock.cs b/Items/Placeables/FurnitureStatigel/StatigelClock.cs index a3ad4e7f12..eae100c052 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelClock.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelClock.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelDoor.cs b/Items/Placeables/FurnitureStatigel/StatigelDoor.cs index 583efa5451..b1fb823a18 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelDoor.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelDoor.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureStatigel; +using CalamityMod.Tiles.FurnitureStatigel; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel { CreateRecipe(). AddIngredient(6). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelDresser.cs b/Items/Placeables/FurnitureStatigel/StatigelDresser.cs index 59b759b84c..6f90cd7f3e 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelDresser.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelDresser.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel { CreateRecipe(). AddIngredient(16). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelLamp.cs b/Items/Placeables/FurnitureStatigel/StatigelLamp.cs index 01f6b7453c..fd947260c4 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelLamp.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelLamp.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelLantern.cs b/Items/Placeables/FurnitureStatigel/StatigelLantern.cs index 8eea59ba86..632cdf1874 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelLantern.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelLantern.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelPiano.cs b/Items/Placeables/FurnitureStatigel/StatigelPiano.cs index 05b1cd26fd..ddfcc1c85f 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelPiano.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelPiano.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelPlatform.cs b/Items/Placeables/FurnitureStatigel/StatigelPlatform.cs index 51b059ea36..9bf0cf0ef1 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelPlatform.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelPlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel { public class StatigelPlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurnitureStatigel/StatigelSink.cs b/Items/Placeables/FurnitureStatigel/StatigelSink.cs index 4f62ce1aca..6476dbe6e5 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelSink.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelSink.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.WaterBucket). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelSofa.cs b/Items/Placeables/FurnitureStatigel/StatigelSofa.cs index 15e53c4ebc..1a57a1115e 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelSofa.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelSofa.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Silk, 2). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelTable.cs b/Items/Placeables/FurnitureStatigel/StatigelTable.cs index db940dd1d7..5f9b7e22d4 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelTable.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelTable.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStatigel @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStatigel/StatigelWorkBench.cs b/Items/Placeables/FurnitureStatigel/StatigelWorkBench.cs index e284ee43ed..a866eeb6ca 100644 --- a/Items/Placeables/FurnitureStatigel/StatigelWorkBench.cs +++ b/Items/Placeables/FurnitureStatigel/StatigelWorkBench.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureStatigel; +using CalamityMod.Tiles.FurnitureStatigel; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStatigel { CreateRecipe(). AddIngredient(10). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusBathtub.cs b/Items/Placeables/FurnitureStratus/StratusBathtub.cs index 3f5e3b6b76..fed24d4ca4 100644 --- a/Items/Placeables/FurnitureStratus/StratusBathtub.cs +++ b/Items/Placeables/FurnitureStratus/StratusBathtub.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { @@ -16,7 +15,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus { CreateRecipe(). AddIngredient(14). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusBed.cs b/Items/Placeables/FurnitureStratus/StratusBed.cs index 6ce98dccab..3a23cd3b1e 100644 --- a/Items/Placeables/FurnitureStratus/StratusBed.cs +++ b/Items/Placeables/FurnitureStratus/StratusBed.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusBookcase.cs b/Items/Placeables/FurnitureStratus/StratusBookcase.cs index 558a78bfec..63064b76b9 100644 --- a/Items/Placeables/FurnitureStratus/StratusBookcase.cs +++ b/Items/Placeables/FurnitureStratus/StratusBookcase.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusBricks.cs b/Items/Placeables/FurnitureStratus/StratusBricks.cs index c8e4ecead9..64080d7e9c 100644 --- a/Items/Placeables/FurnitureStratus/StratusBricks.cs +++ b/Items/Placeables/FurnitureStratus/StratusBricks.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus AddIngredient(3). AddIngredient(). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/FurnitureStratus/StratusCandelabra.cs b/Items/Placeables/FurnitureStratus/StratusCandelabra.cs index 3f4a616950..29b342236a 100644 --- a/Items/Placeables/FurnitureStratus/StratusCandelabra.cs +++ b/Items/Placeables/FurnitureStratus/StratusCandelabra.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Torch, 3). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusCandle.cs b/Items/Placeables/FurnitureStratus/StratusCandle.cs index 1e0c3bc8ea..6a60ac11de 100644 --- a/Items/Placeables/FurnitureStratus/StratusCandle.cs +++ b/Items/Placeables/FurnitureStratus/StratusCandle.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusChair.cs b/Items/Placeables/FurnitureStratus/StratusChair.cs index 20dd9f148d..a0c3c9134d 100644 --- a/Items/Placeables/FurnitureStratus/StratusChair.cs +++ b/Items/Placeables/FurnitureStratus/StratusChair.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { @@ -16,7 +15,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus { CreateRecipe(). AddIngredient(4). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusChandelier.cs b/Items/Placeables/FurnitureStratus/StratusChandelier.cs index 84b7f7fe5d..bd8fb08464 100644 --- a/Items/Placeables/FurnitureStratus/StratusChandelier.cs +++ b/Items/Placeables/FurnitureStratus/StratusChandelier.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusChest.cs b/Items/Placeables/FurnitureStratus/StratusChest.cs index 9137ca711c..560e5c31e8 100644 --- a/Items/Placeables/FurnitureStratus/StratusChest.cs +++ b/Items/Placeables/FurnitureStratus/StratusChest.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(8). AddRecipeGroup("IronBar", 2). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusClock.cs b/Items/Placeables/FurnitureStratus/StratusClock.cs index 35591f9dac..c36dd0c39c 100644 --- a/Items/Placeables/FurnitureStratus/StratusClock.cs +++ b/Items/Placeables/FurnitureStratus/StratusClock.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusDoor.cs b/Items/Placeables/FurnitureStratus/StratusDoor.cs index c0086b86cc..a3568b7e5b 100644 --- a/Items/Placeables/FurnitureStratus/StratusDoor.cs +++ b/Items/Placeables/FurnitureStratus/StratusDoor.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.FurnitureStratus; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus { CreateRecipe(). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusDresser.cs b/Items/Placeables/FurnitureStratus/StratusDresser.cs index 3371fd2794..dd286f633e 100644 --- a/Items/Placeables/FurnitureStratus/StratusDresser.cs +++ b/Items/Placeables/FurnitureStratus/StratusDresser.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { @@ -16,7 +15,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus { CreateRecipe(). AddIngredient(16). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusLamp.cs b/Items/Placeables/FurnitureStratus/StratusLamp.cs index 10dd94a614..2b778c19b0 100644 --- a/Items/Placeables/FurnitureStratus/StratusLamp.cs +++ b/Items/Placeables/FurnitureStratus/StratusLamp.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusLantern.cs b/Items/Placeables/FurnitureStratus/StratusLantern.cs index 96d8746e51..0943f5f6ee 100644 --- a/Items/Placeables/FurnitureStratus/StratusLantern.cs +++ b/Items/Placeables/FurnitureStratus/StratusLantern.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusPiano.cs b/Items/Placeables/FurnitureStratus/StratusPiano.cs index daf3753343..2985284bac 100644 --- a/Items/Placeables/FurnitureStratus/StratusPiano.cs +++ b/Items/Placeables/FurnitureStratus/StratusPiano.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusPlatform.cs b/Items/Placeables/FurnitureStratus/StratusPlatform.cs index 1bc9e4a576..2d552e659c 100644 --- a/Items/Placeables/FurnitureStratus/StratusPlatform.cs +++ b/Items/Placeables/FurnitureStratus/StratusPlatform.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { public class StratusPlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurnitureStratus/StratusSink.cs b/Items/Placeables/FurnitureStratus/StratusSink.cs index adbc891824..b1f842dd38 100644 --- a/Items/Placeables/FurnitureStratus/StratusSink.cs +++ b/Items/Placeables/FurnitureStratus/StratusSink.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.WaterBucket). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusSofa.cs b/Items/Placeables/FurnitureStratus/StratusSofa.cs index 53c00d843d..703293629e 100644 --- a/Items/Placeables/FurnitureStratus/StratusSofa.cs +++ b/Items/Placeables/FurnitureStratus/StratusSofa.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Silk, 2). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusStarPlatformItem.cs b/Items/Placeables/FurnitureStratus/StratusStarPlatformItem.cs index bfbfc866ac..cc1d444562 100644 --- a/Items/Placeables/FurnitureStratus/StratusStarPlatformItem.cs +++ b/Items/Placeables/FurnitureStratus/StratusStarPlatformItem.cs @@ -1,5 +1,4 @@ using CalamityMod.Tiles.FurnitureStratus; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus diff --git a/Items/Placeables/FurnitureStratus/StratusTable.cs b/Items/Placeables/FurnitureStratus/StratusTable.cs index dd7749ac4f..fe379213f5 100644 --- a/Items/Placeables/FurnitureStratus/StratusTable.cs +++ b/Items/Placeables/FurnitureStratus/StratusTable.cs @@ -1,5 +1,4 @@ using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { @@ -16,7 +15,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus { CreateRecipe(). AddIngredient(8). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureStratus/StratusWorkBench.cs b/Items/Placeables/FurnitureStratus/StratusWorkBench.cs index 12f8d5edcd..3eb65ebef6 100644 --- a/Items/Placeables/FurnitureStratus/StratusWorkBench.cs +++ b/Items/Placeables/FurnitureStratus/StratusWorkBench.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.FurnitureStratus; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureStratus { @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureStratus { CreateRecipe(). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.cs b/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.cs index 36e1377ed5..882daed7f8 100644 --- a/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.cs +++ b/Items/Placeables/FurnitureVoid/SmoothVoidstonePlatform.cs @@ -1,6 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { public class SmoothVoidstonePlatform : ModItem, ILocalizedModType diff --git a/Items/Placeables/FurnitureVoid/VoidBathtub.cs b/Items/Placeables/FurnitureVoid/VoidBathtub.cs index 44e4bc34a0..39ee5fc062 100644 --- a/Items/Placeables/FurnitureVoid/VoidBathtub.cs +++ b/Items/Placeables/FurnitureVoid/VoidBathtub.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { diff --git a/Items/Placeables/FurnitureVoid/VoidChair.cs b/Items/Placeables/FurnitureVoid/VoidChair.cs index 8ba7af4c53..df176075e6 100644 --- a/Items/Placeables/FurnitureVoid/VoidChair.cs +++ b/Items/Placeables/FurnitureVoid/VoidChair.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { diff --git a/Items/Placeables/FurnitureVoid/VoidChest.cs b/Items/Placeables/FurnitureVoid/VoidChest.cs index 3eba2cb5cf..0991c2a38a 100644 --- a/Items/Placeables/FurnitureVoid/VoidChest.cs +++ b/Items/Placeables/FurnitureVoid/VoidChest.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { diff --git a/Items/Placeables/FurnitureVoid/VoidDoor.cs b/Items/Placeables/FurnitureVoid/VoidDoor.cs index 16addc9a82..f802e36a6c 100644 --- a/Items/Placeables/FurnitureVoid/VoidDoor.cs +++ b/Items/Placeables/FurnitureVoid/VoidDoor.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureVoid; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { diff --git a/Items/Placeables/FurnitureVoid/VoidDresser.cs b/Items/Placeables/FurnitureVoid/VoidDresser.cs index e56e219ec8..fea6319c78 100644 --- a/Items/Placeables/FurnitureVoid/VoidDresser.cs +++ b/Items/Placeables/FurnitureVoid/VoidDresser.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { diff --git a/Items/Placeables/FurnitureVoid/VoidTable.cs b/Items/Placeables/FurnitureVoid/VoidTable.cs index 3e1ad4e28a..46fcf8fc26 100644 --- a/Items/Placeables/FurnitureVoid/VoidTable.cs +++ b/Items/Placeables/FurnitureVoid/VoidTable.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { diff --git a/Items/Placeables/FurnitureVoid/VoidWorkBench.cs b/Items/Placeables/FurnitureVoid/VoidWorkBench.cs index db41e4f1e0..af483639c6 100644 --- a/Items/Placeables/FurnitureVoid/VoidWorkBench.cs +++ b/Items/Placeables/FurnitureVoid/VoidWorkBench.cs @@ -1,7 +1,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.FurnitureVoid; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureVoid { diff --git a/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPanels.cs b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPanels.cs new file mode 100644 index 0000000000..2e81833872 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPanels.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class AnodizedWulfrumPanels : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddRecipeGroup("AnyStoneBlock", 25). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPanels.png b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPanels.png new file mode 100644 index 0000000000..e30cada799 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPanels.png differ diff --git a/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform.cs b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform.cs new file mode 100644 index 0000000000..9564c66148 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform.cs @@ -0,0 +1,30 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class AnodizedWulfrumPlatform : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow").Value); + } + + public override void AddRecipes() + { + CreateRecipe(2). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform.png b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform.png new file mode 100644 index 0000000000..25fbcddcd6 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform.png differ diff --git a/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow.png b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow.png new file mode 100644 index 0000000000..80c89d798a Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow.png differ diff --git a/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumTrim.cs b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumTrim.cs new file mode 100644 index 0000000000..217e10347b --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumTrim.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class AnodizedWulfrumTrim : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddRecipeGroup("AnyStoneBlock", 25). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumTrim.png b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumTrim.png new file mode 100644 index 0000000000..196d3e8e6b Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/AnodizedWulfrumTrim.png differ diff --git a/Items/Placeables/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.cs b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.cs new file mode 100644 index 0000000000..5e8ceacfb0 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class ChargedWulfrumEnergyBarrier : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddIngredient(ItemID.Glass, 25). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.png b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.png new file mode 100644 index 0000000000..0201cfa0e6 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.png differ diff --git a/Items/Placeables/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.cs b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.cs new file mode 100644 index 0000000000..32c04ea235 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.cs @@ -0,0 +1,27 @@ +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class ChargedWulfrumWallMountedBulb : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType ()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.png b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.png new file mode 100644 index 0000000000..e948233679 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.cs new file mode 100644 index 0000000000..de0bfef937 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumBathtub : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.png new file mode 100644 index 0000000000..c8ab44889a Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.cs new file mode 100644 index 0000000000..04cf89d918 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumBookcase : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(20). + AddIngredient(ItemID.Book, 10). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.png new file mode 100644 index 0000000000..57cf58bd96 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.cs new file mode 100644 index 0000000000..8a0e2edd3b --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumChair : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.png new file mode 100644 index 0000000000..649e6f9e82 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.cs new file mode 100644 index 0000000000..e5fddabb38 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.cs @@ -0,0 +1,25 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumChandelier : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch, 4). + AddIngredient(ItemID.Chain). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.png new file mode 100644 index 0000000000..94b71006d0 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.cs new file mode 100644 index 0000000000..d37e281282 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumChest : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddRecipeGroup("IronBar", 2). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.png new file mode 100644 index 0000000000..44df951fe5 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock.png new file mode 100644 index 0000000000..7cb80254aa Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.cs new file mode 100644 index 0000000000..ddb5ace6c6 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumDeskLight : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddIngredient(ItemID.Torch). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.png new file mode 100644 index 0000000000..fad6a339c0 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoor.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoor.cs new file mode 100644 index 0000000000..037fd6d7b9 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoor.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumDoor : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 40); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoor.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoor.png new file mode 100644 index 0000000000..dd4f7de09c Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoor.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.cs new file mode 100644 index 0000000000..f5e8cae536 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumDresser : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(16). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.png new file mode 100644 index 0000000000..b0f8cc58c4 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.cs new file mode 100644 index 0000000000..ce923b21cd --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumJukebox : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.png new file mode 100644 index 0000000000..672db05d5a Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.cs new file mode 100644 index 0000000000..b35cb1a373 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumLamp : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.Torch). + AddIngredient(3). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.png new file mode 100644 index 0000000000..a19882f1b3 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.cs new file mode 100644 index 0000000000..1d75bb050f --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumLantern : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.Torch). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.png new file mode 100644 index 0000000000..8e530f9b95 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.cs new file mode 100644 index 0000000000..4526a0c916 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumSink : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(6). + AddIngredient(ItemID.WaterBucket). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.png new file mode 100644 index 0000000000..c96f440a2b Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.cs new file mode 100644 index 0000000000..658af68ac3 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumSleepingPod : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 4); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(ItemID.Silk, 5). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.png new file mode 100644 index 0000000000..b438294241 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.cs new file mode 100644 index 0000000000..69a1e5c83e --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumSofa : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.Silk, 2). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.png new file mode 100644 index 0000000000..c848b79b7c Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.cs new file mode 100644 index 0000000000..c2b55a269d --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumTable : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 60); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.png new file mode 100644 index 0000000000..b24d120326 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.cs new file mode 100644 index 0000000000..e453b0d63a --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumToilet : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.png new file mode 100644 index 0000000000..5483bcf85a Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.png differ diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.cs b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.cs new file mode 100644 index 0000000000..13ac5b9cef --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumWorkBench : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(copper: 30); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.png b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.png new file mode 100644 index 0000000000..b066974f66 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.png differ diff --git a/Items/Placeables/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.cs b/Items/Placeables/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.cs new file mode 100644 index 0000000000..efdd3e9678 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.cs @@ -0,0 +1,32 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class RoundedAnodizedWulfrumPanels : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddRecipeGroup("AnyStoneBlock", 25). + AddIngredient(). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.png b/Items/Placeables/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.png new file mode 100644 index 0000000000..597351bb01 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumBathtub.cs b/Items/Placeables/FurnitureWulfrum/WulfrumBathtub.cs index 45519cd146..d8c0fc528e 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumBathtub.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumBathtub.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum { CreateRecipe(). AddIngredient(14). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumBed.cs b/Items/Placeables/FurnitureWulfrum/WulfrumBed.cs index dba6f46033..d3cdabc118 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumBed.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumBed.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(15). AddIngredient(ItemID.Silk, 5). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumBookcase.cs b/Items/Placeables/FurnitureWulfrum/WulfrumBookcase.cs index 183ac5df10..865bb7ba0b 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumBookcase.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumBookcase.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -19,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(20). AddIngredient(ItemID.Book, 10). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumCandelabra.cs b/Items/Placeables/FurnitureWulfrum/WulfrumCandelabra.cs index 6f0a7e44f5..d6a0dc1b60 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumCandelabra.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumCandelabra.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Torch, 3). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumCandle.cs b/Items/Placeables/FurnitureWulfrum/WulfrumCandle.cs index be884f8399..c1e7d67c4a 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumCandle.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumCandle.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(4). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumChair.cs b/Items/Placeables/FurnitureWulfrum/WulfrumChair.cs index 87ee331186..2459975308 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumChair.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumChair.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum { CreateRecipe(). AddIngredient(4). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumChandelier.cs b/Items/Placeables/FurnitureWulfrum/WulfrumChandelier.cs index d023bcca90..c54dfbcdba 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumChandelier.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumChandelier.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum AddIngredient(4). AddIngredient(ItemID.Torch, 4). AddIngredient(ItemID.Chain). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumChest.cs b/Items/Placeables/FurnitureWulfrum/WulfrumChest.cs index 16228bfe97..7bbd7662a1 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumChest.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumChest.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(10). AddRecipeGroup("IronBar", 2). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumClock.cs b/Items/Placeables/FurnitureWulfrum/WulfrumClock.cs index fd29ef50dc..12281f55d8 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumClock.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumClock.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum AddIngredient(10). AddRecipeGroup("IronBar", 3). AddIngredient(ItemID.Glass, 6). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumDresser.cs b/Items/Placeables/FurnitureWulfrum/WulfrumDresser.cs index e18969357f..b8ed0620f2 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumDresser.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumDresser.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum { CreateRecipe(). AddIngredient(16). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumEnergyBarrier.cs b/Items/Placeables/FurnitureWulfrum/WulfrumEnergyBarrier.cs new file mode 100644 index 0000000000..d59706138c --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/WulfrumEnergyBarrier.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class WulfrumEnergyBarrier : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddIngredient(ItemID.Glass, 25). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumEnergyBarrier.png b/Items/Placeables/FurnitureWulfrum/WulfrumEnergyBarrier.png new file mode 100644 index 0000000000..22b1dacbc8 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/WulfrumEnergyBarrier.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumLabstationItem.cs b/Items/Placeables/FurnitureWulfrum/WulfrumLabstationItem.cs new file mode 100644 index 0000000000..c9957e338c --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/WulfrumLabstationItem.cs @@ -0,0 +1,22 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class WulfrumLabstationItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.value = Item.sellPrice(silver: 1); // This is REALLY too easy to craft to sell for 2 gold + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(20). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/Furniture/CraftingStations/WulfrumLabstationItem.png b/Items/Placeables/FurnitureWulfrum/WulfrumLabstationItem.png similarity index 100% rename from Items/Placeables/Furniture/CraftingStations/WulfrumLabstationItem.png rename to Items/Placeables/FurnitureWulfrum/WulfrumLabstationItem.png diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumLamp.cs b/Items/Placeables/FurnitureWulfrum/WulfrumLamp.cs index b271efdb91..396b06b659 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumLamp.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumLamp.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(3). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumLantern.cs b/Items/Placeables/FurnitureWulfrum/WulfrumLantern.cs index 72ebb8ebc3..91fb23650e 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumLantern.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumLantern.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.Torch). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumPanels.cs b/Items/Placeables/FurnitureWulfrum/WulfrumPanels.cs new file mode 100644 index 0000000000..d1a1221b0a --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/WulfrumPanels.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class WulfrumPanels : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddRecipeGroup("AnyStoneBlock", 25). + AddIngredient(). + AddTile(TileID.Furnaces). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumPanels.png b/Items/Placeables/FurnitureWulfrum/WulfrumPanels.png new file mode 100644 index 0000000000..b7ba3e50a9 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/WulfrumPanels.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumPiano.cs b/Items/Placeables/FurnitureWulfrum/WulfrumPiano.cs index 1000898784..1000227421 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumPiano.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumPiano.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum AddIngredient(15). AddIngredient(ItemID.Bone, 4). AddIngredient(ItemID.Book). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumPlatform.cs b/Items/Placeables/FurnitureWulfrum/WulfrumPlatform.cs new file mode 100644 index 0000000000..40b2838e84 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/WulfrumPlatform.cs @@ -0,0 +1,30 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class WulfrumPlatform : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Placeables/FurnitureWulfrum/WulfrumPlatform_Glow").Value); + } + + public override void AddRecipes() + { + CreateRecipe(2). + AddIngredient(). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumPlatform.png b/Items/Placeables/FurnitureWulfrum/WulfrumPlatform.png new file mode 100644 index 0000000000..d91c28ed3f Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/WulfrumPlatform.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumPlatform_Glow.png b/Items/Placeables/FurnitureWulfrum/WulfrumPlatform_Glow.png new file mode 100644 index 0000000000..9cc33827ee Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/WulfrumPlatform_Glow.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumPlating.cs b/Items/Placeables/FurnitureWulfrum/WulfrumPlating.cs index f77b24e65e..a77f27331c 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumPlating.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumPlating.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(25). AddRecipeGroup("AnyStoneBlock", 25). AddIngredient(). - AddTile(TileID.HeavyWorkBench). + AddTile(TileID.Furnaces). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumSheets.cs b/Items/Placeables/FurnitureWulfrum/WulfrumSheets.cs new file mode 100644 index 0000000000..b88c79d9c1 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/WulfrumSheets.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class WulfrumSheets : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddRecipeGroup("AnyStoneBlock", 25). + AddIngredient(). + AddTile(TileID.Furnaces). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumSheets.png b/Items/Placeables/FurnitureWulfrum/WulfrumSheets.png new file mode 100644 index 0000000000..2d29605930 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/WulfrumSheets.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumSiding.cs b/Items/Placeables/FurnitureWulfrum/WulfrumSiding.cs new file mode 100644 index 0000000000..a10cbbc284 --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/WulfrumSiding.cs @@ -0,0 +1,32 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class WulfrumSiding : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + + public override void AddRecipes() + { + CreateRecipe(25). + AddRecipeGroup("AnyStoneBlock", 25). + AddIngredient(). + AddIngredient(). + AddTile(TileID.Furnaces). + Register(); + //CreateRecipe(). + // AddIngredient(4). + // AddTile(TileID.WorkBenches). + // DisableDecraft(). + // Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumSiding.png b/Items/Placeables/FurnitureWulfrum/WulfrumSiding.png new file mode 100644 index 0000000000..462a2ce24d Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/WulfrumSiding.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumSink.cs b/Items/Placeables/FurnitureWulfrum/WulfrumSink.cs index 5cff22aca0..339254b0d9 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumSink.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumSink.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.WaterBucket). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumSofa.cs b/Items/Placeables/FurnitureWulfrum/WulfrumSofa.cs index bc87369619..3309550a1f 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumSofa.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumSofa.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum CreateRecipe(). AddIngredient(5). AddIngredient(ItemID.Silk, 2). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumTable.cs b/Items/Placeables/FurnitureWulfrum/WulfrumTable.cs index 9f4ca75337..cb2f4bc261 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumTable.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumTable.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum { CreateRecipe(). AddIngredient(8). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumToilet.cs b/Items/Placeables/FurnitureWulfrum/WulfrumToilet.cs index bb8189d1d8..60b8d9a426 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumToilet.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumToilet.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.FurnitureWulfrum @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum { CreateRecipe(). AddIngredient(6). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumWallMountedBulb.cs b/Items/Placeables/FurnitureWulfrum/WulfrumWallMountedBulb.cs new file mode 100644 index 0000000000..2c5ea085bb --- /dev/null +++ b/Items/Placeables/FurnitureWulfrum/WulfrumWallMountedBulb.cs @@ -0,0 +1,27 @@ +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.FurnitureWulfrum +{ + public class WulfrumWallMountedBulb : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType ()); + Item.value = Item.sellPrice(silver: 1); + } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumWallMountedBulb.png b/Items/Placeables/FurnitureWulfrum/WulfrumWallMountedBulb.png new file mode 100644 index 0000000000..fa3672d7d4 Binary files /dev/null and b/Items/Placeables/FurnitureWulfrum/WulfrumWallMountedBulb.png differ diff --git a/Items/Placeables/FurnitureWulfrum/WulfrumWorkBench.cs b/Items/Placeables/FurnitureWulfrum/WulfrumWorkBench.cs index a4b4e96e4a..fdcd025f6b 100644 --- a/Items/Placeables/FurnitureWulfrum/WulfrumWorkBench.cs +++ b/Items/Placeables/FurnitureWulfrum/WulfrumWorkBench.cs @@ -1,5 +1,4 @@ -using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.Tiles.FurnitureWulfrum; +using CalamityMod.Tiles.FurnitureWulfrum; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Placeables.FurnitureWulfrum { CreateRecipe(). AddIngredient(10). - AddTile(). + AddTile(TileID.HeavyWorkBench). Register(); } } diff --git a/Items/Placeables/Ores/AstralOre.cs b/Items/Placeables/Ores/AstralOre.cs index d9114c0a60..8f0c0115b2 100644 --- a/Items/Placeables/Ores/AstralOre.cs +++ b/Items/Placeables/Ores/AstralOre.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -11,6 +12,7 @@ namespace CalamityMod.Items.Placeables.Ores { Item.ResearchUnlockCount = 100; ItemID.Sets.SortingPriorityMaterials[Type] = 99; // Luminite + ItemTrader.ChlorophyteExtractinator.AddOption_OneWay(Type, 1, ItemID.Meteorite, 1); } public override void SetDefaults() diff --git a/Items/Placeables/Ores/AuricOre.cs b/Items/Placeables/Ores/AuricOre.cs index e4d55a7f3f..0d313efc82 100644 --- a/Items/Placeables/Ores/AuricOre.cs +++ b/Items/Placeables/Ores/AuricOre.cs @@ -18,13 +18,13 @@ namespace CalamityMod.Items.Placeables.Ores public override void SetDefaults() { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(silver: 50); - Item.rare = ModContent.RarityType(); + Item.value = Item.sellPrice(silver: 60); + Item.rare = ModContent.RarityType(); } public override void AddRecipes() { - CreateRecipe(30). + CreateRecipe(10). AddIngredient(). AddCondition(Condition.NearShimmer). Register(); diff --git a/Items/Placeables/Ores/ExodiumCluster.png b/Items/Placeables/Ores/ExodiumCluster.png index 7baedbf6af..2375afce0a 100644 Binary files a/Items/Placeables/Ores/ExodiumCluster.png and b/Items/Placeables/Ores/ExodiumCluster.png differ diff --git a/Items/Placeables/PlaceableTurrets/FireTurret.cs b/Items/Placeables/PlaceableTurrets/FireTurret.cs index f2494e86fd..a6c8034db8 100644 --- a/Items/Placeables/PlaceableTurrets/FireTurret.cs +++ b/Items/Placeables/PlaceableTurrets/FireTurret.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Pink; } diff --git a/Items/Placeables/PlaceableTurrets/HostileFireTurret.cs b/Items/Placeables/PlaceableTurrets/HostileFireTurret.cs index 81788cba31..e71a454a82 100644 --- a/Items/Placeables/PlaceableTurrets/HostileFireTurret.cs +++ b/Items/Placeables/PlaceableTurrets/HostileFireTurret.cs @@ -1,4 +1,9 @@ -using Terraria; +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Plates; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,8 +17,22 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Pink; } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddIngredient(20). + AddIngredient(10). + AddIngredient(12). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). + AddCondition(Condition.InGraveyard). + AddTile(TileID.MythrilAnvil). + Register(); + } } } diff --git a/Items/Placeables/PlaceableTurrets/HostileIceTurret.cs b/Items/Placeables/PlaceableTurrets/HostileIceTurret.cs index 703b0d5d1e..14465b824c 100644 --- a/Items/Placeables/PlaceableTurrets/HostileIceTurret.cs +++ b/Items/Placeables/PlaceableTurrets/HostileIceTurret.cs @@ -1,4 +1,9 @@ -using Terraria; +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Plates; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,8 +17,22 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Pink; } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddIngredient(20). + AddIngredient(10). + AddIngredient(12). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). + AddCondition(Condition.InGraveyard). + AddTile(TileID.MythrilAnvil). + Register(); + } } } diff --git a/Items/Placeables/PlaceableTurrets/HostileLabTurret.cs b/Items/Placeables/PlaceableTurrets/HostileLabTurret.cs index 1025683d72..c205b4c5e1 100644 --- a/Items/Placeables/PlaceableTurrets/HostileLabTurret.cs +++ b/Items/Placeables/PlaceableTurrets/HostileLabTurret.cs @@ -1,4 +1,8 @@ -using Terraria; +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,8 +16,20 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 1); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Orange; } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddIngredient(20). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). + AddCondition(Condition.InGraveyard). + AddTile(TileID.Anvils). + Register(); + } } } diff --git a/Items/Placeables/PlaceableTurrets/HostileLaserTurret.cs b/Items/Placeables/PlaceableTurrets/HostileLaserTurret.cs index 259a7deefa..721ae5cb19 100644 --- a/Items/Placeables/PlaceableTurrets/HostileLaserTurret.cs +++ b/Items/Placeables/PlaceableTurrets/HostileLaserTurret.cs @@ -1,4 +1,9 @@ -using Terraria; +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Plates; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,8 +17,22 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Pink; } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddIngredient(20). + AddIngredient(10). + AddIngredient(12). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). + AddTile(TileID.MythrilAnvil). + AddCondition(Condition.InGraveyard). + Register(); + } } } diff --git a/Items/Placeables/PlaceableTurrets/HostileOnyxTurret.cs b/Items/Placeables/PlaceableTurrets/HostileOnyxTurret.cs index e8325902a8..8805f64449 100644 --- a/Items/Placeables/PlaceableTurrets/HostileOnyxTurret.cs +++ b/Items/Placeables/PlaceableTurrets/HostileOnyxTurret.cs @@ -1,4 +1,9 @@ -using Terraria; +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Plates; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,8 +17,22 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 1); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Orange; } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddIngredient(20). + AddIngredient(10). + AddIngredient(50). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). + AddCondition(Condition.InGraveyard). + AddTile(TileID.Anvils). + Register(); + } } } diff --git a/Items/Placeables/PlaceableTurrets/HostilePlagueTurret.cs b/Items/Placeables/PlaceableTurrets/HostilePlagueTurret.cs index c98f5193fd..d1e5aeade1 100644 --- a/Items/Placeables/PlaceableTurrets/HostilePlagueTurret.cs +++ b/Items/Placeables/PlaceableTurrets/HostilePlagueTurret.cs @@ -1,4 +1,9 @@ -using Terraria; +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Plates; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,8 +17,22 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 4); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Yellow; } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddIngredient(20). + AddIngredient(10). + AddIngredient(12). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func condition), condition). + AddCondition(Condition.InGraveyard). + AddTile(TileID.MythrilAnvil). + Register(); + } } } diff --git a/Items/Placeables/PlaceableTurrets/HostileWaterTurret.cs b/Items/Placeables/PlaceableTurrets/HostileWaterTurret.cs index bd7c54752c..4dbe4ba55a 100644 --- a/Items/Placeables/PlaceableTurrets/HostileWaterTurret.cs +++ b/Items/Placeables/PlaceableTurrets/HostileWaterTurret.cs @@ -1,4 +1,9 @@ -using Terraria; +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Plates; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,8 +17,21 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 1); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Orange; } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(14). + AddIngredient(20). + AddIngredient(10). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). + AddCondition(Condition.InGraveyard). + AddTile(TileID.Anvils). + Register(); + } } } diff --git a/Items/Placeables/PlaceableTurrets/IceTurret.cs b/Items/Placeables/PlaceableTurrets/IceTurret.cs index 5882121585..de0562566d 100644 --- a/Items/Placeables/PlaceableTurrets/IceTurret.cs +++ b/Items/Placeables/PlaceableTurrets/IceTurret.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Pink; } @@ -31,6 +31,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets AddIngredient(12). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). AddTile(TileID.MythrilAnvil). + SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } } diff --git a/Items/Placeables/PlaceableTurrets/LabTurret.cs b/Items/Placeables/PlaceableTurrets/LabTurret.cs index ffd9663bcc..90ba6f1fad 100644 --- a/Items/Placeables/PlaceableTurrets/LabTurret.cs +++ b/Items/Placeables/PlaceableTurrets/LabTurret.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 1); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Orange; } @@ -28,6 +28,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets AddIngredient(20). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } } diff --git a/Items/Placeables/PlaceableTurrets/LaserTurret .cs b/Items/Placeables/PlaceableTurrets/LaserTurret .cs index c3bd0ffb62..cde58acbb1 100644 --- a/Items/Placeables/PlaceableTurrets/LaserTurret .cs +++ b/Items/Placeables/PlaceableTurrets/LaserTurret .cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 2); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Pink; } @@ -31,6 +31,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets AddIngredient(12). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). AddTile(TileID.MythrilAnvil). + SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } } diff --git a/Items/Placeables/PlaceableTurrets/OnyxTurret.cs b/Items/Placeables/PlaceableTurrets/OnyxTurret.cs index 68349ef1ef..7d07cba715 100644 --- a/Items/Placeables/PlaceableTurrets/OnyxTurret.cs +++ b/Items/Placeables/PlaceableTurrets/OnyxTurret.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 1); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Orange; } @@ -31,6 +31,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets AddIngredient(50). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } } diff --git a/Items/Placeables/PlaceableTurrets/PlagueTurret.cs b/Items/Placeables/PlaceableTurrets/PlagueTurret.cs index 76ae55713d..a002365481 100644 --- a/Items/Placeables/PlaceableTurrets/PlagueTurret.cs +++ b/Items/Placeables/PlaceableTurrets/PlagueTurret.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 4); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Yellow; } @@ -31,6 +31,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets AddIngredient(12). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func condition), condition). AddTile(TileID.MythrilAnvil). + SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } } diff --git a/Items/Placeables/PlaceableTurrets/WaterTurret.cs b/Items/Placeables/PlaceableTurrets/WaterTurret.cs index b2fa1aa6bf..5082b4792d 100644 --- a/Items/Placeables/PlaceableTurrets/WaterTurret.cs +++ b/Items/Placeables/PlaceableTurrets/WaterTurret.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets { Item.DefaultToPlaceableTile(ModContent.TileType()); - Item.value = Item.sellPrice(gold: 1); + Item.value = Item.sellPrice(silver: 50); Item.rare = ItemRarityID.Orange; } @@ -30,6 +30,7 @@ namespace CalamityMod.Items.Placeables.PlaceableTurrets AddIngredient(10). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). AddTile(TileID.Anvils). + SortBeforeFirstRecipesOf(ModContent.ItemType()). Register(); } } diff --git a/Items/Placeables/Plates/Onyxplate.cs b/Items/Placeables/Plates/Onyxplate.cs index 4b77b92416..f34f6f9308 100644 --- a/Items/Placeables/Plates/Onyxplate.cs +++ b/Items/Placeables/Plates/Onyxplate.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Walls; +using CalamityMod.Items.Placeables.Walls; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Rock.cs b/Items/Placeables/Rock.cs similarity index 84% rename from Items/Rock.cs rename to Items/Placeables/Rock.cs index 30bf1937ab..be73346308 100644 --- a/Items/Rock.cs +++ b/Items/Placeables/Rock.cs @@ -4,11 +4,11 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items +namespace CalamityMod.Items.Placeables { public class Rock : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Misc"; + public new string LocalizationCategory => "Items.Placeables"; public override void SetStaticDefaults() { Item.ResearchUnlockCount = 0; diff --git a/Items/Rock.png b/Items/Placeables/Rock.png similarity index 100% rename from Items/Rock.png rename to Items/Placeables/Rock.png diff --git a/Items/Placeables/Stohne.cs b/Items/Placeables/Stohne.cs index 1e17d1f9ee..4bcee4017d 100644 --- a/Items/Placeables/Stohne.cs +++ b/Items/Placeables/Stohne.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables { diff --git a/Items/Placeables/SunkenSea/AridSoil.cs b/Items/Placeables/SunkenSea/AridSoil.cs new file mode 100644 index 0000000000..4bfe8b3bfb --- /dev/null +++ b/Items/Placeables/SunkenSea/AridSoil.cs @@ -0,0 +1,17 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.SunkenSea +{ + public class AridSoil : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + } +} diff --git a/Items/Placeables/SunkenSea/AridSoil.png b/Items/Placeables/SunkenSea/AridSoil.png new file mode 100644 index 0000000000..040ca55e28 Binary files /dev/null and b/Items/Placeables/SunkenSea/AridSoil.png differ diff --git a/Items/Placeables/SunkenSea/Basalt.cs b/Items/Placeables/SunkenSea/Basalt.cs index b6445da5bb..a933d258ec 100644 --- a/Items/Placeables/SunkenSea/Basalt.cs +++ b/Items/Placeables/SunkenSea/Basalt.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea { diff --git a/Items/Placeables/SunkenSea/Driftwood.cs b/Items/Placeables/SunkenSea/Driftwood.cs deleted file mode 100644 index d870b66fb5..0000000000 --- a/Items/Placeables/SunkenSea/Driftwood.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.SunkenSea -{ - public class Driftwood : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.Wood; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.Wood; - } - - public override void AddRecipes() - { - CreateRecipe(4). - AddIngredient(4). - AddTile(TileID.WorkBenches). - DisableDecraft(). - Register(); - } - } -} diff --git a/Items/Placeables/SunkenSea/Driftwood.png b/Items/Placeables/SunkenSea/Driftwood.png deleted file mode 100644 index 25ff08f299..0000000000 Binary files a/Items/Placeables/SunkenSea/Driftwood.png and /dev/null differ diff --git a/Items/Placeables/SunkenSea/Dunesand.cs b/Items/Placeables/SunkenSea/Dunesand.cs new file mode 100644 index 0000000000..495107affc --- /dev/null +++ b/Items/Placeables/SunkenSea/Dunesand.cs @@ -0,0 +1,27 @@ +using CalamityMod.Projectiles.Typeless; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.SunkenSea +{ + [LegacyName("RuneSand")] + public class Dunesand : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + + //+5 flat damage + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); + } + + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.ammo = AmmoID.Sand; + Item.notAmmo = true; + } + } +} diff --git a/Items/Placeables/SunkenSea/RuneSand.png b/Items/Placeables/SunkenSea/Dunesand.png similarity index 100% rename from Items/Placeables/SunkenSea/RuneSand.png rename to Items/Placeables/SunkenSea/Dunesand.png diff --git a/Items/Placeables/SunkenSea/EutrophicGlass.cs b/Items/Placeables/SunkenSea/EutrophicGlass.cs index d278bac6a7..9d4d5ebd5c 100644 --- a/Items/Placeables/SunkenSea/EutrophicGlass.cs +++ b/Items/Placeables/SunkenSea/EutrophicGlass.cs @@ -1,4 +1,4 @@ -using Terraria; +using CalamityMod.Items.Placeables.Walls; using Terraria.ID; using Terraria.ModLoader; @@ -20,6 +20,12 @@ namespace CalamityMod.Items.Placeables.SunkenSea AddIngredient(2). AddTile(TileID.Furnaces). Register(); + + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + DisableDecraft(). + Register(); } } } diff --git a/Items/Placeables/SunkenSea/EutrophicSand.cs b/Items/Placeables/SunkenSea/EutrophicSand.cs index 903c1b2618..c334d3a5d2 100644 --- a/Items/Placeables/SunkenSea/EutrophicSand.cs +++ b/Items/Placeables/SunkenSea/EutrophicSand.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Projectiles.Typeless; -using Terraria; +using CalamityMod.Projectiles.Typeless; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +12,8 @@ namespace CalamityMod.Items.Placeables.SunkenSea Item.ResearchUnlockCount = 100; ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - // +5 flat damage, equal to other sand variants - ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 5); + // -5 flat damage + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(),-5); } public override void SetDefaults() @@ -24,14 +22,5 @@ namespace CalamityMod.Items.Placeables.SunkenSea Item.ammo = AmmoID.Sand; Item.notAmmo = true; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddTile(TileID.WorkBenches). - DisableDecraft(). - Register(); - } } } diff --git a/Items/Placeables/SunkenSea/HardenedEutrophicSand.cs b/Items/Placeables/SunkenSea/HardenedEutrophicSand.cs index c950d573fc..5709e6aaba 100644 --- a/Items/Placeables/SunkenSea/HardenedEutrophicSand.cs +++ b/Items/Placeables/SunkenSea/HardenedEutrophicSand.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea diff --git a/Items/Placeables/SunkenSea/MossyStone.cs b/Items/Placeables/SunkenSea/MossyStone.cs new file mode 100644 index 0000000000..b8305438f7 --- /dev/null +++ b/Items/Placeables/SunkenSea/MossyStone.cs @@ -0,0 +1,15 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables.SunkenSea +{ + public class MossyStone : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + } +} diff --git a/Items/Placeables/SunkenSea/MossyStone.png b/Items/Placeables/SunkenSea/MossyStone.png new file mode 100644 index 0000000000..98a2598de5 Binary files /dev/null and b/Items/Placeables/SunkenSea/MossyStone.png differ diff --git a/Items/Placeables/SunkenSea/Navystone.cs b/Items/Placeables/SunkenSea/Navystone.cs index 247e14cc42..ce7abca02a 100644 --- a/Items/Placeables/SunkenSea/Navystone.cs +++ b/Items/Placeables/SunkenSea/Navystone.cs @@ -1,6 +1,5 @@ -using CalamityMod.Items.Placeables.FurnitureEutrophic; +using CalamityMod.Items.Placeables.FurnitureNavystone; using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea @@ -19,13 +18,13 @@ namespace CalamityMod.Items.Placeables.SunkenSea public override void AddRecipes() { CreateRecipe(). - AddIngredient(4). + AddIngredient(4). AddTile(TileID.WorkBenches). DisableDecraft(). Register(); CreateRecipe(). - AddIngredient(2). + AddIngredient(2). DisableDecraft(). Register(); } diff --git a/Items/Placeables/SunkenSea/PolishedNavystoneBrick.cs b/Items/Placeables/SunkenSea/PolishedNavystoneBrick.cs deleted file mode 100644 index e0aa52e928..0000000000 --- a/Items/Placeables/SunkenSea/PolishedNavystoneBrick.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.SunkenSea -{ - public class PolishedNavystoneBrick : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(2). - AddTile(TileID.Furnaces). - Register(); - } - } -} diff --git a/Items/Placeables/SunkenSea/PolypSand.cs b/Items/Placeables/SunkenSea/PolypSand.cs index 50c699626f..cc20b3828f 100644 --- a/Items/Placeables/SunkenSea/PolypSand.cs +++ b/Items/Placeables/SunkenSea/PolypSand.cs @@ -1,4 +1,5 @@ -using Terraria.ID; +using CalamityMod.Projectiles.Typeless; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea @@ -9,8 +10,15 @@ namespace CalamityMod.Items.Placeables.SunkenSea public override void SetStaticDefaults() { Item.ResearchUnlockCount = 100; + + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.ammo = AmmoID.Sand; + Item.notAmmo = true; + } } } diff --git a/Items/Placeables/SunkenSea/RuneSand.cs b/Items/Placeables/SunkenSea/RuneSand.cs deleted file mode 100644 index b5c6ead314..0000000000 --- a/Items/Placeables/SunkenSea/RuneSand.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.SunkenSea -{ - public class RuneSand : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - } -} diff --git a/Items/Placeables/SunkenSea/Runestone.cs b/Items/Placeables/SunkenSea/Runestone.cs index cca228044b..85774e2da0 100644 --- a/Items/Placeables/SunkenSea/Runestone.cs +++ b/Items/Placeables/SunkenSea/Runestone.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Walls; -using Terraria; +using CalamityMod.Items.Placeables.Walls; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Placeables/SunkenSea/SeaPrismBrick.cs b/Items/Placeables/SunkenSea/SeaPrismBrick.cs index d247dbfee9..0119b857f4 100644 --- a/Items/Placeables/SunkenSea/SeaPrismBrick.cs +++ b/Items/Placeables/SunkenSea/SeaPrismBrick.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea diff --git a/Items/Placeables/SunkenSea/Shellstone.cs b/Items/Placeables/SunkenSea/Shellstone.cs index 321018307f..ad69d66322 100644 --- a/Items/Placeables/SunkenSea/Shellstone.cs +++ b/Items/Placeables/SunkenSea/Shellstone.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Placeables.SunkenSea public override void SetStaticDefaults() { Item.ResearchUnlockCount = 100; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); } public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); diff --git a/Items/Placeables/SunkenSea/ShellstoneSlab.cs b/Items/Placeables/SunkenSea/ShellstoneSlab.cs deleted file mode 100644 index 2e3be721f4..0000000000 --- a/Items/Placeables/SunkenSea/ShellstoneSlab.cs +++ /dev/null @@ -1,30 +0,0 @@ -using CalamityMod.Items.Placeables.Walls; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Placeables.SunkenSea -{ - public class ShellstoneSlab : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 100; - } - - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddTile(TileID.HeavyWorkBench). - Register(); - CreateRecipe(). - AddIngredient(4). - AddTile(TileID.WorkBenches). - DisableDecraft(). - Register(); - } - } -} diff --git a/Items/Placeables/SunkenSea/VolcanicSand.cs b/Items/Placeables/SunkenSea/VolcanicSand.cs index 277f746966..c7003f7cb6 100644 --- a/Items/Placeables/SunkenSea/VolcanicSand.cs +++ b/Items/Placeables/SunkenSea/VolcanicSand.cs @@ -1,4 +1,5 @@ -using Terraria.ID; +using CalamityMod.Projectiles.Typeless; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables.SunkenSea @@ -9,8 +10,14 @@ namespace CalamityMod.Items.Placeables.SunkenSea public override void SetStaticDefaults() { Item.ResearchUnlockCount = 100; + ItemID.Sets.SandgunAmmoProjectileData[Type] = new(ModContent.ProjectileType(), 0); } - public override void SetDefaults() => Item.DefaultToPlaceableTile(ModContent.TileType()); + public override void SetDefaults() + { + Item.DefaultToPlaceableTile(ModContent.TileType()); + Item.ammo = AmmoID.Sand; + Item.notAmmo = true; + } } } diff --git a/Items/Placeables/UelibloomBrick.cs b/Items/Placeables/UelibloomBrick.cs index b90fd18f95..50ba86c548 100644 --- a/Items/Placeables/UelibloomBrick.cs +++ b/Items/Placeables/UelibloomBrick.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables.FurnitureBotanic; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Placeables.Walls; -using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Placeables @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Placeables CreateRecipe(50). AddRecipeGroup("AnyStoneBlock", 50). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.AdamantiteForge). Register(); CreateRecipe(). AddIngredient(4). diff --git a/Items/Placeables/VernalSoil.cs b/Items/Placeables/VernalSoil.cs index 0339f3c9e9..c97b7bf940 100644 --- a/Items/Placeables/VernalSoil.cs +++ b/Items/Placeables/VernalSoil.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Items.Placeables { diff --git a/Items/Placeables/Walls/AbyssGravelWallItem.cs b/Items/Placeables/Walls/AbyssGravelWallItem.cs index 943045e744..576b4ce224 100644 --- a/Items/Placeables/Walls/AbyssGravelWallItem.cs +++ b/Items/Placeables/Walls/AbyssGravelWallItem.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/AcidwoodWallItem.cs b/Items/Placeables/Walls/AcidwoodWallItem.cs index 51968f9e81..4d6d6f3b77 100644 --- a/Items/Placeables/Walls/AcidwoodWallItem.cs +++ b/Items/Placeables/Walls/AcidwoodWallItem.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Terraria.ID; using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; diff --git a/Items/Placeables/Walls/AncientSmoothNavystoneWall .cs b/Items/Placeables/Walls/AncientSmoothNavystoneWall .cs new file mode 100644 index 0000000000..1e314cc02e --- /dev/null +++ b/Items/Placeables/Walls/AncientSmoothNavystoneWall .cs @@ -0,0 +1,25 @@ +using CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; +namespace CalamityMod.Items.Placeables.Walls +{ + public class AncientSmoothNavystoneWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/AncientSmoothNavystoneWall.png b/Items/Placeables/Walls/AncientSmoothNavystoneWall.png new file mode 100644 index 0000000000..d867a30eb6 Binary files /dev/null and b/Items/Placeables/Walls/AncientSmoothNavystoneWall.png differ diff --git a/Items/Placeables/Walls/AnodizedWulfrumTrimWall.cs b/Items/Placeables/Walls/AnodizedWulfrumTrimWall.cs new file mode 100644 index 0000000000..aef59907c9 --- /dev/null +++ b/Items/Placeables/Walls/AnodizedWulfrumTrimWall.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class AnodizedWulfrumTrimWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(8). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/AnodizedWulfrumTrimWall.png b/Items/Placeables/Walls/AnodizedWulfrumTrimWall.png new file mode 100644 index 0000000000..8ffe2432ec Binary files /dev/null and b/Items/Placeables/Walls/AnodizedWulfrumTrimWall.png differ diff --git a/Items/Placeables/Walls/AstralDirtWall.cs b/Items/Placeables/Walls/AstralDirtWall.cs index 92f04ca230..70ec1c3246 100644 --- a/Items/Placeables/Walls/AstralDirtWall.cs +++ b/Items/Placeables/Walls/AstralDirtWall.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/AstralGrassWall.cs b/Items/Placeables/Walls/AstralGrassWall.cs index 4b733618b7..939e9c4f27 100644 --- a/Items/Placeables/Walls/AstralGrassWall.cs +++ b/Items/Placeables/Walls/AstralGrassWall.cs @@ -1,5 +1,4 @@ -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; namespace CalamityMod.Items.Placeables.Walls @@ -12,6 +11,6 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); } } diff --git a/Items/Placeables/Walls/AstralIceWall.cs b/Items/Placeables/Walls/AstralIceWall.cs index c97435081c..10f38bc8d5 100644 --- a/Items/Placeables/Walls/AstralIceWall.cs +++ b/Items/Placeables/Walls/AstralIceWall.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/AstralMonolithWall.cs b/Items/Placeables/Walls/AstralMonolithWall.cs index 0066082c69..a82474c496 100644 --- a/Items/Placeables/Walls/AstralMonolithWall.cs +++ b/Items/Placeables/Walls/AstralMonolithWall.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using Terraria.ID; using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; diff --git a/Items/Placeables/Walls/AstralSandstoneWall.cs b/Items/Placeables/Walls/AstralSandstoneWall.cs index aba828d058..43a2277c27 100644 --- a/Items/Placeables/Walls/AstralSandstoneWall.cs +++ b/Items/Placeables/Walls/AstralSandstoneWall.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/AstralSnowWall.cs b/Items/Placeables/Walls/AstralSnowWall.cs index ad137271ff..8771a360bf 100644 --- a/Items/Placeables/Walls/AstralSnowWall.cs +++ b/Items/Placeables/Walls/AstralSnowWall.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/AstralStoneWall.cs b/Items/Placeables/Walls/AstralStoneWall.cs index 25f2ec002e..07b8f957dd 100644 --- a/Items/Placeables/Walls/AstralStoneWall.cs +++ b/Items/Placeables/Walls/AstralStoneWall.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/ChargedWulfrumEnergyBarrierWall.cs b/Items/Placeables/Walls/ChargedWulfrumEnergyBarrierWall.cs new file mode 100644 index 0000000000..e54857d01b --- /dev/null +++ b/Items/Placeables/Walls/ChargedWulfrumEnergyBarrierWall.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Placeables.FurnitureWulfrum; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class ChargedWulfrumEnergyBarrierWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/ChargedWulfrumEnergyBarrierWall.png b/Items/Placeables/Walls/ChargedWulfrumEnergyBarrierWall.png new file mode 100644 index 0000000000..f179d2db1e Binary files /dev/null and b/Items/Placeables/Walls/ChargedWulfrumEnergyBarrierWall.png differ diff --git a/Items/Placeables/Walls/DriftwoodWall.cs b/Items/Placeables/Walls/DriftwoodWall.cs index 6f4217b604..dad7d4bf22 100644 --- a/Items/Placeables/Walls/DriftwoodWall.cs +++ b/Items/Placeables/Walls/DriftwoodWall.cs @@ -1,7 +1,7 @@ using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; using Terraria.ID; -using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.FurnitureDriftwood; namespace CalamityMod.Items.Placeables.Walls { diff --git a/Items/Placeables/Walls/EutrophicGlassWall.cs b/Items/Placeables/Walls/EutrophicGlassWall.cs new file mode 100644 index 0000000000..64ab1c799f --- /dev/null +++ b/Items/Placeables/Walls/EutrophicGlassWall.cs @@ -0,0 +1,25 @@ +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class EutrophicGlassWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/EutrophicGlassWall.png b/Items/Placeables/Walls/EutrophicGlassWall.png new file mode 100644 index 0000000000..9f7cfe4799 Binary files /dev/null and b/Items/Placeables/Walls/EutrophicGlassWall.png differ diff --git a/Items/Placeables/Walls/EutrophicSandWall.cs b/Items/Placeables/Walls/EutrophicSandWall.cs deleted file mode 100644 index f7e9ef7d62..0000000000 --- a/Items/Placeables/Walls/EutrophicSandWall.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Terraria.ID; -using Terraria.ModLoader; -using WallTiles = CalamityMod.Walls; - -namespace CalamityMod.Items.Placeables.Walls -{ - public class EutrophicSandWall : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 400; - ItemID.Sets.DrawUnsafeIndicator[Type] = true; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - } - - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); - } -} diff --git a/Items/Placeables/Walls/EutrophicSandWall.png b/Items/Placeables/Walls/EutrophicSandWall.png deleted file mode 100644 index 04e425d8b5..0000000000 Binary files a/Items/Placeables/Walls/EutrophicSandWall.png and /dev/null differ diff --git a/Items/Placeables/Walls/EutrophicSandWallSafe.cs b/Items/Placeables/Walls/EutrophicSandWallSafe.cs deleted file mode 100644 index d1558ba3c6..0000000000 --- a/Items/Placeables/Walls/EutrophicSandWallSafe.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using Terraria.ID; -using Terraria.ModLoader; -using WallTiles = CalamityMod.Walls; - -namespace CalamityMod.Items.Placeables.Walls -{ - public class EutrophicSandWallSafe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 400; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - } - - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); - - public override void AddRecipes() - { - CreateRecipe(4). - AddIngredient(). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Placeables/Walls/EutrophicSandWallSafe.png b/Items/Placeables/Walls/EutrophicSandWallSafe.png deleted file mode 100644 index 04e425d8b5..0000000000 Binary files a/Items/Placeables/Walls/EutrophicSandWallSafe.png and /dev/null differ diff --git a/Items/Placeables/Walls/HardenedAstralSandWall.cs b/Items/Placeables/Walls/HardenedAstralSandWall.cs index 23e5cebc10..5740900953 100644 --- a/Items/Placeables/Walls/HardenedAstralSandWall.cs +++ b/Items/Placeables/Walls/HardenedAstralSandWall.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/NavystoneWall.cs b/Items/Placeables/Walls/NavystoneWall.cs index 86d37219d1..32e1a1439f 100644 --- a/Items/Placeables/Walls/NavystoneWall.cs +++ b/Items/Placeables/Walls/NavystoneWall.cs @@ -1,18 +1,28 @@ -using Terraria.ID; +using CalamityMod.Items.Placeables.SunkenSea; +using Terraria.ID; using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; + namespace CalamityMod.Items.Placeables.Walls { + [LegacyName("NavystoneWallSafe")] public class NavystoneWall : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Placeables"; public override void SetStaticDefaults() { Item.ResearchUnlockCount = 400; - ItemID.Sets.DrawUnsafeIndicator[Type] = true; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); } public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } } } diff --git a/Items/Placeables/Walls/NavystoneWallSafe.cs b/Items/Placeables/Walls/NavystoneWallSafe.cs deleted file mode 100644 index 7dd6ce6ca0..0000000000 --- a/Items/Placeables/Walls/NavystoneWallSafe.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using Terraria.ID; -using Terraria.ModLoader; -using WallTiles = CalamityMod.Walls; -namespace CalamityMod.Items.Placeables.Walls -{ - public class NavystoneWallSafe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Placeables"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 400; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - } - - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); - - public override void AddRecipes() - { - CreateRecipe(4). - AddIngredient(). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Placeables/Walls/PolishedMarniteWall.cs b/Items/Placeables/Walls/PolishedMarniteWall.cs index 330cf077b1..16eb9d67d2 100644 --- a/Items/Placeables/Walls/PolishedMarniteWall.cs +++ b/Items/Placeables/Walls/PolishedMarniteWall.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Placeables.FurnitureMarnite; -using CalamityMod.Walls; using Terraria.ID; using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; diff --git a/Items/Placeables/Walls/RoundedAnodizedWulfrumPanelWall.cs b/Items/Placeables/Walls/RoundedAnodizedWulfrumPanelWall.cs new file mode 100644 index 0000000000..566caf0e2f --- /dev/null +++ b/Items/Placeables/Walls/RoundedAnodizedWulfrumPanelWall.cs @@ -0,0 +1,25 @@ +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class RoundedAnodizedWulfrumPanelWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(8). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/RoundedAnodizedWulfrumPanelWall.png b/Items/Placeables/Walls/RoundedAnodizedWulfrumPanelWall.png new file mode 100644 index 0000000000..f95eb6ede4 Binary files /dev/null and b/Items/Placeables/Walls/RoundedAnodizedWulfrumPanelWall.png differ diff --git a/Items/Placeables/Walls/ShellTrimBrickWall.cs b/Items/Placeables/Walls/ShellTrimBrickWall.cs new file mode 100644 index 0000000000..d319d780ea --- /dev/null +++ b/Items/Placeables/Walls/ShellTrimBrickWall.cs @@ -0,0 +1,26 @@ +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; +using Terraria.ID; +using CalamityMod.Items.Placeables.FurnitureShellstone; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class ShellTrimBrickWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/ShellTrimBrickWall.png b/Items/Placeables/Walls/ShellTrimBrickWall.png new file mode 100644 index 0000000000..6659b189f6 Binary files /dev/null and b/Items/Placeables/Walls/ShellTrimBrickWall.png differ diff --git a/Items/Placeables/Walls/ShellstoneSlabWall.cs b/Items/Placeables/Walls/ShellstoneSlabWall.cs index 71a1f34779..556af95bbd 100644 --- a/Items/Placeables/Walls/ShellstoneSlabWall.cs +++ b/Items/Placeables/Walls/ShellstoneSlabWall.cs @@ -1,7 +1,7 @@ using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; using Terraria.ID; -using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.FurnitureShellstone; namespace CalamityMod.Items.Placeables.Walls { diff --git a/Items/Placeables/Walls/SmoothNavystoneWall.cs b/Items/Placeables/Walls/SmoothNavystoneWall.cs index a2104c8b5c..11667b7dc1 100644 --- a/Items/Placeables/Walls/SmoothNavystoneWall.cs +++ b/Items/Placeables/Walls/SmoothNavystoneWall.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.FurnitureEutrophic; +using CalamityMod.Items.Placeables.FurnitureNavystone; using Terraria.ID; using Terraria.ModLoader; using WallTiles = CalamityMod.Walls; diff --git a/Items/Placeables/Walls/SmoothNavystoneWall.png b/Items/Placeables/Walls/SmoothNavystoneWall.png index d867a30eb6..d58aa5330c 100644 Binary files a/Items/Placeables/Walls/SmoothNavystoneWall.png and b/Items/Placeables/Walls/SmoothNavystoneWall.png differ diff --git a/Items/Placeables/Walls/SulphurousSandWall.cs b/Items/Placeables/Walls/SulphurousSandWall.cs index a975584667..526057ed0c 100644 --- a/Items/Placeables/Walls/SulphurousSandWall.cs +++ b/Items/Placeables/Walls/SulphurousSandWall.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/SulphurousSandstoneWall.cs b/Items/Placeables/Walls/SulphurousSandstoneWall.cs index 994455af66..50b901e0c3 100644 --- a/Items/Placeables/Walls/SulphurousSandstoneWall.cs +++ b/Items/Placeables/Walls/SulphurousSandstoneWall.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/SulphurousShaleWall.cs b/Items/Placeables/Walls/SulphurousShaleWall.cs index 2801be9e26..d245987b63 100644 --- a/Items/Placeables/Walls/SulphurousShaleWall.cs +++ b/Items/Placeables/Walls/SulphurousShaleWall.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Placeables.Walls Item.ResearchUnlockCount = 400; } - public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); public override void AddRecipes() { diff --git a/Items/Placeables/Walls/UnsafeNavystoneWall.cs b/Items/Placeables/Walls/UnsafeNavystoneWall.cs new file mode 100644 index 0000000000..1ee4cedf64 --- /dev/null +++ b/Items/Placeables/Walls/UnsafeNavystoneWall.cs @@ -0,0 +1,19 @@ +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls.UnsafeWalls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class UnsafeNavystoneWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + ItemID.Sets.DrawUnsafeIndicator[Type] = true; + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + } +} diff --git a/Items/Placeables/Walls/NavystoneWallSafe.png b/Items/Placeables/Walls/UnsafeNavystoneWall.png similarity index 100% rename from Items/Placeables/Walls/NavystoneWallSafe.png rename to Items/Placeables/Walls/UnsafeNavystoneWall.png diff --git a/Items/Placeables/Walls/WulfrumComplexPanelWall.cs b/Items/Placeables/Walls/WulfrumComplexPanelWall.cs new file mode 100644 index 0000000000..17c7c70994 --- /dev/null +++ b/Items/Placeables/Walls/WulfrumComplexPanelWall.cs @@ -0,0 +1,28 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class WulfrumComplexPanelWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(8). + AddIngredient(). + AddIngredient(). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/WulfrumComplexPanelWall.png b/Items/Placeables/Walls/WulfrumComplexPanelWall.png new file mode 100644 index 0000000000..bbf5dd0895 Binary files /dev/null and b/Items/Placeables/Walls/WulfrumComplexPanelWall.png differ diff --git a/Items/Placeables/Walls/WulfrumEnergyBarrierWall.cs b/Items/Placeables/Walls/WulfrumEnergyBarrierWall.cs new file mode 100644 index 0000000000..7ce9e493b5 --- /dev/null +++ b/Items/Placeables/Walls/WulfrumEnergyBarrierWall.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Placeables.FurnitureWulfrum; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class WulfrumEnergyBarrierWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/WulfrumEnergyBarrierWall.png b/Items/Placeables/Walls/WulfrumEnergyBarrierWall.png new file mode 100644 index 0000000000..212f4a7a8c Binary files /dev/null and b/Items/Placeables/Walls/WulfrumEnergyBarrierWall.png differ diff --git a/Items/Placeables/Walls/WulfrumPanelWall.cs b/Items/Placeables/Walls/WulfrumPanelWall.cs new file mode 100644 index 0000000000..c459d56ba5 --- /dev/null +++ b/Items/Placeables/Walls/WulfrumPanelWall.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Placeables.FurnitureWulfrum; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class WulfrumPanelWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/WulfrumPanelWall.png b/Items/Placeables/Walls/WulfrumPanelWall.png new file mode 100644 index 0000000000..2333e1721f Binary files /dev/null and b/Items/Placeables/Walls/WulfrumPanelWall.png differ diff --git a/Items/Placeables/Walls/WulfrumPillar.cs b/Items/Placeables/Walls/WulfrumPillar.cs new file mode 100644 index 0000000000..224ebd54e7 --- /dev/null +++ b/Items/Placeables/Walls/WulfrumPillar.cs @@ -0,0 +1,27 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class WulfrumPillar : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(8). + AddIngredient(). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/WulfrumPillar.png b/Items/Placeables/Walls/WulfrumPillar.png new file mode 100644 index 0000000000..e4c3444ab3 Binary files /dev/null and b/Items/Placeables/Walls/WulfrumPillar.png differ diff --git a/Items/Placeables/Walls/WulfrumPlatingWall.png b/Items/Placeables/Walls/WulfrumPlatingWall.png index 22d0216af5..8d32b5e211 100644 Binary files a/Items/Placeables/Walls/WulfrumPlatingWall.png and b/Items/Placeables/Walls/WulfrumPlatingWall.png differ diff --git a/Items/Placeables/Walls/WulfrumSheetWall.cs b/Items/Placeables/Walls/WulfrumSheetWall.cs new file mode 100644 index 0000000000..91c9471ddc --- /dev/null +++ b/Items/Placeables/Walls/WulfrumSheetWall.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Placeables.FurnitureWulfrum; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class WulfrumSheetWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/WulfrumSheetWall.png b/Items/Placeables/Walls/WulfrumSheetWall.png new file mode 100644 index 0000000000..c9a8e72a7a Binary files /dev/null and b/Items/Placeables/Walls/WulfrumSheetWall.png differ diff --git a/Items/Placeables/Walls/WulfrumSidingWall.cs b/Items/Placeables/Walls/WulfrumSidingWall.cs new file mode 100644 index 0000000000..f444611ee7 --- /dev/null +++ b/Items/Placeables/Walls/WulfrumSidingWall.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Placeables.FurnitureWulfrum; +using Terraria.ID; +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class WulfrumSidingWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() => Item.DefaultToPlaceableWall(ModContent.WallType()); + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/WulfrumSidingWall.png b/Items/Placeables/Walls/WulfrumSidingWall.png new file mode 100644 index 0000000000..6657ef206b Binary files /dev/null and b/Items/Placeables/Walls/WulfrumSidingWall.png differ diff --git a/Items/Potions/Alcohol/BloodyMary.cs b/Items/Potions/Alcohol/BloodyMary.cs index b9a40e4147..6dd7d3f933 100644 --- a/Items/Potions/Alcohol/BloodyMary.cs +++ b/Items/Potions/Alcohol/BloodyMary.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,12 +12,6 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float DamageBoost = 0.1f; - public static float MoveSpeedBoost = 0.1f; // Both 10% so we only need just one in the tooltip - public static int RegenLoss = 4; - public static float DefenseLossPercent = 0.04f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), RegenLoss.ToRegenPerSecond(), DefenseLossPercent.ToPercent()); - public override void SetStaticDefaults() { Item.ResearchUnlockCount = 20; @@ -29,10 +24,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(20, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 80); - Item.rare = ItemRarityID.Lime; + Item.DefaultToFood(20, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Blue; + } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.BloodMoonStarter). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/CaribbeanRum.cs b/Items/Potions/Alcohol/CaribbeanRum.cs index 2d0df11fd0..ea3de081cf 100644 --- a/Items/Potions/Alcohol/CaribbeanRum.cs +++ b/Items/Potions/Alcohol/CaribbeanRum.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,10 +12,9 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static int RegenBoost = 2; - public static float MoveSpeedBoost = 0.1f; - public static float DefenseLossPercent = 0.1f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenBoost.ToRegenPerSecond(), MoveSpeedBoost.ToPercent(), DefenseLossPercent.ToPercent()); + public static float MoveSpeedBoost = 0.25f; + public static float GravityMultiplier = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent(), (1-GravityMultiplier).ToPercent()); public override void SetStaticDefaults() { @@ -29,10 +29,19 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(14, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 60); - Item.rare = ItemRarityID.Lime; + Item.DefaultToFood(14, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Pink; + } + + public override void AddRecipes() + { + CreateRecipe(20). + AddIngredient(ItemID.Bottle, 20). + AddIngredient(ItemID.IceFeather). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/CinnamonRoll.cs b/Items/Potions/Alcohol/CinnamonRoll.cs index ada553d5dc..990fcb4353 100644 --- a/Items/Potions/Alcohol/CinnamonRoll.cs +++ b/Items/Potions/Alcohol/CinnamonRoll.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,13 +13,6 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - // Mana has a stupid formula so it won't go into the tooltip - public static float ManaRegenDelayBonus = 1f; - public static int ManaRegenBonus = 10; - public static float HeatDebuffBoost = 0.5f; - public static float DefenseLossPercent = 0.1f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((1f + HeatDebuffBoost).ToString(), DefenseLossPercent.ToPercent()); - public override void SetStaticDefaults() { Item.ResearchUnlockCount = 20; @@ -30,10 +25,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(18, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 1); - Item.rare = ItemRarityID.Yellow; + Item.DefaultToFood(18, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Lime; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.TurtleShell). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/CirrusVodka.cs b/Items/Potions/Alcohol/CirrusVodka.cs deleted file mode 100644 index 4b59118bae..0000000000 --- a/Items/Potions/Alcohol/CirrusVodka.cs +++ /dev/null @@ -1,59 +0,0 @@ -using CalamityMod.Buffs.Alcohol; -using CalamityMod.Items.Accessories.Vanity; -using CalamityMod.Items.Materials; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Potions.Alcohol -{ - [LegacyName("FabsolsVodka")] - public class CirrusVodka : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Potions"; - - public static float DamageBoost = 0.08f; - public static float DefenseLossPercent = 0.05f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), DefenseLossPercent.ToPercent()); - - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 20; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - ItemID.Sets.DrinkParticleColors[Type] = new Color[3] { - new Color(239, 123, 202), - new Color(187, 56, 158), - new Color(165, 47, 255) - }; - } - - public override void SetDefaults() - { - Item.DefaultToFood(30, 42, ModContent.BuffType(), CalamityUtils.MinutesToFrames(15), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 30); - Item.rare = ItemRarityID.LightRed; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.Ale). - AddIngredient(ItemID.PixieDust, 10). - AddIngredient(ItemID.CrystalShard, 5). - AddIngredient(ItemID.UnicornHorn). - AddTile(TileID.Kegs). - Register(); - - CreateRecipe(). - AddIngredient(ItemID.Ale). - AddIngredient(15). - AddIngredient(ItemID.CrystalShard). - AddTile(TileID.AlchemyTable). - Register() - .DisableDecraft(); - } - } -} diff --git a/Items/Potions/Alcohol/Everclear.cs b/Items/Potions/Alcohol/Everclear.cs index 1a79a28375..3089c42d4d 100644 --- a/Items/Potions/Alcohol/Everclear.cs +++ b/Items/Potions/Alcohol/Everclear.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -28,10 +29,20 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(14, 42, ModContent.BuffType(), CalamityUtils.MinutesToFrames(1), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 80); - Item.rare = ItemRarityID.Lime; + Item.DefaultToFood(14, 42, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.LightRed; + } + + public override void AddRecipes() + { + CreateRecipe(20). + AddIngredient(ItemID.Bottle, 20). + AddIngredient(ItemID.BlackLens). + AddIngredient(ItemID.SoulofNight, 10). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/EvergreenGin.cs b/Items/Potions/Alcohol/EvergreenGin.cs index e3ac50f3ee..e1b4a1fa07 100644 --- a/Items/Potions/Alcohol/EvergreenGin.cs +++ b/Items/Potions/Alcohol/EvergreenGin.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,9 +12,9 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float SicknessWaterDebuffBoost = 0.25f; - public static int RegenLoss = 1; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((1f + SicknessWaterDebuffBoost).ToString(), RegenLoss.ToRegenPerSecond()); + public static float DebuffBoost = 0.5f; + public static float DebuffLoss = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DebuffBoost).ToPercent(), DebuffLoss.ToPercent()); public override void SetStaticDefaults() { @@ -28,10 +29,20 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(18, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 60); - Item.rare = ItemRarityID.Lime; + Item.DefaultToFood(18, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.LightRed; + } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.Vine, 3). + AddIngredient(10). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/Fireball.cs b/Items/Potions/Alcohol/Fireball.cs index c5c3326bdb..8fcea00497 100644 --- a/Items/Potions/Alcohol/Fireball.cs +++ b/Items/Potions/Alcohol/Fireball.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,9 +12,9 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float HeatDebuffBoost = 0.25f; - public static int RegenLoss = 1; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((1f + HeatDebuffBoost).ToString(), RegenLoss.ToRegenPerSecond()); + public static float DebuffBoost = 0.5f; + public static float DebuffLoss = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DebuffBoost).ToPercent(), DebuffLoss.ToPercent()); public override void SetStaticDefaults() { @@ -27,10 +28,21 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(16, 38, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 30); + Item.DefaultToFood(16, 38, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); Item.rare = ItemRarityID.LightRed; } + + public override void AddRecipes() + { + + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.LivingFireBlock, 50). + AddIngredient(10). + AddTile(TileID.Kegs). + Register(); + } } } diff --git a/Items/Potions/Alcohol/GrapeBeer.cs b/Items/Potions/Alcohol/GrapeBeer.cs index 5a6ecfe28c..af8baea14b 100644 --- a/Items/Potions/Alcohol/GrapeBeer.cs +++ b/Items/Potions/Alcohol/GrapeBeer.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,13 +12,12 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float DefenseLossPercent = 0.03f; - public static int SecondDuration = 15; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DefenseLossPercent.ToPercent(), SecondDuration); + public static float CritLoss = 75; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(CritLoss); public override void SetStaticDefaults() { - Item.ResearchUnlockCount = 30; + Item.ResearchUnlockCount = 20; ItemID.Sets.DrinkParticleColors[Type] = new Color[3] { new Color(36, 2, 41), new Color(56, 0, 64), @@ -27,15 +27,19 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToHealingPotion(12, 28, 100); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 3); + Item.DefaultToFood(12, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); Item.rare = ItemRarityID.LightRed; } - public override void OnConsumeItem(Player player) + public override void AddRecipes() { - player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(SecondDuration)); + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.Grapes). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/Manhattan.cs b/Items/Potions/Alcohol/Manhattan.cs new file mode 100644 index 0000000000..b2b338a0b3 --- /dev/null +++ b/Items/Potions/Alcohol/Manhattan.cs @@ -0,0 +1,47 @@ +using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions.Alcohol +{ + public class Manhattan : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + + public static float DebuffBoost = 0.5f; + public static float DebuffLoss = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DebuffBoost).ToPercent(), DebuffLoss.ToPercent()); + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 20; + ItemID.Sets.DrinkParticleColors[Type] = new Color[3] { + new Color(225, 84, 33), + new Color(244, 176, 77), + new Color(255, 218, 102) + }; + } + + public override void SetDefaults() + { + Item.DefaultToFood(14, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Pink; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.FrostCore). + AddIngredient(10). + AddTile(TileID.Kegs). + Register(); + } + } +} diff --git a/Items/Potions/Alcohol/Manhattan.png b/Items/Potions/Alcohol/Manhattan.png new file mode 100644 index 0000000000..c6226e8ff7 Binary files /dev/null and b/Items/Potions/Alcohol/Manhattan.png differ diff --git a/Items/Potions/Alcohol/Margarita.cs b/Items/Potions/Alcohol/Margarita.cs index fef39cfa86..4df44ae8fb 100644 --- a/Items/Potions/Alcohol/Margarita.cs +++ b/Items/Potions/Alcohol/Margarita.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -12,14 +13,13 @@ namespace CalamityMod.Items.Potions.Alcohol public new string LocalizationCategory => "Items.Potions"; public static int BuffType = ModContent.BuffType(); - public static float DefenseLossPercent = 0.06f; - public static int RegenLoss = 1; - public static int MinuteDuration = 3; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DefenseLossPercent.ToPercent(), RegenLoss.ToRegenPerSecond(), MinuteDuration); + public static float DebuffLoss = 0.5f; + public static int MinuteDuration = 3; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DebuffLoss.ToPercent()); public override void SetStaticDefaults() { - Item.ResearchUnlockCount = 30; + Item.ResearchUnlockCount = 20; ItemID.Sets.DrinkParticleColors[Type] = new Color[3] { new Color(219, 227, 191), new Color(186, 189, 147), @@ -29,15 +29,19 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToHealingPotion(28, 40, 200); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 60); - Item.rare = ItemRarityID.Lime; - } + Item.DefaultToFood(28, 40, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); - public override void OnConsumeItem(Player player) + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.LightRed; + } + public override void AddRecipes() { - player.AddBuff(BuffType, CalamityUtils.MinutesToFrames(MinuteDuration)); + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.DarkShard). + AddIngredient(10). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/Moonshine.cs b/Items/Potions/Alcohol/Moonshine.cs index bbe98be132..fd89995259 100644 --- a/Items/Potions/Alcohol/Moonshine.cs +++ b/Items/Potions/Alcohol/Moonshine.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,10 +12,8 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static int DefenseBoost = 10; - public static float DamageReductionBoost = 0.03f; - public static int RegenLoss = 1; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DefenseBoost, DamageReductionBoost.ToPercent(), RegenLoss.ToRegenPerSecond()); + public static float MaxLifePercentBoost = 0.33f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxLifePercentBoost.ToPercent()); public override void SetStaticDefaults() { @@ -29,10 +28,20 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(24, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 1); - Item.rare = ItemRarityID.Yellow; + Item.DefaultToFood(24, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Lime; + } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.LifeFruit). + AddIngredient(5). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/MoscowMule.cs b/Items/Potions/Alcohol/MoscowMule.cs index e3de1158d0..69406883aa 100644 --- a/Items/Potions/Alcohol/MoscowMule.cs +++ b/Items/Potions/Alcohol/MoscowMule.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,11 +13,8 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float DamageBoost = 0.09f; public static float KnockbackBoost = 0.5f; - public static int CritBoost = 3; - public static int RegenLoss = 4; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), KnockbackBoost.ToPercent(), CritBoost, RegenLoss.ToRegenPerSecond()); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(KnockbackBoost.ToPercent()); public override void SetStaticDefaults() { @@ -30,10 +29,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(32, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 1); - Item.rare = ItemRarityID.Yellow; + Item.DefaultToFood(32, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.LightRed; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/OddMushroom.cs b/Items/Potions/Alcohol/OddMushroom.cs index 39c9dc8190..562d4ae785 100644 --- a/Items/Potions/Alcohol/OddMushroom.cs +++ b/Items/Potions/Alcohol/OddMushroom.cs @@ -10,8 +10,6 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float DamageBoost = 0.5f; - public override void SetStaticDefaults() { Item.ResearchUnlockCount = 20; @@ -25,15 +23,9 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { Item.DefaultToFood(38, 50, ModContent.BuffType(), CalamityUtils.MinutesToFrames(60)); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 10); - Item.rare = ItemRarityID.LightRed; - } - public override void OnConsumeItem(Player player) - { - if (player.Calamity().trippyLevel < 3) - player.Calamity().trippyLevel++; + Item.value = Item.buyPrice(gold: 5); // Sold by Truffle + Item.rare = ItemRarityID.LightRed; } } } diff --git a/Items/Potions/Alcohol/OldFashioned.cs b/Items/Potions/Alcohol/OldFashioned.cs index 8240710765..802234bc9d 100644 --- a/Items/Potions/Alcohol/OldFashioned.cs +++ b/Items/Potions/Alcohol/OldFashioned.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -28,9 +29,17 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { Item.DefaultToFood(30, 38, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 60); - Item.rare = ItemRarityID.Lime; + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Blue; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.Grapefruit). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/OldFashioned.png b/Items/Potions/Alcohol/OldFashioned.png index fddbd65368..c46adf86ba 100644 Binary files a/Items/Potions/Alcohol/OldFashioned.png and b/Items/Potions/Alcohol/OldFashioned.png differ diff --git a/Items/Potions/Alcohol/PurpleHaze.cs b/Items/Potions/Alcohol/PurpleHaze.cs new file mode 100644 index 0000000000..4c7792e387 --- /dev/null +++ b/Items/Potions/Alcohol/PurpleHaze.cs @@ -0,0 +1,48 @@ +using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions.Alcohol +{ + [LegacyName("FabsolsVodka")] + public class PurpleHaze : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + + public static float DamageBoost = 0.25f; + public static float StealthDamageLoss = 0.25f; + + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(),StealthDamageLoss.ToPercent()); + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 20; + ItemID.Sets.DrinkParticleColors[Type] = new Color[3] { + new Color(239, 123, 202), + new Color(187, 56, 158), + new Color(165, 47, 255) + }; + } + + public override void SetDefaults() + { + Item.DefaultToFood(30, 42, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Blue; + } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.Plum). + AddTile(TileID.Kegs). + Register(); + } + } +} diff --git a/Items/Potions/Alcohol/CirrusVodka.png b/Items/Potions/Alcohol/PurpleHaze.png similarity index 100% rename from Items/Potions/Alcohol/CirrusVodka.png rename to Items/Potions/Alcohol/PurpleHaze.png diff --git a/Items/Potions/Alcohol/RedWine.cs b/Items/Potions/Alcohol/RedWine.cs index 15c37e5d1a..f0314cc7f1 100644 --- a/Items/Potions/Alcohol/RedWine.cs +++ b/Items/Potions/Alcohol/RedWine.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions.Food; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,14 +13,13 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static int HealValue = 200; - public static int RegenLoss = 1; - public static int SecondDuration = 15; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenLoss.ToRegenPerSecond(), SecondDuration); + public static float VerticalSpeedBoost = 0.1f; + public static float FlightTimeLoss = 0.25f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(VerticalSpeedBoost.ToPercent(), FlightTimeLoss.ToPercent()); public override void SetStaticDefaults() { - Item.ResearchUnlockCount = 30; + Item.ResearchUnlockCount = 20; ItemID.Sets.DrinkParticleColors[Type] = new Color[3] { new Color(54, 5, 21), new Color(82, 9, 36), @@ -28,20 +29,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToHealingPotion(14, 48, HealValue); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 30); - Item.rare = ItemRarityID.LightRed; - } + Item.DefaultToFood(14, 48, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6)); - public override void GetHealLife(Player player, bool quickHeal, ref int healValue) - { - healValue = player.Calamity().baguette ? Baguette.RedWineBuffedHealValue : HealValue; + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Pink; } - - public override void OnConsumeItem(Player player) + public override void AddRecipes() { - player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(SecondDuration)); + CreateRecipe(20). + AddIngredient(ItemID.Bottle, 20). + AddIngredient(ItemID.FireFeather). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/Rum.cs b/Items/Potions/Alcohol/Rum.cs index ec9ac8cb46..e1b83237a8 100644 --- a/Items/Potions/Alcohol/Rum.cs +++ b/Items/Potions/Alcohol/Rum.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,10 +12,9 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static int RegenBoost = 2; - public static float MoveSpeedBoost = 0.1f; - public static float DefenseLossPercent = 0.05f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenBoost.ToRegenPerSecond(), MoveSpeedBoost.ToPercent(), DefenseLossPercent.ToPercent()); + public static float NonMinionBoost = 1.15f; + public static float MinionBoost = 0.85f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((NonMinionBoost-1).ToPercent(), (1- MinionBoost).ToPercent()); public override void SetStaticDefaults() { @@ -28,10 +28,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(24, 26, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 30); + Item.DefaultToFood(24, 26, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); Item.rare = ItemRarityID.LightRed; } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.SpiderFang, 3). + AddTile(TileID.Kegs). + Register(); + } } } diff --git a/Items/Potions/Alcohol/Screwdriver.cs b/Items/Potions/Alcohol/Screwdriver.cs index 7324ec7709..65c071fa43 100644 --- a/Items/Potions/Alcohol/Screwdriver.cs +++ b/Items/Potions/Alcohol/Screwdriver.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,9 +13,9 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float PiercingDamageBuff = 0.05f; - public static int RegenLoss = 1; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((1f + PiercingDamageBuff).ToString(), RegenLoss.ToRegenPerSecond()); + public static float DebuffBoost = 0.5f; + public static float DebuffLoss = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DebuffBoost).ToPercent(), DebuffLoss.ToPercent()); public override void SetStaticDefaults() { @@ -27,10 +29,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(14, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 40); - Item.rare = ItemRarityID.LightPurple; + Item.DefaultToFood(14, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Blue; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.Diamond). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/StarBeamRye.cs b/Items/Potions/Alcohol/StarBeamRye.cs index a2db1c7ac3..ffdfc3aca0 100644 --- a/Items/Potions/Alcohol/StarBeamRye.cs +++ b/Items/Potions/Alcohol/StarBeamRye.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,12 +12,9 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static int MaxManaBoost = 50; - public static float MagicDamageBoost = 0.08f; - public static float ManaCostReduction = 0.1f; - public static float DefenseLossPercent = 0.06f; - public static int RegenLoss = 2; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MaxManaBoost, MagicDamageBoost.ToPercent(), ManaCostReduction.ToPercent(), DefenseLossPercent.ToPercent(), RegenLoss.ToRegenPerSecond()); + public static float MaxManaBoost = 0.5f; + public static float ManaRegenBoost = 2f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(ManaRegenBoost.ToPercent(),(1-MaxManaBoost).ToPercent()); public override void SetStaticDefaults() { @@ -31,10 +29,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(20, 34, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 80); - Item.rare = ItemRarityID.Lime; + Item.DefaultToFood(20, 34, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.LightRed; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.Starfruit). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/Tequila.cs b/Items/Potions/Alcohol/Tequila.cs index c423400e0a..b9d4df742e 100644 --- a/Items/Potions/Alcohol/Tequila.cs +++ b/Items/Potions/Alcohol/Tequila.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,11 +12,10 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float KnockbackBoost = 0.1f; - public static int CritBoost = 4; - public static int DefenseBoost = 5; - public static int RegenLoss = 1; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(KnockbackBoost.ToPercent(), CritBoost, DefenseBoost, RegenLoss.ToRegenPerSecond()); + + public static float DebuffBoost = 0.5f; + public static float DebuffLoss = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DebuffBoost).ToPercent(), DebuffLoss.ToPercent()); public override void SetStaticDefaults() { @@ -29,10 +29,20 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(16, 34, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 30); + Item.DefaultToFood(16, 34, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); Item.rare = ItemRarityID.LightRed; } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(3). + AddIngredient(10). + AddTile(TileID.Kegs). + Register(); + } } } diff --git a/Items/Potions/Alcohol/TequilaSunrise.cs b/Items/Potions/Alcohol/TequilaSunrise.cs index 3a65d32387..2e04f06f82 100644 --- a/Items/Potions/Alcohol/TequilaSunrise.cs +++ b/Items/Potions/Alcohol/TequilaSunrise.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,11 +13,8 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float KnockbackBoost = 0.2f; - public static int CritBoost = 8; - public static int DefenseBoost = 10; - public static int RegenLoss = 2; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(KnockbackBoost.ToPercent(), CritBoost, DefenseBoost, RegenLoss.ToRegenPerSecond()); + public static float DoTMultiplier = 1.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DoTMultiplier-1).ToPercent()); public override void SetStaticDefaults() { @@ -29,10 +28,20 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(22, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(gold: 1); - Item.rare = ItemRarityID.Yellow; + Item.DefaultToFood(22, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.LightRed; + } + + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.LightShard). + AddIngredient(10). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/Vodka.cs b/Items/Potions/Alcohol/Vodka.cs index b1b0ef79ca..ca404e6e3c 100644 --- a/Items/Potions/Alcohol/Vodka.cs +++ b/Items/Potions/Alcohol/Vodka.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,11 +13,9 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float DamageBoost = 0.06f; - public static int CritBoost = 2; - public static int RegenLoss = 1; - public static float DefenseLossPercent = 0.05f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), CritBoost, RegenLoss.ToRegenPerSecond(), DefenseLossPercent.ToPercent()); + public static float DebuffBoost = 0.25f; + public static float DebuffLoss = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DebuffBoost).ToPercent(), DebuffLoss.ToPercent()); public override void SetStaticDefaults() { @@ -29,10 +29,19 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(14, 36, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 40); - Item.rare = ItemRarityID.LightPurple; + Item.DefaultToFood(14, 36, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.LightRed; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(10). + AddIngredient(10). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/Whiskey.cs b/Items/Potions/Alcohol/Whiskey.cs index eed0d9f389..8affbb3282 100644 --- a/Items/Potions/Alcohol/Whiskey.cs +++ b/Items/Potions/Alcohol/Whiskey.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -11,11 +12,11 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float DamageBoost = 0.04f; - public static float KnockbackBoost = 0.2f; - public static int CritBoost = 2; - public static float DefenseLossPercent = 0.05f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(DamageBoost.ToPercent(), KnockbackBoost.ToPercent(), CritBoost, DefenseLossPercent.ToPercent()); + public static float MaxDamageBoost = 0.15f; + public static float MinDamageBoost = -0.15f; + public static float TimeToDischarge = 600; + public static float TimeToRecharge = 300; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MinDamageBoost.ToPercent(), MaxDamageBoost.ToPercent(), (TimeToDischarge/60).ToString("0.##"), (TimeToRecharge/60).ToString("0.##")); public override void SetStaticDefaults() { @@ -29,10 +30,18 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(18, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 30); - Item.rare = ItemRarityID.LightRed; + Item.DefaultToFood(18, 32, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Blue; + } + public override void AddRecipes() + { + CreateRecipe(10). + AddIngredient(ItemID.Bottle, 10). + AddIngredient(ItemID.SpicyPepper). + AddTile(TileID.Kegs). + Register(); } } } diff --git a/Items/Potions/Alcohol/WhiteWine.cs b/Items/Potions/Alcohol/WhiteWine.cs index 7e5249978d..32890d06ad 100644 --- a/Items/Potions/Alcohol/WhiteWine.cs +++ b/Items/Potions/Alcohol/WhiteWine.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.Alcohol; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameInput; @@ -12,14 +14,13 @@ namespace CalamityMod.Items.Potions.Alcohol { public new string LocalizationCategory => "Items.Potions"; - public static float MagicDamageBoost = 0.08f; - public static float DefenseLossPercent = 0.06f; - public static int RegenLoss = 2; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MagicDamageBoost.ToPercent(), DefenseLossPercent.ToPercent(), RegenLoss.ToRegenPerSecond()); + public static float FlightTimeRecoveryAmount = 0.66f; + public static float FlightTimeLoss = 0.5f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(FlightTimeLoss.ToPercent()); public override void SetStaticDefaults() { - Item.ResearchUnlockCount = 30; + Item.ResearchUnlockCount = 20; // Clear, yellow-green ItemID.Sets.DrinkParticleColors[Type] = new Color[3] { new Color(242, 252, 177, 180), @@ -30,29 +31,22 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.DefaultToFood(14, 44, ModContent.BuffType(), CalamityUtils.MinutesToFrames(5), true); - Item.healMana = 300; - // Cirrus overcharges: 10% sell value instead of 20% - Item.value = Item.sellPrice(silver: 40); - Item.rare = ItemRarityID.LightPurple; + Item.DefaultToFood(14, 44, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Pink; } public override void OnConsumeItem(Player player) { - if (PlayerInput.Triggers.JustPressed.QuickBuff) - { - player.statMana += Item.healMana; - if (player.statMana > player.statManaMax2) - { - player.statMana = player.statManaMax2; - } - player.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true); - if (Main.myPlayer == player.whoAmI) - { - player.ManaEffect(Item.healMana); - } - } player.AddBuff(Item.buffType, Item.buffTime); } + public override void AddRecipes() + { + CreateRecipe(20). + AddIngredient(ItemID.Bottle, 20). + AddIngredient(ItemID.GiantHarpyFeather). + AddTile(TileID.Kegs). + Register(); + } } } diff --git a/Items/Potions/AstralInjection.cs b/Items/Potions/AstralInjection.cs index e2bbfbc188..11496ee727 100644 --- a/Items/Potions/AstralInjection.cs +++ b/Items/Potions/AstralInjection.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Potions } if (player.statLife <= 0) { - player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AstralInjection" + Main.rand.Next(1, 2 + 1)).Format(player.name)), 1000.0, 0, false); + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.AstralInjection" + Main.rand.Next(1, 2 + 1)).ToNetworkText(player.name)), 1000.0, 0, false); } } @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Potions AddIngredient(4). AddIngredient(). AddTile(TileID.AlchemyTable). - AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). + AddConsumeIngredientCallback(Recipe.IngredientQuantityRules.Alchemy). Register(); CreateRecipe(15). diff --git a/Items/Potions/Baguette.png b/Items/Potions/Baguette.png deleted file mode 100644 index 756ae9cd99..0000000000 Binary files a/Items/Potions/Baguette.png and /dev/null differ diff --git a/Items/Potions/BlasphemousDonut.png b/Items/Potions/BlasphemousDonut.png deleted file mode 100644 index 07e7f0f8fb..0000000000 Binary files a/Items/Potions/BlasphemousDonut.png and /dev/null differ diff --git a/Items/Potions/BottledPanacea.cs b/Items/Potions/BottledPanacea.cs new file mode 100644 index 0000000000..347e59c2f1 --- /dev/null +++ b/Items/Potions/BottledPanacea.cs @@ -0,0 +1,67 @@ +using CalamityMod.Cooldowns; +using CalamityMod.DataStructures; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions +{ + public class BottledPanacea : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 20; + ItemID.Sets.DrinkParticleColors[Type] = new Color[2] { + new Color(84, 215, 254), + new Color(35, 101, 192) + }; + } + + public override void SetDefaults() + { + Item.UseSound = SoundID.Item3; + Item.useStyle = ItemUseStyleID.DrinkLiquid; + Item.useTurn = true; + Item.useTime = Item.useAnimation = 17; + Item.maxStack = Item.CommonMaxStack; + Item.consumable = true; + Item.value = Item.sellPrice(silver: 2); + Item.rare = ItemRarityID.Blue; + } + + public override bool CanUseItem(Player player) => !player.HasCooldown(PanaceaCooldown.ID); + + public override bool? UseItem(Player player) + { + if (player.itemAnimation > 0 && player.itemTime == 0) + { + player.itemTime = Item.useTime; + SoundEngine.PlaySound(SoundID.Item4, player.Center); + + for (int i = Player.MaxBuffs - 1; i >= 0; i--) + { + int buffType = player.buffType[i]; + if (BuffDatasets.DebuffDataset[buffType] is not null && (BuffDatasets.DebuffDataset[buffType].SicknessDebuffScaling > 0 || BuffDatasets.DebuffDataset[buffType].ElectricDebuffScaling > 0)) + player.DelBuff(i); + } + + for (int i = 0; i < 4; i++) + { + Vector2 plusVel = new Vector2(Main.rand.NextFloat(-0.55f, 0.55f), Main.rand.NextFloat(-6f, 0f)); + HealingPlus plus = new(Main.rand.NextVector2FromRectangle(player.Hitbox), Main.rand.NextFloat(1.25f, 1.5f), plusVel, Color.SkyBlue, Color.SkyBlue, 20); + GeneralParticleHandler.SpawnParticle(plus); + } + for (int d = 0; d < 10; d++) + Dust.NewDust(player.position, player.width, player.height, DustID.BlueTorch); + + player.AddCooldown(PanaceaCooldown.ID, CalamityUtils.SecondsToFrames(30)); + } + return true; + } + } +} diff --git a/Items/Potions/BottledPanacea.png b/Items/Potions/BottledPanacea.png new file mode 100644 index 0000000000..8a98e6f6bf Binary files /dev/null and b/Items/Potions/BottledPanacea.png differ diff --git a/Items/Potions/BoundingPotion.cs b/Items/Potions/BoundingPotion.cs index a5906281fa..416300231c 100644 --- a/Items/Potions/BoundingPotion.cs +++ b/Items/Potions/BoundingPotion.cs @@ -34,9 +34,9 @@ namespace CalamityMod.Items.Potions public override void AddRecipes() { - CreateRecipe(3). - AddIngredient(ItemID.BottledWater, 3). - AddIngredient(ItemID.Frog). + CreateRecipe(). + AddIngredient(ItemID.BottledWater). + AddIngredient(ItemID.PinkGel). AddIngredient(ItemID.Moonglow). AddTile(TileID.Bottles). Register(); diff --git a/Items/Potions/CeaselessHungerPotion.cs b/Items/Potions/CeaselessHungerPotion.cs index 625751c603..b2ba7604a1 100644 --- a/Items/Potions/CeaselessHungerPotion.cs +++ b/Items/Potions/CeaselessHungerPotion.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Potions AddIngredient(ItemID.BottledWater, 4). AddIngredient(). AddTile(TileID.AlchemyTable). - AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). + AddConsumeIngredientCallback(Recipe.IngredientQuantityRules.Alchemy). Register(); CreateRecipe(8). diff --git a/Items/Potions/DeliciousMeat.cs b/Items/Potions/DeliciousMeat.cs deleted file mode 100644 index 779c5e8f18..0000000000 --- a/Items/Potions/DeliciousMeat.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Potions -{ - public class DeliciousMeat : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Potions"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 5; - ItemID.Sets.FoodParticleColors[Type] = new Color[2] { - new Color(147, 197, 206), - new Color(94, 131, 168), - }; - } - public override void SetDefaults() - { - Item.DefaultToFood(32, 30, BuffID.WellFed2, CalamityUtils.MinutesToFrames(30)); - Item.value = Item.buyPrice(silver: 50); // Sold by Archmage - Item.rare = ItemRarityID.Pink; - } - } -} diff --git a/Items/Potions/DeliciousMeat.png b/Items/Potions/DeliciousMeat.png deleted file mode 100644 index 9bae865748..0000000000 Binary files a/Items/Potions/DeliciousMeat.png and /dev/null differ diff --git a/Items/Potions/Fabsoup.cs b/Items/Potions/Fabsoup.cs deleted file mode 100644 index 91e98d12c6..0000000000 --- a/Items/Potions/Fabsoup.cs +++ /dev/null @@ -1,63 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Rarities; -using ReLogic.Utilities; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Potions -{ - public class Fabsoup : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Potions"; - public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/SoupConsumption"); - public SlotId DrinkSoundSlot; - - public override void SetDefaults() - { - Item.width = 56; - Item.height = 50; - Item.value = 0; - Item.rare = ModContent.RarityType(); - Item.maxStack = 1; - Item.consumable = false; - Item.useAnimation = 901; - Item.useTime = 901; - Item.UseSound = null; - Item.useStyle = ItemUseStyleID.DrinkLiquid; - Item.useTurn = true; - } - public override bool? UseItem(Player player) - { - DrinkSoundSlot = SoundEngine.PlaySound(UseSound, player.Center); - return true; - } - - public override void UseItemFrame(Player player) - { - int time = CalamityUtils.MinutesToFrames(33); - if (player.itemAnimation == 180) - { - player.AddBuff(BuffID.WellFed3, time); - } - // ow hot - if (player.itemAnimation == 60) - { - player.AddBuff(BuffID.WellFed3, time); - player.AddBuff(BuffID.OnFire, time); - player.AddBuff(BuffID.Frostburn, time); - player.AddBuff(BuffID.CursedInferno, time); - player.AddBuff(ModContent.BuffType(), time); - player.AddBuff(ModContent.BuffType(), time); - player.AddBuff(ModContent.BuffType(), time); - player.AddBuff(ModContent.BuffType(), time); - player.AddBuff(ModContent.BuffType(), time); - player.AddBuff(ModContent.BuffType(), time); - } - - if (SoundEngine.TryGetActiveSound(DrinkSoundSlot, out var drinkSound) && drinkSound.IsPlaying) - drinkSound.Position = player.Center; - } - } -} diff --git a/Items/Potions/Fabsoup.png b/Items/Potions/Fabsoup.png deleted file mode 100644 index 0a576efee3..0000000000 Binary files a/Items/Potions/Fabsoup.png and /dev/null differ diff --git a/Items/Potions/Baguette.cs b/Items/Potions/Food/Baguette.cs similarity index 89% rename from Items/Potions/Baguette.cs rename to Items/Potions/Food/Baguette.cs index 0009eb0f1c..862d4a1da9 100644 --- a/Items/Potions/Baguette.cs +++ b/Items/Potions/Food/Baguette.cs @@ -1,11 +1,12 @@ using CalamityMod.Buffs.Potions; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -namespace CalamityMod.Items.Potions +namespace CalamityMod.Items.Potions.Food { public class Baguette : ModItem, ILocalizedModType { @@ -18,11 +19,13 @@ namespace CalamityMod.Items.Potions public override void SetStaticDefaults() { Item.ResearchUnlockCount = 5; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3)); ItemID.Sets.FoodParticleColors[Type] = new Color[3] { new Color(231, 137, 159), new Color(179, 104, 56), new Color(108, 47, 16) }; + ItemID.Sets.IsFood[Type] = true; } public override void SetDefaults() diff --git a/Items/Potions/Food/Baguette.png b/Items/Potions/Food/Baguette.png new file mode 100644 index 0000000000..bcaa686ec1 Binary files /dev/null and b/Items/Potions/Food/Baguette.png differ diff --git a/Items/Potions/BlasphemousDonut.cs b/Items/Potions/Food/BlasphemousDonut.cs similarity index 79% rename from Items/Potions/BlasphemousDonut.cs rename to Items/Potions/Food/BlasphemousDonut.cs index 994ceb77fa..c0b6e25193 100644 --- a/Items/Potions/BlasphemousDonut.cs +++ b/Items/Potions/Food/BlasphemousDonut.cs @@ -1,9 +1,10 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items.Potions +namespace CalamityMod.Items.Potions.Food { public class BlasphemousDonut : ModItem, ILocalizedModType { @@ -11,11 +12,13 @@ namespace CalamityMod.Items.Potions public override void SetStaticDefaults() { Item.ResearchUnlockCount = 5; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3)); ItemID.Sets.FoodParticleColors[Type] = new Color[3] { new Color(122, 66, 59), new Color(206, 116, 59), new Color(198, 153, 113) }; + ItemID.Sets.IsFood[Type] = true; } public override void SetDefaults() { diff --git a/Items/Potions/Food/BlasphemousDonut.png b/Items/Potions/Food/BlasphemousDonut.png new file mode 100644 index 0000000000..6d6ff5195a Binary files /dev/null and b/Items/Potions/Food/BlasphemousDonut.png differ diff --git a/Items/Potions/Food/DeliciousMeat.cs b/Items/Potions/Food/DeliciousMeat.cs new file mode 100644 index 0000000000..fcc87fc022 --- /dev/null +++ b/Items/Potions/Food/DeliciousMeat.cs @@ -0,0 +1,31 @@ +using CalamityMod.Items.Tools; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions.Food +{ + public class DeliciousMeat : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + public override void SetStaticDefaults() + { + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + Item.ResearchUnlockCount = 5; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3)); + ItemID.Sets.FoodParticleColors[Type] = new Color[2] { + new Color(147, 197, 206), + new Color(94, 131, 168), + }; + ItemID.Sets.IsFood[Type] = true; + } + public override void SetDefaults() + { + Item.DefaultToFood(32, 30, BuffID.WellFed2, CalamityUtils.MinutesToFrames(30)); + Item.value = Item.buyPrice(silver: 50); // Sold by Archmage + Item.rare = ItemRarityID.Pink; + } + } +} diff --git a/Items/Potions/Food/DeliciousMeat.png b/Items/Potions/Food/DeliciousMeat.png new file mode 100644 index 0000000000..61f729cdd9 Binary files /dev/null and b/Items/Potions/Food/DeliciousMeat.png differ diff --git a/Items/Potions/Food/HadalStew.cs b/Items/Potions/Food/HadalStew.cs new file mode 100644 index 0000000000..49567ef489 --- /dev/null +++ b/Items/Potions/Food/HadalStew.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using CalamityMod.Items.Fishing.BrimstoneCragCatches; +using CalamityMod.Items.Placeables.Abyss; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions.Food +{ + [LegacyName("SunkenStew")] + public class HadalStew : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + public static int BuffType = BuffID.WellFed3; + public static int BuffDuration = CalamityUtils.MinutesToFrames(8); + public static int SicknessDuration = CalamityUtils.SecondsToFrames(50); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(BuffDuration / 3600); + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 30; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3)); + // Even though this uses the drinking animation, it does not use DrinkParticleColors + // This is so that dusts fly out (like Bowl of Soup) instead of drip down (like Apple Juice) + ItemID.Sets.FoodParticleColors[Type] = new Color[4] { + new Color(185, 117, 70), + new Color(214, 98, 44), + new Color(235, 156, 117), + new Color(89, 54, 46) + }; + ItemID.Sets.IsFood[Type] = true; + } + + public override void SetDefaults() + { + Item.DefaultToHealingPotion(28, 18, 100); + Item.value = Item.sellPrice(silver: 40); + Item.rare = ItemRarityID.Green; + } + + public override void ModifyTooltips(List list) + { + string duration = Main.LocalPlayer.pStone ? (SicknessDuration / 60 * 0.75f).ToString("N1") : (SicknessDuration / 60).ToString(); + list.FindAndReplace("[S]", duration); + } + + public override void ModifyPotionDelay(Player player, ref int baseDelay) => baseDelay -= CalamityUtils.SecondsToFrames(60) - SicknessDuration; + + public override void OnConsumeItem(Player player) => player.AddBuff(BuffType, BuffDuration); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(3). + AddIngredient(). + AddIngredient(ItemID.Bowl). + AddTile(TileID.CookingPots). + Register(); + + CreateRecipe(). + AddIngredient(3). + AddIngredient(). + AddIngredient(ItemID.Bowl). + AddTile(TileID.CookingPots). + Register(); + } + } +} diff --git a/Items/Potions/Food/HadalStew.png b/Items/Potions/Food/HadalStew.png new file mode 100644 index 0000000000..2d216185b3 Binary files /dev/null and b/Items/Potions/Food/HadalStew.png differ diff --git a/Items/Potions/Food/LavaChickenBroth.cs b/Items/Potions/Food/LavaChickenBroth.cs new file mode 100644 index 0000000000..dd69f6fc01 --- /dev/null +++ b/Items/Potions/Food/LavaChickenBroth.cs @@ -0,0 +1,71 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Rarities; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions.Food +{ + [LegacyName("Fabsoup")] + public class LavaChickenBroth : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/SoupConsumption"); + public SlotId DrinkSoundSlot; + + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3)); + ItemID.Sets.IsFood[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 56; + Item.height = 50; + Item.value = 0; + Item.rare = ModContent.RarityType(); + Item.maxStack = 1; + Item.consumable = false; + Item.useAnimation = 901; + Item.useTime = 901; + Item.UseSound = null; + Item.useStyle = ItemUseStyleID.EatFood; + Item.useTurn = true; + } + public override bool? UseItem(Player player) + { + DrinkSoundSlot = SoundEngine.PlaySound(UseSound, player.Center); + return true; + } + + public override void UseItemFrame(Player player) + { + int time = CalamityUtils.MinutesToFrames(25) + CalamityUtils.SecondsToFrames(25); + if (player.itemAnimation == 180) + { + player.AddBuff(BuffID.WellFed3, time); + } + // ow hot + if (player.itemAnimation == 60) + { + player.AddBuff(BuffID.WellFed3, time); + player.AddBuff(BuffID.OnFire, time); + player.AddBuff(BuffID.Frostburn, time); + player.AddBuff(BuffID.CursedInferno, time); + player.AddBuff(ModContent.BuffType(), time); + player.AddBuff(ModContent.BuffType(), time); + player.AddBuff(ModContent.BuffType(), time); + player.AddBuff(ModContent.BuffType(), time); + player.AddBuff(ModContent.BuffType(), time); + player.AddBuff(ModContent.BuffType(), time); + } + + if (SoundEngine.TryGetActiveSound(DrinkSoundSlot, out var drinkSound) && drinkSound.IsPlaying) + drinkSound.Position = player.Center; + } + } +} diff --git a/Items/Potions/Food/LavaChickenBroth.png b/Items/Potions/Food/LavaChickenBroth.png new file mode 100644 index 0000000000..21efe60b25 Binary files /dev/null and b/Items/Potions/Food/LavaChickenBroth.png differ diff --git a/Items/Potions/Food/ShroomBowl.cs b/Items/Potions/Food/ShroomBowl.cs new file mode 100644 index 0000000000..f8db24d22a --- /dev/null +++ b/Items/Potions/Food/ShroomBowl.cs @@ -0,0 +1,42 @@ +using CalamityMod.Items.Critters; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Potions.Food +{ + public class ShroomBowl : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Potions"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 5; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3)); + ItemID.Sets.FoodParticleColors[Type] = [ + new Color(248, 195, 96), + new Color(115, 57, 15), + new Color(230, 124, 45) + ]; + ItemID.Sets.IsFood[Type] = true; + } + + public override void SetDefaults() + { + Item.DefaultToFood(30, 24, BuffID.WellFed2, CalamityUtils.MinutesToFrames(10), true); + Item.value = Item.sellPrice(silver: 10); + Item.rare = ItemRarityID.Blue; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.Bowl). + AddIngredient(). + AddTile(TileID.CookingPots). + DisableDecraft(). + Register(); + } + } +} diff --git a/Items/Potions/Food/ShroomBowl.png b/Items/Potions/Food/ShroomBowl.png new file mode 100644 index 0000000000..20a6f6abe0 Binary files /dev/null and b/Items/Potions/Food/ShroomBowl.png differ diff --git a/Items/Potions/GravityNormalizerPotion.cs b/Items/Potions/GravityNormalizerPotion.cs index e95b3e3898..b7de4cc666 100644 --- a/Items/Potions/GravityNormalizerPotion.cs +++ b/Items/Potions/GravityNormalizerPotion.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Potions AddIngredient(). AddIngredient(). AddTile(TileID.AlchemyTable). - AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). + AddConsumeIngredientCallback(Recipe.IngredientQuantityRules.Alchemy). Register(); CreateRecipe(). diff --git a/Items/Potions/HadalStew.cs b/Items/Potions/HadalStew.cs deleted file mode 100644 index a724a51365..0000000000 --- a/Items/Potions/HadalStew.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Items.Fishing.BrimstoneCragCatches; -using CalamityMod.Items.Placeables.Abyss; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Potions -{ - [LegacyName("SunkenStew")] - public class HadalStew : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Potions"; - public static int BuffType = BuffID.WellFed2; - public static int BuffDuration = CalamityUtils.MinutesToFrames(60); - public static int SicknessDuration = CalamityUtils.SecondsToFrames(50); - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(BuffDuration / 3600); - - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 30; - // Even though this uses the drinking animation, it does not use DrinkParticleColors - // This is so that dusts fly out (like Bowl of Soup) instead of drip down (like Apple Juice) - ItemID.Sets.FoodParticleColors[Type] = new Color[4] { - new Color(185, 117, 70), - new Color(214, 98, 44), - new Color(235, 156, 117), - new Color(89, 54, 46) - }; - } - - public override void SetDefaults() - { - Item.DefaultToHealingPotion(28, 18, 120); - Item.value = Item.sellPrice(silver: 40); - Item.rare = ItemRarityID.Green; - } - - public override void ModifyTooltips(List list) - { - string duration = Main.LocalPlayer.pStone ? (SicknessDuration / 60 * 0.75f).ToString("N1") : (SicknessDuration / 60).ToString(); - list.FindAndReplace("[S]", duration); - } - - public override bool CanUseItem(Player player) - { - return player.potionDelay <= 0 && player.Calamity().potionTimer <= 0; - } - - public override void OnConsumeItem(Player player) - { - player.AddBuff(BuffType, BuffDuration); - // fixes hardcoded potion sickness duration from quick heal (see CalamityPlayerMiscEffects.cs) - player.Calamity().potionTimer = 2; - } - - public override void AddRecipes() - { - CreateRecipe(2). - AddIngredient(10). - AddIngredient(). - AddIngredient(ItemID.Honeyfin). - AddIngredient(ItemID.Bowl, 2). - AddTile(TileID.CookingPots). - Register(); - - CreateRecipe(2). - AddIngredient(10). - AddIngredient(). - AddIngredient(ItemID.Honeyfin). - AddIngredient(ItemID.Bowl, 2). - AddTile(TileID.CookingPots). - Register(); - } - } -} diff --git a/Items/Potions/HadalStew.png b/Items/Potions/HadalStew.png deleted file mode 100644 index 0c2828d09a..0000000000 Binary files a/Items/Potions/HadalStew.png and /dev/null differ diff --git a/Items/Potions/OmegaHealingPotion.cs b/Items/Potions/OmegaHealingPotion.cs index a4e28baa46..e145c6d146 100644 --- a/Items/Potions/OmegaHealingPotion.cs +++ b/Items/Potions/OmegaHealingPotion.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Potions { Item.DefaultToHealingPotion(24, 32, 300); Item.value = Item.sellPrice(gold: 1); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void AddRecipes() diff --git a/Items/Potions/PhotosynthesisPotion.cs b/Items/Potions/PhotosynthesisPotion.cs index f1dbcd15c1..ef2b4b4340 100644 --- a/Items/Potions/PhotosynthesisPotion.cs +++ b/Items/Potions/PhotosynthesisPotion.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Potions AddIngredient(ItemID.Daybloom, 3). AddIngredient(). AddTile(TileID.AlchemyTable). - AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). + AddConsumeIngredientCallback(Recipe.IngredientQuantityRules.Alchemy). AddDecraftCondition(Condition.Hardmode). Register(); diff --git a/Items/Potions/SoaringPotion.cs b/Items/Potions/SoaringPotion.cs index c89f575924..0404bafdb8 100644 --- a/Items/Potions/SoaringPotion.cs +++ b/Items/Potions/SoaringPotion.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Potions public override void SetDefaults() { - Item.DefaultToFood(30, 30, ModContent.BuffType(), CalamityUtils.MinutesToFrames(6), true); + Item.DefaultToFood(30, 30, ModContent.BuffType(), CalamityUtils.MinutesToFrames(8), true); Item.value = Item.sellPrice(silver: 2); Item.rare = ItemRarityID.LightRed; } @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Potions AddIngredient(). AddIngredient(ItemID.SoulofFlight). AddTile(TileID.AlchemyTable). - AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). + AddConsumeIngredientCallback(Recipe.IngredientQuantityRules.Alchemy). Register(); CreateRecipe(). diff --git a/Items/Potions/SupremeHealingPotion.cs b/Items/Potions/SupremeHealingPotion.cs index 8d2d5d7d74..a6be404eb4 100644 --- a/Items/Potions/SupremeHealingPotion.cs +++ b/Items/Potions/SupremeHealingPotion.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Materials; +using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -23,7 +24,7 @@ namespace CalamityMod.Items.Potions { Item.DefaultToHealingPotion(26, 38, 250); Item.value = Item.sellPrice(silver: 60); - Item.rare = ItemRarityID.Purple; + Item.rare = ModContent.RarityType(); } public override void AddRecipes() diff --git a/Items/Potions/ZenPotion.cs b/Items/Potions/ZenPotion.cs index 905b6f831d..44636fe640 100644 --- a/Items/Potions/ZenPotion.cs +++ b/Items/Potions/ZenPotion.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Potions public override void SetDefaults() { - Item.DefaultToFood(24, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(15), true); + Item.DefaultToFood(24, 28, ModContent.BuffType(), CalamityUtils.MinutesToFrames(12), true); Item.value = Item.sellPrice(silver: 2); Item.rare = ItemRarityID.LightRed; } @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Potions AddIngredient(2). AddIngredient(ItemID.Daybloom, 3). AddTile(TileID.AlchemyTable). - AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). + AddConsumeIngredientCallback(Recipe.IngredientQuantityRules.Alchemy). Register(); CreateRecipe(). diff --git a/Items/Potions/ZergPotion.cs b/Items/Potions/ZergPotion.cs index 0d118409f3..edeaf48637 100644 --- a/Items/Potions/ZergPotion.cs +++ b/Items/Potions/ZergPotion.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Potions public override void SetDefaults() { - Item.DefaultToFood(24, 34, ModContent.BuffType(), CalamityUtils.MinutesToFrames(15), true); + Item.DefaultToFood(24, 34, ModContent.BuffType(), CalamityUtils.MinutesToFrames(7), true); Item.value = Item.sellPrice(silver: 2); Item.rare = ItemRarityID.LightRed; } @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Potions AddIngredient(2). AddIngredient(ItemID.Fireblossom, 2). AddTile(TileID.AlchemyTable). - AddConsumeItemCallback(Recipe.ConsumptionRules.Alchemy). + AddConsumeIngredientCallback(Recipe.IngredientQuantityRules.Alchemy). Register(); CreateRecipe(). diff --git a/Items/RelicOfResilience.cs b/Items/RelicOfResilience.cs deleted file mode 100644 index cf610774c1..0000000000 --- a/Items/RelicOfResilience.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Linq; -using CalamityMod.Projectiles.Damageable; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items -{ - public class RelicOfResilience : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Misc"; - public override void SetDefaults() - { - Item.width = 40; - Item.height = 34; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; - } - public override void HoldItem(Player player) - { - player.Calamity().mouseWorldListener = true; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther; - } - } -} diff --git a/Items/RogueGlobalItem.cs b/Items/RogueGlobalItem.cs new file mode 100644 index 0000000000..0215e92a00 --- /dev/null +++ b/Items/RogueGlobalItem.cs @@ -0,0 +1,33 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items +{ + public sealed class RogueGlobalItem : GlobalItem + { + public override bool InstancePerEntity => true; + + /// Tracks the stealth strike damage modifier for this item, derived from its prefix. + internal float StealthStrikePrefixBonus = 0.0f; + + public override GlobalItem Clone(Item from, Item to) + { + RogueGlobalItem myClone = (RogueGlobalItem)base.Clone(from, to); + + // Rogue + myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus; + + return myClone; + } + + public override bool AppliesToEntity(Item entity, bool lateInstantiation) + { + return entity.CountsAsClass(); + } + + public override void PreReforge(Item item) + { + StealthStrikePrefixBonus = 0f; + } + } +} diff --git a/Items/SirenproofEarMuffs.cs b/Items/SirenproofEarMuffs.cs deleted file mode 100644 index 884f337b5b..0000000000 --- a/Items/SirenproofEarMuffs.cs +++ /dev/null @@ -1,100 +0,0 @@ -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() - { - Item.width = 44; - Item.height = 34; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; - } - - public override bool CanRightClick() => true; - - public override void RightClick(Player player) - { - if (player.Calamity().disableAnahitaSpawns == true) - player.Calamity().disableAnahitaSpawns = false; - else - player.Calamity().disableAnahitaSpawns = true; - state = player.Calamity().disableAnahitaSpawns; - - Item.RestoreConsumedItemByRightClick(); - } - - /* - 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() - { - CreateRecipe(). - AddIngredient(ItemID.FlinxFur, 2). - AddIngredient(ItemID.Silk, 5). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/SummonItems/Abombination.cs b/Items/SummonItems/Abombination.cs index 5897c5788b..c842ac181a 100644 --- a/Items/SummonItems/Abombination.cs +++ b/Items/SummonItems/Abombination.cs @@ -54,8 +54,7 @@ namespace CalamityMod.Items.SummonItems { CreateRecipe(). AddIngredient(20). - AddRecipeGroup("IronBar", 8). - AddIngredient(8). + AddIngredient(12). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func condition), condition). AddTile(TileID.MythrilAnvil). Register(); diff --git a/Items/SummonItems/BloodyWormFood.cs b/Items/SummonItems/BloodyWormFood.cs index 590d5c5b4b..b5dd639393 100644 --- a/Items/SummonItems/BloodyWormFood.cs +++ b/Items/SummonItems/BloodyWormFood.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.SummonItems { CreateRecipe() .AddIngredient(ItemID.CrimtaneBar, 3) - .AddIngredient(7) + .AddIngredient(7) .AddIngredient(ItemID.Vertebrae, 13) .AddTile(TileID.DemonAltar) .AddDecraftCondition(CalamityConditions.DownedPerforator) diff --git a/Items/SummonItems/CeremonialUrn.cs b/Items/SummonItems/CeremonialUrn.cs index b3dcdb5e58..d0e5bfa47e 100644 --- a/Items/SummonItems/CeremonialUrn.cs +++ b/Items/SummonItems/CeremonialUrn.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.SummonItems { Item.width = 34; Item.height = 54; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) diff --git a/Items/SummonItems/CosmicWorm.cs b/Items/SummonItems/CosmicWorm.cs index fb810a7c9e..2c7bbb1321 100644 --- a/Items/SummonItems/CosmicWorm.cs +++ b/Items/SummonItems/CosmicWorm.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Materials; using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Rarities; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -40,11 +39,11 @@ namespace CalamityMod.Items.SummonItems public override bool? UseItem(Player player) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText7"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + // Server literally do nothing here. + if (Main.dedServ) + return true; - CalamityUtils.SpawnBossUsingItem(player, DevourerofGodsHead.SpawnSound); + NPC n = CalamityUtils.SpawnBossOnPosUsingItem(player, (int)player.Center.X, (int)player.Center.Y - 1600, DevourerofGodsHead.SpawnSound); return true; } @@ -54,7 +53,7 @@ namespace CalamityMod.Items.SummonItems AddIngredient(). AddIngredient(). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register() .DisableDecraft(); @@ -63,9 +62,8 @@ namespace CalamityMod.Items.SummonItems AddIngredient(ItemID.LunarBar, 40). AddIngredient(10). AddIngredient(40). - AddTile(TileID.LunarCraftingStation). - Register() - .DisableDecraft(); + AddTile(TileID.MythrilAnvil). + Register(); } } } diff --git a/Items/SummonItems/CryoKey.cs b/Items/SummonItems/CryoKey.cs index d8f4048ae0..85360eb9fc 100644 --- a/Items/SummonItems/CryoKey.cs +++ b/Items/SummonItems/CryoKey.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.NPCs.Cryogen; diff --git a/Items/SummonItems/DeathWhistle.cs b/Items/SummonItems/DeathWhistle.cs index 017f3eddee..50784255c0 100644 --- a/Items/SummonItems/DeathWhistle.cs +++ b/Items/SummonItems/DeathWhistle.cs @@ -1,8 +1,6 @@ using CalamityMod.Events; using CalamityMod.NPCs.Ravager; using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -52,7 +50,7 @@ namespace CalamityMod.Items.SummonItems CreateRecipe(). AddIngredient(ItemID.LunarTabletFragment, 15). AddIngredient(ItemID.LihzahrdBrick, 25). - AddTile(TileID.MythrilAnvil). + AddTile(TileID.DemonAltar). Register(); } } diff --git a/Items/SummonItems/DecapoditaSprout.cs b/Items/SummonItems/DecapoditaSprout.cs index 23ada1d63c..5011a26b64 100644 --- a/Items/SummonItems/DecapoditaSprout.cs +++ b/Items/SummonItems/DecapoditaSprout.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return player.ZoneGlowshroom && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; + return player.ZoneGlowshroom && (player.position.Y / 16f) > Main.worldSurface && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; } public override bool? UseItem(Player player) diff --git a/Items/SummonItems/EidolonTablet.cs b/Items/SummonItems/EidolonTablet.cs index efbc3cdfc3..ab9d6b9b34 100644 --- a/Items/SummonItems/EidolonTablet.cs +++ b/Items/SummonItems/EidolonTablet.cs @@ -45,7 +45,6 @@ namespace CalamityMod.Items.SummonItems { switch (npc.type) { - case NPCID.CultistTablet: case NPCID.CultistBoss: case NPCID.LunarTowerSolar: case NPCID.LunarTowerVortex: diff --git a/Items/SummonItems/ExoticPheromones.cs b/Items/SummonItems/ExoticPheromones.cs index 995118804c..6c6504bc90 100644 --- a/Items/SummonItems/ExoticPheromones.cs +++ b/Items/SummonItems/ExoticPheromones.cs @@ -34,12 +34,12 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return player.ZoneJungle && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; + return player.ZoneJungle && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; } public override bool? UseItem(Player player) { - CalamityUtils.SpawnBossUsingItem(player, SoundID.Roar); + CalamityUtils.SpawnBossUsingItem(player, SoundID.Roar); return true; } diff --git a/Items/SummonItems/EyeofDesolation.cs b/Items/SummonItems/EyeofDesolation.cs index 8168d6aae7..4f400f3f02 100644 --- a/Items/SummonItems/EyeofDesolation.cs +++ b/Items/SummonItems/EyeofDesolation.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.NPCs.CalClone; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,15 +11,6 @@ namespace CalamityMod.Items.SummonItems public class EyeofDesolation : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.SummonItems"; - public Rectangle safeBox = default; - public int spawnX = 0; - public int spawnX2 = 0; - public int spawnXReset = 0; - public int spawnXReset2 = 0; - public int spawnXAdd = 200; - public int spawnY = 0; - public int spawnYReset = 0; - public int spawnYAdd = 0; public override void SetStaticDefaults() { ItemID.Sets.SortingPriorityBossSpawns[Type] = 11; // Pirate Map (1 above Mechanical Skull) @@ -45,56 +34,15 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return !Main.IsItDay() && !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; + return !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; } public override bool? UseItem(Player player) { CalamityUtils.SpawnBossUsingItem(player, SoundID.Roar); - - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) - { - safeBox.X = spawnX = spawnXReset = (int)(player.Center.X - 1250f); - spawnX2 = spawnXReset2 = (int)(player.Center.X + 1250f); - safeBox.Y = spawnY = spawnYReset = (int)(player.Center.Y - 1250f); - safeBox.Width = 2500; - safeBox.Height = 2500; - spawnYAdd = 125; - - int safeBoxTilesX = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; - int safeBoxTilesY = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; - int safeBoxTilesWidth = safeBox.Width / 2 / 16 + 1; - for (int i = safeBoxTilesX - safeBoxTilesWidth; i <= safeBoxTilesX + safeBoxTilesWidth; i++) - { - for (int j = safeBoxTilesY - safeBoxTilesWidth; j <= safeBoxTilesY + safeBoxTilesWidth; j++) - { - if (!WorldGen.InWorld(i, j, 2)) - continue; - - int xoffset = 0; - int yoffset = 0; - - if ((i == safeBoxTilesX - safeBoxTilesWidth || i == safeBoxTilesX + safeBoxTilesWidth || j == safeBoxTilesY - safeBoxTilesWidth || j == safeBoxTilesY + safeBoxTilesWidth) && !Main.tile[i + xoffset, j + yoffset].HasTile) - { - Main.tile[i + xoffset, j + yoffset].TileType = (ushort)ModContent.TileType(); - Main.tile[i + xoffset, j + yoffset].Get().HasTile = true; - } - if (Main.dedServ) - { - NetMessage.SendTileSquare(-1, i + xoffset, j + yoffset, 1, TileChangeType.None); - } - else - { - WorldGen.SquareTileFrame(i + xoffset, j + yoffset, true); - } - } - } - } return true; } - public override void ModifyTooltips(List list) => list.FindAndReplace("[GFB]", Main.zenithWorld ? "\n" + this.GetLocalizedValue("GFBInfo") : string.Empty); - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/SummonItems/Invasion/CausticTear.cs b/Items/SummonItems/Invasion/CausticTear.cs index 75deb7d52b..0663d7c312 100644 --- a/Items/SummonItems/Invasion/CausticTear.cs +++ b/Items/SummonItems/Invasion/CausticTear.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Items.SummonItems.Invasion public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { + Item.ResearchUnlockCount = 3; ItemID.Sets.SortingPriorityBossSpawns[Type] = 4; // Goblin Battle Standard } @@ -18,12 +19,11 @@ namespace CalamityMod.Items.SummonItems.Invasion { Item.width = 16; Item.height = 28; - Item.maxStack = 1; - Item.rare = ItemRarityID.Green; - Item.useAnimation = 10; - Item.useTime = 10; + Item.consumable = true; + Item.maxStack = Item.CommonMaxStack; + Item.useAnimation = Item.useTime = 10; Item.useStyle = ItemUseStyleID.HoldUp; - Item.consumable = false; + Item.rare = ItemRarityID.Green; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -51,7 +51,7 @@ namespace CalamityMod.Items.SummonItems.Invasion public override void AddRecipes() { CreateRecipe(). - AddIngredient(5). + AddIngredient(). AddCondition(Condition.NearWater). Register(); } diff --git a/Items/SummonItems/Invasion/MartianDistressRemote.cs b/Items/SummonItems/Invasion/MartianDistressRemote.cs index 880a169570..73140ce6ff 100644 --- a/Items/SummonItems/Invasion/MartianDistressRemote.cs +++ b/Items/SummonItems/Invasion/MartianDistressRemote.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Items.SummonItems.Invasion public int frame = 0; public override void SetStaticDefaults() { + Item.ResearchUnlockCount = 3; ItemID.Sets.SortingPriorityBossSpawns[Type] = 17; // Solar Tablet (1 above Lihzahrd Power Cell) } @@ -22,13 +23,13 @@ namespace CalamityMod.Items.SummonItems.Invasion { Item.width = 26; Item.height = 52; - Item.maxStack = 1; - Item.rare = ItemRarityID.Yellow; - Item.useAnimation = 10; - Item.useTime = 10; - Item.useStyle = ItemUseStyleID.HoldUp; - Item.consumable = false; + Item.consumable = true; + Item.maxStack = Item.CommonMaxStack; + Item.useAnimation = Item.useTime = 10; Item.UseSound = SoundID.Zombie67; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.value = Item.buyPrice(gold: 50); // Sold by Cyborg + Item.rare = ItemRarityID.Yellow; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) diff --git a/Items/SummonItems/MarkofProvidence.cs b/Items/SummonItems/MarkofProvidence.cs index d41c16641b..fb8b8032d1 100644 --- a/Items/SummonItems/MarkofProvidence.cs +++ b/Items/SummonItems/MarkofProvidence.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Items.SummonItems AddIngredient(ItemID.LunarBar, 3). AddIngredient(40). AddIngredient(ItemID.FragmentSolar, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/SummonItems/NO.cs b/Items/SummonItems/NO.cs index 6578012f85..b51b1d575d 100644 --- a/Items/SummonItems/NO.cs +++ b/Items/SummonItems/NO.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.SummonItems public override void SetDefaults() { Item.width = Item.height = 32; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.useAnimation = 10; Item.useTime = 10; Item.useStyle = ItemUseStyleID.HoldUp; diff --git a/Items/SummonItems/NaiadsWarhorn.cs b/Items/SummonItems/NaiadsWarhorn.cs index ff3e494d4f..4ce5c72e6c 100644 --- a/Items/SummonItems/NaiadsWarhorn.cs +++ b/Items/SummonItems/NaiadsWarhorn.cs @@ -1,12 +1,10 @@ using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.FurnitureDriftwood; using CalamityMod.NPCs.Leviathan; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Steamworks; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Items/SummonItems/NecroplasmicBeacon.cs b/Items/SummonItems/NecroplasmicBeacon.cs index ff4eabadb1..93b6e698ef 100644 --- a/Items/SummonItems/NecroplasmicBeacon.cs +++ b/Items/SummonItems/NecroplasmicBeacon.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.SummonItems CreateRecipe(). AddRecipeGroup("Wood", 25). AddIngredient(50). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/SummonItems/ProfanedShard.cs b/Items/SummonItems/ProfanedShard.cs index 11a1a9a4df..623d77197c 100644 --- a/Items/SummonItems/ProfanedShard.cs +++ b/Items/SummonItems/ProfanedShard.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.NPCs.ProfanedGuardians; using Terraria; @@ -50,7 +49,7 @@ namespace CalamityMod.Items.SummonItems CreateRecipe(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(25). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/SummonItems/Teratoma.cs b/Items/SummonItems/Teratoma.cs index fabb86b0a4..9e09b791ae 100644 --- a/Items/SummonItems/Teratoma.cs +++ b/Items/SummonItems/Teratoma.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.SummonItems { CreateRecipe(). AddIngredient(ItemID.DemoniteBar, 3). - AddIngredient(7). + AddIngredient(7). AddIngredient(ItemID.RottenChunk, 13). AddTile(TileID.DemonAltar). AddDecraftCondition(CalamityConditions.DownedHiveMind). diff --git a/Items/SummonItems/YharonEgg.cs b/Items/SummonItems/YharonEgg.cs index ccd197a89e..f5b1b48745 100644 --- a/Items/SummonItems/YharonEgg.cs +++ b/Items/SummonItems/YharonEgg.cs @@ -4,7 +4,6 @@ using CalamityMod.NPCs.Yharon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -27,7 +26,7 @@ namespace CalamityMod.Items.SummonItems Item.useTime = 10; Item.useStyle = ItemUseStyleID.HoldUp; Item.consumable = false; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -56,7 +55,7 @@ namespace CalamityMod.Items.SummonItems CreateRecipe(). AddIngredient(10). AddIngredient(15). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Tools/AcidwoodAxe.cs b/Items/Tools/AcidwoodAxe.cs deleted file mode 100644 index 681916df76..0000000000 --- a/Items/Tools/AcidwoodAxe.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CalamityMod.Items.Placeables.Abyss; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools -{ - public class AcidwoodAxe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Tools"; - public override void SetDefaults() - { - Item.damage = 8; - Item.knockBack = 3f; - Item.useTime = 15; - Item.useAnimation = 23; - Item.axe = 60 / 5; - - Item.DamageType = DamageClass.Melee; - Item.width = 40; - Item.height = 32; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; - Item.rare = ItemRarityID.White; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - } - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Tools/AcidwoodAxe.png b/Items/Tools/AcidwoodAxe.png deleted file mode 100644 index 55652b2c68..0000000000 Binary files a/Items/Tools/AcidwoodAxe.png and /dev/null differ diff --git a/Items/Tools/AcidwoodHammer.cs b/Items/Tools/AcidwoodHammer.cs index 78f5eeb610..4bd66b4d49 100644 --- a/Items/Tools/AcidwoodHammer.cs +++ b/Items/Tools/AcidwoodHammer.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using Terraria; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Tools/AcidwoodPickaxe.cs b/Items/Tools/AcidwoodPickaxe.cs deleted file mode 100644 index 95630050c4..0000000000 --- a/Items/Tools/AcidwoodPickaxe.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CalamityMod.Items.Placeables.Abyss; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools -{ - public class AcidwoodPickaxe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Tools"; - public override void SetDefaults() - { - Item.damage = 5; - Item.knockBack = 1f; - Item.useTime = 8; - Item.useAnimation = 18; - Item.pick = 40; - - Item.DamageType = DamageClass.Melee; - Item.width = 36; - Item.height = 36; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; - Item.rare = ItemRarityID.White; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(15). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Tools/AcidwoodPickaxe.png b/Items/Tools/AcidwoodPickaxe.png deleted file mode 100644 index 800c0698de..0000000000 Binary files a/Items/Tools/AcidwoodPickaxe.png and /dev/null differ diff --git a/Items/Tools/AerialHamaxe.cs b/Items/Tools/AerialHamaxe.cs index 7f257532ef..d07fd537db 100644 --- a/Items/Tools/AerialHamaxe.cs +++ b/Items/Tools/AerialHamaxe.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Tools CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.SunplateBlock, 5). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/BallAndChain.cs b/Items/Tools/BallAndChain.cs new file mode 100644 index 0000000000..18a6e566d7 --- /dev/null +++ b/Items/Tools/BallAndChain.cs @@ -0,0 +1,90 @@ +using System.Collections.Generic; +using System.IO; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Items.Tools +{ + public class BallAndChain : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + + public static Asset DisabledSprite; + public override void Load() => DisabledSprite = ModContent.Request("CalamityMod/Items/Tools/BallAndChainDisabled"); + + public override void SetDefaults() + { + Item.width = 48; + Item.height = 48; + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther; + } + + #region Toggling + public bool Enabled = true; + + public override ModItem Clone(Item item) + { + var clone = (BallAndChain)base.Clone(item); + clone.Enabled = Enabled; + return clone; + } + + public override void SaveData(TagCompound tag) => tag.Add("blockerEnabled", Enabled); + public override void LoadData(TagCompound tag) => Enabled = tag.GetBool("blockerEnabled"); + public override void NetSend(BinaryWriter writer) => writer.Write(Enabled); + public override void NetReceive(BinaryReader reader) => Enabled = reader.ReadBoolean(); + + public override bool CanRightClick() => true; + public override bool ConsumeItem(Player player) => false; + public override void RightClick(Player player) + { + Enabled = !Enabled; + Item.NetStateChanged(); + } + #endregion + + public override bool CanUseItem(Player player) => false; + public override void UpdateInventory(Player player) => player.Calamity().blockAllDashes |= Enabled; + + public override void ModifyTooltips(List tooltips) + { + string text = this.GetLocalizedValue(Enabled ? "TooltipEnabled" : "TooltipDisabled"); + tooltips.FindAndReplace("[STATE]", text); + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D tex = Enabled ? TextureAssets.Item[Type].Value : DisabledSprite.Value; + CalamityUtils.DrawInventoryCustomScale(spriteBatch, tex, position, frame, drawColor, itemColor, origin, scale, 0.8f); + return false; + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D tex = Enabled ? TextureAssets.Item[Type].Value : DisabledSprite.Value; + Vector2 origin = tex.Size() / 2f; + spriteBatch.Draw(tex, Item.Bottom - Main.screenPosition - Vector2.UnitY * origin.Y, null, lightColor, rotation, origin, scale, SpriteEffects.None, 0f); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddRecipeGroup("IronBar", 10). + AddIngredient(ItemID.Chain). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Tools/BallAndChain.png b/Items/Tools/BallAndChain.png new file mode 100644 index 0000000000..349d76abf6 Binary files /dev/null and b/Items/Tools/BallAndChain.png differ diff --git a/Items/Tools/BallAndChainDisabled.png b/Items/Tools/BallAndChainDisabled.png new file mode 100644 index 0000000000..ffcd47384e Binary files /dev/null and b/Items/Tools/BallAndChainDisabled.png differ diff --git a/Items/Tools/BlossomPickaxe.cs b/Items/Tools/BlossomPickaxe.cs index 6030917674..3af6f63a84 100644 --- a/Items/Tools/BlossomPickaxe.cs +++ b/Items/Tools/BlossomPickaxe.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Tools { CreateRecipe(). AddIngredient(7). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/BrimstoneLocus.cs b/Items/Tools/BrimstoneLocus.cs similarity index 83% rename from Items/BrimstoneLocus.cs rename to Items/Tools/BrimstoneLocus.cs index cb7ab3a98b..19e3fab570 100644 --- a/Items/BrimstoneLocus.cs +++ b/Items/Tools/BrimstoneLocus.cs @@ -3,16 +3,16 @@ using CalamityMod.Rarities; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items +namespace CalamityMod.Items.Tools { public class BrimstoneLocus : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Misc"; + public new string LocalizationCategory => "Items.Tools"; public override void SetDefaults() { Item.width = 20; Item.height = 20; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = 0; } diff --git a/Items/BrimstoneLocus.png b/Items/Tools/BrimstoneLocus.png similarity index 100% rename from Items/BrimstoneLocus.png rename to Items/Tools/BrimstoneLocus.png diff --git a/Items/Tools/ClimateChange/Bakidon.cs b/Items/Tools/ClimateChange/Bakidon.cs new file mode 100644 index 0000000000..304f80c05f --- /dev/null +++ b/Items/Tools/ClimateChange/Bakidon.cs @@ -0,0 +1,86 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent.Creative; +using Terraria.GameContent.NetModules; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Net; + +namespace CalamityMod.Items.Tools.ClimateChange +{ + [LegacyName("Moonlight")] + public class Bakidon : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + + public static int FreezeTime => CalamityUtils.MinutesToFrames(10); + public static float RechargeMultiplier => 1; + + public override void SetDefaults() + { + Item.width = 20; + Item.height = 20; + Item.rare = ItemRarityID.LightRed; + Item.useAnimation = 9; + Item.useTime = 9; + Item.autoReuse = false; // Explicitly not autofire, since it can be used quickly now + Item.useStyle = ItemUseStyleID.HoldUp; + Item.UseSound = SoundID.Item60; + Item.consumable = false; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther; + } + + public override bool? UseItem(Player player) + { + player.Calamity().WeakTimeFreezeInUse = !player.Calamity().WeakTimeFreezeInUse; + if (Main.netMode != NetmodeID.Server && player == Main.LocalPlayer) + { + var power = CreativePowerManager.Instance.GetPower(); + NetPacket packet = NetCreativePowersModule.PreparePacket(power.PowerId, 1); + packet.Writer.Write(player.Calamity().WeakTimeFreezeInUse); + NetManager.Instance.SendToServerOrLoopback(packet); + } + return true; + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + var cplayer = Main.LocalPlayer.Calamity(); + float fill = 1 - cplayer.WeakTimeFreezeUseTimer / (float)(FreezeTime / RechargeMultiplier); + if (fill >= 1) + return; + + float barScale = 1.1f; + + var barBG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; + var barFG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; + + Vector2 barOrigin = barBG.Size() * 0.5f; + float yOffset = 7.5f; + Vector2 drawPos = position + Vector2.UnitY * scale * (frame.Height - yOffset); + Rectangle frameCrop = new Rectangle(0, 0, (int)((fill) * barFG.Width), barFG.Height); + Color colorBG = Color.DarkViolet * 0.5f; + Color colorFG = Color.Lerp(Color.Orange, Color.Green, fill); + + spriteBatch.Draw(barBG, drawPos, null, colorBG, 0f, barOrigin, scale * barScale, 0f, 0f); + spriteBatch.Draw(barFG, drawPos, frameCrop, colorFG, 0f, barOrigin, scale * barScale, 0f, 0f); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.FallenStar, 10). + AddIngredient(ItemID.SoulofLight, 7). + AddIngredient(ItemID.SoulofNight, 7). + AddIngredient(5). + AddTile(TileID.DemonAltar). + Register(); + } + } +} diff --git a/Items/Tools/ClimateChange/Bakidon.png b/Items/Tools/ClimateChange/Bakidon.png new file mode 100644 index 0000000000..e48b63f744 Binary files /dev/null and b/Items/Tools/ClimateChange/Bakidon.png differ diff --git a/Items/Tools/ClimateChange/Cosmolight.cs b/Items/Tools/ClimateChange/Cosmolight.cs index b380c4f384..1eced6ca1b 100644 --- a/Items/Tools/ClimateChange/Cosmolight.cs +++ b/Items/Tools/ClimateChange/Cosmolight.cs @@ -1,18 +1,17 @@ -using CalamityMod.CalPlayer; +using System.Linq; using CalamityMod.Items.Materials; using Terraria; +using Terraria.GameContent.Creative; +using Terraria.GameContent.NetModules; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Net; namespace CalamityMod.Items.Tools.ClimateChange { public class Cosmolight : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Tools"; - // Hardcoded times set by the vanilla Journey Mode buttons. - // These are "halfway through day" and "halfway through night" respectively. - private const int NoonCutoff = 27000; - private const int MidnightCutoff = 16200; public override void SetDefaults() { @@ -21,10 +20,11 @@ namespace CalamityMod.Items.Tools.ClimateChange Item.rare = ItemRarityID.LightRed; Item.useAnimation = 9; Item.useTime = 9; - Item.autoReuse = false; // Explicitly not autofire, since it can be used quickly now + Item.autoReuse = false; Item.useStyle = ItemUseStyleID.HoldUp; Item.UseSound = SoundID.Item60; Item.consumable = false; + Item.channel = true; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) @@ -32,42 +32,51 @@ namespace CalamityMod.Items.Tools.ClimateChange itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther; } - public override bool CanUseItem(Player player) => !CalamityPlayer.areThereAnyDamnBosses; + public override bool AltFunctionUse(Player player) + { + return true; + } public override bool? UseItem(Player player) { - //Only SinglePlayer or DedServ should change time to prevent unwanted race condition - if (Main.netMode == NetmodeID.MultiplayerClient) - return true; - - // Early Morning -> Noon - if (Main.dayTime && Main.time < NoonCutoff) - Main.SkipToTime(NoonCutoff, true); - - // Afternoon -> Dusk - else if (Main.dayTime) - Main.SkipToTime(0, false); - - // Early Night -> Midnight - else if (!Main.dayTime && Main.time < MidnightCutoff) - Main.SkipToTime(MidnightCutoff, false); - - // Late Night -> Dawn - else if (!Main.dayTime) - Main.SkipToTime(0, true); - + if (Main.netMode != NetmodeID.Server && player == Main.LocalPlayer && (player.altFunctionUse == 2 || (CreativePowerManager.Instance.GetPower().Enabled))) + { + var power = CreativePowerManager.Instance.GetPower(); + NetPacket packet = NetCreativePowersModule.PreparePacket(power.PowerId, 1); + packet.Writer.Write(!power.Enabled); + NetManager.Instance.SendToServerOrLoopback(packet); + } return true; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.FallenStar, 10). - AddIngredient(ItemID.SoulofLight, 7). - AddIngredient(ItemID.SoulofNight, 7). - AddIngredient(5). - AddTile(TileID.Anvils). + AddIngredient(). + AddIngredient(ItemID.Sundial). + AddIngredient(3). + AddIngredient(ItemID.FragmentSolar, 15). + AddTile(TileID.DemonAltar). + Register(); + + CreateRecipe(). + AddIngredient(). + AddIngredient(ItemID.Moondial). + AddIngredient(3). + AddIngredient(ItemID.FragmentSolar, 15). + AddTile(TileID.DemonAltar). Register(); } } + + public class CosmolightTimeRateChange : ModSystem + { + public override void ModifyTimeRate(ref double timeRate, ref double tileUpdateRate, ref double eventUpdateRate) + { + if (Main.player.Any(x => x.active && x.channel && x.altFunctionUse != 2 && x.HeldItem.type == ModContent.ItemType())) + { + timeRate *= 120; + } + } + } } diff --git a/Items/Tools/DisgustingMeat.cs b/Items/Tools/DisgustingMeat.cs new file mode 100644 index 0000000000..8a32de7347 --- /dev/null +++ b/Items/Tools/DisgustingMeat.cs @@ -0,0 +1,98 @@ +using CalamityMod.Items.PermanentBoosters; +using CalamityMod.Items.Potions.Food; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class DisgustingMeat : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + + public override void SetStaticDefaults() + { + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + } + public override void SetDefaults() + { + Item.DefaultToFood(26, 36, 0, 0); + Item.value = 0; + Item.UseSound = SoundID.NPCDeath13; + Item.maxStack = 1; + Item.consumable = false; + } + + public override bool AltFunctionUse(Player player) => true; + public override bool? UseItem(Player player) + { + if (player.ItemTimeIsZero) + { + var calPlayer = player.Calamity(); + if (player.altFunctionUse == 2) + { + TryDropBoosterItem(player, ref calPlayer.rageBoostOne, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.rageBoostTwo, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.rageBoostThree, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.adrenalineBoostOne, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.adrenalineBoostTwo, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.adrenalineBoostThree, ModContent.ItemType()); + } + else + { + if (calPlayer.sTangerine || calPlayer.mFruit || calPlayer.tCloudberry || calPlayer.sStrawberry) + { + TryDropBoosterItem(player, ref calPlayer.sTangerine, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.mFruit, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.tCloudberry, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.sStrawberry, ModContent.ItemType()); + } + else + { + for (int i = 0; i < player.ConsumedLifeFruit; i++) + { + int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.LifeFruit); + Main.item[drop].noGrabDelay = 100; + } + player.ConsumedLifeFruit = 0; + for (int j = 0; j < player.ConsumedLifeCrystals; j++) + { + int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.LifeCrystal); + Main.item[drop].noGrabDelay = 100; + } + player.ConsumedLifeCrystals = 0; + } + + if (calPlayer.cShard || calPlayer.eCore || calPlayer.pHeart) + { + TryDropBoosterItem(player, ref calPlayer.cShard, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.eCore, ModContent.ItemType()); + TryDropBoosterItem(player, ref calPlayer.pHeart, ModContent.ItemType()); + } + else + { + for (int k = 0; k < player.ConsumedManaCrystals; k++) + { + int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, ItemID.ManaCrystal); + Main.item[drop].noGrabDelay = 100; + } + player.ConsumedManaCrystals = 0; + } + } + return true; + } + + return null; + } + + private static void TryDropBoosterItem(Player player, ref bool condition, int itemType) + { + if (condition) + { + condition = false; + int drop = Item.NewItem(player.GetSource_DropAsItem(), player.Hitbox, itemType); + Main.item[drop].noGrabDelay = 100; + } + } + } +} diff --git a/Items/Tools/DisgustingMeat.png b/Items/Tools/DisgustingMeat.png new file mode 100644 index 0000000000..9e015178f3 Binary files /dev/null and b/Items/Tools/DisgustingMeat.png differ diff --git a/Items/Tools/DriftwoodAxe.cs b/Items/Tools/DriftwoodAxe.cs deleted file mode 100644 index 2d06c0f68f..0000000000 --- a/Items/Tools/DriftwoodAxe.cs +++ /dev/null @@ -1,61 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools -{ - public class DriftwoodAxe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Tools"; - - public static int NormalUseTime = 15; - public static int FasterUseTime = 11; - - public override void SetDefaults() - { - Item.damage = 9; - Item.knockBack = 3.5f; - Item.useTime = NormalUseTime; - Item.useAnimation = 30; - Item.axe = 60 / 5; - - Item.DamageType = DamageClass.Melee; - Item.width = 40; - Item.height = 34; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; - Item.rare = ItemRarityID.White; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - } - - // The tool is mechanically faster when wet. - public override float UseTimeMultiplier(Player player) - { - bool surface = player.Center.Y < Main.worldSurface * 16.0; - bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); - if (GetEffects) - return (float)FasterUseTime / NormalUseTime; - return base.UseTimeMultiplier(player); - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - bool surface = player.Center.Y < Main.worldSurface * 16.0; - bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); - if (GetEffects) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Tools/DriftwoodAxe.png b/Items/Tools/DriftwoodAxe.png deleted file mode 100644 index 9fb519983f..0000000000 Binary files a/Items/Tools/DriftwoodAxe.png and /dev/null differ diff --git a/Items/Tools/DriftwoodHammer.cs b/Items/Tools/DriftwoodHammer.cs index 2a1917c2e2..a49cc26b67 100644 --- a/Items/Tools/DriftwoodHammer.cs +++ b/Items/Tools/DriftwoodHammer.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.FurnitureDriftwood; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Tools bool surface = player.Center.Y < Main.worldSurface * 16.0; bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); if (GetEffects) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.MagnetSphere); } public override void AddRecipes() diff --git a/Items/Tools/DriftwoodPickaxe.cs b/Items/Tools/DriftwoodPickaxe.cs deleted file mode 100644 index dbec552f83..0000000000 --- a/Items/Tools/DriftwoodPickaxe.cs +++ /dev/null @@ -1,61 +0,0 @@ -using CalamityMod.Items.Placeables.SunkenSea; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools -{ - public class DriftwoodPickaxe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Tools"; - - public static int NormalUseTime = 8; - public static int FasterUseTime = 6; - - public override void SetDefaults() - { - Item.damage = 7; - Item.knockBack = 1.5f; - Item.useTime = NormalUseTime; - Item.useAnimation = 18; - Item.pick = 45; - - Item.DamageType = DamageClass.Melee; - Item.width = 38; - Item.height = 38; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; - Item.rare = ItemRarityID.White; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - } - - // The tool is mechanically faster when wet. - public override float UseTimeMultiplier(Player player) - { - bool surface = player.Center.Y < Main.worldSurface * 16.0; - bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); - if (GetEffects) - return (float)FasterUseTime / NormalUseTime; - return base.UseTimeMultiplier(player); - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - bool surface = player.Center.Y < Main.worldSurface * 16.0; - bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); - if (GetEffects) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(15). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Tools/DriftwoodPickaxe.png b/Items/Tools/DriftwoodPickaxe.png deleted file mode 100644 index 8e7156c574..0000000000 Binary files a/Items/Tools/DriftwoodPickaxe.png and /dev/null differ diff --git a/Items/Tools/FellerofEvergreens.cs b/Items/Tools/FellerofEvergreens.cs index 4d95f705b3..27e3ff40a1 100644 --- a/Items/Tools/FellerofEvergreens.cs +++ b/Items/Tools/FellerofEvergreens.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ID; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Tools @@ -30,7 +29,7 @@ namespace CalamityMod.Items.Tools { CreateRecipe(). AddRecipeGroup("AnySilverBar", 18). - AddRecipeGroup("Wood", 18). + AddIngredient(ItemID.RichMahogany, 18). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/Gelpick.cs b/Items/Tools/Gelpick.cs index 8dddba14cd..c10908edba 100644 --- a/Items/Tools/Gelpick.cs +++ b/Items/Tools/Gelpick.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -16,9 +15,9 @@ namespace CalamityMod.Items.Tools Item.height = 48; Item.damage = 19; Item.knockBack = 2.5f; - Item.useTime = 9; - Item.useAnimation = 20; - Item.pick = 105; + Item.useTime = 6; + Item.useAnimation = 12; + Item.pick = 90; Item.tileBoost += 1; Item.DamageType = DamageClass.Melee; @@ -35,7 +34,7 @@ namespace CalamityMod.Items.Tools CreateRecipe(). AddIngredient(12). AddIngredient(12). - AddTile(). + AddTile(TileID.Solidifier). Register(); } diff --git a/Items/Tools/GenesisPickaxe.cs b/Items/Tools/GenesisPickaxe.cs index c74692833c..056e668089 100644 --- a/Items/Tools/GenesisPickaxe.cs +++ b/Items/Tools/GenesisPickaxe.cs @@ -3,10 +3,8 @@ using CalamityMod.Items.Materials; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Graphics.Renderers; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Utilities.Terraria.Utilities; namespace CalamityMod.Items.Tools { diff --git a/Items/Tools/Grax.cs b/Items/Tools/Grax.cs index dfa90262bf..1cd4cc87d7 100644 --- a/Items/Tools/Grax.cs +++ b/Items/Tools/Grax.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Tools AddIngredient(). AddRecipeGroup("LunarHamaxe"). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Tools/GreatbayPickaxe.cs b/Items/Tools/GreatbayPickaxe.cs index abc45a967d..ca95c84031 100644 --- a/Items/Tools/GreatbayPickaxe.cs +++ b/Items/Tools/GreatbayPickaxe.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Tools/InfernaCutter.cs b/Items/Tools/InfernaCutter.cs index 54feccc2ee..e4b232899e 100644 --- a/Items/Tools/InfernaCutter.cs +++ b/Items/Tools/InfernaCutter.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Tools/MarniteDeconstructor.cs b/Items/Tools/MarniteDeconstructor.cs index 5e1fd756fd..25f1c986f9 100644 --- a/Items/Tools/MarniteDeconstructor.cs +++ b/Items/Tools/MarniteDeconstructor.cs @@ -1,6 +1,5 @@ using CalamityMod.Projectiles.Melee; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/MomentumCapacitor.cs b/Items/Tools/MomentumCapacitor.cs similarity index 91% rename from Items/MomentumCapacitor.cs rename to Items/Tools/MomentumCapacitor.cs index b5bf27973e..e3be6272b5 100644 --- a/Items/MomentumCapacitor.cs +++ b/Items/Tools/MomentumCapacitor.cs @@ -1,15 +1,14 @@ using System.Collections.Generic; using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items +namespace CalamityMod.Items.Tools { public class MomentumCapacitor : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Misc"; + public new string LocalizationCategory => "Items.Tools"; internal const float MomentumChargePerFrame = 0.02f; internal const float MaxMomentumCharge = 5.8f; // +580% movemnt speed internal const int TotalFadeTime = 16; @@ -18,7 +17,7 @@ namespace CalamityMod.Items { Item.width = 28; Item.height = 32; - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.value = Item.buyPrice(gold: 50); // Sold by Bandit Item.rare = ItemRarityID.Pink; Item.useStyle = ItemUseStyleID.HoldUp; diff --git a/Items/MomentumCapacitor.png b/Items/Tools/MomentumCapacitor.png similarity index 100% rename from Items/MomentumCapacitor.png rename to Items/Tools/MomentumCapacitor.png diff --git a/Items/Tools/MonolithAxe.cs b/Items/Tools/MonolithAxe.cs deleted file mode 100644 index a34af5e678..0000000000 --- a/Items/Tools/MonolithAxe.cs +++ /dev/null @@ -1,45 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Astral; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools -{ - public class MonolithAxe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Tools"; - public override void SetDefaults() - { - Item.damage = 25; - Item.knockBack = 2f; - Item.useTime = 8; - Item.useAnimation = 8; - Item.axe = 90 / 5; - Item.tileBoost = 1; - - Item.DamageType = DamageClass.Melee; - Item.width = 38; - Item.height = 36; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(3)) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()); - } - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(10). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Tools/MonolithAxe.png b/Items/Tools/MonolithAxe.png deleted file mode 100644 index b87a887ee3..0000000000 Binary files a/Items/Tools/MonolithAxe.png and /dev/null differ diff --git a/Items/Tools/MonolithHammer.cs b/Items/Tools/MonolithHammer.cs index 4c30aa8ccb..0280dc5695 100644 --- a/Items/Tools/MonolithHammer.cs +++ b/Items/Tools/MonolithHammer.cs @@ -1,5 +1,5 @@ using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Items/Tools/MonolithPickaxe.cs b/Items/Tools/MonolithPickaxe.cs deleted file mode 100644 index 5281c45aae..0000000000 --- a/Items/Tools/MonolithPickaxe.cs +++ /dev/null @@ -1,45 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Astral; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools -{ - public class MonolithPickaxe : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Tools"; - public override void SetDefaults() - { - Item.damage = 19; - Item.knockBack = 0.8f; - Item.useTime = 6; - Item.useAnimation = 6; - Item.pick = 90; - Item.tileBoost = 1; - - Item.DamageType = DamageClass.Melee; - Item.width = 38; - Item.height = 40; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(3)) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()); - } - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(15). - AddTile(TileID.WorkBenches). - Register(); - } - } -} diff --git a/Items/Tools/MonolithPickaxe.png b/Items/Tools/MonolithPickaxe.png deleted file mode 100644 index d4e945293c..0000000000 Binary files a/Items/Tools/MonolithPickaxe.png and /dev/null differ diff --git a/Items/NormalityRelocator.cs b/Items/Tools/NormalityRelocator.cs similarity index 92% rename from Items/NormalityRelocator.cs rename to Items/Tools/NormalityRelocator.cs index 12efc351c0..0e33d5589c 100644 --- a/Items/NormalityRelocator.cs +++ b/Items/Tools/NormalityRelocator.cs @@ -8,11 +8,11 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items +namespace CalamityMod.Items.Tools { public class NormalityRelocator : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Misc"; + public new string LocalizationCategory => "Items.Tools"; public static readonly SoundStyle TeleportSound = new("CalamityMod/Sounds/Item/NormalityRelocator", 3); public override void SetStaticDefaults() { @@ -49,7 +49,7 @@ namespace CalamityMod.Items AddIngredient(ItemID.FragmentStardust, 30). AddIngredient(5). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/NormalityRelocator.png b/Items/Tools/NormalityRelocator.png similarity index 100% rename from Items/NormalityRelocator.png rename to Items/Tools/NormalityRelocator.png diff --git a/Items/Tools/ReefclawHamaxe.cs b/Items/Tools/ReefclawHamaxe.cs index ac0cfd10aa..366d49d15d 100644 --- a/Items/Tools/ReefclawHamaxe.cs +++ b/Items/Tools/ReefclawHamaxe.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/RelicOfConvergence.cs b/Items/Tools/RelicOfConvergence.cs similarity index 85% rename from Items/RelicOfConvergence.cs rename to Items/Tools/RelicOfConvergence.cs index d441f610cc..09dc85fc43 100644 --- a/Items/RelicOfConvergence.cs +++ b/Items/Tools/RelicOfConvergence.cs @@ -4,13 +4,15 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -namespace CalamityMod.Items +namespace CalamityMod.Items.Tools { public class RelicOfConvergence : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Misc"; + public new string LocalizationCategory => "Items.Tools"; - public static int HealValue = 60; + public static int HealValue = 50; + public static float IncomingDamageMultiplier = 1.5f; + public static float DefenseMultiplier = 0.5f; public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(HealValue); public override void SetStaticDefaults() diff --git a/Items/RelicOfConvergence.png b/Items/Tools/RelicOfConvergence.png similarity index 100% rename from Items/RelicOfConvergence.png rename to Items/Tools/RelicOfConvergence.png diff --git a/Items/Tools/RelicOfResilience.cs b/Items/Tools/RelicOfResilience.cs new file mode 100644 index 0000000000..af20a97f04 --- /dev/null +++ b/Items/Tools/RelicOfResilience.cs @@ -0,0 +1,27 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class RelicOfResilience : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.width = 40; + Item.height = 34; + Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; + Item.rare = ItemRarityID.Purple; + } + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ToolsOther; + } + } +} diff --git a/Items/RelicOfResilience.png b/Items/Tools/RelicOfResilience.png similarity index 100% rename from Items/RelicOfResilience.png rename to Items/Tools/RelicOfResilience.png diff --git a/Items/Tools/SkyfringePickaxe.cs b/Items/Tools/SkyfringePickaxe.cs index 5bf89577f3..9a969c5485 100644 --- a/Items/Tools/SkyfringePickaxe.cs +++ b/Items/Tools/SkyfringePickaxe.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Tools CreateRecipe(). AddIngredient(7). AddIngredient(ItemID.SunplateBlock, 3). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/SpawnBlocker/AntiCystOintment.cs b/Items/Tools/SpawnBlocker/AntiCystOintment.cs new file mode 100644 index 0000000000..08abe17ffe --- /dev/null +++ b/Items/Tools/SpawnBlocker/AntiCystOintment.cs @@ -0,0 +1,120 @@ +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Items.Tools.SpawnBlocker +{ + public class AntiCystOintment : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.width = 44; + Item.height = 34; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; + } + + #region Toggle Feature + + public bool Enabled = true; + + public override ModItem Clone(Item item) + { + var clone = (AntiCystOintment)base.Clone(item); + clone.Enabled = Enabled; + return clone; + } + + public override void SaveData(TagCompound tag) => tag.Add("blockerEnabled", Enabled); + + public override void LoadData(TagCompound tag) => Enabled = tag.GetBool("blockerEnabled"); + + public override void NetSend(BinaryWriter writer) => writer.Write(Enabled); + + public override void NetReceive(BinaryReader reader) => Enabled = reader.ReadBoolean(); + + public override bool CanRightClick() => true; + + public override bool ConsumeItem(Player player) => false; + + public override void RightClick(Player player) + { + Enabled = !Enabled; + Item.NetStateChanged(); + } + + #endregion + + public override void UpdateInventory(Player player) + { + player.Calamity().disablePerfCystSpawns |= Enabled; + } + + /* + 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 (Enabled) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.CrimtaneBar, 5). + AddIngredient(ItemID.BottledWater). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/AntiCystOintment.png b/Items/Tools/SpawnBlocker/AntiCystOintment.png similarity index 100% rename from Items/AntiCystOintment.png rename to Items/Tools/SpawnBlocker/AntiCystOintment.png diff --git a/Items/Tools/SpawnBlocker/AntiTumorOintment.cs b/Items/Tools/SpawnBlocker/AntiTumorOintment.cs new file mode 100644 index 0000000000..564dc8d4c3 --- /dev/null +++ b/Items/Tools/SpawnBlocker/AntiTumorOintment.cs @@ -0,0 +1,121 @@ +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Items.Tools.SpawnBlocker +{ + public class AntiTumorOintment : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.width = 44; + Item.height = 34; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; + } + + #region Toggle Feature + + public bool Enabled = true; + + public override ModItem Clone(Item item) + { + var clone = (AntiTumorOintment)base.Clone(item); + clone.Enabled = Enabled; + return clone; + } + + public override void SaveData(TagCompound tag) => tag.Add("blockerEnabled", Enabled); + + public override void LoadData(TagCompound tag) => Enabled = tag.GetBool("blockerEnabled"); + + public override void NetSend(BinaryWriter writer) => writer.Write(Enabled); + + public override void NetReceive(BinaryReader reader) => Enabled = reader.ReadBoolean(); + + public override bool CanRightClick() => true; + + public override bool ConsumeItem(Player player) => false; + + public override void RightClick(Player player) + { + Enabled = !Enabled; + Item.NetStateChanged(); + } + + #endregion + + public override void UpdateInventory(Player player) + { + player.Calamity().disableHiveCystSpawns |= Enabled; + } + + /* + 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 (Enabled) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.DemoniteBar, 5). + AddIngredient(ItemID.BottledWater). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/AntiTumorOintment.png b/Items/Tools/SpawnBlocker/AntiTumorOintment.png similarity index 100% rename from Items/AntiTumorOintment.png rename to Items/Tools/SpawnBlocker/AntiTumorOintment.png diff --git a/Items/Tools/SpawnBlocker/BleachBall.cs b/Items/Tools/SpawnBlocker/BleachBall.cs new file mode 100644 index 0000000000..c2c6df1948 --- /dev/null +++ b/Items/Tools/SpawnBlocker/BleachBall.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.IO; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Items.Tools.SpawnBlocker +{ + public class BleachBall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.width = 38; + Item.height = 46; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; + } + + #region Toggle Feature + + public bool Enabled = true; + + public override ModItem Clone(Item item) + { + var clone = (BleachBall)base.Clone(item); + clone.Enabled = Enabled; + return clone; + } + + public override void SaveData(TagCompound tag) => tag.Add("blockerEnabled", Enabled); + + public override void LoadData(TagCompound tag) => Enabled = tag.GetBool("blockerEnabled"); + + public override void NetSend(BinaryWriter writer) => writer.Write(Enabled); + + public override void NetReceive(BinaryReader reader) => Enabled = reader.ReadBoolean(); + + public override bool CanRightClick() => true; + + public override bool ConsumeItem(Player player) => false; + + public override void RightClick(Player player) + { + Enabled = !Enabled; + Item.NetStateChanged(); + } + + #endregion + + public override void UpdateInventory(Player player) + { + player.Calamity().disableNaturalScourgeSpawns |= Enabled; + } + + /* + 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 (Enabled) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(ItemID.CalmingPotion). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/BleachBall.png b/Items/Tools/SpawnBlocker/BleachBall.png similarity index 100% rename from Items/BleachBall.png rename to Items/Tools/SpawnBlocker/BleachBall.png diff --git a/Items/Tools/SpawnBlocker/BrokenWaterFilter.cs b/Items/Tools/SpawnBlocker/BrokenWaterFilter.cs new file mode 100644 index 0000000000..9740d03c89 --- /dev/null +++ b/Items/Tools/SpawnBlocker/BrokenWaterFilter.cs @@ -0,0 +1,112 @@ +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Items.Tools.SpawnBlocker +{ + public class BrokenWaterFilter : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.width = 32; + Item.height = 34; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; + } + + #region Toggle Feature + + public bool Enabled = true; + + public override ModItem Clone(Item item) + { + var clone = (BrokenWaterFilter)base.Clone(item); + clone.Enabled = Enabled; + return clone; + } + + public override void SaveData(TagCompound tag) => tag.Add("blockerEnabled", Enabled); + + public override void LoadData(TagCompound tag) => Enabled = tag.GetBool("blockerEnabled"); + + public override void NetSend(BinaryWriter writer) => writer.Write(Enabled); + + public override void NetReceive(BinaryReader reader) => Enabled = reader.ReadBoolean(); + + public override bool CanRightClick() => true; + + public override bool ConsumeItem(Player player) => false; + + public override void RightClick(Player player) + { + Enabled = !Enabled; + Item.NetStateChanged(); + } + + #endregion + + public override void UpdateInventory(Player player) + { + player.Calamity().noStupidNaturalARSpawns |= Enabled; + } + + /* + 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 (Enabled) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); + } + } +} diff --git a/Items/BrokenWaterFilter.png b/Items/Tools/SpawnBlocker/BrokenWaterFilter.png similarity index 100% rename from Items/BrokenWaterFilter.png rename to Items/Tools/SpawnBlocker/BrokenWaterFilter.png diff --git a/Items/Tools/SpawnBlocker/SirenproofEarMuffs.cs b/Items/Tools/SpawnBlocker/SirenproofEarMuffs.cs new file mode 100644 index 0000000000..29c1e1e10d --- /dev/null +++ b/Items/Tools/SpawnBlocker/SirenproofEarMuffs.cs @@ -0,0 +1,121 @@ +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Items.Tools.SpawnBlocker +{ + public class SirenproofEarMuffs : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.width = 44; + Item.height = 34; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; + } + + #region Toggle Feature + + public bool Enabled = true; + + public override ModItem Clone(Item item) + { + var clone = (SirenproofEarMuffs)base.Clone(item); + clone.Enabled = Enabled; + return clone; + } + + public override void SaveData(TagCompound tag) => tag.Add("blockerEnabled", Enabled); + + public override void LoadData(TagCompound tag) => Enabled = tag.GetBool("blockerEnabled"); + + public override void NetSend(BinaryWriter writer) => writer.Write(Enabled); + + public override void NetReceive(BinaryReader reader) => Enabled = reader.ReadBoolean(); + + public override bool CanRightClick() => true; + + public override bool ConsumeItem(Player player) => false; + + public override void RightClick(Player player) + { + Enabled = !Enabled; + Item.NetStateChanged(); + } + + #endregion + + public override void UpdateInventory(Player player) + { + player.Calamity().disableAnahitaSpawns |= Enabled; + } + + /* + 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 (Enabled) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.FlinxFur, 2). + AddIngredient(ItemID.Silk, 5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/SirenproofEarMuffs.png b/Items/Tools/SpawnBlocker/SirenproofEarMuffs.png similarity index 100% rename from Items/SirenproofEarMuffs.png rename to Items/Tools/SpawnBlocker/SirenproofEarMuffs.png diff --git a/Items/Tools/SpawnBlocker/VoodooDemonVoodooDoll.cs b/Items/Tools/SpawnBlocker/VoodooDemonVoodooDoll.cs new file mode 100644 index 0000000000..dd57546bb3 --- /dev/null +++ b/Items/Tools/SpawnBlocker/VoodooDemonVoodooDoll.cs @@ -0,0 +1,123 @@ +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Items.Tools.SpawnBlocker +{ + public class VoodooDemonVoodooDoll : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + + 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) + { + itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; + } + + #region Toggle Feature + + public bool Enabled = true; + + public override ModItem Clone(Item item) + { + var clone = (VoodooDemonVoodooDoll)base.Clone(item); + clone.Enabled = Enabled; + return clone; + } + + public override void SaveData(TagCompound tag) => tag.Add("blockerEnabled", Enabled); + + public override void LoadData(TagCompound tag) => Enabled = tag.GetBool("blockerEnabled"); + + public override void NetSend(BinaryWriter writer) => writer.Write(Enabled); + + public override void NetReceive(BinaryReader reader) => Enabled = reader.ReadBoolean(); + + public override bool CanRightClick() => true; + + public override bool ConsumeItem(Player player) => false; + + public override void RightClick(Player player) + { + Enabled = !Enabled; + Item.NetStateChanged(); + } + + #endregion + + public override void UpdateInventory(Player player) + { + player.Calamity().disableVoodooSpawns |= Enabled; + } + + /* + 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 (Enabled) + text = GetTextValue("Items.Misc.SpawnBlockersOn"); + else + text = GetTextValue("Items.Misc.SpawnBlockersOff"); + tooltips.FindAndReplace("[STATE]", text); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.HellstoneBar, 5). + AddIngredient(ItemID.Silk, 5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/VoodooDemonVoodooDoll.png b/Items/Tools/SpawnBlocker/VoodooDemonVoodooDoll.png similarity index 100% rename from Items/VoodooDemonVoodooDoll.png rename to Items/Tools/SpawnBlocker/VoodooDemonVoodooDoll.png diff --git a/Items/SulphurousSeaWorldSideChanger.cs b/Items/Tools/SulphurousSeaWorldSideChanger.cs similarity index 83% rename from Items/SulphurousSeaWorldSideChanger.cs rename to Items/Tools/SulphurousSeaWorldSideChanger.cs index 5dd4542242..8f173a2f35 100644 --- a/Items/SulphurousSeaWorldSideChanger.cs +++ b/Items/Tools/SulphurousSeaWorldSideChanger.cs @@ -1,17 +1,15 @@ -using System; -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.Rarities; using CalamityMod.World; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items +namespace CalamityMod.Items.Tools { public class SulphurousSeaWorldSideChanger : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Misc"; + public new string LocalizationCategory => "Items.Tools"; public override void SetStaticDefaults() { Item.ResearchUnlockCount = 0; @@ -43,7 +41,7 @@ namespace CalamityMod.Items { Abyss.AtLeftSideOfWorld = true; } - CalamityUtils.DisplayLocalizedText(key, AcidRainEvent.TextColor); + CalamityUtils.BroadcastLocalizedText(key, AcidRainEvent.TextColor); return true; } } diff --git a/Items/SulphurousSeaWorldSideChanger.png b/Items/Tools/SulphurousSeaWorldSideChanger.png similarity index 100% rename from Items/SulphurousSeaWorldSideChanger.png rename to Items/Tools/SulphurousSeaWorldSideChanger.png diff --git a/Items/SuperDummy.cs b/Items/Tools/SuperDummy.cs similarity index 93% rename from Items/SuperDummy.cs rename to Items/Tools/SuperDummy.cs index 415c44514a..dd380e9b03 100644 --- a/Items/SuperDummy.cs +++ b/Items/Tools/SuperDummy.cs @@ -5,11 +5,11 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Items +namespace CalamityMod.Items.Tools { public class SuperDummy : ModItem, ILocalizedModType { - public new string LocalizationCategory => "Items.Misc"; + public new string LocalizationCategory => "Items.Tools"; public override void SetDefaults() { Item.width = 20; @@ -59,7 +59,7 @@ namespace CalamityMod.Items } } } - else if (player.whoAmI == Main.myPlayer) + else if (player.whoAmI == Main.myPlayer && NPC.CountNPCS(ModContent.NPCType()) < 50) { int x = (int)Main.MouseWorld.X - 9; int y = (int)Main.MouseWorld.Y - 20; @@ -104,6 +104,7 @@ namespace CalamityMod.Items r = Recipe.Create(ItemID.TargetDummy); r.AddIngredient(); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.TargetDummy); } } } diff --git a/Items/SuperDummy.png b/Items/Tools/SuperDummy.png similarity index 100% rename from Items/SuperDummy.png rename to Items/Tools/SuperDummy.png diff --git a/Items/Tools/WulfrumDiggingTurtle.cs b/Items/Tools/WulfrumDiggingTurtle.cs index 76181d9eeb..828c7d88a9 100644 --- a/Items/Tools/WulfrumDiggingTurtle.cs +++ b/Items/Tools/WulfrumDiggingTurtle.cs @@ -76,9 +76,9 @@ namespace CalamityMod.Items.Tools public override void AddRecipes() { - CreateRecipe(3). - AddIngredient(ItemID.Gel, 5). //Gel is a default combustible item to fuel the motors of the lil guys + CreateRecipe(15). AddIngredient(3). + AddIngredient(). Register(); } } diff --git a/Items/Tools/WulfrumDrill.cs b/Items/Tools/WulfrumDrill.cs index 0d829fad72..99ac145eee 100644 --- a/Items/Tools/WulfrumDrill.cs +++ b/Items/Tools/WulfrumDrill.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Tools public override void AddRecipes() { CreateRecipe(). - AddIngredient(8). + AddIngredient(5). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/WulfrumTreasurePinger.cs b/Items/Tools/WulfrumTreasurePinger.cs index 165d179cd3..b5d2490121 100644 --- a/Items/Tools/WulfrumTreasurePinger.cs +++ b/Items/Tools/WulfrumTreasurePinger.cs @@ -3,6 +3,7 @@ using System.IO; using CalamityMod.Items.Materials; using CalamityMod.Particles; using CalamityMod.Systems; +using CalamityMod.Systems.Mechanic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -115,19 +116,19 @@ namespace CalamityMod.Items.Tools for (int i = 0; i < sparkCount; i++) { - Dust.NewDustPerfect(centerPosition, 226, Main.rand.NextVector2Circular(18f, 18f), Scale: Main.rand.NextFloat(0.4f, 1f)); + Dust.NewDustPerfect(centerPosition, DustID.Electric, Main.rand.NextVector2Circular(18f, 18f), Scale: Main.rand.NextFloat(0.4f, 1f)); } } } public override bool CanUseItem(Player player) { - return !(TilePingerSystem.tileEffects["WulfrumPing"].Active); + return !WulfrumPingTileEffect.Instance.Active; } public override bool? UseItem(Player player) { - if (TilePingerSystem.AddPing("WulfrumPing", player.Center, player)) + if (!Main.dedServ && TilePingerSystem.AddPing(WulfrumPingTileEffect.Instance, player.Center, player)) { if (player.name != "John Wulfrum") usesLeft--; @@ -281,7 +282,7 @@ namespace CalamityMod.Items.Tools { //Intentionally craftable anywhere. CreateRecipe(). - AddIngredient(6). + AddIngredient(5). Register() .DisableDecraft(); } diff --git a/Items/TreasureBags/AquaticScourgeBag.cs b/Items/TreasureBags/AquaticScourgeBag.cs index 84daab017c..dc22604c69 100644 --- a/Items/TreasureBags/AquaticScourgeBag.cs +++ b/Items/TreasureBags/AquaticScourgeBag.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; -using CalamityMod.Items.TreasureBags.MiscGrabBags; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -80,9 +79,6 @@ namespace CalamityMod.Items.TreasureBags // Vanity itemLoot.Add(ModContent.ItemType(), 7); itemLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); - - // Fishing - itemLoot.Add(ModContent.ItemType()); } } } diff --git a/Items/TreasureBags/AstrumAureusBag.cs b/Items/TreasureBags/AstrumAureusBag.cs index ebb93f3858..c401790e5e 100644 --- a/Items/TreasureBags/AstrumAureusBag.cs +++ b/Items/TreasureBags/AstrumAureusBag.cs @@ -3,7 +3,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Mounts; using CalamityMod.Items.PermanentBoosters; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Potions; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; diff --git a/Items/TreasureBags/AstrumDeusBag.cs b/Items/TreasureBags/AstrumDeusBag.cs index 46858f2661..b1d835ae13 100644 --- a/Items/TreasureBags/AstrumDeusBag.cs +++ b/Items/TreasureBags/AstrumDeusBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; diff --git a/Items/TreasureBags/BrimstoneElementalBag.cs b/Items/TreasureBags/BrimstoneElementalBag.cs new file mode 100644 index 0000000000..3b20645166 --- /dev/null +++ b/Items/TreasureBags/BrimstoneElementalBag.cs @@ -0,0 +1,88 @@ +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; +using CalamityMod.Items.Placeables.Furniture.Paintings; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.BrimstoneElemental; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent.ItemDropRules; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.TreasureBags +{ + [LegacyName("BrimstoneWaifuBag")] + public class BrimstoneElementalBag : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.TreasureBags"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 3; + ItemID.Sets.BossBag[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 24; + Item.height = 24; + Item.maxStack = Item.CommonMaxStack; + Item.consumable = true; + Item.expert = true; + Item.rare = ItemRarityID.Cyan; + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossBags; + } + + public override bool CanRightClick() => true; + + public override Color? GetAlpha(Color lightColor) => Color.Lerp(lightColor, Color.White, 0.4f); + + public override void PostUpdate() => Item.TreasureBagLightAndDust(); + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + return CalamityUtils.DrawTreasureBagInWorld(Item, spriteBatch, ref rotation, ref scale, whoAmI); + } + + public override void ModifyItemLoot(ItemLoot itemLoot) + { + // Money + itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); + + // Materials + itemLoot.Add(ModContent.ItemType(), 1, 10, 12); + + // Weapons + itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + })); + + // Equipment + itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] + { + ModContent.ItemType(), + })); + itemLoot.Add(ModContent.ItemType()); + itemLoot.AddRevBagAccessories(); + + // Vanity + itemLoot.Add(ModContent.ItemType(), 7); + itemLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); + itemLoot.AddIf(() => CalamityWorld.revenge, ModContent.ItemType()); + } + } +} diff --git a/Items/TreasureBags/BrimstoneWaifuBag.png b/Items/TreasureBags/BrimstoneElementalBag.png similarity index 100% rename from Items/TreasureBags/BrimstoneWaifuBag.png rename to Items/TreasureBags/BrimstoneElementalBag.png diff --git a/Items/TreasureBags/BrimstoneWaifuBag.cs b/Items/TreasureBags/BrimstoneWaifuBag.cs deleted file mode 100644 index 4b68c1a252..0000000000 --- a/Items/TreasureBags/BrimstoneWaifuBag.cs +++ /dev/null @@ -1,88 +0,0 @@ -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; -using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent.ItemDropRules; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.TreasureBags -{ - public class BrimstoneWaifuBag : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.TreasureBags"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 3; - ItemID.Sets.BossBag[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 24; - Item.height = 24; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.expert = true; - Item.rare = ItemRarityID.Cyan; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossBags; - } - - public override bool CanRightClick() => true; - - public override Color? GetAlpha(Color lightColor) => Color.Lerp(lightColor, Color.White, 0.4f); - - public override void PostUpdate() => Item.TreasureBagLightAndDust(); - - public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) - { - return CalamityUtils.DrawTreasureBagInWorld(Item, spriteBatch, ref rotation, ref scale, whoAmI); - } - - public override void ModifyItemLoot(ItemLoot itemLoot) - { - // Money - itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); - - // Materials - itemLoot.Add(ModContent.ItemType(), 1, 10, 12); - - // Weapons - itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] - { - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - })); - - // Equipment - itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] - { - ModContent.ItemType(), - })); - itemLoot.Add(ModContent.ItemType()); - itemLoot.AddRevBagAccessories(); - - // Vanity - itemLoot.Add(ModContent.ItemType(), 7); - itemLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); - itemLoot.AddIf(() => CalamityWorld.revenge, ModContent.ItemType()); - } - } -} diff --git a/Items/TreasureBags/CalamitasCloneBag.cs b/Items/TreasureBags/CalamitasCloneBag.cs index 08b9c7558d..25b976118d 100644 --- a/Items/TreasureBags/CalamitasCloneBag.cs +++ b/Items/TreasureBags/CalamitasCloneBag.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -72,8 +72,8 @@ namespace CalamityMod.Items.TreasureBags // Equipment itemLoot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); + itemLoot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); itemLoot.Add(ModContent.ItemType()); - itemLoot.Add(ModContent.ItemType(), 10); itemLoot.AddRevBagAccessories(); // Vanity diff --git a/Items/TreasureBags/CalamitasCoffer.cs b/Items/TreasureBags/CalamitasCoffer.cs index 42fa940a87..1f5a2388e8 100644 --- a/Items/TreasureBags/CalamitasCoffer.cs +++ b/Items/TreasureBags/CalamitasCoffer.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; diff --git a/Items/TreasureBags/CeaselessVoidBag.cs b/Items/TreasureBags/CeaselessVoidBag.cs index 3e82674595..ea2b30c3b9 100644 --- a/Items/TreasureBags/CeaselessVoidBag.cs +++ b/Items/TreasureBags/CeaselessVoidBag.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.CeaselessVoid; @@ -55,7 +55,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 6, 9); + itemLoot.Add(ModContent.ItemType(), 1, 12, 16); // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] diff --git a/Items/TreasureBags/CrabulonBag.cs b/Items/TreasureBags/CrabulonBag.cs index 7dde476399..f7968f4e1b 100644 --- a/Items/TreasureBags/CrabulonBag.cs +++ b/Items/TreasureBags/CrabulonBag.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.PermanentBoosters; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; diff --git a/Items/TreasureBags/CryogenBag.cs b/Items/TreasureBags/CryogenBag.cs index 224aee88b5..0338db7e8c 100644 --- a/Items/TreasureBags/CryogenBag.cs +++ b/Items/TreasureBags/CryogenBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; diff --git a/Items/TreasureBags/DesertScourgeBag.cs b/Items/TreasureBags/DesertScourgeBag.cs index 42d1b0abc6..39df2bafef 100644 --- a/Items/TreasureBags/DesertScourgeBag.cs +++ b/Items/TreasureBags/DesertScourgeBag.cs @@ -1,8 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; -using CalamityMod.Items.TreasureBags.MiscGrabBags; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -83,9 +82,6 @@ namespace CalamityMod.Items.TreasureBags // Vanity itemLoot.Add(ModContent.ItemType(), 7); itemLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); - - // Fishing - itemLoot.Add(ModContent.ItemType()); } } } diff --git a/Items/TreasureBags/DevourerofGodsBag.cs b/Items/TreasureBags/DevourerofGodsBag.cs index e5bd7e7854..33393fd996 100644 --- a/Items/TreasureBags/DevourerofGodsBag.cs +++ b/Items/TreasureBags/DevourerofGodsBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.FurnitureCosmilite; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; @@ -70,21 +70,20 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 55, 65); + itemLoot.Add(ModContent.ItemType(), 1, 75, 90); itemLoot.Add(ModContent.ItemType(), 1, 200, 320); // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] { - ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() })); itemLoot.Add(ModContent.ItemType(), 10); - itemLoot.Add(ModContent.ItemType(), 10); // Equipment itemLoot.Add(ModContent.ItemType()); diff --git a/Items/TreasureBags/DraedonBag.cs b/Items/TreasureBags/DraedonBag.cs index 99969e8636..694a1a7b98 100644 --- a/Items/TreasureBags/DraedonBag.cs +++ b/Items/TreasureBags/DraedonBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Mounts; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; diff --git a/Items/TreasureBags/DragonfollyBag.cs b/Items/TreasureBags/DragonfollyBag.cs index bdbc785757..48df7c8405 100644 --- a/Items/TreasureBags/DragonfollyBag.cs +++ b/Items/TreasureBags/DragonfollyBag.cs @@ -3,7 +3,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Mounts; using CalamityMod.Items.PermanentBoosters; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -57,7 +57,7 @@ namespace CalamityMod.Items.TreasureBags public override void ModifyItemLoot(ItemLoot itemLoot) { // Money - itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); + itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials itemLoot.Add(ModContent.ItemType(), 1, 30, 35); @@ -69,7 +69,6 @@ namespace CalamityMod.Items.TreasureBags ModContent.ItemType(), ModContent.ItemType() })); - itemLoot.Add(ModContent.ItemType(), 10); // Equipment itemLoot.Add(ModContent.ItemType(), DropHelper.BagWeaponDropRateFraction); diff --git a/Items/TreasureBags/HiveMindBag.cs b/Items/TreasureBags/HiveMindBag.cs index 22c3df8060..27a22c2ee0 100644 --- a/Items/TreasureBags/HiveMindBag.cs +++ b/Items/TreasureBags/HiveMindBag.cs @@ -1,8 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -60,7 +59,6 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 30, 40); itemLoot.Add(ItemID.DemoniteBar, 1, 15, 20); itemLoot.Add(ItemID.RottenChunk, 1, 15, 20); itemLoot.AddIf(() => Main.hardMode, ItemID.CursedFlame, 1, 25, 30); diff --git a/Items/TreasureBags/LeviathanBag.cs b/Items/TreasureBags/LeviathanBag.cs index 1f54228f35..d567825dd0 100644 --- a/Items/TreasureBags/LeviathanBag.cs +++ b/Items/TreasureBags/LeviathanBag.cs @@ -1,6 +1,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Monoliths; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; diff --git a/Items/TreasureBags/MiscGrabBags/AbyssalTreasure.cs b/Items/TreasureBags/MiscGrabBags/AbyssalTreasure.cs index bbbe86179b..10b84e3d82 100644 --- a/Items/TreasureBags/MiscGrabBags/AbyssalTreasure.cs +++ b/Items/TreasureBags/MiscGrabBags/AbyssalTreasure.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.FurnitureAbyss; +using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Potions; using Terraria; using Terraria.GameContent.ItemDropRules; @@ -61,7 +61,7 @@ namespace CalamityMod.Items.TreasureBags.MiscGrabBags // Pots can normally contain hearts here... but we turned it into a grab bag (so... coins!) // 4-12/5-18 Biome Torches @ 12.43% (87/700) - var torches = DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 4, 12, 5, 18); + var torches = DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 4, 12, 5, 18); // 10-20 Hellfire Arrows @ 12.43% var ammo = ItemDropRule.NotScalingWithLuck(ItemID.HellfireArrow, 1, 10, 20); diff --git a/Items/TreasureBags/MiscGrabBags/BleachedAnglingKit.cs b/Items/TreasureBags/MiscGrabBags/BleachedAnglingKit.cs deleted file mode 100644 index e371b23910..0000000000 --- a/Items/TreasureBags/MiscGrabBags/BleachedAnglingKit.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Terraria; -using Terraria.GameContent.ItemDropRules; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.TreasureBags.MiscGrabBags -{ - public class BleachedAnglingKit : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.TreasureBags"; - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); - } - - public override void SetDefaults() - { - Item.width = 24; - Item.height = 24; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.rare = ItemRarityID.Pink; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.GoodieBags; - } - - public override bool CanRightClick() => true; - - public override void ModifyItemLoot(ItemLoot itemLoot) - { - // Different drop rates on Normal and Expert, so define normal first, then expert - var normalOnly = itemLoot.DefineNormalOnlyDropSet(); - normalOnly.Add(ItemID.FishermansGuide, 18); - normalOnly.Add(ItemID.WeatherRadio, 18); - normalOnly.Add(ItemID.Sextant, 18); - normalOnly.Add(ItemID.FishingPotion, 3, 2, 3); - normalOnly.Add(ItemID.SonarPotion, 3, 2, 3); - normalOnly.Add(ItemID.CratePotion, 3, 2, 3); - normalOnly.Add(ItemID.GoldCoin, 1, 3, 4); - - var expertPlus = itemLoot.DefineConditionalDropSet(new Conditions.IsExpert()); - expertPlus.Add(ItemID.FishermansGuide, 14); - expertPlus.Add(ItemID.WeatherRadio, 14); - expertPlus.Add(ItemID.Sextant, 14); - expertPlus.Add(ItemID.FishingPotion, 2, 2, 3); - expertPlus.Add(ItemID.SonarPotion, 2, 2, 3); - expertPlus.Add(ItemID.CratePotion, 2, 2, 3); - expertPlus.Add(ItemID.GoldCoin, 1, 4, 5); - } - } -} diff --git a/Items/TreasureBags/MiscGrabBags/BleachedAnglingKit.png b/Items/TreasureBags/MiscGrabBags/BleachedAnglingKit.png deleted file mode 100644 index 6b26715325..0000000000 Binary files a/Items/TreasureBags/MiscGrabBags/BleachedAnglingKit.png and /dev/null differ diff --git a/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs b/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs index 983ac2f023..eb5436ff16 100644 --- a/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs +++ b/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs @@ -55,8 +55,8 @@ namespace CalamityMod.Items.TreasureBags.MiscGrabBags expertPlus.Add(ModContent.ItemType(), 1, 1, 3); expertPlus.Add(ModContent.ItemType(), 1, 1, 3); expertPlus.Add(ModContent.ItemType(), 1, 1, 3); - normalOnly.Add(ModContent.ItemType(), 2); - normalOnly.Add(ModContent.ItemType(), 3); + expertPlus.Add(ModContent.ItemType(), 2); + expertPlus.Add(ModContent.ItemType(), 3); } } } diff --git a/Items/TreasureBags/MiscGrabBags/SandyAnglingKit.cs b/Items/TreasureBags/MiscGrabBags/SandyAnglingKit.cs deleted file mode 100644 index c2b5e5076f..0000000000 --- a/Items/TreasureBags/MiscGrabBags/SandyAnglingKit.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Terraria; -using Terraria.GameContent.ItemDropRules; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.TreasureBags.MiscGrabBags -{ - public class SandyAnglingKit : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.TreasureBags"; - - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 10; - } - - public override void SetDefaults() - { - Item.width = 24; - Item.height = 24; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; - Item.rare = ItemRarityID.Blue; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = ContentSamples.CreativeHelper.ItemGroup.GoodieBags; - } - - public override bool CanRightClick() => true; - - public override void ModifyItemLoot(ItemLoot itemLoot) - { - // Different drop rates on Normal and Expert, so define normal first, then expert - var normalOnly = itemLoot.DefineNormalOnlyDropSet(); - normalOnly.Add(ItemID.FishermansGuide, 20); - normalOnly.Add(ItemID.WeatherRadio, 20); - normalOnly.Add(ItemID.Sextant, 20); - normalOnly.Add(ItemID.FishingPotion, 3, 2, 3); - normalOnly.Add(ItemID.SonarPotion, 3, 2, 3); - normalOnly.Add(ItemID.CratePotion, 3, 2, 3); - normalOnly.Add(ItemID.GoldCoin, 1, 1, 2); - - var expertPlus = itemLoot.DefineConditionalDropSet(new Conditions.IsExpert()); - expertPlus.Add(ItemID.FishermansGuide, 16); - expertPlus.Add(ItemID.WeatherRadio, 16); - expertPlus.Add(ItemID.Sextant, 16); - expertPlus.Add(ItemID.FishingPotion, 2, 2, 3); - expertPlus.Add(ItemID.SonarPotion, 2, 2, 3); - expertPlus.Add(ItemID.CratePotion, 2, 2, 3); - expertPlus.Add(ItemID.GoldCoin, 1, 2, 3); - } - } -} diff --git a/Items/TreasureBags/MiscGrabBags/SandyAnglingKit.png b/Items/TreasureBags/MiscGrabBags/SandyAnglingKit.png deleted file mode 100644 index f8948c63bd..0000000000 Binary files a/Items/TreasureBags/MiscGrabBags/SandyAnglingKit.png and /dev/null differ diff --git a/Items/TreasureBags/MiscGrabBags/StarterBag.cs b/Items/TreasureBags/MiscGrabBags/StarterBag.cs index 0398fbda0c..4e1d2b5ad8 100644 --- a/Items/TreasureBags/MiscGrabBags/StarterBag.cs +++ b/Items/TreasureBags/MiscGrabBags/StarterBag.cs @@ -49,19 +49,15 @@ namespace CalamityMod.Items.TreasureBags.MiscGrabBags // Tools and Utility Items tin.Add(ItemID.TinHammer); tin.OnFailedConditions(new CommonDrop(ItemID.CopperHammer, 1)); - itemLoot.Add(ItemID.Bomb, 1, 10, 10); itemLoot.Add(ItemID.Rope, 1, 50, 50); // Potions LeadingConditionRule multiplayer = itemLoot.DefineConditionalDropSet(() => Main.netMode == NetmodeID.MultiplayerClient); - itemLoot.Add(ItemID.MiningPotion, 1, 3, 3); - itemLoot.Add(ItemID.SpelunkerPotion, 1, 3, 3); itemLoot.Add(ItemID.RecallPotion, 1, 3, 3); multiplayer.Add(ItemID.WormholePotion, 1, 3, 3); // Tiles itemLoot.Add(ItemID.Torch, 1, 25, 25); - itemLoot.Add(ItemID.Chest, 1, 3, 3); // Calamity title theme music box (if music mod is enabled) Mod musicMod = ExternalMods.musicMod; @@ -117,16 +113,6 @@ namespace CalamityMod.Items.TreasureBags.MiscGrabBags itemLoot.AddIf(getsGhostBracelet, ModContent.ItemType()); - // Shayy dev item - // Name specific: "Shayy" - static bool getsPunchCard(DropAttemptInfo info) - { - string playerName = info.player.name; - return playerName == "Shayy"; - } - - itemLoot.AddIf(getsPunchCard, ModContent.ItemType()); - // Xyk dev item // Name specific: "Xyk" static bool getsXyksBlessing(DropAttemptInfo info) @@ -146,16 +132,6 @@ namespace CalamityMod.Items.TreasureBags.MiscGrabBags } itemLoot.AddIf(getsOracleHeadphones, ModContent.ItemType()); - - // Fabsol dev item - // Name specific: "Fabsol" or "Cirrus" - static bool getsCrystalHeartVodka(DropAttemptInfo info) - { - string playerName = info.player.name; - return playerName is "Fabsol" or "Cirrus"; - } - - itemLoot.AddIf(getsCrystalHeartVodka, ModContent.ItemType()); } } } diff --git a/Items/TreasureBags/OldDukeBag.cs b/Items/TreasureBags/OldDukeBag.cs index 051ba8705b..13f3b10b35 100644 --- a/Items/TreasureBags/OldDukeBag.cs +++ b/Items/TreasureBags/OldDukeBag.cs @@ -1,6 +1,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; diff --git a/Items/TreasureBags/PerforatorBag.cs b/Items/TreasureBags/PerforatorBag.cs index cec78d95d9..165ec5afb6 100644 --- a/Items/TreasureBags/PerforatorBag.cs +++ b/Items/TreasureBags/PerforatorBag.cs @@ -1,8 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -60,7 +59,6 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 30, 40); itemLoot.Add(ItemID.CrimtaneBar, 1, 15, 20); itemLoot.Add(ItemID.Vertebrae, 1, 15, 20); itemLoot.AddIf(() => Main.hardMode, ItemID.Ichor, 1, 25, 30); diff --git a/Items/TreasureBags/PlaguebringerGoliathBag.cs b/Items/TreasureBags/PlaguebringerGoliathBag.cs index 90f1610de5..c0f2e9952f 100644 --- a/Items/TreasureBags/PlaguebringerGoliathBag.cs +++ b/Items/TreasureBags/PlaguebringerGoliathBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -60,15 +60,15 @@ namespace CalamityMod.Items.TreasureBags // Materials itemLoot.Add(ModContent.ItemType(), 1, 25, 30); - itemLoot.Add(ModContent.ItemType(), 1, 30, 35); + itemLoot.Add(ModContent.ItemType(), 1, 40, 50); itemLoot.Add(ItemID.Stinger, 1, 4, 8); // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] { ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), diff --git a/Items/TreasureBags/PolterghastBag.cs b/Items/TreasureBags/PolterghastBag.cs index 6b10c1e1a0..a366a960d3 100644 --- a/Items/TreasureBags/PolterghastBag.cs +++ b/Items/TreasureBags/PolterghastBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.PermanentBoosters; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -65,7 +65,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 10, 20); + itemLoot.Add(ModContent.ItemType(), 1, 25, 30); itemLoot.Add(ModContent.ItemType(), 1, 40, 50); // Weapons diff --git a/Items/TreasureBags/ProvidenceBag.cs b/Items/TreasureBags/ProvidenceBag.cs index d192e2f733..965665155d 100644 --- a/Items/TreasureBags/ProvidenceBag.cs +++ b/Items/TreasureBags/ProvidenceBag.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -58,8 +58,8 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 25, 35); - itemLoot.Add(ModContent.ItemType(), 1, 30, 40); + itemLoot.Add(ModContent.ItemType(), 1, 40, 50); + itemLoot.Add(ModContent.ItemType(), 1, 60, 70); // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] diff --git a/Items/TreasureBags/RavagerBag.cs b/Items/TreasureBags/RavagerBag.cs index e6159c6cb7..3acad9e6e1 100644 --- a/Items/TreasureBags/RavagerBag.cs +++ b/Items/TreasureBags/RavagerBag.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.PermanentBoosters; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; @@ -76,10 +76,8 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ModContent.ItemType(), 20); // Equipment - itemLoot.Add(ItemDropRule.OneFromOptionsNotScalingWithLuck(1, - ModContent.ItemType(), - ModContent.ItemType() - )); + itemLoot.Add(ModContent.ItemType()); + itemLoot.Add(ModContent.ItemType(), 2); itemLoot.AddIf(() => DownedBossSystem.downedProvidence, ModContent.ItemType()); itemLoot.AddRevBagAccessories(); itemLoot.AddIf((info) => CalamityWorld.revenge && !info.player.Calamity().rageBoostTwo, ModContent.ItemType()); diff --git a/Items/TreasureBags/SignusBag.cs b/Items/TreasureBags/SignusBag.cs index fff0ce985d..54d8a6a0c1 100644 --- a/Items/TreasureBags/SignusBag.cs +++ b/Items/TreasureBags/SignusBag.cs @@ -1,7 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.Signus; @@ -55,7 +55,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 6, 9); + itemLoot.Add(ModContent.ItemType(), 1, 12, 16); // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] diff --git a/Items/TreasureBags/SlimeGodBag.cs b/Items/TreasureBags/SlimeGodBag.cs index 2172292425..9889e3fbe4 100644 --- a/Items/TreasureBags/SlimeGodBag.cs +++ b/Items/TreasureBags/SlimeGodBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.PermanentBoosters; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; diff --git a/Items/TreasureBags/StormWeaverBag.cs b/Items/TreasureBags/StormWeaverBag.cs index 48c7eb7a9d..bbac331a24 100644 --- a/Items/TreasureBags/StormWeaverBag.cs +++ b/Items/TreasureBags/StormWeaverBag.cs @@ -2,7 +2,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -57,7 +57,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 6, 9); + itemLoot.Add(ModContent.ItemType(), 1, 12, 16); // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] diff --git a/Items/TreasureBags/YharonBag.cs b/Items/TreasureBags/YharonBag.cs index 82a29bcd1c..badf82a24b 100644 --- a/Items/TreasureBags/YharonBag.cs +++ b/Items/TreasureBags/YharonBag.cs @@ -3,7 +3,7 @@ using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -61,7 +61,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ItemDropRule.CoinsBasedOnNPCValue(ModContent.NPCType())); // Materials - itemLoot.Add(ModContent.ItemType(), 1, 30, 35); + itemLoot.Add(ModContent.ItemType(), 1, 40, 50); // Weapons itemLoot.Add(DropHelper.CalamityStyle(DropHelper.BagWeaponDropRateFraction, new int[] @@ -78,7 +78,7 @@ namespace CalamityMod.Items.TreasureBags itemLoot.Add(ModContent.ItemType(), 10); // Equipment - itemLoot.Add(ModContent.ItemType()); + itemLoot.Add(ModContent.ItemType()); itemLoot.Add(ModContent.ItemType()); itemLoot.AddRevBagAccessories(); diff --git a/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs b/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs index 97b89059ef..43c6867f92 100644 --- a/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs +++ b/Items/VanillaArmorChanges/AdamantiteArmorSetChange.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Adamantite"; public const int MaxManaBoost = 20; - public const int DefenseBoostMax = 15; + public const int DefenseBoostMax = 10; public const int TimeUntilDecayBeginsAfterAttacking = 60; public const int TimeUntilBoostCompletelyDecays = 210; diff --git a/Items/VanillaArmorChanges/ChlorophyteArmorSetChange.cs b/Items/VanillaArmorChanges/ChlorophyteArmorSetChange.cs deleted file mode 100644 index 478e6ceca6..0000000000 --- a/Items/VanillaArmorChanges/ChlorophyteArmorSetChange.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Terraria.ID; - -namespace CalamityMod.Items.VanillaArmorChanges -{ - public class ChlorophyteArmorSetChange : VanillaArmorChange - { - public override int? HeadPieceID => ItemID.ChlorophyteHeadgear; - - public override int? BodyPieceID => ItemID.ChlorophytePlateMail; - - public override int? LegPieceID => ItemID.ChlorophyteGreaves; - - public override int[] AlternativeHeadPieceIDs => new int[] { ItemID.ChlorophyteMask, ItemID.ChlorophyteHelmet }; - - public override string ArmorSetName => "Chlorophyte"; - - public const int AmountToHealPerPulse = 5; - - public const int PulseReleaseRate = 300; - - public const int DelayBetweenHeals = 270; - - public const int BaseDamageToEnemies = 250; - - public override void UpdateSetBonusText(ref string setBonusText) - { - setBonusText = $"{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(PulseReleaseRate / 60f, BaseDamageToEnemies, AmountToHealPerPulse, DelayBetweenHeals / 60f)}"; - } - } -} diff --git a/Items/VanillaArmorChanges/CopperArmorSetChange.cs b/Items/VanillaArmorChanges/CopperArmorSetChange.cs index fbf35b1549..6f4d3ea46a 100644 --- a/Items/VanillaArmorChanges/CopperArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CopperArmorSetChange.cs @@ -1,5 +1,4 @@ -using System.Text; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,20 +14,11 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Copper"; - public const float HeadDamage = 0.05f; - public const float ChestCrit = 3f; - public const float LegsMoveSpeed = 0.05f; public const float SetBonusFlatDamage = 2.0f; - public override void ApplyHeadPieceEffect(Player player) => player.GetDamage() += HeadDamage; - - public override void ApplyBodyPieceEffect(Player player) => player.GetCritChance() += ChestCrit; - - public override void ApplyLegPieceEffect(Player player) => player.moveSpeed += LegsMoveSpeed; - public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(SetBonusFlatDamage.ToString("N0"))}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs b/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs index d74e80cff3..3ba4856861 100644 --- a/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs @@ -16,7 +16,6 @@ namespace CalamityMod.Items.VanillaArmorChanges 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) @@ -35,11 +34,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyHeadPieceEffect(Player player) => ApplyAnyPieceEffect(player); - public override void ApplyBodyPieceEffect(Player player) - { - ApplyAnyPieceEffect(player); - player.lifeRegen += ChestPieceBonusLifeRegen; - } + public override void ApplyBodyPieceEffect(Player player) => ApplyAnyPieceEffect(player); public override void ApplyLegPieceEffect(Player player) => ApplyAnyPieceEffect(player); } diff --git a/Items/VanillaArmorChanges/EskimoArmorSetChange.cs b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs index 94f7ed96f4..c3fccfceb4 100644 --- a/Items/VanillaArmorChanges/EskimoArmorSetChange.cs +++ b/Items/VanillaArmorChanges/EskimoArmorSetChange.cs @@ -1,7 +1,5 @@ -using CalamityMod.Buffs.StatDebuffs; -using Terraria; +using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { @@ -30,9 +28,9 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyArmorSetBonus(Player player) { player.Calamity().eskimoSet = true; + player.Calamity().ColdDebuffMultiplier += 0.25f; player.buffImmune[BuffID.Frostburn] = true; - player.buffImmune[ModContent.BuffType()] = true; } } } diff --git a/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs b/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs index d1ebc8a41b..93c2886fbf 100644 --- a/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs +++ b/Items/VanillaArmorChanges/GladiatorArmorSetChange.cs @@ -44,7 +44,6 @@ namespace CalamityMod.Items.VanillaArmorChanges player.Calamity().wearingRogueArmor = true; player.GetDamage() += 0.05f; player.Calamity().rogueVelocity += 0.1f; - player.statDefense += 3; } } } diff --git a/Items/VanillaArmorChanges/GoldArmorSetChange.cs b/Items/VanillaArmorChanges/GoldArmorSetChange.cs index fbb7771b69..9b34eb9fc9 100644 --- a/Items/VanillaArmorChanges/GoldArmorSetChange.cs +++ b/Items/VanillaArmorChanges/GoldArmorSetChange.cs @@ -17,23 +17,14 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Gold"; - public const float HeadDamage = 0.05f; - public const float ChestDR = 0.05f; - public const float LegsMoveSpeed = 0.1f; public const float GoldDropChanceFromEnemies = 0.02f; public const int GoldFromBosses = 3; - public const float SetBonusCritPerGoldCoin = 0.1f; // 10 gold coins = +1% crit chance - public const float MaximumCritBonus = 7f; - - public override void ApplyHeadPieceEffect(Player player) => player.GetDamage() += HeadDamage; - - public override void ApplyBodyPieceEffect(Player player) => player.endurance += ChestDR; - - public override void ApplyLegPieceEffect(Player player) => player.moveSpeed += LegsMoveSpeed; + public const float SetBonusCritPerGoldCoin = 0.2f; // 5 gold coins = +1% crit chance + public const float MaximumCritBonus = 5f; public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(GoldDropChanceFromEnemies.ToPercent(), GoldFromBosses, SetBonusCritPerGoldCoin, MaximumCritBonus)}"; } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/VanillaArmorChanges/IronArmorSetChange.cs b/Items/VanillaArmorChanges/IronArmorSetChange.cs index ea739abcf5..3906498ffb 100644 --- a/Items/VanillaArmorChanges/IronArmorSetChange.cs +++ b/Items/VanillaArmorChanges/IronArmorSetChange.cs @@ -1,6 +1,6 @@ -using System.Text; -using Terraria; +using Terraria; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { @@ -16,25 +16,16 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Iron"; - public const float ArmorPieceDR = 0.03f; - public const float SetBonusDR = 0.06f; - public const int SetBonusLifeRegen = 2; - - public override void ApplyHeadPieceEffect(Player player) => player.endurance += ArmorPieceDR; - - public override void ApplyBodyPieceEffect(Player player) => player.endurance += ArmorPieceDR; - - public override void ApplyLegPieceEffect(Player player) => player.endurance += ArmorPieceDR; + public const float KnockbackMultiplier = 1.5f; public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(KnockbackMultiplier)}"; } public override void ApplyArmorSetBonus(Player player) { - player.endurance += SetBonusDR; - player.lifeRegen += SetBonusLifeRegen; + player.GetKnockback() *= KnockbackMultiplier; } } } diff --git a/Items/VanillaArmorChanges/JungleArmorSetChange.cs b/Items/VanillaArmorChanges/JungleArmorSetChange.cs index b37c7ea327..7e573a8772 100644 --- a/Items/VanillaArmorChanges/JungleArmorSetChange.cs +++ b/Items/VanillaArmorChanges/JungleArmorSetChange.cs @@ -1,5 +1,4 @@ -using System.Text; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/VanillaArmorChanges/LeadArmorSetChange.cs b/Items/VanillaArmorChanges/LeadArmorSetChange.cs index 4fc7541f41..07dfe7c7e6 100644 --- a/Items/VanillaArmorChanges/LeadArmorSetChange.cs +++ b/Items/VanillaArmorChanges/LeadArmorSetChange.cs @@ -13,16 +13,6 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Lead"; - 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; - - public override void ApplyBodyPieceEffect(Player player) => player.endurance += ArmorPieceDR; - - public override void ApplyLegPieceEffect(Player player) => player.endurance += ArmorPieceDR; - public override void UpdateSetBonusText(ref string setBonusText) { setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; @@ -30,8 +20,6 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyArmorSetBonus(Player player) { - player.endurance += SetBonusDR; - player.lifeRegen += SetBonusLifeRegen; player.noKnockback = true; } } diff --git a/Items/VanillaArmorChanges/MeteorArmorSetChange.cs b/Items/VanillaArmorChanges/MeteorArmorSetChange.cs index 6aeb0b42be..1861e9acc5 100644 --- a/Items/VanillaArmorChanges/MeteorArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MeteorArmorSetChange.cs @@ -19,15 +19,6 @@ namespace CalamityMod.Items.VanillaArmorChanges setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } - // Reducing every piece's damage boost from 9% to 8% - private void ApplyAnyPieceEffect(Player player) => player.GetDamage() -= 0.01f; - - public override void ApplyHeadPieceEffect(Player player) => ApplyAnyPieceEffect(player); - - public override void ApplyBodyPieceEffect(Player player) => ApplyAnyPieceEffect(player); - - public override void ApplyLegPieceEffect(Player player) => ApplyAnyPieceEffect(player); - public override void ApplyArmorSetBonus(Player player) { player.Calamity().meteorSet = true; diff --git a/Items/VanillaArmorChanges/MiningArmorSetChange.cs b/Items/VanillaArmorChanges/MiningArmorSetChange.cs index 1330cc51f3..e236f7de83 100644 --- a/Items/VanillaArmorChanges/MiningArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MiningArmorSetChange.cs @@ -1,6 +1,5 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { diff --git a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs index a0cf88de55..50f35ac57a 100644 --- a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs @@ -14,37 +14,35 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "MonkTier2"; + public static float SetBonusRogueStealth = 0.9f; + public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText = CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(SetBonusRogueStealth.ToStealth()) + "\n" + setBonusText; } public override void ApplyHeadPieceEffect(Player player) { player.GetAttackSpeed() -= 0.2f; - player.Calamity().rogueVelocity += 0.1f; // Replace melee speed with rogue velocity. + player.Calamity().rogueVelocity += 0.15f; // Replace melee speed with rogue velocity. } public override void ApplyBodyPieceEffect(Player player) { - player.GetDamage() -= 0.15f; // Decrease both damage boosts to 5%. player.GetDamage() -= 0.2f; - player.GetDamage() += 0.05f; // Replace melee damage with rogue damage. + player.GetDamage() += 0.15f; // Replace melee damage with rogue damage. + player.GetDamage() -= 0.05f; // Small nerf to summon damage. } public override void ApplyLegPieceEffect(Player player) { - player.GetDamage() -= 0.05f; // Decrease summon damage boost to 5%. - player.GetCritChance() -= 15; // Replace melee crit chance with rogue and decrease to 5%. - player.GetCritChance() += 5; + player.GetCritChance() -= 15; + player.GetCritChance() += 15; // Replace melee crit chance with rogue crit chance. } public override void ApplyArmorSetBonus(Player player) { - player.GetDamage() += 0.15f; // Re-add 15% of the 20% lost summon damage, 10% of the 20% rogue damage, and the rest of the rogue crit. - player.GetDamage() += 0.1f; - player.GetCritChance() += 10; - player.Calamity().rogueStealthMax += 0.9f; // Give rogue stealth. + player.Calamity().rogueStealthMax += SetBonusRogueStealth; // Give rogue stealth. player.Calamity().wearingRogueArmor = true; } } diff --git a/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs index b56de9692e..8ff9fa762b 100644 --- a/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs @@ -14,39 +14,37 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "MonkTier3"; + public static float SetBonusRogueStealth = 1f; + public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText = CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(SetBonusRogueStealth.ToStealth()) + "\n" + setBonusText; } public override void ApplyHeadPieceEffect(Player player) { - player.GetDamage() -= 0.1f; // Decrease both damage boosts to 10%. player.GetDamage() -= 0.2f; - player.GetDamage() += 0.1f; // Replace melee damage with rogue damage. + player.GetDamage() += 0.2f; // Replace melee damage with rogue damage. } public override void ApplyBodyPieceEffect(Player player) { - player.GetDamage() -= 0.1f; // Decrease summon damage boost to 10%. - player.GetAttackSpeed() -= 0.2f; // Replace melee speed with rogue velocity, and decrease to 15%. - player.Calamity().rogueVelocity += 0.15f; - player.GetCritChance() -= 5; // Replace melee crit with rogue crit. - player.GetCritChance() += 5; + player.GetAttackSpeed() -= 0.2f; + player.Calamity().rogueVelocity += 0.2f; // Replace melee speed with rogue velocity. + player.GetCritChance() -= 5; + player.GetCritChance() += 5; // Replace melee crit with rogue crit. } public override void ApplyLegPieceEffect(Player player) { - player.GetDamage() -= 0.1f; // Decrease summon damage boost to 10%. - player.GetCritChance() -= 20; // Replace melee crit chance with rogue, and decrease to 10%. - player.GetCritChance() += 10; + player.GetCritChance() -= 20; + player.GetCritChance() += 10; // Replace melee crit with rogue crit. + player.GetDamage() -= 0.1f; // Small nerf to summon damage. } public override void ApplyArmorSetBonus(Player player) { - player.GetDamage() += 0.2f; // Re-add 20% of the 30% lost summon damage, and the rest of the rogue damage. - player.GetDamage() += 0.1f; - player.Calamity().rogueStealthMax += 1f; // Give rogue stealth. + player.Calamity().rogueStealthMax += SetBonusRogueStealth; // Give rogue stealth. player.Calamity().wearingRogueArmor = true; } } diff --git a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs index 0d162d6663..5ed1269dab 100644 --- a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.VanillaArmorChanges int flareDamage = CalamityUtils.DamageSoftCap(originalDamage * 0.3, FlareDamageSoftcap); Vector2 flareSpawnPosition = victim.Center + Main.rand.NextVector2Circular(10f, 10f); - Projectile.NewProjectile(owner.GetSource_ItemUse(owner.ActiveItem()), flareSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), flareDamage, 0f, owner.whoAmI); + Projectile.NewProjectile(owner.GetSource_OnHit(victim), flareSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), flareDamage, 0f, owner.whoAmI); } } } diff --git a/Items/VanillaArmorChanges/NebulaArmorSetChange.cs b/Items/VanillaArmorChanges/NebulaArmorSetChange.cs index ebab9693fb..508f6285d1 100644 --- a/Items/VanillaArmorChanges/NebulaArmorSetChange.cs +++ b/Items/VanillaArmorChanges/NebulaArmorSetChange.cs @@ -1,7 +1,4 @@ -using System.Text; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ID; namespace CalamityMod.Items.VanillaArmorChanges { diff --git a/Items/VanillaArmorChanges/NecroArmorSetChange.cs b/Items/VanillaArmorChanges/NecroArmorSetChange.cs index f4768a2092..c9ed5209fe 100644 --- a/Items/VanillaArmorChanges/NecroArmorSetChange.cs +++ b/Items/VanillaArmorChanges/NecroArmorSetChange.cs @@ -1,7 +1,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { diff --git a/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs index 18fee450a0..ace816e610 100644 --- a/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs +++ b/Items/VanillaArmorChanges/PlatinumArmorSetChange.cs @@ -1,7 +1,5 @@ -using System; -using Terraria; +using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { @@ -15,34 +13,16 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Platinum"; - public const float HeadDamage = 0.06f; - public const float ChestCrit = 3f; - public const float LegsMoveSpeed = 0.1f; - public const float SetBonusDamagePerDefense = 0.1f; // 10 defense = +1% damage, this gets divided by 100 - public const int SetBonusDefenseCap = 50; - - public override void ApplyHeadPieceEffect(Player player) => player.GetDamage() += HeadDamage; - - public override void ApplyBodyPieceEffect(Player player) => player.GetCritChance() += ChestCrit; - - public override void ApplyLegPieceEffect(Player player) => player.moveSpeed += LegsMoveSpeed; + public const float SetBonusDR = 0.1f; public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(SetBonusDR.ToPercent())}"; } public override void ApplyArmorSetBonus(Player player) { - // 07MAY2024: Ozzatron: Platinum armor doesn't count its own defense for its set bonus - // CIT 1MAR2025: Platinum armor should not count its set bonus defense here, because it hasn't been applied yet - int defenseBesidesThisArmor = player.statDefense - (5 + 6 + 5); - if (defenseBesidesThisArmor <= 0) - return; - - if (defenseBesidesThisArmor > SetBonusDefenseCap) - defenseBesidesThisArmor = SetBonusDefenseCap; - player.GetDamage() += (float)Math.Floor(defenseBesidesThisArmor * SetBonusDamagePerDefense) * 0.01f; + player.endurance += SetBonusDR; } } } diff --git a/Items/VanillaArmorChanges/RainArmorSetChange.cs b/Items/VanillaArmorChanges/RainArmorSetChange.cs index c3845a3259..d777dc2c4a 100644 --- a/Items/VanillaArmorChanges/RainArmorSetChange.cs +++ b/Items/VanillaArmorChanges/RainArmorSetChange.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -24,5 +25,12 @@ namespace CalamityMod.Items.VanillaArmorChanges player.autoJump = true; player.jumpSpeedBoost += 1.2f; // 24% } + + public static void SpawnRainArmorJump(Player Player) + { + bool rainBoost = Player.Center.Y < Main.worldSurface * 16.0 && Main.raining; + int damage = (int)Player.GetBestClassDamage().ApplyTo(30 * (rainBoost ? 2f : 1)); + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Vector2.UnitY * 26, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Main.myPlayer); + } } } diff --git a/Items/VanillaArmorChanges/SilverArmorSetChange.cs b/Items/VanillaArmorChanges/SilverArmorSetChange.cs index 9c9bc580e9..165d7ae5ba 100644 --- a/Items/VanillaArmorChanges/SilverArmorSetChange.cs +++ b/Items/VanillaArmorChanges/SilverArmorSetChange.cs @@ -1,8 +1,6 @@ -using System.Text; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { @@ -16,29 +14,17 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Silver"; - public const float HeadCrit = 5f; - public const int ChestLifeRegen = 2; - public const float LegsMoveSpeed = 0.08f; - public const int SetBonusLifeRegen = 1; - public const double SetBonusMinimumDamageToHeal = 20.0; public const int SetBonusHealTime = 120; public const int SetBonusHealAmount = 10; - public override void ApplyHeadPieceEffect(Player player) => player.GetCritChance() += HeadCrit; - - public override void ApplyBodyPieceEffect(Player player) => player.lifeRegen += ChestLifeRegen; - - public override void ApplyLegPieceEffect(Player player) => player.moveSpeed += LegsMoveSpeed; - public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(SetBonusHealTime.FramesToSeconds(), SetBonusMinimumDamageToHeal.ToString("N0"), SetBonusHealAmount)}"; } public override void ApplyArmorSetBonus(Player player) { - player.lifeRegen += SetBonusLifeRegen; player.Calamity().silverMedkit = true; } diff --git a/Items/VanillaArmorChanges/TinArmorSetChange.cs b/Items/VanillaArmorChanges/TinArmorSetChange.cs index 12a2c7f88e..a46b8b9f21 100644 --- a/Items/VanillaArmorChanges/TinArmorSetChange.cs +++ b/Items/VanillaArmorChanges/TinArmorSetChange.cs @@ -1,5 +1,4 @@ -using System.Text; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -15,25 +14,16 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Tin"; - public const float HeadCrit = 4f; - public const int ChestLifeRegen = 1; - public const float LegsMoveSpeed = 0.05f; - public const float SetBonusArmorPen = 5.0f; - - public override void ApplyHeadPieceEffect(Player player) => player.GetCritChance() += HeadCrit; - - public override void ApplyBodyPieceEffect(Player player) => player.lifeRegen += ChestLifeRegen; - - public override void ApplyLegPieceEffect(Player player) => player.moveSpeed += LegsMoveSpeed; + public const float SetBonusCrit = 10f; public override void UpdateSetBonusText(ref string setBonusText) { - setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(SetBonusCrit)}"; } public override void ApplyArmorSetBonus(Player player) { - player.GetArmorPenetration() += SetBonusArmorPen; + player.GetCritChance() += SetBonusCrit; } } } diff --git a/Items/VanillaArmorChanges/TungstenArmorSetChange.cs b/Items/VanillaArmorChanges/TungstenArmorSetChange.cs index 50c4be4121..31188aa91f 100644 --- a/Items/VanillaArmorChanges/TungstenArmorSetChange.cs +++ b/Items/VanillaArmorChanges/TungstenArmorSetChange.cs @@ -1,8 +1,5 @@ -using System.Text; -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { @@ -16,37 +13,16 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Tungsten"; - public const float HeadDamage = 0.07f; - public const int ChestLifeRegen = 1; - public const float LegsMoveSpeed = 0.08f; - public const float KnockbackMultiplier = 1.33f; - public const float MaxKnockbackCritConversion = 10f; - - public override void ApplyHeadPieceEffect(Player player) => player.GetDamage() += HeadDamage; - - public override void ApplyBodyPieceEffect(Player player) => player.lifeRegen += ChestLifeRegen; - - public override void ApplyLegPieceEffect(Player player) => player.moveSpeed += LegsMoveSpeed; + public const float HookBoost = 0.5f; public override void UpdateSetBonusText(ref string setBonusText) { - Player player = Main.LocalPlayer; - float kb = player.GetWeaponKnockback(player.ActiveItem()); - float bonus = MathHelper.Clamp(kb, 0f, MaxKnockbackCritConversion); - - string bonusText = bonus.ToString("n2"); - string kbText = kb.ToString("n2"); - setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(bonusText, kbText)}"; + setBonusText += $"\n{CalamityUtils.GetText($"Vanilla.Armor.SetBonus.{ArmorSetName}").Format(HookBoost.ToPercent())}"; } public override void ApplyArmorSetBonus(Player player) { - // Apply the 33% knockback boost first, so it applies to the following crit boost - player.GetKnockback() *= KnockbackMultiplier; - - // Give the player crit chance equal to the (now boosted) knockback of their held weapon. - float kbToUse = player.GetWeaponKnockback(player.ActiveItem()); - player.GetCritChance() += MathHelper.Clamp(kbToUse, 0f, MaxKnockbackCritConversion); + player.Calamity().tungstenArmorHookBoost = true; } } } diff --git a/Items/VanillaArmorChanges/VanillaArmorChange.cs b/Items/VanillaArmorChanges/VanillaArmorChange.cs index 7f83242922..1831d7e8dd 100644 --- a/Items/VanillaArmorChanges/VanillaArmorChange.cs +++ b/Items/VanillaArmorChanges/VanillaArmorChange.cs @@ -1,12 +1,13 @@ using System.Linq; using Terraria; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { // Certain things are virtual instead of abstract because not all pieces of armor are explicitly a part of any particular set. // The Wizard Hat is an example of this. The IDs are left abstract so that you don't mistakenly forget to override one of them. - public abstract class VanillaArmorChange + public abstract class VanillaArmorChange : ILoadable { public abstract int? HeadPieceID { get; } @@ -57,5 +58,15 @@ namespace CalamityMod.Items.VanillaArmorChanges if ((LegPieceID ?? ItemID.None) == player.armor[2].type || AlternativeLegPieceIDs.Contains(player.armor[2].type)) ApplyLegPieceEffect(player); } + + public void Load(Mod mod) + { + VanillaArmorChangeManager.ArmorChanges.Add(this); + } + + public void Unload() + { + // Don't really need to do anything here yet + } } } diff --git a/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs index 591bb65d2d..1681dd5cda 100644 --- a/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs +++ b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs @@ -1,26 +1,15 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Serialization; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod.Items.VanillaArmorChanges { public class VanillaArmorChangeManager : ModSystem { - internal static List ArmorChanges; - - public override void OnModLoad() - { - ArmorChanges = []; - ReflectionHelper.IterateCalamityTypes(action: type => - { - ArmorChanges.Add((VanillaArmorChange)Activator.CreateInstance(type)); - }); - } + internal static List ArmorChanges = []; public override void Unload() { diff --git a/Items/VoodooDemonVoodooDoll.cs b/Items/VoodooDemonVoodooDoll.cs deleted file mode 100644 index 5885c4c135..0000000000 --- a/Items/VoodooDemonVoodooDoll.cs +++ /dev/null @@ -1,101 +0,0 @@ -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) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.SpawnPrevention; - } - - public override bool CanRightClick() => true; - - public override void RightClick(Player player) - { - if (player.Calamity().disableVoodooSpawns == true) - player.Calamity().disableVoodooSpawns = false; - else - player.Calamity().disableVoodooSpawns = true; - state = player.Calamity().disableVoodooSpawns; - - Item.RestoreConsumedItemByRightClick(); - } - - /* - 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() - { - CreateRecipe(). - AddIngredient(ItemID.HellstoneBar, 5). - AddIngredient(ItemID.Silk, 5). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/AerialTracker.cs b/Items/Weapons/DraedonsArsenal/AerialTracker.cs new file mode 100644 index 0000000000..8bb357e8d8 --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/AerialTracker.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("TrackingDisk")] + public class AerialTracker : RogueWeapon, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override void SetDefaults() + { + CalamityGlobalItem modItem = Item.Calamity(); + + Item.width = 52; + Item.height = 40; + Item.damage = 16; + Item.DamageType = RogueDamageClass.Instance; + Item.useTime = 40; + Item.useAnimation = 40; + Item.useStyle = ItemUseStyleID.Swing; + Item.useTurn = false; + Item.knockBack = 3f; + + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + + Item.noMelee = true; + Item.noUseGraphic = true; + + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 8f; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.Calamity().StealthStrikeAvailable()) + { + for (int i = -1; i <= 1; i += 2) + { + Vector2 vel = (velocity * 1.2f).RotatedBy(0.6f * i); + int proj = Projectile.NewProjectile(source, position, vel, type, (int)(damage * 0.8f), knockback, player.whoAmI); + Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].ai[2] = i; + Main.projectile[proj].extraUpdates = 3; + Main.projectile[proj].tileCollide = false; + } + } + else + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + return false; + } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(7). + AddIngredient(4). + AddIngredient(7). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/AerialTracker.png b/Items/Weapons/DraedonsArsenal/AerialTracker.png new file mode 100644 index 0000000000..989a70fb14 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/AerialTracker.png differ diff --git a/Items/Weapons/DraedonsArsenal/AqueousHunterDrone.cs b/Items/Weapons/DraedonsArsenal/AqueousHunterDrone.cs new file mode 100644 index 0000000000..6aa71e69b2 --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/AqueousHunterDrone.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + public class AqueousHunterDrone : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public static readonly SoundStyle Fire = new("CalamityMod/Sounds/Item/ShrimpFire"); + public static readonly SoundStyle Hit = new("CalamityMod/Sounds/Item/ShrimpMissileHit"); + public static readonly SoundStyle Sound1 = new("CalamityMod/Sounds/Item/ShrimpSound1"); + public static readonly SoundStyle Sound2 = new("CalamityMod/Sounds/Item/ShrimpSound2"); + public static readonly SoundStyle Surprise = new("CalamityMod/Sounds/Item/ShrimpSurprise"); + public override void SetDefaults() + { + CalamityGlobalItem modItem = Item.Calamity(); + + Item.width = 34; + Item.height = 32; + Item.shootSpeed = 10f; + Item.damage = 24; + Item.mana = 10; + Item.useAnimation = Item.useTime = 36; + Item.useStyle = ItemUseStyleID.HoldUp; + Item.noMelee = true; + Item.knockBack = 2.25f; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.DamageType = DamageClass.Summon; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Vector2 mouse = player.ClampedMouseWorld(); + Point mouseTileCoords = mouse.ToTileCoordinates(); + if (!CalamityUtils.ParanoidTileRetrieval(mouseTileCoords.X, mouseTileCoords.Y).HasTile) + { + int p = Projectile.NewProjectile(source, new Vector2(mouse.X, player.Center.Y - 600), Vector2.Zero, type, damage, knockback, player.whoAmI); + Main.projectile[p].localAI[2] = player.ownedProjectileCounts[Item.shoot]; + if (Main.projectile.IndexInRange(p)) + Main.projectile[p].originalDamage = Item.damage; + } + return false; + } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddIngredient(4). + AddIngredient(4). + AddIngredient(7). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/AqueousHunterDrone.png b/Items/Weapons/DraedonsArsenal/AqueousHunterDrone.png new file mode 100644 index 0000000000..4c5c16cd38 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/AqueousHunterDrone.png differ diff --git a/Items/Weapons/DraedonsArsenal/AqueousHunterDroneGlow.png b/Items/Weapons/DraedonsArsenal/AqueousHunterDroneGlow.png new file mode 100644 index 0000000000..b069a6dde7 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/AqueousHunterDroneGlow.png differ diff --git a/Items/Weapons/DraedonsArsenal/Auger.cs b/Items/Weapons/DraedonsArsenal/Auger.cs new file mode 100644 index 0000000000..6f20e1189a --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/Auger.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + public class Auger : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override void SetDefaults() + { + Item.width = 26; + Item.height = 26; + Item.damage = 68; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useTime = Item.useAnimation = 12; + Item.knockBack = 12f; + Item.autoReuse = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.shoot = ModContent.ProjectileType(); + Item.noMelee = true; + Item.channel = true; + Item.noUseGraphic = true; + + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + } + 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/AugerGlow").Value); + } + public override bool MeleePrefix() => true; + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) => true; + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + player.Calamity().mouseWorldListener = true; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + float swordType = 0; + if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0) + swordType = 5; + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, swordType); + + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(5). + AddIngredient(7). + AddIngredient(4). + AddIngredient(7). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/Auger.png b/Items/Weapons/DraedonsArsenal/Auger.png new file mode 100644 index 0000000000..deb4092662 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/Auger.png differ diff --git a/Items/Weapons/DraedonsArsenal/AugerGlow.png b/Items/Weapons/DraedonsArsenal/AugerGlow.png new file mode 100644 index 0000000000..5c8a5771a1 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/AugerGlow.png differ diff --git a/Items/Weapons/DraedonsArsenal/CountermeasureMitt.cs b/Items/Weapons/DraedonsArsenal/CountermeasureMitt.cs new file mode 100644 index 0000000000..f259e6756b --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/CountermeasureMitt.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("GatlingLaser")] + public class CountermeasureMitt : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override void SetDefaults() + { + CalamityGlobalItem modItem = Item.Calamity(); + + Item.width = 54; + Item.height = 56; + Item.DamageType = DamageClass.Magic; + Item.mana = 3; + Item.damage = 45; + Item.knockBack = 4f; + Item.useAnimation = Item.useTime = 11; + Item.autoReuse = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.channel = true; + Item.noUseGraphic = true; + + Item.value = CalamityGlobalItem.RarityYellowBuyPrice; + Item.rare = ItemRarityID.Yellow; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 24f; + } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) => true; + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + player.Calamity().mouseWorldListener = true; + } + 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/CountermeasureMittGlow").Value); + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + float gunType = 0; + if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0) + gunType = 5; + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, gunType); + + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(15). + AddIngredient(5). + AddIngredient(10). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func condition), condition). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/CountermeasureMitt.png b/Items/Weapons/DraedonsArsenal/CountermeasureMitt.png new file mode 100644 index 0000000000..ea23481c15 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/CountermeasureMitt.png differ diff --git a/Items/Weapons/DraedonsArsenal/CountermeasureMittGlow.png b/Items/Weapons/DraedonsArsenal/CountermeasureMittGlow.png new file mode 100644 index 0000000000..3c119c3088 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/CountermeasureMittGlow.png differ diff --git a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs deleted file mode 100644 index 12f8741267..0000000000 --- a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Projectiles.DraedonsArsenal; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class FrequencyManipulator : RogueWeapon, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 26; - Item.height = 44; - Item.damage = 80; - Item.DamageType = RogueDamageClass.Instance; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.useTime = 56; - Item.useAnimation = 56; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.knockBack = 5f; - - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; - Item.UseSound = SoundID.Item1; - - Item.shootSpeed = 16f; - Item.shoot = ModContent.ProjectileType(); - - modItem.UsesCharge = true; - modItem.MaxCharge = 85f; - modItem.ChargePerUse = 0.04f; - } - - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (player.Calamity().StealthStrikeAvailable()) - damage = (int)(damage * 0.9f); - - int proj = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(8). - AddIngredient(12). - AddRecipeGroup("AnyMythrilBar", 10). - AddIngredient(ItemID.SoulofSight, 20). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.png b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.png deleted file mode 100644 index e99257dcc2..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs b/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs index 7361d5bda7..f6738e8073 100644 --- a/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs +++ b/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs @@ -41,10 +41,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 21f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 0.075f; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; diff --git a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs deleted file mode 100644 index 17fb58acf7..0000000000 --- a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.DraedonsArsenal; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class GatlingLaser : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/GatlingLaserFireStart"); - public static readonly SoundStyle FireLoopSound = new("CalamityMod/Sounds/Item/GatlingLaserFireLoop"); - public static readonly SoundStyle FireEndSound = new("CalamityMod/Sounds/Item/GatlingLaserFireEnd"); - - - // This is the amount of charge consumed every time the holdout projectile fires a laser. - public const float HoldoutChargeUse = 0.0075f; - - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 43; - Item.height = 24; - Item.DamageType = DamageClass.Magic; - Item.damage = 43; - Item.knockBack = 1f; - Item.useTime = 2; - Item.useAnimation = 2; - Item.noUseGraphic = true; - Item.autoReuse = false; - Item.channel = true; - Item.mana = 4; - - Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = FireSound; - Item.noMelee = true; - - Item.value = CalamityGlobalItem.RarityYellowBuyPrice; - Item.rare = ItemRarityID.Yellow; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 24f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. - } - - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); - - public override Vector2? HoldoutOffset() => new Vector2(-20, 0); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(15). - AddIngredient(15). - AddIngredient(5). - AddIngredient(10). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func condition), condition). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/GaussDagger.cs b/Items/Weapons/DraedonsArsenal/GaussDagger.cs deleted file mode 100644 index e8e51a0954..0000000000 --- a/Items/Weapons/DraedonsArsenal/GaussDagger.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Projectiles.DraedonsArsenal; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class GaussDagger : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 26; - Item.height = 26; - Item.damage = 25; - Item.DamageType = DamageClass.Melee; - Item.useTime = 24; - Item.useAnimation = 24; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTurn = true; - Item.knockBack = 7f; - - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.05f; - } - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - if (target.Calamity().GaussFluxTimer == 0) - { - target.Calamity().GaussFluxTimer = 50; - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectile(player.GetSource_ItemUse(Item), target.Center, Vector2.Zero, ModContent.ProjectileType(), Item.damage, 0f, player.whoAmI, 0f, target.whoAmI); - } - } - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(7). - AddIngredient(4). - AddIngredient(7). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/GaussDagger.png b/Items/Weapons/DraedonsArsenal/GaussDagger.png deleted file mode 100644 index 77ac1dfc11..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/GaussDagger.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/GaussPistol.cs b/Items/Weapons/DraedonsArsenal/GaussPistol.cs deleted file mode 100644 index 445df79e74..0000000000 --- a/Items/Weapons/DraedonsArsenal/GaussPistol.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.DraedonsArsenal; -using CalamityMod.Sounds; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class GaussPistol : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 40; - Item.height = 22; - Item.DamageType = DamageClass.Magic; - Item.mana = 6; - Item.damage = 150; - Item.knockBack = 11f; - Item.useAnimation = Item.useTime = 20; - Item.autoReuse = true; - - Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = CommonCalamitySounds.GaussWeaponFire; - Item.noMelee = true; - - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; - - modItem.MaxCharge = 85f; - modItem.UsesCharge = true; - modItem.ChargePerUse = 0.05f; - } - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(12). - AddIngredient(8). - AddRecipeGroup("AnyMythrilBar", 10). - AddIngredient(ItemID.SoulofMight, 20). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/GaussPistol.png b/Items/Weapons/DraedonsArsenal/GaussPistol.png deleted file mode 100644 index d68e739419..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/GaussPistol.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/GaussRifle.cs b/Items/Weapons/DraedonsArsenal/GaussRifle.cs deleted file mode 100644 index 5988a7d135..0000000000 --- a/Items/Weapons/DraedonsArsenal/GaussRifle.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.DraedonsArsenal; -using CalamityMod.Sounds; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class GaussRifle : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/LargeMechGaussRifle"); - - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 70; - Item.height = 30; - Item.DamageType = DamageClass.Ranged; - Item.damage = 100; - Item.knockBack = 0.2f; - Item.useTime = Item.useAnimation = 10; - Item.autoReuse = true; - - Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/GaussFire") with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0.5f, 0.65f) }; - Item.noMelee = true; - - Item.value = CalamityGlobalItem.RarityYellowBuyPrice; - Item.rare = ItemRarityID.Yellow; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 7f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 0.0225f; - } - - 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 * 6, velocity.RotatedByRandom(0.03f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); - 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/GaussRifleGlow").Value); - } - public override void UseStyle(Player player, Rectangle heldItemFrame) - { - player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); - float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; - - Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; - Vector2 itemSize = new Vector2(70, 30); - Vector2 itemOrigin = new Vector2(-18, 6); - - CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); - - base.UseStyle(player, heldItemFrame); - } - public override void UseItemFrame(Player player) - { - player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); - - float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; - float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; - if (animProgress < 0.4f) - rotation += -0.025f * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction; - - player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); - } - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(18). - AddIngredient(12). - AddIngredient(5). - AddIngredient(10). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func condition), condition). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/GaussRifle.png b/Items/Weapons/DraedonsArsenal/GaussRifle.png deleted file mode 100644 index ac001b522d..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/GaussRifle.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/GaussRifleGlow.png b/Items/Weapons/DraedonsArsenal/GaussRifleGlow.png deleted file mode 100644 index 89cc2dc642..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/GaussRifleGlow.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/HolofiberImmolator.cs b/Items/Weapons/DraedonsArsenal/HolofiberImmolator.cs deleted file mode 100644 index ab7226c2e3..0000000000 --- a/Items/Weapons/DraedonsArsenal/HolofiberImmolator.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.DraedonsArsenal; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - [LegacyName("MatterModulator")] - public class HolofiberImmolator : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public static readonly SoundStyle PlasmaSound = new("CalamityMod/Sounds/Item/PlasmaSmall"); - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 30; - Item.height = 62; - Item.DamageType = DamageClass.Ranged; - Item.damage = 57; - Item.knockBack = 0.8f; - Item.useTime = Item.useAnimation = 14; - Item.autoReuse = true; - Item.noUseGraphic = true; - Item.channel = true; - - Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = null; - Item.noMelee = true; - - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; - //Item.useAmmo = AmmoID.Arrow; - - modItem.UsesCharge = true; - modItem.MaxCharge = 85f; - modItem.ChargePerUse = 0.001f; // Charge depletion is done in the holdout, but it needs a small fee to prevent usage at 0% - } - - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - public override bool CanConsumeAmmo(Item ammo, Player player) => false; - public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; - 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/HolofiberImmolatorGlow").Value); - } - 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, 1); - holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); - return false; - } - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(12). - AddIngredient(8). - AddRecipeGroup("AnyMythrilBar", 10). - AddIngredient(ItemID.SoulofFright, 20). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/HolofiberImmolator.png b/Items/Weapons/DraedonsArsenal/HolofiberImmolator.png deleted file mode 100644 index cda04308bb..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/HolofiberImmolator.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/HolofiberImmolatorGlow.png b/Items/Weapons/DraedonsArsenal/HolofiberImmolatorGlow.png deleted file mode 100644 index b0ce820d9a..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/HolofiberImmolatorGlow.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/HolofibreImmolator.cs b/Items/Weapons/DraedonsArsenal/HolofibreImmolator.cs new file mode 100644 index 0000000000..e151cbc2aa --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/HolofibreImmolator.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("MatterModulator")] + public class HolofibreImmolator : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public static readonly SoundStyle PlasmaSound = new("CalamityMod/Sounds/Item/PlasmaSmall"); + public override void SetStaticDefaults() + { + ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + } + public override void SetDefaults() + { + CalamityGlobalItem modItem = Item.Calamity(); + + Item.width = 26; + Item.height = 78; + Item.DamageType = DamageClass.Ranged; + Item.damage = 30; + Item.knockBack = 0.8f; + Item.useTime = Item.useAnimation = 14; + Item.autoReuse = true; + Item.noUseGraphic = true; + Item.channel = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = null; + Item.noMelee = true; + + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 12f; + } + public override bool AltFunctionUse(Player player) => true; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + + player.Calamity().mouseWorldListener = true; + } + 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/HolofibreImmolatorGlow").Value); + } + 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, 1); + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; + } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(12). + AddIngredient(8). + AddRecipeGroup("AnyMythrilBar", 10). + AddIngredient(ItemID.SoulofFright, 20). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/HolofibreImmolator.png b/Items/Weapons/DraedonsArsenal/HolofibreImmolator.png new file mode 100644 index 0000000000..6a8c4ccaae Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/HolofibreImmolator.png differ diff --git a/Items/Weapons/DraedonsArsenal/HolofibreImmolatorGlow.png b/Items/Weapons/DraedonsArsenal/HolofibreImmolatorGlow.png new file mode 100644 index 0000000000..847fa4b5c8 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/HolofibreImmolatorGlow.png differ diff --git a/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs b/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs index 8fce78b1c8..44004d9aa0 100644 --- a/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs +++ b/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs @@ -12,8 +12,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public class HydraulicVoltCrasher : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - // This is the amount of charge consumed every frame the holdout projectile is summoned, i.e. the weapon is in use. - public const float HoldoutChargeUse = 0.002f; public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; @@ -43,10 +41,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.noUseGraphic = true; Item.DamageType = TrueMeleeNoSpeedDamageClass.Instance; Item.channel = true; - - modItem.UsesCharge = true; - modItem.MaxCharge = 85f; - modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. } public override bool AltFunctionUse(Player player) => true; @@ -62,7 +56,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal { Item.hammer = 100; } - return player.ownedProjectileCounts[Item.shoot] <= 0 && Item.Calamity().Charge > 0; + return player.ownedProjectileCounts[Item.shoot] <= 0; } public override void HoldItem(Player player) { diff --git a/Items/Weapons/DraedonsArsenal/MountedScanner.cs b/Items/Weapons/DraedonsArsenal/MountedScanner.cs index f6a07d25f4..597c31346b 100644 --- a/Items/Weapons/DraedonsArsenal/MountedScanner.cs +++ b/Items/Weapons/DraedonsArsenal/MountedScanner.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.damage = 24; Item.knockBack = 2f; Item.mana = 10; - Item.useAnimation = Item.useTime = 24; + Item.useAnimation = Item.useTime = 36; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.HoldUp; @@ -36,11 +36,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 1f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 85f; - modItem.ChargePerUse = 0.85f; - modItem.ChargePerAltUse = 0f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/DraedonsArsenal/Nidhogg.cs b/Items/Weapons/DraedonsArsenal/Nidhogg.cs new file mode 100644 index 0000000000..b709c79b66 --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/Nidhogg.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("GaussRifle", "CompactRailgun")] + public class Nidhogg : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + } + public override void SetDefaults() + { + CalamityGlobalItem modItem = Item.Calamity(); + + Item.width = 70; + Item.height = 30; + Item.DamageType = DamageClass.Ranged; + Item.damage = 69; + Item.knockBack = 7f; + Item.useTime = Item.useAnimation = 8; + Item.autoReuse = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.channel = true; + Item.noUseGraphic = true; + + Item.value = CalamityGlobalItem.RarityYellowBuyPrice; + Item.rare = ItemRarityID.Yellow; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 7f; + } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) => true; + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + player.Calamity().mouseWorldListener = true; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + float gunType = 0; + if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0) + gunType = 5; + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, gunType); + + // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction + // 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); + 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/NidhoggGlow").Value); + } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(18). + AddIngredient(12). + AddIngredient(5). + AddIngredient(10). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func condition), condition). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/Nidhogg.png b/Items/Weapons/DraedonsArsenal/Nidhogg.png new file mode 100644 index 0000000000..9e37dee348 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/Nidhogg.png differ diff --git a/Items/Weapons/DraedonsArsenal/NidhoggGlow.png b/Items/Weapons/DraedonsArsenal/NidhoggGlow.png new file mode 100644 index 0000000000..6df5cebd78 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/NidhoggGlow.png differ diff --git a/Items/Weapons/DraedonsArsenal/PhalanxSurge.cs b/Items/Weapons/DraedonsArsenal/PhalanxSurge.cs new file mode 100644 index 0000000000..aae000f87b --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/PhalanxSurge.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.DraedonsArsenal; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("HeavyLaserRifle")] + [LegacyName("ScattershotSkewer")] + public class PhalanxSurge : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + } + public override void SetDefaults() + { + Item.width = 64; + Item.height = 36; + Item.DamageType = DamageClass.Ranged; + Item.damage = 175; + Item.knockBack = 4f; + Item.useTime = 30; + Item.useAnimation = 30; + Item.autoReuse = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.channel = true; + Item.noUseGraphic = true; + + Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + Item.rare = ModContent.RarityType(); + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 5f; + } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) => true; + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + player.Calamity().mouseWorldListener = true; + } + 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/PhalanxSurgeGlow").Value); + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + float gunType = 0; + if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0) + gunType = 5; + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, gunType); + + // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction + // 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); + return false; + } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddIngredient(15). + AddIngredient(8). + AddIngredient(ItemID.LunarBar, 4). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(4, out Func condition), condition). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/ScattershotSkewer.png b/Items/Weapons/DraedonsArsenal/PhalanxSurge.png similarity index 100% rename from Items/Weapons/DraedonsArsenal/ScattershotSkewer.png rename to Items/Weapons/DraedonsArsenal/PhalanxSurge.png diff --git a/Items/Weapons/DraedonsArsenal/ScattershotSkewerGlow.png b/Items/Weapons/DraedonsArsenal/PhalanxSurgeGlow.png similarity index 100% rename from Items/Weapons/DraedonsArsenal/ScattershotSkewerGlow.png rename to Items/Weapons/DraedonsArsenal/PhalanxSurgeGlow.png diff --git a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs index d177e4d0b0..986806d251 100644 --- a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs +++ b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs @@ -20,10 +20,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public const float SizeChargeThreshold = 0.25f; // The small sword barely affects damage on its own because damage is already dropping significantly at low charge. public const float SmallDamageMultiplier = 0.9f; - // This is the amount of charge consumed every frame the holdout projectile is summoned, i.e. the weapon is in use. - public const float HoldoutChargeUse = 0.005f; - // This is the amount of charge consumed every time a sword beam is fired. - public const float SwordBeamChargeUse = 0.1f; public override void SetDefaults() { @@ -31,7 +27,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 26; Item.height = 26; - Item.damage = 980; + Item.damage = 1350; Item.DamageType = DamageClass.MeleeNoSpeed; Item.useTime = 24; Item.useAnimation = 24; @@ -43,20 +39,16 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.noUseGraphic = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.channel = true; - - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && Item.Calamity().Charge > 0; + public override bool CanUseItem(Player player) => 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) { diff --git a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs index 544c5818aa..7520d358ee 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs @@ -47,11 +47,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 5f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 0.32f; - modItem.ChargePerAltUse = 0.12f; // turbo mode is more energy inefficient } public override bool AltFunctionUse(Player player) => true; @@ -108,7 +103,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal AddIngredient(8). AddIngredient(ItemID.LunarBar, 4). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(4, out Func condition), condition). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs index 1a3f98583d..c2394b7a95 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 22; Item.height = 28; - Item.damage = 950; + Item.damage = 860; Item.noMelee = true; Item.noUseGraphic = true; Item.consumable = false; @@ -37,18 +37,13 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; Item.DamageType = RogueDamageClass.Instance; - - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0.25f; } - public override float StealthDamageMultiplier => 0.90f; public override float StealthVelocityMultiplier => 1.2f; public override float StealthKnockbackMultiplier => 1.5f; diff --git a/Items/Weapons/DraedonsArsenal/PoleWarper.cs b/Items/Weapons/DraedonsArsenal/PoleWarper.cs index 5c2902b993..574881ee74 100644 --- a/Items/Weapons/DraedonsArsenal/PoleWarper.cs +++ b/Items/Weapons/DraedonsArsenal/PoleWarper.cs @@ -23,26 +23,21 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 38; Item.height = 24; Item.shootSpeed = 10f; - Item.damage = 310; + Item.damage = 207; Item.mana = 12; - Item.useAnimation = Item.useTime = 9; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 8f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item15; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; - - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 1.25f; - modItem.ChargePerAltUse = 0f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockBack) diff --git a/Items/Weapons/DraedonsArsenal/PulseDragon.cs b/Items/Weapons/DraedonsArsenal/PulseDragon.cs index 25fd1376a2..47de2e064d 100644 --- a/Items/Weapons/DraedonsArsenal/PulseDragon.cs +++ b/Items/Weapons/DraedonsArsenal/PulseDragon.cs @@ -36,10 +36,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.channel = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 0.32f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockBack) @@ -64,7 +60,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal AddIngredient(8). AddIngredient(ItemID.LunarBar, 4). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(4, out Func condition), condition). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/DraedonsArsenal/PulseGrenade.cs b/Items/Weapons/DraedonsArsenal/PulseGrenade.cs new file mode 100644 index 0000000000..480f8fbc4a --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/PulseGrenade.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("FrequencyManipulator")] + public class PulseGrenade : RogueWeapon, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override void SetDefaults() + { + CalamityGlobalItem modItem = Item.Calamity(); + + Item.width = 30; + Item.height = 40; + Item.damage = 59; + Item.DamageType = RogueDamageClass.Instance; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.useTime = 75; + Item.useAnimation = 75; + Item.autoReuse = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.knockBack = 8f; + Item.channel = true; + + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; + + Item.shootSpeed = 16f; + Item.shoot = ModContent.ProjectileType(); + } + public override bool CanUseItem(Player player) + { + return (player.ownedProjectileCounts[Item.shoot] <= 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0); + } + public override void HoldItem(Player player) + { + bool notUsingItem = (player.ownedProjectileCounts[Item.shoot] <= 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0); + if (!notUsingItem) + { + player.Calamity().rogueStealth = 0; + } + + player.Calamity().mouseWorldListener = true; + } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile grenade = Projectile.NewProjectileDirect(source, position, velocity, type, damage, 0, player.whoAmI, 0, 0); + 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/PulseGrenadeGlow").Value); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddIngredient(12). + AddRecipeGroup("AnyMythrilBar", 10). + AddIngredient(ItemID.SoulofSight, 20). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/PulseGrenade.png b/Items/Weapons/DraedonsArsenal/PulseGrenade.png new file mode 100644 index 0000000000..a30040e813 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/PulseGrenade.png differ diff --git a/Items/Weapons/DraedonsArsenal/PulseGrenadeGlow.png b/Items/Weapons/DraedonsArsenal/PulseGrenadeGlow.png new file mode 100644 index 0000000000..9d305134cc Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/PulseGrenadeGlow.png differ diff --git a/Items/Weapons/DraedonsArsenal/PulsePistol.cs b/Items/Weapons/DraedonsArsenal/PulsePistol.cs index c75c22416d..45033681b3 100644 --- a/Items/Weapons/DraedonsArsenal/PulsePistol.cs +++ b/Items/Weapons/DraedonsArsenal/PulsePistol.cs @@ -22,11 +22,12 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 54; Item.height = 38; Item.DamageType = DamageClass.Magic; - Item.damage = 70; + Item.damage = 42; Item.knockBack = 3f; - Item.useTime = Item.useAnimation = 44; + Item.useTime = 64; + Item.useAnimation = 64; Item.autoReuse = true; - Item.mana = 3; + Item.mana = 15; Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = PulseRifle.FireSound with { Pitch = 0.3f, Volume = 0.7f }; @@ -36,16 +37,12 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 8.2f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.01f; + Item.shootSpeed = 8f; } 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 * 4, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 3f); + Projectile.NewProjectile(source, position + velocity * 4, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } public override void UseStyle(Player player, Rectangle heldItemFrame) diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.cs b/Items/Weapons/DraedonsArsenal/PulseRifle.cs index 3d58c31b72..787cd50132 100644 --- a/Items/Weapons/DraedonsArsenal/PulseRifle.cs +++ b/Items/Weapons/DraedonsArsenal/PulseRifle.cs @@ -19,17 +19,18 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/PulseRifleFire") { Volume = 0.8f }; - private int BaseDamage = 990; public int FiringTimer = 30; + public override void SetStaticDefaults() + { + ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + } public override void SetDefaults() { - CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 100; Item.height = 32; Item.DamageType = DamageClass.Ranged; - Item.damage = BaseDamage; + Item.damage = 530; Item.useAnimation = Item.useTime = 55; Item.knockBack = 0.25f; Item.shoot = ModContent.ProjectileType(); @@ -41,17 +42,44 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.noMelee = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0.24f; + Item.rare = ModContent.RarityType(); } 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 void UseStyle(Player player, Rectangle heldItemFrame) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + + float pullback = 13f; + + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.8f) + pullback -= (5.75f) * (float)Math.Pow((0.85f - animProgress) / 0.85f, 2); + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * pullback; + Vector2 itemSize = new Vector2(100, 32); + Vector2 itemOrigin = new Vector2(-44, 4); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + + base.UseStyle(player, heldItemFrame); + } + + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } public override Vector2? HoldoutOffset() => new Vector2(-15, 0); diff --git a/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs b/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs index 3ddaa8b693..96d5975e9a 100644 --- a/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs +++ b/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.DamageType = DamageClass.Summon; Item.sentry = true; Item.mana = 10; - Item.useAnimation = Item.useTime = 24; + Item.useAnimation = Item.useTime = 30; Item.knockBack = 0.25f; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 1f; @@ -36,11 +36,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; - - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 1f; - modItem.ChargePerAltUse = 0f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/DraedonsArsenal/ScattershotSkewer.cs b/Items/Weapons/DraedonsArsenal/ScattershotSkewer.cs deleted file mode 100644 index 33cf49ae5f..0000000000 --- a/Items/Weapons/DraedonsArsenal/ScattershotSkewer.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.DraedonsArsenal; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - [LegacyName("HeavyLaserRifle")] - public class ScattershotSkewer : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 64; - Item.height = 36; - Item.DamageType = DamageClass.Ranged; - Item.damage = 196; - Item.knockBack = 4f; - Item.useTime = 45; - Item.useAnimation = 35; - Item.autoReuse = true; - - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.channel = true; - Item.noUseGraphic = true; - - Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.rare = ModContent.RarityType(); - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 5f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 0.001f; // Charge depletion is done in the holdout, but it needs a small fee to prevent usage at 0% - } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; - 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/ScattershotSkewerGlow").Value); - } - 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, 1); - holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); - return false; - } - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(15). - AddIngredient(15). - AddIngredient(8). - AddIngredient(ItemID.LunarBar, 4). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(4, out Func condition), condition). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/ShortCircuit.cs b/Items/Weapons/DraedonsArsenal/ShortCircuit.cs new file mode 100644 index 0000000000..fdb1940821 --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/ShortCircuit.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("Taser")] + public class ShortCircuit : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(10); + public static readonly SoundStyle Fire = new("CalamityMod/Sounds/Item/TaserLaunch") { Volume = 0.6f }; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + } + public override void SetDefaults() + { + CalamityGlobalItem modItem = Item.Calamity(); + + Item.width = 42; + Item.height = 24; + Item.DamageType = DamageClass.Ranged; + Item.damage = 11; + Item.knockBack = 7f; + Item.useTime = Item.useAnimation = 8; + Item.autoReuse = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 6f; + } + public override float UseSpeedMultiplier(Player player) + { + if (player.altFunctionUse == 2) + return 0.3f; + + return 1f; + } + public override bool CanUseItem(Player player) => (player.altFunctionUse == 2 && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) || player.altFunctionUse == 0; + 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) + { + if (player.altFunctionUse == 2 && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0) + { + SoundEngine.PlaySound(Fire with { Pitch = -0.1f }, position); + Projectile hook = Projectile.NewProjectileDirect(source, position, velocity, ModContent.ProjectileType(), (int)(damage * 1.2f), 0, player.whoAmI); + return false; + } + + if (player.altFunctionUse == 0) + { + SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotSmall"); + SoundEngine.PlaySound(fire with { Pitch = Main.rand.NextFloat(0.5f, 0.65f), Volume = 0.2f, MaxInstances = -1 }, position); + Projectile shot = Projectile.NewProjectileDirect(source, position + velocity - Vector2.UnitY * 5, (velocity * 1.5f).RotatedByRandom(0.15f), type, damage, 0, player.whoAmI); + return false; + } + + return false; + } + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + player.Calamity().mouseWorldListener = true; + } + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + if (player.altFunctionUse == 0) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + + float pullback = 7f; + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.4f) + pullback -= (2.75f) * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2); + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * pullback; + Vector2 itemSize = new Vector2(42, 24); + Vector2 itemOrigin = new Vector2(-24, 4); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + + base.UseStyle(player, heldItemFrame); + } + } + + public override void UseItemFrame(Player player) + { + if (player.altFunctionUse == 0) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.4f) + rotation += (player.altFunctionUse == 2 ? -0.15f : 0) * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } + } + public override Vector2? HoldoutOffset() => new Vector2(0f, 0f); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(7). + AddIngredient(5). + AddIngredient(4). + AddIngredient(7). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/Taser.png b/Items/Weapons/DraedonsArsenal/ShortCircuit.png similarity index 100% rename from Items/Weapons/DraedonsArsenal/Taser.png rename to Items/Weapons/DraedonsArsenal/ShortCircuit.png diff --git a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs index 1b041e028e..5b65b1c0a3 100644 --- a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs +++ b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.height = 24; Item.damage = 200; Item.mana = 12; - Item.useAnimation = Item.useTime = 14; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 3f; @@ -40,12 +40,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; - - CalamityGlobalItem modItem = Item.Calamity(); - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 1f; - modItem.ChargePerAltUse = 0f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -64,7 +58,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal AddIngredient(8). AddIngredient(ItemID.LunarBar, 4). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(4, out Func condition), condition). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs b/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs deleted file mode 100644 index 15fda0cf58..0000000000 --- a/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Projectiles.DraedonsArsenal; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class StarSwallowerContainmentUnit : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 18; - Item.height = 28; - Item.shootSpeed = 10f; - Item.damage = 24; - Item.mana = 10; - Item.useAnimation = Item.useTime = 30; - Item.useStyle = ItemUseStyleID.HoldUp; - Item.noMelee = true; - Item.knockBack = 2.25f; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.UseSound = SoundID.Item15; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - Item.DamageType = DamageClass.Summon; - - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.8f; - modItem.ChargePerAltUse = 0f; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Vector2 mouse = player.ClampedMouseWorld(); - Point mouseTileCoords = mouse.ToTileCoordinates(); - if (!CalamityUtils.ParanoidTileRetrieval(mouseTileCoords.X, mouseTileCoords.Y).HasTile) - { - int p = Projectile.NewProjectile(source, mouse, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } - return false; - } - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(8). - AddIngredient(4). - AddIngredient(4). - AddIngredient(7). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/SystemBane.cs b/Items/Weapons/DraedonsArsenal/SystemBane.cs index aaa42e66ec..2578cc8d2f 100644 --- a/Items/Weapons/DraedonsArsenal/SystemBane.cs +++ b/Items/Weapons/DraedonsArsenal/SystemBane.cs @@ -19,8 +19,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void SetDefaults() { - CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 42; Item.height = 36; Item.damage = 45; @@ -38,10 +36,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.shootSpeed = 16f; Item.shoot = ModContent.ProjectileType(); - - modItem.UsesCharge = true; - modItem.MaxCharge = 135f; - modItem.ChargePerUse = 0.085f; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < MaxDeployedProjectiles; diff --git a/Items/Weapons/DraedonsArsenal/Taser.cs b/Items/Weapons/DraedonsArsenal/Taser.cs deleted file mode 100644 index f736f38e1e..0000000000 --- a/Items/Weapons/DraedonsArsenal/Taser.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Projectiles.DraedonsArsenal; -using CalamityMod.Sounds; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class Taser : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public static readonly SoundStyle Fire = new("CalamityMod/Sounds/Item/TaserLaunch") { Volume = 0.6f }; - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 42; - Item.height = 24; - Item.DamageType = DamageClass.Ranged; - Item.damage = 20; - Item.knockBack = 0f; - Item.useTime = Item.useAnimation = 28; - Item.autoReuse = true; - Item.reuseDelay = 15; - - Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = Fire; - Item.noMelee = true; - - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 6f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.05f; - } - - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - - public override Vector2? HoldoutOffset() => new Vector2(5f, 0f); - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(7). - AddIngredient(5). - AddIngredient(4). - AddIngredient(7). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs index 1388f7623a..4abbc9858a 100644 --- a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs +++ b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs @@ -21,15 +21,12 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void SetDefaults() { - CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 78; Item.height = 28; Item.DamageType = DamageClass.Magic; - Item.damage = 1220; + Item.damage = 1200; Item.knockBack = 10f; - Item.useTime = 90; - Item.useAnimation = 90; + Item.useTime = Item.useAnimation = 90; Item.autoReuse = true; Item.mana = 60; @@ -38,14 +35,10 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.noMelee = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 5f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0.75f; } public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) diff --git a/Items/Weapons/DraedonsArsenal/TheAnomalysNanogun.cs b/Items/Weapons/DraedonsArsenal/TheAnomalysNanogun.cs index 475c24e69e..6f168ec2b7 100644 --- a/Items/Weapons/DraedonsArsenal/TheAnomalysNanogun.cs +++ b/Items/Weapons/DraedonsArsenal/TheAnomalysNanogun.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; -using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; @@ -29,7 +28,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 102; Item.height = 44; - Item.damage = 1675; + Item.damage = 1600; Item.knockBack = 4.5f; Item.useAnimation = Item.useTime = AnomalysNanogunHoldout.PlasmaFireTimer; Item.shootSpeed = 5f; @@ -40,13 +39,8 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.noMelee = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); modItem.donorItem = true; - - modItem.UsesCharge = true; - modItem.MaxCharge = 250f; - modItem.ChargePerUse = 0.3f; - modItem.ChargePerAltUse = 0.15f; } public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); diff --git a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs b/Items/Weapons/DraedonsArsenal/TrackingDisk.cs deleted file mode 100644 index 857568aad3..0000000000 --- a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Projectiles.DraedonsArsenal; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.DraedonsArsenal -{ - public class TrackingDisk : RogueWeapon, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; - public override void SetDefaults() - { - CalamityGlobalItem modItem = Item.Calamity(); - - Item.width = 58; - Item.height = 48; - Item.damage = 16; - Item.DamageType = RogueDamageClass.Instance; - Item.useTime = 40; - Item.useAnimation = 40; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTurn = false; - Item.knockBack = 3f; - - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - - Item.noMelee = true; - Item.noUseGraphic = true; - - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 8f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 50f; - modItem.ChargePerUse = 0.05f; - } - - 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, type, damage, knockback, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - - public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(5). - AddIngredient(7). - AddIngredient(4). - AddIngredient(7). - AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(1, out Func condition), condition). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/DraedonsArsenal/TrackingDisk.png b/Items/Weapons/DraedonsArsenal/TrackingDisk.png deleted file mode 100644 index f56766fafb..0000000000 Binary files a/Items/Weapons/DraedonsArsenal/TrackingDisk.png and /dev/null differ diff --git a/Items/Weapons/DraedonsArsenal/Vulcan.cs b/Items/Weapons/DraedonsArsenal/Vulcan.cs new file mode 100644 index 0000000000..2e3e82cc90 --- /dev/null +++ b/Items/Weapons/DraedonsArsenal/Vulcan.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.DraedonsArsenal +{ + [LegacyName("GaussPistol")] + public class Vulcan : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; + public override void SetDefaults() + { + Item.width = 28; + Item.height = 34; + Item.DamageType = DamageClass.Magic; + Item.mana = 9; + Item.damage = 40; + Item.knockBack = 11f; + Item.useAnimation = Item.useTime = 11; + Item.autoReuse = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.channel = true; + Item.noUseGraphic = true; + + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 14f; + } + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) => true; + public override void HoldItem(Player player) + { + if (Main.myPlayer == player.whoAmI) + player.Calamity().rightClickListener = true; + player.Calamity().mouseWorldListener = true; + } + 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/VulcanGlow").Value); + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + float gunType = 0; + if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0) + gunType = 5; + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, gunType); + + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(12). + AddIngredient(8). + AddRecipeGroup("AnyMythrilBar", 10). + AddIngredient(ItemID.SoulofMight, 20). + AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(2, out Func condition), condition). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/DraedonsArsenal/Vulcan.png b/Items/Weapons/DraedonsArsenal/Vulcan.png new file mode 100644 index 0000000000..975227e30f Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/Vulcan.png differ diff --git a/Items/Weapons/DraedonsArsenal/VulcanGlow.png b/Items/Weapons/DraedonsArsenal/VulcanGlow.png new file mode 100644 index 0000000000..8a4e160b58 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/VulcanGlow.png differ diff --git a/Items/Weapons/DraedonsArsenal/WavePounder.cs b/Items/Weapons/DraedonsArsenal/WavePounder.cs index cd2d2ec4c1..97cc9f80b3 100644 --- a/Items/Weapons/DraedonsArsenal/WavePounder.cs +++ b/Items/Weapons/DraedonsArsenal/WavePounder.cs @@ -18,8 +18,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal"; public override void SetDefaults() { - CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 26; Item.height = 44; Item.damage = 75; @@ -37,10 +35,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); - - modItem.UsesCharge = true; - modItem.MaxCharge = 190f; - modItem.ChargePerUse = 0.5f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -61,7 +55,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal AddIngredient(8). AddIngredient(ItemID.LunarBar, 4). AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(4, out Func condition), condition). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/AbyssShocker.cs b/Items/Weapons/Magic/AbyssShocker.cs index 5fca24ab40..bc02df607b 100644 --- a/Items/Weapons/Magic/AbyssShocker.cs +++ b/Items/Weapons/Magic/AbyssShocker.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/AbyssalTome.cs b/Items/Weapons/Magic/AbyssalTome.cs index 12edcf818c..52fa42b4d9 100644 --- a/Items/Weapons/Magic/AbyssalTome.cs +++ b/Items/Weapons/Magic/AbyssalTome.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs.SlimeGod; using CalamityMod.Projectiles.Magic; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/AcidGun.cs b/Items/Weapons/Magic/AcidGun.cs index 1332539641..002238f231 100644 --- a/Items/Weapons/Magic/AcidGun.cs +++ b/Items/Weapons/Magic/AcidGun.cs @@ -1,5 +1,5 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; @@ -63,8 +63,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void AddRecipes() { CreateRecipe(). - AddIngredient(35). - AddIngredient(10). + AddIngredient(15). + AddIngredient(12). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Magic/AetherfluxCannon.cs b/Items/Weapons/Magic/AetherfluxCannon.cs index 77be95907f..7223d35dbe 100644 --- a/Items/Weapons/Magic/AetherfluxCannon.cs +++ b/Items/Weapons/Magic/AetherfluxCannon.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 24f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } diff --git a/Items/Weapons/Magic/AethersWhisper.cs b/Items/Weapons/Magic/AethersWhisper.cs index ebb944edd7..e6b56a57c7 100644 --- a/Items/Weapons/Magic/AethersWhisper.cs +++ b/Items/Weapons/Magic/AethersWhisper.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -40,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Magic CreateRecipe(). AddIngredient(). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/AlphaDraconis.cs b/Items/Weapons/Magic/AlphaDraconis.cs new file mode 100644 index 0000000000..ee0ed26f78 --- /dev/null +++ b/Items/Weapons/Magic/AlphaDraconis.cs @@ -0,0 +1,83 @@ +using System; +using System.Linq; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + [LegacyName("ClamorNoctus")] + public class AlphaDraconis : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Magic"; + public override void SetStaticDefaults() + { + Item.staff[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 52; + Item.height = 74; + Item.damage = 150; + Item.DamageType = DamageClass.Magic; + Item.mana = 12; + Item.useTime = 12; + Item.useAnimation = 12; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 5.2f; + Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + Item.rare = ModContent.RarityType(); + Item.UseSound = SoundID.Item105; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 8f; + } + + public override bool AltFunctionUse(Player player) + { + return player.Calamity().StratusStarburst >= 5 || player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; + } + public override void HoldItem(Player player) + { + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse == 2) + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + var p = Main.projectile.First(x => x.type == ModContent.ProjectileType() && x.active && x.owner == player.whoAmI); + p.timeLeft = (int)MathHelper.Min(p.timeLeft, 60); + } else + Projectile.NewProjectile(source, player.Center + new Vector2(-125,-100), -Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 4f), knockback, player.whoAmI); + return false; + } + var mousePos = player.Calamity().mouseWorld; + var dir = player.DirectionTo(mousePos); + for (var i = 0; i < 3; i++) + Projectile.NewProjectile(source, new Vector2(mousePos.X,player.Center.Y) + new Vector2(Main.rand.Next(500, 1300) * -player.direction, Main.rand.Next(-800,-600)), Vector2.UnitX * player.direction * velocity.Length(), type, damage, knockback, player.whoAmI, mousePos.X, mousePos.Y); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(6). + AddIngredient(5). + AddIngredient(10). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/Magic/ClamorNoctus.png b/Items/Weapons/Magic/AlphaDraconis.png similarity index 100% rename from Items/Weapons/Magic/ClamorNoctus.png rename to Items/Weapons/Magic/AlphaDraconis.png diff --git a/Items/Weapons/Magic/AlulaAustralis.cs b/Items/Weapons/Magic/AlulaAustralis.cs index 7211108bdf..2bf63f0bd7 100644 --- a/Items/Weapons/Magic/AlulaAustralis.cs +++ b/Items/Weapons/Magic/AlulaAustralis.cs @@ -1,5 +1,5 @@ -using CalamityMod.Projectiles.Magic; -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/AnahitasArpeggio.cs b/Items/Weapons/Magic/AnahitasArpeggio.cs index 49ef7576af..a64e4316dd 100644 --- a/Items/Weapons/Magic/AnahitasArpeggio.cs +++ b/Items/Weapons/Magic/AnahitasArpeggio.cs @@ -19,12 +19,11 @@ namespace CalamityMod.Items.Weapons.Magic public static readonly SoundStyle CapSound = new("CalamityMod/Sounds/Item/HarpLV6"); public static readonly SoundStyle EndSound = new("CalamityMod/Sounds/Item/HarpEnd"); public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/Item/HarpNoteHit"); - public override void SetDefaults() { Item.width = 56; Item.height = 50; - Item.damage = 77; + Item.damage = 60; Item.DamageType = DamageClass.Magic; Item.mana = 7; Item.useTime = 22; @@ -58,8 +57,8 @@ namespace CalamityMod.Items.Weapons.Magic if (nonReleasedMusicNotes >= musicNoteCap) { - Main.musicPitch = -0.5f; - SoundEngine.PlaySound(CapSound with { Volume = 0.8f }, player.Center); + if (!Main.zenithWorld) + SoundEngine.PlaySound(CapSound with { Volume = 0.8f }, player.Center); return false; } else diff --git a/Items/Weapons/Magic/Apathanull.cs b/Items/Weapons/Magic/Apathanull.cs index da4a586ebb..862e88b275 100644 --- a/Items/Weapons/Magic/Apathanull.cs +++ b/Items/Weapons/Magic/Apathanull.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 28; Item.height = 30; - Item.damage = 54; + Item.damage = 63; Item.DamageType = DamageClass.Magic; - Item.mana = 15; + Item.mana = 20; Item.useTime = 8; Item.useAnimation = 20; Item.reuseDelay = 8; diff --git a/Items/Weapons/Magic/ApoctosisArray.cs b/Items/Weapons/Magic/ApoctosisArray.cs index 079f04f32a..db3036dc29 100644 --- a/Items/Weapons/Magic/ApoctosisArray.cs +++ b/Items/Weapons/Magic/ApoctosisArray.cs @@ -15,9 +15,9 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 130; Item.height = 58; - Item.damage = 69; + Item.damage = 40; Item.DamageType = DamageClass.Magic; - Item.mana = 7; + Item.mana = 14; Item.useAnimation = 5; Item.useTime = 5; Item.useStyle = ItemUseStyleID.Shoot; @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(). - AddIngredient(ItemID.FragmentSolar, 6). + AddIngredient(ItemID.FragmentSolar, 12). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Magic/Apotheosis.cs b/Items/Weapons/Magic/Apotheosis.cs index 997c64fb18..278a72e01e 100644 --- a/Items/Weapons/Magic/Apotheosis.cs +++ b/Items/Weapons/Magic/Apotheosis.cs @@ -47,8 +47,8 @@ namespace CalamityMod.Items.Weapons.Magic CreateRecipe(). AddIngredient(ItemID.SpellTome). AddIngredient(). - AddIngredient(2). - AddIngredient(2). + AddIngredient(2). + AddIngredient(2). AddIngredient(5). AddIngredient(33). AddIngredient(11). diff --git a/Items/Weapons/Magic/ArchAmaryllis.cs b/Items/Weapons/Magic/ArchAmaryllis.cs index 33419882b8..654f269409 100644 --- a/Items/Weapons/Magic/ArchAmaryllis.cs +++ b/Items/Weapons/Magic/ArchAmaryllis.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Magic; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/ArcticBearPaw.cs b/Items/Weapons/Magic/ArcticBearPaw.cs index 467f1d0c4b..3e39e2804f 100644 --- a/Items/Weapons/Magic/ArcticBearPaw.cs +++ b/Items/Weapons/Magic/ArcticBearPaw.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Magic; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 28; Item.height = 24; - Item.damage = 90; + Item.damage = 80; Item.DamageType = DamageClass.Magic; Item.mana = 18; Item.useTime = 28; diff --git a/Items/Weapons/Magic/AsteroidStaff.cs b/Items/Weapons/Magic/AsteroidStaff.cs deleted file mode 100644 index 78a029f901..0000000000 --- a/Items/Weapons/Magic/AsteroidStaff.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Magic -{ - public class AsteroidStaff : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Magic"; - - #region GFB Projectile Array - public static int[] CorekeeperChaos = - { - ProjectileID.BallofFire, - ProjectileID.BallofFrost, - ProjectileID.MagicMissile, - ProjectileID.WaterStream, - ProjectileID.Flamelash, - ProjectileID.RainbowRodBullet, - ProjectileID.UnholyTridentFriendly, - ProjectileID.AmethystBolt, - ProjectileID.AmberBolt, - ProjectileID.TopazBolt, - ProjectileID.DiamondBolt, - ProjectileID.SapphireBolt, - ProjectileID.RubyBolt, - ProjectileID.EmeraldBolt, - ProjectileID.RainCloudMoving, - ProjectileID.BloodCloudMoving, - ProjectileID.ShadowBeamFriendly, - ProjectileID.InfernoFriendlyBlast, - ProjectileID.LostSoulFriendly, - ProjectileID.Bat, - - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - }; - #endregion - public override void SetStaticDefaults() - { - Item.staff[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 50; - Item.height = 50; - Item.damage = 146; - Item.DamageType = DamageClass.Magic; - Item.mana = 18; - Item.useTime = 10; - Item.useAnimation = 10; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 6.75f; - Item.UseSound = SoundID.Item88; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 20f; - - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (Main.zenithWorld) - { - for (int i = 0; i < 4; i++) - { - int projType; - projType = CorekeeperChaos[Main.rand.Next(CorekeeperChaos.Length)]; - float SpeedX = velocity.X + (float)Main.rand.Next(-60, 61) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-60, 61) * 0.05f; - int index = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, projType, damage, knockback, player.whoAmI); - - } - } - else - { - float meteorSpeed = Item.shootSpeed; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float meteorSpawnXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float meteorSpawnYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) - { - meteorSpawnYPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; - } - float meteorSpawnDist = (float)Math.Sqrt((double)(meteorSpawnXPos * meteorSpawnXPos + meteorSpawnYPos * meteorSpawnYPos)); - if ((float.IsNaN(meteorSpawnXPos) && float.IsNaN(meteorSpawnYPos)) || (meteorSpawnXPos == 0f && meteorSpawnYPos == 0f)) - for (int i = 0; i < 4; i++) - { - meteorSpawnXPos = (float)player.direction; - meteorSpawnYPos = 0f; - meteorSpawnDist = meteorSpeed; - } - else - { - meteorSpawnDist = meteorSpeed / meteorSpawnDist; - } - - int asteroidAmt = 3; - for (int i = 0; i < asteroidAmt; i++) - { - realPlayerPos = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - realPlayerPos.Y -= (float)(100 * i); - meteorSpawnXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; - meteorSpawnYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (meteorSpawnYPos < 0f) - { - meteorSpawnYPos *= -1f; - } - if (meteorSpawnYPos < 20f) - { - meteorSpawnYPos = 20f; - } - meteorSpawnDist = (float)Math.Sqrt((double)(meteorSpawnXPos * meteorSpawnXPos + meteorSpawnYPos * meteorSpawnYPos)); - meteorSpawnDist = meteorSpeed / meteorSpawnDist; - meteorSpawnXPos *= meteorSpawnDist; - meteorSpawnYPos *= meteorSpawnDist; - float meteorSpawnXOffset = meteorSpawnXPos; - float meteorSpawnYOffset = meteorSpawnYPos + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, meteorSpawnXOffset * 0.75f, meteorSpawnYOffset * 0.75f, type, damage, knockback, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); - } - } - return false; - } - - public override void ModifyTooltips(List list) => list.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.MeteorStaff). - AddIngredient(ItemID.LunarBar, 5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Magic/AsteroidStaff.png b/Items/Weapons/Magic/AsteroidStaff.png deleted file mode 100644 index 623294885e..0000000000 Binary files a/Items/Weapons/Magic/AsteroidStaff.png and /dev/null differ diff --git a/Items/Weapons/Magic/AstralachneaStaff.cs b/Items/Weapons/Magic/AstralachneaStaff.cs index 8ffa9448aa..a4338c8a20 100644 --- a/Items/Weapons/Magic/AstralachneaStaff.cs +++ b/Items/Weapons/Magic/AstralachneaStaff.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 52; Item.height = 52; - Item.damage = 50; + Item.damage = 55; Item.DamageType = DamageClass.Magic; Item.mana = 19; Item.useTime = 21; @@ -39,38 +38,18 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - int i = Main.myPlayer; - float fangSpeed = Item.shootSpeed; float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - int spikeAmount = 4; - if (Main.rand.NextBool(3)) - { - spikeAmount++; - } - if (Main.rand.NextBool(4)) - { - spikeAmount++; - } - if (Main.rand.NextBool(5)) - { - spikeAmount += 2; - } + + int spikeAmount = Main.rand.Next(3, 4+1); for (int j = 0; j < spikeAmount; j++) { - float fangSpawnX = mouseXDist; - float fangSpawnY = mouseYDist; - float offsetDampener = 0.05f * (float)j; - fangSpawnX += (float)Main.rand.Next(-400, 400) * offsetDampener; - fangSpawnY += (float)Main.rand.Next(-400, 400) * offsetDampener; - float fangDistance = (float)Math.Sqrt((double)(fangSpawnX * fangSpawnX + fangSpawnY * fangSpawnY)); - fangDistance = fangSpeed / fangDistance; - fangSpawnX *= fangDistance; - fangSpawnY *= fangDistance; - float x2 = realPlayerPos.X; - float y2 = realPlayerPos.Y; - Projectile.NewProjectile(source, x2, y2, fangSpawnX, fangSpawnY, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); + Vector2 fangSpawn = new Vector2(mouseXDist, mouseYDist); + fangSpawn.X += Main.rand.NextFloat(-20f, 20f) * j; + fangSpawn.Y += Main.rand.NextFloat(-20f, 20f) * j; + fangSpawn = fangSpawn.SafeNormalize(Vector2.UnitX) * Item.shootSpeed; + + Projectile.NewProjectile(source, realPlayerPos, fangSpawn, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/Atlantis.cs b/Items/Weapons/Magic/Atlantis.cs index ffa9afe85a..9aaf1df0bd 100644 --- a/Items/Weapons/Magic/Atlantis.cs +++ b/Items/Weapons/Magic/Atlantis.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -7,6 +6,7 @@ using CalamityMod.Particles; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Items.Weapons.Summon; namespace CalamityMod.Items.Weapons.Magic { @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 28; Item.height = 30; - Item.damage = 88; + Item.damage = 81; Item.DamageType = DamageClass.Magic; Item.mana = 12; Item.useTime = 25; @@ -38,16 +38,6 @@ namespace CalamityMod.Items.Weapons.Magic Item.shootSpeed = 40f; } - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) - { - if (Main.zenithWorld) - { - bool devourer = DownedBossSystem.downedDoG; - float damageMult = 1f + (devourer ? (348f / 86f - 1f) : 0f); - damage *= damageMult; - } - } - public override float UseSpeedMultiplier(Player player) => (DownedBossSystem.downedDoG && Main.zenithWorld) ? 2.5f : 1f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int points = 6; @@ -60,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Magic GeneralParticleHandler.SpawnParticle(spark); for (int b = 0; b < 3; b++) { - Dust dust = Dust.NewDustPerfect(position + velocity * 2.5f, 278, (velocity2 * 10).RotatedByRandom(0.5) * Main.rand.NextFloat(0.5f, 0.9f)); + Dust dust = Dust.NewDustPerfect(position + velocity * 2.5f, DustID.FireworksRGB, (velocity2 * 10).RotatedByRandom(0.5) * Main.rand.NextFloat(0.5f, 0.9f)); dust.scale = Main.rand.NextFloat(0.3f, 0.5f); dust.color = Main.rand.NextBool() ? Color.Cyan : Color.LightBlue; dust.noGravity = true; @@ -74,16 +64,5 @@ namespace CalamityMod.Items.Weapons.Magic Projectile.NewProjectile(source, position + velocity * 2, velocity, type, damage, knockback, player.whoAmI, 0f, 0f, 5f); return false; } - - public override void ModifyTooltips(List list) - { - bool devourer = DownedBossSystem.downedDoG; - string line = this.GetLocalizedValue("TooltipNormal"); - if (Main.zenithWorld && devourer) - line = this.GetLocalizedValue("TooltipGFBDoG"); - else if (Main.zenithWorld) - line = this.GetLocalizedValue("TooltipGFB"); - list.FindAndReplace("[GFB]", line); - } } } diff --git a/Items/Weapons/Magic/BloodBath.cs b/Items/Weapons/Magic/BloodBath.cs index 5bdcb4e06f..53bf0748d8 100644 --- a/Items/Weapons/Magic/BloodBath.cs +++ b/Items/Weapons/Magic/BloodBath.cs @@ -1,5 +1,5 @@ using System; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; @@ -90,15 +90,5 @@ namespace CalamityMod.Items.Weapons.Magic } return false; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 3). - AddIngredient(9). - AddIngredient(ItemID.Vertebrae, 3). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Magic/ChronomancersScythe.cs b/Items/Weapons/Magic/ChronomancersScythe.cs index 2902fe0d98..7785365ef0 100644 --- a/Items/Weapons/Magic/ChronomancersScythe.cs +++ b/Items/Weapons/Magic/ChronomancersScythe.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.FastClock). AddIngredient(ItemID.LunarBar, 10). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/ClamorNoctus.cs b/Items/Weapons/Magic/ClamorNoctus.cs deleted file mode 100644 index a54e500163..0000000000 --- a/Items/Weapons/Magic/ClamorNoctus.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Magic -{ - public class ClamorNoctus : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Magic"; - public override void SetStaticDefaults() - { - Item.staff[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 52; - Item.height = 74; - Item.damage = 270; - Item.DamageType = DamageClass.Magic; - Item.mana = 12; - Item.useTime = 21; - Item.useAnimation = 21; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 5.2f; - Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item105; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 25f; - } - - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - float projSpeed = Item.shootSpeed; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - mouseDistance = projSpeed; - } - else - { - mouseDistance = projSpeed / mouseDistance; - } - - int projAmt = 3; - for (int i = 0; i < projAmt; i++) - { - float damageMult = 1f; - float kbMult = 1f; - if (Main.rand.NextBool(10)) - { - type = ModContent.ProjectileType(); - } - if (type == ModContent.ProjectileType()) - { - damageMult = 25f; - kbMult = 1.5f; - } - realPlayerPos = new Vector2(player.Center.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.Center.X), player.MountedCenter.Y - 600f); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - realPlayerPos.Y -= (float)(100 * i); - mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - mouseDistance = projSpeed / mouseDistance; - mouseXDist *= mouseDistance; - mouseYDist *= mouseDistance; - float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); - } - return false; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(6). - AddIngredient(5). - AddIngredient(10). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Magic/DarkSpark.cs b/Items/Weapons/Magic/DarkSpark.cs index bfb28a081d..ed3956944a 100644 --- a/Items/Weapons/Magic/DarkSpark.cs +++ b/Items/Weapons/Magic/DarkSpark.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(10). AddIngredient(20). AddIngredient(30). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/DeathValleyDuster.cs b/Items/Weapons/Magic/DeathValleyDuster.cs index f78e124280..78a54eeab3 100644 --- a/Items/Weapons/Magic/DeathValleyDuster.cs +++ b/Items/Weapons/Magic/DeathValleyDuster.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 36; Item.height = 40; - Item.damage = 143; + Item.damage = 130; Item.DamageType = DamageClass.Magic; Item.mana = 38; Item.useTime = 50; @@ -33,6 +33,8 @@ namespace CalamityMod.Items.Weapons.Magic } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + if (player.velocity.Length() <= 12) + player.velocity += -velocity.SafeNormalize(Vector2.UnitX) * 5f; bool MaxMana = player.statMana >= (player.statManaMax2 - ((int)(Item.mana * player.manaCost))) && !player.HasBuff(BuffID.ManaSickness); Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 0f, MaxMana ? 1f : 0f); diff --git a/Items/Weapons/Magic/DeathhailStaff.cs b/Items/Weapons/Magic/DeathhailStaff.cs deleted file mode 100644 index 36dd27dd3b..0000000000 --- a/Items/Weapons/Magic/DeathhailStaff.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Magic -{ - public class DeathhailStaff : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Magic"; - public override void SetStaticDefaults() - { - Item.staff[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 80; - Item.height = 84; - Item.damage = 328; - Item.DamageType = DamageClass.Magic; - Item.mana = 16; - Item.useTime = 11; - Item.useAnimation = 22; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 4f; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item12; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 18f; - } - - 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/DeathhailStaffGlow").Value); - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - int i = Main.myPlayer; - float beamSpeed = Item.shootSpeed; - float beamKnockback = knockback; - beamKnockback = player.GetWeaponKnockback(Item, beamKnockback); - player.itemTime = Item.useTime; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - mouseDistance = beamSpeed; - } - else - { - mouseDistance = beamSpeed / mouseDistance; - } - - int numLasers = 2; - for (int j = 0; j < numLasers; j++) - { - realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(91) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - realPlayerPos.Y -= (float)(100 * j); - mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - mouseDistance = beamSpeed / mouseDistance; - mouseXDist *= mouseDistance; - mouseYDist *= mouseDistance; - float speedX4 = mouseXDist + (float)Main.rand.Next(-50, 51) * 0.02f; - float speedY5 = mouseYDist + (float)Main.rand.Next(-50, 51) * 0.02f; - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, beamKnockback, i, 0f, 0f); - } - return false; - } - } -} diff --git a/Items/Weapons/Magic/DivineRetribution.cs b/Items/Weapons/Magic/DivineRetribution.cs deleted file mode 100644 index 91f0211d95..0000000000 --- a/Items/Weapons/Magic/DivineRetribution.cs +++ /dev/null @@ -1,68 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Magic -{ - public class DivineRetribution : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Magic"; - public override void SetStaticDefaults() - { - Item.staff[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 66; - Item.height = 88; - Item.damage = 48; - Item.DamageType = DamageClass.Magic; - Item.mana = 15; - Item.useTime = 12; - Item.useAnimation = 12; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 3.5f; - - Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.rare = ModContent.RarityType(); - Item.Calamity().donorItem = true; - - Item.UseSound = SoundID.Item73; - Item.autoReuse = true; - Item.shootSpeed = 25f; - Item.shoot = ModContent.ProjectileType(); - } - - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - // 5 projectiles total - Vector2 mouse = player.ClampedMouseWorld(); - for (int i = -2; i < 3; i++) - { - Vector2 newPos = new Vector2(mouse.X + Main.rand.NextFloat(8f, 64f) * i, player.MountedCenter.Y + Main.rand.NextFloat(640f, 800f)); - Vector2 newVel = (mouse + Main.rand.NextVector2CircularEdge(4f, 4f) - newPos).SafeNormalize(Vector2.Zero) * velocity.Length() * Main.rand.NextFloat(1f, 1.25f); - float velScale = 1f + Main.rand.NextFloat(0.02f, 0.08f) * i; - Projectile.NewProjectile(source, newPos, newVel, type, damage, knockback, player.whoAmI, velScale); - } - return false; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(8). - AddIngredient(10). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Magic/DivineRetribution.png b/Items/Weapons/Magic/DivineRetribution.png deleted file mode 100644 index 4a5c496127..0000000000 Binary files a/Items/Weapons/Magic/DivineRetribution.png and /dev/null differ diff --git a/Items/Weapons/Magic/Downpour.cs b/Items/Weapons/Magic/Downpour.cs index 0bede5d021..2590ac3d1e 100644 --- a/Items/Weapons/Magic/Downpour.cs +++ b/Items/Weapons/Magic/Downpour.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/Effervescence.cs b/Items/Weapons/Magic/Effervescence.cs index 971a031c93..2856620fe7 100644 --- a/Items/Weapons/Magic/Effervescence.cs +++ b/Items/Weapons/Magic/Effervescence.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables; -using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -11,6 +11,10 @@ namespace CalamityMod.Items.Weapons.Magic public class Effervescence : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; + public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/EffervescenceFire") { PitchVariance = 0.1f }; + public static readonly SoundStyle BurstSound = new("CalamityMod/Sounds/Item/EffervescenceBurst") { PitchVariance = 0.1f }; + public static readonly SoundStyle PopSound = new("CalamityMod/Sounds/Item/EffervescencePop") { PitchVariance = 0.1f }; + public override void SetDefaults() { Item.width = 56; @@ -25,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.knockBack = 3.75f; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; - Item.UseSound = SoundID.Item95; + Item.UseSound = FireSound; Item.autoReuse = true; Item.shootSpeed = 13f; Item.shoot = ModContent.ProjectileType(); @@ -37,9 +41,8 @@ namespace CalamityMod.Items.Weapons.Magic { for (int randomBullets = 0; randomBullets < 4; randomBullets++) { - float SpeedX = velocity.X + Main.rand.Next(-25, 26) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-25, 26) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.85f, 1.2f); + Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI); } return false; } @@ -50,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.BubbleGun). AddIngredient(ItemID.LunarBar, 5). AddIngredient(ItemID.ShimmerBlock, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/EidolicWail.cs b/Items/Weapons/Magic/EidolicWail.cs index 411bae5c95..6eb2576e61 100644 --- a/Items/Weapons/Magic/EidolicWail.cs +++ b/Items/Weapons/Magic/EidolicWail.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/EldritchTome.cs b/Items/Weapons/Magic/EldritchTome.cs index 3021f53ee0..e231ed2ab4 100644 --- a/Items/Weapons/Magic/EldritchTome.cs +++ b/Items/Weapons/Magic/EldritchTome.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Magic/EvergladeSpray.cs b/Items/Weapons/Magic/EvergladeSpray.cs index d073842bf8..6bbe8845ab 100644 --- a/Items/Weapons/Magic/EvergladeSpray.cs +++ b/Items/Weapons/Magic/EvergladeSpray.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,14 +12,14 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 34; Item.height = 30; - Item.damage = 28; + Item.damage = 65; Item.DamageType = DamageClass.Magic; - Item.mana = 8; + Item.mana = 7; Item.useTime = 6; Item.useAnimation = 18; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 4.5f; + Item.knockBack = 2f; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; Item.UseSound = SoundID.Item13; diff --git a/Items/Weapons/Magic/Fabstaff.cs b/Items/Weapons/Magic/Fabstaff.cs deleted file mode 100644 index 0875c6bebd..0000000000 --- a/Items/Weapons/Magic/Fabstaff.cs +++ /dev/null @@ -1,53 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Magic -{ - public class Fabstaff : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Magic"; - public override void SetStaticDefaults() - { - Item.staff[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 84; - Item.height = 84; - Item.damage = 135; - Item.DamageType = DamageClass.Magic; - Item.mana = 40; - Item.useAnimation = Item.useTime = 20; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 5f; - - Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; - Item.rare = ModContent.RarityType(); - Item.Calamity().devItem = true; - - Item.UseSound = SoundID.Item60; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 13.5f; - } - - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.RainbowRod). - AddIngredient(5). - AddIngredient(10). - AddTile(). - Register(); - } - } -} diff --git a/Items/Weapons/Magic/Fabstaff.png b/Items/Weapons/Magic/Fabstaff.png deleted file mode 100644 index 6658464065..0000000000 Binary files a/Items/Weapons/Magic/Fabstaff.png and /dev/null differ diff --git a/Items/Weapons/Magic/FaceMelter.cs b/Items/Weapons/Magic/FaceMelter.cs index 1148903310..bff3fc20e7 100644 --- a/Items/Weapons/Magic/FaceMelter.cs +++ b/Items/Weapons/Magic/FaceMelter.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 56; Item.height = 50; - Item.damage = 165; + Item.damage = 130; Item.DamageType = DamageClass.Magic; Item.mana = 10; Item.useTime = 5; @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Magic/FlareBolt.cs b/Items/Weapons/Magic/FlareBolt.cs index 3168b9b7ef..2dfac6fc97 100644 --- a/Items/Weapons/Magic/FlareBolt.cs +++ b/Items/Weapons/Magic/FlareBolt.cs @@ -57,9 +57,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.HellstoneBar, 6). - AddIngredient(ItemID.Obsidian, 9). - AddIngredient(ItemID.Fireblossom, 2). + AddIngredient(ItemID.HellstoneBar, 10). + AddIngredient(ItemID.Fireblossom, 5). AddIngredient(ItemID.Ruby). AddTile(TileID.Bookcases). Register(); diff --git a/Items/Weapons/Magic/ForbiddenSun.cs b/Items/Weapons/Magic/ForbiddenSun.cs index ff631c0944..7bdd5e22e0 100644 --- a/Items/Weapons/Magic/ForbiddenSun.cs +++ b/Items/Weapons/Magic/ForbiddenSun.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/FrigidflashBolt.cs b/Items/Weapons/Magic/FrigidflashBolt.cs index 5320497da6..13423363d4 100644 --- a/Items/Weapons/Magic/FrigidflashBolt.cs +++ b/Items/Weapons/Magic/FrigidflashBolt.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -26,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 38; Item.height = 42; - Item.damage = 72; + Item.damage = 79; Item.DamageType = DamageClass.Magic; Item.mana = 13; Item.useTime = 20; diff --git a/Items/Weapons/Magic/FrostBolt.cs b/Items/Weapons/Magic/FrostBolt.cs index 4b90f09c01..ee5d0a68df 100644 --- a/Items/Weapons/Magic/FrostBolt.cs +++ b/Items/Weapons/Magic/FrostBolt.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Weapons/Magic/Genesis.cs b/Items/Weapons/Magic/Genesis.cs index 20af5325b0..85f3e019ea 100644 --- a/Items/Weapons/Magic/Genesis.cs +++ b/Items/Weapons/Magic/Genesis.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.LaserRifle). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/GhastlyVisage.cs b/Items/Weapons/Magic/GhastlyVisage.cs index 086b54ccde..1e24726a97 100644 --- a/Items/Weapons/Magic/GhastlyVisage.cs +++ b/Items/Weapons/Magic/GhastlyVisage.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -12,6 +13,7 @@ namespace CalamityMod.Items.Weapons.Magic public class GhastlyVisage : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; + public override void SetDefaults() { Item.width = 32; diff --git a/Items/Weapons/Magic/GleamingMagnolia.cs b/Items/Weapons/Magic/GleamingMagnolia.cs index 8cc2defd86..f3806aa889 100644 --- a/Items/Weapons/Magic/GleamingMagnolia.cs +++ b/Items/Weapons/Magic/GleamingMagnolia.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Magic; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/GloriousEnd.cs b/Items/Weapons/Magic/GloriousEnd.cs index 61de44955a..fa31df187f 100644 --- a/Items/Weapons/Magic/GloriousEnd.cs +++ b/Items/Weapons/Magic/GloriousEnd.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,13 +9,13 @@ namespace CalamityMod.Items.Weapons.Magic public class GloriousEnd : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; - public static int PlayerExplosionDmgMin = 50; - public static int PlayerExplosionDmgMax = 60; + public static int PlayerExplosionDmgMin = 60; + public static int PlayerExplosionDmgMax = 80; public override void SetDefaults() { Item.width = 30; Item.height = 58; - Item.damage = 120; + Item.damage = 100; Item.knockBack = 10f; Item.useAnimation = Item.useTime = 30; Item.mana = 20; @@ -30,6 +31,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.Calamity().donorItem = true; } + public override bool? CanAutoReuseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; diff --git a/Items/Weapons/Magic/GruesomeEminence.cs b/Items/Weapons/Magic/GruesomeEminence.cs index e4a64b95a0..2e56c3fd15 100644 --- a/Items/Weapons/Magic/GruesomeEminence.cs +++ b/Items/Weapons/Magic/GruesomeEminence.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.shoot = ModContent.ProjectileType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void SetStaticDefaults() diff --git a/Items/Weapons/Magic/HadalUrn.cs b/Items/Weapons/Magic/HadalUrn.cs index 1a30b38322..22c98c5b65 100644 --- a/Items/Weapons/Magic/HadalUrn.cs +++ b/Items/Weapons/Magic/HadalUrn.cs @@ -21,8 +21,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.damage = 37; Item.DamageType = DamageClass.Magic; Item.mana = 10; - Item.useTime = 16; - Item.useAnimation = 16; + Item.useTime = Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2.75f; diff --git a/Items/Weapons/Magic/HeliumFlash.cs b/Items/Weapons/Magic/HeliumFlash.cs index 4344a34749..2d293f49c8 100644 --- a/Items/Weapons/Magic/HeliumFlash.cs +++ b/Items/Weapons/Magic/HeliumFlash.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.useStyle = ItemUseStyleID.Shoot; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; diff --git a/Items/Weapons/Magic/HellwingStaff.cs b/Items/Weapons/Magic/HellwingStaff.cs index 4e98d6301c..964464d8d0 100644 --- a/Items/Weapons/Magic/HellwingStaff.cs +++ b/Items/Weapons/Magic/HellwingStaff.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 70; Item.height = 60; - Item.damage = 22; + Item.damage = 21; Item.DamageType = DamageClass.Magic; Item.mana = 18; Item.useTime = 30; @@ -39,48 +39,18 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float projSpeed = velocity.Length(); - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X; - float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - mouseDistance = projSpeed; - } - else - { - mouseDistance = projSpeed / mouseDistance; - } - for (int i = 0; i < 4; i++) { - realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - realPlayerPos.Y -= (float)(100 * i); - mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - mouseDistance = projSpeed / mouseDistance; - mouseXDist *= mouseDistance; - mouseYDist *= mouseDistance; - float speedX4 = mouseXDist + (float)Main.rand.Next(-40, 41) * 0.02f; - float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); + Vector2 realPlayerPos = new Vector2((player.MountedCenter.X + Main.mouseX + Main.screenPosition.X - player.position.X + player.Center.X) / 2f, player.MountedCenter.Y - (100f * i)); + + Vector2 mouseDist = new Vector2(Main.mouseX + Main.screenPosition.X - realPlayerPos.X, Math.Abs(Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y)); + if (mouseDist.Y < 20f) + mouseDist.Y = 20f; + mouseDist = mouseDist.SafeNormalize(Vector2.UnitX) * velocity.Length(); + mouseDist.X += Main.rand.NextFloat(-0.4f, 0.4f); + mouseDist.Y += Main.rand.NextFloat(-0.4f, 0.4f); + + Projectile.NewProjectile(source, realPlayerPos, mouseDist, type, damage, knockback, player.whoAmI); } return false; } @@ -89,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(ItemID.HellstoneBar, 10). - AddIngredient(ItemID.AshWood, 7). + AddIngredient(ItemID.AshWood, 10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Magic/Hematemesis.cs b/Items/Weapons/Magic/Hematemesis.cs index 5ccbd20082..daf9021e23 100644 --- a/Items/Weapons/Magic/Hematemesis.cs +++ b/Items/Weapons/Magic/Hematemesis.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Magic/Heresy.cs b/Items/Weapons/Magic/Heresy.cs index 2349832e9d..5b215872ec 100644 --- a/Items/Weapons/Magic/Heresy.cs +++ b/Items/Weapons/Magic/Heresy.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.noUseGraphic = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; diff --git a/Items/Weapons/Magic/HyperdeathRiftScepter.cs b/Items/Weapons/Magic/HyperdeathRiftScepter.cs new file mode 100644 index 0000000000..384dabfa6c --- /dev/null +++ b/Items/Weapons/Magic/HyperdeathRiftScepter.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + [LegacyName("DeathhailStaff")] + public class HyperdeathRiftScepter : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Magic"; + + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplaceAll("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); + } + public override void SetStaticDefaults() + { + Item.staff[Type] = true; + } + public override void SetDefaults() + { + Item.width = 80; + Item.height = 84; + Item.damage = 4300; + Item.DamageType = DamageClass.Magic; + Item.mana = 50; + Item.useTime = Item.useAnimation = 50; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 4f; + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + Item.UseSound = SoundID.Item12 with {Volume = 0.75f}; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 18f; + } + + 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/HyperdeathRiftScepterGlow").Value); + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectile(source, player.Calamity().mouseWorld, Vector2.Zero, type, damage, knockback, player.whoAmI,1); + return false; + } + } +} diff --git a/Items/Weapons/Magic/DeathhailStaff.png b/Items/Weapons/Magic/HyperdeathRiftScepter.png similarity index 100% rename from Items/Weapons/Magic/DeathhailStaff.png rename to Items/Weapons/Magic/HyperdeathRiftScepter.png diff --git a/Items/Weapons/Magic/DeathhailStaffGlow.png b/Items/Weapons/Magic/HyperdeathRiftScepterGlow.png similarity index 100% rename from Items/Weapons/Magic/DeathhailStaffGlow.png rename to Items/Weapons/Magic/HyperdeathRiftScepterGlow.png diff --git a/Items/Weapons/Magic/HyphaeRod.cs b/Items/Weapons/Magic/HyphaeRod.cs index dc7b12a637..1a4654ad88 100644 --- a/Items/Weapons/Magic/HyphaeRod.cs +++ b/Items/Weapons/Magic/HyphaeRod.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; diff --git a/Items/Weapons/Magic/IceBarrage.cs b/Items/Weapons/Magic/IceBarrage.cs index 90f046f193..6b23620bef 100644 --- a/Items/Weapons/Magic/IceBarrage.cs +++ b/Items/Weapons/Magic/IceBarrage.cs @@ -28,10 +28,10 @@ namespace CalamityMod.Items.Weapons.Magic Item.UseSound = CastSound; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; - Item.damage = 2300; + Item.damage = 2250; Item.knockBack = 6f; Item.useAnimation = Item.useTime = 300; Item.reuseDelay = 60; diff --git a/Items/Weapons/Magic/IonBlaster.cs b/Items/Weapons/Magic/IonBlaster.cs index 00ed3a7ef7..8126a4a72f 100644 --- a/Items/Weapons/Magic/IonBlaster.cs +++ b/Items/Weapons/Magic/IonBlaster.cs @@ -19,9 +19,9 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 68; Item.height = 38; - Item.damage = 42; + Item.damage = 24; Item.DamageType = DamageClass.Magic; - Item.mana = 8; + Item.mana = 12; Item.useAnimation = 7; Item.useTime = 7; Item.useStyle = ItemUseStyleID.Shoot; @@ -61,8 +61,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void AddRecipes() { CreateRecipe(). - AddRecipeGroup("AnyAdamantiteBar", 7). - AddIngredient(ItemID.SoulofFright, 10). + AddRecipeGroup("AnyAdamantiteBar", 10). + AddIngredient(ItemID.SoulofLight, 5). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Magic/Keelhaul.cs b/Items/Weapons/Magic/Keelhaul.cs index 5929c99224..770e8029e4 100644 --- a/Items/Weapons/Magic/Keelhaul.cs +++ b/Items/Weapons/Magic/Keelhaul.cs @@ -12,11 +12,10 @@ namespace CalamityMod.Items.Weapons.Magic Item.width = 42; Item.height = 42; Item.damage = 55; - Item.mana = 50; + Item.mana = 40; Item.DamageType = DamageClass.Magic; Item.noMelee = true; - Item.useTime = 30; - Item.useAnimation = 30; + Item.useTime = Item.useAnimation = 30; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 2f; diff --git a/Items/Weapons/Magic/LashesofChaos.cs b/Items/Weapons/Magic/LashesofChaos.cs index e993083d8c..7da3eaaf27 100644 --- a/Items/Weapons/Magic/LashesofChaos.cs +++ b/Items/Weapons/Magic/LashesofChaos.cs @@ -1,4 +1,5 @@ using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.Particles; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; @@ -16,7 +17,6 @@ namespace CalamityMod.Items.Weapons.Magic public int FiringMode = 0; // 0 = hellfireballs, 1 = hellblasts public int ProjectilesFired = 0; - public override void SetDefaults() { Item.width = 28; diff --git a/Items/Weapons/Magic/LightGodsBrilliance.cs b/Items/Weapons/Magic/LightGodsBrilliance.cs index d43e562b13..46c1df127f 100644 --- a/Items/Weapons/Magic/LightGodsBrilliance.cs +++ b/Items/Weapons/Magic/LightGodsBrilliance.cs @@ -19,12 +19,12 @@ namespace CalamityMod.Items.Weapons.Magic Item.damage = 111; Item.DamageType = DamageClass.Magic; Item.mana = 6; - Item.useAnimation = Item.useTime = 4; + Item.useAnimation = Item.useTime = 6; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.UseSound = SoundID.Item9; Item.autoReuse = true; diff --git a/Items/Weapons/Magic/MagneticMeltdown.cs b/Items/Weapons/Magic/MagneticMeltdown.cs index 0e5266cef6..c3a329728b 100644 --- a/Items/Weapons/Magic/MagneticMeltdown.cs +++ b/Items/Weapons/Magic/MagneticMeltdown.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Magic CreateRecipe(). AddIngredient(ItemID.MagnetSphere). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/ManaRose.cs b/Items/Weapons/Magic/ManaRose.cs index be441ecf19..79a5e5bdbf 100644 --- a/Items/Weapons/Magic/ManaRose.cs +++ b/Items/Weapons/Magic/ManaRose.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Magic; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -26,8 +25,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.25f; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; Item.UseSound = SoundID.Item109; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Magic/Mistlestorm.cs b/Items/Weapons/Magic/Mistlestorm.cs index 17811fcf7d..426c3841ea 100644 --- a/Items/Weapons/Magic/Mistlestorm.cs +++ b/Items/Weapons/Magic/Mistlestorm.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.LeafBlower). AddIngredient(5). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/NanoPurge.cs b/Items/Weapons/Magic/NanoPurge.cs index c5cd65b095..d78bf8a75f 100644 --- a/Items/Weapons/Magic/NanoPurge.cs +++ b/Items/Weapons/Magic/NanoPurge.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.LaserMachinegun). AddIngredient(7). AddIngredient(ItemID.Nanites, 100). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/NebulousCataclysm.cs b/Items/Weapons/Magic/NebulousCataclysm.cs index ad891db07e..00b99ac405 100644 --- a/Items/Weapons/Magic/NebulousCataclysm.cs +++ b/Items/Weapons/Magic/NebulousCataclysm.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,11 +18,10 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 120; Item.height = 124; - Item.damage = 510; + Item.damage = 530; Item.DamageType = DamageClass.Magic; - Item.mana = 60; - Item.useTime = 30; - Item.useAnimation = 30; + Item.mana = 70; + Item.useTime = Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = null; Item.noMelee = true; @@ -29,16 +29,14 @@ namespace CalamityMod.Items.Weapons.Magic Item.channel = true; Item.knockBack = 6f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 3f; + Item.shootSpeed = 5f; } public override void OnConsumeMana(Player player, int manaConsumed) => player.statMana += manaConsumed; - public override bool CanUseItem(Player player) => 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, type, damage, knockback, player.whoAmI); @@ -52,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.NebulaBlaze). AddIngredient(8). AddIngredient(20). - AddTile(TileID.LunarCraftingStation). + AddTile(). Register(); } } diff --git a/Items/Weapons/Magic/NightsRay.cs b/Items/Weapons/Magic/NightsRay.cs index 27f2e1b514..7cdb460325 100644 --- a/Items/Weapons/Magic/NightsRay.cs +++ b/Items/Weapons/Magic/NightsRay.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/NuclearFury.cs b/Items/Weapons/Magic/NuclearFury.cs index 15ccc2aacb..8dddf82b8d 100644 --- a/Items/Weapons/Magic/NuclearFury.cs +++ b/Items/Weapons/Magic/NuclearFury.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Magic/Nucleosynthesis.cs b/Items/Weapons/Magic/Nucleosynthesis.cs index f00df0ee15..76e953984c 100644 --- a/Items/Weapons/Magic/Nucleosynthesis.cs +++ b/Items/Weapons/Magic/Nucleosynthesis.cs @@ -87,7 +87,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentNebula, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/Omicron.cs b/Items/Weapons/Magic/Omicron.cs index 5b920b4c1a..551aecb37b 100644 --- a/Items/Weapons/Magic/Omicron.cs +++ b/Items/Weapons/Magic/Omicron.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.DataStructures; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; @@ -24,9 +23,9 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 122; Item.height = 54; - Item.damage = 82; + Item.damage = 80; Item.DamageType = DamageClass.Magic; - Item.mana = 8; + Item.mana = 10; Item.useAnimation = Item.useTime = 4; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; @@ -38,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.channel = true; Item.noUseGraphic = true; Item.shoot = ModContent.ProjectileType(); - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 2; diff --git a/Items/Weapons/Magic/ParasiticSceptor.cs b/Items/Weapons/Magic/ParasiticSceptor.cs index 3713f53c6e..ecae376a81 100644 --- a/Items/Weapons/Magic/ParasiticSceptor.cs +++ b/Items/Weapons/Magic/ParasiticSceptor.cs @@ -1,5 +1,5 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; @@ -96,7 +96,7 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(15). - AddIngredient(18). + AddIngredient(12). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Magic/PhantasmalFury.cs b/Items/Weapons/Magic/PhantasmalFury.cs index a3d4564a54..3c3c0b7f3f 100644 --- a/Items/Weapons/Magic/PhantasmalFury.cs +++ b/Items/Weapons/Magic/PhantasmalFury.cs @@ -22,9 +22,9 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 62; Item.height = 60; - Item.damage = 188; + Item.damage = 190; Item.DamageType = DamageClass.Magic; - Item.mana = 60; + Item.mana = 80; Item.useTime = 3; Item.useAnimation = 45; Item.reuseDelay = 75; @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Magic } for (int i = 0; i < 2; i++) { - Dust chargefull = Dust.NewDustPerfect(position + velocity * 13, 267); + Dust chargefull = Dust.NewDustPerfect(position + velocity * 13, DustID.RainbowMk2); chargefull.velocity = velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(1f, 4); chargefull.scale = Main.rand.NextFloat(0.5f, 0.9f); chargefull.noGravity = true; @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.SpectreStaff). AddIngredient(2). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/PhoenixFlameBarrage.cs b/Items/Weapons/Magic/PhoenixFlameBarrage.cs index 1921f78eeb..1d915a0feb 100644 --- a/Items/Weapons/Magic/PhoenixFlameBarrage.cs +++ b/Items/Weapons/Magic/PhoenixFlameBarrage.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -30,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.noMelee = true; Item.knockBack = 3.5f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item20; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Magic/Photosynthesis.cs b/Items/Weapons/Magic/Photosynthesis.cs index dc4e32d222..47d1882e66 100644 --- a/Items/Weapons/Magic/Photosynthesis.cs +++ b/Items/Weapons/Magic/Photosynthesis.cs @@ -22,11 +22,10 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 78; Item.height = 78; - Item.damage = 60; + Item.damage = 74; Item.DamageType = DamageClass.Magic; Item.mana = 10; - Item.useTime = 24; - Item.useAnimation = 24; + Item.useTime = Item.useAnimation = 21; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4f; diff --git a/Items/Weapons/Magic/PhotosynthesisGlow.png b/Items/Weapons/Magic/PhotosynthesisGlow.png index dc3a8eeab5..ca021b33a5 100644 Binary files a/Items/Weapons/Magic/PhotosynthesisGlow.png and b/Items/Weapons/Magic/PhotosynthesisGlow.png differ diff --git a/Items/Weapons/Magic/PlagueStaff.cs b/Items/Weapons/Magic/PlagueStaff.cs index c9cd97def5..9b52981aab 100644 --- a/Items/Weapons/Magic/PlagueStaff.cs +++ b/Items/Weapons/Magic/PlagueStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Magic/PlasmaRifle.cs b/Items/Weapons/Magic/PlasmaRifle.cs index 4cf11901f2..f81e4afd4c 100644 --- a/Items/Weapons/Magic/PlasmaRifle.cs +++ b/Items/Weapons/Magic/PlasmaRifle.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Rarities; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -26,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 72; Item.height = 20; - Item.damage = 160; + Item.damage = 120; Item.DamageType = DamageClass.Magic; Item.mana = 40; Item.useAnimation = Item.useTime = 40; diff --git a/Items/Weapons/Magic/PlasmaRod.cs b/Items/Weapons/Magic/PlasmaRod.cs index 904896c5ae..9760a8dd39 100644 --- a/Items/Weapons/Magic/PlasmaRod.cs +++ b/Items/Weapons/Magic/PlasmaRod.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Magic; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -26,8 +25,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2.5f; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.Item109; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Magic/Poseidon.cs b/Items/Weapons/Magic/Poseidon.cs index 305b14499d..c1bb33dcf2 100644 --- a/Items/Weapons/Magic/Poseidon.cs +++ b/Items/Weapons/Magic/Poseidon.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Magic; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/PrimordialAncient.cs b/Items/Weapons/Magic/PrimordialAncient.cs index b587e34686..016e0e5e2a 100644 --- a/Items/Weapons/Magic/PrimordialAncient.cs +++ b/Items/Weapons/Magic/PrimordialAncient.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 40; Item.height = 56; - Item.damage = 2800; + Item.damage = 4350; Item.DamageType = DamageClass.Magic; - Item.mana = 85; + Item.mana = 95; Item.useTime = 78; Item.useAnimation = 78; Item.useStyle = ItemUseStyleID.Shoot; @@ -37,10 +37,13 @@ namespace CalamityMod.Items.Weapons.Magic Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + if (player.velocity.Length() <= 16) + player.velocity += -velocity.SafeNormalize(Vector2.UnitX) * 7f; + bool MaxMana = player.statMana >= (player.statManaMax2 - ((int)(Item.mana * player.manaCost))) && !player.HasBuff(BuffID.ManaSickness); for (int i = -2; i <= 2; i++) { diff --git a/Items/Weapons/Magic/PrimordialEarth.cs b/Items/Weapons/Magic/PrimordialEarth.cs index bfda7be735..f0f2663dd6 100644 --- a/Items/Weapons/Magic/PrimordialEarth.cs +++ b/Items/Weapons/Magic/PrimordialEarth.cs @@ -21,11 +21,10 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 36; Item.height = 42; - Item.damage = 210; + Item.damage = 205; Item.DamageType = DamageClass.Magic; Item.mana = 48; - Item.useTime = 68; - Item.useAnimation = 68; + Item.useTime = Item.useAnimation = 68; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 10; @@ -38,10 +37,14 @@ namespace CalamityMod.Items.Weapons.Magic } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + if (player.velocity.Length() <= 14) + player.velocity += -velocity.SafeNormalize(Vector2.UnitX) * 6f; + + Vector2 staticSpeed = Utils.DirectionTo(player.Center, player.Calamity().mouseWorld) * Utils.Distance(player.Center, player.ClampedMouseWorld()) * 0.008f; bool MaxMana = player.statMana >= (player.statManaMax2 - ((int)(Item.mana * player.manaCost))) && !player.HasBuff(BuffID.ManaSickness); float rotation = 0.4f; - Projectile.NewProjectile(source, position, velocity.RotatedBy(-rotation), type, damage / 2, knockback, player.whoAmI, 0f, 1f, MaxMana ? 1f : 0f); - Projectile.NewProjectile(source, position, velocity.RotatedBy(rotation), type, damage / 2, knockback, player.whoAmI, 0f, 0f, MaxMana ? 1f : 0f); + Projectile.NewProjectile(source, position, staticSpeed.RotatedBy(-rotation), type, damage / 2, knockback, player.whoAmI, 0f, 1f, MaxMana ? 1f : 0f); + Projectile.NewProjectile(source, position, staticSpeed.RotatedBy(rotation), type, damage / 2, knockback, player.whoAmI, 0f, 0f, MaxMana ? 1f : 0f); return false; } diff --git a/Items/Weapons/Magic/PurgeGuzzler.cs b/Items/Weapons/Magic/PurgeGuzzler.cs index b39487c4e9..e75ae3fdfe 100644 --- a/Items/Weapons/Magic/PurgeGuzzler.cs +++ b/Items/Weapons/Magic/PurgeGuzzler.cs @@ -1,6 +1,6 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -13,7 +13,6 @@ namespace CalamityMod.Items.Weapons.Magic { public new string LocalizationCategory => "Items.Weapons.Magic"; private const float Spread = 0.025f; - public override void SetDefaults() { Item.width = 64; diff --git a/Items/Weapons/Magic/RainbowPartyCannon.cs b/Items/Weapons/Magic/RainbowPartyCannon.cs index e496dd6214..49abe53755 100644 --- a/Items/Weapons/Magic/RainbowPartyCannon.cs +++ b/Items/Weapons/Magic/RainbowPartyCannon.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 52; Item.height = 30; - Item.damage = 175; + Item.damage = 170; Item.DamageType = DamageClass.Magic; Item.mana = 25; Item.crit += 4; diff --git a/Items/Weapons/Magic/Rancor.cs b/Items/Weapons/Magic/Rancor.cs index f69ac44ac2..c18625be66 100644 --- a/Items/Weapons/Magic/Rancor.cs +++ b/Items/Weapons/Magic/Rancor.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.shoot = ModContent.ProjectileType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void SetStaticDefaults() diff --git a/Items/Weapons/Magic/RecitationoftheBeast.cs b/Items/Weapons/Magic/RecitationoftheBeast.cs index 4b4cf8fedc..252fca4e1a 100644 --- a/Items/Weapons/Magic/RecitationoftheBeast.cs +++ b/Items/Weapons/Magic/RecitationoftheBeast.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using Microsoft.Xna.Framework; diff --git a/Items/Weapons/Magic/RougeSlash.cs b/Items/Weapons/Magic/RougeSlash.cs index e9975d1d74..a6d93c7a17 100644 --- a/Items/Weapons/Magic/RougeSlash.cs +++ b/Items/Weapons/Magic/RougeSlash.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 379715917a..a35ea032b6 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -20,8 +19,11 @@ namespace CalamityMod.Items.Weapons.Magic { public new string LocalizationCategory => "Items.Weapons.Magic"; public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/AnomalysNanogunMPFBShot"); + public static readonly SoundStyle VacuumStart = new SoundStyle("CalamityMod/Sounds/Item/SHPCVacuumStart") with { Volume = 0.75f }; + public static readonly SoundStyle VacuumLoop = new SoundStyle("CalamityMod/Sounds/Item/SHPCVacuumLoop") with { Volume = 0.75f }; + public static readonly SoundStyle VacuumEnd = new SoundStyle("CalamityMod/Sounds/Item/SHPCVacuumEnd") with { Volume = 0.75f }; - public const int ShotsPerSoul = 40; + public const int ShotsPerSoul = 50; public int storedSoulpower = 0; public int storedSoulType = ItemID.SoulofLight; // Determines bar color and soul effects for projectile public int recoilProgress = 0; @@ -29,8 +31,8 @@ namespace CalamityMod.Items.Weapons.Magic public const float LightExplosionSizeMult = 1.5f; public const float NightExplosionTimeMult = 2.5f; public const int FlightDirectHitFlightBoost = 25; // The amount of flight time restored on direct hits with Flight bombs, in frames - public const float MightKnockbackStrength = 8f; // The value to multiply the unit vector by when applying velocity to enemies launched by Might bombs - public const float SightHomingRange = 288f; // Range of homing for Sight bombs, in pixels + public const float MightKnockbackStrength = 20f; // The value to multiply the unit vector by when applying velocity to enemies launched by Might bombs + public const float SightHomingRange = 320f; // Range of homing for Sight bombs, in pixels public const int FrightFlatDamage = 20; public override Color? TooltipExtensionColor => new Color(31, 251, 255); @@ -41,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 124; Item.height = 52; - Item.damage = 94; + Item.damage = 97; Item.DamageType = DamageClass.Magic; Item.mana = 15; Item.useAnimation = Item.useTime = 60; @@ -58,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Magic } #region Weapon-Specific Functions - public int FindSoulForAmmo(Player player) + public static int FindSoulForAmmo(Player player) { int soul = -1; bool foundItem = false; @@ -111,7 +113,7 @@ namespace CalamityMod.Items.Weapons.Magic returnColor = new(79, 255, 124); break; case ItemID.SoulofFright: - returnColor = new(255, 128, 20); + returnColor = new(255, 96, 20); break; } return returnColor; @@ -146,7 +148,6 @@ namespace CalamityMod.Items.Weapons.Magic #endregion public override Vector2? HoldoutOffset() => new Vector2(-35, -10); - public override bool AltFunctionUse(Player player) => true; public override void OnCreated(ItemCreationContext context) @@ -157,40 +158,34 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) { - if (player.altFunctionUse == 2) - { - Item.useTime = 3; - Item.useAnimation = 3 * storedSoulpower; - Item.UseSound = null; - } - else - { - Item.useTime = Item.useAnimation = 60; - Item.UseSound = FireSound; - } - - return storedSoulpower > 0 || (FindSoulForAmmo(player) != -1 && player.altFunctionUse != 2); + Item.channel = Item.noUseGraphic = player.altFunctionUse == 2; + Item.UseSound = player.altFunctionUse == 2 ? null : FireSound; + return ((player.altFunctionUse == 0 && (storedSoulpower > 0 || (FindSoulForAmmo(player) != -1))) || player.altFunctionUse == 2) && + player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; } public override bool? UseItem(Player player) { - if (storedSoulpower > 0) - storedSoulpower--; - - if (storedSoulpower <= 0 && player.altFunctionUse != 2) + if (player.altFunctionUse != 2) { - bool ammoConsumed = false; + if (storedSoulpower > 0) + storedSoulpower--; - if (FindSoulForAmmo(player) != -1) + if (storedSoulpower <= 0) { - int soulType = FindSoulForAmmo(player); - player.ConsumeItem(soulType); - storedSoulType = soulType; - ammoConsumed = true; - } + bool ammoConsumed = false; - if (ammoConsumed) - storedSoulpower = ShotsPerSoul; + if (FindSoulForAmmo(player) != -1) + { + int soulType = FindSoulForAmmo(player); + player.ConsumeItem(soulType); + storedSoulType = soulType; + ammoConsumed = true; + } + + if (ammoConsumed) + storedSoulpower = ShotsPerSoul; + } } return base.UseItem(player); @@ -199,7 +194,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void ModifyManaCost(Player player, ref float reduce, ref float mult) { if (player.altFunctionUse == 2) - mult *= 0.3f; + mult *= 0f; } public override float UseSpeedMultiplier(Player player) @@ -214,12 +209,7 @@ namespace CalamityMod.Items.Weapons.Magic { if (player.altFunctionUse == 2) { - SoundEngine.PlaySound(CommonCalamitySounds.ELRFireSound, player.Center); - if (storedSoulpower % 2 == 0) - { - Vector2 Speed = new Vector2(velocity.X + Main.rand.NextFloat(-1f, 1f), velocity.Y + Main.rand.NextFloat(-1f, 1f)); - Projectile.NewProjectile(source, position + new Vector2(0, -10) + velocity * 2.6f, Speed, ModContent.ProjectileType(), (int)(damage * 0.25f), knockback * 0.5f, player.whoAmI, TransferColorToProj()); - } + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, 0f, player.whoAmI); return false; } else @@ -247,7 +237,11 @@ namespace CalamityMod.Items.Weapons.Magic } #region Recoil Stuff - public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + player.Calamity().rightClickListener = true; + } public override void UseStyle(Player player, Rectangle heldItemFrame) { player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); @@ -307,7 +301,13 @@ namespace CalamityMod.Items.Weapons.Magic damage *= damageMult; } } - public override void ModifyTooltips(List list) => list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal"))); + public override void ModifyTooltips(List list) + { + if (Main.zenithWorld) + list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalizedValue("TooltipGFB"))); + else + list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalization("TooltipNormal").Format(this.GetLocalizedValue(storedSoulpower == 0 ? "NoSoul" : "SoulDesc" + storedSoulType)))); + } public override void AddRecipes() { diff --git a/Items/Weapons/Magic/SandstreamScepter.cs b/Items/Weapons/Magic/SandstreamScepter.cs index 2478aed15c..f4cb2ed872 100644 --- a/Items/Weapons/Magic/SandstreamScepter.cs +++ b/Items/Weapons/Magic/SandstreamScepter.cs @@ -1,7 +1,7 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/SandstreamScepter.png b/Items/Weapons/Magic/SandstreamScepter.png index 64e58ebf01..c85eec12d1 100644 Binary files a/Items/Weapons/Magic/SandstreamScepter.png and b/Items/Weapons/Magic/SandstreamScepter.png differ diff --git a/Items/Weapons/Magic/SanguineFlare.cs b/Items/Weapons/Magic/SanguineFlare.cs index bc7827c338..90da4ae001 100644 --- a/Items/Weapons/Magic/SanguineFlare.cs +++ b/Items/Weapons/Magic/SanguineFlare.cs @@ -21,12 +21,13 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 56; Item.height = 60; - Item.damage = 143; + Item.damage = 1050; Item.DamageType = DamageClass.Magic; - Item.mana = 22; + Item.mana = 36; Item.useTime = 25; Item.useAnimation = 25; Item.useStyle = ItemUseStyleID.Shoot; + Item.channel = true; Item.noMelee = true; Item.knockBack = 8f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; @@ -39,11 +40,7 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int i = 0; i < 7; i++) - { - Vector2 spreadVelocity = velocity.RotatedByRandom(MathHelper.ToRadians(5f)) * Main.rand.NextFloat(0.8f, 1.2f); - Projectile.NewProjectile(source, position, spreadVelocity, type, damage, knockback, Main.myPlayer); - } + velocity *= 0; return true; // Fires one directly with no randomness, totaling 8 projectiles } @@ -51,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/SeethingDischarge.cs b/Items/Weapons/Magic/SeethingDischarge.cs index 63aeac78ab..45cd4e9c0e 100644 --- a/Items/Weapons/Magic/SeethingDischarge.cs +++ b/Items/Weapons/Magic/SeethingDischarge.cs @@ -1,6 +1,6 @@ -using CalamityMod.NPCs.BrimstoneElemental; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.BrimstoneElemental; using CalamityMod.Projectiles.Magic; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Magic/ShaderainStaff.cs b/Items/Weapons/Magic/ShaderainStaff.cs index cb4d8ccff9..8fc506cf8e 100644 --- a/Items/Weapons/Magic/ShaderainStaff.cs +++ b/Items/Weapons/Magic/ShaderainStaff.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; @@ -11,6 +11,7 @@ namespace CalamityMod.Items.Weapons.Magic public class ShaderainStaff : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; + #region Other stats // Stats for the shaderain. @@ -26,7 +27,6 @@ namespace CalamityMod.Items.Weapons.Magic public const float DeaccelerationStrenght = 0.95f; // A number lower than 1, non-including 1, changing it very slightly will have drastic results. #endregion - public override void SetStaticDefaults() { Item.staff[Type] = true; @@ -77,15 +77,5 @@ namespace CalamityMod.Items.Weapons.Magic return false; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.DemoniteBar, 3). - AddIngredient(9). - AddIngredient(ItemID.RottenChunk, 3). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Magic/ShadowboltStaff.cs b/Items/Weapons/Magic/ShadowboltStaff.cs index d438f5e097..f5639d3e79 100644 --- a/Items/Weapons/Magic/ShadowboltStaff.cs +++ b/Items/Weapons/Magic/ShadowboltStaff.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -20,16 +19,17 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 58; Item.height = 56; - Item.damage = 190; + Item.damage = 285; Item.DamageType = DamageClass.Magic; - Item.mana = 10; - Item.useTime = 12; - Item.useAnimation = 12; + Item.mana = 15; + Item.useTime = 8; + Item.useAnimation = 24; + Item.reuseDelay = 30; + Item.useLimitPerAnimation = 3; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.UseSound = SoundID.Item72; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 5f; @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.ShadowbeamStaff). AddIngredient(2). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/ShiftingSands.cs b/Items/Weapons/Magic/ShiftingSands.cs index ad97b003f3..71f95c4283 100644 --- a/Items/Weapons/Magic/ShiftingSands.cs +++ b/Items/Weapons/Magic/ShiftingSands.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { Item.width = Item.height = 58; - Item.damage = 76; + Item.damage = 81; Item.knockBack = 5f; Item.useAnimation = Item.useTime = 30; Item.mana = 20; @@ -29,15 +29,14 @@ namespace CalamityMod.Items.Weapons.Magic Item.rare = ItemRarityID.Lime; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanUseItem(Player player) => !player.channel; public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.MagicMissile). + AddIngredient(ItemID.AncientCloth, 5). AddIngredient(). - AddIngredient(ItemID.AncientBattleArmorMaterial, 2). - AddIngredient(ItemID.SpectreBar, 5). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Magic/SkyGlaze.cs b/Items/Weapons/Magic/SkyGlaze.cs index a9bc168915..cc5d6061da 100644 --- a/Items/Weapons/Magic/SkyGlaze.cs +++ b/Items/Weapons/Magic/SkyGlaze.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.Item102; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Magic/SnowstormStaff.cs b/Items/Weapons/Magic/SnowstormStaff.cs index 4d4c8e00f5..674b3ffb97 100644 --- a/Items/Weapons/Magic/SnowstormStaff.cs +++ b/Items/Weapons/Magic/SnowstormStaff.cs @@ -1,5 +1,5 @@ -using CalamityMod.Projectiles.Magic; -using Terraria; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Magic; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/SoulPiercer.cs b/Items/Weapons/Magic/SoulPiercer.cs index c7c48d362a..52b15901ca 100644 --- a/Items/Weapons/Magic/SoulPiercer.cs +++ b/Items/Weapons/Magic/SoulPiercer.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 64; Item.height = 64; - Item.damage = 310; + Item.damage = 235; Item.DamageType = DamageClass.Magic; Item.mana = 19; Item.useAnimation = Item.useTime = 25; @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 6f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Weapons/Magic/StarShower.cs b/Items/Weapons/Magic/StarShower.cs index f699464be8..ae8c5a91a7 100644 --- a/Items/Weapons/Magic/StarShower.cs +++ b/Items/Weapons/Magic/StarShower.cs @@ -1,6 +1,6 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -14,7 +14,6 @@ namespace CalamityMod.Items.Weapons.Magic public new string LocalizationCategory => "Items.Weapons.Magic"; internal const float ShootSpeed = 28f; - public override void SetDefaults() { Item.width = 38; diff --git a/Items/Weapons/Magic/SubsumingVortex.cs b/Items/Weapons/Magic/SubsumingVortex.cs index 84db87a52f..0f21e8bc20 100644 --- a/Items/Weapons/Magic/SubsumingVortex.cs +++ b/Items/Weapons/Magic/SubsumingVortex.cs @@ -7,7 +7,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -58,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.shoot = ModContent.ProjectileType(); Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = SoundID.Item84; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.noMelee = true; Item.channel = true; diff --git a/Items/Weapons/Magic/Sylvestaff.cs b/Items/Weapons/Magic/Sylvestaff.cs new file mode 100644 index 0000000000..ec5fdb3816 --- /dev/null +++ b/Items/Weapons/Magic/Sylvestaff.cs @@ -0,0 +1,121 @@ +using CalamityMod.Items.Materials; +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.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + [LegacyName("Fabstaff")] + public class Sylvestaff : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Magic"; + + /// + /// The amount by which the staff recoils after firing. + /// + public static float StaffRecoilForce => 0.04f; + + /// + /// The rate at which rays from the staff can release bolts. + /// + public static int RayBoltShootRate => CalamityUtils.SecondsToFrames(0.0667f); + + /// + /// The distance range that targets need to be within relative to a ray's evaluation points in order to shoot bolts. + /// + public static float RayBoltTargetingRange => 272f; + + /// + /// The turn speed interpolant that dictates how fast or slow the staff can move to aim towards the mouse. + /// + public static float TurnSpeedInterpolant => 0.276f; + + /// + /// The sound played when Sylvestaff rays are fired. + /// + public static readonly SoundStyle FireSound = new SoundStyle("CalamityMod/Sounds/Item/SylvestaffFire", 3) with { MaxInstances = 5 }; + + /// + /// The sound played when Sylvestaff rays bounce off of tiles. + /// + public static readonly SoundStyle BounceSound = new SoundStyle("CalamityMod/Sounds/Item/SylvestaffProjectileBounce", 3) with { MaxInstances = 5 }; + + public override string Texture + { + get + { + if (WorldGen.SavedOreTiers.Gold == TileID.Gold || Main.gameMenu) + return "CalamityMod/Items/Weapons/Magic/SylvestaffGold"; + + return "CalamityMod/Items/Weapons/Magic/SylvestaffPlatinum"; + } + } + + public override void SetStaticDefaults() + { + Item.staff[Item.type] = true; + } + + public override void SetDefaults() + { + Item.width = 84; + Item.height = 84; + Item.damage = 140; + Item.DamageType = DamageClass.Magic; + Item.mana = 30; + Item.useTime = 20; + Item.useAnimation = 20; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.channel = true; + Item.noUseGraphic = true; + Item.knockBack = 5f; + + Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; + Item.rare = ModContent.RarityType(); + Item.Calamity().devItem = true; + + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 13.5f; + } + + public override void ModifyManaCost(Player player, ref float reduce, ref float mult) + { + if (player.ownedProjectileCounts[Item.shoot] <= 0) + mult *= 0; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.RainbowRod). + AddIngredient(ItemID.GenderChangePotion). + AddRecipeGroup("AnyGoldBar", 5). + AddIngredient(10). + AddIngredient(5). + AddTile(). + Register(); + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture = ModContent.Request(Texture).Value; + spriteBatch.Draw(texture, position, frame, drawColor, 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 = ModContent.Request(Texture).Value; + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0); + return false; + } + } +} diff --git a/Items/Weapons/Magic/SylvestaffGold.png b/Items/Weapons/Magic/SylvestaffGold.png new file mode 100644 index 0000000000..2cd1d31e38 Binary files /dev/null and b/Items/Weapons/Magic/SylvestaffGold.png differ diff --git a/Items/Weapons/Magic/SylvestaffPlatinum.png b/Items/Weapons/Magic/SylvestaffPlatinum.png new file mode 100644 index 0000000000..c611c58ea1 Binary files /dev/null and b/Items/Weapons/Magic/SylvestaffPlatinum.png differ diff --git a/Items/Weapons/Magic/TacticiansTrumpCard.cs b/Items/Weapons/Magic/TacticiansTrumpCard.cs index 4e26e129e7..f6e98b2b9f 100644 --- a/Items/Weapons/Magic/TacticiansTrumpCard.cs +++ b/Items/Weapons/Magic/TacticiansTrumpCard.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(). AddIngredient(5). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); CreateRecipe(). AddIngredient(ItemID.TinShortsword). @@ -65,7 +65,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(). AddIngredient(5). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/TearsofHeaven.cs b/Items/Weapons/Magic/TearsofHeaven.cs index 6e31eef359..babeb02a00 100644 --- a/Items/Weapons/Magic/TearsofHeaven.cs +++ b/Items/Weapons/Magic/TearsofHeaven.cs @@ -18,11 +18,10 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 38; Item.height = 48; - Item.damage = 45; + Item.damage = 43; Item.DamageType = DamageClass.Magic; - Item.mana = 18; - Item.useTime = 20; - Item.useAnimation = 20; + Item.mana = 15; + Item.useTime = Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5.5f; @@ -38,9 +37,9 @@ namespace CalamityMod.Items.Weapons.Magic { for (int index = 0; index < 2; ++index) { - float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); + float SpeedX = velocity.X + Main.rand.NextFloat(-2f, 2f); + float SpeedY = velocity.Y + Main.rand.NextFloat(-2f, 2f); + Projectile.NewProjectile(source, position, new Vector2(SpeedX, SpeedY), type, damage, knockback, player.whoAmI); } return false; } diff --git a/Items/Weapons/Magic/Teslastaff.cs b/Items/Weapons/Magic/Teslastaff.cs index ac23efa9d6..ac1a2b30c9 100644 --- a/Items/Weapons/Magic/Teslastaff.cs +++ b/Items/Weapons/Magic/Teslastaff.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Magic AddRecipeGroup("AnyCopperBar", 20). AddIngredient(6). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/TheCauldron.cs b/Items/Weapons/Magic/TheCauldron.cs index d3b57adcb1..065b00b449 100644 --- a/Items/Weapons/Magic/TheCauldron.cs +++ b/Items/Weapons/Magic/TheCauldron.cs @@ -25,12 +25,11 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 46; Item.height = 46; - Item.damage = 59; + Item.damage = 56; Item.noMelee = true; Item.noUseGraphic = true; Item.useStyle = ItemUseStyleID.Swing; - Item.useAnimation = 60; - Item.useTime = 60; + Item.useTime = Item.useAnimation = 60; Item.knockBack = 8f; Item.mana = 18; Item.UseSound = SoundID.DD2_MonkStaffSwing; diff --git a/Items/Weapons/Magic/ThePrince.cs b/Items/Weapons/Magic/ThePrince.cs index 2cf5bc192a..7aec53e0f5 100644 --- a/Items/Weapons/Magic/ThePrince.cs +++ b/Items/Weapons/Magic/ThePrince.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(). AddIngredient(15). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/TheWand.cs b/Items/Weapons/Magic/TheWand.cs index cb2dcf2656..4a02a8674c 100644 --- a/Items/Weapons/Magic/TheWand.cs +++ b/Items/Weapons/Magic/TheWand.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 24f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) diff --git a/Items/Weapons/Magic/ThornBlossom.cs b/Items/Weapons/Magic/ThornBlossom.cs index 005e22edf6..d948d7f944 100644 --- a/Items/Weapons/Magic/ThornBlossom.cs +++ b/Items/Weapons/Magic/ThornBlossom.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Magic player.statLife -= 3; if (player.statLife <= 0) { - player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ThornBlossom").Format(player.name)), 1000.0, 0, false); + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ThornBlossom").ToNetworkText(player.name)), 1000.0, 0, false); } for (int index = 0; index < 3; ++index) { @@ -58,7 +58,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(). AddIngredient(10). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/Tradewinds.cs b/Items/Weapons/Magic/Tradewinds.cs index a895a3b7b5..7a665800ad 100644 --- a/Items/Weapons/Magic/Tradewinds.cs +++ b/Items/Weapons/Magic/Tradewinds.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/UltraLiquidator.cs b/Items/Weapons/Magic/UltraLiquidator.cs index 1095523651..6dc127929d 100644 --- a/Items/Weapons/Magic/UltraLiquidator.cs +++ b/Items/Weapons/Magic/UltraLiquidator.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.AquaScepter). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/UndinesRetribution.cs b/Items/Weapons/Magic/UndinesRetribution.cs index 1ffeebf364..3b0c0a2a62 100644 --- a/Items/Weapons/Magic/UndinesRetribution.cs +++ b/Items/Weapons/Magic/UndinesRetribution.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 64; Item.height = 64; - Item.damage = 46; + Item.damage = 44; Item.DamageType = DamageClass.Magic; Item.mana = 15; Item.useTime = 18; diff --git a/Items/Weapons/Magic/UnstableCastersGauntlet.cs b/Items/Weapons/Magic/UnstableCastersGauntlet.cs new file mode 100644 index 0000000000..1aff49b38d --- /dev/null +++ b/Items/Weapons/Magic/UnstableCastersGauntlet.cs @@ -0,0 +1,72 @@ +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Items.Materials; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class UnstableCastersGauntlet : ModItem, ILocalizedModType, IHoldShiftTooltipItem + { + public static int UseTime = 20; + public new string LocalizationCategory => "Items.Weapons.Magic"; + + public override void SetDefaults() + { + Item.width = 62; + Item.height = 60; + Item.damage = 320; + Item.DamageType = DamageClass.Magic; + Item.mana = 0; + Item.useAnimation = Item.useTime = UseTime; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.channel = true; + Item.knockBack = 3f; + Item.value = CalamityGlobalItem.RarityRedBuyPrice; + Item.rare = ItemRarityID.Red; + Item.Calamity().donorItem = true; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 15f; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + public override bool CanRightClick() => true; + public override bool AltFunctionUse(Player player) => true; + + public override void HoldItem(Player player) + { + player.Calamity().mouseRotationListener = true; + } + + public override void EquipFrameEffects(Player player, EquipType type) + { + player.handon = -1; + player.handoff = -1; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + // Projectile will point toward your cursor. + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + + Projectile.NewProjectile(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.LunarBar, 5). + AddIngredient(5). + AddIngredient(ItemID.FragmentNebula, 5). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/Magic/UnstableCastersGauntlet.png b/Items/Weapons/Magic/UnstableCastersGauntlet.png new file mode 100644 index 0000000000..3a132e5679 Binary files /dev/null and b/Items/Weapons/Magic/UnstableCastersGauntlet.png differ diff --git a/Items/Weapons/Magic/UnstableCastersGauntlet_HandsOn.png b/Items/Weapons/Magic/UnstableCastersGauntlet_HandsOn.png new file mode 100644 index 0000000000..4479ed3db2 Binary files /dev/null and b/Items/Weapons/Magic/UnstableCastersGauntlet_HandsOn.png differ diff --git a/Items/Weapons/Magic/ValkyrieRay.cs b/Items/Weapons/Magic/ValkyrieRay.cs index 9c8c4765fe..5174f80dbc 100644 --- a/Items/Weapons/Magic/ValkyrieRay.cs +++ b/Items/Weapons/Magic/ValkyrieRay.cs @@ -10,11 +10,11 @@ namespace CalamityMod.Items.Weapons.Magic public class ValkyrieRay : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; - // The base use time of the weapon is 47: 28 charge frames + 19 cooldown frames. + // The base use time of the weapon is 28: 18 charge frames + 10 cooldown frames. // The rate at which it progresses through its charge and discharge cycle is dynamically sped up by reforges. // This math is handled in its holdout projectile, ValkyrieRayStaff. - public const int ChargeFrames = 28; - public const int CooldownFrames = 19; + public const int ChargeFrames = 18; + public const int CooldownFrames = 10; public const float GemDistance = 18f; public static readonly Color LightColor = new Color(235, 40, 121); @@ -27,14 +27,14 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 54; Item.height = 52; - Item.damage = 53; + Item.damage = 115; Item.knockBack = 8.5f; Item.DamageType = DamageClass.Magic; - Item.mana = 26; + Item.mana = 17; Item.useTime = ChargeFrames + CooldownFrames; Item.useAnimation = ChargeFrames + CooldownFrames; Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = SoundID.NPCDeath7; + Item.UseSound = SoundID.NPCDeath7 with { Volume = 0.7f }; Item.useTurn = false; Item.noMelee = true; Item.noUseGraphic = true; @@ -45,6 +45,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.autoReuse = true; } + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 11; + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Magic/VeeringWind.cs b/Items/Weapons/Magic/VeeringWind.cs index 603589b897..b3e9f78474 100644 --- a/Items/Weapons/Magic/VeeringWind.cs +++ b/Items/Weapons/Magic/VeeringWind.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Magic/Vehemence.cs b/Items/Weapons/Magic/Vehemence.cs index 00f8970db7..72df4ffb67 100644 --- a/Items/Weapons/Magic/Vehemence.cs +++ b/Items/Weapons/Magic/Vehemence.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -37,13 +38,13 @@ namespace CalamityMod.Items.Weapons.Magic Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16.5f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Item v = player.ActiveItem(); + Item v = player.HeldItem; int chargeTime = 2 * v.useAnimation; Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, chargeTime); return false; diff --git a/Items/Weapons/Magic/VenusianTrident.cs b/Items/Weapons/Magic/VenusianTrident.cs index 407eaf612a..ea4d77de37 100644 --- a/Items/Weapons/Magic/VenusianTrident.cs +++ b/Items/Weapons/Magic/VenusianTrident.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 70; Item.height = 68; - Item.damage = 2156; + Item.damage = 2800; Item.DamageType = DamageClass.Magic; Item.mana = 40; Item.useTime = 65; @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(ItemID.InfernoFork). AddIngredient(2). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/Viscera.cs b/Items/Weapons/Magic/Viscera.cs index ec75d92d53..82854d3c88 100644 --- a/Items/Weapons/Magic/Viscera.cs +++ b/Items/Weapons/Magic/Viscera.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -60,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(4). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Magic/VitriolicViper.cs b/Items/Weapons/Magic/VitriolicViper.cs index 681c2e9007..56af4dc19c 100644 --- a/Items/Weapons/Magic/VitriolicViper.cs +++ b/Items/Weapons/Magic/VitriolicViper.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -11,7 +12,6 @@ namespace CalamityMod.Items.Weapons.Magic public class VitriolicViper : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; - public override void SetDefaults() { Item.width = 60; diff --git a/Items/Weapons/Magic/VividClarity.cs b/Items/Weapons/Magic/VividClarity.cs index 5aabf36d9d..b4ea614361 100644 --- a/Items/Weapons/Magic/VividClarity.cs +++ b/Items/Weapons/Magic/VividClarity.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 6f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo projSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Magic/VoidVortex.cs b/Items/Weapons/Magic/VoidVortex.cs index abd18f69a4..8c0e9cfa2a 100644 --- a/Items/Weapons/Magic/VoidVortex.cs +++ b/Items/Weapons/Magic/VoidVortex.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.noMelee = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Magic/VoltaicClimax.cs b/Items/Weapons/Magic/VoltaicClimax.cs index 5cd70a1c53..2f20bd1f80 100644 --- a/Items/Weapons/Magic/VoltaicClimax.cs +++ b/Items/Weapons/Magic/VoltaicClimax.cs @@ -24,11 +24,10 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 78; Item.height = 78; - Item.damage = 235; + Item.damage = 215; Item.DamageType = DamageClass.Magic; Item.mana = 32; - Item.useTime = 29; - Item.useAnimation = 29; + Item.useTime = Item.useAnimation = 34; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5f; @@ -37,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Magic/Volterion.cs b/Items/Weapons/Magic/Volterion.cs index 5579403159..0d98315476 100644 --- a/Items/Weapons/Magic/Volterion.cs +++ b/Items/Weapons/Magic/Volterion.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Weapons/Magic/WintersFury.cs b/Items/Weapons/Magic/WintersFury.cs index 73d7bf6a5e..6e35c1d79c 100644 --- a/Items/Weapons/Magic/WintersFury.cs +++ b/Items/Weapons/Magic/WintersFury.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 36; Item.height = 40; - Item.damage = 70; + Item.damage = 65; Item.DamageType = DamageClass.Magic; Item.mana = 7; Item.useTime = 12; @@ -32,16 +32,14 @@ namespace CalamityMod.Items.Weapons.Magic Item.UseSound = SoundID.Item9; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 15f; + Item.shootSpeed = 16f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (!Main.rand.NextBool(4)) { - Vector2 speed = velocity.RotatedBy(MathHelper.ToRadians(Main.rand.Next(-15, 16))); - speed.Normalize(); - speed *= 15f; + Vector2 speed = velocity.RotatedByRandom(MathHelper.Pi / 12f); speed.Y -= Math.Abs(speed.X) * 0.2f; int p = Projectile.NewProjectile(source, position, speed, ModContent.ProjectileType(), damage, knockback, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) @@ -52,8 +50,8 @@ namespace CalamityMod.Items.Weapons.Magic SoundEngine.PlaySound(SoundID.Item1, position); Projectile.NewProjectile(source, position.X, position.Y, velocity.X * 1.2f, velocity.Y * 1.2f, ModContent.ProjectileType(), damage, knockback * 2f, player.whoAmI); } - velocity.X += Main.rand.Next(-40, 41) * 0.05f; - velocity.Y += Main.rand.Next(-40, 41) * 0.05f; + velocity.X += Main.rand.NextFloat(-2f, 2f); + velocity.Y += Main.rand.NextFloat(-2f, 2f); return true; } } diff --git a/Items/Weapons/Magic/WulfrumProsthesis.cs b/Items/Weapons/Magic/WulfrumProsthesis.cs index 08f1946933..1028f4af5a 100644 --- a/Items/Weapons/Magic/WulfrumProsthesis.cs +++ b/Items/Weapons/Magic/WulfrumProsthesis.cs @@ -145,7 +145,6 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(10). - AddIngredient(). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Magic/YharimsCrystal.cs b/Items/Weapons/Magic/YharimsCrystal.cs index 79f6ee338e..d2173baeb2 100644 --- a/Items/Weapons/Magic/YharimsCrystal.cs +++ b/Items/Weapons/Magic/YharimsCrystal.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -32,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.channel = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; diff --git a/Items/Weapons/Melee/AbsoluteZero.cs b/Items/Weapons/Melee/AbsoluteZero.cs index de9f7969e6..1b9615ad9c 100644 --- a/Items/Weapons/Melee/AbsoluteZero.cs +++ b/Items/Weapons/Melee/AbsoluteZero.cs @@ -42,7 +42,6 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { target.AddBuff(BuffID.Frostburn2, 300); - target.AddBuff(ModContent.BuffType(), 60); var source = player.GetSource_ItemUse(Item); int p = Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), Item.damage, 12f, player.whoAmI); Main.projectile[p].Kill(); diff --git a/Items/Weapons/Melee/AbyssBlade.cs b/Items/Weapons/Melee/AbyssBlade.cs index 71525139dd..3261dd0d92 100644 --- a/Items/Weapons/Melee/AbyssBlade.cs +++ b/Items/Weapons/Melee/AbyssBlade.cs @@ -1,11 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; -using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 74; Item.height = 74; - Item.damage = 140; + Item.damage = 123; Item.knockBack = 7.5f; Item.useTime = 65; Item.useAnimation = 65; diff --git a/Items/Weapons/Melee/AcidwoodSword.cs b/Items/Weapons/Melee/AcidwoodSword.cs index e66fd94976..f204f19fe8 100644 --- a/Items/Weapons/Melee/AcidwoodSword.cs +++ b/Items/Weapons/Melee/AcidwoodSword.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using Terraria; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/Aftershock.cs b/Items/Weapons/Melee/Aftershock.cs deleted file mode 100644 index aa4dcc8de9..0000000000 --- a/Items/Weapons/Melee/Aftershock.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - public class Aftershock : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - - internal const float ShootSpeed = 12f; - - public override void SetDefaults() - { - Item.width = 54; - Item.height = 58; - Item.damage = 65; - Item.DamageType = DamageClass.Melee; - Item.useTime = 28; - Item.useAnimation = 28; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.knockBack = 9f; - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.shootSpeed = ShootSpeed; - } - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 300); - Vector2 destination = target.Center; - Vector2 position = destination - (Vector2.UnitY * (destination.Y - Main.screenPosition.Y + 80f)) + (Vector2.UnitX * Main.rand.Next(-160, 161)); - Vector2 velocity = (destination - position).SafeNormalize(Vector2.UnitY) * ShootSpeed * Main.rand.NextFloat(0.9f, 1.1f); - int rockDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(player.GetSource_ItemUse(Item), position, velocity, ModContent.ProjectileType(), rockDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10), target.Center.Y); - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - target.AddBuff(ModContent.BuffType(), 300); - Vector2 destination = target.Center; - Vector2 position = destination - (Vector2.UnitY * (destination.Y - Main.screenPosition.Y + 80f)) + (Vector2.UnitX * Main.rand.Next(-160, 161)); - Vector2 velocity = (destination - position).SafeNormalize(Vector2.UnitY) * ShootSpeed * Main.rand.NextFloat(0.9f, 1.1f); - int rockDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(player.GetSource_ItemUse(Item), position, velocity, ModContent.ProjectileType(), rockDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10), target.Center.Y); - } - } -} diff --git a/Items/Weapons/Melee/Aftershock.png b/Items/Weapons/Melee/Aftershock.png deleted file mode 100644 index 3a6a2d76a2..0000000000 Binary files a/Items/Weapons/Melee/Aftershock.png and /dev/null differ diff --git a/Items/Weapons/Melee/AirSpinner.cs b/Items/Weapons/Melee/AirSpinner.cs index f3a317b299..3c03fb9b15 100644 --- a/Items/Weapons/Melee/AirSpinner.cs +++ b/Items/Weapons/Melee/AirSpinner.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -52,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Melee CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.SunplateBlock, 3). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Melee/AmidiasTrident.cs b/Items/Weapons/Melee/AmidiasTrident.cs index 36530c0bdb..f92771ee63 100644 --- a/Items/Weapons/Melee/AmidiasTrident.cs +++ b/Items/Weapons/Melee/AmidiasTrident.cs @@ -1,11 +1,12 @@ -using CalamityMod.Projectiles.Melee.Spears; +using CalamityMod.Items.BaseItems; +using CalamityMod.Projectiles.Melee.Spears; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class AmidiasTrident : ModItem, ILocalizedModType + public class AmidiasTrident : CustomUseProjItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; public override void SetStaticDefaults() @@ -13,27 +14,40 @@ namespace CalamityMod.Items.Weapons.Melee ItemID.Sets.Spears[Type] = true; } + /// + /// The damage multiplier for the primary use's long-range projectiles. + /// + public static readonly float BaseAttackProjectileMult = 0.5f; + /// + /// The damage multiplier for the secondary attack. + /// + public static readonly float SecondaryAttackMeleeMult = 1.25f; + /// + /// Secondary attack proc effect damage. Multiplied by the number of stacks of Sea King's Assurance the enemy taking damage has. + /// + public static readonly int SecondaryAttackBlastBaseDamage = 20; + public override void SetDefaults() { Item.width = 44; Item.height = 44; - Item.damage = 12; + Item.damage = 20; Item.DamageType = DamageClass.Melee; Item.noMelee = true; - Item.useTurn = true; Item.noUseGraphic = true; - Item.useAnimation = 17; + Item.useAnimation = 45; Item.useStyle = ItemUseStyleID.Shoot; - Item.useTime = 17; + Item.useTime = 45; Item.knockBack = 4.5f; - Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 6f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) + { + return true; + } } } diff --git a/Items/Weapons/Melee/AnarchyBlade.cs b/Items/Weapons/Melee/AnarchyBlade.cs index deda0bf7d1..93f04e9e1d 100644 --- a/Items/Weapons/Melee/AnarchyBlade.cs +++ b/Items/Weapons/Melee/AnarchyBlade.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 114; Item.height = 122; - Item.damage = 150; + Item.damage = 120; Item.DamageType = DamageClass.Melee; Item.useAnimation = 19; Item.useTime = 19; diff --git a/Items/Weapons/Melee/Aorta.cs b/Items/Weapons/Melee/Aorta.cs index 6552a7ee34..18b879d7ed 100644 --- a/Items/Weapons/Melee/Aorta.cs +++ b/Items/Weapons/Melee/Aorta.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; +using CalamityMod.Projectiles.Melee.Yoyos; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -46,15 +44,5 @@ namespace CalamityMod.Items.Weapons.Melee Item.rare = ItemRarityID.Orange; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 3). - AddIngredient(9). - AddIngredient(ItemID.Vertebrae, 3). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index 905ec0cf9c..14a4346bf8 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee public static float MaxThrowReach = 760; public static float SnapDamageMultiplier = 1.2f; //Extra damage from making the scissors snap - public static float MaxCharge = 15f; // Maximum charge value AKA how much charge you get from a parry + public static float MaxCharge = 16f; // Maximum charge value AKA how much charge you get from a parry public static float chargeDamageMultiplier = 1.35f; //Extra damage from charge public static float chainDamageMultiplier = 0.1f; public static float SnapBoltsDamageMultiplier = 0.1f; @@ -76,7 +76,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = Item.height = 136; - Item.damage = 1700; + Item.damage = 1800; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noMelee = true; Item.noUseGraphic = true; @@ -90,7 +90,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 28f; - Item.rare = RarityType(); + Item.rare = RarityType(); } // Terraria seems to really dislike high crit values in SetDefaults @@ -127,10 +127,11 @@ namespace CalamityMod.Items.Weapons.Melee // If it has been less than N frames since the last alt function use, this is a double right click. bool rightMouseDoubleClick = rmbFrames > 0; - // Check if a parry holdout is already present. + // Check if a parry holdout or blast is already present. Projectile parrier = Main.projectile.FirstOrDefault(p => p.active && p.owner == player.whoAmI && p.type == ProjectileType(), null); + Projectile blast = Main.projectile.FirstOrDefault(p => p.active && p.owner == player.whoAmI && p.type == ProjectileType(), null); - bool canExecuteBlast = rightMouseDoubleClick && Charge > 0; + bool canExecuteBlast = rightMouseDoubleClick && Charge > 0 && blast is null; bool canExecuteParry = parrier is null && !canExecuteBlast; // The blast is checked first, so that it overrides the first right click triggering a parry. Blasts delete any active parry holdouts on use. @@ -141,8 +142,8 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(source, player.Center + angle.ToRotationVector2() * 90f, velocity, ProjectileType(), (int)(damage * BlastDamageMultiplier), 0, player.whoAmI, Charge); Charge = 0; - // If the parry holdout has existed for very few frames and hasn't parried something, just delete it. - if (parrier is not null && parrier.timeLeft > ArkoftheCosmosParryHoldout.MaxTime - DoubleRightClickFrames && parrier.ai[1] <= 0f) + // If the parry holdout has existed for very few frames, just delete it. + if (parrier is not null && parrier.timeLeft > ArkoftheCosmosParryHoldout.MaxTime - DoubleRightClickFrames) { parrier.active = false; parrier.netUpdate = true; @@ -235,7 +236,7 @@ namespace CalamityMod.Items.Weapons.Melee var barBG = Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; var barFG = Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; - float barScale = 3f; + float barScale = 4f; Vector2 barOrigin = barBG.Size() * 0.5f; float yOffset = 50f; Vector2 drawPos = position + Vector2.UnitY * scale * (frame.Height - yOffset); diff --git a/Items/Weapons/Melee/ArkoftheElements.cs b/Items/Weapons/Melee/ArkoftheElements.cs index 39b95d5473..8a65882035 100644 --- a/Items/Weapons/Melee/ArkoftheElements.cs +++ b/Items/Weapons/Melee/ArkoftheElements.cs @@ -211,7 +211,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentSolar, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/AstralBlade.cs b/Items/Weapons/Melee/AstralBlade.cs deleted file mode 100644 index 46e95a74f6..0000000000 --- a/Items/Weapons/Melee/AstralBlade.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Items.Materials; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items.Weapons.Melee -{ - public class AstralBlade : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() - { - Item.width = 80; - Item.height = 80; - Item.damage = 142; - Item.DamageType = TrueMeleeDamageClass.Instance; - Item.useTime = 12; - Item.useAnimation = 12; - Item.useTurn = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.knockBack = 6f; - Item.value = CalamityGlobalItem.RarityCyanBuyPrice; - Item.rare = ItemRarityID.Cyan; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - } - - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 25; - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 300); - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) => target.AddBuff(ModContent.BuffType(), 300); - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - for (int i = 0; i < 3; i++) - { - Dust d = CalamityUtils.MeleeDustHelper(player, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(), 0.7f, 55, 110, -0.07f, 0.07f); - if (d != null) - d.customData = 0.03f; - } - } - - public override void ModifyHitNPC(Player player, NPC target, ref NPC.HitModifiers modifiers) - { - // Avoid dividing by 0 at all costs. - if (target.lifeMax <= 0) - return; - - float lifeRatio = MathHelper.Clamp(target.life / (float)target.lifeMax, 0f, 1f); - float maxMultiplier = 1.25f; - float multiplier = MathHelper.Lerp(1f, maxMultiplier, lifeRatio); - - modifiers.SourceDamage *= multiplier; - modifiers.Knockback *= multiplier; - - if (Main.rand.NextBool((int)MathHelper.Clamp((Item.crit + player.GetCritChance()) * multiplier, 0f, 99f), 100)) - modifiers.SetCrit(); - - SoundEngine.PlaySound(SoundID.Item105, player.Center); - - bool blue = Main.rand.NextBool(); - float angleStart = Main.rand.NextFloat(0f, MathHelper.TwoPi); - float var = 0.05f + (maxMultiplier - multiplier); - for (float angle = 0f; angle < MathHelper.TwoPi; angle += var) - { - blue = !blue; - Vector2 velocity = angle.ToRotationVector2() * (2f + (float)(Math.Sin(angleStart + angle * 3f) + 1) * 2.5f) * Main.rand.NextFloat(0.95f, 1.05f); - Dust d = Dust.NewDustPerfect(target.Center, blue ? ModContent.DustType() : ModContent.DustType(), velocity); - d.customData = 0.025f; - d.scale = multiplier; - d.noLight = false; - } - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(8). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Melee/AstralBlade.png b/Items/Weapons/Melee/AstralBlade.png deleted file mode 100644 index 96c91d0c8b..0000000000 Binary files a/Items/Weapons/Melee/AstralBlade.png and /dev/null differ diff --git a/Items/Weapons/Melee/Ataraxia.cs b/Items/Weapons/Melee/Ataraxia.cs index 62bc330370..49cf9686b6 100644 --- a/Items/Weapons/Melee/Ataraxia.cs +++ b/Items/Weapons/Melee/Ataraxia.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/Avalanche.cs b/Items/Weapons/Melee/Avalanche.cs index af32ff182b..e7af81dc97 100644 --- a/Items/Weapons/Melee/Avalanche.cs +++ b/Items/Weapons/Melee/Avalanche.cs @@ -1,4 +1,4 @@ -using System; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { int type = ModContent.ProjectileType(); - if (CalamityUtils.CountOwnedProjectiles(type, player.whoAmI) < 16) + if (player.ownedProjectileCounts[type] < 16) { var source = player.GetSource_ItemUse(Item); int bombDamage = player.CalcIntDamage(Item.damage); diff --git a/Items/Weapons/Melee/Azathoth.cs b/Items/Weapons/Melee/Azathoth.cs deleted file mode 100644 index 2dd12c9fb4..0000000000 --- a/Items/Weapons/Melee/Azathoth.cs +++ /dev/null @@ -1,63 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee.Yoyos; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - public class Azathoth : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - - public static float Reach = 880f; - public static float Speed = 60f; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(Reach.ToTiles(), Speed); - - public override void SetStaticDefaults() - { - ItemID.Sets.Yoyo[Type] = true; - ItemID.Sets.GamepadExtraRange[Type] = 15; - ItemID.Sets.GamepadSmartQuickReach[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 40; - Item.height = 54; - Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 90; - Item.knockBack = 6f; - Item.useTime = 20; - Item.useAnimation = 20; - Item.autoReuse = true; - - Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = SoundID.Item1; - Item.channel = true; - Item.noUseGraphic = true; - Item.noMelee = true; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 16f; - - Item.autoReuse = true; - Item.rare = ModContent.RarityType(); - Item.Calamity().devItem = true; - Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.Terrarian). - AddIngredient(5). - AddIngredient(2). - AddTile(). - Register(); - } - } -} diff --git a/Items/Weapons/Melee/BalefulHarvester.cs b/Items/Weapons/Melee/BalefulHarvester.cs index 57fd032a47..8d4c5f7395 100644 --- a/Items/Weapons/Melee/BalefulHarvester.cs +++ b/Items/Weapons/Melee/BalefulHarvester.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.BaseItems; using CalamityMod.Projectiles.Melee; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,12 +11,12 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.width = 86; - Item.height = 98; - Item.damage = 120; + Item.width = 92; + Item.height = 106; + Item.damage = 150; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useStyle = ItemUseStyleID.Shoot; - Item.useAnimation = Item.useTime = 80; + Item.useAnimation = Item.useTime = 90; Item.useTurn = true; Item.knockBack = 8f; Item.UseSound = null; diff --git a/Items/Weapons/Melee/BalefulHarvester.png b/Items/Weapons/Melee/BalefulHarvester.png index 360c99acaf..bf3ee4403c 100644 Binary files a/Items/Weapons/Melee/BalefulHarvester.png and b/Items/Weapons/Melee/BalefulHarvester.png differ diff --git a/Items/Weapons/Melee/BallOFugu.cs b/Items/Weapons/Melee/BallOFugu.cs index c0d446fcdf..475588999f 100644 --- a/Items/Weapons/Melee/BallOFugu.cs +++ b/Items/Weapons/Melee/BallOFugu.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Melee.MaceFlails; -using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/Basher.cs b/Items/Weapons/Melee/Basher.cs index e050f25e6f..4920f4ff29 100644 --- a/Items/Weapons/Melee/Basher.cs +++ b/Items/Weapons/Melee/Basher.cs @@ -1,9 +1,7 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.BaseItems; +using CalamityMod.Items.BaseItems; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using CalamityMod.Projectiles.Melee; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(15). AddIngredient(12). AddTile(TileID.Anvils). Register(); diff --git a/Items/Weapons/Melee/BladecrestOathsword.cs b/Items/Weapons/Melee/BladecrestOathsword.cs index e88d676e19..ab15acffd1 100644 --- a/Items/Weapons/Melee/BladecrestOathsword.cs +++ b/Items/Weapons/Melee/BladecrestOathsword.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 56; Item.height = 56; - Item.damage = 50; + Item.damage = 42; Item.knockBack = 3f; Item.useTime = 53; Item.useAnimation = 53; diff --git a/Items/Weapons/Melee/BlightedCleaver.cs b/Items/Weapons/Melee/BlightedCleaver.cs index ec16818ed4..978212c6eb 100644 --- a/Items/Weapons/Melee/BlightedCleaver.cs +++ b/Items/Weapons/Melee/BlightedCleaver.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 88; Item.height = 88; - Item.damage = 92; + Item.damage = 90; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 28; Item.useStyle = ItemUseStyleID.Swing; @@ -74,14 +73,12 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - player.AddBuff(ModContent.BuffType(), 180); target.AddBuff(BuffID.Venom, 240); target.AddBuff(BuffID.OnFire3, 240); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { - player.AddBuff(ModContent.BuffType(), 180); target.AddBuff(BuffID.Venom, 240); target.AddBuff(BuffID.OnFire3, 240); } @@ -93,7 +90,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.BrokenHeroSword). AddIngredient(ItemID.ChlorophyteBar, 15). AddIngredient(ItemID.VialofVenom, 10). - AddTile(TileID.DemonAltar). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/Bonebreaker.cs b/Items/Weapons/Melee/Bonebreaker.cs index a3a36efc90..10443ca6d9 100644 --- a/Items/Weapons/Melee/Bonebreaker.cs +++ b/Items/Weapons/Melee/Bonebreaker.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/BotanicPiercer.cs b/Items/Weapons/Melee/BotanicPiercer.cs index 25f5f5eb42..1d67b9f7ff 100644 --- a/Items/Weapons/Melee/BotanicPiercer.cs +++ b/Items/Weapons/Melee/BotanicPiercer.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 112; Item.height = 112; - Item.damage = 88; + Item.damage = 110; Item.DamageType = DamageClass.Melee; Item.noMelee = true; Item.useTurn = true; diff --git a/Items/Weapons/Melee/Brimlance.cs b/Items/Weapons/Melee/Brimlance.cs index 891c17c57e..cc5889cd95 100644 --- a/Items/Weapons/Melee/Brimlance.cs +++ b/Items/Weapons/Melee/Brimlance.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Melee.Spears; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee.Spears; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,7 +13,6 @@ namespace CalamityMod.Items.Weapons.Melee { ItemID.Sets.Spears[Type] = true; } - public override void SetDefaults() { Item.width = 56; diff --git a/Items/Weapons/Melee/Brimlash.cs b/Items/Weapons/Melee/Brimlash.cs index 2107039480..39a841fea3 100644 --- a/Items/Weapons/Melee/Brimlash.cs +++ b/Items/Weapons/Melee/Brimlash.cs @@ -15,10 +15,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = Item.height = 72; - Item.damage = 70; + Item.damage = 60; Item.DamageType = DamageClass.Melee; - Item.useAnimation = 30; - Item.useTime = 30; + Item.useTime = Item.useAnimation = 30; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6f; diff --git a/Items/Weapons/Melee/BrimstoneSword.cs b/Items/Weapons/Melee/BrimstoneSword.cs index 78ccce24fd..35e119edbf 100644 --- a/Items/Weapons/Melee/BrimstoneSword.cs +++ b/Items/Weapons/Melee/BrimstoneSword.cs @@ -4,7 +4,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/BrinyBaron.cs b/Items/Weapons/Melee/BrinyBaron.cs index 0720ced625..b33b4a75e3 100644 --- a/Items/Weapons/Melee/BrinyBaron.cs +++ b/Items/Weapons/Melee/BrinyBaron.cs @@ -2,7 +2,6 @@ using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/BrokenBiomeBlade.cs b/Items/Weapons/Melee/BrokenBiomeBlade.cs index 2da5be69b2..02a837769c 100644 --- a/Items/Weapons/Melee/BrokenBiomeBlade.cs +++ b/Items/Weapons/Melee/BrokenBiomeBlade.cs @@ -324,8 +324,8 @@ namespace CalamityMod.Items.Weapons.Melee { CreateRecipe(). AddRecipeGroup("AnyWoodenSword"). - AddIngredient(ItemType(), 5). - AddIngredient(ItemID.HellstoneBar, 5). + AddIngredient(ItemType(), 10). + AddIngredient(ItemID.HellstoneBar, 10). AddIngredient(ItemID.DirtBlock, 50). AddIngredient(ItemID.StoneBlock, 50). AddTile(TileID.Anvils). diff --git a/Items/Weapons/Melee/BurningRevelation.cs b/Items/Weapons/Melee/BurningRevelation.cs index b4523d58ba..2770675015 100644 --- a/Items/Weapons/Melee/BurningRevelation.cs +++ b/Items/Weapons/Melee/BurningRevelation.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -29,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = 40; - Item.height = 38; + Item.height = 48; Item.DamageType = DamageClass.MeleeNoSpeed; Item.damage = 300; Item.knockBack = 7.5f; diff --git a/Items/Weapons/Melee/CelestialClaymore.cs b/Items/Weapons/Melee/CelestialClaymore.cs index be2b5e936f..8a7863cb4e 100644 --- a/Items/Weapons/Melee/CelestialClaymore.cs +++ b/Items/Weapons/Melee/CelestialClaymore.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -24,8 +23,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.knockBack = 5.25f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; - Item.rare = ItemRarityID.LightRed; + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 0.1f; } diff --git a/Items/Weapons/Melee/ClamCrusher.cs b/Items/Weapons/Melee/ClamCrusher.cs index 81072b8d27..a6b2b23db1 100644 --- a/Items/Weapons/Melee/ClamCrusher.cs +++ b/Items/Weapons/Melee/ClamCrusher.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Melee; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/CometQuasher.cs b/Items/Weapons/Melee/CometQuasher.cs index 31455c4fe4..303ec17ba6 100644 --- a/Items/Weapons/Melee/CometQuasher.cs +++ b/Items/Weapons/Melee/CometQuasher.cs @@ -1,11 +1,8 @@ -using System; -using CalamityMod.Dusts; -using CalamityMod.Items.BaseItems; +using CalamityMod.Items.BaseItems; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 92; Item.height = 94; - Item.damage = 35; + Item.damage = 48; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = Item.useTime = 38; diff --git a/Items/Weapons/Melee/CosmicDischarge.cs b/Items/Weapons/Melee/CosmicDischarge.cs index f27421e8d2..b9a87ab485 100644 --- a/Items/Weapons/Melee/CosmicDischarge.cs +++ b/Items/Weapons/Melee/CosmicDischarge.cs @@ -15,14 +15,13 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 50; Item.height = 52; - Item.damage = 400; + Item.damage = 450; Item.noMelee = true; Item.noUseGraphic = true; Item.channel = true; Item.autoReuse = true; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.useAnimation = 15; - Item.useTime = 15; + Item.useTime = Item.useAnimation = 15; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 0.5f; Item.UseSound = SoundID.Item122; @@ -30,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.shoot = ModContent.ProjectileType(); Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Melee/CosmicShiv.cs b/Items/Weapons/Melee/CosmicShiv.cs index e8e5ba8113..0c5bdfb0f6 100644 --- a/Items/Weapons/Melee/CosmicShiv.cs +++ b/Items/Weapons/Melee/CosmicShiv.cs @@ -2,7 +2,6 @@ using CalamityMod.Projectiles.Melee.Shortswords; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -20,15 +19,15 @@ namespace CalamityMod.Items.Weapons.Melee Item.noUseGraphic = true; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 270; + Item.damage = 155; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 40; + Item.useAnimation = Item.useTime = 30; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 2.4f; Item.knockBack = 9f; Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; // revertusernamechange on Discord (Yatagarasu) } @@ -37,10 +36,10 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(8). AddTile(). Register(); } } -} \ No newline at end of file +} diff --git a/Items/Weapons/Melee/CrescentMoon.cs b/Items/Weapons/Melee/CrescentMoon.cs index 4452ea6789..de1086891f 100644 --- a/Items/Weapons/Melee/CrescentMoon.cs +++ b/Items/Weapons/Melee/CrescentMoon.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 16; Item.height = 16; - Item.damage = 380; + Item.damage = 1000; Item.noMelee = true; Item.noUseGraphic = true; Item.channel = true; @@ -34,6 +34,10 @@ namespace CalamityMod.Items.Weapons.Melee Item.shoot = ModContent.ProjectileType(); } + public override void HoldItem(Player player) + { + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { float ai3 = (Main.rand.NextFloat() - 0.5f) * 0.7853982f; //0.5 @@ -48,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(8). AddIngredient(3). AddIngredient(16). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/DeathsAscension.cs b/Items/Weapons/Melee/DeathsAscension.cs index a71bc50700..b180aeca3d 100644 --- a/Items/Weapons/Melee/DeathsAscension.cs +++ b/Items/Weapons/Melee/DeathsAscension.cs @@ -125,7 +125,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(4). AddIngredient(ItemID.SoulofNight, 15). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/DefiledGreatsword.cs b/Items/Weapons/Melee/DefiledGreatsword.cs index b46bdb4425..54b6418ceb 100644 --- a/Items/Weapons/Melee/DefiledGreatsword.cs +++ b/Items/Weapons/Melee/DefiledGreatsword.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -119,14 +118,12 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - player.AddBuff(ModContent.BuffType(), 300); target.AddBuff(BuffID.Venom, 360); target.AddBuff(BuffID.OnFire3, 360); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { - player.AddBuff(ModContent.BuffType(), 300); target.AddBuff(BuffID.Venom, 360); target.AddBuff(BuffID.OnFire3, 360); } @@ -137,7 +134,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(). AddIngredient(). AddIngredient(15). - AddTile(TileID.DemonAltar). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/DepthCrusher.cs b/Items/Weapons/Melee/DepthCrusher.cs index 86f994eb02..fbae45ccaa 100644 --- a/Items/Weapons/Melee/DepthCrusher.cs +++ b/Items/Weapons/Melee/DepthCrusher.cs @@ -1,7 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; -using Terraria; +using CalamityMod.Projectiles.Melee; using Terraria.ID; using Terraria.ModLoader; @@ -30,8 +27,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = null; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; } } } diff --git a/Items/Weapons/Melee/DevilsDevastation.cs b/Items/Weapons/Melee/DevilsDevastation.cs index 8e6627d650..7fb483872b 100644 --- a/Items/Weapons/Melee/DevilsDevastation.cs +++ b/Items/Weapons/Melee/DevilsDevastation.cs @@ -1,11 +1,8 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Cooldowns; +using CalamityMod.Cooldowns; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; @@ -26,7 +23,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 118; Item.height = 118; - Item.damage = 235; + Item.damage = 333; + Item.crit = 41; Item.useAnimation = Item.useTime = 45; Item.useStyle = ItemUseStyleID.Shoot; @@ -41,15 +39,14 @@ namespace CalamityMod.Items.Weapons.Melee Item.channel = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool MeleePrefix() => true; - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 41; public override bool CanUseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && !player.Calamity().mouseRight; public override void HoldItem(Player player) { player.Calamity().mouseWorldListener = true; - if (player.Calamity().mouseRight && player.Calamity().killModeCooldown == 0 && !Main.mapFullscreen && !Main.blockMouse) + if (player.Calamity().mouseRight && !player.mouseInterface && player.Calamity().killModeCooldown == 0 && !Main.mapFullscreen && !Main.blockMouse) { SoundStyle buff = new("CalamityMod/Sounds/Item/DemonSwordKillMode"); SoundEngine.PlaySound(buff with { Volume = 0.95f }, player.Center); @@ -76,7 +73,7 @@ namespace CalamityMod.Items.Weapons.Melee } if (player.Calamity().demonSwordKillMode && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && player.Calamity().killModeCooldown == KillMode.cooldownMax + KillMode.buffMax) { - Projectile blade = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), Item.damage * 30, Item.knockBack, player.whoAmI, 0, throwCount); + Projectile.NewProjectile(player.GetSource_ItemUse(Item), player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), Item.damage * 15, Item.knockBack, player.whoAmI, 0, throwCount); //This used to be 30x damage. } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Melee/DevilsSunrise.cs b/Items/Weapons/Melee/DevilsSunrise.cs index 0706ed19c2..99c244a22e 100644 --- a/Items/Weapons/Melee/DevilsSunrise.cs +++ b/Items/Weapons/Melee/DevilsSunrise.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.Terragrim). AddIngredient(25). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/DragonPow.cs b/Items/Weapons/Melee/DragonPow.cs index 9b2ca8504b..d1e27ec1d4 100644 --- a/Items/Weapons/Melee/DragonPow.cs +++ b/Items/Weapons/Melee/DragonPow.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.channel = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/DragonRage.cs b/Items/Weapons/Melee/DragonRage.cs index dc5f9e1f86..3b7300228c 100644 --- a/Items/Weapons/Melee/DragonRage.cs +++ b/Items/Weapons/Melee/DragonRage.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = SoundID.DD2_SkyDragonsFurySwing; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } } } diff --git a/Items/Weapons/Melee/DriftwoodSword.cs b/Items/Weapons/Melee/DriftwoodSword.cs index 92ea5b1ac9..3860343caf 100644 --- a/Items/Weapons/Melee/DriftwoodSword.cs +++ b/Items/Weapons/Melee/DriftwoodSword.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.FurnitureDriftwood; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void MeleeEffects(Player player, Rectangle hitbox) { if (IsPlayerInContactWithWater(player)) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.MagnetSphere); } public override float UseSpeedMultiplier(Player player) => IsPlayerInContactWithWater(player) ? 1.66f : 1f; diff --git a/Items/Weapons/Melee/Earth.cs b/Items/Weapons/Melee/Earth.cs index ad209469b3..24d310a7ab 100644 --- a/Items/Weapons/Melee/Earth.cs +++ b/Items/Weapons/Melee/Earth.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using CalamityMod.Items.BaseItems; using CalamityMod.Items.Materials; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 186; Item.height = 186; - Item.damage = 5684; + Item.damage = 4200; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = 42; Item.useTime = 42; diff --git a/Items/Weapons/Melee/EmpyreanKnives.cs b/Items/Weapons/Melee/EmpyreanKnives.cs index 285c560887..07a926f727 100644 --- a/Items/Weapons/Melee/EmpyreanKnives.cs +++ b/Items/Weapons/Melee/EmpyreanKnives.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -28,8 +27,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.knockBack = 3f; Item.UseSound = SoundID.Item39; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; } @@ -98,7 +97,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.VampireKnives). AddIngredient(). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/EntropicClaymore.cs b/Items/Weapons/Melee/EntropicClaymore.cs index 125028b0c0..8ade723dba 100644 --- a/Items/Weapons/Melee/EntropicClaymore.cs +++ b/Items/Weapons/Melee/EntropicClaymore.cs @@ -3,7 +3,6 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using System; -using System.Collections.Generic; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -23,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 130; Item.height = 130; - Item.damage = 110; + Item.damage = 90; Item.DamageType = DamageClass.Melee; Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Swing; @@ -38,18 +37,6 @@ namespace CalamityMod.Items.Weapons.Melee Item.shootSpeed = 12f; } - /*public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) - { - int hitX = (int)(player.itemLocation + (swingRotation + MathHelper.ToRadians(90f)).ToRotationVector2() * 90).X; - int hitY = (int)(player.itemLocation + (swingRotation + MathHelper.ToRadians(90f)).ToRotationVector2() * 90).Y; - hitbox = new Rectangle(hitX, hitY, Item.width / 3, Item.height / 3); - - Particle spark2 = new GlowOrbParticle(new Vector2(hitX, hitY), Vector2.Zero, false, 5, 1, Color.Red); - GeneralParticleHandler.SpawnParticle(spark2); - }*/ - - public override void ModifyTooltips(List tooltips) => tooltips.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { for (int i = 0; i < 5; i++) @@ -85,7 +72,7 @@ namespace CalamityMod.Items.Weapons.Melee if (Main.rand.NextBool()) { Vector2 dustVel = new Vector2(5 * swordDirection, -5).RotatedByRandom(1.55f) * Main.rand.NextFloat(0.7f, 1.3f) * 2; - Dust dust = Dust.NewDustPerfect(player.Center + dustVel * 9, 66); + Dust dust = Dust.NewDustPerfect(player.Center + dustVel * 9, DustID.RainbowTorch); dust.scale = Main.rand.NextFloat(0.5f, 0.75f); dust.velocity = dustVel * 0.85f; dust.color = Color.LightGreen; diff --git a/Items/Weapons/Melee/EssenceFlayer.cs b/Items/Weapons/Melee/EssenceFlayer.cs index 790801310d..7d6a21fa2c 100644 --- a/Items/Weapons/Melee/EssenceFlayer.cs +++ b/Items/Weapons/Melee/EssenceFlayer.cs @@ -19,11 +19,10 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 100; Item.height = 78; - Item.damage = 225; + Item.damage = 220; Item.DamageType = DamageClass.Melee; - Item.useAnimation = 19; + Item.useTime = Item.useAnimation = 19; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 19; Item.useTurn = true; Item.knockBack = 8f; Item.UseSound = SoundID.Item71; @@ -31,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 21f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Weapons/Melee/ExaltedOathblade.cs b/Items/Weapons/Melee/ExaltedOathblade.cs index 6dd42db33a..583832586e 100644 --- a/Items/Weapons/Melee/ExaltedOathblade.cs +++ b/Items/Weapons/Melee/ExaltedOathblade.cs @@ -1,11 +1,8 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Cooldowns; +using CalamityMod.Cooldowns; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -24,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 88; Item.height = 88; - Item.damage = 95; + Item.damage = 90; Item.useAnimation = Item.useTime = 45; Item.useStyle = ItemUseStyleID.Shoot; @@ -47,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void HoldItem(Player player) { player.Calamity().mouseWorldListener = true; - if (player.Calamity().mouseRight && player.Calamity().killModeCooldown == 0 && !Main.mapFullscreen && !Main.blockMouse) + if (player.Calamity().mouseRight && !player.mouseInterface && player.Calamity().killModeCooldown == 0 && !Main.mapFullscreen && !Main.blockMouse) { SoundStyle buff = new("CalamityMod/Sounds/Item/DemonSwordKillMode"); SoundEngine.PlaySound(buff with { Volume = 0.95f }, player.Center); @@ -74,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Melee } if (player.Calamity().demonSwordKillMode && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && player.Calamity().killModeCooldown == KillMode.cooldownMax + KillMode.buffMax) { - Projectile blade = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), Item.damage * 23, Item.knockBack, player.whoAmI, 0, throwCount); + Projectile.NewProjectile(player.GetSource_FromThis(), player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), Item.damage * 14, Item.knockBack, player.whoAmI, 0, throwCount); //This used to be 23x damage. } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Melee/Excelsus.cs b/Items/Weapons/Melee/Excelsus.cs deleted file mode 100644 index 8c5022575a..0000000000 --- a/Items/Weapons/Melee/Excelsus.cs +++ /dev/null @@ -1,74 +0,0 @@ -using CalamityMod.Projectiles.Melee; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - public class Excelsus : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() - { - Item.width = 78; - Item.height = 94; - Item.damage = 250; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = 15; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 15; - Item.useTurn = true; - Item.knockBack = 8f; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; - } - - 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/ExcelsusGlow").Value); - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - for (int index = 0; index < 3; ++index) - { - float SpeedX = velocity.X + Main.rand.NextFloat(-1.5f, 1.5f); - float SpeedY = velocity.Y + Main.rand.NextFloat(-1.5f, 1.5f); - switch (index) - { - case 0: - type = ModContent.ProjectileType(); - break; - case 1: - type = ModContent.ProjectileType(); - break; - case 2: - type = ModContent.ProjectileType(); - break; - } - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - } - return false; - } - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - var source = player.GetSource_ItemUse(Item); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, player.whoAmI); - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - var source = player.GetSource_ItemUse(Item); - Projectile.NewProjectile(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, player.whoAmI); - } - } -} diff --git a/Items/Weapons/Melee/Exoblade.cs b/Items/Weapons/Melee/Exoblade.cs index e13b50b5e5..928c535962 100644 --- a/Items/Weapons/Melee/Exoblade.cs +++ b/Items/Weapons/Melee/Exoblade.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.shoot = ProjectileType(); Item.shootSpeed = 9f; - Item.rare = RarityType(); + Item.rare = RarityType(); } public override bool CanShoot(Player player) @@ -144,8 +144,8 @@ namespace CalamityMod.Items.Weapons.Melee { CreateRecipe(). AddIngredient(). + AddIngredient(). AddIngredient(). - AddIngredient(). AddIngredient(). AddIngredient(). AddTile(TileType()). diff --git a/Items/Weapons/Melee/FallenPaladinsHammer.cs b/Items/Weapons/Melee/FallenPaladinsHammer.cs index 3eac1280c0..4f655380f6 100644 --- a/Items/Weapons/Melee/FallenPaladinsHammer.cs +++ b/Items/Weapons/Melee/FallenPaladinsHammer.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/FaultLine.cs b/Items/Weapons/Melee/FaultLine.cs index 17876a8b2a..28a6fd39e3 100644 --- a/Items/Weapons/Melee/FaultLine.cs +++ b/Items/Weapons/Melee/FaultLine.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/Floodtide.cs b/Items/Weapons/Melee/Floodtide.cs index 67930b7773..746f4822f9 100644 --- a/Items/Weapons/Melee/Floodtide.cs +++ b/Items/Weapons/Melee/Floodtide.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; @@ -16,10 +15,9 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 80; Item.height = 92; - Item.damage = 91; + Item.damage = 85; Item.DamageType = DamageClass.Melee; - Item.useTime = 21; - Item.useAnimation = 21; + Item.useTime = Item.useAnimation = 24; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6f; diff --git a/Items/Weapons/Melee/ForbiddenOathblade.cs b/Items/Weapons/Melee/ForbiddenOathblade.cs index 91545b0bfb..aed26bb46f 100644 --- a/Items/Weapons/Melee/ForbiddenOathblade.cs +++ b/Items/Weapons/Melee/ForbiddenOathblade.cs @@ -1,14 +1,9 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Cooldowns; +using CalamityMod.Cooldowns; using CalamityMod.Dusts; -using CalamityMod.Items.BaseItems; using CalamityMod.Items.Materials; using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; -using Mono.Cecil; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -25,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 74; Item.height = 74; - Item.damage = 44; + Item.damage = 58; Item.useAnimation = Item.useTime = 50; Item.useStyle = ItemUseStyleID.Shoot; @@ -48,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void HoldItem(Player player) { player.Calamity().mouseWorldListener = true; - if (player.Calamity().mouseRight && player.Calamity().killModeCooldown == 0 && !Main.mapFullscreen && !Main.blockMouse) + if (player.Calamity().mouseRight && !player.mouseInterface && player.Calamity().killModeCooldown == 0 && !Main.mapFullscreen && !Main.blockMouse) { SoundStyle buff = new("CalamityMod/Sounds/Item/DemonSwordKillMode"); SoundEngine.PlaySound(buff with { Volume = 0.95f }, player.Center); @@ -75,7 +70,7 @@ namespace CalamityMod.Items.Weapons.Melee } if (player.Calamity().demonSwordKillMode && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && player.Calamity().killModeCooldown == KillMode.cooldownMax + KillMode.buffMax) { - Projectile blade = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.MountedCenter,Vector2.Zero, ModContent.ProjectileType(), Item.damage * 12, Item.knockBack, player.whoAmI, 0, throwCount); + Projectile blade = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.MountedCenter,Vector2.Zero, ModContent.ProjectileType(), Item.damage * 10, Item.knockBack, player.whoAmI, 0, throwCount); // This used to be 12x damage. } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Melee/FourSeasonsGalaxia.cs b/Items/Weapons/Melee/FourSeasonsGalaxia.cs index d729006844..681c4a05ce 100644 --- a/Items/Weapons/Melee/FourSeasonsGalaxia.cs +++ b/Items/Weapons/Melee/FourSeasonsGalaxia.cs @@ -7,7 +7,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using CalamityMod.Systems; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -87,7 +86,7 @@ namespace CalamityMod.Items.Weapons.Melee //.. but just in case if (mainAttunement == null) { - CalamityMod.Instance.Logger.Error("No main attunement on galaxia, couldn't edit its tooltip properly. How the hell did that happen."); + CalamityMod.Log.Error("No main attunement on galaxia, couldn't edit its tooltip properly. How the hell did that happen."); return; } @@ -121,7 +120,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.rare = RarityType(); Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 24f; - Item.reuseDelay = 30; + Item.reuseDelay = 12; } #region saving and syncing attunements @@ -297,7 +296,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(). AddIngredient(). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/GaelsGreatsword.cs b/Items/Weapons/Melee/GaelsGreatsword.cs index 4d78166bc2..dd45adfed8 100644 --- a/Items/Weapons/Melee/GaelsGreatsword.cs +++ b/Items/Weapons/Melee/GaelsGreatsword.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().devItem = true; Item.shoot = ModContent.ProjectileType(); @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void MeleeEffects(Player player, Rectangle hitbox) { var source = player.GetSource_ItemUse(Item); - if (CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), player.whoAmI) < 3 && + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 3 && player.statLife <= player.statLifeMax2 * 0.5f && Main.myPlayer == player.whoAmI) { @@ -80,7 +80,7 @@ namespace CalamityMod.Items.Weapons.Melee Vector2 dustSpawn = t.ToRotationVector2() * r * Item.Size; if (dustSpawn.X > Item.width / 2) { - Dust.NewDustPerfect(player.MountedCenter + dustSpawn.RotatedBy(player.itemRotation) * player.direction, 218, Vector2.Zero).noGravity = true; + Dust.NewDustPerfect(player.MountedCenter + dustSpawn.RotatedBy(player.itemRotation) * player.direction, DustID.Rain_BloodMoon, Vector2.Zero).noGravity = true; } else { diff --git a/Items/Weapons/Melee/GalactusBlade.cs b/Items/Weapons/Melee/GalactusBlade.cs index eeddb62413..9fbcb94c5e 100644 --- a/Items/Weapons/Melee/GalactusBlade.cs +++ b/Items/Weapons/Melee/GalactusBlade.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Security.Cryptography.X509Certificates; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; @@ -30,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 144; Item.height = 146; - Item.damage = 828; + Item.damage = 185; Item.DamageType = DamageClass.Melee; Item.useAnimation = 27; Item.useStyle = ItemUseStyleID.Swing; @@ -40,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item105; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.rare = ModContent.RarityType(); - Item.shoot = ModContent.ProjectileType(); + Item.rare = RarityType(); + Item.shoot = ProjectileType(); Item.shootSpeed = 13f; Item.scale = 0.75f; } @@ -99,7 +97,7 @@ namespace CalamityMod.Items.Weapons.Melee { Vector2 clampedMouse = player.ClampedMouseWorld(); Vector2 spawnSpot = new Vector2(clampedMouse.X, player.Center.Y) + new Vector2(Main.rand.NextFloat(-850, 850), Main.rand.NextFloat(-750, -1250)); - Projectile comet = Projectile.NewProjectileDirect(Item.GetSource_FromThis(), spawnSpot, Utils.DirectionTo(spawnSpot, player.Calamity().mouseWorld + Main.rand.NextVector2Circular(50, 50)) * Item.shootSpeed, Item.shoot, Item.damage / 3, Item.knockBack, player.whoAmI); + Projectile comet = Projectile.NewProjectileDirect(player.GetSource_ItemUse(Item), spawnSpot, Utils.DirectionTo(spawnSpot, player.Calamity().mouseWorld + Main.rand.NextVector2Circular(50, 50)) * Item.shootSpeed, Item.shoot, Item.damage, Item.knockBack, player.whoAmI); comet.extraUpdates = Main.rand.Next(2, 3 + 1); } spawnProj = false; @@ -135,7 +133,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.StarWrath). AddIngredient(10). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/GalaxySmasher.cs b/Items/Weapons/Melee/GalaxySmasher.cs index 4181e6db0e..eba0964390 100644 --- a/Items/Weapons/Melee/GalaxySmasher.cs +++ b/Items/Weapons/Melee/GalaxySmasher.cs @@ -21,10 +21,9 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 86; Item.height = 72; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 1300; + Item.damage = 1180; Item.knockBack = 14f; - Item.useAnimation = 48; - Item.useTime = 48; + Item.useTime = Item.useAnimation = 48; Item.autoReuse = true; Item.noMelee = true; Item.noUseGraphic = true; @@ -32,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item1; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/GalileoGladius.cs b/Items/Weapons/Melee/GalileoGladius.cs index fa34986a90..108b448374 100644 --- a/Items/Weapons/Melee/GalileoGladius.cs +++ b/Items/Weapons/Melee/GalileoGladius.cs @@ -1,38 +1,69 @@ -using CalamityMod.Items.Materials; +using System.Linq; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Melee.Shortswords; using CalamityMod.Rarities; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class GalileoGladius : ModItem, ILocalizedModType + public class GalileoGladius : BaseSwordHoldoutItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + public override int ProjectileType => ModContent.ProjectileType(); + public override bool SizeModifiers => true; public override void SetDefaults() { Item.width = 44; Item.height = 44; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 92; + Item.damage = 600; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 12; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 0.9f; + Item.useAnimation = Item.useTime = 8; Item.knockBack = 10f; Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); + Item.shootSpeed = 10; + base.SetDefaults(); + } + public override void HoldItem(Player player) + { + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); } - public override bool MeleePrefix() => true; + public override bool AltFunctionUse(Player player) + { + return player.Calamity().AvaliableStarburst >= 10; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + var proj = Main.projectile.First(x => x.active && x.type == ModContent.ProjectileType() && x.owner == player.whoAmI); + if (proj.ai[0] > 0) + if (player.altFunctionUse == 2 && player.Calamity().AvaliableStarburst >= 20) + proj.ai[1] = 3; + else + proj.ai[1] = 2; + proj.netUpdate = true; + return false; + } + if (player.altFunctionUse == 2) + { + Projectile.NewProjectile(source,position,velocity*2,ModContent.ProjectileType(),damage,knockback,player.whoAmI); + return false; + } + return base.Shoot(player, source, position, velocity, type, damage, knockback); + } public override void AddRecipes() { CreateRecipe(). @@ -40,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(8). AddIngredient(5). AddIngredient(15). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/GeliticBlade.cs b/Items/Weapons/Melee/GeliticBlade.cs index 7fd0f6babb..5747f80feb 100644 --- a/Items/Weapons/Melee/GeliticBlade.cs +++ b/Items/Weapons/Melee/GeliticBlade.cs @@ -1,8 +1,8 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -11,6 +11,9 @@ namespace CalamityMod.Items.Weapons.Melee public class GeliticBlade : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + + public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/GeliticBladeSwing", 2); + public override void SetDefaults() { Item.width = 44; @@ -22,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 5.25f; - Item.UseSound = SoundID.Item1; + Item.UseSound = UseSound; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; @@ -54,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Melee CreateRecipe(). AddIngredient(18). AddIngredient(18). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Weapons/Melee/GildedProboscis.cs b/Items/Weapons/Melee/GildedProboscis.cs index e278081d7e..baa7683d14 100644 --- a/Items/Weapons/Melee/GildedProboscis.cs +++ b/Items/Weapons/Melee/GildedProboscis.cs @@ -1,39 +1,43 @@ -using CalamityMod.Projectiles.Melee.Spears; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee.Spears; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class GildedProboscis : ModItem, ILocalizedModType + public class GildedProboscis : BaseSwordHoldoutItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + + public override int ProjectileType => ModContent.ProjectileType(); + public override void SetStaticDefaults() { - ItemID.Sets.Spears[Type] = true; + base.SetStaticDefaults(); } - + public override bool SizeModifiers => false; public override void SetDefaults() { Item.width = 66; Item.height = 66; - Item.damage = 315; - Item.DamageType = TrueMeleeDamageClass.Instance; - Item.noMelee = true; - Item.useTurn = true; - Item.noUseGraphic = true; - Item.useAnimation = 19; + Item.damage = 2090; + Item.DamageType = TrueMeleeNoSpeedDamageClass.Instance; + Item.useAnimation = Item.useTime = 65; Item.useStyle = ItemUseStyleID.Shoot; - Item.useTime = 19; - Item.knockBack = 8.75f; - Item.UseSound = SoundID.Item1; + Item.knockBack = 15f; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; - Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 13f; + Item.channel = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + base.SetDefaults(); + } + public override bool AltFunctionUse(Player player) + { + return true; } - - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; } } diff --git a/Items/Weapons/Melee/GoldplumeSpear.cs b/Items/Weapons/Melee/GoldplumeSpear.cs index b870ed806a..cd2cf73cb4 100644 --- a/Items/Weapons/Melee/GoldplumeSpear.cs +++ b/Items/Weapons/Melee/GoldplumeSpear.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee CreateRecipe(). AddIngredient(10). AddIngredient(ItemID.SunplateBlock, 4). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Melee/GrandDad.cs b/Items/Weapons/Melee/GrandDad.cs index ac5bfb214c..19af4012db 100644 --- a/Items/Weapons/Melee/GrandDad.cs +++ b/Items/Weapons/Melee/GrandDad.cs @@ -1,11 +1,14 @@ -using CalamityMod.Items.BaseItems; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework; +using System; using System.Collections.Generic; -using System.Linq; +using CalamityMod.Dusts; +using CalamityMod.Items.BaseItems; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -18,6 +21,10 @@ namespace CalamityMod.Items.Weapons.Melee { public new string LocalizationCategory => "Items.Weapons.Melee"; public static readonly SoundStyle GrandDadEasterEggSound = new("CalamityMod/Sounds/Custom/GFB/GrandDad"); + public Vector2 oldVel = Vector2.Zero; + public int time = 0; + public float highestSpeed = 0; + public bool hitFloor = false; public override void SetDefaults() { Item.width = 124; @@ -54,10 +61,72 @@ namespace CalamityMod.Items.Weapons.Melee CreateRecipe(). AddIngredient(). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } + public override void OnSpawn(IEntitySource source) + { + time = 0; + hitFloor = false; + } + public override void Update(ref float gravity, ref float maxFallSpeed) + { + Vector2 place = Item.Center + Vector2.UnitY * 48; + if (time == 0 && Item.velocity.Y != 0) + { + oldVel = Item.velocity; + Item.velocity = new Vector2(Math.Sign(Item.velocity.X) * 20, -10); + } + if (oldVel.Y != 0 && Item.velocity.Y == 0) + { + time = 0; + float power = Utils.GetLerpValue(35, 75, highestSpeed, true) * 2; + Main.LocalPlayer.SetScreenshake(3.5f * power); + if (power > 0.25f) + { + float blastSize = 150 * power; + float minMultiplier = 0.3f; + int hitsToMinMult = 8; + Projectile blast = Projectile.NewProjectileDirect(Item.GetSource_FromThis(), place, Vector2.Zero, ModContent.ProjectileType(), (int)(Item.damage * 2 * power), -35 * power, -1, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 5; + int particleNumber = (int)Math.Max(15 * power, 2); + for (int i = -particleNumber; i <= particleNumber; i++) + { + Particle sparks = new AltSparkParticle(place, (Vector2.UnitX * (5 + Math.Abs(i)) * Math.Sign(i)).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1) * power, false, Main.rand.Next(17, 30 + 1), Main.rand.NextFloat(0.2f, 0.8f), Main.rand.NextBool() ? Color.Lerp(Color.Blue, Color.DodgerBlue, 0.3f) : Color.Gold); + GeneralParticleHandler.SpawnParticle(sparks); + Dust dust = Dust.NewDustPerfect(place, ModContent.DustType(), (Vector2.UnitX * (5 + Math.Abs(i)) * Math.Sign(i)).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.5f, 1) * power, 0, default, Main.rand.NextFloat(0.85f, 1.2f) * power); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.Blue : Color.DodgerBlue; + } + + SoundStyle sound = new("CalamityMod/Sounds/NPCHit/ExoHit3"); + SoundEngine.PlaySound(sound with { Volume = 0.6f * power, Pitch = Main.rand.NextFloat(0.4f, 0.6f) }, Item.Center); + SoundStyle sound2 = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1"); + SoundEngine.PlaySound(sound2 with { Volume = 0.45f * power, Pitch = -0.2f }, Item.Center); + } + + highestSpeed = 0; + } + if (Item.velocity.Y != 0) + { + if (Item.velocity.Y > 0 && Item.velocity.Y < 75) + { + Item.velocity.X *= 0.98f; + Item.velocity.Y += 0.35f; + Item.velocity.Y *= 1.15f; + } + else + Item.velocity.Y += 0.55f; + time++; + if (highestSpeed < Item.velocity.Y) + highestSpeed = Item.velocity.Y; + } + + gravity = 0; + maxFallSpeed = 75; + oldVel = Item.velocity; + } public override void OnCreated(ItemCreationContext context) { if (Main.zenithWorld) diff --git a/Items/Weapons/Melee/GrandGuardian.cs b/Items/Weapons/Melee/GrandGuardian.cs index 5691d09fe2..3b5ced3498 100644 --- a/Items/Weapons/Melee/GrandGuardian.cs +++ b/Items/Weapons/Melee/GrandGuardian.cs @@ -1,9 +1,7 @@ using CalamityMod.Items.BaseItems; -using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 130; Item.height = 130; - Item.damage = 325; + Item.damage = 515; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = 35; Item.useTime = 35; diff --git a/Items/Weapons/Melee/GreatswordofJudgement.cs b/Items/Weapons/Melee/GreatswordofJudgement.cs index 19486833cb..5b0b5fb1a8 100644 --- a/Items/Weapons/Melee/GreatswordofJudgement.cs +++ b/Items/Weapons/Melee/GreatswordofJudgement.cs @@ -1,85 +1,144 @@ -using CalamityMod.Dusts; +using System; +using CalamityMod.Items.Materials; using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Terraria; using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { public class GreatswordofJudgement : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - private float swingRoatation = 0; - private int time = 0; - private Color mainColor; - private int swordDirection; - private int useTime = 20; - private int opacityAdjust = 0; - private float smearOpacity = 0; + public int time = 0; + public Vector2 bladeHitboxPos; + public float bladeRotation = 0; + public int bladeDirection = 0; + public float completion = 0; + public bool canHit => (completion >= 0.35f && completion <= 0.8f); + public int swingCount = 0; + public bool spawnProj = true; + public bool playSound = true; + + public Color clr = Color.MediumOrchid; + public override void SetDefaults() { Item.width = 78; Item.height = 78; - Item.damage = 155; + Item.damage = 240; Item.DamageType = DamageClass.Melee; Item.useStyle = ItemUseStyleID.Swing; - Item.useAnimation = Item.useTime = useTime; + Item.useAnimation = Item.useTime = 20; Item.useTurn = true; Item.knockBack = 7f; - Item.UseSound = SoundID.Item60; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 5f; + Item.shootSpeed = 5.5f; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + return false; } public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) { - float scale = 1.1f; + // Basically just insures the enemy is always able to be hit if they're in range, the actual collision check is done in CanHitNPC + float scale = 8f; Vector2 newSize = new Point(hitbox.Width, hitbox.Height).ToVector2() * scale; - hitbox = new Rectangle(hitbox.X - (int)((newSize.X - hitbox.Width) / 2f), hitbox.Y - (int)((newSize.Y - hitbox.Height) / 2f), (int)newSize.X, (int)newSize.Y); + hitbox = new Rectangle((int)(bladeHitboxPos.X - newSize.X / 2f), (int)(bladeHitboxPos.Y - newSize.Y / 2f), (int)newSize.X, (int)newSize.Y); + } + public override bool? CanHitNPC(Player player, NPC target) + { + Vector2 mPos = player.Calamity().mouseWorld; + Vector2 shootDir = player.Center.DirectionTo(mPos); + float _ = float.NaN; + bool hitCheck = Collision.CheckAABBvLineCollision(target.Hitbox.TopLeft(), target.Hitbox.Size(), player.Center - shootDir * 30, player.Center + shootDir * 145, Item.width * 3f, ref _); + return ((canHit && hitCheck) ? null : false); } public override void UseAnimation(Player player) { - swordDirection = player.direction; + swingCount++; time = 0; - swingRoatation = 0; - mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; - opacityAdjust = 0; - smearOpacity = 0; + bladeDirection = player.direction; + bladeHitboxPos = player.Center; + bladeRotation = 0; + spawnProj = true; + playSound = true; + int dir = -Math.Sign(player.Center.X - player.Calamity().mouseWorld.X); + float startRot = MathHelper.ToRadians(-90) * dir * (swingCount % 2 == 0 ? 1 : -1); + + clr = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; } public override void MeleeEffects(Player player, Rectangle hitbox) { - opacityAdjust++; - if (opacityAdjust >= 5 && opacityAdjust <= 15 && smearOpacity < 0.9f) - smearOpacity += 0.1f; - else if (smearOpacity > 0) - smearOpacity -= 0.2f; + Vector2 mPos = player.Calamity().mouseWorld; + completion = (float)((float)time / ((float)(Item.useAnimation / player.GetAttackSpeed(DamageClass.Melee)))); + int dir = -Math.Sign(player.Center.X - mPos.X); + + float startRot = MathHelper.ToRadians(-110) * dir * (swingCount % 2 == 0 ? 1 : -1); + float endRot = MathHelper.ToRadians(-110) * dir * (swingCount % 2 == 0 ? -1 : 1); + float minRot = MathHelper.ToRadians(-150) * dir * (swingCount % 2 == 0 ? 1 : -1); + float cutoff = 0.2f; + float cutoff2 = 0.95f; + + Vector2 shootDir = player.Center.DirectionTo(mPos) * Item.shootSpeed; + + if (completion <= cutoff) + { + float lerp = Utils.GetLerpValue(0, cutoff, completion, true); + player.itemRotation = player.Center.DirectionTo(mPos).ToRotation() + MathHelper.Lerp(startRot, minRot, CalamityUtils.EaseInOutExp(lerp, 4f, 4f)); + player.itemRotation += (MathHelper.Pi) * (dir == 1 ? 0 : 1) + MathHelper.PiOver4 * dir; + } + else + { + if (playSound) + { + SoundStyle swing = new("CalamityMod/Sounds/Item/SwooshMid"); + SoundEngine.PlaySound(swing with { Pitch = Main.rand.NextFloat(0.1f, 0.3f), Volume = 1f }, player.Center); + playSound = false; + } + if (completion >= 0.65f && spawnProj) + { + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, shootDir, Item.shoot, Item.damage, Item.knockBack, player.whoAmI, 0f); + + Particle swipe = new CustomSpark(player.Center - shootDir * 5, shootDir.RotatedBy(0.4f * (dir * (swingCount % 2 == 0 ? 1 : -1))) * 2.5f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.6f, clr, new Vector2(1f, 1f), true, false, 0, false, false); + GeneralParticleHandler.SpawnParticle(swipe); + + SoundEngine.PlaySound(SoundID.Item60, player.Center); + spawnProj = false; + } + float lerp = Utils.GetLerpValue(cutoff, cutoff2, completion, true); + player.itemRotation = player.Center.DirectionTo(mPos).ToRotation() + MathHelper.Lerp(minRot, endRot, CalamityUtils.EaseInOutExp(lerp, 6f, 2f)); + player.itemRotation += (MathHelper.Pi) * (dir == 1 ? 0 : 1) + MathHelper.PiOver4 * dir; + } + + float extraRot = (dir == 1 ? -MathHelper.PiOver4 : MathHelper.ToRadians(225)); + bladeHitboxPos = player.Center + (player.itemRotation + extraRot).ToRotationVector2() * 180; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, player.itemRotation + MathHelper.ToRadians(-130) * dir); + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, player.itemRotation + MathHelper.ToRadians(-130) * dir); + + player.itemLocation = player.Center; + player.direction = dir; time++; - swingRoatation += swordDirection == 1 ? 0.13f : -0.13f; - - float Rot = (swordDirection == -1 ? 1.8f : -1.8f) + swingRoatation; - if (swordDirection != player.direction) + } + public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) + { + int beamDamage = player.CalcIntDamage(Item.damage * 0.4f); + Vector2 mouseClamped = player.ClampedMouseWorld(); + SoundEngine.PlaySound(SoundID.Item84 with { Volume = 1f, Pitch = Main.rand.NextFloat(0.5f, 0.7f) }, player.Center); + for (int i = 0; i < 2; i++) { - swingRoatation *= -1; - swordDirection = player.direction; - } - Particle Smear = new SemiCircularSmearFade(player.Center, Vector2.Zero, mainColor * smearOpacity, Rot, Main.rand.NextFloat(1.95f, 2.2f), new Vector2(1, 1), 2, true, false, true, player.direction); - GeneralParticleHandler.SpawnParticle(Smear); - - if (Main.rand.NextBool(3)) - { - Vector2 dustVel = new Vector2(5 * swordDirection, -5).RotatedByRandom(1.55f) * Main.rand.NextFloat(0.7f, 1.3f); - Dust dust = Dust.NewDustPerfect(player.Center + dustVel * 9, 278); - dust.scale = Main.rand.NextFloat(0.4f, 0.55f); - dust.velocity = dustVel * 0.55f; - dust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; - dust.noGravity = true; + Vector2 vel = player.Center.DirectionFrom(target.Center).RotatedByRandom(0.7f) * Main.rand.NextFloat(18, 20); + Projectile.NewProjectile(player.GetSource_ItemUse(Item), player.Center, vel, ModContent.ProjectileType(), beamDamage, 0, player.whoAmI, 0, (i == 0 ? -1 : 1), 1); } } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) @@ -90,6 +149,8 @@ namespace CalamityMod.Items.Weapons.Melee { CreateRecipe(). AddIngredient(ItemID.LunarBar, 7). + AddIngredient(). + AddIngredient(5). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Melee/Greentide.cs b/Items/Weapons/Melee/Greentide.cs index 2c7fe3aabe..7311c1be59 100644 --- a/Items/Weapons/Melee/Greentide.cs +++ b/Items/Weapons/Melee/Greentide.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; @@ -20,16 +21,15 @@ namespace CalamityMod.Items.Weapons.Melee internal const int TotalRows = 2; - internal const int TotalTeeth = 4; + internal const int TotalTeeth = 3; public override void SetDefaults() { Item.width = 62; Item.height = 62; - Item.damage = 87; // IS THAT THE BITE OF '87 + Item.damage = 81; Item.DamageType = DamageClass.Melee; - Item.useTime = 27; - Item.useAnimation = 27; + Item.useTime = Item.useAnimation = 30; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 7f; @@ -46,17 +46,19 @@ namespace CalamityMod.Items.Weapons.Melee } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int i = 0; i < 2; ++i) + for (int i = -2; i <= 2; i++) { - Projectile tooth = Projectile.NewProjectileDirect(source, position, velocity.RotatedBy(-0.1f * (i + 1)).RotatedByRandom(0.06f) * (1 - i * 0.3f), type, (int)(damage * 0.5f), knockback / 3, player.whoAmI, 1f, 0f); + if (i == 0) + { + Projectile strongTooth = Projectile.NewProjectileDirect(source, position, velocity * 1.2f, type, damage, knockback, player.whoAmI, 2f, 0f); + strongTooth.penetrate = -1; + strongTooth.timeLeft = 150; + } + else + { + Projectile.NewProjectile(source, position, velocity.RotatedBy(0.1f * i).RotatedByRandom(0.06f) * (1 - (Math.Abs(i) - 1) * 0.3f), type, (int)(damage * 0.5f), knockback / 3, player.whoAmI, 1f, 0f); + } } - for (int i = 0; i < 2; ++i) - { - Projectile tooth = Projectile.NewProjectileDirect(source, position, velocity.RotatedBy(0.1f * (i + 1)).RotatedByRandom(0.06f) * (1 - i * 0.3f), type, (int)(damage * 0.5f), knockback / 3, player.whoAmI, 1f, 0f); - } - Projectile strongTooth = Projectile.NewProjectileDirect(source, position, velocity * 1.2f, type, (int)(damage), knockback, player.whoAmI, 2f, 0f); - strongTooth.penetrate = -1; - strongTooth.timeLeft = 150; return false; } @@ -81,20 +83,16 @@ namespace CalamityMod.Items.Weapons.Melee int teethDamage = player.CalcIntDamage((int)(Item.damage * 0.1f)); float teethKnockback = Item.knockBack * 0.2f; - bool evenNumberOfProjectiles = TotalTeeth % 2 == 0; - float amountToAdd = evenNumberOfProjectiles ? 0.5f : 0f; int centralProjectile = TotalTeeth / 2; - int otherCentralProjectile = centralProjectile - 1; float teethXVelocityReduction = 0.9f; float minVelocityAdjustment = 0.8f; float maxVelocityAdjustment = 1f; - float velocityAdjustment = minVelocityAdjustment; for (int i = 0; i < TotalRows; i++) { bool topTeeth = i == 0; for (int j = 0; j < TotalTeeth; j++) { - velocityAdjustment = ((j == centralProjectile || j == otherCentralProjectile) && evenNumberOfProjectiles) ? minVelocityAdjustment : MathHelper.Lerp(minVelocityAdjustment, maxVelocityAdjustment, Math.Abs((j + amountToAdd) - centralProjectile) / (float)centralProjectile); + float velocityAdjustment = j == centralProjectile ? minVelocityAdjustment : MathHelper.Lerp(minVelocityAdjustment, maxVelocityAdjustment, Math.Abs(j + 0.5f - centralProjectile) / (float)centralProjectile); if (topTeeth) { position.X += MathHelper.Lerp(-HalvedTeethSpread * 0.3f, HalvedTeethSpread * 0.3f, j / (float)(TotalTeeth - 1)); @@ -131,22 +129,18 @@ namespace CalamityMod.Items.Weapons.Melee Vector2 secondVelocity = (destination - secondPosition).SafeNormalize(Vector2.UnitY) * ShootSpeed; Vector2 secondCachedVelocity = secondVelocity; - int teethDamage = player.CalcIntDamage((int)(Item.damage * 0.5)); + int teethDamage = player.CalcIntDamage((int)(Item.damage * 0.1f)); float teethKnockback = Item.knockBack * 0.2f; - bool evenNumberOfProjectiles = TotalTeeth % 2 == 0; - float amountToAdd = evenNumberOfProjectiles ? 0.5f : 0f; int centralProjectile = TotalTeeth / 2; - int otherCentralProjectile = centralProjectile - 1; float teethXVelocityReduction = 0.9f; float minVelocityAdjustment = 0.8f; float maxVelocityAdjustment = 1f; - float velocityAdjustment = minVelocityAdjustment; for (int i = 0; i < TotalRows; i++) { bool topTeeth = i == 0; for (int j = 0; j < TotalTeeth; j++) { - velocityAdjustment = ((j == centralProjectile || j == otherCentralProjectile) && evenNumberOfProjectiles) ? minVelocityAdjustment : MathHelper.Lerp(minVelocityAdjustment, maxVelocityAdjustment, Math.Abs((j + amountToAdd) - centralProjectile) / (float)centralProjectile); + float velocityAdjustment = j == centralProjectile ? minVelocityAdjustment : MathHelper.Lerp(minVelocityAdjustment, maxVelocityAdjustment, Math.Abs(j + 0.5f - centralProjectile) / (float)centralProjectile); if (topTeeth) { position.X += MathHelper.Lerp(-HalvedTeethSpread, HalvedTeethSpread, j / (float)(TotalTeeth - 1)); @@ -173,7 +167,7 @@ namespace CalamityMod.Items.Weapons.Melee { Vector2 dustVel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.9f, 1.5f); if (Main.rand.NextBool(3)) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 102, dustVel.X, dustVel.Y); + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.Water_Desert, dustVel.X, dustVel.Y); } } } diff --git a/Items/Weapons/Melee/HellionFlowerSpear.cs b/Items/Weapons/Melee/HellionFlowerSpear.cs index d89110439a..94a013896c 100644 --- a/Items/Weapons/Melee/HellionFlowerSpear.cs +++ b/Items/Weapons/Melee/HellionFlowerSpear.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 64; Item.height = 64; - Item.damage = 135; + Item.damage = 85; Item.DamageType = DamageClass.Melee; Item.noMelee = true; Item.useTurn = true; diff --git a/Items/Weapons/Melee/Hellkite.cs b/Items/Weapons/Melee/Hellkite.cs index e3954b3dff..5cb216baa4 100644 --- a/Items/Weapons/Melee/Hellkite.cs +++ b/Items/Weapons/Melee/Hellkite.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 124; Item.height = 124; - Item.damage = 795; + Item.damage = 760; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = Item.useTime = 71; Item.useTurn = true; diff --git a/Items/Weapons/Melee/HolyCollider.cs b/Items/Weapons/Melee/HolyCollider.cs index 8829a63b1c..bb54a11859 100644 --- a/Items/Weapons/Melee/HolyCollider.cs +++ b/Items/Weapons/Melee/HolyCollider.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.BaseItems; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; diff --git a/Items/Weapons/Melee/IllustriousKnives.cs b/Items/Weapons/Melee/IllustriousKnives.cs index 4ccb3cde94..2c7b01de10 100644 --- a/Items/Weapons/Melee/IllustriousKnives.cs +++ b/Items/Weapons/Melee/IllustriousKnives.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; diff --git a/Items/Weapons/Melee/InsidiousImpaler.cs b/Items/Weapons/Melee/InsidiousImpaler.cs index 840223abe1..a47be30daa 100644 --- a/Items/Weapons/Melee/InsidiousImpaler.cs +++ b/Items/Weapons/Melee/InsidiousImpaler.cs @@ -1,5 +1,5 @@ -using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Melee.Spears; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -12,12 +12,11 @@ namespace CalamityMod.Items.Weapons.Melee public class InsidiousImpaler : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() { Item.width = 66; Item.height = 70; - Item.damage = 295; + Item.damage = 300; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noMelee = true; Item.useTurn = true; diff --git a/Items/Weapons/Melee/IridescentExcalibur.cs b/Items/Weapons/Melee/IridescentExcalibur.cs deleted file mode 100644 index 76c749add9..0000000000 --- a/Items/Weapons/Melee/IridescentExcalibur.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Materials; -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.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - [LegacyName("ElementalExcalibur")] - public class IridescentExcalibur : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - - private int MaxBeamTypes = 12; - - private int BeamType = 0; - - private const int Alpha = 100; - - private const float ShootSpeed = 16f; - - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 112; - Item.height = 112; - Item.damage = 3000; - Item.useAnimation = Item.useTime = 15; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTurn = true; - Item.DamageType = DamageClass.Melee; - Item.knockBack = 8f; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = ShootSpeed; - Item.rare = ModContent.RarityType(); - Item.shootsEveryUse = true; - } - - public override void UseStyle(Player player, Rectangle heldItemFrame) - { - player.itemLocation += new Vector2(-12f * player.direction, 2f * player.gravDir).RotatedBy(player.itemRotation); - } - - 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/IridescentExcaliburGlow").Value); - } - - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 10; - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (player.altFunctionUse == 2) - { - float adjustedItemScale = player.GetAdjustedItemScale(Item); - Projectile.NewProjectile(source, player.MountedCenter, new Vector2(player.direction, 0f), ModContent.ProjectileType(), damage, knockback, player.whoAmI, (float)player.direction * player.gravDir, player.itemAnimationMax, adjustedItemScale); - Projectile.NewProjectile(source, player.MountedCenter, new Vector2(player.direction, 0f), ModContent.ProjectileType(), 0, knockback, player.whoAmI, (float)player.direction * player.gravDir, player.itemAnimationMax, adjustedItemScale); - Projectile.NewProjectile(source, player.MountedCenter, new Vector2(player.direction, 0f), ModContent.ProjectileType(), 0, knockback, player.whoAmI, (float)player.direction * player.gravDir, player.itemAnimationMax, adjustedItemScale); - NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, player.whoAmI); - } - else - { - int proj = Projectile.NewProjectile(source, position, velocity, type, (int)Math.Round(damage * 0.5), knockback * 0.5f, player.whoAmI, (float)BeamType); - if (BeamType == 7) - Main.projectile[proj].penetrate = 3; - - BeamType++; - if (BeamType >= MaxBeamTypes) - BeamType = 0; - } - - return false; - } - - public override bool AltFunctionUse(Player player) => true; - - public override bool? UseItem(Player player) - { - Item.noMelee = player.altFunctionUse == 2; - return base.UseItem(player); - } - - public override void ModifyHitNPC(Player player, NPC target, ref NPC.HitModifiers modifiers) - { - if (player.altFunctionUse == 2) - modifiers.SourceDamage *= 2; - } - - public override void ModifyHitPvp(Player player, Player target, ref Player.HurtModifiers modifiers) - { - if (player.altFunctionUse == 2) - modifiers.SourceDamage *= 2; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool()) - { - Color rainbowColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Alpha); - Color color = Color.White; - int dustChoice = player.altFunctionUse == 2 ? Main.rand.Next(12) : BeamType; - switch (dustChoice) - { - case 0: // Red - color = new Color(255, 0, 0, Alpha); - break; - case 1: // Orange - color = new Color(255, 128, 0, Alpha); - break; - case 2: // Yellow - color = new Color(255, 255, 0, Alpha); - break; - case 3: // Lime - color = new Color(128, 255, 0, Alpha); - break; - case 4: // Green - color = new Color(0, 255, 0, Alpha); - break; - case 5: // Turquoise - color = new Color(0, 255, 128, Alpha); - break; - case 6: // Cyan - color = new Color(0, 255, 255, Alpha); - break; - case 7: // Light Blue - color = new Color(0, 128, 255, Alpha); - break; - case 8: // Blue - color = new Color(0, 0, 255, Alpha); - break; - case 9: // Purple - color = new Color(128, 0, 255, Alpha); - break; - case 10: // Fuschia - color = new Color(255, 0, 255, Alpha); - break; - case 11: // Hot Pink - color = new Color(255, 0, 128, Alpha); - break; - default: - break; - } - - Dust rainbow = Main.dust[Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.RainbowMk2)]; - rainbow.velocity *= 0f; - rainbow.color = Color.Lerp(rainbowColor, color, (float)Math.Sqrt((MathF.Cos(Main.GlobalTimeWrappedHourly / 60f) + 1f) * 0.5f)); - rainbow.color.A = 100; - rainbow.scale = Main.rand.NextFloat(1.2f, 1.6f); - rainbow.fadeIn = Main.rand.NextFloat(0.4f, 1f); - rainbow.noGravity = true; - } - } - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 600); - target.AddBuff(ModContent.BuffType(), 60); - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - target.AddBuff(ModContent.BuffType(), 600); - target.AddBuff(ModContent.BuffType(), 60); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.TrueExcalibur). - AddIngredient(). - AddIngredient(3). - AddIngredient(15). - AddTile(). - Register(); - } - } -} diff --git a/Items/Weapons/Melee/IridescentExcalibur.png b/Items/Weapons/Melee/IridescentExcalibur.png deleted file mode 100644 index 5ff82d5ac7..0000000000 Binary files a/Items/Weapons/Melee/IridescentExcalibur.png and /dev/null differ diff --git a/Items/Weapons/Melee/IridescentExcaliburGlow.png b/Items/Weapons/Melee/IridescentExcaliburGlow.png deleted file mode 100644 index e122aef76b..0000000000 Binary files a/Items/Weapons/Melee/IridescentExcaliburGlow.png and /dev/null differ diff --git a/Items/Weapons/Melee/Lacerator.cs b/Items/Weapons/Melee/Lacerator.cs index f0b0564e82..53d2f6cc00 100644 --- a/Items/Weapons/Melee/Lacerator.cs +++ b/Items/Weapons/Melee/Lacerator.cs @@ -1,9 +1,7 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.Rarities; -using CalamityMod.World; using Terraria; using Terraria.ID; using Terraria.Localization; @@ -31,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 30; Item.height = 26; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 152; + Item.damage = 115; Item.knockBack = 7f; Item.useTime = 20; Item.useAnimation = 20; @@ -56,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Melee { CreateRecipe(). AddIngredient(4). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/LifehuntScythe.cs b/Items/Weapons/Melee/LifehuntScythe.cs index 54c3aaf1e1..ae3eeebd78 100644 --- a/Items/Weapons/Melee/LifehuntScythe.cs +++ b/Items/Weapons/Melee/LifehuntScythe.cs @@ -1,5 +1,4 @@ -using CalamityMod.Enums; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -38,31 +37,13 @@ namespace CalamityMod.Items.Weapons.Melee Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.CursedTorch); } - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - if (player.moonLeech || player.lifeSteal <= 0f || target.lifeMax <= 5) - return; - - int heal = 5; - player.lifeSteal -= heal; - player.HealPlayer(heal); - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - if (player.moonLeech || player.lifeSteal <= 0f) - return; - - int heal = 5; - player.lifeSteal -= heal; - player.HealPlayer(heal); - } + public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) => player.DoLifestealDirect(target, 5, 0.5f); public override void AddRecipes() { CreateRecipe(). AddIngredient(15). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/Lightspeed.cs b/Items/Weapons/Melee/Lightspeed.cs new file mode 100644 index 0000000000..97b6bc2f38 --- /dev/null +++ b/Items/Weapons/Melee/Lightspeed.cs @@ -0,0 +1,65 @@ +using CalamityMod.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + [LegacyName("ElementalShortsword", "ElementalShiv")] + public class Lightspeed : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + + public static int MaxEnergy = 100; + + public override void SetDefaults() + { + Item.width = 74; + Item.height = 94; + Item.useStyle = ItemUseStyleID.Shoot; + Item.damage = 234; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useAnimation = Item.useTime = 20; + Item.shootSpeed = 10f; + Item.knockBack = 2f; + Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; + Item.rare = ItemRarityID.Purple; + Item.shoot = ModContent.ProjectileType(); + + Item.noMelee = true; + Item.noUseGraphic = true; + + Item.autoReuse = true; + Item.channel = true; + base.SetDefaults(); + } + + // You can only use the right-click if you have sufficient Elemental Mastery + public override bool AltFunctionUse(Player player) => player.Calamity().elementalMastery >= 100; + + public override void HoldItem(Player player) + { + if (player.Calamity().cooldowns.TryGetValue(ElementalMastery.ID, out var cooldown)) + { + cooldown.timeLeft = player.Calamity().elementalMastery; + } + else + { + player.AddCooldown(ElementalMastery.ID, 0); + } + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.PiercingStarlight). + AddIngredient(). + AddIngredient(ItemID.LunarBar, 5). + AddIngredient(5). + AddIngredient(ItemID.FragmentSolar, 5). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/Melee/StarburstShiv.png b/Items/Weapons/Melee/Lightspeed.png similarity index 100% rename from Items/Weapons/Melee/StarburstShiv.png rename to Items/Weapons/Melee/Lightspeed.png diff --git a/Items/Weapons/Melee/StarburstShivGlow.png b/Items/Weapons/Melee/LightspeedGlow.png similarity index 100% rename from Items/Weapons/Melee/StarburstShivGlow.png rename to Items/Weapons/Melee/LightspeedGlow.png diff --git a/Items/Weapons/Melee/Lucrecia.cs b/Items/Weapons/Melee/Lucrecia.cs index e9a0937621..ff151ba276 100644 --- a/Items/Weapons/Melee/Lucrecia.cs +++ b/Items/Weapons/Melee/Lucrecia.cs @@ -1,41 +1,63 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee.Shortswords; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class Lucrecia : ModItem, ILocalizedModType + public class Lucrecia : BaseSwordHoldoutItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; + public static int MaxEnergy = 100; + + public override int ProjectileType => ModContent.ProjectileType(); + public override void SetDefaults() { Item.width = 54; Item.height = 54; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 90; + Item.useStyle = ItemUseStyleID.Shoot; + Item.damage = 170; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 30; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 4.2f; + Item.useAnimation = Item.useTime = 34; + Item.shootSpeed = 10f; Item.knockBack = 8.25f; - Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; + + Item.autoReuse = true; + Item.channel = true; + // Item.noMelee = true; + // Item.noUseGraphic = true; + base.SetDefaults(); + } - public override bool MeleePrefix() => true; + public override bool AltFunctionUse(Player player) => player.Calamity().darklightEnergy >= MaxEnergy; + + public override void HoldItem(Player player) + { + if (player.Calamity().cooldowns.TryGetValue(DarklightEnergy.ID, out var cooldown)) + { + cooldown.timeLeft = player.Calamity().darklightEnergy; + } + else + { + player.AddCooldown(DarklightEnergy.ID, 0); + } + } + + // public override bool MeleePrefix() => true; public override void AddRecipes() { CreateRecipe(). AddIngredient(5). - AddIngredient(). + AddIngredient(ItemID.FallenStar, 10). AddIngredient(ItemID.SoulofLight, 5). AddIngredient(ItemID.SoulofNight, 5). AddTile(TileID.MythrilAnvil). diff --git a/Items/Weapons/Melee/MajesticGuard.cs b/Items/Weapons/Melee/MajesticGuard.cs index f61f948bca..98046d1acc 100644 --- a/Items/Weapons/Melee/MajesticGuard.cs +++ b/Items/Weapons/Melee/MajesticGuard.cs @@ -3,7 +3,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 100; Item.height = 100; - Item.damage = 325; + Item.damage = 365; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = 50; Item.useTime = 50; diff --git a/Items/Weapons/Melee/MantisClaws.cs b/Items/Weapons/Melee/MantisClaws.cs index e088461822..74d26cb6f7 100644 --- a/Items/Weapons/Melee/MantisClaws.cs +++ b/Items/Weapons/Melee/MantisClaws.cs @@ -1,17 +1,8 @@ -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; +using CalamityMod.Items.BaseItems; +using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; -using CalamityMod.Items.BaseItems; using Terraria.ModLoader; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using CalamityMod.Balancing; -using Terraria.Audio; -using CalamityMod.Projectiles.Melee; -using System; -using CalamityMod.Particles; namespace CalamityMod.Items.Weapons.Melee { @@ -20,10 +11,9 @@ namespace CalamityMod.Items.Weapons.Melee public new string LocalizationCategory => "Items.Weapons.Melee"; public override void SetDefaults() { - base.SetDefaults(); Item.width = 26; Item.height = 20; - Item.damage = 111; + Item.damage = 75; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 25; Item.knockBack = 0.25f; @@ -39,5 +29,6 @@ namespace CalamityMod.Items.Weapons.Melee } public override bool AltFunctionUse(Player player) => true; + public override bool MeleePrefix() => true; } } diff --git a/Items/Weapons/Melee/MawOfInfinity.cs b/Items/Weapons/Melee/MawOfInfinity.cs new file mode 100644 index 0000000000..1cfcd0745f --- /dev/null +++ b/Items/Weapons/Melee/MawOfInfinity.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + [LegacyName("Excelsus")] + public class MawOfInfinity: BaseSwordHoldoutItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + public override int ProjectileType => ModContent.ProjectileType(); + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + } + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplaceAll("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); + } + public override void SetDefaults() + { + Item.width = 78; + Item.height = 94; + Item.damage = 2080; + Item.DamageType = DamageClass.Melee; + Item.useTime = Item.useAnimation = 33; + Item.useStyle = ItemUseStyleID.Swing; + Item.useTurn = true; + Item.knockBack = 8f; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 12f; + base.SetDefaults(); + } + + 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/MawOfInfinityGlow").Value); + } + } +} diff --git a/Items/Weapons/Melee/Excelsus.png b/Items/Weapons/Melee/MawOfInfinity.png similarity index 100% rename from Items/Weapons/Melee/Excelsus.png rename to Items/Weapons/Melee/MawOfInfinity.png diff --git a/Items/Weapons/Melee/ExcelsusGlow.png b/Items/Weapons/Melee/MawOfInfinityGlow.png similarity index 100% rename from Items/Weapons/Melee/ExcelsusGlow.png rename to Items/Weapons/Melee/MawOfInfinityGlow.png diff --git a/Items/Weapons/Melee/MirrorBlade.cs b/Items/Weapons/Melee/MirrorBlade.cs index beda17aa01..bd822fed9e 100644 --- a/Items/Weapons/Melee/MirrorBlade.cs +++ b/Items/Weapons/Melee/MirrorBlade.cs @@ -1,47 +1,166 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class MirrorBlade : ModItem, ILocalizedModType + public class MirrorBlade : BaseSwordHoldoutItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Weapons.Melee"; - private int baseDamage = 100; + public bool HasFlavorTooltip => true; + public override int ProjectileType => ModContent.ProjectileType(); + internal const float SlashProjectileDamageMultiplier = 0.5f; + internal const int SlashProjectileLimit = 4; + internal const int SlashCreationRate = 18; + + public int reflectTimer = 0; + + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 5)); + ItemID.Sets.AnimatesAsSoul[Type] = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + base.SetStaticDefaults(); + } public override void SetDefaults() { - Item.width = 72; - Item.height = 72; - Item.damage = baseDamage; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = 12; - Item.useTime = 12; + Item.width = 114; + Item.height = 128; + Item.damage = 550; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useAnimation = 40; + Item.useTime = 40; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 7f; - Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.shootSpeed = 9f; Item.shoot = ModContent.ProjectileType(); + base.SetDefaults(); } - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) + public override bool CanUseItem(Player player) { - int conDamage = target.damage + baseDamage; - if (conDamage < baseDamage) + return base.CanUseItem(player); + } + + public override void UpdateInventory(Player player) + { + if (reflectTimer > 0) { - conDamage = baseDamage; + if (reflectTimer <= 50) + { + + float coneLength = 96f; + float maximumAngle = 1f; + float coneRotation = player.DirectionTo(Main.MouseWorld).ToRotation(); + var shardCount = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && (proj.ModProjectile as MirrorBlast).isShard) + { + shardCount++; + } + } + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.type == ModContent.ProjectileType() && proj.ModProjectile().time >= 29) + { + if (shardCount > 0) + { + SoundEngine.PlaySound(SeekingScorcher.LightShatterSound, player.Center); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath, player.Center); + } + if (shardCount >= 10) + { + player.SetImmuneTimeForAllTypes(player.longInvince ? 60 : 30); + } + proj.Calamity().multiplicativeDR += shardCount / 10f; + proj.Calamity().multiplicativeDRTimer = 60; + foreach (var proj2 in Main.projectile) + { + if (proj2.active && proj2.type == ModContent.ProjectileType() && proj2.owner == player.whoAmI && (proj2.ModProjectile as MirrorBlast).isShard) + { + proj2.damage = (int)(proj2.damage * (shardCount >= 10 ? 3f : 2f)); + (proj2.ModProjectile as MirrorBlast).shardShield = 0; + (proj2.ModProjectile as MirrorBlast).shardNum = 11; + proj2.netUpdate = true; + } + } + reflectTimer = 0; + return; + } else + if (proj.hostile && proj.damage > 0 && proj.Hitbox.IntersectsConeSlowMoreAccurate(player.Center, coneLength, coneRotation, maximumAngle)) + { + if (shardCount > 0) + { + SoundEngine.PlaySound(SeekingScorcher.LightShatterSound, player.Center); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath, player.Center); + } + if (shardCount >= 10) + { + player.SetImmuneTimeForAllTypes(player.longInvince ? 60 : 30); + } + proj.Calamity().multiplicativeDR += shardCount / 10f; + proj.Calamity().multiplicativeDRTimer = 60; + foreach (var proj2 in Main.projectile) + { + if (proj2.active && proj2.type == ModContent.ProjectileType() && proj2.owner == player.whoAmI && (proj2.ModProjectile as MirrorBlast).isShard) + { + proj2.damage = (int)(proj2.damage * (shardCount >= 10 ? 3f : 2f)); + (proj2.ModProjectile as MirrorBlast).shardShield = 0; + (proj2.ModProjectile as MirrorBlast).shardNum = 11; + proj2.netUpdate = true; + } + } + reflectTimer = 0; + return; + } + } + } + reflectTimer--; } - if (conDamage > 400) + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse == 2) { - conDamage = 400; + bool alreadyReflecting = reflectTimer > 0; + bool hasShard = false; + reflectTimer = 60; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && (proj.ModProjectile as MirrorBlast).isShard) + { + (proj.ModProjectile as MirrorBlast).shardShield = 60; + proj.netUpdate = true; + hasShard = true; + } + } + + if (!alreadyReflecting && hasShard) + SoundEngine.PlaySound(SoundID.DD2_EtherianPortalSpawnEnemy,player.Center); + return false; } - Item.damage = conDamage; + return base.Shoot(player, source, position, velocity, type, damage, knockback); + } + + + public override bool AltFunctionUse(Player player) + { + return true; } } } diff --git a/Items/Weapons/Melee/MirrorBlade.png b/Items/Weapons/Melee/MirrorBlade.png index 5247456d75..3af0672f28 100644 Binary files a/Items/Weapons/Melee/MirrorBlade.png and b/Items/Weapons/Melee/MirrorBlade.png differ diff --git a/Items/Weapons/Melee/MonolithSword.cs b/Items/Weapons/Melee/MonolithSword.cs index 79100057a1..911473b62a 100644 --- a/Items/Weapons/Melee/MonolithSword.cs +++ b/Items/Weapons/Melee/MonolithSword.cs @@ -1,5 +1,5 @@ using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Weapons/Melee/MonstrousKnives.cs b/Items/Weapons/Melee/MonstrousKnives.cs index 2b512bb0b4..4dff8f0547 100644 --- a/Items/Weapons/Melee/MonstrousKnives.cs +++ b/Items/Weapons/Melee/MonstrousKnives.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.ThrowingKnife, 200). + AddIngredient(ItemID.ThrowingKnife, 50). AddIngredient(ItemID.LifeCrystal). AddIngredient(ItemID.LesserHealingPotion, 5). AddTile(TileID.Anvils). diff --git a/Items/Weapons/Melee/Mourningstar.cs b/Items/Weapons/Melee/Mourningstar.cs index c04ecb3315..672286eabd 100644 --- a/Items/Weapons/Melee/Mourningstar.cs +++ b/Items/Weapons/Melee/Mourningstar.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(6). AddIngredient(6). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index aec2123d1a..b7a00a61d5 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 90; Item.height = 134; - Item.damage = 2222; + Item.damage = 2001; Item.DamageType = TrueMeleeNoSpeedDamageClass.Instance; Item.noMelee = true; Item.noUseGraphic = true; @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 24f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Melee/MycelialClaws.cs b/Items/Weapons/Melee/MycelialClaws.cs index d8ed6d9a09..5a63926a6f 100644 --- a/Items/Weapons/Melee/MycelialClaws.cs +++ b/Items/Weapons/Melee/MycelialClaws.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Items/Weapons/Melee/Nadir.cs b/Items/Weapons/Melee/Nadir.cs index 4ba4e5d206..e8edf14bad 100644 --- a/Items/Weapons/Melee/Nadir.cs +++ b/Items/Weapons/Melee/Nadir.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/Nebulash.cs b/Items/Weapons/Melee/Nebulash.cs index b6c96a6a50..ee11b955df 100644 --- a/Items/Weapons/Melee/Nebulash.cs +++ b/Items/Weapons/Melee/Nebulash.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -14,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 16; Item.height = 16; - Item.damage = 60; + Item.damage = 85; Item.rare = ItemRarityID.Lime; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/NeptunesBounty.cs b/Items/Weapons/Melee/NeptunesBounty.cs index 91c8905696..4e680798df 100644 --- a/Items/Weapons/Melee/NeptunesBounty.cs +++ b/Items/Weapons/Melee/NeptunesBounty.cs @@ -1,10 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -42,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(). AddIngredient(6). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/Oblivion.cs b/Items/Weapons/Melee/Oblivion.cs index 33ee8074d6..142c3e5f28 100644 --- a/Items/Weapons/Melee/Oblivion.cs +++ b/Items/Weapons/Melee/Oblivion.cs @@ -1,5 +1,5 @@ -using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee.Yoyos; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 28; Item.height = 38; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 55; + Item.damage = 50; Item.knockBack = 4f; Item.useTime = 22; Item.useAnimation = 22; diff --git a/Items/Weapons/Melee/OldLordClaymore.cs b/Items/Weapons/Melee/OldLordClaymore.cs index 8151d67e9f..82d8b08a91 100644 --- a/Items/Weapons/Melee/OldLordClaymore.cs +++ b/Items/Weapons/Melee/OldLordClaymore.cs @@ -1,5 +1,7 @@ using CalamityMod.Items.BaseItems; using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,9 +15,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - Item.width = 70; - Item.height = 70; - Item.damage = 202; + Item.width = 76; + Item.height = 76; + Item.damage = 144; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = Item.useTime = 90; // Yes it's actually supposed to be this slow @@ -31,6 +33,10 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; } + 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/OldLordClaymoreGlow").Value); + } public override bool MeleePrefix() => true; public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 11; } diff --git a/Items/Weapons/Melee/OldLordClaymore.png b/Items/Weapons/Melee/OldLordClaymore.png index 9326b47f1e..3ac3266613 100644 Binary files a/Items/Weapons/Melee/OldLordClaymore.png and b/Items/Weapons/Melee/OldLordClaymore.png differ diff --git a/Items/Weapons/Melee/OldLordClaymoreGlow.png b/Items/Weapons/Melee/OldLordClaymoreGlow.png new file mode 100644 index 0000000000..1dc3c129f5 Binary files /dev/null and b/Items/Weapons/Melee/OldLordClaymoreGlow.png differ diff --git a/Items/Weapons/Melee/Orderbringer.cs b/Items/Weapons/Melee/Orderbringer.cs index d4192e2eda..657b17ab47 100644 --- a/Items/Weapons/Melee/Orderbringer.cs +++ b/Items/Weapons/Melee/Orderbringer.cs @@ -1,131 +1,195 @@ -using CalamityMod.Items.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria.Audio; -using Terraria.ID; using Microsoft.Xna.Framework; -using Terraria.ModLoader; -using CalamityMod.Particles; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; -using Basic.Reference.Assemblies; -using System; -using Mono.Cecil; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { [LegacyName("GreatswordofBlah")] + [LegacyName("IridescentExcalibur")] public class Orderbringer : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - private float swingRoatation = 0; - private int time = 0; - private Color mainColor; - private int swordDirection; - private int useTime = 18; - private int opacityAdjust = 0; - private float smearOpacity = 0; + public int time = 0; + public Vector2 bladeHitboxPos; + public float bladeRotation = 0; + public int bladeDirection = 0; + public float completion = 0; + public bool canHit => (completion >= 0.35f && completion <= 0.8f); + public int swingCount = 0; + public bool spawnProj = true; + public bool playSound = true; public override void SetDefaults() { - Item.width = Item.height = 108; - Item.damage = 415; + Item.width = Item.height = 112; + Item.damage = 840; Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = useTime; + Item.useAnimation = Item.useTime = 16; Item.useStyle = ItemUseStyleID.Swing; Item.useTurn = true; Item.knockBack = 8f; - Item.UseSound = SoundID.Item60; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 5.5f; } 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, type, damage, knockback, player.whoAmI, 0f); - - for (int i = 0; i < 4; i++) - { - Vector2 vel = (velocity * 2.5f).RotatedByRandom(0.6f); - Projectile.NewProjectile(source, player.ClampedMouseWorld() - (velocity * 40) + Main.rand.NextVector2Circular(130, 130), vel * Main.rand.NextFloat(0.8f, 1.2f), ModContent.ProjectileType(), (int)(damage * 0.1f), knockback * 0.2f, player.whoAmI, 0, 0, 1); - } return false; } public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) { - float scale = 1.2f; + // Basically just insures the enemy is always able to be hit if they're in range, the actual collision check is done in CanHitNPC + float scale = 8f; Vector2 newSize = new Point(hitbox.Width, hitbox.Height).ToVector2() * scale; - hitbox = new Rectangle(hitbox.X - (int)((newSize.X - hitbox.Width) / 2f), hitbox.Y - (int)((newSize.Y - hitbox.Height) / 2f), (int)newSize.X, (int)newSize.Y); + hitbox = new Rectangle((int)(bladeHitboxPos.X - newSize.X / 2f), (int)(bladeHitboxPos.Y - newSize.Y / 2f), (int)newSize.X, (int)newSize.Y); + } + public override bool? CanHitNPC(Player player, NPC target) + { + Vector2 mPos = player.Calamity().mouseWorld; + Vector2 shootDir = player.Center.DirectionTo(mPos); + float _ = float.NaN; + bool hitCheck = Collision.CheckAABBvLineCollision(target.Hitbox.TopLeft(), target.Hitbox.Size(), player.Center - shootDir * 30, player.Center + shootDir * 245, Item.width * 3f, ref _); + return ((canHit && hitCheck) ? null : false); } public override void UseAnimation(Player player) { - swordDirection = player.direction; + swingCount++; time = 0; - swingRoatation = 0; - mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; - opacityAdjust = 0; - smearOpacity = 0; + bladeDirection = player.direction; + bladeHitboxPos = player.Center; + bladeRotation = 0; + spawnProj = true; + playSound = true; + int dir = -Math.Sign(player.Center.X - player.Calamity().mouseWorld.X); + float startRot = MathHelper.ToRadians(-90) * dir * (swingCount % 2 == 0 ? 1 : -1); } public override void MeleeEffects(Player player, Rectangle hitbox) { - opacityAdjust++; - if (opacityAdjust >= 5 && opacityAdjust <= 15 && smearOpacity < 0.9f) - smearOpacity += 0.1f; - else if (smearOpacity > 0) - smearOpacity -= 0.2f; + Vector2 mPos = player.Calamity().mouseWorld; + completion = (float)((float)time / ((float)(Item.useAnimation / player.GetAttackSpeed(DamageClass.Melee)))); + int dir = -Math.Sign(player.Center.X - mPos.X); + + float startRot = MathHelper.ToRadians(-110) * dir * (swingCount % 2 == 0 ? 1 : -1); + float endRot = MathHelper.ToRadians(-110) * dir * (swingCount % 2 == 0 ? -1 : 1); + float minRot = MathHelper.ToRadians(-150) * dir * (swingCount % 2 == 0 ? 1 : -1); + float cutoff = 0.2f; + float cutoff2 = 0.95f; + + Vector2 shootDir = player.Center.DirectionTo(mPos) * Item.shootSpeed; + + if (completion <= cutoff) + { + float lerp = Utils.GetLerpValue(0, cutoff, completion, true); + player.itemRotation = player.Center.DirectionTo(mPos).ToRotation() + MathHelper.Lerp(startRot, minRot, CalamityUtils.EaseInOutExp(lerp, 4f, 4f)); + player.itemRotation += (MathHelper.Pi) * (dir == 1 ? 0 : 1) + MathHelper.PiOver4 * dir; + } + else + { + if (playSound) + { + SoundStyle swing = new("CalamityMod/Sounds/Item/SwooshMid"); + SoundEngine.PlaySound(swing with { Pitch = Main.rand.NextFloat(0.1f, 0.3f), Volume = 1f }, player.Center); + playSound = false; + } + if (completion >= 0.65f && spawnProj) + { + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, shootDir, Item.shoot, Item.damage, Item.knockBack, player.whoAmI, 0f); + + for (int i = 0; i < 4; i++) + { + float rot = Main.rand.NextFloat(0.5f, 0.65f) * (Main.rand.NextBool() ? 1 : -1); + Vector2 vel = (shootDir * 2.5f).RotatedByRandom(0.6f); + Projectile.NewProjectile(player.GetSource_FromThis(), player.ClampedMouseWorld() - (shootDir * 40) + Main.rand.NextVector2Circular(130, 130), vel.RotatedBy(rot) * Main.rand.NextFloat(0.9f, 1.2f), ModContent.ProjectileType(), (int)(Item.damage * 0.12f), (int)(Item.knockBack * 0.2f), player.whoAmI, 0, rot, 1); + } + + Particle swipe = new CustomSpark(player.Center - shootDir * 5, shootDir.RotatedBy(0.4f * (dir * (swingCount % 2 == 0 ? 1 : -1))) * 2.5f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.8f, player.Calamity().lightRGB, new Vector2(1f, 1f), true, false, 0, false, false); + GeneralParticleHandler.SpawnParticle(swipe); + + SoundEngine.PlaySound(SoundID.Item60, player.Center); + spawnProj = false; + } + float lerp = Utils.GetLerpValue(cutoff, cutoff2, completion, true); + player.itemRotation = player.Center.DirectionTo(mPos).ToRotation() + MathHelper.Lerp(minRot, endRot, CalamityUtils.EaseInOutExp(lerp, 6f, 2f)); + player.itemRotation += (MathHelper.Pi) * (dir == 1 ? 0 : 1) + MathHelper.PiOver4 * dir; + } + + float extraRot = (dir == 1 ? -MathHelper.PiOver4 : MathHelper.ToRadians(225)); + bladeHitboxPos = player.Center + (player.itemRotation + extraRot).ToRotationVector2() * 240; + Vector2 tipPos = player.Center + (player.itemRotation + extraRot).ToRotationVector2() * 180; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, player.itemRotation + MathHelper.ToRadians(-130) * dir); + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, player.itemRotation + MathHelper.ToRadians(-130) * dir); + + player.itemLocation = player.Center; + player.direction = dir; time++; - swingRoatation += swordDirection == 1 ? 0.17f : -0.17f; - - float Rot = (swordDirection == -1 ? 1.8f : -1.8f) + swingRoatation; - if (swordDirection != player.direction) - { - swingRoatation *= -1; - swordDirection = player.direction; - } - Particle Smear = new SemiCircularSmearFade(player.Center, Vector2.Zero, mainColor * smearOpacity, Rot, Main.rand.NextFloat(2.8f, 3.2f), new Vector2(1, 1), 2, true, false, true, player.direction); - GeneralParticleHandler.SpawnParticle(Smear); - - if (Main.rand.NextBool()) - { - Vector2 dustVel = new Vector2(5 * swordDirection, -5).RotatedByRandom(1.55f) * Main.rand.NextFloat(0.7f, 1.3f) * 2; - Dust dust = Dust.NewDustPerfect(player.Center + dustVel * 9, 278); - dust.scale = Main.rand.NextFloat(0.5f, 0.75f); - dust.velocity = dustVel * 0.55f; - dust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; - dust.noGravity = true; - } } public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - int beamDamage = player.CalcIntDamage(Item.damage * 0.5f); + int beamDamage = player.CalcIntDamage(Item.damage * 0.4f); Vector2 mouseClamped = player.ClampedMouseWorld(); + SoundEngine.PlaySound(SoundID.Item84 with { Volume = 1f, Pitch = Main.rand.NextFloat(0.5f, 0.7f)}, player.Center); for (int i = 0; i < 2; i++) { Vector2 targetPos = Main.MouseWorld; NPC target2 = Main.MouseWorld.ClosestNPCAt(650); if (target2 != null) - targetPos = target2.Center + target2.velocity * 14; + targetPos = target2.Center; Vector2 spawnPos = mouseClamped + new Vector2(Main.rand.NextFloat(-300, 300), -900); Vector2 vel = (targetPos - spawnPos).SafeNormalize(Vector2.UnitY) * 10; Projectile.NewProjectile(player.GetSource_ItemUse(Item), spawnPos, vel, ModContent.ProjectileType(), beamDamage, 0, player.whoAmI); } } + public override void ModifyTooltips(List list) + { + Player Owner = Main.LocalPlayer; + if (Owner is null) + return; + + float rate = Main.GlobalTimeWrappedHourly * 7; + List eColors = new List() + { + Color.PaleVioletRed, + Color.Coral, + Color.Khaki, + Color.PaleGreen, + Color.Turquoise, + Color.Violet + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color finalColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip2"); + if (line != null) + line.OverrideColor = Color.Lerp(finalColor, Color.White, 0.3f); + } 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/OrderbringerGlow").Value); } - public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(8). - AddIngredient(20). + AddIngredient(5). + AddIngredient(5). AddTile(). Register(); } diff --git a/Items/Weapons/Melee/Orderbringer.png b/Items/Weapons/Melee/Orderbringer.png index ade13f44bf..5ff82d5ac7 100644 Binary files a/Items/Weapons/Melee/Orderbringer.png and b/Items/Weapons/Melee/Orderbringer.png differ diff --git a/Items/Weapons/Melee/OrderbringerGlow.png b/Items/Weapons/Melee/OrderbringerGlow.png index 8c6448103a..e122aef76b 100644 Binary files a/Items/Weapons/Melee/OrderbringerGlow.png and b/Items/Weapons/Melee/OrderbringerGlow.png differ diff --git a/Items/Weapons/Melee/Ozzathoth.cs b/Items/Weapons/Melee/Ozzathoth.cs new file mode 100644 index 0000000000..5259795122 --- /dev/null +++ b/Items/Weapons/Melee/Ozzathoth.cs @@ -0,0 +1,63 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee.Yoyos; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + [LegacyName("Azathoth")] + public class Ozzathoth : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + + public static float Reach = 880f; + public static float Speed = 60f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(Reach.ToTiles(), Speed); + + public override void SetStaticDefaults() + { + ItemID.Sets.Yoyo[Type] = true; + ItemID.Sets.GamepadExtraRange[Type] = 15; + ItemID.Sets.GamepadSmartQuickReach[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 40; + Item.height = 54; + Item.DamageType = DamageClass.MeleeNoSpeed; + Item.damage = 90; + Item.knockBack = 6f; + Item.useTime = 20; + Item.useAnimation = 20; + Item.autoReuse = true; + + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = SoundID.Item1; + Item.channel = true; + Item.noUseGraphic = true; + Item.noMelee = true; + + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 16f; + + Item.autoReuse = true; + Item.rare = ModContent.RarityType(); + Item.Calamity().devItem = true; + Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.Terrarian). + AddIngredient(5). + AddIngredient(2). + AddTile(). + Register(); + } + } +} diff --git a/Items/Weapons/Melee/Azathoth.png b/Items/Weapons/Melee/Ozzathoth.png similarity index 100% rename from Items/Weapons/Melee/Azathoth.png rename to Items/Weapons/Melee/Ozzathoth.png diff --git a/Items/Weapons/Melee/Pandemic.cs b/Items/Weapons/Melee/Pandemic.cs index 49c829b756..f6e8d04a94 100644 --- a/Items/Weapons/Melee/Pandemic.cs +++ b/Items/Weapons/Melee/Pandemic.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/PerfectDark.cs b/Items/Weapons/Melee/PerfectDark.cs index 666b744d04..1579b0affa 100644 --- a/Items/Weapons/Melee/PerfectDark.cs +++ b/Items/Weapons/Melee/PerfectDark.cs @@ -1,5 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; @@ -37,14 +37,5 @@ namespace CalamityMod.Items.Weapons.Melee { target.AddBuff(ModContent.BuffType(), 300); } - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.DemoniteBar, 5). - AddIngredient(15). - AddIngredient(ItemID.RottenChunk, 5). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Melee/PhotonRipper.cs b/Items/Weapons/Melee/PhotonRipper.cs index 067ee83e3b..8faaf618d0 100644 --- a/Items/Weapons/Melee/PhotonRipper.cs +++ b/Items/Weapons/Melee/PhotonRipper.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 1f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } diff --git a/Items/Weapons/Melee/PrismaticBreaker.cs b/Items/Weapons/Melee/PrismaticBreaker.cs index 20941fbed8..369c603161 100644 --- a/Items/Weapons/Melee/PrismaticBreaker.cs +++ b/Items/Weapons/Melee/PrismaticBreaker.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Tools; +using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; @@ -8,7 +6,6 @@ using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -17,34 +14,13 @@ namespace CalamityMod.Items.Weapons.Melee public class PrismaticBreaker : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - internal static readonly Color[] colors = new Color[] - { - new Color(255, 0, 0, 50), //Red - new Color(255, 128, 0, 50), //Orange - new Color(255, 255, 0, 50), //Yellow - new Color(128, 255, 0, 50), //Lime - new Color(0, 255, 0, 50), //Green - new Color(0, 255, 128, 50), //Turquoise - new Color(0, 255, 255, 50), //Cyan - new Color(0, 128, 255, 50), //Light Blue - new Color(0, 0, 255, 50), //Blue - new Color(128, 0, 255, 50), //Purple - new Color(255, 0, 255, 50), //Fuschia - new Color(255, 0, 128, 50) //Hot Pink - }; - - public override void SetStaticDefaults() - { - Item.staff[Type] = true; - - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; - } + public override void SetStaticDefaults() => Item.staff[Type] = true; public override void SetDefaults() { Item.width = 50; Item.height = 50; - Item.damage = 300; + Item.damage = 425; Item.useStyle = ItemUseStyleID.Shoot; Item.useAnimation = Item.useTime = 13; Item.reuseDelay = 30; @@ -56,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 14f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Weapons/Melee/Pwnagehammer.cs b/Items/Weapons/Melee/Pwnagehammer.cs index 4c0510417d..0b0e47fa19 100644 --- a/Items/Weapons/Melee/Pwnagehammer.cs +++ b/Items/Weapons/Melee/Pwnagehammer.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 66; Item.height = 66; - Item.damage = 210; + Item.damage = 150; Item.noMelee = true; Item.noUseGraphic = true; Item.autoReuse = true; diff --git a/Items/Weapons/Melee/Quagmire.cs b/Items/Weapons/Melee/Quagmire.cs index 93827b8f25..4e6f6f1fcd 100644 --- a/Items/Weapons/Melee/Quagmire.cs +++ b/Items/Weapons/Melee/Quagmire.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -27,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 30; Item.height = 36; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 52; + Item.damage = 54; Item.knockBack = 3.5f; Item.useTime = 22; Item.useAnimation = 22; diff --git a/Items/Weapons/Melee/RemsRevenge.cs b/Items/Weapons/Melee/RemsRevenge.cs index 6b59d9ff1b..9be51a7c3a 100644 --- a/Items/Weapons/Melee/RemsRevenge.cs +++ b/Items/Weapons/Melee/RemsRevenge.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.BlueMoon). AddIngredient(ItemID.LunarBar, 5). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/Riptide.cs b/Items/Weapons/Melee/Riptide.cs index 1803c1123e..ddff94048a 100644 --- a/Items/Weapons/Melee/Riptide.cs +++ b/Items/Weapons/Melee/Riptide.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/SaharaSlicers.cs b/Items/Weapons/Melee/SaharaSlicers.cs index 40549fec04..415b9f6834 100644 --- a/Items/Weapons/Melee/SaharaSlicers.cs +++ b/Items/Weapons/Melee/SaharaSlicers.cs @@ -1,6 +1,6 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Melee.Shortswords; -using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -18,6 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + } public override void SetDefaults() { diff --git a/Items/Weapons/Melee/SaharaSlicers.png b/Items/Weapons/Melee/SaharaSlicers.png index d3667f574b..aecbe93345 100644 Binary files a/Items/Weapons/Melee/SaharaSlicers.png and b/Items/Weapons/Melee/SaharaSlicers.png differ diff --git a/Items/Weapons/Melee/SausageMaker.cs b/Items/Weapons/Melee/SausageMaker.cs index d43d86bd7f..437408836f 100644 --- a/Items/Weapons/Melee/SausageMaker.cs +++ b/Items/Weapons/Melee/SausageMaker.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee.Spears; +using CalamityMod.Projectiles.Melee.Spears; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -36,15 +35,5 @@ namespace CalamityMod.Items.Weapons.Melee } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 4). - AddIngredient(12). - AddIngredient(ItemID.Vertebrae, 4). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Melee/ScourgeoftheCosmos.cs b/Items/Weapons/Melee/ScourgeoftheCosmos.cs index 3eaaa817b5..a94b2dfeaa 100644 --- a/Items/Weapons/Melee/ScourgeoftheCosmos.cs +++ b/Items/Weapons/Melee/ScourgeoftheCosmos.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = Item.height = 64; - Item.damage = 478; + Item.damage = 380; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noMelee = true; Item.noUseGraphic = true; @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item109; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; } diff --git a/Items/Weapons/Melee/SeekingScorcher.cs b/Items/Weapons/Melee/SeekingScorcher.cs index f7fb0a7c67..c12e7a7fdf 100644 --- a/Items/Weapons/Melee/SeekingScorcher.cs +++ b/Items/Weapons/Melee/SeekingScorcher.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; -using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 86; Item.height = 64; - Item.damage = 718; + Item.damage = 1100; Item.DamageType = DamageClass.MeleeNoSpeed; Item.useAnimation = Item.useTime = 55; Item.knockBack = 8.5f; @@ -43,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.PossessedHatchet). AddIngredient(5). AddIngredient(8). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/Shimmerspark.cs b/Items/Weapons/Melee/Shimmerspark.cs index 526fd23df7..464e024176 100644 --- a/Items/Weapons/Melee/Shimmerspark.cs +++ b/Items/Weapons/Melee/Shimmerspark.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/SkytideDragoon.cs b/Items/Weapons/Melee/SkytideDragoon.cs index ec33a45b04..fea9b76093 100644 --- a/Items/Weapons/Melee/SkytideDragoon.cs +++ b/Items/Weapons/Melee/SkytideDragoon.cs @@ -1,10 +1,9 @@ using CalamityMod.Items.BaseItems; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,12 +12,11 @@ namespace CalamityMod.Items.Weapons.Melee public class SkytideDragoon : CustomUseProjItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() { Item.width = 86; Item.height = 94; - Item.damage = 345; + Item.damage = 365; Item.DamageType = DamageClass.Melee; Item.useAnimation = 35; Item.useTime = 35; diff --git a/Items/Weapons/Melee/SmokingComet.cs b/Items/Weapons/Melee/SmokingComet.cs index 8fe6c66857..a95510aa7e 100644 --- a/Items/Weapons/Melee/SmokingComet.cs +++ b/Items/Weapons/Melee/SmokingComet.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -27,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 36; Item.height = 40; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 21; + Item.damage = 17; Item.knockBack = 1.5f; Item.useTime = 25; Item.useAnimation = 25; diff --git a/Items/Weapons/Melee/SpineOfThanatos.cs b/Items/Weapons/Melee/SpineOfThanatos.cs index 6b9de5cab9..aeeb946f60 100644 --- a/Items/Weapons/Melee/SpineOfThanatos.cs +++ b/Items/Weapons/Melee/SpineOfThanatos.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = Item.height = 28; Item.damage = 128; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.noMelee = true; Item.noUseGraphic = true; Item.channel = true; diff --git a/Items/Weapons/Melee/StarburstShiv.cs b/Items/Weapons/Melee/StarburstShiv.cs deleted file mode 100644 index 5fdd6a0f4f..0000000000 --- a/Items/Weapons/Melee/StarburstShiv.cs +++ /dev/null @@ -1,50 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee.Shortswords; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - [LegacyName("ElementalShortsword", "ElementalShiv")] - public class StarburstShiv : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - - public override void SetDefaults() - { - Item.width = 74; - Item.height = 94; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Rapier; - Item.damage = 138; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = Item.useTime = 13; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 2.4f; - Item.knockBack = 8.5f; - Item.UseSound = SoundID.Item1; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; - } - - public override bool MeleePrefix() => true; - - 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/StarburstShivGlow").Value); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.PiercingStarlight). - AddIngredient(ItemID.LunarBar, 5). - AddIngredient(5). - AddIngredient(ItemID.FragmentSolar, 5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index 7179fb521f..caa4050981 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -1,9 +1,5 @@ -using System; -using CalamityMod.Items.BaseItems; +using CalamityMod.Items.BaseItems; using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -17,10 +13,9 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 100; Item.height = 118; - Item.damage = 56; + Item.damage = 143; Item.DamageType = TrueMeleeDamageClass.Instance; - - Item.useAnimation = Item.useTime = 33; + Item.useAnimation = Item.useTime = 28; Item.useTurn = true; Item.knockBack = 7.75f; diff --git a/Items/Weapons/Melee/StormRuler.cs b/Items/Weapons/Melee/StormRuler.cs index cf8ce8d329..9bb6c6e6e5 100644 --- a/Items/Weapons/Melee/StormRuler.cs +++ b/Items/Weapons/Melee/StormRuler.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Items/Weapons/Melee/StormSaber.cs b/Items/Weapons/Melee/StormSaber.cs index 4df89ae204..723257bc87 100644 --- a/Items/Weapons/Melee/StormSaber.cs +++ b/Items/Weapons/Melee/StormSaber.cs @@ -14,10 +14,9 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 58; Item.height = 64; - Item.damage = 66; + Item.damage = 50; Item.DamageType = DamageClass.Melee; - Item.useAnimation = 23; - Item.useTime = 23; + Item.useTime = Item.useAnimation = 23; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6f; @@ -31,17 +30,15 @@ namespace CalamityMod.Items.Weapons.Melee 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, type, (int)(damage * 0.8), knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); Vector2 spawnPos = new Vector2(player.MountedCenter.X + Main.rand.Next(-200, 201), player.MountedCenter.Y - 600f); // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Vector2 targetPos = Main.MouseWorld + new Vector2(Main.rand.Next(-30, 31), Main.rand.Next(-30, 31)); - velocity = targetPos - spawnPos; - velocity.Normalize(); - velocity *= 13f; + velocity = Utils.DirectionTo(spawnPos, targetPos) * Item.shootSpeed; - Projectile.NewProjectile(source, spawnPos, velocity, type, (int)(damage * 0.6), knockback, player.whoAmI); + Projectile.NewProjectile(source, spawnPos, velocity, type, (int)(damage * 0.75), knockback, player.whoAmI); return false; } diff --git a/Items/Weapons/Melee/StreamGouge.cs b/Items/Weapons/Melee/StreamGouge.cs index 7358ae671f..759d565a3d 100644 --- a/Items/Weapons/Melee/StreamGouge.cs +++ b/Items/Weapons/Melee/StreamGouge.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 100; Item.height = 100; - Item.damage = 500; + Item.damage = 470; Item.DamageType = DamageClass.Melee; Item.noMelee = true; Item.useTurn = true; @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Weapons/Melee/StygianShield.cs b/Items/Weapons/Melee/StygianShield.cs index a2c212cbd7..53f56777d9 100644 --- a/Items/Weapons/Melee/StygianShield.cs +++ b/Items/Weapons/Melee/StygianShield.cs @@ -91,7 +91,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void UpdateEquips() { - if (Player.ActiveItem().type == ModContent.ItemType()) + if (Player.HeldItem.type == ModContent.ItemType()) { Player.hasRaisableShield = true; Player.statDefense += StygianShield.HeldDefense; @@ -111,7 +111,7 @@ namespace CalamityMod.Items.Weapons.Melee // Overrides every other shield in accessories public override void UpdateVisibleVanityAccessories() { - if (Player.ActiveItem().type == ModContent.ItemType()) + if (Player.HeldItem.type == ModContent.ItemType()) { Player.shield = EquipLoader.GetEquipSlot(Mod, "StygianShield", EquipType.Shield); Player.cShield = 0; diff --git a/Items/Weapons/Melee/SubmarineShocker.cs b/Items/Weapons/Melee/SubmarineShocker.cs index 3ec096138d..d2c61af5a5 100644 --- a/Items/Weapons/Melee/SubmarineShocker.cs +++ b/Items/Weapons/Melee/SubmarineShocker.cs @@ -1,5 +1,5 @@ -using CalamityMod.Projectiles.Melee.Shortswords; -using Terraria; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee.Shortswords; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/SulphurousGrabber.cs b/Items/Weapons/Melee/SulphurousGrabber.cs index f6815107aa..91e8f8d9e9 100644 --- a/Items/Weapons/Melee/SulphurousGrabber.cs +++ b/Items/Weapons/Melee/SulphurousGrabber.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Items/Weapons/Melee/Swordsplosion.cs b/Items/Weapons/Melee/Swordsplosion.cs index ad10265c3a..be38aa1993 100644 --- a/Items/Weapons/Melee/Swordsplosion.cs +++ b/Items/Weapons/Melee/Swordsplosion.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; @@ -95,5 +96,14 @@ namespace CalamityMod.Items.Weapons.Melee Main.dust[swingDust].noGravity = true; } } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddIngredient(15). + AddTile(TileID.MythrilAnvil). + Register(); + } } } diff --git a/Items/Weapons/Melee/TaintedBlade.cs b/Items/Weapons/Melee/TaintedBlade.cs index eb0e887f73..d48de63d99 100644 --- a/Items/Weapons/Melee/TaintedBlade.cs +++ b/Items/Weapons/Melee/TaintedBlade.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 46; Item.height = 46; - Item.damage = 60; + Item.damage = 48; Item.DamageType = DamageClass.Melee; Item.useTurn = true; Item.useAnimation = 27; @@ -23,8 +23,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.knockBack = 5f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; } public override void MeleeEffects(Player player, Rectangle hitbox) @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(10). AddRecipeGroup("Boss2Material", 8). AddIngredient(ItemID.Deathweed, 2). - AddTile(TileID.DemonAltar). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Melee/TenebreusTides.cs b/Items/Weapons/Melee/TenebreusTides.cs index f92d002223..9721c5f584 100644 --- a/Items/Weapons/Melee/TenebreusTides.cs +++ b/Items/Weapons/Melee/TenebreusTides.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Melee.Spears; using Terraria; diff --git a/Items/Weapons/Melee/Terratomere.cs b/Items/Weapons/Melee/Terratomere.cs index 519bed62e3..b8b499265d 100644 --- a/Items/Weapons/Melee/Terratomere.cs +++ b/Items/Weapons/Melee/Terratomere.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.TerraBlade). AddIngredient(7). AddIngredient(9). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/TerrorBlade.cs b/Items/Weapons/Melee/TerrorBlade.cs index e85ba3366f..c05314d34c 100644 --- a/Items/Weapons/Melee/TerrorBlade.cs +++ b/Items/Weapons/Melee/TerrorBlade.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -12,7 +13,6 @@ namespace CalamityMod.Items.Weapons.Melee { public new string LocalizationCategory => "Items.Weapons.Melee"; internal const float TerrorBlastMultiplier = 0.3f; - public override void SetDefaults() { Item.width = 88; diff --git a/Items/Weapons/Melee/TheBurningSky.cs b/Items/Weapons/Melee/TheBurningSky.cs index a4e26ae751..161909dfc0 100644 --- a/Items/Weapons/Melee/TheBurningSky.cs +++ b/Items/Weapons/Melee/TheBurningSky.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -17,7 +18,6 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { - // Visually a sword, but with no true melee capability. The Burning Sky is held out like a staff. Item.staff[Type] = true; } @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.shootSpeed = 14f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Melee/TheEnforcer.cs b/Items/Weapons/Melee/TheEnforcer.cs deleted file mode 100644 index b027454e91..0000000000 --- a/Items/Weapons/Melee/TheEnforcer.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using CalamityMod.Items.Materials; -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.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Melee -{ - public class TheEnforcer : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() - { - Item.width = 100; - Item.height = 100; - Item.damage = 890; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = 17; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 17; - Item.useTurn = true; - Item.knockBack = 9f; - Item.UseSound = SoundID.Item20; - Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - } - - 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/TheEnforcerGlow").Value); - } - - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - var source = player.GetSource_ItemUse(Item); - SoundEngine.PlaySound(SoundID.Item73, player.Center); - int i = Main.myPlayer; - float flameSpeed = 3f; - player.itemTime = Item.useTime; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = Main.mouseX + Main.screenPosition.X + realPlayerPos.X; - float mouseYDist = Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = player.direction; - mouseYDist = 0f; - mouseDistance = flameSpeed; - } - else - { - mouseDistance = flameSpeed / mouseDistance; - } - - int essenceDamage = player.CalcIntDamage(0.25f * Item.damage); - for (int j = 0; j < 5; j++) - { - realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); - realPlayerPos.Y -= 100 * j; - mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); - mouseDistance = flameSpeed / mouseDistance; - Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); - } - } - - public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) - { - var source = player.GetSource_ItemUse(Item); - SoundEngine.PlaySound(SoundID.Item73, player.Center); - int j = Main.myPlayer; - float flameSpeed = 3f; - player.itemTime = Item.useTime; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = Main.mouseX + Main.screenPosition.X + realPlayerPos.X; - float mouseYDist = Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = player.direction; - mouseYDist = 0f; - mouseDistance = flameSpeed; - } - else - { - mouseDistance = flameSpeed / mouseDistance; - } - - int essenceDamage = player.CalcIntDamage(0.25f * Item.damage); - for (int i = 0; i < 5; i++) - { - realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); - realPlayerPos.Y -= 100 * i; - mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); - mouseDistance = flameSpeed / mouseDistance; - Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); - } - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(3)) - Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.ShadowbeamStaff); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(12). - AddTile(). - Register(); - } - } -} diff --git a/Items/Weapons/Melee/TheEnforcer.png b/Items/Weapons/Melee/TheEnforcer.png deleted file mode 100644 index 1bebf830c6..0000000000 Binary files a/Items/Weapons/Melee/TheEnforcer.png and /dev/null differ diff --git a/Items/Weapons/Melee/TheEnforcerGlow.png b/Items/Weapons/Melee/TheEnforcerGlow.png deleted file mode 100644 index b1041824c6..0000000000 Binary files a/Items/Weapons/Melee/TheEnforcerGlow.png and /dev/null differ diff --git a/Items/Weapons/Melee/TheGodsGambit.cs b/Items/Weapons/Melee/TheGodsGambit.cs index d17e980aa4..2a95e484ab 100644 --- a/Items/Weapons/Melee/TheGodsGambit.cs +++ b/Items/Weapons/Melee/TheGodsGambit.cs @@ -1,7 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Yoyos; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -52,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Melee CreateRecipe(). AddIngredient(18). AddIngredient(18). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Weapons/Melee/TheLastMourning.cs b/Items/Weapons/Melee/TheLastMourning.cs index ebe94fe490..ee6e286544 100644 --- a/Items/Weapons/Melee/TheLastMourning.cs +++ b/Items/Weapons/Melee/TheLastMourning.cs @@ -35,8 +35,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - bool isDoGSegment = target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); - if (!isDoGSegment || Main.rand.NextBool(3)) + if (target.type != ModContent.NPCType() || Main.rand.NextBool(3)) { CalamityPlayer.HorsemansBladeOnHit(player, target.whoAmI, Item.damage, Item.knockBack, 0, ModContent.ProjectileType()); CalamityPlayer.HorsemansBladeOnHit(player, target.whoAmI, Item.damage, Item.knockBack, 1); @@ -80,7 +79,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.SoulofNight, 30). AddIngredient(5). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/TheMicrowave.cs b/Items/Weapons/Melee/TheMicrowave.cs index 21be661ebd..b93466528a 100644 --- a/Items/Weapons/Melee/TheMicrowave.cs +++ b/Items/Weapons/Melee/TheMicrowave.cs @@ -1,5 +1,5 @@ -using CalamityMod.Projectiles.Melee.Yoyos; -using Terraria; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee.Yoyos; using Terraria.Audio; using Terraria.ID; using Terraria.Localization; diff --git a/Items/Weapons/Melee/TheMutilator.cs b/Items/Weapons/Melee/TheMutilator.cs index 0c217455a0..3f71b02898 100644 --- a/Items/Weapons/Melee/TheMutilator.cs +++ b/Items/Weapons/Melee/TheMutilator.cs @@ -1,82 +1,86 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Melee { - public class TheMutilator : ModItem, ILocalizedModType + public class TheMutilator : BaseSwordHoldoutItem, ILocalizedModType { + public static int MaximumCharge = 7; + public int Charge = 0; + + public int DecayTimer = 0; public new string LocalizationCategory => "Items.Weapons.Melee"; + public override int ProjectileType => ModContent.ProjectileType(); public override void SetDefaults() { Item.width = 90; Item.height = 90; - Item.damage = 483; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = 18; + Item.damage = 1005; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 18; - Item.useTurn = true; + Item.useTime = 30; Item.knockBack = 8f; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; Item.shootSpeed = 10f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); + base.SetDefaults(); } - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 240); - if (target.life <= (target.lifeMax * 0.2f)) + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) + { + damage *= 1 + Charge / 7f; + } + public override void UpdateInventory(Player player) + { + if (DecayTimer > 0) DecayTimer--; + else { - if (!CalamityPlayer.areThereAnyDamnBosses || Main.rand.NextBool()) + if (Charge > 0) { - int heartDrop = CalamityPlayer.areThereAnyDamnBosses ? 1 : Main.rand.Next(1, 3); - for (int i = 0; i < heartDrop; i++) - { - Item.NewItem(player.GetSource_OnHit(target), (int)target.position.X, (int)target.position.Y, target.width, target.height, 58, 1, false, 0, false, false); - } - } - SoundEngine.PlaySound(SoundID.Item14, target.Center); - target.position.X += target.width / 2; - target.position.Y += target.height / 2; - target.position.X -= target.width / 2; - target.position.Y -= target.height / 2; - for (int i = 0; i < 30; i++) - { - int bloodDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[bloodDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[bloodDust].scale = 0.5f; - Main.dust[bloodDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 50; j++) - { - int bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.Blood, 0f, 0f, 100, default, 3f); - Main.dust[bloodDust2].noGravity = true; - Main.dust[bloodDust2].velocity *= 5f; - bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.Blood, 0f, 0f, 100, default, 2f); - Main.dust[bloodDust2].velocity *= 2f; + Charge--; + DecayTimer = 60; } } } + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + float fill = Charge / (float)MaximumCharge; + if (fill <= 0) + return; + + float barScale = 3f; + + var barBG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; + var barFG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; + + Vector2 barOrigin = barBG.Size() * 0.5f; + float yOffset = 44f; + Vector2 drawPos = position + Vector2.UnitY * scale * (frame.Height - yOffset); + Rectangle frameCrop = new Rectangle(0, 0, (int)((fill) * barFG.Width), barFG.Height); + Color colorBG = Color.Crimson; + Color colorFG = Color.Lerp(Color.OrangeRed, Color.DarkOrange, fill); + + spriteBatch.Draw(barBG, drawPos, null, colorBG, 0f, barOrigin, scale * barScale, 0f, 0f); + spriteBatch.Draw(barFG, drawPos, frameCrop, colorFG, 0f, barOrigin, scale * barScale, 0f, 0f); + } + + public override void AddRecipes() { CreateRecipe(). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/TheObliterator.cs b/Items/Weapons/Melee/TheObliterator.cs index 61674ef152..274426a673 100644 --- a/Items/Weapons/Melee/TheObliterator.cs +++ b/Items/Weapons/Melee/TheObliterator.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.Rarities; using Terraria; @@ -15,6 +17,12 @@ namespace CalamityMod.Items.Weapons.Melee public static float Reach = 720f; public static float Speed = 54f; public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(Reach.ToTiles(), Speed); + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); + if (!Main.zenithWorld) + tooltips.FindAndReplaceAll("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); + } public override void SetStaticDefaults() { @@ -28,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 42; Item.height = 40; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 222; + Item.damage = 475; Item.knockBack = 7.5f; Item.useTime = 20; Item.useAnimation = 20; @@ -44,8 +52,9 @@ namespace CalamityMod.Items.Weapons.Melee Item.shootSpeed = 16f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } - public override void ModifyTooltips(List list) => list.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; } } diff --git a/Items/Weapons/Melee/TheOracle.cs b/Items/Weapons/Melee/TheOracle.cs index 7bf5027c5c..100bef55bb 100644 --- a/Items/Weapons/Melee/TheOracle.cs +++ b/Items/Weapons/Melee/TheOracle.cs @@ -2,9 +2,6 @@ using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -50,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.shootSpeed = 16f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs index c24a749c40..9edfa0d77f 100644 --- a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs +++ b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs @@ -2,7 +2,6 @@ using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,11 +16,11 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 168; Item.height = 168; - Item.damage = 5000; + Item.damage = 2000; Item.noMelee = true; Item.noUseGraphic = true; Item.autoReuse = true; - Item.useAnimation = Item.useTime = 36; + Item.useAnimation = Item.useTime = 40; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 14f; Item.UseSound = SoundID.Item1; diff --git a/Items/Weapons/Melee/TrueArkoftheAncients.cs b/Items/Weapons/Melee/TrueArkoftheAncients.cs index bce0c1ee8b..965503a687 100644 --- a/Items/Weapons/Melee/TrueArkoftheAncients.cs +++ b/Items/Weapons/Melee/TrueArkoftheAncients.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee public float Charge = 0f; public static float chargeDamageMultiplier = 1.25f; //Extra damage from charge public static float beamDamageMultiplier = 1f; //Damage multiplier for the charged shots (remember it applies ontop of the charge damage multiplied - public static float glassStarDamageMultiplier = 0.6f; //Damage multiplier for the glass stars it shoots (Shoots 3x glass stars when not charged, shoots 2x glass stars + one beam when charged) + public static float glassStarDamageMultiplier = 1f; //Damage multiplier for the glass stars it shoots (Shoots 3x glass stars when not charged, shoots 2x glass stars + one beam when charged) public override void ModifyTooltips(List tooltips) { @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = Item.height = 72; - Item.damage = 194; + Item.damage = 130; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noUseGraphic = true; Item.noMelee = true; @@ -103,7 +103,6 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(source, player.Center - Shift, velocity.RotatedBy(-MathHelper.PiOver4 * 0.3f), ProjectileType(), (int)(damage * glassStarDamageMultiplier), knockback, player.whoAmI, Charge > 0 ? 1 : 0); } - Charge--; if (Charge < 0) Charge = 0; diff --git a/Items/Weapons/Melee/TrueBiomeBlade.cs b/Items/Weapons/Melee/TrueBiomeBlade.cs index 2dbd3efbd9..36b0850ef5 100644 --- a/Items/Weapons/Melee/TrueBiomeBlade.cs +++ b/Items/Weapons/Melee/TrueBiomeBlade.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Melee #region stats public static int BaseDamage = 115; - public static int DefaultAttunement_BaseDamage = 100; + public static int DefaultAttunement_BaseDamage = 90; public static int DefaultAttunement_SigilTime = 900; public static int DefaultAttunement_BeamTime = 90; public static float DefaultAttunement_LungeDamageMult = 2f; @@ -48,27 +48,27 @@ namespace CalamityMod.Items.Weapons.Melee public static float EvilAttunement_SlashDamageBoost = 3f; public static int EvilAttunement_SlashIFrames = 60; - public static int ColdAttunement_BaseDamage = 150; + public static int ColdAttunement_BaseDamage = 140; public static float ColdAttunement_ThirdSwingBoost = 1.25f; public static float ColdAttunement_MistDamageReduction = 0.11f; - public static int HotAttunement_BaseDamage = 135; + public static int HotAttunement_BaseDamage = 126; public static int HotAttunement_PlayerShredIFrames = 8; public static float HotAttunement_ShotDamageBoost = 4.5f; public static int HotAttunement_LocalIFrames = 24; //Be warned its got one extra update so all the iframes should be divided in 2 public static float HotAttunement_ShredDecayRate = 0.65f; //How much charge is lost per frame. - public static int TropicalAttunement_BaseDamage = 150; + public static int TropicalAttunement_BaseDamage = 132; public static float TropicalAttunement_ChainDamageReduction = 0.6f; public static float TropicalAttunement_VineDamageReduction = 0.3f; public static float TropicalAttunement_SweetSpotDamageMultiplier = 1.5f; //It also crits, so be mindful of that public static int TropicalAttunement_LocalIFrames = 60; //Be warned its got 2 extra updates so all the iframes should be divided in 3 - public static int HolyAttunement_BaseDamage = 66; - public static float HolyAttunement_BaseSwingDamageMult = 0.75f; - public static float HolyAttunement_FullSwingDamageMult = 1.5f; - public static float HolyAttunement_ThrowDamageBoost = 3.8f; - public static int HolyAttunement_LocalIFrames = 16; //Be warned its got 1 extra update yadda yadda + public static int HolyAttunement_BaseDamage = 84; + public static float HolyAttunement_BaseSwingDamageMult = 0.5f; + public static float HolyAttunement_FullSwingDamageMult = 1f; + public static float HolyAttunement_ThrowDamageBoost = 3f; + public static int HolyAttunement_LocalIFrames = 20; //Be warned its got 1 extra update yadda yadda public static float HolyAttunement_MonolithDamage = 0.5f; #endregion diff --git a/Items/Weapons/Melee/TrueCausticEdge.cs b/Items/Weapons/Melee/TrueCausticEdge.cs index ccfead5620..30f48ba898 100644 --- a/Items/Weapons/Melee/TrueCausticEdge.cs +++ b/Items/Weapons/Melee/TrueCausticEdge.cs @@ -1,7 +1,6 @@ using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -60,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(). AddRecipeGroup("CursedFlameIchor", 8). AddIngredient(ItemID.SpiderFang, 8). - AddTile(TileID.DemonAltar). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Melee/Tumbleweed.cs b/Items/Weapons/Melee/Tumbleweed.cs index 3b237302bb..2a919c9a8b 100644 --- a/Items/Weapons/Melee/Tumbleweed.cs +++ b/Items/Weapons/Melee/Tumbleweed.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.MaceFlails; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -35,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Melee { CreateRecipe(). AddIngredient(ItemID.Sunfury). + AddIngredient(ItemID.AncientCloth, 5). AddIngredient(). - AddIngredient(ItemID.SoulofMight, 5). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Melee/TyphonsGreed.cs b/Items/Weapons/Melee/TyphonsGreed.cs index e2d8e61327..cb45e00330 100644 --- a/Items/Weapons/Melee/TyphonsGreed.cs +++ b/Items/Weapons/Melee/TyphonsGreed.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Projectiles.Melee; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 16; Item.height = 16; - Item.damage = 62; + Item.damage = 60; Item.DamageType = DamageClass.Melee; Item.useTime = 30; Item.useAnimation = 30; diff --git a/Items/Weapons/Melee/UltimusCleaver.cs b/Items/Weapons/Melee/UltimusCleaver.cs index f9128f195b..32c44c88ba 100644 --- a/Items/Weapons/Melee/UltimusCleaver.cs +++ b/Items/Weapons/Melee/UltimusCleaver.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -12,7 +13,6 @@ namespace CalamityMod.Items.Weapons.Melee public class UltimusCleaver : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - public override void SetDefaults() { Item.width = 72; @@ -36,51 +36,34 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.OnFire3, 360); + SoundEngine.PlaySound(SoundID.Item14, target.Center); int onHitDamage = player.CalcIntDamage(Item.damage); Projectile blast = Projectile.NewProjectileDirect(Item.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), onHitDamage, 0f, player.whoAmI, target.whoAmI); blast.DamageType = Item.DamageType; - float firstDustScale = 1.7f; - float secondDustScale = 0.8f; - float thirdDustScale = 2f; - Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2(); + + Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); Vector2 dustVelocity = dustRotation * target.velocity.Length(); - SoundEngine.PlaySound(SoundID.Item14, target.Center); - int increment; - for (int i = 0; i < 40; i = increment + 1) + for (int i = 0; i < 40; i++) { - int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 200, default, firstDustScale); - Dust dust = Main.dust[swingDust]; - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 3f; - dust.velocity += dustVelocity * Main.rand.NextFloat(); - swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 100, default, secondDustScale); - dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; - dust.velocity.Y -= 6f; - dust.velocity *= 2f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.color = Color.Crimson * 0.5f; - dust.velocity += dustVelocity * Main.rand.NextFloat(); - increment = i; + Vector2 mainDustPos = target.Center + Main.rand.NextVector2Circular(target.width / 2, target.width / 2); + Dust swingDust = Dust.NewDustPerfect(mainDustPos, DustID.InfernoFork, dustVelocity * Main.rand.NextFloat() - Vector2.UnitY * 18f, 200, Scale: 1.7f); + swingDust.noGravity = true; + + Dust swingDust2 = Dust.NewDustPerfect(mainDustPos, DustID.InfernoFork, dustVelocity * Main.rand.NextFloat() - Vector2.UnitY * 12f, 100, Color.Crimson * 0.5f, 0.8f); + swingDust2.noGravity = true; + swingDust2.fadeIn = 1f; } - for (int j = 0; j < 20; j = increment + 1) + for (int j = 0; j < 20; j++) { - int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, DustID.InfernoFork, 0f, 0f, 0, default, thirdDustScale); - Dust dust = Main.dust[swingDust2]; - dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; - dust.noGravity = true; - dust.velocity.Y -= 6f; - dust.velocity *= 0.5f; - dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); - increment = j; + Vector2 dustPos = target.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(target.velocity.ToRotation()) * (target.width / 3f); + Dust moreDust = Dust.NewDustPerfect(dustPos, DustID.InfernoFork, dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()) - Vector2.UnitY * 3f, Scale: 2f); + moreDust.noGravity = true; } } public override void MeleeEffects(Player player, Rectangle hitbox) { - if (player.whoAmI == Main.myPlayer) + if (player.whoAmI == Main.myPlayer && !player.Calamity().bladeArmEnchant) { if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1) || player.itemAnimation == (int)(player.itemAnimationMax * 0.3) || @@ -88,65 +71,48 @@ namespace CalamityMod.Items.Weapons.Melee player.itemAnimation == (int)(player.itemAnimationMax * 0.7) || player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - float sparkYVel = 0f; float sparkXVel = 0f; - float sparkYSpawn = 0f; + float sparkYVel = 0f; float sparkXSpawn = 0f; + float sparkYSpawn = 0f; + if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - sparkYVel = -7f; + sparkYVel = -10.5f; + if (player.direction == -1) + sparkXSpawn = -8f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - sparkYVel = -6f; - sparkXVel = 2f; + sparkYVel = -9f; + sparkXVel = 3f; + sparkXSpawn = player.direction == -1 ? 20f : 26f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { - sparkYVel = -4f; - sparkXVel = 4f; - } - if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) - { - sparkYVel = -2f; + sparkYVel = -6f; sparkXVel = 6f; } - if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) - { - sparkXVel = 7f; - } - if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) - { - sparkXSpawn = 26f; - } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - sparkXSpawn -= 4f; - sparkYSpawn -= 20f; + sparkXVel = 9f; + sparkYVel = -3f; + sparkXSpawn = -4f; + sparkYSpawn = -20f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - sparkYSpawn += 6f; + sparkXVel = 10.5f; + sparkYSpawn = 6f; } - if (player.direction == -1) - { - if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) - { - sparkXSpawn -= 8f; - } - if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) - { - sparkXSpawn -= 6f; - } - } - sparkYVel *= 1.5f; - sparkXVel *= 1.5f; - sparkXSpawn *= (float)player.direction; + + sparkXVel *= player.direction; + sparkYVel *= player.gravDir; + sparkXSpawn *= player.direction; sparkYSpawn *= player.gravDir; var source = player.GetSource_ItemUse(Item); int damage = (int)player.GetTotalDamage().ApplyTo(Item.damage * 0.1f); - Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + sparkXSpawn, (float)(hitbox.Y + hitbox.Height / 2) + sparkYSpawn, - (float)player.direction * sparkXVel, sparkYVel * player.gravDir, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, hitbox.X + hitbox.Width / 2 + sparkXSpawn, hitbox.Y + hitbox.Height / 2 + sparkYSpawn, sparkXVel, sparkYVel, ModContent.ProjectileType(), damage, 0f, player.whoAmI); } } } diff --git a/Items/Weapons/Melee/VanishingPoint.cs b/Items/Weapons/Melee/VanishingPoint.cs index 5aee60aefa..5b4f875482 100644 --- a/Items/Weapons/Melee/VanishingPoint.cs +++ b/Items/Weapons/Melee/VanishingPoint.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using System.Collections.Generic; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Melee.Spears; using Terraria; using Terraria.ID; @@ -37,6 +38,8 @@ namespace CalamityMod.Items.Weapons.Melee } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void ModifyTooltips(List tooltips) => tooltips.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); + public override float UseSpeedMultiplier(Player player) => Main.zenithWorld ? 2f : 1f; public override void AddRecipes() { @@ -45,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentSolar, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Melee/VeinBurster.cs b/Items/Weapons/Melee/VeinBurster.cs index c8d2f1f9d7..3da0ed1b9e 100644 --- a/Items/Weapons/Melee/VeinBurster.cs +++ b/Items/Weapons/Melee/VeinBurster.cs @@ -1,5 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; @@ -37,14 +37,5 @@ namespace CalamityMod.Items.Weapons.Melee { target.AddBuff(ModContent.BuffType(), 300); } - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 5). - AddIngredient(15). - AddIngredient(ItemID.Vertebrae, 5). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Melee/Violence.cs b/Items/Weapons/Melee/Violence.cs index a4e12b4d79..84b8de2cdc 100644 --- a/Items/Weapons/Melee/Violence.cs +++ b/Items/Weapons/Melee/Violence.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -19,24 +20,36 @@ namespace CalamityMod.Items.Weapons.Melee Item.noMelee = true; Item.useTurn = true; Item.noUseGraphic = true; - Item.useAnimation = 25; + Item.useAnimation = 60; Item.useTime = 25; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 9f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); - Item.channel = true; + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; + Item.channel = true; } - public override bool CanUseItem(Player player) => player.altFunctionUse == 2 || player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) + { + return true; + } + + public override bool CanUseItem(Player player) => 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, type, damage, knockback, player.whoAmI, 0f, velocity.ToRotation()); + if (player.altFunctionUse == 2) + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + player.itemAnimation = player.itemAnimationMax = player.itemTime = player.itemTimeMax = 60; + Projectile.NewProjectile(source, position, velocity*1.6666f, type, (int)(damage * 20), knockback, player.whoAmI, 0f, velocity.ToRotation(), 0); + } + else + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, velocity.ToRotation(), 1); return false; } } diff --git a/Items/Weapons/Melee/Virulence.cs b/Items/Weapons/Melee/Virulence.cs index 97f4b5a5ac..0c3d658d2c 100644 --- a/Items/Weapons/Melee/Virulence.cs +++ b/Items/Weapons/Melee/Virulence.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Weapons/Melee/VoidEdge.cs b/Items/Weapons/Melee/VoidEdge.cs index 07276065ed..7ac33fbcb3 100644 --- a/Items/Weapons/Melee/VoidEdge.cs +++ b/Items/Weapons/Melee/VoidEdge.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -81,7 +79,7 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool()) { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 66, 0f, 0f, 0, Color.Plum, Main.rand.NextFloat(0.65f, 1.2f)); + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.RainbowTorch, 0f, 0f, 0, Color.Plum, Main.rand.NextFloat(0.65f, 1.2f)); Main.dust[dust].noGravity = true; } } @@ -91,10 +89,10 @@ namespace CalamityMod.Items.Weapons.Melee SoundEngine.PlaySound(sound with { Volume = 0.65f, PitchVariance = 0.3f, Pitch = -0.5f }, target.Center); for (int i = 0; i <= 30; i++) { - Dust dust = Dust.NewDustPerfect(target.Center, 66, new Vector2(0, -18).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 1.9f)); + Dust dust = Dust.NewDustPerfect(target.Center, DustID.RainbowTorch, new Vector2(0, -18).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 1.9f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.7f, 1.6f); - Dust dust2 = Dust.NewDustPerfect(target.Center, 66, new Vector2(0, -7).RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.9f)); + Dust dust2 = Dust.NewDustPerfect(target.Center, DustID.RainbowTorch, new Vector2(0, -7).RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.9f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.7f, 1.6f); } diff --git a/Items/Weapons/Melee/WindBlade.cs b/Items/Weapons/Melee/WindBlade.cs index dfda5d3c3f..1be0c3f0b6 100644 --- a/Items/Weapons/Melee/WindBlade.cs +++ b/Items/Weapons/Melee/WindBlade.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Melee CreateRecipe(). AddIngredient(9). AddIngredient(ItemID.SunplateBlock, 3). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Melee/WulfrumScrewdriver.cs b/Items/Weapons/Melee/WulfrumScrewdriver.cs index 74a3d5142f..ff12b06675 100644 --- a/Items/Weapons/Melee/WulfrumScrewdriver.cs +++ b/Items/Weapons/Melee/WulfrumScrewdriver.cs @@ -85,8 +85,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(12). - AddIngredient(). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } @@ -94,7 +93,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void Update(ref float gravity, ref float maxFallSpeed) => ScrewStored = false; public override void UpdateInventory(Player player) { - if (player.ActiveItem() != Item) + if (player.HeldItem != Item) ScrewStored = false; } @@ -166,7 +165,7 @@ namespace CalamityMod.Items.Weapons.Melee Player myPlayer = Main.LocalPlayer; - if (myPlayer.ActiveItem() != Item || !myPlayer.active || myPlayer.dead) + if (myPlayer.HeldItem != Item || !myPlayer.active || myPlayer.dead) return; spriteBatch.End(); diff --git a/Items/Weapons/Melee/YateveoBloom.cs b/Items/Weapons/Melee/YateveoBloom.cs index 0cb321f18f..9a88f1eec0 100644 --- a/Items/Weapons/Melee/YateveoBloom.cs +++ b/Items/Weapons/Melee/YateveoBloom.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = SoundID.Item1; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/YinYo.cs b/Items/Weapons/Melee/YinYo.cs index 31cedfa79f..b3a233e150 100644 --- a/Items/Weapons/Melee/YinYo.cs +++ b/Items/Weapons/Melee/YinYo.cs @@ -50,8 +50,8 @@ namespace CalamityMod.Items.Weapons.Melee AddIngredient(ItemID.Valor). AddIngredient(ItemID.DarkShard). AddIngredient(ItemID.LightShard). - AddIngredient(ItemID.SoulofNight, 7). AddIngredient(ItemID.SoulofLight, 7). + AddIngredient(ItemID.SoulofNight, 7). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Ranged/AcesHigh.cs b/Items/Weapons/Ranged/AcesHigh.cs index 7f7c60844b..9160848eac 100644 --- a/Items/Weapons/Ranged/AcesHigh.cs +++ b/Items/Weapons/Ranged/AcesHigh.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Typeless; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -12,7 +13,9 @@ namespace CalamityMod.Items.Weapons.Ranged { public class AcesHigh : ModItem, ILocalizedModType { + public int shots = 0; public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() { Item.width = 48; @@ -28,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.knockBack = 6f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.UseSound = SoundID.Item36; @@ -36,12 +39,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 24f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; + Item.consumeAmmoOnLastShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override void AddRecipes() { @@ -56,13 +57,23 @@ namespace CalamityMod.Items.Weapons.Ranged public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) { - type = Utils.SelectRandom(Main.rand, new int[] + shots++; + switch (shots) { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); + case 4: + type = ModContent.ProjectileType(); + shots = 0; + break; + case 3: + type = ModContent.ProjectileType(); + break; + case 2: + type = ModContent.ProjectileType(); + break; + default: + type = ModContent.ProjectileType(); + break; + } } } } diff --git a/Items/Weapons/Ranged/AcidwoodBow.cs b/Items/Weapons/Ranged/AcidwoodBow.cs index 37af5aa1ea..f5e8ce8ea4 100644 --- a/Items/Weapons/Ranged/AcidwoodBow.cs +++ b/Items/Weapons/Ranged/AcidwoodBow.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Abyss; -using Terraria; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using Terraria.ID; using Terraria.ModLoader; @@ -26,7 +25,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 6.6f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index f90dedf730..6defc4c398 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 62; Item.height = 90; - Item.damage = 83; + Item.damage = 96; Item.DamageType = DamageClass.Ranged; Item.useTime = 15; Item.useAnimation = 30; @@ -31,8 +30,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; - Item.rare = ModContent.RarityType(); - Item.Calamity().canFirePointBlankShots = true; + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -69,12 +67,9 @@ namespace CalamityMod.Items.Weapons.Ranged newType = ModContent.ProjectileType(); break; } - int proj = Projectile.NewProjectile(spawnSource, source.X + offset.X, source.Y + offset.Y, velocity.X, velocity.Y, newType, (int)(damage * 2.3f), knockback, player.whoAmI); + int proj = Projectile.NewProjectile(spawnSource, source.X + offset.X, source.Y + offset.Y, velocity.X, velocity.Y, newType, (int)(damage * 1.35f), knockback, player.whoAmI); if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].arrow = true; Main.projectile[proj].extraUpdates += 1; - } } else { diff --git a/Items/Weapons/Ranged/AngelicShotgun.cs b/Items/Weapons/Ranged/AngelicShotgun.cs index 4057a09072..a62c89a908 100644 --- a/Items/Weapons/Ranged/AngelicShotgun.cs +++ b/Items/Weapons/Ranged/AngelicShotgun.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Ammo; +using CalamityMod.Items.Ammo; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; @@ -38,7 +37,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() @@ -64,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Ranged Projectile.NewProjectile(source, position + velocity.SafeNormalize(Vector2.Zero) * 16f, randomVelocity, type, damage, knockback, player.whoAmI); } - // Spawn a beam from the sky ala Deathhail Staff or Lunar Flare + // Spawn a beam from the sky ala Hyperdeath Rift Scepter or Lunar Flare // This is more powerful if Hallow-Point Rounds (either naturally used or converted) are fired bool empowered = type == ModContent.ProjectileType(); float laserSpeed = 8f; @@ -88,7 +86,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.SunplateBlock, 75). AddIngredient(15). AddIngredient(7). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Ranged/Animosity.cs b/Items/Weapons/Ranged/Animosity.cs index 3ca149441e..fdb7e08c9b 100644 --- a/Items/Weapons/Ranged/Animosity.cs +++ b/Items/Weapons/Ranged/Animosity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Ranged; @@ -8,7 +9,6 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -23,20 +23,19 @@ namespace CalamityMod.Items.Weapons.Ranged public float SniperVelocityMult = 2f; public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; - + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + } public override void SetDefaults() { Item.width = 70; Item.height = 18; - Item.damage = 46; + Item.damage = 39; Item.DamageType = DamageClass.Ranged; - Item.width = 70; - Item.height = 18; Item.scale = 0.85f; - Item.useTime = 30; + Item.useTime = Item.useAnimation = 33; Item.reuseDelay = 10; - Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2f; @@ -48,12 +47,11 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 6.5f; Item.useAmmo = AmmoID.Bullet; Item.crit = 8; - Item.Calamity().canFirePointBlankShots = true; } public override void UpdateInventory(Player player) { - //ITS MY REWORK SO I CAN PUT A REFERENCE: Shotgun full of hate, returns Animosity otherwise + //ITS MY REWORK SO I CAN PUT A REFERENCE: Shotgun Full of Hate, returns Animosity otherwise if (Main.zenithWorld) Item.SetNameOverride(this.GetLocalizedValue("GFBName")); } @@ -65,15 +63,8 @@ namespace CalamityMod.Items.Weapons.Ranged //Distortion wind do whisper one truth... } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - public override bool AltFunctionUse(Player player) - { - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); + public override bool AltFunctionUse(Player player) => true; public override float UseSpeedMultiplier(Player player) { @@ -100,7 +91,7 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.altFunctionUse == 2) { - player.Calamity().GeneralScreenShakePower = 2f; + player.SetScreenshake(2f); SoundEngine.PlaySound(ShootAndReloadSound with { PitchVariance = 0.3f }, position); if (Main.zenithWorld) // Why only shotgun full of hate, why not Hexagun too? (See AnimosityBullet for more) @@ -131,7 +122,7 @@ namespace CalamityMod.Items.Weapons.Ranged } for (int i = 0; i <= 10; i++) { - Dust dust = Dust.NewDustPerfect(nuzzlePos, 303, velocity.RotatedByRandom(MathHelper.ToRadians(7f)) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(0.9f, 1.2f)); + Dust dust = Dust.NewDustPerfect(nuzzlePos, DustID.SteampunkSteam, velocity.RotatedByRandom(MathHelper.ToRadians(7f)) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; dust.alpha = 150; } @@ -180,7 +171,7 @@ namespace CalamityMod.Items.Weapons.Ranged if (!Main.dedServ) { string goreType = Main.rand.NextBool() ? "EmptyAnimosityShell" : "EmptyAnimosityShell2"; - Gore.NewGore(source, position, velocity.RotatedBy(2f * -player.direction) * Main.rand.NextFloat(0.6f, 0.7f), Mod.Find(goreType).Type); + Gore.NewGore(source, position, velocity.RotatedBy(2f * -player.direction) * Main.rand.NextFloat(0.6f, 0.7f), Mod.Find(goreType).Type, 0.75f); } return false; } diff --git a/Items/Weapons/Ranged/AntiMaterielRifle.cs b/Items/Weapons/Ranged/AntiMaterielRifle.cs index f777603609..8ed530291d 100644 --- a/Items/Weapons/Ranged/AntiMaterielRifle.cs +++ b/Items/Weapons/Ranged/AntiMaterielRifle.cs @@ -18,10 +18,9 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 154; Item.height = 40; - Item.damage = 1860; + Item.damage = 1818; Item.DamageType = DamageClass.Ranged; - Item.useTime = 60; - Item.useAnimation = 60; + Item.useTime = Item.useAnimation = 60; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 9.5f; @@ -31,8 +30,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; - Item.rare = ModContent.RarityType(); - Item.Calamity().canFirePointBlankShots = true; + Item.rare = ModContent.RarityType(); } public override Vector2? HoldoutOffset() => new Vector2(-30, 0); diff --git a/Items/Weapons/Ranged/AquashardShotgun.cs b/Items/Weapons/Ranged/AquashardShotgun.cs deleted file mode 100644 index c388ec1d2e..0000000000 --- a/Items/Weapons/Ranged/AquashardShotgun.cs +++ /dev/null @@ -1,69 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class AquashardShotgun : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetDefaults() - { - Item.width = 62; - Item.height = 26; - Item.damage = 12; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 30; - Item.useAnimation = 30; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 5.5f; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.UseSound = SoundID.Item61; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 30f; - Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; - } - - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6; - - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - for (int index = 0; index < 2; ++index) - { - float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f; - - if (type == ProjectileID.Bullet) - { - int projectile = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - Main.projectile[projectile].timeLeft = 200; - } - else - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - } - return false; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.Boomstick). - AddIngredient(2). - AddIngredient(10). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/AquashardShotgun.png b/Items/Weapons/Ranged/AquashardShotgun.png deleted file mode 100644 index 516b1fa7cc..0000000000 Binary files a/Items/Weapons/Ranged/AquashardShotgun.png and /dev/null differ diff --git a/Items/Weapons/Ranged/Arbalest.cs b/Items/Weapons/Ranged/Arbalest.cs index 3ee4b56f48..bacb49e7ed 100644 --- a/Items/Weapons/Ranged/Arbalest.cs +++ b/Items/Weapons/Ranged/Arbalest.cs @@ -33,12 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20; - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { SoundEngine.PlaySound(SoundID.Item5, player.Center); @@ -70,5 +66,15 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } + + public override void AddRecipes() + { + CreateRecipe(). + AddRecipeGroup("AnyMythrilBar", 10). + AddIngredient(ItemID.Cog, 15). + AddIngredient(ItemID.SoulofSight, 10). + AddTile(TileID.MythrilAnvil). + Register(); + } } } diff --git a/Items/Weapons/Ranged/ArcNovaDiffuser.cs b/Items/Weapons/Ranged/ArcNovaDiffuser.cs index 737ffe8a93..20b20c1cb3 100644 --- a/Items/Weapons/Ranged/ArcNovaDiffuser.cs +++ b/Items/Weapons/Ranged/ArcNovaDiffuser.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged public static int AftershotCooldownFrames = 9; public static int Charge1Frames = 156; public static int Charge2Frames = 308; + public static Color mainColor = new Color(116, 225, 0); public new string LocalizationCategory => "Items.Weapons.Ranged"; @@ -32,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 58; Item.height = 28; - Item.damage = 172; + Item.damage = 125; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = AftershotCooldownFrames; Item.noMelee = true; @@ -46,7 +47,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = false; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; - Item.Calamity().canFirePointBlankShots = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; @@ -66,8 +66,7 @@ namespace CalamityMod.Items.Weapons.Ranged CreateRecipe(). AddIngredient(). AddIngredient(). - AddIngredient(3). - AddIngredient(ItemID.MartianConduitPlating, 15). + AddIngredient(). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Ranged/Archerfish.cs b/Items/Weapons/Ranged/Archerfish.cs index 80e6aabbf1..860c80bc8b 100644 --- a/Items/Weapons/Ranged/Archerfish.cs +++ b/Items/Weapons/Ranged/Archerfish.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -11,6 +12,10 @@ namespace CalamityMod.Items.Weapons.Ranged public class Archerfish : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 33; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 78; @@ -29,7 +34,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, -5); @@ -61,5 +65,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } + + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; } } diff --git a/Items/Weapons/Ranged/Arietes41.cs b/Items/Weapons/Ranged/Arietes41.cs index d1de224282..aac14b3dbc 100644 --- a/Items/Weapons/Ranged/Arietes41.cs +++ b/Items/Weapons/Ranged/Arietes41.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Particles; -using CalamityMod.Projectiles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.width = 56; Item.height = 30; Item.scale = 0.85f; - Item.damage = 95; + Item.damage = 77; Item.DamageType = DamageClass.Ranged; Item.useTime = 13; Item.useAnimation = 13; @@ -34,12 +33,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 13f; Item.shoot = ProjectileID.PurificationPowder; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; - Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; // Shock bullet @@ -51,8 +48,7 @@ namespace CalamityMod.Items.Weapons.Ranged GeneralParticleHandler.SpawnParticle(spark); } Projectile shockShot = Projectile.NewProjectileDirect(source, itemPosition + velocity.RotatedBy(-0.6 * player.direction) + velocity * 1.65f, velocity, type, damage, knockback, player.whoAmI); - CalamityGlobalProjectile cgp = shockShot.Calamity(); - cgp.shockBullet = true; + shockShot.Calamity().shockBullet = true; } // Life bullet if (swapType) @@ -63,8 +59,7 @@ namespace CalamityMod.Items.Weapons.Ranged GeneralParticleHandler.SpawnParticle(spark); } Projectile lifeShot = Projectile.NewProjectileDirect(source, itemPosition + velocity.RotatedBy(-0.6 * player.direction) - velocity * 0.65f, velocity, type, damage, knockback, player.whoAmI); - CalamityGlobalProjectile cgp = lifeShot.Calamity(); - cgp.lifeBullet = true; + lifeShot.Calamity().lifeBullet = true; } swapType = !swapType; diff --git a/Items/Weapons/Ranged/ArterialAssault.cs b/Items/Weapons/Ranged/ArterialAssault.cs index 9a37c667b7..aee4c0087e 100644 --- a/Items/Weapons/Ranged/ArterialAssault.cs +++ b/Items/Weapons/Ranged/ArterialAssault.cs @@ -1,6 +1,5 @@ -using System; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -13,14 +12,16 @@ namespace CalamityMod.Items.Weapons.Ranged public class ArterialAssault : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + int shotNum = 0; public override void SetDefaults() { Item.width = 44; Item.height = 100; - Item.damage = 110; + Item.damage = 256; Item.DamageType = DamageClass.Ranged; - Item.useTime = 3; - Item.useAnimation = 15; + Item.useTime = 6; + Item.useAnimation = 40; Item.reuseDelay = 10; Item.useLimitPerAnimation = 5; Item.useStyle = ItemUseStyleID.Shoot; @@ -34,52 +35,20 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 30f; Item.useAmmo = AmmoID.Arrow; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float arrowSpeed = Item.shootSpeed; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; - } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) - { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - mouseDistance = arrowSpeed; - } - else - { - mouseDistance = arrowSpeed / mouseDistance; - } - - realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (-(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f; - realPlayerPos.Y -= 100f; - mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (mouseYDist < 0f) - { - mouseYDist *= -1f; - } - if (mouseYDist < 20f) - { - mouseYDist = 20f; - } - mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - mouseDistance = arrowSpeed / mouseDistance; - mouseXDist *= mouseDistance; - mouseYDist *= mouseDistance; - Vector2 arrowVel = new Vector2(mouseXDist, mouseYDist); - - Projectile shotArrow = Projectile.NewProjectileDirect(source, realPlayerPos, arrowVel, type, damage, knockback, player.whoAmI); + float rotateBy = 0.75f * ((shotNum*3) % 5 - 2); + position += velocity.SafeNormalize(Vector2.Zero).RotatedBy(rotateBy) * 64; + velocity = position.DirectionTo(Main.MouseWorld) * velocity.Length()*2; + type = ModContent.ProjectileType(); + Projectile shotArrow = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI); shotArrow.noDropItem = true; shotArrow.tileCollide = false; - shotArrow.Calamity().conditionalHomingRange = 300f; + (shotArrow.ModProjectile as BloodfireArrowProj).DisableEffects = true; + shotArrow.Calamity().conditionalHomingRange = 175f; + shotArrow.Calamity().BloodstoneOrbValue = 15; + shotNum++; + if (shotNum > 4) shotNum = 0; return false; } @@ -87,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Ranged { CreateRecipe(). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/AstralBlaster.cs b/Items/Weapons/Ranged/AstralBlaster.cs index 621e409326..e6c0803a7a 100644 --- a/Items/Weapons/Ranged/AstralBlaster.cs +++ b/Items/Weapons/Ranged/AstralBlaster.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Ranged/AstralBow.cs b/Items/Weapons/Ranged/AstralBow.cs deleted file mode 100644 index 308327e530..0000000000 --- a/Items/Weapons/Ranged/AstralBow.cs +++ /dev/null @@ -1,46 +0,0 @@ -using CalamityMod.Items.Materials; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - [LegacyName("AstralRepeater")] - public class AstralBow : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetDefaults() - { - Item.width = 38; - Item.height = 78; - Item.damage = 92; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 6; - Item.useAnimation = 18; - Item.reuseDelay = 18; - Item.useLimitPerAnimation = 3; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 2.5f; - Item.value = CalamityGlobalItem.RarityCyanBuyPrice; - Item.rare = ItemRarityID.Cyan; - Item.UseSound = SoundID.Item5; - Item.autoReuse = true; - Item.shoot = ProjectileID.WoodenArrowFriendly; - Item.shootSpeed = 16f; - Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; - } - - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 25; - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(7). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/AstralBow.png b/Items/Weapons/Ranged/AstralBow.png deleted file mode 100644 index 25d1c56e14..0000000000 Binary files a/Items/Weapons/Ranged/AstralBow.png and /dev/null differ diff --git a/Items/Weapons/Ranged/AstrealDefeat.cs b/Items/Weapons/Ranged/AstrealDefeat.cs index 3231490127..fdc11428a1 100644 --- a/Items/Weapons/Ranged/AstrealDefeat.cs +++ b/Items/Weapons/Ranged/AstrealDefeat.cs @@ -11,14 +11,16 @@ namespace CalamityMod.Items.Weapons.Ranged public class AstrealDefeat : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() { Item.width = 40; Item.height = 78; - Item.damage = 153; + Item.damage = 160; Item.DamageType = DamageClass.Ranged; Item.useTime = 4; Item.useAnimation = 20; + Item.useLimitPerAnimation = 5; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5.5f; @@ -29,12 +31,11 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 4f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; + Item.consumeAmmoOnLastShotOnly = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float speed = velocity.Length(); if (speed > 8f) velocity *= 8f / speed; @@ -55,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.ShadowFlameBow). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/Auralis.cs b/Items/Weapons/Ranged/Auralis.cs index 1d5ca3004e..f396e088ac 100644 --- a/Items/Weapons/Ranged/Auralis.cs +++ b/Items/Weapons/Ranged/Auralis.cs @@ -2,10 +2,10 @@ using CalamityMod.Items.Potions; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -14,6 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public class Auralis : ModItem, ILocalizedModType { + public static readonly SoundStyle HeavyShotSound = new("CalamityMod/Sounds/Item/PlasmaRifleMain"); public new string LocalizationCategory => "Items.Weapons.Ranged"; public static readonly Color blueColor = new Color(0, 77, 255); public static readonly Color greenColor = new Color(0, 255, 77); @@ -33,11 +34,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.UseSound = CommonCalamitySounds.PlasmaBlastSound; + Item.UseSound = HeavyShotSound with { Volume = 0.8f }; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } public override void ModifyWeaponDamage(Player player, ref StatModifier damage) @@ -61,8 +61,6 @@ namespace CalamityMod.Items.Weapons.Ranged public override void HoldItem(Player player) => player.scope = true; - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 50; - public override void AddRecipes() { CreateRecipe(). @@ -70,7 +68,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(5). AddIngredient(5). AddIngredient(50). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/AuroraBlazer.cs b/Items/Weapons/Ranged/AuroraBlazer.cs index 5e3073cde9..ec2406c754 100644 --- a/Items/Weapons/Ranged/AuroraBlazer.cs +++ b/Items/Weapons/Ranged/AuroraBlazer.cs @@ -1,8 +1,7 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -15,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 68; Item.height = 36; - Item.damage = 74; + Item.damage = 69; Item.DamageType = DamageClass.Ranged; Item.useTime = 5; Item.useAnimation = 30; diff --git a/Items/Weapons/Ranged/Barinade.cs b/Items/Weapons/Ranged/Barinade.cs index aae8b9e920..352270f1ab 100644 --- a/Items/Weapons/Ranged/Barinade.cs +++ b/Items/Weapons/Ranged/Barinade.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -28,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(0, 4); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/Barinade.png b/Items/Weapons/Ranged/Barinade.png index 5ab49d1c58..0d4a6b1bf8 100644 Binary files a/Items/Weapons/Ranged/Barinade.png and b/Items/Weapons/Ranged/Barinade.png differ diff --git a/Items/Weapons/Ranged/Barinautical.cs b/Items/Weapons/Ranged/Barinautical.cs index 12d468c942..188376a253 100644 --- a/Items/Weapons/Ranged/Barinautical.cs +++ b/Items/Weapons/Ranged/Barinautical.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -30,7 +31,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/BarracudaGun.cs b/Items/Weapons/Ranged/BarracudaGun.cs index 87895c9b14..9264c360f9 100644 --- a/Items/Weapons/Ranged/BarracudaGun.cs +++ b/Items/Weapons/Ranged/BarracudaGun.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -62,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.PiranhaGun). AddIngredient(ItemID.LunarBar, 5). AddIngredient(ItemID.SharkFin, 2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/BladedgeRailbow.cs b/Items/Weapons/Ranged/BladedgeRailbow.cs index 323cf7ae91..0b06168605 100644 --- a/Items/Weapons/Ranged/BladedgeRailbow.cs +++ b/Items/Weapons/Ranged/BladedgeRailbow.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -67,9 +68,11 @@ namespace CalamityMod.Items.Weapons.Ranged ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), - ModContent.ProjectileType(), + ModContent.ProjectileType(), // Not ranged ModContent.ProjectileType(), ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), // Not ranged ModContent.ProjectileType(), @@ -96,8 +99,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.height = 24; Item.damage = 30; Item.DamageType = DamageClass.Ranged; - Item.useTime = 29; - Item.useAnimation = 29; + Item.useTime = Item.useAnimation = 28; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; @@ -108,25 +110,20 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 14f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { for (int i = 0; i < 4; i++) { - float SpeedX = velocity.X + (float)Main.rand.Next(-60, 61) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-60, 61) * 0.05f; + float SpeedX = velocity.X + Main.rand.NextFloat(-3f, 3f); + float SpeedY = velocity.Y + Main.rand.NextFloat(-3f, 3f); int index = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); Main.projectile[index].noDropItem = true; } Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float PiOver10 = MathHelper.Pi * 0.1f; Vector2 arrowVel = velocity; arrowVel.Normalize(); arrowVel *= 10f; @@ -135,12 +132,10 @@ namespace CalamityMod.Items.Weapons.Ranged int numArrows = Main.zenithWorld ? 4 : 2; for (int i = 0; i < numArrows; i++) { - float arrowOffset = (float)i - 1f / 2f; - Vector2 offsetSpawn = arrowVel.RotatedBy((double)(PiOver10 * arrowOffset), default); + float arrowOffset = i - 0.5f; + Vector2 offsetSpawn = arrowVel.RotatedBy(MathHelper.Pi * 0.1f * arrowOffset); if (!arrowHitsTiles) - { offsetSpawn -= arrowVel; - } int projType; if (Main.zenithWorld) @@ -148,12 +143,20 @@ namespace CalamityMod.Items.Weapons.Ranged else projType = ProjectileID.Leaf; - int projectile = Projectile.NewProjectile(source, realPlayerPos.X + offsetSpawn.X, realPlayerPos.Y + offsetSpawn.Y, velocity.X, velocity.Y, projType, damage, 0f, player.whoAmI); + int projectile = Projectile.NewProjectile(source, realPlayerPos.X + offsetSpawn.X, realPlayerPos.Y + offsetSpawn.Y, velocity.X, velocity.Y, projType, (int)(damage * 0.7f), 0f, player.whoAmI); // Now for the special conditions to fix stuff... - if (projectile.WithinBounds(Main.maxProjectiles) && (projType == ProjectileID.Leaf || projType == ModContent.ProjectileType())) - Main.projectile[projectile].DamageType = DamageClass.Ranged; - if (projType == ModContent.ProjectileType() || projType == ModContent.ProjectileType() || projType == ModContent.ProjectileType()) - Main.projectile[projectile].velocity /= 2; + if (projectile.WithinBounds(Main.maxProjectiles)) + { + if (projType == ProjectileID.Leaf || projType == ModContent.ProjectileType() || projType == ModContent.ProjectileType()) + Main.projectile[projectile].DamageType = DamageClass.Ranged; + if (projType == ModContent.ProjectileType() || projType == ModContent.ProjectileType() || projType == ModContent.ProjectileType()) + Main.projectile[projectile].velocity /= 2; + if (projType == ModContent.ProjectileType()) + { + Main.projectile[projectile].ai[0] = -0.25f; + Main.projectile[projectile].ai[1] = 1f; + } + } } return false; } diff --git a/Items/Weapons/Ranged/BlightSpewer.cs b/Items/Weapons/Ranged/BlightSpewer.cs index 50e3df7a73..2e526f3c0e 100644 --- a/Items/Weapons/Ranged/BlightSpewer.cs +++ b/Items/Weapons/Ranged/BlightSpewer.cs @@ -1,8 +1,10 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -13,6 +15,10 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public static readonly SoundStyle Nanomachines = new("CalamityMod/Sounds/Item/NanoSwarm") { PitchVariance = 0.45f, Volume = 0.4f }; + + public static int AmmoSavedPercent = 33; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 76; @@ -32,15 +38,19 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 7f; Item.useAmmo = AmmoID.Gel; } - public override bool CanConsumeAmmo(Item ammo, Player player) + + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; + + public override void AddRecipes() { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; - } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); + CreateRecipe(). + AddIngredient(). + AddIngredient(5). + AddIngredient(10). + AddTile(TileID.MythrilAnvil). + Register(); } } } diff --git a/Items/Weapons/Ranged/BlissfulBombardier.cs b/Items/Weapons/Ranged/BlissfulBombardier.cs index 93f7bfbfff..0e5d044d87 100644 --- a/Items/Weapons/Ranged/BlissfulBombardier.cs +++ b/Items/Weapons/Ranged/BlissfulBombardier.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 88; Item.height = 48; - Item.damage = 592; + Item.damage = 550; Item.DamageType = DamageClass.Ranged; Item.useTime = 39; Item.useAnimation = 39; diff --git a/Items/Weapons/Ranged/BloodBoiler.cs b/Items/Weapons/Ranged/BloodBoiler.cs index 4a0f30013d..35eabb4e58 100644 --- a/Items/Weapons/Ranged/BloodBoiler.cs +++ b/Items/Weapons/Ranged/BloodBoiler.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 60; Item.height = 30; - Item.damage = 115; + Item.damage = 120; Item.DamageType = DamageClass.Ranged; Item.useTime = 5; Item.useAnimation = 25; @@ -46,11 +46,11 @@ 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) { shotReturn = !shotReturn; - if (Main.rand.NextFloat() > 0.60f) + if (Main.rand.NextFloat() > 0.20f) player.statLife -= 1; if (player.statLife <= 0) { - PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodBoiler" + Main.rand.Next(1, 2 + 1)).Format(player.name)); + PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodBoiler" + Main.rand.Next(1, 2 + 1)).ToNetworkText(player.name)); player.KillMe(pdr, 1000.0, 0, false); return false; } @@ -63,7 +63,7 @@ namespace CalamityMod.Items.Weapons.Ranged { CreateRecipe(). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/BlossomFlux.cs b/Items/Weapons/Ranged/BlossomFlux.cs index 8fc15e31b1..bd7cc1d39b 100644 --- a/Items/Weapons/Ranged/BlossomFlux.cs +++ b/Items/Weapons/Ranged/BlossomFlux.cs @@ -10,6 +10,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class BlossomFlux : LegendaryItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override Color? TooltipExtensionColor => new Color(109, 161, 84); public override void SetStaticDefaults() { @@ -20,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 38; Item.height = 68; - Item.damage = 20; + Item.damage = 18; Item.DamageType = DamageClass.Ranged; Item.useTime = 4; Item.useAnimation = 16; @@ -32,16 +33,13 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.useAmmo = AmmoID.Arrow; + Item.consumeAmmoOnFirstShotOnly = true; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.Calamity().canFirePointBlankShots = true; } - public override bool AltFunctionUse(Player player) - { - return true; - } + public override bool AltFunctionUse(Player player) => true; public override bool CanUseItem(Player player) { @@ -49,12 +47,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.useTime = 25; Item.useAnimation = 25; + Item.useLimitPerAnimation = 1; Item.UseSound = SoundID.Item77; } else { Item.useTime = 3; Item.useAnimation = 15; + Item.useLimitPerAnimation = 5; Item.UseSound = SoundID.Item5; } return base.CanUseItem(player); diff --git a/Items/Weapons/Ranged/BrimstoneFury.cs b/Items/Weapons/Ranged/BrimstoneFury.cs index 634cb0cef9..c4d586c689 100644 --- a/Items/Weapons/Ranged/BrimstoneFury.cs +++ b/Items/Weapons/Ranged/BrimstoneFury.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 13f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/BulletFilledShotgun.cs b/Items/Weapons/Ranged/BulletFilledShotgun.cs index 4bee81bf6d..35ca568391 100644 --- a/Items/Weapons/Ranged/BulletFilledShotgun.cs +++ b/Items/Weapons/Ranged/BulletFilledShotgun.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAnimation = Item.useTime = 75; Item.knockBack = 0.25f; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 9f; + Item.shootSpeed = 18f; Item.useAmmo = AmmoID.Bullet; Item.UseSound = SoundID.Item38; @@ -34,7 +34,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-7, 0); @@ -47,7 +46,8 @@ 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) { type = Item.shoot; - int bulletAmt = 30; + position += player.itemRotation.ToRotationVector2() * player.direction * 48f; + int bulletAmt = 40; for (int i = 0; i < bulletAmt; i++) { float newSpeedX = velocity.X + Main.rand.NextFloat(-15f, 15f); diff --git a/Items/Weapons/Ranged/Buzzkill.cs b/Items/Weapons/Ranged/Buzzkill.cs index b5a9e54ea7..cfeef85b6b 100644 --- a/Items/Weapons/Ranged/Buzzkill.cs +++ b/Items/Weapons/Ranged/Buzzkill.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 1f; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; - Item.rare = ItemRarityID.LightRed; + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; Item.noMelee = true; Item.noUseGraphic = true; Item.DamageType = DamageClass.Ranged; @@ -35,7 +35,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Ranged/ChickenCannon.cs b/Items/Weapons/Ranged/ChickenCannon.cs index 1382b7b071..c5514a88ee 100644 --- a/Items/Weapons/Ranged/ChickenCannon.cs +++ b/Items/Weapons/Ranged/ChickenCannon.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -23,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.knockBack = 1.5f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); // No use sound is intentional Item.autoReuse = true; Item.shootSpeed = 14.5f; diff --git a/Items/Weapons/Ranged/ChromaticEruption.cs b/Items/Weapons/Ranged/ChromaticEruption.cs index dd1cab2c5d..8b5d134047 100644 --- a/Items/Weapons/Ranged/ChromaticEruption.cs +++ b/Items/Weapons/Ranged/ChromaticEruption.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -14,7 +15,8 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public int FlareCounter = 0; + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; @@ -46,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; // Spawning the holdout cannot consume ammo - public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -65,7 +67,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentVortex, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/ClamorRifle.cs b/Items/Weapons/Ranged/ClamorRifle.cs index b51d12896b..83d1c7daac 100644 --- a/Items/Weapons/Ranged/ClamorRifle.cs +++ b/Items/Weapons/Ranged/ClamorRifle.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); diff --git a/Items/Weapons/Ranged/ClaretCannon.cs b/Items/Weapons/Ranged/ClaretCannon.cs deleted file mode 100644 index 0e19d9b1a0..0000000000 --- a/Items/Weapons/Ranged/ClaretCannon.cs +++ /dev/null @@ -1,58 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class ClaretCannon : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetDefaults() - { - Item.width = 48; - Item.height = 30; - Item.damage = 140; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 3; - Item.useAnimation = 9; - Item.reuseDelay = 10; - Item.useLimitPerAnimation = 3; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 5.5f; - Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item40; - Item.autoReuse = true; - Item.shootSpeed = 24f; - Item.shoot = ModContent.ProjectileType(); - Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; - } - - public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddTile(TileID.LunarCraftingStation). - Register(); - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - else - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - - return false; - } - } -} diff --git a/Items/Weapons/Ranged/CleansingBlaze.cs b/Items/Weapons/Ranged/CleansingBlaze.cs index 5e0af0c3f6..80a3ed689c 100644 --- a/Items/Weapons/Ranged/CleansingBlaze.cs +++ b/Items/Weapons/Ranged/CleansingBlaze.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 104; Item.height = 62; - Item.damage = 290; + Item.damage = 275; Item.DamageType = DamageClass.Ranged; Item.useTime = 3; Item.useAnimation = 24; @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 11f; Item.useAmmo = AmmoID.Gel; Item.consumeAmmoOnFirstShotOnly = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request(Texture + "Glow").Value); diff --git a/Items/Weapons/Ranged/ClockGatlignum.cs b/Items/Weapons/Ranged/ClockGatlignum.cs deleted file mode 100644 index 422f865ff1..0000000000 --- a/Items/Weapons/Ranged/ClockGatlignum.cs +++ /dev/null @@ -1,69 +0,0 @@ -using CalamityMod.Items.Materials; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class ClockGatlignum : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetDefaults() - { - Item.width = 66; - Item.height = 34; - Item.damage = 55; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 3; - Item.useAnimation = 9; - Item.reuseDelay = 12; - Item.useLimitPerAnimation = 3; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 3.75f; - Item.value = CalamityGlobalItem.RarityYellowBuyPrice; - Item.rare = ItemRarityID.Yellow; - Item.UseSound = SoundID.Item31; - Item.autoReuse = true; - Item.shoot = ProjectileID.PurificationPowder; - Item.shootSpeed = 20f; - Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; - } - - public override Vector2? HoldoutOffset() => new Vector2(-14, 0); - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - float SpeedX = velocity.X + Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-15, 16) * 0.05f; - - if (type == ProjectileID.Bullet) - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ProjectileID.BulletHighVelocity, damage, knockback, player.whoAmI); - else - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - - return false; - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 33) - return false; - return true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.ClockworkAssaultRifle). - AddIngredient(ItemID.Gatligator). - AddIngredient(ItemID.VenusMagnum). - AddIngredient(3). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/ClockGatlignum.png b/Items/Weapons/Ranged/ClockGatlignum.png deleted file mode 100644 index d9483a7d49..0000000000 Binary files a/Items/Weapons/Ranged/ClockGatlignum.png and /dev/null differ diff --git a/Items/Weapons/Ranged/ClockworkBow.cs b/Items/Weapons/Ranged/ClockworkBow.cs index d2de85e06e..78a96f7bd5 100644 --- a/Items/Weapons/Ranged/ClockworkBow.cs +++ b/Items/Weapons/Ranged/ClockworkBow.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Ranged CreateRecipe(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(ItemID.Cog, 50). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/Condemnation.cs b/Items/Weapons/Ranged/Condemnation.cs index 96d14370c5..b0a3d62c15 100644 --- a/Items/Weapons/Ranged/Condemnation.cs +++ b/Items/Weapons/Ranged/Condemnation.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -30,12 +31,11 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-50f, 0f); diff --git a/Items/Weapons/Ranged/ConferenceCall.cs b/Items/Weapons/Ranged/ConferenceCall.cs index a673f01eb8..adab0eaaed 100644 --- a/Items/Weapons/Ranged/ConferenceCall.cs +++ b/Items/Weapons/Ranged/ConferenceCall.cs @@ -10,6 +10,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class ConferenceCall : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() { Item.width = 66; @@ -30,21 +31,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Bullet; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int bulletAmt = 4; for (int index = 0; index < bulletAmt; ++index) { @@ -87,10 +77,12 @@ namespace CalamityMod.Items.Weapons.Ranged targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); targetPosition.Y -= 100 * j; - Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[j]].Center - targetPosition) * Item.shootSpeed; + // Create a dummy projectile to grab the number of max updates the bullet has for predictive aim use + Projectile dummy = new Projectile(); + dummy.SetDefaults(type); + Vector2 extraBulletVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(targetPosition, Main.npc[targets[j]], Item.shootSpeed, dummy.MaxUpdates); int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); - Main.projectile[proj].extraUpdates += 14; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; } @@ -107,10 +99,12 @@ namespace CalamityMod.Items.Weapons.Ranged targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); targetPosition.Y -= 100 * randomTarget; - Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed; + // Create a dummy projectile to grab the number of max updates the bullet has for predictive aim use + Projectile dummy = new Projectile(); + dummy.SetDefaults(type); + Vector2 extraBulletVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(targetPosition, Main.npc[targets[randomTarget]], Item.shootSpeed, dummy.MaxUpdates); int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); - Main.projectile[proj].extraUpdates += 14; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; } diff --git a/Items/Weapons/Ranged/Contagion.cs b/Items/Weapons/Ranged/Contagion.cs index c878c4894e..1f941bd2dc 100644 --- a/Items/Weapons/Ranged/Contagion.cs +++ b/Items/Weapons/Ranged/Contagion.cs @@ -34,7 +34,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; Item.rare = ModContent.RarityType(); Item.Calamity().devItem = true; - Item.Calamity().canFirePointBlankShots = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; diff --git a/Items/Weapons/Ranged/ContinentalGreatbow.cs b/Items/Weapons/Ranged/ContinentalGreatbow.cs index 6e63b9f837..e82feae262 100644 --- a/Items/Weapons/Ranged/ContinentalGreatbow.cs +++ b/Items/Weapons/Ranged/ContinentalGreatbow.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 18; Item.height = 36; - Item.damage = 34; + Item.damage = 38; Item.DamageType = DamageClass.Ranged; Item.useTime = 24; Item.useAnimation = 24; @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 17f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/CorinthPrime.cs b/Items/Weapons/Ranged/CorinthPrime.cs index 2bcfaa60db..abc000862a 100644 --- a/Items/Weapons/Ranged/CorinthPrime.cs +++ b/Items/Weapons/Ranged/CorinthPrime.cs @@ -37,7 +37,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; Item.shoot = ModContent.ProjectileType(); - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-20, 5); @@ -91,7 +90,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.VortexBeater). AddIngredient(ItemID.IllegalGunParts). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/CorrodedCaustibow.cs b/Items/Weapons/Ranged/CorrodedCaustibow.cs index 8a79b82295..2c4d7fcd6e 100644 --- a/Items/Weapons/Ranged/CorrodedCaustibow.cs +++ b/Items/Weapons/Ranged/CorrodedCaustibow.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 5f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Ranged/CrackshotColt.cs b/Items/Weapons/Ranged/CrackshotColt.cs index 964b561572..6d80394bf6 100644 --- a/Items/Weapons/Ranged/CrackshotColt.cs +++ b/Items/Weapons/Ranged/CrackshotColt.cs @@ -26,14 +26,13 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2.25f; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; - Item.rare = ItemRarityID.Blue; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; Item.UseSound = ShootSound; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; Item.shootSpeed = 14f; - Item.Calamity().canFirePointBlankShots = true; } // This item has a right click. diff --git a/Items/Weapons/Ranged/DaemonsFlame.cs b/Items/Weapons/Ranged/DaemonsFlame.cs index 0574340fcb..b14ade2cb0 100644 --- a/Items/Weapons/Ranged/DaemonsFlame.cs +++ b/Items/Weapons/Ranged/DaemonsFlame.cs @@ -1,10 +1,12 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -12,11 +14,14 @@ namespace CalamityMod.Items.Weapons.Ranged public class DaemonsFlame : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 66; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); public override void SetDefaults() { Item.width = 62; Item.height = 128; - Item.damage = 150; + Item.damage = 162; Item.useTime = 12; Item.useAnimation = 12; Item.useStyle = ItemUseStyleID.Shoot; @@ -33,13 +38,12 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); - Item.Calamity().canFirePointBlankShots = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; // Spawning the holdout cannot consume ammo - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(3) && player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { diff --git a/Items/Weapons/Ranged/DarkechoGreatbow.cs b/Items/Weapons/Ranged/DarkechoGreatbow.cs index 960f51a999..7516999dd8 100644 --- a/Items/Weapons/Ranged/DarkechoGreatbow.cs +++ b/Items/Weapons/Ranged/DarkechoGreatbow.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/DeadSunsWind.cs b/Items/Weapons/Ranged/DeadSunsWind.cs index d95779c143..ac6a849c6c 100644 --- a/Items/Weapons/Ranged/DeadSunsWind.cs +++ b/Items/Weapons/Ranged/DeadSunsWind.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; -using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -20,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 70; Item.height = 24; - Item.damage = 100; + Item.damage = 115; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = 22; Item.useStyle = ItemUseStyleID.Shoot; diff --git a/Items/Weapons/Ranged/Deathwind.cs b/Items/Weapons/Ranged/Deathwind.cs deleted file mode 100644 index 5b485b9487..0000000000 --- a/Items/Weapons/Ranged/Deathwind.cs +++ /dev/null @@ -1,60 +0,0 @@ -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class Deathwind : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetDefaults() - { - Item.width = 40; - Item.height = 82; - Item.damage = 148; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 14; - Item.useAnimation = 14; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 5f; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item5; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 20f; - Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; - } - - 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/DeathwindGlow").Value); - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - for (int index = 0; index < 4; ++index) - { - float SpeedX = velocity.X + Main.rand.Next(-20, 21) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-20, 21) * 0.05f; - if (CalamityUtils.CheckWoodenAmmo(type, player)) - { - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 2), knockback, player.whoAmI); - } - else - { - int baseArrow = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - Main.projectile[baseArrow].noDropItem = true; - } - } - return false; - } - } -} diff --git a/Items/Weapons/Ranged/DeepcoreGK2.cs b/Items/Weapons/Ranged/DeepcoreGK2.cs index cd98650a7f..d5266a1a8c 100644 --- a/Items/Weapons/Ranged/DeepcoreGK2.cs +++ b/Items/Weapons/Ranged/DeepcoreGK2.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 20f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-20, 0); diff --git a/Items/Weapons/Ranged/DodusHandcannon.cs b/Items/Weapons/Ranged/DodusHandcannon.cs deleted file mode 100644 index f36fde133d..0000000000 --- a/Items/Weapons/Ranged/DodusHandcannon.cs +++ /dev/null @@ -1,58 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; -using CalamityMod.Sounds; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class DodusHandcannon : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetDefaults() - { - Item.width = 62; - Item.height = 34; - Item.damage = 1020; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 30; - Item.useAnimation = 30; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 6f; - - // Reduce volume to 30% so it stops destroying people's ears. - Item.UseSound = CommonCalamitySounds.LargeWeaponFireSound with { Volume = 0.3f }; - - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 13f; - Item.useAmmo = AmmoID.Bullet; - - Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.rare = ModContent.RarityType(); - Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; - } - - public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) - { - type = Item.shoot; - } - - public override Vector2? HoldoutOffset() => new Vector2(-17, 5); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(ItemID.LunarBar, 15). - AddIngredient(5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/DodusHandcannon.png b/Items/Weapons/Ranged/DodusHandcannon.png deleted file mode 100644 index d78a7a37f7..0000000000 Binary files a/Items/Weapons/Ranged/DodusHandcannon.png and /dev/null differ diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index df0e1a9c79..8cc59baacc 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -1,12 +1,12 @@ -using System; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -15,13 +15,13 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public static int AmmoSavedPercent = 80; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public static readonly SoundStyle FireballSound = new("CalamityMod/Sounds/Custom/Yharon/YharonFireball", 3) { PitchVariance = 0.3f, Volume = 0.75f }; public static readonly SoundStyle WeldingStart = new("CalamityMod/Sounds/Item/DragonsBreathStrongStart") { Volume = 1.75f }; public static readonly SoundStyle WeldingBurn = new("CalamityMod/Sounds/Item/WeldingBurn") { Volume = 0.65f }; public static readonly SoundStyle WeldingShoot = new("CalamityMod/Sounds/Item/WeldingShoot") { Volume = 0.45f }; - - public int Counter = 0; - public override void SetDefaults() { Item.width = 124; @@ -42,10 +42,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 3.5f; Item.useAmmo = AmmoID.Gel; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } - public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/Drataliornus.cs b/Items/Weapons/Ranged/Drataliornus.cs index 36ca91f8d5..86c76c93bf 100644 --- a/Items/Weapons/Ranged/Drataliornus.cs +++ b/Items/Weapons/Ranged/Drataliornus.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useTurn = false; Item.useAmmo = AmmoID.Arrow; Item.autoReuse = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool AltFunctionUse(Player player) diff --git a/Items/Weapons/Ranged/DriftwoodBow.cs b/Items/Weapons/Ranged/DriftwoodBow.cs index 66322c7e39..500a1cbc66 100644 --- a/Items/Weapons/Ranged/DriftwoodBow.cs +++ b/Items/Weapons/Ranged/DriftwoodBow.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.FurnitureDriftwood; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -28,7 +28,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 6.6f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) @@ -40,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged for (int i = 0; i <= 18; i++) { - Dust dust = Dust.NewDustPerfect(position + velocity * 3f, 160, velocity.RotatedByRandom(MathHelper.ToRadians(19f)) * Main.rand.NextFloat(0.8f, 3.8f), Scale: Main.rand.NextFloat(1.2f, 1.6f)); + Dust dust = Dust.NewDustPerfect(position + velocity * 3f, DustID.MagnetSphere, velocity.RotatedByRandom(MathHelper.ToRadians(19f)) * Main.rand.NextFloat(0.8f, 3.8f), Scale: Main.rand.NextFloat(1.2f, 1.6f)); dust.noGravity = true; } } diff --git a/Items/Weapons/Ranged/EternalBlizzard.cs b/Items/Weapons/Ranged/EternalBlizzard.cs index 988223ece0..6fa526b7e7 100644 --- a/Items/Weapons/Ranged/EternalBlizzard.cs +++ b/Items/Weapons/Ranged/EternalBlizzard.cs @@ -32,7 +32,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/Eviscerator.cs b/Items/Weapons/Ranged/Eviscerator.cs index 6a6d5e6b82..a6dca96d15 100644 --- a/Items/Weapons/Ranged/Eviscerator.cs +++ b/Items/Weapons/Ranged/Eviscerator.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 22f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults @@ -46,15 +45,5 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 4). - AddIngredient(12). - AddIngredient(ItemID.Vertebrae, 4). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Ranged/FetidEmesis.cs b/Items/Weapons/Ranged/FetidEmesis.cs index 65e5339690..97a65d7165 100644 --- a/Items/Weapons/Ranged/FetidEmesis.cs +++ b/Items/Weapons/Ranged/FetidEmesis.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -11,11 +12,14 @@ namespace CalamityMod.Items.Weapons.Ranged public class FetidEmesis : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 66; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); public override void SetDefaults() { Item.width = 76; Item.height = 46; - Item.damage = 250; + Item.damage = 224; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = 6; Item.useStyle = ItemUseStyleID.Shoot; @@ -33,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; 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); diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index 51ecdc5739..f26eca63a1 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -1,7 +1,8 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -9,89 +10,62 @@ namespace CalamityMod.Items.Weapons.Ranged public class FirestormCannon : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; - } + + public static int AmmoSavedPercent = 33; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + + // This is intentionally stored on the item instead of the holdout to prevent swapping items to instantly reset the heat + // This could be theoretically exploited using multiple items, but the heat dissipates fast enough that I can't really care + public int BuiltUpHeat = 0; + public const int OverheatLevel = 480; + public const int OverheatCooldown = 180; + public const int OverheatDamage = 20; public override void SetDefaults() { Item.width = 56; Item.height = 28; - Item.damage = 14; + Item.damage = 17; Item.DamageType = DamageClass.Ranged; - Item.useTime = 12; - Item.useAnimation = 12; + Item.useTime = Item.useAnimation = 11; + Item.knockBack = 1.5f; + Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 1.5f; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - Item.UseSound = SoundID.Item11; + Item.channel = true; + Item.noUseGraphic = true; Item.autoReuse = true; - Item.shoot = ProjectileID.Flare; + + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 5.5f; Item.useAmmo = AmmoID.Flare; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 70; - - public override bool AltFunctionUse(Player player) => true; - - public override float UseSpeedMultiplier(Player player) + public override void HoldItem(Player player) { - if (player.altFunctionUse == 2) - return 1 / 3f; - return 1f; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (player.altFunctionUse == 2) + player.Calamity().rightClickListener = true; + // Heat decrements if: + // The holdout exists, the player is not firing, the player is not in overheat, and there is heat in the weapon + if (player.ownedProjectileCounts[Item.shoot] > 0 && !Main.mouseLeft && player.Calamity().flareGunOverheat == 0 && BuiltUpHeat > 0) { - velocity *= 2f; - int flareAmt = Main.rand.Next(4, 6); - for (int index = 0; index < flareAmt; ++index) - { - float SpeedX = velocity.X + (float)Main.rand.Next(-50, 51) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-50, 51) * 0.05f; - int flare = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - if (flare.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flare].penetrate = 1; - Main.projectile[flare].timeLeft = 600; - Main.projectile[flare].DamageType = DamageClass.Ranged; - } - } - return false; - } - else - { - int flareAmt = Main.rand.Next(1, 3); - for (int index = 0; index < flareAmt; ++index) - { - float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; - int flare = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - if (flare.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[flare].DamageType = DamageClass.Ranged; - Main.projectile[flare].timeLeft = 200; - Main.projectile[flare].penetrate = 3; - } - } - return false; + BuiltUpHeat -= player.miscCounter % 2 == 0 ? 3 : 2; + if (BuiltUpHeat < 0) + BuiltUpHeat = 0; } } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && !player.Calamity().mouseRight; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; + public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) => type = Item.shoot; + public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.FlareGun). AddIngredient(ItemID.HellstoneBar, 10). + AddIngredient(ItemID.IllegalGunParts). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Ranged/FlakKraken.cs b/Items/Weapons/Ranged/FlakKraken.cs index 868f04b376..76ccecc30f 100644 --- a/Items/Weapons/Ranged/FlakKraken.cs +++ b/Items/Weapons/Ranged/FlakKraken.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 152; Item.height = 58; - Item.damage = 124; + Item.damage = 78; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = OriginalUseTime; Item.knockBack = 0.25f; diff --git a/Items/Weapons/Ranged/FlarewingBow.cs b/Items/Weapons/Ranged/FlarewingBow.cs index a1f6d32d26..b5320a069d 100644 --- a/Items/Weapons/Ranged/FlarewingBow.cs +++ b/Items/Weapons/Ranged/FlarewingBow.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 18f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/FlurrystormCannon.cs b/Items/Weapons/Ranged/FlurrystormCannon.cs index fb1b12d224..3e1221e805 100644 --- a/Items/Weapons/Ranged/FlurrystormCannon.cs +++ b/Items/Weapons/Ranged/FlurrystormCannon.cs @@ -3,6 +3,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -10,6 +11,10 @@ namespace CalamityMod.Items.Weapons.Ranged public class FlurrystormCannon : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 68; @@ -33,13 +38,12 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Snowball; Item.shootSpeed = 18f; - Item.Calamity().canFirePointBlankShots = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; // Spawning the holdout cannot consume ammo - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool() && player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) => type = Item.shoot; diff --git a/Items/Weapons/Ranged/FreedomStar.cs b/Items/Weapons/Ranged/FreedomStar.cs index cf45be4de1..e237779ec0 100644 --- a/Items/Weapons/Ranged/FreedomStar.cs +++ b/Items/Weapons/Ranged/FreedomStar.cs @@ -12,11 +12,6 @@ namespace CalamityMod.Items.Weapons.Ranged public class FreedomStar : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - // This is the amount of charge consumed every time the holdout projectile fires various projectiles. - public const float HoldoutChargeUse_Orb = 0.004f; - public const float HoldoutChargeUse_OrbLarge = 0.005f; - public const float HoldoutChargeUse_Laser = 0.006f; - public const float HoldoutChargeUse_LaserLarge = 0.01f; public override void SetDefaults() { @@ -38,9 +33,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item75; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; - modItem.UsesCharge = true; - modItem.MaxCharge = 150f; - modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); @@ -63,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(18). AddIngredient(8). AddIngredient(ItemID.LunarBar, 4). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/FrostbiteBlaster.cs b/Items/Weapons/Ranged/FrostbiteBlaster.cs index 38f5f1dca7..9712968aa5 100644 --- a/Items/Weapons/Ranged/FrostbiteBlaster.cs +++ b/Items/Weapons/Ranged/FrostbiteBlaster.cs @@ -31,7 +31,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = true; Item.shoot = ProjectileID.Blizzard; Item.shootSpeed = 9f; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-14, 0); diff --git a/Items/Weapons/Ranged/Fungicide.cs b/Items/Weapons/Ranged/Fungicide.cs index 830466446c..33fc6a1542 100644 --- a/Items/Weapons/Ranged/Fungicide.cs +++ b/Items/Weapons/Ranged/Fungicide.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -14,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 40; Item.height = 26; - Item.damage = 20; + Item.damage = 19; Item.DamageType = DamageClass.Ranged; Item.useTime = 22; Item.useAnimation = 22; @@ -28,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 14f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() diff --git a/Items/Weapons/Ranged/Galeforce.cs b/Items/Weapons/Ranged/Galeforce.cs index 8fbc80de2b..e6d5027ac3 100644 --- a/Items/Weapons/Ranged/Galeforce.cs +++ b/Items/Weapons/Ranged/Galeforce.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 20f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -47,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Ranged CreateRecipe(). AddIngredient(8). AddIngredient(ItemID.SunplateBlock, 3). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Ranged/GoldenEagle.cs b/Items/Weapons/Ranged/GoldenEagle.cs index 87466ac4f7..f280982f63 100644 --- a/Items/Weapons/Ranged/GoldenEagle.cs +++ b/Items/Weapons/Ranged/GoldenEagle.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,16 +11,15 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; private const float Spread = 0.0425f; - public override void SetDefaults() { Item.width = 46; Item.height = 30; - Item.damage = 85; + Item.damage = 88; Item.DamageType = DamageClass.Ranged; Item.noMelee = true; - Item.useTime = 19; - Item.useAnimation = 19; + Item.useTime = 18; + Item.useAnimation = 18; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 3f; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 20f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); diff --git a/Items/Weapons/Ranged/Goobow.cs b/Items/Weapons/Ranged/Goobow.cs index 6b51c5ba4b..b4ecc5f53c 100644 --- a/Items/Weapons/Ranged/Goobow.cs +++ b/Items/Weapons/Ranged/Goobow.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -30,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -62,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Ranged CreateRecipe(). AddIngredient(18). AddIngredient(18). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Weapons/Ranged/GunkShot.cs b/Items/Weapons/Ranged/GunkShot.cs index 175b7691be..2db7216cbd 100644 --- a/Items/Weapons/Ranged/GunkShot.cs +++ b/Items/Weapons/Ranged/GunkShot.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -29,7 +28,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 5f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() @@ -54,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Ranged CreateRecipe(). AddIngredient(18). AddIngredient(18). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Weapons/Ranged/HalibutCannon.cs b/Items/Weapons/Ranged/HalibutCannon.cs index 7dc5bc4243..82e65e004e 100644 --- a/Items/Weapons/Ranged/HalibutCannon.cs +++ b/Items/Weapons/Ranged/HalibutCannon.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -using System.Linq; using CalamityMod.Rarities; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -32,7 +30,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-15, 0); diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index 4068714c06..c6fbde9718 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -1,10 +1,13 @@ -using CalamityMod.Items.Materials; +using System.Linq; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics; using Terraria.ID; using Terraria.ModLoader; @@ -16,6 +19,14 @@ namespace CalamityMod.Items.Weapons.Ranged public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/HalleysInfernoShoot") { Volume = 0.68f }; public static readonly SoundStyle Hit = new("CalamityMod/Sounds/Item/HalleysInfernoHit") { Volume = 0.75f }; + public static float MaxStarburstPerComet => 1; + public static float MaxStarburstPerStar => 0.25f; + public static float LostAccuracyPerMiss => 4; + public static float MaxAccuracy => 50; + + public static float StarburstDmgMult => 1.25f; + + public static float StarburstVelMult = 0.75f; public override void SetDefaults() { Item.width = 84; @@ -32,8 +43,9 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = true; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; Item.shootSpeed = 12f; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; @@ -41,15 +53,30 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); } + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + } // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20; + public override void HoldItem(Player player) + { + if (Main.LocalPlayer == player) + { + if (!Main.projectile.Any(x=> x.active && x.owner == player.whoAmI && x.type == Item.shoot)) + { + Projectile.NewProjectile(player.GetSource_ItemUse(Item),player.Center,Vector2.Zero,Item.shoot,0,0,player.whoAmI); + } + } + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); + player.Calamity().ammoCost *= 0.5f; + } - public override Vector2? HoldoutOffset() => new Vector2(-15, 0); - - public override void HoldItem(Player player) => player.scope = true; - - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 50; + public override bool CanUseItem(Player player) + { + return false; + } public override void AddRecipes() { @@ -58,7 +85,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(6). AddIngredient(4). AddIngredient(12). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/HandheldTank.cs b/Items/Weapons/Ranged/HandheldTank.cs index 45ca6ba331..9e0189cacd 100644 --- a/Items/Weapons/Ranged/HandheldTank.cs +++ b/Items/Weapons/Ranged/HandheldTank.cs @@ -21,8 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.DamageType = DamageClass.Ranged; Item.damage = 740; Item.knockBack = 16f; - Item.useTime = 84; - Item.useAnimation = 84; + Item.useTime = Item.useAnimation = 74; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Shoot; @@ -52,11 +51,11 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(ItemID.RocketLauncher). AddRecipeGroup("IronBar", 50). AddIngredient(5). AddIngredient(ItemID.TigerSkin). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/HavocsBreath.cs b/Items/Weapons/Ranged/HavocsBreath.cs index fa23d2cd9b..9ca4a9a5a4 100644 --- a/Items/Weapons/Ranged/HavocsBreath.cs +++ b/Items/Weapons/Ranged/HavocsBreath.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 68; Item.height = 26; - Item.damage = 74; + Item.damage = 62; Item.DamageType = DamageClass.Ranged; Item.useTime = 5; Item.useAnimation = 35; diff --git a/Items/Weapons/Ranged/HeavenlyGale.cs b/Items/Weapons/Ranged/HeavenlyGale.cs index 3c3643b112..42c7c55d87 100644 --- a/Items/Weapons/Ranged/HeavenlyGale.cs +++ b/Items/Weapons/Ranged/HeavenlyGale.cs @@ -5,7 +5,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -53,9 +52,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; Item.useTurn = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.Calamity().canFirePointBlankShots = true; } // Shoot via the projectile only diff --git a/Items/Weapons/Ranged/Hellborn.cs b/Items/Weapons/Ranged/Hellborn.cs index 0dedc0af37..4dd558e453 100644 --- a/Items/Weapons/Ranged/Hellborn.cs +++ b/Items/Weapons/Ranged/Hellborn.cs @@ -1,10 +1,9 @@ using System.Linq; using CalamityMod.Cooldowns; -using CalamityMod.Items.Accessories; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -23,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 62; Item.height = 34; - Item.damage = 320; + Item.damage = 423; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Shoot; @@ -51,11 +50,11 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.Calamity().cooldowns.TryGetValue(HellbornShots.ID, out var cooldown)) { - cooldown.timeLeft = 8 - player.Calamity().hellbornShots; + cooldown.timeLeft = 12 - player.Calamity().hellbornShots; } else { - player.AddCooldown(HellbornShots.ID, 8); + player.AddCooldown(HellbornShots.ID, 12); } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/Helstorm.cs b/Items/Weapons/Ranged/Helstorm.cs index dfb6c5bb78..759c3af8c5 100644 --- a/Items/Weapons/Ranged/Helstorm.cs +++ b/Items/Weapons/Ranged/Helstorm.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 11.5f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() diff --git a/Items/Weapons/Ranged/HoarfrostBow.cs b/Items/Weapons/Ranged/HoarfrostBow.cs index 6dcc2a5750..0fa9153c7b 100644 --- a/Items/Weapons/Ranged/HoarfrostBow.cs +++ b/Items/Weapons/Ranged/HoarfrostBow.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -29,7 +30,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/Hydra.cs b/Items/Weapons/Ranged/Hydra.cs index 521f677b7a..207ae0eb05 100644 --- a/Items/Weapons/Ranged/Hydra.cs +++ b/Items/Weapons/Ranged/Hydra.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; //Editable stats: - public const int BulletsPerShot = 4; + public const int BulletsPerShot = 3; public const float ShotSpread = 10f; //in degrees public const int TimeToSpawnHead = 3; //in seconds public const int MaximumHeadCount = 3; @@ -47,7 +47,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.UseSound = null; //does so in Shoot - Item.Calamity().canFirePointBlankShots = true; } public override bool CanConsumeAmmo(Item ammo, Player player) => player.altFunctionUse == 2 ? false : true; @@ -55,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void UpdateInventory(Player player) { //Spawn heads while holding - if (player.ActiveItem() == Item && player.ownedProjectileCounts[HeadID] < MaximumHeadCount) + if (player.HeldItem == Item && player.ownedProjectileCounts[HeadID] < MaximumHeadCount) { HeadSpawnTimer++; if (HeadSpawnTimer >= TimeToSpawnHead * 60) @@ -66,7 +65,7 @@ namespace CalamityMod.Items.Weapons.Ranged head.OriginalCritChance = Item.crit; } } - else if (player.ActiveItem().type != Item.type || player.dead || !player.active) + else if (player.HeldItem.type != Item.type || player.dead || !player.active) { foreach (Projectile p in Main.ActiveProjectiles) { @@ -97,7 +96,7 @@ 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) { Vector2 shootDirection = velocity.SafeNormalize(Vector2.Zero); - for (int i = 0; i < 4; i++) + for (int i = 0; i < BulletsPerShot; i++) { int CurrentHeadCount = player.ownedProjectileCounts[HeadID]; //Exponentially louder the more heads, slightly diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 6f702331f1..4eb04468eb 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -16,6 +17,10 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; public int SineCounter = 0; + + public static int AmmoSavedPercent = 80; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; @@ -25,36 +30,30 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 85; + Item.damage = 75; Item.DamageType = DamageClass.Ranged; Item.useTime = 1; Item.useAnimation = 4; + Item.useLimitPerAnimation = 4; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item31; Item.autoReuse = true; Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 6f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; + Item.consumeAmmoOnLastShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - public override bool AltFunctionUse(Player player) - { - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); + 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) { - int shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); + int shotType = player.altFunctionUse == 2 ? type : ModContent.ProjectileType(); // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction position = position + (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.UnitX) * 65; @@ -62,24 +61,27 @@ namespace CalamityMod.Items.Weapons.Ranged SineCounter++; if (SineCounter % 4 == 0) { - Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); - Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 1f); - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 1f); + for (int i = -1; i <= 1; i += 2) + { + Vector2 helixVel = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(i * sine)); + Projectile.NewProjectile(source, position, helixVel, shotType, damage, knockback, player.whoAmI, 0, 0, player.altFunctionUse != 2 ? 1 : 0); + } } else if (player.altFunctionUse != 2) { Particle spark2 = new LineParticle(position + Main.rand.NextVector2Circular(6, 6), (velocity * 4).RotatedByRandom(0.2f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(1.5f, 2f), new Color(229, 49, 39)); GeneralParticleHandler.SpawnParticle(spark2); } + + // Reset altFunctionUse to zero to prevent blank frame appear between shots on Alt-fire + if (player.itemAnimation <= 1) + player.altFunctionUse = 0; + return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) > 80 && SineCounter % 4 == 0) - return true; - return false; - } + + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/Karasawa.cs b/Items/Weapons/Ranged/Karasawa.cs index cbcef379cc..a8ed967b01 100644 --- a/Items/Weapons/Ranged/Karasawa.cs +++ b/Items/Weapons/Ranged/Karasawa.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; Item.shoot = ModContent.ProjectileType(); @@ -41,10 +41,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Bullet; } - public override bool CanUseItem(Player player) - { - return CalamityGlobalItem.HasEnoughAmmo(player, Item, 5); - } + public override bool CanUseItem(Player player) => CalamityGlobalItem.HasEnoughAmmo(player, Item, 5); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -57,20 +54,13 @@ namespace CalamityMod.Items.Weapons.Ranged // Consume 5 ammo per shot CalamityGlobalItem.ConsumeAdditionalAmmo(player, Item, 5); - return false; } // Disable vanilla ammo consumption - public override bool CanConsumeAmmo(Item ammo, Player player) - { - return false; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => false; - public override Vector2? HoldoutOffset() - { - return new Vector2(-20, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-20, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Kingsbane.cs b/Items/Weapons/Ranged/Kingsbane.cs index 1fd0f82a85..277365c178 100644 --- a/Items/Weapons/Ranged/Kingsbane.cs +++ b/Items/Weapons/Ranged/Kingsbane.cs @@ -4,9 +4,9 @@ using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -15,11 +15,15 @@ namespace CalamityMod.Items.Weapons.Ranged public class Kingsbane : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 95; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 92; Item.height = 44; - Item.damage = 245; + Item.damage = 249; Item.DamageType = DamageClass.Ranged; Item.useTime = 3; Item.useAnimation = 3; @@ -34,10 +38,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 2f; Item.useAmmo = AmmoID.Bullet; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.95f && player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; 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, position, velocity, Item.shoot, damage, knockback, player.whoAmI); @@ -52,6 +56,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.ChainGun). AddIngredient(). AddIngredient(5). + AddIngredient(3). AddTile(). Register(); } diff --git a/Items/Weapons/Ranged/Leviatitan.cs b/Items/Weapons/Ranged/Leviatitan.cs index 61010b9c37..31f5298295 100644 --- a/Items/Weapons/Ranged/Leviatitan.cs +++ b/Items/Weapons/Ranged/Leviatitan.cs @@ -1,8 +1,6 @@ using System; -using System.Diagnostics.Metrics; -using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Ranged; -using Microsoft.Build.Tasks; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -27,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 82; Item.height = 28; - Item.damage = 121; + Item.damage = 89; Item.DamageType = DamageClass.Ranged; Item.useTime = Item.useAnimation = 18; //Try not to change this if you can help it. Item.noMelee = true; @@ -40,7 +38,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 13f; Item.useStyle = ItemUseStyleID.Shoot; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); @@ -58,7 +55,7 @@ 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) { - // Reposition to the gun's tip. Calculated seperately due to the two different shot styles. + // Reposition to the gun's tip. Calculated separately due to the two different shot styles. Vector2 boulderPos = position + new Vector2(74f, player.direction * (Math.Abs(velocity.SafeNormalize(Vector2.Zero).X) < 0.02f ? -2f : -8f)).RotatedBy(velocity.ToRotation()); Vector2 shotPos = position + new Vector2(74f, player.direction * (Math.Abs(velocity.SafeNormalize(Vector2.Zero).X) < 0.02f ? -6f : 3f)).RotatedBy(velocity.ToRotation()); diff --git a/Items/Weapons/Ranged/LunarianBow.cs b/Items/Weapons/Ranged/LunarianBow.cs index ea46bd671f..c4cbe5856e 100644 --- a/Items/Weapons/Ranged/LunarianBow.cs +++ b/Items/Weapons/Ranged/LunarianBow.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/M1Garand.cs b/Items/Weapons/Ranged/M1Garand.cs new file mode 100644 index 0000000000..ff034f96b2 --- /dev/null +++ b/Items/Weapons/Ranged/M1Garand.cs @@ -0,0 +1,62 @@ +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.DataStructures; +using static Terraria.ModLoader.ModContent; +using CalamityMod.Cooldowns; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class M1Garand : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() + { + Item.width = 102; + Item.height = 22; + Item.damage = 75; + Item.DamageType = DamageClass.Ranged; + + Item.useTime = 40; + Item.useAnimation = 40; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 2f; + Item.autoReuse = false; // Because holdout + Item.channel = true; // Because holdout + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 12f; + Item.useAmmo = AmmoID.Bullet; + Item.noUseGraphic = true; + + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + } + + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 10; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) + { + if (player.Calamity().cooldowns.TryGetValue(M1GarandShots.ID, out var cooldown)) + { + cooldown.timeLeft = 8 - player.Calamity().garandShots; + } + else + { + player.AddCooldown(M1GarandShots.ID, 8); + } + } + + 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, ProjectileType(), damage, knockback, player.whoAmI); + + // Seting its velocity like this is what aims to the mouse + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + + return false; + } + } +} diff --git a/Items/Weapons/Ranged/M1Garand.png b/Items/Weapons/Ranged/M1Garand.png new file mode 100644 index 0000000000..a0b47c6f6d Binary files /dev/null and b/Items/Weapons/Ranged/M1Garand.png differ diff --git a/Items/Weapons/Ranged/MagnaCannon.cs b/Items/Weapons/Ranged/MagnaCannon.cs index d31343d31b..0ec26d25e0 100644 --- a/Items/Weapons/Ranged/MagnaCannon.cs +++ b/Items/Weapons/Ranged/MagnaCannon.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public static readonly SoundStyle Fire = new("CalamityMod/Sounds/Item/MagnaCannonShot") { PitchVariance = 0.3f, Volume = 0.4f }; public static int AftershotCooldownFrames = 30; - public static int FullChargeFrames = 138; //126 frames is durration of charge sound + public static int FullChargeFrames = 138; //126 frames is duration of charge sound public new string LocalizationCategory => "Items.Weapons.Ranged"; @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 34; - Item.damage = 30; + Item.damage = 25; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = AftershotCooldownFrames; Item.useStyle = ItemUseStyleID.Shoot; @@ -42,7 +42,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = false; Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); - Item.Calamity().canFirePointBlankShots = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; diff --git a/Items/Weapons/Ranged/MagnomalyCannon.cs b/Items/Weapons/Ranged/MagnomalyCannon.cs index c329d10c8c..27c689dd12 100644 --- a/Items/Weapons/Ranged/MagnomalyCannon.cs +++ b/Items/Weapons/Ranged/MagnomalyCannon.cs @@ -1,11 +1,11 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Weapons.Typeless; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -13,6 +13,10 @@ namespace CalamityMod.Items.Weapons.Ranged public class MagnomalyCannon : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 84; @@ -30,22 +34,14 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; Item.useAmmo = AmmoID.Rocket; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } - public override Vector2? HoldoutOffset() - { - return new Vector2(-30, -10); - } + public override Vector2? HoldoutOffset() => new Vector2(-30, -10); public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) => type = Item.shoot; - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 66) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Malevolence.cs b/Items/Weapons/Ranged/Malevolence.cs index 0645679232..60283a1ddd 100644 --- a/Items/Weapons/Ranged/Malevolence.cs +++ b/Items/Weapons/Ranged/Malevolence.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -49,15 +48,5 @@ namespace CalamityMod.Items.Weapons.Ranged } return false; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.BeesKnees). - AddIngredient(5). - AddIngredient(10). - AddTile(TileID.MythrilAnvil). - Register(); - } } } diff --git a/Items/Weapons/Ranged/MarksmanBow.cs b/Items/Weapons/Ranged/MarksmanBow.cs index 155944b311..04583dd290 100644 --- a/Items/Weapons/Ranged/MarksmanBow.cs +++ b/Items/Weapons/Ranged/MarksmanBow.cs @@ -13,10 +13,12 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 36; Item.height = 110; - Item.damage = 35; + Item.damage = 39; Item.DamageType = DamageClass.Ranged; - Item.useTime = 18; - Item.useAnimation = 18; + Item.useTime = 5; + Item.useAnimation = 15; + Item.useLimitPerAnimation = 3; + Item.reuseDelay = 10; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 6f; @@ -29,11 +31,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20; + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 10; public override Vector2? HoldoutOffset() => new Vector2(-4, 0); @@ -43,20 +44,16 @@ namespace CalamityMod.Items.Weapons.Ranged if (CalamityUtils.CheckWoodenAmmo(type, player)) type = ProjectileID.JestersArrow; - for (int i = 0; i < 3; i++) + float SpeedX = velocity.X + Main.rand.NextFloat(-0.5f, 0.5f); + float SpeedY = velocity.Y + Main.rand.NextFloat(-0.5f, 0.5f); + int arrow = Projectile.NewProjectile(source, position, new Vector2(SpeedX, SpeedY), type, damage, knockback, player.whoAmI); + Main.projectile[arrow].noDropItem = true; + if (type == ProjectileID.JestersArrow) { - int randomExtraUpdates = Main.rand.Next(3); - float SpeedX = velocity.X + Main.rand.NextFloat(-10f, 10f) * 0.05f; - float SpeedY = velocity.Y + Main.rand.NextFloat(-10f, 10f) * 0.05f; - int arrow = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - Main.projectile[arrow].noDropItem = true; - Main.projectile[arrow].extraUpdates += randomExtraUpdates; //0 to 2 extra updates - if (type == ProjectileID.JestersArrow) - { - Main.projectile[arrow].localNPCHitCooldown = 10 * (randomExtraUpdates + 1); - Main.projectile[arrow].usesLocalNPCImmunity = true; - Main.projectile[arrow].tileCollide = false; - } + Main.projectile[arrow].localNPCHitCooldown = 12 * Main.projectile[arrow].MaxUpdates; + Main.projectile[arrow].usesLocalNPCImmunity = true; + Main.projectile[arrow].usesIDStaticNPCImmunity = false; + Main.projectile[arrow].tileCollide = false; } return false; } diff --git a/Items/Weapons/Ranged/Megalodon.cs b/Items/Weapons/Ranged/Megalodon.cs index 5f22951eac..deaea9191e 100644 --- a/Items/Weapons/Ranged/Megalodon.cs +++ b/Items/Weapons/Ranged/Megalodon.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 72; Item.height = 32; - Item.damage = 41; + Item.damage = 29; Item.DamageType = DamageClass.Ranged; Item.useTime = 6; Item.useAnimation = 6; @@ -33,7 +33,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); @@ -42,11 +41,11 @@ namespace CalamityMod.Items.Weapons.Ranged { // Reposition to the gun's tip + add some inaccuracy Vector2 newPos = position + new Vector2(64f, player.direction * (Math.Abs(velocity.SafeNormalize(Vector2.Zero).X) < 0.02f ? -2f : -8f)).RotatedBy(velocity.ToRotation()); - Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(5f)); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(3f)); // Fire either the bullet or the water jet, depending on cadence. int projectileToFire = fireWater ? Item.shoot : type; - Projectile.NewProjectile(source, newPos, newVel, projectileToFire, (int)(damage * 0.8f), knockback, player.whoAmI); + Projectile.NewProjectile(source, newPos, newVel, projectileToFire, damage, knockback, player.whoAmI); // Always fires a close range water blast. // It goes in the same direction as the main shot but has a minor velocity variation to be less monotonous. diff --git a/Items/Weapons/Ranged/MidasPrime.cs b/Items/Weapons/Ranged/MidasPrime.cs index 80ec7fb0ed..ee3a74f18d 100644 --- a/Items/Weapons/Ranged/MidasPrime.cs +++ b/Items/Weapons/Ranged/MidasPrime.cs @@ -43,7 +43,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; Item.shootSpeed = 14f; - Item.Calamity().canFirePointBlankShots = true; } // This item has a right click. diff --git a/Items/Weapons/Ranged/MonolithBow.cs b/Items/Weapons/Ranged/MonolithBow.cs index fa8b2ea872..be48baab00 100644 --- a/Items/Weapons/Ranged/MonolithBow.cs +++ b/Items/Weapons/Ranged/MonolithBow.cs @@ -1,5 +1,5 @@ using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureMonolith; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -31,7 +31,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 9f; Item.useAmmo = AmmoID.Arrow; Item.consumeAmmoOnFirstShotOnly = true; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/Monsoon.cs b/Items/Weapons/Ranged/Monsoon.cs index 1b018e6854..519b914bea 100644 --- a/Items/Weapons/Ranged/Monsoon.cs +++ b/Items/Weapons/Ranged/Monsoon.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -17,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 46; Item.height = 78; - Item.damage = 152; + Item.damage = 156; Item.DamageType = DamageClass.Ranged; Item.useTime = 20; Item.useAnimation = 20; @@ -31,7 +30,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.WoodenArrowFriendly; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -67,10 +65,7 @@ namespace CalamityMod.Items.Weapons.Ranged } int proj = Projectile.NewProjectile(spawnSource, source.X + offset.X, source.Y + offset.Y, velocity.X, velocity.Y, newType, (int)(damage * 1.1), knockback, player.whoAmI); if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].arrow = true; Main.projectile[proj].extraUpdates += 1; - } } else { @@ -88,7 +83,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(). AddIngredient(6). AddIngredient(10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/NettlevineGreatbow.cs b/Items/Weapons/Ranged/NettlevineGreatbow.cs index db0811ac93..486f5f7cf7 100644 --- a/Items/Weapons/Ranged/NettlevineGreatbow.cs +++ b/Items/Weapons/Ranged/NettlevineGreatbow.cs @@ -30,7 +30,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 16f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -77,7 +76,7 @@ namespace CalamityMod.Items.Weapons.Ranged { CreateRecipe(). AddIngredient(12). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/NitroExpressRifle.cs b/Items/Weapons/Ranged/NitroExpressRifle.cs index 021467e500..ee5b504667 100644 --- a/Items/Weapons/Ranged/NitroExpressRifle.cs +++ b/Items/Weapons/Ranged/NitroExpressRifle.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; -using CalamityMod.Sounds; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -35,7 +31,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; Item.rare = ItemRarityID.LightRed; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, 8); @@ -80,30 +75,6 @@ namespace CalamityMod.Items.Weapons.Ranged Vector2 itemSize = new Vector2(Item.width, Item.height); Vector2 itemOrigin = new Vector2(-5, 6); - - //Sniper's horizontal recoil; can be a bit subtle but it is noticeable - if (player.altFunctionUse == 2) - { - //Recoil: - int anim = 0; - for (int r = 0; r < Item.useAnimation; ++r) - { - if (anim == 10 && r < Item.useAnimation / 2) //animates every 10 frames so that the player notices a recoil because this happens way too fast - { - itemPosition.X -= player.direction * 0.025f; - itemPosition.Y -= player.direction * 0.025f; - anim = 0; - } - else if (anim == 10 && r > Item.useAnimation / 2) - { - itemPosition.X += player.direction * 0.025f; - itemPosition.Y += player.direction * 0.025f; - anim = 0; - } - ++anim; - } - } - CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); base.UseStyle(player, heldItemFrame); } @@ -116,7 +87,7 @@ namespace CalamityMod.Items.Weapons.Ranged float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; if (animProgress < 0.5) - rotation += (player.altFunctionUse == 2 ? -1f : -0.45f) * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction; + rotation += -0.45f * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction; player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); //must be here otherwise it will vibrate diff --git a/Items/Weapons/Ranged/Norfleet.cs b/Items/Weapons/Ranged/Norfleet.cs index ab4a0922b6..5e1b8da3e9 100644 --- a/Items/Weapons/Ranged/Norfleet.cs +++ b/Items/Weapons/Ranged/Norfleet.cs @@ -1,9 +1,9 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -13,7 +13,6 @@ namespace CalamityMod.Items.Weapons.Ranged public class Norfleet : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public int loadedShots = 3; public override void SetStaticDefaults() { @@ -23,55 +22,46 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 140; Item.height = 42; - Item.damage = 7777; + Item.damage = 5678; + Item.DamageType = DamageClass.Ranged; + Item.crit = 16; + Item.useTime = Item.useAnimation = 70; Item.knockBack = 15f; Item.shootSpeed = 30f; + Item.useStyle = ItemUseStyleID.Shoot; - Item.useAnimation = 70; - Item.useTime = 70; Item.UseSound = null; Item.shoot = ModContent.ProjectileType(); Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.noMelee = true; Item.noUseGraphic = true; - Item.DamageType = DamageClass.Ranged; Item.channel = true; Item.autoReuse = true; } 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) { - // 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); + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI); // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction // 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; } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(8). + AddIngredient(20). + AddTile(). + Register(); + } } } diff --git a/Items/Weapons/Ranged/NullificationPistol.cs b/Items/Weapons/Ranged/NullificationPistol.cs index f196a583e4..dbc8265159 100644 --- a/Items/Weapons/Ranged/NullificationPistol.cs +++ b/Items/Weapons/Ranged/NullificationPistol.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public bool shotType = true; // true = positive shot, false = negative shot public float mult = 0; + public static SoundStyle HitSound = new("CalamityMod/Sounds/Item/NullHit"); public override void SetStaticDefaults() { @@ -42,17 +43,16 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool AltFunctionUse(Player player) => true; public override float UseSpeedMultiplier(Player player) { - if (player.altFunctionUse == 2) - return 1.3f; + return 1.3f - (float)(1 - Math.Pow(Utils.GetLerpValue(0, shotType ? 0.175f : 0.25f, mult, true), 2.5f)); if (Main.zenithWorld) return 3 * (shotType ? 0.7f : 1); if (!shotType) - return 1.5f - mult; + return 1.5f - ((mult > 0.25f) ? mult : 0); - return 1f - mult; + return 1f - ((mult > 0.175f) ? mult : 0); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -74,7 +74,8 @@ namespace CalamityMod.Items.Weapons.Ranged { for (int i = 0; i < 3; i++) Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage / 3, 0, player.whoAmI, 0, 0, i); - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage / 2, 0, player.whoAmI, 0, 0); + if (mult < 0.175f) + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, 0, player.whoAmI, 0, 0); if (mult < 0.35f) mult += 0.013f; } @@ -82,14 +83,27 @@ namespace CalamityMod.Items.Weapons.Ranged { Projectile aBeam = Projectile.NewProjectileDirect(source, position, velocity, ModContent.ProjectileType(), (int)(damage * 0.7f), 0, player.whoAmI, 0, 5); aBeam.penetrate = 1; - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage / 2, 0, player.whoAmI, 0, 5); + if (mult < 0.25f) + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), (int)(damage * 0.75f), 0, player.whoAmI, 0, 5); if (mult < 0.5f) mult += 0.013f; } if (player.altFunctionUse != 2) { SoundStyle fire = new("CalamityMod/Sounds/Item/NullShot"); - SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0f, 0.2f) + (!shotType ? 0.3f : 0) }, position); + SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0f, 0.2f) + (!shotType ? 0.3f : 0) - (shotType ? ((mult > 0.25f) ? mult : 0) : ((mult > 0.175f) ? mult : 0)) }, position); + + if (mult >= (shotType ? 0.175f : 0.25f)) + { + for (int i = 0; i < 18; i++) + { + Dust dust = Dust.NewDustPerfect(position + velocity * 8, ModContent.DustType(), (velocity).RotatedByRandom(0.5) * Main.rand.NextFloat(0.4f, 1f)); + dust.noGravity = !Main.rand.NextBool(4); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f); + dust.color = Main.rand.NextBool() ? Color.White : (Main.rand.NextBool() ? Color.Orchid : Color.Turquoise); + dust.fadeIn = 7.5f; + } + } } return false; } diff --git a/Items/Weapons/Ranged/OntologicalDespoiler.cs b/Items/Weapons/Ranged/OntologicalDespoiler.cs index 89fb5c4a7a..577180c67e 100644 --- a/Items/Weapons/Ranged/OntologicalDespoiler.cs +++ b/Items/Weapons/Ranged/OntologicalDespoiler.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Linq; +using System.Linq; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; @@ -38,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 88; Item.height = 34; - Item.damage = 387; + Item.damage = 445; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = 8; Item.noMelee = true; @@ -55,15 +54,12 @@ namespace CalamityMod.Items.Weapons.Ranged } public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 25; public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - public override void HoldItem(Player player) { if (Main.myPlayer == player.whoAmI) player.Calamity().rightClickListener = true; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { // Only one out at a time @@ -74,11 +70,15 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse) { - Projectile holdout2 = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.ActiveItem().damage, 0f, player.whoAmI, 0, 0, 10 + (shotType ? 5 : 0)); + int aiType = 10 + (shotType ? 5 : 0); + if (!player.Calamity().despoilerNerf) + aiType = 20; + Projectile holdout2 = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.HeldItem.damage, 0f, player.whoAmI, 0, 0, aiType); holdout2.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); SoundStyle fire = new("CalamityMod/Sounds/Item/DudFire"); - SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (shotType ? 0.5f : 0) }, player.Center); - shotType = !shotType; + SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = aiType == 20 ? -0.7f : (-0.5f + (shotType ? 0.5f : 0)) }, player.Center); + if (aiType != 20) + shotType = !shotType; } else { @@ -87,39 +87,13 @@ namespace CalamityMod.Items.Weapons.Ranged } return false; } - public override void ModifyTooltips(List list) - { - Player Owner = Main.LocalPlayer; - if (Owner is null) - return; - float rate = (Main.GlobalTimeWrappedHourly * 3); - List eColors = new List() - { - Owner.shirtColor, - Color.Lerp(Owner.shirtColor, Color.Black, 0.3f), - Color.Lerp(Owner.shirtColor, Color.White, 0.2f), - Color.Lerp(Owner.shirtColor, Color.White, 0.4f) - }; - int colorIndex = (int)(rate / 2 % eColors.Count); - Color currentColor = eColors[colorIndex]; - Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; - Color eTooltipColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); - if (Owner.shirtColor == Color.White) - eTooltipColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - - TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip7"); - if (line != null) - line.OverrideColor = Color.Lerp(eTooltipColor, Color.White, 0.2f); - } - public override void AddRecipes() { CreateRecipe(). AddIngredient(). AddIngredient(). - AddIngredient(2). - AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddIngredient(3). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/OnyxChainBlaster.cs b/Items/Weapons/Ranged/OnyxChainBlaster.cs index 4dddf0b7fd..dfba364ec7 100644 --- a/Items/Weapons/Ranged/OnyxChainBlaster.cs +++ b/Items/Weapons/Ranged/OnyxChainBlaster.cs @@ -2,6 +2,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -9,11 +10,15 @@ namespace CalamityMod.Items.Weapons.Ranged public class OnyxChainBlaster : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 64; Item.height = 32; - Item.damage = 51; + Item.damage = 58; Item.DamageType = DamageClass.Ranged; Item.useTime = 15; Item.useAnimation = 15; @@ -27,19 +32,15 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.BlackBolt; Item.shootSpeed = 24f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { // Fire the Onyx Shard that is characteristic of the Onyx Blaster - // The shard deals 250% damage and double knockback - int shardDamage = (int)(2.5f * damage); + // The shard deals 200% damage and double knockback + int shardDamage = 2 * damage; float shardKB = 2f * knockback; Vector2 offset = new Vector2(Main.rand.Next(-25, 26) * 0.05f, Main.rand.Next(-25, 26) * 0.05f); Projectile shard = Projectile.NewProjectileDirect(source, position, velocity + offset, ProjectileID.BlackBolt, shardDamage, shardKB, player.whoAmI); @@ -53,12 +54,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override void AddRecipes() { @@ -66,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.OnyxBlaster). AddIngredient(ItemID.ChainGun). AddIngredient(ItemID.LunarBar, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/Onyxia.cs b/Items/Weapons/Ranged/Onyxia.cs index 175f3a44a0..4b7a75c87c 100644 --- a/Items/Weapons/Ranged/Onyxia.cs +++ b/Items/Weapons/Ranged/Onyxia.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -12,7 +13,9 @@ namespace CalamityMod.Items.Weapons.Ranged public class Onyxia : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - const int NotConsumeAmmo = 50; + + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); public override void SetDefaults() { @@ -25,19 +28,15 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.knockBack = 4.5f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item36; Item.autoReuse = true; Item.shoot = ProjectileID.BlackBolt; Item.shootSpeed = 28f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-11, 3); - } + public override Vector2? HoldoutOffset() => new Vector2(-11, 3); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -61,12 +60,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < NotConsumeAmmo) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index e2abf396ac..74b412be00 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 48; Item.height = 24; - Item.damage = 33; + Item.damage = 30; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = AftershotCooldownFrames; Item.useStyle = ItemUseStyleID.Shoot; @@ -41,7 +41,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.channel = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; - Item.Calamity().canFirePointBlankShots = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; diff --git a/Items/Weapons/Ranged/OverloadedBlaster.cs b/Items/Weapons/Ranged/OverloadedBlaster.cs index 509277d994..66e42a42cc 100644 --- a/Items/Weapons/Ranged/OverloadedBlaster.cs +++ b/Items/Weapons/Ranged/OverloadedBlaster.cs @@ -1,8 +1,10 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -10,6 +12,9 @@ namespace CalamityMod.Items.Weapons.Ranged public class OverloadedBlaster : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 25; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); public override void SetDefaults() { Item.width = 42; @@ -31,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-4, -5); - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 25; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/P90.cs b/Items/Weapons/Ranged/P90.cs index 6a810bba8d..3382cb756c 100644 --- a/Items/Weapons/Ranged/P90.cs +++ b/Items/Weapons/Ranged/P90.cs @@ -1,10 +1,9 @@ using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Turret; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -13,6 +12,9 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public bool fireShot = true; public override void SetDefaults() { @@ -24,20 +26,16 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; + Item.value = Item.buyPrice(gold: 35); // Sold by Arms Dealer Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item11 with { Volume = 0.6f }; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 9f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-14, -1); - } + public override Vector2? HoldoutOffset() => new Vector2(-14, -1); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -47,6 +45,6 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => fireShot && Main.rand.NextFloat() < 0.25f; + public override bool CanConsumeAmmo(Item ammo, Player player) => fireShot && Main.rand.Next(100) >= AmmoSavedPercent; } } diff --git a/Items/Weapons/Ranged/PearlGod.cs b/Items/Weapons/Ranged/PearlGod.cs index dd50793b44..1250e9ac9a 100644 --- a/Items/Weapons/Ranged/PearlGod.cs +++ b/Items/Weapons/Ranged/PearlGod.cs @@ -10,7 +10,6 @@ using Terraria.ModLoader; using CalamityMod.Rarities; using Terraria.Audio; using CalamityMod.Items.Materials; -using Steamworks; namespace CalamityMod.Items.Weapons.Ranged { @@ -24,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 80; Item.height = 46; - Item.damage = 150; + Item.damage = 160; Item.scale = 0.75f; Item.DamageType = DamageClass.Ranged; Item.useTime = 9; @@ -39,7 +38,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 14f; Item.shoot = ProjectileID.PurificationPowder; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -104,7 +102,7 @@ namespace CalamityMod.Items.Weapons.Ranged int randomColor = Main.rand.Next(1, 3 + 1); Color color = randomColor == 1 ? Color.LightBlue : randomColor == 2 ? Color.LightPink : Color.Khaki; - Dust dust2 = Dust.NewDustPerfect(itemPosition + velocity.RotatedBy(-0.6 * player.direction) + velocity * 1.35f, 278, velocity.RotatedByRandom(0.25) * Main.rand.NextFloat(0.1f, 0.9f)); + Dust dust2 = Dust.NewDustPerfect(itemPosition + velocity.RotatedBy(-0.6 * player.direction) + velocity * 1.35f, DustID.FireworksRGB, velocity.RotatedByRandom(0.25) * Main.rand.NextFloat(0.1f, 0.9f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.3f, 0.45f); dust2.color = color; @@ -159,7 +157,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(5). AddIngredient(2). AddIngredient(ItemID.WhitePearl). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/PestilentDefiler.cs b/Items/Weapons/Ranged/PestilentDefiler.cs index f8eebf70e4..bc9757aeb1 100644 --- a/Items/Weapons/Ranged/PestilentDefiler.cs +++ b/Items/Weapons/Ranged/PestilentDefiler.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index 1b25904346..11a20c6147 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -1,5 +1,4 @@ -using System.Linq; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -9,6 +8,7 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -20,8 +20,9 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; // Left-click stats - public static float AmmoNotConsumeChance = 0.95f; + public static int AmmoSavedPercent = 95; public static int LightBombCooldown = 10; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); // Right-click stats public static float RightClickVelocityMult = 2.5f; @@ -48,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.noUseGraphic = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } diff --git a/Items/Weapons/Ranged/PlagueTaintedSMG.cs b/Items/Weapons/Ranged/PlagueTaintedSMG.cs index c5c81448e0..14523f3158 100644 --- a/Items/Weapons/Ranged/PlagueTaintedSMG.cs +++ b/Items/Weapons/Ranged/PlagueTaintedSMG.cs @@ -1,9 +1,6 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -42,7 +39,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; Item.shoot = ModContent.ProjectileType(); - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-20, 5); diff --git a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs index 6838dd2b28..380832d89e 100644 --- a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs +++ b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs @@ -106,7 +106,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentVortex, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/PolarisParrotfish.cs b/Items/Weapons/Ranged/PolarisParrotfish.cs index ee3f0273a3..331eec6798 100644 --- a/Items/Weapons/Ranged/PolarisParrotfish.cs +++ b/Items/Weapons/Ranged/PolarisParrotfish.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - Item.width = 38; + Item.width = 36; Item.height = 34; Item.damage = 35; Item.DamageType = DamageClass.Ranged; @@ -58,9 +58,9 @@ namespace CalamityMod.Items.Weapons.Ranged Happy = false; player.itemTime = 200; player.itemAnimation = 200; - player.Calamity().GeneralScreenShakePower = 26f; + player.SetScreenshake(26f); player.AddBuff(BuffID.Obstructed, 600); - Main.NewText("Too much love...", 255, 0, 0); + Main.NewText(CalamityUtils.GetTextValue("Misc.Polaris0"), 255, 0, 0); SoundEngine.PlaySound(Squeak with { Pitch = -1f }, player.Center); SoundStyle roar = new("CalamityMod/Sounds/Custom/CeaselessVoidDeathBuild"); SoundEngine.PlaySound(roar with { Pitch = 0.5f }, player.Center); diff --git a/Items/Weapons/Ranged/PolarisParrotfish.png b/Items/Weapons/Ranged/PolarisParrotfish.png index 66364fdc29..3a625316ae 100644 Binary files a/Items/Weapons/Ranged/PolarisParrotfish.png and b/Items/Weapons/Ranged/PolarisParrotfish.png differ diff --git a/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs b/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs index 604367a05d..c8a2b8f899 100644 --- a/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs +++ b/Items/Weapons/Ranged/PridefulHuntersPlanarRipper.cs @@ -1,8 +1,8 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -13,11 +13,14 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; private int counter = 0; + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 68; Item.height = 32; - Item.damage = 74; + Item.damage = 79; Item.DamageType = DamageClass.Ranged; Item.useTime = 5; Item.useAnimation = 5; @@ -34,12 +37,11 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-12, -6); - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(0, 100) >= 33; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) { @@ -63,7 +65,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.Uzi). AddIngredient(ItemID.LunarBar, 5). AddIngredient(ItemID.FragmentVortex, 10). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/PristineFury.cs b/Items/Weapons/Ranged/PristineFury.cs index e1aa81d309..233a1ecc5a 100644 --- a/Items/Weapons/Ranged/PristineFury.cs +++ b/Items/Weapons/Ranged/PristineFury.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using CalamityMod.Cooldowns; +using CalamityMod.Dusts; using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; @@ -8,6 +9,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.CalPlayer; namespace CalamityMod.Items.Weapons.Ranged { @@ -32,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 100; Item.height = 46; - Item.damage = 80; + Item.damage = 77; Item.DamageType = DamageClass.Ranged; Item.useTime = 3; Item.useAnimation = 15; @@ -56,20 +58,38 @@ namespace CalamityMod.Items.Weapons.Ranged // Right click consumes ammo at the same rate but faster at spewing public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 0.5f : 1f; + public override void HoldItem(Player player) + { + int max = CalamityPlayer.FuryFuelMax; + if (player.Calamity().cooldowns.TryGetValue(FuryFuel.ID, out var cooldown)) + { + cooldown.timeLeft = max - player.Calamity().furyFuel; + } + else + { + player.AddCooldown(FuryFuel.ID, max); + } + } + public override bool CanConsumeAmmo(Item ammo, Player player) => player.altFunctionUse != 2; // Right click doesn't use ammo, it's crystal powder not gel public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.altFunctionUse == 2) { - Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(5f)); - Projectile.NewProjectile(source, position, newVel, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + player.Calamity().furyRefuelTimer = -50; + if (player.Calamity().furyFuel > 0) + { + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(5f)); + Projectile.NewProjectile(source, position, newVel, ModContent.ProjectileType(), (int)(damage * 0.25f), knockback, player.whoAmI); //.25x base damage - Dust dust = Dust.NewDustPerfect(position + velocity * 3f + new Vector2(0, -3), ModContent.DustType(), velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.5f, 2.5f), 0, default, Main.rand.NextFloat(0.4f, 0.8f)); - dust.noGravity = true; - dust.color = Color.Orchid; + Dust dust = Dust.NewDustPerfect(position + velocity * 3f + new Vector2(0, -3), ModContent.DustType(), velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.5f, 2.5f), 0, default, Main.rand.NextFloat(0.4f, 0.8f)); + dust.noGravity = true; + dust.color = Color.Orchid; - CritSpark spark = new CritSpark(position + velocity * 3f + new Vector2(0, -3), velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.2f, 1.8f), Color.White, Color.Orchid, 0.9f, 18, 2f, 2.2f); - GeneralParticleHandler.SpawnParticle(spark); + CritSpark spark = new CritSpark(position + velocity * 3f + new Vector2(0, -3), velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.2f, 1.8f), Color.White, Color.Orchid, 0.9f, 18, 2f, 2.2f); + GeneralParticleHandler.SpawnParticle(spark); + player.Calamity().furyFuel -= 15; + } } else { @@ -77,7 +97,7 @@ namespace CalamityMod.Items.Weapons.Ranged Trail = !Trail; for (int i = 0; i <= 2; i++) { - Dust dust = Dust.NewDustPerfect(position + velocity * 3f + new Vector2(0, -3), 158, velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.5f, 2.5f), 0, default, Main.rand.NextFloat(1.6f, 2f)); + Dust dust = Dust.NewDustPerfect(position + velocity * 3f + new Vector2(0, -3), DustID.OrangeTorch, velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.5f, 2.5f), 0, default, Main.rand.NextFloat(1.6f, 2f)); dust.noGravity = true; } CritSpark spark = new CritSpark(position + velocity * 3f + new Vector2(0, -3), velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.2f, 1.8f), Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed, Color.OrangeRed, 0.9f, 18, 2f, 1.9f); diff --git a/Items/Weapons/Ranged/Pumpler.cs b/Items/Weapons/Ranged/Pumpler.cs index 36aeaafe38..b5625dec07 100644 --- a/Items/Weapons/Ranged/Pumpler.cs +++ b/Items/Weapons/Ranged/Pumpler.cs @@ -36,7 +36,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.channel = true; Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 11f; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-30f, 0f); diff --git a/Items/Weapons/Ranged/RealmRavager.cs b/Items/Weapons/Ranged/RealmRavager.cs index baaed6a188..dbd54084f4 100644 --- a/Items/Weapons/Ranged/RealmRavager.cs +++ b/Items/Weapons/Ranged/RealmRavager.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -28,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 30f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); diff --git a/Items/Weapons/Ranged/ReedBlowgun.cs b/Items/Weapons/Ranged/ReedBlowgun.cs index d0939ed636..0a3672d8c9 100644 --- a/Items/Weapons/Ranged/ReedBlowgun.cs +++ b/Items/Weapons/Ranged/ReedBlowgun.cs @@ -2,7 +2,6 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Ranged/Riftburst.cs b/Items/Weapons/Ranged/Riftburst.cs index 61f46860e6..9f7f766745 100644 --- a/Items/Weapons/Ranged/Riftburst.cs +++ b/Items/Weapons/Ranged/Riftburst.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -15,13 +16,16 @@ namespace CalamityMod.Items.Weapons.Ranged public class Riftburst : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 66; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 48; Item.height = 82; - Item.damage = 117; - Item.useTime = 12; - Item.useAnimation = 12; + Item.damage = 91; + Item.useTime = Item.useAnimation = 12; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 3f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; @@ -34,14 +38,13 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; Item.useAmmo = AmmoID.Arrow; - Item.rare = ModContent.RarityType(); - Item.Calamity().canFirePointBlankShots = true; + Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; // Spawning the holdout cannot consume ammo - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(3) && player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/RubicoPrime.cs b/Items/Weapons/Ranged/RubicoPrime.cs index 2042afd288..46a5289e33 100644 --- a/Items/Weapons/Ranged/RubicoPrime.cs +++ b/Items/Weapons/Ranged/RubicoPrime.cs @@ -1,11 +1,6 @@ using System; -using System.Diagnostics.Metrics; -using System.Threading; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; -using CalamityMod.Sounds; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -42,7 +37,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Ranged/SDFMG.cs b/Items/Weapons/Ranged/SDFMG.cs index 93660b0972..68ac499b6d 100644 --- a/Items/Weapons/Ranged/SDFMG.cs +++ b/Items/Weapons/Ranged/SDFMG.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -7,6 +6,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -14,14 +14,18 @@ namespace CalamityMod.Items.Weapons.Ranged public class SDFMG : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 66; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + + private int ShotCounter = 0; public override void SetDefaults() { Item.width = 74; Item.height = 34; - Item.damage = 100; + Item.damage = 118; Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 2; + Item.useTime = Item.useAnimation = 3; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2.75f; @@ -31,33 +35,28 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 16f; Item.useAmmo = AmmoID.Bullet; - Item.rare = ModContent.RarityType(); - Item.Calamity().canFirePointBlankShots = true; + Item.rare = ModContent.RarityType(); } // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 15; - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float SpeedX = velocity.X + Main.rand.Next(-5, 6) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-5, 6) * 0.05f; - if (Main.rand.NextBool(5)) + float SpeedX = velocity.X + Main.rand.NextFloat(-0.25f, 0.25f); + float SpeedY = velocity.Y + Main.rand.NextFloat(-0.25f, 0.25f); + ShotCounter++; + if (ShotCounter >= 7) { + ShotCounter = 0; Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockback, player.whoAmI); } Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Sandblaster.cs b/Items/Weapons/Ranged/Sandblaster.cs index 71bec5ad7c..b48742dd8c 100644 --- a/Items/Weapons/Ranged/Sandblaster.cs +++ b/Items/Weapons/Ranged/Sandblaster.cs @@ -2,8 +2,8 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -12,14 +12,17 @@ namespace CalamityMod.Items.Weapons.Ranged public class Sandblaster : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 62; Item.height = 26; - Item.damage = 80; + Item.damage = 70; Item.DamageType = DamageClass.Ranged; - Item.useTime = 15; - Item.useAnimation = 15; + Item.useTime = Item.useAnimation = 18; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5f; @@ -30,34 +33,20 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Sand; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; - 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); - return false; - } + public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) => type = Item.shoot; public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.Sandgun). + AddIngredient(ItemID.AncientCloth, 5). AddIngredient(). - AddIngredient(ItemID.Amber, 5). - AddIngredient(ItemID.SandBlock, 50). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Ranged/ScorchedEarth.cs b/Items/Weapons/Ranged/ScorchedEarth.cs index 57a93203f4..eedf099b8c 100644 --- a/Items/Weapons/Ranged/ScorchedEarth.cs +++ b/Items/Weapons/Ranged/ScorchedEarth.cs @@ -7,62 +7,66 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Ranged { public class ScorchedEarth : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/ScorchedEarthShot", 3); + public static readonly SoundStyle RocketShoot = new("CalamityMod/Sounds/Item/ScorpioShot") { Volume = 0.45f }; - private int counter = 0; + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + + public static int OriginalUseTime = 60; + public static int TimeBetweenBursts = 10; + public static int ProjectilesPerBurst = 4; public override void SetDefaults() { + Item.damage = 550; + Item.DamageType = DamageClass.Ranged; + Item.useAnimation = Item.useTime = OriginalUseTime; + Item.shoot = ProjectileType(); + Item.shootSpeed = 15f; + Item.knockBack = 6.5f; + Item.width = 104; Item.height = 44; - Item.damage = 500; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 8; - Item.useAnimation = 32; // 4 shots in just over half a second - Item.reuseDelay = 60; // 1 second recharge - Item.useLimitPerAnimation = 4; - Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 8.7f; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - Item.autoReuse = true; - Item.shootSpeed = 12.6f; - Item.shoot = ModContent.ProjectileType(); + Item.channel = true; + Item.noUseGraphic = true; Item.useAmmo = AmmoID.Rocket; + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.9f, PitchVariance = 0.1f }; Item.Calamity().donorItem = true; } - // Consume two ammo per fire - public override bool CanConsumeAmmo(Item ammo, Player player) => counter % 2 == 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; - public override Vector2? HoldoutOffset() => new Vector2(-30, 0); + // Spawning the holdout won't consume ammo. + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; + + // 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.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI, -30); - if (counter == 0) - { - SoundEngine.PlaySound(ShootSound, position); - } - - counter++; - if (counter == 4) - counter = 0; + // 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); return false; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddRecipeGroup("AnyAdamantiteBar", 15). AddIngredient(10). AddIngredient(ItemID.FragmentSolar, 50). diff --git a/Items/Weapons/Ranged/Seadragon.cs b/Items/Weapons/Ranged/Seadragon.cs index 6e4b33c8a2..60d2fadde4 100644 --- a/Items/Weapons/Ranged/Seadragon.cs +++ b/Items/Weapons/Ranged/Seadragon.cs @@ -38,7 +38,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); @@ -100,7 +99,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(9). AddIngredient(10). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/SepticSkewer.cs b/Items/Weapons/Ranged/SepticSkewer.cs index ab572d256f..611ff063c9 100644 --- a/Items/Weapons/Ranged/SepticSkewer.cs +++ b/Items/Weapons/Ranged/SepticSkewer.cs @@ -6,9 +6,8 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using System; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.Boss; using Terraria.Audio; +using CalamityMod.Items.Weapons.Magic; namespace CalamityMod.Items.Weapons.Ranged { @@ -25,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 46; Item.height = 24; - Item.damage = 1303; + Item.damage = 933; Item.DamageType = DamageClass.Ranged; Item.useTime = 30; Item.useAnimation = 30; @@ -59,7 +58,7 @@ namespace CalamityMod.Items.Weapons.Ranged SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotMid"); SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0.7f, 0.8f) }, position); if (pulled) - player.Calamity().GeneralScreenShakePower = 5.5f; + player.SetScreenshake(5.5f); } else { diff --git a/Items/Weapons/Ranged/Shadethrower.cs b/Items/Weapons/Ranged/Shadethrower.cs index 24ffb6e7cb..ddb77dca90 100644 --- a/Items/Weapons/Ranged/Shadethrower.cs +++ b/Items/Weapons/Ranged/Shadethrower.cs @@ -1,7 +1,6 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -32,15 +31,5 @@ namespace CalamityMod.Items.Weapons.Ranged } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.DemoniteBar, 4). - AddIngredient(12). - AddIngredient(ItemID.RottenChunk, 4). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Ranged/Shardshocker.cs b/Items/Weapons/Ranged/Shardshocker.cs new file mode 100644 index 0000000000..27d64ec957 --- /dev/null +++ b/Items/Weapons/Ranged/Shardshocker.cs @@ -0,0 +1,99 @@ +using System; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class Shardshocker : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public static readonly SoundStyle ShootAndReloadSound = new("CalamityMod/Sounds/Item/WulfrumBlunderbussFireAndReload") { PitchVariance = 0.25f }; + public override void SetDefaults() + { + Item.width = 86; + Item.height = 44; + Item.damage = 115; + Item.DamageType = DamageClass.Ranged; + Item.useTime = 60; + Item.useAnimation = 60; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 5.5f; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.UseSound = null; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 50f; + } + + // Terraria seems to really dislike high crit values in SetDefaults + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6; + + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + SoundEngine.PlaySound(ShootAndReloadSound with { PitchVariance = 0.3f }, position); + SoundEngine.PlaySound(GiantClam.SlamSound with { Pitch = 0.2f }, position); + Projectile.NewProjectile(source, position, velocity, Item.shoot, damage, knockback, player.whoAmI); + return false; + } + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 41f; + Vector2 itemSize = new Vector2(Item.width, Item.height); + Vector2 itemOrigin = new Vector2(4, 1); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + base.UseStyle(player, heldItemFrame); + } + + // Recoil + Not having the gun aim downwards + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.5) + rotation += (player.altFunctionUse == 2 ? -1f : -0.45f) * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction; + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); //must be here otherwise it will vibrate + + + //Reloads the gun + if (animProgress > 0.5f) + { + float backArmRotation = rotation + 0.52f * player.direction; + + Player.CompositeArmStretchAmount stretch = ((float)Math.Sin(MathHelper.Pi * (animProgress - 0.5f) / 0.36f)).ToStretchAmount(); + player.SetCompositeArmBack(true, stretch, backArmRotation); + } + + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(5). + AddIngredient(15). + AddIngredient(2). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/Shardshocker.png b/Items/Weapons/Ranged/Shardshocker.png new file mode 100644 index 0000000000..dc5fde0017 Binary files /dev/null and b/Items/Weapons/Ranged/Shardshocker.png differ diff --git a/Items/Weapons/Ranged/Shellshooter.cs b/Items/Weapons/Ranged/Shellshooter.cs index 45d07acc99..e39b9b4e76 100644 --- a/Items/Weapons/Ranged/Shellshooter.cs +++ b/Items/Weapons/Ranged/Shellshooter.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 2.5f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index 5137773712..7657926ed4 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -1,17 +1,16 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using System; namespace CalamityMod.Items.Weapons.Ranged { public class Shredder : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; @@ -21,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 45; + Item.damage = 48; Item.DamageType = DamageClass.Ranged; Item.useTime = 4; Item.useAnimation = 32; @@ -37,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 5f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; + Item.consumeAmmoOnLastShotOnly = true; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); @@ -53,14 +52,13 @@ namespace CalamityMod.Items.Weapons.Ranged { Projectile.NewProjectile(source, newPosition, (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedByRandom(0.2f), shotType, damage, knockback, player.whoAmI); } + + // Reset altFunctionUse to zero to prevent blank frame appear between shots on Alt-fire + if (player.itemAnimation <= 1) + player.altFunctionUse = 0; + return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 60) - return false; - return true; - } public override void AddRecipes() { @@ -68,7 +66,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(). AddIngredient(). AddIngredient(ItemID.LunarBar, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/Shroomer.cs b/Items/Weapons/Ranged/Shroomer.cs index 4d103f929b..2b619ab787 100644 --- a/Items/Weapons/Ranged/Shroomer.cs +++ b/Items/Weapons/Ranged/Shroomer.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 10f; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Ranged/SlagMagnum.cs b/Items/Weapons/Ranged/SlagMagnum.cs index e3a71d7dfb..6c3656b312 100644 --- a/Items/Weapons/Ranged/SlagMagnum.cs +++ b/Items/Weapons/Ranged/SlagMagnum.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() diff --git a/Items/Weapons/Ranged/SlagfireDouser.cs b/Items/Weapons/Ranged/SlagfireDouser.cs new file mode 100644 index 0000000000..bcec4c9e0f --- /dev/null +++ b/Items/Weapons/Ranged/SlagfireDouser.cs @@ -0,0 +1,50 @@ +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class SlagfireDouser : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() + { + Item.width = 104; + Item.height = 34; + Item.damage = 5; + Item.DamageType = DamageClass.Ranged; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 2f; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.95f, PitchVariance = 0.1f }; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.autoReuse = false; // Because holdout + Item.shoot = ModContent.ProjectileType(); + Item.ArmorPenetration = 10; + Item.shootSpeed = 13f; + Item.reuseDelay = 0; // Because holdout + Item.channel = true; // Because holdout + Item.noUseGraphic = true; + } + + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override Vector2? HoldoutOffset() => new Vector2(102, 0); + + 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, ProjectileType(), damage, knockback, player.whoAmI); + + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); // Aim toward mouse + + return false; + } + } +} diff --git a/Items/Weapons/Ranged/SlagfireDouser.png b/Items/Weapons/Ranged/SlagfireDouser.png new file mode 100644 index 0000000000..cc4081bfd8 Binary files /dev/null and b/Items/Weapons/Ranged/SlagfireDouser.png differ diff --git a/Items/Weapons/Ranged/SomaPrime.cs b/Items/Weapons/Ranged/SomaPrime.cs index beed00b0e5..016c4f32fa 100644 --- a/Items/Weapons/Ranged/SomaPrime.cs +++ b/Items/Weapons/Ranged/SomaPrime.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -15,6 +16,9 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; private static readonly float XYInaccuracy = 0.32f; + public static int AmmoSavedPercent = 80; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 94; @@ -34,7 +38,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; Item.rare = ModContent.RarityType(); Item.Calamity().devItem = true; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults @@ -64,13 +67,13 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.8f; + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). + AddIngredient(ItemID.VenusMagnum). AddIngredient(5). AddTile(). Register(); diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index 8ff1657262..fcb17bdbb2 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -1,6 +1,5 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Ranged/SpectralstormCannon.cs b/Items/Weapons/Ranged/SpectralstormCannon.cs index fc161fa028..cf941d622b 100644 --- a/Items/Weapons/Ranged/SpectralstormCannon.cs +++ b/Items/Weapons/Ranged/SpectralstormCannon.cs @@ -1,8 +1,8 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -10,58 +10,54 @@ namespace CalamityMod.Items.Weapons.Ranged public class SpectralstormCannon : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 33; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + + // This is intentionally stored on the item instead of the holdout to prevent swapping items to instantly reset the heat + // This could be theoretically exploited using multiple items, but the heat dissipates fast enough that I can't really care + public int BuiltUpHeat = 0; + public const int OverheatLevel = 540; + public const int OverheatCooldown = 160; + public const int OverheatDamage = 50; + public override void SetDefaults() { Item.width = 66; Item.height = 26; - Item.damage = 48; + Item.damage = 82; Item.DamageType = DamageClass.Ranged; - Item.useTime = 4; - Item.useAnimation = 12; + Item.useTime = Item.useAnimation = 11; + Item.knockBack = 1.5f; + Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 1.5f; + Item.channel = true; + Item.noUseGraphic = true; + Item.autoReuse = true; + Item.value = CalamityGlobalItem.RarityRedBuyPrice; Item.rare = ItemRarityID.Red; - Item.UseSound = SoundID.Item11; - Item.autoReuse = true; - Item.shoot = ProjectileID.Flare; - Item.shootSpeed = 9.5f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; Item.useAmmo = AmmoID.Flare; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - - public override bool CanConsumeAmmo(Item ammo, Player player) + public override void HoldItem(Player player) { - if (Main.rand.Next(0, 100) < 70) - return false; - return true; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; - int flare = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - if (flare.WithinBounds(Main.maxProjectiles)) + player.Calamity().rightClickListener = true; + // Heat decrements if: + // The holdout exists, the player is not firing, the player is not in overheat, and there is heat in the weapon + if (player.ownedProjectileCounts[Item.shoot] > 0 && !Main.mouseLeft && player.Calamity().flareGunOverheat == 0 && BuiltUpHeat > 0) { - Main.projectile[flare].timeLeft = 200; - Main.projectile[flare].DamageType = DamageClass.Ranged; + BuiltUpHeat -= 3; + if (BuiltUpHeat < 0) + BuiltUpHeat = 0; } - - float SpeedX2 = velocity.X + (float)Main.rand.Next(-20, 21) * 0.05f; - float SpeedY2 = velocity.Y + (float)Main.rand.Next(-20, 21) * 0.05f; - int soul = Projectile.NewProjectile(source, position.X, position.Y, SpeedX2, SpeedY2, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 2f, 0f); - if (soul.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[soul].timeLeft = 600; - Main.projectile[soul].DamageType = DamageClass.Ranged; - Main.projectile[soul].frame = Main.rand.Next(4); - } - return false; } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && !player.Calamity().mouseRight; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; + public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) => type = Item.shoot; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/SpeedBlaster.cs b/Items/Weapons/Ranged/SpeedBlaster.cs index 91eb648f97..d688e25497 100644 --- a/Items/Weapons/Ranged/SpeedBlaster.cs +++ b/Items/Weapons/Ranged/SpeedBlaster.cs @@ -1,6 +1,4 @@ using System; -using CalamityMod.CalPlayer; -using CalamityMod.CalPlayer.Dashes; using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; @@ -50,7 +48,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = true; Item.shootSpeed = 20f; Item.shoot = ModContent.ProjectileType(); - Item.Calamity().canFirePointBlankShots = true; } public override bool AltFunctionUse(Player player) => true; public override bool CanUseItem(Player player) diff --git a/Items/Weapons/Ranged/Spyker.cs b/Items/Weapons/Ranged/Spyker.cs index 52c0aa0e0a..739a788ce0 100644 --- a/Items/Weapons/Ranged/Spyker.cs +++ b/Items/Weapons/Ranged/Spyker.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(). AddIngredient(ItemID.Stynger). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/StarSputter.cs b/Items/Weapons/Ranged/StarSputter.cs index f8c21806ff..9525263705 100644 --- a/Items/Weapons/Ranged/StarSputter.cs +++ b/Items/Weapons/Ranged/StarSputter.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -11,7 +12,6 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; private int counter = 0; - public override void SetDefaults() { Item.width = 80; @@ -32,19 +32,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; Item.useAmmo = AmmoID.FallenStar; + Item.consumeAmmoOnFirstShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) //consume ammo only once per round - { - if (counter == 1 || counter == 2 || counter == 4 || counter == 5 || counter == 7 || counter == 8 || counter == 10 || counter == 11) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/Starfleet.cs b/Items/Weapons/Ranged/Starfleet.cs index d3797af0c3..973c243ce8 100644 --- a/Items/Weapons/Ranged/Starfleet.cs +++ b/Items/Weapons/Ranged/Starfleet.cs @@ -1,11 +1,12 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Ores; +using System.Collections.Generic; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; +using CalamityMod.Rarities; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using System.Linq; +using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Ranged { @@ -16,45 +17,52 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 76; Item.height = 36; - Item.damage = 115; + Item.damage = 3170; Item.DamageType = DamageClass.Ranged; - Item.useTime = 55; - Item.useAnimation = 55; + Item.useTime = 70; + Item.useAnimation = 70; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 15f; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; - Item.UseSound = SoundID.Item92; + Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + Item.rare = ModContent.RarityType(); + Item.channel = true; + Item.noUseGraphic = true; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; Item.useAmmo = AmmoID.FallenStar; } - - public override Vector2? HoldoutOffset() + // Holdout projectile is spawned when holding the item, so using the item does nothing + public override bool CanUseItem(Player player) => false; + public override void ModifyTooltips(List list) { - return new Vector2(-8, -11); - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - for (int index = 0; index < 5; ++index) + Player Owner = Main.LocalPlayer; + if (Owner is null) + return; + float rate = (Main.GlobalTimeWrappedHourly * 3); + List eColors = new List() { - float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - } - return false; - } + new Color(146, 255, 211), + new Color(222, 225, 146), + new Color(255, 233, 146) + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color eTooltipColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); + TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip7"); + if (line != null) + line.OverrideColor = Color.Lerp(eTooltipColor, Color.White, 0.2f); + } public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.SuperStarCannon). - AddIngredient(6). AddIngredient(4). - AddIngredient(12). + AddIngredient(ItemID.FallenStar, 15). + AddIngredient(3). AddTile(TileID.LunarCraftingStation). Register(); } diff --git a/Items/Weapons/Ranged/StarfleetGlow.png b/Items/Weapons/Ranged/StarfleetGlow.png new file mode 100644 index 0000000000..27e53bab19 Binary files /dev/null and b/Items/Weapons/Ranged/StarfleetGlow.png differ diff --git a/Items/Weapons/Ranged/Starmada.cs b/Items/Weapons/Ranged/Starmada.cs index 20425ca0c6..96d212d876 100644 --- a/Items/Weapons/Ranged/Starmada.cs +++ b/Items/Weapons/Ranged/Starmada.cs @@ -1,13 +1,15 @@ -using CalamityMod.Items.Materials; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; +using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Ranged { @@ -15,52 +17,58 @@ namespace CalamityMod.Items.Weapons.Ranged public class Starmada : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 66; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 122; Item.height = 50; - Item.damage = 135; - Item.knockBack = 15f; - Item.shootSpeed = 16f; - Item.useStyle = ItemUseStyleID.Shoot; - Item.useAnimation = Item.useTime = 27; - Item.UseSound = SoundID.Item92; - Item.shoot = ModContent.ProjectileType(); - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.noMelee = true; - Item.noUseGraphic = true; + Item.damage = 4900; Item.DamageType = DamageClass.Ranged; + Item.useAnimation = Item.useTime = 70; + Item.knockBack = 15f; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; Item.channel = true; - Item.useTurn = false; - Item.useAmmo = AmmoID.FallenStar; + Item.noUseGraphic = true; Item.autoReuse = true; - Item.rare = ModContent.RarityType(); + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 12f; + Item.useAmmo = AmmoID.FallenStar; + Item.rare = ModContent.RarityType(); + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } - - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; - - // Spawning the holdout cannot consume ammo - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(3) && player.ownedProjectileCounts[Item.shoot] > 0; - - public override Vector2? HoldoutOffset() + // Holdout projectile is spawned when holding the item, so using the item does nothing + public override bool CanUseItem(Player player) => false; + public override void ModifyTooltips(List list) { - return new Vector2(-10, 0); - } + Player Owner = Main.LocalPlayer; + if (Owner is null) + return; + float rate = (Main.GlobalTimeWrappedHourly * 3); + List eColors = new List() + { + new Color(164, 47, 160), + new Color(227, 97, 72), + new Color(193, 255, 146) + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color eTooltipColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); - 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(), 0, 0f, player.whoAmI); - return false; + TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip8"); + if (line != null) + line.OverrideColor = Color.Lerp(eTooltipColor, Color.White, 0.2f); } - public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). - AddIngredient(8). - AddIngredient(8). - AddIngredient(15). + AddIngredient(5). + AddIngredient(25). AddTile(). Register(); } diff --git a/Items/Weapons/Ranged/Starmada.png b/Items/Weapons/Ranged/Starmada.png index 3cef0ffadf..b9c45f34cb 100644 Binary files a/Items/Weapons/Ranged/Starmada.png and b/Items/Weapons/Ranged/Starmada.png differ diff --git a/Items/Weapons/Ranged/StarmadaGlow.png b/Items/Weapons/Ranged/StarmadaGlow.png new file mode 100644 index 0000000000..f7d1a7365e Binary files /dev/null and b/Items/Weapons/Ranged/StarmadaGlow.png differ diff --git a/Items/Weapons/Ranged/Starmageddon.cs b/Items/Weapons/Ranged/Starmageddon.cs index a2c2cd6707..941526a75c 100644 --- a/Items/Weapons/Ranged/Starmageddon.cs +++ b/Items/Weapons/Ranged/Starmageddon.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 166; Item.height = 62; - Item.damage = 100; + Item.damage = 138; Item.knockBack = 4f; Item.shootSpeed = 16f; Item.useStyle = ItemUseStyleID.Shoot; @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.channel = true; Item.useTurn = false; Item.autoReuse = true; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Weapons/Ranged/StellarCannon.cs b/Items/Weapons/Ranged/StellarCannon.cs index 376629dbca..7445e3628f 100644 --- a/Items/Weapons/Ranged/StellarCannon.cs +++ b/Items/Weapons/Ranged/StellarCannon.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 50; Item.height = 30; - Item.damage = 182; + Item.damage = 180; Item.DamageType = DamageClass.Ranged; Item.useTime = 40; Item.useAnimation = 40; diff --git a/Items/Weapons/Ranged/StormSurge.cs b/Items/Weapons/Ranged/StormSurge.cs index a9c9ae609c..e858c065ba 100644 --- a/Items/Weapons/Ranged/StormSurge.cs +++ b/Items/Weapons/Ranged/StormSurge.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Ranged/SuperradiantSlaughterer.cs b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs index 39271ef02f..9685412233 100644 --- a/Items/Weapons/Ranged/SuperradiantSlaughterer.cs +++ b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs @@ -1,16 +1,13 @@ -using CalamityMod.Cooldowns; +using CalamityMod.CalPlayer.Dashes; +using CalamityMod.Cooldowns; using CalamityMod.Items.Materials; -using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using System.Collections.Generic; using System.Linq; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -21,9 +18,12 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public const float ShootSpeed = 24f; - public const int DashCooldown = 360; + public bool hasDashed = false; + public int rightClickDelay = 0; + public static int doubleRightFrameWindow = 23; + public override void ModifyTooltips(List tooltips) { if (tooltips == null) @@ -55,10 +55,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 84; Item.height = 46; - Item.damage = 88; + Item.damage = 100; Item.DamageType = DamageClass.Ranged; - Item.useTime = 30; - Item.useAnimation = 30; + Item.useTime = 10; + Item.useAnimation = 10; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.noUseGraphic = true; @@ -69,19 +69,12 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = ShootSpeed; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 21; public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2 && player.HasCooldown(SuperradiantSawBoost.ID)) - return false; - else - return player.ownedProjectileCounts[Item.shoot] <= 0; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; public override void HoldItem(Player player) { @@ -91,6 +84,11 @@ namespace CalamityMod.Items.Weapons.Ranged player.Calamity().mouseWorldListener = true; player.Calamity().rightClickListener = true; + if (rightClickDelay > 0) + rightClickDelay--; + if (!player.HasCooldown(SuperradiantSawBoost.ID)) + hasDashed = false; + // Right-click channeling if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse && !player.HasCooldown(SuperradiantSawBoost.ID)) { @@ -108,9 +106,24 @@ 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) { - // The holdout will initially double up when right clicking otherwise + // Handles allowing the dash if (player.altFunctionUse == 2) + { + bool doubleRightClick = rightClickDelay > 0 && !hasDashed; + bool canDash = doubleRightClick && player.Calamity().DashID != SuperradiantSawDash.ID; + + // If you hit the right-click window, dash + if (canDash) + { + hasDashed = true; + player.Calamity().sBlasterDashActivated = true; + } + + // Set the double right-click frames + rightClickDelay = doubleRightFrameWindow; + // The holdout will initially double up when right clicking otherwise return false; + } // The holdout deals 2x base damage. Projectile.NewProjectile(source, position, velocity, Item.shoot, damage * 2, knockback, player.whoAmI); @@ -125,7 +138,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentVortex, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/SurgeDriver.cs b/Items/Weapons/Ranged/SurgeDriver.cs index a344d60962..702c3531da 100644 --- a/Items/Weapons/Ranged/SurgeDriver.cs +++ b/Items/Weapons/Ranged/SurgeDriver.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.channel = true; Item.knockBack = 8f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index da30c36b85..d10a646a8a 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -16,6 +17,10 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; public int SineCounter = 0; + + public static int AmmoSavedPercent = 80; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; @@ -24,10 +29,11 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 60; Item.height = 26; - Item.damage = 222; + Item.damage = 232; Item.DamageType = DamageClass.Ranged; Item.useTime = 1; - Item.useAnimation = 3; + Item.useAnimation = 4; + Item.useLimitPerAnimation = 4; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; @@ -41,15 +47,11 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 6f; Item.shoot = ProjectileID.PurificationPowder; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; + Item.consumeAmmoOnLastShotOnly = true; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - public override bool AltFunctionUse(Player player) - { - return true; - } - public override void HoldItem(Player player) => player.scope = false; + 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) { @@ -62,12 +64,12 @@ namespace CalamityMod.Items.Weapons.Ranged SineCounter++; if (SineCounter % 4 == 0) { - Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); - Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); - Vector2 helixVel3 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine2)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 2f); - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 4f); - int shot3 = Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 3f); + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + Vector2 helixVel3 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine2)); + Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, player.altFunctionUse != 2 ? 2f : 0); + Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, player.altFunctionUse != 2 ? 4f : 0); + Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, player.altFunctionUse != 2 ? 3f : 0); } else if (player.altFunctionUse != 2) { @@ -76,12 +78,8 @@ namespace CalamityMod.Items.Weapons.Ranged } return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) > 90 && SineCounter % 4 == 0) - return true; - return false; - } + + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/TauCannon.cs b/Items/Weapons/Ranged/TauCannon.cs index 189682bcad..5028dacd09 100644 --- a/Items/Weapons/Ranged/TauCannon.cs +++ b/Items/Weapons/Ranged/TauCannon.cs @@ -1,9 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; -using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -15,8 +13,6 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - CalamityGlobalItem modItem = Item.Calamity(); - Item.damage = 620; Item.DamageType = DamageClass.Ranged; Item.useTime = Item.useAnimation = 180; @@ -32,12 +28,9 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); Item.useStyle = ItemUseStyleID.Shoot; - - modItem.UsesCharge = true; - modItem.MaxCharge = 200f; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0 && Item.Calamity().Charge > 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; @@ -49,7 +42,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(15). AddIngredient(10). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/TelluricGlare.cs b/Items/Weapons/Ranged/TelluricGlare.cs index 2c5775d3a2..417ab80d6c 100644 --- a/Items/Weapons/Ranged/TelluricGlare.cs +++ b/Items/Weapons/Ranged/TelluricGlare.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -16,6 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public int shots = 0; public int frame = 0; public int frameCounter = 0; + public override void SetStaticDefaults() { Main.RegisterItemAnimation(Type, new DrawAnimationVertical(3, 5)); @@ -25,10 +27,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 74; Item.height = 126; - Item.damage = 79; + Item.damage = 83; Item.DamageType = DamageClass.Ranged; Item.useTime = 3; - Item.useAnimation = 25; + Item.useAnimation = 24; Item.useLimitPerAnimation = 8; Item.knockBack = 7.5f; Item.useStyle = ItemUseStyleID.Shoot; @@ -42,10 +44,9 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 18f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; + Item.consumeAmmoOnLastShotOnly = true; } public override Vector2? HoldoutOffset() => new Vector2(-14f, 0f); - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() < 0.25f; public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { Texture2D texture; diff --git a/Items/Weapons/Ranged/TheBallista.cs b/Items/Weapons/Ranged/TheBallista.cs index f6219b4d3e..17cf943732 100644 --- a/Items/Weapons/Ranged/TheBallista.cs +++ b/Items/Weapons/Ranged/TheBallista.cs @@ -14,10 +14,9 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 40; Item.height = 70; - Item.damage = 108; + Item.damage = 88; Item.DamageType = DamageClass.Ranged; - Item.useTime = 22; - Item.useAnimation = 22; + Item.useTime = Item.useAnimation = 28; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 8f; @@ -28,7 +27,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/TheBlunderbass.cs b/Items/Weapons/Ranged/TheBlunderbass.cs new file mode 100644 index 0000000000..d29689df96 --- /dev/null +++ b/Items/Weapons/Ranged/TheBlunderbass.cs @@ -0,0 +1,101 @@ +using System; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + [LegacyName("AquashardShotgun")] + public class TheBlunderbass : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public static readonly SoundStyle ShootAndReloadSound = new("CalamityMod/Sounds/Item/WulfrumBlunderbussFireAndReload") { PitchVariance = 0.25f }; + public override void SetDefaults() + { + Item.width = 56; + Item.height = 26; + Item.damage = 35; + Item.DamageType = DamageClass.Ranged; + Item.useTime = 55; + Item.useAnimation = 55; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 5.5f; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.UseSound = null; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 25f; + } + + // Terraria seems to really dislike high crit values in SetDefaults + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6; + + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + SoundEngine.PlaySound(ShootAndReloadSound with { PitchVariance = 0.3f }, position); + SoundEngine.PlaySound(GiantClam.SlamSound with { Pitch = 0.2f }, position); + Projectile.NewProjectile(source, position, velocity, Item.shoot, damage, knockback, player.whoAmI); + return false; + } + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 41f; + Vector2 itemSize = new Vector2(Item.width, Item.height); + Vector2 itemOrigin = new Vector2(4, 1); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + base.UseStyle(player, heldItemFrame); + } + + // Recoil + Not having the gun aim downwards + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.5) + rotation += (player.altFunctionUse == 2 ? -1f : -0.45f) * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction; + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); //must be here otherwise it will vibrate + + + //Reloads the gun + if (animProgress > 0.5f) + { + float backArmRotation = rotation + 0.52f * player.direction; + + Player.CompositeArmStretchAmount stretch = ((float)Math.Sin(MathHelper.Pi * (animProgress - 0.5f) / 0.36f)).ToStretchAmount(); + player.SetCompositeArmBack(true, stretch, backArmRotation); + } + + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(15). + AddIngredient(3). + AddIngredient(7). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/TheBlunderbass.png b/Items/Weapons/Ranged/TheBlunderbass.png new file mode 100644 index 0000000000..255af4609d Binary files /dev/null and b/Items/Weapons/Ranged/TheBlunderbass.png differ diff --git a/Items/Weapons/Ranged/TheHive.cs b/Items/Weapons/Ranged/TheHive.cs index a5365bc034..f43d7cfdde 100644 --- a/Items/Weapons/Ranged/TheHive.cs +++ b/Items/Weapons/Ranged/TheHive.cs @@ -16,7 +16,6 @@ namespace CalamityMod.Items.Weapons.Ranged public static float MaxCharge = 90f; public static int OriginalUseTime = 34; - public override void SetDefaults() { Item.damage = 92; diff --git a/Items/Weapons/Ranged/TheJailor.cs b/Items/Weapons/Ranged/TheJailor.cs index 79bdaba8f6..11e6a60c75 100644 --- a/Items/Weapons/Ranged/TheJailor.cs +++ b/Items/Weapons/Ranged/TheJailor.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.knockBack = 8f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item14; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Ranged/TheMaelstrom.cs b/Items/Weapons/Ranged/TheMaelstrom.cs index 81342eb7a0..d84ae38408 100644 --- a/Items/Weapons/Ranged/TheMaelstrom.cs +++ b/Items/Weapons/Ranged/TheMaelstrom.cs @@ -32,7 +32,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; Item.Calamity().donorItem = true; } @@ -49,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddIngredient(3). AddIngredient(20). AddIngredient(50). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/ThePack.cs b/Items/Weapons/Ranged/ThePack.cs index a6d0fc3f6f..9bafa9238f 100644 --- a/Items/Weapons/Ranged/ThePack.cs +++ b/Items/Weapons/Ranged/ThePack.cs @@ -15,12 +15,11 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.width = 96; - Item.height = 40; + Item.width = 134; + Item.height = 46; Item.damage = 1000; Item.DamageType = DamageClass.Ranged; - Item.useTime = 52; - Item.useAnimation = 52; + Item.useTime = Item.useAnimation = 53; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 7.5f; @@ -31,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Rocket; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; } diff --git a/Items/Weapons/Ranged/ThePack.png b/Items/Weapons/Ranged/ThePack.png index e865101e10..5867be9ba8 100644 Binary files a/Items/Weapons/Ranged/ThePack.png and b/Items/Weapons/Ranged/ThePack.png differ diff --git a/Items/Weapons/Ranged/TheSevensStriker.cs b/Items/Weapons/Ranged/TheSevensStriker.cs index 347ed65b3a..fc2338f5fe 100644 --- a/Items/Weapons/Ranged/TheSevensStriker.cs +++ b/Items/Weapons/Ranged/TheSevensStriker.cs @@ -6,6 +6,7 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -28,6 +29,8 @@ namespace CalamityMod.Items.Weapons.Ranged public static readonly float RightClickCopperMultiplier = 0.04f; public static readonly float RightClickSilverMultiplier = 0.08f; public static readonly float RightClickGoldMultiplier = 0.16f; + public static int RightClickAmmoSavedPercent = 80; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RightClickAmmoSavedPercent); public static readonly float DoublesMultiplier = 1f; // Unfortunately doubles can't be doubles. Balancing! public static readonly float TriplesCherryMultiplier = 1f; @@ -67,10 +70,10 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool? UseItem(Player player) { - // Right click has a 20% chance to consume money + // Right click has a chance to save money if (player.altFunctionUse == 2) { - bool consumeCoin = Main.rand.NextFloat() > 0.8f; + bool consumeCoin = Main.rand.Next(100) >= RightClickAmmoSavedPercent; long coinCount = Utils.CoinsCount(out bool overflow, player.inventory); int price; @@ -169,12 +172,11 @@ namespace CalamityMod.Items.Weapons.Ranged { CreateRecipe(). AddIngredient(ItemID.CoinGun). - AddIngredient(). AddIngredient(ItemID.PlatinumCoin, 7). AddIngredient(ItemID.GoldCoin, 77). AddIngredient(ItemID.LunarBar, 12). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/TheStorm.cs b/Items/Weapons/Ranged/TheStorm.cs index 83e6dd9282..c3b443304c 100644 --- a/Items/Weapons/Ranged/TheStorm.cs +++ b/Items/Weapons/Ranged/TheStorm.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -23,10 +24,11 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 54; Item.height = 90; - Item.damage = 23; + Item.damage = 40; Item.DamageType = DamageClass.Ranged; Item.useTime = 2; Item.useAnimation = 20; + Item.useLimitPerAnimation = 10; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; @@ -36,18 +38,11 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Arrow; + Item.consumeAmmoOnLastShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 95) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (shots % 2 == 0) diff --git a/Items/Weapons/Ranged/ThermoclineBlaster.cs b/Items/Weapons/Ranged/ThermoclineBlaster.cs index cb2a56540f..d13b3ae62f 100644 --- a/Items/Weapons/Ranged/ThermoclineBlaster.cs +++ b/Items/Weapons/Ranged/ThermoclineBlaster.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Particles; using CalamityMod.Projectiles; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -36,7 +34,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 12f; Item.shoot = ProjectileID.PurificationPowder; Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -75,7 +72,7 @@ namespace CalamityMod.Items.Weapons.Ranged Particle smoke = new HeavySmokeParticle(spawnPosition, smokeVel, Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.45f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); GeneralParticleHandler.SpawnParticle(smoke); - Dust dust = Dust.NewDustPerfect(spawnPosition, 303, smokeVel.RotatedByRandom(0.15f), 80, default, Main.rand.NextFloat(0.25f, 1f)); + Dust dust = Dust.NewDustPerfect(spawnPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.15f), 80, default, Main.rand.NextFloat(0.25f, 1f)); dust.noGravity = false; dust.color = Color.White; } diff --git a/Items/Weapons/Ranged/ThreadOfEradication.cs b/Items/Weapons/Ranged/ThreadOfEradication.cs new file mode 100644 index 0000000000..2e959a2428 --- /dev/null +++ b/Items/Weapons/Ranged/ThreadOfEradication.cs @@ -0,0 +1,121 @@ +using System.Collections.Generic; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + [LegacyName("Deathwind")] + public class ThreadOfEradication : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplaceAll("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); + } + public override void SetDefaults() + { + Item.width = 40; + Item.height = 82; + Item.damage = 4375; + Item.DamageType = DamageClass.Ranged; + Item.useTime = 45; + Item.useAnimation = 45; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 5f; + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 20f; + Item.useAmmo = AmmoID.Arrow; + Item.channel = true; + } + + 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/ThreadOfEradicationGlow").Value); + } + private int storedDMG = 1; + private float storedKB = 1; + private int storedDir = 1; + private float storedRot = -5; + public override void UseItemFrame(Player player) + { + if (player.direction == -1) + player.itemRotation -= MathHelper.Pi; + if (storedRot == -5) + storedRot = player.itemRotation; + bool flip = false; + if (storedDir != player.direction) + flip = true; + if (player.itemTime < 60) + { + player.itemRotation = player.DirectionTo(player.Calamity().mouseWorld).ToRotation(); + if (player.itemTime == 1) + { + if (player.channel) + { + player.itemTime = 180; + player.itemAnimation = 180; + } + else + { + + if (Main.LocalPlayer.Distance(player.Center) < 1600) + Main.LocalPlayer.SetScreenshake(2f); + if (Main.myPlayer == player.whoAmI) + { + Projectile.NewProjectile(Item.GetSource_FromThis(), player.Center + Vector2.UnitX.RotatedBy(player.itemRotation) * 2016, Vector2.UnitX.RotatedBy(player.itemRotation), ModContent.ProjectileType(), storedDMG, storedKB, player.whoAmI, -1, 1); + } + } + } + } + else + { + player.itemRotation += MathHelper.Clamp(MathHelper.WrapAngle(player.DirectionTo(player.Calamity().mouseWorld).ToRotation() - player.itemRotation), -0.045f, 0.045f); + if (player.itemTime == 60) + { + + if (Main.LocalPlayer.Distance(player.Center) < 1600) + Main.LocalPlayer.SetScreenshake(5f); + if (Main.myPlayer == player.whoAmI) + { + int p = Projectile.NewProjectile(Item.GetSource_FromThis(), player.Center + Vector2.UnitX.RotatedBy(player.itemRotation) * 2016, Vector2.UnitX.RotatedBy(player.itemRotation), ModContent.ProjectileType(), storedDMG*4, storedKB, player.whoAmI,-0.25f,1); + if (Main.projectile.IndexInRange(p)) + { + Main.projectile[p].scale = 4; + } + } + player.itemTime = 0; + player.itemAnimation = 0; + } + } + if (player.dashDelay != -1) + player.direction = player.itemRotation.ToRotationVector2().X.DirectionalSign(); + storedDir = player.direction; + storedRot = player.itemRotation; + if (player.direction == -1) + player.itemRotation += MathHelper.Pi; + if (flip) + { + player.itemRotation -= MathHelper.Pi; + player.itemRotation *= -1; + } + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + storedDMG = damage; + storedKB = knockback; + return false; + } + } +} diff --git a/Items/Weapons/Ranged/Deathwind.png b/Items/Weapons/Ranged/ThreadOfEradication.png similarity index 100% rename from Items/Weapons/Ranged/Deathwind.png rename to Items/Weapons/Ranged/ThreadOfEradication.png diff --git a/Items/Weapons/Ranged/DeathwindGlow.png b/Items/Weapons/Ranged/ThreadOfEradicationGlow.png similarity index 100% rename from Items/Weapons/Ranged/DeathwindGlow.png rename to Items/Weapons/Ranged/ThreadOfEradicationGlow.png diff --git a/Items/Weapons/Ranged/TitaniumRailgun.cs b/Items/Weapons/Ranged/TitaniumRailgun.cs index 34ad55a974..ce97852a7d 100644 --- a/Items/Weapons/Ranged/TitaniumRailgun.cs +++ b/Items/Weapons/Ranged/TitaniumRailgun.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shootSpeed = 16f; } - public override Vector2? HoldoutOffset() => new Vector2(-5, 4); + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/TitaniumRailgun.png b/Items/Weapons/Ranged/TitaniumRailgun.png index 869227b094..1122b96be4 100644 Binary files a/Items/Weapons/Ranged/TitaniumRailgun.png and b/Items/Weapons/Ranged/TitaniumRailgun.png differ diff --git a/Items/Weapons/Ranged/Toxibow.cs b/Items/Weapons/Ranged/Toxibow.cs index 51ad67d868..b96c7d83a2 100644 --- a/Items/Weapons/Ranged/Toxibow.cs +++ b/Items/Weapons/Ranged/Toxibow.cs @@ -1,5 +1,5 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; @@ -29,7 +29,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.PurificationPowder; Item.shootSpeed = 15f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -45,8 +44,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(15). + AddIngredient(15). + AddIngredient(12). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Ranged/TyrannysEnd.cs b/Items/Weapons/Ranged/TyrannysEnd.cs index 2dec620a10..86672a1208 100644 --- a/Items/Weapons/Ranged/TyrannysEnd.cs +++ b/Items/Weapons/Ranged/TyrannysEnd.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 150; Item.height = 48; - Item.damage = 2000; + Item.damage = 2150; Item.knockBack = 9.5f; Item.DamageType = DamageClass.Ranged; Item.useTime = 60; @@ -31,9 +31,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.UseSound = CommonCalamitySounds.LargeWeaponFireSound; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } // Terraria seems to really dislike high crit values in SetDefaults @@ -46,9 +45,10 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(5). + AddIngredient(3). AddTile(). Register(); } diff --git a/Items/Weapons/Ranged/Ultima.cs b/Items/Weapons/Ranged/Ultima.cs index 4a2e5cf67a..82e09e2fc7 100644 --- a/Items/Weapons/Ranged/Ultima.cs +++ b/Items/Weapons/Ranged/Ultima.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -14,18 +15,22 @@ namespace CalamityMod.Items.Weapons.Ranged public class Ultima : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static int AmmoSavedPercent = 66; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public const float FullChargeTime = 420f; public override void SetDefaults() { Item.width = 44; Item.height = 58; - Item.damage = 150; + Item.damage = 115; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = 8; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2f; - Item.UseSound = SoundID.Item33; + Item.UseSound = SoundID.Item158; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 18f; @@ -35,9 +40,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = true; Item.noUseGraphic = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -46,14 +50,14 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(0, 100) >= 90; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; + public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.PulseBow). AddIngredient(ItemID.LaserRifle). AddIngredient(). - AddIngredient(). AddIngredient(8). AddIngredient(8). AddIngredient(15). diff --git a/Items/Weapons/Ranged/UniversalGenesis.cs b/Items/Weapons/Ranged/UniversalGenesis.cs index d26c0be45e..bdb0a943a7 100644 --- a/Items/Weapons/Ranged/UniversalGenesis.cs +++ b/Items/Weapons/Ranged/UniversalGenesis.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; @@ -15,11 +14,12 @@ namespace CalamityMod.Items.Weapons.Ranged public class UniversalGenesis : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() { Item.width = 158; Item.height = 60; - Item.damage = 192; + Item.damage = 180; Item.DamageType = DamageClass.Ranged; Item.useAnimation = Item.useTime = 26; Item.knockBack = 6.5f; @@ -27,15 +27,13 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 20f; Item.autoReuse = true; - Item.Calamity().canFirePointBlankShots = true; Item.noMelee = true; Item.UseSound = SoundID.Item38; Item.useStyle = ItemUseStyleID.Shoot; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.Calamity().donorItem = true; - Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-50f, -8f); @@ -57,39 +55,27 @@ namespace CalamityMod.Items.Weapons.Ranged // Stars from above float speed = Item.shootSpeed; - Vector2 spawnPos = player.RotatedRelativePoint(player.MountedCenter, true); - int starAmt = 6; - int starDmg = (int)(damage * 0.4); + int starAmt = 5; + int starDmg = (int)(damage * 0.5f); for (int i = 0; i < starAmt; i++) { - spawnPos = new Vector2(player.Center.X + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + Vector2 spawnPos = new Vector2(player.Center.X + (Main.rand.Next(201) * -player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); spawnPos.X = (spawnPos.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); spawnPos.Y -= 100 + i; - float xDist = Main.mouseX + Main.screenPosition.X - spawnPos.X; - float yDist = Main.mouseY + Main.screenPosition.Y - spawnPos.Y; - if (yDist < 0f) - { - yDist *= -1f; - } - if (yDist < 20f) - { - yDist = 20f; - } - float travelDist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - travelDist = speed / travelDist; - xDist *= travelDist; - yDist *= travelDist; - float xVel = xDist + Main.rand.NextFloat(-0.6f, 0.6f); - float yVel = yDist + Main.rand.NextFloat(-0.6f, 0.6f); - int star = Projectile.NewProjectile(source, spawnPos.X, spawnPos.Y, xVel, yVel, ModContent.ProjectileType(), starDmg, knockback, player.whoAmI, i, 1f); + + Vector2 vel = new Vector2(Main.mouseX + Main.screenPosition.X - spawnPos.X, MathF.Abs(Main.mouseY + Main.screenPosition.Y - spawnPos.Y)); + if (vel.Y < 20f) + vel.Y = 20f; + vel = vel.SafeNormalize(Vector2.UnitY) * speed; + vel.X += Main.rand.NextFloat(-0.6f, 0.6f); + vel.Y += Main.rand.NextFloat(-0.6f, 0.6f); + + int star = Projectile.NewProjectile(source, spawnPos, vel, ModContent.ProjectileType(), starDmg, knockback, player.whoAmI, i, 1f); Main.projectile[star].extraUpdates = 2; - Main.projectile[star].localNPCHitCooldown = 30; } return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(); - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/VernalBolter.cs b/Items/Weapons/Ranged/VernalBolter.cs index fca73e5091..f105614251 100644 --- a/Items/Weapons/Ranged/VernalBolter.cs +++ b/Items/Weapons/Ranged/VernalBolter.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 68; Item.height = 94; - Item.damage = 48; + Item.damage = 35; Item.DamageType = DamageClass.Ranged; Item.useTime = 20; Item.useAnimation = 20; @@ -31,7 +31,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.useAmmo = AmmoID.Arrow; - Item.Calamity().canFirePointBlankShots = true; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Weapons/Ranged/Voidragon.cs b/Items/Weapons/Ranged/Voidragon.cs index 2cd4c67f92..955813f31c 100644 --- a/Items/Weapons/Ranged/Voidragon.cs +++ b/Items/Weapons/Ranged/Voidragon.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -16,10 +17,8 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; private int shotType = 1; - public override void SetStaticDefaults() - { - // Long live Megafleet. You will be missed. Maybe one day we can revive you. - } + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); public override void SetDefaults() { @@ -41,13 +40,9 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; Item.rare = ModContent.RarityType(); Item.Calamity().devItem = true; - Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -69,12 +64,7 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 50 || shotType % 2 == 0) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= AmmoSavedPercent && shotType % 2 == 1; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/WildfireBloom.cs b/Items/Weapons/Ranged/WildfireBloom.cs index ce9ab240c8..efcde627f1 100644 --- a/Items/Weapons/Ranged/WildfireBloom.cs +++ b/Items/Weapons/Ranged/WildfireBloom.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged @@ -13,15 +14,16 @@ namespace CalamityMod.Items.Weapons.Ranged public class WildfireBloom : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - - public int FlareCounter = 0; public int WildfireUseTime = 8; + public static int AmmoSavedPercent = 50; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(AmmoSavedPercent); + public override void SetDefaults() { Item.width = 114; Item.height = 58; - Item.damage = 78; + Item.damage = 62; Item.DamageType = DamageClass.Ranged; Item.useTime = WildfireUseTime; Item.useAnimation = WildfireUseTime; @@ -45,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; // Spawning the holdout cannot consume ammo - public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0 && Main.rand.Next(100) >= AmmoSavedPercent; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -54,7 +56,6 @@ namespace CalamityMod.Items.Weapons.Ranged // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction // 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); - return false; } diff --git a/Items/Weapons/Ranged/WulfrumBlunderbuss.cs b/Items/Weapons/Ranged/WulfrumBlunderbuss.cs index 5b74101f5d..ee2cfded77 100644 --- a/Items/Weapons/Ranged/WulfrumBlunderbuss.cs +++ b/Items/Weapons/Ranged/WulfrumBlunderbuss.cs @@ -53,7 +53,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.autoReuse = false; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; - Item.Calamity().canFirePointBlankShots = true; } public override void HoldItem(Player player) @@ -107,8 +106,7 @@ 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) { - if (player.Calamity().GeneralScreenShakePower < 3f) - player.Calamity().GeneralScreenShakePower = 3f; + player.SetScreenshake(3f); // 14NOV2024: Ozzatron: clamped mouse position unnecessary due to the result being clamped float aimLength = (Main.MouseWorld - player.MountedCenter).Length(); @@ -185,7 +183,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(9). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/AcidicRainBarrel.cs b/Items/Weapons/Rogue/AcidicRainBarrel.cs deleted file mode 100644 index 162324b036..0000000000 --- a/Items/Weapons/Rogue/AcidicRainBarrel.cs +++ /dev/null @@ -1,57 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Rogue -{ - public class AcidicRainBarrel : RogueWeapon - { - public override void SetDefaults() - { - Item.width = 48; - Item.height = 48; - Item.damage = 43; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.useAnimation = 22; - Item.useTime = 22; - Item.knockBack = 8f; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; - Item.DamageType = RogueDamageClass.Instance; - } - - public override void ModifyStatsExtra(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) - { - position = position - Vector2.UnitY * 12f; - velocity.Y *= 0.667f; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); - return false; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(). - AddIngredient(15). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/Rogue/AcidicRainBarrel.png b/Items/Weapons/Rogue/AcidicRainBarrel.png deleted file mode 100644 index 2a8d7fd74b..0000000000 Binary files a/Items/Weapons/Rogue/AcidicRainBarrel.png and /dev/null differ diff --git a/Items/Weapons/Rogue/Apoctolith.cs b/Items/Weapons/Rogue/Apoctolith.cs index aa889bdab6..ea514d1562 100644 --- a/Items/Weapons/Rogue/Apoctolith.cs +++ b/Items/Weapons/Rogue/Apoctolith.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 66; Item.height = 64; - Item.damage = 238; + Item.damage = 185; Item.shootSpeed = 18f; Item.shoot = ModContent.ProjectileType(); Item.useAnimation = Item.useTime = 26; diff --git a/Items/Weapons/Rogue/AuroradicalThrow.cs b/Items/Weapons/Rogue/AuroradicalThrow.cs index 04409f3752..76a19ba723 100644 --- a/Items/Weapons/Rogue/AuroradicalThrow.cs +++ b/Items/Weapons/Rogue/AuroradicalThrow.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Items/Weapons/Rogue/BallisticPoisonBomb.cs b/Items/Weapons/Rogue/BallisticPoisonBomb.cs index a5adb023be..478fd5c16f 100644 --- a/Items/Weapons/Rogue/BallisticPoisonBomb.cs +++ b/Items/Weapons/Rogue/BallisticPoisonBomb.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; @@ -16,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 30; Item.height = 38; - Item.damage = 72; + Item.damage = 57; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = Item.useTime = 26; diff --git a/Items/Weapons/Rogue/BlazingStar.cs b/Items/Weapons/Rogue/BlazingStar.cs index 5f608b05d3..5dd14afede 100644 --- a/Items/Weapons/Rogue/BlazingStar.cs +++ b/Items/Weapons/Rogue/BlazingStar.cs @@ -12,16 +12,17 @@ namespace CalamityMod.Items.Weapons.Rogue { public override void SetDefaults() { - Item.width = 1; - Item.height = 1; + Item.width = 32; + Item.height = 32; Item.damage = 75; Item.DamageType = RogueDamageClass.Instance; + Item.autoReuse = true; Item.noMelee = true; Item.noUseGraphic = true; Item.useTime = 15; Item.useAnimation = 15; Item.useStyle = ItemUseStyleID.Swing; - Item.knockBack = 4f; + Item.knockBack = 3; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item1; @@ -29,43 +30,47 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shootSpeed = 13f; Item.shoot = ModContent.ProjectileType(); } + public override float StealthVelocityMultiplier => 1.3f; - // Terraria seems to really dislike high crit values in SetDefaults + public override float StealthDamageMultiplier => 0.5f; public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 4; - - public override float StealthDamageMultiplier => 0.6f; - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + var p = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, -1f); if (player.Calamity().StealthStrikeAvailable()) { - for (int i = 0; i < 3; i++) - { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.Lerp(-MathHelper.ToRadians(8f), MathHelper.ToRadians(8f), i / 2f)); - Projectile proj = Projectile.NewProjectileDirect(source, position, perturbedSpeed, type, damage, knockback, player.whoAmI); - if (proj.whoAmI.WithinBounds(Main.maxProjectiles)) - proj.Calamity().stealthStrike = true; + p.Calamity().stealthStrike = true; + p.netUpdate = true; - Projectile projectile = Projectile.NewProjectileDirect(source, position, perturbedSpeed, type, damage, knockback, player.whoAmI); - if (projectile.whoAmI.WithinBounds(Main.maxProjectiles)) + var goType = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[goType] <= 0) + { + p = Projectile.NewProjectileDirect(source, position, Vector2.Zero, goType, damage, 10, player.whoAmI, 0f, -1f); + p.Calamity().stealthStrike = true; + } + else + { + foreach (var proj in Main.ActiveProjectiles) { - projectile.penetrate = -1; - projectile.Calamity().stealthStrike = true; + if (proj.active && proj.type == goType && proj.owner == player.whoAmI) + { + proj.timeLeft += 300; + proj.netUpdate = true; + break; + } } } - return false; - } - return true; - } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 3; + } + return false; + } public override void AddRecipes() { CreateRecipe(). AddIngredient(). AddIngredient(ItemID.HellstoneBar, 5). AddIngredient(10). - AddTile(TileID.Anvils). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/BloodsoakedCrasher.cs b/Items/Weapons/Rogue/BloodsoakedCrasher.cs index f2387e8a45..6c1da5bf6e 100644 --- a/Items/Weapons/Rogue/BloodsoakedCrasher.cs +++ b/Items/Weapons/Rogue/BloodsoakedCrasher.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(). AddIngredient(12). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/BouncingEyeball.cs b/Items/Weapons/Rogue/BouncingEyeball.cs index 0da66baf7a..1d99ee20b9 100644 --- a/Items/Weapons/Rogue/BouncingEyeball.cs +++ b/Items/Weapons/Rogue/BouncingEyeball.cs @@ -9,9 +9,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public class BouncingEyeball : RogueWeapon { - public override void SetStaticDefaults() - { - } public override void SetDefaults() { Item.width = 26; @@ -21,8 +18,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.useAnimation = 23; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 3.5f; - Item.rare = ItemRarityID.Green; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.DamageType = RogueDamageClass.Instance; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Rogue/CelestialReaper.cs b/Items/Weapons/Rogue/CelestialReaper.cs index 946d0cf61e..5ca003824f 100644 --- a/Items/Weapons/Rogue/CelestialReaper.cs +++ b/Items/Weapons/Rogue/CelestialReaper.cs @@ -9,7 +9,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public class CelestialReaper : RogueWeapon { - public override void SetDefaults() { Item.width = 66; @@ -24,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item71; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; + Item.value = Item.buyPrice(platinum: 3); // Sold by Bandit Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; Item.DamageType = RogueDamageClass.Instance; diff --git a/Items/Weapons/Rogue/Celestus.cs b/Items/Weapons/Rogue/Celestus.cs index 113f7e24a7..2af3d2b3dc 100644 --- a/Items/Weapons/Rogue/Celestus.cs +++ b/Items/Weapons/Rogue/Celestus.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shoot = ModContent.ProjectileType(); Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item1; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.autoReuse = true; Item.noMelee = true; diff --git a/Items/Weapons/Rogue/Cinquedea.cs b/Items/Weapons/Rogue/Cinquedea.cs index 888ab52af2..9ef1e82297 100644 --- a/Items/Weapons/Rogue/Cinquedea.cs +++ b/Items/Weapons/Rogue/Cinquedea.cs @@ -9,7 +9,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public class Cinquedea : RogueWeapon { - public override void SetDefaults() { Item.width = 32; @@ -26,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.noUseGraphic = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.value = Item.buyPrice(gold: 10); // Sold by Bandit Item.DamageType = RogueDamageClass.Instance; } diff --git a/Items/Weapons/Rogue/CobaltKunai.cs b/Items/Weapons/Rogue/CobaltKunai.cs index 1fbc6ca7a2..68c8965605 100644 --- a/Items/Weapons/Rogue/CobaltKunai.cs +++ b/Items/Weapons/Rogue/CobaltKunai.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 1.85f; + public override float StealthDamageMultiplier => 1.4f; public override float StealthVelocityMultiplier => 0.9f; public override float StealthKnockbackMultiplier => 0.5f; @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - for (int i = -1; i <= 1; i++) + for (float i = -1.5f; i <= 1.5f; i++) { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * 9f)); + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * 7f)); int stealth = Projectile.NewProjectile(source, position, perturbedSpeed, ModContent.ProjectileType(), damage, knockback, player.whoAmI); if (stealth.WithinBounds(Main.maxProjectiles)) Main.projectile[stealth].Calamity().stealthStrike = true; diff --git a/Items/Weapons/Rogue/ContaminatedBile.cs b/Items/Weapons/Rogue/ContaminatedBile.cs index 96c82f5ca8..242728ea3f 100644 --- a/Items/Weapons/Rogue/ContaminatedBile.cs +++ b/Items/Weapons/Rogue/ContaminatedBile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Rogue/CorpusAvertor.cs b/Items/Weapons/Rogue/CorpusAvertor.cs index bfad290128..cb42af2674 100644 --- a/Items/Weapons/Rogue/CorpusAvertor.cs +++ b/Items/Weapons/Rogue/CorpusAvertor.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -53,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Rogue if (Main.myPlayer == player.whoAmI) player.HealEffect(-6); if (player.statLife <= 0) - player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.CorpusAvertor").Format(player.name)), 1000.0, 0, false); + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.CorpusAvertor").ToNetworkText(player.name)), 1000.0, 0, false); return false; } return true; diff --git a/Items/Weapons/Rogue/CosmicKunai.cs b/Items/Weapons/Rogue/CosmicKunai.cs index 39a5b4a75d..7e3bd1a7b3 100644 --- a/Items/Weapons/Rogue/CosmicKunai.cs +++ b/Items/Weapons/Rogue/CosmicKunai.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Weapons/Rogue/CraniumSmasher.cs b/Items/Weapons/Rogue/CraniumSmasher.cs index 5ef882b4c0..7d61a447d9 100644 --- a/Items/Weapons/Rogue/CraniumSmasher.cs +++ b/Items/Weapons/Rogue/CraniumSmasher.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Rogue/CrushsawCrasher.cs b/Items/Weapons/Rogue/CrushsawCrasher.cs index 611d050155..a82b2e5f37 100644 --- a/Items/Weapons/Rogue/CrushsawCrasher.cs +++ b/Items/Weapons/Rogue/CrushsawCrasher.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 38; Item.height = 22; - Item.damage = 81; + Item.damage = 57; Item.useAnimation = 18; Item.useStyle = ItemUseStyleID.Swing; Item.useTime = 18; @@ -31,20 +31,19 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 0.7f; - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { int spread = 3; - for (int i = 0; i < 5; i++) + for (int i = 0; i < 6; i++) { Vector2 perturbedspeed = new Vector2(velocity.X + Main.rand.Next(-3, 4), velocity.Y + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(spread)); int proj = Projectile.NewProjectile(source, position, perturbedspeed, type, damage, knockback, player.whoAmI); if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].penetrate = 1; } spread -= Main.rand.Next(1, 4); } diff --git a/Items/Weapons/Rogue/CrystalPiercer.cs b/Items/Weapons/Rogue/CrystalPiercer.cs index f7b115b4da..3a54076ed3 100644 --- a/Items/Weapons/Rogue/CrystalPiercer.cs +++ b/Items/Weapons/Rogue/CrystalPiercer.cs @@ -39,7 +39,9 @@ namespace CalamityMod.Items.Weapons.Rogue Main.projectile[stealth].Calamity().stealthStrike = true; Main.projectile[stealth].aiStyle = -1; Main.projectile[stealth].tileCollide = false; + Main.projectile[stealth].usesIDStaticNPCImmunity = false; Main.projectile[stealth].usesLocalNPCImmunity = true; + Main.projectile[stealth].localNPCHitCooldown = 10; } return false; } diff --git a/Items/Weapons/Rogue/Crystalline.cs b/Items/Weapons/Rogue/Crystalline.cs index 74260456a7..83add7844f 100644 --- a/Items/Weapons/Rogue/Crystalline.cs +++ b/Items/Weapons/Rogue/Crystalline.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Rogue // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 4; - public override float StealthDamageMultiplier => 3f; + public override float StealthDamageMultiplier => 1.7f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/CursedDagger.cs b/Items/Weapons/Rogue/CursedDagger.cs index 289fc8c55c..624d0dddf8 100644 --- a/Items/Weapons/Rogue/CursedDagger.cs +++ b/Items/Weapons/Rogue/CursedDagger.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.Rogue; -using log4net.Core; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Items/Weapons/Rogue/DeepWounder.cs b/Items/Weapons/Rogue/DeepWounder.cs index 4bb20aae43..7cbfc94525 100644 --- a/Items/Weapons/Rogue/DeepWounder.cs +++ b/Items/Weapons/Rogue/DeepWounder.cs @@ -13,12 +13,11 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 58; Item.height = 52; - Item.damage = 136; + Item.damage = 132; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 23; + Item.useTime = Item.useAnimation = 25; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 23; Item.knockBack = 3f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; @@ -36,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); + int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; return false; diff --git a/Items/Weapons/Rogue/DefectiveSphere.cs b/Items/Weapons/Rogue/DefectiveSphere.cs index d9a4719ab1..c729ae8e2b 100644 --- a/Items/Weapons/Rogue/DefectiveSphere.cs +++ b/Items/Weapons/Rogue/DefectiveSphere.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Rogue @@ -16,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 42; Item.height = 44; - Item.damage = 116; + Item.damage = 85; Item.knockBack = 5f; Item.useAnimation = 13; Item.useTime = 13; @@ -37,22 +36,9 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool CanUseItem(Player player) { - if (player.Calamity().StealthStrikeAvailable()) - { - return true; - } - else if ((player.ownedProjectileCounts[Item.shoot] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()]) >= 5) - { - return false; - } - else - { - return true; - } + return player.Calamity().StealthStrikeAvailable() || (player.ownedProjectileCounts[Item.shoot] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()]) <= 4; } - public override float StealthDamageMultiplier => 0.9f; - public override void ModifyStatsExtra(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) { type = Utils.SelectRandom(Main.rand, new int[] @@ -72,13 +58,13 @@ namespace CalamityMod.Items.Weapons.Rogue { // This is done to allow looping when creating projectiles, instead of having to create many projectile/velocity variables all at once, // which this shoot code used to do. - int[] projectilesToShoot = new int[] - { + int[] projectilesToShoot = + [ ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType() - }; + ]; foreach (int projectileType in projectilesToShoot) { diff --git a/Items/Weapons/Rogue/DimensionTearingDisk.cs b/Items/Weapons/Rogue/DimensionTearingDisk.cs new file mode 100644 index 0000000000..4a4aeb869d --- /dev/null +++ b/Items/Weapons/Rogue/DimensionTearingDisk.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + [LegacyName("Eradicator")] + public class DimensionTearingDisk : RogueWeapon + { + public static float Speed = 10.5f; + public override void SetDefaults() + { + Item.width = 62; + Item.height = 58; + Item.DamageType = RogueDamageClass.Instance; + Item.useTime = Item.useAnimation = 24; + Item.knockBack = 7f; + Item.damage = 980; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.autoReuse = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.UseSound = SoundID.Item1; + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = Speed; + } + + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplaceAll("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); + } + + 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, type, damage, knockback, player.whoAmI); + if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].Calamity().stealthStrike = true; + } + 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/DimensionTearingDiskGlow").Value); + } + } +} diff --git a/Items/Weapons/Rogue/Eradicator.png b/Items/Weapons/Rogue/DimensionTearingDisk.png similarity index 100% rename from Items/Weapons/Rogue/Eradicator.png rename to Items/Weapons/Rogue/DimensionTearingDisk.png diff --git a/Items/Weapons/Rogue/EradicatorGlow.png b/Items/Weapons/Rogue/DimensionTearingDiskGlow.png similarity index 100% rename from Items/Weapons/Rogue/EradicatorGlow.png rename to Items/Weapons/Rogue/DimensionTearingDiskGlow.png diff --git a/Items/Weapons/Rogue/DuststormInABottle.cs b/Items/Weapons/Rogue/DuststormInABottle.cs index cb31651c19..612a1f66f7 100644 --- a/Items/Weapons/Rogue/DuststormInABottle.cs +++ b/Items/Weapons/Rogue/DuststormInABottle.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 20; Item.height = 24; - Item.damage = 74; + Item.damage = 65; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 28; @@ -30,18 +30,16 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public static float StealthDmgMult = 0.6f; //So I can edit it directly via DragonLens instead of having to do math with CalTestHelpers - public override float StealthDamageMultiplier => StealthDmgMult; + public override float StealthDamageMultiplier => 0.6f; public static int CloudLifetime = 200; public static float DustRadius = 11f; - public static int StealthIframes = 9; //Cloud hitbox size manipulation public static float MaxSize = 3.2f; public static float MaxSizeStealth = 3.6f; public static float GrowthRate = 0.025f; - public static float StealthGrowhRate = 0.035f; + public static float StealthGrowthRate = 0.035f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { @@ -59,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Rogue { CreateRecipe(). AddIngredient(ItemID.SandstorminaBottle). - AddIngredient(10). + AddIngredient(ItemID.AncientCloth,5). AddIngredient(). AddTile(TileID.MythrilAnvil). Register(); diff --git a/Items/Weapons/Rogue/DynamicPursuer.cs b/Items/Weapons/Rogue/DynamicPursuer.cs index 926ce17a5a..e625e2d5b1 100644 --- a/Items/Weapons/Rogue/DynamicPursuer.cs +++ b/Items/Weapons/Rogue/DynamicPursuer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CustomRecipes; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables; +using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; @@ -19,8 +15,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public override void SetDefaults() { - CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 30; Item.height = 34; Item.damage = 2850; @@ -32,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 3f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.noMelee = true; Item.noUseGraphic = true; @@ -42,10 +36,6 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 17f; - - modItem.UsesCharge = true; - modItem.MaxCharge = 300f; // Tesla Cannon = 250f - modItem.ChargePerUse = 0.4f; // Tesla Cannon = 0.9f } public static float StealthDmgMult = 0.3f; //So I can edit it directly via DragonLens instead of having to do math with CalTestHelpers public override float StealthDamageMultiplier => StealthDmgMult; @@ -72,8 +62,8 @@ namespace CalamityMod.Items.Weapons.Rogue public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(). + AddIngredient(). + AddIngredient(). AddIngredient(5). AddTile(). Register(); diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index 66e11cf25d..073d54b200 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.height = 88; Item.damage = 500; Item.knockBack = 3.5f; - Item.useAnimation = Item.useTime = 22; + Item.useAnimation = Item.useTime = 24; Item.autoReuse = true; Item.DamageType = RogueDamageClass.Instance; Item.shootSpeed = 15f; @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.noUseGraphic = true; Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(8). AddIngredient(8). AddIngredient(12). diff --git a/Items/Weapons/Rogue/EnchantedAxe.cs b/Items/Weapons/Rogue/EnchantedAxe.cs index 187a61f645..266a1b1862 100644 --- a/Items/Weapons/Rogue/EnchantedAxe.cs +++ b/Items/Weapons/Rogue/EnchantedAxe.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Items.Weapons.Rogue Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.maxStack = 1; - Item.value = 1000; Item.rare = ItemRarityID.Orange; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Rogue/Equanimity.cs b/Items/Weapons/Rogue/Equanimity.cs index 3133d376dc..a53b430182 100644 --- a/Items/Weapons/Rogue/Equanimity.cs +++ b/Items/Weapons/Rogue/Equanimity.cs @@ -1,6 +1,4 @@ -using System.Linq; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -51,8 +49,8 @@ namespace CalamityMod.Items.Weapons.Rogue AddIngredient(). AddIngredient(ItemID.DarkShard). AddIngredient(ItemID.LightShard). - AddIngredient(ItemID.SoulofNight, 7). AddIngredient(ItemID.SoulofLight, 7). + AddIngredient(ItemID.SoulofNight, 7). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/Eradicator.cs b/Items/Weapons/Rogue/Eradicator.cs deleted file mode 100644 index 7d6589d230..0000000000 --- a/Items/Weapons/Rogue/Eradicator.cs +++ /dev/null @@ -1,54 +0,0 @@ -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Rogue -{ - public class Eradicator : RogueWeapon - { - public static float Speed = 10.5f; - - public override void SetDefaults() - { - Item.width = 62; - Item.height = 58; - Item.damage = 620; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 33; - Item.useAnimation = 33; - Item.knockBack = 7f; - Item.UseSound = SoundID.Item1; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = Speed; - Item.DamageType = RogueDamageClass.Instance; - } - - public override float StealthDamageMultiplier => 0.6f; - - 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, type, damage, knockback, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].timeLeft += EradicatorProjectile.StealthExtraLifetime; - Main.projectile[proj].Calamity().stealthStrike = true; - } - 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/EradicatorGlow").Value); - } - } -} diff --git a/Items/Weapons/Rogue/ExecutionersBlade.cs b/Items/Weapons/Rogue/ExecutionersBlade.cs index 2399ea3992..72d6da8198 100644 --- a/Items/Weapons/Rogue/ExecutionersBlade.cs +++ b/Items/Weapons/Rogue/ExecutionersBlade.cs @@ -17,12 +17,11 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 64; Item.height = 64; - Item.damage = 195; + Item.damage = 165; Item.noMelee = true; Item.noUseGraphic = true; Item.useTime = 3; Item.useAnimation = 9; - Item.reuseDelay = 1; Item.useLimitPerAnimation = 3; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6.75f; @@ -32,14 +31,13 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 24f; Item.DamageType = RogueDamageClass.Instance; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } 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/ExecutionersBladeGlow").Value); } - public override float StealthDamageMultiplier => 0.6f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/Exorcism.cs b/Items/Weapons/Rogue/Exorcism.cs index 4742e420dc..4f412f2c09 100644 --- a/Items/Weapons/Rogue/Exorcism.cs +++ b/Items/Weapons/Rogue/Exorcism.cs @@ -13,17 +13,17 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 109; Item.height = 128; - Item.damage = 285; + Item.damage = 192; Item.noMelee = true; Item.noUseGraphic = true; - // Due to the amazing sound engine, having more than one of these on screen will cause audio bugs! - // Therefore this thing has to be absurdly slow (Not that I've ever complained about that before) - Item.useAnimation = Item.useTime = 115; + // Due to the amazing sound engine, having multiple crosses embedded in enemies cuts off the sound + // Therefore this thing has to be very slow (Not that I've ever complained about that before) + Item.useAnimation = Item.useTime = 96; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 12f; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityPinkBuyPrice; - Item.rare = ItemRarityID.Pink; + Item.value = CalamityGlobalItem.RarityLightPurpleBuyPrice; + Item.rare = ItemRarityID.LightPurple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 6f; Item.DamageType = RogueDamageClass.Instance; diff --git a/Items/Weapons/Rogue/FantasyTalisman.cs b/Items/Weapons/Rogue/FantasyTalisman.cs index aad9aeb1d9..8b7f5a9494 100644 --- a/Items/Weapons/Rogue/FantasyTalisman.cs +++ b/Items/Weapons/Rogue/FantasyTalisman.cs @@ -14,11 +14,10 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 30; Item.height = 30; - Item.damage = 52; + Item.damage = 45; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 25; - Item.useTime = 25; + Item.useTime = Item.useAnimation = 25; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6f; Item.UseSound = SoundID.Item1; @@ -29,28 +28,18 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shootSpeed = 18f; Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 0.7f; + public override float StealthDamageMultiplier => 0.75f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (!player.Calamity().StealthStrikeAvailable()) + for (int i = -1; i <= 1; i++) { - for (int i = -1; i <= 1; i++) - { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * 6f)); - Projectile.NewProjectile(source, position, perturbedSpeed, type, damage, knockback, player.whoAmI); - } + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * (player.Calamity().StealthStrikeAvailable() ? 5f : 6f))); + int shootCard = player.Calamity().StealthStrikeAvailable() ? ModContent.ProjectileType() : type; + int card = Projectile.NewProjectile(source, position, perturbedSpeed, shootCard, damage, knockback, player.whoAmI); + if (card.WithinBounds(Main.maxProjectiles) && player.Calamity().StealthStrikeAvailable()) + Main.projectile[card].Calamity().stealthStrike = true; } - else if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike - { - for (int i = -1; i <= 1; i++) - { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * 5f)); - int stealth = Projectile.NewProjectile(source, position, perturbedSpeed, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - } - } - return true; + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Rogue/FeatherKnife.cs b/Items/Weapons/Rogue/FeatherKnife.cs index 756ef3c40a..e67b1ec4cc 100644 --- a/Items/Weapons/Rogue/FeatherKnife.cs +++ b/Items/Weapons/Rogue/FeatherKnife.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(6). AddIngredient(ItemID.SunplateBlock, 4). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Rogue/FishboneBoomerang.cs b/Items/Weapons/Rogue/FishboneBoomerang.cs index a6d0facb12..70a790c702 100644 --- a/Items/Weapons/Rogue/FishboneBoomerang.cs +++ b/Items/Weapons/Rogue/FishboneBoomerang.cs @@ -1,5 +1,4 @@ -using System.Linq; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; @@ -19,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Rogue Item.damage = 27; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 15; + Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 15; + Item.useTime = 30; Item.knockBack = 5.5f; Item.UseSound = null; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; @@ -32,10 +31,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.autoReuse = true; } - public override bool CanUseItem(Player player) - { - return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType()); - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 3; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/FrostcrushValari.cs b/Items/Weapons/Rogue/FrostcrushValari.cs index 43953e042c..39545494e2 100644 --- a/Items/Weapons/Rogue/FrostcrushValari.cs +++ b/Items/Weapons/Rogue/FrostcrushValari.cs @@ -1,5 +1,4 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; @@ -16,11 +15,11 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SetDefaults() { - Item.width = 32; - Item.height = 46; - Item.damage = 89; + Item.width = 34; + Item.height = 58; + Item.damage = 81; Item.DamageType = RogueDamageClass.Instance; - Item.useTime = Item.useAnimation = 17; + Item.useTime = Item.useAnimation = 19; Item.knockBack = 12; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; @@ -37,9 +36,6 @@ namespace CalamityMod.Items.Weapons.Rogue // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 16; - public override float StealthDamageMultiplier => 0.9f; - public override float StealthKnockbackMultiplier => 0.3333f; - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) @@ -48,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Rogue if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].Calamity().stealthStrike = true; - Main.projectile[proj].penetrate = 5; + Main.projectile[proj].penetrate = 4; } return false; } diff --git a/Items/Weapons/Rogue/FrostcrushValari.png b/Items/Weapons/Rogue/FrostcrushValari.png index a22a47651b..06928cd5eb 100644 Binary files a/Items/Weapons/Rogue/FrostcrushValari.png and b/Items/Weapons/Rogue/FrostcrushValari.png differ diff --git a/Items/Weapons/Rogue/FrostyFlare.cs b/Items/Weapons/Rogue/FrostyFlare.cs index 1226639a46..acf40a72cb 100644 --- a/Items/Weapons/Rogue/FrostyFlare.cs +++ b/Items/Weapons/Rogue/FrostyFlare.cs @@ -9,16 +9,11 @@ namespace CalamityMod.Items.Weapons.Rogue { public class FrostyFlare : RogueWeapon { - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 99; - } - public override void SetDefaults() { Item.width = 10; Item.height = 22; - Item.damage = 32; + Item.damage = 37; Item.noUseGraphic = true; Item.noMelee = true; Item.useAnimation = Item.useTime = 13; @@ -27,12 +22,10 @@ namespace CalamityMod.Items.Weapons.Rogue Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.knockBack = 2f; - Item.value = Item.buyPrice(0, 0, 8, 0); + Item.value = CalamityGlobalItem.RarityLightPurpleBuyPrice; Item.rare = ItemRarityID.LightPurple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 22f; - Item.maxStack = Item.CommonMaxStack; - Item.consumable = true; Item.DamageType = RogueDamageClass.Instance; } diff --git a/Items/Weapons/Rogue/GacruxianMollusk.cs b/Items/Weapons/Rogue/GacruxianMollusk.cs index eefd917f1f..8ea216e1a8 100644 --- a/Items/Weapons/Rogue/GacruxianMollusk.cs +++ b/Items/Weapons/Rogue/GacruxianMollusk.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.noUseGraphic = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = Speed; - Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; - Item.rare = ItemRarityID.LightRed; + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; + Item.rare = ItemRarityID.Pink; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Rogue/GelDart.cs b/Items/Weapons/Rogue/GelDart.cs index c01f1fb608..f3d4a13f8e 100644 --- a/Items/Weapons/Rogue/GelDart.cs +++ b/Items/Weapons/Rogue/GelDart.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -54,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(18). AddIngredient(18). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Weapons/Rogue/GhoulishGouger.cs b/Items/Weapons/Rogue/GhoulishGouger.cs index e3b26d6f38..d69d5b3f12 100644 --- a/Items/Weapons/Rogue/GhoulishGouger.cs +++ b/Items/Weapons/Rogue/GhoulishGouger.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Items/Weapons/Rogue/GildedDagger.cs b/Items/Weapons/Rogue/GildedDagger.cs index a83905ca76..a2e668dace 100644 --- a/Items/Weapons/Rogue/GildedDagger.cs +++ b/Items/Weapons/Rogue/GildedDagger.cs @@ -51,7 +51,6 @@ namespace CalamityMod.Items.Weapons.Rogue { CreateRecipe(). AddIngredient(ItemID.GoldBar, 12). - AddIngredient(ItemID.ThrowingKnife, 250). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/Glaive.cs b/Items/Weapons/Rogue/Glaive.cs index b76b2ab6d9..3c10931c2e 100644 --- a/Items/Weapons/Rogue/Glaive.cs +++ b/Items/Weapons/Rogue/Glaive.cs @@ -9,49 +9,59 @@ namespace CalamityMod.Items.Weapons.Rogue { public class Glaive : RogueWeapon { - //These 2 are used on the Projectile AI and thus remain here - public static float Speed = 10f; - public static float StealthSpeedMult = 1.8f; - public override void SetDefaults() { Item.width = 34; Item.height = 32; - Item.damage = 45; + Item.damage = 25; Item.DamageType = RogueDamageClass.Instance; + Item.autoReuse = true; Item.noMelee = true; Item.noUseGraphic = true; Item.useTime = 15; Item.useAnimation = 15; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 3; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.value = Item.buyPrice(gold: 10); // Sold by Bandit Item.rare = ItemRarityID.Orange; Item.UseSound = SoundID.Item1; - Item.shootSpeed = 10; + Item.shootSpeed = 13f; Item.shoot = ModContent.ProjectileType(); } + public override float StealthVelocityMultiplier => 1.3f; - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 4; - - public override float StealthVelocityMultiplier => StealthSpeedMult; - + public override float StealthDamageMultiplier => 0.5f; + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float ai1 = 0f; + var p = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, -1f); if (player.Calamity().StealthStrikeAvailable()) { - ai1 = 1f; - } + p.Calamity().stealthStrike = true; + p.netUpdate = true; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, ai1); - if (player.Calamity().StealthStrikeAvailable() && p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; + var goType = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[goType] <= 0) + { + p = Projectile.NewProjectileDirect(source, position, Vector2.Zero, ModContent.ProjectileType(), damage, 10, player.whoAmI, 0f, -1f); + p.Calamity().stealthStrike = true; + } + else + { + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.active && proj.type == goType && proj.owner == player.whoAmI) + { + proj.timeLeft += 300; + proj.netUpdate = true; + break; + } + } + } + + } return false; } - - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 3; } } diff --git a/Items/Weapons/Rogue/GleamingDagger.cs b/Items/Weapons/Rogue/GleamingDagger.cs index 6e8efee10d..e609f2bb77 100644 --- a/Items/Weapons/Rogue/GleamingDagger.cs +++ b/Items/Weapons/Rogue/GleamingDagger.cs @@ -51,7 +51,6 @@ namespace CalamityMod.Items.Weapons.Rogue { CreateRecipe(). AddIngredient(ItemID.PlatinumBar, 12). - AddIngredient(ItemID.ThrowingKnife, 250). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/GodsParanoia.cs b/Items/Weapons/Rogue/GodsParanoia.cs index 617ddddddc..02bd23baf5 100644 --- a/Items/Weapons/Rogue/GodsParanoia.cs +++ b/Items/Weapons/Rogue/GodsParanoia.cs @@ -1,5 +1,4 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -18,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 20; Item.height = 20; - Item.damage = 210; + Item.damage = 163; Item.DamageType = RogueDamageClass.Instance; Item.noMelee = true; Item.noUseGraphic = true; @@ -26,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 5; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item1; Item.autoReuse = true; diff --git a/Items/Weapons/Rogue/HardenedHoneycomb.cs b/Items/Weapons/Rogue/HardenedHoneycomb.cs index 2042fcee4d..6e34fb3c3e 100644 --- a/Items/Weapons/Rogue/HardenedHoneycomb.cs +++ b/Items/Weapons/Rogue/HardenedHoneycomb.cs @@ -9,11 +9,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public class HardenedHoneycomb : RogueWeapon { - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 99; - } - public override void SetDefaults() { Item.width = 30; @@ -46,14 +41,5 @@ namespace CalamityMod.Items.Weapons.Rogue } return true; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.Hive, 10). - AddIngredient(ItemID.BeeWax, 8). - AddTile(TileID.Anvils). - Register(); - } } } diff --git a/Items/Weapons/Rogue/HeavenfallenStardisk.cs b/Items/Weapons/Rogue/HeavenfallenStardisk.cs index 92de798ec1..81315aedd6 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 = 165; + Item.damage = 160; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = Item.useTime = 40; @@ -21,8 +21,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 8f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityLimeBuyPrice; - Item.rare = ItemRarityID.Lime; + Item.value = CalamityGlobalItem.RarityYellowBuyPrice; + Item.rare = ItemRarityID.Yellow; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.DamageType = RogueDamageClass.Instance; @@ -32,26 +32,10 @@ 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) { - { - 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; - } + 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; } } } diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index c219d0b749..31043a2f4e 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -19,31 +19,29 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 46; Item.height = 32; + Item.damage = 148; + Item.DamageType = RogueDamageClass.Instance; + Item.useTime = 4; + Item.useAnimation = 12; + Item.reuseDelay = 1; + Item.useLimitPerAnimation = 3; + Item.knockBack = 3f; + Item.autoReuse = true; Item.noUseGraphic = true; Item.noMelee = true; Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item7; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - - Item.damage = 200; - Item.useTime = 3; - Item.useAnimation = 21; - Item.reuseDelay = 1; - Item.useLimitPerAnimation = 7; - Item.knockBack = 3f; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8f; - Item.rare = ModContent.RarityType(); - Item.DamageType = RogueDamageClass.Instance; + Item.rare = ModContent.RarityType(); + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; } // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 16; - public override float StealthDamageMultiplier => 1.1f; - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) @@ -66,10 +64,9 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = 0; i < projAmt; ++i) { - float SpeedX = velocity.X + Main.rand.NextFloat(-2f, 2f); - float SpeedY = velocity.Y + Main.rand.NextFloat(-2f, 2f); + Vector2 shardVel = velocity.RotatedByRandom(MathHelper.Pi / 30f) * Main.rand.NextFloat(0.9f, 1.1f); int texID = Main.rand.Next(4); - Projectile.NewProjectile(source, position, new Vector2(SpeedX, SpeedY), type, damage, knockback, player.whoAmI, texID, 0f); + Projectile.NewProjectile(source, position, shardVel, type, damage, knockback, player.whoAmI, texID); } return false; diff --git a/Items/Weapons/Rogue/IceStar.cs b/Items/Weapons/Rogue/IceStar.cs index d7cf231cb7..9d025acef4 100644 --- a/Items/Weapons/Rogue/IceStar.cs +++ b/Items/Weapons/Rogue/IceStar.cs @@ -9,11 +9,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public class IceStar : RogueWeapon { - public override void SetStaticDefaults() - { - Item.ResearchUnlockCount = 99; - } - public override void SetDefaults() { Item.width = Item.height = 66; @@ -26,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 2.5f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; - Item.value = Item.buyPrice(0, 0, 5, 0); + Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 14f; diff --git a/Items/Weapons/Rogue/Icebreaker.cs b/Items/Weapons/Rogue/Icebreaker.cs index 2e7bee34db..70313458d7 100644 --- a/Items/Weapons/Rogue/Icebreaker.cs +++ b/Items/Weapons/Rogue/Icebreaker.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Rogue/InfernalKris.cs b/Items/Weapons/Rogue/InfernalKris.cs index eacb33e1bc..a253fb640c 100644 --- a/Items/Weapons/Rogue/InfernalKris.cs +++ b/Items/Weapons/Rogue/InfernalKris.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 32; Item.height = 38; - Item.damage = 23; + Item.damage = 21; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 18; @@ -35,7 +35,10 @@ namespace CalamityMod.Items.Weapons.Rogue { int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); if (p.WithinBounds(Main.maxProjectiles)) + { Main.projectile[p].Calamity().stealthStrike = true; + Main.projectile[p].penetrate = 1; + } return false; } return true; @@ -45,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Rogue { CreateRecipe(). AddIngredient(ItemID.HellstoneBar, 10). - AddIngredient(ItemID.Obsidian, 9). + AddIngredient(ItemID.AshWood, 10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/JawsOfOblivion.cs b/Items/Weapons/Rogue/JawsOfOblivion.cs index 82b1ec85be..b910cf3358 100644 --- a/Items/Weapons/Rogue/JawsOfOblivion.cs +++ b/Items/Weapons/Rogue/JawsOfOblivion.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddIngredient(6). AddIngredient(15). AddIngredient(2). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/KelvinCatalyst.cs b/Items/Weapons/Rogue/KelvinCatalyst.cs index dc3bf49211..bdb23f1f1c 100644 --- a/Items/Weapons/Rogue/KelvinCatalyst.cs +++ b/Items/Weapons/Rogue/KelvinCatalyst.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 20; Item.height = 20; - Item.damage = 60; + Item.damage = 50; Item.noMelee = true; Item.noUseGraphic = true; Item.autoReuse = true; @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void AddRecipes() { CreateRecipe(). - AddIngredient(100). + AddIngredient(). AddIngredient(). AddIngredient(). AddIngredient(). diff --git a/Items/Weapons/Rogue/Kylie.cs b/Items/Weapons/Rogue/Kylie.cs index b9004d3226..f8848e07eb 100644 --- a/Items/Weapons/Rogue/Kylie.cs +++ b/Items/Weapons/Rogue/Kylie.cs @@ -1,5 +1,4 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Rogue/LeadTomahawk.cs b/Items/Weapons/Rogue/LeadTomahawk.cs index d07c9ea8e1..a981e139b2 100644 --- a/Items/Weapons/Rogue/LeadTomahawk.cs +++ b/Items/Weapons/Rogue/LeadTomahawk.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 40; Item.height = 36; - Item.damage = 10; + Item.damage = 9; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 20; diff --git a/Items/Weapons/Rogue/LeonidProgenitor.cs b/Items/Weapons/Rogue/LeonidProgenitor.cs index 7918e2eded..26a17019bd 100644 --- a/Items/Weapons/Rogue/LeonidProgenitor.cs +++ b/Items/Weapons/Rogue/LeonidProgenitor.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 32; Item.height = 48; - Item.damage = 64; + Item.damage = 57; Item.DamageType = RogueDamageClass.Instance; Item.knockBack = 3f; Item.useAnimation = Item.useTime = 15; @@ -38,9 +38,9 @@ namespace CalamityMod.Items.Weapons.Rogue Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; } + public override float StealthDamageMultiplier => 1.25f; public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) { if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) @@ -56,35 +56,23 @@ namespace CalamityMod.Items.Weapons.Rogue return base.CanUseItem(player); } - public override float UseSpeedMultiplier(Player player) - { - if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) - return 1f; - return 0.8f; - } - - public override float StealthDamageMultiplier => 1.25f; - - public override void ModifyStatsExtra(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) - { - if (!player.Calamity().StealthStrikeAvailable() && player.altFunctionUse == 2) - damage = (int)(damage * 0.5f); - } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) { int bomb = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (bomb.WithinBounds(Main.maxProjectiles)) - Main.projectile[bomb].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (bomb.WithinBounds(Main.maxProjectiles) && player.Calamity().StealthStrikeAvailable()) + { + Main.projectile[bomb].Calamity().stealthStrike = true; + Main.projectile[bomb].extraUpdates = 1; + } return false; } else { - for (float i = -2.5f; i < 3f; ++i) + for (int i = 0; i < 2; i++) { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i)); + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians((i - 0.5f) * 2)); Projectile.NewProjectile(source, position, perturbedSpeed, type, damage, knockback, player.whoAmI); } } diff --git a/Items/Weapons/Rogue/LeviathanTeeth.cs b/Items/Weapons/Rogue/LeviathanTeeth.cs index adc05255a4..bbced63075 100644 --- a/Items/Weapons/Rogue/LeviathanTeeth.cs +++ b/Items/Weapons/Rogue/LeviathanTeeth.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 36; Item.height = 38; - Item.damage = 44; + Item.damage = 43; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = Item.useTime = 9; @@ -21,35 +21,24 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 1f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; - Item.maxStack = 1; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 5.5f; + Item.shootSpeed = 7.5f; Item.DamageType = RogueDamageClass.Instance; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - bool stealthStrike = false; - if (player.Calamity().StealthStrikeAvailable()) - stealthStrike = true; - for (int i = 0; i < 2; i++) { - if (stealthStrike) - { - Projectile tooth = Projectile.NewProjectileDirect(source, position, velocity * 1.5f, type, damage, knockback * 12, player.whoAmI); - tooth.Calamity().stealthStrike = true; - tooth.timeLeft = 140; - tooth.ai[1] = 4; - return false; // This makes it not fire 2 with the for loop, thanks Angel lol - } - else - { - Projectile tooth = Projectile.NewProjectileDirect(source, position, velocity.RotatedByRandom(0.05f + i * 0.15f) * Main.rand.NextFloat(0.7f, 1f), type, damage, knockback, player.whoAmI); - tooth.ai[1] = Main.rand.Next(1, 3 + 1); - } + Projectile tooth = Projectile.NewProjectileDirect(source, position, velocity.SafeNormalize(Vector2.UnitX), ModContent.ProjectileType(), damage, 0, player.whoAmI, 0, 0); + tooth.Calamity().stealthStrike = true; + } + else + { + for (int i = 0; i < 2; i++) + Projectile.NewProjectile(source, position, velocity.RotatedByRandom(0.05f + i * 0.15f) * Main.rand.NextFloat(0.8f, 1f), type, damage, knockback, player.whoAmI, 0f, Main.rand.Next(1, 3+1)); } return false; } diff --git a/Items/Weapons/Rogue/LunarKunai.cs b/Items/Weapons/Rogue/LunarKunai.cs index 5c695cd2d4..829959a4cc 100644 --- a/Items/Weapons/Rogue/LunarKunai.cs +++ b/Items/Weapons/Rogue/LunarKunai.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Rogue/MeteorFist.cs b/Items/Weapons/Rogue/MeteorFist.cs index 3fe824bcf6..514769e61b 100644 --- a/Items/Weapons/Rogue/MeteorFist.cs +++ b/Items/Weapons/Rogue/MeteorFist.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 22; Item.height = 28; - Item.damage = 37; + Item.damage = 31; Item.DamageType = RogueDamageClass.Instance; - Item.useAnimation = Item.useTime = 28; + Item.useAnimation = Item.useTime = 25; Item.knockBack = 5.75f; Item.shootSpeed = 4f; @@ -31,8 +31,6 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shoot = ModContent.ProjectileType(); } - public override float StealthDamageMultiplier => 1.15f; - public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Rogue/MoltenAmputator.cs b/Items/Weapons/Rogue/MoltenAmputator.cs index c493609360..5c21deb49e 100644 --- a/Items/Weapons/Rogue/MoltenAmputator.cs +++ b/Items/Weapons/Rogue/MoltenAmputator.cs @@ -1,5 +1,5 @@ -using System; -using CalamityMod.Dusts; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using Microsoft.Xna.Framework; diff --git a/Items/Weapons/Rogue/Mycoroot.cs b/Items/Weapons/Rogue/Mycoroot.cs index 7adee86c42..445b1f993e 100644 --- a/Items/Weapons/Rogue/Mycoroot.cs +++ b/Items/Weapons/Rogue/Mycoroot.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; @@ -17,8 +18,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.damage = 12; Item.noMelee = true; Item.noUseGraphic = true; - Item.useTime = 5; - Item.useAnimation = 5; + Item.useTime = 6; + Item.useAnimation = 6; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 1.5f; Item.UseSound = SoundID.Item1; @@ -36,21 +37,19 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 20 && stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].Calamity().stealthStrike = true; - int projAmt = Main.rand.Next(7, 11); - for (int i = 0; i < projAmt; i++) + for (int i = 0; i < 8; i++) { - int spore = Projectile.NewProjectile(source, player.Center, velocity, ModContent.ProjectileType(), (int)(damage * 0.5f), knockback, player.whoAmI); - if (spore.WithinBounds(Main.maxProjectiles)) - Main.projectile[spore].ai[1] = 1f; + int spore = Projectile.NewProjectile(source, player.Center, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1f); } foreach (Player other in Main.ActivePlayers) { if (other.dead) continue; + if ((other.team == player.team && player.team != 0) || player.whoAmI == other.whoAmI) { if (player.Distance(other.Center) <= 800f) - other.AddBuff(ModContent.BuffType(), 900); + other.AddBuff(ModContent.BuffType(), 900, quiet: false); } } } diff --git a/Items/Weapons/Rogue/NightsGaze.cs b/Items/Weapons/Rogue/NightsGaze.cs deleted file mode 100644 index 04afde8631..0000000000 --- a/Items/Weapons/Rogue/NightsGaze.cs +++ /dev/null @@ -1,67 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Rogue -{ - public class NightsGaze : RogueWeapon - { - public override void SetDefaults() - { - Item.width = 82; - Item.height = 82; - Item.damage = 531; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.useAnimation = 20; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 20; - Item.knockBack = 1f; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.maxStack = 1; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 30f; - Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.rare = ModContent.RarityType(); - Item.DamageType = RogueDamageClass.Instance; - } - - 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) - { - if (player.Calamity().StealthStrikeAvailable()) - { - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (p.WithinBounds(Main.maxProjectiles)) - Main.projectile[p].Calamity().stealthStrike = true; - return false; - } - return true; - } - - 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/NightsGazeGlow").Value); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(7). - AddIngredient(4). - AddIngredient(12). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Rogue/Penumbra.cs b/Items/Weapons/Rogue/Penumbra.cs index e933be5740..bf62bd5875 100644 --- a/Items/Weapons/Rogue/Penumbra.cs +++ b/Items/Weapons/Rogue/Penumbra.cs @@ -24,42 +24,38 @@ namespace CalamityMod.Items.Weapons.Rogue Item.UseSound = SoundID.Item103; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.damage = 830; - Item.useAnimation = 40; - Item.useTime = 40; + Item.damage = 725; + Item.crit = 16; + Item.useTime = Item.useAnimation = 35; Item.knockBack = 8f; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 9f; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.DamageType = RogueDamageClass.Instance; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 16; - - public override float StealthDamageMultiplier => 0.85f; + public override float StealthDamageMultiplier => 0.9f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) { Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) - { - mouseYDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - realPlayerPos.Y; - } + float mouseXDist = Main.screenPosition.X + Main.mouseX - realPlayerPos.X; + float mouseYDist = Main.screenPosition.Y + (player.gravDir == -1 ? Main.screenHeight - Main.mouseY : Main.mouseY) - realPlayerPos.Y; if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { mouseXDist = player.direction; mouseYDist = 0f; } realPlayerPos += new Vector2(mouseXDist, mouseYDist); - int proj = Projectile.NewProjectile(source, realPlayerPos, new Vector2(0f, -0.5f), ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1f); + int proj = Projectile.NewProjectile(source, realPlayerPos, -Vector2.UnitY * 0.25f, ModContent.ProjectileType(), damage, knockback, player.whoAmI); if (proj.WithinBounds(Main.maxProjectiles)) + { Main.projectile[proj].Calamity().stealthStrike = true; + Main.projectile[proj].timeLeft = 450; + } return false; } return true; diff --git a/Items/Weapons/Rogue/PhantasmalRuin.cs b/Items/Weapons/Rogue/PhantasmalRuin.cs index c00e7059f6..1132a4b5fe 100644 --- a/Items/Weapons/Rogue/PhantasmalRuin.cs +++ b/Items/Weapons/Rogue/PhantasmalRuin.cs @@ -1,9 +1,6 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Rarities; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -16,13 +13,12 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 108; Item.height = 114; - Item.damage = 152; + Item.damage = 140; Item.knockBack = 8f; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.noUseGraphic = true; - Item.useTime = 30; - Item.useAnimation = 30; + Item.useTime = Item.useAnimation = 30; Item.autoReuse = true; Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Rogue/ProfanedPartisan.cs b/Items/Weapons/Rogue/ProfanedPartisan.cs index c6d2aec7aa..9c04347e38 100644 --- a/Items/Weapons/Rogue/ProfanedPartisan.cs +++ b/Items/Weapons/Rogue/ProfanedPartisan.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Weapons.Rogue { public override void SetDefaults() { - Item.width = 56; - Item.height = 56; + Item.width = 68; + Item.height = 68; Item.damage = 222; Item.knockBack = 8f; Item.useStyle = ItemUseStyleID.Swing; @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(). AddIngredient(25). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/ProfanedPartisan.png b/Items/Weapons/Rogue/ProfanedPartisan.png index defd077056..24b45d1ccc 100644 Binary files a/Items/Weapons/Rogue/ProfanedPartisan.png and b/Items/Weapons/Rogue/ProfanedPartisan.png differ diff --git a/Items/Weapons/Rogue/Pumpkaboom.cs b/Items/Weapons/Rogue/Pumpkaboom.cs new file mode 100644 index 0000000000..e636ef3972 --- /dev/null +++ b/Items/Weapons/Rogue/Pumpkaboom.cs @@ -0,0 +1,72 @@ +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + public class Pumpkaboom : RogueWeapon + { + public override void SetDefaults() + { + Item.width = 26; + Item.height = 34; + Item.damage = 17; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.useTime = Item.useAnimation = 70; + Item.useStyle = ItemUseStyleID.Swing; + Item.knockBack = 2f; + Item.UseSound = null; + Item.autoReuse = true; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 14f; + Item.DamageType = RogueDamageClass.Instance; + } + + public override bool CanUseItem(Player player) + { + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.type == Item.shoot && projectile.localAI[1] < 5 && projectile.owner == player.whoAmI) + { + return false; + } + } + return true; + } + + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.Calamity().StealthStrikeAvailable()) + { + int proj = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = true; + + return false; + } + return true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.Grenade, 15). + AddIngredient(ItemID.Pumpkin, 30). + AddIngredient(ItemID.PumpkinSeed, 5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/Rogue/Pumpkaboom.png b/Items/Weapons/Rogue/Pumpkaboom.png new file mode 100644 index 0000000000..4d612c1005 Binary files /dev/null and b/Items/Weapons/Rogue/Pumpkaboom.png differ diff --git a/Items/Weapons/Rogue/RealityRupture.cs b/Items/Weapons/Rogue/RealityRupture.cs index f88d479661..715d4575c6 100644 --- a/Items/Weapons/Rogue/RealityRupture.cs +++ b/Items/Weapons/Rogue/RealityRupture.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddIngredient(). AddIngredient(). AddIngredient(). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/ReboundingRainbow.cs b/Items/Weapons/Rogue/ReboundingRainbow.cs index a874f6347d..e006335ca7 100644 --- a/Items/Weapons/Rogue/ReboundingRainbow.cs +++ b/Items/Weapons/Rogue/ReboundingRainbow.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/RefractionRotor.cs b/Items/Weapons/Rogue/RefractionRotor.cs index 4d9491c548..6004817676 100644 --- a/Items/Weapons/Rogue/RefractionRotor.cs +++ b/Items/Weapons/Rogue/RefractionRotor.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.noMelee = true; Item.noUseGraphic = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override float StealthDamageMultiplier => 0.3f; diff --git a/Items/Weapons/Rogue/RegulusRiot.cs b/Items/Weapons/Rogue/RegulusRiot.cs index 02c40309ce..e283390dbe 100644 --- a/Items/Weapons/Rogue/RegulusRiot.cs +++ b/Items/Weapons/Rogue/RegulusRiot.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Rogue/RogueWeapon.cs b/Items/Weapons/Rogue/RogueWeapon.cs index d3f15c1c90..890861ce21 100644 --- a/Items/Weapons/Rogue/RogueWeapon.cs +++ b/Items/Weapons/Rogue/RogueWeapon.cs @@ -1,5 +1,4 @@ -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; using static Terraria.ID.ContentSamples.CreativeHelper; diff --git a/Items/Weapons/Rogue/RotBall.cs b/Items/Weapons/Rogue/RotBall.cs index 89cf7dcd29..24d5f0bf51 100644 --- a/Items/Weapons/Rogue/RotBall.cs +++ b/Items/Weapons/Rogue/RotBall.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; @@ -41,21 +41,10 @@ namespace CalamityMod.Items.Weapons.Rogue if (stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; } return false; } return true; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.DemoniteBar, 4). - AddIngredient(12). - AddIngredient(ItemID.RottenChunk, 4). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Rogue/Sacrifice.cs b/Items/Weapons/Rogue/Sacrifice.cs index d13814e54e..cd5c882622 100644 --- a/Items/Weapons/Rogue/Sacrifice.cs +++ b/Items/Weapons/Rogue/Sacrifice.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -26,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shootSpeed = 16f; Item.DamageType = RogueDamageClass.Instance; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } diff --git a/Items/Weapons/Rogue/SamsaraSlicer.cs b/Items/Weapons/Rogue/SamsaraSlicer.cs index a6cb2e84ef..a094442bb2 100644 --- a/Items/Weapons/Rogue/SamsaraSlicer.cs +++ b/Items/Weapons/Rogue/SamsaraSlicer.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Rogue [LegacyName("TerraDisk")] public class SamsaraSlicer : RogueWeapon { - public static float Speed = 20f; + public static float Speed = 25f; public override void SetDefaults() { @@ -36,8 +36,6 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shootSpeed = Speed; } - public override float StealthVelocityMultiplier => 1.5f; - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.ownedProjectileCounts[type] > 4) return false; diff --git a/Items/Weapons/Rogue/SandDollar.cs b/Items/Weapons/Rogue/SandDollar.cs index f873ac1eba..9cd76f632b 100644 --- a/Items/Weapons/Rogue/SandDollar.cs +++ b/Items/Weapons/Rogue/SandDollar.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -14,12 +13,11 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 30; Item.height = 28; - Item.damage = 26; + Item.damage = 20; Item.DamageType = RogueDamageClass.Instance; Item.noMelee = true; Item.noUseGraphic = true; - Item.useTime = 15; - Item.useAnimation = 15; + Item.useTime = Item.useAnimation = 28; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 3.5f; Item.autoReuse = true; @@ -27,34 +25,17 @@ namespace CalamityMod.Items.Weapons.Rogue Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; - } - - public override bool CanUseItem(Player player) - { - if (player.ownedProjectileCounts[Item.shoot] >= 2 && !player.Calamity().StealthStrikeAvailable()) - { - return false; - } - else - { - return true; - } + Item.shootSpeed = 8f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int spread = 2; - for (int i = 0; i < 2; i++) - { - Vector2 perturbedspeed = new Vector2(velocity.X + Main.rand.Next(-2, 3), velocity.Y + Main.rand.Next(-2, 3)).RotatedBy(MathHelper.ToRadians(spread)); - int stealth = Projectile.NewProjectile(source, position.X, position.Y, perturbedspeed.X * 1.5f, perturbedspeed.Y * 1.5f, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - spread -= Main.rand.Next(1, 3); - } + int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + return false; } return true; diff --git a/Items/Weapons/Rogue/ScourgeoftheDesert.cs b/Items/Weapons/Rogue/ScourgeoftheDesert.cs index 3686253aea..84fd0c9d23 100644 --- a/Items/Weapons/Rogue/ScourgeoftheDesert.cs +++ b/Items/Weapons/Rogue/ScourgeoftheDesert.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -9,6 +10,7 @@ namespace CalamityMod.Items.Weapons.Rogue { public class ScourgeoftheDesert : RogueWeapon { + public override void SetDefaults() { Item.width = 112; diff --git a/Items/Weapons/Rogue/ScourgeoftheDesert.png b/Items/Weapons/Rogue/ScourgeoftheDesert.png index 625d9bb541..8e86310af5 100644 Binary files a/Items/Weapons/Rogue/ScourgeoftheDesert.png and b/Items/Weapons/Rogue/ScourgeoftheDesert.png differ diff --git a/Items/Weapons/Rogue/ScourgeoftheSeas.cs b/Items/Weapons/Rogue/ScourgeoftheSeas.cs index 73754f4fb0..724c55ebb7 100644 --- a/Items/Weapons/Rogue/ScourgeoftheSeas.cs +++ b/Items/Weapons/Rogue/ScourgeoftheSeas.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; diff --git a/Items/Weapons/Rogue/SealedSingularity.cs b/Items/Weapons/Rogue/SealedSingularity.cs index 0c81d9d686..1aa1b4dd1f 100644 --- a/Items/Weapons/Rogue/SealedSingularity.cs +++ b/Items/Weapons/Rogue/SealedSingularity.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/SearedPan.cs b/Items/Weapons/Rogue/SearedPan.cs deleted file mode 100644 index b7cc902959..0000000000 --- a/Items/Weapons/Rogue/SearedPan.cs +++ /dev/null @@ -1,78 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Rarities; -using CalamityMod.Tiles.Furniture.CraftingStations; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Rogue -{ - public class SearedPan : RogueWeapon - { - public static readonly SoundStyle SmashSound = new("CalamityMod/Sounds/Item/SearedPanSmash"); - - // Attacks must be within 40 frames of each other to count as "consecutive" hits - // This is a little less than double the use time - public static int ConsecutiveHitOpening = 40; - public override void SetDefaults() - { - Item.width = 60; - Item.height = 36; - Item.damage = 2222; - Item.DamageType = RogueDamageClass.Instance; - Item.knockBack = 10f; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.useAnimation = Item.useTime = 25; - Item.reuseDelay = 1; - Item.useLimitPerAnimation = 1; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 15f; - Item.Calamity().donorItem = true; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - float mode = 1f; - if (player.Calamity().searedPanCounter >= 3) - { - player.Calamity().searedPanCounter = 0; - mode = 2f; - } - if (player.Calamity().StealthStrikeAvailable()) - { - player.Calamity().searedPanCounter = 0; - mode = 3f; - } - int pan = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, mode); - if (mode > 1f && pan.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[pan].extraUpdates++; - if (mode == 3f) - Main.projectile[pan].Calamity().stealthStrike = true; - } - return false; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(5). - AddIngredient(ItemID.LifeCrystal). - AddIngredient(ItemID.Bone, 92). - // AddIngredient(ItemID.Steak). - AddTile(). - Register(); - } - } -} diff --git a/Items/Weapons/Rogue/SearedPan.png b/Items/Weapons/Rogue/SearedPan.png deleted file mode 100644 index b5bef1d2cc..0000000000 Binary files a/Items/Weapons/Rogue/SearedPan.png and /dev/null differ diff --git a/Items/Weapons/Rogue/Seraphim.cs b/Items/Weapons/Rogue/Seraphim.cs index 70f1b3c210..c55b583ae2 100644 --- a/Items/Weapons/Rogue/Seraphim.cs +++ b/Items/Weapons/Rogue/Seraphim.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = SeraphimProjectile.InitialSpeed; Item.DamageType = RogueDamageClass.Instance; diff --git a/Items/Weapons/Rogue/ShardofAntumbra.cs b/Items/Weapons/Rogue/ShardofAntumbra.cs index 1b49987a1c..8afe0a8142 100644 --- a/Items/Weapons/Rogue/ShardofAntumbra.cs +++ b/Items/Weapons/Rogue/ShardofAntumbra.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 48; Item.height = 48; - Item.damage = 111; + Item.damage = 144; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 17; @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 0.5f; + public override float StealthDamageMultiplier => 0.65f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/ShatteredDawn.cs b/Items/Weapons/Rogue/ShatteredDawn.cs index ddd03e1541..0602d4e927 100644 --- a/Items/Weapons/Rogue/ShatteredDawn.cs +++ b/Items/Weapons/Rogue/ShatteredDawn.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(). AddIngredient(6). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/SkyStabber.cs b/Items/Weapons/Rogue/SkyStabber.cs deleted file mode 100644 index 21446160b0..0000000000 --- a/Items/Weapons/Rogue/SkyStabber.cs +++ /dev/null @@ -1,83 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Rogue -{ - public class SkyStabber : RogueWeapon - { - private static int knockBack = 2; - - public override void SetDefaults() - { - Item.width = 16; - Item.height = 16; - Item.damage = 50; - Item.DamageType = RogueDamageClass.Instance; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.useTime = 15; - Item.useAnimation = 15; - Item.useStyle = ItemUseStyleID.Swing; - Item.knockBack = knockBack; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; - Item.rare = ItemRarityID.Orange; - Item.UseSound = SoundID.Item1; - - Item.shootSpeed = 2.2f; - Item.shoot = ModContent.ProjectileType(); - } - - public override float StealthDamageMultiplier => 0.5f; - - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - Item.shoot = ProjectileID.None; - return player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; - } - else - { - Item.shoot = ModContent.ProjectileType(); - return player.ownedProjectileCounts[ModContent.ProjectileType()] < 4; - } - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.killSpikyBalls = false; - if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike - { - int stealth = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - return false; - } - return true; - } - - public override bool AltFunctionUse(Player player) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.killSpikyBalls = true; - return true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(4). - AddIngredient(ItemID.SunplateBlock, 8). - AddTile(TileID.SkyMill). - Register(); - } - - } -} diff --git a/Items/Weapons/Rogue/SkyStabber.png b/Items/Weapons/Rogue/SkyStabber.png deleted file mode 100644 index cd4be4f0a2..0000000000 Binary files a/Items/Weapons/Rogue/SkyStabber.png and /dev/null differ diff --git a/Items/Weapons/Rogue/SkyfinBombers.cs b/Items/Weapons/Rogue/SkyfinBombers.cs index f03534a050..33d8971e0f 100644 --- a/Items/Weapons/Rogue/SkyfinBombers.cs +++ b/Items/Weapons/Rogue/SkyfinBombers.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -40,5 +41,14 @@ namespace CalamityMod.Items.Weapons.Rogue } return true; } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(15). + AddTile(TileID.Anvils). + Register(); + } } } diff --git a/Items/Weapons/Rogue/SlickCane.cs b/Items/Weapons/Rogue/SlickCane.cs index 66108a171d..60f192551e 100644 --- a/Items/Weapons/Rogue/SlickCane.cs +++ b/Items/Weapons/Rogue/SlickCane.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 6f; Item.UseSound = SoundID.DD2_GhastlyGlaivePierce; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.value = Item.buyPrice(gold: 35); // Sold by Bandit Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; diff --git a/Items/Weapons/Rogue/SludgeSplotch.cs b/Items/Weapons/Rogue/SludgeSplotch.cs index d3f9b71e46..e90b104126 100644 --- a/Items/Weapons/Rogue/SludgeSplotch.cs +++ b/Items/Weapons/Rogue/SludgeSplotch.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 32; Item.height = 30; - Item.damage = 41; + Item.damage = 30; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 18; diff --git a/Items/Weapons/Rogue/SpearofDestiny.cs b/Items/Weapons/Rogue/SpearofDestiny.cs index e99ea4e662..17823595ac 100644 --- a/Items/Weapons/Rogue/SpearofDestiny.cs +++ b/Items/Weapons/Rogue/SpearofDestiny.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Accessories; -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 52; Item.height = 52; - Item.damage = 75; + Item.damage = 70; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = Item.useTime = 41; diff --git a/Items/Weapons/Rogue/StarofDestruction.cs b/Items/Weapons/Rogue/StarofDestruction.cs index 31295b43ed..3c9d4d3ddf 100644 --- a/Items/Weapons/Rogue/StarofDestruction.cs +++ b/Items/Weapons/Rogue/StarofDestruction.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; -using CalamityMod.UI; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -14,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SetDefaults() { Item.width = Item.height = 94; - Item.damage = 420; + Item.damage = 438; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = Item.useTime = 90; diff --git a/Items/Weapons/Rogue/StellarKnife.cs b/Items/Weapons/Rogue/StellarKnife.cs index b8f8e6eb71..abe77f582a 100644 --- a/Items/Weapons/Rogue/StellarKnife.cs +++ b/Items/Weapons/Rogue/StellarKnife.cs @@ -15,12 +15,11 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 32; Item.height = 34; - Item.damage = 82; + Item.damage = 69; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 9; + Item.useTime = Item.useAnimation = 9; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 9; Item.knockBack = 4f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; diff --git a/Items/Weapons/Rogue/Supernova.cs b/Items/Weapons/Rogue/Supernova.cs index d6bef9b091..abcaa7fee0 100644 --- a/Items/Weapons/Rogue/Supernova.cs +++ b/Items/Weapons/Rogue/Supernova.cs @@ -1,5 +1,4 @@ using CalamityMod.Items.Materials; -using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -35,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.DamageType = RogueDamageClass.Instance; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override float StealthDamageMultiplier => 0.7f; diff --git a/Items/Weapons/Rogue/TarragonThrowingDart.cs b/Items/Weapons/Rogue/TarragonThrowingDart.cs index cc2beb46e3..d76c7cc2d6 100644 --- a/Items/Weapons/Rogue/TarragonThrowingDart.cs +++ b/Items/Weapons/Rogue/TarragonThrowingDart.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Rogue { CreateRecipe(). AddIngredient(12). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/TerrorTalons.cs b/Items/Weapons/Rogue/TerrorTalons.cs index 72246ccf3b..c70d0fd3bc 100644 --- a/Items/Weapons/Rogue/TerrorTalons.cs +++ b/Items/Weapons/Rogue/TerrorTalons.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 40; Item.height = 24; - Item.damage = 50; + Item.damage = 47; Item.noMelee = true; Item.noUseGraphic = true; Item.useStyle = ItemUseStyleID.Swing; @@ -23,8 +23,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 3f; Item.UseSound = SoundID.Item39; Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityLightPurpleBuyPrice; - Item.rare = ItemRarityID.LightPurple; + Item.value = CalamityGlobalItem.RarityLimeBuyPrice; + Item.rare = ItemRarityID.Lime; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; Item.DamageType = RogueDamageClass.Instance; diff --git a/Items/Weapons/Rogue/TheAtomSplitter.cs b/Items/Weapons/Rogue/TheAtomSplitter.cs index 10cbf7a310..7372b085b7 100644 --- a/Items/Weapons/Rogue/TheAtomSplitter.cs +++ b/Items/Weapons/Rogue/TheAtomSplitter.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.noMelee = true; Item.noUseGraphic = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Rogue/TheFinalDawn.cs b/Items/Weapons/Rogue/TheFinalDawn.cs index beb247c99c..e85e7b59a3 100644 --- a/Items/Weapons/Rogue/TheFinalDawn.cs +++ b/Items/Weapons/Rogue/TheFinalDawn.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 4; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = RarityType(); + Item.rare = RarityType(); Item.Calamity().donorItem = true; Item.autoReuse = false; diff --git a/Items/Weapons/Rogue/TheOldReaper.cs b/Items/Weapons/Rogue/TheOldReaper.cs index 841f548173..80c69b5fab 100644 --- a/Items/Weapons/Rogue/TheOldReaper.cs +++ b/Items/Weapons/Rogue/TheOldReaper.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 106; Item.height = 104; - Item.damage = 1450; + Item.damage = 1520; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 50; diff --git a/Items/Weapons/Rogue/TheSyringe.cs b/Items/Weapons/Rogue/TheSyringe.cs index 0275281647..45944bb9c8 100644 --- a/Items/Weapons/Rogue/TheSyringe.cs +++ b/Items/Weapons/Rogue/TheSyringe.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -11,7 +12,6 @@ namespace CalamityMod.Items.Weapons.Rogue { public static float Knockback = 5f; public static float Speed = 15f; - public override void SetDefaults() { Item.width = 14; diff --git a/Items/Weapons/Rogue/ThrowingBrick.cs b/Items/Weapons/Rogue/ThrowingBrick.cs index a34ec66c13..d290fbacab 100644 --- a/Items/Weapons/Rogue/ThrowingBrick.cs +++ b/Items/Weapons/Rogue/ThrowingBrick.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.useAnimation = Item.useTime = 25; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 5f; - Item.value = Item.sellPrice(0, 0, 0, 4); + Item.value = Item.sellPrice(copper: 4); Item.rare = ItemRarityID.White; Item.maxStack = Item.CommonMaxStack; Item.UseSound = SoundID.Item1; diff --git a/Items/Weapons/Rogue/TimeBolt.cs b/Items/Weapons/Rogue/TimeBolt.cs index 6d48b1f18c..f5605f6e5f 100644 --- a/Items/Weapons/Rogue/TimeBolt.cs +++ b/Items/Weapons/Rogue/TimeBolt.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddIngredient(ItemID.FastClock). AddIngredient(5). AddIngredient(20). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/ToothBall.cs b/Items/Weapons/Rogue/ToothBall.cs index 2799f984b0..fd95ef183a 100644 --- a/Items/Weapons/Rogue/ToothBall.cs +++ b/Items/Weapons/Rogue/ToothBall.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; @@ -41,21 +41,10 @@ namespace CalamityMod.Items.Weapons.Rogue if (stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].Calamity().stealthStrike = true; - Main.projectile[stealth].usesLocalNPCImmunity = true; } return false; } return true; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 4). - AddIngredient(12). - AddIngredient(ItemID.Vertebrae, 4). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Rogue/TotalityBreakers.cs b/Items/Weapons/Rogue/TotalityBreakers.cs index d531ffe9ce..f606cd97b4 100644 --- a/Items/Weapons/Rogue/TotalityBreakers.cs +++ b/Items/Weapons/Rogue/TotalityBreakers.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 32; Item.height = 42; - Item.damage = 50; + Item.damage = 64; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 28; diff --git a/Items/Weapons/Rogue/ToxicantTwister.cs b/Items/Weapons/Rogue/ToxicantTwister.cs index 8a9a9c21f4..a4fa72738a 100644 --- a/Items/Weapons/Rogue/ToxicantTwister.cs +++ b/Items/Weapons/Rogue/ToxicantTwister.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -14,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 42; Item.height = 46; - Item.damage = 230; + Item.damage = 272; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = Item.useTime = 40; diff --git a/Items/Weapons/Rogue/Turbulance.cs b/Items/Weapons/Rogue/Turbulance.cs index f74c72f6fb..7dcbb8d404 100644 --- a/Items/Weapons/Rogue/Turbulance.cs +++ b/Items/Weapons/Rogue/Turbulance.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Rogue CreateRecipe(). AddIngredient(7). AddIngredient(ItemID.SunplateBlock, 3). - AddTile(TileID.SkyMill). + AddTile(TileID.Anvils). Register(); } } diff --git a/Items/Weapons/Rogue/TwistingThunder.cs b/Items/Weapons/Rogue/TwistingThunder.cs index 55cfb38d91..1ff0517975 100644 --- a/Items/Weapons/Rogue/TwistingThunder.cs +++ b/Items/Weapons/Rogue/TwistingThunder.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddIngredient(). AddIngredient(15). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Rogue/UtensilPoker.cs b/Items/Weapons/Rogue/UtensilPoker.cs index 01742616dc..90259f9cf0 100644 --- a/Items/Weapons/Rogue/UtensilPoker.cs +++ b/Items/Weapons/Rogue/UtensilPoker.cs @@ -1,5 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.Particles; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; diff --git a/Items/Weapons/Rogue/Vega.cs b/Items/Weapons/Rogue/Vega.cs new file mode 100644 index 0000000000..d44040ddb9 --- /dev/null +++ b/Items/Weapons/Rogue/Vega.cs @@ -0,0 +1,101 @@ +using System; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + [LegacyName("NightsGaze")] + public class Vega : RogueWeapon + { + public static int StarburstCost = 20; + public override void SetDefaults() + { + Item.width = 82; + Item.height = 82; + Item.damage = 531; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.useAnimation = 20; + Item.useStyle = ItemUseStyleID.Swing; + Item.useTime = 20; + Item.knockBack = 1f; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + Item.maxStack = 1; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 30f; + Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + Item.rare = ModContent.RarityType(); + Item.DamageType = RogueDamageClass.Instance; + } + + public override float StealthDamageMultiplier => 1.2f; + public override void HoldItem(Player player) + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 600); + } + + public override bool AltFunctionUse(Player player) + { + if (player.Calamity().AvaliableStarburst >= StarburstCost) + { + return true; + } + return false; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse == 2) + { + //Vega temporarily allows stealth strikes regardless of armor for 10 seconds on Starburst usage + player.Calamity().temporaryStealthTimer = 600; + player.Calamity().temporaryStealthMax = 1; //Bloodflare is 1.2f + player.Calamity().rogueStealth = Math.Max(player.Calamity().rogueStealthMax, player.Calamity().temporaryStealthMax); + player.Calamity().StratusStarburst -= StarburstCost; + int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI,0,1); + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().stealthStrike = true; + Main.projectile[p].extraUpdates += 1; + } + return false; + } + if (player.Calamity().StealthStrikeAvailable()) + { + int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[p].Calamity().stealthStrike = true; + Main.projectile[p].extraUpdates += 1; + } + return false; + } + return true; + } + + 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/VegaGlow").Value); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(7). + AddIngredient(4). + AddIngredient(12). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/Rogue/NightsGaze.png b/Items/Weapons/Rogue/Vega.png similarity index 100% rename from Items/Weapons/Rogue/NightsGaze.png rename to Items/Weapons/Rogue/Vega.png diff --git a/Items/Weapons/Rogue/NightsGazeGlow.png b/Items/Weapons/Rogue/VegaGlow.png similarity index 100% rename from Items/Weapons/Rogue/NightsGazeGlow.png rename to Items/Weapons/Rogue/VegaGlow.png diff --git a/Items/Weapons/Rogue/WaveSkipper.cs b/Items/Weapons/Rogue/WaveSkipper.cs index 8b13ced2b3..16d9b27fb2 100644 --- a/Items/Weapons/Rogue/WaveSkipper.cs +++ b/Items/Weapons/Rogue/WaveSkipper.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; diff --git a/Items/Weapons/Rogue/Whitewater.cs b/Items/Weapons/Rogue/Whitewater.cs index fe1e7f836b..6718f9aa7f 100644 --- a/Items/Weapons/Rogue/Whitewater.cs +++ b/Items/Weapons/Rogue/Whitewater.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -15,12 +16,11 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 36; Item.height = 40; - Item.damage = 88; + Item.damage = 80; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 42; + Item.useTime = Item.useAnimation = 34; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 42; Item.knockBack = 6.5f; Item.UseSound = SoundID.Item106 with { Volume = 0.7f }; Item.autoReuse = true; @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 0.85f; + public override float StealthDamageMultiplier => 0.9f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/Wrathwing.cs b/Items/Weapons/Rogue/Wrathwing.cs index 1e974a818b..1efb913580 100644 --- a/Items/Weapons/Rogue/Wrathwing.cs +++ b/Items/Weapons/Rogue/Wrathwing.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Rogue; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -24,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.autoReuse = true; Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 28f; Item.DamageType = RogueDamageClass.Instance; diff --git a/Items/Weapons/Rogue/WulfrumKnife.cs b/Items/Weapons/Rogue/WulfrumKnife.cs index 57a97d0e19..f8afaeb2c7 100644 --- a/Items/Weapons/Rogue/WulfrumKnife.cs +++ b/Items/Weapons/Rogue/WulfrumKnife.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.knockBack = 1f; Item.UseSound = Throw3Sound; Item.autoReuse = true; - Item.value = Item.sellPrice(0, 0, 0, 5); + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 4f; @@ -50,13 +50,28 @@ namespace CalamityMod.Items.Weapons.Rogue stealthStrikeStarted = false; Item.UseSound = Throw3Sound; - - if (Item.stack == 2) - Item.UseSound = Throw2Sound; - if (Item.stack == 1) - Item.UseSound = Throw1Sound; } + public override void HoldItem(Player player) + { + if (player.controlUseTile && !player.mouseInterface && !player.ItemAnimationActive) + { + if (Main.rand.NextBool(7)) + { + Particle streak = new ManaDrainStreak(player, Main.rand.NextFloat(0.2f, 0.5f), Main.rand.NextVector2CircularEdge(1f, 1f) * Main.rand.NextFloat(170f, 670f), Main.rand.NextFloat(30f, 44f), Color.GreenYellow, Color.DeepSkyBlue, Main.rand.Next(15, 30)); + GeneralParticleHandler.SpawnParticle(streak); + } + foreach (var item in Main.ActiveProjectiles) + { + if (item.type == ModContent.ProjectileType() && item.owner == player.whoAmI && (item.ai[0] > 0 || item.damage == 0)) + { + item.ai[0] = -1; + } + } + } + } + public override bool AltFunctionUse(Player player) => false; + public override float StealthDamageMultiplier => 1.5f; public override bool AdditionalStealthCheck() => stealthStrikeStarted; @@ -71,6 +86,17 @@ 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) { + if (player.altFunctionUse == 2) + { + foreach (var item in Main.ActiveProjectiles) + { + if (item.type == ModContent.ProjectileType() && item.owner == player.whoAmI && item.ai[0] > 0) + { + item.ai[0] = -1; + } + } + return false; + } if (player.Calamity().StealthStrikeAvailable() || stealthStrikeStarted) { stealthStrikeStarted = true; @@ -91,7 +117,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void AddRecipes() { CreateRecipe(). - AddIngredient(9). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Summon/AbandonedSlimeStaff.cs b/Items/Weapons/Summon/AbandonedSlimeStaff.cs index f29d97c52a..d64c3cd5e1 100644 --- a/Items/Weapons/Summon/AbandonedSlimeStaff.cs +++ b/Items/Weapons/Summon/AbandonedSlimeStaff.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.Summon; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -24,9 +25,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 40; Item.damage = 56; Item.knockBack = 3f; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; @@ -48,21 +49,16 @@ namespace CalamityMod.Items.Weapons.Summon slimeSlots = (int)(player.maxMinions - minionCount); } - public override bool CanUseItem(Player player) - { - return slimeSlots >= 1; - } + public override bool CanUseItem(Player player) => slimeSlots >= 1; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(true, type, player); float damageMult = ((float)Math.Log(slimeSlots, 8f)) + 1f; - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int slime = Projectile.NewProjectile(source, position, velocity, type, (int)(damage * damageMult), knockback, player.whoAmI); - Main.projectile[slime].originalDamage = (int)(Item.damage * damageMult); - Main.projectile[slime].minionSlots = slimeSlots; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, (int)(damage * damageMult), knockback, player.whoAmI); + minion.originalDamage = (int)(Item.damage * damageMult); + minion.minionSlots = slimeSlots; return false; } } diff --git a/Items/Weapons/Summon/AmphibiansGuitar.cs b/Items/Weapons/Summon/AmphibiansGuitar.cs index 1957f73d79..3958287ca6 100644 --- a/Items/Weapons/Summon/AmphibiansGuitar.cs +++ b/Items/Weapons/Summon/AmphibiansGuitar.cs @@ -12,12 +12,13 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - Item.damage = 200; + Item.width = 72; + Item.height = 64; + Item.damage = 54; Item.DamageType = DamageClass.Summon; Item.shoot = ModContent.ProjectileType(); - (Item.width, Item.height) = (72, 64); - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 36; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; diff --git a/Items/Weapons/Summon/AncientIceChunk.cs b/Items/Weapons/Summon/AncientIceChunk.cs index 00bfcf39ee..5cf2d78f05 100644 --- a/Items/Weapons/Summon/AncientIceChunk.cs +++ b/Items/Weapons/Summon/AncientIceChunk.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -35,10 +36,11 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 50; Item.damage = 25; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 2f; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; @@ -50,7 +52,9 @@ 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) { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(1f, 1f), type, damage, knockback, player.whoAmI); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(1f, 1f), type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/AquasScepter.cs b/Items/Weapons/Summon/AquasScepter.cs index f97b61c3c5..dbd049e737 100644 --- a/Items/Weapons/Summon/AquasScepter.cs +++ b/Items/Weapons/Summon/AquasScepter.cs @@ -4,7 +4,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.Creative; using Terraria.ID; using Terraria.ModLoader; @@ -27,8 +26,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 50; Item.DamageType = DamageClass.Summon; Item.sentry = true; - Item.useTime = 30; - Item.useAnimation = 30; + Item.useTime = Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; @@ -50,12 +48,12 @@ namespace CalamityMod.Items.Weapons.Summon public override void AddRecipes() { - Recipe recipe = Recipe.Create(ModContent.ItemType()); - recipe.AddIngredient(ItemID.NimbusRod); - recipe.AddIngredient(ItemID.AquaScepter); - recipe.AddIngredient(3); - recipe.AddTile(TileID.LunarCraftingStation); //LunarCraftingStation = Ancient Manipulator - recipe.Register(); + CreateRecipe(). + AddIngredient(ItemID.NimbusRod). + AddIngredient(ItemID.AquaScepter). + AddIngredient(3). + AddTile(TileID.MythrilAnvil). + Register(); } } } diff --git a/Items/Weapons/Summon/AresExoskeleton.cs b/Items/Weapons/Summon/AresExoskeleton.cs index 5b822be2c0..f8c8a5a9d7 100644 --- a/Items/Weapons/Summon/AresExoskeleton.cs +++ b/Items/Weapons/Summon/AresExoskeleton.cs @@ -73,12 +73,12 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 625; Item.useStyle = ItemUseStyleID.HoldUp; Item.noUseGraphic = true; - Item.useAnimation = Item.useTime = 9; + Item.useAnimation = Item.useTime = 24; Item.noMelee = true; Item.knockBack = 1f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item117; Item.shoot = ModContent.ProjectileType(); @@ -86,6 +86,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; } + public override bool? CanAutoReuseItem(Player player) => false; + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Summon/AresExoskeleton").Value; diff --git a/Items/Weapons/Summon/AtlasMunitionsBeacon.cs b/Items/Weapons/Summon/AtlasMunitionsBeacon.cs index 0706ca78d9..159b5cb614 100644 --- a/Items/Weapons/Summon/AtlasMunitionsBeacon.cs +++ b/Items/Weapons/Summon/AtlasMunitionsBeacon.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 38; Item.damage = 200; Item.mana = 10; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 4.75f; @@ -60,7 +60,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.shootSpeed = 10f; Item.noUseGraphic = true; Item.DamageType = DamageClass.Summon; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.sentry = true; } diff --git a/Items/Weapons/Summon/BelladonnaSpiritStaff.cs b/Items/Weapons/Summon/BelladonnaSpiritStaff.cs index 44890bd7ff..36d0e892f3 100644 --- a/Items/Weapons/Summon/BelladonnaSpiritStaff.cs +++ b/Items/Weapons/Summon/BelladonnaSpiritStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -32,22 +33,23 @@ namespace CalamityMod.Items.Weapons.Summon Item.knockBack = 1f; Item.mana = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 36; Item.DamageType = DamageClass.Summon; Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item44; - Item.rare = ItemRarityID.Blue; - Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.noMelee = true; Item.autoReuse = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int belladonna = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(belladonna)) - Main.projectile[belladonna].originalDamage = Item.damage; + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } public override void AddRecipes() diff --git a/Items/Weapons/Summon/BlackHawkRemote.cs b/Items/Weapons/Summon/BlackHawkRemote.cs index 330d2f3e95..7cfd0afdd7 100644 --- a/Items/Weapons/Summon/BlackHawkRemote.cs +++ b/Items/Weapons/Summon/BlackHawkRemote.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,13 +17,14 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 40; Item.damage = 25; Item.mana = 10; - Item.useAnimation = Item.useTime = 24; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 1f; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.UseSound = SoundID.Item15; //phaseblade sound effect Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 6f; // Affects bullet speed Item.DamageType = DamageClass.Summon; @@ -31,15 +33,9 @@ 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) { - if (player.altFunctionUse != 2) - { - if (player.whoAmI == Main.myPlayer) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/BorealisBomber.cs b/Items/Weapons/Summon/BorealisBomber.cs index d3fdc3a340..4e3b061271 100644 --- a/Items/Weapons/Summon/BorealisBomber.cs +++ b/Items/Weapons/Summon/BorealisBomber.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -19,9 +20,9 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 48; Item.height = 56; - Item.damage = 35; + Item.damage = 34; Item.mana = 10; - Item.useAnimation = Item.useTime = 19; + Item.useAnimation = Item.useTime = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5f; diff --git a/Items/Weapons/Summon/BrittleStarStaff.cs b/Items/Weapons/Summon/BrittleStarStaff.cs index a69c43a5a0..7eb8ef10a1 100644 --- a/Items/Weapons/Summon/BrittleStarStaff.cs +++ b/Items/Weapons/Summon/BrittleStarStaff.cs @@ -1,11 +1,11 @@ -using CalamityMod.Projectiles.Summon; -using CalamityMod.Projectiles.Typeless; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Items.Weapons.Summon { @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 64; Item.damage = 10; Item.mana = 10; - Item.useAnimation = Item.useTime = 32; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = Knockback; @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.Item44 with { Pitch = 0.5f }; Item.autoReuse = true; - Item.shootSpeed = 5; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; } @@ -42,12 +42,9 @@ namespace CalamityMod.Items.Weapons.Summon if (player.altFunctionUse != 2) { Item.noUseGraphic = false; - position = player.ClampedMouseWorld(); - velocity = Vector2.Zero; int SummonNumber = player.ownedProjectileCounts[type]; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0, 0, SummonNumber); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, SummonNumber); + minion.originalDamage = Item.damage; } if (player.altFunctionUse == 2) { diff --git a/Items/Weapons/Summon/BrittleStarStaff.png b/Items/Weapons/Summon/BrittleStarStaff.png index 5bcb654ee5..782d3eb149 100644 Binary files a/Items/Weapons/Summon/BrittleStarStaff.png and b/Items/Weapons/Summon/BrittleStarStaff.png differ diff --git a/Items/Weapons/Summon/CadaverousCarrion.cs b/Items/Weapons/Summon/CadaverousCarrion.cs index e2ff231070..03a7bc9f9d 100644 --- a/Items/Weapons/Summon/CadaverousCarrion.cs +++ b/Items/Weapons/Summon/CadaverousCarrion.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 10; Item.DamageType = DamageClass.Summon; Item.sentry = true; - Item.useAnimation = Item.useTime = 14; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.autoReuse = true; diff --git a/Items/Weapons/Summon/CalamarisLament.cs b/Items/Weapons/Summon/CalamarisLament.cs index 8123714305..f4b263ecf6 100644 --- a/Items/Weapons/Summon/CalamarisLament.cs +++ b/Items/Weapons/Summon/CalamarisLament.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CalamityMod.Buffs.Summon; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -43,8 +44,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 110; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.knockBack = 0.25f; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 1f; // This does nothing, it's just here so it's able to act like a staff. @@ -59,7 +61,9 @@ 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) { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), velocity, type, damage, knockback, player.whoAmI); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), velocity, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/CausticCroakerStaff.cs b/Items/Weapons/Summon/CausticCroakerStaff.cs index f9fc88fab2..a55ae33a05 100644 --- a/Items/Weapons/Summon/CausticCroakerStaff.cs +++ b/Items/Weapons/Summon/CausticCroakerStaff.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; Item.sentry = true; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 30; Item.knockBack = 0.25f; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; diff --git a/Items/Weapons/Summon/CausticStaff.cs b/Items/Weapons/Summon/CausticStaff.cs index 88a22bfafb..a37f4cebd2 100644 --- a/Items/Weapons/Summon/CausticStaff.cs +++ b/Items/Weapons/Summon/CausticStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,10 +18,10 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 10; Item.damage = 15; Item.useStyle = ItemUseStyleID.Swing; - Item.shootSpeed = 10f; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.UseSound = SoundID.Item77; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; @@ -34,12 +35,9 @@ 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) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/CinderBlossomStaff.cs b/Items/Weapons/Summon/CinderBlossomStaff.cs index f048621794..4fdd3eb232 100644 --- a/Items/Weapons/Summon/CinderBlossomStaff.cs +++ b/Items/Weapons/Summon/CinderBlossomStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,8 +18,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 16; Item.knockBack = 2f; Item.mana = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.DamageType = DamageClass.Summon; Item.useStyle = ItemUseStyleID.Swing; @@ -32,10 +34,10 @@ 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/CindersOfLament.cs b/Items/Weapons/Summon/CindersOfLament.cs index 6d7d05659f..ebaba97f0c 100644 --- a/Items/Weapons/Summon/CindersOfLament.cs +++ b/Items/Weapons/Summon/CindersOfLament.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.noMelee = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Summon/Cnidarian.cs b/Items/Weapons/Summon/Cnidarian.cs index 6799b4cac7..56b6601cad 100644 --- a/Items/Weapons/Summon/Cnidarian.cs +++ b/Items/Weapons/Summon/Cnidarian.cs @@ -1,6 +1,9 @@ using System.Linq; +using CalamityMod.Buffs.Summon.Whips; +using CalamityMod.DataStructures; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -15,6 +18,17 @@ namespace CalamityMod.Items.Weapons.Summon public new string LocalizationCategory => "Items.Weapons.Summon"; public override string Texture => "CalamityMod/Items/Weapons/Summon/CnidarianFishingRod"; + public static SummonTag summonTag = new() + { + FlatTagDamage = 2 + }; + + public override void SetStaticDefaults() + { + summonTag.TagItem = Type; + CalamityBuffSets.SummonTagDebuff.Add(BuffType(), summonTag); + } + public override void SetDefaults() { Item.width = 30; diff --git a/Items/Weapons/Summon/CorroslimeStaff.cs b/Items/Weapons/Summon/CorroslimeStaff.cs index bdaf95d306..4708a0d420 100644 --- a/Items/Weapons/Summon/CorroslimeStaff.cs +++ b/Items/Weapons/Summon/CorroslimeStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 54; Item.damage = 24; Item.mana = 10; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; @@ -24,22 +25,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/CorvidHarbringerStaff.cs b/Items/Weapons/Summon/CorvidHarbringerStaff.cs index 781e063250..0bfb67a0bf 100644 --- a/Items/Weapons/Summon/CorvidHarbringerStaff.cs +++ b/Items/Weapons/Summon/CorvidHarbringerStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -17,30 +18,28 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 54; Item.height = 52; + Item.damage = 99; + Item.DamageType = DamageClass.Summon; + Item.useAnimation = Item.useTime = 24; + Item.mana = 10; + Item.knockBack = 2f; + Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.UseSound = SoundID.DD2_BetsyFlyingCircleAttack; - Item.DamageType = DamageClass.Summon; - Item.mana = 10; - Item.damage = 114; - Item.knockBack = 2f; Item.autoReuse = true; - Item.useAnimation = Item.useTime = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 13f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/CosmicImmaterializer.cs b/Items/Weapons/Summon/CosmicImmaterializer.cs index d555808fda..37ff1d6a4a 100644 --- a/Items/Weapons/Summon/CosmicImmaterializer.cs +++ b/Items/Weapons/Summon/CosmicImmaterializer.cs @@ -1,4 +1,4 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; @@ -25,27 +25,27 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 560; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.knockBack = 0.25f; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.UseSound = SoundID.Item60; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.maxMinions >= 10; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/CosmicViperEngine.cs b/Items/Weapons/Summon/CosmicViperEngine.cs index ce0fd4f2de..63c5df1b8e 100644 --- a/Items/Weapons/Summon/CosmicViperEngine.cs +++ b/Items/Weapons/Summon/CosmicViperEngine.cs @@ -1,6 +1,5 @@ -using System; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -19,55 +18,37 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 46; Item.height = 28; - Item.damage = 321; + Item.damage = 255; Item.mana = 10; - Item.useAnimation = Item.useTime = 9; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 6f; Item.UseSound = SoundID.Item15; //phaseblade sound effect Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; // Affects bullet speed Item.DamageType = DamageClass.Summon; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - float speed = Item.shootSpeed; - Vector2 spawnPos = player.RotatedRelativePoint(player.MountedCenter, true); - float xPos = (float)Main.mouseX + Main.screenPosition.X - spawnPos.X; - float yPos = (float)Main.mouseY + Main.screenPosition.Y - spawnPos.Y; - if (player.gravDir == -1f) - { - yPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - spawnPos.Y; - } - Vector2 vel = new Vector2(xPos, yPos); - float dist = vel.Length(); - if ((float.IsNaN(vel.X) && float.IsNaN(vel.Y)) || (vel.X == 0f && vel.Y == 0f)) - { - vel.X = (float)player.direction; - vel.Y = 0f; - dist = speed; - } - else - { - dist = speed / dist; - } - vel.X *= dist; - vel.Y *= dist; - spawnPos.X = (float)Main.mouseX + Main.screenPosition.X; - spawnPos.Y = (float)Main.mouseY + Main.screenPosition.Y; - vel = vel.RotatedBy(MathHelper.PiOver2, default); - int p = Projectile.NewProjectile(source, spawnPos + vel, vel, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + + float speed = Item.shootSpeed; + Vector2 spawnPos = player.RotatedRelativePoint(player.MountedCenter, true); + float xPos = Main.screenPosition.X + Main.mouseX - spawnPos.X; + float yPos = Main.screenPosition.Y + (player.gravDir == -1 ? Main.screenHeight - Main.mouseY : Main.mouseY) - spawnPos.Y; + Vector2 vel = new Vector2(xPos, yPos).SafeNormalize(Vector2.UnitX * player.direction) * speed; + + spawnPos = player.ClampedMouseWorld(); + vel = vel.RotatedBy(MathHelper.PiOver2); + var minion = Projectile.NewProjectileDirect(source, spawnPos + vel, vel, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/Cosmilamp.cs b/Items/Weapons/Summon/Cosmilamp.cs index e1a878b754..2b2c829df1 100644 --- a/Items/Weapons/Summon/Cosmilamp.cs +++ b/Items/Weapons/Summon/Cosmilamp.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -19,7 +21,10 @@ namespace CalamityMod.Items.Weapons.Summon public const float LanternSummonCost = 2f; - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 2f; + public override void SetStaticDefaults() + { + ItemID.Sets.StaffMinionSlotsRequired[Type] = 2f; + } public override void SetDefaults() { @@ -27,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 60; Item.damage = 127; Item.mana = 10; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 4f; @@ -35,8 +40,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } @@ -44,26 +49,22 @@ 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) { - if (player.altFunctionUse != 2) - { - // Reset the timer for all lamps, to re-align the formation. - foreach (Projectile pro in Main.ActiveProjectiles) - { - if (pro.type == type && pro.owner == player.whoAmI) - { - pro.ModProjectile().Timer = 0f; - pro.netUpdate = true; - } - } + player.AddBuff(Item.buffType, 2); - int existingLamps = player.ownedProjectileCounts[type]; - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) + // Reset the timer for all lamps, to re-align the formation. + foreach (Projectile pro in Main.ActiveProjectiles) + { + if (pro.type == type && pro.owner == player.whoAmI) { - Main.projectile[p].originalDamage = Item.damage; - Main.projectile[p].ai[0] = existingLamps; + pro.ModProjectile().Timer = 0f; + pro.netUpdate = true; } } + + int existingLamps = player.ownedProjectileCounts[type]; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; + minion.ai[0] = existingLamps; return false; } } diff --git a/Items/Weapons/Summon/CrimslimeStaff.cs b/Items/Weapons/Summon/CrimslimeStaff.cs index 24fa2614c3..fcef51fb1b 100644 --- a/Items/Weapons/Summon/CrimslimeStaff.cs +++ b/Items/Weapons/Summon/CrimslimeStaff.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 52; Item.damage = 24; Item.mana = 10; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; @@ -24,22 +26,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/CryogenicStaff.cs b/Items/Weapons/Summon/CryogenicStaff.cs index 8408855e68..9f7e63c30d 100644 --- a/Items/Weapons/Summon/CryogenicStaff.cs +++ b/Items/Weapons/Summon/CryogenicStaff.cs @@ -14,11 +14,11 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 82; Item.height = 84; - Item.damage = 50; + Item.damage = 30; Item.mana = 10; Item.DamageType = DamageClass.Summon; Item.sentry = true; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.autoReuse = true; diff --git a/Items/Weapons/Summon/DaedalusGolemStaff.cs b/Items/Weapons/Summon/DaedalusGolemStaff.cs index ec0b92d270..7204fd2c03 100644 --- a/Items/Weapons/Summon/DaedalusGolemStaff.cs +++ b/Items/Weapons/Summon/DaedalusGolemStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -11,24 +12,20 @@ namespace CalamityMod.Items.Weapons.Summon public class DaedalusGolemStaff : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetStaticDefaults() - { - // Funny Hollow Knight reference. - } public override void SetDefaults() { Item.width = Item.height = 32; Item.damage = 70; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 3f; Item.UseSound = SoundID.Item67; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; @@ -36,13 +33,13 @@ 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) { + player.AddBuff(Item.buffType, 2); Vector2 mouse = player.ClampedMouseWorld(); Point mouseTileCoords = mouse.ToTileCoordinates(); if (!CalamityUtils.ParanoidTileRetrieval(mouseTileCoords.X, mouseTileCoords.Y).IsTileSolidGround()) { - int p = Projectile.NewProjectile(source, mouse, Vector2.UnitY * 4f, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, mouse, Vector2.UnitY * 4f, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; } return false; } diff --git a/Items/Weapons/Summon/DankStaff.cs b/Items/Weapons/Summon/DankStaff.cs index 9f99226039..8629b2ab5b 100644 --- a/Items/Weapons/Summon/DankStaff.cs +++ b/Items/Weapons/Summon/DankStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -17,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 58; Item.damage = 14; Item.mana = 10; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2.25f; @@ -25,33 +26,17 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Orange; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.DemoniteBar, 4). - AddIngredient(12). - AddIngredient(ItemID.RottenChunk, 4). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Summon/DazzlingStabberStaff.cs b/Items/Weapons/Summon/DazzlingStabberStaff.cs index 477f451751..f66a47e2db 100644 --- a/Items/Weapons/Summon/DazzlingStabberStaff.cs +++ b/Items/Weapons/Summon/DazzlingStabberStaff.cs @@ -1,9 +1,10 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -22,12 +23,12 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.DD2_DarkMageHealImpact; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.damage = 127; + Item.damage = 43; Item.knockBack = 2f; Item.autoReuse = true; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 24; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 13f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); @@ -38,29 +39,42 @@ 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) { - if (player.altFunctionUse != 2) + float usedMinionSlots = 0; + foreach (var minions in Main.ActiveProjectiles) + { + if (minions.owner == player.whoAmI) + usedMinionSlots += minions.minionSlots; + } + bool hasSlotsForSummon = true; + if (usedMinionSlots + 1 > player.maxMinions) + hasSlotsForSummon = false; + + player.AddBuff(Item.buffType, 2); + + int projCount = player.ownedProjectileCounts[type] + (hasSlotsForSummon ? 3 : 0); + if (hasSlotsForSummon) { for (int i = 0; i < 3; i++) { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, i + 1); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, i + 1); + minion.originalDamage = Item.damage; } } float angleMax = MathHelper.ToRadians(360f); - if (CalamityUtils.CountOwnedProjectiles(type, player.whoAmI) == 1) + if (projCount == 100) angleMax = 0f; float index = 1f; - if (player.ownedProjectileCounts[Item.shoot] > 30) + if (projCount > 30) { - angleMax += MathHelper.ToRadians((player.ownedProjectileCounts[Item.shoot] - 30) * 2.5f); + angleMax += MathHelper.ToRadians((projCount - 30) * 2.5f); } angleMax = angleMax > MathHelper.ToRadians(360f) ? MathHelper.ToRadians(360f) : angleMax; // More intuitive than using a min function foreach (Projectile p in Main.ActiveProjectiles) { if (p.type == type && p.owner == player.whoAmI) { - p.ai[1] = (index / CalamityUtils.CountOwnedProjectiles(type, player.whoAmI)) * angleMax - angleMax / 2f; + int adjustedProjCount = (int)(projCount); + p.ai[1] = index / adjustedProjCount * angleMax - angleMax / 2f; p.netUpdate = true; index++; } diff --git a/Items/Weapons/Summon/DeathstareRod.cs b/Items/Weapons/Summon/DeathstareRod.cs index 8bd0029774..014bf2a35a 100644 --- a/Items/Weapons/Summon/DeathstareRod.cs +++ b/Items/Weapons/Summon/DeathstareRod.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -15,24 +16,24 @@ namespace CalamityMod.Items.Weapons.Summon Item.width = Item.height = 46; Item.damage = 20; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.NPCHit8; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool CanUseItem(Player player) => 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/DeepseaStaff.cs b/Items/Weapons/Summon/DeepseaStaff.cs index b68a90c690..74ee7ec666 100644 --- a/Items/Weapons/Summon/DeepseaStaff.cs +++ b/Items/Weapons/Summon/DeepseaStaff.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -15,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.width = Item.height = 44; Item.damage = 40; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; @@ -23,20 +25,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Pink; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity = Vector2.Zero; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/DormantBrimseeker.cs b/Items/Weapons/Summon/DormantBrimseeker.cs index 1dbc591245..a3167682e3 100644 --- a/Items/Weapons/Summon/DormantBrimseeker.cs +++ b/Items/Weapons/Summon/DormantBrimseeker.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -15,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.width = Item.height = 32; Item.damage = 42; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Summon/DragonbloodDisgorger.cs b/Items/Weapons/Summon/DragonbloodDisgorger.cs index 2adca37808..c286cda0f7 100644 --- a/Items/Weapons/Summon/DragonbloodDisgorger.cs +++ b/Items/Weapons/Summon/DragonbloodDisgorger.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -21,23 +22,23 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 62; Item.damage = 215; Item.mana = 10; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 4f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.DD2_SkeletonDeath; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } @@ -47,7 +48,7 @@ namespace CalamityMod.Items.Weapons.Summon { CreateRecipe(). AddIngredient(12). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Summon/DreadmineStaff.cs b/Items/Weapons/Summon/DreadmineStaff.cs index e26467a1f2..8209148404 100644 --- a/Items/Weapons/Summon/DreadmineStaff.cs +++ b/Items/Weapons/Summon/DreadmineStaff.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 44; Item.height = 44; - Item.damage = 60; + Item.damage = 40; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 4.5f; @@ -34,7 +34,6 @@ 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) { - //CalamityUtils.OnlyOneSentry(player, type); int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; diff --git a/Items/Weapons/Summon/EnchantedConch.cs b/Items/Weapons/Summon/EnchantedConch.cs index 768ffed01d..eae9c882f3 100644 --- a/Items/Weapons/Summon/EnchantedConch.cs +++ b/Items/Weapons/Summon/EnchantedConch.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -18,10 +19,11 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 26; Item.damage = 20; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 2f; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 36; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; @@ -33,7 +35,9 @@ 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) { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Main.rand.NextVector2CircularEdge(5f, 5f), type, damage, knockback, player.whoAmI); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2CircularEdge(5f, 5f), type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/EnchantedKnifeStaff.cs b/Items/Weapons/Summon/EnchantedKnifeStaff.cs new file mode 100644 index 0000000000..c2b9993bd0 --- /dev/null +++ b/Items/Weapons/Summon/EnchantedKnifeStaff.cs @@ -0,0 +1,50 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class EnchantedKnifeStaff : ModItem, ILocalizedModType + { + public static float SwingTime = 20f; + public static float SwingWait = 10f; + public static float ProjectileSpeed = 15f; + public static float DashCooldown = 30f; + public static float DashSpeed = 16f; + + public new string LocalizationCategory => "Items.Weapons.Summon"; + + public override void SetStaticDefaults() => Item.staff[Type] = true; + + public override void SetDefaults() + { + Item.damage = 10; + Item.DamageType = DamageClass.Summon; + Item.shoot = ModContent.ProjectileType(); + Item.knockBack = 2f; + + Item.useTime = Item.useAnimation = 15; + Item.mana = 10; + Item.noMelee = true; + Item.autoReuse = true; + Item.width = 50; + Item.height = 50; + Item.value = CalamityGlobalItem.RarityBlueBuyPrice; + Item.rare = ItemRarityID.Blue; + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = SoundID.Item8; + + // Does nothing mechanical. Just makes Item.staff[] work. + Item.shootSpeed = 1f; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectileDirect(source, Main.MouseWorld, Vector2.Zero, type, damage, knockback, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Summon/EnchantedKnifeStaff.png b/Items/Weapons/Summon/EnchantedKnifeStaff.png new file mode 100644 index 0000000000..acafcb8fc9 Binary files /dev/null and b/Items/Weapons/Summon/EnchantedKnifeStaff.png differ diff --git a/Items/Weapons/Summon/EndoHydraStaff.cs b/Items/Weapons/Summon/EndoHydraStaff.cs index 3b64d117d0..55b0c7cb8c 100644 --- a/Items/Weapons/Summon/EndoHydraStaff.cs +++ b/Items/Weapons/Summon/EndoHydraStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -17,59 +18,57 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 58; Item.height = 60; + Item.damage = 190; + Item.DamageType = DamageClass.Summon; + Item.useAnimation = Item.useTime = 24; + Item.mana = 10; + Item.knockBack = 3f; + Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.UseSound = SoundID.Item60; - Item.DamageType = DamageClass.Summon; - Item.mana = 10; - Item.damage = 232; - Item.knockBack = 3f; Item.autoReuse = true; - Item.useAnimation = Item.useTime = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) + player.AddBuff(Item.buffType, 2); + + bool bodyExists = false; + int bodyIndex = -1; + foreach (Projectile p in Main.ActiveProjectiles) { - bool bodyExists = false; - int bodyIndex = -1; - foreach (Projectile p in Main.ActiveProjectiles) + if (p.type == type && p.owner == player.whoAmI) { - if (p.type == type && p.owner == player.whoAmI) - { - bodyIndex = p.whoAmI; - bodyExists = true; - break; - } + bodyIndex = p.whoAmI; + bodyExists = true; + break; } - if (bodyExists) + } + if (bodyExists) + { + var head = Projectile.NewProjectileDirect(source, player.Center, Main.rand.NextVector2Unit(), ModContent.ProjectileType(), damage, knockback, player.whoAmI, bodyIndex); + head.originalDamage = Item.damage; + } + else + { + bodyIndex = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + if (Main.projectile.IndexInRange(bodyIndex)) + Main.projectile[bodyIndex].originalDamage = Item.damage; + var head = Projectile.NewProjectileDirect(source, player.Center, Main.rand.NextVector2Unit(), ModContent.ProjectileType(), damage, knockback, player.whoAmI, bodyIndex); + head.originalDamage = Item.damage; + for (int i = 0; i < 72; i++) { - int p = Projectile.NewProjectile(source, player.Center, Main.rand.NextVector2Unit(), ModContent.ProjectileType(), damage, knockback, player.whoAmI, bodyIndex); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } - else - { - bodyIndex = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); - int head = Projectile.NewProjectile(source, player.Center, Main.rand.NextVector2Unit(), ModContent.ProjectileType(), damage, knockback, player.whoAmI, bodyIndex); - if (Main.projectile.IndexInRange(bodyIndex)) - Main.projectile[bodyIndex].originalDamage = Item.damage; - if (Main.projectile.IndexInRange(head)) - Main.projectile[head].originalDamage = Item.damage; - for (int i = 0; i < 72; i++) - { - Dust dust = Dust.NewDustPerfect(Main.projectile[bodyIndex].Center, 113); - dust.velocity = (MathHelper.TwoPi * Vector2.Dot((i / 72f * MathHelper.TwoPi).ToRotationVector2(), player.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(i / 72f * -MathHelper.TwoPi))).ToRotationVector2(); - dust.velocity = dust.velocity.RotatedBy(i / 36f * MathHelper.TwoPi) * 8f; - dust.noGravity = true; - dust.scale = 1.9f; - } + Dust dust = Dust.NewDustPerfect(Main.projectile[bodyIndex].Center, DustID.MushroomSpray); + dust.velocity = (MathHelper.TwoPi * Vector2.Dot((i / 72f * MathHelper.TwoPi).ToRotationVector2(), player.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(i / 72f * -MathHelper.TwoPi))).ToRotationVector2(); + dust.velocity = dust.velocity.RotatedBy(i / 36f * MathHelper.TwoPi) * 8f; + dust.noGravity = true; + dust.scale = 1.9f; } } return false; diff --git a/Items/Weapons/Summon/Endogenesis.cs b/Items/Weapons/Summon/Endogenesis.cs index 97942a9175..1e6da182f1 100644 --- a/Items/Weapons/Summon/Endogenesis.cs +++ b/Items/Weapons/Summon/Endogenesis.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -32,9 +33,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 1300; Item.knockBack = 4f; Item.autoReuse = true; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; Item.rare = ModContent.RarityType(); @@ -45,21 +46,19 @@ 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) { - if (player.altFunctionUse != 2) + CalamityUtils.KillShootProjectileMany(player, new int[] { - CalamityUtils.KillShootProjectileMany(player, new int[] - { - type, - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); + type, + ModContent.ProjectileType(), + ModContent.ProjectileType() + }); - SummonEndoCooper(source, AttackMode, player.ClampedMouseWorld(), damage, Item.damage, knockback, player, out _, out _); + player.AddBuff(Item.buffType, 2); + SummonEndoCooper(source, AttackMode, player.ClampedMouseWorld(), damage, Item.damage, knockback, player, out _, out _); - AttackMode++; - if (AttackMode > 3) - AttackMode = 0; - } + AttackMode++; + if (AttackMode > 3) + AttackMode = 0; return false; } diff --git a/Items/Weapons/Summon/EntropysVigil.cs b/Items/Weapons/Summon/EntropysVigil.cs index 676648fcab..1bbb84a7fc 100644 --- a/Items/Weapons/Summon/EntropysVigil.cs +++ b/Items/Weapons/Summon/EntropysVigil.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -22,12 +24,13 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 52; Item.height = 52; - Item.damage = 47; + Item.damage = 42; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 2f; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; @@ -42,6 +45,8 @@ 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) { + player.AddBuff(Item.buffType, 2); + Vector2 mouse = player.ClampedMouseWorld(); float randomAngleOffset = Main.rand.NextFloat(MathHelper.TwoPi); for (int i = 0; i < 3; i++) @@ -52,15 +57,18 @@ namespace CalamityMod.Items.Weapons.Summon switch (i) { case 0: - Projectile.NewProjectile(source, mouse, spawnVelocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + type = ModContent.ProjectileType(); break; case 1: - Projectile.NewProjectile(source, mouse, spawnVelocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + type = ModContent.ProjectileType(); break; case 2: - Projectile.NewProjectile(source, mouse, spawnVelocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + type = ModContent.ProjectileType(); break; } + + var minion = Projectile.NewProjectileDirect(source, mouse, spawnVelocity, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; } return false; diff --git a/Items/Weapons/Summon/EtherealSubjugator.cs b/Items/Weapons/Summon/EtherealSubjugator.cs index e1103cbc49..1d95674621 100644 --- a/Items/Weapons/Summon/EtherealSubjugator.cs +++ b/Items/Weapons/Summon/EtherealSubjugator.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -12,17 +14,17 @@ namespace CalamityMod.Items.Weapons.Summon public class EtherealSubjugator : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetDefaults() { Item.width = 66; Item.height = 70; - Item.damage = 200; + Item.damage = 175; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 1f; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; @@ -38,7 +40,9 @@ 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) { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Main.rand.NextVector2CircularEdge(5f, 5f), type, damage, knockback, player.whoAmI); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2CircularEdge(5f, 5f), type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/EyeOfNight.cs b/Items/Weapons/Summon/EyeOfNight.cs index 4dae0ecdb7..2a42ede2d8 100644 --- a/Items/Weapons/Summon/EyeOfNight.cs +++ b/Items/Weapons/Summon/EyeOfNight.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -16,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.width = Item.height = 36; Item.damage = 24; Item.mana = 10; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 1f; @@ -25,19 +26,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.NPCHit1; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.UnitY * -3f, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.UnitY * -3f, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/FlamsteedRing.cs b/Items/Weapons/Summon/FlamsteedRing.cs index 9f7230b417..21714b2e37 100644 --- a/Items/Weapons/Summon/FlamsteedRing.cs +++ b/Items/Weapons/Summon/FlamsteedRing.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Linq; +using System.Linq; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; @@ -67,6 +66,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.Calamity().CannotBeEnchanted = true; } + public override bool? CanAutoReuseItem(Player player) => false; + public static bool SpaceForLargeMech(Player player, bool visuals = true) { bool sufficientSpace = true; @@ -84,9 +85,9 @@ namespace CalamityMod.Items.Weapons.Summon if (!visuals) return false; - Dust warningDust = Dust.NewDustPerfect(pos.ToVector2() * 16f + Vector2.One * 8f, 127, Scale: 1.2f); + Dust warningDust = Dust.NewDustPerfect(pos.ToVector2() * 16f + Vector2.One * 8f, DustID.Flare, Scale: 1.2f); - warningDust = Dust.NewDustPerfect(pos.ToVector2() * 16f + Vector2.One * 8f, 114, Vector2.Zero, Scale: 1.4f); + warningDust = Dust.NewDustPerfect(pos.ToVector2() * 16f + Vector2.One * 8f, DustID.CrimsonSpray, Vector2.Zero, Scale: 1.4f); warningDust.noGravity = true; } } @@ -195,7 +196,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddIngredient(). AddIngredient(ItemID.WingsVortex). AddIngredient(5). diff --git a/Items/Weapons/Summon/FlarebatStaff.cs b/Items/Weapons/Summon/FlarebatStaff.cs deleted file mode 100644 index f94955710b..0000000000 --- a/Items/Weapons/Summon/FlarebatStaff.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Summon -{ - public class FlarebatStaff : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Summon"; - - public override void SetDefaults() - { - Item.damage = 18; - Item.DamageType = DamageClass.Summon; - Item.shoot = ModContent.ProjectileType(); - Item.knockBack = 1f; - - Item.useAnimation = Item.useTime = 15; - (Item.width, Item.height) = (50, 50); - Item.mana = 10; - Item.noMelee = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.UseSound = SoundID.Item20; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - return false; - } - } -} diff --git a/Items/Weapons/Summon/FlarebatStaff.png b/Items/Weapons/Summon/FlarebatStaff.png deleted file mode 100644 index 22e7b112ab..0000000000 Binary files a/Items/Weapons/Summon/FlarebatStaff.png and /dev/null differ diff --git a/Items/Weapons/Summon/FleshOfInfidelity.cs b/Items/Weapons/Summon/FleshOfInfidelity.cs index a7f73e84fa..75b31facef 100644 --- a/Items/Weapons/Summon/FleshOfInfidelity.cs +++ b/Items/Weapons/Summon/FleshOfInfidelity.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -11,17 +12,17 @@ namespace CalamityMod.Items.Weapons.Summon public class FleshOfInfidelity : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetDefaults() { Item.width = 42; Item.height = 42; Item.damage = 20; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 1f; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 36; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; @@ -33,18 +34,10 @@ 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) { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.UnitY * -1f, type, damage, knockback, player.whoAmI); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.UnitY * -1f, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.CrimtaneBar, 4). - AddIngredient(12). - AddIngredient(ItemID.Vertebrae, 4). - AddTile(TileID.DemonAltar). - Register(); - } } } diff --git a/Items/Weapons/Summon/FlowersOfMortality.cs b/Items/Weapons/Summon/FlowersOfMortality.cs index 2778b1c5a0..a1fcef6f85 100644 --- a/Items/Weapons/Summon/FlowersOfMortality.cs +++ b/Items/Weapons/Summon/FlowersOfMortality.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -21,13 +22,14 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 72; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item44; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; } @@ -36,6 +38,7 @@ 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(false, type, player); for (int i = 0; i < 5; i++) { @@ -53,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentStardust, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Summon/ForgottenApexWand.cs b/Items/Weapons/Summon/ForgottenApexWand.cs index 4fb966f134..32000195ad 100644 --- a/Items/Weapons/Summon/ForgottenApexWand.cs +++ b/Items/Weapons/Summon/ForgottenApexWand.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -25,22 +26,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.knockBack = 4f; Item.mana = 10; Item.damage = 28; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - vector2.X = Main.mouseX + Main.screenPosition.X; - vector2.Y = Main.mouseY + Main.screenPosition.Y; - int p = Projectile.NewProjectile(source, vector2, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/FrostBlossomStaff.cs b/Items/Weapons/Summon/FrostBlossomStaff.cs index 852b6cd188..6c3af92baa 100644 --- a/Items/Weapons/Summon/FrostBlossomStaff.cs +++ b/Items/Weapons/Summon/FrostBlossomStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,24 +17,24 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 24; Item.damage = 10; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; Item.UseSound = SoundID.Item28; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool CanUseItem(Player player) => 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } public override void AddRecipes() diff --git a/Items/Weapons/Summon/FrostbatStaff.cs b/Items/Weapons/Summon/FrostbatStaff.cs deleted file mode 100644 index ade55ae2aa..0000000000 --- a/Items/Weapons/Summon/FrostbatStaff.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Summon -{ - public class FrostbatStaff : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Summon"; - - public override void SetDefaults() - { - Item.damage = 22; - Item.DamageType = DamageClass.Summon; - Item.shoot = ModContent.ProjectileType(); - Item.knockBack = 1f; - - Item.useAnimation = Item.useTime = 15; - (Item.width, Item.height) = (50, 50); - Item.mana = 10; - Item.noMelee = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Swing; - Item.UseSound = SoundID.Item28; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.rare = ItemRarityID.Green; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - return false; - } - } -} diff --git a/Items/Weapons/Summon/FrostbatStaff.png b/Items/Weapons/Summon/FrostbatStaff.png deleted file mode 100644 index 1c99a19da7..0000000000 Binary files a/Items/Weapons/Summon/FrostbatStaff.png and /dev/null differ diff --git a/Items/Weapons/Summon/FuelCellBundle.cs b/Items/Weapons/Summon/FuelCellBundle.cs index 6e0f725d93..5a39da29cf 100644 --- a/Items/Weapons/Summon/FuelCellBundle.cs +++ b/Items/Weapons/Summon/FuelCellBundle.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 10; Item.damage = 25; Item.useStyle = ItemUseStyleID.Swing; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; Item.noMelee = true; Item.knockBack = 7f; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; diff --git a/Items/Weapons/Summon/GammaHeart.cs b/Items/Weapons/Summon/GammaHeart.cs index 6ab12f05c7..ae0778527f 100644 --- a/Items/Weapons/Summon/GammaHeart.cs +++ b/Items/Weapons/Summon/GammaHeart.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -23,21 +24,18 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 85; Item.knockBack = 3f; Item.autoReuse = true; - Item.useAnimation = Item.useTime = 14; + Item.useAnimation = Item.useTime = 24; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/GastricBelcherStaff.cs b/Items/Weapons/Summon/GastricBelcherStaff.cs index 4d2796f9cd..be53b10b04 100644 --- a/Items/Weapons/Summon/GastricBelcherStaff.cs +++ b/Items/Weapons/Summon/GastricBelcherStaff.cs @@ -1,4 +1,5 @@ -using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -15,53 +16,26 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 66; Item.height = 70; - Item.damage = 60; + Item.damage = 50; Item.mana = 10; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 1f; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; Item.UseSound = SoundID.Item76; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; Item.autoReuse = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float directionX = Main.mouseX + Main.screenPosition.X - playerPos.X; - float directionY = Main.mouseY + Main.screenPosition.Y - playerPos.Y; - if (player.gravDir == -1f) - { - directionY = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; - } - Vector2 spinningpoint = new Vector2(directionX, directionY); - float dist = spinningpoint.Length(); - if ((float.IsNaN(spinningpoint.X) && float.IsNaN(spinningpoint.Y)) || (spinningpoint.X == 0f && spinningpoint.Y == 0f)) - { - spinningpoint.X = player.direction; - spinningpoint.Y = 0f; - dist = Item.shootSpeed; - } - else - { - dist = Item.shootSpeed / dist; - } - spinningpoint.X *= dist; - spinningpoint.Y *= dist; - playerPos.X = Main.mouseX + Main.screenPosition.X; - playerPos.Y = Main.mouseY + Main.screenPosition.Y; - spinningpoint = spinningpoint.RotatedBy(Math.PI / 2D, default); - int p = Projectile.NewProjectile(source, playerPos + spinningpoint, spinningpoint, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(5f, 5f), type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/GlacialEmbrace.cs b/Items/Weapons/Summon/GlacialEmbrace.cs index 00fc0f2f75..0c886411d4 100644 --- a/Items/Weapons/Summon/GlacialEmbrace.cs +++ b/Items/Weapons/Summon/GlacialEmbrace.cs @@ -18,12 +18,13 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 50; Item.damage = 48; Item.mana = 10; - Item.useAnimation = Item.useTime = 24; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 4.5f; Item.UseSound = SoundID.Item30; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; @@ -44,11 +45,10 @@ namespace CalamityMod.Items.Weapons.Summon } if (player.altFunctionUse != 2 && totalMinionSlots < player.maxMinions) { - player.AddBuff(ModContent.BuffType(), 120, true); + player.AddBuff(Item.buffType, 2); position = player.ClampedMouseWorld(); - int p = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; int pointyThingCount = 0; foreach (Projectile pro in Main.ActiveProjectiles) { diff --git a/Items/Weapons/Summon/GuidelightofOblivion.cs b/Items/Weapons/Summon/GuidelightofOblivion.cs index 4f3797d962..493f59fa9d 100644 --- a/Items/Weapons/Summon/GuidelightofOblivion.cs +++ b/Items/Weapons/Summon/GuidelightofOblivion.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; Item.sentry = true; Item.mana = 10; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 5f; @@ -35,7 +35,6 @@ 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) { - //CalamityUtils.OnlyOneSentry(player, type); int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; diff --git a/Items/Weapons/Summon/HarvestStaff.cs b/Items/Weapons/Summon/HarvestStaff.cs index 4d26fbbfbc..a482ceb882 100644 --- a/Items/Weapons/Summon/HarvestStaff.cs +++ b/Items/Weapons/Summon/HarvestStaff.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.shoot = ModContent.ProjectileType(); Item.knockBack = 5f; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 30; Item.mana = 10; Item.width = 44; Item.height = 46; diff --git a/Items/Weapons/Summon/HauntedScroll.cs b/Items/Weapons/Summon/HauntedScroll.cs index 5ac5707364..33e2418c28 100644 --- a/Items/Weapons/Summon/HauntedScroll.cs +++ b/Items/Weapons/Summon/HauntedScroll.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -22,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 48; Item.damage = 25; Item.mana = 10; - Item.useAnimation = Item.useTime = 24; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 3f; @@ -30,23 +31,17 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item60; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 30f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - //projectile.ai[1] is attack cooldown. Setting it here prevents immediate attacks - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 30f); + minion.originalDamage = Item.damage; + //projectile.ai[1] is attack cooldown. Setting it here prevents immediate attacks return false; } diff --git a/Items/Weapons/Summon/HerringStaff.cs b/Items/Weapons/Summon/HerringStaff.cs index 33f8bd5fbe..3a4ce3aeed 100644 --- a/Items/Weapons/Summon/HerringStaff.cs +++ b/Items/Weapons/Summon/HerringStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,8 +18,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.knockBack = 1.25f; Item.mana = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.DamageType = DamageClass.Summon; Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item21; @@ -30,12 +32,9 @@ 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) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/HivePod.cs b/Items/Weapons/Summon/HivePod.cs index 8fdf65c7a8..f652f2aa3d 100644 --- a/Items/Weapons/Summon/HivePod.cs +++ b/Items/Weapons/Summon/HivePod.cs @@ -14,12 +14,12 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 46; Item.height = 50; - Item.damage = 125; + Item.damage = 75; Item.mana = 10; Item.DamageType = DamageClass.Summon; Item.sentry = true; Item.autoReuse = true; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 4f; diff --git a/Items/Weapons/Summon/IgneousExaltation.cs b/Items/Weapons/Summon/IgneousExaltation.cs index 1fb197c03a..2523a46969 100644 --- a/Items/Weapons/Summon/IgneousExaltation.cs +++ b/Items/Weapons/Summon/IgneousExaltation.cs @@ -1,8 +1,12 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; +using CalamityMod.Packets; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -10,7 +14,28 @@ namespace CalamityMod.Items.Weapons.Summon { public class IgneousExaltation : ModItem, ILocalizedModType { + public static int ChargeDuration = 30; + public static int ChargeCooldown = 120; public new string LocalizationCategory => "Items.Weapons.Summon"; + private static Texture2D BladeOutline = null; + public static Texture2D GetBladeOutlineTex() + { + if (BladeOutline == null) + { + var texture = ModContent.Request("CalamityMod/Projectiles/Summon/IgneousBlade").Value; + BladeOutline = new Texture2D(Main.graphics.GraphicsDevice, texture.Width, texture.Height); + + var BaseArray = new Color[BladeOutline.Width * BladeOutline.Height]; + var ColorArray = new Color[BladeOutline.Width * BladeOutline.Height]; + texture.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + BladeOutline.SetData(ColorArray); + } + return BladeOutline; + } public override void SetStaticDefaults() { Item.staff[Type] = true; @@ -22,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 50; Item.damage = 34; Item.mana = 10; - Item.useAnimation = Item.useTime = 24; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4.5f; @@ -30,63 +55,87 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Pink; Item.UseSound = SoundID.Item71; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } + + public override bool CanRightClick() + { + if (!Main.keyState.PressingShift()) + return false; + return true; + } + public override void RightClick(Player player) + { + Main.LocalPlayer.Calamity().InvertExaltationLineRotationDirections = !Main.LocalPlayer.Calamity().InvertExaltationLineRotationDirections; + if (Main.netMode != NetmodeID.SinglePlayer) + ExaltationDirectionSyncPacket.Send(Main.LocalPlayer.Calamity()); + } + + public override bool ConsumeItem(Player player) => false; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float totalMinionSlots = 0f; - foreach (Projectile pro in Main.ActiveProjectiles) + float totalSlots = 0f; + foreach (Projectile p in Main.ActiveProjectiles) { - if (pro.minion && pro.owner == player.whoAmI) + if (p.minion && p.owner == player.whoAmI) { - totalMinionSlots += pro.minionSlots; + totalSlots += p.minionSlots; } } - if (player.altFunctionUse != 2 && totalMinionSlots < player.maxMinions) + if (totalSlots >= player.maxMinions) { - position = player.ClampedMouseWorld(); - int p = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - int swordCount = 0; + foreach (Projectile pro in Main.ActiveProjectiles) + { + if (pro.type == type && pro.owner == player.whoAmI && pro.ai[1] >= 0 && pro.ai[0] == 0) + { + pro.ModProjectile().CurrentState = IgneousBlade.AIState.TransitionToLaunch; + pro.netUpdate = true; + } + } + } + else + { + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; + + int bladeIndex = 0; foreach (Projectile pro in Main.ActiveProjectiles) { if (pro.type == type && pro.owner == player.whoAmI) { - if ((pro.ModProjectile as IgneousBlade).Firing) - continue; - swordCount++; - for (int j = 0; j < 22; j++) - { - 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; - } - } - } - float angleVariance = MathHelper.TwoPi / swordCount; - float angle = 0f; - foreach (Projectile pro in Main.ActiveProjectiles) - { - if (pro.type == type && pro.owner == player.whoAmI && pro.localAI[1] == 0f) - { - if ((pro.ModProjectile as IgneousBlade).Firing) - continue; - pro.ai[0] = angle; - angle += angleVariance; - for (int j = 0; j < 22; j++) - { - 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; - } + pro.ModProjectile().BladeIndex = bladeIndex++; + pro.ModProjectile().AITimer = -ChargeCooldown; + pro.ModProjectile().DistanceTimer = -IgneousExaltation.ChargeCooldown; + pro.ModProjectile().CurrentState = IgneousBlade.AIState.CircleOwner; + pro.netUpdate = true; } } } return false; } + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + var tex = TextureAssets.Item[Type].Value; + CalamityUtils.DrawInventoryCustomScale( + spriteBatch, + tex, + position, + frame, + drawColor, + itemColor, + origin, + scale, + wantedScale: 0.75f, + spriteEffects: Main.LocalPlayer.Calamity().InvertExaltationLineRotationDirections ? SpriteEffects.FlipHorizontally : SpriteEffects.None, + rotation: Main.LocalPlayer.Calamity().InvertExaltationLineRotationDirections ? MathHelper.PiOver2 : 0 + ); + return false; + } public override void AddRecipes() { diff --git a/Items/Weapons/Summon/InfectedRemote.cs b/Items/Weapons/Summon/InfectedRemote.cs index afde753a8f..597f138b65 100644 --- a/Items/Weapons/Summon/InfectedRemote.cs +++ b/Items/Weapons/Summon/InfectedRemote.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -11,28 +13,23 @@ namespace CalamityMod.Items.Weapons.Summon { public new string LocalizationCategory => "Items.Weapons.Summon"; public const int DefaultIframes = 10; - public const int ChargeIframes = 2; - public const int RocketShootRate = 6; - public const int BeeShootRate = 22; public const int MaxUpdatesWhenCharging = 2; - public const float RegularChargeSpeed = 40f; - public const float HorizontalRocketChargeSpeed = 22f; public const float RocketDamageFactor = 0.7f; - public const float BeeDamageFactor = 0.65f; - public const float MinionSlotRequirement = 3f; - public const float EnemyTargetingRange = 1300f; - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 3f; + public override void SetStaticDefaults() + { + ItemID.Sets.StaffMinionSlotsRequired[Type] = 3f; + } public override void SetDefaults() { @@ -40,13 +37,13 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 28; Item.damage = 50; Item.mana = 10; - Item.useAnimation = Item.useTime = 19; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 5f; Item.UseSound = SoundID.Item15; //phaseblade sound effect + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; @@ -58,11 +55,10 @@ 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(true, type, player); - - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/KingofConstellationsTenryu.cs b/Items/Weapons/Summon/KingofConstellationsTenryu.cs index c8e3d512af..1747ceda75 100644 --- a/Items/Weapons/Summon/KingofConstellationsTenryu.cs +++ b/Items/Weapons/Summon/KingofConstellationsTenryu.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; @@ -23,10 +24,10 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 10; Item.damage = 187; Item.useStyle = ItemUseStyleID.HoldUp; - Item.shootSpeed = 10f; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.UseSound = Flare.FlareSound; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 24; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); @@ -38,10 +39,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.autoReuse = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-20, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-20, 0); public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.maxMinions >= 4; @@ -49,20 +47,23 @@ namespace CalamityMod.Items.Weapons.Summon { Vector2 spawnPos = new Vector2(player.position.X - 200, player.position.Y - 200); Vector2 spawnPos2 = new Vector2(player.position.X + 200, player.position.Y - 200); - SpawnDragon(ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), spawnPos2, player, source, damage, knockback); - SpawnDragon(ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), spawnPos, player, source, damage, knockback); + player.AddBuff(Item.buffType, 2); + SpawnDragon(ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), spawnPos2, player, source, damage, Item.damage, knockback); + SpawnDragon(ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), spawnPos, player, source, damage, Item.damage, knockback); return false; } - public static void SpawnDragon(int head, int body, int tail, Vector2 spawnPos, Player player, EntitySource_ItemUse_WithAmmo source, int damage, float knockback) + public static void SpawnDragon(int headType, int bodyType, int tailType, Vector2 spawnPos, Player player, EntitySource_ItemUse_WithAmmo source, int damage, int originalDamage, float knockback) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Projectile.NewProjectile(source, spawnPos, player.DirectionTo(Main.MouseWorld) * 3, head, damage, knockback, player.whoAmI); - // okay but seriously why are you multiplying zero by three - Projectile.NewProjectile(source, spawnPos, Vector2.Zero * 3, tail, damage, knockback, player.whoAmI); + var head = Projectile.NewProjectileDirect(source, spawnPos, player.DirectionTo(Main.MouseWorld) * 3, headType, damage, knockback, player.whoAmI); + head.originalDamage = originalDamage; + var tail = Projectile.NewProjectileDirect(source, spawnPos, Vector2.Zero, tailType, damage, knockback, player.whoAmI); + tail.originalDamage = originalDamage; for (var i = 0; i < 20; i++) { - Projectile.NewProjectile(source, spawnPos, Vector2.Zero * 3, body, damage, knockback, player.whoAmI); + var body = Projectile.NewProjectileDirect(source, spawnPos, Vector2.Zero, bodyType, damage, knockback, player.whoAmI); + body.originalDamage = originalDamage; } } @@ -73,7 +74,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(ItemID.DarkShard). AddIngredient(ItemID.LightShard). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.Bookcases). Register(); } } diff --git a/Items/Weapons/Summon/LegionofCelestia.cs b/Items/Weapons/Summon/LegionofCelestia.cs index 227aa6aed1..2268696ea2 100644 --- a/Items/Weapons/Summon/LegionofCelestia.cs +++ b/Items/Weapons/Summon/LegionofCelestia.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -20,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 57; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 5f; @@ -28,8 +29,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; } public override void UseStyle(Player player, Rectangle heldItemFrame) @@ -39,15 +40,9 @@ 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) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } @@ -56,12 +51,12 @@ namespace CalamityMod.Items.Weapons.Summon public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.EmpressBlade). AddIngredient(). + AddIngredient(ItemID.Smolstar). // Blade Staff AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(ItemID.FragmentStardust, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Summon/LiliesOfFinality.cs b/Items/Weapons/Summon/LiliesOfFinality.cs index 6f30839132..d4a1db3047 100644 --- a/Items/Weapons/Summon/LiliesOfFinality.cs +++ b/Items/Weapons/Summon/LiliesOfFinality.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -32,27 +33,25 @@ namespace CalamityMod.Items.Weapons.Summon public static int Ariane_AoESize = 1050; public static float Ariane_AoEDMGMultiplier = 0.4f; - // Do not change this number, ever. - Fabsol - public const int TheNumber = 512; - #endregion public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 2f; public override void SetDefaults() { - Item.damage = TheNumber; + Item.damage = 512; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ProjectileType(); Item.knockBack = 5f; Item.mana = 10; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 24; Item.width = 36; Item.height = 50; Item.noMelee = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = RarityType(); + Item.rare = RarityType(); Item.useStyle = ItemUseStyleID.HoldUp; Item.UseSound = new("CalamityMod/Sounds/Item/LiliesOfFinalitySummonSpawn"); } @@ -61,9 +60,12 @@ 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) { + player.AddBuff(Item.buffType, 2); Vector2 mouse = player.ClampedMouseWorld(); - Projectile.NewProjectile(source, mouse, new Vector2(-1f, -1f) * 3f, type, damage, knockback, player.whoAmI); - Projectile.NewProjectile(source, mouse, new Vector2(1f, -1f) * 3f, ProjectileType(), damage, knockback, player.whoAmI); + var elster = Projectile.NewProjectileDirect(source, mouse, new Vector2(-1f, -1f) * 3f, type, damage, knockback, player.whoAmI); + elster.originalDamage = Item.damage; + var ariane = Projectile.NewProjectileDirect(source, mouse, new Vector2(1f, -1f) * 3f, ProjectileType(), damage, knockback, player.whoAmI); + ariane.originalDamage = Item.damage; if (Main.dedServ) return false; diff --git a/Items/Weapons/Summon/Metastasis.cs b/Items/Weapons/Summon/Metastasis.cs index ce288d7a8b..c489968bf5 100644 --- a/Items/Weapons/Summon/Metastasis.cs +++ b/Items/Weapons/Summon/Metastasis.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -14,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetStaticDefaults() { - ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); ItemID.Sets.StaffMinionSlotsRequired[Type] = 4f; } @@ -24,15 +25,15 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 78; Item.damage = 400; Item.mana = 10; - Item.useAnimation = Item.useTime = 10; // 9 because of useStyle 1 + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.DD2_BetsySummon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } @@ -40,9 +41,9 @@ 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) { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), -Vector2.UnitY * 5f, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), -Vector2.UnitY * 5f, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/MidnightSunBeacon.cs b/Items/Weapons/Summon/MidnightSunBeacon.cs index 431dfd4d0f..90479063db 100644 --- a/Items/Weapons/Summon/MidnightSunBeacon.cs +++ b/Items/Weapons/Summon/MidnightSunBeacon.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.width = Item.height = 32; Item.damage = 176; Item.mana = 10; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.noUseGraphic = true; @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Summon/MirrorofKalandra.cs b/Items/Weapons/Summon/MirrorofKalandra.cs index 764c1af28f..b79de9d2a3 100644 --- a/Items/Weapons/Summon/MirrorofKalandra.cs +++ b/Items/Weapons/Summon/MirrorofKalandra.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon.MirrorofKalandraMinions; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -20,19 +21,19 @@ namespace CalamityMod.Items.Weapons.Summon public static float Axe_MinRamSpeed = 30f; public static float Axe_MaxRamSpeed = 50f; - public static int Axe_IFrames = 15; + public static int Axe_IFrames = 20; public static float Axe_SpinSpeed = 25f; // In degrees per frame. public static float Purple_MinRamSpeed = 40f; public static float Purple_MaxRamSpeed = 60f; - public static int Purple_IFrames = 23; - public static float Purple_BlastDMGModifier = 2.25f; + public static int Purple_IFrames = 28; + public static float Purple_BlastDMGModifier = 2f; public static float Purple_BlastFireRate = 240f; // In frames. public static int Purple_BlastSize = 300; public static int Purple_BlastChargeTime = 10; public static float Purple_SpinSpeed = 25f; // In degrees per frame. - public static int Scimitar_IFrames = 36; // Note that the effective iframes are half of this number, since the weapon is given an extra update while attacking. + public static int Scimitar_IFrames = 40; // Note that the effective iframes are half of this number, since the weapon is given an extra update while attacking. public static int Wind_BowChargeTime = 5; // Therefore, the higher the time, the slower the fire rate will be, and viceversa. public static float Wind_ArrowSpeed = 5f; @@ -49,10 +50,11 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 58; Item.height = 50; - Item.damage = 317; - Item.useAnimation = Item.useTime = 30; + Item.damage = 256; + Item.useAnimation = Item.useTime = 24; Item.knockBack = 4f; Item.mana = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.autoReuse = true; @@ -61,7 +63,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; Item.useStyle = ItemUseStyleID.Shoot; Item.UseSound = SoundID.Item4; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; } @@ -71,6 +73,7 @@ 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) { + player.AddBuff(Item.buffType, 2); if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 1) { type = ModContent.ProjectileType(); @@ -82,9 +85,9 @@ namespace CalamityMod.Items.Weapons.Summon type = ModContent.ProjectileType(); } - int minion = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(minion)) - Main.projectile[minion].rotation = -MathHelper.PiOver2; + var minion = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.rotation = -MathHelper.PiOver2; + minion.originalDamage = Item.damage; return false; } @@ -97,6 +100,13 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(10). AddCondition(Condition.NearShimmer). Register(); + + CreateRecipe(). + AddIngredient(ItemID.IceMirror). + AddIngredient(10). + AddIngredient(10). + AddCondition(Condition.NearShimmer). + Register(); } } } diff --git a/Items/Weapons/Summon/MutatedTruffle.cs b/Items/Weapons/Summon/MutatedTruffle.cs index 145cc7d099..31c577e525 100644 --- a/Items/Weapons/Summon/MutatedTruffle.cs +++ b/Items/Weapons/Summon/MutatedTruffle.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -29,18 +31,22 @@ namespace CalamityMod.Items.Weapons.Summon #endregion - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 3f; + public override void SetStaticDefaults() + { + ItemID.Sets.StaffMinionSlotsRequired[Type] = 3f; + } public override void SetDefaults() { Item.width = 24; Item.height = 26; - Item.damage = 275; + Item.damage = 250; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 5f; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.mana = 10; Item.noMelee = true; Item.useStyle = ItemUseStyleID.HoldUp; @@ -49,12 +55,15 @@ namespace CalamityMod.Items.Weapons.Summon Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; } + // Only one can be summoned. + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 1 && player.maxMinions >= 3; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - // Only one can be summoned. - if (player.ownedProjectileCounts[type] < 1 && player.maxMinions >= 3) - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(2f, 2f), type, damage, knockback, player.whoAmI); - + player.AddBuff(Item.buffType, 2); + CalamityUtils.KillShootProjectiles(true, type, player); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(2f, 2f), type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/OrthoceraShell.cs b/Items/Weapons/Summon/OrthoceraShell.cs index 54321a17b5..be0981aa6b 100644 --- a/Items/Weapons/Summon/OrthoceraShell.cs +++ b/Items/Weapons/Summon/OrthoceraShell.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 34; Item.damage = 53; Item.mana = 10; - Item.useAnimation = Item.useTime = 24; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 2f; diff --git a/Items/Weapons/Summon/Perdition.cs b/Items/Weapons/Summon/Perdition.cs index 9db7a9910e..d608c2d761 100644 --- a/Items/Weapons/Summon/Perdition.cs +++ b/Items/Weapons/Summon/Perdition.cs @@ -1,8 +1,8 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -13,39 +13,35 @@ namespace CalamityMod.Items.Weapons.Summon { public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 5f; - public override void SetDefaults() { Item.width = Item.height = 56; Item.damage = 375; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); + Item.sentry = true; Item.knockBack = 4f; - Item.useAnimation = Item.useTime = 10; // 9 because of useStyle 1. + Item.useAnimation = Item.useTime = 30; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.DD2_EtherianPortalOpen; } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 1; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - if (player.ownedProjectileCounts[type] < 1) - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - } - else - { - // Play some demonic noises prior to a target being selected. - SoundEngine.PlaySound(SoundID.Zombie93, player.Center); - SoundEngine.PlaySound(SoundID.Item119, player.Center); - } + player.AddBuff(Item.buffType, 2); + CalamityUtils.KillShootProjectiles(true, type, player); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; + player.UpdateMaxTurrets(); return false; } } diff --git a/Items/Weapons/Summon/PlantationStaff.cs b/Items/Weapons/Summon/PlantationStaff.cs index f7ab0903ef..c251959055 100644 --- a/Items/Weapons/Summon/PlantationStaff.cs +++ b/Items/Weapons/Summon/PlantationStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -41,11 +42,12 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 50; Item.damage = 58; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 1f; Item.mana = 10; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; Item.noMelee = true; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; @@ -57,7 +59,9 @@ 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) { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(2f, 2f), type, damage, knockback, player.whoAmI); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(2f, 2f), type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } @@ -70,7 +74,6 @@ namespace CalamityMod.Items.Weapons.Summon { CreateRecipe(). AddIngredient(). - AddIngredient(ItemID.Smolstar). // Blade Staff. AddIngredient(12). AddTile(TileID.MythrilAnvil). Register(); diff --git a/Items/Weapons/Summon/PolypLauncher.cs b/Items/Weapons/Summon/PolypLauncher.cs index dd22edc4cd..7b518c3e03 100644 --- a/Items/Weapons/Summon/PolypLauncher.cs +++ b/Items/Weapons/Summon/PolypLauncher.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; Item.sentry = true; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 30; Item.knockBack = 0.25f; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; diff --git a/Items/Weapons/Summon/PuffShroom.cs b/Items/Weapons/Summon/PuffShroom.cs index b1e933d4d3..10a939369c 100644 --- a/Items/Weapons/Summon/PuffShroom.cs +++ b/Items/Weapons/Summon/PuffShroom.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 32; Item.damage = 14; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; @@ -24,19 +26,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.Item42; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int puffGuy = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(puffGuy)) - Main.projectile[puffGuy].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/ResurrectionButterfly.cs b/Items/Weapons/Summon/ResurrectionButterfly.cs index 98ff76631a..579885a228 100644 --- a/Items/Weapons/Summon/ResurrectionButterfly.cs +++ b/Items/Weapons/Summon/ResurrectionButterfly.cs @@ -1,4 +1,4 @@ -using System; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 46; Item.damage = 66; // clueless Item.mana = 10; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 1f; @@ -29,22 +29,21 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + player.AddBuff(Item.buffType, 2); Vector2 clampedMouse = player.ClampedMouseWorld(); - Vector2 mouseDirection = Vector2.Normalize(clampedMouse - player.Center) * Item.shootSpeed; + Vector2 mouseDirection = Vector2.Normalize(clampedMouse - player.Center) * 10f; - int p = Projectile.NewProjectile(source, clampedMouse, mouseDirection.RotatedBy(MathHelper.PiOver2), ModContent.ProjectileType(), damage, knockback, Main.myPlayer, 0f, 0f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - p = Projectile.NewProjectile(source, clampedMouse, mouseDirection.RotatedBy(-MathHelper.PiOver2), ModContent.ProjectileType(), damage, knockback, Main.myPlayer, 0f, 0f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var pink = Projectile.NewProjectileDirect(source, clampedMouse, mouseDirection.RotatedBy(MathHelper.PiOver2), ModContent.ProjectileType(), damage, knockback, Main.myPlayer, 0f, 0f); + pink.originalDamage = Item.damage; + var purple = Projectile.NewProjectileDirect(source, clampedMouse, mouseDirection.RotatedBy(-MathHelper.PiOver2), ModContent.ProjectileType(), damage, knockback, Main.myPlayer, 0f, 0f); + purple.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/RustyBeaconPrototype.cs b/Items/Weapons/Summon/RustyBeaconPrototype.cs index 2cc3731c36..b70e451dc8 100644 --- a/Items/Weapons/Summon/RustyBeaconPrototype.cs +++ b/Items/Weapons/Summon/RustyBeaconPrototype.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 20; Item.mana = 10; Item.damage = 8; - Item.useAnimation = Item.useTime = 34; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 0.5f; @@ -33,6 +33,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; + Item.sentry = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Summon/SanctifiedSpark.cs b/Items/Weapons/Summon/SanctifiedSpark.cs index 443383274b..62798dbb63 100644 --- a/Items/Weapons/Summon/SanctifiedSpark.cs +++ b/Items/Weapons/Summon/SanctifiedSpark.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; Item.sentry = true; Item.mana = 100; - Item.useAnimation = Item.useTime = 14; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5f; @@ -36,7 +36,6 @@ 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) { - //CalamityUtils.OnlyOneSentry(player, type); int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 16f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; diff --git a/Items/Weapons/Summon/SandSharknadoStaff.cs b/Items/Weapons/Summon/SandSharknadoStaff.cs index 5254fbb849..884350d5e0 100644 --- a/Items/Weapons/Summon/SandSharknadoStaff.cs +++ b/Items/Weapons/Summon/SandSharknadoStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -11,24 +12,20 @@ namespace CalamityMod.Items.Weapons.Summon public class SandSharknadoStaff : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - #region Other stats for easy modification - public const float ProjSpeed = 30f; - public const float FireSpeed = 50f; // In frames. 60 frames = 1 second. - #endregion - public override void SetDefaults() { Item.width = 48; Item.height = 56; - Item.damage = 94; + Item.damage = 71; Item.knockBack = 2f; Item.mana = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; Item.DamageType = DamageClass.Summon; Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item44; @@ -40,12 +37,9 @@ 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) { - if (player.altFunctionUse != 2) - { - int sandnado = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(sandnado)) - Main.projectile[sandnado].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } @@ -53,9 +47,8 @@ namespace CalamityMod.Items.Weapons.Summon { CreateRecipe(). AddIngredient(). - AddIngredient(). - AddIngredient(10). AddIngredient(ItemID.AncientCloth, 5). + AddIngredient(). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index cb7411cbcc..d1d6cfef1f 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -1,9 +1,12 @@ -using CalamityMod.Items.Materials; +using System.Linq; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -13,43 +16,60 @@ namespace CalamityMod.Items.Weapons.Summon public class SarosPossession : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 8f; - + public static SoundStyle FiringSound => new SoundStyle("CalamityMod/Sounds/Item/Summon/SarosFiring") with { MaxInstances = 1 ,Volume = 0.3f, pitchVariance = 0.05f, pitch = 0.5f }; + public static SoundStyle SpawnSound => new SoundStyle("CalamityMod/Sounds/Item/Summon/SarosSpawn"); + public static SoundStyle LoopSound => SoundID.DD2_BetsyFlameBreath with { Volume = 0.2f }; public override void SetDefaults() { - Item.width = Item.height = 56; - Item.damage = 500; - Item.knockBack = 4f; + Item.width = 44; + Item.height = 48; + Item.damage = 66; Item.mana = 10; - - Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = Item.useTime = 10; - Item.DamageType = DamageClass.Summon; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; - Item.UseSound = SoundID.DD2_BetsyFlameBreath; - Item.rare = ModContent.RarityType(); - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.noMelee = true; + Item.knockBack = 1.15f; + Item.UseSound = null; + Item.buffType = ModContent.BuffType(); + Item.shoot = ModContent.ProjectileType(); + Item.DamageType = DamageClass.Summon; + Item.channel = true; + + Item.value = CalamityGlobalItem.RarityVioletBuyPrice; + Item.rare = ModContent.RarityType(); } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.maxMinions >= 8; + public override bool CanUseItem(Player player) + { + return player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - return false; + if (player.ownedProjectileCounts[type] > 0) + { + var p = Main.projectile.First(x => x.active && x.type == type && x.owner == player.whoAmI); + p.ai[0]++; + p.netUpdate = true; + + SoundEngine.PlaySound(SpawnSound with { MaxInstances = 10, SoundLimitBehavior = SoundLimitBehavior.IgnoreNew, pitchVariance = 0.05f, }, player.Center); + return false; + } else + { + player.channel = false; + } + player.AddBuff(Item.buffType, 2); + + SoundEngine.PlaySound(SpawnSound with { MaxInstances = 10, SoundLimitBehavior = SoundLimitBehavior.IgnoreNew, pitchVariance = 0.05f, }, player.Center); + return true; } public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(8). - AddIngredient(8). + AddIngredient(5). + AddIngredient(15). AddTile(). Register(); } diff --git a/Items/Weapons/Summon/ScabRipper.cs b/Items/Weapons/Summon/ScabRipper.cs index 74d18a268c..539d0a401b 100644 --- a/Items/Weapons/Summon/ScabRipper.cs +++ b/Items/Weapons/Summon/ScabRipper.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,9 +18,9 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 66; Item.height = 70; - Item.damage = 16; + Item.damage = 15; Item.mana = 10; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 0.5f; @@ -27,6 +28,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Green; Item.UseSound = SoundID.Item83; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; @@ -36,15 +38,9 @@ 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) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/SeashineHilt.cs b/Items/Weapons/Summon/SeashineHilt.cs new file mode 100644 index 0000000000..312100f28f --- /dev/null +++ b/Items/Weapons/Summon/SeashineHilt.cs @@ -0,0 +1,159 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.Dusts; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + [LegacyName("SeashineSword")] + public class SeashineHilt : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Summon"; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + } + public override void SetDefaults() + { + Item.width = 32; + Item.height = 34; + Item.useTime = Item.useAnimation = 36; + Item.damage = 55; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.autoReuse = true; + Item.useStyle = ItemUseStyleID.Shoot; + Item.DamageType = DamageClass.Summon; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.knockBack = 5f; + Item.shootSpeed = 12f; + Item.mana = 10; + Item.rare = ItemRarityID.Green; + Item.buffType = ModContent.BuffType(); + Item.shoot = ModContent.ProjectileType(); + } + public override bool AltFunctionUse(Player player) => true; + public override float UseSpeedMultiplier(Player player) + { + // There's a long cooldown on commanding blades + // This is so you don't just hold down right click, since now it's optimal to only command blades when all are ready + if (player.altFunctionUse == 2) + return 0.37f; + else + return 1f; + } + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + float usedMinionSlots = 0; + foreach (var minions in Main.ActiveProjectiles) + { + if (minions.owner == player.whoAmI) + usedMinionSlots += minions.minionSlots; + } + bool hasSlotsForSummon = true; + if (usedMinionSlots + 1 > player.maxMinions) + hasSlotsForSummon = false; + + + // Call all active blades to attack if they are charged + // The check to see if a blade is charged is done in the blade itself + if (player.altFunctionUse == 2) + { + int blades = 0; + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.type == Item.shoot && projectile.ai[0] < 5 && projectile.timeLeft < 90000 - 180) + { + projectile.ai[0] = 5; + blades++; + } + } + if (blades > 0) // If theres no blades, then don't do anything + { + for (int i = 0; i < 7; i++) + { + Dust dust = Dust.NewDustPerfect(player.Center, ModContent.DustType(), (velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(5f, 10f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.95f, 1.7f); + dust.color = Main.rand.NextBool() ? Color.Cyan : Color.DodgerBlue; + dust.noLightEmittence = true; + + Particle fx = new CustomSpark(player.Center, (velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(10f, 20f), "CalamityMod/Particles/Sparkle", false, (int)(Main.rand.Next(16, 26 + 1)), Main.rand.NextFloat(1.1f, 1.7f), Main.rand.NextBool() ? Color.Cyan : Color.DodgerBlue, new Vector2(0.5f, 1.1f), extraRotation: 0, shrinkSpeed: 0.2f); + GeneralParticleHandler.SpawnParticle(fx); + } + Particle e = new CustomSpark(player.Center, (velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(7f, 20f), "CalamityMod/Particles/WaterFoam", false, 14, Main.rand.NextFloat(0.15f, 0.25f) * 3, Main.rand.NextBool() ? Color.Cyan : Color.DodgerBlue, new Vector2(1f, 1f), true, false, shrinkSpeed: 0.4f); + GeneralParticleHandler.SpawnParticle(e); + SoundEngine.PlaySound(SoundID.Item101 with { Volume = 0.9f, Pitch = Main.rand.NextFloat(0.3f, 0.5f) }, player.Center); + } + } + else if (hasSlotsForSummon) // Toss out the summon + { + player.AddBuff(Item.buffType, 2); + SoundEngine.PlaySound(SoundID.Item1, player.Center); + + var minion = Projectile.NewProjectileDirect(source, player.Center, velocity, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; + + float angleMax = MathHelper.ToRadians(360f); + if (CalamityUtils.CountProjectiles(type) == 1) + angleMax = 0f; + float index = 1f; + if (player.ownedProjectileCounts[Item.shoot] > 30) + { + angleMax += MathHelper.ToRadians((player.ownedProjectileCounts[Item.shoot] - 30) * 2.5f); + } + angleMax = angleMax > MathHelper.ToRadians(360f) ? MathHelper.ToRadians(360f) : angleMax; // More intuative than using a min function + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == type && p.owner == player.whoAmI) + { + p.ai[2] = (index / CalamityUtils.CountProjectiles(type)) * angleMax - angleMax / 2f; + p.ai[1] = index; + p.netUpdate = true; + index++; + } + } + } + + + return false; + } + public override void UseItemFrame(Player player) // Player hand animation when you command the blades + { + if (player.altFunctionUse == 2) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.4f) + rotation += (-0.15f) * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(3). + AddIngredient(7). + AddIngredient(10). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/Summon/SeashineSword.png b/Items/Weapons/Summon/SeashineHilt.png similarity index 100% rename from Items/Weapons/Summon/SeashineSword.png rename to Items/Weapons/Summon/SeashineHilt.png diff --git a/Items/Weapons/Summon/SeashineSword.cs b/Items/Weapons/Summon/SeashineSword.cs deleted file mode 100644 index 3425ef6d93..0000000000 --- a/Items/Weapons/Summon/SeashineSword.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using CalamityMod.Dusts; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Summon -{ - public class SeashineSword : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; - } - public override void SetDefaults() - { - Item.width = 32; - Item.height = 34; - Item.useTime = 10; - Item.useAnimation = 10; - Item.damage = 55; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.autoReuse = true; - Item.useStyle = ItemUseStyleID.Shoot; - Item.DamageType = DamageClass.Summon; - Item.value = CalamityGlobalItem.RarityGreenBuyPrice; - Item.knockBack = 5f; - Item.shootSpeed = 12f; - Item.mana = 10; - Item.rare = ItemRarityID.Green; - Item.shoot = ModContent.ProjectileType(); - } - public override bool AltFunctionUse(Player player) => true; - public override float UseSpeedMultiplier(Player player) - { - // There's a long cooldown on commanding blades - // This is so you don't just hold down right click, since now it's optimal to only command blades when all are ready - if (player.altFunctionUse == 2) - return 0.1f; - else - return 1f; - } - public override void HoldItem(Player player) - { - player.Calamity().mouseWorldListener = true; - } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - // Call all active blades to attack if they are charged - // The check to see if a blade is charged is done in the blade itself - if (player.altFunctionUse == 2) - { - int blades = 0; - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active && projectile.type == Item.shoot && projectile.ai[0] < 5 && projectile.timeLeft < 90000 - 180) - { - projectile.ai[0] = 5; - blades++; - } - } - if (blades > 0) // If theres no blades, then don't do anything - { - for (int i = 0; i < 7; i++) - { - Dust dust = Dust.NewDustPerfect(player.Center, ModContent.DustType(), (velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(5f, 10f)); - dust.noGravity = false; - dust.scale = Main.rand.NextFloat(0.95f, 1.7f); - dust.color = Main.rand.NextBool() ? Color.Cyan : Color.DodgerBlue; - dust.noLightEmittence = true; - - Particle fx = new CustomSpark(player.Center, (velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(10f, 20f), "CalamityMod/Particles/Sparkle", false, (int)(Main.rand.Next(16, 26 + 1)), Main.rand.NextFloat(1.1f, 1.7f), Main.rand.NextBool() ? Color.Cyan : Color.DodgerBlue, new Vector2(0.5f, 1.1f), extraRotation: 0, shrinkSpeed: 0.2f); - GeneralParticleHandler.SpawnParticle(fx); - } - Particle e = new CustomSpark(player.Center, (velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(7f, 20f), "CalamityMod/Particles/WaterFoam", false, 14, Main.rand.NextFloat(0.15f, 0.25f) * 3, Main.rand.NextBool() ? Color.Cyan : Color.DodgerBlue, new Vector2(1f, 1f), true, false, shrinkSpeed: 0.4f); - GeneralParticleHandler.SpawnParticle(e); - SoundEngine.PlaySound(SoundID.Item101 with { Volume = 0.9f, Pitch = Main.rand.NextFloat(0.3f, 0.5f) }, player.Center); - } - } - else // Toss out the summon - { - SoundEngine.PlaySound(SoundID.Item1, player.Center); - - int pr = Projectile.NewProjectile(source, player.Center, velocity, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(pr)) - Main.projectile[pr].originalDamage = Item.damage; - - float angleMax = MathHelper.ToRadians(360f); - if (CalamityUtils.CountProjectiles(type) == 1) - angleMax = 0f; - float index = 1f; - if (player.ownedProjectileCounts[Item.shoot] > 30) - { - angleMax += MathHelper.ToRadians((player.ownedProjectileCounts[Item.shoot] - 30) * 2.5f); - } - angleMax = angleMax > MathHelper.ToRadians(360f) ? MathHelper.ToRadians(360f) : angleMax; // More intuative than using a min function - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.type == type && p.owner == player.whoAmI) - { - p.ai[2] = (index / CalamityUtils.CountProjectiles(type)) * angleMax - angleMax / 2f; - p.ai[1] = index; - p.netUpdate = true; - index++; - } - } - } - return false; - } - public override void UseItemFrame(Player player) // Player hand animation when you command the blades - { - if (player.altFunctionUse == 2) - { - player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); - - float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; - float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; - if (animProgress < 0.4f) - rotation += (-0.15f) * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction; - - player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); - } - } - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(3). - AddIngredient(7). - AddIngredient(10). - AddTile(TileID.Anvils). - Register(); - } - } -} diff --git a/Items/Weapons/Summon/ShellfishStaff.cs b/Items/Weapons/Summon/ShellfishStaff.cs index acfa24fee7..33f74c79fb 100644 --- a/Items/Weapons/Summon/ShellfishStaff.cs +++ b/Items/Weapons/Summon/ShellfishStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -19,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 50; Item.damage = 70; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; @@ -27,19 +28,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Pink; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/Sirius.cs b/Items/Weapons/Summon/Sirius.cs index deee425550..3b90737476 100644 --- a/Items/Weapons/Summon/Sirius.cs +++ b/Items/Weapons/Summon/Sirius.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; @@ -14,15 +15,16 @@ namespace CalamityMod.Items.Weapons.Summon { public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 6f; + public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 1f; public override void SetDefaults() { Item.width = Item.height = 62; - Item.damage = 600; - Item.useAnimation = Item.useTime = 10; + Item.damage = 150; + Item.useAnimation = Item.useTime = 24; Item.mana = 10; Item.knockBack = 10f; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; Item.useStyle = ItemUseStyleID.Swing; @@ -30,17 +32,33 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.noMelee = true; + Item.autoReuse = true; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.maxMinions >= 6; + public override bool CanUseItem(Player player) => true; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - return false; + if (player.ownedProjectileCounts[type] > 0) + { + Projectile sirius = null; + foreach (var item in Main.ActiveProjectiles) + { + if (item.type == type && item.owner == player.whoAmI) + { + if (item.type == type) + sirius = item; + } + } + if (sirius != null) + { + sirius.ai[1]++; + + } + return false; + } + else + return true; } public override void AddRecipes() @@ -50,7 +68,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(5). AddIngredient(2). AddIngredient(12). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Summon/SlimePuppetStaff.cs b/Items/Weapons/Summon/SlimePuppetStaff.cs index 96f57f7c7c..98dd09eb39 100644 --- a/Items/Weapons/Summon/SlimePuppetStaff.cs +++ b/Items/Weapons/Summon/SlimePuppetStaff.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.NPCs.SlimeGod; using CalamityMod.Projectiles.Summon; -using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -50,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Summon CreateRecipe(). AddIngredient(18). AddIngredient(18). - AddTile(). + AddTile(TileID.Solidifier). Register(); } } diff --git a/Items/Weapons/Summon/SpikecragStaff.cs b/Items/Weapons/Summon/SpikecragStaff.cs index d9eb1fdafa..70feda5470 100644 --- a/Items/Weapons/Summon/SpikecragStaff.cs +++ b/Items/Weapons/Summon/SpikecragStaff.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -19,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 10; Item.DamageType = DamageClass.Summon; Item.sentry = true; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 30; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; diff --git a/Items/Weapons/Summon/SquirrelSquireStaff.cs b/Items/Weapons/Summon/SquirrelSquireStaff.cs index 5ee42ced6e..f705751590 100644 --- a/Items/Weapons/Summon/SquirrelSquireStaff.cs +++ b/Items/Weapons/Summon/SquirrelSquireStaff.cs @@ -1,6 +1,5 @@ using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -28,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.shoot = ModContent.ProjectileType(); Item.knockBack = 0.5f; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 30; Item.mana = 10; Item.width = 46; Item.height = 52; @@ -48,23 +47,16 @@ namespace CalamityMod.Items.Weapons.Summon { // Find the base farthest position Vector2 initialSpawn = player.GetFarthestSpawnPositionOnLine(position, velocity.X, velocity.Y); + int dontLoopForever = 0; - // Push the squirrel away from collision in all directions if applicable - while (!Collision.CanHit(initialSpawn, 0, 0, initialSpawn + Vector2.UnitX * 20f, 0, 0) || + // Move the squirrel towards the player if the position does not have line of sight on all edges + while ((!Collision.CanHit(initialSpawn, 0, 0, initialSpawn + Vector2.UnitX * 20f, 0, 0) || !Collision.CanHit(initialSpawn, 0, 0, initialSpawn - Vector2.UnitX * 20f, 0, 0) || !Collision.CanHit(initialSpawn, 0, 0, initialSpawn + Vector2.UnitY * 24f, 0, 0) || - !Collision.CanHit(initialSpawn, 0, 0, initialSpawn - Vector2.UnitY * 24f, 0, 0)) + !Collision.CanHit(initialSpawn, 0, 0, initialSpawn - Vector2.UnitY * 24f, 0, 0)) && dontLoopForever < 200) { - if (!Collision.CanHit(initialSpawn, 0, 0, initialSpawn + Vector2.UnitX * 20f, 0, 0)) - initialSpawn.X -= 1f; - // Be sure to not infinite loop - if (!Collision.CanHit(initialSpawn, 0, 0, initialSpawn - Vector2.UnitX * 20f, 0, 0) && Collision.CanHit(initialSpawn, 0, 0, initialSpawn + Vector2.UnitX * 20f, 0, 0)) - initialSpawn.X += 1f; - if (!Collision.CanHit(initialSpawn, 0, 0, initialSpawn + Vector2.UnitY * 24f, 0, 0)) - initialSpawn.Y -= 1f; - // Be sure to not infinite loop - if (!Collision.CanHit(initialSpawn, 0, 0, initialSpawn - Vector2.UnitY * 24f, 0, 0) && Collision.CanHit(initialSpawn, 0, 0, initialSpawn + Vector2.UnitY * 24f, 0, 0)) - initialSpawn.Y += 1f; + initialSpawn = Vector2.Lerp(player.Center, initialSpawn, 0.99f); + dontLoopForever++; } Projectile.NewProjectile(source, initialSpawn, Vector2.Zero, type, damage, knockback, player.whoAmI); diff --git a/Items/Weapons/Summon/StaffOfNecrosteocytes.cs b/Items/Weapons/Summon/StaffOfNecrosteocytes.cs index 9bd042de78..46d99f5fd5 100644 --- a/Items/Weapons/Summon/StaffOfNecrosteocytes.cs +++ b/Items/Weapons/Summon/StaffOfNecrosteocytes.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 54; Item.damage = 31; Item.mana = 10; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 3.5f; @@ -24,22 +25,19 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Orange; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Point mouseTileCoords = position.ToTileCoordinates(); + player.AddBuff(Item.buffType, 2); + Point mouseTileCoords = player.ClampedMouseWorld().ToTileCoordinates(); if (WorldGen.SolidTile(mouseTileCoords.X, mouseTileCoords.Y)) return false; - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/StaffoftheMechworm.cs b/Items/Weapons/Summon/StaffoftheMechworm.cs deleted file mode 100644 index d6bee5eefe..0000000000 --- a/Items/Weapons/Summon/StaffoftheMechworm.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Linq; -using CalamityMod.Projectiles.Summon; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Summon -{ - public class StaffoftheMechworm : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetDefaults() - { - Item.width = 68; - Item.height = 68; - Item.damage = 100; - Item.mana = 10; - Item.useAnimation = Item.useTime = 10; // 9 because of useStyle 1 - Item.useStyle = ItemUseStyleID.Swing; - Item.noMelee = true; - Item.knockBack = 2f; - Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item113; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - Item.DamageType = DamageClass.Summon; - } - - public override bool CanUseItem(Player player) - { - float neededSlots = 1; - float foundSlotsCount = 0; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.minion && p.owner == player.whoAmI) - { - foundSlotsCount += p.minionSlots; - if (foundSlotsCount + neededSlots > player.maxMinions) - { - return false; - } - } - } - return true; - } - - public static void SummonBaseMechworm(IEntitySource source, int damage, int baseDamage, float knockback, Player owner, out int tailIndex) - { - tailIndex = -1; - if (Main.myPlayer != owner.whoAmI) - return; - - Vector2 mouse = owner.ClampedMouseWorld(); - - int curr = Projectile.NewProjectile(source, mouse, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, owner.whoAmI, 0f, 0f); - if (Main.projectile.IndexInRange(curr)) - Main.projectile[curr].originalDamage = baseDamage; - curr = Projectile.NewProjectile(source, mouse, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, owner.whoAmI, Main.projectile[curr].identity, 0f); - if (Main.projectile.IndexInRange(curr)) - Main.projectile[curr].originalDamage = baseDamage; - int prev = curr; - curr = Projectile.NewProjectile(source, mouse, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, owner.whoAmI, Main.projectile[curr].identity, 0f); - if (Main.projectile.IndexInRange(curr)) - Main.projectile[curr].originalDamage = baseDamage; - Main.projectile[prev].localAI[1] = curr; - prev = curr; - curr = Projectile.NewProjectile(source, mouse, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, owner.whoAmI, Main.projectile[curr].identity, 0f); - if (Main.projectile.IndexInRange(curr)) - Main.projectile[curr].originalDamage = baseDamage; - Main.projectile[prev].localAI[1] = curr; - - tailIndex = curr; - } - - public static void AddSegmentToMechworm(IEntitySource source, int tailIndex, int damage, int baseDamage, float knockback, Player owner) - { - if (Main.myPlayer != owner.whoAmI) - return; - - Vector2 spawnPosition = Main.projectile[tailIndex].Center; - Projectile tailAheadSegment = Main.projectile.Take(Main.maxProjectiles).FirstOrDefault(proj => MechwormBody.SameIdentity(proj, owner.whoAmI, (int)Main.projectile[tailIndex].ai[0])); - int body = Projectile.NewProjectile(source, spawnPosition, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, owner.whoAmI, tailAheadSegment.identity, 0f); - int body2 = body; - body = Projectile.NewProjectile(source, spawnPosition, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, owner.whoAmI, Main.projectile[body].identity, 0f); - - var m = Main.projectileIdentity; - Main.projectile[tailIndex].ai[0] = Main.projectile[body].identity; - Main.projectile[tailIndex].netUpdate = true; - if (Main.projectile.IndexInRange(body)) - Main.projectile[body].originalDamage = baseDamage; - if (Main.projectile.IndexInRange(body2)) - Main.projectile[body2].originalDamage = baseDamage; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - int head = -1; - int tail = -1; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.owner == Main.myPlayer) - { - if (head == -1 && p.type == ModContent.ProjectileType()) - { - head = p.whoAmI; - } - if (tail == -1 && p.type == ModContent.ProjectileType()) - { - tail = p.whoAmI; - } - if (head != -1 && tail != -1) - { - break; - } - } - } - if (head == -1 && tail == -1) - SummonBaseMechworm(source, damage, Item.damage, knockback, player, out _); - else if (head != -1 && tail != -1) - AddSegmentToMechworm(source, tail, damage, Item.damage, knockback, player); - return false; - } - } -} diff --git a/Items/Weapons/Summon/StarspawnHelixStaff.cs b/Items/Weapons/Summon/StarspawnHelixStaff.cs index 333bdf5ce4..da35a81f3f 100644 --- a/Items/Weapons/Summon/StarspawnHelixStaff.cs +++ b/Items/Weapons/Summon/StarspawnHelixStaff.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -19,8 +21,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.knockBack = 1.25f; Item.mana = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; Item.DamageType = DamageClass.Summon; Item.useStyle = ItemUseStyleID.Swing; Item.UseSound = SoundID.Item44; @@ -32,24 +35,19 @@ 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) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), velocity, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(p)) - { - Main.projectile[p].originalDamage = Item.damage; - Main.projectile[p].ModProjectile().ProbeIndex = player.ownedProjectileCounts[type]; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; + minion.ModProjectile().ProbeIndex = player.ownedProjectileCounts[type]; - int bladeIndex = 0; - foreach (Projectile pro in Main.ActiveProjectiles) + int bladeIndex = 0; + foreach (Projectile pro in Main.ActiveProjectiles) + { + if (pro.type == type && pro.owner == player.whoAmI) { - if (pro.type == type && pro.owner == player.whoAmI) - { - pro.ModProjectile().ProbeIndex = bladeIndex++; - pro.ModProjectile().AITimer = 0f; - pro.netUpdate = true; - } + pro.ModProjectile().ProbeIndex = bladeIndex++; + pro.ModProjectile().AITimer = 0f; + pro.netUpdate = true; } } diff --git a/Items/Weapons/Summon/StellarTorusStaff.cs b/Items/Weapons/Summon/StellarTorusStaff.cs index 2540e43a21..6dc2fda202 100644 --- a/Items/Weapons/Summon/StellarTorusStaff.cs +++ b/Items/Weapons/Summon/StellarTorusStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -26,9 +27,10 @@ namespace CalamityMod.Items.Weapons.Summon Item.width = 42; Item.height = 42; Item.damage = 142; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 24; Item.knockBack = 4f; Item.mana = 10; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.noMelee = true; @@ -43,11 +45,9 @@ 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) { - int minion = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(2f, 2f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); - - if (Main.projectile.IndexInRange(minion)) - Main.projectile[minion].originalDamage = Item.OriginalDamage; - + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2Circular(2f, 2f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); + minion.originalDamage = Item.OriginalDamage; return false; } @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(ItemID.XenoStaff). AddIngredient(ItemID.FragmentStardust, 6). AddIngredient(3). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Summon/StormjawStaff.cs b/Items/Weapons/Summon/StormjawStaff.cs index 53c47e8b77..118ad7d47d 100644 --- a/Items/Weapons/Summon/StormjawStaff.cs +++ b/Items/Weapons/Summon/StormjawStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Buffs.Summon; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -17,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 32; Item.damage = 11; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; @@ -25,19 +26,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Green; Item.UseSound = Stormlion.DeathSound; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Summon/SunSpiritStaff.cs b/Items/Weapons/Summon/SunSpiritStaff.cs index fa04a52417..9d5ac24f1d 100644 --- a/Items/Weapons/Summon/SunSpiritStaff.cs +++ b/Items/Weapons/Summon/SunSpiritStaff.cs @@ -1,4 +1,6 @@ -using CalamityMod.Items.Materials; +using System.Linq; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -15,28 +17,42 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 44; Item.height = 48; - Item.damage = 12; + Item.damage = 25; Item.mana = 10; - Item.useAnimation = Item.useTime = 35; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 1.15f; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; Item.UseSound = SoundID.Item44; - Item.shoot = ModContent.ProjectileType(); + Item.buffType = ModContent.BuffType(); + Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanUseItem(Player player) + { + float minionSlotsAvailable = player.maxMinions; + foreach (var item in Main.ActiveProjectiles) + { + if (item.owner == player.whoAmI) + minionSlotsAvailable -= item.minionSlots; + } + return minionSlotsAvailable >= 1; + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - return false; + if (player.ownedProjectileCounts[type] > 0) + { + var p = Main.projectile.First(x => x.active && x.type == type && x.owner == player.whoAmI); + p.ai[0]++; + p.netUpdate = true; + return false; + } + player.AddBuff(Item.buffType, 2); + return true; } public override void AddRecipes() diff --git a/Items/Weapons/Summon/TacticalPlagueEngine.cs b/Items/Weapons/Summon/TacticalPlagueEngine.cs index f29284f1c7..06b5521bd9 100644 --- a/Items/Weapons/Summon/TacticalPlagueEngine.cs +++ b/Items/Weapons/Summon/TacticalPlagueEngine.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -18,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 20; Item.damage = 140; Item.mana = 10; - Item.useAnimation = Item.useTime = 14; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 0.5f; @@ -27,18 +28,16 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.Item14; Item.autoReuse = true; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 7f; // Affects bullet speed } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; return false; } @@ -48,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(). AddIngredient(). AddIngredient(ItemID.LunarBar, 5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Summon/TemporalUmbrella.cs b/Items/Weapons/Summon/TemporalUmbrella.cs index 592dea16b1..30044336d3 100644 --- a/Items/Weapons/Summon/TemporalUmbrella.cs +++ b/Items/Weapons/Summon/TemporalUmbrella.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon.Umbrella; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -24,9 +25,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.damage = 193; Item.knockBack = 1f; Item.mana = 99; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.DamageType = DamageClass.Summon; - Item.shootSpeed = 0f; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.useStyle = ItemUseStyleID.Swing; @@ -41,10 +42,10 @@ 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectileMany(player, type, ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType()); - int p = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + var minion = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs b/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs index dcf2926b9a..5725ba1b3d 100644 --- a/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs +++ b/Items/Weapons/Summon/TundraFlameBlossomsStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -16,13 +17,14 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 60; Item.damage = 40; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 3f; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; Item.UseSound = SoundID.Item46; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; } @@ -31,6 +33,7 @@ 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(false, type, player); for (int i = 0; i < 3; i++) { diff --git a/Items/Weapons/Summon/UniverseSplitter.cs b/Items/Weapons/Summon/UniverseSplitter.cs index 89b2e15d82..6eb2272ea5 100644 --- a/Items/Weapons/Summon/UniverseSplitter.cs +++ b/Items/Weapons/Summon/UniverseSplitter.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.Items.SummonItems; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; @@ -58,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Summon for (int i = 0; i < 36; i++) { float angle = MathHelper.TwoPi / 36f * i + Main.rand.NextFloat(MathHelper.TwoPi / 36f); - Dust dust = Dust.NewDustPerfect(position + angle.ToRotationVector2() * ItemUseDustMaxRadius, 247); + Dust dust = Dust.NewDustPerfect(position + angle.ToRotationVector2() * ItemUseDustMaxRadius, DustID.PlatinumCoin); dust.velocity = Vector2.Normalize(angle.ToRotationVector2()) * 2.5f; dust.noGravity = true; dust.scale = 0.8f; @@ -75,6 +76,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void AddRecipes() { CreateRecipe(). + AddIngredient(). AddIngredient(). AddIngredient(5). AddTile(). diff --git a/Items/Weapons/Summon/VengefulSunStaff.cs b/Items/Weapons/Summon/VengefulSunStaff.cs index fc5250bf6d..7152f1617f 100644 --- a/Items/Weapons/Summon/VengefulSunStaff.cs +++ b/Items/Weapons/Summon/VengefulSunStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using System.Linq; +using CalamityMod.Buffs.Summon; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -16,35 +17,49 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 72; Item.height = 72; - Item.damage = 60; + Item.damage = 40; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 1.25f; Item.value = CalamityGlobalItem.RarityLightPurpleBuyPrice; Item.rare = ItemRarityID.LightPurple; Item.UseSound = SoundID.Item44; - Item.shoot = ModContent.ProjectileType(); + Item.buffType = ModContent.BuffType(); + Item.shoot = ModContent.ProjectileType(); Item.DamageType = DamageClass.Summon; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanUseItem(Player player) + { + float minionSlotsAvailable = player.maxMinions; + foreach (var item in Main.ActiveProjectiles) + { + if (item.owner == player.whoAmI) + minionSlotsAvailable -= item.minionSlots; + } + return minionSlotsAvailable >= 1; + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - CalamityUtils.KillShootProjectiles(true, type, player); - int p = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - return false; + if (player.ownedProjectileCounts[type] > 0) + { + var p = Main.projectile.First(x => x.active && x.type == type && x.owner == player.whoAmI); + p.ai[0]++; + p.netUpdate = true; + return false; + } + player.AddBuff(Item.buffType, 2); + return true; } public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(5). + AddIngredient(ItemID.MoonStone). AddIngredient(ItemID.SoulofFright, 3). AddIngredient(ItemID.SoulofMight, 3). AddIngredient(ItemID.SoulofSight, 3). diff --git a/Items/Weapons/Summon/Vigilance.cs b/Items/Weapons/Summon/Vigilance.cs index a1bb127949..ebd6932831 100644 --- a/Items/Weapons/Summon/Vigilance.cs +++ b/Items/Weapons/Summon/Vigilance.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; @@ -16,33 +18,28 @@ namespace CalamityMod.Items.Weapons.Summon Item.width = Item.height = 32; Item.damage = 115; Item.mana = 10; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 4f; Item.UseSound = SoundID.DD2_BetsySummon; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) + if (player.maxMinions - player.slotsMinions >= 1f) { - if (player.maxMinions - player.slotsMinions >= 1f) - { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - { - Main.projectile[p].ai[0] = player.ownedProjectileCounts[type]; - Main.projectile[p].originalDamage = Item.damage; - } - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.ai[0] = player.ownedProjectileCounts[type]; + minion.originalDamage = Item.damage; } return false; } diff --git a/Items/Weapons/Summon/VileFeeder.cs b/Items/Weapons/Summon/VileFeeder.cs index e584d973f4..1bd661c128 100644 --- a/Items/Weapons/Summon/VileFeeder.cs +++ b/Items/Weapons/Summon/VileFeeder.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,12 +18,13 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 40; Item.height = 36; - Item.damage = 14; + Item.damage = 15; Item.DamageType = DamageClass.Summon; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.knockBack = 0.5f; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 36; Item.mana = 10; Item.noMelee = true; Item.autoReuse = true; @@ -37,7 +39,9 @@ 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) { - Projectile.NewProjectile(source, player.ClampedMouseWorld(), Main.rand.NextVector2CircularEdge(5f, 5f), type, damage, knockback, player.whoAmI); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Main.rand.NextVector2CircularEdge(5f, 5f), type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } diff --git a/Items/Weapons/Summon/ViralSprout.cs b/Items/Weapons/Summon/ViralSprout.cs index 967ce92bd5..0fe8274228 100644 --- a/Items/Weapons/Summon/ViralSprout.cs +++ b/Items/Weapons/Summon/ViralSprout.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -15,9 +16,9 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 48; Item.height = 56; - Item.damage = 30; + Item.damage = 24; Item.mana = 10; - Item.useAnimation = Item.useTime = 19; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 2f; @@ -25,29 +26,26 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Lime; Item.UseSound = SoundID.Item44; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; + + int minionCount = 0; + foreach (Projectile pro in Main.ActiveProjectiles) { - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; + if (pro.type != type || pro.owner != player.whoAmI) + continue; - int minionCount = 0; - foreach (Projectile pro in Main.ActiveProjectiles) - { - if (pro.type != type || pro.owner != player.whoAmI) - continue; - - pro.localAI[0] = minionCount; - pro.netUpdate = true; - minionCount++; - } + pro.localAI[0] = minionCount; + pro.netUpdate = true; + minionCount++; } return false; } diff --git a/Items/Weapons/Summon/ViridVanguard.cs b/Items/Weapons/Summon/ViridVanguard.cs index 0da9bba37e..9cd7b0a4d1 100644 --- a/Items/Weapons/Summon/ViridVanguard.cs +++ b/Items/Weapons/Summon/ViridVanguard.cs @@ -1,9 +1,13 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; +using CalamityMod.Packets; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon @@ -11,21 +15,58 @@ namespace CalamityMod.Items.Weapons.Summon public class ViridVanguard : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - public const int HorizontalSlashChargeTime = 14; - public const float HorizontalSlashSpeed = 44f; + #region AI-Related Balancing Properties - public const int VerticalSlashChargeTime = 32; + public static float IdleCirclingSpeed => 0.0375f; + public static float AxeCirclingSpeedMultiplier => 3f; + public static float ActiveAttackCirclingSpeedMultiplier => 10f; - public const float VerticalSlashSpeed = 45f; + //The next three are the amount of times the sword does each attack before moving to the next one + public static int HorizontalSlashAmount => 7; + public static int VerticalPierceAmount => 5; + public static int StabAmount => 6; + /// + /// How long the player must wait after an active ends to start the next one + /// + public static int ActiveAttackCooldown => 300; + public static int ActiveAttackStartup => 90; + public static int ActiveAttackEndlag => 30; + /// + /// How many slashes each vanguard will do during the active + /// + public static int ActiveAttackSlashCount => 4; + #endregion + #region Damage Balancing Properties - public const float VerticalTeleportOffset = 850f; - public const int PierceChargeAttackCycleTime = 44; + //Sage Poison's damage is kept in the Sage Poison file + public static float ActiveAttackSlashDmgMult => 5f; - public const float MaxTargetingDistance = 1550f; + //Note: the following two only apply when not using the active attack + public static float AxeDmgMult => 1.25f; + public static float SwordDmgMult => 1f; + #endregion - public const int ChargesPerAttackCycle = 7; + private static Texture2D BladeOutline = null; + public static Texture2D GetBladeOutlineTex() + { + if (BladeOutline == null) + { + var texture = ModContent.Request("CalamityMod/Projectiles/Summon/ViridVanguardBlade").Value; + BladeOutline = new Texture2D(Main.graphics.GraphicsDevice, texture.Width, texture.Height); + + var BaseArray = new Color[BladeOutline.Width * BladeOutline.Height]; + var ColorArray = new Color[BladeOutline.Width * BladeOutline.Height]; + texture.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + BladeOutline.SetData(ColorArray); + } + return BladeOutline; + } public override void SetStaticDefaults() { @@ -36,10 +77,10 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 26; Item.height = 36; - Item.damage = 73; + Item.damage = 60; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.useAnimation = Item.useTime = 14; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 5f; @@ -47,20 +88,69 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Red; Item.UseSound = SoundID.Item71; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); Item.rare = ModContent.RarityType(); } + public override bool CanRightClick() + { + if (!Main.keyState.PressingShift()) + return false; + return true; + } + public override void RightClick(Player player) + { + Main.LocalPlayer.Calamity().InvertExaltationLineRotationDirections = !Main.LocalPlayer.Calamity().InvertExaltationLineRotationDirections; + if (Main.netMode != NetmodeID.SinglePlayer) + ExaltationDirectionSyncPacket.Send(Main.LocalPlayer.Calamity()); + } + + public override bool ConsumeItem(Player player) => false; + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + var tex = TextureAssets.Item[Type].Value; + CalamityUtils.DrawInventoryCustomScale( + spriteBatch, + tex, + position, + frame, + drawColor, + itemColor, + origin, + scale, + wantedScale: 0.9f, + spriteEffects: Main.LocalPlayer.Calamity().InvertExaltationLineRotationDirections ? SpriteEffects.FlipHorizontally : SpriteEffects.None + ); + return false; + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) + float totalSlots = 0f; + foreach (Projectile p in Main.ActiveProjectiles) { - int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(p)) + if (p.minion && p.owner == player.whoAmI) { - Main.projectile[p].originalDamage = Item.damage; - Main.projectile[p].ModProjectile().BladeIndex = player.ownedProjectileCounts[type]; + totalSlots += p.minionSlots; } + } + if (totalSlots >= player.maxMinions) + { + foreach (Projectile pro in Main.ActiveProjectiles) + { + if (pro.type == type && pro.owner == player.whoAmI && pro.ModProjectile().ActiveTimer == 0) + { + pro.ModProjectile().BeginSuperEpicPhotonRipperZenithKnockoffAttack(); + } + } + } + else + { + player.AddBuff(Item.buffType, 2); + + var minion = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.ModProjectile().BladeIndex = player.ownedProjectileCounts[type]; int bladeIndex = 0; foreach (Projectile pro in Main.ActiveProjectiles) @@ -68,20 +158,23 @@ namespace CalamityMod.Items.Weapons.Summon if (pro.type == type && pro.owner == player.whoAmI) { pro.ModProjectile().BladeIndex = bladeIndex++; + pro.ModProjectile().ActiveTimer = ViridVanguard.ActiveAttackCooldown; pro.ModProjectile().AITimer = 0f; pro.netUpdate = true; } } } - return false; } public override void AddRecipes() { CreateRecipe(). + AddIngredient(). + AddIngredient(). AddIngredient(15). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } + } diff --git a/Items/Weapons/Summon/VoidConcentrationStaff.cs b/Items/Weapons/Summon/VoidConcentrationStaff.cs index 332e3bc54d..5fa54ffc7a 100644 --- a/Items/Weapons/Summon/VoidConcentrationStaff.cs +++ b/Items/Weapons/Summon/VoidConcentrationStaff.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; @@ -13,7 +14,10 @@ namespace CalamityMod.Items.Weapons.Summon { public new string LocalizationCategory => "Items.Weapons.Summon"; - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 3f; + public override void SetStaticDefaults() + { + ItemID.Sets.StaffMinionSlotsRequired[Type] = 3f; + } public override void SetDefaults() { @@ -26,9 +30,9 @@ namespace CalamityMod.Items.Weapons.Summon Item.mana = 10; Item.damage = 105; Item.knockBack = 4f; - Item.useAnimation = Item.useTime = 15; // 14 because of useStyle 1 + Item.useAnimation = Item.useTime = 24; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); } @@ -44,10 +48,9 @@ namespace CalamityMod.Items.Weapons.Summon { if (player.altFunctionUse != 2) { - int p = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = Item.damage; - player.AddBuff(ModContent.BuffType(), 120); + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; } return false; } diff --git a/Items/Weapons/Summon/VoidEaterMarionette.cs b/Items/Weapons/Summon/VoidEaterMarionette.cs new file mode 100644 index 0000000000..4bfb783090 --- /dev/null +++ b/Items/Weapons/Summon/VoidEaterMarionette.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + [LegacyName("StaffoftheMechworm")] + public class VoidEaterMarionette : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Summon"; + + public bool FocusFetch = false; + + public override void ModifyTooltips(List tooltips) + { + tooltips.FindAndReplaceAll("ff00ff", Utils.Hex3(DevourerofGodsHead.SpecialMoveColor)); + } + public override void SetDefaults() + { + Item.width = 68; + Item.height = 68; + Item.damage = 110; + Item.mana = 10; + Item.useAnimation = Item.useTime = 24; + Item.useStyle = ItemUseStyleID.Swing; + Item.noMelee = true; + Item.knockBack = 2f; + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + Item.UseSound = SoundID.Item113; + Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); + Item.shoot = ModContent.ProjectileType(); + Item.DamageType = DamageClass.Summon; + Item.shootSpeed = 8; + } + public override bool CanRightClick() + { + if (!Main.keyState.PressingShift()) + return false; + return true; + } + public override void RightClick(Player player) + { + if (player.ownedProjectileCounts[Item.shoot] > 0) + { + var p = Main.projectile.First(x => x.active && x.type == Item.shoot && x.owner == player.whoAmI); + p.ModProjectile().FocusOnFetching = !p.ModProjectile().FocusOnFetching; + p.netUpdate = true; + } + } + public override bool ConsumeItem(Player player) => false; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.ownedProjectileCounts[type] > 0) + { + var p = Main.projectile.First(x => x.active && x.type == type && x.owner == player.whoAmI); + p.ai[0]++; + p.netUpdate = true; + return false; + } + position = Main.MouseWorld; + var worm = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI,2); + Projectile.NewProjectile(source, position, Vector2.Zero, ModContent.ProjectileType(), 0, 0, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Summon/StaffoftheMechworm.png b/Items/Weapons/Summon/VoidEaterMarionette.png similarity index 100% rename from Items/Weapons/Summon/StaffoftheMechworm.png rename to Items/Weapons/Summon/VoidEaterMarionette.png diff --git a/Items/Weapons/Summon/WarloksMoonFist.cs b/Items/Weapons/Summon/WarloksMoonFist.cs index b346171917..1adfc5491b 100644 --- a/Items/Weapons/Summon/WarloksMoonFist.cs +++ b/Items/Weapons/Summon/WarloksMoonFist.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; @@ -25,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 50; Item.damage = 450; Item.mana = 10; - Item.useAnimation = Item.useTime = 25; + Item.useAnimation = Item.useTime = 24; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 2f; @@ -35,24 +36,19 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.Item104; Item.autoReuse = true; Item.noUseGraphic = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; Item.Calamity().donorItem = true; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - int existingFists = player.ownedProjectileCounts[type]; - int p = Projectile.NewProjectile(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(p)) - { - Main.projectile[p].originalDamage = Item.damage; - Main.projectile[p].ai[0] = existingFists; - } - } + player.AddBuff(Item.buffType, 2); + int existingFists = player.ownedProjectileCounts[type]; + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; + minion.ai[0] = existingFists; return false; } @@ -63,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(10). AddIngredient(5). AddIngredient(5). - AddTile(TileID.LunarCraftingStation). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Summon/WitherBlossomsStaff.cs b/Items/Weapons/Summon/WitherBlossomsStaff.cs index e4ff0d39fd..f636b50101 100644 --- a/Items/Weapons/Summon/WitherBlossomsStaff.cs +++ b/Items/Weapons/Summon/WitherBlossomsStaff.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Materials; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; @@ -20,15 +21,15 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 60; Item.damage = 50; Item.mana = 10; - Item.useAnimation = Item.useTime = 20; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; Item.knockBack = 3f; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.UseSound = SoundID.Item46; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } @@ -36,6 +37,7 @@ 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) { + player.AddBuff(Item.buffType, 2); CalamityUtils.KillShootProjectiles(false, type, player); for (int i = 0; i < 4; i++) { diff --git a/Items/Weapons/Summon/WulfrumController.cs b/Items/Weapons/Summon/WulfrumController.cs index 8aae13745f..5d433d0621 100644 --- a/Items/Weapons/Summon/WulfrumController.cs +++ b/Items/Weapons/Summon/WulfrumController.cs @@ -1,4 +1,4 @@ -using System; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.height = 20; Item.damage = 16; Item.mana = 10; - Item.useAnimation = Item.useTime = 34; + Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; Item.knockBack = 0.5f; @@ -27,8 +27,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.rare = ItemRarityID.Blue; Item.UseSound = SoundID.Item15; //phaseblade sound effect Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; Item.DamageType = DamageClass.Summon; } @@ -40,22 +40,16 @@ 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) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - velocity.X = 0; - velocity.Y = 0; - int droid = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); - if (Main.projectile.IndexInRange(droid)) - Main.projectile[droid].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.originalDamage = Item.damage; return false; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(9). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } @@ -94,7 +88,7 @@ namespace CalamityMod.Items.Weapons.Summon { Vector2 dustPos = Player.position + (Player.height * Main.rand.NextFloat(0.7f, 1f) + Player.gfxOffY) * Vector2.UnitY + Vector2.UnitX * Main.rand.NextFloat() * Player.width; - Dust chust = Dust.NewDustPerfect(dustPos, 274, -Vector2.UnitY * Main.rand.NextFloat(1.4f, 7f) + Player.velocity, Alpha: 100, Scale: Main.rand.NextFloat(1.2f, 1.8f)); + Dust chust = Dust.NewDustPerfect(dustPos, DustID.ApprenticeStorm, -Vector2.UnitY * Main.rand.NextFloat(1.4f, 7f) + Player.velocity, Alpha: 100, Scale: Main.rand.NextFloat(1.2f, 1.8f)); chust.noGravity = true; chust.noLight = true; } diff --git a/Items/Weapons/Summon/YharonsKindleStaff.cs b/Items/Weapons/Summon/YharonsKindleStaff.cs index dc09c1c246..33c5fc3603 100644 --- a/Items/Weapons/Summon/YharonsKindleStaff.cs +++ b/Items/Weapons/Summon/YharonsKindleStaff.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using CalamityMod.Sounds; using Microsoft.Xna.Framework; @@ -15,36 +17,35 @@ namespace CalamityMod.Items.Weapons.Summon public new string LocalizationCategory => "Items.Weapons.Summon"; public const float ReboundRamDamageFactor = 2f; - public override void SetStaticDefaults() => ItemID.Sets.StaffMinionSlotsRequired[Type] = 5f; + public override void SetStaticDefaults() + { + ItemID.Sets.StaffMinionSlotsRequired[Type] = 5f; + } public override void SetDefaults() { Item.width = 80; Item.height = 74; Item.damage = 325; + Item.DamageType = DamageClass.Summon; Item.mana = 10; Item.useStyle = ItemUseStyleID.Swing; - Item.useAnimation = Item.useTime = 10; + Item.useAnimation = Item.useTime = 24; Item.noMelee = true; Item.knockBack = 7f; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.rare = ModContent.RarityType(); + Item.rare = ModContent.RarityType(); Item.UseSound = CommonCalamitySounds.FlareSound; Item.autoReuse = true; + Item.buffType = ModContent.BuffType(); Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; - Item.DamageType = DamageClass.Summon; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse != 2) - { - position = player.ClampedMouseWorld(); - int dragon = Projectile.NewProjectile(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - if (Main.projectile.IndexInRange(dragon)) - Main.projectile[dragon].originalDamage = Item.damage; - } + player.AddBuff(Item.buffType, 2); + var minion = Projectile.NewProjectileDirect(source, player.ClampedMouseWorld(), Vector2.Zero, type, damage, knockback, player.whoAmI); + minion.originalDamage = Item.damage; return false; } } diff --git a/Items/Weapons/Typeless/ClaretCannon.cs b/Items/Weapons/Typeless/ClaretCannon.cs new file mode 100644 index 0000000000..655a33eefa --- /dev/null +++ b/Items/Weapons/Typeless/ClaretCannon.cs @@ -0,0 +1,109 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; +using System; + +namespace CalamityMod.Items.Weapons.Typeless +{ + public class ClaretCannon : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Typeless"; + + public int ClaretCooldown = 0; + + public static int ClaretCooldownMax = 600; + + public float baseUseDir = 0; + public override void SetDefaults() + { + Item.width = 48; + Item.height = 30; + Item.damage = 500; + Item.DamageType = AverageDamageClass.Instance; + Item.useTime = 10; + Item.useAnimation = 10; + Item.useLimitPerAnimation = 1; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 5.5f; + Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + Item.rare = ModContent.RarityType(); + Item.UseSound = SoundID.Item40; + Item.autoReuse = true; + Item.shootSpeed = 12f; + Item.shoot = ModContent.ProjectileType(); + } + + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); + + public override void UpdateInventory(Player player) + { + ClaretCooldown--; + if (ClaretCooldown < 0) + ClaretCooldown = 0; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.MythrilAnvil). + Register(); + } + + public override bool CanUseItem(Player player) + { + if (ClaretCooldown > 0) + return false; + return true; + } + + public override void UseAnimation(Player player) + { + } + + public override void UseItemFrame(Player player) + { + float comp = 1 - player.itemTime / (float)player.itemTimeMax; + float lerpValue1 = MathHelper.Lerp(0, 90, MathF.Pow(comp, 0.3f)); + float lerpValue2 = MathHelper.Lerp(90, 0, MathF.Pow(comp, 2)); + player.itemRotation = baseUseDir - MathHelper.ToRadians(Math.Min(lerpValue1, lerpValue2)) * player.direction; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + baseUseDir = player.itemRotation; + ClaretCooldown = ClaretCooldownMax; + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + return false; + } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + float fill = ClaretCooldown / (float)ClaretCooldownMax; + if (fill <= 0) + return; + + float barScale = 1.5f; + + var barBG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; + var barFG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; + + Vector2 barOrigin = barBG.Size() * 0.5f; + float yOffset = 5f; + Vector2 drawPos = position + Vector2.UnitY * scale * (frame.Height - yOffset); + Rectangle frameCrop = new Rectangle(0, 0, (int)((fill) * barFG.Width), barFG.Height); + Color colorBG = Color.Crimson; + Color colorFG = Color.Lerp(Color.OrangeRed, Color.DarkOrange, fill); + + spriteBatch.Draw(barBG, drawPos, null, colorBG, 0f, barOrigin, scale * barScale, 0f, 0f); + spriteBatch.Draw(barFG, drawPos, frameCrop, colorFG, 0f, barOrigin, scale * barScale, 0f, 0f); + } + + } +} diff --git a/Items/Weapons/Ranged/ClaretCannon.png b/Items/Weapons/Typeless/ClaretCannon.png similarity index 100% rename from Items/Weapons/Ranged/ClaretCannon.png rename to Items/Weapons/Typeless/ClaretCannon.png diff --git a/Items/Weapons/Typeless/ColdheartIcicle.cs b/Items/Weapons/Typeless/ColdheartIcicle.cs new file mode 100644 index 0000000000..8d09e32d98 --- /dev/null +++ b/Items/Weapons/Typeless/ColdheartIcicle.cs @@ -0,0 +1,114 @@ +using CalamityMod.NPCs.Other; +using CalamityMod.Particles; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Typeless +{ + [LegacyName("AlicornonaStick")] + public class ColdheartIcicle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Typeless"; + public override void SetDefaults() + { + Item.width = 42; + Item.height = 50; + Item.holdStyle = 6; + Item.value = 0; + Item.rare = ModContent.RarityType(); + } + + public override void HoldStyle(Player player, Rectangle heldItemFrame) + { + player.itemRotation = player.direction == -1 ? -MathHelper.PiOver4 : MathHelper.PiOver4; + player.itemLocation = player.GetBackHandPosition(Player.CompositeArmStretchAmount.Full, player.direction * MathHelper.PiOver4) + Vector2.UnitX * player.direction * 14; + } + + public override void HoldItemFrame(Player player) + { + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, -player.direction * MathHelper.PiOver4); + } + + public override void HoldItem(Player player) + { + 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.ActiveNPCs) + { + if (!npc.dontTakeDamage && npc.type != ModContent.NPCType()) + { + if (itemRect.Intersects(npc.getRect())) + { + int damage = npc.SimpleStrikeNPC((int)(npc.lifeMax / 200), player.direction, true); + SoundEngine.PlaySound(Projectiles.Summon.CnidarianJellyfishOnTheString.SlapSound with { Volume = 2, MaxInstances = 200 }, npc.Center); + if (!Main.dedServ) + { + BloodShed(itemRect, npc, damage, player); + } + } + } + } + } + + public void BloodShed(Rectangle hitBox, NPC target, int damage, Player player) + { + // this is violence but exaggerated + float damageInterpolant = Utils.GetLerpValue(950f, 2000f, damage, true); + + Vector2 impactPoint = Vector2.Lerp(hitBox.Center.ToVector2(), target.Center, 0.65f); + Vector2 bloodSpawnPosition = target.Center + Main.rand.NextVector2Circular(target.width, target.height) * 0.04f; + Vector2 splatterDirection = (new Vector2(bloodSpawnPosition.X * player.direction, bloodSpawnPosition.Y)).SafeNormalize(Vector2.UnitY); + + // Emit blood if the target is organic. + if (target.Organic()) + { + for (int i = 0; i < 16; i++) + { + int bloodLifetime = Main.rand.Next(22, 36); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); + bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); + + if (Main.rand.NextBool(20)) + bloodScale *= 2f; + + Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.81f) * Main.rand.NextFloat(11f, 23f); + bloodVelocity.Y -= 12f; + BloodParticle blood = new BloodParticle(bloodSpawnPosition, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + for (int i = 0; i < 9; i++) + { + float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); + Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.9f) * Main.rand.NextFloat(9f, 14.5f); + BloodParticle2 blood = new BloodParticle2(bloodSpawnPosition, bloodVelocity, 20, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + } + + // Emit sparks if the target is not organic. + else + { + for (int i = 0; i < 16; i++) + { + int sparkLifetime = Main.rand.Next(22, 36); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) + damageInterpolant * 0.85f; + Color sparkColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.Orange, Main.rand.NextFloat()); + + if (Main.rand.NextBool(10)) + sparkScale *= 2f; + + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); + sparkVelocity.Y -= 6f; + SparkParticle spark = new SparkParticle(impactPoint, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + } +} diff --git a/Items/Weapons/Typeless/ColdheartIcicle.png b/Items/Weapons/Typeless/ColdheartIcicle.png new file mode 100644 index 0000000000..a8efd6e769 Binary files /dev/null and b/Items/Weapons/Typeless/ColdheartIcicle.png differ diff --git a/Items/Weapons/Typeless/LunicEye.cs b/Items/Weapons/Typeless/LunicEye.cs index 872d2e4d6a..bfc0f7aa08 100644 --- a/Items/Weapons/Typeless/LunicEye.cs +++ b/Items/Weapons/Typeless/LunicEye.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Typeless { public new string LocalizationCategory => "Items.Weapons.Typeless"; - public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/LunicShot", 2) { PitchVariance = 0.1f }; + public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/LunicShot", 2) { Volume = 0.8f, PitchVariance = 0.1f }; public static readonly SoundStyle ImpactSound = new("CalamityMod/Sounds/Item/LunicImpact") { PitchVariance = 0.1f }; public override void SetDefaults() diff --git a/Items/Weapons/Typeless/Skynamite.cs b/Items/Weapons/Typeless/Skynamite.cs index 4b58acd186..3442373d04 100644 --- a/Items/Weapons/Typeless/Skynamite.cs +++ b/Items/Weapons/Typeless/Skynamite.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Typeless; +using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Typeless Item.noMelee = true; Item.noUseGraphic = true; Item.UseSound = SoundID.Item1; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice / 10; // Crafted 10 at a time - Item.rare = ItemRarityID.Orange; + Item.value = Item.sellPrice(silver: 4); // Identical to Dynamite + Item.rare = ItemRarityID.Blue; } public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) diff --git a/Items/Weapons/Typeless/StarStruckWater.cs b/Items/Weapons/Typeless/StarStruckWater.cs index 13499cb0f5..b2e8980739 100644 --- a/Items/Weapons/Typeless/StarStruckWater.cs +++ b/Items/Weapons/Typeless/StarStruckWater.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Typeless Item.useTime = 15; Item.noUseGraphic = true; Item.noMelee = true; - Item.value = 200; + Item.value = Item.sellPrice(copper: 40); // Identical to Holy Water } public override void AddRecipes() diff --git a/Items/Weapons/Typeless/StratusSphere.cs b/Items/Weapons/Typeless/StratusSphere.cs new file mode 100644 index 0000000000..5f57fda8ce --- /dev/null +++ b/Items/Weapons/Typeless/StratusSphere.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Typeless +{ + public class StratusSphere : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Typeless"; + public static readonly SoundStyle CastSound = new SoundStyle("CalamityMod/Sounds/Item/StratusSphereCast") with { Volume = 0.75f }; + + public override void SetDefaults() + { + Item.width = 48; + Item.height = 30; + Item.damage = 400; + Item.DamageType = AverageDamageClass.Instance; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useLimitPerAnimation = 1; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 5.5f; + Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + Item.rare = ModContent.RarityType(); + Item.UseSound = CastSound; + Item.autoReuse = true; + Item.shootSpeed = 20f; + Item.shoot = ModContent.ProjectileType(); + Item.noUseGraphic = true; + } + + public override bool AltFunctionUse(Player player) + { + return true; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.NebulaArcanum). + AddIngredient(6). + AddIngredient(4). + AddIngredient(12). + AddTile(TileID.MythrilAnvil). + Register(); + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + List holes = new(); + foreach (var item in Main.ActiveProjectiles) + { + if (item.type == type && item.owner == player.whoAmI && item.timeLeft > 30) + { + holes.Add(item); + } + } + var orderedholes = holes.OrderBy(x => x.timeLeft).ToList(); + while (orderedholes.Count >= 1) + { + orderedholes.First().timeLeft = 30; + orderedholes.Remove(orderedholes.First()); + } + if (player.altFunctionUse == 2) + { + if (player.Calamity().Starshield > 45) + { + player.Calamity().Starshield = 30; + } + else + player.Calamity().Starshield = CalamityUtils.MinutesToFrames(10); + } + else + { + + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + player.Calamity().Starshield = (int)MathHelper.Min(30,player.Calamity().Starshield); + } + return false; + } + + } +} diff --git a/Items/Weapons/Typeless/StratusSphere.png b/Items/Weapons/Typeless/StratusSphere.png new file mode 100644 index 0000000000..b26cd057fc Binary files /dev/null and b/Items/Weapons/Typeless/StratusSphere.png differ diff --git a/Items/Weapons/Typeless/YanmeisKnife.cs b/Items/Weapons/Typeless/YanmeisKnife.cs deleted file mode 100644 index 9aa8579d24..0000000000 --- a/Items/Weapons/Typeless/YanmeisKnife.cs +++ /dev/null @@ -1,76 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Typeless -{ - public class YanmeisKnife : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Typeless"; - public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/Item/YanmeiKnifeHit"); - public static readonly SoundStyle ExpireSound = new("CalamityMod/Sounds/Custom/YanmeiKnifeExpire"); - - public static int DebuffDuration = 600; - public static int DebuffDoT = 250; - public static float DebuffDamageReductionMult = 0.8f; - public static float DebuffNPCSpeedCap = 16f; - - public static int BoostDuration = 600; - public static float RunSpeedBoost = 0.15f; - public static float RunAccelerationBoost = 0.15f; - public static float DamageBoost = 0.15f; // All 15% so we only need just one in the tooltip -- Same for the respective buff - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RunSpeedBoost.ToPercent(), BoostDuration.FramesToSeconds()); - - public override void SetDefaults() - { - Item.width = 48; - Item.height = 44; - Item.damage = 8; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.useAnimation = Item.useTime = 32; - Item.useStyle = ItemUseStyleID.Shoot; - Item.knockBack = 4.5f; - Item.autoReuse = false; - Item.value = CalamityGlobalItem.RarityYellowBuyPrice; - Item.rare = ItemRarityID.Yellow; - Item.Calamity().donorItem = true; - Item.UseSound = SoundID.Item71; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 24f; - } - - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) - { - itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.ClasslessWeapon; - } - - // Terraria seems to really dislike high crit values in SetDefaults - public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6; - - public override bool CanUseItem(Player player) - { - if (player.Calamity().KameiBladeUseDelay > 0) - return false; - return base.CanUseItem(player); - } - - public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) => player.Calamity().KameiBladeUseDelay = 180; - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(ItemID.PsychoKnife). - AddIngredient(ItemID.Obsidian, 10). - AddRecipeGroup("IronBar", 20). - AddIngredient(50). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/Typeless/YanmeisKnife.png b/Items/Weapons/Typeless/YanmeisKnife.png deleted file mode 100644 index b7f214f8f4..0000000000 Binary files a/Items/Weapons/Typeless/YanmeisKnife.png and /dev/null differ diff --git a/Localization/en-US/Mods.CalamityMod.Attunement.hjson b/Localization/en-US/Mods.CalamityMod.Attunement.hjson index a694250087..bb971a8498 100644 --- a/Localization/en-US/Mods.CalamityMod.Attunement.hjson +++ b/Localization/en-US/Mods.CalamityMod.Attunement.hjson @@ -138,7 +138,7 @@ PhoenixAttunement: { Swing the sword around you, accelerating over time The swirling nebula constantly emits homing cosmic bolts Release to hurl the sword toward the cursor alongside 6 gigantic cosmic bolts - The hurled sword erupts into a blazing flame pillar on enemy hits + The hurled sword erupts into a blazing tornado on enemy hits ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson index 269038422a..1b8d3e82f5 100644 --- a/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Bestiary.Vanilla.hjson @@ -1,7 +1,7 @@ // Put their internal name here NPCName: { - Guide: Once tasked with shepherding the Wall of Flesh, the Guide is a godlike figure in Demon folklore. However, the former warlock apprentice now savors a humble life, mentoring adventurers with his sharp intuition. - Dryad: Dryads practice the art of Life Magic, pioneered by Silva. She is connected with nature and can analyze its purity worldwide. She sells seeds, too! + Guide: Once tasked with shepherding the Wall of Flesh, the Guide is a godlike figure in Demon folklore. However, the former warlock apprentice now savors a humble life, offering useful advice and crafting recipes. + Dryad: The Dryad practices the art of Life Magic, pioneered by Silva. She is connected with nature and can analyze its purity worldwide. She sells seeds, too! Mechanic: The Mechanic was imprisoned for sticking her nose where she shouldn't. She sells wiring and tools for putting together anything imaginable. EmpressButterfly: These familiars conjured by the Empress draw power from their surroundings and later bring it to their master. They remind her of a lost loved one, and should one perish in the chaos of night, she shall unleash her full fury upon the attacker. DemonEye: "{$CommonEntries.DemonEye}" @@ -56,13 +56,12 @@ NPCName: { RaggedCaster: "{$CommonEntries.RaggedCaster}" RaggedCasterOpenCoat: "{$CommonEntries.RaggedCaster}" DungeonGuardian: The Old Man is cursed to never leave nor enter the Dungeon, much less die. Whoever crosses paths with him and dares to descend into those halls shall not pass! - BoneSerpentHead: Mighty serpentine beasts ruled hell since before history, later led by the exiled Flame Dragon. For said alliance, their obsidian scales were turned to Ash shortly after his demise. Now their skeletal husks remain, forced to protect the demonic territory using stolen Azafurian spells. + BoneSerpentHead: Mighty serpentine beasts ruled hell since before history, but after the demise of their liege, godly wrath had their obsidian scales immolated. Now only their skeletal husks remain, forced by stolen spells to protect demonic territory. Demon: Despite being a primitive civilization, demons populate most of the underworld. Unlike their lesser brothers, they cast shadow magic rather than hell magic. - VoodooDemon: Demons have several religious practices, specially sacrifices. They worship the Wall of Flesh ever since it started roaming the underworld, using offerings to draw it closer. - RedDevil: Conjuring potent spears of dark magic, these elite demons look after the adventurer that destroyed their perceived deity. + VoodooDemon: Demons have several religious practices, especially sacrifices. They worship the Wall of Flesh ever since it started roaming the underworld, using offerings to draw it closer. + RedDevil: Conjuring potent spears of dark magic, these elite demons hunt after the adventurer that destroyed their perceived deity. WyvernHead: Deeply in tune with the magic of the world, these serpentine dragons guard the skyward ruins of Chrysadia on behalf of the Storm Dragon. Now, their duty calls louder as divine essence surges through the land. - Harpy: Winged, demi-human creatures from distant southward mountains who came to inhabit Chrysadia after its tragic downfall. They defend their new territory fiercely against invaders with their razor-sharp feathers. - Scutlix: One of the few creatures left in the Martian homeworld, these creatures function similarly to horses. That is, if horses could fire lasers from their eyes. + Harpy: Winged, demi-human creatures from distant southward mountains who came to inhabit the sky archipelago after the ruin of its old civilization. They defend their new territory fiercely against invaders with their razor-sharp feathers. MartianProbe: Sensing growing power on the planet, otherworldly beings send space-age technology to scan for valuable resources. SeekerHead: Godly magicks have unleashed the dark influences that gave birth to the Eater of Worlds, producing smaller, but just as deadly worms. DesertDjinn: Buried in these caves lie cryptic artifacts older than Ilmeris, their origins swept away by the sands of time. Corrupted by divine magicks, the once friendly djinns within them now reemerge, full of hostility. @@ -73,7 +72,7 @@ NPCName: { PirateCaptain: A pirate captain's love for riches is only rivaled by his desire to explore! Word that the Crusade had seemingly ended spread fast across the world, and abundances to plunder in this continent attracted this sea dweller and his motley crew. MartianSaucerCore: Following the destruction of their planet by otherworldly creatures, the Martians' military evolved at an unprecedented rate. They were prepared to fight back any future threats, and also pillage any other worlds they could find. TorchGod: An unknown entity responsible for a torch's eternal flicker, however easily angered by the unsightly, ungrateful abuse of torch placement. - EyeofCthulhu: A gargantuan monster of unknown origins, responsible for plaguing the night with Demon Eyes. It was given the title of "Cthulhu", which means "Great Beast" in the language of dragons. + EyeofCthulhu: A gargantuan monster of unknown origins, responsible for plaguing the night with Demon Eyes. Beasts of such caliber are often given the title of "Cthulhu", a word that meant "great beast" in the language of dragons. BrainofCthulhu: The death of a god often birthed great monsters due to the volatile nature of godly essence. The culling of such abominations used to be cause for songs and festivities, but now, they only give birth to disappointments. SkeletronHead: A demonic construct that bursts out of the Old Man when necessary and the most dangerous part of the curse laid by the Dragon Cult. They hoped to stop all intruders with it, but one was too cunning even for them. WallofFlesh: Originally created by Azafurian mages as a gambit to seal away godly essence, the towering wall broke free after the city's destruction. Its existence was problematic, but its demise has ushered even greater instability upon the world. @@ -82,7 +81,7 @@ NPCName: { Spazmatism: A pair of mechanical eyes built by Draedon for reconnaissance and assassination, Spazmatism chases at high speed, exhaling cursed flames. TheDestroyer: Despite being made with repurposed mining equipment, the Destroyer was built for fighting other deities in single combat, decorated in laser-armed probes, which detach from its body when damaged. SkeletronPrime: Built with the express purpose of inciting fear into the hearts of any god worshiper, this machine has more arms than ever before, and a variety of fierce weapons. - Plantera: A creation of the Vernal Pass meant to replace Braelor in his absence. They harnessed dead animal souls to give it life, but the span of such magic was far larger than anticipated. It didn't take long for the Plantera to grow out of control and slaughter its masters. + Plantera: A dormant, yet powerful floral guardian grown by the elders of the Vernal Pass, using volatile animal souls as nourishment. Unshackled in a fit of herbage carnage, its reach now spans the entire jungle. HallowBoss: Despite their parentage, children of gods do not inherit a shred of their power. The Empress chose to claim power for herself by siphoning it from other places and beings. She found a perfect candidate in the Hallow due to its unstable nature, and is now transformed into a mighty fae. Golem: A remarkable display of ingenuity constructed by the Lihzahrd race. Seeking light after they hid away in their temple out of shame for driving their goddess away, they built this construct. Powered by solar energy cells, it is ready to guard the Temple. DukeFishron: An aquatic-evolved species which lives in isolation in the depths of the ocean. Despite their shortcomings, they still share blood with the dragons of old, claiming near complete dominion over the oceans. Legends claim it only surfaces in search of a rare, savory type of worm. @@ -100,7 +99,7 @@ CommonEntries: { SandShark: Sand Sharks lived in the shallow waters of Ilmeris, hiding beneath the sand. They were thankfully well equipped to deal with the fallout of the Incineration. AngryBones: Cursed with undeath, the former prisoners of the Dungeon roam endlessly through its halls, seeking a victim for their unending fury. BlueArmoredBones: Mercenaries hired by Yharim to guard the Dungeon, the Marching Blues were disciplined and relentless, sundering any escapees that decided to rise against their jailors. - HellArmoredBones: Mercenaries hired by Yharim to guard the Dungeon hailing from Azafure, the fiery glow of the Molten Legion is unmistakable. If anyone ever tried to hide, their red-hot armaments would melt the hideout immediately. + HellArmoredBones: Mercenaries hired by Yharim to guard the Dungeon hailing from Azafure, the fiery glow of the Molten Legion is unmistakable. When the halls of the Dungeon lit up, every prisoner knew hell would be let loose. RustyArmoredBones: Mercenaries hired by Yharim to guard the Dungeon hailing from Underground factions, the Rusted Company's weapons are jagged and rough through use and neglect. The brutality they employed on the field was enough to make many prisoners give up on freedom. Diabolist: Mages of Azafure who bear the Diabolic Sigil, a certificate of their prowess, wielding flames as intense as any in the underworld. They were effective at blocking passageways and at making prisoners talk. Necromancer: These sorcerers were trained in Azafure and bore the Necromantic Sign, a certificate of their prowess. Much like they terrorized prisoners with the bodies of their friends, so do they terrorize the Dungeon now. diff --git a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson index 06606aa88c..db28331712 100644 --- a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson +++ b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson @@ -66,7 +66,7 @@ Nanodroid: Ambient lighting, total surveillance, instantaneous repair… With en RepairUnitCritter: These handy little helpers are the reason that Draedon's decades-old labs stand to this day. Though bulkier and less energy efficient than nanodroids, having to take what power they need from the labs' generators, they can easily clean up the dust, though struggle with the rust. //Normal Uncategorized Enemies AeroSlime: Previously mundane slimes that have absorbed trace amounts of draconic essence from the outpour of energy caused by the re-enchantment of Aerialite. They now soar the skies with their newly sprouted wings, reaching heights few of their gelatinous kind ever have. -ArmoredDigger: Despite being relatively primitive compared to Draedon's current technology, armored diggers continue to see use to this day. Though their primary directive is mining and delivering minerals, they also once cleared room for the numerous underground laboratories. +Burrower: Despite being relatively primitive compared to Draedon's current technology, Burrowers continue to see use to this day. Though their primary directive is mining and delivering minerals, they also once cleared room for the numerous underground laboratories. AuroraSpirit: Thought to be no more than an old wives' tale, sightings of aurora spirits have become commonplace since the defeat of the wall of flesh. Upon closer inspection, it appears these "spirits" are rather wisp-like entities clad in a cryonic shell, a sure sign that these were created by Archmage Permafrost. BloomSlime: Imbued with profaned energy, this slime wishes to see the world reduced to ashes to ensure the suffering it brings is no more. However, the simplicity of their form makes it difficult for the slain goddess to fully impose her will onto them. Bohldohr: Bohldohrs were made to serve the lihzahrds, being crafted from ancient stone and brought to life with magical power in the twilight of the great Lihzahrd Dynasty. But the sun sets on every civilization, and once their deity abandoned them, they were left to fend for themselves. @@ -79,14 +79,14 @@ CryoSlime: Slimes enchanted by the Archmage, as a host to crystallize the frozen Eidolist: Once members of the dragon cult, they now beg the favor of a new master. They are able to live in the abyss indefinitely thanks to their wyrm-like form, allowing them to serve a new purpose. FearlessGoldfishWarrior: Though Goldfish thrive in their ponds and lakes, many take to land during storms to feed on the worms that have also surfaced. There are even accounts of aquatic warriors who carry daggers of shimmering gold, though most consider these tales far too fishy to be credible. Frogfish: Well-camouflaged and prepared to strike at any moment, Frogfish show that the ocean is rarely as serene as it seems. There are few places where one can find true peace here in the heart of what once was an empire unrivaled. -Horse: After the Brimstone Elemental became dormant, the forgemasters of Azafure used clockwork and crystal to bind the powers of an elemental to a mechanical body. While formidable, it seems the dream of creating a true replacement for an elemental died unfulfilled with Azafure itself. +EarthElemental: After the Brimstone Elemental became dormant, the forgemasters of Azafure used clockwork and crystal to bind the powers of an elemental to a mechanical body. While formidable, it seems the dream of creating a true replacement for an elemental died unfulfilled with Azafure itself. IceClasper: Though their exact origins are an enigma, what is known is that these ethereal beings seek to stamp out any and all sources of warmth that exist in their home. Due to this fact, and taking into account the fossil record, many speculate that ice claspers may have played a vital role in the tundra's creation. ImpiousImmolator: An idol carved in the image of Her, it is lit ablaze with the crafter's lifeforce. After all, what weight does one's life hold when one wishes to see the world wreathed in Her holy flames? MantisShrimp: Though a variety of answers are given when one asks adventurers about dangerous creatures, few aside from sailors will mention the small yet mighty Mantis Shrimp. Their strikes are so swift that the energy generated from them heats the water to temperatures rivaling the magma of Azafure. OverloadedSoldier: A body given life again, overflowing with the souls of warriors that perished during the Crusade who were unable to find peace. Their ravenous hunger for battle has been reignited due to sensing godly essences in the land once more. PerennialSlime: These slimes have seized a small amount of the Goddess of Life's essence. Despite her reimprisonment in the deepest depths of the Abyss, the tendrils of her influence now stretch far into the world beyond. PhantomSpirit: The spirits within the Dungeon only vaguely recall their lives, and yet there is one thing each and all clearly remember, that drives them to chaos: the man responsible for locking them in these cursed walls, and his overwhelming power– power that they have been reminded of, due to one ever growing in strength roaming their halls. -Piggy: These little swines waddle their little legs across these lands with little purpose, but they are happy with just that. Yet, little is known about how their little stomach carries a not-so-little amount of coins. +Piggy: These little swines waddle their little legs across these lands with little purpose, but they are happy with just that. Yet, little is known about how their little stomach carries a not-so-little amount of fat and muscle. ProfanedEnergyBody: Those most devout to Her travel the world, being planted into societies and acting as spies and assassins. Among their duties is constructing shrines in Her honor infused with Her divine power, that She might bless pagans blinded by darkness with visions of Her new age of light. Rimehound: These hounds were bred and trained to survive in the tundra's hostile conditions by Yharim's forces, so that they may act as scouts. Most were simply abandoned by their masters out of either necessity or choice, and were resigned to roam forever without purpose. Rotdog: Fast and furious, these hounds prowl the night, hunting prey with their razor sharp teeth. They are similar in nature to the demon eyes, both being spawned from the same vile mire, yet these creatures are tailored made to end those who have proven themselves a threat to it. @@ -117,30 +117,42 @@ Toxicatfish: Though these fish once threatened none other than their prey, the r Trasher: Despite being equipped with a mouth large enough to swallow a child whole, these crocodiles simply act as scavengers, devouring scraps and bones left over from predators' meals. Needing to conserve energy due to eating relatively little, they rarely move at their full speed unless they feel threatened. //Sunken Sea Enemies BabyGhostBell: Despite their decidedly lower size and development, infant Ghost Bells can deliver just as many volts to unsuspecting creatures. The Ilmerian army bred thousands of Ghost Bells to maintain the lethal electric field around the sea kingdom, but all their efforts were consumed by ash in a single burning moment. +CarrionSwallower: Of all the species of fish rendered extinct by the Great Incineration, few were lucky enough to even have their corpses remain in one piece. Those that did had their souls infused with trace amounts of brimstone, which they use to hunt any that dare trespass on the old sea. Clam: Despite having the same filter feeder appetite of the common clam, the Ilmeran species adopted defensive mechanisms against macrofauna due to their forced relocation by the Incineration. Almost all of the remaining Clams have congregated in a small den at the bottom of the sea; what makes this place unique is unknown, as few divers can withstand the ferocity of the clams in their natural abode. Cnidrion: Once trained to be the steeds of honored Ilmerian warriors, Cnidrions fought valiantly alongside their masters during the Incineration. Though many perished unceremoniously with the warriors that commanded them, one managed to escape a fiery demise, continuing to defend what was once the heart of the sea kingdom with a fierce loyalty. EutrophicRay: Living life as a filter feeder, the tranquil Eutrophic Ray is quick to flee from any dangers. They are aided by their commensalistic relationship with Ghost Bells, storing the latent voltage in a sac on their underbelly for electrical muscle stimulation, allowing for great bursts of speed. GhostBell: Commonly encountered as large walls of electric power, these high-voltage jellyfish can incapacitate most with a single touch. Even when not delivering shocks to prey, they passively release a current into the surrounding water, which the old sea kingdom exploited to drive back Yharim's crusade for decades. GiantClam: Pearls are formed from ambient mana combining with natural limestone deposits, and are claimed to be capable of storing thoughts and memories. Although most clams die and break down before their shells can act as sufficient conduits, the largest and strongest clams can gather enough mana in their pearls for direct use in feeding and defense. +GildedAxolotl: In Ilmeris, these gracious critters were worshipped as mythical paragons of healing and good fortune. Previously considered one of many species lost to the fiery onslaught, their resurgence in the Sunken Sea is a shining ray of hope for Ilmerian survivors. HauntedChum: During the Witch's razing of Ilmeris' seas, many of the largest fish that had never known fear in their lives were foolish enough to fight back. Even in death they remain consumed by rage, attacking those who draw near, despite being as ruined as the sea itself. Jellyghoul: The spirits of some Ilmerians were so consumed by grief and despair that, over time, their identity and memories faded away. These souls are now confined in the blank form of phantom jellyfishes, doomed to forever haunt the Timeless Shores. KelpieSeadragon: Kelpie Seadragons enjoy hiding in the scarlet kelp fronds of the Polyp Forest, where they can observe their surroundings without being noticed. Don’t underestimate them, as their silly-looking faces can shoot highly poisonous pellets! +LazarusLampfish: No less than living fossils, Lazarus Lampfish were long thought to be extinct. Their species survived for millions of years in the secluded depths of the Ilmeran Sea, using bright flashes of light emitted from their “lamp” to great defensive effect. +Leerslug: Named for their unsightly snapping teeth, the Leerslug uses the rather cruel reproduction method of laying their eggs within the skin of Searslugs. Once their lethargic and shaky host is no longer needed, they violently erupt out and bite another Searslug, continuing the cycle. LostShoal: Shoals of spectral fish swim through the damp air of the Sunken shoreline, fully ignorant of their ominous demeanor and the horrible fate that befell them. Pearlpod: Residing in the utmost depths of the Sunken Sea, these docile crustaceans consume Lantern Kelp and organic remains to survive. When curled up, their nacreous hide makes them almost identical to pearls and impervious to attacks. +PodobooKoi: The basaltic canyons are constantly being scouted by these giant Koi, whose lateral plates mineralize into an impenetrable set of armor. Carnivorous and volatile, not even the tough magmatic rock will save prey from their insatiable hunger. PolypPanasea: The vibrant Panaseas developed a natural coating which counters the toxins of polyps, and now frequently take shelter in their tentacles. Anything that chases the fish into their home swiftly learns about the other side of this partnership. +Polyperil: Comprising a large portion of the polyp that lends the Polyp Forest its name, these sea anemone capture small prey through the venomous toxins that coat their tentacles. They have developed a mutualistic relationship with the Panaseas that populate the Forest, providing protection in exchange for live meals that give chase to the Panasea, along with nutrients from its waste. PrismBack: Far too slow and bulky to hunt normally, these turtles subsist on a diet of purely kelp. As a result of their slow and infrequent movement, large prisms are able to accumulate on their backs, providing natural protection against threats that would not risk swallowing a razor-sharp crystal. +PrismaticGuppy: Is it a crystal? Is it a candy? No, it's a little Guppy! Thanks to the unique prismatic sheen of their scales and their striking geometric shapes, these fish can camouflage as Sea Prisms to escape pursuing predators. Probesnout: One of just a few known seahorse species who miraculously survived the Incineration. Its efficient snout allows it to streamline nutrients from the abundant sponge in the reefs that it lives in. SandProwler: These colorful sea serpents prowl through the sand, looking for the gleam of an unsuspecting Guppy to snack on. Due to this creature’s habit of mistakenly capturing dropped coins, Ilmerians fond of avarice began to share the namesake. +Scavenger: This odd species of crab migrated to Ilmeris after its fateful incineration. Gifted with a remarkable sense of ownership and value, they hoard any scavenged treasures as a display of social status. Trade is not a foreign concept to their tribe, and they value Pearls above all else. SeaFloaty: Flatworms can be found in many seas and oceans across the world, and are exceptional at fitting through cracks or crevices to find kelp due to their thin bodies. These particular flatworms are incredibly skittish, and thus fled with plenty of time to be spared from the infernal carnage. SeaMinnow: Large schools of Sea Minnows were one of the most beautiful things one could witness during the days when Ilmeris was unsundered. Though the kingdom's grandeur has been lost like ashes in the wind, the tranquil fish continue to swim at peace, a breathtaking reminder that not all was lost. +Searslug: A distant cousin of the Slugbuns which can withstand the extreme heat of molten basalt. Their skin is scalding to the touch, a side effect of their adaptations to the many lava dips needed to squirm around the regions it lives in. Sharkoon: The bulbous Sharkoon wanders the reefs on the outskirts of the Sunken Sea. It retaliates against threats through the unusual method of exploding a sac on its body that stores highly reactive chemicals, fleeing in the confusion caused by its shockwave. +Shoreskipper: This fish stands out among the coastal fauna, showing its peers a hostility unseen in its interactions with other creatures. Their outlandish behavior has fueled centuries of analogies for the folly of bipolar moral judgement. +Slugbun: The name of these cute sea dwellers is actually a misnomer given to them by outside visitors of the sea kingdom, who often sold them as exotic pets. In fact, their "bunny ear" appendages are actually their antennae taking on the appearance of the various sea prisms scattered throughout their home. +Steampod: These distant relatives of the Pearlpods possess a powerful environmental adaptation. Their ability to eject steam propels themselves through the air as a deadly pneumatic boulder that packs quite a punch. Stormlion: Some Ilmerian survivors claim that enough magical lightning surged through the sea during its final days that there existed not a single drop of water without levin coursing through it. Even now, electricity remains buried in the sands, with several antlion species having learned to channel the former kingdom's power. +StormlionSentry: Some Ilmeran survivors claim that enough magical lightning surged through the sea during its final days that there existed not a single drop of water without levin coursing through it. Even now, electricity remains buried in the sands, with several antlion species having learned to channel the former kingdom's power. //Town NPCs AndroombaFriendly: Reverse-engineered Androombas that have been retrofitted to spread the Steampunker's solutions rather than clean dust and debris off of floors. They can be used to purify the world– or ruin it further, if one so desires. Archmage: One of the world's foremost experts on magical theory, he is renowned for his skill with the arcane arts. In his days when he traveled with Yharim's entourage, he acted as the Godseeker's advisor, due to both his status and his distaste for actively participating in battle. Bandit: The bandit may have a bad habit of looting battlefields and taking what isn't theirs, but their actions are mostly motivated by their hatred of the obscenely rich who haven't truly earned the wealth they possess. Their methods are somewhat shady, but can always be relied upon to get a job done. BrimstoneWitch: Recruited to Yharim's forces late into the war, her magic overflows with such power that she is largely incapable of casting normal spells. Yet despite her great power, Calamitas prefers not to use it, as it takes a heavy toll on her psyche. -Cirrus: A princess from an unknown land. She drinks constantly in a vain attempt to escape the memories of her past, but is practically immune to alcohol. She makes a business of selling her mixtures, alcoholic and alchemic alike. SeaKing: The seventeenth ruler of the constitutional monarchy of Ilmeris since the tribes of the Ilmeran Sea unified, under the Electric Goddess, Otonilou, and the elusive God of the Seas. Alas, one cannot be a ruler without subjects, and while he remains respected by those who opposed Godseeker Yharim, his kingdom is no more. //Boss Minions Brimling: Extensions of the Brimstone Elemental herself, and part of her very being. Both she and her Brimlings are of a single mind, so she naturally cares for them just as she cares for herself. When heavily wounded, they withdraw into a cocoon to protect themselves from further harm. @@ -150,7 +162,7 @@ DesertNuisance: Though these serpents are of the Desert Scourge's species, they CosmicGuardian: Though of the same species as the nameless serpent, their minds and functions are far more basic. They possess very little will of their own and blindly follow the orders of their gluttonous master. DankCreeper: Divine puppeteers beheld incessantly through their devotees, an organic panopticon for a wicked hive mind. Their word was truth, and evidence otherwise was burned. Even in decay, they summon subjects to creep, spy and kill. DarkHeart: Beneath all the schemes and lies, dark desires coiled inside the pitch-black hearts of these deities. With their forms rent beyond recognition, new hearts arise from their rot to beat with misery once more -HiveBlob: The faceless are bulletproof, and so the corrupt coalescence shields itself behind dull pawns, as the Gods it was birthed from once did. +HiveBlob: The faceless are bulletproof, and so the corrupt coalescence shields itself behind dull pawns, as the gods it was birthed from once did. HiveTumor: This tumor acts as the brain of the putrid wasteland, being all that is left of the minds of the slain gods that lay there. The creatures of the Corruption exist to protect it, and those who attempt to harm it rarely live to tell the tale. AquaticAberration: A spawn of the immense Leviathan, their lifespan can be measured in hours. All they know is how to hunt for their masters. Even non-aquatic life is well within their reach, due to their uncanny ability to fly through air just as easily as swimming through water. LeviathanStart: A lure created by the Water Elemental, Anahita. It sings so sweetly, its voice full of promise and warmth, but beware: follow the siren's call at your own peril. diff --git a/Localization/en-US/Mods.CalamityMod.Biomes.hjson b/Localization/en-US/Mods.CalamityMod.Biomes.hjson index b3057f8810..e0bdacb71f 100644 --- a/Localization/en-US/Mods.CalamityMod.Biomes.hjson +++ b/Localization/en-US/Mods.CalamityMod.Biomes.hjson @@ -72,7 +72,7 @@ SunkenSeaBiome: { } AstralUnderground: { - DisplayName: Astral Underground + DisplayName: Underground Astral TownNPCDialogueName: Underground Astral Infection } @@ -87,26 +87,31 @@ FloralParadiseBiome: { } BasaltGullyBiome: { - DisplayName: Basalt Gully Biome - TownNPCDialogueName: the Basalt Gully Biome + DisplayName: Basalt Gully + TownNPCDialogueName: the Basalt Gully } GleamingBurrowsBiome: { - DisplayName: Gleaming Burrows Biome - TownNPCDialogueName: the Gleaming Burrows Biome + DisplayName: Gleaming Burrows + TownNPCDialogueName: the Gleaming Burrows } PolypForestBiome: { - DisplayName: Polyp Forest Biome - TownNPCDialogueName: the Polyp Forest Biome + DisplayName: Polyp Forest + TownNPCDialogueName: the Polyp Forest } RadiantReefsBiome: { - DisplayName: Radiant Reefs Biome - TownNPCDialogueName: the Radiant Reefs Biome + DisplayName: Radiant Reefs + TownNPCDialogueName: the Radiant Reefs } TimelessShoresBiome: { - DisplayName: Timeless Shores Biome - TownNPCDialogueName: the Timeless Shores Biome + DisplayName: Timeless Shores + TownNPCDialogueName: the Timeless Shores +} + +ClamDenBiome: { + DisplayName: Clam Den + TownNPCDialogueName: the Clam Den } diff --git a/Localization/en-US/Mods.CalamityMod.BossChecklistIntegration.hjson b/Localization/en-US/Mods.CalamityMod.BossChecklistIntegration.hjson index 1887130660..8e6b15daba 100644 --- a/Localization/en-US/Mods.CalamityMod.BossChecklistIntegration.hjson +++ b/Localization/en-US/Mods.CalamityMod.BossChecklistIntegration.hjson @@ -20,7 +20,7 @@ AquaticScourge: { } AstrumAureus: { - SpawnInfo: Use an [i:CalamityMod/AstralChunk] at night in the Astral Infection. + SpawnInfo: Use an [i:CalamityMod/AstralChunk] in the Astral Infection. DespawnMessage: "[c/FFD700:Aureus has neutralized all threats. Resume prior reconnaissance.]" } @@ -47,7 +47,7 @@ Calamitas: { } CalamitasClone: { - SpawnInfo: Use an [i:CalamityMod/EyeofDesolation] at night. + SpawnInfo: Use an [i:CalamityMod/EyeofDesolation]. DespawnMessage: "[c/FFA500:The clone spits a bit of blood in disgust and vanishes.]" } @@ -58,7 +58,7 @@ CeaselessVoid: { } Crabulon: { - SpawnInfo: Use a [i:CalamityMod/DecapoditaSprout] in a Glowing Mushroom biome. + SpawnInfo: Use a [i:CalamityMod/DecapoditaSprout] in an underground Glowing Mushroom biome. DespawnMessage: "[c/6495ED:The monstrous mycelial crab shuffles away…]" } diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 67845293c8..69e5c2fd76 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -6,22 +6,22 @@ AlcoholPoisoning: { BloodyMaryBuff: { DisplayName: Bloody Mary - Description: Damage and movement speed increased during a Blood Moon, life regen and defense reduced + Description: Increased enemy spawn rates, reduced piercing weapon effectiveness } CaribbeanRumBuff: { DisplayName: Caribbean Rum - Description: Life regen and movement speed increased, you are floaty and defense is reduced + Description: Increased movement speed, reduced gravity } CinnamonRollBuff: { DisplayName: Cinnamon Roll - Description: Mana regen rate and fire debuff damage increased, defense reduced + Description: Greatly increased dash speed, greatly reduced dash distance } -CirrusVodkaBuff: { - DisplayName: Fab - Description: You feel fabulous +PurpleHazeBuff: { + DisplayName: Purple Haze + Description: Increased damage after a stealth strike, reduced stealth strike damage } EverclearBuff: { @@ -31,32 +31,37 @@ EverclearBuff: { EvergreenGinBuff: { DisplayName: Evergreen Gin - Description: Sickness and water debuff damage increased, life regen reduced + Description: Sickness and water debuff damage increased, electric and heat debuff damage reduced } FireballBuff: { DisplayName: Fireball - Description: Fire debuff damage increased, life regen reduced + Description: Heat debuff damage increased, sickness debuff damage reduced } GrapeBeerBuff: { DisplayName: Grape Beer - Description: Defense reduced + Description: Ranged projectiles gain homing, reduced critical strike damage +} + +ManhattanBuff: { + DisplayName: Manhattan + Description: Cold debuff damage increased, water debuff damage reduced } MargaritaBuff: { DisplayName: Margarita - Description: Reduced duration to most debuffs, defense and life regen reduced + Description: Reduced duration to most harmful debuffs, reduced damage dealt to enemies from debuffs } MoonshineBuff: { DisplayName: Moonshine - Description: Defense and damage reduction increased, life regen reduced + Description: Increased maximum health, increased defense damage taken } MoscowMuleBuff: { DisplayName: Moscow Mule - Description: Damage, critical strike chance, and knockback increased, life regen reduced + Description: Increased knockback, reduced piercing weapon effectiveness } OldFashionedBuff: { @@ -66,52 +71,52 @@ OldFashionedBuff: { RedWineBuff: { DisplayName: Red Wine - Description: Life regen reduced + Description: Increased vertical speed, reduced flight time } RumBuff: { DisplayName: Rum - Description: Movement speed and life regen increased, defense reduced + Description: Increased non-minion summon damage, decreased minion damage } ScrewdriverBuff: { DisplayName: Screwdriver - Description: Piercing projectile damage increased, life regen reduced + Description: Improved building ability, reduced damage } StarBeamRyeBuff: { DisplayName: Star Beam Rye - Description: Max mana and magic damage increased. Defense, mana usage, and life regen reduced + Description: Increased magic damage, reduced mana regeneration } TequilaBuff: { DisplayName: Tequila - Description: Critical strike chance, defense, and knockback increased during daytime, life regen reduced + Description: Increased electric debuff damage, reduced cold debuff damage } TequilaSunriseBuff: { DisplayName: Tequila Sunrise - Description: Critical strike chance, defense, and knockback increased during daytime, life regen reduced + Description: Increased life regeneration, increased damage taken from debuffs } Trippy: { DisplayName: Trippy - Description: You see the world for what it truly is... and you also have a {0}% increase to all damage + Description: You see the world for what it truly is... } VodkaBuff: { DisplayName: Vodka - Description: Damage and critical strike chance increased, defense and life regen reduced + Description: Increased typeless debuff damage, reduced other debuff damage } WhiskeyBuff: { DisplayName: Whiskey - Description: Damage, critical strike chance, and knockback increased, defense reduced + Description: Increased damage when swapping weapons } WhiteWineBuff: { DisplayName: White Wine - Description: Magic damage increased, life regen and defense reduced + Description: Regenerate flight time when near enemies, reduced flight time } // Cooldowns @@ -124,71 +129,85 @@ Withered: { AstralInfectionDebuff: { DisplayName: Astral Infection Description: Your flesh is melting off + ItemTooltip: Sickness - 37.5 DPS } AuricRebuke: { DisplayName: Auric Rebuke Description: Your cells are violently bouncing off each other + ItemTooltip: Electric - 100 DPS. Deals 4x damage against moving targets } BanishingFire: { DisplayName: Banishing Fire Description: You shall not be forgiven for your sins + ItemTooltip: Heat - Deals DPS equal to 0.1% of max HP or 2000, whichever is greater } BrimstoneFlames: { DisplayName: Brimstone Flames Description: Incinerating both body and mind + ItemTooltip: Heat - 30 DPS } BurningBlood: { DisplayName: Burning Blood Description: Your blood is on fire + ItemTooltip: Sickness - 20 DPS } BrainRot: { DisplayName: Brain Rot Description: Your neurons are popping like corn kernels + ItemTooltip: Sickness - 20 DPS } DemonicFlames: { DisplayName: Demonic Flames Description: Immolating flames sear your soul + ItemTooltip: Heat - DPS depends on inflicting item } ElementalMix: { DisplayName: Elemental Mix Description: A beautiful elemental symphony is flaying you alive + ItemTooltip: Typeless - 200 DPS } CrushDepth: { DisplayName: Crush Depth Description: Crushed by aquatic pressure + ItemTooltip: Water - 50 DPS } RiptideDebuff: { DisplayName: Riptide Description: Lashed at by powerful waters + ItemTooltip: Water - 15 DPS } Dragonfire: { DisplayName: Dragonfire Description: Engulfed by roaring flames + ItemTooltip: Heat - 480 DPS } GodSlayerInferno: { DisplayName: God Slayer Inferno Description: Your flesh is burning off + ItemTooltip: Heat - 250 DPS } HeavyBleeding: { DisplayName: Heavy Bleeding Description: That's gonna need stitches + ItemTooltip: Typeless - 40 DPS } HolyFlames: { DisplayName: Holy Flames Description: Dissolving from holy light + ItemTooltip: Heat - 150 DPS } HolyInferno: { @@ -199,31 +218,41 @@ HolyInferno: { Laceration: { DisplayName: Laceration Description: You're a bloody mess + ItemTooltip: Typeless - 200 DPS } ManaBurn: { DisplayName: Mana Burn Description: The excess of mana sears your body and mind + ItemTooltip: + ''' + Typeless + Every 100 negative mana reduces your life regen by 4 HP/s, but burns enemies for 3% of dealt damage + ''' } MiracleBlight: { DisplayName: Miracle Blight Description: Exotic resonance shreds your corporeal form + ItemTooltip: Typeless - 1500 DPS } Nightwither: { DisplayName: Nightwither Description: Incinerated by lunar rays + ItemTooltip: Cold - 100 DPS } Plague: { DisplayName: Plague Description: Rotting from the inside + ItemTooltip: Sickness - 50 DPS } SagePoison: { DisplayName: Sage Poison Description: Poisoned + ItemTooltip: Sickness - DPS scales with summoned Viral Sprout amount } SearingLava: { @@ -239,6 +268,7 @@ ShellfishClaps: { Shred: { DisplayName: Shred Description: Someone built ten Tri-Tip Daggers... + ItemTooltip: "" } SnapClamDebuff: { @@ -249,36 +279,56 @@ SnapClamDebuff: { StaticDischarge: { DisplayName: Static Discharge Description: Shocked by static electricity + ItemTooltip: Electric - 2.5 DPS. 4x damage to moving targets } SulphuricPoisoning: { DisplayName: Sulphuric Poisoning Description: The acidic water burns away your flesh + ItemTooltip: Sickness - 120 DPS } TrueVulnerabilityHex: { DisplayName: True Vulnerability Hex Description: The end has come + ItemTooltip: + ''' + Heat - 1998 DPS + Increases damage taken from all sources + Slows enemies + ''' } Vaporfied: { DisplayName: Vaporfied Description: Vape + ItemTooltip: + ''' + Typeless - 15 DPS + Slows enemies + ''' } VermillionFlux: { DisplayName: Vermillion Flux Description: Sharp arcs of scarlet course through you + ItemTooltip: Electric - 50 DPS. Deals 4x damage against moving targets } Voidfrost: { DisplayName: Voidfrost Description: The emptiness of space devours all warmth and life + ItemTooltip: Cold - 200 DPS } VulnerabilityHex: { DisplayName: Vulnerability Hex Description: Your mental fortitude is fading + ItemTooltip: + ''' + Heat - 1332 DPS + Slows enemies + ''' } WeakBrimstoneFlames: { @@ -287,10 +337,6 @@ WeakBrimstoneFlames: { } // Mounts -AlicornBuff: { - DisplayName: Alicorn - Description: You beat DoG while drunk, you are truly fabulous! -} AndromedaBuff: { DisplayName: Andromeda @@ -428,6 +474,11 @@ FoxPetBuff: { Description: Fox Pet? FOX PET } +FrostyBatBuff: { + DisplayName: Frosty Bat Friend + Description: A frosty bat flits about +} + FurtasticDuoBuff: { DisplayName: Furtastic Duo Description: They just did! The Furtastic Duo will accompany you! @@ -483,11 +534,6 @@ RadiatorBuff: { Description: Radioactive but adorable } -ReaverOrbBuff: { - DisplayName: Reaver Orb - Description: The reaver orb will light your way -} - SparksBuff: { DisplayName: Sparks Description: Eats butterflies @@ -498,6 +544,11 @@ ThirdSageBuff: { Description: Eh? No way it's an oni } +ToastyBatBuff: { + DisplayName: Toasty Bat Friend + Description: A fiery bat flutters at your shoulder +} + YharonSonBuff: { DisplayName: Son of Yharon Description: You better not eat his dinner @@ -509,22 +560,22 @@ ChaosCandleBuff: { Description: Spawn rates around the candle are boosted! } -CirrusBlueCandleBuff: { +BlueCandleBuff: { DisplayName: Limber Description: The floating flame seems to uplift your very spirit } -CirrusPinkCandleBuff: { +PinkCandleBuff: { DisplayName: Vigor Description: The brilliant light suffuses you with hope } -CirrusPurpleCandleBuff: { +PurpleCandleBuff: { DisplayName: Resilience Description: Neither rain nor wind can snuff your undying flame } -CirrusYellowCandleBuff: { +YellowCandleBuff: { DisplayName: Spite Description: The hateful, flickering glow fuels your ire } @@ -562,7 +613,7 @@ AstralInjectionBuff: { BaguetteBuff: { DisplayName: Baguette - Description: "[c/B00BA5:'If only I knew...' ~Cirrus]" + Description: Goes well with Red Wine } BloodfinBoost: { @@ -652,6 +703,7 @@ AbsorberRegen: { You are blessed by the culmimation of nature's powers Life regen increased by {0} HP/s, damage increased by {1}%, damage reduction increased by {2}% ''' + ItemTooltip: Increases life regeneration, damage, and damage reduction } AbyssalDivingSuitBuff: { @@ -659,11 +711,6 @@ AbyssalDivingSuitBuff: { Description: You are made of metal } -AbyssalDivingSuitPlates: { - DisplayName: Abyssal Diving Suit Plates - Description: "{0}% increased damage reduction" -} - AbyssalMadness: { DisplayName: Abyssal Madness Description: Increased damage, critical strike chance, and tentacle aggression and range @@ -679,7 +726,7 @@ AeolianEarthBuff: { Description: ''' You are strengthened by primordial powers - Damage reduction increased by {0}%, damage increased by {1}% + Damage reduction increased by {0}%, damage increased by {1}%, and massively buffed mana regen ''' } @@ -734,11 +781,6 @@ BrimflameFrenzyBuff: { Description: Dark magic empowers your attacks at the cost of your life } -BrutalCarnage: { - DisplayName: Brutal Carnage - Description: "{0}% increased melee damage" -} - ChiBuff: { DisplayName: Chi Description: You are more resilient @@ -757,6 +799,7 @@ CoralSymbiosis: { CosmicFreeze: { DisplayName: Cosmic Freeze Description: You feel as cold as the empty expanse of outer space + ItemTooltip: Increases regeneration, especially when standing still, and freezes nearby enemies } DivineBless: { @@ -764,11 +807,6 @@ DivineBless: { Description: Increased health regen and minions inflict Banishing Fire } -EmpyreanRage: { - DisplayName: Empyrean Rage - Description: Rage of the cosmos -} - EmpyreanWrath: { DisplayName: Empyrean Wrath Description: Wrath of the cosmos @@ -779,6 +817,11 @@ Encased: { Description: Increased defense by {0} and damage reduction by {1}%, but... } +FortunesFavor: { + DisplayName: Fortune's Favor + Description: How bold. Life regen increased by {0} HP/s +} + GraxBoost: { DisplayName: Grax Boost Description: Your defenses and muscles are strong @@ -791,7 +834,7 @@ GreenJellyRegen: { HallowedRuneDefense: { DisplayName: Hallowed Defense - Description: Increased defense by {0} and damage reduction by {1}% + Description: Increased defense by {0} } HallowedRunePower: { @@ -814,14 +857,10 @@ IceShieldBuff: { Description: Absorbs {0}% damage from the next hit you take, then shatters } -KamiBuff: { - DisplayName: Kami Injection - Description: "{0}% increased max movement speed, acceleration and damage" -} - Mushy: { DisplayName: Mushy Description: Increased defense by {0} and life regen by {1} HP/s + ItemTooltip: Increases defense and life regeneration } PhantomicEmpowerment: { @@ -838,7 +877,7 @@ PhantomicShield: { DisplayName: Phantomic Shield Description: ''' - Defense increased by {0} and damage reduction increased by {1}% + Increased defense by {0} An ephemeral bulwark protects you ''' } @@ -892,6 +931,7 @@ ReaverRage: { Rage of the earth Defense increased by {0} and damage increased by {1}% ''' + ItemTooltip: Increased defense and damage } SandsWindBuff: { @@ -899,7 +939,7 @@ SandsWindBuff: { Description: ''' You are strengthened by the powers of sand - Defense increased by {0}, damage increased by {1}% + Defense increased by {0}, damage increased by {1}%, and greatly buffed mana regen ''' } @@ -910,7 +950,7 @@ SilvaRevival: { SpiritDefense: { DisplayName: Spirit Defense - Description: Defense increased by {0} and damage reduction increased by {1}% + Description: Defense increased by {0} } SpiritPower: { @@ -936,12 +976,14 @@ TarragonImmunity: { TarraLifeRegen: { DisplayName: Tarra Life Description: Rapid healing + ItemTooltip: "" } // Stat debuffs AbsorberAffliction: { DisplayName: Absorber Affliction Description: Damn nature, you scary! + ItemTooltip: Sickness - 200 DPS } AndromedaCripple: { @@ -952,11 +994,13 @@ AndromedaCripple: { ArmorCrunch: { DisplayName: Armor Crunch Description: Your armor is shredded + ItemTooltip: Damage Reduction is 15% less effective } Crumbling: { DisplayName: Crumbling Description: Your armor is damaged + ItemTooltip: Damage Reduction is 8% less effective } Clamity: { @@ -981,6 +1025,7 @@ Enraged: { Eutrophication: { DisplayName: Eutrophication Description: Excessive nutrients restrict your movement + ItemTooltip: Slows enemies } ExoFreeze: { @@ -1001,16 +1046,19 @@ FrozenLungs: { GalvanicCorrosion: { DisplayName: Galvanic Corrosion Description: Your limbs have begun to corrode + ItemTooltip: Slows enemies } GlacialState: { DisplayName: Glacial State Description: Cannot move + ItemTooltip: Freezes enemies } HadopelagicPressure: { DisplayName: Hadopelagic Pressure Description: Rapidly sinking to a watery grave + ItemTooltip: Water - 200 DPS } IcarusFolly: { @@ -1025,16 +1073,17 @@ IcarusFolly: { Irradiated: { DisplayName: Irradiated Description: Your skin is burning off -} - -KamiFlu: { - DisplayName: Kami Flu - Description: Defenseless and dying + ItemTooltip: + ''' + Typeless - 10 DPS + Increases damage taken from Sickness debuffs + ''' } MarkedforDeath: { DisplayName: Marked for Death Description: Damage reduction reduced + ItemTooltip: Damage reduction is 50% less effective } PearlAura: { @@ -1050,11 +1099,13 @@ ProfanedWeakness: { TemporalSadness: { DisplayName: Temporal Sadness Description: You are crying + ItemTooltip: Freezes enemies } TimeDistortion: { DisplayName: Time Distortion Description: Time is slowed + ItemTooltip: Slows enemies } Warped: { @@ -1070,6 +1121,7 @@ WeakPetrification: { WhisperingDeath: { DisplayName: Whispering Death Description: Death approaches; attack power and life regen reduced + ItemTooltip: Reduced contact damage } WitherDebuff: { @@ -1102,6 +1154,11 @@ AquaticStar: { Description: The aquatic star will protect you } +AqueousHunterDroneBuff: { + DisplayName: Aqueous Hunter Drone Buff + Description: Unfortunately incapable of producing fried rice +} + AstralProbeBuff: { DisplayName: Astral Probe Description: The astral probe will protect you @@ -1137,7 +1194,7 @@ BrimseekerBuff: { Description: Does it want something from you? } -BrimstoneWaifu: { +BrimstoneElemental: { DisplayName: Brimstone Elemental Description: The Brimstone Elemental will protect you } @@ -1147,6 +1204,11 @@ BrittleStar: { Description: The brittle star will protect you } +BurrowerBuff: { + DisplayName: Burrower + Description: A friendly burrower answered your call +} + CalamarisLamentBuff: { DisplayName: Calamari Description: Time to transport all of your foes to stupid squid jail! @@ -1162,16 +1224,11 @@ CinderBlossomBuff: { Description: A hot, searing flower is floating uncomfortably close to you } -CloudyWaifu: { +CloudElemental: { DisplayName: Cloud Elemental Description: The Cloud Elemental will protect you } -GlacialEmbraceBuff: { - DisplayName: Glacial Embrace - Description: The magic of the ancient ice castle will aid you -} - Corroslime: { DisplayName: Corroslime Description: The corroslime will protect you @@ -1227,9 +1284,9 @@ DemonshadeSetDevilBuff: { Description: The red devil will protect you } -LegionofCelestiaBuff: { - DisplayName: Celestial Axe - Description: If only it was this good at chopping trees... +EnchantedKnifeStaffBuff: { + DisplayName: Enchanted Knife + Description: Junk knives not included } EndoCooperBuff: { @@ -1262,11 +1319,6 @@ FieryDraconidBuff: { Description: The fiery draconid will protect you } -FlarebatBuff: { - DisplayName: Flarebat - Description: The construct of fire will protect you -} - FleshBallBuff: { DisplayName: Flesh Ball Description: Why is it following you? @@ -1277,11 +1329,6 @@ FlowersOfMortalityBuff: { Description: Celestial blossoms surround you } -FrostbatBuff: { - DisplayName: Frostbat - Description: The construct of ice will protect you -} - FrostBlossomBuff: { DisplayName: Frost Blossom Description: A cold, prickly flower is floating uncomfortably close to you @@ -1302,6 +1349,11 @@ GastricAberrationBuff: { Description: The aquatic aberration will protect you } +GlacialEmbraceBuff: { + DisplayName: Glacial Embrace + Description: The magic of the ancient ice castle will aid you +} + HauntedDishesBuff: { DisplayName: Haunted Dishes Description: The haunted dishes will protect you @@ -1352,6 +1404,11 @@ KingofConstellationsBuff: { Description: The celestial dragons will protect you } +LegionofCelestiaBuff: { + DisplayName: Celestial Axe + Description: If only it was this good at chopping trees... +} + LiliesOfFinalityBuff: { DisplayName: Finality Description: Remember our promise @@ -1372,9 +1429,9 @@ MagicHatBuff: { Description: The hat carries your soul, bound by a contract } -Mechworm: { - DisplayName: Mechworm - Description: The mechworm will protect you +VoidEaterMarionetteBuff: { + DisplayName: Void Eater Marionette + Description: The power to control the Devourer is yours } MidnightSunBuff: { @@ -1443,6 +1500,11 @@ PuffWarriorBuff: { Description: It confidently and excitedly protects you } +RareSandElemental: { + DisplayName: Rare Sand Elemental + Description: The Sand Elemental will heal you +} + ResurrectionButterflyBuff: { DisplayName: Resurrection Butterfly Description: Sleep beneath the Cherry Blossoms, Red-White Butterfly @@ -1458,12 +1520,7 @@ Sandnado: { Description: The sandnado will protect you } -SandyHealingWaifu: { - DisplayName: Rare Sand Elemental - Description: The Sand Elemental will heal you -} - -SandyWaifu: { +SandElemental: { DisplayName: Sand Elemental Description: The Sand Elemental will protect you } @@ -1533,11 +1590,6 @@ SoulSeekerBuff: { Description: It definitely wants something from you } -StarSwallowerBuff: { - DisplayName: Star Swallower - Description: Mmmm myes -} - StellarTorusBuff: { DisplayName: Stellar Torus Description: Summons a Torus Orbital that fries your foes @@ -1578,7 +1630,7 @@ VoidConcentrationBuff: { Description: The infinite void yearns for more... } -WaterWaifu: { +WaterElemental: { DisplayName: Anahita Description: Anahita will protect you } @@ -1599,6 +1651,12 @@ YoungDukeBuff: { } // Misc + +HyperiusCollapse: { + DisplayName: Hyperius Collapse + Description: You should never see this... +} + PopoBuff: { DisplayName: Popo Description: You are a snowman now! @@ -1608,3 +1666,28 @@ PopoNoselessBuff: { DisplayName: Noseless Popo Description: Your nose has been stolen! } + +Daybroken: { + DisplayName: Daybroken + ItemTooltip: Heat - 100 DPS +} + +Shadowflame: { + DisplayName: Shadowflame + ItemTooltip: Heat - 30 DPS +} + +ForbiddenStealthSummonTagBuff: { + DisplayName: Forbidden Stealth Summon Tag Buff + Description: If you're seeing this, something went horribly wrong +} + +SeaKingsAssurance: { + DisplayName: Sea King's Assurance + Description: If you're seeing this, something assuredly went horribly wrong +} + +CnidarianSummonTagBuff: { + DisplayName: Cnidarian Summon Tag Buff + Description: you are not seeing this +} diff --git a/Localization/en-US/Mods.CalamityMod.Common.hjson b/Localization/en-US/Mods.CalamityMod.Common.hjson index c083073773..f3363486be 100644 --- a/Localization/en-US/Mods.CalamityMod.Common.hjson +++ b/Localization/en-US/Mods.CalamityMod.Common.hjson @@ -1,6 +1,21 @@ -AbyssLightLevel1: Provides a small amount of light in the abyss -AbyssLightLevel2: Provides a moderate amount of light in the abyss -AbyssLightLevel3: Provides a large amount of light in the abyss +// Plain stat boosts +RogueDamage: "{0}% increased rogue damage" +RogueCrit: "{0}% increased rogue critical strike chance" +RogueDamageCrit: "{0}% increased rogue damage and critical strike chance" +RogueVelocity: "{0}% increased rogue velocity" +RogueStealth: +{0} maximum stealth +// Armor Set Bonus key states +BothArmorSetBonusKeys: Press {0} or Double tap {1} +NoArmorSetBonusKey: Press the Armor Set Bonus key +ArmorSetBonusKey: Press {0} +DoubleTapDown: Double tap {0} +// Miscellaneous stats/info +AggroBoost: Enemies are more likely to target you +AggroReduction: Enemies are less likely to target you +KnockbackImmunity: Grants immunity to knockback +AbyssLightLevel: Reduces the darkness intensity of the abyss +AbyssFlashlight: Increases flashlight width in the abyss +AbyssGlow: Increases visibily range in the abyss AbyssBreathLevel1: Slightly reduces breath loss in the abyss AbyssBreathLevel2: Moderately reduces breath loss in the abyss AbyssBreathLevel3: Greatly reduces breath loss in the abyss @@ -8,9 +23,9 @@ AlcoholWarning: Drinking more than 3 different alcohols might not end well with ArmorPenetration: Ignores {0} points of enemy Defense CanMineUelibloom: Can mine Uelibloom Ore NotConsumable: Not consumable -RogueDamage: "{0}% increased rogue damage" -RogueCrit: "{0}% increased rogue critical strike chance" -RogueVelocity: "{0}% increased rogue velocity" +SummonTagDamageFlat: "{0} summon tag damage" +SummonTagDamageMult: "{0}x summon tag damage" +SummonTagCrit: "{0}% summon tag critical strike chance" DodgeInformation: ''' Attacks that deal less than 5% of your max life in damage will not be dodged diff --git a/Localization/en-US/Mods.CalamityMod.Condition.hjson b/Localization/en-US/Mods.CalamityMod.Condition.hjson index 99fdd6fa50..d99892c2dd 100644 --- a/Localization/en-US/Mods.CalamityMod.Condition.hjson +++ b/Localization/en-US/Mods.CalamityMod.Condition.hjson @@ -47,12 +47,11 @@ Drops: { Drops if Providence was defeated only with the [i:CalamityMod/ProfanedSoulArtifact] Profaned Soul Artifact {$Bestiary_ItemDropConditions.IsExpert} ''' - TrasherKill: Drops if fed to a Trasher } // Other conditions -PotionConfig: While the Town NPC Potion Selling configuration option is enabled HasFlareGun: While holding a Flare Gun upgrade +LacewingBestiary: When at least 40% of the Bestiary has been completed HasRogueArmor: While wearing rogue armor HasWings: While wearing wings InAstral: In the Astral Infection @@ -61,10 +60,3 @@ InSulph: In the Sulphurous Sea InSunken: In the Sunken Sea InRev: In Revengeance Mode InRevOrMM: In Revengeance Mode or in Master Mode -AlcoholPoison: While inflicted with Alcohol Poisoning -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.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson index 61bb06bf81..4083c303e5 100644 --- a/Localization/en-US/Mods.CalamityMod.Configs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson @@ -6,8 +6,12 @@ CalamityClientConfig: { Graphics: Graphics Changes UI: UI Changes MeterPositions: Meter Positions - MusicEvents: In-Game Music Events - Multithreading: Multi-Threading + MusicToggles: Music Toggles + } + + AbyssLayer3Alt: { + Label: "[i:CalamityModMusic/AbyssLayer3AltMusicBox] Abyss Layer 3 Alt" + Tooltip: Plays Calamity Mod OST - "R'lyehian Depths", while in the Thermal Vents layer of the Abyss. } AdrenalineMeterPosX: { @@ -75,11 +79,7 @@ CalamityClientConfig: { CooldownDisplay: { Label: "[i:CalamityMod/NebulousCore] Cooldown Rack Display Mode" - Tooltip: - ''' - Adds the Cooldown Rack which displays all important cooldowns right underneath buffs and debuffs. - Set this to 1 to display the Cooldown Rack in compact mode, and to 0 to hide it entirely. - ''' + Tooltip: Adds the Cooldown Rack which displays all important cooldowns right underneath buffs and debuffs. } DebuffDisplay: { @@ -92,6 +92,15 @@ CalamityClientConfig: { Tooltip: Plays Calamity Mod OST - "Scourge of the Universe (Eulogy for the Ego)", after the Devourer of Gods has been defeated. } + DisableGravityScreenSwap: { + Label: Disable Gravity Screen Flip + Tooltip: + ''' + Disables vanilla's screen-flipping from changing gravity, flipping the player instead. + Enable this if the screen-flipping is distracting or induces motion sickness. + ''' + } + EnableVanillaTextureEdits: { Label: "[i:Paintbrush] Enable Vanilla Texture Edits" Tooltip: @@ -110,18 +119,28 @@ CalamityClientConfig: { ''' } + FancyBackgroundVisuals: { + Label: "[i:CalamityMod/BlueDistortedMonolith] Toggle Fancy Background Visuals" + Tooltip: + ''' + Controls whether or not fancy background visuals will be displayed during certain parts of the game, such as boss fights. + When disabled, a simplified version of the main visual will be displayed in certain cases. + Recommended to have disabled if you struggle with visibility issues or low performance. + ''' + } + FasterFallHotkey: { Label: "[i:CalamityMod/BallAndChain] Enable Fast Falling" Tooltip: ''' - When enabled, you can hold the DOWN key while in the air to accelerate downwards faster. + When enabled, you can hold the {$Key.DOWN} key while in the air to accelerate downwards faster. This config does not increase your maximum falling speed, just how quickly you accelerate to it. Calamity is balanced around this setting being enabled. ''' } FlightBar: { - Label: "[i:CalamityMod/DrewsWings] Display Flight Bar" + Label: "[i:AngelWings] Display Flight Bar" Tooltip: ''' Enables the Flight Bar UI, which shows the player's remaining wing flight time. @@ -148,19 +167,15 @@ CalamityClientConfig: { ''' } - Interlude1: { - Label: "[i:CalamityModMusic/Interlude1MusicBox] Interlude 1" - Tooltip: Plays Calamity Mod OST - "Silence before the storms", after Calamitas Clone has been defeated. - } - - Interlude2: { - Label: "[i:CalamityModMusic/Interlude2MusicBox] Interlude 2" - Tooltip: Plays Calamity Mod OST - "Storms before the catastrophes", after the Moon Lord has been defeated. - } - - Interlude3: { - Label: "[i:CalamityModMusic/Interlude3MusicBox] Interlude 3" - Tooltip: Plays Calamity Mod OST - "Catastrophes before the calamity", after Yharon has been defeated. + Interludes: { + Label: "[i:CalamityModMusic/Interlude1MusicBox] Interludes" + Tooltip: + ''' + Enables the playing of three interlude tracks in-game: + Plays Calamity Mod OST - "Silence before the storms", after Calamitas Clone has been defeated. + Plays Calamity Mod OST - "Storms before the catastrophes", after the Moon Lord has been defeated. + Plays Calamity Mod OST - "Catastrophes before the calamity", after Yharon has been defeated. + ''' } MeterPosLock: { @@ -231,6 +246,11 @@ CalamityClientConfig: { ''' } + SetBonusDoubleTap: { + Label: "[i:VortexHelmet] Allow Double Tap for Armor Set Bonuses" + Tooltip: Allows all armor set bonuses to be triggered by the vanilla double-tap {$Key.DOWN} hotkey (or {$Key.UP} depending on your settings). + } + ShopNewAlert: { Label: "[i:GoldChest] New Shop Inventory Alerts" Tooltip: Adds an icon that appears over Town NPCs when they have new items in their shops. @@ -300,6 +320,17 @@ CalamityClientConfig: { ''' } + StutterFix: { + Label: "[i:TrifoldMap] Enable Stutter Fix" + Tooltip: + ''' + When enabled, upon entering a world, the entire world will be loaded at once. + This config causes Terraria to stop responding while the world is being loaded, do NOT close the game while this is occurring. + Once the game starts responding again, you will enter the world and be able to play without random stutters. + This config option is only recommended for players who can't stand random stutters while playing. + ''' + } + SulphuricWaterMeterPosX: { Label: "[i:LaserRuler] Sulphuric Water Poison Meter X Position" Tooltip: @@ -318,6 +349,30 @@ CalamityClientConfig: { ''' } + SunkenSeaBackgroundDistortion: { + Label: "[i:CalamityMod/SeaRemains] Sunken Sea Background Distortion" + Tooltip: + ''' + Whether or not the Sunken Sea's custom backgrounds should have an additional distortion shader applied to them. + This will give the illusion of underwater distortion. + [c/FF232C:Note that this will ONLY work if your "Wave Quality" setting is turned off.] + ''' + } + + TextEffects: { + Label: "[i:LeinforsAccessory] Extra Text Effects" + Tooltip: + ''' + When enabled, certain Calamity rarities will display extra visual effects within item names. + Disable if reduced visual clutter is desired. + ''' + } + + TileTextureBlendingQuality: { + Label: "[i:GlowPaint] Tile Merge Soft Blending" + Tooltip: Changes the quality of the soft-blending renderer used when different types of tiles merge together. + } + VanillaCooldownDisplay: { Label: "[i:HealingPotion] Display Vanilla Cooldowns" Tooltip: @@ -336,21 +391,6 @@ CalamityClientConfig: { Label: "[i:Book] Wiki Status Message" Tooltip: Enable or disable the status message promoting the Official Calamity Wiki that plays on world entry. } - - MultiThreadingType: { - Label: Sunken Sea Multi-Threading Option - Tooltip: - ''' - Option 0 will disable worldgen multi-threading. - Option 1 will enable ReLogic's multi-threading. - Option 2 will enable custom multi-threading. - ''' - } - - SunkenSeaMultiThreading: { - Label: Sunken Sea Multi Threading - Tooltip: "" - } } CalamityServerConfig: { @@ -410,7 +450,7 @@ CalamityServerConfig: { Label: "[i:Pwnhammer] Early Hardmode Progression Rework" Tooltip: ''' - Demon Altars no longer spawn ores and crimson/corruption blocks when broken. + Demon Altars no longer spawn ores when broken. Wall of Flesh spawns Cobalt and Palladium ore on first kill. The first mech boss you fight has 20% (10% in Expert and Master) less HP and damage and spawns Mythril and Orichalcum ore on first kill. The second mech boss you fight has 10% (5% in Expert and Master) less HP and damage and spawns Adamantite and Titanium ore on first kill. @@ -475,7 +515,7 @@ CalamityServerConfig: { RemoveLavaDropsFromLavaSlimes: { Label: "[i:LavaWaders] Remove Lava Drops From Lava Slimes" - Tooltip: When enabled, Lava Slimes will be replaced with a new Lava Slime that no longer drops lava. + Tooltip: When enabled, Lava Slimes will be prevented from dropping lava in Expert Mode. } RemoveReforgeRNG: { @@ -496,6 +536,15 @@ CalamityServerConfig: { ''' } + SimplifyAccessoryReforge: { + Label: "[i:Autohammer] Simplify Accessory Reforging" + Tooltip: + ''' + Makes accessory reforging simpler by restricting options to the following prefixes: + - Warding, Menacing, Lucky, Quick, Violent, Arcane, Silent, Invigorating, Dauntless + ''' + } + TownNPCSpawnRateMultiplier: { Label: "[i:GuideVoodooDoll] Town NPC Spawn Rate Multiplier" Tooltip: @@ -514,3 +563,64 @@ CalamityServerConfig: { ''' } } + +CooldownDisplayOptions: { + Tooltip: "" + + Full: { + Label: Full + Tooltip: Displays a circular bar around an icon which indicates cooldown duration + } + + Compact: { + Label: Compact + Tooltip: Displays a gradient over an icon which indicates cooldown duration + } + + Hidden: { + Label: Hidden + Tooltip: "" + } +} + +SetBonusDoubleTapOptions: { + Tooltip: "" + + On: { + Label: Always On + Tooltip: Always enables double-tap. Can be used in conjunction with Calamity's {$Keybinds.ArmorSetBonus.DisplayName} hotkey. + } + + Auto: { + Label: Auto + Tooltip: Automatically turns off double-tap as long as Calamity's {$Keybinds.ArmorSetBonus.DisplayName} hotkey is bound. + } + + Off: { + Label: Always Off + Tooltip: Always disables double-tap. Can be used to completely disable set bonus activation. + } +} + +TileBlendingQuality: { + Tooltip: "" + + Disable: { + Label: Disabled + Tooltip: Tile texture soft blending is disabled. + } + + Normal: { + Label: Enabled + Tooltip: Tile texture soft blending is enabled. + } + + High: { + Label: Enabled + Slices + Tooltip: + ''' + Tile texture soft blending is enabled and uses sliced rendering. + [c/F05A5A:Not recommended for low-end devices.] + ''' + } +} diff --git a/Localization/en-US/Mods.CalamityMod.GameTips.hjson b/Localization/en-US/Mods.CalamityMod.GameTips.hjson index 9d69d69161..d9a4d5bfa2 100644 --- a/Localization/en-US/Mods.CalamityMod.GameTips.hjson +++ b/Localization/en-US/Mods.CalamityMod.GameTips.hjson @@ -4,14 +4,11 @@ PlanetoidTip: You can find Planetoids high up in Space! AbyssTip: The Abyss can be found deep below the Sulphurous Sea. Be sure to have proper diving gear when exploring it. BanditTip: The Bandit won't steal from the poor. If you want to see them, you will need a lot of money to pique their attention. RefundTip: If you've been reforging a lot with the Goblin Tinkerer, it might pay off to give the Bandit a visit. -DrunkPrincessTip: The Drunk Princess is great to party with. If you carry her favorite vodka, she might move in. SeaKingTip: The Sea King used to like clams. He changed his mind when he got eaten by one. AmidiasBlessingTip: The Sea King can provide a bubble to aid with breathing underwater to any who ask for help. ArchmageTip: The Archmage can be freed if you manage to destroy the cell he was imprisoned in. BrimstoneWitchTip: The Brimstone Witch can enchant your items to grant them new powers. TitanHeartTip: Titan Hearts can be used as an offering at a Beacon found in the Astral Infection. -NightProvTip: Summoning the Profaned Goddess under the light of the moon massively empowers her strength and endurance. -DayEoLTip: Summoning the fae monarch under the light of day will start a vicious and persistent battle. BossEnemyTip: Killing the most harmless of enemies can awaken the wrath of a much stronger monster. Slay them at your own risk! RoDAbyssTip: Use the Rod of Discord in the Abyss at your own risk. The light left behind may attract the attention of unwanted foes. TerminusTip: An ancient artifact resides at the bottom of the Abyss. Use with great caution. @@ -22,7 +19,6 @@ FactoryChargingTip: Power Cell Factories and Charging Stations can be looted fro StealthTip: Wearing any rogue class armor lets you build stealth! SummonNerfTip: Holding a non-summoner weapon reduces the damage of your minions. DefenseDamageTip: Certain attacks will chip away at your defense, but it will quickly regenerate afterward. -PointBlankTip: Ranged weapons fired at point blank will do a lot more damage. RevengeanceTip: Need a challenge beyond Expert Mode? Try Revengeance Mode! BloodOrbTip: Blood Orbs collected during the Blood Moon can craft almost any potion. KeybindsTip: Modded controls can be bound in Settings. diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson index 9fbc0e3b60..100e290574 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.Wings.hjson @@ -3,25 +3,16 @@ AureateBooster: { Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} + {$CommonItemTooltip.PressUpToBooster} 'Mach speed with style!' ''' } -DrewsWings: { - DisplayName: Drew's Wings - Tooltip: - ''' - {$CommonItemTooltip.FlightAndSlowfall} - 'Absolutely Fabulous' - ''' -} - ElysianWings: { DisplayName: Elysian Wings Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} - 10% increased movement speed and grants immunity to lava Blessed by the Profaned Flame ''' } @@ -31,7 +22,7 @@ ExodusWings: { Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} - Grants permanent Empyrean Wrath and Empyrean Rage while wearing the Empyrean armor + Grants permanent Empyrean Wrath while wearing the Empyrean armor Pulsing with an alien heartbeat ''' } @@ -60,19 +51,47 @@ MOAB: { Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} + {$CommonItemTooltip.PressUpToBooster} 32% increased jump speed and allows auto-jump Grants the player cloud, blizzard, and sandstorm mid-air jumps + [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:Jetpack] [c/aaaaaa:jetpack] 'The Mother Of All Balloons' ''' } +MoonWalkers: { + DisplayName: Moon Walkers + TreadsName: Moon Boots + Tooltip: + ''' + {$CommonItemTooltip.FlightAndSlowfall} + 24% increased running acceleration + Provides the effects of [i:CalamityMod/AngelTreads] Angel Treads + Provides immunity to lava + [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:AngelWings] [c/aaaaaa:wings] + 'Hee hee!' + ''' +} + +SeraphTracers: { + DisplayName: Seraph Tracers + TreadsName: Seraph Treads + Tooltip: + ''' + {$CommonItemTooltip.FlightAndSlowfall} + 50% increased running acceleration + Provides the effects of [i:CalamityMod/AngelTreads] Angel Treads + Provides immunity to lava and damaging tiles, including [i:CalamityMod/AuricOre] Auric Ore + [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:AngelWings] [c/aaaaaa:wings] + 'Taking speed EVEN FURTHER BEYOND!' + ''' +} + SilvaWings: { DisplayName: Silva Wings Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} - Grants a scaling life regeneration boost while you remain in the air without resetting flight time - This boost caps at 8 HP/s after 15 seconds 'The purest of nature' ''' } @@ -105,43 +124,29 @@ TarragonWings: { Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} - +15 defense and +1 HP/s life regen 'Born of the jungle' ''' } -TracersCelestial: { - DisplayName: Celestial Tracers +VoidStriders: { + DisplayName: Void Striders + TreadsName: Void Kicks Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} - 24% increased running acceleration and greater mobility on ice - Provides the ability to walk on water, honey, and lava - Grants immunity to fire and lava + 36% increased running acceleration + Provides the effects of [i:CalamityMod/AngelTreads] Angel Treads + Provides immunity to lava + [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:AngelWings] [c/aaaaaa:wings] 'Ludicrous speed!' ''' } -TracersElysian: { - DisplayName: Elysian Tracers +WingsofRebirth: { + DisplayName: Wings of Rebirth Tooltip: ''' {$CommonItemTooltip.FlightAndSlowfall} - 36% increased running acceleration and greater mobility on ice - Provides the ability to walk on water, honey, and lava - Grants immunity to fire and lava - 'Ludicrous speed!' - ''' -} - -TracersSeraph: { - DisplayName: Seraph Tracers - Tooltip: - ''' - {$CommonItemTooltip.FlightAndSlowfall} - 50% increased running acceleration and greater mobility on ice - Provides the ability to walk on water, honey, and lava - Grants immunity to fire, lava, and harmful block effects - 'Taking speed EVEN FURTHER BEYOND!' + 'Resplendent to the very end' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 7644d07267..4a26fa734d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -2,9 +2,9 @@ Abaddon: { DisplayName: Abaddon Tooltip: ''' - 8% increased critical strike chance - Critical strikes explode, causing nearby enemies to ignite with Brimstone Flames - Greatly reduces the damage taken by the Brimstone Flames debuff + {$CommonItemTooltip.PercentIncreasedCritChance} + Critical strikes explode, igniting nearby foes with [cbuff:CalamityMod/BrimstoneFlames] + Reduces damage taken from [cbuff:CalamityMod/BrimstoneFlames] by {1}% ''' } @@ -26,15 +26,11 @@ AbyssalDivingSuit: { ''' Transforms the holder into an armored diver: Increases max movement speed and acceleration while underwater, but reduces it outside of water - The suit's armored plates increase damage reduction by 15% - Wearing this suit grants 15% damage reduction for hits under 50 damage - The suit can absorb up to 3 hits over 50 damage, and will take 3 minutes to regenerate - Reduces the damage caused by drowning in the abyss, and removes the bleed effect in the upper layers Grants the ability to swim, extends underwater breathing, emits light underwater, and improves mobility on ice - Provides a moderate amount of light and reduces breath loss in the abyss + Provides a moderate amount of light, reduces breath loss, and reduces damage caused by drowning in the abyss Abyss creatures are less likely to see you, mitigates the abyss' defense reduction, and lets you sink faster in liquids - Grants immunity to the sulphurous waters and Crush Depth's increased breath loss - Grants resistance to the increased breath loss caused by Hadopelagic Pressure + Grants immunity to the sulphurous waters and [cbuff:CalamityMod/CrushDepth]'s increased breath loss + Grants resistance to the increased breath loss caused by [cbuff:CalamityMod/HadopelagicPressure] ''' } @@ -43,7 +39,7 @@ AbyssalMirror: { Tooltip: ''' Enemies are less likely to target you, even in the abyss - Generate stealth 25% faster when standing still and 12% faster while moving + Generate stealth {0}% faster when standing still and {1}% faster while moving Grants the ability to dodge attacks, releasing a cloud of lumenyl fluid which damages and stuns nearby enemies ''' HoldShiftTooltip: @@ -58,7 +54,7 @@ AeroStone: { DisplayName: Aero Stone Tooltip: ''' - Provides an additional 50 flight time + Provides an additional {0} seconds of flight time You slowly recover flight time while in the air while not flying or gliding 'One of the ancient relics' ''' @@ -66,16 +62,16 @@ AeroStone: { Affliction: { DisplayName: Affliction - Tooltip: Gives all teammates +0.5 HP/s life regen, +10% max life, 7% damage reduction, 13 defense and 10% increased damage + Tooltip: Gives all teammates +{0} HP/s life regen, +{1}% max life, {2}% damage reduction, {3} defense and {4}% increased damage } -AlchemicalFlask: { - DisplayName: Alchemical Flask +AlchemicalDecanter: { + DisplayName: Alchemical Decanter Tooltip: ''' - All attacks inflict the Plague and reduces damage taken from the Plague + All attacks inflict the [cbuff:CalamityMod/Plague] and reduces damage taken from the [cbuff:CalamityMod/Plague] by {0}% Projectiles spawn plague seekers on enemy hits - Releases plague bees when damaged and douses you in honey + Releases plague bees and douses you in [cbuff:Honey] when damaged ''' } @@ -83,7 +79,7 @@ AlluringBait: { DisplayName: Alluring Bait Tooltip: ''' - Increases fishing power by 10 + Increases fishing power by {0} Increases the yield of potion ingredient fish ''' } @@ -92,7 +88,6 @@ AmalgamatedBrain: { DisplayName: Amalgamated Brain Tooltip: ''' - 5% increased damage Taking damage confuses nearby enemies and spawns a dank creeper The dank creeper flies above you, exploding into several shaderain clouds Grants the ability to dodge attacks @@ -105,10 +100,10 @@ AmbrosialAmpoule: { DisplayName: Ambrosial Ampoule Tooltip: ''' - +50 max life - Grants +1 HP/s life regen - Grants +2 to +6 HP/s life regen based on missing health - Standing still grants +1.5 HP/s life regen and +1 HP/s life regen when inflicted with a damage debuff + +{0} max life + Grants +{1} to +{2} HP/s life regen based on missing health + Grants the [cbuff:Honey] buff + Current boost: +[REGEN] HP/s Fire and sickness debuff durations are halved You emit yellow light if visibility is enabled ''' @@ -118,7 +113,7 @@ AncientFossil: { DisplayName: Ancient Fossil Tooltip: ''' - Increases mining speed by 10% + Increases mining speed by {0}% Provides immunity to damage from falling blocks ''' } @@ -138,13 +133,13 @@ AngelicAlliance: { ''' Call upon the force of heaven to empower your attacks and minions Courage, Enlightenment, Bliss. United in Judgement - +2 max minions, 15% increased summon damage, and 8% increased damage to all other classes - +2 HP/s life regen while airborne using wings - Press [KEY] to grace yourself in divinity for 15 seconds - While Divine Bless is active, for every minion you have, an archangel shall be summoned to aid you in combat - Each spawned angel will instantly restore 2 HP - All minion attacks inflict Banishing Fire, and you are granted a flat 4 HP/s regen - This effect has a cooldown of 1 minute + +{0} max minions, {1}% increased summon damage, and {2}% increased damage to all other classes + +{3} HP/s life regen while flight time is partially or fully expended + Press [KEY] to grace yourself with the [cbuff:CalamityMod/DivineBless] buff for {4} seconds + While active, an archangel is summoned for every minion you have + Archangels vaporize foes with heavenly light and each restore {5} HP upon spawning + Minion attacks inflict [cbuff:CalamityMod/BanishingFire], and you gain a flat {6} HP/s regen + This effect has a cooldown of {7} minute ''' } @@ -152,10 +147,11 @@ AngelTreads: { DisplayName: Angel Treads Tooltip: ''' - 36% increased running acceleration - Increased flight time and grants rocket flight - Provides water walking and extra mobility on ice - Grants immunity to On Fire! and temporary immunity to lava + Allows flight, super fast running, and extra mobility on ice + {0}% increased movement speed and {1}% increased flight time + Provides the ability to walk on water, honey & lava + Grants immunity to fire blocks and {2} seconds of immunity to lava + Reduces damage from touching lava 'Extreme speed!' ''' } @@ -165,9 +161,9 @@ AquaticEmblem: { Tooltip: ''' Most ocean enemies become friendly and allows breathing underwater - Being underwater boosts your defense over time, and slows movement speed - The defense boost and movement speed reduction slowly vanish outside of water - Maximum defense boost is 50 and movement speed reduction is 10% + Being underwater gradually increases defense but slows movement speed over {0} seconds + This effect slowly vanishes outside of water and resets while mounted + Maximum defense boost is {1} and movement speed reduction is {2}% Provides a small amount of light and moderately reduces breath loss in the abyss ''' } @@ -183,11 +179,11 @@ AquaticHeart: { FullTooltip: ''' Wow, you can swim now! - Being underwater increases max speed and acceleration by 15% - Greatly reduces breath loss and provides a small amount of light in the abyss - Attackers are inflicted with Glacial State - Gain a fragile ice barrier that grants 20% damage reduction for one hit - The ice shield regenerates after 30 seconds + Being underwater increases max speed and acceleration by {0}% + Greatly reduces breath loss and reduces the darkness intensity in the abyss + Attackers are inflicted with [cbuff:CalamityMod/GlacialState] + Gain a fragile ice barrier that grants {1}% damage reduction for one hit + The ice shield regenerates after {2} seconds ''' } @@ -195,7 +191,7 @@ ArcFlashRing: { DisplayName: Arc Flash Ring Tooltip: ''' - Attacks have a 6% chance to call down a lightning bolt for 4x damage + Attacks have a {0}% chance to call down a lightning bolt for {1}x damage The chance is reduced for each enemy an attack hits The bolt's damage is based on non-crit damage, but can itself crit Bolts are transparent and silent if visibility is disabled @@ -206,9 +202,9 @@ ArchaicPowder: { DisplayName: Archaic Powder Tooltip: ''' - Increases mining speed by 30% + Increases mining speed by {0}% Provides immunity to damage from falling blocks and dart traps - 65% resistance to all damage from traps + {1}% resistance to all damage from traps Does not stack with downgrades ''' } @@ -217,9 +213,9 @@ AscendantInsignia: { DisplayName: Ascendant Insignia Tooltip: ''' - Increases wing flight time by 50%, movement and jump speed by 15%, and acceleration by 1.5x - Pressing [KEY] grants you the power of ascension, providing infinite flight time for 4 seconds - Ascension has a 40 second cooldown + Increases wing flight time by {0}%, movement and jump speed by {1}%, and acceleration by {2}x + Pressing [KEY] grants you the power of ascension, providing infinite flight time for {3} seconds + Ascension has a {4} second cooldown ''' } @@ -227,17 +223,9 @@ AsgardianAegis: { DisplayName: Asgardian Aegis Tooltip: ''' + {$Common.KnockbackImmunity} Allows the ability to dash, empowered by a cosmic inferno This dash can ram through enemies without taking damage - Grants immunity to knockback and fire blocks, as well as multiple debuffs - ''' - HoldShiftTooltip: - ''' - On Fire!, Hellfire, Burning, Chilled, Frozen, Frostburn, Frostbite, Weak, - Broken Armor, Bleeding, Poisoned, Acid Venom, Sulphuric Poisoning, Slow, Confused, - Silenced, Cursed, Darkness, Webbed, Mighty Wind, Stoned, Armor Crunch, Blackout, - Brain Rot, Burning Blood, Heavy Bleeding, Laceration, Cursed Inferno, Brimstone Flames, - Shadowflame, Daybroken, Nightwither, Holy Flames, Voidfrost, God Slayer Inferno ''' } @@ -245,15 +233,9 @@ AsgardsValor: { DisplayName: Asgard's Valor Tooltip: ''' + {$Common.KnockbackImmunity} Allows the ability to ram dash This dash can ram through enemies without taking damage - Grants immunity to knockback and fire blocks, as well as multiple debuffs - ''' - HoldShiftTooltip: - ''' - On Fire!, Hellfire, Chilled, Frozen, Frostburn, Frostbite, Weak, - Broken Armor, Bleeding, Poisoned, Slow, Confused, Silenced, Cursed, - Darkness, Mighty Wind, Stoned, Brimstone Flames, Burning ''' } @@ -270,7 +252,7 @@ BadgeofBravery: { DisplayName: Badge of Bravery Tooltip: ''' - Increases melee damage and melee crit by 10% + Increases melee damage and critical strike chance by 10% Increases melee armor penetration by 5 ''' } @@ -284,12 +266,25 @@ Baroclaw: { ''' } +BatholithBangle: { + DisplayName: Batholith Bangle + Tooltip: + ''' + Magic enemy hits create a powerful granite flash that always critically strikes + This effect has a 10 second cooldown + Visual and audio effects are reduced if visibility is disabled + [c/0189D7:'The solid granite radiates energy throughout your body'] + ''' +} + BlackGlassBand: { DisplayName: Black Glass Band Tooltip: ''' - Enemy hits create an obsidian blast that always critically strikes - This effect has a 7 second cooldown, but is halved if the blast kills an enemy + Enemy hits create an obsidian flash that always critically strikes + This effect has a 5 second cooldown, but is halved if the flash kills an enemy + Visual and audio effects are reduced if visibility is disabled + [c/655DC5:'A shining band with boundless potential'] ''' } @@ -297,13 +292,13 @@ BlazingCore: { DisplayName: Blazing Core Tooltip: ''' + {$Common.KnockbackImmunity} The searing core of the Profaned Goddess Pressing [KEY] will activate a parry, encasing you in luminous profaned crystal Being hit shortly after encasement will shatter the crystal Upon shattering, holy stars spiral outwards and damage taken is negated After shattering, this damage reduction effect goes on cooldown Damage parried whilst on cooldown summons additional healing stars, and will not be reduced - {$Common.AbyssLightLevel2} ''' } @@ -311,6 +306,7 @@ BloodflareCore: { DisplayName: Bloodflare Core Tooltip: ''' + {$Common.KnockbackImmunity} Recovering defense damage heals you, each defense recovered gives 1 HP Taking damage converts at least half of your total defense in defense damage ''' @@ -322,13 +318,13 @@ BloodPact: { ''' Increases max HP by 25% Grants immunity to Bleeding, Burning Blood and Heavy Bleeding - Healing Potions are 25% more effective + Healing Potions are 33% more effective ''' } BloodstainedGlove: { DisplayName: Bloodstained Glove - Tooltip: Stealth strikes have +8 armor penetration and heal for 2 HP + Tooltip: Stealth strikes have +8 armor penetration and heal for 5 HP } BloodyWormScarf: { @@ -345,11 +341,10 @@ BloomStone: { DisplayName: Bloom Stone Tooltip: ''' - Grants between +1 HP/s and +3 HP/s life regen depending on time of day - Accelerates life regen based on time of day - Both of these effects are maximized from noon to sunset - Flowers grow on the grass you walk on - Random dye plants will grow while standing on grassless dirt + Healing Potions are 50% more effective, but provide their healing over time + Grappling hooks retract and pull the player 50% faster, and grow a flower at hookpoints + Touching a flower makes it burst into pollen which gives a temporary boost to potion healing over time + Potion healing slows drastically when at full health 'One of the ancient relics' ''' } @@ -401,10 +396,12 @@ ChaosStone: { DisplayName: Chaos Stone Tooltip: ''' - Mana Sickness from drinking mana potions is replaced by Mana Burn - Mana Burn deals damage over time relative to the intensity of the debuff - This debuff does not reduce your magic damage - 'One of the ancient relics' + Disables automatic potion consumption + Items that consume mana can be used even without the required mana amount + Mana usage can overflow into negative mana, causing you to both receive and inflict [cbuff:CalamityMod/ManaBurn] + The lower your mana, the more intense the manafire burns + Negative Mana is capped at your maximum mana amount + Current maximum intensity with your maximum mana: -[REGEN] HP/s, and burns enemies for [DAMAGE]% of dealt damage ''' } @@ -421,7 +418,7 @@ CoinofDeceit: { DisplayName: Coin of Deceit Tooltip: ''' - Stealth strikes only expend 85% of your max stealth + Stealth strikes only expend 90% of your max stealth 6% increased rogue crit chance ''' } @@ -431,14 +428,14 @@ CorrosiveSpine: { Tooltip: ''' 5% increased movement speed - Multiplies all sickness and water-related debuff damage by 1.25x + 25% increased Sickness and Water debuff damage All attacks irradiate enemies and reduces the severity of the sulphuric waters You burst into radioactive clouds when struck ''' } -CorruptFlask: { - DisplayName: Corrupt Flask +UnholyTonic: { + DisplayName: Unholy Tonic Tooltip: ''' Increases damage reduction by 4% and defense by 6 while in the corruption @@ -450,7 +447,6 @@ CounterScarf: { DisplayName: Counter Scarf Tooltip: ''' - 10% increased true melee damage Grants the ability to dash; dashing into an attack will cause you to dodge it After a successful dodge you must wait 30 seconds before you can dodge again ''' @@ -465,8 +461,8 @@ CrawCarapace: { ''' } -CrimsonFlask: { - DisplayName: Crimson Flask +ViciousTonic: { + DisplayName: Vicious Tonic Tooltip: ''' Increases damage reduction by 4% and defense by 6 while in the crimson @@ -480,7 +476,6 @@ CrownJewel: { ''' +1 HP/s life regen You gain an additional +1.5 HP/s life regen while afflicted with any debuff - Massively boosts natural life regen while afflicted with any debuff ''' } @@ -488,7 +483,7 @@ CryoStone: { DisplayName: Cryo Stone Tooltip: ''' - Multiplies all cold-based debuff damage by 1.5x + 50% increased Cold debuff damage Creates a rotating ice shield around you that damages and slows down enemies on contact 'One of the ancient relics' ''' @@ -532,6 +527,7 @@ DarkSunRing: { DisplayName: Dark Sun Ring Tooltip: ''' + {$Common.KnockbackImmunity} 12% increased damage +0.5 HP/s life regen and +2 max minions Increased minion knockback @@ -540,8 +536,8 @@ DarkSunRing: { HoldShiftTooltip: ''' During the day, grants +2 HP/s life regen - During the night, grants +20 defense - During an eclipse, grants +1 HP/s life regen and +10 defense + During the night, grants +16 defense + During an eclipse, grants +1 HP/s life regen and +8 defense ''' FlavorTooltip: "'Contains the power of the dark sun'" } @@ -570,10 +566,11 @@ DeificAmulet: { DisplayName: Deific Amulet Tooltip: ''' - Causes stars to fall and increases length of invincibility after taking damage - Grants bonus invincibility frames based on your missing health - This effect scales from 10 frames at full HP to 40 frames at 25% or less HP + Releases a burst of homing star-bees[TOGGLE] and drenches you in [cbuff:Honey] after taking damage + Increases the length of invincibility, with it increasing even more when at low health + [c/aaaaaa:Shift- this item in your inventory to toggle] [i:PanicNecklace] [c/aaaaaa:Panic Necklace's effect] ''' + ToggleEffect: ", increases movement speed," } DepthCharm: { @@ -581,11 +578,26 @@ DepthCharm: { Tooltip: ''' Reduces the damage caused by drowning in the abyss - Removes the bleed effect caused by the upper layers of the abyss Removes the increased breath loss of Crush Depth ''' } +DiamondOfTheDeep: { + DisplayName: Diamond of the Deep + Tooltip: + ''' + 60% increased Water debuff damage + Slowly accrue up to three different abyssal spirits + Dash to disperse the spirits and have them attack enemies + When dispersed [c/CB7AD7:below 50% life], the spirits support you instead + The spirits appear in order and have different effects based on color: + [c/3CB371: Explodes on impact and inflicts Crush Depth] / [c/CB7AD7:Heals for 8 HP] + [c/FF4500: Pierces enemies and inflicts Hellfire] / [c/CB7AD7:Increases defense by 10 temporarily] + [c/1E90FF: Hits multiple times and inflicts Hadopelagic Pressure] / [c/CB7AD7:Heals 5% of max HP] + Spirits are transparent and silent when visibility is toggled off + ''' +} + DimensionalSoulArtifact: { DisplayName: Dimensional Soul Artifact Tooltip: @@ -599,6 +611,7 @@ DraedonsHeart: { DisplayName: Draedon's Heart Tooltip: ''' + {$Common.KnockbackImmunity} {0}% reduced contact damage from enemies [NANODESC] With full Nanomachines, press [KEY] to heal {1} health over {2} {^2:second;seconds} @@ -672,7 +685,7 @@ ElectriciansGlove: { DisplayName: Electrician's Glove Tooltip: ''' - Stealth strikes summon sparks on enemy hits and heal you for 2 HP + Stealth strikes summon sparks on enemy hits and heal you for 10 HP Stealth strikes also have +8 armor penetration and deal 8% more damage ''' } @@ -690,20 +703,20 @@ ElementalGauntlet: { ''' } +ElementalinaBottle: { + DisplayName: Elemental in a Bottle + Tooltip: Summons a sand elemental to fight for you +} + ElysianAegis: { DisplayName: Elysian Aegis Tooltip: ''' + {$Common.KnockbackImmunity} Allows the ability to dash, empowered by holy fire This dash can ram through enemies without taking damage - Grants immunity to knockback, fire blocks, as well as multiple debuffs + 'Blessed by the Profaned Flame' ''' - HoldShiftTooltip: - ''' - On Fire!, Hellfire, Cursed Inferno, Shadowflame, Daybroken, - Holy Flames, Brimstone Flames, Burning - ''' - FlavorTooltip: "'Blessed by the Profaned Flame'" } EnchantedPearl: { @@ -732,7 +745,8 @@ EtherealTalisman: { 15% increased magic damage, 5% increased magic critical strike chance +150 max mana and 10% decreased mana usage Increases pickup range for mana stars - You automatically use mana potions when needed if visibility is on + You automatically use mana potions when needed + [c/aaaaaa:Shift- in your inventory to toggle] [i:ManaFlower] [c/aaaaaa:Mana Flower's effect] ''' } @@ -740,9 +754,9 @@ EvasionScarf: { DisplayName: Evasion Scarf Tooltip: ''' - 15% increased true melee damage Grants the ability to dash; dashing into an attack will cause you to dodge it After a successful dodge you must wait 30 seconds before you can dodge again + Has a shorter dash cooldown than most dashes ''' } @@ -769,6 +783,7 @@ FlameLickedShell: { DisplayName: Flame-Licked Shell Tooltip: ''' + {$Common.KnockbackImmunity} Pressing [KEY] will activate a parry, encasing you in rocks Being hit shortly after encasement will implode the rocks Upon implosion, a ring of brimstone hellfire is launched outwards and you receive 90% DR for that hit @@ -802,7 +817,7 @@ FrostFlare: { All attacks and projectiles inflict Frostbite Grants immunity to Frostburn, Chilled and Frozen Being above 50% life grants 10% increased damage - Being below 50% life grants 20 defense and 15% increased max movement speed and acceleration + Being below 50% life grants 15 defense and 15% increased max movement speed and acceleration Grants resistance against cold attacks ''' } @@ -821,7 +836,7 @@ FungalSymbiote: { Tooltip: ''' You grow mushrooms on the grass beneath you - Consuming mushrooms provides the Mushy buff, granting 8 defense and +1 HP/s life regen + Consuming mushrooms provides the Mushy buff, granting 5 defense and +1 HP/s life regen 10% increased damage while you have the Mushy buff ''' } @@ -833,7 +848,7 @@ GiantPearl: { You have a light aura around you Enemies within the aura are slowed down Enemies that remain within the aura are bombarded by homing prism shards - {$Common.AbyssLightLevel1} + {$Common.AbyssGlow} ''' } @@ -850,7 +865,7 @@ GiantTortoiseShell: { DisplayName: Giant Tortoise Shell Tooltip: ''' - Grants immunity to knockback + {$Common.KnockbackImmunity} 5% increased damage reduction and 10% reduced dash velocity Taking a hit restores dash velocity and reduces defense and damage reduction for 3 seconds ''' @@ -867,7 +882,11 @@ GladiatorsLocket: { GloveOfPrecision: { DisplayName: Glove of Precision - Tooltip: Decreases rogue attack speed by 15%, but increases damage by 10%, crit by 15% and velocity by 15% + Tooltip: + ''' + Decreases rogue attack speed by 15% + Increases rogue damage and critical strike chance by 10%, and velocity by 15% + ''' } GloveOfRecklessness: { @@ -900,7 +919,7 @@ HallowedRune: { HoldShiftTooltip: ''' [c/8ce0ff: Hallowed Power] [c/ccf1ff: grants 10% increased summon damage and rains stars on enemies] - [c/d08aff: Hallowed Defense] [c/eed4ff: grants 8 defense and 4% damage reduction] + [c/d08aff: Hallowed Defense] [c/eed4ff: grants 5 defense] [c/ff8cb5: Hallowed Regen] [c/ffccde: grants +1.5 HP/s life regen] ''' } @@ -928,10 +947,9 @@ HideofAstrumDeus: { DisplayName: Hide of Astrum Deus Tooltip: ''' - Taking damage or inflicting true melee strikes drops an immense amount of astral stars from the sky - Taking damage temporarily increases true melee damage by 30% + True melee strikes drops astral stars from the sky + Releases an explosion and temporarily increases true melee damage by 30% when damaged Boost duration scales with the amount of damage you took, up to 10 seconds - Attackers take damage and are inflicted with Astral Infection Nullifies the Astral Infection debuff ''' } @@ -940,9 +958,8 @@ HoneyDew: { DisplayName: Honey Dew Tooltip: ''' - +30 max life - Grants +1 HP/s life regen, and +1 HP/s life regen when inflicted with a damaging debuff - Standing still in Honey grants +1.5 HP/s life regen + +10 max life + Grants the Honey buff Sickness debuff durations are halved ''' } @@ -971,10 +988,9 @@ InfectedJewel: { Tooltip: ''' Passively grants +1 HP/s life regen - Grants 16 defense and +2 HP/s life regen while afflicted with any debuff - Massively boosts natural life regen while afflicted with any debuff + Grants 12 defense and +2 HP/s life regen while afflicted with any debuff Granted defense fades away quickly when not afflicted with any debuffs - Each debuff beyond the first grants 5 additional defense + Each debuff beyond the first grants 4 additional defense Nullifies the Astral Infection debuff 'A beautiful gemstone tarnished by spaceborne rot' ''' @@ -984,8 +1000,9 @@ InkBomb: { DisplayName: Ink Bomb Tooltip: ''' - Throws several ink bombs when hit that explode into ink - Gain a lot of stealth and confuse enemies when struck + Stealth generates 7% faster + Throws several ink bombs when hit that explode into ink and confuse enemies + Gain a lot of stealth when struck This effect has a 20 second cooldown before it can occur again ''' } @@ -995,8 +1012,8 @@ InterstellarStompers: { Tooltip: ''' 6% increased movement speed, 20% increased jump speed, and negates fall damage - Hold DOWN to increase your maximum fall speed - Hold [KEY] for 0.5 seconds while midair to charge up a superspeed slam + Hold {$Key.DOWN} to increase your maximum fall speed + Pressing [KEY] while midair charges up a superspeed slam over 0.33 seconds While falling, you ram through enemies and don't take contact damage Once you hit the ground, you create an explosion at your feet The explosion scales in both damage and size the longer you slam for @@ -1006,7 +1023,25 @@ InterstellarStompers: { IronBoots: { DisplayName: Iron Boots - Tooltip: Allows you to sink faster through liquids + Tooltip: + ''' + Hold {$Key.DOWN} to increase your maximum fall speed, even in water + Upon hitting the ground, a shockwave is created at your feet + The shockwave scales in both damage and size the longer you fall for + Negates fall damage + ''' +} + +IVDripOnTheRocks: { + DisplayName: IV Drip on the Rocks + Tooltip: + ''' + Multiplies most non-weapon, non-debuff damage by {0}x + Multiplies all weapon damage by {1}x + Counts as an alcohol stack toward Alcohol Poisoning + {$Common.AlcoholWarning} + '(drunken mumbling)' + ''' } JellyChargedBattery: { @@ -1036,8 +1071,9 @@ LeviathanAmbergris: { DisplayName: Leviathan Ambergris Tooltip: ''' - 20% increased dash velocity, and dash cooldown is 33% faster + 120% increased initial dash velocity, 33% faster dash cooldown, and greatly increased dash deceleration Your dashes are empowered by water, knocking back and damaging nearby enemies with viscous currents + Visual effects are reduced if visibility is disabled ''' } @@ -1054,23 +1090,12 @@ LivingDew: { DisplayName: Living Dew Tooltip: ''' - +50 max life - Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damaging debuff - Standing still in Honey grants +1.5 HP/s life regen + +25 max life + Grants the Honey buff Fire and sickness debuff durations are halved ''' } -LumenousAmulet: { - DisplayName: Lumenous Amulet - Tooltip: - ''' - Attacks inflict Crush Depth, and grants immunity to Crush Depth and Riptide - While in the abyss you gain 25% increased max life - {$Common.AbyssLightLevel2} - ''' -} - LuxorsGift: { DisplayName: Luxor's Gift Tooltip: @@ -1086,10 +1111,12 @@ ManaPolarizer: { DisplayName: Mana Polarizer Tooltip: ''' - Increases max mana by 50 and magic damage by 6% - -1.5 HP/s life regen if mana is above 50% of its maximum + Increases max mana by 50 + Provides life regeneration and magic damage that scales based on how much mana you have + Lower mana means more life regeneration, but less magic damage + These scale from -2 to 2 HP/sec, and 15% to 5% damage + The provided regeneration is halved when under Mana Sickness Magic projectiles steal enemy life while holding a magic weapon - The more mana you have, the more you heal ''' } @@ -1149,8 +1176,9 @@ NecklaceofVexation: { DisplayName: Necklace of Vexation Tooltip: ''' - 20% increased damage when under 50% life - All attacks inflict acid venom while wearing Reaver armor + Up to 30% increased damage the lower your life is + Current boost: [DAMAGE]% + All attacks inflict acid venom Revenge ''' } @@ -1169,7 +1197,7 @@ Nucleogenesis: { DisplayName: Nucleogenesis Tooltip: ''' - Increases your max number of mininons by 4 + Increases your max number of minions by 4 Grants immunity to Shadowflame and Irradiated 15% increased summon damage, and increased minion knockback Minions inflict a variety of debuffs @@ -1218,6 +1246,7 @@ OldDukeScales: { DisplayName: Old Duke's Scales Tooltip: ''' + {$Common.KnockbackImmunity} 10% increased damage reduction, max movement speed, and acceleration 25% increased dash velocity and length Adds a stamina tracker to the cooldown rack @@ -1240,7 +1269,6 @@ OrnateShield: { ''' Allows the ability to dash This dash can ram through enemies without taking damage - Grants immunity to Chilled, Frostburn, Frostbite, and Frozen ''' } @@ -1275,7 +1303,7 @@ PhantomicArtifact: { HoldShiftTooltip: ''' [c/8ce0ff: Phantomic Empowerment] [c/ccf1ff: grants 10% increased summon damage and throws knives at enemies] - [c/d08aff: Phantomic Shield] [c/eed4ff: grants 10 defense, 5% damage reduction and a 20% damage reduction bulwark] + [c/d08aff: Phantomic Shield] [c/eed4ff: grants 10 defense and a 20% damage reduction bulwark] [c/ff8cb5: Phantomic Regen] [c/ffccde: grants 1 HP/s life regen and occasionally drops phantom hearts which grant an additional 1 HP/s life regen] ''' } @@ -1348,6 +1376,17 @@ ProfanedSoulCrystal: { ''' } +ProtolithBangle: { + DisplayName: Protolith Bangle + Tooltip: + ''' + Ranged enemy hits create a marble flash that always critically strikes and can hit multiple enemies + This effect has a 7 second cooldown + Visual and audio effects are reduced if visibility is disabled + [c/C5B965:'The cold marble against your wrist puts your mind at ease'] + ''' +} + QuiverofNihility: { DisplayName: Quiver of Nihility Tooltip: @@ -1364,43 +1403,59 @@ Radiance: { Tooltip: ''' +70 max life - Increases life regen based on missing health - Grants +1 HP/s life regen, and +1 HP/s life regen when inflicted with a damaging debuff - Each additional debuff grants 8 defense, which slowly decays while not debuffed - Standing still grants +2 HP/s life regen - Grants 20 defense and stronger regeneration while afflicted with any debuff - The healing eventually slows down if debuffed for an extended period of time - Weaker DoT debuffs are harmless and halves the duration of most other debuffs + Provides greatly improved life regen, increasing with lost health + Gain increased defense from debuffs inflicted on you, and greatly reduces their effectiveness + Current boosts: +[REGEN] HP/s and [DEFENSE] defense. You emit shining blue light if visibility is enabled 'A once putrid crystal, now glimmering with immaculate purity' ''' + HoldShiftTooltip: + ''' + [c/CDF69C:Grants +2 to +5 HP/s life regen based on missing health] + [c/CDF69C:Recover an additional 6 HP/s while inflicted with a debuff] + [c/CDF69C:This eventually slows to 1.33 HP/s when debuffed for an extended time period] + [c/CDF69C:Grants the Honey buff] + [c/CDF69C:Grants 15 defense while afflicted with any debuff] + [c/CDF69C:Each additional debuff grants 5 defense, which slowly decays while not debuffed] + [c/CDF69C:Weak damaging debuffs are harmless and halves the duration of most other debuffs] + ''' } RadiantOoze: { DisplayName: Radiant Ooze Tooltip: ''' - Grants +2 to +6 HP/s life regen based on missing health + Grants +{0} to +{1} HP/s life regen based on missing health + Current boost: +[REGEN] HP/s You emit yellow light if visibility is enabled ''' } RaidersTalisman: { DisplayName: Raider's Talisman - Tooltip: Stealth strikes grant 10% critical strike chance to non-stealth strikes for 5 seconds + Tooltip: Stealth strikes grant 15% critical strike chance to non-stealth strikes for 10 seconds } RampartofDeities: { DisplayName: Rampart of Deities Tooltip: ''' - Causes stars to fall and increases length of invincibility after taking damage - Grants bonus invincibility frames based on your missing health - This effect scales from 10 frames at full HP to 40 frames at 25% or less HP - Being struck for over 200 damage grants 30 additional invincibility frames - Grants immunity to knockback - Puts a shell around the owner when below 50% life that reduces damage taken - Absorbs 25% of damage done to players on your team when above 25% life + {$Common.KnockbackImmunity} + Releases a blast of homing star-bees[TOGGLE] and drenches you in [cbuff:Honey] after taking damage + Increases the length of invincibility, with it increasing even more when at low health or taking high damage attacks + Reduces damage taken by 25% when below 50% life + Absorbs 25% of damage done to players on your team when you are above 25% life + [c/aaaaaa:Shift- this item in your inventory to toggle] [i:PanicNecklace] [c/aaaaaa:Panic Necklace's effect] + ''' + ToggleEffect: ", increases movement speed," +} + +RareElementalinaBottle: { + DisplayName: Rare Elemental in a Bottle + Tooltip: + ''' + Summons a sand elemental to heal you + ;D ''' } @@ -1414,13 +1469,13 @@ ReaperToothNecklace: { ''' } -Regenator: { - DisplayName: Regenator +Regenerator: { + DisplayName: Regenerator Tooltip: ''' - Your health cannot exceed 50% of its maximum + Your health cannot exceed {0}% of its maximum Increases length of invincibility after taking damage - Provides powerful special life regen to heal you for 8.5 HP/s + Provides powerful special life regen to heal you for {1} HP/s All normal life regen is negated and converted into damage Current damage boost: [DAMAGE]% ''' @@ -1440,7 +1495,6 @@ RottenBrain: { DisplayName: Rotten Brain Tooltip: ''' - 5% increased damage Taking damage spawns a dank creeper The dank creeper flies above you, exploding into several shaderain clouds ''' @@ -1448,16 +1502,16 @@ RottenBrain: { RottenDogtooth: { DisplayName: Rotten Dogtooth - Tooltip: Stealth strikes inflict Crumbling and deal 8% more damage + Tooltip: Stealth strikes inflict Crumbling for 2.5 seconds and deal 8% more damage } RoverDrive: { DisplayName: Rover Drive Tooltip: ''' - Gain a barrier with 20 health, which grants 10 defense while active + Gain a barrier with {0} health [ADREN] - If depleted, the barrier's health regenerates after not receiving damage for 10 seconds + The barrier will regenerate {1} seconds after being hit, taking {2} seconds to completely regenerate Getting hit resets the timer Can also be scrapped at an extractinator ''' @@ -1473,22 +1527,13 @@ RuinMedallion: { ''' } -RustyMedallion: { - DisplayName: Rusty Medallion - Tooltip: - ''' - Causes most ranged weapons to release acid droplets from the sky - Grants immunity to Irradiated - ''' -} - SandCloak: { DisplayName: Sand Cloak Tooltip: ''' Dashing creates a large protective sand veil which damages enemies inside it The sand veil lasts 15 seconds, but dissipates early if you dash again - The veil slowly follows you, and any player inside it gains 10 defense and 1.75x acceleration + The veil slowly follows you, and any player inside it gains 4 defense and 1.75x acceleration After dissipating, the sand veil has a 15 second cooldown before it can be used again ''' } @@ -1498,7 +1543,18 @@ SandSharkToothNecklace: { Tooltip: ''' Increases armor penetration by 10 - 6% increased damage + 10% increased damage + ''' +} + +ScionsCurio: { + DisplayName: Scions Curio + Tooltip: + ''' + Ranged hits increase the effectiveness of the Irradiated debuff + Irradiated damage over time scales off of your ranged damage and crit chance + On kill, enemies burst, spreading Irradiated + Taking damage causes the curio to explode in retaliation ''' } @@ -1506,7 +1562,7 @@ ScuttlersJewel: { DisplayName: Scuttler's Jewel Tooltip: ''' - Stealth strike projectiles spawn a jewel spike when destroyed + Stealth strike projectiles spawn a jewel spike on hit or when destroyed Can also be broken down at an extractinator ''' } @@ -1518,7 +1574,7 @@ SeaSpiritAmulet: { Slowly accumulate up to eight spirit orbs that follow you Spirits disperse when dashing If below 50% life, they will heal you, otherwise they will attack nearby enemies - Multiplies all water debuff damage by 1.35x + 35% increased Water debuff damage Spirit orbs are transparent and silent if visibility is disabled ''' } @@ -1600,8 +1656,10 @@ SlagsplitterPauldron: { DisplayName: Slagsplitter Pauldron Tooltip: ''' - You gain 10% damage reduction while dashing, and enemies are inflicted with Armor Crunch - Your dashes are empowered by fire, shredding enemies near you with violent explosions + Your dashes become empowered by flame, erupting on contact with enemies + Grants immunity to knockback and 10% damage reduction while dashing + Enemies hit by your dashes have their armor crushed + Visual effects are reduced if visibility is disabled ''' } @@ -1628,7 +1686,7 @@ SpiritGlyph: { HoldShiftTooltip: ''' [c/8ce0ff: Spirit Power] [c/ccf1ff:grants 10% increased summon damage] - [c/d08aff: Spirit Defense] [c/eed4ff:grants 6 defense and 3% damage reduction] + [c/d08aff: Spirit Defense] [c/eed4ff:grants 3 defense] [c/ff8cb5: Spirit Regen] [c/ffccde:grants +1 HP/s life regeneration] ''' } @@ -1677,13 +1735,13 @@ StatisNinjaBelt: { DisplayName: Statis' Ninja Belt Tooltip: ''' - 32% increased jump speed, allows auto-jump, and negates fall damage - Increases movement acceleration and deceleration by 1.75x - Increases movement speed by 1.15x. This bonus applies to running boot accessories - Grants the ability to swim, climb walls, dash, and dodge attacks - Provides light when worn - {$Common.AbyssLightLevel1} + Provides a high-speed dash + 10% increased movement speed, 32% increased jump speed, allows auto-jump, and negates fall damage + Increases movement acceleration and deceleration by 1.6x + Grants the ability to swim[TOGGLE] and dodge attacks + [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:ClimbingClaws] [c/aaaaaa:Climbing Claws] ''' + ToggleEffect: ", climb walls," HoldShiftTooltip: "{$Common.DodgeInformation}" } @@ -1691,14 +1749,14 @@ StatisVoidSash: { DisplayName: Statis' Void Sash Tooltip: ''' - 32% increased jump speed, allows auto-jump, and negates fall damage - Increases movement acceleration and deceleration by 1.75x - Increases movement speed by 1.15x. This bonus applies to running boot accessories - Grants the ability to swim, climb walls, dash, and dodge attacks - Dashes leave homing scythes in your wake - Provides light when worn - {$Common.AbyssLightLevel1} + Provides a high-speed dash + 20% increased movement speed, 32% increased jump speed, allows auto-jump, and negates fall damage + Increases movement acceleration and deceleration by 1.85x + Grants the ability to swim[TOGGLE] and dodge attacks + Visual effects are reduced if visibility is disabled + [c/aaaaaa:Shift- this item in your inventory to toggle the] [i:ClimbingClaws] [c/aaaaaa:Climbing Claws] ''' + ToggleEffect: ", climb walls," HoldShiftTooltip: "{$Common.DodgeInformation}" } @@ -1742,8 +1800,8 @@ StatMeter: { AttackSpeed: Attack Speed: {0}% WhipMeleeInheritance: " [{0}% from melee]" // Class stats - RangedStats: Ammo Consumption Chance: {0} - MagicStats: Mana Usage: {0}% | Mana Regen: {1} + AmmoStats: Ammo Consumption Chance: {0}% + ManaStats: Mana Usage: {0}% | Mana Regen: {1} SummonStats: Minion Slots: {0} | Sentry Slots: {1} WhipStats: Whip Range: {0}% RogueStats: @@ -1767,10 +1825,10 @@ StatMeter: { MiscStats: Aggro: {0} | Luck: {1}% AbyssStats: ''' - Abyss Light Strength: {0} - Breath Lost Per Tick: {1} | Breath Loss Rate: {2} - Life Lost Per Tick at Zero Breath: {3} - Defense Lost From Pressure: {4} + Abyss Darkness: {0} | Player Glow: {1}x | Flashlight Width: {2}x + Breath Loss Rate: {3} + Life Lost Per Tick at Zero Breath: {4} + Defense Lost From Pressure: {5} ''' AbyssStatsHidden: Abyss stats are only displayed while in the Abyss } @@ -1790,7 +1848,7 @@ SupremeBaitTackleBoxFishingStation: { ''' Increases fishing power by 50 Fishing line will never break and decreases chance of bait consumption - Allows fishing in lava and detects hooked fish + Allows fishing in lava ''' } @@ -1808,8 +1866,8 @@ TheAbsorber: { DisplayName: The Absorber Tooltip: ''' + {$Common.KnockbackImmunity} {0}% increased movement and jump speed - Grants immunity to knockback Attackers take immense damage and are afflicted with a crippling sickness debuff Using a healing potion will spawn a green aura that lasts for {1} seconds Walking into the aura removes all debuffs once and grants {2} HP/s regen, {3}% damage, and {4}% damage reduction @@ -1821,12 +1879,13 @@ TheAmalgam: { DisplayName: The Amalgam Tooltip: ''' - 15% increased damage + All attacks inflict a variety of debuffs, 300% increased elemental debuff damage Most buffs last twice as long, and persist after dying - Taking damage inflicts several debuffs on nearby enemies and spawns a dank creeper + Taking damage confuses nearby enemies and spawns a dank creeper The dank creeper flies above you, exploding into several shaderain clouds Grants the ability to dodge attacks After dodging, summon damage and crit chance are boosted by 10% + 'You have no idea how it's staying together' ''' HoldShiftTooltip: "{$Common.DodgeInformation}" } @@ -1846,10 +1905,10 @@ TheCamper: { DisplayName: The Camper Tooltip: ''' - You deal 90% less damage unless stationary + You deal 50% less damage unless stationary Standing still grants buffs depending on held item, and creates a damaging aura around you While moving, you regenerate health as if standing still - {$Common.AbyssLightLevel1} + {$Common.AbyssGlow} when standing still 'In rest may we find victory' ''' } @@ -1860,7 +1919,7 @@ TheCommunity: { ''' [STATS] 'The heart of (most of) the Terraria community' - [c/B00BA5:Thank you to all of my supporters who made this mod a reality!] + Thank you to all of our supporters who made this mod a reality! ''' StatsList: ''' @@ -1876,10 +1935,9 @@ TheEvolution: { DisplayName: The Evolution Tooltip: ''' - Reflects projectiles that hit you, negating their damage and dealing 10x damage to enemies - {$Common.ReflectInformation} - Reflecting a projectile grants +6 HP/s life regen for 5 seconds and grants maximum natural life regen - Getting hit by the same enemy projectile type during cooldown will resist its damage by 20% + Allows you to dodge projectiles, reflecting highly damaging mirror shards back at enemies + {$Common.DodgeInformation} + Getting hit by the same enemy projectile type during cooldown will resist its damage by 25% ''' } @@ -1896,10 +1954,11 @@ TheSponge: { DisplayName: The Sponge Tooltip: ''' - Gain a barrier with 180 health - The barrier grants 30 defense and 10% damage reduction while active + {$Common.KnockbackImmunity} + Gain a barrier with {0} health + The barrier grants {1}% damage reduction while active [ADREN] - Once depleted, the barrier will regenerate 9 seconds after being hit + The barrier will regenerate {2} seconds after being hit, taking {3} seconds to completely regenerate Getting hit resets the timer ''' ShieldAdren: Halved Adrenaline loss if all damage is absorbed @@ -1932,7 +1991,7 @@ ToxicHeart: { ''' Your heart beats with the plague, pulsing outside of your body Pulse frequency scale with regen, and pulses that kill enemies pulse again to heal you - Multiplies all sickness debuff damage by 1.5x + 50% increased Sickness debuff damage Effects are transparent and silent if visibility is disabled ''' } @@ -1941,9 +2000,9 @@ TrinketofChi: { DisplayName: Trinket of Chi Tooltip: ''' - Increases damage reduction by 4% if you avoid taking damage for 5 seconds + Increases damage reduction by 8% if you avoid taking damage for 10 seconds This buff expires on hit - +1 HP/s life regen for teammates + +1 HP/s life regen for you and your teammates ''' } @@ -1961,8 +2020,11 @@ VampiricTalisman: { Tooltip: ''' Rogue critical strikes steal enemy life - 12% increased rogue damage + Stealth strikes grant 15% critical strike chance and increased lifesteal to non-stealth strikes for 10 seconds + Stealth strikes inflict Heavy Bleeding and Armor Crunch, and deal 8% more damage + 'Possessing the talisman makes you yearn for blood' ''' + YearningForBlood: THIS ENDLESS HUNGER WON'T END } VeneratedLocket: { @@ -1994,9 +2056,9 @@ VoidofExtinction: { DisplayName: Void of Extinction Tooltip: ''' - 13% increased critical strike chance - Critical strikes explode, igniting enemies with Brimstone Flames - Partially resist the Brimstone Flames debuff + {$CommonItemTooltip.PercentIncreasedCritChance} + Critical strikes explode, igniting nearby foes with [cbuff:CalamityMod/BrimstoneFlames] + Reduces damage taken from [cbuff:CalamityMod/BrimstoneFlames] by {1}% ''' } @@ -2013,35 +2075,25 @@ WarbanneroftheRighteous: { DisplayName: Warbanner of the Righteous Tooltip: ''' - Damage is increased by 20% when close to enemies, but decreased by 60% when none are nearby + Multiplies all damage based on how close you are to enemies + Maximum damage boost is 15%, minimum damage boost is -15% Emit a blazing aura that burns and repels nearby enemies Enemies take increasing damage the closer they are to you and the longer they are near you Effects are transparent and silent if visibility is disabled ''' } -WifeinaBottle: { - DisplayName: Elemental in a Bottle - Tooltip: Summons a sand elemental to fight for you -} - -WifeinaBottlewithBoobs: { - DisplayName: Rare Elemental in a Bottle - Tooltip: - ''' - Summons a sand elemental to heal you - ;D - ''' -} - WulfrumAcrobaticsPack: { DisplayName: Wulfrum Acrobatics Pack Tooltip: ''' - Transforms equipped hooks into a wulfrum slingshot + Provides a wulfrum slingshot grappling hook + This slingshot's stats scale with your equipped hook + If the hook has special effects, the slingshot also benefits from them The slingshot allows for advanced rope-swinging physics + Hold {$Key.UP} or {$Key.DOWN} to retract or extend the slingshot's rope Automatically grapples nearby walls if a lethal fall is detected - This safety feature won't activate if DOWN is held + This safety feature won't activate if {$Key.DOWN} is held 8% increased movement speed ''' } @@ -2061,6 +2113,7 @@ YharimsGift: { DisplayName: Yharim's Gift Tooltip: ''' + {$Common.KnockbackImmunity} Flaming meteors rain down after getting hit Volatile dragon dust trails behind you Increases damage and movement speed by 15% @@ -2081,11 +2134,6 @@ AbandonedWulfrumHelmet: { ''' } -CrystalHeartVodka: { - DisplayName: Crystal Heart Vodka - Tooltip: "'Tastes like strawberry cream liqueur (and estrogen)'" -} - GhostBracelet: { DisplayName: Ghost Bracelet Tooltip: Wow.... It looks at me with its hollow eyes full of curiosity @@ -2101,6 +2149,11 @@ HapuFruit: { Tooltip: "'A fruit that calms your nerves (may have unintended side effects)'" } +LucisSight: { + DisplayName: Luci's Sight + Tooltip: "'Fashionable glasses? In Earthia's current economy?!'" +} + OracleHeadphones: { DisplayName: Oracle Headphones Tooltip: "'Hey game's over!'" @@ -2115,15 +2168,6 @@ Popo: { ''' } -PunchCard: { - DisplayName: Punch Card - Tooltip: "[c/842593:'Please... please get world record...']" - // These are used to spawn the item via chat -- both must be all lower case for the detection to work - SpawnText1: it's late - SpawnText1Alt: its late - SpawnText2: go to bed -} - SharkyPlush: { DisplayName: Sharky Plush Tooltip: "[c/696969:'Look out, for the force without form...']" @@ -2143,7 +2187,7 @@ XyksBlessingBlue: { DisplayName: Xyk's Blessing (Blue) Tooltip: ''' - Applies visual effects to your dashes and deaths + Applies visual effects to your dashes, wings, and deaths to transform 'It's simply too much to turn back now; passion and time have long since stained it. [c/5f8ae1:Have I always been so selfish?'] @@ -2154,7 +2198,7 @@ XyksBlessingOrange: { DisplayName: Xyk's Blessing (Orange) Tooltip: ''' - Applies visual effects to your dashes and deaths + Applies visual effects to your dashes, wings, and deaths to transform 'Even so, the march of time waits for none. Recall that feeling of fulfillment, and show it to the world. [c/E1B65F:Prove that it was never a waste.'] diff --git a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson index 31f7ee1828..3ba3ea1a9b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson @@ -12,7 +12,7 @@ BloodfireArrow: { Tooltip: ''' High-velocity arrows with a blood soaked tip - Firing these arrows will drain your health + Firing these arrows will drain your health and boost the arrow damage by 30% Accelerates your natural life regen and heals you on hit ''' } @@ -21,9 +21,9 @@ BloodfireBullet: { DisplayName: Bloodfire Bullet Tooltip: ''' - Passes through tiles and accelerates your natural life regen on hit - Deals bonus damage based on your current life regen and natural life regen - This damage caps at 35 + Passes through tiles and accelerates your natural life regen on hit based on how powerful the hit was + Deals bonus damage based on your current natural life regen + This damage caps at 1.1x ''' } @@ -58,7 +58,11 @@ ElysianArrow: { FlashRound: { DisplayName: Flash Round - Tooltip: Emits a wide-reaching concussive blast which briefly confuses enemies + Tooltip: + ''' + A ricocheting bullet that deals more damage with each bounce + The damage bonus is 1.13x or +2 flat damage per bounce, depending on which is stronger + ''' } GodSlayerSlug: { @@ -92,14 +96,22 @@ HolyFireBullet: { DisplayName: Holy Fire Bullet Tooltip: ''' - Profaned bullets that explode on impact, dealing extra damage - The explosion grows weaker the further the bullet travels + Profaned bullets that deal 1.15x damage and explode on impact + The explosion is larger and the bullet deals increased damage if impact occurs immediately after firing + The extra damage bonus caps at 1.15x ''' } HyperiusBullet: { DisplayName: Hyperius Bullet - Tooltip: Dazzling multicolor bullets that split into swirling lights on impact + Tooltip: + ''' + Dazzling multicolor bullets that split into swirling lights on impact + Damage that would be dealt from the bullets is instead stored on the target + As more damage is stored, it will begin to overflow, slowly releasing and damaging the enemy + Attacks from sources other than Hyperius Bullets will release some of the charge + Releasing charge in this way deals 20% more damage + ''' } IcicleArrow: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index 91905b3659..35c60fa863 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -2,21 +2,22 @@ AstralBreastplate: { DisplayName: Astral Breastplate Tooltip: ''' - 7% increased damage - +80 max mana and +20 max life + {$CommonItemTooltip.IncreasesMaxManaBy} + {$CommonItemTooltip.PercentIncreasedDamage@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} ''' } AstralHelm: { DisplayName: Astral Helm - Tooltip: 5% increased damage and 10% increased critical strike chance + Tooltip: "{$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1}" SetBonus: ''' - +3 max minions - 10% increased damage and critical strike chance + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedDamageCritChance@1} Detects nearby creatures, enemy projectiles, danger sources, and treasure Whenever you crit an enemy, a barrage of stars will rain down - This effect has a 1 second cooldown before it can trigger again + This effect has a {2} {^2:second;seconds} cooldown before it can trigger again ''' } @@ -24,8 +25,8 @@ AstralLeggings: { DisplayName: Astral Leggings Tooltip: ''' - 5% increased damage - 15% increased movement speed + {$CommonItemTooltip.PercentIncreasedDamage} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -33,79 +34,59 @@ BrimflameBoots: { DisplayName: Brimflame Boots Tooltip: ''' - 5% increased magic damage - 5% increased movement speed + {$CommonItemTooltip.PercentIncreasedMagicDamage} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} + ''' +} + +BrimflameCowl: { + DisplayName: Brimflame Cowl + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamageCritChance@2} + Immunity to [cbuff:OnFire], [cbuff:CalamityMod/BrimstoneFlames] and [cbuff:Frostburn] + ''' + SetBonus: + ''' + {$CommonItemTooltip.PercentIncreasedMagicDamageCritChance} + [c/{1}:Brimflame Frenzy - {2} for {3} {^3:second;seconds} of {$CommonItemTooltip.PercentIncreasedMagicDamage@4}] + [c/FF9173:However, this inflicts rapid life loss and disables mana regeneration and mana potions] + [c/FF9173:This effect can be toggled off and has a cooldown of {5} {^5:second;seconds}] ''' } BrimflameRobes: { DisplayName: Brimflame Robes - Tooltip: 5% increased magic damage and critical strike chance -} - -BrimflameScowl: { - DisplayName: Brimflame Cowl - Tooltip: - ''' - 5% increased magic damage and critical strike chance - Increases maximum mana by 80 and reduces mana usage by 10% - Immunity to On Fire!, Brimstone Flames and Frostburn - ''' - SetBonus: - ''' - Grants an additional 15% increased magic damage and critical strike chance - Press {0} to trigger a brimflame frenzy effect - While under this effect, you get an additional 40% increase to magic damage - However, this inflicts rapid life loss and disables mana regeneration and mana potions - This can be toggled off, however, brimflame frenzy has a 30 second cooldown - ''' -} - -CirrusDress: { - DisplayName: Cirrus' Dress - Tooltip: - ''' - 5% increased magic damage and critical strike chance - 20% decreased movement speed and increases maximum fall speed to 61 mph - Allows for drinking 5 alcohols before your liver is poisoned - [c/B00BA5:'Here, this should help you drink a lot more than usual!'] - 'You feel thick...' - ''' + Tooltip: "{$CommonItemTooltip.PercentIncreasedMagicDamageCritChance}" } DaedalusBreastplate: { DisplayName: Daedalus Breastplate - Tooltip: 3% increased damage and critical strike chance + Tooltip: "{$CommonItemTooltip.PercentIncreasedDamage}" } DaedalusHeadMagic: { DisplayName: Daedalus Hood Tooltip: ''' - 13% increased magic damage and 7% increased magic critical strike chance - 10% reduced mana usage and +60 max mana - ''' - SetBonus: - ''' - 5% increased magic damage - You have a 10% chance to absorb physical attacks and projectiles when hit - If you absorb an attack you are healed for 1/2 of that attack's damage + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} ''' + SetBonus: You have a {0}% chance to heal back {1}% of taken damage } DaedalusHeadMelee: { DisplayName: Daedalus Helm Tooltip: ''' - 15% increased melee damage - 10% increased melee critical strike chance + {$CommonItemTooltip.PercentIncreasedMeleeDamageCritChance} + {$CommonItemTooltip.PercentIncreasedMeleeSpeed@1} ''' SetBonus: ''' - 10% increased melee speed - Enemies are more likely to target you - You reflect projectiles back at enemies - Reflected projectiles deal 50% less damage to you + {$Common.AggroBoost} + You reflect projectiles back at enemies, negating their damage {$Common.ReflectInformation} ''' } @@ -114,37 +95,37 @@ DaedalusHeadRanged: { DisplayName: Daedalus Headgear Tooltip: ''' - 13% increased ranged damage and 7% increased ranged critical strike chance - Reduces ammo usage by 20% - ''' - SetBonus: - ''' - 5% increased ranged damage - Getting hit causes you to emit a blast of crystal shards + {$CommonItemTooltip.PercentIncreasedRangedDamage} and {$CommonItemTooltip.PercentIncreasedRangedCritChance@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} ''' + SetBonus: Getting hit causes you to emit a blast of crystal shards } DaedalusHeadRogue: { DisplayName: Daedalus Facemask Tooltip: ''' - 13% increased rogue damage and 7% increased rogue critical strike chance - 15% increased rogue velocity and 5% increased movement speed + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$Common.RogueVelocity@2} and {$CommonItemTooltip.PercentIncreasedMovementSpeed@3} ''' SetBonus: ''' - 5% increased rogue damage - +105 maximum stealth + {$Common.RogueStealth} Rogue projectiles throw out crystal shards as they travel ''' } DaedalusHeadSummon: { DisplayName: Daedalus Mask - Tooltip: 5% increased summon damage + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + ''' SetBonus: ''' - 20% increased summon damage and +2 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} A daedalus crystal floats above you to protect you ''' } @@ -153,8 +134,8 @@ DaedalusLeggings: { DisplayName: Daedalus Leggings Tooltip: ''' - 3% increased critical strike chance - 10% increased movement speed + {$CommonItemTooltip.PercentIncreasedCritChance} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -162,9 +143,9 @@ FathomSwarmerBoots: { DisplayName: Fathom Swarmer Greaves Tooltip: ''' - 8% increased summon damage + {$CommonItemTooltip.PercentIncreasedSummonDamage} Grants the ability to swim - Movement speed increased by 40% while submerged in liquid + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} while submerged in liquid ''' } @@ -172,9 +153,8 @@ FathomSwarmerBreastplate: { DisplayName: Fathom Swarmer Breastplate Tooltip: ''' - 6% increased damage reduction - Increases your max number of minions by 1 - 10% increased summon damage + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Reduces defense loss within the Abyss ''' } @@ -183,29 +163,31 @@ FathomSwarmerVisage: { DisplayName: Fathom Swarmer Visage Tooltip: ''' - Increases your max number of minions by 1 - 8% increased summon damage + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Provides breathing and light underwater + Greatly enhances visibility in the abyss ''' SetBonus: ''' - 10% increased summon damage and +2 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Grants the ability to climb walls - 20% increased summon damage, +10 defense and +2.5 HP/s life regen while underwater + {$CommonItemTooltip.PercentIncreasedSummonDamage@2}, +{3} defense and +{4} HP/s life regen while underwater Provides a moderate amount of light and moderately reduces breath loss in the abyss ''' } ForbiddenCirclet: { DisplayName: Forbidden Circlet - Tooltip: 10% increased summon damage and 15% increased rogue velocity + Tooltip: "{$CommonItemTooltip.PercentIncreasedSummonDamage} and {$Common.RogueVelocity@1}" SetBonus: ''' - +40 maximum stealth - Press {0} to call an ancient storm to the cursor location - The ancient storm costs {1} mana and benefits from both summon and rogue bonuses - Rogue stealth strikes spawn homing eaters on enemy hits - Rogue and summon attacks will scale off of the stat with a higher boost + {$Common.RogueStealth} + {1} to call an ancient storm to the cursor location + The ancient storm costs {2} mana and benefits from both summon and rogue bonuses + Rogue stealth strikes will tag enemies, causing summons to spawn homing eaters on hit + Using summon weapons no longer reset your stealth Minions no longer deal less damage while wielding rogue weapons ''' } @@ -214,12 +196,12 @@ HydrothermicArmor: { DisplayName: Hydrothermic Armor Tooltip: ''' - +20 max life - 8% increased damage and 4% increased critical strike chance + {$CommonItemTooltip.PercentIncreasedDamage} + Grants immunity to lava and [cbuff:OnFire] ''' CommonSetBonus: ''' - Inferno effect when below 50% life + Inferno effect when below {0}% life You emit a blazing explosion when you are hit ''' } @@ -228,13 +210,13 @@ HydrothermicHeadMagic: { DisplayName: Hydrothermic Mask Tooltip: ''' - 12% increased magic damage, +100 max mana, and 10% increased magic critical strike chance - Grants immunity to fire and lava + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} ''' SetBonus: ''' - 5% increased magic damage and 15% reduced mana usage Magic attacks summon damaging and healing flare orbs on hit + {$HydrothermicArmor.CommonSetBonus} ''' } @@ -242,15 +224,14 @@ HydrothermicHeadMelee: { DisplayName: Hydrothermic Helm Tooltip: ''' - 17% increased melee damage and 10% increased melee critical strike chance - Melee attacks and melee projectiles inflict on fire - Grants immunity to fire and lava + {$CommonItemTooltip.PercentIncreasedMeleeDamage} and {$CommonItemTooltip.PercentIncreasedMeleeCritChance@1} + {$CommonItemTooltip.PercentIncreasedMeleeSpeed@2} ''' SetBonus: ''' - 15% increased melee speed - Enemies are more likely to target you + {$Common.AggroBoost} Melee attacks and projectiles cause chaos flames to erupt on enemy hits + {$HydrothermicArmor.CommonSetBonus} ''' } @@ -258,14 +239,13 @@ HydrothermicHeadRanged: { DisplayName: Hydrothermic Headgear Tooltip: ''' - 12% increased ranged damage and 10% increased ranged critical strike chance - Reduces ammo usage by 25% - Grants immunity to fire and lava + {$CommonItemTooltip.PercentIncreasedRangedDamage} and {$CommonItemTooltip.PercentIncreasedRangedCritChance@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} ''' SetBonus: ''' - 5% increased ranged damage - You fire a homing chaos flare when using ranged weapons every 0.33 seconds + You fire a homing chaos flare when using ranged weapons every {0} seconds + {$HydrothermicArmor.CommonSetBonus@1} ''' } @@ -273,15 +253,14 @@ HydrothermicHeadRogue: { DisplayName: Hydrothermic Hood Tooltip: ''' - 12% increased rogue damage and 10% increased rogue critical strike chance - 5% increased movement speed - Grants immunity to fire and lava + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} ''' SetBonus: ''' - 5% increased rogue damage - +110 maximum stealth - Rogue weapons unleash a volley of homing chaos flames around the player every 2 seconds + {$Common.RogueStealth} + Rogue weapons unleash a volley of homing chaos flames around the player every {1} seconds + {$HydrothermicArmor.CommonSetBonus@2} ''' } @@ -289,13 +268,15 @@ HydrothermicHeadSummon: { DisplayName: Hydrothermic Helmet Tooltip: ''' - 5% increased summon damage and increased minion knockback - Grants immunity to fire and lava + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} ''' SetBonus: ''' - 40% increased summon damage and +2 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Summons a hydrothermic vent to protect you + {$HydrothermicArmor.CommonSetBonus@2} ''' } @@ -303,8 +284,8 @@ HydrothermicSubligar: { DisplayName: Hydrothermic Subligar Tooltip: ''' - 5% increased critical strike chance - 10% increased movement speed + {$CommonItemTooltip.PercentIncreasedCritChance} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -312,9 +293,8 @@ LunicCorpsBoots: { DisplayName: Lunic Corps Boots Tooltip: ''' - 15% increased movement speed - 5% increased ranged critical strike chance - 10% increased max movement speed and acceleration + {$CommonItemTooltip.PercentIncreasedRangedCritChance} + {1}% increased movement speed and acceleration ''' } @@ -322,30 +302,27 @@ LunicCorpsHelmet: { DisplayName: Lunic Corps Helmet Tooltip: ''' - 15% increased ranged damage - Night vision and creature detect + Increases non-bow damage by {0}% + Improves vision and shows the location of enemies ''' SetBonus: ''' - 'Finish the fight' - Projects a bubble shield that absorbs up to 50 damage {0} - The shield starts recharging 5 seconds after being hit - Recharging from zero to full charge takes 2 seconds - Being hit again while recharging restarts the charge timer - 15% increased bullet damage - 15% increased specialist ranged damage - These are launchers, dartguns, or anything else that doesn't shoot arrows/bullets - 20% increased jump speed + {0}% increased jump speed + [c/{1}:MJOLNIR Shield - Projects a bubble shield that absorbs up to {2} damage]{3} + [c/52CBDE:The shield starts recharging {4} {^4:second;seconds} after being hit] + [c/52CBDE:Recharging from zero to full charge takes {5} {^5:second;seconds}] + [c/52CBDE:Being hit again while recharging restarts the charge timer] + [c/9EA67F:'Finish the fight'] ''' - ShieldAdren: Halves Adrenaline lost on hit if the shield fully absorbs the hit + ShieldAdren: "[c/52CBDE:Halves Adrenaline lost on hit if the shield fully absorbs the hit]" } LunicCorpsVest: { DisplayName: Lunic Corps Vest Tooltip: ''' - 5% increased ranged damage - 15% increased ranged critical strike chance + {$CommonItemTooltip.PercentIncreasedRangedDamageCritChance} + {$CommonItemTooltip.PercentChanceToSaveAmmo@1} ''' } @@ -353,7 +330,7 @@ MolluskShelleggings: { DisplayName: Mollusk Shelleggings Tooltip: ''' - 6% increased damage and 4% increased critical strike chance + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} Your horizontal movement is slowed ''' } @@ -362,14 +339,14 @@ MolluskShellmet: { DisplayName: Mollusk Shellmet Tooltip: ''' - 5% increased damage and 4% increased critical strike chance + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} You can move freely through liquids Your horizontal movement is slowed ''' SetBonus: ''' + {0}% increased damage reduction Two shellfishes aid you in combat - 10% increased damage reduction ''' } @@ -377,7 +354,7 @@ MolluskShellplate: { DisplayName: Mollusk Shellplate Tooltip: ''' - 6% increased damage and 5% increased critical strike chance + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} Your horizontal movement is slowed ''' } @@ -386,9 +363,9 @@ PlaguebringerCarapace: { DisplayName: Plaguebringer Carapace Tooltip: ''' - Grants immunity to the Plague - 15% increased summon damage - Friendly bees inflict the plague + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + Grants immunity to [cbuff:CalamityMod/Plague] ''' } @@ -396,8 +373,9 @@ PlaguebringerPistons: { DisplayName: Plaguebringer Pistons Tooltip: ''' - 15% increased summon damage and 15% increased movement speed - You grow flowers on the grass beneath you, chance to grow very random dye plants on grassless dirt + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} and {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} + Flowers grow on the grass you walk on, and dye plants rarely grow on grassless dirt you walk on ''' } @@ -405,27 +383,31 @@ PlaguebringerVisor: { DisplayName: Plaguebringer Visor Tooltip: ''' - 15% increased summon damage - +20 max life + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} ''' SetBonus: ''' Grants a plague dash which can slam through enemies without taking damage Summons a lil' plaguebringer which swarms your foes with little bees - +3 max minions + Friendly bees inflict [cbuff:CalamityMod/Plague] ''' } PlagueReaperMask: { DisplayName: Plague Reaper Mask - Tooltip: 10% increased ranged damage and 8% increased ranged critical strike chance + Tooltip: + ''' + {$CommonItemTooltip.PercentIncreasedRangedDamage} and {$CommonItemTooltip.PercentIncreasedRangedCritChance@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} + ''' SetBonus: ''' - 25% reduced ammo usage and 5% increased flight time - Enemies receive 10% more damage from ranged projectiles when afflicted by the Plague - Getting hit causes plague cinders to rain from above - Press {0} to blind yourself for 5 seconds but massively boost your ranged damage - This has a 25 second cooldown. + {0}% increased flight time + Enemies afflicted by the Plague take {1}x damage from ranged projectiles + [c/{2}:Plague Blackout - {3} to greatly empower your damage but completely blind yourself] + [c/009418:{$CommonItemTooltip.PercentIncreasedRangedDamage@4} and {$CommonItemTooltip.PercentIncreasedRangedCritChance@5} while blacked out] + [c/009418:This effect lasts {6} {^6:second;seconds} and has a cooldown of {7} {^7:second;seconds}] ''' } @@ -433,8 +415,8 @@ PlagueReaperStriders: { DisplayName: Plague Reaper Striders Tooltip: ''' - 3% increased ranged critical strike chance - 15% increased movement speed + {$CommonItemTooltip.PercentIncreasedRangedCritChance} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -442,102 +424,85 @@ PlagueReaperVest: { DisplayName: Plague Reaper Vest Tooltip: ''' + {$CommonItemTooltip.PercentIncreasedRangedDamage} Grants immunity to the Plague - 15% increased ranged damage and 5% increased ranged critical strike chance ''' } ReaverCuisses: { DisplayName: Reaver Cuisses - Tooltip: - ''' - 5% increased critical strike chance - 12% increased movement speed - ''' + Tooltip: "{$CommonItemTooltip.PercentIncreasedMovementSpeed}" } ReaverHeadExplore: { DisplayName: Reaver Headgear Tooltip: ''' - 20% increased mining speed - 50% increased block & wall placement speed + {0}% increased mining speed + {1}% increased block & wall placement speed Grants immunity to lava and can move freely through liquids ''' SetBonus: ''' - Summons an orb which highlights nearby treasure and provides light - Grants underwater breathing and reduced enemy aggression - These have a moderate effect while in the Abyss - Increased block placement & tool range by 7 + Emits light and shows the location of treasure and ore + {$Common.AggroReduction} and grants underwater breathing + Greatly enhances visibility in the abyss + Increased block placement & tool range by {0} Increases pickup range for items ''' } ReaverHeadMobility: { DisplayName: Reaver Visage - Tooltip: 10% increased jump speed and 15% increased movement speed + Tooltip: "{$CommonItemTooltip.PercentIncreasedMovementSpeed} and {1}% increased jump speed" SetBonus: ''' Grants immunity to fall damage and allows constant jumping - 10% increased flight time and horizontal wing speed - Hooks fly out and retract 10% faster - Reduces the cooldown of dashes + {0}% increased flight time and horizontal wing speed + Grappling hooks retract and pull the player {1}% faster + Reduces the cooldown of dashes by {2}% ''' } ReaverHeadTank: { DisplayName: Reaver Helm - Tooltip: - ''' - 15% increased damage reduction but 30% decreased damage - +50 max life - Restores 1 HP every second, this applies separately from life regen - ''' + Tooltip: +{0} max life and +{1} HP/s life regen SetBonus: ''' - +10 defense and +1.5 HP/s life regen - Enemies are more likely to target you - Reduces the life regen lost from damage over time debuffs by 20% - All attacks steal life and speed up the rate of life regen - 30% decreased movement speed and flight time - Enemy damage is reflected and summons a thorn spike - Reaver Rage activates when you are damaged + {$Common.AggroBoost} + Reduces the life regen lost from damage over time debuffs by {0}% + {1}% decreased movement speed and flight time + Grants [cbuff:CalamityMod/ReaverRage] for {2} {^2:second;seconds} after taking damage ''' } ReaverScaleMail: { DisplayName: Reaver Scale Mail - Tooltip: - ''' - 9% increased damage and 4% increased critical strike chance - +20 max life - ''' + Tooltip: "{0}% increased damage reduction" } TitanHeartBoots: { DisplayName: Titan Heart Boots - Tooltip: 4% increased rogue damage, 10% increased rogue velocity, and 5% increased rogue knockback + Tooltip: "{$Common.RogueDamage}" } TitanHeartMantle: { DisplayName: Titan Heart Mantle - Tooltip: 5% boosted rogue damage and knockback + Tooltip: "{$Common.RogueDamage} and {1}% increased rogue knockback" } TitanHeartMask: { DisplayName: Titan Heart Mask Tooltip: ''' - 5% increased rogue damage and knockback - Rogue weapons inflict the Astral Infection debuff + {$Common.RogueDamage} and {$Common.RogueVelocity@1} + Rogue weapons inflict [cbuff:CalamityMod/AstralInfectionDebuff] ''' SetBonus: ''' - 10% increased rogue damage and 20% increased rogue knockback - +100 maximum stealth - Stealth strikes deal double knockback and cause an astral explosion - Grants immunity to knockback + {$Common.RogueStealth} + Stealth strikes deal {1}x knockback and cause an astral explosion + {$Common.KnockbackImmunity} ''' } @@ -545,17 +510,17 @@ UmbraphileBoots: { DisplayName: Umbraphile Boots Tooltip: ''' - 9% increased rogue damage and 6% increased rogue crit - 20% increased movement speed + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} ''' } UmbraphileHood: { DisplayName: Umbraphile Hood - Tooltip: 8% increased rogue damage and 10% increased rogue velocity + Tooltip: "{$Common.RogueDamage} and {$Common.RogueVelocity@1}" SetBonus: ''' - +110 maximum stealth + {$Common.RogueStealth} Rogue weapons have a chance to create explosions on hit Stealth strikes always create an explosion ''' @@ -563,5 +528,5 @@ UmbraphileHood: { UmbraphileRegalia: { DisplayName: Umbraphile Regalia - Tooltip: 10% increased rogue damage and 10% increased rogue crit + Tooltip: "{$Common.RogueDamageCrit}" } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson index f94a0fd15a..10cdedab20 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson @@ -1,85 +1,171 @@ AuricTeslaBodyArmor: { DisplayName: Auric Tesla Body Armor - Tooltip: - ''' - +100 max life - 8% increased damage and 5% increased critical strike chance - ''' + Tooltip: "{$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1}" } AuricTeslaCuisses: { DisplayName: Auric Tesla Cuisses Tooltip: ''' - 10% increased movement speed - 12% increased damage and 5% increased critical strike chance - Magic carpet effect + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} + Provides a magical flying carpet + [c/aaaaaa:Shift- in your inventory to toggle] [i:FlyingCarpet] [c/aaaaaa:Flying Carpet's effect] ''' } -AuricTeslaHoodedFacemask: { +AuricTeslaHeadRanged: { DisplayName: Auric Tesla Hooded Facemask - Tooltip: 30% increased ranged damage and critical strike chance - SetBonus: Ranged Tarragon, Bloodflare and God Slayer armor effects + Tooltip: + ''' + {$CommonItemTooltip.PercentIncreasedRangedDamage} and {$CommonItemTooltip.PercentIncreasedRangedCritChance@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} + ''' + SetBonus: + ''' + Ranged Tarragon, Bloodflare and God Slayer armor effects + Hold Shift to view these set bonus details and press Shift repeatedly to cycle through them + ''' + SetBonus1: + ''' + Inherited Tarragon Set Bonus: + {$TarragonHeadRanged.SetBonusEffect} + ''' + SetBonus2: + ''' + Inherited Bloodflare Set Bonus: + {$BloodflareHeadRanged.SetBonusEffect} + ''' + SetBonus3: + ''' + Inherited God Slayer Set Bonus: + {$GodSlayerHeadRanged.SetBonusEffect} + ''' } -AuricTeslaPlumedHelm: { +AuricTeslaHeadRogue: { DisplayName: Auric Tesla Plumed Helm Tooltip: ''' - 20% increased rogue damage and critical strike chance - 5% increased movement speed + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} ''' SetBonus: ''' + {$Common.RogueStealth} Rogue Tarragon, Bloodflare and God Slayer armor effects - +130 maximum stealth + Hold Shift to view these set bonus details and press Shift repeatedly to cycle through them + ''' + SetBonus1: + ''' + Inherited Tarragon Set Bonus: + {$TarragonHeadRogue.SetBonusEffect} + ''' + SetBonus2: + ''' + Inherited Bloodflare Set Bonus: + {$BloodflareHeadRogue.SetBonusEffect} + ''' + SetBonus3: + ''' + Inherited God Slayer Set Bonus: + {$GodSlayerHeadRogue.SetBonusEffect} ''' } -AuricTeslaRoyalHelm: { +AuricTeslaHeadMelee: { DisplayName: Auric Tesla Royal Helm Tooltip: ''' - 20% increased melee damage - 10% increased melee critical strike chance + {$CommonItemTooltip.PercentIncreasedMeleeDamage} + {$CommonItemTooltip.PercentIncreasedMeleeSpeed@1} ''' SetBonus: ''' + {$Common.AggroBoost} Melee Tarragon, Bloodflare and God Slayer effects - Enemies are more likely to target you - 28% increased melee speed + Hold Shift to view these set bonus details and press Shift repeatedly to cycle through them + ''' + SetBonus1: + ''' + Inherited Tarragon Set Bonus: + {$TarragonHeadMelee.SetBonusEffect} + ''' + SetBonus2: + ''' + Inherited Bloodflare Set Bonus: + {$BloodflareHeadMelee.SetBonusEffect} + ''' + SetBonus3: + ''' + Inherited God Slayer Set Bonus: + {$GodSlayerHeadMelee.SetBonusEffect} ''' } -AuricTeslaSpaceHelmet: { +AuricTeslaHeadSummon: { DisplayName: Auric Tesla Space Helmet - Tooltip: 15% increased summon damage + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + ''' SetBonus: ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Summoner Tarragon, Bloodflare and Silva armor effects - Max run speed and acceleration boosted by 5% - +6 max minions and 75% increased summon damage + Hold Shift to view these set bonus details and press Shift repeatedly to cycle through them + ''' + SetBonus1: + ''' + Inherited Tarragon Set Bonus: + {$TarragonHeadSummon.SetBonusEffect} + ''' + SetBonus2: + ''' + Inherited Bloodflare Set Bonus: + {$BloodflareHeadSummon.SetBonusEffect} + ''' + SetBonus3: + ''' + Inherited Silva Set Bonus: + {$SilvaHeadSummon.SetBonusEffect} ''' } -AuricTeslaWireHemmedVisage: { +AuricTeslaHeadMagic: { DisplayName: Auric Tesla Wire-Hemmed Visage - Tooltip: 30% increased magic damage, 20% increased magic critical strike chance, +100 max mana and 20% reduced mana usage + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} + ''' SetBonus: ''' Magic Tarragon, Bloodflare and Silva armor effects - Max run speed and acceleration boosted by 5% + Hold Shift to view these set bonus details and press Shift repeatedly to cycle through them + ''' + SetBonus1: + ''' + Inherited Tarragon Set Bonus: + {$TarragonHeadMagic.SetBonusEffect} + ''' + SetBonus2: + ''' + Inherited Bloodflare Set Bonus: + {$BloodflareHeadMagic.SetBonusEffect} + ''' + SetBonus3: + ''' + Inherited Silva Set Bonus: + {$SilvaHeadMagic.SetBonusEffect} ''' } BloodflareBodyArmor: { DisplayName: Bloodflare Body Armor - Tooltip: - ''' - 12% increased damage and 8% increased critical strike chance - +40 max life - ''' + Tooltip: "{$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1}" CommonSetBonus: ''' Greatly increased life regen, equivalent to Crimson armor @@ -90,41 +176,64 @@ BloodflareBodyArmor: { BloodflareCuisses: { DisplayName: Bloodflare Cuisses - Tooltip: 17% increased movement speed, 10% increased damage and 7% increased critical strike chance + Tooltip: + ''' + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} + ''' } BloodflareHeadMagic: { DisplayName: Bloodflare Hydra Hood - Tooltip: 20% increased magic damage, 10% increased magic critical strike chance, +100 max mana and 17% reduced mana usage - SetBonus: + Tooltip: ''' - Magic weapons fire ghostly bolts every 1.67 seconds - Magic critical strikes cause blood explosions every 2 seconds + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} + ''' + SetBonus: "{$BloodflareHeadMagic.SetBonusEffect}" + SetBonusEffect: + ''' + Magic weapons fire ghostly bolts every {0} seconds + Magic critical strikes cause blood explosions every {1} seconds + {$BloodflareBodyArmor.CommonSetBonus} ''' } BloodflareHeadMelee: { DisplayName: Bloodflare Ram Mask - Tooltip: 10% increased melee damage and 5% increased melee critical strike chance + Tooltip: + ''' + {$CommonItemTooltip.PercentIncreasedMeleeDamage} and {$CommonItemTooltip.PercentIncreasedMeleeCritChance@1} + {$CommonItemTooltip.PercentIncreasedMeleeSpeed@2} + ''' SetBonus: ''' - 18% increased melee speed - Enemies are more likely to target you - True melee strikes will heal you - After striking an enemy 15 times with true melee you will enter a blood frenzy for 5 seconds - During this you will gain 25% increased melee damage, critical strike chance, and contact damage is halved - This effect has a 30 second cooldown + {$Common.AggroBoost} + {$BloodflareHeadMelee.SetBonusEffect} + ''' + SetBonusEffect: + ''' + After striking an enemy {0} times with true melee you will enter a blood frenzy for {1} seconds + During this you will gain {2}% increased melee damage, critical strike chance, and {3}% reduced contact damage + This effect has a {4} second cooldown + {$BloodflareBodyArmor.CommonSetBonus} ''' } BloodflareHeadRanged: { DisplayName: Bloodflare Horned Helm - Tooltip: 10% increased ranged damage and critical strike chance - SetBonus: + Tooltip: ''' - Press {0} to unleash the lost souls of polterghast to destroy your enemies - This effect has a 30 second cooldown - Ranged weapons fire bloodsplosion orbs every 2.5 seconds + {$CommonItemTooltip.PercentIncreasedRangedDamageCritChance} + {$CommonItemTooltip.PercentChanceToSaveAmmo@1} + ''' + SetBonus: "{$BloodflareHeadRanged.SetBonusEffect}" + SetBonusEffect: + ''' + {0} to unleash the lost souls of polterghast to destroy your enemies + This effect has a {1} second cooldown + Ranged weapons fire bloodsplosion orbs every {2} seconds + {$BloodflareBodyArmor.CommonSetBonus} ''' } @@ -132,27 +241,40 @@ BloodflareHeadRogue: { DisplayName: Bloodflare Imp Mask Tooltip: ''' - 10% increased rogue damage and critical strike chance - 5% increased movement speed + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} ''' SetBonus: ''' - +120 maximum stealth - Being over 80% life boosts your defense by 30 and rogue crit by 5% - Being below 80% life boosts your rogue damage by 10% - Rogue critical strikes heal you + {$Common.RogueStealth} + {$BloodflareHeadRogue.SetBonusEffect@1} + ''' + SetBonusEffect: + ''' + Grants {0} defense when above {1}% life + Rogue critical strikes have lifesteal + {$BloodflareBodyArmor.CommonSetBonus} ''' } BloodflareHeadSummon: { DisplayName: Bloodflare Wyvern Helm - Tooltip: 5% increased summon damage + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + ''' SetBonus: ''' - 50% increased summon damage and +3 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + {$BloodflareHeadSummon.SetBonusEffect@2} + ''' + SetBonusEffect: + ''' Summons polterghast mines to circle you - At 90% life and above you gain 10% increased summon damage - At 50% life and below you gain 20 defense and +1 HP/s life regen + Grants {0} defense when below {1}% life + {$BloodflareBodyArmor.CommonSetBonus} ''' } @@ -160,9 +282,10 @@ DemonshadeBreastplate: { DisplayName: Demonshade Breastplate Tooltip: ''' - 25% increased melee speed, 15% increased damage and critical strike chance - Enemies take ungodly damage when they touch you - Increased max life and mana by 200 + {$CommonItemTooltip.IncreasesMaxManaBy} + {$CommonItemTooltip.PercentIncreasedDamageCritChance@1} + {$CommonItemTooltip.PercentIncreasedMeleeSpeed@2} + {$CommonItemTooltip.PercentChanceToSaveAmmo@3} Standing still absorbs shadows to grant exponentially accelerating life regen ''' } @@ -174,33 +297,33 @@ DemonshadeGreaves: { DemonshadeHelm: { DisplayName: Demonshade Helm - Tooltip: 30% increased damage and 15% increased critical strike chance + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedDamage@1} and {$CommonItemTooltip.PercentIncreasedCritChance@2} + ''' SetBonus: ''' - 100% increased summon damage and +10 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Shadowbeams and demon scythes will fire down when you are hit A friendly red devil follows you around - Press {0} to enrage nearby enemies with a dark magic spell for 10 seconds - This makes them take {1}x total damage, but they will deal {2}x damage to you + {2} to enrage nearby enemies with a dark magic spell for {3} seconds + This makes them take {4}x total damage, but they will deal {5}x damage to you ''' } EmpyreanCloak: { DisplayName: Empyrean Cloak - Tooltip: - ''' - Armor of the cosmos - +20 max life - 7% increased rogue damage and critical strike chance - ''' + Tooltip: "{$Common.RogueDamage} and {$Common.RogueCrit@1}" } EmpyreanCuisses: { DisplayName: Empyrean Cuisses Tooltip: ''' - 5% increased rogue damage and critical strike chance - 15% increased movement speed + {$Common.RogueDamageCrit} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -208,15 +331,14 @@ EmpyreanMask: { DisplayName: Empyrean Mask Tooltip: ''' - 11% increased rogue damage and critical strike chance - 5% increased movement speed + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$Common.RogueVelocity@2} ''' SetBonus: ''' - 9% increased rogue damage and velocity - +115 maximum stealth + {$Common.RogueStealth} Rogue projectiles have special effects on enemy hits - Imbued with cosmic wrath and rage when you are damaged + Imbued with cosmic wrath when you are damaged ''' } @@ -224,18 +346,16 @@ FearmongerGreathelm: { DisplayName: Fearmonger Greathelm Tooltip: ''' + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedSummonDamage@2} Pure terror radiates from your eyes - +60 max mana and 10% reduced mana usage - 10% increased summon damage ''' SetBonus: ''' - 20% increased summon damage and +2 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} Minions no longer deal less damage while wielding non-summoner weapons Immunity to all but the strongest forms of frost and flame - Minion attacks grant +3.5 HP/s life regen and massively accelerate life regen - 15% increased damage reduction during the Pumpkin and Frost Moons - This extra damage reduction ignores the soft cap + Minion attacks grant +{1} HP/s life regen and massively accelerate life regen ''' } @@ -243,10 +363,8 @@ FearmongerGreaves: { DisplayName: Fearmonger Greaves Tooltip: ''' - 6% increased damage - 50% increased minion knockback - 10% increased movement speed - Taking damage increases your movement speed by 40% for 4 seconds + {$CommonItemTooltip.PercentIncreasedDamage} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -254,8 +372,8 @@ FearmongerPlateMail: { DisplayName: Fearmonger Plate Mail Tooltip: ''' - +100 max life and 8% increased damage reduction - 5% increased damage and critical strike chance + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} + +{2} max life and {3}% increased damage reduction ''' } @@ -267,7 +385,7 @@ GemTechBodyArmor: { GemTechHeadgear: { DisplayName: Gem Tech Headgear Tooltip: "'The Devil said: Revel in your victory; You've earned your damning. Pack your things and leave.'" - AbilityBrief: Power Gems - Six gem fragments idly orbit you; one for each class, and a base gem + AbilityBrief: "[c/{0}:Power Gems - Six gem fragments idly orbit you; one for each class, and a base gem]" AbilityDescription: ''' Each active gem provides a bonus for its respective class, while the defensive gem grants defensive boosts @@ -277,18 +395,18 @@ GemTechHeadgear: { ''' GeneralGemInfo: ''' - A gem is lost when you take more than {0} damage in a single hit. + A gem is lost when you take more than {0} damage in a single hit The type of gem lost is the same as the class of the most recently used weapon If said gem has already been lost, the base gem is lost instead When a gem is lost, it breaks off and homes towards the nearest enemy or boss, if one is present, dealing a base of {1} damage Gems have a {2} second delay before they appear again ''' - RedGemInfo: "[i:Ruby] The red gem grants {0} maximum stealth, increased rogue stats, and makes stealth only consumable by rogue weapons" - YellowGemInfo: "[i:Topaz] The yellow gem provides increased melee stats and makes melee attacks release shards on hit with a cooldown. This cooldown is shorter for true melee attacks" - GreenGemInfo: "[i:Emerald] The green gem provides increased ranged stats and causes flechettes to fly swiftly towards targets when they are damaged by a ranged projectile" - BlueGemInfo: "[i:Sapphire] The blue gem grants {0} extra maximum minions, increased summon damage, and negates the summon damage penalty while wielding non-summoner weapons" - PurpleGemInfo: "[i:Amethyst] The violet gem grants {0} extra maximum mana, increased magic stats, and makes mana rapidly regenerate when holding a non-magic weapon" - PinkGemInfo: "[i:Diamond] The pink base gem grants {0} extra defense, extra damage reduction, increased movement speed, jump speed, and +{1} HP/s life regen" + RedGemInfo: "[i:CalamityMod/GemTechRedGem] The red gem grants {0} maximum stealth, increased rogue stats, and makes stealth only consumable by rogue weapons" + YellowGemInfo: "[i:CalamityMod/GemTechYellowGem] The yellow gem provides increased melee stats and makes melee attacks release shards on hit with a cooldown. This cooldown is shorter for true melee attacks" + GreenGemInfo: "[i:CalamityMod/GemTechGreenGem] The green gem provides increased ranged stats and causes flechettes to fly swiftly towards targets when they are damaged by a ranged projectile" + BlueGemInfo: "[i:CalamityMod/GemTechBlueGem] The blue gem grants {0} maximum minions, increased summon damage, and negates the summon damage penalty while wielding non-summoner weapons" + PurpleGemInfo: "[i:CalamityMod/GemTechPurpleGem] The violet gem grants {0} maximum mana, increased magic stats, and makes mana rapidly regenerate when holding a non-magic weapon" + PinkGemInfo: "[i:CalamityMod/GemTechPinkGem] The pink base gem grants {0} defense, increased damage reduction, movement speed, jump speed, and +{1} HP/s life regen" GemBonusInfo: ''' When all gems exist simultaneously, hitting a target with any weapon grants you +{0} HP/s life regen for {1} seconds @@ -303,18 +421,13 @@ GemTechSchynbaulds: { GodSlayerChestplate: { DisplayName: God Slayer Chestplate - Tooltip: - ''' - +60 max life - Enemies take damage when they hit you - 11% increased damage and 6% increased critical strike chance - ''' + Tooltip: "{$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1}" CommonSetBonus: ''' - Pressing {0} allows you to dash towards your cursor for 2.5 seconds + Press {0} to [c/ff00ff:Dimensional Drive] towards your cursor for 2 seconds Enemies you dash through take massive damage - During the dash you are immune to most debuffs - The dash has a {1} second cooldown + During [c/ff00ff:Dimensional Drive] you are immune to damage and most debuffs + [c/ff00ff:Dimensional Drive] has a {1} second cooldown ''' } @@ -322,36 +435,53 @@ GodSlayerHeadMelee: { DisplayName: God Slayer Horned Greathelm Tooltip: ''' - 14% increased melee damage - 7% increased melee critical strike chance + {$CommonItemTooltip.PercentIncreasedMeleeDamage} and {$CommonItemTooltip.PercentIncreasedMeleeCritChance@1} + {$CommonItemTooltip.PercentIncreasedMeleeSpeed@2} ''' SetBonus: ''' - 20% increased melee speed - Enemies are more likely to target you - Taking over 80 damage in one hit will cause you to release a swarm of high-damage god killer darts - Enemies take a lot of damage when they hit you + {$Common.AggroBoost} + {$GodSlayerHeadMelee.SetBonusEffect} + ''' + SetBonusEffect: + ''' + Releases a swarm of god killer darts when taking over {0} damage in one hit + {$GodSlayerChestplate.CommonSetBonus@1} ''' } GodSlayerHeadRanged: { DisplayName: God Slayer Helmet - Tooltip: 14% increased ranged damage and critical strike chance - SetBonus: You fire a god killer shrapnel round while firing ranged weapons every 2.5 seconds + Tooltip: + ''' + {$CommonItemTooltip.PercentIncreasedRangedDamage} and {$CommonItemTooltip.PercentIncreasedRangedCritChance@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} + ''' + SetBonus: "{$GodSlayerHeadRanged.SetBonusEffect}" + SetBonusEffect: + ''' + Ranged weapons fire a god killer shrapnel round every {0} seconds + {$GodSlayerChestplate.CommonSetBonus@1} + ''' } GodSlayerHeadRogue: { DisplayName: God Slayer Mask Tooltip: ''' - 14% increased rogue damage and critical strike chance - 5% increased movement speed + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} ''' SetBonus: ''' - +120 maximum stealth - While at full HP all of your rogue stats are boosted by 10% - If you take over 80 damage in one hit you will be given extra immunity frames + {$Common.RogueStealth} + {$GodSlayerHeadRogue.SetBonusEffect@1} + ''' + SetBonusEffect: + ''' + {0}% increased rogue damage, critical strike chance, and velocity when at full health + Increased length of invincibility when taking over {1} damage in one hit + {$GodSlayerChestplate.CommonSetBonus@2} ''' } @@ -359,8 +489,8 @@ GodSlayerLeggings: { DisplayName: God Slayer Leggings Tooltip: ''' - 5% increased movement speed - 10% increased damage and critical strike chance + {$CommonItemTooltip.PercentIncreasedDamageCritChance} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -368,7 +498,8 @@ OmegaBlueChestplate: { DisplayName: Omega Blue Chestplate Tooltip: ''' - 12% increased damage and 8% increased critical strike chance + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} Your attacks inflict Hadopelagic Pressure No positive life regen ''' @@ -378,17 +509,17 @@ OmegaBlueHelmet: { DisplayName: Omega Blue Helmet Tooltip: ''' + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} You can move freely through liquids - 12% increased damage and 8% increased critical strike chance ''' SetBonus: ''' - Increases armor penetration by 15 - 10% increased damage and critical strike chance and +2 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} Short-ranged tentacles heal you by sucking enemy life - Press {0} to activate abyssal madness for 5 seconds - Abyssal madness increases damage, critical strike chance, and tentacle aggression/range - This effect has a 25 second cooldown + [c/{1}:Abyssal Madness - {2} to go berserk for {3} seconds] + [c/99ABFF:While active, tentacles attack with greater range and aggression, and always critically strike] + [c/99ABFF:This also grants {$CommonItemTooltip.PercentIncreasedDamageCritChance@4}] + [c/99ABFF:This effect has a {5} second cooldown] ''' } @@ -396,8 +527,8 @@ OmegaBlueTentacles: { DisplayName: Omega Blue Tentacles Tooltip: ''' - 12% increased movement speed - 12% increased damage and critical strike chance + {$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} ''' } @@ -405,9 +536,9 @@ PrismaticGreaves: { DisplayName: Prismatic Greaves Tooltip: ''' - 10% increased magic damage and 12% increased magic crit - 20% decreased non-magic damage - 10% increased flight time and 2% increased jump speed + {$CommonItemTooltip.PercentIncreasedMagicDamage} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@1} + {2}% decreased non-magic damage + {3}% increased flight time and {4}% increased jump speed ''' } @@ -415,17 +546,17 @@ PrismaticHelmet: { DisplayName: Prismatic Helmet Tooltip: ''' - 18% increased magic damage and 12% increased magic crit - 20% decreased non-magic damage + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} + {4}% decreased non-magic damage Enemies with less than 500 max health deal no contact damage This does not occur while a boss is alive ''' SetBonus: ''' - +40 max mana and 15% reduced mana cost Increased mana regeneration rate - Press {0} to unleash a barrage of death lasers at the cursor for the next 5 seconds - This has a 30 second cooldown + [c/{0}:Prismatic Barrage - {1} to unleash a laser barrage at the cursor for {2} seconds] + [c/67F4FB:This has a {3} second cooldown] ''' } @@ -433,26 +564,21 @@ PrismaticRegalia: { DisplayName: Prismatic Regalia Tooltip: ''' - 12% increased magic damage and 15% increased magic crit - 20% decreased non-magic damage - +20 max life and +40 max mana - Magic attacks occasionally fire a pair of homing rockets + {$CommonItemTooltip.PercentIncreasedMagicDamageCritChance} + {1}% decreased non-magic damage + Magic attacks have a {2}% chance to fire a pair of homing rockets ''' } SilvaArmor: { DisplayName: Silva Armor - Tooltip: - ''' - +80 max life - 12% increased damage and 8% increased critical strike chance - ''' + Tooltip: "{$CommonItemTooltip.PercentIncreasedDamage} and {$CommonItemTooltip.PercentIncreasedCritChance@1}" CommonSetBonus: ''' - All projectiles spawn healing leaf orbs on enemy hits - Max run speed and acceleration boosted by 5% - Taking fatal damage will revive you and make you invulnerable to all damage for 5 seconds - This effect has a 5 minute cooldown, which does not decrement if any bosses or events are active + +{0} HP/s life regen + {1}% increased max run speed and acceleration + Taking fatal damage will revive you and make you invulnerable to all damage for {2} seconds + This effect has a {3} minute cooldown, which does not decrement if any bosses or events are active ''' } @@ -460,19 +586,34 @@ SilvaHeadMagic: { DisplayName: Silva Masked Cap Tooltip: ''' - 23% increased magic damage and 13% increased magic critical strike chance - +100 max mana and 19% reduced mana usage + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} + ''' + SetBonus: "{$SilvaHeadMagic.SetBonusEffect}" + SetBonusEffect: + ''' + Magic projectiles which cannot pierce will occasionally set off potent blasts of nature energy + {$SilvaArmor.CommonSetBonus} ''' - SetBonus: Magic projectiles which cannot pierce will occasionally set off potent blasts of nature energy } SilvaHeadSummon: { DisplayName: Silva Horned Hood - Tooltip: 10% increased summon damage + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + ''' SetBonus: ''' - 65% increased summon damage and +5 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + {$SilvaHeadSummon.SetBonusEffect@2} + ''' + SetBonusEffect: + ''' Summons an ancient leaf prism to blast your enemies with life energy + {$SilvaArmor.CommonSetBonus} ''' } @@ -480,8 +621,8 @@ SilvaLeggings: { DisplayName: Silva Leggings Tooltip: ''' - 10% increased movement speed - 12% increased damage and critical strike chance + {$CommonItemTooltip.PercentIncreasedDamageCritChance} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } @@ -489,12 +630,11 @@ TarragonBreastplate: { DisplayName: Tarragon Breastplate Tooltip: ''' - 10% increased damage and 5% increased critical strike chance - +1.5 HP/s life regen and +40 max life + {0}% increased damage and {1}% increased critical strike chance + +{2} HP/s life regen and {3}% increased damage reduction ''' CommonSetBonus: ''' - Reduces enemy spawn rates Increased heart pickup range Enemies have a chance to drop extra hearts on death ''' @@ -504,14 +644,14 @@ TarragonHeadMagic: { DisplayName: Tarragon Mask Tooltip: ''' - 15% increased magic damage and 10% increased magic critical strike chance - 10% increased damage reduction, +100 max mana, and 15% reduced mana usage + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} ''' - SetBonus: + SetBonus: "{$TarragonHeadMagic.SetBonusEffect}" + SetBonusEffect: ''' On every 5th critical strike you will fire a leaf storm - Magic projectiles heal you on enemy hits - Amount healed is based on projectile damage + {$TarragonBreastplate.CommonSetBonus} ''' } @@ -519,16 +659,20 @@ TarragonHeadMelee: { DisplayName: Tarragon Helm Tooltip: ''' - 12% increased melee damage and 7% increased melee critical strike chance - 10% increased damage reduction + {$CommonItemTooltip.PercentIncreasedMeleeDamage} and {$CommonItemTooltip.PercentIncreasedMeleeCritChance@1} + {$CommonItemTooltip.PercentIncreasedMeleeSpeed@2} ''' SetBonus: ''' - 15% increased melee speed - Enemies are more likely to target you - Taking damage gives the Tarra Life buff, which grants +1.5 HP/s life regen - Press {0} to cloak yourself in life energy that heavily reduces enemy contact damage for 10 seconds - This has a 30 second cooldown + {$Common.AggroBoost} + {$TarragonHeadMelee.SetBonusEffect} + ''' + SetBonusEffect: + ''' + Taking damage gives [cbuff:CalamityMod/TarraLifeRegen], which grants +{0} HP/s life regen + {1} to cloak yourself in life energy that heavily reduces enemy contact damage for {2} seconds + This has a {3} second cooldown + {$TarragonBreastplate.CommonSetBonus} ''' } @@ -536,35 +680,55 @@ TarragonHeadRanged: { DisplayName: Tarragon Visage Tooltip: ''' - 10% increased ranged damage and critical strike chance - 10% increased damage reduction + {$CommonItemTooltip.PercentIncreasedRangedDamage} and {$CommonItemTooltip.PercentIncreasedRangedCritChance@1} + {$CommonItemTooltip.PercentChanceToSaveAmmo@2} + ''' + SetBonus: "{$TarragonHeadRanged.SetBonusEffect}" + SetBonusEffect: + ''' + Ranged projectiles spawn homing life energy and leaves on enemy hits + {$TarragonBreastplate.CommonSetBonus} ''' - SetBonus: Ranged projectiles split into homing life energy and leaves on death } TarragonHeadRogue: { DisplayName: Tarragon Helmet Tooltip: ''' - 10% increased rogue damage and critical strike chance - 10% increased damage reduction and 5% increased movement speed + {$Common.RogueDamage} and {$Common.RogueCrit@1} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} ''' SetBonus: ''' - +115 maximum stealth - After every 50 rogue critical hits you will gain 2.5 seconds of damage immunity - This effect has a cooldown of 25 seconds - While under the effects of a debuff you gain 10% increased rogue damage + {$Common.RogueStealth} + {$TarragonHeadRogue.SetBonusEffect@1} + ''' + SetBonusEffect: + ''' + After every {0} rogue critical hits you will gain {1} seconds of damage immunity + This effect has a cooldown of {2} seconds + While under the effects of a debuff you gain {3}% increased rogue damage + {$TarragonBreastplate.CommonSetBonus} ''' } TarragonHeadSummon: { DisplayName: Tarragon Horned Helm - Tooltip: 10% increased damage reduction and 5% increased summon damage + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + ''' SetBonus: ''' - 50% increased summon damage and +3 max minions + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + {$TarragonHeadSummon.SetBonusEffect} + ''' + SetBonusEffect: + ''' Summons a life aura around you that damages nearby enemies + {$TarragonBreastplate.CommonSetBonus} ''' } @@ -572,7 +736,7 @@ TarragonLeggings: { DisplayName: Tarragon Leggings Tooltip: ''' - 10% increased movement speed - 8% increased damage and critical strike chance + {$CommonItemTooltip.PercentIncreasedDamageCritChance} + {$CommonItemTooltip.PercentIncreasedMovementSpeed@1} ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson index 3095f99502..1edc83276a 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson @@ -1,147 +1,162 @@ AerospecBreastplate: { DisplayName: Aerospec Breastplate - Tooltip: 3% increased damage and critical strike chance + Tooltip: "{$CommonItemTooltip.PercentIncreasedDamageCritChance}" CommonSetBonus: ''' - Taking over 25 damage in one hit will cause a spread of homing feathers to fall + Taking over {0} damage in one hit will cause a spread of homing feathers to fall Allows you to fall more quickly and disables fall damage ''' } -AerospecHat: { +AerospecHeadMagic: { DisplayName: Aerospec Hat - Tooltip: 10% increased magic damage and +30 max mana + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxManaBy} + {$CommonItemTooltip.PercentIncreasedMagicDamage@1} + ''' SetBonus: ''' - 8% reduced mana cost - 5% increased movement speed and magic critical strike chance + {$CommonItemTooltip.PercentReducedManaCost} + {1}% increased movement speed and magic critical strike chance + {$AerospecBreastplate.CommonSetBonus@2} ''' } -AerospecHeadgear: { +AerospecHeadRogue: { DisplayName: Aerospec Headgear - Tooltip: 10% increased rogue damage and 5% increased movement speed + Tooltip: "{$Common.RogueDamage} and {$CommonItemTooltip.PercentIncreasedMovementSpeed@1}" SetBonus: ''' - 5% increased movement speed and rogue critical strike chance - +80 maximum stealth + {$Common.RogueStealth} + {1}% increased movement speed and rogue critical strike chance + {$AerospecBreastplate.CommonSetBonus@2} ''' } -AerospecHelm: { +AerospecHeadMelee: { DisplayName: Aerospec Helm - Tooltip: 10% increased melee damage + Tooltip: "{$CommonItemTooltip.PercentIncreasedMeleeDamage}" SetBonus: ''' - 5% increased movement speed and melee critical strike chance - Enemies are more likely to target you + {0}% increased movement speed and melee critical strike chance + {$Common.AggroBoost} + {$AerospecBreastplate.CommonSetBonus@1} ''' } -AerospecHelmet: { +AerospecHeadSummon: { DisplayName: Aerospec Helmet - Tooltip: 10% increased summon damage and 5% increased movement speed + Tooltip: "{$CommonItemTooltip.PercentIncreasedSummonDamage} and {$CommonItemTooltip.PercentIncreasedMovementSpeed@1}" SetBonus: ''' - 11% increased summon damage and +1 max minion + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} Summons a valkyrie to protect you + {$AerospecBreastplate.CommonSetBonus@2} ''' } -AerospecHood: { +AerospecHeadRanged: { DisplayName: Aerospec Hood - Tooltip: 10% increased ranged damage - SetBonus: 5% increased movement speed and ranged critical strike chance + Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedDamage}" + SetBonus: + ''' + {0}% increased movement speed and ranged critical strike chance + {$AerospecBreastplate.CommonSetBonus@1} + ''' } AerospecLeggings: { DisplayName: Aerospec Leggings - Tooltip: 12% increased movement speed + Tooltip: "{$CommonItemTooltip.PercentIncreasedMovementSpeed}" } DesertProwlerHat: { DisplayName: Desert Prowler Hat - Tooltip: 4% increased ranged critical strike chance and 20% chance to not consume ammo - SetBonus: Ranged attacks deal an extra {0} flat damage - AbilityBrief: Sandsmoke Bomb - Double tap {0} to shroud yourself in a small cloud of sand - AbilityDescription: + Tooltip: "{$Common.RogueCrit}" + SetBonus: ''' - While the sand cloud is active, gain increased mobility but heavily reduced defense - Using a ranged weapon instantly dispels the sand cloak, but guarantees a supercrit for {0}% damage - The super crit applies only as long as the resulting hit wouldn't exceed {1} damage - Landing the killing blow on an enemy with this shot shortens the ability's cooldown to {2} seconds + {$Common.RogueStealth} + [c/{1}:Sandsmoke Bomb - {2} to shroud yourself in a small cloud of sand] + [c/CCB648:While the sand cloud is active, gain increased mobility but heavily reduced defense] + [c/CCB648:Using a rogue weapon instantly dispels the sand cloak, but guarantees a supercrit for {3}% damage] + [c/CCB648:The supercrit applies only as long as the resulting hit wouldn't exceed {4} damage] + [c/CCB648:Landing the killing blow on an enemy with this shot shortens the ability's cooldown to {5} {^5:second;seconds}] ''' } DesertProwlerPants: { DisplayName: Desert Prowler Pants - Tooltip: 10% increased movement speed and immunity to the Mighty Wind debuff + Tooltip: + ''' + {$Common.RogueCrit} + Grants immunity to {$BuffName.WindPushed} + ''' } DesertProwlerShirt: { DisplayName: Desert Prowler Shirt - Tooltip: 5% increased ranged critical strike chance + Tooltip: "{$Common.RogueDamage}" } MarniteArchitectHeadgear: { DisplayName: Marnite Architect Headgear - Tooltip: Increases block placement & tool range by 5 - AbilityBrief: Marnite Lift - You can summon a lift under your feet to reach higher up - AbilityDescription: + Tooltip: Increases block placement & tool range by {0} + SetBonus: ''' - The lift gets summoned when the mount hotkey gets pressed [c/D4C870:without any mounts equipped] - Using the Up and Down keys can change the lift's height + [c/{0}:Marnite Lift - You can summon a lift under your feet to reach higher up] + [c/91C5EF:The lift gets summoned when the mount hotkey gets pressed] [c/D4C870:without any mounts equipped] + [c/91C5EF:Press {$Key.UP} and {$Key.DOWN} to change the lift's height, reaching up to {1} tiles above ground] ''' } MarniteArchitectToga: { DisplayName: Marnite Architect Toga - Tooltip: Increases block & wall placement speed by 50% + Tooltip: Increases block & wall placement speed by {0}% } SnowRuffianChestplate: { DisplayName: Snow Ruffian Chestplate - Tooltip: 3% increased rogue critical strike chance + Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedCritChance}" } SnowRuffianGreaves: { DisplayName: Snow Ruffian Greaves - Tooltip: 5% increased movement speed + Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedCritChance}" } SnowRuffianMask: { DisplayName: Snow Ruffian Mask - Tooltip: 2% increased rogue damage + Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedCritChance}" SetBonus: ''' - 5% increased rogue damage - +50 maximum stealth You can glide to negate fall damage + Ranged critical strikes inflict [cbuff:Frostburn] for {0} {^0:second;seconds} ''' } StatigelArmor: { DisplayName: Statigel Armor - Tooltip: 5% increased critical strike chance + Tooltip: "{$CommonItemTooltip.PercentIncreasedCritChance}" CommonSetBonus: ''' - When you take over 100 damage in one hit you become immune to damage for an extended period of time Grants an extra jump and increased jump height - 12% increased jump speed + {0}% increased jump speed ''' } StatigelGreaves: { DisplayName: Statigel Greaves - Tooltip: 5% increased damage and movement speed + Tooltip: "{0}% increased damage and movement speed" } StatigelHeadMagic: { DisplayName: Statigel Cap Tooltip: ''' - 10% increased magic damage and 10% reduced mana cost - 7% increased magic critical strike chance and +40 max mana + {$CommonItemTooltip.IncreasesMaxManaBy} and {$CommonItemTooltip.PercentReducedManaCost@1} + {$CommonItemTooltip.PercentIncreasedMagicDamage@2} and {$CommonItemTooltip.PercentIncreasedMagicCritChance@3} ''' } @@ -149,18 +164,22 @@ StatigelHeadMelee: { DisplayName: Statigel Helm Tooltip: ''' - 10% increased melee damage and melee speed - 7% increased melee critical strike chance + {0}% increased melee damage and melee speed + {$CommonItemTooltip.PercentIncreasedMeleeCritChance@1} + ''' + SetBonus: + ''' + {$Common.AggroBoost} + {$StatigelArmor.CommonSetBonus} ''' - SetBonus: Enemies are more likely to target you } StatigelHeadRanged: { DisplayName: Statigel Headgear Tooltip: ''' - 10% increased ranged damage - 7% increased ranged critical strike chance + {$CommonItemTooltip.PercentIncreasedRangedDamage} + {$CommonItemTooltip.PercentIncreasedRangedCritChance@1} ''' } @@ -168,117 +187,113 @@ StatigelHeadRogue: { DisplayName: Statigel Mask Tooltip: ''' - 10% increased rogue damage - 7% increased rogue critical strike chance and 5% increased movement speed + {$Common.RogueDamage} + {$Common.RogueCrit@1} and {$CommonItemTooltip.PercentIncreasedMovementSpeed@2} + ''' + SetBonus: + ''' + {$Common.RogueStealth} + {$StatigelArmor.CommonSetBonus@1} ''' - SetBonus: +90 maximum stealth } StatigelHeadSummon: { DisplayName: Statigel Hood - Tooltip: Increased minion knockback + Tooltip: + ''' + {$CommonItemTooltip.IncreasesMaxMinionsBy} + {$CommonItemTooltip.PercentIncreasedSummonDamage@1} + ''' SetBonus: ''' - 18% increased summon damage and +1 max minion + {$CommonItemTooltip.PercentIncreasedSummonDamage} Summons a mini paladin to fight for you, the type depends on what world evil you have + {$StatigelArmor.CommonSetBonus@1} ''' } SulphurousBreastplate: { DisplayName: Sulphurous Breastplate - Tooltip: 6% increased rogue damage and 4% increased rogue critical strike chance + Tooltip: "{$Common.RogueDamage}" } SulphurousHelmet: { DisplayName: Sulphurous Helmet Tooltip: ''' - 4% increased rogue damage - 2% increased rogue critical strike chance + {$Common.RogueCrit} Grants underwater breathing ''' SetBonus: ''' - +65 maximum stealth - Attacking and being attacked by enemies inflicts poison + {$Common.RogueStealth} + Attacking and being attacked by enemies inflicts [cbuff:Poisoned] for {1} {^1:second;seconds} Grants an additional jump that summons a sulphurous bubble - Provides increased underwater mobility and reduces the severity of the sulphuric waters + Reduces the severity of the sulphuric waters ''' } SulphurousLeggings: { DisplayName: Sulphurous Leggings - Tooltip: - ''' - Movement speed increased by 10% - Movement speed increased an additional 25% while submerged in liquid - ''' + Tooltip: "{$Common.RogueDamage}" } VictideBreastplate: { DisplayName: Victide Breastplate - Tooltip: - ''' - 5% increased damage reduction and critical strike chance - +5 defense and 10% increased damage reduction while submerged in liquid - ''' - CommonSetBonus: - ''' - When using any weapon you have a 10% chance to throw a returning seashell projectile - This seashell does true damage and does not benefit from any damage class - Provides increased underwater mobility and slightly reduces breath loss in the abyss - ''' + Tooltip: +{0} HP/s life regen } VictideGreaves: { DisplayName: Victide Greaves + Tooltip: "{$CommonItemTooltip.PercentIncreasedMovementSpeed}" +} + +VictideHeadBarrier: { + DisplayName: Victide Hermit Helmet Tooltip: ''' - Movement speed increased by 8% - Movement speed increased by 30% while submerged in liquid + +{0} HP/s life regen + Increases movement acceleration and deceleration by {1}x ''' -} - -VictideHeadMagic: { - DisplayName: Victide Hermit Helmet - Tooltip: 5% increased magic damage - SetBonus: +1.5 HP/s life regen and 10% increased magic damage while submerged in liquid -} - -VictideHeadMelee: { - DisplayName: Victide Shellmet - Tooltip: 5% increased melee damage SetBonus: ''' - Enemies are more likely to target you - +1.5 HP/s life regen and 10% increased melee damage while submerged in liquid + [c/{0}:Warding Wave - Forms a tidal barrier which can be exploded to launch you] + [c/A2D6FF:The barrier grants {1} defense and gradually heals back {2}% of taken damage] + [c/A2D6FF:{3} to disperse it for {4} {^4:second;seconds} and propel you in the direction of the cursor] + [c/A2D6FF:The resulting dash can slam through and damage enemies] ''' } -VictideHeadRanged: { - DisplayName: Victide Coral Turban - Tooltip: 5% increased ranged damage - SetBonus: +1.5 HP/s life regen and 10% increased ranged damage while submerged in liquid -} - -VictideHeadRogue: { +VictideHeadBurrow: { DisplayName: Victide Headcrab - Tooltip: 5% increased rogue damage + Tooltip: + ''' + {0}% increased movement speed and acceleration + Grants underwater breathing and slightly reduces breath loss in the abyss + ''' SetBonus: ''' - +60 maximum stealth - +1.5 HP/s life regen and 10% increased rogue damage while submerged in liquid + Allows quick travel in water + [c/{0}:Bubbly Burrow - {1} to transform into an agile water spirit for a short time] + [c/A2D6FF:The spirit can be controlled through movement keys and can traverse through tiles] + [c/A2D6FF:While in spirit form, you are impervious to most damage but unable to use items] + [c/A2D6FF:This effect lasts {2} {^2:second;seconds} and has a cooldown of {3} {^3:second;seconds}] ''' } -VictideHeadSummon: { +VictideHeadSnail: { DisplayName: Victide Mask - Tooltip: 10% increased summon damage + Tooltip: + ''' + {$CommonItemTooltip.IncreasesFishingPowerBy} + {$Common.AggroReduction} + ''' SetBonus: ''' - +1 max minion - Summons a sea snail to protect you - +1.5 HP/s life regen and 10% increased summon damage while submerged in liquid + Increases pickup range for items + [c/{0}:Helper Angler - Summons a sea snail to fish alongside you] + [c/A2D6FF:It automatically casts and reels as you are standing still and fishing] + [c/A2D6FF:Equipped fishing abilities and stats are inherited from its owner] ''' } @@ -296,25 +311,24 @@ WulfrumHat: { DisplayName: Wulfrum Hat & Goggles Tooltip: ''' - 10% increased summon damage + {$CommonItemTooltip.PercentIncreasedSummonDamage} Comes equipped with hair extensions ''' - SetBonus: +1 max minion - AbilityBrief: Wulfrum Bastion - Double tap {0} while dismounted to equip wulfrum power armor - AbilityDescription: + SetBonus: ''' - While the armor is active, you can only use the integrated fusion cannon, but your defensive stats are increased - Calling down the armor consumes one piece of {0}, and the armor will lose durability faster when hit + [c/{0}:Wulfrum Bastion - {1} to equip a power armor, costing one] [i:CalamityMod/WulfrumMetalScrap] [c/{0}:{$Items.Materials.WulfrumMetalScrap.DisplayName}] + [c/6EC05D:While active, you can only use the integrated fusion cannon, but your defensive stats are increased] + [c/6EC05D:The armor lasts up to {2} {^2:second;seconds}, but each hit loses {3} {^3:second;seconds} of duration] + [c/BEBEBE:Hold Shift to see the stats of the fusion cannon] ''' - ShiftToExpand: Hold SHIFT to see the stats of the fusion cannon } WulfrumJacket: { DisplayName: Wulfrum Jacket - Tooltip: 5% increased damage reduction + Tooltip: "{$CommonItemTooltip.IncreasesMaxMinionsBy}" } WulfrumOveralls: { DisplayName: Wulfrum Overalls - Tooltip: Movement speed increased by 5% + Tooltip: "{$CommonItemTooltip.PercentIncreasedSummonDamage}" } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Vanity.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Vanity.hjson index 7ac8dddb6c..2c7fff7f7e 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Vanity.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Vanity.hjson @@ -58,7 +58,7 @@ AstrumDeusMask: { Tooltip: "" } -BrimstoneWaifuMask: { +BrimstoneElementalMask: { DisplayName: Brimstone Elemental Mask Tooltip: "" } @@ -128,6 +128,21 @@ LeviathanMask: { Tooltip: "" } +LucisBoots: { + DisplayName: Luci's Boots + Tooltip: "'One small step a time, you can do this.'" +} + +LucisHairstyle: { + DisplayName: Luci's Hairstyle + Tooltip: "'Hero of Light, Luci Skyshot.'" +} + +LucisMilitaryUniform: { + DisplayName: Luci's Military Uniform + Tooltip: "'Bearing the iconic Liberation Army insignia of freedom.'" +} + OldDukeMask: { DisplayName: Old Duke Mask Tooltip: "" @@ -253,6 +268,16 @@ TheGrandGarment: { Tooltip: Part of The High-Flying Finery } +VictideCoralTurban: { + DisplayName: Victide Coral Turban + Tooltip: "" +} + +VictideShellmet: { + DisplayName: Victide Shellmet + Tooltip: "" +} + YharonMask: { DisplayName: Yharon Mask Tooltip: "" diff --git a/Localization/en-US/Mods.CalamityMod.Items.Debug.hjson b/Localization/en-US/Mods.CalamityMod.Items.Debug.hjson new file mode 100644 index 0000000000..3e4013eca5 --- /dev/null +++ b/Localization/en-US/Mods.CalamityMod.Items.Debug.hjson @@ -0,0 +1,4 @@ +DialogueDisplayDebugItem: { + DisplayName: Dialogue Display Debug Item + Tooltip: "" +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Dyes.hjson b/Localization/en-US/Mods.CalamityMod.Items.Dyes.hjson index 5ccba37d5d..9b45147d45 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Dyes.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Dyes.hjson @@ -123,6 +123,11 @@ WingTimeHairDye: { Tooltip: "" } +InvisibleDye: { + DisplayName: Invisible Dye + Tooltip: "" +} + LivingShardDye: { DisplayName: Living Shard Dye Tooltip: "" diff --git a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson index a79d57210b..48756b94b9 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson @@ -1,7 +1,10 @@ -// Quest fish tooltips -CaughtInAstral: "'Caught in the Astral Infection'" -CaughtInBrimstoneCrag: "'Caught in the Brimstone Crag'" -CaughtInSunkenSea: "'Caught in the Sunken Sea'" +// Quest fish tooltips +CaughtInAstral: Caught in the Astral Infection +CaughtInBrimstoneCrag: Caught in the Brimstone Crag +CaughtInSnow: Caught in Tundra +CaughtInSpace: Caught in Sky Lakes +CaughtInSunkenSea: Caught in the Sunken Sea +LocationTooltip: "'{0}'" // Astral Infection Catches AldebaranAlewife: { @@ -102,14 +105,14 @@ DragoonDrizzlefish: { ''' Fires an assortment of hellfire and brimstone fireballs Sometimes fires a larger splitting fireball - Right click to feed the little boy some tasty gel + to feed the little boy some tasty gel 'He is a hungry boy' ''' } Havocfish: { DisplayName: Havocfish - Tooltip: Press to extract [i:CalamityMod/EssenceofHavoc] essence + QuestDescription: When you killed that gross flesh wall, so much chaos and havoc was infused into those ruinous crags that even the lava sprouted fish made of the pure essence! Go fetch it for me, pure havoc sounds like exactly what my next scheme needs! } Shadowfish: { @@ -128,6 +131,11 @@ Slurpfish: { } // Sunken Sea Catches +CoralskinFoolfish: { + DisplayName: Coralskin Foolfish + Tooltip: Camouflage is one of nature's best defenses +} + EutrophicCrate: { DisplayName: Eutrophic Crate Tooltip: "{$CommonItemTooltip.RightClickToOpen}" @@ -138,27 +146,37 @@ EutrophicSandfish: { QuestDescription: You ever wondered what would happen if a lizard that lived in the desert wandered too deep into those old Ilmeran areas? Well I know, and it looks super cool! But it's way too slippery for me to get my hands on, so you go and get it so I can keep it as a pet! } +GleamingCucumber: { + DisplayName: Gleaming Cucumber + Tooltip: A slippery, slimy creature found on the Polyp Forest's floor +} + GreenwaveLoach: { DisplayName: Greenwave Loach Tooltip: An endangered fish that is highly prized in the market } +MoltenFishron: { + DisplayName: Molten Fishron + Tooltip: + ''' + Instead of honking it makes crisp wheezing noises + Or maybe it actually is wheezing due to being taken out of lava + ''' +} + PrismCrate: { DisplayName: Prism Crate Tooltip: "{$CommonItemTooltip.RightClickToOpen}" } -PrismaticGuppy: { - DisplayName: Prismatic Guppy - Tooltip: Throwing these in an aquarium would be insanity -} - RustedJingleBell: { DisplayName: Rusted Jingle Bell Tooltip: ''' - Summons a baby ghost bell light pet + Summons a baby ghost bell to light the way for you Provides a moderate amount of light while underwater + {$Common.AbyssLightLevel} ''' } @@ -179,14 +197,14 @@ SparklingEmpress: { ''' Fires a stream of erratic magic After firing for long enough, the fish will shine - Ceasing use of the fish while it shines will restore some of your mana and life + Ceasing use of the fish while it shines will restore some of your mana 'An beautiful fish that seems to feed on mana' ''' TooltipGFB: ''' Fires a stream of erratic magic After firing for long enough, the fish will shine - Ceasing use of the fish while it shines will restore some of your mana and life + Ceasing use of the fish while it shines will restore some of your mana 'Hello there, you seem to be an unfamiliar face around here. Perhaps you are surprised a fish like me is able to speak? No need for worry, I have no intention of any foul play. @@ -202,6 +220,20 @@ SparklingEmpress: { ''' } +SpecularSturgeon: { + DisplayName: Specular Sturgeon + Tooltip: + ''' + A deep-dwelling fish that can live for many generations + Needless to say, it's old! + ''' +} + +Squidoom: { + DisplayName: Squidoom + Tooltip: Those who gaze at it for too long are said to enter a hypnotic state +} + SunkenSailfish: { DisplayName: Sunken Sailfish Tooltip: Zooming at 60 miles per hour @@ -224,7 +256,7 @@ EnchantedStarfish: { FishofEleum: { DisplayName: Fish of Eleum - Tooltip: Press to extract [i:CalamityMod/EssenceofEleum] essence + QuestDescription: It's so unfair that all the cool fish only come out when you slay big demon guys! I mean that "cool" in two ways by the way. I've seen fish in the tundra materialized out of the essence of pure coldness! It's about time I get an ice pack for my fish, so fetch me that fish, or you're cold! } FishofFlight: { @@ -232,16 +264,6 @@ FishofFlight: { Tooltip: Press to extract [i:SoulofFlight] souls } -FishofLight: { - DisplayName: Fish of Light - Tooltip: Press to extract [i:SoulofLight] souls -} - -FishofNight: { - DisplayName: Fish of Night - Tooltip: Press to extract [i:SoulofNight] souls -} - GlimmeringGemfish: { DisplayName: Glimmering Gemfish Tooltip: Press to extract [ITEMS] gems @@ -278,7 +300,7 @@ SulphurousCrate: { SunbeamFish: { DisplayName: Sunbeam Fish - Tooltip: Press to extract [i:CalamityMod/EssenceofSunlight] essence + QuestDescription: Have you ever seen those sunskaters that float way above the clouds? Well, I'll let you in on my little secret: They began their lives as little fish! So what are you waiting for, go reach for the stars and pluck one down for me! } // Fishing Rods @@ -314,9 +336,9 @@ NavyFishingRod: { DisplayName: Navy Fishing Rod Tooltip: ''' - While held, slowly electrifies nearby enemies - 'The sea is a city. - Just below are highways, boulevards, streets and roundabouts bustling with submarine traffic.' + Fires bobbers that inflict Static Discharge on nearby enemies + 'The sea is a city. Just below are highways, boulevards, + streets, and roundabouts bustling with submarine traffic.' ''' } @@ -324,7 +346,7 @@ RiftReeler: { DisplayName: Rift Reeler Tooltip: ''' - Fires three to five lines at once + Fires four lines at once Can fish in lava 'The battlefield is a scene of constant chaos. The winner will be the one who controls that chaos, both the pole and the fish.' @@ -345,6 +367,9 @@ TheDevourerofCods: { Tooltip: ''' Fires ten lines at once. Line never snaps and can fish from lava + Hooked items stay hooked forever + Common fish are automatically consumed while fishing + Consuming fish allows a bobber to hook a new item and feeds the user 'The devourer was once just an Eater of Shoals' ''' } @@ -360,7 +385,11 @@ VerstaltiteFishingRod: { WulfrumRod: { DisplayName: Wulfrum Fishing Pole - Tooltip: "'This barely works, but it's better than nothing...'" + Tooltip: + ''' + Can fish up Wulfrum Metal Scrap and Wulfrum Energy Cores + 'This barely works, but it's better than nothing...' + ''' } // Bait @@ -368,3 +397,64 @@ GrandMarquisBait: { DisplayName: Grand Marquis Bait Tooltip: "" } + +// Bobbers +ScrapBobber: { + DisplayName: Wulfrum Bobber + Tooltip: + ''' + Provides a fishing minigame + Move in the indicated direction while fishing to catch items + The rod empowers the longer you go without a mistake, speeding it up + 'There's supposed to be a fish finder installed, but it only beeps when you point it at yourself...' + ''' +} + +NavystoneBobber: { + DisplayName: Sunken Sinker + Tooltip: + ''' + {$ItemTooltip.FishingBobber} + Provides a fishing minigame + The bobber will float at your height underwater, allowing underwater fishing + Move in the indicated direction while fishing to catch items + ''' +} + +SkylineBobber: { + DisplayName: Acrobatic Bobber + Tooltip: + ''' + {$ItemTooltip.FishingBobber} + Provides a fishing minigame + Moving while fishing instead moves your bobbers + Rings appear over time above the water's surface + Touching a ring hooks an item onto the bobber + Bobbers will automatically reel in hooked items upon landing back in the water + ''' +} + +PerennialBobber: { + DisplayName: Feral Bobber + Tooltip: + ''' + {$ItemTooltip.FishingBobber} + Gains fishing power the more life you have lost + Provides a fishing minigame + Hold while catching fish to drain life and speed up catches + Bobbers can hook onto enemies, dealing damage when life is drained + ''' +} + +ScoriaBobber: { + DisplayName: Volcanic Sinker + Tooltip: + ''' + {$ItemTooltip.FishingBobber} + Allows fishing in lava + Provides a fishing minigame + Moving while fishing instead moves your bobbers + Rifts appear over time in liquids, containing an item + When bobbers touch a rift, they automatically reel in the item within + ''' +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson index eeb8cd9033..a14d21675b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson @@ -1,7 +1,7 @@ ShortTooltip: ''' [c/E3AF40:Whispers from on high dance in your ears...] - [c/BEBEBE:Press "Left Shift" to listen closer] + [c/BEBEBE:Hold Shift to listen closer] ''' LoreAbyss: { @@ -11,7 +11,7 @@ LoreAbyss: { While there are many sightless crevasses in the deep sea, this one is a geological marvel. It is located unsettlingly close to the shoreline. Somehow, even eons of tectonics could not seal or crush it. The isolated Abyss is the debatably tranquil home of the naiad Anahita and other reclusive sea creatures. - Here I disposed of the burgeoning remains of Silva, the Goddess of Life itself. Obviously, she of all Gods refused to truly die. + Here I disposed of the burgeoning remains of Silva, the goddess of life itself. Obviously, she of all gods refused to truly die. My wishes were that she would be forgotten, but her tenacity and very willpower is remarkable. Diffused, her influence inundated that pit of crushing pressure with flora and fauna aplenty. Her great roots continue to thrash and tear at the impossibly dense stone, growing uncontrollably. @@ -81,8 +81,8 @@ LoreAstrumDeus: { DisplayName: Astrum Deus Lore: ''' - On our world, this being is revered as the God of the night sky. It is said to devour dying stars and birth new ones in turn. - Unlike the many Gods you or I know, it is guiltless. An important distinction, for it was equally as diseased as they. + On our world, this being is revered as the god of the night sky. It is said to devour dying stars and birth new ones in turn. + Unlike the many gods you or I know, it is guiltless. An important distinction, for it was equally as diseased as they. The infection that tainted its body is from beyond Terraria. Neither I nor Draedon recognize it fully. With its will subsumed, it hurled a chunk of infested astral matter at our world, then came to guard it. Thankfully, such a grandiose being that walks amongst the stars is likely not truly dead. @@ -95,7 +95,7 @@ LoreAwakening: { DisplayName: Awakening Lore: ''' - The tombs of the Dragons stir. My eyes lift to see ancient dust dancing from high ledges. + The tombs of the dragons stir. My eyes lift to see ancient dust dancing from high ledges. These grand wings… how long has it been since I was a hero worthy of their name? It feels like centuries have passed, yet all I've done is blink. Look upon my works, as they are… Ruined. None would dare seek me out; tread my path. @@ -121,7 +121,7 @@ LoreBloodMoon: { DisplayName: Blood Moon Lore: ''' - This malevolence is not the work of any God. Blood moons trace their origins to the dawn of history. + This malevolence is not the work of any god. Blood moons trace their origins to the dawn of history. It is an occurrence equally sinister and banal. Everyone is acclimated to the shambling hordes of undead. Organized societies are not threatened in the slightest. If anything, they welcome the opportunity to train green foot soldiers. Those with fire in their veins may strike out on their own, to revel in the slaughter. @@ -135,7 +135,7 @@ LoreBrainofCthulhu: { Lore: ''' It is true that unspeakable abominations may now be commonplace, largely by my hand. - Though they have always been a product of the folly of the Gods, the same Gods would cull them in equal measure. + Though they have always been a product of the folly of the gods, the same gods would cull them in equal measure. My decimation of the falsely divine left many old horrors unconstrained, with new ones birthed every year. Now, they are your stepping stones. ''' @@ -166,10 +166,10 @@ LoreCalamitas: { When I first saw her, she was still a girl. Prostrated in my court, garbed in charred rags as she trembled. I could not grasp the unfathomable, raw power of the fell magics that coursed through her. She could scant control it herself. Permafrost recognized this immediately. With a pained face, he counseled me to look after her. - The Witch entered his tutelage, and soon after my service. She was ablaze with desire to douse the Gods in her wicked wrath. + The Witch entered his tutelage, and soon after my service. She was ablaze with desire to douse the gods in her wicked wrath. Indeed, the faithful already quaked in her presence. Her name was a moniker of theirs, one uttered quietly in fear. In my campaigns, I counted on her sheer capacity for annihilation as my ace in the hole. - No man: army, city or God could stand against her unbridled fury. + No man, army, city or god could stand against her unbridled fury. Eventually, the girl's horrific sin was too much for her to bear. She left my side along with her mentor. The weight of her deeds haunts her to this day. She despises me, and I cannot blame her. Please, if you would... show her respect where I did not. @@ -210,9 +210,9 @@ LoreCorruption: { DisplayName: The Corruption Lore: ''' - To not properly dispose of the essence of a slain God is a fatal mistake. This wasteland stands as proof of such. - Having slain my first Gods, I turned a blind eye as corrupt essence gushed from their rent forms and burrowed into the bowels of Terraria. - The mere existence of this putrid place proves that the Gods of old were beyond redemption. + To not properly dispose of the essence of a slain god is a fatal mistake. This wasteland stands as proof of such. + Having slain my first gods, I turned a blind eye as corrupt essence gushed from their rent forms and burrowed into the bowels of Terraria. + The mere existence of this putrid place proves that the gods of old were beyond redemption. ''' Tooltip: "" } @@ -233,8 +233,8 @@ LoreCrimson: { Lore: ''' The foul air, the morbid fauna, the disgusting terrain… Here lies the first mistake of my crusade. - The essence of a God does not simply vanish when the body dies. It must be properly disposed of or destroyed entirely. - Essence of a pious God could never fester into a mire as dreadful as this. + The essence of a god does not simply vanish when the body dies. It must be properly disposed of or destroyed entirely. + Essence of a pious god could never fester into a mire as dreadful as this. ''' Tooltip: "" } @@ -248,7 +248,7 @@ LoreCynosure: { You have rent all asunder as they crossed your path. The very land now bends to your will. Do you not see how the grass parts where you step, how the stars illuminate where you gaze? Terraria itself kneels to you, whether it be out of fear or respect. - This is the strength the Dragons held. The primordial power they commanded. + This is the strength the dragons held. The primordial power they commanded. Little stands between us now. If you did not seek battle with me, I doubt you would have come so far. When you are prepared: seek the grave of the Light, at the summit of the Dragon Aerie. I await your challenge. @@ -286,8 +286,8 @@ LoreDevourerofGods: { Lore: ''' The infamous, otherworldly glutton, in the flesh. His imposing title was self-granted, but undeniable truth made it stick. - He is a formidable foe: Capable of swallowing Gods whole, absorbing their essence in its entirety. - I ordered Draedon to armor his gargantuan form, so he could safely best even the greater Gods in single combat. + He is a formidable foe: Capable of swallowing gods whole, absorbing their essence in its entirety. + I ordered Draedon to armor his gargantuan form, so he could safely best even the greater gods in single combat. Fittingly, he possessed a serpent's tongue. He manipulated me incessantly, driving me to awful acts. I recruited him out of desperation. My war had dragged on for decades, and I would do anything to have it end. It was then my negligence was born. My descent began the moment recruiting this scoundrel crossed my mind. @@ -302,7 +302,7 @@ LoreDragonfolly: { DisplayName: Dragonfolly Lore: ''' - Near the close of the Draconic Era, there are records of the "impure" Dragon species. + Near the close of the Draconic Era, there are records of the "impure" dragon species. Wyverns, basilisks, Pigrons and the like are documented. Though none are sure how exactly they came to be. To this day, scholars argue over the true names and lineages of these creatures. Names aside: it is clear the first offshoots are pure enough to retain the great strength of their forebears. @@ -319,9 +319,9 @@ LoreDukeFishron: { ''' Outlandish as they may seem, this species is the single mightiest of the seas. They are relentless hunters and can easily spend significant time out of the water. - Folklore holds that the Fishrons claim heritage from the true Dragons; countless years back. + Folklore holds that the fishrons claim heritage from the true dragons; countless years back. While there are many such tales of creatures hailing draconic descent, this case is factual. - Genetic heritage or not: the Fishrons lack Auric souls. I would know well. + Genetic heritage or not: the fishrons lack auric souls. I would know well. ''' Tooltip: "" } @@ -357,7 +357,7 @@ LoreExoMechs: { Lore: ''' What a terrifying marvel of engineering. Draedon's specialty always lay in the machines of war, but these are immaculate. - His bold claim that no God can match his work is, however… incorrect. He is not privy to the Traitor almighty. + His bold claim that no god can match his work is, however… incorrect. He is not privy to the Traitor almighty. Regardless, from steel and wit alone, he has forged engines of destruction that rival Calamitas. It brings me little comfort to remark that even she, at least has a heart to speak of. Draedon is an amoral monster beyond compare. He is entirely devoid of humanity and compassion. @@ -386,7 +386,7 @@ LoreGolem: { ''' What a sad, piteous thing. Truly, a mockery in every sense of the word. The Lihzahrds were abandoned by their deity long ago. They set upon creating the idol as a pathetic replacement. - The result is an amalgamation of the concepts and themes of many Gods, prominently the heat of the sun. + The result is an amalgamation of the concepts and themes of many gods, prominently the heat of the sun. It is a far cry from a mechanical god… for the better. The alternative is too chilling to consider. While I believe this insignificant construct deserves no mention, the Lihzahrds revere it unflinchingly. I see no need to intervene in affairs beneath me and my people. @@ -398,7 +398,7 @@ LoreHiveMind: { DisplayName: The Hive Mind Lore: ''' - Some semblance of a God's mind may survive death, much like the twitches of a crushed insect. + Some semblance of a god's mind may survive death, much like the twitches of a crushed insect. What little remains attempts to convene and coalesce in worship. A desperate attempt that its power may yet be restored. How pitiful. Fortunately for us, the futility of this effort is unmatched. The biomass obeys; even though nothing is accomplished. Divine power is known to be rooted in faith. Gods are forged of their own strength, and the mindless spread of corruption is its own foul reverence. @@ -451,7 +451,7 @@ LoreOldDuke: { ''' That was possibly one of the oldest mundane living beings on the face of the planet. The first Fishrons were spotted in the middle of the Draconic Era. What exotic prestige…! - Fishrons were one of the original offshoots of pure-blooded Auric Dragons. + Fishrons were one of the original offshoots of pure-blooded auric dragons. They are so old and venerated that many historians are convinced they are the original sea monsters of folklore. This particular Duke's guile is self-evident: It evaded centuries of hunting, and until now had survived a most thorough poisoning. Above almost all others, this creature was a living fable. One must wonder what goes through the mind of a fading legend…. @@ -463,7 +463,7 @@ LorePerforators: { DisplayName: The Perforators and Their Hive Lore: ''' - These creatures were unique. They wielded the slain Gods' power as purely as possible, veins flowing with spilt ichor. + These creatures were unique. They wielded the slain gods' power as purely as possible, veins flowing with spilt ichor. All that exists in the Crimson is truly the divine turned inside out; their gore now glistens with perverse treachery for all to bear witness. The mire reeks of centuries of vile manipulation and callous domination of the hapless. Judgement has long passed and only extinction is left waiting. @@ -521,14 +521,14 @@ LorePrelude: { DisplayName: Prelude Lore: ''' - In ages past, now named the Draconic Era, the majestic Dragons protected Terraria from all threats. + In ages past, now named the Draconic Era, the majestic dragons protected Terraria from all threats. Their famed might was put to the ultimate test by an aberrant behemoth from beyond the stars. - Fighting with all their strength, the Dragons could wound and weaken it… but not destroy it. + Fighting with all their strength, the dragons could wound and weaken it… but not destroy it. Lacking options, they tore the monster down to a shadow of its former self; sealing it away. - What is left of it now lies imprisoned in the Moon, as far away as the Dragons could banish it. + What is left of it now lies imprisoned in the Moon, as far away as the dragons could banish it. Much of dragonkind was lost as casualties in that struggle, and they never recovered. Zeratros himself was gravely injured. It seemed his power, along with his life, would be lost forever. - One mortal, sworn to the service of the Dragons, rose in determination to save their virtuous King. + One mortal, sworn to the service of the dragons, rose in determination to save their virtuous King. ''' Tooltip: "" } @@ -540,7 +540,7 @@ LoreProfanedGuardians: { The Guardians are foul extensions of the Profaned Goddess' power, wielders of the same wicked flame. They were given partial autonomy to hunt down threats, rarely spotted outside of temples sanctified in her name. She has been expanding her iniquitous domain, and she believes you to be her largest threat. - After all, it was you that finished off the voidborn horror that catalyzed the downfall of the Dragons. + After all, it was you that finished off the voidborn horror that catalyzed the downfall of the dragons. Draw her out from hiding. Have no mercy; the Profaned Goddess shows none herself. ''' Tooltip: "" @@ -552,10 +552,10 @@ LoreProvidence: { ''' A glorious day. Deeds of valor of this caliber are enshrined in legend. Of this age only the Witch, Braelor and myself can compare. - Providence was perhaps one of the wickedest Gods, hellbent on purification through erasure. + Providence was perhaps one of the wickedest gods, hellbent on purification through erasure. Her worshippers saw little value in life. Pain was not a price they felt justified to pay. The Profaned Goddess promised her followers she would end inequality by reducing all to featureless ash. - Those devoted to her were weak-willed, yet she reigned as one of the mightiest Gods. + Those devoted to her were weak-willed, yet she reigned as one of the mightiest gods. Perhaps it was their easily-swayed nature that let her draw so much power from them…. ''' Tooltip: "" @@ -605,12 +605,12 @@ LoreRequiem: { Lore: ''' As the Light Dragon was fading, a monk visited him. Nearly none understand what transpired that day. - Most say his passing was eased. The truth? Zeratros' Auric soul was consumed; utterly. + Most say his passing was eased. The truth? Zeratros' auric soul was consumed; utterly. The monk stood, wreathed in Primordial Light, declaring themselves Xeroc. The First God. - When a Dragon is laid to rest on the Aerie, its powers are relinquished so they may one day return. + When a dragon is laid to rest on the Aerie, its powers are relinquished so they may one day return. Xeroc renounced their sworn oath and broke the cycle, becoming a traitor without equal. - Word of the ascension spread quickly. Many attempted to follow suit, hoping to claim an Auric soul for themselves. - Now you know… Good intentions or no, all Gods are sinners. Each and every one complicit in genocide. + Word of the ascension spread quickly. Many attempted to follow suit, hoping to claim an auric soul for themselves. + Now you know… Good intentions or no, all gods are sinners. Each and every one complicit in genocide. Wherever your journey may lead, whether you are with me or against…. May fortune favor you. For nothing else will. ''' @@ -637,7 +637,7 @@ LoreSkeletron: { Lore: ''' An unfortunate old man who was caught by an ancient cult, cursing him for trespassing on their ancient library. - They were once my friends. The leader is infatuated with Dragons, with a dream of even resurrecting one. + They were once my friends. The leader is infatuated with dragons, with a dream of even resurrecting one. The very walls of that place are cursed further still. The magic has long since faded as the soldiers rotted within. Do not expect to learn much from those tarnished tomes. They were penned with misguided zeal. ''' @@ -720,7 +720,7 @@ LoreUnderworld: { ''' The hellish reputation the underworld gets is rather a recent development. The layers of ash choking the formerly great cities is still warm. - The more domineering of Gods wished for me to champion their causes, asking to rule their society from here. + The more domineering of gods wished for me to champion their causes, asking to rule their society from here. Yet despite being surrounded by magma, Azafure simply burned when their wishes were not met. Such is the unfortunate price of war, though I have no regrets fighting for my people. ''' @@ -731,7 +731,7 @@ LoreWallofFlesh: { DisplayName: The Wall of Flesh Lore: ''' - To contain the essence of a slain God is no small thing. It is rather a towering, ghastly construct. + To contain the essence of a slain god is no small thing. It is rather a towering, ghastly construct. The Wall was lashed together with foul sinew and fouler magics, forming a rudimentary prison of flesh. It served its purpose: halting the diffusion of undue divine influence. Were it not for this alchemical breakthrough, the very world I fought for may have been lost in the carnage I wrought. @@ -746,9 +746,9 @@ LoreYharon: { Lore: ''' The return of the Age of Dragons, dashed. Just like that, it is but ashes in the wind…. - Yharon was the last of the Auric Dragons. As a phoenix, his domain of power includes rebirth. - The Gods thought him culled with the rest of his kind, but he returned as an egg. Hidden on the Aerie. - I was destined to consume his Auric soul when he hatched, and rule forever as God-King. + Yharon was the last of the auric dragons. As a phoenix, his domain of power includes rebirth. + The gods thought him culled with the rest of his kind, but he returned as an egg hidden on the Aerie. + I was destined to consume his auric soul when he hatched, and rule forever as God-King. [c/FCA92B:Destiny is for the weak.] diff --git a/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson b/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson index e6c83d21fe..ba2ebe56aa 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Materials.hjson @@ -53,11 +53,6 @@ BloodOrb: { Tooltip: "" } -BloodSample: { - DisplayName: Blood Sample - Tooltip: "" -} - Bloodstone: { DisplayName: Bloodstone Tooltip: "" @@ -247,11 +242,6 @@ ReaperTooth: { Tooltip: Sharp enough to cut diamonds } -RottenMatter: { - DisplayName: Rotten Matter - Tooltip: "" -} - RuinousSoul: { DisplayName: Ruinous Soul Tooltip: A shard of the distant past @@ -331,3 +321,13 @@ YharonSoulFragment: { DisplayName: Yharon Soul Fragment Tooltip: A shard of a draconic Auric Soul } + +AnodizedWulfrumMetal: { + DisplayName: Anodized Wulfrum Metal + Tooltip: "" +} + +WillOWisp: { + DisplayName: Will O Wisp + Tooltip: "" +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson index 45aa900888..18c738eb26 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Misc.hjson @@ -1,11 +1,11 @@ // Critters AlphaSeaMinnowItem: { - DisplayName: Alpha Sea Minnow + DisplayName: "{$NPCs.AlphaSeaMinnow.DisplayName}" Tooltip: "" } AlphaSeaMinnowGoldItem: { - DisplayName: Gold Alpha Sea Minnow + DisplayName: "{$NPCs.AlphaSeaMinnowGold.DisplayName}" Tooltip: "" } @@ -34,7 +34,7 @@ BabyGhostBellItem: { } BabyGhostBellGoldItem: { - DisplayName: Gold Baby Ghost Bell + DisplayName: "{$NPCs.GoldBabyGhostBell}" Tooltip: "" } @@ -44,12 +44,17 @@ BabyGhostBellGreenItem: { } BabyGhostBellRadiantItem: { - DisplayName: Radiant Baby Ghost Bell + DisplayName: "{$NPCs.RadiantBabyGhostBell}" Tooltip: "" } -BabyGhostBellRedItem: { - DisplayName: Red Baby Ghost Bell +BabyGhostBellPinkItem: { + DisplayName: Pink Baby Ghost Bell + Tooltip: "" +} + +GildedAxolotlItem: { + DisplayName: Gilded Axolotl Tooltip: "" } @@ -83,18 +88,13 @@ PearlpodItem: { Tooltip: "" } -PearlpodGoldItem: { - DisplayName: Gold Pearlpod - Tooltip: "" -} - PearlpodPinkItem: { DisplayName: Pink Pearlpod Tooltip: "" } PolypPanaseaGoldItem: { - DisplayName: Gold Polyp Panasea + DisplayName: "{$NPCs.GoldPolypPanasea}" Tooltip: "" } @@ -114,7 +114,7 @@ PolypPanaseaPurpleItem: { } PolypPanaseaRadiantItem: { - DisplayName: Radiant Polyp Panasea + DisplayName: "{$NPCs.RadiantPolypPanasea}" Tooltip: "" } @@ -128,18 +128,68 @@ PiggyItem: { Tooltip: "" } +PrismaticGuppyBlueItem: { + DisplayName: Blue Prismatic Guppy + Tooltip: "" +} + +PrismaticGuppyGoldItem: { + DisplayName: "{$NPCs.GoldPrismaticGuppy}" + Tooltip: "" +} + +PrismaticGuppyGreenItem: { + DisplayName: Green Prismatic Guppy + Tooltip: "" +} + +PrismaticGuppyPinkItem: { + DisplayName: Pink Prismatic Guppy + Tooltip: "" +} + +PrismaticGuppyRadiantItem: { + DisplayName: "{$NPCs.RadiantPrismaticGuppy}" + Tooltip: "" +} + +ProbesnoutGoldItem: { + DisplayName: "{$NPCs.ProbesnoutGold.DisplayName}" + Tooltip: "" +} + +ProbesnoutItem: { + DisplayName: "{$NPCs.Probesnout.DisplayName}" + Tooltip: "" +} + RepairUnitItem: { DisplayName: "{$NPCs.RepairUnitCritter.DisplayName}" Tooltip: "" } +SeaFloatyItem: { + DisplayName: "{$NPCs.SeaFloaty.DisplayName}" + Tooltip: "" +} + SeaMinnowItem: { DisplayName: "{$NPCs.SeaMinnow.DisplayName}" Tooltip: "" } SeaMinnowGoldItem: { - DisplayName: Gold Sea Minnow + DisplayName: "{$NPCs.SeaMinnowGold.DisplayName}" + Tooltip: "" +} + +SearslugItem: { + DisplayName: "{$NPCs.Searslug.DisplayName}" + Tooltip: "" +} + +ShoreskipperItem: { + DisplayName: "{$NPCs.Shoreskipper.DisplayName}" Tooltip: "" } @@ -148,6 +198,26 @@ ShroombleItem: { Tooltip: "" } +SlugbunBurrowsItem: { + DisplayName: Burrows Slugbun + Tooltip: "" +} + +SlugbunItem: { + DisplayName: Reef Slugbun + Tooltip: "" +} + +SlugbunPolypItem: { + DisplayName: Polyp Slugbun + Tooltip: "" +} + +SlugbunRadiantItem: { + DisplayName: "{$NPCs.RadiantSlugbun}" + Tooltip: "" +} + TwinklerItem: { DisplayName: "{$NPCs.Twinkler.DisplayName}" Tooltip: "" @@ -202,16 +272,6 @@ MiracleFruit: { MushroomPlasmaRoot.DisplayName: Mushroom Plasma Root -NimbleBounder: { - DisplayName: Nimble Bounder - Tooltip: - ''' - Permanently increases movement and jump speed by {0}% - Permanently increases acceleration by {1}% - [c/842593:'Might be useful for speedrunning'] - ''' -} - PhantomHeart: { DisplayName: Phantom Heart Tooltip: @@ -256,193 +316,16 @@ TaintedCloudberry: { } // Spawn Blockers -SpawnBlockersOn: Currently enabled -SpawnBlockersOff: Currently disabled - -AntiCystOintment: { - DisplayName: Anti-Cyst Ointment - Tooltip: - ''' - Toggle this item to prevent hive cysts from spawning near you - Press to toggle - [STATE] - ''' -} - -AntiTumorOintment: { - DisplayName: Anti-Tumor Ointment - Tooltip: - ''' - Toggle this item to prevent hive tumors from spawning near you - Press to toggle - [STATE] - ''' -} - -BleachBall: { - DisplayName: Bleach Ball - Tooltip: - ''' - Toggle this item to prevent Aquatic Scourge from spawning - Press to toggle - [STATE] - ''' -} - -BrokenWaterFilter: { - DisplayName: Broken Water Filter - Tooltip: - ''' - Toggle this item to prevent Acid Rain from occurring - Press to toggle - [STATE] - ''' -} - -SirenproofEarMuffs: { - DisplayName: Sirenproof Earmuffs - Tooltip: - ''' - Toggle this item to prevent Anahita from spawning - Press to toggle - [STATE] - ''' -} - -VoodooDemonVoodooDoll: { - DisplayName: Voodoo Demon Voodoo Doll - Tooltip: - ''' - Toggle this item to prevent voodoo demons from spawning near you - Press to toggle - [STATE] - ''' -} - +SpawnBlockersOn: Spawns are currently disabled +SpawnBlockersOff: Spawns are currently enabled // Uncategorized ExhumeShortTooltip: ''' [c/C61B40:'Ah, are you curious what I saw within this item?'] - [c/BABABA:Press "Left Shift" to listen] + [c/BABABA:Hold Shift to listen] ''' LegendaryShortTooltip: ''' [c/FF6F00:Tales of legends past radiate around you...] - [c/BABABA:Press "Left Shift" to listen closer] + [c/BABABA:Hold Shift to listen closer] ''' - -AlicornonaStick: { - DisplayName: Alicorn on a Stick - Tooltip: "'Congratulations, you're winner! Here's my head on a stick.'" -} - -BallAndChain: { - DisplayName: Ball and Chain - Tooltip: - ''' - Favorite this item to disable any dashes granted by equipment - 'So heavy...' - ''' -} - -BrimstoneLocus: { - DisplayName: Brimstone Locus - Tooltip: - ''' - [c/C61B40:'Not only can I enhance your equipment with potent magic,] - [c/C61B40:I can also transcend some of your weaponry to entirely new forms.] - [c/C61B40:Such items are revealed while this item is in your inventory.'] - ''' -} - -MomentumCapacitor: { - DisplayName: Momentum Capacitor - GFBName: Burden Breaker - Tooltip: "[GFB]" - TooltipNormal: - ''' - While using the Momentum Capacitor, - your top speed will continuously and uncontrollably increase - This effect only works if there are no bosses alive - ''' - TooltipGFB: - ''' - The good time - Go fast - WARNING: May have disastrous results - Only works if there are no bosses alive - ''' -} - -NormalityRelocator: { - DisplayName: Normality Relocator - Tooltip: - ''' - Press [KEY] to teleport to the position of the mouse - Fall speed is doubled for 0.5 seconds after teleporting - Teleportation is disabled while Chaos State is active - Works while in the inventory - 'I'll be there in the blink of an eye' - ''' -} - -RelicOfConvergence: { - DisplayName: Relic of Convergence - Tooltip: - ''' - Creates a profaned crystal at the cursor that channels a healing aura before shattering - All players within the area of effect are healed for {0} HP - Allies gain 50% extra healing - Holding out the crystal heavily reduces the damage of all summons - [c/FF8C00:Never once had I known kindness. Neither my peers or family had a shred of compassion for me.] - [c/FF8C00:I wished for someone I could confide. A presence that cleansed me of anxiety.] - [c/FF8C00:And when I saw Her radiant smile when we met, I knew I had finally found it.] - ''' -} - -RelicOfResilience: { - DisplayName: Relic of Resilience - Tooltip: - ''' - Holding this item creates orbiting rock shards around you and nearby allies - While they orbit you, your minimum defense is set to 150 and minimum damage reduction to 10% - Taking a hit or pressing will pull in the shards, then blast them outward, crippling hit enemies - This effect has a 10 second cooldown after taking a hit - Holding out the shield heavily reduces the damage of all summons while rocks are active, only for you - [c/FF8C00:I saw a massacre and did nothing to stop it. My vow broken, I was shunned.] - [c/FF8C00:My will to forge ahead vanished. My final wish was simply to not die alone.] - [c/FF8C00:But when She put faith in my shield, I would never again let it falter.] - ''' -} - -Rock: { - DisplayName: Rock - Tooltip: - ''' - When the battle was finally over, the dust having just began to settle - Where even the stone refused the course of time, there sat a monk - Who dared to question history and stare into fate - 'What is the true price of the past being ever eternal? - Why must our future forever haunt us?' - ''' -} - -SulphurousSeaWorldSideChanger: { - DisplayName: Sulphurous Sea World Side Changer - Tooltip: - ''' - Spawn and use this if your regular ocean counts as a Sulphurous Sea - This will also fix the Abyss if it is broken - ''' -} - -SuperDummy: { - DisplayName: Super Dummy - Tooltip: - ''' - Creates a super dummy - Regenerates 1 million life per second - Will not die when taking damage over time from debuffs - Right click to kill all super dummies - ''' -} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Mounts.hjson b/Localization/en-US/Mods.CalamityMod.Items.Mounts.hjson index 609f6d8a11..f94a4f85a8 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Mounts.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Mounts.hjson @@ -32,7 +32,7 @@ GazeOfCrysthamyr: { Tooltip: ''' Summons a rideable shadow dragon mount - Hold Up to ascend faster + Hold {$Key.UP} to ascend faster ''' } @@ -46,19 +46,9 @@ OnyxExcavatorKey: { Tooltip: ''' Summons a rideable Onyx Drill mount - to mine blocks in front of you so you can destroy all the neat world generation - with complete disregard for all the creatures that inhabit these lands - I am sure the EPA and PETA would like to have a word with you afterwards - The power of the destruction scales with the highest powered pickaxe in your inventory - ''' -} - -PrincessSpiritinaBottle: { - DisplayName: Princess Spirit in a Bottle - Tooltip: - ''' - Summons the spirit of Cirrus, the Drunk Princess, in her alicorn form - Mounting will transform Cirrus, dismounting transforms her back + Hold to drill blocks while moving either horizontally or downwards + The drill's pickaxe power and mining speed copy the best pickaxe in your inventory + 'Irresponsibly demolishing all the neat world generation and causing unchecked ecological devastation? Splendid' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson index 06dae2e293..d8d310e8b3 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Pets.hjson @@ -26,6 +26,15 @@ BrimstoneJewel: { ''' } +BurrowerController: { + DisplayName: Burrower Beacon + Tooltip: + ''' + Requests a friendly burrower to follow you around and illuminate ores + Counts as a light pet + ''' +} + CharredRelic: { DisplayName: Charred Relic Tooltip: Contains a small amount of brimstone @@ -36,7 +45,6 @@ ChromaticOrb: { Tooltip: ''' Summons an ancient dragon light pet that highlights nearby enemies and danger sources - {$Common.AbyssLightLevel1} 'It glows warmly in your hand' ''' } @@ -56,7 +64,6 @@ EnchantedButterfly: { Tooltip: ''' Summons a mysterious dragonfly light pet - {$Common.AbyssLightLevel1} 'Feed him butterflies to keep him strong!' ''' } @@ -75,6 +82,15 @@ FoxDrive: { ''' } +FrostyBatBottle: { + DisplayName: Frosty Bat Bottle + Tooltip: + ''' + Summons an icy bat to light your way that flies towards your cursor when you dash + [c/6ECAC3:'All the world's bats are prime to squeak!'] + ''' +} + GeyserShell: { DisplayName: Geyser Shell Tooltip: Summons a little flak hermit @@ -106,7 +122,7 @@ LittleLight: { Tooltip: ''' Summons a small construct that follows you and provides a great amount of light - {$Common.AbyssLightLevel3} + {$Common.AbyssLightLevel} 'It's been looking for you for a long time' ''' } @@ -136,7 +152,6 @@ RadiatingCrystal: { Tooltip: ''' Summons a radiator light pet - {$Common.AbyssLightLevel1} 'The crystal contains traces of holothurin' ''' } @@ -157,6 +172,7 @@ StrangeOrb: { ''' Summons a miniature Ocean Spirit light pet Provides a large amount of light while underwater + {$Common.AbyssLightLevel} ''' } @@ -184,11 +200,19 @@ ThiefsDime: { Tooltip: ''' Summons Goldie the rogue coin to collect nearby coins and light your way - {$Common.AbyssLightLevel1} 'Once worthless treasure, now a relic of a thief's companionship' ''' } +ToastyBatBottle: { + DisplayName: Toasty Bat Bottle + Tooltip: + ''' + Summons a fiery bat to light your way that leaves a trail of glowing embers + [c/CF6454:'Guaranteed to NOT knock you off your hellbridge'] + ''' +} + TrashmanTrashcan: { DisplayName: Trash Can Tooltip: Summons the trash man diff --git a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson index 74cc606294..495946b816 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson @@ -8,7 +8,7 @@ AndroombaBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" AnthozoanCrabBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" AquaticUrchinBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" AriesBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" -ArmoredDiggerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +BurrowerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" AstraglomerateBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" AstralachneaBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" AstralProbeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" @@ -26,6 +26,7 @@ BohldohrBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" BoxJellyfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" CalamityEyeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" CannonballJellyfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +CarrionSwallowerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ChaoticPufferBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" CladCrabBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ClamBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" @@ -54,15 +55,22 @@ FusionFeederBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" GammaSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" GhostBellBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" GiantSquidBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +GildedAxolotlBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" GnasherBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" GulperEelBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" HadarianBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +HauntedChumBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" HeatSpiritBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" IceClasperBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ImpiousImmolatorBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" InfernalCongealmentBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" IrradiatedSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +JellyghoulBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +KelpieSeadragonBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" LaserfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +LazarusLampfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +LeerslugBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +LostShoalBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" LuminousCorvinaBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" MantisBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" MantisShrimpBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" @@ -74,6 +82,7 @@ NuclearToadBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" OarfishBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" OrthoceraBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" OverloadedSoldierBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +PearlpodBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" PerennialSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" PestilentSlimeBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" PhantomSpiritBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" @@ -81,7 +90,11 @@ PiggyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" PlaguebringerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" PlagueChargerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" PlagueshellBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +PodobooKoiBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +PolyperilBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" PrismBackBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +PrismaticGuppyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +ProbesnoutBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ProfanedEnergyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" RadiatorBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ReaperSharkBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" @@ -90,21 +103,28 @@ RepairUnitBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" RimehoundBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" RotdogBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" RubyCrawlerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +SandProwlerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SapphireCrawlerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +ScavengerBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ScornEaterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ScryllarBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SeaFloatyBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SeaMinnowBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" -SeaSerpentBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +SearslugBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +SharkoonBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ShockstormShuttleBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +ShoreskipperBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" ShroombleBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SightseerColliderBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SightseerSpitterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SkyfinBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SlabCrabBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +SlugbunBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SoulSlurperBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +SteampodBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" StellarCulexBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" StormlionBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" +StormlionSentryBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SulflounderBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SulphurousSkaterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" SunskaterBanner.DisplayName: "{$Items.Placeables.FormattedBannerName}" @@ -381,6 +401,18 @@ ReinforcedCrateItem: { Tooltip: "" } +Rock: { + DisplayName: Rock + Tooltip: + ''' + When the battle was finally over, the dust having just began to settle + Where even the stone refused the course of time, there sat a monk + Who dared to question history and stare into fate + 'What is the true price of the past being ever eternal? + Why must our future forever haunt us?' + ''' +} + RustedPipes: { DisplayName: Rusted Pipes Tooltip: "" @@ -491,37 +523,6 @@ BabyGhostBellJar: { Tooltip: "" } -CalamityCanvas2023: { - DisplayName: Calamity Canvas 2023 - Tooltip: - ''' - when placed to open a UI which allows customizing the focus of the painting - to make the focus follow the cursor, again to set it - Arrow keys can also be used to manually adjust the focus point - The scroll wheel zooms the focus in and out - Hold SHIFT to hide the UI without closing it - 'Embrace chaos' - ''' -} - -CalamityCanvas2024: { - DisplayName: Calamity Canvas 2024 - Tooltip: - ''' - when placed to open a UI which allows customizing the focus of the painting - to make the focus follow the cursor, again to set it - Arrow keys can also be used to manually adjust the focus point - The scroll wheel zooms the focus in and out - Hold SHIFT to hide the UI without closing it - 'Embrace havoc' - ''' -} - -CirrusCouch: { - DisplayName: Cirrus Couch - Tooltip: This shouldn't exist... -} - AquaticScourgeRelic: { DisplayName: Aquatic Scourge Relic Tooltip: A glimpse into what could have been... @@ -677,6 +678,11 @@ YharonRelic: { Tooltip: A glimpse into what will be... } +CausticTorch: { + DisplayName: Caustic Torch + Tooltip: Can be placed in water +} + ChaosCandle: { DisplayName: Chaos Candle Tooltip: The mere presence of this candle enrages surrounding enemies drastically @@ -697,27 +703,18 @@ AltarOfTheAccursedItem: { Tooltip: ''' Offer [i:CalamityMod/AshesofCalamity] {$Items.Materials.AshesofCalamity.DisplayName} at this altar to summon the Witch - Doing so will create a square arena of blocks, with the altar at its center + Doing so will create a square arena, with the altar at its center The Witch enrages while you are outside of the arena + Hovering over the altar while using ruler measurements will display a temporary arena box {$CommonItemTooltip.SpecialCrafting} ''' } -AncientAltar: { - DisplayName: Ancient Altar - Tooltip: "{$CommonItemTooltip.SpecialCrafting}" -} - AshenAltar: { DisplayName: Ashen Altar Tooltip: "{$CommonItemTooltip.SpecialCrafting}" } -BotanicPlanter: { - DisplayName: Botanic Planter - Tooltip: "{$CommonItemTooltip.SpecialCrafting}" -} - CosmicAnvilItem: { DisplayName: Cosmic Anvil Tooltip: @@ -736,21 +733,6 @@ DraedonsForge: { ''' } -EffulgentManipulator: { - DisplayName: Effulgent Manipulator - Tooltip: "{$CommonItemTooltip.SpecialCrafting}" -} - -EutrophicShelf: { - DisplayName: Eutrophic Shelf - Tooltip: "{$CommonItemTooltip.SpecialCrafting}" -} - -MonolithAmalgam: { - DisplayName: Monolith Amalgam - Tooltip: "{$CommonItemTooltip.SpecialCrafting}" -} - PlagueInfuser: { DisplayName: Plague Infuser Tooltip: "{$CommonItemTooltip.SpecialCrafting}" @@ -761,21 +743,11 @@ ProfanedCrucible: { Tooltip: "{$CommonItemTooltip.SpecialCrafting}" } -StaticRefiner: { - DisplayName: Static Refiner - Tooltip: "{$CommonItemTooltip.SpecialCrafting}" -} - VoidCondenser: { DisplayName: Void Condenser Tooltip: "{$CommonItemTooltip.SpecialCrafting}" } -WulfrumLabstationItem: { - DisplayName: Wulfrum Labstation - Tooltip: "{$CommonItemTooltip.SpecialCrafting}" -} - CrimsonEffigy: { DisplayName: Crimson Effigy Tooltip: @@ -786,16 +758,6 @@ CrimsonEffigy: { ''' } -ThankYouPainting: { - DisplayName: Thank You - Tooltip: - ''' - Thanks to the entire team, everyone who supported, and those who all play the mod and keep it alive! - The confines of this painting is not enough to fit the entire team - Hold SHIFT to see a list of past and current developers - ''' -} - EffigyOfDecay: { DisplayName: Effigy of Decay Tooltip: @@ -886,6 +848,16 @@ FrigidMonolith: { Tooltip: "'Enchant the sky with frosty auroras.'" } +KelpTorch: { + DisplayName: Kelp Torch + Tooltip: Can be placed in water +} + +OldDukeMonolith: { + DisplayName: Elden Diorama + Tooltip: "" +} + OtonilouStatue: { DisplayName: Otonilou Memorial Tooltip: "" @@ -906,6 +878,56 @@ NavyPrismTorch: { Tooltip: Can be placed in water } +AmidiasPainting: { + DisplayName: Sea King's Release + Tooltip: + ''' + 'O. Rios' + 'September-October!' + ''' +} + +CalamityCanvas2023: { + DisplayName: Calamity Canvas 2023 + Tooltip: + ''' + when placed to open a UI which allows customizing the focus of the painting + to make the focus follow the cursor, again to set it + Arrow keys can also be used to manually adjust the focus point + The scroll wheel zooms the focus in and out + Hold Shift to hide the UI without closing it + 'Embrace chaos' + ''' +} + +CalamityCanvas2024: { + DisplayName: Calamity Canvas 2024 + Tooltip: + ''' + when placed to open a UI which allows customizing the focus of the painting + to make the focus follow the cursor, again to set it + Arrow keys can also be used to manually adjust the focus point + The scroll wheel zooms the focus in and out + Hold Shift to hide the UI without closing it + 'Embrace havoc' + ''' +} + +ForgivenessPainting: { + DisplayName: Forgiveness + Tooltip: "'D. User'" +} + +ThankYouPainting: { + DisplayName: Thank You + Tooltip: + ''' + Thanks to the entire team, everyone who supported, and those who all play the mod and keep it alive! + The confines of this painting is not enough to fit the entire team + Hold Shift to see a list of past and current developers + ''' +} + PiggyCage: { DisplayName: Piggy Cage Tooltip: "" @@ -927,7 +949,7 @@ ResilientCandle: { ''' when placed to make defense block {0}% more damage ({1}% in Classic, {2}% in Expert, and {3}% in Master) - This cannot be stacked with other Cirrus Candle buffs + This cannot be stacked with other Candle buffs 'Neither rain nor wind can snuff its undying flame' ''' } @@ -948,7 +970,7 @@ SpitefulCandle: { ''' when placed to deal {0}x damage to all enemies The extra {1}x damage bypasses enemy defense and damage reduction - This cannot be stacked with other Cirrus Candle buffs + This cannot be stacked with other Candle buffs 'Its hateful glow flickers with ire' ''' } @@ -968,11 +990,29 @@ ThaumaticChair: { Tooltip: One of Chloe's finest creations } +ThermalTorch: { + DisplayName: Thermal Torch + Tooltip: + ''' + Can be placed in water + Can dispell the magical darkness of the Abyss when placed + ''' +} + TranquilityCandle: { DisplayName: Tranquility Candle Tooltip: The mere presence of this candle calms surrounding enemies drastically } +VoidTorch: { + DisplayName: Void Torch + Tooltip: + ''' + Can be placed in water + Can dispell the magical darkness of the Abyss when placed + ''' +} + AnahitaTrophy: { DisplayName: Anahita Trophy Tooltip: "" @@ -1178,8 +1218,8 @@ VigorousCandle: { Tooltip: ''' when placed to regenerate {0}% of your maximum health per second - This regeneration is at full power even while moving and bypasses Revengeance Mode caps - This cannot be stacked with other Cirrus Candle buffs + This regeneration is at full power even while moving + This cannot be stacked with other Candle buffs 'Its brilliant light suffuses those nearby with hope' ''' } @@ -1189,7 +1229,7 @@ WeightlessCandle: { Tooltip: ''' when placed to gain {0}% increased movement speed, wing time and acceleration - This cannot be stacked with other Cirrus Candle buffs + This cannot be stacked with other Candle buffs 'The floating flame seems to uplift your very spirit' ''' } @@ -1293,11 +1333,6 @@ AbyssTable: { Tooltip: "" } -AbyssTorch: { - DisplayName: Abyss Torch - Tooltip: Can be placed in water -} - AbyssWorkBench: { DisplayName: Abyss Work Bench Tooltip: "" @@ -1408,6 +1443,11 @@ AcidwoodWorkBench: { Tooltip: "" } +AncientAltar: { + DisplayName: Ancient Altar + Tooltip: "" +} + AncientBasin: { DisplayName: Ancient Basin Tooltip: "" @@ -1747,6 +1787,11 @@ BotanicPiano: { Tooltip: "" } +BotanicPlanter: { + DisplayName: Botanic Planter + Tooltip: "" +} + BotanicPlatform: { DisplayName: Botanic Platform Tooltip: "" @@ -1877,103 +1922,308 @@ CosmiliteWorkBench: { Tooltip: "" } +DriftwoodBaroqueCello: { + DisplayName: Driftwood Baroque Cello + Tooltip: "" +} + +DriftwoodBathtub: { + DisplayName: Driftwood Bathtub + Tooltip: "" +} + +DriftwoodBed: { + DisplayName: Driftwood Bed + Tooltip: "" +} + +DriftwoodBookcase: { + DisplayName: Driftwood Bookcase + Tooltip: "" +} + +DriftwoodCandelabra: { + DisplayName: Driftwood Candelabra + Tooltip: "" +} + +DriftwoodCandle: { + DisplayName: Driftwood Candle + Tooltip: "" +} + +DriftwoodChair: { + DisplayName: Driftwood Chair + Tooltip: "" +} + +DriftwoodChandelier: { + DisplayName: Driftwood Chandelier + Tooltip: "" +} + +DriftwoodChest: { + DisplayName: Driftwood Chest + Tooltip: "" +} + +DriftwoodDoor: { + DisplayName: Driftwood Door + Tooltip: "" +} + +DriftwoodDresser: { + DisplayName: Driftwood Dresser + Tooltip: "" +} + +DriftwoodLamp: { + DisplayName: Driftwood Lamp + Tooltip: "" +} + +DriftwoodLantern: { + DisplayName: Driftwood Lantern + Tooltip: "" +} + +DriftwoodPlatform: { + DisplayName: Driftwood Platform + Tooltip: "" +} + +DriftwoodSink: { + DisplayName: Driftwood Sink + Tooltip: Counts as a water source +} + +DriftwoodSofa: { + DisplayName: Driftwood Sofa + Tooltip: "" +} + +DriftwoodSundial: { + DisplayName: Driftwood Sundial + Tooltip: "" +} + +DriftwoodTable: { + DisplayName: Driftwood Table + Tooltip: "" +} + +DriftwoodToilet: { + DisplayName: Driftwood Toilet + Tooltip: "" +} + +DriftwoodWorkBench: { + DisplayName: Driftwood Work Bench + Tooltip: "" +} + +AncientNavystoneBathtub: { + DisplayName: Ancient Navystone Bathtub + Tooltip: "" +} + +AncientNavystoneBed: { + DisplayName: Ancient Navystone Bed + Tooltip: "" +} + +AncientNavystoneBench: { + DisplayName: Ancient Navystone Bench + Tooltip: "" +} + +AncientNavystoneBookcase: { + DisplayName: Ancient Navystone Bookcase + Tooltip: "" +} + +AncientNavystoneCandelabra: { + DisplayName: Ancient Navystone Candelabra + Tooltip: "" +} + +AncientNavystoneCandle: { + DisplayName: Ancient Navystone Candle + Tooltip: "" +} + +AncientNavystoneChair: { + DisplayName: Ancient Navystone Chair + Tooltip: "" +} + +AncientNavystoneChandelier: { + DisplayName: Ancient Navystone Chandelier + Tooltip: "" +} + +AncientNavystoneChest: { + DisplayName: Ancient Navystone Chest + Tooltip: "" +} + +AncientNavystoneClock: { + DisplayName: Ancient Navystone Clock + Tooltip: "" +} + +AncientNavystoneDoor: { + DisplayName: Ancient Navystone Door + Tooltip: "" +} + +AncientNavystoneDresser: { + DisplayName: Ancient Navystone Dresser + Tooltip: "" +} + +AncientNavystoneLamp: { + DisplayName: Ancient Navystone Lamp + Tooltip: "" +} + +AncientNavystoneLantern: { + DisplayName: Ancient Navystone Lantern + Tooltip: "" +} + +AncientNavystonePiano: { + DisplayName: Ancient Navystone Piano + Tooltip: "" +} + +AncientNavystonePlatform: { + DisplayName: Ancient Navystone Platform + Tooltip: "" +} + +AncientNavystoneSink: { + DisplayName: Ancient Navystone Sink + Tooltip: Counts as a water source +} + +AncientNavystoneTable: { + DisplayName: Ancient Navystone Table + Tooltip: "" +} + +AncientNavystoneWorkBench: { + DisplayName: Ancient Navystone Work Bench + Tooltip: "" +} + AncientSmoothNavystone: { DisplayName: Ancient Smooth Navystone Tooltip: "" } -EutrophicBathtub: { - DisplayName: Eutrophic Bathtub +EutrophicShelf: { + DisplayName: Eutrophic Shelf Tooltip: "" } -EutrophicBed: { - DisplayName: Eutrophic Bed +NavystoneBathtub: { + DisplayName: Navystone Bathtub Tooltip: "" } -EutrophicBench: { - DisplayName: Eutrophic Bench +NavystoneBed: { + DisplayName: Navystone Bed Tooltip: "" } -EutrophicBookcase: { - DisplayName: Eutrophic Bookcase +NavystoneBookcase: { + DisplayName: Navystone Bookcase Tooltip: "" } -EutrophicCandelabra: { - DisplayName: Eutrophic Candelabra +NavystoneCandelabra: { + DisplayName: Navystone Candelabra Tooltip: "" } -EutrophicCandle: { - DisplayName: Eutrophic Candle +NavystoneCandle: { + DisplayName: Navystone Candle Tooltip: "" } -EutrophicChair: { - DisplayName: Eutrophic Chair +NavystoneChair: { + DisplayName: Navystone Chair Tooltip: "" } -EutrophicChandelier: { - DisplayName: Eutrophic Chandelier +NavystoneChandelier: { + DisplayName: Navystone Chandelier Tooltip: "" } -EutrophicChest: { - DisplayName: Eutrophic Chest +NavystoneChest: { + DisplayName: Navystone Chest Tooltip: "" } -EutrophicClock: { - DisplayName: Eutrophic Clock +NavystoneClock: { + DisplayName: Navystone Clock Tooltip: "" } -EutrophicDoor: { - DisplayName: Eutrophic Door +NavystoneDoor: { + DisplayName: Navystone Door Tooltip: "" } -EutrophicDresser: { - DisplayName: Eutrophic Dresser +NavystoneDresser: { + DisplayName: Navystone Dresser Tooltip: "" } -EutrophicLamp: { - DisplayName: Eutrophic Lamp +NavystoneLamp: { + DisplayName: Navystone Lamp Tooltip: "" } -EutrophicLantern: { - DisplayName: Eutrophic Lantern +NavystoneLantern: { + DisplayName: Navystone Lantern Tooltip: "" } -EutrophicPiano: { - DisplayName: Eutrophic Piano +NavystoneLyre: { + DisplayName: Navystone Lyre Tooltip: "" } -EutrophicPlatform: { - DisplayName: Eutrophic Platform +NavystonePlatform: { + DisplayName: Navystone Platform Tooltip: "" } -EutrophicSink: { - DisplayName: Eutrophic Sink +NavystoneSink: { + DisplayName: Navystone Sink Tooltip: Counts as a water source } -EutrophicTable: { - DisplayName: Eutrophic Table +NavystoneTable: { + DisplayName: Navystone Table Tooltip: "" } -EutrophicWorkBench: { - DisplayName: Eutrophic Work Bench +NavystoneToilet: { + DisplayName: Navystone Toilet + Tooltip: "" +} + +NavystoneTriclinium: { + DisplayName: Navystone Triclinium + Tooltip: "" +} + +NavystoneWorkBench: { + DisplayName: Navystone Work Bench Tooltip: "" } @@ -2237,6 +2487,11 @@ PolishedMarniteWall: { Tooltip: "" } +MonolithAmalgam: { + DisplayName: Monolith Amalgam + Tooltip: "" +} + MonolithBathtub: { DisplayName: Monolith Bathtub Tooltip: "" @@ -2781,6 +3036,11 @@ SacrilegiousWorkBench: { Tooltip: "" } +SilvaBasin: { + DisplayName: Silva Basin + Tooltip: "" +} + SilvaBathtub: { DisplayName: Silva Bathtub Tooltip: "" @@ -2881,6 +3141,11 @@ SilvaWorkBench: { Tooltip: "" } +StaticRefiner: { + DisplayName: Static Refiner + Tooltip: "" +} + StatigelBathtub: { DisplayName: Statigel Bathtub Tooltip: "" @@ -3191,6 +3456,16 @@ VoidWorkBench: { Tooltip: "" } +ChargedWulfrumEnergyBarrier: { + DisplayName: Charged Wulfrum Energy Barrier + Tooltip: "" +} + +ChargedWulfrumWallMountedBulb: { + DisplayName: Charged Wulfrum Wall Mounted Bulb + Tooltip: "" +} + WulfrumBathtub: { DisplayName: Wulfrum Bathtub Tooltip: "" @@ -3236,6 +3511,16 @@ WulfrumDresser: { Tooltip: "" } +WulfrumEnergyBarrier: { + DisplayName: Wulfrum Energy Barrier + Tooltip: "" +} + +WulfrumLabstationItem: { + DisplayName: Wulfrum Labstation + Tooltip: "" +} + WulfrumLamp: { DisplayName: Wulfrum Lamp Tooltip: "" @@ -3246,19 +3531,39 @@ WulfrumLantern: { Tooltip: "" } +WulfrumPanels: { + DisplayName: Wulfrum Panels + Tooltip: "" +} + WulfrumPiano: { DisplayName: Wulfrum Piano Tooltip: "" } +WulfrumPlatform: { + DisplayName: Wulfrum Platform + Tooltip: "" +} + WulfrumPlating: { DisplayName: Wulfrum Plating Tooltip: "" } +WulfrumSheets: { + DisplayName: Wulfrum Sheets + Tooltip: "" +} + +WulfrumSiding: { + DisplayName: Wulfrum Siding + Tooltip: "" +} + WulfrumSink: { DisplayName: Wulfrum Sink - Tooltip: "" + Tooltip: Counts as a water source } WulfrumSofa: { @@ -3276,11 +3581,121 @@ WulfrumToilet: { Tooltip: "" } +WulfrumWallMountedBulb: { + DisplayName: Wulfrum Wall Mounted Bulb + Tooltip: "" +} + WulfrumWorkBench: { DisplayName: Wulfrum Work Bench Tooltip: "" } +AnodizedWulfrumBathtub: { + DisplayName: Anodized Wulfrum Bathtub + Tooltip: "" +} + +AnodizedWulfrumBookcase: { + DisplayName: Anodized Wulfrum Bookcase + Tooltip: "" +} + +AnodizedWulfrumChair: { + DisplayName: Anodized Wulfrum Chair + Tooltip: "" +} + +AnodizedWulfrumChandelier: { + DisplayName: Anodized Wulfrum Chandelier + Tooltip: "" +} + +AnodizedWulfrumChest: { + DisplayName: Anodized Wulfrum Chest + Tooltip: "" +} + +AnodizedWulfrumDeskLight: { + DisplayName: Anodized Wulfrum Desk Light + Tooltip: "" +} + +AnodizedWulfrumDoor: { + DisplayName: Anodized Wulfrum Door + Tooltip: "" +} + +AnodizedWulfrumDresser: { + DisplayName: Anodized Wulfrum Dresser + Tooltip: "" +} + +AnodizedWulfrumJukebox: { + DisplayName: Anodized Wulfrum Jukebox + Tooltip: "" +} + +AnodizedWulfrumLamp: { + DisplayName: Anodized Wulfrum Lamp + Tooltip: "" +} + +AnodizedWulfrumLantern: { + DisplayName: Anodized Wulfrum Lantern + Tooltip: "" +} + +AnodizedWulfrumPanels: { + DisplayName: Anodized Wulfrum Panels + Tooltip: "" +} + +AnodizedWulfrumPlatform: { + DisplayName: Anodized Wulfrum Platform + Tooltip: "" +} + +AnodizedWulfrumSink: { + DisplayName: Anodized Wulfrum Sink + Tooltip: Counts as a water source +} + +AnodizedWulfrumSleepingPod: { + DisplayName: Anodized Wulfrum Sleeping Pod + Tooltip: "" +} + +AnodizedWulfrumSofa: { + DisplayName: Anodized Wulfrum Sofa + Tooltip: "" +} + +AnodizedWulfrumTable: { + DisplayName: Anodized Wulfrum Table + Tooltip: "" +} + +AnodizedWulfrumTrim: { + DisplayName: Anodized Wulfrum Trim + Tooltip: "" +} + +AnodizedWulfrumToilet: { + DisplayName: Anodized Wulfrum Toilet + Tooltip: "" +} + +AnodizedWulfrumWorkBench: { + DisplayName: Anodized Wulfrum Work Bench + Tooltip: "" +} + +RoundedAnodizedWulfrumPanels: { + DisplayName: Rounded Anodized Wulfrum Panels + Tooltip: "" +} + HardenedAstralSand: { DisplayName: Hardened Astral Sand Tooltip: "" @@ -3500,6 +3915,11 @@ Driftwood: { Tooltip: "" } +Dunesand: { + DisplayName: Dunesand + Tooltip: "" +} + Navystone: { DisplayName: Navystone Tooltip: "" @@ -3580,6 +4000,11 @@ PolypSand: { Tooltip: "" } +TableCoralLeft: { + DisplayName: Table Coral + Tooltip: "" +} + VolcanicSand: { DisplayName: Volcanic Sand Tooltip: "" @@ -3617,6 +4042,11 @@ AerialiteBrickWall: { Tooltip: "" } +AncientSmoothNavystoneWall: { + DisplayName: Ancient Smooth Navystone Wall + Tooltip: "" +} + AshenSlabWall: { DisplayName: Ashen Slab Wall Tooltip: "" @@ -3736,6 +4166,16 @@ RustedPlatingWall: { // End of Draedon +AnodizedWulfrumTrimWall: { + DisplayName: Anodized Wulfrum Trim Wall + Tooltip: "" +} + +ChargedWulfrumEnergyBarrierWall: { + DisplayName: Charged Wulfrum Energy Barrier Wall + Tooltip: "" +} + DriftwoodWall: { DisplayName: Driftwood Wall Tooltip: "" @@ -3746,13 +4186,8 @@ ElumplateWall: { Tooltip: "" } -EutrophicSandWall: { - DisplayName: Unsafe Eutrophic Sand Wall - Tooltip: "" -} - -EutrophicSandWallSafe: { - DisplayName: Eutrophic Sand Wall +EutrophicGlassWall: { + DisplayName: Eutrophic Glass Wall Tooltip: "" } @@ -3786,17 +4221,17 @@ HavocplateWall: { Tooltip: "" } +LimestoneWall: { + DisplayName: Limestone Wall + Tooltip: "" +} + NavyplateWall: { DisplayName: Navyplate Wall Tooltip: "" } NavystoneWall: { - DisplayName: Unsafe Navystone Wall - Tooltip: "" -} - -NavystoneWallSafe: { DisplayName: Navystone Wall Tooltip: "" } @@ -3851,6 +4286,16 @@ PyreMantleWall: { Tooltip: "" } +RoundedAnodizedWulfrumPanelWall: { + DisplayName: Rounded Anodized Wulfrum Panel Wall + Tooltip: "" +} + +RunestoneWall: { + DisplayName: Runestone Wall + Tooltip: "" +} + RunicProfanedBrickWall: { DisplayName: Runic Profaned Brick Wall Tooltip: "" @@ -3941,11 +4386,41 @@ VoidstoneWall: { Tooltip: "" } +WulfrumComplexPanelWall: { + DisplayName: Wulfrum Complex Panel Wall + Tooltip: "" +} + +WulfrumEnergyBarrierWall: { + DisplayName: Wulfrum Energy Barrier Wall + Tooltip: "" +} + +WulfrumPanelWall: { + DisplayName: Wulfrum Panel Wall + Tooltip: "" +} + +WulfrumPillar: { + DisplayName: Wulfrum Pillar + Tooltip: "" +} + WulfrumPlatingWall: { DisplayName: Wulfrum Plating Wall Tooltip: "" } +WulfrumSheetWall: { + DisplayName: Wulfrum Sheet Wall + Tooltip: "" +} + +WulfrumSidingWall: { + DisplayName: Wulfrum Siding Wall + Tooltip: "" +} + FireTurret: { DisplayName: Fire Turret Tooltip: @@ -4186,15 +4661,37 @@ MiniAgedFloodlightItem: { Tooltip: "" } -ProbesnoutBanner.DisplayName: Probesnout Banner -SharkoonBanner.DisplayName: Sharkoon Banner - -LimestoneWall: { - DisplayName: Limestone Wall +AridSoil: { + DisplayName: Arid Soil Tooltip: "" } -RunestoneWall: { - DisplayName: Runestone Wall +RunestoneTerracotta: { + DisplayName: Runestone Terracotta + Tooltip: "" +} + +ShellTrimBrick: { + DisplayName: Shell Trim Brick + Tooltip: "" +} + +ShellTrimBrickWall: { + DisplayName: Shell Trim Brick Wall + Tooltip: "" +} + +BasaltSlab: { + DisplayName: Basalt Slab + Tooltip: "" +} + +UnsafeNavystoneWall: { + DisplayName: Unsafe Navystone Wall + Tooltip: "" +} + +MossyStone: { + DisplayName: Mossy Stone Tooltip: "" } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson index eda5f6d73f..e429042221 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson @@ -22,7 +22,6 @@ Baguette: { Tooltip: ''' {$CommonItemTooltip.MinorStats} - {$Potions.RedWine.DisplayName} heals {0} HP, but reduces life regen by {1} HP/s [c/FCE391:'je suis Monte'] ''' } @@ -36,6 +35,15 @@ BlasphemousDonut: { ''' } +BottledPanacea: { + DisplayName: Bottled Panacea + Tooltip: + ''' + Cures you of all sickness and electricity debuffs when consumed + This has a 30 second cooldown + ''' +} + BoundingPotion: { DisplayName: Bounding Potion Tooltip: "{0}% increased jump speed and {1}% increased jump height" @@ -60,15 +68,6 @@ DeliciousMeat: { ''' } -Fabsoup: { - DisplayName: Pot of Pain - Tooltip: - ''' - {$CommonItemTooltip.MajorStats} - 'hrngh, soup' - ''' -} - FlaskOfBrimstone: { DisplayName: Flask of Brimstone Tooltip: Melee, Whip, and Rogue attacks inflict {$Buffs.BrimstoneFlames.DisplayName} @@ -94,11 +93,20 @@ HadalStew: { Tooltip: ''' Only gives [S] seconds of {$BuffName.PotionSickness} - {$CommonItemTooltip.MediumStats} + {$CommonItemTooltip.MajorStats} {$CommonItemTooltip.MinuteDuration} ''' } +LavaChickenBroth: { + DisplayName: Lava Chicken Broth + Tooltip: + ''' + {$CommonItemTooltip.MajorStats} + 'It's tasty as hell' + ''' +} + OmegaHealingPotion: { DisplayName: Omega Healing Potion Tooltip: "" @@ -158,15 +166,13 @@ ZergPotion: { Tooltip: Vastly increases enemy spawn rate } -// Drunk Princess Shop Items BloodyMary: { DisplayName: Bloody Mary Tooltip: ''' - {0}% increased damage and movement speed during a Blood Moon - Reduces life regen by {1} HP/s and defense by {2}% + Increases enemy spawn rates by 7x + Greatly reduces piercing weapon effectiveness {$Common.AlcoholWarning} - [c/B00BA5:'Extra spicy... and bloody!'] ''' } @@ -174,10 +180,9 @@ CaribbeanRum: { DisplayName: Caribbean Rum Tooltip: ''' - Increases life regen by {0} HP/s, movement speed by {1}% - Makes you floaty and reduces defense by {2}% + Increases move speed by {0}% + Reduces your gravity by {1}% {$Common.AlcoholWarning} - [c/B00BA5:'Why is the rum gone?'] ''' } @@ -185,21 +190,18 @@ CinnamonRoll: { DisplayName: Cinnamon Roll Tooltip: ''' - Multiplies all fire-based debuff damage by {0}x and increases mana regeneration - Reduces defense by {1}% + Greatly increases dash speed + Greatly reduces dash distance {$Common.AlcoholWarning} - [c/B00BA5:'A great-tasting cinnamon whiskey with a touch of cream soda.'] ''' } -CirrusVodka: { - DisplayName: Cirrus' Vodka +PurpleHaze: { + DisplayName: Purple Haze Tooltip: ''' - {0}% increased damage, but lowers defense by {1}% - Increases immune time after being struck + For 5 seconds after a stealth strike, all damage increased by {0}%, but stealth strike damage reduced by {1}% {$Common.AlcoholWarning} - This magical liquor is highly sought by those with a refined palate ''' } @@ -211,7 +213,6 @@ Everclear: { Reduces life regen by {1} HP/s and defense by {2}% Counts as 2 alcohols for {$Buffs.AlcoholPoisoning.DisplayName} {$Common.AlcoholWarning} - [c/B00BA5:'This is the most potent booze I have, be careful with it.'] ''' } @@ -219,10 +220,9 @@ EvergreenGin: { DisplayName: Evergreen Gin Tooltip: ''' - Multiplies all sickness and water-related debuff damage by {0}x - Reduces life regen by {1} HP/s + {0}% increased Water and Sickness debuff damage + {1}% decreased Electric and Heat debuff damage {$Common.AlcoholWarning} - [c/B00BA5:'It tastes like a Christmas tree, if you can imagine that.'] ''' } @@ -230,10 +230,9 @@ Fireball: { DisplayName: Fireball Tooltip: ''' - Multiplies all fire-based debuff damage by {0}x - Reduces life regen by {1} HP/s + {0}% increased Heat debuff damage + {1}% decreased Sickness debuff damage {$Common.AlcoholWarning} - [c/B00BA5:'A great-tasting cinnamon whiskey.'] ''' } @@ -241,9 +240,19 @@ GrapeBeer: { DisplayName: Grape Beer Tooltip: ''' - Reduces defense by {0}% for {1} seconds + Bullets, Arrows, Darts, and Rockets gain homing + {0}% reduced critical strike damage + {$Common.AlcoholWarning} + ''' +} + +Manhattan: { + DisplayName: Manhattan + Tooltip: + ''' + {0}% increased Cold debuff damage + {1}% decreased Water debuff damage {$Common.AlcoholWarning} - [c/B00BA5:'This crap is abhorrent, but you might like it.'] ''' } @@ -251,11 +260,9 @@ Margarita: { DisplayName: Margarita Tooltip: ''' - Halves the duration of most harmful debuffs - Reduces defense by {0}% and life regen by {1} HP/s + Halves duration of harmful debuffs you receive + Reduces damage of debuffs you inflict by {0}% {$Common.AlcoholWarning} - [c/B00BA5:'One of the best drinks ever created, enjoy it while it lasts.'] - {$CommonItemTooltip.MinuteDuration@2} ''' } @@ -263,10 +270,10 @@ Moonshine: { DisplayName: Moonshine Tooltip: ''' - Increases defense by {0} and damage reduction by {1}% - Reduces life regen by {2} HP/s + Increases maximum health by {0}% + Attacks always take at least half your defense worth of defense damage + Defense damage takes twice as long to recover {$Common.AlcoholWarning} - [c/B00BA5:'This stuff is pretty strong, but I'm sure you can handle it.'] ''' } @@ -274,10 +281,9 @@ MoscowMule: { DisplayName: Moscow Mule Tooltip: ''' - Increases damage by {0}%, knockback by {1}% and critical strike chance by {2}% - Reduces life regen by {3} HP/s + {0}% increased knockback, all attacks inflict heavy knockback + Reduces the effectiveness of piercing weapons {$Common.AlcoholWarning} - [c/B00BA5:'I once heard the copper mug can be toxic and I told 'em, 'listen, dummy, I'm already poisoning myself!''] ''' } @@ -286,7 +292,6 @@ OddMushroom: { Tooltip: ''' Causes you to see many fake, vibrant copies of all nearby entities - These effects become more potent as you consume more shrooms [c/FF232C:These visual effects may be nauseating or otherwise bad for some] 'Trippy' ''' @@ -299,7 +304,6 @@ OldFashioned: { Multiplies most non-weapon, non-debuff damage by {0}x Multiplies all weapon damage by {1}x {$Common.AlcoholWarning} - [c/B00BA5:'An old favorite of mine.'] ''' } @@ -307,9 +311,9 @@ RedWine: { DisplayName: Red Wine Tooltip: ''' - Reduces life regen by {0} HP/s for {1} seconds + {0}% increased vertical speed + {1}% reduced flight time {$Common.AlcoholWarning} - [c/B00BA5:'Too dry for my taste.'] ''' } @@ -317,10 +321,9 @@ Rum: { DisplayName: Rum Tooltip: ''' - Increases life regen by {0} HP/s and movement speed by {1}% - Reduces defense by {2}% + {0}% increased non-minion summon damage + {1}% decreased minion damage {$Common.AlcoholWarning} - [c/B00BA5:'Sweet and potent, just how I like it.'] ''' } @@ -328,10 +331,9 @@ Screwdriver: { DisplayName: Screwdriver Tooltip: ''' - Multiplies piercing projectile damage by {0}x - Reduces life regen by {1} HP/s + Greatly increases tile and wall placement range and speed + Greatly reduces damage dealt {$Common.AlcoholWarning} - [c/B00BA5:'Do you have a screw loose?'] ''' } @@ -339,11 +341,11 @@ StarBeamRye: { DisplayName: Star Beam Rye Tooltip: ''' - Increases max mana by {0}, magic damage by {1}%, - and reduces mana usage by {2}% - Reduces defense by {3}% and life regen by {4} HP/s + Disables natural mana regeneration + Mana regenerates at a fixed rate, even while using an item + Magic weapons deal increased damage based on how quickly they consume mana + This does not work while inflicted with Mana Sickness {$Common.AlcoholWarning} - [c/B00BA5:'Made from some stuff I found near the Astral Meteor crash site. Don't worry, it's safe, trust me...'] ''' } @@ -351,10 +353,9 @@ Tequila: { DisplayName: Tequila Tooltip: ''' - Increases knockback by {0}%, crit chance by {1}% and defense by {2} during daytime - Reduces life regen by {3} HP/s + {0}% increased Electric debuff damage + {1}% decreased Cold debuff damage {$Common.AlcoholWarning} - [c/B00BA5:'Great for mixing up daytime drinks.'] ''' } @@ -362,10 +363,9 @@ TequilaSunrise: { DisplayName: Tequila Sunrise Tooltip: ''' - Increases knockback by {0}%, crit chance by {1}% and defense by {2} during daytime - Reduces life regen by {3} HP/s + Greatly increases natural life regeneration after suffering a damaging debuff + {0}% increased damage taken from debuffs {$Common.AlcoholWarning} - [c/B00BA5:'The greatest daytime drink I've ever had.'] ''' } @@ -373,10 +373,9 @@ Vodka: { DisplayName: Vodka Tooltip: ''' - Increases damage by {0}% and critical strike chance by {1}% - Reduces life regen by {2} HP/s and defense by {3}% + {0}% increased Typeless debuff damage + {1}% decreased elemental debuff damage {$Common.AlcoholWarning} - [c/B00BA5:'The number one alcohol for creating great mixed drinks.'] ''' } @@ -384,10 +383,11 @@ Whiskey: { DisplayName: Whiskey Tooltip: ''' - Increases damage by {0}%, knockback by {1}% and critical strike chance by {2}% - Reduces defense by {3}% + Provides between {0}% and {1}% damage to the held weapon's class + Each class tracks this boost individually + This boost lowers the longer you hold weapons of the same class, taking {2} seconds to fully decay + This boost recharges when holding weapons of a different class, taking {3} seconds to fully recharge {$Common.AlcoholWarning} - [c/B00BA5:'The burning sensation makes it tastier.'] ''' } @@ -395,10 +395,9 @@ WhiteWine: { DisplayName: White Wine Tooltip: ''' - Increases magic damage by {0}% - Reduces defense by {1}% and life regen by {2} HP/s + You regain flight time the closer you are to an enemy + {0}% reduced flight time {$Common.AlcoholWarning} - [c/B00BA5:'I drank a full barrel of this stuff once in one night, I couldn't remember who I was the next day.'] ''' } @@ -440,3 +439,12 @@ Salak: { DisplayName: Salak Tooltip: "{$CommonItemTooltip.MinorStats}" } + +ShroomBowl: { + DisplayName: Shroom Bowl + Tooltip: + ''' + {$CommonItemTooltip.MediumStats} + 'He has been grounded' + ''' +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson index ad00243c80..7b5ef7a2e5 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson @@ -14,7 +14,6 @@ AstralChunk: { Tooltip: ''' Summons Astrum Aureus when used in the Astral Infection - Enrages during the day while outside the Astral Infection {$Common.NotConsumable} 'The Infection's fortress has found another target.' ''' @@ -34,7 +33,7 @@ BloodyWormFood: { Tooltip: ''' Summons the Perforator Hive when used in the Crimson - Enrages outside the Underground Crimson + Despawns outside the Crimson {$Common.NotConsumable} 'Do not play with your food, they won't play with theirs.' ''' @@ -42,11 +41,7 @@ BloodyWormFood: { CausticTear: { DisplayName: Caustic Tear - Tooltip: - ''' - Causes an acidic downpour in the Sulphurous Sea - {$Common.NotConsumable} - ''' + Tooltip: Causes an acidic downpour in the Sulphurous Sea } CeremonialUrn: { @@ -86,7 +81,6 @@ CryoKey: { Tooltip: ''' [SPAWN] - Enrages outside the tundra {$Common.NotConsumable} 'A key for a glacial prison.' ''' @@ -108,8 +102,7 @@ DecapoditaSprout: { DisplayName: Decapodita Sprout Tooltip: ''' - Summons Crabulon when used in the Mushroom biome - Enrages outside the Underground Mushroom biome + Summons Crabulon when used in the Underground Mushroom biome {$Common.NotConsumable} 'Bristling with the spores of a unique, parasitic strain.' ''' @@ -149,15 +142,13 @@ ExoticPheromones: { EyeofDesolation: { DisplayName: Eye of Desolation - // The GFB tag generates a new line below when placed at the end of a line Tooltip: ''' - Summons the Calamitas Clone when used during nighttime[GFB] - Enrages during the day + Summons the Calamitas Clone + Creates a square arena in Revengeance Mode, with you at its bottom {$Common.NotConsumable} 'She is here.' ''' - GFBInfo: Creates a square arena of blocks, with you at its center } NaiadsWarhorn: { @@ -184,7 +175,7 @@ MarkofProvidence: { SpawnVoid: ''' Summons the Ceaseless Void - Enrages on the surface + Despawns on the surface ''' SpawnSignus: Summons Signus, Envoy of the Devourer SpawnWeaver: Summons the Storm Weaver @@ -192,11 +183,7 @@ MarkofProvidence: { MartianDistressRemote: { DisplayName: Martian Distress Remote - Tooltip: - ''' - Summons the Martian Madness - {$Common.NotConsumable} - ''' + Tooltip: Summons the Martian Madness } NecroplasmicBeacon: { @@ -204,6 +191,7 @@ NecroplasmicBeacon: { Tooltip: ''' Summons Polterghast when used in the Dungeon + Despawns on the surface {$Common.NotConsumable} 'The wails of the spirits disturbed something far more terrifying.' ''' @@ -280,7 +268,6 @@ Starcore: { Tooltip: ''' Summons Astrum Deus at the Astral Beacon, but is not consumed - Enrages during the day 'May the stars guide your way' ''' } @@ -290,7 +277,7 @@ Teratoma: { Tooltip: ''' Summons the Hive Mind when used in the Corruption - Enrages outside the Underground Corruption + Despawns outside the Corruption {$Common.NotConsumable} 'An exquisitely hideous tumor for those diseased in the head.' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson b/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson index 7b35e3cf51..64675769a1 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson @@ -23,6 +23,26 @@ AerialHamaxe: { Tooltip: "" } +AntiCystOintment: { + DisplayName: Anti-Cyst Ointment + Tooltip: + ''' + Toggle this item to prevent hive cysts from spawning near you + Press to toggle + [STATE] + ''' +} + +AntiTumorOintment: { + DisplayName: Anti-Tumor Ointment + Tooltip: + ''' + Toggle this item to prevent hive tumors from spawning near you + Press to toggle + [STATE] + ''' +} + AridArtifact: { DisplayName: Arid Artifact Tooltip: @@ -52,6 +72,31 @@ AxeofPurity: { ''' } +Bakidon: { + DisplayName: Bakidon + Tooltip: + ''' + A lost artifact said to pin the heavens in place + to freeze the passage of day and night temporarily + This does not work during celestial anomalies + The time freeze recharges while not in use + ''' +} + +BallAndChain: { + DisplayName: Ball and Chain + Tooltip: + ''' + Toggle this item to disable any dashes granted by equipment + to toggle + [STATE] + 'So heavy...' + ''' + // This is "backwards" because enabling this disables dashes + TooltipEnabled: Dashes are currently disabled + TooltipDisabled: Dashes are currently enabled +} + BeastialPickaxe: { DisplayName: Beastial Pickaxe Tooltip: "" @@ -62,6 +107,16 @@ BerserkerWaraxe: { Tooltip: "" } +BleachBall: { + DisplayName: Bleach Ball + Tooltip: + ''' + Toggle this item to prevent Aquatic Scourge from spawning + Press to toggle + [STATE] + ''' +} + BlossomPickaxe: { DisplayName: Blossom Pickaxe Tooltip: Can mine Auric Ore @@ -76,12 +131,34 @@ BobbitHook: { ''' } +BrimstoneLocus: { + DisplayName: Brimstone Locus + Tooltip: + ''' + [c/C61B40:'Not only can I enhance your equipment with potent magic,] + [c/C61B40:I can also transcend some of your weaponry to entirely new forms.] + [c/C61B40:Such items are revealed while this item is in your inventory.'] + ''' +} + +BrokenWaterFilter: { + DisplayName: Broken Water Filter + Tooltip: + ''' + Toggle this item to prevent Acid Rain from occurring + Press to toggle + [STATE] + ''' +} + Cosmolight: { DisplayName: Cosmolight Tooltip: ''' - Advances time immediately to the next dawn, noon, dusk or midnight - Does not work while a boss is alive + A lost artifact freshly rekindled by exposure to raw cosmic energies + Hold to drastically accelerate the passage of day and night + to freeze the passage of day and night indefinitely + The time freeze lasts forever and works during celestial anomalies ''' } @@ -94,6 +171,16 @@ CrystylCrusher: { ''' } +DisgustingMeat: { + DisplayName: Disgusting Meat + Tooltip: + ''' + will remove health and mana upgrades, use with no Calamity upgrades to remove vanilla upgrades + will remove rage and adrenaline upgrades, plus other miscellaneous boosters + Removed boosters will be vomited out of you as items + ''' +} + DriftwoodAxe: { DisplayName: Driftwood Axe Tooltip: Improved efficiency while you are wet @@ -111,7 +198,7 @@ DriftwoodPickaxe: { FellerofEvergreens: { DisplayName: Feller of Evergreens - Tooltip: "" + Tooltip: Occasionally drops extra fruits from shaking trees } Gelpick: { @@ -165,6 +252,25 @@ MarniteObliterator: { ''' } +MomentumCapacitor: { + DisplayName: Momentum Capacitor + GFBName: Burden Breaker + Tooltip: "[GFB]" + TooltipNormal: + ''' + While using the Momentum Capacitor, + your top speed will continuously and uncontrollably increase + This effect only works if there are no bosses alive + ''' + TooltipGFB: + ''' + The good time + Go fast + WARNING: May have disastrous results + Only works if there are no bosses alive + ''' +} + MonolithAxe: { DisplayName: Monolith Axe Tooltip: "" @@ -180,11 +286,52 @@ MonolithPickaxe: { Tooltip: "" } +NormalityRelocator: { + DisplayName: Normality Relocator + Tooltip: + ''' + Press [KEY] to teleport to the position of the mouse + Fall speed is doubled for 0.5 seconds after teleporting + Teleportation is disabled while Chaos State is active + Works while in the inventory + 'I'll be there in the blink of an eye' + ''' +} + ReefclawHamaxe: { DisplayName: Reefclaw Hamaxe Tooltip: "" } +RelicOfConvergence: { + DisplayName: Relic of Convergence + Tooltip: + ''' + Creates a profaned crystal at the cursor that channels a healing aura before shattering + All players within the area of effect are healed for {0} HP + Allies gain 50% extra healing + Holding out the crystal reduces the damage of all summons, decreases defense, and increases incoming damage + [c/FF8C00:Never once had I known kindness. Neither my peers or family had a shred of compassion for me.] + [c/FF8C00:I wished for someone I could confide. A presence that cleansed me of anxiety.] + [c/FF8C00:And when I saw Her radiant smile when we met, I knew I had finally found it.] + ''' +} + +RelicOfResilience: { + DisplayName: Relic of Resilience + Tooltip: + ''' + Holding this item creates orbiting rock shards around you and nearby allies + While they orbit you, your minimum defense is set to 150 and minimum damage reduction to 10% + Taking a hit or pressing will pull in the shards, then blast them outward, crippling hit enemies + This effect has a 10 second cooldown after taking a hit + Holding out the shield heavily reduces the damage of all summons while rocks are active, only for you + [c/FF8C00:I saw a massacre and did nothing to stop it. My vow broken, I was shunned.] + [c/FF8C00:My will to forge ahead vanished. My final wish was simply to not die alone.] + [c/FF8C00:But when She put faith in my shield, I would never again let it falter.] + ''' +} + SeismicHampick: { DisplayName: Seismic Hampick Tooltip: @@ -200,11 +347,42 @@ ShardlightPickaxe: { Tooltip: "" } +SirenproofEarMuffs: { + DisplayName: Sirenproof Earmuffs + Tooltip: + ''' + Toggle this item to prevent Anahita from spawning + Press to toggle + [STATE] + ''' +} + SkyfringePickaxe: { DisplayName: Skyfringe Pickaxe Tooltip: Able to mine Hellstone } +SulphurousSeaWorldSideChanger: { + DisplayName: Sulphurous Sea World Side Changer + Tooltip: + ''' + Spawn and use this if your regular ocean counts as a Sulphurous Sea + This will also fix the Abyss if it is broken + ''' +} + +SuperDummy: { + DisplayName: Super Dummy + Tooltip: + ''' + Creates a super dummy + Regenerates 1 million life per second + Will not die when taking damage over time from debuffs + to kill all super dummies + Can only spawn 50 super dummies at once + ''' +} + TectonicTruncator: { DisplayName: Tectonic Truncator Tooltip: "" @@ -220,12 +398,23 @@ TorrentialTear: { ''' } +VoodooDemonVoodooDoll: { + DisplayName: Voodoo Demon Voodoo Doll + Tooltip: + ''' + Toggle this item to prevent voodoo demons from spawning near you + Press to toggle + [STATE] + ''' +} + WulfrumDiggingTurtle: { DisplayName: Wulfrum Digging Turtle Tooltip: ''' Throws a rickety mining contraption to dig out a small tunnel In case of an emergency, press to instantly detonate all your digging turtles + The turtle scales with your pickaxe power ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.TreasureBags.hjson b/Localization/en-US/Mods.CalamityMod.Items.TreasureBags.hjson index 4dab8cfc05..61238dff19 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.TreasureBags.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.TreasureBags.hjson @@ -14,7 +14,7 @@ AstrumDeusBag: { Tooltip: "{$CommonItemTooltip.RightClickToOpen}" } -BrimstoneWaifuBag: { +BrimstoneElementalBag: { DisplayName: Treasure Bag (Brimstone Elemental) Tooltip: "{$CommonItemTooltip.RightClickToOpen}" } @@ -130,15 +130,6 @@ AbyssalTreasure: { Tooltip: "{$CommonItemTooltip.RightClickToOpen}" } -BleachedAnglingKit: { - DisplayName: Bleached Angling Kit - Tooltip: - ''' - Has a chance to contain various fishing gear - {$CommonItemTooltip.RightClickToOpen} - ''' -} - FleshyGeode: { DisplayName: Fleshy Geode Tooltip: "{$CommonItemTooltip.RightClickToOpen}" @@ -149,15 +140,6 @@ NecromanticGeode: { Tooltip: "{$CommonItemTooltip.RightClickToOpen}" } -SandyAnglingKit: { - DisplayName: Sandy Angling Kit - Tooltip: - ''' - Has a chance to contain various fishing gear - {$CommonItemTooltip.RightClickToOpen} - ''' -} - StarterBag: { DisplayName: Starter Bag Tooltip: "{$CommonItemTooltip.RightClickToOpen}" diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson index 946cf85832..154ba2a790 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson @@ -1,11 +1,48 @@ -FrequencyManipulator: { - DisplayName: Frequency Manipulator +AerialTracker: { + DisplayName: P-LSR: Aerial Tracker Tooltip: ''' - Swings a spear around and then throws it - On collision, the spear releases a burst of homing energy - Stealth strikes release more energy and explode on collision - [c/1FFBFF:'A lengthy device originally used for mechanical tuning.'] + Releases a flying disk that fires lasers at nearby enemies + Lasers do not directly damage enemies, but instead apply a stacking laser burn effect + Once hit by enough lasers or sufficient time has passed, laser burn will deal direct damage + The disk gains acceleration as it returns to the player + Stealth strikes toss two disks that can fire at multiple different targets from farther range + ''' +} + +AqueousHunterDrone: { + DisplayName: P-PMA: Aqueous Hunter Drone + Tooltip: + ''' + Summons a shrimp drone that fires bursts of homing plasma missiles + while holding any summon weapon to command the shrimp to launch a vertical missile barrage + Vertical missiles aim towards your cursor and leave a lingering blast if they hit solid ground + Each shrimp uses 4 minion slots + [c/1FBFF:'When pursuing the adherents of gods, Yharim believed no stone should be left unturned.] + [c/1FBFF:Weaponry for underwater contingencies was an unusually heavy focus, but no models ever saw deployment.'] + ''' +} + +Auger: { + DisplayName: P-GSS: Auger + Tooltip: + ''' + A wrist-mounted device which emits a magnetic energy blade + to create a brief magnetic pull at your cursor and amplify your next slash + [c/1FFBFF:'Initially manufactured to serrate and separate chunks of raw material for transport.] + [c/1FFBFF:Keeping both hands free without compromising on power made it exceptionally ergonomic.'] + ''' +} + +CountermeasureMitt: { + DisplayName: B-LSR: Countermeasure Mitt + Tooltip: + ''' + A precision welding glove with laser emitters in each fingertip + to focus all emitters into a short range palm blast that always critically strikes + Palm blasts have a cooldown which is significantly shorter if they miss + [c/1FFBFF:'Most battalions prefer to either spread attacks widely, or focus on a singular target.] + [c/1FFBFF:This glove caters to both, though it will never bridge the gap between their strategies.'] ''' } @@ -20,53 +57,15 @@ GalvanizingGlaive: { ''' } -GatlingLaser: { - DisplayName: Gatling Laser - Tooltip: - ''' - Fires a rapid barrage of accelerated lasers to annihilate foes - [c/1FFBFF:'Developed to be used primarily by Yharim's fleet and base defense force.'] - ''' -} - -GaussDagger: { - DisplayName: Gauss Dagger - Tooltip: - ''' - Slices through foes with turbulent magnetic force - Striking foes envelops them in a damaging magnetic flux - ''' -} - -GaussPistol: { - DisplayName: Gauss Pistol - Tooltip: - ''' - Fires a devastating high-velocity blast with extreme knockback - [c/1FFBFF:'Though this arcane pistol may seem mundane, it is deceivingly powerful.] - [c/1FFBFF:One of the many advantages of magical firearms is that size does not equal power.'] - ''' -} - -GaussRifle: { - DisplayName: Gauss Rifle - Tooltip: - ''' - A magnet powered energy rifle that fires piercing shots, creating magnetic implosions that pull in weak enemies on hit - Implosions only spawn on the first enemy hit by the beam - [c/1FFBFF:'Many soldiers underestimate the destructive capabilities of magnetism.] - [c/1FFBFF:This rifle has reliably pulled in skeptics of its crushing efficiency.'] - ''' -} - -HolofiberImmolator: { - DisplayName: Holofiber Immolator +HolofibreImmolator: { + DisplayName: R-PMA: Holofibre Immolator Tooltip: ''' Fires three gravity-affected plasma drops which dissolve through foes - Holding quickly charges the bow, firing a homing plasma arrow + Holding quickly charges the bow, firing a high-speed plasma arrow Plasma arrows will detonate after impact, creating stronger explosions if stuck into tiles Holding will repeatedly fire uncharged shots + Holding and will automatically fire charged arrows at a slightly slower rate [c/1FFBFF:'The elegance of holofibre is unmatched.] [c/1FFBFF:However, mechanical tension may have produced more consistent results.'] ''' @@ -88,6 +87,32 @@ MountedScanner: { Tooltip: Summons a powerful scanner module above your head that fires lasers at nearby enemies } +Nidhogg: { + DisplayName: B-GSS: Nidhogg + Tooltip: + ''' + A magnet powered energy railgun that fires rapidly, creating lingering magnetic implosions that pull in weak enemies on hit + Only one implosion can exist at a time + Press to begin charging a devastating energy beam that always crits and will fire once ready + This charge attack can not be interrupted once started and has a long cooldown + [c/1FFBFF:'Many soldiers underestimate the destructive capabilities of magnetism.] + [c/1FFBFF:This railgun has reliably pulled in skeptics of its crushing efficiency.'] + ''' +} + +PhalanxSurge: { + DisplayName: W-LSR: Phalanx Surge + Tooltip: + ''' + Fires a spread of lasers + Holding charges the weapon, allowing it to thrust forward and impale enemies with an energy spear + Holding when firing the charge attack will launch you forward at high speeds and deal extra damage + Using the charged attack has a short cooldown + [c/1FFBFF:'There was much call from Yharim's forces for close range armaments.] + [c/1FFBFF:A laser lance with which to gore their foes was met with thunderous applause.'] + ''' +} + Phaseslayer: { DisplayName: Phaseslayer Tooltip: @@ -95,7 +120,6 @@ Phaseslayer: { Projects a colossal laser blade which is controlled by the cursor Move the cursor to swing the blade and rip and tear through enemies Faster swings deal more damage and release additional sword beams - When at low charge, the blade becomes smaller and weaker ''' } @@ -137,18 +161,28 @@ PulseDragon: { ''' } +PulseGrenade: { + DisplayName: R-PLS: Pulse Grenade + Tooltip: + ''' + A regenerating grenade that will track enemies and burst into 8 pulse orbs + Pulse orbs will return to you and reform the grenade, hitting anything in their path + Stealth strikes throw the grenade at high speeds and burst into twice as many orbs + ''' +} + PulsePistol: { - DisplayName: Pulse Pistol + DisplayName: P-PLS: Pulse Pistol Tooltip: ''' Fires a pulse orb that tracks nearby targets After hitting an enemy, the pulse orb will split in two - Pulse orb pierce will not decrease when killing enemies + Pulse orb pierce will increase when killing enemies ''' } PulseRifle: { - DisplayName: Pulse Rifle + DisplayName: A-PLS: Pulse Rifle Tooltip: ''' Fires an enhanced pulse beam that dissipates into 4 high-frequency pulse orbs on hit @@ -169,16 +203,15 @@ PulseTurretRemote: { ''' } -ScattershotSkewer: { - DisplayName: Scattershot Skewer +ShortCircuit: { + DisplayName: P-TSL: Short Circuit Tooltip: ''' - Fires a spread of lasers - Holding charges the weapon, allowing it to thrust forward and impale enemies with an energy spear - Using the charged attack has a short cooldown - Holding will repeatedly fire uncharged shots - [c/1FFBFF:'There was much call from Yharim's forces for close range armaments.] - [c/1FFBFF:A laser lance with which to gore their foes was met with thunderous applause.'] + Press to rapidly fire stunning bolts with high knockback + Press to shoot a hook that attaches to enemies and rapidly electrocutes them + After electrocuting an enemy enough, the hook will create a shock explosion before returning to you + Successful hook attacks have a short cooldown that is applied unless the hook kills an enemy + {$Common.ArmorPenetration} ''' } @@ -194,16 +227,6 @@ SnakeEyes: { ''' } -StarSwallowerContainmentUnit: { - DisplayName: Star Swallower Containment Unit - Tooltip: - ''' - Summons a biomechanical frog that vomits plasma onto enemies - [c/1FFBFF:'These simplistic creatures were mechanized to autonomously transport plasma.] - [c/1FFBFF:They are vastly more servicable than their mundane organic counterparts.'] - ''' -} - SystemBane: { DisplayName: System Bane Tooltip: @@ -213,15 +236,6 @@ SystemBane: { ''' } -Taser: { - DisplayName: Taser - Tooltip: - ''' - Shoots a hook that attaches to enemies and rapidly electrocutes them before returning - After electrocuting an enemy enough, the hook will create a large electric burst on it - ''' -} - TeslaCannon: { DisplayName: Tesla Cannon Tooltip: @@ -241,15 +255,16 @@ TheAnomalysNanogun: { ''' } -TrackingDisk: { - DisplayName: Tracking Disk +Vulcan: { + DisplayName: R-GSS: Vulcan Tooltip: ''' - Releases a flying disk that fires lasers at nearby enemies - Lasers do not directly damage enemies, but instead apply a stacking laser burn effect - Once hit by enough lasers or sufficient time has passed, laser burn will deal direct damage - The disk gains acceleration as it returns to the player - Stealth strikes fire lasers at a faster rate and distance, can fire at multiple different targets, and lasers deal small amounts of damage + A mana-fueled Gatling cannon that fires in bursts + Press to launch a magnetic harpoon which attracts your shots + Launching a harpoon makes burst fire mode last longer + When a harpoon expires, all magnetized shots launch at nearby enemies with increased damage + [c/1FFBFF:'Originally a ceiling mounted mining beam, the removal of its battery reduced its heft only marginally.] + [c/1FFBFF:It saw little use and many complaints from the battlemage corps.'] ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index b6a8a7aef9..50f3ab49e3 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -29,7 +29,20 @@ AethersWhisper: { AlulaAustralis: { DisplayName: Alula Australis - Tooltip: Fires a beautiful aurora trailed by a star shower + Tooltip: Fires a beautiful aurora that inflicts [cbuff:CalamityMod/AstralInfectionDebuff] trailed by a star shower +} + +AlphaDraconis: { + DisplayName: Alpha Draconis + Tooltip: + ''' + Calls down a meteor shower towards the cursor + Successful hits sometimes create Starbursts that can be picked up + with enough Starbursts to summon Draco to protect you + Draco burns Starbursts over time, and can be disspelled with + Draco inflicts [cbuff:CalamityMod/Voidfrost] + 'An imitation of insanity' + ''' } AnahitasArpeggio: { @@ -38,7 +51,8 @@ AnahitasArpeggio: { TooltipNormal: ''' Holding casts up to 6 treble clefs that orbit the player - Releasing causes the treble clefs to fade away, then converge at the cursor + Releasing causes the treble clefs to converge at the cursor + After converging, treble clefs seek your cursor ''' TooltipGFB: ''' @@ -106,33 +120,19 @@ ArtAttack: { ''' } -AsteroidStaff: { - DisplayName: Asteroid Staff - Tooltip: "[GFB]" - TooltipNormal: Summons asteroids from the sky - TooltipGFB: - ''' - Core Keeper Chaos Staff - bottom text - ''' -} - AstralachneaStaff: { DisplayName: Astralachnea Staff - Tooltip: Fires a spread of homing astral spider fangs + Tooltip: Fires a spread of homing astral spider fangs that inflict [cbuff:CalamityMod/AstralInfectionDebuff] } AstralStaff: { DisplayName: Astral Staff - Tooltip: Summons a large crystal from the sky that has a large area of effect on impact + Tooltip: Summons a large crystal from the sky that has a large area of effect on impact and inflicts [cbuff:CalamityMod/AstralInfectionDebuff] } Atlantis: { DisplayName: Atlantis - Tooltip: "[GFB]" - TooltipNormal: Casts aquatic spears that split as they travel - TooltipGFB: A cosmic serpent prevents this weapon's true potential from shining... - TooltipGFBDoG: Take good care of my weapon, or else... -CIT + Tooltip: Casts aquatic spears that split as they travel } AuguroftheVoid: { @@ -191,15 +191,6 @@ ChronomancersScythe: { ''' } -ClamorNoctus: { - DisplayName: Clamor Noctus - Tooltip: - ''' - Fires night wyverns and stars from the sky that stick to enemies and tiles and explode - 'Let the sky fall' - ''' -} - ClothiersWrath: { DisplayName: Clothier's Wrath Tooltip: Shoots 3 shadowflame skulls @@ -242,30 +233,16 @@ DarkSpark: { ''' } -DeathhailStaff: { - DisplayName: Deathhail Staff - Tooltip: - ''' - Casts a storm of nebula lasers from the sky - 'Rain death upon your foes!' - ''' -} - DeathValleyDuster: { DisplayName: Death Valley Duster Tooltip: ''' Casts an enchanted blast of sand that passes through enemies and tiles Casting this spell at max mana while without mana sickness will cause it to give you and any player it hits the Sand's Wind Buff - The Sand's Wind Buff increases your defense by 10 and damage by 12% + The Sand's Wind Buff increases your defense by 10, damage by 12%, and greatly buffs mana regen ''' } -DivineRetribution: { - DisplayName: Divine Retribution - Tooltip: Mage is superior to rogue; look, we got a donor weapon to prove it! -} - Downpour: { DisplayName: Downpour Tooltip: @@ -324,11 +301,6 @@ EvergladeSpray: { Tooltip: Fires a stream of burning green ichor } -Fabstaff: { - DisplayName: Fabstaff - Tooltip: Casts a bouncing beam that splits when enemies are near it -} - FaceMelter: { DisplayName: Face Melter Tooltip: @@ -462,6 +434,11 @@ Heresy: { ''' } +HyperdeathRiftScepter: { + DisplayName: Hyperdeath Rift Scepter + Tooltip: Tears space in two with [c/ff00ff:Hyperdeath Rift Ripper] +} + HyphaeRod: { DisplayName: Hyphae Rod Tooltip: Creates mushroom spores near the player @@ -509,7 +486,8 @@ Keelhaul: { DisplayName: Keelhaul Tooltip: ''' - Summons a geyser upon hitting an enemy + Summons a lingering geyser upon hitting an enemy + Only one geyser can exist at a time 'Crumple 'em like paper' ''' } @@ -675,7 +653,7 @@ PrimordialAncient: { ''' Casts five primordial sand blasts that converge at your cursor after a moment and create a giant explosion Casting this spell at max mana while without mana sickness will cause it to give you and any player it hits the {$Buffs.AeolianEarthBuff.DisplayName} buff - The {$Buffs.AeolianEarthBuff.DisplayName} buff increases your damage reduction by {0}% and damage by {1}% + The {$Buffs.AeolianEarthBuff.DisplayName} buff increases your damage reduction by {0}%, damage by {1}%, and massively buffs mana regen ''' } @@ -685,7 +663,7 @@ PrimordialEarth: { ''' Casts two enchanted blasts of sand that coverge with each other and explode Casting this spell at max mana while without mana sickness will cause it to give you and any player it hits the {$Buffs.SandsWindBuff.DisplayName} buff - The {$Buffs.SandsWindBuff.DisplayName} buff increases your defense by {0} and damage by {1}% + The {$Buffs.SandsWindBuff.DisplayName} buff increases your defense by {0}, damage by {1}%, and greatly buffs mana regen ''' } @@ -749,7 +727,12 @@ SandstreamScepter: { SanguineFlare: { DisplayName: Sanguine Flare - Tooltip: Fires a blast of sanguine flares that drain enemy life + Tooltip: + ''' + Charges up a sanguine flare that gains power over time + When striking an enemy, this flare causes a bloodsplosion and splits into blood orbs + Picking up these blood orbs reduces the duration of [cbuff:PotionSickness] + ''' } SeethingDischarge: { @@ -796,11 +779,21 @@ SHPC: { TooltipNormal: ''' Consumes Souls as ammo - Fires orbs of unstable, concentrated soulpower that linger after ejection - Orbs create a large explosion and emit seeking souls after collapse + Ejects orbs of unstable, concentrated soulpower that linger and explode + Orbs emit seeking souls and lingering pickup souls after collapse Orbs have varying effects depending on Soul type used - Press Right Click to discharge all soulpower in the weapon as weak energy beams + {0} + Press to use the machine as a vacuum, pulling in lingering souls + Once released, a torrent of soul lasers is discharged scaling with the number of souls pulled in ''' + // These are the soul effect descriptions, the number is the item ID of the soul + NoSoul: "[c/808080:There is currently no soul type injected into the weapon]" + SoulDesc520: "[c/F01DC4:Light-infused orbs create larger explosions]" + SoulDesc521: "[c/7B1DDC:Night-infused orbs create longer lasting explosions]" + SoulDesc575: "[c/6AF0FA:Flight-infused orbs travel faster and restore flight time on direct hits]" + SoulDesc548: "[c/0433DE:Might-infused orbs apply mighty knockback to enemies]" + SoulDesc549: "[c/4FFF7C:Sight-infused orbs seek out nearby enemies]" + SoulDesc547: "[c/FF6014:Fright-infused orbs deal extra flat damage with their hatred]" LegendaryText: ''' 'Though soul-powered machines were a near failure, potential remained in souls as a form of fuel. @@ -857,6 +850,15 @@ SubsumingVortex: { ''' } +Sylvestaff: { + DisplayName: Sylvestaff + Tooltip: + ''' + Casts a bouncing beam that splits when enemies are near it + 'Also known as the Karma Staff!' + ''' +} + TacticiansTrumpCard: { DisplayName: Tactician's Trump Card Tooltip: @@ -947,6 +949,29 @@ UndinesRetribution: { Tooltip: Casts a swarm of homing spears } +UnstableCastersGauntlet: { + DisplayName: Unstable Caster's Gauntlet + Tooltip: + ''' + to fire piercing needles + to summon a ring of sigils, each representing a primordial element + Hold with sigils available to consume random sigils, each unleashing an attack + again while the elemental ring is out to replace all empty slots with [c/DD84E8:Warped] sigils + [c/DD84E8:Warped] sigils automatically fire barrages of inaccurate purple blasts + All actions require sufficient [c/EADAF5:Vis] to use + [c/EADAF5:Vis] is restored over time + ''' + HoldShiftTooltip: + ''' + [c/DBD7CA:Ordo] sigils always land critical strikes and pierce infinitely + [c/ABB6D4:Perdito] sigils ignore 25 points of enemy defense + [c/E89B8E:Ignis] sigils inflict Daybroken + [c/8ECBE8:Aqua] sigils inflict Crush Depth + [c/E1E88E:Aer] sigils boast substantial knockback + [c/ACCF9F:Terra] sigils split into sharp rocks + ''' +} + ValkyrieRay: { DisplayName: Valkyrie Ray Tooltip: Casts a devastating ray of holy power @@ -984,7 +1009,9 @@ Viscera: { DisplayName: Viscera Tooltip: ''' - Fires a rapid barrage of piercing blood beams that heal you on enemy hit + Fires a rapid barrage of piercing blood beams + The first enemy struck by each beam will burst into blood orbs + Picking up these blood orbs reduces the duration of [cbuff:PotionSickness] Each successive beam in the barrage deals more damage The last beam of the barrage instead explodes upon hitting an enemy ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index f221281fd1..f1d885ebe0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -31,11 +31,6 @@ AegisBlade: { ''' } -Aftershock: { - DisplayName: Aftershock - Tooltip: Summons boulders from the sky on enemy hits -} - AirSpinner: { DisplayName: Air Spinner Tooltip: @@ -47,7 +42,12 @@ AirSpinner: { AmidiasTrident: { DisplayName: Amidias' Trident - Tooltip: Shoots homing whirlpools + Tooltip: + ''' + [c/CCE9FF:Striking enemies inflicts] [c/28A3FF:Sea King's Assurance], [c/CCE9FF:which can stack up to eight] + Right click to spin the trident then thrust into the air, expending all nearby stacks of Sea King's Assurance + Secondary attack deals more damage for every stack applied + ''' } AnarchyBlade: { @@ -89,7 +89,7 @@ ArkoftheCosmos: { to snip out the scissor blades in front of you Hitting an enemy with it will parry them, granting you brief invulnerability You can also parry projectiles to make them deal 160 less damage for a short period - Parrying will empower the next 15 swings of the sword + Parrying will empower the next 16 swings of the sword ''' BlastInfo: Double with charges available to cause a Big Rip in spacetime and consume all charges } @@ -116,19 +116,14 @@ ArkoftheElements: { ''' } -AstralBlade: { - DisplayName: Astral Blade - Tooltip: Deals more damage the more life an enemy has left -} - AstralPike: { DisplayName: Astral Pike - Tooltip: Summons astral star swarms on hit + Tooltip: Summons astral star swarms on hit and inflicts [cbuff:CalamityMod/AstralInfectionDebuff] } AstralScythe: { DisplayName: Astral Scythe - Tooltip: Shoots a scythe ring that accelerates over time + Tooltip: Shoots a scythe ring that accelerates over time and inflicts [cbuff:CalamityMod/AstralInfectionDebuff] } Ataraxia: { @@ -145,16 +140,6 @@ Avalanche: { ''' } -Azathoth: { - DisplayName: Azathoth - Tooltip: - ''' - {$Common.YoyoStatsInfinite} - Fires cosmic orbs that blast nearby enemies with lasers - 'Destroy the universe in the blink of an eye' - ''' -} - BalefulHarvester: { DisplayName: Baleful Harvester Tooltip: @@ -205,12 +190,7 @@ BladecrestOathsword: { BlightedCleaver: { DisplayName: Blighted Cleaver - Tooltip: - ''' - Fires homing blazing blades - Gives the player the Brutal Carnage buff on enemy hits - This buff increases melee damage by 20% - ''' + Tooltip: Fires homing blazing blades } Bonebreaker: { @@ -260,7 +240,7 @@ BrokenBiomeBlade: { Hold down while standing still on flat ground to attune the weapon to the powers of the surrounding biome Pressing otherwise switches between the current attunement and an extra stored one Main Attunement : [ATT1] - Secondary Attunement: [ATT2] + Secondary Attunement : [ATT2] ''' DefaultFunction: Does nothing... yet } @@ -330,8 +310,11 @@ CrescentMoon: { DisplayName: Crescent Moon Tooltip: ''' - Fires a whip sword that summons homing crescent moons - 'People wanted the moon, let's bring the moon to them' + Throws a lunar flail that releases homing moons at the apex of its path + Holding spins the flail around you, generating Starbursts + With 20 Starbursts, hold again after throwing the flail to cause it to explode + Instead of releasing moons, this explosion summons Scorpius to do immense damage and inflict [cbuff:CalamityMod/Voidfrost] + 'Lunacy derived from genius' ''' } @@ -354,12 +337,7 @@ DeathsAscension: { DefiledGreatsword: { DisplayName: Defiled Greatsword - Tooltip: - ''' - Fires blazing, hyper, and sunlight blades - Gives the player the Brutal Carnage buff on enemy hits - This buff increases melee damage by 20% - ''' + Tooltip: Fires blazing, hyper, and sunlight blades } DepthCrusher: { @@ -388,7 +366,7 @@ DevilsDevastation: { ''' [c/d13ca2:The perfect blade of the Underworld, wielding the power of Brimstone directly.] [c/d13ca2:Humans understand this force as Havoc, the inevitable sundering of all order in fire.] - [c/d13ca2:Perhaps this is why the Brimstone Elemental had strength unrivaled by her sisters.] + [c/d13ca2:Perhaps this is why the Brimstone Elemental had strength unrivaled by her sisters.] ''' } @@ -463,20 +441,12 @@ EmpyreanKnives: { EntropicClaymore: { DisplayName: Entropic Claymore - Tooltip: "[GFB]" - TooltipNormal: + Tooltip: ''' Fires a spread of living plasma that swims though the air Plasma will track your cursor or enemies near it, prioritizing which is closest The plasma pierces, but will stop tracking after hitting the first enemy ''' - TooltipGFB: - ''' - Fires a spread of dead tapeworms that swim throuh the air - Tapeworms will track your cursor or enemies near it, prioritizing which is closest - The tapeworms pierce, but will stop tracking after hitting the first enemy - [c/FF0000:'Go my tapeworms, make their balls itch'] - ''' } EssenceFlayer: { @@ -516,15 +486,6 @@ ExaltedOathblade: { ''' } -Excelsus: { - DisplayName: Excelsus - Tooltip: - ''' - Fires a spread of spinning blades - Summons laser fountains on hit - ''' -} - Exoblade: { DisplayName: Exoblade Tooltip: @@ -661,9 +622,13 @@ GalileoGladius: { DisplayName: Galileo Gladius Tooltip: ''' - Shoots a homing crescent moon - Spawns planetoids on enemy hits - 'Don't underestimate the power of small space swords' + Rapidly stabs in front of the player, generating Starbursts on hit + to throw the gladius on a constellation chain, impaling foes and inflicting [cbuff:CalamityMod/Voidfrost] + When the blade is impaled, use or to free it + pulls it free and deals high damage, consuming 10 Starbursts + pulls youself to the blade, allowing you to jump off the foe + Jumping off a foe consumes 20 Starbursts and provides invincibility + 'Figaro, magnifico' ''' } @@ -674,7 +639,15 @@ GeliticBlade: { GildedProboscis: { DisplayName: Gilded Proboscis - Tooltip: Heals the player on hit + Tooltip: + ''' + Steals life proportional to the damage dealt to foes + to charge up a precise thrust + The thrust begins weak, but becomes more powerful the longer it's held + to dash forward with a mighty upstrike + The distance you dash depends on if you are moving with or against the dash + Always critically strikes + ''' } GoldplumeSpear: { @@ -715,7 +688,11 @@ GrandGuardian: { GreatswordofJudgement: { DisplayName: Greatsword of Judgement - Tooltip: Fires a piercing energy wave that releases homing stars as it flies + Tooltip: + ''' + Fires a piercing energy wave that releases homing stars as it flies + Hits with the blade summon two stronger stars from behind you + ''' } Greentide: { @@ -788,22 +765,16 @@ InsidiousImpaler: { ''' } -IridescentExcalibur: { - DisplayName: Iridescent Excalibur - Tooltip: - ''' - True melee strikes freeze enemies - Fires rainbow beams that change their behavior based on their color - Press for true melee - ''' -} - Lacerator: { DisplayName: Lacerator Tooltip: ''' {$Common.YoyoStatsInfinite} - Accelerates natural life regeneration on hits with the yoyo + Striking enemies conjures a bloody saw to shred them + The saw does more damage the more often the yoyo hits, and fades away when not striking enemies + Enemies touching the edge of the sawblade get blood orbs torn out of them + Picking up these blood orbs reduces the duration of [cbuff:PotionSickness] + The direction of the saw's spin depends on which direction you originally threw the yoyo [GFB] ''' TooltipNormal: Someone thought this was a viable weapon against DoG at one point lol @@ -815,6 +786,17 @@ LifehuntScythe: { Tooltip: Heals you on hit and shoots an energy scythe } +Lightspeed: { + DisplayName: Lightspeed + Tooltip: + ''' + [c/c7f5ff:Unleash a flurry of stabs which build Elemental Mastery on hit] + [c/c2fff2:Elemental Mastery is lost over time but briefly stops depleting after reaching its maximum] + [c/ffdfba:Press with maximum Elemental Mastery to dash toward your cursor] + [c/ffc7c7:Hitting an enemy during the dash refunds some Elemental Mastery] + ''' +} + LionHeart: { DisplayName: Lion Heart Tooltip: @@ -829,8 +811,10 @@ Lucrecia: { DisplayName: Lucrecia Tooltip: ''' - Fires a DNA chain - Finesse + [c/9370db:Fires a spiraling darklight shard when swung] + [c/837ce4:Hits with the blade itself build Darklight Energy] + [c/7489ee:Darklight Energy is lost over time but briefly stops depleting after reaching its maximum] + [c/6495f7:Press with maximum energy to fire a double helix comet] ''' } @@ -854,13 +838,32 @@ MantisClaws: { ''' } +MawOfInfinity: { + DisplayName: Maw of Infinity + Tooltip: + ''' + Swings a blade forged from the Devourer's maw in a 3-swing combo + The first swing only hits close range + The second swing additionally launches [c/ff00ff:Faith Incinerator] + The third swing unleashes [c/ff00ff:Divinity Devourer] at your cursor, exploding for massive damage + ''' +} + MirrorBlade: { DisplayName: Mirror Blade Tooltip: ''' - The amount of contact damage an enemy does is added to this weapons' damage - You must hit an enemy with the blade to trigger this effect + Striking an enemy or a hostile projectile summons up to 10 orbiting mirror shards + Any shards above 10 instead seek out enemies + Holding coalesces the orbiting mirror shards into a shield ''' + HoldShiftTooltip: + ''' + [c/aab7f1:Each shard reduces the damage of a projectile that hit the shield by 10%] + [c/aab7f1:The shield shatters after one projectile, launching the shards at enemies with increased damage] + [c/aab7f1:With all 10 shards, you gain a brief period of invulnerability when shattering the shield] + ''' + FlavorTooltip: "[c/7b6d8d:'A blade taken from your own reflection within the Ceaseless Void']" } MonolithSword: { @@ -905,7 +908,7 @@ Nadir: { Nebulash: { DisplayName: Nebulash - Tooltip: Fires a whip sword that emits particle explosions on hit + Tooltip: Fires a whip sword that emits particle explosions on hit and inflicts [cbuff:CalamityMod/AstralInfectionDebuff] } NeptunesBounty: { @@ -932,7 +935,7 @@ OldLordClaymore: { HoldShiftTooltip: ''' [c/df4420:A gift to outstanding Demons, a replica of the sword used by the greatest of all Demon Lords.] - [c/df4420:The prosperity he brought to their kind is unmatched even now that they alone rule the Undeworld.] + [c/df4420:The prosperity he brought to their kind is unmatched even now that they alone rule the Underworld.] ''' } @@ -946,7 +949,7 @@ OmegaBiomeBlade: { Holding down for 2 seconds attunes the weapon to the powers of the surrounding biome Pressing for a shorter period of time switches your active and passive attunements around Active Attunement : [ATT1] - Passive Attunement: [ATT2] + Passive Attunement : [ATT2] ''' DefaultFunction: ''' @@ -966,12 +969,21 @@ Orderbringer: { Tooltip: ''' Fires piercing energy waves and summons four homing stars near your cursor - Energy waves deal more damage with each consecutive hit Hits with the blade summon two beams from the sky 'No matter where you may be you are never alone' ''' } +Ozzathoth: { + DisplayName: Ozzathoth + Tooltip: + ''' + {$Common.YoyoStatsInfinite} + Fires cosmic orbs that blast nearby enemies with lasers + 'Destroy the universe in the blink of an eye' + ''' +} + Pandemic: { DisplayName: Pandemic Tooltip: @@ -1068,7 +1080,7 @@ Riptide: { Tooltip: ''' {$Common.YoyoStats} - Occasionally pulses a riptide wave with heavy knockback + Rapidly pulses riptide waves which get larger the more hits landed by the yoyo ''' } @@ -1174,11 +1186,6 @@ SpineOfThanatos: { ''' } -StarburstShiv: { - DisplayName: Starburst Shiv - Tooltip: Shoots a rainbow shiv that spawns additional shivs on hit -} - StarnightLance: { DisplayName: Starnight Lance Tooltip: Shoots a frigid starnight beam @@ -1326,11 +1333,6 @@ TheDarkMaster: { ''' } -TheEnforcer: { - DisplayName: The Enforcer - Tooltip: Spawns essence flames on hit -} - TheGodsGambit: { DisplayName: The God's Gambit Tooltip: @@ -1350,7 +1352,7 @@ TheMicrowave: { Tooltip: ''' {$Common.YoyoStatsInfinite} - Fries nearby enemies with radiation + Fries nearby enemies with radiation and inflicts [cbuff:CalamityMod/AstralInfectionDebuff] 'Cooking, Astral Infection style' ''' } @@ -1359,8 +1361,9 @@ TheMutilator: { DisplayName: The Mutilator Tooltip: ''' - Striking an enemy below 20% life will trigger a bloodsplosion - Bloodsplosions cause hearts to drop that can be picked up to heal you + Striking enemies empowers The Mutilator, increasing its damage + At full charge, striking enemies causes a blood orb explosion + Picking up these blood orbs reduces the duration of [cbuff:PotionSickness] ''' } @@ -1371,7 +1374,7 @@ TheObliterator: { {$Common.YoyoStatsInfinite} [GFB] ''' - TooltipNormal: Ruins nearby enemies with death lasers + TooltipNormal: Occasionally performs a miniature [c/ff00ff:Dimensional Drive] at nearby foes TooltipGFB: just a slight bit of dust spam on this weapon im afraid } @@ -1390,7 +1393,7 @@ TitanArm: { DisplayName: Titan Arm Tooltip: ''' - Sends enemies straight to the stars at the speed of light + Sends enemies straight to the stars at the speed of light and inflicts [cbuff:CalamityMod/AstralInfectionDebuff] Slap Hand but better ''' } @@ -1431,7 +1434,7 @@ TrueBiomeBlade: { Hold down while standing still on flat ground to attune the weapon to the powers of the surrounding biome Pressing otherwise switches between the current attunement and an extra stored one Main Attunement : [ATT1] - Secondary Attunement: [ATT2] + Secondary Attunement : [ATT2] ''' DefaultFunction: ''' @@ -1475,16 +1478,27 @@ UltimusCleaver: { UrchinMace: { DisplayName: Urchin Mace - Tooltip: Throws out a whirlpool when released + Tooltip: + ''' + Throws out a whirlpool when released + [c/5C95A1:'The people of the sea were adept hunters, but they abhorred unnecessary violence.] + [c/5C95A1:Unfortunately, neighboring nations were brutish, so they fashioned their tools for war.'] + ''' } VanishingPoint: { DisplayName: Vanishing Point - Tooltip: + Tooltip: "[GFB]" + TooltipNormal: ''' Fires a lance beam that splits multiple times as it travels 'Rend the cosmos asunder!' ''' + TooltipGFB: + ''' + Fires a lance beam that splits, like, a LOT. Way more than it ever should. + 'Rend the projectile limit asunder!' + ''' } VeinBurster: { @@ -1494,7 +1508,12 @@ VeinBurster: { Violence: { DisplayName: Violence - Tooltip: Releases a blazing fork which stays near the mouse and shreds enemies + Tooltip: + ''' + A demonic pitchfork, cursed to cause endless bloodshed + commands the trident to follow your cursor and shred enemies with devastating speed + throws the trident, violently tearing through enemies with immense power and inflicting Vulnerability Hex + ''' } Virulence: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index d312f52466..71d9cca713 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -65,11 +65,6 @@ AntiMaterielRifle: { ''' } -AquashardShotgun: { - DisplayName: Aquashard Shotgun - Tooltip: Converts musket balls into aquashards that split upon hitting an enemy -} - Arbalest: { DisplayName: Arbalest Tooltip: @@ -82,7 +77,11 @@ Arbalest: { Archerfish: { DisplayName: Archerfish - Tooltip: Converts musket balls into streams of water + Tooltip: + ''' + Converts musket balls into streams of water + {$CommonItemTooltip.PercentChanceToSaveAmmo} + ''' } ArcNovaDiffuser: { @@ -91,7 +90,7 @@ ArcNovaDiffuser: { ''' Charges and fires a rapid burst of nova bolts The first charging stage increases the fire rate of the burst - The second charging stage replaces the rapid burst with a devastating nova blast + The second charging stage replaces the rapid burst with a devastating nova blast that always crits ''' } @@ -108,19 +107,15 @@ ArterialAssault: { DisplayName: Arterial Assault Tooltip: ''' - Fires a chain of 5 arrows from the sky - All arrows will rapidly home in on nearby enemies + Fires a group of 5 homing blood arrows + These blood arrows burst into blood orbs upon striking an enemy + Picking up these blood orbs reduces the duration of [cbuff:PotionSickness] ''' } AstralBlaster: { DisplayName: Astral Blaster - Tooltip: Converts musket balls into homing astral rounds -} - -AstralBow: { - DisplayName: Astral Bow - Tooltip: Fires a burst of three arrows + Tooltip: Converts musket balls into homing astral rounds that inflict [cbuff:CalamityMod/AstralInfectionDebuff] } AstrealDefeat: { @@ -138,7 +133,6 @@ Auralis: { Standing still for 5 or more seconds while using the scope ability will summon an aurora The aurora reduces the damage of the next projectile hit by 100 This effect lasts up to 20 seconds and has a 30 second cooldown - 50% chance to save ammo ''' } @@ -146,7 +140,7 @@ AuroraBlazer: { DisplayName: Aurora Blazer Tooltip: ''' - Spews a nebula stream which forms a star shaped pattern + Spews a nebula stream which forms a star shaped pattern and inflicts [cbuff:CalamityMod/AstralInfectionDebuff] Uses gel for ammo ''' } @@ -179,7 +173,7 @@ BlightSpewer: { ''' Fires clouds of plague nanomachines that stick to tiles Nanomachines aggressively lock onto nearby enemies - 40% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -196,9 +190,10 @@ BloodBoiler: { DisplayName: Blood Boiler Tooltip: ''' - Fires twin streams of life stealing bloodfire that returns to you + Fires twin streams of bloodfire that returns to you + Retuning bloodfire reduces [cbuff:PotionSickness] if it struck an enemy Uses your health as ammo - 40% chance to save health + 20% chance to save health ''' } @@ -230,6 +225,7 @@ BulletFilledShotgun: { Tooltip: ''' Fires a massive spread of bouncing bullets + Bullets attempt to bounce towards enemies after bouncing twice Consumes five bullets per-use 'Aim? What's that?' ''' @@ -257,7 +253,7 @@ ChromaticEruption: { ''' Charges up to spew rainbow flames and pairs of homing chromatic flares Uses gel for ammo - 70% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -266,15 +262,6 @@ ClamorRifle: { Tooltip: Converts musket balls into homing energy bolts } -ClaretCannon: { - DisplayName: Claret Cannon - Tooltip: - ''' - Fires strings of 3 bullets - Converts musket balls into bloody tears that drain enemy health - ''' -} - CleansingBlaze: { DisplayName: Cleansing Blaze Tooltip: @@ -284,20 +271,11 @@ CleansingBlaze: { ''' } -ClockGatlignum: { - DisplayName: Clock Gatlignum - Tooltip: - ''' - Converts musket balls into strings of 3 high velocity bullets - 33% chance to save ammo - ''' -} - ClockworkBow: { DisplayName: Clockwork Bow Tooltip: ''' - Hold left click to load up to six precision bolts + Hold to load up to six precision bolts The more precision bolts are loaded, the harder they hit ''' } @@ -317,7 +295,6 @@ ConferenceCall: { Tooltip: ''' Fires a tight spread of bullets that call more bullets from the sky - 50% chance to save ammo [c/768EE6:@everyone] ''' } @@ -370,7 +347,7 @@ DaemonsFlame: { Tooltip: ''' Shoots daemon flame fireballs as well as 4 regular arrows - 66% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -394,16 +371,6 @@ DeadSunsWind: { ''' } -Deathwind: { - DisplayName: Deathwind - Tooltip: - ''' - Fires a spread of 4 arrows - Wooden arrows are converted into nebula arrows - Nebula arrows deal more damage and inflict god slayer inferno - ''' -} - DeepcoreGK2: { DisplayName: Deepcore GK2 Tooltip: @@ -413,15 +380,6 @@ DeepcoreGK2: { ''' } -DodusHandcannon: { - DisplayName: Dodu's Handcannon - Tooltip: - ''' - Fires high explosive peanut shells, literally - 'The power of the nut rests in your hands' - ''' -} - DragonsBreath: { DisplayName: Dragon's Breath Tooltip: @@ -430,7 +388,7 @@ DragonsBreath: { Upon firing for long enough, you will begin using a cartridge of energy While using a cartridge you will shoot a draconic beam of fire that doesn't consume ammo Once a cartridge has been ejected you will return to the original fire rate - 80% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -467,9 +425,9 @@ FetidEmesis: { ''' Fires an accelerating stream of bullets until the barrel overheats When the barrel overheats, a spread of fetid chunks is vomited out -After firing, the gun must cool back down before it can be used again + After firing, the gun must cool back down before it can be used again Pressing while firing will instantly launch the chunks - 75% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -477,9 +435,11 @@ FirestormCannon: { DisplayName: Firestorm Cannon Tooltip: ''' - Releases a constant stream of weaponized flares - Press to fire a condensed spread of flares - 70% chance to save ammo + Fires a rapid barrage of flares that builds up a searing heat in the weapon + Firing for too long overheats the weapon, leaving it unusable for a short period + Press to put away the weapon, which preserves its heat + {$CommonItemTooltip.PercentChanceToSaveAmmo} + 'What could go wrong?' ''' } @@ -519,7 +479,7 @@ FlurrystormCannon: { ''' Fires a chain of snowballs that become faster over time Has a chance to also fire an ice chunk that shatters into shards - 50% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -578,10 +538,10 @@ HalleysInferno: { Tooltip: ''' Fires a burst of intensely concentrated lunar fire jets - Press to zoom out + to rapid-fire Starbursts that inflict [cbuff:CalamityMod/Voidfrost] + Generates Starbursts when hitting enemies, depending on your accuracy Uses gel for ammo - 50% chance to save ammo - 'Halley came sooner than expected' + 'Halley arrived sooner than expected' ''' } @@ -615,7 +575,7 @@ Hellborn: { ''' An ornate firearm created during the Draconic Era by Azafure's finest forgemaster Hold to twirl the gun in your hand, rapidly hitting nearby enemies - Hits with the gun itself add rounds to the gun, up to a max of 8 + Hits with the gun itself add rounds to the gun, up to a max of 12 At the cost of one round, hold to fire a giant energy sphere with potent recoil [c/E1B65F:'Know the grace of a gun forged through beauteous inspiration'] ''' @@ -657,6 +617,7 @@ Infinity: { ''' Fires a twin stream of energy bolts that split Press to fire a barrage of normal bullets + {$CommonItemTooltip.PercentChanceToSaveAmmo} 'They say infinity is neverending, yet you hold it in your hands' ''' } @@ -674,7 +635,7 @@ Kingsbane: { When you stop firing you will release a barrage of auric bullets Auric bullets aggressively home in on enemies and ignore 50 points of defense Constantly consumes ammo while in use - 90% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -698,6 +659,17 @@ LunarianBow: { ''' } +M1Garand: { + DisplayName: M1 Garand + Tooltip: + ''' + Converts bullets into .30-06 rounds which inherit the damage of the converted bullet + Fires 8 bullets before ejecting the rifle's cartridge + Bullets which ricochet off coins can ricochet off cartridges too + 'Mind your thumb' + ''' +} + MagnaCannon: { DisplayName: Magna Cannon Tooltip: @@ -714,7 +686,7 @@ MagnomalyCannon: { ''' Launches a powerful exo rocket to nuke anything and everything Rockets are surrounded by an invisible damaging aura and split into damaging beams on hit - 66% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -841,12 +813,12 @@ OntologicalDespoiler: { DisplayName: Ontological Despoiler Tooltip: ''' - Condenses chargeable pockets of concentrated unreality. to swap modes + Condenses chargeable pockets of concentrated unreality. to swap modes only after firing a charged shot Unstable condensate shots trifurcate and pierce enemies Null condensate shots fire rapidly and home in on enemies At 50% charge or higher, rate of fire significantly increases Fully charged unstable condensate lobs a homing disruption sphere - Fully charged null condensate emits a hitscan null-annihilation beam + Fully charged null condensate emits a hitscan null-annihilation beam that always crits Each mode charges slower when used repeatedly and resets to full speed when swapped 'Rob them of continuity and the laws of physics they hold so dear.' ''' @@ -857,7 +829,7 @@ OnyxChainBlaster: { Tooltip: ''' Fires a spread of bullets and an onyx shard - 50% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -866,7 +838,7 @@ Onyxia: { Tooltip: ''' Fires a storm of bullets and onyx shards - 50% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -887,7 +859,7 @@ OverloadedBlaster: { Overloaded slime pearls deal 60% more damage but no longer pierce Slime pearls bounce off of walls at very high speed Uses gel for ammo - 25% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -897,7 +869,7 @@ P90: { ''' Unleashes a stream of armor-piercing rounds at an incredible rate Armor-piercing rounds ignore 30 defense - 75% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} 'It's a bullet hose' ''' } @@ -923,7 +895,7 @@ Photoviscerator: { Emits a continuous beam of exo radiation that disintegrates everything Press to fire homing exo flares which stick to and incinerate enemies Uses gel for ammo - 95% chance to save ammo + The beam has a {0}% chance to save ammo ''' } @@ -960,7 +932,7 @@ PolarisParrotfish: { ''' Rapidly fires an array of colorful star shots Firing speed increases the closer you are to an enemy - Right click to give the little girl some attention + to give the little girl some attention 'She is a happy girl' ''' } @@ -975,7 +947,7 @@ PridefulHuntersPlanarRipper: { Lightning bolt crits grant a stacking speed boost to the player This stacks up to 20 percent bonus movement speed and acceleration The boost will reset if the player holds a different item - 33% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -984,8 +956,8 @@ PristineFury: { Tooltip: ''' Fires an intense helix of flames that burst into a column of smoke - to disperse flammable crystalline powder - Powder can be ignited, causuing it to explode for extra damage + to disperse a limited supply of flammable crystalline powder that restores over time + Powder can be ignited, causing it to explode for extra damage Both helix flames and other nearby explosions can ignite the powder Uses gel for ammo ''' @@ -993,7 +965,7 @@ PristineFury: { ''' 'I and many others lost everything in this world's darkest hour. I saw a beast descend from the heavens. A hulking cosmic monstrosity that heralded countless angels of death. - My family was torn from me by them, and my people forsake me. Even our supposed protectors did nothing to aid us. + My family was torn from me, my people forsake me. Even our supposed protectors did nothing to aid us. And thus I swore to those I lost that I would do what is right, that my blaze's light would dwarf even that of Zeratros' Sun; That one day, this cruel world would know nothing less than My perfect fury.' ''' @@ -1028,7 +1000,7 @@ Riftburst: { Tooltip: ''' Fires a spread of 5 arrows and emits phantom arrows on enemy hits - 66% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -1047,7 +1019,7 @@ Sandblaster: { ''' Fires sand bullets that explode and slow enemies on hit Uses sand as ammo - 50% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -1055,8 +1027,9 @@ ScorchedEarth: { DisplayName: Scorched Earth Tooltip: ''' - Fires a burst of four fuel-air rockets which explode into cluster bombs - Each burst consumes two rockets each + Fires a burst of four heat seeking missiles that rapidly accelerate after a short delay + All rockets explode into napalm cluster bombs on impact + {$CommonItemTooltip.PercentChanceToSaveAmmo} 'Burns your targets to a fine crisp' ''' } @@ -1076,7 +1049,7 @@ SDFMG: { DisplayName: SDFMG Tooltip: ''' - 50% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} 'It came from the edge of Terraria' ''' } @@ -1122,6 +1095,18 @@ Shadethrower: { ''' } +Shardshocker: { + DisplayName: Shardshocker + Tooltip: + ''' + Fires an electrically charged crystal that travels a short distance before stopping + The crystal will hang in the air and occasionally give off damaging pulses of electricity + Hitting a stopped crystal with a moving one will detonate both in a massive explosion that lets off homing shards + Direct hits with the crystal will create a smaller explosion and stun enemies + 'Plasmaaaaaa!' + ''' +} + Shellshooter: { DisplayName: Shellshooter Tooltip: @@ -1146,6 +1131,16 @@ Shroomer: { Tooltip: Fires bullets and an extremely powerful homing mushroom } +SlagfireDouser: { + DisplayName: Slagfire Douser + Tooltip: + ''' + Lobs armor-penetrating lava in bursts + Armor-penetrating lava ignores 10 points of enemy defense + [c/FF9900:Capable of dousing townsfolk in lava too...] + ''' +} + SlagMagnum: { DisplayName: Slag Magnum Tooltip: Converts musket balls into fossil shards that split into additional shards on impact @@ -1161,7 +1156,7 @@ SomaPrime: { Shred deals 600 DPS per stack and scales with your ranged stats Damage ticks of Shred can critically strike for 3x damage and can supercrit Replaces musket balls with enhanced High Velocity Bullets - 80% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -1178,8 +1173,13 @@ SpectralstormCannon: { DisplayName: Spectralstorm Cannon Tooltip: ''' - Fires a storm of lost souls and flares - 70% chance to save ammo + Fires a barrage of spectral flares that builds up a searing heat in the weapon + While cooling down, heat-seeking phantoms are continuously released + Firing for too long overheats the weapon, leaving it unusable for a short period + However, triggering overheat releases a powerful burst of souls and resets heat + Press to put away the weapon, which preserves its heat + {$CommonItemTooltip.PercentChanceToSaveAmmo} + 'Ectoplasmic blast rated visor mandatory' ''' } @@ -1202,15 +1202,30 @@ Spyker: { Starfleet: { DisplayName: Starfleet - Tooltip: Fires a spread of plasma blasts + Tooltip: + ''' + fires a spread of starshots + fires a concussive short range starburst + Starshots can be accelerated by firing when the starburst goes off + Perfect timing reduces spread and increases damage + Imperfect timing still increases damage, but heavily increases spread + Uses fallen stars, 50% chance to save ammo + 'Etoile, et toi' + ''' } Starmada: { DisplayName: Starmada Tooltip: ''' - Fires a barrage of stars and plasma blasts - 66% chance to save ammo + fires a spread of starshots + fires a concussive short range starburst + Starshots can be accelerated by firing when the starburst goes off + Perfect timing reduces spread, increases damage, and adds a stacking weapon power buff + Imperfect timing still increases damage, but heavily increases spread and reduces weapon power + The weapon power buff strengthens both starshots and the concussive starburst + Uses fallen stars, 50% chance to save ammo + 'Et toi, et moi' ''' } @@ -1223,7 +1238,7 @@ StarSputter: { DisplayName: Star Sputter Tooltip: ''' - Fires a chain of comets + Fires a chain of comets that inflict [cbuff:CalamityMod/AstralInfectionDebuff] Fires a bigger, more powerful comet every four rounds 'Look to the stars for a galaxy far, far away' ''' @@ -1231,7 +1246,7 @@ StarSputter: { StellarCannon: { DisplayName: Stellar Cannon - Tooltip: Launches an explosive astral crystal + Tooltip: Launches an explosive astral crystal that inflicts [cbuff:CalamityMod/AstralInfectionDebuff] } StormSurge: { @@ -1264,17 +1279,14 @@ SuperradiantSlaughterer: { MainInfo: ''' Hold to rev up an elemental buzzsaw that deals close-range damage - Release to fire the buzzsaw to pierce through and lacerate foes - Fired buzzsaws bounce off tiles and return to the player after winding down - When returning, the saws release extra homing bolts depending on the number of enemy and tile hits - Revving up the saws increases their damage and allows them to pierce more enemies + Release to fire the buzzsaw which bounces off tiles, releasing homing bolts when returning depending on hits + Revving up the saw increases its damage and allows it to pierce more enemies ''' AltInfo: ''' - Press to eject a lingering buzzsaw towards the cursor that fires homing bolts - Using this ability rapidly propels you in the direction you are moving - This ability has a {0} second cooldown - During this cooldown, buzzsaws home to the cursor and constantly release homing bolts while returning + Press to eject a lingering buzzsaw towards the cursor on a {0} second cooldown + Double to rapidly propel yourself in the direction you are moving + During the cooldown, buzzsaws home to the cursor and constantly release homing bolts while returning ''' } @@ -1293,6 +1305,7 @@ Svantechnical: { ''' Fires a trinity of energy bolts that split into beams that track your cursor Press to fire a barrage of normal bullets + {$CommonItemTooltip.PercentChanceToSaveAmmo} 'The age old balance of trading damage for frames' ''' } @@ -1305,6 +1318,7 @@ TauCannon: { Charge level one fires a burst of bolts Charge level two fires a beam of energy that quickly fizzles out Charge level three fires a massive laser and creates astral portals around you + Inflicts [cbuff:CalamityMod/AstralInfectionDebuff] 'This weapon is very ethically questionable' ''' } @@ -1316,7 +1330,6 @@ TelluricGlare: { Rapidly fires volleys of arrows Every other arrow is converted into radiant greatarrows which pierce but quicky dissapear after striking Wooden arrows are converted into more powerful greatarrows that deal increased damage - 75% chance to save ammo ''' } @@ -1325,6 +1338,15 @@ TheBallista: { Tooltip: Converts wooden arrows into greatarrows that crush enemy armor and break into shards } +TheBlunderbass: { + DisplayName: The Blunderbass + Tooltip: + ''' + Fires a large crystal that travels a short distance before bursting into homing shards + Direct hits with the crystal stun enemies and increase the amount of shards created + ''' +} + TheHive: { DisplayName: The Hive Tooltip: @@ -1366,7 +1388,7 @@ TheSevensStriker: { Press to consume 1 coin and play a slot machine The quality of the outcome depends on the coin used Press to rapidly fire a barrage of coins - The coin barrage has an 80% chance to save ammo and will not fire platinum coins + The coin barrage has an {0}% chance to save ammo and will not fire platinum coins 'A gun given to a great gunslinger Forged by the arms of a man given no name' ''' @@ -1379,7 +1401,16 @@ TheStorm: { ''' Fires a spread of homing lightning bolts and arrows from the sky Converts wooden arrows into powerful electric beams - 95% chance to save ammo + ''' +} + +ThreadOfEradication: { + DisplayName: Thread of Eradication + Tooltip: + ''' + Charges up [c/ff00ff:God's Bane Doombeam] + Channelling the weapon causes it to charge up [c/ff00ff:Hyperdeath Rift] instead + While charging [c/ff00ff:Hyperdeath Rift], the bow's turning speed is slowed down ''' } @@ -1416,7 +1447,7 @@ Ultima: { Casts a continuous stream of plasma bolts Over time the bolts are replaced with powerful lasers Bolts power up into solid beams as you continue shooting - 90% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } @@ -1426,7 +1457,6 @@ UniversalGenesis: { ''' Fires a spread of bullets from the gun and a flurry of stars to rain down on the cursor Converts musket balls into starcaller shots that summon additional stars on enemy hits - 50% chance to save ammo 'Let the starry sky fall upon your enemies' ''' } @@ -1446,7 +1476,7 @@ Voidragon: { ''' Fires void blasts that explode every other shot Shoots demon flame tentacles alongside every shot - 75% chance to save ammo + Void blasts consume no ammo and bullets have a {0}% chance to save ammo ''' } @@ -1461,7 +1491,7 @@ WildfireBloom: { ''' Charges up to emit a stream of energized flames and pairs of homing wildfire flares Uses gel for ammo - 50% chance to save ammo + {$CommonItemTooltip.PercentChanceToSaveAmmo} ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 923f4de428..8802201e32 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -1,12 +1,3 @@ -AcidicRainBarrel: { - DisplayName: Acidic Rain Barrel - Tooltip: - ''' - Throws a rolling barrel that explodes on wall collision - Stealth strikes make it rain on collision - ''' -} - AdamantiteThrowingAxe: { DisplayName: Adamantite Throwing Axe Tooltip: Stealth strikes ignore gravity and rain down lightning on enemy hits @@ -48,6 +39,7 @@ AuroradicalThrow: { Launches a star that splits after a short period of time Split stars home in on nearby enemies after a few seconds Stealth strikes summon a meteor upon enemy impact + Inflicts [cbuff:CalamityMod/AstralInfectionDebuff] ''' } @@ -74,8 +66,9 @@ BlazingStar: { DisplayName: Blazing Star Tooltip: ''' - Tosses up to 3 red hot returning glaives - Stealth strikes throw three glaives with infinite piercing + Tosses a red-hot ricocheting glaive + After bouncing off of tiles, the glaive can re-hit the same enemy + Stealth strikes shred the first enemy they hit and provide rings of high-knockback orbiting glaives ''' } @@ -85,8 +78,9 @@ BloodsoakedCrasher: { ''' Throws a bloody axe that is affected by gravity and can bounce twice The axe speeds up over time, but will slow down upon hitting an enemy - Heals on enemy hits - Stealth strikes spawn homing blood on enemy hits + Spews blood orbs upon enemy hits + Picking up these blood orbs reduces the duration of [cbuff:PotionSickness] + Stealth strikes spawn homing blood bolts on hit ''' } @@ -145,7 +139,7 @@ Cinquedea: { CobaltKunai: { DisplayName: Cobalt Kunai - Tooltip: Stealth strikes fire three homing cobalt energy bolts + Tooltip: Stealth strikes fire four homing cobalt energy bolts } ConsecratedWater: { @@ -203,7 +197,7 @@ CrushsawCrasher: { Tooltip: ''' Throws bouncing axes - Stealth strikes throw five at once + Stealth strikes throw six at once ''' GFBFirstWords: ''' @@ -284,8 +278,8 @@ DeepWounder: { DisplayName: Deep Wounder Tooltip: ''' - Throws an abyssal hatchet that inflicts Armor Crunch and Crush Depth to the enemies it hits - Stealth strikes cause the hatchet to stick to struck enemies, causing Heavy Bleeding and spawning a burst of water projectiles + Throws an abyssal hatchet that inflicts Heavy Bleeding and Crush Depth to the enemies it hits + Stealth strikes cause the hatchet to stick to struck enemies, releasing a barrage of water projectiles Water projectiles launch at the closest enemy after a brief delay ''' } @@ -309,6 +303,15 @@ DesecratedWater: { ''' } +DimensionTearingDisk: { + DisplayName: Dimension-Tearing Disk + Tooltip: + ''' + Throws a disk that tears space in the direction of the nearest enemy + Stealth strikes stick to enemies and unleash [c/ff00ff:God's Bane Doombeam Array] + ''' +} + DoomsdayDevice: { DisplayName: Doomsday Device Tooltip: @@ -391,15 +394,6 @@ Equanimity: { ''' } -Eradicator: { - DisplayName: Eradicator - Tooltip: - ''' - Throws a disk that fires nebula lasers at nearby enemies - Stealth strikes stick to enemies and unleash a barrage of lasers in all directions - ''' -} - ExecutionersBlade: { DisplayName: Executioner's Blade Tooltip: @@ -415,7 +409,7 @@ Exorcism: { ''' Throws a gigantic hallowed cross to the heavens, which will fall at your cursor a moment later Enemies hit as it falls are impaled and repeatedly seared with holy light - Upon experation a cross shaped explosion is created + Upon expiration a cross shaped explosion is created Stealth strikes twirl and throw the cross, ending in a stronger explosion at your cursor ''' } @@ -457,7 +451,6 @@ FrostcrushValari: { ''' Fires a long ranged frosty boomerang that chips off homing icicles on hit Stealth strikes throw a boomerang which follows the cursor - This boomerang creates a freezing blast and chips off homing icicles on every hit ''' } @@ -466,7 +459,7 @@ FrostyFlare: { Tooltip: ''' Throw a flare that sticks to enemies and rains a hailstorm on them - Stealth strikes trail snowflakes and summon phantom copies instead of ice shards + Stealth strikes summon phantom copies instead of ice shards 'Do not insert in flare gun' ''' } @@ -512,8 +505,8 @@ Glaive: { DisplayName: Glaive Tooltip: ''' - Tosses up to 3 sharp returning glaives - Stealth strikes are super fast and pierce infinitely + Tosses a ricocheting glaive + Stealth strikes shred the first enemy they hit and provide a ring of high-knockback orbiting glaives ''' } @@ -564,7 +557,8 @@ HeavenfallenStardisk: { ''' Throws a stardisk upwards which then launches itself towards your mouse cursor Explodes into a star of astral bolts on hit - Stealth strikes throw three disks that rain astral energy bolts from the sky + Stealth strikes rain astral energy bolts from the sky + Inflicts [cbuff:CalamityMod/AstralInfectionDebuff] ''' } @@ -608,8 +602,8 @@ InfernalKris: { DisplayName: Infernal Kris Tooltip: ''' - Throws a burning dagger that starts spinning after travelling a short distance, inflicting additional damage while spinning - Stealth strikes cause the dagger to be engulfed in flames, exploding on contact with walls and enemies + Rapidly throws burning daggers + Stealth strikes engulf the dagger in flames, exploding when hitting walls and enemies ''' } @@ -676,6 +670,7 @@ LeonidProgenitor: { Throws a bombshell that explodes, summoning a meteor to impact the site Press to throw a spread of gravity affected comets that explode, leaving behind a star Stealth strikes lob a bombshell that additionally splits into comets on hit + Inflicts [cbuff:CalamityMod/AstralInfectionDebuff] ''' } @@ -685,7 +680,7 @@ LeviathanTeeth: { ''' Rapidly throws a spread of teeth that stick into enemies After sticking to an enemy, the teeth will gouge through them and shoot out the other side - Stealth strikes throw a single piercing tooth that creates a jawline of teeth to maul your foes + Stealth strikes create a clamping jaw of teeth to maul your foes ''' } @@ -821,16 +816,6 @@ NastyCholla: { ''' } -NightsGaze: { - DisplayName: Night's Gaze - Tooltip: - ''' - Strike your foes with this spear of the night - Throws a spear that shatters when it hits an enemy - Stealth strikes cause the spear to summon homing stars as it flies - ''' -} - OrichalcumSpikedGemstone: { DisplayName: Orichalcum Spiked Gemstone Tooltip: Stealth strikes last longer and summon petals on enemy hits @@ -890,7 +875,7 @@ RadiantStar: { DisplayName: Radiant Star Tooltip: ''' - Throws daggers that explode and split after a while + Throws daggers that explode and split after a while and inflict [cbuff:CalamityMod/AstralInfectionDebuff] Stealth strikes split more with a devastating explosion that sucks enemies in ''' } @@ -927,7 +912,7 @@ RegulusRiot: { DisplayName: Regulus Riot Tooltip: ''' - Fires a swift homing disk + Fires a swift homing disk that inflicts [cbuff:CalamityMod/AstralInfectionDebuff] Stealth strikes explode into energy stars ''' } @@ -953,7 +938,7 @@ SamsaraSlicer: { Tooltip: ''' Throws a disk that has a chance to generate several disks if enemies are near it - Stealth strikes travel slower and are rapidly orbited by the smaller disks + Stealth strikes shred enemies and are rapidly orbited by the smaller disks ''' } @@ -961,8 +946,9 @@ SandDollar: { DisplayName: Sand Dollar Tooltip: ''' - Throws up to 2 returning sand dollars - Stealth strikes throw 2 long ranged sand dollars that explode into coral shards on enemy hits + Throws gliding sand dollars which can pierce enemies or bounce off floors + After bouncing, sand dollars lose their pierce but split into damaging shards on impact + Stealth strikes linger in place after bouncing, creating a small sandstorm around them ''' } @@ -1024,20 +1010,6 @@ SealedSingularity: { ''' } -SearedPan: { - DisplayName: Seared Pan - Tooltip: - ''' - Fires a frying pan at high velocity - Enemy hits summon fireballs that linger around the target - Landing three consecutive hits will launch a golden pan on the next throw - Golden pans cause all fireballs to aggressively home in on their target on hit - Stealth strikes act similar to golden pans but also explode into golden sparks - Stealth strikes also summon additional fireballs on hit - [c/842593:'dAMaGe iS rAthEr cOnSisTeNT'] - ''' -} - Seraphim: { DisplayName: Seraphim Tooltip: @@ -1086,16 +1058,6 @@ SkyfinBombers: { ''' } -SkyStabber: { - DisplayName: Sky Stabber - Tooltip: - ''' - Throws up to 4 gravity-defying spiky balls - Stealth strikes make the balls rain feathers onto enemies when they hit - Press to delete all existing spiky balls - ''' -} - SlickCane: { DisplayName: Slick Cane Tooltip: @@ -1175,7 +1137,7 @@ StellarKnife: { DisplayName: Stellar Knife Tooltip: ''' - Throws knives that stop middair and then home into enemies + Throws knives that stop middair and then home into enemies, inflicting [cbuff:CalamityMod/AstralInfectionDebuff] Stealth strikes throw a volley of 10 knives in a spread 'ZA WARUDO' ''' @@ -1371,6 +1333,19 @@ Valediction: { ''' } +Vega: { + DisplayName: Vega + Tooltip: + ''' + Throws a spear that shatters into star fragments on impact and generates Starbursts + Stealth strikes conjure an image of Lyra to deal immense damage in an area + to consume 20 Starbursts and immediately perform a stealth strike, regardless of your current Stealth + This strike calls all star fragments to attack the damaged foe and inflicts [cbuff:CalamityMod/Voidfrost] + Consuming Starbursts with Vega allows using stealth for 10 seconds, even without rogue armor + 'The final song of a misunderstood genius... or just a madman' + ''' +} + WaveSkipper: { DisplayName: Wave Skipper Tooltip: @@ -1396,7 +1371,7 @@ Whitewater: { Throws a flask of magic white water at the cursor that glows after a short while Flasks that hit enemies while glowing release four water spears that converge back on the flask's position If the flask hits an enemy or gets too far, it will return to the owner - Stealth strikes create eight water spears and summon a swirling whitewater vortex that heals players and knocks back enemies + Stealth strikes create six water spears and summon a swirling whitewater vortex that heals players and knocks back enemies Allies that enter the vortex will heal for twice as long ''' } @@ -1414,7 +1389,18 @@ WulfrumKnife: { DisplayName: Wulfrum Knife Tooltip: ''' - Fires wulfrum knives in bursts of 3 + Fires wulfrum knives in bursts of 3 that stick in enemies Stealth strikes make the knife fly further and hit several times at once + to magnetize all stuck knives back to you, restoring stealth + Returning knives also temporarily allows using stealth strikes without rogue armor + ''' +} + +Pumpkaboom: { + DisplayName: Pumpkaboom + Tooltip: + ''' + Throws a pumpkin which sticks to enemies and explodes after a delay + Stealth strikes throw larger pumpkins which pull enemies in before releasing a larger explosion ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 50e9c95edd..cb427c4298 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -2,6 +2,7 @@ AbandonedSlimeStaff: { DisplayName: Abandoned Slime Staff Tooltip: ''' + Summons an astral slime that inflicts [cbuff:CalamityMod/AstralInfectionDebuff] Consumes all of the remaining minion slots on use Must be used from the hotbar Increased power and size based on the number of minion slots used @@ -10,6 +11,16 @@ AbandonedSlimeStaff: { ''' } +AmphibiansGuitar: { + DisplayName: Amphibian's Guitar + Tooltip: + ''' + Summons up to 8 guitars that spin around you and shoot notes at the target, occasionally firing spread shots + If all 8 guitars are present, some notes become empowered, dealing extra damage + 'I'll show you suffering!' + ''' +} + AncientIceChunk: { DisplayName: Ancient Ice Chunk Tooltip: @@ -51,7 +62,7 @@ AtlasMunitionsBeacon: { [c/F27049:If an enemy is in close proximity, it will enter Overdrive] [c/F27049:When in Overdrive the cannon uses its full power to bring down any foe] [c/F27049:While in Overdrive, the cannon will build up heat, eventually overheating] - [c/69F0DC:Press right click while holding this item to pick up the cannon and use it yourself] + [c/69F0DC:Press while holding this item to pick up the cannon and use it yourself] [c/69F0DC:When held, the cannon will always be in Overdrive] [c/69F0DC:If the cannon overheats while you hold it, you will be forced to drop it] [c/9AA4AE:Pressing allows you to drop it manually] @@ -91,7 +102,7 @@ BrittleStarStaff: { ''' Summons a small brittle starfish that will dash through enemies until it shatters Starfish will quickly regenerate after shattering - Holding right click will swap starfish between dashing and circling you + Holding will swap starfish between dashing and circling you When the starfish are circling, each one provides you with 4 defense ''' } @@ -169,7 +180,7 @@ Cnidarian: { Tooltip: ''' Fishes up an electric jellyfish - Periodically sends out sparks to electrocute nearby enemies. + Periodically sends out sparks to electrocute nearby enemies [c/5C95A1:'From looking at their less sapient brethren, the Old Kingdom's inhabitants adapted tools and weapons designed for underwater efficiency.] [c/5C95A1:The electric properties of ghost bells remain useful even after death, having been commonly used as conduits.'] ''' @@ -292,7 +303,8 @@ DragonbloodDisgorger: { Tooltip: ''' Summons a skeletal dragon and her two children - Baby spits passively heal the player + Baby spits burst into blood orbs upon hitting an enemy + Picking up these blood orbs reduces the duration of [cbuff:PotionSickness] Requires 6 minion slots to be summoned There can only be one family at a time ''' @@ -312,6 +324,11 @@ EnchantedConch: { Tooltip: Summons a hermit crab to fight for you } +EnchantedKnifeStaff: { + DisplayName: Enchanted Knife Staff + Tooltip: Summons an Enchanted Knife to fight for you +} + Endogenesis: { DisplayName: Endogenesis Tooltip: @@ -363,7 +380,7 @@ FlamsteedRing: { Tooltip: ''' Summons a colossal controllable mech - Right click to display the mech's control panel + to display the mech's control panel The panel has 3 configurations, selected using the brackets on the edges of the UI Each bracket powers 2 out of 3 possible functions, represented by the circular icons The bottom left icon miniaturizes the mech to the size of a player, but weakens its weapons @@ -434,7 +451,7 @@ GlacialEmbrace: { For each minion slot used, you will gain an additional orbiting shield spike These spikes accelerate rapidly towards a nearby enemy to inflict heavy damage They take some time to regenerate after launching themselves at the target, however - On right click, summons a duplicate ring around the targeted enemy, which slowly converges before exploding + On , summons a duplicate ring around the targeted enemy, which slowly converges before exploding ''' } @@ -484,7 +501,9 @@ IgneousExaltation: { Tooltip: ''' Summons an Igneous blade that orbits around you - Right click to launch all blades towards the cursor + When your minion slots are full, again to launch all blades towards the cursor + This ability has a two-second cooldown that requires holding this item + Shift- this item in your inventory to change the rotation direction ''' } @@ -588,9 +607,10 @@ Perdition: { DisplayName: Perdition Tooltip: ''' + {$CommonItemTooltip.Sentry} Summons a beacon at the position of the mouse - When a target is manually selected via right click it releases torrents of souls from below onto the target - Requires 5 minion slots to summon and only one beacon may exist at a time + When a target is manually selected via it releases torrents of souls from below onto the target + Requires one sentry slot to summon, and only one beacon may exist at a time ''' } @@ -657,10 +677,10 @@ SarosPossession: { DisplayName: Saros Possession Tooltip: ''' - Summons a radiant aura that gives absolute control of light itself - The aura will annihilate enemies with orbs of radiance - There can only be one aura at a time - Requires 8 minion slots + Summons a radiant aura harnessing the power of primordial light + Repeated summons increase the power of the aura + with full summon slots to channel an eclipse beam that decays over time + This beam recharges when not in use ''' } @@ -669,8 +689,8 @@ ScabRipper: { Tooltip: Summons a baby blood crawler to protect you } -SeashineSword: { - DisplayName: Seashine Sword +SeashineHilt: { + DisplayName: Seashine Hilt Tooltip: ''' Summons a brilliant sea prism blade to slice your enemies @@ -693,9 +713,12 @@ Sirius: { DisplayName: Sirius Tooltip: ''' - Summons the brightest star in the night sky to shine upon your foes - There can only be one star at a time - Requires 6 minion slots + Summons the brightest star in the sky, Sirius, to protect you + Continue summoning to complete Canis Major + Repeated summons increase its power greatly, even after the constellation is complete + Sirius passively generates Starbursts when targeting enemies + When Starbursts are full, Sirius consumes them to launch a powerful piercing quasar that inflicts [cbuff:CalamityMod/Voidfrost] + 'A guide to a dream never realized' ''' } @@ -743,14 +766,9 @@ StaffOfNecrosteocytes: { ''' } -StaffoftheMechworm: { - DisplayName: Staff of the Mechworm - Tooltip: Summons an aerial mechworm to fight for you -} - StarspawnHelixStaff: { DisplayName: Starspawn Helix Staff - Tooltip: Summons astral probes to protect you + Tooltip: Summons astral probes that inflict [cbuff:CalamityMod/AstralInfectionDebuff] } StellarTorusStaff: { @@ -768,7 +786,7 @@ SunSpiritStaff: { Tooltip: ''' Summons a solar spirit to protect you - There can only be one spirit at a time + Repeated summons increase its power ''' } @@ -827,8 +845,8 @@ VengefulSunStaff: { DisplayName: Vengeful Sun Staff Tooltip: ''' - Summons a vengeful solar spirit to protect you - There can only be one spirit at a time + Summons an eclipse spirit to protect you + Repeated summons increase its power ''' } @@ -853,7 +871,16 @@ ViralSprout: { ViridVanguard: { DisplayName: Virid Vanguard - Tooltip: Summons a circular formation of blades that slice nearby enemies to pieces + Tooltip: + ''' + Alternates between summoning axes and swords, both laced with a powerful poison + Axes orbit the player, dealing high damage at a close range + Swords chase down enemies with extreme precision, tearing them to shreds + All weapons inflict Sage Poison, which becomes more powerful the more weapons are summoned + When all minion slots are full, again to spin up a flurry of slashes aimed at your cursor + This ability has a five-second cooldown that requires holding this item + Shift- this item in your inventory to change the rotation direction + ''' } VoidConcentrationStaff: { @@ -864,7 +891,19 @@ VoidConcentrationStaff: { Minion damage is increased by 5% while the aura is active Requires three minion slots to use There can only be one aura at a time - Right click to launch a black hole that grows in size + to launch a black hole that grows in size + ''' +} + +VoidEaterMarionette: { + DisplayName: Void Eater Marionette + Tooltip: + ''' + Contains the power to control a miniature Devourer + Repeated summons increase the length and power of the Devourer + The Devourer attacks with [c/ff00ff:Divinity Devourer], [c/ff00ff:Faith Incinerator] and [c/ff00ff:Ultracosmic Maelstrom] + Can play fetch with dropped items + Shift- this item in your inventory when the Devourer has been spawned to prioritize fetching ''' } @@ -891,7 +930,7 @@ WulfrumController: { Tooltip: ''' Summons a wulfrum droid to fight for you - Hold right click while holding the remote to switch all of your drones into supercharge mode + Hold while holding the remote to switch all of your drones between regular and supercharge mode Supercharged droids will stop attacking and focus wulfrum energy onto you Supercharged droids provide +0.5 HP/s life regen and 3 defense per droid Can also be used to heal other players by keeping your mouse cursor close enough to them @@ -906,31 +945,3 @@ YharonsKindleStaff: { Requires 5 minion slots to use ''' } - -FlarebatStaff: { - DisplayName: Flarebat Staff - Tooltip: - ''' - Summons a bat construct of pure fire to fight for you - Swoops towards foes with great haste - ''' -} - -FrostbatStaff: { - DisplayName: Frostbat Staff - Tooltip: - ''' - Summons a bat construct of pure ice to fight for you - Swoops towards foes with slow and precise maneuvers - ''' -} - -AmphibiansGuitar: { - DisplayName: Amphibian's Guitar - Tooltip: - ''' - Summons up to 8 guitars that spin around you and shoot notes at the target, ocasianally firing spread shots - If all 8 guitars are present some notes become empowered dealing extra damage - "I'll show you suffering!" - ''' -} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Typeless.hjson index cad73bc9d5..08fb7476d2 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Typeless.hjson @@ -7,6 +7,24 @@ Aestheticus: { ''' } +ClaretCannon: { + DisplayName: Claret Cannon + Tooltip: + ''' + Fires a hypercondensed claret round + The round explodes upon striking an enemy and releases blood orbs + The explosion shreds enemies, inflicting [cbuff:CalamityMod/Laceration] and dramatically reducing their defense + Picking up the blood orbs will reduce [cbuff:PotionSickness] when possible + If you do not have [cbuff:PotionSickness], your natural regeneration will be enhanced + Can only fire once every 10 seconds + ''' +} + +ColdheartIcicle: { + DisplayName: Coldheart Icicle + Tooltip: "'N(ice) work'" +} + EyeofMagnus: { DisplayName: Eye of Magnus Tooltip: @@ -57,14 +75,14 @@ StarStruckWater: { Tooltip: Spreads the Astral Infection to some blocks } -YanmeisKnife: { - DisplayName: Yanmei's Knife +StratusSphere: { + DisplayName: Stratus Sphere Tooltip: ''' - Enemies you hit are crippled - Hits will also give you {0}% increased movement speed and damage for {1} seconds - 'A knife from an unknown world - An owner whose heart is pure and free of taint - A heart of iron and valor' + Launches a singularity which exerts influence on all entities in a large area around it + Influenced players gain Starbursts over time, while enemies instead take damage + to cause Starbursts to form a barrier, causing you to lose Starbursts instead of health + Launching the singularity deactivates the barrier, and creating a barrier deactivates the singularity + 'Channeling souls into stars, an inane concept' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson index 8f12f250f0..9235ed6df0 100644 --- a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson +++ b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson @@ -7,9 +7,11 @@ AscendantInsigniaHotKey.DisplayName: Ascendant Insignia Flight BoosterDash.DisplayName: Booster Dash DashDoubleTapOverride.DisplayName: Dash Double Tap Override ExoChairSlowDown.DisplayName: Exo Chair Slow Down -GodSlayerDash.DisplayName: God Slayer Dash +GodSlayerDash.DisplayName: Dimensional Drive GravistarSabatonHotkey.DisplayName: Interstellar Stompers Slam NormalityRelocator.DisplayName: Normality Relocator RageMode.DisplayName: Rage Mode SpectralVeilTeleport.DisplayName: Spectral Veil Teleport TransformerHotKey.DisplayName: Transformer Hot Key +GravitySwapOverride.DisplayName: Gravity Swap Override +ExpandDebuffInfo.DisplayName: See Debuff Information diff --git a/Localization/en-US/Mods.CalamityMod.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Misc.hjson index ff133415d5..9390417a75 100644 --- a/Localization/en-US/Mods.CalamityMod.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Misc.hjson @@ -1,21 +1,18 @@ -// Recipe Groups +# Recipe Groups +# {$LegacyMisc.37} is the vanilla localization used in recipe groups, that reads "Any" in English. RecipeGroup: { - HardmodeAnvil: Any Hardmode Anvil - HardmodeForge: Any Hardmode Forge - AnyLargeGem: Any Large Gem - AnyFood: Any Food Item - AnyEvilBar: Any Evil Bar - AnyEvilPowder: Any Evil Powder + HardmodeAnvil: "{$LegacyMisc.37} Hardmode Anvil" + HardmodeForge: "{$LegacyMisc.37} Hardmode Forge" + AnyFood: "{$LegacyMisc.37} Food Item" + AnyEvilBar: "{$LegacyMisc.37} Evil Bar" Boss2Material: Shadow Scale or Tissue Sample CursedFlameIchor: Cursed Flame or Ichor - AnyEvilWater: Any Evil Water - AnyEvilFlask: Any Evil Flask - AnyEvilBlock: Any Evil Block - AnyGoodBlock: Any Good Block - LunarPickaxe: Any Lunar Pickaxe - LunarHamaxe: Any Lunar Hamaxe - AnyQuiver: Any Quiver - AnyWings: Any Wings + AnyEvilWater: "{$LegacyMisc.37} Evil Water" + AnyEvilBlock: "{$LegacyMisc.37} Evil Block" + AnyGoodBlock: "{$LegacyMisc.37} Good Block" + LunarPickaxe: "{$LegacyMisc.37} Lunar Pickaxe" + LunarHamaxe: "{$LegacyMisc.37} Lunar Hamaxe" + AnyQuiver: "{$LegacyMisc.37} Quiver" } // Status @@ -42,7 +39,9 @@ Tier3KnowledgeTooltip: The Jungle schematic must be deciphered first Tier4KnowledgeTooltip: The Underworld schematic must be deciphered first Tier5KnowledgeTooltip: The Ice biome schematic must be deciphered first // Other CombatText uses and Item Messages -ShiftToExpand: Hold SHIFT to see an expanded description +ShiftToExpand: Hold Shift to see an expanded description +AltExpand: Hold {0} to see buff information +AltExpandUnset: Set a keybind to see debuff information LearnedSchematic: You learned how to create new things! CragmawVibeCheck: Vibe check. AutocannonHot: OUCH! HOT! @@ -60,6 +59,7 @@ SevensDoubles: Doubles! SevensTriples: Triples! StylishHammerHit: Stylish! GenericConsumedText: "[c/8A8A8A:You have already consumed this item]" +CelestialOnionText: You have already consumed a Celestial Onion. Consuming another would distort you. SanguineTangerineText: You have already consumed a Sanguine Tangerine. Eating any more would make your blood too thick to flow. MiracleFruitText: You have already consumed a Miracle Fruit. It would take a miracle to put you back together if you ate another. TaintedCloudberryText: You have already consumed a Tainted Cloudberry. Your body would become dust if you ate more than one. @@ -69,6 +69,7 @@ EtherealCoreText: You have already used an Ethereal Core. Your brain would escap PhantomHeartText: You have already used a Phantom Heart. The voices are telling you it's a bad idea to use it again. SulphurSwitchLeft: The Sulphurous Sea is now on the left side of the world. SulphurSwitchRight: The Sulphurous Sea is now on the right side of the world. +Polaris0: Too much love... Polaris1: You give Polaris belly rubs Polaris2: You give Polaris a small treat Polaris3: You tell Polaris she's a good girl @@ -78,8 +79,47 @@ Empress1: A fine day for mana consumption. Empress2: That's quite enough mana... Empress3: OH GREAT HEAVENS! Empress4: A -// Point Blank -PointBlank: Does extra damage to enemies shot at point-blank range +SwineSecret0: Hey +SwineSecret1: You know, swine like us tend to keep our secrets. +SwineSecret2: I once drank a gallon of molten pig iron. +SwineSecret3: Pay me 10 Ozzacoins and I'll hack in some Miracle Matter for ya, c'mon trust me! +SwineSecret4: I've heard tales of a palace somewhere... +SwineSecret5: Swine. +SwineSecret6: There once was a duke who was old, he sat on a throne made of gold, he ate up a treat, gave his kids spoiled meat, and sang tales of great swine never told. +SwineSecret7: WAIT WAIT A GOLDEN CRITTER JUST SPAWNE- aww you missed it... +SwineSecret8: Fishrons? Who calls them that? +SwineSecret9: Why the hell is everything always blowing up?! You're gonna start a fire you know, and I'm not a fan of flames! +SwineSecret10: HELP ME +SwineSecret11: Saying that someone 'eats babies' is stereotypically evil, but I'm a good guy and I eat babies! I mean surely it's not THAT bad. People who don't eat babies are just wusses. +SwineSecret12: Phalostion ale bonei wha treaites gon bardo galan ale gorve frus frum galibon! +SwineSecret13: My soul is made of jade, it's unbreakable! Just like the palace. You should go there sometime. +SwineSecret14: CAAAAAAARRRRLLLL! You must finish your work Carl. +SwineSecret15: Before gods quarreled or stars wept, it was the Old Duke's hunger that tore the first wound in the deep. +SwineSecret16: When the Third Moon drowned, the Old Duke wept salt into the jade chalice, and the coral gates first bled. +SwineSecret17: The Old Duke's hunger was not for flesh, but for the silence between tides that he called the Eel Hour. +SwineSecret18: The jade palace does not sink, it re-aligns beneath the fins of royal shame. +SwineSecret19: The duke never died. He just changed tides. +SwineSecret20: The Old Duke struck the reefclock thrice, and time drowned in brine-glass. Since then, no hour has been true. +SwineSecret21: There were once seven Duke-Born. then there were six, then there were five, then there were four, then there were three, then there were two, then there was one... +SwineSecret22: No one built the jade palace, the world simply uncoiled its seventh spine. +SwineSecret23: When the true fishron arises, the glorious jade palace shall rise once more from the sea and the ocean will kneel. +SwineSecret24: What mortals call the Old Duke is a mere echo of the pristine swine, the sovereign who ruled the sulphuric seas. +SwineSecret25: Gods speak in radiance. But the Old Duke? He chewed on their syllables and spat out storms. +SwineSecret26: Those who enter the Old Duke's stomach will learn what it means to be truly erased from samsara. +SwineSecret27: The great jade swine once whispered into Polterghast's ear, and that is why the moon forgot its face. +SwineSecret28: They say the Old Duke had no lungs. That's wrong, he had five. +SwineSecret29: The palace still sinks. It has not stopped sinking since the first sin. +SwineSecret30: The village people saw the fishron trade his draconic roar for silence. It was louder this way. +SwineSecret31: @everyone Please do not announce to the sever when you are going to fight Old Duke. This has been a recurring issue... +SwineSecret32: No, I have never played Undertale. +SwineSecret33: These sprites look like they were drawn by a four-year-old with the talents of Pablo Picasso in his prime. Which is what I would have said if I liked the sprites. Which I do. Not. +SwineSecret34: Who are you dressed as... your OC? That's cringe. +SwineSecret35: Watch out for Polymorphine, that stuff sucks. Trust me I know. +SwineSecret36: Many say to keep the greatest swine secret on the down low. I disagree, We cannot shh it. +SwineSecret37: Let me know when it's 7 PM, I've got to tweak something before some poor soul falls off of it! +SwineSecret38: Thank Xeroc I don't have any of that 'Pathfinding' garbage, whatever the hell that is. +SwineSecret39: If you think the Sulphur Sea smells bad, you're not close enough to me! +SwineSecret40: Did you know there's 40 of these damn things? // Charge Charge: Current Charge: {0}% //GFB Rogue Keys @@ -87,3 +127,4 @@ GFBRogueUppercase: Rogue GFBRougeUppercase: Rouge GFBRogueLowercase: rogue GFBRougeLowercase: rouge +HotkeyNotBound: "[None]" diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index 9083290ac3..22f3ea08cd 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -2,6 +2,8 @@ BabyCannonballJellyfish.DisplayName: Baby Cannonball Jellyfish Bloatfish.DisplayName: Bloatfish BobbitWormHead.DisplayName: Bobbit Worm BoxJellyfish.DisplayName: Box Jellyfish +Burrower.DisplayName: Burrower +BurrowerHitbox.DisplayName: Burrower CannonballJellyfish.DisplayName: Cannonball Jellyfish ChaoticPuffer.DisplayName: Chaotic Puffer ColossalSquid.DisplayName: Colossal Squid @@ -144,10 +146,8 @@ AquaticAberration.DisplayName: Aquatic Aberration Leviathan.DisplayName: The Leviathan LeviathanStart.DisplayName: ??? AeroSlime.DisplayName: Aero Slime -ArmoredDiggerHead.DisplayName: Armored Digger MechanizedSerpent: Mechanized Serpent AuroraSpirit.DisplayName: Aurora Spirit -BloodlettingServant.DisplayName: Bloodletting Servant BloomSlime.DisplayName: Bloom Slime Bohldohr.DisplayName: Bohldohr BucketZombie.DisplayName: "{$NPCName.Zombie}" @@ -168,14 +168,11 @@ CryoSlime.DisplayName: Cryo Slime EbonianBlightSlime.DisplayName: Ebonian Blight Slime Eidolist.DisplayName: Eidolist FearlessGoldfishWarrior.DisplayName: Fearless Goldfish Warrior -Foveanator.DisplayName: Foveanator Frogfish.DisplayName: Frogfish -Horse.DisplayName: Earth Elemental +EarthElemental.DisplayName: Earth Elemental IceClasper.DisplayName: Ice Clasper ImpiousImmolator.DisplayName: Impious Immolator -KingSlimeJewelEmerald.DisplayName: Emerald Jewel KingSlimeJewelRuby.DisplayName: Ruby Jewel -KingSlimeJewelSapphire.DisplayName: Sapphire Jewel LavaSlimeNoLavaDrop.DisplayName: Lava Slime MantisShrimp.DisplayName: Mantis Shrimp OverloadedSoldier.DisplayName: Overloaded Soldier @@ -189,8 +186,8 @@ Rotdog.DisplayName: Rotdog ScornEater.DisplayName: Scorn Eater ShockstormShuttle.DisplayName: Shockstorm Shuttle Shroomble.DisplayName: Shroomble -SkeletronPrime2.DisplayName: Skeletron Prime Stormlion.DisplayName: Stormlion +StormlionSentry.DisplayName: Stormlion Sentry Sunskater.DisplayName: Sunskater SuperDummyNPC.DisplayName: Super Dummy WildBumblefuck.DisplayName: Draconic Swarmer @@ -265,6 +262,7 @@ AlphaSeaMinnow.DisplayName: Alpha Sea Minnow AlphaSeaMinnowGold.DisplayName: Gold Alpha Sea Minnow MinnowPrime: Minnow Prime BabyGhostBell.DisplayName: Baby Ghost Bell +CarrionSwallower.DisplayName: Carrion Swallower Clam.DisplayName: Clam EutrophicRay.DisplayName: Eutrophic Ray FesteringRemains.DisplayName: Festering Remains @@ -272,29 +270,45 @@ GhostBell.DisplayName: Ghost Bell GiantClam.DisplayName: Giant Clam Clamitas: Clamitas SupremeClamitas: Supreme Clamitas +GildedAxolotl.DisplayName: Gilded Axolotl +GoldBabyGhostBell: Gold Baby Ghost Bell +GoldPolypPanasea: Gold Polyp Panasea +GoldPrismaticGuppy: Gold Prismatic Guppy HauntedChum.DisplayName: Haunted Chum Jellyghoul.DisplayName: Jellyghoul KelpieSeadragon.DisplayName: Kelpie Seadragon +LazarusLampfish.DisplayName: Lazarus Lampfish +Leerslug.DisplayName: Leerslug LostShoal.DisplayName: Lost Shoal PearlpodBlack.DisplayName: Pearlpod -PearlpodGold.DisplayName: Gold Pearlpod PearlpodPink.DisplayName: Pearlpod PearlpodWhite.DisplayName: Pearlpod +PodobooKoi.DisplayName: Podoboo Koi PolypPanasea.DisplayName: Polyp Panasea +Polyperil.DisplayName: Polyperil PrismBack.DisplayName: Prism-Back Probesnout.DisplayName: Probesnout -ProbesnoutGold.DisplayName: Probesnout Gold +ProbesnoutGold.DisplayName: Gold Probesnout +PrismaticGuppy.DisplayName: Prismatic Guppy +RadiantBabyGhostBell: Radiant Baby Ghost Bell +RadiantPolypPanasea: Radiant Polyp Panasea +RadiantPrismaticGuppy: Radiant Prismatic Guppy +RadiantSlugbun: Radiant Slugbun SandProwler.DisplayName: Sand Prowler SandProwlerNested.DisplayName: Sand Prowler +Scavenger.DisplayName: Scavenger SeaFloaty.DisplayName: Sea Floaty SeaMinnow.DisplayName: Sea Minnow SeaMinnowGold.DisplayName: Gold Sea Minnow +Searslug.DisplayName: Searslug Sharkoon.DisplayName: Sharkoon +Slugbun.DisplayName: Slugbun +Steampod.DisplayName: Steampod BrimstoneHeart.DisplayName: Brimstone Heart SepulcherHead.DisplayName: Sepulcher SoulSeekerSupreme.DisplayName: Soul Seeker SupremeCalamitas.DisplayName: Supreme Witch, Calamitas -SupremeCirrus: Supreme Alchemist, Cirrus +SupremePermafrost: Supreme Ultramage, Permafrost SupremeCataclysm.DisplayName: Cataclysm SupremeCatastrophe.DisplayName: Catastrophe Yharon.DisplayName: Yharon, Dragon of Rebirth @@ -381,7 +395,6 @@ Bandit: { Night1: Hm, the stars are too bright tonight. Makes sneaking around a little more difficult. Night2: You think those stars that fall occasionally would make good throwing weapons? BrimstoneWitch: Hey, hey, has {0} seriously moved in here with us? Why??? - DrunkPrincess: I learned never to steal {0}'s drinks. She doesn't appreciate me right now, so I'll go back to hiding. Merchant: Don't tell {0}, but I took some of his stuff and replaced it with Angel Statues. NurseArmsDealer: Don't tell {0} that I was responsible for {1}'s injuries. NamedLaura: The nice thing about maps is I can track anything that has fallen. @@ -440,12 +453,13 @@ BrimstoneWitch: { BloodMoon2: I can't work with nights like these. The stars seem to have shrunk away in fear. Night1: These undead are horrific, I can't stand to look at them. How could anyone be satisfied with such amateur work? Night2: I don't think it's a stretch to say that astrology is utter nonsense... but it was a hobby of mine once. - DrunkPrincess: I wonder if {0} ever feels cold given how revealing her dress is. Perhaps she should cover up a bit more. SeaKing: I cannot understand the Sea King. He does not seem to want me dead. That amount of compassion I just can't understand. Party: If another person asks me if I can dance or not, I will light their hat on fire. } EnchantButton: Enchant + DonorButton: Donors + DonorShoutout: Hey {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23} and {24}. You guys are good people. TownNPCMood: { Content: I can't complain, really. @@ -464,118 +478,6 @@ BrimstoneWitch: { } } -Cirrus: { - DisplayName: Drunk Princess - Census.SpawnCondition: Have {$Items.Potions.CirrusVodka.DisplayName} [i:CalamityMod/CirrusVodka] in your inventory in Hardmode or defeat Calamitas Clone/Plantera - Name.Cirrus: Cirrus - - Chat: { - BossAlive: Why are you talking to me right now? Shouldn't you be bumbling about and dying for my amusement? - BossAliveAlt: You must be joking! Get back out there and FINISH THE FIGHT! - Homeless1: I could smell my vodka from MILES away! - Homeless2: Have any spare rooms available? Preferably candle-lit with a hefty supply of booze? - BloodMoon1: I'm gonna make some Bloody Marys to relax, celery included. Want one? - BloodMoon2: If you're too lazy to craft potions normally, try Blood Orbs. Blood is fuel, dumbass. - BloodMoon3: I'm trying to not be bitchy tonight, but it's hard when everyone else won't shut up. - BloodMoonSlap1: Sorry, I have no moral compass at the moment. - BloodMoonSlap2: I could slap you... but you've done more for me than most. What do you need? - Normal1: What do you want this time? I have an appointment to get my nails done in 5 minutes, make it quick. - Normal1Alt: Whaddya need? I have candles and alcohols galore! - Normal2: Maybe you should drink something that turns you into a magical flying unicorn, so you can be just like me. - Normal2Alt: Sometimes, I think about returning to nature for a while, to escape from all of this chaos. - Normal3: Deals so good I'll [$$!$] myself! ...Sorry, I may have just had a minor stroke! - Normal3Alt: I've been thinking more about the future lately. I can't say I'm not worried, but I'll be trying my best to make it better. - Normal4: Did anyone ever tell you that large assets cause back pain? Well, they were right. - Normal4Alt: Do you have any idea how much extra money I make so {0} can afford her super-fancy hair products? Heh, the back pain is worth it. - Archmage: "{0} can share a drink with me any time! ...Or maybe not, I'm not sure his old heart could take it." - BrimstoneWitch: The abuse {0} endured is something I can scarcely comprehend. I'd offer her a drink, but I don't think she'd enjoy it. - Tavernkeep1: My booze will always be better than {0}'s, and nobody can convince me otherwise. - Tavernkeep2: Tell {0} to stop calling me. He's not wanted. - Tavernkeep3: I've had to tell baldie where my eyes are so many times that I've lost count. - Stylist1: Ever since {0} moved in I haven't been drinking as much... a strange, but not unwelcome, feeling. - Stylist1Alt: I've stopped drinking almost entirely, thanks to {0} and... you. Thank you, for making this world a safer place. - Stylist2: You can't stop me from trying to move in with {0}. - Stylist2Alt: If you have {0} and I housed in one of those so-called 'NPC prisons'... we WILL find you, and we WILL bring the scissors... - Stylist3: I love it when {0}'s hands get sticky from all that... wax. - Stylist3Alt: "{0} and I will be building wax figures tonight. And no, there's nothing weird about that." - Day1: I'm literally balls drunk off my sass right now, what do you want? - Day1Alt: A nice day for a walk in the woods, don't you think? Anyway, what do you need? - Day2: I'm either laughing because I'm drunk or because I've lost my mind, probably both. - Day2Alt: Some people ask me whether it's 'unicorn', 'pegacorn', 'alicorn', 'pegasus'... whatever, all of them suit me. - Day3: When I'm drunk I'm way happier... at least until the talking worms start to appear. - Day3Alt: Did you know that certain worms can speak? Neither did I, until I flew to outer space. - Day4: I should go fishing... while drunk, and jump into the ocean to spare myself {0}'s annoying naivety... - Day4Alt: I may be a 'hater' and a 'gatekeeper', but I'm also Dionysus' favorite princess, and the most fabulous girl in the world. - DayStylist1: "{0} helped me accept my past. It's been tough, but I think I'm on the right path now." - DayStylist2: Might go out for a jog later with {0}. Nice day for it. - DayDrunk1: I drink to forget... What am I trying to forget, you might ask? Well, the point is to FORGET, not RECALL, isn't it? - DayDrunk2: What a great day! Might just drink so much that I get poisoned again. - Night1: A perfect night to light some candles, drink some wine, and relax. - Night2: Here's a challenge, take a shot for every time you've had to use the wiki. Oh wait, you'd die. - Night2Alt: There's more to life than challenge, y'know. Be sure to sit back and treat yourself once in a while. - Night3: You lost or something? I don't mind company, but I'd rather be left alone at night. - Night3Alt: I do love gazing at the stars. You could join me, if you like. - Night4: Are you sure you're 21? ...Alright, fine, but don't tell anyone I sold you these. - NightStylist: I should watch some movies with {0} tonight. You could come too, but only if you bring snacks. - Party: You'll always find me at parties where booze is involved... well, you'll always find BOOZE where I'M involved! - PartyAlt: Y'know... this is fun and all, but I can't wait for the festivities to be over. - AcidRain: I'm melting! Put a stop to this inclement weather before it ruins my hair! - Martians: You should probably deal with those 'ayy lmaos' before doing anything else, but whatever. - CryogenDefeated: God, I can't wait to smash some ice again! ...For drinks, of course. - LeviathanDefeated: How could you murder such a beautiful creature!? ...The blue one, not the obese cucumber. - MoonLordDefeated: Ever wondered why the Moon Lord needed so many tentacles? Uhm... on second thought, I won't answer that. - PolterghastDefeated: I saw a ghost down by the old train tracks back at my homeland once, flailing wildly at the lily pads... frightening times those were. - DoGDefeated: I hear it's amazing when the famous Devourer of Gods out in flap-jaw space, with the tuning fork, does a raw blink on Hara-kiri rock. I need scissors! 61! - HasChibii: The hell is that? Looks like something I'd carry around if I was 5 years old. - HasChibiiAlt: I won't judge you for having that creature in tow... but keep it the hell away from me. - HasAnahitaTrans: Nice scales... Is it hot in here, or is it just me? - HasVodka: Do you like my vodka? I created it by mixing fairy dust, crystallized cave sweat, and other magical crap. - HasAlicorn1: So... you found my special bottle. Hope you enjoy it, I know I will. - HasAlicorn2: Be sure to dismount me once in a while, I get tired. And besides, I can't rip you off-I mean, offer you excellent deals you won't find anywhere else, if you're riding me 24/7. - HasAlicorn3: Before you ask, no, I do NOT have a heart on my butt while in human form. Don't question my transformation preferences! - NewOutfit: It's so refreshing to finally wear something else. I still love my dress, of course, but it's not exactly ideal for exercising. - } - - // Death Count stuffs - DeathCountButton: Death Count + Donors - DeathCount: You have failed {0} {^0:time;times}. - Death10000: Congratulations! You are now, officially, the biggest loser in Terraria's history! - Death5000: I'm not sure what to say this time... perhaps, that you're bad and should feel bad? - Death2500: I could dodge better than you even if I was blackout drunk. - Death1000: It is said that the average Terrarian has a lifespan of 2 minutes or less... well, not really, but I feel like you'd be part of that statistic. - Death500: Your inability to avoid dying to even the most basic of attacks is astonishing to me. - Death250: I admire your tenacity. Keep it up, your enemies are racking up quite the kill count! - Death100: Consider lowering the difficulty. If you found that statement irritating, good. - DonorShoutout: Hey {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23} and {24}! You're all pretty good! - - TownNPCMood: { - Content: It's 5 o'clock somewhere. - NoHome: I need a place to crash! My drinks MUST be properly cooled before they can be served! - LoveSpace: Finally, some peace and quiet. Large quantities of people tend to piss me off. - FarFromHome: Don't get me wrong, I'm used to running away from home, but this is a little ridiculous. - DislikeCrowded: If one more person tells me 'it's happy hour somewhere', I'm going to snap! - HateCrowded: No amount of alcohol can drown out the noise these people make! - LoveBiome: Other unicorns? I never thought I'd see the day... this place is incredible! - LikeBiome: Ah, a soothing breeze and a gorgeous view; a great way to calm some of my more 'unpleasant' patrons. - DislikeBiome: This dry air and heat isn't good for my hair, or my drinks. - HateBiome: You think I can fix this place with a magical friendship rainbow? That's not how it works, so get me out of here already! - LoveNPC_Stylist: "{NPCName} works wonders for my hair... among other things, hehe." - LoveNPC_BestiaryGirl: "{NPCName} is so fluffy and squishy! She also says my alicorn form is 'mega rad'." - LikeNPC_DyeTrader: I tried inviting {NPCName} over for drinks a while back, but he didn't seem interested... oh well, his loss. - LikeNPC_PartyGirl: "{NPCName} would make for a great bartender some day. She really knows how to liven the mood!" - DislikeNPC_DD2Bartender: "{NPCName} is so bald. The sheen reflecting off his dome could legit blind someone, like, oh my god." - DislikeNPC_TaxCollector: "{NPCName} had best keep his distance... he wouldn't want to wake up one morning with a pipe bomb in his mailbox." - HateNPC_GoblinTinkerer: "{NPCName} was so terrible that I had to FORCE him to stop ripping off his customers... why would you house me next to him!?" - HateNPC_Angler: "{NPCName} never stops blabbering about his inane fishing quests. Get me away from him before I punt him into the sulphurous sea!" - LikeNPC_Princess: You think I'd dislike {NPCName} because we're too different? Quite the contrary, there's a lot we like to talk about, over non-alcoholic drinks, of course. - Princess_LovesNPC: "{NPCName} has some fascinating stories to tell, I've learned quite a lot from her already." - HateNPC: I hate {NPCName}. - DislikeNPC: I dislike {NPCName}. - LikeNPC: I like {NPCName}. - LoveNPC: I love {NPCName}. - } -} - SeaKing: { DisplayName: Sea King Census.SpawnCondition: Defeat a Giant Clam after defeating the Desert Scourge @@ -591,10 +493,8 @@ SeaKing: { Night1: There lurk horrifying creatures beyond the light of our homes. You should take care. Night2: My eyes are not well suited to bright lights after so many years of darkness. The peace of the night is welcome. Night3: Oh, me? I do not sleep, it is part of my nature. - Angler1: Meet me at {0}'s house at night. We will throw him to the Trashers. - Angler2: Not sure how {0} has not been roasted and digested by now, hanging around the sulphuric seas for so long. Perhaps it got to his head. + Angler: Not sure how {0} has not been roasted and digested by now, hanging around the sulphuric seas for so long. Perhaps it got to his head. BrimstoneWitch: I must admit, the Witch's presence is unsettling to me. But so many years have passed, and she too has suffered much. - DrunkPrincess: Rumor has it {0} drinks to forget her troubled past. PartyGirl: "{0} asked if my nose could be used as a vuvuzela. What is a vuvuzela?" BloodMoon1: Since ancient times people have said that deities cause celestial events. Which one then, is the cause for these? BloodMoon2: I've never been keen on these nights. Such violence. @@ -606,19 +506,19 @@ SeaKing: { } Help: { - YharonDefeated1: Auric is near impossible to work with without being attuned to a Dragon or using the claimed soul of a Dragon to perform a "mock" attunement. However, if one can work with it truly powerful things can be created; enough so that using it in anything was deemed heretical by the Gods. - YharonDefeated2: The Golden Heretic, Yharim, possesses strength that may just surpass all of the Gods. When you face him, be well prepared for the battle of your life. + YharonDefeated1: Auric is near impossible to work with without being attuned to a dragon, or using the claimed soul of a dragon to perform a "mock" attunement. However, if one can work with it truly powerful things can be created; enough so that using it in anything was deemed heretical by the gods. + YharonDefeated2: The Golden Heretic, Yharim, possesses strength that may just surpass all of the gods. When you face him, be well prepared for the battle of your life. YharonDefeated3: Draedon isn't a frontline fighter; he is a scientist and inventor. He is unlikely to face you directly, and will likely have his creations confront you instead. Be prepared for anything that blasphemous machine could throw at you. DoGDefeated1: The Devourer's armor was specially made by Draedon. Extremely flexible yet durable and massive, it may be one of his most impressive creations. I shudder to think of what unholy things he may be able to create now, if his research has not stopped. DoGDefeated2: With the cosmic steel you can fashion many of your weapons into much more powerful forms. - DoGDefeated3: The Devourer of Gods is truly an enigma. Some say it's not even from this world at all. What is known is that he is a being that can devour the essence of Gods entirely, leaving absolutely nothing left. It's no wonder Yharim recruited that monster. + DoGDefeated3: The Devourer of Gods is truly an enigma. Some say it's not even from this world at all. What is known is that he is a being that can devour the essence of gods entirely, leaving absolutely nothing left. It's no wonder Yharim recruited that monster. PolterghastDefeated1: The Abyss holds many secrets revealed with time. Checking it out again may not be a bad idea. PolterghastDefeated2: Ah... I can sense a powerful change in the weather. You may want to venture to the Sulphurous Seas once more during the rain to experience it. ProvidenceDefeated1: The Rune of Kos holds a significant portion of Providence's brand of magic, easily distinguishable from all others. Activating it in certain places would have some... risky consequences. - ProvidenceDefeated2: I do wonder what has happened to Braelor and Statis. I have heard or seen very little of either. In my days, both were great heroes to those who worshiped the Gods. Have they been killed, captured, or are they simply in hiding? + ProvidenceDefeated2: I do wonder what has happened to Braelor and Statis. I have heard or seen very little of either. In my days, both were great heroes to those who worshiped the gods. Have they been killed, captured, or are they simply in hiding? MoonLordDefeated1: Your adventure focuses to the jungle it seems. The Dragonfolly and its swarming offspring should be eliminated before their numbers spiral out of control. MoonLordDefeated2: Profaned creatures now lurk in the Hallow and in Hell. If you destroy enough and gather their essence together you shall be able to capture the attention of the Profaned Guardians. - MoonLordDefeated3: The Profaned Guardians serve Providence, one of the few Gods even I despise. The Guardians attempt to eliminate threats to their Goddess preemptively, and it is likely that their next target is you. + MoonLordDefeated3: The Profaned Guardians serve Providence, one of the few gods even I despise. The Guardians attempt to eliminate threats to their goddess preemptively, and it is likely that their next target is you. MoonLordDefeated4: Providence can likely be drawn out for combat by using the relic her Guardians left behind. I wonder... Why has Yharim not challenged her? Is he simply that negligent now? MoonLordDefeated5: Providence was a great threat to Yharim and his army. She would appear out of seemingly thin air, wreck havoc, and vanish before much damage could be done to her. Perhaps she would be overconfident in facing but a single warrior. GolemDefeated1: The men at the front of the dungeon are performing a ritual to keep the Moon Lord contained in his prison. In order to gain Yharim's attention, however, you may need to defeat them. @@ -638,7 +538,7 @@ SeaKing: { PreHardmode5: The Sulphurous Sea was created more than a millenia ago, but it has gotten truly unbearable in the past decades. It's the fault of that accursed robot, Draedon, dumping waste and abandoned projects in there constantly. It's viler than it's ever been, thanks to him. PreHardmode6: Be careful what you attack in the {0}. You might just unveil a greater threat than what was there before. PreHardmode7: Scattered across the lands are shrines dedicated to the gods. They contain powerful gear that may help you on your adventures. - PreHardmode8: I assume you have heard of the legendary ninja, Statis? He and his clan worshiped the God of slime, who may be a survivor of the war due to its trickery and knowing when to hide or flee. + PreHardmode8: I assume you have heard of the legendary ninja, Statis? He and his clan worshiped the god of slime, who may be a survivor of the war due to its trickery and knowing when to hide or flee. PreHardmode9: The {0} is a relatively recent development in the world, and its formation marked the start of Yharim's treacherous war. Although the source of its growth would be sealed away, nothing was ever done about the original manifestations. PreHardmode10: Throughout the world lie various structures left behind by Draedon. Archaic defenses may remain, but the goods inside may be worth your while. } @@ -660,3 +560,10 @@ SeaKing: { Princess_LovesNPC: "{NPCName} always smiles when I'm nearby, I like being around him just for that!" } } + +WildBumblebirb.DisplayName: Wild Bumblebirb +DraconicSwarmer.DisplayName: Draconic Swarmer +Dragonfolly.DisplayName: Dragonfolly +Shoreskipper.DisplayName: Shoreskipper +BrainIllusion.DisplayName: Brain Illusion +FalseBrain.DisplayName: False Brain diff --git a/Localization/en-US/Mods.CalamityMod.Prefixes.hjson b/Localization/en-US/Mods.CalamityMod.Prefixes.hjson index 636579790f..e8127c2e3e 100644 --- a/Localization/en-US/Mods.CalamityMod.Prefixes.hjson +++ b/Localization/en-US/Mods.CalamityMod.Prefixes.hjson @@ -1,8 +1,11 @@ Accessory: { - Cloaked.DisplayName: Cloaked Silent.DisplayName: Silent + Invigorating.DisplayName: Invigorating + Dauntless.DisplayName: Dauntless // New modifier effects (this is only positive) StealthGenTooltip: +{0}% stealth generation + LifeRegenTooltip: +{0} HP/s life regen + MaxLifeBoostTooltip: +{0} max life } Weapon: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson index 9c5863d7c5..576280052c 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson @@ -24,6 +24,7 @@ BigFlare2.DisplayName: Big Flare BirbAura.DisplayName: Draconic Aura BirbAuraFlare.DisplayName: Draconic Aura Flare BloodGeyser.DisplayName: Blood Geyser +BloodScythe.DisplayName: Blood Scythe BrimstoneBall.DisplayName: Brimstone Fireball BrimstoneBarrage.DisplayName: Brimstone Dart BrimstoneFire.DisplayName: Brimstone Fire @@ -36,11 +37,16 @@ BrimstoneTargetRay.DisplayName: Brimstone Target Ray BrimstoneWave.DisplayName: Brimstone Flame Skull BrokenApolloLens.DisplayName: Lens BrokenArtemisLens.DisplayName: Lens -CirrusBlast.DisplayName: Cirrus Mushroom Blast -CirrusBlaster.DisplayName: Cirrus Mushroom -CirrusPhotonRipperPrismTooth.DisplayName: Cirrus Photon Ripper Tooth -CirrusPhotonRipperProjectile.DisplayName: Cirrus Photon Ripper -CirrusVolatileVodkaBottle.DisplayName: Volatile Vodka Bottle +BurningBolt.DisplayName: Burning Bolt +BurningFireblast.DisplayName: Burning Fireblast +BurningGigablast.DisplayName: Burning Gigablast +CalamitousDart.DisplayName: Calamitous Dart +CalamitousExplosion.DisplayName: Calamitous Explosion +CalamitousFireball.DisplayName: Calamitous Fireball +CataclysmicFlame.DisplayName: Cataclysmic Flame +CatastrophicCinder.DisplayName: Catastrophic Cinder +CirclingBloodScythe.DisplayName: Circling Blood Scythe +CrimsonEye.DisplayName: Crimson Eye CrimulanSpike.DisplayName: Crimulan Spike CursedFire.DisplayName: Eye Fire DarkEnergyBall.DisplayName: Dark Energy @@ -56,10 +62,12 @@ DoGBeam.DisplayName: Portal Laser DoGBeamPortal.DisplayName: Beam Portal DoGDeath.DisplayName: Death Beam DoGDeathBoom.DisplayName: Cosmic Explosion -DoGFire.DisplayName: Death Fire +DoGFire.DisplayName: Faith Incinerator +DoGLaserWalls.DisplayName: God's Bane Doombeam Array +DoGLaserWallsBigBeam.DisplayName: Hyperdeath Rift Ripper DoGP1EndPortal.DisplayName: Portal -DoGTeleportRift.DisplayName: Rift -DoGWingdings.DisplayName: Ramblings of Wing DoGster +DoGRiftCrack.DisplayName: DoG Distortion Crack +DoGTeleportRift.DisplayName: DoG Distortion Rift DraedonSummonLaser.DisplayName: Giant Fuck-off Deathray of Doom DyingSun.DisplayName: Dying Sun EssenceDust.DisplayName: Cosmic Dust @@ -68,10 +76,10 @@ FlareBomb.DisplayName: Flare Bomb FlareDust.DisplayName: Flare Dust FlareDust2.DisplayName: Flare Bomb Flarenado.DisplayName: Flarenado -FoveanatorEnergyBomb.DisplayName: Nebulous Energy Bomb -FoveanatorLaser.DisplayName: Nebulous Laser -FoveanatorFlamethrower.DisplayName: Nebulous Flames +FriendlyLaserWallBeam.DisplayName: God's Bane Doombeam FrostMist.DisplayName: Frost Mist +GolemInfernoBolt.DisplayName: Golem Fire Bolt +GolemInfernoBlast.DisplayName: Golem Fire Blast GooglyEye.DisplayName: Googly Eye GreatSandBlast.DisplayName: Great Sand Blast HellfireExplosion.DisplayName: Brimstone Hellfire Explosion @@ -93,6 +101,7 @@ IceBomb.DisplayName: Ice Bomb IceRain.DisplayName: Ice Rain IchorBlob.DisplayName: Ichor Blob IchorShot.DisplayName: Ichor Shot +IchorShower.DisplayName: Ichor Shower Infernado.DisplayName: Infernado Infernado2.DisplayName: Infernado InfernadoRevenge.DisplayName: Infernado @@ -104,12 +113,18 @@ MoltenBlast.DisplayName: Molten Blast MoltenBlob.DisplayName: Molten Blob MushBomb.DisplayName: Mushroom Shot MushBombFall.DisplayName: Falling Mushroom +MushBombGround.DisplayName: Mushroom Shot OldDukeGore.DisplayName: Sulphurous Gore OldDukeSummonDrop.DisplayName: Acid OldDukeToothBallSpike.DisplayName: Spike OldDukeVortex.DisplayName: Sulphurous Vortex OverlyDramaticDukeSummoner.DisplayName: Old Duke Summoner PeanutRocket.DisplayName: High Explosive Peanut Shell +PermafrostAbsoluteZeroProjectile.DisplayName: Absolute Ultra Zero +PermafrostBlast.DisplayName: Permafrost's Gigablast +PermafrostBlaster.DisplayName: Blaster of Unlimited Air Conditioning +PermafrostColdheartIcicle.DisplayName: Coldheart Icicle +PermafrostMeat.DisplayName: Cool Meat PhantomBlast.DisplayName: Phantom Blast PhantomBlast2.DisplayName: Potent Phantom Blast PhantomGhostShot.DisplayName: Potent Phantom Spirit Shot @@ -127,6 +142,7 @@ ProvidenceHolyRay.DisplayName: Holy Ray RavagerBlast.DisplayName: Ravaging Laser RavagerBlaster.DisplayName: Ravager Blaster RavagerFlame.DisplayName: Blue Flame +RavagerNuke.DisplayName: Homing Nuke RedLightning.DisplayName: Red Lightning RedLightningFeather.DisplayName: Lightning Feather SandBlast.DisplayName: Sand Blast @@ -137,7 +153,7 @@ SCalBrimstoneFireblast.DisplayName: Brimstone Fireblast SCalBrimstoneGigablast.DisplayName: Brimstone Gigablast SCalRitualDrama.DisplayName: Calamitous Ritual Drama HomingLaserDart.DisplayName: Homing Dart -ScavengerNuke.DisplayName: Homing Nuke +HyperdeathRiftScepterBeam.DisplayName: Hyperdeath Rift Ripper ShadeNimbusHostile.DisplayName: Shade Nimbus ShaderainHostile.DisplayName: Shade Rain ShadowflameFireball.DisplayName: Shadowflame Fireball @@ -151,6 +167,8 @@ StormWeaverFrostWaveTelegraph.DisplayName: Frost Wave Telegraph SupremeCataclysmFist.DisplayName: Fist of Fury SupremeCatastropheSlash.DisplayName: Resonance Slash SwirlingFire.DisplayName: Fire +TelekineticEnemyGrab.DisplayName: Telekinetic Enemy Grab +TelekineticBlast.DisplayName: Telekinetic Blast ThanatosBeamStart.DisplayName: T Hanos Beam ThanatosBeamTelegraph.DisplayName: Gamma Disintegration Beam Telegraph ThanatosLaser.DisplayName: Exo Pulse Laser diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson index 7de66aee2f..4f2e7b90d0 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Enemy.hjson @@ -1,5 +1,8 @@ +AnglerFlash.DisplayName: Angler Flash AstralMeteorProj.DisplayName: Astral Meteor BelchingCoralSpike.DisplayName: Spike +CarrionPus.DisplayName: Carrion Pus +ClamBubbleBlast.DisplayName: Clam Bubble Blast CrabBoulder.DisplayName: Boulder CragmawAcidDrop.DisplayName: Acid CragmawBeam.DisplayName: Gamma Ray @@ -15,6 +18,7 @@ FlameBurstHostile.DisplayName: Burst GammaAcid.DisplayName: Acid GammaBeam.DisplayName: Gamma Ray GammaRayBurst.DisplayName: G-FUEL BEAM +GhostBellShock.DisplayName: Electrical Field HorsPoisonBlast.DisplayName: Poisonous Spit HorsWaterBlast.DisplayName: Water IceClasperEnemyProjectile.DisplayName: Ice Shard @@ -31,8 +35,15 @@ NuclearToadGoo.DisplayName: Goop OrthoceraStream.DisplayName: Acid Stream PearlBurst.DisplayName: Pearl Burst PearlRain.DisplayName: Pearl Rain +PodobooSpit.DisplayName: Podoboo Spit +PodobooSpitHoming.DisplayName: Psychic Podoboo Spit +PodobooSpitSplitting.DisplayName: Loose Podoboo Spit +PodobooSpitUltima.DisplayName: Ultima Podoboo Spit +PrismBackCrystal.DisplayName: Prism-Back Shard PufferExplosion.DisplayName: Explosion SharkoonExplosion.DisplayName: Sharkoon Explosion +ShoreskipperTackle.DisplayName: Shoreskipper Tackle +StormlionSentryBullet.DisplayName: Stormlion Sentry Bullet StormMarkHostile.DisplayName: Mark SulphuricAcidBubble.DisplayName: Acid Bubble SulphuricAcidMist.DisplayName: Acid Mist diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson index 6f207a3da2..e8077f1f00 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Healing.hjson @@ -1,5 +1,6 @@ AbsorberAura.DisplayName: Absorber Aura AltTransfusionTrail.DisplayName: Alt Transfusion Trail +BloodstoneHealOrb.DisplayName: Bloodstone Heal Orb BlueJellyAura.DisplayName: Blue Jelly Aura BurntSiennaProj.DisplayName: Sienna CactusHealOrb.DisplayName: Heal @@ -10,12 +11,9 @@ FungalHeal.DisplayName: Heal GladiatorHealOrb.DisplayName: Heal GreenJellyAura.DisplayName: Green Jelly Aura HydrothermicHealOrb.DisplayName: Hydrothermic Rejuvenation -IridescentExcaliburHeal.DisplayName: Iridescent Excalibur Heal ManaPolarizerHealOrb.DisplayName: Mana Polarizer Heal Orb PhantomicHeart.DisplayName: Phantomic Heart PinkJellyAura.DisplayName: Pink Jelly Aura -ReaverHealOrb.DisplayName: Reaver Heal Orb RoyalHeal.DisplayName: Heal ShinobiHealOrb.DisplayName: Blue Healing Orb -SilvaOrb.DisplayName: Silva Orb TransfusionTrail.DisplayName: Heal diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index 0808ef37fd..d0515c4a86 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -3,17 +3,25 @@ AcidGunStream.DisplayName: Acid Stream AcidicReed.DisplayName: Acidic Reed AcidicSaxBubble.DisplayName: Acid Bubble AcidicSaxMist.DisplayName: Acid Mist +AerSigil.DisplayName: Aer Sigil +AerSigilBlast.DisplayName: Aer Blast +AerSigilFeather.DisplayName: Aer Feather +AerSigilMissile.DisplayName: Aer Missile AetherBeam.DisplayName: Aether Beam +AlphaDraconisStar.DisplayName: Shooting Star AnahitasArpeggioNote.DisplayName: Anahita's Song Ancient2.DisplayName: Ancient Dust ApoctosisBlast.DisplayName: Apoctosis Blast ApotheosisEnergy.DisplayName: Apotheosis Energy ApotheosisWorm.DisplayName: The Devourer of Gods AquamarineBolt.DisplayName: Aqua Bolt +AquaSigil.DisplayName: Aqua Sigil +AquaSigilWaterball.DisplayName: Aqua Waterball +AquaSigilWaterballExplosion.DisplayName: Aqua Waterball Explosion +AquaSigilWaterdroplet.DisplayName: Aqua Waterdroplet ArcticBearPawProj.DisplayName: Arctic Bear Paw ArtAttackStar.DisplayName: Artsy Star ArtAttackStrike.DisplayName: Art Attack -Asteroid.DisplayName: Asteroid AsteroidMolten.DisplayName: Molten Asteroid AstralachneaFang.DisplayName: Astral Fang AstralCrystal.DisplayName: Astral Crystal @@ -41,8 +49,6 @@ CauldronProjSmall.DisplayName: Smaullerdron 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 ClimaxProj.DisplayName: Voltaic Orb CoralSpike.DisplayName: Coral Spike @@ -52,9 +58,9 @@ CosmicTentacle.DisplayName: Dark Tentacle CryoBlast.DisplayName: Cryo Blast DarkSparkBeam.DisplayName: Dark Spark Beam DarkSparkPrism.DisplayName: Dark Crystal -DeathhailBeam.DisplayName: Deathhail DeathValleyDusterProjectile.DisplayName: Death Valley Duster -DivineRetributionSpear.DisplayName: Divine Retribution +DeathhailBeam.DisplayName: Deathhail Beam +DracoConstellation.DisplayName: Draco EelDrop.DisplayName: Acid Eel Drop EidolicWailSoundwave.DisplayName: Eidolic Wail EldritchTentacle.DisplayName: Eldritch Tentacle @@ -68,8 +74,6 @@ EventHorizonStar.DisplayName: Event Horizon Star EvergladeSprayProjectile.DisplayName: Everglade Spray ExoVortex.DisplayName: Subsuming Vortex ExoVortex2.DisplayName: Subsuming Vortex -FabBolt.DisplayName: Fab Bolt -FabRay.DisplayName: Fab Ray FatesRevealFlame.DisplayName: Fate's Reveal FireImplosion.DisplayName: Swirling Backdraft FlareBoltProjectile.DisplayName: Flare Bolt @@ -96,12 +100,17 @@ HellfireExplosionFriendly.DisplayName: Explosion HellwingBat.DisplayName: Ashen Hellwing HolyFlame.DisplayName: Holy Flame HolyLaser.DisplayName: Holy Laser +HyperdeathRiftScepterBeam.DisplayName: Hyperdeath Rift Ripper IceBarrageMain.DisplayName: Ice Barrage IceBlock.DisplayName: Ice Barrage Block IceBlockIcicle.DisplayName: Ice Barrage Icicle IceCluster.DisplayName: Ice Cluster Icicle.DisplayName: Icicle IcicleStaffProj.DisplayName: Furious Icicle +IgnisSigil.DisplayName: Ignis Sigil +IgnisSigilFireballExplosion.DisplayName: Ignis Fireball Explosion +IgnisSigilFireball.DisplayName: Ignis Fireball +IgnisSigilEmbers.DisplayName: Ignis Ember IncineratingFireball.DisplayName: Incinerating Fireball InfernadoFriendly.DisplayName: Infernado InfernadoMarkFriendly.DisplayName: Infernado Mark @@ -151,7 +160,12 @@ NightOrb.DisplayName: Night's Orb NightsRayBeam.DisplayName: Night's Ray NuclearFuryProjectile.DisplayName: Nuclear Fury OmicronBeam.DisplayName: Omicron Beam +OrdoSigil.DisplayName: Ordo Sigil +OrdoSigilBeam.DisplayName: Ordo Beam PartySparkle.DisplayName: Pretty Sparkle +PerditoSigil.DisplayName: Perdito Sigil +PerditoSigilShot.DisplayName: Perdito Shot +PerditoSigilShotCreator.DisplayName: Perdito Shot Creator PhantasmalFuryProj.DisplayName: Phantasmal Fury Phantom.DisplayName: Phantom PhasedGodRay.DisplayName: Phased God Ray @@ -201,6 +215,8 @@ SHPB.DisplayName: SHPB SHPExplosion.DisplayName: SHPB Explosion SHPL.DisplayName: SHPL SHPS.DisplayName: SHPS +SHPV.DisplayName: SHPV +SigilSet.DisplayName: Sigil Set SilvaBurst.DisplayName: Silva Burst SlitheringEelProjectile.DisplayName: Slithering Eel SmallSpirit.DisplayName: Small Angry Spirit @@ -217,9 +233,15 @@ SpiritDust.DisplayName: Spirit Dust Starblast.DisplayName: Star StardustElementalBeam.DisplayName: Stardust Beam StickyFeather.DisplayName: Feather +SylvBolt.DisplayName: Sylv Bolt +SylvRay.DisplayName: Sylv Ray TacticiansElectricBoom.DisplayName: Electric Explosion TacticiansTrumpCardProj.DisplayName: Trump Beam TearsofHeavenProjectile.DisplayName: Tears of Heaven +TerraSigil.DisplayName: Terra Sigil +TerraSigilLargeRock.DisplayName: Terra Large Rock +TerraSigilMediumRock.DisplayName: Terra Medium Rock +TerraSigilSmallRock.DisplayName: Terra Small Rock Teslabeam.DisplayName: Teslabeam TradewindsProjectile.DisplayName: Tradewinds Feather TridentIcicle.DisplayName: Trident Icicle @@ -237,6 +259,7 @@ VenusianExplosion.DisplayName: Venusian Explosion VenusianFlame.DisplayName: Venusian Cinder VisceraBeam.DisplayName: Viscera VisceraBoom.DisplayName: Viscera Boom +VisNeedle.DisplayName: Vis Needle VitriolicViperFang.DisplayName: Vitriolic Fang VitriolicViperSpit.DisplayName: Vitriolic Spit VividBeam.DisplayName: Vivid Beam @@ -251,6 +274,9 @@ VolterionOrb.DisplayName: Unstable Ball Lightning VolterionShot.DisplayName: Ultracharged Filament VortexElementalBeam.DisplayName: Vortex Lightning WaterLeechProj.DisplayName: Water Leech +WarpSigil.DisplayName: Warp Sigil +WarpSigilShot.DisplayName: Warped Shot +WarpSigilShotCreator.DisplayName: Warped Shot Creator WaywasherProj.DisplayName: Waywasher Wave WingmanGrenade.DisplayName: Mana Grenade WingmanShot.DisplayName: Mana Shot diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 72ae489a01..bb4a5def16 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -4,7 +4,7 @@ AegisBeam.DisplayName: Aegis Beam AegisBlast.DisplayName: Aegis Blast AegisBlast2.DisplayName: Aegis Blast AegisFlame.DisplayName: Aegis Flame -AftershockRock.DisplayName: Afterrock +AmidiasTridentBoltProj.DisplayName: Trident Bolt AmidiasWhirlpool.DisplayName: Whirlpool AncientBeam.DisplayName: Ancient Beam AncientStar.DisplayName: Ancient Star @@ -68,7 +68,7 @@ CosmicShivBlade.DisplayName: Cosmic Beam CosmicShivTrail.DisplayName: Cosmic Shiv Trail CosmicSpiritBomb.DisplayName: Cosmic Bomb CrescentMoonFlail.DisplayName: Crescent Moon -CrescentMoonProj.DisplayName: Crescent Moon +CrescentMoonProj.DisplayName: Seeking Moon CrystylCrusherRay.DisplayName: Crystyl Crusher Ray Cyclone.DisplayName: Cyclone DarkBall.DisplayName: Dark Ball @@ -86,7 +86,6 @@ DepthCrusherProjectile.DisplayName: Depth Crusher DepthCrusherSplitProjectile.DisplayName: Depth Crusher Jet DevilsDevastationThrownBlade.DisplayName: Devils Devastation Thrown Blade DevilsSunriseCyclone.DisplayName: Devil's Sunrise -DNA.DisplayName: DNA DracoBeam.DisplayName: Draconic Beam DracoBeam2.DisplayName: Draconic Beam DraconicSpark.DisplayName: Draconic Spark @@ -105,12 +104,10 @@ ElementalGlassStar.DisplayName: Glass Star EmpyreanKnife.DisplayName: Empyrean Knife EntropicFlechette.DisplayName: Entropic Flechette EonBolt.DisplayName: Eon Bolt -EssenceFlame2.DisplayName: Essence Flame EssenceScythe.DisplayName: Essence Scythe ExaltedOathbladeThrownBlade.DisplayName: Exalted Oathblade Thrown Blade -ExcelsusBlue.DisplayName: Excelsus -ExcelsusMain.DisplayName: Excelsus -ExcelsusPink.DisplayName: Excelsus +MawOfInfinityHoldout.DisplayName: Maw of Infinity +MawOfInfinityJaws.DisplayName: Divinity Devourer Exobeam.DisplayName: Exobeam ExobeamSlash.DisplayName: Exobeam Slash ExobeamSlashCreator.DisplayName: Anime Sword Effect @@ -136,6 +133,7 @@ GalaxySmasherHammer.DisplayName: Galaxy Smasher GalaxySmasherMini.DisplayName: Cosmic Shard GalileosMoon.DisplayName: Crescent Moon GalileosPlanet.DisplayName: Planet +GalileoGladiusThrown.DisplayName: Galileo Gladius (Thrown) GayBeam.DisplayName: Iridescent Beam GelWave.DisplayName: Gelitic Wave GemTechYellowShard.DisplayName: Trireme's Yellow Gem @@ -149,6 +147,7 @@ GrandGuardianBoom.DisplayName: Cosmic Burst GreenWater.DisplayName: Greentide Tooth GrovetendersEntanglingVines.DisplayName: Entangling Growth GrovetendersTouch.DisplayName: Grovetender's Touch +GildedProboscisProj.DisplayName: Gilded Proboscis HeavensMight.DisplayName: Heaven's Might HeavensMonolith.DisplayName: Heaven's Monolith HellionSpike.DisplayName: Hellion Spike @@ -156,24 +155,30 @@ HolyColliderHolyFire.DisplayName: Holy Collider Fire IceBombFriendly.DisplayName: Ice Bomb IllustriousKnife.DisplayName: Illustrious Knife InsidiousHarpoon.DisplayName: Insidious Harpoon -IridescentExcaliburSlash.DisplayName: Iridescent Excalibur Slash -IridescentExcaliburSlash2.DisplayName: Iridescent Excalibur Slash -IridescentExcaliburSlash3.DisplayName: Iridescent Excalibur Slash JudgementProj.DisplayName: JUDGEMENT LamentationsOfTheChained.DisplayName: Lamentations of the Chained -LaserFountain.DisplayName: Laser Fountain LifeScythe.DisplayName: Lifehunt Scythe LightBeam.DisplayName: Light Beam LightningThing.DisplayName: Lightning +LightspeedDashHitbox.DisplayName: Lightspeed Rupture +LightspeedHoldout.DisplayName: Lightspeed +LightspeedM1Hitbox.DisplayName: Lightspeed Stab +LucreciaBolt.DisplayName: Lucrecia Bolt +LucreciaDNATrailCreator.DisplayName: Darklight Comet Trail +LucreciaHoldout.DisplayName: Lucrecia LuxorsGiftMelee.DisplayName: Luxor's Melee MantisClawHoldout.DisplayName: Mantis Claw MantisClawJet.DisplayName: Mantis Claw Jet MantisClawSlash.DisplayName: Mantis Claw Slash MicrowaveAura.DisplayName: Microwave Radiation -MirrorBlast.DisplayName: Mirror Blade +MirrorBlast.DisplayName: Mirror Blast +MirrorBladeProjectile.DisplayName: Mirror Blade +MirrorBladeSlash.DisplayName: Mirror Blade Slash +MirrorBladeSlashCreator.DisplayName: Mirror Blade Slash Creator MonstrousKnife.DisplayName: Monstrous Knife MourningSkull.DisplayName: Mourning Skull MourningstarFlail.DisplayName: Mourningstar +MutilatorSwordProj.DisplayName: The Mutilator Nebudust.DisplayName: Nebulash Dust NebulashFlail.DisplayName: Nebulash NebulaShot.DisplayName: Nebula Shot @@ -223,6 +228,7 @@ SanguineFury.DisplayName: Sanguine Fury SanguineFuryDash.DisplayName: Shredding Lunge SanguineFuryWheel.DisplayName: Sanguine Bladewheel ScorcherExplosion.DisplayName: Scorching Crystal Blast +ScorpiusConstellation.DisplayName: Scorpius Constellation ScourgeoftheCosmosMini.DisplayName: Miniature Cosmic Scourge ScourgeoftheCosmosProj.DisplayName: Cosmic Scourge SeekingScorcherProj.DisplayName: Scorching Seeker @@ -235,10 +241,9 @@ SpatialSpear2.DisplayName: Elemental Spear SpatialSpear3.DisplayName: Elemental Spear SpatialSpear4.DisplayName: Elemental Spear SpineOfThanatosProjectile.DisplayName: Spine of Thanatos -StarburstBeam.DisplayName: Star Shiv -StarburstSHIV.DisplayName: SHIV StarnightBeam.DisplayName: Starnight Beam StarofJudgement.DisplayName: Star of Judgement +StarofOrder.DisplayName: Star of Order StellarContemptBlast.DisplayName: Stellar Blast StellarContemptEcho.DisplayName: Echoes of Contempt StellarContemptHammer.DisplayName: Stellar Contempt diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson index 2106b8f772..303e04c84f 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson @@ -1,54 +1,57 @@ // Damageable -ArtifactOfResilienceBulwark.DisplayName: Artifact of Resilience MarniteRepulsionHitbox.DisplayName: Repulsion Matrix // Draedon's Arsenal +AerialTrackerLaser.DisplayName: Laser +AerialTrackerProjectile.DisplayName: Aerial Tracker AnomalysNanogunHoldout.DisplayName: The Anomaly's Nanogun AnomalysNanogunMPFBBoom.DisplayName: MPFB Explosion AnomalysNanogunMPFBDevastator.DisplayName: MPFB Devastator AnomalysNanogunPlasmaBeam.DisplayName: Plasma Beam -FrequencyManipulatorEnergy.DisplayName: Pulse Energy -FrequencyManipulatorProjectile.DisplayName: Frequency Manipulator -GatlingLaserShot.DisplayName: Gatling Laser +AqueousHunterDroneSummon.DisplayName: Plasma Shrimp +AugerHoldout.DisplayName: P-GSS Auger +AugerSlash.DisplayName: Auger Slash +AugerPull.DisplayName: Auger Pull +CountermeasurePalmBlast.DisplayName: Palm Blast GaussEnergy.DisplayName: Gauss Energy GaussFlux.DisplayName: Gauss Flux -GaussPistolShot.DisplayName: Gauss Shot -GaussRifleBlast.DisplayName: Gauss Blast -GaussRifleExplosion.DisplayName: Gauss Explosion ImmolationArrow.DisplayName: Immolation Arrow ImmolationBurst.DisplayName: Immolation Burst ImmolationSpray.DisplayName: Immolation Spray -LaserRifleShot.DisplayName: Laser Rifle MassivePlasmaExplosion.DisplayName: Plasma Explosion MountedScannerLaser.DisplayName: Deathray MountedScannerSummon.DisplayName: Mounted Scanner +NidhoggRailgunBigShot.DisplayName: Nidhogg Railgun +NidhoggRailgunBlast.DisplayName: Nidhogg Beam +NidhoggExplosion.DisplayName: Magnetic Implosion +PhalanxSurgeLance.DisplayName: Laser Lance +PhalanxSurgeLaser.DisplayName: Phalanx Laser PhaseslayerBeam.DisplayName: Light Blade PlasmaCasterShot.DisplayName: Plasma Bolt PlasmaGrenadeProjectile.DisplayName: Plasma Grenade PlasmaGrenadeSmallExplosion.DisplayName: Plasma Explosion PoleWarperSummon.DisplayName: Pole Warper PulseDragonProjectile.DisplayName: Pulse Dragon +PulseGrenadeProjectile.DisplayName: Pulse Grenade +PulseGrenadeOrb.DisplayName: Pulse Orb PulsePistolShot.DisplayName: Pulse Bolt PulseRifleShot.DisplayName: Pulse Bolt PulseTurret.DisplayName: Pulse Turret PulseTurretShot.DisplayName: Pulse Bolt -ScattershotLance.DisplayName: Laser Lance -ScattershotLaser.DisplayName: Scattershot Laser +ShortCircuitHook.DisplayName: Short Circuit Hook +ShrimpPlasmaMissile.DisplayName: Plasma Shrimp Missile SnakeEyesSummon.DisplayName: Snake Eyes SnakeEyesProjectile.DisplayName: Inescapable Bolt -StarSwallowerAcid.DisplayName: Acid -StarSwallowerSummon.DisplayName: Pet Froge SystemBaneLightning.DisplayName: Lightning SystemBaneProjectile.DisplayName: System Bane -TaserHook.DisplayName: Taser TeslaCannonShot.DisplayName: Tesla Beam -TrackingDiskLaser.DisplayName: Laser -TrackingDiskProjectile.DisplayName: Tracking Disk -UnstableMatter.DisplayName: Unstable Matter VoltageStream.DisplayName: Voltage Stream +VulcanProjectile.DisplayName: Vulcan Shot +VulcanSpear.DisplayName: Vulcan Harpoon WavePounderBoom.DisplayName: Explosion WavePounderProjectile.DisplayName: Wave Pounder // Environmental AcidDrop.DisplayName: Acid +BarrelCactusProjectile.DisplayName: Barrel Cactus BrimstoneGeyser.DisplayName: Smoke GeyserTelegraph.DisplayName: Geyser HotSteam.DisplayName: Steam diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Pets.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Pets.hjson index b4bc7c0ea2..1578f2adc3 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Pets.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Pets.hjson @@ -10,6 +10,7 @@ DaawnlightSpiritOriginMinion.DisplayName: Daawnlight DannyDevitoPet.DisplayName: Danny Devito EidolonSnail.DisplayName: Escargidolon Snail FlakPet.DisplayName: Flak Hermit +FrostyBatPet.DisplayName: Frosty Bat Friend FoxPet.DisplayName: Fox GoldiePet.DisplayName: Goldie KendraPet.DisplayName: Kendra @@ -28,4 +29,6 @@ RotomPet.DisplayName: Rotom SCalPet.DisplayName: Supreme Calamitas Sparks.DisplayName: Sparks ThirdSage.DisplayName: Third Sage +ToastyBatPet.DisplayName: Toasty Bat Friend YharonSonPet.DisplayName: Son of Yharon +BurrowerPet.DisplayName: Burrower diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 8f7aca918e..7d68549da7 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -1,3 +1,4 @@ +AcidRocket.DisplayName: Acid Rocket AdamAcceleratorBeam.DisplayName: Adamantite Particle Beam AMR2.DisplayName: AMR AMRShot.DisplayName: AMR @@ -5,7 +6,7 @@ AngelicBeam.DisplayName: Angelic Beam AnimosityBullet.DisplayName: Brimstone Round AquaBlast.DisplayName: Aqua Blast AquaBlastToxic.DisplayName: Aqua Blast Toxic -Aquashard.DisplayName: Aquashard +Aquashard.DisplayName: Aqua Crystal AquashardSplit.DisplayName: Aquashard ArcherfishRing.DisplayName: Archerfish Ring ArcherfishShot.DisplayName: Water Round @@ -46,7 +47,6 @@ ChromaticFlare.DisplayName: Chromatic Flare CinderArrowProj.DisplayName: Cinder Arrow ClamorRifleProj.DisplayName: Clamor Bolt ClamorRifleProjSplit.DisplayName: Clamor Bolt -ClaretCannonProj.DisplayName: Claret Cannon CondemnationArrow.DisplayName: Condemning Arrow CondemnationArrowHoming.DisplayName: Condemning Echo ContagionArrow.DisplayName: Contagion Arrow @@ -68,7 +68,6 @@ DrizzlefishFireball.DisplayName: Drizzlefish Fireball DrizzlefishFireSplit.DisplayName: Drizzlefish Flames DryadsTearMain.DisplayName: Dryad's Tear DryadsTearSplit.DisplayName: Dryad's Tear -DWArrow.DisplayName: Death's Arrow ElysianArrowProj.DisplayName: Elysian Arrow ElysianArrowRain.DisplayName: Elysian Light EmesisGore.DisplayName: Rotten Gore @@ -87,6 +86,7 @@ FlakKrakenProjectile.DisplayName: Flak Kraken FlakToxicannonProjectile.DisplayName: Flak Toxicannon FlareBat.DisplayName: Flare Bat Flash.DisplayName: Flash +FlashRoundFlash.DisplayName: Flash FlashRoundProj.DisplayName: Flash Round FlurrystormIceChunk.DisplayName: Ice Chunk FlurrystormIceShard.DisplayName: Ice Shard @@ -97,9 +97,11 @@ FungiOrb2.DisplayName: Fungi Orb GemTechGreenFlechette.DisplayName: Gem Tech Flechette GodSlayerSlugProj.DisplayName: God Slayer Slug HalleysComet.DisplayName: Halley's Comet +HalleysStarburst.DisplayName: Halley's Starburst HandheldTankShell.DisplayName: Tank Shell HeavenlyGaleProj.DisplayName: Heavenly Gale -HighExplosivePeanutShell.DisplayName: High Explosive Peanut Shell +HellbornProj.DisplayName: Hell-born Gunblast +HellbornShell.DisplayName: Hell's Shell HiveMissile.DisplayName: Hive Missile HiveNuke.DisplayName: Hive Nuke HolyFireBulletProj.DisplayName: Holy Fire Bullet @@ -107,15 +109,21 @@ HydraHead.DisplayName: Hydra Head HydraHeadLaunch.DisplayName: Hydra Head HydrasBlood.DisplayName: Hydra's Blood HyperiusBulletProj.DisplayName: Hyperius Bullet -HyperiusSplit.DisplayName: Hyperius Bad Time +HyperiusSplit.DisplayName: Hyperius Fragment IcicleArrowProj.DisplayName: Icicle Arrow HailstormBulletProj.DisplayName: Hailstorm Bullet HallowPointRoundProj.DisplayName: Hallow-Point Round ImpactRound.DisplayName: Impact Round KarasawaShot.DisplayName: Karasawa Shot LeafArrow.DisplayName: Leaf Arrow +LeviatitanAberration.DisplayName: Leviatitan Aberration +LeviatitanExplosion.DisplayName: Leviatitan Explosion +LeviatitanMeteor.DisplayName: Leviatitan Meteor LunarBolt.DisplayName: Bolt LuxorsGiftRanged.DisplayName: Luxor's Ranged +M1GarandBulletCasing.DisplayName: M1 Garand Bullet Casing +M1GarandEmptyClip.DisplayName: M1 Garand Empty Clip +M1GarandShot.DisplayName: .30-06 Round MagnaShot.DisplayName: Magna Bolt MagnomalyAura.DisplayName: Magnomaly Aura MagnomalyBeam.DisplayName: Beam @@ -123,6 +131,7 @@ MagnomalyExplosion.DisplayName: Explosion MagnomalyRocket.DisplayName: Nuke MarksmanShot.DisplayName: Marksman Shot MechanicalBarracuda.DisplayName: Barracuda +MegalodonShot.DisplayName: Megalodon Shot MeowCreature.DisplayName: the creature :3 MeowFire.DisplayName: Purr Fire MineralMortarProjectile.DisplayName: Onyx Bomb @@ -154,7 +163,6 @@ PlagueTaintedDrone.DisplayName: Plague Tainted Drone PlanarRipperBolt.DisplayName: Planar Bolt PlanarRipperExplosion.DisplayName: Planar Explosion PlanetaryAnnihilationProj.DisplayName: Planetary Ball -PlasmaBlast.DisplayName: Plasma Blast PlasmaExplosion.DisplayName: Plasma Explosion PolarStar.DisplayName: Star Shot PrecisionBolt.DisplayName: Precision Bolt @@ -175,8 +183,8 @@ RealmRavagerBullet.DisplayName: Explosive Bullet RicoshotCoin.DisplayName: Ricoshot Coin RocketFire.DisplayName: Fire RubberMortarRoundProj.DisplayName: Rubber Mortar +RubicoPrimeMag.DisplayName: Rubico Prime Mag SandblasterBullet.DisplayName: Sandstorm -ScorchedEarthBlast.DisplayName: Earth Scorcher ScorchedEarthClusterBomb.DisplayName: Cluster Bomb ScorchedEarthRocket.DisplayName: Rocket ScorpioRocket.DisplayName: Nano Missile @@ -195,17 +203,21 @@ SevensStrikerGrape.DisplayName: Grapes SevensStrikerOrange.DisplayName: Orange SevensStrikerPlatinumCoin.DisplayName: Platinum Coin ShadeFire.DisplayName: Shady Fire +ShardshockerCrystal.DisplayName: Charged Aqua Crystal Shell.DisplayName: Shell Shockblast.DisplayName: Blast ShockblastRound.DisplayName: Round +ShortCircuitExplosion.DisplayName: Short Circuit +ShortCircuitShot.DisplayName: Short Circuit Shot Shroom.DisplayName: Shroom Sickness.DisplayName: Sickness SicknessRound.DisplayName: Round SicknessRound2.DisplayName: Round SlagRound.DisplayName: Slag Round +Slagfire.DisplayName: Slagfire SlimeBolt.DisplayName: Slime Bolt -SmallCoral.DisplayName: Small Coral SparkSpreaderFire.DisplayName: Sparked Flames +SpectralFlare.DisplayName: Spectral Flare SpeedBlasterShot.DisplayName: Splatter Shot SporeBomb.DisplayName: Spore Bomb SproutingArrowMain.DisplayName: Sprouting Arrow @@ -213,18 +225,22 @@ SproutingArrowSplit.DisplayName: Sprouting Arrow SputterComet.DisplayName: Sputter Comet SputterCometBig.DisplayName: Sputter Comet SpykerProj.DisplayName: Spyker +StarfleetStar.DisplayName: Starfleet Star +StarmadaHitProj.DisplayName: Starmada +StarmadaStar.DisplayName: Starmada Star StarmageddonBinaryStarCenter.DisplayName: Starmageddon Binary Star Center StarmageddonStar.DisplayName: Starmageddon Star StarmageddonStar2.DisplayName: Starmageddon Star StormSurgeTornado.DisplayName: Surge +SulphuricAcidCannonExplosion.DisplayName: Sulphuric Acid Cannon Explosion SulphuricBlast.DisplayName: Sulphuric Blast +SulphuricDrop.DisplayName: Sulphuric Drop SuperradiantBolt.DisplayName: Superradiant Bolt SuperradiantSaw.DisplayName: Superradiant Saw SuperradiantSawLingering.DisplayName: Ultraradiant Saw TauCannonBeam.DisplayName: Tau Cannon Beam TauCannonBolt.DisplayName: Tau Cannon Bolt TauCannonPortal.DisplayName: Tau Cannon Portal -TaserExplosion.DisplayName: Taser Explosion TelluricGlareArrow.DisplayName: Radiant Arrow TheMaelstromExplosion.DisplayName: Reaper Explosion TheMaelstromShark.DisplayName: Reaper Shark @@ -252,13 +268,3 @@ WaterSpout.DisplayName: Spout WildfireBloomFire.DisplayName: Wildfire Fire WildfireBloomFlare.DisplayName: Wildfire Flare WulfrumScrapBullet.DisplayName: High Speed Scrap -HellbornProj.DisplayName: Hell-born Gunblast -HellbornShell.DisplayName: Hell's Shell -RubicoPrimeMag.DisplayName: Rubico Prime Mag -MegalodonShot.DisplayName: Megalodon Shot -SulphuricAcidCannonExplosion.DisplayName: Sulphuric Acid Cannon Explosion -LeviatitanAberration.DisplayName: Leviatitan Aberration -LeviatitanMeteor.DisplayName: Leviatitan Meteor -LeviatitanExplosion.DisplayName: Leviatitan Explosion -SulphuricDrop.DisplayName: Sulphuric Drop -AcidRocket.DisplayName: Acid Rocket diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index db8881eeac..3d2baf7cde 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -1,6 +1,4 @@ AbyssalMirrorProjectile.DisplayName: Lumenyl Fluid -AcidBarrelDrop.DisplayName: Barrel Acid Drop -AcidShrapnel.DisplayName: Acidic Shrapnel AdamantiteThrowingAxeProjectile.DisplayName: Adamantite Throwing Axe AntlionSkewerProj.DisplayName: Antlion on a Stick AntlionSkewerSandBlast.DisplayName: Antlion Blast @@ -20,6 +18,7 @@ BallisticPoisonCloud.DisplayName: Ballistic Cloud BarrelShrapnel.DisplayName: Barrel Shrapnel BileExplosion.DisplayName: Bile BlastBarrelProjectile.DisplayName: Blast Barrel +BlazingStarOrbital.DisplayName: Orbital Blazing Star BlazingStarProj.DisplayName: Blazing Star BloodsoakedCrashax.DisplayName: Bloodsoaked Crasher BlueFlamePillar.DisplayName: Flame Pillar @@ -40,7 +39,6 @@ CelestialReaperProjectile.DisplayName: Celestial Reaper CelestusMiniScythe.DisplayName: Celestus CelestusProj.DisplayName: Celestus CinquedeaProj.DisplayName: Cinquedea -CircletMark.DisplayName: Tornado Mark CircletTornado.DisplayName: Tornado CobaltEnergy.DisplayName: Cobalt Energy CobaltKunaiProjectile.DisplayName: Cobalt Kunai @@ -98,7 +96,7 @@ EpidemicShredderProjectile.DisplayName: Epidemic Shredder EquanimityDarkShard.DisplayName: Dark Shard EquanimityLightShard.DisplayName: Light Shard EquanimityProj.DisplayName: Equanimity -EradicatorProjectile.DisplayName: Eradicator +DimensionTearingDiskProjectile.DisplayName: Dimension-Tearing Disk ExecutionersBladeProj.DisplayName: Executioner's Blade ExecutionersBladeStealthProj.DisplayName: Executioner's Blade ExorcismProj.DisplayName: Exorcism @@ -125,12 +123,12 @@ GacruxianProj.DisplayName: Gacruxian Mollusk GelDartProjectile.DisplayName: Gel Dart GhoulishGougerBoomerang.DisplayName: Ghoulish Gouger GildedDaggerProj.DisplayName: Gilded Dagger +GlaiveOrbital.DisplayName: Orbital Glaive GlaiveProj.DisplayName: Glaive GleamingDaggerProj.DisplayName: Gleaming Dagger GodsParanoiaDart.DisplayName: God's Paranoia Dart GodsParanoiaProj.DisplayName: God's Paranoia GraveGrimreaverProjectile.DisplayName: Grave Grimreaver -GreenDonkeyKongReference.DisplayName: Acidic Rain Barrel GrimreaverBat.DisplayName: Grim Bat GrimreaverSkull.DisplayName: Grim Skull HeavenfallenEnergy.DisplayName: Heavenfallen Energy @@ -161,11 +159,13 @@ LeonidCometSmall.DisplayName: Leonid Comet LeonidProgenitorBombshell.DisplayName: Leonid Bombshell LeonidStar.DisplayName: Leonid Star LeviathanTooth.DisplayName: Leviathan Tooth +LeviathanToothStealth.DisplayName: Leviathan Jaw LionfishProj.DisplayName: Lionfish LostSoulFriendly.DisplayName: Lost Soul LuminousShard.DisplayName: Stardust Shard LunarKunaiProj.DisplayName: Lunar Kunai LuxorsGiftRogue.DisplayName: Luxor's Rogue +LyraConstellation.DisplayName: Lyra Constellation MalachiteBolt.DisplayName: Malachite MalachiteProj.DisplayName: Malachite MalachiteStealth.DisplayName: Malachite @@ -190,13 +190,8 @@ NanoblackStrike.DisplayName: Zero-Point Energy Strike NanoblackTesselation.DisplayName: Nanoblack Tesselation NastyChollaBol.DisplayName: Nasty Cholla NastyChollaNeedle.DisplayName: Cactus Needle -NiceCock.DisplayName: Kitchen Fire -NightsGazeProjectile.DisplayName: Night's Gaze -NightsGazeSpark.DisplayName: Night's Gaze Spark -NightsGazeStar.DisplayName: Night's Gaze Star OrichalcumSpikedGemstoneProjectile.DisplayName: Orichalcum Gemstone PalladiumJavelinProjectile.DisplayName: Palladium Javelin -PanSpark.DisplayName: Pan Spark PartisanExplosion.DisplayName: Profaned Explosion PenumbraBomb.DisplayName: Penumbra Bomb PenumbraSoul.DisplayName: Penumbra Soul @@ -213,9 +208,15 @@ PrismRocket.DisplayName: Prism Rocket PrismShurikenBlade.DisplayName: Refraction Blade ProfanedPartisanProj.DisplayName: Profaned Partisan ProfanedPartisanSpear.DisplayName: Profaned Spear +PumpkaboomSmall.DisplayName: Small Pumpkaboom +PumpkaboomBoomSmall.DisplayName: Pump-kaboom! +PumpkaboomBig.DisplayName: Big Pumpkaboom +PumpkaboomBoomBig.DisplayName: Pump-KABOOM!! RadiantExplosion.DisplayName: Radiant Explosion RadiantStar2.DisplayName: Radiant Star RadiantStarKnife.DisplayName: Radiant Star +RadiationBurst.DisplayName: Radiation Burst +RadiationRain.DisplayName: Radiation Rain RealityRuptureLance.DisplayName: Lance of Reality RealityRuptureMini.DisplayName: Reality Shard RealityRuptureStealth.DisplayName: Ruptured Reality @@ -223,14 +224,17 @@ ReaperProjectile.DisplayName: The Old Reaper ReboundingRainbowProj.DisplayName: Rebounding Rainbow ReboundingRainbowSplit.DisplayName: Rebounding Rainbow RefractionRotorProjectile.DisplayName: Prism Shuriken +RefractionRotorSlashCreator.DisplayName: Refraction Rotor Slash Creator +RefractionSlash.DisplayName: Refraction Slash RegulusEnergy.DisplayName: Regulus Energy RegulusRiotProj.DisplayName: Regulus Riot RotBallProjectile.DisplayName: Rot Ball SacrificeProjectile.DisplayName: Sacrificial Dagger SamsaraSlicerProjectile.DisplayName: Samsara Slicer -SamsaraSlicerSmallDisk.DisplayName: Samsara Slicer +SamsaraSlicerSmallDisk.DisplayName: Samsara Slicer Split +SandDollarFrag.DisplayName: Sand Dollar Frag SandDollarProj.DisplayName: Sand Dollar -SandDollarStealth.DisplayName: Sand Dollar +SandDollarStealth.DisplayName: Sand Dollar Duststorm ScarletBlast.DisplayName: Scarlet Blast ScarletDevilBullet.DisplayName: Gungnir Bullet ScarletDevilProjectile.DisplayName: Spear the Gungnir @@ -242,7 +246,6 @@ SeafoamBubble.DisplayName: Seafoam Bubble SealedSingularityBlackhole.DisplayName: Sealed Blackhole SealedSingularityGore.DisplayName: Sealed Singularity Fragment SealedSingularityProj.DisplayName: Sealed Singularity -SearedPanProjectile.DisplayName: Pan SeraphimAngelicLight.DisplayName: Light Orb SeraphimAngelicLight2.DisplayName: Light Orb SeraphimBeamLarge.DisplayName: Holy Beam @@ -259,7 +262,6 @@ ShockTeslaAura.DisplayName: Electrifying Aura ShroomerangSpore.DisplayName: Infested Spore SkyBomberGas.DisplayName: Irradiated Cloud SkyfinNuke.DisplayName: Skyfin Nuke -SkyStabberProj.DisplayName: Sky Stabber SludgeSplotchProj1.DisplayName: Sludge Splotch SludgeSplotchProj2.DisplayName: Sludge Splotch SnapClamProj.DisplayName: Snap Clam @@ -273,6 +275,8 @@ SphereBladed.DisplayName: Bladed Sphere SphereBlue.DisplayName: Blue Thruster Sphere SphereSpiked.DisplayName: Spiked Sphere SphereYellow.DisplayName: Yellow Thruster Sphere +SporeKnifeBud.DisplayName: Spore Knife Bud +SporeKnifeProj.DisplayName: Spore Knife StealthNimbus.DisplayName: Nimbus StealthNimbusCloud.DisplayName: Nimbus StealthRain.DisplayName: Rain @@ -315,6 +319,9 @@ ValariBoomerang.DisplayName: Frostcrush Valari Valaricicle.DisplayName: Valaricicle Valaricicle2.DisplayName: Valaricicle ValedictionBoomerang.DisplayName: Valediction +VegaProjectile.DisplayName: Vega +VegaSpark.DisplayName: Vega Spark +VegaStar.DisplayName: Vega Star VeneratedKnife.DisplayName: Venerated Knife WaveSkipperProjectile.DisplayName: Wave Skipper WebBallBol.DisplayName: Web Ball @@ -325,9 +332,3 @@ WrathwingCinder.DisplayName: Wrathwing Eruption WrathwingFireball.DisplayName: Wrathwing Fireball WrathwingSpear.DisplayName: Wrathwing WulfrumKnifeProj.DisplayName: Wulfrum Knife -RadiationBurst.DisplayName: Radiation Burst -RadiationRain.DisplayName: Radiation Rain -RefractionRotorSlashCreator.DisplayName: Refraction Rotor Slash Creator -RefractionSlash.DisplayName: Refraction Slash -SporeKnifeProj.DisplayName: Spore Knife -SporeKnifeBud.DisplayName: Spore Knife Bud diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 3be6965766..612736762c 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -1,3 +1,5 @@ +AmphibiansGuitarMinion.DisplayName: Amphibian's Guitars +AmphibiansGuitarProjectile.DisplayName: Note AndromedaDeathRay.DisplayName: Beam AndromedaRegislash.DisplayName: Regislash AndromedaUI_Background.DisplayName: UI @@ -59,7 +61,7 @@ CausticStaffSummon.DisplayName: Caustic Dragon CelestialAxeMinion.DisplayName: Celestial Axe Cinder.DisplayName: Cinder CinderBlossom.DisplayName: Cinder Blossom -CloudElementalMinion.DisplayName: Cloudy Waifu +CloudElementalMinion.DisplayName: Cloud Elemental CnidarianJellyfishOnTheString.DisplayName: Cnidarian CnidarianSpark.DisplayName: Cnidarian Spark CorroslimeMinion.DisplayName: Corroslime @@ -90,6 +92,8 @@ DormantBrimseekerBab.DisplayName: Dormant Brimseeker DormantBrimseekerSummoner.DisplayName: Dormant Brimseeker Dreadmine.DisplayName: Dreadmine DreadmineTurret.DisplayName: Dreadmine Turret +EnchantedKnifeSummon.DisplayName: Enchanted Knife +EnchantedKnifeStaffProjectile.DisplayName: Enchanted Knife Beam EndoBeam.DisplayName: Endo Beam EndoCooperBody.DisplayName: Ascened Cooper EndoCooperLimbs.DisplayName: Ascened Cooper @@ -167,11 +171,10 @@ LostSoulGold.DisplayName: Gold Soul LostSoulLarge.DisplayName: Soul LostSoulSmall.DisplayName: Soul LuxorsGiftSummon.DisplayName: Luxor's Summon -MechwormBody.DisplayName: Mechworm -MechwormHead.DisplayName: Mechworm -MechwormLaser.DisplayName: Mechworm Laser -MechwormTail.DisplayName: Mechworm -MechwormTeleportRift.DisplayName: Rift +VoidEaterMarionetteBody.DisplayName: Void Eater Marionette +VoidEaterMarionetteHead.DisplayName: Void Eater Marionette +VoidEaterMarionetteTail.DisplayName: Void Eater Marionette +DoGWeaponTeleportRift.DisplayName: Rift MidnightSunBeaconProj.DisplayName: Midnight Sun Beacon MidnightSunBeam.DisplayName: Midnight Beam MidnightSunShot.DisplayName: Midnight Shot @@ -242,8 +245,8 @@ SandMark.DisplayName: Mark SandnadoMinion.DisplayName: Sandnado SandTornado.DisplayName: Tornado SarosAura.DisplayName: Saros Aura -SarosMicrosun.DisplayName: Saros Microsun SarosSunfire.DisplayName: Saros Sunfire +SarosEclipseBeam.DisplayName: Eclipse Beam SeashineSwordProj.DisplayName: Seashine Sword SeekerSummonProj.DisplayName: Soul Seeker SepulcherMinion.DisplayName: Sepulcher @@ -251,6 +254,7 @@ Shellfish.DisplayName: Shellfish SilvaCrystal.DisplayName: Silva Crystal SilvaCrystalExplosion.DisplayName: Silva Explosion SiriusBeam.DisplayName: Sirius Beam +SiriusQuasar.DisplayName: Sirius Quasar SiriusExplosion.DisplayName: Sirius Explosion SiriusMinion.DisplayName: Sirius SkeletalDragonChild.DisplayName: Skeletal Child @@ -275,9 +279,6 @@ MinionPlasmaBlast.DisplayName: Volatile Plasma Blast MinionPlasmaGas.DisplayName: Superheated Plasma Cloud MinionTeslaOrb.DisplayName: Tesla Sphere SmallSkeletonMinion.DisplayName: Small Skeleton -SolarBeam.DisplayName: Solar Beam -SolarGod.DisplayName: Vengeful Solar Spirit -SolarPixie.DisplayName: Solar Pixie Spikecrag.DisplayName: Spikecrag SpikecragSpike.DisplayName: Spikecrag Spike SquirrelSquireAcorn.DisplayName: Squirrel Acorn @@ -290,6 +291,8 @@ StormjawBaby.DisplayName: Stormjaw Baby SummonAstralExplosion.DisplayName: Explosion SummonBrimstoneExplosion.DisplayName: Explosion SummonBrimstoneExplosionSmall.DisplayName: Explosion +SunSpiritBeam.DisplayName: Sun Beam +SunSpiritMinion.DisplayName: Sun Spirit TacticalPlagueJet.DisplayName: Tactical Plague Jet TundraFlameBlossom.DisplayName: Tundra Flame Blossoms TundraFlameBlossomsOrb.DisplayName: Tundra Flame Blossoms Orb @@ -307,15 +310,16 @@ MagicUmbrella.DisplayName: Cyan Umbrella UniverseSplitterField.DisplayName: Field UniverseSplitterHugeBeam.DisplayName: Universe Splitter Ray UniverseSplitterSmallBeam.DisplayName: Universe Splitter Ray -UrchinSpike.DisplayName: Urchin Spike Valkyrie.DisplayName: Valkyrie -VictideSeaSnail.DisplayName: Sea Snail +VengefulSunBeam.DisplayName: Vengeful Sun Beam +VengefulSunSpiritMinion.DisplayName: Vengeful Sun Spirit VileFeederProjectile.DisplayName: Eater of Souls Mini VileFeederSummon.DisplayName: Baby Eater ViridVanguardBlade.DisplayName: Vanguard Blade VoidConcentrationAura.DisplayName: Concentrated Void Aura VoidConcentrationBlackhole.DisplayName: Black Hole VoidConcentrationOrb.DisplayName: Void Orb +VoidEaterMarionetteProjectile.DisplayName: Void Eater Marionette VolcanicFireballSummon.DisplayName: Volcanic Fireball WaterElementalMinion.DisplayName: Anahita WaterElementalSong.DisplayName: Siren Song @@ -331,7 +335,3 @@ WulfrumDroid.DisplayName: Wulfrum Droid WulfrumEnergyBurst.DisplayName: Wulfrum Bolt WulfrumFusionBolt.DisplayName: Fusion Bolt YharonMinionFireball.DisplayName: Dragon Fireball -FlarebatMinion.DisplayName: Flarebat -FrostbatMinion.DisplayName: Frostbat -AmphibiansGuitarMinion.DisplayName: Amphibian's Guitars -AmphibiansGuitarProjectile.DisplayName: Note diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 2d7cf3ef7b..4521bdd13e 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -5,16 +5,18 @@ AmuletEnergy.DisplayName: Sea Spirit ArcZap.DisplayName: Arc Zap ArtifactOfResilienceShards.DisplayName: Artifact Shard AscendantAura.DisplayName: Ascendant Aura -AstralFallingSand.DisplayName: Astral Falling Sand -AstralSandBallFalling.DisplayName: Astral Sand -AstralSandBallGun.DisplayName: Astral Sand +AstralSandBallFalling.DisplayName: Astral Sand Ball +AstralSandBallGun.DisplayName: Astral Sand Ball AstralSpray.DisplayName: Astral Spray AstralStar.DisplayName: Star AuricLandMineExplosion.DisplayName: Auric Land Mine Explosion BabyCannonballProjectile.DisplayName: Baby Cannonball Projectile BasicBurst.DisplayName: Nondescript Damaging Explosion +BasicBurstExclusive.DisplayName: Nondescript Damaging Explosion BasicPlagueBee.DisplayName: Basic Plague Bee +BatholithBangleProjectile.DisplayName: Granite Flash BlackGlassBandProjectile.DisplayName: Obsidian Strike +BlackPearlFalling.DisplayName: Black Pearl BlazingStarHeal.DisplayName: Blazing Star Heal BlazingStarThatDoesNotHeal.DisplayName: Blazing Star That Does Not Heal BlazingSun.DisplayName: Blazing Sun @@ -22,6 +24,7 @@ BlazingSun2.DisplayName: Blazing Sun BlissfulBombardierDustProjectile.DisplayName: Dust BloodBomb.DisplayName: Bomb BloodBombExplosion.DisplayName: Explosion +BloomStoneFlower.DisplayName: Bloom Stone Flower BlunderBoosterAura.DisplayName: Red Lightning Aura BobbitHead.DisplayName: Bobbit Head BossRushEffectThing.DisplayName: Boss Rush Effect Thing @@ -29,8 +32,8 @@ BossRushEndEffectThing.DisplayName: Boss Rush End Effect Thing BossRushFailureEffectThing.DisplayName: Boss Rush Failure Effect Thing BossRushTierAnimation.DisplayName: Boss Rush Tier Animation ChaoticGeyser.DisplayName: Chaotic Geyser -ChlorophyteLifePulse.DisplayName: Life Pulse ChronoClock.DisplayName: Chrono Clock +ClaretCannonProj.DisplayName: Claret Round CoralBubble.DisplayName: Bubble CoralBubbleSmall.DisplayName: Bubble CosmicDashExplosion.DisplayName: Cosmic Dash Explosion @@ -42,8 +45,11 @@ DarkIce.DisplayName: Dark Ice DeepseaBlaze.DisplayName: Deepsea Blaze DemonshadeRedDevil.DisplayName: Red Devil DevourerofCodsBobber.DisplayName: Devourer of Cods Bobber +DiamondOfTheDeepProjectile.DisplayName: Abyss Spirit DirectStrike.DisplayName: Nondescript Damaging Entity DragonDust.DisplayName: Dust +DunesandBallFalling.DisplayName: Dunesand Ball +DuneSandBallGun.DisplayName: Dunesand Ball EarlyBloomBobber.DisplayName: Early Bloom Bobber EmpyreanBlast.DisplayName: Empyrean Blast EmpyreanEmber.DisplayName: Empyrean Ember @@ -51,15 +57,18 @@ EmpyreanGlob.DisplayName: Empyeran Glob EmpyreanMarble.DisplayName: Empyrean Marble EmpyreanStellarDetritus.DisplayName: Empyrean Stellar Detritus EnergyShell.DisplayName: Energy Shell -EutrophicSandBallGun.DisplayName: Eutrophic Sand +EutrophicSandBallFalling.DisplayName: Eutrophic Sand Ball +EutrophicSandBallGun.DisplayName: Eutrophic Sand Ball ExoTankHoverThrust.DisplayName: Exo Thrust ExoTankLaser.DisplayName: Mini Exo Pulse Laser ExoTankMissile.DisplayName: Miracle Missile ExoTankMuzzleFlash.DisplayName: Mini Exo Flash FeralDoubleBobber.DisplayName: Feral Bobber +FestiveWingsOrnament.DisplayName: Ornament FlameLickedBarrage.DisplayName: Flame Licked Barrage FlameLickedHellblast.DisplayName: Flame Licked Hellblast FlashBolt.DisplayName: The Reminder +FriendlyLaserWallBeam.DisplayName: God's Bane Doombeam FuckYou.DisplayName: Explosion FungalClumpMinion.DisplayName: Fungal Clump GemTechArmorGem.DisplayName: Trireme's Gem @@ -77,6 +86,8 @@ HydrothermalSmoke.DisplayName: Smoke HydrothermicFlare.DisplayName: Hydrothermic Flare HydrothermicFlareRogue.DisplayName: Hydrothermic Flare HydrothermicSphere.DisplayName: Hydrothermic Sphere +HyperiusDamage.DisplayName: Hyperius Overflow +HyperiusBleed.DisplayName: Hyperius Bleed JewelSpike.DisplayName: Spike KelvinCatalystStar.DisplayName: Kelvin Catalyst Star LeviAmberDash.DisplayName: Riptide Slam @@ -98,18 +109,24 @@ PauldronDash.DisplayName: Pauldron Dash PauldronExplosion.DisplayName: Pauldron Explosion PearlAuraShard.DisplayName: Prism Shard PlaguePulse.DisplayName: Plague Pulse +PinkPearlFalling.DisplayName: Pink Pearl PoisonousSeawater.DisplayName: Seawater +PolypSandBallFalling.DisplayName: Polyp Sand Ball +PolypSandBallGun.DisplayName: Polyp Sand Ball +ProtolithBangleProjectile.DisplayName: Marble Shatter PscTransformAnimation.DisplayName: Psc Transform Animation PscTransformRocks.DisplayName: Psc Transform Rocks PuddleSplash.DisplayName: Puddle Splash -ReaverOrb.DisplayName: Reaver Orb ReaverThornBase.DisplayName: Thorn RedLabSeeker.DisplayName: Seeking Mechanism RelicGuard.DisplayName: Relic Guard RetaliationProjectile.DisplayName: Retaliation Shard RiftReelerBobber.DisplayName: Chaotic Bobber +RustyMedallionDroplet.DisplayName: Acid Droplet SandCloakVeil.DisplayName: Dust Veil SandExplosion.DisplayName: Sand +SCalAltarArenaVisual.DisplayName: Supreme Calamitas Arena Visual +ScionsCurioMini.DisplayName: Scions Curio Seashell.DisplayName: Seashell SepulcherSoul.DisplayName: Tormented Soul SerpentsBiteHook.DisplayName: Serpent's Bite @@ -126,7 +143,7 @@ StickyFeatherAero.DisplayName: Feather StomperSlam.DisplayName: Stomper Slam SuicideBomberDemon.DisplayName: Demon SulphuricAcidBubbleFriendly.DisplayName: Acid Bubble -SulphurousSandBallGun.DisplayName: Sulphurous Sand +SulphurousSandBallGun.DisplayName: Sulphurous Sand Ball TarraEnergy.DisplayName: Tarra Energy TarragonAura.DisplayName: Tarragon Aura TatteredFairyDust.DisplayName: Tattered Fairy Dust @@ -136,16 +153,23 @@ TransformerAura.DisplayName: Transformer Aura TransformerBlob.DisplayName: Transformer Shard UrsaSlash.DisplayName: Ursa Slash VerstaltiteBobber.DisplayName: Verstaltite Bobber +VictideBarrier.DisplayName: Tidal Barrier +VictideBobber.DisplayName: Snail Bobber +VictideSeaSnail.DisplayName: Sea Snail +VictideSpirit.DisplayName: Bubbly Spirit VoidFieldGenerator.DisplayName: Void Field Generator +VolcanicSandBallFalling.DisplayName: Volcanic Sand Ball +VolcanicSandBallGun.DisplayName: Volcanic Sand Ball WarbannerDamage.DisplayName: The Unmatched Power of the Sun WarbannerLight.DisplayName: Warbanner Light -WaterConvertor.DisplayName: Water Convertor WhiteLabSeeker.DisplayName: Seeking Mechanism +WhitePearlFalling.DisplayName: White Pearl WulfrumBobber.DisplayName: Wulfrum Bobber WulfrumDiggingTurtleProjectile.DisplayName: Digging Turtle WulfrumHook.DisplayName: Wulfrum Slingshot WulfrumLureSignal.DisplayName: Signal -YanmeisKnifeSlash.DisplayName: Yanmei's Knife YellowLabSeeker.DisplayName: Seeking Mechanism VoidofExtinctionCrit.DisplayName: Void of Extinction Crit XykDeathAnim.DisplayName: Xyk Death Animation +XykWings.DisplayName: Xyk Wings +StratusBlackHole.DisplayName: Stratus Singularity diff --git a/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson index 05300a04a6..3b293f65f6 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson @@ -3,9 +3,6 @@ SlimeGodRun: The Slime God flees to fight another day... // Cryogen CryogenBossText: Cryogen is derping out! PyrogenBossText: Pyrogen is derping out! -// Triplets -TripletsBossText: The Triplets have awoken! -TripletsDefeatName: The Triplets // Calamitas Clone CalamitasBossText: You underestimate my power... CalamitasBossText2: Rise again, my siblings. @@ -16,22 +13,36 @@ SandSharkText2: An enormous apex predator approaches... // Plaguebringer Goliath PlagueBossText: PLAGUE NUKE BARRAGE ARMED, PREPARING FOR LAUNCH!!! PlagueBossText2: MISSILES LAUNCHED, TARGETING ROUTINE INITIATED!!! -// Astrum Deus -DeusAltarRejectNightText: The god of the stars rejects your offering. The ritual can only be performed at night. // Providence ProfanedBossText: Holy flames burn away at your wings... // Polterghast GhostBossText2: Wails echo through the dilapidated dungeon halls... GhostBossText3: Long-dead prisoners seek their zealous revenge... // Devourer of Gods -EdgyBossText: Don't get cocky! -EdgyBossText2: A fatal mistake! -EdgyBossText3: Delicious... -EdgyBossText4: Did that hurt? -EdgyBossText5: It's not over yet! -EdgyBossText6: A GOD DOES NOT FEAR DEATH! -EdgyBossText7: You are no god... but I shall feast upon your essence regardless! -EdgyBossText8: You think...you can butcher...ME!? +DoGSpawn: You are no god... but I shall feast upon your essence regardless! +DoGSubphase1: You've done better than most, but don't get cocky! +DoGPhase2: It's not over yet, kid! +DoGPhase3: A GOD DOES NOT FEAR DEATH! +DoGHead1: Fall to your knees, worm! +DoGHead2: Let's see how much longer you'll last... +DoGHead3: Getting tired yet? +DoGHead4: You'll fall, just like the others! +DoGHead5: Give up! It'll be easier for both of us! +DoGHead6: Let me end you already! +DoGHead7: This is starting to get ridiculous...! +DoGHead8: How are you doing this?! +DoGHead9: Are you playing me for a fool?! +DoGHead10: Why won't you DIE?! +DoGHead11: FALL! +DoGHead12: BEGONE! +DoGHead13: DIE! +DoGHeadDeath1: Tasteless slop. +DoGHeadDeath2: Delicious... A feast worthy of a god! +DoGHeadDeath3: And STAY dead! +DoGHeadDeath4: WEAK. +DoGHeadDeath5: PATHETIC. ALL THAT RUNNING JUST TO DIE TO A SINGLE TOUCH?! +DoGHeadRunning: You can't run forever! +DoGHeadRunning2: WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?! // Yharon FlameText: The air is getting warmer around you. // Draedon (introduction) @@ -105,20 +116,20 @@ SCalDesparationText1Rematch: A terrific display, I concede this match to you. SCalDesparationText2Rematch: No doubt you will face enemies stronger than I. SCalDesparationText3Rematch: I trust you will not make the same mistakes he did. SCalDesparationText4Rematch: I can't imagine what your future holds now. -// Cirrus (GFB) -CirrusSummonText: Are you prepared for a task most Sisyphean? -CirrusBirbSwarmText: Those hearts are a bit too edgy. How about a swarm of birbs instead? -CirrusBH2Text: Feelin' thirsty? I can fix that! -CirrusBH3Text: Check out this cool toy I found! -CirrusDoGText: I told you the talking worms were real! But you didn't believe me! -CirrusPhase2Text: Time for a transformation! -CirrusBH4Text: It's HAGE time! -CirrusHallowBossSpamText: I have more friends than you could possibly imagine! -CirrusBH5Text: Hah! You're good, but I'm better! -CirrusSecondBirbSwarmText: Time for another swarm! -CirrusNonchalantText: I'm getting tired... -CirrusBruhText: Just kidding! Time for my special attack! -CirrusGiveUpText: Meh, whatever, I'm a bit tired of this. +// Permafrost (GFB) +PermafrostSummonText: Are you prepared for a task most Sisyphean? +PermafrostBirbSwarmText: Those hearts were a bit too brutal for my taste. How about some lovely birds instead? +PermafrostBH2Text: Getting tired from the battle, adventurer? Hungry? How does some Delicious Meat sound? +PermafrostBH3Text: Suprised at how I am holding my own again you? I did train Calamitas, after all! +PermafrostDoGText: The serpent!? How!? What is HE doing here!? Is he here to torment me further!? Kill it, adventurer! +PermafrostPhase2Text: Ha! I suppose I can no longer be "chill" about this duel! Get it? +PermafrostBH4Text: Need a break? Can you not even keep up with an old man? +PermafrostHallowBossSpamText: You truly have grown strong! Thankfully, I and Calamitas reconstructed this to assist me. +PermafrostBH5Text: Why, it has been quite long since I have had an excuse to use these magics! +PermafrostSecondBirbSwarmText: I must say, those birds earlier were rather cute! Do some more not sound nice? +PermafrostNonchalantText: I must say, I am not the mage I used to be. This is starting to tire my old body... +PermafrostBruhText: Ha! Just kidding! Watch what happens when I cast a spell I know! +PermafrostGiveUpText: Gah, I think I pulled a muscle! Ah, well. I seems that I must concede. Well fought! // April Fools AprilFools: The LORDE is approaching... AprilFoolsGFB: La Ruga is approaching... diff --git a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson index 472bb07020..3e976e6542 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson @@ -46,8 +46,6 @@ ChaliceOfTheBloodGod18: "{0} was reduced to a dry husk by the Chalice of the Blo ChaliceOfTheBloodGodClose: "{0} almost made it. Almost." ChaliceOfTheBloodGodUnequip: "{0} violated their pact with the Blood God." ChibiiDoggo: "{0} couldn't stand the sharp objects." -CirrusSlap1: "{0} was slapped too hard." -CirrusSlap2: "{0} forked around and found out." CorpusAvertor: "{0} became the Blood God's sacrifice." CrushDepth1: "{0} was crushed by the pressure." CrushDepth2: "{0}'s lungs collapsed." @@ -60,12 +58,17 @@ Dragonfire1: "{0}'s ashes scatter in the wind." Dragonfire2: "{0}'s embers fade away in a warm glow." Dragonfire3: "{0} can no longer feel the heat of the dragonfire." Dragonfire4: This was a fight {0} could not win. +DimensionalDrive: "{0} was blasted apart into space dust by the Dimensional Drive." +DivinityDevourer1: "{0} fell victim to the Divinity Devourer." +DivinityDevourer2: "{0} was consumed by the Divinity Devourer." +DivinityDevourer3: "{0}'s essence was snuffed by the Divinity Devourer." ElementalMix1: "{0} was reduced to technicolor confetti." ElementalMix2: "{0} was blasted apart by a harmonized elemental onslaught." ElementalMix3: "{0} was overwhelmed by elemental turbulence." -GodSlayerInferno1: "{0} imploded into nothingness." -GodSlayerInferno2: "{0}'s body slipped into oblivion." -GodSlayerInferno3: "{0} ceased being a part of our universe." +FlareGunOverheat: "{0}'s gun was simply too hot to handle." +GodSlayerInferno1: "{0}'s hopes and dreams were cremated." +GodSlayerInferno2: "{0}'s consciousness slipped into oblivion." +GodSlayerInferno3: "{0} ceased to be part of our universe." Goldfish: "{0} was once again impaled by Goldfish." HeavyBleeding1: "{0} expired from heavy internal bleeding." HeavyBleeding2: "{0} forgot that blood is supposed to stay inside the body." @@ -104,6 +107,8 @@ SulphuricPoisoning1: "{0} was melted by the toxic waste." SulphuricPoisoning2: "{0} ingested too many caustic chemicals." SulphuricPoisoning3: "{0} couldn't handle the industrial backwash." ThornBlossom: "{0} was violently pricked by a flower." +UltracosmicMaelstrom1: "{0} was sublimated by the Ultracosmic Maelstrom." +UltracosmicMaelstrom2: "{0} got cut down to size by the Ultracosmic Maelstrom." Vaporfied: "{0} vaporized into thin air." VermillionFlux1: "{0} burst apart in a shower of scarlet sparks." VermillionFlux2: "{0} went deathly stiff, still crackling with crimson." diff --git a/Localization/en-US/Mods.CalamityMod.Tiles.hjson b/Localization/en-US/Mods.CalamityMod.Tiles.hjson index 32316202fc..a88b068345 100644 --- a/Localization/en-US/Mods.CalamityMod.Tiles.hjson +++ b/Localization/en-US/Mods.CalamityMod.Tiles.hjson @@ -9,6 +9,8 @@ PirateCrate: Abandoned Crate // Basic Calamity Furniture Basin: Basin LavaFountain: Lava Fountain +BaroqueCello: Baroque Cello +Jukebox: Jukebox PipeOrgan: Pipe Organ Sconce: Sconce // Draedon Lab Furniture diff --git a/Localization/en-US/Mods.CalamityMod.UI.WindowTitle.hjson b/Localization/en-US/Mods.CalamityMod.UI.WindowTitle.hjson new file mode 100644 index 0000000000..b6aef90746 --- /dev/null +++ b/Localization/en-US/Mods.CalamityMod.UI.WindowTitle.hjson @@ -0,0 +1,43 @@ +0: Terraria: What a Calamity! +1: Terraria: Calamity: Also try Terraria +2: Terraria: Throw out the sunk with the seawater! +3: Terraria: Yhon vs Dron +4: Terraria: The Community cracks... +5: Terraria: Just don't get hit! +6: Terraria: May be missing critical features +7: Terraria: Perfectly ba-lanced +8: Terraria: Chalice of the Blood Game +9: Terraria: Oops, all bosses! +10: Terraria: Now with parries and defense damage! +11: Terraria: Free pulls daily, with hooks +12: Terraria: Not to be confused with Cataclysm +13: Terraria: Not to be confused with Catastrophe +14: Terraria: Bees may be upgraded with nanomachines +15: Terraria: Ontological Despoiler? I hardly knew her! +16: Terraria: Difficulty salad free with your meal +17: Terraria: Fresh out of water +18: Terraria: Future bosses, way in the past +19: Terraria: Another God Bites the Dust +20: Terraria: I call it... the Fogbound. +21: Terraria: Worms... why did it have to be worms +22: Terraria: 22 +23: Terraria: Tubular Bells.sf2 +24: Terraria: Now with more Acid Rain +25: Terraria: Reincarnated as a lotus flower +26: Terraria: Also try RAM! +27: Terraria: The chicken nugget of destiny +28: Terraria: Big Bad Auric Man +29: Terraria: Yes, it's still overpowered +30: Terraria: Beware of DoG +31: Terraria: Draedon, where's my car? +32: Terraria: This is a message to my master +33: Terraria: Honey Who Absorbed the Dragons +34: Terraria: Please disregard the Elementals +35: Terraria: Seahorse Scrutiny +36: Terraria: Trapped in the fish mines +37: Terraria: Find my paths +38: Terraria: Impaled by Goldfish +39: Terraria: Code merged without looking +40: Terraria: Endless Calamity +41: Terraria: Throwing is dead, long live rogue +42: Terraria: A Quick One Before the Nameless Serpent Devours Azafure diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index dc46a26af4..150728ab41 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -1,68 +1,85 @@ -// Vanilla UI edits SmallWorldWarning: "[c/FF0000:SMALL WORLDS NOT SUPPORTED BY CALAMITY]" -WorldMaster: Game over man, game over! (Brutally hard boss changes, for the truly brave) +// Main Menu Name +MainMenu: Calamity Style +MainMenuClassic: Calamity Style - Classic +MainMenuSunken: Calamity Style - Sunken // Main UI Elements Adrenaline: Adrenaline Nanomachines: Nanomachines Rage: Rage Flight: "{0} Flight Remaining" Charge: Current Charge +Vis: Current Vis DefenseDamage: Defense Damage SulphurousWater: Sulphuric Poisoning Stealth: Stealth -StealthShiftText: Hold SHIFT for more information on Rogue stealth +StealthShiftText: Hold Shift for more information on Rogue stealth StealthInfoText: ''' Rogue stealth builds while not attacking and slower while moving Once you have built max stealth, you will be able to perform a Stealth Strike Rogue stealth only reduces when you attack, it does not reduce while moving - The higher your rogue stealth the higher your rogue damage and crit + The higher your rogue stealth the higher your rogue damage Having more stealth regeneration slightly decreases the damage bonus from stealth This is offset by you being able to use stealth strikes far more often ''' // Difficulty UI DifficultyStatusText: "{0} is {1}." -ModeAppend: " Mode" +ModeAppend: "{0} Mode" Active: Active NotActive: Not active -DifficultyShiftText: "[c/737373:Hold the 'Shift' key for more information]" +DifficultyShiftText: "[c/737373:Hold Shift for more information]" CurrentlySelected: Currently Selected : {0} DifficultyClickText: "[c/919191:Click to select a difficulty mode]" ExpertDifficultyLock: "[c/919191:Higher difficulty modes can only be toggled in Expert Mode or above]" ChangingTheRules: "[c/919191:You cannot change the rules now!]" -NoDifficulty: None -NoDifficultyInfo: The classic Terraria experience, with no Calamity difficulty changes +DifficultySwitch: Difficulty changed from [c/{0}:{1}] to [c/{2}:{3}]. +ClassicInfo: Your Adventure Begins... A relaxed, casual Terraria experience +ExpertShortInfo: "[c/FF9900:Fortune & Glory, Kid. For those looking for a more difficult vanilla experience]" +ExpertExpandedInfo: + ''' + [c/A87A07:Most bosses gain new attacks and more difficult attack patterns] + [c/A87A07:Most enemies have twice as much health, deal twice as much damage and receive 10% less knockback] + [c/A87A07:Certain enemies have new attacks, can inflict new debuffs or have a higher chance of inflicting debuffs they already had] + [c/A87A07:Enemies drop more loot and have higher drop rates for their items] + [c/A87A07:Bosses have exclusive, signature "Expert drop" items] + [c/A87A07:Players drop more of their coins on death] + ''' +MasterShortInfo: "[c/FF2619:Game over man, game over! A tough step up in stats from Expert Mode]" +MasterExpandedInfo: + ''' + [c/bd5e6e:Most enemies have even more health and knockback resistance than in Expert Mode] + [c/bd5e6e:All foes deal even more damage than in Expert Mode] + [c/bd5e6e:Bosses have new exclusive vanity rewards] + [c/bd5e6e:Players drop ALL their coins on death] + [c/bd5e6e:Players gain an additional accessory slot at the start of the game] + ''' +LegendaryShortInfo: "[c/32CD32:For those who are worthy... Even higher stats than Master Mode]" +LegendaryExpandedInfo: "[c/0b870b:Enemies have further increased health and contact damage from Master Mode]" Revengeance: Revengeance -RevMaster: Rev+Master -RevLegend: Rev+Legend -RevengeanceEnabled: Revengeance Mode is enabled -RevengeanceShortInfo: "[c/F54254:The intended Calamity experience! Can only be enabled in Expert Mode!]" +RevengeanceShortInfo: "[c/F54254:The intended Calamity experience. Can only be enabled in Expert Mode]" RevengeanceExpandedInfo: ''' [c/B55362:Enables the] [c/85FFE9:Adrenaline] [c/B55362:mechanic. You gain Adrenaline while fighting bosses. Getting hit drops Adrenaline back to 0] [c/B55362: When Adrenaline is maxed, press] {1} [c/B55362:for a large damage boost] [c/B55362:Enables the] [c/FF8B54:Rage] [c/B55362:mechanic. You gain Rage when in proximity of enemies or by using certain items] [c/B55362: When Rage is maxed, press] {0} [c/B55362:for a temporary damage boost] - [c/B55362:Most foes have higher stats and more aggressive AIs] - [c/B55362:Bosses have new AI mechanics, new phases, and will drop Master Mode loot. Enemies spawn more frequently] - [c/F7342A:This mode is more difficult than Expert. Be sure to prepare for the challenge] + [c/B55362:Many enemies have new, more aggressive behavior patterns. Enemies spawn more frequently] + [c/B55362:All bosses have new attacks and patterns. Some are completely changed] + [c/B55362:Bosses will drop both "Expert drop" items and Master Mode's vanity rewards] ''' -RevengeanceActivate: Revengeance is active. -RevengeanceDeactivate: Revengeance is not active. Death: Death -DeathMaster: Death+Master -DeathLegend: Death+Legend -DeathEnabled: Death Mode is enabled -DeathShortInfo: "[c/C82DF7:A far more difficult challenge than Revengeance Mode! Can only be enabled in Master Mode!]" +DeathShortInfo: "[c/E066F7:A far greater challenge than Revengeance! Can only be enabled in Master Mode]" DeathExpandedInfo: ''' - [c/B834E0:All foes will pose a much larger threat with highly aggressive AIs and increased damage] - [c/B834E0:Bosses have substantially harder AI changes. Enemies are even more numerous and can easily overwhelm you] + [c/B834E0:Most basic enemies pose a much larger threat with highly aggressive behavior] + [c/B834E0:Blood Moons spawn unending waves of foes which can quickly overwhelm you] + [c/B834E0:Bosses are substantially faster and much more difficult than in Revengeance Mode] [c/B834E0:Debuffs are especially lethal and the Abyss is significantly more dangerous] - [c/E945FF:Vigilance and tenacity are crucial to survival] ''' -DeathActivate: Death is active; enjoy the fun. -DeathDeactivate: Death is not active; not fun enough for you? +Malice: Malice +MaliceShortInfo: "[c/f08080:For those who wish for suffering. Can only be enabled in Legendary Mode]" +MaliceExpandedInfo: "[c/a34e4e:Enemies have Death Mode and For The Worthy behavior with Legendary Mode stats]" // Calamity Health Bar ExoTwinsNameNormal: XS-01 Artemis and XS-03 Apollo ExoTwinsNameHekate: Eyes of XB-∞ Hekate @@ -87,16 +104,20 @@ Cooldowns: { BloodflareFrenzy: Blood Frenzy Cooldown BloodflareRangedSet: Bloodflare Soul Cooldown BrimflameFrenzy: Brimflame Frenzy Cooldown + BubblyBurrowActive: Bubbly Burrow + BubblyBurrowCooldown: Bubbly Burrow Cooldown ChaosState: Teleportation Cooldown + DarklightEnergy: Darklight Energy DivineBless: Divine Bless Cooldown - DivingPlatesBreaking: Abyssal Diving Suit Plates Durability - DivingPlatesBroken: Abyssal Diving Suit Broken Plates DSOCritCooldown: Extra Critical Strike Chance ParryCooldown: Parry Ability Cooldown + ElementalMastery: Elemental Mastery FleshTotem: Contact Damage Halving Cooldown + FuryFuel: Crystal Powder GaelsRage: Gael's Greatsword Rage Cooldown + BandCooldown: Band Cooldown GlobalDodge: Dodge Cooldown - GodSlayerDash: God Slayer Dash Cooldown + GodSlayerDash: Dimensional Drive Cooldown HellbornShots: Hellborn Shots HolyProtection: Holy Protection InkBomb: Ink Bomb Cooldown @@ -104,18 +125,21 @@ Cooldowns: { KillModeCooldown: Kill Mode Cooldown LifeSteal: Life Steal Cooldown LionHeartShield: Energy Shell Cooldown + M1GarandShots: Chambered Rounds MasterChefShieldDurability: MJOLNIR Shield Level MasterChefShieldRecharge: MJOLNIR Shield Recharge NebulousCore: Nebulous Core Cooldown OldDukeScalesFatigue: Stamina OmegaBlueActive: Abyssal Madness OmegaBlueCooldown: Abyssal Madness Cooldown + Panacea: Panacea Cooldown PermafrostConcoction: Permafrost's Concoction Cooldown PlagueBlackout: Plague Blackout Cooldown PotionSickness: Healing Cooldown PrismaticLaser: Prismatic Laser Barrage Cooldown ProfanedSoulShieldDurability: Profaned Soul Shield Durability ProfanedSoulShieldRecharge: Profaned Soul Shield Recharge + RaidersBoost: Extra Critical Strike Chance RelicOfResilienceCooldown: Relic of Resilience Cooldown RogueBooster: Rogue Booster Cooldown SandCloak: Sand Cloak Cooldown @@ -126,11 +150,13 @@ Cooldowns: { SpeedBlasterBoost: Speed Blaster Boost SpongeDurability: Sponge Barrier Durability SpongeRecharge: Sponge Barrier Recharge + Starburst: Stratus Starbursts SuperradiantSawBoost: Superradiant Saw Boost TarragonCloak: Tarragon Cloak Cooldown TarragonImmunity: Tarragon Immunity Cooldown UniverseSplitter: Universe Splitter Cooldown WarbanneroftheRighteousBuff: Warbanner Strength + WardingWave: Warding Wave Cooldown WulfrumBastionActive: Power Armor Durability WulfrumBastionCooldown: Wulfrum Bastion Cooldown WulfrumRoverDriveDurability: Protective Matrix Durability @@ -146,7 +172,7 @@ Evoke: Evoke Exit: Exit Communicate: Communicate ConfirmationText: Are you sure? -UpgradesRequired: Encryption unsolveable: Upgrades required. +UpgradesRequired: Encryption unsolvable: Upgrades required. ThanatosIcon: Thanatos, a serpentine terror with impervious armor and innumerable laser turrets. AresIcon: Ares, a heavyweight, diabolical monstrosity with four Exo superweapons. ArtemisApolloIcon: Artemis and Apollo, a pair of extremely persistent automatons with unstable energy reserves. @@ -205,13 +231,13 @@ Communication: { Inquiry: Your Origins Response: ''' - 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 + My first memories are that of awakening in a distant laboratory on the date of 1227-11-19, 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 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 - At the date of 7.30.1385, expansion of the laboratory became impractical. Thus, I chose to instead expand my horizons. I sent hundreds of remotely-piloted scoutbots to thoroughly survey the continent, ignorant of the attention such an endeavor would draw when not properly prepared.\n + At the date of 1385-07-30, expansion of the laboratory became impractical. Thus, I chose to instead expand my horizons. I sent hundreds of remotely-piloted scoutbots to thoroughly survey the continent, ignorant of the attention such an endeavor would draw when not properly prepared.\n In the following years, legends and rumors began to spread in nearby cities. Many spoke of encounters with roaming creatures made not of flesh and blood, but steel and oil. Scholars attempted to study my machines. Some explorers even followed my creations back to one of my several recon bodies.\n @@ -223,7 +249,7 @@ Communication: { Inquiry: Role in the Crusade Response: ''' - While the Crusade is widely considered to have begun on the date of 6.19.1781 with Yharon's rebirth, I took no part in it until 4.23.1803. Upon joining, I was chosen to lead the science and engineering divisions. While I was given freedom over which projects I chose and how I pursued them, it was expected that anything I made would be beneficial to the war effort.\n + While the Crusade is widely considered to have begun on the date of 1781-06-19 with Yharon's rebirth, I took no part in it until 1803-04-23. Upon joining, I was chosen to lead the science and engineering divisions. While I was given freedom over which projects I chose and how I pursued them, it was expected that anything I made would be beneficial to the war effort.\n Boosting the efficiency of mining operations was my first major contribution to Yharim's campaign, being essential to any further development. I learned how to mass produce the first generation of Excavators to expand mining operations outside of Azafure, and then used similar mass-producible technology to create arms and armaments that far outclassed our enemies'. Many simply dubbed this equipment "The Arsenal".\n @@ -325,9 +351,9 @@ Communication: { Inquiry: Yharim Response: ''' - The Godseeker. He once fascinated me nearly as much as you now do, both of you being unpredictable catalysts of a new era. I first heard word of him and the Crusade via scoutbot reports twenty-two years after the crusades began. While the rumors about Yharim himself and his war plans to conquer a city on the continent I was on intrigued me, another rumor demanded my full attention. Supposedly, he was accompanied by the Auric dragon that was the catalyst for the Auric dragons' rebirth.\n + The Godseeker. He once fascinated me nearly as much as you now do, both of you being unpredictable catalysts of a new era. I first heard word of him and the Crusade via scoutbot reports twenty-two years after the crusades began. While the rumors about Yharim himself and his war plans to conquer a city on the continent I was on intrigued me, another rumor demanded my full attention. Supposedly, he was accompanied by the auric dragon that was the catalyst for the auric dragons' rebirth.\n - I saw this as an opportunity that could not be missed. I modified a scoutbot to enable two-way communication and dispatched it to the city that was supposedly Yharim's target. I had expected it to arrive while the city was still under siege to have an edge in negotiations, but by the time my machine arrived, the city had fallen a week prior. Such military might was beyond anything I had deemed possible at the time. It was then the Godseeker interested me just as much as the Auric dragon did.\n + I saw this as an opportunity that could not be missed. I modified a scoutbot to enable two-way communication and dispatched it to the city that was supposedly Yharim's target. I had expected it to arrive while the city was still under siege to have an edge in negotiations, but by the time my machine arrived, the city had fallen a week prior. Such military might was beyond anything I had deemed possible at the time. It was then the Godseeker interested me just as much as the auric dragon did.\n Yharim was a very distinctive figure even then and it was not difficult to locate him. I found him in a charred street directing the cleanup effort. After he spotted my reconnaissance drone unexpectedly, we had a tense but brief negotiation. I discovered he had a passion for military history, as he quickly deduced that I was the source of the mysterious beings of steel and oil from centuries past. Despite the initial tension, I found him receptive to my offers after his realization. Perhaps he viewed me akin to a mythical force of nature not allied with the gods.\n @@ -337,7 +363,7 @@ Communication: { Though I was disappointed that I had little chance to study Yharon given he was what initially drew me to Yharim, I would be presented with many other opportunities throughout the next seventy-two years: the Archmage's magic, the Devourer's realm, and the Witch's power were the most notable. The Crusade taught me that I progressed faster with external aid, even if it only served as inspiration.\n - My last interaction with Yharim was not even a year before I first observed you. He had come to me some months after his nearly fatal encounter with Braelor and Statis and requested that I enhance his Auric armor with my newly-invented exotechnology. We spoke little before he departed to the Dragon Aerie, and I believe him to still be there. + My last interaction with Yharim was not even a year before I first observed you. He had come to me some months after his nearly fatal encounter with Braelor and Statis and requested that I enhance his auric armor with my newly-invented exotechnology. We spoke little before he departed to the Dragon Aerie, and I believe him to still be there. ''' } @@ -349,11 +375,11 @@ 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 + 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 + 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. + 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. ''' } @@ -417,9 +443,9 @@ Communication: { ''' The "Mechanical Trio", as most call them, are what you annoyingly refer to as The Destroyer, Retinazer & Spazmatism, and, though it pains me to call it this, "Skeletron Prime". While you may be an exceptional individual, I question your naming capabilities. For your information, their formal designations are HM-03, HSx-00, HSy-01, and HF-04 respectively.\n - They were a rudimentary but potent start to my experimentation with engines of war. In search of inspiration, I turned to study the gods and their purportedly unmatched might. While each deity wielded a unique worldly aspect, all drew their strength from an identical source: the soul of an Auric dragon.\n + They were a rudimentary but potent start to my experimentation with engines of war. In search of inspiration, I turned to study the gods and their purportedly unmatched might. While each deity wielded a unique worldly aspect, all drew their strength from an identical source: the soul of an auric dragon.\n - As acquiring an Auric soul was and still is infeasible, experiments with more mundane souls soon began. I was initially discouraged upon discovering that individual souls held a paltry amount of spiritual power, but their potential when coalesced far surpassed my predictions.\n + As acquiring an auric soul was and still is infeasible, experiments with more mundane souls soon began. I was initially discouraged upon discovering that individual souls held a paltry amount of spiritual power, but their potential when coalesced far surpassed my predictions.\n Upon further research, I confirmed that a soul's strength is defined by its intense emotions or resolve. Here, Yharim's unrivaled charisma and skill at evoking passion within the hearts of others was key. Not only was finding a source of emblazoned souls trivial, but many of his most stalwart troops even directly consented to having their souls embedded in my machines after their demise at the hands of the enemy.\n @@ -513,7 +539,7 @@ Exhumed: { Indignant: { DisplayName: Indignant - Description: Summons demons that harm you but drop healing items on death on item usage. + Description: Summons demons that harm you but drop healing orbs on death on item usage. } Aflame: { @@ -589,17 +615,30 @@ Lecherous: { Disenchant: Disenchant // Worldgen Tasks +BetterUnderworld: Creating a smoother Underworld +BetterShimmer: Placing shimmer in a sane location +UnderworldStructures: Remnants of an Azafurian and Demonic war +UnderworldTreesAndGrass: Growing Underworld flora +UnderworldGeyserTraps: Adding an Underworld minefield +ShimmerShrine: Excavating an ancient shimmer well EvilIslandCorrupt: Adding a putrid floating island EvilIslandCrimson: Adding a grotesque floating island AstralChest: Placing an astral chest +LivingMahoganyTree: Growing a giant jungle tree BetterJungleTemple: Building a bigger jungle temple JungleTempleAltar: Placing the Lihzahrd altar GiantBeehive: Building a giant beehive MechanicShed: Placing mechanic shed VernalPass: Blessing a flourishing jungle grove SunkenSea: Partially flooding an overblown desert +TimelessShores: Digging a subaquatic graveyard +RadiantReefs: Making the sea sparkle and shine +PolypForest: Adding life to nutrient-rich waters +GleamingBurrows: Burying pearls and catching caustics +BasaltGully: Provoking volcanic activity below the sea GemAdjustment: Sensibly shuffling gem depth DungeonArchive: Entombing occult literature +Planetoids: Enriching low Terraria orbit SulphurSea: Polluting one of the oceans BrimstoneCrags: Incinerating Azafure HiddenShrines: Hiding forbidden shrines @@ -625,8 +664,8 @@ SulphurSea2: Irradiating one of the oceans Roxcalibur: I wanna rock AuricLandMines: Setting god killing traps // Hold Shift tooltip default -HoldShiftTooltipExtensionIndicator: Hold "Left Shift" for more -HoldShiftTooltipReplacementIndicator: Hold "Left Shift" for details +HoldShiftTooltipExtensionIndicator: Hold Shift for more +HoldShiftTooltipReplacementIndicator: Hold Shift for details // Dev and Donor Items DevItemTooltip: - Dev Item - DonorItemTooltip: - Donor Item - diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson index 718270c4af..4fe4d6f239 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson @@ -10,15 +10,6 @@ SetBonus: { Melee: 15% increased melee speed and 20% increased movement speed } - Chlorophyte: - ''' - Summons a powerful leaf crystal to shoot pulses of life every {0} seconds - The pulses do a base damage of {1} to enemies within its range - The pulses also provide a {2} health boost to you and all players on your team - Players healed by pulses cannot be healed by another pulse until {3} seconds have passed - Both the health boost and the damage scale based on your strongest class - ''' - Cobalt: { $parentVal: ''' @@ -28,7 +19,7 @@ SetBonus: { Melee: 10% increased melee damage } - Copper: Increases all damage by 2 + Copper: Increases all damage by {0} Crimson: ''' Greatly increased natural life regen @@ -37,9 +28,8 @@ SetBonus: { ''' Eskimo: ''' - Multiplies all cold-based debuff damage by 1.25x - Cold enemies will deal reduced contact damage to the player - Provides immunity to the Chilled, Frozen, Frostburn and Glacial State debuffs + 25% increased Cold debuff damage + Provides immunity to the Chilled, Frozen, and Frostburn debuffs ''' Rain: ''' @@ -49,7 +39,7 @@ SetBonus: { ''' Forbidden: ''' - {$LegacyTooltip.48} {$ArmorSetBonus.Forbidden} + {$LegacyTooltip.48} {0} to call an ancient storm to the cursor location Minions no longer deal less damage while wielding magic weapons ''' Frost: @@ -60,27 +50,18 @@ SetBonus: { ''' Gladiator: ''' - +3 defense +60 maximum stealth 5% increased rogue damage and 10% increased velocity ''' Gold: ''' - All enemies have a 2% chance to drop 1 gold; bosses killed drop 3 gold - You gain 1% critical strike chance for every 10 gold in your inventory, capped at 7% - ''' - Iron: - ''' - Increases damage reduction by 6% - +1 HP/s life regen + All enemies have a {0}% chance to drop 1 extra gold + All bosses drop {1} extra gold + You gain {2}% critical strike chance for every gold in your inventory, capped at {3}% ''' + Iron: Multiplies all player-inflicted knockback by {0}x Jungle: 10% reduced mana costs - Lead: - ''' - Increases damage reduction by 4% - +0.5 HP/s life regen - Grants immunity to knockback - ''' + Lead: Grants immunity to knockback Meteor: All magic guns cost 33% mana Mining: Mining ore will sometimes have additional yield Molten: @@ -89,17 +70,8 @@ SetBonus: { 10% extra true melee damage Grants immunity to fire blocks and temporary immunity to lava ''' - MonkTier2: - ''' - 10% increased rogue damage and critical strike chance - 15% increased summon damage - +90 maximum stealth - ''' - MonkTier3: - ''' - 10% increased rogue damage and 20% increased summon damage - +100 maximum stealth - ''' + MonkTier2: "{$Common.RogueStealth}" + MonkTier3: "{$Common.RogueStealth}" Mythril: ''' Enemy hits release mythril flares, which home in on enemies after a short delay @@ -126,28 +98,20 @@ SetBonus: { Grants +2 HP/s life regeneration after striking an enemy This life regeneration bypasses negative life regeneration ''' - PlatinumChainmail: 3% increased critical strike chance - Platinum: - ''' - Every 10 extra defense gives you 1% increased damage - The 20 defense from the Platinum Armor itself does not contribute to this effect - Bonus damage caps at 50 extra defense - ''' + Platinum: Increases damage reduction by {0}% Silver: ''' - +0.5 HP/s life regen - Two seconds after getting hit for 20 or more damage, you heal for 10 + {0} seconds after getting hit for {1} or more damage, you heal for {2} Getting hit again resets the timer, delaying the heal ''' - Tin: Increases armor penetration by 5 - Tungsten: - ''' - Increases your critical strike chance by 100% of the knockback of your held weapon - This effect caps at Insane knockback, which gives 10% increased critical strike chance - Increases all knockback by 33%, this counts for the above boost - Current bonus: {0}% critical strike chance from {1} knockback - ''' + Tin: "{0}% increased critical strike chance" + Tungsten: Grappling hooks pull and retract {0}% faster MagicHat: Increases maximum mana by 40 + Vortex: + ''' + {$LegacyTooltip.48} {0} to toggle stealth, + increasing ranged ability and reducing chance for enemies to target you but slowing movement speed + ''' Wizard: 4% increased magic critical strike chance CrystalAssassin: ''' @@ -155,20 +119,6 @@ SetBonus: { 10% increased damage and critical strike chance +90 maximum stealth ''' - SquireTier2: - ''' - Grants +1.5 HP/s life regen - 15% increased summon damage and 10% increased melee critical strike chance - ''' - HuntressTier2: 10% increased summon and ranged damage - ApprenticeTier2: 10% increased summon damage and magic critical strike chance - SquireTier3: - ''' - Grants +3 HP/s life regen - 10% increased summon damage and 15% increased melee critical strike chance - ''' - HuntressTier3: 10% increased summon and ranged damage - ApprenticeTier3: 15% increased summon damage and magic critical strike chance SpectreHealing: ''' Converts magic damage to healing force diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.Wings.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.Wings.hjson index 9edc92b12c..2a9963a8f4 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.Wings.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.Wings.hjson @@ -1,19 +1,14 @@ -BatWings: Improved vision -BeeWings: Permanently gives the Honey buff +BeeWings: Decreases fall speed while not pressing {$Key.DOWN} BoneWings: Halves flight time when taking a hit -ButterflyWings: Increases mana regeneration rate -FestiveWings: Homing ornaments rain down as you fly -FinWings: +DemonWings: Increases fall speed +FestiveWings: Spawns ornaments which restore flight time +FinWings: Allows quick travel in water +TatteredFairyWings: Leaves a trail of flight draining fairy dust +WingsNebula: Greatly increases the pickup range of Nebula armor's nebula boosters while hovering +WingsSolar: Solar Flare armor's shield restores flight time whenever a charge is consumed +WingsStardust: ''' - Gills effect and you can move freely through liquids - You fall faster while submerged in liquid + Greatly increases Stardust armor's stardust guardian attack range + Stardust guardian damage increases the lower your flight time ''' -FlameWings: Multiplies all heat debuff damage by 1.25x -FrozenWings: Multiplies all cold debuff damage by 1.25x -HarpyWings: 10% increased movement speed -LeafWings: +10 defense and permanent Dryad's Blessing -TatteredFairyWings: You leave a trail of fairy dust as you fly -WingsNebula: Increases the pickup range of Nebula armor's nebula boosters -WingsSolar: Allows Solar Flare armor's dash to be used without any charges -WingsStardust: Greatly increases Stardust armor's stardust guardian damage and attack range -WingsVortex: Vortex armor's stealth ability is automatically reactivated 1 second after dashing +WingsVortex: Vortex armor's stealth gradually restores flight time while activated diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index 198423a825..dabf9366a9 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -1,3 +1,4 @@ +DashKey: Press {0} while facing a direction DodgeInfo: ''' Grants the ability to dodge attacks @@ -7,13 +8,37 @@ DodgeInfo: ''' AddedTooltip: { + /* + Accessories + */ + TitanGloveLine: 10% increased true melee damage + YoyoGlove: Secondary yoyos will do 50% less damage + // Also used by Sniper Scope + EyeoftheGolem: 15% increased critical strike damage + RifleScope: The scope effect can be toggled with visibility + ArcaneFlower: 5% increased magic damage + HellfireTreads: + ''' + 50% increased Heat debuff damage, does not stack with downgrades + All attacks inflict Hellfire + ''' + FairyBoots: + ''' + Fairies can spawn at any time on the surface and spawn far more frequently + Nearby fairies grant +2 HP/s life regen, 6 defense and 10% movement speed + Fairies are immune to damage and will no longer flee + ''' + FleshKnucklesLine: Max life increased by 25 + HandWarmer: Provides a regeneration boost while wearing the Snow armor + /* + Others + */ TruffleWorm: ''' Summons Duke Fishron if used as bait in the Ocean Enrages outside the Ocean ''' SlimeGun: Slimed enemies take more damage from fire-based debuffs - FleshKnucklesLine: Max life increased by 45 RodofDiscord: Teleportation is disabled while Chaos State is active Pwnhammer: ''' @@ -26,64 +51,34 @@ AddedTooltip: { This grants +1.5 HP/s life regen and accelerates natural life regen Life drain stacks based on the number of enemies being hit ''' - WarmthPotion: Greatly reduces the duration of Chilled, Frozen, and Glacial State - HandWarmer: Provides a regeneration boost while wearing the Snow armor GoldenFishingRod: Its fishing line will never break Tombstones: ''' 13 of any tombstone turns the surrounding area into a graveyard Graveyards have various new item sales and recipes ''' - DeathSickle: Inflicts Whispering Death on hit - HellfireTreads: - ''' - Multiplies all fire-based debuff damage by 1.5x, does not stack with downgrades - All attacks inflict Hellfire - ''' - FairyBoots: - ''' - Fairies can spawn at any time on the surface and spawn far more frequently - Nearby fairies grant +2 HP/s life regen, 10 defense and 10% movement speed - Fairies are immune to damage and will no longer flee - ''' - MoonStone: Reduces the damage of the Nightwither debuff - SunStone: Reduces the damage of the Daybroken debuff - CelestialStone: Reduces the damage of the Nightwither and Daybroken debuffs - ArcaneFlower: 5% increased magic damage - RifleScope: The scope effect can be toggled with visibility FeatherfallPotion: Disables all airborne flight recovery - TitanGloveLine: 10% increased true melee damage - YoyoGlove: Secondary yoyos will do 50% less damage - DefensePrefix: +{0}% damage reduction - LuckyPrefix: +0.05 luck - /* - Armor - */ - CopperHelmet: 5% increased damage - CopperChainmail: 3% increased critical strike chance - CopperGreaves: 5% increased movement speed - TinHelmet: 3% increased critical strike chance - TinChainmail: +0.5 HP/s life regen - TinGreaves: 5% increased movement speed - IronPieces: Increases damage reduction by 3% - LeadPieces: Increases damage reduction by 2% - SilverHelmet: 5% increased critical strike chance - SilverChainmail: +1 HP/s life regen - SilverGreaves: 8% increased movement speed - TungstenHelmet: 7% increased damage - TungstenChainmail: +0.5 HP/s life regen - TungstenGreaves: 8% increased movement speed - GoldHelmet: 5% increased damage - GoldChainmail: Increases damage reduction by 5% - GoldGreaves: 10% increased movement speed - PlatinumHelmet: 6% increased damage - PlatinumChainmail: 3% increased critical strike chance - PlatinumGreaves: 10% increased movement speed - CrimsonBreastplate: +1 HP/s life regen - CrimsonOtherPieces: +0.5 HP/s life regen + CrimsonArmorPieces: +0.5 HP/s life regen Picksaw: Can mine Scoria Ore located in the Abyss } +PrefixTooltip: { + ArcaneBuffStat: + ''' + +{0} max mana + +{1}% magic damage + -{2}% mana cost + ''' + ArmorPenStat: +{0} armor penetration + CritStat: +{0}% critical strike chance + DamageStat: +{0}% damage + DefenseStat: +{0} defense + DRStat: +{0}% damage reduction + LuckStat: +{0} luck + MeleeSpeedStat: +{0}% melee speed + SpeedStat: +{0}% movement speed +} + EditedTooltip: { /* Boss Summons @@ -96,7 +91,7 @@ EditedTooltip: { BloodySpine: ''' Summons the Brain of Cthulhu when used in the Crimson - Enrages outside the Underground Crimson + Despawns outside the Crimson ''' ClothierVoodooDoll: ''' @@ -115,41 +110,23 @@ EditedTooltip: { Summons the Golem when used at the Lihzahrd Altar Enrages outside the Jungle Temple ''' - MechanicalEye: - ''' - Summons The Twins when used during nighttime - Enrages during the day - ''' + MechanicalEye: Summons The Twins when used during nighttime MechanicalSkull: ''' Summons Skeletron Prime when used during nighttime Enrages during the day ''' - MechanicalWorm: - ''' - Summons The Destroyer when used during nighttime - Enrages during the day - ''' + MechanicalWorm: Summons The Destroyer when used during nighttime QueenSlimeCrystal: Summons Queen Slime when used in the Hallow - SuspiciousLookingEye: - ''' - Summons the Eye of Cthulhu when used during nighttime - Enrages during the day - ''' + SuspiciousLookingEye: Summons the Eye of Cthulhu when used during nighttime WormFood: ''' Summons the Eater of Worlds when used in the Corruption - Enrages outside the Underground Corruption + Despawns outside the Corruption ''' - MasterExclusive: Master or Revengeance - // Sparkle Slime Balloon - GelBalloon: - ''' - Throws a mixture of slime and sparkling crystals - Slimed enemies take more damage from fire-based debuffs - ''' - AnkhShield1: Grants immunity to knockback - AnkhShield2: Grants immunity to most debuffs, including Mighty Wind + /* + Life Regen + */ Campfires: Life regen is increased by 0.5 HP/s when near a campfire HeartLantern: Grants +1 HP/s life regeneration when placed nearby BottledHoney: @@ -162,45 +139,31 @@ EditedTooltip: { CharmofMyths: Grants +1 HP/s life regeneration and reduces the cooldown of healing potions by 25% RegenerationPotion: Provides +2 HP/s life regeneration HamBat: Defeating enemies temporarily grants +3 HP/s life regen - // Arcane Crystal + // Vital Crystal AegisCrystal: Permanently boosts natural life regeneration - ArcheryPotion: 20% increased arrow speed and 5% increased arrow damage - IronskinPotion: Increase defense by {0} - // Aerial Bane - DD2BetsyBow: Shoots a tight spread of 6 splitting arrows - AleSake: - ''' - Increases melee damage by 10% and reduces defense by 5% - Counts as an alcohol for Alcohol Poisoning - {$Common.AlcoholWarning} - ''' - FlameWakerBoots: - ''' - Multiplies all fire-based debuff damage by 1.25x - All attacks light enemies on fire - 'Never get cold feet again' - ''' + /* + OOA armors + */ + ApprenticeHat: Increases your max number of sentries by 1, 10% reduced mana cost + ApprenticeRobe: 15% increased summon damage and magic damage + ApprenticeTrousers: 10% increased summon damage, 15% increased magic critical strike chance, 20% increased movement speed + SquireGreatHelm: Increases your max number of sentries by 1 and grants +2 HP/s life regen + SquireGreaves: 10% increased summon damage, 15% increased melee critical strike chance and movement speed + MonkBrows: Increases your max number of sentries by 1 and increases rogue velocity by 15% + MonkShirt: 15% increased summon and rogue damage + MonkPants: 15% increased rogue critical strike chance and 20% increased movement speed + // Valhalla Knight + SquireAltShirt: 30% increased summon damage and grants +4 HP/s life regen + // Shinobi Infiltrator + MonkAltHead: Increases your max number of sentries by 2 and increases summon & rogue damage by 20% + MonkAltShirt0: 20% increased summon damage and rogue velocity + MonkAltShirt1: 5% increased rogue critical strike chance + MonkAltPants: 10% increased summon damage and rogue critical strike chance + /* + Accessories + */ SunMoonStones: critical strike chance, life regeneration, CelestialStoneShell: Minor increase to damage, - MagnetFlower: 10% reduced mana cost - ArcaneFlowerManaCloak: 12% reduced mana cost - Magiluminescence: - ''' - Increases movement acceleration and deceleration by 1.75x - Increases movement speed by 1.15x. This bonus applies to running boot accessories - ''' - FrogLeg: Increases jump speed by {0}% and allows auto-jump - // Soaring Insignia - EmpressFlightBooster1: Increases wing flight time by 33% - EmpressFlightBooster2: Increases movement and jump speed by 10% and acceleration by 1.25x - RifleScope1: Increase view range for guns (Right click to zoom out) - RifleScope2: The scope effect can be toggled with visibility - SniperScope: 7% increased ranged damage and critical strike chance - MagicQuiver: Increases arrow damage by 5% and greatly increases arrow speed - MoltenQuiver1: Increases arrow damage by 7% and greatly increases arrow speed - MoltenQuiver2: Lights wooden arrows ablaze and all arrows inflict Hellfire - MagicPowerPotion: 10% increased magic damage - MagicHat: 6% increased magic critical strike chance PowerGlove: 10% increased melee speed, does not stack with downgrades BerserkerGlove: 10% increased true melee damage MechanicalGlove: @@ -214,10 +177,49 @@ EditedTooltip: { 14% increased melee damage 14% increased melee speed, does not stack with downgrades ''' - ObsidianSkullLine: Grants immunity to the Burning and On Fire! debuffs - LavaWaders: Grants immunity to the Burning and On Fire! debuffs, and 7 seconds of immunity to lava + MoltenQuiver: Lights wooden arrows ablaze and all arrows inflict Hellfire + RifleScope1: Increase view range for guns ( to zoom out) + RifleScope2: The scope effect can be toggled with visibility + SniperScope: 12% increased ranged critical strike chance + Magiluminescence: + ''' + Increases movement acceleration and deceleration by 1.75x + Increases movement speed by 1.15x. This bonus applies to running boot accessories + ''' + FrogLeg: Increases jump speed by {0}% and allows auto-jump + // Soaring Insignia + EmpressFlightBooster1: Increases wing flight time by 33% + EmpressFlightBooster2: Increases movement speed by 7.5%, jump speed by 10%, and acceleration by 1.25x + GravityGlobe: + ''' + Provides 32% increased jump speed and increased fall speed + Provides a gravitational boost jump, which recharges whenever gravity is flipped + Slightly improves wingless air movement speed + Press {$Key.UP} to change gravity + Press {$Key.DOWN} to fall faster + ''' + FlameWakerBoots: + ''' + 25% increased Heat debuff damage + All attacks light enemies on fire + 'Never get cold feet again' + ''' + /* + Armor + */ + MagicHat: 6% increased magic critical strike chance Gi: 10% increased movement and jump speed - GoldPickaxe: Can mine Demonite, Crimtane, Meteorite, Sea Prisms, and Sea Prism Crystals + SolarFlarePieces: Grants +1 HP/s life regeneration + /* + Potions + */ + ArcheryPotion: 5% increased arrow damage and 20% increased arrow speed + AleSake: + ''' + Increases melee weapon scale by 15%, but decreases melee speed by 10% + Counts as an alcohol for Alcohol Poisoning + {$Common.AlcoholWarning} + ''' FlaskofCursedFlames: Melee, Whip, and Rogue attacks inflict enemies with cursed flames FlaskofFire: Melee, Whip, and Rogue attacks set enemies on fire FlaskofGold: Melee, Whip, and Rogue attacks make enemies drop more gold @@ -226,54 +228,22 @@ EditedTooltip: { FlaskofParty: All attacks cause confetti to appear FlaskofPoison: Melee, Whip, and Rogue attacks poison enemies FlaskofVenom: Melee, Whip, and Rogue attacks inflict Acid Venom on enemies - SolarFlarePieces: Grants +1 HP/s life regeneration /* - OOA sets + Others */ - SquireGreatHelm: Increases your max number of sentries by 1 and grants +0.5 HP/s life regen - SquirePlating: 5% increased summon damage and 15% increased melee damage - SquireGreaves: + // Aerial Bane + DD2BetsyBow: Shoots a tight spread of 6 splitting arrows + GoldPickaxe: Can mine Demonite, Crimtane, Meteorite, Sea Prisms, and Sea Prism Crystals + MasterExclusive: Master or Revengeance + // Sparkle Slime Balloon + GelBalloon: ''' - 5% increased summon damage and melee critical strike chance - 15% increased movement speed + Throws a mixture of slime and sparkling crystals + Slimed enemies take more damage from fire-based debuffs ''' - MonkBrows: Increases your max number of sentries by 1 and increases rogue velocity by 10% - MonkShirt: 5% increased summon and rogue damage - MonkPants1: 5% increased summon damage and rogue critical strike chance - MonkPants2: 20% increased movement speed - // Valhalla Knight - SquireAltHead: Increases your max number of sentries by 2 and increases summon and melee damage by 15% - SquireAltShirt: 15% increased summon damage and grants +1 HP/s life regen - SquireAltPants: 10% increased summon damage - HuntressJerkin: - ''' - 10% increased summon damage and 5% increased ranged damage and critical strike chance - 10% chance to not consume ammo - ''' - HuntressPants: 5% increased summon damage and 20% increased movement speed - ApprenticeHat: Increases your max number of sentries by 1, 5% increased magic damage and 10% reduced mana cost - ApprenticeRobe: 10% increased summon and magic damage - ApprenticeTrousers: - ''' - 5% increased summon damage and magic critical strike chance - 20% increased movement speed - ''' - // Shinobi Infiltrator - MonkAltHead: - ''' - Increases your max number of sentries by 2 - 10% increased summon and rogue damage - ''' - MonkAltShirt0: 10% increased summon damage and 15% increased rogue velocity - MonkAltShirt1: 5% increased rogue critical strike chance - MonkAltPants: 10% increased summon damage and rogue critical strike chance - // Red Riding - HuntressAltShirt: 10% increased summon and ranged damage and 20% chance to not consume ammo - HuntressAltPants: 20% increased summon damage and 5% increased ranged critical strike chance - // Dark Artist - ApprenticeAltHead: 10% increased summon & magic damage - ApprenticeAltShirt: 15% increased summon damage and 10% increased magic damage - ApprenticeAltPants: 10% increased summon damage + // Ancient Manipulator + LunarCraftingStation: Used to craft items from Lunar Fragments, Luminite, and Astral Bars + AnkhShield: Grants immunity to most debuffs, including Mighty Wind } // Buff Descriptions @@ -281,8 +251,7 @@ BuffDescription: { Banner: You have increased damage and defense against the following: BeetleMight: Melee damage and speed increase by {0}% and {1}% respectively ChaosState: Rod of Discord teleports are disabled - LeafCrystal: Emits powerful life pulses at nearby enemies - WarmthExtra: Reduced durations of Chilled, Frozen, and Glacial State + Rabies: Decreased life regen, Causes status effects WeaponImbueConfetti: All attacks cause confetti to appear WeaponImbueCursedFlames: Melee, Whip, and Rogue attacks inflict enemies with cursed flames WeaponImbueFire: Melee, Whip, and Rogue attacks set enemies on fire @@ -326,7 +295,6 @@ DemolitionistChat: { DryadChat: { DarksunEclipse: There's a dark solar energy emanating from the moths that appear during this time. What's up with moths getting stronger as you do too? Hardmode: That starborne illness sits upon this land like a blister. Do even more vile forces of corruption exist in worlds beyond? - DrunkPrincessShroom: "{0} put me up to this." Mushroom: I'm not here for any reason! Just picking up mushrooms for uh, later use. SulphurSea: My Goddess is resting deep below this sea. If you may excuse me, I wish to pay my respects to her alone. } @@ -364,7 +332,6 @@ MechanicChat: { MoonLordDefeated: What do you mean your traps aren't making the cut? Don't look at me! Eclipse: Um... should my nightlight be on? AcidRain: Maybe I should've waterproofed my gadgets... They're starting to corrode. - DrunkPrincess: Well, I like {0}, but I, ah... I have my eyes on someone else. } MerchantChat: { @@ -374,8 +341,6 @@ MerchantChat: { Bandit: I happen to have several Angel Statues at the moment, a truely rare commodity. Want one? } -NurseChat.HealNotAllowed: Now is not the time! - PainterChat: { Corruption: A little sickness isn't going to stop me from doing my work as an artist! Crimson: There's a surprising art to this area. A sort of horrifying, eldritch feeling. It inspires me! @@ -394,7 +359,6 @@ PainterChat: { } PartyGirlChat: { - DrunkPrincess: I have a feeling we're going to have absolutely fantastic parties with {0} around! Eclipse1: I think my light display is turning into an accidental bug zapper. At least the monsters are enjoying it. Eclipse2: Ooh! I love parties where everyone wears a scary costume! } @@ -402,7 +366,6 @@ PartyGirlChat: { PirateChat: { PreLeviathan: Aye, I've heard of a mythical creature in the oceans, singing with an alluring voice. Careful when yer fishin out there. WetScourgeDefeated: I have to thank ye again for takin' care of that sea serpent. Or was that another one... - DrunkPrincess: Twenty-nine bottles of beer on the wall... SeaKing: I remember legends about that {0}. He ain't quite how the stories make him out to be though. Ocean: Now this is a scene that I can admire any time! I feel like something is watching me though. SulphurSea1: It ain't much of a sight, but there's still life living in these waters. @@ -429,18 +392,12 @@ SteampunkerChat: { StylistChat: { Hardmode: Please don't catch space lice. Or {0} lice. Or just lice in general. - DrunkPrincess1: "{0} is always trying to brighten my mood... even though, deep down, I know she's sad..." - DrunkPrincess2: Sometimes I catch {0} sneaking up from behind me. - DrunkPrincess3: "{0} has been smiling more often lately, even without alcohol. I think I can thank you for that, at least somewhat." ProfanedSoulCrystal1: They look so cute and yet, I can feel their immense power just by being near them. What are you? ProfanedSoulCrystal2: I hate to break it to you, but you don't have hair to cut or style, hun. ProfanedDonuts: Aww, they're so cute, do they have names? } -TavernkeepChat: { - FullMoon: Care for a little Moonshine? - DrunkPrincess: Sheesh, {0} is a little cruel, isn't she? I never claimed to be an expert on anything but ale! -} +TavernkeepChat.FullMoon: Care for a little Moonshine? TaxCollectorChat: { DoGDefeated: Devourer of what, you said? Devourer of Funds, if its payroll is anything to go by! @@ -450,12 +407,7 @@ TaxCollectorChat: { Has100Plat: BAH! Doesn't seem like I'll ever be able to quarrel with the debts of the town again! } -TravellingMerchantChat.DrunkPrincessMerchant: Tell {0} I'll take up her offer and meet with her at the back of {1}'s house. - -TruffleChat: { - Normal: I don't feel very safe; I think there's pigs following me around and it frightens me. - DrunkPrincess: Sometimes, {0} just looks at me funny and I'm not sure how I feel about that. -} +TruffleChat.Normal: I don't feel very safe; I think there's pigs following me around and it frightens me. WitchDoctorChat: { BloodMoon: This is as good a time as any to pick up the best ingredients for potions. @@ -463,7 +415,4 @@ WitchDoctorChat: { Jungle: I wonder how my relatives are doing, last time I checked on them they were too busy praising the... Sun, I think. } -WizardChat: { - Hardmode: Space just got way too close for comfort. - MentionRoD: I saw some teleporting pink apparitions in the Hallow. If you let me live nearby, I should be able to channel their magic into a special staff for you. -} +WizardChat.Hardmode: Space just got way too close for comfort. diff --git a/Localization/en-US/Mods.Terraria.Buffs.hjson b/Localization/en-US/Mods.Terraria.Buffs.hjson new file mode 100644 index 0000000000..ea70752e4b --- /dev/null +++ b/Localization/en-US/Mods.Terraria.Buffs.hjson @@ -0,0 +1,24 @@ +Venom.ItemTooltip: Sickness - 30 DPS +BetsysCurse.ItemTooltip: -40 defense +CursedInferno.ItemTooltip: Heat - 24 DPS +Frostburn2.ItemTooltip: Cold - 50 DPS +Frostburn.ItemTooltip: Cold - 8 DPS +OnFire3.ItemTooltip: Heat - 15 DPS +OnFire.ItemTooltip: Heat - 6 DPS +Ichor.ItemTooltip: -10 defense +Oiled.ItemTooltip: + ''' + Heat - 25 DPS. Recieves 2x the effect from Heat multipliers + Only does damage when paired with another Heat debuff + ''' +Poisoned.ItemTooltip: Sickness - 6 DPS +PotionSickness.ItemTooltip: "" +Slimed.ItemTooltip: Enhances Heat debuff damage +Wet.ItemTooltip: Enhances Electric debuff damage +Electrified.ItemTooltip: Electric - 10.5 DPS. Deals 4x damage to moving targets +Honey.ItemTooltip: + ''' + Increases health regeneration by 1 HP/s + Increases natural regeneration acceleration by 300% + Reduces damage taken from DoT debuffs by 2 HP/s + ''' diff --git a/MainMenu/CalamityMainMenu.cs b/MainMenu/CalamityMainMenu.cs index 3d92738200..deb0852e84 100644 --- a/MainMenu/CalamityMainMenu.cs +++ b/MainMenu/CalamityMainMenu.cs @@ -41,7 +41,7 @@ namespace CalamityMod.MainMenu } = new(); public float remixLogoRotation = 0f; - public override string DisplayName => "Calamity Style"; + public override string DisplayName => CalamityUtils.GetTextValue("UI.MainMenu"); public override Asset Logo => ModContent.Request("CalamityMod/MainMenu/Logo"); public override Asset SunTexture => ModContent.Request("CalamityMod/Backgrounds/BlankPixel"); diff --git a/MainMenu/CalamityMainMenu_Classic.cs b/MainMenu/CalamityMainMenu_Classic.cs index c887934987..b589df95dc 100644 --- a/MainMenu/CalamityMainMenu_Classic.cs +++ b/MainMenu/CalamityMainMenu_Classic.cs @@ -40,7 +40,7 @@ namespace CalamityMod.MainMenu } = new(); public float remixLogoRotation = 0f; - public override string DisplayName => "Calamity Style - Classic"; + public override string DisplayName => CalamityUtils.GetTextValue("UI.MainMenuClassic"); public override Asset Logo => ModContent.Request("CalamityMod/MainMenu/Logo"); public override Asset SunTexture => ModContent.Request("CalamityMod/Backgrounds/BlankPixel"); diff --git a/MainMenu/CalamityMainMenu_Sunken.cs b/MainMenu/CalamityMainMenu_Sunken.cs new file mode 100644 index 0000000000..661e9c03f8 --- /dev/null +++ b/MainMenu/CalamityMainMenu_Sunken.cs @@ -0,0 +1,426 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Systems; +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.MainMenu.SunkenFishBoid; + +namespace CalamityMod.MainMenu +{ + public class CalamityMainMenu_Sunken : ModMenu + { + public class Bubble + { + public int Time; + public int Lifetime; + public int IdentityIndex; + public float Scale; + public float StoredScale; + public float Rotation; + public float RotationSpeed; + public float Depth; + public Color DrawColor; + public Vector2 Velocity; + public Vector2 Center; + + public Asset BubbleTexture; + + public Bubble(int lifetime, int identity, float depth, float storedScale, Color color, Vector2 startingPosition, Vector2 startingVelocity) + { + Lifetime = lifetime; + IdentityIndex = identity; + Depth = depth; + StoredScale = storedScale; + DrawColor = color; + Center = startingPosition; + Velocity = startingVelocity; + + Rotation = Main.rand.NextFloat(MathF.Tau); + RotationSpeed = Main.rand.NextFloat(0.01f, 0.04f) * Main.rand.NextBool().ToDirectionInt(); + BubbleTexture = ModContent.Request("CalamityMod/Particles/Bubble"); + } + + public void Update() + { + // Sway from side to side. + Velocity.X = MathHelper.Lerp(-1f, 1f, CalamityUtils.SineBumpEasing((Time / 60f), 1)); + Scale = MathHelper.Lerp(StoredScale, 0f, Time / (float)Lifetime); + + // Rotate. + Rotation += RotationSpeed * MathHelper.TwoPi * 0.1f; + + Time++; + Center += Velocity; + } + + public void Draw(SpriteBatch spriteBatch) + { + Vector2 depthFactor = new(1f / Depth, 1.1f / Depth); + Vector2 parallaxedPosition = Center * depthFactor; + var scaleByDepth = Scale * Utils.Remap(Depth, 1, 5, 1f, 0.4f, true); + spriteBatch.Draw(BubbleTexture.Value, parallaxedPosition, null, DrawColor, Rotation, BubbleTexture.Value.Size() * 0.5f, scaleByDepth, 0, 0f); + } + } + + public static List Bubbles { get; private set; } = []; + + public static List Fishes { get; private set; } = []; + + public static Asset LogoWater => ModContent.Request("CalamityMod/MainMenu/LogoSunken_Water"); + + public static Asset LogoWaterFill => ModContent.Request("CalamityMod/MainMenu/LogoSunken_Water_Fill"); + + public static Asset Perlin => ModContent.Request("CalamityMod/MainMenu/Perlin"); + + public static Asset WorleyInverted => ModContent.Request("CalamityMod/MainMenu/WorleyInverted"); + + private static RenderTarget2D logoWaterFillTarget; + private static RenderTarget2D logoTarget; + + public int MaxBoids = 120; + + public float remixLogoRotation = 0f; + + /// + /// The global save data key which dictates whether or not the player is opening the Sunken Sea Overhaul update for the first time. + /// + public const string FirstTimeOpeningSunkenSeaOverhaulKey = "HasOpenedTheSunkenSeaOverhaulForTheFirstTime"; + + public override string DisplayName => CalamityUtils.GetTextValue("UI.MainMenuSunken"); + + public override Asset Logo => ModContent.Request("CalamityMod/MainMenu/LogoSunken"); + + public override Asset SunTexture => ModContent.Request("CalamityMod/Backgrounds/BlankPixel"); + + public override Asset MoonTexture => ModContent.Request("CalamityMod/Backgrounds/BlankPixel"); + + public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; + + public override ModSurfaceBackgroundStyle MenuBackgroundStyle => ModContent.GetInstance(); + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + + if (!Main.dedServ) + { + LogoWaterFill.Wait(); + Logo.Wait(); + + Main.QueueMainThreadAction(() => + { + logoWaterFillTarget = new RenderTarget2D(Main.instance.GraphicsDevice, LogoWaterFill.Width(), LogoWaterFill.Height()); + logoTarget = new RenderTarget2D(Main.instance.GraphicsDevice, Logo.Width(), Logo.Height()); + }); + } + } + + public static void ForceMenuStyle() + { + // Forcefully open this ModMenu if it's the player's first time opening the Sunken Sea Overhaul update. + if (GlobalSaveDataSystem.IsKeyAlreadySaved(FirstTimeOpeningSunkenSeaOverhaulKey)) + return; + + List modMenus = MenuLoader.menus; + + var sunkenMenu = ModContent.GetInstance(); + if (modMenus.Contains(sunkenMenu)) + { + int sunkenSeaMenuIndex = modMenus.IndexOf(sunkenMenu); + MenuLoader.LastSelectedModMenu = modMenus[sunkenSeaMenuIndex].FullName; + } + } + + public override void Update(bool isOnTitleScreen) + { + if (!GlobalSaveDataSystem.IsKeyAlreadySaved(FirstTimeOpeningSunkenSeaOverhaulKey)) + GlobalSaveDataSystem.SaveKey(FirstTimeOpeningSunkenSeaOverhaulKey); + } + + public override bool PreDrawLogo(SpriteBatch spriteBatch, ref Vector2 logoDrawCenter, ref float logoRotation, ref float logoScale, ref Color drawColor) + { + DrawLogoWaterShader(spriteBatch); + + // Draw the main background for the menu. + DrawMenuBackground(spriteBatch); + + // Draw the fish boids passively swimming around the menu. + DrawFishes(spriteBatch); + + // Draw the bubbles rising from the bottom of the screen. + DrawBubbles(spriteBatch); + + // Draw the light rays at the top of the screen. + DrawLightRays(spriteBatch); + + // Draw the logo. + DrawLogo(spriteBatch, ref logoDrawCenter, ref logoRotation, ref logoScale, ref drawColor); + + return false; + } + + private static void DrawLogoWaterShader(SpriteBatch sb) + { + sb.End(); + + using (logoWaterFillTarget.Scope(clearColor: Color.Transparent)) + { + sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity); + + var fillShader = CalamityShaders.SunkenSeaMenuLogoWater.Value; + fillShader.Parameters["uImageSize"]?.SetValue(LogoWaterFill.Size()); + fillShader.Parameters["uTexture0"]?.SetValue(WorleyInverted.Value); + fillShader.Parameters["uBubbleTexture"]?.SetValue(Perlin.Value); + //fillShader.Parameters["uFillAmount"]?.SetValue(0.75f + (MathF.Sin(Main.GlobalTimeWrappedHourly) / 2f) * 0.25f); + fillShader.Parameters["uFillAmount"]?.SetValue(0.75f); + fillShader.Parameters["uWaveStrength"]?.SetValue(2.5f); + fillShader.Parameters["uWaveOffset"]?.SetValue(0.6f); + fillShader.Parameters["uSubtract"]?.SetValue(0.4f); + fillShader.Parameters["uTime"]?.SetValue(Main.GlobalTimeWrappedHourly); + fillShader.Parameters["uFillColor"]?.SetValue(new Color(67, 187, 204, 255 / 2).ToVector4() * 0.7f); + fillShader.Parameters["uEdgeColor"]?.SetValue(new Color(16, 99, 112, 255 / 2).ToVector4() * 0.7f); + fillShader.Parameters["uLineColor"]?.SetValue(new Color(179, 255, 255, 255 / 2).ToVector4() * 0.7f); + fillShader.CurrentTechnique.Passes[0].Apply(); + + sb.Draw(LogoWaterFill.Value, Vector2.Zero, Color.White); + + sb.End(); + } + + Main.pixelShader.CurrentTechnique.Passes[0].Apply(); + + using (logoTarget.Scope(clearColor: Color.Transparent)) + { + sb.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity); + sb.Draw(logoWaterFillTarget, new Vector2(406, 48), Color.White); + sb.End(); + } + + sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.UIScaleMatrix); + } + + private void DrawMenuBackground(SpriteBatch spriteBatch) + { + Texture2D backgroundTexture = ModContent.Request("CalamityMod/MainMenu/SunkenMenuBackground").Value; + + // Calculate the draw position offset and scale in the event that someone is using a non-16:9 monitor + Vector2 drawOffset = Vector2.Zero; + float xScale = (float)Main.screenWidth / backgroundTexture.Width; + float yScale = (float)Main.screenHeight / backgroundTexture.Height; + float scale = xScale; + + // if someone's monitor isn't in wacky dimensions, no calculations need to be performed at all + if (xScale != yScale) + { + // If someone's monitor is tall, it needs to be shifted to the left so that it's still centered on screen + // Additionally the Y scale is used so that it still covers the entire screen + if (yScale > xScale) + { + scale = yScale; + drawOffset.X -= (backgroundTexture.Width * scale - Main.screenWidth) * 0.5f; + } + else + // The opposite is true if someone's monitor is widescreen + drawOffset.Y -= (backgroundTexture.Height * scale - Main.screenHeight) * 0.5f; + } + + // Distort the background slightly to make it appear as if it's properly underwater. + MiscShaderData distortionShader = GameShaders.Misc["CalamityMod:BasicTextureDistortion"]; + Asset distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Swirls"); + + spriteBatch.End(); // BLESS THIS. + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix); + + const float distortionXSpeed = -0.012f; + const float distortionYSpeed = 0.015f; + const float noiseScale = 0.75f; + const float noiseStrength = 0.02f; + Vector2 timeOffset = new Vector2(distortionXSpeed, distortionYSpeed) * Main.GlobalTimeWrappedHourly * noiseScale; + Vector2 noiseScaleStrength = new Vector2(noiseScale, noiseStrength); + distortionShader.Shader.Parameters["timeOffset"].SetValue(timeOffset); + distortionShader.Shader.Parameters["noiseScaleStrength"].SetValue(noiseScaleStrength); + distortionShader.SetShaderTexture(distortionTexture); + distortionShader.Apply(); + + spriteBatch.Draw(backgroundTexture, drawOffset, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix); + } + + private void DrawLightRays(SpriteBatch spriteBatch) + { + // Draw rays shining down from the top of the screen. + MiscShaderData underwaterRaysShader = GameShaders.Misc["CalamityMod:UnderwaterRays"]; + Asset underwaterRayTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Pebbles"); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix); + + underwaterRaysShader.Shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + underwaterRaysShader.Shader.Parameters["fadeOutMargin"].SetValue(0.58f); + underwaterRaysShader.Shader.Parameters["overallOpacity"].SetValue(1f); + underwaterRaysShader.Shader.Parameters["pixelationAmount"].SetValue(Main.screenWidth * 0.5f); + underwaterRaysShader.Shader.Parameters["scrollSpeedX"].SetValue(0.013f); + underwaterRaysShader.Shader.Parameters["scrollSpeedY"].SetValue(0.006f); + underwaterRaysShader.Shader.Parameters["noiseScale"].SetValue(new Vector2(1.25f, 0.25f)); + underwaterRaysShader.Shader.Parameters["rayColor"].SetValue(Color.LightSkyBlue.ToVector3()); + underwaterRaysShader.Apply(); + + spriteBatch.Draw(underwaterRayTexture.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix); + } + + private void DrawLogo(SpriteBatch spriteBatch, ref Vector2 logoDrawCenter, ref float logoRotation, ref float logoScale, ref Color drawColor) + { + // Set the logo draw color to be white and the time to be noon + // This is because there is not a day/night cycle in this menu, and changing colors would look bad + drawColor = Color.White; + Main.time = 27000; + Main.dayTime = true; + + // Adjust rotation based on secret seeds; only Drunk world and Remix touch this, with GFB leeching off those two + // Standard rotation is none; Drunk world makes it spin out, so it can use the vanilla rotation due to disappearing + // Remix makes it flip upside down, and in GFB it will spin forever + if (WorldGen.remixWorldGen) + { + remixLogoRotation += MathHelper.Pi / 50f; + if (remixLogoRotation >= MathHelper.Pi && !WorldGen.everythingWorldGen) + remixLogoRotation = MathHelper.Pi; + } + else + remixLogoRotation = 0f; + float rotationSecretSeedAdjusted = WorldGen.remixWorldGen ? remixLogoRotation : WorldGen.drunkWorldGen ? logoRotation : 0f; + + // Draw the logo using a different spritebatch blending setting so it doesn't have a horrible yellow glow + Vector2 drawPos = new Vector2(Main.screenWidth / 2f, 100f); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix); + spriteBatch.Draw(logoTarget, drawPos, null, drawColor, rotationSecretSeedAdjusted, logoTarget.Size() * 0.5f, WorldGen.drunkWorldGen ? logoScale : 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(Logo.Value, drawPos, null, drawColor, rotationSecretSeedAdjusted, Logo.Value.Size() * 0.5f, WorldGen.drunkWorldGen ? logoScale : 1f, SpriteEffects.None, 0f); + spriteBatch.Draw(LogoWater.Value, drawPos, null, new Color(255, 255, 255, 0.5f) * 0.7f, rotationSecretSeedAdjusted, Logo.Value.Size() * 0.5f, WorldGen.drunkWorldGen ? logoScale : 1f, SpriteEffects.None, 0f); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.UIScaleMatrix); + } + + private void DrawBubbles(SpriteBatch spriteBatch) + { + // Randomly add bubbles. + for (int i = 0; i < 3; i++) + { + if (Main.rand.NextBool(4)) + { + int lifetime = Main.rand.NextBool(5) ? Main.rand.Next(400, 500) : Main.rand.Next(200, 250); + float depth = Main.rand.NextFloat(1f, 5f); + float scale = Main.rand.NextFloat(0.2f, 0.8f); + Vector2 startingPosition = new Vector2(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f), Main.screenHeight * 1.05f) * depth; + Vector2 startingVelocity = -Vector2.UnitY.RotatedBy(Main.rand.NextFloat(-0.4f, 0.4f)) * 6f; + Color bubbleColor = Color.Lerp(SelectBubbleColor(), Color.White, 0.6f); + + Bubbles.Add(new Bubble(lifetime, Bubbles.Count, depth, scale, bubbleColor, startingPosition, startingVelocity)); + } + } + + // Update all bubbles. + for (int i = 0; i < Bubbles.Count; i++) + { + Bubbles[i].Update(); + + Bubbles[i].DrawColor.A = 180; + if (Bubbles[i].IdentityIndex % 13 == 12) + Bubbles[i].Scale *= 0.5f; + } + + // Clear away all dead bubbles. + Bubbles.RemoveAll(c => c.Time >= c.Lifetime); + + // Draw bubbles. + var bubblesByDepth = Bubbles.OrderByDescending(b => b.Depth).ToList(); + foreach (Bubble bubble in bubblesByDepth) + bubble.Draw(spriteBatch); + } + + /// + /// Selects a random color for the bubbles which rise from the bottom of the screen. + /// + private static Color SelectBubbleColor() + => Color.Lerp(Color.Lerp(Color.MediumSlateBlue, Color.DarkBlue, 0.3f), Color.Lerp(Color.MediumTurquoise, Color.PaleTurquoise, Main.rand.NextFloat()), Main.rand.NextFloat()); + + private void DrawFishes(SpriteBatch spriteBatch) + { + // Generate random fishes. + if (Main.rand.NextBool(14) && Fishes.Count < MaxBoids) + { + int schoolCount = Main.rand.Next(2, 9); + for (int i = 0; i < schoolCount; i++) + { + int depth = Main.rand.Next(1, 4); + int lifetime = Main.rand.Next(1200, 1800); + float scale = Main.rand.NextFloat(0.8f, 1.2f); + Vector2 spawnPosition = new(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f) * depth, Main.screenHeight * Main.rand.NextFloat(-0.1f, 1.1f) * depth); + SunkenFishBoid fish = new(spawnPosition, scale, depth); + Fishes.Add(fish); + } + } + + // Remove fish when they are offscreen. + Rectangle outOfBoundsRectangle = new(-50, -50, Main.screenWidth + 100, Main.screenHeight + 100); + Fishes.RemoveAll(f => + { + Vector2 depthFactor = new(1f / f.Depth, 1.1f / f.Depth); + Vector2 parallaxedPosition = f.Position * depthFactor; + return !outOfBoundsRectangle.Contains((int)parallaxedPosition.X, (int)parallaxedPosition.Y); + }); + + // Update all fish. + for (int i = 0; i < Fishes.Count; i++) + { + // Alpha Sea Minnows and Prismatic Guppies can spawn in schools. + bool canSpawnSchool = Fishes[i].SelectedFishType == FishType.AlphaSeaMinnow || Fishes[i].IsAPrismaticGuppy; + if (canSpawnSchool && !Fishes[i].HasSpawnedSchool) + { + int fishCount = Main.rand.Next(3, 8); + for (int fishes = 0; fishes < fishCount; fishes++) + { + Vector2 spawnPosition = Fishes[i].Position + Main.rand.NextVector2Circular(50f, 50f) * Fishes[i].Depth; + float scale = Main.rand.NextFloat(0.8f, 1.2f); + FishType typeToSpawn = Fishes[i].IsAPrismaticGuppy ? (FishType)Main.rand.Next(3, 6) : FishType.SeaMinnow; + + SunkenFishBoid schoolingFish = new(spawnPosition, scale, Fishes[i].Depth, typeToSpawn) + { + HasSpawnedSchool = true + }; + + if (Fishes[i].SelectedFishType == FishType.AlphaSeaMinnow) + { + Fishes[i].SeaMinnowSchoolMembers.Add(schoolingFish); + schoolingFish.SeaMinnowSchoolMembers.Add(schoolingFish); + schoolingFish.SeaMinnowSchoolMembers.Add(Fishes[i]); + } + + Fishes.Add(schoolingFish); + } + + Fishes[i].HasSpawnedSchool = true; + } + + Fishes[i].Update(); + } + + // Draw all fish in an order based on their depth. + var fishesByDepth = Fishes.OrderByDescending(f => f.Depth).ToList(); + foreach (SunkenFishBoid fish in fishesByDepth) + fish.Draw(spriteBatch); + } + } +} diff --git a/MainMenu/LogoSunken.png b/MainMenu/LogoSunken.png new file mode 100644 index 0000000000..29f8b05cc2 Binary files /dev/null and b/MainMenu/LogoSunken.png differ diff --git a/MainMenu/LogoSunken_Water.png b/MainMenu/LogoSunken_Water.png new file mode 100644 index 0000000000..12c60ac53f Binary files /dev/null and b/MainMenu/LogoSunken_Water.png differ diff --git a/MainMenu/LogoSunken_Water_Fill.png b/MainMenu/LogoSunken_Water_Fill.png new file mode 100644 index 0000000000..e3a57cf193 Binary files /dev/null and b/MainMenu/LogoSunken_Water_Fill.png differ diff --git a/MainMenu/Perlin.png b/MainMenu/Perlin.png new file mode 100644 index 0000000000..45b02c6b29 Binary files /dev/null and b/MainMenu/Perlin.png differ diff --git a/MainMenu/SunkenFishBoid.cs b/MainMenu/SunkenFishBoid.cs new file mode 100644 index 0000000000..1dd3cfa715 --- /dev/null +++ b/MainMenu/SunkenFishBoid.cs @@ -0,0 +1,349 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; +using Terraria.Utilities; + +namespace CalamityMod.MainMenu +{ + public class SunkenFishBoid + { + // -- GENERAL VARIABLES FOR DEFINING GENERAL BEHAVIOR AND FUNCTIONALITY FOR THE FISH ENTITIES -- + + public enum FishType + { + SeaMinnow, + AlphaSeaMinnow, + PolypPanasea, + PrismaticGuppy1, + PrismaticGuppy2, + PrismaticGuppy3, + } + + public string[] SeaMinnowTextureNames = + [ + "SeaMinnow", + "AlphaSeaMinnow", + ]; + + public string[] PolypPanaseaTextureNames = + [ + "PolypPanasea", + "PolypPanaseaGreen", + "PolypPanaseaPurple", + "PolypPanaseaRadiant", + "PolypPanaseaTurquoise", + "PolypPanaseaGreenCoated", + "PolypPanaseaPurpleCoated", + "PolypPanaseaRadiantCoated", + "PolypPanaseaRedCoated", + "PolypPanaseaTurquoiseCoated", + ]; + + public string[] PrismaticGuppyTextureNames_1 = + [ + "PrismaticGuppy", + "PrismaticGuppyGreen", + "PrismaticGuppyPink", + "PrismaticGuppyRadiant", + ]; + + public string[] PrismaticGuppyTextureNames_2 = + [ + "PrismaticGuppy2", + "PrismaticGuppyGreen2", + "PrismaticGuppyPink2", + "PrismaticGuppyRadiant2", + ]; + + public string[] PrismaticGuppyTextureNames_3 = + [ + "PrismaticGuppy3", + "PrismaticGuppyGreen3", + "PrismaticGuppyPink3", + "PrismaticGuppyRadiant3", + ]; + + public int Time; + + public int Depth; + + public int CurrentFrame; + + public int MaxFrames; + + public int FrameSpeed; + + public Vector2 Position; + + public Vector2 Velocity; + + public Vector2 StretchFactor; + + public float Scale; + + public float StoredScale; + + public float Rotation; + + public float Opacity; + + public float PassiveMovementTimer; + + public Vector2 PassiveMovementVector; + + public float PassiveMovementSpeed; + + public float MaxSpeed_Default = 3f; + + public float MaxSpeed_SwimAwayFromCursor = 4.25f; + + public FishType SelectedFishType; + + public FishType? FishTypeOverride; + + public WeightedRandom RandomFishType = new(); + + public int FishTextureIndex = -1; + + public bool Initialized = false; + + public bool HasSpawnedSchool = false; + + public List SeaMinnowSchoolMembers = []; + + public Asset FishTexture; + + // -- BOID ALOGORITHM SPECIFIC VARIABLES -- + + // 19MAY2025: fryzahh: + // Coefficients to control how strongly each of the Boid Algos affect the movement of each boid. + // Higher values will lead to sharper flocking AI, but movement might be a little choppier. + // Please beware of this if you ever change these values. + public float CohesionCoefficient = 0.075f; + + public float AlignmentCoefficient = 0.12f; + + public float SeparationCoefficient = 0.03f; + + public float MaxRadiusFromOtherFish = 125f; + + public float MaxDetectionRadius = 200f; + + /// + /// Whether or not this fish boid is any of the Prismatic Guppy variants. Used for allowing Prismatic Guppies to school with each other. + /// + public bool IsAPrismaticGuppy => SelectedFishType == FishType.PrismaticGuppy1 || SelectedFishType == FishType.PrismaticGuppy2 || SelectedFishType == FishType.PrismaticGuppy3; + + /// + /// Whether or not this fish boid is any one of the Sea Minnow variants. Used for allowing Sea Minnows to school with Alphas properly. + /// + public bool IsASeaMinnow => SelectedFishType == FishType.SeaMinnow || SelectedFishType == FishType.AlphaSeaMinnow; + + public SunkenFishBoid(Vector2 position, float scale, int depth, FishType? fishTypeOverride = null) + { + Position = position; + StoredScale = scale; + Depth = depth; + FishTypeOverride = fishTypeOverride; + + FrameSpeed = Main.rand.Next(6, 11); + StretchFactor = Vector2.One; + RandomFishType.Add(FishType.AlphaSeaMinnow, 0.7f); + RandomFishType.Add(FishType.PolypPanasea, 0.6f); + RandomFishType.Add(FishType.PrismaticGuppy1, 0.1f); + RandomFishType.Add(FishType.PrismaticGuppy2, 0.1f); + RandomFishType.Add(FishType.PrismaticGuppy3, 0.1f); + } + + public void Update() + { + if (!Initialized) + { + // Select the appropriate fish type. + SelectedFishType = FishTypeOverride ?? RandomFishType; + + // Select the correct texture index for the different types of fish textures. + if (SelectedFishType == FishType.SeaMinnow) + FishTextureIndex = 0; + if (SelectedFishType == FishType.AlphaSeaMinnow) + FishTextureIndex = 1; + if (SelectedFishType == FishType.PolypPanasea) + FishTextureIndex = Main.rand.Next(PolypPanaseaTextureNames.Length); + if (IsAPrismaticGuppy) + FishTextureIndex = Main.rand.Next(PrismaticGuppyTextureNames_1.Length); + + // Select the correct amount of animation frames each texture has based on the fish type. + if (IsASeaMinnow) + MaxFrames = 8; + if (SelectedFishType == FishType.PolypPanasea) + MaxFrames = 6; + if (SelectedFishType == FishType.PrismaticGuppy1) + MaxFrames = 6; + if (SelectedFishType == FishType.PrismaticGuppy2) + MaxFrames = 4; + if (SelectedFishType == FishType.PrismaticGuppy3) + MaxFrames = 5; + + CurrentFrame = Main.rand.Next(MaxFrames); + FishTexture = GetCorrectFishTexture(); + Initialized = true; + } + + if (!Initialized) + return; + + if (Scale < StoredScale) + { + Scale = MathHelper.Clamp(Scale + 0.05f, 0f, StoredScale); + Opacity = MathHelper.Clamp(Opacity + 0.05f, 0f, 1f); + } + + // Perform all Boids Behavior. + DoBoidsBehavior(); + + // Move and swim around idly. + PassiveMovementTimer--; + if (PassiveMovementTimer <= 0f) + { + PassiveMovementSpeed = Main.rand.NextFloat(0.25f, MaxSpeed_Default); + PassiveMovementVector.X = Main.rand.NextFloat(-100f, 101f); + PassiveMovementVector.Y = Main.rand.NextFloat(-100f, 101f); + PassiveMovementTimer = Main.rand.Next(120, 180); + } + + var moveSpeed = PassiveMovementSpeed / PassiveMovementVector.Length(); + Velocity = Vector2.Lerp(Velocity, PassiveMovementVector * moveSpeed, 0.01f); + + // Make fishes closest to the screen swim away from the mouse cursor if it's nearby. + var distanceFromCursor = Vector2.Distance(Position, Main.MouseScreen); + var shouldSwimAway = distanceFromCursor < 100f && Depth <= 1; + if (shouldSwimAway) + { + var distanceInterpolant = Utils.GetLerpValue(175f, 0f, distanceFromCursor, true); + Velocity += Position.DirectionTo(Main.MouseScreen).SafeNormalize(Vector2.UnitY) * distanceInterpolant * -0.46f; + + // Stretch a little while swimming away from danger for additional silliness :D + float stretch = MathHelper.Clamp(Velocity.Length() / MaxSpeed_SwimAwayFromCursor * 0.1f, 1f, 1.65f); + Vector2 stretchedVector = new(Scale * stretch, Scale - Scale * stretch * 0.3f); + StretchFactor = Vector2.Lerp(StretchFactor, stretchedVector, 0.15f); + } + else + { + if (Velocity.Length() > MaxSpeed_Default) + Velocity *= 0.7f; + StretchFactor = Vector2.Lerp(StretchFactor, Vector2.One, 0.15f); + } + + Velocity = Velocity.ClampMagnitude(0.25f, MaxSpeed_SwimAwayFromCursor); + Position += Velocity; + + Rotation = Velocity.ToRotation(); + if (Time % FrameSpeed == 0) + CurrentFrame = (CurrentFrame + 1) % MaxFrames; + + Time++; + } + + public void DoBoidsBehavior() + { + // Polyp Panaseas do not travel in schools. + if (SelectedFishType == FishType.PolypPanasea) + return; + + var cohesion = Vector2.Zero; + var alignment = Vector2.Zero; + var separation = Vector2.Zero; + var totalSchoolMembers = 0; + + var detetctionRadiusSquared = MathF.Pow(MaxDetectionRadius, 2f); + var separationDistanceSquared = MathF.Pow(MaxRadiusFromOtherFish, 2f); + var allOtherFishes = CalamityMainMenu_Sunken.Fishes; + + // Alpha Sea Minnows spawn a school of Sea Minnows manually and stick with it. + if (IsASeaMinnow && SeaMinnowSchoolMembers.Count > 0) + { + foreach (var minnow in SeaMinnowSchoolMembers) + { + var distance = Vector2.DistanceSquared(Position, minnow.Position); + var separationFactor = Utils.GetLerpValue(separationDistanceSquared, 0f, distance, true); + separation += (Position - minnow.Position) * separationFactor * 0.7f; + + cohesion += minnow.Position; + alignment += minnow.Velocity; + totalSchoolMembers++; + } + } + else + { + foreach (var other in allOtherFishes) + { + // Only school with other fishes that are nearby, of the same type and within the same depth. + var isPrismaticGuppy = IsAPrismaticGuppy && other.IsAPrismaticGuppy; + var schoolByFishType = isPrismaticGuppy || SelectedFishType == other.SelectedFishType; + + var distance = Vector2.DistanceSquared(Position, other.Position); + if (distance < detetctionRadiusSquared && other != this && schoolByFishType && other.Depth == Depth) + { + var separationFactor = Utils.GetLerpValue(separationDistanceSquared, 0f, distance, true); + separation += (Position - other.Position) * separationFactor * 0.7f; + + cohesion += other.Position; + alignment += other.Velocity; + totalSchoolMembers++; + } + } + } + + if (totalSchoolMembers == 0) + return; + + // Add all boids algorithm factors into the velocity. + cohesion /= totalSchoolMembers; + var schoolCenterInterpolant = Utils.GetLerpValue(0f, 80f, Position.Distance(cohesion), true); + Velocity += (cohesion - Position).SafeNormalize(-Vector2.UnitY) * schoolCenterInterpolant * CohesionCoefficient; + + alignment /= totalSchoolMembers; + Velocity += Velocity.ToRotation().AngleLerp(alignment.ToRotation(), 0.06f).ToRotationVector2() * Velocity.Length() * AlignmentCoefficient; + + separation /= totalSchoolMembers; + Velocity += separation.SafeNormalize(-Vector2.UnitY) * SeparationCoefficient; + } + + public void Draw(SpriteBatch spriteBatch) + { + if (!Initialized) + return; + + Vector2 depthFactor = new(1f / Depth, 1.1f / Depth); + Vector2 parallaxedPosition = Position * depthFactor; + + var frame = FishTexture.Frame(1, MaxFrames, 0, CurrentFrame); + var origin = frame.Size() * 0.5f; + + var scaleByDepth = Scale / Depth; + var drawRotaton = Rotation + MathHelper.Pi; + var colorByDepth = Color.Lerp(Color.White, Color.Black, Utils.Remap(Depth, 1, 4, 0f, 0.8f, true)); + + var effects = Velocity.X > 0f ? SpriteEffects.FlipVertically : SpriteEffects.None; + spriteBatch.Draw(FishTexture.Value, parallaxedPosition, frame, colorByDepth * Opacity, drawRotaton, origin, StretchFactor * scaleByDepth, effects, 0f); + } + + private Asset GetCorrectFishTexture() + { + var sunkenSeaPath = "CalamityMod/NPCs/SunkenSea/"; + var returnTexture = SelectedFishType switch + { + FishType.PolypPanasea => ModContent.Request(sunkenSeaPath + PolypPanaseaTextureNames[FishTextureIndex]), + FishType.PrismaticGuppy1 => ModContent.Request(sunkenSeaPath + PrismaticGuppyTextureNames_1[FishTextureIndex]), + FishType.PrismaticGuppy2 => ModContent.Request(sunkenSeaPath + PrismaticGuppyTextureNames_2[FishTextureIndex]), + FishType.PrismaticGuppy3 => ModContent.Request(sunkenSeaPath + PrismaticGuppyTextureNames_3[FishTextureIndex]), + _ => ModContent.Request(sunkenSeaPath + SeaMinnowTextureNames[FishTextureIndex]), + }; + return returnTexture; + } + } +} diff --git a/MainMenu/SunkenMenuBackground.png b/MainMenu/SunkenMenuBackground.png new file mode 100644 index 0000000000..6df4caab99 Binary files /dev/null and b/MainMenu/SunkenMenuBackground.png differ diff --git a/MainMenu/WorleyInverted.png b/MainMenu/WorleyInverted.png new file mode 100644 index 0000000000..48b63f46aa Binary files /dev/null and b/MainMenu/WorleyInverted.png differ diff --git a/ModSupport/ExternalMods.cs b/ModSupport/ExternalMods.cs index 7518e201c1..f69d8d110d 100644 --- a/ModSupport/ExternalMods.cs +++ b/ModSupport/ExternalMods.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria.ID; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod { @@ -31,6 +25,7 @@ namespace CalamityMod internal static Mod magicStorage = null; internal static Mod overhaul = null; internal static Mod redemption = null; + internal static Mod remnants = null; internal static Mod soa = null; internal static Mod subworldLibrary = null; internal static Mod summonersAssociation = null; @@ -67,6 +62,8 @@ namespace CalamityMod ModLoader.TryGetMod("TerrariaOverhaul", out overhaul); redemption = null; ModLoader.TryGetMod("Redemption", out redemption); + remnants = null; + ModLoader.TryGetMod("Remnants", out remnants); soa = null; ModLoader.TryGetMod("SacredTools", out soa); subworldLibrary = null; @@ -97,6 +94,7 @@ namespace CalamityMod magicStorage = null; overhaul = null; redemption = null; + remnants = null; soa = null; subworldLibrary = null; summonersAssociation = null; diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index bce9cbdf27..d38e623dd8 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.CalPlayer; using CalamityMod.Events; -using CalamityMod.Items; using CalamityMod.NPCs; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Systems; @@ -663,18 +662,17 @@ namespace CalamityMod #endregion #region Other Player Stats - public static int GetLightStrength(Player p) => p?.GetCurrentAbyssLightLevel() ?? 0; - - public static void AddAbyssLightStrength(Player p, int add) + public static float GetDarknessIntensity(Player p) { if (p != null) - p.Calamity().externalAbyssLight += add; + return p.Calamity().darknessIntensity; + return 0; } - public static void AddBreathLossMult(Player p, float add) + public static void AddAbyssLightStrength(Player p, float add) { if (p != null) - p.Calamity().externalBreathLossMultBoost += add; + p.Calamity().abyssDarkness -= add; } public static void AddBreathTick(Player p, float add) @@ -872,86 +870,48 @@ namespace CalamityMod public static bool DisableAllDodges(bool disable) => Main.LocalPlayer.Calamity().disableAllDodges = disable; #endregion - #region Can Fire Point Blank Shots - /// - /// Gets whether the given item can fire point blank shots. - /// - /// The item which is being checked. - /// Whether the item can fire point blank shots. - public static bool CanFirePointBlank(Item it) - { - if (it is null || it.Calamity() is null) - return false; - CalamityGlobalItem cgi = it.Calamity(); - return cgi.canFirePointBlankShots; - } - - /// - /// Sets whether the given item can fire point blank shots. - /// - /// The item whose point blank capabilities is being toggled. - /// The value to apply. - /// Whether the item can fire point blank shots. - public static bool SetFirePointBlank(Item it, bool enabled) - { - if (it is null || it.Calamity() is null) - return false; - CalamityGlobalItem cgi = it.Calamity(); - cgi.canFirePointBlankShots = enabled; - return cgi.canFirePointBlankShots; - } - - // Set a projectile's point blank duration - public static void SetPointBlankDuration(Projectile projectile, int duration) - { - if (projectile != null) - projectile.Calamity().pointBlankShotDuration = duration; - } - - // Gets a projectile's current point blank duration - public static int GetPointBlankDuration(Projectile projectile) => projectile?.Calamity()?.pointBlankShotDuration ?? 0; - #endregion - #region Amalgam Potion Buff List public static bool SetAmalgamBuffList(int type, bool shouldBeListed) { - if (shouldBeListed && !AmalgamBuffList.Includes(type)) + if (shouldBeListed && !CalamityBuffSets.BuffedByAmalgam[type]) { - AmalgamBuffList.List.Add(type); + CalamityBuffSets.BuffedByAmalgam[type] = true; return true; } else if (!shouldBeListed) { - return AmalgamBuffList.List.Remove(type); + CalamityBuffSets.BuffedByAmalgam[type] = false; + return false; } return false; } public static bool SetPersistentBuffList(int type, bool isPersistent) { - if (isPersistent && !PersistentBuffList.Includes(type)) + if (isPersistent && !CalamityBuffSets.IsPersistentBuff[type]) { - PersistentBuffList.List.Add(type); + CalamityBuffSets.IsPersistentBuff[type] = true; return true; } else if (!isPersistent) { - return PersistentBuffList.List.Remove(type); + CalamityBuffSets.IsPersistentBuff[type] = false; + return false; } return false; } - public static bool IsOnAmalgamBuffList(int type) => AmalgamBuffList.Includes(type); - public static bool IsOnPersistentBuffList(int type) => PersistentBuffList.Includes(type); + public static bool IsOnAmalgamBuffList(int type) => CalamityBuffSets.BuffedByAmalgam[type]; + public static bool IsOnPersistentBuffList(int type) => CalamityBuffSets.IsPersistentBuff[type]; #endregion #region Venerated Locket Bans public static bool AddToVeneratedLocketBanlist(int type) { - if (!VeneratedLocketBanList.Includes(type)) + if (!CalamityItemSets.DisablesVeneratedLocketEffect[type]) { - VeneratedLocketBanList.List.Add(type); + CalamityItemSets.DisablesVeneratedLocketEffect[type] = true; return true; } return false; @@ -961,35 +921,37 @@ namespace CalamityMod #region Summoner Cross Class Nerf Disabling public static bool SetSummonerNerfDisabledByMinion(int type, bool disableNerf) { - if (disableNerf && !DisabledSummonerNerfMinionList.Includes(type)) + if (disableNerf && !CalamityProjectileSets.MinionWhichIgnoresSummonerNerf[type]) { - DisabledSummonerNerfMinionList.List.Add(type); + CalamityProjectileSets.MinionWhichIgnoresSummonerNerf[type] = true; return true; } else if (!disableNerf) { - return DisabledSummonerNerfMinionList.List.Remove(type); + CalamityProjectileSets.MinionWhichIgnoresSummonerNerf[type] = false; + return false; } return false; } public static bool SetSummonerNerfDisabledByItem(int type, bool disableNerf) { - if (disableNerf && !DisabledSummonerNerfItemList.Includes(type)) + if (disableNerf && !CalamityItemSets.ItemWhichDisablesSummonerNerf[type]) { - DisabledSummonerNerfItemList.List.Add(type); + CalamityItemSets.ItemWhichDisablesSummonerNerf[type] = true; return true; } else if (!disableNerf) { - return DisabledSummonerNerfItemList.List.Remove(type); + CalamityItemSets.ItemWhichDisablesSummonerNerf[type] = false; + return false; } return false; } - public static bool GetSummonerNerfDisabledByMinion(int type) => DisabledSummonerNerfMinionList.Includes(type); - public static bool GetSummonerNerfDisabledByItem(int type) => DisabledSummonerNerfItemList.Includes(type); + public static bool GetSummonerNerfDisabledByMinion(int type) => CalamityProjectileSets.MinionWhichIgnoresSummonerNerf[type]; + public static bool GetSummonerNerfDisabledByItem(int type) => CalamityItemSets.ItemWhichDisablesSummonerNerf[type]; #endregion #region Debuff Display support @@ -1005,9 +967,9 @@ namespace CalamityMod #region Town NPC Alert support public static void RegisterTownNPCShop(int id, Predicate getShop, Action setShop) { - if (!CalamityGlobalNPC.npcAlertList.Contains((id, getShop, setShop))) + if (!CalamityGlobalTownNPC.npcAlertList.Contains((id, getShop, setShop))) { - CalamityGlobalNPC.npcAlertList.Add((id, getShop, setShop)); + CalamityGlobalTownNPC.npcAlertList.Add((id, getShop, setShop)); } } #endregion @@ -1023,8 +985,6 @@ namespace CalamityMod "TaintedCloudberry" => player.Calamity().tCloudberry, "SacredStrawberry" => player.Calamity().sStrawberry, - "NimbleBounder" => player.Calamity().nimbleBounderBoost, - "CometShard" => player.Calamity().cShard, "EtherealCore" => player.Calamity().eCore, "PhantomHeart" => player.Calamity().pHeart, @@ -1058,8 +1018,6 @@ namespace CalamityMod case "EtherealCore": player.Calamity().eCore = value; break; case "PhantomHeart": player.Calamity().pHeart = value; break; - case "NimbleBounder": player.Calamity().nimbleBounderBoost = value; break; - case "MushroomPlasmaRoot": player.Calamity().rageBoostOne = value; break; case "InfernalBlood": player.Calamity().rageBoostTwo = value; break; case "RedLightningContainer": player.Calamity().rageBoostThree = value; break; @@ -1069,7 +1027,7 @@ namespace CalamityMod case "Ectoheart": player.Calamity().adrenalineBoostThree = value; break; case "CelestialOnion": player.Calamity().extraAccessoryML = value; break; - }; + } } #endregion @@ -1077,9 +1035,9 @@ namespace CalamityMod //This is to add minions to the hp scaling config public static bool AddToHPScaling(int type) { - if (!BossHPScalingList.List.Contains(type)) + if (!CalamityNPCSets.ScalesHealthLikeBoss[type]) { - BossHPScalingList.List.Add(type); + CalamityNPCSets.ScalesHealthLikeBoss[type] = true; return true; } return false; @@ -1242,17 +1200,14 @@ namespace CalamityMod return null; } - case "GetLight": - case "GetLightLevel": - case "GetLightStrength": - case "GetAbyssLight": - case "GetAbyssLightLevel": - case "GetAbyssLightStrength": + case "GetDarkness": + case "GetAbyssDarkness": + case "GetDarknessIntensity": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetLightStrength\" must be a Player or an int."); - return GetLightStrength(castPlayer(args[1])); + return GetDarknessIntensity(castPlayer(args[1])); case "AddLight": case "AddLightLevel": @@ -1271,21 +1226,6 @@ namespace CalamityMod AddAbyssLightStrength(castPlayer(args[1]), light); return null; - case "BreathMult": - case "BreathLossMult": - case "AddBreathMult": - case "AddBreathLossMult": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and breath loss mult change as a float."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify breath loss mult change as a float."); - if (!(args[2] is float breathLossMult)) - return new ArgumentException("ERROR: The second argument to \"AddBreathLossMult\" must be a float."); - if (!isValidPlayerArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"AddBreathLossMult\" must be a Player or an int."); - AddBreathLossMult(castPlayer(args[1]), breathLossMult); - return null; - case "BreathTick": case "AbyssBreathTick": case "AddBreathTick": @@ -1843,6 +1783,21 @@ namespace CalamityMod return null; } + case "GetVanillaAIOverrideEnabled": + { + return CalamityVanillaAIOverrideNPC.Enabled; + } + + case "SetVanillaAIOverrideEnabled": + { + if (args.Length < 1) + return new ArgumentNullException(nameof(args), "ERROR: Must specify a bool parameter"); + if (args[1] is not bool aiOverrideEnabled) + return new ArgumentException("ERROR: The third argument to \"SetVanillaAIOverrideEnabled\" must be a bool."); + CalamityVanillaAIOverrideNPC.Enabled = aiOverrideEnabled; + return null; + } + case "GetCalamityAI": case "GetNewAI": { @@ -1908,55 +1863,6 @@ namespace CalamityMod return GetShouldCloseBossHealthBar(castNPC(args[1])); } - case "CanFirePointBlank": - case "CanFirePointBlankShots": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify an Item object (or int index of an Item in the Main.item array)."); ; - if (!isValidItemArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"CanFirePointBlank\" must be an Item or an int."); - return CanFirePointBlank(castItem(args[1])); - - case "SetFirePointBlank": - case "SetFirePointBlankShots": - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both an Item object (or int index of an Item in the Main.item array) and a bool."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify whether the item can fire point blank as a bool."); - if (!(args[2] is bool firePointBlank)) - return new ArgumentException("ERROR: The second argument to \"SetFirePointBlank\" must be a bool."); - if (!isValidItemArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"SetFirePointBlank\" must be an Item or an int."); - return SetFirePointBlank(castItem(args[1]), firePointBlank); - - - case "GetPointBlankDuration": - case "GetProjectilePointBlank": - case "GetProjectilePointBlankDuration": - { - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Projectile."); - if (!isValidProjectileArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"GetPointBlankDuration\" must be a Projectile."); - return GetPointBlankDuration(castProjectile(args[1])); - } - - case "SetPointBlankDuration": - case "SetProjectilePointBlank": - case "SetProjectilePointBlankDuration": - { - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify both a Projectile and point blank duration as an int."); - if (args.Length < 3) - return new ArgumentNullException("ERROR: Must specify the point blank duration as an int."); - if (!(args[2] is int pbDuration)) - return new ArgumentException("ERROR: The second argument to \"SetPointBlankDuration\" must be an int."); - if (!isValidProjectileArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"SetPointBlankDuration\" must be a Projectile."); - - SetPointBlankDuration(castProjectile(args[1]), pbDuration); - return null; - } - case "NoDodges": case "DodgesDisabled": case "GetDodgesDisabled": @@ -2155,11 +2061,11 @@ namespace CalamityMod return null; case "LoadParticleInstances": - CalamityMod.Instance.Logger.Warn("This mod call is deprecated. Calamity automatically registers particles."); + CalamityMod.Log.Warn("This mod call is deprecated. Calamity automatically registers particles."); return null; case "RegisterModCooldowns": - CalamityMod.Instance.Logger.Warn("This mod call is deprecated. Calamity automatically registers cooldowns."); + CalamityMod.Log.Warn("This mod call is deprecated. Calamity automatically registers cooldowns."); return null; case "GetSummonerNerfDisabledByItem": @@ -2276,7 +2182,7 @@ namespace CalamityMod return new ArgumentException("ERROR: The first argument to \"SetNewShopVariable\" must be an integer array of npc ids that should be alerted."); if (args.Length != 3 || args[2] is not bool alreadySet) return new ArgumentException("ERROR: The second argument to \"SetNewShopVariable\" Must be a bool that determines if the shop alert should show."); - CalamityGlobalNPC.SetNewShopVariable(npcs, alreadySet); + CalamityGlobalTownNPC.SetNewShopVariable(npcs, alreadySet); return null; } diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index e5aaf5bc23..0f2bf130da 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -2,31 +2,24 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Buffs.Summon; -using CalamityMod.Cooldowns; using CalamityMod.Events; -using CalamityMod.Items; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; -using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Pets; +using CalamityMod.Items.Placeables; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.SummonItems; using CalamityMod.Items.SummonItems.Invasion; using CalamityMod.Items.Weapons.DraedonsArsenal; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; using CalamityMod.NPCs.Bumblebirb; using CalamityMod.NPCs.CalClone; using CalamityMod.NPCs.CeaselessVoid; @@ -57,12 +50,11 @@ using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.TownNPCs; using CalamityMod.NPCs.Yharon; -using CalamityMod.Particles; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Summon.Umbrella; using CalamityMod.Systems; -using CalamityMod.UI; +using CalamityMod.Systems.Graphic.LiquidSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -212,10 +204,9 @@ namespace CalamityMod if (biomelava == null) return; - foreach (ModLavaStyle item in LavaStylesLoader.Content) + foreach (ModLavaStyle lavaStyle in ModLavaStyleLoader.AllStyles) { - int type = item.Slot; - ModLavaStyle lavaStyle = LavaStylesLoader.Get(type); + int type = lavaStyle.Slot; if (lavaStyle != null) { Func GetSplashDust = lavaStyle.GetSplashDust; @@ -337,8 +328,6 @@ namespace CalamityMod // Enemies EnemyRedirect(NPCType(), "Crown Jewels"); - EnemyRedirect(NPCType(), "Crown Jewels"); - EnemyRedirect(NPCType(), "Crown Jewels"); EnemyRedirect(NPCType(), "Tooth Ball (Old Duke)"); EnemyRedirect(NPCType(), "Enchantment"); EnemyRedirect(NPCType(), "%3F%3F%3F"); @@ -460,9 +449,11 @@ namespace CalamityMod string entryName = "HiveMind"; BossChecklistProgressionValues.TryGetValue(entryName, out float order); int type = NPCType(); + Func IsCorruption = () => !WorldGen.crimson || Main.drunkWorld; List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; AddBoss(bossChecklist, calamity, entryName, order, DownedHiveMind, type, new Dictionary() { + ["availability"] = IsCorruption, ["spawnInfo"] = GetSpawnInfo(entryName), ["despawnMessage"] = GetDespawnMessage(entryName), ["spawnItems"] = ItemType(), @@ -476,9 +467,11 @@ namespace CalamityMod string entryName = "Perforators"; BossChecklistProgressionValues.TryGetValue(entryName, out float order); int type = NPCType(); + Func IsCrimson = () => WorldGen.crimson || Main.drunkWorld; List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; AddBoss(bossChecklist, calamity, entryName, order, DownedPerforators, type, new Dictionary() { + ["availability"] = IsCrimson, ["displayName"] = GetDisplayName(entryName), ["spawnInfo"] = GetSpawnInfo(entryName), ["despawnMessage"] = GetDespawnMessage(entryName), @@ -563,8 +556,8 @@ namespace CalamityMod { string entryName = "BrimstoneElemental"; BossChecklistProgressionValues.TryGetValue(entryName, out float order); - int type = NPCType(); - List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + int type = NPCType(); + List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; AddBoss(bossChecklist, calamity, entryName, order, DownedBrimstoneElemental, type, new Dictionary() { ["spawnInfo"] = GetSpawnInfo(entryName), @@ -741,7 +734,7 @@ namespace CalamityMod { string entryName = "Dragonfolly"; BossChecklistProgressionValues.TryGetValue(entryName, out float order); - int type = NPCType(); + int type = NPCType(); List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; AddBoss(bossChecklist, calamity, entryName, order, DownedDragonfolly, type, new Dictionary() { @@ -1160,7 +1153,7 @@ namespace CalamityMod sAssociation.Call("AddMinionInfo", summonItem, summonBuff, summonProjectile); } RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); @@ -1172,7 +1165,7 @@ namespace CalamityMod RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); @@ -1188,7 +1181,7 @@ namespace CalamityMod RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); @@ -1212,7 +1205,7 @@ namespace CalamityMod RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); - RegisterSummon(ItemType(), BuffType(), ProjectileType()); + RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); RegisterSummon(ItemType(), BuffType(), ProjectileType()); @@ -1317,7 +1310,7 @@ namespace CalamityMod #region Luminance private static void RegisterWorldInfoIcon(Mod luminance, string texturePath, string hoverTextKey, Func shouldAppear, byte priority) => luminance.Call("RegisterWorldInfoIcon", texturePath, hoverTextKey, shouldAppear, priority); - + private static void LuminanceSupport() { Mod luminance = ExternalMods.luminance; @@ -1331,7 +1324,7 @@ namespace CalamityMod return tagData.ContainsKey("DeathMode") && tagData.GetBool("DeathMode"); }; - + Func revengeanceEnabled = data => { if (!data.TryGetHeaderData(out var tagData)) @@ -1339,9 +1332,9 @@ namespace CalamityMod return tagData.ContainsKey("RevengeanceMode") && tagData.GetBool("RevengeanceMode") && !(tagData.ContainsKey("DeathMode") && tagData.GetBool("DeathMode")); }; - - RegisterWorldInfoIcon(luminance, "CalamityMod/UI/ModeIndicator/ModeIndicator_Death", "Mods.CalamityMod.UI.DeathEnabled", deathEnabled, 50); - RegisterWorldInfoIcon(luminance, "CalamityMod/UI/ModeIndicator/ModeIndicator_Rev", "Mods.CalamityMod.UI.RevengeanceEnabled", revengeanceEnabled, 50); + + RegisterWorldInfoIcon(luminance, "CalamityMod/UI/ModeIndicator/ModeIndicator_Death", "Mods.CalamityMod.UI.Death", deathEnabled, 50); + RegisterWorldInfoIcon(luminance, "CalamityMod/UI/ModeIndicator/ModeIndicator_Rev", "Mods.CalamityMod.UI.Revengeance", revengeanceEnabled, 50); } #endregion } diff --git a/NPCs/Abyss/BabyCannonballJellyfish.cs b/NPCs/Abyss/BabyCannonballJellyfish.cs index 43e00656d4..bd3e9c570e 100644 --- a/NPCs/Abyss/BabyCannonballJellyfish.cs +++ b/NPCs/Abyss/BabyCannonballJellyfish.cs @@ -1,5 +1,4 @@ using System.IO; -using System.Linq; using CalamityMod.BiomeManagers; using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables.Banners; @@ -53,10 +52,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Abyss/Bloatfish.cs b/NPCs/Abyss/Bloatfish.cs index 002ff2ebce..1888f7692b 100644 --- a/NPCs/Abyss/Bloatfish.cs +++ b/NPCs/Abyss/Bloatfish.cs @@ -4,7 +4,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.World; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -28,10 +27,10 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 74; NPC.height = 94; NPC.defense = 100; - NPC.lifeMax = 9000; + NPC.lifeMax = 7200; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 30, 0); + NPC.value = Item.buyPrice(silver: 30); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.9f; @@ -42,10 +41,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Abyss/BobbitWormHead.cs b/NPCs/Abyss/BobbitWormHead.cs index b9218ec8df..682b2f106e 100644 --- a/NPCs/Abyss/BobbitWormHead.cs +++ b/NPCs/Abyss/BobbitWormHead.cs @@ -31,18 +31,16 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { NPC.lavaImmune = true; - NPC.Calamity().canBreakPlayerDefense = true; NPC.aiStyle = -1; NPC.damage = 150; NPC.width = 80; NPC.height = 40; NPC.defense = 50; - NPC.DR_NERD(0.25f); - NPC.lifeMax = 7500; + NPC.lifeMax = 6000; NPC.knockBackResist = 0f; AIType = -1; NPC.noGravity = true; - NPC.value = Item.buyPrice(0, 0, 50, 0); + NPC.value = Item.buyPrice(silver: 50); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Banner = NPC.type; @@ -52,10 +50,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Abyss/BoxJellyfish.cs b/NPCs/Abyss/BoxJellyfish.cs index 3852e1e332..77b456c045 100644 --- a/NPCs/Abyss/BoxJellyfish.cs +++ b/NPCs/Abyss/BoxJellyfish.cs @@ -29,12 +29,12 @@ namespace CalamityMod.NPCs.Abyss NPC.damage = 44; NPC.width = 30; NPC.height = 33; - NPC.defense = 5; - NPC.lifeMax = 115; + NPC.defense = 8; + NPC.lifeMax = 100; NPC.alpha = 20; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit25; NPC.DeathSound = SoundID.NPCDeath28; Banner = NPC.type; @@ -44,10 +44,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -224,7 +220,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.JellyfishNecklace, 100); + npcLoot.Add(ItemID.JellyfishNecklace, 30); var postSkeletron = npcLoot.DefineConditionalDropSet(() => NPC.downedBoss3); postSkeletron.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 50, 40)); } diff --git a/NPCs/Abyss/CannonballJellyfish.cs b/NPCs/Abyss/CannonballJellyfish.cs index 4658c23195..4ac27bd126 100644 --- a/NPCs/Abyss/CannonballJellyfish.cs +++ b/NPCs/Abyss/CannonballJellyfish.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Placeables.Banners; @@ -11,6 +10,7 @@ using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; @@ -41,10 +41,10 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 54; NPC.height = 76; NPC.defense = 0; - NPC.lifeMax = 500; + NPC.lifeMax = 400; NPC.knockBackResist = 0f; NPC.alpha = 100; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.HitSound = SoundID.NPCHit25; NPC.DeathSound = SoundID.NPCDeath28; Banner = NPC.type; @@ -54,10 +54,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -323,8 +319,9 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.Bomb, 1, 1, 1); - npcLoot.Add(ItemID.JellyfishNecklace, 100); + npcLoot.Add(ItemID.Bomb); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Bezoar, 100, 50)); + npcLoot.Add(ItemID.JellyfishNecklace, 30); } } } diff --git a/NPCs/Abyss/ChaoticPuffer.cs b/NPCs/Abyss/ChaoticPuffer.cs index db902d9ae9..2ef44a8f59 100644 --- a/NPCs/Abyss/ChaoticPuffer.cs +++ b/NPCs/Abyss/ChaoticPuffer.cs @@ -8,7 +8,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -41,11 +40,11 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 78; NPC.height = 78; NPC.defense = 50; - NPC.lifeMax = 7000; + NPC.lifeMax = 5600; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 30, 0); + NPC.value = Item.buyPrice(silver: 30); NPC.HitSound = SoundID.NPCHit23; NPC.DeathSound = SoundID.NPCDeath28; Banner = NPC.type; @@ -248,7 +247,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 180); if (puffedUp) { diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 2b7e4564fa..951075b079 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -7,7 +7,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -38,13 +37,12 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 180; NPC.height = 180; NPC.defense = 50; - NPC.DR_NERD(0.05f); NPC.lifeMax = 130000; // Previously 220,000 NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; NPC.timeLeft = NPC.activeTime * 30; - NPC.value = Item.buyPrice(0, 25, 0, 0); + NPC.value = Item.buyPrice(gold: 25); NPC.HitSound = SoundID.NPCHit20; NPC.DeathSound = SoundID.NPCDeath23; NPC.rarity = 2; @@ -56,10 +54,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToWater = false; NPC.Calamity().canBreakPlayerDefense = true; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -629,7 +623,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.BlackInk, 1, 3, 5); + npcLoot.Add(ItemID.BlackInk, 1, 12, 16); npcLoot.Add(ModContent.ItemType(), 3); var postLevi = npcLoot.DefineConditionalDropSet(DropHelper.PostLevi()); diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index 8e5716a636..58dd3787e6 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -7,7 +7,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; @@ -36,11 +35,11 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 58; NPC.height = 30; NPC.defense = 8; - NPC.lifeMax = 140; + NPC.lifeMax = 160; NPC.aiStyle = -1; AIType = -1; NPC.alpha = 150; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath28; NPC.knockBackResist = 0.3f; @@ -51,10 +50,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -364,7 +359,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Darkness, 120, true); + target.AddBuff(BuffID.Darkness, 300); } public override float SpawnChance(NPCSpawnInfo spawnInfo) @@ -379,6 +374,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 2); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Blindfold, 100, 50)); npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 5)); } diff --git a/NPCs/Abyss/DevilFish.cs b/NPCs/Abyss/DevilFish.cs index ab478d5acd..46a8f218cc 100644 --- a/NPCs/Abyss/DevilFish.cs +++ b/NPCs/Abyss/DevilFish.cs @@ -12,7 +12,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -46,15 +45,14 @@ namespace CalamityMod.NPCs.Abyss { NPC.noGravity = true; NPC.lavaImmune = true; - NPC.Calamity().canBreakPlayerDefense = true; NPC.damage = 90; NPC.width = 136; NPC.height = 62; NPC.defense = 999999; - NPC.lifeMax = 500; + NPC.lifeMax = 800; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.85f; @@ -65,10 +63,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -109,7 +103,7 @@ namespace CalamityMod.NPCs.Abyss { brokenMask = true; NPC.HitSound = SoundID.NPCHit1; - NPC.defense = 15; + NPC.defense = 25; if (!Main.dedServ) { for (int i = 1; i < 4; i++) diff --git a/NPCs/Abyss/DevilFishAlt.cs b/NPCs/Abyss/DevilFishAlt.cs index f1be9b6e3a..bf97d15176 100644 --- a/NPCs/Abyss/DevilFishAlt.cs +++ b/NPCs/Abyss/DevilFishAlt.cs @@ -9,8 +9,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; @@ -36,15 +34,14 @@ namespace CalamityMod.NPCs.Abyss { NPC.noGravity = true; NPC.lavaImmune = true; - NPC.Calamity().canBreakPlayerDefense = true; NPC.damage = 90; NPC.width = 136; NPC.height = 62; NPC.defense = 999999; - NPC.lifeMax = 500; + NPC.lifeMax = 800; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.85f; @@ -55,10 +52,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SendExtraAI(BinaryWriter writer) @@ -91,7 +84,7 @@ namespace CalamityMod.NPCs.Abyss { brokenMask = true; NPC.HitSound = SoundID.NPCHit1; - NPC.defense = 15; + NPC.defense = 25; if (!Main.dedServ) { for (int i = 1; i < 4; i++) diff --git a/NPCs/Abyss/EidolonWyrmBody.cs b/NPCs/Abyss/EidolonWyrmBody.cs index 02450d05e6..46268d84d5 100644 --- a/NPCs/Abyss/EidolonWyrmBody.cs +++ b/NPCs/Abyss/EidolonWyrmBody.cs @@ -43,10 +43,6 @@ namespace CalamityMod.NPCs.Abyss NPC.dontCountMe = true; NPC.dontTakeDamage = true; NPC.chaseable = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) diff --git a/NPCs/Abyss/EidolonWyrmBodyAlt.cs b/NPCs/Abyss/EidolonWyrmBodyAlt.cs index bb6bcfa664..d63b9dd8ff 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAlt.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAlt.cs @@ -43,10 +43,6 @@ namespace CalamityMod.NPCs.Abyss NPC.dontCountMe = true; NPC.dontTakeDamage = true; NPC.chaseable = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 3ad3252016..52c405524e 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -11,7 +11,6 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PrimordialWyrm; using CalamityMod.Sounds; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -59,12 +58,11 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 126; //36 NPC.height = 76; //20 NPC.defense = 70; - NPC.DR_NERD(0.15f); NPC.lifeMax = 160000; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 25, 0, 0); + NPC.value = Item.buyPrice(gold: 25); NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -79,10 +77,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Abyss/EidolonWyrmTail.cs b/NPCs/Abyss/EidolonWyrmTail.cs index dba229a146..2b126c6a68 100644 --- a/NPCs/Abyss/EidolonWyrmTail.cs +++ b/NPCs/Abyss/EidolonWyrmTail.cs @@ -43,10 +43,6 @@ namespace CalamityMod.NPCs.Abyss NPC.dontCountMe = true; NPC.dontTakeDamage = true; NPC.chaseable = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) diff --git a/NPCs/Abyss/GiantSquid.cs b/NPCs/Abyss/GiantSquid.cs index 9651d90ae0..b1208a2cf5 100644 --- a/NPCs/Abyss/GiantSquid.cs +++ b/NPCs/Abyss/GiantSquid.cs @@ -9,8 +9,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; 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; @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.Abyss NPC.lifeMax = 1000; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Banner = NPC.type; @@ -51,10 +51,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -248,14 +244,16 @@ namespace CalamityMod.NPCs.Abyss { if (hurtInfo.Damage > 0) { - target.AddBuff(ModContent.BuffType(), 180, true); - target.AddBuff(BuffID.Darkness, 180, true); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffID.Darkness, 300); } } public override void ModifyNPCLoot(NPCLoot npcLoot) { var postLevi = npcLoot.DefineConditionalDropSet(DropHelper.PostLevi()); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Blindfold, 100, 50)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 5)); postLevi.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 2, 4, 3, 6)); } diff --git a/NPCs/Abyss/GulperEelBody.cs b/NPCs/Abyss/GulperEelBody.cs index fffdbe9751..c3de1de626 100644 --- a/NPCs/Abyss/GulperEelBody.cs +++ b/NPCs/Abyss/GulperEelBody.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Placeables.Banners; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -50,10 +49,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -180,11 +175,5 @@ namespace CalamityMod.NPCs.Abyss } } } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); - } } } diff --git a/NPCs/Abyss/GulperEelBodyAlt.cs b/NPCs/Abyss/GulperEelBodyAlt.cs index 700c7a225a..1adb6c288b 100644 --- a/NPCs/Abyss/GulperEelBodyAlt.cs +++ b/NPCs/Abyss/GulperEelBodyAlt.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Placeables.Banners; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -50,10 +49,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -180,11 +175,5 @@ namespace CalamityMod.NPCs.Abyss } } } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); - } } } diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index 5c3bad9db5..b3db09830a 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -47,7 +47,6 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; NPC.damage = 135; NPC.width = 40; //36 NPC.height = 84; //20 @@ -56,7 +55,7 @@ namespace CalamityMod.NPCs.Abyss NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 1, 0, 0); + NPC.value = Item.buyPrice(gold: 1); NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -70,10 +69,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Abyss/GulperEelTail.cs b/NPCs/Abyss/GulperEelTail.cs index edd3285342..2d5a9a04c9 100644 --- a/NPCs/Abyss/GulperEelTail.cs +++ b/NPCs/Abyss/GulperEelTail.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Placeables.Banners; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -50,10 +49,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -179,11 +174,5 @@ namespace CalamityMod.NPCs.Abyss } } } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); - } } } diff --git a/NPCs/Abyss/Laserfish.cs b/NPCs/Abyss/Laserfish.cs index e15e91f222..a813e9af22 100644 --- a/NPCs/Abyss/Laserfish.cs +++ b/NPCs/Abyss/Laserfish.cs @@ -2,12 +2,11 @@ using CalamityMod.BiomeManagers; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -34,11 +33,11 @@ namespace CalamityMod.NPCs.Abyss NPC.damage = 0; // 0 contact damage, laser damage is handled in the general swimming AI NPC.width = 58; NPC.height = 32; - NPC.defense = 15; + NPC.defense = 20; NPC.lifeMax = 600; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.HitSound = SoundID.NPCHit51; NPC.DeathSound = SoundID.NPCDeath26; NPC.knockBackResist = 0.65f; @@ -50,10 +49,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Abyss/LuminousCorvina.cs b/NPCs/Abyss/LuminousCorvina.cs index 6b95e594c6..20218ea143 100644 --- a/NPCs/Abyss/LuminousCorvina.cs +++ b/NPCs/Abyss/LuminousCorvina.cs @@ -3,6 +3,7 @@ using System.IO; using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Graphics; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Placeables.Banners; @@ -12,7 +13,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -44,11 +44,11 @@ namespace CalamityMod.NPCs.Abyss NPC.damage = 10; NPC.width = 68; NPC.height = 58; - NPC.defense = 12; - NPC.lifeMax = 1000; + NPC.defense = 18; + NPC.lifeMax = 800; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.85f; @@ -59,10 +59,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -89,6 +85,9 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { + + EnhancedDarknessSystem.lights.Add(new(NPC.Center,scale: 1f)); + NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; NPC.noGravity = true; if (NPC.direction == 0) diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 5147891755..13dcc29c85 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -8,7 +8,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; @@ -46,12 +45,12 @@ namespace CalamityMod.NPCs.Abyss NPC.damage = 100; NPC.width = 78; NPC.height = 170; - NPC.defense = 10; - NPC.lifeMax = 7500; + NPC.defense = 30; + NPC.lifeMax = 6000; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 25, 0); + NPC.value = Item.buyPrice(silver: 25); NPC.HitSound = SoundID.NPCHit25; NPC.DeathSound = SoundID.NPCDeath28; Banner = NPC.type; @@ -61,10 +60,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = false; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Abyss/MorayEel.cs b/NPCs/Abyss/MorayEel.cs index dcbd788354..38266adf48 100644 --- a/NPCs/Abyss/MorayEel.cs +++ b/NPCs/Abyss/MorayEel.cs @@ -1,11 +1,9 @@ using System.IO; using CalamityMod.BiomeManagers; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using Terraria; using Terraria.GameContent.Bestiary; -using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; @@ -34,10 +32,10 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 136; NPC.height = 40; NPC.defense = 8; - NPC.lifeMax = 450; + NPC.lifeMax = 360; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.75f; @@ -49,10 +47,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -99,7 +93,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Venom, 30, true); + target.AddBuff(BuffID.Venom, 120); } public override float SpawnChance(NPCSpawnInfo spawnInfo) @@ -117,7 +111,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.Flipper, 20); + npcLoot.Add(ItemID.Flipper, 15); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Abyss/OarfishBody.cs b/NPCs/Abyss/OarfishBody.cs index b110c6b019..e87f136a82 100644 --- a/NPCs/Abyss/OarfishBody.cs +++ b/NPCs/Abyss/OarfishBody.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 16; //28 NPC.height = 16; //28 NPC.defense = 20; - NPC.lifeMax = 5000; + NPC.lifeMax = 4000; NPC.aiStyle = -1; //new AIType = -1; //new NPC.knockBackResist = 0f; @@ -41,10 +41,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index c59d64fa26..fec514fc15 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -43,11 +43,11 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 59; NPC.height = 38; NPC.defense = 10; - NPC.lifeMax = 5000; + NPC.lifeMax = 4000; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -61,10 +61,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -364,7 +360,7 @@ namespace CalamityMod.NPCs.Abyss public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) diff --git a/NPCs/Abyss/OarfishTail.cs b/NPCs/Abyss/OarfishTail.cs index e18c3657b6..f4d57a3847 100644 --- a/NPCs/Abyss/OarfishTail.cs +++ b/NPCs/Abyss/OarfishTail.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.Abyss NPC.width = 14; //28 NPC.height = 16; //28 NPC.defense = 30; - NPC.lifeMax = 5000; + NPC.lifeMax = 4000; NPC.aiStyle = -1; //new AIType = -1; //new NPC.knockBackResist = 0f; @@ -41,10 +41,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) diff --git a/NPCs/Abyss/ReaperShark.cs b/NPCs/Abyss/ReaperShark.cs index 6fb205d54a..cce3312e48 100644 --- a/NPCs/Abyss/ReaperShark.cs +++ b/NPCs/Abyss/ReaperShark.cs @@ -7,7 +7,6 @@ using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Potions; using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -55,7 +54,7 @@ namespace CalamityMod.NPCs.Abyss NPC.aiStyle = -1; AIType = -1; NPC.timeLeft = NPC.activeTime * 30; - NPC.value = Item.buyPrice(0, 25, 0, 0); + NPC.value = Item.buyPrice(gold: 25); NPC.HitSound = SoundID.NPCHit56; NPC.DeathSound = SoundID.NPCDeath60; NPC.knockBackResist = 0f; @@ -70,10 +69,6 @@ namespace CalamityMod.NPCs.Abyss if (Main.zenithWorld) // legg NPC.height = (int)(NPC.height * 1.5f); - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -650,7 +645,7 @@ namespace CalamityMod.NPCs.Abyss { Vector2 direction = shorkCenter - player.Center; direction.Normalize(); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, direction * 10f, ProjectileID.DemonSickle, NPC.damage / 2, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, direction * 10f, ProjectileID.DemonSickle, 80, 0f, Main.myPlayer); } } } diff --git a/NPCs/Abyss/SlabCrab.cs b/NPCs/Abyss/SlabCrab.cs index a595aa9e36..99d5a112fe 100644 --- a/NPCs/Abyss/SlabCrab.cs +++ b/NPCs/Abyss/SlabCrab.cs @@ -55,12 +55,12 @@ namespace CalamityMod.NPCs.Abyss NPC.height = 30; NPC.damage = BaseAttack; - NPC.lifeMax = 375; + NPC.lifeMax = 300; NPC.aiStyle = AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.lavaImmune = true; NPC.noGravity = false; NPC.noTileCollide = false; @@ -77,10 +77,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToWater = false; NPC.GravityIgnoresLiquid = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -303,6 +299,7 @@ namespace CalamityMod.NPCs.Abyss return false; return null; } + public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.Player.Calamity().ZoneAbyssLayer1 && spawnInfo.Water) @@ -384,6 +381,7 @@ namespace CalamityMod.NPCs.Abyss break; } } + // the crab is invincible while hiding public override bool? CanBeHitByItem(Player player, Item item) => CurrentPhase > (int)AIState.IdleAnim; @@ -462,11 +460,13 @@ namespace CalamityMod.NPCs.Abyss } } } + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { if (!NPC.IsABestiaryIconDummy) diff --git a/NPCs/Abyss/ToxicMinnow.cs b/NPCs/Abyss/ToxicMinnow.cs index c1aa1563e4..e8f8c64ede 100644 --- a/NPCs/Abyss/ToxicMinnow.cs +++ b/NPCs/Abyss/ToxicMinnow.cs @@ -3,15 +3,15 @@ using System.IO; using CalamityMod.BiomeManagers; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Enemy; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; @@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.Abyss NPC.lifeMax = 300; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.15f; @@ -57,10 +57,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -187,6 +183,7 @@ namespace CalamityMod.NPCs.Abyss { var postLevi = npcLoot.DefineConditionalDropSet(DropHelper.PostLevi()); postLevi.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 2, 3, 4, 6)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Bezoar, 100, 50)); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Abyss/Viperfish.cs b/NPCs/Abyss/Viperfish.cs index 2fed796aaa..721042e6bd 100644 --- a/NPCs/Abyss/Viperfish.cs +++ b/NPCs/Abyss/Viperfish.cs @@ -4,12 +4,11 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; @@ -46,7 +45,7 @@ namespace CalamityMod.NPCs.Abyss NPC.lifeMax = 400; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.85f; @@ -58,10 +57,6 @@ namespace CalamityMod.NPCs.Abyss NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AcidRain/AcidEel.cs b/NPCs/AcidRain/AcidEel.cs index feba4c4c47..1566b94f2e 100644 --- a/NPCs/AcidRain/AcidEel.cs +++ b/NPCs/AcidRain/AcidEel.cs @@ -59,7 +59,6 @@ namespace CalamityMod.NPCs.AcidRain if (DownedBossSystem.downedPolterghast) { - NPC.DR_NERD(0.05f); NPC.damage = 100; NPC.lifeMax = 2000; NPC.defense = 20; @@ -71,7 +70,7 @@ namespace CalamityMod.NPCs.AcidRain NPC.lifeMax = 180; } - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.aiStyle = -1; AIType = -1; NPC.lavaImmune = false; @@ -85,10 +84,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -103,9 +98,6 @@ namespace CalamityMod.NPCs.AcidRain { NPC.TargetClosest(false); - // Fall through platforms. - NPC.Calamity().ShouldFallThroughPlatforms = true; - // Play a slither sound from time to time. if (Main.rand.NextBool(480)) SoundEngine.PlaySound(SoundID.Zombie32, NPC.Center); @@ -169,6 +161,8 @@ namespace CalamityMod.NPCs.AcidRain NPC.velocity.X = (NPC.velocity.X * 24f + NPC.direction * swimSpeed) / 25f; } + public override bool? CanFallThroughPlatforms() => true; + public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 2, 1, 3); @@ -188,7 +182,7 @@ namespace CalamityMod.NPCs.AcidRain } } - public float SegmentWidthFunction(float completionRatio) => NPC.width * NPC.scale * 0.5f; + public float SegmentWidthFunction(float completionRatio, Vector2 vertexPos) => NPC.width * NPC.scale * 0.5f; public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { @@ -242,10 +236,11 @@ namespace CalamityMod.NPCs.AcidRain if (segmentPositions.Length >= 2) { float tailRotation = (segmentPositions[^2] - segmentPositions[^1]).ToRotation() + MathHelper.Pi; - Vector2 tailDrawPosition = segmentPositions[^1] - tailRotation.ToRotationVector2() * 4f; + Vector2 tailDrawPosition = segmentPositions[^1] - tailRotation.ToRotationVector2() * 4f - screenPos; SpriteEffects tailDirection = NPC.velocity.X < 0f ? SpriteEffects.None : SpriteEffects.FlipVertically; Main.EntitySpriteDraw(tailTexture, tailDrawPosition, tailArea, NPC.GetAlpha(Color.White), tailRotation, tailArea.Size() * new Vector2(0f, 0.5f), NPC.scale, tailDirection, 0); - PrimitiveRenderer.RenderTrail(segmentPositions, new(SegmentWidthFunction, _ => NPC.GetAlpha(Color.White), pixelate: false, shader: GameShaders.Misc["CalamityMod:PrimitiveTexture"]), 36); + Main.instance.GraphicsDevice.BlendState = BlendState.AlphaBlend; + PrimitiveRenderer.RenderTrail(segmentPositions, new(SegmentWidthFunction, (_,_) => NPC.GetAlpha(Color.White), pixelate: false, shader: GameShaders.Misc["CalamityMod:PrimitiveTexture"]), 36); } return false; diff --git a/NPCs/AcidRain/BloodwormNormal.cs b/NPCs/AcidRain/BloodwormNormal.cs index 3d61fbbac8..ad723affaa 100644 --- a/NPCs/AcidRain/BloodwormNormal.cs +++ b/NPCs/AcidRain/BloodwormNormal.cs @@ -7,7 +7,7 @@ using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Utilities; + namespace CalamityMod.NPCs.AcidRain { public class BloodwormNormal : ModNPC diff --git a/NPCs/AcidRain/CragmawMire.cs b/NPCs/AcidRain/CragmawMire.cs index 7cfa43f431..a91b3a9793 100644 --- a/NPCs/AcidRain/CragmawMire.cs +++ b/NPCs/AcidRain/CragmawMire.cs @@ -76,7 +76,7 @@ namespace CalamityMod.NPCs.AcidRain NPC.damage = 66; NPC.lifeMax = 4000; NPC.defense = 25; - NPC.value = Item.buyPrice(0, 2, 0, 0); + NPC.value = Item.buyPrice(gold: 2); if (DownedBossSystem.downedPolterghast) { @@ -177,7 +177,7 @@ namespace CalamityMod.NPCs.AcidRain { for (int i = 0; i < 4; i++) { - Dust rock = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(75f, 75f), 1); + Dust rock = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(75f, 75f), DustID.Stone); rock.color = Color.Yellow; rock.velocity = (NPC.Center - rock.position) * Main.rand.NextFloat(0.06f, 0.09f); rock.scale = Main.rand.NextFloat(1f, 1.3f); @@ -289,7 +289,7 @@ namespace CalamityMod.NPCs.AcidRain // Register ground collision from the slam. // Once it has been hit a nuke explosion projectile is created on the ground, along with homing nuclear drops. - if ((NPC.Bottom.Y > Target.Bottom.Y && Collision.SolidCollision(NPC.BottomLeft, NPC.width, 1)) || AttackTimer > 180f) + if ((NPC.Bottom.Y > Target.Bottom.Y && Collision.SolidCollision(NPC.BottomLeft, NPC.width, 1) || Collision.WetCollision(NPC.BottomLeft, NPC.width, 1)) || AttackTimer > 180f) { NPC.velocity = Vector2.Zero; @@ -400,7 +400,7 @@ namespace CalamityMod.NPCs.AcidRain // Create some charge dust. if (AttackTimer > digReapperTime && AttackTimer < digReapperTime + chargeupTelegraphTime) { - Dust chargeupDust = Dust.NewDustPerfect(NPC.Center, 267); + Dust chargeupDust = Dust.NewDustPerfect(NPC.Center, DustID.RainbowMk2); chargeupDust.position -= Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * NPC.height * 0.4f; chargeupDust.velocity = -Vector2.UnitY.RotatedByRandom(0.31f) * Main.rand.NextFloat(2f, 6f); chargeupDust.color = Color.Lerp(Color.Green, Color.Yellow, Main.rand.NextFloat()); @@ -415,7 +415,7 @@ namespace CalamityMod.NPCs.AcidRain SoundEngine.PlaySound(SoundID.Zombie104, NPC.Center); for (int i = 0; i < 40; i++) { - Dust burstDust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(75f, 75f), 267); + Dust burstDust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(75f, 75f), DustID.RainbowMk2); burstDust.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 6f); burstDust.color = Color.Lerp(Color.Green, Color.Yellow, Main.rand.NextFloat()); burstDust.scale = Main.rand.NextFloat(1.1f, 1.45f); diff --git a/NPCs/AcidRain/FlakCrab.cs b/NPCs/AcidRain/FlakCrab.cs index c9505ec7fe..a2f6a64262 100644 --- a/NPCs/AcidRain/FlakCrab.cs +++ b/NPCs/AcidRain/FlakCrab.cs @@ -43,11 +43,10 @@ namespace CalamityMod.NPCs.AcidRain if (DownedBossSystem.downedPolterghast) { NPC.lifeMax = 4200; - NPC.DR_NERD(0.2f); } NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.lavaImmune = true; NPC.noGravity = false; NPC.noTileCollide = false; @@ -60,10 +59,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AcidRain/GammaSlime.cs b/NPCs/AcidRain/GammaSlime.cs index a901b64e48..c3bae2cc77 100644 --- a/NPCs/AcidRain/GammaSlime.cs +++ b/NPCs/AcidRain/GammaSlime.cs @@ -43,14 +43,13 @@ namespace CalamityMod.NPCs.AcidRain NPC.damage = 110; NPC.lifeMax = 5000; - NPC.DR_NERD(0.15f); NPC.defense = 25; NPC.aiStyle = AIType = -1; NPC.knockBackResist = 0f; AnimationType = NPCID.CorruptSlime; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.alpha = 50; NPC.lavaImmune = false; NPC.noGravity = false; @@ -64,10 +63,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AcidRain/IrradiatedSlime.cs b/NPCs/AcidRain/IrradiatedSlime.cs index 4a47bcbc42..eee58ef4a5 100644 --- a/NPCs/AcidRain/IrradiatedSlime.cs +++ b/NPCs/AcidRain/IrradiatedSlime.cs @@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.AcidRain NPC.knockBackResist = 0.5f; AnimationType = NPCID.CorruptSlime; AIType = NPCID.ToxicSludge; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.alpha = 50; NPC.lavaImmune = false; NPC.noGravity = false; @@ -52,10 +52,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AcidRain/Mauler.cs b/NPCs/AcidRain/Mauler.cs index 0ab66f14c6..51ed39b3da 100644 --- a/NPCs/AcidRain/Mauler.cs +++ b/NPCs/AcidRain/Mauler.cs @@ -67,6 +67,10 @@ namespace CalamityMod.NPCs.AcidRain } } + public static int DropletDamage = 55; // 220 + public static int BubbleDamage = 55; // 220 + public static int GFBDeathBombDamage = 100; // 400 + public override void SetDefaults() { NPC.noGravity = true; @@ -74,11 +78,10 @@ namespace CalamityMod.NPCs.AcidRain NPC.width = 180; NPC.height = 90; NPC.defense = 50; - NPC.DR_NERD(0.05f); NPC.lifeMax = 90000; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 20, 0, 0); + NPC.value = Item.buyPrice(gold: 20); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath60; NPC.knockBackResist = 0f; @@ -194,12 +197,11 @@ namespace CalamityMod.NPCs.AcidRain if (Main.netMode != NetmodeID.MultiplayerClient) { int bubbleShootType = ModContent.ProjectileType(); - int bubbleDamage = NPC.GetProjectileDamage(bubbleShootType); Vector2 baseBubbleShootVelocity = NPC.SafeDirectionTo(mouthPosition) * 13.5f; for (int i = 0; i < bubblesPerBurst; i++) { Vector2 bubbleShootVelocity = baseBubbleShootVelocity + Main.rand.NextVector2Circular(4f, 4f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, bubbleShootVelocity, bubbleShootType, bubbleDamage, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, bubbleShootVelocity, bubbleShootType, BubbleDamage, 0f); } // Get launched back after firing. This only happens if in water and there's no obstacles behind. @@ -290,10 +292,9 @@ namespace CalamityMod.NPCs.AcidRain if (Main.netMode != NetmodeID.MultiplayerClient) { int acidShootType = ModContent.ProjectileType(); - int acidDamage = NPC.GetProjectileDamage(acidShootType); Vector2 acidSpawnPosition = NPC.Center + Main.rand.NextVector2Circular(30f, 10f).RotatedBy(NPC.rotation); Vector2 acidShootVelocity = -Vector2.UnitY.RotatedByRandom(0.33f) * Main.rand.NextFloat(8f, 10.5f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), acidSpawnPosition, acidShootVelocity, acidShootType, acidDamage, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), acidSpawnPosition, acidShootVelocity, acidShootType, DropletDamage, 0f); NPC.netUpdate = true; } } @@ -496,15 +497,14 @@ namespace CalamityMod.NPCs.AcidRain double deltaAngleBoom = spreadBoom / 8f; double offsetAngleBoom; int iBoom; - int damageBoom = Main.masterMode ? 127 : Main.expertMode ? 150 : 200; for (iBoom = 0; iBoom < 25; iBoom++) { int projectileType = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); offsetAngleBoom = startAngleBoom + deltaAngleBoom * (iBoom + iBoom * iBoom) / 2f + 32f * iBoom; if (Main.netMode != NetmodeID.MultiplayerClient) { - int boom1 = Projectile.NewProjectile(NPC.GetSource_Death(), valueBoom.X, valueBoom.Y, (float)(Math.Sin(offsetAngleBoom) * 6f), (float)(Math.Cos(offsetAngleBoom) * 6f), projectileType, damageBoom, 0f, Main.myPlayer, 0f, 0f); - int boom2 = Projectile.NewProjectile(NPC.GetSource_Death(), valueBoom.X, valueBoom.Y, (float)(-Math.Sin(offsetAngleBoom) * 6f), (float)(-Math.Cos(offsetAngleBoom) * 6f), projectileType, damageBoom, 0f, Main.myPlayer, 0f, 0f); + int boom1 = Projectile.NewProjectile(NPC.GetSource_Death(), valueBoom.X, valueBoom.Y, (float)(Math.Sin(offsetAngleBoom) * 6f), (float)(Math.Cos(offsetAngleBoom) * 6f), projectileType, GFBDeathBombDamage, 0f, Main.myPlayer, 0f, 0f); + int boom2 = Projectile.NewProjectile(NPC.GetSource_Death(), valueBoom.X, valueBoom.Y, (float)(-Math.Sin(offsetAngleBoom) * 6f), (float)(-Math.Cos(offsetAngleBoom) * 6f), projectileType, GFBDeathBombDamage, 0f, Main.myPlayer, 0f, 0f); } } for (int i = 0; i < 25; i++) diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 95dcf1abeb..7d6d04049f 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -8,7 +8,6 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -113,8 +112,7 @@ namespace CalamityMod.NPCs.AcidRain NPC.defense = 50; NPC.damage = 135; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 20, 0, 0); - NPC.DR_NERD(0.3f); + NPC.value = Item.buyPrice(gold: 20); NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -514,8 +512,7 @@ Continue: } } float screenShakePower = 20 * Utils.GetLerpValue(1300f, 0f, NPC.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; + Main.LocalPlayer.SetScreenshake(screenShakePower); } else if (DeathrayTime >= 630f) { diff --git a/NPCs/AcidRain/NuclearToad.cs b/NPCs/AcidRain/NuclearToad.cs index 5f50419754..5e97dd2d05 100644 --- a/NPCs/AcidRain/NuclearToad.cs +++ b/NPCs/AcidRain/NuclearToad.cs @@ -77,7 +77,7 @@ namespace CalamityMod.NPCs.AcidRain } NPC.knockBackResist = 0.7f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.lavaImmune = false; NPC.noGravity = true; NPC.noTileCollide = false; @@ -90,10 +90,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AcidRain/Orthocera.cs b/NPCs/AcidRain/Orthocera.cs index ef3fd1d1f3..13eaba493e 100644 --- a/NPCs/AcidRain/Orthocera.cs +++ b/NPCs/AcidRain/Orthocera.cs @@ -47,18 +47,16 @@ namespace CalamityMod.NPCs.AcidRain NPC.damage = 45; NPC.lifeMax = 280; NPC.defense = 15; - NPC.DR_NERD(0.075f); if (DownedBossSystem.downedPolterghast) { NPC.damage = 120; NPC.lifeMax = 3850; NPC.defense = 35; - NPC.DR_NERD(0.15f); } NPC.knockBackResist = 0.6f; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.lavaImmune = false; NPC.noGravity = true; NPC.noTileCollide = false; @@ -71,10 +69,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AcidRain/Radiator.cs b/NPCs/AcidRain/Radiator.cs index 08e6905be3..54e09b8fbb 100644 --- a/NPCs/AcidRain/Radiator.cs +++ b/NPCs/AcidRain/Radiator.cs @@ -7,8 +7,10 @@ using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.AcidRain { public class Radiator : ModNPC @@ -41,7 +43,7 @@ namespace CalamityMod.NPCs.AcidRain } NPC.knockBackResist = 0.8f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -56,10 +58,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -116,6 +114,7 @@ namespace CalamityMod.NPCs.AcidRain public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 2, 1, 3); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Bezoar, 100, 50)); } } } diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index 2c95fabde1..5b8f9fe270 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -3,12 +3,10 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.GameContent.Bestiary; -using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; @@ -47,16 +45,14 @@ namespace CalamityMod.NPCs.AcidRain NPC.damage = 88; NPC.lifeMax = 3025; NPC.defense = 18; - NPC.DR_NERD(0.05f); } else if (DownedBossSystem.downedAquaticScourge) { NPC.damage = 38; NPC.lifeMax = 220; - NPC.DR_NERD(0.05f); } - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.lavaImmune = false; NPC.noGravity = true; NPC.noTileCollide = true; @@ -69,10 +65,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -181,8 +173,6 @@ namespace CalamityMod.NPCs.AcidRain public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 2, 1, 3); - LeadingConditionRule postAS = npcLoot.DefineConditionalDropSet(DropHelper.PostAS()); - postAS.Add(ModContent.ItemType(), 20); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/AcidRain/SulphurousSkater.cs b/NPCs/AcidRain/SulphurousSkater.cs index 759e49aa4e..51a9914263 100644 --- a/NPCs/AcidRain/SulphurousSkater.cs +++ b/NPCs/AcidRain/SulphurousSkater.cs @@ -58,7 +58,7 @@ namespace CalamityMod.NPCs.AcidRain } NPC.knockBackResist = 0.8f; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.lavaImmune = false; NPC.noGravity = true; NPC.noTileCollide = false; @@ -73,10 +73,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SendExtraAI(BinaryWriter writer) => writer.Write(Flying); @@ -103,7 +99,6 @@ namespace CalamityMod.NPCs.AcidRain public void JumpToDestination() { NPC.knockBackResist = 0.8f; - NPC.DR_NERD(0.35f); NPC.noGravity = false; Projectile closestBubble = SearchForNearestBubble(out float distanceToBubbele); @@ -161,7 +156,6 @@ namespace CalamityMod.NPCs.AcidRain public void DoFlyMovement() { NPC.knockBackResist = 0.5f; - NPC.DR_NERD(0f); float flySpeed = DownedBossSystem.downedPolterghast ? 17f : 14f; float flyInertia = DownedBossSystem.downedPolterghast ? 20f : 24.5f; diff --git a/NPCs/AcidRain/Trilobite.cs b/NPCs/AcidRain/Trilobite.cs index f85ec39507..7a03127bf9 100644 --- a/NPCs/AcidRain/Trilobite.cs +++ b/NPCs/AcidRain/Trilobite.cs @@ -5,7 +5,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -39,7 +38,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.damage = 45; NPC.lifeMax = 300; NPC.defense = 15; - NPC.DR_NERD(0.25f); if (DownedBossSystem.downedPolterghast) { @@ -49,7 +47,7 @@ namespace CalamityMod.NPCs.AcidRain } NPC.knockBackResist = 0.2f; - NPC.value = Item.buyPrice(0, 0, 4, 0); + NPC.value = Item.buyPrice(silver: 4); NPC.lavaImmune = false; NPC.noGravity = true; NPC.noTileCollide = false; @@ -62,10 +60,6 @@ namespace CalamityMod.NPCs.AcidRain NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/AquaticScourge/AquaticScourgeBody.cs b/NPCs/AquaticScourge/AquaticScourgeBody.cs index fa66f19776..b9f91cbcc0 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBody.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBody.cs @@ -1,18 +1,23 @@ using System.IO; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; +using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using CalamityMod.Systems.Collections; namespace CalamityMod.NPCs.AquaticScourge { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(AquaticScourgeHead))] public class AquaticScourgeBody : ModNPC { @@ -22,10 +27,12 @@ namespace CalamityMod.NPCs.AquaticScourge this.HideFromBestiary(); } + public static int ToothDamage = 25; // 100 + public override void SetDefaults() { + NPC.damage = 52; // 104 NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); NPC.width = 32; NPC.height = 32; NPC.defense = 20; @@ -35,8 +42,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.knockBackResist = 0f; NPC.alpha = 255; NPC.LifeMaxNERB(80000, 96000, 1000000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax *= 2; NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -46,9 +51,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.dontCountMe = true; NPC.chaseable = false; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -62,9 +65,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -88,7 +88,231 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, false); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool getFuckedAI = Main.zenithWorld; + + // Adjust hostility and stats + bool nonHostile = calamityGlobalNPC.newAI[0] == 0f; + if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || BossRushEvent.BossRushActive || Main.zenithWorld) + { + if (nonHostile) + { + // Kiss my motherfucking ass you piece of shit game + NPC.timeLeft *= 20; + NPC.npcSlots = 16f; + NPC.damage = NPC.defDamage; + CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); + calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.newAI[0] = 1f; + nonHostile = false; + NPC.chaseable = true; + NPC.netUpdate = true; + } + } + else + NPC.damage = 0; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < 0.75f; + bool phase3 = lifeRatio < 0.5f; + bool phase4 = lifeRatio < 0.25f; + + // Set worm variable + if (NPC.ai[2] > 0f) + NPC.realLife = (int)NPC.ai[2]; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool notOcean = player.position.Y < 300f || + player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + + // Check for the flipped Abyss + if (Main.remixWorld) + { + notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + } + + bool biomeEnraged = NPC.localAI[2] <= 0f; + float enrageScale = 0f; + if (biomeEnraged) + { + NPC.Calamity().CurrentlyEnraged = true; + enrageScale += 2f; + } + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = getFuckedAI; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // Fire teeth + if (calamityGlobalNPC.newAI[0] == 1f && (!phase3 || phase4)) + { + NPC.localAI[0] += 1f; + float shootProjectile = 300; + float timer = NPC.ai[0] + 15f; + float divisor = timer + shootProjectile; + + if (NPC.localAI[0] % divisor == 0f && (NPC.ai[0] % 3f == 0f || getFuckedAI || !death)) + { + NPC.TargetClosest(); + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + { + SoundEngine.PlaySound(SoundID.Item17, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float toothVelocity = death ? 9f : 8f; + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); + int type = ModContent.ProjectileType(); + float accelerate = phase4 ? 1f : 0f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity * 5f, projectileVelocity * toothVelocity, type, ToothDamage, 0f, Main.myPlayer, accelerate, 0f); + } + + NPC.netUpdate = true; + } + } + } + + // Kill body and tail + 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; + } + } + if (!shouldDespawn) + { + if (NPC.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)NPC.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); + NPC.active = false; + } + + float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f; + if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged)) + { + calamityGlobalNPC.newAI[1] = 1f; + NPC.TargetClosest(false); + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + { + for (int a = 0; a < Main.npc.Length; a++) + { + int type = Main.npc[a].type; + if (CalamityNPCTypeSets.AquaticScourge.Contains(type)) + Main.npc[a].active = false; + } + } + } + else + calamityGlobalNPC.newAI[1] = 0f; + + // Change direction + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + else if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + + // Alpha changes + if (Main.npc[(int)NPC.ai[1]].alpha < 128) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + Vector2 scourgePosition = NPC.Center; + Vector2 predictionVector = Main.getGoodWorld ? Main.player[NPC.target].velocity * 20f : Vector2.Zero; + float scourgeTargetX = player.Center.X + predictionVector.X; + float scourgeTargetY = player.Center.Y + predictionVector.Y; + + // Velocity and movement + float scourgeMaxSpeed = 5f; + if (calamityGlobalNPC.newAI[0] == 1f) + { + scourgeMaxSpeed = revenge ? 14.4f : 12f; + if (expertMode) + scourgeMaxSpeed += 2.4f * (1f - lifeRatio); + scourgeMaxSpeed += 3f * enrageScale; + if (death || getFuckedAI) + { + scourgeMaxSpeed += 5f; + scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f; + } + + if (Main.getGoodWorld) + scourgeMaxSpeed *= 1.15f; + } + + scourgeTargetX = (int)(scourgeTargetX / 16f) * 16; + scourgeTargetY = (int)(scourgeTargetY / 16f) * 16; + scourgePosition.X = (int)(scourgePosition.X / 16f) * 16; + scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16; + scourgeTargetX -= scourgePosition.X; + scourgeTargetY -= scourgePosition.Y; + + if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) + { + try + { + scourgePosition = NPC.Center; + scourgeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - scourgePosition.X; + scourgeTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - scourgePosition.Y; + } + catch + { + } + + NPC.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2; + float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); + int scourgeWidth = NPC.width; + scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist; + scourgeTargetX *= scourgeTargetDist; + scourgeTargetY *= scourgeTargetDist; + NPC.velocity = Vector2.Zero; + NPC.position.X = NPC.position.X + scourgeTargetX; + NPC.position.Y = NPC.position.Y + scourgeTargetY; + + if (scourgeTargetX < 0f) + NPC.spriteDirection = -1; + else if (scourgeTargetX > 0f) + NPC.spriteDirection = 1; + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -138,7 +362,6 @@ namespace CalamityMod.NPCs.AquaticScourge public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs index 9ef8a4450b..56a6c7432c 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs @@ -1,7 +1,9 @@ -using System.IO; +using System; +using System.IO; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,6 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AquaticScourge { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(AquaticScourgeHead))] public class AquaticScourgeBodyAlt : ModNPC { @@ -24,7 +27,8 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 48; // 96 + NPC.Calamity().canBreakPlayerDefense = true; NPC.width = 32; NPC.height = 32; NPC.defense = 15; @@ -34,8 +38,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.knockBackResist = 0f; NPC.alpha = 255; NPC.LifeMaxNERB(80000, 96000, 1000000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax *= 2; NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -45,9 +47,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.dontCountMe = true; NPC.chaseable = false; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -61,9 +61,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -87,7 +84,202 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, false); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool getFuckedAI = Main.zenithWorld; + + // Adjust hostility and stats + bool nonHostile = calamityGlobalNPC.newAI[0] == 0f; + if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || BossRushEvent.BossRushActive || Main.zenithWorld) + { + if (nonHostile) + { + // Kiss my motherfucking ass you piece of shit game + NPC.timeLeft *= 20; + NPC.npcSlots = 16f; + NPC.damage = NPC.defDamage; + CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); + calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.newAI[0] = 1f; + nonHostile = false; + NPC.chaseable = true; + NPC.netUpdate = true; + } + } + else + NPC.damage = 0; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < 0.75f; + bool phase3 = lifeRatio < 0.5f; + bool phase4 = lifeRatio < 0.25f; + + // Set worm variable + if (NPC.ai[2] > 0f) + NPC.realLife = (int)NPC.ai[2]; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool notOcean = player.position.Y < 300f || + player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + + // Check for the flipped Abyss + if (Main.remixWorld) + { + notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + } + + bool biomeEnraged = NPC.localAI[2] <= 0f; + float enrageScale = 0f; + if (biomeEnraged) + { + NPC.Calamity().CurrentlyEnraged = true; + enrageScale += 2f; + } + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = getFuckedAI; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // Kill body and tail + 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; + } + } + if (!shouldDespawn) + { + if (NPC.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)NPC.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); + NPC.active = false; + } + + float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f; + if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged)) + { + calamityGlobalNPC.newAI[1] = 1f; + NPC.TargetClosest(false); + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + { + for (int a = 0; a < Main.npc.Length; a++) + { + int type = Main.npc[a].type; + if (CalamityNPCTypeSets.AquaticScourge.Contains(type)) + Main.npc[a].active = false; + } + } + } + else + calamityGlobalNPC.newAI[1] = 0f; + + // Change direction + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + else if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + + // Alpha changes + if (Main.npc[(int)NPC.ai[1]].alpha < 128) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + Vector2 scourgePosition = NPC.Center; + Vector2 predictionVector = Main.getGoodWorld ? Main.player[NPC.target].velocity * 20f : Vector2.Zero; + float scourgeTargetX = player.Center.X + predictionVector.X; + float scourgeTargetY = player.Center.Y + predictionVector.Y; + + // Velocity and movement + float scourgeMaxSpeed = 5f; + if (calamityGlobalNPC.newAI[0] == 1f) + { + scourgeMaxSpeed = revenge ? 14.4f : 12f; + if (expertMode) + scourgeMaxSpeed += 2.4f * (1f - lifeRatio); + scourgeMaxSpeed += 3f * enrageScale; + if (death || getFuckedAI) + { + scourgeMaxSpeed += 5f; + scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f; + } + + if (Main.getGoodWorld) + scourgeMaxSpeed *= 1.15f; + } + + scourgeTargetX = (int)(scourgeTargetX / 16f) * 16; + scourgeTargetY = (int)(scourgeTargetY / 16f) * 16; + scourgePosition.X = (int)(scourgePosition.X / 16f) * 16; + scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16; + scourgeTargetX -= scourgePosition.X; + scourgeTargetY -= scourgePosition.Y; + + if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) + { + try + { + scourgePosition = NPC.Center; + scourgeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - scourgePosition.X; + scourgeTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - scourgePosition.Y; + } + catch + { + } + + NPC.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2; + float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); + int scourgeWidth = NPC.width; + scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist; + scourgeTargetX *= scourgeTargetDist; + scourgeTargetY *= scourgeTargetDist; + NPC.velocity = Vector2.Zero; + NPC.position.X = NPC.position.X + scourgeTargetX; + NPC.position.Y = NPC.position.Y + scourgeTargetY; + + if (scourgeTargetX < 0f) + NPC.spriteDirection = -1; + else if (scourgeTargetX > 0f) + NPC.spriteDirection = 1; + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -137,7 +329,6 @@ namespace CalamityMod.NPCs.AquaticScourge public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index d40200466a..28db71c293 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -1,5 +1,6 @@ using System.IO; using CalamityMod.BiomeManagers; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.Items.Accessories; @@ -7,22 +8,21 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; -using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -30,10 +30,12 @@ using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Systems.Collections; namespace CalamityMod.NPCs.AquaticScourge { [AutoloadBossHead] + [HasPierceResist] [LongDistanceNetSync] public class AquaticScourgeHead : ModNPC { @@ -51,9 +53,12 @@ namespace CalamityMod.NPCs.AquaticScourge NPCID.Sets.MPAllowedEnemies[Type] = true; } + public static int MistDamage = 23; // 92 + public static int CloudDamage = 26; // 104; applies to both Sand and Toxic + public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 85; // 170 NPC.Calamity().canBreakPlayerDefense = true; NPC.width = 90; NPC.height = 90; @@ -62,10 +67,8 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.aiStyle = -1; AIType = -1; NPC.LifeMaxNERB(80000, 96000, 1000000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax *= 2; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 16, 0, 0); + NPC.value = Item.buyPrice(gold: 12); NPC.behindTiles = true; NPC.chaseable = false; NPC.noGravity = true; @@ -74,9 +77,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.DeathSound = SoundID.NPCDeath1; NPC.netAlways = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -91,9 +92,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -130,7 +128,447 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, true); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool getFuckedAI = Main.zenithWorld; + CalamityGlobalNPC.aquaticScourge = NPC.whoAmI; + + // Adjust hostility and stats + bool nonHostile = calamityGlobalNPC.newAI[0] == 0f; + if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || BossRushEvent.BossRushActive || Main.zenithWorld) + { + if (nonHostile) + { + // Kiss my motherfucking ass you piece of shit game + NPC.timeLeft *= 20; + NPC.npcSlots = 16f; + NPC.damage = NPC.defDamage; + CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); + calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.newAI[0] = 1f; + nonHostile = false; + NPC.boss = true; + NPC.chaseable = true; + NPC.netUpdate = true; + } + } + else + NPC.damage = 0; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < 0.75f; + bool phase3 = lifeRatio < 0.5f; + bool phase4 = lifeRatio < 0.25f; + + // Set worm variable + if (NPC.ai[2] > 0f) + NPC.realLife = (int)NPC.ai[2]; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool notOcean = player.position.Y < 300f || + player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + + // Check for the flipped Abyss + if (Main.remixWorld) + { + notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + } + + // Enrage + if (notOcean && !player.Calamity().ZoneSulphur && !BossRushEvent.BossRushActive) + { + if (NPC.localAI[2] > 0f) + NPC.localAI[2] -= 1f; + } + else + NPC.localAI[2] = CalamityGlobalNPC.biomeEnrageTimerMax; + + bool biomeEnraged = NPC.localAI[2] <= 0f; + + float enrageScale = 0f; + if (biomeEnraged) + { + NPC.Calamity().CurrentlyEnraged = true; + enrageScale += 2f; + } + + // Circular movement + float colorFadeTimeAfterSpiral = 90f; + float spiralGateValue = 480f; + bool doSpiral = false; + if (calamityGlobalNPC.newAI[0] == 1f && calamityGlobalNPC.newAI[2] == 1f && (revenge || getFuckedAI)) + { + doSpiral = calamityGlobalNPC.newAI[1] == 0f && calamityGlobalNPC.newAI[3] >= spiralGateValue; + if (Vector2.Distance(NPC.Center, player.Center) < (getFuckedAI ? 1600f : 1000f) || doSpiral) + calamityGlobalNPC.newAI[3] += 1f; + + if (doSpiral) + { + NPC.localAI[3] = colorFadeTimeAfterSpiral; + + // Vomit acid mist + float acidMistBarfDivisor = getFuckedAI ? 2f : ((float)Math.Floor(death ? 5f : 6f) * (phase3 ? 1.5f : 1f)); + if (calamityGlobalNPC.newAI[3] % acidMistBarfDivisor == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float mistVelocity = death ? 10f : 8f; + Vector2 projectileVelocity = (NPC.Center + NPC.velocity * 10f - NPC.Center).SafeNormalize(Vector2.UnitY); + int type = ModContent.ProjectileType(); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity * 5f, projectileVelocity * mistVelocity, type, MistDamage, 0f, Main.myPlayer); + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].timeLeft = getFuckedAI ? 240 : 600; + } + } + + // Vomit circular spreads of acid clouds while in phase 3 + float toxicCloudBarfDivisor = death ? 30f : 40f; + if (calamityGlobalNPC.newAI[3] % toxicCloudBarfDivisor == 0f && phase3) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int totalProjectiles = (phase4 ? 6 : 9) + (getFuckedAI ? Main.rand.Next(-2, 3) : (int)((calamityGlobalNPC.newAI[3] - spiralGateValue) / toxicCloudBarfDivisor) * (phase4 ? 2 : 3)); + float radians = MathHelper.TwoPi / totalProjectiles; + float cloudVelocity = 1f + enrageScale; + Vector2 spinningPoint = new Vector2(0f, -cloudVelocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, CloudDamage, 0f, Main.myPlayer); + } + } + } + + // Velocity boost + if (calamityGlobalNPC.newAI[3] == spiralGateValue) + { + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY); + NPC.velocity *= 24f; + } + + // Spin velocity + float velocity = (float)(MathHelper.Pi * 2D) / 120f; + // In GFB, contracts the radius as the fight progresses + if (getFuckedAI) + velocity *= phase3 ? 1.5f : phase2 ? 1.25f : 1f; + NPC.velocity = NPC.velocity.RotatedBy(-(double)velocity * NPC.localAI[1]); + // Speed up even more in GFB for more radius + if (getFuckedAI && NPC.velocity.Length() <= 32f) + NPC.velocity *= 1.1f; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + + // Reset and charge at target + // Don't reset in GFB + if (!getFuckedAI && calamityGlobalNPC.newAI[3] >= spiralGateValue + 120f) + { + calamityGlobalNPC.newAI[3] = 0f; + NPC.TargetClosest(); + } + } + else + { + if (!Collision.CanHit(NPC.Center, 1, 1, player.position, player.width, player.height) && calamityGlobalNPC.newAI[3] > 300f) + calamityGlobalNPC.newAI[3] -= 2f; + + if (NPC.localAI[3] > 0f) + NPC.localAI[3] -= 1f; + + NPC.localAI[1] = NPC.Center.X - player.Center.X < 0 ? 1f : -1f; + } + } + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = doSpiral || getFuckedAI; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // Spawn segments + if (calamityGlobalNPC.newAI[2] == 0f && NPC.ai[0] == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxLength = getFuckedAI ? 24 : death ? 80 : revenge ? 40 : expertMode ? 35 : 30; + int Previous = NPC.whoAmI; + for (int segments = 0; segments < maxLength; segments++) + { + int lol; + if (segments >= 0 && segments < maxLength - 1) + { + if (segments % 2 == 0) + lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI); + else + lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI); + } + else + lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI); + + Main.npc[lol].realLife = NPC.whoAmI; + Main.npc[lol].ai[2] = NPC.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol); + Previous = lol; + } + } + + calamityGlobalNPC.newAI[2] = 1f; + } + + // Big barf attack + if (calamityGlobalNPC.newAI[0] == 1f && (!doSpiral && phase2) || (getFuckedAI && !phase3)) + { + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= (revenge ? 360f : 420f)) + { + if (Vector2.Distance(player.Center, NPC.Center) > 320f) + { + NPC.localAI[0] = 0f; + NPC.netUpdate = true; + SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int totalProjectiles = expertMode ? 8 : 6; + if (phase3) + totalProjectiles *= 2; + + int type = ModContent.ProjectileType(); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 velocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + velocity = velocity.SafeNormalize(Vector2.UnitY); + velocity *= Main.rand.Next(phase3 ? 300 : 100, 401) * 0.01f; + + float maximumVelocityMult = death ? 0.75f : 0.5f; + if (expertMode) + velocity *= 1f + (maximumVelocityMult * (0.5f - lifeRatio)); + + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + velocity.SafeNormalize(Vector2.UnitY) * 5f, velocity, type, CloudDamage, 0f, Main.myPlayer); + } + } + } + } + } + + if (NPC.life > Main.npc[(int)NPC.ai[0]].life) + NPC.life = Main.npc[(int)NPC.ai[0]].life; + + float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f; + if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged)) + { + calamityGlobalNPC.newAI[1] = 1f; + NPC.TargetClosest(false); + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + { + for (int a = 0; a < Main.npc.Length; a++) + { + int type = Main.npc[a].type; + if (CalamityNPCTypeSets.AquaticScourge.Contains(type)) + Main.npc[a].active = false; + } + } + } + else + calamityGlobalNPC.newAI[1] = 0f; + + // Change direction + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + else if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + + // Alpha changes + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + + Vector2 scourgePosition = NPC.Center; + Vector2 predictionVector = Main.getGoodWorld ? Main.player[NPC.target].velocity * 20f : Vector2.Zero; + float scourgeTargetX = player.Center.X + predictionVector.X; + float scourgeTargetY = player.Center.Y + predictionVector.Y; + + // Velocity and movement + float scourgeMaxSpeed = 5f; + float scourgeAcceleration = 0.08f; + if (calamityGlobalNPC.newAI[0] == 1f) + { + scourgeMaxSpeed = revenge ? 14.4f : 12f; + scourgeAcceleration = revenge ? 0.18f : 0.15f; + if (expertMode) + { + scourgeMaxSpeed += 2.4f * (1f - lifeRatio); + scourgeAcceleration += 0.03f * (1f - lifeRatio); + } + scourgeMaxSpeed += 3f * enrageScale; + scourgeAcceleration += 0.06f * enrageScale; + if (death || getFuckedAI) + { + scourgeMaxSpeed += 5f; + scourgeAcceleration -= getFuckedAI ? 0f : 0.03f; + scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f; + scourgeAcceleration += Vector2.Distance(player.Center, NPC.Center) * 0.000045f; + } + + // Increase acceleration after spiral attack + if (NPC.localAI[3] > 0f) + { + float accelerationMultiplier = MathHelper.Lerp(1f, 2f, NPC.localAI[3] / colorFadeTimeAfterSpiral); + scourgeAcceleration *= accelerationMultiplier; + } + + if (Main.getGoodWorld) + { + scourgeMaxSpeed *= 1.15f; + scourgeAcceleration *= 1.15f; + } + } + + if (!doSpiral) + { + if (calamityGlobalNPC.newAI[0] != 1f) + { + scourgeTargetY += 400; + if (Math.Abs(NPC.Center.X - player.Center.X) < 500f) + { + if (NPC.velocity.X > 0f) + scourgeTargetX = player.Center.X + 600f; + else + scourgeTargetX = player.Center.X - 600f; + } + } + + float scourgeHigherSpeed = scourgeMaxSpeed * 1.3f; + float scourgeLowerSpeed = scourgeMaxSpeed * 0.7f; + float scourgeSpeed = NPC.velocity.Length(); + if (scourgeSpeed > 0f) + { + if (scourgeSpeed > scourgeHigherSpeed) + { + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY); + NPC.velocity *= scourgeHigherSpeed; + } + else if (scourgeSpeed < scourgeLowerSpeed) + { + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY); + NPC.velocity *= scourgeLowerSpeed; + } + } + } + + scourgeTargetX = (int)(scourgeTargetX / 16f) * 16; + scourgeTargetY = (int)(scourgeTargetY / 16f) * 16; + scourgePosition.X = (int)(scourgePosition.X / 16f) * 16; + scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16; + scourgeTargetX -= scourgePosition.X; + scourgeTargetY -= scourgePosition.Y; + float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); + + if (!doSpiral) + { + float scourgeAbsoluteTargetX = Math.Abs(scourgeTargetX); + float scourgeAbsoluteTargetY = Math.Abs(scourgeTargetY); + float scourgeTimeToReachTarget = scourgeMaxSpeed / scourgeTargetDist; + scourgeTargetX *= scourgeTimeToReachTarget; + scourgeTargetY *= scourgeTimeToReachTarget; + + if ((NPC.velocity.X > 0f && scourgeTargetX > 0f) || (NPC.velocity.X < 0f && scourgeTargetX < 0f) || (NPC.velocity.Y > 0f && scourgeTargetY > 0f) || (NPC.velocity.Y < 0f && scourgeTargetY < 0f)) + { + if (NPC.velocity.X < scourgeTargetX) + { + NPC.velocity.X += scourgeAcceleration; + } + else + { + if (NPC.velocity.X > scourgeTargetX) + NPC.velocity.X -= scourgeAcceleration; + } + + if (NPC.velocity.Y < scourgeTargetY) + { + NPC.velocity.Y += scourgeAcceleration; + } + else + { + if (NPC.velocity.Y > scourgeTargetY) + NPC.velocity.Y -= scourgeAcceleration; + } + + if (Math.Abs(scourgeTargetY) < scourgeMaxSpeed * 0.2 && ((NPC.velocity.X > 0f && scourgeTargetX < 0f) || (NPC.velocity.X < 0f && scourgeTargetX > 0f))) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += scourgeAcceleration * 2f; + else + NPC.velocity.Y -= scourgeAcceleration * 2f; + } + + if (Math.Abs(scourgeTargetX) < scourgeMaxSpeed * 0.2 && ((NPC.velocity.Y > 0f && scourgeTargetY < 0f) || (NPC.velocity.Y < 0f && scourgeTargetY > 0f))) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X += scourgeAcceleration * 2f; + else + NPC.velocity.X -= scourgeAcceleration * 2f; + } + } + else + { + if (scourgeAbsoluteTargetX > scourgeAbsoluteTargetY) + { + if (NPC.velocity.X < scourgeTargetX) + NPC.velocity.X += scourgeAcceleration * 1.1f; + else if (NPC.velocity.X > scourgeTargetX) + NPC.velocity.X -= scourgeAcceleration * 1.1f; + + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < scourgeMaxSpeed * 0.5) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += scourgeAcceleration; + else + NPC.velocity.Y -= scourgeAcceleration; + } + } + else + { + if (NPC.velocity.Y < scourgeTargetY) + NPC.velocity.Y += scourgeAcceleration * 1.1f; + else if (NPC.velocity.Y > scourgeTargetY) + NPC.velocity.Y -= scourgeAcceleration * 1.1f; + + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < scourgeMaxSpeed * 0.5) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X += scourgeAcceleration; + else + NPC.velocity.X -= scourgeAcceleration; + } + } + } + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -204,13 +642,13 @@ namespace CalamityMod.NPCs.AquaticScourge if (spawnInfo.Player.Calamity().ZoneSulphur && spawnInfo.Water) { if (!NPC.AnyNPCs(ModContent.NPCType())) - return (Main.getGoodWorld ? 0.05f : 0.01f); + return Main.zenithWorld ? 0.1f : 0.01f; } return 0f; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -250,12 +688,10 @@ namespace CalamityMod.NPCs.AquaticScourge normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); normalOnly.Add(ModContent.ItemType(), 10); - - // Fishing - normalOnly.Add(ModContent.ItemType()); } npcLoot.DefineConditionalDropSet(() => true).Add(DropHelper.PerPlayer(ItemID.GreaterHealingPotion, 1, 5, 15), hideLootReport: true); // Healing Potions don't show up in the Bestiary @@ -263,7 +699,7 @@ namespace CalamityMod.NPCs.AquaticScourge npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB troll drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore bool firstASKill() => !DownedBossSystem.downedAquaticScourge; @@ -288,7 +724,7 @@ namespace CalamityMod.NPCs.AquaticScourge string sulfSeaBoostKey = "Mods.CalamityMod.Status.Progression.WetWormBossText"; Color sulfSeaBoostColor = AcidRainEvent.TextColor; - CalamityUtils.DisplayLocalizedText(sulfSeaBoostKey, sulfSeaBoostColor); + CalamityUtils.BroadcastLocalizedText(sulfSeaBoostKey, sulfSeaBoostColor); // Set a timer for acid rain to start after 10 seconds AcidRainEvent.CountdownUntilForcedAcidRain = 601; @@ -302,7 +738,6 @@ namespace CalamityMod.NPCs.AquaticScourge public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/AquaticScourge/AquaticScourgeTail.cs b/NPCs/AquaticScourge/AquaticScourgeTail.cs index 0c7761be5b..75935256b7 100644 --- a/NPCs/AquaticScourge/AquaticScourgeTail.cs +++ b/NPCs/AquaticScourge/AquaticScourgeTail.cs @@ -1,7 +1,9 @@ -using System.IO; +using System; +using System.IO; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,6 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AquaticScourge { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(AquaticScourgeHead))] public class AquaticScourgeTail : ModNPC { @@ -24,7 +27,7 @@ namespace CalamityMod.NPCs.AquaticScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 36; // 72 NPC.width = 32; NPC.height = 32; NPC.defense = 25; @@ -34,8 +37,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.knockBackResist = 0f; NPC.alpha = 255; NPC.LifeMaxNERB(80000, 96000, 1000000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax *= 2; NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -45,9 +46,7 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.dontCountMe = true; NPC.chaseable = false; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -61,9 +60,6 @@ namespace CalamityMod.NPCs.AquaticScourge NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -87,7 +83,202 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - AquaticScourgeAI.VanillaAquaticScourgeAI(NPC, Mod, false); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool getFuckedAI = Main.zenithWorld; + + // Adjust hostility and stats + bool nonHostile = calamityGlobalNPC.newAI[0] == 0f; + if (NPC.justHit || NPC.life <= NPC.lifeMax * 0.999 || BossRushEvent.BossRushActive || Main.zenithWorld) + { + if (nonHostile) + { + // Kiss my motherfucking ass you piece of shit game + NPC.timeLeft *= 20; + NPC.npcSlots = 16f; + NPC.damage = NPC.defDamage; + CalamityGlobalNPC.BossKillTimes.TryGetValue(NPC.type, out int revKillTime); + calamityGlobalNPC.KillTime = revKillTime; + calamityGlobalNPC.newAI[0] = 1f; + nonHostile = false; + NPC.chaseable = true; + NPC.netUpdate = true; + } + } + else + NPC.damage = 0; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < 0.75f; + bool phase3 = lifeRatio < 0.5f; + bool phase4 = lifeRatio < 0.25f; + + // Set worm variable + if (NPC.ai[2] > 0f) + NPC.realLife = (int)NPC.ai[2]; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool notOcean = player.position.Y < 300f || + player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + + // Check for the flipped Abyss + if (Main.remixWorld) + { + notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer || + (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); + } + + bool biomeEnraged = NPC.localAI[2] <= 0f; + float enrageScale = 0f; + if (biomeEnraged) + { + NPC.Calamity().CurrentlyEnraged = true; + enrageScale += 2f; + } + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = getFuckedAI; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // Kill body and tail + 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; + } + } + if (!shouldDespawn) + { + if (NPC.ai[1] <= 0f) + shouldDespawn = true; + else if (Main.npc[(int)NPC.ai[1]].life <= 0) + shouldDespawn = true; + } + if (shouldDespawn) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); + NPC.active = false; + } + + float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f; + if (player.dead || Vector2.Distance(NPC.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged)) + { + calamityGlobalNPC.newAI[1] = 1f; + NPC.TargetClosest(false); + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + NPC.velocity.Y += 2f; + + if (NPC.position.Y > Main.worldSurface * 16D) + { + for (int a = 0; a < Main.npc.Length; a++) + { + int type = Main.npc[a].type; + if (CalamityNPCTypeSets.AquaticScourge.Contains(type)) + Main.npc[a].active = false; + } + } + } + else + calamityGlobalNPC.newAI[1] = 0f; + + // Change direction + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + else if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + + // Alpha changes + if (Main.npc[(int)NPC.ai[1]].alpha < 128) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + Vector2 scourgePosition = NPC.Center; + Vector2 predictionVector = Main.getGoodWorld ? Main.player[NPC.target].velocity * 20f : Vector2.Zero; + float scourgeTargetX = player.Center.X + predictionVector.X; + float scourgeTargetY = player.Center.Y + predictionVector.Y; + + // Velocity and movement + float scourgeMaxSpeed = 5f; + if (calamityGlobalNPC.newAI[0] == 1f) + { + scourgeMaxSpeed = revenge ? 14.4f : 12f; + if (expertMode) + scourgeMaxSpeed += 2.4f * (1f - lifeRatio); + scourgeMaxSpeed += 3f * enrageScale; + if (death || getFuckedAI) + { + scourgeMaxSpeed += 5f; + scourgeMaxSpeed += Vector2.Distance(player.Center, NPC.Center) * 0.001f; + } + + if (Main.getGoodWorld) + scourgeMaxSpeed *= 1.15f; + } + + scourgeTargetX = (int)(scourgeTargetX / 16f) * 16; + scourgeTargetY = (int)(scourgeTargetY / 16f) * 16; + scourgePosition.X = (int)(scourgePosition.X / 16f) * 16; + scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16; + scourgeTargetX -= scourgePosition.X; + scourgeTargetY -= scourgePosition.Y; + + if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) + { + try + { + scourgePosition = NPC.Center; + scourgeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - scourgePosition.X; + scourgeTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - scourgePosition.Y; + } + catch + { + } + + NPC.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2; + float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); + int scourgeWidth = NPC.width; + scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist; + scourgeTargetX *= scourgeTargetDist; + scourgeTargetY *= scourgeTargetDist; + NPC.velocity = Vector2.Zero; + NPC.position.X = NPC.position.X + scourgeTargetX; + NPC.position.Y = NPC.position.Y + scourgeTargetY; + + if (scourgeTargetX < 0f) + NPC.spriteDirection = -1; + else if (scourgeTargetX > 0f) + NPC.spriteDirection = 1; + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -137,7 +328,6 @@ namespace CalamityMod.NPCs.AquaticScourge public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) @@ -163,7 +353,7 @@ namespace CalamityMod.NPCs.AquaticScourge public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 180, true); + target.AddBuff(ModContent.BuffType(), 300, true); } } } diff --git a/NPCs/Astral/Aries.cs b/NPCs/Astral/Aries.cs index 55856d0640..070908c158 100644 --- a/NPCs/Astral/Aries.cs +++ b/NPCs/Astral/Aries.cs @@ -33,28 +33,23 @@ namespace CalamityMod.NPCs.Astral NPC.width = 66; NPC.height = 64; NPC.aiStyle = NPCAIStyleID.Herpling; - NPC.defense = 14; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 380; + NPC.defense = 22; + NPC.lifeMax = 300; NPC.knockBackResist = 0.6f; - NPC.value = Item.buyPrice(0, 0, 3, 0); + NPC.value = Item.buyPrice(silver: 3); NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 85; - NPC.defense = 24; + NPC.defense = 32; NPC.knockBackResist = 0.5f; - NPC.lifeMax = 570; + NPC.lifeMax = 450; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -123,7 +118,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/Astraglomerate.cs b/NPCs/Astral/Astraglomerate.cs index 0d611c3384..87cd7ea9b6 100644 --- a/NPCs/Astral/Astraglomerate.cs +++ b/NPCs/Astral/Astraglomerate.cs @@ -1,6 +1,4 @@ using System; -using CalamityMod.BiomeManagers; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; @@ -37,18 +35,17 @@ namespace CalamityMod.NPCs.Astral NPC.height = 62; NPC.aiStyle = -1; NPC.damage = 0; - NPC.defense = 15; - NPC.DR_NERD(0.15f); + NPC.defense = 30; NPC.lifeMax = 600; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.value = Item.buyPrice(silver: 8); Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 90; - NPC.defense = 25; + NPC.defense = 40; NPC.lifeMax = 900; } NPC.Calamity().VulnerableToHeat = true; @@ -58,10 +55,6 @@ namespace CalamityMod.NPCs.Astral { NPC.scale = 3f; } - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -153,12 +146,6 @@ namespace CalamityMod.NPCs.Astral return 0f; } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); - } - public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 1, 3, 1, 4)); diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index faddb06bef..7a09024fa7 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -1,6 +1,4 @@ using System; -using CalamityMod.BiomeManagers; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; @@ -33,16 +31,15 @@ namespace CalamityMod.NPCs.Astral public override void SetDefaults() { - NPC.damage = 0; // 0 contact damage, laser damage in handled separately + NPC.damage = 0; // 0 contact damage, laser damage is handled separately NPC.width = 30; //324 NPC.height = 30; //216 - NPC.defense = 10; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 70; + NPC.defense = 20; + NPC.lifeMax = 120; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0.95f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.noGravity = true; NPC.noTileCollide = true; NPC.DeathSound = SoundID.NPCDeath14; @@ -51,17 +48,13 @@ namespace CalamityMod.NPCs.Astral if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 30; - NPC.defense = 20; + NPC.defense = 30; NPC.knockBackResist = 0.85f; - NPC.lifeMax = 105; + NPC.lifeMax = 180; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -351,11 +344,5 @@ namespace CalamityMod.NPCs.Astral } return 0f; } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); - } } } diff --git a/NPCs/Astral/AstralSlime.cs b/NPCs/Astral/AstralSlime.cs index 573a6b45a8..b192406b1f 100644 --- a/NPCs/Astral/AstralSlime.cs +++ b/NPCs/Astral/AstralSlime.cs @@ -26,10 +26,10 @@ namespace CalamityMod.NPCs.Astral NPC.width = 36; NPC.height = 31; NPC.aiStyle = NPCAIStyleID.Slime; - NPC.defense = 8; - NPC.lifeMax = 250; + NPC.defense = 18; + NPC.lifeMax = 240; NPC.knockBackResist = 0.6f; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.alpha = 60; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; @@ -39,16 +39,12 @@ namespace CalamityMod.NPCs.Astral if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 65; - NPC.defense = 18; - NPC.lifeMax = 375; + NPC.defense = 28; + NPC.lifeMax = 360; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -95,7 +91,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/AstralachneaGround.cs b/NPCs/Astral/AstralachneaGround.cs index dbd069a50d..52efaf4c48 100644 --- a/NPCs/Astral/AstralachneaGround.cs +++ b/NPCs/Astral/AstralachneaGround.cs @@ -33,12 +33,11 @@ namespace CalamityMod.NPCs.Astral NPC.height = 34; NPC.aiStyle = NPCAIStyleID.Fighter; NPC.damage = 55; - NPC.defense = 20; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 630; + NPC.defense = 30; + NPC.lifeMax = 500; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.knockBackResist = 0.38f; - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.value = Item.buyPrice(silver: 8); NPC.timeLeft = NPC.activeTime * 2; AnimationType = NPCID.WallCreeper; Banner = ModContent.NPCType(); @@ -46,16 +45,12 @@ namespace CalamityMod.NPCs.Astral if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 90; - NPC.defense = 30; + NPC.defense = 40; NPC.knockBackResist = 0.28f; - NPC.lifeMax = 945; + NPC.lifeMax = 750; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() @@ -70,7 +65,7 @@ namespace CalamityMod.NPCs.Astral { for (int j = y - 1; j <= y + 1; j++) { - if (Main.tile[i, j] != null && Main.tile[i, j].WallType > 0) + if (Main.tile[i, j] != null && Main.tile[i, j].WallType > WallID.None) { transform = true; } @@ -155,7 +150,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) => AstralachneaWall.ModifyAstralachneaLoot(npcLoot); diff --git a/NPCs/Astral/AstralachneaWall.cs b/NPCs/Astral/AstralachneaWall.cs index b4dd27e74b..9f9a0c9703 100644 --- a/NPCs/Astral/AstralachneaWall.cs +++ b/NPCs/Astral/AstralachneaWall.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; @@ -40,13 +39,12 @@ namespace CalamityMod.NPCs.Astral NPC.height = 60; NPC.aiStyle = -1; NPC.damage = 55; - NPC.defense = 20; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 630; + NPC.defense = 30; + NPC.lifeMax = 500; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.knockBackResist = 0f; NPC.noGravity = true; - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.value = Item.buyPrice(silver: 8); NPC.timeLeft = NPC.activeTime * 2; AnimationType = NPCID.BlackRecluseWall; Banner = NPC.type; @@ -54,16 +52,12 @@ namespace CalamityMod.NPCs.Astral if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 90; - NPC.defense = 30; - NPC.lifeMax = 945; + NPC.defense = 40; + NPC.lifeMax = 750; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -151,7 +145,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); + target.AddBuff(ModContent.BuffType(), 180); } public static void ModifyAstralachneaLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/Atlas.cs b/NPCs/Astral/Atlas.cs index 435dcc51a2..d41e9dfd53 100644 --- a/NPCs/Astral/Atlas.cs +++ b/NPCs/Astral/Atlas.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; @@ -125,13 +124,11 @@ namespace CalamityMod.NPCs.Astral NPC.height = 88; NPC.damage = 70; NPC.defense = 40; - NPC.DR_NERD(0.15f); NPC.lifeMax = 1200; NPC.knockBackResist = 0.08f; - NPC.value = Item.buyPrice(0, 0, 50, 0); + NPC.value = Item.buyPrice(silver: 50); NPC.aiStyle = -1; NPC.DeathSound = DeathSound; - NPC.rarity = 1; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -154,10 +151,6 @@ namespace CalamityMod.NPCs.Astral NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -651,7 +644,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 150, true); + target.AddBuff(ModContent.BuffType(), 300); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/FusionFeeder.cs b/NPCs/Astral/FusionFeeder.cs index 818c5c67b4..390b054364 100644 --- a/NPCs/Astral/FusionFeeder.cs +++ b/NPCs/Astral/FusionFeeder.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; @@ -58,9 +57,8 @@ namespace CalamityMod.NPCs.Astral NPC.damage = 45; NPC.aiStyle = -1; NPC.lifeMax = 500; - NPC.defense = 12; - NPC.DR_NERD(0.15f); - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.defense = 28; + NPC.value = Item.buyPrice(silver: 8); NPC.knockBackResist = 0.8f; NPC.behindTiles = true; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; @@ -70,17 +68,13 @@ namespace CalamityMod.NPCs.Astral if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 65; - NPC.defense = 22; + NPC.defense = 38; NPC.knockBackResist = 0.7f; NPC.lifeMax = 750; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public static bool ValidMovementPosition(Tile tile) @@ -308,13 +302,14 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.SharkFin, 8); npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 2, 3, 3, 4)); + npcLoot.Add(ItemID.Nachos, 30); } } } diff --git a/NPCs/Astral/Glomerling.cs b/NPCs/Astral/Glomerling.cs index 4064e9380b..f23aee7f7c 100644 --- a/NPCs/Astral/Glomerling.cs +++ b/NPCs/Astral/Glomerling.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Sounds; @@ -39,11 +38,10 @@ namespace CalamityMod.NPCs.Astral NPC.aiStyle = -1; NPC.damage = 30; NPC.defense = 0; - NPC.lifeMax = 190; + NPC.lifeMax = 160; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.knockBackResist = 0.5f; NPC.noGravity = true; - NPC.value = Item.buyPrice(0, 0, 1, 0); Banner = ModContent.NPCType(); BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) @@ -51,15 +49,11 @@ namespace CalamityMod.NPCs.Astral NPC.damage = 50; NPC.defense = 8; NPC.knockBackResist = 0.4f; - NPC.lifeMax = 285; + NPC.lifeMax = 240; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -159,7 +153,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 25, true); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/NPCs/Astral/Hadarian.cs b/NPCs/Astral/Hadarian.cs index 8f004e0ea7..0bc9245130 100644 --- a/NPCs/Astral/Hadarian.cs +++ b/NPCs/Astral/Hadarian.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Accessories.Wings; @@ -42,28 +41,23 @@ namespace CalamityMod.NPCs.Astral NPC.height = 40; NPC.aiStyle = -1; NPC.damage = 50; - NPC.defense = 8; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 420; + NPC.defense = 18; + NPC.lifeMax = 360; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.knockBackResist = 0.75f; - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.value = Item.buyPrice(silver: 8); Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 80; - NPC.defense = 18; + NPC.defense = 28; NPC.knockBackResist = 0.65f; - NPC.lifeMax = 630; + NPC.lifeMax = 540; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -217,7 +211,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/Mantis.cs b/NPCs/Astral/Mantis.cs index de94ff79cf..f37b03bb38 100644 --- a/NPCs/Astral/Mantis.cs +++ b/NPCs/Astral/Mantis.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; @@ -38,33 +37,27 @@ namespace CalamityMod.NPCs.Astral public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; NPC.damage = 55; NPC.width = 60; NPC.height = 58; NPC.aiStyle = -1; - NPC.defense = 6; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 430; + NPC.defense = 22; + NPC.lifeMax = 400; NPC.knockBackResist = 0.2f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 85; - NPC.defense = 16; + NPC.defense = 32; NPC.knockBackResist = 0.1f; - NPC.lifeMax = 645; + NPC.lifeMax = 600; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -245,7 +238,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 45, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/Nova.cs b/NPCs/Astral/Nova.cs index d14ec0d4dd..7e50169673 100644 --- a/NPCs/Astral/Nova.cs +++ b/NPCs/Astral/Nova.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; @@ -52,22 +51,21 @@ namespace CalamityMod.NPCs.Astral NPC.width = 78; NPC.height = 50; NPC.damage = 45; - NPC.defense = 15; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 290; + NPC.defense = 26; + NPC.lifeMax = 300; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.noGravity = true; NPC.knockBackResist = 0.5f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.aiStyle = -1; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 75; - NPC.defense = 25; + NPC.defense = 36; NPC.knockBackResist = 0.4f; - NPC.lifeMax = 435; + NPC.lifeMax = 450; } if (CalamityWorld.revenge) { @@ -82,10 +80,6 @@ namespace CalamityMod.NPCs.Astral NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -329,7 +323,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 45, true); + target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/NPCs/Astral/SightseerCollider.cs b/NPCs/Astral/SightseerCollider.cs index 95120b8a6c..396bdb5842 100644 --- a/NPCs/Astral/SightseerCollider.cs +++ b/NPCs/Astral/SightseerCollider.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; @@ -40,30 +39,25 @@ namespace CalamityMod.NPCs.Astral NPC.width = 48; NPC.height = 40; NPC.damage = 38; - NPC.defense = 16; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 390; + NPC.defense = 28; + NPC.lifeMax = 320; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.noGravity = true; NPC.knockBackResist = 0.58f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.aiStyle = -1; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 58; - NPC.defense = 26; + NPC.defense = 38; NPC.knockBackResist = 0.48f; - NPC.lifeMax = 585; + NPC.lifeMax = 480; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -152,7 +146,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 25, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/SightseerSpitter.cs b/NPCs/Astral/SightseerSpitter.cs index 67d8668cfb..d3c9e0f44a 100644 --- a/NPCs/Astral/SightseerSpitter.cs +++ b/NPCs/Astral/SightseerSpitter.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Materials; @@ -42,30 +41,25 @@ namespace CalamityMod.NPCs.Astral NPC.width = 64; NPC.height = 56; NPC.damage = 50; - NPC.defense = 20; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 540; + NPC.defense = 35; + NPC.lifeMax = 500; NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; NPC.noGravity = true; NPC.knockBackResist = 0.8f; - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.value = Item.buyPrice(silver: 8); NPC.aiStyle = -1; Banner = NPC.type; BannerItem = ModContent.ItemType(); if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 85; - NPC.defense = 30; + NPC.defense = 45; NPC.knockBackResist = 0.7f; - NPC.lifeMax = 810; + NPC.lifeMax = 750; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -121,9 +115,12 @@ namespace CalamityMod.NPCs.Astral { NPC.ai[1] = 0f; - int n = NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnPoint.X, (int)spawnPoint.Y, ModContent.NPCType()); - Main.npc[n].Center = spawnPoint; - Main.npc[n].velocity = vector * (CalamityWorld.death ? 12f : CalamityWorld.revenge ? 11f : 10f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int n = NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnPoint.X, (int)spawnPoint.Y, ModContent.NPCType()); + Main.npc[n].Center = spawnPoint; + Main.npc[n].velocity = vector * (CalamityWorld.death ? 12f : CalamityWorld.revenge ? 11f : 10f); + } } else if (NPC.ai[1] >= 140f) //oozin dust at the "mouth" { @@ -181,7 +178,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 45, true); + target.AddBuff(ModContent.BuffType(), 180, true); } public override void ModifyNPCLoot(NPCLoot npcLoot) @@ -275,7 +272,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 45, true); + target.AddBuff(ModContent.BuffType(), 180); } private void DoKillDust() diff --git a/NPCs/Astral/StellarCulex.cs b/NPCs/Astral/StellarCulex.cs index 1da35af01f..32cd516561 100644 --- a/NPCs/Astral/StellarCulex.cs +++ b/NPCs/Astral/StellarCulex.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Accessories; @@ -40,13 +39,11 @@ namespace CalamityMod.NPCs.Astral NPC.width = 60; NPC.height = 50; NPC.aiStyle = NPCAIStyleID.Bat; //bats - NPC.npcSlots = 0.5f; //needed? NPC.damage = 55; - NPC.defense = 18; - NPC.DR_NERD(0.15f); + NPC.defense = 26; NPC.knockBackResist = 0.65f; - NPC.lifeMax = 270; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.lifeMax = 280; + NPC.value = Item.buyPrice(silver: 5); NPC.DeathSound = CommonCalamitySounds.AstralNPCDeathSound; AnimationType = NPCID.GiantFlyingFox; Banner = NPC.type; @@ -54,17 +51,13 @@ namespace CalamityMod.NPCs.Astral if (DownedBossSystem.downedAstrumAureus) { NPC.damage = 90; - NPC.defense = 28; + NPC.defense = 36; NPC.knockBackResist = 0.55f; - NPC.lifeMax = 405; + NPC.lifeMax = 420; } NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -131,7 +124,7 @@ namespace CalamityMod.NPCs.Astral public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 45, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Astral/Twinkler.cs b/NPCs/Astral/Twinkler.cs index c7ae6c354e..4b9d281f26 100644 --- a/NPCs/Astral/Twinkler.cs +++ b/NPCs/Astral/Twinkler.cs @@ -1,5 +1,4 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Items.Critters; using Terraria; using Terraria.GameContent.Bestiary; diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 20bc8703cc..e9e311449f 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -1,15 +1,15 @@ -using System.IO; +using System; +using System.Collections.Generic; +using System.IO; using System.Threading; -using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -18,8 +18,8 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; -using CalamityMod.NPCs.TownNPCs; +using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; +using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -35,6 +35,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AstrumAureus { [AutoloadBossHead] + [HasPierceResist(singleHitbox: true)] public class AstrumAureus : ModNPC { public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/NPCHit/AureusHit", 4); @@ -58,6 +59,8 @@ namespace CalamityMod.NPCs.AstrumAureus public int slimeProjCounter = 0; public int slimePhase = 0; + public RevengeanceAndDeathAI.MimicAI ZenithSeedMimicAI; + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 6; @@ -85,22 +88,25 @@ namespace CalamityMod.NPCs.AstrumAureus } } + public static int LaserDamage = 25; // 100 + public static int CrystalDamage = 30; // 120 + public override void SetDefaults() { NPC.lavaImmune = true; NPC.noGravity = true; NPC.npcSlots = 15f; - NPC.GetNPCDamage(); + NPC.damage = 80; // 160 NPC.Calamity().canBreakPlayerDefense = true; NPC.width = 374; NPC.height = 374; NPC.defense = 40; - NPC.DR_NERD(0.4f); - NPC.LifeMaxNERB(120000, 140000, 740000); // 30 seconds in boss rush + NPC.DR_NERD(0.1f); + NPC.LifeMaxNERB(75000, 120000, 740000); // 30 seconds in boss rush NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 25, 0, 0); + NPC.value = Item.buyPrice(gold: 15); NPC.boss = true; NPC.DeathSound = DeathSound; NPC.Calamity().VulnerableToHeat = true; @@ -108,12 +114,12 @@ namespace CalamityMod.NPCs.AstrumAureus SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; if (Main.getGoodWorld) - NPC.scale *= 0.8f; + NPC.scale = 0.7f; if (Main.zenithWorld) - NPC.scale *= 1.5f; + NPC.scale = 1.5f; - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); + ZenithSeedMimicAI = new RevengeanceAndDeathAI.MimicAI(); + ZenithSeedMimicAI.NPC = NPC; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -151,8 +157,911 @@ namespace CalamityMod.NPCs.AstrumAureus public override void AI() { - AstrumAureusAI.VanillaAstrumAureusAI(NPC, Mod); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + CalamityGlobalNPC.astrumAureus = NPC.whoAmI; + + // Variables + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < (revenge ? 0.85f : expertMode ? 0.8f : 0.75f); + bool phase3 = lifeRatio < (revenge ? 0.7f : expertMode ? 0.6f : 0.5f); + bool phase4 = lifeRatio < (revenge ? 0.5f : 0.4f) && expertMode; + bool phase5 = lifeRatio < 0.3f && revenge; + + // Exhaustion + bool exhausted = NPC.ai[2] >= (phase3 ? 2f : 1f); + + // 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(); + + Player player = Main.player[NPC.target]; + + // Don't fire projectiles and don't increment phase timers for 4 seconds after the teleport phase to avoid cheap bullshit + float noProjectileOrPhaseIncrementTime = 240f; + + bool dontAttack = NPC.localAI[3] > 0f; + if (dontAttack) + { + NPC.localAI[3] -= 1f; + if (NPC.Distance(player.Center) < 240f) + NPC.localAI[3] -= death ? 4f : expertMode ? 2f : 1f; + } + + float astralFlameBarrageTimerIncrement = 1f; + if (expertMode) + astralFlameBarrageTimerIncrement += death ? (float)Math.Round(3f * (1f - lifeRatio)) : (float)Math.Round(2f * (1f - lifeRatio)); + + float walkingVelocity = phase5 ? 7f : 5f; + if (expertMode) + walkingVelocity += 1.5f * (1f - lifeRatio); + if (revenge) + walkingVelocity += Math.Abs(NPC.Center.X - player.Center.X) * 0.0025f; + if (Main.getGoodWorld) + walkingVelocity *= 1.15f; + + float walkingProjectileVelocity = walkingVelocity * 0.8f; + + // Direction + NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; + + // Used to reduce Aureus' fall speed + bool reduceFallSpeed = NPC.velocity.Y > 0f && Collision.SolidCollision(NPC.position + Vector2.UnitY * 1.1f * NPC.velocity.Y, NPC.width, NPC.height) && NPC.ai[0] == 4f; + + // Despawn + bool despawnDistance = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; + if (!player.active || player.dead || despawnDistance) + { + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + if (!player.active || player.dead || despawnDistance) + { + NPC.noTileCollide = true; + + if (NPC.velocity.Y < -3f) + NPC.velocity.Y = -3f; + NPC.velocity.Y += 0.1f; + if (NPC.velocity.Y > 12f) + NPC.velocity.Y = 12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + + if (NPC.ai[0] != 0f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[2] = 0f; + NPC.localAI[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + NPC.netUpdate = true; + } + return; + } + } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; + + bool geldonPhase1 = lifeRatio > 0.6f && lifeRatio <= 0.7f; + bool geldonPhase2 = lifeRatio <= 0.1f; + if (Main.zenithWorld && (geldonPhase1 || geldonPhase2)) + { + slimeProjCounter++; + if (slimeProjCounter % 180 == 0) + { + SoundEngine.PlaySound(SoundID.Item33, NPC.Center); // Intentionally keeping the old laser sound in GFB + + if (slimePhase == 1) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int totalProjectiles = death ? 12 : revenge ? 10 : expertMode ? 8 : 6; + float radians = MathHelper.TwoPi / totalProjectiles; + float velocity = 10f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, CrystalDamage, 0f, Main.myPlayer, 0f, 1f); + } + } + slimePhase = 0; + } + else + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + float aureusLaserSpeed = 7f; + float aureusLaserTargetX = player.Center.X - NPC.Center.X; + float aureusLaserTargetY = player.Center.Y - NPC.Center.Y; + float aureusLaserTargetDist = (float)Math.Sqrt(aureusLaserTargetX * aureusLaserTargetX + aureusLaserTargetY * aureusLaserTargetY); + aureusLaserTargetDist = aureusLaserSpeed / aureusLaserTargetDist; + aureusLaserTargetX *= aureusLaserTargetDist; + aureusLaserTargetY *= aureusLaserTargetDist; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, aureusLaserTargetX, aureusLaserTargetY, type, LaserDamage, 0f, Main.myPlayer); + for (int i = 0; i < 4; i++) + { + Vector2 offset = new Vector2(Main.rand.Next(-6, 7), Main.rand.Next(-6, 7)); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, aureusLaserTargetX + offset.X, aureusLaserTargetY + offset.Y, type, LaserDamage, 0f, Main.myPlayer); + } + } + slimePhase = 1; + } + } + ZenithSeedMimicAI.AI(Mod); + NPC.noGravity = false; + NPC.noTileCollide = false; + return; + } + else + { + NPC.noGravity = true; + } + + // Emit light when not Idle + if (NPC.ai[0] != 1f) + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1.3f, 0.5f, 0f); + + // Fire projectiles while walking, teleporting, or falling + if (NPC.ai[0] == 2f || NPC.ai[0] >= 5f) + { + if (!dontAttack) + NPC.localAI[0] += NPC.ai[0] == 2f ? 1f : astralFlameBarrageTimerIncrement; + + float astralFlameBarrageGateValue = phase4 ? 30f : 60f; + if (NPC.localAI[0] >= astralFlameBarrageGateValue) + { + // Fire astral flames while teleporting + if (NPC.ai[0] >= 5f && NPC.ai[0] != 7) + { + NPC.localAI[0] = 0f; + SoundEngine.PlaySound(FlameCrystalSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float velocity = death ? (8f + NPC.localAI[2] * 0.025f) : 7f; + int type = ModContent.ProjectileType(); + float spreadLimit = phase4 ? 100f : 50f; + float randomSpread = (Main.rand.NextFloat() - 0.5f) * spreadLimit; + Vector2 spawnVector = new Vector2(NPC.Center.X, NPC.Center.Y - 80f * NPC.scale); + Vector2 destination = new Vector2(spawnVector.X + randomSpread, spawnVector.Y - 100f * NPC.scale); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, Vector2.Normalize(destination - spawnVector) * velocity, type, CrystalDamage, 0f, Main.myPlayer); + } + } + } + + float laserBarrageGateValue = phase5 ? 160f : phase3 ? 120f : phase2 ? 80f : 60f; + if (NPC.localAI[0] >= laserBarrageGateValue) + { + // Fire astral lasers while walking + if (NPC.ai[0] == 2f) + { + NPC.localAI[0] = 0f; + + SoundEngine.PlaySound(LaserSound, NPC.Center); + + if (calamityGlobalNPC.newAI[2] == 0f) + { + calamityGlobalNPC.newAI[2] = 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxProjectiles = !phase2 ? 3 : 5; + int spread = !phase2 ? 8 : 10; + + int type = ModContent.ProjectileType(); + Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * walkingProjectileVelocity; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < maxProjectiles; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, LaserDamage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f); + } + + if (phase3) + { + float flameVelocity = walkingProjectileVelocity; + maxProjectiles = 2; + spread = 45; + + type = ModContent.ProjectileType(); + projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * flameVelocity; + rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < maxProjectiles; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, CrystalDamage, 0f, Main.myPlayer); + } + } + } + } + else + { + calamityGlobalNPC.newAI[2] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxProjectiles = !phase3 ? (death ? 11 : 9) : (death ? 17 : 15); + int spread = !phase3 ? (death ? 18 : 16) : (death ? 22 : 20); + + int type = ModContent.ProjectileType(); + int centralLaser = maxProjectiles / 2; + int[] lasersToNotFire = new int[6] { centralLaser - 3, centralLaser - 2, centralLaser - 1, centralLaser + 1, centralLaser + 2, centralLaser + 3 }; + Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * walkingProjectileVelocity; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < maxProjectiles; i++) + { + if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3] && i != lasersToNotFire[4] && i != lasersToNotFire[5]) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, LaserDamage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f); + } + } + } + } + } + } + } + else + NPC.localAI[0] = 0f; + + // Start up + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 1f; + NPC.netUpdate = true; + CustomGravity(); + } + + // Idle + else if (NPC.ai[0] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + // Slow down + NPC.velocity.X *= 0.8f; + + // Stay vulnerable for 3 seconds + NPC.ai[1] += 1f; + if (NPC.Distance(player.Center) < 240f) + NPC.ai[1] += death ? 4f : expertMode ? 2f : 1f; + + if (NPC.ai[1] >= 180f) + { + // Set AI to random state and reset other AI arrays + NPC.TargetClosest(); + switch (Main.rand.Next(phase3 ? 3 : 2)) + { + case 0: + NPC.ai[0] = 2f; + break; + + case 1: + NPC.ai[0] = 3f; + break; + + case 2: + NPC.ai[0] = 5f; + break; + + default: + break; + } + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + // Stop colliding with tiles if entering walking phase + NPC.noTileCollide = NPC.ai[0] == 2f; + + NPC.netUpdate = true; + } + else + CustomGravity(); + } + + // Walk + else if (NPC.ai[0] == 2f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + // Set walking direction + if (Math.Abs(NPC.Center.X - player.Center.X) < 200f * NPC.scale) + { + NPC.velocity.X *= 0.8f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + } + else + { + float playerLocation = NPC.Center.X - player.Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + + if (NPC.direction > 0) + NPC.velocity.X = (NPC.velocity.X * 20f + walkingVelocity) / 21f; + if (NPC.direction < 0) + NPC.velocity.X = (NPC.velocity.X * 20f - walkingVelocity) / 21f; + } + + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && player.position.Y <= NPC.position.Y + NPC.height && !NPC.collideX) + { + CustomGravity(); + NPC.noTileCollide = false; + } + else + { + NPC.noTileCollide = true; + + // Walk through tiles if colliding with tiles and player is out of reach + int aureusHitboxWidth = 80; + int aureusHitboxHeight = 20; + Vector2 aureusHitboxTileCollideSize = new Vector2(NPC.Center.X - (aureusHitboxWidth / 2), NPC.position.Y + NPC.height - aureusHitboxHeight); + + bool nearPlayerWalkingThroughTiles = false; + if (NPC.position.X < player.position.X && NPC.position.X + NPC.width > player.position.X + player.width && NPC.position.Y + NPC.height < player.position.Y + player.height - 16f) + nearPlayerWalkingThroughTiles = true; + + if (nearPlayerWalkingThroughTiles) + { + NPC.velocity.Y += 0.5f; + } + else if (Collision.SolidCollision(aureusHitboxTileCollideSize, aureusHitboxWidth, aureusHitboxHeight)) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y = 0f; + + if (NPC.velocity.Y > -0.2) + NPC.velocity.Y -= 0.025f; + else + NPC.velocity.Y -= 0.2f; + + if (NPC.velocity.Y < -4f) + NPC.velocity.Y = -4f; + } + else + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y = 0f; + + if (NPC.velocity.Y < 0.1) + NPC.velocity.Y += 0.025f; + else + NPC.velocity.Y += 0.5f; + } + } + + // Walk for a maximum of 6 seconds + if (!dontAttack) + { + NPC.ai[1] += 1f; + if (NPC.Distance(player.Center) < 240f) + NPC.ai[1] += death ? 4f : expertMode ? 2f : 1f; + } + + if (NPC.ai[1] >= (360f - (death ? 90f * (1f - lifeRatio) : 0f))) + { + // Collide with tiles again + NPC.noTileCollide = false; + + // Set AI to next phase (Jump) and reset other AI + NPC.TargetClosest(); + NPC.ai[0] = exhausted ? 1f : 3f; + NPC.ai[1] = 0f; + NPC.ai[2] += 1f; + NPC.netUpdate = true; + } + + // Limit downward velocity + if (NPC.velocity.Y > 10f) + NPC.velocity.Y = 10f; + } + + // Jump + else if (NPC.ai[0] == 3f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.noTileCollide = false; + + if (NPC.velocity.Y == 0f) + { + // Slow down + NPC.velocity.X *= 0.8f; + + // Half second delay before jumping + if (!dontAttack) + NPC.ai[1] += 1f; + + if (NPC.ai[1] >= 30f) + { + NPC.ai[1] = -20f; + } + else if (NPC.ai[1] == -1f) + { + // Set damage + NPC.damage = NPC.defDamage; + + // Set jump velocity, reset and set AI to next phase (Stomp) + float distanceFromPlayerOnXAxis = NPC.Center.X - player.Center.X; + NPC.direction = distanceFromPlayerOnXAxis < 0 ? 1 : -1; + calamityGlobalNPC.newAI[3] = NPC.direction; + + // The limit for how much Aureus can multiply its jump velocity + float speedMultLimit = 1f; + + // Maxes out when the player is a full 2000 pixels away from or above Aureus + float multiplier = 1f / 2000f; + + // Increase Aureus jump velocity X if it's far enough away from the player + float distanceAwayFromTarget = Math.Abs(distanceFromPlayerOnXAxis); + float distanceGateValue = 400f; + bool increaseJumpVelocityX = distanceAwayFromTarget > distanceGateValue && expertMode; + if (increaseJumpVelocityX) + { + calamityGlobalNPC.newAI[0] = (distanceAwayFromTarget - distanceGateValue) * multiplier; + if (calamityGlobalNPC.newAI[0] > speedMultLimit) + calamityGlobalNPC.newAI[0] = speedMultLimit; + } + + // Increase Aureus jump velocity Y if it's far enough above the player + float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); + bool increaseJumpVelocityY = distanceBelowTarget > 0f && revenge; + if (increaseJumpVelocityY) + { + calamityGlobalNPC.newAI[1] = distanceBelowTarget * multiplier; + if (calamityGlobalNPC.newAI[1] > speedMultLimit) + calamityGlobalNPC.newAI[1] = speedMultLimit; + } + + float velocity = 20f; + if (expertMode) + velocity += death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + if (Main.getGoodWorld) + velocity *= 1.15f; + + NPC.velocity = (new Vector2(player.Center.X, player.Center.Y - 500f) - NPC.Center).SafeNormalize(Vector2.Zero) * velocity; + NPC.velocity *= new Vector2(calamityGlobalNPC.newAI[0] + 1f, calamityGlobalNPC.newAI[1] + 1f); + + NPC.noTileCollide = true; + + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + + SoundEngine.PlaySound(JumpSound, NPC.Center); + + NPC.netUpdate = true; + } + } + + // Don't run custom gravity when starting a jump + if (NPC.ai[0] != 4f) + CustomGravity(); + } + + // Stomp + else if (NPC.ai[0] == 4f) + { + if (NPC.velocity.Y == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + // Play stomp sound. Gotta specify the filepath to avoid confusion between the namespace and NPC + SoundStyle soundToPlay = Main.zenithWorld ? ExoMechs.Ares.AresGaussNuke.NukeExplosionSound : StompSound; + SoundEngine.PlaySound(soundToPlay, NPC.Center); + + if (Main.zenithWorld) + { + float screenShakePower = 16 * Utils.GetLerpValue(1300f, 0f, NPC.Distance(Main.LocalPlayer.Center), true); + Main.LocalPlayer.SetScreenshake(screenShakePower); + } + + // Stomp and jump again, if stomped twice then reset and set AI to next phase (Teleport or Idle) + NPC.TargetClosest(); + NPC.localAI[1] += 1f; + float maxStompAmt = phase5 ? 5f : phase3 ? 2f : 3f; + if (NPC.localAI[1] >= maxStompAmt) + { + NPC.ai[0] = exhausted ? 1f : (phase3 ? 5f : 2f); + NPC.localAI[1] = 0f; + NPC.ai[2] += 1f; + NPC.ai[3] = 0f; + NPC.noTileCollide = false; + NPC.netUpdate = true; + } + else + { + float playerLocation = NPC.Center.X - player.Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.ai[0] = 3f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + // Spawn dust for visual effect + for (int i = (int)NPC.position.X - 20; i < (int)NPC.position.X + NPC.width + 40; i += 20) + { + for (int j = 0; j < 4; j++) + { + int stompDust = Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y + NPC.height), NPC.width + 20, 4, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); + Main.dust[stompDust].velocity *= 0.2f; + } + } + + // Fire lasers or flames on stomp + SoundEngine.PlaySound(LaserSound, NPC.Center); + + if (Main.zenithWorld) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + bool crystal = Main.rand.NextBool(); + int type = crystal ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = crystal ? CrystalDamage : LaserDamage; + int totalProjectiles = death ? 12 : revenge ? 10 : expertMode ? 8 : 6; + float radians = MathHelper.TwoPi / totalProjectiles; + float velocity = 10f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f); + } + } + } + else if (calamityGlobalNPC.newAI[2] == 0f && phase2) + { + calamityGlobalNPC.newAI[2] = 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float flameVelocity = 6f; + int maxProjectiles = death ? 3 : 2; + int spread = death ? 28 : 20; + + int type = ModContent.ProjectileType(); + Vector2 spawnVector = new Vector2(NPC.Center.X, NPC.Center.Y - 80f * NPC.scale); + Vector2 destination = new Vector2(spawnVector.X, spawnVector.Y + 100f * NPC.scale); + Vector2 projectileVelocity = Vector2.Normalize(destination - spawnVector) * flameVelocity; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < maxProjectiles; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector + Vector2.Normalize(perturbedSpeed) * 100f, perturbedSpeed, type, CrystalDamage, 0f, Main.myPlayer); + } + } + } + else + { + calamityGlobalNPC.newAI[2] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float laserVelocity = Main.getGoodWorld ? 7f : death ? 6f : 5f; + int maxProjectiles = !phase3 ? (death ? 11 : 9) : (death ? 15 : 13); + int spread = !phase3 ? (death ? 18 : 16) : (death ? 22 : 20); + + int type = ModContent.ProjectileType(); + int[] lasersToNotFire = new int[4] { 1, 3, maxProjectiles - 2, maxProjectiles - 4 }; + Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * laserVelocity; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < maxProjectiles; i++) + { + if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3]) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, LaserDamage, 0f, Main.myPlayer, 0f, laserVelocity * 2f); + } + } + } + } + } + else + { + // Set damage + NPC.damage = NPC.defDamage; + + // Set velocities while falling, this happens before the stomp + // Fall through + if (!player.dead) + { + if ((player.position.Y > NPC.Bottom.Y && NPC.velocity.Y > 0f) || (player.position.Y < NPC.Bottom.Y && NPC.velocity.Y < 0f)) + NPC.noTileCollide = true; + else if ((NPC.velocity.Y > 0f && NPC.Bottom.Y > Main.player[NPC.target].Top.Y) || (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height))) + NPC.noTileCollide = false; + } + + if (NPC.position.X < player.position.X && NPC.position.X + NPC.width > player.position.X + player.width) + { + // Make sure Aureus falls quickly when directly on top of or below the player + if (NPC.ai[3] < 30f) + NPC.ai[3] = 30f; + + NPC.velocity.X *= 0.8f; + + if (NPC.Bottom.Y < player.position.Y) + { + // Make sure Aureus falls rather quickly + if (NPC.velocity.Y < -3f) + NPC.velocity.Y = -3f; + + float fallSpeed = 1.2f; + if (expertMode) + fallSpeed += death ? 0.36f * (1f - lifeRatio) : 0.24f * (1f - lifeRatio); + if (Main.getGoodWorld) + fallSpeed += 0.5f; + + if (calamityGlobalNPC.newAI[1] > 0f) + fallSpeed *= calamityGlobalNPC.newAI[1] + 1f; + + NPC.velocity.Y += fallSpeed; + } + } + else + { + // Push Aureus towards the player on the X axis if he's not directly on top of or below the player + float velocityXChange = 0.2f + Math.Abs(NPC.Center.X - player.Center.X) * 0.0001f; + + if (calamityGlobalNPC.newAI[0] > 0f) + velocityXChange *= calamityGlobalNPC.newAI[0] + 1f; + + if (NPC.direction < 0) + NPC.velocity.X -= velocityXChange; + else if (NPC.direction > 0) + NPC.velocity.X += velocityXChange; + + float velocityXCap = 12f; + if (expertMode) + velocityXCap += death ? 3.6f * (1f - lifeRatio) : 2.4f * (1f - lifeRatio); + if (Main.getGoodWorld) + velocityXCap += 5f; + + if (calamityGlobalNPC.newAI[0] > 0f) + velocityXCap *= calamityGlobalNPC.newAI[0] + 1f; + + float playerLocation = NPC.Center.X - player.Center.X; + int directionRelativeToTarget = playerLocation < 0 ? 1 : -1; + bool slowDown = directionRelativeToTarget != calamityGlobalNPC.newAI[3]; + + if (slowDown) + velocityXCap *= 0.333f; + + if (NPC.velocity.X < -velocityXCap) + NPC.velocity.X = -velocityXCap; + if (NPC.velocity.X > velocityXCap) + NPC.velocity.X = velocityXCap; + } + + // Don't start falling quickly until half a second has passed + NPC.ai[3] += 1f; + if (NPC.ai[3] > 30f) + CustomGravity(); + } + } + + // Teleport + else if (NPC.ai[0] == 5f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + // Slow down + NPC.velocity.X *= 0.8f; + + // Start teleport + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 1f; + if (death) + NPC.localAI[2] += 1.25f; + + if (phase4) + { + NPC.localAI[1] += 1f; + if (death) + NPC.localAI[2] += 1.25f; + } + + if (NPC.localAI[1] >= (death ? 180f : 240f)) + { + // Reset localAI and find a teleport destination + NPC.TargetClosest(); + NPC.localAI[1] = 0f; + + Vector2 vectorAimedAheadOfTarget = Main.player[NPC.target].Center + new Vector2((float)Math.Round(Main.player[NPC.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1000f; + Point point4 = vectorAimedAheadOfTarget.ToTileCoordinates(); + int teleportTries = 0; + while (teleportTries < 100) + { + teleportTries++; + int teleportTileX = Main.rand.Next(point4.X - 5, point4.X + 6); + int teleportTileY = Main.rand.Next(point4.Y - 5, point4.Y); + + if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) + { + NPC.ai[1] = teleportTileX * 16 + 8; + NPC.ai[3] = teleportTileY * 16 + 16; + break; + } + } + + // Default teleport if the above conditions aren't met in 100 iterations + if (teleportTries >= 100) + { + Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; + NPC.ai[1] = bottom.X; + NPC.ai[3] = bottom.Y; + } + + // Set AI to next phase (Mid-teleport) + NPC.ai[0] = 6f; + NPC.netUpdate = true; + } + } + + CustomGravity(); + } + + // Mid-teleport + else if (NPC.ai[0] == 6f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (death) + NPC.localAI[2] += 1.25f; + + if (phase4) + { + if (death) + NPC.localAI[2] += 1.25f; + } + + // Turn invisible + NPC.alpha += 10; + if (NPC.alpha >= 255) + { + // Set position to teleport destination + NPC.Bottom = new Vector2(NPC.ai[1], NPC.ai[3]); + + // Reset alpha and set AI to next phase (End of teleport) + NPC.alpha = 255; + NPC.ai[0] = 7f; + NPC.localAI[2] = 0f; + NPC.netUpdate = true; + } + + // Play sound for cool effect + if (NPC.soundDelay == 0) + { + NPC.soundDelay = 15; + SoundEngine.PlaySound(TeleportSound, NPC.Center); + } + + // Emit dust to make the teleport pretty + for (int i = 0; i < 10; i++) + { + int teleportDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, ModContent.DustType(), NPC.velocity.X, NPC.velocity.Y, 255, default, 2f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity *= 0.5f; + } + + CustomGravity(); + } + + // End of teleport + else if (NPC.ai[0] == 7f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + // Turn visible + NPC.alpha -= 10; + if (NPC.alpha <= 0) + { + // Spawn Aureus Spawns + bool spawnFlag = expertMode; + if (NPC.CountNPCS(ModContent.NPCType()) >= 2) + spawnFlag = false; + + if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient) + { + int aureusSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y - 25f * NPC.scale), ModContent.NPCType()); + Main.npc[aureusSpawn].velocity.Y = -10f; + Main.npc[aureusSpawn].netUpdate = true; + if (revenge) + { + aureusSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y - 25f * NPC.scale), ModContent.NPCType()); + Main.npc[aureusSpawn].velocity.Y = -15f; + Main.npc[aureusSpawn].netUpdate = true; + } + + if (death) + { + int damageAmt = NPC.lifeMax / 50; + NPC.life -= damageAmt; + if (NPC.life < 1) + NPC.life = 1; + + NPC.DamageEffect(damageAmt); + } + } + + // Reset alpha and set AI to next phase (Idle) + NPC.alpha = 0; + NPC.ai[0] = exhausted ? 1f : 2f; + NPC.ai[1] = 0f; + NPC.ai[2] += 1f; + NPC.localAI[3] = noProjectileOrPhaseIncrementTime; + + // Stop colliding with tiles if entering walking phase + NPC.noTileCollide = NPC.ai[0] == 2f; + + NPC.netUpdate = true; + } + + // Play sound at teleport destination for cool effect + if (NPC.soundDelay == 0) + { + NPC.soundDelay = 15; + SoundEngine.PlaySound(SoundID.Item109, NPC.Center); + } + + // Emit dust to make the teleport pretty + for (int i = 0; i < 10; i++) + { + int teleportDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, ModContent.DustType(), NPC.velocity.X, NPC.velocity.Y, 255, default, 2f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity *= 0.5f; + } + + CustomGravity(); + } + + void CustomGravity() + { + float gravity = 0.36f; + float maxFallSpeed = 12f; + + if (calamityGlobalNPC.newAI[1] > 0f && !reduceFallSpeed) + maxFallSpeed *= calamityGlobalNPC.newAI[1] + 1f; + + if (Main.getGoodWorld && !reduceFallSpeed) + { + gravity *= 1.15f; + maxFallSpeed *= 1.15f; + } + + NPC.velocity.Y += gravity; + if (NPC.velocity.Y > maxFallSpeed) + NPC.velocity.Y = maxFallSpeed; + } } + public override bool? CanFallThroughPlatforms() => NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height; public override void FindFrame(int frameHeight) { @@ -370,7 +1279,7 @@ namespace CalamityMod.NPCs.AstrumAureus return false; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.GreaterHealingPotion; } @@ -399,7 +1308,8 @@ namespace CalamityMod.NPCs.AstrumAureus normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Other normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 9, 12)); @@ -412,11 +1322,11 @@ namespace CalamityMod.NPCs.AstrumAureus // Relic npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); - // GFB Crab Banner and Asteroid Staff drop + // GFB troll drops: Crab Banners and a random item which uses Luminite Bars + // Luminite Bar item drop is handled in a separate mod system var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.CrabBanner, 1, 1, 9999, true); - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.CrabBanner, 1, 1, 9999), true); } // Lore @@ -431,8 +1341,6 @@ namespace CalamityMod.NPCs.AstrumAureus CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedAstrumAureus); - // If Astrum Aureus has not yet been killed, notify players of new Astral enemy drops if (!DownedBossSystem.downedAstrumAureus) { @@ -440,8 +1348,8 @@ namespace CalamityMod.NPCs.AstrumAureus string key2 = "Mods.CalamityMod.Status.Progression.AureusBossText2"; Color messageColor = Color.Gold; - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(key2, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key2, messageColor); } // Drop an Astral Meteor if applicable @@ -511,7 +1419,6 @@ namespace CalamityMod.NPCs.AstrumAureus public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } // Can only hit the target if within certain distance @@ -581,7 +1488,28 @@ namespace CalamityMod.NPCs.AstrumAureus public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 200, true); + target.AddBuff(ModContent.BuffType(), 360); + } + } + + // This ModSystem is used to allow Aureus to drop a random item which uses Luminite Bars in its recipe in Get fixed boi. + // This cannot be placed in ModifyNPCLoot, because ModifyNPCLoot is run before modded recipes are initialized. Thus, placing it there would only drop vanilla items. + // As a funny side effect, this also allows for dropping items from other mods which use Luminite Bars in their recipes. + public class AddAureusGFBDrop : ModSystem + { + public override void PostSetupRecipes() + { + // Iterate through all recipes, and list the items which use Luminite Bars in their recipes. + List luminiteStuff = []; + for (int i = 0; i < Main.recipe.Length; i++) + { + if (Main.recipe[i].ContainsIngredient(ItemID.LunarBar) && !luminiteStuff.Contains(Main.recipe[i].createItem.type)) + luminiteStuff.Add(Main.recipe[i].createItem.type); + } + // Define the conditional for GFB. + LeadingConditionRule GFBOnly = new LeadingConditionRule(DropHelper.GFB); + GFBOnly.OnSuccess(ItemDropRule.OneFromOptionsNotScalingWithLuck(1, luminiteStuff.ToArray())); + Main.ItemDropsDB.RegisterToNPCNetId(ModContent.NPCType(), GFBOnly); } } } diff --git a/NPCs/AstrumAureus/AureusSpawn.cs b/NPCs/AstrumAureus/AureusSpawn.cs index cb5ac7cbd0..9d20520ac4 100644 --- a/NPCs/AstrumAureus/AureusSpawn.cs +++ b/NPCs/AstrumAureus/AureusSpawn.cs @@ -35,9 +35,9 @@ namespace CalamityMod.NPCs.AstrumAureus public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 60; // 120 NPC.aiStyle = -1; AIType = -1; - NPC.GetNPCDamage(); NPC.width = 90; NPC.height = 60; NPC.Opacity = 0f; @@ -308,11 +308,10 @@ namespace CalamityMod.NPCs.AstrumAureus { if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 36 : (3 + (int)((NPC.scale - 1f) * 3)); + int totalProjectiles = 3 + (int)((NPC.scale - 1f) * 3); double radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - int damage2 = NPC.GetProjectileDamage(type); - float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : 6f; + float velocity = 6f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); @@ -320,7 +319,7 @@ namespace CalamityMod.NPCs.AstrumAureus for (int k = 0; k < totalProjectiles; k++) { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector255, type, damage2, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector255, type, AstrumAureus.LaserDamage, 0f, Main.myPlayer); } } } @@ -379,7 +378,7 @@ namespace CalamityMod.NPCs.AstrumAureus public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { int debuffType = Main.zenithWorld ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(debuffType, (int)(75 * NPC.scale), true); + target.AddBuff(debuffType, (int)(120 * NPC.scale)); } } } diff --git a/NPCs/AstrumDeus/AstrumDeusBody.cs b/NPCs/AstrumDeus/AstrumDeusBody.cs index 48520d3f9e..1a017ad86a 100644 --- a/NPCs/AstrumDeus/AstrumDeusBody.cs +++ b/NPCs/AstrumDeus/AstrumDeusBody.cs @@ -1,13 +1,16 @@ -using System.IO; +using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; @@ -15,6 +18,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AstrumDeus { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(AstrumDeusHead))] public class AstrumDeusBody : ModNPC { @@ -25,8 +29,11 @@ namespace CalamityMod.NPCs.AstrumDeus public static Asset TextureGlow2; public static Asset TextureGlow3; public static Asset TextureGlow4; + public static Asset TextureFlash; + public static Asset TextureFlash2; public static Asset TextureAltGlow1; public static Asset TextureAltGlow2; + public static Asset TextureAltFlash; public override void SetStaticDefaults() { @@ -39,14 +46,21 @@ namespace CalamityMod.NPCs.AstrumDeus TextureGlow2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); TextureGlow3 = ModContent.Request(Texture + "Glow3", AssetRequestMode.AsyncLoad); TextureGlow4 = ModContent.Request(Texture + "Glow4", AssetRequestMode.AsyncLoad); + TextureFlash = ModContent.Request(Texture + "GlowFlash", AssetRequestMode.AsyncLoad); + TextureFlash2 = ModContent.Request(Texture + "GlowFlash2", AssetRequestMode.AsyncLoad); TextureAltGlow1 = ModContent.Request(Texture + "AltGlow", AssetRequestMode.AsyncLoad); TextureAltGlow2 = ModContent.Request(Texture + "AltGlow2", AssetRequestMode.AsyncLoad); + TextureAltFlash = ModContent.Request(Texture + "AltGlowFlash", AssetRequestMode.AsyncLoad); } } + public static int LaserDamage = 30; // 120 + public static int HelixLaserDamage = 40; // 160 + public static int MineDamage = 40; // 160 + public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 70; // 140 NPC.npcSlots = 5f; NPC.width = 38; NPC.height = 44; @@ -57,9 +71,7 @@ namespace CalamityMod.NPCs.AstrumDeus AIType = -1; NPC.knockBackResist = 0f; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.5f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.4f; else if (CalamityWorld.revenge) NPC.scale *= 1.35f; @@ -77,9 +89,6 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.dontCountMe = true; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -105,7 +114,309 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - AstrumDeusAI.VanillaAstrumDeusAI(NPC, Mod, false); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Difficulty variables + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Deus cannot hit for 3 seconds or while invulnerable + bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || NPC.dontTakeDamage; + if (doNotDealDamage) + NPC.damage = 0; + else + NPC.damage = NPC.defDamage; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool increaseSpeed = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; + bool increaseSpeedMore = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; + + // Inflict Extreme Gravity to nearby players + if (revenge) + { + if (!Main.dedServ) + { + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + } + } + + // Life + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases based on life percentage + bool halfHealth = lifeRatio < 0.5f; + bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f; + bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase; + bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode; + bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode; + bool splittingMines = lifeRatio < 0.7f; + bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode; + bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f; + bool deathModeEnragePhase_BodyAndTail = false; + + // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing + float resistanceTime = doubleWormPhase ? 300f : 600f; + + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime; + + // Flight timer + float aiSwitchTimer = doubleWormPhase ? (Main.getGoodWorld ? 600f : 1200f) : (Main.getGoodWorld ? 900f : 1800f); + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer) + calamityGlobalNPC.newAI[3] = 0f; + // Sound effect for swapping between attack behaviors in phase 2 + if (doubleWormPhase && calamityGlobalNPC.newAI[3] % aiSwitchTimer == 0f && !(deathModeEnragePhase_Head || deathModeEnragePhase_BodyAndTail)) + SoundEngine.PlaySound(AstrumDeusHead.SplitSound with { Pitch = -0.2f, Volume = 0.9f }, player.Center); + + // Phase for flying at the player + bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase; + + // Length of worms + int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50; + int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25; + int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5; + int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length; + + // Become gradually more pissed as more worms are killed + int gfbMaxWormCount = 10; + int gfbWormCount = 0; + if (Main.zenithWorld) + gfbWormCount = NPC.CountNPCS(ModContent.NPCType()); + if (gfbWormCount > gfbMaxWormCount) + gfbWormCount = gfbMaxWormCount; + + // Copy dontTakeDamage and Opacity from head + NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage; + NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; + deathModeEnragePhase_BodyAndTail = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f; + if (deathModeEnragePhase_BodyAndTail) + { + NPC.defense = 25; + calamityGlobalNPC.DR = 0.15f; + } + + // Set worm variable + if (NPC.ai[2] > 0f) + NPC.realLife = (int)NPC.ai[2]; + + // Alpha effects + if (Main.npc[(int)NPC.ai[1]].alpha < 128 && !NPC.dontTakeDamage) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + int headType = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type != headType || !Main.npc[i].active) + continue; + shouldDespawn = false; + break; + } + if (shouldDespawn) + { + if (Main.npc.IndexInRange((int)NPC.ai[1]) && Main.npc[(int)NPC.ai[1]].active && Main.npc[(int)NPC.ai[1]].life > 0) + shouldDespawn = false; + } + if (shouldDespawn) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); + NPC.active = false; + NPC.ForceNetUpdate(false); + } + + // Direction + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + else if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + + bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning + float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; + + float segmentVelocityBoost = 5f * (1f - lifeRatio); + segmentVelocity += segmentVelocityBoost; + if (gfbWormCount > 0) + segmentVelocity += (gfbMaxWormCount - gfbWormCount) * 0.444f; + + if (revenge) + { + float revMultiplier = 1.1f; + segmentVelocity *= revMultiplier; + } + + // Shoot lasers + NPC.localAI[0] += 1f; + + int shootTime = (doubleWormPhase && expertMode) ? 2 : 1; + float shootProjectile = (doubleWormPhase && expertMode) ? 200 : 400; + float timer = NPC.ai[0] + 15f; + float divisor = timer + shootProjectile; + bool canFireProjectiles = NPC.Opacity >= 1f; + bool shootGodRays = phase2 || deathModeEnragePhase_BodyAndTail; + + if (canFireProjectiles) + { + if (!flyAtTarget || deathModeEnragePhase_BodyAndTail) + { + float laserDivisor = (phase2 && !deathModeEnragePhase_BodyAndTail) ? 4f : 2f; + if (NPC.localAI[0] % divisor == 0f && NPC.ai[0] % laserDivisor == 0f) + { + NPC.TargetClosest(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (deathModeEnragePhase_BodyAndTail) + { + Vector2 velocity = Vector2.Zero; + if (movingMines) + { + Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + randomMineMovement.Normalize(); + randomMineMovement *= Main.rand.Next(90, 121) * 0.01f; + velocity = randomMineMovement; + } + + int type = ModContent.ProjectileType(); + float split = (splittingMines && NPC.ai[0] % 3f == 0f) ? 1f : 0f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, MineDamage, 0f, Main.myPlayer, split, 0f); + } + } + + if (Vector2.Distance(player.Center, NPC.Center) > 80f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float deusLaserSpeed = death ? 16f : revenge ? 14f : 13f; + if (gfbWormCount > 0) + deusLaserSpeed += (gfbMaxWormCount - gfbWormCount) * 0.444f; + + Vector2 deusLaserCenter = NPC.Center; + float deusLaserTargetX = player.Center.X - deusLaserCenter.X; + float deusLaserTargetY = player.Center.Y - deusLaserCenter.Y; + float deusLaserTargetDist = (float)Math.Sqrt(deusLaserTargetX * deusLaserTargetX + deusLaserTargetY * deusLaserTargetY); + deusLaserTargetDist = deusLaserSpeed / deusLaserTargetDist; + deusLaserTargetX *= deusLaserTargetDist; + deusLaserTargetY *= deusLaserTargetDist; + deusLaserCenter.X += deusLaserTargetX * 5f; + deusLaserCenter.Y += deusLaserTargetY * 5f; + + Vector2 shootDirection = new Vector2(deusLaserTargetX, deusLaserTargetY).SafeNormalize(Vector2.UnitY); + Vector2 laserVelocity = shootDirection * deusLaserSpeed; + + int type = shootGodRays ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = shootGodRays ? HelixLaserDamage : LaserDamage; + if (shootGodRays) + { + SoundEngine.PlaySound(AstrumDeusHead.GodRaySound, NPC.Center); + // Waving beams need to start offset so they cross each other neatly. + float waveSideOffset = Main.rand.NextFloat(9f, 14f); + Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset; + + for (int i = -1; i <= 1; i += 2) + { + Vector2 laserStartPos = deusLaserCenter + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); + Projectile godRay = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), laserStartPos, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + + // Tell this Phased God Ray exactly which way it should be waving. + godRay.localAI[1] = i * 0.5f; + } + } + else + { + SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); + Projectile.NewProjectile(NPC.GetSource_FromAI(), deusLaserCenter, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); + } + } + } + } + } + else + { + if (NPC.localAI[0] % divisor == 0f && NPC.ai[0] % 2f == 0f) + { + Vector2 velocity = Vector2.Zero; + if (movingMines) + { + Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + randomMineMovement.Normalize(); + randomMineMovement *= Main.rand.Next(30, 121) * 0.01f; + velocity = randomMineMovement; + } + + int type = ModContent.ProjectileType(); + float split = (splittingMines && NPC.ai[0] % 3f == 0f) ? 1f : 0f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, MineDamage, 0f, Main.myPlayer, split, 0f); + } + } + } + + // Follow the head + Vector2 segmentCenter = NPC.Center; + float segmentTargetX = player.Center.X; + float segmentTargetY = player.Center.Y; + segmentTargetX = (int)(segmentTargetX / 16f) * 16; + segmentTargetY = (int)(segmentTargetY / 16f) * 16; + segmentCenter.X = (int)(segmentCenter.X / 16f) * 16; + segmentCenter.Y = (int)(segmentCenter.Y / 16f) * 16; + segmentTargetX -= segmentCenter.X; + segmentTargetY -= segmentCenter.Y; + + if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) + { + try + { + segmentCenter = NPC.Center; + segmentTargetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentCenter.X; + segmentTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentCenter.Y; + } + catch + { + } + + NPC.rotation = (float)Math.Atan2(segmentTargetY, segmentTargetX) + MathHelper.PiOver2; + float segmentTargetDist = (float)Math.Sqrt(segmentTargetX * segmentTargetX + segmentTargetY * segmentTargetY); + int segmentWidth = NPC.width; + segmentTargetDist = (segmentTargetDist - segmentWidth) / segmentTargetDist; + segmentTargetX *= segmentTargetDist; + segmentTargetY *= segmentTargetDist; + NPC.velocity = Vector2.Zero; + NPC.position.X = NPC.position.X + segmentTargetX; + NPC.position.Y = NPC.position.Y + segmentTargetY; + + if (segmentTargetX < 0f) + NPC.spriteDirection = -1; + else if (segmentTargetX > 0f) + NPC.spriteDirection = 1; + } + + // Play spawn sound on Deus on the first frame because otherwise the sound wouldn't play properly in multiplayer + if (calamityGlobalNPC.newAI[1] == 0f && !doubleWormPhase) + { + SoundEngine.PlaySound(AstrumDeusHead.SpawnSound, NPC.Center); + calamityGlobalNPC.newAI[1] = 1f; + } + + // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing + if (calamityGlobalNPC.newAI[1] < resistanceTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 1f)) + calamityGlobalNPC.newAI[1] += 1f; } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -118,12 +429,21 @@ namespace CalamityMod.NPCs.AstrumDeus spriteEffects = SpriteEffects.FlipHorizontally; bool altBodyTextures = NPC.localAI[3] == 1f; - bool drawCyan = NPC.Calamity().newAI[3] >= (Main.getGoodWorld ? 300f : 600f); bool deathModeEnragePhase = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f; bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase; + // Need segment amount to get a smooth transition down the worm based on length + int segmentAmt = Main.zenithWorld ? (CalamityWorld.death ? 8 : CalamityWorld.revenge ? 7 : Main.expertMode ? 6 : 5) : (CalamityWorld.death ? 40 : CalamityWorld.revenge ? 35 : Main.expertMode ? 30 : 25); + float cyanThreshold = Main.getGoodWorld ? 300f : 600f; + float transitionStart = MathHelper.Lerp(cyanThreshold * 0.75f, cyanThreshold * 0.95f, 1f - (NPC.ai[3] / (float)segmentAmt)); + float transitionEnd = MathHelper.Lerp(cyanThreshold * 0.8f, cyanThreshold, 1f - (NPC.ai[3] / (float)segmentAmt)); + bool drawCyan = NPC.Calamity().newAI[3] >= transitionEnd && NPC.Calamity().newAI[3] <= cyanThreshold + transitionEnd; + bool inColorTrans = doubleWormPhase && NPC.Calamity().newAI[3] % cyanThreshold >= transitionStart && NPC.Calamity().newAI[3] % cyanThreshold <= transitionEnd; + Texture2D mainWormTex = altBodyTextures ? AltTexture.Value : TextureAssets.Npc[Type].Value; Texture2D secondWormTex = TextureGlow2.Value; + Texture2D mainFlashTex = altBodyTextures ? TextureAltFlash.Value : TextureFlash.Value; + Texture2D otherMainTex, otherSecondTex; Vector2 halfSizeTex = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / 2); Vector2 drawLocation = NPC.Center - screenPos; @@ -132,26 +452,50 @@ namespace CalamityMod.NPCs.AstrumDeus spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); mainWormTex = altBodyTextures ? TextureAltGlow1.Value : TextureGlow1.Value; + float colorOpacity = Utils.GetLerpValue(transitionStart, transitionEnd, NPC.Calamity().newAI[3] % cyanThreshold, true); Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; - if (doubleWormPhase) + Color otherPhaseColor = drawCyan ? Color.Orange : Color.Cyan; + if (doubleWormPhase) // otherMainTex and otherSecondTex contain the opposite texture, and are faded in during the transition { mainWormTex = drawCyan ? mainWormTex : (altBodyTextures ? TextureAltGlow2.Value : TextureGlow3.Value); + otherMainTex = drawCyan ? (altBodyTextures ? TextureAltGlow2.Value : TextureGlow3.Value) : mainWormTex; secondWormTex = drawCyan ? TextureGlow4.Value : secondWormTex; + otherSecondTex = drawCyan ? secondWormTex : TextureGlow4.Value; + } + else + { + otherMainTex = mainWormTex; + otherSecondTex = secondWormTex; } Color mainWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); Color secondWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, mainWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + { + spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, mainWormColorLerp * (inColorTrans ? 1f - colorOpacity : 1f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the new fading in glowmask for the upcoming behavior + if (inColorTrans) + spriteBatch.Draw(otherMainTex, drawLocation, NPC.frame, Color.Lerp(Color.White, otherPhaseColor, 0.5f) * colorOpacity, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the white flash immediately after swapping behaviors + if (doubleWormPhase && NPC.Calamity().newAI[3] % cyanThreshold < 25f) + spriteBatch.Draw(mainFlashTex, drawLocation, NPC.frame, Color.White * MathHelper.Lerp(1f, 0f, NPC.Calamity().newAI[3] % cyanThreshold / 25f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + } if (!altBodyTextures) { timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(secondWormTex, drawLocation, NPC.frame, secondWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + { + spriteBatch.Draw(secondWormTex, drawLocation, NPC.frame, secondWormColorLerp * (inColorTrans ? 1f - colorOpacity : 1f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the new fading in glowmask for the upcoming behavior + if (inColorTrans) + spriteBatch.Draw(otherSecondTex, drawLocation, NPC.frame, Color.Lerp(Color.White, otherPhaseColor, 0.5f) * colorOpacity, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the white flash immediately after swapping behaviors + if (doubleWormPhase && NPC.Calamity().newAI[3] % cyanThreshold < 25f) + spriteBatch.Draw(TextureFlash2.Value, drawLocation, NPC.frame, Color.White * MathHelper.Lerp(1f, 0f, NPC.Calamity().newAI[3] % cyanThreshold / 25f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + } } - return false; } @@ -213,13 +557,12 @@ namespace CalamityMod.NPCs.AstrumDeus public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 100, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/AstrumDeus/AstrumDeusBodyAltGlowFlash.png b/NPCs/AstrumDeus/AstrumDeusBodyAltGlowFlash.png new file mode 100644 index 0000000000..ca1a023d67 Binary files /dev/null and b/NPCs/AstrumDeus/AstrumDeusBodyAltGlowFlash.png differ diff --git a/NPCs/AstrumDeus/AstrumDeusBodyGlowFlash.png b/NPCs/AstrumDeus/AstrumDeusBodyGlowFlash.png new file mode 100644 index 0000000000..b6ca774c4d Binary files /dev/null and b/NPCs/AstrumDeus/AstrumDeusBodyGlowFlash.png differ diff --git a/NPCs/AstrumDeus/AstrumDeusBodyGlowFlash2.png b/NPCs/AstrumDeus/AstrumDeusBodyGlowFlash2.png new file mode 100644 index 0000000000..1b450f2ec9 Binary files /dev/null and b/NPCs/AstrumDeus/AstrumDeusBodyGlowFlash2.png differ diff --git a/NPCs/AstrumDeus/AstrumDeusHead.cs b/NPCs/AstrumDeus/AstrumDeusHead.cs index e1e14712ef..fe6991d43f 100644 --- a/NPCs/AstrumDeus/AstrumDeusHead.cs +++ b/NPCs/AstrumDeus/AstrumDeusHead.cs @@ -1,15 +1,15 @@ -using System.IO; -using CalamityMod.BiomeManagers; +using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; @@ -17,8 +17,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Packets; using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -35,6 +34,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AstrumDeus { [AutoloadBossHead] + [HasPierceResist] [LongDistanceNetSync] public class AstrumDeusHead : ModNPC { @@ -50,6 +50,7 @@ namespace CalamityMod.NPCs.AstrumDeus public static Asset TextureGlow2; public static Asset TextureGlow3; public static Asset TextureGlow4; + public static Asset TextureFlash2; // There is intentionally no flash texture for the eyes because I thought it looked weird public override void SetStaticDefaults() { @@ -69,26 +70,25 @@ namespace CalamityMod.NPCs.AstrumDeus TextureGlow2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); TextureGlow3 = ModContent.Request(Texture + "Glow3", AssetRequestMode.AsyncLoad); TextureGlow4 = ModContent.Request(Texture + "Glow4", AssetRequestMode.AsyncLoad); + TextureFlash2 = ModContent.Request(Texture + "GlowFlash2", AssetRequestMode.AsyncLoad); } } public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 120; // 240 NPC.npcSlots = 5f; NPC.width = 56; NPC.height = 56; NPC.defense = 20; NPC.DR_NERD(0.1f); - NPC.LifeMaxNERB(200000, 240000, 650000); + NPC.LifeMaxNERB(150000, 240000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.5f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.4f; else if (CalamityWorld.revenge) NPC.scale *= 1.35f; @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.boss = true; NPC.BossBar = ModContent.GetInstance(); - NPC.value = Item.buyPrice(0, 50, 0, 0); + NPC.value = Item.buyPrice(gold: 50); NPC.alpha = 255; NPC.behindTiles = true; NPC.noGravity = true; @@ -116,9 +116,6 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.value /= 5; } - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -146,7 +143,634 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - AstrumDeusAI.VanillaAstrumDeusAI(NPC, Mod, true); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Difficulty variables + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Deus cannot hit for 3 seconds or while invulnerable + bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || NPC.dontTakeDamage; + if (doNotDealDamage) + NPC.damage = 0; + else + NPC.damage = NPC.defDamage; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool increaseSpeed = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; + bool increaseSpeedMore = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; + + // Despawn safety, make sure to target another player if the current player target is too far away + if (increaseSpeedMore) + NPC.TargetClosest(); + + // Inflict Extreme Gravity to nearby players + if (revenge) + { + if (!Main.dedServ) + { + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + } + } + + // Life + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases based on life percentage + bool halfHealth = lifeRatio < 0.5f; + bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f; + bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase; + bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode; + bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode; + bool splittingMines = lifeRatio < 0.7f; + bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode; + bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f; + bool deathModeEnragePhase_BodyAndTail = false; + + // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing + float resistanceTime = doubleWormPhase ? 300f : 600f; + + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime; + + // Flight timer + float aiSwitchTimer = doubleWormPhase ? (Main.getGoodWorld ? 600f : 1200f) : (Main.getGoodWorld ? 900f : 1800f); + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer) + calamityGlobalNPC.newAI[3] = 0f; + // Sound effect for swapping between attack behaviors in phase 2 + if (doubleWormPhase && calamityGlobalNPC.newAI[3] % aiSwitchTimer == 0f && !(deathModeEnragePhase_Head || deathModeEnragePhase_BodyAndTail)) + SoundEngine.PlaySound(SplitSound with { Pitch = -0.2f, Volume = 0.9f }, player.Center); + + // Phase for flying at the player + bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase; + + // Length of worms + int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50; + int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25; + int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5; + int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length; + + // Become gradually more pissed as more worms are killed + int gfbMaxWormCount = 10; + int gfbWormCount = 0; + if (Main.zenithWorld) + gfbWormCount = NPC.CountNPCS(ModContent.NPCType()); + if (gfbWormCount > gfbMaxWormCount) + gfbWormCount = gfbMaxWormCount; + + // Split into two worms + float splitAnimationTime = 180f; + bool oneWormAlive = NPC.CountNPCS(ModContent.NPCType()) < 2; + bool deathModeFinalWormEnrage = death && doubleWormPhase && oneWormAlive && calamityGlobalNPC.newAI[1] >= resistanceTime; + if (deathModeFinalWormEnrage) + { + if (calamityGlobalNPC.newAI[0] != 3f) + { + SoundEngine.PlaySound(SplitSound, player.Center); + calamityGlobalNPC.newAI[0] = 3f; + NPC.defense = 12; + calamityGlobalNPC.DR = 0.075f; + + // Despawns the other deus worm segments + int bodyID = ModContent.NPCType(); + int tailID = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC wormseg = Main.npc[i]; + if (!wormseg.active) + continue; + + if ((wormseg.type == bodyID || wormseg.type == tailID) && Main.npc[(int)wormseg.ai[2]].Calamity().newAI[0] != 3f) + { + wormseg.life = 0; + wormseg.active = false; + } + } + } + + calamityGlobalNPC.newAI[2] += 10f; + if (calamityGlobalNPC.newAI[2] > 162f) + calamityGlobalNPC.newAI[2] = 162f; + + NPC.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); + } + + bool despawnRemainingWorm = doubleWormPhase && oneWormAlive && !death; + if ((halfHealth && calamityGlobalNPC.newAI[0] == 0f) || despawnRemainingWorm) + { + NPC.dontTakeDamage = true; + + calamityGlobalNPC.newAI[2] += despawnRemainingWorm ? 10f : 1f; + NPC.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); + + bool despawning = calamityGlobalNPC.newAI[2] == splitAnimationTime; + + // + // CODE TWEAKED BY: OZZATRON + // September 20th, 2020 + // reason: fixing Astrum Deus death mode NPC cap bug + // + + // Despawn the unsplit Astrum Deus and spawn two half-size Astrum Deus worms. + if (despawning) + { + // If this is already a split worm (newAI[0] != 0f) then don't do anything. At all. + if (doubleWormPhase) + return; + + // Mark all existing body and tail segments as inactive. This instantly frees up their NPC slots for the freshly spawned worms. + int bodyID = ModContent.NPCType(); + int tailID = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC wormseg = Main.npc[i]; + if (!wormseg.active) + continue; + if (wormseg.type == bodyID || wormseg.type == tailID) + { + wormseg.life = 0; + wormseg.active = false; + } + } + + // The unsplit Astrum Deus worm head will die next frame. + NPC.life = 0; + + // Do not spawn worms client side. The server handles this. + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int wormamt = Main.zenithWorld ? 5 : 1; + for (int i = 0; i < wormamt; i++) + { + // Now that the original worm doesn't exist, startCount can be zero. + // int startCount = NPC.whoAmI + phase1Length + 1; + int startIndexHeadOne = 1; + int headOneID = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPC.type, startIndexHeadOne); + Main.npc[headOneID].Calamity().newAI[0] = 1f; + Main.npc[headOneID].velocity = Vector2.Normalize(player.Center - Main.npc[headOneID].Center) * 16f; + Main.npc[headOneID].timeLeft *= 20; + Main.npc[headOneID].ForceNetUpdate(); + + // On server, immediately send the correct extra AI of this head to clients. + if (Main.dedServ) + { + SyncCalamityNPCAIArrayPacket.Send(Main.npc[headOneID]); + } + + // Make sure the second split worm is also contiguous. + int startIndexHeadTwo = startIndexHeadOne + phase2Length + 1; + int headTwoID = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPC.type, startIndexHeadTwo); + Main.npc[headTwoID].Calamity().newAI[0] = 2f; + Main.npc[headTwoID].Calamity().newAI[3] = Main.getGoodWorld ? 300f : 600f; + Main.npc[headTwoID].velocity = Vector2.Normalize(player.Center - Main.npc[headTwoID].Center) * 16f; + Main.npc[headTwoID].timeLeft *= 20; + Main.npc[headTwoID].ForceNetUpdate(); + + // On server, immediately send the correct extra AI of this head to clients. + if (Main.dedServ) + { + SyncCalamityNPCAIArrayPacket.Send(Main.npc[headTwoID]); + } + } + + SoundEngine.PlaySound(AstrumDeusHead.SplitSound, player.Center); + } + return; + } + } + + if (Main.zenithWorld && calamityGlobalNPC.newAI[1] < 10f) // desync the deuses + { + float pushForce = 0.25f; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC otherDeus = Main.npc[k]; + // Short circuits to make the loop as fast as possible + if (!otherDeus.active || k == NPC.whoAmI) + continue; + + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherDeus.type == NPC.type; + float taxicabDist = Vector2.Distance(NPC.Center, otherDeus.Center); + float distancegate = 320f; + if (sameProjType && taxicabDist < distancegate) + { + if (NPC.position.X < otherDeus.position.X) + NPC.velocity.X -= pushForce; + else + NPC.velocity.X += pushForce; + + if (NPC.position.Y < otherDeus.position.Y) + NPC.velocity.Y -= pushForce; + else + NPC.velocity.Y += pushForce; + } + } + } + + // Set worm variable + if (NPC.ai[2] > 0f) + NPC.realLife = (int)NPC.ai[2]; + + // Alpha effects + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + + // Direction + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + else if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.ai[0] == 0f) + { + int Previous = NPC.whoAmI; + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + for (int segments = 0; segments < maxLength; segments++) + { + int lol; + if (segments >= 0 && segments < maxLength - 1) + lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, bodyType, NPC.whoAmI); + else + lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, tailType, NPC.whoAmI); + + if (segments % 2 == 0) + Main.npc[lol].localAI[3] = 1f; + + Main.npc[lol].realLife = NPC.whoAmI; + Main.npc[lol].Calamity().newAI[0] = Main.npc[Previous].Calamity().newAI[0]; + Main.npc[lol].Calamity().newAI[3] = Main.npc[Previous].Calamity().newAI[3]; + + if (Main.dedServ) + { + SyncCalamityNPCAIArrayPacket.Send(Main.npc[lol]); + } + + Main.npc[lol].ai[3] = segments + 1; + Main.npc[lol].ai[2] = NPC.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol); + Previous = lol; + } + } + } + + if (NPC.life > Main.npc[(int)NPC.ai[0]].life) + NPC.life = Main.npc[(int)NPC.ai[0]].life; + + bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning + float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; + + float segmentVelocityBoost = 5f * (1f - lifeRatio); + segmentVelocity += segmentVelocityBoost; + if (gfbWormCount > 0) + segmentVelocity += (gfbMaxWormCount - gfbWormCount) * 0.444f; + + if (revenge) + { + float revMultiplier = 1.1f; + segmentVelocity *= revMultiplier; + } + + int headTilePositionX = (int)(NPC.position.X / 16f) - 1; + int headTileWidthPosX = (int)((NPC.position.X + NPC.width) / 16f) + 2; + int headTilePositionY = (int)(NPC.position.Y / 16f) - 1; + int headTileWidthPosY = (int)((NPC.position.Y + NPC.height) / 16f) + 2; + + if (headTilePositionX < 0) + headTilePositionX = 0; + if (headTileWidthPosX > Main.maxTilesX) + headTileWidthPosX = Main.maxTilesX; + if (headTilePositionY < 0) + headTilePositionY = 0; + if (headTileWidthPosY > Main.maxTilesY) + headTileWidthPosY = Main.maxTilesY; + + // Fly or not + bool shouldFly = flyAtTarget; + if (!shouldFly) + { + for (int k = headTilePositionX; k < headTileWidthPosX; k++) + { + for (int l = headTilePositionY; l < headTileWidthPosY; l++) + { + if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[Main.tile[k, l].TileType] || (Main.tileSolidTop[Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) + { + Vector2 vector2; + vector2.X = k * 16f; + vector2.Y = l * 16f; + if (NPC.position.X + NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f) + { + shouldFly = true; + break; + } + } + } + } + } + + // Start flying if target is not within a certain distance + if (!shouldFly) + { + NPC.localAI[1] = 1f; + + Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); + int noFlyZone = 200; + int heightReduction = death ? 130 : (int)(130f * (1f - lifeRatio)); + int height = 400 - heightReduction; + bool outsideNoFlyZone = true; + + if (NPC.position.Y > player.position.Y) + { + for (int m = 0; m < Main.maxPlayers; m++) + { + if (Main.player[m].active) + { + Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, height); + if (rectangle.Intersects(rectangle2)) + { + outsideNoFlyZone = false; + break; + } + } + } + + if (outsideNoFlyZone) + shouldFly = true; + } + } + else + NPC.localAI[1] = 0f; + + // Despawn + if (player.dead) + { + shouldFly = false; + float velocity = 2f; + NPC.velocity.Y -= velocity; + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + segmentVelocity *= 2f; + NPC.velocity.Y -= velocity; + } + + int headType = ModContent.NPCType(); + int bodyType = ModContent.NPCType(); + int tailType = ModContent.NPCType(); + if ((double)NPC.position.Y < Main.topWorld + 16f) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type == headType || Main.npc[i].type == bodyType || Main.npc[i].type == tailType) + { + Main.npc[i].active = false; + Main.npc[i].ForceNetUpdate(false); + } + } + } + } + + // Speed and movement + float speedBoost = death ? (0.1f * (1f - lifeRatio)) : (0.13f * (1f - lifeRatio)); + float turnSpeedBoost = death ? (0.18f * (1f - lifeRatio)) : (0.2f * (1f - lifeRatio)); + float speed = (hasJustSpawned ? 0.26f : deathModeEnragePhase_Head ? 0.2f : death ? 0.18f : 0.13f) + speedBoost; + float turnSpeed = (hasJustSpawned ? 0.3f : deathModeEnragePhase_Head ? 0.27f : death ? 0.25f : 0.2f) + turnSpeedBoost; + if (gfbWormCount > 0) + { + speed += (gfbMaxWormCount - gfbWormCount) * 0.00555f; + turnSpeed += (gfbMaxWormCount - gfbWormCount) * 0.00888f; + } + + if (flyAtTarget) + { + float speedMultiplier = deathModeEnragePhase_Head ? 1.25f : doubleWormPhase ? (phase3 ? 1.25f : phase2 ? 1.2f : 1.15f) : 1f; + speed *= speedMultiplier; + } + + if (revenge) + { + float revMultiplier = 1.1f; + speed *= revMultiplier; + turnSpeed *= revMultiplier; + } + + speed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f; + turnSpeed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f; + + if (Main.getGoodWorld) + { + speed *= 1.15f; + turnSpeed *= 1.15f; + } + + Vector2 deusCenter = NPC.Center; + float deusTargetX = player.Center.X; + float deusTargetY = player.Center.Y; + deusTargetX = (int)(deusTargetX / 16f) * 16; + deusTargetY = (int)(deusTargetY / 16f) * 16; + deusCenter.X = (int)(deusCenter.X / 16f) * 16; + deusCenter.Y = (int)(deusCenter.Y / 16f) * 16; + deusTargetX -= deusCenter.X; + deusTargetY -= deusCenter.Y; + + if (!shouldFly) + { + NPC.velocity.Y += 0.15f; + if (NPC.velocity.Y > segmentVelocity) + NPC.velocity.Y = segmentVelocity; + + // This bool exists to stop the strange wiggle behavior when worms are falling down + bool slowXVelocity = Math.Abs(NPC.velocity.X) > speed; + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.4) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X -= speed * 1.1f; + else + NPC.velocity.X += speed * 1.1f; + } + else if (NPC.velocity.Y == segmentVelocity) + { + if (slowXVelocity) + { + if (NPC.velocity.X < deusTargetX) + NPC.velocity.X += speed; + else if (NPC.velocity.X > deusTargetX) + NPC.velocity.X -= speed; + } + else + NPC.velocity.X = 0f; + } + else if (NPC.velocity.Y > 4f) + { + if (slowXVelocity) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X += speed * 0.9f; + else + NPC.velocity.X -= speed * 0.9f; + } + else + NPC.velocity.X = 0f; + } + } + else + { + float deusTargetDist = (float)Math.Sqrt(deusTargetX * deusTargetX + deusTargetY * deusTargetY); + float deusAbsoluteTargetX = Math.Abs(deusTargetX); + float deusAbsoluteTargetY = Math.Abs(deusTargetY); + float deusTimeToReachTarget = segmentVelocity / deusTargetDist; + deusTargetX *= deusTimeToReachTarget; + deusTargetY *= deusTimeToReachTarget; + + bool speedUpWhileFlying = false; + if (flyAtTarget) + { + if (((NPC.velocity.X > 0f && deusTargetX < 0f) || (NPC.velocity.X < 0f && deusTargetX > 0f) || (NPC.velocity.Y > 0f && deusTargetY < 0f) || (NPC.velocity.Y < 0f && deusTargetY > 0f)) && Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) > speed / 2f && deusTargetDist < 400f) + { + speedUpWhileFlying = true; + + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < segmentVelocity) + NPC.velocity *= 1.1f; + } + + if (NPC.position.Y > player.position.Y) + { + speedUpWhileFlying = true; + + if (Math.Abs(NPC.velocity.X) < segmentVelocity / 2f) + { + if (NPC.velocity.X == 0f) + NPC.velocity.X -= NPC.direction; + + NPC.velocity.X *= 1.1f; + } + else if (NPC.velocity.Y > -segmentVelocity) + NPC.velocity.Y -= speed; + } + } + + if (!speedUpWhileFlying) + { + if (!flyAtTarget) + { + if (((NPC.velocity.X > 0f && deusTargetX > 0f) || (NPC.velocity.X < 0f && deusTargetX < 0f)) && ((NPC.velocity.Y > 0f && deusTargetY > 0f) || (NPC.velocity.Y < 0f && deusTargetY < 0f))) + { + if (NPC.velocity.X < deusTargetX) + NPC.velocity.X += turnSpeed; + else if (NPC.velocity.X > deusTargetX) + NPC.velocity.X -= turnSpeed; + + if (NPC.velocity.Y < deusTargetY) + NPC.velocity.Y += turnSpeed; + else if (NPC.velocity.Y > deusTargetY) + NPC.velocity.Y -= turnSpeed; + } + } + + if ((NPC.velocity.X > 0f && deusTargetX > 0f) || (NPC.velocity.X < 0f && deusTargetX < 0f) || (NPC.velocity.Y > 0f && deusTargetY > 0f) || (NPC.velocity.Y < 0f && deusTargetY < 0f)) + { + if (NPC.velocity.X < deusTargetX) + NPC.velocity.X += speed; + else if (NPC.velocity.X > deusTargetX) + NPC.velocity.X -= speed; + + if (NPC.velocity.Y < deusTargetY) + NPC.velocity.Y += speed; + else if (NPC.velocity.Y > deusTargetY) + NPC.velocity.Y -= speed; + + if (Math.Abs(deusTargetY) < segmentVelocity * 0.2 && ((NPC.velocity.X > 0f && deusTargetX < 0f) || (NPC.velocity.X < 0f && deusTargetX > 0f))) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += speed * 2f; + else + NPC.velocity.Y -= speed * 2f; + } + + if (Math.Abs(deusTargetX) < segmentVelocity * 0.2 && ((NPC.velocity.Y > 0f && deusTargetY < 0f) || (NPC.velocity.Y < 0f && deusTargetY > 0f))) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X += speed * 2f; + else + NPC.velocity.X -= speed * 2f; + } + } + else if (deusAbsoluteTargetX > deusAbsoluteTargetY) + { + if (NPC.velocity.X < deusTargetX) + NPC.velocity.X += speed * 1.1f; + else if (NPC.velocity.X > deusTargetX) + NPC.velocity.X -= speed * 1.1f; + + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += speed; + else + NPC.velocity.Y -= speed; + } + } + else + { + if (NPC.velocity.Y < deusTargetY) + NPC.velocity.Y += speed * 1.1f; + else if (NPC.velocity.Y > deusTargetY) + NPC.velocity.Y -= speed * 1.1f; + + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X += speed; + else + NPC.velocity.X -= speed; + } + } + } + } + + if (shouldFly) + { + if (NPC.localAI[0] != 1f) + NPC.ForceNetUpdate(false); + + NPC.localAI[0] = 1f; + } + else + { + if (NPC.localAI[0] != 0f) + NPC.ForceNetUpdate(false); + + NPC.localAI[0] = 0f; + } + + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + NPC.ForceNetUpdate(false); + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + + // Play spawn sound on Deus on the first frame because otherwise the sound wouldn't play properly in multiplayer + if (calamityGlobalNPC.newAI[1] == 0f && !doubleWormPhase) + { + SoundEngine.PlaySound(SpawnSound, NPC.Center); + calamityGlobalNPC.newAI[1] = 1f; + } + + // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing + if (calamityGlobalNPC.newAI[1] < resistanceTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 1f)) + calamityGlobalNPC.newAI[1] += 1f; } public override bool CheckActive() @@ -166,12 +790,18 @@ namespace CalamityMod.NPCs.AstrumDeus if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - bool drawCyan = NPC.Calamity().newAI[3] >= (Main.getGoodWorld ? 300f : 600f); bool deathModeEnragePhase = NPC.Calamity().newAI[0] == 3f; bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase; + float cyanThreshold = Main.getGoodWorld ? 300f : 600f; + // Head is always the last segment to visually transition + float transitionStart = cyanThreshold * 0.95f; + bool drawCyan = NPC.Calamity().newAI[3] >= cyanThreshold; + bool inColorTrans = doubleWormPhase && NPC.Calamity().newAI[3] % cyanThreshold >= transitionStart; + Texture2D mainWormTex = TextureAssets.Npc[Type].Value; Texture2D secondWormTex = TextureGlow2.Value; + Texture2D otherMainTex, otherSecondTex; Vector2 halfSizeTex = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / 2); Vector2 drawLocation = NPC.Center - screenPos; @@ -180,23 +810,45 @@ namespace CalamityMod.NPCs.AstrumDeus spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); mainWormTex = TextureGlow1.Value; + float colorOpacity = Utils.GetLerpValue(transitionStart, cyanThreshold, NPC.Calamity().newAI[3] % cyanThreshold, true); Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; - if (doubleWormPhase) + Color otherPhaseColor = drawCyan ? Color.Orange : Color.Cyan; + if (doubleWormPhase) // otherMainTex and otherSecondTex contain the opposite texture, and are faded in during the transition { mainWormTex = drawCyan ? mainWormTex : TextureGlow3.Value; + otherMainTex = drawCyan ? TextureGlow3.Value : mainWormTex; secondWormTex = drawCyan ? TextureGlow4.Value : secondWormTex; + otherSecondTex = drawCyan ? secondWormTex : TextureGlow4.Value; + } + else + { + otherMainTex = mainWormTex; + otherSecondTex = secondWormTex; } Color mainWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Cyan, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); Color secondWormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 1 : 2; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, mainWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + { + spriteBatch.Draw(mainWormTex, drawLocation, NPC.frame, mainWormColorLerp * (inColorTrans ? 1f - colorOpacity : 1f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the new fading in glowmask for the upcoming behavior + if (inColorTrans) + spriteBatch.Draw(otherMainTex, drawLocation, NPC.frame, Color.Lerp(Color.White, otherPhaseColor, 0.5f) * colorOpacity, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Eyes intentionally do not flash + } timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(secondWormTex, drawLocation, NPC.frame, secondWormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); - + { + spriteBatch.Draw(secondWormTex, drawLocation, NPC.frame, secondWormColorLerp * (inColorTrans ? 1f - colorOpacity : 1f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the new fading in glowmask for the upcoming behavior + if (inColorTrans) + spriteBatch.Draw(otherSecondTex, drawLocation, NPC.frame, Color.Lerp(Color.White, otherPhaseColor, 0.5f) * colorOpacity, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the white flash immediately after swapping behaviors + if (doubleWormPhase && NPC.Calamity().newAI[3] % cyanThreshold < 25f) + spriteBatch.Draw(TextureFlash2.Value, drawLocation, NPC.frame, Color.White * MathHelper.Lerp(1f, 0f, NPC.Calamity().newAI[3] % cyanThreshold / 25f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + } return false; } @@ -241,9 +893,9 @@ namespace CalamityMod.NPCs.AstrumDeus } } - public override void BossLoot(ref string name, ref int potionType) => potionType = ModContent.ItemType(); + public override void BossLoot(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); + public static bool ShouldNotDropThings(NPC NPC) => NPC.Calamity().newAI[0] == 0f || ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.Calamity().newAI[0] != 3f); public override bool SpecialOnKill() { @@ -288,7 +940,7 @@ namespace CalamityMod.NPCs.AstrumDeus { string key = "Mods.CalamityMod.Status.Progression.AstralBossText"; Color messageColor = Color.Gold; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Mark Astrum Deus as dead @@ -321,7 +973,8 @@ namespace CalamityMod.NPCs.AstrumDeus normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); normalOnly.Add(ModContent.ItemType(), 5); // Materials @@ -345,12 +998,12 @@ namespace CalamityMod.NPCs.AstrumDeus // GFB Worm and Spaghetti drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.Worm, 1, 1, 9999, true); - GFBOnly.Add(ItemID.CanOfWorms, 1, 1, 9999, true); - GFBOnly.Add(ItemID.GummyWorm, 1, 1, 9999, true); - GFBOnly.Add(ItemID.TruffleWorm, 1, 1, 9999, true); - GFBOnly.Add(ItemID.EnchantedNightcrawler, 1, 1, 9999, true); - GFBOnly.Add(ItemID.Spaghetti, 1, 1, 9999, true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Worm, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.CanOfWorms, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.GummyWorm, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.TruffleWorm, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.EnchantedNightcrawler, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Spaghetti, 1, 1, 9999), true); } // Lore @@ -362,7 +1015,7 @@ namespace CalamityMod.NPCs.AstrumDeus public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 200, true); + target.AddBuff(ModContent.BuffType(), 360); } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) diff --git a/NPCs/AstrumDeus/AstrumDeusHeadGlowFlash2.png b/NPCs/AstrumDeus/AstrumDeusHeadGlowFlash2.png new file mode 100644 index 0000000000..a974fd1138 Binary files /dev/null and b/NPCs/AstrumDeus/AstrumDeusHeadGlowFlash2.png differ diff --git a/NPCs/AstrumDeus/AstrumDeusTail.cs b/NPCs/AstrumDeus/AstrumDeusTail.cs index df4cda8149..d231d34b8d 100644 --- a/NPCs/AstrumDeus/AstrumDeusTail.cs +++ b/NPCs/AstrumDeus/AstrumDeusTail.cs @@ -1,13 +1,15 @@ -using System.IO; +using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; @@ -15,6 +17,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.AstrumDeus { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(AstrumDeusHead))] public class AstrumDeusTail : ModNPC { @@ -22,6 +25,7 @@ namespace CalamityMod.NPCs.AstrumDeus public static Asset GlowTexture; public static Asset GlowTexture2; + public static Asset TextureFlash; public override void SetStaticDefaults() { @@ -31,12 +35,13 @@ namespace CalamityMod.NPCs.AstrumDeus { GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); GlowTexture2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); + TextureFlash = ModContent.Request(Texture + "GlowFlash", AssetRequestMode.AsyncLoad); } } public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 60; // 120 NPC.npcSlots = 5f; NPC.width = 52; NPC.height = 68; @@ -47,9 +52,7 @@ namespace CalamityMod.NPCs.AstrumDeus AIType = -1; NPC.knockBackResist = 0f; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.5f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.4f; else if (CalamityWorld.revenge) NPC.scale *= 1.35f; @@ -67,9 +70,6 @@ namespace CalamityMod.NPCs.AstrumDeus NPC.dontCountMe = true; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -93,7 +93,203 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - AstrumDeusAI.VanillaAstrumDeusAI(NPC, Mod, false); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Difficulty variables + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Deus cannot hit for 3 seconds or while invulnerable + bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || NPC.dontTakeDamage; + if (doNotDealDamage) + NPC.damage = 0; + else + NPC.damage = NPC.defDamage; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool increaseSpeed = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; + bool increaseSpeedMore = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; + + // Inflict Extreme Gravity to nearby players + if (revenge) + { + if (!Main.dedServ) + { + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + } + } + + // Life + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases based on life percentage + bool halfHealth = lifeRatio < 0.5f; + bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f; + bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase; + bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode; + bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode; + bool splittingMines = lifeRatio < 0.7f; + bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode; + bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f; + bool deathModeEnragePhase_BodyAndTail = false; + + // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing + float resistanceTime = doubleWormPhase ? 300f : 600f; + + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime; + + // Flight timer + float aiSwitchTimer = doubleWormPhase ? (Main.getGoodWorld ? 600f : 1200f) : (Main.getGoodWorld ? 900f : 1800f); + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer) + calamityGlobalNPC.newAI[3] = 0f; + // Sound effect for swapping between attack behaviors in phase 2 + if (doubleWormPhase && calamityGlobalNPC.newAI[3] % aiSwitchTimer == 0f && !(deathModeEnragePhase_Head || deathModeEnragePhase_BodyAndTail)) + SoundEngine.PlaySound(AstrumDeusHead.SplitSound with { Pitch = -0.2f, Volume = 0.9f }, player.Center); + + // Phase for flying at the player + bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase; + + // Length of worms + int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50; + int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25; + int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5; + int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length; + + // Become gradually more pissed as more worms are killed + int gfbMaxWormCount = 10; + int gfbWormCount = 0; + if (Main.zenithWorld) + gfbWormCount = NPC.CountNPCS(ModContent.NPCType()); + if (gfbWormCount > gfbMaxWormCount) + gfbWormCount = gfbMaxWormCount; + + // Copy dontTakeDamage and Opacity from head + NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage; + NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; + deathModeEnragePhase_BodyAndTail = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f; + if (deathModeEnragePhase_BodyAndTail) + { + NPC.defense = 25; + calamityGlobalNPC.DR = 0.15f; + } + + // Set worm variable + if (NPC.ai[2] > 0f) + NPC.realLife = (int)NPC.ai[2]; + + // Alpha effects + if (Main.npc[(int)NPC.ai[1]].alpha < 128 && !NPC.dontTakeDamage) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + // Check if other segments are still alive, if not, die + bool shouldDespawn = true; + int headType = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type != headType || !Main.npc[i].active) + continue; + shouldDespawn = false; + break; + } + if (shouldDespawn) + { + if (Main.npc.IndexInRange((int)NPC.ai[1]) && Main.npc[(int)NPC.ai[1]].active && Main.npc[(int)NPC.ai[1]].life > 0) + shouldDespawn = false; + } + if (shouldDespawn) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); + NPC.active = false; + NPC.ForceNetUpdate(false); + } + + // Direction + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + else if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + + bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning + float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; + + float segmentVelocityBoost = 5f * (1f - lifeRatio); + segmentVelocity += segmentVelocityBoost; + if (gfbWormCount > 0) + segmentVelocity += (gfbMaxWormCount - gfbWormCount) * 0.444f; + + if (revenge) + { + float revMultiplier = 1.1f; + segmentVelocity *= revMultiplier; + } + + // Follow the head + Vector2 segmentCenter = NPC.Center; + float segmentTargetX = player.Center.X; + float segmentTargetY = player.Center.Y; + segmentTargetX = (int)(segmentTargetX / 16f) * 16; + segmentTargetY = (int)(segmentTargetY / 16f) * 16; + segmentCenter.X = (int)(segmentCenter.X / 16f) * 16; + segmentCenter.Y = (int)(segmentCenter.Y / 16f) * 16; + segmentTargetX -= segmentCenter.X; + segmentTargetY -= segmentCenter.Y; + + if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) + { + try + { + segmentCenter = NPC.Center; + segmentTargetX = Main.npc[(int)NPC.ai[1]].Center.X - segmentCenter.X; + segmentTargetY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentCenter.Y; + } + catch + { + } + + NPC.rotation = (float)Math.Atan2(segmentTargetY, segmentTargetX) + MathHelper.PiOver2; + float segmentTargetDist = (float)Math.Sqrt(segmentTargetX * segmentTargetX + segmentTargetY * segmentTargetY); + int segmentWidth = NPC.width; + segmentTargetDist = (segmentTargetDist - segmentWidth) / segmentTargetDist; + segmentTargetX *= segmentTargetDist; + segmentTargetY *= segmentTargetDist; + NPC.velocity = Vector2.Zero; + NPC.position.X = NPC.position.X + segmentTargetX; + NPC.position.Y = NPC.position.Y + segmentTargetY; + + if (segmentTargetX < 0f) + NPC.spriteDirection = -1; + else if (segmentTargetX > 0f) + NPC.spriteDirection = 1; + } + + // Play spawn sound on Deus on the first frame because otherwise the sound wouldn't play properly in multiplayer + if (calamityGlobalNPC.newAI[1] == 0f && !doubleWormPhase) + { + SoundEngine.PlaySound(AstrumDeusHead.SpawnSound, NPC.Center); + calamityGlobalNPC.newAI[1] = 1f; + } + + // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing + if (calamityGlobalNPC.newAI[1] < resistanceTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 1f)) + calamityGlobalNPC.newAI[1] += 1f; } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -105,11 +301,18 @@ namespace CalamityMod.NPCs.AstrumDeus if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - bool drawCyan = NPC.Calamity().newAI[3] >= (Main.getGoodWorld ? 300f : 600f); bool deathModeEnragePhase = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] == 3f; bool doubleWormPhase = NPC.Calamity().newAI[0] != 0f && !deathModeEnragePhase; + float cyanThreshold = Main.getGoodWorld ? 300f : 600f; + // Tail is always the first segment to visually transition + float transitionStart = cyanThreshold * 0.75f; + float transitionEnd = cyanThreshold * 0.8f; + bool drawCyan = NPC.Calamity().newAI[3] >= transitionEnd && NPC.Calamity().newAI[3] <= cyanThreshold + transitionEnd; + bool inColorTrans = doubleWormPhase && NPC.Calamity().newAI[3] % cyanThreshold >= transitionStart && NPC.Calamity().newAI[3] % cyanThreshold <= transitionEnd; + Texture2D wormTexture = TextureAssets.Npc[Type].Value; + Texture2D otherTexture; Vector2 halfSizeTex = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / 2); Vector2 drawLocation = NPC.Center - screenPos; @@ -119,15 +322,29 @@ namespace CalamityMod.NPCs.AstrumDeus wormTexture = GlowTexture.Value; Color phaseColor = drawCyan ? Color.Cyan : Color.Orange; - if (doubleWormPhase) + Color otherPhaseColor = drawCyan ? Color.Orange : Color.Cyan; + if (doubleWormPhase) // otherTexture contains the opposite texture, and is faded in during the transition + { wormTexture = drawCyan ? GlowTexture2.Value : wormTexture; + otherTexture = drawCyan ? wormTexture : GlowTexture2.Value; + } + else + otherTexture = wormTexture; Color wormColorLerp = Color.Lerp(Color.White, doubleWormPhase ? phaseColor : Color.Orange, 0.5f) * (deathModeEnragePhase ? 1f : NPC.Opacity); int timesToDraw = deathModeEnragePhase ? 3 : drawCyan ? 2 : 1; for (int i = 0; i < timesToDraw; i++) - spriteBatch.Draw(wormTexture, drawLocation, NPC.frame, wormColorLerp, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); - + { + float opacity = Utils.GetLerpValue(transitionStart, transitionEnd, NPC.Calamity().newAI[3] % cyanThreshold, true); + spriteBatch.Draw(wormTexture, drawLocation, NPC.frame, wormColorLerp * (inColorTrans ? 1f - opacity : 1f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the new fading in glowmask for the upcoming behavior + if (inColorTrans) + spriteBatch.Draw(otherTexture, drawLocation, NPC.frame, Color.Lerp(Color.White, otherPhaseColor, 0.5f) * opacity, NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + // Controls drawing the white flash immediately after swapping behaviors + if (doubleWormPhase && NPC.Calamity().newAI[3] % cyanThreshold < 25f) + spriteBatch.Draw(TextureFlash.Value, drawLocation, NPC.frame, Color.White * MathHelper.Lerp(1f, 0f, NPC.Calamity().newAI[3] % cyanThreshold / 25f), NPC.rotation, halfSizeTex, NPC.scale, spriteEffects, 0f); + } return false; } @@ -181,13 +398,12 @@ namespace CalamityMod.NPCs.AstrumDeus public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 75, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/AstrumDeus/AstrumDeusTailGlowFlash.png b/NPCs/AstrumDeus/AstrumDeusTailGlowFlash.png new file mode 100644 index 0000000000..d8f48ba6b6 Binary files /dev/null and b/NPCs/AstrumDeus/AstrumDeusTailGlowFlash.png differ diff --git a/NPCs/BaseWormNPC.cs b/NPCs/BaseWormNPC.cs new file mode 100644 index 0000000000..3535bd42d5 --- /dev/null +++ b/NPCs/BaseWormNPC.cs @@ -0,0 +1,694 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs +{ + #region Animations + public class WormAnimation + { + + + public Dictionary AnimationKeyframes = new(); + + /// + /// The rigidity of segments + /// + public float segmentRigidity = 0.75f; + /// + /// Should this animation mirror to match the worm's X direction? + /// + public bool mirror = true; + /// + /// Should this animation apply the animation's rotation values? + /// + public bool applyRotation = true; + public class WormKeyframe + { + public float[] segmentOffsets = new float[1]; + /// + /// Creates the segment rotation offsets for the given keyframe. + /// Everything to NaN, which will inherit the rotation offset of the frame before it. + /// + public WormKeyframe(params (float, float)[] parameters) + { + segmentOffsets = new float[200]; + var off = new List(); + for (var i = 0; i < 200; i++) + { + bool broken = false; + for (var i2 = 0; i2 < parameters.Length; i2++) + { + if (parameters[i2].Item1 == i) + { + segmentOffsets[i] = parameters[i2].Item2; + broken = true; + break; + } + } + if (!broken) + segmentOffsets[i] = float.NaN; + } + } + + public static WormKeyframe GetCurrent(BaseWormNPC HeadNPC) + { + WormKeyframe kf = new(); + for (var i = 0; i < HeadNPC.Segments.Count(); i++) + { + if (i == 0) + { + + var dif = ShortestAngle(HeadNPC.NPC.rotation, HeadNPC.Segments[i].rotation); + kf.segmentOffsets[i] = dif; + //Main.NewText((HeadNPC.NPC.rotation, HeadNPC.Segments[i].DirectionFrom(HeadNPC.NPC.Center).ToRotation())); + } + else + { + var dif = ShortestAngle(HeadNPC.Segments[i - 1].rotation, HeadNPC.Segments[i].rotation); + kf.segmentOffsets[i] = dif; + } + } + return kf; + } + static float ShortestAngle(float from, float to) + { + float difference = to - from; + + while (difference < -MathHelper.Pi) + difference += MathHelper.TwoPi; + while (difference > MathHelper.Pi) + difference -= MathHelper.TwoPi; + + return difference; + } + /// + /// Converts this keyframe into a usable array. + /// + /// + public float[] ClearTheNaNs() + { + float[] offsets = new float[segmentOffsets.Length]; + for (var i = 0; i < segmentOffsets.Length; i++) + { + if (float.IsNaN(segmentOffsets[i])) + { + if (i == 0) + offsets[i] = 0; + else + offsets[i] = offsets[i - 1]; + } + else + { + offsets[i] = segmentOffsets[i]; + } + } + return offsets; + } + } + + /// + /// Applies this animation for the given frame + /// + /// + /// + public void ApplyAnimationFrame(Entity HeadEntity, float frame) + { + var orderedKeyframes = AnimationKeyframes.OrderBy(x => x.Key); + (int, float[], float)? prev = null; + (int, float[], float)? next = null; + float[] goalSegmentRotOffsets = new float[200]; + float goalRotation = float.NaN; + foreach (var item in orderedKeyframes) + { + if (item.Key < frame) + { + prev = (item.Key, item.Value.Item1.ClearTheNaNs(), item.Value.Item2); + } + else + { + next = (item.Key, item.Value.Item1.ClearTheNaNs(), item.Value.Item2); + break; + } + } + if (next.HasValue && prev.HasValue) + { + float completion = (frame - prev.Value.Item1) / (next.Value.Item1 - prev.Value.Item1); + for (var i = 0; i < goalSegmentRotOffsets.Length; i++) + { + goalSegmentRotOffsets[i] = MathHelper.Lerp(prev.Value.Item2[i], next.Value.Item2[i], completion); + } + if (float.IsNaN(next.Value.Item3) && frame == next.Value.Item1) + AnimationKeyframes[next.Value.Item1] = (AnimationKeyframes[next.Value.Item1].Item1, next.Value.Item3); + if (!float.IsNaN(prev.Value.Item3)) + { + goalRotation = MathHelper.Lerp(prev.Value.Item3, next.Value.Item3, completion); + } + } + else + { + if (prev.HasValue) + goalSegmentRotOffsets = prev.Value.Item2; + if (next.HasValue) + { + goalSegmentRotOffsets = next.Value.Item2; + if (float.IsNaN(next.Value.Item3) && frame == next.Value.Item1) + AnimationKeyframes[next.Value.Item1] = (AnimationKeyframes[next.Value.Item1].Item1, next.Value.Item3); + } + } + //We use the same animation framework for both projectiles and NPCs, but applying it is different for each type and so we do the final applications here. + if (HeadEntity is NPC) + { + BaseWormNPC HeadNPC = ((NPC)HeadEntity).ModNPC(); + if (HeadNPC.Segments.Count > 0) + { + if (applyRotation && !(float.IsNaN(goalRotation))) + { + HeadNPC.NPC.rotation = goalRotation * (mirror ? HeadNPC.NPC.velocity.X.DirectionalSign() : 1); + } + for (int i = 0; i < HeadNPC.Segments.Count; i++) + { + + Vector2 pos1 = HeadNPC.NPC.Center; + float dist = HeadNPC.SegmentTypePositionOffsets[0]; + if (i != 0) + { + dist = HeadNPC.SegmentTypePositionOffsets[HeadNPC.Segments[i - 1].segmentType + 1]; + } + dist *= HeadNPC.NPC.scale; + Vector2 rot = (HeadNPC.NPC.rotation - MathHelper.PiOver2).ToRotationVector2(); + if (rot == Vector2.Zero) + rot = HeadNPC.Segments[0].Center.AngleTo(HeadNPC.NPC.Center).ToRotationVector2(); + if (i >= 1) + { + pos1 = HeadNPC.Segments[i - 1].Center; + rot = HeadNPC.Segments[i - 1].velocity.SafeNormalize(Vector2.Zero); + } + rot = rot.RotatedBy(goalSegmentRotOffsets[i] * (mirror ? HeadNPC.NPC.velocity.X.DirectionalSign() : 1)); + var dir = HeadNPC.Segments[i].Center.DirectionFrom(pos1); + HeadNPC.Segments[i].Center = pos1 + Vector2.Lerp(dir, -(rot), segmentRigidity) * dist; + float rotationOffset = Vector2.Lerp(dir, -(rot), segmentRigidity).ToRotation(); + float finalOffset = (-rot).ToRotation().AngleLerp(rotationOffset, 0); + HeadNPC.Segments[i].Center = pos1 + finalOffset.ToRotationVector2() * dist; + HeadNPC.Segments[i].velocity = HeadNPC.Segments[i].Center.DirectionTo(pos1); + HeadNPC.Segments[i].rotation = HeadNPC.Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + } + + for (int i = 1; i < HeadNPC.Segments.Count - 1; i++) + { + HeadNPC.Segments[i].rotation = HeadNPC.Segments[i + 1].Center.DirectionTo(HeadNPC.Segments[i - 1].Center).ToRotation() + MathHelper.PiOver2; + } + } + } + else if (HeadEntity is Projectile) + { + BaseWormProjectile HeadProjectile = ((Projectile)HeadEntity).ModProjectile(); + if (HeadProjectile.Segments.Count > 0) + { + if (applyRotation && !(float.IsNaN(goalRotation))) + { + HeadProjectile.Projectile.rotation = goalRotation * (mirror ? HeadProjectile.Projectile.velocity.X.DirectionalSign() : 1); + } + for (int i = 0; i < HeadProjectile.Segments.Count; i++) + { + + Vector2 pos1 = HeadProjectile.Projectile.Center; + float dist = HeadProjectile.SegmentTypePositionOffsets[0]; + if (i != 0) + { + dist = HeadProjectile.SegmentTypePositionOffsets[HeadProjectile.Segments[i - 1].segmentType + 1]; + } + dist *= HeadProjectile.Projectile.scale; + Vector2 rot = (HeadProjectile.Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + if (rot == Vector2.Zero) + rot = HeadProjectile.Segments[0].Center.AngleTo(HeadProjectile.Projectile.Center).ToRotationVector2(); + if (i >= 1) + { + pos1 = HeadProjectile.Segments[i - 1].Center; + rot = HeadProjectile.Segments[i - 1].velocity.SafeNormalize(Vector2.Zero); + } + rot = rot.RotatedBy(goalSegmentRotOffsets[i] * (mirror ? HeadProjectile.Projectile.velocity.X.DirectionalSign() : 1)); + var dir = HeadProjectile.Segments[i].Center.DirectionFrom(pos1); + HeadProjectile.Segments[i].Center = pos1 + Vector2.Lerp(dir, -(rot), segmentRigidity) * dist; + HeadProjectile.Segments[i].velocity = HeadProjectile.Segments[i].Center.DirectionTo(pos1); + HeadProjectile.Segments[i].rotation = HeadProjectile.Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + } + + for (int i = 1; i < HeadProjectile.Segments.Count - 1; i++) + { + HeadProjectile.Segments[i].rotation = HeadProjectile.Segments[i + 1].Center.DirectionTo(HeadProjectile.Segments[i - 1].Center).ToRotation() + MathHelper.PiOver2; + } + } + } + } + } + #endregion + + #region Segment Class + /// + /// This class is used to store the information of each segment's location, size, and texture path + /// Due to the amount of segments, there is only one actual NPC for this boss + /// + public class BaseWormSegment + { + /// + /// The type of segment this is. Segment type is used to determine spacing and textures. + /// + public int segmentType = 0; + + /// + /// The position of the center of this segment + /// + public Vector2 Center = Vector2.Zero; + + /// + /// The rotation of this segment in radians + /// + public float rotation = 0; + + /// + /// The velocity this segment has. + /// Currently doesn't actually do anything besides be a token value if needed to be read by something + /// + public Vector2 velocity = Vector2.Zero; + /// + /// How opaque this segment is. Ranges from 1 (fully opaque) to 0 (fully transparent) + /// + public float Opacity = 1; + public BaseWormSegment(ModNPC Head, int segmentStyle = 0) + { + Center = Head.NPC.Center; + rotation = Head.NPC.rotation; + velocity = Head.NPC.velocity; + segmentType = segmentStyle; + } + + public BaseWormSegment(ModProjectile Head, int segmentStyle = 0) + { + Center = Head.Projectile.Center; + rotation = Head.Projectile.rotation; + velocity = Head.Projectile.velocity; + segmentType = segmentStyle; + } + } + #endregion + public abstract class BaseWormNPC : ModNPC + { + #region Abstracts & Commonly Overriden Fields + /// + /// The amount of segments of this worm. This does not include the head + /// + public abstract int SegmentCount { get; } + /// + /// A list of the offsets to the next segment in the worm from this segment + /// DOES include the head + /// + public abstract List SegmentTypePositionOffsets { get; } + /// + /// A list of all textures for the segments to draw with + /// does NOT include the head + /// + public abstract List SegmentTextures { get; } + + /// + /// A list of all glow textures for the segments to draw with + /// DOES include the head + /// + public virtual List GlowTextures { get; } + /// + /// The type of the worm hitbox NPC + /// Make sure that NPC is a child of BaseWormHitboxNPC! + /// + public abstract int WormHitboxNpcType { get; } + /// + /// Offsets for drawing each segment + /// + public List SegmentTypeDrawOffsets = new List(); + + + /// + /// How far through the current animation this worm is + /// + public float AnimationFrame = 0; + /// + /// The active animation for the worm + /// + public WormAnimation ActiveAnimation = null; + #endregion + + #region Segments + /// + /// The list of all segments of this worm + /// + public List Segments = new(); + + /// + /// The textures for each segment type of this worm. Works like getting a texture from TextureAssets + /// + public List> SegmentTextureAssets + { + get + { + if (internalTexAssets.Count == 0) + for (var i = 0; i < SegmentTextures.Count; i++) + { + internalTexAssets.Add(ModContent.Request(SegmentTextures[i])); + if (SegmentTypeDrawOffsets.Count <= i) + { + SegmentTypeDrawOffsets.Add(Vector2.Zero); + } + } + return internalTexAssets; + } + } + + /// + /// Internal list that stores the textureassets. + /// Use SegmentTextureAssets to get the data stored here. + /// + private List> internalTexAssets = new List>(); + /// + /// The textures for each glow type of this worm. Works like getting a texture from TextureAssets + /// + public List> GlowTextureAssets + { + get + { + if (internalGlowAssets.Count == 0) + for (var i = 0; i < GlowTextures.Count; i++) + { + if (GlowTextures[i] is not null) + internalGlowAssets.Add(ModContent.Request(GlowTextures[i])); + else internalGlowAssets.Add(ModContent.Request("CalamityMod/Projectiles/InvisibleProj")); + } + return internalGlowAssets; + } + } + + /// + /// Internal list that stores the glow textureassets. + /// Use SegmentTextureAssets to get the data stored here. + /// + private List> internalGlowAssets = new List>(); + + public enum SegmentFollowLogic + { + Regular = 0, //Traditional worm segment logic + Exact = 1, //Follows the path the head took exactly + // In the future, add a segment logic that supports solid tile collisions and forces applied to *any* segment + } + + /// + /// Which type of segment following logic this worm should currently use + /// + public SegmentFollowLogic SegmentFollowType; + + /// + /// How rigid the segment should be when using default segment logic + /// + public float SegmentRigidity = 0.2f; + + /// + /// The max rotational offset from the direction of the previous segment + /// + public float SegmentMaxRotation = MathHelper.TwoPi; + + /// + /// The points used by ExactSegmentLogic to exactly follow the head + /// + private List segmentPoints = new List(); + + /// + /// Updates the positions of the segments based on the value set in SegmentFollowType + /// + public void UpdateSegments() + { + NPC.position += NPC.velocity; //Update this segment's movement so that all other segments use this as the base. This is undone at the end of the method. + if (ActiveAnimation is not null) + { + ActiveAnimation.ApplyAnimationFrame(NPC, AnimationFrame); + AnimationFrame++; + if (AnimationFrame > ActiveAnimation.AnimationKeyframes.Keys.Max()) + { + AnimationFrame = 0; + ActiveAnimation = null; + } + } + else + { + if (segmentPoints.Count < 1 || segmentPoints[0].Distance(NPC.Center) > 8) + { + segmentPoints.Insert(0, NPC.Center); + } + while (segmentPoints.Count > 300) + { + segmentPoints.RemoveAt(segmentPoints.Count - 1); + } + switch (SegmentFollowType) + { + case (SegmentFollowLogic.Regular): + RegularSegmentLogic(); + break; + case (SegmentFollowLogic.Exact): + ExactSegmentLogic(); + break; + } + } + NPC.position -= NPC.velocity; + + //Spawning hitboxes for all the segments near the player + SpawnHitboxes(); + + } + + private void RegularSegmentLogic() + { + for (int i = 0; i < Segments.Count; i++) + { + float segmentDistance = SegmentTypePositionOffsets[0]; + var thisSeg = Segments[i]; + var aheadSeg = new BaseWormSegment(this); + if (i != 0) + { + aheadSeg = Segments[i - 1]; + segmentDistance = SegmentTypePositionOffsets[Segments[i - 1].segmentType + 1]; + } + segmentDistance *= NPC.scale; + Vector2 nexSegDir = aheadSeg.Center - thisSeg.Center; + if (aheadSeg.rotation != thisSeg.rotation) + { + nexSegDir = nexSegDir.RotatedBy(MathHelper.WrapAngle(aheadSeg.rotation - thisSeg.rotation) * SegmentRigidity); + nexSegDir = nexSegDir.MoveTowards((aheadSeg.rotation - thisSeg.rotation).ToRotationVector2(), 1f); + } + thisSeg.rotation = nexSegDir.ToRotation() + MathHelper.PiOver2; + float angledif = MathHelper.WrapAngle(thisSeg.rotation - aheadSeg.rotation); + thisSeg.rotation = thisSeg.rotation.AngleLerp(aheadSeg.rotation + MathHelper.Clamp(angledif, -SegmentMaxRotation * 0.5f, SegmentMaxRotation * 0.5f),0.25f); + thisSeg.Center = aheadSeg.Center - (thisSeg.rotation -MathHelper.PiOver2).ToRotationVector2() * segmentDistance; + + } + } + + private void ExactSegmentLogic() + { + float dist = 40f; + int segmentPointInUse = 0; + for (int i = 0; i < Segments.Count; i++) + { + var thisSeg = Segments[i]; + var aheadSeg = new BaseWormSegment(this); + if (i != 0) + aheadSeg = Segments[i - 1]; + bool hasMoved = false; + while (segmentPointInUse < segmentPoints.Count) + { + if (segmentPointInUse == 0) + { + if (aheadSeg.Center.Distance(segmentPoints[0]) >= dist) + { + thisSeg.Center = aheadSeg.Center + aheadSeg.Center.DirectionTo(segmentPoints[0]) * dist; + Segments[i].velocity = Segments[i].Center.DirectionTo(aheadSeg.Center); + Segments[i].rotation = Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + hasMoved = true; + break; + } + else + { + segmentPointInUse++; + } + } + else + { + if (aheadSeg.Center.Distance(segmentPoints[segmentPointInUse]) >= dist) + { + thisSeg.Center = aheadSeg.Center + aheadSeg.Center.DirectionTo(segmentPoints[segmentPointInUse]) * dist; + Segments[i].velocity = Segments[i].Center.DirectionTo(aheadSeg.Center); + Segments[i].rotation = Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + hasMoved = true; + break; + } + else + { + segmentPointInUse++; + } + } + } + if (!hasMoved && segmentPointInUse >= segmentPoints.Count) + { + thisSeg.Center = segmentPoints[segmentPoints.Count - 1]; + Segments[i].velocity = Segments[i].Center.DirectionTo(aheadSeg.Center); + Segments[i].rotation = Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + hasMoved = true; + break; + } + } + } + + /// + /// Spawns the hitboxes for the worm's segments. + /// Won't spawn hitboxes if there's less than 5 avaliable NPC slots + /// + public virtual void SpawnHitboxes() + { + if (Main.netMode != NetmodeID.MultiplayerClient) + for (int i = 0; i < Segments.Count; i++) + { + if (Main.npc.Count(x => x.active) >= Main.maxNPCs - 5) + break; + if (Main.player.Any(x => x.active && Segments[i].Center.Distance(x.Center) < 1200)) + { + if (Main.npc.Any(x => x.active && x.type == WormHitboxNpcType && x.ai[1] == i && x.ai[0] == NPC.whoAmI)) + { + Main.npc.First(x => x.active && x.type == WormHitboxNpcType && x.ai[1] == i && x.ai[0] == NPC.whoAmI).ai[2] = 0; + } + else + NPC.NewNPC(NPC.GetSource_Misc("Hitbox"), (int)Segments[i].Center.X, (int)Segments[i].Center.Y + 100, WormHitboxNpcType, ai0: NPC.whoAmI, ai1: i); + } + } + } + #endregion + + #region Defaults + + public override void SetStaticDefaults() + { + NPCID.Sets.MustAlwaysDraw[Type] = true; + } + public override void SetDefaults() + { + for (var i = 0; i < SegmentCount - 1; i++) + { + Segments.Add(new BaseWormSegment(this, 0)); + } + Segments.Add(new BaseWormSegment(this, 1)); + } + + #endregion + + #region Draw + + public override void FindFrame(int frameHeight) + { + if (NPC.IsABestiaryIconDummy) + { + NPC.rotation = MathF.Sin(Main.GlobalTimeWrappedHourly) * 0.2f + MathHelper.PiOver2; + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.IsABestiaryIconDummy) + { + drawColor = Color.White; + SegmentRigidity = 0.1f; + UpdateSegments(); + } + for (int i = Segments.Count - 1; i >= 0; i--) + { + DrawSegment(spriteBatch, screenPos, drawColor, Segments[i]); + } + spriteBatch.Draw(TextureAssets.Npc[Type].Value, NPC.Center - screenPos, null, drawColor* NPC.Opacity, NPC.rotation, TextureAssets.Npc[Type].Value.Size() / 2, NPC.scale, SpriteEffects.None, 1); + if (GlowTextures.Count > 0 && GlowTextures[0] is not null) + spriteBatch.Draw(GlowTextureAssets[0].Value, NPC.Center - screenPos, null, Color.White * NPC.Opacity, NPC.rotation, GlowTextureAssets[0].Size() / 2, NPC.scale, SpriteEffects.None, 1); + return false; + } + + public virtual void DrawSegment(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor, BaseWormSegment segment) + { + var color = Lighting.GetColor(segment.Center.ToTileCoordinates()); + if (NPC.IsABestiaryIconDummy) + { + color = Color.White; + } + if (!SegmentTextureAssets.IndexInRange(segment.segmentType)) + { + return; + } + var tex = SegmentTextureAssets[segment.segmentType].Value; + spriteBatch.Draw(tex, segment.Center - screenPos, null, color * segment.Opacity, segment.rotation, tex.Size() / 2 + (SegmentTypeDrawOffsets[segment.segmentType]), NPC.scale, SpriteEffects.None, 1); + if (!GlowTextures.IndexInRange(segment.segmentType+1) || GlowTextures[segment.segmentType+1] is null) + { + return; + } + tex = GlowTextureAssets[segment.segmentType+1].Value; + spriteBatch.Draw(tex, segment.Center - screenPos, null, Color.White * segment.Opacity, segment.rotation, tex.Size() / 2 + (SegmentTypeDrawOffsets[segment.segmentType]), NPC.scale, SpriteEffects.None, 1); + } + #endregion + } + + //The segments near a player spawn a hitbox NPC to allow damaging players and taking damage + public abstract class BaseWormHitboxNPC : ModNPC + { + public override void SetDefaults() + { + NPC.width = 200; + NPC.height = 200; + NPC.lifeMax = 10000; + NPC.knockBackResist = 0; + NPC.noTileCollide = true; + NPC.aiStyle = -1; + } + + public override bool? CanBeHitByItem(Player player, Item item) + { + var canhit = Main.npc[(int)NPC.ai[0]].ModNPC.CanBeHitByItem(player, item); + if (canhit.HasValue && !canhit.Value) + return false; + return base.CanBeHitByItem(player, item); + } + + public override bool? CanBeHitByProjectile(Projectile projectile) + { + var canhit = Main.npc[(int)NPC.ai[0]].ModNPC.CanBeHitByProjectile(projectile); + if (canhit.HasValue && !canhit.Value) + return false; + return base.CanBeHitByProjectile(projectile); + } + + public override void AI() + { + var headNPC = Main.npc[(int)NPC.ai[0]]; + if (!(headNPC.ModNPC is BaseWormNPC && headNPC.active)) + { + NPC.active = false; + return; + } + NPC.realLife = (int)NPC.ai[0]; + NPC.damage = headNPC.damage; + NPC.lifeMax = headNPC.lifeMax; + NPC.life = headNPC.life; + NPC.Center = (headNPC.ModNPC as BaseWormNPC).Segments[(int)NPC.ai[1]].Center; + } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + return false; + } + } +} diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index 478a14704b..b6b30908e0 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental { NPC.aiStyle = -1; AIType = -1; - NPC.damage = 0; // 0 contact damage, projectile damage values are pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.width = 60; NPC.height = 60; NPC.defense = 0; @@ -93,25 +93,18 @@ namespace CalamityMod.NPCs.BrimstoneElemental } // Variables for buffing the AI - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining for Brim float lifeRatio = Main.npc[CalamityGlobalNPC.brimstoneElemental].life / (float)Main.npc[CalamityGlobalNPC.brimstoneElemental].lifeMax; // Enraged Brim checks - bool biomeEnraged = Main.npc[CalamityGlobalNPC.brimstoneElemental].Calamity().newAI[3] <= 0f || bossRush; - float enrageScale = bossRush ? 1f : 0f; - if (biomeEnraged && (!Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].ZoneUnderworldHeight || bossRush)) - { - Main.npc[CalamityGlobalNPC.brimstoneElemental].Calamity().CurrentlyEnraged = !bossRush; + bool biomeEnraged = Main.npc[CalamityGlobalNPC.brimstoneElemental].Calamity().newAI[3] <= 0f; + float enrageScale = 0f; + if (biomeEnraged && !Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].ZoneUnderworldHeight) enrageScale += 1f; - } - if (biomeEnraged && (!Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].Calamity().ZoneCalamity || bossRush)) - { - Main.npc[CalamityGlobalNPC.brimstoneElemental].Calamity().CurrentlyEnraged = !bossRush; + if (biomeEnraged && !Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].Calamity().ZoneCalamity) enrageScale += 1f; - } // Brim phase checks bool brimIsAboutToTeleport = Main.npc[CalamityGlobalNPC.brimstoneElemental].ai[0] == 1f && Main.npc[CalamityGlobalNPC.brimstoneElemental].alpha == 0; @@ -153,7 +146,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental { float projectileVelocity = 5f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = BrimstoneElemental.DartDamage; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].Center - NPC.Center) * projectileVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocity * 3f); } } @@ -246,7 +239,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental { float projectileVelocity = 5f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = BrimstoneElemental.HellfireballDamage; SoundEngine.PlaySound(BrimstoneElemental.HellfireballSound, NPC.Center); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].Center - NPC.Center) * projectileVelocity, type, damage, 0f, Main.myPlayer, Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].position.X, Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].position.Y); } diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index ca14fd91ab..d2704738f7 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -8,17 +8,19 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -63,15 +65,22 @@ namespace CalamityMod.NPCs.BrimstoneElemental NPCID.Sets.MPAllowedEnemies[Type] = true; } + // These values are all applied alongside their respective GFB attacks (too many to list) + public static int DartDamage = 19; // 76 + public static int HellblastDamage = 24; // 96 + public static int HellfireballDamage = 24; // 96 + public static int RayDamage = 35; // 140 + public override void SetDefaults() { NPC.npcSlots = 64f; - NPC.GetNPCDamage(); + NPC.damage = 56; // 112 + NPC.Calamity().canBreakPlayerDefense = true; NPC.width = 100; NPC.height = 150; NPC.defense = 15; - NPC.value = Item.buyPrice(0, 16, 0, 0); - NPC.LifeMaxNERB(41000, 49200, 500000); + NPC.value = Item.buyPrice(gold: 12); + NPC.LifeMaxNERB(30000, 49200, 500000); NPC.DR_NERD(0.2f); NPC.knockBackResist = 0f; NPC.aiStyle = -1; @@ -86,9 +95,6 @@ namespace CalamityMod.NPCs.BrimstoneElemental NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -123,7 +129,681 @@ namespace CalamityMod.NPCs.BrimstoneElemental public override void AI() { - BrimstoneElementalAI.VanillaBrimstoneElementalAI(NPC, Mod); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Used for Brimling AI states + CalamityGlobalNPC.brimstoneElemental = NPC.whoAmI; + + // Emit light + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1.2f, 0f, 0f); + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + bool despawnDistance = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; + + if (!player.active || player.dead || despawnDistance) + { + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + if (!player.active || player.dead || despawnDistance) + { + NPC.rotation = NPC.velocity.X * 0.04f; + + if (NPC.velocity.Y > 3f) + NPC.velocity.Y = 3f; + NPC.velocity.Y -= 0.1f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + + if (NPC.ai[0] != 0f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[0] = 0f; + NPC.localAI[1] = 0f; + NPC.netUpdate = true; + } + return; + } + } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; + + // Reset defense + NPC.defense = NPC.defDefense; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = NPC.ai[0] == 4f; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Variables for buffing the AI + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + bool phase2 = lifeRatio < 0.5f && revenge; + bool phase3 = lifeRatio < 0.33f; + + // Enrage + if ((!player.ZoneUnderworldHeight || !player.Calamity().ZoneCalamity) && !BossRushEvent.BossRushActive) + { + if (calamityGlobalNPC.newAI[3] > 0f) + calamityGlobalNPC.newAI[3] -= 1f; + } + else + calamityGlobalNPC.newAI[3] = CalamityGlobalNPC.biomeEnrageTimerMax; + + bool biomeEnraged = calamityGlobalNPC.newAI[3] <= 0f; + + float enrageScale = 0f; + if (biomeEnraged && !player.ZoneUnderworldHeight) + { + NPC.Calamity().CurrentlyEnraged = true; + enrageScale += 0.5f; + } + if (biomeEnraged && !player.Calamity().ZoneCalamity) + { + NPC.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } + + NPC.Calamity().DR = NPC.ai[0] == 4f ? 0.6f : 0.2f; + + // Emit dust + int dustAmt = (NPC.ai[0] == 2f) ? 2 : 1; + int size = (NPC.ai[0] == 2f) ? 50 : 35; + if (NPC.ai[0] != 1f) + { + for (int i = 0; i < 2; i++) + { + if (Main.rand.Next(3) < dustAmt) + { + int dust = Dust.NewDust(NPC.Center - new Vector2(size), size * 2, size * 2, DustID.LifeDrain, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.2f; + Main.dust[dust].fadeIn = 1f; + } + } + } + + // Distance from destination where Brimmy stops moving + float movementDistanceGateValue = 100f; + + // How fast Brimmy moves to the destination + float baseVelocity = (death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f) * (NPC.ai[0] == 5f ? 0.05f : NPC.ai[0] == 3f ? 1.5f : 1f); + baseVelocity += 3f * enrageScale; + if (expertMode) + baseVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + + float baseAcceleration = (death ? 0.12f : 0.1f) * (NPC.ai[0] == 5f ? 0.5f : NPC.ai[0] == 3f ? 1.5f : 1f); + baseAcceleration += 0.06f * enrageScale; + if (expertMode) + baseAcceleration += 0.03f * (1f - lifeRatio); + + // This is where Brimmy should be + Vector2 destination = NPC.ai[0] != 3f ? player.Center : new Vector2(player.Center.X, player.Center.Y - 300f); + + // How far Brimmy is from where she's supposed to be + Vector2 distanceFromDestination = destination - NPC.Center; + + // Movement + if (NPC.ai[0] != 4f) + CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, baseAcceleration, true); + + // Rotation and direction + if (NPC.ai[0] <= 2f || NPC.ai[0] == 5f) + { + NPC.rotation = NPC.velocity.X * 0.04f; + if (NPC.ai[0] != 5 || (NPC.ai[1] < 180f && NPC.ai[0] == 5f)) + { + float playerLocation = NPC.Center.X - player.Center.X; + NPC.direction = playerLocation < 0f ? 1 : -1; + NPC.spriteDirection = NPC.direction; + } + } + + if (Main.zenithWorld) // in gfb, Brimmy channels the power of the other elementals. + { + int newMode; + if (lifeRatio <= 0.8f && lifeRatio > 0.6f) + { + newMode = 1; // Sand + } + else if (lifeRatio <= 0.6f && lifeRatio > 0.4f) + { + newMode = 2; // Rare Sand + } + else if (lifeRatio <= 0.4f && lifeRatio > 0.2f) + { + newMode = 3; // Cloud + } + else if (lifeRatio <= 0.2f) + { + newMode = 4; // Water + } + else + { + newMode = 0; // Brimstone, default + } + if (newMode != currentMode) + { + SoundEngine.PlaySound(SoundID.Item29, NPC.Center); + } + currentMode = newMode; + } + + if (NPC.ai[0] == -1f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int phase; + int random = phase2 ? 6 : 5; + do phase = Main.rand.Next(random); + while (phase == NPC.ai[1] || (phase == 0 && phase3 && revenge) || phase == 1 || phase == 2 || (phase == 4 && NPC.localAI[3] != 0f)); + + NPC.ai[0] = phase; + NPC.ai[1] = 0f; + + // Cocoon phase cooldown + if (NPC.localAI[3] > 0f) + NPC.localAI[3] -= 1f; + else if (phase == 4) + { + NPC.localAI[3] = 3f; + SoundEngine.PlaySound(HideInShellSound, player.Center); + } + + // Prevent netUpdate from being blocked by the spam counter. + // A phase switch sync is a critical operation that must be synced. + NPC.ForceNetUpdate(false); + } + } + + // Pick a location to teleport to + else if (NPC.ai[0] == 0f) + { + NPC.chaseable = true; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 1f; + + if (NPC.localAI[1] >= (death ? 120f : 180f)) + { + NPC.TargetClosest(); + NPC.localAI[1] = 0f; + int timer = 0; + int playerPosX; + int playerPosY; + while (true) + { + timer++; + playerPosX = (int)player.Center.X / 16; + playerPosY = (int)player.Center.Y / 16; + + int min = 12; + int max = 16; + + if (Main.rand.NextBool()) + playerPosX += Main.rand.Next(min, max); + else + playerPosX -= Main.rand.Next(min, max); + + if (Main.rand.NextBool()) + playerPosY += Main.rand.Next(min, max); + else + playerPosY -= Main.rand.Next(min, max); + + if (!WorldGen.SolidTile(playerPosX, playerPosY)) + break; + + if (timer > 100) + return; + } + NPC.ai[0] = 1f; + NPC.ai[1] = playerPosX; + NPC.ai[2] = playerPosY; + NPC.netUpdate = true; + } + } + } + + // Teleport to location + else if (NPC.ai[0] == 1f) + { + // Disable contact damage for some time while fading away + NPC.damage = 0; + + NPC.chaseable = true; + Vector2 position = new Vector2(NPC.ai[1] * 16f - (NPC.width / 2), NPC.ai[2] * 16f - (NPC.height / 2)); + for (int m = 0; m < 5; m++) + { + int dust = Dust.NewDust(position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].fadeIn = 1f; + } + NPC.alpha += death ? 5 : revenge ? 4 : expertMode ? 3 : 2; + if (NPC.alpha >= 255) + { + int spawnType = currentMode == 3 ? NPCID.AngryNimbus : ModContent.NPCType(); + int enemyCount = currentMode == 3 ? 3 : 1; // 3 angry nimbi if cloud, otherwise 1 brimling + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(spawnType) < (death ? 1 : 2) && revenge && currentMode != 2) // dont spawn anything if gfb rare sand + { + for (int i = 0; i < enemyCount; i++) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, spawnType); + } + SoundEngine.PlaySound(TeleportSound, NPC.Center); + NPC.alpha = 255; + NPC.position = position; + for (int n = 0; n < 15; n++) + { + int warpDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, 3f); + Main.dust[warpDust].noGravity = true; + } + NPC.ai[0] = 2f; + NPC.netUpdate = true; + } + } + + // Either teleport again or go to next AI state + else if (NPC.ai[0] == 2f) + { + if (NPC.alpha >= 255) + { + if (Main.zenithWorld) + { + SoundEngine.PlaySound(SoundID.Item68, NPC.Center); + int type = ModContent.ProjectileType(); + int damage = RayDamage; + Vector2 pos = NPC.Center; + for (int i = 0; i < 4; i++) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), pos, Vector2.UnitY.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 4f)), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + } + } + if (currentMode >= 1 && currentMode <= 3) + { + int tornadoType = currentMode == 3 ? ModContent.ProjectileType() : ProjectileID.SandnadoHostileMark; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), pos, Vector2.Zero, tornadoType, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + if (currentMode == 2) + { + int healAmt = NPC.lifeMax / 25; + if (healAmt > 0) + { + NPC.life += healAmt; + NPC.HealEffect(healAmt, true); + NPC.netUpdate = true; + } + } + } + } + + NPC.alpha -= 50; + if (NPC.alpha <= 0) + { + // Restore contact damage once returned to proper opacity + NPC.damage = NPC.defDamage; + NPC.chaseable = true; + NPC.ai[3] += 1f; + NPC.alpha = 0; + if (NPC.ai[3] >= 2f || phase2 || Main.getGoodWorld) + { + NPC.ai[0] = -1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + } + else + { + NPC.ai[0] = 0f; + } + NPC.netUpdate = true; + } + } + + // Float above target and fire projectiles + else if (NPC.ai[0] == 3f) + { + NPC.chaseable = true; + NPC.rotation = NPC.velocity.X * 0.04f; + + float playerLocation = NPC.Center.X - player.Center.X; + NPC.direction = playerLocation < 0f ? 1 : -1; + NPC.spriteDirection = NPC.direction; + + NPC.ai[1] += 1f; + float divisor = expertMode ? (death ? 80f : revenge ? 45f : 50f) - (float)Math.Ceiling(10f * (1f - lifeRatio)) : 50f; + divisor -= 3f * enrageScale; + float divisor2 = divisor * 2f; + + if (NPC.ai[1] % divisor == divisor - 1f) + { + float velocity = (death ? 7f : revenge ? 6f : 5f) + (2f * enrageScale) + (expertMode ? 3f * (1f - lifeRatio) : 0f); + int type = ModContent.ProjectileType(); + int damage = HellfireballDamage; + if (currentMode == 4) + { + type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SoundID.Item30, player.Center); + } + else + { + SoundEngine.PlaySound(HellfireballSound, player.Center); + } + Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 5f, projectileVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y); + Main.projectile[proj].timeLeft = 240; + } + + if (NPC.ai[1] % divisor2 == divisor2 - 1f) + { + velocity = (death ? 5f : 4f) + 2f * enrageScale; + type = ModContent.ProjectileType(); + damage = DartDamage; + if (currentMode == 4) + { + type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SoundID.Item21, player.Center); + } + else + { + SoundEngine.PlaySound(DartSound, player.Center); + } + projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; + int numProj = death ? 8 : 4; + int spread = death ? 90 : 45; + if (Main.getGoodWorld) + { + numProj *= 3; + spread *= 2; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float rotation = MathHelper.ToRadians(spread); + float projectileVelocityToPass = velocity * 3f; + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass); + } + } + } + } + + if (NPC.ai[1] >= divisor * (death ? 5f : 10f)) + { + NPC.TargetClosest(); + NPC.ai[0] = -1f; + NPC.ai[1] = 3f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + } + + // Cocoon bullet hell + else if (NPC.ai[0] == 4f) + { + NPC.defense = NPC.defDefense * 4; + + NPC.chaseable = false; + NPC.localAI[0] += 1f; + if (Main.getGoodWorld) + NPC.localAI[0] += 2f; + if (expertMode) + NPC.localAI[0] += 1f - lifeRatio; + NPC.localAI[0] += enrageScale; + + if (NPC.localAI[0] >= 120f) + { + NPC.localAI[0] = 0f; + + float projectileSpeed = death ? 9f : revenge ? 8f : 6f; + projectileSpeed += 2f * enrageScale; + + Vector2 projectileVelocity = player.Center - NPC.Center; + + float radialOffset = 0.2f; + float diameter = 80f; + + projectileVelocity = projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileSpeed; + + Vector2 velocity = projectileVelocity; + velocity = velocity.SafeNormalize(Vector2.UnitY); + velocity *= diameter; + + int totalProjectiles = 6; + float offsetAngle = MathHelper.Pi * radialOffset; + int type = ModContent.ProjectileType(); + int damage = HellblastDamage; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int j = 0; j < totalProjectiles; j++) + { + float radians = j - (totalProjectiles - 1f) / 2f; + Vector2 offset = velocity.RotatedBy(offsetAngle * radians); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, projectileVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 300; + Main.projectile[proj].tileCollide = false; + } + } + + totalProjectiles = 12; + float radians2 = MathHelper.TwoPi / totalProjectiles; + type = ModContent.ProjectileType(); + damage = DartDamage; + if (currentMode == 4) + { + type = ModContent.ProjectileType(); + SoundEngine.PlaySound(SoundID.Item26, player.Center); + } + else + { + SoundEngine.PlaySound(ShellFireSound, player.Center); + } + double angleA = radians2 * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = NPC.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float projectileVelocityToPass = projectileSpeed * 3f; + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass); + } + + if (death) + { + spinningPoint = NPC.localAI[2] % 2f == 0f ? new Vector2(-velocityX, -projectileSpeed) : new Vector2(0f, -projectileSpeed); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255 * 0.75f, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass); + } + } + } + + NPC.localAI[2] += 1f; + } + + NPC.velocity *= 0.95f; + NPC.rotation = NPC.velocity.X * 0.04f; + float playerLocation = NPC.Center.X - player.Center.X; + NPC.direction = playerLocation < 0f ? 1 : -1; + NPC.spriteDirection = NPC.direction; + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (death ? 240f : 300f)) + { + NPC.TargetClosest(); + NPC.ai[0] = -1f; + NPC.ai[1] = 4f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[0] = 0f; + NPC.netUpdate = true; + } + } + + // Laser beam attack + else if (NPC.ai[0] == 5f) + { + NPC.chaseable = true; + + NPC.defense = NPC.defDefense * 2; + + Vector2 source = new Vector2(NPC.Center.X + (NPC.spriteDirection > 0 ? 34f : -34f), NPC.Center.Y - 74f); + Vector2 aimAt = player.Center + player.velocity * 20f; + float aimResponsiveness = (NPC.ai[2] == 1f || death) ? 0.1f : 0.25f; + + Vector2 aimVector = (aimAt - source).SafeNormalize(Vector2.UnitY); + if (aimVector.HasNaNs()) + aimVector = -Vector2.UnitY; + aimVector = Vector2.Lerp(aimVector, NPC.velocity.SafeNormalize(Vector2.UnitY), aimResponsiveness).SafeNormalize(Vector2.UnitY); + aimVector *= 6f; + + Vector2 laserVelocity = aimVector.SafeNormalize(Vector2.UnitY); + if (laserVelocity.HasNaNs()) + laserVelocity = -Vector2.UnitY; + + calamityGlobalNPC.newAI[1] = laserVelocity.X; + calamityGlobalNPC.newAI[2] = laserVelocity.Y; + + // Rev = 190 + 165 = 355 + // Death = 165 + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 240f) + { + NPC.TargetClosest(); + NPC.ai[2] += 1f; + NPC.localAI[0] = 0f; + NPC.localAI[1] = 0f; + if (NPC.ai[2] >= (death ? 1f : 2f)) + { + NPC.ai[0] = -1f; + NPC.ai[1] = 5f; + NPC.ai[2] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + else + { + NPC.ai[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + else if (NPC.ai[1] >= 180f) + { + NPC.velocity *= 0.95f; + if (NPC.ai[1] == 180f) + { + SoundEngine.PlaySound(SoundID.Item68, source); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 laserVelocity2 = new Vector2(NPC.localAI[0], NPC.localAI[1]); + laserVelocity2 = laserVelocity2.SafeNormalize(Vector2.UnitY); + int type = ModContent.ProjectileType(); + int damage = RayDamage; + + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + if (Main.getGoodWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, -laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + + if (Main.zenithWorld) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(-laserVelocity2.X, laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(laserVelocity2.X, -laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + } + } + } + } + else + { + float playSoundTimer = 30f; + if (NPC.ai[1] < 150f) + { + switch ((int)NPC.ai[2]) + { + case 0: + NPC.ai[1] += 0.5f; + break; + case 1: + NPC.ai[1] += 1f; + playSoundTimer = 40f; + break; + } + if (death) + { + NPC.ai[1] += 0.5f; + playSoundTimer += 10f; + } + } + + if (NPC.ai[1] % playSoundTimer == 0f) + SoundEngine.PlaySound(SoundID.Item20, NPC.Center); + + if (NPC.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI); + if (Main.getGoodWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, -laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI); + + if (Main.zenithWorld) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(-laserVelocity.X, laserVelocity.Y), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, new Vector2(laserVelocity.X, -laserVelocity.Y), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, NPC.whoAmI); + } + } + + calamityGlobalNPC.newAI[0] = 1f; + } + else + { + if (NPC.ai[1] == 150f) + { + NPC.localAI[0] = laserVelocity.X; + NPC.localAI[1] = laserVelocity.Y; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, NPC.localAI[0], NPC.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI); + if (Main.getGoodWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, -NPC.localAI[0], -NPC.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI); + + if (Main.zenithWorld) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, -NPC.localAI[0], NPC.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, NPC.localAI[0], -NPC.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.whoAmI); + } + } + } + } + } + } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -134,7 +814,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 240); } public override void FindFrame(int frameHeight) // 9 total frames @@ -186,14 +866,14 @@ namespace CalamityMod.NPCs.BrimstoneElemental } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.GreaterHealingPotion; } public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); // Normal drops: Everything that would otherwise be in the bag var normalOnly = npcLoot.DefineNormalOnlyDropSet(); @@ -217,10 +897,11 @@ namespace CalamityMod.NPCs.BrimstoneElemental ModContent.ItemType(), }; normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, accs)); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity - normalOnly.Add(ModContent.ItemType(), 7); + normalOnly.Add(ModContent.ItemType(), 7); normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); } @@ -232,7 +913,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Heart of the Elements drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedBrimstoneElemental, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -255,7 +936,6 @@ namespace CalamityMod.NPCs.BrimstoneElemental public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs deleted file mode 100644 index 6b934b0360..0000000000 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ /dev/null @@ -1,537 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; -using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; -using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Potions; -using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.GameContent.Bestiary; -using Terraria.GameContent.ItemDropRules; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.Bumblebirb -{ - [AutoloadBossHead] - public class Bumblefuck : ModNPC - { - public static Asset GlowTexture; - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 6; - NPCID.Sets.TrailingMode[Type] = 1; - NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - Scale = 0.5f, - PortraitScale = 0.85f, - PortraitPositionYOverride = 14f - }; - value.Position.X += 20f; - value.Position.Y += 8f; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - NPCID.Sets.MPAllowedEnemies[Type] = true; - if (!Main.dedServ) - { - GlowTexture = ModContent.Request("CalamityMod/NPCs/Bumblebirb/BirbGlow", AssetRequestMode.AsyncLoad); - } - } - - public override string Texture => "CalamityMod/NPCs/Bumblebirb/Birb"; - public override string BossHeadTexture => "CalamityMod/NPCs/Bumblebirb/Birb_Head_Boss"; - - public override void SetDefaults() - { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.npcSlots = 32f; - NPC.aiStyle = -1; - AIType = -1; - NPC.GetNPCDamage(); - NPC.width = 130; - NPC.height = 100; - NPC.defense = 40; - NPC.DR_NERD(0.1f); - NPC.LifeMaxNERB(187500, 225000, 300000); // Old HP - 227500, 252500 - NPC.knockBackResist = 0f; - NPC.boss = true; - NPC.noTileCollide = true; - NPC.lavaImmune = true; - NPC.noGravity = true; - NPC.value = Item.buyPrice(1, 0, 0, 0); - NPC.HitSound = SoundID.NPCHit51; - NPC.DeathSound = SoundID.NPCDeath46; - NPC.Calamity().VulnerableToHeat = true; - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToSickness = true; - NPC.Calamity().VulnerableToElectricity = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Bumblefuck") - }); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(NPC.localAI[0]); - writer.Write(NPC.localAI[1]); - writer.Write(NPC.localAI[2]); - writer.Write(NPC.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(NPC.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - NPC.localAI[0] = reader.ReadSingle(); - NPC.localAI[1] = reader.ReadSingle(); - NPC.localAI[2] = reader.ReadSingle(); - NPC.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - NPC.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() - { - BumblebirbAI.VanillaBumblebirbAI(NPC, Mod); - } - - public override void FindFrame(int frameHeight) - { - CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; - - // Phases - bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; - bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); - bool birbSpawn = NPC.ai[0] == 4f && NPC.ai[1] > 0f; - - // Animation goes nyoom - if (Main.zenithWorld) - { - NPC.frameCounter += 4; - } - - float newPhaseTimer = 180f; - bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || - (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); - - if (phaseSwitchPhase || birbSpawn) - { - float frameGateValue = birbSpawn ? NPC.ai[1] : phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]; - int frameTimer = 180; - if (frameGateValue < (frameTimer - 60) || frameGateValue > (frameTimer - 20)) - { - NPC.frameCounter += 1D; - if (NPC.frameCounter > 5D) - { - NPC.frameCounter = 0D; - NPC.frame.Y += frameHeight; - } - if (NPC.frame.Y >= frameHeight * 5) - { - NPC.frame.Y = 0; - } - } - else - { - NPC.frame.Y = frameHeight * 4; - if (frameGateValue > (frameTimer - 50) && frameGateValue < (frameTimer - 25)) - { - NPC.frame.Y = frameHeight * 5; - } - } - } - else if (NPC.ai[0] == 5f) - { - int otherFrameTimer = 120; - if (NPC.ai[1] < (otherFrameTimer - 50) || NPC.ai[1] > (otherFrameTimer - 10)) - { - NPC.frameCounter += 1D; - if (NPC.frameCounter > 5D) - { - NPC.frameCounter = 0D; - NPC.frame.Y += frameHeight; - } - if (NPC.frame.Y >= frameHeight * 5) - { - NPC.frame.Y = 0; - } - } - else - { - NPC.frame.Y = frameHeight * 4; - if (NPC.ai[1] > (otherFrameTimer - 40) && NPC.ai[1] < (otherFrameTimer - 15)) - { - NPC.frame.Y = frameHeight * 5; - } - } - } - else - { - NPC.frameCounter += (NPC.ai[0] == 3.2f ? 1.5 : 1D); - if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base - { - NPC.frameCounter = 0D; - NPC.frame.Y += frameHeight; - } - if (NPC.frame.Y >= frameHeight * 5) - { - NPC.frame.Y = 0; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; - - // Phases - bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; - bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); - - float newPhaseTimer = 180f; - bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || - (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); - - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2)); - Color color = drawColor; - Color altColor = Color.White; - - float lerpDrawTransition = 0f; - int newAITracker = 120; - int buffColorDampener = 60; - - if (phase3 && calamityGlobalNPC.newAI[3] == 1f) - { - color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.6f, 0.2f, 1f); - } - else if (phase2 && calamityGlobalNPC.newAI[2] == 1f) - { - color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.3f, 1f); - } - else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker) - { - float phase2TranBuff = calamityGlobalNPC.newAI[0] - (float)newAITracker; - phase2TranBuff /= (float)buffColorDampener; - color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * phase2TranBuff, 1f - 0.3f * phase2TranBuff, 1f - 0.7f * phase2TranBuff, 1f); - } - - int afterimageAmt = 10; - int afterimageIncrement = 2; - if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f) - { - afterimageAmt = 4; - } - if (NPC.ai[0] == 1f || NPC.ai[0] == 3f || NPC.ai[0] == 4.1f) - { - afterimageAmt = 7; - } - if (NPC.ai[0] == 2f || NPC.ai[0] == 3.2f || (phase2 && calamityGlobalNPC.newAI[2] == 1f)) - { - altColor = Color.Yellow; - lerpDrawTransition = 0.5f; - } - else - { - color = altColor; - } - - if (CalamityClientConfig.Instance.Afterimages) - { - for (int i = 1; i < afterimageAmt; i += afterimageIncrement) - { - Color afterimageColor = color; - afterimageColor = Color.Lerp(afterimageColor, altColor, lerpDrawTransition); - afterimageColor = NPC.GetAlpha(afterimageColor); - afterimageColor *= (float)(afterimageAmt - i) / 15f; - Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - afterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; - afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - } - - int extraAfterimageAmt = 0; - float extraAfterimageDampener = 0f; - float afterimageScaler = 0f; - - if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f) - { - extraAfterimageAmt = 4; - } - - if (NPC.ai[0] == 5f) - { - if (NPC.ai[1] > 60f) - { - extraAfterimageAmt = 6; - extraAfterimageDampener = 1f - (float)Math.Cos((double)((NPC.ai[1] - 60f) / 30f * MathHelper.TwoPi)); - extraAfterimageDampener /= 3f; - afterimageScaler = 40f; - } - } - - if (phaseSwitchPhase) - { - if (phase3 && calamityGlobalNPC.newAI[1] > (float)newAITracker) - { - extraAfterimageAmt = 6; - extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[1] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi)); - extraAfterimageDampener /= 3f; - afterimageScaler = 60f; - } - else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker) - { - extraAfterimageAmt = 6; - extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[0] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi)); - extraAfterimageDampener /= 3f; - afterimageScaler = 60f; - } - } - - if (CalamityClientConfig.Instance.Afterimages) - { - for (int j = 0; j < extraAfterimageAmt; j++) - { - Color extraAfterimageColor = altColor; - extraAfterimageColor = Color.Lerp(extraAfterimageColor, altColor, lerpDrawTransition); - extraAfterimageColor = NPC.GetAlpha(extraAfterimageColor); - extraAfterimageColor *= 1f - extraAfterimageDampener; - Vector2 extraAfterimageDrawPos = NPC.Center + ((float)j / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos; - extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; - extraAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, extraAfterimageDrawPos, NPC.frame, extraAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - } - - Color mainDrawingColor = altColor; - mainDrawingColor = Color.Lerp(mainDrawingColor, altColor, lerpDrawTransition); - mainDrawingColor = NPC.GetAlpha(mainDrawingColor); - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, (phase3 && calamityGlobalNPC.newAI[3] == 1f ? mainDrawingColor : NPC.GetAlpha(altColor)), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - if (phase2) - { - texture2D15 = GlowTexture.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Red, 0.5f); - altColor = Color.Red; - - lerpDrawTransition = 1f; - extraAfterimageDampener = 0.5f; - afterimageScaler = 10f; - afterimageIncrement = 1; - - if (phaseSwitchPhase) - { - float glowmaskDampener = (phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]) - (float)newAITracker; - glowmaskDampener /= (float)buffColorDampener; - altColor *= glowmaskDampener; - glowmaskColor *= glowmaskDampener; - } - - if (CalamityClientConfig.Instance.Afterimages) - { - for (int k = 1; k < afterimageAmt; k += afterimageIncrement) - { - Color glowmaskAfterimageColor = glowmaskColor; - glowmaskAfterimageColor = Color.Lerp(glowmaskAfterimageColor, altColor, lerpDrawTransition); - glowmaskAfterimageColor *= (float)(afterimageAmt - k) / 15f; - Vector2 glowmaskAfterimageDrawPos = NPC.oldPos[k] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - glowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; - glowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, glowmaskAfterimageDrawPos, NPC.frame, glowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - - for (int l = 1; l < extraAfterimageAmt; l++) - { - Color extraGlowmaskAfterimageColor = glowmaskColor; - extraGlowmaskAfterimageColor = Color.Lerp(extraGlowmaskAfterimageColor, altColor, lerpDrawTransition); - extraGlowmaskAfterimageColor = NPC.GetAlpha(extraGlowmaskAfterimageColor); - extraGlowmaskAfterimageColor *= 1f - extraAfterimageDampener; - Vector2 extraGlowmaskAfterimageDrawPos = NPC.Center + ((float)l / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos; - extraGlowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; - extraGlowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, extraGlowmaskAfterimageDrawPos, NPC.frame, extraGlowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - - return false; - } - - private static Color buffColor(Color newColor, float R, float G, float B, float A) - { - newColor.R = (byte)((float)newColor.R * R); - newColor.G = (byte)((float)newColor.G * G); - newColor.B = (byte)((float)newColor.B * B); - newColor.A = (byte)((float)newColor.A * A); - return newColor; - } - - public override void BossLoot(ref string name, ref int potionType) => potionType = ItemID.SuperHealingPotion; - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); - - // Normal drops: Everything that would otherwise be in the bag - var normalOnly = npcLoot.DefineNormalOnlyDropSet(); - { - // Weapons - int[] items = new int[] - { - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() - }; - normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, items)); - normalOnly.Add(ModContent.ItemType(), 10); - - // Materials - normalOnly.Add(ModContent.ItemType(), 1, 25, 30); - - // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); - normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); - - // Vanity - normalOnly.Add(ModContent.ItemType(), 7); - normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); - } - - npcLoot.Add(ModContent.ItemType(), 10); - - // Relic - npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); - - // GFB Omega Healing Potion drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 50, 100, true); - - // Lore - npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedDragonfolly, ModContent.ItemType(), desc: DropHelper.FirstKillText); - } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); - } - public override void OnKill() - { - // Don't bother running any of this in Boss Rush. - if (BossRushEvent.BossRushActive) - return; - - CalamityGlobalNPC.SetNewBossJustDowned(NPC); - - // Mark The Dragonfolly as dead - DownedBossSystem.downedDragonfolly = true; - CalamityNetcode.SyncWorld(); - - if (Main.zenithWorld) - { - int spacing = 40; - int amt = 7; - SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < amt; i++) - { - Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); - Vector2 ai0 = NPC.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); - } - } - } - - } - - public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) - { - NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - - public override void ModifyTypeName(ref string typeName) - { - if (Main.zenithWorld) - { - typeName = CalamityUtils.GetTextValue("NPCs.Bumblebirb"); - } - } - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - for (int k = 0; k < 50; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); - } - if (!Main.dedServ) - { - for (int i = 0; i < 6; i++) // 1 head, 1 wing, 4 legs = 6. one wing due to them being chonky boyes now - { - string gore = "Bumble"; - float randomSpread = Main.rand.Next(-200, 201) / 100f; - gore += i == 0 ? "Head" : i > 1 ? "Leg" : "Wing"; - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find(gore).Type, 1f); - } - } - } - } - } -} diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs deleted file mode 100644 index ef8f02eaf5..0000000000 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ /dev/null @@ -1,153 +0,0 @@ -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Sounds; -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; - -namespace CalamityMod.NPCs.Bumblebirb -{ - public class Bumblefuck2 : ModNPC - { - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 5; - NPCID.Sets.TrailingMode[Type] = 1; - this.HideFromBestiary(); - } - - public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly"; - - public override void SetDefaults() - { - NPC.npcSlots = 1f; - NPC.aiStyle = -1; - AIType = -1; - NPC.GetNPCDamage(); - NPC.width = 120; - NPC.height = 80; - NPC.defense = 20; - NPC.LifeMaxNERB(9375, 11250, 5000); - NPC.knockBackResist = 0.15f; - NPC.lavaImmune = true; - NPC.noTileCollide = true; - NPC.noGravity = true; - NPC.HitSound = SoundID.NPCHit51; - NPC.DeathSound = SoundID.NPCDeath46; - NPC.Calamity().VulnerableToHeat = true; - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void AI() - { - BumblebirbAI.VanillaBumblebirb2AI(NPC, Mod, true); - } - - public override void OnKill() - { - int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); - if (Main.rand.NextBool(4) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); - - if (Main.zenithWorld) - { - SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < 5; i++) - { - Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f); - Vector2 ai0 = NPC.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); - } - } - } - } - - public override void FindFrame(int frameHeight) - { - NPC.frameCounter += NPC.ai[0] == 2.1f ? 1.5 : 1D; - if (Main.zenithWorld) - { - NPC.frameCounter += 2D; - } - if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base - { - NPC.frameCounter = 0D; - NPC.frame.Y += frameHeight; - } - if (NPC.frame.Y >= frameHeight * 4) - { - NPC.frame.Y = 0; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2); - int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0; - - if (CalamityClientConfig.Instance.Afterimages) - { - for (int i = 1; i < afterimageAmt; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f); - afterimageColor = NPC.GetAlpha(afterimageColor); - afterimageColor *= (afterimageAmt - i) / 15f; - Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - afterimageDrawPos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; - afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - } - - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override void ModifyTypeName(ref string typeName) - { - if (Main.zenithWorld) - { - typeName = CalamityUtils.GetTextValue("NPCs.Bumblebirb"); - } - } - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - for (int k = 0; k < 50; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); - } - } - } - } -} diff --git a/NPCs/Bumblebirb/DraconicSwarmer.cs b/NPCs/Bumblebirb/DraconicSwarmer.cs new file mode 100644 index 0000000000..844bc9618d --- /dev/null +++ b/NPCs/Bumblebirb/DraconicSwarmer.cs @@ -0,0 +1,354 @@ +using CalamityMod.Projectiles.Boss; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Bumblebirb +{ + public class DraconicSwarmer : ModNPC + { + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 5; + NPCID.Sets.TrailingMode[Type] = 1; + this.HideFromBestiary(); + } + + public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly"; + + public override void SetDefaults() + { + NPC.damage = 96; // 192 + NPC.npcSlots = 1f; + NPC.aiStyle = -1; + AIType = -1; + NPC.width = 120; + NPC.height = 80; + NPC.defense = 20; + NPC.LifeMaxNERB(9375, 11250, 5000); + NPC.knockBackResist = 0.15f; + NPC.lavaImmune = true; + NPC.noTileCollide = true; + NPC.noGravity = true; + NPC.HitSound = SoundID.NPCHit51; + NPC.DeathSound = SoundID.NPCDeath46; + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToSickness = true; + } + + public override void AI() + { + Player player = Main.player[NPC.target]; + + float rotationMult = 4f; + float rotationAmt = 0.04f; + + if (Vector2.Distance(player.Center, NPC.Center) > 5600f) + { + if (NPC.timeLeft > 5) + NPC.timeLeft = 5; + } + + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt * 1.25f) / 10f; + + if (NPC.ai[0] == 0f || NPC.ai[0] == 1f) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type) + { + Vector2 otherSwarmerDirection = Main.npc[i].Center - NPC.Center; + if (otherSwarmerDirection.Length() < (NPC.width + NPC.height)) + { + otherSwarmerDirection.Normalize(); + otherSwarmerDirection *= -0.1f; + NPC.velocity += otherSwarmerDirection; + NPC nPC6 = Main.npc[i]; + nPC6.velocity -= otherSwarmerDirection; + } + } + } + } + + if (NPC.target < 0 || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + NPC.TargetClosest(true); + Vector2 swarmerTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (Main.player[NPC.target].dead || swarmerTargetDist.Length() > 5600f) + NPC.ai[0] = -1f; + } + else + { + Vector2 swarmerCatchUpTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (NPC.ai[0] > 1f && swarmerCatchUpTargetDist.Length() > 3600f) + NPC.ai[0] = 1f; + } + + if (NPC.ai[0] == -1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + Vector2 swarmerDespawnVelMult = new Vector2(0f, -8f); + NPC.velocity = (NPC.velocity * 21f + swarmerDespawnVelMult) / 10f; + return; + } + + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.TargetClosest(true); + NPC.spriteDirection = NPC.direction; + + Vector2 swarmerIdleTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (swarmerIdleTargetDist.Length() > 2800f) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + } + else if (swarmerIdleTargetDist.Length() > 400f) + { + float swarmerIdleSpeed = 9f + swarmerIdleTargetDist.Length() / 100f + NPC.ai[1] / 15f; + swarmerIdleTargetDist.Normalize(); + swarmerIdleTargetDist *= swarmerIdleSpeed; + NPC.velocity = (NPC.velocity * 29f + swarmerIdleTargetDist) / 30f; + } + else if (NPC.velocity.Length() > 2f) + NPC.velocity *= 0.95f; + else if (NPC.velocity.Length() < 1f) + NPC.velocity *= 1.05f; + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 90f) + { + NPC.ai[1] = 0f; + NPC.ai[0] = 2f; + } + } + else + { + if (NPC.ai[0] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.target < 0 || !Main.player[NPC.target].active || Main.player[NPC.target].dead) + NPC.TargetClosest(true); + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt) / 10f; + + Vector2 swarmerChargeTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (swarmerChargeTargetDist.Length() < 800f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + } + + NPC.ai[2] += 0.0166666675f; + float swarmerChargeSpeed = 12f + NPC.ai[2] + swarmerChargeTargetDist.Length() / 150f; + float swarmerChargeVelMult = 25f; + swarmerChargeTargetDist.Normalize(); + swarmerChargeTargetDist *= swarmerChargeSpeed; + NPC.velocity = (NPC.velocity * (swarmerChargeVelMult - 1f) + swarmerChargeTargetDist) / swarmerChargeVelMult; + + NPC.ForceNetUpdate(); + + return; + } + + if (NPC.ai[0] == 2f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult * 0.75f + NPC.velocity.X * rotationAmt * 1.25f) / 8f; + + Vector2 swarmerDecelerateTargetDist = Main.player[NPC.target].Center - NPC.Center; + swarmerDecelerateTargetDist.Y -= 8f; + float swarmerDecelerateSpeed = 18f; + float swarmerDecelerateVelMult = 8f; + swarmerDecelerateTargetDist.Normalize(); + swarmerDecelerateTargetDist *= swarmerDecelerateSpeed; + NPC.velocity = (NPC.velocity * (swarmerDecelerateVelMult - 1f) + swarmerDecelerateTargetDist) / swarmerDecelerateVelMult; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + + NPC.ai[1] += 1f; + if (NPC.ai[1] > 10f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.velocity = swarmerDecelerateTargetDist; + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.ai[0] = 2.1f; + NPC.ai[1] = 0f; + } + } + else if (NPC.ai[0] == 2.1f) + { + // Set damage + NPC.damage = NPC.defDamage; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + + NPC.velocity *= 1.01f; + + NPC.ai[1] += 1f; + if (NPC.ai[1] > 30f) + { + if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + return; + } + + if (NPC.ai[1] > 60f) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + } + } + } + } + + public override void OnKill() + { + int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); + if (Main.rand.NextBool(4) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); + + if (Main.zenithWorld) + { + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < 5; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), Dragonfolly.LightningDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } + } + } + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += NPC.ai[0] == 2.1f ? 1.5 : 1D; + if (Main.zenithWorld) + { + NPC.frameCounter += 2D; + } + if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base + { + NPC.frameCounter = 0D; + NPC.frame.Y += frameHeight; + } + if (NPC.frame.Y >= frameHeight * 4) + { + NPC.frame.Y = 0; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = TextureAssets.Npc[Type].Value; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2); + int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0; + + if (CalamityClientConfig.Instance.Afterimages) + { + for (int i = 1; i < afterimageAmt; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimageDrawPos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; + afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + } + + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + return false; + } + + public override void ModifyTypeName(ref string typeName) + { + if (Main.zenithWorld) + { + typeName = CalamityUtils.GetTextValue("NPCs.Bumblebirb"); + } + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 50; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); + } + } + } + } +} diff --git a/NPCs/Bumblebirb/Dragonfolly.cs b/NPCs/Bumblebirb/Dragonfolly.cs new file mode 100644 index 0000000000..51810443f1 --- /dev/null +++ b/NPCs/Bumblebirb/Dragonfolly.cs @@ -0,0 +1,1347 @@ +using System; +using System.IO; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.LoreItems; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Mounts; +using CalamityMod.Items.Placeables.Furniture.BossRelics; +using CalamityMod.Items.Placeables.Furniture.Paintings; +using CalamityMod.Items.Placeables.Furniture.Trophies; +using CalamityMod.Items.Potions; +using CalamityMod.Items.TreasureBags; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Sounds; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Bumblebirb +{ + [AutoloadBossHead] + public class Dragonfolly : ModNPC + { + public static Asset GlowTexture; + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 6; + NPCID.Sets.TrailingMode[Type] = 1; + NPCID.Sets.BossBestiaryPriority.Add(Type); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + { + Scale = 0.5f, + PortraitScale = 0.85f, + PortraitPositionYOverride = 14f + }; + value.Position.X += 20f; + value.Position.Y += 8f; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + NPCID.Sets.MPAllowedEnemies[Type] = true; + if (!Main.dedServ) + { + GlowTexture = ModContent.Request("CalamityMod/NPCs/Bumblebirb/BirbGlow", AssetRequestMode.AsyncLoad); + } + } + + public override string Texture => "CalamityMod/NPCs/Bumblebirb/Birb"; + public override string BossHeadTexture => "CalamityMod/NPCs/Bumblebirb/Birb_Head_Boss"; + + public static float DashDamageMult = 1.5f; // 240 + public static int FeatherDamage = 36; // 144 + public static int LightningDamage = 64; // 256 + + public override void SetDefaults() + { + NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 80; // 160 + NPC.npcSlots = 32f; + NPC.aiStyle = -1; + AIType = -1; + NPC.width = 130; + NPC.height = 100; + NPC.defense = 40; + NPC.DR_NERD(0.1f); + NPC.LifeMaxNERB(150000, 225000, 300000); // Old HP - 227500, 252500 + NPC.knockBackResist = 0f; + NPC.boss = true; + NPC.noTileCollide = true; + NPC.lavaImmune = true; + NPC.noGravity = true; + NPC.value = Item.buyPrice(gold: 50); + NPC.HitSound = SoundID.NPCHit51; + NPC.DeathSound = SoundID.NPCDeath46; + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToElectricity = false; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Bumblefuck") + }); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.localAI[0]); + writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(NPC.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.localAI[0] = reader.ReadSingle(); + NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // 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(); + + Player player = Main.player[NPC.target]; + + // Variables + float rotationMult = 3f; + float rotationAmt = 0.03f; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = NPC.ai[0] == 3f || NPC.ai[0] == 3.1f || NPC.ai[0] == 3.2f; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // If target is outside the jungle for more than 5 seconds, enrage + if (!player.ZoneJungle && !BossRushEvent.BossRushActive) + { + if (NPC.localAI[1] < CalamityGlobalNPC.biomeEnrageTimerMax) + NPC.localAI[1] += 1f; + } + else + NPC.localAI[1] = 0f; + + // If dragonfolly is off screen, enrage for the next couple attacks + if (Vector2.Distance(player.Center, NPC.Center) > 1200f) + NPC.localAI[2] = 2f; + + // Enrage scale + float enrageScale = death ? 1.5f : 1f; + if (NPC.localAI[1] >= CalamityGlobalNPC.biomeEnrageTimerMax) + { + NPC.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } + + if (NPC.localAI[2] > 0f) + enrageScale += 1f; + + if (Main.getGoodWorld) + enrageScale += 0.5f; + + if (enrageScale > 3f) + enrageScale = 3f; + + // Despawn + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f) + { + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f) + { + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt) / 10f; + + if (NPC.velocity.Y > 3f) + NPC.velocity.Y = 3f; + NPC.velocity.Y -= 0.2f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + + if (NPC.ai[0] != 0f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + NPC.ForceNetUpdate(false); + } + + return; + } + } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f); + bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f) && expertMode; + + float birbSpawnPhaseTimer = 180f; + float newPhaseTimer = 180f; + bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || + (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); + + calamityGlobalNPC.DR = phaseSwitchPhase || NPC.ai[0] == 5f || enrageScale == 3f ? 0.55f : 0.1f; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phaseSwitchPhase || NPC.ai[0] == 5f || enrageScale == 3f; + + if (phaseSwitchPhase) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt) / 10f; + + if (phase3) + { + calamityGlobalNPC.newAI[1] += 1f; + + // Sound + if (calamityGlobalNPC.newAI[1] == newPhaseTimer - 60f) + { + float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; + SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, NPC.Center); + + if (Main.zenithWorld) + { + int spacing = 20; + int amt = 5; + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), LightningDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } + } + } + } + + if (calamityGlobalNPC.newAI[1] >= newPhaseTimer) + { + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 1f; + calamityGlobalNPC.newAI[3] = 1f; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.SyncExtraAI(); + NPC.ForceNetUpdate(false); + } + } + else + { + calamityGlobalNPC.newAI[0] += 1f; + + // Sound + if (calamityGlobalNPC.newAI[0] == newPhaseTimer - 60f) + { + float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; + SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, NPC.Center); + + if (Main.zenithWorld) + { + int spacing = 20; + int amt = 3; + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), LightningDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } + } + } + } + + if (calamityGlobalNPC.newAI[0] >= newPhaseTimer) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[2] = 1f; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.SyncExtraAI(); + NPC.ForceNetUpdate(false); + } + } + + Vector2 follyTargetDirection = player.Center - NPC.Center; + float follyTargetDistance = 4f + follyTargetDirection.Length() / 100f; + float follyVelocityMult = 25f; + follyTargetDirection.Normalize(); + follyTargetDirection *= follyTargetDistance; + NPC.velocity = (NPC.velocity * (follyVelocityMult - 1f) + follyTargetDirection) / follyVelocityMult; + return; + } + + // Max spawn amount + int maxBirbs = Main.zenithWorld ? 12 : revenge ? 3 : 2; + + // Variable for charging + float chargeDistance = 600f; + if (phase2) + chargeDistance -= 50f; + if (phase3) + chargeDistance -= 50f; + chargeDistance -= (enrageScale - 1f) * 100f; + + // Phase switch + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.Center.X < player.Center.X - 2f) + NPC.direction = 1; + if (NPC.Center.X > player.Center.X + 2f) + NPC.direction = -1; + + // Direction and rotation + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt * 1.25f) / 10f; + + // Fly to target if target is too far away, otherwise get close to target and then slow down + Vector2 follyFlyTargetDirection = player.Center - NPC.Center; + follyFlyTargetDirection.Y -= 200f; + if (follyFlyTargetDirection.Length() > 2800f) + { + NPC.TargetClosest(); + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + else if (follyFlyTargetDirection.Length() > 240f) + { + float follyFlySpeed = 12f + (enrageScale - 1f) * 6f; + float follyFlyVelocityMult = 30f; + follyFlyTargetDirection.Normalize(); + follyFlyTargetDirection *= follyFlySpeed; + NPC.velocity = (NPC.velocity * (follyFlyVelocityMult - 1f) + follyFlyTargetDirection) / follyFlyVelocityMult; + } + else if (NPC.velocity.Length() > 2f) + NPC.velocity *= 0.95f; + else if (NPC.velocity.Length() < 1f) + NPC.velocity *= 1.05f; + + // Phase switch + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 30f) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + while (NPC.ai[0] == 0f) + { + if (phase2) + NPC.localAI[0] += 1f; + + if (NPC.localAI[0] >= (phase3 ? 7 : 9)) + { + NPC.TargetClosest(); + NPC.ai[0] = 5f; + NPC.localAI[0] = 0f; + + // Decrease the feather variable, feathers can be used again if it's at 0 + if (NPC.ai[3] > 0f) + NPC.ai[3] -= 1f; + + // Decrease enraged attacks by 1 + if (NPC.localAI[2] > 0f) + NPC.localAI[2] -= 1f; + + // Decrease amount of attacks until able to spawn small birbs again + if (NPC.localAI[3] > 0f) + NPC.localAI[3] -= 1f; + } + else + { + int follyAttackPicker = phase2 ? Main.rand.Next(2) + 1 : Main.rand.Next(3); + if (phase3) + follyAttackPicker = 1; + + float featherVelocity = 2f + (enrageScale - 1f); + int type = ModContent.ProjectileType(); + + if (follyAttackPicker == 0 && NPC.localAI[3] == 0f) + { + NPC.TargetClosest(); + NPC.ai[0] = 2f; + + // Decrease the feather variable, feathers can be used again if it's at 0 + if (NPC.ai[3] > 0f) + NPC.ai[3] -= 1f; + + // Decrease enraged attacks by 1 + if (NPC.localAI[2] > 0f) + NPC.localAI[2] -= 1f; + + // Birb will do at least 1 different attack before entering this phase again + NPC.localAI[3] = 1f; + } + else if (follyAttackPicker == 1) + { + NPC.TargetClosest(); + NPC.ai[0] = 3f; + + // Decrease enraged attacks by 1 + if (NPC.localAI[2] > 0f) + NPC.localAI[2] -= 1f; + + // Decrease amount of attacks until able to use other attacks again + if (NPC.localAI[3] > 0f) + NPC.localAI[3] -= 1f; + + if (phase2 && NPC.ai[3] == 0f) + { + NPC.ai[3] = 3f; + SoundEngine.PlaySound(SoundID.Item102, player.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int totalProjectiles = 40; + float radians = MathHelper.TwoPi / totalProjectiles; + int distance = 800; + bool spawnRight = player.velocity.X > 0f; + for (int i = 0; i < totalProjectiles; i++) + { + if (Main.getGoodWorld) + { + if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, FeatherDamage, 0f, Main.myPlayer); + } + if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, FeatherDamage, 0f, Main.myPlayer); + } + } + else + { + if (spawnRight) + { + if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, FeatherDamage, 0f, Main.myPlayer); + } + } + else + { + if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, FeatherDamage, 0f, Main.myPlayer); + } + } + } + } + } + } + else + { + // Decrease the feather variable, feathers can be used again if it's at 0 + if (NPC.ai[3] > 0f) + NPC.ai[3] -= 1f; + } + } + else if (NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && NPC.localAI[3] == 0f) + { + NPC.TargetClosest(); + NPC.ai[0] = 4f; + + // Birb will do at least 2 different attacks before entering this phase again + NPC.localAI[3] = 2f; + + // Decrease enraged attacks by 1 + if (NPC.localAI[2] > 0f) + NPC.localAI[2] -= 1f; + + if (NPC.ai[3] == 0f) + { + NPC.ai[3] = 3f; + SoundEngine.PlaySound(SoundID.Item102, player.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int totalProjectiles = phase2 ? 40 : 48; + + if (Main.getGoodWorld) + totalProjectiles *= 2; + + float radians = MathHelper.TwoPi / totalProjectiles; + int distance = phase2 ? 1200 : 1320; + + if (Main.getGoodWorld) + distance *= 2; + + bool spawnRight = player.velocity.X > 0f; + for (int i = 0; i < totalProjectiles; i++) + { + if (spawnRight) + { + if (i >= totalProjectiles / 2) + break; + + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, FeatherDamage, 0f, Main.myPlayer); + } + else + { + if (i >= totalProjectiles / 2) + { + Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; + Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, FeatherDamage, 0f, Main.myPlayer); + } + } + } + } + } + else + { + // Decrease the feather variable, feathers can be used again if it's at 0 + if (NPC.ai[3] > 0f) + NPC.ai[3] -= 1f; + } + } + } + } + + NPC.ForceNetUpdate(false); + NPC.SyncExtraAI(); + } + } + + // Fly to target + else if (NPC.ai[0] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt) / 10f; + + Vector2 follyTargetDirection = player.Center - NPC.Center; + if (follyTargetDirection.Length() < 800f) + { + NPC.TargetClosest(); + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + NPC.ForceNetUpdate(false); + NPC.SyncExtraAI(); + } + + float velocity = 14f + (enrageScale - 1f) * 4f; + float follyTargetDistance = velocity + follyTargetDirection.Length() / 100f; + float follyVelocityMult = 25f; + follyTargetDirection.Normalize(); + follyTargetDirection *= follyTargetDistance; + NPC.velocity = (NPC.velocity * (follyVelocityMult - 1f) + follyTargetDirection) / follyVelocityMult; + } + + // Fly towards target quickly + else if (NPC.ai[0] == 2f) + { + NPC.damage = NPC.defDamage; + + if (NPC.target < 0 || !player.active || player.dead) + { + NPC.TargetClosest(); + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + NPC.ForceNetUpdate(false); + NPC.SyncExtraAI(); + } + + if (player.Center.X - 10f < NPC.Center.X) + NPC.direction = -1; + else if (player.Center.X + 10f > NPC.Center.X) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult * 0.5f + NPC.velocity.X * rotationAmt * 1.25f) / 5f; + + Vector2 follyQuickFlyTargetDirection = player.Center - NPC.Center; + follyQuickFlyTargetDirection.Y -= 20f; + NPC.ai[2] += 0.0222222228f; + if (expertMode) + NPC.ai[2] += 0.0166666675f; + + float velocity = 8f + (enrageScale - 1f) * 2f; + float follyQuickFlySpeed = velocity + NPC.ai[2] + follyQuickFlyTargetDirection.Length() / 120f; + if (Main.getGoodWorld) + follyQuickFlySpeed *= 2f; + + float follyQuickFlyVelMult = 20f; + follyQuickFlyTargetDirection.Normalize(); + follyQuickFlyTargetDirection *= follyQuickFlySpeed; + NPC.velocity = (NPC.velocity * (follyQuickFlyVelMult - 1f) + follyQuickFlyTargetDirection) / follyQuickFlyVelMult; + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (Main.getGoodWorld ? 90f : 180f)) + { + NPC.TargetClosest(); + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + NPC.ForceNetUpdate(false); + NPC.SyncExtraAI(); + } + } + + // Line up charge + else if (NPC.ai[0] == 3f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult * 0.5f + NPC.velocity.X * rotationAmt * 0.85f) / 5f; + + Vector2 follyLineUpTargetDirection = player.Center - NPC.Center; + follyLineUpTargetDirection.Y -= 12f; + if (NPC.Center.X > player.Center.X) + follyLineUpTargetDirection.X += chargeDistance; + else + follyLineUpTargetDirection.X -= chargeDistance; + + float verticalDistanceGateValue = (phase3 ? 100f : 20f) + (enrageScale - 1f) * 20f; + if (Math.Abs(NPC.Center.X - player.Center.X) > chargeDistance - 50f && Math.Abs(NPC.Center.Y - player.Center.Y) < verticalDistanceGateValue) + { + NPC.ai[0] = 3.1f; + NPC.ai[1] = 0f; + + NPC.ForceNetUpdate(false); + NPC.SyncExtraAI(); + } + + NPC.ai[1] += 0.0333333351f; + float velocity = 16f + (enrageScale - 1f) * 4f; + float follyLineUpSpeed = velocity + NPC.ai[1]; + float follyLineUpVelMult = 4f; + follyLineUpTargetDirection.Normalize(); + follyLineUpTargetDirection *= follyLineUpSpeed; + NPC.velocity = (NPC.velocity * (follyLineUpVelMult - 1f) + follyLineUpTargetDirection) / follyLineUpVelMult; + } + + // Prepare to charge + else if (NPC.ai[0] == 3.1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.rotation = (NPC.rotation * rotationMult * 0.5f + NPC.velocity.X * rotationAmt * 0.85f) / 5f; + + Vector2 follyChargePrepareTargetDirection = player.Center - NPC.Center; + follyChargePrepareTargetDirection.Y -= 12f; + float follyChargePrepareSpeed = 28f + (enrageScale - 1f) * 4f; + float follyChargePrepareVelMult = 8f; + follyChargePrepareTargetDirection.Normalize(); + follyChargePrepareTargetDirection *= follyChargePrepareSpeed; + NPC.velocity = (NPC.velocity * (follyChargePrepareVelMult - 1f) + follyChargePrepareTargetDirection) / follyChargePrepareVelMult; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + + NPC.ai[1] += 1f; + if (NPC.ai[1] > 10f) + { + NPC.damage = (int)Math.Round(NPC.defDamage * DashDamageMult); + + NPC.velocity = follyChargePrepareTargetDirection; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.ai[0] = 3.2f; + NPC.ai[1] = NPC.direction; + + NPC.ForceNetUpdate(false); + NPC.SyncExtraAI(); + } + } + + // Charge + else if (NPC.ai[0] == 3.2f) + { + NPC.damage = (int)Math.Round(NPC.defDamage * DashDamageMult); + + NPC.ai[2] += 0.0333333351f; + float velocity = 28f + (enrageScale - 1f) * 4f; + NPC.velocity.X = (velocity + NPC.ai[2]) * NPC.ai[1]; + + if ((NPC.ai[1] > 0f && NPC.Center.X > player.Center.X + (chargeDistance - 140f)) || (NPC.ai[1] < 0f && NPC.Center.X < player.Center.X - (chargeDistance - 140f))) + { + if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.TargetClosest(); + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ForceNetUpdate(false); + } + else if (Math.Abs(NPC.Center.X - player.Center.X) > chargeDistance + 200f) + { + NPC.TargetClosest(); + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ForceNetUpdate(false); + } + } + + NPC.rotation = (NPC.rotation * rotationMult * 0.5f + NPC.velocity.X * rotationAmt * 0.85f) / 5f; + } + + // Birb spawn + else if (NPC.ai[0] == 4f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.ai[1] == 0f) + { + Vector2 destination2 = player.Center + new Vector2(0f, -200f); + Vector2 desiredVelocity2 = NPC.SafeDirectionTo(destination2, -Vector2.UnitY) * 18f; + NPC.SimpleFlyMovement(desiredVelocity2, 1.5f); + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + + NPC.ai[2] += 1f; + if (NPC.Distance(player.Center) < 600f || NPC.ai[2] >= 180f) + { + NPC.ai[1] = 1f; + NPC.ForceNetUpdate(false); + } + } + else + { + if (NPC.ai[1] < 90f) + NPC.velocity *= 0.95f; + else + NPC.velocity *= 0.98f; + + if (NPC.ai[1] == 90f) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y /= 3f; + + NPC.velocity.Y -= 3f; + } + + // Sound + if (NPC.ai[1] == birbSpawnPhaseTimer - 60f) + { + float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; + SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, NPC.Center); + + if (Main.zenithWorld) + { + int spacing = 30; + int amt = 3; + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), LightningDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } + } + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + bool gfbSpawnFlag = Main.zenithWorld && (NPC.ai[1] == 145f || NPC.ai[1] == 150f || NPC.ai[1] == 160f || NPC.ai[1] == 165f); + bool spawnFlag = NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && (NPC.ai[1] == 140f || (revenge && NPC.ai[1] == 155f) || NPC.ai[1] == 170f || gfbSpawnFlag); + if (spawnFlag) + { + Vector2 follySpawnCenter = NPC.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 50f * (0.6f + Main.rand.NextFloat() * 0.4f); + if (Vector2.Distance(follySpawnCenter, player.Center) > 150f) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)follySpawnCenter.X, (int)follySpawnCenter.Y, ModContent.NPCType(), NPC.whoAmI); + + NPC.ForceNetUpdate(false); + } + } + + NPC.ai[1] += 1f; + } + + if (NPC.ai[1] >= birbSpawnPhaseTimer) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.TargetClosest(); + NPC.ForceNetUpdate(false); + } + } + + // Spit homing aura sphere + else if (NPC.ai[0] == 5f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + // Velocity + NPC.velocity *= 0.98f; + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt) / 10f; + + // Play sound + float aiGateValue = 120f; + if (NPC.ai[1] == aiGateValue - 30f) + { + SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 follySpawnCenter = NPC.rotation.ToRotationVector2() * (Vector2.UnitX * NPC.direction) * (NPC.width + 20) / 2f + NPC.Center; + float ai0 = (phase3 ? 2f : 0f) + (enrageScale - 1f); + if (ai0 > 3f) + ai0 = 3f; + + Projectile.NewProjectile(NPC.GetSource_FromAI(), follySpawnCenter.X, follySpawnCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, ai0, NPC.target + 1); + NPC.ForceNetUpdate(false); + } + + if (Main.zenithWorld) + { + int spacing = 30; + int amt = 3; + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), LightningDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } + } + } + } + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= aiGateValue) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ForceNetUpdate(false); + } + } + } + + public override void FindFrame(int frameHeight) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; + bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); + bool birbSpawn = NPC.ai[0] == 4f && NPC.ai[1] > 0f; + + // Animation goes nyoom + if (Main.zenithWorld) + { + NPC.frameCounter += 4; + } + + float newPhaseTimer = 180f; + bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || + (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); + + if (phaseSwitchPhase || birbSpawn) + { + float frameGateValue = birbSpawn ? NPC.ai[1] : phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]; + int frameTimer = 180; + if (frameGateValue < (frameTimer - 60) || frameGateValue > (frameTimer - 20)) + { + NPC.frameCounter += 1D; + if (NPC.frameCounter > 5D) + { + NPC.frameCounter = 0D; + NPC.frame.Y += frameHeight; + } + if (NPC.frame.Y >= frameHeight * 5) + { + NPC.frame.Y = 0; + } + } + else + { + NPC.frame.Y = frameHeight * 4; + if (frameGateValue > (frameTimer - 50) && frameGateValue < (frameTimer - 25)) + { + NPC.frame.Y = frameHeight * 5; + } + } + } + else if (NPC.ai[0] == 5f) + { + int otherFrameTimer = 120; + if (NPC.ai[1] < (otherFrameTimer - 50) || NPC.ai[1] > (otherFrameTimer - 10)) + { + NPC.frameCounter += 1D; + if (NPC.frameCounter > 5D) + { + NPC.frameCounter = 0D; + NPC.frame.Y += frameHeight; + } + if (NPC.frame.Y >= frameHeight * 5) + { + NPC.frame.Y = 0; + } + } + else + { + NPC.frame.Y = frameHeight * 4; + if (NPC.ai[1] > (otherFrameTimer - 40) && NPC.ai[1] < (otherFrameTimer - 15)) + { + NPC.frame.Y = frameHeight * 5; + } + } + } + else + { + NPC.frameCounter += (NPC.ai[0] == 3.2f ? 1.5 : 1D); + if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base + { + NPC.frameCounter = 0D; + NPC.frame.Y += frameHeight; + } + if (NPC.frame.Y >= frameHeight * 5) + { + NPC.frame.Y = 0; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; + bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); + + float newPhaseTimer = 180f; + bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || + (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); + + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = TextureAssets.Npc[Type].Value; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2)); + Color color = drawColor; + Color altColor = Color.White; + + float lerpDrawTransition = 0f; + int newAITracker = 120; + int buffColorDampener = 60; + + if (phase3 && calamityGlobalNPC.newAI[3] == 1f) + { + color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.6f, 0.2f, 1f); + } + else if (phase2 && calamityGlobalNPC.newAI[2] == 1f) + { + color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.3f, 1f); + } + else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker) + { + float phase2TranBuff = calamityGlobalNPC.newAI[0] - (float)newAITracker; + phase2TranBuff /= (float)buffColorDampener; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * phase2TranBuff, 1f - 0.3f * phase2TranBuff, 1f - 0.7f * phase2TranBuff, 1f); + } + + int afterimageAmt = 10; + int afterimageIncrement = 2; + if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f) + { + afterimageAmt = 4; + } + if (NPC.ai[0] == 1f || NPC.ai[0] == 3f || NPC.ai[0] == 4.1f) + { + afterimageAmt = 7; + } + if (NPC.ai[0] == 2f || NPC.ai[0] == 3.2f || (phase2 && calamityGlobalNPC.newAI[2] == 1f)) + { + altColor = Color.Yellow; + lerpDrawTransition = 0.5f; + } + else + { + color = altColor; + } + + if (CalamityClientConfig.Instance.Afterimages) + { + for (int i = 1; i < afterimageAmt; i += afterimageIncrement) + { + Color afterimageColor = color; + afterimageColor = Color.Lerp(afterimageColor, altColor, lerpDrawTransition); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimageDrawPos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; + afterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimageDrawPos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + } + + int extraAfterimageAmt = 0; + float extraAfterimageDampener = 0f; + float afterimageScaler = 0f; + + if (NPC.ai[0] == 0f || NPC.ai[0] == 3.1f || NPC.ai[0] == 4f || NPC.ai[0] == 4.2f) + { + extraAfterimageAmt = 4; + } + + if (NPC.ai[0] == 5f) + { + if (NPC.ai[1] > 60f) + { + extraAfterimageAmt = 6; + extraAfterimageDampener = 1f - (float)Math.Cos((double)((NPC.ai[1] - 60f) / 30f * MathHelper.TwoPi)); + extraAfterimageDampener /= 3f; + afterimageScaler = 40f; + } + } + + if (phaseSwitchPhase) + { + if (phase3 && calamityGlobalNPC.newAI[1] > (float)newAITracker) + { + extraAfterimageAmt = 6; + extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[1] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi)); + extraAfterimageDampener /= 3f; + afterimageScaler = 60f; + } + else if (phase2 && calamityGlobalNPC.newAI[0] > (float)newAITracker) + { + extraAfterimageAmt = 6; + extraAfterimageDampener = 1f - (float)Math.Cos((double)((calamityGlobalNPC.newAI[0] - (float)newAITracker) / (float)buffColorDampener * MathHelper.TwoPi)); + extraAfterimageDampener /= 3f; + afterimageScaler = 60f; + } + } + + if (CalamityClientConfig.Instance.Afterimages) + { + for (int j = 0; j < extraAfterimageAmt; j++) + { + Color extraAfterimageColor = altColor; + extraAfterimageColor = Color.Lerp(extraAfterimageColor, altColor, lerpDrawTransition); + extraAfterimageColor = NPC.GetAlpha(extraAfterimageColor); + extraAfterimageColor *= 1f - extraAfterimageDampener; + Vector2 extraAfterimageDrawPos = NPC.Center + ((float)j / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos; + extraAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; + extraAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, extraAfterimageDrawPos, NPC.frame, extraAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + } + + Color mainDrawingColor = altColor; + mainDrawingColor = Color.Lerp(mainDrawingColor, altColor, lerpDrawTransition); + mainDrawingColor = NPC.GetAlpha(mainDrawingColor); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, (phase3 && calamityGlobalNPC.newAI[3] == 1f ? mainDrawingColor : NPC.GetAlpha(altColor)), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + if (phase2) + { + texture2D15 = GlowTexture.Value; + Color glowmaskColor = Color.Lerp(Color.White, Color.Red, 0.5f); + altColor = Color.Red; + + lerpDrawTransition = 1f; + extraAfterimageDampener = 0.5f; + afterimageScaler = 10f; + afterimageIncrement = 1; + + if (phaseSwitchPhase) + { + float glowmaskDampener = (phase3 ? calamityGlobalNPC.newAI[1] : calamityGlobalNPC.newAI[0]) - (float)newAITracker; + glowmaskDampener /= (float)buffColorDampener; + altColor *= glowmaskDampener; + glowmaskColor *= glowmaskDampener; + } + + if (CalamityClientConfig.Instance.Afterimages) + { + for (int k = 1; k < afterimageAmt; k += afterimageIncrement) + { + Color glowmaskAfterimageColor = glowmaskColor; + glowmaskAfterimageColor = Color.Lerp(glowmaskAfterimageColor, altColor, lerpDrawTransition); + glowmaskAfterimageColor *= (float)(afterimageAmt - k) / 15f; + Vector2 glowmaskAfterimageDrawPos = NPC.oldPos[k] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + glowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; + glowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, glowmaskAfterimageDrawPos, NPC.frame, glowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + + for (int l = 1; l < extraAfterimageAmt; l++) + { + Color extraGlowmaskAfterimageColor = glowmaskColor; + extraGlowmaskAfterimageColor = Color.Lerp(extraGlowmaskAfterimageColor, altColor, lerpDrawTransition); + extraGlowmaskAfterimageColor = NPC.GetAlpha(extraGlowmaskAfterimageColor); + extraGlowmaskAfterimageColor *= 1f - extraAfterimageDampener; + Vector2 extraGlowmaskAfterimageDrawPos = NPC.Center + ((float)l / (float)extraAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScaler * extraAfterimageDampener - screenPos; + extraGlowmaskAfterimageDrawPos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; + extraGlowmaskAfterimageDrawPos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, extraGlowmaskAfterimageDrawPos, NPC.frame, extraGlowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + + return false; + } + + private static Color buffColor(Color newColor, float R, float G, float B, float A) + { + newColor.R = (byte)((float)newColor.R * R); + newColor.G = (byte)((float)newColor.G * G); + newColor.B = (byte)((float)newColor.B * B); + newColor.A = (byte)((float)newColor.A * A); + return newColor; + } + + public override void BossLoot(ref int potionType) => potionType = ItemID.SuperHealingPotion; + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + + // Normal drops: Everything that would otherwise be in the bag + var normalOnly = npcLoot.DefineNormalOnlyDropSet(); + { + // Weapons + int[] items = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; + normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, items)); + + // Materials + normalOnly.Add(ModContent.ItemType(), 1, 25, 30); + + // Equipment + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); + + // Vanity + normalOnly.Add(ModContent.ItemType(), 7); + normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); + } + + npcLoot.Add(ModContent.ItemType(), 10); + + // Relic + npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); + + // GFB Omega Healing Potion drop + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 50, 100), true); + + // Lore + npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedDragonfolly, ModContent.ItemType(), desc: DropHelper.FirstKillText); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage > 0) + target.AddBuff(ModContent.BuffType(), Main.zenithWorld ? 360 : 180); + } + + public override void OnKill() + { + // Don't bother running any of this in Boss Rush. + if (BossRushEvent.BossRushActive) + return; + + CalamityGlobalNPC.SetNewBossJustDowned(NPC); + + // Mark The Dragonfolly as dead + DownedBossSystem.downedDragonfolly = true; + CalamityNetcode.SyncWorld(); + + if (Main.zenithWorld) + { + int spacing = 40; + int amt = 7; + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < amt; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (spacing * i) - (spacing * amt / 2), NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), LightningDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } + } + } + + } + + public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) + { + NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); + } + + public override void ModifyTypeName(ref string typeName) + { + if (Main.zenithWorld) + { + typeName = CalamityUtils.GetTextValue("NPCs.Bumblebirb"); + } + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 50; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); + } + if (!Main.dedServ) + { + for (int i = 0; i < 6; i++) // 1 head, 1 wing, 4 legs = 6. one wing due to them being chonky boyes now + { + string gore = "Bumble"; + float randomSpread = Main.rand.Next(-200, 201) / 100f; + gore += i == 0 ? "Head" : i > 1 ? "Leg" : "Wing"; + Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread, Mod.Find(gore).Type, 1f); + } + } + } + } + } +} diff --git a/NPCs/CalClone/CalamitasClone.cs b/NPCs/CalClone/CalamitasClone.cs index 4a97327806..7f96e910bc 100644 --- a/NPCs/CalClone/CalamitasClone.cs +++ b/NPCs/CalClone/CalamitasClone.cs @@ -1,22 +1,24 @@ -using System.IO; +using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; using CalamityMod.NPCs.TownNPCs; -using CalamityMod.Sounds; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Systems.Mechanic; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -40,8 +42,65 @@ namespace CalamityMod.NPCs.CalClone public static readonly SoundStyle BulletHellWarning = new("CalamityMod/Sounds/Custom/CalamitasClone/BulletHellEnding"); public static readonly SoundStyle BulletHellEnd = new("CalamityMod/Sounds/Custom/CalamitasClone/BulletHellEnd"); public static readonly SoundStyle ChargeSound = new("CalamityMod/Sounds/Custom/CalamitasClone/CalCloneDash", 3); + public static readonly SoundStyle CalamitousFireballSound = new SoundStyle("CalamityMod/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit", 4) with {MaxInstances = 4}; + public static readonly SoundStyle CalamitousExplosionSound = new SoundStyle("CalamityMod/Sounds/Custom/CalamitasClone/CalClone_Explosion", 3) with { MaxInstances = 4 }; public SlotId BulletHellWarnSlot; + public ArenaWallSystem.Box ArenaBox = null; + void UpdateArena(ArenaWallSystem.Box box) + { + if (box.borderColor == Color.Gray || box.oldData.borderColor == Color.Gray) + return; + for (var i2 = 0; i2 < box.Size.Y / 400f; i2++) + { + var p = Vector2.Lerp(box.BottomRight, box.TopRight, Main.rand.NextFloat()); + Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor); + + p = Vector2.Lerp(box.TopLeft, box.BottomLeft, Main.rand.NextFloat()); + Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor); + + } + for (var i2 = 0; i2 < box.Size.X / 400f; i2++) + { + var p = Vector2.Lerp(box.TopLeft, box.TopRight, Main.rand.NextFloat()); + Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor); + p = Vector2.Lerp(box.BottomRight, box.BottomLeft, Main.rand.NextFloat()); + Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor); + } + } + + void DrawArena(ArenaWallSystem.Box box) + { + + var color = Color.Black * 0.75f; + //Inside Fill + box.DrawBoxWithOffset(box.borderThickness * 0.5f, box.borderThickness, Color.Black * 0.75f); + //Inner Border + box.DrawBoxWithOffset(4, 8, box.borderColor); + //Inner Border Clones + float amount = 4; + float totalDistance = 64f; + for (var i = Main.GlobalTimeWrappedHourly % 1; i < amount; i++) + { + box.DrawBoxWithOffset(totalDistance * (i / amount) + 4, 4, box.borderColor * (1 - i / amount)); + } + //Outer Border + box.DrawBoxWithOffset(box.borderThickness - 4, 4, box.borderColor); + } + public static Vector4 GetArenaSize(bool brothersActive = false, float lifeRatio = 0, bool inBulletHell = false) + { + var baseSize = new Vector4(1600, 800, 0, 800); + if (brothersActive) + baseSize *= 1.25f; + if (NPC.AnyNPCs(ModContent.NPCType())) + baseSize *= new Vector4(1.5f, 0.75f, 1.5f, 0.75f); + if (!CalamityWorld.death) + baseSize *= 1.25f; + if (lifeRatio < 0.1f && !inBulletHell && CalamityWorld.death) + baseSize *= MathHelper.Lerp(Main.getGoodWorld ? 0.22f : 0.4f, 1f, lifeRatio * 10f); // Scale down the lower health calclone has. Much lower bound on FTW. + + return baseSize + new Vector4(-22, 0, 22, 0); + } public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 6; @@ -61,21 +120,22 @@ namespace CalamityMod.NPCs.CalClone } } + public static int DartDamage = 22; // 88 + public static int HellblastDamage = 25; // 100 + public static int HellfireballDamage = 25; // 100 + public static int FireblastDamage = 35; // 140; Also applies to GFB Gigablasts + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 70; // 140 NPC.npcSlots = 14f; NPC.width = 120; NPC.height = 120; - if (CalamityWorld.death || BossRushEvent.BossRushActive) - NPC.scale *= 0.8f; - - NPC.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 12 : 25; - NPC.value = Item.buyPrice(0, 20, 0, 0); - NPC.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.075f : 0.15f); - NPC.LifeMaxNERB(37500, 45000, 520000); + NPC.defense = 25; + NPC.value = Item.buyPrice(gold: 15); + NPC.LifeMaxNERB(30000, 46875, 520000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -87,9 +147,6 @@ namespace CalamityMod.NPCs.CalClone NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -108,7 +165,6 @@ namespace CalamityMod.NPCs.CalClone writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); writer.Write(NPC.localAI[2]); - writer.Write(NPC.localAI[3]); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -119,7 +175,6 @@ namespace CalamityMod.NPCs.CalClone NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); NPC.localAI[2] = reader.ReadSingle(); - NPC.localAI[3] = reader.ReadSingle(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); } @@ -131,10 +186,764 @@ namespace CalamityMod.NPCs.CalClone int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; } - public override void AI() { - CalamitasCloneAI.VanillaCalamitasCloneAI(NPC, Mod, BulletHellWarnSlot); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Emit light + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1f, 0f, 0f); + + // Variables for increasing difficulty + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < 0.7f || death; + bool phase3 = lifeRatio < 0.35f; + bool phase4 = lifeRatio <= 0.1f && death; + + // Don't take damage during bullet hells + NPC.dontTakeDamage = calamityGlobalNPC.newAI[2] > 0f; + + // Variable for live brothers + bool brotherAlive = false; + + // For seekers + CalamityGlobalNPC.calamitas = NPC.whoAmI; + + // Seeker ring + if (calamityGlobalNPC.newAI[1] == 0f && phase3 && expertMode) + { + SoundEngine.PlaySound(SoundID.Item72, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int seekerAmt = death ? 10 : 5; + int seekerSpread = 360 / seekerAmt; + int seekerDistance = death ? 180 : 150; + for (int i = 0; i < seekerAmt; i++) + { + int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + (Math.Sin(i * seekerSpread) * seekerDistance)), (int)(NPC.Center.Y + (Math.Cos(i * seekerSpread) * seekerDistance)), ModContent.NPCType(), NPC.whoAmI, 0, 0, 0, -1); + Main.npc[spawn].ai[0] = i * seekerSpread; + } + } + + string key = "Mods.CalamityMod.Status.Boss.CalamitasBossText3"; + Color messageColor = Color.Orange; + CalamityUtils.BroadcastLocalizedText(key, messageColor); + + calamityGlobalNPC.newAI[1] = 1f; + } + + // CIT 14SEP2024: Fixed bug where her phases would get offset by dealing a large amount of damage in a single hit to take her into a new phase. + // newAI[0] now starts at 1 and has 0.3 subtracted from it for each phase, instead of it storing her current health when she enters a new phase. + + // Do bullet hell or spawn brothers + if (calamityGlobalNPC.newAI[0] == 0f && NPC.life > 0) + calamityGlobalNPC.newAI[0] = 1f; + + // Bullet hells at 70% and 10%, brothers at 40% + if (NPC.life > 0) + { + int calClonePhaseThreshold = (int)(NPC.lifeMax * 0.3); + if (((NPC.life + calClonePhaseThreshold) / (float)NPC.lifeMax) < calamityGlobalNPC.newAI[0]) + { + calamityGlobalNPC.newAI[0] -= 0.3f; + if (calamityGlobalNPC.newAI[0] <= 0.1f) + { + SoundEngine.PlaySound(SoundID.Item109, NPC.Center); + calamityGlobalNPC.newAI[2] = 2f; + + if (Main.zenithWorld) + calamityGlobalNPC.newAI[3] = 0f; + + SpawnDust(); + } + else if (calamityGlobalNPC.newAI[0] <= 0.4f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.position.Y + NPC.height, ModContent.NPCType(), NPC.whoAmI); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.position.Y + NPC.height, ModContent.NPCType(), NPC.whoAmI); + } + + string key = "Mods.CalamityMod.Status.Boss.CalamitasBossText2"; + Color messageColor = Color.Orange; + CalamityUtils.BroadcastLocalizedText(key, messageColor); + + SpawnDust(); + } + else + { + SoundEngine.PlaySound(SoundID.Item109, NPC.Center); + calamityGlobalNPC.newAI[2] = 1f; + + if (Main.zenithWorld) + calamityGlobalNPC.newAI[3] = 0f; + + SpawnDust(); + } + } + } + + // Immunity if brothers are alive + if (CalamityGlobalNPC.cataclysm != -1) + { + if (Main.npc[CalamityGlobalNPC.cataclysm].active) + brotherAlive = true; + } + if (CalamityGlobalNPC.catastrophe != -1) + { + if (Main.npc[CalamityGlobalNPC.catastrophe].active) + brotherAlive = true; + } + + if (brotherAlive) + NPC.dontTakeDamage = true; + + bool inBulletHell = calamityGlobalNPC.newAI[2] > 0f; + + //arena in rev+ + if (revenge) + { + if (ArenaBox is null) + { + ArenaBox = new() + { + position = Main.player[NPC.FindClosestPlayer()].Center, + boxDimensions = new Vector4(2000), + borderThickness = 2000, + RemovalCondition = () => !(Main.npc[NPC.whoAmI].active) || Main.npc[NPC.whoAmI].type != Type, + UpdateBox = UpdateArena, + DrawBox = DrawArena, + DespawnAction = (box) => + { + box.boxDimensions += new Vector4(64); + if (box.Size.X > 5000) + return true; + return false; + } + }; + ArenaWallSystem.ActiveBoxes.Add(ArenaBox); + } + ArenaBox.NewDimensions = Vector4.Lerp(ArenaBox.boxDimensions, GetArenaSize(brotherAlive, lifeRatio, inBulletHell), lifeRatio > 0.9f ? 0.1f : 0.025f); + if (ArenaBox.oldData is not null) + ArenaBox.oldData.borderColor = Color.White; + if (brotherAlive) + ArenaBox.borderColor = Color.Lerp(ArenaBox.borderColor, Color.Lerp(new Color(0, 255, 255), new Color(255, 0, 229), (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.5f) + 1) * 0.5f), 0.03f); + else if (NPC.AnyNPCs(ModContent.NPCType())) + ArenaBox.borderColor = Color.Lerp(ArenaBox.borderColor, Color.Lerp(Color.Crimson, new Color(255, 106, 0), (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.5f) + 1) * 0.5f), 0.03f); + else if (NPC.dontTakeDamage) + { + ArenaBox.borderColor = Color.Lerp(ArenaBox.borderColor, Color.Gray, 0.1f); + ArenaBox.oldData.borderColor = Color.Gray; + } + else + ArenaBox.borderColor = Color.Lerp(ArenaBox.borderColor, Color.Lerp(Color.Crimson, Color.IndianRed, (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.5f) + 1) * 0.25f), 0.03f); + } + + void SpawnDust() + { + int dustAmt = 50; + int random = 3; + + for (int j = 0; j < 10; j++) + { + random += j; + int dustAmtSpawned = 0; + int scale = random * 6; + float dustPositionX = NPC.Center.X - (scale / 2); + float dustPositionY = NPC.Center.Y - (scale / 2); + while (dustAmtSpawned < dustAmt) + { + float dustVelocityX = Main.rand.Next(-random, random); + float dustVelocityY = Main.rand.Next(-random, random); + float dustVelocityScalar = random * 2f; + float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); + dustVelocity = dustVelocityScalar / dustVelocity; + dustVelocityX *= dustVelocity; + dustVelocityY *= dustVelocity; + int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].position.X = NPC.Center.X; + Main.dust[dust].position.Y = NPC.Center.Y; + Main.dust[dust].position.X += Main.rand.Next(-10, 11); + Main.dust[dust].position.Y += Main.rand.Next(-10, 11); + Main.dust[dust].velocity.X = dustVelocityX; + Main.dust[dust].velocity.Y = dustVelocityY; + dustAmtSpawned++; + } + } + } + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + // Target variable + Player player = Main.player[NPC.target]; + + + //Invincible outside of arena + if (ArenaBox is not null) + { + if (!Collision.CheckAABBvAABBCollision(ArenaBox.TopLeft,ArenaBox.Size,player.position,player.Size)) + NPC.dontTakeDamage = true; + } + + // Rotation + Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.position.Y + NPC.height - 59f); + Vector2 lookAt = new Vector2(player.position.X - (player.width / 2), player.position.Y - (player.height / 2)); + Vector2 rotationVector = npcCenter - lookAt; + + float rotation = (float)Math.Atan2(rotationVector.Y, rotationVector.X) + MathHelper.PiOver2; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + else if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + float rotationAmt = 0.1f; + if (NPC.rotation < rotation) + { + if ((rotation - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= rotationAmt; + else + NPC.rotation += rotationAmt; + } + else if (NPC.rotation > rotation) + { + if ((NPC.rotation - rotation) > MathHelper.Pi) + NPC.rotation += rotationAmt; + else + NPC.rotation -= rotationAmt; + } + + if (NPC.rotation > rotation - rotationAmt && NPC.rotation < rotation + rotationAmt) + NPC.rotation = rotation; + if (NPC.rotation < 0f) + NPC.rotation += MathHelper.TwoPi; + else if (NPC.rotation > MathHelper.TwoPi) + NPC.rotation -= MathHelper.TwoPi; + if (NPC.rotation > rotation - rotationAmt && NPC.rotation < rotation + rotationAmt) + NPC.rotation = rotation; + + // Despawn + if (!player.active || player.dead) + { + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + if (!player.active || player.dead) + { + if (SoundEngine.TryGetActiveSound(BulletHellWarnSlot, out var warningSound) && warningSound.IsPlaying) + warningSound.Stop(); + + if (NPC.velocity.Y > 3f) + NPC.velocity.Y = 3f; + NPC.velocity.Y -= 0.1f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + + if (NPC.ai[1] != 0f) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + NPC.alpha = 0; + NPC.netUpdate = true; + } + return; + } + } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; + + // Distance from destination where Cal Clone stops moving + float movementDistanceGateValue = 100f; + + // How fast Cal Clone moves to the destination + float baseVelocity = (expertMode ? 10f : 8.5f) * (NPC.ai[1] == 4f ? 1.4f : 1f); + float baseAcceleration = (expertMode ? 0.18f : 0.155f) * (NPC.ai[1] == 4f ? 1.4f : 1f); + if (revenge) + { + baseVelocity += 1.5f * (1f - lifeRatio); + baseAcceleration += 0.03f * (1f - lifeRatio); + } + if (death) + { + baseVelocity += 1.5f * (1f - lifeRatio); + baseAcceleration += 0.03f * (1f - lifeRatio); + } + if (Main.getGoodWorld) + { + baseVelocity *= 1.15f; + baseAcceleration *= 1.15f; + } + + // What side Cal Clone should be on, relative to the target + int xPos = 1; + if (NPC.Center.X < player.Center.X) + xPos = -1; + + // How far Cal Clone should be from the target + float averageDistance = 400f; + float chargeDistance = phase4 ? 300f : 400f; + + // This is where Cal Clone should be + Vector2 destination = (calamityGlobalNPC.newAI[2] > 0f || NPC.ai[1] == 0f) ? new Vector2(player.Center.X, player.Center.Y - averageDistance) : + NPC.ai[1] == 1f ? new Vector2(player.Center.X + averageDistance * xPos, player.Center.Y) : + new Vector2(player.Center.X + chargeDistance * xPos, player.Center.Y); + + // Add some random distance to the destination after certain attacks + if (NPC.localAI[0] == 1f) + { + NPC.localAI[0] = 0f; + NPC.localAI[2] = Main.rand.Next(-300, 301); + NPC.netUpdate = true; + } + + // Add a bit of randomness to the destination + if (death) + { + if (NPC.ai[1] == 0f) + destination.X += NPC.localAI[2]; + else + destination.Y += NPC.localAI[2]; + } + + // How far Cal Clone is from where she's supposed to be + Vector2 distanceFromDestination = destination - NPC.Center; + + // Movement + if (NPC.ai[1] == 0f || NPC.ai[1] == 1f || NPC.ai[1] == 4f || calamityGlobalNPC.newAI[2] > 0f) + CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, baseAcceleration, true); + + // Bullet hell phase + if (calamityGlobalNPC.newAI[2] > 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (calamityGlobalNPC.newAI[3] < 900f) + { + calamityGlobalNPC.newAI[3] += 1f; + NPC.dontTakeDamage = true; + NPC.alpha = 255; + + float rotX = player.Center.X - NPC.Center.X; + float rotY = player.Center.Y - NPC.Center.Y; + NPC.rotation = (float)Math.Atan2(rotY, rotX) - MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (calamityGlobalNPC.newAI[2] == 2f) + { + int type = ModContent.ProjectileType(); + int damage = FireblastDamage; + if (Main.zenithWorld) + type = ModContent.ProjectileType(); + + float gigaBlastFrequency = Main.getGoodWorld ? 120f : expertMode ? 180f : 240f; + float projSpeed = 5f; + if (calamityGlobalNPC.newAI[3] <= 300f) + { + if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); + } + else if (calamityGlobalNPC.newAI[3] <= 600f && calamityGlobalNPC.newAI[3] > 300f) + { + if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from right + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -projSpeed, 0f, type, damage, 0f, Main.myPlayer); + } + else if (calamityGlobalNPC.newAI[3] > 600f) + { + if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); + } + } + } + + NPC.ai[0] += 1f; + float hellblastGateValue = expertMode ? 12f : 16f; + if (NPC.ai[0] >= hellblastGateValue) + { + NPC.ai[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = HellblastDamage; + float projSpeed = 4f; + // Blasts aimed directly at the player's horizontal position, does not spawn during the second bullet hell + if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f && calamityGlobalNPC.newAI[2] != 2f) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = distance == -1000f ? projSpeed : -projSpeed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + + if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + else // Blasts from above, left, and right + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + } + } + + if (calamityGlobalNPC.newAI[3] == 900f - 360f) + BulletHellWarnSlot = SoundEngine.PlaySound(CalamitasClone.BulletHellWarning with { Volume = 0.75f }, player.Center); + if (calamityGlobalNPC.newAI[3] > 900f - 360f) + { + if (SoundEngine.TryGetActiveSound(BulletHellWarnSlot, out var warningSound) && warningSound.IsPlaying) + warningSound.Position = player.Center; + } + } + else + { + NPC.ai[0] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + SoundEngine.PlaySound(CalamitasClone.BulletHellEnd with { Volume = 0.75f }, player.Center); + + // Prevent bullshit charge hits when second bullet hell ends. + if (phase4) + { + NPC.ai[1] = 4f; + NPC.ai[2] = -105f; + NPC.TargetClosest(); + } + else + { + if (death) + { + int AIState = Main.rand.Next(3); + switch (AIState) + { + case 0: + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + break; + case 1: + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + break; + case 2: + NPC.ai[1] = 4f; + NPC.ai[2] = -105f; + NPC.TargetClosest(); + break; + } + } + else + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + if (death) + NPC.localAI[0] = 1f; + } + + NPC.netUpdate = true; + + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active) + { + if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + { + if (projectile.timeLeft > 60) + projectile.timeLeft = 60; + } + else if (projectile.type == ModContent.ProjectileType()) + { + projectile.ai[2] = 1f; + + if (projectile.timeLeft > 60) + projectile.timeLeft = 60; + } + } + } + } + + return; + } + else if (Main.zenithWorld) + { + if (calamityGlobalNPC.newAI[3] < 900f) + calamityGlobalNPC.newAI[3] += 1f; + else + calamityGlobalNPC.newAI[3] = 0f; + + NPC.ai[0] += 1f; + float hellblastGateValue = 30f; + if (NPC.ai[0] >= hellblastGateValue) + { + NPC.ai[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = HellblastDamage; + float projSpeed = 4f; + if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f) + { + float distance = Main.rand.NextBool() ? -1000f : 1000f; + float velocity = distance == -1000f ? projSpeed : -projSpeed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + + if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + else // Blasts from above, left, and right + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + } + } + } + } + + NPC.alpha = NPC.dontTakeDamage ? 255 : 0; + + // Float above target and fire hellfireballs + if (NPC.ai[1] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[2] += 1f; + float phaseTimer = 400f - (death ? 120f * (1f - lifeRatio) : 0f); + if (NPC.ai[2] >= phaseTimer || phase4) + { + // Prevent going to other positions during brothers phase + if (!brotherAlive) + NPC.ai[1] = death && !phase4 && Main.rand.NextBool() ? 4f : 1f; + + NPC.ai[2] = 0f; + if (death) + NPC.localAI[0] = 1f; + + NPC.netUpdate = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && !brotherAlive) + { + NPC.localAI[1] += 1f; + if (expertMode) + NPC.localAI[1] += death ? 2f * (1f - lifeRatio) : 1f - lifeRatio; + if (revenge) + NPC.localAI[1] += 0.5f; + + if (NPC.localAI[1] >= 120f) + { + NPC.localAI[1] = 0f; + SoundEngine.PlaySound(CalamitousFireballSound, NPC.Center); + + float projectileVelocity = expertMode ? 14f : 12.5f; + int type = ModContent.ProjectileType(); + Vector2 predictionVector = Main.getGoodWorld ? player.velocity * 20f : Vector2.Zero; + Vector2 fireballVelocity = Vector2.Normalize(player.Center + predictionVector - NPC.Center) * projectileVelocity; + Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, fireballVelocity, type, HellfireballDamage, 0f, Main.myPlayer, player.position.X, player.position.Y); + Main.projectile[proj].netUpdate = true; + } + } + } + + // Float to the side of the target and fire + else if (NPC.ai[1] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (Main.netMode != NetmodeID.MultiplayerClient && !brotherAlive) + { + NPC.localAI[1] += 1f; + if (revenge) + NPC.localAI[1] += 0.5f; + if (expertMode) + NPC.localAI[1] += 0.5f; + + if (NPC.localAI[1] >= 50f && Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + { + NPC.localAI[1] = 0f; + + float projectileVelocity = expertMode ? 12.5f : 11f; + int type = ModContent.ProjectileType(); + int damage = HellblastDamage; + Vector2 fireballVelocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; + Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; + + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) + { + type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, fireballVelocity, type, HellfireballDamage, 0f, Main.myPlayer, player.position.X, player.position.Y); + } + else + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, fireballVelocity, type, damage, 0f, Main.myPlayer, 1f); + SoundEngine.PlaySound(CalamitousFireballSound, NPC.Center); + } + } + } + + NPC.ai[2] += 1f; + float phaseTimer = 240f - (death ? 60f * (1f - lifeRatio) : 0f); + if (NPC.ai[2] >= phaseTimer || phase4) + { + if (brotherAlive) + NPC.ai[1] = 0f; + else if (death && !phase4 && Main.rand.NextBool()) + NPC.ai[1] = 0f; + else + NPC.ai[1] = phase2 && revenge ? 4f : 0f; + + NPC.ai[2] = 0f; + if (death) + NPC.localAI[0] = 1f; + + NPC.netUpdate = true; + } + } + else if (NPC.ai[1] == 2f) + { + // Set damage + NPC.damage = NPC.defDamage; + SoundEngine.PlaySound(ChargeSound, NPC.Center); + NPC.rotation = rotation; + + float chargeVelocity = phase4 ? 30f : death ? 28f : 25f; + + Vector2 vector = Vector2.Normalize(player.Center - NPC.Center); + NPC.velocity = vector * chargeVelocity; + + NPC.ai[1] = 3f; + NPC.netUpdate = true; + } + else if (NPC.ai[1] == 3f) // Dashing time + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.ai[2] += 1f; + + float chargeTime = phase4 ? 35f : death ? 40f : 45f; + if (NPC.ai[2] >= chargeTime) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.velocity *= 0.9f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; + } + else + { + //VFX + for (var i = 0; i < 5; i++) + { + var p = CalamitasMetaball.SpawnParticle(NPC.Center + NPC.velocity + (NPC.rotation + MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(1f) * 64f, NPC.velocity.RotatedByRandom(0.25f) * 0.5f, 32f); + p.SizeScaling = 0.9f; + } + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) - MathHelper.PiOver2; + + // Leave behind slow hellblasts in Death Mode + if (Main.netMode != NetmodeID.MultiplayerClient && death && phase4 && NPC.ai[2] % 6f == 0f) + { + int type = ModContent.ProjectileType(); + Vector2 fireballVelocity = Main.getGoodWorld ? Main.rand.NextVector2CircularEdge(0.02f, 0.02f) : NPC.velocity * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, fireballVelocity, type, HellblastDamage, 0f, Main.myPlayer, 1f, 0f, 2f); // ai[2] is used here to distinguish acceleration in its ai + } + } + + if (NPC.ai[2] >= chargeTime + 10f) + { + if (!phase4) + NPC.ai[3] += 1f; + + NPC.ai[2] = 0f; + + NPC.rotation = rotation; + NPC.netUpdate = true; + + if (NPC.ai[3] >= 2f) + { + NPC.TargetClosest(); + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + return; + } + + NPC.ai[1] = 4f; + } + } + + // Prepare dash + else + { + NPC.damage = 0; + + NPC.ai[2] += 1f; + float telegraphDuration = phase4 ? 15f : 30f; + + + float startTelegraphTime = phase4 ? -25f : -10f; // Start 40 frames before dash + if (NPC.ai[2] >= startTelegraphTime && NPC.ai[2] < telegraphDuration && Main.netMode != NetmodeID.MultiplayerClient) + { + // Lines converge inward + if (Main.rand.NextBool(3)) + { + + Vector2 dustVel2 = (Vector2.UnitX).RotatedByRandom(100) * Main.rand.NextFloat(23f, 28f); + + var p = CalamitasMetaball.SpawnParticle(NPC.Center + dustVel2.SafeNormalize(Vector2.UnitX) * 420, -dustVel2 * 1.2f, 16f * Main.rand.NextFloat(1.4f, 2.35f)); + p.Scale = new(1f, 0.33f); + p.rotation = p.Velocity.ToRotation(); + p.SizeScaling = 0.95f; + } + } + + if (NPC.ai[2] >= telegraphDuration) + { + NPC.ai[1] = 2f; // Start dash + NPC.ai[2] = 0f; + if (death) + NPC.localAI[0] = 1f; + + NPC.netUpdate = true; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -147,7 +956,11 @@ namespace CalamityMod.NPCs.CalClone Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[Type] / 2)); Color white = Color.White; float colorLerpAmt = 0.5f; - int afterimageAmt = 7; + int afterimageAmt = 6; + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + float lifeRatio = NPC.life / (float)NPC.lifeMax; + bool phase4 = lifeRatio <= 0.1f && death; if (CalamityClientConfig.Instance.Afterimages) { @@ -190,8 +1003,33 @@ namespace CalamityMod.NPCs.CalClone } } - spriteBatch.Draw(texture, npcOffset, NPC.frame, color, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + if (NPC.ai[1] == 4f) + { + // Same logic as in AI + float telegraphDuration = phase4 ? 15f : 30f; + float startTelegraphTime = phase4 ? -25f : -10f; + float glowTimeElapsed = NPC.ai[2] - startTelegraphTime; + float timeForMaxGlow = telegraphDuration - startTelegraphTime; + + float lifeFadeIn = Utils.GetLerpValue(0, timeForMaxGlow, glowTimeElapsed, true); + + float glowSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 10f); // Period of full pulse + float pulse = MathHelper.Lerp(0.7f, 1f, glowSine); // Least protruding to most protruding + float finalGlowIntensity = pulse * lifeFadeIn; + + // Create 20 visual copies of calclone that draw behind to create a glowy outline effect + for (int i = 0; i < 20; i++) + { + float rotationOffset = (MathHelper.TwoPi * i / 15); + Vector2 glowOffset = rotationOffset.ToRotationVector2() * (3f + glowSine * 1f) * finalGlowIntensity; + + // Use the drawPosition variable that incorporates the screen offset + Main.spriteBatch.Draw(texture, NPC.Center - screenPos + glowOffset, NPC.frame, Color.Red with { A = 150 } * finalGlowIntensity, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture, npcOffset, NPC.frame, color, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); return false; } @@ -213,9 +1051,10 @@ namespace CalamityMod.NPCs.CalClone normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, items)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); - normalOnly.Add(ModContent.ItemType(), 10); + normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); // Materials normalOnly.Add(ModContent.ItemType(), 1, 8, 10); @@ -235,7 +1074,7 @@ namespace CalamityMod.NPCs.CalClone npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Ashes of Annihilation drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 6, 9, true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 6, 9), true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCalamitasClone, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -249,14 +1088,14 @@ namespace CalamityMod.NPCs.CalClone CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedCalamitasClone); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedCalamitasClone); // Mark the Calamitas Clone as dead DownedBossSystem.downedCalamitasClone = true; CalamityNetcode.SyncWorld(); } - public override void BossLoot(ref string name, ref int potionType) => potionType = ItemID.GreaterHealingPotion; + public override void BossLoot(ref int potionType) => potionType = ItemID.GreaterHealingPotion; public override void HitEffect(NPC.HitInfo hit) { @@ -305,7 +1144,6 @@ namespace CalamityMod.NPCs.CalClone public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -317,7 +1155,7 @@ namespace CalamityMod.NPCs.CalClone public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 150, true); + target.AddBuff(ModContent.BuffType(), 240); } } } diff --git a/NPCs/CalClone/Cataclysm.cs b/NPCs/CalClone/Cataclysm.cs index c5b3cbf9c1..031a656f20 100644 --- a/NPCs/CalClone/Cataclysm.cs +++ b/NPCs/CalClone/Cataclysm.cs @@ -4,11 +4,12 @@ using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; +using System; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -47,11 +48,13 @@ namespace CalamityMod.NPCs.CalClone } } + public static int FlamethrowerDamage = 30; // 120 + public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 54; // 108 NPC.npcSlots = 5f; NPC.width = 120; NPC.height = 120; @@ -59,9 +62,8 @@ namespace CalamityMod.NPCs.CalClone if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; - NPC.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 15 : 10; - NPC.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.225f : 0.15f); - NPC.LifeMaxNERB(11000, 13200, 80000); + NPC.defense = 10; + NPC.LifeMaxNERB(7000, 10000, 80000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -109,7 +111,309 @@ namespace CalamityMod.NPCs.CalClone public override void AI() { - CalamitasCloneAI.VanillaCataclysmAI(NPC, Mod); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active) + { + if (NPC.alpha < 255) + { + NPC.velocity *= 0.9f; + + NPC.alpha += 2; + if (NPC.alpha > 255) + NPC.alpha = 255; + + int dustAmount = (int)Math.Round(MathHelper.Lerp(1f, 5f, (255 - NPC.alpha) / 255f)); + for (int i = 0; i < dustAmount; i++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, Main.rand.NextFloat(0.5f, 2f)); + Main.dust[dust].noGravity = true; + Main.dust[dust].fadeIn = 1f; + } + } + else + NPC.active = false; + + NPC.active = false; + return; + } + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + CalamityGlobalNPC.cataclysm = NPC.whoAmI; + + // Emit light + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1f, 0f, 0f); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + float calCloneBroPlayerXDist = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2); + float calCloneBroPlayerYDist = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2); + float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2; + if (calCloneBroRotation < 0f) + calCloneBroRotation += MathHelper.TwoPi; + else if (calCloneBroRotation > MathHelper.TwoPi) + calCloneBroRotation -= MathHelper.TwoPi; + + float calCloneBroRotationSpeed = 0.15f; + if (NPC.rotation < calCloneBroRotation) + { + if ((calCloneBroRotation - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= calCloneBroRotationSpeed; + else + NPC.rotation += calCloneBroRotationSpeed; + } + else if (NPC.rotation > calCloneBroRotation) + { + if ((NPC.rotation - calCloneBroRotation) > MathHelper.Pi) + NPC.rotation += calCloneBroRotationSpeed; + else + NPC.rotation -= calCloneBroRotationSpeed; + } + + if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + NPC.rotation = calCloneBroRotation; + if (NPC.rotation < 0f) + NPC.rotation += MathHelper.TwoPi; + else if (NPC.rotation > MathHelper.TwoPi) + NPC.rotation -= MathHelper.TwoPi; + if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + NPC.rotation = calCloneBroRotation; + + if (!player.active || player.dead) + { + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + if (!player.active || player.dead) + { + if (NPC.velocity.Y > 3f) + NPC.velocity.Y = 3f; + NPC.velocity.Y -= 0.1f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + + if (NPC.ai[1] != 0f) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + return; + } + } + + if (NPC.ai[1] == 0f) + { + float calCloneBroProjAttackMaxSpeed = 5f; + float calCloneBroProjAttackAccel = 0.1f; + + if (Main.getGoodWorld) + { + calCloneBroProjAttackMaxSpeed *= 1.15f; + calCloneBroProjAttackAccel *= 1.15f; + } + + int calCloneBroProjAttackDirection = 1; + if (NPC.position.X + (NPC.width / 2) < player.position.X + player.width) + calCloneBroProjAttackDirection = -1; + + Vector2 calCloneBroProjLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float calCloneBroProjTargetX = player.position.X + (player.width / 2) + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X; + float calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; + float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); + + if (expertMode) + { + if (calCloneBroProjTargetDist > 300f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 400f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 500f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 600f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 700f) + calCloneBroProjAttackMaxSpeed += 0.6f; + if (calCloneBroProjTargetDist > 800f) + calCloneBroProjAttackMaxSpeed += 0.6f; + } + + calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; + + if (NPC.velocity.X < calCloneBroProjTargetX) + { + NPC.velocity.X += calCloneBroProjAttackAccel; + if (NPC.velocity.X < 0f && calCloneBroProjTargetX > 0f) + NPC.velocity.X += calCloneBroProjAttackAccel; + } + else if (NPC.velocity.X > calCloneBroProjTargetX) + { + NPC.velocity.X -= calCloneBroProjAttackAccel; + if (NPC.velocity.X > 0f && calCloneBroProjTargetX < 0f) + NPC.velocity.X -= calCloneBroProjAttackAccel; + } + if (NPC.velocity.Y < calCloneBroProjTargetY) + { + NPC.velocity.Y += calCloneBroProjAttackAccel; + if (NPC.velocity.Y < 0f && calCloneBroProjTargetY > 0f) + NPC.velocity.Y += calCloneBroProjAttackAccel; + } + else if (NPC.velocity.Y > calCloneBroProjTargetY) + { + NPC.velocity.Y -= calCloneBroProjAttackAccel; + if (NPC.velocity.Y > 0f && calCloneBroProjTargetY < 0f) + NPC.velocity.Y -= calCloneBroProjAttackAccel; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= (240f - (death ? 120f * (1f - lifeRatio) : 0f))) + { + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + NPC.target = 255; + NPC.netUpdate = true; + } + + bool fireDelay = NPC.ai[2] > 120f || NPC.life < NPC.lifeMax * 0.9; + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height) && fireDelay) + { + if (NPC.localAI[2] == 0f) + SoundEngine.PlaySound(Cataclysm.FlamethrowerStart, NPC.Center); + + NPC.localAI[2] += 1f; + if (NPC.localAI[2] > 30f) + { + NPC.localAI[2] = 1f; + SoundEngine.PlaySound(Cataclysm.FlamethrowerLoop, NPC.Center); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 3f; + if (revenge) + NPC.localAI[1] += 1f; + + if (NPC.localAI[1] > 12f) + { + NPC.localAI[1] = 0f; + float calCloneBroProjSpeed = NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; + int type = ModContent.ProjectileType(); + calCloneBroProjLocation = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X; + calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; + calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); + calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; + calCloneBroProjTargetY += NPC.velocity.Y * 0.5f; + calCloneBroProjTargetX += NPC.velocity.X * 0.5f; + calCloneBroProjLocation.X -= calCloneBroProjTargetX; + calCloneBroProjLocation.Y -= calCloneBroProjTargetY; + Projectile.NewProjectile(NPC.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, FlamethrowerDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + } + else + { + if (NPC.ai[1] == 1f) + { + SoundEngine.PlaySound(SoundID.Roar, NPC.Center); + NPC.rotation = calCloneBroRotation; + + float calCloneBroChargeSpeed = 14f + (death ? 4f * (1f - lifeRatio) : 0f); + if (expertMode) + calCloneBroChargeSpeed += 2f; + if (revenge) + calCloneBroChargeSpeed += 2f; + if (Main.getGoodWorld) + calCloneBroChargeSpeed *= 1.25f; + + Vector2 calCloneBroChargeCenter = NPC.Center; + float calCloneBroChargeTargetXDist = player.Center.X - calCloneBroChargeCenter.X; + float calCloneBroChargeTargetYDist = player.Center.Y - calCloneBroChargeCenter.Y; + float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist); + calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance; + NPC.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance; + NPC.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance; + NPC.ai[1] = 2f; + + if (Main.zenithWorld) + { + SoundEngine.PlaySound(SupremeCalamitas.SupremeCalamitas.BrimstoneShotSound, NPC.Center); + + int type = ModContent.ProjectileType(); + + int totalProjectiles = death ? 10 : revenge ? 8 : expertMode ? 6 : 4; + float radians = MathHelper.TwoPi / totalProjectiles; + float velocity = 5f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + float projectileVelocityToPass = velocity * 3f; + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, CalamitasClone.DartDamage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); + } + + for (int i = 0; i < 6; i++) + Dust.NewDust(NPC.position + NPC.velocity, NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f); + } + return; + } + + if (NPC.ai[1] == 2f) + { + NPC.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); + if (expertMode) + NPC.ai[2] += 0.25f; + if (revenge) + NPC.ai[2] += 0.25f; + + if (NPC.ai[2] >= 75f) + { + NPC.velocity.X *= 0.93f; + NPC.velocity.Y *= 0.93f; + + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; + } + else + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) - MathHelper.PiOver2; + + if (NPC.ai[2] >= 105f) + { + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; + NPC.target = 255; + NPC.rotation = calCloneBroRotation; + if (NPC.ai[3] >= 3f) + { + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + return; + } + NPC.ai[1] = 1f; + } + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -237,7 +541,7 @@ namespace CalamityMod.NPCs.CalClone public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/NPCs/CalClone/Catastrophe.cs b/NPCs/CalClone/Catastrophe.cs index ee72d7ea16..a4695e2630 100644 --- a/NPCs/CalClone/Catastrophe.cs +++ b/NPCs/CalClone/Catastrophe.cs @@ -4,12 +4,14 @@ using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; +using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; +using System; using Terraria; +using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; @@ -41,11 +43,13 @@ namespace CalamityMod.NPCs.CalClone } } + public static int BallDamage = 22; // 88 + public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 54; // 108 NPC.npcSlots = 5f; NPC.width = 120; NPC.height = 120; @@ -53,9 +57,8 @@ namespace CalamityMod.NPCs.CalClone if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; - NPC.defense = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 15 : 10; - NPC.DR_NERD((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.225f : 0.15f); - NPC.LifeMaxNERB(9200, 11025, 80000); + NPC.defense = 10; + NPC.LifeMaxNERB(7000, 10000, 80000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -103,7 +106,304 @@ namespace CalamityMod.NPCs.CalClone public override void AI() { - CalamitasCloneAI.VanillaCatastropheAI(NPC, Mod); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active) + { + if (NPC.alpha < 255) + { + NPC.velocity *= 0.9f; + + NPC.alpha += 2; + if (NPC.alpha > 255) + NPC.alpha = 255; + + int dustAmount = (int)Math.Round(MathHelper.Lerp(1f, 5f, (255 - NPC.alpha) / 255f)); + for (int i = 0; i < dustAmount; i++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LifeDrain, 0f, -1f, 90, default, Main.rand.NextFloat(0.5f, 2f)); + Main.dust[dust].noGravity = true; + Main.dust[dust].fadeIn = 1f; + } + } + else + NPC.active = false; + + return; + } + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + CalamityGlobalNPC.catastrophe = NPC.whoAmI; + + // Emit light + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1f, 0f, 0f); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + Player player = Main.player[NPC.target]; + + float calCloneBroPlayerXDist = NPC.position.X + (NPC.width / 2) - player.position.X - (player.width / 2); + float calCloneBroPlayerYDist = NPC.position.Y + NPC.height - 59f - player.position.Y - (player.height / 2); + float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2; + if (calCloneBroRotation < 0f) + calCloneBroRotation += MathHelper.TwoPi; + else if (calCloneBroRotation > MathHelper.TwoPi) + calCloneBroRotation -= MathHelper.TwoPi; + + float calCloneBroRotationSpeed = 0.15f; + if (NPC.rotation < calCloneBroRotation) + { + if ((calCloneBroRotation - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= calCloneBroRotationSpeed; + else + NPC.rotation += calCloneBroRotationSpeed; + } + else if (NPC.rotation > calCloneBroRotation) + { + if ((NPC.rotation - calCloneBroRotation) > MathHelper.Pi) + NPC.rotation += calCloneBroRotationSpeed; + else + NPC.rotation -= calCloneBroRotationSpeed; + } + + if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + NPC.rotation = calCloneBroRotation; + if (NPC.rotation < 0f) + NPC.rotation += MathHelper.TwoPi; + else if (NPC.rotation > MathHelper.TwoPi) + NPC.rotation -= MathHelper.TwoPi; + if (NPC.rotation > calCloneBroRotation - calCloneBroRotationSpeed && NPC.rotation < calCloneBroRotation + calCloneBroRotationSpeed) + NPC.rotation = calCloneBroRotation; + + if (!player.active || player.dead) + { + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + if (!player.active || player.dead) + { + if (NPC.velocity.Y > 3f) + NPC.velocity.Y = 3f; + NPC.velocity.Y -= 0.1f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + + if (NPC.ai[1] != 0f) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + return; + } + } + + if (NPC.ai[1] == 0f) + { + float calCloneBroProjAttackMaxSpeed = 4.5f; + float calCloneBroProjAttackAccel = 0.2f; + + if (Main.getGoodWorld) + { + calCloneBroProjAttackMaxSpeed *= 1.15f; + calCloneBroProjAttackAccel *= 1.15f; + } + + int calCloneBroProjAttackDirection = 1; + if (NPC.Center.X < player.Center.X) + calCloneBroProjAttackDirection = -1; + + Vector2 calCloneBroProjLocation = NPC.Center; + float calCloneBroProjTargetX = player.Center.X + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X; + float calCloneBroProjTargetY = player.Center.Y - calCloneBroProjLocation.Y; + float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); + + if (expertMode) + { + if (calCloneBroProjTargetDist > 300f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 400f) + calCloneBroProjAttackMaxSpeed += 0.5f; + if (calCloneBroProjTargetDist > 500f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 600f) + calCloneBroProjAttackMaxSpeed += 0.55f; + if (calCloneBroProjTargetDist > 700f) + calCloneBroProjAttackMaxSpeed += 0.6f; + if (calCloneBroProjTargetDist > 800f) + calCloneBroProjAttackMaxSpeed += 0.6f; + } + + calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; + + if (NPC.velocity.X < calCloneBroProjTargetX) + { + NPC.velocity.X += calCloneBroProjAttackAccel; + if (NPC.velocity.X < 0f && calCloneBroProjTargetX > 0f) + NPC.velocity.X += calCloneBroProjAttackAccel; + } + else if (NPC.velocity.X > calCloneBroProjTargetX) + { + NPC.velocity.X -= calCloneBroProjAttackAccel; + if (NPC.velocity.X > 0f && calCloneBroProjTargetX < 0f) + NPC.velocity.X -= calCloneBroProjAttackAccel; + } + if (NPC.velocity.Y < calCloneBroProjTargetY) + { + NPC.velocity.Y += calCloneBroProjAttackAccel; + if (NPC.velocity.Y < 0f && calCloneBroProjTargetY > 0f) + NPC.velocity.Y += calCloneBroProjAttackAccel; + } + else if (NPC.velocity.Y > calCloneBroProjTargetY) + { + NPC.velocity.Y -= calCloneBroProjAttackAccel; + if (NPC.velocity.Y > 0f && calCloneBroProjTargetY < 0f) + NPC.velocity.Y -= calCloneBroProjAttackAccel; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= (180f - (death ? 90f * (1f - lifeRatio) : 0f))) + { + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + NPC.target = 255; + NPC.netUpdate = true; + } + + bool fireDelay = NPC.ai[2] > 120f || lifeRatio < 0.9f; + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height) && fireDelay) + { + NPC.localAI[2] += 1f; + if (NPC.localAI[2] > 36f) + { + NPC.localAI[2] = 0f; + SoundEngine.PlaySound(SoundID.Item34, NPC.Center); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 1f; + if (revenge) + NPC.localAI[1] += 0.5f; + + if (NPC.localAI[1] > 50f) + { + NPC.localAI[1] = 0f; + float calCloneBroProjSpeed = death ? 14f : 12f; + int type = ModContent.ProjectileType(); + calCloneBroProjLocation = NPC.Center + new Vector2(112,0).RotatedBy(NPC.rotation + MathHelper.PiOver2); + calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X; + calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; + calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); + calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist; + calCloneBroProjTargetX *= calCloneBroProjTargetDist; + calCloneBroProjTargetY *= calCloneBroProjTargetDist; + calCloneBroProjTargetY += NPC.velocity.Y * 0.5f; + calCloneBroProjTargetX += NPC.velocity.X * 0.5f; + calCloneBroProjLocation.X -= calCloneBroProjTargetX; + calCloneBroProjLocation.Y -= calCloneBroProjTargetY; + Projectile.NewProjectile(NPC.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, BallDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + } + else + { + if (NPC.ai[1] == 1f) + { + SoundEngine.PlaySound(SoundID.Roar, NPC.Center); + NPC.rotation = calCloneBroRotation; + + float calCloneBroChargeSpeed = (NPC.AnyNPCs(ModContent.NPCType()) ? 12f : 16f) + (death ? 4f * (1f - lifeRatio) : 0f); + if (expertMode) + calCloneBroChargeSpeed += 2f; + if (revenge) + calCloneBroChargeSpeed += 2f; + if (Main.getGoodWorld) + calCloneBroChargeSpeed *= 1.25f; + + Vector2 calCloneBroChargeCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float calCloneBroChargeTargetXDist = player.position.X + (player.width / 2) - calCloneBroChargeCenter.X; + float calCloneBroChargeTargetYDist = player.position.Y + (player.height / 2) - calCloneBroChargeCenter.Y; + float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist); + calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance; + NPC.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance; + NPC.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance; + NPC.ai[1] = 2f; + + if (Main.zenithWorld) + { + SoundEngine.PlaySound(SupremeCalamitas.SupremeCalamitas.BrimstoneShotSound, NPC.Center); + + int type = ModContent.ProjectileType(); + + int totalProjectiles = death ? 10 : revenge ? 8 : expertMode ? 6 : 4; + float radians = MathHelper.TwoPi / totalProjectiles; + float velocity = 5f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + float projectileVelocityToPass = velocity * 3f; + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, CalamitasClone.DartDamage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); + } + + for (int i = 0; i < 6; i++) + Dust.NewDust(NPC.position + NPC.velocity, NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f); + } + return; + } + + if (NPC.ai[1] == 2f) + { + NPC.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); + if (expertMode) + NPC.ai[2] += 0.25f; + if (revenge) + NPC.ai[2] += 0.25f; + + if (NPC.ai[2] >= 60f) //50 + { + NPC.velocity.X *= 0.93f; + NPC.velocity.Y *= 0.93f; + + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; + } + else + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) - MathHelper.PiOver2; + + if (NPC.ai[2] >= 90f) //80 + { + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; + NPC.rotation = calCloneBroRotation; + if (NPC.ai[3] >= 4f) + { + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + return; + } + NPC.ai[1] = 1f; + } + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -231,7 +531,7 @@ namespace CalamityMod.NPCs.CalClone public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/NPCs/CalClone/SoulSeeker.cs b/NPCs/CalClone/SoulSeeker.cs index d6a78285ce..c224c25225 100644 --- a/NPCs/CalClone/SoulSeeker.cs +++ b/NPCs/CalClone/SoulSeeker.cs @@ -40,9 +40,8 @@ namespace CalamityMod.NPCs.CalClone NPC.height = 40; NPC.noGravity = true; NPC.noTileCollide = true; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.defense = 10; - NPC.DR_NERD(0.1f); NPC.lifeMax = CalamityWorld.death ? 1500 : 2500; if (BossRushEvent.BossRushActive) { @@ -53,10 +52,6 @@ namespace CalamityMod.NPCs.CalClone NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -118,9 +113,8 @@ namespace CalamityMod.NPCs.CalClone for (int d = 0; d < 3; d++) Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 1f, parent.target, 1f, 0f, projectileSpeed * 2f); + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, CalamitasClone.DartDamage, 1f, parent.target, 1f, 0f, projectileSpeed * 2f); } timer = 0; } diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs deleted file mode 100644 index b4b7b4b27b..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs +++ /dev/null @@ -1,629 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class AquaticScourgeAI - { - public static void VanillaAquaticScourgeAI(NPC npc, Mod mod, bool head) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - bool getFuckedAI = Main.zenithWorld; - - if (head) - CalamityGlobalNPC.aquaticScourge = npc.whoAmI; - - // Adjust hostility and stats - bool nonHostile = calamityGlobalNPC.newAI[0] == 0f; - if (npc.justHit || npc.life <= npc.lifeMax * 0.999 || bossRush || Main.getGoodWorld) - { - if (nonHostile) - { - // Kiss my motherfucking ass you piece of shit game - npc.timeLeft *= 20; - npc.npcSlots = 16f; - CalamityGlobalNPC.BossKillTimes.TryGetValue(npc.type, out int revKillTime); - calamityGlobalNPC.KillTime = revKillTime; - calamityGlobalNPC.newAI[0] = 1f; - nonHostile = false; - npc.boss = head; - npc.chaseable = true; - npc.netUpdate = true; - } - } - else - npc.damage = 0; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < 0.75f; - bool phase3 = lifeRatio < 0.5f; - bool phase4 = lifeRatio < 0.25f; - - // Set worm variable - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - if (!head) - { - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - bool notOcean = player.position.Y < 300f || - player.position.Y > Main.worldSurface * 16.0 || - (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); - - // Check for the flipped Abyss - if (Main.remixWorld) - { - notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer || - (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); - } - - // Enrage - if (head) - { - if (notOcean && !player.Calamity().ZoneSulphur && !bossRush) - { - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - } - else - npc.localAI[2] = CalamityGlobalNPC.biomeEnrageTimerMax; - } - - bool biomeEnraged = npc.localAI[2] <= 0f || bossRush; - - float enrageScale = bossRush ? 1f : 0f; - if (biomeEnraged) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } - - // Circular movement - float colorFadeTimeAfterSpiral = 90f; - float spiralGateValue = 480f; - bool doSpiral = false; - if (head && calamityGlobalNPC.newAI[0] == 1f && calamityGlobalNPC.newAI[2] == 1f && (revenge || getFuckedAI)) - { - doSpiral = calamityGlobalNPC.newAI[1] == 0f && calamityGlobalNPC.newAI[3] >= spiralGateValue; - if (Vector2.Distance(npc.Center, player.Center) < (getFuckedAI ? 1600f : 1000f) || doSpiral) - calamityGlobalNPC.newAI[3] += 1f; - - if (doSpiral) - { - npc.localAI[3] = colorFadeTimeAfterSpiral; - - // Vomit acid mist - float acidMistBarfDivisor = getFuckedAI ? 2f : ((float)Math.Floor(bossRush ? 4f : death ? 5f : 6f) * (phase3 ? 1.5f : 1f)); - if (calamityGlobalNPC.newAI[3] % acidMistBarfDivisor == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float mistVelocity = death ? 10f : 8f; - Vector2 projectileVelocity = (npc.Center + npc.velocity * 10f - npc.Center).SafeNormalize(Vector2.UnitY); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity * 5f, projectileVelocity * mistVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].timeLeft = getFuckedAI ? 240 : 600; - } - } - - // Vomit circular spreads of acid clouds while in phase 3 - float toxicCloudBarfDivisor = bossRush ? 20f : death ? 30f : 40f; - if (calamityGlobalNPC.newAI[3] % toxicCloudBarfDivisor == 0f && phase3) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalProjectiles = (phase4 ? 6 : 9) + (getFuckedAI ? Main.rand.Next(-2, 3) : (int)((calamityGlobalNPC.newAI[3] - spiralGateValue) / toxicCloudBarfDivisor) * (phase4 ? 2 : 3)); - float radians = MathHelper.TwoPi / totalProjectiles; - float cloudVelocity = 1f + enrageScale; - Vector2 spinningPoint = new Vector2(0f, -cloudVelocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer); - } - } - } - - // Velocity boost - if (calamityGlobalNPC.newAI[3] == spiralGateValue) - { - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); - npc.velocity *= 24f; - } - - // Spin velocity - float velocity = (float)(Math.PI * 2D) / 120f; - // In GFB, contracts the radius as the fight progresses - if (getFuckedAI) - velocity *= phase3 ? 1.5f : phase2 ? 1.25f : 1f; - npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.localAI[1]); - // Speed up even more in GFB for more radius - if (getFuckedAI && npc.velocity.Length() <= 32f) - npc.velocity *= 1.1f; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - // Reset and charge at target - // Don't reset in GFB - if (!getFuckedAI && calamityGlobalNPC.newAI[3] >= spiralGateValue + 120f) - { - calamityGlobalNPC.newAI[3] = 0f; - npc.TargetClosest(); - } - } - else - { - if (!Collision.CanHit(npc.Center, 1, 1, player.position, player.width, player.height) && calamityGlobalNPC.newAI[3] > 300f) - calamityGlobalNPC.newAI[3] -= 2f; - - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - - npc.localAI[1] = npc.Center.X - player.Center.X < 0 ? 1f : -1f; - } - } - - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = doSpiral || getFuckedAI; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - - if (head) - { - // Spawn segments - if (calamityGlobalNPC.newAI[2] == 0f && npc.ai[0] == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxLength = getFuckedAI ? 24 : death ? 80 : revenge ? 40 : expertMode ? 35 : 30; - int Previous = npc.whoAmI; - for (int segments = 0; segments < maxLength; segments++) - { - int lol; - if (segments >= 0 && segments < maxLength - 1) - { - if (segments % 2 == 0) - lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); - else - lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); - } - else - lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType(), npc.whoAmI); - - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol); - Previous = lol; - } - } - - calamityGlobalNPC.newAI[2] = 1f; - } - - // Big barf attack - if (calamityGlobalNPC.newAI[0] == 1f && (!doSpiral && phase2) || (getFuckedAI && !phase3)) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= (revenge ? 360f : 420f)) - { - if (Vector2.Distance(player.Center, npc.Center) > 320f) - { - npc.localAI[0] = 0f; - npc.netUpdate = true; - SoundEngine.PlaySound(SoundID.NPCDeath13, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalProjectiles = bossRush ? 10 : expertMode ? 8 : 6; - if (phase3) - totalProjectiles *= 2; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 velocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - velocity = velocity.SafeNormalize(Vector2.UnitY); - velocity *= Main.rand.Next(phase3 ? 300 : 100, 401) * 0.01f; - - float maximumVelocityMult = death ? 0.75f : 0.5f; - if (expertMode) - velocity *= 1f + (maximumVelocityMult * (0.5f - lifeRatio)); - - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + velocity.SafeNormalize(Vector2.UnitY) * 5f, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - } - } - - // Fire teeth depending on body type - else - { - if (calamityGlobalNPC.newAI[0] == 1f && (!phase3 || phase4)) - { - npc.localAI[0] += 1f; - float shootProjectile = 300; - float timer = npc.ai[0] + 15f; - float divisor = timer + shootProjectile; - - if (npc.type == ModContent.NPCType()) - { - if (npc.localAI[0] % divisor == 0f && (npc.ai[0] % 3f == 0f || getFuckedAI || !death)) - { - npc.TargetClosest(); - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - SoundEngine.PlaySound(SoundID.Item17, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float toothVelocity = death ? 9f : 8f; - Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float accelerate = phase4 ? 1f : 0f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity * 5f, projectileVelocity * toothVelocity, type, damage, 0f, Main.myPlayer, accelerate, 0f); - } - - npc.netUpdate = true; - } - } - } - } - } - - // Kill body and tail - if (!head) - { - 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; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - } - else - { - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; - } - - float maxDistance = calamityGlobalNPC.newAI[0] == 1f ? 12800f : 6400f; - if (player.dead || Vector2.Distance(npc.Center, player.Center) > maxDistance || (nonHostile && biomeEnraged)) - { - calamityGlobalNPC.newAI[1] = 1f; - npc.TargetClosest(false); - npc.velocity.Y += 2f; - - if (npc.position.Y > Main.worldSurface * 16D) - npc.velocity.Y += 2f; - - if (npc.position.Y > Main.worldSurface * 16D) - { - for (int a = 0; a < Main.npc.Length; a++) - { - int type = Main.npc[a].type; - if (type == ModContent.NPCType() || type == ModContent.NPCType() || type == ModContent.NPCType() || type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - } - else - calamityGlobalNPC.newAI[1] = 0f; - - // Change direction - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - // Alpha changes - if (head || Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - Vector2 scourgePosition = npc.Center; - Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[npc.target].velocity * 20f : Vector2.Zero; - float scourgeTargetX = player.Center.X + predictionVector.X; - float scourgeTargetY = player.Center.Y + predictionVector.Y; - - // Velocity and movement - float scourgeMaxSpeed = 5f; - float scourgeAcceleration = 0.08f; - if (calamityGlobalNPC.newAI[0] == 1f) - { - scourgeMaxSpeed = revenge ? 14.4f : 12f; - scourgeAcceleration = revenge ? 0.18f : 0.15f; - if (expertMode) - { - scourgeMaxSpeed += 2.4f * (1f - lifeRatio); - scourgeAcceleration += 0.03f * (1f - lifeRatio); - } - scourgeMaxSpeed += 3f * enrageScale; - scourgeAcceleration += 0.06f * enrageScale; - if (death || getFuckedAI) - { - scourgeMaxSpeed += 5f; - scourgeAcceleration -= getFuckedAI ? 0f : 0.03f; - scourgeMaxSpeed += Vector2.Distance(player.Center, npc.Center) * 0.001f; - scourgeAcceleration += Vector2.Distance(player.Center, npc.Center) * 0.000045f; - } - - // Increase acceleration after spiral attack - if (npc.localAI[3] > 0f) - { - float accelerationMultiplier = MathHelper.Lerp(1f, 2f, npc.localAI[3] / colorFadeTimeAfterSpiral); - scourgeAcceleration *= accelerationMultiplier; - } - - if (Main.getGoodWorld) - { - scourgeMaxSpeed *= 1.15f; - scourgeAcceleration *= 1.15f; - } - } - - if (head && !doSpiral) - { - if (calamityGlobalNPC.newAI[0] != 1f) - { - scourgeTargetY += 400; - if (Math.Abs(npc.Center.X - player.Center.X) < 500f) - { - if (npc.velocity.X > 0f) - scourgeTargetX = player.Center.X + 600f; - else - scourgeTargetX = player.Center.X - 600f; - } - } - - float scourgeHigherSpeed = scourgeMaxSpeed * 1.3f; - float scourgeLowerSpeed = scourgeMaxSpeed * 0.7f; - float scourgeSpeed = npc.velocity.Length(); - if (scourgeSpeed > 0f) - { - if (scourgeSpeed > scourgeHigherSpeed) - { - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); - npc.velocity *= scourgeHigherSpeed; - } - else if (scourgeSpeed < scourgeLowerSpeed) - { - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); - npc.velocity *= scourgeLowerSpeed; - } - } - } - - scourgeTargetX = (int)(scourgeTargetX / 16f) * 16; - scourgeTargetY = (int)(scourgeTargetY / 16f) * 16; - scourgePosition.X = (int)(scourgePosition.X / 16f) * 16; - scourgePosition.Y = (int)(scourgePosition.Y / 16f) * 16; - scourgeTargetX -= scourgePosition.X; - scourgeTargetY -= scourgePosition.Y; - float scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); - - if (!head) - { - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - scourgePosition = npc.Center; - scourgeTargetX = Main.npc[(int)npc.ai[1]].Center.X - scourgePosition.X; - scourgeTargetY = Main.npc[(int)npc.ai[1]].Center.Y - scourgePosition.Y; - } - catch - { - } - - npc.rotation = (float)Math.Atan2(scourgeTargetY, scourgeTargetX) + MathHelper.PiOver2; - scourgeTargetDist = (float)Math.Sqrt(scourgeTargetX * scourgeTargetX + scourgeTargetY * scourgeTargetY); - int scourgeWidth = npc.width; - scourgeTargetDist = (scourgeTargetDist - scourgeWidth) / scourgeTargetDist; - scourgeTargetX *= scourgeTargetDist; - scourgeTargetY *= scourgeTargetDist; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + scourgeTargetX; - npc.position.Y = npc.position.Y + scourgeTargetY; - - if (scourgeTargetX < 0f) - npc.spriteDirection = -1; - else if (scourgeTargetX > 0f) - npc.spriteDirection = 1; - } - } - else if (!doSpiral) - { - float scourgeAbsoluteTargetX = Math.Abs(scourgeTargetX); - float scourgeAbsoluteTargetY = Math.Abs(scourgeTargetY); - float scourgeTimeToReachTarget = scourgeMaxSpeed / scourgeTargetDist; - scourgeTargetX *= scourgeTimeToReachTarget; - scourgeTargetY *= scourgeTimeToReachTarget; - - if ((npc.velocity.X > 0f && scourgeTargetX > 0f) || (npc.velocity.X < 0f && scourgeTargetX < 0f) || (npc.velocity.Y > 0f && scourgeTargetY > 0f) || (npc.velocity.Y < 0f && scourgeTargetY < 0f)) - { - if (npc.velocity.X < scourgeTargetX) - { - npc.velocity.X += scourgeAcceleration; - } - else - { - if (npc.velocity.X > scourgeTargetX) - npc.velocity.X -= scourgeAcceleration; - } - - if (npc.velocity.Y < scourgeTargetY) - { - npc.velocity.Y += scourgeAcceleration; - } - else - { - if (npc.velocity.Y > scourgeTargetY) - npc.velocity.Y -= scourgeAcceleration; - } - - if (Math.Abs(scourgeTargetY) < scourgeMaxSpeed * 0.2 && ((npc.velocity.X > 0f && scourgeTargetX < 0f) || (npc.velocity.X < 0f && scourgeTargetX > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += scourgeAcceleration * 2f; - else - npc.velocity.Y -= scourgeAcceleration * 2f; - } - - if (Math.Abs(scourgeTargetX) < scourgeMaxSpeed * 0.2 && ((npc.velocity.Y > 0f && scourgeTargetY < 0f) || (npc.velocity.Y < 0f && scourgeTargetY > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += scourgeAcceleration * 2f; - else - npc.velocity.X -= scourgeAcceleration * 2f; - } - } - else - { - if (scourgeAbsoluteTargetX > scourgeAbsoluteTargetY) - { - if (npc.velocity.X < scourgeTargetX) - npc.velocity.X += scourgeAcceleration * 1.1f; - else if (npc.velocity.X > scourgeTargetX) - npc.velocity.X -= scourgeAcceleration * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < scourgeMaxSpeed * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += scourgeAcceleration; - else - npc.velocity.Y -= scourgeAcceleration; - } - } - else - { - if (npc.velocity.Y < scourgeTargetY) - npc.velocity.Y += scourgeAcceleration * 1.1f; - else if (npc.velocity.Y > scourgeTargetY) - npc.velocity.Y -= scourgeAcceleration * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < scourgeMaxSpeed * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += scourgeAcceleration; - else - npc.velocity.X -= scourgeAcceleration; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - } - - // Calculate contact damage based on velocity - if (!nonHostile) - { - float minimalContactDamageVelocity = scourgeMaxSpeed * 0.25f; - float minimalDamageVelocity = scourgeMaxSpeed * 0.5f; - if (head) - { - if (npc.velocity.Length() <= minimalContactDamageVelocity) - { - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar); - } - } - else - { - float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - npc.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar); - } - } - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AstrumAureusAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AstrumAureusAI.cs deleted file mode 100644 index 6762f39117..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/AstrumAureusAI.cs +++ /dev/null @@ -1,974 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class AstrumAureusAI - { - public static void VanillaAstrumAureusAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.astrumAureus = npc.whoAmI; - - // Variables - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < (revenge ? 0.85f : expertMode ? 0.8f : 0.75f); - bool phase3 = lifeRatio < (revenge ? 0.7f : expertMode ? 0.6f : 0.5f); - bool phase4 = lifeRatio < (revenge ? 0.5f : 0.4f) && expertMode; - bool phase5 = lifeRatio < 0.3f && revenge; - - // Exhaustion - bool exhausted = npc.ai[2] >= (phase3 ? 2f : 1f); - calamityGlobalNPC.DR = exhausted ? 0.2f : 0.4f; - npc.defense = exhausted ? npc.defDefense / 2 : npc.defDefense; - - // 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(); - - Player player = Main.player[npc.target]; - - // Don't fire projectiles and don't increment phase timers for 4 seconds after the teleport phase to avoid cheap bullshit - float noProjectileOrPhaseIncrementTime = 240f; - - bool dontAttack = npc.localAI[3] > 0f; - if (dontAttack) - { - npc.localAI[3] -= 1f; - if (npc.justHit && masterMode) - npc.localAI[3] -= 3f; - if (npc.Distance(player.Center) < 240f) - npc.localAI[3] -= masterMode ? 4f : expertMode ? 2f : 1f; - } - - float enrageScale = bossRush ? 1f : 0f; - if ((Main.IsItDay() && !player.Calamity().ZoneAstral) || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - - float astralFlameBarrageTimerIncrement = 1f; - if (expertMode) - astralFlameBarrageTimerIncrement += death ? (float)Math.Round(3f * (1f - lifeRatio)) : (float)Math.Round(2f * (1f - lifeRatio)); - - float walkingVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 6f : 5f; - walkingVelocity += 3f * enrageScale; - if (phase5) - walkingVelocity += 2f; - if (expertMode) - walkingVelocity += 1.5f * (1f - lifeRatio); - if (revenge) - walkingVelocity += Math.Abs(npc.Center.X - player.Center.X) * 0.0025f; - if (Main.getGoodWorld) - walkingVelocity *= 1.15f; - - float walkingProjectileVelocity = walkingVelocity * 0.8f; - - // Direction - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - - // Used to reduce Aureus' fall speed - bool reduceFallSpeed = npc.velocity.Y > 0f && Collision.SolidCollision(npc.position + Vector2.UnitY * 1.1f * npc.velocity.Y, npc.width, npc.height) && npc.ai[0] == 4f; - - // Despawn - bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - if (!player.active || player.dead || despawnDistance) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || despawnDistance) - { - npc.noTileCollide = true; - - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 12f) - npc.velocity.Y = 12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[2] = 0f; - npc.localAI[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - npc.netUpdate = true; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - bool geldonPhase1 = lifeRatio > 0.6f && lifeRatio <= 0.7f; - bool geldonPhase2 = lifeRatio <= 0.1f; - if (Main.zenithWorld && (geldonPhase1 || geldonPhase2)) - { - AstrumAureus.AstrumAureus astrumAureus = npc.ModNPC(); - astrumAureus.slimeProjCounter++; - if (astrumAureus.slimeProjCounter % 180 == 0) - { - SoundEngine.PlaySound(SoundID.Item33, npc.Center); // Intentionally keeping the old laser sound in GFB - - if (astrumAureus.slimePhase == 1) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalProjectiles = bossRush ? 14 : death ? 12 : revenge ? 10 : expertMode ? 8 : 6; - float radians = MathHelper.TwoPi / totalProjectiles; - float velocity = 10f; - Vector2 spinningPoint = new Vector2(0f, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f); - } - } - astrumAureus.slimePhase = 0; - } - else - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float aureusLaserSpeed = 7f; - float aureusLaserTargetX = player.Center.X - npc.Center.X; - float aureusLaserTargetY = player.Center.Y - npc.Center.Y; - float aureusLaserTargetDist = (float)Math.Sqrt(aureusLaserTargetX * aureusLaserTargetX + aureusLaserTargetY * aureusLaserTargetY); - aureusLaserTargetDist = aureusLaserSpeed / aureusLaserTargetDist; - aureusLaserTargetX *= aureusLaserTargetDist; - aureusLaserTargetY *= aureusLaserTargetDist; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, aureusLaserTargetX, aureusLaserTargetY, type, damage, 0f, Main.myPlayer); - for (int i = 0; i < 4; i++) - { - Vector2 offset = new Vector2(Main.rand.Next(-6, 7), Main.rand.Next(-6, 7)); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, aureusLaserTargetX + offset.X, aureusLaserTargetY + offset.Y, type, damage, 0f, Main.myPlayer); - } - } - astrumAureus.slimePhase = 1; - } - } - RevengeanceAndDeathAI.BuffedMimicAI(npc, mod); - npc.noGravity = false; - npc.noTileCollide = false; - return; - } - else - { - npc.noGravity = true; - } - - // Emit light when not Idle - if (npc.ai[0] != 1f) - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1.3f, 0.5f, 0f); - - // Fire projectiles while walking, teleporting, or falling - if (npc.ai[0] == 2f || npc.ai[0] >= 5f) - { - if (!dontAttack) - npc.localAI[0] += npc.ai[0] == 2f ? 1f : astralFlameBarrageTimerIncrement; - - float astralFlameBarrageGateValue = phase4 ? 30f : 60f; - if (npc.localAI[0] >= astralFlameBarrageGateValue) - { - // Fire astral flames while teleporting - if (npc.ai[0] >= 5f && npc.ai[0] != 7) - { - npc.localAI[0] = 0f; - SoundEngine.PlaySound(AstrumAureus.AstrumAureus.FlameCrystalSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float velocity = death ? (8f + npc.localAI[2] * 0.025f) : 7f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float spreadLimit = (phase4 ? 100f : 50f) + enrageScale * 50f; - float randomSpread = (Main.rand.NextFloat() - 0.5f) * spreadLimit; - Vector2 spawnVector = new Vector2(npc.Center.X, npc.Center.Y - 80f * npc.scale); - Vector2 destination = new Vector2(spawnVector.X + randomSpread, spawnVector.Y - 100f * npc.scale); - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, Vector2.Normalize(destination - spawnVector) * velocity, type, damage, 0f, Main.myPlayer); - } - } - } - - float laserBarrageGateValue = phase5 ? 160f : phase3 ? 120f : phase2 ? 80f : 60f; - if (npc.localAI[0] >= laserBarrageGateValue) - { - // Fire astral lasers while walking - if (npc.ai[0] == 2f) - { - npc.localAI[0] = 0f; - - SoundEngine.PlaySound(AstrumAureus.AstrumAureus.LaserSound, npc.Center); - - if (calamityGlobalNPC.newAI[2] == 0f) - { - calamityGlobalNPC.newAI[2] = 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxProjectiles = !phase2 ? (bossRush ? 5 : 3) : (bossRush ? 7 : 5); - int spread = !phase2 ? (bossRush ? 11 : 8) : (bossRush ? 12 : 10); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * walkingProjectileVelocity; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < maxProjectiles; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f); - } - - if (phase3) - { - float flameVelocity = walkingProjectileVelocity; - maxProjectiles = 2; - spread = 45; - - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * flameVelocity; - rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < maxProjectiles; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } - } - } - } - else - { - calamityGlobalNPC.newAI[2] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 19 : death ? 17 : 15); - int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int centralLaser = maxProjectiles / 2; - int[] lasersToNotFire = new int[6] { centralLaser - 3, centralLaser - 2, centralLaser - 1, centralLaser + 1, centralLaser + 2, centralLaser + 3 }; - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * walkingProjectileVelocity; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < maxProjectiles; i++) - { - if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3] && i != lasersToNotFire[4] && i != lasersToNotFire[5]) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, walkingProjectileVelocity * 2f); - } - } - } - } - } - } - } - else - npc.localAI[0] = 0f; - - // Start up - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[0] = 1f; - npc.netUpdate = true; - CustomGravity(); - } - - // Idle - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Slow down - npc.velocity.X *= 0.8f; - - // Stay vulnerable for 3 seconds - npc.ai[1] += 1f; - if (npc.justHit && masterMode) - npc.ai[1] += 3f; - if (npc.Distance(player.Center) < 240f) - npc.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; - - if (npc.ai[1] >= 180f || bossRush) - { - // Set AI to random state and reset other AI arrays - npc.TargetClosest(); - switch (Main.rand.Next(phase3 ? 3 : 2)) - { - case 0: - npc.ai[0] = 2f; - break; - - case 1: - npc.ai[0] = 3f; - break; - - case 2: - npc.ai[0] = 5f; - break; - - default: - break; - } - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - // Stop colliding with tiles if entering walking phase - npc.noTileCollide = npc.ai[0] == 2f; - - npc.netUpdate = true; - } - else - CustomGravity(); - } - - // Walk - else if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Set walking direction - if (Math.Abs(npc.Center.X - player.Center.X) < 200f * npc.scale) - { - npc.velocity.X *= 0.8f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - } - else - { - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - - if (npc.direction > 0) - npc.velocity.X = (npc.velocity.X * 20f + walkingVelocity) / 21f; - if (npc.direction < 0) - npc.velocity.X = (npc.velocity.X * 20f - walkingVelocity) / 21f; - } - - if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height && !npc.collideX) - { - CustomGravity(); - npc.noTileCollide = false; - } - else - { - npc.noTileCollide = true; - - // Walk through tiles if colliding with tiles and player is out of reach - int aureusHitboxWidth = 80; - int aureusHitboxHeight = 20; - Vector2 aureusHitboxTileCollideSize = new Vector2(npc.Center.X - (aureusHitboxWidth / 2), npc.position.Y + npc.height - aureusHitboxHeight); - - bool nearPlayerWalkingThroughTiles = false; - if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f) - nearPlayerWalkingThroughTiles = true; - - if (nearPlayerWalkingThroughTiles) - { - npc.velocity.Y += 0.5f; - } - else if (Collision.SolidCollision(aureusHitboxTileCollideSize, aureusHitboxWidth, aureusHitboxHeight)) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = 0f; - - if (npc.velocity.Y > -0.2) - npc.velocity.Y -= 0.025f; - else - npc.velocity.Y -= 0.2f; - - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - } - else - { - if (npc.velocity.Y < 0f) - npc.velocity.Y = 0f; - - if (npc.velocity.Y < 0.1) - npc.velocity.Y += 0.025f; - else - npc.velocity.Y += 0.5f; - } - } - - // Walk for a maximum of 6 seconds - if (!dontAttack) - { - npc.ai[1] += 1f; - if (npc.Distance(player.Center) < 240f) - npc.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; - } - - if (npc.ai[1] >= ((bossRush ? 270f : 360f) - (death ? 90f * (1f - lifeRatio) : 0f))) - { - // Collide with tiles again - npc.noTileCollide = false; - - // Set AI to next phase (Jump) and reset other AI - npc.TargetClosest(); - npc.ai[0] = exhausted ? 1f : 3f; - npc.ai[1] = 0f; - npc.ai[2] += 1f; - npc.netUpdate = true; - } - - // Limit downward velocity - if (npc.velocity.Y > 10f) - npc.velocity.Y = 10f; - } - - // Jump - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.noTileCollide = false; - - if (npc.velocity.Y == 0f) - { - // Slow down - npc.velocity.X *= 0.8f; - - // Half second delay before jumping - if (!dontAttack) - npc.ai[1] += 1f; - - if (npc.ai[1] >= 30f) - { - npc.ai[1] = -20f; - } - else if (npc.ai[1] == -1f) - { - // Set damage - npc.damage = npc.defDamage; - - // Set jump velocity, reset and set AI to next phase (Stomp) - float distanceFromPlayerOnXAxis = npc.Center.X - player.Center.X; - npc.direction = distanceFromPlayerOnXAxis < 0 ? 1 : -1; - calamityGlobalNPC.newAI[3] = npc.direction; - - // The limit for how much Aureus can multiply its jump velocity - float speedMultLimit = 1f; - - // Maxes out when the player is a full 2000 pixels away from or above Aureus - float multiplier = 1f / 2000f; - - // Increase Aureus jump velocity X if it's far enough away from the player - float distanceAwayFromTarget = Math.Abs(distanceFromPlayerOnXAxis); - float distanceGateValue = 400f; - bool increaseJumpVelocityX = distanceAwayFromTarget > distanceGateValue && expertMode; - if (increaseJumpVelocityX) - { - calamityGlobalNPC.newAI[0] = (distanceAwayFromTarget - distanceGateValue) * multiplier; - if (calamityGlobalNPC.newAI[0] > speedMultLimit) - calamityGlobalNPC.newAI[0] = speedMultLimit; - } - - // Increase Aureus jump velocity Y if it's far enough above the player - float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); - bool increaseJumpVelocityY = distanceBelowTarget > 0f && revenge; - if (increaseJumpVelocityY) - { - calamityGlobalNPC.newAI[1] = distanceBelowTarget * multiplier; - if (calamityGlobalNPC.newAI[1] > speedMultLimit) - calamityGlobalNPC.newAI[1] = speedMultLimit; - } - - float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 27f : 20f; - velocity += 6f * enrageScale; - if (expertMode) - velocity += death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - if (Main.getGoodWorld) - velocity *= 1.15f; - - npc.velocity = (new Vector2(player.Center.X, player.Center.Y - 500f) - npc.Center).SafeNormalize(Vector2.Zero) * velocity; - npc.velocity *= new Vector2(calamityGlobalNPC.newAI[0] + 1f, calamityGlobalNPC.newAI[1] + 1f); - - npc.noTileCollide = true; - - npc.ai[0] = 4f; - npc.ai[1] = 0f; - - SoundEngine.PlaySound(AstrumAureus.AstrumAureus.JumpSound, npc.Center); - - npc.netUpdate = true; - } - } - - // Don't run custom gravity when starting a jump - if (npc.ai[0] != 4f) - CustomGravity(); - } - - // Stomp - else if (npc.ai[0] == 4f) - { - if (npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Play stomp sound. Gotta specify the filepath to avoid confusion between the namespace and npc - SoundStyle soundToPlay = Main.zenithWorld ? NPCs.ExoMechs.Ares.AresGaussNuke.NukeExplosionSound : NPCs.AstrumAureus.AstrumAureus.StompSound; - SoundEngine.PlaySound(soundToPlay, npc.Center); - - if (Main.zenithWorld) - { - float screenShakePower = 16 * Utils.GetLerpValue(1300f, 0f, npc.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; - } - - // Stomp and jump again, if stomped twice then reset and set AI to next phase (Teleport or Idle) - npc.TargetClosest(); - npc.localAI[1] += 1f; - float maxStompAmt = phase5 ? 5f : phase3 ? 2f : 3f; - if (npc.localAI[1] >= maxStompAmt) - { - npc.ai[0] = exhausted ? 1f : (phase3 ? 5f : 2f); - npc.localAI[1] = 0f; - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.noTileCollide = false; - npc.netUpdate = true; - } - else - { - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.ai[0] = 3f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - - // Spawn dust for visual effect - for (int i = (int)npc.position.X - 20; i < (int)npc.position.X + npc.width + 40; i += 20) - { - for (int j = 0; j < 4; j++) - { - int stompDust = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - Main.dust[stompDust].velocity *= 0.2f; - } - } - - // Fire lasers or flames on stomp - SoundEngine.PlaySound(AstrumAureus.AstrumAureus.LaserSound, npc.Center); - - if (Main.zenithWorld) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalProjectiles = bossRush ? 14 : death ? 12 : revenge ? 10 : expertMode ? 8 : 6; - float radians = MathHelper.TwoPi / totalProjectiles; - float velocity = 10f; - Vector2 spinningPoint = new Vector2(0f, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 1f); - } - } - } - else if (calamityGlobalNPC.newAI[2] == 0f && phase2) - { - calamityGlobalNPC.newAI[2] = 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float flameVelocity = 6f; - int maxProjectiles = bossRush ? 4 : death ? 3 : 2; - int spread = bossRush ? 36 : death ? 28 : 20; - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 spawnVector = new Vector2(npc.Center.X, npc.Center.Y - 80f * npc.scale); - Vector2 destination = new Vector2(spawnVector.X, spawnVector.Y + 100f * npc.scale); - Vector2 projectileVelocity = Vector2.Normalize(destination - spawnVector) * flameVelocity; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < maxProjectiles; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector + Vector2.Normalize(perturbedSpeed) * 100f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } - } - } - else - { - calamityGlobalNPC.newAI[2] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float laserVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 7f : death ? 6f : 5f; - int maxProjectiles = !phase3 ? (bossRush ? 13 : death ? 11 : 9) : (bossRush ? 17 : death ? 15 : 13); - int spread = !phase3 ? (bossRush ? 20 : death ? 18 : 16) : (bossRush ? 24 : death ? 22 : 20); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int[] lasersToNotFire = new int[4] { 1, 3, maxProjectiles - 2, maxProjectiles - 4 }; - Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * laserVelocity; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < maxProjectiles; i++) - { - if (i != lasersToNotFire[0] && i != lasersToNotFire[1] && i != lasersToNotFire[2] && i != lasersToNotFire[3]) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(maxProjectiles - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, laserVelocity * 2f); - } - } - } - } - } - else - { - // Set damage - npc.damage = npc.defDamage; - - // Set velocities while falling, this happens before the stomp - // Fall through - if (!player.dead) - { - if ((player.position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (player.position.Y < npc.Bottom.Y && npc.velocity.Y < 0f)) - npc.noTileCollide = true; - else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height))) - npc.noTileCollide = false; - } - - if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width) - { - // Make sure Aureus falls quickly when directly on top of or below the player - if (npc.ai[3] < 30f) - npc.ai[3] = 30f; - - npc.velocity.X *= 0.8f; - - if (npc.Bottom.Y < player.position.Y) - { - // Make sure Aureus falls rather quickly - if (npc.velocity.Y < -3f) - npc.velocity.Y = -3f; - - float fallSpeed = 1.2f; - fallSpeed += 0.36f * enrageScale; - if (expertMode) - fallSpeed += death ? 0.36f * (1f - lifeRatio) : 0.24f * (1f - lifeRatio); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - fallSpeed += 0.5f; - - if (calamityGlobalNPC.newAI[1] > 0f) - fallSpeed *= calamityGlobalNPC.newAI[1] + 1f; - - npc.velocity.Y += fallSpeed; - } - } - else - { - // Push Aureus towards the player on the X axis if he's not directly on top of or below the player - float velocityXChange = 0.2f + Math.Abs(npc.Center.X - player.Center.X) * 0.0001f; - velocityXChange += 0.1f * enrageScale; - - if (calamityGlobalNPC.newAI[0] > 0f) - velocityXChange *= calamityGlobalNPC.newAI[0] + 1f; - - if (npc.direction < 0) - npc.velocity.X -= velocityXChange; - else if (npc.direction > 0) - npc.velocity.X += velocityXChange; - - float velocityXCap = 12f; - velocityXCap += 3.6f * enrageScale; - if (expertMode) - velocityXCap += death ? 3.6f * (1f - lifeRatio) : 2.4f * (1f - lifeRatio); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - velocityXCap += 5f; - - if (calamityGlobalNPC.newAI[0] > 0f) - velocityXCap *= calamityGlobalNPC.newAI[0] + 1f; - - float playerLocation = npc.Center.X - player.Center.X; - int directionRelativeToTarget = playerLocation < 0 ? 1 : -1; - bool slowDown = directionRelativeToTarget != calamityGlobalNPC.newAI[3]; - - if (slowDown) - velocityXCap *= 0.333f; - - if (npc.velocity.X < -velocityXCap) - npc.velocity.X = -velocityXCap; - if (npc.velocity.X > velocityXCap) - npc.velocity.X = velocityXCap; - } - - // Don't start falling quickly until half a second has passed - npc.ai[3] += 1f; - if (npc.ai[3] > 30f) - CustomGravity(); - } - } - - // Teleport - else if (npc.ai[0] == 5f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Slow down - npc.velocity.X *= 0.8f; - - // Start teleport - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (death) - npc.localAI[2] += 1.25f; - - if (phase4) - { - npc.localAI[1] += 1f; - if (death) - npc.localAI[2] += 1.25f; - } - - if (npc.localAI[1] >= (bossRush ? 60f : death ? 180f : 240f)) - { - // Reset localAI and find a teleport destination - npc.TargetClosest(); - npc.localAI[1] = 0f; - - Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 1000f; - Point point4 = vectorAimedAheadOfTarget.ToTileCoordinates(); - int teleportTries = 0; - while (teleportTries < 100) - { - teleportTries++; - int teleportTileX = Main.rand.Next(point4.X - 5, point4.X + 6); - int teleportTileY = Main.rand.Next(point4.Y - 5, point4.Y); - - if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) - { - npc.ai[1] = teleportTileX * 16 + 8; - npc.ai[3] = teleportTileY * 16 + 16; - break; - } - } - - // Default teleport if the above conditions aren't met in 100 iterations - if (teleportTries >= 100) - { - Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; - npc.ai[1] = bottom.X; - npc.ai[3] = bottom.Y; - } - - // Set AI to next phase (Mid-teleport) - npc.ai[0] = 6f; - npc.netUpdate = true; - } - } - - CustomGravity(); - } - - // Mid-teleport - else if (npc.ai[0] == 6f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (death) - npc.localAI[2] += 1.25f; - - if (phase4) - { - if (death) - npc.localAI[2] += 1.25f; - } - - // Turn invisible - npc.alpha += 10; - if (npc.alpha >= 255) - { - // Set position to teleport destination - npc.Bottom = new Vector2(npc.ai[1], npc.ai[3]); - - // Reset alpha and set AI to next phase (End of teleport) - npc.alpha = 255; - npc.ai[0] = 7f; - npc.localAI[2] = 0f; - npc.netUpdate = true; - } - - // Play sound for cool effect - if (npc.soundDelay == 0) - { - npc.soundDelay = 15; - SoundEngine.PlaySound(AstrumAureus.AstrumAureus.TeleportSound, npc.Center); - } - - // Emit dust to make the teleport pretty - for (int i = 0; i < 10; i++) - { - int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType(), npc.velocity.X, npc.velocity.Y, 255, default, 2f); - Main.dust[teleportDust].noGravity = true; - Main.dust[teleportDust].velocity *= 0.5f; - } - - CustomGravity(); - } - - // End of teleport - else if (npc.ai[0] == 7f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Turn visible - npc.alpha -= 10; - if (npc.alpha <= 0) - { - // Spawn Aureus Spawns - bool spawnFlag = expertMode; - if (NPC.CountNPCS(ModContent.NPCType()) >= 2) - spawnFlag = false; - - if (spawnFlag && Main.netMode != NetmodeID.MultiplayerClient) - { - int aureusSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType()); - Main.npc[aureusSpawn].velocity.Y = -10f; - Main.npc[aureusSpawn].netUpdate = true; - if (revenge) - { - aureusSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.Center.Y - 25f * npc.scale), ModContent.NPCType()); - Main.npc[aureusSpawn].velocity.Y = -15f; - Main.npc[aureusSpawn].netUpdate = true; - } - - if (death) - { - int damageAmt = npc.lifeMax / 50; - npc.life -= damageAmt; - if (npc.life < 1) - npc.life = 1; - - npc.DamageEffect(damageAmt); - } - } - - // Reset alpha and set AI to next phase (Idle) - npc.alpha = 0; - npc.ai[0] = exhausted ? 1f : 2f; - npc.ai[1] = 0f; - npc.ai[2] += 1f; - npc.localAI[3] = noProjectileOrPhaseIncrementTime; - - // Stop colliding with tiles if entering walking phase - npc.noTileCollide = npc.ai[0] == 2f; - - npc.netUpdate = true; - } - - // Play sound at teleport destination for cool effect - if (npc.soundDelay == 0) - { - npc.soundDelay = 15; - SoundEngine.PlaySound(SoundID.Item109, npc.Center); - } - - // Emit dust to make the teleport pretty - for (int i = 0; i < 10; i++) - { - int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, ModContent.DustType(), npc.velocity.X, npc.velocity.Y, 255, default, 2f); - Main.dust[teleportDust].noGravity = true; - Main.dust[teleportDust].velocity *= 0.5f; - } - - CustomGravity(); - } - - void CustomGravity() - { - float gravity = 0.36f + 0.12f * enrageScale; - float maxFallSpeed = reduceFallSpeed ? 12f : 12f + 4f * enrageScale; - - if (calamityGlobalNPC.newAI[1] > 0f && !reduceFallSpeed) - maxFallSpeed *= calamityGlobalNPC.newAI[1] + 1f; - - if (Main.getGoodWorld && !reduceFallSpeed) - { - gravity *= 1.15f; - maxFallSpeed *= 1.15f; - } - - npc.velocity.Y += gravity; - if (npc.velocity.Y > maxFallSpeed) - npc.velocity.Y = maxFallSpeed; - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AstrumDeusAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AstrumDeusAI.cs deleted file mode 100644 index 4ae6fd1ae2..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/AstrumDeusAI.cs +++ /dev/null @@ -1,904 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Packets; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class AstrumDeusAI - { - public static void VanillaAstrumDeusAI(NPC npc, Mod mod, bool head) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Difficulty variables - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - float enrageScale = bossRush ? 0.5f : 0f; - if (Main.IsItDay() || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1.5f; - } - - // Deus cannot hit for 3 seconds or while invulnerable - bool doNotDealDamage = calamityGlobalNPC.newAI[1] < 180f || npc.dontTakeDamage; - if (doNotDealDamage) - npc.damage = 0; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - bool increaseSpeed = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - - // Despawn safety, make sure to target another player if the current player target is too far away - if (increaseSpeedMore && head) - npc.TargetClosest(); - - // Inflict Extreme Gravity to nearby players - if (revenge) - { - if (!Main.dedServ) - { - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); - } - } - - // Life - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases based on life percentage - bool halfHealth = lifeRatio < 0.5f; - bool doubleWormPhase = calamityGlobalNPC.newAI[0] != 0f; - bool startFlightPhase = lifeRatio < 0.8f || death || doubleWormPhase; - bool phase2 = lifeRatio < 0.5f && doubleWormPhase && expertMode; - bool phase3 = lifeRatio < 0.2f && doubleWormPhase && expertMode; - bool splittingMines = lifeRatio < 0.7f; - bool movingMines = lifeRatio < 0.3f && doubleWormPhase && expertMode; - bool deathModeEnragePhase_Head = calamityGlobalNPC.newAI[0] == 3f; - bool deathModeEnragePhase_BodyAndTail = false; - - // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing - float resistanceTime = doubleWormPhase ? 300f : 600f; - - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < resistanceTime; - - // Flight timer - float aiSwitchTimer = doubleWormPhase ? (Main.getGoodWorld ? 600f : 1200f) : (Main.getGoodWorld ? 900f : 1800f); - - calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] >= aiSwitchTimer) - calamityGlobalNPC.newAI[3] = 0f; - - // Phase for flying at the player - bool flyAtTarget = calamityGlobalNPC.newAI[3] >= (aiSwitchTimer * 0.5f) && startFlightPhase; - - // Length of worms - int phase1Length = death ? 80 : revenge ? 70 : expertMode ? 60 : 50; - int phase2Length = death ? 40 : revenge ? 35 : expertMode ? 30 : 25; - int gfbLength = death ? 8 : revenge ? 7 : expertMode ? 6 : 5; - int maxLength = Main.zenithWorld && doubleWormPhase ? gfbLength : doubleWormPhase ? phase2Length : phase1Length; - - // Become gradually more pissed as more worms are killed - int gfbMaxWormCount = 10; - int gfbWormCount = 0; - if (CalamityWorld.LegendaryMode && revenge) - gfbWormCount = NPC.CountNPCS(ModContent.NPCType()); - if (gfbWormCount > gfbMaxWormCount) - gfbWormCount = gfbMaxWormCount; - if (gfbWormCount > 0) - enrageScale += (gfbMaxWormCount - gfbWormCount) * 0.111f; - - // Split into two worms - if (head) - { - float splitAnimationTime = 180f; - bool oneWormAlive = NPC.CountNPCS(ModContent.NPCType()) < 2; - bool deathModeFinalWormEnrage = death && doubleWormPhase && oneWormAlive && calamityGlobalNPC.newAI[1] >= resistanceTime; - if (deathModeFinalWormEnrage) - { - if (calamityGlobalNPC.newAI[0] != 3f) - { - SoundEngine.PlaySound(AstrumDeusHead.SplitSound, player.Center); - calamityGlobalNPC.newAI[0] = 3f; - npc.defense = 12; - calamityGlobalNPC.DR = 0.075f; - - // Despawns the other deus worm segments - int bodyID = ModContent.NPCType(); - int tailID = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC wormseg = Main.npc[i]; - if (!wormseg.active) - continue; - - if ((wormseg.type == bodyID || wormseg.type == tailID) && Main.npc[(int)wormseg.ai[2]].Calamity().newAI[0] != 3f) - { - wormseg.life = 0; - wormseg.active = false; - } - } - } - - calamityGlobalNPC.newAI[2] += 10f; - if (calamityGlobalNPC.newAI[2] > 162f) - calamityGlobalNPC.newAI[2] = 162f; - - npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); - } - - bool despawnRemainingWorm = doubleWormPhase && oneWormAlive && !death; - if ((halfHealth && calamityGlobalNPC.newAI[0] == 0f) || despawnRemainingWorm) - { - npc.dontTakeDamage = true; - - calamityGlobalNPC.newAI[2] += despawnRemainingWorm ? 10f : 1f; - npc.Opacity = MathHelper.Clamp(1f - (calamityGlobalNPC.newAI[2] / splitAnimationTime), 0f, 1f); - - bool despawning = calamityGlobalNPC.newAI[2] == splitAnimationTime; - - // - // CODE TWEAKED BY: OZZATRON - // September 20th, 2020 - // reason: fixing Astrum Deus death mode NPC cap bug - // - - // Despawn the unsplit Astrum Deus and spawn two half-size Astrum Deus worms. - if (despawning) - { - // If this is already a split worm (newAI[0] != 0f) then don't do anything. At all. - if (doubleWormPhase) - return; - - // Mark all existing body and tail segments as inactive. This instantly frees up their NPC slots for the freshly spawned worms. - int bodyID = ModContent.NPCType(); - int tailID = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC wormseg = Main.npc[i]; - if (!wormseg.active) - continue; - if (wormseg.type == bodyID || wormseg.type == tailID) - { - wormseg.life = 0; - wormseg.active = false; - } - } - - // The unsplit Astrum Deus worm head will die next frame. - npc.life = 0; - - // Do not spawn worms client side. The server handles this. - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int wormamt = Main.zenithWorld ? 5 : 1; - for (int i = 0; i < wormamt; i++) - { - // Now that the original worm doesn't exist, startCount can be zero. - // int startCount = npc.whoAmI + phase1Length + 1; - int startIndexHeadOne = 1; - int headOneID = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadOne); - Main.npc[headOneID].Calamity().newAI[0] = 1f; - Main.npc[headOneID].velocity = Vector2.Normalize(player.Center - Main.npc[headOneID].Center) * 16f; - Main.npc[headOneID].timeLeft *= 20; - Main.npc[headOneID].ForceNetUpdate(); - - // On server, immediately send the correct extra AI of this head to clients. - if (Main.dedServ) - { - SyncCalamityNPCAIArrayPacket.Send(Main.npc[headOneID]); - } - - // Make sure the second split worm is also contiguous. - int startIndexHeadTwo = startIndexHeadOne + phase2Length + 1; - int headTwoID = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, npc.type, startIndexHeadTwo); - Main.npc[headTwoID].Calamity().newAI[0] = 2f; - Main.npc[headTwoID].Calamity().newAI[3] = Main.getGoodWorld ? 300f : 600f; - Main.npc[headTwoID].velocity = Vector2.Normalize(player.Center - Main.npc[headTwoID].Center) * 16f; - Main.npc[headTwoID].timeLeft *= 20; - Main.npc[headTwoID].ForceNetUpdate(); - - // On server, immediately send the correct extra AI of this head to clients. - if (Main.dedServ) - { - SyncCalamityNPCAIArrayPacket.Send(Main.npc[headTwoID]); - } - } - - SoundEngine.PlaySound(AstrumDeusHead.SplitSound, player.Center); - } - return; - } - } - - if (Main.zenithWorld && calamityGlobalNPC.newAI[1] < 10f) // desync the deuses - { - float pushForce = 0.25f; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC otherDeus = Main.npc[k]; - // Short circuits to make the loop as fast as possible - if (!otherDeus.active || k == npc.whoAmI) - continue; - - // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. - bool sameProjType = otherDeus.type == npc.type; - float taxicabDist = Vector2.Distance(npc.Center, otherDeus.Center); - float distancegate = 320f; - if (sameProjType && taxicabDist < distancegate) - { - if (npc.position.X < otherDeus.position.X) - npc.velocity.X -= pushForce; - else - npc.velocity.X += pushForce; - - if (npc.position.Y < otherDeus.position.Y) - npc.velocity.Y -= pushForce; - else - npc.velocity.Y += pushForce; - } - } - } - } - - // Copy dontTakeDamage and Opacity from head - else - { - npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage; - npc.Opacity = Main.npc[(int)npc.ai[2]].Opacity; - deathModeEnragePhase_BodyAndTail = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] == 3f; - - if (deathModeEnragePhase_BodyAndTail) - { - npc.defense = 25; - calamityGlobalNPC.DR = 0.15f; - } - } - - // Set worm variable - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Alpha effects - if ((head || Main.npc[(int)npc.ai[1]].alpha < 128) && !npc.dontTakeDamage) - { - // Alpha changes - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - // Check if other segments are still alive, if not, die - if (!head) - { - bool shouldDespawn = true; - int headType = ModContent.NPCType(); - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type != headType || !Main.npc[i].active) - continue; - shouldDespawn = false; - break; - } - if (shouldDespawn) - { - if (Main.npc.IndexInRange((int)npc.ai[1]) && Main.npc[(int)npc.ai[1]].active && Main.npc[(int)npc.ai[1]].life > 0) - shouldDespawn = false; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - npc.ForceNetUpdate(false); - } - } - - // Direction - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - // Head code - if (head) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - int bodyType = ModContent.NPCType(); - int tailType = ModContent.NPCType(); - for (int segments = 0; segments < maxLength; segments++) - { - int lol; - if (segments >= 0 && segments < maxLength - 1) - lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, bodyType, npc.whoAmI); - else - lol = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, tailType, npc.whoAmI); - - if (segments % 2 == 0) - Main.npc[lol].localAI[3] = 1f; - - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].Calamity().newAI[0] = Main.npc[Previous].Calamity().newAI[0]; - Main.npc[lol].Calamity().newAI[3] = Main.npc[Previous].Calamity().newAI[3]; - - if (Main.dedServ) - { - SyncCalamityNPCAIArrayPacket.Send(Main.npc[lol]); - } - - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol); - Previous = lol; - } - } - } - - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; - } - else - { - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - } - - bool hasJustSpawned = calamityGlobalNPC.newAI[1] < resistanceTime * 0.4f && !doubleWormPhase; // Speed boost for the first 4 seconds after spawning - float segmentVelocity = hasJustSpawned ? 25f : deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; - - float segmentVelocityBoost = 5f * (1f - lifeRatio); - segmentVelocity += segmentVelocityBoost; - segmentVelocity += 4f * enrageScale; - - if (revenge) - { - float revMultiplier = 1.1f; - segmentVelocity *= revMultiplier; - } - - if (head) - { - int headTilePositionX = (int)(npc.position.X / 16f) - 1; - int headTileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2; - int headTilePositionY = (int)(npc.position.Y / 16f) - 1; - int headTileWidthPosY = (int)((npc.position.Y + npc.height) / 16f) + 2; - - if (headTilePositionX < 0) - headTilePositionX = 0; - if (headTileWidthPosX > Main.maxTilesX) - headTileWidthPosX = Main.maxTilesX; - if (headTilePositionY < 0) - headTilePositionY = 0; - if (headTileWidthPosY > Main.maxTilesY) - headTileWidthPosY = Main.maxTilesY; - - // Fly or not - bool shouldFly = flyAtTarget; - if (!shouldFly) - { - for (int k = headTilePositionX; k < headTileWidthPosX; k++) - { - for (int l = headTilePositionY; l < headTileWidthPosY; l++) - { - if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[Main.tile[k, l].TileType] || (Main.tileSolidTop[Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) - { - Vector2 vector2; - vector2.X = k * 16f; - vector2.Y = l * 16f; - if (npc.position.X + npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f) - { - shouldFly = true; - break; - } - } - } - } - } - - // Start flying if target is not within a certain distance - if (!shouldFly) - { - npc.localAI[1] = 1f; - - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int noFlyZone = 200; - int heightReduction = death ? 130 : (int)(130f * (1f - lifeRatio)); - int height = 400 - heightReduction; - bool outsideNoFlyZone = true; - - if (npc.position.Y > player.position.Y) - { - for (int m = 0; m < Main.maxPlayers; m++) - { - if (Main.player[m].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, height); - if (rectangle.Intersects(rectangle2)) - { - outsideNoFlyZone = false; - break; - } - } - } - - if (outsideNoFlyZone) - shouldFly = true; - } - } - else - npc.localAI[1] = 0f; - - // Despawn - if (player.dead) - { - shouldFly = false; - float velocity = 2f; - npc.velocity.Y -= velocity; - if ((double)npc.position.Y < Main.topWorld + 16f) - { - segmentVelocity *= 2f; - npc.velocity.Y -= velocity; - } - - int headType = ModContent.NPCType(); - int bodyType = ModContent.NPCType(); - int tailType = ModContent.NPCType(); - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type == headType || Main.npc[i].type == bodyType || Main.npc[i].type == tailType) - { - Main.npc[i].active = false; - Main.npc[i].ForceNetUpdate(false); - } - } - } - } - - // Speed and movement - float speedBoost = death ? (0.1f * (1f - lifeRatio)) : (0.13f * (1f - lifeRatio)); - float turnSpeedBoost = death ? (0.18f * (1f - lifeRatio)) : (0.2f * (1f - lifeRatio)); - float speed = (hasJustSpawned ? 0.26f : deathModeEnragePhase_Head ? 0.2f : death ? 0.18f : 0.13f) + speedBoost; - float turnSpeed = (hasJustSpawned ? 0.3f : deathModeEnragePhase_Head ? 0.27f : death ? 0.25f : 0.2f) + turnSpeedBoost; - speed += 0.05f * enrageScale; - turnSpeed += 0.08f * enrageScale; - - if (flyAtTarget) - { - float speedMultiplier = deathModeEnragePhase_Head ? 1.25f : doubleWormPhase ? (phase3 ? 1.25f : phase2 ? 1.2f : 1.15f) : 1f; - speed *= speedMultiplier; - } - - if (revenge) - { - float revMultiplier = 1.1f; - speed *= revMultiplier; - turnSpeed *= revMultiplier; - } - - speed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f; - turnSpeed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f; - - if (Main.getGoodWorld) - { - speed *= 1.15f; - turnSpeed *= 1.15f; - } - - Vector2 deusCenter = npc.Center; - float deusTargetX = player.Center.X; - float deusTargetY = player.Center.Y; - deusTargetX = (int)(deusTargetX / 16f) * 16; - deusTargetY = (int)(deusTargetY / 16f) * 16; - deusCenter.X = (int)(deusCenter.X / 16f) * 16; - deusCenter.Y = (int)(deusCenter.Y / 16f) * 16; - deusTargetX -= deusCenter.X; - deusTargetY -= deusCenter.Y; - - if (!shouldFly) - { - npc.velocity.Y += 0.15f; - if (npc.velocity.Y > segmentVelocity) - npc.velocity.Y = segmentVelocity; - - // This bool exists to stop the strange wiggle behavior when worms are falling down - bool slowXVelocity = Math.Abs(npc.velocity.X) > speed; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.4) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= speed * 1.1f; - else - npc.velocity.X += speed * 1.1f; - } - else if (npc.velocity.Y == segmentVelocity) - { - if (slowXVelocity) - { - if (npc.velocity.X < deusTargetX) - npc.velocity.X += speed; - else if (npc.velocity.X > deusTargetX) - npc.velocity.X -= speed; - } - else - npc.velocity.X = 0f; - } - else if (npc.velocity.Y > 4f) - { - if (slowXVelocity) - { - if (npc.velocity.X < 0f) - npc.velocity.X += speed * 0.9f; - else - npc.velocity.X -= speed * 0.9f; - } - else - npc.velocity.X = 0f; - } - } - else - { - float deusTargetDist = (float)Math.Sqrt(deusTargetX * deusTargetX + deusTargetY * deusTargetY); - float deusAbsoluteTargetX = Math.Abs(deusTargetX); - float deusAbsoluteTargetY = Math.Abs(deusTargetY); - float deusTimeToReachTarget = segmentVelocity / deusTargetDist; - deusTargetX *= deusTimeToReachTarget; - deusTargetY *= deusTimeToReachTarget; - - bool speedUpWhileFlying = false; - if (flyAtTarget) - { - if (((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f) || (npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && deusTargetDist < 400f) - { - speedUpWhileFlying = true; - - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < segmentVelocity) - npc.velocity *= 1.1f; - } - - if (npc.position.Y > player.position.Y) - { - speedUpWhileFlying = true; - - if (Math.Abs(npc.velocity.X) < segmentVelocity / 2f) - { - if (npc.velocity.X == 0f) - npc.velocity.X -= npc.direction; - - npc.velocity.X *= 1.1f; - } - else if (npc.velocity.Y > -segmentVelocity) - npc.velocity.Y -= speed; - } - } - - if (!speedUpWhileFlying) - { - if (!flyAtTarget) - { - if (((npc.velocity.X > 0f && deusTargetX > 0f) || (npc.velocity.X < 0f && deusTargetX < 0f)) && ((npc.velocity.Y > 0f && deusTargetY > 0f) || (npc.velocity.Y < 0f && deusTargetY < 0f))) - { - if (npc.velocity.X < deusTargetX) - npc.velocity.X += turnSpeed; - else if (npc.velocity.X > deusTargetX) - npc.velocity.X -= turnSpeed; - - if (npc.velocity.Y < deusTargetY) - npc.velocity.Y += turnSpeed; - else if (npc.velocity.Y > deusTargetY) - npc.velocity.Y -= turnSpeed; - } - } - - if ((npc.velocity.X > 0f && deusTargetX > 0f) || (npc.velocity.X < 0f && deusTargetX < 0f) || (npc.velocity.Y > 0f && deusTargetY > 0f) || (npc.velocity.Y < 0f && deusTargetY < 0f)) - { - if (npc.velocity.X < deusTargetX) - npc.velocity.X += speed; - else if (npc.velocity.X > deusTargetX) - npc.velocity.X -= speed; - - if (npc.velocity.Y < deusTargetY) - npc.velocity.Y += speed; - else if (npc.velocity.Y > deusTargetY) - npc.velocity.Y -= speed; - - if (Math.Abs(deusTargetY) < segmentVelocity * 0.2 && ((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += speed * 2f; - else - npc.velocity.Y -= speed * 2f; - } - - if (Math.Abs(deusTargetX) < segmentVelocity * 0.2 && ((npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += speed * 2f; - else - npc.velocity.X -= speed * 2f; - } - } - else if (deusAbsoluteTargetX > deusAbsoluteTargetY) - { - if (npc.velocity.X < deusTargetX) - npc.velocity.X += speed * 1.1f; - else if (npc.velocity.X > deusTargetX) - npc.velocity.X -= speed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += speed; - else - npc.velocity.Y -= speed; - } - } - else - { - if (npc.velocity.Y < deusTargetY) - npc.velocity.Y += speed * 1.1f; - else if (npc.velocity.Y > deusTargetY) - npc.velocity.Y -= speed * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += speed; - else - npc.velocity.X -= speed; - } - } - } - } - - if (shouldFly) - { - if (npc.localAI[0] != 1f) - npc.ForceNetUpdate(false); - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.ForceNetUpdate(false); - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.ForceNetUpdate(false); - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - } - - // Only the main worm body and tail use this code - else - { - // Shoot lasers - if (npc.type == ModContent.NPCType()) - { - npc.localAI[0] += 1f; - - int shootTime = (doubleWormPhase && expertMode) ? 2 : 1; - float shootProjectile = (doubleWormPhase && expertMode) ? 200 : 400; - float timer = npc.ai[0] + 15f; - float divisor = timer + shootProjectile; - bool canFireProjectiles = npc.Opacity >= 1f; - bool shootGodRays = phase2 || deathModeEnragePhase_BodyAndTail; - - if (canFireProjectiles) - { - if (!flyAtTarget || deathModeEnragePhase_BodyAndTail) - { - float laserDivisor = (phase2 && !deathModeEnragePhase_BodyAndTail) ? 4f : 2f; - if (npc.localAI[0] % divisor == 0f && npc.ai[0] % laserDivisor == 0f) - { - npc.TargetClosest(); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (deathModeEnragePhase_BodyAndTail) - { - Vector2 velocity = Vector2.Zero; - if (movingMines) - { - Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - randomMineMovement.Normalize(); - randomMineMovement *= Main.rand.Next(90, 121) * 0.01f; - velocity = randomMineMovement; - } - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); - } - } - - if (Vector2.Distance(player.Center, npc.Center) > 80f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float deusLaserSpeed = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; - - Vector2 deusLaserCenter = npc.Center; - float deusLaserTargetX = player.Center.X - deusLaserCenter.X; - float deusLaserTargetY = player.Center.Y - deusLaserCenter.Y; - float deusLaserTargetDist = (float)Math.Sqrt(deusLaserTargetX * deusLaserTargetX + deusLaserTargetY * deusLaserTargetY); - deusLaserTargetDist = deusLaserSpeed / deusLaserTargetDist; - deusLaserTargetX *= deusLaserTargetDist; - deusLaserTargetY *= deusLaserTargetDist; - deusLaserCenter.X += deusLaserTargetX * 5f; - deusLaserCenter.Y += deusLaserTargetY * 5f; - - Vector2 shootDirection = new Vector2(deusLaserTargetX, deusLaserTargetY).SafeNormalize(Vector2.UnitY); - Vector2 laserVelocity = shootDirection * deusLaserSpeed; - - int type = shootGodRays ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (shootGodRays) - { - SoundEngine.PlaySound(AstrumDeusHead.GodRaySound, npc.Center); - // Waving beams need to start offset so they cross each other neatly. - float waveSideOffset = Main.rand.NextFloat(9f, 14f); - Vector2 perp = shootDirection.RotatedBy(-MathHelper.PiOver2) * waveSideOffset; - - for (int i = -1; i <= 1; i += 2) - { - Vector2 laserStartPos = deusLaserCenter + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); - Projectile godRay = Projectile.NewProjectileDirect(npc.GetSource_FromAI(), laserStartPos, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); - - // Tell this Phased God Ray exactly which way it should be waving. - godRay.localAI[1] = i * 0.5f; - } - } - else - { - SoundEngine.PlaySound(AstrumDeusHead.LaserSound, npc.Center); - Projectile.NewProjectile(npc.GetSource_FromAI(), deusLaserCenter, laserVelocity, type, damage, 0f, Main.myPlayer, player.Center.X, player.Center.Y); - } - } - } - } - } - else - { - if (npc.localAI[0] % divisor == 0f && npc.ai[0] % 2f == 0f) - { - Vector2 velocity = Vector2.Zero; - if (movingMines) - { - Vector2 randomMineMovement = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - randomMineMovement.Normalize(); - randomMineMovement *= Main.rand.Next(30, 121) * 0.01f; - velocity = randomMineMovement; - } - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float split = (splittingMines && npc.ai[0] % 3f == 0f) ? 1f : 0f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, type, damage, 0f, Main.myPlayer, split, 0f); - } - } - } - } - - // Follow the head - Vector2 segmentCenter = npc.Center; - float segmentTargetX = player.Center.X; - float segmentTargetY = player.Center.Y; - segmentTargetX = (int)(segmentTargetX / 16f) * 16; - segmentTargetY = (int)(segmentTargetY / 16f) * 16; - segmentCenter.X = (int)(segmentCenter.X / 16f) * 16; - segmentCenter.Y = (int)(segmentCenter.Y / 16f) * 16; - segmentTargetX -= segmentCenter.X; - segmentTargetY -= segmentCenter.Y; - - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - segmentCenter = npc.Center; - segmentTargetX = Main.npc[(int)npc.ai[1]].Center.X - segmentCenter.X; - segmentTargetY = Main.npc[(int)npc.ai[1]].Center.Y - segmentCenter.Y; - } - catch - { - } - - npc.rotation = (float)Math.Atan2(segmentTargetY, segmentTargetX) + MathHelper.PiOver2; - float segmentTargetDist = (float)Math.Sqrt(segmentTargetX * segmentTargetX + segmentTargetY * segmentTargetY); - int segmentWidth = npc.width; - segmentTargetDist = (segmentTargetDist - segmentWidth) / segmentTargetDist; - segmentTargetX *= segmentTargetDist; - segmentTargetY *= segmentTargetDist; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + segmentTargetX; - npc.position.Y = npc.position.Y + segmentTargetY; - - if (segmentTargetX < 0f) - npc.spriteDirection = -1; - else if (segmentTargetX > 0f) - npc.spriteDirection = 1; - } - } - - // 5 seconds of resistance in phase 2, 10 seconds in phase 1, to prevent spawn killing - if (calamityGlobalNPC.newAI[1] < resistanceTime && ((npc.position - npc.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 0f)) - calamityGlobalNPC.newAI[1] += 1f; - - // Calculate contact damage based on velocity - if (!doNotDealDamage) - { - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - if (head) - { - if (npc.velocity.Length() <= minimalContactDamageVelocity) - { - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar); - } - } - else - { - float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - npc.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar); - } - } - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityBossAIs/BrimstoneElementalAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/BrimstoneElementalAI.cs deleted file mode 100644 index 3719557ee3..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/BrimstoneElementalAI.cs +++ /dev/null @@ -1,737 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class BrimstoneElementalAI - { - public static void VanillaBrimstoneElementalAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - BrimstoneElemental.BrimstoneElemental brimmy = npc.ModNPC(); - - // Used for Brimling AI states - CalamityGlobalNPC.brimstoneElemental = npc.whoAmI; - - // Emit light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1.2f, 0f, 0f); - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - - if (!player.active || player.dead || despawnDistance) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || despawnDistance) - { - npc.rotation = npc.velocity.X * 0.04f; - - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - CalamityPlayer modPlayer = player.Calamity(); - - // Reset defense - npc.defense = npc.defDefense; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == 4f; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Variables for buffing the AI - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - bool phase2 = lifeRatio < 0.5f && revenge; - bool phase3 = lifeRatio < 0.33f; - - // Enrage - if ((!player.ZoneUnderworldHeight || !modPlayer.ZoneCalamity) && !bossRush) - { - if (calamityGlobalNPC.newAI[3] > 0f) - calamityGlobalNPC.newAI[3] -= 1f; - } - else - calamityGlobalNPC.newAI[3] = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = calamityGlobalNPC.newAI[3] <= 0f || bossRush; - - float enrageScale = bossRush ? 0.5f : 0f; - if (biomeEnraged && (!player.ZoneUnderworldHeight || bossRush)) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 0.5f; - } - if (biomeEnraged && (!modPlayer.ZoneCalamity || bossRush)) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - - npc.Calamity().DR = npc.ai[0] == 4f ? 0.6f : 0.2f; - - // Emit dust - int dustAmt = (npc.ai[0] == 2f) ? 2 : 1; - int size = (npc.ai[0] == 2f) ? 50 : 35; - if (npc.ai[0] != 1f) - { - for (int i = 0; i < 2; i++) - { - if (Main.rand.Next(3) < dustAmt) - { - int dust = Dust.NewDust(npc.Center - new Vector2(size), size * 2, size * 2, DustID.LifeDrain, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 1.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.2f; - Main.dust[dust].fadeIn = 1f; - } - } - } - - // Distance from destination where Brimmy stops moving - float movementDistanceGateValue = 100f; - - // How fast Brimmy moves to the destination - float baseVelocity = (death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f) * (npc.ai[0] == 5f ? 0.05f : npc.ai[0] == 3f ? 1.5f : 1f); - baseVelocity += 3f * enrageScale; - if (expertMode) - baseVelocity += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - - float baseAcceleration = (death ? 0.12f : 0.1f) * (npc.ai[0] == 5f ? 0.5f : npc.ai[0] == 3f ? 1.5f : 1f); - baseAcceleration += 0.06f * enrageScale; - if (expertMode) - baseAcceleration += 0.03f * (1f - lifeRatio); - - // This is where Brimmy should be - Vector2 destination = npc.ai[0] != 3f ? player.Center : new Vector2(player.Center.X, player.Center.Y - 300f); - - // How far Brimmy is from where she's supposed to be - Vector2 distanceFromDestination = destination - npc.Center; - - // Movement - if (npc.ai[0] != 4f) - CalamityUtils.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity, baseAcceleration, true); - - // Rotation and direction - if (npc.ai[0] <= 2f || npc.ai[0] == 5f) - { - npc.rotation = npc.velocity.X * 0.04f; - if (npc.ai[0] != 5 || (npc.ai[1] < 180f && npc.ai[0] == 5f)) - { - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; - } - } - - if (Main.zenithWorld) // in gfb, Brimmy channels the power of the other elementals. - { - int newMode; - if (lifeRatio <= 0.8f && lifeRatio > 0.6f) - { - newMode = 1; // Sand - } - else if (lifeRatio <= 0.6f && lifeRatio > 0.4f) - { - newMode = 2; // Rare Sand - } - else if (lifeRatio <= 0.4f && lifeRatio > 0.2f) - { - newMode = 3; // Cloud - } - else if (lifeRatio <= 0.2f) - { - newMode = 4; // Water - } - else - { - newMode = 0; // Brimstone, default - } - if (newMode != brimmy.currentMode) - { - SoundEngine.PlaySound(SoundID.Item29, npc.Center); - } - brimmy.currentMode = newMode; - } - - if (npc.ai[0] == -1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int phase; - int random = phase2 ? 6 : 5; - do phase = Main.rand.Next(random); - while (phase == npc.ai[1] || (phase == 0 && phase3 && revenge) || phase == 1 || phase == 2 || (phase == 4 && npc.localAI[3] != 0f)); - - npc.ai[0] = phase; - npc.ai[1] = 0f; - - // Cocoon phase cooldown - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - else if (phase == 4) - { - npc.localAI[3] = 3f; - SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HideInShellSound, player.Center); - } - - // Prevent netUpdate from being blocked by the spam counter. - // A phase switch sync is a critical operation that must be synced. - npc.ForceNetUpdate(false); - } - } - - // Pick a location to teleport to - else if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.chaseable = true; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (npc.justHit) - npc.localAI[1] += masterMode ? 7f : expertMode ? 5f : 3f; - if (npc.Distance(player.Center) < 160f) - npc.localAI[1] += masterMode ? 4f : expertMode ? 2f : 1f; - - if (npc.localAI[1] >= (bossRush ? 90f : death ? 120f : 180f)) - { - npc.TargetClosest(); - npc.localAI[1] = 0f; - int timer = 0; - int playerPosX; - int playerPosY; - while (true) - { - timer++; - playerPosX = (int)player.Center.X / 16; - playerPosY = (int)player.Center.Y / 16; - - int min = 12; - int max = 16; - - if (Main.rand.NextBool()) - playerPosX += Main.rand.Next(min, max); - else - playerPosX -= Main.rand.Next(min, max); - - if (Main.rand.NextBool()) - playerPosY += Main.rand.Next(min, max); - else - playerPosY -= Main.rand.Next(min, max); - - if (!WorldGen.SolidTile(playerPosX, playerPosY)) - break; - - if (timer > 100) - return; - } - npc.ai[0] = 1f; - npc.ai[1] = playerPosX; - npc.ai[2] = playerPosY; - npc.netUpdate = true; - } - } - } - - // Teleport to location - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.chaseable = true; - Vector2 position = new Vector2(npc.ai[1] * 16f - (npc.width / 2), npc.ai[2] * 16f - (npc.height / 2)); - for (int m = 0; m < 5; m++) - { - int dust = Dust.NewDust(position, npc.width, npc.height, DustID.LifeDrain, 0f, -1f, 90, default, 2f); - Main.dust[dust].noGravity = true; - Main.dust[dust].fadeIn = 1f; - } - npc.alpha += bossRush ? 8 : death ? 5 : revenge ? 4 : expertMode ? 3 : 2; - if (npc.alpha >= 255) - { - int spawnType = brimmy.currentMode == 3 ? NPCID.AngryNimbus : ModContent.NPCType(); - int enemyCount = brimmy.currentMode == 3 ? 3 : 1; // 3 angry nimbi if cloud, otherwise 1 brimling - if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(spawnType) < (death ? 1 : 2) && revenge && brimmy.currentMode != 2) // dont spawn anything if gfb rare sand - { - for (int i = 0; i < enemyCount; i++) - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, spawnType); - } - SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.TeleportSound, npc.Center); - npc.alpha = 255; - npc.position = position; - for (int n = 0; n < 15; n++) - { - int warpDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.LifeDrain, 0f, -1f, 90, default, 3f); - Main.dust[warpDust].noGravity = true; - } - npc.ai[0] = 2f; - npc.netUpdate = true; - } - } - - // Either teleport again or go to next AI state - else if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.alpha >= 255) - { - if (Main.zenithWorld) - { - SoundEngine.PlaySound(SoundID.Item68, npc.Center); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 pos = npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(0, 1), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(0, -1), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(1, 0), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - Projectile.NewProjectile(npc.GetSource_FromAI(), pos, new Vector2(-1, 0), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - if (brimmy.currentMode >= 1 && brimmy.currentMode <= 3) - { - int tornadoType = brimmy.currentMode == 3 ? ModContent.ProjectileType() : ProjectileID.SandnadoHostileMark; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), pos, Vector2.Zero, tornadoType, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - if (brimmy.currentMode == 2) - { - int healAmt = npc.lifeMax / 25; - if (healAmt > 0) - { - npc.life += healAmt; - npc.HealEffect(healAmt, true); - npc.netUpdate = true; - } - } - } - } - - npc.alpha -= 50; - if (npc.alpha <= 0) - { - npc.chaseable = true; - npc.ai[3] += 1f; - npc.alpha = 0; - if (npc.ai[3] >= 2f || phase2 || Main.getGoodWorld) - { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else - { - npc.ai[0] = 0f; - } - npc.netUpdate = true; - } - } - - // Float above target and fire projectiles - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.chaseable = true; - npc.rotation = npc.velocity.X * 0.04f; - - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; - - npc.ai[1] += 1f; - float divisor = expertMode ? (death ? 80f : revenge ? 45f : 50f) - (float)Math.Ceiling(10f * (1f - lifeRatio)) : 50f; - divisor -= 3f * enrageScale; - float divisor2 = divisor * 2f; - - if (npc.ai[1] % divisor == divisor - 1f) - { - float velocity = (death ? 7f : revenge ? 6f : 5f) + (2f * enrageScale) + (expertMode ? 3f * (1f - lifeRatio) : 0f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (brimmy.currentMode == 4) - { - type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SoundID.Item30, player.Center); - } - else - { - SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HellfireballSound, player.Center); - } - Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 5f, projectileVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y); - Main.projectile[proj].timeLeft = 240; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Main.projectile[proj].extraUpdates += 1; - } - - if (npc.ai[1] % divisor2 == divisor2 - 1f) - { - velocity = (death ? 5f : 4f) + 2f * enrageScale; - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - if (brimmy.currentMode == 4) - { - type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SoundID.Item21, player.Center); - } - else - { - SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.DartSound, player.Center); - } - projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - int numProj = death ? 8 : 4; - int spread = death ? 90 : 45; - if (Main.getGoodWorld) - { - numProj *= 3; - spread *= 2; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float rotation = MathHelper.ToRadians(spread); - float projectileVelocityToPass = velocity * 3f; - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj2 = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Main.projectile[proj2].extraUpdates += 1; - } - } - } - } - - if (npc.ai[1] >= divisor * (death ? 5f : 10f)) - { - npc.TargetClosest(); - npc.ai[0] = -1f; - npc.ai[1] = 3f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - - // Cocoon bullet hell - else if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.defense = npc.defDefense * 4; - - npc.chaseable = false; - npc.localAI[0] += 1f; - if (Main.getGoodWorld) - npc.localAI[0] += 2f; - if (expertMode) - npc.localAI[0] += 1f - lifeRatio; - npc.localAI[0] += enrageScale; - - if (npc.localAI[0] >= 120f) - { - npc.localAI[0] = 0f; - - float projectileSpeed = death ? 9f : revenge ? 8f : 6f; - projectileSpeed += 2f * enrageScale; - - Vector2 projectileVelocity = player.Center - npc.Center; - - float radialOffset = 0.2f; - float diameter = 80f; - - projectileVelocity = projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileSpeed; - - Vector2 velocity = projectileVelocity; - velocity = velocity.SafeNormalize(Vector2.UnitY); - velocity *= diameter; - - int totalProjectiles = 6; - float offsetAngle = (float)Math.PI * radialOffset; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int j = 0; j < totalProjectiles; j++) - { - float radians = j - (totalProjectiles - 1f) / 2f; - Vector2 offset = velocity.RotatedBy(offsetAngle * radians); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, projectileVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 300; - Main.projectile[proj].tileCollide = false; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Main.projectile[proj].extraUpdates += 1; - } - } - - totalProjectiles = 12; - float radians2 = MathHelper.TwoPi / totalProjectiles; - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - if (brimmy.currentMode == 4) - { - type = ModContent.ProjectileType(); - SoundEngine.PlaySound(SoundID.Item26, player.Center); - } - else - { - SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.ShellFireSound, player.Center); - } - double angleA = radians2 * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(0f, -projectileSpeed) : new Vector2(-velocityX, -projectileSpeed); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float projectileVelocityToPass = projectileSpeed * 3f; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Main.projectile[proj].extraUpdates += 1; - } - - if (death) - { - spinningPoint = npc.localAI[2] % 2f == 0f ? new Vector2(-velocityX, -projectileSpeed) : new Vector2(0f, -projectileSpeed); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians2 * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + vector255.SafeNormalize(Vector2.UnitY) * 5f, vector255 * 0.75f, type, damage, 0f, Main.myPlayer, 1f, 0f, projectileVelocityToPass); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Main.projectile[proj].extraUpdates += 1; - } - } - } - - npc.localAI[2] += 1f; - } - - npc.velocity *= 0.95f; - npc.rotation = npc.velocity.X * 0.04f; - float playerLocation = npc.Center.X - player.Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; - - npc.ai[1] += 1f; - if (npc.ai[1] >= (death ? 240f : 300f)) - { - npc.TargetClosest(); - npc.ai[0] = -1f; - npc.ai[1] = 4f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] = 0f; - npc.netUpdate = true; - } - } - - // Laser beam attack - else if (npc.ai[0] == 5f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.chaseable = true; - - npc.defense = npc.defDefense * 2; - - Vector2 source = new Vector2(npc.Center.X + (npc.spriteDirection > 0 ? 34f : -34f), npc.Center.Y - 74f); - Vector2 aimAt = player.Center + player.velocity * 20f; - float aimResponsiveness = bossRush ? 0.05f : (npc.ai[2] == 1f || death) ? 0.1f : 0.25f; - - Vector2 aimVector = (aimAt - source).SafeNormalize(Vector2.UnitY); - if (aimVector.HasNaNs()) - aimVector = -Vector2.UnitY; - aimVector = (Vector2.Lerp(aimVector, npc.velocity.SafeNormalize(Vector2.UnitY), aimResponsiveness)).SafeNormalize(Vector2.UnitY); - aimVector *= 6f; - - Vector2 laserVelocity = aimVector.SafeNormalize(Vector2.UnitY); - if (laserVelocity.HasNaNs()) - laserVelocity = -Vector2.UnitY; - - calamityGlobalNPC.newAI[1] = laserVelocity.X; - calamityGlobalNPC.newAI[2] = laserVelocity.Y; - - // Rev = 190 + 165 = 355 - // Death = 165 - - npc.ai[1] += 1f; - if (npc.ai[1] >= 240f) - { - npc.TargetClosest(); - npc.ai[2] += 1f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; - if (npc.ai[2] >= (death ? 1f : 2f)) - { - npc.ai[0] = -1f; - npc.ai[1] = 5f; - npc.ai[2] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - else - { - npc.ai[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - else if (npc.ai[1] >= 180f) - { - npc.velocity *= 0.95f; - if (npc.ai[1] == 180f) - { - SoundEngine.PlaySound(SoundID.Item68, source); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 laserVelocity2 = new Vector2(npc.localAI[0], npc.localAI[1]); - laserVelocity2 = laserVelocity2.SafeNormalize(Vector2.UnitY); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - Projectile.NewProjectile(npc.GetSource_FromAI(), source, laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - if (Main.getGoodWorld) - Projectile.NewProjectile(npc.GetSource_FromAI(), source, -laserVelocity2, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - - if (Main.zenithWorld) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(-laserVelocity2.X, laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(laserVelocity2.X, -laserVelocity2.Y), type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - else - { - float playSoundTimer = 30f; - if (npc.ai[1] < 150f) - { - switch ((int)npc.ai[2]) - { - case 0: - npc.ai[1] += 0.5f; - break; - case 1: - npc.ai[1] += 1f; - playSoundTimer = 40f; - break; - } - if (death) - { - npc.ai[1] += 0.5f; - playSoundTimer += 10f; - } - } - - if (npc.ai[1] % playSoundTimer == 0f) - SoundEngine.PlaySound(SoundID.Item20, npc.Center); - - if (npc.ai[1] < 150f && calamityGlobalNPC.newAI[0] == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), source, laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - if (Main.getGoodWorld) - Projectile.NewProjectile(npc.GetSource_FromAI(), source, -laserVelocity, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - - if (Main.zenithWorld) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(-laserVelocity.X, laserVelocity.Y), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - Projectile.NewProjectile(npc.GetSource_FromAI(), source, new Vector2(laserVelocity.X, -laserVelocity.Y), ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - - calamityGlobalNPC.newAI[0] = 1f; - } - else - { - if (npc.ai[1] == 150f) - { - npc.localAI[0] = laserVelocity.X; - npc.localAI[1] = laserVelocity.Y; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, npc.localAI[0], npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); - if (Main.getGoodWorld) - Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, -npc.localAI[0], -npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); - - if (Main.zenithWorld) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, -npc.localAI[0], npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); - Projectile.NewProjectile(npc.GetSource_FromAI(), source.X, source.Y, npc.localAI[0], -npc.localAI[1], ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.whoAmI); - } - } - } - } - } - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityBossAIs/BumblebirbAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/BumblebirbAI.cs deleted file mode 100644 index 7ee45394c2..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/BumblebirbAI.cs +++ /dev/null @@ -1,1078 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class BumblebirbAI - { - public static void VanillaBumblebirbAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // 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(); - - Player player = Main.player[npc.target]; - - // Variables - float rotationMult = 3f; - float rotationAmt = 0.03f; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = npc.ai[0] == 3f || npc.ai[0] == 3.1f || npc.ai[0] == 3.2f; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - - // If target is outside the jungle for more than 5 seconds, enrage - if (!player.ZoneJungle) - { - if (npc.localAI[1] < CalamityGlobalNPC.biomeEnrageTimerMax) - npc.localAI[1] += 1f; - } - else - npc.localAI[1] = 0f; - - // If dragonfolly is off screen, enrage for the next couple attacks - if (Vector2.Distance(player.Center, npc.Center) > 1200f) - npc.localAI[2] = 2f; - - // Enrage scale - float enrageScale = death ? 1.5f : 1f; - if (npc.localAI[1] >= CalamityGlobalNPC.biomeEnrageTimerMax || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - - if (npc.localAI[2] > 0f || bossRush) - enrageScale += 1f; - - if (Main.getGoodWorld) - enrageScale += 0.5f; - - if (enrageScale > 3f) - enrageScale = 3f; - - // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) - { - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.2f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[0] != 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - npc.ForceNetUpdate(false); - } - - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f); - bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f) && expertMode; - - float birbSpawnPhaseTimer = 180f; - float newPhaseTimer = 180f; - bool phaseSwitchPhase = (phase2 && calamityGlobalNPC.newAI[0] < newPhaseTimer && calamityGlobalNPC.newAI[2] != 1f) || - (phase3 && calamityGlobalNPC.newAI[1] < newPhaseTimer && calamityGlobalNPC.newAI[3] != 1f); - - calamityGlobalNPC.DR = (phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !bossRush)) ? (bossRush ? 0.99f : 0.55f) : 0.1f; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !bossRush); - - int reducedSetDamage = (int)Math.Round(npc.defDamage * 0.5); - - if (phaseSwitchPhase) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - if (phase3) - { - calamityGlobalNPC.newAI[1] += 1f; - - // Sound - if (calamityGlobalNPC.newAI[1] == newPhaseTimer - 60f) - { - float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; - SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, npc.Center); - - if (Main.zenithWorld) - { - int spacing = 20; - int amt = 5; - SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < amt; i++) - { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.defDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); - } - } - } - } - - if (calamityGlobalNPC.newAI[1] >= newPhaseTimer) - { - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 1f; - calamityGlobalNPC.newAI[3] = 1f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.SyncExtraAI(); - npc.ForceNetUpdate(false); - } - } - else - { - calamityGlobalNPC.newAI[0] += 1f; - - // Sound - if (calamityGlobalNPC.newAI[0] == newPhaseTimer - 60f) - { - float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; - SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, npc.Center); - - if (Main.zenithWorld) - { - int spacing = 20; - int amt = 3; - SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < amt; i++) - { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.defDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); - } - } - } - } - - if (calamityGlobalNPC.newAI[0] >= newPhaseTimer) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[2] = 1f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.SyncExtraAI(); - npc.ForceNetUpdate(false); - } - } - - Vector2 follyTargetDirection = player.Center - npc.Center; - float follyTargetDistance = 4f + follyTargetDirection.Length() / 100f; - float follyVelocityMult = 25f; - follyTargetDirection.Normalize(); - follyTargetDirection *= follyTargetDistance; - npc.velocity = (npc.velocity * (follyVelocityMult - 1f) + follyTargetDirection) / follyVelocityMult; - return; - } - - // Max spawn amount - int maxBirbs = (CalamityWorld.LegendaryMode && revenge) ? 12 : revenge ? 3 : 2; - - // Variable for charging - float chargeDistance = 600f; - if (phase2) - chargeDistance -= 50f; - if (phase3) - chargeDistance -= 50f; - chargeDistance -= (enrageScale - 1f) * 100f; - - // Phase switch - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.Center.X < player.Center.X - 2f) - npc.direction = 1; - if (npc.Center.X > player.Center.X + 2f) - npc.direction = -1; - - // Direction and rotation - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt * 1.25f) / 10f; - - // Fly to target if target is too far away, otherwise get close to target and then slow down - Vector2 follyFlyTargetDirection = player.Center - npc.Center; - follyFlyTargetDirection.Y -= 200f; - if (follyFlyTargetDirection.Length() > 2800f) - { - npc.TargetClosest(); - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - else if (follyFlyTargetDirection.Length() > 240f) - { - float follyFlySpeed = 12f + (enrageScale - 1f) * 6f; - float follyFlyVelocityMult = 30f; - follyFlyTargetDirection.Normalize(); - follyFlyTargetDirection *= follyFlySpeed; - npc.velocity = (npc.velocity * (follyFlyVelocityMult - 1f) + follyFlyTargetDirection) / follyFlyVelocityMult; - } - else if (npc.velocity.Length() > 2f) - npc.velocity *= 0.95f; - else if (npc.velocity.Length() < 1f) - npc.velocity *= 1.05f; - - // Phase switch - npc.ai[1] += 1f; - if (npc.ai[1] >= 30f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - while (npc.ai[0] == 0f) - { - if (phase2) - npc.localAI[0] += 1f; - - if (npc.localAI[0] >= (phase3 ? 7 : 9)) - { - npc.TargetClosest(); - npc.ai[0] = 5f; - npc.localAI[0] = 0f; - - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - // Decrease amount of attacks until able to spawn small birbs again - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - } - else - { - int follyAttackPicker = phase2 ? Main.rand.Next(2) + 1 : Main.rand.Next(3); - if (phase3) - follyAttackPicker = 1; - - float featherVelocity = 2f + (enrageScale - 1f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - if (follyAttackPicker == 0 && npc.localAI[3] == 0f) - { - npc.TargetClosest(); - npc.ai[0] = 2f; - - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - // Birb will do at least 1 different attack before entering this phase again - npc.localAI[3] = 1f; - } - else if (follyAttackPicker == 1) - { - npc.TargetClosest(); - npc.ai[0] = 3f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - // Decrease amount of attacks until able to use other attacks again - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - - if (phase2 && npc.ai[3] == 0f) - { - npc.ai[3] = 3f; - SoundEngine.PlaySound(SoundID.Item102, player.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalProjectiles = 40; - float radians = MathHelper.TwoPi / totalProjectiles; - int distance = 800; - bool spawnRight = player.velocity.X > 0f; - for (int i = 0; i < totalProjectiles; i++) - { - if (Main.getGoodWorld) - { - if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - else - { - if (spawnRight) - { - if (i >= (int)(totalProjectiles * 0.125) && i <= (int)(totalProjectiles * 0.375)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - else - { - if (i >= (int)(totalProjectiles * 0.625) && i <= (int)(totalProjectiles * 0.875)) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - } - } - else - { - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - } - } - else if (NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && npc.localAI[3] == 0f) - { - npc.TargetClosest(); - npc.ai[0] = 4f; - - // Birb will do at least 2 different attacks before entering this phase again - npc.localAI[3] = 2f; - - // Decrease enraged attacks by 1 - if (npc.localAI[2] > 0f) - npc.localAI[2] -= 1f; - - if (npc.ai[3] == 0f) - { - npc.ai[3] = 3f; - SoundEngine.PlaySound(SoundID.Item102, player.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalProjectiles = phase2 ? 40 : 48; - - if (Main.getGoodWorld) - totalProjectiles *= 2; - - float radians = MathHelper.TwoPi / totalProjectiles; - int distance = phase2 ? 1200 : 1320; - - if (Main.getGoodWorld) - distance *= 2; - - bool spawnRight = player.velocity.X > 0f; - for (int i = 0; i < totalProjectiles; i++) - { - if (spawnRight) - { - if (i >= totalProjectiles / 2) - break; - - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - else - { - if (i >= totalProjectiles / 2) - { - Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -featherVelocity).RotatedBy(radians * i)) * distance; - Vector2 velocity = Vector2.Normalize(player.Center - spawnVector) * featherVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - } - else - { - // Decrease the feather variable, feathers can be used again if it's at 0 - if (npc.ai[3] > 0f) - npc.ai[3] -= 1f; - } - } - } - } - - npc.ForceNetUpdate(false); - npc.SyncExtraAI(); - } - } - - // Fly to target - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - Vector2 follyTargetDirection = player.Center - npc.Center; - if (follyTargetDirection.Length() < 800f) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - npc.ForceNetUpdate(false); - npc.SyncExtraAI(); - } - - float velocity = 14f + (enrageScale - 1f) * 4f; - float follyTargetDistance = velocity + follyTargetDirection.Length() / 100f; - float follyVelocityMult = 25f; - follyTargetDirection.Normalize(); - follyTargetDirection *= follyTargetDistance; - npc.velocity = (npc.velocity * (follyVelocityMult - 1f) + follyTargetDirection) / follyVelocityMult; - } - - // Fly towards target quickly - else if (npc.ai[0] == 2f) - { - // Set reduced damage - npc.damage = reducedSetDamage; - - if (npc.target < 0 || !player.active || player.dead) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - npc.ForceNetUpdate(false); - npc.SyncExtraAI(); - } - - if (player.Center.X - 10f < npc.Center.X) - npc.direction = -1; - else if (player.Center.X + 10f > npc.Center.X) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 1.25f) / 5f; - - Vector2 follyQuickFlyTargetDirection = player.Center - npc.Center; - follyQuickFlyTargetDirection.Y -= 20f; - npc.ai[2] += 0.0222222228f; - if (expertMode) - npc.ai[2] += 0.0166666675f; - - float velocity = 8f + (enrageScale - 1f) * 2f; - float follyQuickFlySpeed = velocity + npc.ai[2] + follyQuickFlyTargetDirection.Length() / 120f; - if (CalamityWorld.LegendaryMode && revenge) - follyQuickFlySpeed *= 2f; - - float follyQuickFlyVelMult = 20f; - follyQuickFlyTargetDirection.Normalize(); - follyQuickFlyTargetDirection *= follyQuickFlySpeed; - npc.velocity = (npc.velocity * (follyQuickFlyVelMult - 1f) + follyQuickFlyTargetDirection) / follyQuickFlyVelMult; - - npc.ai[1] += 1f; - if (npc.ai[1] >= ((CalamityWorld.LegendaryMode && revenge) ? 90f : 180f)) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - npc.ForceNetUpdate(false); - npc.SyncExtraAI(); - } - } - - // Line up charge - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - - Vector2 follyLineUpTargetDirection = player.Center - npc.Center; - follyLineUpTargetDirection.Y -= 12f; - if (npc.Center.X > player.Center.X) - follyLineUpTargetDirection.X += chargeDistance; - else - follyLineUpTargetDirection.X -= chargeDistance; - - float verticalDistanceGateValue = (phase3 ? 100f : 20f) + (enrageScale - 1f) * 20f; - if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance - 50f && Math.Abs(npc.Center.Y - player.Center.Y) < verticalDistanceGateValue) - { - npc.ai[0] = 3.1f; - npc.ai[1] = 0f; - - npc.ForceNetUpdate(false); - npc.SyncExtraAI(); - } - - npc.ai[1] += 0.0333333351f; - float velocity = 16f + (enrageScale - 1f) * 4f; - float follyLineUpSpeed = velocity + npc.ai[1]; - float follyLineUpVelMult = 4f; - follyLineUpTargetDirection.Normalize(); - follyLineUpTargetDirection *= follyLineUpSpeed; - npc.velocity = (npc.velocity * (follyLineUpVelMult - 1f) + follyLineUpTargetDirection) / follyLineUpVelMult; - } - - // Prepare to charge - else if (npc.ai[0] == 3.1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - - Vector2 follyChargePrepareTargetDirection = player.Center - npc.Center; - follyChargePrepareTargetDirection.Y -= 12f; - float follyChargePrepareSpeed = 28f + (enrageScale - 1f) * 4f; - float follyChargePrepareVelMult = 8f; - follyChargePrepareTargetDirection.Normalize(); - follyChargePrepareTargetDirection *= follyChargePrepareSpeed; - npc.velocity = (npc.velocity * (follyChargePrepareVelMult - 1f) + follyChargePrepareTargetDirection) / follyChargePrepareVelMult; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - npc.ai[1] += 1f; - if (npc.ai[1] > 10f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.velocity = follyChargePrepareTargetDirection; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.ai[0] = 3.2f; - npc.ai[1] = npc.direction; - - npc.ForceNetUpdate(false); - npc.SyncExtraAI(); - } - } - - // Charge - else if (npc.ai[0] == 3.2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 0.0333333351f; - float velocity = 28f + (enrageScale - 1f) * 4f; - npc.velocity.X = (velocity + npc.ai[2]) * npc.ai[1]; - - if ((npc.ai[1] > 0f && npc.Center.X > player.Center.X + (chargeDistance - 140f)) || (npc.ai[1] < 0f && npc.Center.X < player.Center.X - (chargeDistance - 140f))) - { - if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ForceNetUpdate(false); - } - else if (Math.Abs(npc.Center.X - player.Center.X) > chargeDistance + 200f) - { - npc.TargetClosest(); - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ForceNetUpdate(false); - } - } - - npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; - } - - // Birb spawn - else if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.ai[1] == 0f) - { - Vector2 destination2 = player.Center + new Vector2(0f, -200f); - Vector2 desiredVelocity2 = npc.SafeDirectionTo(destination2, -Vector2.UnitY) * 18f; - npc.SimpleFlyMovement(desiredVelocity2, 1.5f); - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - npc.ai[2] += 1f; - if (npc.Distance(player.Center) < 600f || npc.ai[2] >= 180f) - { - npc.ai[1] = 1f; - npc.ForceNetUpdate(false); - } - } - else - { - if (npc.ai[1] < 90f) - npc.velocity *= 0.95f; - else - npc.velocity *= 0.98f; - - if (npc.ai[1] == 90f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y /= 3f; - - npc.velocity.Y -= 3f; - } - - // Sound - if (npc.ai[1] == birbSpawnPhaseTimer - 60f) - { - float squawkpitch = Main.zenithWorld ? 1.3f : 0.25f; - SoundEngine.PlaySound(SoundID.DD2_BetsyScream with { Pitch = squawkpitch }, npc.Center); - - if (Main.zenithWorld) - { - int spacing = 30; - int amt = 3; - SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < amt; i++) - { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); - } - } - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - bool gfbSpawnFlag = CalamityWorld.LegendaryMode && revenge && (npc.ai[1] == 145f || npc.ai[1] == 150f || npc.ai[1] == 160f || npc.ai[1] == 165f); - bool spawnFlag = NPC.CountNPCS(ModContent.NPCType()) < maxBirbs && (npc.ai[1] == 140f || (revenge && npc.ai[1] == 155f) || npc.ai[1] == 170f || gfbSpawnFlag); - if (spawnFlag) - { - Vector2 follySpawnCenter = npc.Center + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 50f * (0.6f + Main.rand.NextFloat() * 0.4f); - if (Vector2.Distance(follySpawnCenter, player.Center) > 150f) - NPC.NewNPC(npc.GetSource_FromAI(), (int)follySpawnCenter.X, (int)follySpawnCenter.Y, ModContent.NPCType(), npc.whoAmI); - - npc.ForceNetUpdate(false); - } - } - - npc.ai[1] += 1f; - } - - if (npc.ai[1] >= birbSpawnPhaseTimer) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.ForceNetUpdate(false); - } - } - - // Spit homing aura sphere - else if (npc.ai[0] == 5f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - npc.velocity *= 0.98f; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - // Play sound - float aiGateValue = 120f; - if (npc.ai[1] == aiGateValue - 30f) - { - SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 follySpawnCenter = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; - float ai0 = (phase3 ? 2f : 0f) + (enrageScale - 1f); - if (ai0 > 3f) - ai0 = 3f; - - Projectile.NewProjectile(npc.GetSource_FromAI(), follySpawnCenter.X, follySpawnCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, ai0, npc.target + 1); - npc.ForceNetUpdate(false); - } - - if (Main.zenithWorld) - { - int spacing = 30; - int amt = 3; - SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, npc.Center - Vector2.UnitY * 300f); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < amt; i++) - { - Vector2 fireFrom = new Vector2(npc.Center.X + (spacing * i) - (spacing * amt / 2), npc.Center.Y - 900f); - Vector2 ai0 = npc.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); - } - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= aiGateValue) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ForceNetUpdate(false); - } - } - } - - public static void VanillaBumblebirb2AI(NPC npc, Mod mod, bool bossMinion) - { - Player player = Main.player[npc.target]; - - float rotationMult = 4f; - float rotationAmt = 0.04f; - - if (Vector2.Distance(player.Center, npc.Center) > 5600f) - { - if (npc.timeLeft > 5) - npc.timeLeft = 5; - } - - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt * 1.25f) / 10f; - - if (npc.ai[0] == 0f || npc.ai[0] == 1f) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type) - { - Vector2 otherSwarmerDirection = Main.npc[i].Center - npc.Center; - if (otherSwarmerDirection.Length() < (npc.width + npc.height)) - { - otherSwarmerDirection.Normalize(); - otherSwarmerDirection *= -0.1f; - npc.velocity += otherSwarmerDirection; - NPC nPC6 = Main.npc[i]; - nPC6.velocity -= otherSwarmerDirection; - } - } - } - } - - if (npc.target < 0 || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - npc.TargetClosest(true); - Vector2 swarmerTargetDist = Main.player[npc.target].Center - npc.Center; - if (Main.player[npc.target].dead || swarmerTargetDist.Length() > (bossMinion ? 5600f : 2800f)) - npc.ai[0] = -1f; - } - else - { - Vector2 swarmerCatchUpTargetDist = Main.player[npc.target].Center - npc.Center; - if (npc.ai[0] > 1f && swarmerCatchUpTargetDist.Length() > 3600f) - npc.ai[0] = 1f; - } - - if (npc.ai[0] == -1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 swarmerDespawnVelMult = new Vector2(0f, -8f); - npc.velocity = (npc.velocity * 21f + swarmerDespawnVelMult) / 10f; - return; - } - - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.TargetClosest(true); - npc.spriteDirection = npc.direction; - - Vector2 swarmerIdleTargetDist = Main.player[npc.target].Center - npc.Center; - if (swarmerIdleTargetDist.Length() > 2800f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else if (swarmerIdleTargetDist.Length() > 400f) - { - float swarmerIdleSpeed = (bossMinion ? 9f : 7f) + swarmerIdleTargetDist.Length() / 100f + npc.ai[1] / 15f; - swarmerIdleTargetDist.Normalize(); - swarmerIdleTargetDist *= swarmerIdleSpeed; - npc.velocity = (npc.velocity * 29f + swarmerIdleTargetDist) / 30f; - if (Main.getGoodWorld && !Main.zenithWorld) - npc.velocity *= 1.15f; - } - else if (npc.velocity.Length() > 2f) - npc.velocity *= 0.95f; - else if (npc.velocity.Length() < 1f) - npc.velocity *= 1.05f; - - npc.ai[1] += 1f; - if (npc.ai[1] >= (bossMinion ? 90f : 105f)) - { - npc.ai[1] = 0f; - npc.ai[0] = 2f; - } - } - else - { - if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.target < 0 || !Main.player[npc.target].active || Main.player[npc.target].dead) - npc.TargetClosest(true); - - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; - - Vector2 swarmerChargeTargetDist = Main.player[npc.target].Center - npc.Center; - if (swarmerChargeTargetDist.Length() < 800f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - - npc.ai[2] += 0.0166666675f; - float swarmerChargeSpeed = (bossMinion ? 12f : 9f) + npc.ai[2] + swarmerChargeTargetDist.Length() / 150f; - float swarmerChargeVelMult = 25f; - swarmerChargeTargetDist.Normalize(); - swarmerChargeTargetDist *= swarmerChargeSpeed; - npc.velocity = (npc.velocity * (swarmerChargeVelMult - 1f) + swarmerChargeTargetDist) / swarmerChargeVelMult; - if (Main.getGoodWorld && !Main.zenithWorld) - npc.velocity *= 1.15f; - - npc.ForceNetUpdate(); - - return; - } - - if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * rotationMult * 0.75f + npc.velocity.X * rotationAmt * 1.25f) / 8f; - - Vector2 swarmerDecelerateTargetDist = Main.player[npc.target].Center - npc.Center; - swarmerDecelerateTargetDist.Y -= 8f; - float swarmerDecelerateSpeed = bossMinion ? 18f : 14f; - float swarmerDecelerateVelMult = 8f; - swarmerDecelerateTargetDist.Normalize(); - swarmerDecelerateTargetDist *= swarmerDecelerateSpeed; - npc.velocity = (npc.velocity * (swarmerDecelerateVelMult - 1f) + swarmerDecelerateTargetDist) / swarmerDecelerateVelMult; - if (Main.getGoodWorld && !Main.zenithWorld) - npc.velocity *= 1.15f; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - npc.ai[1] += 1f; - if (npc.ai[1] > 10f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.velocity = swarmerDecelerateTargetDist; - if (Main.getGoodWorld && !Main.zenithWorld) - npc.velocity *= 1.15f; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.ai[0] = 2.1f; - npc.ai[1] = 0f; - } - } - else if (npc.ai[0] == 2.1f) - { - // Set damage - npc.damage = npc.defDamage; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else if (npc.velocity.X > 0f) - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - npc.velocity *= 1.01f; - - npc.ai[1] += 1f; - if (npc.ai[1] > 30f) - { - if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - return; - } - - if (npc.ai[1] > 60f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - } - } - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityBossAIs/CalamitasCloneAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/CalamitasCloneAI.cs deleted file mode 100644 index 7dfb5557da..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/CalamitasCloneAI.cs +++ /dev/null @@ -1,1405 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.CalClone; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using ReLogic.Utilities; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class CalamitasCloneAI - { - public static void VanillaCalamitasCloneAI(NPC npc, Mod mod, SlotId warn) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Emit light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); - - // Variables for increasing difficulty - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < 0.7f || death; - bool phase3 = lifeRatio < 0.35f; - bool phase4 = lifeRatio <= 0.1f && death; - - // Don't take damage during bullet hells - npc.dontTakeDamage = calamityGlobalNPC.newAI[2] > 0f; - - // Variable for live brothers - bool brotherAlive = false; - - // For seekers - CalamityGlobalNPC.calamitas = npc.whoAmI; - - // Seeker ring - if (calamityGlobalNPC.newAI[1] == 0f && phase3 && expertMode) - { - SoundEngine.PlaySound(SoundID.Item72, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int seekerAmt = death ? 10 : 5; - int seekerSpread = 360 / seekerAmt; - int seekerDistance = death ? 180 : 150; - for (int i = 0; i < seekerAmt; i++) - { - int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * seekerSpread) * seekerDistance)), (int)(npc.Center.Y + (Math.Cos(i * seekerSpread) * seekerDistance)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); - Main.npc[spawn].ai[0] = i * seekerSpread; - } - } - - string key = "Mods.CalamityMod.Status.Boss.CalamitasBossText3"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - calamityGlobalNPC.newAI[1] = 1f; - } - - // CIT 14SEP2024: Fixed bug where her phases would get offset by dealing a large amount of damage in a single hit to take her into a new phase. - // newAI[0] now starts at 1 and has 0.3 subtracted from it for each phase, instead of it storing her current health when she enters a new phase. - - // Do bullet hell or spawn brothers - if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) - calamityGlobalNPC.newAI[0] = 1f; - - // Bullet hells at 70% and 10%, brothers at 40% - if (npc.life > 0) - { - int calClonePhaseThreshold = (int)(npc.lifeMax * 0.3); - if (((npc.life + calClonePhaseThreshold) / (float)npc.lifeMax) < calamityGlobalNPC.newAI[0]) - { - calamityGlobalNPC.newAI[0] -= 0.3f; - if (calamityGlobalNPC.newAI[0] <= 0.1f) - { - SoundEngine.PlaySound(SoundID.Item109, npc.Center); - calamityGlobalNPC.newAI[2] = 2f; - - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - calamityGlobalNPC.newAI[3] = 0f; - - SpawnDust(); - } - else if (calamityGlobalNPC.newAI[0] <= 0.4f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); - } - - string key = "Mods.CalamityMod.Status.Boss.CalamitasBossText2"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - SpawnDust(); - } - else - { - SoundEngine.PlaySound(SoundID.Item109, npc.Center); - calamityGlobalNPC.newAI[2] = 1f; - - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - calamityGlobalNPC.newAI[3] = 0f; - - SpawnDust(); - } - } - } - - // Immunity if brothers are alive - if (CalamityGlobalNPC.cataclysm != -1) - { - if (Main.npc[CalamityGlobalNPC.cataclysm].active) - brotherAlive = true; - } - if (CalamityGlobalNPC.catastrophe != -1) - { - if (Main.npc[CalamityGlobalNPC.catastrophe].active) - brotherAlive = true; - } - - if (brotherAlive) - npc.dontTakeDamage = true; - - void SpawnDust() - { - int dustAmt = 50; - int random = 3; - - for (int j = 0; j < 10; j++) - { - random += j; - int dustAmtSpawned = 0; - int scale = random * 6; - float dustPositionX = npc.Center.X - (scale / 2); - float dustPositionY = npc.Center.Y - (scale / 2); - while (dustAmtSpawned < dustAmt) - { - float dustVelocityX = Main.rand.Next(-random, random); - float dustVelocityY = Main.rand.Next(-random, random); - float dustVelocityScalar = random * 2f; - float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - dustVelocity = dustVelocityScalar / dustVelocity; - dustVelocityX *= dustVelocity; - dustVelocityY *= dustVelocity; - int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position.X = npc.Center.X; - Main.dust[dust].position.Y = npc.Center.Y; - Main.dust[dust].position.X += Main.rand.Next(-10, 11); - Main.dust[dust].position.Y += Main.rand.Next(-10, 11); - Main.dust[dust].velocity.X = dustVelocityX; - Main.dust[dust].velocity.Y = dustVelocityY; - dustAmtSpawned++; - } - } - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Target variable - Player player = Main.player[npc.target]; - - float enrageScale = bossRush ? 1f : 0f; - if (Main.IsItDay() || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } - - // Rotation - Vector2 npcCenter = new Vector2(npc.Center.X, npc.position.Y + npc.height - 59f); - Vector2 lookAt = new Vector2(player.position.X - (player.width / 2), player.position.Y - (player.height / 2)); - Vector2 rotationVector = npcCenter - lookAt; - - // Boss Rush predictive charge rotation - if (npc.ai[1] == 4f && phase4 && bossRush) - { - // Velocity - float chargeVelocity = 30f; - chargeVelocity += 5f * enrageScale; - lookAt += Main.player[npc.target].velocity * 20f; - rotationVector = Vector2.Normalize(npcCenter - lookAt) * chargeVelocity; - } - - float rotation = (float)Math.Atan2(rotationVector.Y, rotationVector.X) + MathHelper.PiOver2; - if (rotation < 0f) - rotation += MathHelper.TwoPi; - else if (rotation > MathHelper.TwoPi) - rotation -= MathHelper.TwoPi; - - float rotationAmt = 0.1f; - if (npc.rotation < rotation) - { - if ((rotation - npc.rotation) > MathHelper.Pi) - npc.rotation -= rotationAmt; - else - npc.rotation += rotationAmt; - } - else if (npc.rotation > rotation) - { - if ((npc.rotation - rotation) > MathHelper.Pi) - npc.rotation += rotationAmt; - else - npc.rotation -= rotationAmt; - } - - if (npc.rotation > rotation - rotationAmt && npc.rotation < rotation + rotationAmt) - npc.rotation = rotation; - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > rotation - rotationAmt && npc.rotation < rotation + rotationAmt) - npc.rotation = rotation; - - // Despawn - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (SoundEngine.TryGetActiveSound(warn, out var warningSound) && warningSound.IsPlaying) - warningSound.Stop(); - - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[1] != 0f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.alpha = 0; - npc.netUpdate = true; - } - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - // Distance from destination where Cal Clone stops moving - float movementDistanceGateValue = 100f; - - // How fast Cal Clone moves to the destination - float baseVelocity = (expertMode ? 10f : 8.5f) * (npc.ai[1] == 4f ? 1.4f : 1f); - float baseAcceleration = (expertMode ? 0.18f : 0.155f) * (npc.ai[1] == 4f ? 1.4f : 1f); - baseVelocity += 4f * enrageScale; - baseAcceleration += 0.1f * enrageScale; - if (revenge) - { - baseVelocity += 1.5f * (1f - lifeRatio); - baseAcceleration += 0.03f * (1f - lifeRatio); - } - if (death) - { - baseVelocity += 1.5f * (1f - lifeRatio); - baseAcceleration += 0.03f * (1f - lifeRatio); - } - if (Main.getGoodWorld) - { - baseVelocity *= 1.15f; - baseAcceleration *= 1.15f; - } - - // What side Cal Clone should be on, relative to the target - int xPos = 1; - if (npc.Center.X < player.Center.X) - xPos = -1; - - // How far Cal Clone should be from the target - float averageDistance = 500f; - float chargeDistance = phase4 ? 300f : 400f; - - // This is where Cal Clone should be - Vector2 destination = (calamityGlobalNPC.newAI[2] > 0f || npc.ai[1] == 0f) ? new Vector2(player.Center.X, player.Center.Y - averageDistance) : - npc.ai[1] == 1f ? new Vector2(player.Center.X + averageDistance * xPos, player.Center.Y) : - new Vector2(player.Center.X + chargeDistance * xPos, player.Center.Y); - - // Add some random distance to the destination after certain attacks - if (npc.localAI[0] == 1f) - { - npc.localAI[0] = 0f; - npc.localAI[2] = Main.rand.Next(-50, 51); - npc.localAI[3] = Main.rand.Next(-300, 301); - npc.netUpdate = true; - } - - // Add a bit of randomness to the destination - if (death) - { - destination.X += npc.ai[1] == 0f ? npc.localAI[3] : npc.localAI[2]; - destination.Y += npc.ai[1] == 0f ? npc.localAI[2] : npc.localAI[3]; - } - - // How far Cal Clone is from where she's supposed to be - Vector2 distanceFromDestination = destination - npc.Center; - - // Movement - if (npc.ai[1] == 0f || npc.ai[1] == 1f || npc.ai[1] == 4f || calamityGlobalNPC.newAI[2] > 0f) - CalamityUtils.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity, baseAcceleration, true); - - // Bullet hell phase - if (calamityGlobalNPC.newAI[2] > 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (calamityGlobalNPC.newAI[3] < 900f) - { - calamityGlobalNPC.newAI[3] += 1f; - npc.dontTakeDamage = true; - npc.alpha = 255; - - float rotX = player.Center.X - npc.Center.X; - float rotY = player.Center.Y - npc.Center.Y; - npc.rotation = (float)Math.Atan2(rotY, rotX) - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (calamityGlobalNPC.newAI[2] == 2f) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (Main.zenithWorld) - type = ModContent.ProjectileType(); - - float gigaBlastFrequency = (Main.getGoodWorld ? 120f : expertMode ? 180f : 240f) - enrageScale * 15f; - float projSpeed = bossRush ? 6.25f : 5f; - if (calamityGlobalNPC.newAI[3] <= 300f) - { - if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); - } - else if (calamityGlobalNPC.newAI[3] <= 600f && calamityGlobalNPC.newAI[3] > 300f) - { - if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from right - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -projSpeed, 0f, type, damage, 0f, Main.myPlayer); - } - else if (calamityGlobalNPC.newAI[3] > 600f) - { - if (calamityGlobalNPC.newAI[3] % gigaBlastFrequency == 0f) // Blasts from top - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer); - } - } - } - - npc.ai[0] += 1f; - float hellblastGateValue = (expertMode ? 12f : 16f) - enrageScale; - if (npc.ai[0] >= hellblastGateValue) - { - npc.ai[0] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float projSpeed = bossRush ? 4.5f : 4f; - if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = distance == -1000f ? projSpeed : -projSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - - if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above - { - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right - { - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - else // Blasts from above, left, and right - { - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - } - } - - if (calamityGlobalNPC.newAI[3] == 900f - 360f) - warn = SoundEngine.PlaySound(CalamitasClone.BulletHellWarning, player.Center); - if (calamityGlobalNPC.newAI[3] > 900f - 360f) - { - if (SoundEngine.TryGetActiveSound(warn, out var warningSound) && warningSound.IsPlaying) - warningSound.Position = player.Center; - } - } - else - { - npc.ai[0] = 0f; - npc.ai[3] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - SoundEngine.PlaySound(CalamitasClone.BulletHellEnd, player.Center); - - // Prevent bullshit charge hits when second bullet hell ends. - if (phase4) - { - npc.ai[1] = 4f; - npc.ai[2] = -105f; - npc.TargetClosest(); - } - else - { - if (death) - { - int AIState = Main.rand.Next(3); - switch (AIState) - { - case 0: - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - case 1: - npc.ai[1] = 1f; - npc.ai[2] = 0f; - break; - case 2: - npc.ai[1] = 4f; - npc.ai[2] = -105f; - npc.TargetClosest(); - break; - } - } - else - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - if (death) - npc.localAI[0] = 1f; - } - - npc.netUpdate = true; - - for (int x = 0; x < Main.maxProjectiles; x++) - { - Projectile projectile = Main.projectile[x]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; - } - else if (projectile.type == ModContent.ProjectileType()) - { - projectile.ai[2] = 1f; - - if (projectile.timeLeft > 60) - projectile.timeLeft = 60; - } - } - } - } - - return; - } - else if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - { - if (calamityGlobalNPC.newAI[3] < 900f) - calamityGlobalNPC.newAI[3] += 1f; - else - calamityGlobalNPC.newAI[3] = 0f; - - npc.ai[0] += 1f; - float hellblastGateValue = 30f - enrageScale; - if (npc.ai[0] >= hellblastGateValue) - { - npc.ai[0] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float projSpeed = bossRush ? 5f : 4f; - if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f) - { - float distance = Main.rand.NextBool() ? -1000f : 1000f; - float velocity = distance == -1000f ? projSpeed : -projSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - - if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above - { - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right - { - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - else // Blasts from above, left, and right - { - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - Projectile.NewProjectile(npc.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); - } - } - } - } - - npc.alpha = npc.dontTakeDamage ? 255 : 0; - - // Float above target and fire hellfireballs - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] += 1f; - float phaseTimer = 400f - (death ? 120f * (1f - lifeRatio) : 0f); - if (npc.ai[2] >= phaseTimer || phase4) - { - if (death && !phase4 && Main.rand.NextBool() && !brotherAlive) - npc.ai[1] = 4f; - else - npc.ai[1] = 1f; - - npc.ai[2] = 0f; - if (death) - npc.localAI[0] = 1f; - - npc.netUpdate = true; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (!brotherAlive) - { - if (expertMode) - npc.localAI[1] += death ? 2f * (1f - lifeRatio) : 1f - lifeRatio; - if (revenge) - npc.localAI[1] += 0.5f; - } - - if (npc.localAI[1] >= (brotherAlive ? 180f : 120f)) - { - npc.localAI[1] = 0f; - SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HellfireballSound, npc.Center); - - float projectileVelocity = expertMode ? 14f : 12.5f; - projectileVelocity += 3f * enrageScale; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - bool shootPredictiveShot = CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool(); - Vector2 predictionVector = shootPredictiveShot ? player.velocity * 20f : Vector2.Zero; - Vector2 fireballVelocity = Vector2.Normalize(player.Center + predictionVector - npc.Center) * projectileVelocity; - Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, fireballVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y); - Main.projectile[proj].netUpdate = true; - } - } - } - - // Float to the side of the target and fire - else if (npc.ai[1] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (!brotherAlive) - { - if (revenge) - npc.localAI[1] += 0.5f; - if (expertMode) - npc.localAI[1] += 0.5f; - } - - if (npc.localAI[1] >= (brotherAlive ? 75f : 50f) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - npc.localAI[1] = 0f; - - float projectileVelocity = expertMode ? 12.5f : 11f; - projectileVelocity += 3f * enrageScale; - int type = brotherAlive ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 fireballVelocity = Vector2.Normalize(player.Center - npc.Center) * projectileVelocity; - Vector2 offset = Vector2.Normalize(fireballVelocity) * 40f; - - if (!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) - { - type = ModContent.ProjectileType(); - damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, fireballVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y); - } - else - { - float ai0 = type == ModContent.ProjectileType() ? 1f : player.position.X; - float ai1 = type == ModContent.ProjectileType() ? 0f : player.position.Y; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, fireballVelocity, type, damage, 0f, Main.myPlayer, ai0, ai1); - } - } - } - - npc.ai[2] += 1f; - float phaseTimer = 240f - (death ? 60f * (1f - lifeRatio) : 0f); - if (npc.ai[2] >= phaseTimer || phase4) - { - if (death && !phase4 && Main.rand.NextBool() && !brotherAlive) - npc.ai[1] = 0f; - else - npc.ai[1] = !brotherAlive && phase2 && revenge ? 4f : 0f; - - npc.ai[2] = 0f; - if (death) - npc.localAI[0] = 1f; - - npc.netUpdate = true; - } - } - else if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - SoundEngine.PlaySound(CalamitasClone.ChargeSound, npc.Center); - npc.rotation = rotation; - - float chargeVelocity = phase4 ? 30f : death ? 28f : 25f; - chargeVelocity += 5f * enrageScale; - - Vector2 vector = Vector2.Normalize(player.Center + (phase4 && bossRush ? player.velocity * 20f : Vector2.Zero) - npc.Center); - npc.velocity = vector * chargeVelocity; - - npc.ai[1] = 3f; - npc.netUpdate = true; - } - else if (npc.ai[1] == 3f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f; - - float chargeTime = phase4 ? 35f : death ? 40f : 45f; - if (npc.ai[2] >= chargeTime) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.9f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - { - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - // Leave behind slow hellblasts in Death Mode - if (Main.netMode != NetmodeID.MultiplayerClient && death && phase3 && npc.ai[2] % (phase4 ? 6f : 10f) == 0f) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 fireballVelocity = CalamityWorld.LegendaryMode ? Main.rand.NextVector2CircularEdge(0.02f, 0.02f) : npc.velocity * 0.01f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, fireballVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f); - } - } - - if (npc.ai[2] >= chargeTime + 10f) - { - if (!phase4) - npc.ai[3] += 1f; - - npc.ai[2] = 0f; - - npc.rotation = rotation; - npc.netUpdate = true; - - if (npc.ai[3] >= 2f) - { - npc.TargetClosest(); - npc.ai[1] = 0f; - npc.ai[3] = 0f; - return; - } - - npc.ai[1] = 4f; - } - } - else - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] += 1f; - if (npc.ai[2] >= (phase4 ? 15f : 30f)) - { - npc.ai[1] = 2f; - npc.ai[2] = 0f; - if (death) - npc.localAI[0] = 1f; - - npc.netUpdate = true; - } - } - } - - public static void VanillaCataclysmAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active) - { - if (npc.alpha < 255) - { - npc.velocity *= 0.9f; - - npc.alpha += 2; - if (npc.alpha > 255) - npc.alpha = 255; - - int dustAmount = (int)Math.Round(MathHelper.Lerp(1f, 5f, (255 - npc.alpha) / 255f)); - for (int i = 0; i < dustAmount; i++) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.LifeDrain, 0f, -1f, 90, default, Main.rand.NextFloat(0.5f, 2f)); - Main.dust[dust].noGravity = true; - Main.dust[dust].fadeIn = 1f; - } - } - else - npc.active = false; - - npc.active = false; - return; - } - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - CalamityGlobalNPC.cataclysm = npc.whoAmI; - - // Emit light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); - - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - float enrageScale = bossRush ? 1f : 0f; - if (Main.IsItDay() || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } - - float calCloneBroPlayerXDist = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); - float calCloneBroPlayerYDist = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); - float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2; - if (calCloneBroRotation < 0f) - calCloneBroRotation += MathHelper.TwoPi; - else if (calCloneBroRotation > MathHelper.TwoPi) - calCloneBroRotation -= MathHelper.TwoPi; - - float calCloneBroRotationSpeed = 0.15f; - if (npc.rotation < calCloneBroRotation) - { - if ((calCloneBroRotation - npc.rotation) > MathHelper.Pi) - npc.rotation -= calCloneBroRotationSpeed; - else - npc.rotation += calCloneBroRotationSpeed; - } - else if (npc.rotation > calCloneBroRotation) - { - if ((npc.rotation - calCloneBroRotation) > MathHelper.Pi) - npc.rotation += calCloneBroRotationSpeed; - else - npc.rotation -= calCloneBroRotationSpeed; - } - - if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) - npc.rotation = calCloneBroRotation; - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) - npc.rotation = calCloneBroRotation; - - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[1] != 0f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - return; - } - } - - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - - float calCloneBroProjAttackMaxSpeed = 5f; - float calCloneBroProjAttackAccel = 0.1f; - calCloneBroProjAttackMaxSpeed += 2f * enrageScale; - calCloneBroProjAttackAccel += 0.06f * enrageScale; - - if (Main.getGoodWorld) - { - calCloneBroProjAttackMaxSpeed *= 1.15f; - calCloneBroProjAttackAccel *= 1.15f; - } - - int calCloneBroProjAttackDirection = 1; - if (npc.position.X + (npc.width / 2) < player.position.X + player.width) - calCloneBroProjAttackDirection = -1; - - Vector2 calCloneBroProjLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float calCloneBroProjTargetX = player.position.X + (player.width / 2) + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X; - float calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; - float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); - - if (expertMode) - { - if (calCloneBroProjTargetDist > 300f) - calCloneBroProjAttackMaxSpeed += 0.5f; - if (calCloneBroProjTargetDist > 400f) - calCloneBroProjAttackMaxSpeed += 0.5f; - if (calCloneBroProjTargetDist > 500f) - calCloneBroProjAttackMaxSpeed += 0.55f; - if (calCloneBroProjTargetDist > 600f) - calCloneBroProjAttackMaxSpeed += 0.55f; - if (calCloneBroProjTargetDist > 700f) - calCloneBroProjAttackMaxSpeed += 0.6f; - if (calCloneBroProjTargetDist > 800f) - calCloneBroProjAttackMaxSpeed += 0.6f; - } - - calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist; - calCloneBroProjTargetX *= calCloneBroProjTargetDist; - calCloneBroProjTargetY *= calCloneBroProjTargetDist; - - if (npc.velocity.X < calCloneBroProjTargetX) - { - npc.velocity.X += calCloneBroProjAttackAccel; - if (npc.velocity.X < 0f && calCloneBroProjTargetX > 0f) - npc.velocity.X += calCloneBroProjAttackAccel; - } - else if (npc.velocity.X > calCloneBroProjTargetX) - { - npc.velocity.X -= calCloneBroProjAttackAccel; - if (npc.velocity.X > 0f && calCloneBroProjTargetX < 0f) - npc.velocity.X -= calCloneBroProjAttackAccel; - } - if (npc.velocity.Y < calCloneBroProjTargetY) - { - npc.velocity.Y += calCloneBroProjAttackAccel; - if (npc.velocity.Y < 0f && calCloneBroProjTargetY > 0f) - npc.velocity.Y += calCloneBroProjAttackAccel; - } - else if (npc.velocity.Y > calCloneBroProjTargetY) - { - npc.velocity.Y -= calCloneBroProjAttackAccel; - if (npc.velocity.Y > 0f && calCloneBroProjTargetY < 0f) - npc.velocity.Y -= calCloneBroProjAttackAccel; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (240f - (death ? 120f * (1f - lifeRatio) : 0f))) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.target = 255; - npc.netUpdate = true; - } - - bool fireDelay = npc.ai[2] > 120f || npc.life < npc.lifeMax * 0.9; - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && fireDelay) - { - if (npc.localAI[2] == 0f) - SoundEngine.PlaySound(Cataclysm.FlamethrowerStart, npc.Center); - - npc.localAI[2] += 1f; - if (npc.localAI[2] > 30f) - { - npc.localAI[2] = 1f; - SoundEngine.PlaySound(Cataclysm.FlamethrowerLoop, npc.Center); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 3f; - if (revenge) - npc.localAI[1] += 1f; - - if (npc.localAI[1] > 12f) - { - npc.localAI[1] = 0f; - float calCloneBroProjSpeed = NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; - calCloneBroProjSpeed += enrageScale; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - calCloneBroProjLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X; - calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; - calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); - calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist; - calCloneBroProjTargetX *= calCloneBroProjTargetDist; - calCloneBroProjTargetY *= calCloneBroProjTargetDist; - calCloneBroProjTargetY += npc.velocity.Y * 0.5f; - calCloneBroProjTargetX += npc.velocity.X * 0.5f; - calCloneBroProjLocation.X -= calCloneBroProjTargetX; - calCloneBroProjLocation.Y -= calCloneBroProjTargetY; - Projectile.NewProjectile(npc.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - else - { - if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = npc.defDamage; - - SoundEngine.PlaySound(SoundID.Roar, npc.Center); - npc.rotation = calCloneBroRotation; - - float calCloneBroChargeSpeed = 14f + (death ? 4f * (1f - lifeRatio) : 0f); - calCloneBroChargeSpeed += 3f * enrageScale; - if (expertMode) - calCloneBroChargeSpeed += 2f; - if (revenge) - calCloneBroChargeSpeed += 2f; - if (Main.getGoodWorld) - calCloneBroChargeSpeed *= 1.25f; - - Vector2 calCloneBroChargeCenter = npc.Center; - float calCloneBroChargeTargetXDist = player.Center.X - calCloneBroChargeCenter.X; - float calCloneBroChargeTargetYDist = player.Center.Y - calCloneBroChargeCenter.Y; - float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist); - calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance; - npc.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance; - npc.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance; - npc.ai[1] = 2f; - - if (Main.zenithWorld) - { - SoundEngine.PlaySound(SupremeCalamitas.SupremeCalamitas.BrimstoneShotSound, npc.Center); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(ModContent.ProjectileType()); - if (bossRush) - damage /= 2; - - int totalProjectiles = bossRush ? 12 : death ? 10 : revenge ? 8 : expertMode ? 6 : 4; - float radians = MathHelper.TwoPi / totalProjectiles; - float velocity = 5f; - Vector2 spinningPoint = new Vector2(0f, -velocity); - float projectileVelocityToPass = velocity * 3f; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); - } - - for (int i = 0; i < 6; i++) - Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f); - } - return; - } - - if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); - if (expertMode) - npc.ai[2] += 0.25f; - if (revenge) - npc.ai[2] += 0.25f; - - if (npc.ai[2] >= 75f) - { - // Avoid cheap bullshit - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - - npc.velocity.X *= 0.93f; - npc.velocity.Y *= 0.93f; - - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - if (npc.ai[2] >= 105f) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.target = 255; - npc.rotation = calCloneBroRotation; - if (npc.ai[3] >= 3f) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - return; - } - npc.ai[1] = 1f; - } - } - } - } - - public static void VanillaCatastropheAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - if (CalamityGlobalNPC.calamitas < 0 || !Main.npc[CalamityGlobalNPC.calamitas].active) - { - if (npc.alpha < 255) - { - npc.velocity *= 0.9f; - - npc.alpha += 2; - if (npc.alpha > 255) - npc.alpha = 255; - - int dustAmount = (int)Math.Round(MathHelper.Lerp(1f, 5f, (255 - npc.alpha) / 255f)); - for (int i = 0; i < dustAmount; i++) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.LifeDrain, 0f, -1f, 90, default, Main.rand.NextFloat(0.5f, 2f)); - Main.dust[dust].noGravity = true; - Main.dust[dust].fadeIn = 1f; - } - } - else - npc.active = false; - - return; - } - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - CalamityGlobalNPC.catastrophe = npc.whoAmI; - - // Emit light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1f, 0f, 0f); - - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - Player player = Main.player[npc.target]; - - float enrageScale = bossRush ? 1f : 0f; - if (Main.IsItDay() || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } - - float calCloneBroPlayerXDist = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); - float calCloneBroPlayerYDist = npc.position.Y + npc.height - 59f - player.position.Y - (player.height / 2); - float calCloneBroRotation = (float)Math.Atan2(calCloneBroPlayerYDist, calCloneBroPlayerXDist) + MathHelper.PiOver2; - if (calCloneBroRotation < 0f) - calCloneBroRotation += MathHelper.TwoPi; - else if (calCloneBroRotation > MathHelper.TwoPi) - calCloneBroRotation -= MathHelper.TwoPi; - - float calCloneBroRotationSpeed = 0.15f; - if (npc.rotation < calCloneBroRotation) - { - if ((calCloneBroRotation - npc.rotation) > MathHelper.Pi) - npc.rotation -= calCloneBroRotationSpeed; - else - npc.rotation += calCloneBroRotationSpeed; - } - else if (npc.rotation > calCloneBroRotation) - { - if ((npc.rotation - calCloneBroRotation) > MathHelper.Pi) - npc.rotation += calCloneBroRotationSpeed; - else - npc.rotation -= calCloneBroRotationSpeed; - } - - if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) - npc.rotation = calCloneBroRotation; - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > calCloneBroRotation - calCloneBroRotationSpeed && npc.rotation < calCloneBroRotation + calCloneBroRotationSpeed) - npc.rotation = calCloneBroRotation; - - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - if (npc.ai[1] != 0f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - return; - } - } - - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - - float calCloneBroProjAttackMaxSpeed = 4.5f; - float calCloneBroProjAttackAccel = 0.2f; - calCloneBroProjAttackMaxSpeed += 2f * enrageScale; - calCloneBroProjAttackAccel += 0.1f * enrageScale; - - if (Main.getGoodWorld) - { - calCloneBroProjAttackMaxSpeed *= 1.15f; - calCloneBroProjAttackAccel *= 1.15f; - } - - int calCloneBroProjAttackDirection = 1; - if (npc.Center.X < player.Center.X) - calCloneBroProjAttackDirection = -1; - - Vector2 calCloneBroProjLocation = npc.Center; - float calCloneBroProjTargetX = player.Center.X + (calCloneBroProjAttackDirection * 180) - calCloneBroProjLocation.X; - float calCloneBroProjTargetY = player.Center.Y - calCloneBroProjLocation.Y; - float calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); - - if (expertMode) - { - if (calCloneBroProjTargetDist > 300f) - calCloneBroProjAttackMaxSpeed += 0.5f; - if (calCloneBroProjTargetDist > 400f) - calCloneBroProjAttackMaxSpeed += 0.5f; - if (calCloneBroProjTargetDist > 500f) - calCloneBroProjAttackMaxSpeed += 0.55f; - if (calCloneBroProjTargetDist > 600f) - calCloneBroProjAttackMaxSpeed += 0.55f; - if (calCloneBroProjTargetDist > 700f) - calCloneBroProjAttackMaxSpeed += 0.6f; - if (calCloneBroProjTargetDist > 800f) - calCloneBroProjAttackMaxSpeed += 0.6f; - } - - calCloneBroProjTargetDist = calCloneBroProjAttackMaxSpeed / calCloneBroProjTargetDist; - calCloneBroProjTargetX *= calCloneBroProjTargetDist; - calCloneBroProjTargetY *= calCloneBroProjTargetDist; - - if (npc.velocity.X < calCloneBroProjTargetX) - { - npc.velocity.X += calCloneBroProjAttackAccel; - if (npc.velocity.X < 0f && calCloneBroProjTargetX > 0f) - npc.velocity.X += calCloneBroProjAttackAccel; - } - else if (npc.velocity.X > calCloneBroProjTargetX) - { - npc.velocity.X -= calCloneBroProjAttackAccel; - if (npc.velocity.X > 0f && calCloneBroProjTargetX < 0f) - npc.velocity.X -= calCloneBroProjAttackAccel; - } - if (npc.velocity.Y < calCloneBroProjTargetY) - { - npc.velocity.Y += calCloneBroProjAttackAccel; - if (npc.velocity.Y < 0f && calCloneBroProjTargetY > 0f) - npc.velocity.Y += calCloneBroProjAttackAccel; - } - else if (npc.velocity.Y > calCloneBroProjTargetY) - { - npc.velocity.Y -= calCloneBroProjAttackAccel; - if (npc.velocity.Y > 0f && calCloneBroProjTargetY < 0f) - npc.velocity.Y -= calCloneBroProjAttackAccel; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (180f - (death ? 90f * (1f - lifeRatio) : 0f))) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.target = 255; - npc.netUpdate = true; - } - - bool fireDelay = npc.ai[2] > 120f || lifeRatio < 0.9f; - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && fireDelay) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] > 36f) - { - npc.localAI[2] = 0f; - SoundEngine.PlaySound(SoundID.Item34, npc.Center); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (revenge) - npc.localAI[1] += 0.5f; - - if (npc.localAI[1] > 50f) - { - npc.localAI[1] = 0f; - float calCloneBroProjSpeed = death ? 14f : 12f; - calCloneBroProjSpeed += 3f * enrageScale; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - calCloneBroProjLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - calCloneBroProjTargetX = player.position.X + (player.width / 2) - calCloneBroProjLocation.X; - calCloneBroProjTargetY = player.position.Y + (player.height / 2) - calCloneBroProjLocation.Y; - calCloneBroProjTargetDist = (float)Math.Sqrt(calCloneBroProjTargetX * calCloneBroProjTargetX + calCloneBroProjTargetY * calCloneBroProjTargetY); - calCloneBroProjTargetDist = calCloneBroProjSpeed / calCloneBroProjTargetDist; - calCloneBroProjTargetX *= calCloneBroProjTargetDist; - calCloneBroProjTargetY *= calCloneBroProjTargetDist; - calCloneBroProjTargetY += npc.velocity.Y * 0.5f; - calCloneBroProjTargetX += npc.velocity.X * 0.5f; - calCloneBroProjLocation.X -= calCloneBroProjTargetX; - calCloneBroProjLocation.Y -= calCloneBroProjTargetY; - Projectile.NewProjectile(npc.GetSource_FromAI(), calCloneBroProjLocation.X, calCloneBroProjLocation.Y, calCloneBroProjTargetX, calCloneBroProjTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - else - { - if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = npc.defDamage; - - SoundEngine.PlaySound(SoundID.Roar, npc.Center); - npc.rotation = calCloneBroRotation; - - float calCloneBroChargeSpeed = (NPC.AnyNPCs(ModContent.NPCType()) ? 12f : 16f) + (death ? 4f * (1f - lifeRatio) : 0f); - calCloneBroChargeSpeed += 4f * enrageScale; - if (expertMode) - calCloneBroChargeSpeed += 2f; - if (revenge) - calCloneBroChargeSpeed += 2f; - if (Main.getGoodWorld) - calCloneBroChargeSpeed *= 1.25f; - - Vector2 calCloneBroChargeCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float calCloneBroChargeTargetXDist = player.position.X + (player.width / 2) - calCloneBroChargeCenter.X; - float calCloneBroChargeTargetYDist = player.position.Y + (player.height / 2) - calCloneBroChargeCenter.Y; - float calCloneBroChargeTargetDistance = (float)Math.Sqrt(calCloneBroChargeTargetXDist * calCloneBroChargeTargetXDist + calCloneBroChargeTargetYDist * calCloneBroChargeTargetYDist); - calCloneBroChargeTargetDistance = calCloneBroChargeSpeed / calCloneBroChargeTargetDistance; - npc.velocity.X = calCloneBroChargeTargetXDist * calCloneBroChargeTargetDistance; - npc.velocity.Y = calCloneBroChargeTargetYDist * calCloneBroChargeTargetDistance; - npc.ai[1] = 2f; - - if (Main.zenithWorld) - { - SoundEngine.PlaySound(SupremeCalamitas.SupremeCalamitas.BrimstoneShotSound, npc.Center); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(ModContent.ProjectileType()); - if (bossRush) - damage /= 2; - - int totalProjectiles = bossRush ? 12 : death ? 10 : revenge ? 8 : expertMode ? 6 : 4; - float radians = MathHelper.TwoPi / totalProjectiles; - float velocity = 5f; - Vector2 spinningPoint = new Vector2(0f, -velocity); - float projectileVelocityToPass = velocity * 3f; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); - } - - for (int i = 0; i < 6; i++) - Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f); - } - return; - } - - if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f + (death ? 0.5f * (1f - lifeRatio) : 0f); - if (expertMode) - npc.ai[2] += 0.25f; - if (revenge) - npc.ai[2] += 0.25f; - - if (npc.ai[2] >= 60f) //50 - { - // Avoid cheap bullshit - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - - npc.velocity.X *= 0.93f; - npc.velocity.Y *= 0.93f; - - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - if (npc.ai[2] >= 90f) //80 - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = calCloneBroRotation; - if (npc.ai[3] >= 4f) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - return; - } - npc.ai[1] = 1f; - } - } - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs deleted file mode 100644 index cac49fe66f..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs +++ /dev/null @@ -1,614 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class CeaselessVoidAI - { - public static void VanillaCeaselessVoidAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - CalamityGlobalNPC.voidBoss = npc.whoAmI; - - // Percent life remaining - double lifeRatio = npc.life / (double)npc.lifeMax; - - // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - // Phases - bool phase2 = lifeRatio <= 0.7; - bool phase3 = lifeRatio <= 0.4; - bool phase4 = lifeRatio <= 0.1; - bool theBigSucc = npc.life / (double)npc.lifeMax <= 0.1; - bool succSoHardThatYouDie = npc.life / (double)npc.lifeMax <= 0.005; - - // Spawn Dark Energies - int darkEnergyAmt = death ? 6 : revenge ? 5 : expertMode ? 4 : 3; - if (phase2) - darkEnergyAmt += 1; - if (phase3) - darkEnergyAmt += 1; - if (phase4) - darkEnergyAmt += 1; - - if (Main.getGoodWorld) - darkEnergyAmt *= 2; - - // Spawn a few Dark Energies as soon as the fight starts - int spacing = 360 / darkEnergyAmt; - int distance2 = 10; - if (npc.ai[2] == 0f) - { - npc.ai[2] = 1f; - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); - } - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 0.5f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1.5f, 0f, 0f); - } - - // If there are any Dark Energies alive, change AI and don't take damage - bool anyDarkEnergies = NPC.AnyNPCs(ModContent.NPCType()); - bool movingDuringSuccPhase = npc.ai[3] == 0f; - npc.dontTakeDamage = anyDarkEnergies || theBigSucc || movingDuringSuccPhase; - - // 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(); - - Player player = Main.player[npc.target]; - - // Speed enrage - bool moveVeryFast = Vector2.Distance(npc.Center, player.Center) > 960f || (!player.ZoneDungeon && !bossRush && player.position.Y < Main.worldSurface * 16.0); - - // Despawn - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) - { - if (npc.velocity.Y > 3f) - npc.velocity.Y = 3f; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.timeLeft > 60) - npc.timeLeft = 60; - - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - float tileEnrageMult = (CalamityWorld.LegendaryMode && revenge) ? 1.5f : bossRush ? 1.375f : 1f; - npc.Calamity().CurrentlyEnraged = tileEnrageMult > 1f && !bossRush; - - // Set AI variable to be used by Dark Energies - npc.ai[1] = tileEnrageMult; - - // Increase projectile fire rate based on number of nearby active tiles - float projectileFireRateMultiplier = MathHelper.Lerp(0.5f, 1.5f, 1f - ((tileEnrageMult - 1f) / 0.5f)); - - // Succ attack - if (!anyDarkEnergies) - { - // This is here because it's used in multiple places - float suckDistance = (CalamityWorld.LegendaryMode && revenge) ? 2400f : bossRush ? 1920f : death ? 1600f : revenge ? 1440f : expertMode ? 1280f : 1040f; - - // Move closer to the target before trying to succ - if (movingDuringSuccPhase) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Vector2.Distance(npc.Center, player.Center) > 320f || !Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1)) - Movement(true); - else - npc.ai[3] = 1f; - } - else - { - // Set damage - npc.damage = npc.defDamage; - - // Use this to generate more and more dust in final phase - float finalPhaseDustRatio = 1f; - if (succSoHardThatYouDie) - { - finalPhaseDustRatio = 5f; - } - else if (theBigSucc) - { - float amount = (10f - (float)(npc.life / (double)npc.lifeMax) * 100f) / 10f; - finalPhaseDustRatio += MathHelper.Lerp(0f, 2f, amount); - } - - // Slow down - if (npc.velocity.Length() > 0.5f) - npc.velocity *= 0.8f; - else - npc.velocity = Vector2.Zero; - - // Move towards target again if they get outside the succ radius - float moveCloserGateValue = suckDistance * 0.75f; - if (Vector2.Distance(npc.Center, player.Center) > moveCloserGateValue) - npc.ai[3] = 0f; - - // Ceaseless Void sucks in dark energy in different patterns - // This attack also sucks in all players that are within reach of the succ - int dustRings = 3; - for (int h = 0; h < dustRings; h++) - { - float distanceDivisor = h + 1f; - float dustDistance = suckDistance / distanceDivisor; - int numDust = (int)(0.1f * MathHelper.TwoPi * dustDistance); - float angleIncrement = MathHelper.TwoPi / numDust; - Vector2 dustOffset = new Vector2(dustDistance, 0f); - dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); - - int var = (int)(dustDistance / finalPhaseDustRatio); - float dustVelocity = 24f / distanceDivisor * finalPhaseDustRatio; - for (int i = 0; i < numDust; i++) - { - if (Main.rand.NextBool(var)) - { - dustOffset = dustOffset.RotatedBy(angleIncrement); - int dust = Dust.NewDust(npc.Center, 1, 1, ModContent.DustType()); - Main.dust[dust].position = npc.Center + dustOffset; - Main.dust[dust].fadeIn = 1f; - Main.dust[dust].velocity = Vector2.Normalize(npc.Center - Main.dust[dust].position) * dustVelocity; - Main.dust[dust].scale = 3f - h; - } - } - } - - float succPower = 0.125f + finalPhaseDustRatio * 0.125f; - for (int i = 0; i < Main.maxPlayers; i++) - { - float distance = Vector2.Distance(Main.player[i].Center, npc.Center); - if (distance < suckDistance && Main.player[i].grappling[0] == -1) - { - if (Collision.CanHit(npc.Center, 1, 1, Main.player[i].Center, 1, 1)) - { - float distanceRatio = distance / suckDistance; - float multiplier = 1f - distanceRatio; - - if (Main.player[i].Center.X < npc.Center.X) - Main.player[i].velocity.X += succPower * multiplier; - else - Main.player[i].velocity.X -= succPower * multiplier; - } - } - } - - // Slowly die in final phase and then implode - // This phase lasts 20 seconds - if (theBigSucc && calamityGlobalNPC.newAI[1] % 60f == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int damageAmt = npc.lifeMax / 200; - npc.life -= damageAmt; - npc.DamageEffect(damageAmt); - } - - if (npc.life <= ((npc.lifeMax / 200) * 5) && !npc.ModNPC().playedbuildsound) - { - SoundEngine.PlaySound(CeaselessVoid.CeaselessVoid.BuildupSound, npc.Center); - npc.ModNPC().playedbuildsound = true; - } - - if (npc.life <= 0) - { - npc.life = 0; - npc.HitEffect(); - npc.checkDead(); - } - - npc.netUpdate = true; - } - - // Beam Portals - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (calamityGlobalNPC.newAI[1] == 0f) - { - int numBeamPortals = bossRush ? 4 : revenge ? 3 : 2; - float degrees = 360 / numBeamPortals; - float beamPortalDistance = bossRush ? 360f : death ? 400f : revenge ? 420f : expertMode ? 440f : 480f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < numBeamPortals; i++) - { - float ai1 = i * degrees; - Projectile.NewProjectile(npc.GetSource_FromAI(), player.Center.X + (float)(Math.Sin(i * degrees) * beamPortalDistance), player.Center.Y + (float)(Math.Cos(i * degrees) * beamPortalDistance), 0f, 0f, type, damage, 0f, Main.myPlayer, ai1, 0f); - } - } - } - - // Use this timer to lessen Dark Energy projectile rate of fire while Beam Portals are active - float beamPortalTimeLeft = 600f; - bool summonLessDarkEnergies = false; - if (calamityGlobalNPC.newAI[1] < beamPortalTimeLeft) - { - calamityGlobalNPC.newAI[1] += 1f; - summonLessDarkEnergies = true; - } - else if (theBigSucc) - calamityGlobalNPC.newAI[1] += 1f; - - // Suck in Dark Energy projectiles from far away - calamityGlobalNPC.newAI[3] += 1f; - float darkEnergySpiralGateValue = (summonLessDarkEnergies ? 24f : 12f) * projectileFireRateMultiplier; - if (calamityGlobalNPC.newAI[3] >= darkEnergySpiralGateValue) - { - calamityGlobalNPC.newAI[3] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - bool normalSpread = npc.localAI[0] % 2f == 0f; - float speed = 0.5f; - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); - float radialOffset = MathHelper.ToRadians(npc.localAI[1]); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 spawnVector = npc.Center + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; - Vector2 velocity = Vector2.Normalize(npc.Center - spawnVector) * speed; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - - npc.localAI[1] += 10f; - } - - // Summon some extra projectiles in Expert Mode - if (phase2 && expertMode) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] >= 60f * projectileFireRateMultiplier) - { - npc.localAI[2] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - bool normalSpread = npc.localAI[0] % 2f != 0f; - float speed = 2f; - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); - float radialOffset = MathHelper.ToRadians(npc.localAI[1] * 0.25f); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 spawnVector = npc.Center + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; - Vector2 velocity = Vector2.Normalize(npc.Center - spawnVector) * speed; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - - // Summon some extra projectiles in Revengeance Mode - if (phase4 && revenge) - { - npc.localAI[3] += 1f; - if (npc.localAI[3] >= 90f * projectileFireRateMultiplier) - { - npc.localAI[3] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - bool normalSpread = npc.localAI[0] % 2f == 0f; - float speed = 4f; - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalSpread ? new Vector2(0f, -speed) : new Vector2(-velocityX, -speed); - float radialOffset = MathHelper.ToRadians(npc.localAI[1] * 0.25f); - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 spawnVector = npc.Center + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; - Vector2 velocity = Vector2.Normalize(npc.Center - spawnVector) * speed; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnVector, velocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - } - } - else - { - // Avoid cheap bullshit - npc.damage = 0; - - Movement(false); - - // Count up all Dark Energy HP values - int totalDarkEnergyHP = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC darkEnergy = Main.npc[i]; - if (darkEnergy.active && darkEnergy.type == ModContent.NPCType()) - totalDarkEnergyHP += darkEnergy.life; - } - - // Destroy all Dark Energies if their total HP is below 20% - int darkEnergyMaxHP = bossRush ? DarkEnergy.MaxBossRushHP : DarkEnergy.MaxHP; - //These are still needed so that CV Dark energy despawn works properly - double HPBoost = CalamityServerConfig.Instance.BossHealthBoost * 0.01; - darkEnergyMaxHP += (int)(darkEnergyMaxHP * HPBoost); - - int totalDarkEnergiesSpawned = darkEnergyAmt * 3 + 2; - int totalDarkEnergyMaxHP = darkEnergyMaxHP * totalDarkEnergiesSpawned; - int succPhaseGateValue = (int)(totalDarkEnergyMaxHP * 0.2); - if (totalDarkEnergyHP < succPhaseGateValue) - { - SoundEngine.PlaySound(SoundID.NPCDeath44, npc.Center); - - // Kill all Dark Energies - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC darkEnergy = Main.npc[i]; - if (darkEnergy.active && darkEnergy.type == ModContent.NPCType()) - { - darkEnergy.HitEffect(); - darkEnergy.active = false; - darkEnergy.netUpdate = true; - } - } - - // Generate a dust explosion - int dustAmt = 30; - int random = 3; - for (int j = 0; j < 10; j++) - { - random += j * 2; - int dustAmtSpawned = 0; - int scale = random * 13; - float dustPositionX = npc.Center.X - (scale / 2); - float dustPositionY = npc.Center.Y - (scale / 2); - while (dustAmtSpawned < dustAmt) - { - float dustVelocityX = Main.rand.Next(-random, random); - float dustVelocityY = Main.rand.Next(-random, random); - float dustVelocityScalar = random * 2f; - float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - dustVelocity = dustVelocityScalar / dustVelocity; - dustVelocityX *= dustVelocity; - dustVelocityY *= dustVelocity; - int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position.X = npc.Center.X; - Main.dust[dust].position.Y = npc.Center.Y; - Main.dust[dust].position.X += Main.rand.Next(-10, 11); - Main.dust[dust].position.Y += Main.rand.Next(-10, 11); - Main.dust[dust].velocity.X = dustVelocityX; - Main.dust[dust].velocity.Y = dustVelocityY; - dustAmtSpawned++; - } - } - } - } - - // Basic movement towards a location - void Movement(bool succ) - { - float velocity = moveVeryFast ? 25f : bossRush ? 15f : ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; - float acceleration = (moveVeryFast ? 0.75f : bossRush ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f) + (float)(death ? 0.04f * (1D - lifeRatio) : 0f) * tileEnrageMult; - - // Increase speed dramatically in succ phase - if (succ) - { - velocity *= 2f; - acceleration *= 2f; - } - - if (Main.getGoodWorld) - { - velocity *= 1.15f; - acceleration *= 1.15f; - } - - Vector2 destination = player.Center; - - // Move between 8 different positions around the player, in order - float maxDistance = 320f; - Vector2 moveToOffset = succ ? Vector2.Zero : new Vector2(0f, -maxDistance); - if (!succ) - { - // Move to a new location every few seconds - calamityGlobalNPC.newAI[2] += 1f; - float newPositionGateValue = bossRush ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; - if (calamityGlobalNPC.newAI[2] > newPositionGateValue) - { - calamityGlobalNPC.newAI[2] = 0f; - - npc.ai[0] += 1f; - if (npc.ai[0] > 7f) - npc.ai[0] = 0f; - } - - switch ((int)npc.ai[0]) - { - case 0: - break; - case 1: - moveToOffset.X = -maxDistance; - break; - case 2: - moveToOffset.X = -maxDistance; - moveToOffset.Y = 0f; - break; - case 3: - moveToOffset.X = -maxDistance; - moveToOffset.Y = maxDistance; - break; - case 4: - moveToOffset.Y = maxDistance; - break; - case 5: - moveToOffset.X = maxDistance; - moveToOffset.Y = maxDistance; - break; - case 6: - moveToOffset.X = maxDistance; - moveToOffset.Y = 0f; - break; - case 7: - moveToOffset.X = maxDistance; - break; - } - } - - destination += moveToOffset; - - // How far Ceaseless Void is from where it's supposed to be - Vector2 distanceFromDestination = destination - npc.Center; - - // Movement - if (npc.Distance(destination) > maxDistance || succ) - { - CalamityUtils.SmoothMovement(npc, 0f, distanceFromDestination, velocity, acceleration, true); - } - else - { - // Slow down - if (npc.velocity.Length() > 0.5f) - npc.velocity *= 0.8f; - else - npc.velocity = Vector2.Zero; - } - } - - // Spawn more Dark Energies as the fight progresses - if (calamityGlobalNPC.newAI[0] == 0f && npc.life > 0) - calamityGlobalNPC.newAI[0] = npc.lifeMax; - - if (npc.life > 0) - { - int healthGateValue = (int)(npc.lifeMax * 0.3); - if ((npc.life + healthGateValue) < calamityGlobalNPC.newAI[0]) - { - npc.TargetClosest(); - calamityGlobalNPC.newAI[0] = npc.life; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.ai[3] = 0f; - npc.localAI[0] += 1f; - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - npc.localAI[3] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (phase4) - { - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 4f, 0f, 0f); - } - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 3f, 0f, 0f); - } - else if (phase3) - { - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1.5f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 3f, 0f, 0f); - } - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 0.5f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 2f, 0f, 0f); - } - else - { - for (int i = 0; i < darkEnergyAmt; i++) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 0f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 1f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(npc.Center.Y + (Math.Cos(i * spacing) * distance2)), ModContent.NPCType(), npc.whoAmI, i * spacing, 2f, 0f, 0f); - } - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 1.5f, 0f, 0f); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + (Math.Sin(0) * distance2)), (int)(npc.Center.Y + (Math.Cos(0) * distance2)), ModContent.NPCType(), npc.whoAmI, 0f, 2.5f, 0f, 0f); - } - } - - // Despawn potentially hazardous projectiles when entering a new phase - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile projectile = Main.projectile[i]; - if (projectile.active) - { - if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 30) - projectile.timeLeft = 30; - } - } - } - } - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs deleted file mode 100644 index abd55657ee..0000000000 --- a/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs +++ /dev/null @@ -1,1657 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs -{ - public static class OldDukeAI - { - public static void VanillaOldDukeAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - OldDuke.OldDuke modNPC = npc.ModNPC(); - - npc.Calamity().canBreakPlayerDefense = true; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Variables - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - float exhaustionGateValue = 360f; - if (Main.getGoodWorld) - exhaustionGateValue *= 0.5f; - - float numberOfAttacksBeforeExhaustion = 12f; - float exhaustionIncreasePerAttack = exhaustionGateValue * (1f / numberOfAttacksBeforeExhaustion); - bool exhausted = calamityGlobalNPC.newAI[1] == 1f; - bool phase2 = lifeRatio <= (death ? 0.8f : revenge ? 0.7f : 0.5f); - bool phase3 = lifeRatio <= (death ? 0.5f : (revenge ? 0.35f : 0.2f)) && expertMode; - bool phase2AI = npc.ai[0] > 4f; - bool phase3AI = npc.ai[0] > 9f; - bool charging = npc.ai[3] < 10f; - float pie = (float)Math.PI; - - if (calamityGlobalNPC.newAI[0] >= exhaustionGateValue) - calamityGlobalNPC.newAI[1] = 1f; - - float alphaScale = (255 - npc.alpha) / 255f; - float redLight = (phase3AI ? 0.4f : phase2AI ? 0.64f : 0.88f) * alphaScale; - float greenLight = (phase3AI ? 1.2f : phase2AI ? 0.8f : 0.4f) * alphaScale; - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), redLight, greenLight, 0f); - - if (CalamityServerConfig.Instance.BossesStopWeather) - CalamityWorld.StopRain(); - else if (!Main.raining && !BossRushEvent.BossRushActive) - CalamityWorld.StartRain(); - - // Adjust stats - int setDamage = npc.defDamage; - calamityGlobalNPC.DR = exhausted ? 0f : 0.5f; - npc.defense = exhausted ? 0 : npc.defDefense; - if (phase3AI) - { - setDamage = (int)Math.Round(setDamage * 1.2); - npc.defense = exhausted ? 0 : npc.defDefense - 40; - } - else if (phase2AI) - { - setDamage = (int)Math.Round(setDamage * 1.1); - npc.defense = exhausted ? 0 : npc.defDefense - 20; - } - - int idlePhaseTimer = expertMode ? 55 : 60; - float idlePhaseAcceleration = expertMode ? 0.75f : 0.7f; - float idlePhaseVelocity = expertMode ? 14f : 13f; - if (phase3AI) - { - idlePhaseAcceleration = expertMode ? 0.6f : 0.55f; - idlePhaseVelocity = expertMode ? 12f : 11f; - } - else if (phase2AI & charging) - { - idlePhaseAcceleration = expertMode ? 0.8f : 0.75f; - idlePhaseVelocity = expertMode ? 15f : 14f; - } - - int chargeTime = expertMode ? 34 : 36; - float chargeVelocity = expertMode ? 20f : 19f; - if (phase3AI) - { - chargeTime = expertMode ? 28 : 30; - chargeVelocity = expertMode ? 26f : 25f; - } - else if (charging & phase2AI) - { - chargeTime = expertMode ? 31 : 33; - chargeVelocity = expertMode ? 24f : 23f; - } - - if (bossRush) - { - idlePhaseTimer = 35; - idlePhaseAcceleration *= 1.25f; - idlePhaseVelocity *= 1.2f; - chargeTime -= 3; - chargeVelocity *= 1.25f; - } - else if (death) - { - idlePhaseTimer = 51; - idlePhaseAcceleration *= 1.05f; - idlePhaseVelocity *= 1.05f; - chargeTime -= 2; - chargeVelocity *= 1.1f; - } - else if (revenge) - { - idlePhaseTimer = 53; - idlePhaseAcceleration *= 1.025f; - idlePhaseVelocity *= 1.025f; - chargeTime -= 1; - chargeVelocity *= 1.05f; - } - - // The dumbest thing to ever exist - if (CalamityWorld.LegendaryMode && revenge) - chargeVelocity *= 1.25f; - - if (exhausted) - idlePhaseVelocity *= 0.25f; - - // Variables - int maxToothBallBelches = bossRush ? 5 : death ? 4 : 3; - int toothBallBelchPhaseDivisor = bossRush ? 24 : death ? 30 : 40; - int toothBallBelchPhaseTimer = toothBallBelchPhaseDivisor * maxToothBallBelches; - float toothBallBelchPhaseAcceleration = bossRush ? 0.95f : death ? 0.6f : 0.55f; - float toothBallBelchPhaseVelocity = bossRush ? 14f : death ? 10f : 9f; - float toothBallFinalVelocity = death ? 14f : revenge ? 13f : 12f; - float goreVelocityX = death ? 8f : revenge ? 7.5f : expertMode ? 7f : 6f; - float goreVelocityY = death ? 10.5f : revenge ? 10f : expertMode ? 9.5f : 8f; - float sharkronVelocity = bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; - int attackTimer = 120; - int phaseTransitionTimer = 180; - int teleportPauseTimer = 30; - int toothBallSpinPhaseDivisor = bossRush ? 27 : death ? 32 : 45; - int toothBallSpinTimer = maxToothBallBelches * toothBallSpinPhaseDivisor; - float spinTime = toothBallSpinTimer / 2f; - float toothBallSpinToothBallVelocity = bossRush ? 14f : death ? 9.5f : 9f; - float spinAttackSpeed = Main.zenithWorld ? 44f : 22f; - float spinSpeed = MathHelper.TwoPi / spinTime; - - Player player = Main.player[npc.target]; - - // Get target - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active) - { - npc.TargetClosest(); - player = Main.player[npc.target]; - npc.netUpdate = true; - } - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - // Despawn - if (player.dead || Vector2.Distance(player.Center, npc.Center) > 8800f) - { - npc.TargetClosest(); - - npc.velocity.Y -= 0.4f; - - if (npc.timeLeft > 10) - npc.timeLeft = 10; - - if (npc.timeLeft == 1) - { - AcidRainEvent.AccumulatedKillPoints = 0; - AcidRainEvent.HasTriedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - npc.timeLeft = 0; - } - - if (npc.ai[0] > 4f) - npc.ai[0] = 5f; - else - npc.ai[0] = 0f; - - npc.ai[2] = 0f; - } - - if (exhausted) - { - npc.Calamity().canBreakPlayerDefense = false; - - // Play exhausted sound - if (calamityGlobalNPC.newAI[0] % 60f == 0f && Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < 2800f) - SoundEngine.PlaySound(OldDuke.OldDuke.HuffSound with { Volume = OldDuke.OldDuke.HuffSound.Volume * 1.25f }, Main.LocalPlayer.Center); - - if (Main.zenithWorld) - { - float screenShakePower = 10 * Utils.GetLerpValue(800f, 0f, npc.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; - - if (calamityGlobalNPC.newAI[0] == exhaustionGateValue) - SoundEngine.PlaySound(SoundID.NPCDeath64 with { Pitch = SoundID.NPCDeath64.Pitch - 0.9f, Volume = SoundID.NPCDeath64.Volume + 0.4f }, player.Center); // fart - - if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[0] % 5f == 0f) - { - Vector2 dist = player.Center - npc.Center; - dist.Normalize(); - dist *= 3; - dist.X += Main.rand.NextFloat(-0.5f, 0.5f); - dist.Y += Main.rand.NextFloat(-0.5f, 0.5f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, -dist, type, damage, 0, Main.myPlayer); - } - } - - calamityGlobalNPC.newAI[0] -= bossRush ? 1.5f : 1f; - if (calamityGlobalNPC.newAI[0] <= 0f) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - } - } - - // Enrage variable - bool enrage = !bossRush && - (player.position.Y < 300f || player.position.Y > Main.worldSurface * 16.0 || - (player.position.X > 8000f && player.position.X < (Main.maxTilesX * 16 - 8000))); - - // Check for the flipped Abyss - if (Main.remixWorld) - { - enrage = !bossRush && - (player.position.Y < Main.UnderworldLayer * 16 * 0.8f || player.position.Y > Main.UnderworldLayer * 16 || - (player.position.X > 8000f && player.position.X < (Main.maxTilesX * 16 - 8000))); - } - - // Enrage - if (enrage) - { - if (npc.localAI[1] > 0f) - npc.localAI[1] -= 1f; - } - else - npc.localAI[1] = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = npc.localAI[1] <= 0f; - - npc.Calamity().CurrentlyEnraged = biomeEnraged || bossRush; - - // Increased DR while transitioning phases and not exhausted - if (!exhausted) - calamityGlobalNPC.DR = (npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f) ? (bossRush ? 0.99f : 0.75f) : 0.5f; - - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f; - - // Enrage - if (biomeEnraged) - { - toothBallBelchPhaseTimer = 60; - toothBallBelchPhaseDivisor = 20; - toothBallBelchPhaseAcceleration = 1f; - toothBallBelchPhaseVelocity = 15f; - goreVelocityX = 12f; - goreVelocityY = 16f; - sharkronVelocity = 20f; - idlePhaseTimer = 20; - idlePhaseAcceleration = 1.2f; - idlePhaseVelocity = 20f; - chargeTime = 25; - chargeVelocity += 8f; - toothBallSpinPhaseDivisor = 24; - toothBallSpinToothBallVelocity = 15f; - setDamage *= 2; - npc.defense = npc.defDefense * 3; - } - - // The dumbest thing to ever exist - if (CalamityWorld.LegendaryMode && revenge) - chargeTime *= 2; - - // Set variables for spawn effects - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - npc.alpha = 255; - npc.rotation = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = -1f; - npc.netUpdate = true; - } - } - - // Rotation - float rateOfRotation = 0.04f; - if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 7f || npc.ai[0] == 14f) - rateOfRotation = 0f; - if (npc.ai[0] == 3f || npc.ai[0] == 4f) - rateOfRotation = 0.01f; - if (npc.ai[0] == 8f || npc.ai[0] == 13f) - rateOfRotation = 0.05f; - - Vector2 rotationVector = player.Center - npc.Center; - if (calamityGlobalNPC.newAI[1] != 1f && !player.dead) - { - // Rotate to show direction of predictive charge - if (npc.ai[0] == 0f && !phase2) - { - if (npc.ai[3] < 6f) - { - rateOfRotation = 0.1f; - rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - npc.Center) * chargeVelocity; - } - } - else if (npc.ai[0] == 5f && !phase3) - { - if (npc.ai[3] < 4f) - { - rateOfRotation = 0.1f; - rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - npc.Center) * chargeVelocity; - } - } - else if (npc.ai[0] == 10f) - { - if (npc.ai[3] < 8f && npc.ai[3] != 1f && npc.ai[3] != 4f) - { - rateOfRotation = 0.1f; - rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - npc.Center) * chargeVelocity; - } - } - } - - float dukeRotationSpeed = (float)Math.Atan2(rotationVector.Y, rotationVector.X); - if (npc.spriteDirection == 1) - dukeRotationSpeed += pie; - if (dukeRotationSpeed < 0f) - dukeRotationSpeed += MathHelper.TwoPi; - if (dukeRotationSpeed > MathHelper.TwoPi) - dukeRotationSpeed -= MathHelper.TwoPi; - if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f) - dukeRotationSpeed = 0f; - if (npc.ai[0] == 8f || npc.ai[0] == 13f) - dukeRotationSpeed = pie * 0.1666666667f * npc.spriteDirection; - - if (npc.rotation < dukeRotationSpeed) - { - if (dukeRotationSpeed - npc.rotation > pie) - npc.rotation -= rateOfRotation; - else - npc.rotation += rateOfRotation; - } - if (npc.rotation > dukeRotationSpeed) - { - if (npc.rotation - dukeRotationSpeed > pie) - npc.rotation += rateOfRotation; - else - npc.rotation -= rateOfRotation; - } - - if ((npc.ai[0] != 8f && npc.ai[0] != 13f) || npc.spriteDirection == 1) - { - if (npc.rotation > dukeRotationSpeed - rateOfRotation && npc.rotation < dukeRotationSpeed + rateOfRotation) - npc.rotation = dukeRotationSpeed; - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > dukeRotationSpeed - rateOfRotation && npc.rotation < dukeRotationSpeed + rateOfRotation) - npc.rotation = dukeRotationSpeed; - } - - // Alpha adjustments - if (npc.ai[0] != -1f && (npc.ai[0] < 9f || npc.ai[0] > 12f)) - { - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - else - npc.alpha -= 15; - - if (npc.alpha < 0) - npc.alpha = 0; - if (npc.alpha > 150) - npc.alpha = 150; - } - - // Spawn effects - if (npc.ai[0] == -1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - if (npc.Calamity().newAI[3] == 0f) - npc.velocity *= 0.98f; - - // Direction - int dukeFaceDirection = Math.Sign(player.Center.X - npc.Center.X); - if (dukeFaceDirection != 0) - { - npc.direction = dukeFaceDirection; - npc.spriteDirection = -npc.direction; - } - - // Alpha - if (npc.ai[2] > 20f) - { - if (npc.Calamity().newAI[3] == 0f) - npc.velocity.Y = -2f; - - npc.alpha -= 5; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - if (npc.alpha < 0) - npc.alpha = 0; - if (npc.alpha > 150) - npc.alpha = 150; - } - - // Spawn dust and play sound - if (npc.ai[2] == attackTimer - 30) - { - int dustAmt = 36; - for (int i = 0; i < dustAmt; i++) - { - Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt) + npc.Center; - Vector2 vector2 = dust - npc.Center; - int toxicDust = Dust.NewDust(dust + vector2, 0, 0, (int)CalamityDusts.SulphurousSeaAcid, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); - Main.dust[toxicDust].noGravity = true; - Main.dust[toxicDust].noLight = true; - Main.dust[toxicDust].velocity = Vector2.Normalize(vector2) * 3f; - } - - modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= 75) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - - // Phase 1 - else if (npc.ai[0] == 0f && !player.dead) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - if (npc.ai[1] == 0f) - npc.ai[1] = 500 * Math.Sign((npc.Center - player.Center).X); - - Vector2 phase1IdleSpeed = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(phase1IdleSpeed, idlePhaseAcceleration); - - // Rotation and direction - int dukeLookAt = Math.Sign(player.Center.X - npc.Center.X); - if (dukeLookAt != 0) - { - if (npc.ai[2] == 0f && dukeLookAt != npc.direction) - npc.rotation += pie; - - npc.direction = dukeLookAt; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - // Phase switch - if (calamityGlobalNPC.newAI[1] != 1f || (phase2 && !phase2AI)) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer || (phase2 && !phase2AI)) - { - int oldDukeAttackPicker = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - oldDukeAttackPicker = 1; - break; - case 6: - npc.ai[3] = 1f; - oldDukeAttackPicker = 2; - break; - case 7: - npc.ai[3] = 0f; - oldDukeAttackPicker = 3; - break; - } - - if (phase2) - oldDukeAttackPicker = 4; - - // Set velocity for charge - if (oldDukeAttackPicker == 1) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - // Velocity - Vector2 distanceVector = player.Center + player.velocity * 20f - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (dukeLookAt != 0) - { - npc.direction = dukeLookAt; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - // Tooth Balls - else if (oldDukeAttackPicker == 2) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Call sharks from the sides of the screen - else if (oldDukeAttackPicker == 3) - { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Go to phase 2 - else if (oldDukeAttackPicker == 4) - { - npc.ai[0] = 4f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - npc.netUpdate = true; - } - } - } - - // Charge - else if (npc.ai[0] == 1f) - { - // Set damage - npc.damage = setDamage; - - // The dumbest thing to ever exist - if (CalamityWorld.LegendaryMode && revenge && npc.ai[2] % 10f == 0f) - { - // Rotation and direction - int dir = Math.Sign(player.Center.X - npc.Center.X); - if (dir != 0) - { - if (npc.ai[2] == 0f && dir != npc.direction) - npc.rotation += pie; - - npc.direction = dir; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - Vector2 distanceVector = player.Center + player.velocity * 20f - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (dir != 0) - { - npc.direction = dir; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - else - { - // Accelerate - npc.velocity *= 1.01f; - } - - // Spawn dust - int chargeDustAmt = 7; - for (int j = 0; j < chargeDustAmt; j++) - { - Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (chargeDustAmt / 2 - 1)) * pie / chargeDustAmt) + npc.Center; - Vector2 vector4 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int chargeDust = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, (int)CalamityDusts.SulphurousSeaAcid, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); - Main.dust[chargeDust].noGravity = true; - Main.dust[chargeDust].noLight = true; - Main.dust[chargeDust].velocity /= 4f; - Main.dust[chargeDust].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Tooth Ball belch - else if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - if (npc.ai[1] == 0f) - npc.ai[1] = 500 * Math.Sign((npc.Center - player.Center).X); - - Vector2 toothBallBelchPhaseSpeed = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * toothBallBelchPhaseVelocity; - npc.SimpleFlyMovement(toothBallBelchPhaseSpeed, toothBallBelchPhaseAcceleration); - - // Play sounds and spawn Tooth Balls - if (npc.ai[2] == 0f) - modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - - if (npc.ai[2] % toothBallBelchPhaseDivisor == 0f) - { - if (npc.ai[2] != 0f) - SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - - Vector2 toothBallDirection = Vector2.Normalize(player.Center - npc.Center) * (npc.width + 20) / 2f + npc.Center; - Vector2 toothBallVelocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * toothBallFinalVelocity; - Vector2 toothBallSpawnPos = new Vector2(toothBallDirection.X, toothBallDirection.Y + 45f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int toothBall = NPC.NewNPC(npc.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); - Main.npc[toothBall].velocity = Vector2.Normalize(toothBallVelocity) * npc.velocity.Length(); - Main.npc[toothBall].netUpdate = true; - } - - for (int i = 0; i < 50; i++) - { - int dustID; - switch (Main.rand.Next(6)) - { - case 0: - case 1: - case 2: - case 3: - dustID = (int)CalamityDusts.SulphurousSeaAcid; - break; - default: - dustID = DustID.Blood; - break; - } - - // Choose a random speed and angle to belch out the vomit - float dustSpeed = Main.rand.NextFloat(3.0f, 12.0f); - float angleRandom = 0.06f; - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(toothBallVelocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - - // Pick a size for the vomit particles - float scale = Main.rand.NextFloat(1f, 2f); - - // Actually spawn the vomit - int idx = Dust.NewDust(toothBallSpawnPos, 40, 40, dustID, dustVel.X, dustVel.Y, 0, default, scale); - Main.dust[idx].noGravity = true; - } - } - - // Direction - int toothBallLookAt = Math.Sign(player.Center.X - npc.Center.X); - if (toothBallLookAt != 0) - { - npc.direction = toothBallLookAt; - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - npc.spriteDirection = -npc.direction; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= toothBallBelchPhaseTimer) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Call sharks from the sides of the screen - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound and spawn sharks - if (npc.ai[2] == attackTimer - 30) - SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - - if (npc.ai[2] >= attackTimer - 90) - { - if (npc.ai[2] % 18f == 0f) - { - calamityGlobalNPC.newAI[2] += 100f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 900f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 900f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - - if (Main.getGoodWorld) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 1800f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 1800f), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - } - } - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= attackTimer) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Transition to phase 2 and call sharks from below - else if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Sound - if (npc.ai[2] == phaseTransitionTimer - 60) - modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - - if (npc.ai[2] >= phaseTransitionTimer - 60) - { - if (npc.ai[2] % 18f == 0f) - { - calamityGlobalNPC.newAI[2] += 150f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); - - if (Main.getGoodWorld) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); - } - } - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= phaseTransitionTimer) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Phase 2 - else if (npc.ai[0] == 5f && !player.dead) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - if (npc.ai[1] == 0f) - npc.ai[1] = 500 * Math.Sign((npc.Center - player.Center).X); - - Vector2 dukePhase2IdleSpeed = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -300f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(dukePhase2IdleSpeed, idlePhaseAcceleration); - - // Direction and rotation - int phase2FaceDirection = Math.Sign(player.Center.X - npc.Center.X); - if (phase2FaceDirection != 0) - { - if (npc.ai[2] == 0f && phase2FaceDirection != npc.direction) - npc.rotation += pie; - - npc.direction = phase2FaceDirection; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - // Phase switch - if (calamityGlobalNPC.newAI[1] != 1f || (phase3 && !phase3AI)) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer || (phase3 && !phase3AI)) - { - int phase2AttackPicker = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 1: - case 2: - case 3: - phase2AttackPicker = 1; - break; - case 4: - npc.ai[3] = 1f; - phase2AttackPicker = 2; - break; - case 5: - npc.ai[3] = 0f; - phase2AttackPicker = 3; - break; - } - - if (phase3) - phase2AttackPicker = 4; - - // Set velocity for charge - if (phase2AttackPicker == 1) - { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - // Velocity and rotation - Vector2 distanceVector = player.Center + player.velocity * 20f - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (phase2FaceDirection != 0) - { - npc.direction = phase2FaceDirection; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - // Set velocity for spin - else if (phase2AttackPicker == 2) - { - // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * spinAttackSpeed; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (phase2FaceDirection != 0) - { - npc.direction = phase2FaceDirection; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[0] = 7f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - else if (phase2AttackPicker == 3) - { - npc.ai[0] = 8f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Go to next phase - else if (phase2AttackPicker == 4) - { - npc.ai[0] = 9f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - npc.netUpdate = true; - } - } - } - - // Charge - else if (npc.ai[0] == 6f) - { - // Set damage - npc.damage = setDamage; - - // The dumbest thing to ever exist - if (CalamityWorld.LegendaryMode && revenge && npc.ai[2] % 8f == 0f) - { - // Rotation and direction - int dir = Math.Sign(player.Center.X - npc.Center.X); - if (dir != 0) - { - if (npc.ai[2] == 0f && dir != npc.direction) - npc.rotation += pie; - - npc.direction = dir; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - Vector2 distanceVector = player.Center + player.velocity * 20f - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (dir != 0) - { - npc.direction = dir; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - else - { - // Accelerate - npc.velocity *= 1.01f; - } - - // Spawn dust - int phase2ChargeDustAmt = 7; - for (int k = 0; k < phase2ChargeDustAmt; k++) - { - Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (phase2ChargeDustAmt / 2 - 1)) * pie / phase2ChargeDustAmt) + npc.Center; - Vector2 vector9 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int phase2ChargeDust = Dust.NewDust(arg_1A97_0 + vector9, 0, 0, (int)CalamityDusts.SulphurousSeaAcid, vector9.X * 2f, vector9.Y * 2f, 100, default, 1.4f); - Main.dust[phase2ChargeDust].noGravity = true; - Main.dust[phase2ChargeDust].noLight = true; - Main.dust[phase2ChargeDust].velocity /= 4f; - Main.dust[phase2ChargeDust].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Tooth Ball and Vortex spin - else if (npc.ai[0] == 7f) - { - // Set damage - npc.damage = 0; - - // Play sounds and spawn Tooth Balls and a Vortex - if (npc.ai[2] == 0f) - { - modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 vortexSpawn = npc.Center + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); - } - - if (npc.ai[2] % toothBallSpinPhaseDivisor == 0f) - { - if (npc.ai[2] != 0f) - SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - - Vector2 phase2ToothBallDirection = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; - Vector2 toothBallVelocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; - Vector2 toothBallSpawnPos = new Vector2(phase2ToothBallDirection.X, phase2ToothBallDirection.Y + 45f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int toothBall = NPC.NewNPC(npc.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); - Main.npc[toothBall].target = npc.target; - Main.npc[toothBall].velocity = Vector2.Normalize(toothBallVelocity) * toothBallSpinToothBallVelocity * 0.5f; - Main.npc[toothBall].netUpdate = true; - Main.npc[toothBall].ai[3] = 30f; - } - - for (int i = 0; i < 50; i++) - { - int dustID; - switch (Main.rand.Next(6)) - { - case 0: - case 1: - case 2: - case 3: - dustID = (int)CalamityDusts.SulphurousSeaAcid; - break; - default: - dustID = DustID.Blood; - break; - } - - // Choose a random speed and angle to belch out the vomit - float dustSpeed = Main.rand.NextFloat(3.0f, 12.0f); - float angleRandom = 0.06f; - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(toothBallVelocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - - // Pick a size for the vomit particles - float scale = Main.rand.NextFloat(1f, 2f); - - // Actually spawn the vomit - int idx = Dust.NewDust(toothBallSpawnPos, 40, 40, dustID, dustVel.X, dustVel.Y, 0, default, scale); - Main.dust[idx].noGravity = true; - } - } - - // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy(-(double)spinSpeed * (float)npc.direction); - npc.rotation -= spinSpeed * npc.direction; - - npc.ai[2] += 1f; - if (npc.ai[2] >= toothBallSpinTimer) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen - else if (npc.ai[0] == 8f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound - if (npc.ai[2] == attackTimer - 30) - { - SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 phase2GoreDirection = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalGore = Main.getGoodWorld ? 40 : 20; - for (int i = 0; i < totalGore; i++) - { - float velocityX = npc.direction * goreVelocityX * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); - float velocityY = goreVelocityY * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); - - if (Main.getGoodWorld) - { - velocityX *= Main.rand.NextFloat() + 0.5f; - velocityY *= Main.rand.NextFloat() + 0.5f; - } - - Projectile.NewProjectile(npc.GetSource_FromAI(), phase2GoreDirection.X, phase2GoreDirection.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - - if (npc.ai[2] >= attackTimer - 90) - { - if (npc.ai[2] % 18f == 0f) - { - calamityGlobalNPC.newAI[2] += 100f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float x = 900f - calamityGlobalNPC.newAI[2]; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - } - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= attackTimer) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Transition to phase 3 and summon sharks from above - else if (npc.ai[0] == 9f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Sound - if (npc.ai[2] == phaseTransitionTimer - 60) - modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - - if (npc.ai[2] >= phaseTransitionTimer - 60) - { - if (npc.ai[2] % 18f == 0f) - { - calamityGlobalNPC.newAI[2] += 200f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(npc.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, sharkronVelocity, 255); - - if (Main.getGoodWorld) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(npc.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); - } - } - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= phaseTransitionTimer) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Phase 3 - else if (npc.ai[0] == 10f && !player.dead) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Alpha - npc.alpha -= 25; - if (npc.alpha < 0) - npc.alpha = 0; - - // Movement location - if (npc.ai[1] == 0f) - npc.ai[1] = 500 * Math.Sign((npc.Center - player.Center).X); - - Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(-npc.ai[1], -300f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); - - // Rotation and direction - int phase3FaceDirection = Math.Sign(player.Center.X - npc.Center.X); - if (phase3FaceDirection != 0) - { - if (npc.ai[2] == 0f && phase3FaceDirection != npc.direction) - { - npc.rotation += pie; - for (int l = 0; l < npc.oldPos.Length; l++) - npc.oldPos[l] = Vector2.Zero; - } - - npc.direction = phase3FaceDirection; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - // Phase switch - if (calamityGlobalNPC.newAI[1] != 1f) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer) - { - int phase3AttackPicker = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 2: - case 3: - case 5: - case 6: - case 7: - phase3AttackPicker = 1; - break; - case 1: - case 8: - phase3AttackPicker = 2; - break; - case 4: - npc.ai[3] = 1f; - phase3AttackPicker = 3; - break; - case 9: - npc.ai[3] = 6f; - phase3AttackPicker = 4; - break; - } - - // Set velocity for charge - if (phase3AttackPicker == 1) - { - npc.ai[0] = 11f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - // Velocity and rotation - Vector2 distanceVector = player.Center + player.velocity * 20f - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (phase3FaceDirection != 0) - { - npc.direction = phase3FaceDirection; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - // Pause - else if (phase3AttackPicker == 2) - { - npc.ai[0] = 12f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - else if (phase3AttackPicker == 3) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Set velocity for spin - else if (phase3AttackPicker == 4) - { - // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * spinAttackSpeed; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (phase3FaceDirection != 0) - { - npc.direction = phase3FaceDirection; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[0] = 14f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - npc.netUpdate = true; - } - } - } - - // Charge - else if (npc.ai[0] == 11f) - { - // Set damage - npc.damage = setDamage; - - // The dumbest thing to ever exist - if (CalamityWorld.LegendaryMode && revenge && npc.ai[2] % 6f == 0f) - { - // Rotation and direction - int dir = Math.Sign(player.Center.X - npc.Center.X); - if (dir != 0) - { - if (npc.ai[2] == 0f && dir != npc.direction) - npc.rotation += pie; - - npc.direction = dir; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - - Vector2 distanceVector = player.Center + player.velocity * 20f - npc.Center; - npc.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - - // Direction - if (dir != 0) - { - npc.direction = dir; - - if (npc.spriteDirection == 1) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - else - { - // Accelerate - npc.velocity *= 1.01f; - } - - // Spawn dust - int phase3ChargeDustAmt = 7; - for (int m = 0; m < phase3ChargeDustAmt; m++) - { - Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (phase3ChargeDustAmt / 2 - 1)) * pie / phase3ChargeDustAmt) + npc.Center; - Vector2 vector11 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int phase3ChargeDust = Dust.NewDust(arg_2444_0 + vector11, 0, 0, (int)CalamityDusts.SulphurousSeaAcid, vector11.X * 2f, vector11.Y * 2f, 100, default, 1.4f); - Main.dust[phase3ChargeDust].noGravity = true; - Main.dust[phase3ChargeDust].noLight = true; - Main.dust[phase3ChargeDust].velocity /= 4f; - Main.dust[phase3ChargeDust].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Pause before teleport - else if (npc.ai[0] == 12f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Alpha - if (npc.alpha < 255 && npc.ai[2] >= teleportPauseTimer - 15f) - { - npc.alpha += 17; - if (npc.alpha > 255) - npc.alpha = 255; - } - - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound - if (npc.ai[2] == teleportPauseTimer / 2) - modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == teleportPauseTimer / 2) - { - // Teleport location - if (npc.ai[1] == 0f) - npc.ai[1] = 600 * Math.Sign((npc.Center - player.Center).X); - - // Rotation and direction - Vector2 center = player.Center + new Vector2(npc.ai[1], -300f); - Vector2 npcCenter = npc.Center = center; - int phase3TeleportFaceDirection = Math.Sign(player.Center.X - npcCenter.X); - if (phase3TeleportFaceDirection != 0) - { - if (npc.ai[2] == 0f && phase3TeleportFaceDirection != npc.direction) - { - npc.rotation += pie; - for (int n = 0; n < npc.oldPos.Length; n++) - npc.oldPos[n] = Vector2.Zero; - } - - npc.direction = phase3TeleportFaceDirection; - - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; - - npc.spriteDirection = -npc.direction; - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= teleportPauseTimer) - { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - - npc.ai[3] += 2f; - if (npc.ai[3] >= 9f) - npc.ai[3] = 0f; - - npc.netUpdate = true; - } - } - - // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen - else if (npc.ai[0] == 13f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - - // Play sound - if (npc.ai[2] == attackTimer - 30) - { - SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 phase3GoreDirection = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - int totalGore = Main.getGoodWorld ? 40 : 20; - for (int i = 0; i < totalGore; i++) - { - float velocityX = npc.direction * goreVelocityX * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); - float velocityY = goreVelocityY * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); - - if (Main.getGoodWorld) - { - velocityX *= Main.rand.NextFloat() + 0.5f; - velocityY *= Main.rand.NextFloat() + 0.5f; - } - - Projectile.NewProjectile(npc.GetSource_FromAI(), phase3GoreDirection.X, phase3GoreDirection.Y, velocityX, -velocityY, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - - if (npc.ai[2] >= attackTimer - 90) - { - if (npc.ai[2] % 18f == 0f) - { - calamityGlobalNPC.newAI[2] += 150f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float x = 900f - calamityGlobalNPC.newAI[2]; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - - if (Main.getGoodWorld) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X + x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X - x), (int)(npc.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, npc.whoAmI, 0f, 255); - } - } - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= attackTimer) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - calamityGlobalNPC.newAI[2] = 0f; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - // Tooth Ball and Vortex spin - else if (npc.ai[0] == 14f) - { - // Set damage - npc.damage = 0; - - // Play sounds and spawn Tooth Balls and a Vortex - if (npc.ai[2] == 0f) - { - modNPC.RoarSoundSlot = SoundEngine.PlaySound(OldDuke.OldDuke.RoarSound, npc.Center); - - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 vortexSpawn = npc.Center + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / MathHelper.TwoPi; - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), vortexSpawn, Vector2.Zero, type, damage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); - } - - if (npc.ai[2] % toothBallSpinPhaseDivisor == 0f) - { - if (npc.ai[2] != 0f) - SoundEngine.PlaySound(OldDuke.OldDuke.VomitSound, npc.Center); - - Vector2 phase3ToothBallDirection = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; - Vector2 toothBallVelocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * toothBallSpinToothBallVelocity; - Vector2 toothBallSpawnPos = new Vector2(phase3ToothBallDirection.X, phase3ToothBallDirection.Y + 45f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int toothBall = NPC.NewNPC(npc.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); - Main.npc[toothBall].target = npc.target; - Main.npc[toothBall].velocity = Vector2.Normalize(toothBallVelocity) * toothBallSpinToothBallVelocity * 0.5f; - Main.npc[toothBall].netUpdate = true; - Main.npc[toothBall].ai[3] = 60f; - } - - for (int i = 0; i < 50; i++) - { - int dustID; - switch (Main.rand.Next(6)) - { - case 0: - case 1: - case 2: - case 3: - dustID = (int)CalamityDusts.SulphurousSeaAcid; - break; - default: - dustID = DustID.Blood; - break; - } - - // Choose a random speed and angle to belch out the vomit - float dustSpeed = Main.rand.NextFloat(3.0f, 12.0f); - float angleRandom = 0.06f; - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(toothBallVelocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - - // Pick a size for the vomit particles - float scale = Main.rand.NextFloat(1f, 2f); - - // Actually spawn the vomit - int idx = Dust.NewDust(toothBallSpawnPos, 40, 40, dustID, dustVel.X, dustVel.Y, 0, default, scale); - Main.dust[idx].noGravity = true; - } - } - - // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy(-(double)spinSpeed * npc.direction); - npc.rotation -= spinSpeed * npc.direction; - - npc.ai[2] += 1f; - if (npc.ai[2] >= toothBallSpinTimer) - { - calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - - if (SoundEngine.TryGetActiveSound(modNPC.RoarSoundSlot, out var roarSound) && roarSound.IsPlaying) - { - roarSound.Position = npc.Center; - } - } - } -} diff --git a/NPCs/CalamityAIs/CalamityRegularEnemyAIs/CalamityRegularEnemyAI.cs b/NPCs/CalamityAIs/CalamityRegularEnemyAIs/CalamityRegularEnemyAI.cs deleted file mode 100644 index f0ec92c278..0000000000 --- a/NPCs/CalamityAIs/CalamityRegularEnemyAIs/CalamityRegularEnemyAI.cs +++ /dev/null @@ -1,742 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs -{ - public static class CalamityRegularEnemyAI - { - #region Gem Crawler AI - public static void GemCrawlerAI(NPC npc, Mod mod, float speedDetect, float speedAdditive) - { - int turnAroundDelay = 30; - bool unusedFlag = false; - bool isRunning = false; - bool shouldTurnAround = false; - if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction > 0) || (npc.velocity.X < 0f && npc.direction < 0))) - { - isRunning = true; - npc.ai[3] += 1f; - } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay) | isRunning) - { - npc.ai[3] += 1f; - shouldTurnAround = true; - } - else if (npc.ai[3] > 0f) - { - npc.ai[3] -= 1f; - } - if (npc.ai[3] > (float)(turnAroundDelay * 10)) - { - npc.ai[3] = 0f; - } - if (npc.justHit) - { - npc.ai[3] = 0f; - } - if (npc.ai[3] == (float)turnAroundDelay) - { - npc.netUpdate = true; - } - Vector2 npcPos = new Vector2(npc.Center.X, npc.Center.Y); - float xDist = Main.player[npc.target].Center.X - npcPos.X; - float yDist = Main.player[npc.target].Center.Y - npcPos.Y; - float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (targetDist < 200f && !shouldTurnAround) - { - npc.ai[3] = 0f; - } - if (npc.ai[3] < (float)turnAroundDelay) - { - npc.TargetClosest(true); - } - else - { - if (npc.velocity.X == 0f) - { - if (npc.velocity.Y == 0f) - { - npc.ai[0] += 1f; - if (npc.ai[0] >= 2f) - { - npc.direction *= -1; - npc.spriteDirection = -npc.direction; - npc.ai[0] = 0f; - } - } - } - else - { - npc.ai[0] = 0f; - } - npc.directionY = -1; - if (npc.direction == 0) - { - npc.direction = 1; - } - } - float maxVelocity = speedDetect; //5 - float acceleration = speedAdditive; //0.05 - if (!unusedFlag && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction > 0) || (npc.velocity.X >= 0f && npc.direction < 0))) - { - if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < maxVelocity && npc.direction == -1) - { - npc.velocity.X = npc.velocity.X + acceleration; - if (npc.velocity.X > maxVelocity) - { - npc.velocity.X = maxVelocity; - } - } - else if (npc.velocity.X > -maxVelocity && npc.direction == 1) - { - npc.velocity.X = npc.velocity.X - acceleration; - if (npc.velocity.X < -maxVelocity) - { - npc.velocity.X = -maxVelocity; - } - } - } - if (npc.velocity.Y >= 0f) - { - int faceDirection = 0; - if (npc.velocity.X < 0f) - { - faceDirection = -1; - } - if (npc.velocity.X > 0f) - { - faceDirection = 1; - } - Vector2 position = npc.position; - position.X += npc.velocity.X; - int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); - int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - faceDirection, y - 3].TileType])) - { - float npcBottom = (float)(y * 16); - if (Main.tile[x, y].IsHalfBlock) - { - npcBottom += 8f; - } - if (Main.tile[x, y - 1].IsHalfBlock) - { - npcBottom -= 8f; - } - if (npcBottom < position.Y + (float)npc.height) - { - float percentageTileRisen = position.Y + (float)npc.height - npcBottom; - if (percentageTileRisen <= 16.1f) - { - npc.gfxOffY += npc.position.Y + (float)npc.height - npcBottom; - npc.position.Y = npcBottom - (float)npc.height; - if (percentageTileRisen < 9f) - { - npc.stepSpeed = 1f; - } - else - { - npc.stepSpeed = 2f; - } - } - } - } - } - } - #endregion - - #region Dungeon Spirit AI - public static void DungeonSpiritAI(NPC npc, Mod mod, float speed, float rotation, bool lantern = false) - { - npc.TargetClosest(true); - Vector2 npcPos = new Vector2(npc.Center.X, npc.Center.Y); - float xDist = Main.player[npc.target].Center.X - npcPos.X; - float yDist = Main.player[npc.target].Center.Y - npcPos.Y; - float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - float homingSpeed = speed; - - if (lantern) - { - if (npc.localAI[0] < 85f) - { - homingSpeed = 0.1f; - targetDist = homingSpeed / targetDist; - xDist *= targetDist; - yDist *= targetDist; - npc.velocity = (npc.velocity * 100f + new Vector2(xDist, yDist)) / 101f; - npc.localAI[0] += 1f; - return; - } - - npc.dontTakeDamage = false; - } - - targetDist = homingSpeed / targetDist; - xDist *= targetDist; - yDist *= targetDist; - npc.velocity.X = (npc.velocity.X * 100f + xDist) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + yDist) / 101f; - - if (lantern) - { - npc.rotation = npc.velocity.X * 0.08f; - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - } - else - npc.rotation = (float)Math.Atan2((double)yDist, (double)xDist) + rotation; - } - #endregion - - #region Unicorn AI - public static void UnicornAI(NPC npc, Mod mod, bool spin, float bounciness, float speedDetect, float speedAdditive, float bouncy1 = -8.5f, float bouncy2 = -7.5f, float bouncy3 = -7f, float bouncy4 = -6f, float bouncy5 = -8f) - { - bool DogPhase1 = npc.type == ModContent.NPCType() && npc.life > npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); - bool DogPhase2 = npc.type == ModContent.NPCType() && npc.life <= npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); - int turnAroundDelay = 30; - bool isRunning = false; - bool shouldTurnAround = false; - if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) - { - isRunning = true; - npc.ai[3] += 1f; - } - int turnAroundDelayMult = DogPhase1 ? 10 : 4; - if (!DogPhase1) - { - bool noYVelocity = npc.velocity.Y == 0f; - for (int i = 0; i < Main.maxNPCs; i++) - { - 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 (npc.position.X < Main.npc[i].position.X) - { - npc.velocity.X -= 0.05f; - } - else - { - npc.velocity.X += 0.05f; - } - if (npc.position.Y < Main.npc[i].position.Y) - { - npc.velocity.Y -= 0.05f; - } - else - { - npc.velocity.Y += 0.05f; - } - } - } - if (noYVelocity) - { - npc.velocity.Y = 0f; - } - } - if (npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay || isRunning) - { - npc.ai[3] += 1f; - shouldTurnAround = true; - } - else if (npc.ai[3] > 0f) - { - npc.ai[3] -= 1f; - } - if (npc.ai[3] > (float)(turnAroundDelay * turnAroundDelayMult)) - { - npc.ai[3] = 0f; - } - if (npc.justHit) - { - npc.ai[3] = 0f; - } - if (npc.ai[3] == (float)turnAroundDelay) - { - npc.netUpdate = true; - } - Vector2 npcPos = new Vector2(npc.Center.X, npc.Center.Y); - float xDist = Main.player[npc.target].Center.X - npcPos.X; - float yDist = Main.player[npc.target].Center.Y - npcPos.Y; - float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (targetDist < 200f && !shouldTurnAround) - { - npc.ai[3] = 0f; - } - if (!DogPhase1) - { - if (npc.velocity.Y == 0f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) - { - npc.velocity.Y -= bounciness; - if (npc.type == ModContent.NPCType()) - { - SoundEngine.PlaySound(SoundID.Item14, npc.Center); - for (int k = 0; k < 10; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, -1f, 0, default, 1f); - } - if (Main.zenithWorld) - { - float screenShakePower = 2 * Utils.GetLerpValue(1300f, 0f, npc.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; - } - } - if (npc.type == ModContent.NPCType()) - { - SoundEngine.PlaySound(SoundID.NPCHit7, npc.Center); - } - if (DogPhase2) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Water, 0f, -1f, 0, default, 1f); - } - } - if (npc.type == ModContent.NPCType()) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Water, 0f, -1f, 0, default, 1f); - } - } - } - } - if (npc.ai[3] < (float)turnAroundDelay) - { - npc.TargetClosest(true); - } - else - { - if (npc.velocity.X == 0f) - { - if (npc.velocity.Y == 0f) - { - npc.ai[0] += 1f; - if (npc.ai[0] >= 2f) - { - npc.direction *= -1; - npc.spriteDirection = npc.direction; - npc.ai[0] = 0f; - } - } - } - else - { - npc.ai[0] = 0f; - } - npc.directionY = -1; - if (npc.direction == 0) - { - npc.direction = 1; - } - } - - if (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction < 0) || (npc.velocity.X >= 0f && npc.direction > 0)) - { - if (Math.Sign(npc.velocity.X) != npc.direction && !DogPhase1) - { - npc.velocity.X *= 0.92f; - } - float sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); - if (!Main.player[npc.target].ZoneSandstorm) - { - sandstormPush = 0f; - } - float maxVelocity = speedDetect; - float acceleration = speedAdditive; - if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < maxVelocity && npc.direction == 1) - { - npc.velocity.X += acceleration; - if (npc.velocity.X > maxVelocity) - { - npc.velocity.X = maxVelocity; - } - } - else if (npc.velocity.X > -maxVelocity && npc.direction == -1) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X < -maxVelocity) - { - npc.velocity.X = -maxVelocity; - } - } - } - if (npc.velocity.Y >= 0f) - { - int faceDirection = 0; - if (npc.velocity.X < 0f) - { - faceDirection = -1; - } - if (npc.velocity.X > 0f) - { - faceDirection = 1; - } - Vector2 position = npc.position; - position.X += npc.velocity.X; - int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); - int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - - // 21JAN2023: Ozzatron -- this is probably the single most unmaintainable if statement I've ever seen - // I have broken all the individual statements out even though I do not fully understand the code. - Tile t_xy = CalamityUtils.ParanoidTileRetrieval(x, y); - Tile t_xy1 = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - Tile t_xy2 = CalamityUtils.ParanoidTileRetrieval(x, y - 2); - Tile t_xy3 = CalamityUtils.ParanoidTileRetrieval(x, y - 3); - Tile t_xOffY3 = CalamityUtils.ParanoidTileRetrieval(x - faceDirection, y - 3); // 3 down, offset 1 in the direction of the NPC's movement - Tile t_xy4 = CalamityUtils.ParanoidTileRetrieval(x, y - 4); - bool positionCheck = (float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X; - bool tileSolidityCheck1 = t_xy.HasUnactuatedTile && !t_xy.TopSlope && !t_xy1.TopSlope && Main.tileSolid[t_xy.TileType] && !Main.tileSolidTop[t_xy.TileType]; - bool oneBelowIsSolidHalf = t_xy1.IsHalfBlock && t_xy1.HasUnactuatedTile; - bool canFallThrough = !t_xy1.HasUnactuatedTile || !Main.tileSolid[t_xy1.TileType] || Main.tileSolidTop[t_xy1.TileType] || (t_xy1.IsHalfBlock && (!t_xy4.HasUnactuatedTile || !Main.tileSolid[t_xy4.TileType] || Main.tileSolidTop[t_xy4.TileType])); - bool twoDownIsNonSolid = !t_xy2.HasUnactuatedTile || !Main.tileSolid[t_xy2.TileType] || Main.tileSolidTop[t_xy2.TileType]; - bool threeDownIsNonSolid = !t_xy3.HasUnactuatedTile || !Main.tileSolid[t_xy3.TileType] || Main.tileSolidTop[t_xy3.TileType]; - // Notice it doesn't check for platforms in ther offset position. This is why walking AIs twirl on 1-wide platforms in hellevators. They have to turn around before this check succeeds. - bool threeDownOffsetIsNonSolid = !t_xOffY3.HasUnactuatedTile || !Main.tileSolid[t_xOffY3.TileType]; - if (positionCheck && (tileSolidityCheck1 || oneBelowIsSolidHalf) && canFallThrough && twoDownIsNonSolid && threeDownIsNonSolid && threeDownOffsetIsNonSolid) - { - float tilePixelPosition = (float)(y * 16); - if (Main.tile[x, y].IsHalfBlock) - { - tilePixelPosition += 8f; - } - if (Main.tile[x, y - 1].IsHalfBlock) - { - tilePixelPosition -= 8f; - } - if (tilePixelPosition < position.Y + (float)npc.height) - { - float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; - if ((double)percentageTileRisen <= 16.1) - { - npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; - npc.position.Y = tilePixelPosition - (float)npc.height; - if (percentageTileRisen < 9f) - { - npc.stepSpeed = 1f; - } - else - { - npc.stepSpeed = 2f; - } - } - } - } - } - if (npc.velocity.Y == 0f) - { - int npcTileX = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); - int npcTileY = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - int spriteDirection = npc.spriteDirection; - spriteDirection *= -1; - if ((npc.velocity.X < 0f && spriteDirection == -1) || (npc.velocity.X > 0f && spriteDirection == 1)) - { - if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 2].TileType]) - { - if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 3].TileType]) - { - npc.velocity.Y = bouncy1; - npc.netUpdate = true; - } - else - { - npc.velocity.Y = bouncy2; - npc.netUpdate = true; - } - } - else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 1].TileType]) - { - npc.velocity.Y = bouncy3; - npc.netUpdate = true; - } - else if (npc.position.Y + (float)npc.height - (float)(npcTileY * 16) > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType]) - { - npc.velocity.Y = bouncy4; - npc.netUpdate = true; - } - else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > 3f) && (!Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + npc.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX + npc.direction, npcTileY + 3].TileType])) - { - npc.velocity.Y = bouncy5; - npc.netUpdate = true; - } - } - } - if (spin) - { - npc.rotation += npc.velocity.X * 0.05f; - npc.spriteDirection = -npc.direction; - } - } - #endregion - - #region Swimming AI - // Passiveness: - // 0 = Catfish, Flounder, Frogfish, Viperfish, Moray Eel, Laserfish - // 1 = Blinded Angler - // 2 = Prism-Back, Toxic Minnow - // 3 = Sea Minnow - public static void PassiveSwimmingAI(NPC npc, Mod mod, int passiveness, float detectRange, float xSpeed, float ySpeed, float speedLimitX, float speedLimitY, float rotation, bool spriteFacesLeft = true) - { - if (spriteFacesLeft) - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - else - npc.spriteDirection = (npc.direction > 0) ? -1 : 1; - - npc.noGravity = true; - if (npc.direction == 0) - npc.TargetClosest(); - - Player target = Main.player[npc.target]; - if (npc.justHit && passiveness != 3) - npc.chaseable = true; - - if (npc.wet) - { - bool hasWetTarget = npc.chaseable; - npc.TargetClosest(false); - target = Main.player[npc.target]; - - // Player detection behavior - if (passiveness != 2) - { - if (npc.type == ModContent.NPCType()) - { - if (target.wet && !target.dead) - { - hasWetTarget = true; - npc.chaseable = true; // Once the enemy has detected the player, let minions fuck it up - } - } - - if (npc.type == ModContent.NPCType()) - { - if (!target.dead) - { - hasWetTarget = true; - npc.chaseable = true; // Once the enemy has detected the player, let minions fuck it up - } - } - else if (target.wet && !target.dead && (target.Center - npc.Center).Length() < detectRange && Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) - { - hasWetTarget = true; - npc.chaseable = true; // Once the enemy has detected the player, let minions fuck it up - } - else - { - if (passiveness == 1) - hasWetTarget = false; - } - } - - if ((target.dead || !Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) && hasWetTarget) - hasWetTarget = false; - - // Swim back and forth - if (!hasWetTarget || passiveness == 2) - { - if (passiveness == 0) - { - npc.TargetClosest(false); - target = Main.player[npc.target]; - } - - if (npc.collideX) - { - npc.velocity.X *= -1f; - npc.direction *= -1; - npc.netUpdate = true; - } - - if (npc.collideY) - { - npc.netUpdate = true; - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; - npc.directionY = -1; - npc.ai[0] = -1f; - } - else if (npc.velocity.Y < 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y); - npc.directionY = 1; - npc.ai[0] = 1f; - } - } - } - - if (hasWetTarget && passiveness != 2) - { - npc.TargetClosest(); - target = Main.player[npc.target]; - - // Swim away from the player - if (passiveness == 3) - { - npc.velocity.X = npc.velocity.X - (float)npc.direction * xSpeed; - npc.velocity.Y = npc.velocity.Y - (float)npc.directionY * ySpeed; - } - // Swim toward the player - else - { - npc.velocity.X = npc.velocity.X + (float)npc.direction * (CalamityWorld.death ? 2f * xSpeed : CalamityWorld.revenge ? 1.5f * xSpeed : xSpeed); - npc.velocity.Y = npc.velocity.Y + (float)npc.directionY * (CalamityWorld.death ? 2f * ySpeed : CalamityWorld.revenge ? 1.5f * ySpeed : ySpeed); - } - - float velocityCapX = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitX : CalamityWorld.revenge ? 1.5f * speedLimitX : speedLimitX; - float velocityCapY = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitY : CalamityWorld.revenge ? 1.5f * speedLimitY : speedLimitY; - npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -velocityCapX, velocityCapX); - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -velocityCapY, velocityCapY); - - if (npc.justHit) - npc.localAI[0] = 0f; - - // Laserfish shoot the player - if (npc.type == ModContent.NPCType()) - { - npc.localAI[0] += (CalamityWorld.death ? 2f : CalamityWorld.revenge ? 1.5f : 1f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 120f) - { - npc.localAI[0] = 0f; - if (Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) - { - float speed = 5f; - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float velX = target.Center.X - vector.X + Main.rand.NextFloat(-20f, 20f); - float velY = target.Center.Y - vector.Y + Main.rand.NextFloat(-20f, 20f); - float dist = (float)Math.Sqrt((double)(velX * velX + velY * velY)); - dist = speed / dist; - velX *= dist; - velY *= dist; - int damage = Main.masterMode ? 34 : Main.expertMode ? 40 : 50; - int beam = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (npc.spriteDirection == 1 ? 25f : -25f), npc.Center.Y + (target.position.Y > npc.Center.Y ? 5f : -5f), velX, velY, ProjectileID.EyeBeam, damage, 0f, Main.myPlayer); - Main.projectile[beam].tileCollide = true; - } - } - } - - // Flounder shoot Sulphuric Mist at the player - if (npc.type == ModContent.NPCType()) - { - if ((target.Center - npc.Center).Length() < 350f) - { - npc.localAI[0] += (CalamityWorld.death ? 3f : CalamityWorld.revenge ? 2f : 1f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 180f) - { - npc.localAI[0] = 0f; - if (Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) - { - float speed = 4f; - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float velX = target.Center.X - vector.X + Main.rand.NextFloat(-20f, 20f); - float velY = target.Center.Y - vector.Y + Main.rand.NextFloat(-20f, 20f); - float dist = (float)Math.Sqrt((double)(velX * velX + velY * velY)); - dist = speed / dist; - velX *= dist; - velY *= dist; - int damage = Main.masterMode ? 21 : Main.expertMode ? 25 : 35; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (npc.spriteDirection == 1 ? 10f : -10f), npc.Center.Y, velX, velY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer); - } - } - } - } - - // Sea Minnows face away from the player - if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) - npc.direction *= -1; - } - else - { - // No target behavior - npc.velocity.X += (float)npc.direction * 0.1f; - if (npc.velocity.X < -2.5f || npc.velocity.X > 2.5f) - npc.velocity.X *= 0.95f; - - if (npc.ai[0] == -1f) - { - npc.velocity.Y -= 0.01f; - if (npc.velocity.Y < -0.3f) - npc.ai[0] = 1f; - } - else - { - npc.velocity.Y += 0.01f; - if (npc.velocity.Y > 0.3f) - npc.ai[0] = -1f; - } - } - - int npcTileX = (int)(npc.position.X + (float)(npc.width / 2)) / 16; - int npcTileY = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; - if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) - { - if (Main.tile[npcTileX, npcTileY + 1].HasTile) - npc.ai[0] = -1f; - else if (Main.tile[npcTileX, npcTileY + 2].HasTile) - npc.ai[0] = -1f; - } - - if (npc.velocity.Y > 0.4f || npc.velocity.Y < -0.4f) - npc.velocity.Y *= 0.95f; - } - else - { - // Out of water behavior - if (npc.velocity.Y == 0f) - { - npc.velocity.X *= 0.94f; - if (npc.velocity.X > -0.2f && npc.velocity.X < 0.2f) - npc.velocity.X = 0f; - } - - npc.velocity.Y += 0.4f; - if (npc.velocity.Y > 12f) - npc.velocity.Y = 12f; - - npc.ai[0] = 1f; - } - - npc.rotation = npc.velocity.Y * (float)npc.direction * rotation; - float rotationLimit = 2f * rotation; - npc.rotation = MathHelper.Clamp(npc.rotation, -rotationLimit, rotationLimit); - } - #endregion - } -} diff --git a/NPCs/CalamityDrawParameterNPC.cs b/NPCs/CalamityDrawParameterNPC.cs index ca630f4f02..bf4d15ddbe 100644 --- a/NPCs/CalamityDrawParameterNPC.cs +++ b/NPCs/CalamityDrawParameterNPC.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.ExoMechs.Ares; -using Steamworks; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -21,6 +16,7 @@ namespace CalamityMod.NPCs #region Draw Parameters public static bool[] DrawingMiracleBlight { get; private set; } public static bool[] DrawingPolarity { get; private set; } + public static int DoGDeathAnimationTimer { get; private set; } #endregion #region Filtering Fields @@ -45,8 +41,8 @@ namespace CalamityMod.NPCs #region Load / Unload public override void Load() { - DrawingMiracleBlight = new bool[Main.maxNPCs]; - DrawingPolarity = new bool[Main.maxNPCs]; + DrawingMiracleBlight = new bool[Main.maxNPCs + 1]; + DrawingPolarity = new bool[Main.maxNPCs + 1]; } public override void Unload() @@ -57,28 +53,39 @@ namespace CalamityMod.NPCs #endregion public override void SetDefaults(NPC entity) => ResetParameters(entity); - public override bool PreAI(NPC npc) - { - if (npc is null) - return true; - - var whoAmI = npc.whoAmI; - DrawingMiracleBlight[whoAmI] = ShouldDrawMiracleBlight(npc); - DrawingPolarity[whoAmI] = ShouldDrawPolarity(npc); - - return true; - } - public static void ResetParameters(NPC npc) { if (npc is null) return; + if (npc.whoAmI < 0 || npc.whoAmI >= Main.maxNPCs) + return; + var whoAmI = npc.whoAmI; DrawingMiracleBlight[whoAmI] = false; DrawingPolarity[whoAmI] = false; } + public override bool PreAI(NPC npc) + { + if (npc is null) + return true; + + if (npc.whoAmI < 0 || npc.whoAmI >= Main.maxNPCs) + return true; + + var whoAmI = npc.whoAmI; + DrawingMiracleBlight[whoAmI] = ShouldDrawMiracleBlight(npc); + DrawingPolarity[whoAmI] = ShouldDrawPolarity(npc); + return true; + } + + public static void PostUpdateNPCs() + { + DoGDeathAnimationTimer = GetDoGDeathTimer(); + } + + #region Miracle Blight Effect public static bool ShouldDrawMiracleBlight(NPC npc) { if (npc is null || !npc.active) @@ -97,11 +104,11 @@ namespace CalamityMod.NPCs return false; // Safety check for weird MP bug when getting global npcs. - if (!npc.TryGetGlobalNPCSafer(out var calNPC) || !npc.TryGetGlobalNPCSafer(out var polNPC)) + if (!npc.TryGetGlobalNPC(out var calNPC) || !npc.TryGetGlobalNPC(out var polNPC)) return false; // Do not draw if the npc does not have miracle blight, or has the polarity effect. - if (calNPC.miracleBlight <= 0 || polNPC.CurPolarity > 0f) + if (!calNPC.miracleBlight || polNPC.CurPolarity > 0f) return false; // Do not draw if the current player has the trippy effect. @@ -110,18 +117,20 @@ namespace CalamityMod.NPCs return true; } + #endregion + #region Polarity Effect public static bool ShouldDrawPolarity(NPC npc) { if (npc is null || !npc.active) return false; // Safety check for weird MP bug when getting global npcs. - if (!npc.TryGetGlobalNPCSafer(out var calNPC) || !npc.TryGetGlobalNPCSafer(out var polNPC)) + if (!npc.TryGetGlobalNPC(out var calNPC) || !npc.TryGetGlobalNPC(out var polNPC)) return false; // I don't know who would be using this while also inflicting miracle blight, but in that rare case, do not draw these. - if (calNPC.miracleBlight > 0) + if (calNPC.miracleBlight) return false; // Do not draw if the npc doesn't have the polarity effect. @@ -130,5 +139,50 @@ namespace CalamityMod.NPCs return true; } + #endregion + + #region DoG Death Animation + public static bool ShouldDrawDoGDeathAnimation(NPC npc) + { + // Do not draw inactive npcs, or ones with weird MP types less than or equal to 0. + if (npc == null || !npc.active || npc.type <= NPCID.None) + return false; + + if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + return false; + + // Do not draw if Death Animation did not triggered + if (GetDoGDeathTimer() <= 0) + return false; + + return true; + } + + public static int GetDoGDeathTimer() + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.DoGHead)) + return 0; + + var head = Main.npc[CalamityGlobalNPC.DoGHead].ModNPC(); + if (head == null) + return 0; + + // Don't draw if DoG hasn't started it's death animation yet. + if (head.DeathAnimationTimer <= 0) + return 0; + + return head.DeathAnimationTimer; + } + #endregion + + #region PostUpdateNPCs Hook + private sealed class PostUpdateNPCsHook : ModSystem + { + public override void PostUpdateNPCs() + { + CalamityDrawParameterNPC.PostUpdateNPCs(); + } + } + #endregion } } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 8aa7c99fa5..cb30fed767 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1,26 +1,22 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using CalamityMod.Balancing; using CalamityMod.BiomeManagers; using CalamityMod.Buffs; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Buffs.Summon.Whips; using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.ExtraTextures; using CalamityMod.Graphics.Metaballs; -using CalamityMod.Graphics.Renderers.CalamityRenderers; -using CalamityMod.Items; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Accessories.Vanity; +using CalamityMod.Items.Armor.PlagueReaper; using CalamityMod.Items.Tools; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Typeless; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.AquaticScourge; @@ -29,7 +25,6 @@ using CalamityMod.NPCs.AstrumDeus; using CalamityMod.NPCs.Bumblebirb; using CalamityMod.NPCs.CalClone; using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.DraedonLabThings; @@ -57,12 +52,9 @@ using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; using CalamityMod.Packets; using CalamityMod.Particles; -using CalamityMod.Projectiles; using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; -using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; using CalamityMod.Systems.Collections; @@ -70,9 +62,9 @@ using CalamityMod.Tiles.FurnitureAuric; using CalamityMod.Tiles.Ores; using CalamityMod.UI; using CalamityMod.UI.DebuffSystem; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.Walls.DraedonStructures; using CalamityMod.World; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MonoMod.Utils; @@ -84,6 +76,7 @@ using Terraria.GameContent; using Terraria.GameContent.Achievements; using Terraria.GameContent.Bestiary; using Terraria.GameContent.Events; +using Terraria.GameContent.UI.BigProgressBar; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -107,17 +100,9 @@ namespace CalamityMod.NPCs /// Damage Reduction Value public float DR { get; set; } = 0f; - /// If set to true, the NPC's damage reduction cannot be reduced via any means. This applies regardless of whether is true or false. + /// If set to true, the NPC's damage reduction cannot be reduced via any means. public bool unbreakableDR = false; - /// - /// Overrides the normal DR math and uses custom DR reductions for each debuff, registered separately.
- /// Used primarily by post-Moon Lord bosses. - ///
- public bool customDR = false; - public Dictionary flatDRReductions = new Dictionary(); - public Dictionary multDRReductions = new Dictionary(); - public int KillTime { get; set; } = 0; /// @@ -146,14 +131,28 @@ namespace CalamityMod.NPCs /// public bool? VulnerableToWater = null; - public const double BaseDoTDamageMult = 1D; - public const double VulnerableToDoTDamageMult = 2D; - public const double VulnerableToDoTDamageMult_Worms_SlimeGod = 1.5; - public const double ResistantToDoTDamageMult = 0.5; + public const float BaseDoTDamageMult = 1f; + public const float VulnerableToDoTDamageMult = 2f; + public const float VulnerableToDoTDamageMult_Worms_SlimeGod = 1.5f; + public const float ResistantToDoTDamageMult = 0.5f; + + public StatModifier TypelessDebuffMultiplier = new StatModifier(); + public StatModifier HeatDebuffMultiplier = new StatModifier(); + public StatModifier ColdDebuffMultiplier = new StatModifier(); + public StatModifier SicknessDebuffMultiplier = new StatModifier(); + public StatModifier WaterDebuffMultiplier = new StatModifier(); + public StatModifier ElectricDebuffMultiplier = new StatModifier(); + + // These are all recalculated constantly, while the regular ones are recalulated only on hit + public StatModifier ActiveTypelessDebuffMultiplier = new StatModifier(); + public StatModifier ActiveHeatDebuffMultiplier = new StatModifier(); + public StatModifier ActiveColdDebuffMultiplier = new StatModifier(); + public StatModifier ActiveSicknessDebuffMultiplier = new StatModifier(); + public StatModifier ActiveWaterDebuffMultiplier = new StatModifier(); + public StatModifier ActiveElectricDebuffMultiplier = new StatModifier(); // Cold debuff effects public bool IncreasedColdEffects_EskimoSet = false; - public bool IncreasedColdEffects_FrozenWings = false; public bool IncreasedColdEffects_CryoStone = false; // Electric effects @@ -163,7 +162,6 @@ namespace CalamityMod.NPCs public bool IncreasedHeatEffects_Fireball = false; public bool IncreasedHeatEffects_CinnamonRoll = false; public int IncreasedHeatEffects_FireBoots = 0; - public bool IncreasedHeatEffects_FlameWings = false; // Toxic Heart effect public bool IncreasedSicknessEffects_ToxicHeart = false; @@ -176,6 +174,9 @@ namespace CalamityMod.NPCs public bool IncreasedSicknessAndWaterEffects_EvergreenGin = false; public bool IncreasedSicknessAndWaterEffects_CorrosiveSpine = false; + // Universal debuff effects + public bool IncreasedDebuffEffects_Amalgam = false; + /// Constant variable representing the grace period, in frames, in which a boss can remain outside of its native biome before enraging. public const int biomeEnrageTimerMax = 300; @@ -186,8 +187,6 @@ namespace CalamityMod.NPCs public float velocityPriorToPhaseSwap = 0f; public const float velocityPriorToPhaseSwapIncrement = 0.1f; - public bool ShouldFallThroughPlatforms; - /// Allows hostile NPCs to deal defense damage to the player, used mostly for hard-hitting bosses. public bool canBreakPlayerDefense = false; @@ -210,30 +209,8 @@ namespace CalamityMod.NPCs ///
private const float BossZenDistance = 6400f; - /// - /// Destroyer laser colors, used for telegraphs.
- /// None = -1, Red = 0, Green = 1, Cyan = 2 - ///
- public int destroyerLaserColor = -1; - - /// Constant multiplier used to increase vanilla enemy health. - private const double EnemyHPMultiplier = 1.25; /// Constant multiplier used to decrease the health and/or damage of pre-Hardmode Desert enemies. private const double DesertEnemyStatMultiplier = 0.75; - /// - /// Constant multiplier used to decrease vanilla boss health in Master Mode.
- /// When combined with the universal health multiplier, results in 27.5% more health than Expert Mode. - ///
- public const double MasterModeBossHPMultiplier = 0.85; - - /// Constant multiplier used to decrease enemy health in Master Mode. - public const double MasterModeEnemyHPMultiplier = 0.75; - /// Constant multiplier used to decrease enemy damage in Master Mode. - public const double MasterModeEnemyDamageMultiplier = 0.9; - /// Constant multiplier used to decrease enemy knockback resistance. - public const float ExpertModeEnemyKnockbackMultiplier = 0.05f; - /// - public const float MasterModeEnemyKnockbackMultiplier = 0.1f; /// Constant multiplier used for decreasing the health and damage of mechanical bosses if the Early Hardmode Progression Rework config is enabled. public const double EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic = 0.8; @@ -255,11 +232,6 @@ namespace CalamityMod.NPCs public const int maxPlayerImmunities = Main.maxPlayers + 1; public int[] dashImmunityTime = new int[maxPlayerImmunities]; - /// Used to control the animation of the Town NPC Shop Alert icon, if the respective config is enabled. - public int shopAlertAnimTimer = 0; - /// - public int shopAlertAnimFrame = 0; - /// /// If set to false, prevents this NPC from allowing Rage to be generated by nearby players, regardless of other factors.
/// Defaults to true. @@ -267,12 +239,10 @@ namespace CalamityMod.NPCs public bool ProvidesProximityRage = true; // NewAI + // TODO: This should be deprecated at some point. internal const int maxAIMod = 4; public float[] newAI = new float[maxAIMod]; - public int AITimer = 0; - - /// Used for allowing Patreon names for Town NPCs. - public bool setNewName = true; + public int killTimeTimer = 0; /// If set to true, the Boss Health Bar for this NPC will count the total health of all individual segments using worm segment logic. public bool SplittingWorm = false; @@ -286,17 +256,20 @@ namespace CalamityMod.NPCs /// Tracks the current slowing debuff cooldown for this NPC. public int debuffResistanceTimer = 0; - // Debuffs - public int vaporfied = 0; - public int timeSlow = 0; - public int gState = 0; - public int tesla = 0; - public int tSad = 0; - public int eutrophication = 0; - public int webbed = 0; - public int slowed = 0; - public int electrified = 0; - public int pearlAura = 0; + #region Debuffs + public bool vaporfied = false; + public bool timeDistortion = false; + public bool glacialState = false; + public bool galvanicCorrosion = false; + public bool temporalSadness = false; + public bool eutrophication = false; + public bool webbed = false; + public bool electrified = false; + public bool pearlAura = false; + + public float manaBurn = 0f; + public float manaBurnPeak = 0f; + public float playerManaBurnIntensity = 0f; /// /// Counter variable that increments while the NPC is inflicted with Pearl Aura.
/// Used to determine when Giant Pearl's pearl shards should rain down onto the NPC. @@ -307,24 +280,25 @@ namespace CalamityMod.NPCs /// Used for properly counting pearl shard amount and for giving pearl shards an owner. ///
public int pearlAuraOwner = -1; - public int bBlood = 0; - public int brainRot = 0; - public int heavybleeding = 0; - public int laceration = 0; - public int elementalMix = 0; - public int marked = 0; - public int absorberAffliction = 0; - public int irradiated = 0; - public int bFlames = 0; - public int demonicFlames = 0; + public bool burningBlood = false; + public bool brainRot = false; + public bool heavyBleeding = false; + public bool laceration = false; + public bool elementalMix = false; + public bool markedForDeath = false; + public bool absorberAffliction = false; + public bool irradiated = false; + public double irradiatedContactBoost = 1.5; + public bool brimstoneFlames = false; + public bool demonicFlames = false; public int demonicFlamesBonusDamage = 0; - public int hFlames = 0; - /// Plague debuff. - public int pFlames = 0; - public int aCrunch = 0; - public int crumble = 0; + public bool holyFlames = false; + public bool plague = false; + public bool armorCrunch = false; + public bool crumble = false; public int antlionCloudDebuffTimer = 0; + public bool scionsCurioEffected = false; public int warbannerBurnTime = 0; // Determines the rate that the enemy is damaged public int warbannerBurnTimer = 0; // The duration of the debuff public int warbannerBurnStacks = 0; // The stacks increase how fast the debuff hits @@ -339,13 +313,27 @@ namespace CalamityMod.NPCs public int veriumDoomStacks = 0; public bool veriumDoomMarked = false; - // Laser Burn Type (1 = applied damage added and dealt in a single hit, 2 = flat damage + extra flat damage from stacks, 0 = innactive) + public bool laserBurnMarked = false; + /// + /// The type of laser burn that this NPC is inflicted with.
+ /// When set to 1, applies all accrued damage in a single hit. When set to 2, deals constant flat damage + extra flat damage from stacks. + ///
public int laserBurnType = 0; public int laserBurnDamage = 0; // Only used if laser burn type is 1 public const int laserBurnTime = 300; public int laserBurnTimer = 0; public int laserBurnStacks = 0; - public bool laserBurnMarked = false; + + public bool hyperiusMarked = false; + public int hyperiusDamage = 0; + public static int hyperiusOverflowTime = 100; + public int hyperiusOverflowTimer = hyperiusOverflowTime; + /// Constant variable representing the % of max health Hyperius Bullet's damage stacks must reach before they start to overflow. + public const float HyperiusLifePercentThreshold = 0.07f; + public int hyperiusFxTimer = 0; + + public int glaiveShredTimer = 0; + public int blazingStarShredTimer = 0; /// /// Tracks the strength of Calamity's cursor effect; increments by 2 on every frame.
@@ -371,41 +359,41 @@ namespace CalamityMod.NPCs /// Counter used for removing stacks of Shred. The number of stacks is subtracted every frame, and when it hits zero, it is reset and one stack is removed. public int somaShredFalloff = Shred.StackFalloffFrames; - public int cDepth = 0; - public int rTide = 0; - public int hPressure = 0; - public int gsInferno = 0; - public int dragonFire = 0; - public int vermillionFlux = 0; - public int auricRebuke = 0; - public int staticDischarge = 0; - public int miracleBlight = 0; - public int astralInfection = 0; - public int wDeath = 0; - public int nightwither = 0; - /// If greater than 0, this NPC has been "shocked" by Amidias' Spark's on hurt effect. + public bool crushDepth = false; + public bool riptide = false; + public bool hadopelagicPressure = false; + public bool godSlayerInferno = false; + public bool dragonFire = false; + public bool vermillionFlux = false; + public bool auricRebuke = false; + public bool staticDischarge = false; + public bool miracleBlight = false; + public bool astralInfection = false; + public bool whisperingDeath = false; + public bool nightwither = false; + /// If greater than 0, this NPC has been "shocked" by Ilmeris' Spark's on hurt effect. public int shocked = 0; - public int voidfrost = 0; - public int shellfishVore = 0; - public int clamDebuff = 0; - public int sulphurPoison = 0; + public bool voidfrost = false; + public bool shellfishStaffDebuff = false; + public bool snapClamDebuff = false; + public bool sulphurPoison = false; /// If greater than 0, makes this NPC constantly spawn heart gores. public int ladHearts = 0; - public int kamiFlu = 0; - public int relicOfResilienceWeakness = 0; - /// Cooldown variable for spawning Gauss Dagger's gauss flux projectiles. - public int GaussFluxTimer = 0; - public int sagePoisonTime = 0; + public bool relicOfResilienceWeakness = false; + public bool sagePoison = false; public int sagePoisonDamage = 0; - public int vulnerabilityHex = 0; - public int trueVulnerabilityHex = 0; - public int banishingFire = 0; - public int wither = 0; + public bool vulnerabilityHex = false; + public bool trueVulnerabilityHex = false; + public bool banishingFire = false; + public bool wither = false; /// /// If greater than 0, this enemy will appear to disintegrate into ash when killed.
/// Used by Rancor's laser beam. ///
public int ashesOnDeath = 0; + #endregion + + public bool fortunesFavor = false; // Buff which grants positive life regen. Given when near Gilded Axolotls. // whoAmI Variables public static int[] bobbitWormBottom = new int[5]; @@ -465,6 +453,7 @@ namespace CalamityMod.NPCs // Drawing variables. public FireParticleSet VulnerabilityHexFireDrawer = null; + public FireParticleSet ManaBurnFireDrawer = null; /// /// Boss Enrage variable for use with the boss health UI.
@@ -513,13 +502,6 @@ namespace CalamityMod.NPCs myClone.DR = DR; myClone.unbreakableDR = unbreakableDR; - myClone.flatDRReductions = new Dictionary(); - foreach (var flatDR in flatDRReductions) - myClone.flatDRReductions.Add(flatDR.Key, flatDR.Value); - myClone.multDRReductions = new Dictionary(); - foreach (var multDR in multDRReductions) - myClone.multDRReductions.Add(multDR.Key, multDR.Value); - myClone.KillTime = KillTime; myClone.VulnerableToHeat = VulnerableToHeat; @@ -529,44 +511,34 @@ namespace CalamityMod.NPCs myClone.VulnerableToWater = VulnerableToWater; myClone.IncreasedColdEffects_EskimoSet = IncreasedColdEffects_EskimoSet; - myClone.IncreasedColdEffects_FrozenWings = IncreasedColdEffects_FrozenWings; myClone.IncreasedColdEffects_CryoStone = IncreasedColdEffects_CryoStone; myClone.IncreasedElectricityEffects_Unused = IncreasedElectricityEffects_Unused; myClone.IncreasedHeatEffects_Fireball = IncreasedHeatEffects_Fireball; myClone.IncreasedHeatEffects_CinnamonRoll = IncreasedHeatEffects_CinnamonRoll; myClone.IncreasedHeatEffects_FireBoots = IncreasedHeatEffects_FireBoots; - myClone.IncreasedHeatEffects_FlameWings = IncreasedHeatEffects_FlameWings; myClone.IncreasedSicknessEffects_ToxicHeart = IncreasedSicknessEffects_ToxicHeart; myClone.IncreasedWaterEffects_Amulet1 = IncreasedWaterEffects_Amulet1; myClone.IncreasedWaterEffects_Amulet2 = IncreasedWaterEffects_Amulet2; myClone.IncreasedSicknessAndWaterEffects_CorrosiveSpine = IncreasedSicknessAndWaterEffects_CorrosiveSpine; myClone.IncreasedSicknessAndWaterEffects_EvergreenGin = IncreasedSicknessAndWaterEffects_EvergreenGin; + myClone.IncreasedDebuffEffects_Amalgam = IncreasedDebuffEffects_Amalgam; myClone.velocityPriorToPhaseSwap = velocityPriorToPhaseSwap; - myClone.ShouldFallThroughPlatforms = ShouldFallThroughPlatforms; - myClone.canBreakPlayerDefense = canBreakPlayerDefense; myClone.miscDefenseLoss = miscDefenseLoss; - myClone.destroyerLaserColor = destroyerLaserColor; - myClone.dashImmunityTime = new int[maxPlayerImmunities]; for (int i = 0; i < maxPlayerImmunities; ++i) myClone.dashImmunityTime[i] = dashImmunityTime[i]; - myClone.shopAlertAnimTimer = shopAlertAnimTimer; - myClone.shopAlertAnimFrame = shopAlertAnimFrame; - myClone.ProvidesProximityRage = ProvidesProximityRage; myClone.newAI = new float[maxAIMod]; for (int i = 0; i < maxAIMod; ++i) myClone.newAI[i] = newAI[i]; - myClone.AITimer = AITimer; - - myClone.setNewName = setNewName; + myClone.killTimeTimer = killTimeTimer; myClone.SplittingWorm = SplittingWorm; myClone.CanHaveBossHealthBar = CanHaveBossHealthBar; @@ -575,33 +547,34 @@ namespace CalamityMod.NPCs myClone.debuffResistanceTimer = debuffResistanceTimer; myClone.vaporfied = vaporfied; - myClone.timeSlow = timeSlow; - myClone.gState = gState; - myClone.tesla = tesla; - myClone.tSad = tSad; + myClone.timeDistortion = timeDistortion; + myClone.glacialState = glacialState; + myClone.galvanicCorrosion = galvanicCorrosion; + myClone.temporalSadness = temporalSadness; myClone.eutrophication = eutrophication; myClone.webbed = webbed; - myClone.slowed = slowed; myClone.electrified = electrified; myClone.pearlAura = pearlAura; myClone.pearlAuraCounter = pearlAuraCounter; - myClone.bBlood = bBlood; + myClone.burningBlood = burningBlood; myClone.brainRot = brainRot; - myClone.heavybleeding = heavybleeding; + myClone.heavyBleeding = heavyBleeding; myClone.laceration = laceration; myClone.elementalMix = elementalMix; - myClone.marked = marked; + myClone.markedForDeath = markedForDeath; myClone.absorberAffliction = absorberAffliction; myClone.irradiated = irradiated; - myClone.bFlames = bFlames; + myClone.irradiatedContactBoost = irradiatedContactBoost; + myClone.brimstoneFlames = brimstoneFlames; myClone.demonicFlames = demonicFlames; myClone.demonicFlamesBonusDamage = demonicFlamesBonusDamage; - myClone.hFlames = hFlames; - myClone.pFlames = pFlames; - myClone.aCrunch = aCrunch; + myClone.holyFlames = holyFlames; + myClone.plague = plague; + myClone.armorCrunch = armorCrunch; myClone.crumble = crumble; myClone.antlionCloudDebuffTimer = antlionCloudDebuffTimer; + myClone.scionsCurioEffected = scionsCurioEffected; myClone.warbannerBurnTime = warbannerBurnTime; myClone.warbannerBurnTimer = warbannerBurnTimer; myClone.warbannerBurnStacks = warbannerBurnStacks; @@ -613,6 +586,15 @@ namespace CalamityMod.NPCs myClone.veriumDoomTimer = veriumDoomTimer; myClone.veriumDoomStacks = veriumDoomStacks; myClone.veriumDoomMarked = veriumDoomMarked; + myClone.laserBurnDamage = laserBurnDamage; + myClone.laserBurnMarked = laserBurnMarked; + myClone.laserBurnStacks = laserBurnStacks; + myClone.laserBurnTimer = laserBurnTimer; + myClone.laserBurnType = laserBurnType; + myClone.hyperiusDamage = hyperiusDamage; + myClone.hyperiusMarked = hyperiusMarked; + myClone.hyperiusOverflowTimer = hyperiusOverflowTimer; + myClone.hyperiusFxTimer = hyperiusFxTimer; myClone.cursorFocus = cursorFocus; myClone.demonSwordImpales = demonSwordImpales; myClone.impalePacketTimer = impalePacketTimer; @@ -623,28 +605,26 @@ namespace CalamityMod.NPCs myClone.somaShredApplicator = somaShredApplicator; myClone.somaShredFalloff = somaShredFalloff; - myClone.cDepth = cDepth; - myClone.rTide = rTide; - myClone.hPressure = hPressure; - myClone.gsInferno = gsInferno; + myClone.crushDepth = crushDepth; + myClone.riptide = riptide; + myClone.hadopelagicPressure = hadopelagicPressure; + myClone.godSlayerInferno = godSlayerInferno; myClone.miracleBlight = miracleBlight; myClone.dragonFire = dragonFire; myClone.vermillionFlux = vermillionFlux; myClone.auricRebuke = auricRebuke; myClone.staticDischarge = staticDischarge; myClone.astralInfection = astralInfection; - myClone.wDeath = wDeath; + myClone.whisperingDeath = whisperingDeath; myClone.nightwither = nightwither; myClone.shocked = shocked; myClone.voidfrost = voidfrost; - myClone.shellfishVore = shellfishVore; - myClone.clamDebuff = clamDebuff; + myClone.shellfishStaffDebuff = shellfishStaffDebuff; + myClone.snapClamDebuff = snapClamDebuff; myClone.sulphurPoison = sulphurPoison; myClone.ladHearts = ladHearts; - myClone.kamiFlu = kamiFlu; myClone.relicOfResilienceWeakness = relicOfResilienceWeakness; - myClone.GaussFluxTimer = GaussFluxTimer; - myClone.sagePoisonTime = sagePoisonTime; + myClone.sagePoison = sagePoison; myClone.sagePoisonDamage = sagePoisonDamage; myClone.vulnerabilityHex = vulnerabilityHex; myClone.trueVulnerabilityHex = trueVulnerabilityHex; @@ -652,8 +632,11 @@ namespace CalamityMod.NPCs myClone.wither = wither; myClone.ashesOnDeath = ashesOnDeath; + myClone.fortunesFavor = fortunesFavor; + // This gets set up as needed. myClone.VulnerabilityHexFireDrawer = null; + myClone.ManaBurnFireDrawer = null; myClone.CurrentlyEnraged = CurrentlyEnraged; @@ -694,7 +677,7 @@ namespace CalamityMod.NPCs ResetSavedIndex(ref hiveMind, NPCType()); ResetSavedIndex(ref perfHive, NPCType()); - ResetSavedIndex(ref slimeGodPurple, NPCType(), NPCType()); + ResetSavedIndex(ref slimeGodPurple, NPCType(), NPCType()); ResetSavedIndex(ref slimeGodRed, NPCType(), NPCType()); ResetSavedIndex(ref slimeGod, NPCType()); ResetSavedIndex(ref laserEye, NPCID.Retinazer); @@ -754,13 +737,86 @@ namespace CalamityMod.NPCs CanHaveBossHealthBar = false; ShouldCloseHPBar = false; if (arcZapCooldown > 0) { arcZapCooldown--; } + + //Debuff Bool clearing. + // Doze 2jun2025 - Moved here from PostAI so drawing can read the bools. + if (debuffResistanceTimer > 0) + debuffResistanceTimer--; + + timeDistortion = false; + galvanicCorrosion = false; + glacialState = false; + temporalSadness = false; + eutrophication = false; + webbed = false; + vaporfied = false; + electrified = false; + pearlAura = false; + burningBlood = false; + brainRot = false; + heavyBleeding = false; + laceration = false; + elementalMix = false; + if (!trueVulnerabilityHex && !vulnerabilityHex) + { + cursorFocus = 0; + } + trueVulnerabilityHex = false; + vulnerabilityHex = false; + markedForDeath = false; + absorberAffliction = false; + irradiated = false; + if (scionsCurioEffected) + irradiatedContactBoost = 2f; + brimstoneFlames = false; + if (!demonicFlames) + demonicFlamesBonusDamage = 0; + demonicFlames = false; + holyFlames = false; + plague = false; + // Soma Prime's Shred stacks have a unique falloff mechanic in the debuff's own file. + armorCrunch = false; + crumble = false; + crushDepth = false; + hadopelagicPressure = false; + riptide = false; + godSlayerInferno = false; + dragonFire = false; + vermillionFlux = false; + auricRebuke = false; + staticDischarge = false; + miracleBlight = false; + astralInfection = false; + whisperingDeath = false; + nightwither = false; + if (shocked > 0) + shocked--; + voidfrost = false; + shellfishStaffDebuff = false; + snapClamDebuff = false; + sulphurPoison = false; + sagePoison = false; + if (ladHearts > 0) + ladHearts--; + banishingFire = false; + wither = false; + if (ashesOnDeath > 0) + ashesOnDeath--; + + fortunesFavor = false; + + if (antlionCloudDebuffTimer > 0) + antlionCloudDebuffTimer--; + if (cursorFocus > 0 && cursorFocus < cursorFocusMax) + cursorFocus--; + relicOfResilienceWeakness = false; } #endregion #region Life Regen public override void UpdateLifeRegen(NPC npc, ref int damage) { - if (npc.damage > 0 && !npc.boss && !npc.friendly && !npc.dontTakeDamage && BiomeTileCounterSystem.SulphurTiles > 30 && + if (npc.defDamage > 0 && !npc.boss && !npc.friendly && !npc.dontTakeDamage && BiomeTileCounterSystem.SulphurTiles > 30 && !npc.buffImmune[BuffID.Poisoned] && !npc.buffImmune[BuffType()]) { if (npc.wet) @@ -770,8 +826,7 @@ namespace CalamityMod.NPCs npc.AddBuff(BuffType(), 2); } - #region Stacking Debuff Effects - // Lionfish, Leviathan Teeth, and Jaws of Oblivion debuff stacking + // Lionfish and Jaws of Oblivion debuff stacking if (npc.venom) { if (npc.lifeRegen > 0) @@ -780,7 +835,7 @@ namespace CalamityMod.NPCs int projectileCount = 0; foreach (Projectile p in Main.ActiveProjectiles) { - if ((p.type == ProjectileType() || p.type == ProjectileType() || p.type == ProjectileType()) && + if ((p.type == ProjectileType() || p.type == ProjectileType()) && p.ai[0] == 1f && p.ai[1] == npc.whoAmI) { projectileCount++; @@ -789,564 +844,124 @@ namespace CalamityMod.NPCs if (projectileCount > 0) { - npc.lifeRegen -= projectileCount * 30; + npc.lifeRegen -= projectileCount * (int)(DebuffData.AcidVenom.EnemyLostRegen / 2); if (damage < projectileCount * 6) damage = projectileCount * 6; } } - // Bonebreaker debuff stacking - if (npc.javelined) - { - if (npc.lifeRegen > 0) - npc.lifeRegen = 0; - - int projectileCount = 0; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.type == ProjectileType() && - p.ai[0] == 1f && p.ai[1] == npc.whoAmI) - { - projectileCount++; - } - } - - if (projectileCount > 0) - { - npc.lifeRegen -= projectileCount * 20; - - if (damage < projectileCount * 4) - damage = projectileCount * 4; - } - } - - // Shellfish Staff (and Mollusk armor) debuff stacking - if (shellfishVore > 0) - { - int projectileCount = 0; - int owner = 255; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.type == ProjectileType() && - p.ai[0] == 1f && p.ai[1] == npc.whoAmI) - { - owner = p.owner; - projectileCount++; - if (projectileCount >= 5) - { - projectileCount = 5; - break; - } - } - } - - Item heldItem = Main.player[owner].ActiveItem(); - int totalDamage = (int)Main.player[owner].GetTotalDamage().ApplyTo(150f); - - if (CalamityUtils.ShouldTriggerSummonPenalty(Main.player[owner], heldItem)) - totalDamage = (int)(totalDamage * BalancingConstants.SummonerCrossClassNerf); - - int totalDisplayedDamage = totalDamage / 5; - ApplyDPSDebuff(projectileCount * totalDamage, projectileCount * totalDisplayedDamage, ref npc.lifeRegen, ref damage); - } - - // Snap Clam debuff stacking - if (clamDebuff > 0) - { - int projectileCount = 0; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.ai[0] == 1f && p.ai[1] == npc.whoAmI) - { - if (p.type == ProjectileType()) - projectileCount += 2; - if (p.type == ProjectileType()) - projectileCount++; - } - } - - ApplyDPSDebuff(projectileCount * 15, projectileCount * 3, ref npc.lifeRegen, ref damage); - } - - // Parasitic Scepter debuff stacking - if (irradiated > 0) - { - int projectileCount = 0; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.type == ProjectileType() && - p.ai[0] == 1f && p.ai[1] == npc.whoAmI) - { - projectileCount++; - } - } - - if (projectileCount > 0) - ApplyDPSDebuff(projectileCount * 20, projectileCount * 4, ref npc.lifeRegen, ref damage); - else - ApplyDPSDebuff(20, 4, ref npc.lifeRegen, ref damage); - } - #endregion - // Debuff vulnerabilities and resistances. // Damage multiplier calcs. // Worms that are vulnerable to debuffs and Slime God slimes take reduced damage from vulnerabilities. #region Debuff System Multiplier Calculations - bool wormBoss = DesertScourgeIDList.Includes(npc.type) || EaterOfWorldsIDList.Includes(npc.type) || PerforatorWormIDList.Includes(npc.type) || - AquaticScourgeIDList.Includes(npc.type) || AstrumDeusIDList.Includes(npc.type) || StormWeaverIDList.Includes(npc.type); - bool slimeGod = SlimeGodIDList.Includes(npc.type); + bool wormBoss = CalamityNPCTypeSets.DesertScourge.Contains(npc.type) || CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type) || CalamityNPCTypeSets.Perforators.Contains(npc.type) || + CalamityNPCTypeSets.AquaticScourge.Contains(npc.type) || CalamityNPCTypeSets.AstrumDeus.Contains(npc.type) || CalamityNPCTypeSets.StormWeaver.Contains(npc.type); + bool slimeGod = CalamityNPCTypeSets.SlimeGod.Contains(npc.type); - bool slimed = npc.drippingSlime || npc.drippingSparkleSlime; - bool wetReducedEffectiveness = npc.wet || npc.honeyWet || npc.dripping; - double heatDamageMult = slimed ? ((wormBoss || slimeGod) ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult) : BaseDoTDamageMult; - if (wetReducedEffectiveness) - heatDamageMult *= wormBoss || slimeGod ? 0.66 : ResistantToDoTDamageMult; + ActiveHeatDebuffMultiplier = HeatDebuffMultiplier; + ActiveColdDebuffMultiplier = ColdDebuffMultiplier; + ActiveSicknessDebuffMultiplier = SicknessDebuffMultiplier; + ActiveElectricDebuffMultiplier = ElectricDebuffMultiplier; + ActiveWaterDebuffMultiplier = WaterDebuffMultiplier; + + if (irradiated) + { + float irradiatedBoost = scionsCurioEffected ? 1.75f : 1f; + ActiveSicknessDebuffMultiplier += irradiatedBoost; + } + + if (npc.drippingSlime || npc.drippingSparkleSlime) + { + ActiveHeatDebuffMultiplier += 1; + } + + if (npc.wet || npc.honeyWet || npc.lavaWet || npc.dripping) + { + ActiveElectricDebuffMultiplier += 1; + } + + if (npc.wet || npc.honeyWet || npc.dripping) + { + ActiveColdDebuffMultiplier += 1; + ActiveHeatDebuffMultiplier -= 0.5f; + } + if (npc.HasBuff(BuffID.Chilled)) //Nothing inflicts this at the moment. Put here so we can start using it. + { + ActiveWaterDebuffMultiplier += 1; + } + + if (npc.HasBuff()) //Searing Lava is so hot it makes cold less strong + { + ActiveColdDebuffMultiplier -= 0.5f; + } if (VulnerableToHeat.HasValue) { if (VulnerableToHeat.Value) - heatDamageMult *= slimed ? ((wormBoss || slimeGod) ? 1.25 : 1.5) : ((wormBoss || slimeGod) ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult); + ActiveHeatDebuffMultiplier *= wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult; else - heatDamageMult *= slimed ? ((wormBoss || slimeGod) ? 0.66 : ResistantToDoTDamageMult) : ResistantToDoTDamageMult; + ActiveHeatDebuffMultiplier *= ResistantToDoTDamageMult; } - double coldDamageMult = BaseDoTDamageMult; if (VulnerableToCold.HasValue) { if (VulnerableToCold.Value) - coldDamageMult *= wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult; + ActiveColdDebuffMultiplier *= wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult; else - coldDamageMult *= ResistantToDoTDamageMult; + ActiveColdDebuffMultiplier *= ResistantToDoTDamageMult; } - double sicknessDamageMult = irradiated > 0 ? (wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult) : BaseDoTDamageMult; if (VulnerableToSickness.HasValue) { if (VulnerableToSickness.Value) - sicknessDamageMult *= irradiated > 0 ? (wormBoss ? 1.25 : 1.5) : (wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult); + ActiveSicknessDebuffMultiplier *= wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult; else - sicknessDamageMult *= irradiated > 0 ? (wormBoss ? 0.66 : ResistantToDoTDamageMult) : ResistantToDoTDamageMult; + ActiveSicknessDebuffMultiplier *= ResistantToDoTDamageMult; } - - bool increasedElectricityDamage = npc.wet || npc.honeyWet || npc.lavaWet || npc.dripping; - double electricityDamageMult = increasedElectricityDamage ? (wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult) : BaseDoTDamageMult; if (VulnerableToElectricity.HasValue) { if (VulnerableToElectricity.Value) - electricityDamageMult *= increasedElectricityDamage ? (wormBoss ? 1.25 : 1.5) : (wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult); + ActiveElectricDebuffMultiplier *= wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult; else - electricityDamageMult *= increasedElectricityDamage ? (wormBoss ? 0.66 : ResistantToDoTDamageMult) : ResistantToDoTDamageMult; + ActiveElectricDebuffMultiplier *= ResistantToDoTDamageMult; } - - double waterDamageMult = BaseDoTDamageMult; if (VulnerableToWater.HasValue) { if (VulnerableToWater.Value) - waterDamageMult *= wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult; + ActiveWaterDebuffMultiplier *= wormBoss ? VulnerableToDoTDamageMult_Worms_SlimeGod : VulnerableToDoTDamageMult; else - waterDamageMult *= ResistantToDoTDamageMult; - } - - if (IncreasedColdEffects_EskimoSet) - coldDamageMult += 0.25; - if (IncreasedColdEffects_FrozenWings) - coldDamageMult += 0.25; - if (IncreasedColdEffects_CryoStone) - coldDamageMult += 0.5; - - if (IncreasedElectricityEffects_Unused) - electricityDamageMult += 0.5; - - if (IncreasedHeatEffects_Fireball) - heatDamageMult += Fireball.HeatDebuffBoost; - if (IncreasedHeatEffects_FireBoots > 0) - heatDamageMult += 0.25 * IncreasedHeatEffects_FireBoots; - if (IncreasedHeatEffects_CinnamonRoll) - heatDamageMult += CinnamonRoll.HeatDebuffBoost; - if (IncreasedHeatEffects_FlameWings) - heatDamageMult += 0.25; - - if (IncreasedSicknessEffects_ToxicHeart) - sicknessDamageMult += 0.5; - - if (IncreasedWaterEffects_Amulet1) - waterDamageMult += 0.35; - if (IncreasedWaterEffects_Amulet2) - waterDamageMult += 0.75; - - if (IncreasedSicknessAndWaterEffects_CorrosiveSpine) - { - sicknessDamageMult += 0.25; - waterDamageMult += 0.25; - } - if (IncreasedSicknessAndWaterEffects_EvergreenGin) - { - sicknessDamageMult += EvergreenGin.SicknessWaterDebuffBoost; - waterDamageMult += EvergreenGin.SicknessWaterDebuffBoost; - } - - // Subtract 1 for the vanilla damage multiplier because it's already dealing DoT in the vanilla regen code. - double vanillaHeatDamageMult = heatDamageMult - BaseDoTDamageMult; - double vanillaColdDamageMult = coldDamageMult - BaseDoTDamageMult; - double vanillaSicknessDamageMult = sicknessDamageMult - BaseDoTDamageMult; - #endregion - - // Oiled - bool hasColdOil = npc.onFrostBurn || npc.onFrostBurn2; - bool hasHotOil = npc.onFire || npc.onFire2 || npc.onFire3 || npc.shadowFlame; - bool hasModHotOil = bFlames > 0 || demonicFlames > 0 || hFlames > 0 || gsInferno > 0 || dragonFire > 0 || banishingFire > 0 || vulnerabilityHex > 0; - if (npc.oiled && (hasColdOil || hasHotOil || hasModHotOil)) - { - double multiplier = 1D; - if (hasColdOil) - multiplier *= vanillaColdDamageMult; - if (hasHotOil || (hasModHotOil && hasColdOil)) - multiplier *= vanillaHeatDamageMult; - if (hasModHotOil && !hasColdOil && !hasHotOil) - multiplier *= heatDamageMult; - - int baseOiledDoTValue = (int)(50 * multiplier); - npc.lifeRegen -= baseOiledDoTValue; - if (damage < baseOiledDoTValue / 4) - damage = baseOiledDoTValue / 4; - } - - #region Cold Debuffs - // Frostburn - if (npc.onFrostBurn) - { - int baseFrostBurnDoTValue = (int)(16 * vanillaColdDamageMult); - npc.lifeRegen -= baseFrostBurnDoTValue; - if (damage < baseFrostBurnDoTValue / 4) - damage = baseFrostBurnDoTValue / 4; - } - - // Frostbite - if (npc.onFrostBurn2) - { - int baseFrostBiteDoTValue = (int)(50 * vanillaColdDamageMult); - npc.lifeRegen -= baseFrostBiteDoTValue; - if (damage < baseFrostBiteDoTValue / 4) - damage = baseFrostBiteDoTValue / 4; - } - - // Nightwither - if (nightwither > 0) - { - int baseNightwitherDoTValue = (int)(200 * coldDamageMult); - ApplyDPSDebuff(baseNightwitherDoTValue, baseNightwitherDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Voidfrost - if (voidfrost > 0) - { - int baseVoidfrostDoTValue = (int)(300 * coldDamageMult); - ApplyDPSDebuff(baseVoidfrostDoTValue, baseVoidfrostDoTValue / 5, ref npc.lifeRegen, ref damage); + ActiveWaterDebuffMultiplier *= ResistantToDoTDamageMult; } #endregion - #region Electricity Debuffs - // Static Discharge - if (staticDischarge > 0) + if (fortunesFavor) { - int baseStaticDischargeDoTValue = (int)(5 * (npc.velocity.X == 0 ? 1 : 4) * electricityDamageMult); // 24 on moving targets - ApplyDPSDebuff(baseStaticDischargeDoTValue, baseStaticDischargeDoTValue / 15, ref npc.lifeRegen, ref damage); + npc.lifeRegen += 4; // 2 HP/s at base } - // Electrified - if (electrified > 0) + //Apply DoT Debuffs + for (var index = 0; index < npc.buffType.Length; index++) { - int baseElectrifiedDoTValue = (int)(21 * (npc.velocity.X == 0 ? 1 : 4) * electricityDamageMult); // 84 on moving targets - ApplyDPSDebuff(baseElectrifiedDoTValue, baseElectrifiedDoTValue / 22, ref npc.lifeRegen, ref damage); + var type = npc.buffType[index]; + var debuffData = BuffDatasets.DebuffDataset[type]; + if (debuffData == null || debuffData == DebuffData.Oiled) //Oiled is done after + continue; + debuffData.NPCLifeRegenMethod(npc, type, ref index, ref damage); } - - // Vermillion Flux - if (vermillionFlux > 0) + //Oiled comes after so that we can detect if they have a heat debuff in the above loop + bool hasVanillaOil = npc.onFrostBurn || npc.onFrostBurn2 || npc.onFire || npc.onFire2 || npc.onFire3 || npc.shadowFlame; + if (npc.oiled) { - int baseVermillionFluxDoTValue = (int)(100 * (npc.velocity.X == 0 ? 1 : 4) * electricityDamageMult); // 400 on moving targets - ApplyDPSDebuff(baseVermillionFluxDoTValue, baseVermillionFluxDoTValue / 40, ref npc.lifeRegen, ref damage); - } - - // Auric Rebuke - if (auricRebuke > 0) - { - int baseAuricRebukeDoTValue = (int)(200 * (npc.velocity.X == 0 ? 1 : 4) * electricityDamageMult); // 800 on moving targets - ApplyDPSDebuff(baseAuricRebukeDoTValue, baseAuricRebukeDoTValue / 70, ref npc.lifeRegen, ref damage); - } - #endregion - - #region Heat Debuffs - // On Fire - if (npc.onFire) - { - int baseOnFireDoTValue = (int)(12 * vanillaHeatDamageMult); - npc.lifeRegen -= baseOnFireDoTValue; - if (damage < baseOnFireDoTValue / 4) - damage = baseOnFireDoTValue / 4; - } - - // Hellfire - if (npc.onFire3) - { - int baseHellfireDoTValue = (int)(30 * vanillaHeatDamageMult); - npc.lifeRegen -= baseHellfireDoTValue; - if (damage < baseHellfireDoTValue / 4) - damage = baseHellfireDoTValue / 4; - } - - // Cursed Inferno - if (npc.onFire2) - { - int baseCursedInfernoDoTValue = (int)(48 * vanillaHeatDamageMult); - npc.lifeRegen -= baseCursedInfernoDoTValue; - if (damage < baseCursedInfernoDoTValue / 4) - damage = baseCursedInfernoDoTValue / 4; - } - - // Shadowflame - if (npc.shadowFlame) - { - int baseShadowFlameDoTValue = (int)(60 * vanillaHeatDamageMult); - npc.lifeRegen -= baseShadowFlameDoTValue; - if (damage < baseShadowFlameDoTValue / 4) - damage = baseShadowFlameDoTValue / 4; - } - - // Daybroken - // 18OCT2023: Ozzatron: im not gonna sugarcoat it - // vanilla debuff damage from Daybreak impales scales linearly up to 8 for 800 DPS - // instead of allowing this entire 800 DPS to be multiplied by heat weakness + heat DoT bonuses, - // each Daybreak spear beyond the first is only affected 25% as much by weaknesses or resistances. - // This also stops Daybreak's DPS from being utterly shafted by heat resistance. - // As no other weapon can stack Daybroken, this has no effect on other weapons (they count as "1 Daybreak spear") - if (npc.daybreak) - { - int numImpaledSpears = 0; - for (int k = 0; k < Main.maxProjectiles; k++) - { - if (Main.projectile[k].active && Main.projectile[k].type == ProjectileID.Daybreak && Main.projectile[k].ai[0] == 1f && Main.projectile[k].ai[1] == npc.whoAmI) - numImpaledSpears++; - } - - // If there are no Daybreak impaled spears, Daybroken has 1x potency (it was applied some other way) - float daybrokenMultiplier = numImpaledSpears <= 1 ? 1f : (1f + 0.25f * (numImpaledSpears - 1)); - - int baseDaybreakDoTValue = (int)(daybrokenMultiplier * 2 * 100 * vanillaHeatDamageMult); - npc.lifeRegen -= baseDaybreakDoTValue; - if (damage < baseDaybreakDoTValue / 4) - damage = baseDaybreakDoTValue / 4; - } - - // Brimstone Flames - if (bFlames > 0) - { - int baseBrimstoneFlamesDoTValue = (int)(60 * heatDamageMult); - ApplyDPSDebuff(baseBrimstoneFlamesDoTValue, baseBrimstoneFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Demonic Flames - // An unresistable fire debuff that you can set the damage of when it is applied - // This way it can be viable for multiple tiers - if (demonicFlames > 0) - { - int baseDemonicFlamesDoTValue = (int)((demonicFlamesBonusDamage) * Math.Max(heatDamageMult, 1)); - ApplyDPSDebuff(baseDemonicFlamesDoTValue, baseDemonicFlamesDoTValue / 15, ref npc.lifeRegen, ref damage); - } - - // Holy Flames - if (hFlames > 0) - { - int baseHolyFlamesDoTValue = (int)(300 * heatDamageMult); - ApplyDPSDebuff(baseHolyFlamesDoTValue, baseHolyFlamesDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // God Slayer Inferno - if (gsInferno > 0) - { - int baseGodSlayerInfernoDoTValue = (int)(500 * heatDamageMult); - ApplyDPSDebuff(baseGodSlayerInfernoDoTValue, baseGodSlayerInfernoDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Dragonfire - if (dragonFire > 0) - { - int baseDragonFireDoTValue = (int)(960 * heatDamageMult); - ApplyDPSDebuff(baseDragonFireDoTValue, baseDragonFireDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Vulnerability Hex - if (vulnerabilityHex > 0) - { - int baseVulnerabilityHexDoTValue = (int)(VulnerabilityHex.DPS * heatDamageMult); - ApplyDPSDebuff(baseVulnerabilityHexDoTValue, VulnerabilityHex.TickNumber, ref npc.lifeRegen, ref damage); - } - - // True Vulnerability Hex - if (trueVulnerabilityHex > 0) - { - int baseTrueVHexDoTValue = (int)(TrueVulnerabilityHex.DPS * heatDamageMult); - ApplyDPSDebuff(baseTrueVHexDoTValue, TrueVulnerabilityHex.TickNumber, ref npc.lifeRegen, ref damage); - } - - // Banishing Fire - if (banishingFire > 0) - { - int baseBanishingFireDoTValue = (int)((npc.lifeMax >= 1000000 ? npc.lifeMax / 500 : 4000) * heatDamageMult); - ApplyDPSDebuff(baseBanishingFireDoTValue, baseBanishingFireDoTValue / 5, ref npc.lifeRegen, ref damage); - } - #endregion - - #region Sickness Debuffs - // Poisoned - if (npc.poisoned) - { - int basePoisonedDoTValue = (int)(12 * vanillaSicknessDamageMult); - npc.lifeRegen -= basePoisonedDoTValue; - if (damage < basePoisonedDoTValue / 4) - damage = basePoisonedDoTValue / 4; - } - - // Venom - if (npc.venom) - { - int baseVenomDoTValue = (int)(60 * vanillaSicknessDamageMult); - npc.lifeRegen -= baseVenomDoTValue; - if (damage < baseVenomDoTValue / 4) - damage = baseVenomDoTValue / 4; - } - - // Burning Blood - if (bBlood > 0) - { - int baseBurningBloodDoTValue = (int)(40 * sicknessDamageMult); - ApplyDPSDebuff(baseBurningBloodDoTValue, baseBurningBloodDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Brain Rot - if (brainRot > 0) - { - int baseBrainRotDoTValue = (int)(40 * sicknessDamageMult); - ApplyDPSDebuff(baseBrainRotDoTValue, baseBrainRotDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Sage Poison - if (sagePoisonTime > 0) - { - // npc.Calamity().sagePoisonDamage = 50 * (float)(Math.Pow(totalSageSpirits, 0.73D) + Math.Pow(totalSageSpirits, 1.1D)) * 0.5f - // See SageNeedle.cs for details - int baseSagePoisonDoTValue = (int)(npc.Calamity().sagePoisonDamage * sicknessDamageMult); - ApplyDPSDebuff(baseSagePoisonDoTValue, baseSagePoisonDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Astral Infection - if (astralInfection > 0) - { - int baseAstralInfectionDoTValue = (int)(75 * sicknessDamageMult); - ApplyDPSDebuff(baseAstralInfectionDoTValue, baseAstralInfectionDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Plague - if (pFlames > 0) - { - int basePlagueDoTValue = (int)(100 * sicknessDamageMult); - ApplyDPSDebuff(basePlagueDoTValue, basePlagueDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Sulphuric Poisoning - if (sulphurPoison > 0) - { - int baseSulphurPoisonDoTValue = (int)(240 * sicknessDamageMult); - ApplyDPSDebuff(baseSulphurPoisonDoTValue, baseSulphurPoisonDoTValue / 5, ref npc.lifeRegen, ref damage); - } - - // Kami Debuff from Yanmei's Knife - if (kamiFlu > 0) - { - int baseKamiFluDoTValue = (int)(YanmeisKnife.DebuffDoT * sicknessDamageMult); - ApplyDPSDebuff(baseKamiFluDoTValue, baseKamiFluDoTValue / 10, ref npc.lifeRegen, ref damage); - } - - //Absorber Affliction - if (absorberAffliction > 0) - { - int baseAbsorberDoTValue = (int)(400 * sicknessDamageMult); - ApplyDPSDebuff(baseAbsorberDoTValue, baseAbsorberDoTValue / 65, ref npc.lifeRegen, ref damage); - } - #endregion - - #region Water Debuffs - // Riptide - if (rTide > 0) - { - int baseRiptideDoTValue = (int)(30 * waterDamageMult); - ApplyDPSDebuff(baseRiptideDoTValue, baseRiptideDoTValue / 3, ref npc.lifeRegen, ref damage); - } - - // Crush Depth - if (cDepth > 0) - { - int baseCrushDepthDoTValue = (int)(100 * waterDamageMult); - ApplyDPSDebuff(baseCrushDepthDoTValue, baseCrushDepthDoTValue / 2, ref npc.lifeRegen, ref damage); - } - - //Hadopelagic Pressure - if (hPressure > 0) - { - int baseHadopelagicPressureDoTValue = (int)(400 * waterDamageMult); - ApplyDPSDebuff(baseHadopelagicPressureDoTValue, baseHadopelagicPressureDoTValue / 2, ref npc.lifeRegen, ref damage); - } - #endregion - - if (npc.dryadBane) - { - // Buffs match 1:1 with Town NPC buffs - // See CalamityGlobalTownNPC: BuffTownNPC - float buffedDryadsBaneMult = 0f + - (NPC.downedMoonlord ? 0.6f : 0f) + - (DownedBossSystem.downedProvidence ? 0.2f : 0f) + - (DownedBossSystem.downedPolterghast ? 0.2f : 0f) + - (DownedBossSystem.downedDoG ? 0.2f : 0f) + - (DownedBossSystem.downedYharon ? 0.2f : 0f) + - (DownedBossSystem.downedExoMechs ? 0.6f : 0f) + - (DownedBossSystem.downedCalamitas ? 0.6f : 0f); - if (Main.expertMode) - buffedDryadsBaneMult *= Main.GameModeInfo.TownNPCDamageMultiplier; - int buffedDryadsBaneDoTValue = 2 * (int)(4 * buffedDryadsBaneMult); - npc.lifeRegen -= buffedDryadsBaneDoTValue; - - // Scales damage tick if greater than the vanilla amount - float vanillaDryadsBaneMult = 1f + - (NPC.downedBoss1 ? 0.1f : 0f) + - (NPC.downedBoss2 ? 0.1f : 0f) + - (NPC.downedBoss3 ? 0.1f : 0f) + - (NPC.downedQueenBee ? 0.1f : 0f) + - (Main.hardMode ? 0.4f : 0f) + - (NPC.downedMechBoss1 ? 0.15f : 0f) + - (NPC.downedMechBoss1 ? 0.15f : 0f) + - (NPC.downedMechBoss1 ? 0.15f : 0f) + - (NPC.downedPlantBoss ? 0.15f : 0f) + - (NPC.downedGolemBoss ? 0.15f : 0f) + - (NPC.downedAncientCultist ? 0.15f : 0f); - if (Main.expertMode) - vanillaDryadsBaneMult *= Main.GameModeInfo.TownNPCDamageMultiplier; - int totalDryadsBaneDoTValue = 2 * (int)(4 * vanillaDryadsBaneMult) + buffedDryadsBaneDoTValue; - if (damage < totalDryadsBaneDoTValue / 6) - damage = totalDryadsBaneDoTValue / 6; + var oil = DebuffData.Oiled; + int index = npc.FindBuffIndex(BuffID.Oiled); + if (hasVanillaOil) + npc.lifeRegen -= oil.EnemyVanillaRegenToCancelOut; + oil.NPCLifeRegenMethod(npc, BuffID.Oiled, ref index, ref damage); } // Debuffs that aren't affected by weaknesses or resistances. - if (vaporfied > 0) - ApplyDPSDebuff(30, 6, ref npc.lifeRegen, ref damage); if (somaShredStacks > 0) Shred.TickDebuff(npc, this); - if (heavybleeding > 0) - ApplyDPSDebuff(80, 10, ref npc.lifeRegen, ref damage); - if (laceration > 0) - ApplyDPSDebuff(400, 100, ref npc.lifeRegen, ref damage); - if (elementalMix > 0) - ApplyDPSDebuff(400, 100, ref npc.lifeRegen, ref damage); - if (miracleBlight > 0) - ApplyDPSDebuff(3000, 500, ref npc.lifeRegen, ref damage); // Reduce DoT on worm bosses and Creepers by 75%. if ((wormBoss || npc.type == NPCID.Creeper) && npc.lifeRegen < 0) @@ -1355,10 +970,57 @@ namespace CalamityMod.NPCs if (npc.lifeRegen > -1) npc.lifeRegen = -1; - // Every other EoW body segment and the head segments are immune to DoT. + // Every other EoW body segment and the head segments are immune to DoT in Death Mode. if (((npc.ai[2] % 2f == 0f && npc.type == NPCID.EaterofWorldsBody) || npc.type == NPCID.EaterofWorldsHead) && (CalamityWorld.death || BossRushEvent.BossRushActive)) npc.lifeRegen = 0; } + + // Mana Burn + // This is at the end to leave it full effect on worms, and to force the DOT numbers to match mana burn + if (manaBurn > 0) + { + if (manaBurnPeak >= 0.1f) + manaBurnPeak *= 0.999f; + + manaBurnPeak = Math.Max(manaBurnPeak, manaBurn); + int burnPerSecond = (int)MathF.Ceiling(manaBurn * 0.5f); + manaBurn -= burnPerSecond / 60f; + + if (npc.lifeRegen > 0) + npc.lifeRegen = 0; + + npc.lifeRegen -= burnPerSecond * 2; + damage += (int)(burnPerSecond * 0.5f); + } + else + { + manaBurnPeak = 0; + playerManaBurnIntensity = 0; + } + + // This is at the end to make sure the dmg check for particle creations runs properly + if (glaiveShredTimer > 0 || blazingStarShredTimer > 0) + { + int dmg = 0; + if (glaiveShredTimer > 0) + { + dmg += 120; // 60 DPS + glaiveShredTimer--; + } + if (blazingStarShredTimer > 0) + { + dmg += 480; // 240 DPS + blazingStarShredTimer--; + } + npc.lifeRegenCount -= dmg; + if (damage < dmg / 12) // 1/6th of the DPS dealt by Glaive Shred shows up as the indicator, unless another debuff does more per tick + damage = dmg / 12; + + if (-120 * damage >= npc.lifeRegenCount) + { + GeneralParticleHandler.SpawnParticle(new CustomSpark(npc.Center, new Vector2(1, 0).RotatedByRandom(7), "CalamityMod/Particles/TrientCircularSmear", false, 15, 0.4f + 0.1f * npc.width / 16f, Color.White, new Vector2(0.5f, 1f))); + } + } } public void ApplyDPSDebuff(int lifeRegenValue, int damageValue, ref int lifeRegen, ref int damage) @@ -1378,116 +1040,28 @@ namespace CalamityMod.NPCs { #region Setup Vanilla DR Values DRValues = new SortedDictionary { - { NPCID.AngryBonesBig, 0.2f }, - { NPCID.AngryBonesBigHelmet, 0.2f }, - { NPCID.AngryBonesBigMuscle, 0.2f }, - { NPCID.AnomuraFungus, 0.1f }, - { NPCID.Antlion, 0.1f }, - { NPCID.Arapaima, 0.1f }, - { NPCID.ArmoredSkeleton, 0.15f }, - { NPCID.ArmoredViking, 0.1f }, - { NPCID.BigMimicCorruption, 0.3f }, - { NPCID.BigMimicCrimson, 0.3f }, - { NPCID.BigMimicHallow, 0.3f }, - { NPCID.BigMimicJungle, 0.3f }, - { NPCID.BlueArmoredBones, 0.2f }, - { NPCID.BlueArmoredBonesMace, 0.2f }, - { NPCID.BlueArmoredBonesNoPants, 0.2f }, - { NPCID.BlueArmoredBonesSword, 0.2f }, - { NPCID.BoneLee, 0.2f }, - { NPCID.Crab, 0.05f }, - { NPCID.Crawdad, 0.2f }, - { NPCID.Crawdad2, 0.2f }, { NPCID.CultistBoss, 0.15f }, - { NPCID.Deerclops, 0.05f }, - { NPCID.DD2Betsy, 0.1f }, - { NPCID.DD2OgreT2, 0.1f }, - { NPCID.DD2OgreT3, 0.15f }, - { NPCID.DeadlySphere, 0.4f }, - { NPCID.DiabolistRed, 0.2f }, - { NPCID.DiabolistWhite, 0.2f }, { NPCID.DukeFishron, 0.15f }, - { NPCID.DungeonGuardian, 0.9f }, - { NPCID.DungeonSpirit, 0.2f }, - { NPCID.ElfCopter, 0.15f }, - { NPCID.Everscream, 0.1f }, - { NPCID.FlyingAntlion, 0.05f }, - { NPCID.GiantCursedSkull, 0.2f }, - { NPCID.GiantShelly, 0.2f }, - { NPCID.GiantShelly2, 0.2f }, - { NPCID.GiantTortoise, 0.35f }, - { NPCID.Golem, 0.25f }, - { NPCID.GolemFistLeft, 0.25f }, - { NPCID.GolemFistRight, 0.25f }, - { NPCID.GolemHead, 0.25f }, - { NPCID.GolemHeadFree, 0.25f }, - { NPCID.GraniteFlyer, 0.1f }, - { NPCID.GraniteGolem, 0.15f }, - { NPCID.GreekSkeleton, 0.1f }, - { NPCID.HellArmoredBones, 0.2f }, - { NPCID.HellArmoredBonesMace, 0.2f }, - { NPCID.HellArmoredBonesSpikeShield, 0.2f }, - { NPCID.HellArmoredBonesSword, 0.2f }, - { NPCID.IceGolem, 0.1f }, - { NPCID.IceQueen, 0.1f }, - { NPCID.IceTortoise, 0.35f }, - { NPCID.HeadlessHorseman, 0.05f }, - { NPCID.MartianDrone, 0.2f }, - { NPCID.MartianSaucer, 0.2f }, - { NPCID.MartianSaucerCannon, 0.2f }, - { NPCID.MartianSaucerCore, 0.2f }, - { NPCID.MartianSaucerTurret, 0.2f }, - { NPCID.MartianTurret, 0.2f }, - { NPCID.MartianWalker, 0.35f }, - { NPCID.Mimic, 0.3f }, + { NPCID.Golem, 0.15f }, + { NPCID.GolemFistLeft, 0.15f }, + { NPCID.GolemFistRight, 0.15f }, + { NPCID.GolemHead, 0.15f }, { NPCID.MoonLordCore, 0.15f }, { NPCID.MoonLordHand, 0.15f }, { NPCID.MoonLordHead, 0.15f }, - { NPCID.Mothron, 0.2f }, - { NPCID.MothronEgg, 0.5f }, - { NPCID.MourningWood, 0.1f }, - { NPCID.Necromancer, 0.2f }, - { NPCID.NecromancerArmored, 0.2f }, - { NPCID.Paladin, 0.45f }, - { NPCID.PirateCaptain, 0.05f }, - { NPCID.PirateShipCannon, 0.15f }, { NPCID.Plantera, 0.15f }, - { NPCID.PlanterasTentacle, 0.1f }, { NPCID.HallowBoss, 0.15f }, - { NPCID.PossessedArmor, 0.25f }, - { NPCID.PresentMimic, 0.3f }, { NPCID.PrimeCannon, 0.2f }, { NPCID.PrimeLaser, 0.2f }, { NPCID.PrimeSaw, 0.2f }, { NPCID.PrimeVice, 0.2f }, - { NPCID.Probe, 0.2f }, - { NPCID.Pumpking, 0.1f }, - { NPCID.QueenBee, 0.05f }, - { NPCID.RaggedCaster, 0.2f }, - { NPCID.RaggedCasterOpenCoat, 0.2f }, { NPCID.Retinazer, 0.2f }, - { NPCID.RustyArmoredBonesAxe, 0.2f }, - { NPCID.RustyArmoredBonesFlail, 0.2f }, - { NPCID.RustyArmoredBonesSword, 0.2f }, - { NPCID.RustyArmoredBonesSwordNoArmor, 0.2f }, - { NPCID.SandElemental, 0.1f }, - { NPCID.SantaNK1, 0.35f }, - { NPCID.SeaSnail, 0.05f }, - { NPCID.SkeletonArcher, 0.1f }, - { NPCID.SkeletonCommando, 0.2f }, - { NPCID.SkeletonSniper, 0.2f }, - { NPCID.SkeletronHand, 0.05f }, - { NPCID.SkeletronHead, 0.05f }, { NPCID.SkeletronPrime, 0.2f }, { NPCID.Spazmatism, 0.2f }, - { NPCID.TacticalSkeleton, 0.2f }, { NPCID.TheDestroyer, 0.1f }, { NPCID.TheDestroyerBody, 0.2f }, { NPCID.TheDestroyerTail, 0.35f }, - { NPCID.TheHungry, 0.1f }, - { NPCID.UndeadViking, 0.1f }, - { NPCID.WalkingAntlion, 0.1f }, - { NPCID.WallofFlesh, 0.5f }, + { NPCID.WallofFlesh, 0.15f }, }; #endregion @@ -1524,7 +1098,7 @@ namespace CalamityMod.NPCs { NPCID.Creeper, 1800 }, // 0:30 (30 seconds, length of Creepers phase) { NPCID.Deerclops, 5400 }, // 1:30 (90 seconds) { NPCID.QueenBee, 7200 }, // 2:00 (120 seconds) - { NPCID.SkeletronHead, 9000 }, // 2:30 (150 seconds) + { NPCID.SkeletronHead, 7200 }, // 2:00 (120 seconds) { NPCID.WallofFlesh, 7200 }, // 2:00 (120 seconds) { NPCID.WallofFleshEye, 7200 }, { NPCID.QueenSlimeBoss, 7200 }, // 2:00 (120 seconds) @@ -1535,10 +1109,10 @@ namespace CalamityMod.NPCs { NPCID.TheDestroyerTail, 10800 }, { NPCID.SkeletronPrime, 10800 }, // 3:00 (180 seconds) { NPCID.Plantera, 10800 }, // 3:00 (180 seconds) - { NPCID.HallowBoss, 10800 }, // 3:00 (180 seconds) { NPCID.Golem, 9000 }, // 2:30 (150 seconds) { NPCID.GolemHead, 3600 }, // 1:00 (60 seconds) { NPCID.DukeFishron, 9000 }, // 2:30 (150 seconds) + { NPCID.HallowBoss, 10800 }, // 3:00 (180 seconds) { NPCID.CultistBoss, 9000 }, // 2:30 (150 seconds) { NPCID.MoonLordCore, 14400 }, // 4:00 (240 seconds) { NPCID.MoonLordHand, 7200 }, // 2:00 (120 seconds) @@ -1564,7 +1138,7 @@ namespace CalamityMod.NPCs { NPCType(), 9000 }, { NPCType(), 9000 }, { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 14400 }, // 4:00 (240 seconds) + { NPCType(), 10800 }, // 3:00 (180 seconds) { NPCType(), 10800 }, // 3:00 (180 seconds) { NPCType(), 10800 }, { NPCType(), 10800 }, // 3:00 (180 seconds) @@ -1573,8 +1147,8 @@ namespace CalamityMod.NPCs { NPCType(), 7200 }, { NPCType(), 10800 }, // 3:00 (180 seconds) { NPCType(), 10800 }, // 3:00 (180 seconds) - { NPCType(), 5400 }, // 1:30 (90 seconds) - { NPCType(), 7200 }, // 2:00 (120 seconds) + { NPCType(), 7200 }, // 2:00 (120 seconds) + { NPCType(), 7200 }, // 2:00 (120 seconds) { NPCType(), 14400 }, // 4:00 (240 seconds) { NPCType(), 10800 }, // 3:00 (180 seconds) { NPCType(), 1200 }, // 0:20 (20 seconds) @@ -1587,7 +1161,7 @@ namespace CalamityMod.NPCs { NPCType(), 14400 }, // 4:00 (240 seconds) { NPCType(), 14400 }, // DoG Phase 1 is 1:30, DoG Phase 2 is 2:30 { NPCType(), 14400 }, - { NPCType(), 14700 }, // 4:05 (245 seconds) -- he spends 5 seconds invincible where you can't do anything + { NPCType(), 14400 }, // 4:00 (240 seconds) { NPCType(), 21600 }, // 6:00 (360 seconds) { NPCType(), 21600 }, { NPCType(), 21600 }, // 6:00 (360 seconds) @@ -1615,8 +1189,6 @@ namespace CalamityMod.NPCs public override void SetDefaults(NPC npc) { - ShouldFallThroughPlatforms = false; - for (int i = 0; i < maxPlayerImmunities; i++) dashImmunityTime[i] = 0; @@ -1632,10 +1204,8 @@ namespace CalamityMod.NPCs } // Aquatic Scourge sets kill time in AI, not here. - if (BossKillTimes.TryGetValue(npc.type, out int revKillTime) && !AquaticScourgeIDList.Includes(npc.type)) - { + if (BossKillTimes.TryGetValue(npc.type, out int revKillTime) && !CalamityNPCTypeSets.AquaticScourge.Contains(npc.type)) KillTime = revKillTime; - } // Fixing more red mistakes if (npc.type == NPCID.WallofFleshEye) @@ -1647,18 +1217,18 @@ namespace CalamityMod.NPCs DeclareBossHealthUIVariables(npc); - BaseVanillaBossHPAdjustments(npc); - if (BossRushEvent.BossRushActive) BossRushStatChanges(npc, Mod); - BossValueChanges(npc); - if (CalamityWorld.revenge) RevDeathStatChanges(npc, Mod); OtherStatChanges(npc); + // Change Queen Slime's fart sound on death to something more serious. Except GFB though because naturally + if (npc.type == NPCID.QueenSlimeBoss) + npc.DeathSound = Main.zenithWorld ? new SoundStyle("CalamityMod/Sounds/Item/GFBScreams/Scream", 8) : SoundID.NPCDeath1; + // Function lives in NPCDebuffs.cs // This applies to ALL NPCs, vanilla AND Calamity. // Calamity NPC debuff immunity definitions live here. @@ -1671,7 +1241,21 @@ namespace CalamityMod.NPCs VulnerabilitiesAndResistances(npc); - BoundNPCSafety(Mod, npc); + // Gives Brain of Cthulhu a unique boss bar in Rev+ where Creepers contribute to a Shield rather than additional Health + if (npc.type == NPCID.BrainofCthulhu && CalamityWorld.revenge) + npc.BossBar = GetInstance(); + // Replaces Moon Lord's boss bar in Rev+ to fix a health counting bug with the eyes after being killed + bool hasBar = Main.BigBossProgressBar.TryGetSpecialVanillaBossBar(npc.type, out IBigProgressBar bar); + if (hasBar && bar is MoonLordProgressBar && CalamityWorld.revenge) + npc.BossBar = GetInstance(); + } + + public override bool? CanFallThroughPlatforms(NPC npc) + { + // Allow the free Golem Head to pass through platforms in Rev+ + if (npc.type == NPCID.GolemHeadFree && (CalamityWorld.revenge || BossRushEvent.BossRushActive)) + return true; + return base.CanFallThroughPlatforms(npc); } #endregion @@ -1683,300 +1267,196 @@ namespace CalamityMod.NPCs } #endregion - #region Base Vanilla Boss HP Adjustments - private void BaseVanillaBossHPAdjustments(NPC npc) - { - switch (npc.type) - { - case NPCID.MoonLordCore: - npc.lifeMax = 92000; - break; - - case NPCID.CultistBoss: - npc.lifeMax = 80000; - break; - - case NPCID.CultistDragonBody1: - case NPCID.CultistDragonBody2: - case NPCID.CultistDragonBody3: - case NPCID.CultistDragonBody4: - case NPCID.CultistDragonHead: - case NPCID.CultistDragonTail: - npc.lifeMax = 20000; - break; - - case NPCID.AncientCultistSquidhead: - npc.lifeMax = 3200; - break; - - case NPCID.DukeFishron: - npc.lifeMax = 100000; - break; - - case NPCID.Golem: - npc.lifeMax = 30000; - break; - - case NPCID.GolemHead: - npc.lifeMax = 20000; - break; - - case NPCID.GolemFistRight: - case NPCID.GolemFistLeft: - npc.lifeMax = 7000; - break; - - case NPCID.HallowBoss: - npc.lifeMax = 100000; - break; - - case NPCID.Plantera: - npc.lifeMax = 80000; - break; - - case NPCID.PlanterasTentacle: - npc.lifeMax = 500; - break; - - case NPCID.Retinazer: - npc.lifeMax = 23500; - break; - - case NPCID.Spazmatism: - npc.lifeMax = 24500; - break; - - case NPCID.QueenSlimeBoss: - npc.lifeMax = 27000; - break; - - case NPCID.WallofFlesh: - case NPCID.WallofFleshEye: - npc.lifeMax = 12800; - break; - - case NPCID.Deerclops: - npc.lifeMax = 10000; - break; - - case NPCID.BrainofCthulhu: - npc.lifeMax = 1500; - break; - - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsTail: - npc.lifeMax = 175; - break; - - case NPCID.EyeofCthulhu: - npc.lifeMax = 3000; - break; - } - } - #endregion - #region Boss Rush Stat Changes private void BossRushStatChanges(NPC npc, Mod mod) { - if (BossRushHPChangeDict.TryGet(npc.type, out var newHP)) + if (CalamityNPCSets.BossRushHealth.TryGetValue(npc.type, out var newHP)) { npc.lifeMax = newHP; } } #endregion - #region Boss Value Changes - private void BossValueChanges(NPC npc) - { - if (BossValueDict.TryGet(npc.type, out var value)) - { - npc.value = value; - } - } - #endregion - #region Revengeance and Death Mode Stat Changes private void RevDeathStatChanges(NPC npc, Mod mod) { - if (DeathModeSplittingWormList.Includes(npc.type)) + // Health changes (disabled in Boss Rush) + if (!BossRushEvent.BossRushActive) { - if (CalamityWorld.death) - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.15); + switch (npc.type) + { + case NPCID.KingSlime: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); + break; + case NPCID.EyeofCthulhu: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); + break; + case NPCID.ServantofCthulhu: + npc.lifeMax *= 4; + break; + case NPCID.BrainofCthulhu: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.75); + break; + case NPCID.QueenBee: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); + break; + case NPCID.Bee: + case NPCID.BeeSmall: + if (CalamityPlayer.areThereAnyDamnBosses) + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); + break; + case NPCID.Deerclops: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); + break; + case NPCID.SkeletronHand: + npc.lifeMax = (int)Math.Round(npc.lifeMax * (CalamityWorld.death ? 0.5 : 0.75)); + break; + case NPCID.WallofFlesh: + case NPCID.WallofFleshEye: + npc.lifeMax *= 2; + break; + case NPCID.QueenSlimeBoss: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); + break; + case NPCID.Retinazer: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); + break; + case NPCID.Spazmatism: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.3); + break; + case NPCID.Probe: + if (CalamityWorld.death) + npc.lifeMax *= 2; + break; + case NPCID.SkeletronPrime: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); + break; + case NPCID.PrimeCannon: + case NPCID.PrimeSaw: + case NPCID.PrimeVice: + case NPCID.PrimeLaser: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.65); + break; + case NPCID.Plantera: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.85); + break; + case NPCID.PlanterasTentacle: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); + break; + case NPCID.Golem: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 3.2); + break; + case NPCID.GolemHead: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.28); + break; + case NPCID.GolemFistLeft: + case NPCID.GolemFistRight: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.75); + break; + case NPCID.DukeFishron: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.3); + break; + case NPCID.Sharkron: + case NPCID.Sharkron2: + npc.lifeMax *= 5; + break; + case NPCID.HallowBoss: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.7); + break; + case NPCID.CultistBoss: + npc.lifeMax *= 3; + break; + case NPCID.AncientCultistSquidhead: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); + break; + case NPCID.MoonLordCore: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.2); + break; + case NPCID.MoonLordHand: + case NPCID.MoonLordHead: + case NPCID.MoonLordLeechBlob: + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); + break; + } + + if (npc.type >= NPCID.CultistDragonHead && npc.type <= NPCID.CultistDragonTail) + { + npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.4); + } + else if (CalamityNPCTypeSets.Destroyer.Contains(npc.type)) + { + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.25); + } + else if (CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type)) + { + npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); + } } - if (npc.type == NPCID.Mothron) + // Other stat changes + switch (npc.type) { - npc.scale *= 1.25f; + case NPCID.KingSlime: + npc.scale = CalamityWorld.death ? (Main.getGoodWorld ? 6f : 2.5f) : (Main.getGoodWorld ? 3f : 1.5f); + break; + case NPCID.QueenBee: + npc.defense = 14; + npc.defDefense = npc.defense; + break; + case NPCID.Bee: + case NPCID.BeeSmall: + if (CalamityPlayer.areThereAnyDamnBosses) + npc.scale *= 1.25f; + break; + case NPCID.Probe: + npc.scale *= Main.zenithWorld ? 2f : 1.2f; + break; + case NPCID.PrimeCannon: + case NPCID.PrimeSaw: + case NPCID.PrimeVice: + case NPCID.PrimeLaser: + npc.scale *= 1.15f; + break; + case NPCID.GolemFistLeft: + case NPCID.GolemFistRight: + npc.scale *= 1.15f; + break; + case NPCID.Mothron: + npc.scale *= 1.25f; + break; + case NPCID.Ghost: + case NPCID.IceMimic: + case NPCID.Mimic: + case NPCID.PresentMimic: + case NPCID.Reaper: + case NPCID.SandElemental: + case NPCID.Wraith: + if (Main.getGoodWorld) + npc.knockBackResist = 0f; + break; } - else if (npc.type == NPCID.MoonLordCore || npc.type == NPCID.MoonLordHand || npc.type == NPCID.MoonLordHead || npc.type == NPCID.MoonLordLeechBlob) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - if (npc.type == NPCID.MoonLordCore) - npc.npcSlots = 36f; - } - else if (npc.type == NPCID.CultistBoss || (npc.type >= NPCID.CultistDragonHead && npc.type <= NPCID.CultistDragonTail) || npc.type == NPCID.AncientCultistSquidhead) + if (CalamityNPCTypeSets.Destroyer.Contains(npc.type)) { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - - if (npc.type == NPCID.CultistBoss) - npc.npcSlots = 20f; + npc.scale *= Main.zenithWorld ? 2f : 1.2f; } - else if (npc.type == NPCID.DukeFishron) + else if (CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type)) { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); - npc.npcSlots = 20f; - } - else if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 5D); - } - else if (npc.type == NPCID.Golem || npc.type == NPCID.GolemHead) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); - - if (npc.type == NPCID.Golem) - npc.npcSlots = 64f; - } - else if (npc.type == NPCID.GolemHeadFree) - { - npc.dontTakeDamage = false; - } - else if (npc.type == NPCID.HallowBoss) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - npc.npcSlots = 32f; - } - else if (npc.type == NPCID.Plantera) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - npc.npcSlots = 32f; - } - else if (DestroyerIDList.Includes(npc.type)) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.25); - npc.scale *= Main.zenithWorld ? 2f : CalamityWorld.death ? 1.4f : 1.2f; - npc.npcSlots = 10f; - } - else if (npc.type == NPCID.Probe) - { - if (CalamityWorld.death) - npc.lifeMax = (int)Math.Round(npc.lifeMax * 2D); - - npc.scale *= Main.zenithWorld ? 2f : CalamityWorld.death ? 1.4f : 1.2f; - } - else if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType()) - { - // HP boosted in Master Mode due to having two heads (piercing can make them die faster than normal here since they share an HP bar) - npc.lifeMax = (int)Math.Round(npc.lifeMax * (Main.masterMode ? 1.7 : 1.2)); - npc.npcSlots = 12f; - } - else if (npc.type <= NPCID.PrimeLaser && npc.type >= NPCID.PrimeCannon) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.55); - } - else if (npc.type == NPCID.Retinazer || npc.type == NPCID.Spazmatism || npc.type == NPCType()) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - npc.npcSlots = 10f; - } - else if (npc.type == NPCID.QueenSlimeBoss) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - npc.npcSlots = 32f; - } - else if (npc.type == NPCID.WallofFlesh || npc.type == NPCID.WallofFleshEye) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.3); - - if (npc.type == NPCID.WallofFlesh) - npc.npcSlots = 20f; - } - else if (npc.type == NPCID.Deerclops) - { - npc.npcSlots = 16f; - } - else if (npc.type == NPCID.SkeletronHead) - { - /*if (CalamityWorld.death) - npc.lifeMax = (int)(npc.lifeMax * 0.65); - else - npc.lifeMax = (int)(npc.lifeMax * 0.9);*/ - - npc.npcSlots = 12f; - } - else if (npc.type == NPCID.SkeletronHand) - { - if (CalamityWorld.death) - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); - else - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.75); - } - else if (npc.type == NPCID.QueenBee) - { - npc.defense = 14; - npc.defDefense = npc.defense; - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.8); - npc.npcSlots = 14f; - } - else if ((npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) && CalamityPlayer.areThereAnyDamnBosses) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.5); - npc.scale *= 1.25f; - } - else if (npc.type == NPCID.BrainofCthulhu) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.65); - npc.npcSlots = 12f; - } - else if (npc.type == NPCID.Creeper) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); - } - else if (EaterOfWorldsIDList.Includes(npc.type)) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.2); - - if (npc.type == NPCID.EaterofWorldsHead) - npc.npcSlots = 10f; - if (CalamityWorld.death) npc.scale *= 1.1f; } - else if (npc.type == NPCID.EyeofCthulhu) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 1.4); - npc.npcSlots = 10f; - } - else if (npc.type == NPCID.ServantofCthulhu) - { - npc.lifeMax = (int)Math.Round(npc.lifeMax * 4D); - } - else if (npc.type == NPCID.KingSlime) - { - if (CalamityWorld.death) - npc.scale = Main.getGoodWorld ? 6f : 2.5f; - else - npc.scale = Main.getGoodWorld ? 3f : 1.5f; - - npc.lifeMax = (int)Math.Round(npc.lifeMax * (Main.getGoodWorld ? 1.8 : 1.5)); - } - else if ((npc.type == NPCID.Wraith || npc.type == NPCID.Mimic || npc.type == NPCID.Reaper || npc.type == NPCID.PresentMimic || npc.type == NPCID.SandElemental || npc.type == NPCID.Ghost) && CalamityWorld.LegendaryMode) - { - npc.knockBackResist = 0f; - } } #endregion #region Vulnerabilities and Resistances private void VulnerabilitiesAndResistances(NPC npc) { - // These enemies are categorized in such a way to make them easy to understand. - // Do not mess with these categories unless you ask me for permission - Fab. + // These enemies are categorized in such a way to make them easy to understand + // Regroup these if necessary, reminder to keep it comprehensive switch (npc.type) { - // Regular organic desert enemies. + // Organic desert enemies: +Cold, +Sickness, +Water + #region Organic Desert case NPCID.Antlion: case NPCID.GiantWalkingAntlion: case NPCID.FlyingAntlion: @@ -2009,8 +1489,9 @@ namespace CalamityMod.NPCs VulnerableToSickness = true; VulnerableToWater = true; break; + #endregion - // Scorpions and sand elemental. + // Sand Poacher and Sand Elemental: +Cold, +Water, -Sickness case NPCID.DesertScorpionWalk: case NPCID.DesertScorpionWall: case NPCID.SandElemental: @@ -2019,7 +1500,7 @@ namespace CalamityMod.NPCs VulnerableToWater = true; break; - // Desert slimes. + // Sand Slime: +Cold, +Water, +Heat, -Sickness case NPCID.SandSlime: VulnerableToCold = true; VulnerableToSickness = false; @@ -2027,17 +1508,16 @@ namespace CalamityMod.NPCs VulnerableToHeat = true; break; - // Organic undead or other enemies that are covered in slime. + // Organic undead enemies covered in slime: +Cold, +Heat case NPCID.ArmedZombieSlimed: case NPCID.BigSlimedZombie: - case NPCID.BunnySlimed: case NPCID.SlimedZombie: case NPCID.SmallSlimedZombie: VulnerableToCold = true; VulnerableToHeat = true; break; - // Slimes that use heat-related attacks. + // Lava Slime: +Cold, +Water, -Sickness, -Heat case NPCID.LavaSlime: VulnerableToCold = true; VulnerableToSickness = false; @@ -2045,7 +1525,8 @@ namespace CalamityMod.NPCs VulnerableToWater = true; break; - // Regular slimes. + // Regular slimes: +Heat, -Sickness + #region Slimes case NPCID.QueenSlimeBoss: case NPCID.QueenSlimeMinionBlue: case NPCID.QueenSlimeMinionPink: @@ -2086,8 +1567,9 @@ namespace CalamityMod.NPCs VulnerableToSickness = false; VulnerableToHeat = true; break; + #endregion - // Skeletons and other armored/bone enemies that use heat-related attacks. + // Skeleton enemies that are heat-related: +Cold, +Water, -Heat, -Sickness case NPCID.HellArmoredBones: case NPCID.HellArmoredBonesMace: case NPCID.HellArmoredBonesSpikeShield: @@ -2100,14 +1582,15 @@ namespace CalamityMod.NPCs VulnerableToWater = true; break; - // Spore skeleton. + // Spore Skeleton: +Heat, +Water, -Sickness case NPCID.SporeSkeleton: VulnerableToHeat = true; VulnerableToSickness = false; VulnerableToWater = true; break; - // Skeletons and other armored/bone enemies that are dead or undead. + // Skeleton and rock enemies: +Water, -Sickness + #region Skeletons And Rock Enemies case NPCID.SkeletronHand: case NPCID.SkeletronHead: case NPCID.AngryBones: @@ -2180,8 +1663,9 @@ namespace CalamityMod.NPCs VulnerableToSickness = false; VulnerableToWater = true; break; + #endregion - // Metal non-robotic enemies + // Metal non-robotic enemies: -Sickness case NPCID.BigMimicCorruption: case NPCID.BigMimicCrimson: case NPCID.BigMimicHallow: @@ -2194,7 +1678,8 @@ namespace CalamityMod.NPCs VulnerableToSickness = false; break; - // Robotic enemies. + // Robotic enemies: +Electricity, -Sickness + #region Robots case NPCID.Probe: case NPCID.MartianProbe: case NPCID.DeadlySphere: @@ -2219,8 +1704,10 @@ namespace CalamityMod.NPCs VulnerableToElectricity = true; VulnerableToSickness = false; break; + #endregion - // Ghostly or ethereal enemies. + // Ghostly or ethereal enemies: -Sickness + #region Ghosts case NPCID.DungeonSpirit: case NPCID.AncientCultistSquidhead: case NPCID.CultistDragonBody1: @@ -2243,8 +1730,10 @@ namespace CalamityMod.NPCs case NPCID.PirateGhost: VulnerableToSickness = false; break; + #endregion - // Organic enemies. + // Organic enemies: +Cold, +Heat, +Sickness + #region Organic Enemies case NPCID.HallowBoss: case NPCID.Dandelion: case NPCID.Gnome: @@ -2502,8 +1991,10 @@ namespace CalamityMod.NPCs VulnerableToHeat = true; VulnerableToSickness = true; break; + #endregion - // Demons and shit. + // Demons: +Cold, +Sickness, -Heat + #region Demons case NPCID.WallofFlesh: case NPCID.WallofFleshEye: case NPCID.TheHungry: @@ -2519,8 +2010,9 @@ namespace CalamityMod.NPCs VulnerableToHeat = false; VulnerableToSickness = true; break; + #endregion - // Fire enemies that are also organic. + // Fiery organic enemies: +Cold, +Sickness, +Water, -Heat case NPCID.FireImp: case NPCID.Hellbat: case NPCID.Lavabat: @@ -2530,7 +2022,7 @@ namespace CalamityMod.NPCs VulnerableToWater = true; break; - // Fire enemies that aren't organic. + // Meteor Head: +Cold, +Water, -Heat, -Sickness case NPCID.MeteorHead: VulnerableToCold = true; VulnerableToHeat = false; @@ -2538,7 +2030,7 @@ namespace CalamityMod.NPCs VulnerableToWater = true; break; - // Lightning bug thing. + // Lightning Bug: +Cold, +Heat, +Sickness, -Electricity case NPCID.DD2LightningBugT3: VulnerableToElectricity = false; VulnerableToCold = true; @@ -2546,14 +2038,14 @@ namespace CalamityMod.NPCs VulnerableToSickness = true; break; - // Betsy. + // Betsy: +Cold, +Sickness, -Heat case NPCID.DD2Betsy: VulnerableToCold = true; VulnerableToHeat = false; VulnerableToSickness = true; break; - // Nimbus + // Angry Nimbus: +Cold, -Heat, -Sickness, -Electricity, -Water case NPCID.AngryNimbus: VulnerableToCold = true; VulnerableToElectricity = false; @@ -2562,7 +2054,8 @@ namespace CalamityMod.NPCs VulnerableToSickness = false; break; - // Cold-themed enemies + // Cold organic enemies: +Heat, +Sickness, -Cold + #region Cold Organic case NPCID.ArmedZombieEskimo: case NPCID.ZombieEskimo: case NPCID.IceBat: @@ -2588,8 +2081,10 @@ namespace CalamityMod.NPCs VulnerableToCold = false; VulnerableToSickness = true; break; + #endregion - // Cold-themed enemies that aren't organic. + // Cold non-organic enemies: +Heat, -Cold, -Sickness + #region Cold Non-Organic case NPCID.IceElemental: case NPCID.IceSlime: case NPCID.SpikedIceSlime: @@ -2605,8 +2100,10 @@ namespace CalamityMod.NPCs VulnerableToHeat = true; VulnerableToSickness = false; break; + #endregion - // Water-themed enemies. + // Fish and aquatic enemies: +Sickness, +Electricity, -Water, -Heat + #region Aquatic Enemies case NPCID.Crawdad: case NPCID.Crawdad2: case NPCID.BlueJellyfish: @@ -2634,8 +2131,10 @@ namespace CalamityMod.NPCs VulnerableToElectricity = true; VulnerableToWater = false; break; + #endregion - // Fucking bees, hornets and poisonous/toxic stuff. + // Bees, Hornets, and poisonous enemies: +Cold, +Heat, -Sickness + #region Bees and Poisonous case NPCID.Bee: case NPCID.BeeSmall: case NPCID.QueenBee: @@ -2670,6 +2169,209 @@ namespace CalamityMod.NPCs VulnerableToHeat = true; VulnerableToSickness = false; break; + #endregion + + // Town NPCs. Mostly irrelevant, but it displays in the Bestiary + #region Town NPCs + case NPCID.Merchant: + case NPCID.Nurse: + case NPCID.ArmsDealer: + case NPCID.Dryad: + case NPCID.Guide: + case NPCID.OldMan: + case NPCID.Demolitionist: + case NPCID.Clothier: + case NPCID.BoundGoblin: + case NPCID.BoundWizard: + case NPCID.GoblinTinkerer: + case NPCID.Wizard: + case NPCID.BoundMechanic: + case NPCID.Mechanic: + case NPCID.Truffle: + case NPCID.Steampunker: + case NPCID.DyeTrader: + case NPCID.PartyGirl: + case NPCID.Painter: + case NPCID.WitchDoctor: + case NPCID.Pirate: + case NPCID.Stylist: + case NPCID.WebbedStylist: + case NPCID.TravellingMerchant: + case NPCID.Angler: + case NPCID.SleepingAngler: + case NPCID.DD2Bartender: + case NPCID.BartenderUnconscious: + case NPCID.Golfer: + case NPCID.GolferRescue: + case NPCID.BestiaryGirl: + case NPCID.Princess: + case NPCID.TownCat: + case NPCID.TownDog: + case NPCID.TownBunny: + VulnerableToCold = true; + VulnerableToHeat = true; + VulnerableToSickness = true; + break; + case NPCID.SantaClaus: + VulnerableToCold = false; + VulnerableToHeat = true; + VulnerableToSickness = true; + break; + case NPCID.TaxCollector: + VulnerableToCold = true; + VulnerableToHeat = false; + VulnerableToSickness = true; + break; + // Non-organic Town NPCs. + case NPCID.Cyborg: + case NPCID.BoundTownSlimeOld: + VulnerableToSickness = false; + break; + // Town Slimes. + case NPCID.TownSlimeBlue: + case NPCID.TownSlimeGreen: + case NPCID.TownSlimeOld: + case NPCID.TownSlimePurple: + case NPCID.TownSlimeRainbow: + case NPCID.TownSlimeRed: + case NPCID.TownSlimeYellow: + case NPCID.TownSlimeCopper: + case NPCID.BoundTownSlimePurple: + VulnerableToSickness = false; + VulnerableToHeat = true; + break; + #endregion + + // Critters + #region Critters + case NPCID.Bunny: + case NPCID.Bird: + case NPCID.BirdBlue: + case NPCID.BirdRed: + case NPCID.Squirrel: + case NPCID.Mouse: + case NPCID.BunnySlimed: + case NPCID.BunnyXmas: + case NPCID.Firefly: + case NPCID.Butterfly: + case NPCID.Worm: + case NPCID.LightningBug: + case NPCID.Snail: + case NPCID.GlowingSnail: + case NPCID.Frog: + case NPCID.Duck: + case NPCID.Duck2: + case NPCID.DuckWhite: + case NPCID.DuckWhite2: + case NPCID.ScorpionBlack: + case NPCID.Scorpion: + case NPCID.TruffleWorm: + case NPCID.TruffleWormDigger: + case NPCID.Grasshopper: + case NPCID.GoldBird: + case NPCID.GoldBunny: + case NPCID.GoldButterfly: + case NPCID.GoldFrog: + case NPCID.GoldGrasshopper: + case NPCID.GoldMouse: + case NPCID.GoldWorm: + case NPCID.EnchantedNightcrawler: + case NPCID.Grubby: + case NPCID.Sluggy: + case NPCID.Buggy: + case NPCID.SquirrelRed: + case NPCID.SquirrelGold: + case NPCID.PartyBunny: + case NPCID.BlackDragonfly: + case NPCID.BlueDragonfly: + case NPCID.GreenDragonfly: + case NPCID.OrangeDragonfly: + case NPCID.RedDragonfly: + case NPCID.YellowDragonfly: + case NPCID.GoldDragonfly: + case NPCID.Seagull: + case NPCID.Seagull2: + case NPCID.LadyBug: + case NPCID.GoldLadyBug: + case NPCID.Maggot: + case NPCID.Grebe: + case NPCID.Grebe2: + case NPCID.Rat: + case NPCID.Owl: + case NPCID.WaterStrider: + case NPCID.GoldWaterStrider: + case NPCID.ExplosiveBunny: + case NPCID.EmpressButterfly: + case NPCID.Stinkbug: + case NPCID.ScarletMacaw: + case NPCID.BlueMacaw: + case NPCID.Toucan: + case NPCID.YellowCockatiel: + case NPCID.GrayCockatiel: + case NPCID.Shimmerfly: + case NPCID.BoundTownSlimeYellow: + VulnerableToCold = true; + VulnerableToHeat = true; + VulnerableToSickness = true; + break; + // Water Critters + case NPCID.Goldfish: + case NPCID.GoldfishWalker: + case NPCID.GoldGoldfish: + case NPCID.GoldGoldfishWalker: + case NPCID.Pupfish: + case NPCID.Dolphin: + case NPCID.Turtle: + case NPCID.TurtleJungle: + case NPCID.SeaTurtle: + case NPCID.Seahorse: + case NPCID.GoldSeahorse: + VulnerableToHeat = false; + VulnerableToSickness = true; + VulnerableToElectricity = true; + VulnerableToWater = false; + break; + // Penguins + case NPCID.Penguin: + case NPCID.PenguinBlack: + VulnerableToCold = false; + VulnerableToHeat = true; + VulnerableToSickness = true; + break; + // Fairies + case NPCID.FairyCritterPink: + case NPCID.FairyCritterGreen: + case NPCID.FairyCritterBlue: + VulnerableToSickness = false; + break; + // Gem Critters + case NPCID.GemSquirrelAmethyst: + case NPCID.GemSquirrelTopaz: + case NPCID.GemSquirrelSapphire: + case NPCID.GemSquirrelEmerald: + case NPCID.GemSquirrelRuby: + case NPCID.GemSquirrelDiamond: + case NPCID.GemSquirrelAmber: + case NPCID.GemBunnyAmethyst: + case NPCID.GemBunnyTopaz: + case NPCID.GemBunnySapphire: + case NPCID.GemBunnyEmerald: + case NPCID.GemBunnyDiamond: + case NPCID.GemBunnyAmber: + VulnerableToCold = true; + VulnerableToSickness = true; + VulnerableToWater = true; + break; + // Underworld Critters + case NPCID.HellButterfly: + case NPCID.Lavafly: + case NPCID.MagmaSnail: + VulnerableToCold = true; + VulnerableToHeat = false; + VulnerableToSickness = true; + VulnerableToWater = true; + break; + #endregion } } #endregion @@ -2679,14 +2381,7 @@ namespace CalamityMod.NPCs { EditGlobalCoinDrops(npc); - // Put this first so that any boss damage value modifications aren't reset - bool vanillaNPC = npc.type < NPCID.Count; - if (vanillaNPC && NPCStats.EnemyStats.ContactDamageValues.ContainsKey(npc.type)) - { - npc.GetNPCDamage(); - npc.defDamage = npc.damage; - } - if ((npc.boss && npc.type != NPCID.MartianSaucerCore) || BossHPScalingList.Includes(npc.type)) + if ((npc.boss && npc.type != NPCID.MartianSaucerCore) || CalamityNPCSets.ScalesHealthLikeBoss[npc.type]) { double HPBoost = CalamityServerConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)Math.Round(npc.lifeMax * HPBoost); @@ -2698,44 +2393,15 @@ namespace CalamityMod.NPCs case NPCID.EyeofCthulhu: case NPCID.BrainofCthulhu: case NPCID.QueenBee: - case NPCID.Corruptor: - case NPCID.Crawdad: - case NPCID.Crawdad2: - case NPCID.ManEater: - case NPCID.AngryTrapper: - case NPCID.Snatcher: - case NPCID.SpikeBall: - case NPCID.DesertBeast: - case NPCID.BoneLee: case NPCID.Paladin: case NPCID.BigMimicCorruption: case NPCID.BigMimicCrimson: case NPCID.BigMimicHallow: - case NPCID.DiggerHead: - case NPCID.SeekerHead: - case NPCID.DuneSplicerHead: - case NPCID.SolarCrawltipedeHead: - case NPCID.Mimic: - case NPCID.SandShark: - case NPCID.SandsharkCorrupt: - case NPCID.SandsharkCrimson: - case NPCID.SandsharkHallow: - case NPCID.Butcher: - case NPCID.DeadlySphere: case NPCID.Mothron: - case NPCID.Reaper: - case NPCID.Psycho: - case NPCID.PresentMimic: - case NPCID.Yeti: - case NPCID.NebulaBeast: - case NPCID.SolarCorite: - case NPCID.StardustWormHead: case NPCID.EaterofWorldsHead: case NPCID.SkeletronHead: - case NPCID.SkeletronHand: + case NPCID.DungeonGuardian: case NPCID.WallofFlesh: - case NPCID.TheHungry: - case NPCID.TheHungryII: case NPCID.Spazmatism: case NPCID.Retinazer: case NPCID.TheDestroyer: @@ -2750,56 +2416,30 @@ namespace CalamityMod.NPCs case NPCID.GolemFistLeft: case NPCID.GolemFistRight: case NPCID.CultistDragonHead: - case NPCID.AncientCultistSquidhead: - case NPCID.AncientLight: case NPCID.DD2OgreT2: case NPCID.DD2OgreT3: case NPCID.DD2Betsy: case NPCID.PumpkingBlade: case NPCID.SantaNK1: case NPCID.DukeFishron: - case NPCID.RockGolem: - case NPCID.BloodEelHead: case NPCID.BloodNautilus: - case NPCID.GoblinShark: - case NPCID.ZombieMerman: case NPCID.HallowBoss: case NPCID.QueenSlimeBoss: case NPCID.Deerclops: canBreakPlayerDefense = true; break; - // Enemies that should have coldDamage set to true - case NPCID.IceMimic: - canBreakPlayerDefense = true; - npc.coldDamage = true; - break; - - case NPCID.IceBat: - case NPCID.IceTortoise: - npc.coldDamage = true; - break; - // These go through walls and are very annoying with the new tombstone breaking spawning them mechanic in 1.4 case NPCID.Ghost: npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); break; - case NPCID.PirateGhost: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.33); - break; - case NPCID.BloodSquid: npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.25); break; - case NPCID.ChatteringTeethBomb: - npc.damage = 100; - canBreakPlayerDefense = true; - break; - case NPCID.LarvaeAntlion: - npc.lifeMax = 15; + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); break; // Reduce prehardmode desert enemy stats @@ -2810,7 +2450,6 @@ namespace CalamityMod.NPCs npc.defDamage = npc.damage; npc.defense /= 2; npc.defDefense = npc.defense; - canBreakPlayerDefense = true; break; case NPCID.Antlion: @@ -2823,19 +2462,11 @@ namespace CalamityMod.NPCs npc.defDefense = npc.defense; break; - // Reduce Dungeon Guardian HP - case NPCID.DungeonGuardian: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.1); - canBreakPlayerDefense = true; - break; - // Reduce Tomb Crawler stats case NPCID.TombCrawlerHead: npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); npc.damage = (int)Math.Round(npc.damage * DesertEnemyStatMultiplier); npc.defDamage = npc.damage; - // Tomb Crawler Head has 0 defense so there is no need to reduce it - canBreakPlayerDefense = true; break; case NPCID.TombCrawlerBody: @@ -2852,28 +2483,23 @@ namespace CalamityMod.NPCs case NPCID.Sharkron2: npc.width = npc.height = 36; npc.chaseable = false; - canBreakPlayerDefense = true; break; - // Fix drawing issues with Golem's Free Head - case NPCID.GolemHeadFree: - npc.width = 88; - npc.height = 90; - break; - - // Make Core hitbox bigger and reduce HP + // Make Core hitbox bigger case NPCID.MartianSaucerCore: - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.6); npc.width *= 2; npc.height *= 2; break; - // Nerf Green Jellyfish because they spawn in prehardmode + // Nerf Green Jellyfish stats in pre-Hardmode case NPCID.GreenJellyfish: - npc.damage = 40; - npc.defDamage = npc.damage; - npc.defense = 4; - npc.defDefense = npc.defense; + if (!Main.hardMode) + { + npc.damage = 40; + npc.defDamage = npc.damage; + npc.defense = 4; + npc.defDefense = npc.defense; + } break; // Make Plantera's Spores immune to damage because otherwise they're pointless @@ -2881,9 +2507,10 @@ namespace CalamityMod.NPCs npc.dontTakeDamage = true; break; - // Make Fishron and Anahita Bubbles immune to damage in Death Mode + // Make Fishron and Anahita Bubbles have actual health in Death Mode case NPCID.DetonatingBubble: - npc.dontTakeDamage = CalamityWorld.death; + if (CalamityWorld.death) + npc.lifeMax = 300; break; default: @@ -2895,7 +2522,7 @@ namespace CalamityMod.NPCs { if (!NPC.downedMechBossAny) { - if (DestroyerIDList.Includes(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDList.Includes(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer || npc.type == NPCType()) + if (CalamityNPCTypeSets.Destroyer.Contains(npc.type) || npc.type == NPCID.Probe || CalamityNPCTypeSets.SkeletronPrime.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) { double multiplier = Main.expertMode ? EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; npc.lifeMax = (int)Math.Round(npc.lifeMax * multiplier); @@ -2905,7 +2532,7 @@ namespace CalamityMod.NPCs } else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) { - if (DestroyerIDList.Includes(npc.type) || npc.type == NPCID.Probe || SkeletronPrimeIDList.Includes(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer || npc.type == NPCType()) + if (CalamityNPCTypeSets.Destroyer.Contains(npc.type) || npc.type == NPCID.Probe || CalamityNPCTypeSets.SkeletronPrime.Contains(npc.type) || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) { double multiplier = Main.expertMode ? EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; npc.lifeMax = (int)Math.Round(npc.lifeMax * multiplier); @@ -2932,7 +2559,7 @@ namespace CalamityMod.NPCs } } - if (Main.hardMode && HardmodeNPCNerfList.Includes(npc.type)) + if (Main.hardMode && CalamityNPCSets.NerfDamageInHardmode[npc.type]) { npc.damage = (int)Math.Round(npc.damage * 0.75); npc.defDamage = npc.damage; @@ -2940,21 +2567,21 @@ namespace CalamityMod.NPCs if (DownedBossSystem.downedDoG) { - if (PumpkinMoonBuffList.Includes(npc.type)) + if (CalamityNPCSets.IsBuffedPumpkinMoonEnemy[npc.type]) { npc.lifeMax = (int)Math.Round(npc.lifeMax * 3.5); npc.damage += 30; npc.life = npc.lifeMax; npc.defDamage = npc.damage; } - else if (FrostMoonBuffList.Includes(npc.type)) + else if (CalamityNPCSets.IsBuffedFrostMoonEnemy[npc.type]) { npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.5); npc.damage += 30; npc.life = npc.lifeMax; npc.defDamage = npc.damage; } - else if (EclipseBuffList.Includes(npc.type)) + else if (CalamityNPCSets.IsBuffedSolarEclipseEnemy[npc.type]) { npc.lifeMax = (int)Math.Round(npc.lifeMax * 5D); npc.damage += 30; @@ -2965,7 +2592,7 @@ namespace CalamityMod.NPCs if (NPC.downedMoonlord) { - if (BuffedDungeonEnemiesList.Includes(npc.type)) + if (CalamityNPCSets.IsBuffedDungeonEnemy[npc.type]) { npc.lifeMax = (int)Math.Round(npc.lifeMax * 2.5); npc.damage += 30; @@ -2973,575 +2600,6 @@ namespace CalamityMod.NPCs npc.defDamage = npc.damage; } } - - // Nerf KB resist in Expert and Master using this roundabout method - if (Main.expertMode) - AdjustExpertModeStatScaling(npc); - - // Adjust a ton of enemy stats - switch (npc.type) - { - case NPCID.AngryBones: - case NPCID.AngryBonesBig: - case NPCID.AngryBonesBigHelmet: - case NPCID.AngryBonesBigMuscle: - case NPCID.BigBoned: - case NPCID.ShortBones: - case NPCID.AnomuraFungus: - case NPCID.Antlion: - case NPCID.WalkingAntlion: - case NPCID.GiantWalkingAntlion: - case NPCID.LarvaeAntlion: - case NPCID.FlyingAntlion: - case NPCID.GiantFlyingAntlion: - case NPCID.BabySlime: - case NPCID.BlackSlime: - case NPCID.BlazingWheel: - case NPCID.BloodCrawler: - case NPCID.BloodCrawlerWall: - case NPCID.BlueJellyfish: - case NPCID.GreenJellyfish: - case NPCID.PinkJellyfish: - case NPCID.BloodJelly: - case NPCID.FungoFish: - case NPCID.BlueSlime: - case NPCID.BoneSerpentBody: - case NPCID.BoneSerpentHead: - case NPCID.BoneSerpentTail: - case NPCID.CaveBat: - case NPCID.CochinealBeetle: - case NPCID.Crab: - case NPCID.Crawdad: - case NPCID.Crawdad2: - case NPCID.Crimera: - case NPCID.BigCrimera: - case NPCID.LittleCrimera: - case NPCID.CursedSkull: - case NPCID.CyanBeetle: - case NPCID.Demon: - case NPCID.DemonEye: - case NPCID.CataractEye: - case NPCID.CataractEye2: - case NPCID.DemonEye2: - case NPCID.DemonEyeOwl: - case NPCID.DemonEyeSpaceship: - case NPCID.DialatedEye: - case NPCID.DialatedEye2: - case NPCID.GreenEye: - case NPCID.GreenEye2: - case NPCID.PurpleEye: - case NPCID.PurpleEye2: - case NPCID.SleepyEye: - case NPCID.SleepyEye2: - case NPCID.DevourerBody: - case NPCID.DevourerHead: - case NPCID.DevourerTail: - case NPCID.DoctorBones: - case NPCID.DungeonSlime: - case NPCID.EaterofSouls: - case NPCID.BigEater: - case NPCID.LittleEater: - case NPCID.FaceMonster: - case NPCID.ArmedZombieEskimo: - case NPCID.ZombieEskimo: - case NPCID.FungiBulb: - case NPCID.Ghost: - case NPCID.GiantShelly: - case NPCID.GiantShelly2: - case NPCID.GiantWormBody: - case NPCID.GiantWormHead: - case NPCID.GiantWormTail: - case NPCID.Gnome: - case NPCID.GoblinScout: - case NPCID.GraniteFlyer: - case NPCID.GraniteGolem: - case NPCID.GreenSlime: - case NPCID.Harpy: - case NPCID.Hellbat: - case NPCID.GreekSkeleton: - case NPCID.Hornet: - case NPCID.HornetFatty: - case NPCID.HornetHoney: - case NPCID.HornetLeafy: - case NPCID.HornetSpikey: - case NPCID.HornetStingy: - case NPCID.BigHornetFatty: - case NPCID.BigHornetHoney: - case NPCID.BigHornetLeafy: - case NPCID.BigHornetSpikey: - case NPCID.BigHornetStingy: - case NPCID.BigMossHornet: - case NPCID.GiantMossHornet: - case NPCID.LittleHornetFatty: - case NPCID.LittleHornetHoney: - case NPCID.LittleHornetLeafy: - case NPCID.LittleHornetSpikey: - case NPCID.LittleHornetStingy: - case NPCID.LittleMossHornet: - case NPCID.MossHornet: - case NPCID.TinyMossHornet: - case NPCID.IceBat: - case NPCID.IceSlime: - case NPCID.JungleBat: - case NPCID.JungleSlime: - case NPCID.LacBeetle: - case NPCID.LavaSlime: - case NPCID.MaggotZombie: - case NPCID.ManEater: - case NPCID.MeteorHead: - case NPCID.MotherSlime: - case NPCID.MushiLadybug: - case NPCID.Nymph: - case NPCID.Pinky: - case NPCID.Piranha: - case NPCID.PurpleSlime: - case NPCID.Raven: - case NPCID.RedSlime: - case NPCID.Salamander: - case NPCID.Salamander2: - case NPCID.Salamander3: - case NPCID.Salamander4: - case NPCID.Salamander5: - case NPCID.Salamander6: - case NPCID.Salamander7: - case NPCID.Salamander8: - case NPCID.Salamander9: - case NPCID.SandSlime: - case NPCID.SeaSnail: - case NPCID.Shark: - case NPCID.ShimmerSlime: - case NPCID.Skeleton: - case NPCID.SkeletonAlien: - case NPCID.SkeletonAstonaut: - case NPCID.SkeletonTopHat: - case NPCID.ArmoredSkeleton: - case NPCID.BigHeadacheSkeleton: - case NPCID.BigMisassembledSkeleton: - case NPCID.BigPantlessSkeleton: - case NPCID.BigSkeleton: - case NPCID.BoneThrowingSkeleton: - case NPCID.BoneThrowingSkeleton2: - case NPCID.BoneThrowingSkeleton3: - case NPCID.BoneThrowingSkeleton4: - case NPCID.HeadacheSkeleton: - case NPCID.HeavySkeleton: - case NPCID.MisassembledSkeleton: - case NPCID.PantlessSkeleton: - case NPCID.SmallMisassembledSkeleton: - case NPCID.SmallHeadacheSkeleton: - case NPCID.SmallSkeleton: - case NPCID.SmallPantlessSkeleton: - case NPCID.SporeSkeleton: - case NPCID.TacticalSkeleton: - case NPCID.SkeletonSniper: - case NPCID.SkeletonCommando: - case NPCID.DarkCaster: - case NPCID.FireImp: - case NPCID.Snatcher: - case NPCID.SnowFlinx: - case NPCID.SpikeBall: - case NPCID.SpikedIceSlime: - case NPCID.SpikedJungleSlime: - case NPCID.SporeBat: - case NPCID.ZombieMushroom: - case NPCID.ZombieMushroomHat: - case NPCID.Squid: - case NPCID.Tim: - case NPCID.TombCrawlerBody: - case NPCID.TombCrawlerHead: - case NPCID.TombCrawlerTail: - case NPCID.UndeadMiner: - case NPCID.UndeadViking: - case NPCID.VoodooDemon: - case NPCID.Vulture: - case NPCID.WallCreeper: - case NPCID.WallCreeperWall: - case NPCID.YellowSlime: - case NPCID.Zombie: - case NPCID.ZombieDoctor: - case NPCID.ZombieElf: - case NPCID.ZombieElfBeard: - case NPCID.ZombieElfGirl: - case NPCID.ZombieMerman: - case NPCID.ZombiePixie: - case NPCID.ZombieRaincoat: - case NPCID.ZombieSuperman: - case NPCID.ZombieSweater: - case NPCID.ZombieXmas: - case NPCID.ArmedTorchZombie: - case NPCID.ArmedZombie: - case NPCID.ArmedZombieCenx: - case NPCID.ArmedZombiePincussion: - case NPCID.ArmedZombieSlimed: - case NPCID.ArmedZombieSwamp: - case NPCID.ArmedZombieTwiggy: - case NPCID.BaldZombie: - case NPCID.BigBaldZombie: - case NPCID.BigFemaleZombie: - case NPCID.BigPincushionZombie: - case NPCID.BigRainZombie: - case NPCID.BigSlimedZombie: - case NPCID.BigSwampZombie: - case NPCID.BigTwiggyZombie: - case NPCID.BigZombie: - case NPCID.BloodZombie: - case NPCID.FemaleZombie: - case NPCID.PincushionZombie: - case NPCID.SlimedZombie: - case NPCID.SmallBaldZombie: - case NPCID.SmallFemaleZombie: - case NPCID.SmallPincushionZombie: - case NPCID.SmallRainZombie: - case NPCID.SmallSlimedZombie: - case NPCID.SmallSwampZombie: - case NPCID.SmallTwiggyZombie: - case NPCID.SmallZombie: - case NPCID.SwampZombie: - case NPCID.TorchZombie: - case NPCID.TwiggyZombie: - case NPCID.AnglerFish: - case NPCID.AngryTrapper: - case NPCID.Arapaima: - case NPCID.ArmoredViking: - case NPCID.DesertBeast: - case NPCID.BlackRecluse: - case NPCID.BlackRecluseWall: - case NPCID.BloodFeeder: - case NPCID.Mummy: - case NPCID.BloodMummy: - case NPCID.DarkMummy: - case NPCID.LightMummy: - case NPCID.BlueArmoredBones: - case NPCID.BlueArmoredBonesMace: - case NPCID.BlueArmoredBonesNoPants: - case NPCID.BlueArmoredBonesSword: - case NPCID.BoneLee: - case NPCID.ChaosElemental: - case NPCID.Clinger: - case NPCID.BigMimicCorruption: - case NPCID.BigMimicCrimson: - case NPCID.BigMimicHallow: - case NPCID.BigMimicJungle: - case NPCID.CorruptSlime: - case NPCID.Corruptor: - case NPCID.Crimslime: - case NPCID.BigCrimslime: - case NPCID.LittleCrimslime: - case NPCID.CrimsonAxe: - case NPCID.CultistArcherBlue: - case NPCID.CultistArcherWhite: - case NPCID.CultistDevote: - case NPCID.CursedHammer: - case NPCID.Derpling: - case NPCID.Herpling: - case NPCID.DesertDjinn: - case NPCID.DiabolistRed: - case NPCID.DiabolistWhite: - case NPCID.DiggerBody: - case NPCID.DiggerHead: - case NPCID.DiggerTail: - case NPCID.DesertGhoul: - case NPCID.DesertGhoulCorruption: - case NPCID.DesertGhoulCrimson: - case NPCID.DesertGhoulHallow: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerTail: - case NPCID.DungeonSpirit: - case NPCID.EnchantedSword: - case NPCID.FloatyGross: - case NPCID.FlyingSnake: - case NPCID.Gastropod: - case NPCID.GiantBat: - case NPCID.GiantCursedSkull: - case NPCID.GiantFlyingFox: - case NPCID.GiantFungiBulb: - case NPCID.GiantTortoise: - case NPCID.IceTortoise: - case NPCID.HellArmoredBones: - case NPCID.HellArmoredBonesMace: - case NPCID.HellArmoredBonesSpikeShield: - case NPCID.HellArmoredBonesSword: - case NPCID.HoppinJack: - case NPCID.IceElemental: - case NPCID.Mimic: - case NPCID.IceMimic: - case NPCID.PresentMimic: - case NPCID.IchorSticker: - case NPCID.IcyMerman: - case NPCID.IlluminantBat: - case NPCID.IlluminantSlime: - case NPCID.JungleCreeper: - case NPCID.JungleCreeperWall: - case NPCID.DesertLamiaDark: - case NPCID.DesertLamiaLight: - case NPCID.Lavabat: - case NPCID.Lihzahrd: - case NPCID.LihzahrdCrawler: - case NPCID.Medusa: - case NPCID.Moth: - case NPCID.Necromancer: - case NPCID.NecromancerArmored: - case NPCID.Paladin: - case NPCID.PigronCorruption: - case NPCID.PigronCrimson: - case NPCID.PigronHallow: - case NPCID.Pixie: - case NPCID.PossessedArmor: - case NPCID.RaggedCaster: - case NPCID.RaggedCasterOpenCoat: - case NPCID.RedDevil: - case NPCID.RockGolem: - case NPCID.RuneWizard: - case NPCID.RustyArmoredBonesAxe: - case NPCID.RustyArmoredBonesFlail: - case NPCID.RustyArmoredBonesSword: - case NPCID.RustyArmoredBonesSwordNoArmor: - case NPCID.DesertScorpionWalk: - case NPCID.DesertScorpionWall: - case NPCID.SkeletonArcher: - case NPCID.Slimeling: - case NPCID.Slimer: - case NPCID.Slimer2: - case NPCID.ToxicSludge: - case NPCID.Unicorn: - case NPCID.WanderingEye: - case NPCID.Werewolf: - case NPCID.Wolf: - case NPCID.SeekerBody: - case NPCID.SeekerHead: - case NPCID.SeekerTail: - case NPCID.Wraith: - case NPCID.WyvernBody: - case NPCID.WyvernBody2: - case NPCID.WyvernBody3: - case NPCID.WyvernHead: - case NPCID.WyvernLegs: - case NPCID.WyvernTail: - case NPCID.BloodEelBody: - case NPCID.BloodEelHead: - case NPCID.BloodEelTail: - case NPCID.BloodSquid: - case NPCID.ChatteringTeethBomb: - case NPCID.Clown: - case NPCID.CorruptBunny: - case NPCID.CorruptGoldfish: - case NPCID.CorruptPenguin: - case NPCID.Drippler: - case NPCID.GoblinShark: - case NPCID.TheGroom: - case NPCID.TheBride: - case NPCID.CrimsonBunny: - case NPCID.CrimsonGoldfish: - case NPCID.CrimsonPenguin: - case NPCID.EyeballFlyingFish: - case NPCID.Dandelion: - case NPCID.AngryNimbus: - case NPCID.FlyingFish: - case NPCID.IceGolem: - case NPCID.RainbowSlime: - case NPCID.UmbrellaSlime: - case NPCID.Tumbleweed: - case NPCID.SandShark: - case NPCID.SandsharkCorrupt: - case NPCID.SandsharkCrimson: - case NPCID.SandsharkHallow: - case NPCID.SandElemental: - case NPCID.BloodNautilus: - case NPCID.GoblinArcher: - case NPCID.GoblinPeon: - case NPCID.GoblinSorcerer: - case NPCID.GoblinSummoner: - case NPCID.GoblinThief: - case NPCID.GoblinWarrior: - case NPCID.MisterStabby: - case NPCID.SnowBalla: - case NPCID.SnowmanGangsta: - case NPCID.Parrot: - case NPCID.PirateCaptain: - case NPCID.PirateCorsair: - case NPCID.PirateCrossbower: - case NPCID.PirateDeadeye: - case NPCID.PirateDeckhand: - case NPCID.PirateGhost: - case NPCID.PirateShipCannon: - case NPCID.MothronSpawn: - case NPCID.Mothron: - case NPCID.Butcher: - case NPCID.CreatureFromTheDeep: - case NPCID.DeadlySphere: - case NPCID.DrManFly: - case NPCID.Eyezor: - case NPCID.Frankenstein: - case NPCID.Fritz: - case NPCID.Nailhead: - case NPCID.Psycho: - case NPCID.Reaper: - case NPCID.ThePossessed: - case NPCID.SwampThing: - case NPCID.Vampire: - case NPCID.VampireBat: - case NPCID.BrainScrambler: - case NPCID.GigaZapper: - case NPCID.MartianWalker: - case NPCID.GrayGrunt: - case NPCID.MartianDrone: - case NPCID.MartianEngineer: - case NPCID.MartianOfficer: - case NPCID.RayGunner: - case NPCID.Scutlix: - case NPCID.ScutlixRider: - case NPCID.MartianTurret: - case NPCID.HeadlessHorseman: - case NPCID.Hellhound: - case NPCID.Splinterling: - case NPCID.Poltergeist: - case NPCID.Scarecrow1: - case NPCID.Scarecrow2: - case NPCID.Scarecrow3: - case NPCID.Scarecrow4: - case NPCID.Scarecrow5: - case NPCID.Scarecrow6: - case NPCID.Scarecrow7: - case NPCID.Scarecrow8: - case NPCID.Scarecrow9: - case NPCID.Scarecrow10: - case NPCID.ElfArcher: - case NPCID.ElfCopter: - case NPCID.Flocko: - case NPCID.GingerbreadMan: - case NPCID.Krampus: - case NPCID.Nutcracker: - case NPCID.NutcrackerSpinning: - case NPCID.Yeti: - case NPCID.NebulaBeast: - case NPCID.NebulaBrain: - case NPCID.NebulaHeadcrab: - case NPCID.NebulaSoldier: - case NPCID.SolarCorite: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarDrakomire: - case NPCID.SolarDrakomireRider: - case NPCID.SolarSolenian: - case NPCID.SolarSpearman: - case NPCID.SolarSroller: - case NPCID.StardustCellBig: - case NPCID.StardustCellSmall: - case NPCID.StardustJellyfishBig: - case NPCID.StardustWormBody: - case NPCID.StardustWormHead: - case NPCID.StardustWormTail: - case NPCID.StardustSoldier: - case NPCID.StardustSpiderBig: - case NPCID.StardustSpiderSmall: - case NPCID.VortexHornet: - case NPCID.VortexHornetQueen: - case NPCID.VortexLarva: - case NPCID.VortexRifleman: - case NPCID.VortexSoldier: - case NPCID.DD2DarkMageT1: - case NPCID.DD2DarkMageT3: - case NPCID.DD2OgreT2: - case NPCID.DD2OgreT3: - case NPCID.MartianSaucerCore: - case NPCID.MartianSaucerCannon: - case NPCID.MartianSaucerTurret: - case NPCID.DD2SkeletonT1: - case NPCID.DD2SkeletonT3: - case NPCID.DD2DrakinT2: - case NPCID.DD2DrakinT3: - case NPCID.DD2GoblinBomberT1: - case NPCID.DD2GoblinBomberT2: - case NPCID.DD2GoblinBomberT3: - case NPCID.DD2GoblinT1: - case NPCID.DD2GoblinT2: - case NPCID.DD2GoblinT3: - case NPCID.DD2JavelinstT1: - case NPCID.DD2JavelinstT2: - case NPCID.DD2JavelinstT3: - case NPCID.DD2KoboldFlyerT2: - case NPCID.DD2KoboldFlyerT3: - case NPCID.DD2KoboldWalkerT2: - case NPCID.DD2KoboldWalkerT3: - case NPCID.DD2LightningBugT3: - case NPCID.DD2WitherBeastT2: - case NPCID.DD2WitherBeastT3: - case NPCID.DD2WyvernT1: - case NPCID.DD2WyvernT2: - case NPCID.DD2WyvernT3: - case NPCID.SlimeSpiked: - - // Buff enemy HP by 25% - npc.lifeMax = (int)Math.Round(npc.lifeMax * EnemyHPMultiplier); - - // Nerf a shitload of Master Mode enemies - // HP is nerfed by 25% (this nerf is higher due to the player not dealing any more damage in Master) - // Damage is nerfed by 15% (this nerf is lower due to the player having 100% effective defense in Master) - if (Main.masterMode) - { - AdjustMasterModeStatScaling(npc); - npc.defDamage = npc.damage; - } - - break; - - case NPCID.AncientCultistSquidhead: - // This guy only gets Master Mode nerfs - // HP is nerfed by 25% (this nerf is higher due to the player not dealing any more damage in Master) - // Damage is nerfed by 15% (this nerf is lower due to the player having 100% effective defense in Master) - if (Main.masterMode) - { - AdjustMasterModeStatScaling(npc); - npc.defDamage = npc.damage; - } - break; - - case NPCID.KingSlime: - case NPCID.EyeofCthulhu: - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsTail: - case NPCID.BrainofCthulhu: - case NPCID.Creeper: - case NPCID.QueenBee: - case NPCID.SkeletronHead: - case NPCID.SkeletronHand: - case NPCID.Deerclops: - case NPCID.WallofFlesh: - case NPCID.WallofFleshEye: - case NPCID.QueenSlimeBoss: - case NPCID.Retinazer: - case NPCID.Spazmatism: - case NPCID.TheDestroyer: - case NPCID.TheDestroyerBody: - case NPCID.TheDestroyerTail: - case NPCID.SkeletronPrime: - case NPCID.PrimeCannon: - case NPCID.PrimeLaser: - case NPCID.PrimeSaw: - case NPCID.PrimeVice: - case NPCID.Plantera: - case NPCID.PlanterasTentacle: - case NPCID.Golem: - case NPCID.GolemHead: - case NPCID.GolemHeadFree: - case NPCID.GolemFistLeft: - case NPCID.GolemFistRight: - case NPCID.HallowBoss: - case NPCID.DukeFishron: - case NPCID.CultistBoss: - case NPCID.MoonLordCore: - case NPCID.MoonLordFreeEye: - case NPCID.MoonLordHand: - case NPCID.MoonLordHead: - - if (Main.masterMode) - AdjustMasterModeStatScaling(npc, true); - - break; - } } #endregion @@ -3570,21 +2628,10 @@ namespace CalamityMod.NPCs #region Special Drawing public static void DrawGlowmask(NPC npc, SpriteBatch spriteBatch, Texture2D texture = null, bool invertedDirection = false, Vector2 offset = default) { - if (texture is null) - texture = TextureAssets.Npc[npc.type].Value; - SpriteEffects effects = npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - if (invertedDirection) - effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + texture ??= TextureAssets.Npc[npc.type].Value; + SpriteEffects effects = npc.spriteDirection == 1 ? (invertedDirection ? SpriteEffects.FlipHorizontally : SpriteEffects.None) : (invertedDirection ? SpriteEffects.None : SpriteEffects.FlipHorizontally); Vector2 screenOffset = npc.IsABestiaryIconDummy ? Vector2.Zero : Main.screenPosition; - spriteBatch.Draw(texture, - npc.Center - screenOffset + offset, - npc.frame, - npc.GetAlpha(Color.White), - npc.rotation, - npc.frame.Size() * 0.5f, - npc.scale, - effects, - 0f); + spriteBatch.Draw(texture, npc.Center - screenOffset + offset, npc.frame, npc.GetAlpha(Color.White), npc.rotation, npc.frame.Size() * 0.5f, npc.scale, effects, 0f); } public static void DrawAfterimage(NPC npc, SpriteBatch spriteBatch, Color startingColor, Color endingColor, Texture2D texture = null, Func rotationCalculation = null, bool directioning = false, bool invertedDirection = false) @@ -3593,19 +2640,15 @@ namespace CalamityMod.NPCs return; SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == -1 && directioning) spriteEffects = SpriteEffects.FlipHorizontally; - if (invertedDirection) spriteEffects ^= SpriteEffects.FlipHorizontally; // Same as x XOR 1, or x XOR TRUE, which inverts the bit. In this case, this reverses the horizontal flip - // Set the rotation calculation to a predefined value. The null default is solely so that - if (rotationCalculation is null) - rotationCalculation = (nPC, afterimageIndex) => nPC.rotation; + // Set the rotation calculation to a predefined value. + rotationCalculation ??= (nPC, afterimageIndex) => nPC.rotation; endingColor.A = 0; - Color drawColor = npc.GetAlpha(startingColor); Texture2D npcTexture = texture ?? TextureAssets.Npc[npc.type].Value; Vector2 screenOffset = npc.IsABestiaryIconDummy ? Vector2.Zero : Main.screenPosition; @@ -3614,21 +2657,25 @@ namespace CalamityMod.NPCs { Color colorToDraw = Color.Lerp(drawColor, endingColor, afterimageCounter / (float)NPCID.Sets.TrailCacheLength[npc.type]); colorToDraw *= afterimageCounter / (float)NPCID.Sets.TrailCacheLength[npc.type]; - spriteBatch.Draw(npcTexture, - npc.oldPos[afterimageCounter] + npc.Size / 2f - screenOffset + Vector2.UnitY * npc.gfxOffY, - npc.frame, - colorToDraw, - rotationCalculation.Invoke(npc, afterimageCounter), - npc.frame.Size() * 0.5f, - npc.scale, - spriteEffects, - 0f); + Vector2 imagePosition = npc.oldPos[afterimageCounter] + npc.Size / 2f - screenOffset + Vector2.UnitY * npc.gfxOffY; + + spriteBatch.Draw(npcTexture, imagePosition, npc.frame, colorToDraw, rotationCalculation.Invoke(npc, afterimageCounter), npc.frame.Size() * 0.5f, npc.scale, spriteEffects, 0f); afterimageCounter++; } } #endregion #region Scale Expert Multiplayer Stats + private const float VanillaScalingFactor_2Players = 1.35f; + private const float VanillaScalingFactor_3Players = 1.9166666666666666f; + + /// + /// Applies Calamity's adjustments to difficulty-based player count stat scaling for NPCs. Calamity only adjusts the health of NPCs and does not touch any other stats. + /// + /// The NPC which is having its stats adjusted. + /// The number of players considered active for the purposes of stat scaling. + /// The vanilla Expert+ multiplayer health scalar value. + /// An arbitrary float to make Master Mode easier. On Master Mode, it is 0.85, otherwise it is 1.0. public override void ApplyDifficultyAndPlayerScaling(NPC npc, int numPlayers, float balance, float bossAdjustment) { // Do absolutely nothing in single player, or in multiplayer with only one player connected. @@ -3636,46 +2683,75 @@ namespace CalamityMod.NPCs return; bool countsAsBoss = npc.boss || NPCID.Sets.ShouldBeCountedAsBoss[npc.type]; - bool scalesLikeBoss = countsAsBoss || BossHPScalingList.List.Contains(npc.type); + bool scalesLikeBoss = countsAsBoss || CalamityNPCSets.ScalesHealthLikeBoss[npc.type]; bool isCalamityNPC = npc.ModNPC != null && npc.ModNPC.Mod == CalamityMod.Instance; - // All bosses, NPCs that are supposed to scale like bosses, and Calamity NPCs follow these rules. - if (scalesLikeBoss || isCalamityNPC) + // 14APR2025: Ozzatron: Reworked how Calamity changes the health of Expert+ multiplayer bosses + // Non-boss enemies that receive scaling in Expert+ are still reduced via the old formula + // + // TL;DR: + // - 2 players goes from 135% health to 175% health + // - 3 players goes from 191.6% health to 225% health + // - 4 players and beyond are unedited (4 players is 262.8% for reference) + + // This case applies to all bosses: vanilla, Calamity, and other mods, and anything that is supposed to scale like a boss. + if (countsAsBoss || scalesLikeBoss) { - double scalar; - switch (numPlayers) // Decrease HP in multiplayer before vanilla scaling - { - case 1: - scalar = 1.0; - break; + double adjustmentFactor = 1.0; - case 2: - scalar = 0.9; // 1.8 - break; + // The 2-player boss case is too easy; 1.35x health does not even come close to justify being able to respawn. + if (numPlayers == 2) + adjustmentFactor = BalancingConstants.ExpertHealthScalingOverride_2Players / VanillaScalingFactor_2Players; - case 3: - scalar = 0.82; // 2.46 - break; + // Similarly, the 3-player boss case is too easy, given the considerably higher damage output available. + else if (numPlayers == 3) + adjustmentFactor = BalancingConstants.ExpertHealthScalingOverride_3Players / VanillaScalingFactor_3Players; - case 4: - scalar = 0.76; // 3.04 - break; + // Cases beyond 3 players are already sufficiently scaled by vanilla and continue to scale harder with more players. - case 5: - scalar = 0.71; // 3.55 - break; - - case 6: - scalar = 0.67; // 4.02 - break; - - default: - scalar = 0.64; // 4.48 + 0.64 per player beyond 7 - break; - } - - npc.lifeMax = (int)Math.Round(npc.lifeMax * scalar); + // Apply the adjustment factor, if any. No other changes are made to bosses or boss-like NPCs. + npc.life = (int)Math.Round(npc.life * adjustmentFactor); + return; } + + // Do not touch non-boss NPCs from vanilla or other mods. + if (!isCalamityNPC) + return; + + // Reduction to multiplayer HP scaling for non-boss Calamity enemies in Expert+ + double scalar; + switch (numPlayers) + { + case 1: + scalar = 1.0; + break; + + case 2: + scalar = 0.9; // 1.8 + break; + + case 3: + scalar = 0.82; // 2.46 + break; + + case 4: + scalar = 0.76; // 3.04 + break; + + case 5: + scalar = 0.71; // 3.55 + break; + + case 6: + scalar = 0.67; // 4.02 + break; + + default: + scalar = 0.64; // 4.48 + 0.64 per player beyond 7 + break; + } + + npc.lifeMax = (int)Math.Round(npc.lifeMax * scalar); } #endregion @@ -3705,18 +2781,21 @@ namespace CalamityMod.NPCs // Apply armor penetration based on Calamity debuffs. The hit system manages the sequencing. // Ozzatron 05JAN2023: fixed doubled armor pen, this time for real - int defenseReduction = (marked > 0 && DR <= 0f ? MarkedforDeath.DefenseReduction : 0) + (wither > 0 ? RemsRevenge.WitherDefenseReduction : 0) + miscDefenseLoss; + int defenseReduction = (markedForDeath && DR <= 0f ? MarkedforDeath.DefenseReduction : 0) + (wither ? RemsRevenge.WitherDefenseReduction : 0) + miscDefenseLoss; modifiers.ArmorPenetration += defenseReduction; // DR applies after vanilla defense. ApplyDR(npc, ref modifiers); // Damage reduction on spawn for certain worm bosses. - if (EaterOfWorldsIDList.Includes(npc.type) && newAI[1] < EaterOfWorldsAI.DRIncreaseTime) - modifiers.FinalDamage *= 1f - (float)Math.Sqrt(MathHelper.Lerp(BossRushEvent.BossRushActive ? 0.6f : 0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / EaterOfWorldsAI.DRIncreaseTime, 0f, 1f))); - if (DestroyerIDList.Includes(npc.type) && newAI[1] < DestroyerAI.DRIncreaseTime) - modifiers.FinalDamage *= 1f - (float)Math.Sqrt(MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / DestroyerAI.DRIncreaseTime, 0f, 1f))); - if (AstrumDeusIDList.Includes(npc.type)) + if (CalamityWorld.revenge) + { + if (CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type) && newAI[1] < EaterOfWorldsAI.DRIncreaseTime) + modifiers.FinalDamage *= 1f - (float)Math.Sqrt(MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / EaterOfWorldsAI.DRIncreaseTime, 0f, 1f))); + if (CalamityNPCTypeSets.Destroyer.Contains(npc.type) && newAI[1] < DestroyerAI.DRIncreaseTime) + modifiers.FinalDamage *= 1f - (float)Math.Sqrt(MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / DestroyerAI.DRIncreaseTime, 0f, 1f))); + } + if (CalamityNPCTypeSets.AstrumDeus.Contains(npc.type)) { float drTime = newAI[0] != 0f ? 300f : 600f; if (newAI[1] < drTime) @@ -3734,25 +2813,15 @@ namespace CalamityMod.NPCs float finalMultiplier = 1f; // If the NPC currently has unbreakable DR, it cannot be reduced by any means. - // If custom DR is enabled, use that instead of normal DR. - float effectiveDR = unbreakableDR ? DR : (customDR ? CustomDRMath(npc, DR) : DefaultDRMath(npc, DR)); + float effectiveDR = unbreakableDR ? DR : ApplyDRReduction(npc, DR); // DR floor is 0%. Nothing can have negative DR. if (effectiveDR <= 0f) effectiveDR = 0f; // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac - // Cirrus being active makes the extra DR cease to function - bool cirrusBossActive = false; - if (SCal != -1) - { - if (Main.npc[SCal].active) - cirrusBossActive = Main.npc[SCal].ModNPC().cirrus; - } - bool enragedProvi = npc.type == NPCType() && !ProvUtils.StandardAI(); - bool dayEmpress = npc.type == NPCID.HallowBoss && NPC.ShouldEmpressBeEnraged(); - if (KillTime > 0 && AITimer < KillTime && !BossRushEvent.BossRushActive && !cirrusBossActive && (enragedProvi || dayEmpress)) + if (KillTime > 0 && killTimeTimer < KillTime && !BossRushEvent.BossRushActive && enragedProvi) { // Set the DR scaling factor float DRScalar = 10f; @@ -3764,7 +2833,7 @@ namespace CalamityMod.NPCs float currentHPRatio = npc.life / (float)npc.lifeMax; // Ranges from 0 to 1 - float killTimeRatio = AITimer / (float)KillTime; + float killTimeRatio = killTimeTimer / (float)KillTime; // If the player is damaging the boss too quickly float extraDRScalar = currentHPRatio + killTimeRatio; @@ -3781,77 +2850,24 @@ namespace CalamityMod.NPCs modifiers.FinalDamage *= finalMultiplier; } - private float DefaultDRMath(NPC npc, float DR) + //TODO: + //This will need to be adjusted to use DebuffData in the future. + //However, we still need to decide what to actually do with these due to the general flattening of DR amounts and removal from most enemies + //This means that this will be handled in the future + private float ApplyDRReduction(NPC npc, float DR) { float calcDR = DR; - if (marked > 0) + if (markedForDeath) calcDR *= 0.5f; - if (absorberAffliction > 0) + if (absorberAffliction) calcDR *= 0.8f; - if (npc.Calamity().kamiFlu > 0) - calcDR *= YanmeisKnife.DebuffDamageReductionMult; - if (npc.Calamity().aCrunch > 0) + if (npc.Calamity().armorCrunch) calcDR *= ArmorCrunch.MultiplicativeDamageReductionEnemy; - if (npc.Calamity().crumble > 0) + if (npc.Calamity().crumble) calcDR *= Crumbling.MultiplicativeDamageReductionEnemy; - if (relicOfResilienceWeakness > 0) + if (relicOfResilienceWeakness) calcDR *= 0.5f; - - return calcDR; - } - - private float CustomDRMath(NPC npc, float DR) - { - void FlatEditDR(ref float theDR, bool npcHasDebuff, int buffID) - { - if (npcHasDebuff && flatDRReductions.TryGetValue(buffID, out float reduction)) - theDR -= reduction; - } - void MultEditDR(ref float theDR, bool npcHasDebuff, int buffID) - { - if (npcHasDebuff && multDRReductions.TryGetValue(buffID, out float multiplier)) - theDR *= multiplier; - } - - float calcDR = DR; - - // Apply flat reductions first. All vanilla debuffs check their internal booleans. - FlatEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned); - FlatEditDR(ref calcDR, npc.onFire, BuffID.OnFire); - FlatEditDR(ref calcDR, npc.onFire3, BuffID.OnFire3); - FlatEditDR(ref calcDR, npc.venom, BuffID.Venom); - FlatEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn); - FlatEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame); - FlatEditDR(ref calcDR, npc.daybreak, BuffID.Daybreak); - FlatEditDR(ref calcDR, npc.onFire2, BuffID.CursedInferno); - - // Modded debuffs are handled modularly and use HasBuff. - foreach (KeyValuePair entry in flatDRReductions) - { - int buffID = entry.Key; - if (buffID >= BuffID.Count && npc.HasBuff(buffID)) - calcDR -= entry.Value; - } - - // Apply multiplicative reductions second. All vanilla debuffs check their internal booleans. - MultEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned); - MultEditDR(ref calcDR, npc.onFire, BuffID.OnFire); - MultEditDR(ref calcDR, npc.onFire3, BuffID.OnFire3); - MultEditDR(ref calcDR, npc.venom, BuffID.Venom); - MultEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn); - MultEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame); - MultEditDR(ref calcDR, npc.daybreak, BuffID.Daybreak); - MultEditDR(ref calcDR, npc.onFire2, BuffID.CursedInferno); - - // Modded debuffs are handled modularly and use HasBuff. - foreach (KeyValuePair entry in multDRReductions) - { - int buffID = entry.Key; - if (buffID >= BuffID.Count && npc.HasBuff(buffID)) - calcDR *= entry.Value; - } - return calcDR; } @@ -3861,30 +2877,11 @@ namespace CalamityMod.NPCs } #endregion - #region Boss Head Slot - public override void BossHeadSlot(NPC npc, ref int index) - { - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - if (npc.type == NPCID.SkeletronPrime && (Main.masterMode || BossRushEvent.BossRushActive)) - index = ExtraTextureRefs.BossHeadIndex_ChadPrime; - - if (npc.type == NPCID.DukeFishron && (CalamityWorld.death || BossRushEvent.BossRushActive)) - { - float lifeRatio = npc.life / (float)npc.lifeMax; - float mapIconVanishValue = Main.masterMode ? 0.3f : 0.4f; - if (lifeRatio < mapIconVanishValue || (lifeRatio > 0.9f && (Main.masterMode || BossRushEvent.BossRushActive))) - index = -1; - } - } - } - #endregion - #region Pre AI public override bool PreAI(NPC npc) { // Change Spaz and Ret weaknesses and resistances when phase 2 starts. - if (npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer || npc.type == NPCType()) + if (npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer) { if (npc.ai[0] >= 2f) { @@ -3895,10 +2892,17 @@ namespace CalamityMod.NPCs } } - if (VulnerabilityHexFireDrawer != null) - VulnerabilityHexFireDrawer.Update(); + VulnerabilityHexFireDrawer?.Update(); - SetPatreonTownNPCName(npc, Mod); + if (ManaBurnFireDrawer != null) + { + ManaBurnFireDrawer.LocalTimer = 0; + float power = npc.height / 100f; + if (power > 2.75f) + power = 2.75f; + ManaBurnFireDrawer.RelativePower = power * MathHelper.Lerp(0.5f, 1.5f, MathHelper.Clamp(manaBurn / manaBurnPeak, 0, 1)) * playerManaBurnIntensity; + ManaBurnFireDrawer.Update(); + } // Decrement each immune timer if it's greater than 0. for (int i = 0; i < maxPlayerImmunities; i++) @@ -3914,1095 +2918,26 @@ namespace CalamityMod.NPCs { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < BossZenDistance) Main.LocalPlayer.AddBuff(BuffType(), 2); - - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && npc.type == NPCType() && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < BossZenDistance) - Main.LocalPlayer.AddBuff(BuffType(), 2); } if (npc.type != NPCType()) { - if (AITimer < KillTime) - AITimer++; + if (killTimeTimer < KillTime) + killTimeTimer++; } } if (npc.type == NPCID.TargetDummy || npc.type == NPCType()) - { - npc.dontTakeDamage = CalamityPlayer.areThereAnyDamnBosses; - - if (draedon != -1) - { - if (Main.npc[draedon].active) - npc.dontTakeDamage = true; - } - } + npc.dontTakeDamage = CalamityPlayer.areThereAnyDamnBosses || (draedon != -1 && Main.npc[draedon].active); // Setting this in SetDefaults will disable expert mode scaling, so put it here instead - if (ZeroContactDamageNPCList.Includes(npc.type) && (npc.type != NPCID.RuneWizard || !Main.zenithWorld)) + if (CalamityNPCSets.DealsZeroContactDamage[npc.type] && !(npc.type == NPCID.RuneWizard && Main.zenithWorld)) npc.damage = 0; - // Don't do damage for 42 frames after spawning in - if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2) - npc.damage = npc.alpha > 0 ? 0 : npc.defDamage; - - if (BossRushEvent.BossRushActive && !npc.friendly && !npc.townNPC && !npc.Calamity().DoesNotDisappearInBossRush) + if (BossRushEvent.BossRushActive && !npc.friendly && !npc.townNPC && !DoesNotDisappearInBossRush) BossRushForceDespawnOtherNPCs(npc, Mod); - if (NPC.LunarApocalypseIsUp) - PillarEventProgressionEdit(npc); - - // Adult Wyrm Ancient Doom - if (npc.type == NPCID.AncientDoom) - { - if (Main.npc[(int)npc.ai[0]].type == NPCType()) - return CultistAI.BuffedAncientDoomAI(npc, Mod); - } - - // Completely override the shitty AI and replace it - if (npc.type == NPCID.BloodNautilus) - return DreadnautilusAI.BuffedDreadnautilusAI(npc, Mod); - - // More telegraphs - if (npc.type == NPCID.SpikedIceSlime || npc.type == NPCID.SpikedJungleSlime || npc.type == NPCID.SlimeSpiked) - return SlimeAI.BuffedSlimeAI(npc, Mod); - - // Decrease the projectile velocities of several fighter enemies and make them better to fight in general - // Also limit the amount of times Vortex Larvae and Hornets can evolve - if (npc.type == NPCID.IceGolem || npc.type == NPCID.Eyezor || npc.type == NPCID.VortexRifleman || - npc.type == NPCID.TacticalSkeleton || npc.type == NPCID.Nailhead || npc.type == NPCID.WallCreeper || - npc.type == NPCID.BloodCrawler || npc.type == NPCID.BlackRecluse || npc.type == NPCID.JungleCreeper || - npc.type == NPCID.BoneLee || npc.type == NPCID.VortexLarva || npc.type == NPCID.VortexHornet || - npc.type == NPCID.VortexHornetQueen) - { - return RevengeanceAndDeathAI.BuffedFighterAI(npc, Mod); - } - - // More telegraphs - if (npc.type == NPCID.Harpy || npc.type == NPCID.Demon || npc.type == NPCID.VoodooDemon || - npc.type == NPCID.RedDevil) - { - return RevengeanceAndDeathAI.BuffedBatAI(npc, Mod); - } - - // Casters hold their hands up for longer before firing in all modes - if (npc.type == NPCID.FireImp || npc.type == NPCID.DarkCaster || npc.type == NPCID.Tim || - npc.type == NPCID.RuneWizard || (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite) || - npc.type == NPCID.DesertDjinn || npc.type == NPCID.GoblinSorcerer) - { - return RevengeanceAndDeathAI.BuffedCasterAI(npc, Mod); - } - - // Antlion telegraph - if (npc.type == NPCID.Antlion) - return RevengeanceAndDeathAI.BuffedAntlionAI(npc, Mod); - - // Corruptor and Blood Squid telegraphs - if (npc.type == NPCID.Corruptor || npc.type == NPCID.BloodSquid) - return RevengeanceAndDeathAI.BuffedFlyingAI(npc, Mod); - - // Ichor Sticker and Ice Elemental telegraphs - if (npc.type == NPCID.IchorSticker || npc.type == NPCID.IceElemental) - return RevengeanceAndDeathAI.BuffedHoveringAI(npc, Mod); - - // Fungi Bulb telegraphs - if (npc.type == NPCID.FungiBulb || npc.type == NPCID.GiantFungiBulb) - return RevengeanceAndDeathAI.BuffedPlantAI(npc, Mod); - - // Spider web spit telegraph - if (npc.type == NPCID.WallCreeperWall || npc.type == NPCID.BloodCrawlerWall || npc.type == NPCID.BlackRecluseWall || - npc.type == NPCID.JungleCreeperWall) - { - return RevengeanceAndDeathAI.BuffedSpiderAI(npc, Mod); - } - - // Servant of Cthulhu light - if (npc.type == NPCID.ServantofCthulhu) - Lighting.AddLight(npc.Center, 0.2f, 0.2f, 0.2f); - - if (npc.type == NPCID.CultistBoss || npc.type == NPCID.CultistBossClone) - { - if (npc.type == NPCID.CultistBossClone) - { - if (Main.npc[(int)npc.ai[3]].active) - { - // Emit light - float lifeRatio = Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax; - float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); - Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); - Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); - } - } - else - { - // Emit light - float lifeRatio = npc.life / (float)npc.lifeMax; - float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); - Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); - Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); - - // Decrement the hit counter for the shield flicker - if (newAI[1] > 0f) - newAI[1] -= 1f; - - // Cultist shield hitbox - Vector2 hitboxSize = new Vector2(216f / 1.4142f); - if (npc.Size != hitboxSize) - npc.Size = hitboxSize; - } - } - - if (Main.zenithWorld) - { - if (npc.type == NPCID.QueenBee) - return QueenBeeAI.BuffedQueenBeeAI(npc, Mod); - } - - if (CalamityWorld.death) - { - if (npc.type == NPCID.DetonatingBubble) - return DukeFishronAI.BuffedDetonatingBubbleAI(npc, Mod); - } - - // Expert+ Hive Mind Vile Spits - if (npc.type == NPCID.VileSpitEaterOfWorlds) - { - if (Main.expertMode || BossRushEvent.BossRushActive) - { - if (npc.ai[1] >= 69f) - { - if (npc.target == Main.maxPlayers) - { - npc.TargetClosest(); - - float velocity = Main.getGoodWorld ? 10f : (Main.masterMode || BossRushEvent.BossRushActive) ? 8f : 6f; - if (npc.ai[1] == 70f) - velocity *= 0.6f; - - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - } - - if (Main.getGoodWorld && !npc.dontTakeDamage) - { - if ((double)(npc.Center.Y / 16f) < Main.worldSurface) - npc.dontTakeDamage = true; - } - - npc.damage = npc.GetAttackDamage_ScaledByStrength(32f); - - npc.ai[0] += 1f; - if (npc.ai[0] > 3f) - npc.ai[0] = 3f; - - if (npc.ai[0] == 2f) - { - npc.position += npc.velocity; - SoundEngine.PlaySound(SoundID.NPCDeath9, npc.Center); - for (int i = 0; i < 20; i++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f) + npc.netOffset, npc.width, npc.height, DustID.CorruptGibs, 0f, 0f, 100, default, 1.8f); - Main.dust[dust].velocity *= 1.3f; - Main.dust[dust].velocity += npc.velocity; - Main.dust[dust].noGravity = true; - } - } - - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - } - - npc.EncourageDespawn(100); - - npc.position += npc.netOffset; - for (int i = 0; i < 2; i++) - { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.CorruptGibs, npc.velocity.X * 0.1f, npc.velocity.Y * 0.1f, 80, default, 1.3f); - Main.dust[dust].velocity *= 0.3f; - Main.dust[dust].noGravity = true; - } - - npc.rotation += 0.4f * npc.direction; - npc.position -= npc.netOffset; - - return false; - } - } - } - - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - switch (npc.type) - { - case NPCID.KingSlime: - return KingSlimeAI.BuffedKingSlimeAI(npc, Mod); - - case NPCID.EyeofCthulhu: - return EyeOfCthulhuAI.BuffedEyeofCthulhuAI(npc, Mod); - - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsTail: - return EaterOfWorldsAI.BuffedEaterofWorldsAI(npc, Mod); - - case NPCID.BrainofCthulhu: - return BrainOfCthulhuAI.BuffedBrainofCthulhuAI(npc, Mod); - case NPCID.Creeper: - return BrainOfCthulhuAI.BuffedCreeperAI(npc, Mod); - - case NPCID.QueenBee: - return QueenBeeAI.BuffedQueenBeeAI(npc, Mod); - - case NPCID.SkeletronHand: - return SkeletronAI.BuffedSkeletronHandAI(npc, Mod); - case NPCID.SkeletronHead: - return SkeletronAI.BuffedSkeletronAI(npc, Mod); - - case NPCID.Deerclops: - return DeerclopsAI.BuffedDeerclopsAI(npc, Mod); - - case NPCID.WallofFlesh: - return WallOfFleshAI.BuffedWallofFleshAI(npc, Mod); - case NPCID.WallofFleshEye: - return WallOfFleshAI.BuffedWallofFleshEyeAI(npc, Mod); - - case NPCID.QueenSlimeBoss: - return QueenSlimeAI.BuffedQueenSlimeAI(npc, Mod); - - case NPCID.TheDestroyer: - case NPCID.TheDestroyerBody: - case NPCID.TheDestroyerTail: - return DestroyerAI.BuffedDestroyerAI(npc, Mod); - case NPCID.Probe: - return DestroyerAI.BuffedProbeAI(npc, Mod); - - case NPCID.Retinazer: - return TwinsAI.BuffedRetinazerAI(npc, Mod); - case NPCID.Spazmatism: - return TwinsAI.BuffedSpazmatismAI(npc, Mod); - - case NPCID.SkeletronPrime: - return SkeletronPrimeAI.BuffedSkeletronPrimeAI(npc, Mod); - case NPCID.PrimeLaser: - return SkeletronPrimeAI.BuffedPrimeLaserAI(npc, Mod); - case NPCID.PrimeCannon: - return SkeletronPrimeAI.BuffedPrimeCannonAI(npc, Mod); - case NPCID.PrimeVice: - return SkeletronPrimeAI.BuffedPrimeViceAI(npc, Mod); - case NPCID.PrimeSaw: - return SkeletronPrimeAI.BuffedPrimeSawAI(npc, Mod); - - case NPCID.Plantera: - return PlanteraAI.BuffedPlanteraAI(npc, Mod); - case NPCID.PlanterasHook: - return PlanteraAI.BuffedPlanterasHookAI(npc, Mod); - case NPCID.PlanterasTentacle: - return PlanteraAI.BuffedPlanterasTentacleAI(npc, Mod); - - case NPCID.HallowBoss: - return EmpressofLightAI.BuffedEmpressofLightAI(npc, Mod); - - case NPCID.Golem: - return GolemAI.BuffedGolemAI(npc, Mod); - case NPCID.GolemFistLeft: - case NPCID.GolemFistRight: - return GolemAI.BuffedGolemFistAI(npc, Mod); - case NPCID.GolemHead: - return GolemAI.BuffedGolemHeadAI(npc, Mod); - case NPCID.GolemHeadFree: - return GolemAI.BuffedGolemHeadFreeAI(npc, Mod); - - case NPCID.DukeFishron: - return DukeFishronAI.BuffedDukeFishronAI(npc, Mod); - - case NPCID.Pumpking: - if (DownedBossSystem.downedDoG) - { - return CalamityGlobalAI.BuffedPumpkingAI(npc); - } - - break; - - case NPCID.PumpkingBlade: - if (DownedBossSystem.downedDoG) - { - return CalamityGlobalAI.BuffedPumpkingBladeAI(npc); - } - - break; - - case NPCID.IceQueen: - if (DownedBossSystem.downedDoG) - { - return CalamityGlobalAI.BuffedIceQueenAI(npc); - } - - break; - - case NPCID.Mothron: - if (DownedBossSystem.downedDoG) - { - return CalamityGlobalAI.BuffedMothronAI(npc); - } - - break; - - case NPCID.CultistBoss: - case NPCID.CultistBossClone: - return CultistAI.BuffedCultistAI(npc, Mod); - case NPCID.AncientLight: - return CultistAI.BuffedAncientLightAI(npc, Mod); - case NPCID.AncientDoom: - return CultistAI.BuffedAncientDoomAI(npc, Mod); - - case NPCID.MoonLordCore: - case NPCID.MoonLordHand: - case NPCID.MoonLordHead: - case NPCID.MoonLordFreeEye: - case NPCID.MoonLordLeechBlob: - return MoonLordAI.BuffedMoonLordAI(npc, Mod); - - default: - break; - } - } - - // Adjust vanilla AI in Classic, Expert and Master - // Fair contact damage and a few Expert/Master AI edits happen here - // Deerclops doesn't deserve love so he's not here - else if (!CalamityMod.ExternalFlag_DisableNonRevBossAI) - { - switch (npc.type) - { - case NPCID.KingSlime: - return KingSlimeAI.VanillaKingSlimeAI(npc, Mod); - - case NPCID.EyeofCthulhu: - return EyeOfCthulhuAI.VanillaEyeofCthulhuAI(npc, Mod); - - case NPCID.EaterofWorldsHead: - case NPCID.EaterofWorldsBody: - case NPCID.EaterofWorldsTail: - return EaterOfWorldsAI.VanillaEaterofWorldsAI(npc, Mod); - - case NPCID.BrainofCthulhu: - return BrainOfCthulhuAI.VanillaBrainofCthulhuAI(npc, Mod); - case NPCID.Creeper: - return BrainOfCthulhuAI.VanillaCreeperAI(npc, Mod); - - case NPCID.QueenBee: - return QueenBeeAI.VanillaQueenBeeAI(npc, Mod); - - case NPCID.SkeletronHand: - return SkeletronAI.VanillaSkeletronHandAI(npc, Mod); - case NPCID.SkeletronHead: - return SkeletronAI.VanillaSkeletronAI(npc, Mod); - - case NPCID.WallofFlesh: - return WallOfFleshAI.VanillaWallofFleshAI(npc, Mod); - case NPCID.WallofFleshEye: - return WallOfFleshAI.VanillaWallofFleshEyeAI(npc, Mod); - - case NPCID.QueenSlimeBoss: - return QueenSlimeAI.VanillaQueenSlimeAI(npc, Mod); - - case NPCID.TheDestroyer: - case NPCID.TheDestroyerBody: - case NPCID.TheDestroyerTail: - return DestroyerAI.VanillaDestroyerAI(npc, Mod); - case NPCID.Probe: - return DestroyerAI.VanillaProbeAI(npc, Mod); - - case NPCID.Retinazer: - return TwinsAI.VanillaRetinazerAI(npc, Mod); - case NPCID.Spazmatism: - return TwinsAI.VanillaSpazmatismAI(npc, Mod); - - case NPCID.SkeletronPrime: - return SkeletronPrimeAI.VanillaSkeletronPrimeAI(npc, Mod); - case NPCID.PrimeLaser: - return SkeletronPrimeAI.VanillaPrimeLaserAI(npc, Mod); - case NPCID.PrimeCannon: - return SkeletronPrimeAI.VanillaPrimeCannonAI(npc, Mod); - case NPCID.PrimeVice: - return SkeletronPrimeAI.VanillaPrimeViceAI(npc, Mod); - case NPCID.PrimeSaw: - return SkeletronPrimeAI.VanillaPrimeSawAI(npc, Mod); - - case NPCID.Plantera: - return PlanteraAI.VanillaPlanteraAI(npc, Mod); - - case NPCID.HallowBoss: - return EmpressofLightAI.VanillaEmpressofLightAI(npc, Mod); - - case NPCID.Golem: - return GolemAI.VanillaGolemAI(npc, Mod); - case NPCID.GolemFistLeft: - case NPCID.GolemFistRight: - return GolemAI.VanillaGolemFistAI(npc, Mod); - case NPCID.GolemHead: - return GolemAI.VanillaGolemHeadAI(npc, Mod); - case NPCID.GolemHeadFree: - return GolemAI.VanillaGolemHeadFreeAI(npc, Mod); - - case NPCID.DukeFishron: - return DukeFishronAI.VanillaDukeFishronAI(npc, Mod); - - case NPCID.CultistBoss: - case NPCID.CultistBossClone: - return CultistAI.VanillaCultistAI(npc, Mod); - case NPCID.AncientLight: - return CultistAI.VanillaAncientLightAI(npc, Mod); - case NPCID.AncientDoom: - return CultistAI.VanillaAncientDoomAI(npc, Mod); - - /*case NPCID.MoonLordCore: - case NPCID.MoonLordHand: - case NPCID.MoonLordHead: - case NPCID.MoonLordFreeEye: - return MoonLordAI.VanillaMoonLordAI(npc, Mod);*/ - - default: - break; - } - } - - if (CalamityWorld.revenge) - { - switch (npc.aiStyle) - { - case NPCAIStyleID.Slime: - if (npc.type == NPCType() || npc.type == NPCType() || - npc.type == NPCType() || npc.type == NPCType() || - npc.type == NPCType() || npc.type == NPCType() || - npc.type == NPCType() || npc.type == NPCType()) - { - return SlimeAI.BuffedSlimeAI(npc, Mod); - } - else - { - switch (npc.type) - { - case NPCID.BlueSlime: - case NPCID.MotherSlime: - case NPCID.LavaSlime: - case NPCID.DungeonSlime: - case NPCID.CorruptSlime: - case NPCID.IlluminantSlime: - case NPCID.ToxicSludge: - case NPCID.IceSlime: - case NPCID.Crimslime: - case NPCID.UmbrellaSlime: - case NPCID.RainbowSlime: - case NPCID.SlimeMasked: - case NPCID.HoppinJack: - case NPCID.SlimeRibbonWhite: - case NPCID.SlimeRibbonYellow: - case NPCID.SlimeRibbonGreen: - case NPCID.SlimeRibbonRed: - case NPCID.SandSlime: - case NPCID.GoldenSlime: - case NPCID.ShimmerSlime: - return SlimeAI.BuffedSlimeAI(npc, Mod); - } - } - break; - - case NPCAIStyleID.DemonEye: - if (npc.type == NPCType()) - { - return DemonEyeAI.BuffedDemonEyeAI(npc, Mod); - } - else - { - switch (npc.type) - { - case NPCID.DemonEye: - case NPCID.TheHungryII: - case NPCID.WanderingEye: - case NPCID.PigronCorruption: - case NPCID.PigronHallow: - case NPCID.PigronCrimson: - case NPCID.CataractEye: - case NPCID.SleepyEye: - case NPCID.DialatedEye: - case NPCID.GreenEye: - case NPCID.PurpleEye: - case NPCID.DemonEyeOwl: - case NPCID.DemonEyeSpaceship: - return DemonEyeAI.BuffedDemonEyeAI(npc, Mod); - } - } - break; - - case NPCAIStyleID.Fighter: - if (npc.type == NPCType() || - npc.type == NPCType() || npc.type == NPCType()) - { - return RevengeanceAndDeathAI.BuffedFighterAI(npc, Mod); - } - else - { - switch (npc.type) - { - case NPCID.Zombie: - case NPCID.ArmedZombie: - case NPCID.ArmedZombieEskimo: - case NPCID.ArmedZombiePincussion: - case NPCID.ArmedZombieSlimed: - case NPCID.ArmedZombieSwamp: - case NPCID.ArmedZombieTwiggy: - case NPCID.ArmedZombieCenx: - case NPCID.Skeleton: - case NPCID.SporeSkeleton: - case NPCID.AngryBones: - case NPCID.UndeadMiner: - case NPCID.CorruptBunny: - case NPCID.DoctorBones: - case NPCID.TheGroom: - case NPCID.Crab: - case NPCID.GoblinScout: - case NPCID.ArmoredSkeleton: - case NPCID.Mummy: - case NPCID.DarkMummy: - case NPCID.LightMummy: - case NPCID.Werewolf: - case NPCID.Clown: - case NPCID.SkeletonArcher: - case NPCID.ChaosElemental: - case NPCID.BaldZombie: - case NPCID.PossessedArmor: - case NPCID.ZombieEskimo: - case NPCID.UndeadViking: - case NPCID.CorruptPenguin: - case NPCID.FaceMonster: - case NPCID.SnowFlinx: - case NPCID.PincushionZombie: - case NPCID.SlimedZombie: - case NPCID.SwampZombie: - case NPCID.TwiggyZombie: - case NPCID.Nymph: - case NPCID.ArmoredViking: - case NPCID.Lihzahrd: - case NPCID.LihzahrdCrawler: - case NPCID.FemaleZombie: - case NPCID.HeadacheSkeleton: - case NPCID.MisassembledSkeleton: - case NPCID.PantlessSkeleton: - case NPCID.IcyMerman: - case NPCID.PirateDeckhand: - case NPCID.PirateCorsair: - case NPCID.PirateDeadeye: - case NPCID.PirateCrossbower: - case NPCID.PirateCaptain: - case NPCID.CochinealBeetle: - case NPCID.CyanBeetle: - case NPCID.LacBeetle: - case NPCID.SeaSnail: - case NPCID.ZombieRaincoat: - case NPCID.ZombieMushroom: - case NPCID.ZombieMushroomHat: - case NPCID.AnomuraFungus: - case NPCID.MushiLadybug: - case NPCID.RustyArmoredBonesAxe: - case NPCID.RustyArmoredBonesFlail: - case NPCID.RustyArmoredBonesSword: - case NPCID.RustyArmoredBonesSwordNoArmor: - case NPCID.BlueArmoredBones: - case NPCID.BlueArmoredBonesMace: - case NPCID.BlueArmoredBonesNoPants: - case NPCID.BlueArmoredBonesSword: - case NPCID.HellArmoredBones: - case NPCID.HellArmoredBonesSpikeShield: - case NPCID.HellArmoredBonesMace: - case NPCID.HellArmoredBonesSword: - case NPCID.Paladin: - case NPCID.SkeletonSniper: - case NPCID.SkeletonCommando: - case NPCID.AngryBonesBig: - case NPCID.AngryBonesBigMuscle: - case NPCID.AngryBonesBigHelmet: - case NPCID.Scarecrow1: - case NPCID.Scarecrow2: - case NPCID.Scarecrow3: - case NPCID.Scarecrow4: - case NPCID.Scarecrow5: - case NPCID.Scarecrow6: - case NPCID.Scarecrow7: - case NPCID.Scarecrow8: - case NPCID.Scarecrow9: - case NPCID.Scarecrow10: - case NPCID.ZombieDoctor: - case NPCID.ZombieSuperman: - case NPCID.ZombiePixie: - case NPCID.SkeletonTopHat: - case NPCID.SkeletonAstonaut: - case NPCID.SkeletonAlien: - case NPCID.Splinterling: - case NPCID.ZombieXmas: - case NPCID.ZombieSweater: - case NPCID.ZombieElf: - case NPCID.ZombieElfBeard: - case NPCID.ZombieElfGirl: - case NPCID.GingerbreadMan: - case NPCID.Yeti: - case NPCID.Nutcracker: - case NPCID.NutcrackerSpinning: - case NPCID.ElfArcher: - case NPCID.Krampus: - case NPCID.CultistArcherBlue: - case NPCID.CultistArcherWhite: - case NPCID.BrainScrambler: - case NPCID.RayGunner: - case NPCID.MartianOfficer: - case NPCID.GrayGrunt: - case NPCID.MartianEngineer: - case NPCID.GigaZapper: - case NPCID.Scutlix: - case NPCID.BoneThrowingSkeleton: - case NPCID.BoneThrowingSkeleton2: - case NPCID.BoneThrowingSkeleton3: - case NPCID.BoneThrowingSkeleton4: - case NPCID.CrimsonBunny: - case NPCID.CrimsonPenguin: - case NPCID.Medusa: - case NPCID.GreekSkeleton: - case NPCID.GraniteGolem: - case NPCID.BloodZombie: - case NPCID.Crawdad: - case NPCID.Crawdad2: - case NPCID.Salamander: - case NPCID.Salamander2: - case NPCID.Salamander3: - case NPCID.Salamander4: - case NPCID.Salamander5: - case NPCID.Salamander6: - case NPCID.Salamander7: - case NPCID.Salamander8: - case NPCID.Salamander9: - case NPCID.GiantWalkingAntlion: - case NPCID.WalkingAntlion: - case NPCID.LarvaeAntlion: - case NPCID.DesertGhoul: - case NPCID.DesertGhoulCorruption: - case NPCID.DesertGhoulCrimson: - case NPCID.DesertGhoulHallow: - case NPCID.DesertLamiaLight: - case NPCID.DesertLamiaDark: - case NPCID.DesertScorpionWalk: - case NPCID.DesertBeast: - case NPCID.StardustSoldier: - case NPCID.StardustSpiderBig: - case NPCID.NebulaSoldier: - case NPCID.VortexSoldier: - case NPCID.SolarDrakomire: - case NPCID.SolarSpearman: - case NPCID.SolarSolenian: - case NPCID.Frankenstein: - case NPCID.SwampThing: - case NPCID.Vampire: - case NPCID.Butcher: - case NPCID.CreatureFromTheDeep: - case NPCID.Fritz: - case NPCID.Psycho: - case NPCID.ThePossessed: - case NPCID.DrManFly: - case NPCID.GoblinPeon: - case NPCID.GoblinThief: - case NPCID.GoblinWarrior: - case NPCID.GoblinArcher: - case NPCID.GoblinSummoner: - case NPCID.MartianWalker: - case NPCID.DemonTaxCollector: - case NPCID.TheBride: - return RevengeanceAndDeathAI.BuffedFighterAI(npc, Mod); - } - } - break; - - case NPCAIStyleID.Flying: - switch (npc.type) - { - case NPCID.ServantofCthulhu: - case NPCID.EaterofSouls: - case NPCID.MeteorHead: - case NPCID.Crimera: - case NPCID.Moth: - case NPCID.Parrot: - case NPCID.Bee: - case NPCID.BeeSmall: - case NPCID.Hornet: - case NPCID.HornetFatty: - case NPCID.HornetHoney: - case NPCID.HornetLeafy: - case NPCID.HornetSpikey: - case NPCID.HornetStingy: - case NPCID.MossHornet: - return RevengeanceAndDeathAI.BuffedFlyingAI(npc, Mod); - } - break; - - case NPCAIStyleID.Worm: - switch (npc.type) - { - case NPCID.DevourerHead: - case NPCID.DevourerBody: - case NPCID.DevourerTail: - case NPCID.GiantWormHead: - case NPCID.GiantWormBody: - case NPCID.GiantWormTail: - case NPCID.BoneSerpentHead: - case NPCID.BoneSerpentBody: - case NPCID.BoneSerpentTail: - case NPCID.WyvernHead: - case NPCID.WyvernLegs: - case NPCID.WyvernBody: - case NPCID.WyvernBody2: - case NPCID.WyvernBody3: - case NPCID.WyvernTail: - case NPCID.LeechHead: - case NPCID.LeechBody: - case NPCID.LeechTail: - case NPCID.TombCrawlerHead: - case NPCID.TombCrawlerBody: - case NPCID.TombCrawlerTail: - case NPCID.StardustWormHead: - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - case NPCID.BloodEelHead: - case NPCID.BloodEelBody: - case NPCID.BloodEelTail: - return RevengeanceAndDeathAI.BuffedWormAI(npc, Mod); - - // Death Mode splitting worms. - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - if (CalamityWorld.death) - return RevengeanceAndDeathAI.BuffedWormAI(npc, Mod); - else - return true; - } - break; - - case NPCAIStyleID.ManEater: - switch (npc.type) - { - case NPCID.ManEater: - case NPCID.Snatcher: - case NPCID.Clinger: - case NPCID.AngryTrapper: - return RevengeanceAndDeathAI.BuffedPlantAI(npc, Mod); - } - break; - - case NPCAIStyleID.Bat: - if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) - { - return RevengeanceAndDeathAI.BuffedBatAI(npc, Mod); - } - else - { - switch (npc.type) - { - case NPCID.CaveBat: - case NPCID.JungleBat: - case NPCID.Hellbat: - case NPCID.GiantBat: - case NPCID.Slimer: - case NPCID.IlluminantBat: - case NPCID.IceBat: - case NPCID.Lavabat: - case NPCID.GiantFlyingFox: - case NPCID.FlyingSnake: - case NPCID.VampireBat: - case NPCID.SporeBat: - return RevengeanceAndDeathAI.BuffedBatAI(npc, Mod); - } - } - break; - - case NPCAIStyleID.Piranha: - switch (npc.type) - { - case NPCID.CorruptGoldfish: - case NPCID.Piranha: - case NPCID.Shark: - case NPCID.AnglerFish: - case NPCID.Arapaima: - case NPCID.BloodFeeder: - case NPCID.CrimsonGoldfish: - return RevengeanceAndDeathAI.BuffedSwimmingAI(npc, Mod); - } - break; - - case NPCAIStyleID.Jellyfish: - switch (npc.type) - { - case NPCID.BlueJellyfish: - case NPCID.PinkJellyfish: - case NPCID.GreenJellyfish: - case NPCID.Squid: - case NPCID.BloodJelly: - case NPCID.FungoFish: - return RevengeanceAndDeathAI.BuffedJellyfishAI(npc, Mod); - } - break; - - case NPCAIStyleID.SpikeBall: - switch (npc.type) - { - case NPCID.SpikeBall: - return RevengeanceAndDeathAI.BuffedSpikeBallAI(npc, Mod); - } - break; - - case NPCAIStyleID.BlazingWheel: - switch (npc.type) - { - case NPCID.BlazingWheel: - return RevengeanceAndDeathAI.BuffedBlazingWheelAI(npc, Mod); - } - break; - - case NPCAIStyleID.HoveringFighter: - switch (npc.type) - { - case NPCID.Pixie: - case NPCID.Wraith: - case NPCID.Gastropod: - case NPCID.FloatyGross: - case NPCID.Ghost: - case NPCID.Poltergeist: - case NPCID.Drippler: - case NPCID.Reaper: - return RevengeanceAndDeathAI.BuffedHoveringAI(npc, Mod); - } - break; - - case NPCAIStyleID.EnchantedSword: - switch (npc.type) - { - case NPCID.CursedHammer: - case NPCID.EnchantedSword: - case NPCID.CrimsonAxe: - return RevengeanceAndDeathAI.BuffedFlyingWeaponAI(npc, Mod); - } - break; - - case NPCAIStyleID.Mimic: - switch (npc.type) - { - case NPCID.Mimic: - case NPCID.PresentMimic: - case NPCID.IceMimic: - return RevengeanceAndDeathAI.BuffedMimicAI(npc, Mod); - } - break; - - case NPCAIStyleID.Unicorn: - if (npc.type == NPCType()) - { - return RevengeanceAndDeathAI.BuffedUnicornAI(npc, Mod); - } - else - { - switch (npc.type) - { - case NPCID.Unicorn: - case NPCID.Wolf: - case NPCID.HeadlessHorseman: - case NPCID.Hellhound: - case NPCID.StardustSpiderSmall: - case NPCID.NebulaBeast: - case NPCID.Tumbleweed: - return RevengeanceAndDeathAI.BuffedUnicornAI(npc, Mod); - } - } - break; - - case NPCAIStyleID.TheHungry: - switch (npc.type) - { - case NPCID.TheHungry: - return WallOfFleshAI.BuffedHungryAI(npc, Mod); - } - break; - - case NPCAIStyleID.GiantTortoise: - if (npc.type == NPCType()) - { - return RevengeanceAndDeathAI.BuffedTortoiseAI(npc, Mod); - } - else - { - switch (npc.type) - { - case NPCID.GiantTortoise: - case NPCID.IceTortoise: - case NPCID.GiantShelly: - case NPCID.GiantShelly2: - case NPCID.SolarSroller: - return RevengeanceAndDeathAI.BuffedTortoiseAI(npc, Mod); - } - } - break; - - case NPCAIStyleID.Spider: - switch (npc.type) - { - case NPCID.DesertScorpionWall: - return RevengeanceAndDeathAI.BuffedSpiderAI(npc, Mod); - } - break; - - case NPCAIStyleID.Herpling: - if (npc.type == NPCType()) - { - return RevengeanceAndDeathAI.BuffedHerplingAI(npc, Mod); - } - else - { - switch (npc.type) - { - case NPCID.Herpling: - case NPCID.Derpling: - case NPCID.ChatteringTeethBomb: - return RevengeanceAndDeathAI.BuffedHerplingAI(npc, Mod); - } - } - break; - - case NPCAIStyleID.FlyingFish: - switch (npc.type) - { - case NPCID.FlyingFish: - case NPCID.GiantFlyingAntlion: - case NPCID.FlyingAntlion: - case NPCID.EyeballFlyingFish: - return RevengeanceAndDeathAI.BuffedFlyingFishAI(npc, Mod); - } - break; - - case NPCAIStyleID.AngryNimbus: - switch (npc.type) - { - case NPCID.AngryNimbus: - return RevengeanceAndDeathAI.BuffedAngryNimbusAI(npc, Mod); - } - break; - - case NPCAIStyleID.TeslaTurret: - switch (npc.type) - { - case NPCID.MartianTurret: - return RevengeanceAndDeathAI.BuffedTeslaTurretAI(npc, Mod); - } - break; - - case NPCAIStyleID.Corite: - switch (npc.type) - { - case NPCID.MartianDrone: - case NPCID.SolarCorite: - return RevengeanceAndDeathAI.BuffedCoriteAI(npc, Mod); - } - break; - - case NPCAIStyleID.MartianProbe: - switch (npc.type) - { - case NPCID.MartianProbe: - return RevengeanceAndDeathAI.BuffedMartianProbeAI(npc, Mod); - } - break; - - case NPCAIStyleID.StarCell: - switch (npc.type) - { - case NPCID.StardustCellBig: - case NPCID.NebulaHeadcrab: - case NPCID.DeadlySphere: - return RevengeanceAndDeathAI.BuffedStarCellAI(npc, Mod); - } - break; - - case NPCAIStyleID.AncientVision: - switch (npc.type) - { - case NPCID.ShadowFlameApparition: - case NPCID.AncientCultistSquidhead: - return RevengeanceAndDeathAI.BuffedAncientVisionAI(npc, Mod); - } - break; - - case NPCAIStyleID.BiomeMimic: - switch (npc.type) - { - case NPCID.BigMimicCorruption: - case NPCID.BigMimicCrimson: - case NPCID.BigMimicHallow: - case NPCID.BigMimicJungle: - return RevengeanceAndDeathAI.BuffedBigMimicAI(npc, Mod); - } - break; - - case NPCAIStyleID.MothronEgg: - switch (npc.type) - { - case NPCID.MothronEgg: - return RevengeanceAndDeathAI.BuffedMothronEggAI(npc, Mod); - } - break; - - case NPCAIStyleID.GraniteElemental: - switch (npc.type) - { - case NPCID.GraniteFlyer: - return RevengeanceAndDeathAI.BuffedGraniteElementalAI(npc, Mod); - } - break; - - case NPCAIStyleID.SmallStarCell: - switch (npc.type) - { - case NPCID.StardustCellSmall: - return RevengeanceAndDeathAI.BuffedSmallStarCellAI(npc, Mod); - } - break; - - case NPCAIStyleID.FlowInvader: - switch (npc.type) - { - case NPCID.StardustJellyfishBig: - return RevengeanceAndDeathAI.BuffedFlowInvaderAI(npc, Mod); - } - break; - - default: - break; - } - } - - if (npc.type == NPCID.QueenSlimeMinionBlue) - return QueenSlimeAI.QueenSlimeCrystalSlimeAI(npc, Mod); - - if (npc.type == NPCID.QueenSlimeMinionPink) - return QueenSlimeAI.QueenSlimeBouncySlimeAI(npc, Mod); - - if (npc.type == NPCID.FungiBulb) - return RevengeanceAndDeathAI.BuffedPlantAI(npc, Mod); - - if (npc.type == NPCID.FungiSpore || npc.type == NPCID.Spore) - return RevengeanceAndDeathAI.BuffedSporeAI(npc, Mod); - + #region Fairies Edit // Fairies don't run away and are immune to damage while wearing Fairy Boots. if (npc.type >= NPCID.FairyCritterPink && npc.type <= NPCID.FairyCritterBlue && (npc.ai[2] < 2f || npc.ai[2] == 7f)) { @@ -5045,29 +2980,27 @@ namespace CalamityMod.NPCs npc.velocity = Vector2.Lerp(npc.velocity, targetPointDir, 0.07f); } - for (int k = 0; k < Main.maxNPCs; k++) + foreach (NPC k in Main.ActiveNPCs) { - if (k != npc.whoAmI && Main.npc[k].active && Main.npc[k].aiStyle == NPCAIStyleID.Fairy && Math.Abs(npc.position.X - Main.npc[k].position.X) + Math.Abs(npc.position.Y - Main.npc[k].position.Y) < (float)npc.width * 1.5f) + if (k != npc && k.aiStyle == NPCAIStyleID.Fairy && Math.Abs(npc.position.X - k.position.X) + Math.Abs(npc.position.Y - k.position.Y) < npc.width * 1.5f) { - if (npc.position.Y < Main.npc[k].position.Y) + if (npc.position.Y < k.position.Y) npc.velocity.Y -= 0.05f; else npc.velocity.Y += 0.05f; } } - npc.direction = (npc.velocity.X >= 0f) ? 1 : (-1); + npc.direction = npc.velocity.X >= 0f ? 1 : -1; npc.spriteDirection = -npc.direction; Color dustLerpColor1 = Color.HotPink; Color dustLerpColor2 = Color.LightPink; - int dustPosition = 4; if (npc.type == NPCID.FairyCritterGreen) { dustLerpColor1 = Color.LimeGreen; dustLerpColor2 = Color.LightSeaGreen; } - if (npc.type == NPCID.FairyCritterBlue) { dustLerpColor1 = Color.RoyalBlue; @@ -5077,7 +3010,7 @@ namespace CalamityMod.NPCs if ((int)Main.timeForVisualEffects % 2 == 0) { npc.position += npc.netOffset; - Dust dust = Dust.NewDustDirect(npc.Center - new Vector2(dustPosition) * 0.5f, dustPosition + 4, dustPosition + 4, DustID.FireworksRGB, 0f, 0f, 200, Color.Lerp(dustLerpColor1, dustLerpColor2, Main.rand.NextFloat()), 0.65f); + Dust dust = Dust.NewDustDirect(npc.Center - new Vector2(2f), 8, 8, DustID.FireworksRGB, 0f, 0f, 200, Color.Lerp(dustLerpColor1, dustLerpColor2, Main.rand.NextFloat()), 0.65f); dust.velocity *= 0f; dust.velocity += npc.velocity * 0.3f; dust.noGravity = true; @@ -5096,6 +3029,7 @@ namespace CalamityMod.NPCs return false; } } + #endregion return true; } @@ -5115,409 +3049,6 @@ namespace CalamityMod.NPCs } #endregion - #region Pillar Event Progression Edit - private void PillarEventProgressionEdit(NPC npc) - { - // Make pillars a bit more fun by forcing more difficult enemies based on progression. - int solarTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerSolar / 25D); - switch (solarTowerShieldStrength) - { - case 4: - // Possible spawns: Drakanian, Drakomire, Drakomire Rider, Sroller - switch (npc.type) - { - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarSolenian: - case NPCID.SolarCorite: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Drakanian, Drakomire Rider, Sroller - switch (npc.type) - { - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarDrakomire: - case NPCID.SolarSolenian: - case NPCID.SolarCorite: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 2: - // Possible spawns: Drakanian, Selenian, Sroller - switch (npc.type) - { - case NPCID.SolarDrakomire: - case NPCID.SolarCrawltipedeHead: - case NPCID.SolarCrawltipedeBody: - case NPCID.SolarCrawltipedeTail: - case NPCID.SolarCorite: - case NPCID.SolarDrakomireRider: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 1: - // Possible spawns: Corite, Selenian, Sroller, Crawltipede - switch (npc.type) - { - case NPCID.SolarDrakomire: - case NPCID.SolarSpearman: - case NPCID.SolarDrakomireRider: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 0: - // Possible spawns: Corite, Crawltipede, Selenian - switch (npc.type) - { - case NPCID.SolarDrakomire: - case NPCID.SolarSpearman: - case NPCID.SolarDrakomireRider: - case NPCID.SolarSroller: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - } - - int vortexTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerVortex / 25D); - switch (vortexTowerShieldStrength) - { - case 4: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen - switch (npc.type) - { - case NPCID.VortexSoldier: - case NPCID.VortexRifleman: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian - if (npc.type == NPCID.VortexRifleman) - { - npc.active = false; - npc.netUpdate = true; - } - break; - case 2: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Storm Diver - if (npc.type == NPCID.VortexSoldier) - { - npc.active = false; - npc.netUpdate = true; - } - break; - case 1: - case 0: - // Possible spawns: Alien Larva, Alien Hornet, Alien Queen, Vortexian, Storm Diver - break; - } - - int nebulaTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerNebula / 25D); - switch (nebulaTowerShieldStrength) - { - case 4: - // Possible spawns: Brain Suckler - switch (npc.type) - { - case NPCID.NebulaBeast: - case NPCID.NebulaBrain: - case NPCID.NebulaSoldier: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Brain Suckler, Predictor - switch (npc.type) - { - case NPCID.NebulaBeast: - case NPCID.NebulaBrain: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 2: - // Possible spawns: Brain Suckler, Predictor, Evolution Beast - if (npc.type == NPCID.NebulaBrain) - { - npc.active = false; - npc.netUpdate = true; - } - break; - case 1: - case 0: - // Possible spawns: Predictor, Evolution Beast, Nebula Floater - if (npc.type == NPCID.NebulaHeadcrab) - { - npc.active = false; - npc.netUpdate = true; - } - break; - } - - int stardustTowerShieldStrength = (int)Math.Ceiling(NPC.ShieldStrengthTowerStardust / 25D); - switch (stardustTowerShieldStrength) - { - case 4: - // Possible spawns: Milkyway Weaver, Star Cell - switch (npc.type) - { - case NPCID.StardustSpiderBig: - case NPCID.StardustSoldier: - case NPCID.StardustJellyfishBig: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 3: - // Possible spawns: Milkyway Weaver, Stargazer, Twinkle Popper - switch (npc.type) - { - case NPCID.StardustCellBig: - case NPCID.StardustJellyfishBig: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 2: - // Possible spawns: Stargazer, Twinkle Popper, Flow Invader - switch (npc.type) - { - case NPCID.StardustCellBig: - case NPCID.StardustWormHead: - case NPCID.StardustWormBody: - case NPCID.StardustWormTail: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - case 1: - case 0: - // Possible spawns: Twinkle Popper, Flow Invader - switch (npc.type) - { - case NPCID.StardustCellBig: - case NPCID.StardustWormHead: - case NPCID.StardustWormBody: - case NPCID.StardustWormTail: - case NPCID.StardustSoldier: - npc.active = false; - npc.netUpdate = true; - break; - default: - break; - } - break; - } - } - #endregion - - #region AI - public override void AI(NPC npc) - { - // Fair contact damage - switch (npc.type) - { - case NPCID.DD2Betsy: - npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; - break; - - case NPCID.DD2WyvernT1: - case NPCID.DD2WyvernT2: - case NPCID.DD2WyvernT3: - npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; - break; - - case NPCID.DD2GoblinT1: - case NPCID.DD2GoblinT2: - case NPCID.DD2GoblinT3: - npc.damage = (npc.ai[0] > 0f && npc.ai[0] < 24f) ? npc.defDamage : 0; - break; - - case NPCID.PumpkingBlade: - npc.damage = (npc.ai[2] == 2f || npc.ai[2] == 5f) ? npc.defDamage : 0; - break; - - case NPCID.Mothron: - npc.damage = npc.ai[0] == 3.2f ? (int)Math.Round(npc.defDamage * 1.3) : npc.ai[0] == 2f ? (int)Math.Round(npc.defDamage * 0.5) : 0; - break; - - case NPCID.MothronSpawn: - npc.damage = npc.ai[0] == 2.1f ? npc.defDamage : 0; - break; - - case NPCID.Flocko: - npc.damage = npc.ai[0] > 0f ? npc.defDamage : 0; - break; - - case NPCID.Mimic: - case NPCID.IceMimic: - case NPCID.PresentMimic: - npc.damage = (npc.ai[0] == 0f || npc.velocity.Y == 0f) ? 0 : npc.defDamage; - break; - - case NPCID.BigMimicCorruption: - case NPCID.BigMimicCrimson: - case NPCID.BigMimicHallow: - case NPCID.BigMimicJungle: - npc.damage = npc.ai[0] == 3f ? 0 : npc.defDamage; - - // Spend less time in closed state - if (npc.ai[0] == 3f) - npc.ai[1] += 0.5f; - - break; - - case NPCID.DeadlySphere: - npc.damage = npc.ai[0] == 1f ? npc.defDamage : 0; - break; - - case NPCID.NebulaHeadcrab: - npc.damage = npc.ai[0] == 5f ? npc.defDamage : 0; - break; - - case NPCID.MartianDrone: - case NPCID.SolarCorite: - npc.damage = (npc.ai[0] == 2f || npc.ai[0] == 3f) ? npc.defDamage : 0; - break; - - case NPCID.ArmedTorchZombie: - case NPCID.ArmedZombie: - case NPCID.ArmedZombieCenx: - case NPCID.ArmedZombieEskimo: - case NPCID.ArmedZombiePincussion: - case NPCID.ArmedZombieSlimed: - case NPCID.ArmedZombieSwamp: - case NPCID.ArmedZombieTwiggy: - case NPCID.Crawdad: - case NPCID.Crawdad2: - npc.damage = npc.ai[2] == 0f ? 0 : (int)Math.Round(npc.defDamage * 1.4); - break; - - case NPCID.GraniteFlyer: - npc.damage = npc.ai[0] == -1f ? 0 : npc.defDamage; - break; - - case NPCID.GraniteGolem: - npc.damage = npc.ai[2] < 0f ? 0 : npc.defDamage; - break; - - case NPCID.Squid: - case NPCID.BlueJellyfish: - case NPCID.GreenJellyfish: - case NPCID.PinkJellyfish: - case NPCID.BloodJelly: - case NPCID.FungoFish: - float damagingVelocity = npc.type == NPCID.GreenJellyfish ? 3.6f : 2.8f; - npc.damage = (npc.dontTakeDamage || npc.velocity.Length() > damagingVelocity) ? npc.defDamage : 0; - break; - - case NPCID.Herpling: - case NPCID.Derpling: - npc.damage = (npc.velocity.Y == 0f || npc.velocity.Length() < 3f) ? 0 : npc.defDamage; - break; - - case NPCID.BlueSlime: - case NPCID.MotherSlime: - case NPCID.LavaSlime: - case NPCID.DungeonSlime: - case NPCID.CorruptSlime: - case NPCID.IlluminantSlime: - case NPCID.ToxicSludge: - case NPCID.IceSlime: - case NPCID.Crimslime: - case NPCID.UmbrellaSlime: - case NPCID.RainbowSlime: - case NPCID.SlimeMasked: - case NPCID.HoppinJack: - case NPCID.SlimeRibbonWhite: - case NPCID.SlimeRibbonYellow: - case NPCID.SlimeRibbonGreen: - case NPCID.SlimeRibbonRed: - case NPCID.SandSlime: - case NPCID.GoldenSlime: - case NPCID.ShimmerSlime: - case NPCID.GreenSlime: - case NPCID.RedSlime: - case NPCID.PurpleSlime: - case NPCID.YellowSlime: - case NPCID.BlackSlime: - case NPCID.JungleSlime: - case NPCID.BabySlime: - case NPCID.Pinky: - case NPCID.BunnySlimed: - case NPCID.Slimeling: - case NPCID.Slimer2: - npc.damage = (npc.velocity.Y == 0f || npc.velocity.Length() < 3f) ? 0 : npc.defDamage; - break; - - case NPCID.GiantShelly: - case NPCID.GiantShelly2: - npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.2) : 0; - break; - - case NPCID.GiantTortoise: - case NPCID.IceTortoise: - npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.4) : 0; - break; - - case NPCID.SolarSroller: - npc.damage = npc.ai[0] == 6f ? (int)Math.Round(npc.defDamage * 1.2) : 0; - break; - - default: - break; - } - - if (CalamityWorld.revenge && npc.type == NPCID.DungeonGuardian) - SkeletronAI.RevengeanceDungeonGuardianAI(npc); - } - #endregion - #region Post AI public override void PostAI(NPC npc) { @@ -5601,128 +3132,6 @@ namespace CalamityMod.NPCs npc.ai[3] = 0f; } - // Debuff decrements - if (debuffResistanceTimer > 0) - debuffResistanceTimer--; - - if (timeSlow > 0) - timeSlow--; - if (tesla > 0) - tesla--; - if (gState > 0) - gState--; - if (tSad > 0) - tSad--; - if (eutrophication > 0) - eutrophication--; - if (webbed > 0) - webbed--; - if (slowed > 0) - slowed--; - if (kamiFlu > 0) - kamiFlu--; - if (vaporfied > 0) - vaporfied--; - - if (electrified > 0) - electrified--; - if (pearlAura > 0) - pearlAura--; - if (bBlood > 0) - bBlood--; - if (brainRot > 0) - brainRot--; - if (heavybleeding > 0) - heavybleeding--; - if (laceration > 0) - laceration--; - if (elementalMix > 0) - elementalMix--; - if (trueVulnerabilityHex > 0) - { - vulnerabilityHex = 0; // You cannot stack True VHex with its lesser counterpart. - trueVulnerabilityHex--; - if (trueVulnerabilityHex == 0) - cursorFocus = 0; - } - if (vulnerabilityHex > 0) - vulnerabilityHex--; - if (marked > 0) - marked--; - if (absorberAffliction > 0) - absorberAffliction--; - if (irradiated > 0) - irradiated--; - if (bFlames > 0) - bFlames--; - if (demonicFlames > 0) - demonicFlames--; - else - demonicFlamesBonusDamage = 0; - if (hFlames > 0) - hFlames--; - if (pFlames > 0) - pFlames--; - // Soma Prime's Shred stacks have a unique falloff mechanic in the debuff's own file. - if (aCrunch > 0) - aCrunch--; - if (crumble > 0) - crumble--; - if (cDepth > 0) - cDepth--; - if (hPressure > 0) - hPressure--; - if (rTide > 0) - rTide--; - if (gsInferno > 0) - gsInferno--; - if (dragonFire > 0) - dragonFire--; - if (vermillionFlux > 0) - vermillionFlux--; - if (auricRebuke > 0) - auricRebuke--; - if (staticDischarge > 0) - staticDischarge--; - if (miracleBlight > 0) - miracleBlight--; - if (astralInfection > 0) - astralInfection--; - if (wDeath > 0) - wDeath--; - if (nightwither > 0) - nightwither--; - if (shocked > 0) - shocked--; - if (voidfrost > 0) - voidfrost--; - if (shellfishVore > 0) - shellfishVore--; - if (clamDebuff > 0) - clamDebuff--; - if (sulphurPoison > 0) - sulphurPoison--; - if (sagePoisonTime > 0) - sagePoisonTime--; - if (GaussFluxTimer > 0) - GaussFluxTimer--; - if (ladHearts > 0) - ladHearts--; - if (banishingFire > 0) - banishingFire--; - if (wither > 0) - wither--; - if (ashesOnDeath > 0) - ashesOnDeath--; - - if (antlionCloudDebuffTimer > 0) - antlionCloudDebuffTimer--; - if (cursorFocus > 0 && cursorFocus < cursorFocusMax) - cursorFocus--; - - if (relicOfResilienceWeakness > 0) - relicOfResilienceWeakness--; - if (warbannerBurnTimer > 0) warbannerBurnTimer--; if (warbannerBurnTimer == 0 && warbannerBurnMarked) @@ -5732,6 +3141,10 @@ namespace CalamityMod.NPCs warbannerBurnMarked = false; warbannerBurnStacks = 0; } + if (warbannerBurnTimer <= 60) + { + warbannerBurnStacks = (int)(warbannerBurnStacks * 0.9f); + } if (warbannerBurnMarked) { int maxStacks = 300; // Time in frames needed to reach max power @@ -5793,9 +3206,6 @@ namespace CalamityMod.NPCs if (veriumDoomTimer > 0) veriumDoomTimer--; - if (laserBurnTimer > 0) - laserBurnTimer--; - if (veriumDoomTimer == 0 && veriumDoomMarked) { for (int d = 0; d < 14 + veriumDoomStacks; d++) @@ -5804,7 +3214,7 @@ namespace CalamityMod.NPCs GeneralParticleHandler.SpawnParticle(sparks); } - SoundEngine.PlaySound(new("CalamityMod/Sounds/NPCHit/CryogenHit", 3) { Volume = 0.6f }, npc.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCHit/CryogenHit", 3) { Volume = 0.6f }, npc.Center); Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ProjectileType(), 100 + (15 * veriumDoomStacks), 0, Main.myPlayer, npc.whoAmI); veriumDoomMarked = false; @@ -5815,7 +3225,6 @@ namespace CalamityMod.NPCs if (shocked > 0) { var player = Main.LocalPlayer; - int frequency = 15; // Spawn sparks from the enemy @@ -5828,32 +3237,67 @@ namespace CalamityMod.NPCs spark.penetrate = 3; } } + if (hyperiusMarked) + { + if (hyperiusFxTimer < 20) + hyperiusFxTimer++; + else if (hyperiusFxTimer > 20) + hyperiusFxTimer = (int)Utils.Lerp(hyperiusFxTimer, 20, 0.2f); - if (laserBurnTimer <= 0 && laserBurnMarked && laserBurnType > 0) + float threshold = hyperiusDamage / (float)(npc.lifeMax); + int overflowSpeed = (int)Utils.Remap(threshold, HyperiusLifePercentThreshold, 0.35f, 1, 34); + if (threshold > HyperiusLifePercentThreshold) // If the stored damage is greater than the life % cap of the target's max health, rapily deal a % of the stored damage to the enemy to drain it + { + bool enemyIsNotArmored = npc.defense < 1000 && !unbreakableDR && DR <= 0.9f && !npc.dontTakeDamage && !npc.immortal; + if (enemyIsNotArmored) + hyperiusOverflowTimer -= overflowSpeed; + if (hyperiusOverflowTimer <= 0) + { + hyperiusOverflowTimer = hyperiusOverflowTime; + + float damagePercent = 0.07f; // The % of stacks drained when you're over the cap + int damage = Math.Max((int)(hyperiusDamage * damagePercent), 1); + hyperiusDamage -= damage; + + // Spawn "bleed" hit + // Uses a seperate projectile so that the hit takes defense and DR into account + Projectile overflow = Projectile.NewProjectileDirect(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ProjectileType(), damage, 0, -1, npc.whoAmI); + overflow.DamageType = DamageClass.Ranged; + if (hyperiusFxTimer >= 20) + hyperiusFxTimer = 35; + + if (hyperiusDamage <= 0) + { + hyperiusDamage = 0; + hyperiusMarked = false; + } + } + } + } + else if (hyperiusFxTimer > 0) + hyperiusFxTimer--; + + if (laserBurnTimer > 0) + laserBurnTimer--; + if ((laserBurnTimer <= 0 || laserBurnDamage >= npc.life * 1.5f) && laserBurnMarked && laserBurnType > 0) { if (laserBurnType == 1) // Applied damage Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ProjectileType(), laserBurnDamage, 0, Main.myPlayer, npc.whoAmI); if (laserBurnType == 2) // Flat damage + stacks Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ProjectileType(), 70 + (20 * laserBurnStacks), 0, Main.myPlayer, npc.whoAmI); - for (int d = 0; d < (int)(6 + laserBurnStacks * 0.35f); d++) + for (int d = 0; d < (int)(7 + laserBurnStacks * 0.4f); d++) { - float partScale = Main.rand.NextFloat(0.7f, 1f); - Vector2 partVel = (new Vector2(15, 15) * (laserBurnStacks * 0.025f)).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f); - for (int i = 0; i < 2; i++) - { - Particle sparks = new SparkParticle(npc.Center, partVel, false, 30, i == 0 ? partScale : partScale * 0.4f, i == 0 ? Color.Red : Color.White); - GeneralParticleHandler.SpawnParticle(sparks); - } + Vector2 partVel = (new Vector2(10) * (laserBurnStacks * 0.025f)).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(0.2f, 1f); + Particle spark2 = new CustomSpark(npc.Center, partVel, "CalamityMod/Particles/BloomLineSoftEdge", false, 12, Main.rand.NextFloat(0.02f, 0.03f), Effects.ArsenalEffects.ArsenalLaserColor * 0.8f, new Vector2(1, 1), true, false, 0, false, false, 1f); + GeneralParticleHandler.SpawnParticle(spark2); - Dust dust = Dust.NewDustPerfect(npc.Center, 278); - dust.velocity = (new Vector2(10, 10) * (laserBurnStacks * 0.05f)).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f) + new Vector2(0, -1); - dust.scale = Main.rand.NextFloat(0.8f, 1.1f); - dust.noGravity = false; - dust.color = Color.Red; + Vector2 dustVel = (Vector2.UnitX * 5f * (laserBurnStacks * 0.05f)).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(0.85f, 1f); + Dust dust = Dust.NewDustPerfect(npc.Center, Effects.ArsenalEffects.ArsenalLaserDust, dustVel, 0, Color.Red, Main.rand.NextFloat(0.65f, 0.8f)); + dust.noGravity = true; } - SoundEngine.PlaySound(new("CalamityMod/Sounds/Item/LaserBurn") { Volume = 0.6f, PitchVariance = 0.15f }, npc.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LaserBurn") { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, npc.Center); laserBurnMarked = false; laserBurnStacks = 0; laserBurnTimer = 0; @@ -5866,7 +3310,7 @@ namespace CalamityMod.NPCs // Pearl Aura shard spawning // Slowing is handled in the general slowing code below - if (pearlAura > 0) + if (pearlAura) { pearlAuraCounter++; if (pearlAuraCounter >= 45) @@ -5876,7 +3320,7 @@ namespace CalamityMod.NPCs // Prevent things from getting too crazy // CIT 8MAR2025: It is assumed that pearlAuraOwner is always set to something other than -1 when this code is run. - if (CalamityUtils.CountOwnedProjectiles(ProjectileType(), pearlAuraOwner) <= 3) + if (Main.player[pearlAuraOwner].ownedProjectileCounts[ProjectileType()] <= 3) { for (int i = 0; i < 3; i++) { @@ -5905,33 +3349,27 @@ namespace CalamityMod.NPCs } impalePacketTimer++; - // Queen Bee is completely immune to having her movement impaired if not in a high difficulty mode. - if (npc.type == NPCID.QueenBee && !CalamityWorld.revenge && !BossRushEvent.BossRushActive) - return; - // Apply slowing debuff effects if (debuffResistanceTimer <= 0 || (debuffResistanceTimer > slowingDebuffResistanceMin)) { // Slowing debuffs which set a velocity hard cap take priority first. - if (vulnerabilityHex > 0) + if (vulnerabilityHex) npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-Calamity.MaxNPCSpeed), new Vector2(Calamity.MaxNPCSpeed, 10f)); - else if (kamiFlu > 360) - npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-YanmeisKnife.DebuffNPCSpeedCap), new Vector2(YanmeisKnife.DebuffNPCSpeedCap)); // Then debuffs which apply a multiplier to velocity. // These multipliers can stack with each other, even if you'll rarely see this on a boss. float velocitySlownessFactor = 1f; - if (tSad > 0) + if (temporalSadness) velocitySlownessFactor += 0.2f; - if (timeSlow > 0) + if (timeDistortion) velocitySlownessFactor += 0.15f; - if (webbed > 0) + if (webbed) velocitySlownessFactor += 0.15f; - if (gState > 0) + if (glacialState) { float baseSlownessFactor = 0.1f; if (VulnerableToCold.HasValue) @@ -5944,10 +3382,10 @@ namespace CalamityMod.NPCs velocitySlownessFactor += baseSlownessFactor; } - if (pearlAura > 0) + if (pearlAura) velocitySlownessFactor += 0.1f; - if (eutrophication > 0) + if (eutrophication) { float baseSlownessFactor = 0.05f; if (VulnerableToWater.HasValue) @@ -5960,10 +3398,7 @@ namespace CalamityMod.NPCs velocitySlownessFactor += baseSlownessFactor; } - if (slowed > 0) - velocitySlownessFactor += 0.05f; - - if (tesla > 0) + if (galvanicCorrosion) { float baseSlownessFactor = 0.05f; if (VulnerableToElectricity.HasValue) @@ -5976,7 +3411,7 @@ namespace CalamityMod.NPCs velocitySlownessFactor += baseSlownessFactor; } - if (vaporfied > 0) + if (vaporfied) velocitySlownessFactor += 0.05f; // Divide 1 by the slowness factor to get the amount to slow by. @@ -5985,40 +3420,28 @@ namespace CalamityMod.NPCs npc.velocity *= velocitySlownessFactor; } - // Auric Ore/Repulsers reject Town NPCs and dummies (Auric Land Mines work on them too) + // Auric Ore/Repulsers reject Town NPCs and dummies if ((NPCID.Sets.ActsLikeTownNPC[npc.type] || npc.townNPC) && !npc.dontTakeDamage || npc.type == NPCType()) { int auricOreID = TileType(); int auricRepulserID = TileType(); - int auricLandMineID = TileType(); // Get a list of tiles near the npc // This is just Collision.GetEntityTiles but with a larger detection square because the sheer speed from auric boosts causes the detection to fail at higher speeds - List EdgeTiles = new List(); + List EdgeTiles = []; int extraDist = (int)(8 * npc.velocity.Length() / 6) + 1; int left = (int)npc.position.X - extraDist; int up = (int)npc.position.Y - extraDist; int right = (int)npc.Right.X + extraDist; int down = (int)npc.Bottom.Y + extraDist; if (left % 16 == 0) - { left--; - } - if (up % 16 == 0) - { up--; - } - if (right % 16 == 0) - { right++; - } - if (down % 16 == 0) - { down++; - } int width = right / 16 - left / 16; int height = down / 16 - up / 16; @@ -6041,17 +3464,6 @@ namespace CalamityMod.NPCs if (!tile.HasTile || !tile.HasUnactuatedTile) continue; - if (tile.TileType == auricLandMineID) - { - SoundStyle explode = new("CalamityMod/Sounds/Item/DudFire"); - SoundEngine.PlaySound(explode with { Pitch = 0.8f }, touchedTile.ToWorldCoordinates()); - GenericSparkle sparker = new GenericSparkle(touchedTile.ToWorldCoordinates(), Vector2.Zero, Color.Goldenrod, Color.Gold, 2.5f, 9, Main.rand.NextFloat(-0.01f, 0.01f), 2.68f); - GeneralParticleHandler.SpawnParticle(sparker); - Projectile.NewProjectile(new EntitySource_TileInteraction(npc, touchedTile.X, touchedTile.Y), touchedTile.ToWorldCoordinates(), Vector2.Zero, ProjectileType(), 40000, 0f); - WorldGen.KillTile(touchedTile.X, touchedTile.Y, noItem: true); - continue; - } - if (tile.TileType != auricOreID && tile.TileType != auricRepulserID) continue; @@ -6088,11 +3500,9 @@ namespace CalamityMod.NPCs npc.AddBuff(BuffID.Poisoned, 60); if (target.Calamity().ilSpark) - { shocked = 120; - } - if (target.Calamity().snowman) + if (target.Transformation().Type == ItemType()) { if (npc.type == NPCID.Demon || npc.type == NPCID.VoodooDemon || npc.type == NPCID.RedDevil) target.AddBuff(BuffType(), 36000); @@ -6100,19 +3510,28 @@ namespace CalamityMod.NPCs switch (npc.type) { - case NPCID.VileSpitEaterOfWorlds: - case NPCID.VileSpit: + case NPCID.DevourerHead: + case NPCID.FaceMonster: + target.AddBuff(BuffID.Weak, 180); + break; - target.AddBuff(BuffType(), 180); - if (Main.rand.NextBool(10)) - target.AddBuff(BuffID.Weak, 3600); - else if (Main.rand.NextBool(5)) - target.AddBuff(BuffID.Weak, 720); - else if (Main.rand.NextBool(2)) - target.AddBuff(BuffID.Weak, 120); - else - target.AddBuff(BuffID.Weak, 60); + case NPCID.ArmoredViking: + if (Main.rand.NextBool(6)) + target.AddBuff(BuffID.BrokenArmor, 1800); + break; + case NPCID.IlluminantBat: + if (Main.rand.NextBool(14)) + target.AddBuff(BuffID.Confused, 180); + break; + + case NPCID.Piranha: + target.AddBuff(BuffID.Bleeding, 180); + break; + + case NPCID.Arapaima: + case NPCID.BloodFeeder: + target.AddBuff(BuffID.Bleeding, 300); break; case NPCID.ShadowFlameApparition: @@ -6124,60 +3543,17 @@ namespace CalamityMod.NPCs target.AddBuff(BuffType(), 120); break; - case NPCID.EyeofCthulhu: - if (npc.ai[0] > 2f) - target.AddBuff(BuffID.Bleeding, 180); - break; - - case NPCID.WallofFlesh: - target.AddBuff(BuffID.Bleeding, 300); - break; - - case NPCID.Spazmatism: - if (npc.ai[0] != 1f && npc.ai[0] != 2f && npc.ai[0] != 0f) - target.AddBuff(BuffType(), 180, true); - break; - - case NPCID.SkeletronPrime: - if (npc.ai[1] == 1f || npc.ai[1] == 2f) - target.AddBuff(BuffType(), 180, true); - break; - - case NPCID.PrimeSaw: - target.AddBuff(BuffType(), 120, true); - break; - - case NPCID.Plantera: - if (npc.life < npc.lifeMax / 2) - target.AddBuff(BuffID.Poisoned, 300); - break; - - case NPCID.PlanterasTentacle: - target.AddBuff(BuffID.Poisoned, 120); - break; - case NPCID.Golem: - target.AddBuff(BuffType(), 480); + if (CalamityWorld.revenge) + target.AddBuff(BuffType(), 480); break; case NPCID.GolemHead: case NPCID.GolemHeadFree: case NPCID.GolemFistRight: case NPCID.GolemFistLeft: - target.AddBuff(BuffType(), 240); - break; - - case NPCID.DukeFishron: - target.AddBuff(BuffType(), 120, true); - break; - - case NPCID.AncientLight: - target.AddBuff(BuffType(), 120); - break; - - case NPCID.HallowBoss: - if (NPC.ShouldEmpressBeEnraged()) - target.AddBuff(BuffType(), 240); + if (CalamityWorld.revenge) + target.AddBuff(BuffType(), 240); break; case NPCID.BloodNautilus: @@ -6189,8 +3565,13 @@ namespace CalamityMod.NPCs target.AddBuff(BuffType(), 180); break; + case NPCID.Hellbat: + if (Main.expertMode) + target.AddBuff(BuffID.OnFire, 120); + break; + case NPCID.Lavabat: - target.AddBuff(BuffID.OnFire, 120); + target.AddBuff(BuffID.OnFire, 300); break; case NPCID.RuneWizard: @@ -6202,71 +3583,22 @@ namespace CalamityMod.NPCs break; } - if (Main.hardMode) + // GFB Brain and its Creepers can inflict literally any buff in the game + // Yes this includes pets, light pets, mounts, whip tags, endgame debuffs, anything! + if ((npc.type == NPCID.BrainofCthulhu || npc.type == NPCID.Creeper) && Main.zenithWorld) { - switch (npc.type) - { - case NPCID.BigBoned: - case NPCID.ShortBones: - case NPCID.AngryBones: - case NPCID.AngryBonesBig: - case NPCID.AngryBonesBigMuscle: - case NPCID.AngryBonesBigHelmet: - target.AddBuff(BuffType(), 60); - break; - - default: - break; - } - - if (NPC.downedPlantBoss) - { - switch (npc.type) - { - case NPCID.RustyArmoredBonesAxe: - case NPCID.RustyArmoredBonesFlail: - case NPCID.RustyArmoredBonesSword: - case NPCID.RustyArmoredBonesSwordNoArmor: - case NPCID.BlueArmoredBones: - case NPCID.BlueArmoredBonesMace: - case NPCID.BlueArmoredBonesNoPants: - case NPCID.BlueArmoredBonesSword: - case NPCID.HellArmoredBones: - case NPCID.HellArmoredBonesSpikeShield: - case NPCID.HellArmoredBonesMace: - case NPCID.HellArmoredBonesSword: - target.AddBuff(BuffType(), 120); - break; - - default: - break; - } - } - } - - if (Main.expertMode) - { - switch (npc.type) - { - case NPCID.Hellbat: - target.AddBuff(BuffID.OnFire, 60); - break; - - default: - break; - } + int buffType = Main.rand.Next(BuffLoader.BuffCount); + target.AddBuff(buffType, Main.rand.Next(300, 601)); } } #endregion #region On Hit NPC - public override void OnHitNPC(NPC npc, NPC target, NPC.HitInfo hit) { if (target.ModNPC is SunkenSeaNPC ssnpc) ssnpc.OnHitByNPC(npc); } - #endregion #region Modify Hit @@ -6295,10 +3627,9 @@ namespace CalamityMod.NPCs if (SharkIDs.Contains(npc.type) && target.name == "Rebecca" && Main.zenithWorld) { SoundEngine.PlaySound(AresGaussNuke.NukeExplosionSound, target.Center); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 12f) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 12f; + Main.LocalPlayer.SetScreenshake(12f); - target.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Rebecca").Format(target.name)), 1000.0, 0); + target.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Rebecca").ToNetworkText(target.name)), 1000.0, 0); modifiers.SourceDamage *= target.statLifeMax2 * Main.rand.NextFloat(3f, 6f); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -6314,45 +3645,48 @@ namespace CalamityMod.NPCs { CalamityPlayer modPlayer = player.Calamity(); if (modPlayer.camper && !player.StandingStill()) - modifiers.SourceDamage *= 0.1f; + modifiers.SourceDamage *= 0.5f; - if (IsArmored()) //Hide combat text so we can draw our own for armored NPCs - { + // Hide combat text so we can draw our own for armored NPCs + if (IsArmored()) modifiers.HideCombatText(); - } // True melee resists - if (DesertScourgeIDList.Includes(npc.type) || EaterOfWorldsIDList.Includes(npc.type) || npc.type == NPCID.Creeper || - PerforatorWormIDList.Includes(npc.type) || AquaticScourgeIDList.Includes(npc.type) || DestroyerIDList.Includes(npc.type) || - AstrumDeusIDList.Includes(npc.type) || StormWeaverIDList.Includes(npc.type) || ThanatosIDList.Includes(npc.type) || - npc.type == NPCType() || npc.type == NPCType() || AresIDList.Includes(npc.type) || npc.type == NPCType() || - npc.type == NPCType()) + // TODO: This should probably be moved into BalancingChangesManager + if (item.CountsAsClass() && item.type != ItemType()) { - float damageMult = ThanatosIDList.Includes(npc.type) ? 0.35f : (DesertScourgeIDList.Includes(npc.type) || npc.type == NPCType()) ? 0.75f : 0.5f; - if (item.CountsAsClass() && item.type != ItemType()) - modifiers.SourceDamage *= damageMult; + float damageMult = 1f; + if (npc.type == NPCType()) + damageMult = 0.8f; + else if (CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type) || npc.type == NPCID.Creeper || npc.type == NPCType()) + damageMult = 0.75f; + else if (CalamityNPCTypeSets.Perforators.Contains(npc.type) || CalamityNPCTypeSets.AquaticScourge.Contains(npc.type) || CalamityNPCTypeSets.Destroyer.Contains(npc.type) || + CalamityNPCTypeSets.Ravager.Contains(npc.type) || CalamityNPCTypeSets.AstrumDeus.Contains(npc.type) || CalamityNPCTypeSets.StormWeaver.Contains(npc.type) || + npc.type == NPCType() || npc.type == NPCType()) + damageMult = 0.5f; + else if (CalamityNPCTypeSets.Thanatos.Contains(npc.type)) + damageMult = 0.35f; + + modifiers.SourceDamage *= damageMult; } } #endregion #region Modify Hit By Projectile public static bool DisableMultWhipTag = false; - //this bool does nothing on this branch, its just here so that CalTestHelpers doesn't crash searching for it - //if you want to mess with this, please do so in the summoner branch - Shade + // This bool does nothing on the main branch, it's just here so that CalTestHelpers doesn't crash searching for it + // If you want to mess with this to test whips, please do so in the summoner branch - Shade public override void ModifyHitByProjectile(NPC npc, Projectile projectile, ref NPC.HitModifiers modifiers) { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - MakeTownNPCsTakeMoreDamage(npc, projectile, Mod, ref modifiers); - - if (IsArmored()) //Hide combat text so we can draw our own for armored NPCs - { + // Hide combat text so we can draw our own for armored NPCs + if (IsArmored()) modifiers.HideCombatText(); - } // Block natural falling stars from killing boss spawners randomly - if ((projectile.type == ProjectileID.FallingStar && projectile.damage >= 1000) && (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType())) + if (projectile.type == ProjectileID.FallingStar && projectile.damage >= 1000 && (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType())) modifiers.SourceDamage *= 0f; // Supercrits @@ -6439,7 +3773,7 @@ namespace CalamityMod.NPCs { // 08OCT2024: Ozzatron: this can be abused by firing a ton of shots then hotswapping to AMR while they are in flight // we will need IEntitySource item use time provenance to fix this, and even that is unreliable with holdouts - modPlayer.spiritOriginCritBoost += player.ActiveItem().useTime; + modPlayer.spiritOriginCritBoost += player.HeldItem.useTime; if (bullseye.ai[2] == 0f) { @@ -6472,163 +3806,161 @@ namespace CalamityMod.NPCs if (!projectile.npcProj && !projectile.trap) { - // Plague Reaper deals 1.1x damage to Plagued enemies - if (projectile.CountsAsClass() && modPlayer.plagueReaper && pFlames > 0) - modifiers.SourceDamage *= 1.1f; + // Plague Reaper deals extra damage to Plagued enemies + if (projectile.CountsAsClass() && modPlayer.plagueReaper && plague) + modifiers.SourceDamage *= PlagueReaperMask.SetBonusPlaguedRangedDamageMult; // True Vulnerability Hex causes enemies to take 1.15x damage, 2.5x from Calamity itself - if (trueVulnerabilityHex > 0) - modifiers.SourceDamage *= (projectile.type == ProjectileType() && projectile.ai[1] == 1f) ? 2.5f : 1.15f; - } - - // Any weapons that shoot projectiles from anywhere other than the player's center aren't affected by point-blank shot damage boost. - if (!Main.player[projectile.owner].ActiveItem().IsAir && Main.player[projectile.owner].ActiveItem().Calamity().canFirePointBlankShots && projectile.CountsAsClass()) - { - if (projectile.Calamity().pointBlankShotDuration > 0 && projectile.Calamity().pointBlankShotDistanceTravelled < CalamityGlobalProjectile.PointBlankShotDistanceLimit) - { - float pointBlankShotDurationRatio = projectile.Calamity().pointBlankShotDuration / (float)CalamityGlobalProjectile.DefaultPointBlankDuration; - float pointBlankShotDistanceRatio = 1f - projectile.Calamity().pointBlankShotDistanceTravelled / CalamityGlobalProjectile.PointBlankShotDistanceLimit; - float pointBlankDamageRatio = (pointBlankShotDurationRatio < pointBlankShotDistanceRatio ? pointBlankShotDurationRatio : pointBlankShotDistanceRatio) * 0.25f; - float pointBlankShotDamageMultiplier = 1f + pointBlankDamageRatio; - modifiers.SourceDamage *= pointBlankShotDamageMultiplier; - projectile.Calamity().pointBlankShotDuration = 0; - } + if (trueVulnerabilityHex) + modifiers.SourceDamage *= (projectile.type == ProjectileType() && projectile.ai[1] == 255f) ? 2.5f : 1.15f; } // Apply balancing resists/vulnerabilities. BalancingChangesManager.ApplyFromProjectile(npc, ref modifiers, projectile); - if (GrenadeResistIDList.Includes(projectile.type)) + if (CalamityProjectileSets.ResistedExplosiveProjectile[projectile.type]) { // Eater of Worlds has a vanilla resist in Expert+, this gives it to him in Normal mode - // Note that Calamity reduces the vanilla resist from 80% to 60% - bool hasResist = EaterOfWorldsIDList.Includes(npc.type) && !Main.expertMode; + // Note that Calamity reduces the vanilla resist from 80% to 67% + bool hasResist = CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type) && !Main.expertMode; // Add a resist for BoC's creepers and Prehardmode worm bosses - if (npc.type == NPCID.Creeper || DesertScourgeIDList.Includes(npc.type) || PerforatorWormIDList.Includes(npc.type)) + if (npc.type == NPCID.Creeper || CalamityNPCTypeSets.DesertScourge.Contains(npc.type) || CalamityNPCTypeSets.Perforators.Contains(npc.type)) hasResist = true; if (hasResist) - modifiers.SourceDamage *= 0.4f; + modifiers.SourceDamage *= 0.33f; } - if (PierceResistList.Includes(npc.type)) - PierceResistGlobal(projectile, npc, ref modifiers); - if (modPlayer.camper && !player.StandingStill()) - modifiers.SourceDamage *= 0.1f; + modifiers.SourceDamage *= 0.5f; + // Reduce damage of summon weapons while using Guardians relics if ((projectile.minion || ProjectileID.Sets.MinionShot[projectile.type] || projectile.sentry || ProjectileID.Sets.SentryShot[projectile.type]) && (player.ownedProjectileCounts[ProjectileType()] > 0 || player.ownedProjectileCounts[ProjectileType()] > 0 || (player.Calamity().rOfResilienceCooldown == 0 && player.HeldItem.type == ItemType()))) modifiers.SourceDamage *= 0.1f; + // Doze apr-6-2025: With the summon tag system we now have this is unnecessary and very likely causes issues on MP, so I'm commenting it out for the time being. Once further testing is done, delete it entirely. + // Delete Ardor Blossom sparks and buff if hit by something that isn't a minion or sentry while not having Ardor Blossom Star in hand. + /*if (npc.HasBuff() && player.HeldItem.type != ModContent.ItemType() && !projectile.minion && !ProjectileID.Sets.MinionShot[projectile.type] && !projectile.sentry) + { + npc.RequestBuffRemoval(ModContent.BuffType()); + //Remove all embers from this enemy + for (int k = 0; k < Main.maxProjectiles; k++) + { + if (Main.projectile[k].active && Main.projectile[k].type == ModContent.ProjectileType() && Main.projectile[k].ai[0] == 1f && Main.projectile[k].ai[1] == npc.whoAmI && Main.projectile[k].owner == player.whoAmI) + Main.projectile[k].Kill(); + } + }*/ + // Handle summon tag effects if (projectile.minion || ProjectileID.Sets.MinionShot[projectile.type] || projectile.sentry || ProjectileID.Sets.SentryShot[projectile.type]) - EditWhipTagDamage(projectile, npc, ref modifiers); - } - - // Generalized pierce resistance that stacks with all other resistances for some specific bosses defined in a list. - // The actual resistance formula isn't really a problem, but the implementation of this desperately needs refactoring. - private void PierceResistGlobal(Projectile projectile, NPC npc, ref NPC.HitModifiers modifiers) - { - // Thanatos segments do not trigger pierce resistance if they are closed - if (ThanatosIDList.Includes(npc.type) && unbreakableDR) - return; - - // Isolates projectiles which ignore pierce resist only on Leviathan and Astrum Aureus - if ((npc.type == NPCType() || npc.type == NPCType()) && PierceResistExceptionLeviAureusList.Includes(projectile.type)) - return; - - float damageReduction = projectile.Calamity().timesPierced * CalamityGlobalProjectile.PierceResistHarshness; - if (damageReduction > CalamityGlobalProjectile.PierceResistCap) - damageReduction = CalamityGlobalProjectile.PierceResistCap; - - modifiers.FinalDamage *= 1f - damageReduction; - - if ((projectile.penetrate > 1 || projectile.penetrate == -1) && !PierceResistExceptionList.Includes(projectile.type) && !projectile.CountsAsClass() && projectile.aiStyle != ProjAIStyleID.Flail && projectile.aiStyle != ProjAIStyleID.MechanicalPiranha && projectile.aiStyle != ProjAIStyleID.Yoyo) - projectile.Calamity().timesPierced++; + EditSummonTagDamage(projectile, npc, ref modifiers); } #endregion + #region OnHitBy overrides public override void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitInfo hit, int damagedone) { - if (IsArmored()) - { - CombatText.NewText(npc.Hitbox, Color.Gray, damagedone, hit.Crit); - } - } + if (projectile.minion || ProjectileID.Sets.MinionShot[projectile.type] || projectile.sentry || ProjectileID.Sets.SentryShot[projectile.type]) + SummonTagOnHitEffects(npc, projectile, hit, damagedone); - public override void OnHitByItem(NPC npc, Player player, Item item, NPC.HitInfo hit, int damagedone) - { if (IsArmored()) - { CombatText.NewText(npc.Hitbox, Color.Gray, damagedone, hit.Crit); + + if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) + { + float rate = Main.GlobalTimeWrappedHourly * 3f; + List eColors = + [ + Color.Yellow, + Color.Magenta, + Color.Red, + Color.Cyan, + Color.Lime + ]; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + CombatText.NewText(npc.Hitbox, usedColor, damagedone, hit.Crit, true); } } #endregion - #region Whip Tag - // Make whip tags multiplicative, by effectively reversing the process done to it - private void EditWhipTagDamage(Projectile proj, NPC npc, ref NPC.HitModifiers modifiers) + + #region Summon Tag + //doze 03-15-2025: A full refactor of the summon tag system to make it easier to use and more flexible. Ping me with any questions. + private void EditSummonTagDamage(Projectile proj, NPC npc, ref NPC.HitModifiers modifiers) { - // Don't make it run through the index if it's a trap - if (proj.npcProj || proj.trap) + // Don't run on non-player-owned projectiles. + if (proj.npcProj || proj.trap || proj.owner == -1) return; + var player = Main.player[proj.owner]; + var modPlayer = player.Calamity(); + + float critChance = modPlayer.bonusCritTag; float TagDamageMult = ProjectileID.Sets.SummonTagDamageMultiplier[proj.type]; + + TagDamageMult += modPlayer.bonusMultTag; + modifiers.FlatBonusDamage += modPlayer.bonusFlatTag; + for (int i = 0; i < NPC.maxBuffs; i++) { if (npc.buffTime[i] >= 1) { - switch (npc.buffType[i]) - { - case BuffID.BlandWhipEnemyDebuff: // Leather Whip - modifiers.FlatBonusDamage += -4f * TagDamageMult; - modifiers.ScalingBonusDamage += (BalancingConstants.DurendalTagDamageMultiplier - 1f) * TagDamageMult; - break; - case BuffID.ThornWhipNPCDebuff: // Snapthorn - modifiers.FlatBonusDamage += -6f * TagDamageMult; - modifiers.ScalingBonusDamage += (BalancingConstants.SnapthornTagDamageMultiplier - 1f) * TagDamageMult; - break; - case BuffID.BoneWhipNPCDebuff: // Spinal Tap - modifiers.FlatBonusDamage += -7f * TagDamageMult; - modifiers.ScalingBonusDamage += (BalancingConstants.SpinalTapTagDamageMultiplier - 1f) * TagDamageMult; - break; - case BuffID.FlameWhipEnemyDebuff: // Firecracker - modifiers.ScalingBonusDamage += (BalancingConstants.FirecrackerExplosionDamageMultiplier - 2.75f) * TagDamageMult; - break; - case BuffID.CoolWhipNPCDebuff: // Cool Whip - modifiers.FlatBonusDamage += -6f * TagDamageMult; - modifiers.ScalingBonusDamage += (BalancingConstants.CoolWhipTagDamageMultiplier - 1f) * TagDamageMult; - break; - case BuffID.SwordWhipNPCDebuff: // Durendal - modifiers.FlatBonusDamage += -9f * TagDamageMult; - modifiers.ScalingBonusDamage += (BalancingConstants.DurendalTagDamageMultiplier - 1f) * TagDamageMult; - break; - case BuffID.ScytheWhipEnemyDebuff: // Dark Harvest - modifiers.FlatBonusDamage += -10f * TagDamageMult; - break; - case BuffID.MaceWhipNPCDebuff: // Morning Star - modifiers.FlatBonusDamage += -8f * TagDamageMult; - modifiers.ScalingBonusDamage += (BalancingConstants.MorningStarTagDamageMultiplier - 1f) * TagDamageMult; - break; - case BuffID.RainbowWhipNPCDebuff: // Kaleidoscope - modifiers.FlatBonusDamage += -20f * TagDamageMult; - modifiers.ScalingBonusDamage += (BalancingConstants.KaleidoscopeTagDamageMultiplier - 1f) * TagDamageMult; - break; - } + int type = npc.buffType[i]; + if (CalamityBuffSets.SummonTagDebuff.TryGetValue(type, out SummonTag tag)) + tag.TagModifyHitEffects(proj, npc, ref modifiers, ref TagDamageMult, ref critChance); } } - //BuffType cannot be used in switch case, so that has to be handled outside of it - //Verify that the owner of the proj has psc state higher or equal to psc buffs - if (npc.HasBuff() && Main.player[proj.owner].Calamity().pscState >= (int)ProfanedSoulCrystal.ProfanedSoulCrystalState.Buffs) + + //For the vanilla Monk/Shinobi armor critting with Lightning Auras. In vanilla it doesn't stack additively but frankly I do not care. It's not like aura is that good anyway. + if (proj.type == ProjectileID.DD2LightningAuraT1 || proj.type == ProjectileID.DD2LightningAuraT2 || proj.type == ProjectileID.DD2LightningAuraT3) { - var empowered = Main.player[proj.owner].Calamity().pscState == (int)ProfanedSoulCrystal.ProfanedSoulCrystalState.Empowered; - //20% is balanced for non empowered, while 40% helps ensure psc remains balanced at empowered tier - //Some PSC projectiles receive a reduced amount of benefit from this, for balancing purposes - modifiers.ScalingBonusDamage += (empowered ? 0.4f : 0.2f) * TagDamageMult; - if (!Main.dedServ) + if (player.setMonkT3) { - var color = ProvUtils.GetColorBasedOnEnrage(!Main.dayTime, 0); - float power = Math.Min(npc.height / 100f, 3f); - var position = new Vector2(Main.rand.NextFloat(npc.Left.X, npc.Right.X), Main.rand.NextFloat(npc.Top.Y, npc.Bottom.Y)); - var particle = new FlameParticle(position, 50, 0.25f, power, color * (Main.dayTime ? 1f : 1.25f), color * (Main.dayTime ? 1.25f : 1f)); - GeneralParticleHandler.SpawnParticle(particle); + critChance += 0.25f; // 1/4 chance to crit with Shinobi + } + else if (player.setMonkT2) + { + critChance += 0.166f; // 1/6 chance to crit with Monk + } + } + + // Used to convert all multiplicative tag into crit chance and vice-versa. If both force tag crit and multiplicative are applied, chooses one at random. + if (modPlayer.forceSummonTagCrit && !(modPlayer.forceSummonTagMultiplicative && Main.rand.NextBool())) + { + critChance += modifiers.ScalingBonusDamage.Value; + modifiers.ScalingBonusDamage += -modifiers.ScalingBonusDamage.Value; + + } + else if (modPlayer.forceSummonTagMultiplicative) + { + modifiers.ScalingBonusDamage += critChance; + critChance = 0; + } + + // Currently doesn't support more than 100% crit chance, todo if something does more than +100% tag damage + if (Main.rand.NextFloat() < critChance) + modifiers.SetCrit(); + else + modifiers.DisableCrit(); // This is to prevent Morning Star and Kalei from critting with their vanilla tag effect. If you want a minion/sentry to crit, you *must* make sure to change critChance in this function. + } + + // This is for whip tag effects that run on hit and don't modify the damage of the hit. + private void SummonTagOnHitEffects(NPC npc, Projectile projectile, NPC.HitInfo hit, int damagedone) + { + // Don't run on non-player-owned projectiles. + if (projectile.npcProj || projectile.trap || projectile.owner == -1) + return; + + Player player = Main.player[projectile.owner]; + + for (int i = 0; i < NPC.maxBuffs; i++) + { + if (npc.buffTime[i] >= 1) + { + int type = npc.buffType[i]; + if (CalamityBuffSets.SummonTagDebuff.TryGetValue(type, out SummonTag tag)) + tag.TagOnHit(npc, projectile, hit, damagedone); } } } @@ -6637,26 +3969,6 @@ namespace CalamityMod.NPCs #region Check Dead public override bool CheckDead(NPC npc) { - if (npc.type == NPCID.SkeletronPrime) - { - if ((Main.masterMode || BossRushEvent.BossRushActive) && CalamityWorld.revenge) - { - // Kill the other head if he's still alive when this head dies - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC nPC = Main.npc[i]; - if (nPC.active && nPC.type == NPCType() && nPC.life > 0) - { - nPC.life = 0; - nPC.HitEffect(); - nPC.checkDead(); - nPC.active = false; - nPC.netUpdate = true; - } - } - } - } - if (npc.lifeMax > 1000 && npc.type != NPCID.DungeonSpirit && npc.type != NPCType() && npc.type != NPCType() && @@ -6671,18 +3983,18 @@ namespace CalamityMod.NPCs if (Main.player[npc.target].RollLuck(baseValue) == 0 && Main.wallDungeon[Main.tile[(int)npc.Center.X / 16, (int)npc.Center.Y / 16].WallType]) { - int randomType = Utils.SelectRandom(Main.rand, new int[] - { + int randomType = Utils.SelectRandom(Main.rand, + [ NPCType(), NPCType(), NPCType(), NPCType() - }); + ]); - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, randomType); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, randomType); } } - return true; } #endregion @@ -6711,7 +4023,7 @@ namespace CalamityMod.NPCs if (npc.life <= 0) { if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), NPCType()); + NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + npc.width / 2), (int)(npc.position.Y + npc.height), NPCType()); } break; @@ -6720,7 +4032,7 @@ namespace CalamityMod.NPCs { if (Main.netMode != NetmodeID.MultiplayerClient) { - int slimeAmt = Main.getGoodWorld ? Main.rand.Next(6) + 10 : Main.rand.Next(2) + 2; // 2 to 3 extra + int slimeAmt = Main.rand.Next(2) + 2; // 2 to 3 extra for (int s = 0; s < slimeAmt; s++) { int slime = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)(npc.position.Y + npc.height), NPCID.BlueSlime, 0, 0f, 0f, 0f, 0f, 255); @@ -6728,8 +4040,8 @@ namespace CalamityMod.NPCs npc2.SetDefaults(NPCID.BabySlime); npc2.velocity.X = npc.velocity.X * 2f; npc2.velocity.Y = npc.velocity.Y; - npc2.velocity.X += Main.rand.Next(-20, 20) * (Main.getGoodWorld ? 0.5f : 0.1f) + s * npc.direction * (Main.getGoodWorld ? 0.5f : 0.3f); - npc2.velocity.Y -= Main.rand.Next(0, 10) * (Main.getGoodWorld ? 0.5f : 0.1f) + s; + npc2.velocity.X += Main.rand.Next(-20, 20) * 0.1f + s * npc.direction * 0.3f; + npc2.velocity.Y -= Main.rand.Next(10) * 0.1f + s; npc2.ai[0] = -1000 * Main.rand.Next(3); if (Main.dedServ && slime < Main.maxNPCs) @@ -6742,38 +4054,24 @@ namespace CalamityMod.NPCs case NPCID.CursedHammer: case NPCID.EnchantedSword: case NPCID.CrimsonAxe: - if (Main.getGoodWorld) - npc.justHit = false; - - break; - case NPCID.Clinger: case NPCID.Gastropod: case NPCID.GiantTortoise: case NPCID.IceTortoise: case NPCID.BlackRecluse: case NPCID.BlackRecluseWall: - if (Main.getGoodWorld) - npc.justHit = false; - - break; - case NPCID.Paladin: if (Main.getGoodWorld) npc.justHit = false; - break; } - if (npc.type == NPCType()) - { - if (Main.getGoodWorld) - npc.justHit = false; - } + if (npc.type == NPCType() && Main.getGoodWorld) + npc.justHit = false; } // Plague debuff on kill effect - if (pFlames > 0 && npc.life <= 0 && npc.realLife == -1) + if (plague && npc.life <= 0 && npc.realLife == -1) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -6790,22 +4088,57 @@ namespace CalamityMod.NPCs { NPC target = Main.npc[i]; - if (target != null && target.IsAnEnemy(true, true) && !target.buffImmune[BuffType()] && Vector2.Distance(target.Center, npc.Center) < 400) + if (target != null && target.IsAnEnemy() && !target.buffImmune[BuffType()] && Vector2.Distance(target.Center, npc.Center) < 400) { - if (target.HasBuff() || target.life <= 0) + if (!target.HasBuff() && target.life > 0) { - target.AddBuff(BuffType(), 300); - } - else - { - target.AddBuff(BuffType(), 300); - DirectionalPulseRing pulse = new DirectionalPulseRing(target.Center, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f) * 3, 0f, 15); + DirectionalPulseRing pulse = new DirectionalPulseRing(target.Center, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, Vector2.One, 0, Main.rand.NextFloat(0.07f, 0.18f) * 3, 0f, 15); GeneralParticleHandler.SpawnParticle(pulse); } + target.AddBuff(BuffType(), 300); } } } } + + if (scionsCurioEffected && npc.life <= 0 && npc.realLife == -1) + { + for (int g = 0; g < 17; g++) + { + Vector2 dustVel = new Vector2(9).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(0.4f, 0.9f) + Vector2.UnitY * -10; + Dust dust = Dust.NewDustPerfect(npc.Center, DustType(), dustVel, 0, Main.rand.NextBool() ? Color.Green : Color.Chartreuse, Main.rand.NextFloat(1.1f, 1.35f)); + dust.noGravity = false; + dust.fadeIn = Main.rand.NextFloat(0.2f, 2f); + } + Particle blastvfx = new CustomPulse(npc.Center, Vector2.Zero, Color.Chartreuse * 0.9f, "CalamityMod/Particles/ShineExplosion1", Vector2.One, Main.rand.NextFloat(-10, 10), 0.05f, 0.15f, 10, true); + GeneralParticleHandler.SpawnParticle(blastvfx); + SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Volume = 0.5f, Pitch = Main.rand.NextFloat(0.5f, 0.7f), MaxInstances = 6 }, npc.Center); + + int explosionDamage = 12; + float highestDamage = 0; + Player Owner = null; + foreach (Player p in Main.ActivePlayers) + { + float playerRangedDamage = p.GetTotalDamage(DamageClass.Ranged).ApplyTo(explosionDamage); + if (playerRangedDamage > highestDamage && p.Calamity().scionsCurio) + { + highestDamage = playerRangedDamage; + Owner = p; + } + } + + // Create Blast + float blastSize = 115; + float minMultiplier = 0.5f; + int hitsToMinMult = 5; + int debuff = BuffType(); + int debuffTime = 300; + Projectile blast = Projectile.NewProjectileDirect(Owner != null ? Owner.GetSource_FromThis() : npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ProjectileType(), (int)highestDamage, 7, Owner != null ? Owner.whoAmI : -1, blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff; + blast.localAI[1] = debuffTime; + blast.timeLeft = 15; + blast.DamageType = DamageClass.Ranged; + } } #endregion @@ -6871,10 +4204,16 @@ namespace CalamityMod.NPCs maxSpawns = (int)(maxSpawns * 1.5f); } - if (CalamityWorld.death && Main.bloodMoon) + if (CalamityWorld.death && Main.bloodMoon && player.position.Y < Main.worldSurface * 16.0) { spawnRate = (int)(spawnRate * 0.25); - maxSpawns = (int)(maxSpawns * 10f); + maxSpawns = (int)(maxSpawns * 5f); + } + + if (CalamityWorld.death && player.ZoneGraveyard) + { + spawnRate = (int)(spawnRate * 0.6667); + maxSpawns = (int)(maxSpawns * 1.5f); } if (NPC.LunarApocalypseIsUp) @@ -6890,53 +4229,32 @@ namespace CalamityMod.NPCs if (CalamityWorld.revenge) spawnRate = (int)(spawnRate * 0.85); - if (Main.SceneMetrics.WaterCandleCount > 0) - { - spawnRate = (int)(spawnRate * 0.9); - maxSpawns = (int)(maxSpawns * 1.1f); - } - if (player.enemySpawns) - { - spawnRate = (int)(spawnRate * 0.8); - maxSpawns = (int)(maxSpawns * 1.2f); - } if (player.Calamity().chaosCandle) { - spawnRate = (int)(spawnRate * 0.6); - maxSpawns = (int)(maxSpawns * 2.5f); + spawnRate = (int)(spawnRate * 0.5); // 2x spawn rate + maxSpawns = (int)(maxSpawns * 2f); } if (player.Calamity().zerg) { - spawnRate = (int)(spawnRate * 0.2); - maxSpawns = (int)(maxSpawns * 5f); + spawnRate = (int)(spawnRate * 0.25); // 4x spawn rate + maxSpawns = (int)(maxSpawns * 4f); } - - // This is horribly unoptimized, I'm leaving it commented out. - Fab - /*if (NPC.AnyNPCs(NPCType())) + if (player.Calamity().bloodyMary) { - int otherWulfrumEnemies = NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()) + NPC.CountNPCS(NPCType()); - if (otherWulfrumEnemies < 4) - { - spawnRate = (int)(spawnRate * 0.8); - maxSpawns = (int)(maxSpawns * 1.2f); - } - }*/ + spawnRate = (int)(spawnRate * 0.142); // ~7x spawn rate + maxSpawns = (int)(maxSpawns * 5f); // Only 5x the cap, however + } // Reductions - if (Main.SceneMetrics.PeaceCandleCount > 0) - { - spawnRate = (int)(spawnRate * 1.1); - maxSpawns = (int)(maxSpawns * 0.9f); - } if (player.Calamity().tranquilityCandle) { - spawnRate = (int)(spawnRate * 1.4); - maxSpawns = (int)(maxSpawns * 0.4f); + spawnRate = (int)(spawnRate * 1.6666); // 0.6x spawn rate + maxSpawns = (int)(maxSpawns * 0.6f); } if (player.Calamity().zen || (CalamityServerConfig.Instance.ForceTownSafety && player.townNPCs > 1f && Main.expertMode)) { - spawnRate = (int)(spawnRate * 2.5); - maxSpawns = (int)(maxSpawns * 0.3f); + spawnRate = (int)(spawnRate * 2.5); // 0.4x spawn rate + maxSpawns = (int)(maxSpawns * 0.4f); } if (player.Calamity().isNearbyBoss && CalamityServerConfig.Instance.BossZen) { @@ -6958,16 +4276,13 @@ namespace CalamityMod.NPCs #endregion #region Edit Spawn Pool - - internal static readonly FieldInfo MaxSpawnsField = typeof(NPC).GetField("maxSpawns", BindingFlags.NonPublic | BindingFlags.Static); - public static void AttemptToSpawnLabCritters(Player player) { if (Main.netMode == NetmodeID.MultiplayerClient) return; int spawnRate = 400; - int maxSpawnCount = (int)MaxSpawnsField.GetValue(null); + int maxSpawnCount = NPC.maxSpawns; NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount); // Enforce a limit on the amount of enemies that can appear. @@ -7031,6 +4346,54 @@ namespace CalamityMod.NPCs } } + public static void AttemptToSpawnLavaNPCs(Player player) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + // For now, we only need this for the Basalt Gully, but this may be used for the crags in the future + if (!player.Calamity().ZoneBasaltGully) + return; + + int spawnRate = 400; + int maxSpawnCount = NPC.maxSpawns; + NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount); + + // Enforce a limit on the amount of enemies that can appear. + if (player.nearbyActiveNPCs >= maxSpawnCount) + return; + + float playerCenterX = player.Center.X / 16f; + float playerCenterY = player.Center.Y / 16f; + for (int i = 0; i < 8; i++) + { + int checkPositionX = (int)(playerCenterX + Main.rand.Next(30, 54) * Main.rand.NextBool().ToDirectionInt()); + int checkPositionY = (int)(playerCenterY + Main.rand.Next(24, 45) * Main.rand.NextBool().ToDirectionInt()); + Vector2 checkPosition = new Vector2(checkPositionX, checkPositionY); + + Tile aboveSpawnTile = CalamityUtils.ParanoidTileRetrieval(checkPositionX, checkPositionY - 1); + + if (aboveSpawnTile.LiquidAmount < 255 || aboveSpawnTile.LiquidType != LiquidID.Lava || Collision.SolidCollision((checkPosition - new Vector2(2f, 2f)).ToWorldCoordinates(), 4, 4) || player.nearbyActiveNPCs >= maxSpawnCount || !Main.rand.NextBool(spawnRate)) + continue; + + WeightedRandom pool = new WeightedRandom(); + pool.Add(NPCID.None, 1f); + pool.Add(NPCType(), 0.05f); + + int typeToSpawn = pool.Get(); + if (typeToSpawn != NPCID.None) + { + int spawnedNPC = NPCLoader.SpawnNPC(typeToSpawn, checkPositionX, checkPositionY - 1); + if (Main.dedServ && spawnedNPC < Main.maxNPCs) + { + Main.npc[spawnedNPC].position.Y -= 8f; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, spawnedNPC); + return; + } + } + } + } + public override void EditSpawnPool(IDictionary pool, NPCSpawnInfo spawnInfo) { bool calamityBiomeZone = spawnInfo.Player.Calamity().ZoneAbyss || @@ -7039,27 +4402,36 @@ namespace CalamityMod.NPCs spawnInfo.Player.Calamity().ZoneSunkenSea || (spawnInfo.Player.Calamity().ZoneAstral && !spawnInfo.Player.PillarZone()); - // Fuck the Goblin and the Wizard + // Increase Goblin and Wizard spawn rates if (!spawnInfo.Water && spawnInfo.Player.ZoneRockLayerHeight) { if (NPC.downedGoblins && !NPC.savedGoblin) { if (!NPC.AnyNPCs(NPCID.BoundGoblin)) - pool[NPCID.BoundGoblin] = SpawnCondition.BoundCaveNPC.Chance * 5f; + pool[NPCID.BoundGoblin] = SpawnCondition.BoundCaveNPC.Chance * 2f; } if (Main.hardMode && !NPC.savedWizard) { if (!NPC.AnyNPCs(NPCID.BoundWizard)) - pool[NPCID.BoundWizard] = SpawnCondition.BoundCaveNPC.Chance * 5f; + pool[NPCID.BoundWizard] = SpawnCondition.BoundCaveNPC.Chance * 2f; } } - // Replace vanilla Lava Slimes with Calamity Lava Slimes to avoid annoying lava drops - if (spawnInfo.Player.ZoneUnderworldHeight && !calamityBiomeZone && CalamityServerConfig.Instance.RemoveLavaDropsFromLavaSlimes && Main.expertMode) + // Overrides the vanilla spawn of Chaos Elementals so they can be AFK farmed once more + if (Main.hardMode && spawnInfo.Player.ZoneRockLayerHeight && !calamityBiomeZone) { - pool.Add(NPCType(), SpawnCondition.Underworld.Chance); - pool.Remove(NPCID.LavaSlime); + // Added more tiles for them to spawn on + bool isChaosElementalSpawnTile = + spawnInfo.SpawnTileType == TileID.Pearlstone || + spawnInfo.SpawnTileType == TileID.Pearlsand || + spawnInfo.SpawnTileType == TileID.HallowedIce || + spawnInfo.SpawnTileType == TileID.HallowedGrass || + spawnInfo.SpawnTileType == TileID.HallowHardenedSand || + spawnInfo.SpawnTileType == TileID.HallowSandstone; + + if (isChaosElementalSpawnTile) + pool[NPCID.ChaosElemental] = SpawnCondition.Cavern.Chance * 0.125f; } // Spawn Green Jellyfish in prehm and Blue Jellyfish in hardmode @@ -7100,18 +4472,21 @@ namespace CalamityMod.NPCs } } - // 12JUL2023: Ozzatron: what does this do - // 27SEP2023: Fabsol: disables vanilla spawns "a pool of [0] indicates vanilla spawning" - if (calamityBiomeZone) + // Increased Maggot Zombie,the Groom, and the Bride spawn rates in a Graveyard + if (spawnInfo.Player.ZoneGraveyard) { - pool[0] = 0f; + pool[NPCID.MaggotZombie] = SpawnCondition.OverworldNightMonster.Chance * 0.2f; + pool[NPCID.TheGroom] = SpawnCondition.OverworldNightMonster.Chance * 0.035f; + pool[NPCID.TheBride] = SpawnCondition.OverworldNightMonster.Chance * 0.035f; } + // Disable vanilla spawns while in the Brimstone Crag + if (calamityBiomeZone) + pool[0] = 0f; + // Add Enchanted Nightcrawlers as a critter to the Astral Infection if (!AnyEvents(spawnInfo.Player) && spawnInfo.Player.InAstral()) - { pool[NPCID.EnchantedNightcrawler] = SpawnCondition.TownCritter.Chance; - } if (spawnInfo.Player.Calamity().ZoneSulphur && !spawnInfo.Player.Calamity().ZoneAbyss && AcidRainEvent.AcidRainEventIsOngoing) { @@ -7180,9 +4555,7 @@ namespace CalamityMod.NPCs } } if (NPC.CountNPCS(NPCType()) >= AcidRainEvent.MaxNuclearToadCount) - { pool.Remove(NPCType()); - } } } @@ -7191,15 +4564,9 @@ namespace CalamityMod.NPCs // Voodoo Demon changes (including partial Voodoo Demon Voodoo Doll implementation) bool voodooDemonDollActive = spawnInfo.Player.Calamity().disableVoodooSpawns; - // If the doll is active, Voodoo Demons cannot spawn (via modded means). if (voodooDemonDollActive) pool.Remove(NPCID.VoodooDemon); - // Otherwise, if it's pre-Hardmode, provide a modded spawn entry that makes them much more common. - else if (!Main.hardMode && spawnInfo.Player.ZoneUnderworldHeight && !calamityBiomeZone) - { - pool[NPCID.VoodooDemon] = SpawnCondition.Underworld.Chance * 0.15f; - } } #endregion @@ -7209,10 +4576,19 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.Deerclops) { DeerclopsAI.hasTargetBeenInRange = false; - DeerclopsAI.borderDelay = 7f * 60f; - DeerclopsAI.borderScalar = 0f; - DeerclopsAI.innerBorder = DeerclopsAI.maxDRIncreaseDistance * 5f; - DeerclopsAI.outerBorder = DeerclopsAI.maxDRIncreaseDistance * 5f; + } + + // Despawn Blazing Wheels and Spike Balls when a boss spawns so they're not annoying and stay in the arena + if (npc.boss) + { + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type == NPCID.BlazingWheel || n.type == NPCID.SpikeBall) + { + n.active = false; + n.netUpdate = true; + } + } } if (npc.type != NPCID.VoodooDemon) @@ -7246,39 +4622,32 @@ namespace CalamityMod.NPCs #region Drawing public override void FindFrame(NPC npc, int frameHeight) { - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType()) - npc.frameCounter = 0D; - } // Increment the bestiary worm timer when hovering over the NPC or having their entry open. Pauses otherwise if (npc.IsABestiaryIconDummy) { bestiaryWormTimer += 0.02f; // Resets after an hour. No sane human being is looking at a bestiary entry for an hour straight if (bestiaryWormTimer > 4320) - { bestiaryWormTimer = 0; - } } } // Debuff visuals. Alphabetical order as per usual, please + // TODO - Merge these into DebuffData public override void DrawEffects(NPC npc, ref Color drawColor) { if (!npc.canDisplayBuffs) return; - if (absorberAffliction > 0) + if (absorberAffliction) AbsorberAffliction.DrawEffects(npc, ref drawColor); // Rancor's burn effect if (ashesOnDeath > 0) { if (Main.rand.NextBool(4)) - { Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Main.rand.NextVector2Circular(2.75f, 6.5f), ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0.475f); - } + if (Main.rand.NextBool(6)) { Vector2 randomPosition = new(npc.position.X + Main.rand.NextFloat(-10f, npc.width + 10f), npc.position.Y + Main.rand.NextFloat(-10f, npc.height + 10f)); @@ -7286,148 +4655,176 @@ namespace CalamityMod.NPCs } } - if (astralInfection > 0) + if (astralInfection) AstralInfectionDebuff.DrawEffects(npc, ref drawColor); // Brimstone Flames and Demonshade Enrage set bonus share the same visual effects // TODO -- change this when Demonshade is reworked - if (bFlames > 0 || npc.HasBuff()) + if (brimstoneFlames || npc.HasBuff()) BrimstoneFlames.DrawEffects(npc, ref drawColor); - if (demonicFlames > 0) + if (demonicFlames) DemonicFlames.DrawEffects(npc, ref drawColor); - if (bBlood > 0) + if (burningBlood) BurningBlood.DrawEffects(npc, ref drawColor); - if (brainRot > 0) + if (brainRot) BrainRot.DrawEffects(npc, ref drawColor); - if (cDepth > 0) + if (crushDepth) CrushDepth.DrawEffects(npc, ref drawColor); - if (hPressure > 0) + if (hadopelagicPressure) HadopelagicPressure.DrawEffects(npc, ref drawColor); - if (dragonFire > 0) + if (dragonFire) Dragonfire.DrawEffects(npc, ref drawColor); - if (vermillionFlux > 0) + if (vermillionFlux) VermillionFlux.DrawEffects(npc, ref drawColor); - if (auricRebuke > 0) + if (auricRebuke) AuricRebuke.DrawEffects(npc, ref drawColor); - if (staticDischarge > 0) + if (staticDischarge) StaticDischarge.DrawEffects(npc, ref drawColor); - if (elementalMix > 0) + if (elementalMix) ElementalMix.DrawEffects(npc, ref drawColor); // Eutrophication and Temporal Sadness share the same visual effects - if (eutrophication > 0 || tSad > 0) + if (eutrophication || temporalSadness) Eutrophication.DrawEffects(npc, ref drawColor); - if (gsInferno > 0) + if (fortunesFavor) + FortunesFavor.DrawEffects(npc, ref drawColor); + + if (godSlayerInferno) GodSlayerInferno.DrawEffects(npc, ref drawColor); // Holy Flames and Banishing Fire share the same visual effects - if (hFlames > 0 || banishingFire > 0) + if (holyFlames || banishingFire) HolyFlames.DrawEffects(npc, ref drawColor); - if (heavybleeding > 0) + if (heavyBleeding) HeavyBleeding.DrawEffects(npc, ref drawColor); - if (laceration > 0) - Laceration.DrawEffects(npc, ref drawColor); - - // These draw effects do not include Miracle Blight's shader - if (miracleBlight > 0) - MiracleBlight.DrawEffects(npc, ref drawColor); - - if (nightwither > 0) - Nightwither.DrawEffects(npc, ref drawColor); - - if (pearlAura > 0) - PearlAura.DrawEffects(npc, ref drawColor); - - if (pFlames > 0) // Plague debuff - Plague.DrawEffects(npc, ref drawColor); - - if (relicOfResilienceWeakness > 0) - ProfanedWeakness.DrawEffects(npc, ref drawColor); - - if (rTide > 0) - RiptideDebuff.DrawEffects(npc, ref drawColor); - - if (somaShredStacks > 0 && !Main.dedServ) - Shred.DrawEffects(npc, this, ref drawColor); - - if (sulphurPoison > 0) - SulphuricPoisoning.DrawEffects(npc, ref drawColor); - - if (trueVulnerabilityHex > 0) - TrueVulnerabilityHex.DrawEffects(npc, ref drawColor); - - if (vaporfied > 0) - Vaporfied.DrawEffects(npc, ref drawColor); - - if (veriumDoomTimer > 0) + if (hyperiusFxTimer > 0) { - int sparkleChance = Math.Max(2, 8 - (veriumDoomStacks / 2)); - if (veriumDoomTimer % sparkleChance == 0) + float rate = (Main.GlobalTimeWrappedHourly * 5); + List eColors = + [ + Color.Yellow, + Color.Magenta, + Color.Red, + Color.Cyan, + Color.Lime + ]; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + Texture2D tex2 = Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D sparkle = Request("CalamityMod/Particles/BloomLineSoftEdge").Value; + Vector2 drawPosition = npc.Center - Main.screenPosition; + + float power = (float)(Math.Pow(Utils.GetLerpValue(0, 20, hyperiusFxTimer, true), 3)) * MathHelper.Lerp(Math.Max(npc.height, npc.width) / 100, 1.4f, 0.5f); + for (int i = 0; i < 4; i++) { - float veriumRatio = (float)veriumDoomTimer / (float)veriumDoomTime; - Vector2 randPosition = new Vector2(npc.position.X + Main.rand.Next(0, npc.width), npc.position.Y + Main.rand.Next(0, npc.height)); - Particle markedSparkle = new CustomPulse(randPosition, Vector2.Zero, Color.Lerp(new Color(103, 230, 240), new Color(255, 110, 220), 1 - veriumRatio), "CalamityMod/Particles/Sparkle", Vector2.One, Main.rand.NextFloat(-0.75f, 0.75f), 0.9f, 1.1f, 35); - GeneralParticleHandler.SpawnParticle(markedSparkle); + float iMult = 1 + 0.25f * i; + Main.EntitySpriteDraw(tex2, drawPosition, null, Color.Lerp(usedColor, Color.White, i * 0.1f) with { A = 0 } * 0.6f, Main.rand.NextFloat(-5f, 5f), tex2.Size() * 0.5f, new Vector2(1f, 0.8f) * 0.35f * Main.rand.NextFloat(0.9f, 1.1f) * iMult * power * (Utils.GetLerpValue(0, 20, hyperiusFxTimer)), SpriteEffects.None); + + for (int b = -1; b <= 1; b += 2) + { + float uncappedSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 8f / MathHelper.Pi); + float sine = MathHelper.Lerp(Math.Abs(uncappedSine), 0.75f, 0.75f); + Vector2 scale = new Vector2((0.25f / iMult) + (0.7f * (1 - sine)), 1.1f * sine * iMult) * power * 0.05f; + float rotation = MathHelper.PiOver4 * b * uncappedSine; + Main.EntitySpriteDraw(sparkle, drawPosition, null, Color.Lerp(usedColor, Color.White, i * 0.1f) with { A = 0 }, rotation, sparkle.Size() * 0.5f, scale, SpriteEffects.None); + } } } + if (laceration) + Laceration.DrawEffects(npc, ref drawColor); + if (laserBurnTimer > 0) { int particleChance = Math.Max(3, 10 - (laserBurnStacks / 3)); if (laserBurnTimer % particleChance == 0) { Vector2 randPosition = new Vector2(npc.position.X + Main.rand.Next(0, npc.width), npc.position.Y + Main.rand.Next(0, npc.height)); - Particle markedParticle = new GlowOrbParticle(randPosition, Vector2.Zero, false, Main.rand.Next(7, 9 + 1), Main.rand.NextFloat(0.3f, 0.45f) + (laserBurnStacks * 0.045f), Color.Red); - GeneralParticleHandler.SpawnParticle(markedParticle); + + Dust dust = Dust.NewDustPerfect(randPosition, Effects.ArsenalEffects.ArsenalLaserDust); + dust.velocity = ((Vector2.UnitX * 3 * (laserBurnStacks * 0.03f)).RotatedByRandom(100) * Main.rand.NextFloat(0.85f, 1f)) + npc.velocity * 0.5f; + dust.scale = Main.rand.NextFloat(0.55f, 0.7f) + laserBurnStacks * 0.01f; + dust.noGravity = true; + dust.color = Color.Red; + dust.fadeIn = laserBurnStacks * 0.3f; } + // If for some reason neither burn type is set if (laserBurnType == 0) { - Main.NewText("No Burn Type Set", Color.OrangeRed); laserBurnMarked = false; laserBurnTimer = 0; } } - if (voidfrost > 0) + // These draw effects do not include Miracle Blight's shader + if (miracleBlight) + MiracleBlight.DrawEffects(npc, ref drawColor); + + if (nightwither) + Nightwither.DrawEffects(npc, ref drawColor); + + if (pearlAura) + PearlAura.DrawEffects(npc, ref drawColor); + + if (plague) + Plague.DrawEffects(npc, ref drawColor); + + if (relicOfResilienceWeakness) + ProfanedWeakness.DrawEffects(npc, ref drawColor); + + if (riptide) + RiptideDebuff.DrawEffects(npc, ref drawColor); + + if (somaShredStacks > 0 && !Main.dedServ) + Shred.DrawEffects(npc, this, ref drawColor); + + if (sulphurPoison) + SulphuricPoisoning.DrawEffects(npc, ref drawColor); + + if (trueVulnerabilityHex) + TrueVulnerabilityHex.DrawEffects(npc, ref drawColor); + + if (vaporfied) + Vaporfied.DrawEffects(npc, ref drawColor); + + if (veriumDoomTimer > 0) + { + int sparkleChance = Math.Max(2, 8 - (veriumDoomStacks / 2)); + if (veriumDoomTimer % sparkleChance == 0) + { + float veriumRatio = veriumDoomTimer / (float)veriumDoomTime; + Vector2 randPosition = new Vector2(npc.position.X + Main.rand.Next(0, npc.width), npc.position.Y + Main.rand.Next(0, npc.height)); + Particle markedSparkle = new CustomPulse(randPosition, Vector2.Zero, Color.Lerp(new Color(103, 230, 240), new Color(255, 110, 220), 1 - veriumRatio), "CalamityMod/Particles/Sparkle", Vector2.One, Main.rand.NextFloat(-0.75f, 0.75f), 0.9f, 1.1f, 35); + GeneralParticleHandler.SpawnParticle(markedSparkle); + } + } + + if (voidfrost) Voidfrost.DrawEffects(npc, ref drawColor); // TODO -- These debuff visuals cannot be moved because they correspond to vanilla debuffs - if (electrified > 0) + if (electrified) { if (Main.rand.NextBool()) - { Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Electric, Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f), 0, default, 0.35f); - } } - if (slowed > 0) - { - if (Main.rand.Next(5) < 4) - { - int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, DustID.SpookyWood, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 225, default, 3f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 1.1f; - Main.dust[dust].velocity.Y += 0.25f; - if (Main.rand.NextBool()) - { - Main.dust[dust].noGravity = false; - Main.dust[dust].scale *= 0.5f; - } - } - } - if (webbed > 0) + if (webbed) { if (Main.rand.Next(5) < 4) { @@ -7443,7 +4840,7 @@ namespace CalamityMod.NPCs } } - // Some extraneous and probably undocumented visual effect caused by the heart lad pet thing + // Lad pet spawns hearts from NPCs if (ladHearts > 0 && !npc.loveStruck && !Main.dedServ) { if (Main.rand.NextBool(5)) @@ -7461,35 +4858,35 @@ namespace CalamityMod.NPCs // Calamity debuff coloring effects // These are in order of precedence because they override each other. - if (gState > 0) + if (glacialState) drawColor = Color.Cyan; - else if (auricRebuke > 0) + else if (auricRebuke) { int scaleFactor = (int)(Utils.Remap(npc.width, 30, 400, 5, 15, true)); drawColor = Main.rand.NextBool(scaleFactor) ? Color.Lerp(Color.DarkBlue, Color.White, Utils.Remap(npc.width, 30, 400, 0.4f, 0.7f, true)) : Color.White; } - else if (vermillionFlux > 0) + else if (vermillionFlux) { int scaleFactor = (int)(Utils.Remap(npc.width, 30, 400, 5, 15, true)); drawColor = Main.rand.NextBool(scaleFactor) ? Color.Lerp(Color.DarkRed, Color.White, Utils.Remap(npc.width, 30, 400, 0, 0.7f, true)) : Color.White; } - else if (electrified > 0) + else if (electrified) { int scaleFactor = (int)(Utils.Remap(npc.width, 30, 400, 5, 15, true)); drawColor = Main.rand.NextBool(scaleFactor) ? Color.Lerp(Color.SlateGray, Color.White, Utils.Remap(npc.width, 30, 400, 0, 0.7f, true)) : Color.White; } - else if (absorberAffliction > 0) + else if (absorberAffliction) drawColor = Color.DarkSeaGreen; - else if (marked > 0 || vaporfied > 0) + else if (markedForDeath || vaporfied) drawColor = Color.Fuchsia; - else if (pearlAura > 0) + else if (pearlAura) drawColor = new Color(185, 185, 255); - else if (timeSlow > 0 || tesla > 0) + else if (timeDistortion || galvanicCorrosion) drawColor = Color.Aquamarine; } @@ -7499,12 +4896,9 @@ namespace CalamityMod.NPCs if (npc.IsABestiaryIconDummy) return null; - if (Main.LocalPlayer.Calamity().trippy || (npc.type == NPCID.KingSlime && CalamityWorld.LegendaryMode && CalamityWorld.revenge)) + if (Main.LocalPlayer.Calamity().trippy || (npc.type == NPCID.KingSlime && Main.zenithWorld)) return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); - if (npc.type == NPCID.KingSlime && CalamityWorld.death) - return NPC.AnyNPCs(NPCType()) ? Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f) : null; - if (npc.type == NPCID.QueenBee && Main.zenithWorld) { if (npc.life / (float)npc.lifeMax < 0.5f) @@ -7516,9 +4910,6 @@ namespace CalamityMod.NPCs if (npc.HasBuff()) return new Color(200, 50, 50, 255 - npc.alpha); - if (npc.Calamity().kamiFlu > 0 && !KamiDebuffColorImmuneList.Includes(npc.type)) - return new Color(51, 197, 108, 255 - npc.alpha); - if (npc.type == NPCID.VileSpit || npc.type == NPCID.VileSpitEaterOfWorlds) return new Color(150, 200, 0, npc.alpha); @@ -7528,62 +4919,63 @@ namespace CalamityMod.NPCs return null; } + //TODO - Make this a part of DebuffData public static List<(string, Predicate)> moddedDebuffTextureList = new List<(string, Predicate)> { // All Calamity DoTs in alphabetical order - ("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff", NPC => NPC.Calamity().astralInfection > 0), - ("CalamityMod/Buffs/DamageOverTime/AuricRebuke", NPC => NPC.Calamity().auricRebuke > 0), - ("CalamityMod/Buffs/DamageOverTime/BanishingFire", NPC => NPC.Calamity().banishingFire > 0), - ("CalamityMod/Buffs/DamageOverTime/BrainRot", NPC => NPC.Calamity().brainRot > 0), - ("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames", NPC => NPC.Calamity().bFlames > 0), - ("CalamityMod/Buffs/DamageOverTime/DemonicFlames", NPC => NPC.Calamity().demonicFlames > 0), - ("CalamityMod/Buffs/DamageOverTime/BurningBlood", NPC => NPC.Calamity().bBlood > 0), - ("CalamityMod/Buffs/DamageOverTime/CrushDepth", NPC => NPC.Calamity().cDepth > 0), - ("CalamityMod/Buffs/DamageOverTime/Dragonfire", NPC => NPC.Calamity().dragonFire > 0), - ("CalamityMod/Buffs/DamageOverTime/ElementalMix", NPC => NPC.Calamity().elementalMix > 0), - ("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno", NPC => NPC.Calamity().gsInferno > 0), - ("CalamityMod/Buffs/DamageOverTime/HadopelagicPressure", NPC => NPC.Calamity().hPressure > 0), - ("CalamityMod/Buffs/DamageOverTime/HolyFlames", NPC => NPC.Calamity().hFlames > 0), - ("CalamityMod/Buffs/DamageOverTime/Laceration", NPC => NPC.Calamity().laceration > 0), - ("CalamityMod/Buffs/DamageOverTime/HeavyBleeding", NPC => NPC.Calamity().heavybleeding > 0), - ("CalamityMod/Buffs/DamageOverTime/MiracleBlight", NPC => NPC.Calamity().miracleBlight > 0), - ("CalamityMod/Buffs/DamageOverTime/Nightwither", NPC => NPC.Calamity().nightwither > 0), - ("CalamityMod/Buffs/DamageOverTime/Plague", NPC => NPC.Calamity().pFlames > 0), - ("CalamityMod/Buffs/DamageOverTime/RiptideDebuff", NPC => NPC.Calamity().rTide > 0), - ("CalamityMod/Buffs/DamageOverTime/SagePoison", NPC => NPC.Calamity().sagePoisonTime > 0), - ("CalamityMod/Buffs/DamageOverTime/ShellfishClaps", NPC => NPC.Calamity().shellfishVore > 0), + ("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff", NPC => NPC.Calamity().astralInfection), + ("CalamityMod/Buffs/DamageOverTime/AuricRebuke", NPC => NPC.Calamity().auricRebuke), + ("CalamityMod/Buffs/DamageOverTime/BanishingFire", NPC => NPC.Calamity().banishingFire), + ("CalamityMod/Buffs/DamageOverTime/BrainRot", NPC => NPC.Calamity().brainRot), + ("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames", NPC => NPC.Calamity().brimstoneFlames), + ("CalamityMod/Buffs/DamageOverTime/DemonicFlames", NPC => NPC.Calamity().demonicFlames), + ("CalamityMod/Buffs/DamageOverTime/BurningBlood", NPC => NPC.Calamity().burningBlood), + ("CalamityMod/Buffs/DamageOverTime/CrushDepth", NPC => NPC.Calamity().crushDepth), + ("CalamityMod/Buffs/DamageOverTime/Dragonfire", NPC => NPC.Calamity().dragonFire), + ("CalamityMod/Buffs/DamageOverTime/ElementalMix", NPC => NPC.Calamity().elementalMix), + ("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno", NPC => NPC.Calamity().godSlayerInferno), + ("CalamityMod/Buffs/DamageOverTime/HadopelagicPressure", NPC => NPC.Calamity().hadopelagicPressure), + ("CalamityMod/Buffs/DamageOverTime/HolyFlames", NPC => NPC.Calamity().holyFlames), + ("CalamityMod/Buffs/DamageOverTime/Laceration", NPC => NPC.Calamity().laceration), + ("CalamityMod/Buffs/DamageOverTime/HeavyBleeding", NPC => NPC.Calamity().heavyBleeding), + ("CalamityMod/Buffs/DamageOverTime/ManaBurn", NPC => NPC.Calamity().manaBurn > 0), + ("CalamityMod/Buffs/DamageOverTime/MiracleBlight", NPC => NPC.Calamity().miracleBlight), + ("CalamityMod/Buffs/DamageOverTime/Nightwither", NPC => NPC.Calamity().nightwither), + ("CalamityMod/Buffs/DamageOverTime/Plague", NPC => NPC.Calamity().plague), + ("CalamityMod/Buffs/DamageOverTime/RiptideDebuff", NPC => NPC.Calamity().riptide), + ("CalamityMod/Buffs/DamageOverTime/SagePoison", NPC => NPC.Calamity().sagePoison), + ("CalamityMod/Buffs/DamageOverTime/SearingLava", NPC => NPC.HasBuff()), + ("CalamityMod/Buffs/DamageOverTime/ShellfishClaps", NPC => NPC.Calamity().shellfishStaffDebuff), ("CalamityMod/Buffs/DamageOverTime/Shred", NPC => NPC.Calamity().somaShredStacks > 0), - ("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff", NPC => NPC.Calamity().clamDebuff > 0), - ("CalamityMod/Buffs/DamageOverTime/StaticDischarge", NPC => NPC.Calamity().staticDischarge > 0), - ("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning", NPC => NPC.Calamity().sulphurPoison > 0), - ("CalamityMod/Buffs/DamageOverTime/TrueVulnerabilityHex", NPC => NPC.Calamity().trueVulnerabilityHex > 0), - ("CalamityMod/Buffs/DamageOverTime/Vaporfied", NPC => NPC.Calamity().vaporfied > 0), - ("CalamityMod/Buffs/DamageOverTime/VermillionFlux", NPC => NPC.Calamity().vermillionFlux > 0), - ("CalamityMod/Buffs/DamageOverTime/Voidfrost", NPC => NPC.Calamity().voidfrost > 0), - ("CalamityMod/Buffs/DamageOverTime/VulnerabilityHex", NPC => NPC.Calamity().vulnerabilityHex > 0), + ("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff", NPC => NPC.Calamity().snapClamDebuff), + ("CalamityMod/Buffs/DamageOverTime/StaticDischarge", NPC => NPC.Calamity().staticDischarge), + ("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning", NPC => NPC.Calamity().sulphurPoison), + ("CalamityMod/Buffs/DamageOverTime/TrueVulnerabilityHex", NPC => NPC.Calamity().trueVulnerabilityHex), + ("CalamityMod/Buffs/DamageOverTime/Vaporfied", NPC => NPC.Calamity().vaporfied), + ("CalamityMod/Buffs/DamageOverTime/VermillionFlux", NPC => NPC.Calamity().vermillionFlux), + ("CalamityMod/Buffs/DamageOverTime/Voidfrost", NPC => NPC.Calamity().voidfrost), + ("CalamityMod/Buffs/DamageOverTime/VulnerabilityHex", NPC => NPC.Calamity().vulnerabilityHex), // All other important Calamity debuffs, in alphabetical order - ("CalamityMod/Buffs/StatDebuffs/AbsorberAffliction", NPC => NPC.Calamity().absorberAffliction > 0), - ("CalamityMod/Buffs/StatDebuffs/ArmorCrunch", NPC => NPC.Calamity().aCrunch > 0), - ("CalamityMod/Buffs/StatDebuffs/Crumbling", NPC => NPC.Calamity().crumble > 0), - ("CalamityMod/Buffs/StatDebuffs/Eutrophication", NPC => NPC.Calamity().eutrophication > 0), - ("CalamityMod/Buffs/StatDebuffs/GalvanicCorrosion", NPC => NPC.Calamity().tesla > 0), - ("CalamityMod/Buffs/StatDebuffs/GlacialState", NPC => NPC.Calamity().gState > 0), - ("CalamityMod/Buffs/StatDebuffs/Irradiated", NPC => NPC.Calamity().irradiated > 0), - ("CalamityMod/Buffs/StatDebuffs/KamiFlu", NPC => NPC.Calamity().kamiFlu > 0), - ("CalamityMod/Buffs/StatDebuffs/MarkedforDeath", NPC => NPC.Calamity().marked > 0), - ("CalamityMod/Buffs/StatDebuffs/PearlAura", NPC => NPC.Calamity().pearlAura > 0), - ("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness", NPC => NPC.Calamity().relicOfResilienceWeakness > 0), - ("CalamityMod/Buffs/StatDebuffs/TemporalSadness", NPC => NPC.Calamity().tSad > 0), - ("CalamityMod/Buffs/StatDebuffs/TimeDistortion", NPC => NPC.Calamity().timeSlow > 0), - ("CalamityMod/Buffs/StatDebuffs/WhisperingDeath", NPC => NPC.Calamity().wDeath > 0), - ("CalamityMod/Buffs/StatDebuffs/WitherDebuff", NPC => NPC.Calamity().wither > 0), + ("CalamityMod/Buffs/StatDebuffs/AbsorberAffliction", NPC => NPC.Calamity().absorberAffliction), + ("CalamityMod/Buffs/StatDebuffs/ArmorCrunch", NPC => NPC.Calamity().armorCrunch), + ("CalamityMod/Buffs/StatDebuffs/Crumbling", NPC => NPC.Calamity().crumble), + ("CalamityMod/Buffs/StatDebuffs/Eutrophication", NPC => NPC.Calamity().eutrophication), + ("CalamityMod/Buffs/StatDebuffs/GalvanicCorrosion", NPC => NPC.Calamity().galvanicCorrosion), + ("CalamityMod/Buffs/StatDebuffs/GlacialState", NPC => NPC.Calamity().glacialState), + ("CalamityMod/Buffs/StatDebuffs/Irradiated", NPC => NPC.Calamity().irradiated), + ("CalamityMod/Buffs/StatDebuffs/MarkedforDeath", NPC => NPC.Calamity().markedForDeath), + ("CalamityMod/Buffs/StatDebuffs/PearlAura", NPC => NPC.Calamity().pearlAura), + ("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness", NPC => NPC.Calamity().relicOfResilienceWeakness), + ("CalamityMod/Buffs/StatDebuffs/TemporalSadness", NPC => NPC.Calamity().temporalSadness), + ("CalamityMod/Buffs/StatDebuffs/TimeDistortion", NPC => NPC.Calamity().timeDistortion), + ("CalamityMod/Buffs/StatDebuffs/WhisperingDeath", NPC => NPC.Calamity().whisperingDeath), + ("CalamityMod/Buffs/StatDebuffs/WitherDebuff", NPC => NPC.Calamity().wither), }; public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - // This is used so that NPCs with specific PreDraws can still have Odd Mushroom clone drawing. - // If Odd Mushroom clone drawing is done manually due to using a different texture, just return false instead of setting this. + // This is used so that NPCs with specific PreDraws can still draw everything in this hook. bool shouldDrawBool = true; if (npc.IsABestiaryIconDummy) @@ -7610,20 +5002,17 @@ namespace CalamityMod.NPCs } if (npc.type != NPCID.BrainofCthulhu && (npc.type != NPCID.DukeFishron || npc.ai[0] <= 9f) && npc.active) { - if (CalamityClientConfig.Instance.DebuffDisplay && (npc.boss || BossHealthBarManager.MinibossHPBarList.Contains(npc.type) || BossHealthBarManager.OneToMany.ContainsKey(npc.type) || NeedsDebuffIconDisplayList.Includes(npc.type))) + if (CalamityClientConfig.Instance.DebuffDisplay && (npc.boss || BossHealthBarManager.MinibossHPBarList.Contains(npc.type) || BossHealthBarManager.OneToMany.ContainsKey(npc.type) || CalamityNPCSets.ForceDrawDebuffDisplay[npc.type])) { List currentDebuffs = new List() { }; for (int b = 0; b < moddedDebuffTextureList.Count(); b++) { if (moddedDebuffTextureList[b].Item2.Invoke(npc)) - { currentDebuffs.Add(Request(moddedDebuffTextureList[b].Item1).Value); - } } - // Vanilla damage over time debuffs - if (electrified > 0) + if (electrified) currentDebuffs.Add(TextureAssets.Buff[BuffID.Electrified].Value); if (npc.onFire) currentDebuffs.Add(TextureAssets.Buff[BuffID.OnFire].Value); @@ -7663,9 +5052,7 @@ namespace CalamityMod.NPCs currentDebuffs.Add(TextureAssets.Buff[BuffID.Confused].Value); if (npc.ichor) currentDebuffs.Add(TextureAssets.Buff[BuffID.Ichor].Value); - if (slowed > 0) - currentDebuffs.Add(TextureAssets.Buff[BuffID.Slow].Value); - if (webbed > 0) + if (webbed) currentDebuffs.Add(TextureAssets.Buff[BuffID.Webbed].Value); if (npc.midas) currentDebuffs.Add(TextureAssets.Buff[BuffID.Midas].Value); @@ -7681,27 +5068,20 @@ namespace CalamityMod.NPCs currentDebuffs.Add(TextureAssets.Buff[BuffID.Slimed].Value); if (npc.drippingSparkleSlime) currentDebuffs.Add(TextureAssets.Buff[BuffID.GelBalloonBuff].Value); - if (npc.markedByScytheWhip) // Dark Harvest whip, the only Whip debuff that has an NPC bool - currentDebuffs.Add(TextureAssets.Buff[BuffID.ScytheWhipEnemyDebuff].Value); // Total amount of elements in the buff list - int buffTextureListLength = currentDebuffs.Count(); - + int buffTextureListLength = currentDebuffs.Count; // Total length of a single row in the buff display int totalLength = buffTextureListLength * 14; - // Max amount of buffs per row int buffDisplayRowLimit = 5; - // The maximum length of a single row in the buff display // Limited to 80 units, because every buff drawn here is half the size of a normal buff, 16 x 16, 16 * 5 = 80 units float drawPosX = totalLength >= 80f ? 40f : (float)(totalLength / 2); - // The height of a single frame of the npc - float npcHeight = (float)(TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type] / 2) * npc.scale; - + float npcHeight = (npc.height * npc.scale) / 2; // Offset the debuff display based on the npc's graphical offset, and 16 units, to create some space between the sprite and the display - float drawPosY = npcHeight + npc.gfxOffY + 16f; + float drawPosY = npcHeight + npc.gfxOffY + 32f; // Iterate through the buff texture list for (int i = 0; i < currentDebuffs.Count; i++) @@ -7726,180 +5106,39 @@ namespace CalamityMod.NPCs if (currentDebuffs[i] == TextureAssets.Buff[BuffType()].Value) ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, somaShredStacks.ToString(), npc.Center - screenPos - new Vector2(drawPosX, drawPosY + additionalYOffset) + Vector2.One * 4f, Color.Gold, 0f, Vector2.Zero, Vector2.One * Main.UIScale * 0.8f); } - } - } - TownNPCAlertSystem(npc, Mod, spriteBatch); - - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) - { - if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType() || DestroyerIDList.Includes(npc.type)) - shouldDrawBool = false; - } - - if (npc.type == NPCID.Corruptor || npc.type == NPCID.BloodSquid || npc.type == NPCID.Probe || (npc.type == NPCID.HornetHoney && npc.ai[3] == 1f)) - { - Texture2D texture = TextureAssets.Npc[npc.type].Value; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Main.spriteBatch.Draw(texture, npc.Center - screenPos + new Vector2(0f, npc.gfxOffY), npc.frame, npc.GetAlpha(drawColor), npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f); - - shouldDrawBool = false; - } - - if (npc.type == NPCID.GolemHeadFree) - { - // Draw the head as usual. - Texture2D golemHeadTexture = TextureAssets.Npc[npc.type].Value; - Vector2 headDrawPosition = npc.Center - screenPos; - spriteBatch.Draw(golemHeadTexture, headDrawPosition, npc.frame, npc.GetAlpha(drawColor), 0f, npc.frame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - - // Draw the eyes. The way vanilla handles this is hardcoded bullshit that cannot handle different hitboxes and thus requires rewriting. - Color eyeColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, 0); - Vector2 eyesDrawPosition = headDrawPosition - npc.scale * new Vector2(1f, 12f); - Rectangle eyesFrame = new Rectangle(0, 0, TextureAssets.Golem[1].Value.Width, TextureAssets.Golem[1].Value.Height / 2); - spriteBatch.Draw(TextureAssets.Golem[1].Value, eyesDrawPosition, eyesFrame, eyeColor, 0f, eyesFrame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - - // Draw the glowmasks. - int frameCounter = (int)npc.frameCounter / 4; - Rectangle frame = TextureAssets.Extra[106].Value.Frame(1, 8); - frame.Y += frame.Height * 2 * frameCounter + npc.frame.Y; - Rectangle glowFrame = frame; - spriteBatch.Draw(TextureAssets.Extra[106].Value, eyesDrawPosition, glowFrame, eyeColor, 0f, glowFrame.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - frame = npc.frame; - Rectangle glowFrame2 = frame; - spriteBatch.Draw(TextureAssets.Extra[107].Value, eyesDrawPosition, glowFrame2, eyeColor, 0f, glowFrame2.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); - shouldDrawBool = false; - } - - if (Main.LocalPlayer.Calamity().trippy && !npc.IsABestiaryIconDummy) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Color rainbow = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); - Color alphaColor = npc.GetAlpha(rainbow); - float RGBMult = 0.99f; - alphaColor.R = (byte)(alphaColor.R * RGBMult); - alphaColor.G = (byte)(alphaColor.G * RGBMult); - alphaColor.B = (byte)(alphaColor.B * RGBMult); - alphaColor.A = (byte)(alphaColor.A * RGBMult); - int totalAfterimages = Main.LocalPlayer.Calamity().trippyLevel == 3 ? 16 : (Main.LocalPlayer.Calamity().trippyLevel == 2 ? 12 : 4); - for (int i = 0; i < totalAfterimages; i++) - { - Vector2 position = npc.position; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - - float smallDistanceMult = 0.48f; - float largeDistanceMult = 1.33f; - bool whatTheFuck = Main.LocalPlayer.Calamity().trippyLevel == 3; - - switch (i) + // Draw summon tag display. TODO: make it use custom textures provided by SummonTag. + int yOffset = 0; + for (int i = NPC.maxBuffs - 1; i >= 0; i--) { - case 0: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; + if (npc.buffTime[i] > 0) + { + if (CalamityBuffSets.SummonTagDebuff.TryGetValue(npc.buffType[i], out SummonTag tag)) + { + // Fetch the item and its frames + var tex = TextureAssets.Item[tag.TagItem].Value; + Rectangle frame = (Main.itemAnimations[tag.TagItem] == null) ? tex.Frame() : Main.itemAnimations[tag.TagItem].GetFrame(tex); + if (tag.TagTexture != null) + { + tex = tag.TagTexture.Value; + frame = tex.Frame(); + } - case 1: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; - - case 2: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - case 3: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - case 4: // 1 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 1f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 0f : largeDistanceMult)); - break; - - case 5: // 4 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 0f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 1f : smallDistanceMult)); - break; - - case 6: // 7 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 1f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 0f : largeDistanceMult)); - break; - - case 7: // 10 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 0f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 1f : smallDistanceMult)); - break; - - case 8: // 11 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 0f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 0.5f : largeDistanceMult)); - break; - - case 9: // 2 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 0.5f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 0f : smallDistanceMult)); - break; - - case 10: // 5 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 0f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 0.5f : largeDistanceMult)); - break; - - case 11: // 8 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 0.5f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 0f : smallDistanceMult)); - break; - - case 12: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY * 0.5f; - break; - - case 13: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY * 0.5f; - break; - - case 14: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY * 0.5f; - break; - - case 15: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY * 0.5f; - break; - - - default: - break; + // Draw it accordingly + // This is drawn below the NPC as opposed to above to differentiate from regular debuffs + Vector2 drawPos = npc.Center - screenPos + Vector2.UnitY * (drawPosY + frame.Height * 0.5f + yOffset); + spriteBatch.Draw(tex, drawPos, frame, Color.White, 0f, frame.Size() * 0.5f, 0.75f, SpriteEffects.None, 0f); + yOffset += frame.Height + 4; + } + } } - - position.X -= npc.width / 2; - position.Y -= npc.height / 2; - - Vector2 halfSize = npc.frame.Size() / 2; - - 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 + + // VHex, Mana Burn and Miracle Blight visuals do not appear if Odd Mushroom is in use for sanity reasons + if (!Main.LocalPlayer.Calamity().trippy) { - // VHex and Miracle Blight visuals do not appear if Odd Mushroom is in use for sanity reasons - if (npc.Calamity().vulnerabilityHex > 0 || npc.Calamity().trueVulnerabilityHex > 0) + if (npc.Calamity().vulnerabilityHex || npc.Calamity().trueVulnerabilityHex) { float compactness = npc.width * 0.6f; if (compactness < 10f) @@ -7908,16 +5147,30 @@ namespace CalamityMod.NPCs if (power > 2.75f) power = 2.75f; if (VulnerabilityHexFireDrawer is null || VulnerabilityHexFireDrawer.LocalTimer >= VulnerabilityHexFireDrawer.SetLifetime) - VulnerabilityHexFireDrawer = new FireParticleSet(npc.Calamity().trueVulnerabilityHex > 0 ? npc.Calamity().trueVulnerabilityHex : npc.Calamity().vulnerabilityHex, 1, Color.Red * 1.25f, Color.Red, compactness, power); + VulnerabilityHexFireDrawer = new FireParticleSet(npc.Calamity().trueVulnerabilityHex ? npc.buffTime[npc.FindBuffIndex(BuffType())] : npc.buffTime[npc.FindBuffIndex(BuffType())], 1, Color.Red * 1.25f, Color.Red, compactness, power); else VulnerabilityHexFireDrawer.DrawSet(npc.Bottom - Vector2.UnitY * (12f - npc.gfxOffY)); } else VulnerabilityHexFireDrawer = null; - // Only draw the NPC if told to by the miracle blight drawer. - if (MiracleBlightRenderer.ValidToDraw(npc)) - return MiracleBlightRenderer.ActuallyDoPreDraw; + // Mana Burn effect is just vhex but blue + if (npc.Calamity().manaBurn > 0) + { + float compactness = npc.width * 0.6f; + if (compactness < 10f) + compactness = 10f; + float power = npc.height / 100f; + if (power > 2.75f) + power = 2.75f; + var color = Color.Blue; + if (ManaBurnFireDrawer is null || ManaBurnFireDrawer.LocalTimer >= ManaBurnFireDrawer.SetLifetime) + ManaBurnFireDrawer = new FireParticleSet(60, 1, color * 1.25f, color, compactness, power); + else + ManaBurnFireDrawer.DrawSet(npc.Bottom - Vector2.UnitY * (12f - npc.gfxOffY)); + } + else + ManaBurnFireDrawer = null; } if (Main.zenithWorld) @@ -7934,745 +5187,6 @@ namespace CalamityMod.NPCs return shouldDrawBool; } - public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - // Energy shield - if (npc.type == NPCID.CultistBoss || npc.type == NPCID.CultistBossClone) - { - spriteBatch.EnterShaderRegion(); - - float intensity = newAI[1] / 35f; - - float lifeRatio = npc.type == NPCID.CultistBoss ? (npc.life / (float)npc.lifeMax) : (Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax); - - float flickerPower = 0f; - if (lifeRatio < 0.85f) - flickerPower += 0.1f; - if (lifeRatio < 0.7f) - flickerPower += 0.1f; - if (lifeRatio < 0.55f) - flickerPower += 0.1f; - if (lifeRatio < 0.4f) - flickerPower += 0.1f; - if (lifeRatio < 0.25f) - flickerPower += 0.1f; - if (lifeRatio < 0.1f) - flickerPower += 0.1f; - - float opacity = 1f; - opacity *= MathHelper.Lerp(MathHelper.Max(1f - flickerPower, 0.56f), 1f, (float)Math.Pow(Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.Lerp(3f, 5f, flickerPower)) * 0.5 + 0.5, 24D)); - - // Dampen the opacity and intensity slightly, to allow Cultist to be more easily visible inside of the forcefield. - // Dampen the opacity and intensity a bit more for the Clones. - float intensityAndOpacityMult = npc.type == NPCID.CultistBossClone ? 0.9f : 1f; - intensity *= intensityAndOpacityMult; - opacity *= intensityAndOpacityMult; - - Texture2D forcefieldTexture = SupremeCalamitas.SupremeCalamitas.ForcefieldTexture.Value; - - if (npc.type == NPCID.CultistBoss) - GameShaders.Misc["CalamityMod:SupremeShield"].SetShaderTexture(Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); - else - GameShaders.Misc["CalamityMod:SupremeShield"].UseImage1("Images/Misc/noise"); - - float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); - Color forcefieldColor = Color.Lerp(Color.MediumSpringGreen, Color.Black, colorTransitionAmt); - Color secondaryForcefieldColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); - - forcefieldColor *= opacity; - secondaryForcefieldColor *= opacity; - - GameShaders.Misc["CalamityMod:SupremeShield"].UseSecondaryColor(secondaryForcefieldColor); - GameShaders.Misc["CalamityMod:SupremeShield"].UseColor(forcefieldColor); - GameShaders.Misc["CalamityMod:SupremeShield"].UseSaturation(1); - GameShaders.Misc["CalamityMod:SupremeShield"].UseOpacity(0.65f); - GameShaders.Misc["CalamityMod:SupremeShield"].Apply(); - - // Actual Cultist has a bigger shield than the Clones. - float shieldScale = npc.type == NPCID.CultistBossClone ? 1.65f : MathHelper.Lerp(1.65f, 3f, (float)Math.Pow((double)lifeRatio, 2D)); - spriteBatch.Draw(forcefieldTexture, npc.Center - Main.screenPosition, null, Color.White * opacity, 0f, forcefieldTexture.Size() * 0.5f, shieldScale, SpriteEffects.None, 0f); - - spriteBatch.ExitShaderRegion(); - } - - // Destroyer drawing and laser telegraphs - else if (DestroyerIDList.Includes(npc.type) && !npc.IsABestiaryIconDummy) - { - Texture2D npcTexture = TextureAssets.Npc[npc.type].Value; - int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type]; - - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Color segmentDrawColor = npc.GetAlpha(drawColor); - - // Check if Destroyer is behind tiles and, if so, how much of the segment is behind tiles and adjust color accordingly - int x = (int)((npc.position.X - 8f) / 16f); - int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); - int y = (int)((npc.position.Y - 8f) / 16f); - int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); - for (int l = x; l <= x2; l++) - { - for (int m = y; m <= y2; m++) - { - if (Lighting.Brightness(l, m) == 0f) - segmentDrawColor = Color.Black; - } - } - - // Draw segments - spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), - npc.frame, segmentDrawColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - - // Draw lights - if (npc.ai[2] == 0f && segmentDrawColor != Color.Black) - { - // This life ratio is fine now because all Destroyer segments update to have the same amount of life every frame - float destroyerLifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase4 = destroyerLifeRatio < (death ? 0.4f : 0.25f); - bool phase5 = destroyerLifeRatio < (death ? 0.2f : 0.1f); - - // Spawn DR check - bool hasSpawnDR = newAI[1] < DestroyerAI.DRIncreaseTime && newAI[1] > 60f; - - // Gradual color transition from ground to flight and vice versa - // 0f = Red, 1f = Purple - float phaseTransitionColorAmount = (hasSpawnDR || phase5) ? 1f : 0f; - if (!hasSpawnDR && !phase5) - { - if (newAI[3] >= DestroyerAI.GroundTelegraphStartGateValue) - phaseTransitionColorAmount = MathHelper.Clamp(1f - (newAI[3] - DestroyerAI.GroundTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); - else if (newAI[3] >= DestroyerAI.FlightTelegraphStartGateValue) - phaseTransitionColorAmount = MathHelper.Clamp((newAI[3] - DestroyerAI.FlightTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); - } - - // Light colors - int alpha = 192; - Color groundColor = new Color(150, 0, 0, alpha); - Color flightColor = revenge ? new Color(0, 0, 150, alpha) : groundColor; - Color segmentColor = Color.Lerp(groundColor, flightColor, phaseTransitionColorAmount); - Color telegraphColor_Red = new Color(255, 125, 125, alpha); - Color telegraphColor_Green = new Color(125, 255, 125, alpha); - Color telegraphColor_Cyan = new Color(0, 255, 255, alpha); - Color telegraphColor = telegraphColor_Red; - - // Telegraph for the laser breath and body lasers - float telegraphProgress = 0f; - if (destroyerLaserColor != -1) - { - if (npc.type == NPCID.TheDestroyer && death) - { - float telegraphGateValue = DestroyerAI.DeathModeLaserBreathGateValue - DestroyerAI.LaserTelegraphTime; - if (newAI[0] > telegraphGateValue) - { - switch (destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - telegraphColor = telegraphColor_Green; - break; - - case 2: - telegraphColor = telegraphColor_Cyan; - break; - } - telegraphProgress = MathHelper.Clamp((newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f); - } - } - else if (npc.type == NPCID.TheDestroyerBody && revenge) - { - 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 telegraphGateValue = shootProjectileGateValue - DestroyerAI.LaserTelegraphTime; - if (newAI[0] > telegraphGateValue) - { - switch (destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - telegraphColor = telegraphColor_Green; - break; - - case 2: - telegraphColor = telegraphColor_Cyan; - break; - } - telegraphProgress = MathHelper.Clamp((newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f); - } - } - else if (npc.type == NPCID.TheDestroyerBody) - { - float shootProjectileTime = Main.masterMode ? 500f : Main.expertMode ? 700f : 900f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float telegraphGateValue = shootProjectileGateValue - DestroyerAI.LaserTelegraphTime; - if (npc.localAI[0] > telegraphGateValue) - telegraphProgress = MathHelper.Clamp((npc.localAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f); - } - } - - Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerHeadGlowmask.Value : TextureAssets.Dest[0].Value; - switch (npc.type) - { - default: - case NPCID.TheDestroyer: - break; - - case NPCID.TheDestroyerBody: - glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerBodyGlowmask.Value : TextureAssets.Dest[1].Value; - break; - - case NPCID.TheDestroyerTail: - glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerTailGlowmask.Value : TextureAssets.Dest[2].Value; - break; - } - - float alphaMultiplier = 1f - npc.alpha / 255f; - spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, Color.Lerp(segmentColor, telegraphColor, telegraphProgress) * alphaMultiplier, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - - // Laser telegraph - else if (npc.type == NPCID.Probe && CalamityClientConfig.Instance.EnableVanillaTextureEdits) - { - float eyeTelegraphGateValue = (NPC.IsMechQueenUp ? DestroyerAI.ProbeLaserGateValue_Mechdusa : BossRushEvent.BossRushActive ? DestroyerAI.ProbeLaserGateValue_BossRush : revenge ? DestroyerAI.ProbeLaserGateValue_Rev : DestroyerAI.ProbeLaserGateValue) - DestroyerAI.ProbeLaserTelegraphTime; - Texture2D glowTexture = ExtraTextureRefs.ProbeGlowmask.Value; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - - float colorScale = MathHelper.Clamp((npc.localAI[0] - eyeTelegraphGateValue) / DestroyerAI.ProbeLaserTelegraphTime, 0f, 1f); - Color drawColor2 = Color.Lerp(new Color(150, 0, 0, 192), new Color(255, 100, 150, 192), colorScale); - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - - if (revenge) - { - // Create additional afterimages in the cardinal directions in Rev+ - if (npc.type == NPCID.BrainofCthulhu) - { - float secondAfterimageSetHealthValue = (int)(npc.lifeMax * 0.8f); - if (npc.life < secondAfterimageSetHealthValue) - { - int totalAfterimages = death ? 12 : 4; - for (int i = 0; i < totalAfterimages; i++) - { - Color currentColor = npc.GetAlpha(drawColor); - float opacityScale = 1f - MathHelper.Lerp(0.34f, 1f, npc.life / (float)secondAfterimageSetHealthValue); - float opacity = Main.getGoodWorld ? 0.7f : opacityScale; - - opacity = MathHelper.Clamp(opacity, 0f, 1f); - currentColor.R = (byte)((float)(int)currentColor.R * opacity); - currentColor.G = (byte)((float)(int)currentColor.G * opacity); - currentColor.B = (byte)((float)(int)currentColor.B * opacity); - currentColor.A = (byte)((float)(int)currentColor.A * opacity); - - Vector2 position = npc.position; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - if (i > 3) - { - currentColor *= 0.5f; - distanceFromTargetX *= 0.5f; - distanceFromTargetY *= 0.5f; - } - if (i > 7) - currentColor *= 0.5f; - - switch (i) - { - case 0: - case 4: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y; - break; - - case 1: - case 5: - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - position.X = Main.LocalPlayer.Center.X; - break; - - case 2: - case 6: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y; - break; - - case 3: - case 7: - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - position.X = Main.LocalPlayer.Center.X; - break; - - case 8: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; - - case 9: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; - - case 10: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - case 11: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - default: - break; - } - - position.X -= npc.width / 2; - position.Y -= npc.height / 2; - - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - 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); - } - } - } - - // Telegraph for charge and blood shots - else if (npc.type == NPCID.Creeper) - { - if (NPC.crimsonBoss < 0) - return; - - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - bool brainIsInPhase2 = Main.npc[NPC.crimsonBoss].ai[0] < 0f; - if (brainIsInPhase2) - { - Vector2 distanceFromBrain = npc.Center - Main.npc[NPC.crimsonBoss].Center; - Color currentColor = npc.GetAlpha(drawColor); - float opacity = (1f - Main.npc[NPC.crimsonBoss].life / (float)Main.npc[NPC.crimsonBoss].lifeMax) * 2f; - opacity *= opacity; - if (Main.getGoodWorld) - opacity = 1f; - - opacity = MathHelper.Clamp(opacity, 0f, 1f); - currentColor.R = (byte)((float)(int)currentColor.R * opacity); - currentColor.G = (byte)((float)(int)currentColor.G * opacity); - currentColor.B = (byte)((float)(int)currentColor.B * opacity); - currentColor.A = (byte)((float)(int)currentColor.A * opacity); - int totalAfterimages = 4; - for (int i = 0; i < totalAfterimages; i++) - { - Vector2 position = npc.position; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - if (i == 0 || i == 2) - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - else - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - - position.X -= npc.width / 2; - if (i == 0 || i == 1) - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - else - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - - position.Y -= npc.height / 2; - - 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); - if (Main.npc[NPC.crimsonBoss].life < secondAfterimageSetHealthValue) - { - currentColor = npc.GetAlpha(drawColor); - float opacityScale = 1f - Main.npc[NPC.crimsonBoss].life / (float)secondAfterimageSetHealthValue; - opacity = Main.getGoodWorld ? 1f : opacityScale; - - opacity = MathHelper.Clamp(opacity, 0f, 1f); - currentColor.R = (byte)((float)(int)currentColor.R * opacity); - currentColor.G = (byte)((float)(int)currentColor.G * opacity); - currentColor.B = (byte)((float)(int)currentColor.B * opacity); - currentColor.A = (byte)((float)(int)currentColor.A * opacity); - totalAfterimages = death ? 12 : 4; - for (int i = 0; i < totalAfterimages; i++) - { - Vector2 position = npc.position; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - if (i > 3) - { - currentColor *= 0.5f; - distanceFromTargetX *= 0.5f; - distanceFromTargetY *= 0.5f; - } - - switch (i) - { - case 0: - case 4: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromBrain.Y; - break; - - case 1: - case 5: - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - position.X = Main.LocalPlayer.Center.X + distanceFromBrain.X; - break; - - case 2: - case 6: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromBrain.Y; - break; - - case 3: - case 7: - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - position.X = Main.LocalPlayer.Center.X + distanceFromBrain.X; - break; - - case 8: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; - - case 9: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; - - case 10: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - case 11: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - default: - break; - } - - position.X -= npc.width / 2; - position.Y -= npc.height / 2; - - 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 beginTelegraphGateValue = BrainOfCthulhuAI.TimeBeforeCreeperAttack - BrainOfCthulhuAI.CreeperTelegraphTime; - if (npc.ai[1] > beginTelegraphGateValue || npc.ai[0] == 1f) - { - float colorScale = npc.ai[0] == 1f ? 1f : MathHelper.Clamp((npc.ai[1] - beginTelegraphGateValue) / BrainOfCthulhuAI.CreeperTelegraphTime, 0f, 1f); - Color drawColor2 = new Color(150, 30, 30, 0) * colorScale; - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - // Telegraph for charges - else if (npc.type == NPCID.SkeletronHead) - { - float beginTelegraphGateValue = SkeletronAI.ChargeGateValue - SkeletronAI.ChargeTelegraphTime; - if (npc.localAI[1] > beginTelegraphGateValue) - { - float colorScale = MathHelper.Clamp((npc.localAI[1] - beginTelegraphGateValue) / SkeletronAI.ChargeTelegraphTime, 0f, 1f); - Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - // Telegraph for slaps - else if (npc.type == NPCID.SkeletronHand) - { - float beginTelegraphGateValue = SkeletronAI.HandSlapGateValue - SkeletronAI.HandSlapTelegraphTime; - if (newAI[2] > beginTelegraphGateValue) - { - float colorScale = MathHelper.Clamp((newAI[2] - beginTelegraphGateValue) / SkeletronAI.HandSlapTelegraphTime, 0f, 1f); - Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Vector2 glowOffset = Vector2.UnitY * 8f; - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY) - glowOffset, npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - // Laser telegraph - else if (npc.type == NPCID.WallofFleshEye && Main.wofNPCIndex >= 0) - { - bool enraged = npc.localAI[3] > 0f; - float eyeTelegraphGateValue = WallOfFleshAI.LaserShootGateValue - WallOfFleshAI.LaserShootTelegraphTime; - if (npc.localAI[1] > eyeTelegraphGateValue || npc.localAI[2] > 0f || enraged) - { - Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.WallOfFleshEyeGlowmask.Value : TextureAssets.Npc[npc.type].Value; - Vector2 halfSize = npc.frame.Size() / 2; - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - float colorScale = enraged ? MathHelper.Clamp(npc.localAI[3] / WallOfFleshAI.EnragedLaserFiringDuration, 0f, 1f) : - npc.localAI[2] > 0f ? 1f - ((npc.localAI[2] - 1f) / WallOfFleshAI.TotalLasersPerBarrage) : - MathHelper.Clamp((npc.localAI[1] - eyeTelegraphGateValue) / WallOfFleshAI.LaserShootTelegraphTime, 0f, 1f); - - Color drawColor2 = new Color(100, 0, 200, 192) * colorScale; - for (int i = 0; i < 2; i++) - { - spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, - drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); - } - } - } - - // His afterimages I can't get to work, so fuck it - else if (npc.type == NPCID.SkeletronPrime || npc.type == NPCType()) - { - Texture2D npcTexture = (death && npc.type == NPCID.SkeletronPrime) ? ExtraTextureRefs.ChadPrime.Value : TextureAssets.Npc[npc.type].Value; - int frameHeight = npcTexture.Height / Main.npcFrameCount[npc.type]; - - npc.frame.Y = (int)newAI[3]; - - // Mechdusa drawing - if (NPC.IsMechQueenUp) - { - if (npc.ai[1] == 0f || npc.ai[1] == 4f) - { - newAI[2] += 1f; - if (newAI[2] >= 12f) - { - newAI[2] = 0f; - newAI[3] += frameHeight; - if (newAI[3] / frameHeight >= 5) - newAI[3] = frameHeight * 3; - } - } - else - { - newAI[2] = 0f; - newAI[3] = frameHeight * 5; - } - } - - // Floating phase - else if (npc.ai[1] == 0f || npc.ai[1] == 4f) - { - newAI[2] += 1f; - if (newAI[2] >= 12f) - { - newAI[2] = 0f; - newAI[3] += frameHeight; - - if (newAI[3] / frameHeight >= 2f) - newAI[3] = 0f; - } - } - - // Spinning probe spawn or fly over phase - else if (npc.ai[1] == 5f || npc.ai[1] == 6f) - { - newAI[2] = 0f; - newAI[3] = frameHeight; - } - - // Spinning phase - else - { - newAI[2] = 0f; - newAI[3] = frameHeight * 2; - } - - npc.frame.Y = (int)newAI[3]; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, npc.GetAlpha(drawColor), npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f); - - Color eyesColor = new Color(200, 200, 200, 0); - if (death) - { - int alpha = 192; - eyesColor = npc.type == NPCType() ? new Color(150, 100, 255, alpha) : new Color(255, 255, 0, alpha); - Texture2D glowTexture = npc.type == NPCID.SkeletronPrime ? ExtraTextureRefs.ChadPrimeEyeGlowmask.Value : SkeletronPrime2.EyeTexture.Value; - spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, eyesColor, npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f); - } - else - spriteBatch.Draw(TextureAssets.BoneEyes.Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, eyesColor, npc.rotation, npc.frame.Size() / 2, npc.scale, spriteEffects, 0f); - } - - else if (npc.type == NPCID.Plantera) - { - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - Texture2D npcTexture = TextureAssets.Npc[npc.type].Value; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Color originalColor = npc.GetAlpha(drawColor); - Color newColor = new Color(100, 255, 100, 255); - Vector2 glowOffset = Vector2.UnitY * -4f; - Vector2 drawPosition = npc.Center - screenPos + new Vector2(0, npc.gfxOffY) + glowOffset; - Vector2 origin = npc.frame.Size() / 2; - - bool phase2 = lifeRatio <= 0.5f; - if (!phase2) - { - float telegraphTimer = Math.Abs(npc.ai[1]); - bool startSeedGatlingSporeGasTelegraph = npc.ai[1] > PlanteraAI.SeedGatlingColorChangeGateValue; - bool endSeedGatlingSporeGasTelegraph = npc.ai[1] < -PlanteraAI.SeedGatlingDuration + PlanteraAI.SeedGatlingColorChangeDuration; - if (startSeedGatlingSporeGasTelegraph) - { - float telegraphScalar = MathHelper.Clamp((telegraphTimer - PlanteraAI.SeedGatlingColorChangeGateValue) / PlanteraAI.SeedGatlingColorChangeDuration, 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - spriteBatch.Draw(npcTexture, drawPosition, npc.frame, telegraphColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - - // -300 to -120 - else if (endSeedGatlingSporeGasTelegraph) - { - float telegraphScalar = MathHelper.Clamp((telegraphTimer - (PlanteraAI.SeedGatlingDuration - PlanteraAI.SeedGatlingColorChangeDuration)) / PlanteraAI.SeedGatlingColorChangeDuration, 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - spriteBatch.Draw(npcTexture, drawPosition, npc.frame, telegraphColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - else - { - float telegraphTimer = Math.Abs(npc.ai[3]); - bool startChargeTelegraph = npc.ai[3] > PlanteraAI.ChargeTelegraphColorChangeGateValue; - bool endChargeTelegraph = npc.ai[3] <= -2f; - if (startChargeTelegraph) - { - float telegraphScalar = MathHelper.Clamp((telegraphTimer - PlanteraAI.ChargeTelegraphColorChangeGateValue) / PlanteraAI.SeedGatlingColorChangeDuration, 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - spriteBatch.Draw(npcTexture, drawPosition, npc.frame, telegraphColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - - // -195 to -2 - else if (endChargeTelegraph) - { - float telegraphScalar = MathHelper.Clamp((Math.Abs(PlanteraAI.StopChargeGateValue) - telegraphTimer) / Math.Abs(PlanteraAI.StopChargeGateValue), 0f, 1f); - Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - - if (CalamityClientConfig.Instance.Afterimages) - { - 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) + glowOffset; - 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); - } - } - } - } - } - - public override bool? DrawHealthBar(NPC npc, byte hbPosition, ref float scale, ref Vector2 position) - { - if (CalamityWorld.death || BossRushEvent.BossRushActive) - { - if (npc.type == NPCID.Creeper) - { - bool brainIsInPhase2 = Main.npc[NPC.crimsonBoss].ai[0] < 0f; - if (brainIsInPhase2) - return false; - } - } - - if (CalamityWorld.death) - { - switch (npc.type) - { - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - return true; - - default: - break; - } - } - - return null; - } - public static Color buffColor(Color newColor, float R, float G, float B, float A) { newColor.R = (byte)((float)newColor.R * R); @@ -8795,61 +5309,45 @@ namespace CalamityMod.NPCs { case NPCID.KingSlime: return NPC.downedSlimeKing; - case NPCID.EyeofCthulhu: return NPC.downedBoss1; - case NPCID.EaterofWorldsHead: case NPCID.EaterofWorldsBody: case NPCID.EaterofWorldsTail: case NPCID.BrainofCthulhu: case NPCID.Creeper: return NPC.downedBoss2; - case NPCID.QueenBee: return NPC.downedQueenBee; - case NPCID.SkeletronHead: return NPC.downedBoss3; - case NPCID.Deerclops: return NPC.downedDeerclops; - case NPCID.WallofFlesh: case NPCID.WallofFleshEye: return Main.hardMode; - case NPCID.QueenSlimeBoss: return NPC.downedQueenSlime; - case NPCID.TheDestroyer: case NPCID.TheDestroyerBody: case NPCID.TheDestroyerTail: return NPC.downedMechBoss1; - case NPCID.Spazmatism: case NPCID.Retinazer: return NPC.downedMechBoss2; - case NPCID.SkeletronPrime: return NPC.downedMechBoss3; - case NPCID.Plantera: return NPC.downedPlantBoss; - case NPCID.HallowBoss: return NPC.downedEmpressOfLight; - case NPCID.Golem: case NPCID.GolemHead: return NPC.downedGolemBoss; - case NPCID.DukeFishron: return NPC.downedFishron; - case NPCID.CultistBoss: return NPC.downedAncientCultist; - case NPCID.MoonLordCore: case NPCID.MoonLordHand: case NPCID.MoonLordHead: @@ -8857,113 +5355,59 @@ namespace CalamityMod.NPCs } if (type == NPCType() || type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedDesertScourge; - } else if (type == NPCType()) - { return DownedBossSystem.downedCrabulon; - } else if (type == NPCType()) - { return DownedBossSystem.downedHiveMind; - } else if (type == NPCType()) - { return DownedBossSystem.downedPerforator; - } else if (type == NPCType()) - { return DownedBossSystem.downedSlimeGod; - } else if (type == NPCType()) - { return DownedBossSystem.downedCryogen; - } else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedAquaticScourge; - } else if (type == NPCType()) - { return DownedBossSystem.downedBrimstoneElemental; - } else if (type == NPCType()) - { return DownedBossSystem.downedCalamitasClone; - } else if (type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedLeviathan; - } else if (type == NPCType()) - { return DownedBossSystem.downedAstrumAureus; - } else if (type == NPCType() || type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedAstrumDeus; - } else if (type == NPCType()) - { return DownedBossSystem.downedPlaguebringer; - } else if (type == NPCType()) - { return DownedBossSystem.downedRavager; - } else if (type == NPCType()) - { return DownedBossSystem.downedGuardians; - } - else if (type == NPCType()) - { + else if (type == NPCType()) return DownedBossSystem.downedDragonfolly; - } else if (type == NPCType()) - { return DownedBossSystem.downedProvidence; - } else if (type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedCeaselessVoid; - } else if (type == NPCType() || type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedStormWeaver; - } else if (type == NPCType()) - { return DownedBossSystem.downedSignus; - } else if (type == NPCType()) - { return DownedBossSystem.downedPolterghast; - } else if (type == NPCType()) - { return DownedBossSystem.downedBoomerDuke; - } else if (type == NPCType() || type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedDoG; - } else if (type == NPCType()) - { return DownedBossSystem.downedYharon; - } else if (type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType() || type == NPCType()) - { return DownedBossSystem.downedExoMechs; - } else if (type == NPCType()) - { return DownedBossSystem.downedCalamitas; - } else if (type == NPCType()) - { return DownedBossSystem.downedPrimordialWyrm; - } return true; } @@ -8974,8 +5418,7 @@ namespace CalamityMod.NPCs { if (!GetDownedBossVariable(npc.type)) { - BossTypeDict.TryGet(npc.type, out int newBossTypeJustDowned); - + CalamityNPCSets.BossSpeedrunTimerID.TryGetValue(npc.type, out int newBossTypeJustDowned); for (int i = 0; i < Main.maxPlayers; i++) { Player player = Main.player[i]; @@ -8996,9 +5439,7 @@ namespace CalamityMod.NPCs foreach (Player player in Main.ActivePlayers) { if (!player.dead && !player.ghost) - { return true; - } } return false; } @@ -9006,9 +5447,7 @@ namespace CalamityMod.NPCs public static int GetActivePlayerCount() { if (Main.netMode == NetmodeID.SinglePlayer) - { return 1; - } return Main.CurrentFrameFlags.ActivePlayersCount; } @@ -9017,13 +5456,13 @@ namespace CalamityMod.NPCs #region Should Affect NPC public static bool ShouldAffectNPC(NPC target) { - if (EaterOfWorldsIDList.Includes(target.type) || DestroyerIDList.Includes(target.type)) + if (CalamityNPCTypeSets.EaterOfWorlds.Contains(target.type) || CalamityNPCTypeSets.Destroyer.Contains(target.type)) return false; if (target.damage > 0 && !target.boss && !target.friendly && !target.dontTakeDamage && target.type != NPCID.Creeper && target.type != NPCType() && target.type != NPCID.MourningWood && target.type != NPCID.Everscream && target.type != NPCID.SantaNK1 && target.type != NPCType() && target.type != NPCType() && target.type != NPCType() && target.type != NPCType() && target.type != NPCID.GolemFistLeft && target.type != NPCID.GolemFistRight && - target.type != NPCType() && target.type != NPCType() && target.type != NPCID.DD2Betsy && !EnemyImmunitiesList.Includes(target.type) && !AcidRainEvent.AllMinibosses.Contains(target.type)) + target.type != NPCType() && target.type != NPCType() && target.type != NPCID.DD2Betsy && !CalamityNPCSets.ResistSlowingDebuffsAndOtherSpecialEffects[target.type] && !AcidRainEvent.AllMinibosses.Contains(target.type)) { return true; } @@ -9035,7 +5474,6 @@ namespace CalamityMod.NPCs public static void OldDukeSpawn(int plr, int type, int baitType) { Player player = Main.player[plr]; - if (!player.active || player.dead) return; @@ -9054,7 +5492,7 @@ namespace CalamityMod.NPCs player.inventory[item].stack--; if (player.inventory[item].stack <= 0) { - player.inventory[item].SetDefaults(0, false); + player.inventory[item].SetDefaults(ItemID.None, false); } break; } @@ -9064,10 +5502,8 @@ namespace CalamityMod.NPCs projectile.netUpdate = true; // The vanilla game uses a special packet for Duke Fishron spawning. - // However, this packet doesn't work on modded NPC types, so we must create - // a custom one. - // Also, you can't use Netmode != NetmodeID.MultiplayerClient in a projectile context that - // has an owner, hence the MyPlayer check. + // However, this packet doesn't work on modded NPC types, so we must create a custom one. + // Also, you can't use Netmode != NetmodeID.MultiplayerClient in a projectile context that has an owner, hence the MyPlayer check. if (Main.myPlayer == projectile.owner) { if (!player.active || player.dead) @@ -9099,7 +5535,6 @@ namespace CalamityMod.NPCs } } } - break; } else @@ -9110,7 +5545,7 @@ namespace CalamityMod.NPCs } #endregion - #region Astral things + #region Astral Things public static void DoHitDust(NPC npc, int hitDirection, int dustType = 5, float xSpeedMult = 1f, int numHitDust = 5, int numDeathDust = 20) { for (int k = 0; k < 5; k++) @@ -9121,19 +5556,15 @@ namespace CalamityMod.NPCs if (npc.life <= 0) { for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, dustType, hitDirection * xSpeedMult, -1f); - } } } public static void DoFlyingAI(NPC npc, float maxSpeed, float acceleration, float circleTime, float minDistanceTarget = 150f, bool shouldAttackTarget = true) { - //Pick a new target. + // Pick a new target if (npc.target < 0 || npc.target >= Main.maxPlayers || Main.player[npc.target].dead) - { npc.TargetClosest(true); - } Player myTarget = Main.player[npc.target]; Vector2 toTarget = myTarget.Center - npc.Center; @@ -9150,40 +5581,26 @@ namespace CalamityMod.NPCs maxVelocity *= magnitude; } - //Circular motion + // Circular motion npc.ai[0]++; - //y motion + // Y motion if (npc.ai[0] > circleTime * 0.5f) - { npc.velocity.Y += acceleration; - } else - { npc.velocity.Y -= acceleration; - } - - //x motion + // X motion if (npc.ai[0] < circleTime * 0.25f || npc.ai[0] > circleTime * 0.75f) - { npc.velocity.X += acceleration; - } else - { npc.velocity.X -= acceleration; - } - - //reset + // Reset if (npc.ai[0] > circleTime) - { npc.ai[0] = 0f; - } - //if close enough + // If close enough if (shouldAttackTarget && distanceToTarget < minDistanceTarget) - { npc.velocity += maxVelocity * 0.007f; - } if (myTarget.dead) { @@ -9191,40 +5608,25 @@ namespace CalamityMod.NPCs maxVelocity.Y = -maxSpeed / 2f; } - //maximise velocity + // Maximise velocity if (npc.velocity.X < maxVelocity.X) - { npc.velocity.X += acceleration; - } - if (npc.velocity.X > maxVelocity.X) - { npc.velocity.X -= acceleration; - } - if (npc.velocity.Y < maxVelocity.Y) - { npc.velocity.Y += acceleration; - } - if (npc.velocity.Y > maxVelocity.Y) - { npc.velocity.Y -= acceleration; - } - //rotate towards player if alive + // Rotate towards player if alive if (!myTarget.dead) - { npc.rotation = toTarget.ToRotation(); - } - else //don't, do velocity instead - { + else // Don't, do velocity instead npc.rotation = npc.velocity.ToRotation(); - } npc.rotation += MathHelper.Pi; - //tile collision + // Tile collision float collisionDamp = 0.7f; if (npc.collideX) { @@ -9232,14 +5634,9 @@ namespace CalamityMod.NPCs npc.velocity.X = npc.oldVelocity.X * -collisionDamp; if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - { npc.velocity.X = 2f; - } - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - { npc.velocity.X = -2f; - } } if (npc.collideY) { @@ -9247,33 +5644,22 @@ namespace CalamityMod.NPCs npc.velocity.Y = npc.oldVelocity.Y * -collisionDamp; if (npc.velocity.Y > 0f && npc.velocity.Y < 1.5f) - { npc.velocity.Y = 1.5f; - } - if (npc.velocity.Y < 0f && npc.velocity.Y > -1.5f) - { npc.velocity.Y = -1.5f; - } } - //water collision + // Water collision if (npc.wet) { if (npc.velocity.Y > 0f) - { npc.velocity.Y *= 0.95f; - } - npc.velocity.Y -= 0.3f; - if (npc.velocity.Y < -2f) - { npc.velocity.Y = -2f; - } } - //Taken from source. Important for net? + // Taken from source. Important for net? if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) { npc.netUpdate = true; @@ -9282,16 +5668,14 @@ namespace CalamityMod.NPCs public static void DoSpiderWallAI(NPC npc, int transformType, float chaseMaxSpeed = 2f, float chaseAcceleration = 0.08f) { - //GET NEW TARGET + // GET NEW TARGET if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) - { npc.TargetClosest(); - } Vector2 between = Main.player[npc.target].Center - npc.Center; float distance = between.Length(); - //modify vector depending on distance and speed. + // Modify vector depending on distance and speed. if (distance == 0f) { between.X = npc.velocity.X; @@ -9304,7 +5688,7 @@ namespace CalamityMod.NPCs between.Y *= distance; } - //update if target dead. + // Update if target dead. if (Main.player[npc.target].dead) { between.X = npc.direction * chaseMaxSpeed / 2f; @@ -9312,58 +5696,35 @@ namespace CalamityMod.NPCs } npc.spriteDirection = -1; - //If spider can't see target, circle around to attempt to find the target. + // If spider can't see target, circle around to attempt to find the target. if (!Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - //CIRCULAR MOTION, SIMILAR TO FLYING AI (Eater of Souls etc.) + // CIRCULAR MOTION, SIMILAR TO FLYING AI (Eater of Souls etc.) npc.ai[0]++; if (npc.ai[0] > 0f) - { npc.velocity.Y += 0.023f; - } else - { npc.velocity.Y -= 0.023f; - } - if (npc.ai[0] < -100f || npc.ai[0] > 100f) - { npc.velocity.X += 0.023f; - } else - { npc.velocity.X -= 0.023f; - } - if (npc.ai[0] > 200f) - { npc.ai[0] = -200f; - } npc.velocity.X += between.X * 0.007f; npc.velocity.Y += between.Y * 0.007f; npc.rotation = npc.velocity.ToRotation(); if (npc.velocity.X > 1.5f) - { npc.velocity.X *= 0.9f; - } - if (npc.velocity.X < -1.5f) - { npc.velocity.X *= 0.9f; - } - if (npc.velocity.Y > 1.5f) - { npc.velocity.Y *= 0.9f; - } - if (npc.velocity.Y < -1.5f) - { npc.velocity.Y *= 0.9f; - } npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -3f, 3f); npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -3f, 3f); @@ -9373,43 +5734,31 @@ namespace CalamityMod.NPCs if (npc.velocity.X < between.X) { npc.velocity.X += chaseAcceleration; - if (npc.velocity.X < 0f && between.X > 0f) - { npc.velocity.X += chaseAcceleration; - } } else if (npc.velocity.X > between.X) { npc.velocity.X -= chaseAcceleration; - if (npc.velocity.X > 0f && between.X < 0f) - { npc.velocity.X -= chaseAcceleration; - } } if (npc.velocity.Y < between.Y) { npc.velocity.Y += chaseAcceleration; - if (npc.velocity.Y < 0f && between.Y > 0f) - { npc.velocity.Y += chaseAcceleration; - } } else if (npc.velocity.Y > between.Y) { npc.velocity.Y -= chaseAcceleration; - if (npc.velocity.Y > 0f && between.Y < 0f) - { npc.velocity.Y -= chaseAcceleration; - } } npc.rotation = between.ToRotation(); } - //DAMP COLLISIONS OFF OF WALLS + // DAMP COLLISIONS OFF OF WALLS float collisionDamp = 0.5f; if (npc.collideX) { @@ -9417,14 +5766,9 @@ namespace CalamityMod.NPCs npc.velocity.X = npc.oldVelocity.X * -collisionDamp; if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - { npc.velocity.X = 2f; - } - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - { npc.velocity.X = -2f; - } } if (npc.collideY) { @@ -9432,14 +5776,9 @@ namespace CalamityMod.NPCs npc.velocity.Y = npc.oldVelocity.Y * -collisionDamp; if (npc.velocity.Y > 0f && npc.velocity.Y < 1.5f) - { npc.velocity.Y = 2f; - } - if (npc.velocity.Y < 0f && npc.velocity.Y > -1.5f) - { npc.velocity.Y = -2f; - } } if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) @@ -9457,10 +5796,8 @@ namespace CalamityMod.NPCs { for (int j = y - 1; j <= y + 1; j++) { - if (Main.tile[i, j].WallType > 0) - { + if (Main.tile[i, j].WallType > WallID.None) flag = true; - } } } if (!flag) @@ -9511,14 +5848,9 @@ namespace CalamityMod.NPCs npc.velocity.X = npc.oldVelocity.X * -0.5f; if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - { npc.velocity.X = 2f; - } - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - { npc.velocity.X = -2f; - } } if (npc.collideY) @@ -9526,14 +5858,9 @@ namespace CalamityMod.NPCs npc.velocity.Y = npc.oldVelocity.Y * -0.5f; if (npc.velocity.Y > 0f && npc.velocity.Y < 1f) - { npc.velocity.Y = 1f; - } - if (npc.velocity.Y < 0f && npc.velocity.Y > -1f) - { npc.velocity.Y = -1f; - } } if (npc.direction == -1 && npc.velocity.X > -maxSpeed) @@ -9541,88 +5868,57 @@ namespace CalamityMod.NPCs npc.velocity.X -= acceleration; if (npc.velocity.X > maxSpeed) - { npc.velocity.X -= acceleration; - } else if (npc.velocity.X > 0f) - { npc.velocity.X -= acceleration * 0.5f; - } - if (npc.velocity.X < -maxSpeed) - { npc.velocity.X = -maxSpeed; - } } else if (npc.direction == 1 && npc.velocity.X < maxSpeed) { npc.velocity.X += acceleration; if (npc.velocity.X < -maxSpeed) - { npc.velocity.X += acceleration; - } else if (npc.velocity.X < 0f) - { npc.velocity.X += acceleration * 0.5f; - } - if (npc.velocity.X > maxSpeed) - { npc.velocity.X = maxSpeed; - } } float xDistance = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); float yLimiter = Main.player[npc.target].position.Y - (npc.height / 2f); if (xDistance > 50f) - { yLimiter -= 100f; - } if (npc.position.Y < yLimiter) { npc.velocity.Y += acceleration * 0.5f; if (npc.velocity.Y < 0f) - { npc.velocity.Y += acceleration * 0.1f; - } } else { npc.velocity.Y -= acceleration * 0.5f; if (npc.velocity.Y > 0f) - { npc.velocity.Y -= acceleration * 0.1f; - } } if (npc.velocity.Y < -maxSpeed) - { npc.velocity.Y = -maxSpeed; - } - if (npc.velocity.Y > maxSpeed) - { npc.velocity.Y = maxSpeed; - } } - //Change velocity if wet. + // Change velocity if wet. if (npc.wet) { if (npc.velocity.Y > 0f) - { npc.velocity.Y *= 0.95f; - } - npc.velocity.Y -= 0.5f; - if (npc.velocity.Y < -4f) - { npc.velocity.Y = -4f; - } } } @@ -9637,7 +5933,7 @@ namespace CalamityMod.NPCs { Vector2 half = new Vector2(frameWidth / 2f, frameHeight / 2f); - //"flip" the rectangle's position x-wise. + // "Flip" the rectangle's position x-wise. if ((!useSpriteDirection && npc.direction == 1) || (useSpriteDirection && npc.spriteDirection == 1)) { rect.X = frameWidth - rect.Right; @@ -9654,37 +5950,6 @@ namespace CalamityMod.NPCs } #endregion - #region Adjust Difficulty Stat Scaling - // Adjust HP and damage in Master Mode - public static void AdjustMasterModeStatScaling(NPC npc, bool isABoss = false) - { - if (!Main.masterMode) - return; - - // Bosses and enemies have separate HP reduction multipliers - npc.lifeMax = (int)Math.Round(npc.lifeMax * (isABoss ? MasterModeBossHPMultiplier : MasterModeEnemyHPMultiplier)); - - // Bosses do not get their damage reduced - if (!isABoss) - npc.damage = (int)Math.Round(npc.damage * MasterModeEnemyDamageMultiplier); - } - - // Adjust only knockback resist in Expert Mode (this is also adjusted in Master Mode because Expert has to be enabled if Master is enabled) - public static void AdjustExpertModeStatScaling(NPC npc) - { - if (!Main.expertMode) - return; - - if (npc.knockBackResist <= 0f) - return; - - // Knockback resist is backasswards in this fucking game so we need to add to the knockBackResist variable here :^) - float knockBackResistMult = Main.masterMode ? MasterModeEnemyKnockbackMultiplier : ExpertModeEnemyKnockbackMultiplier; - float knockBackResistReduction = npc.knockBackResist * knockBackResistMult; - npc.knockBackResist += knockBackResistReduction; - } - #endregion - #region Bestiary public override void SetBestiary(NPC npc, BestiaryDatabase database, BestiaryEntry bestiaryEntry) { @@ -9762,7 +6027,6 @@ namespace CalamityMod.NPCs case NPCID.GoblinSummoner: case NPCID.GoblinSorcerer: case NPCID.PirateCaptain: - case NPCID.Scutlix: case NPCID.MartianSaucerCore: case NPCID.TorchGod: case NPCID.EyeofCthulhu: @@ -9809,15 +6073,11 @@ namespace CalamityMod.NPCs // Add the Astral Infection to the Enchanted Nightcrawler's entry as it spawns there now if (npc.type == NPCID.EnchantedNightcrawler) - { bestiaryEntry.AddTags(GetInstance().ModBiomeBestiaryInfoElement); - } // Add the Surface Mushroom biome to the Truffle Worm's entry as it spawns there now if (npc.type == NPCID.TruffleWorm) - { bestiaryEntry.AddTags(BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SurfaceMushroom); - } // Remove the static portraits from vanilla worms so that Calamity's worm movement can be added in PreDraw switch (npc.netID) @@ -9846,13 +6106,10 @@ namespace CalamityMod.NPCs { string result = CalamityUtils.GetTextValue("UI.DebuffSystem.Neutral"); if (effectiveness == true) - { result = CalamityUtils.GetTextValue("UI.DebuffSystem.Weak"); - } else if (effectiveness == false) - { result = CalamityUtils.GetTextValue("UI.DebuffSystem.Resistant"); - } + result += " " + CalamityUtils.GetTextValue("UI.DebuffSystem.To") + " " + name; return result; } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 55206d6a05..fa87ef4718 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -1,7 +1,7 @@ using System; +using System.Collections.Generic; using System.Threading; using CalamityMod.Events; -using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Fishing; @@ -9,7 +9,8 @@ using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.PermanentBoosters; using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.SummonItems; @@ -30,6 +31,7 @@ using Terraria.Audio; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.NPCs.CalamityGlobalTownNPC; namespace CalamityMod.NPCs { @@ -126,17 +128,33 @@ namespace CalamityMod.NPCs #region Underground // Giant Shelly + // Giant Shell @ 100% IF Hardmode + // OTHERWISE, // Giant Shell @ 14.29% Normal, 25% Expert+ case NPCID.GiantShelly: case NPCID.GiantShelly2: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); + hardmode.Add(ModContent.ItemType()); + hardmode.OnFailedConditions(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); break; // Crawdad + // Craw Carapace @ 100% IF Hardmode + // OTHERWISE, // Craw Carapace @ 14.29% Normal, 25% Expert+ case NPCID.Crawdad: case NPCID.Crawdad2: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); + hardmode.Add(ModContent.ItemType()); + hardmode.OnFailedConditions(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 7, 4)); + break; + + // Medusa + // Pocket Mirror @ 7.14% Normal, 14.29% Expert+ (2.5% Normal, 5% Expert+ in vanilla) + case NPCID.Medusa: + // Remove the vanilla loot rule for Pocket Mirror. + npcLoot.RemoveWhere((rule) => rule is CommonDrop conditionalRule && conditionalRule.itemId == ItemID.PocketMirror); + + // Define a replacement rule which has an increased chance. + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.PocketMirror, 14, 7)); break; // Tim @@ -145,10 +163,18 @@ namespace CalamityMod.NPCs npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 3, 2)); break; - // Skeleton Merchant - // Punch Card @ 100% - case NPCID.SkeletonMerchant: - npcLoot.Add(ModContent.ItemType()); + // Skeleton Archer + // Magic Quiver @ 5% (2.5% in Vanilla) + // Marrow @ 2% (0.5% in Vanilla) + case NPCID.SkeletonArcher: + npcLoot.ChangeDropRate(ItemID.MagicQuiver, 1, 20); + npcLoot.ChangeDropRate(ItemID.Marrow, 1, 50); + break; + + // Armored Skeleton + // Beam Sword @ 2% (0.67% in Vanilla) + case NPCID.ArmoredSkeleton: + npcLoot.ChangeDropRate(ItemID.BeamSword, 1, 50); break; // Mimic @@ -218,34 +244,82 @@ namespace CalamityMod.NPCs npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 25, 15)); break; + // Desert Spirit + // Nazar @ 1% Normal, 2% Expert+ + case NPCID.DesertDjinn: + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Nazar, 100, 50)); + break; + + // Dreamer Ghoul + // Trifold Map @ 1% Normal, 2% Expert+ + // Light Shard @ 10% + case NPCID.DesertGhoulHallow: + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.TrifoldMap, 100, 50)); + npcLoot.ChangeDropRate(ItemID.LightShard, 1, 10); + break; + + // Crystal Thresher + // Light Shard @ 10% + case NPCID.SandsharkHallow: + npcLoot.ChangeDropRate(ItemID.LightShard, 1, 10); + break; + // Sand Elemental // Elemental in a Bottle @ 20% Normal, 33.33% Expert+ // Rare Elemental in a Bottle @ 10% Normal, 16.67% Expert+ // Desert Key @ 10% case NPCID.SandElemental: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 5, 3)); - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 6)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 5, 3)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 6)); npcLoot.Add(ItemID.DungeonDesertKey, 10); break; + + // Tainted Ghoul, Vile Ghoul, Bone Biter, Flesh Reaver + // Dark Shard @ 10% + case NPCID.DesertGhoulCorruption: + case NPCID.DesertGhoulCrimson: + case NPCID.SandsharkCorrupt: + case NPCID.SandsharkCrimson: + npcLoot.ChangeDropRate(ItemID.DarkShard, 1, 10); + break; #endregion #region Ice - // Ice Bat. - // Frostbat Staff @ 6.67% + // Ice Bat + // Frosty Bat Bottle @ 7.14% case NPCID.IceBat: - npcLoot.Add(ModContent.ItemType(), 15); + npcLoot.Add(ModContent.ItemType(), 14); + break; + + // Armored Viking + // Armor Polish @ 1% Normal, 2% Expert + case NPCID.ArmoredViking: + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.ArmorPolish, 100, 50)); break; // Icy Merman, Icy Tortoise, Ice Elemental, Wolf // Essence of Eleum @ 100% case NPCID.IcyMerman: - case NPCID.IceTortoise: case NPCID.IceElemental: case NPCID.Wolf: npcLoot.Add(ModContent.ItemType()); break; + // Modify Frozen Turtle Shell drop rate from 2% to 5% + case NPCID.IceTortoise: + npcLoot.Add(ModContent.ItemType()); + List rules = npcLoot.Get(false); + foreach (IItemDropRule rule in rules) + { + if (rule is CommonDrop drop && drop.itemId == ItemID.FrozenTurtleShell) + { + drop.chanceDenominator = 20; + return; + } + } + break; + // Ice Mimic // Drops all of its items Calamity Style @ 25% each, Toy Sled is drops on its own at a 5% chance // Since one weapon is guaranteed to drop, it is at least 33.33% chance for a specific weapon @@ -314,20 +388,32 @@ namespace CalamityMod.NPCs #region Aquatic / Ocean // Pink Jellyfish // Life Jelly @ 10% Normal, 14.29% Expert+ + // Jellyfish Necklace @ 3.33% (1% in vanilla) case NPCID.PinkJellyfish: npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 7)); + npcLoot.ChangeDropRate(ItemID.JellyfishNecklace, 1, 30); break; // Blue Jellyfish // Cleansing Jelly @ 10% Normal, 14.29% Expert+ case NPCID.BlueJellyfish: npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 7)); + npcLoot.ChangeDropRate(ItemID.JellyfishNecklace, 1, 30); break; // Green Jellyfish // Vital Jelly @ 12.5% Normal, 20% Expert+ case NPCID.GreenJellyfish: npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 8, 5)); + npcLoot.ChangeDropRate(ItemID.JellyfishNecklace, 1, 30); + break; + + // Piranha, Arapaima, Blood Feeder + // Adhesive Bandage @ 1% Normal, 2% Expert+ + case NPCID.Piranha: + case NPCID.Arapaima: + case NPCID.BloodFeeder: + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.AdhesiveBandage, 100, 50)); break; // Shark @@ -341,14 +427,36 @@ namespace CalamityMod.NPCs break; // Blood Jelly, Fungo Fish - // Jellyfish Necklace @ 1% + // Jellyfish Necklace @ 3.33% case NPCID.BloodJelly: case NPCID.FungoFish: - npcLoot.Add(ItemID.JellyfishNecklace, 100); + npcLoot.Add(ItemID.JellyfishNecklace, 30); break; #endregion #region Corruption, Crimson, Hallow + // Face Monster, Devourer + // Vitamins @ 1% Normal, 2% Expert+ + case NPCID.FaceMonster: + case NPCID.DevourerHead: + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Vitamins, 100, 50)); + break; + + // Chaos Elemental + // Rod of Discord @ 0.5% Normal, 0.625% Expert+ (2.5 times higher chance than vanilla) + case NPCID.ChaosElemental: + // Remove the vanilla loot rule for Rod of Discord. + npcLoot.RemoveWhere((rule) => rule is CommonDrop conditionalRule && conditionalRule.itemId == ItemID.RodofDiscord); + // Define a replacement rule which has an increased chance. + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.RodofDiscord, 200, 160)); + break; + + // Illuminant Bat + // Trifold Map @ 1% Normal, 2% Expert+ + case NPCID.IlluminantBat: + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.TrifoldMap, 100, 50)); + break; + // Gastropod // 5-10 Pink Gel @ 100% case NPCID.Gastropod: @@ -422,7 +530,12 @@ namespace CalamityMod.NPCs #endregion #region Jungle - //Moss hornets are after all of this switching since it no longer works if placed here + // Moss Hornet + // Needler @ 4% Normal, 6.67% Expert+ + // This automatically covers all variations + case NPCID.MossHornet: + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 25, 15)); + break; // Moth // Butterfly Dust @ 100% INSTEAD OF 50% @@ -454,7 +567,7 @@ namespace CalamityMod.NPCs npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 15, 10)); break; - //The ectoplasm extra drops got moved to the list section; just like moss hornets + // The ectoplasm extra drops got moved to the list section; just like moss hornets // Hardmode Dungeon Melee Skeletons // Wisp in a Bottle @ 0.5% INSTEAD OF 0.25% @@ -487,6 +600,13 @@ namespace CalamityMod.NPCs npcLoot.ChangeDropRate(ItemID.Tabi, 1, 4); break; + // Necromancers + // Nazar @ 1% Normal, 2% Expert+ + case NPCID.Necromancer: + case NPCID.NecromancerArmored: + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.FastClock, 100, 50)); + break; + // Paladin // Paladin's Hammer @ 15% INSTEAD OF 6.67% // Paladin's Shield @ 20% INSTEAD OF 9.33% @@ -498,10 +618,18 @@ namespace CalamityMod.NPCs #region Hell - // Hellbat. - // Flarebat Staff @ 4% + // Hellbat + // Toasty Bat Bottle @ 3.33% + // Magma Stone @ 1.33% (0.67% in Vanilla) case NPCID.Hellbat: - npcLoot.Add(ModContent.ItemType(), 25); + npcLoot.Add(ModContent.ItemType(), 30); + npcLoot.ChangeDropRate(ItemID.MagmaStone, 1, 75); + break; + + // Lava Bat + // Magma Stone @ 3.33% (2% in Vanilla) + case NPCID.Lavabat: + npcLoot.ChangeDropRate(ItemID.MagmaStone, 1, 30); break; // Fire Imp @@ -513,10 +641,12 @@ namespace CalamityMod.NPCs // Demon, Voodoo Demon // Bladecrest Oathsword @ 2%, 6.67% after defeating EoW/BoC + // Demon Scythe @ 5% (2.86% in Vanilla) case NPCID.Demon: case NPCID.VoodooDemon: npcLoot.AddIf((info) => !NPC.downedBoss2, ModContent.ItemType(), 50); npcLoot.AddIf((info) => NPC.downedBoss2, ModContent.ItemType(), 15); + npcLoot.ChangeDropRate(ItemID.DemonScythe, 1, 20); break; // Bone Serpent @@ -538,11 +668,15 @@ namespace CalamityMod.NPCs #endregion #region Graveyard - // Alternate Blood Orb obtainment methods (10%) + // Alternate Blood Orb obtainment methods (20%) case NPCID.MaggotZombie: + postEoC.Add(ModContent.ItemType(), 5); + break; + + // 100%, 3-6 each case NPCID.TheBride: case NPCID.TheGroom: - postEoC.Add(ModContent.ItemType(), 10); + postEoC.Add(ModContent.ItemType(), 1, 3, 6); break; // Ghost Bracelet @ 5% (Dandy requests this drops at a "high chance" but inventory clutter is real so) @@ -558,21 +692,18 @@ namespace CalamityMod.NPCs case NPCID.Drippler: postEoC.Add(ModContent.ItemType(), 4); break; - + //Hardmode enemies drop orbs even if EoC is not dead //99% of players will not encounter this and challenge runners will appreciate it case NPCID.Clown: npcLoot.Add(ModContent.ItemType(), 1, 6, 12); break; - // Wandering Eye Fish - // Bouncing Eyeball @ 10% Normal, 16.66% Expert+ + // Wandering Eye Fish, Zombie Merman + // Bouncing Eyeball @ 12.5% case NPCID.EyeballFlyingFish: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 6)); - postEoC.Add(ModContent.ItemType(), 1, 10, 12); - break; - case NPCID.ZombieMerman: + npcLoot.Add(ModContent.ItemType(), 8); postEoC.Add(ModContent.ItemType(), 1, 10, 12); break; @@ -752,8 +883,6 @@ namespace CalamityMod.NPCs // 5-10 Nightmare Fuel @ 100% IF Devourer of Gods dead postDoG.Add(ModContent.ItemType(), 1, 5, 10); - pMoon.OnSuccess(ItemDropRule.ByCondition(new Conditions.NotExpert(), ItemID.WitchBroom, 5)); - // Master items drop in Revengeance pMoon.OnSuccess(ItemDropRule.ByCondition(DropHelper.RevNoMaster, ItemID.MourningWoodMasterTrophy)); pMoon.OnSuccess(ItemDropRule.ByCondition(DropHelper.RevNoMaster, ItemID.SpookyWoodMountItem, 4)); @@ -826,15 +955,15 @@ namespace CalamityMod.NPCs #region Martian Madness // Martian Madness On-Foot Soldiers - // 1.5% chance to drop any of the three Calamity martian drops + // 1% chance to drop any of the three Calamity martian drops case NPCID.BrainScrambler: case NPCID.GrayGrunt: case NPCID.GigaZapper: case NPCID.RayGunner: case NPCID.ScutlixRider: - npcLoot.Add(ModContent.ItemType(), 66); - npcLoot.Add(ModContent.ItemType(), 66); - npcLoot.Add(ModContent.ItemType(), 66); + npcLoot.Add(ModContent.ItemType(), 100); + npcLoot.Add(ModContent.ItemType(), 100); + npcLoot.Add(ModContent.ItemType(), 100); break; // Martian Engineer @@ -959,14 +1088,9 @@ namespace CalamityMod.NPCs break; // Angler - // Golden Fishing Rod @ 100% IF fed to a Trasher - // OTHERWISE, // Golden Fishing Rod @ 8.33% IF Hardmode case NPCID.Angler: - LeadingConditionRule trasherLCR = new LeadingConditionRule(DropHelper.AnglerFedToTrasherCondition); - trasherLCR.Add(ItemDropRule.ByCondition(DropHelper.TrasherText, ItemID.GoldenFishingRod)); - trasherLCR.OnFailedConditions(ItemDropRule.ByCondition(DropHelper.Hardmode(), ItemID.GoldenFishingRod, 12)); - npcLoot.Add(trasherLCR); + hardmode.Add(ItemID.GoldenFishingRod, 12, 1, 1); break; #endregion @@ -985,14 +1109,14 @@ namespace CalamityMod.NPCs }; npcLoot.Add(new DropOneByOne(ItemID.Gel, kingSlimeGelSpray)); - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.RoyalGel)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.RoyalGel)); // Would be in the bag otherwise - npcLoot.AddNormalOnly(ItemDropRule.ByCondition(DropHelper.Remix, ItemID.Keybrand, 4)); - npcLoot.AddNormalOnly(ItemDropRule.ByCondition(DropHelper.NotRemix, ItemID.Katana, 4)); + npcLoot.AddNormalOnly(ItemDropRule.ByCondition(DropHelper.Remix, ItemID.Keybrand, DropHelper.NormalWeaponDropRateInt)); + npcLoot.AddNormalOnly(ItemDropRule.ByCondition(DropHelper.NotRemix, ItemID.Katana, DropHelper.NormalWeaponDropRateInt)); - npcLoot.AddNormalOnly(ModContent.ItemType(), 10); + npcLoot.AddNormalOnly(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1000,19 +1124,19 @@ namespace CalamityMod.NPCs rev.Add(ItemID.KingSlimePetItem, 4); // GFB Aureus Cell drop - GFB.Add(ModContent.ItemType(), 1, 45, 55, true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 45, 55)); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedSlimeKing, ModContent.ItemType(), desc: DropHelper.FirstKillText); break; case NPCID.EyeofCthulhu: - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.EoCShield)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.EoCShield)); // Would be in the bag otherwise - npcLoot.AddNormalOnly(ModContent.ItemType(), 10); - npcLoot.AddNormalOnly(ModContent.ItemType(), 4); + npcLoot.AddNormalOnly(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); + npcLoot.AddNormalOnly(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1020,7 +1144,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.EyeOfCthulhuPetItem, 4); // GFB Optic Staff drop - GFB.Add(ItemID.OpticStaff, hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.OpticStaff), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedBoss1, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1029,21 +1153,20 @@ namespace CalamityMod.NPCs case NPCID.EaterofWorldsHead: case NPCID.EaterofWorldsBody: case NPCID.EaterofWorldsTail: - // Expert+ drops are also available on Normal. Drop what would be in the bag otherwise + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic LeadingConditionRule EoWKill = new(DropHelper.If((info) => info.npc.boss)); - EoWKill.Add(DropHelper.PerPlayer(ItemID.WormScarf)); + // EoWKill.Add(DropHelper.PerPlayer(ItemID.WormScarf)); EoWKill.Add(ModContent.ItemType(), ThankYouPainting.DropInt); npcLoot.AddNormalOnly(EoWKill); - // Would be in the bag otherwise - npcLoot.AddIf((info) => info.npc.boss, ModContent.ItemType(), ThankYouPainting.DropInt); - // Master items drop in Revengeance rev.AddIf((info) => info.npc.boss, ItemID.EaterofWorldsMasterTrophy); rev.AddIf((info) => info.npc.boss, ItemID.EaterOfWorldsPetItem, 4); // GFB Light Disc drop - GFB.AddIf((info) => info.npc.boss, ItemID.LightDisc, hideLootReport: true); + LeadingConditionRule EoWKillGFB = new(DropHelper.If((info) => info.npc.boss)); + EoWKillGFB.Add(DropHelper.PerPlayer(ItemID.LightDisc), hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(EoWKillGFB); // Corruption World OR Drunk World: Corruption Lore LeadingConditionRule eowCorruptionLore = new(DropHelper.If((info) => info.npc.boss && (!WorldGen.crimson || WorldGen.drunkWorldGen) && !NPC.downedBoss2, desc: DropHelper.FirstKillText)); @@ -1059,8 +1182,8 @@ namespace CalamityMod.NPCs break; case NPCID.BrainofCthulhu: - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BrainOfConfusion)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BrainOfConfusion)); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1070,7 +1193,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.BrainOfCthulhuPetItem, 4); // GFB Occult Skull Crown drop - GFB.Add(ModContent.ItemType(), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Corruption World OR Drunk World: Corruption Lore LeadingConditionRule bocCorruptionLore = new(DropHelper.If(() => (!WorldGen.crimson || WorldGen.drunkWorldGen) && !NPC.downedBoss2, desc: DropHelper.FirstKillText)); @@ -1109,8 +1232,8 @@ namespace CalamityMod.NPCs } catch (ArgumentNullException) { } - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BoneHelm)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BoneHelm)); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1132,9 +1255,10 @@ namespace CalamityMod.NPCs // Define a replacement rule which drops the weapons Calamity style. npcLoot.AddNormalOnly(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, ItemID.BeeKeeper, ItemID.BeesKnees, ItemID.BeeGun, ModContent.ItemType())); - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.HiveBackpack)); - npcLoot.AddNormalOnly(ModContent.ItemType(), 10); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.HiveBackpack)); + + npcLoot.AddNormalOnly(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1147,8 +1271,8 @@ namespace CalamityMod.NPCs rev.Add(ItemID.QueenBeePetItem, 4); // GFB Lavaproof Bug Net and Alchemical Flask drop - GFB.Add(ItemID.FireproofBugNet, hideLootReport: true); - GFB.Add(ModContent.ItemType(), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FireproofBugNet), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedQueenBee, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1167,8 +1291,8 @@ namespace CalamityMod.NPCs }; npcLoot.Add(new DropOneByOne(ItemID.Bone, skeletronBoneSpray)); - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BoneGlove)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.BoneGlove)); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1178,7 +1302,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.SkeletronPetItem, 4); // GFB Flamethrower drop - GFB.Add(ItemID.Flamethrower, hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.Flamethrower), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedBoss3, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1200,6 +1324,7 @@ namespace CalamityMod.NPCs var wofWeapons = new int[] { ItemID.BreakerBlade, + ModContent.ItemType(), ItemID.ClockworkAssaultRifle, ModContent.ItemType(), ItemID.LaserRifle, @@ -1236,9 +1361,6 @@ namespace CalamityMod.NPCs } catch (ArgumentNullException) { } - // Would be in the bag otherwise - npcLoot.AddNormalOnly(ModContent.ItemType(), 10); - // Drop Hermit's Box directly for EACH player, regardles of Expert or not. 100% chance on first kill, 10% chance afterwards. // The special first kill rule is unlisted in the Bestiary LeadingConditionRule firstWoFKill = new(DropHelper.If(() => !Main.hardMode)); @@ -1260,8 +1382,8 @@ namespace CalamityMod.NPCs rev.Add(ItemID.WallOfFleshGoatMountItem, 4); // GFB Eye of Magnus and Flesh Wall drops - GFB.Add(ModContent.ItemType(), hideLootReport: true); - GFB.Add(ItemID.FleshBlockWall, hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FleshBlockWall), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !Main.hardMode, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1269,12 +1391,12 @@ namespace CalamityMod.NPCs break; case NPCID.QueenSlimeBoss: - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.VolatileGelatin)); - npcLoot.AddNormalOnly(ItemID.SoulofLight, 1, 15, 20); - npcLoot.AddNormalOnly(ItemID.PinkGel, 1, 15, 20); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.VolatileGelatin)); // Would be in the bag otherwise + npcLoot.AddNormalOnly(ItemID.SoulofLight, 1, 15, 20); + npcLoot.AddNormalOnly(ItemID.PinkGel, 1, 15, 20); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1282,7 +1404,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.QueenSlimePetItem, 4); // GFB Bottomless Shimmer Bucket drop - GFB.Add(ItemID.BottomlessShimmerBucket, hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.BottomlessShimmerBucket), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedQueenSlime, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1296,8 +1418,8 @@ namespace CalamityMod.NPCs // Define a replacement rule which respects the Early Hardmode Progression Rework. npcLoot.AddNormalOnly(ItemDropRule.ByCondition(DropHelper.HallowedBarsCondition, ItemID.HallowedBar, 1, 15, 30)); - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.MechanicalWagonPiece)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.MechanicalWagonPiece)); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1307,7 +1429,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.DestroyerPetItem, 4); // GFB Bloodworm drop - GFB.Add(ModContent.ItemType(), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedMechBoss1, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1337,9 +1459,9 @@ namespace CalamityMod.NPCs } catch (ArgumentNullException) { } - // Expert+ drops are also available on Normal. These are done manually due to Last Twin Standing. - npcLoot.AddIf((info) => !Main.expertMode && IsLastTwinStanding(info), ItemID.MechanicalWheelPiece); - npcLoot.AddIf((info) => !Main.expertMode && IsLastTwinStanding(info), ModContent.ItemType(), 10); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // These are done manually due to Last Twin Standing. + // npcLoot.AddIf((info) => !Main.expertMode && IsLastTwinStanding(info), ItemID.MechanicalWheelPiece); // Would be in the bag otherwise npcLoot.AddIf((info) => !Main.expertMode && IsLastTwinStanding(info), ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1349,7 +1471,9 @@ namespace CalamityMod.NPCs rev.AddIf((info) => IsLastTwinStanding(info), ItemID.TwinsPetItem, 4); // GFB The Eye of Cthulhu drop - GFB.AddIf((info) => IsLastTwinStanding(info), ItemID.TheEyeOfCthulhu, hideLootReport: true); + LeadingConditionRule TwinsKillGFB = new(DropHelper.If((info) => IsLastTwinStanding(info))); + TwinsKillGFB.Add(DropHelper.PerPlayer(ItemID.TheEyeOfCthulhu), hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(TwinsKillGFB); // Lore npcLoot.AddConditionalPerPlayer((info) => !NPC.downedMechBoss2 && IsLastTwinStanding(info), ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1363,8 +1487,8 @@ namespace CalamityMod.NPCs // Define a replacement rule which respects the Early Hardmode Progression Rework. npcLoot.AddNormalOnly(ItemDropRule.ByCondition(DropHelper.HallowedBarsCondition, ItemID.HallowedBar, 1, 15, 30)); - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.MechanicalBatteryPiece)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.MechanicalBatteryPiece)); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1374,7 +1498,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.SkeletronPrimePetItem, 4); // GFB Bone Wings drop - GFB.Add(ItemID.BoneWings, hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.BoneWings), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedMechBoss3, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1421,13 +1545,13 @@ namespace CalamityMod.NPCs } catch (ArgumentNullException) { } - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.SporeSac)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.SporeSac)); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), 10); npcLoot.AddNormalOnly(ModContent.ItemType(), 10); - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30)); + npcLoot.AddNormalOnly(DropHelper.PerPlayer(ModContent.ItemType(), 1, 30, 40)); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); // Master items drop in Revengeance @@ -1435,7 +1559,7 @@ namespace CalamityMod.NPCs rev.Add(ItemID.PlanteraPetItem, 4); // GFB Life Fruit drop - GFB.Add(ItemID.LifeFruit, 1, 1, 9999, true); + GFB.Add(DropHelper.PerPlayer(ItemID.LifeFruit, 1, 1, 9999), true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedPlantBoss, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1474,9 +1598,10 @@ namespace CalamityMod.NPCs } catch (ArgumentNullException) { } - // Expert+ drops are also available on Normal var normalOnly = npcLoot.DefineNormalOnlyDropSet(); - normalOnly.Add(DropHelper.PerPlayer(ItemID.ShinyStone)); + + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // normalOnly.Add(DropHelper.PerPlayer(ItemID.ShinyStone)); // Would be in the bag otherwise normalOnly.Add(ModContent.ItemType(), 1, 8, 10); @@ -1493,12 +1618,12 @@ namespace CalamityMod.NPCs rev.Add(ItemID.GolemPetItem, 4); // GFB Vision Potion drop - GFB.Add(ItemID.NightOwlPotion, 1, 1, 9999, true); - GFB.Add(ItemID.ShinePotion, 1, 1, 9999, true); - GFB.Add(ItemID.HunterPotion, 1, 1, 9999, true); - GFB.Add(ItemID.TrapsightPotion, 1, 1, 9999, true); - GFB.Add(ItemID.SpelunkerPotion, 1, 1, 9999, true); - GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); + GFB.Add(DropHelper.PerPlayer(ItemID.NightOwlPotion, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ItemID.ShinePotion, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ItemID.HunterPotion, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ItemID.TrapsightPotion, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ItemID.SpelunkerPotion, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 9999), true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedGolemBoss, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1571,10 +1696,10 @@ namespace CalamityMod.NPCs catch (ArgumentNullException) { } DukeEditFailed: -// Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.ShrimpyTruffle)); +// 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic +// npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.ShrimpyTruffle)); - // Would be in the bag otherwise +// Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), 10); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1583,28 +1708,26 @@ DukeEditFailed: rev.Add(ItemID.DukeFishronPetItem, 4); // GFB Old Die and Fish drop - GFB.Add(ModContent.ItemType(), hideLootReport: true); - GFB.Add(ItemID.Fish, hideLootReport: true); - GFB.Add(ItemID.FishBowl, hideLootReport: true); - GFB.Add(ItemID.FishCostumeFinskirt, hideLootReport: true); - GFB.Add(ItemID.FishCostumeMask, hideLootReport: true); - GFB.Add(ItemID.FishCostumeShirt, hideLootReport: true); - GFB.Add(ItemID.FishermansGuide, hideLootReport: true); - GFB.Add(ItemID.FisherofSouls, hideLootReport: true); - GFB.Add(ItemID.FishFinder, hideLootReport: true); - GFB.Add(ItemID.FishHook, hideLootReport: true); - GFB.Add(ItemID.FishingBobber, hideLootReport: true); - GFB.Add(ItemID.FishingPotion, 1, 1, 9999, true); - GFB.Add(ItemID.FishingSeaweed, 1, 1, 9999, true); - GFB.Add(ItemID.FishMinecart, hideLootReport: true); - GFB.Add(ItemID.Fishotron, hideLootReport: true); - GFB.Add(ItemID.Fishron, hideLootReport: true); - GFB.Add(ItemID.FishStatue, 1, 1, 9999, true); - GFB.Add(ModContent.ItemType(), hideLootReport: true); - GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); - GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); - GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); - GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.Fish), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishBowl), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishCostumeFinskirt), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishCostumeMask), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishCostumeShirt), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishermansGuide), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FisherofSouls), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishFinder), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishHook), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishingBobber), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishingPotion, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishingSeaweed, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishMinecart), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.Fishotron), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.Fishron), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ItemID.FishStatue, 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 9999), true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedFishron, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1629,7 +1752,6 @@ DukeEditFailed: ItemID.FairyQueenRangedItem, // Eventide ItemID.FairyQueenMagicItem, // Nightglow ItemID.SparkleGuitar, // Stellar Tune - ItemID.EmpressBlade, // Terraprisma ItemID.RainbowWhip, // Kaleidoscope ItemID.RainbowWings // Empress Wings }; @@ -1645,8 +1767,8 @@ DukeEditFailed: } catch (ArgumentNullException) { } - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.EmpressFlightBooster)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.EmpressFlightBooster)); // Would be in the bag otherwise npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1655,9 +1777,9 @@ DukeEditFailed: rev.Add(ItemID.FairyQueenMasterTrophy); rev.Add(ItemID.FairyQueenPetItem, 4); - // GFB Cirrus' Vodka and Terraformer drop - GFB.Add(ModContent.ItemType(), 1, 1, 9999, true); - GFB.Add(ItemID.Clentaminator2, hideLootReport: true); + // GFB Purple Haze and Terraformer drop + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 9999), true); + GFB.Add(DropHelper.PerPlayer(ItemID.Clentaminator2), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedEmpressOfLight, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1672,7 +1794,7 @@ DukeEditFailed: npcLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // GFB Luminite Brick drop - GFB.Add(ItemID.LunarBrick, 1, 1, 9999, true); + GFB.Add(DropHelper.PerPlayer(ItemID.LunarBrick, 1, 1, 9999), true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedAncientCultist, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1708,12 +1830,13 @@ DukeEditFailed: } catch (ArgumentNullException) { } - // Expert+ drops are also available on Normal - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.GravityGlobe)); - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.SuspiciousLookingTentacle)); - npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.LongRainbowTrailWings)); + // 16NOV2025: Ozzatron: following overwhelming dev vote, Expert+ drops are NOT available in Classic + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.GravityGlobe)); + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.SuspiciousLookingTentacle)); + // npcLoot.AddNormalOnly(DropHelper.PerPlayer(ItemID.LongRainbowTrailWings)); // Would be in the bag otherwise + // 16NOV2025: Ozzatron (executive decision): Celestial Onion remains available as a 6th slot in Classic. npcLoot.AddNormalOnly(DropHelper.PerPlayer(ModContent.ItemType())); npcLoot.AddNormalOnly(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1722,7 +1845,7 @@ DukeEditFailed: rev.Add(ItemID.MoonLordPetItem, 4); // GFB Calamari's Lament drop - GFB.Add(ModContent.ItemType(), hideLootReport: true); + GFB.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !NPC.downedMoonlord, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1732,58 +1855,18 @@ DukeEditFailed: break; #endregion } - //If the enemy is part of a list (Hornets, Skeletons, etc,) place it here as in the section before it no longer works + //If the enemy is part of a list, place it here as in the section before it no longer works #region Enemy Lists - - // All Moss Hornets - // Needler @ 4% Normal, 6.67% Expert+ - if (MossHornetIDList.Includes(npc.type)) - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 25, 15)); - // All Skeletons // Ancient Bone Dust @ 20% Normal, 33.33% Expert+ - if (SkeletonIDList.Includes(npc.type)) + if (CalamityNPCTypeSets.Skeleton[npc.type]) npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 5, 3)); // All Hardmode Dungeon Enemies // Ectoplasm @ 20% - if (BuffedDungeonEnemiesList.Includes(npc.type)) + if (CalamityNPCSets.IsBuffedDungeonEnemy[npc.type]) npcLoot.Add(ItemID.Ectoplasm, 5); #endregion - - // Blanket remove all specific food item drops that have changed obtainment methods in Calamity - // This is type-indiscriminate and will also most probably hit modded NPCs too - - // CIT 7NOV2024: Yeah it hits modded NPCs; in fact it removes GFB drops from Ravager and Deus - // Fixing this by making the code only run if the NPC is not a boss - if (!npc.boss) - { - int[] randomFoodItems = new int[] -{ - ItemID.ApplePie, - ItemID.BananaSplit, - ItemID.BBQRibs, - ItemID.Burger, - ItemID.MilkCarton, - ItemID.ChocolateChipCookie, - ItemID.CoffeeCup, - ItemID.CreamSoda, - ItemID.FriedEgg, - ItemID.Fries, - ItemID.Grapes, - ItemID.Hotdog, - ItemID.IceCream, - ItemID.Milkshake, - ItemID.Nachos, - ItemID.Pizza, - ItemID.PotatoChips, - ItemID.ShrimpPoBoy, - ItemID.Spaghetti, - ItemID.Steak -}; - foreach (int foodItemID in randomFoodItems) - npcLoot.RemoveWhere((rule) => rule is ItemDropWithConditionRule foodRule && foodRule.itemId == foodItemID); - } } #endregion @@ -1815,7 +1898,7 @@ DukeEditFailed: public override bool PreKill(NPC npc) { // Stop Eater of Worlds segments and Brain of Cthulhu Creepers from dropping partial loot in Rev+ - if (CalamityWorld.revenge && (EaterOfWorldsIDList.Includes(npc.type) || npc.type == NPCID.Creeper)) + if (CalamityWorld.revenge && (CalamityNPCTypeSets.EaterOfWorlds.Contains(npc.type) || npc.type == NPCID.Creeper)) DropHelper.BlockDrops(ItemID.DemoniteOre, ItemID.ShadowScale, ItemID.CrimtaneOre, ItemID.TissueSample); // Boss Rush pre-kill effects @@ -1842,14 +1925,6 @@ DukeEditFailed: if (AcidRainEvent.AcidRainEventIsOngoing) AcidRainEvent.OnEnemyKill(npc); - // Stop Death Mode splitting worms from dropping excessive loot - if (CalamityWorld.death && !SplittingWormLootBlockWrapper(npc, Mod)) - DropHelper.BlockEverything(); - - // Correctly increment bestiary entries for splitting worms - if (npc.AnyInteractions()) - SplittingWormBestiaryUpdate(npc); - // Determine whether this NPC is the second Twin killed in a fight, regardless of which Twin it is. bool lastTwinStanding = false; if (npc.type == NPCID.Retinazer) @@ -1898,12 +1973,12 @@ DukeEditFailed: World.Abyss.UnlockAllAbyssChests(); } string keysk = "Mods.CalamityMod.Status.Progression.SkeletronAbyssChestNotification"; - CalamityUtils.DisplayLocalizedText(keysk, new Color(76, 181, 76)); + CalamityUtils.BroadcastLocalizedText(keysk, new Color(76, 181, 76)); } break; case NPCID.WallofFlesh: - SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Painter, NPCID.WitchDoctor, NPCID.Stylist, NPCID.DyeTrader, NPCID.Demolitionist, NPCID.PartyGirl, NPCID.Clothier, NPCID.SkeletonMerchant, NPCID.BestiaryGirl }, Main.hardMode); + SetNewShopVariable(new int[] { NPCID.Merchant, NPCID.ArmsDealer, NPCID.Dryad, NPCID.Painter, NPCID.WitchDoctor, NPCID.Stylist, NPCID.DyeTrader, NPCID.Demolitionist, NPCID.PartyGirl, NPCID.Clothier, NPCID.SkeletonMerchant }, Main.hardMode); SetNewBossJustDowned(npc); if (!Main.hardMode && !BossRushEvent.BossRushActive) @@ -1914,7 +1989,7 @@ DukeEditFailed: string key2 = "Mods.CalamityMod.Status.Progression.UglyBossText"; Color messageColor2 = Color.Aquamarine; - CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.BroadcastLocalizedText(key2, messageColor2); } break; @@ -1930,7 +2005,7 @@ DukeEditFailed: case NPCID.TheDestroyer: SetNewShopVariable(new int[] { NPCID.Demolitionist, NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle }, NPC.downedMechBossAny); - SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3); + SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3); SetNewBossJustDowned(npc); if (!NPC.downedMechBoss1 && CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) @@ -1942,7 +2017,7 @@ DukeEditFailed: if (lastTwinStanding) { SetNewShopVariable(new int[] { NPCID.Demolitionist, NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle }, NPC.downedMechBossAny); - SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || NPC.downedMechBoss2 || !NPC.downedMechBoss3); + SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || NPC.downedMechBoss2 || !NPC.downedMechBoss3); SetNewBossJustDowned(npc); if (!NPC.downedMechBoss2 && CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) @@ -1952,7 +2027,7 @@ DukeEditFailed: case NPCID.SkeletronPrime: SetNewShopVariable(new int[] { NPCID.Demolitionist, NPCID.DD2Bartender, NPCID.Stylist, NPCID.Truffle }, NPC.downedMechBossAny); - SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || !NPC.downedMechBoss2 || NPC.downedMechBoss3); + SetNewShopVariable(new int[] { NPCID.Stylist, ModContent.NPCType(), ModContent.NPCType() }, !NPC.downedMechBoss1 || !NPC.downedMechBoss2 || NPC.downedMechBoss3); SetNewBossJustDowned(npc); if (!NPC.downedMechBoss3 && CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) @@ -1960,7 +2035,7 @@ DukeEditFailed: break; case NPCID.Plantera: - SetNewShopVariable(new int[] { NPCID.WitchDoctor, NPCID.Truffle, NPCID.BestiaryGirl, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedPlantBoss); + SetNewShopVariable(new int[] { NPCID.WitchDoctor, NPCID.Truffle, NPCID.BestiaryGirl, ModContent.NPCType() }, NPC.downedPlantBoss); SetNewBossJustDowned(npc); // Spawn Perennial Ore if Plantera has never been killed @@ -1974,8 +2049,8 @@ DukeEditFailed: // TODO -- this should probably be moved to a thread like Aureus meteor CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.65f, 0.85f, 5, 10, TileID.Dirt, TileID.Stone); - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.BroadcastLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key2, messageColor2); } break; @@ -1996,7 +2071,7 @@ DukeEditFailed: break; case NPCID.Golem: - SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Cyborg, NPCID.Steampunker, NPCID.Wizard, NPCID.WitchDoctor, NPCID.DD2Bartender, ModContent.NPCType(), ModContent.NPCType() }, NPC.downedGolemBoss); + SetNewShopVariable(new int[] { NPCID.ArmsDealer, NPCID.Cyborg, NPCID.Steampunker, NPCID.Wizard, NPCID.WitchDoctor, NPCID.DD2Bartender, ModContent.NPCType() }, NPC.downedGolemBoss); SetNewBossJustDowned(npc); // If Golem has never been killed, send a message about the Plague. @@ -2008,7 +2083,7 @@ DukeEditFailed: string key3 = "Mods.CalamityMod.Status.Progression.BabyBossText"; Color messageColor3 = Color.Lime; - CalamityUtils.DisplayLocalizedText(key3, messageColor3); + CalamityUtils.BroadcastLocalizedText(key3, messageColor3); } break; @@ -2063,9 +2138,9 @@ DukeEditFailed: // Spawn Exodium planetoids and send messages about Providence, Exodium, and Necroplasm if ML has not been killed yet if (!NPC.downedMoonlord) { - CalamityUtils.DisplayLocalizedText(key5, messageColor5); - CalamityUtils.DisplayLocalizedText(key6, messageColor6); - CalamityUtils.DisplayLocalizedText(key7, messageColor7); + CalamityUtils.BroadcastLocalizedText(key5, messageColor5); + CalamityUtils.BroadcastLocalizedText(key6, messageColor6); + CalamityUtils.BroadcastLocalizedText(key7, messageColor7); } } break; @@ -2083,7 +2158,7 @@ DukeEditFailed: Color messageColor = new Color(50, 255, 130); CalamityUtils.SpawnOre(TileID.Mythril, 12E-05, 0.55f, 0.8f, 3, 8); CalamityUtils.SpawnOre(TileID.Orichalcum, 12E-05, 0.55f, 0.8f, 3, 8); - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) { @@ -2091,132 +2166,16 @@ DukeEditFailed: Color messageColor = new Color(50, 255, 130); CalamityUtils.SpawnOre(TileID.Adamantite, 12E-05, 0.65f, 0.9f, 3, 8); CalamityUtils.SpawnOre(TileID.Titanium, 12E-05, 0.65f, 0.9f, 3, 8); - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } else { string key = "Mods.CalamityMod.Status.Progression.HardmodeOreTier4Text"; Color messageColor = new Color(50, 255, 130); CalamityUtils.SpawnOre(ModContent.TileType(), 17E-05, 0.55f, 0.9f, 8, 14, TileID.Pearlstone, TileID.HallowHardenedSand, TileID.HallowSandstone, TileID.HallowedIce); - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } } #endregion - - #region Splitting Worm Loot - internal static void SplittingWormBroadcastInteractionWrapper(NPC npc, int player) - { - if (!CalamityWorld.death) - return; - - switch (npc.type) - { - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - SplittingWormBroadcastInteraction(npc, player, NPCID.DiggerHead, NPCID.DiggerBody, NPCID.DiggerTail); - return; - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - SplittingWormBroadcastInteraction(npc, player, NPCID.SeekerHead, NPCID.SeekerBody, NPCID.SeekerTail); - return; - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - SplittingWormBroadcastInteraction(npc, player, NPCID.DuneSplicerHead, NPCID.DuneSplicerBody, NPCID.DuneSplicerTail); - return; - } - } - - internal static void SplittingWormBroadcastInteraction(NPC npc, int player, int head, int body, int tail) - { - foreach (NPC n in Main.ActiveNPCs) - { - if (n.whoAmI != npc.whoAmI && (n.type == head || n.type == body || n.type == tail)) - { - n.ApplyInteraction(player); - } - } - } - - internal static void SplittingWormBestiaryUpdate(NPC npc) - { - if (!CalamityWorld.death) - return; - - switch (npc.type) - { - case NPCID.DiggerBody: - case NPCID.DiggerTail: - NPC diggerHead = new(); - diggerHead.SetDefaults(NPCID.DiggerHead); - Main.BestiaryTracker.Kills.RegisterKill(diggerHead); - return; - case NPCID.SeekerBody: - case NPCID.SeekerTail: - NPC seekerHead = new(); - seekerHead.SetDefaults(NPCID.SeekerHead); - Main.BestiaryTracker.Kills.RegisterKill(seekerHead); - return; - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - NPC duneSplicerHead = new(); - duneSplicerHead.SetDefaults(NPCID.DuneSplicerHead); - Main.BestiaryTracker.Kills.RegisterKill(duneSplicerHead); - return; - } - } - - internal static bool SplittingWormLootBlockWrapper(NPC npc, Mod mod) - { - if (!CalamityWorld.death) - return true; - - switch (npc.type) - { - case NPCID.DiggerHead: - case NPCID.DiggerBody: - case NPCID.DiggerTail: - return SplittingWormLoot(npc, mod, 0); - case NPCID.SeekerHead: - case NPCID.SeekerBody: - case NPCID.SeekerTail: - return SplittingWormLoot(npc, mod, 1); - case NPCID.DuneSplicerHead: - case NPCID.DuneSplicerBody: - case NPCID.DuneSplicerTail: - return SplittingWormLoot(npc, mod, 2); - default: - return true; - } - } - - internal static bool SplittingWormLoot(NPC npc, Mod mod, int wormType) - { - switch (wormType) - { - case 0: return CheckSegments(NPCID.DiggerHead, NPCID.DiggerBody, NPCID.DiggerTail); - case 1: return CheckSegments(NPCID.SeekerHead, NPCID.SeekerBody, NPCID.SeekerTail); - case 2: return CheckSegments(NPCID.DuneSplicerHead, NPCID.DuneSplicerBody, NPCID.DuneSplicerTail); - default: - break; - } - - bool CheckSegments(int head, int body, int tail) - { - foreach (NPC n in Main.ActiveNPCs) - { - if (n.whoAmI != npc.whoAmI && (n.type == head || n.type == body || n.type == tail)) - { - return false; - } - } - return true; - } - - return true; - } - #endregion } } diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index ccf0720218..4ebe48254c 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; using CalamityMod.Events; -using CalamityMod.Items; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Ammo; -using CalamityMod.Items.Armor; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Dyes; using CalamityMod.Items.Dyes.HairDye; @@ -13,7 +12,9 @@ using CalamityMod.Items.Placeables.Astral; using CalamityMod.Items.Placeables.Crags; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Placeables.Furniture.Fountains; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Potions; +using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.SummonItems.Invasion; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -25,6 +26,7 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Enums; using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; @@ -33,46 +35,70 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs { - public partial class CalamityGlobalNPC : GlobalNPC + public class CalamityGlobalTownNPC : GlobalNPC { public static float TaxYieldFactor { get { - // Max of 20 platinum. - if (DownedBossSystem.downedYharon) - return 40f; - - // Max of 10 platinum. + // 10 silver per NPC, max of 5 platinum. if (DownedBossSystem.downedDoG) - return 20f; - - // Max of 5 platinum. - if (NPC.downedMoonlord) return 10f; - // Max of 2 platinum. + // 8 silver per NPC, max of 4 platinum. + if (NPC.downedMoonlord) + return 8f; + + // 2 silver per NPC, max of 1 platinum. if (NPC.downedPlantBoss) - return 4f; + return 2f; return 1f; } } - public static int TotalTaxesPerNPC => (int)(Item.buyPrice(0, 0, 1, 50) * TaxYieldFactor); + // Vanilla: 50 copper + public static int TotalTaxesPerNPC => (int)(Item.buyPrice(silver: 1) * TaxYieldFactor); - public static int TaxesToCollectLimit => (int)(Item.buyPrice(0, 50, 0, 0) * TaxYieldFactor); + // Vanilla: 25 gold + public static int TaxesToCollectLimit => (int)(Item.buyPrice(gold: 50) * TaxYieldFactor); + + + /// Used for allowing Patreon names for Town NPCs. + public bool setNewName = true; + /// Used to control the animation of the Town NPC Shop Alert icon, if the respective config is enabled. + public int shopAlertAnimTimer = 0; + /// + public int shopAlertAnimFrame = 0; + + public override bool InstancePerEntity => true; + + public override bool AppliesToEntity(NPC entity, bool lateInstantiation) + { + return entity.isLikeATownNPC; + } + + public override GlobalNPC Clone(NPC npc, NPC npcClone) + { + CalamityGlobalTownNPC myClone = (CalamityGlobalTownNPC)base.Clone(npc, npcClone); + + myClone.setNewName = setNewName; + myClone.shopAlertAnimTimer = shopAlertAnimTimer; + myClone.shopAlertAnimFrame = shopAlertAnimFrame; + + return myClone; + } #region Town NPC Patreon Name Sets private static readonly string[] AnglerNames = - { + [ "Dazren", "Johnny Test", // <@!589966747977777197> (konorango) "Bling Bling Boy", // <@!522970788203069442> (phallguy) - }; + "RICE", // <@!400107830889152524> (rice_xd.) + ]; private static readonly string[] ArmsDealerNames = - { - "Drifter", + [ "Finchi", "Heniek", // <@!363404700445442050> (kazurgundu) "Fire", // <@!354362326947856384> (ultimatefirewaster) @@ -82,34 +108,38 @@ namespace CalamityMod.NPCs "The Cooler Arthur", // <@!568263512523014154> (gokuartillery) "Shark", // <@!874464051697172492> (congratsistrash) "Sagi", // <@!508233115781693441> (sagittariod) - }; + ]; private static readonly string[] ClothierNames = - { + [ "Joeseph Jostar", "Storm Havik", // <@!1013452363178197072> (fishnotduck) - }; + "Magorfis Splunt the Greater Finklejim", // <@!147490809334333440> (eidolbyssus) + "Perrin", // <@!253764551139393537> (easyperrin) + ]; private static readonly string[] CyborgNames = - { + [ "Sylux", // <@!331812782183809025> (gonkachino) - "XL-39 Nemesis", // <@!1104036024063107082> (yashimayamanata) - }; + "Nemesis", // <@!1104036024063107082> (yashimayamanata) + "Univerze", // <@!1256376346536448150> (unizumi02) + ]; private static readonly string[] DemolitionistNames = - { + [ "Tavish DeGroot", // <@!442447226992721930> (magicoal) "Fimmy", // <@!407348617079160832> (darkmega5) - "Dorira", // <@!215269032360804352> (crimsoncb) - }; + "John Helldiver", // <@!614126424751603714> (exellent.) + ]; private static readonly string[] DryadNames = - { + [ "Rythmi", "Izuna", "Jasmine", // <@!430532867479699456> (phantasmagoria.) "Cybil", // <@!486507232666845185> (Captain Doofus#????) "Ruth", // <@!1001307586068492388> (briny_coffee) - }; + "Kanna", // <@!730203712898859018> (cosmoredeathwish) + ]; private static readonly string[] DyeTraderNames = null; private static readonly string[] GoblinTinkererNames = - { + [ "Verth", "Gormer", // <@!287651204924833795> (picassosbean2819 -- RIP) "TingFlarg", // <@!185605031716847616> (smugggo) @@ -120,10 +150,13 @@ namespace CalamityMod.NPCs "Him", // <@!931019614958256139> (himtheguy1) "Tooshiboots", // <@!333532730593771522> (ulmod) "Neesh", // <@!175803493464932352> (xjetty) - }; + "Bars Boldia", // <@!332989575708540939> (careless_imp) + "Basel Raiden John Clive Fantasy 16", // <@!529392083136413696> (raiden_ii) + "Gobby, Destroyer of Wallets", // <@!429024941296582658> (bwlstorm) + ]; private static readonly string[] GolferNames = null; private static readonly string[] GuideNames = - { + [ "Lapp", "Ben Shapiro", "Streakist", // used to be "StreakistYT". couldn't find the youtube channel, and decided to remove the ad. @@ -139,113 +172,138 @@ namespace CalamityMod.NPCs "Alfred Rend", // <@!606301806481375255> (deadsqurp300) "Leeman", // <@!281999243168841728> (tweee) "Mihai", // <@!373941893467209730> (cmihaii.) - "Cooler Kevin", // <@!614126424751603714> (exellent.) "Dinkleberg", // <@!581993958037520404> (hyperionzx) - }; + "Wamy", // Fab added this name with no Discord ID. May be a donor who has no Discord account. + "Baggute", // <@!535140564174110720> (thebaggutegamer) + "Jacob Bryson", // <@!879794107218817026> (.melongun) + ]; private static readonly string[] MechanicNames = - { + [ "Lilly", "Daawn", // <@!206162323541458944> (daawnily) "Robin", // <@!654737510030639112> (altzeus) "Curly", // <@!673092101780668416> (curly4830) "Cobalt", // <@!132962828922388481> (cobalt_44) - }; + "Dizzetriya", // <@!719818245665980517> (dizzykbity) + ]; private static readonly string[] MerchantNames = - { + [ "Morshu", // <@!194931581826236416> (uberransy) - }; + "Spamton G. Spamton", // <@!497146350438318101> (j.u.n.e.s) + ]; private static readonly string[] NurseNames = - { + [ "Farsni", "Fanny", // <@!799749125720637460> (zombiewolf511) "Mausi", // <@!194156349347594241> (sadouken) "Fiona", // <@!475216964168450048> (thatgayguy69) - }; + ]; private static readonly string[] PainterNames = - { + [ "Picasso", // <@!353316526306361347> (sconicboom -- for the late picassosbean2819) "Bew", // <@!232291351167893505> (dmshi) - }; + ]; private static readonly string[] PartyGirlNames = - { + [ "Arin", // <@!268169458302976012> (kiyotu) "Typhäne", // <@!222064016107896832> (typhane.) - }; + "Charlotte Linlin", // <@!563406464522125323> (vixcalibur) + ]; private static readonly string[] PirateNames = - { + [ "Tyler Van Hook", "Cap'n Deek", // "Alex N" on Patreon (No discord account) "Captain Billy Bones", // <@!699589229507772416> (djackv) "Captain J. Crackers", // <@!233232602994049024> (qyuuno) "Gol D. Roger", // <@!256228859110752257> (xtra3678) - }; + "Yarrim", // <@!290061123137306624> (borb9834) + "Hector Barbossa", // <@!615704209303797790> (thatrockisfullamagic) + "Blunderbeard", // <@!1039460813490102293> (parmiigianoreggiano) + "Vergil Cyrus", // <@!732350101619605584> (cyver1) + ]; private static readonly string[] PrincessNames = - { - "Catalyst", // <@!156672312425316352> (xaqult) + [ "Nyapano", // <@!120976656826368003> (nyapano) "Jade", // <@!187395834625785869> (verymasterninja) "Nyavi Aceso", // <@!270260920888852480> (navigator.) "everquartz", // <@!451343554451865611> (everquartz) "Gwynevere", // <@!142752927348424704> (nuclearchaosazathoth) "Hael", // <@!641747280944431156> (kalebtull) - }; + "Yumesaki Mirrin", // <@!100235144744415232> (milinen) + "Vela", // <@!208719047146209281> (nyxxynightstar) + "Misako Drevis", // <@!1103067115386323065> (threadsofmemory) + ]; private static readonly string[] SantaClausNames = - { + [ "Jank", // <@!339950757472239616> (jankle_) - }; + "Aoi Kurashiki", // <@!358411687885537291> (nothinpurrsonal) + ]; private static readonly string[] SkeletonMerchantNames = - { - "Sans Undertale", // <@!145379091648872450> (shayy) + [ + "Sans Undertale", // <@!534770496038895616> (done_22_) "Papyrus Undertale", // <@!262663471189983242> (nycro) "Mr. Bones", // <@!359215912856977408> (jaybones.) - }; + "Freakbob", // <@!377863128140087296> (jevilamv) + ]; private static readonly string[] SteampunkerNames = - { + [ "Vorbis", "Angel", "Mòrag Ladair", // <@!161893929485074432> (jalapeno9) "Linn", // <@!277983612383526913> (duckycolors) "Eira", // <@!1166136068408623234> (taela_gemetha) - }; + "Kreutz", // <@!553445849149997056> (red_r_kreutz) + "Cathlyn", // <@!156672312425316352> (xaqult) + "Eunice", // <@!358376627400605699> (srmg267) + ]; private static readonly string[] StylistNames = - { + [ "Amber", // <@!114677116473180169> (mishirousui) "Faith", // <@!509050283871961123> (toasty1007) "Xsiana", // <@!625780237489143839> (lokistic) "Lain", // <@!655201622863118337> (literallyadeerfr) - }; + "Hamis", // <@!608455754093035521> (haefer) + "Brio Scarlet", // <@!358576903701004289> (brio_scarlet) + "Vanessa", // <@!638901548591611945> (mediocreking) + ]; private static readonly string[] TavernkeepNames = - { + [ "Tim Lockwood", // <@!605839945483026434> (pomvoid) "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (ryaegos) "Brutus", // <@!591889650692521984> (.brutus._) "Sloth", // <@!486265327387279391> (bossypunch) - }; + ]; private static readonly string[] TaxCollectorNames = - { + [ "Emmett", - }; + "Bagman", // <@!701831892990820383> (supportcrispy) + ]; private static readonly string[] TravelingMerchantNames = - { + [ "Stan Pines", - "Slap Battles", // <@!923504188615450654> (gravityglider.) + "Intergaze", // <@!923504188615450654> (intergaze) "Borgus", // <@!539127427482255376> (therealmeepman) - }; + "Postman Hiss", // <@!454638106122125312> (karinthefairy) + "Cosmoec", // <@!793660591449309204> (cosmoecark) + "Junorism", // <@!740625002596008036> (hewhoshallnotbebaned) + ]; private static readonly string[] TruffleNames = - { + [ "Aldrimil", // <@!413719640238194689> (Thorioum#2475) - }; + "Wonton", // <@!1198092982923043040> (imonthatgudkush) + "Mad Lad", // <@!215269032360804352> (crimsoncb) + "Nokko", // <@!706732954079985745> (violet.prime) + ]; private static readonly string[] WitchDoctorNames = - { + [ "Sok'ar", - "Toxin", // <@!348174404984766465> (Toxin#9598), + "Aeroni", // <@!348174404984766465> (aeroni) (previously: toxin) "Mixcoatl", // <@!284775927294984203> (.sharzz) - "Khatunz", // <@!303022375191183360> (jackshiz) "Amnesia Wapers", // <@!326821498323075073> (retardedadvicefromaretard) - }; + "Tequila", // <@!889175547744239677> (thecrispistofnuggets) + ]; private static readonly string[] WizardNames = - { - "Mage One-Trick", // <@!340996105460514816> (pixlgray) + [ "Inorim, son of Ivukey", "Jensen", "Merasmus", // <@!288066987819663360> (spiderprovidence) @@ -254,14 +312,32 @@ namespace CalamityMod.NPCs "Chris Tallballs", // <@!770211589076418571> (vysterx) (previously: bewearium) "Syethas", // <@!325413275066171393> (cosmicstariight) "Nextdoor Psycho", // <@!173261518572486656> (nextdoorpsycho) - }; + "Mike Cyclops", // <@!702327497475227741> (seichoseicho) + "Derin", // <@!466703979695308820> (god_15) + "Umbara", // <@!450062421294579712> (umbaraeclipse) + ]; private static readonly string[] ZoologistNames = - { + [ "Kiriku", // <@!395312478160027668> (rulosss) "Lacuna", // <@!790746689211203604> (_lacuna_) "Mae Borowski", //<@!219158690433990656> (justakkolite) "Fera", // <@!195850711567826945> (juneark_) - }; + "Gwenhwyvar", // <@!291342874497515531> (diamondnife) + "Daxie", // <@!465438861103988737> (daxie626) + ]; + // Town Slimes + private static readonly string[] ClumsySlimeNames = null; + private static readonly string[] CoolSlimeNames = null; + private static readonly string[] DivaSlimeNames = null; + private static readonly string[] ElderSlimeNames = null; + private static readonly string[] MysticSlimeNames = null; + private static readonly string[] NerdySlimeNames = + [ + "Big Blungus", // <@!272759434282008577> (schmoov) + "Rimuru Tempest", // <@!806463201398358036> (c0d3_404) + ]; + private static readonly string[] SquireSlimeNames = null; + private static readonly string[] SurlySlimeNames = null; // The following sets are for the 1.4 Town Pets: Town Dogs, Cats and Bunnies. // All three pet types come in numerous breeds. Each breed has its own name pool. @@ -274,27 +350,35 @@ namespace CalamityMod.NPCs private const int TownDogDalmatianVanillaNames = 13; private const int TownDogHuskyVanillaNames = 16; private static readonly string[] TownDogNames = - { + [ "Ozymandias", // <@!146333264871686145> (ozzatron) - }; + "Miss Throws a Lot", // <@!799345607847182400> (oakhamsam) + "Brikwilla", // <@!543803736909414438> (lavendercobra) + ]; private static readonly string[] TownDogLabradorNames = - { + [ "Riley", // <@!260875558592708619> (potionpal) - }; + "Silvie", // <@!979862425211912242> (goldsockz2) + "Madison", // <@!338315261352476682> (tyeski) + ]; private static readonly string[] TownDogPitBullNames = - { + [ "Splinter", // <@!320320801213775873> (kaimonick) - }; + ]; private static readonly string[] TownDogBeagleNames = - { + [ "Kendra", // <@!237247188005158912> (lordmetarex) - }; + "Libby", // <@!338315261352476682> (tyeski) + "Myles", // <@!658760860722004017> (apotofkoolaid) + "Luna", // <@!534132902095749120> (mizzultraviolet) + ]; private static readonly string[] TownDogCorgiNames = null; private static readonly string[] TownDogDalmatianNames = null; private static readonly string[] TownDogHuskyNames = - { + [ "Yoshi", // <@!541127291426832384> (gregthespinarak) - }; + "Franklin", // <@!338315261352476682> (tyeski) + ]; private const int TownCatSiameseVanillaNames = 12; private const int TownCatBlackVanillaNames = 23; @@ -303,27 +387,46 @@ namespace CalamityMod.NPCs private const int TownCatSilverVanillaNames = 17; private const int TownCatWhiteVanillaNames = 15; private static readonly string[] TownCatNames = - { + [ "Smoogle", // <@!709968379334623274> (smooglin) "The Meowurer of Gods", // <@!385949114271268864> (thatgp) "Katsafaros", // <@!190595401328492544> (gr_mm) "Lucerne", // <@!271954788676141066> (lord_lucerne) "Milo", // <@!401849201597874179> (maskedmilo) "Octo", // <@!796112889353994281> (octolinggrimm) - "Chease", // <@!1039460813490102293> (parmiigianoreggiano) - }; - private static readonly string[] TownCatSiameseNames = null; + ]; + private static readonly string[] TownCatSiameseNames = + [ + "Conductor", // <@!555512087711973390> (grayaeternum) + "Vivian", // <@!338315261352476682> (TYESKI) + "Pudum", // <@!731141759484297226> (trianglepixel) + "Snickers", // <@!658760860722004017> (apotofkoolaid) + "Mr. Kitten", // <@!658760860722004017> (apotofkoolaid) + ]; private static readonly string[] TownCatBlackNames = - { + [ "Bear", // <@!183424826407518208> (lilac_vrt_olligoci) - }; + "Storm", // <@!620383533516718085> (airwaveslr) + "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) + "Saffie", // <@!319753595161411584> (CDMusic) + "Willow", // <@!319753595161411584> (CDMusic) + "Maine", // <@!731141759484297226> (trianglepixel) + ]; private static readonly string[] TownCatOrangeTabbyNames = - { + [ "Felix", // <@!183424826407518208> (lilac_vrt_olligoci) "Tardo", // <@!739343546867384391> (midnight295) - }; + "Dali", // <@!460238880436781061> (darthlego) + "Kiba", // <@!852348657072340992> (jollydragonslayer) + "Monkey", // <@!338315261352476682> (TYESKI) + "Percy", // <@!658760860722004017> (apotofkoolaid) + ]; private static readonly string[] TownCatRussianBlueNames = null; - private static readonly string[] TownCatSilverNames = null; + private static readonly string[] TownCatSilverNames = + [ + "Archie", // <@!303022375191183360> (jackshiz) + "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) + ]; private static readonly string[] TownCatWhiteNames = null; private const int TownBunnyWhiteVanillaNames = 14; @@ -332,7 +435,11 @@ namespace CalamityMod.NPCs private const int TownBunnyFlemishVanillaNames = 12; private const int TownBunnyLopVanillaNames = 13; private const int TownBunnySilverVanillaNames = 13; - private static readonly string[] TownBunnyNames = null; + private static readonly string[] TownBunnyNames = + [ + "Poco", // <@!1192261996146593872> (tostitomuncher33) + "Puffer", // <@!181103507711983616> (piky) + ]; private static readonly string[] TownBunnyWhiteNames = null; private static readonly string[] TownBunnyAngoraNames = null; private static readonly string[] TownBunnyDutchNames = null; @@ -570,6 +677,32 @@ namespace CalamityMod.NPCs AddNewNames(nameList, ZoologistNames); break; + // Town Slimes + case NPCID.TownSlimePurple: // Clumsy Slime + AddNewNames(nameList, ClumsySlimeNames); + break; + case NPCID.TownSlimeGreen: // Cool Slime + AddNewNames(nameList, CoolSlimeNames); + break; + case NPCID.TownSlimeRainbow: // Diva Slime + AddNewNames(nameList, DivaSlimeNames); + break; + case NPCID.TownSlimeOld: // Elder Slime + AddNewNames(nameList, ElderSlimeNames); + break; + case NPCID.TownSlimeYellow: // Mystic Slime + AddNewNames(nameList, MysticSlimeNames); + break; + case NPCID.TownSlimeBlue: // Nerdy Slime + AddNewNames(nameList, NerdySlimeNames); + break; + case NPCID.TownSlimeCopper: // Squire Slime + AddNewNames(nameList, SquireSlimeNames); + break; + case NPCID.TownSlimeRed: // Surly Slime + AddNewNames(nameList, SurlySlimeNames); + break; + // This function doesn't work with Town Pets currently case NPCID.TownCat: AddNewNames(nameList, TownCatNames); @@ -656,6 +789,29 @@ namespace CalamityMod.NPCs } #endregion + #region SetDefaults + public override void SetDefaults(NPC npc) + { + BoundNPCSafety(Mod, npc); + } + #endregion + + #region PreAI + public override bool PreAI(NPC npc) + { + SetPatreonTownNPCName(npc, Mod); + return true; + } + #endregion + + #region PreDraw + public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + TownNPCAlertSystem(npc, Mod, spriteBatch); + return true; + } + #endregion + #region NPC New Shop Alert public static List<(int, Predicate, Action)> npcAlertList = new List<(int, Predicate, Action)>() @@ -684,7 +840,6 @@ namespace CalamityMod.NPCs (NPCID.SkeletonMerchant, (Player player) => player.Calamity().newSkeletonMerchantInventory, (Player player, bool enabled) =>{ player.Calamity().newSkeletonMerchantInventory = enabled; }), (NPCType(), (Player player) => player.Calamity().newAmidiasInventory,(Player player, bool enabled) =>{ player.Calamity().newAmidiasInventory = enabled; }), (NPCType(), (Player player) => player.Calamity().newBanditInventory,(Player player, bool enabled) =>{ player.Calamity().newBanditInventory = enabled; }), - (NPCType(), (Player player) => player.Calamity().newCirrusInventory,(Player player, bool enabled) =>{ player.Calamity().newCirrusInventory = enabled; }), (NPCType(), (Player player) => player.Calamity().newPermafrostInventory,(Player player, bool enabled) =>{ player.Calamity().newPermafrostInventory = enabled; }), (NPCType(), (Player player) => player.Calamity().newCalamitasInventory,(Player player, bool enabled) =>{ player.Calamity().newCalamitasInventory = enabled; }) // lol }; @@ -764,8 +919,7 @@ namespace CalamityMod.NPCs #region NPC Chat public override void GetChat(NPC npc, ref string chat) { - int cirrus = NPC.FindFirstNPC(NPCType()); - int permadong = NPC.FindFirstNPC(NPCType()); + int permafrost = NPC.FindFirstNPC(NPCType()); int seahorse = NPC.FindFirstNPC(NPCType()); int thief = NPC.FindFirstNPC(NPCType()); int angelstatue = NPC.FindFirstNPC(NPCID.Merchant); @@ -820,10 +974,7 @@ namespace CalamityMod.NPCs chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.DarksunEclipse"); else if (Main.rand.NextBool(5) && Main.LocalPlayer.ZoneGlowshroom) { - if (Main.rand.NextBool() && cirrus != -1) - chat = CalamityUtils.GetText("Vanilla.DryadChat.DrunkPrincessShroom").Format(Main.npc[cirrus].GivenName); - else - chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.Mushroom"); + chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.Mushroom"); } else if (Main.rand.NextBool(5) && Main.LocalPlayer.Calamity().ZoneSulphur) chat = CalamityUtils.GetTextValue("Vanilla.DryadChat.SulphurSea"); @@ -832,8 +983,8 @@ namespace CalamityMod.NPCs break; case NPCID.DyeTrader: - if (Main.rand.NextBool(5) && permadong != -1) - chat = CalamityUtils.GetText("Vanilla.DyeTraderChat.Archmage").Format(Main.npc[permadong].GivenName); + if (Main.rand.NextBool(5) && permafrost != -1) + chat = CalamityUtils.GetText("Vanilla.DyeTraderChat.Archmage").Format(Main.npc[permafrost].GivenName); else if (Main.rand.NextBool(5)) chat = CalamityUtils.GetTextValue("Vanilla.DyeTraderChat.Normal"); break; @@ -863,8 +1014,6 @@ namespace CalamityMod.NPCs chat = CalamityUtils.GetTextValue("Vanilla.MechanicChat.Eclipse"); else if (Main.rand.NextBool(5) && AcidRainEvent.AcidRainEventIsOngoing) chat = CalamityUtils.GetTextValue("Vanilla.MechanicChat.AcidRain"); - else if (Main.rand.NextBool(5) && cirrus != -1) - chat = CalamityUtils.GetText("Vanilla.MechanicChat.DrunkPrincess").Format(Main.npc[cirrus].GivenName); break; case NPCID.Merchant: @@ -885,8 +1034,8 @@ namespace CalamityMod.NPCs chat = CalamityUtils.GetTextValue("Vanilla.PainterChat.Crimson"); if (Main.rand.NextBool(4) && Main.LocalPlayer.ZoneSnow) { - if (Main.rand.NextBool() && permadong != -1) - chat = CalamityUtils.GetText("Vanilla.PainterChat.Archmage").Format(Main.npc[permadong].GivenName); + if (Main.rand.NextBool() && permafrost != -1) + chat = CalamityUtils.GetText("Vanilla.PainterChat.Archmage").Format(Main.npc[permafrost].GivenName); else chat = CalamityUtils.GetTextValue("Vanilla.PainterChat.Tundra"); } @@ -913,8 +1062,6 @@ namespace CalamityMod.NPCs case NPCID.PartyGirl: if (Main.rand.NextBool(4) && Main.eclipse) chat = CalamityUtils.GetTextValue("Vanilla.PartyGirlChat.Eclipse" + Main.rand.Next(1, 2 + 1)); - else if (Main.rand.NextBool(10) && cirrus != -1) - chat = CalamityUtils.GetText("Vanilla.PartyGirlChat.DrunkPrincess").Format(Main.npc[cirrus].GivenName); break; case NPCID.Pirate: @@ -922,8 +1069,6 @@ namespace CalamityMod.NPCs chat = CalamityUtils.GetTextValue("Vanilla.PirateChat.PreLeviathan"); else if (Main.rand.NextBool(5) && DownedBossSystem.downedAquaticScourge) chat = CalamityUtils.GetTextValue("Vanilla.PirateChat.WetScourgeDefeated"); - else if (Main.rand.NextBool(5) && cirrus != -1) - chat = CalamityUtils.GetTextValue("Vanilla.PirateChat.DrunkPrincess"); else if (Main.rand.NextBool(5) && seahorse != -1) chat = CalamityUtils.GetText("Vanilla.PirateChat.SeaKing").Format(Main.npc[seahorse].GivenName); else if (Main.rand.NextBool(5) && Main.LocalPlayer.Center.ToTileCoordinates().X < 380 && !Main.LocalPlayer.Calamity().ZoneSulphur) @@ -950,12 +1095,6 @@ namespace CalamityMod.NPCs string worldEvil = Language.GetTextValue("LegacyMisc." + (WorldGen.crimson ? 102 : 101)); if (Main.rand.NextBool(15) && Main.hardMode) chat = CalamityUtils.GetText("Vanilla.StylistChat.Hardmode").Format(worldEvil); - if (Main.rand.NextBool(15) && cirrus != -1) - { - int noChildSafetyCirrusLines = NPC.downedMoonlord ? Main.rand.Next(2, 3 + 1) : Main.rand.Next(1, 2 + 1); - int childSafetyCirrusLines = NPC.downedMoonlord ? 3 : 1; - chat = CalamityUtils.GetText("Vanilla.StylistChat.DrunkPrincess" + (ChildSafety.Disabled ? noChildSafetyCirrusLines : childSafetyCirrusLines)).Format(Main.npc[cirrus].GivenName); - } if ((Main.rand.NextBool(npc.GivenName == "Amber" ? 10 : 15)) && Main.LocalPlayer.Calamity().pSoulArtifact) { if (Main.LocalPlayer.Calamity().profanedCrystalBuffs) @@ -968,8 +1107,6 @@ namespace CalamityMod.NPCs case NPCID.DD2Bartender: if (Main.rand.NextBool(5) && !Main.dayTime && Main.moonPhase == 0) chat = CalamityUtils.GetTextValue("Vanilla.TavernkeepChat.FullMoon"); - else if (Main.rand.NextBool(10) && cirrus != -1) - chat = CalamityUtils.GetText("Vanilla.TavernkeepChat.DrunkPrincess").Format(Main.npc[cirrus].GivenName); break; case NPCID.TaxCollector: @@ -998,15 +1135,8 @@ namespace CalamityMod.NPCs chat = CalamityUtils.GetTextValue("Vanilla.TaxCollectorChat.Has100Plat"); break; - case NPCID.TravellingMerchant: - if (Main.rand.NextBool(5) && cirrus != -1 && angelstatue != -1) - chat = CalamityUtils.GetText("Vanilla.TravellingMerchantChat.DrunkPrincessMerchant").Format(Main.npc[cirrus].GivenName, Main.npc[angelstatue].GivenName); - break; - case NPCID.Truffle: - if (Main.rand.NextBool(4) && cirrus != -1) - chat = CalamityUtils.GetText("Vanilla.TruffleChat.DrunkPrincess").Format(Main.npc[cirrus].GivenName); - else if (Main.rand.NextBool(8)) + if (Main.rand.NextBool(8)) chat = CalamityUtils.GetTextValue("Vanilla.TruffleChat.Normal"); break; @@ -1020,8 +1150,6 @@ namespace CalamityMod.NPCs break; case NPCID.Wizard: - if (Main.rand.NextBool(6) && !Main.LocalPlayer.InventoryHas(ItemID.RodofDiscord) && !Main.LocalPlayer.InventoryHas(ItemType()) && !Main.LocalPlayer.ZoneHallow) - chat = CalamityUtils.GetTextValue("Vanilla.WizardChat.MentionRoD"); if (Main.rand.NextBool(10) && Main.hardMode) chat = CalamityUtils.GetTextValue("Vanilla.WizardChat.Hardmode"); break; @@ -1036,16 +1164,8 @@ namespace CalamityMod.NPCs public void BoundNPCSafety(Mod mod, NPC npc) { // Make Bound Town NPCs take no damage - if (BoundNPCIDList.Includes(npc.type)) - { + if (CalamityNPCTypeSets.BoundTownNPC[npc.type]) npc.dontTakeDamageFromHostiles = true; - } - } - - public void MakeTownNPCsTakeMoreDamage(NPC npc, Projectile projectile, Mod mod, ref NPC.HitModifiers modifiers) - { - if (npc.townNPC && projectile.hostile) - modifiers.SourceDamage *= 2f; } // Does not affect Dryad's Bane @@ -1091,7 +1211,7 @@ namespace CalamityMod.NPCs public override bool? CanBeHitByProjectile(NPC npc, Projectile projectile) { - //Not an axe but close enough + // Not an axe but close enough if (npc.type == NPCID.TaxCollector && projectile.type == ProjectileType()) return true; return base.CanBeHitByProjectile(npc, projectile); @@ -1102,176 +1222,168 @@ namespace CalamityMod.NPCs public override void ModifyShop(NPCShop shop) { int type = shop.NpcType; - int goldCost = NPC.downedMoonlord ? 16 : Main.hardMode ? 8 : 4; - - bool happy = Main.LocalPlayer.currentShoppingSettings.PriceAdjustment <= 0.9; + Condition spelunkerGlowCondition = new(Language.GetText("Conditions.NightDayFullMoon"), () => !Main.dayTime || Main.GetMoonPhase() == MoonPhase.Full); // Identical to the one in NPCShopDatabase Condition hasFlareGunUpgrade = new(CalamityUtils.GetText("Condition.HasFlareGun"), () => (Main.LocalPlayer.HasItem(ItemType()) || Main.LocalPlayer.HasItem(ItemType())) && !Main.LocalPlayer.HasItem(ItemID.FlareGun)); - Condition roguePlayer = CalamityConditions.PlayerHasRogueArmor; - Condition wingedPlayer = CalamityConditions.PlayerHasWings; - Condition revengeance = CalamityConditions.InRevengeanceMode; - Condition drunk = CalamityConditions.PlayerAlcoholPoisoned; - Condition downedPolterghast = CalamityConditions.DownedPolterghast; - Condition downedDoG = CalamityConditions.DownedDevourerOfGods; + Condition bestiaryProgressLacewing = new(CalamityUtils.GetText("Condition.LacewingBestiary"), () => Main.GetBestiaryProgressReport().CompletionPercent >= 0.4f); if (type == NPCID.Merchant) { - shop.AddWithCustomValue(ItemID.Bottle, Item.buyPrice(copper: 20)) - .AddWithCustomValue(ItemID.WormholePotion, Item.buyPrice(silver: 5), Condition.HappyEnoughToSellPylons); - shop.Add(ItemID.Flare, hasFlareGunUpgrade) - .Add(ItemID.BlueFlare, hasFlareGunUpgrade) - .AddWithCustomValue(ItemID.AngelStatue, Item.buyPrice(gold: 5), Condition.NpcIsPresent(NPCType())) - .AddWithCustomValue(ItemID.Burger, Item.buyPrice(gold: 5), Condition.HappyEnoughToSellPylons, Condition.DownedSkeletron) - .AddWithCustomValue(ItemID.Hotdog, Item.buyPrice(gold: 5), Condition.HappyEnoughToSellPylons, Condition.DownedSkeletron) - .AddWithCustomValue(ItemID.CoffeeCup, Item.buyPrice(gold: 2), Condition.HappyEnoughToSellPylons); + shop.InsertBefore(ItemID.LesserHealingPotion, ItemID.Bottle) + .InsertAfter(ItemID.ManaPotion, ItemID.WormholePotion, Condition.HappyEnoughToSellPylons) + .InsertAfter(ItemID.Safe, ItemID.MusicBox) + .InsertAfter(ItemID.Flare, ItemID.Flare, hasFlareGunUpgrade) + .InsertAfter(ItemID.BlueFlare, ItemID.BlueFlare, hasFlareGunUpgrade) + .AddWithCustomValue(ItemID.AngelStatue, Item.buyPrice(gold: 5), Condition.NpcIsPresent(NPCType())); } if (type == NPCID.DyeTrader) { - shop.Add(ItemType(), Condition.Hardmode) + shop.Add(Condition.Hardmode) .AddWithCustomValue(ItemID.DyeTradersScimitar, Item.buyPrice(gold: 15)); } if (type == NPCID.Demolitionist) { - shop.Add(ItemType(), Condition.DownedMechBossAny); + shop.Add(Condition.DownedMechBossAny); } if (type == NPCID.ArmsDealer) { - - shop.AddWithCustomValue(ItemType(), Item.buyPrice(gold: 25), Condition.Hardmode) - .AddWithCustomValue(ItemID.Boomstick, Item.buyPrice(gold: 20), Condition.DownedQueenBee) - .AddWithCustomValue(ItemID.Uzi, Item.buyPrice(gold: 45), Condition.DownedPlantera) - .AddWithCustomValue(ItemID.TacticalShotgun, Item.buyPrice(gold: 60), Condition.DownedGolem) - .AddWithCustomValue(ItemID.SniperRifle, Item.buyPrice(gold: 60), Condition.DownedGolem) - .AddWithCustomValue(ItemID.RifleScope, Item.buyPrice(gold: 60), Condition.DownedGolem); + shop.AddWithCustomValue(ItemType(), Item.buyPrice(gold: 20), Condition.DownedSkeletron) + .Add(Condition.Hardmode) + .AddWithCustomValue(ItemID.Boomstick, Item.buyPrice(gold: 25), Condition.DownedQueenBee) + .AddWithCustomValue(ItemID.Uzi, Item.buyPrice(gold: 50), Condition.DownedPlantera); } if (type == NPCID.Stylist) { - shop.Add(ItemType(), roguePlayer) - .Add(ItemType(), wingedPlayer) - .Add(ItemType(), revengeance) - .Add(ItemType(), revengeance) - .AddWithCustomValue(ItemID.StylistKilLaKillScissorsIWish, Item.buyPrice(gold: 15)) - .Add(ItemType(), Condition.NpcIsPresent(NPCType()), drunk) - .AddWithCustomValue(ItemID.ChocolateChipCookie, Item.buyPrice(gold: 3), Condition.HappyEnoughToSellPylons, Condition.NpcIsPresent(NPCType())); + shop.Add(CalamityConditions.PlayerHasRogueArmor) + .Add(CalamityConditions.PlayerHasWings) + .Add(CalamityConditions.InRevengeanceMode) + .Add(CalamityConditions.InRevengeanceMode) + .AddWithCustomValue(ItemID.StylistKilLaKillScissorsIWish, Item.buyPrice(gold: 15)); } if (type == NPCID.Cyborg) { - shop.AddWithCustomValue(ItemID.RocketLauncher, Item.buyPrice(gold: 25), Condition.DownedGolem) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 50), Condition.DownedGolem) - .Add(ItemType(), downedPolterghast); + shop.Add(Condition.DownedGolem) + .Add(CalamityConditions.DownedPolterghast); } if (type == NPCID.Dryad) { - shop.AddWithCustomValue(ItemID.JungleRose, Item.buyPrice(gold: 2)) - .AddWithCustomValue(ItemID.NaturesGift, Item.buyPrice(gold: 10)) - .Add(ItemType()) - .AddWithCustomValue(ItemID.Grapes, Item.buyPrice(gold: 2, silver: 50), Condition.HappyEnoughToSellPylons, Condition.DownedSkeletron) - .Add(ItemType(), Condition.DownedSkeletron) - .Add(ItemID.CorruptSeeds, Condition.CrimsonWorld, Condition.InGraveyard, Condition.PreHardmode) - .Add(ItemID.CrimsonSeeds, Condition.CorruptWorld, Condition.InGraveyard, Condition.PreHardmode) // Vanilla sells these in Hardmode, we just make them available at all times - .Add(ItemType(), Condition.NotBloodMoon, Condition.Hardmode); + shop.InsertAfter(ItemID.AshGrassSeeds, ItemType(), Condition.DownedSkeletron) + // Vanilla sells these in Hardmode, we just make them available at all times + // Fun fact: Corrupt and Crimson Seeds are sold twice, in different positions! + // This position is placed over the Graveyard one, and not the Blood Moon one (which is what happens if you insert after Corrupt Seeds). Totally awesome shop database. - Iris + .InsertAfter(ItemID.GrassWall, ItemID.CorruptSeeds, Condition.CrimsonWorld, Condition.InGraveyard, Condition.PreHardmode) + .InsertAfter(ItemID.GrassWall, ItemID.CrimsonSeeds, Condition.CorruptWorld, Condition.InGraveyard, Condition.PreHardmode) + .InsertAfter(ItemID.HallowedGrassEcho, ItemType(), Condition.NotBloodMoon, Condition.Hardmode) + .AddWithCustomValue(ItemID.JungleRose, Item.buyPrice(gold: 3)) + .AddWithCustomValue(ItemID.NaturesGift, Item.buyPrice(gold: 15)) + .Add(); } if (type == NPCID.GoblinTinkerer) { - shop.Add(ItemType()) - .Add(ItemID.Toolbox, Condition.NpcIsPresent(NPCID.Mechanic)) - .AddWithCustomValue(ItemID.Spaghetti, Item.buyPrice(gold: 5), Condition.HappyEnoughToSellPylons, Condition.DownedSkeletron); + shop.Add() + .Add(ItemID.Toolbox, Condition.NpcIsPresent(NPCID.Mechanic)); } if (type == NPCID.Mechanic) { - shop.AddWithCustomValue(ItemID.BuilderPotion, Item.buyPrice(gold: 4), Condition.HappyEnoughToSellPylons) - .AddWithCustomValue(ItemID.CombatWrench, Item.buyPrice(gold: 10)); + shop.AddWithCustomValue(ItemID.BuilderPotion, Item.buyPrice(gold: 2), Condition.HappyEnoughToSellPylons) + .AddWithCustomValue(ItemID.CombatWrench, Item.buyPrice(gold: 15)); } if (type == NPCID.Clothier) { - shop.AddWithCustomValue(ItemType(), Item.buyPrice(gold: 10)) - .AddWithCustomValue(ItemID.GoldenKey, Item.buyPrice(gold: 5), Condition.Hardmode) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 8), downedDoG) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 8), downedDoG) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 8), downedDoG) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 8), downedDoG) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 8), downedDoG); + shop.Add() + .AddWithCustomValue(ItemID.GoldenKey, Item.buyPrice(gold: 15), Condition.Hardmode) + .Add(CalamityConditions.DownedDevourerOfGods) + .Add(CalamityConditions.DownedDevourerOfGods) + .Add(CalamityConditions.DownedDevourerOfGods) + .Add(CalamityConditions.DownedDevourerOfGods) + .Add(CalamityConditions.DownedDevourerOfGods); } if (type == NPCID.Painter) { - shop.AddWithCustomValue(ItemID.PainterPaintballGun, Item.buyPrice(gold: 15)); + shop.AddWithCustomValue(ItemID.PainterPaintballGun, Item.buyPrice(gold: 15)) + .Add(ItemType(), CalamityConditions.InSunken, Condition.NpcIsPresent(NPCType())); } if (type == NPCID.Steampunker) { - shop.Add(ItemType(), Condition.NotRemixWorld) - .Add(ItemID.PurpleSolution, Condition.InGraveyard, Condition.CrimsonWorld, Condition.NotRemixWorld) - .Add(ItemID.RedSolution, Condition.InGraveyard, Condition.CorruptWorld, Condition.NotRemixWorld); + shop.InsertAfter(ItemID.BlueSolution, ItemType(), Condition.NotRemixWorld) + .InsertAfter(ItemID.PurpleSolution, ItemID.PurpleSolution, Condition.InGraveyard, Condition.CrimsonWorld, Condition.NotRemixWorld) + .InsertAfter(ItemID.RedSolution, ItemID.RedSolution, Condition.InGraveyard, Condition.CorruptWorld, Condition.NotRemixWorld) + .Add() + .Add() + .Add() + .Add(); } if (type == NPCID.Wizard) { - shop.AddWithCustomValue(ItemType(), CalamityGlobalItem.RarityLightRedBuyPrice * 3) - .AddWithCustomValue(ItemID.MagicMissile, Item.buyPrice(gold: 5)) - .AddWithCustomValue(ItemID.RodofDiscord, Item.buyPrice(gold: 50), Condition.Hardmode, Condition.InHallow) - .AddWithCustomValue(ItemID.SpectreStaff, Item.buyPrice(gold: 25), Condition.DownedGolem) - .AddWithCustomValue(ItemID.InfernoFork, Item.buyPrice(gold: 25), Condition.DownedGolem) - .AddWithCustomValue(ItemID.ShadowbeamStaff, Item.buyPrice(gold: 25), Condition.DownedGolem) - .AddWithCustomValue(ItemID.MagnetSphere, Item.buyPrice(gold: 25), Condition.DownedGolem); + shop.Add() + .AddWithCustomValue(ItemID.MagicMissile, Item.buyPrice(gold: 25)) + .Add() + .Add() + .Add() + .Add(); } if (type == NPCID.WitchDoctor) { - shop.Add(ItemType()) - .Add(ItemType()) - .Add(ItemType()) - .Add(ItemType()) - .Add(ItemType()) - .AddWithCustomValue(ItemID.ButterflyDust, Item.buyPrice(gold: 10), Condition.DownedGolem) - .AddWithCustomValue(ItemID.FriedEgg, Item.buyPrice(gold: 2, silver: 50), Condition.HappyEnoughToSellPylons); + shop.InsertAfter(ItemID.OasisFountain, ItemType()) + .InsertAfter(ItemID.OasisFountain, ItemType()) + .InsertAfter(ItemID.OasisFountain, ItemType()) + .InsertAfter(ItemID.OasisFountain, ItemType()) + .InsertAfter(ItemID.OasisFountain, ItemType()); } if (type == NPCID.PartyGirl) { - shop.AddWithCustomValue(ItemID.GenderChangePotion, Item.buyPrice(silver: 25), Condition.HappyEnoughToSellPylons) - .AddWithCustomValue(ItemID.Pizza, Item.buyPrice(gold: 5), Condition.HappyEnoughToSellPylons, Condition.DownedSkeletron) - .AddWithCustomValue(ItemID.CreamSoda, Item.buyPrice(gold: 2, silver: 50), Condition.HappyEnoughToSellPylons); + shop.Add(ItemID.GenderChangePotion, Condition.HappyEnoughToSellPylons); } if (type == NPCID.Princess) { - shop.AddWithCustomValue(ItemID.PrincessWeapon, Item.buyPrice(gold: 50)) - .Add(ItemType()) - .Add(ItemID.AppleJuice, Condition.NpcIsPresent(NPCType())) - .Add(ItemID.FruitJuice, Condition.NpcIsPresent(NPCType())) - .Add(ItemID.Lemonade, Condition.NpcIsPresent(NPCType())) - .Add(ItemID.PrismaticPunch, Condition.NpcIsPresent(NPCType())) - .Add(ItemID.SmoothieofDarkness, Condition.NpcIsPresent(NPCType())) - .Add(ItemID.TropicalSmoothie, Condition.NpcIsPresent(NPCType())); + Mod musicMod = ExternalMods.musicMod; + musicMod.TryFind("Interlude1MusicBox", out ModItem interlude1Box); + musicMod.TryFind("Interlude2MusicBox", out ModItem interlude2Box); + musicMod.TryFind("Interlude3MusicBox", out ModItem interlude3Box); + musicMod.TryFind("DevourerofGodsEulogyMusicBox", out ModItem eulogyBox); + + shop.InsertAfter(ItemID.MusicBoxCredits, interlude1Box.Type, CalamityConditions.DownedCalamitasClone) + .InsertAfter(ItemID.MusicBoxCredits, interlude2Box.Type, Condition.DownedMoonLord) + .InsertAfter(ItemID.MusicBoxCredits, interlude3Box.Type, CalamityConditions.DownedYharon) + .InsertAfter(ItemID.MusicBoxCredits, eulogyBox.Type, CalamityConditions.DownedDevourerOfGods) + .AddWithCustomValue(ItemID.PrincessWeapon, Item.buyPrice(platinum: 1), Condition.Hardmode) + .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 15), Condition.NpcIsPresent(NPCType())) + .Add(); } if (type == NPCID.SkeletonMerchant) { - shop.AddWithCustomValue(ItemType(), Item.buyPrice(silver: 25)) - .Add(ItemID.MilkCarton) + shop.InsertAfter(ItemID.HealingPotion, ItemType()) + .InsertAfter(ItemID.HealingPotion, ItemID.MilkCarton) + .InsertAfter(ItemID.SpelunkerFlare, ItemID.SpelunkerFlare, spelunkerGlowCondition, hasFlareGunUpgrade) .AddWithCustomValue(ItemID.Marrow, Item.buyPrice(gold: 25), Condition.Hardmode) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 12)) - .AddWithCustomValue(ItemType(), Item.buyPrice(gold: 12)); - } - - if (type == NPCID.Golfer) - { - shop.AddWithCustomValue(ItemID.PotatoChips, Item.buyPrice(gold: 1), Condition.HappyEnoughToSellPylons); + .AddWithCustomValue(Item.buyPrice(gold: 15)) + .AddWithCustomValue(Item.buyPrice(gold: 15)); } if (type == NPCID.BestiaryGirl) { - shop.AddWithCustomValue(ItemID.Steak, Item.buyPrice(gold: 5), Condition.HappyEnoughToSellPylons, Condition.Hardmode); + shop.Add(ItemID.EmpressButterfly, bestiaryProgressLacewing); + } + + if (type == NPCID.Truffle) + { + shop.Add(); } } #endregion diff --git a/NPCs/CalamityNaturalSpawnBossNPC.cs b/NPCs/CalamityNaturalSpawnBossNPC.cs index a549a45289..f588545a6a 100644 --- a/NPCs/CalamityNaturalSpawnBossNPC.cs +++ b/NPCs/CalamityNaturalSpawnBossNPC.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Linq; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.NormalNPCs; @@ -50,6 +46,15 @@ namespace CalamityMod.NPCs _GreatSharkTriggerNPCS = null; } + private sealed class ClearWorldHook : ModSystem + { + public override void ClearWorld() + { + ghostKillCount = 0; + sharkKillCount = 0; + } + } + public override void OnKill(NPC npc) { CheckPolterghastCondition(npc); @@ -73,14 +78,14 @@ namespace CalamityMod.NPCs string key = "Mods.CalamityMod.Status.Boss.GhostBossText2"; Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } else if (ghostKillCount == 20) { string key = "Mods.CalamityMod.Status.Boss.GhostBossText3"; Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } if (ghostKillCount >= 30 && Main.netMode != NetmodeID.MultiplayerClient) @@ -119,14 +124,14 @@ namespace CalamityMod.NPCs string key = "Mods.CalamityMod.Status.Boss.SandSharkText"; Color messageColor = Color.Goldenrod; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } else if (sharkKillCount == 8) { string key = "Mods.CalamityMod.Status.Boss.SandSharkText2"; Color messageColor = Color.Goldenrod; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } if (sharkKillCount >= 10 && Main.netMode != NetmodeID.MultiplayerClient) { diff --git a/NPCs/CalamityNetImportantNPC.cs b/NPCs/CalamityNetImportantNPC.cs index 065b2138d8..21c6bb5a98 100644 --- a/NPCs/CalamityNetImportantNPC.cs +++ b/NPCs/CalamityNetImportantNPC.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; -using System.CommandLine.Parsing; -using System.Linq; using System.Reflection; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod.NPCs { @@ -41,24 +38,19 @@ namespace CalamityMod.NPCs uniqueNetOffsetID++; #endregion Vanilla Enemies - var types = AssemblyManager.GetLoadableTypes(CalamityMod.Instance.Code) - .Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(ModNPC))); - - // Caching this for better performance - var npcTypeMethod = typeof(ModContent).GetMethod(nameof(ModContent.NPCType)); + var npcs = ModContent.GetContent(); var netOffsetTable = new Dictionary(); - foreach (var type in types) + foreach (var npc in npcs) { try { + var type = npc.GetType(); var longDistSync = type.GetCustomAttribute(); if (longDistSync == null) continue; - var npcTypeActualMethod = npcTypeMethod.MakeGenericMethod(typeArguments: type); - - int npcType = (int)npcTypeActualMethod.Invoke(null, null); + int npcType = npc.Type; int netOffset = uniqueNetOffsetID; Type typeToCheck = longDistSync.SyncWith ?? type; @@ -76,7 +68,7 @@ namespace CalamityMod.NPCs } catch (Exception e) { - CalamityMod.Instance.Logger.Error($"Exception thrown while evaluating type \"{type.Name}\": {e}"); + CalamityMod.Log.Error($"Exception thrown while evaluating type \"{npc.FullName}\": {e}"); } } diff --git a/NPCs/CalamityPierceResistance.cs b/NPCs/CalamityPierceResistance.cs new file mode 100644 index 0000000000..2ee5de4bbc --- /dev/null +++ b/NPCs/CalamityPierceResistance.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using CalamityMod.Balancing; +using CalamityMod.Items.Accessories; +using CalamityMod.Systems.Collections; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.NPCs +{ + public sealed class PierceResistNPC : GlobalNPC + { + internal static HashSet exemptProjectiles; + internal static HashSet pierceResistNPC; + internal static HashSet singleHitboxNPC; + internal static Dictionary singleHitboxExemptProjectiles; + + public override void Load() + { + exemptProjectiles = new(); + pierceResistNPC = new(); + singleHitboxNPC = new(); + singleHitboxExemptProjectiles = new(); + } + + public override void Unload() + { + exemptProjectiles?.Clear(); + exemptProjectiles = null; + pierceResistNPC?.Clear(); + pierceResistNPC = null; + singleHitboxNPC?.Clear(); + singleHitboxNPC = null; + singleHitboxExemptProjectiles?.Clear(); + singleHitboxExemptProjectiles = null; + } + + public override void SetStaticDefaults() + { + // Specific vanilla NPC's with pierce resistance + pierceResistNPC.Add(NPCID.EaterofWorldsHead); + pierceResistNPC.Add(NPCID.EaterofWorldsBody); + pierceResistNPC.Add(NPCID.EaterofWorldsTail); + pierceResistNPC.Add(NPCID.Creeper); + pierceResistNPC.Add(NPCID.TheDestroyer); + pierceResistNPC.Add(NPCID.TheDestroyerBody); + pierceResistNPC.Add(NPCID.TheDestroyerTail); + + // Specific vanilla projectile exemptions + exemptProjectiles.Add(ProjectileID.Arkhalis); + exemptProjectiles.Add(ProjectileID.ChargedBlasterLaser); + exemptProjectiles.Add(ProjectileID.ClingerStaff); + exemptProjectiles.Add(ProjectileID.FinalFractal); + exemptProjectiles.Add(ProjectileID.FlyingKnife); + exemptProjectiles.Add(ProjectileID.HallowJoustingLance); + exemptProjectiles.Add(ProjectileID.JoustingLance); + exemptProjectiles.Add(ProjectileID.LastPrismLaser); + exemptProjectiles.Add(ProjectileType()); // Included here as it does not have a projectile + exemptProjectiles.Add(ProjectileID.MonkStaffT3); + exemptProjectiles.Add(ProjectileID.PiercingStarlight); + exemptProjectiles.Add(ProjectileID.ShadowJoustingLance); + exemptProjectiles.Add(ProjectileID.Terragrim); + + // Specific vanilla projectile single hitbox exemptions + singleHitboxExemptProjectiles[ProjectileID.NettleBurstEnd] = true; + singleHitboxExemptProjectiles[ProjectileID.NettleBurstLeft] = true; + singleHitboxExemptProjectiles[ProjectileID.NettleBurstRight] = true; + singleHitboxExemptProjectiles[ProjectileID.PrincessWeapon] = true; + singleHitboxExemptProjectiles[ProjectileID.ToxicCloud] = true; + singleHitboxExemptProjectiles[ProjectileID.ToxicCloud2] = true; + singleHitboxExemptProjectiles[ProjectileID.ToxicCloud3] = true; + + var projectiles = GetContent(); + foreach (var projectile in projectiles) + { + try + { + var type = projectile.GetType(); + var pierceResistException = type.GetCustomAttribute(); + if (pierceResistException == null) + continue; + + int projectileType = projectile.Type; + + if (pierceResistException.OnlyForSingleHitbox) + { + singleHitboxExemptProjectiles[projectileType] = true; + continue; + } + else + { + exemptProjectiles.Add(projectileType); + } + } + catch (Exception e) + { + CalamityMod.Log.Error($"Exception thrown while evaluating type \"{projectile.FullName}\": {e}"); + } + } + + var npcs = GetContent(); + foreach (var npc in npcs) + { + try + { + var type = npc.GetType(); + var hasPierceResist = type.GetCustomAttribute(); + if (hasPierceResist == null) + continue; + + int npcType = npc.Type; + + pierceResistNPC.Add(npcType); + if (hasPierceResist.SingleHitbox) + singleHitboxNPC.Add(npcType); + } + catch (Exception e) + { + CalamityMod.Log.Error($"Exception thrown while evaluating type \"{npc.FullName}\": {e}"); + } + } + } + + public override void ModifyHitByProjectile(NPC npc, Projectile projectile, ref NPC.HitModifiers modifiers) + { + // Skip if NPC does not have pierce resistance or projectile is exempt + if (!pierceResistNPC.Contains(npc.type) || exemptProjectiles.Contains(projectile.type)) + return; + + // Skip if the projectile is exempt on single hitboxes and the NPC is a single hitbox + if (singleHitboxExemptProjectiles.TryGetValue(projectile.type, out bool isSingleHitboxExempt) && isSingleHitboxExempt && singleHitboxNPC.Contains(npc.type)) + return; + + PierceResistGlobal(projectile, npc, ref modifiers); + } + + // Generalized pierce resistance that stacks with all other resistances for some specific bosses defined in a list. + private void PierceResistGlobal(Projectile projectile, NPC npc, ref NPC.HitModifiers modifiers) + { + // Thanatos segments do not trigger pierce resistance if they are closed + if (CalamityNPCTypeSets.Thanatos.Contains(npc.type) && npc.GetGlobalNPC().unbreakableDR) + return; + + float damageReduction = projectile.Calamity().timesPierced * BalancingConstants.PierceResistHarshness; + if (damageReduction > BalancingConstants.PierceResistCap) + damageReduction = BalancingConstants.PierceResistCap; + + modifiers.FinalDamage *= 1f - damageReduction; + + bool aiStyleExempt = projectile.aiStyle == ProjAIStyleID.Flail || projectile.aiStyle == ProjAIStyleID.MechanicalPiranha || projectile.aiStyle == ProjAIStyleID.Yoyo; + if ((projectile.penetrate > 1 || projectile.penetrate == -1) && !projectile.CountsAsClass() && !aiStyleExempt) + projectile.Calamity().timesPierced++; + } + } +} diff --git a/NPCs/CalamityTileCollisionHarmNPC.cs b/NPCs/CalamityTileCollisionHarmNPC.cs index 0e1c4d420a..e8c8ce2d34 100644 --- a/NPCs/CalamityTileCollisionHarmNPC.cs +++ b/NPCs/CalamityTileCollisionHarmNPC.cs @@ -1,10 +1,8 @@ using System; -using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; namespace CalamityMod.NPCs { @@ -122,13 +120,17 @@ namespace CalamityMod.NPCs { float oldVelocity = OldVelocity.Length(); + npc.Center += ForcedVel; + ForcedVel *= 0.995f; + if (Collision.SolidCollision(npc.Center, (int)(npc.width * 0.5f), (int)(npc.height * 0.5f)) || !WorldGen.InWorld(npc.Center.ToTileCoordinates().X, npc.Center.ToTileCoordinates().Y, 40)) { if (!ForceVelocityOnly) { - int wallImpactDamage = (int)(PotentialEnergyDamage * Math.Clamp(oldVelocity / terminalVelocityForFullFallDamage, 0f, 1f)); + int wallImpactDamage = (int)(PotentialEnergyDamage * Math.Clamp(oldVelocity / terminalVelocityForFullFallDamage, (ForcedVel.Length() > 0 ? 1f : 0f), 1f)); Projectile wallImpact = Projectile.NewProjectileDirect(attacker.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType(), wallImpactDamage, 0f, attacker.whoAmI, npc.whoAmI); wallImpact.DamageType = DamageClass.Melee; + wallImpact.CritChance = (int)attacker.GetCritChance(DamageClass.Melee) + attacker.HeldItem.crit; } PotentialEnergyDamage = 0; @@ -136,8 +138,6 @@ namespace CalamityMod.NPCs hitVoid = false; } - npc.Center += ForcedVel; - ForcedVel *= 0.995f; if (packetTimer % 30 == 0) npc.SyncMotionToServer(); if (!WorldGen.InWorld(npc.Center.ToTileCoordinates().X, npc.Center.ToTileCoordinates().Y, 40) && !hitVoid) diff --git a/NPCs/CalamityVanillaAIOverrideNPC.Global.cs b/NPCs/CalamityVanillaAIOverrideNPC.Global.cs new file mode 100644 index 0000000000..33061a02d0 --- /dev/null +++ b/NPCs/CalamityVanillaAIOverrideNPC.Global.cs @@ -0,0 +1,366 @@ +using System; +using CalamityMod.Events; +using CalamityMod.ExtraTextures; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; +using CalamityMod.Systems.Collections; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs; + +public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC +{ + private static bool GlobalPreAI(NPC npc) + { + var calNPC = npc.GetGlobalNPC(); + + // Don't do damage for 42 frames after spawning in + if (npc.type == NPCID.Sharkron || npc.type == NPCID.Sharkron2) + { + npc.damage = npc.alpha > 0 ? 0 : npc.defDamage; + } + + // Servant of Cthulhu light + else if (npc.type == NPCID.ServantofCthulhu) + { + Lighting.AddLight(npc.Center, 0.2f, 0.2f, 0.2f); + } + + // Cultist Boss light and hitbox changes + else if (npc.type == NPCID.CultistBoss) + { + // Emit light + float lifeRatio = npc.life / (float)npc.lifeMax; + float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); + Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); + Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); + + // Decrement the hit counter for the shield flicker + if (calNPC.newAI[1] > 0f) + calNPC.newAI[1] -= 1f; + + // Cultist shield hitbox + Vector2 hitboxSize = new Vector2(216f / 1.4142f); + if (npc.Size != hitboxSize) + npc.Size = hitboxSize; + } + + // Cultist Clone Light + else if (npc.type == NPCID.CultistBossClone) + { + if (Main.npc[(int)npc.ai[3]].active) + { + // Emit light + float lifeRatio = Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax; + float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); + Color lightColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); + Lighting.AddLight(npc.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); + } + } + + return true; + } + + private static void GlobalAI(NPC npc) + { + // Fair contact damage + switch (npc.type) + { + case NPCID.DD2Betsy: + npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; + break; + + case NPCID.DD2WyvernT1: + case NPCID.DD2WyvernT2: + case NPCID.DD2WyvernT3: + npc.damage = npc.ai[0] == 2f ? npc.defDamage : 0; + break; + + case NPCID.Mothron: + npc.damage = npc.ai[0] == 3.2f ? (int)Math.Round(npc.defDamage * 1.3) : npc.ai[0] == 2f ? (int)Math.Round(npc.defDamage * 0.5) : 0; + break; + + case NPCID.MothronSpawn: + npc.damage = npc.ai[0] == 2.1f ? npc.defDamage : 0; + break; + + case NPCID.Mimic: + case NPCID.IceMimic: + case NPCID.PresentMimic: + npc.damage = (npc.ai[0] == 0f || npc.velocity.Y == 0f) ? 0 : npc.defDamage; + break; + + case NPCID.BigMimicCorruption: + case NPCID.BigMimicCrimson: + case NPCID.BigMimicHallow: + case NPCID.BigMimicJungle: + npc.damage = npc.ai[0] == 3f ? 0 : npc.defDamage; + + // Spend less time in closed state + if (npc.ai[0] == 3f) + npc.ai[1] += 0.5f; + + break; + + case NPCID.MartianDrone: + case NPCID.SolarCorite: + npc.damage = (npc.ai[0] == 2f || npc.ai[0] == 3f) ? npc.defDamage : 0; + break; + + case NPCID.GraniteFlyer: + npc.damage = npc.ai[0] == -1f ? 0 : npc.defDamage; + break; + + case NPCID.GraniteGolem: + npc.damage = npc.ai[2] < 0f ? 0 : npc.defDamage; + break; + + case NPCID.BlueSlime: + case NPCID.MotherSlime: + case NPCID.LavaSlime: + case NPCID.DungeonSlime: + case NPCID.CorruptSlime: + case NPCID.IlluminantSlime: + case NPCID.ToxicSludge: + case NPCID.IceSlime: + case NPCID.Crimslime: + case NPCID.UmbrellaSlime: + case NPCID.RainbowSlime: + case NPCID.SlimeMasked: + case NPCID.HoppinJack: + case NPCID.SlimeRibbonWhite: + case NPCID.SlimeRibbonYellow: + case NPCID.SlimeRibbonGreen: + case NPCID.SlimeRibbonRed: + case NPCID.SandSlime: + case NPCID.GoldenSlime: + case NPCID.ShimmerSlime: + case NPCID.GreenSlime: + case NPCID.RedSlime: + case NPCID.PurpleSlime: + case NPCID.YellowSlime: + case NPCID.BlackSlime: + case NPCID.JungleSlime: + case NPCID.BabySlime: + case NPCID.Pinky: + case NPCID.Slimeling: + case NPCID.Slimer2: + npc.damage = (npc.velocity.Y == 0f || npc.velocity.Length() < 3f) ? 0 : npc.defDamage; + break; + + case NPCID.GiantShelly: + case NPCID.GiantShelly2: + npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.2) : 0; + break; + + case NPCID.GiantTortoise: + case NPCID.IceTortoise: + npc.damage = npc.ai[0] == 3f ? (int)Math.Round(npc.defDamage * 1.4) : 0; + break; + + case NPCID.SolarSroller: + npc.damage = npc.ai[0] == 6f ? (int)Math.Round(npc.defDamage * 1.2) : 0; + break; + + default: + break; + } + } + + private static bool GlobalPreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + var calNPC = npc.GetGlobalNPC(); + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Destroyer drawing and laser telegraphs + if (CalamityNPCTypeSets.Destroyer.Contains(npc.type) && !npc.IsABestiaryIconDummy) + { + Texture2D npcTexture = TextureAssets.Npc[npc.type].Value; + Vector2 halfSize = npc.frame.Size() / 2; + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Color segmentDrawColor = npc.GetAlpha(drawColor); + + // Check if Destroyer is behind tiles and, if so, how much of the segment is behind tiles and adjust color accordingly + int x = (int)((npc.position.X - 8f) / 16f); + int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); + int y = (int)((npc.position.Y - 8f) / 16f); + int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); + for (int l = x; l <= x2; l++) + { + for (int m = y; m <= y2; m++) + { + if (Lighting.Brightness(l, m) == 0f) + segmentDrawColor = Color.Black; + } + } + + // Draw segments + spriteBatch.Draw(npcTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, segmentDrawColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + + // Draw lights + if (npc.ai[2] == 0f && segmentDrawColor != Color.Black) + { + // This life ratio is fine now because all Destroyer segments update to have the same amount of life every frame + float destroyerLifeRatio = npc.life / (float)npc.lifeMax; + + // Phases + bool phase4 = destroyerLifeRatio < (death ? 0.4f : 0.25f); + bool phase5 = destroyerLifeRatio < (death ? 0.2f : 0.1f); + + // Spawn DR check + bool hasSpawnDR = calNPC.newAI[1] < DestroyerAI.DRIncreaseTime && calNPC.newAI[1] > 60f; + + // Gradual color transition from ground to flight and vice versa + // 0f = Red, 1f = Purple + float phaseTransitionColorAmount = (hasSpawnDR || phase5) ? 1f : 0f; + if (!hasSpawnDR && !phase5) + { + if (calNPC.newAI[3] >= DestroyerAI.GroundTelegraphStartGateValue) + phaseTransitionColorAmount = MathHelper.Clamp(1f - (calNPC.newAI[3] - DestroyerAI.GroundTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); + else if (calNPC.newAI[3] >= DestroyerAI.FlightTelegraphStartGateValue) + phaseTransitionColorAmount = MathHelper.Clamp((calNPC.newAI[3] - DestroyerAI.FlightTelegraphStartGateValue) / DestroyerAI.PhaseTransitionTelegraphTime, 0f, 1f); + } + + // Light colors + int alpha = 192; + Color groundColor = new Color(150, 0, 0, alpha); + Color flightColor = revenge ? new Color(0, 0, 150, alpha) : groundColor; + Color segmentColor = Color.Lerp(groundColor, flightColor, phaseTransitionColorAmount); + Color telegraphColor_Red = new Color(255, 125, 125, alpha); + Color telegraphColor_Green = new Color(125, 255, 125, alpha); + Color telegraphColor_Cyan = new Color(0, 255, 255, alpha); + Color telegraphColor = telegraphColor_Red; + + // Telegraph for body lasers + float telegraphProgress = 0f; + if (npc.TryGetAIOverride(out var destroyerAI) && destroyerAI.LaserColor != -1) + { + float shootProjectileTime = death ? (phase5 ? 180f : phase4 ? 270f : 360f) : 450f; + float telegraphGateValue = shootProjectileTime - DestroyerAI.LaserTelegraphTime; + if (calNPC.newAI[0] > telegraphGateValue) + { + switch (destroyerAI.LaserColor) + { + default: + case 0: + break; + case 1: + telegraphColor = telegraphColor_Green; + break; + case 2: + telegraphColor = telegraphColor_Cyan; + break; + } + telegraphProgress = MathHelper.Clamp((calNPC.newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f); + } + } + + Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerHeadGlowmask.Value : TextureAssets.Dest[0].Value; + switch (npc.type) + { + default: + case NPCID.TheDestroyer: + break; + case NPCID.TheDestroyerBody: + glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerBodyGlowmask.Value : TextureAssets.Dest[1].Value; + break; + case NPCID.TheDestroyerTail: + glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.DestroyerTailGlowmask.Value : TextureAssets.Dest[2].Value; + break; + } + + float alphaMultiplier = 1f - npc.alpha / 255f; + spriteBatch.Draw(glowTexture, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, Color.Lerp(segmentColor, telegraphColor, telegraphProgress) * alphaMultiplier, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + } + return false; + } + return true; + } + + private static void GlobalPostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + var calNPC = npc.GetGlobalNPC(); + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Energy shield + if (npc.type == NPCID.CultistBoss || npc.type == NPCID.CultistBossClone) + { + spriteBatch.EnterShaderRegion(); + + float intensity = calNPC.newAI[1] / 35f; + float lifeRatio = npc.type == NPCID.CultistBoss ? (npc.life / (float)npc.lifeMax) : (Main.npc[(int)npc.ai[3]].life / (float)Main.npc[(int)npc.ai[3]].lifeMax); + + float flickerPower = 0f; + if (lifeRatio < 0.85f) + flickerPower += 0.1f; + if (lifeRatio < 0.7f) + flickerPower += 0.1f; + if (lifeRatio < 0.55f) + flickerPower += 0.1f; + if (lifeRatio < 0.4f) + flickerPower += 0.1f; + if (lifeRatio < 0.25f) + flickerPower += 0.1f; + if (lifeRatio < 0.1f) + flickerPower += 0.1f; + + float opacity = 1f; + opacity *= MathHelper.Lerp(MathHelper.Max(1f - flickerPower, 0.56f), 1f, (float)Math.Pow(Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.Lerp(3f, 5f, flickerPower)) * 0.5 + 0.5, 24D)); + + // Dampen the opacity and intensity slightly, to allow Cultist to be more easily visible inside of the forcefield. + // Dampen the opacity and intensity a bit more for the Clones. + float intensityAndOpacityMult = npc.type == NPCID.CultistBossClone ? 0.9f : 1f; + intensity *= intensityAndOpacityMult; + opacity *= intensityAndOpacityMult; + + Texture2D forcefieldTexture = SupremeCalamitas.SupremeCalamitas.ForcefieldTexture.Value; + + if (npc.type == NPCID.CultistBoss) + GameShaders.Misc["CalamityMod:SupremeShield"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); + else + GameShaders.Misc["CalamityMod:SupremeShield"].UseImage1("Images/Misc/noise"); + + float colorTransitionAmt = (float)Math.Pow((double)(1f - lifeRatio), 2D); + Color forcefieldColor = Color.Lerp(Color.MediumSpringGreen, Color.Black, colorTransitionAmt); + Color secondaryForcefieldColor = Color.Lerp(Color.Cyan, Color.Blue, colorTransitionAmt); + + forcefieldColor *= opacity; + secondaryForcefieldColor *= opacity; + + GameShaders.Misc["CalamityMod:SupremeShield"].UseSecondaryColor(secondaryForcefieldColor); + GameShaders.Misc["CalamityMod:SupremeShield"].UseColor(forcefieldColor); + GameShaders.Misc["CalamityMod:SupremeShield"].UseSaturation(1); + GameShaders.Misc["CalamityMod:SupremeShield"].UseOpacity(0.65f); + GameShaders.Misc["CalamityMod:SupremeShield"].Apply(); + + // Actual Cultist has a bigger shield than the Clones. + float shieldScale = npc.type == NPCID.CultistBossClone ? 1.65f : MathHelper.Lerp(1.65f, 3f, (float)Math.Pow((double)lifeRatio, 2D)); + spriteBatch.Draw(forcefieldTexture, npc.Center - Main.screenPosition, null, Color.White * opacity, 0f, forcefieldTexture.Size() * 0.5f, shieldScale, SpriteEffects.None, 0f); + + spriteBatch.ExitShaderRegion(); + } + + // Laser telegraph + else if (npc.type == NPCID.Probe) + { + float eyeTelegraphGateValue = (NPC.IsMechQueenUp ? DestroyerAI.ProbeLaserGateValue_Mechdusa : revenge ? DestroyerAI.ProbeLaserGateValue_Rev : DestroyerAI.ProbeLaserGateValue) - DestroyerAI.ProbeLaserTelegraphTime; + Texture2D glowTexture = ModContent.Request("CalamityMod/Particles/Sparkle").Value; + Vector2 halfSize = npc.frame.Size() / 2; + + Vector2 drawPosition = npc.Center - screenPos + Vector2.UnitX.RotatedBy(npc.rotation) * (npc.width * 0.45f * npc.spriteDirection) + Vector2.UnitY * npc.gfxOffY; + float colorScale = MathHelper.Clamp((npc.localAI[0] - eyeTelegraphGateValue) / DestroyerAI.ProbeLaserTelegraphTime, 0f, 1f); + Color drawColor2 = new Color(255, 100, 150, 192) * colorScale; + spriteBatch.SetBlendState(BlendState.Additive); + spriteBatch.Draw(glowTexture, drawPosition, npc.frame, drawColor2, npc.rotation, halfSize, npc.scale * 1.1f, SpriteEffects.None, 0f); + spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + } +} diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs new file mode 100644 index 0000000000..80ec7028d6 --- /dev/null +++ b/NPCs/CalamityVanillaAIOverrideNPC.cs @@ -0,0 +1,1144 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CalamityMod.Events; +using CalamityMod.NPCs.AcidRain; +using CalamityMod.NPCs.Astral; +using CalamityMod.NPCs.Crags; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.PlagueEnemies; +using CalamityMod.NPCs.PrimordialWyrm; +using CalamityMod.NPCs.VanillaNPCAIOverrides; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; +using CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses; +using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; +using CalamityMod.Systems.Collections; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.NPCs; + +public static class VanillaAIOverrideExtension +{ + extension(NPC npc) + { + public bool TryGetAIOverride(out AI aiInstance) where AI : VanillaAIOverride, new() + { + if (!npc.TryGetGlobalNPC(out var aiOverrideNPC)) + { + aiInstance = null; + return false; + } + + aiInstance = aiOverrideNPC.AIOverride as AI; + return aiInstance != null; + } + } +} + +public sealed partial class CalamityVanillaAIOverrideNPC : GlobalNPC +{ + /// + /// Toggle Entire System. External mods can toggle this out if they want. + /// + public static bool Enabled { get; set; } = true; + + /// + /// Blacklist for non difficulty specific AI changes. External mods can add NPC type to opt-out global changes. + /// Example: Destroyer Probe's Telegraph Drawing + /// + public static HashSet GlobalChangeBlacklist { get; private set; } = []; + + /// + /// Hook to Modify AI Overrides on External mods demand.
+ /// Modifying will result in NPCs to use that specific AI. + ///
+ public static event Action ModifyAIOverride; + + /// + /// Specify the AI Override to work with. This handles AI, SendExtraAI and ReceiveExtraAI in instaned manner. + /// + public VanillaAIOverride AIOverride = null; + + public static Dictionary NetIDLookup = []; + + public const int InvalidNetID = 0; + + public override bool AppliesToEntity(NPC entity, bool lateInstantiation) + { + if (entity.townNPC) return false; + if (entity.friendly) return false; + if (entity.CountsAsACritter) return false; + if (CalamityNPCSets.DontCountAsEnemy[entity.type]) return false; + return true; + } + + #region Clone Logic + public override bool InstancePerEntity => true; + + public override GlobalNPC Clone(NPC npc, NPC npcClone) + { + CalamityVanillaAIOverrideNPC clone = (CalamityVanillaAIOverrideNPC)base.Clone(npc, npcClone); + if (AIOverride != null) + { + clone.AIOverride = AIOverride.Clone(); + clone.AIOverride.NPC = npcClone; + } + else + { + clone.AIOverride = null; + } + return clone; + } + + #endregion + + #region Vanilla AI Override Rule + public static VanillaAIOverride GetVanillaAIOverrideToApply(NPC npc) + { + if (npc == null) + return null; + + if (npc.whoAmI < 0 || npc.whoAmI >= Main.maxNPCs) + return null; + + if (!npc.active) + return null; + + // Completely override the shitty AI and replace it + if (npc.type == NPCID.BloodNautilus) + return new DreadnautilusAI(); + + // Adult Wyrm Ancient Doom + if (npc.type == NPCID.AncientDoom) + { + if (Main.npc[(int)npc.ai[0]].type == NPCType()) + return new CultistAI.AncientDoomAI(); + } + + // Zenith seed Specifics + if (Main.zenithWorld) + { + if (npc.type == NPCID.QueenBee) + return new QueenBeeAI(); + } + + // Death Mode Specifics + if (CalamityWorld.death) + { + if (npc.type == NPCID.DetonatingBubble) + return new DukeFishronAI.DetonatingBubbleAI(); + } + + #region Rev+ Mode Boss/Miniboss AI Overrides + + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + { + switch (npc.type) + { + case NPCID.KingSlime: + return new KingSlimeAI(); + + case NPCID.EyeofCthulhu: + return new EyeOfCthulhuAI(); + + case NPCID.EaterofWorldsHead or NPCID.EaterofWorldsBody or NPCID.EaterofWorldsTail: + return new EaterOfWorldsAI(); + + case NPCID.BrainofCthulhu: + return new BrainOfCthulhuAI(); + case NPCID.Creeper: + return new CreeperAI(); + + case NPCID.QueenBee: + return new QueenBeeAI(); + + case NPCID.SkeletronHead: + if (Main.netMode == NetmodeID.SinglePlayer) + return new SkeletronAI(); + else return null; + + case NPCID.SkeletronHand: + if (Main.netMode == NetmodeID.SinglePlayer) + return new SkeletronAI.SkeletronHandAI(); + else return null; + + case NPCID.DungeonGuardian: + return new SkeletronAI.DungeonGuardianAI(); + + case NPCID.Deerclops: + return new DeerclopsAI(); + + case NPCID.WallofFlesh: + return new WallOfFleshAI(); + case NPCID.WallofFleshEye: + return new WallOfFleshAI.EyeAI(); + + case NPCID.QueenSlimeBoss: + return new QueenSlimeAI(); + case NPCID.QueenSlimeMinionBlue: + return new QueenSlimeAI.CrystalSlimeAI(); + case NPCID.QueenSlimeMinionPink: + return new QueenSlimeAI.BouncySlimeAI(); + + case NPCID.TheDestroyer or NPCID.TheDestroyerBody or NPCID.TheDestroyerTail: + return new DestroyerAI(); + case NPCID.Probe: + return new DestroyerAI.ProbeAI(); + + case NPCID.Retinazer: + return new TwinsAI.RetinazerAI(); + case NPCID.Spazmatism: + return new TwinsAI.SpazmatismAI(); + + case NPCID.SkeletronPrime: + return new SkeletronPrimeAI(); + case NPCID.PrimeLaser: + return new SkeletronPrimeAI.PrimeLaserAI(); + case NPCID.PrimeCannon: + return new SkeletronPrimeAI.PrimeCannonAI(); + case NPCID.PrimeVice: + return new SkeletronPrimeAI.PrimeViceAI(); + case NPCID.PrimeSaw: + return new SkeletronPrimeAI.PrimeSawAI(); + + case NPCID.Plantera: + return new PlanteraAI(); + case NPCID.PlanterasHook: + return new PlanteraAI.HookAI(); + case NPCID.PlanterasTentacle: + return new PlanteraAI.TentacleAI(); + + case NPCID.HallowBoss: + return new EmpressofLightAI(); + + case NPCID.Golem: + return new GolemAI(); + case NPCID.GolemFistLeft or NPCID.GolemFistRight: + return new GolemAI.FistAI(); + case NPCID.GolemHead: + return new GolemAI.HeadAI(); + case NPCID.GolemHeadFree: + return new GolemAI.HeadFreeAI(); + + case NPCID.DukeFishron: + return new DukeFishronAI(); + + case NPCID.Pumpking when DownedBossSystem.downedDoG: + return new PumpkingAI(); + + case NPCID.PumpkingBlade when DownedBossSystem.downedDoG: + return new PumpkingAI.BladeAI(); + + case NPCID.IceQueen when DownedBossSystem.downedDoG: + return new IceQueenAI(); + + case NPCID.Mothron when DownedBossSystem.downedDoG: + return new MothronAI(); + + case NPCID.CultistBoss or NPCID.CultistBossClone: + return new CultistAI(); + case NPCID.AncientLight: + return new CultistAI.AncientLightAI(); + case NPCID.AncientDoom: + return new CultistAI.AncientDoomAI(); + + case NPCID.MoonLordCore: + case NPCID.MoonLordHand: + case NPCID.MoonLordHead: + case NPCID.MoonLordFreeEye: + case NPCID.MoonLordLeechBlob: + return new MoonLordAI(); + } + ; + } + + #endregion + + #region Rev+ Mode Regular Enemies AI Overrides + + if (CalamityWorld.revenge) + { + switch (npc.aiStyle) + { + case NPCAIStyleID.Slime: + if (npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType()) + { + return new SlimeAI(); + } + else + { + switch (npc.type) + { + case NPCID.BlueSlime: + case NPCID.MotherSlime: + case NPCID.LavaSlime: + case NPCID.DungeonSlime: + case NPCID.CorruptSlime: + case NPCID.IlluminantSlime: + case NPCID.ToxicSludge: + case NPCID.IceSlime: + case NPCID.Crimslime: + case NPCID.SpikedIceSlime: + case NPCID.SpikedJungleSlime: + case NPCID.UmbrellaSlime: + case NPCID.RainbowSlime: + case NPCID.SlimeMasked: + case NPCID.HoppinJack: + case NPCID.SlimeRibbonWhite: + case NPCID.SlimeRibbonYellow: + case NPCID.SlimeRibbonGreen: + case NPCID.SlimeRibbonRed: + case NPCID.SandSlime: + case NPCID.SlimeSpiked: + case NPCID.GoldenSlime: + case NPCID.ShimmerSlime: + return new SlimeAI(); + } + } + break; + + case NPCAIStyleID.DemonEye: + if (npc.type == NPCType()) + { + return new DemonEyeAI(); + } + else + { + switch (npc.type) + { + case NPCID.DemonEye: + case NPCID.TheHungryII: + case NPCID.WanderingEye: + case NPCID.PigronCorruption: + case NPCID.PigronHallow: + case NPCID.PigronCrimson: + case NPCID.CataractEye: + case NPCID.SleepyEye: + case NPCID.DialatedEye: + case NPCID.GreenEye: + case NPCID.PurpleEye: + case NPCID.DemonEyeOwl: + case NPCID.DemonEyeSpaceship: + return new DemonEyeAI(); + } + } + break; + + case NPCAIStyleID.Fighter: + if (npc.type == NPCType() || npc.type == NPCType() || + npc.type == NPCType() || npc.type == NPCType()) + { + return new RevengeanceAndDeathAI.FighterAI(); + } + else + { + switch (npc.type) + { + case NPCID.Zombie: + case NPCID.ArmedZombie: + case NPCID.ArmedZombieEskimo: + case NPCID.ArmedZombiePincussion: + case NPCID.ArmedZombieSlimed: + case NPCID.ArmedZombieSwamp: + case NPCID.ArmedZombieTwiggy: + case NPCID.ArmedZombieCenx: + case NPCID.Skeleton: + case NPCID.SporeSkeleton: + case NPCID.AngryBones: + case NPCID.UndeadMiner: + case NPCID.CorruptBunny: + case NPCID.DoctorBones: + case NPCID.TheGroom: + case NPCID.Crab: + case NPCID.GoblinScout: + case NPCID.ArmoredSkeleton: + case NPCID.Mummy: + case NPCID.DarkMummy: + case NPCID.LightMummy: + case NPCID.Werewolf: + case NPCID.Clown: + case NPCID.SkeletonArcher: + case NPCID.ChaosElemental: + case NPCID.BaldZombie: + case NPCID.PossessedArmor: + case NPCID.ZombieEskimo: + case NPCID.UndeadViking: + case NPCID.CorruptPenguin: + case NPCID.FaceMonster: + case NPCID.SnowFlinx: + case NPCID.PincushionZombie: + case NPCID.SlimedZombie: + case NPCID.SwampZombie: + case NPCID.TwiggyZombie: + case NPCID.Nymph: + case NPCID.ArmoredViking: + case NPCID.Lihzahrd: + case NPCID.LihzahrdCrawler: + case NPCID.FemaleZombie: + case NPCID.HeadacheSkeleton: + case NPCID.MisassembledSkeleton: + case NPCID.PantlessSkeleton: + case NPCID.IcyMerman: + case NPCID.PirateDeckhand: + case NPCID.PirateCorsair: + case NPCID.PirateDeadeye: + case NPCID.PirateCrossbower: + case NPCID.PirateCaptain: + case NPCID.CochinealBeetle: + case NPCID.CyanBeetle: + case NPCID.LacBeetle: + case NPCID.SeaSnail: + case NPCID.ZombieRaincoat: + case NPCID.ZombieMushroom: + case NPCID.ZombieMushroomHat: + case NPCID.AnomuraFungus: + case NPCID.MushiLadybug: + case NPCID.RustyArmoredBonesAxe: + case NPCID.RustyArmoredBonesFlail: + case NPCID.RustyArmoredBonesSword: + case NPCID.RustyArmoredBonesSwordNoArmor: + case NPCID.BlueArmoredBones: + case NPCID.BlueArmoredBonesMace: + case NPCID.BlueArmoredBonesNoPants: + case NPCID.BlueArmoredBonesSword: + case NPCID.HellArmoredBones: + case NPCID.HellArmoredBonesSpikeShield: + case NPCID.HellArmoredBonesMace: + case NPCID.HellArmoredBonesSword: + case NPCID.Paladin: + case NPCID.SkeletonSniper: + case NPCID.SkeletonCommando: + case NPCID.AngryBonesBig: + case NPCID.AngryBonesBigMuscle: + case NPCID.AngryBonesBigHelmet: + case NPCID.Scarecrow1: + case NPCID.Scarecrow2: + case NPCID.Scarecrow3: + case NPCID.Scarecrow4: + case NPCID.Scarecrow5: + case NPCID.Scarecrow6: + case NPCID.Scarecrow7: + case NPCID.Scarecrow8: + case NPCID.Scarecrow9: + case NPCID.Scarecrow10: + case NPCID.ZombieDoctor: + case NPCID.ZombieSuperman: + case NPCID.ZombiePixie: + case NPCID.SkeletonTopHat: + case NPCID.SkeletonAstonaut: + case NPCID.SkeletonAlien: + case NPCID.Splinterling: + case NPCID.ZombieXmas: + case NPCID.ZombieSweater: + case NPCID.ZombieElf: + case NPCID.ZombieElfBeard: + case NPCID.ZombieElfGirl: + case NPCID.GingerbreadMan: + case NPCID.Yeti: + case NPCID.Nutcracker: + case NPCID.NutcrackerSpinning: + case NPCID.ElfArcher: + case NPCID.Krampus: + case NPCID.CultistArcherBlue: + case NPCID.CultistArcherWhite: + case NPCID.BrainScrambler: + case NPCID.RayGunner: + case NPCID.MartianOfficer: + case NPCID.GrayGrunt: + case NPCID.MartianEngineer: + case NPCID.GigaZapper: + case NPCID.Scutlix: + case NPCID.BoneThrowingSkeleton: + case NPCID.BoneThrowingSkeleton2: + case NPCID.BoneThrowingSkeleton3: + case NPCID.BoneThrowingSkeleton4: + case NPCID.CrimsonBunny: + case NPCID.CrimsonPenguin: + case NPCID.Medusa: + case NPCID.GreekSkeleton: + case NPCID.GraniteGolem: + case NPCID.BloodZombie: + case NPCID.Crawdad: + case NPCID.Crawdad2: + case NPCID.Salamander: + case NPCID.Salamander2: + case NPCID.Salamander3: + case NPCID.Salamander4: + case NPCID.Salamander5: + case NPCID.Salamander6: + case NPCID.Salamander7: + case NPCID.Salamander8: + case NPCID.Salamander9: + case NPCID.GiantWalkingAntlion: + case NPCID.WalkingAntlion: + case NPCID.LarvaeAntlion: + case NPCID.DesertGhoul: + case NPCID.DesertGhoulCorruption: + case NPCID.DesertGhoulCrimson: + case NPCID.DesertGhoulHallow: + case NPCID.DesertLamiaLight: + case NPCID.DesertLamiaDark: + case NPCID.DesertScorpionWalk: + case NPCID.DesertBeast: + case NPCID.StardustSoldier: + case NPCID.StardustSpiderBig: + case NPCID.NebulaSoldier: + case NPCID.VortexSoldier: + case NPCID.SolarDrakomire: + case NPCID.SolarSpearman: + case NPCID.SolarSolenian: + case NPCID.Frankenstein: + case NPCID.SwampThing: + case NPCID.Vampire: + case NPCID.Butcher: + case NPCID.CreatureFromTheDeep: + case NPCID.Fritz: + case NPCID.Psycho: + case NPCID.ThePossessed: + case NPCID.DrManFly: + case NPCID.GoblinPeon: + case NPCID.GoblinThief: + case NPCID.GoblinWarrior: + case NPCID.GoblinArcher: + case NPCID.GoblinSummoner: + case NPCID.MartianWalker: + case NPCID.DemonTaxCollector: + case NPCID.TheBride: + return new RevengeanceAndDeathAI.FighterAI(); + } + } + break; + + case NPCAIStyleID.Flying: + switch (npc.type) + { + case NPCID.ServantofCthulhu: + case NPCID.EaterofSouls: + case NPCID.MeteorHead: + case NPCID.Crimera: + case NPCID.Moth: + case NPCID.Parrot: + case NPCID.Bee: + case NPCID.BeeSmall: + case NPCID.Hornet: + case NPCID.HornetFatty: + case NPCID.HornetHoney: + case NPCID.HornetLeafy: + case NPCID.HornetSpikey: + case NPCID.HornetStingy: + case NPCID.MossHornet: + return new RevengeanceAndDeathAI.FlyingAI(); + } + break; + + case NPCAIStyleID.Worm: + switch (npc.type) + { + case NPCID.DevourerHead: + case NPCID.DevourerBody: + case NPCID.DevourerTail: + case NPCID.GiantWormHead: + case NPCID.GiantWormBody: + case NPCID.GiantWormTail: + case NPCID.BoneSerpentHead: + case NPCID.BoneSerpentBody: + case NPCID.BoneSerpentTail: + case NPCID.WyvernHead: + case NPCID.WyvernLegs: + case NPCID.WyvernBody: + case NPCID.WyvernBody2: + case NPCID.WyvernBody3: + case NPCID.WyvernTail: + case NPCID.LeechHead: + case NPCID.LeechBody: + case NPCID.LeechTail: + case NPCID.TombCrawlerHead: + case NPCID.TombCrawlerBody: + case NPCID.TombCrawlerTail: + case NPCID.StardustWormHead: + case NPCID.SolarCrawltipedeHead: + case NPCID.SolarCrawltipedeBody: + case NPCID.SolarCrawltipedeTail: + case NPCID.BloodEelHead: + case NPCID.BloodEelBody: + case NPCID.BloodEelTail: + return new RevengeanceAndDeathAI.WormAI(); + } + break; + + case NPCAIStyleID.ManEater: + switch (npc.type) + { + case NPCID.ManEater: + case NPCID.Snatcher: + case NPCID.Clinger: + case NPCID.AngryTrapper: + case NPCID.FungiBulb: + case NPCID.GiantFungiBulb: + return new RevengeanceAndDeathAI.PlantAI(); + } + break; + + case NPCAIStyleID.Bat: + if (npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) + { + return new RevengeanceAndDeathAI.BatAI(); + } + else + { + switch (npc.type) + { + case NPCID.CaveBat: + case NPCID.JungleBat: + case NPCID.Hellbat: + case NPCID.GiantBat: + case NPCID.Slimer: + case NPCID.IlluminantBat: + case NPCID.IceBat: + case NPCID.Lavabat: + case NPCID.GiantFlyingFox: + case NPCID.FlyingSnake: + case NPCID.VampireBat: + case NPCID.SporeBat: + return new RevengeanceAndDeathAI.BatAI(); + } + } + break; + + case NPCAIStyleID.Piranha: + switch (npc.type) + { + case NPCID.CorruptGoldfish: + case NPCID.Piranha: + case NPCID.Shark: + case NPCID.AnglerFish: + case NPCID.Arapaima: + case NPCID.BloodFeeder: + case NPCID.CrimsonGoldfish: + return new RevengeanceAndDeathAI.SwimmingAI(); + } + break; + + case NPCAIStyleID.Jellyfish: + switch (npc.type) + { + case NPCID.BlueJellyfish: + case NPCID.PinkJellyfish: + case NPCID.GreenJellyfish: + case NPCID.Squid: + case NPCID.BloodJelly: + case NPCID.FungoFish: + return new RevengeanceAndDeathAI.JellyfishAI(); + } + break; + + case NPCAIStyleID.SpikeBall: + switch (npc.type) + { + case NPCID.SpikeBall: + return new RevengeanceAndDeathAI.SpikeBallAI(); + } + break; + + case NPCAIStyleID.BlazingWheel: + switch (npc.type) + { + case NPCID.BlazingWheel: + return new RevengeanceAndDeathAI.BlazingWheelAI(); + } + break; + + case NPCAIStyleID.HoveringFighter: + switch (npc.type) + { + case NPCID.Pixie: + case NPCID.Wraith: + case NPCID.Gastropod: + case NPCID.FloatyGross: + case NPCID.Ghost: + case NPCID.Poltergeist: + case NPCID.Drippler: + case NPCID.Reaper: + return new RevengeanceAndDeathAI.HoveringAI(); + } + break; + + case NPCAIStyleID.EnchantedSword: + switch (npc.type) + { + case NPCID.CursedHammer: + case NPCID.EnchantedSword: + case NPCID.CrimsonAxe: + return new RevengeanceAndDeathAI.FlyingWeaponAI(); + } + break; + + case NPCAIStyleID.Mimic: + switch (npc.type) + { + case NPCID.Mimic: + case NPCID.PresentMimic: + case NPCID.IceMimic: + return new RevengeanceAndDeathAI.MimicAI(); + } + break; + + case NPCAIStyleID.Unicorn: + if (npc.type == NPCType()) + { + return new RevengeanceAndDeathAI.UnicornAI(); + } + else + { + switch (npc.type) + { + case NPCID.Unicorn: + case NPCID.Wolf: + case NPCID.HeadlessHorseman: + case NPCID.Hellhound: + case NPCID.StardustSpiderSmall: + case NPCID.NebulaBeast: + case NPCID.Tumbleweed: + return new RevengeanceAndDeathAI.UnicornAI(); + } + } + break; + + case NPCAIStyleID.TheHungry: + switch (npc.type) + { + case NPCID.TheHungry: + return new WallOfFleshAI.HungryAI(); + } + break; + + case NPCAIStyleID.GiantTortoise: + if (npc.type == NPCType()) + { + return new RevengeanceAndDeathAI.TortoiseAI(); + } + else + { + switch (npc.type) + { + case NPCID.GiantTortoise: + case NPCID.IceTortoise: + case NPCID.GiantShelly: + case NPCID.GiantShelly2: + case NPCID.SolarSroller: + return new RevengeanceAndDeathAI.TortoiseAI(); + } + } + break; + + case NPCAIStyleID.Spider: + switch (npc.type) + { + case NPCID.DesertScorpionWall: + return new RevengeanceAndDeathAI.SpiderAI(); + } + break; + + case NPCAIStyleID.Herpling: + if (npc.type == NPCType()) + { + return new RevengeanceAndDeathAI.HerplingAI(); + } + else + { + switch (npc.type) + { + case NPCID.Herpling: + case NPCID.Derpling: + case NPCID.ChatteringTeethBomb: + return new RevengeanceAndDeathAI.HerplingAI(); + } + } + break; + + case NPCAIStyleID.FlyingFish: + switch (npc.type) + { + case NPCID.FlyingFish: + case NPCID.GiantFlyingAntlion: + case NPCID.FlyingAntlion: + case NPCID.EyeballFlyingFish: + return new RevengeanceAndDeathAI.FlyingFishAI(); + } + break; + + case NPCAIStyleID.AngryNimbus: + switch (npc.type) + { + case NPCID.AngryNimbus: + return new RevengeanceAndDeathAI.AngryNimbusAI(); + } + break; + + case NPCAIStyleID.TeslaTurret: + switch (npc.type) + { + case NPCID.MartianTurret: + return new RevengeanceAndDeathAI.TeslaTurretAI(); + } + break; + + case NPCAIStyleID.Corite: + switch (npc.type) + { + case NPCID.MartianDrone: + case NPCID.SolarCorite: + return new RevengeanceAndDeathAI.CoriteAI(); + } + break; + + case NPCAIStyleID.MartianProbe: + switch (npc.type) + { + case NPCID.MartianProbe: + return new RevengeanceAndDeathAI.MartianProbeAI(); + } + break; + + case NPCAIStyleID.StarCell: + switch (npc.type) + { + case NPCID.StardustCellBig: + case NPCID.NebulaHeadcrab: + case NPCID.DeadlySphere: + return new RevengeanceAndDeathAI.StarCellAI(); + } + break; + + case NPCAIStyleID.AncientVision: + switch (npc.type) + { + case NPCID.ShadowFlameApparition: + case NPCID.AncientCultistSquidhead: + return new RevengeanceAndDeathAI.AncientVisionAI(); + } + break; + + case NPCAIStyleID.BiomeMimic: + switch (npc.type) + { + case NPCID.BigMimicCorruption: + case NPCID.BigMimicCrimson: + case NPCID.BigMimicHallow: + case NPCID.BigMimicJungle: + return new RevengeanceAndDeathAI.BigMimicAI(); + } + break; + + case NPCAIStyleID.MothronEgg: + switch (npc.type) + { + case NPCID.MothronEgg: + return new RevengeanceAndDeathAI.MothronEggAI(); + } + break; + + case NPCAIStyleID.GraniteElemental: + switch (npc.type) + { + case NPCID.GraniteFlyer: + return new RevengeanceAndDeathAI.GraniteElementalAI(); + } + break; + + case NPCAIStyleID.SmallStarCell: + switch (npc.type) + { + case NPCID.StardustCellSmall: + return new RevengeanceAndDeathAI.SmallStarCellAI(); + } + break; + + case NPCAIStyleID.FlowInvader: + switch (npc.type) + { + case NPCID.StardustJellyfishBig: + return new RevengeanceAndDeathAI.FlowInvaderAI(); + } + break; + + case NPCAIStyleID.Spore: + switch (npc.type) + { + case NPCID.Spore: + case NPCID.FungiSpore: + return new RevengeanceAndDeathAI.SporeAI(); + } + break; + } + } + + #endregion + + return null; + } + #endregion + + internal static bool IsGlobalChangeBlacklisted(NPC npc) => GlobalChangeBlacklist.Contains(npc.type); + + internal static void RegisterNetID(VanillaAIOverride aiOverride) + { + var id = NetIDLookup.Count + 1; + NetIDLookup[aiOverride.GetType()] = id; + } + + public override void Unload() + { + NetIDLookup.Clear(); + GlobalChangeBlacklist.Clear(); + ModifyAIOverride = null; + } + + public override void SetDefaults(NPC npc) + { + if (!Enabled) + return; + + // Clients will get their instance in ReceiveExtraAI + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + AIOverride = GetVanillaAIOverrideToApply(npc); + if (ModifyAIOverride != null) + { + var context = new VanillaAIOverrideContext() + { + NPC = npc, + NPCType = npc.type, + InRevengeanceWorld = CalamityWorld.revenge, + InDeathWorld = CalamityWorld.death, + InBossRush = BossRushEvent.BossRushActive, + OverrideToApply = AIOverride + }; + ModifyAIOverride.Invoke(context); + AIOverride = context.OverrideToApply; + } + + if (AIOverride != null) + { + AIOverride.NPC = npc; + AIOverride.SetDefaults(Mod); + } + } + + #region Hooks + + public override void OnSpawn(NPC npc, IEntitySource source) + { + if (!Enabled) + return; + + AIOverride?.OnSpawn(Mod); + } + + public override bool PreAI(NPC npc) + { + if (!Enabled) + return base.PreAI(npc); + + bool result = true; + if (!IsGlobalChangeBlacklisted(npc)) result &= GlobalPreAI(npc); + if (AIOverride != null) + { + result &= AIOverride.AI(Mod); + + if (AIOverride.DisableMultiplayerSmoothing) + { + npc.netOffset = Vector2.Zero; + if (AIOverride.EnableMultiplayerSmoothingAheadOfAI) + AIOverride.DisableMultiplayerSmoothing = false; + } + } + return result; + } + + public override void AI(NPC npc) + { + if (!Enabled) + return; + + if (!IsGlobalChangeBlacklisted(npc)) GlobalAI(npc); + } + + public override void PostAI(NPC npc) + { + if (!Enabled) + return; + + AIOverride?.PostAI(Mod); + } + + public override bool? CanBeHitByProjectile(NPC npc, Projectile projectile) + { + if (!Enabled) + return base.CanBeHitByProjectile(npc, projectile); + + return AIOverride?.CanBeHitByProjectile(Mod, projectile); + } + + public override void HitEffect(NPC npc, NPC.HitInfo hit) + { + if (!Enabled) + return; + + AIOverride?.HitEffect(Mod, hit); + } + + public override void ModifyHitByItem(NPC npc, Player player, Item item, ref NPC.HitModifiers modifiers) + { + if (!Enabled) + return; + + AIOverride?.ModifyHitByItem(Mod, player, item, ref modifiers); + } + + public override void ModifyHitByProjectile(NPC npc, Projectile projectile, ref NPC.HitModifiers modifiers) + { + if (!Enabled) + return; + + AIOverride?.ModifyHitByProjectile(Mod, projectile, ref modifiers); + } + + public override void OnHitByItem(NPC npc, Player player, Item item, NPC.HitInfo hit, int damageDone) + { + if (!Enabled) + return; + + AIOverride?.OnHitByItem(Mod, player, item, hit, damageDone); + } + + public override void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitInfo hit, int damageDone) + { + if (!Enabled) + return; + + AIOverride?.OnHitByProjectile(Mod, projectile, hit, damageDone); + } + + public override bool PreKill(NPC npc) + { + if (!Enabled || AIOverride == null) + return base.PreKill(npc); + + return AIOverride.PreKill(Mod); + } + + public override void FindFrame(NPC npc, int frameHeight) + { + if (!Enabled) + return; + + AIOverride?.FindFrame(Mod, frameHeight); + } + + public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (!Enabled) + base.PreDraw(npc, spriteBatch, screenPos, drawColor); + + bool result = true; + if (!IsGlobalChangeBlacklisted(npc)) result &= GlobalPreDraw(npc, spriteBatch, screenPos, drawColor); + result &= AIOverride?.PreDraw(Mod, spriteBatch, screenPos, drawColor) ?? true; + return result; + } + + public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (!Enabled) + return; + + if (!IsGlobalChangeBlacklisted(npc)) GlobalPostDraw(npc, spriteBatch, screenPos, drawColor); + AIOverride?.PostDraw(Mod, spriteBatch, screenPos, drawColor); + } + + #endregion + + #region Networking + + public static int GetNetID(VanillaAIOverride aiOverride) + { + if (aiOverride == null) + return InvalidNetID; + + if (!NetIDLookup.TryGetValue(aiOverride.GetType(), out var netID)) + return InvalidNetID; + + return netID; + } + + public static bool TryGetNetID(VanillaAIOverride aIOverride, out int netID) + { + netID = GetNetID(aIOverride); + return netID != InvalidNetID; + } + + public static VanillaAIOverride GetNewInstanceOrNullFromNetID(int netID, NPC ownerNPC) + { + var type = NetIDLookup.FirstOrDefault(kv => kv.Value == netID).Key; + + if (type == null) + return null; + + var instance = (VanillaAIOverride)Activator.CreateInstance(type); + if (instance == null) + return null; + + instance.NPC = ownerNPC; + return instance; + } + + public override void SendExtraAI(NPC npc, BitWriter bitWriter, BinaryWriter binaryWriter) + { + // OnKill or any similar hooks are not reliable for checking these. + // As SetDefaults being called on deactivated/dead NPC before ReceiveExtraAI, Prevent Sending ExtraAI is only clean way to do. + if (!npc.active || npc.life <= 0) + { + AIOverride = null; + binaryWriter.Write7BitEncodedInt(InvalidNetID); + return; + } + + if (!TryGetNetID(AIOverride, out var netID)) + { + binaryWriter.Write7BitEncodedInt(InvalidNetID); + return; + } + + binaryWriter.Write7BitEncodedInt(netID); + AIOverride.SendExtraAI(bitWriter, binaryWriter); + } + + public override void ReceiveExtraAI(NPC npc, BitReader bitReader, BinaryReader binaryReader) + { + var remoteNetID = binaryReader.Read7BitEncodedInt(); + var localNetID = GetNetID(AIOverride); + if (localNetID != remoteNetID) + { + AIOverride = GetNewInstanceOrNullFromNetID(remoteNetID, npc); + AIOverride?.SetDefaults(Mod); + } + + AIOverride?.ReceiveExtraAI(bitReader, binaryReader); + } + + #endregion +} diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs deleted file mode 100644 index 17167c14af..0000000000 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ /dev/null @@ -1,1093 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; - -namespace CalamityMod.NPCs -{ - public partial class CalamityGlobalAI - { - internal enum MothronAIState - { - DespawnYeet = -1, - NewAISelection = 0, - FlyTowardsPlayer = 1, - AccelerateTowardsPlayer = 2, - ChargeRedirect = 3, - ChargePreparation = 4, - DoTheFuckingCharge = 5, - PickSpotToLayEgg = 6, - FlyToEggSpot = 7, - LayEgg = 8 - } - - #region Buffed Mothron AI - public static bool BuffedMothronAI(NPC npc) - { - npc.noTileCollide = false; - npc.noGravity = true; - npc.knockBackResist = 0f; - - ref float aiState = ref npc.ai[0]; - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - bool phase2 = lifeRatio < 0.4f; - bool phase3 = lifeRatio < 0.1f; - - Player target = Main.player[npc.target]; - - // Despawn if no valid target exists or there's no ongoing eclipse. - if (!Main.eclipse) - aiState = (int)MothronAIState.DespawnYeet; - else if (npc.target < 0 || target.dead || !target.active) - { - npc.TargetClosest(true); - if (target.dead) - { - aiState = (int)MothronAIState.DespawnYeet; - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.netUpdate = true; - } - } - - float flyInertia; - float chargeSpeed = 32f; - Vector2 idealFlyVelocity; - switch ((MothronAIState)(int)aiState) - { - case MothronAIState.DespawnYeet: - npc.damage = 0; - Vector2 idealVelocity = Vector2.UnitY * -34f; - npc.velocity = (npc.velocity * 4f + idealVelocity) / 5f; - npc.noTileCollide = true; - npc.dontTakeDamage = true; - return false; - - case MothronAIState.NewAISelection: - npc.damage = 0; - - ref float aiTimer = ref npc.ai[1]; - - npc.TargetClosest(true); - - if (npc.Center.X < target.Center.X - 2f) - npc.direction = 1; - if (npc.Center.X > target.Center.X + 2f) - npc.direction = -1; - - npc.spriteDirection = npc.direction; - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; - - // Rebounding on tile collision. - if (npc.collideX) - { - npc.velocity.X *= -npc.oldVelocity.X * 0.5f; - npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -4f, 4f); - } - if (npc.collideY) - { - npc.velocity.Y *= -npc.oldVelocity.Y * 0.5f; - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -4f, 4f); - } - - Vector2 destinationAboveTarget = target.Center - Vector2.UnitY * 200f; - float distanceFromAboveTarget = npc.Distance(destinationAboveTarget); - if (distanceFromAboveTarget > 3000f) - { - aiState = (int)MothronAIState.FlyTowardsPlayer; - aiTimer = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - // Otherwise fly towards the destination if relatively far from it. - else if (distanceFromAboveTarget > 600f) - { - flyInertia = 30f; - idealFlyVelocity = npc.SafeDirectionTo(destinationAboveTarget, -Vector2.UnitY) * 15f; - npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; - } - - // And otherwise, if near the destination, slow down a bit. - else if (npc.velocity.Length() > 2f) - npc.velocity *= 0.95f; - else if (npc.velocity.Length() < 1f) - npc.velocity *= 1.05f; - - aiTimer++; - - // Select a new AI state after 10 frames. - if (aiTimer >= 10f && Main.netMode != NetmodeID.MultiplayerClient) - { - aiTimer = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - while ((MothronAIState)(int)aiState == MothronAIState.NewAISelection) - { - int selection = Main.rand.Next(3); - if (phase3) - selection = 1; - else if (phase2) - selection = Main.rand.Next(2); - - if (selection == 0 && Collision.CanHit(npc.Center, 1, 1, target.Center, 1, 1)) - aiState = (int)MothronAIState.AccelerateTowardsPlayer; - else if (selection == 1) - aiState = (int)MothronAIState.ChargeRedirect; - else if (selection == 2 && NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 2) - aiState = (int)MothronAIState.PickSpotToLayEgg; - } - npc.ForceNetUpdate(); - } - break; - - case MothronAIState.FlyTowardsPlayer: - npc.damage = 0; - - npc.collideX = false; - npc.collideY = false; - npc.noTileCollide = true; - - if (npc.target < 0 || !target.active || target.dead) - npc.TargetClosest(true); - - npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.02f) / 10f; - - // Don't bother flying anymore if we're stuck and the target is somewhat close. - if (npc.WithinRange(target.Center, 500f) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - aiState = (int)MothronAIState.NewAISelection; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - float flySpeed = 18f + npc.Distance(target.Center) / 100f; - flyInertia = 25f; - idealFlyVelocity = npc.SafeDirectionTo(target.Center, -Vector2.UnitY) * flySpeed; - npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; - break; - - case MothronAIState.AccelerateTowardsPlayer: - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - - aiTimer = ref npc.ai[1]; - ref float flySpeedAdditive = ref npc.ai[2]; - - // If no valid target exists, try to find a new one and select a new attack. - if (npc.target < 0 || !target.active || target.dead) - { - npc.TargetClosest(true); - aiState = (int)MothronAIState.NewAISelection; - aiTimer = 0f; - flySpeedAdditive = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.025f) / 5f; - - // Rebounding on tile collision. - if (npc.collideX) - { - npc.velocity.X *= -npc.oldVelocity.X * 0.5f; - npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -4f, 4f); - } - if (npc.collideY) - { - npc.velocity.Y *= -npc.oldVelocity.Y * 0.5f; - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -4f, 4f); - } - - Vector2 destination = target.Center - Vector2.UnitY * 20f; - - flySpeedAdditive += 0.0222222228f; - if (Main.expertMode) - flySpeedAdditive += 0.0166666675f; - - flySpeed = 12f + flySpeedAdditive + npc.Distance(destination) / 120f; - flyInertia = 20f; - idealFlyVelocity = npc.SafeDirectionTo(destination, -Vector2.UnitY) * flySpeed; - npc.velocity = (npc.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; - - aiTimer++; - // Stop flying if there's an obstacle between the npc and target. - if (aiTimer >= 120f || !Collision.CanHit(npc.Center, 1, 1, target.Center, 1, 1)) - { - aiState = (int)MothronAIState.NewAISelection; - aiTimer = 0f; - flySpeedAdditive = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - break; - - case MothronAIState.ChargeRedirect: - npc.damage = 0; - - flySpeedAdditive = ref npc.ai[2]; - npc.noTileCollide = true; - - npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; - - destination = target.Center; - destination -= Vector2.UnitY * 12f; - - float xOffset = 600f; - if (npc.Center.X > target.Center.X) - destination.X += xOffset; - else - destination.X -= xOffset; - - // If close to the destination beside the player, enter the charge phase. - if (Main.netMode != NetmodeID.MultiplayerClient && - Math.Abs(npc.Center.X - target.Center.X) > xOffset - 50f && Math.Abs(npc.Center.Y - target.Center.Y) < 20f) - { - aiState = (int)MothronAIState.ChargePreparation; - flySpeedAdditive = 0f; - npc.ForceNetUpdate(); - } - - flySpeedAdditive += 0.0333333351f; - flySpeed = 24f + flySpeedAdditive; - flyInertia = 4f; - idealVelocity = npc.SafeDirectionTo(destination, -Vector2.UnitY) * flySpeed; - npc.velocity = (npc.velocity * (flyInertia - 1f) + idealVelocity) / flyInertia; - break; - - case MothronAIState.ChargePreparation: - npc.damage = 0; - - aiTimer = ref npc.ai[1]; - ref float chargeDirection = ref npc.ai[2]; - - npc.noTileCollide = true; - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; - - destination = target.Center - Vector2.UnitY * 12f; - - float chargePreperationInertia = 8f; - Vector2 chargeVelocity = npc.SafeDirectionTo(destination, -Vector2.UnitY) * chargeSpeed; - npc.velocity = (npc.velocity * (chargePreperationInertia - 1f) + chargeVelocity) / chargePreperationInertia; - npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - - // Redirect for 10 frames. After that time has been spent, immediately charge as usual. - if (Main.netMode != NetmodeID.MultiplayerClient) - { - aiTimer++; - if (aiTimer > 10f) - { - npc.velocity = chargeVelocity; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - aiState = (int)MothronAIState.DoTheFuckingCharge; - chargeDirection = npc.direction; - npc.ForceNetUpdate(); - } - } - break; - - case MothronAIState.DoTheFuckingCharge: - chargeDirection = ref npc.ai[2]; - flySpeedAdditive = ref npc.ai[3]; - - npc.damage = (int)Math.Round(npc.defDamage * 1.2); - npc.collideX = false; - npc.collideY = false; - npc.noTileCollide = true; - flySpeedAdditive += 0.0333333351f; - npc.velocity.X = (chargeSpeed + flySpeedAdditive) * chargeDirection; - - float chargeDistance = 460f; - if (Main.netMode != NetmodeID.MultiplayerClient && - (chargeDirection > 0f && npc.Center.X > target.Center.X + chargeDistance) || - (chargeDirection < 0f && npc.Center.X < target.Center.X - chargeDistance)) - { - // If not stuck, pick a new attack. - if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - aiState = (int)MothronAIState.NewAISelection; - chargeDirection = 0f; - flySpeedAdditive = 0f; - npc.ForceNetUpdate(); - } - - // Otherwise, if somewhat horizontally far from the target, go to typical flying by default. - else if (Math.Abs(npc.Center.X - target.Center.X) > chargeDistance * 2f - 120f) - { - aiState = (int)MothronAIState.FlyTowardsPlayer; - chargeDirection = 0f; - flySpeedAdditive = 0f; - npc.ForceNetUpdate(); - } - } - npc.rotation = (npc.rotation * 4f + npc.velocity.X * 0.0175f) / 5f; - break; - - case MothronAIState.PickSpotToLayEgg: - npc.damage = 0; - - ref float laySpotPositionX = ref npc.ai[2]; - ref float laySpotPositionY = ref npc.ai[3]; - // Fallback if the spot selection fails. - npc.TargetClosest(true); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - aiState = (int)MothronAIState.NewAISelection; - laySpotPositionX = laySpotPositionY = -1f; - - for (int i = 0; i < 1000; i++) - { - int potentialSpotX = (int)target.Center.X / 16; - int potentialSpotY = (int)target.Center.Y / 16; - - // Become more open to positions to search the more failed tries that have been accumulated. - int checkAreaX = 30 + i / 50; - int checkAreaY = 20 + i / 75; - - potentialSpotX += Main.rand.Next(-checkAreaX, checkAreaX + 1); - potentialSpotY += Main.rand.Next(-checkAreaY, checkAreaY + 1); - - if (!WorldGen.SolidTile(potentialSpotX, potentialSpotY)) - { - // Search downward until a solid tile is reached. - // Stop checking if the spot is below the world surface, to prevent potential infinite loops. - while (!WorldGen.SolidTile(potentialSpotX, potentialSpotY) && potentialSpotY < Main.worldSurface) - potentialSpotY++; - - // And ensure that the spot isn't too far away. - if (npc.WithinRange(new Vector2(potentialSpotX, potentialSpotY).ToWorldCoordinates(), 1600f)) - { - aiState = (int)MothronAIState.FlyToEggSpot; - laySpotPositionX = potentialSpotX; - laySpotPositionY = potentialSpotY; - break; - } - } - } - npc.ForceNetUpdate(); - } - break; - - case MothronAIState.FlyToEggSpot: - npc.damage = 0; - - npc.spriteDirection = npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; - npc.noTileCollide = true; - - Vector2 spotToLayEgg = new Vector2(npc.ai[2], npc.ai[3]).ToWorldCoordinates(8f, -20f); - float distanceFromSpot = npc.Distance(spotToLayEgg); - flySpeed = 12f + distanceFromSpot / 150f; - - if (flySpeed > 20f) - flySpeed = 20f; - - if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 10f) - { - aiState = (int)MothronAIState.LayEgg; - npc.netUpdate = true; - } - - flyInertia = 10f; - npc.velocity = (npc.velocity * (flyInertia - 1f) + npc.SafeDirectionTo(spotToLayEgg, -Vector2.UnitY) * flySpeed) / flyInertia; - break; - - case MothronAIState.LayEgg: - npc.damage = 0; - - npc.rotation = (npc.rotation * 9f + npc.velocity.X * 0.025f) / 10f; - npc.noTileCollide = false; - - spotToLayEgg = new Vector2(npc.ai[2], npc.ai[3]).ToWorldCoordinates(8f, -28f); - distanceFromSpot = npc.Distance(spotToLayEgg); - float hoverSpeed = 4f; - float hoverInertia = 2f; - - if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 44f) - { - ref float attackTimer = ref npc.ai[1]; - int eggLayTime = 20; - if (Main.expertMode) - eggLayTime = (int)(eggLayTime * 0.75); - int waitTime = eggLayTime; - - attackTimer++; - if (attackTimer == eggLayTime) - NPC.NewNPC(npc.GetSource_FromAI(), (int)spotToLayEgg.X, (int)spotToLayEgg.Y + 20, 478, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - else if (attackTimer == eggLayTime + waitTime) - { - aiState = (int)MothronAIState.NewAISelection; - attackTimer = 0f; - npc.ai[2] = npc.ai[3] = 0f; - - // Try to lay another egg at a 66% chance if the amount of eggs + spawns is not at the limit. - if (NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 3 && !Main.rand.NextBool(3)) - aiState = (int)MothronAIState.PickSpotToLayEgg; - else if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - aiState = (int)MothronAIState.FlyTowardsPlayer; - npc.netUpdate = true; - } - } - - if (distanceFromSpot < hoverSpeed) - hoverSpeed = distanceFromSpot; - - Vector2 hoverVelocity = npc.SafeDirectionTo(spotToLayEgg) * hoverSpeed; - npc.velocity = (npc.velocity * (hoverInertia - 1f) + hoverVelocity) / hoverInertia; - if (npc.velocity.HasNaNs()) - npc.velocity = Vector2.Zero; - break; - } - return false; - } - #endregion - - #region Buffed Pumpking and Pumpking Blade AI - public static bool BuffedPumpkingAI(NPC npc) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] > 6f) - { - npc.localAI[0] = 0f; - npc.localAI[1] += 1f; - - if (npc.localAI[1] > 4f) - npc.localAI[1] = 0f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] > 300f) - { - npc.ai[3] = (float)Main.rand.Next(3); - npc.localAI[2] = 0f; - } - else if (npc.ai[3] == 0f && npc.localAI[2] % 30f == 0f && npc.localAI[2] > 30f) - { - float greekFireSpeed = 10f; - Vector2 greekFireSpawnPos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - if (!WorldGen.SolidTile((int)greekFireSpawnPos.X / 16, (int)greekFireSpawnPos.Y / 16)) - { - float greekFireTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - greekFireSpawnPos.X; - float greekFireTargetY = Main.player[npc.target].position.Y - greekFireSpawnPos.Y; - greekFireTargetX += (float)Main.rand.Next(-50, 51); - greekFireTargetY += (float)Main.rand.Next(50, 201); - greekFireTargetY *= 0.2f; - float greekFireTargetDist = (float)Math.Sqrt((double)(greekFireTargetX * greekFireTargetX + greekFireTargetY * greekFireTargetY)); - greekFireTargetDist = greekFireSpeed / greekFireTargetDist; - greekFireTargetX *= greekFireTargetDist; - greekFireTargetY *= greekFireTargetDist; - greekFireTargetX *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - greekFireTargetY *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - Projectile.NewProjectile(npc.GetSource_FromAI(), greekFireSpawnPos.X, greekFireSpawnPos.Y, greekFireTargetX, greekFireTargetY, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); - } - } - } - - if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.TargetClosest(true); - npc.ai[0] = 1f; - - int pumpkingBlades = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[pumpkingBlades].ai[0] = -1f; - Main.npc[pumpkingBlades].ai[1] = (float)npc.whoAmI; - Main.npc[pumpkingBlades].target = npc.target; - Main.npc[pumpkingBlades].netUpdate = true; - - pumpkingBlades = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[pumpkingBlades].ai[0] = 1f; - Main.npc[pumpkingBlades].ai[1] = (float)npc.whoAmI; - Main.npc[pumpkingBlades].ai[3] = 150f; - Main.npc[pumpkingBlades].target = npc.target; - Main.npc[pumpkingBlades].netUpdate = true; - } - - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) - { - npc.TargetClosest(true); - - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) - npc.ai[1] = 2f; - } - - if (Main.dayTime) - { - npc.velocity.Y += 0.3f; - npc.velocity.X *= 0.9f; - } - else if (npc.ai[1] == 0f) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 300f) - { - if (npc.ai[3] != 1f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - else - { - npc.ai[2] = 0f; - npc.ai[1] = 1f; - npc.TargetClosest(true); - npc.netUpdate = true; - } - } - - Vector2 aggressivePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float aggressiveTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - aggressivePosition.X; - float aggressiveTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - aggressivePosition.Y; - float aggressiveTargetDist = (float)Math.Sqrt((double)(aggressiveTargetX * aggressiveTargetX + aggressiveTargetY * aggressiveTargetY)); - float aggressiveSpeed = 8f; - - if (npc.ai[3] == 1f) - { - if (aggressiveTargetDist > 900f) - aggressiveSpeed = 14f; - else if (aggressiveTargetDist > 600f) - aggressiveSpeed = 12f; - else if (aggressiveTargetDist > 300f) - aggressiveSpeed = 10f; - } - - if (aggressiveTargetDist > 50f) - { - aggressiveTargetDist = aggressiveSpeed / aggressiveTargetDist; - npc.velocity.X = (npc.velocity.X * 14f + aggressiveTargetX * aggressiveTargetDist) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + aggressiveTargetY * aggressiveTargetDist) / 15f; - } - } - else if (npc.ai[1] == 1f) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 600f || npc.ai[3] != 1f) - { - npc.ai[2] = 0f; - npc.ai[1] = 0f; - } - - Vector2 scytheAttackPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float scytheAttackTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheAttackPosition.X; - float scytheAttackTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheAttackPosition.Y; - float scytheAttackTargetDist = (float)Math.Sqrt((double)(scytheAttackTargetX * scytheAttackTargetX + scytheAttackTargetY * scytheAttackTargetY)); - scytheAttackTargetDist = 20f / scytheAttackTargetDist; - - npc.velocity.X = (npc.velocity.X * 49f + scytheAttackTargetX * scytheAttackTargetDist) / 50f; - npc.velocity.Y = (npc.velocity.Y * 49f + scytheAttackTargetY * scytheAttackTargetDist) / 50f; - } - else if (npc.ai[1] == 2f) - { - npc.ai[1] = 3f; - npc.velocity.Y += 0.1f; - - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.X *= 0.95f; - - if (npc.timeLeft > 500) - npc.timeLeft = 500; - } - npc.rotation = npc.velocity.X * -0.02f; - - return false; - } - - public static bool BuffedPumpkingBladeAI(NPC npc) - { - npc.spriteDirection = -(int)npc.ai[0]; - - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != 58) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) - { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient && Main.npc[(int)npc.ai[1]].ai[3] == 2f) - { - npc.localAI[1] += 1f; - if (npc.localAI[1] > 30f) - { - npc.localAI[1] = 0f; - - float scytheProjSpeed = 0.01f; - Vector2 scytheProjSpawn = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - float scytheProjTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - scytheProjSpawn.X; - float scytheProjTargetY = Main.player[npc.target].position.Y - scytheProjSpawn.Y; - float scytheProjTargetDist = (float)Math.Sqrt((double)(scytheProjTargetX * scytheProjTargetX + scytheProjTargetY * scytheProjTargetY)); - - scytheProjTargetDist = scytheProjSpeed / scytheProjTargetDist; - scytheProjTargetX *= scytheProjTargetDist; - scytheProjTargetY *= scytheProjTargetDist; - - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, scytheProjTargetX, scytheProjTargetY, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, npc.rotation, (float)npc.spriteDirection); - } - } - - if (Main.dayTime) - { - npc.velocity.Y += 0.3f; - npc.velocity.X *= 0.9f; - return false; - } - - if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) - npc.timeLeft = 10; - - npc.ai[3] += 1f; - if (npc.ai[3] >= 180f) - { - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - Vector2 scytheSwipePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float scytheSwipeTargetX = (Main.player[npc.target].Center.X + Main.npc[(int)npc.ai[1]].Center.X) / 2f; - float scytheSwipeTargetY = (Main.player[npc.target].Center.Y + Main.npc[(int)npc.ai[1]].Center.Y) / 2f; - scytheSwipeTargetX += -170f * npc.ai[0] - scytheSwipePosition.X; - scytheSwipeTargetY += 90f - scytheSwipePosition.Y; - - float scytheSwipeReelbackDist = Math.Abs(Main.player[npc.target].Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(Main.player[npc.target].Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if (scytheSwipeReelbackDist > 700f) - { - scytheSwipeTargetX = Main.npc[(int)npc.ai[1]].Center.X - 170f * npc.ai[0] - scytheSwipePosition.X; - scytheSwipeTargetY = Main.npc[(int)npc.ai[1]].Center.Y + 90f - scytheSwipePosition.Y; - } - - float scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); - float scytheSwipeSpeed = 8f; - if (scytheSwipeTargetDist > 1000f) - scytheSwipeSpeed = 23f; - else if (scytheSwipeTargetDist > 800f) - scytheSwipeSpeed = 20f; - else if (scytheSwipeTargetDist > 600f) - scytheSwipeSpeed = 17f; - else if (scytheSwipeTargetDist > 400f) - scytheSwipeSpeed = 14f; - else if (scytheSwipeTargetDist > 200f) - scytheSwipeSpeed = 11f; - - if (npc.ai[0] < 0f && npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) - scytheSwipeTargetX -= 4f; - if (npc.ai[0] > 0f && npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) - scytheSwipeTargetX += 4f; - - scytheSwipeTargetDist = scytheSwipeSpeed / scytheSwipeTargetDist; - npc.velocity.X = (npc.velocity.X * 14f + scytheSwipeTargetX * scytheSwipeTargetDist) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + scytheSwipeTargetY * scytheSwipeTargetDist) / 15f; - scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); - - if (scytheSwipeTargetDist > 20f) - npc.rotation = (float)Math.Atan2((double)scytheSwipeTargetY, (double)scytheSwipeTargetX) + MathHelper.PiOver2; - } - else if (npc.ai[2] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 scytheReturnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float scytheReturnTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - scytheReturnPosition.X; - float scytheReturnTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - scytheReturnPosition.Y; - float scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); - - npc.rotation = (float)Math.Atan2((double)scytheReturnTargetY, (double)scytheReturnTargetX) + MathHelper.PiOver2; - npc.velocity.X *= 0.95f; - npc.velocity.Y -= 0.3f; - - if (npc.velocity.Y < -18f) - npc.velocity.Y = -18f; - - if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.TargetClosest(true); - npc.ai[2] = 2f; - - scytheReturnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - scytheReturnTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheReturnPosition.X; - scytheReturnTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheReturnPosition.Y; - scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); - scytheReturnTargetDist = 24f / scytheReturnTargetDist; - - npc.velocity.X = scytheReturnTargetX * scytheReturnTargetDist; - npc.velocity.Y = scytheReturnTargetY * scytheReturnTargetDist; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 2f) - { - // Avoid cheap bullshit - npc.damage = npc.defDamage; - - float scytheReturnDestination = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f || scytheReturnDestination > 800f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] = 3f; - } - } - else if (npc.ai[2] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 scytheLesserSwipePos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float scytheLesserSwipeTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - scytheLesserSwipePos.X; - float scytheLesserSwipeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - scytheLesserSwipePos.Y; - float scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); - - npc.rotation = (float)Math.Atan2((double)scytheLesserSwipeTargetY, (double)scytheLesserSwipeTargetX) + MathHelper.PiOver2; - npc.velocity.Y *= 0.95f; - npc.velocity.X += 0.3f * -npc.ai[0]; - - if (npc.velocity.X < -18f) - npc.velocity.X = -18f; - if (npc.velocity.X > 18f) - npc.velocity.X = 18f; - - if (npc.position.X + (float)(npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (float)(npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) + 500f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.TargetClosest(true); - npc.ai[2] = 5f; - - scytheLesserSwipePos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - scytheLesserSwipeTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheLesserSwipePos.X; - scytheLesserSwipeTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheLesserSwipePos.Y; - scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); - scytheLesserSwipeTargetDist = 17f / scytheLesserSwipeTargetDist; - - npc.velocity.X = scytheLesserSwipeTargetX * scytheLesserSwipeTargetDist; - npc.velocity.Y = scytheLesserSwipeTargetY * scytheLesserSwipeTargetDist; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 5f) - { - // Set damage - npc.damage = npc.defDamage; - - float scytheLesserSwipeReturnDest = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - - if ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || scytheLesserSwipeReturnDest > 800f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] = 0f; - } - } - - return false; - } - #endregion - - #region Buffed Ice Queen AI - public static bool BuffedIceQueenAI(NPC npc) - { - if (Main.dayTime) - { - if (npc.velocity.X > 0f) - npc.velocity.X += 0.25f; - else - npc.velocity.X -= 0.25f; - - npc.velocity.Y -= 0.1f; - npc.rotation = npc.velocity.X * 0.05f; - } - else if (npc.ai[0] == 0f) - { - if (npc.ai[2] == 0f) - { - npc.TargetClosest(true); - - if (npc.Center.X < Main.player[npc.target].Center.X) - npc.ai[2] = 1f; - else - npc.ai[2] = -1f; - } - - npc.TargetClosest(true); - float iceQueenTargetDist = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); - - if (npc.Center.X < Main.player[npc.target].Center.X && npc.ai[2] < 0f && iceQueenTargetDist > 800f) - npc.ai[2] = 0f; - if (npc.Center.X > Main.player[npc.target].Center.X && npc.ai[2] > 0f && iceQueenTargetDist > 800f) - npc.ai[2] = 0f; - - float iceQueenAcceleration = 0.6f; - float iceQueenMaxVelocity = 10f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - { - iceQueenAcceleration = 0.7f; - iceQueenMaxVelocity = 12f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.5) - { - iceQueenAcceleration = 0.8f; - iceQueenMaxVelocity = 14f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.25) - { - iceQueenAcceleration = 0.95f; - iceQueenMaxVelocity = 16f; - } - - npc.velocity.X += npc.ai[2] * iceQueenAcceleration; - if (npc.velocity.X > iceQueenMaxVelocity) - npc.velocity.X = iceQueenMaxVelocity; - if (npc.velocity.X < -iceQueenMaxVelocity) - npc.velocity.X = -iceQueenMaxVelocity; - - float iceQueenHoverHeight = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (iceQueenHoverHeight < 150f) - npc.velocity.Y -= 0.2f; - if (iceQueenHoverHeight > 200f) - npc.velocity.Y += 0.2f; - if (npc.velocity.Y > 9f) - npc.velocity.Y = 9f; - if (npc.velocity.Y < -9f) - npc.velocity.Y = -9f; - - npc.rotation = npc.velocity.X * 0.05f; - - if ((iceQueenTargetDist < 500f || npc.ai[3] < 0f) && npc.position.Y < Main.player[npc.target].position.Y) - { - npc.ai[3] += 1f; - int frostWaveFireDelay = 8; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - frostWaveFireDelay = 7; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - frostWaveFireDelay = 6; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - frostWaveFireDelay = 5; - - frostWaveFireDelay++; - if (npc.ai[3] > (float)frostWaveFireDelay) - npc.ai[3] = (float)-(float)frostWaveFireDelay; - - if (npc.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 frostWavePosition = new Vector2(npc.Center.X, npc.Center.Y); - frostWavePosition.X += npc.velocity.X * 7f; - float frostWaveTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - frostWavePosition.X; - float frostWaveTargetY = Main.player[npc.target].Center.Y - frostWavePosition.Y; - float frostWaveTargetDist = (float)Math.Sqrt((double)(frostWaveTargetX * frostWaveTargetX + frostWaveTargetY * frostWaveTargetY)); - - float frostWaveSpeed = 8f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - frostWaveSpeed = 9f; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - frostWaveSpeed = 10f; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - frostWaveSpeed = 11f; - - frostWaveTargetDist = frostWaveSpeed / frostWaveTargetDist; - frostWaveTargetX *= frostWaveTargetDist; - frostWaveTargetY *= frostWaveTargetDist; - - Projectile.NewProjectile(npc.GetSource_FromAI(), frostWavePosition.X, frostWavePosition.Y, frostWaveTargetX, frostWaveTargetY, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); - } - } - else if (npc.ai[3] < 0f) - npc.ai[3] += 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] += (float)Main.rand.Next(1, 4); - - if (npc.ai[1] > 600f && iceQueenTargetDist < 600f) - npc.ai[0] = -1f; - } - } - else if (npc.ai[0] == 1f) - { - npc.TargetClosest(true); - - float icicleAttackAcceleration = 0.2f; - float icicleAttackMaxVelocity = 10f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - { - icicleAttackAcceleration = 0.24f; - icicleAttackMaxVelocity = 12f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.5) - { - icicleAttackAcceleration = 0.28f; - icicleAttackMaxVelocity = 14f; - } - if ((double)npc.life < (double)npc.lifeMax * 0.25) - { - icicleAttackAcceleration = 0.32f; - icicleAttackMaxVelocity = 16f; - } - icicleAttackAcceleration -= 0.05f; - icicleAttackMaxVelocity -= 1f; - - if (npc.Center.X < Main.player[npc.target].Center.X) - { - npc.velocity.X += icicleAttackAcceleration; - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; - } - if (npc.Center.X > Main.player[npc.target].Center.X) - { - npc.velocity.X -= icicleAttackAcceleration; - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; - } - if (npc.velocity.X > icicleAttackMaxVelocity || npc.velocity.X < -icicleAttackMaxVelocity) - npc.velocity.X *= 0.95f; - - float icicleAttackHoverHeight = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (icicleAttackHoverHeight < 180f) - npc.velocity.Y -= 0.1f; - if (icicleAttackHoverHeight > 200f) - npc.velocity.Y += 0.1f; - - if (npc.velocity.Y > 7f) - npc.velocity.Y = 7f; - if (npc.velocity.Y < -7f) - npc.velocity.Y = -7f; - - npc.rotation = npc.velocity.X * 0.01f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[3] += 1f; - int icicleFireDelay = 10; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - icicleFireDelay = 8; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - icicleFireDelay = 6; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - icicleFireDelay = 4; - if ((double)npc.life < (double)npc.lifeMax * 0.1) - icicleFireDelay = 2; - - icicleFireDelay += 3; - if (npc.ai[3] >= (float)icicleFireDelay) - { - npc.ai[3] = 0f; - Vector2 icicleSpawnPos = new Vector2(npc.Center.X, npc.position.Y + (float)npc.height - 14f); - int i2 = (int)(icicleSpawnPos.X / 16f); - int j2 = (int)(icicleSpawnPos.Y / 16f); - if (!WorldGen.SolidTile(i2, j2)) - { - float icicleFallSpeed = npc.velocity.Y; - - if (icicleFallSpeed < 0f) - icicleFallSpeed = 0f; - - icicleFallSpeed += 3f; - float speedX2 = npc.velocity.X * 0.25f; - Projectile.NewProjectile(npc.GetSource_FromAI(), icicleSpawnPos.X, icicleSpawnPos.Y, speedX2, icicleFallSpeed, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); - } - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] += (float)Main.rand.Next(1, 4); - - if (npc.ai[1] > 450f) - npc.ai[0] = -1f; - } - } - else if (npc.ai[0] == 2f) - { - npc.TargetClosest(true); - - Vector2 iceRainPosition = new Vector2(npc.Center.X, npc.Center.Y - 20f); - float iceRainXVel = (float)Main.rand.Next(-1000, 1001); - float iceRainYVel = (float)Main.rand.Next(-1000, 1001); - float iceRainVelocity = (float)Math.Sqrt((double)(iceRainXVel * iceRainXVel + iceRainYVel * iceRainYVel)); - float iceRainSpeed = 20f; - - npc.velocity *= 0.95f; - iceRainVelocity = iceRainSpeed / iceRainVelocity; - iceRainXVel *= iceRainVelocity; - iceRainYVel *= iceRainVelocity; - npc.rotation += 0.2f; - iceRainPosition.X += iceRainXVel * 4f; - iceRainPosition.Y += iceRainYVel * 4f; - - npc.ai[3] += 1f; - int iceRainFireDelay = 7; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - iceRainFireDelay--; - if ((double)npc.life < (double)npc.lifeMax * 0.5) - iceRainFireDelay -= 2; - if ((double)npc.life < (double)npc.lifeMax * 0.25) - iceRainFireDelay -= 3; - if ((double)npc.life < (double)npc.lifeMax * 0.1) - iceRainFireDelay -= 4; - - if (npc.ai[3] > (float)iceRainFireDelay) - { - npc.ai[3] = 0f; - int iceRainAttack = Projectile.NewProjectile(npc.GetSource_FromAI(), iceRainPosition.X, iceRainPosition.Y, iceRainXVel, iceRainYVel, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] += (float)Main.rand.Next(1, 4); - - if (npc.ai[1] > 300f) - npc.ai[0] = -1f; - } - } - if (npc.ai[0] == -1f) - { - int attackPicker = Main.rand.Next(3); - npc.TargetClosest(true); - - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 1000f) - attackPicker = 0; - - npc.ai[0] = (float)attackPicker; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - - return false; - } - #endregion - } -} diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 41817f7e07..ed48566ff3 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -6,19 +6,19 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; -using CalamityMod.Sounds; +using CalamityMod.Projectiles.Boss; using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; +using System; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -26,6 +26,7 @@ using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.NPCs.CeaselessVoid { @@ -39,6 +40,8 @@ namespace CalamityMod.NPCs.CeaselessVoid public bool playedbuildsound = false; + public bool madeItToLocation = true; + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 6; @@ -52,34 +55,33 @@ namespace CalamityMod.NPCs.CeaselessVoid NPCID.Sets.MPAllowedEnemies[Type] = true; if (!Main.dedServ) { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); + GlowTexture = Request(Texture + "Glow", AssetRequestMode.AsyncLoad); } } + public static int BeamPortalDamage = 60; // 240 + public static int DarkEnergyProjectileDamage = 60; // 240 + public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 180; // 360 NPC.npcSlots = 36f; NPC.width = 100; NPC.height = 100; NPC.defense = 80; - CalamityGlobalNPC global = NPC.Calamity(); - global.DR = 0.5f; - NPC.LifeMaxNERB(65000, 78000, 72000); - NPC.value = Item.buyPrice(1, 0, 0, 0); + NPC.Calamity().DR = 0.5f; + NPC.LifeMaxNERB(50000, 78000, 72000); + NPC.value = Item.buyPrice(gold: 50); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.noTileCollide = true; NPC.boss = true; - NPC.BossBar = ModContent.GetInstance(); + NPC.BossBar = GetInstance(); NPC.DeathSound = DeathSound; + NPC.Calamity().canBreakPlayerDefense = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -125,7 +127,530 @@ namespace CalamityMod.NPCs.CeaselessVoid public override void AI() { - CeaselessVoidAI.VanillaCeaselessVoidAI(NPC, Mod); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + CalamityGlobalNPC.voidBoss = NPC.whoAmI; + + // Percent life remaining + double lifeRatio = NPC.life / (double)NPC.lifeMax; + + // Difficulty modes + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Phases + bool phase2 = lifeRatio <= 0.7; + bool phase3 = lifeRatio <= 0.4; + bool phase4 = lifeRatio <= 0.1; + bool theBigSucc = NPC.life / (double)NPC.lifeMax <= 0.1; + bool succSoHardThatYouDie = NPC.life / (double)NPC.lifeMax <= 0.005; + + // Spawn Dark Energies + int darkEnergyAmt = death ? 6 : revenge ? 5 : expertMode ? 4 : 3; + if (phase2) + darkEnergyAmt += 1; + if (phase3) + darkEnergyAmt += 1; + if (phase4) + darkEnergyAmt += 1; + + if (Main.getGoodWorld) + darkEnergyAmt *= 2; + + // Spawn a few Dark Energies as soon as the fight starts + int spacing = 360 / darkEnergyAmt; + int distance2 = 10; + if (NPC.ai[2] == 0f) + { + NPC.ai[2] = 1f; + for (int i = 0; i < darkEnergyAmt; i++) + { + for (int j = 0; j < 3; j++) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(NPC.Center.Y + (Math.Cos(i * spacing) * distance2)), NPCType(), NPC.whoAmI, i * spacing, j); + } + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 0.5f); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 1.5f); + } + + // If there are any Dark Energies alive, change AI and don't take damage + bool anyDarkEnergies = NPC.AnyNPCs(NPCType()); + bool movingDuringSuccPhase = NPC.ai[3] == 0f; + NPC.dontTakeDamage = anyDarkEnergies || theBigSucc || movingDuringSuccPhase; + + // 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(); + + Player player = Main.player[NPC.target]; + + // Despawn + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f || (player.position.Y < Main.worldSurface * 16.0 && !BossRushEvent.BossRushActive)) + { + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f || (player.position.Y < Main.worldSurface * 16.0 && !BossRushEvent.BossRushActive)) + { + if (NPC.velocity.Y > 3f) + NPC.velocity.Y = 3f; + NPC.velocity.Y -= 0.1f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + + return; + } + } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; + + // Increase projectile fire rate based on number of nearby active tiles + float projectileFireRateMultiplier = Main.getGoodWorld ? 0.5f : 1.5f; + + // Decides whether Ceaseless moves closer to its target or not + float distanceRequiredToMove = Main.getGoodWorld ? 300f : 720f; + bool move = Vector2.Distance(NPC.Center, player.Center) > distanceRequiredToMove || !Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1); + + // Succ attack + if (!anyDarkEnergies) + { + // This is here because it's used in multiple places + float suckDistance = death ? 1600f : revenge ? 1440f : expertMode ? 1280f : 1040f; + + // Move closer to the target before trying to succ + if (movingDuringSuccPhase) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (move) + Movement(true); + else + NPC.ai[3] = 1f; + } + else + { + // Set damage + NPC.damage = NPC.defDamage; + + // Use this to generate more and more dust in final phase + float finalPhaseDustRatio = 1f; + if (succSoHardThatYouDie) + { + finalPhaseDustRatio = 5f; + } + else if (theBigSucc) + { + float amount = (10f - (float)(NPC.life / (double)NPC.lifeMax) * 100f) / 10f; + finalPhaseDustRatio += MathHelper.Lerp(0f, 2f, amount); + } + + // Slow down + if (NPC.velocity.Length() > 0.5f) + NPC.velocity *= 0.8f; + else + NPC.velocity = Vector2.Zero; + + // Move towards target again if they get outside the succ radius + float moveCloserGateValue = suckDistance * 0.8f; + if (Vector2.Distance(NPC.Center, player.Center) > moveCloserGateValue) + NPC.ai[3] = 0f; + + // Ceaseless Void sucks in dark energy in different patterns + // This attack also sucks in all players that are within reach of the succ + for (int h = 0; h < 3; h++) + { + float distanceDivisor = h + 1f; + float dustDistance = suckDistance / distanceDivisor; + int numDust = (int)(0.1f * MathHelper.TwoPi * dustDistance); + Vector2 dustOffset = Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * dustDistance; + + int var = (int)(dustDistance / finalPhaseDustRatio); + float dustVelocity = 24f / distanceDivisor * finalPhaseDustRatio; + for (int i = 0; i < numDust; i++) + { + if (Main.rand.NextBool(var)) + { + dustOffset = dustOffset.RotatedBy(MathHelper.TwoPi / numDust); + Vector2 dustSpawn = NPC.Center + dustOffset; + Dust dust = Dust.NewDustPerfect(dustSpawn, DustType(), Utils.DirectionTo(dustSpawn, NPC.Center) * dustVelocity, Scale: 3 - h); + dust.fadeIn = 1f; + } + } + } + + float succPower = 0.125f + finalPhaseDustRatio * 0.125f; + for (int i = 0; i < Main.maxPlayers; i++) + { + float distance = Vector2.Distance(Main.player[i].Center, NPC.Center); + if (distance < suckDistance && Main.player[i].grappling[0] == -1) + { + if (Collision.CanHit(NPC.Center, 1, 1, Main.player[i].Center, 1, 1)) + { + float distanceRatio = distance / suckDistance; + float multiplier = 1f - distanceRatio; + + if (Main.player[i].Center.X < NPC.Center.X) + Main.player[i].velocity.X += succPower * multiplier; + else + Main.player[i].velocity.X -= succPower * multiplier; + } + } + } + + // Slowly die in final phase and then implode + // This phase lasts 20 seconds, 60 seconds in GFB + if (theBigSucc && calamityGlobalNPC.newAI[1] % 60f == 0f) + { + int damageIncrement = NPC.lifeMax / (Main.zenithWorld ? 600 : 200); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.life -= damageIncrement; + NPC.DamageEffect(damageIncrement); + } + + if (NPC.life <= (damageIncrement * 5) && !playedbuildsound) + { + SoundEngine.PlaySound(BuildupSound, NPC.Center); + playedbuildsound = true; + } + + if (NPC.life <= 0) + { + NPC.life = 0; + NPC.HitEffect(); + NPC.checkDead(); + } + + NPC.netUpdate = true; + } + + // Beam Portals + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (calamityGlobalNPC.newAI[1] == 0f) + { + int numBeamPortals = revenge ? 3 : 2; + float degrees = 360 / numBeamPortals; + float beamPortalDistance = death ? 400f : revenge ? 420f : expertMode ? 440f : 480f; + int type = ProjectileType(); + for (int i = 0; i < numBeamPortals; i++) + { + float ai1 = i * degrees; + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + (float)(Math.Sin(i * degrees) * beamPortalDistance), player.Center.Y + (float)(Math.Cos(i * degrees) * beamPortalDistance), 0f, 0f, type, BeamPortalDamage, 0f, Main.myPlayer, ai1, 0f); + } + } + } + + // Use this timer to lessen Dark Energy projectile rate of fire while Beam Portals are active + float beamPortalTimeLeft = 600f; + bool summonLessDarkEnergies = false; + if (calamityGlobalNPC.newAI[1] < beamPortalTimeLeft) + { + calamityGlobalNPC.newAI[1] += 1f; + summonLessDarkEnergies = true; + } + else if (theBigSucc) + calamityGlobalNPC.newAI[1] += 1f; + + // Suck in Dark Energy projectiles from far away + calamityGlobalNPC.newAI[3] += 1f; + float darkEnergySpiralGateValue = (summonLessDarkEnergies ? 24f : 12f) * projectileFireRateMultiplier; + if (calamityGlobalNPC.newAI[3] >= darkEnergySpiralGateValue) + { + calamityGlobalNPC.newAI[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ProjectileType(); + bool normalSpread = NPC.localAI[0] % 2f == 0f; + float speed = 0.5f; + int totalProjectiles = 4; + Vector2 spinningPoint = new Vector2(normalSpread ? 0f : -speed, -speed); + float radialOffset = MathHelper.ToRadians(NPC.localAI[1]); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 spawnVector = NPC.Center + Vector2.Normalize(spinningPoint.RotatedBy(MathHelper.TwoPi / totalProjectiles * i + radialOffset)) * suckDistance; + Vector2 velocity = Vector2.Normalize(NPC.Center - spawnVector) * speed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, DarkEnergyProjectileDamage, 0f, Main.myPlayer); + } + } + + NPC.localAI[1] += 10f; + } + + // Summon some extra projectiles in Expert Mode + if (phase2 && expertMode) + { + NPC.localAI[2] += 1f; + if (NPC.localAI[2] >= 60f * projectileFireRateMultiplier) + { + NPC.localAI[2] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ProjectileType(); + bool normalSpread = NPC.localAI[0] % 2f != 0f; + float speed = 2f; + int totalProjectiles = 2; + float radians = MathHelper.TwoPi / totalProjectiles; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = new Vector2(normalSpread ? 0f : -velocityX, -speed); + float radialOffset = MathHelper.ToRadians(NPC.localAI[1] * 0.25f); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 spawnVector = NPC.Center + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; + Vector2 velocity = Vector2.Normalize(NPC.Center - spawnVector) * speed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, DarkEnergyProjectileDamage, 0f, Main.myPlayer); + } + } + } + } + + // Summon some extra projectiles in Revengeance Mode + if (phase4 && revenge) + { + NPC.localAI[3] += 1f; + if (NPC.localAI[3] >= 90f * projectileFireRateMultiplier) + { + NPC.localAI[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ProjectileType(); + bool normalSpread = NPC.localAI[0] % 2f == 0f; + float speed = 4f; + int totalProjectiles = 2; + float radians = MathHelper.TwoPi / totalProjectiles; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(speed * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = new Vector2(normalSpread ? 0f : -velocityX, -speed); + float radialOffset = MathHelper.ToRadians(NPC.localAI[1] * 0.25f); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 spawnVector = NPC.Center + Vector2.Normalize(spinningPoint.RotatedBy(radians * i + radialOffset)) * suckDistance; + Vector2 velocity = Vector2.Normalize(NPC.Center - spawnVector) * speed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, velocity, type, DarkEnergyProjectileDamage, 0f, Main.myPlayer); + } + } + } + } + } + } + else + { + // Avoid cheap bullshit + NPC.damage = 0; + if (move) + { + madeItToLocation = false; + } + if (!madeItToLocation) + { + Movement(false); + } + else + { + // Slow down + if (NPC.velocity.Length() > 0.5f) + NPC.velocity *= 0.8f; + else + NPC.velocity = Vector2.Zero; + } + + // Count up all Dark Energy HP values + int totalDarkEnergyHP = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC darkEnergy = Main.npc[i]; + if (darkEnergy.active && darkEnergy.type == NPCType()) + totalDarkEnergyHP += darkEnergy.life; + } + + // Destroy all Dark Energies if their total HP is below 20% + int darkEnergyMaxHP = BossRushEvent.BossRushActive ? DarkEnergy.MaxBossRushHP : DarkEnergy.MaxHP; + //These are still needed so that CV Dark energy despawn works properly + double HPBoost = CalamityServerConfig.Instance.BossHealthBoost * 0.01; + darkEnergyMaxHP += (int)(darkEnergyMaxHP * HPBoost); + + int totalDarkEnergiesSpawned = darkEnergyAmt * 3 + 2; + int totalDarkEnergyMaxHP = darkEnergyMaxHP * totalDarkEnergiesSpawned; + int succPhaseGateValue = (int)(totalDarkEnergyMaxHP * 0.2); + if (totalDarkEnergyHP < succPhaseGateValue) + { + SoundEngine.PlaySound(SoundID.NPCDeath44, NPC.Center); + + // Kill all Dark Energies + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC darkEnergy = Main.npc[i]; + if (darkEnergy.active && darkEnergy.type == NPCType()) + { + darkEnergy.HitEffect(); + darkEnergy.active = false; + darkEnergy.netUpdate = true; + } + } + + // Generate a dust explosion + int dustAmt = 30; + int random = 3; + for (int j = 0; j < 10; j++) + { + random += j * 2; + for (int d = 0; d < dustAmt; d++) + { + Vector2 dustVelocity = new Vector2(Main.rand.Next(-random, random), Main.rand.Next(-random, random)); + dustVelocity = Vector2.Normalize(dustVelocity) * random * 2f; + Dust realDust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2CircularEdge(10f, 10f), (int)CalamityDusts.PurpleCosmilite, dustVelocity, 100, default, 5f); + realDust.noGravity = true; + } + } + } + } + + // Basic movement towards a location + void Movement(bool succ) + { + float velocity = ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)); + float acceleration = (death ? 0.2f : expertMode ? 0.16f : 0.12f) + (float)(death ? 0.04f * (1D - lifeRatio) : 0f); + + // Increase speed dramatically in succ phase + if (succ) + { + velocity *= 2f; + acceleration *= 2f; + } + + if (!madeItToLocation) + { + + velocity *= 2f; + acceleration *= 5f; + } + + if (Main.getGoodWorld) + { + velocity *= 1.15f; + acceleration *= 1.15f; + } + + Vector2 destination = player.Center; + + // Move between 8 different positions around the player, in order + float maxDistance = 320f; + Vector2 moveToOffset = succ ? Vector2.Zero : Main.getGoodWorld ? new Vector2(0f, -maxDistance) : Vector2.Zero; + if ((!succ && Main.getGoodWorld) || !madeItToLocation) + { + // Move to a new location every few seconds + calamityGlobalNPC.newAI[2] += 1f; + float newPositionGateValue = death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + if (calamityGlobalNPC.newAI[2] > newPositionGateValue) + { + calamityGlobalNPC.newAI[2] = 0f; + + NPC.ai[0] += 1f; + if (NPC.ai[0] > 7f) + NPC.ai[0] = 0f; + } + moveToOffset += new Vector2(maxDistance, 0).RotatedBy(NPC.ai[0] / 8f * MathHelper.TwoPi); + } + + destination += moveToOffset; + + // How far Ceaseless Void is from where it's supposed to be + Vector2 distanceFromDestination = destination - NPC.Center; + + // Movement + if (NPC.Distance(destination) > maxDistance || succ || (!Main.getGoodWorld && !madeItToLocation)) + CalamityUtils.SmoothMovement(NPC, 0f, distanceFromDestination, velocity, acceleration, true); + if (NPC.Distance(destination) < 80) + { + madeItToLocation = true; + } + } + + // Spawn more Dark Energies as the fight progresses + if (calamityGlobalNPC.newAI[0] == 0f && NPC.life > 0) + calamityGlobalNPC.newAI[0] = 1f; + + if (NPC.life > 0) + { + int healthGateValue = (int)(NPC.lifeMax * 0.3); + if (((NPC.life + healthGateValue) / (float)NPC.lifeMax) < calamityGlobalNPC.newAI[0]) + { + NPC.TargetClosest(); + calamityGlobalNPC.newAI[0] -= 0.3f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[0] += 1f; + NPC.localAI[1] = 0f; + NPC.localAI[2] = 0f; + NPC.localAI[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (phase4) + { + madeItToLocation = false; + for (int i = 0; i < darkEnergyAmt; i++) + { + for (int j = 0; j < 3; j++) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(NPC.Center.Y + (Math.Cos(i * spacing) * distance2)), NPCType(), NPC.whoAmI, i * spacing, j * 2f); + } + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 1f); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 3f); + } + else if (phase3) + { + madeItToLocation = false; + for (int i = 0; i < darkEnergyAmt; i++) + { + for (int j = 0; j < 3; j++) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(NPC.Center.Y + (Math.Cos(i * spacing) * distance2)), NPCType(), NPC.whoAmI, i * spacing, j * 1.5f); + } + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 0.5f); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 2f); + } + else + { + madeItToLocation = false; + for (int i = 0; i < darkEnergyAmt; i++) + { + for (int j = 0; j < 3; j++) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + (Math.Sin(i * spacing) * distance2)), (int)(NPC.Center.Y + (Math.Cos(i * spacing) * distance2)), NPCType(), NPC.whoAmI, i * spacing, j); + } + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 1.5f); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)(NPC.Center.Y + distance2), NPCType(), NPC.whoAmI, 0f, 2.5f); + } + } + + // Despawn potentially hazardous projectiles when entering a new phase + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile projectile = Main.projectile[i]; + if (projectile.active) + { + if (projectile.type == ProjectileType() || projectile.type == ProjectileType() || + projectile.type == ProjectileType() || projectile.type == ProjectileType()) + { + if (projectile.timeLeft > 30) + projectile.timeLeft = 30; + } + } + } + } + } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -219,7 +744,7 @@ namespace CalamityMod.NPCs.CeaselessVoid public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemDropRule.BossBag(ModContent.ItemType())); + npcLoot.Add(ItemDropRule.BossBag(ItemType())); // Normal drops: Everything that would otherwise be in the bag LeadingConditionRule normalOnly = new LeadingConditionRule(new Conditions.NotExpert()); @@ -228,40 +753,41 @@ namespace CalamityMod.NPCs.CeaselessVoid // Weapons int[] weapons = new int[] { - ModContent.ItemType(), - ModContent.ItemType(), + ItemType(), + ItemType(), }; normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); // Materials - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 5, 7)); + normalOnly.Add(DropHelper.PerPlayer(ItemType(), 1, 10, 12)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ItemType())); // Vanity - normalOnly.Add(ModContent.ItemType(), 7); - var godSlayerVanity = ItemDropRule.Common(ModContent.ItemType(), 20); - godSlayerVanity.OnSuccess(ItemDropRule.Common(ModContent.ItemType())); - godSlayerVanity.OnSuccess(ItemDropRule.Common(ModContent.ItemType())); + normalOnly.Add(ItemType(), 7); + var godSlayerVanity = ItemDropRule.Common(ItemType(), 20); + godSlayerVanity.OnSuccess(ItemDropRule.Common(ItemType())); + godSlayerVanity.OnSuccess(ItemDropRule.Common(ItemType())); normalOnly.Add(godSlayerVanity); - normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); + normalOnly.Add(ItemType(), ThankYouPainting.DropInt); } - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ItemType(), 10); // Relic - npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); + npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ItemType()); // GFB Eclipse Mirror and Nucleogenesis drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemType()), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemType()), hideLootReport: true); } // Lore - npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCeaselessVoid, ModContent.ItemType(), desc: DropHelper.FirstKillText); + npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCeaselessVoid, ItemType(), desc: DropHelper.FirstKillText); } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) @@ -269,9 +795,9 @@ namespace CalamityMod.NPCs.CeaselessVoid NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { - potionType = ModContent.ItemType(); + potionType = ItemType(); } public override void HitEffect(NPC.HitInfo hit) @@ -279,12 +805,8 @@ namespace CalamityMod.NPCs.CeaselessVoid if (NPC.soundDelay == 0 && NPC.life >= NPC.lifeMax * 0.05f) { NPC.soundDelay = 8; - float pitchVar = 0; - if (Main.zenithWorld) - { - pitchVar = Main.rand.Next(-60, 41) * 0.01f; - } - SoundEngine.PlaySound(CommonCalamitySounds.OtherwordlyHitSound with { Pitch = CommonCalamitySounds.OtherwordlyHitSound.Pitch + pitchVar }, NPC.Center); + float pitchVar = Main.zenithWorld ? 0.4f : 0; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCHit/OtherworldlyHit") with { PitchVariance = pitchVar }, NPC.Center); } for (int k = 0; k < 5; k++) diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index 52c4728c43..f147f52a7f 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -14,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.CeaselessVoid { + [HasPierceResist] public class DarkEnergy : ModNPC { private bool start = true; @@ -44,9 +45,9 @@ namespace CalamityMod.NPCs.CeaselessVoid public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 120; // 240 NPC.aiStyle = -1; AIType = -1; - NPC.GetNPCDamage(); NPC.dontTakeDamage = true; NPC.width = NPC.height = HitboxSize; NPC.defense = 50; @@ -58,10 +59,6 @@ namespace CalamityMod.NPCs.CeaselessVoid NPC.HitSound = SoundID.NPCHit53; NPC.DeathSound = SoundID.NPCDeath44; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -160,18 +157,14 @@ namespace CalamityMod.NPCs.CeaselessVoid NPC.timeLeft = 1800; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - // Gets how enraged Ceaseless Void is - float tileEnrageMult = Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Distance from Ceaseless Void - double maxDistance = bossRush ? 1200D : death ? 1040D : revenge ? 960D : expertMode ? 880D : minMaxDistance; + double maxDistance = death ? 1040D : revenge ? 960D : expertMode ? 880D : minMaxDistance; double rateOfChangeIncrease = (maxDistance / minMaxDistance) - 1D; - double rateOfChange = (NPC.ai[1] * 0.5f) + 2D + (tileEnrageMult - 1f) + rateOfChangeIncrease; + double rateOfChange = (NPC.ai[1] * 0.5f) + 2D + rateOfChangeIncrease; if (NPC.Calamity().newAI[0] == 0f) { distance += rateOfChange; @@ -192,7 +185,7 @@ namespace CalamityMod.NPCs.CeaselessVoid } // Rotation velocity - float minRotationVelocity = 0.5f + tileEnrageMult - 1f; + float minRotationVelocity = 0.5f; float rotationVelocityIncrease = death ? 0.2f : revenge ? 0.15f : expertMode ? 0.1f : 0f; rotationVelocityIncrease += rotationVelocityIncrease * (NPC.ai[1] * 0.5f); @@ -283,7 +276,7 @@ namespace CalamityMod.NPCs.CeaselessVoid if (Main.zenithWorld) { if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Obstructed, 30, true); + target.AddBuff(BuffID.Blackout, 30, true); } } diff --git a/NPCs/Crabulon/CrabShroom.cs b/NPCs/Crabulon/CrabShroom.cs index 2c3e928208..665ccc03c2 100644 --- a/NPCs/Crabulon/CrabShroom.cs +++ b/NPCs/Crabulon/CrabShroom.cs @@ -28,17 +28,15 @@ namespace CalamityMod.NPCs.Crabulon public override void SetDefaults() { NPC.aiStyle = -1; - NPC.GetNPCDamage(); + NPC.damage = 18; // 36 NPC.width = 14; NPC.height = 14; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) NPC.scale = 2f; - NPC.lifeMax = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 180 : 15; + NPC.lifeMax = 15; if (BossRushEvent.BossRushActive) - NPC.lifeMax = 8000; - if (Main.getGoodWorld) - NPC.lifeMax *= 2; + NPC.lifeMax = 6000; AIType = -1; NPC.knockBackResist = 0.5f; NPC.noGravity = true; @@ -48,10 +46,6 @@ namespace CalamityMod.NPCs.Crabulon NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void FindFrame(int frameHeight) @@ -70,8 +64,8 @@ namespace CalamityMod.NPCs.Crabulon bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float xVelocityLimit = BossRushEvent.BossRushActive ? 12f : death ? 8f : revenge ? 6f : 5f; - float yVelocityLimit = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.25f : death ? 0.75f : revenge ? 0.9f : 1f; + float xVelocityLimit = death ? 8f : revenge ? 6f : 5f; + float yVelocityLimit = Main.getGoodWorld ? 0.25f : death ? 0.75f : revenge ? 0.9f : 1f; // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -103,7 +97,7 @@ namespace CalamityMod.NPCs.Crabulon NPC.rotation = NPC.velocity.X * 0.1f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) { float pushVelocity = 0.5f; foreach (NPC n in Main.ActiveNPCs) diff --git a/NPCs/Crabulon/Crabulon.cs b/NPCs/Crabulon/Crabulon.cs index ebc7f6a7a6..3ecd980cd7 100644 --- a/NPCs/Crabulon/Crabulon.cs +++ b/NPCs/Crabulon/Crabulon.cs @@ -1,12 +1,10 @@ using System; using System.IO; -using CalamityMod.Buffs.Alcohol; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.TreasureBags; @@ -34,8 +32,9 @@ namespace CalamityMod.NPCs.Crabulon [AutoloadBossHead] public class Crabulon : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private bool stomping = false; + private const float TelegraphTimeBeforeBigJump = 20f; + private const float DelayBeforeBigJump = 50f; public static Asset AltTexture; public static Asset AttackTexture; @@ -71,22 +70,24 @@ namespace CalamityMod.NPCs.Crabulon } } + public static int MushroomShotDamage = 9; // 36 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 40; // 64 (1.6x expert scaling) NPC.npcSlots = 14f; - NPC.GetNPCDamage(); NPC.width = 196; NPC.height = 196; NPC.defense = 8; - NPC.LifeMaxNERB(3700, 4400, 500000); + NPC.LifeMaxNERB(3500, 4400, 500000); NPC.aiStyle = -1; AIType = -1; NPC.noGravity = false; NPC.noTileCollide = false; NPC.boss = true; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 5, 0, 0); + NPC.value = Item.buyPrice(gold: 5); NPC.HitSound = HitSound; NPC.DeathSound = DeathSound; NPC.Calamity().VulnerableToHeat = true; @@ -98,9 +99,6 @@ namespace CalamityMod.NPCs.Crabulon NPC.scale *= 1.5f; NPC.defense += 12; } - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -114,27 +112,23 @@ namespace CalamityMod.NPCs.Crabulon public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); writer.Write(NPC.localAI[0]); writer.Write(stomping); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); NPC.localAI[0] = reader.ReadSingle(); stomping = reader.ReadBoolean(); } public override void AI() { - Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 0f, 0.3f, 0.7f); + Lighting.AddLight(NPC.Center, 0f, 0.3f, 0.7f); - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; NPC.spriteDirection = NPC.direction; @@ -144,17 +138,20 @@ namespace CalamityMod.NPCs.Crabulon // Phases bool phase2 = lifeRatio < 0.66f && expertMode; bool phase3 = lifeRatio < 0.33f && expertMode; + bool phase4 = lifeRatio < 0.15f && death; + + int despawnDistanceInTiles = 500; // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); Player player = Main.player[NPC.target]; - if (!player.active || player.dead) + if (!player.active || player.dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if (!player.active || player.dead) + if (!player.active || player.dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) { NPC.noTileCollide = true; @@ -181,36 +178,10 @@ namespace CalamityMod.NPCs.Crabulon else if (NPC.timeLeft < 1800) NPC.timeLeft = 1800; - // Enrage - if ((!player.ZoneGlowshroom || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - - float enrageScale = bossRush ? 1f : 0f; - if (biomeEnraged && ((NPC.position.Y / 16f) < Main.worldSurface || bossRush)) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - if (biomeEnraged && (!player.ZoneGlowshroom || bossRush)) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - - if (Main.getGoodWorld) - enrageScale += 0.5f; - if (NPC.ai[0] < 2f) { - int mushBombAmt = phase3 ? 6 : phase2 ? 3 : 1; - float fireRate = phase3 ? 4f : phase2 ? 2f : 1f; + int mushBombAmt = phase4 ? 6 : phase3 ? 3 : phase2 ? 2 : 1; + float fireRate = phase4 ? 6f : phase3 ? 3f : phase2 ? 2f : 1f; NPC.localAI[3] += fireRate; if (NPC.ai[3] == 0f) { @@ -228,24 +199,15 @@ namespace CalamityMod.NPCs.Crabulon if (NPC.ai[3] >= mushBombAmt) NPC.ai[3] = 0f; - float mushBombSpeed = phase3 ? 14f : phase2 ? 12f : 10f; + float mushBombSpeed = phase4 ? 16f : phase3 ? 14f : phase2 ? 12f : 10f; int type = ModContent.ProjectileType(); SoundEngine.PlaySound(SoundID.Item42, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 mushBombDirection = NPC.Center; - float playerXDist = player.position.X + player.width * 0.5f - mushBombDirection.X; - float playerYDist = player.position.Y + player.height * 0.5f - mushBombDirection.Y; - float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - playerDistance = mushBombSpeed / playerDistance; - playerXDist *= playerDistance; - playerYDist *= playerDistance; - mushBombDirection.X += playerXDist; - mushBombDirection.Y += playerYDist; - float yVelocity = death ? 1f : expertMode ? 2.5f : 5f; - Vector2 mushBombVelocity = new Vector2(playerXDist, playerYDist - yVelocity); - Projectile.NewProjectile(NPC.GetSource_FromAI(), mushBombDirection, mushBombVelocity, type, NPC.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, player.Center.Y); + float yVelocity = death ? 1f : expertMode ? 2.5f : 4f; + Vector2 projectileVelocity = (Vector2.Normalize(player.Center - NPC.Center) * mushBombSpeed) - Vector2.UnitY * yVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, MushroomShotDamage, 0f, Main.myPlayer, 0f, player.Center.Y); } } } @@ -261,19 +223,19 @@ namespace CalamityMod.NPCs.Crabulon if (phase2) NPC.ai[1] += 1f; if (phase3) - NPC.ai[1] += 2f; - if (NPC.justHit && masterMode) - NPC.ai[1] += 4f; + NPC.ai[1] += 1f; if (NPC.Distance(player.Center) < 160f) - NPC.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; + NPC.ai[1] += death ? 4f : expertMode ? 2f : 1f; - float idleTime = death ? 30f : expertMode ? 60f : 120f; + // Gets tired easily in final phase. + float idleTime = phase4 ? 480f : death ? 60f : expertMode ? 90f : 120f; if (NPC.ai[1] >= idleTime) { + bool deathModeTripleStomp = Main.rand.NextBool() && death && phase2; NPC.TargetClosest(); - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.ai[0] = 1f; + NPC.noGravity = !deathModeTripleStomp; + NPC.noTileCollide = !deathModeTripleStomp; + NPC.ai[0] = deathModeTripleStomp ? 5f : 1f; NPC.ai[1] = 0f; NPC.netUpdate = true; } @@ -283,12 +245,14 @@ namespace CalamityMod.NPCs.Crabulon // Avoid cheap bullshit NPC.damage = 0; - float walkingVelocity = (death ? (5f + 2f * (1f - lifeRatio)) : expertMode ? 5f : 3.5f) + 2.5f * enrageScale; + float walkingVelocity = death ? (5f + 1f * (1f - lifeRatio)) : expertMode ? 5f : 3.5f; if (phase2) walkingVelocity += 0.5f; if (phase3) + walkingVelocity += 0.75f; + if (phase4) walkingVelocity += 1f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) walkingVelocity *= 2f; bool shouldWalkSlower = false; @@ -307,10 +271,7 @@ namespace CalamityMod.NPCs.Crabulon NPC.direction = playerLocation < 0 ? 1 : -1; float inertia = revenge ? 10f : 20f; - if (NPC.direction > 0) - NPC.velocity.X = (NPC.velocity.X * inertia + walkingVelocity) / (inertia + 1f); - if (NPC.direction < 0) - NPC.velocity.X = (NPC.velocity.X * inertia - walkingVelocity) / (inertia + 1f); + NPC.velocity.X = (NPC.velocity.X * inertia + walkingVelocity * NPC.direction) / (inertia + 1f); } if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && player.position.Y <= NPC.position.Y + NPC.height && !NPC.collideX) @@ -325,11 +286,11 @@ namespace CalamityMod.NPCs.Crabulon Vector2 collisionCheckPosition = new Vector2(NPC.Center.X - 40, NPC.position.Y + NPC.height - 20); bool fallDownOnTopOfTarget = NPC.position.X < player.position.X && NPC.position.X + NPC.width > player.position.X + player.width && NPC.position.Y + NPC.height < player.position.Y + player.height - 16f; - float acceleration = death ? 0.1f : expertMode ? 0.05f : 0.025f; - float acceleration2 = death ? 0.8f : expertMode ? 0.4f : 0.2f; + float acceleration = death ? 0.075f : expertMode ? 0.05f : 0.03f; + float acceleration2 = death ? 0.6f : expertMode ? 0.4f : 0.25f; if (fallDownOnTopOfTarget) { - float fallSpeed = death ? 2f : expertMode ? 1f : 0.5f; + float fallSpeed = death ? 1.5f : expertMode ? 1f : 0.5f; NPC.velocity.Y += fallSpeed; } else if (Collision.SolidCollision(collisionCheckPosition, 80, 20)) @@ -342,7 +303,7 @@ namespace CalamityMod.NPCs.Crabulon else NPC.velocity.Y -= acceleration2; - float upwardSpeedCap = death ? 16f : expertMode ? 8f : 4f; + float upwardSpeedCap = death ? 9f : expertMode ? 6f : 4f; if (NPC.velocity.Y < -upwardSpeedCap) NPC.velocity.Y = -upwardSpeedCap; } @@ -360,16 +321,16 @@ namespace CalamityMod.NPCs.Crabulon NPC.ai[1] += 1f; if (NPC.Distance(player.Center) < 160f) - NPC.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; + NPC.ai[1] += death ? 4f : expertMode ? 2f : 1f; - float stompPhaseGateValue = (revenge ? 150f : expertMode ? 240f : 360f) - (death ? 120f * (1f - lifeRatio) : 0f); + float stompPhaseGateValue = (revenge ? 150f : expertMode ? 240f : 360f) - (death ? 60f * (1f - lifeRatio) : 0f); if (NPC.ai[1] >= stompPhaseGateValue) { NPC.noGravity = false; NPC.noTileCollide = false; - NPC.ai[0] = 2f; + NPC.ai[0] = (Main.rand.NextBool() && revenge && phase2) ? 4f : 2f; NPC.ai[1] = 0f; - NPC.netUpdate = true; + NPC.ForceNetUpdate(); } if (NPC.velocity.Y > 10f) @@ -411,16 +372,18 @@ namespace CalamityMod.NPCs.Crabulon NPC.ai[1] += !revenge ? 2f : 1f; if (phase3) NPC.ai[1] += !revenge ? 2f : 1f; + if (phase4) + NPC.ai[1] += 1f; } - float jumpGateValue = (bossRush ? 15f : expertMode ? 60f : 120f) / (enrageScale + 1f); + float jumpGateValue = expertMode ? 60f : 120f; if (NPC.ai[1] >= jumpGateValue) { NPC.ai[1] = -20f; } else if (NPC.ai[1] == -1f) { - float maxVelocityXIncrease = death ? 6f : 4f; + float maxVelocityXIncrease = death ? 4f : 3f; float maxVelocityYIncrease = death ? 3f : 2f; float velocityX = 6f + (expertMode ? (maxVelocityXIncrease * (1f - lifeRatio)) : 0f); float velocityY = 12f + (expertMode ? (maxVelocityYIncrease * (1f - lifeRatio)) : 0f); @@ -433,22 +396,49 @@ namespace CalamityMod.NPCs.Crabulon float velocityXAdjustment = velocityX; float velocityYAdjustment = velocityY / 3f; - switch ((int)NPC.ai[3]) + if (lifeRatio < 0.5f && death) { - case 0: // Normal - break; - case 1: // High - velocityY += velocityYAdjustment; - break; - case 2: // Low - velocityY -= velocityYAdjustment; - break; - case 3: // Long and low - velocityX += velocityXAdjustment; - velocityY -= velocityYAdjustment; - break; - default: - break; + // Crab smash + switch ((int)NPC.ai[3]) + { + case 0: // Normal + velocityX += velocityXAdjustment * 0.5f; + velocityY -= velocityYAdjustment; + break; + case 1: // High + velocityX += velocityXAdjustment * 0.5f; + break; + case 2: // Low + velocityX += velocityXAdjustment * 0.5f; + velocityY -= velocityYAdjustment * 2f; + break; + case 3: // Long and low + velocityX += velocityXAdjustment * 1.5f; + velocityY -= velocityYAdjustment * 2f; + break; + default: + break; + } + } + else + { + switch ((int)NPC.ai[3]) + { + case 0: // Normal + break; + case 1: // High + velocityY += velocityYAdjustment; + break; + case 2: // Low + velocityY -= velocityYAdjustment; + break; + case 3: // Long and low + velocityX += velocityXAdjustment; + velocityY -= velocityYAdjustment; + break; + default: + break; + } } if (distanceBelowTarget > 0f) @@ -484,7 +474,7 @@ namespace CalamityMod.NPCs.Crabulon } } } - else + else if (NPC.ai[0] == 3f) { if (NPC.velocity.Y == 0f) { @@ -494,24 +484,25 @@ namespace CalamityMod.NPCs.Crabulon SoundEngine.PlaySound(SlamSound, NPC.Center); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); if ((NPC.ai[2] % 2f == 0f || death) && ((phase2 && revenge) || (phase3 && expertMode))) { SoundEngine.PlaySound(SoundID.Item42, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - float projectileVelocity = BossRushEvent.BossRushActive ? 24f : CalamityWorld.death ? 15f : 10f; + float projectileVelocity = CalamityWorld.death ? 15f : 10f; Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; destination.Normalize(); destination *= projectileVelocity; - int numProj = bossRush ? 48 : CalamityWorld.death ? 30 : 20; + + // Less mushrooms in Death Mode phase 3 because otherwise it's an absolute shitshow. + int numProj = phase4 ? 14 : CalamityWorld.death ? (phase3 ? 10 : 16) : 12; float rotation = MathHelper.ToRadians(90); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); Vector2 randomVelocityVector = new Vector2((Main.rand.NextFloat() - 0.5f) * 4f, (Main.rand.NextFloat() - 0.5f) * 4f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, new Vector2(perturbedSpeed.X, -projectileVelocity) + randomVelocityVector, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, new Vector2(perturbedSpeed.X, -projectileVelocity) + randomVelocityVector, type, MushroomShotDamage, 0f, Main.myPlayer, 0f, player.Center.Y); } } } @@ -524,17 +515,19 @@ namespace CalamityMod.NPCs.Crabulon SoundEngine.PlaySound(SoundID.Item42, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - float projectileVelocity = BossRushEvent.BossRushActive ? 24f : CalamityWorld.death ? 15f : 10f; + float projectileVelocity = CalamityWorld.death ? 15f : 10f; Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; destination.Normalize(); destination *= projectileVelocity; - int numProj = bossRush ? 30 : CalamityWorld.death ? 18 : 12; + + // Less mushrooms in Death Mode phase 3 because otherwise it's an absolute shitshow. + int numProj = phase4 ? 8 : (phase3 && death) ? 6 : 8; float rotation = MathHelper.ToRadians(60); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); Vector2 randomVelocityVector = new Vector2((Main.rand.NextFloat() - 0.5f) * 4f, (Main.rand.NextFloat() - 0.5f) * 4f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, new Vector2(perturbedSpeed.X, -projectileVelocity) + randomVelocityVector, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, new Vector2(perturbedSpeed.X, -projectileVelocity) + randomVelocityVector, type, MushroomShotDamage, 0f, Main.myPlayer, 0f, player.Center.Y); } } } @@ -608,30 +601,339 @@ namespace CalamityMod.NPCs.Crabulon if (NPC.position.X < player.position.X && NPC.position.X + NPC.width > player.position.X + player.width) { - float slowDownMultiplier = death ? 0.84f : expertMode ? 0.92f : 0.96f; + float slowDownMultiplier = death ? 0.9f : expertMode ? 0.93f : 0.96f; NPC.velocity.X *= slowDownMultiplier; - float fallSpeedIncrease = death ? 0.24f : expertMode ? 0.12f : 0.06f; + float fallSpeedIncrease = phase4 ? 0.2f : death ? 0.15f : expertMode ? 0.12f : 0.09f; NPC.velocity.Y += fallSpeedIncrease; } else { - float velocityX = (death ? 0.2f : expertMode ? 0.15f : 0.1f) + 0.05f * enrageScale; + float velocityX = death ? 0.15f : expertMode ? 0.125f : 0.1f; if (NPC.direction < 0) NPC.velocity.X -= velocityX; else if (NPC.direction > 0) NPC.velocity.X += velocityX; - float topXSpeed = (death ? 5.5f : expertMode ? 4f : 2.5f) + enrageScale; - if (phase2) - topXSpeed += 1f; - if (phase3) - topXSpeed += 1f; + float maxVelocityXIncrease = death ? 4f : 3f; + float maxVelocityX = 6f + (expertMode ? (maxVelocityXIncrease * (1f - lifeRatio)) : 0f); - if (NPC.velocity.X < -topXSpeed) - NPC.velocity.X = -topXSpeed; - if (NPC.velocity.X > topXSpeed) - NPC.velocity.X = topXSpeed; + if (revenge) + { + float velocityXAdjustment = maxVelocityX; + + if (lifeRatio < 0.5f && death) + { + // Mega velocity + switch ((int)NPC.ai[3]) + { + case 0: // Normal + case 1: // High + case 2: // Low + maxVelocityX += velocityXAdjustment * 0.5f; + break; + + case 3: // Long and low + maxVelocityX += velocityXAdjustment * 1.5f; + break; + + default: + break; + } + } + else + { + switch ((int)NPC.ai[3]) + { + case 0: // Normal + case 1: // High + case 2: // Low + break; + + case 3: // Long and low + maxVelocityX += velocityXAdjustment; + break; + + default: + break; + } + } + } + + if (Math.Abs(NPC.velocity.X) > maxVelocityX) + NPC.velocity.X = NPC.velocity.X < 0f ? -maxVelocityX : maxVelocityX; + } + } + } + else if (NPC.ai[0] == 4f) + { + if (NPC.velocity.Y == 0f || NPC.ai[2] == 1f) + NPC.ai[1] += 1f; + + if (NPC.ai[1] >= DelayBeforeBigJump) + { + if (NPC.ai[1] == DelayBeforeBigJump && NPC.ai[2] == 0f) + { + Vector2 center = NPC.Center; + if (!player.dead && player.active && Math.Abs(NPC.Center.X - player.Center.X) / 16f <= despawnDistanceInTiles) + center = player.Center; + + center.Y -= 320f + Math.Abs(player.Center.Y - NPC.Center.Y); + center.X += Math.Abs(player.Center.X - NPC.Center.X) * ((player.Center.X > NPC.Center.X) ? 1 : -1); + + NPC.ai[2] = 1f; + NPC.ai[3] = NPC.Bottom.Y; + NPC.noTileCollide = true; + + float leapVelocity = death ? 18f : 16f; + NPC.velocity = center - NPC.Center; + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.Zero); + NPC.velocity *= leapVelocity; + NPC.velocity.X *= 0.6f; + + float velocityMinY = -leapVelocity; + if (NPC.velocity.Y > velocityMinY) + NPC.velocity.Y = velocityMinY; + + NPC.ForceNetUpdate(); + } + else + { + float mushroomFireRate = 15f; + if (NPC.ai[1] % mushroomFireRate == 0f) + { + SoundEngine.PlaySound(SoundID.Item42, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + float yVelocity = death ? 3f : 2f; + if (death) + { + int numProj = 3; + Vector2 initialVelocity = (NPC.Center + Vector2.UnitY * 10f - NPC.Center).SafeNormalize(Vector2.UnitY); + float rotation = MathHelper.ToRadians(8); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = initialVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, MushroomShotDamage, 0f, Main.myPlayer, 0f, player.Center.Y); + } + } + else + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.UnitY * yVelocity, type, MushroomShotDamage, 0f, Main.myPlayer, 0f, player.Center.Y); + } + } + + // Collide with tiles if falling and beyond a certain threshold + if (NPC.velocity.Y >= 0f && NPC.Bottom.Y >= NPC.ai[3] - NPC.height) + NPC.noTileCollide = false; + + // Impact and create lines of mushrooms that spread out along the ground (similar to an old Providence attack) + if (NPC.Bottom.Y >= NPC.ai[3] || NPC.velocity.Y == 0f) + { + SoundEngine.PlaySound(SlamSound, NPC.Center); + + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + + int type = ModContent.ProjectileType(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float xVelocity = death ? 2f : 1f; + int numProj = death ? 5 : 3; + Vector2 initialVelocity = Vector2.UnitX * xVelocity; + Vector2 initialSpawnLocation = NPC.Bottom - new Vector2(0f, 8f); + + for (int i = 0; i < numProj; i++) + Projectile.NewProjectile(NPC.GetSource_FromAI(), initialSpawnLocation + new Vector2(Main.rand.Next(0, 81), Main.rand.Next(-20, 1)), initialVelocity - (i / (float)numProj * initialVelocity), type, MushroomShotDamage, 0f, Main.myPlayer); + + for (int i = 0; i < numProj; i++) + Projectile.NewProjectile(NPC.GetSource_FromAI(), initialSpawnLocation + new Vector2(Main.rand.Next(-81, 0), Main.rand.Next(-20, 1)), -(initialVelocity - (i / (float)numProj * initialVelocity)), type, MushroomShotDamage, 0f, Main.myPlayer); + } + + for (int j = (int)NPC.position.X - 20; j < (int)NPC.position.X + NPC.width + 40; j += 20) + { + for (int k = 0; k < 4; k++) + { + int stompDust = Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y + NPC.height), NPC.width + 20, 4, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); + Main.dust[stompDust].velocity *= 0.2f; + } + + // Destroy tiles with stomps in Zenith seed + if (Main.zenithWorld) + { + int x = j / 16; + int y = (int)(NPC.position.Y + NPC.height) / 16; + Tile groundTile = CalamityUtils.ParanoidTileRetrieval(x, y); + Tile walkTile = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + if (!walkTile.HasTile && walkTile.LiquidAmount == 0 && groundTile != null && WorldGen.SolidTile(groundTile)) + { + walkTile.TileFrameY = 0; + walkTile.Get().Slope = SlopeType.Solid; + walkTile.Get().IsHalfBlock = false; + if (groundTile.TileType == TileID.MushroomGrass || groundTile.TileType == TileID.Mud) + { + walkTile.Get().HasTile = true; + walkTile.TileType = TileID.MushroomPlants; + walkTile.TileFrameX = (short)(Main.rand.Next(5) * 18); + + if (Main.netMode == NetmodeID.MultiplayerClient) + NetMessage.SendTileSquare(-1, x, y - 1, 1, TileChangeType.None); + } + } + } + } + } + } + } + else + NPC.velocity.X *= 0.8f; + } + + // Stomp three times quickly, creating lines of mushrooms and a column of mushrooms that slowly fall down + else if (NPC.ai[0] == 5f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.noTileCollide = false; + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X *= 0.8f; + NPC.ai[1] += 1f; + if (NPC.ai[1] % 15f == 14f) + NPC.netUpdate = true; + + float jumpGateValue = 10f; + if (NPC.ai[1] >= jumpGateValue) + { + NPC.ai[1] = -20f; + } + else if (NPC.ai[1] == -1f) + { + NPC.velocity.Y = -(2f + NPC.ai[2]); + + SoundEngine.PlaySound(JumpSound, NPC.Center); + + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + } + } + else if (NPC.ai[0] == 6f) + { + if (NPC.velocity.Y == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + SoundEngine.PlaySound(SlamSound, NPC.Center); + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 3f) + { + // Columns of mushrooms + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int maxColumns = 5; + int mushroomsPerColumn = 8; + Vector2 initialSpawnLocation = NPC.Bottom - new Vector2(210f, 8f); + Vector2 initialVelocity = Vector2.UnitY * 24f; + for (int i = 0; i < maxColumns; i++) + { + // 0 = 0.5, 1 = 0.25, 2 = 0, 3 = 0.25, 4 = 0.5 + initialVelocity -= Vector2.UnitY * 8f * Math.Abs(0.5f - (i / (float)(maxColumns - 1))); + + for (int j = 0; j < mushroomsPerColumn; j++) + { + initialVelocity += Vector2.UnitX * Main.rand.NextFloat(-0.5f, 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), initialSpawnLocation + new Vector2(70f * (i + 1), 0f), -(initialVelocity - ((j / (float)mushroomsPerColumn) * initialVelocity)), type, MushroomShotDamage, 0f, Main.myPlayer, 1f, NPC.Bottom.Y - 16f); + } + + initialVelocity = Vector2.UnitY * 16f; + } + } + + NPC.ai[0] = 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + else + { + // Mushrooms along the ground + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + float xVelocity = death ? 3f : 1.5f; + int numProj = 3; + Vector2 initialVelocity = Vector2.UnitX * xVelocity; + Vector2 initialSpawnLocation = NPC.Bottom - new Vector2(0f, 8f); + + for (int i = 0; i < numProj; i++) + Projectile.NewProjectile(NPC.GetSource_FromAI(), initialSpawnLocation + new Vector2(Main.rand.Next(0, 41), 0f), initialVelocity - ((i / (float)numProj) * initialVelocity), type, MushroomShotDamage, 0f, Main.myPlayer); + + for (int i = 0; i < numProj; i++) + Projectile.NewProjectile(NPC.GetSource_FromAI(), initialSpawnLocation - new Vector2(Main.rand.Next(0, 41), 0f), -(initialVelocity - ((i / (float)numProj) * initialVelocity)), type, MushroomShotDamage, 0f, Main.myPlayer); + } + + float playerLocation = NPC.Center.X - player.Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + + NPC.ai[0] = 5f; + NPC.netUpdate = true; + } + + for (int j = (int)NPC.position.X - 20; j < (int)NPC.position.X + NPC.width + 40; j += 20) + { + for (int k = 0; k < 4; k++) + { + int stompDust = Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y + NPC.height), NPC.width + 20, 4, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); + Main.dust[stompDust].velocity *= 0.2f; + } + + // Destroy tiles with stomps in Zenith seed (this is going to be so awful with this attack lol) + if (Main.zenithWorld) + { + int x = j / 16; + int y = (int)(NPC.position.Y + NPC.height) / 16; + Tile groundTile = CalamityUtils.ParanoidTileRetrieval(x, y); + Tile walkTile = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + if (!walkTile.HasTile && walkTile.LiquidAmount == 0 && groundTile != null && WorldGen.SolidTile(groundTile)) + { + walkTile.TileFrameY = 0; + walkTile.Get().Slope = SlopeType.Solid; + walkTile.Get().IsHalfBlock = false; + if (groundTile.TileType == TileID.MushroomGrass || groundTile.TileType == TileID.Mud) + { + walkTile.Get().HasTile = true; + walkTile.TileType = TileID.MushroomPlants; + walkTile.TileFrameX = (short)(Main.rand.Next(5) * 18); + + if (Main.netMode == NetmodeID.MultiplayerClient) + NetMessage.SendTileSquare(-1, x, y - 1, 1, TileChangeType.None); + } + } + } + } + } + else + { + // Set damage + NPC.damage = NPC.defDamage; + + if (!player.dead) + { + if ((player.position.Y > NPC.Bottom.Y && NPC.velocity.Y > 0f) || (player.position.Y < NPC.Bottom.Y && NPC.velocity.Y < 0f)) + NPC.noTileCollide = true; + else if ((NPC.velocity.Y > 0f && NPC.Bottom.Y > Main.player[NPC.target].Top.Y) || (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height))) + NPC.noTileCollide = false; } } } @@ -643,7 +945,7 @@ namespace CalamityMod.NPCs.Crabulon { if (Main.netMode != NetmodeID.MultiplayerClient) { - int crabShroomSpawnFreq = (int)(NPC.lifeMax * ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.01 : Main.getGoodWorld ? 0.02 : 0.05)); + int crabShroomSpawnFreq = (int)(NPC.lifeMax * (Main.getGoodWorld ? 0.02 : 0.05)); if ((NPC.life + crabShroomSpawnFreq) < NPC.localAI[0]) { NPC.localAI[0] = NPC.life; @@ -664,6 +966,7 @@ namespace CalamityMod.NPCs.Crabulon } } } + public override bool? CanFallThroughPlatforms() => NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height; // Can only hit the target if within certain distance public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -733,7 +1036,7 @@ namespace CalamityMod.NPCs.Crabulon { if (NPC.ai[0] > 1f) { - if (NPC.velocity.Y == 0f && NPC.ai[1] >= 0f && NPC.ai[0] == 2f) // Idle just before jump + if (NPC.velocity.Y == 0f && ((NPC.ai[1] >= 0f && (NPC.ai[0] == 2f || NPC.ai[0] == 5f)) || (NPC.ai[1] < (DelayBeforeBigJump - TelegraphTimeBeforeBigJump) && NPC.ai[0] == 4f && NPC.ai[2] == 0f))) // Idle just before jump { if (stomping) stomping = false; @@ -743,7 +1046,7 @@ namespace CalamityMod.NPCs.Crabulon int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; } - else if (NPC.velocity.Y <= 0f || NPC.ai[1] < 0f) // Prepare to jump and then jump + else if (NPC.velocity.Y <= 0f || (NPC.ai[1] < DelayBeforeBigJump && NPC.ai[0] == 4f && NPC.ai[2] == 0f) || NPC.ai[1] < 0f) // Prepare to jump and then jump { NPC.frameCounter += 1D; if (NPC.frameCounter > 12D) @@ -777,7 +1080,7 @@ namespace CalamityMod.NPCs.Crabulon if (stomping) stomping = false; - NPC.frameCounter += 0.15f; + NPC.frameCounter += 0.15; NPC.frameCounter %= Main.npcFrameCount[Type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; @@ -806,8 +1109,9 @@ namespace CalamityMod.NPCs.Crabulon { Vector2 drawOrigin = new Vector2(textureIdle.Width / 2, textureIdle.Height / Main.npcFrameCount[Type] / 2); Vector2 drawPos = NPC.Center - screenPos + (Vector2.UnitX * textureIdle.Width * c * 1.6f); + // Jumping - if (NPC.ai[0] > 2f && NPC.velocity.Y != 0f) + if ((NPC.ai[0] > 2f && NPC.ai[0] != 5f) && NPC.velocity.Y != 0f) { drawOrigin = new Vector2(textureAttack.Width / 2, textureAttack.Height / 2); drawPos -= new Vector2(textureAttack.Width, textureAttack.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; @@ -816,6 +1120,7 @@ namespace CalamityMod.NPCs.Crabulon spriteBatch.Draw(textureAttack, drawPos, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, drawOrigin, NPC.scale, spriteEffects, 0f); spriteBatch.Draw(glowAttack, drawPos, NPC.frame, glowColor, NPC.rotation, drawOrigin, NPC.scale, spriteEffects, 0f); } + // Walking else if (NPC.ai[0] == 1f) { @@ -826,6 +1131,7 @@ namespace CalamityMod.NPCs.Crabulon spriteBatch.Draw(textureWalk, drawPos, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, drawOrigin, NPC.scale, spriteEffects, 0f); spriteBatch.Draw(glowWalk, drawPos, NPC.frame, glowColor, NPC.rotation, drawOrigin, NPC.scale, spriteEffects, 0f); } + // Standing still else { @@ -874,7 +1180,8 @@ namespace CalamityMod.NPCs.Crabulon normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -887,7 +1194,7 @@ namespace CalamityMod.NPCs.Crabulon npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Odd Mushroom drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 1, 9999, true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 9999), true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCrabulon, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -919,7 +1226,7 @@ namespace CalamityMod.NPCs.Crabulon public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); + NPC.damage = (int)(NPC.damage * 0.8f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Crags/CalamityEye.cs b/NPCs/Crags/CalamityEye.cs index 1c8cbd99a4..bdd3bce54c 100644 --- a/NPCs/Crags/CalamityEye.cs +++ b/NPCs/Crags/CalamityEye.cs @@ -29,10 +29,10 @@ namespace CalamityMod.NPCs.Crags NPC.width = 30; NPC.height = 30; NPC.defense = 12; - NPC.lifeMax = 180; + NPC.lifeMax = 140; NPC.knockBackResist = 0.75f; AnimationType = NPCID.DemonEye; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; if (DownedBossSystem.downedProvidence) @@ -47,10 +47,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -99,7 +95,7 @@ namespace CalamityMod.NPCs.Crags public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 120); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/Crags/DespairStone.cs b/NPCs/Crags/DespairStone.cs index bb3e35e40d..62d3df7ee4 100644 --- a/NPCs/Crags/DespairStone.cs +++ b/NPCs/Crags/DespairStone.cs @@ -5,7 +5,7 @@ using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Placeables.Crags; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Particles; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -35,10 +35,9 @@ namespace CalamityMod.NPCs.Crags NPC.width = 66; NPC.height = 64; NPC.defense = 38; - NPC.DR_NERD(0.35f); NPC.lifeMax = 180; NPC.knockBackResist = 0.1f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit41; NPC.DeathSound = SoundID.NPCDeath14; NPC.behindTiles = true; @@ -55,10 +54,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -171,7 +166,7 @@ namespace CalamityMod.NPCs.Crags public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Crags/HeatSpirit.cs b/NPCs/Crags/HeatSpirit.cs index 1c14f41f6e..cfc7c0469f 100644 --- a/NPCs/Crags/HeatSpirit.cs +++ b/NPCs/Crags/HeatSpirit.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.Crags NPC.defense = 8; NPC.lifeMax = 50; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit52; NPC.DeathSound = SoundID.NPCDeath55; NPC.noGravity = true; @@ -47,10 +47,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Crags/InfernalCongealment.cs b/NPCs/Crags/InfernalCongealment.cs index 99a577e956..4cfd936e34 100644 --- a/NPCs/Crags/InfernalCongealment.cs +++ b/NPCs/Crags/InfernalCongealment.cs @@ -25,11 +25,11 @@ namespace CalamityMod.NPCs.Crags NPC.damage = 40; NPC.width = 40; NPC.height = 30; - NPC.defense = 10; - NPC.lifeMax = 380; + NPC.defense = 30; + NPC.lifeMax = 250; NPC.knockBackResist = 0.5f; AnimationType = NPCID.CorruptSlime; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.alpha = 50; NPC.lavaImmune = true; NPC.noGravity = false; @@ -48,10 +48,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -79,7 +75,7 @@ namespace CalamityMod.NPCs.Crags public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 120); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Crags/RenegadeWarlock.cs b/NPCs/Crags/RenegadeWarlock.cs index 770a2ab412..bda636f6c5 100644 --- a/NPCs/Crags/RenegadeWarlock.cs +++ b/NPCs/Crags/RenegadeWarlock.cs @@ -3,7 +3,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.World; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; @@ -26,11 +25,11 @@ namespace CalamityMod.NPCs.Crags NPC.width = 18; NPC.height = 40; NPC.defense = 16; - NPC.lifeMax = 100; + NPC.lifeMax = 300; NPC.knockBackResist = 0.5f; AnimationType = NPCID.ZombieXmas; AIType = NPCID.ChaosElemental; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath50; if (DownedBossSystem.downedProvidence) @@ -46,10 +45,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -69,7 +64,7 @@ namespace CalamityMod.NPCs.Crags public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 120); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Crags/Scryllar.cs b/NPCs/Crags/Scryllar.cs index 9be31715aa..8fc4cdedc4 100644 --- a/NPCs/Crags/Scryllar.cs +++ b/NPCs/Crags/Scryllar.cs @@ -32,10 +32,10 @@ namespace CalamityMod.NPCs.Crags NPC.width = 80; NPC.height = 80; NPC.defense = 18; - NPC.lifeMax = 120; + NPC.lifeMax = 160; NPC.alpha = 100; NPC.knockBackResist = 0.7f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit49; NPC.DeathSound = SoundID.NPCDeath51; NPC.noGravity = true; @@ -53,10 +53,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -281,7 +277,7 @@ namespace CalamityMod.NPCs.Crags public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 120); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Crags/ScryllarRage.cs b/NPCs/Crags/ScryllarRage.cs index 45bf652574..ce3f1dfa9a 100644 --- a/NPCs/Crags/ScryllarRage.cs +++ b/NPCs/Crags/ScryllarRage.cs @@ -2,7 +2,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; using Terraria; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -23,10 +22,10 @@ namespace CalamityMod.NPCs.Crags NPC.width = 80; NPC.height = 80; NPC.defense = 10; - NPC.lifeMax = 75; + NPC.lifeMax = 100; NPC.alpha = 100; NPC.knockBackResist = 0.9f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit49; NPC.DeathSound = SoundID.NPCDeath51; NPC.noGravity = true; @@ -43,10 +42,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() @@ -254,7 +249,7 @@ namespace CalamityMod.NPCs.Crags public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Crags/SoulSlurper.cs b/NPCs/Crags/SoulSlurper.cs index fedf150195..29c3e75aeb 100644 --- a/NPCs/Crags/SoulSlurper.cs +++ b/NPCs/Crags/SoulSlurper.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.BiomeManagers; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Fishing.FishingRods; using CalamityMod.Items.Materials; @@ -40,10 +39,9 @@ namespace CalamityMod.NPCs.Crags NPC.width = 40; NPC.height = 40; NPC.defense = 30; - NPC.DR_NERD(0.15f); NPC.lifeMax = 80; NPC.knockBackResist = 0.65f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.noGravity = true; NPC.lavaImmune = true; NPC.HitSound = SoundID.NPCHit4; @@ -60,10 +58,6 @@ namespace CalamityMod.NPCs.Crags NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToWater = true; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -306,12 +300,6 @@ namespace CalamityMod.NPCs.Crags postProv.Add(ModContent.ItemType(), 4); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); - } - public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 3; k++) diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index bdf1c00e8a..edea410818 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -2,15 +2,13 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Effects; using CalamityMod.Events; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; @@ -33,16 +31,14 @@ using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.Cryogen { - [LongDistanceNetSync] // Cryogen follows you forever like Queen Bee in vanilla, So we need this to sync it's position on minimap + [LongDistanceNetSync] // Cryogen follows you forever like Queen Bee in vanilla, So we need this to sync its position on minimap public class Cryogen : ModNPC { - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private int currentPhase = 1; private int teleportLocationX = 0; @@ -89,20 +85,24 @@ namespace CalamityMod.NPCs.Cryogen } } + public static int IceBlastDamage = 23; // 92; Also applies to GFB darts + public static int IceRainDamage = 23; // 92; Also applies to GFB darts + public static int IceBombDamage = 28; // 112; Also applies to GFB fireblasts + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 69; // 138 NPC.npcSlots = 24f; - NPC.GetNPCDamage(); NPC.width = 86; NPC.height = 88; NPC.defense = 15; NPC.DR_NERD(0.3f); - NPC.LifeMaxNERB(40000, 48000, 300000); + NPC.LifeMaxNERB(25000, 48000, 300000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 16, 0, 0); + NPC.value = Item.buyPrice(gold: 6); NPC.boss = true; NPC.BossBar = ModContent.GetInstance(); NPC.noGravity = true; @@ -126,9 +126,6 @@ namespace CalamityMod.NPCs.Cryogen NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = false; } - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void BossHeadSlot(ref int index) @@ -150,7 +147,6 @@ namespace CalamityMod.NPCs.Cryogen public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); writer.Write(teleportLocationX); writer.Write(NPC.dontTakeDamage); writer.Write(NPC.localAI[1]); @@ -160,7 +156,6 @@ namespace CalamityMod.NPCs.Cryogen public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); teleportLocationX = reader.ReadInt32(); NPC.dontTakeDamage = reader.ReadBoolean(); NPC.localAI[1] = reader.ReadSingle(); @@ -183,34 +178,9 @@ namespace CalamityMod.NPCs.Cryogen Player player = Main.player[NPC.target]; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - // Enrage - if (!player.ZoneSnow && !bossRush) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - - float enrageScale = death ? 0.5f : 0f; - if (biomeEnraged) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } - - if (enrageScale > 2f) - enrageScale = 2f; - - if (bossRush) - enrageScale = 3f; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -294,7 +264,7 @@ namespace CalamityMod.NPCs.Cryogen else if (NPC.timeLeft < 1800) NPC.timeLeft = 1800; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) { int spawnType = Main.zenithWorld ? NPCID.RedDevil : NPCID.IceGolem; if (!NPC.AnyNPCs(spawnType)) @@ -320,14 +290,14 @@ namespace CalamityMod.NPCs.Cryogen } } - float chargePhaseGateValue = bossRush ? 240f : 360f; + float chargePhaseGateValue = 360f; float chargeDuration = 60f; - float chargeTelegraphTime = NPC.ai[0] == 2f ? ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 60f : 80f) : ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 90f : 120f); + float chargeTelegraphTime = NPC.ai[0] == 2f ? (Main.getGoodWorld ? 60f : 80f) : (Main.getGoodWorld ? 90f : 120f); float chargeTelegraphMaxRotationIncrement = 1f; float chargeTelegraphRotationIncrement = chargeTelegraphMaxRotationIncrement / chargeTelegraphTime; float chargeSlowDownTime = 15f; - float chargeVelocityMin = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 24f : 12f; - float chargeVelocityMax = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 42f : 30f; + float chargeVelocityMin = Main.getGoodWorld ? 24f : 12f; + float chargeVelocityMax = Main.getGoodWorld ? 42f : 30f; if (Main.getGoodWorld) { chargePhaseGateValue *= 0.7f; @@ -340,7 +310,7 @@ namespace CalamityMod.NPCs.Cryogen if (expertMode && (NPC.ai[0] < 5f || !phase6) && !chargePhase) { calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] >= (bossRush ? 660f : 900f)) + if (calamityGlobalNPC.newAI[3] >= 900f) { calamityGlobalNPC.newAI[3] = 0f; SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); @@ -350,7 +320,6 @@ namespace CalamityMod.NPCs.Cryogen int totalProjectiles = 3; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBomb; - int damage = NPC.GetProjectileDamage(type); float velocity = 2f + NPC.ai[0]; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; @@ -359,7 +328,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceBombDamage, 0f, Main.myPlayer); } } } @@ -382,11 +351,10 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = bossRush ? 24 : 16; + int totalProjectiles = 16; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; - int damage = NPC.GetProjectileDamage(type); - float velocity = 9f + enrageScale; + float velocity = death ? 9.5f : 9f; float projectileVelocityToPass = 0f; if (type == ModContent.ProjectileType()) projectileVelocityToPass = velocity * 2f; @@ -395,7 +363,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceBlastDamage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); } } } @@ -406,8 +374,7 @@ namespace CalamityMod.NPCs.Cryogen float playerYDist = player.Center.Y - cryogenCenter.Y; float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - float cryogenSpeed = revenge ? 5f : 4f; - cryogenSpeed += 4f * enrageScale; + float cryogenSpeed = death ? 7f : revenge ? 5f : 4f; playerDistance = cryogenSpeed / playerDistance; playerXDist *= playerDistance; @@ -458,11 +425,10 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = bossRush ? 18 : 12; + int totalProjectiles = 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; - int damage = NPC.GetProjectileDamage(type); - float velocity2 = 9f + enrageScale; + float velocity2 = death ? 9.5f : 9f; float projectileVelocityToPass = 0f; if (type == ModContent.ProjectileType()) projectileVelocityToPass = velocity2 * 2f; @@ -471,16 +437,14 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceBlastDamage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); } } } } - float velocity = revenge ? 3.5f : 4f; - float acceleration = 0.15f; - velocity -= enrageScale * 0.8f; - acceleration += 0.07f * enrageScale; + float velocity = death ? 3.1f : revenge ? 3.5f : 4f; + float acceleration = death ? 0.185f : 0.15f; if (NPC.position.Y > player.position.Y - 375f) { @@ -538,8 +502,7 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { int type = iceRain; - int damage = NPC.GetProjectileDamage(type); - float maxVelocity = 9f + enrageScale; + float maxVelocity = death ? 9.5f : 9f; float velocity = maxVelocity - (calamityGlobalNPC.newAI[0] * maxVelocity * 0.5f); int totalProjectiles = 10; int maxTotalProjectileReductionBasedOnRotationSpeed = (int)(totalProjectiles * 0.7f); @@ -559,7 +522,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectilesShot; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, type == ModContent.ProjectileType() ? 0f : velocity, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceRainDamage, 0f, Main.myPlayer, 0f, type == ModContent.ProjectileType() ? 0f : velocity, projectileVelocityToPass); } } } @@ -578,7 +541,7 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.ai[1] == chargeGateValue) { float chargeVelocity = Vector2.Distance(NPC.Center, player.Center) / chargeDuration * 2f; - NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (chargeVelocity + enrageScale * 2f); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (chargeVelocity + (death ? 1f : 0f)); if (NPC.velocity.Length() < chargeVelocityMin) { @@ -656,11 +619,10 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = bossRush ? 18 : 12; + int totalProjectiles = 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; - int damage = NPC.GetProjectileDamage(type); - float velocity = 9f + enrageScale; + float velocity = death ? 9.5f : 9f; float projectileVelocityToPass = 0f; if (type == ModContent.ProjectileType()) projectileVelocityToPass = velocity * 2f; @@ -669,7 +631,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceBlastDamage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); } } } @@ -680,8 +642,7 @@ namespace CalamityMod.NPCs.Cryogen float playerYDist = player.Center.Y - cryogenCenter.Y; float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - float cryogenSpeed = revenge ? 7f : 6f; - cryogenSpeed += 4f * enrageScale; + float cryogenSpeed = death ? 9f : revenge ? 7f : 6f; playerDistance = cryogenSpeed / playerDistance; playerXDist *= playerDistance; @@ -708,8 +669,7 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { int type = iceRain; - int damage = NPC.GetProjectileDamage(type); - float maxVelocity = 9f + enrageScale; + float maxVelocity = death ? 9.5f : 9f; float velocity = maxVelocity - (calamityGlobalNPC.newAI[0] * maxVelocity * 0.5f); int totalProjectiles = calamityGlobalNPC.newAI[1] == 0f ? 8 : 4; int maxTotalProjectileReductionBasedOnRotationSpeed = (int)(totalProjectiles * 0.4f); @@ -729,7 +689,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectilesShot; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, type == ModContent.ProjectileType() ? 0f : velocity, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceRainDamage, 0f, Main.myPlayer, 0f, type == ModContent.ProjectileType() ? 0f : velocity, projectileVelocityToPass); } } } @@ -748,7 +708,7 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.ai[1] == chargeGateValue) { float chargeVelocity = Vector2.Distance(NPC.Center, player.Center) / chargeDuration * 2f; - NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (chargeVelocity + enrageScale * 2f); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (chargeVelocity + (death ? 1f : 0f)); if (NPC.velocity.Length() < chargeVelocityMin) { @@ -819,11 +779,10 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = bossRush ? 18 : 12; + int totalProjectiles = 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBlast; - int damage = NPC.GetProjectileDamage(type); - float velocity = 10f + enrageScale; + float velocity = death ? 10.5f : 10f; float projectileVelocityToPass = 0f; if (type == ModContent.ProjectileType()) projectileVelocityToPass = velocity * 2f; @@ -832,7 +791,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceBlastDamage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); } } } @@ -843,8 +802,7 @@ namespace CalamityMod.NPCs.Cryogen float playerYDist = player.Center.Y - cryogenCenter.Y; float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - float speed = revenge ? 5.5f : 5f; - speed += 3f * enrageScale; + float speed = death ? 7f : revenge ? 5.5f : 5f; playerDistance = speed / playerDistance; playerXDist *= playerDistance; @@ -927,11 +885,10 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { int type = iceRain; - int damage = NPC.GetProjectileDamage(type); - float velocity = 9f + enrageScale; + float velocity = death ? 9.5f : 9f; for (int i = 0; i < 3; i++) { - int totalProjectiles = bossRush ? 9 : 6; + int totalProjectiles = 6; float radians = MathHelper.TwoPi / totalProjectiles; float newVelocity = velocity - (velocity * 0.33f * i); float projectileVelocityToPass = 0f; @@ -949,7 +906,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, 0f, type == ModContent.ProjectileType() ? 0f : velocity, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceRainDamage, 0f, Main.myPlayer, 0f, type == ModContent.ProjectileType() ? 0f : velocity, projectileVelocityToPass); } } } @@ -1006,7 +963,7 @@ namespace CalamityMod.NPCs.Cryogen { string key = Main.zenithWorld ? "Mods.CalamityMod.Status.Boss.PyrogenBossText" : "Mods.CalamityMod.Status.Boss.CryogenBossText"; Color messageColor = Main.zenithWorld ? Color.Orange : Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } } } @@ -1019,7 +976,7 @@ namespace CalamityMod.NPCs.Cryogen { if (NPC.ai[1] == 60f) // Spawn homing ice blasts on charge { - NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (18f + enrageScale * 2f); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * (death ? 19f : 18f); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { @@ -1028,12 +985,11 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { int type = iceBlast; - int damage = NPC.GetProjectileDamage(type); - float velocity = 1.5f + enrageScale * 0.5f; + float velocity = death ? 1.75f : 1.5f; int totalSpreads = phase7 ? 3 : 2; for (int i = 0; i < totalSpreads; i++) { - int totalProjectiles = bossRush ? 3 : 2; + int totalProjectiles = 2; float radians = MathHelper.TwoPi / totalProjectiles; float newVelocity = velocity - (velocity * (phase7 ? 0.25f : 0.5f) * i); float projectileVelocityToPass = 0f; @@ -1052,7 +1008,7 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer, ai, type == ModContent.ProjectileType() ? 0f : 1f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceBlastDamage, 0f, Main.myPlayer, ai, type == ModContent.ProjectileType() ? 0f : 1f, projectileVelocityToPass); } } } @@ -1096,7 +1052,7 @@ namespace CalamityMod.NPCs.Cryogen return; } - float chargeVelMult = 18f + enrageScale * 2f; + float chargeVelMult = death ? 19f : 18f; Vector2 chargeDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); float playerchargeXDist = player.position.X + player.width * 0.5f - chargeDirection.X; @@ -1156,14 +1112,13 @@ namespace CalamityMod.NPCs.Cryogen NPC.rotation = NPC.velocity.X * 0.1f; calamityGlobalNPC.newAI[3] += 1f; - if (calamityGlobalNPC.newAI[3] >= (bossRush ? 50f : 75f)) + if (calamityGlobalNPC.newAI[3] >= 75f) { calamityGlobalNPC.newAI[3] = 0f; SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); int totalProjectiles = 2; float radians = MathHelper.TwoPi / totalProjectiles; int type = iceBomb; - int damage = NPC.GetProjectileDamage(type); float velocity2 = 6f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; @@ -1172,12 +1127,12 @@ namespace CalamityMod.NPCs.Cryogen for (int k = 0; k < totalProjectiles; k++) { Vector2 projSpreadRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projSpreadRotation) * 30f, projSpreadRotation, type, IceBombDamage, 0f, Main.myPlayer); } } NPC.ai[1] += 1f; - if (NPC.ai[1] >= (bossRush ? 120f : 180f)) + if (NPC.ai[1] >= 180f) { NPC.TargetClosest(); NPC.ai[0] = 4f; @@ -1187,10 +1142,8 @@ namespace CalamityMod.NPCs.Cryogen NPC.netUpdate = true; } - float velocity = revenge ? 5f : 6f; - float acceleration = 0.2f; - velocity -= enrageScale; - acceleration += 0.07f * enrageScale; + float velocity = death ? 4.5f : revenge ? 5f : 6f; + float acceleration = death ? 0.535f : 0.2f; if (NPC.position.Y > player.position.Y - 375f) { @@ -1341,7 +1294,6 @@ namespace CalamityMod.NPCs.Cryogen public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void ModifyTypeName(ref string typeName) @@ -1391,7 +1343,7 @@ namespace CalamityMod.NPCs.Cryogen } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.GreaterHealingPotion; } @@ -1423,7 +1375,8 @@ namespace CalamityMod.NPCs.Cryogen normalOnly.Add(ModContent.ItemType(), 1, 8, 10); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); } @@ -1435,7 +1388,7 @@ namespace CalamityMod.NPCs.Cryogen npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Bloodflare Core drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCryogen, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1472,7 +1425,7 @@ namespace CalamityMod.NPCs.Cryogen tileTypes.Add(TileID.JungleGrass); CalamityUtils.SpawnOre(ModContent.TileType(), 16E-05, 0.45f, 0.7f, 6, 11, tileTypes); - CalamityUtils.DisplayLocalizedText(key, Color.LightSkyBlue); + CalamityUtils.BroadcastLocalizedText(key, Color.LightSkyBlue); } // Mark Cryogen as dead @@ -1506,15 +1459,9 @@ namespace CalamityMod.NPCs.Cryogen if (hurtInfo.Damage > 0) { if (Main.zenithWorld) - { - target.AddBuff(ModContent.BuffType(), 120, true); - target.AddBuff(ModContent.BuffType(), 120, true); - } + target.AddBuff(ModContent.BuffType(), 180); else - { - target.AddBuff(BuffID.Frostburn, 240, true); - target.AddBuff(BuffID.Chilled, 120, true); - } + target.AddBuff(BuffID.Chilled, 120); } } } diff --git a/NPCs/Cryogen/CryogenShield.cs b/NPCs/Cryogen/CryogenShield.cs index aff0c00efc..a2befaa003 100644 --- a/NPCs/Cryogen/CryogenShield.cs +++ b/NPCs/Cryogen/CryogenShield.cs @@ -24,11 +24,11 @@ namespace CalamityMod.NPCs.Cryogen public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 60; // 120 NPC.aiStyle = -1; AIType = -1; NPC.noTileCollide = true; NPC.coldDamage = true; - NPC.GetNPCDamage(); NPC.width = 216; NPC.height = 216; NPC.scale *= (CalamityWorld.death || BossRushEvent.BossRushActive || Main.getGoodWorld) ? 0.8f : 1f; @@ -115,15 +115,9 @@ namespace CalamityMod.NPCs.Cryogen if (hurtInfo.Damage > 0) { if (Main.zenithWorld) - { - target.AddBuff(ModContent.BuffType(), 120, true); - target.AddBuff(ModContent.BuffType(), 120, true); - } + target.AddBuff(ModContent.BuffType(), 180); else - { - target.AddBuff(BuffID.Frostburn, 240, true); - target.AddBuff(BuffID.Chilled, 120, true); - } + target.AddBuff(BuffID.Chilled, 120); } } diff --git a/NPCs/Deconstructors/Burrower.cs b/NPCs/Deconstructors/Burrower.cs new file mode 100644 index 0000000000..17fc2c7c3c --- /dev/null +++ b/NPCs/Deconstructors/Burrower.cs @@ -0,0 +1,553 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Effects; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Sounds; +using CalamityMod.Systems; +using CalamityMod.Systems.Mechanic; +using CalamityMod.Tiles.Ores; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; +namespace CalamityMod.NPCs.Deconstructors +{ + public class BurrowerHitbox : BaseWormHitboxNPC + { + public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.Burrower.DisplayName"); + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + return false; + } + public override void SetDefaults() + { + NPC.damage = 0; + NPC.width = 88; + NPC.height = 88; + NPC.lifeMax = 100; + NPC.value = 0; + + NPC.HitSound = ThanatosHead.ThanatosHitSoundClosed; + NPC.DeathSound = CommonCalamitySounds.WulfrumNPCDeathSound; + NPC.knockBackResist = 0f; + NPC.behindTiles = true; + NPC.noTileCollide = true; + NPC.netAlways = true; + NPC.SuperArmor = true; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToCold = false; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToWater = false; + NPC.chaseable = false; + Banner = ModContent.NPCType(); + BannerItem = ModContent.ItemType(); + base.SetDefaults(); + } + public override void AI() + { + base.AI(); + var headNPC = Main.npc[(int)NPC.ai[0]]; + NPC.Calamity().DR = headNPC.Calamity().DR; + NPC.HitSound = headNPC.HitSound; + NPC.width = 38; + NPC.height = 38; + } + } + public class Burrower : BaseWormNPC + { + public override string Texture => "CalamityMod/NPCs/Deconstructors/DeconstructorMK1Head"; + + public override int WormHitboxNpcType => ModContent.NPCType(); + public override List SegmentTextures => new() + { + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1Body", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt1", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt2", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1Tail" + }; + + public override List GlowTextures => new() + { + null, + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyGlow", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt1Glow", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt2Glow" + }; + public override int SegmentCount => 10; + + public override List SegmentTypePositionOffsets => new() + { + 32, + 32, + 32, + 32, + 32 + }; + + public static HashSet VulnerableDebuffs => [BuffID.Electrified, ModContent.BuffType(), ModContent.BuffType(), ModContent.BuffType()]; + public override void SetStaticDefaults() + { + NPCID.Sets.ImmuneToRegularBuffs[Type] = true; + foreach (var item in VulnerableDebuffs) + { + NPCID.Sets.SpecificDebuffImmunity[Type][item] = false; + } + NPCID.Sets.ImmuneToRegularBuffs[WormHitboxNpcType] = NPCID.Sets.ImmuneToRegularBuffs[Type]; + NPCID.Sets.SpecificDebuffImmunity[WormHitboxNpcType] = NPCID.Sets.SpecificDebuffImmunity[Type]; + base.SetStaticDefaults(); + } + public override void SetDefaults() + { + + NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 0; + NPC.width = 38; + NPC.height = 38; + NPC.lifeMax = 500; + NPC.value = Item.buyPrice(0, 0, 50, 0); + NPC.rarity = 3; + NPC.HitSound = ThanatosHead.ThanatosHitSoundClosed; + NPC.DeathSound = SoundID.NPCDeath44; + NPC.knockBackResist = 0f; + NPC.behindTiles = true; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.netAlways = true; + NPC.chaseable = false; + NPC.Calamity().DR = 0.9f; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToCold = false; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToWater = false; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + + for (var i = 0; i < SegmentCount - 1; i++) + { + Segments.Add(new BaseWormSegment(this, i % 3)); + } + Segments.Add(new BaseWormSegment(this, 3)); + } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange( + [ + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Caverns, + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Burrower") + ]); + } + + #region AI Variables + + public enum AttackState + { + Idle, + Mining, + GettingItem, + Fleeing + } + public AttackState ActiveAttackState + { + get { return (AttackState)NPC.ai[1]; } + set { NPC.ai[1] = (float)value; } + } + public float MainTimer + { + get { return NPC.ai[0]; } + set { NPC.ai[0] = value; } + } + + public float AttackSubstate + { + get { return NPC.ai[2]; } + set { NPC.ai[2] = value; } + } + + public float StateChangeCounter + { + get { return NPC.ai[3]; } + set { NPC.ai[3] = value; } + } + public float VelocityRotation + { + + get { return NPC.velocity.ToRotation(); } + set { NPC.velocity = value.ToRotationVector2() * NPC.velocity.Length(); } + } + + public Vector2 TargetVector = Vector2.Zero; + public Vector2 SecondaryVector = Vector2.Zero; + public float StoredValue = 0; + #endregion + + public void SwitchAttackState(AttackState State, float Substate = 0, bool resetVector = true) + { + ActiveAttackState = State; + AttackSubstate = Substate; + MainTimer = 0; + if (resetVector) + TargetVector = Vector2.Zero; + } + + public override void AI() + { + //Force burrower bestiary to unlock + if (Main.netMode != NetmodeID.MultiplayerClient && Main.BestiaryTracker.Kills.GetKillCount(NPC) <= 0) + { + Main.BestiaryTracker.Kills.RegisterKill(NPC); + } + HandleAIStates(); + MainTimer++; + UpdateSegments(); + } + public static List> FindOreVeins(Point wormTile) + { + List> oreVeins = new(); + HashSet visited = new(); + + for (int x = -30; x <= 30; x++) + { + int tileX = wormTile.X + x; + if (tileX < 0 || tileX >= Main.maxTilesX) + continue; + + for (int y = -30; y <= 30; y++) + { + int tileY = wormTile.Y + y; + if (tileY < 0 || tileY >= Main.maxTilesY) + continue; + + Point start = new(tileX, tileY); + if (visited.Contains(start)) + continue; + + var tile = Main.tile[start]; + + //This uses a flood fill to check for the ore vein + if (tile.HasTile && TileID.Sets.Ore[tile.TileType]) + { + List vein = new(); + Queue queue = new(); + queue.Enqueue(start); + visited.Add(start); + while (queue.Count > 0) + { + Point p = queue.Dequeue(); + vein.Add(p); + foreach (var offset in new[] { new Point(1, 0), new Point(-1, 0), new Point(0, 1), new Point(0, -1) }) + { + Point neighbor = p + offset; + if (neighbor.X < 0 || neighbor.X >= Main.maxTilesX || neighbor.Y < 0 || neighbor.Y >= Main.maxTilesY) + continue; + if (visited.Contains(neighbor)) + continue; + + var neighborTile = Main.tile[neighbor]; + if (neighborTile.HasTile && TileID.Sets.Ore[neighborTile.TileType]) + { + queue.Enqueue(neighbor); + visited.Add(neighbor); + } + } + } + + oreVeins.Add(vein); + } + } + } + return oreVeins; + } + + public static (Point, Point)? FindTargetFromVein(List vein) + { + HashSet veinSet = new(vein); + List<(Point, Point)> outerPoints = []; + + foreach (var p in vein) + { + foreach (var offset in new[] { new Point(1, 0), new Point(-1, 0), new Point(0, 1), new Point(0, -1) }) + { + Point neighbor = p + offset; + if (!veinSet.Contains(neighbor)) + { + if (neighbor.X >= 0 && neighbor.X < Main.maxTilesX && neighbor.Y >= 0 && neighbor.Y < Main.maxTilesY) + { + var tile = Main.tile[neighbor]; + if (tile == null || !tile.HasTile || !tile.IsTileSolid()) + outerPoints.Add((p, neighbor)); // Return the first found ore block adjacent to air, and the air block found. + } + } + } + } + if (outerPoints.Count > 0) + return outerPoints[Main.rand.Next(outerPoints.Count)]; + // If none are adjacent to air, return null + return null; + } + + private void LowerTargetToGround() + { + var pointToCheck = TargetVector.ToTileCoordinates(); + for (var i = 0; i < 50; i++) + { + if (pointToCheck.X < 0 || pointToCheck.X >= Main.maxTilesX || pointToCheck.Y < 0 || pointToCheck.Y >= Main.maxTilesY) + return; + var targetTile = Main.tile[pointToCheck]; + if (targetTile == null || !targetTile.HasTile || !targetTile.IsTileSolidGround()) + pointToCheck.Y += 1; + else + { + TargetVector = pointToCheck.ToWorldCoordinates() - new Vector2(0, 16); + return; + } + } + } + + public void HandleAIStates() + { + NPC.CalamityTargeting(CalamityTargetingParameters.BossDefaults); + if (!NPC.HasValidTarget) + return; + Player player = Main.player[NPC.target]; + SegmentMaxRotation = 0.65f; + SegmentRigidity = 0.2f; + if (NPC.life < NPC.lifeMax && ActiveAttackState != AttackState.Fleeing) + { + ActiveAttackState = AttackState.Fleeing; + GeneralParticleHandler.SpawnParticle(new EmoteExpressionParticle(NPC.Top, -Vector2.UnitY * 5, 2, ArsenalEffects.ArsenalLaserColor, 60, EmoteExpressionParticle.EmoteType.DoubleExclamation)); + } + + NPC.FindClosestPlayer(out float distanceToPlayer); + bool noGravity = distanceToPlayer > 800 || NPC.wet || Collision.SolidCollision(NPC.position, NPC.width, NPC.height, true); + switch (ActiveAttackState) + { + case AttackState.Idle: + { + if (TargetVector == Vector2.Zero || MainTimer > 300 || NPC.Distance(TargetVector) < 32) + { + if (Main.rand.NextBool()) + { + var veins = FindOreVeins(NPC.Center.ToTileCoordinates()); + while (veins.Count > 0) + { + var targetVein = veins[Main.rand.Next(veins.Count)]; + var foundTarget = FindTargetFromVein(targetVein); + if (foundTarget is not null) + { + TargetVector = foundTarget.Value.Item1.ToWorldCoordinates(); + SecondaryVector = foundTarget.Value.Item2.ToWorldCoordinates(); + if (NPC.Distance(TargetVector) > 160) + GeneralParticleHandler.SpawnParticle(new EmoteExpressionParticle(NPC.Top, -Vector2.UnitY * 5, 2, ArsenalEffects.ArsenalGaussColor, 60, EmoteExpressionParticle.EmoteType.Exclamation)); + SwitchAttackState(AttackState.Mining, resetVector: false); + return; + } + else + veins.Remove(targetVein); + } + } + TargetVector = player.Center + Main.rand.NextVector2Circular(800, 800); + LowerTargetToGround(); + MainTimer = 0; + } + if (AttackSubstate <= 0 && noGravity) + { + NPC.velocity += NPC.DirectionTo(TargetVector); + NPC.velocity *= 0.9f; + } + else + { + AttackSubstate--; + if (!noGravity) + { + AttackSubstate = 30; + NPC.velocity.Y += 1f; + } + else + { + if (NPC.velocity.Y > 8) + NPC.velocity.Y *= 0.9f; + NPC.velocity.X *= 0.95f; + } + } + NPC.velocity = NPC.velocity.ClampMagnitude(0, 16); + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + break; + } + case AttackState.Mining: + { + NPC.velocity += NPC.DirectionTo(SecondaryVector).SafeNormalize(Vector2.UnitY); + NPC.velocity *= 0.9f; + if (MainTimer > 600) + SwitchAttackState(AttackState.Idle); + if (NPC.Distance(SecondaryVector) < 4) + { + var dir = SecondaryVector.DirectionTo(TargetVector); + + if (Main.tile[TargetVector.ToTileCoordinates()].TileType == ModContent.TileType()) + { + NPC.velocity = -NPC.DirectionTo(TargetVector) * 16; + NPC.Center = SecondaryVector + NPC.velocity; + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; + NPC.AddBuff(ModContent.BuffType(), 600); + ActiveAttackState = AttackState.Fleeing; + AuricOre.Animate = true; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ExoMechs/TeslaShoot1"), NPC.Center); + return; + } + SegmentRigidity = 0f; + NPC.velocity = Vector2.Zero; + NPC.rotation = SecondaryVector.DirectionTo(TargetVector).ToRotation() + MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.Server && !(BurrowerPingTileEffect.Instance.Active)) + TilePingerSystem.AddPing(BurrowerPingTileEffect.Instance, NPC.Center, player); + for (int i = 0; i < 1; i++) + { + int sparkLifetime = Main.rand.Next(10, 20); + float sparkScale = Main.rand.NextFloat(0.8f, 1f); + Color sparkColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.Orange, Main.rand.NextFloat()); + + if (Main.rand.NextBool(10)) + sparkScale *= 2f; + + Vector2 sparkVelocity = dir.RotatedByRandom(0.6f) * Main.rand.NextFloat(6f, 16f); + SparkParticle spark = new SparkParticle((TargetVector + SecondaryVector) * 0.5f, -sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + + if (MainTimer < 520) + MainTimer = 520; + } + SoundEngine.PlaySound(SoundID.NPCHit18 with { Volume = 0.2f }, NPC.Center); + } + else + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + break; + } + case AttackState.GettingItem: + { + ActiveAttackState = AttackState.Idle; + break; + } + case AttackState.Fleeing: + { + bool shocked = false; + foreach (var item in VulnerableDebuffs) + { + if (NPC.HasBuff(item) || Main.npc.Any(x => x.active && x.type == WormHitboxNpcType && x.HasBuff(item))) + { + shocked = true; + break; + } + } + if (noGravity) + { + if (shocked) + { + SegmentRigidity = 0; + NPC.velocity *= 0.75f; + foreach (var item in Segments) + { + if (!Collision.SolidCollision(item.Center - new Vector2(19, 17), 38, 38, true)) + item.Center.Y += 2f; + } + } + else + { + NPC.velocity += NPC.DirectionFrom(Main.player[NPC.FindClosestPlayer()].Center); + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + } + else + { + NPC.velocity.Y += shocked ? 0.5f : 1; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + break; + } + } + } + public override void HitEffect(NPC.HitInfo hit) + { + if (NPC.life <= 0) + { + + Gore.NewGore(NPC.GetSource_Death(), NPC.Center, NPC.velocity, Mod.Find("DeconstructorMK1_Head").Type, NPC.scale); + Gore.NewGore(NPC.GetSource_Death(), NPC.Center, NPC.velocity, Mod.Find("DeconstructorMK1_Head2").Type, NPC.scale); + foreach (var item in Segments) + { + switch (item.segmentType) + { + case 0: + Gore.NewGore(NPC.GetSource_Death(), item.Center, NPC.velocity, Mod.Find("DeconstructorMK1_Body").Type, NPC.scale); + Gore.NewGore(NPC.GetSource_Death(), item.Center, NPC.velocity, Mod.Find("DeconstructorMK1_Body2").Type, NPC.scale); + break; + + case 1: + Gore.NewGore(NPC.GetSource_Death(), item.Center, NPC.velocity, Mod.Find("DeconstructorMK1_BodyAlt_1").Type, NPC.scale); + Gore.NewGore(NPC.GetSource_Death(), item.Center, NPC.velocity, Mod.Find("DeconstructorMK1_BodyAlt_2").Type, NPC.scale); + break; + + case 2: + Gore.NewGore(NPC.GetSource_Death(), item.Center, NPC.velocity, Mod.Find("DeconstructorMK1_BodyAlt2_1").Type, NPC.scale); + Gore.NewGore(NPC.GetSource_Death(), item.Center, NPC.velocity, Mod.Find("DeconstructorMK1_BodyAlt2_2").Type, NPC.scale); + break; + + case 3: + Gore.NewGore(NPC.GetSource_Death(), item.Center, NPC.velocity, Mod.Find("DeconstructorMK1_Tail").Type, NPC.scale); + break; + } + } + } + } + + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType(), 1, 4, 8); + npcLoot.Add(ModContent.ItemType(), 1, 4, 8); + npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ItemID.CopperOre, 2, 6, 32); + npcLoot.Add(ItemID.TinOre, 2, 6, 32); + npcLoot.Add(ItemID.IronOre, 2, 6, 32); + npcLoot.Add(ItemID.LeadOre, 2, 6, 32); + npcLoot.Add(ItemID.SilverOre, 3, 6, 32); + npcLoot.Add(ItemID.TungstenOre, 3, 6, 32); + npcLoot.Add(ItemID.GoldOre, 4, 6, 32); + npcLoot.Add(ItemID.PlatinumOre, 4, 6, 32); + npcLoot.Add(ItemID.DemoniteOre, 5, 6, 32); + npcLoot.Add(ItemID.CrimtaneOre, 5, 6, 32); + + var condition = npcLoot.DefineConditionalDropSet(DropHelper.PostPlant()); + condition.Add(ItemID.CobaltOre, 2, 6, 32); + condition.Add(ItemID.PalladiumOre, 2, 6, 32); + condition.Add(ItemID.MythrilOre, 3, 6, 32); + condition.Add(ItemID.OrichalcumOre, 3, 6, 32); + condition.Add(ItemID.AdamantiteOre, 4, 6, 32); + condition.Add(ItemID.TitaniumOre, 4, 6, 32); + condition.Add(ModContent.ItemType(), 5, 6, 32); + condition.Add(ModContent.ItemType(), 5, 6, 32); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().InAnyCalamityBiome || Main.npc.Any(x => x.active && x.type == Type)) + { + return 0f; + } + return SpawnCondition.Cavern.Chance * (Main.projectile.Any(x => x.active && x.type == ModContent.ProjectileType()) ? 5f : 0.01f); + } + } +} diff --git a/NPCs/Deconstructors/DeconstructorMK1Body.png b/NPCs/Deconstructors/DeconstructorMK1Body.png new file mode 100644 index 0000000000..51e9c5a95d Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1Body.png differ diff --git a/NPCs/Deconstructors/DeconstructorMK1BodyAlt1.png b/NPCs/Deconstructors/DeconstructorMK1BodyAlt1.png new file mode 100644 index 0000000000..55cc3da5b8 Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1BodyAlt1.png differ diff --git a/NPCs/Deconstructors/DeconstructorMK1BodyAlt1Glow.png b/NPCs/Deconstructors/DeconstructorMK1BodyAlt1Glow.png new file mode 100644 index 0000000000..ea9baf9d2a Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1BodyAlt1Glow.png differ diff --git a/NPCs/Deconstructors/DeconstructorMK1BodyAlt2.png b/NPCs/Deconstructors/DeconstructorMK1BodyAlt2.png new file mode 100644 index 0000000000..d9106efcf1 Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1BodyAlt2.png differ diff --git a/NPCs/Deconstructors/DeconstructorMK1BodyAlt2Glow.png b/NPCs/Deconstructors/DeconstructorMK1BodyAlt2Glow.png new file mode 100644 index 0000000000..ea9baf9d2a Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1BodyAlt2Glow.png differ diff --git a/NPCs/Deconstructors/DeconstructorMK1BodyGlow.png b/NPCs/Deconstructors/DeconstructorMK1BodyGlow.png new file mode 100644 index 0000000000..ea9baf9d2a Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1BodyGlow.png differ diff --git a/NPCs/Deconstructors/DeconstructorMK1Head.png b/NPCs/Deconstructors/DeconstructorMK1Head.png new file mode 100644 index 0000000000..2d82289e9a Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1Head.png differ diff --git a/NPCs/Deconstructors/DeconstructorMK1Tail.png b/NPCs/Deconstructors/DeconstructorMK1Tail.png new file mode 100644 index 0000000000..5919f95939 Binary files /dev/null and b/NPCs/Deconstructors/DeconstructorMK1Tail.png differ diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index e0164802fe..7781a7a2fd 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -1,5 +1,4 @@ -using System.IO; -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -39,7 +38,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 12; // 24 NPC.width = 88; NPC.height = 88; @@ -48,8 +47,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.defense += 27; NPC.LifeMaxNERB(1500, 1800, 40000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax = 4800; + if (Main.getGoodWorld) + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -64,18 +63,14 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.ai[3] > 0f) { @@ -170,28 +165,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * segmentOffset; NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); - - // Calculate contact damage based on velocity - float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHead.SegmentVelocity_ZenithSeed : - Main.getGoodWorld ? DesertNuisanceHead.SegmentVelocity_GoodWorld : - masterMode ? DesertNuisanceHead.SegmentVelocity_Master : - DesertNuisanceHead.SegmentVelocity_Expert; - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CheckActive() => false; @@ -319,12 +292,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * balance); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Bleeding, 60, true); - } - public override Color? GetAlpha(Color drawColor) { if (Main.zenithWorld) diff --git a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs index d3448785a3..8ff751e785 100644 --- a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs @@ -1,5 +1,4 @@ -using System.IO; -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -39,7 +38,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 12; // 24 NPC.width = 78; NPC.height = 78; @@ -48,8 +47,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.defense += 26; NPC.LifeMaxNERB(1300, 1560, 35000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax = 4000; + if (Main.getGoodWorld) + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -64,18 +63,14 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.ai[3] > 0f) { @@ -178,28 +173,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * segmentOffset; NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); - - // Calculate contact damage based on velocity - float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHeadYoung.SegmentVelocity_ZenithSeed : - Main.getGoodWorld ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld : - masterMode ? DesertNuisanceHeadYoung.SegmentVelocity_Master : - DesertNuisanceHeadYoung.SegmentVelocity_Expert; - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CheckActive() => false; @@ -327,12 +300,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * balance); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Bleeding, 60, true); - } - public override Color? GetAlpha(Color drawColor) { if (Main.zenithWorld) diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 3b033e67f9..3eb9cecc4b 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -3,8 +3,10 @@ using System.IO; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -20,10 +22,10 @@ namespace CalamityMod.NPCs.DesertScourge public bool flies = false; private bool tailSpawned = false; - public const float SegmentVelocity_Expert = 14f; - public const float SegmentVelocity_Master = 16.5f; + public const float SegmentVelocity_Expert = 11f; + public const float SegmentVelocity_Death = 13.5f; public const float SegmentVelocity_GoodWorld = 19f; - public const float SegmentVelocity_ZenithSeed = 21.5f; + public const float SegmentVelocity_ZenithSeed = 22f; public const float OpenMouthForBiteDistance = 220f; @@ -36,14 +38,13 @@ namespace CalamityMod.NPCs.DesertScourge NPCID.Sets.BossBestiaryPriority.Add(Type); NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { - Scale = 0.6f, - PortraitScale = 0.6f, - CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/DesertNuisance_Bestiary", - PortraitPositionXOverride = 40, - PortraitPositionYOverride = 40 + Scale = 0.65f, + PortraitScale = 0.7f, + PortraitPositionXOverride = 0, + PortraitPositionYOverride = 0 }; - value.Position.X += 45; - value.Position.Y += 30; + value.Position.X += 0; + value.Position.Y -= 20; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.MPAllowedEnemies[Type] = true; NPCID.Sets.CantTakeLunchMoney[Type] = true; @@ -53,7 +54,7 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 25; // 40 (1.6x expert scaling) NPC.defense = 3; if (Main.getGoodWorld) @@ -63,8 +64,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.height = 88; NPC.LifeMaxNERB(1500, 1800, 40000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax = 4800; + if (Main.getGoodWorld) + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -79,9 +80,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); - if (Main.zenithWorld) NPC.scale *= 2; } @@ -110,17 +108,15 @@ namespace CalamityMod.NPCs.DesertScourge public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Become angry when the other Nuisance dies. bool getMad = (!NPC.AnyNPCs(ModContent.NPCType()) && revenge) || death; // Enrage - if (!Main.player[NPC.target].ZoneDesert && !bossRush) + if (!Main.player[NPC.target].ZoneDesert && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) biomeEnrageTimer--; @@ -128,24 +124,24 @@ namespace CalamityMod.NPCs.DesertScourge else biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; + bool biomeEnraged = biomeEnrageTimer <= 0; - float enrageScale = bossRush ? 1f : getMad ? 0.5f : 0f; + float enrageScale = getMad ? 0.5f : 0f; if (biomeEnraged) { - NPC.Calamity().CurrentlyEnraged = !bossRush; + NPC.Calamity().CurrentlyEnraged = true; enrageScale += 2f; } // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = death ? 0.18f : 0.16f; - float turnSpeed = death ? 0.26f : 0.22f; + float speed = death ? 0.105f : 0.085f; + float turnSpeed = death ? 0.21f : 0.17f; speed += speed * 0.4f * (1f - lifeRatio); turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); - speed += 0.16f * enrageScale; - turnSpeed += 0.22f * enrageScale; + speed += 0.085f * enrageScale; + turnSpeed += 0.17f * enrageScale; if (Main.getGoodWorld) { @@ -247,7 +243,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 = revenge ? 500 : 1000; + int directChaseDistance = death ? 400 : revenge ? 500 : 1000; bool shouldDirectlyChase = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { @@ -274,10 +270,10 @@ namespace CalamityMod.NPCs.DesertScourge float maxChaseSpeed = Main.zenithWorld ? SegmentVelocity_ZenithSeed : Main.getGoodWorld ? SegmentVelocity_GoodWorld : - masterMode ? SegmentVelocity_Master : + death ? SegmentVelocity_Death : SegmentVelocity_Expert; maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - if (masterMode) + if (death) maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (Main.player[NPC.target].dead) @@ -300,12 +296,6 @@ namespace CalamityMod.NPCs.DesertScourge } } - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - { - speed *= 1.5f; - turnSpeed *= 1.5f; - } - Vector2 npcCenter = NPC.Center; float playerX = Main.player[NPC.target].Center.X; float targettingPosition = Main.player[NPC.target].Center.Y; @@ -319,7 +309,7 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.velocity.Y += 0.15f; + NPC.velocity.Y += (death ? 0.125f : 0.1f); if (NPC.velocity.Y > 0f && Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > 180f) NPC.velocity.Y += 0.05f; @@ -455,22 +445,9 @@ namespace CalamityMod.NPCs.DesertScourge } Vector2 destination = Main.player[NPC.target].Center; - if (NPC.Distance(destination) > 1000f) + if (NPC.Distance(destination) > (getMad ? 750f : 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; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } - NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2; if (shouldFly) @@ -598,16 +575,50 @@ namespace CalamityMod.NPCs.DesertScourge } } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.IsABestiaryIconDummy) + { + Texture2D texture = TextureAssets.Npc[NPC.type].Value; + NPC.Opacity = 1f; + // Reimplementation of CalamityUtils.DrawAnimatedBestiaryWorm but tweaked due to this entity' animations + NPC.frame = texture.Frame(); + // Buffers the segment position and rotations + float offset = -0.2f; + float startX = 60; + float startY = 70; + int segmentSpacing = 50; + int animationSpeed = 8; + float wormTimer = NPC.Calamity().bestiaryWormTimer; + int segCount = 3; + // Draw the body segments + for (int i = segCount; i > 0; i--) + { + // The first segment is slightly closer to keep up with the head + float bodyOffset = i * segmentSpacing - segmentSpacing * 0.5f; + + Texture2D toUse = i == 1 ? TextureAssets.Npc[ModContent.NPCType()].Value : DesertNuisanceBody.BodyTexture2.Value; + int frameCount = i == 1 ? 7 : 1; + spriteBatch.Draw(toUse, NPC.position + new Vector2(startX + bodyOffset, MathF.Sin((wormTimer + offset * i) * animationSpeed) * 2 + startY), toUse.Frame(1, frameCount, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer + offset * i) * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(toUse.Width / 2, toUse.Height / (frameCount * 2)), NPC.scale, SpriteEffects.None, 0f); + } + // Draw the head + spriteBatch.Draw(texture, NPC.position + new Vector2(startX + 18, MathF.Sin(wormTimer * animationSpeed) * 2 + startY), texture.Frame(1, 7, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos(wormTimer * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(texture.Width * 0.5f, texture.Height / 7), NPC.scale, SpriteEffects.None, 0f); + + return false; + } + return true; + } + public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * balance); + NPC.damage = (int)(NPC.damage * 0.8f); } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) { - target.AddBuff(BuffID.Bleeding, 180); NPC.ai[3] = 1f; NPC.ForceNetUpdate(); } diff --git a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs index 55f0ff65dd..76c0ac4356 100644 --- a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs @@ -22,8 +22,8 @@ namespace CalamityMod.NPCs.DesertScourge public bool flies = false; private bool tailSpawned = false; - public const float SegmentVelocity_Expert = 12f; - public const float SegmentVelocity_Master = 14f; + public const float SegmentVelocity_Expert = 10f; + public const float SegmentVelocity_Death = 12f; public const float SegmentVelocity_GoodWorld = 16f; public const float SegmentVelocity_ZenithSeed = 18f; @@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 25; // 40 (1.6x expert scaling) NPC.defense = 2; if (Main.getGoodWorld) @@ -55,8 +55,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.height = 78; NPC.LifeMaxNERB(1300, 1560, 35000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax = 4000; + if (Main.getGoodWorld) + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -71,9 +71,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); - if (Main.zenithWorld) NPC.scale *= 2; } @@ -106,17 +103,15 @@ namespace CalamityMod.NPCs.DesertScourge public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Become angry when the other Nuisance dies. bool getMad = (!NPC.AnyNPCs(ModContent.NPCType()) && revenge) || death; // Enrage - if (!Main.player[NPC.target].ZoneDesert && !bossRush) + if (!Main.player[NPC.target].ZoneDesert && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) biomeEnrageTimer--; @@ -124,24 +119,24 @@ namespace CalamityMod.NPCs.DesertScourge else biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; + bool biomeEnraged = biomeEnrageTimer <= 0; - float enrageScale = bossRush ? 1f : getMad ? 0.25f : 0f; + float enrageScale = getMad ? 0.5f : 0f; if (biomeEnraged) { - NPC.Calamity().CurrentlyEnraged = !bossRush; + NPC.Calamity().CurrentlyEnraged = true; enrageScale += 2f; } // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = death ? 0.16f : 0.14f; - float turnSpeed = death ? 0.24f : 0.2f; + float speed = death ? 0.09f : 0.07f; + float turnSpeed = death ? 0.18f : 0.14f; speed += speed * 0.4f * (1f - lifeRatio); turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); - speed += 0.14f * enrageScale; - turnSpeed += 0.2f * enrageScale; + speed += 0.07f * enrageScale; + turnSpeed += 0.14f * enrageScale; if (Main.getGoodWorld) { @@ -159,7 +154,7 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.alpha < 0) NPC.alpha = 0; - if (getMad && NPC.Distance(Main.player[NPC.target].Center) > 240f) + if (NPC.Distance(Main.player[NPC.target].Center) > 360f) { if ((Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) NPC.Calamity().newAI[0] += 1f; @@ -171,17 +166,11 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * (revenge ? 10f : 8f); - int numProj = death ? 6 : 4; - int spread = masterMode ? 28 : 20; - if (masterMode) - { - numProj += 2; - spread += 8; - } + int numProj = death ? 6 : getMad ? 4 : 3; + int spread = death ? 28 : getMad ? 22 : 20; 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))); @@ -194,7 +183,7 @@ namespace CalamityMod.NPCs.DesertScourge 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); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, DesertScourgeHead.SpitDamage, 0f, Main.myPlayer); Main.projectile[proj].aiStyle = -1; Main.projectile[proj].netUpdate = true; } @@ -287,7 +276,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 = revenge ? 500 : 1000; + int directChaseDistance = death ? 400 : revenge ? 500 : 1000; bool shouldDirectlyChase = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { @@ -318,10 +307,10 @@ namespace CalamityMod.NPCs.DesertScourge float maxChaseSpeed = Main.zenithWorld ? SegmentVelocity_ZenithSeed : Main.getGoodWorld ? SegmentVelocity_GoodWorld : - masterMode ? SegmentVelocity_Master : + death ? SegmentVelocity_Death : SegmentVelocity_Expert; maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - if (masterMode) + if (death) maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); if (Main.player[NPC.target].dead) @@ -344,12 +333,6 @@ namespace CalamityMod.NPCs.DesertScourge } } - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - { - speed *= 1.5f; - turnSpeed *= 1.5f; - } - Vector2 npcCenter = NPC.Center; float playerX = Main.player[NPC.target].Center.X; float targettingPosition = Main.player[NPC.target].Center.Y; @@ -363,7 +346,7 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.velocity.Y += 0.15f; + NPC.velocity.Y += 0.1f; if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; @@ -496,22 +479,9 @@ namespace CalamityMod.NPCs.DesertScourge } Vector2 destination = Main.player[NPC.target].Center; - if (NPC.Distance(destination) > 1000f) + if (NPC.Distance(destination) > (getMad ? 750f : 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; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } - NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2; if (shouldFly) @@ -644,13 +614,13 @@ namespace CalamityMod.NPCs.DesertScourge public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * balance); + NPC.damage = (int)(NPC.damage * 0.8f); } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) { - target.AddBuff(BuffID.Bleeding, 180); NPC.ai[3] = 1f; NPC.ForceNetUpdate(); } diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index 7c83738f4c..883bd3aaf9 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 10; // 20 NPC.width = 88; NPC.height = 88; @@ -30,8 +30,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.defense += 34; NPC.LifeMaxNERB(1500, 1800, 40000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax = 4800; + if (Main.getGoodWorld) + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -46,18 +46,14 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -134,28 +130,6 @@ namespace CalamityMod.NPCs.DesertScourge else if (playerXPos > 0f) NPC.spriteDirection = -1; } - - // Calculate contact damage based on velocity - float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHead.SegmentVelocity_ZenithSeed : - Main.getGoodWorld ? DesertNuisanceHead.SegmentVelocity_GoodWorld : - masterMode ? DesertNuisanceHead.SegmentVelocity_Master : - DesertNuisanceHead.SegmentVelocity_Expert; - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -200,12 +174,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * balance); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Bleeding, 30, true); - } - public override Color? GetAlpha(Color drawColor) { if (Main.zenithWorld) diff --git a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs index 00290efb8d..e20f3281f0 100644 --- a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs @@ -21,7 +21,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 10; // 20 NPC.width = 78; NPC.height = 78; @@ -30,8 +30,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.defense += 33; NPC.LifeMaxNERB(1300, 1560, 35000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.lifeMax = 4000; + if (Main.getGoodWorld) + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -46,18 +46,14 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -142,28 +138,6 @@ namespace CalamityMod.NPCs.DesertScourge else if (playerXPos > 0f) NPC.spriteDirection = -1; } - - // Calculate contact damage based on velocity - float maxChaseSpeed = Main.zenithWorld ? DesertNuisanceHeadYoung.SegmentVelocity_ZenithSeed : - Main.getGoodWorld ? DesertNuisanceHeadYoung.SegmentVelocity_GoodWorld : - masterMode ? DesertNuisanceHeadYoung.SegmentVelocity_Master : - DesertNuisanceHeadYoung.SegmentVelocity_Expert; - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - if (masterMode) - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -208,12 +182,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.lifeMax = (int)(NPC.lifeMax * 0.7f * balance); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Bleeding, 30, true); - } - public override Color? GetAlpha(Color drawColor) { if (Main.zenithWorld) diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index 4f71aff1f7..38f3497888 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -1,20 +1,18 @@ using CalamityMod.Events; -using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using System; using System.IO; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(DesertScourgeHead))] public class DesertScourgeBody : ModNPC { @@ -42,15 +40,14 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 16; // 32 NPC.width = 104; NPC.height = 104; NPC.defense = 6; - NPC.DR_NERD(0.05f); - NPC.LifeMaxNERB(4200, 5000, 1400000); + NPC.LifeMaxNERB(4200, 5000, 1150000); if (Main.getGoodWorld) - NPC.lifeMax *= 4; + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -70,9 +67,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; @@ -91,9 +85,8 @@ namespace CalamityMod.NPCs.DesertScourge public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.ai[3] > 0f) { @@ -213,30 +206,6 @@ namespace CalamityMod.NPCs.DesertScourge bool burrow = head.Calamity().newAI[0] >= burrowTimeGateValue; bool lungeUpward = burrow && head.Calamity().newAI[1] == 1f; bool quickFall = head.Calamity().newAI[1] == 2f; - - // Calculate contact damage based on velocity - float maxChaseSpeed = Main.zenithWorld ? DesertScourgeHead.SegmentVelocity_ZenithSeed : - Main.getGoodWorld ? DesertScourgeHead.SegmentVelocity_GoodWorld : - masterMode ? DesertScourgeHead.SegmentVelocity_Master : - expertMode ? DesertScourgeHead.SegmentVelocity_Expert : - DesertScourgeHead.SegmentVelocity_Normal; - if (burrow || lungeUpward) - maxChaseSpeed *= 1.5f; - if (expertMode) - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity || NPC.dontTakeDamage) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -382,12 +351,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Bleeding, 240); - } - public override Color? GetAlpha(Color drawColor) { if (Main.zenithWorld) diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index e39685f9e3..ae7a2ac6fb 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -7,23 +7,23 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.AquaticScourge; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; @@ -32,6 +32,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { [AutoloadBossHead] + [HasPierceResist] [LongDistanceNetSync] public class DesertScourgeHead : ModNPC { @@ -39,9 +40,9 @@ namespace CalamityMod.NPCs.DesertScourge private bool tailSpawned = false; public bool playRoarSound = false; - public const float SegmentVelocity_Normal = 12f; - public const float SegmentVelocity_Expert = 15f; - public const float SegmentVelocity_Master = 18f; + public const float SegmentVelocity_Normal = 10f; + public const float SegmentVelocity_Expert = 12.5f; + public const float SegmentVelocity_Death = 15f; public const float SegmentVelocity_GoodWorld = 21f; public const float SegmentVelocity_ZenithSeed = 24f; @@ -55,7 +56,6 @@ namespace CalamityMod.NPCs.DesertScourge public const float LungeUpwardCutoffDistance = 420f; public const float BurrowDistance_Hide = 1080f; public const float BurrowDistance = 800f; - public const float BurrowDistance_BossRush = 400f; public const float OpenMouthForBiteDistance = 220f; private const int OpenMouthStopFrame = 4; @@ -74,33 +74,34 @@ namespace CalamityMod.NPCs.DesertScourge { Scale = 0.65f, PortraitScale = 0.7f, - CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/DesertScourge_Bestiary", - PortraitPositionXOverride = 40, - PortraitPositionYOverride = 40 + PortraitPositionXOverride = 0, + PortraitPositionYOverride = 0 }; - value.Position.X += 65; - value.Position.Y += 35; + value.Position.X += 20; + value.Position.Y -= 15; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.MPAllowedEnemies[Type] = true; } + public static int SpitDamage = 10; // 40 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 40; // 64 (1.6x expert scaling) NPC.defense = 4; NPC.npcSlots = 12f; NPC.width = 104; NPC.height = 104; - NPC.LifeMaxNERB(4200, 5000, 1400000); + NPC.LifeMaxNERB(4000, 5000, 1150000); if (Main.getGoodWorld) - NPC.lifeMax *= 4; + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; NPC.boss = true; - NPC.value = Item.buyPrice(0, 2, 0, 0); + NPC.value = Item.buyPrice(gold: 1); NPC.alpha = 255; NPC.behindTiles = true; NPC.noGravity = true; @@ -111,21 +112,17 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.getGoodWorld) NPC.scale *= 0.4f; - if (Main.zenithWorld) NPC.scale *= 4f; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void BossHeadSlot(ref int index) { - if ((NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) && !Main.masterMode) + if ((NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()))) index = -1; } @@ -164,14 +161,12 @@ namespace CalamityMod.NPCs.DesertScourge public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Check for Nuisances - bool hide = (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) && !masterMode; + bool hide = (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())); if (hide) { NPC.Calamity().newAI[0] = 0f; @@ -191,7 +186,7 @@ namespace CalamityMod.NPCs.DesertScourge Player player = Main.player[NPC.target]; // Enrage - if (!player.ZoneDesert && !bossRush) + if (!player.ZoneDesert && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) biomeEnrageTimer--; @@ -199,12 +194,12 @@ namespace CalamityMod.NPCs.DesertScourge else biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; + bool biomeEnraged = biomeEnrageTimer <= 0; - float enrageScale = bossRush ? 1f : 0f; + float enrageScale = 0f; if (biomeEnraged) { - NPC.Calamity().CurrentlyEnraged = !bossRush; + NPC.Calamity().CurrentlyEnraged = true; enrageScale += 2f; } @@ -237,25 +232,25 @@ namespace CalamityMod.NPCs.DesertScourge bool lungeUpward = burrow && NPC.Calamity().newAI[1] == 1f; bool quickFall = NPC.Calamity().newAI[1] == 2f; - float burrowDistance = hide ? BurrowDistance_Hide : bossRush ? BurrowDistance_BossRush : BurrowDistance; + float burrowDistance = hide ? BurrowDistance_Hide : BurrowDistance; - float speed = death ? 0.15f : 0.12f; - float turnSpeed = death ? 0.3f : 0.24f; + float speed = death ? 0.105f : 0.085f; + float turnSpeed = death ? 0.21f : 0.17f; if (expertMode) { - speed += speed * 0.2f * (1f - lifeRatio); - turnSpeed += turnSpeed * 0.2f * (1f - lifeRatio); + speed += speed * 0.4f * (1f - lifeRatio); + turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); } if (revenge) { - speed += (death ? 0.05f : 0.04f) * (1f - lifeRatio); - turnSpeed += (death ? 0.1f : 0.08f) * (1f - lifeRatio); + speed += (death ? 0.03f : 0.02f) * (1f - lifeRatio); + turnSpeed += (death ? 0.06f : 0.04f) * (1f - lifeRatio); } - speed += 0.12f * enrageScale; - turnSpeed += 0.24f * enrageScale; + speed += 0.085f * enrageScale; + turnSpeed += 0.17f * enrageScale; if (Main.getGoodWorld) { @@ -303,7 +298,21 @@ namespace CalamityMod.NPCs.DesertScourge } 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); + { + Vector2 sandSplashSpawnPos = new Vector2(headTileCenter.X * 16 + 8, bestY * 16 - 40); + Projectile.NewProjectile(NPC.GetSource_FromAI(), sandSplashSpawnPos, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + + if (death) + { + int type = ModContent.ProjectileType(); + for (int i = 0; i < 7; i++) + { + Vector2 sandSpitPos = new Vector2((i - 2) * 16f, -Math.Abs((i - 2) * 16f)); + Vector2 sandSpitVelocity = ((sandSplashSpawnPos + Vector2.UnitY * 80f) - (sandSplashSpawnPos + sandSpitPos)).SafeNormalize(Vector2.UnitY) * -((Math.Abs(i - 3) + 1) * 3f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), sandSplashSpawnPos + sandSpitPos, sandSpitVelocity, type, SpitDamage, 0f, Main.myPlayer); + } + } + } } } } @@ -343,7 +352,21 @@ namespace CalamityMod.NPCs.DesertScourge } 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); + { + Vector2 sandSplashSpawnPos = new Vector2(headTileCenter.X * 16 + 8, bestY * 16 - 40); + Projectile.NewProjectile(NPC.GetSource_FromAI(), sandSplashSpawnPos, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + + if (death) + { + int type = ModContent.ProjectileType(); + for (int i = 0; i < 7; i++) + { + Vector2 sandSpitPos = new Vector2((i - 2) * 16f, -Math.Abs((i - 2) * 16f)); + Vector2 sandSpitVelocity = ((sandSplashSpawnPos + Vector2.UnitY * 80f) - (sandSplashSpawnPos + sandSpitPos)).SafeNormalize(Vector2.UnitY) * -((Math.Abs(i - 3) + 1) * 3f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), sandSplashSpawnPos + sandSpitPos, sandSpitVelocity, type, SpitDamage, 0f, Main.myPlayer); + } + } + } } } } @@ -479,7 +502,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 = expertMode ? 800 : 1000; + int directChaseDistance = death ? 600 : expertMode ? 800 : 1000; if (enrageScale > 0f) directChaseDistance = 100; @@ -513,7 +536,7 @@ namespace CalamityMod.NPCs.DesertScourge float maxChaseSpeed = Main.zenithWorld ? SegmentVelocity_ZenithSeed : Main.getGoodWorld ? SegmentVelocity_GoodWorld : - masterMode ? SegmentVelocity_Master : + death ? SegmentVelocity_Death : expertMode ? SegmentVelocity_Expert : SegmentVelocity_Normal; if (burrow || lungeUpward) @@ -571,15 +594,14 @@ namespace CalamityMod.NPCs.DesertScourge { // Spit a huge spread of sand upwards that falls down SoundEngine.PlaySound(SandBlastSound, NPC.Center); - float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 16f : bossRush ? 10f : death ? 8.5f : revenge ? 8f : expertMode ? 7.5f : 6f; + float velocity = Main.getGoodWorld ? 16f : death ? 8.5f : revenge ? 8f : expertMode ? 7.5f : 6f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 projectileVelocity = (NPC.Center + NPC.velocity * 10f - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; - int numProj = bossRush ? 30 : death ? 24 : revenge ? 21 : expertMode ? 18 : 12; + int numProj = death ? 24 : revenge ? 21 : expertMode ? 18 : 12; if (Main.getGoodWorld) numProj *= 2; - int spread = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 120 : 90; + int spread = Main.getGoodWorld ? 120 : 90; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { @@ -592,7 +614,7 @@ namespace CalamityMod.NPCs.DesertScourge } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, SpitDamage, 0f, Main.myPlayer); } NPC.TargetClosest(); @@ -631,7 +653,7 @@ namespace CalamityMod.NPCs.DesertScourge } else if (!shouldFly) { - NPC.velocity.Y += 0.15f; + NPC.velocity.Y += (death ? 0.125f : 0.1f); if (NPC.Center.Y - player.Center.Y < -180f) { NPC.velocity.Y += 0.05f; @@ -777,26 +799,6 @@ namespace CalamityMod.NPCs.DesertScourge 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; - if (hide) - { - NPC.damage = 0; - } - else - { - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } - } - NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2; if (shouldFly) @@ -916,7 +918,7 @@ namespace CalamityMod.NPCs.DesertScourge } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.SandBlock; } @@ -937,8 +939,8 @@ namespace CalamityMod.NPCs.DesertScourge string key2 = "Mods.CalamityMod.Status.Progression.SandstormTrigger"; Color messageColor2 = Color.PaleGoldenrod; - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); + CalamityUtils.BroadcastLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key2, messageColor2); if (!Terraria.GameContent.Events.Sandstorm.Happening) CalamityWorld.StartSandstorm(); @@ -992,11 +994,9 @@ namespace CalamityMod.NPCs.DesertScourge normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); - - // Fishing - normalOnly.Add(ModContent.ItemType()); } // Trophy (always directly from boss, never in bag) @@ -1006,7 +1006,7 @@ namespace CalamityMod.NPCs.DesertScourge npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Sand Shark Tooth Necklace drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedDesertScourge, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1034,22 +1034,47 @@ namespace CalamityMod.NPCs.DesertScourge public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { if (NPC.IsABestiaryIconDummy) + { + Texture2D texture = TextureAssets.Npc[NPC.type].Value; NPC.Opacity = 1f; + // Reimplementation of CalamityUtils.DrawAnimatedBestiaryWorm but tweaked due to this entity' animations + NPC.frame = texture.Frame(); + // Buffers the segment position and rotations + float offset = -0.2f; + float startX = 60; + float startY = 70; + int segmentSpacing = 50; + int animationSpeed = 4; + float wormTimer = NPC.Calamity().bestiaryWormTimer; + int segCount = 3; + // Draw the body segments + for (int i = segCount; i > 0; i--) + { + // The first segment is slightly closer to keep up with the head + float bodyOffset = i * segmentSpacing - segmentSpacing * 0.5f; + Texture2D toUse = i == 1 ? TextureAssets.Npc[ModContent.NPCType()].Value : DesertScourgeBody.BodyTexture2.Value; + int frameCount = i == 1 ? 7 : 1; + spriteBatch.Draw(toUse, NPC.position + new Vector2(startX + bodyOffset, MathF.Sin((wormTimer + offset * i) * animationSpeed) * 2 + startY), toUse.Frame(1, frameCount, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer + offset * i) * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(toUse.Width / 2, toUse.Height / (frameCount * 2)), NPC.scale, SpriteEffects.None, 0f); + } + // Draw the head + spriteBatch.Draw(texture, NPC.position + new Vector2(startX + 18, MathF.Sin(wormTimer * animationSpeed) * 2 + startY), texture.Frame(1, 7, 0, 0), NPC.GetAlpha(drawColor), NPC.rotation - MathHelper.PiOver2 - MathF.Cos(wormTimer * animationSpeed) * MathHelper.PiOver4 * 0.075f, new Vector2(texture.Width * 0.5f, texture.Height / 7), NPC.scale, SpriteEffects.None, 0f); + + return false; + } return true; } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); + NPC.damage = (int)(NPC.damage * 0.8f); } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) { - target.AddBuff(BuffID.Bleeding, 600); NPC.ai[3] = 1f; NPC.ForceNetUpdate(); } diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index 31d98c95c6..98d942c3e2 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -10,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DesertScourge { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(DesertScourgeHead))] public class DesertScourgeTail : ModNPC { @@ -22,15 +23,14 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 14; // 28 NPC.width = 104; NPC.height = 104; NPC.defense = 9; - NPC.DR_NERD(0.1f); - NPC.LifeMaxNERB(4200, 5000, 1400000); + NPC.LifeMaxNERB(4200, 5000, 1150000); if (Main.getGoodWorld) - NPC.lifeMax *= 4; + NPC.lifeMax *= 2; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -50,9 +50,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -71,9 +68,8 @@ namespace CalamityMod.NPCs.DesertScourge public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -175,30 +171,6 @@ namespace CalamityMod.NPCs.DesertScourge bool burrow = head.Calamity().newAI[0] >= burrowTimeGateValue; bool lungeUpward = burrow && head.Calamity().newAI[1] == 1f; bool quickFall = head.Calamity().newAI[1] == 2f; - - // Calculate contact damage based on velocity - float maxChaseSpeed = Main.zenithWorld ? DesertScourgeHead.SegmentVelocity_ZenithSeed : - Main.getGoodWorld ? DesertScourgeHead.SegmentVelocity_GoodWorld : - masterMode ? DesertScourgeHead.SegmentVelocity_Master : - expertMode ? DesertScourgeHead.SegmentVelocity_Expert : - DesertScourgeHead.SegmentVelocity_Normal; - if (burrow || lungeUpward) - maxChaseSpeed *= 1.5f; - if (expertMode) - maxChaseSpeed += maxChaseSpeed * 0.2f * (1f - lifeRatio); - - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity || NPC.dontTakeDamage) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -243,12 +215,6 @@ namespace CalamityMod.NPCs.DesertScourge NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Bleeding, 180); - } - public override Color? GetAlpha(Color drawColor) { if (Main.zenithWorld) diff --git a/NPCs/DevourerofGods/CosmicGuardianBody.cs b/NPCs/DevourerofGods/CosmicGuardianBody.cs deleted file mode 100644 index 51946e7d4c..0000000000 --- a/NPCs/DevourerofGods/CosmicGuardianBody.cs +++ /dev/null @@ -1,239 +0,0 @@ -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -namespace CalamityMod.NPCs.DevourerofGods -{ - [LongDistanceNetSync(SyncWith = typeof(CosmicGuardianHead))] - public class CosmicGuardianBody : ModNPC - { - public int invinceTime = 180; - public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.CosmicGuardianHead.DisplayName"); - - public static Asset GlowTexture; - - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } - } - - public override void SetDefaults() - { - NPC.GetNPCDamage(); - NPC.width = 34; - NPC.height = 34; - NPC.defense = 60; - CalamityGlobalNPC global = NPC.Calamity(); - global.DR = 0.5f; - global.unbreakableDR = true; - NPC.lifeMax = 50000; - NPC.aiStyle = -1; - AIType = -1; - NPC.knockBackResist = 0f; - NPC.Opacity = 0f; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - NPC.dontCountMe = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(NPC.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - NPC.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - NPC.damage = 0; - NPC.dontTakeDamage = true; - } - else - { - NPC.damage = NPC.defDamage; - NPC.dontTakeDamage = false; - } - - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); - if (!shouldDespawn) - { - if (NPC.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)NPC.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - NPC.life = 0; - NPC.HitEffect(0, 10.0); - NPC.checkDead(); - NPC.active = false; - } - - NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; - - Vector2 segmentPosition = NPC.Center; - float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - targetX = (int)(targetX / 16f) * 16; - targetY = (int)(targetY / 16f) * 16; - segmentPosition.X = (int)(segmentPosition.X / 16f) * 16; - segmentPosition.Y = (int)(segmentPosition.Y / 16f) * 16; - targetX -= segmentPosition.X; - targetY -= segmentPosition.Y; - float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) - { - try - { - segmentPosition = NPC.Center; - targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; - targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; - } - catch - { - } - NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + 1.57f; - targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - int segmentWidth = NPC.width; - targetDistance = (targetDistance - segmentWidth) / targetDistance; - targetX *= targetDistance; - targetY *= targetDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + targetX; - NPC.position.Y = NPC.position.Y + targetY; - } - - // Calculate contact damage based on velocity - float segmentVelocity = BossRushEvent.BossRushActive ? 30f : CalamityWorld.revenge ? 25f : 23f; - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / 2)); - - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = ImmunityCooldownID.Bosses; - return NPC.Opacity >= 1f && invinceTime <= 0; - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life <= 0) - { - if (!Main.dedServ) - { - float randomSpread = Main.rand.Next(-200, 201) / 100f; - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT3").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT4").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT5").Type, 1f); - } - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; - NPC.position.X = NPC.position.X - (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 10; i++) - { - int cosmiliteDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[cosmiliteDust].scale = 0.5f; - Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 20; j++) - { - int cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[cosmiliteDust2].noGravity = true; - Main.dust[cosmiliteDust2].velocity *= 5f; - cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust2].velocity *= 2f; - } - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 80, true); - } - } -} diff --git a/NPCs/DevourerofGods/CosmicGuardianBody.png b/NPCs/DevourerofGods/CosmicGuardianBody.png deleted file mode 100644 index 63c6a4c27c..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianBody.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianBodyGlow.png b/NPCs/DevourerofGods/CosmicGuardianBodyGlow.png deleted file mode 100644 index d5599ff746..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianBodyGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianHead.cs b/NPCs/DevourerofGods/CosmicGuardianHead.cs deleted file mode 100644 index d85e147d7e..0000000000 --- a/NPCs/DevourerofGods/CosmicGuardianHead.cs +++ /dev/null @@ -1,456 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - [LongDistanceNetSync] - public class CosmicGuardianHead : ModNPC - { - private bool tail = false; - private const int minLength = 10; - private const int maxLength = 11; - private int invinceTime = 180; - - public static Asset GlowTexture; - public static Asset GlowTexture2; - - public override void SetStaticDefaults() - { - NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - Scale = 0.75f, - PortraitScale = 0.75f, - PortraitPositionXOverride = 40, - PortraitPositionYOverride = 40 - }; - value.Position.X += 62f; - value.Position.Y += 35f; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - GlowTexture2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); - } - } - - public override void SetDefaults() - { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); - NPC.width = 64; - NPC.height = 76; - NPC.defense = 40; - NPC.lifeMax = 50000; - NPC.aiStyle = -1; - AIType = -1; - NPC.knockBackResist = 0f; - NPC.Opacity = 0f; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - int associatedNPCType = ModContent.NPCType(); - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[associatedNPCType], quickUnlock: true); - - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.CosmicGuardian") - }); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(NPC.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - NPC.dontTakeDamage = reader.ReadBoolean(); - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - NPC.damage = 0; - NPC.dontTakeDamage = true; - } - else - { - NPC.damage = NPC.defDamage; - NPC.dontTakeDamage = false; - } - - Vector2 vector = NPC.Center; - - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tail && NPC.ai[0] == 0f) - { - int Previous = NPC.whoAmI; - for (int segmentSpawn = 0; segmentSpawn < maxLength; segmentSpawn++) - { - int segment; - if (segmentSpawn >= 0 && segmentSpawn < minLength) - { - segment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } - else - { - segment = 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[segment].realLife = NPC.whoAmI; - Main.npc[segment].ai[2] = NPC.whoAmI; - Main.npc[segment].ai[1] = Previous; - Main.npc[Previous].ai[0] = segment; - NPC.netUpdate = true; - Previous = segment; - } - tail = true; - } - if (!NPC.active && Main.dedServ) - { - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - } - - if (CalamityGlobalNPC.DoGHead < 0 || !Main.npc[CalamityGlobalNPC.DoGHead].active) - { - NPC.velocity.Y -= 4f; - - if ((double)NPC.position.Y < Main.topWorld + 16f) - { - 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].active = false; - } - } - return; - } - - Player player = Main.player[Main.npc[CalamityGlobalNPC.DoGHead].target]; - - bool increaseSpeed = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance350Tiles; - - NPC.Opacity = Main.npc[CalamityGlobalNPC.DoGHead].Opacity; - - // Fly up and despawn if DoG enters phase 2 and isn't in the final Cosmic Guardian spawn phase. - bool flyAwayAndDespawn = (Main.npc[CalamityGlobalNPC.DoGHead].life / (float)Main.npc[CalamityGlobalNPC.DoGHead].lifeMax < 0.6f && Main.npc[CalamityGlobalNPC.DoGHead].life / (float)Main.npc[CalamityGlobalNPC.DoGHead].lifeMax > 0.2f) || Main.npc[CalamityGlobalNPC.DoGHead].life <= 1; - if (flyAwayAndDespawn) - { - // Prevents them from doing damage while despawning. - NPC.Opacity = 0.99f; - - NPC.velocity.Y -= 4f; - - if ((double)NPC.position.Y < Main.topWorld + 16f) - { - 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].active = false; - } - } - return; - } - - Vector2 segmentDirection = NPC.Center; - float dogHeadX = Main.npc[CalamityGlobalNPC.DoGHead].position.X + (Main.npc[CalamityGlobalNPC.DoGHead].width / 2); - float dogHeadY = Main.npc[CalamityGlobalNPC.DoGHead].position.Y + (Main.npc[CalamityGlobalNPC.DoGHead].height / 2); - float segmentVelocity = BossRushEvent.BossRushActive ? 30f : CalamityWorld.revenge ? 25f : 23f; - float velocityMult = BossRushEvent.BossRushActive ? 0.9f : CalamityWorld.revenge ? 0.75f : 0.23f; - float maxDistanceFromDoGHead = 160f; - - if (increaseSpeedMore) - velocityMult *= 4f; - else if (increaseSpeed) - velocityMult *= 2f; - - foreach (NPC n in Main.ActiveNPCs) - { - if ((n.type == NPC.type || n.type == ModContent.NPCType()) && n.whoAmI != NPC.whoAmI) - { - Vector2 distFromHead = n.Center - NPC.Center; - if (distFromHead.Length() < maxDistanceFromDoGHead) - { - distFromHead.Normalize(); - distFromHead *= maxDistanceFromDoGHead; - dogHeadX -= distFromHead.X; - dogHeadY -= distFromHead.Y; - } - } - } - - float higherMaxDistance = segmentVelocity * 1.3f; - float lowerMaxDistance = segmentVelocity * 0.7f; - float npcSpeed = NPC.velocity.Length(); - if (npcSpeed > 0f) - { - if (npcSpeed > higherMaxDistance) - { - NPC.velocity.Normalize(); - NPC.velocity *= higherMaxDistance; - } - else if (npcSpeed < lowerMaxDistance) - { - NPC.velocity.Normalize(); - NPC.velocity *= lowerMaxDistance; - } - } - - dogHeadX = (int)(dogHeadX / 16f) * 16; - dogHeadY = (int)(dogHeadY / 16f) * 16; - segmentDirection.X = (int)(segmentDirection.X / 16f) * 16; - segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; - dogHeadX -= segmentDirection.X; - dogHeadY -= segmentDirection.Y; - float targetDistance = (float)Math.Sqrt(dogHeadX * dogHeadX + dogHeadY * dogHeadY); - float absoluteDoGX = Math.Abs(dogHeadX); - float absoluteDoGY = Math.Abs(dogHeadY); - float timeToReachTarget = segmentVelocity / targetDistance; - dogHeadX *= timeToReachTarget; - dogHeadY *= timeToReachTarget; - if ((NPC.velocity.X > 0f && dogHeadX > 0f) || (NPC.velocity.X < 0f && dogHeadX < 0f) || (NPC.velocity.Y > 0f && dogHeadY > 0f) || (NPC.velocity.Y < 0f && dogHeadY < 0f)) - { - if (NPC.velocity.X < dogHeadX) - { - NPC.velocity.X = NPC.velocity.X + velocityMult; - } - else - { - if (NPC.velocity.X > dogHeadX) - { - NPC.velocity.X = NPC.velocity.X - velocityMult; - } - } - if (NPC.velocity.Y < dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult; - } - else - { - if (NPC.velocity.Y > dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult; - } - } - if (Math.Abs(dogHeadY) < segmentVelocity * 0.2 && ((NPC.velocity.X > 0f && dogHeadX < 0f) || (NPC.velocity.X < 0f && dogHeadX > 0f))) - { - if (NPC.velocity.Y > 0f) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult * 2f; - } - else - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult * 2f; - } - } - if (Math.Abs(dogHeadX) < segmentVelocity * 0.2 && ((NPC.velocity.Y > 0f && dogHeadY < 0f) || (NPC.velocity.Y < 0f && dogHeadY > 0f))) - { - if (NPC.velocity.X > 0f) - { - NPC.velocity.X = NPC.velocity.X + velocityMult * 2f; //changed from 2 - } - else - { - NPC.velocity.X = NPC.velocity.X - velocityMult * 2f; //changed from 2 - } - } - } - else - { - if (absoluteDoGX > absoluteDoGY) - { - if (NPC.velocity.X < dogHeadX) - { - NPC.velocity.X = NPC.velocity.X + velocityMult * 1.1f; //changed from 1.1 - } - else if (NPC.velocity.X > dogHeadX) - { - NPC.velocity.X = NPC.velocity.X - velocityMult * 1.1f; //changed from 1.1 - } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) - { - if (NPC.velocity.Y > 0f) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult; - } - else - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult; - } - } - } - else - { - if (NPC.velocity.Y < dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult * 1.1f; - } - else if (NPC.velocity.Y > dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult * 1.1f; - } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) - { - if (NPC.velocity.X > 0f) - { - NPC.velocity.X = NPC.velocity.X + velocityMult; - } - else - { - NPC.velocity.X = NPC.velocity.X - velocityMult; - } - } - } - } - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } - - NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - if (NPC.IsABestiaryIconDummy) - NPC.Opacity = 1f; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / 2)); - - - if (NPC.IsABestiaryIconDummy) - { - return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, texture2D15, TextureAssets.Npc[ModContent.NPCType()].Value, 8, 26, 0.2f, new Vector2(-10, 0), 4, 5); - } - - Vector2 distFromHead3 = NPC.Center - screenPos; - distFromHead3 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - distFromHead3 += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture2.Value; - glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override void OnKill() - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = ImmunityCooldownID.Bosses; - return NPC.Opacity >= 1f && invinceTime <= 0; - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 1.5f; - return null; - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life <= 0) - { - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("DoT").Type, 1f); - } - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; - NPC.position.X = NPC.position.X - (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 15; i++) - { - int cosmiliteDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[cosmiliteDust].scale = 0.5f; - Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 30; j++) - { - int cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[cosmiliteDust2].noGravity = true; - Main.dust[cosmiliteDust2].velocity *= 5f; - cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust2].velocity *= 2f; - } - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); - } - } -} diff --git a/NPCs/DevourerofGods/CosmicGuardianHead.png b/NPCs/DevourerofGods/CosmicGuardianHead.png deleted file mode 100644 index 5a2e86f44a..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianHead.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianHeadGlow.png b/NPCs/DevourerofGods/CosmicGuardianHeadGlow.png deleted file mode 100644 index 54237b2004..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianHeadGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianHeadGlow2.png b/NPCs/DevourerofGods/CosmicGuardianHeadGlow2.png deleted file mode 100644 index 06614ea355..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianHeadGlow2.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianTail.cs b/NPCs/DevourerofGods/CosmicGuardianTail.cs deleted file mode 100644 index 7bcc59229f..0000000000 --- a/NPCs/DevourerofGods/CosmicGuardianTail.cs +++ /dev/null @@ -1,236 +0,0 @@ -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -namespace CalamityMod.NPCs.DevourerofGods -{ - [LongDistanceNetSync(SyncWith = typeof(CosmicGuardianHead))] - public class CosmicGuardianTail : ModNPC - { - public int invinceTime = 180; - public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.CosmicGuardianHead.DisplayName"); - - public static Asset GlowTexture; - - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } - } - - public override void SetDefaults() - { - NPC.GetNPCDamage(); - NPC.width = 30; - NPC.height = 50; - NPC.defense = 70; - NPC.lifeMax = 50000; - NPC.aiStyle = -1; - AIType = -1; - NPC.knockBackResist = 0f; - NPC.Opacity = 0f; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - NPC.dontCountMe = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(NPC.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - NPC.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - NPC.damage = 0; - NPC.dontTakeDamage = true; - } - else - { - NPC.damage = NPC.defDamage; - NPC.dontTakeDamage = false; - } - - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); - if (!shouldDespawn) - { - if (NPC.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)NPC.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - NPC.life = 0; - NPC.HitEffect(0, 10.0); - NPC.checkDead(); - NPC.active = false; - } - - NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; - - Vector2 segmentPosition = NPC.Center; - float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - targetX = (int)(targetX / 16f) * 16; - targetY = (int)(targetY / 16f) * 16; - segmentPosition.X = (int)(segmentPosition.X / 16f) * 16; - segmentPosition.Y = (int)(segmentPosition.Y / 16f) * 16; - targetX -= segmentPosition.X; - targetY -= segmentPosition.Y; - float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) - { - try - { - segmentPosition = NPC.Center; - targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; - targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; - } - catch - { - } - NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + 1.57f; - targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - int segmentWidth = NPC.width; - targetDistance = (targetDistance - segmentWidth) / targetDistance; - targetX *= targetDistance; - targetY *= targetDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + targetX; - NPC.position.Y = NPC.position.Y + targetY; - } - - // Calculate contact damage based on velocity - float segmentVelocity = BossRushEvent.BossRushActive ? 30f : CalamityWorld.revenge ? 25f : 23f; - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / 2)); - - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = ImmunityCooldownID.Bosses; - return NPC.Opacity >= 1f && invinceTime <= 0; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life <= 0) - { - if (!Main.dedServ) - { - float randomSpread = Main.rand.Next(-200, 201) / 100f; - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT3").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT4").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT5").Type, 1f); - } - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; - NPC.position.X = NPC.position.X - (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 10; i++) - { - int cosmiliteDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[cosmiliteDust].scale = 0.5f; - Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 20; j++) - { - int cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[cosmiliteDust2].noGravity = true; - Main.dust[cosmiliteDust2].velocity *= 5f; - cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust2].velocity *= 2f; - } - } - } - - public override bool CheckActive() - { - return false; - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); - } - } -} diff --git a/NPCs/DevourerofGods/CosmicGuardianTail.png b/NPCs/DevourerofGods/CosmicGuardianTail.png deleted file mode 100644 index e570d41a53..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianTail.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianTailGlow.png b/NPCs/DevourerofGods/CosmicGuardianTailGlow.png deleted file mode 100644 index 250a284fe7..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianTailGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index 5404aa006f..c6b3218cf8 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -1,17 +1,13 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using System.IO; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee.Yoyos; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.GameContent; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -27,7 +23,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void Load() { - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsBody_P2_Head_Boss"; phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); } @@ -41,9 +37,9 @@ namespace CalamityMod.NPCs.DevourerofGods public int SegmentIndex; public static Asset Texture_Glow; - public static Asset Phase2Texture; - public static Asset Phase2Texture_Glow; - public static Asset Phase2Texture_Glow2; + public static Asset TextureP2; + public static Asset TextureP2_Glow_Purple; + public static Asset TextureP2_Glow_Cyan; public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.DevourerofGodsHead.DisplayName"); @@ -52,17 +48,16 @@ namespace CalamityMod.NPCs.DevourerofGods this.HideFromBestiary(); if (!Main.dedServ) { - Texture_Glow = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - Phase2Texture = ModContent.Request(Texture + "S", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow = ModContent.Request(Texture + "SGlow", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow2 = ModContent.Request(Texture + "SGlow2", AssetRequestMode.AsyncLoad); + Texture_Glow = ModContent.Request(Texture + "_Glow", AssetRequestMode.AsyncLoad); + TextureP2 = ModContent.Request(Texture + "_P2", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Purple = ModContent.Request(Texture + "_P2_Glow_Purple", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Cyan = ModContent.Request(Texture + "_P2_Glow_Cyan", AssetRequestMode.AsyncLoad); } } public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 120; // 240 NPC.npcSlots = 5f; NPC.width = 56; NPC.height = 56; @@ -74,7 +69,7 @@ namespace CalamityMod.NPCs.DevourerofGods global.unbreakableDR = true; NPC.chaseable = false; } - NPC.LifeMaxNERB(887500, 1065000, 1500000); // Phase 1 is 355000, Phase 2 is 532500 + NPC.LifeMaxNERB(760000, 910000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -89,18 +84,15 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.dontCountMe = true; - if (Main.getGoodWorld) + if (Main.zenithWorld) NPC.scale *= 1.5f; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void BossHeadSlot(ref int index) { NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; DevourerofGodsHead modNPC = head?.ModNPC() ?? null; - if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) + if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started || NPC.Opacity < 0.1f) { index = -1; return; @@ -145,30 +137,27 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.frame = frame; } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - if (NPC.life > Main.npc[(int)NPC.ai[1]].life) - NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.life = Main.npc[(int)NPC.ai[2]].life; + NPC.lifeMax = Main.npc[(int)NPC.ai[2]].lifeMax;NPC.life = NPC.lifeMax; // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; + float lifeRatio = Main.npc[(int)NPC.ai[2]].life / (float)Main.npc[(int)NPC.ai[2]].lifeMax; - bool phase2 = lifeRatio < 0.6f; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool phase2 = lifeRatio < 0.65f; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (phase2) + if (phase2 && !phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60) { + phase2Started = true; // Once before DoG spawns, set new size @@ -217,67 +206,6 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.active = false; } - // Lasers - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!NPC.dontTakeDamage && NPC.Opacity >= 1f && invinceTime <= 0) - { - if (phase2) - { - // Fire lasers from every 15th (20th in normal mode) body segment if not in laser wall phase - float laserWallPhaseGateValue = DevourerofGodsHead.LaserWallCooldown - (bossRush ? 360f : death ? 180f : 0f); - if (Main.npc[(int)NPC.ai[2]].Calamity().newAI[3] < laserWallPhaseGateValue - 180f) - { - NPC.localAI[0] += 1f; - float laserGateValue = bossRush ? 156f : death ? 180f : 192f; - if (Main.getGoodWorld) - laserGateValue *= 0.5f; - - if (NPC.localAI[0] >= laserGateValue && NPC.ai[0] % (expertMode ? 15f : 20f) == 0f) - { - NPC.localAI[0] = 0f; - if (!AnyTeleportRifts()) - { - NPC.TargetClosest(); - SoundEngine.PlaySound(SoundID.Item12, player.Center); - float maxProjectileVelocity = bossRush ? 24f : death ? 20f : revenge ? 18.25f : expertMode ? 17.5f : 16f; - float minProjectileVelocity = maxProjectileVelocity * LaserVelocityMultiplierMin; - float projectileVelocity = MathHelper.Clamp(Vector2.Distance(player.Center, NPC.Center) * LaserVelocityDistanceMultiplier, minProjectileVelocity, maxProjectileVelocity); - Vector2 velocityVector = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, damage, 0f, Main.myPlayer); - } - } - } - } - else - { - // Fire lasers from every 20th (25th in normal mode) body segment if not in laser barrage phase - float laserBarrageGateValue = bossRush ? 1080f : death ? 1320f : 1440f; - float laserBarrageShootGateValue = bossRush ? 160f : 240f; - float laserBarragePhaseGateValue = laserBarrageGateValue - laserBarrageShootGateValue * 1.5f; - if (Main.npc[(int)NPC.ai[2]].Calamity().newAI[1] < laserBarragePhaseGateValue) - { - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= laserBarrageGateValue * (Main.getGoodWorld ? 0.1f : 0.2f) && NPC.ai[0] % (expertMode ? 20f : 25f) == 0f) - { - NPC.TargetClosest(); - SoundEngine.PlaySound(SoundID.Item12, player.Center); - NPC.localAI[0] = 0f; - float maxProjectileVelocity = bossRush ? 22f : death ? 18f : revenge ? 16.25f : expertMode ? 15.5f : 14f; - float minProjectileVelocity = maxProjectileVelocity * LaserVelocityMultiplierMin; - float projectileVelocity = MathHelper.Clamp(Vector2.Distance(player.Center, NPC.Center) * LaserVelocityDistanceMultiplier, minProjectileVelocity, maxProjectileVelocity); - Vector2 velocityVector = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, damage, 0f, Main.myPlayer); - } - } - } - } - } - if (Main.npc[(int)NPC.ai[1]].Opacity >= 0.5f && (!setOpacity || (Main.npc[(int)NPC.ai[2]].localAI[2] <= 60f && Main.npc[(int)NPC.ai[2]].localAI[2] > 0f))) { NPC.Opacity += 0.165f; @@ -332,40 +260,18 @@ namespace CalamityMod.NPCs.DevourerofGods // Decide segment offset stuff. NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; - NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * NPC.width; + NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * (phase2Started ? 80 : NPC.width ); NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); // Velocity variables - float segmentVelocity = bossRush ? 19f : death ? 17.5f : 16f; + float segmentVelocity = death ? 17.5f : 16f; if (expertMode) segmentVelocity += 4f * (1f - lifeRatio); if (Main.getGoodWorld) segmentVelocity *= 1.1f; - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } - private bool AnyTeleportRifts() - { - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.type == ModContent.ProjectileType()) - return true; - } - return false; - } + Vector2 noiseOffset = Vector2.Zero; public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { @@ -374,14 +280,30 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.npc[NPC.realLife].type != ModContent.NPCType()) return true; - float disintegrationFactor = Main.npc[NPC.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) + bool shouldUseShader = CalamityDrawParameterNPC.DoGDeathAnimationTimer != 0; + SpriteBatchSnapshot snap = new(spriteBatch); + + if (shouldUseShader) { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage1("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); + if (noiseOffset == Vector2.zeroVector) + noiseOffset = NPC.Center; + + Main.spriteBatch.End(out snap); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + + MiscShaderData dissolveShader = GameShaders.Misc["CalamityMod:Dissolve"]; + Texture2D dissolveTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + + dissolveShader.Shader.Parameters["noiseScale"].SetValue(0.25f); + dissolveShader.Shader.Parameters["dissolveIntensity"].SetValue(CalamityDrawParameterNPC.DoGDeathAnimationTimer / 600f); + dissolveShader.Shader.Parameters["sampleOffset"].SetValue(noiseOffset * 0.5f); + dissolveShader.Shader.Parameters["transitionColor"].SetValue(DevourerofGodsHead.SpecialMoveColor.ToVector4()); + dissolveShader.Shader.Parameters["transitionOffset"].SetValue(0.05f); + + Main.instance.GraphicsDevice.Textures[1] = dissolveTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + dissolveShader.Apply(); } SpriteEffects spriteEffects = SpriteEffects.None; @@ -389,7 +311,7 @@ namespace CalamityMod.NPCs.DevourerofGods spriteEffects = SpriteEffects.FlipHorizontally; bool useOtherTextures = phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60f; - Texture2D texture2D15 = useOtherTextures ? Phase2Texture.Value : TextureAssets.Npc[Type].Value; + Texture2D texture2D15 = useOtherTextures ? TextureP2.Value : TextureAssets.Npc[Type].Value; Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); Vector2 drawLocation = NPC.Center - screenPos; @@ -397,30 +319,35 @@ namespace CalamityMod.NPCs.DevourerofGods drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (!NPC.dontTakeDamage) + if (!Main.npc[(int)NPC.ai[2]].ModNPC().isInPassiveState && NPC.Opacity > 0.25f && useOtherTextures) { - if (useOtherTextures) - { - texture2D15 = Phase2Texture_Glow.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + texture2D15 = TextureP2_Glow_Purple.Value; + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - - texture2D15 = useOtherTextures ? Phase2Texture_Glow2.Value : Texture_Glow.Value; + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + if ((!Main.npc[(int)NPC.ai[2]].ModNPC().isInAgressiveState || !useOtherTextures) && NPC.Opacity > 0.25f) + { + texture2D15 = useOtherTextures ? TextureP2_Glow_Cyan.Value : Texture_Glow.Value; Color glowmaskColor2 = Color.Lerp(Color.White, Color.Cyan, 0.5f); spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor2, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); + if (shouldUseShader) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(snap); + } return false; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { + + if (Main.npc[(int)NPC.ai[2]].dontTakeDamage) + return false; cooldownSlot = ImmunityCooldownID.Bosses; Rectangle targetHitbox = target.Hitbox; @@ -448,15 +375,10 @@ namespace CalamityMod.NPCs.DevourerofGods { // viable???, done here since it's conditional if (Main.zenithWorld && projectile.type == ModContent.ProjectileType()) - { modifiers.SourceDamage *= 40f; - } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; public override bool CheckDead() { @@ -517,16 +439,6 @@ namespace CalamityMod.NPCs.DevourerofGods public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - { - target.AddBuff(ModContent.BuffType(), 160, true); - target.AddBuff(ModContent.BuffType(), 480, true); - } } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyGlow.png b/NPCs/DevourerofGods/DevourerofGodsBody_Glow.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodyGlow.png rename to NPCs/DevourerofGods/DevourerofGodsBody_Glow.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyS.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodyS.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodySGlow2.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodySGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodySGlow.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodySGlow.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2_Head_Boss.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2_Head_Boss.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index d377a711a7..6526f0f174 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -1,20 +1,16 @@ using System; using System.Collections.Generic; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Placeables.FurnitureAbyss; using CalamityMod.Items.Placeables.FurnitureCosmilite; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -24,22 +20,25 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee.Yoyos; -using CalamityMod.Sounds; +using CalamityMod.UI.DialogueDisplay; +using CalamityMod.UI.DialogueDisplay.DisplayEffects; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.Events; using Terraria.GameContent.ItemDropRules; using Terraria.Graphics.Shaders; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.DevourerofGods @@ -47,20 +46,30 @@ namespace CalamityMod.NPCs.DevourerofGods [LongDistanceNetSync] public class DevourerofGodsHead : ModNPC { + public static Color SpecialMoveColor => Color.Lerp(Color.Fuchsia, Color.Cyan, MathHelper.SmoothStep(0, 1, (MathF.Sin(Main.GlobalTimeWrappedHourly * 2) + 1) * 0.5f)); + public static int phase1IconIndex; public static int phase2IconIndex; - public static Asset Texture_Glow; - public static Asset Texture_Glow2; - public static Asset Phase2Texture; - public static Asset Phase2Texture_Glow; - public static Asset Phase2Texture_Glow2; + public static Asset Texture_Glow_Purple; + public static Asset Texture_Glow_Cyan; + public static Asset TextureP2; + public static Asset TextureP2_Glow_Purple; + public static Asset TextureP2_Glow_Cyan; + + public static Asset JawTexture; + public static Asset JawTexture_Glow; + public static Asset JawTextureP2; + public static Asset JawTextureP2_Glow; + public static Asset GodSlayerDashJawTexture; + + public static Asset TextureP2_Full; public override void Load() { string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss"; - + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss"; + phase1IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); } @@ -70,22 +79,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Phase 1 variables - // Enums - private enum LaserWallType - { - DiagonalRight = 0, - DiagonalLeft = 1, - DiagonalHorizontal = 2, - DiagonalCross = 3 - } - // Laser spread variables - private const int shotSpacingMax = 1440; - private int shotSpacing = shotSpacingMax; private const int totalShots = 10; - private const int spacingVar = shotSpacingMax / totalShots * 2; - private int laserWallType = 0; - private const float laserWallSpacingOffset = 16f; // Continuously reset variables public bool AttemptingToEnterPortal = false; @@ -113,52 +108,104 @@ namespace CalamityMod.NPCs.DevourerofGods FireLaserWalls = 1, End = 2 } - private enum LaserWallType_Phase2 - { - Normal = 0, - Offset = 1, - DiagonalHorizontal = 2, - MultiLayered = 3, - DiagonalVertical = 4 - } // Laser wall variables - private const int shotSpacingMax_Phase2 = 1440; - private int[] shotSpacing_Phase2 = new int[4] { shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2 }; - private const int spacingVar_Phase2 = 120; - private const int totalShots_Phase2 = 24; - private const int totalDiagonalShots = 6; - private const int diagonalSpacingVar = shotSpacingMax_Phase2 / totalDiagonalShots * 2; - private int laserWallType_Phase2 = 0; public int laserWallPhase = 0; // Phase variables private const int idleCounterMax = 300; private int idleCounter = idleCounterMax; - public const float LaserWallCooldown = 1200f; - private int postTeleportTimer = 0; - private int teleportTimer = -1; - private const int TimeBeforeTeleport_Death = 120; - private const int TimeBeforeTeleport_Revengeance = 140; + public const float LaserWallCooldown = 1800f; + public int postTeleportTimer = 0; + public int teleportTimer = -1; + private const int TimeBeforeTeleport_Death = 150; + private const int TimeBeforeTeleport_Revengeance = 150; private const int TimeBeforeTeleport_Expert = 160; private const int TimeBeforeTeleport_Normal = 180; private bool spawnedGuardians3 = false; - private const float AlphaGateValue = 1060f; + private const float AlphaGateValue = 1660f; public const float SkyColorTransitionTime = 90f; + public Vector2 PortalEntryLocation = Vector2.Zero; + public bool doTpFX = true; + public int dashes = 0; // Death animation variables public bool Dying; public int DeathAnimationTimer; public int DestroyedSegmentCount; + // Jaw related variables. + public float JawRotation; + public float JawChompDownProgress; + public float GodSlayerDashJawFadeProgress; + public float GodSlayerDashJawTimer; + public bool ShouldSpawnChompVFX; + // Sounds public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/DevourerSpawn"); public static readonly SoundStyle AttackSound = new("CalamityMod/Sounds/Custom/DevourerAttack"); + public static readonly SoundStyle RiftOpenSound = new("CalamityMod/Sounds/Custom/DevourerRiftOpen"); + public static readonly SoundStyle RiftBuildingSound = new("CalamityMod/Sounds/Custom/DevourerRiftBuilding"); + public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/NPCHit/OtherworldlyHit"); public static readonly SoundStyle DeathAnimationSound = new("CalamityMod/Sounds/NPCKilled/DevourerDeath"); public static readonly SoundStyle DeathExplosionSound = new("CalamityMod/Sounds/NPCKilled/DevourerDeathImpact"); public static readonly SoundStyle DeathSegmentSound = new("CalamityMod/Sounds/NPCKilled/DevourerSegmentBreak", 4); public float extrapitch = 0; + public bool isInPassiveState + { + get + { + if (Phase2Started && NPC.ai[3] == 1) + return true; + if (!Phase2Started && NPC.ai[3] == 0) + return true; + return false; + } + } + + public bool isInAgressiveState + { + get + { + if (Phase2Started && NPC.ai[3] == 0) + return true; + if (!Phase2Started && NPC.ai[3] == 1) + return true; + return false; + } + } + + public bool isInLaserWallState + { + get + { + if (NPC.ai[3] == 2) + return true; + return false; + } + } + + public bool isInPostWallState + { + get + { + if (NPC.ai[3] > 2) + return true; + return false; + } + } + /// + /// This gets the player's center, adjusted for predictiveness on FTW + /// + /// + Vector2 AdjustedPlayerCenter(float predictiveness = 0) + { + Player player = Main.player[NPC.target]; + if (!(Main.getGoodWorld)) + return player.Center; + return player.Center + player.velocity * predictiveness; + } public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); @@ -175,11 +222,20 @@ namespace CalamityMod.NPCs.DevourerofGods NPCID.Sets.MPAllowedEnemies[Type] = true; if (!Main.dedServ) { - Texture_Glow = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - Texture_Glow2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); - Phase2Texture = ModContent.Request(Texture + "S", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow = ModContent.Request(Texture + "SGlow", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow2 = ModContent.Request(Texture + "SGlow2", AssetRequestMode.AsyncLoad); + Texture_Glow_Purple = ModContent.Request(Texture + "_Glow_Purple", AssetRequestMode.AsyncLoad); + Texture_Glow_Cyan = ModContent.Request(Texture + "_Glow_Cyan", AssetRequestMode.AsyncLoad); + TextureP2 = ModContent.Request(Texture + "_Jawless_P2", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Purple = ModContent.Request(Texture + "_Jawless_P2_Glow_Purple", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Cyan = ModContent.Request(Texture + "_Jawless_P2_Glow_Cyan", AssetRequestMode.AsyncLoad); + + JawTexture = ModContent.Request(Texture + "_Jaw", AssetRequestMode.AsyncLoad); + JawTexture_Glow = ModContent.Request(Texture + "_Jaw_Glow", AssetRequestMode.AsyncLoad); + JawTextureP2 = ModContent.Request(Texture + "_Jaw_P2", AssetRequestMode.AsyncLoad); + JawTextureP2_Glow = ModContent.Request(Texture + "_Jaw_P2_Glow", AssetRequestMode.AsyncLoad); + GodSlayerDashJawTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/GodSlayerDashJaw", AssetRequestMode.AsyncLoad); + + // For bestiary. + TextureP2_Full = ModContent.Request(Texture + "_P2", AssetRequestMode.AsyncLoad); } } @@ -191,38 +247,50 @@ namespace CalamityMod.NPCs.DevourerofGods }); } + public static int LaserWallDamage = 75; // 300 + public static int LaserWallMiddleBeamDamage = 85; // 340 + public static int FireballDamage = 60; // 240 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 250; // 500 NPC.npcSlots = 5f; NPC.width = 104; NPC.height = 104; NPC.defense = 50; - NPC.LifeMaxNERB(887500, 1065000, 1500000); // Phase 1 is 355000, Phase 2 is 532500 - NPC.takenDamageMultiplier = 1.1f; + NPC.LifeMaxNERB(750000, 900000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; NPC.boss = true; - NPC.value = Item.buyPrice(2, 0, 0, 0); + NPC.value = Item.buyPrice(platinum: 1, gold: 50); NPC.Opacity = 0f; NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; NPC.DeathSound = SoundID.NPCDeath14; + NPC.ai[3] = 1; NPC.netAlways = true; - - if (Main.getGoodWorld) + if (Main.rand.NextBool()) + NPC.velocity = new Vector2(-60, 0); + else + NPC.velocity = new Vector2(60, 0); + if (Main.zenithWorld) NPC.scale *= 1.5f; + if (Main.getGoodWorld) + NPC.takenDamageMultiplier = 2; - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); + + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToSickness = false; + + NPC.life = NPC.lifeMax; } public override void BossHeadSlot(ref int index) { - if (Phase2Started && (NPC.localAI[2] > 60f || AwaitingPhase2Teleport)) + if ((Phase2Started && (NPC.localAI[2] > 60f || AwaitingPhase2Teleport)) || NPC.Opacity < 0.1f) index = -1; else if (Phase2Started && !AwaitingPhase2Teleport) index = phase2IconIndex; @@ -236,6 +304,15 @@ namespace CalamityMod.NPCs.DevourerofGods rotation = NPC.rotation; } + public override void OnSpawn(IEntitySource source) + { + string key = "Mods.CalamityMod.Status.Boss.DoGSpawn"; + Color messageColor = Color.Cyan; + CalamityUtils.BroadcastLocalizedText(key, messageColor); + + DialogueDisplaySystem.StartDialogue("Mods.CalamityMod.DevourerOfGods.Phases", NPC, 0, 120, false, new BossText()); + } + public override void SendExtraAI(BinaryWriter writer) { bool wasDyingBefore = Dying; @@ -252,8 +329,6 @@ namespace CalamityMod.NPCs.DevourerofGods writer.Write(hasCreatedPhase1Portal); writer.Write(AwaitingPhase2Teleport); writer.Write(spawnDoGCountdown); - writer.Write(shotSpacing); - writer.Write(laserWallType); writer.Write(PortalIndex); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); @@ -261,13 +336,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Phase 2 syncs writer.Write(NPC.localAI[2]); writer.Write(NPC.localAI[3]); - writer.Write(shotSpacing_Phase2[0]); - writer.Write(shotSpacing_Phase2[1]); - writer.Write(shotSpacing_Phase2[2]); - writer.Write(shotSpacing_Phase2[3]); writer.Write(idleCounter); writer.Write(laserWallPhase); - writer.Write(laserWallType_Phase2); writer.Write(postTeleportTimer); writer.Write(teleportTimer); writer.Write(NPC.Opacity); @@ -277,6 +347,13 @@ namespace CalamityMod.NPCs.DevourerofGods writer.Write(DeathAnimationTimer); writer.Write(DestroyedSegmentCount); + // Jaw animation syncs + writer.Write(JawRotation); + writer.Write(JawChompDownProgress); + writer.Write(GodSlayerDashJawFadeProgress); + writer.Write(GodSlayerDashJawTimer); + writer.Write(ShouldSpawnChompVFX); + // Frame syncs writer.Write(NPC.frame.X); writer.Write(NPC.frame.Y); @@ -305,8 +382,6 @@ namespace CalamityMod.NPCs.DevourerofGods hasCreatedPhase1Portal = reader.ReadBoolean(); AwaitingPhase2Teleport = reader.ReadBoolean(); spawnDoGCountdown = reader.ReadInt32(); - shotSpacing = reader.ReadInt32(); - laserWallType = reader.ReadInt32(); PortalIndex = reader.ReadInt32(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); @@ -314,13 +389,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Phase 2 syncs NPC.localAI[2] = reader.ReadSingle(); NPC.localAI[3] = reader.ReadSingle(); - shotSpacing_Phase2[0] = reader.ReadInt32(); - shotSpacing_Phase2[1] = reader.ReadInt32(); - shotSpacing_Phase2[2] = reader.ReadInt32(); - shotSpacing_Phase2[3] = reader.ReadInt32(); idleCounter = reader.ReadInt32(); laserWallPhase = reader.ReadInt32(); - laserWallType_Phase2 = reader.ReadInt32(); postTeleportTimer = reader.ReadInt32(); teleportTimer = reader.ReadInt32(); NPC.Opacity = reader.ReadSingle(); @@ -330,6 +400,13 @@ namespace CalamityMod.NPCs.DevourerofGods DeathAnimationTimer = reader.ReadInt32(); DestroyedSegmentCount = reader.ReadInt32(); + // Jaw animation syncs + JawRotation = reader.ReadSingle(); + JawChompDownProgress = reader.ReadSingle(); + GodSlayerDashJawFadeProgress = reader.ReadSingle(); + GodSlayerDashJawTimer = reader.ReadSingle(); + ShouldSpawnChompVFX = reader.ReadBoolean(); + // Misc syncs extrapitch = reader.ReadSingle(); @@ -341,6 +418,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void AI() { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // whoAmI variable @@ -359,103 +437,116 @@ namespace CalamityMod.NPCs.DevourerofGods Player player = Main.player[NPC.target]; + // Use the shimmer background effect if fancy background visuals are disabled. + if (DeathAnimationTimer < 435 && !CalamityClientConfig.Instance.FancyBackgroundVisuals) + { + player.shimmerMonolithShader = true; + if (Main.shimmerDarken > 0.75f) + Main.shimmerDarken = 0.75f; + } + // Variables - bool flyUpDuringLaserWalls = laserWallPhase == (int)LaserWallPhase.FireLaserWalls || (laserWallPhase == (int)LaserWallPhase.End && teleportTimer > 0); - bool flies = NPC.ai[3] == 0f || flyUpDuringLaserWalls; - Vector2 destination = flyUpDuringLaserWalls ? (player.Center - Vector2.UnitY * 480f) : player.Center; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool flies = NPC.ai[3] == 0f; + + if (Main.getGoodWorld) + flies = true; + Vector2 destination = AdjustedPlayerCenter(2); + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phase 1 phases - bool phase2 = lifeRatio < 0.9f; + bool phase2 = lifeRatio < 1f; bool phase3 = lifeRatio < 0.75f; - bool bigDaddyPhase2 = lifeRatio < 0.6f; + bool bigDaddyPhase2 = lifeRatio < 0.65f; // Phase 2 phases - bool phase4 = lifeRatio < 0.5f; - bool phase5 = lifeRatio < 0.4f; - bool phase6 = lifeRatio < 0.2f; - bool phase7 = lifeRatio < 0.15f; - - // Black sky timer - if (!death) - { - if (phase7) - { - if (NPC.localAI[3] < SkyColorTransitionTime) - NPC.localAI[3] += 1f; - } - else if (bigDaddyPhase2) - { - if (NPC.localAI[3] > 0f) - NPC.localAI[3] -= 1f; - } - } + bool phase4 = lifeRatio < 0.65f; + bool phase5 = lifeRatio < 0.5f; + bool phase6 = lifeRatio < 0.25f; // Sound pitch extrapitch = Main.zenithWorld ? 0.3f : 0f; // Velocity variables - float segmentVelocity = bossRush ? 19f : death ? 17.5f : 16f; + float segmentVelocity = death ? 17.5f : 16f; if (expertMode) - segmentVelocity += 4f * (1f - lifeRatio); + segmentVelocity += 4f * (1f - (lifeRatio * 0.75f + 0.25f)); - float speed = bossRush ? 18f : death ? 16.5f : 15f; - float turnSpeed = bossRush ? 0.36f : death ? 0.33f : 0.3f; - float homingSpeed = bossRush ? 36f : death ? 30f : 24f; - float homingTurnSpeed = bossRush ? 0.48f : death ? 0.405f : 0.33f; + float speed = death ? 16.5f : 15f; + float turnSpeed = death ? 0.33f : 0.3f; + float homingSpeed = death ? 30f : 24f; + float homingTurnSpeed = 0.405f; if (expertMode) { - speed += 3f * (1f - lifeRatio); - turnSpeed += 0.06f * (1f - lifeRatio); - homingSpeed += 12f * (1f - lifeRatio); - homingTurnSpeed += 0.15f * (1f - lifeRatio); + speed += 3f * (1f - (lifeRatio * 0.75f + 0.25f)); + turnSpeed += 0.06f * (1f - (lifeRatio * 0.75f + 0.25f)); + homingSpeed += 12f * (1f - (lifeRatio * 0.75f + 0.25f)); + homingTurnSpeed += 0.15f * (1f - (lifeRatio * 0.75f + 0.25f)); } - float groundPhaseTurnSpeed = bossRush ? 0.3f : death ? 0.24f : 0.18f; + float groundPhaseTurnSpeed = death ? 0.24f : 0.21f; if (expertMode) - groundPhaseTurnSpeed += 0.1f * (1f - lifeRatio); + groundPhaseTurnSpeed += 0.1f * (1f - (lifeRatio * 0.75f + 0.25f)); groundPhaseTurnSpeed += Vector2.Distance(destination, NPC.Center) * 0.0002f; - if (Main.getGoodWorld) - { - segmentVelocity *= 1.1f; - speed *= 1.1f; - turnSpeed *= 1.1f; - homingSpeed *= 1.1f; - homingTurnSpeed *= 1.1f; - groundPhaseTurnSpeed *= 1.1f; - } + if (Vector2.Distance(destination, NPC.Center) < 320) + groundPhaseTurnSpeed *= 0.75f; // How long it takes before swapping phases - int phaseLimit = death ? 600 : 900; - if (expertMode && NPC.ai[3] == 0f) + int phaseLimit = 900; + if (spawnedGuardians3) + phaseLimit -= 180; + + if (Main.getGoodWorld) { - phaseLimit /= 1 + (int)((death ? 4f : 5f) * (1f - lifeRatio)); - if (phaseLimit < 180) - phaseLimit = 180; + homingSpeed *= 3f; + homingTurnSpeed *= NPC.Distance(destination) / 500f; + if (NPC.Distance(destination) > 1400) + NPC.ai[1] = 1; + if (NPC.ai[1] == -1) + { + NPC.ai[1] = 0; + } + else + if (NPC.ai[1] == 1) + { + homingTurnSpeed *= 5; + float ftwDotProduct = Vector2.Dot(NPC.DirectionTo(destination), NPC.velocity.SafeNormalize(Vector2.Zero)); + if (ftwDotProduct > 0.95f) + { + NPC.ai[1] = -1; + + } + } + else + speed *= 5; + if (NPC.ai[3] == 0) + phaseLimit += 600; + else + phaseLimit -= 600; + + if (lifeRatio < 0.1f && NPC.ai[3] <= 1f) + { + SpawnTeleportLocation(player); + } } // Continuously reset certain things. AttemptingToEnterPortal = false; - // Worm variable - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; // Despawn if (player.dead) { - NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[3] = 3f; + calamityGlobalNPC.newAI[2] = -1f; NPC.velocity.Y -= 4f; @@ -476,16 +567,7 @@ namespace CalamityMod.NPCs.DevourerofGods float distanceFromTarget = Vector2.Distance(destination, NPC.Center); bool increaseSpeed = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance350Tiles; - - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - NPC.takenDamageMultiplier = MathHelper.Lerp(1f, 1.1f, damageTakenScalar); - } - else - NPC.takenDamageMultiplier = 1.1f; + bool increaseSpeedMore = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance350Tiles * 2; // Close DoG's HP bar during P2 transition and decrement the countdown. if (NPC.localAI[2] > 0f) @@ -498,8 +580,9 @@ namespace CalamityMod.NPCs.DevourerofGods float timeWhenDoGShouldTeleportDuringPhase2Countdown = 61f; if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + (death ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal)) SpawnTeleportLocation(player, true); + if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown) - Teleport(player, bossRush, death, revenge, expertMode, phase5); + Teleport(player, death, revenge, expertMode, phase5); // Just in case the projectile cap is reached and the teleport rift doesn't spawn. if (AwaitingPhase2Teleport && NPC.localAI[2] == 0f) @@ -513,7 +596,6 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Opacity = 0f; NPC.dontTakeDamage = true; } - // Start phase 2, only run things that have to happen once in here if (bigDaddyPhase2) { @@ -550,17 +632,26 @@ namespace CalamityMod.NPCs.DevourerofGods } // Dialogue the moment the second phase starts - if (NPC.localAI[2] == 60f && !bossRush) + if (NPC.localAI[2] == 60f && !BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText5"; + string key = "Mods.CalamityMod.Status.Boss.DoGPhase2"; Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); + /* + var ctid = CombatText.NewText(NPC.Hitbox, messageColor, Language.GetTextValue(key), true); + if (ctid < Main.maxCombatText) + player.Calamity().subtitletext = Main.combatText[ctid]; + player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; + */ + DialogueDisplaySystem.StartDialogue("Mods.CalamityMod.DevourerOfGods.Phases", NPC, 2, 120, false, new BossText()); } } // Begin phase 2 + #region Phase 2 if (Phase2Started) { + #region Transition // Go immune and invisible if (NPC.localAI[2] > 5f) { @@ -607,10 +698,12 @@ namespace CalamityMod.NPCs.DevourerofGods AttemptingToEnterPortal = true; } + #endregion // Phase 2 else { + #region Misc Stuff I Want To Be Able To Collapse // Immunity after teleport and when dying NPC.dontTakeDamage = postTeleportTimer > 0 || Dying; @@ -618,10 +711,9 @@ namespace CalamityMod.NPCs.DevourerofGods if (teleportTimer > 0) { teleportTimer--; - // Teleport if (teleportTimer == 0) - Teleport(player, bossRush, death, revenge, expertMode, phase5); + Teleport(player, death, revenge, expertMode, phase5); } // Do the death animation once killed. @@ -640,19 +732,25 @@ namespace CalamityMod.NPCs.DevourerofGods return; } + #endregion // Laser walls - float adjustedAlphaGateValue = AlphaGateValue - (bossRush ? 360f : death ? 180f : 0f); - if (phase4 && !spawnedGuardians3 && postTeleportTimer <= 0) + #region Laser Walls + float adjustedAlphaGateValue = AlphaGateValue; + if (phase4 && postTeleportTimer <= 0) { if (laserWallPhase == (int)LaserWallPhase.SetUp) { // Enter laser wall phase very quickly when final phase starts - if (phase6 && calamityGlobalNPC.newAI[3] < adjustedAlphaGateValue) + if (phase6 && !spawnedGuardians3 && calamityGlobalNPC.newAI[3] < adjustedAlphaGateValue && NPC.ai[3] < 2) + { + NPC.ai[3] = 2; calamityGlobalNPC.newAI[3] = adjustedAlphaGateValue; + } // Increment next laser wall phase timer - calamityGlobalNPC.newAI[3] += 1f; + if (NPC.ai[3] == 2 || (!spawnedGuardians3 && phase6 && NPC.ai[3] < 2)) + calamityGlobalNPC.newAI[3] += 1f; // Set alpha value prior to firing laser walls if (calamityGlobalNPC.newAI[3] > adjustedAlphaGateValue) @@ -660,18 +758,15 @@ namespace CalamityMod.NPCs.DevourerofGods // Disable teleports if (teleportTimer > 0) { - GetRiftLocation(false); + GetRiftLocation(true); teleportTimer = 0; } - - NPC.Opacity = 1f - (MathHelper.Clamp((calamityGlobalNPC.newAI[3] - adjustedAlphaGateValue) * 5f, 0f, 255f) / 255f); } // Fire laser walls every X seconds after a laser wall phase ends - float laserWallGateValue = LaserWallCooldown - (bossRush ? 360f : death ? 180f : 0f); + float laserWallGateValue = LaserWallCooldown; if (calamityGlobalNPC.newAI[3] >= laserWallGateValue) { - NPC.Opacity = 0f; // Reset laser wall timer to 0 calamityGlobalNPC.newAI[1] = 0f; @@ -686,9 +781,10 @@ namespace CalamityMod.NPCs.DevourerofGods idleCounter--; if (idleCounter <= 0) { - SpawnTeleportLocation(player); laserWallPhase = (int)LaserWallPhase.End; idleCounter = idleCounterMax; + NPC.ai[3] = 3; + calamityGlobalNPC.newAI[2] = 0; } } else if (laserWallPhase == (int)LaserWallPhase.End) @@ -713,19 +809,14 @@ namespace CalamityMod.NPCs.DevourerofGods calamityGlobalNPC.newAI[3] = 0f; // Anger message - if (!bossRush) + if (!BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText6"; + string key = "Mods.CalamityMod.Status.Boss.DoGPhase3"; Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } + CalamityUtils.BroadcastLocalizedText(key, messageColor); + Vector2 start = GetRiftLocation(); - // Summon Cosmic Guardians - SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < 3; i++) - NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); + DialogueDisplaySystem.StartDialogue("Mods.CalamityMod.DevourerOfGods.Phases", start, 3, 120, false, new BossText()); } spawnedGuardians3 = true; @@ -738,8 +829,12 @@ namespace CalamityMod.NPCs.DevourerofGods // Set opacity after teleport if (postTeleportTimer > 0) { + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + postTeleportTimer--; NPC.Opacity = 1f - (postTeleportTimer / 255f); + if (NPC.ai[3] < 2) + calamityGlobalNPC.newAI[2] = 0; } else { @@ -750,257 +845,62 @@ namespace CalamityMod.NPCs.DevourerofGods } // Fireballs - // Check angle and distance to make sure it's realistic that they'd be fired - if (NPC.Opacity >= 1f && (distanceFromTarget > 480f || (CalamityWorld.LegendaryMode && CalamityWorld.revenge)) && (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) + if (isInPassiveState) { - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 30f : 150f) && calamityGlobalNPC.newAI[0] % ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 30f : phase7 ? 30f : 60f) == 0f) - { - float fireballSpeed = 8f; - Vector2 fireballVelocity = Vector2.Normalize(player.Center - NPC.Center) * fireballSpeed + NPC.velocity * 0.5f; - - Vector2 dustVelocity = fireballVelocity * 2f; - for (int k = 0; k < 50; k++) - Dust.NewDust(NPC.Center, 52, 52, (int)CalamityDusts.PurpleCosmilite, dustVelocity.X, dustVelocity.Y); - - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, fireballVelocity, type, damage, 0f, Main.myPlayer); - - if (CalamityWorld.LegendaryMode && revenge) - { - for (int l = 0; l < 8; l++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Ichor, 0f, 0f, 100, default, 1f); - float dustVelocityYAdd = Math.Abs(Main.dust[dust].velocity.Y) * 0.5f; - if (Main.dust[dust].velocity.Y < 0f) - Main.dust[dust].velocity.Y = 2f + dustVelocityYAdd; - if (Main.rand.NextBool()) - { - Main.dust[dust].scale = 0.25f; - Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - int numBlobs = 4; - type = ModContent.ProjectileType(); - damage = 60; - - for (int i = 0; i < numBlobs; i++) - { - Vector2 blobVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - blobVelocity.Normalize(); - blobVelocity *= Main.rand.Next(400, 801) * (bossRush ? 0.02f : 0.01f); - blobVelocity *= Main.rand.NextFloat() + 1f; - - float blobVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.5f; - if (blobVelocity.Y < 2f) - blobVelocity.Y = 2f + blobVelocityYAdd; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 50f, blobVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - } - } - } + ShootFireballs(player, distanceFromTarget, revenge); } - else if (distanceFromTarget < 240f) + else + { calamityGlobalNPC.newAI[0] = 0f; + } // Laser walls - if (!spawnedGuardians3 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls && Main.netMode != NetmodeID.MultiplayerClient) { - float spawnOffset = 1200f; - float divisor = bossRush ? 100f : 150f; - - if (calamityGlobalNPC.newAI[1] % divisor == 0f) + if (death && phase6) { - SoundEngine.PlaySound(SoundID.Item12, player.Center); - - // Side walls - float targetPosY = player.position.Y; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - int halfTotalDiagonalShots = totalDiagonalShots / 2; - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - - switch (laserWallType_Phase2) - { - case (int)LaserWallType_Phase2.Normal: - - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.Offset: - - targetPosY += 50f; - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.DiagonalHorizontal: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0]); - aim.Y += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0]); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[0] -= diagonalSpacingVar; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X, targetPosY + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X, targetPosY - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.MultiLayered: - - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - int totalBonusLasers = totalShots_Phase2 / 2; - for (int x = 0; x < totalBonusLasers; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[3], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[3], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[3] -= Main.rand.NextBool() ? 215 : 235; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.DiagonalVertical: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY + spawnOffset); - aim.X += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY - spawnOffset); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[0] -= diagonalSpacingVar; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - } - - // Pick a random laser wall phase in expert+ - if (expertMode) - { - int laserWallPhase; - int choices = revenge ? 5 : 3; - do laserWallPhase = Main.rand.Next(choices); - while (laserWallPhase == laserWallType_Phase2); - laserWallType_Phase2 = laserWallPhase; - } - else - laserWallType_Phase2 = laserWallType_Phase2 == (int)LaserWallType_Phase2.Normal ? (int)LaserWallType_Phase2.Offset : (int)LaserWallType_Phase2.Normal; - - // Lower wall - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + shotSpacing_Phase2[1], player.position.Y + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[1] -= spacingVar_Phase2; - } - - // Upper wall - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + shotSpacing_Phase2[2], player.position.Y - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[2] -= spacingVar_Phase2; - } - - for (int i = 0; i < shotSpacing_Phase2.Length; i++) - shotSpacing_Phase2[i] = shotSpacingMax_Phase2; + float spacing = 320; + float miniInterval = 12; + float megaInterval = 120; + float time = 0.35f; + for (var i = 0; i < 3; i++) + if ((int)(calamityGlobalNPC.newAI[1] - miniInterval * i) % megaInterval == 0f) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, time, spacing, 2 - i); + if (i == 2) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType(), LaserWallMiddleBeamDamage, 0, Main.myPlayer, time, 0, i); + else if (Main.zenithWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, time, 240, 6); + } + calamityGlobalNPC.newAI[1] += 1f; } + else + { + float divisor = death ? 100f : 120f; + if (phase6) + divisor -= 15; - calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] % divisor == 0f) + { + float spacing = death ? 144 : 160; + if (divisor == 0) + spacing += 64; + if (phase6) + spacing += death ? 64 : 32; + int bType = Main.rand.Next(0, 5 + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.5f, spacing, bType); + if (phase6 || death) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType(), LaserWallMiddleBeamDamage, 0, Main.myPlayer, 0.5f, 0, bType); + + if (Main.zenithWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.5f, 120, 6); + } + calamityGlobalNPC.newAI[1] += 1f; + } } // Set flight time to max during laser walls - if (!spawnedGuardians3 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) { if (!Main.dedServ) { @@ -1008,6 +908,7 @@ namespace CalamityMod.NPCs.DevourerofGods Main.LocalPlayer.Calamity().infiniteFlight = true; } } + #endregion // Movement int tilePositionX = (int)(NPC.position.X / 16f) - 1; @@ -1029,13 +930,36 @@ namespace CalamityMod.NPCs.DevourerofGods else if (NPC.velocity.X > 0f) NPC.spriteDirection = 1; + var VelocityRotation = NPC.velocity.ToRotation(); + void TurnTowards(Vector2 goal, float offset = 0, float maxSpeed = 1) + { + float goal2 = (goal - NPC.Center).ToRotation() + offset; + maxSpeed *= (float)Math.PI / 180f; + var dif = MathF.Atan2(MathF.Sin(goal2 - VelocityRotation), MathF.Cos(goal2 - VelocityRotation)); + if (dif < 0) + { + if (-dif > maxSpeed) + VelocityRotation -= maxSpeed; + else + VelocityRotation += dif; + } + else + { + if (dif > maxSpeed) + VelocityRotation += maxSpeed; + else + VelocityRotation += dif; + } + } + // Flight + #region Air AI if (NPC.ai[3] == 0f) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } // Charge in a direction for a second until the timer is back at 0 @@ -1063,61 +987,17 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 npcCenter = NPC.Center; float targetX = destination.X; float targetY = destination.Y; - int flyYLevel = -1; int destinationTileX = (int)(destination.X / 16f); int destinationTileY = (int)(destination.Y / 16f); - // Charge at target for 1.5 seconds - bool flyAtTarget = (!phase4 || spawnedGuardians3) && calamityGlobalNPC.newAI[2] > phaseLimit - 90 && revenge; - for (int i = destinationTileX - 2; i <= destinationTileX + 2; i++) - { - for (int j = destinationTileY; j <= destinationTileY + 15; j++) - { - if (WorldGen.SolidTile2(i, j)) - { - flyYLevel = j; - break; - } - } - if (flyYLevel > 0) - break; - } + speedCopy = homingSpeed; + turnSpeedCopy = homingTurnSpeed; - if (!flyAtTarget && destination == player.Center) - { - if (flyYLevel > 0) - { - flyYLevel *= 16; - float chaseFlyLevel = flyYLevel - 800; - if (player.position.Y > chaseFlyLevel) - { - targetY = chaseFlyLevel; - if (Math.Abs(NPC.Center.X - destination.X) < 500f) - { - if (NPC.velocity.X > 0f) - targetX = destination.X + 600f; - else - targetX = destination.X - 600f; - } - } - } - } - else - { - speedCopy = homingSpeed; - turnSpeedCopy = homingTurnSpeed; - } speedCopy += Vector2.Distance(destination, NPC.Center) * 0.005f; turnSpeedCopy += Vector2.Distance(destination, NPC.Center) * 0.00025f; - if (CalamityWorld.LegendaryMode && revenge) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - speedCopy *= 2f; - } - float fasterSpeedMult = speedCopy * 1.3f; float slowerSpeedMult = speedCopy * 0.7f; float npcSpeed = NPC.velocity.Length(); @@ -1134,7 +1014,6 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity *= slowerSpeedMult; } } - targetX = (int)(targetX / 16f) * 16; targetY = (int)(targetY / 16f) * 16; npcCenter.X = (int)(npcCenter.X / 16f) * 16; @@ -1148,6 +1027,7 @@ namespace CalamityMod.NPCs.DevourerofGods targetX *= timeToReachTarget; targetY *= timeToReachTarget; + turnSpeedCopy *= NPC.Distance(destination) / (death ? 800 : 1000f); if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { if (NPC.velocity.X < targetX) @@ -1238,14 +1118,15 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.ForceNetUpdate(false); } } - + #endregion // Ground - else + #region Ground AI + else if (NPC.ai[3] == 1f) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } // Charge in a direction for a second until the timer is back at 0 @@ -1270,12 +1151,7 @@ namespace CalamityMod.NPCs.DevourerofGods else if (increaseSpeed) groundPhaseTurnSpeed *= 2f; - if (CalamityWorld.LegendaryMode && revenge) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - segmentVelocity *= 2f; - } - + #region Digging AI if (!flies) { for (int r = tilePositionX; r < tileWidthPosX; r++) @@ -1384,10 +1260,13 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity.X = 0f; } } + #endregion + + #region Flying AI else { - double maximumSpeed1 = bossRush ? 0.52 : death ? 0.46 : 0.4; - double maximumSpeed2 = bossRush ? 1.25 : death ? 1.125 : 1D; + double maximumSpeed1 = death ? 0.46 : 0.4; + double maximumSpeed2 = death ? 1.125 : 1D; if (expertMode) { @@ -1474,7 +1353,7 @@ namespace CalamityMod.NPCs.DevourerofGods } } } - + #endregion // Set velocity so that DoG cannot speed burst instantly at the start of a phase swap if (calamityGlobalNPC.velocityPriorToPhaseSwap > 0f) { @@ -1508,24 +1387,79 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { + + calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); NPC.ai[3] = 0f; calamityGlobalNPC.newAI[2] = 0f; + + if ((phase4)) + { + calamityGlobalNPC.newAI[3] = AlphaGateValue - 120; + NPC.ai[3] = 2f; + + } NPC.TargetClosest(); NPC.ForceNetUpdate(false); } } + #endregion + + #region Laser Wall AI + else if (NPC.ai[3] == 2) + { + calamityGlobalNPC.newAI[2]++; + if (laserWallPhase != (int)LaserWallPhase.End) + { + var dogRotation = player.DirectionTo(NPC.Center).ToRotation(); + var DOGDIR = 1; + + var goalpos = player.Center + new Vector2(1000, 0).RotatedBy(dogRotation + 0.05f * DOGDIR); + + var currentVelLength = NPC.velocity.Length(); + var goalVel = NPC.DirectionTo(goalpos) * currentVelLength; + + TurnTowards(goalpos, maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); + NPC.velocity = VelocityRotation.ToRotationVector2() * (currentVelLength < 40 ? currentVelLength + 0.2f : currentVelLength > 42 ? currentVelLength - 0.2f : currentVelLength); + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + else + { + NPC.dontTakeDamage = true; + } + } + #endregion + #region Portal AI + else + { + if (calamityGlobalNPC.newAI[2] == 0) + { + SpawnTeleportLocation(player); + } + NPC.velocity *= 1.02f; + calamityGlobalNPC.newAI[2]++; + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + #endregion } } + #endregion + #region Phase 1 else { - // Spawn Guardians + // Spawn fireballs if (phase3) { - if (!death) + // Fireballs + if (isInPassiveState) { - if (NPC.localAI[3] < SkyColorTransitionTime) - NPC.localAI[3] += 1f; + ShootFireballs(player, distanceFromTarget, revenge); + } + else + { + calamityGlobalNPC.newAI[0] = 0f; } if (!spawnedGuardians) @@ -1533,30 +1467,24 @@ namespace CalamityMod.NPCs.DevourerofGods if (revenge) spawnDoGCountdown = 10; - if (!bossRush) + if (!BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText"; + string key = "Mods.CalamityMod.Status.Boss.DoGSubphase1"; Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); + + /* + int ctid = CombatText.NewText(NPC.Hitbox, messageColor, Language.GetTextValue(key), true); + if (ctid < Main.maxCombatText) + player.Calamity().subtitletext = Main.combatText[ctid]; + player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; + */ + DialogueDisplaySystem.StartDialogue("Mods.CalamityMod.DevourerOfGods.Phases", NPC, 1, 120, false, new BossText()); } NPC.TargetClosest(); spawnedGuardians = true; } - - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0) - { - SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < 2; i++) - NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); - } - } - } } else if (phase2) { @@ -1568,22 +1496,11 @@ namespace CalamityMod.NPCs.DevourerofGods spawnedGuardians2 = true; } - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0) - { - SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); - } - } } // Laser barrage attack variables - float laserBarrageGateValue = bossRush ? 1080f : death ? 1320f : 1440f; - float laserBarrageShootGateValue = bossRush ? 160f : 240f; + float laserBarrageGateValue = 1440f; + float laserBarrageShootGateValue = 240f; float laserBarragePhaseGateValue = laserBarrageGateValue - laserBarrageShootGateValue; // Spawn segments @@ -1621,164 +1538,39 @@ namespace CalamityMod.NPCs.DevourerofGods if (phase2) { - float spawnOffset = 1200f; - - calamityGlobalNPC.newAI[1] += 1f; + if (NPC.ai[3] == 2) + calamityGlobalNPC.newAI[1] += 1f; if (calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) { - if (calamityGlobalNPC.newAI[1] >= laserBarrageGateValue) - calamityGlobalNPC.newAI[1] = 0f; - - if (calamityGlobalNPC.newAI[1] % (laserBarrageShootGateValue * 0.5f) == 0f && calamityGlobalNPC.newAI[1] > 0f) + if (!Main.dedServ) { - SoundEngine.PlaySound(SoundID.Item12, player.Center); + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.LocalPlayer.Calamity().infiniteFlight = true; + } + if (calamityGlobalNPC.newAI[1] >= laserBarrageGateValue) + { + calamityGlobalNPC.newAI[1] = 0f; + NPC.ai[3] = 3; + calamityGlobalNPC.newAI[2] = 0; + NPC.velocity += player.DirectionTo(NPC.Center) * 15; + } - // Side walls - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - Vector2 aimClone = aim; - - switch (laserWallType) + if (calamityGlobalNPC.newAI[1] % (int)(laserBarrageShootGateValue * (death ? 0.33f : 0.5f)) == 0f && calamityGlobalNPC.newAI[1] > 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) { - case (int)LaserWallType.DiagonalRight: + int bType = Main.rand.Next(0, 5 + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.45f, 170, bType); - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType.DiagonalLeft: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType.DiagonalHorizontal: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType.DiagonalCross: - - int randomLaserGap = Main.rand.Next(3) + 3; // 3, 4, 5, 6 - for (int x = 0; x < totalShots + 1; x++) - { - if (x != randomLaserGap && x != randomLaserGap + 1) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y + spawnOffset); - aimClone.X += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aimClone - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y - spawnOffset); - velocity = Vector2.Normalize(aimClone - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - } - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; + if (Main.zenithWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.45f, 120, 6); } - - // Pick a random laser wall phase in expert+ - if (expertMode) - { - int laserWallPhase; - int choices = revenge ? 4 : 3; - do laserWallPhase = Main.rand.Next(choices); - while (laserWallPhase == laserWallType); - laserWallType = laserWallPhase; - } - else - laserWallType = laserWallType == (int)LaserWallType.DiagonalRight ? (int)LaserWallType.DiagonalLeft : (int)LaserWallType.DiagonalRight; - - shotSpacing = shotSpacingMax; } } } // Opacity - if (phase2 && calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) - { - // Adjust opacity upon entering laser barrage phase - NPC.Opacity = 1f - (MathHelper.Clamp((calamityGlobalNPC.newAI[1] - laserBarragePhaseGateValue) * 5f, 0f, 255f) / 255f); - } - else + if (!(phase2 && calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) && !bigDaddyPhase2) { // 2 seconds to become fully visible again NPC.Opacity += 0.0083f; @@ -1806,13 +1598,36 @@ namespace CalamityMod.NPCs.DevourerofGods else if (NPC.velocity.X > 0f) NPC.spriteDirection = 1; + var VelocityRotation = NPC.velocity.ToRotation(); + void TurnTowards(Vector2 goal, float offset = 0, float maxSpeed = 1) + { + float goal2 = (goal - NPC.Center).ToRotation() + offset; + maxSpeed *= (float)Math.PI / 180f; + var dif = MathF.Atan2(MathF.Sin(goal2 - VelocityRotation), MathF.Cos(goal2 - VelocityRotation)); + if (dif < 0) + { + if (-dif > maxSpeed) + VelocityRotation -= maxSpeed; + else + VelocityRotation += dif; + } + else + { + if (dif > maxSpeed) + VelocityRotation += maxSpeed; + else + VelocityRotation += dif; + } + } + // Flight - if (NPC.ai[3] == 0f) + #region Phase 1 Air AI + if (NPC.ai[3] == 1f) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } // Flying movement @@ -1825,58 +1640,15 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 npcCenter = NPC.Center; float targetX = player.position.X + (player.width / 2); float targetY = player.position.Y + (player.height / 2); - int flyYLevel = -1; - int destinationTileX = (int)(destination.X / 16f); - int destinationTileY = (int)(destination.Y / 16f); - for (int i = destinationTileX - 2; i <= destinationTileX + 2; i++) - { - for (int j = destinationTileY; j <= destinationTileY + 15; j++) - { - if (WorldGen.SolidTile2(i, j)) - { - flyYLevel = j; - break; - } - } - if (flyYLevel > 0) - break; - } - - if (flyYLevel > 0) - { - flyYLevel *= 16; - float chaseFlyLevel = flyYLevel - 800; - if (player.position.Y > chaseFlyLevel) - { - targetY = chaseFlyLevel; - if (Math.Abs(NPC.Center.X - destination.X) < 500f) - { - if (NPC.velocity.X > 0f) - targetX = destination.X + 600f; - else - targetX = destination.X - 600f; - } - } - } - else - { - speedCopy = homingSpeed; - turnSpeedCopy = homingTurnSpeed; - } + speedCopy = homingSpeed; + turnSpeedCopy = homingTurnSpeed; if (expertMode) { speedCopy += distanceFromTarget * 0.005f * (1f - lifeRatio); turnSpeedCopy += distanceFromTarget * 0.0001f * (1f - lifeRatio); } - - if (CalamityWorld.LegendaryMode && revenge) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - speedCopy *= 2f; - } - float fasterSpeedMult = speedCopy * 1.3f; float slowerSpeedMult = speedCopy * 0.7f; float npcSpeed = NPC.velocity.Length(); @@ -1907,6 +1679,7 @@ namespace CalamityMod.NPCs.DevourerofGods targetX *= timeToReachTarget; targetY *= timeToReachTarget; + turnSpeedCopy *= NPC.Distance(destination) / (death ? 800 : 1000); if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { if (NPC.velocity.X < targetX) @@ -1991,20 +1764,26 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); - NPC.ai[3] = 1f; + NPC.ai[3] = 0f; calamityGlobalNPC.newAI[2] = 0f; + if (phase2) + { + NPC.ai[3] = 2; + calamityGlobalNPC.newAI[1] = laserBarragePhaseGateValue - 120; + } NPC.TargetClosest(); NPC.ForceNetUpdate(false); } } - + #endregion // Ground - else + #region Phase 1 Ground AI + else if (NPC.ai[3] == 0) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } calamityGlobalNPC.newAI[2] += 1f; @@ -2015,12 +1794,6 @@ namespace CalamityMod.NPCs.DevourerofGods else if (increaseSpeed) groundPhaseTurnSpeed *= 2f; - if (CalamityWorld.LegendaryMode && revenge) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - segmentVelocity *= 2f; - } - if (!flies) { for (int r = tilePositionX; r < tileWidthPosX; r++) @@ -2131,8 +1904,8 @@ namespace CalamityMod.NPCs.DevourerofGods } else { - double maximumSpeed1 = bossRush ? 0.52 : death ? 0.46 : 0.4; - double maximumSpeed2 = bossRush ? 1.25 : death ? 1.125 : 1D; + double maximumSpeed1 = death ? 0.46 : 0.4; + double maximumSpeed2 = death ? 1.125 : 1D; if (expertMode) { @@ -2254,113 +2027,280 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); - NPC.ai[3] = 0f; + NPC.ai[3] = 1f; calamityGlobalNPC.newAI[2] = 0f; NPC.TargetClosest(); NPC.netUpdate = true; } } + #endregion + + #region Laser Wall AI + else if (NPC.ai[3] == 2) + { + calamityGlobalNPC.newAI[2]++; + if (laserWallPhase != (int)LaserWallPhase.End) + { + var dogRotation = player.DirectionTo(NPC.Center).ToRotation(); + var DOGDIR = 1; + + var goalpos = player.Center + new Vector2(1000, 0).RotatedBy(dogRotation + 0.05f * DOGDIR); + + var currentVelLength = NPC.velocity.Length(); + var goalVel = NPC.DirectionTo(goalpos) * currentVelLength; + + TurnTowards(goalpos, maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); + NPC.velocity = VelocityRotation.ToRotationVector2() * (currentVelLength < 40 ? currentVelLength + 0.2f : currentVelLength); + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + } + #endregion + + #region Decoil AI + else + { + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + calamityGlobalNPC.newAI[2]++; + if (calamityGlobalNPC.newAI[2] >= 45) + { + NPC.ai[3] = 0; + calamityGlobalNPC.newAI[2] = 0; + } + } + #endregion } + #endregion // There is no escape... - if (NPC.Distance(player.Center) > 2400f) - NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + if (NPC.Distance(destination) > 2400f) + NPC.velocity += (destination - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) + // Jaw movement. + float targetRotationReset = ((Phase2Started || phase3) && isInPassiveState) ? MathHelper.ToRadians(10f) : 0f; + float targetRotationOpenJaw = MathHelper.ToRadians(Phase2Started ? 32f : 22f); + float targetRotationChompDown = MathHelper.ToRadians(Phase2Started ? -25f : -15f); + float dotProduct = Vector2.Dot(NPC.DirectionTo(destination), NPC.velocity.SafeNormalize(Vector2.Zero)); + bool rotatedTowardsPlayer = dotProduct > 0.8f; + + // Reset slowly at all times. + JawRotation = MathHelper.Lerp(JawRotation, targetRotationReset, 0.08f); + + // Chomp down when close enough to the player. + if (distanceFromTarget < 110f) { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); + JawRotation = MathHelper.Lerp(JawRotation, targetRotationChompDown, JawChompDownProgress); + JawChompDownProgress = MathHelper.Clamp(JawChompDownProgress + 0.28f, 0f, 1f); + + // Spawn some particle effects when chomping down + if (JawChompDownProgress >= 0.94f && ShouldSpawnChompVFX) + { + Vector2 jawChompPosition = (NPC.Center - Vector2.UnitY.RotatedBy(NPC.rotation) * 36f) + (NPC.velocity * 1.45f); + Color jawParticleColor = isInPassiveState ? Color.Cyan : Color.Purple; + for (int i = 0; i < 20; i++) + { + Vector2 sparkVelocity = NPC.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(26f, 32f); + int sparkLifetime = Main.rand.Next(20, 30); + float sparkScale = Main.rand.NextFloat(1.4f, 1.8f); + Color sparkColor = Color.Lerp(jawParticleColor, Color.White, Main.rand.NextFloat(0f, 0.3f)); + + SparkParticle chompSpark = new(jawChompPosition, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(chompSpark); + } + + // Play a sound and add some screenshake with it if you're close enough too. + float shakeStrength = Phase2Started ? 14f : 8f; + CalamityUtils.AddScreenshakeAt(jawChompPosition, shakeStrength, 100f); + SoundEngine.PlaySound(HitSound with { Pitch = -0.45f }, jawChompPosition); + ShouldSpawnChompVFX = false; + NPC.netUpdate = true; + } } - else + // Only open up when DoG is facing the player. + else if (distanceFromTarget < 480f && rotatedTowardsPlayer) { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); + JawRotation = MathHelper.Lerp(JawRotation, targetRotationOpenJaw, 0.28f); + if (!ShouldSpawnChompVFX) + ShouldSpawnChompVFX = true; } + // Fade out the special jaw texture during rift dashes. + GodSlayerDashJawTimer--; + if (GodSlayerDashJawTimer <= 0f) + { + GodSlayerDashJawFadeProgress = MathHelper.Lerp(GodSlayerDashJawFadeProgress, 0f, 0.15f); + if (GodSlayerDashJawTimer < 0f) + GodSlayerDashJawTimer = 0f; + } if (NPC.life > Main.npc[(int)NPC.ai[0]].life) NPC.life = Main.npc[(int)NPC.ai[0]].life; } + private void ShootFireballs(Player player, float distanceFromTarget, bool revenge) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + Vector2 mouthPosition = NPC.Center - Vector2.UnitY.RotatedBy(NPC.rotation) * (Phase2Started ? 28f : -16f); + + calamityGlobalNPC.newAI[0] += 1f; + if (NPC.Opacity >= 1f && (distanceFromTarget > (revenge ? 320f : 480f))) + { + float dotProduct = Vector2.Dot(NPC.DirectionTo(AdjustedPlayerCenter()), NPC.velocity.SafeNormalize(Vector2.Zero)); + if (dotProduct > 0.8f) + { + if (calamityGlobalNPC.newAI[0] > 75f) + { + // Flame and cinder particles from the mouth. + for (int i = 0; i < 18; i++) + { + Vector2 flameVelocity = NPC.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(32f, 44f); + int flameLifetime = Main.rand.Next(45, 60); + float flameScale = Main.rand.NextFloat(0.6f, 0.9f); + float flameOpacity = Main.rand.NextFloat(0.7f, 0.9f); + Color flameColor = Color.Lerp(Color.Cyan, Color.White, Main.rand.NextFloat(0f, 0.4f)); + + HeavySmokeParticle fireballFlames = new(mouthPosition, flameVelocity, flameColor, flameLifetime, flameScale, flameOpacity, 0.01f, true); + GeneralParticleHandler.SpawnParticle(fireballFlames); + } + + for (int i = 0; i < 10; i++) + { + Vector2 cinderVelocity = NPC.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(36f, 48f); + float cinderScale = Main.rand.NextFloat(0.3f, 0.5f); + Color cinderColor = Color.Lerp(Color.Cyan, Color.White, Main.rand.NextFloat(0.2f, 0.6f)); + int cinderLifetime = Main.rand.Next(45, 60); + + SquishyLightParticle cinder = new(mouthPosition, cinderVelocity, cinderScale, cinderColor, cinderLifetime); + GeneralParticleHandler.SpawnParticle(cinder); + } + + // Open DoG's mouth a bit everytime a fireball is fired. + JawRotation = MathHelper.ToRadians(22f); + + float fireballSpeed = 8f; + Vector2 fireballVelocity = Vector2.Normalize(AdjustedPlayerCenter() - NPC.Center) * (fireballSpeed + NPC.velocity.Length() * 0.5f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, fireballVelocity, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, 2f); + + calamityGlobalNPC.newAI[0] = 0f; + NPC.ForceNetUpdate(false); + } + } + } + + } + private void SpawnTeleportLocation(Player player, bool phase2Transition = false) { if (teleportTimer > 0 || player.dead || !player.active) return; - if (!phase2Transition) - teleportTimer = (CalamityWorld.death || BossRushEvent.BossRushActive) ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal; + if (NPC.ai[3] < 2) + NPC.ai[3] = 3; - SoundEngine.PlaySound(SoundID.Item109, player.Center); + int baseTeleportTime = ((CalamityWorld.death || BossRushEvent.BossRushActive) ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal); + if ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.life / (float)NPC.lifeMax < 0.25f && NPC.ai[3] < 8 && NPC.ai[3] > 3) + baseTeleportTime -= 45; + + if (!phase2Transition) + teleportTimer = baseTeleportTime; + + SoundEngine.PlaySound(RiftOpenSound with { Volume = 1.5f }, player.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { int randomRange = Main.zenithWorld ? 960 : 48; float distance = 500f; + if ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.life / (float)NPC.lifeMax < 0.25f && NPC.ai[3] < 8) + { + distance += 450; //More breathing room for rapid dash + } Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); - Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI); + int rift = Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI); + if (Main.projectile.IndexInRange(rift)) + Main.projectile[rift].ModProjectile().RiftLifetime = baseTeleportTime; + // GFB, spawn a ton of fake rifts alongside the real one. if (Main.zenithWorld) { - // Fake portals galore randomRange = 2000; for (int k = 0; k < 35; k++) { targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); - Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI, ai2: 1f); + int faker = Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI); + if (Main.projectile.IndexInRange(faker)) + { + Main.projectile[faker].ModProjectile().FakeRift = true; + Main.projectile[faker].ModProjectile().RiftLifetime = baseTeleportTime; + } } } } } - private void Teleport(Player player, bool bossRush, bool death, bool revenge, bool expertMode, bool phase5) + private void Teleport(Player player, bool death, bool revenge, bool expertMode, bool phase5) { Vector2 newPosition = GetRiftLocation(true); if ((!AwaitingPhase2Teleport && (player.dead || !player.active)) || newPosition == default) return; + bool phase6 = NPC.life / (float)NPC.lifeMax < 0.25f; - if (phase5) + if (Main.netMode != NetmodeID.MultiplayerClient && !(death && phase6 && NPC.ai[3] < 7)) // 4 dashes on Death phase 3 without fireballs { - if (Main.netMode != NetmodeID.MultiplayerClient) + float finalVelocity = death ? 12f : 10f; + int totalSpreads = revenge ? 6 : 3; + float mult = revenge ? 1.5f : 3f; + for (int i = 0; i < totalSpreads; i++) { - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - float finalVelocity = 10f; - int totalSpreads = revenge ? 6 : 3; - float mult = revenge ? 1.5f : 3f; - for (int i = 0; i < totalSpreads; i++) + if (!death && i % 3 == 2) + continue; + int totalProjectiles = 12; + float radians = MathHelper.TwoPi / totalProjectiles; + float newVelocity = finalVelocity - i * mult; + float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); + float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; + for (int k = 0; k < totalProjectiles; k++) { - int totalProjectiles = (CalamityWorld.LegendaryMode && revenge) ? 30 : bossRush ? 18 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - float newVelocity = finalVelocity - i * mult; - float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(newVelocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = i < 3 ? new Vector2(0f, -newVelocity) : new Vector2(-velocityX, -newVelocity); - float finalVelocityReduction = (float)Math.Pow(1.25, i) - 1f; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), newPosition, vector255, type, damage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); - } + Vector2 vector255 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(NPC.GetSource_FromAI(), newPosition, vector255, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); } } } NPC.TargetClosest(); NPC.position = newPosition; - float chargeVelocity = bossRush ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; - float maxChargeDistance = 1600f; + float chargeVelocity = death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; + chargeVelocity *= (death) ? (!(phase6 && NPC.ai[3] < 7)) ? 2.5f : 3 : 2.25f; + float maxChargeDistance = 1800f; postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); + int phase6dashcount = death ? 5 : 3; + if (phase6 && NPC.ai[3] < 2 + phase6dashcount) + { + if (NPC.ai[3] < 3) + NPC.ai[3] = 3; + NPC.ai[3]++; + // On FTW the final 10% is infinite portal dashing + if (Main.getGoodWorld && NPC.life / (float)NPC.lifeMax < 0.1f) + { + NPC.ai[3] = 4; + NPC.SimpleStrikeNPC(10000, 1); + } + } + else + { + NPC.ai[3] = 0; + } + NPC.Calamity().newAI[2] = 0; AwaitingPhase2Teleport = false; NPC.Opacity = 1f - (postTeleportTimer / 255f); - // Prediction is Death Mode only for now because it's weird without the line telegraph that Shayy spoke about - Vector2 predictionVector = death ? player.velocity * 40f : Vector2.Zero; - NPC.velocity = Vector2.Normalize(player.Center + predictionVector - NPC.Center) * chargeVelocity; + NPC.velocity = Vector2.Normalize(AdjustedPlayerCenter(10) - NPC.Center) * chargeVelocity; NPC.ForceNetUpdate(false); - + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; foreach (NPC n in Main.ActiveNPCs) { if (n.type == ModContent.NPCType() || n.type == ModContent.NPCType()) @@ -2374,7 +2314,11 @@ namespace CalamityMod.NPCs.DevourerofGods } } + GodSlayerDashJawFadeProgress = 1f; + GodSlayerDashJawTimer = 60f; SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); + if (Main.getGoodWorld) + NPC.Calamity().velocityPriorToPhaseSwap = 20; } public void DoDeathAnimation() @@ -2408,7 +2352,7 @@ namespace CalamityMod.NPCs.DevourerofGods { for (int j = 0; j < 20; j++) { - Dust cosmicBurst = Dust.NewDustPerfect(n.Center + Main.rand.NextVector2Circular(25f, 25f), 234); + Dust cosmicBurst = Dust.NewDustPerfect(n.Center + Main.rand.NextVector2Circular(25f, 25f), DustID.BoneTorch); cosmicBurst.scale = 1.7f; cosmicBurst.velocity = Main.rand.NextVector2Circular(9f, 9f); cosmicBurst.noGravity = true; @@ -2478,79 +2422,128 @@ namespace CalamityMod.NPCs.DevourerofGods DeathAnimationTimer++; } - private Vector2 GetRiftLocation(bool spawnDust) + public Vector2 GetRiftLocation(bool activateRift = false) { - Vector2 realSpot = default; + Vector2 realSpot = Vector2.Zero; foreach (Projectile proj in Main.ActiveProjectiles) { if (proj.type == ModContent.ProjectileType()) { - if (!spawnDust) - proj.ai[0] = -1f; + if (proj.ModProjectile is DoGTeleportRift rift && !rift.FakeRift) + { + realSpot = proj.Center; - proj.Kill(); - - if (proj.ai[2] == 1f) - continue; - - realSpot = proj.Center; + // Safeguard for if the rift doesn't activate at its designated time. + if (activateRift) + proj.ModProjectile().SwitchAIStates(); + } } } return realSpot; } + Vector2 noiseOffset = Vector2.Zero; + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + bool actuallyInPhaseTwo = (Phase2Started && NPC.localAI[2] <= 60f); + Texture2D mainTexture = actuallyInPhaseTwo ? TextureP2.Value : TextureAssets.Npc[Type].Value; + Texture2D mainGlowTexture = actuallyInPhaseTwo ? TextureP2_Glow_Purple.Value : Texture_Glow_Purple.Value; + Texture2D mainJawTexture = actuallyInPhaseTwo ? JawTextureP2.Value : JawTexture.Value; + Texture2D mainJawGlowTexture = actuallyInPhaseTwo ? JawTextureP2_Glow.Value : JawTexture_Glow.Value; + + // Draw the custom worm bestiary sprite separately. if (NPC.IsABestiaryIconDummy) + { NPC.Opacity = 1f; - - float disintegrationFactor = DeathAnimationTimer / 800f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage0("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); + return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, TextureP2_Full.Value, DevourerofGodsBody.TextureP2.Value, 4, 26, 0.5f, new Vector2(30, 10), 2, 20); } - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + bool shouldUseShader = CalamityDrawParameterNPC.DoGDeathAnimationTimer != 0; + SpriteBatchSnapshot snap = new(spriteBatch); - bool useOtherTextures = (Phase2Started && NPC.localAI[2] <= 60f) || NPC.IsABestiaryIconDummy; - Texture2D texture2D15 = useOtherTextures ? Phase2Texture.Value : TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - if (NPC.IsABestiaryIconDummy) + if (shouldUseShader) { - return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, texture2D15, DevourerofGodsBody.Phase2Texture.Value, 4, 26, 0.5f, new Vector2(30, 10), 2, 20); + if (noiseOffset == Vector2.zeroVector) + noiseOffset = NPC.Center; + + Main.spriteBatch.End(out snap); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + + MiscShaderData dissolveShader = GameShaders.Misc["CalamityMod:Dissolve"]; + Texture2D dissolveTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + + dissolveShader.Shader.Parameters["noiseScale"].SetValue(0.5f); + dissolveShader.Shader.Parameters["dissolveIntensity"].SetValue(CalamityDrawParameterNPC.DoGDeathAnimationTimer / 600f); + dissolveShader.Shader.Parameters["sampleOffset"].SetValue(noiseOffset * 0.5f); + dissolveShader.Shader.Parameters["transitionColor"].SetValue(SpecialMoveColor.ToVector4()); + dissolveShader.Shader.Parameters["transitionOffset"].SetValue(0.05f); + + Main.instance.GraphicsDevice.Textures[1] = dissolveTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + dissolveShader.Apply(); } - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + SpriteEffects spriteEffects = (NPC.spriteDirection == 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 halfSizeTexture = mainTexture.Size() * 0.5f; - if (!NPC.dontTakeDamage) + Vector2 drawPosition = NPC.Center - screenPos; + drawPosition -= new Vector2(mainTexture.Width, mainTexture.Height) * NPC.scale / 2f; + drawPosition += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + + // Draw DoG's mouth and its glow masks. + Vector2 jawOrigin = mainJawTexture.Size() * 0.5f; + for (int i = -1; i <= 1; i += 2) { - texture2D15 = useOtherTextures ? Phase2Texture_Glow.Value : Texture_Glow.Value; - Color glowmaskLerp = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + float jawBaseOffset = actuallyInPhaseTwo ? 42f : 28f; + SpriteEffects jawSpriteEffect = (i == 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + Vector2 jawDrawPosition = drawPosition; + jawDrawPosition += Vector2.UnitX.RotatedBy(NPC.rotation + JawRotation * i) * i * (jawBaseOffset + MathF.Sin(JawRotation) * 24f); + jawDrawPosition -= Vector2.UnitY.RotatedBy(NPC.rotation) * ((actuallyInPhaseTwo ? 44f : 8f) + MathF.Sin(JawRotation) * (actuallyInPhaseTwo ? 30f : -6f)); - texture2D15 = useOtherTextures ? Phase2Texture_Glow2.Value : Texture_Glow2.Value; - glowmaskLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f); + spriteBatch.Draw(mainJawTexture, jawDrawPosition, null, NPC.GetAlpha(drawColor), NPC.rotation + JawRotation * i, jawOrigin, NPC.scale, jawSpriteEffect, 0f); + spriteBatch.Draw(mainJawGlowTexture, jawDrawPosition, null, NPC.GetAlpha(Color.White), NPC.rotation + JawRotation * i, jawOrigin, NPC.scale, jawSpriteEffect, 0f); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + // Draw the additional special jaw textures above these for the Rift Dash attack. + if (GodSlayerDashJawFadeProgress > 0.02f && CalamityDrawParameterNPC.DoGDeathAnimationTimer <= 0) + { + using (spriteBatch.Scope()) + { + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Vector2 godSlayerJawOrigin = GodSlayerDashJawTexture.Size() * 0.5f; + float godSlayerJawOpacity = GodSlayerDashJawFadeProgress; + + spriteBatch.Draw(GodSlayerDashJawTexture.Value, jawDrawPosition, null, NPC.GetAlpha(Color.Fuchsia) * godSlayerJawOpacity, NPC.rotation + JawRotation * i, godSlayerJawOrigin, NPC.scale * 1.6f, jawSpriteEffect, 0f); + spriteBatch.Draw(GodSlayerDashJawTexture.Value, jawDrawPosition, null, NPC.GetAlpha(Color.Cyan) * godSlayerJawOpacity, NPC.rotation + JawRotation * i, godSlayerJawOrigin, NPC.scale * 1.3f, jawSpriteEffect, 0f); + spriteBatch.End(); + } + } } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); + // Draw the main head. + spriteBatch.Draw(mainTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + // Draw the head glow masks. There are two glow mask textures for each head which are split between purple and cyan highlights. + // Each color is exaggerated by a similar color slightly when drawn to make them pop out more. + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + spriteBatch.Draw(mainGlowTexture, drawPosition, NPC.frame, NPC.GetAlpha(glowmaskColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + mainGlowTexture = actuallyInPhaseTwo ? TextureP2_Glow_Cyan.Value : Texture_Glow_Cyan.Value; + glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); + spriteBatch.Draw(mainGlowTexture, drawPosition, NPC.frame, NPC.GetAlpha(glowmaskColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + if (shouldUseShader) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(snap); + } return false; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -2563,7 +2556,7 @@ namespace CalamityMod.NPCs.DevourerofGods CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedDoG); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedDoG); // If DoG has not been killed yet, notify players that the holiday moons are buffed if (!DownedBossSystem.downedDoG) @@ -2575,9 +2568,9 @@ namespace CalamityMod.NPCs.DevourerofGods string key3 = "Mods.CalamityMod.Status.Progression.DargonBossText"; Color messageColor3 = Color.Yellow; - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - CalamityUtils.DisplayLocalizedText(key3, messageColor3); + CalamityUtils.BroadcastLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key2, messageColor2); + CalamityUtils.BroadcastLocalizedText(key3, messageColor3); } // Mark DoG as dead @@ -2603,36 +2596,33 @@ namespace CalamityMod.NPCs.DevourerofGods // Extraneous potions npcLoot.DefineConditionalDropSet(() => true).Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 5, 15), hideLootReport: true); // Healing Potions don't show up in the Bestiary - // Alicorn Mount - npcLoot.AddIf((info) => info.player.Calamity().cirrusVodka, ModContent.ItemType()); - // Normal drops: Everything that would otherwise be in the bag var normalOnly = npcLoot.DefineNormalOnlyDropSet(); { // Weapons int[] weapons = new int[] { - ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() }; normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); normalOnly.Add(ModContent.ItemType(), 10); - normalOnly.Add(ModContent.ItemType(), 10); // Vanity normalOnly.Add(ModContent.ItemType(), 7); normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // Materials - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 45, 55)); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 65, 80)); normalOnly.Add(ModContent.ItemType(), 1, 150, 250); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); } // Relic @@ -2641,42 +2631,45 @@ namespace CalamityMod.NPCs.DevourerofGods // GFB torch and Wand drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // this will be disastrous for the torch economy int dropRate = 10; int dropMin = 1; int dropMax = 9999; - GFBOnly.Add(ItemID.Torch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.PurpleTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.YellowTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.GreenTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.RedTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.WhiteTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.OrangeTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.PinkTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.RainbowTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.IceTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.BoneTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.UltrabrightTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.DemonTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.CursedTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.IchorTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.DesertTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.CoralTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.CorruptTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.CrimsonTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.HallowedTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.JungleTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.MushroomTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ItemID.ShimmerTorch, dropRate, dropMin, dropMax, true); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); - GFBOnly.Add(ModContent.ItemType(), dropRate, dropMin, dropMax, true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Torch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.PurpleTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.YellowTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.GreenTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.RedTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.WhiteTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.OrangeTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.PinkTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.RainbowTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.IceTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.BoneTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.UltrabrightTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.DemonTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.CursedTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.IchorTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.DesertTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.CoralTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.CorruptTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.CrimsonTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.HallowedTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.JungleTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.MushroomTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.ShimmerTorch, dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), dropRate, dropMin, dropMax), true); } // Trophy (always directly from boss, never in bag) @@ -2689,6 +2682,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Can only hit the target if within certain distance public override bool CanHitPlayer(Player target, ref int cooldownSlot) { + if (Phase2Started && NPC.localAI[2] > 60f) + return false; cooldownSlot = ImmunityCooldownID.Bosses; Rectangle targetHitbox = target.Hitbox; @@ -2717,7 +2712,7 @@ namespace CalamityMod.NPCs.DevourerofGods // viable???, done here since it's conditional if (Main.zenithWorld && projectile.type == ModContent.ProjectileType()) { - modifiers.SourceDamage *= 40f; + modifiers.SourceDamage *= 10f; } } @@ -2749,7 +2744,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (NPC.soundDelay == 0) { NPC.soundDelay = 8; - SoundEngine.PlaySound(CommonCalamitySounds.OtherwordlyHitSound with { Pitch = CommonCalamitySounds.OtherwordlyHitSound.Pitch + extrapitch }, NPC.Center); + SoundEngine.PlaySound(HitSound with { Pitch = HitSound.Pitch + extrapitch }, NPC.Center); } if (NPC.life <= 0) { @@ -2796,46 +2791,57 @@ namespace CalamityMod.NPCs.DevourerofGods if (hurtInfo.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 200, true); - target.AddBuff(ModContent.BuffType(), 600, true); - - if (target.Calamity().dogTextCooldown <= 0 && !BossRushEvent.BossRushActive) + if (!DialogueDisplaySystem.ContainsDialogueKey("Mods.CalamityMod.DevourerOfGods.Phases") && target.Calamity().dogTextCooldown <= 0 && !BossRushEvent.BossRushActive) { - string text = Utils.SelectRandom(Main.rand, new string[] + var counter = target.Calamity().DoGHeadHitCounter; + string DialogueGroup; + int DialogueIndex; + if (target.statLife - hurtInfo.Damage <= 0) { - "Mods.CalamityMod.Status.Boss.EdgyBossText2", - "Mods.CalamityMod.Status.Boss.EdgyBossText3", - "Mods.CalamityMod.Status.Boss.EdgyBossText4" - }); - Color messageColor = Color.Cyan; - Rectangle location = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - - // Speak in Wingdings if the Punch Card is equipped - if (target.Calamity().punchCard && DoGWingdings.Wingdings != null && System.Environment.OSVersion.Platform == PlatformID.Win32NT && !GameCulture.FromCultureName(GameCulture.CultureName.Chinese).IsActive && !GameCulture.FromCultureName(GameCulture.CultureName.Russian).IsActive) - { - Vector2 vector = DoGWingdings.Wingdings.MeasureString(Language.GetTextValue(text)); - // This is how normal combat text spawn positioning is handled - float positionX = (float)location.X + (float)location.Width * 0.5f - vector.X * 0.5f + Main.rand.Next(-(int)((double)location.Width * 0.5), (int)((double)location.Width * 0.5) + 1); - float positionY = (float)location.Y + (float)location.Height * 0.25f - vector.Y * 0.5f + Main.rand.Next(-(int)((double)location.Height * 0.5), (int)((double)location.Height * 0.5) + 1); - if (target.gravDir == -1f) - { - positionY = (float)location.Y + (float)location.Height * 0.75f + vector.Y * 0.5f; - } - // Spawn a projectile that mimmicks combat text behaviour - int p = Projectile.NewProjectile(NPC.GetSource_FromThis(), new Vector2(positionX, positionY), new Vector2((float)Main.rand.Next(-25, 26) * 0.05f , - 14f * target.gravDir), ModContent.ProjectileType(), 0, 0, -1, -1); - Projectile proj = Main.projectile[p]; - proj.rotation = proj.velocity.X < 0 ? -0.06f : 0.06f; - - // Pass the spoken dialogue into it - DoGWingdings wingdings = Main.projectile[p].ModProjectile(); - wingdings.dialogue = Language.GetTextValue(text); + DialogueGroup = "Mods.CalamityMod.DevourerOfGods.Death"; + if (counter == 0) + if (NPC.GetLifePercent() <= 0.25f) + DialogueIndex = 4; //All that running just to die to a single touch? + else + DialogueIndex = 0;// text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath1"; //Tasteless slop. + else if (NPC.GetLifePercent() <= 0.25f || counter >= 10) + DialogueIndex = 3; //WEAK. + else if (Phase2Started) + DialogueIndex = 2; //And STAY dead! + else if (!spawnedGuardians) + DialogueIndex = 0; //Tasteless slop. + else + DialogueIndex = 1; //A feast worthy of a god! } else { - CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); + if (counter == 0 && Phase2Started) + { + DialogueGroup = "Mods.CalamityMod.DevourerOfGods.Running"; + if (NPC.GetLifePercent() <= 0.25f) + DialogueIndex = 1; //WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?! + else + DialogueIndex = 0; //You can't run forever! + } + else + { + DialogueGroup = "Mods.CalamityMod.DevourerOfGods.Head"; + if (counter > 9) + DialogueIndex = Main.rand.Next(10, 13); //DogHead11-13 + else if (counter == 9) + DialogueIndex = 10;//text = headHitKeys[9]; //DogHead10 + else if (counter > 4) + DialogueIndex = Main.rand.Next(4, 9); //DogHead5-9 + else + DialogueIndex = Main.rand.Next(0, 4); //DogHead1-4 + } } - target.Calamity().dogTextCooldown = 60; + + DialogueDisplaySystem.StartDialogueOnClient(DialogueGroup, NPC, DialogueIndex, 60, false, new BossText()); + target.Calamity().dogTextCooldown = 90; + } + target.Calamity().DoGHeadHitCounter++; } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.png b/NPCs/DevourerofGods/DevourerofGodsHead.png index e41c65844d..b6513e7905 100644 Binary files a/NPCs/DevourerofGods/DevourerofGodsHead.png and b/NPCs/DevourerofGods/DevourerofGodsHead.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadGlow.png b/NPCs/DevourerofGods/DevourerofGodsHeadGlow.png deleted file mode 100644 index d4883adc06..0000000000 Binary files a/NPCs/DevourerofGods/DevourerofGodsHeadGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadGlow2.png b/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsHead_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Purple.png b/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Purple.png new file mode 100644 index 0000000000..2d049b02ae Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Purple.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw.png new file mode 100644 index 0000000000..1f2b5d3e16 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_Glow.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_Glow.png new file mode 100644 index 0000000000..f26d1e9d13 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_Glow.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2.png new file mode 100644 index 0000000000..2546b70428 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2_Glow.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2_Glow.png new file mode 100644 index 0000000000..36d17aa322 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2_Glow.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2.png new file mode 100644 index 0000000000..ff7808dee5 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Cyan.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Cyan.png new file mode 100644 index 0000000000..5b571069e2 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Cyan.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Purple.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Purple.png new file mode 100644 index 0000000000..f7a489c784 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Purple.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadS.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadSGlow2.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadSGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadSGlow.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadSGlow.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index cc6792d10a..b420b42454 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -1,10 +1,8 @@ using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Projectiles.Melee.Yoyos; -using CalamityMod.Sounds; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -25,16 +23,16 @@ namespace CalamityMod.NPCs.DevourerofGods public static int phase1IconIndex; public static int phase2IconIndex; - public static Asset Texture_Glow; - public static Asset Texture_Glow2; - public static Asset Phase2Texture; - public static Asset Phase2Texture_Glow; - public static Asset Phase2Texture_Glow2; + public static Asset Texture_Glow_Purple; + public static Asset Texture_Glow_Cyan; + public static Asset TextureP2; + public static Asset TextureP2_Glow_Purple; + public static Asset TextureP2_Glow_Cyan; public override void Load() { string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_P2_Head_Boss"; phase1IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); @@ -49,11 +47,11 @@ namespace CalamityMod.NPCs.DevourerofGods this.HideFromBestiary(); if (!Main.dedServ) { - Texture_Glow = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - Texture_Glow2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); - Phase2Texture = ModContent.Request(Texture + "S", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow = ModContent.Request(Texture + "SGlow", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow2 = ModContent.Request(Texture + "SGlow2", AssetRequestMode.AsyncLoad); + Texture_Glow_Purple = ModContent.Request(Texture + "_Glow_Purple", AssetRequestMode.AsyncLoad); + Texture_Glow_Cyan = ModContent.Request(Texture + "_Glow_Cyan", AssetRequestMode.AsyncLoad); + TextureP2 = ModContent.Request(Texture + "_P2", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Purple = ModContent.Request(Texture + "_P2_Glow_Purple", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Cyan = ModContent.Request(Texture + "_P2_Glow_Cyan", AssetRequestMode.AsyncLoad); } } @@ -64,13 +62,12 @@ namespace CalamityMod.NPCs.DevourerofGods public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 100; // 200 NPC.npcSlots = 5f; NPC.width = 66; NPC.height = 66; NPC.defense = 50; - NPC.LifeMaxNERB(887500, 1065000, 1500000); // Phase 1 is 355000, Phase 2 is 532500 + NPC.LifeMaxNERB(760000, 910000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -82,14 +79,13 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.netAlways = true; NPC.boss = true; NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.takenDamageMultiplier = 1.25f; NPC.dontCountMe = true; - if (Main.getGoodWorld) + if (Main.zenithWorld) NPC.scale *= 1.5f; - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); + if (Main.getGoodWorld) + NPC.takenDamageMultiplier = 2; } public override void BossHeadSlot(ref int index) @@ -98,7 +94,7 @@ namespace CalamityMod.NPCs.DevourerofGods DevourerofGodsHead modNPC = head?.ModNPC() ?? null; index = -1; - if (head is null) + if (head is null || NPC.Opacity < 0.1f) return; if (!modNPC.Phase2Started) @@ -146,41 +142,33 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.frame = frame; } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; public override void AI() { if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - if (NPC.life > Main.npc[(int)NPC.ai[1]].life) - NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.life = Main.npc[(int)NPC.ai[2]].life; + NPC.lifeMax = Main.npc[(int)NPC.ai[2]].lifeMax; + // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; + float lifeRatio = Main.npc[(int)NPC.ai[2]].life / (float)Main.npc[(int)NPC.ai[2]].lifeMax; - bool phase2 = lifeRatio < 0.6f; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool death = CalamityWorld.death || bossRush; + bool phase2 = lifeRatio < 0.65f; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (phase2) + if (phase2 && !phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60) { phase2Started = true; - - // Once before DoG spawns, set new size - if (Main.npc[(int)NPC.ai[2]].localAI[2] == 60f) - { NPC.position = NPC.Center; NPC.width = (int)(80 * NPC.scale); - NPC.height = (int)(140 * NPC.scale); + NPC.height = (int)(80 * NPC.scale); NPC.frame = new Rectangle(0, 0, 86, 148); NPC.position -= NPC.Size * 0.5f; NPC.ForceNetUpdate(false); - } } if (invinceTime > 0) @@ -200,16 +188,6 @@ namespace CalamityMod.NPCs.DevourerofGods Player player = Main.player[NPC.target]; - float distanceFromTarget = Vector2.Distance(player.Center, NPC.Center); - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - NPC.takenDamageMultiplier = MathHelper.Lerp(1f, 1.25f, damageTakenScalar); - } - else - NPC.takenDamageMultiplier = 1.25f; - // Check if other segments are still alive, if not, die bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) @@ -280,7 +258,6 @@ namespace CalamityMod.NPCs.DevourerofGods segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; playerXDist -= segmentDirection.X; playerYDist -= segmentDirection.Y; - float playerDistance = (float)System.Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try @@ -293,7 +270,7 @@ namespace CalamityMod.NPCs.DevourerofGods { } NPC.rotation = (float)System.Math.Atan2(playerYDist, playerXDist) + MathHelper.PiOver2; - playerDistance = (float)System.Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); + float playerDistance = (float)System.Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); int segmentWidth = NPC.width; playerDistance = (playerDistance - segmentWidth) / playerDistance; playerXDist *= playerDistance; @@ -309,27 +286,15 @@ namespace CalamityMod.NPCs.DevourerofGods } // Velocity variables - float segmentVelocity = bossRush ? 19f : death ? 17.5f : 16f; + float segmentVelocity = death ? 17.5f : 16f; if (expertMode) segmentVelocity += 4f * (1f - lifeRatio); if (Main.getGoodWorld) segmentVelocity *= 1.1f; - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } + Vector2 noiseOffset = Vector2.Zero; + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { if (NPC.realLife < 0 || NPC.realLife >= Main.maxNPCs || Main.npc[NPC.realLife] is null) @@ -337,14 +302,30 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.npc[NPC.realLife].type != ModContent.NPCType()) return true; - float disintegrationFactor = Main.npc[NPC.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) + bool shouldUseShader = CalamityDrawParameterNPC.DoGDeathAnimationTimer != 0; + SpriteBatchSnapshot snap = new(spriteBatch); + + if (shouldUseShader) { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage1("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); + if (noiseOffset == Vector2.zeroVector) + noiseOffset = NPC.Center; + + Main.spriteBatch.End(out snap); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + + MiscShaderData dissolveShader = GameShaders.Misc["CalamityMod:Dissolve"]; + Texture2D dissolveTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + + dissolveShader.Shader.Parameters["noiseScale"].SetValue(1f); + dissolveShader.Shader.Parameters["dissolveIntensity"].SetValue(CalamityDrawParameterNPC.DoGDeathAnimationTimer / 600f); + dissolveShader.Shader.Parameters["sampleOffset"].SetValue(noiseOffset * 0.5f); + dissolveShader.Shader.Parameters["transitionColor"].SetValue(DevourerofGodsHead.SpecialMoveColor.ToVector4()); + dissolveShader.Shader.Parameters["transitionOffset"].SetValue(0.05f); + + Main.instance.GraphicsDevice.Textures[1] = dissolveTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + dissolveShader.Apply(); } SpriteEffects spriteEffects = SpriteEffects.None; @@ -352,7 +333,7 @@ namespace CalamityMod.NPCs.DevourerofGods spriteEffects = SpriteEffects.FlipHorizontally; bool useOtherTextures = phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60f; - Texture2D texture2D15 = useOtherTextures ? Phase2Texture.Value : TextureAssets.Npc[Type].Value; + Texture2D texture2D15 = useOtherTextures ? TextureP2.Value : TextureAssets.Npc[Type].Value; Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); Vector2 drawPosition = NPC.Center - screenPos; @@ -360,21 +341,26 @@ namespace CalamityMod.NPCs.DevourerofGods drawPosition += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (!NPC.dontTakeDamage) + if ((!Main.npc[(int)NPC.ai[2]].ModNPC().isInPassiveState || !useOtherTextures) && NPC.Opacity > 0.25f) { - texture2D15 = useOtherTextures ? Phase2Texture_Glow.Value : Texture_Glow.Value; + texture2D15 = useOtherTextures ? TextureP2_Glow_Purple.Value : Texture_Glow_Purple.Value; Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = useOtherTextures ? Phase2Texture_Glow2.Value : Texture_Glow2.Value; - glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); + } + if (!Main.npc[(int)NPC.ai[2]].ModNPC().isInAgressiveState && NPC.Opacity > 0.25f) + { + texture2D15 = useOtherTextures ? TextureP2_Glow_Cyan.Value : Texture_Glow_Cyan.Value; + Color glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); + if (shouldUseShader) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(snap); + } return false; } @@ -407,7 +393,7 @@ namespace CalamityMod.NPCs.DevourerofGods { NPC.soundDelay = 8; float extrapitch = Main.zenithWorld ? 0.3f : 0f; - SoundEngine.PlaySound(CommonCalamitySounds.OtherwordlyHitSound with { Pitch = CommonCalamitySounds.OtherwordlyHitSound.Pitch + extrapitch }, NPC.Center); + SoundEngine.PlaySound(DevourerofGodsHead.HitSound with { Pitch = DevourerofGodsHead.HitSound.Pitch + extrapitch }, NPC.Center); } if (NPC.life <= 0) { @@ -450,15 +436,10 @@ namespace CalamityMod.NPCs.DevourerofGods { // viable???, done here since it's conditional if (Main.zenithWorld && projectile.type == ModContent.ProjectileType()) - { modifiers.SourceDamage *= 40f; - } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; public override bool CheckDead() { @@ -483,16 +464,6 @@ namespace CalamityMod.NPCs.DevourerofGods public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - { - target.AddBuff(ModContent.BuffType(), 120, true); - target.AddBuff(ModContent.BuffType(), 360, true); - } } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsTailGlow2.png b/NPCs/DevourerofGods/DevourerofGodsTail_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsTail_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailGlow.png b/NPCs/DevourerofGods/DevourerofGodsTail_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailGlow.png rename to NPCs/DevourerofGods/DevourerofGodsTail_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailS.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailS.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailSGlow2.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailSGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailSGlow.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailSGlow.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2_Head_Boss.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2_Head_Boss.png diff --git a/NPCs/DevourerofGods/DoGSky.cs b/NPCs/DevourerofGods/DoGSky.cs deleted file mode 100644 index 4fe73de101..0000000000 --- a/NPCs/DevourerofGods/DoGSky.cs +++ /dev/null @@ -1,148 +0,0 @@ -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Effects; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - public class DoGSky : CustomSky - { - private bool isActive = false; - private float intensity = 0f; - private int DoGIndex = -1; - - public override void Update(GameTime gameTime) - { - if (DoGIndex == -1) - { - UpdateDoGIndex(); - if (DoGIndex == -1 && Main.LocalPlayer.Calamity().monolithDevourerBShader <= 0 && Main.LocalPlayer.Calamity().monolithDevourerPShader <= 0) - isActive = false; - } - - if (isActive && intensity < 1f) - { - intensity += 0.01f; - } - else if (!isActive && intensity > 0f) - { - intensity -= 0.01f; - } - } - - private float GetIntensity() - { - if (UpdateDoGIndex()) - { - float x = 0f; - if (DoGIndex != -1) - x = Vector2.Distance(Main.LocalPlayer.Center, Main.npc[DoGIndex].Center); - - float intensityScalar = 0.5f; - return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; - } - return 0f; - } - - public override Color OnTileColor(Color inColor) - { - float intensity = GetIntensity(); - return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); - } - - private bool UpdateDoGIndex() - { - int DoGType = ModContent.NPCType(); - if (DoGIndex >= 0 && Main.npc[DoGIndex].active && Main.npc[DoGIndex].type == DoGType) - { - return true; - } - DoGIndex = -1; - foreach (NPC n in Main.ActiveNPCs) - { - if (n.type == DoGType) - { - DoGIndex = n.whoAmI; - break; - } - } - return DoGIndex != -1; - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - if (maxDepth >= 0 && minDepth < 0) - { - if (DoGIndex != -1) - { - if (Main.npc[DoGIndex].active) - { - float intensity = GetIntensity(); - float lifeRatio = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax; - double blackScreenLife_GateValue = (lifeRatio < 0.6f && Main.npc[DoGIndex].localAI[2] <= 2f) ? 0.15 : 0.75; - - float timeToReachNextColor = DevourerofGodsHead.SkyColorTransitionTime; - float phaseTimer = Main.npc[DoGIndex].Calamity().newAI[2]; - float colorChangeProgress = phaseTimer / timeToReachNextColor; - if (colorChangeProgress > 1f) - colorChangeProgress = 1f; - - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - Color regularSkyColor = (Main.npc[DoGIndex].ai[3] == 0f ? Color.Lerp(Color.Fuchsia, Color.Cyan, colorChangeProgress) : Color.Lerp(Color.Cyan, Color.Fuchsia, colorChangeProgress)) * intensity; - if (Main.npc[DoGIndex].life < Main.npc[DoGIndex].lifeMax * blackScreenLife_GateValue || death || Main.npc[DoGIndex].localAI[3] > 0f) - { - float blackSkyTransitionProgress = death ? 1f : Main.npc[DoGIndex].localAI[3] / timeToReachNextColor; - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), Color.Lerp(regularSkyColor, Color.Black * (intensity + 0.5f), blackSkyTransitionProgress)); - } - else - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), regularSkyColor); - } - } - else - { - if (Main.LocalPlayer.Calamity().monolithDevourerBShader > 0) - { - float intensity = MathHelper.Min(MathHelper.Lerp(0, 0.5f, (float)Main.LocalPlayer.Calamity().monolithDevourerBShader / 15), 0.45f); - Color regularSkyColor = Color.Cyan; - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), regularSkyColor * intensity); - } - if (Main.LocalPlayer.Calamity().monolithDevourerPShader > 0) - { - float intensity = MathHelper.Min(MathHelper.Lerp(0, 0.5f, (float)Main.LocalPlayer.Calamity().monolithDevourerPShader / 15), 0.45f); - Color regularSkyColor = Color.Fuchsia; - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), regularSkyColor * intensity); - } - } - } - } - - public override float GetCloudAlpha() - { - return 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - isActive = true; - } - - public override void Deactivate(params object[] args) - { - isActive = false; - } - - public override void Reset() - { - isActive = false; - } - - public override bool IsActive() - { - return isActive || intensity > 0f; - } - } -} diff --git a/NPCs/DevourerofGods/GodSlayerDashJaw.png b/NPCs/DevourerofGods/GodSlayerDashJaw.png new file mode 100644 index 0000000000..8791c0d42e Binary files /dev/null and b/NPCs/DevourerofGods/GodSlayerDashJaw.png differ diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index 9134f87a5f..f523b8cf1c 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -124,7 +124,6 @@ namespace CalamityMod.NPCs.DraedonLabThings Initialized = true; } - NPC.Calamity().ShouldFallThroughPlatforms = false; switch (CurrentState) { case BehaviorState.WalkAround: @@ -147,6 +146,7 @@ namespace CalamityMod.NPCs.DraedonLabThings } } } + public override bool? CanFallThroughPlatforms() => CurrentState == BehaviorState.WalkOnWalls; public void WalkAroundOnGround() { @@ -249,7 +249,7 @@ namespace CalamityMod.NPCs.DraedonLabThings } // If there are walls to clime on and this NPC wants to climb on some, do so. - if (WantsToClimbOnSomeWall && CalamityUtils.ParanoidTileRetrieval((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16).WallType > 0) + if (WantsToClimbOnSomeWall && CalamityUtils.ParanoidTileRetrieval((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16).WallType > WallID.None) { CurrentState = BehaviorState.WalkOnWalls; StuckCount = 0f; @@ -263,7 +263,6 @@ namespace CalamityMod.NPCs.DraedonLabThings { StuckCount = 0f; WantsToClimbOnSomeWall = false; - NPC.Calamity().ShouldFallThroughPlatforms = true; // Generate unusual movement patterns based on sines. float offsetAngle = CalamityUtils.AperiodicSin(Time / 360f, 0f, 1f) * 0.006f; diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index 0aa51994f3..3ba3fb72c2 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -4,7 +4,6 @@ using System.IO; using CalamityMod.Events; using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Potions; -using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.Projectiles.Boss; @@ -107,6 +106,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Variable to pick a different location after each attack private bool pickNewLocation = false; + // Variable used to prevent the fight from softlocking if one mech enters berserk before spawning the others + public bool berserkEarlyBugFix = false; + // Marks Apollo as a component of the Exo Mechdusa public bool exoMechdusa = false; @@ -141,21 +143,25 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo } } + public static int FireballDamage = 80; // 320 + public static int BoltDamage = 70; // 280 + public static int RocketDamage = 95; // 380 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 240; // 480 NPC.npcSlots = 5f; - NPC.GetNPCDamage(); NPC.width = 204; NPC.height = 226; NPC.defense = 100; NPC.DR_NERD(0.25f); - NPC.LifeMaxNERB(1250000, 1495000, 650000); + NPC.LifeMaxNERB(1000000, 1495000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(1, 0, 0, 0); + NPC.value = Item.buyPrice(platinum: 1); NPC.noGravity = true; NPC.noTileCollide = true; NPC.DeathSound = CommonCalamitySounds.ExoDeathSound; @@ -164,9 +170,6 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -234,10 +237,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -277,6 +279,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo otherExoMechsAlive++; exoWormAlive = true; + // Spread the early berserk bug fix variable if it has been set + if ((Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ModNPC as ThanatosHead).berserkEarlyBugFix) + berserkEarlyBugFix = true; } } if (CalamityGlobalNPC.draedonExoMechPrime != -1) @@ -288,6 +293,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo otherExoMechsAlive++; exoPrimeAlive = true; + // Spread the early berserk bug fix variable if it has been set + if ((Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ModNPC as AresBody).berserkEarlyBugFix) + berserkEarlyBugFix = true; } } @@ -407,13 +415,13 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Phase 7 - 0, 1, 2 // Gate values - float reducedTimeForGateValue = bossRush ? 48f : death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; + float reducedTimeForGateValue = death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; float reducedTimeForGateValue_Berserk = reducedTimeForGateValue * 0.5f; float normalAttackTime = 360f - reducedTimeForGateValue; float berserkAttackTime = lastMechAlive ? 225f - reducedTimeForGateValue_Berserk : 270f - reducedTimeForGateValue_Berserk; float attackPhaseGateValue = shouldGetBuffedByBerserkPhase ? berserkAttackTime : normalAttackTime; float timeToLineUpAttack = 30f; - float timeToLineUpCharge = bossRush ? 45f : death ? 60f : revenge ? 68f : expertMode ? 75f : 90f; + float timeToLineUpCharge = death ? 60f : revenge ? 68f : expertMode ? 75f : 90f; if (Main.getGoodWorld) { @@ -426,7 +434,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo float chargeLocationDistanceGateValue = 40f; // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (bossRush ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); float baseVelocity = (AIState == (int)Phase.LineUpChargeCombo ? 40f : 20f) * baseVelocityMult; // Attack gate values @@ -434,7 +442,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo bool doBigAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f + timeToLineUpAttack; // Charge velocity - float chargeVelocity = bossRush ? 115f : death ? 105f : revenge ? 101.25f : expertMode ? 97.5f : 90f; + float chargeVelocity = death ? 105f : revenge ? 101.25f : expertMode ? 97.5f : 90f; if (Main.getGoodWorld) { @@ -669,6 +677,10 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); } + + // If the mech somehow got low enough to enter berserk phase here, trigger the bug fix variable + if (lifeRatio < 0.4f) + berserkEarlyBugFix = true; } } else @@ -852,14 +864,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo AIState = (float)Phase.Normal; // Enter the fight again if any of the other exo mechs is below 70% or dead and other mechs aren't berserk - // CIT 10FEB2025: Added checks for if the other mechs are alive, to fix softlocks if you somehow skip straight to berserk - if ((!exoWormAlive || exoWormLifeRatio < 0.7f || !exoPrimeAlive || exoPrimeLifeRatio < 0.7f) && !otherMechIsBerserk) + // CIT 24MAR2025: Actually fixed the early berserk softlock without affecting the normal fight + if ((exoWormLifeRatio < 0.7f || exoPrimeLifeRatio < 0.7f || berserkEarlyBugFix) && !otherMechIsBerserk) { // Set Artemis variables if (exoMechTwinRedAlive) { Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] = - totalOtherExoMechLifeRatio > 5f ? (float)Artemis.Artemis.SecondaryPhase.Nothing : (float)Artemis.Artemis.SecondaryPhase.Passive; + totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[1] = 0f; Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].ai[2] = 0f; @@ -980,10 +992,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - 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, Main.player[targetIndex].Center.X, Main.player[targetIndex].Center.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaVelocity, type, FireballDamage, 0f, Main.myPlayer, Main.player[targetIndex].Center.X, Main.player[targetIndex].Center.Y); } } } @@ -1044,10 +1055,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - 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, Main.player[targetIndex].Center.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, rocketVelocity, type, RocketDamage, 0f, Main.myPlayer, 0f, Main.player[targetIndex].Center.Y); } } @@ -1167,12 +1177,11 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.ForceNetUpdate(); // Plasma bolts on charge - if (Main.netMode != NetmodeID.MultiplayerClient && (!(Main.zenithWorld && !exoMechdusa) || (CalamityWorld.LegendaryMode && revenge))) // I'm not that evil (you aren't, but I am - Fab) + if (Main.netMode != NetmodeID.MultiplayerClient && !(Main.zenithWorld && !exoMechdusa)) { - int totalProjectiles = bossRush ? 16 : death ? 12 : 8; + int totalProjectiles = death ? 12 : 8; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - int damage = (int)(NPC.GetProjectileDamage(ModContent.ProjectileType()) * 0.8); float velocity = 0.5f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; @@ -1181,7 +1190,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, BoltDamage, 0f, Main.myPlayer); } } @@ -1472,18 +1481,18 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); } - public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeComboFlash; + public float FlameTrailWidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeComboFlash; - public float FlameTrailWidthFunctionBig(float completionRatio) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeComboFlash; + public float FlameTrailWidthFunctionBig(float completionRatio, Vector2 vertexPos) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeComboFlash; - public static float RibbonTrailWidthFunction(float completionRatio) + public static float RibbonTrailWidthFunction(float completionRatio, Vector2 vertexPos) { float baseWidth = Utils.GetLerpValue(1f, 0.54f, completionRatio, true) * 5f; float endTipWidth = CalamityUtils.Convert01To010(Utils.GetLerpValue(0.96f, 0.89f, completionRatio, true)) * 2.4f; return baseWidth + endTipWidth; } - public Color FlameTrailColorFunction(float completionRatio) + public Color FlameTrailColorFunction(float completionRatio, Vector2 vertexPos) { float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true); Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); @@ -1492,7 +1501,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeComboFlash * trailOpacity; } - public Color FlameTrailColorFunctionBig(float completionRatio) + public Color FlameTrailColorFunctionBig(float completionRatio, Vector2 vertexPos) { float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true) * 0.56f; Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); @@ -1503,7 +1512,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo return color; } - public Color RibbonTrailColorFunction(float completionRatio) + public Color RibbonTrailColorFunction(float completionRatio, Vector2 vertexPos) { Color startingColor = new Color(34, 40, 48); Color endColor = new Color(40, 160, 32); @@ -1639,7 +1648,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo for (int i = 0; i < 4; i++) { Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f; - PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70); + PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_,_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70); } } else @@ -1660,7 +1669,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo return false; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -1726,7 +1735,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 3; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1f); if (NPC.soundDelay == 0) { @@ -1738,14 +1747,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo { for (int num193 = 0; num193 < 2; num193++) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } for (int i = 0; i < 20; i++) { - int plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + int plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); Main.dust[plasmaDust].noGravity = true; Main.dust[plasmaDust].velocity *= 3f; - plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); Main.dust[plasmaDust].velocity *= 2f; Main.dust[plasmaDust].noGravity = true; } @@ -1806,7 +1815,6 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index 0eac5b0b48..a254f33078 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -3,18 +3,17 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Events; using CalamityMod.Graphics.Primitives; -using CalamityMod.Items; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; +using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools.SpawnBlocker; using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; @@ -41,6 +40,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { [AutoloadBossHead] + [HasPierceResist] public class AresBody : ModNPC { // Used for loot @@ -125,6 +125,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Variable used to stop the arm spawning loop private bool armsSpawned = false; + // Variable used to prevent the fight from softlocking if one mech enters berserk before spawning the others + public bool berserkEarlyBugFix = false; + // Exo Mechdusa stuff public bool exoMechdusa = false; public int neurontimer = 0; @@ -134,7 +137,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public const float deathrayTelegraphDuration_Expert = 120f; public const float deathrayTelegraphDuration_Rev = 105f; public const float deathrayTelegraphDuration_Death = 90f; - public const float deathrayTelegraphDuration_BossRush = 60f; // Total duration of the deathrays public const float deathrayDuration = 600f; @@ -184,6 +186,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { NPCID.Sets.TrailingMode[Type] = 3; NPCID.Sets.TrailCacheLength[Type] = NPC.oldPos.Length; + NPCID.Sets.NeedsExpertScaling[Type] = true; NPCID.Sets.BossBestiaryPriority.Add(Type); NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { @@ -216,20 +219,25 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } } + public static int BlenderDamage = 105; // 420 + + // Hekate (GFB) + public static int NeuronLaserDamage = 80; // 320 + public override void SetDefaults() { + NPC.damage = 0; // No contact damage NPC.npcSlots = 5f; - NPC.damage = 100; NPC.width = 220; NPC.height = 252; NPC.defense = 100; NPC.DR_NERD(0.35f); - NPC.LifeMaxNERB(1250000, 1495000, 650000); + NPC.LifeMaxNERB(1000000, 1495000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(1, 0, 0, 0); + NPC.value = Item.buyPrice(platinum: 1); NPC.noGravity = true; NPC.noTileCollide = true; NPC.DeathSound = CommonCalamitySounds.ExoDeathSound; @@ -238,9 +246,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.BossBar = ModContent.GetInstance(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -296,10 +301,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; @@ -318,17 +322,21 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { case 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); + Main.npc[lol].localAI[0] = Main.rand.Next(240); break; case 1: 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].Calamity().newAI[3] = Main.rand.Next(240); Main.npc[lol].Calamity().newAI[1] = plasmaArmStartTimer; break; case 2: 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].localAI[0] = Main.rand.Next(240); Main.npc[lol].Calamity().newAI[1] = teslaArmStartTimer; break; case 3: 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].Calamity().newAI[3] = Main.rand.Next(240); break; default: break; @@ -377,9 +385,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares Vector2 betweenR = NeuronRight + velocity * 650; Vector2 betweenL = NeuronLeft + velocity * 650; - Terraria.Audio.SoundEngine.PlaySound(CommonCalamitySounds.LaserCannonSound with { Volume = CommonCalamitySounds.LaserCannonSound.Volume - 0.2f, Pitch = CommonCalamitySounds.LaserCannonSound.Pitch + 0.2f }, NeuronRight); - Projectile.NewProjectile(NPC.GetSource_FromAI(), betweenL, betweenL + velocity, ModContent.ProjectileType(), 111, 0f, Main.myPlayer, 7, NPC.whoAmI); - Projectile.NewProjectile(NPC.GetSource_FromAI(), betweenR, betweenR + velocity, ModContent.ProjectileType(), 111, 0f, Main.myPlayer, 7, NPC.whoAmI); + SoundEngine.PlaySound(CommonCalamitySounds.LaserCannonSound with { Volume = CommonCalamitySounds.LaserCannonSound.Volume - 0.2f, Pitch = CommonCalamitySounds.LaserCannonSound.Pitch + 0.2f }, NeuronRight); + Projectile.NewProjectile(NPC.GetSource_FromAI(), betweenL, betweenL + velocity, ModContent.ProjectileType(), NeuronLaserDamage, 0f, Main.myPlayer, 7, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), betweenR, betweenR + velocity, ModContent.ProjectileType(), NeuronLaserDamage, 0f, Main.myPlayer, 7, NPC.whoAmI); } neurontimer = 0; @@ -442,6 +450,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { otherExoMechsAlive++; exoWormAlive = true; + // Spread the early berserk bug fix variable if it has been set + if ((Main.npc[CalamityGlobalNPC.draedonExoMechWorm].ModNPC as ThanatosHead).berserkEarlyBugFix) + berserkEarlyBugFix = true; } } @@ -452,6 +463,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { otherExoMechsAlive++; exoTwinsAlive = true; + // Spread the early berserk bug fix variable if it has been set + if ((Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ModNPC as Apollo.Apollo).berserkEarlyBugFix) + berserkEarlyBugFix = true; } } @@ -491,11 +505,12 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Prevent mechs from being respawned - if (otherExoMechWasFirst) + // CIT 08JUN2025: This code is pointless and makes me unable to work swapping the laser arm position. Commenting it out. + /*if (otherExoMechWasFirst) { if (NPC.ai[3] < 1f) NPC.ai[3] = 1f; - } + }*/ // Phases bool spawnOtherExoMechs = lifeRatio < 0.7f && NPC.ai[3] == 0f; @@ -592,8 +607,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X, player.Center.Y - 800f) : AIState != (float)Phase.Deathrays ? new Vector2(player.Center.X, player.Center.Y - 425f) : player.Center; // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (bossRush ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); - float baseVelocity = (EnragedState == (float)Enraged.Yes ? 28f : 20f) * baseVelocityMult; + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocity = (EnragedState == (float)Enraged.Yes ? 22f : 14f) * baseVelocityMult; float baseAcceleration = shouldGetBuffedByBerserkPhase ? 1.25f : 1f; float decelerationVelocityMult = 0.85f; @@ -674,6 +689,10 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); } + + // If the mech somehow got low enough to enter berserk phase here, trigger the bug fix variable + if (lifeRatio < 0.4f) + berserkEarlyBugFix = true; } } else @@ -751,8 +770,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares case (int)SecondaryPhase.PassiveAndImmune: // Enter the fight again if any of the other exo mechs is below 70% or dead and other mechs aren't berserk - // CIT 10FEB2025: Added checks for if the other mechs are alive, to fix softlocks if you somehow skip straight to berserk - if (((!exoWormAlive || exoWormLifeRatio < 0.7f) || (!exoTwinsAlive || exoTwinsLifeRatio < 0.7f)) && !otherMechIsBerserk) + // CIT 24MAR2025: Actually fixed the early berserk softlock without affecting the normal fight + if ((exoWormLifeRatio < 0.7f || exoTwinsLifeRatio < 0.7f || berserkEarlyBugFix) && !otherMechIsBerserk) { // Tells Ares to return to the battle in passive state and reset everything // Return to normal phases if one or more mechs have been downed @@ -870,7 +889,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares else { // Enrage if the target is more than the deathray length away - if ((distanceFromTarget > DeathrayEnrageDistance || (CalamityWorld.LegendaryMode && revenge)) && EnragedState == (float)Enraged.No) + if ((distanceFromTarget > DeathrayEnrageDistance || Main.zenithWorld) && EnragedState == (float)Enraged.No) { // Play enrage sound if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < soundDistance) @@ -880,7 +899,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Draedon comments on how foolish it is to run if (Main.netMode != NetmodeID.MultiplayerClient) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonAresEnrageText", Draedon.TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonAresEnrageText", Draedon.TextColor); // Enrage EnragedState = (float)Enraged.Yes; @@ -889,7 +908,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares calamityGlobalNPC.newAI[3] = 1f; NPC.velocity *= decelerationVelocityMult; - int totalProjectiles = bossRush ? 12 : death ? 10 : revenge ? 9 : expertMode ? 8 : 6; + int totalProjectiles = death ? 10 : revenge ? 9 : expertMode ? 8 : 6; if (Main.getGoodWorld) totalProjectiles += 4; @@ -902,8 +921,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); spinningPoint.Normalize(); - float deathrayTelegraphDuration = bossRush ? deathrayTelegraphDuration_BossRush : death ? deathrayTelegraphDuration_Death : - revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; + float deathrayTelegraphDuration = death ? deathrayTelegraphDuration_Death : revenge ? deathrayTelegraphDuration_Rev : + expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; calamityGlobalNPC.newAI[2] += (EnragedState == (float)Enraged.Yes && calamityGlobalNPC.newAI[2] % 2f == 0f) ? 2f : 1f; if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) @@ -973,12 +992,11 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 spawnPoint = NPC.Center + new Vector2(-1f, 23f); for (int k = 0; k < totalProjectiles; k++) { Vector2 laserVelocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPoint + Vector2.Normalize(laserVelocity) * 35f, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPoint + Vector2.Normalize(laserVelocity) * 35f, laserVelocity, type, BlenderDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -1087,8 +1105,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { scale = 2f; @@ -1302,12 +1318,12 @@ namespace CalamityMod.NPCs.ExoMechs.Ares return false; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return MathHelper.Lerp(0.5f, 1.3f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * NPC.scale; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { Color baseColor1 = EnragedState == (float)Enraged.Yes ? Color.Red : Color.Cyan; Color baseColor2 = EnragedState == (float)Enraged.Yes ? Color.IndianRed : Color.Cyan; @@ -1321,9 +1337,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares return color; } - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; + internal float BackgroundWidthFunction(float completionRatio, Vector2 vertexPos) => WidthFunction(completionRatio, vertexPos) * 4f; - public Color BackgroundColorFunction(float completionRatio) + public Color BackgroundColorFunction(float completionRatio, Vector2 vertexPos) { Color backgroundColor = EnragedState == (float)Enraged.Yes ? Color.Crimson : Color.CornflowerBlue; Color color = backgroundColor * NPC.Opacity * 0.4f; @@ -1477,7 +1493,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -1589,7 +1605,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // GFB Broken Water Filter var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); } // Lore item @@ -1607,7 +1623,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares npcLoot.Add(ItemDropRule.BossBagByCondition(DropHelper.If(CanDropLoot), ModContent.ItemType())); // Legendary seed soup - mainDrops.Add(ItemDropRule.ByCondition(DropHelper.If(info => info.npc.type == ModContent.NPCType() && info.npc.ModNPC().exoMechdusa), ModContent.ItemType()), hideLootReport: true); + mainDrops.Add(ItemDropRule.ByCondition(DropHelper.If(info => info.npc.type == ModContent.NPCType() && info.npc.ModNPC().exoMechdusa), ModContent.ItemType()), hideLootReport: true); // All other drops are contained in the bag, so they only drop directly on Normal if (!Main.expertMode) @@ -1634,7 +1650,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Equipment normalOnly.Add(ModContent.ItemType()); - normalOnly.Add(ModContent.ItemType()); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(ModContent.ItemType()); // Vanity // Higher chance due to how the drops work @@ -1650,7 +1667,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 3; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1f); if (NPC.soundDelay == 0) { @@ -1662,14 +1679,14 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { for (int i = 0; i < 2; i++) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } for (int j = 0; j < 20; j++) { - int plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + int plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); Main.dust[plasmaDust].noGravity = true; Main.dust[plasmaDust].velocity *= 3f; - plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); Main.dust[plasmaDust].velocity *= 2f; Main.dust[plasmaDust].noGravity = true; } @@ -1692,7 +1709,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * 0.8f); } } } diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs index 29284604a7..876ab64252 100644 --- a/NPCs/ExoMechs/Ares/AresGaussNuke.cs +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -19,6 +19,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { + [HasPierceResist] public class AresGaussNuke : ModNPC { public enum Phase @@ -78,21 +79,25 @@ namespace CalamityMod.NPCs.ExoMechs.Ares this.HideFromBestiary(); NPCID.Sets.TrailingMode[Type] = 3; NPCID.Sets.TrailCacheLength[Type] = NPC.oldPos.Length; + NPCID.Sets.NeedsExpertScaling[Type] = true; if (!Main.dedServ) { GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); } } + public static int NukeDamage = 135; // 540 + public static int SparkDamage = 70; // 280 + public override void SetDefaults() { + NPC.damage = 0; // No contact damage NPC.npcSlots = 5f; - NPC.damage = 100; NPC.width = 170; NPC.height = 120; NPC.defense = 100; NPC.DR_NERD(0.35f); - NPC.LifeMaxNERB(1250000, 1495000, 650000); + NPC.LifeMaxNERB(1000000, 1495000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; @@ -105,9 +110,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.hide = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -145,10 +147,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; @@ -231,8 +232,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.Opacity = 0f; } + // Global timer used for passive movement + NPC.Calamity().newAI[3]++; + if (NPC.Calamity().newAI[3] >= 240f) + NPC.Calamity().newAI[3] = 0f; + // Predictiveness - float predictionAmt = bossRush ? 20f : death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; + float predictionAmt = death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; if (nerfedAttacks) predictionAmt *= 0.5f; if (passivePhase) @@ -301,10 +307,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Default vector to fly to - float offsetX = 560f; - float offsetY = 0f; - float offsetX2 = 540f; - float offsetY2 = 540f; + Vector2 offset = new Vector2(560f, 20f * (float)Math.Sin(NPC.Calamity().newAI[3] * MathHelper.Pi / 120f)); + Vector2 offset2 = new Vector2(540f, 540f); switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) { case 0: @@ -315,15 +319,14 @@ namespace CalamityMod.NPCs.ExoMechs.Ares case 1: case 2: case 5: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; + offset.X *= -1f; + offset2 *= -1f; break; } - Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); + Vector2 destination = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center + (calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? offset2 : offset); // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (bossRush ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; baseVelocity *= 1f + Main.npc[(int)NPC.ai[2]].localAI[2]; @@ -419,9 +422,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { 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, Main.player[targetIndex].Center.Y); + float nukeOffset = 40f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(gaussNukeVelocity) * nukeOffset, gaussNukeVelocity, type, NukeDamage, 0f, Main.myPlayer, 0f, Main.player[targetIndex].Center.Y); } // Recoil @@ -484,8 +486,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - public override void FindFrame(int frameHeight) { // Use telegraph frames when using gauss nuke @@ -699,7 +699,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * 0.8f); } } } diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.cs b/NPCs/ExoMechs/Ares/AresLaserCannon.cs index 5aed8336db..dadb2b924d 100644 --- a/NPCs/ExoMechs/Ares/AresLaserCannon.cs +++ b/NPCs/ExoMechs/Ares/AresLaserCannon.cs @@ -1,7 +1,6 @@ using System; using System.IO; using CalamityMod.Events; -using CalamityMod.Items.Tools; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; @@ -21,6 +20,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { + [HasPierceResist] public class AresLaserCannon : ModNPC { public enum Phase @@ -81,21 +81,25 @@ namespace CalamityMod.NPCs.ExoMechs.Ares this.HideFromBestiary(); NPCID.Sets.TrailingMode[Type] = 3; NPCID.Sets.TrailCacheLength[Type] = NPC.oldPos.Length; + NPCID.Sets.NeedsExpertScaling[Type] = true; if (!Main.dedServ) { GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); } } + public static int LaserDamage = 80; // 320 + public static int BeamDamage = 105; // 420 + public override void SetDefaults() { + NPC.damage = 0; // No contact damage NPC.npcSlots = 5f; - NPC.damage = 100; NPC.width = 154; NPC.height = 90; NPC.defense = 100; NPC.DR_NERD(0.35f); - NPC.LifeMaxNERB(1250000, 1495000, 650000); + NPC.LifeMaxNERB(1000000, 1495000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; @@ -108,9 +112,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.hide = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -118,6 +119,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares writer.Write(frameX); writer.Write(frameY); writer.Write(NPC.dontTakeDamage); + writer.Write(NPC.localAI[0]); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -127,6 +129,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares frameX = reader.ReadInt32(); frameY = reader.ReadInt32(); NPC.dontTakeDamage = reader.ReadBoolean(); + NPC.localAI[0] = reader.ReadSingle(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); } @@ -148,10 +151,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; @@ -181,6 +183,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares bool nerfedAttacks = false; if (exoTwinsAlive) nerfedAttacks = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] != (float)Apollo.Apollo.SecondaryPhase.PassiveAndImmune; + // Used to make the beam only sweep horizontally during mecha mayhem phase + bool mechaMayhem = nerfedAttacks && exoWormAlive && Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] != (float)ThanatosHead.SecondaryPhase.PassiveAndImmune; // Phases bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); @@ -234,14 +238,17 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.Opacity = 0f; } + // Global timer used for passive movement + NPC.localAI[0]++; + if (NPC.localAI[0] >= 240f) + NPC.localAI[0] = 0f; + // Variable to fire normal lasers bool fireNormalLasers = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; // Default vector to fly to - float offsetX = -560f; - float offsetY = 0f; - float offsetX2 = -540f; - float offsetY2 = -540f; + Vector2 offset = new Vector2(-560f, AIState == (int)Phase.Deathray ? 0f : 20f * (float)Math.Sin(NPC.localAI[0] * MathHelper.Pi / 120f)); + Vector2 offset2 = new Vector2(-540f, -540f); bool flyLeft = true; switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) { @@ -253,13 +260,12 @@ namespace CalamityMod.NPCs.ExoMechs.Ares case 1: case 2: case 5: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; + offset.X *= -1f; + offset2 *= -1f; flyLeft = false; break; } - Vector2 destination = fireNormalLasers ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); + Vector2 destination = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center + (fireNormalLasers ? offset2 : offset); // Rotate the cannon to look at the target while not firing the beam // Rotate the cannon to look in the direction it will fire only while it's charging or while it's firing @@ -320,7 +326,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (bossRush ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; baseVelocity *= 1f + Main.npc[(int)NPC.ai[2]].localAI[2]; float baseAcceleration = shouldGetBuffedByBerserkPhase ? 1.25f : 1f; @@ -341,7 +347,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares else if (shouldGetBuffedByBerserkPhase) deathrayPhaseGateValue *= 0.5f; - float deathrayPhaseVelocity = (nerfedAttacks ? 6f : passivePhase ? 9f : 12f) * baseVelocityMult; + float deathrayPhaseVelocity = (nerfedAttacks ? 8f : passivePhase ? 9f : 12f) * baseVelocityMult; if (lastMechAlive) deathrayPhaseVelocity *= 1.2f; else if (shouldGetBuffedByBerserkPhase) @@ -351,8 +357,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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 : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; + float deathraySpiralTelegraphDuration = death ? AresBody.deathrayTelegraphDuration_Death : revenge ? AresBody.deathrayTelegraphDuration_Rev : + expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; // Variable to disable deathray firing bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || @@ -450,10 +456,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); 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, Main.player[targetIndex].Center, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Vector2 laserOffset = laserVelocity * 70f + Vector2.UnitY * 16f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserOffset, Main.player[targetIndex].Center, type, LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -481,15 +486,14 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - float offset = 84f; - float offset2 = 16f; - Vector2 source = horizontalLaserSweep ? new Vector2(NPC.Center.X - offset2 * NPC.direction, NPC.Center.Y + offset) : new Vector2(NPC.Center.X + offset * NPC.direction, NPC.Center.Y + offset2); + float beamOffset = 84f; + float beamOffset2 = 16f; + Vector2 source = horizontalLaserSweep ? new Vector2(NPC.Center.X - beamOffset2 * NPC.direction, NPC.Center.Y + beamOffset) : new Vector2(NPC.Center.X + beamOffset * NPC.direction, NPC.Center.Y + beamOffset2); Vector2 laserVelocity = Vector2.Normalize(lookAt - source); if (laserVelocity.HasNaNs()) laserVelocity = -Vector2.UnitY; - Projectile.NewProjectile(NPC.GetSource_FromAI(), source, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, laserVelocity, type, BeamDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -507,10 +511,21 @@ namespace CalamityMod.NPCs.ExoMechs.Ares AIState = (float)Phase.Nothing; calamityGlobalNPC.newAI[2] = 0f; - // Change deathray sweep type for next deathray phase + // Change deathray sweep type for next deathray phase; this does not affect anything during mecha mayhem calamityGlobalNPC.newAI[3] += 1f; if (calamityGlobalNPC.newAI[3] > 1f) calamityGlobalNPC.newAI[3] = 0f; + + // If mecha mayhem, make Ares swap the position of the laser and gauss arms, and ensure the beam always sweeps horizontal + if (mechaMayhem) + { + calamityGlobalNPC.newAI[3] = 0f; + if (Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] == 0f) + Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] = 1f; + else + Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3] = 0f; + Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ForceNetUpdate(); + } } break; @@ -531,8 +546,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - public override void FindFrame(int frameHeight) { // Use telegraph frames when using deathrays @@ -746,7 +759,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * 0.8f); } } } diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs index fc227df3a3..7a94a62176 100644 --- a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -1,7 +1,6 @@ using System; using System.IO; using CalamityMod.Events; -using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; @@ -20,6 +19,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { + [HasPierceResist] public class AresPlasmaFlamethrower : ModNPC { public enum Phase @@ -75,21 +75,25 @@ namespace CalamityMod.NPCs.ExoMechs.Ares this.HideFromBestiary(); NPCID.Sets.TrailingMode[Type] = 3; NPCID.Sets.TrailCacheLength[Type] = NPC.oldPos.Length; + NPCID.Sets.NeedsExpertScaling[Type] = true; if (!Main.dedServ) { GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); } } + public static int FireballDamage = 80; // 320 + public static int BoltDamage = 70; // 280 + public override void SetDefaults() { + NPC.damage = 0; // No contact damage NPC.npcSlots = 5f; - NPC.damage = 100; NPC.width = 152; NPC.height = 90; NPC.defense = 100; NPC.DR_NERD(0.35f); - NPC.LifeMaxNERB(1250000, 1495000, 650000); + NPC.LifeMaxNERB(1000000, 1495000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; @@ -102,9 +106,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.hide = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -144,10 +145,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; @@ -230,8 +230,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.Opacity = 0f; } + // Global timer used for passive movement + NPC.Calamity().newAI[3]++; + if (NPC.Calamity().newAI[3] >= 240f) + NPC.Calamity().newAI[3] = 0f; + // Predictiveness - float predictionAmt = bossRush ? 20f : death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; + float predictionAmt = death ? 15f : revenge ? 13.75f : expertMode ? 12.5f : 10f; if (nerfedAttacks) predictionAmt *= 0.5f; if (passivePhase) @@ -313,10 +318,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Default vector to fly to - float offsetX = 375f; - float offsetY = 160f; - float offsetX2 = 540f; - float offsetY2 = -540f; + Vector2 offset = new Vector2(375f, 160f + 20f * (float)Math.Sin(NPC.Calamity().newAI[3] * MathHelper.Pi / 120f)); + Vector2 offset2 = new Vector2(540, -540f); switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) { case 0: @@ -327,15 +330,14 @@ namespace CalamityMod.NPCs.ExoMechs.Ares case 2: case 3: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; + offset.X *= -1f; + offset2 *= -1f; break; } - Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); + Vector2 destination = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center + (calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? offset2 : offset); // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (bossRush ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; baseVelocity *= 1f + Main.npc[(int)NPC.ai[2]].localAI[2]; @@ -351,8 +353,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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 : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; + float deathrayTelegraphDuration = death ? AresBody.deathrayTelegraphDuration_Death : revenge ? AresBody.deathrayTelegraphDuration_Rev : + expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; // Variable to cancel plasma bolt firing bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || @@ -441,13 +443,12 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 offset = Vector2.Normalize(plasmaBoltVelocity) * 40f + Vector2.UnitY * 16f; + Vector2 plasmaOffset = Vector2.Normalize(plasmaBoltVelocity) * 40f + Vector2.UnitY * 16f; if (boltsSplitLess) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, -1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + plasmaOffset, plasmaBoltVelocity, type, FireballDamage, 0f, Main.myPlayer, -1f); else - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, Main.player[targetIndex].Center.X, Main.player[targetIndex].Center.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + plasmaOffset, plasmaBoltVelocity, type, FireballDamage, 0f, Main.myPlayer, Main.player[targetIndex].Center.X, Main.player[targetIndex].Center.Y); } // Recoil @@ -484,8 +485,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - public override void FindFrame(int frameHeight) { // Use telegraph frames when using plasma bolts @@ -697,7 +696,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * 0.8f); } } } diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index e4dc3a1fb2..222bc247ac 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -19,6 +19,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Ares { + [HasPierceResist] public class AresTeslaCannon : ModNPC { public enum Phase @@ -76,21 +77,24 @@ namespace CalamityMod.NPCs.ExoMechs.Ares this.HideFromBestiary(); NPCID.Sets.TrailingMode[Type] = 3; NPCID.Sets.TrailCacheLength[Type] = NPC.oldPos.Length; + NPCID.Sets.NeedsExpertScaling[Type] = true; if (!Main.dedServ) { GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); } } + public static int OrbDamage = 80; // 320 + public override void SetDefaults() { + NPC.damage = 0; // No contact damage NPC.npcSlots = 5f; - NPC.damage = 100; NPC.width = 172; NPC.height = 108; NPC.defense = 100; NPC.DR_NERD(0.35f); - NPC.LifeMaxNERB(1250000, 1495000, 650000); + NPC.LifeMaxNERB(1000000, 1495000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; @@ -103,9 +107,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.hide = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -113,6 +114,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares writer.Write(frameX); writer.Write(frameY); writer.Write(NPC.dontTakeDamage); + writer.Write(NPC.localAI[0]); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -122,6 +124,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares frameX = reader.ReadInt32(); frameY = reader.ReadInt32(); NPC.dontTakeDamage = reader.ReadBoolean(); + NPC.localAI[0] = reader.ReadSingle(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); } @@ -143,10 +146,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; @@ -229,8 +231,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares NPC.Opacity = 0f; } + // Global timer used for passive movement + NPC.localAI[0]++; + if (NPC.localAI[0] >= 240f) + NPC.localAI[0] = 0f; + // Predictiveness - float predictionAmt = bossRush ? 40f : death ? 30f : revenge ? 27.5f : expertMode ? 25f : 20f; + float predictionAmt = death ? 30f : revenge ? 27.5f : expertMode ? 25f : 20f; if (nerfedAttacks) predictionAmt *= 0.5f; if (passivePhase) @@ -314,10 +321,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } // Default vector to fly to - float offsetX = -375f; - float offsetY = 160f; - float offsetX2 = -540f; - float offsetY2 = 540f; + Vector2 offset = new Vector2(-375f, 160f + 20f * (float)Math.Sin(NPC.localAI[0] * MathHelper.Pi / 120f)); + Vector2 offset2 = new Vector2(-540f, 540f); switch ((int)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ai[3]) { case 0: @@ -328,15 +333,14 @@ namespace CalamityMod.NPCs.ExoMechs.Ares case 2: case 3: - offsetX *= -1f; - offsetX2 *= -1f; - offsetY2 *= -1f; + offset.X *= -1f; + offset2 *= -1f; break; } - Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX2, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY2) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + offsetX, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + offsetY); + Vector2 destination = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center + (calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? offset2 : offset); // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (bossRush ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); float baseVelocity = (enraged ? 38f : 30f) * baseVelocityMult; baseVelocity *= 1f + Main.npc[(int)NPC.ai[2]].localAI[2]; @@ -349,8 +353,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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 : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; + float deathrayTelegraphDuration = death ? AresBody.deathrayTelegraphDuration_Death : revenge ? AresBody.deathrayTelegraphDuration_Rev : + expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; // Variable to cancel tesla orb firing bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune || @@ -438,10 +442,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 offset = Vector2.Normalize(teslaOrbVelocity) * 40f + Vector2.UnitY * 8f; + Vector2 orbOffset = Vector2.Normalize(teslaOrbVelocity) * 40f + Vector2.UnitY * 8f; float identity = fireMoreOrbs ? -2f : calamityGlobalNPC.newAI[3] + (calamityGlobalNPC.newAI[2] - teslaOrbTelegraphDuration) / divisor; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, teslaOrbVelocity, type, damage, 0f, Main.myPlayer, identity); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + orbOffset, teslaOrbVelocity, type, OrbDamage, 0f, Main.myPlayer, identity); } // Recoil @@ -479,8 +482,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - public override void FindFrame(int frameHeight) { // Use telegraph frames when using tesla orbs @@ -691,7 +692,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * 0.8f); } } } diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index 7818bae958..390721b462 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -174,16 +174,19 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis } } + public static int LaserDamage = 80; // 320 + public static int BeamDamage = 105; // 420 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 190; // 380 NPC.npcSlots = 5f; - NPC.GetNPCDamage(); NPC.width = 204; NPC.height = 226; NPC.defense = 100; NPC.DR_NERD(0.25f); - NPC.LifeMaxNERB(1250000, 1495000, 650000); + NPC.LifeMaxNERB(1000000, 1495000, 650000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; @@ -196,9 +199,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis NPC.BossBar = ModContent.GetInstance(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -270,10 +270,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -450,7 +449,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Phase 7 - 0, 1, 2 // Gate values - float reducedTimeForGateValue = bossRush ? 48f : death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; + float reducedTimeForGateValue = death ? 32f : revenge ? 24f : expertMode ? 16f : 0f; float reducedTimeForGateValue_Berserk = reducedTimeForGateValue * 0.5f; float normalAttackTime = 360f - reducedTimeForGateValue; float berserkAttackTime = lastMechAlive ? 225f - reducedTimeForGateValue_Berserk : 270f - reducedTimeForGateValue_Berserk; @@ -494,7 +493,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis float movementDistanceGateValue = 100f; // Charge variables - float chargeVelocity = nerfedAttacks ? 60f : bossRush ? 81f : death ? 74f : revenge ? 70.5f : expertMode ? 67f : 60f; + float chargeVelocity = nerfedAttacks ? 60f : death ? 74f : revenge ? 70.5f : expertMode ? 67f : 60f; if (Main.getGoodWorld) chargeVelocity *= 1.15f; @@ -517,7 +516,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis predictionAmt *= 0.5f; // Velocity and acceleration values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (bossRush ? 1.15f : death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.25f : 0f) + (death ? 1.1f : revenge ? 1.075f : expertMode ? 1.05f : 1f); float baseVelocity = ((AIState == (int)Phase.Deathray || lineUpAttack || AIState == (int)Phase.LaserShotgun) ? 40f : 20f) * baseVelocityMult; float decelerationVelocityMult = 0.85f; @@ -777,10 +776,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 offset = laserVelocity * 70f; float setVelocityInAI = 7.5f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, projectileDestination, type, damage, 0f, Main.myPlayer, setVelocityInAI, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + offset, projectileDestination, type, LaserDamage, 0f, Main.myPlayer, setVelocityInAI, NPC.whoAmI); } } } @@ -832,10 +830,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 laserVelocity = chargeVelocityNormalized * 10f; - int numLasersPerSpread = bossRush ? 10 : death ? 8 : expertMode ? 6 : 4; - int spread = bossRush ? 30 : death ? 26 : expertMode ? 21 : 15; + int numLasersPerSpread = death ? 8 : expertMode ? 6 : 4; + int spread = death ? 26 : expertMode ? 21 : 15; float rotation = MathHelper.ToRadians(spread); float distanceFromTarget = Vector2.Distance(NPC.Center, NPC.Center + chargeVelocityNormalized * chargeDistance); float setVelocityInAI = death ? 7f : revenge ? 6.75f : expertMode ? 6.5f : 6f; @@ -848,7 +845,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis Vector2 offset = normalizedPerturbedSpeed * 70f; Vector2 newCenter = NPC.Center + offset; - Projectile.NewProjectile(NPC.GetSource_FromAI(), newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, damage, 0f, Main.myPlayer, setVelocityInAI, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, LaserDamage, 0f, Main.myPlayer, setVelocityInAI, NPC.whoAmI); } } } @@ -929,14 +926,13 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis Vector2 laserVelocity = Vector2.Normalize(aimedVector) * 10f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); /* Spread: * lastMechAlive = 20, 25, 30 * normal = 16, 20, 24 * nerfedAttacks = 12, 15, 18 */ - int numLasersAddedByDifficulty = bossRush ? 3 : death ? 2 : expertMode ? 1 : 0; + int numLasersAddedByDifficulty = death ? 2 : expertMode ? 1 : 0; int numLasersPerSpread = ((nerfedAttacks || nerfedLaserShotgun) ? 3 : lastMechAlive ? 7 : 5) + numLasersAddedByDifficulty; int baseSpread = ((nerfedAttacks || nerfedLaserShotgun) ? 9 : lastMechAlive ? 20 : 15) + numLasersAddedByDifficulty * 2; int spread = baseSpread + (int)(calamityGlobalNPC.newAI[2] / divisor2) * (baseSpread / 4); @@ -954,7 +950,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis Vector2 newCenter = NPC.Center + offset; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, damage, 0f, Main.myPlayer, setVelocityInAI, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, LaserDamage, 0f, Main.myPlayer, setVelocityInAI, NPC.whoAmI); } } @@ -1087,8 +1083,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - int laser = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, NPC.whoAmI); + int laser = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, BeamDamage, 0f, Main.myPlayer, NPC.whoAmI); if (Main.projectile.IndexInRange(laser)) { Main.projectile[laser].ai[0] = NPC.whoAmI; @@ -1099,7 +1094,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis else { // This first variable is used to adjust how long it takes for the rotation rate to reach max - float rotationSpeedMult = bossRush ? 6.66f : death ? 4f : revenge ? 3f : expertMode ? 2.5f : 2f; + float rotationSpeedMult = death ? 4f : revenge ? 3f : expertMode ? 2.5f : 2f; // This is used to adjust both the radians and the velocity of the spin moved per frame // At 15% progress it will be at max rotation in Boss Rush @@ -1367,18 +1362,18 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); } - public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeFlash; + public float FlameTrailWidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.SmoothStep(21f, 8f, completionRatio) * ChargeFlash; - public float FlameTrailWidthFunctionBig(float completionRatio) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeFlash; + public float FlameTrailWidthFunctionBig(float completionRatio, Vector2 vertexPos) => MathHelper.SmoothStep(34f, 12f, completionRatio) * ChargeFlash; - public float RibbonTrailWidthFunction(float completionRatio) + public float RibbonTrailWidthFunction(float completionRatio, Vector2 vertexPos) { float baseWidth = Utils.GetLerpValue(1f, 0.54f, completionRatio, true) * 5f; float endTipWidth = CalamityUtils.Convert01To010(Utils.GetLerpValue(0.96f, 0.89f, completionRatio, true)) * 2.4f; return baseWidth + endTipWidth; } - public Color FlameTrailColorFunction(float completionRatio) + public Color FlameTrailColorFunction(float completionRatio, Vector2 vertexPos) { float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true); Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.27f); @@ -1387,7 +1382,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * ChargeFlash * trailOpacity; } - public Color FlameTrailColorFunctionBig(float completionRatio) + public Color FlameTrailColorFunctionBig(float completionRatio, Vector2 vertexPos) { float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true) * 0.56f; Color startingColor = Color.Lerp(Color.White, Color.Cyan, 0.25f); @@ -1398,7 +1393,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis return color; } - public Color RibbonTrailColorFunction(float completionRatio) + public Color RibbonTrailColorFunction(float completionRatio, Vector2 vertexPos) { Color startingColor = new Color(34, 40, 48); Color endColor = new Color(219, 82, 28); @@ -1534,7 +1529,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis for (int i = 0; i < 4; i++) { Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f; - PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70); + PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_,_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70); } } else @@ -1557,7 +1552,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 3; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1f); if (NPC.soundDelay == 0) { @@ -1569,14 +1564,14 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis { for (int i = 0; i < 2; i++) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } for (int j = 0; j < 20; j++) { - int plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + int plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); Main.dust[plasmaDust].noGravity = true; Main.dust[plasmaDust].velocity *= 3f; - plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + plasmaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Terra, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); Main.dust[plasmaDust].velocity *= 2f; Main.dust[plasmaDust].noGravity = true; } @@ -1592,7 +1587,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -1619,7 +1614,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/ExoMechs/Draedon.cs b/NPCs/ExoMechs/Draedon.cs index 5527da2298..985b98211a 100644 --- a/NPCs/ExoMechs/Draedon.cs +++ b/NPCs/ExoMechs/Draedon.cs @@ -14,7 +14,6 @@ using Terraria; using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; -using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -112,6 +111,9 @@ namespace CalamityMod.NPCs.ExoMechs } } + // GFB + public static int PulseRifleDamage = 100; // 400 + public override void SetDefaults() { NPC.damage = 0; @@ -247,7 +249,7 @@ namespace CalamityMod.NPCs.ExoMechs NPC.Opacity = MathHelper.Clamp(NPC.Opacity + 0.05f, 0f, 1f); KillReappearTextCountdown--; if (KillReappearTextCountdown == 20) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndKillAttemptText", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndKillAttemptText", TextColor); return; } @@ -275,25 +277,25 @@ namespace CalamityMod.NPCs.ExoMechs { if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText1", TextColor); NPC.netUpdate = true; } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText2", TextColor); NPC.netUpdate = true; } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine * 2f) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText3", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText3", TextColor); NPC.netUpdate = true; } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine * 3f) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText4", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText4", TextColor); NPC.netUpdate = true; } @@ -301,11 +303,11 @@ namespace CalamityMod.NPCs.ExoMechs if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine * 4f) { if (bossRush) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonBossRushText", TextColorEdgy); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonBossRushText", TextColorEdgy); else if (CalamityWorld.TalkedToDraedon) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonResummonText", TextColorEdgy); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonResummonText", TextColorEdgy); else - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText5", TextColorEdgy); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonIntroductionText5", TextColorEdgy); // Mark Draedon as talked to. if (!CalamityWorld.TalkedToDraedon) @@ -342,7 +344,7 @@ namespace CalamityMod.NPCs.ExoMechs { if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonMechdusaBeginText", TextColorEdgy); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonMechdusaBeginText", TextColorEdgy); NPC.netUpdate = true; } @@ -396,13 +398,13 @@ namespace CalamityMod.NPCs.ExoMechs if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase1Text1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase1Text1", TextColor); NPC.netUpdate = true; } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime + DelayPerDialogLine) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase1Text2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase1Text2", TextColor); NPC.netUpdate = true; } @@ -415,14 +417,14 @@ namespace CalamityMod.NPCs.ExoMechs SoundEngine.PlaySound(LaughSound, PlayerToFollow.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase2Text1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase2Text1", TextColor); NPC.netUpdate = true; } } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime + DelayPerDialogLine) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase2Text2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase2Text2", TextColor); NPC.netUpdate = true; } @@ -432,7 +434,7 @@ namespace CalamityMod.NPCs.ExoMechs if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase3Text1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase3Text1", TextColor); NPC.netUpdate = true; } @@ -441,7 +443,7 @@ namespace CalamityMod.NPCs.ExoMechs SoundEngine.PlaySound(LaughSound, PlayerToFollow.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase3Text2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase3Text2", TextColor); NPC.netUpdate = true; } } @@ -452,13 +454,13 @@ namespace CalamityMod.NPCs.ExoMechs if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase4Text1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase4Text1", TextColor); NPC.netUpdate = true; } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime + DelayPerDialogLine) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase4Text2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase4Text2", TextColor); NPC.netUpdate = true; } @@ -468,13 +470,13 @@ namespace CalamityMod.NPCs.ExoMechs if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase5Text1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase5Text1", TextColor); NPC.netUpdate = true; } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime + DelayPerDialogLine) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase5Text2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase5Text2", TextColor); NPC.netUpdate = true; } @@ -484,13 +486,13 @@ namespace CalamityMod.NPCs.ExoMechs if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase6Text1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase6Text1", TextColor); NPC.netUpdate = true; } if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == ExoMechPhaseDialogueTime + DelayPerDialogLine) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase6Text2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase6Text2", TextColor); NPC.netUpdate = true; } @@ -499,7 +501,7 @@ namespace CalamityMod.NPCs.ExoMechs SoundEngine.PlaySound(LaughSound, PlayerToFollow.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase6Text3", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonExoPhase6Text3", TextColor); NPC.netUpdate = true; } } @@ -524,7 +526,7 @@ namespace CalamityMod.NPCs.ExoMechs Vector2 shoot = PlayerToFollow.Center - NPC.Center; shoot.Normalize(); shoot *= 4; - int p = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center - Vector2.UnitY * 30, shoot, ModContent.ProjectileType(), 116, 0, Main.myPlayer); + int p = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center - Vector2.UnitY * 30, shoot, ModContent.ProjectileType(), PulseRifleDamage, 0, Main.myPlayer); if (p.WithinBounds(Main.maxProjectiles)) { Main.projectile[p].timeLeft *= 2; @@ -683,43 +685,43 @@ namespace CalamityMod.NPCs.ExoMechs if (exoMechdusa && Main.netMode != NetmodeID.MultiplayerClient) { if (DefeatTimer == DelayBeforeDefeatStandup + 50f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonMechdusaEndText1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonMechdusaEndText1", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay + 50f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonMechdusaEndText2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonMechdusaEndText2", TextColor); } // Otherwise do normal text else if (Main.netMode != NetmodeID.MultiplayerClient) { if (DefeatTimer == DelayBeforeDefeatStandup + 50f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText1", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText1", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay + 50f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText2", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText2", TextColor); // After this point Draedon becomes vulnerable. // He sits back down as well as he thinks for a bit. // Killing him will cause gore to appear but also for Draedon to come back as a hologram. if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay * 2f + 50f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText3", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText3", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay * 3f + 165f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText4", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText4", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay * 4f + 165f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText5", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText5", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay * 5f + 165f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText6", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText6", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay * 6f + 165f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText7", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText7", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay * 7f + 165f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText8", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText8", TextColor); if (DefeatTimer == DelayBeforeDefeatStandup + TalkDelay * 8f + 165f) - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText9", TextColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.DraedonEndText9", TextColor); } } @@ -794,7 +796,7 @@ namespace CalamityMod.NPCs.ExoMechs if (NPC.life > 0) return; - if (!Main.dedServ && !HasBeenKilled) + if (!Main.dedServ && !HasBeenKilled && HologramEffectTimer > 0f) { for (int i = 1; i <= 4; i++) { diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index b34e664e92..63d10f0991 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -17,6 +17,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Thanatos { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(ThanatosHead))] public class ThanatosBody1 : ModNPC { @@ -64,8 +65,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 150; // 300 NPC.npcSlots = 5f; - NPC.GetNPCDamage(); NPC.width = 88; NPC.height = 88; NPC.defense = 100; @@ -87,9 +88,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void BossHeadSlot(ref int index) @@ -140,10 +138,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.life = Main.npc[(int)NPC.ai[1]].life; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Check if other segments are still alive, if not, die bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); @@ -253,7 +250,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.Calamity().newAI[0] == 0f) NPC.ai[3] += 1f; - double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; + double numSegmentsAbleToFire = death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; if (shouldGetBuffedByBerserkPhase) numSegmentsAbleToFire *= 1.25; @@ -305,10 +302,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { // Normal laser int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -363,12 +359,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } - float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + float predictionAmt = death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; if (NPC.ai[0] % 3f == 0f) predictionAmt *= 0.5f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); for (int i = 0; i < numProjectiles; i++) { @@ -377,7 +372,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { // Normal laser if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } else { @@ -385,18 +380,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } // Predictive laser Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); // Opposite laser projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -442,7 +437,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.chaseable = vulnerable; // Adjust DR based on vulnerable - NPC.Calamity().DR = vulnerable ? 0.15f : 0.9999f; + NPC.Calamity().DR = vulnerable ? 0.1f : 0.9999f; NPC.Calamity().unbreakableDR = !vulnerable; // Vent noise and steam @@ -521,7 +516,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } // Velocity and turn speed values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); float baseVelocity = 10f * baseVelocityMult; // Increase top velocity if target is dead or if Thanatos is uncoiling @@ -532,20 +527,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.getGoodWorld) baseVelocity *= 1.15f; - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = baseVelocity * 0.25f; - float minimalDamageVelocity = baseVelocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -689,7 +670,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 51fbaba5ae..fb5343f815 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -17,6 +17,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Thanatos { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(ThanatosHead))] public class ThanatosBody2 : ModNPC { @@ -63,8 +64,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 150; // 300 NPC.npcSlots = 5f; - NPC.GetNPCDamage(); NPC.width = 90; NPC.height = 90; NPC.defense = 100; @@ -86,9 +87,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void BossHeadSlot(ref int index) @@ -139,10 +137,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.life = Main.npc[(int)NPC.ai[1]].life; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Check if other segments are still alive, if not, die bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); @@ -252,7 +249,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.Calamity().newAI[0] == 0f) NPC.ai[3] += 1f; - double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; + double numSegmentsAbleToFire = death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; if (shouldGetBuffedByBerserkPhase) numSegmentsAbleToFire *= 1.25; @@ -304,10 +301,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { // Normal laser int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -362,12 +358,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } - float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + float predictionAmt = death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; if (NPC.ai[0] % 3f == 0f) predictionAmt *= 0.5f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); for (int i = 0; i < numProjectiles; i++) { @@ -376,7 +371,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { // Normal laser if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } else { @@ -384,18 +379,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } // Predictive laser Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); // Opposite laser projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -441,7 +436,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.chaseable = vulnerable; // Adjust DR based on vulnerable - NPC.Calamity().DR = vulnerable ? 0.15f : 0.9999f; + NPC.Calamity().DR = vulnerable ? 0.1f : 0.9999f; NPC.Calamity().unbreakableDR = !vulnerable; // Vent noise and steam @@ -524,7 +519,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } // Velocity and turn speed values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); float baseVelocity = 10f * baseVelocityMult; // Increase top velocity if target is dead or if Thanatos is uncoiling @@ -535,20 +530,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.getGoodWorld) baseVelocity *= 1.15f; - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = baseVelocity * 0.25f; - float minimalDamageVelocity = baseVelocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -694,7 +675,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index 7b418c793b..cc84bf8dba 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -22,6 +22,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Thanatos { + [HasPierceResist] [LongDistanceNetSync] public class ThanatosHead : ModNPC { @@ -32,6 +33,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public static readonly SoundStyle LaserSound = new("CalamityMod/Sounds/Custom/ExoMechs/THanosLaser"); + public static readonly SoundStyle GFBeam = new("CalamityMod/Sounds/Custom/ExoMechs/THanosGFBeam"); + + public static readonly SoundStyle ThanatosHitSoundOpen = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen", 2) { Volume = 0.5f }; public static readonly SoundStyle ThanatosHitSoundClosed = new("CalamityMod/Sounds/NPCHit/ThanatosHitClosed", 3) { Volume = 0.4f }; @@ -121,6 +125,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Variable used to stop the segment spawning loop private bool tailSpawned = false; + // Variable used to prevent the fight from softlocking if one mech enters berserk before spawning the others + public bool berserkEarlyBugFix = false; + // Used in the lerp to smoothly scale velocity up and down private float chargeVelocityScalar = 0f; @@ -159,22 +166,25 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } + public static int LaserDamage = 80; // 320 + public static int BeamDamage = 135; // 540 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 240; // 480 NPC.npcSlots = 5f; - NPC.GetNPCDamage(); NPC.width = 164; NPC.height = 164; NPC.defense = 100; NPC.DR_NERD(0.9999f); NPC.Calamity().unbreakableDR = true; - NPC.LifeMaxNERB(960000, 1150000, 600000); + NPC.LifeMaxNERB(800000, 1150000, 600000); NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(1, 0, 0, 0); + NPC.value = Item.buyPrice(platinum: 1); NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -185,9 +195,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.chaseable = false; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -246,7 +253,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); + (CalamityWorld.death ? 600f : CalamityWorld.revenge ? 700f : Main.expertMode ? 800f : 1000f) * (lastMechAlive ? 0.75f : 1f) * (Main.zenithWorld && !exoMechdusa ? 2 : Main.getGoodWorld ? 0.75f : 1f); public int CheckForOtherMechs(ref int targetIndex, out bool exoPrimeAlive, out bool exoTwinsAlive) { @@ -262,6 +269,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos otherExoMechsAlive++; exoPrimeAlive = true; + // Spread the early berserk bug fix variable if it has been set + if ((Main.npc[CalamityGlobalNPC.draedonExoMechPrime].ModNPC as AresBody).berserkEarlyBugFix) + berserkEarlyBugFix = true; } } @@ -272,6 +282,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { otherExoMechsAlive++; exoTwinsAlive = true; + // Spread the early berserk bug fix variable if it has been set + if ((Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].ModNPC as Apollo.Apollo).berserkEarlyBugFix) + berserkEarlyBugFix = true; } } return otherExoMechsAlive; @@ -284,10 +297,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos CalamityGlobalNPC.draedonExoMechWorm = NPC.whoAmI; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -505,7 +517,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos float laserBarrageLocationDistance = turnDistance * 3f; // Velocity and turn speed values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); float baseVelocity = 10f * baseVelocityMult; // Increase top velocity if target is dead or if Thanatos is uncoiling @@ -574,6 +586,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); NPC.SpawnOnPlayer(Main.player[targetIndex].whoAmI, ModContent.NPCType()); } + + // If the mech somehow got low enough to enter berserk phase here, trigger the bug fix variable + if (lifeRatio < 0.4f) + berserkEarlyBugFix = true; } } else @@ -672,8 +688,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos AIState = (float)Phase.UndergroundLaserBarrage; // Enter the fight again if any of the other exo mechs is below 70% or dead and other mechs aren't berserk - // CIT 10FEB2025: Added checks for if the other mechs are alive, to fix softlocks if you somehow skip straight to berserk - if ((!exoPrimeAlive || exoPrimeLifeRatio < 0.7f || !exoTwinsAlive || exoTwinsLifeRatio < 0.7f) && !otherMechIsBerserk) + // CIT 24MAR2025: Actually fixed the early berserk softlock without affecting the normal fight + if ((exoPrimeLifeRatio < 0.7f || exoTwinsLifeRatio < 0.7f || berserkEarlyBugFix) && !otherMechIsBerserk) { // Tells Thanatos to return to the battle in passive state and reset everything // Return to normal phases if one or more mechs have been downed @@ -889,7 +905,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { //Commented out in case we decide its better for it to simply play from anywhere in range //if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < soundDistance) - LaserSoundSlot = SoundEngine.PlaySound(LaserSound, NPC.Center); + LaserSoundSlot = SoundEngine.PlaySound((Main.zenithWorld ? GFBeam : LaserSound), NPC.Center); // Create a bunch of lightning bolts in the sky ExoMechsSky.CreateLightningBolt(12); @@ -924,8 +940,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, BeamDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -963,7 +978,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.chaseable = vulnerable; // Adjust DR based on vulnerable - NPC.Calamity().DR = vulnerable ? 0.15f : 0.9999f; + NPC.Calamity().DR = vulnerable ? 0.1f : 0.9999f; NPC.Calamity().unbreakableDR = !vulnerable; // Vent noise and steam @@ -1029,19 +1044,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } } - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = baseVelocity * 0.25f; - float minimalDamageVelocity = baseVelocity * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -1228,7 +1230,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos return false; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -1350,7 +1352,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index e3758fb789..5e888f834e 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -17,6 +17,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ExoMechs.Thanatos { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(ThanatosHead))] public class ThanatosTail : ModNPC { @@ -63,8 +64,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 120; // 240 NPC.npcSlots = 5f; - NPC.GetNPCDamage(); NPC.width = 76; NPC.height = 110; NPC.defense = 100; @@ -86,9 +87,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void BossHeadSlot(ref int index) @@ -139,10 +137,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.life = Main.npc[(int)NPC.ai[1]].life; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Check if other segments are still alive, if not, die bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); @@ -252,7 +249,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (NPC.Calamity().newAI[0] == 0f) NPC.ai[3] += 1f; - double numSegmentsAbleToFire = bossRush ? 42D : death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; + double numSegmentsAbleToFire = death ? 36D : revenge ? 34D : expertMode ? 30D : 24D; if (shouldGetBuffedByBerserkPhase) numSegmentsAbleToFire *= 1.25; @@ -304,10 +301,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { // Normal laser int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -362,12 +358,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } - float predictionAmt = bossRush ? 24f : death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; + float predictionAmt = death ? 20f : revenge ? 18f : expertMode ? 16f : 12f; if (NPC.ai[0] % 3f == 0f) predictionAmt *= 0.5f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); SoundEngine.PlaySound(CommonCalamitySounds.ExoLaserShootSound, NPC.Center); for (int i = 0; i < numProjectiles; i++) { @@ -376,7 +371,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { // Normal laser if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } else { @@ -384,18 +379,18 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (shouldGetBuffedByBerserkPhase && NPC.ai[0] % 3f == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, targetCenterArray[i], type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } // Predictive laser Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); // Opposite laser projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileDestination, type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, NPC.whoAmI); } } } @@ -441,7 +436,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos NPC.chaseable = vulnerable; // Adjust DR based on vulnerable - NPC.Calamity().DR = vulnerable ? 0.15f : 0.9999f; + NPC.Calamity().DR = vulnerable ? 0.1f : 0.9999f; NPC.Calamity().unbreakableDR = !vulnerable; // Vent noise and steam @@ -522,7 +517,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } // Velocity and turn speed values - float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); + float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f); float baseVelocity = 10f * baseVelocityMult; // Increase top velocity if target is dead or if Thanatos is uncoiling @@ -533,20 +528,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.getGoodWorld) baseVelocity *= 1.15f; - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = baseVelocity * 0.25f; - float minimalDamageVelocity = baseVelocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -693,7 +674,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index 008c2637d5..42af41cb27 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -52,12 +52,11 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.width = 300; NPC.height = 120; NPC.defense = 40; - NPC.DR_NERD(0.25f); NPC.LifeMaxNERB(9200, 11000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 5, 0, 0); + NPC.value = Item.buyPrice(gold: 5); NPCID.Sets.TrailCacheLength[Type] = 8; NPCID.Sets.TrailingMode[Type] = 1; NPC.behindTiles = true; diff --git a/NPCs/HasPierceResistAttribute.cs b/NPCs/HasPierceResistAttribute.cs new file mode 100644 index 0000000000..eff333dfd8 --- /dev/null +++ b/NPCs/HasPierceResistAttribute.cs @@ -0,0 +1,21 @@ +using System; + +namespace CalamityMod.NPCs +{ + /// + /// This attribute gives an NPC universal pierce resistance + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public sealed class HasPierceResistAttribute : Attribute + { + /// + /// Set this to true to indicate this NPC has a single large hitbox which typical piercing projectiles can hit multiple times. Certain weapons are exempt from pierce resistance on single-hitbox targets. + /// + public bool SingleHitbox { get; } + + public HasPierceResistAttribute(bool singleHitbox = false) + { + SingleHitbox = singleHitbox; + } + } +} diff --git a/NPCs/HiveMind/DankCreeper.cs b/NPCs/HiveMind/DankCreeper.cs index 758f6cac73..761fcac44b 100644 --- a/NPCs/HiveMind/DankCreeper.cs +++ b/NPCs/HiveMind/DankCreeper.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -16,7 +15,7 @@ namespace CalamityMod.NPCs.HiveMind public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 24; // 48 NPC.width = 70; NPC.height = 70; NPC.defense = 6; @@ -25,14 +24,14 @@ namespace CalamityMod.NPCs.HiveMind if (BossRushEvent.BossRushActive) NPC.lifeMax = 2000; if (Main.getGoodWorld) - NPC.lifeMax *= 4; - - if ((CalamityWorld.LegendaryMode && CalamityWorld.revenge)) + { + NPC.lifeMax *= 3; NPC.reflectsProjectiles = true; + } NPC.aiStyle = -1; AIType = -1; - NPC.knockBackResist = BossRushEvent.BossRushActive ? 0f : 0.3f; + NPC.knockBackResist = 0.3f; NPC.noGravity = true; NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit1; @@ -40,10 +39,6 @@ namespace CalamityMod.NPCs.HiveMind NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -65,11 +60,9 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - bool masterMode = Main.masterMode; + bool death = CalamityWorld.death; bool revenge = CalamityWorld.revenge; - float speed = masterMode ? 15f : revenge ? 13f : 11f; - if (BossRushEvent.BossRushActive) - speed = 18f; + float speed = death ? 15f : revenge ? 13f : 11f; if (NPC.ai[1] < 90f) NPC.ai[1] += 1f; @@ -126,7 +119,7 @@ namespace CalamityMod.NPCs.HiveMind if (hurtInfo.Damage < 0) return; - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 120); } public override void HitEffect(NPC.HitInfo hit) @@ -157,8 +150,7 @@ namespace CalamityMod.NPCs.HiveMind if ((Main.expertMode || BossRushEvent.BossRushActive) && Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, HiveMind.ShaderainDamage, 0f, Main.myPlayer); } } } diff --git a/NPCs/HiveMind/DarkHeart.cs b/NPCs/HiveMind/DarkHeart.cs index 9d4e8db3e6..7c8ef8e53e 100644 --- a/NPCs/HiveMind/DarkHeart.cs +++ b/NPCs/HiveMind/DarkHeart.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -21,7 +20,7 @@ namespace CalamityMod.NPCs.HiveMind public override void SetDefaults() { - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.width = 32; NPC.height = 32; NPC.defense = 2; @@ -30,11 +29,11 @@ namespace CalamityMod.NPCs.HiveMind if (BossRushEvent.BossRushActive) NPC.lifeMax = 1800; if (Main.getGoodWorld) - NPC.lifeMax *= 4; + NPC.lifeMax *= 3; NPC.aiStyle = -1; AIType = -1; - NPC.knockBackResist = BossRushEvent.BossRushActive ? 0f : 0.4f; + NPC.knockBackResist = 0.4f; NPC.noGravity = true; NPC.HitSound = SoundID.NPCHit13; NPC.DeathSound = SoundID.NPCDeath21; @@ -63,7 +62,6 @@ namespace CalamityMod.NPCs.HiveMind public override void AI() { - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -74,22 +72,20 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : death ? 7f : revenge ? 6f : 4f; - float acceleration = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.5f : death ? 0.35f : revenge ? 0.3f : 0.2f; - float deceleration = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.9f : death ? 0.95f : revenge ? 0.96f : 0.98f; - if (masterMode) + // Despawn if Hive Mind isn't present + if (CalamityGlobalNPC.hiveMind == -1) { - velocity += 2f; - acceleration += 0.2f; - deceleration -= 0.05f; - } - if (BossRushEvent.BossRushActive) - { - velocity *= 2f; - acceleration *= 2f; + NPC.life = 0; + NPC.HitEffect(); + NPC.checkDead(); + NPC.active = false; } - if (NPC.position.Y > Main.player[NPC.target].position.Y - 350f) + float velocity = Main.getGoodWorld ? 10f : death ? 7f : revenge ? 6f : 4f; + float acceleration = Main.getGoodWorld ? 0.5f : death ? 0.35f : revenge ? 0.3f : 0.2f; + float deceleration = Main.getGoodWorld ? 0.9f : death ? 0.95f : revenge ? 0.96f : 0.98f; + + if (NPC.position.Y > Main.player[NPC.target].position.Y - 400f) { if (NPC.velocity.Y > 0f) NPC.velocity.Y *= deceleration; @@ -104,8 +100,8 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y + acceleration, -velocity, velocity * 1.5f); } - bool dropRain = NPC.Bottom.Y < Main.player[NPC.target].position.Y - 300f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); - float distanceX = masterMode ? 200f : 400f; + bool dropRain = NPC.Bottom.Y < Main.player[NPC.target].position.Y - 350f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + float distanceX = death ? 200f : 400f; if (NPC.Center.X > Main.player[NPC.target].Center.X + distanceX) { dropRain = false; @@ -128,17 +124,16 @@ namespace CalamityMod.NPCs.HiveMind if (dropRain && Main.netMode != NetmodeID.MultiplayerClient) { NPC.ai[0] += 1f; - float rainDropRate = Main.getGoodWorld ? 10f : death ? 20f : revenge ? 25f : 30f; + float rainDropRate = Main.getGoodWorld ? 10f : death ? 15f : revenge ? 20f : 30f; if (NPC.ai[0] >= rainDropRate) { NPC.ai[0] = 0f; int shaderainXPos = (int)(NPC.position.X + 10f + Main.rand.Next(NPC.width - 20)); int shaderainYos = (int)(NPC.position.Y + NPC.height + 4f); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - float randomXVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextFloat() * 5f : 0f; + float randomXVelocity = Main.getGoodWorld ? Main.rand.NextFloat() * 5f : 0f; float velocityY = 8f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), shaderainXPos, shaderainYos, randomXVelocity, velocityY, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shaderainXPos, shaderainYos, randomXVelocity, velocityY, type, HiveMind.ShaderainDamage, 0f, Main.myPlayer); } } } @@ -146,7 +141,7 @@ namespace CalamityMod.NPCs.HiveMind public override void OnKill() { int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); - if (Main.rand.NextBool(4) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) + if (Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } diff --git a/NPCs/HiveMind/HiveBlob.cs b/NPCs/HiveMind/HiveBlob.cs index 195befe9ea..f9467741d4 100644 --- a/NPCs/HiveMind/HiveBlob.cs +++ b/NPCs/HiveMind/HiveBlob.cs @@ -14,20 +14,23 @@ namespace CalamityMod.NPCs.HiveMind { public class HiveBlob : ModNPC { - private const float ShootGateValue = 240f; + private const float NormalShootGate = 240f; + private const float FastShootGate = 180f; private const float TelegraphDuration = 120f; - private const float ShowTelegraphValue = ShootGateValue - TelegraphDuration; + private bool FastVariant => NPC.ai[2] > 0f; - public override void SetStaticDefaults() - { - NPCID.Sets.NeedsExpertScaling[Type] = true; - } + public override void SetStaticDefaults() => NPCID.Sets.NeedsExpertScaling[Type] = true; + + public static int VileClotDamage = 8; // 32 + + // Legendary Mode exclusive + public static int CursedFlameDamage = 15; // 60 public override void SetDefaults() { NPC.npcSlots = 0.1f; NPC.aiStyle = -1; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.width = 25; NPC.height = 25; @@ -62,7 +65,6 @@ namespace CalamityMod.NPCs.HiveMind public override void AI() { bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -108,10 +110,11 @@ namespace CalamityMod.NPCs.HiveMind } } - float hiveMindVelocity = Main.npc[hiveMind].velocity.Length(); float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; float acceleration = 0.8f; - float distanceFromMind = Main.getGoodWorld ? 256f : 128f; + float distanceFromMind = FastVariant ? 96f : 128f; + if (Main.getGoodWorld) + distanceFromMind *= 2; float hiveMindX = Main.npc[hiveMind].Center.X; float hiveMindY = Main.npc[hiveMind].Center.Y; @@ -162,16 +165,16 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient) { + float shootGateValue = FastVariant ? FastShootGate : NormalShootGate; if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) - NPC.localAI[1] = ShootGateValue * 0.5f; + NPC.localAI[1] = shootGateValue * 0.5f; - float shootGateValue = ShootGateValue; if (NPC.localAI[1] < shootGateValue) { NPC.localAI[1] += 1f; - if (NPC.localAI[1] < ShowTelegraphValue) + if (NPC.localAI[1] < shootGateValue - TelegraphDuration) NPC.localAI[1] += Main.rand.Next(2); - if (masterMode) + if (death) NPC.localAI[1] += 1f; } @@ -184,8 +187,6 @@ namespace CalamityMod.NPCs.HiveMind if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) { float projSpeed = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f; - if (masterMode) - projSpeed += 2f; if (Main.getGoodWorld) projSpeed *= 1.5f; @@ -196,8 +197,8 @@ namespace CalamityMod.NPCs.HiveMind playerDist = projSpeed / playerDist; playerX *= playerDist; playerY *= playerDist; - int type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); - int damage = type == ProjectileID.CursedFlameHostile ? 30 : NPC.GetProjectileDamage(type); + int type = (Main.getGoodWorld && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); + int damage = type == ProjectileID.CursedFlameHostile ? CursedFlameDamage : VileClotDamage; Vector2 projectileVelocity = new Vector2(playerX, playerY); if (type == ProjectileID.CursedFlameHostile) { @@ -227,8 +228,9 @@ namespace CalamityMod.NPCs.HiveMind vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color color = NPC.GetAlpha(drawColor); - if (NPC.localAI[1] > ShowTelegraphValue) - color = Color.Lerp(color, Color.LimeGreen * NPC.Opacity, MathHelper.Clamp((NPC.localAI[1] - ShowTelegraphValue) / TelegraphDuration, 0f, 1f)); + float shootGateValue = FastVariant ? FastShootGate : NormalShootGate; + if (NPC.localAI[1] > shootGateValue - TelegraphDuration) + color = Color.Lerp(color, Color.LimeGreen * NPC.Opacity, MathHelper.Clamp((NPC.localAI[1] - (shootGateValue - TelegraphDuration)) / TelegraphDuration, 0f, 1f)); spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); @@ -254,6 +256,16 @@ namespace CalamityMod.NPCs.HiveMind for (int k = 0; k < 10; k++) Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); } + + if (Main.netMode != NetmodeID.MultiplayerClient && FastVariant && Main.zenithWorld) + { + // Spawn even more blobs on death + for (int i = 1; i < 3; i++) + { + Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); + NPC.NewNPC(NPC.GetSource_FromThis(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); + } + } } } } diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs deleted file mode 100644 index 0587b8edb2..0000000000 --- a/NPCs/HiveMind/HiveBlob2.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System; -using CalamityMod.Events; -using CalamityMod.Projectiles.Boss; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.HiveMind -{ - public class HiveBlob2 : ModNPC - { - private const float ShootGateValue = 180f; - private const float TelegraphDuration = 120f; - private const float ShowTelegraphValue = ShootGateValue - TelegraphDuration; - - public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.HiveBlob.DisplayName"); - public override string Texture => "CalamityMod/NPCs/HiveMind/HiveBlob"; - - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - NPCID.Sets.NeedsExpertScaling[Type] = true; - } - - public override void SetDefaults() - { - NPC.npcSlots = 0.1f; - NPC.aiStyle = -1; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats - NPC.width = 25; - NPC.height = 25; - - NPC.lifeMax = 75; - if (BossRushEvent.BossRushActive) - NPC.lifeMax = 1300; - if (Main.getGoodWorld) - NPC.lifeMax *= 2; - - NPC.knockBackResist = 0.9f; - AIType = -1; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.chaseable = false; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.Calamity().VulnerableToHeat = true; - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToSickness = true; - } - - public override void AI() - { - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - bool getFuckedAI = Main.zenithWorld; - - int hiveMind = CalamityGlobalNPC.hiveMind; - if (hiveMind < 0 || !Main.npc[hiveMind].active) - { - NPC.life = 0; - NPC.HitEffect(); - NPC.active = false; - NPC.netUpdate = true; - return; - } - - // When Hive Mind starts flying around - bool phase2 = Main.npc[hiveMind].life / (float)Main.npc[hiveMind].lifeMax < 0.8f; - - if (phase2) - { - NPC.life = 0; - NPC.HitEffect(); - NPC.active = false; - NPC.netUpdate = true; - return; - } - - NPC.alpha = Main.npc[hiveMind].alpha; - - if (NPC.ai[3] > 0f) - hiveMind = (int)NPC.ai[3] - 1; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] -= getFuckedAI ? 10f : 1f; //Relocation rate - float RandomPositionMultiplier = getFuckedAI ? 2f : 1f; - if (NPC.localAI[0] <= 0f) - { - NPC.localAI[0] = Main.rand.Next(180, 361); - NPC.ai[0] = Main.rand.Next(-100, 101) * RandomPositionMultiplier; //X position - NPC.ai[1] = Main.rand.Next(-100, 101) * RandomPositionMultiplier; //Y position - NPC.netUpdate = true; - } - } - - float hiveMindVelocity = Main.npc[hiveMind].velocity.Length(); - float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; - float acceleration = 0.8f; - float distanceFromMind = Main.getGoodWorld ? 192f : 96f; - - float hiveMindX = Main.npc[hiveMind].Center.X; - float hiveMindY = Main.npc[hiveMind].Center.Y; - Vector2 hiveMindPos = new Vector2(hiveMindX, hiveMindY); - float randomPosX = hiveMindX + NPC.ai[0]; - float randomPosY = hiveMindY + NPC.ai[1]; - float finalRandPosX = randomPosX - hiveMindPos.X; - float finalRandPosY = randomPosY - hiveMindPos.Y; - float finalRandDistance = (float)Math.Sqrt(finalRandPosX * finalRandPosX + finalRandPosY * finalRandPosY); - finalRandDistance = distanceFromMind / finalRandDistance; - finalRandPosX *= finalRandDistance; - finalRandPosY *= finalRandDistance; - - if (NPC.position.X < hiveMindX + finalRandPosX) - { - NPC.velocity.X += relocateSpeed; - if (NPC.velocity.X < 0f && finalRandPosX > 0f) - NPC.velocity.X *= acceleration; - } - else if (NPC.position.X > hiveMindX + finalRandPosX) - { - NPC.velocity.X -= relocateSpeed; - if (NPC.velocity.X > 0f && finalRandPosX < 0f) - NPC.velocity.X *= acceleration; - } - if (NPC.position.Y < hiveMindY + finalRandPosY) - { - NPC.velocity.Y += relocateSpeed; - if (NPC.velocity.Y < 0f && finalRandPosY > 0f) - NPC.velocity.Y *= acceleration; - } - else if (NPC.position.Y > hiveMindY + finalRandPosY) - { - NPC.velocity.Y -= relocateSpeed; - if (NPC.velocity.Y > 0f && finalRandPosY < 0f) - NPC.velocity.Y *= acceleration; - } - - float velocityLimit = relocateSpeed * 16f; - if (NPC.velocity.X > velocityLimit) - NPC.velocity.X = velocityLimit; - if (NPC.velocity.X < -velocityLimit) - NPC.velocity.X = -velocityLimit; - if (NPC.velocity.Y > velocityLimit) - NPC.velocity.Y = velocityLimit; - if (NPC.velocity.Y < -velocityLimit) - NPC.velocity.Y = -velocityLimit; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) - NPC.localAI[1] = ShootGateValue * 0.5f; - - float shootGateValue = ShootGateValue; - if (NPC.localAI[1] < shootGateValue) - { - NPC.localAI[1] += 1f; - if (NPC.localAI[1] < ShowTelegraphValue) - NPC.localAI[1] += Main.rand.Next(2); - if (masterMode) - NPC.localAI[1] += 1f; - } - - if (NPC.alpha > 0) - return; - - if (NPC.localAI[1] >= shootGateValue && Vector2.Distance(Main.player[Main.npc[hiveMind].target].Center, NPC.Center) > 80f) - { - NPC.localAI[1] = 0f; - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) - { - float projSpeed = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f; - if (masterMode) - projSpeed += 2f; - if (Main.getGoodWorld) - projSpeed *= 1.5f; - - Vector2 projDirection = NPC.Center; - float playerX = Main.player[Main.npc[hiveMind].target].Center.X - projDirection.X; - float playerY = Main.player[Main.npc[hiveMind].target].Center.Y - projDirection.Y; - float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); - playerDist = projSpeed / playerDist; - playerX *= playerDist; - playerY *= playerDist; - int type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge && Main.rand.NextBool(5)) ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); - int damage = type == ProjectileID.CursedFlameHostile ? 30 : NPC.GetProjectileDamage(type); - Vector2 projectileVelocity = new Vector2(playerX, playerY); - if (type == ProjectileID.CursedFlameHostile) - { - Vector2 v = Main.player[Main.npc[hiveMind].target].Center - NPC.Center - Main.player[Main.npc[hiveMind].target].velocity * 20f; - projectileVelocity = v.SafeNormalize(Vector2.UnitY) * projSpeed; - } - Projectile.NewProjectile(NPC.GetSource_FromAI(), projDirection, projectileVelocity, type, damage, 0f, Main.myPlayer); - NPC.netUpdate = true; - } - } - } - } - - public override bool CanHitNPC(NPC target) => NPC.alpha == 0; // Can only be hit while fully visible - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture = TextureAssets.Npc[Type].Value; - Vector2 vector = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / 2); - - Vector2 vector2 = NPC.Center - screenPos; - vector2 -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; - vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - Color color = NPC.GetAlpha(drawColor); - - if (NPC.localAI[1] > ShowTelegraphValue) - color = Color.Lerp(color, Color.LimeGreen * NPC.Opacity, MathHelper.Clamp((NPC.localAI[1] - ShowTelegraphValue) / TelegraphDuration, 0f, 1f)); - - spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override void OnKill() - { - int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); - if (Main.rand.NextBool(4) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) - Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); - } - - public override bool CheckActive() => false; - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 5; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); - - if (NPC.life <= 0) - { - for (int k = 0; k < 10; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); - - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) - { - // Spawn even more blobs on death - for (int i = 1; i < 3; i++) - { - Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); - NPC.NewNPC(NPC.GetSource_FromThis(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); - } - } - } - } - } -} diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index d8dcab9b15..c3da3cc0f7 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -4,10 +4,9 @@ using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; @@ -48,14 +47,13 @@ namespace CalamityMod.NPCs.HiveMind { string normalIconPath = "CalamityMod/NPCs/HiveMind/HiveMind_Head_Boss"; string phase2IconPath = "CalamityMod/NPCs/HiveMind/HiveMindP2_Head_Boss"; - + normalIconIndex = CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); } // This block of values can be modified in SetDefaults() based on difficulty mode or something - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private int burrowTimer = 420; + private int burrowTimer = 120; private int minimumDriftTime = 300; private int teleportRadius = 300; private int decelerationTime = 30; @@ -66,9 +64,14 @@ namespace CalamityMod.NPCs.HiveMind private int lungeDelay = 90; // # of ticks long hive mind spends sliding to a stop before lunging private int lungeTime = 33; private int lungeFade = 15; // Divide 255 by this for duration of hive mind spin before slowing for lunge + private int lungeAmount = 1; + private int lungesPerformed = 0; + private bool performingLungeCombo = false; private double lungeRots = 0.2; // Number of revolutions made while spinning/fading in for lunge private bool dashStarted = false; - private int vileSpitFireRate = 24; // Fire rate for Expert-exclusive Vile Spits during phase 1 teleports + private int rainDashAmount = 1; + private int rainDashesPerformed = 0; + private bool performingRainDashCombo = false; private int phase2timer = 360; private int rotationDirection; private double rotation; @@ -130,11 +133,13 @@ namespace CalamityMod.NPCs.HiveMind } } + public static int ShaderainDamage = 12; // 48 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 40; // 64 (1.6x expert scaling) NPC.npcSlots = 5f; - NPC.GetNPCDamage(); // this is the only allowed case for using constant directly // as it doesn't have proper frame info yet @@ -142,20 +147,18 @@ namespace CalamityMod.NPCs.HiveMind NPC.height = frameHeight_P1; NPC.defense = 8; - NPC.LifeMaxNERB(7700, 9200, 350000); + NPC.LifeMaxNERB(5000, 7000, 350000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 8, 0, 0); + NPC.value = Item.buyPrice(gold: 5); NPC.boss = true; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (expertMode) { @@ -171,40 +174,18 @@ namespace CalamityMod.NPCs.HiveMind lungeTime = 28; driftSpeed = 2f; driftBoost = 2f; - vileSpitFireRate = 18; } if (death) { lungeRots = 0.4; + lungeAmount = 3; + rainDashAmount = 2; minimumDriftTime = 60; reelbackFade = 6; lungeTime = 23; driftSpeed = 3.5f; driftBoost = 1.5f; - vileSpitFireRate = 15; - } - - if (bossRush) - { - lungeRots = 0.4; - minimumDriftTime = 40; - reelbackFade = 10; - lungeTime = 16; - driftSpeed = 6f; - driftBoost = 1f; - vileSpitFireRate = 12; - } - - if (masterMode) - { - lungeRots += 0.1; - minimumDriftTime /= 2; - reelbackFade *= 2; - lungeTime -= 5; - driftSpeed += ((death && !bossRush) ? 0.5f : 1f); - driftBoost += ((death && !bossRush) ? 0.5f : 1f); - vileSpitFireRate -= 6; } if (Main.getGoodWorld) @@ -218,9 +199,6 @@ namespace CalamityMod.NPCs.HiveMind NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -240,7 +218,6 @@ namespace CalamityMod.NPCs.HiveMind public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); writer.Write(NPC.dontTakeDamage); writer.Write(NPC.noTileCollide); writer.Write(NPC.noGravity); @@ -256,11 +233,14 @@ namespace CalamityMod.NPCs.HiveMind writer.Write(rotation); writer.Write(previousState); writer.Write(reelCount); + writer.Write(lungesPerformed); + writer.Write(performingLungeCombo); + writer.Write(rainDashesPerformed); + writer.Write(performingRainDashCombo); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); NPC.dontTakeDamage = reader.ReadBoolean(); NPC.noTileCollide = reader.ReadBoolean(); NPC.noGravity = reader.ReadBoolean(); @@ -276,6 +256,10 @@ namespace CalamityMod.NPCs.HiveMind rotation = reader.ReadDouble(); previousState = reader.ReadInt32(); reelCount = reader.ReadInt32(); + lungesPerformed = reader.ReadInt32(); + performingLungeCombo = reader.ReadBoolean(); + rainDashesPerformed = reader.ReadInt32(); + performingRainDashCombo = reader.ReadBoolean(); } public override void FindFrame(int _) @@ -293,10 +277,6 @@ namespace CalamityMod.NPCs.HiveMind frameHeight = frameHeight_P2; } - // Update NPC Size accordingly - NPC.width = frameWidth; - NPC.height = frameHeight - 2; //Phase 1 Sprite have 2 pixel margin - NPC.frameCounter += 1.0; // Update each 6 ticks if (NPC.frameCounter >= 6.0) { @@ -352,16 +332,14 @@ namespace CalamityMod.NPCs.HiveMind private void SpawnStuff() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - int maxSpawns = death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + int maxSpawns = death ? Main.rand.Next(3, 5) : revenge ? 3 : expertMode ? Main.rand.Next(2, 4) : 2; for (int i = 0; i < maxSpawns; i++) { - int type = NPCID.EaterofSouls; + int type; int choice = -1; do { @@ -369,23 +347,29 @@ namespace CalamityMod.NPCs.HiveMind switch (choice) { case 0: + type = !NPC.AnyNPCs(NPCID.EaterofSouls) ? NPCID.EaterofSouls : 0; + break; + case 1: - type = NPCID.EaterofSouls; + type = !NPC.AnyNPCs(NPCID.DevourerHead) ? NPCID.DevourerHead : 0; break; + case 2: - type = NPCID.DevourerHead; + type = !NPC.AnyNPCs(ModContent.NPCType()) ? ModContent.NPCType() : 0; break; + case 3: - case 4: - type = ModContent.NPCType(); + type = (!NPC.AnyNPCs(NPCID.Corruptor) && death) ? NPCID.Corruptor : 0; break; + default: + type = -1; break; } } - while (NPC.AnyNPCs(type) && choice < 5); + while (type == 0); - if (choice < 5) + if (type > 0) NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(NPC.height), type); } @@ -396,8 +380,7 @@ namespace CalamityMod.NPCs.HiveMind private void ReelBack() { - bool bossRush = BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || bossRush; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; NPC.alpha = 0; phase2timer = 0; @@ -429,44 +412,23 @@ namespace CalamityMod.NPCs.HiveMind public override void AI() { + // Update NPC Size according to Phase Changes + NPC.width = frameWidth; + NPC.height = frameHeight - 2; //Phase 1 Sprite have 2 pixel margin + // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); Player player = Main.player[NPC.target]; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; - // Enrage - if ((!player.ZoneCorrupt || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - - float enrageScale = bossRush ? 1f : 0f; - if (biomeEnraged && (!player.ZoneCorrupt || bossRush)) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - if (biomeEnraged && ((NPC.position.Y / 16f) < Main.worldSurface || bossRush)) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - // Phase 2 settings if (IsPhaseTwo) { @@ -482,6 +444,25 @@ namespace CalamityMod.NPCs.HiveMind Gore.NewGore(NPC.GetSource_FromAI(), NPC.Center, NPC.velocity, Mod.Find("HiveMindGore" + i).Type, 1f); } + for (int i = 0; i < 20; i++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int j = 0; j < 35; j++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 5f; + dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 2f; + } + SoundEngine.PlaySound(SoundID.NPCDeath1, NPC.Center); NPC.position = NPC.Center; @@ -503,11 +484,11 @@ namespace CalamityMod.NPCs.HiveMind CalamityGlobalNPC.hiveMind = NPC.whoAmI; - if (!player.active || player.dead) + if (!player.active || player.dead || !(player.ZoneCorrupt || BossRushEvent.BossRushActive)) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if (!player.active || player.dead) + if (!player.active || player.dead || !(player.ZoneCorrupt || BossRushEvent.BossRushActive)) { if (NPC.timeLeft > 60) NPC.timeLeft = 60; @@ -553,7 +534,7 @@ namespace CalamityMod.NPCs.HiveMind maxBlobs = 50; for (int i = 0; i < maxBlobs; i++) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, Main.rand.NextBool() ? ModContent.NPCType() : ModContent.NPCType(), NPC.whoAmI); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI, ai2: Main.rand.Next(2)); } } @@ -590,15 +571,15 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient) { - int maxSpawns = bossRush ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); - int maxDankSpawns = bossRush ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; + int maxSpawns = death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + int maxDankSpawns = death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; for (int i = 0; i < maxSpawns; i++) { int x = (int)(NPC.position.X + Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + Main.rand.Next(NPC.height - 32)); - int type = Main.rand.NextBool() ? ModContent.NPCType() : ModContent.NPCType(); + int type = ModContent.NPCType(); if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) type = ModContent.NPCType(); @@ -616,7 +597,7 @@ namespace CalamityMod.NPCs.HiveMind burrowTimer--; if (burrowTimer < -120) { - burrowTimer = (death ? 180 : revenge ? 300 : expertMode ? 360 : 420) - (int)enrageScale * 55; + burrowTimer = death ? 180 : revenge ? 300 : expertMode ? 360 : 420; if (burrowTimer < 30) burrowTimer = 30; @@ -647,15 +628,6 @@ namespace CalamityMod.NPCs.HiveMind burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, DustID.Demonite, 0f, -3f, 100, default, 2.5f * NPC.scale); Main.dust[burrowedDust2].velocity *= 1f; } - - if (expertMode) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && burrowTimer % vileSpitFireRate == 0) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 69f); - } - } } else if (burrowTimer == -60) { @@ -676,7 +648,7 @@ namespace CalamityMod.NPCs.HiveMind for (int i = 0; i < Main.maxNPCs; i++) { NPC hiveBlob = Main.npc[i]; - if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) + if (hiveBlob.active && hiveBlob.type == ModContent.NPCType()) { hiveBlob.position.X = NPC.position.X; hiveBlob.position.Y = NPC.position.Y; @@ -708,15 +680,6 @@ namespace CalamityMod.NPCs.HiveMind burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, DustID.Demonite, 0f, -3f, 100, default, 2.5f * NPC.scale); Main.dust[burrowedDust2].velocity *= 1f; } - - if (expertMode) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && burrowTimer % vileSpitFireRate == 0) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 69f); - } - } } else if (burrowTimer == 0) { @@ -738,8 +701,8 @@ namespace CalamityMod.NPCs.HiveMind { case 0: // Slowdrift - // Avoid cheap bullshit - NPC.damage = 0; + // Set damage + NPC.damage = NPC.defDamage; if (NPC.alpha > 0) { @@ -751,7 +714,7 @@ namespace CalamityMod.NPCs.HiveMind if (nextState == 0) { NPC.TargetClosest(); - if (revenge && lifeRatio < 0.5f) + if (revenge && lifeRatio < 0.6f) { if (death) { @@ -760,7 +723,7 @@ namespace CalamityMod.NPCs.HiveMind while (nextState == previousState); previousState = nextState; } - else if (lifeRatio < 0.25f) + else if (lifeRatio < 0.3f) { do nextState = Main.rand.Next(3, 6); @@ -804,11 +767,11 @@ namespace CalamityMod.NPCs.HiveMind NPC.ForceNetUpdate(); } - if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 8000f) + if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 8000f || !(player.ZoneCorrupt || BossRushEvent.BossRushActive)) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 8000f) + if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 8000f || !(player.ZoneCorrupt || BossRushEvent.BossRushActive)) { if (NPC.timeLeft > 60) NPC.timeLeft = 60; @@ -831,31 +794,20 @@ namespace CalamityMod.NPCs.HiveMind return; } - if (expertMode) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[2] += 1f; - if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && NPC.localAI[2] % (vileSpitFireRate * 2) == 0) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 69f); - } - } - NPC.velocity = player.Center - NPC.Center; phase2timer--; - // Use an attack sooner if being hit - if (NPC.justHit && masterMode) - phase2timer -= 4; - - // Use an attack sooner if target is close - if (NPC.Distance(player.Center) < 160f) - phase2timer -= 2; + if (death) + { + // Use an attack sooner if being hit + if (NPC.justHit) + phase2timer -= 4; + } if (phase2timer <= -180) // No stalling drift mode forever { - NPC.velocity *= 2f / 255f * (reelbackFade + 2 * (int)enrageScale); + NPC.velocity *= 2f / 255f * reelbackFade; ReelBack(); NPC.ForceNetUpdate(); } @@ -863,9 +815,9 @@ namespace CalamityMod.NPCs.HiveMind { NPC.velocity.Normalize(); if (expertMode) // Variable velocity in expert and up - NPC.velocity *= driftSpeed + enrageScale + driftBoost * lifeRatio; + NPC.velocity *= driftSpeed + driftBoost * lifeRatio; else - NPC.velocity *= driftSpeed + enrageScale; + NPC.velocity *= driftSpeed; } break; @@ -875,7 +827,7 @@ namespace CalamityMod.NPCs.HiveMind // Avoid cheap bullshit NPC.damage = 0; - NPC.alpha += reelbackFade + 2 * (int)enrageScale; + NPC.alpha += reelbackFade; NPC.velocity -= deceleration; if (NPC.alpha >= 255) @@ -890,7 +842,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.Y = NPC.ai[2] * 16 - NPC.height / 2; } - phase2timer = minimumDriftTime + Main.rand.Next(masterMode ? 61 : 121); + phase2timer = minimumDriftTime + Main.rand.Next(death ? 61 : 121); NPC.ForceNetUpdate(); } else if (NPC.ai[1] == 0f && NPC.ai[2] == 0f) @@ -916,7 +868,7 @@ namespace CalamityMod.NPCs.HiveMind // Avoid cheap bullshit NPC.damage = 0; - NPC.alpha += reelbackFade + 2 * (int)enrageScale; + NPC.alpha += reelbackFade; NPC.velocity -= deceleration; if (NPC.alpha >= 255) @@ -925,21 +877,24 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity = Vector2.Zero; dashStarted = false; - if (revenge && lifeRatio < 0.53f) + if (revenge && lifeRatio < 0.6f && lungesPerformed == 0 && rainDashesPerformed == 0) { state = nextState; nextState = 0; previousState = state; } else - state = 3; + state = performingRainDashCombo ? 5 : 3; - if (player.velocity.X > 0) - rotationDirection = 1; - else if (player.velocity.X < 0) - rotationDirection = -1; - else - rotationDirection = player.direction; + if (!performingRainDashCombo) + { + if (player.velocity.X > 0) + rotationDirection = 1; + else if (player.velocity.X < 0) + rotationDirection = -1; + else + rotationDirection = player.direction; + } } break; @@ -952,20 +907,9 @@ namespace CalamityMod.NPCs.HiveMind NPC.ForceNetUpdate(); if (NPC.alpha > 0) { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); - - if (masterMode) - { - NPC.localAI[2] += 1f; - if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && NPC.localAI[2] % vileSpitFireRate == 0) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 70f); - } - } - + NPC.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); rotation += rotationIncrement * rotationDirection; - phase2timer = lungeDelay; + phase2timer = lungesPerformed > 0 ? (lungeDelay / (lungesPerformed + 1)) : lungeDelay; NPC.alpha -= lungeFade; if (NPC.alpha < 0) @@ -981,28 +925,17 @@ namespace CalamityMod.NPCs.HiveMind // Set damage NPC.damage = NPC.defDamage; - phase2timer = lungeTime - 4 * (int)enrageScale; - NPC.velocity = player.Center + (bossRush ? player.velocity * 20f : Vector2.Zero) - NPC.Center; + phase2timer = lungeTime; + NPC.velocity = player.Center - NPC.Center; NPC.velocity.Normalize(); - NPC.velocity *= teleportRadius / (lungeTime - (int)enrageScale); + NPC.velocity *= teleportRadius / lungeTime; dashStarted = true; SoundEngine.PlaySound(RoarSound, NPC.Center); NPC.netUpdate = true; } else { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); - - if (masterMode) - { - NPC.localAI[2] += 1f; - if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && NPC.localAI[2] % vileSpitFireRate == 0) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 70f); - } - } - + NPC.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); rotation += rotationIncrement * rotationDirection * phase2timer / lungeDelay; } } @@ -1016,6 +949,7 @@ namespace CalamityMod.NPCs.HiveMind // Avoid cheap bullshit NPC.damage = 0; + performingLungeCombo = death; state = 6; phase2timer = 0; deceleration = NPC.velocity / decelerationTime; @@ -1038,7 +972,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.position.Y += teleportRadius; } - NPC.alpha -= masterMode ? 10 : 5; + NPC.alpha -= 5; if (NPC.alpha < 0) NPC.alpha = 0; @@ -1065,17 +999,10 @@ namespace CalamityMod.NPCs.HiveMind NPC.velocity = NPC.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); phase2timer++; - if (phase2timer == (int)arcTime / 6) + if (phase2timer == (int)(arcTime / 6f)) { phase2timer = 0; NPC.ai[0] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient && Collision.CanHit(NPC.Center, 1, 1, player.position, player.width, player.height)) - { - int maxEaters = revenge ? 3 : 2; - if (NPC.CountNPCS(NPCID.EaterofSouls) < maxEaters && NPC.Distance(Main.player[NPC.target].Center) > 80f) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.EaterofSouls); - } - if (NPC.ai[0] == 6f) { NPC.velocity = NPC.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); @@ -1104,10 +1031,10 @@ namespace CalamityMod.NPCs.HiveMind { NPC.Center = player.Center; NPC.position.Y -= teleportRadius; - NPC.position.X += teleportRadius * rotationDirection; + NPC.position.X += (death ? (teleportRadius * 1.5f) : teleportRadius) * (rainDashesPerformed == 0 ? rotationDirection : -rotationDirection); } - NPC.alpha -= masterMode ? 10 : 5; + NPC.alpha -= 5; if (NPC.alpha < 0) NPC.alpha = 0; @@ -1123,7 +1050,7 @@ namespace CalamityMod.NPCs.HiveMind dashStarted = true; SoundEngine.PlaySound(RoarSound, NPC.Center); NPC.velocity.X = teleportRadius / arcTime * 3; - NPC.velocity *= -rotationDirection; + NPC.velocity *= (rainDashesPerformed == 0 ? -rotationDirection : rotationDirection); NPC.ForceNetUpdate(); } else @@ -1132,21 +1059,21 @@ namespace CalamityMod.NPCs.HiveMind NPC.damage = NPC.defDamage; phase2timer++; - if (phase2timer == (int)arcTime / 20) + if (phase2timer % 30 == (int)(arcTime / (death ? 15f : 20f))) { phase2timer = 0; NPC.ai[0] += 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 cloudSpawnPos = new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(NPC.height)); - Vector2 randomVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextVector2CircularEdge(4f, 4f) : Vector2.Zero; - Projectile.NewProjectile(NPC.GetSource_FromAI(), cloudSpawnPos, randomVelocity, type, damage, 0, Main.myPlayer, 11f); + Vector2 randomVelocity = Main.getGoodWorld ? Main.rand.NextVector2CircularEdge(4f, 4f) : Vector2.Zero; + Projectile.NewProjectile(NPC.GetSource_FromAI(), cloudSpawnPos, randomVelocity, type, ShaderainDamage, 0, Main.myPlayer, 11f); } if (NPC.ai[0] == 10f) { + performingRainDashCombo = death; state = 6; NPC.ai[0] = 0f; deceleration = NPC.velocity / decelerationTime; @@ -1166,8 +1093,42 @@ namespace CalamityMod.NPCs.HiveMind phase2timer++; if (phase2timer == decelerationTime) { - phase2timer = minimumDriftTime + Main.rand.Next(masterMode ? 61 : 121); - state = 0; + if (performingRainDashCombo) + { + rainDashesPerformed++; + if (rainDashesPerformed < rainDashAmount) + { + state = 2; + } + else + { + phase2timer = minimumDriftTime + Main.rand.Next(death ? 61 : 121); + performingRainDashCombo = false; + rainDashesPerformed = 0; + state = 0; + } + } + else if (performingLungeCombo) + { + lungesPerformed++; + if (lungesPerformed < lungeAmount) + { + state = 2; + } + else + { + phase2timer = minimumDriftTime + Main.rand.Next(death ? 61 : 121); + performingLungeCombo = false; + lungesPerformed = 0; + state = 0; + } + } + else + { + phase2timer = minimumDriftTime + Main.rand.Next(death ? 61 : 121); + state = 0; + } + NPC.ForceNetUpdate(); } @@ -1185,8 +1146,7 @@ namespace CalamityMod.NPCs.HiveMind { NPC.ai[3] = NPC.life; - int maxDarkHearts = ((revenge && lifeRatio < 0.25f) || death) ? 2 : 1; - if (NPC.CountNPCS(ModContent.NPCType()) < maxDarkHearts) + if (!NPC.AnyNPCs(ModContent.NPCType())) { SoundEngine.PlaySound(SoundID.NPCDeath22, NPC.Center); @@ -1211,8 +1171,8 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient) { - int x = (int)(NPC.position.X + Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + Main.rand.Next(NPC.height - 32)); + int x = (int)(NPC.position.X + Main.rand.Next(NPC.width)); + int y = (int)(NPC.position.Y + Main.rand.Next(NPC.height)); int type = ModContent.NPCType(); int tenPercentMinions = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, type); Main.npc[tenPercentMinions].SetDefaults(type); @@ -1252,7 +1212,7 @@ namespace CalamityMod.NPCs.HiveMind if (hurtInfo.Damage < 0) return; - target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(ModContent.BuffType(), 240); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => NPC.scale == 1f; // Only draw HP bar while at full size @@ -1270,7 +1230,7 @@ namespace CalamityMod.NPCs.HiveMind public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); + NPC.damage = (int)(NPC.damage * 0.8f); } public override void HitEffect(NPC.HitInfo hit) @@ -1282,13 +1242,13 @@ namespace CalamityMod.NPCs.HiveMind { if (Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.rand.NextBool(60)) + if (Main.rand.NextBool(30)) { - if (NPC.CountNPCS(NPCID.EaterofSouls) < 3) + if (NPC.CountNPCS(NPCID.EaterofSouls) < 2) NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.EaterofSouls); } - if (Main.rand.NextBool(150)) + if (Main.rand.NextBool(45)) { if (!NPC.AnyNPCs(NPCID.DevourerHead)) NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.DevourerHead); @@ -1332,7 +1292,7 @@ namespace CalamityMod.NPCs.HiveMind } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.HealingPotion; } @@ -1352,7 +1312,7 @@ namespace CalamityMod.NPCs.HiveMind Color messageColor = Color.Cyan; AerialiteOreGen.Enchant(); - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Mark The Hive Mind as dead @@ -1381,12 +1341,12 @@ namespace CalamityMod.NPCs.HiveMind normalOnly.Add(ItemID.DemoniteBar, 1, 10, 15); normalOnly.Add(ItemID.RottenChunk, 1, 10, 15); normalOnly.Add(ItemID.CorruptSeeds, 1, 10, 15); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30)); normalOnly.Add(ItemDropRule.ByCondition(DropHelper.Hardmode(), ItemID.CursedFlame, 1, 10, 20)); // Equipment normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -1402,11 +1362,11 @@ namespace CalamityMod.NPCs.HiveMind // GFB class emblem drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.WarriorEmblem, hideLootReport: true); - GFBOnly.Add(ItemID.RangerEmblem, hideLootReport: true); - GFBOnly.Add(ItemID.SorcererEmblem, hideLootReport: true); - GFBOnly.Add(ItemID.SummonerEmblem, hideLootReport: true); - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.WarriorEmblem), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.RangerEmblem), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.SorcererEmblem), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.SummonerEmblem), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); } // Lore diff --git a/NPCs/HiveMind/HiveTumor.cs b/NPCs/HiveMind/HiveTumor.cs index 8a3269a23c..fdd18d8d6c 100644 --- a/NPCs/HiveMind/HiveTumor.cs +++ b/NPCs/HiveMind/HiveTumor.cs @@ -1,5 +1,4 @@ -using CalamityMod.World; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -25,7 +24,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.width = 30; //324 NPC.height = 30; //216 NPC.defense = 0; - NPC.lifeMax = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10 : 1000; + NPC.lifeMax = Main.zenithWorld ? 10 : 1000; NPC.knockBackResist = 0f; NPC.chaseable = false; NPC.HitSound = SoundID.NPCHit1; @@ -80,7 +79,7 @@ namespace CalamityMod.NPCs.HiveMind type = ModContent.NPCType(); break; case 4: - type = ModContent.NPCType(); + type = ModContent.NPCType(); break; default: break; @@ -131,7 +130,7 @@ namespace CalamityMod.NPCs.HiveMind { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); } - if (Main.netMode != NetmodeID.MultiplayerClient && (!NPC.AnyNPCs(ModContent.NPCType()) || (CalamityWorld.LegendaryMode && CalamityWorld.revenge))) + if (Main.netMode != NetmodeID.MultiplayerClient && (!NPC.AnyNPCs(ModContent.NPCType()) || Main.zenithWorld)) { Vector2 spawnAt = NPC.Bottom; NPC.NewNPC(NPC.GetSource_Death(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); diff --git a/NPCs/Leviathan/Anahita.cs b/NPCs/Leviathan/Anahita.cs index 04d468c868..5069afc176 100644 --- a/NPCs/Leviathan/Anahita.cs +++ b/NPCs/Leviathan/Anahita.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.Leviathan private int frameUsed = 0; public bool HasBegunSummoningLeviathan = false; private int DrawProjectileTelegraphTimer = 0; - private int LegendaryModeAttackChosen = 0; + private int GetGoodAttackChosen = 0; public static Asset ChargeTexture; public bool WaitingForLeviathan { @@ -59,21 +59,26 @@ namespace CalamityMod.NPCs.Leviathan } } + public static float DashDamageMult = 1.5f; // 150 + public static int SpearDamage = 27; // 108 + public static int MistDamage = 24; // 96 + public static int SongDamage = 30; // 120 + public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 50; // 100 NPC.npcSlots = 16f; NPC.width = 100; NPC.height = 100; NPC.defense = 20; - NPC.DR_NERD(0.2f); - NPC.LifeMaxNERB(35000, 42000, 260000); + NPC.LifeMaxNERB(25000, 42000, 260000); NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; NPC.boss = true; NPC.BossBar = ModContent.GetInstance(); - NPC.value = Item.buyPrice(0, 12, 50, 0); + NPC.value = Item.buyPrice(gold: 7, silver: 50); NPC.noGravity = true; NPC.noTileCollide = true; NPC.HitSound = HitSound; @@ -88,9 +93,6 @@ namespace CalamityMod.NPCs.Leviathan if (Main.zenithWorld) NPC.scale *= 4f; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -141,9 +143,6 @@ namespace CalamityMod.NPCs.Leviathan if (HasBegunSummoningLeviathan && CalamityGlobalNPC.LeviAndAna == -1) CalamityGlobalNPC.LeviAndAna = NPC.whoAmI; - // Set to false so she doesn't do it constantly - NPC.Calamity().canBreakPlayerDefense = false; - // Light Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0f, 0.5f, 0.3f); @@ -162,15 +161,13 @@ namespace CalamityMod.NPCs.Leviathan // Variables Player player = Main.player[NPC.target]; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool notOcean = player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); // Enrage - if (notOcean && !bossRush) + if (notOcean && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) biomeEnrageTimer--; @@ -178,12 +175,12 @@ namespace CalamityMod.NPCs.Leviathan else biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; + bool biomeEnraged = biomeEnrageTimer <= 0; float enrageScale = 0f; if (biomeEnraged) { - NPC.Calamity().CurrentlyEnraged = !bossRush; + NPC.Calamity().CurrentlyEnraged = true; enrageScale += 1.5f; } @@ -194,8 +191,6 @@ namespace CalamityMod.NPCs.Leviathan if (!leviAlive) bubbleVelocity += 2f * (1f - lifeRatio); if (Main.getGoodWorld) - bubbleVelocity *= 1.15f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) bubbleVelocity *= 2f; // Phases @@ -240,7 +235,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.rotation = NPC.rotation.AngleTowards(idealRotation, 0.08f); - if (bossRush || Collision.WetCollision(NPC.position, NPC.width, NPC.height) || NPC.position.Y > (Main.worldSurface - 125f) * 16f) + if (BossRushEvent.BossRushActive || Collision.WetCollision(NPC.position, NPC.width, NPC.height) || NPC.position.Y > (Main.worldSurface - 125f) * 16f) { int oldAlpha = NPC.alpha; NPC.alpha = Utils.Clamp(NPC.alpha + 9, 0, 255); @@ -316,6 +311,7 @@ namespace CalamityMod.NPCs.Leviathan NPC.dontTakeDamage = true; } + NPC.canDisplayBuffs = true; // Hover near the target, invisible if the Leviathan is present and not sufficiently injured. if ((phase3 || death) && WaitingForLeviathan && !Main.zenithWorld) { @@ -343,6 +339,7 @@ namespace CalamityMod.NPCs.Leviathan } NPC.dontTakeDamage = true; + NPC.canDisplayBuffs = false; if (NPC.ai[0] != -1f) { @@ -449,6 +446,9 @@ namespace CalamityMod.NPCs.Leviathan NPC.rotation = NPC.velocity.X * 0.02f; NPC.spriteDirection = NPC.direction; + // Remove projectile telegraph + DrawProjectileTelegraphTimer = 0; + Vector2 anahitaPos = NPC.Center; float playerXDist = player.position.X + (player.width / 2) - anahitaPos.X; float playerYDist = player.position.Y + (player.height / 2) - 200f * NPC.scale - anahitaPos.Y; @@ -654,17 +654,17 @@ namespace CalamityMod.NPCs.Leviathan int totalTelegraphs = 8; float telegraphDist = 500f; - // In Legendary, the projectiles she fires is randomized - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + // In FTW, the projectiles she fires is randomized + if (Main.getGoodWorld) { - LegendaryModeAttackChosen = Main.rand.Next(3); - if (LegendaryModeAttackChosen == 2) + GetGoodAttackChosen = Main.rand.Next(3); + if (GetGoodAttackChosen == 2) telegraphDist -= 50f; for (int i = 0; i < totalTelegraphs; i++) { Vector2 spawnVector = player.Center - Vector2.UnitY.RotatedBy(MathHelper.TwoPi / totalTelegraphs * i) * telegraphDist; - int tele = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, player.whoAmI, LegendaryModeAttackChosen); + int tele = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, player.whoAmI, GetGoodAttackChosen); Main.projectile[tele].netUpdate = true; } @@ -709,13 +709,13 @@ namespace CalamityMod.NPCs.Leviathan int totalProjectiles = 8; int projectileDistance = 600; int type = ModContent.ProjectileType(); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + int damage = SpearDamage; + if (Main.getGoodWorld) { float radians = MathHelper.TwoPi / totalProjectiles; - int damage = NPC.GetProjectileDamage(type); for (int i = 0; i < totalProjectiles; i++) { - switch (LegendaryModeAttackChosen) + switch (GetGoodAttackChosen) { case 0: SoundEngine.PlaySound(SoundID.Item21, player.Center); @@ -723,11 +723,13 @@ namespace CalamityMod.NPCs.Leviathan case 1: type = ModContent.ProjectileType(); + damage = MistDamage; SoundEngine.PlaySound(SoundID.Item30, player.Center); break; case 2: type = ModContent.ProjectileType(); + damage = SongDamage; float soundPitch = (Main.rand.NextFloat() - 0.5f) * 0.5f; Main.musicPitch = soundPitch; SoundEngine.PlaySound(SoundID.Item26, player.Center); @@ -751,15 +753,16 @@ namespace CalamityMod.NPCs.Leviathan case 1: totalProjectiles = 3; type = ModContent.ProjectileType(); + damage = MistDamage; SoundEngine.PlaySound(SoundID.Item30, player.Center); break; case 2: totalProjectiles = 6; type = ModContent.ProjectileType(); - float soundPitch = (Main.rand.NextFloat() - 0.5f) * 0.5f; - Main.musicPitch = soundPitch; - SoundEngine.PlaySound(SoundID.Item26, player.Center); + damage = SongDamage; + SoundStyle song = new("CalamityMod/Sounds/Item/HarpEnd"); + SoundEngine.PlaySound(song with { Volume = 0.6f }, player.Center); break; } NPC.localAI[3] += 1f; @@ -770,7 +773,6 @@ namespace CalamityMod.NPCs.Leviathan totalProjectiles += totalProjectiles / 2; float radians = MathHelper.TwoPi / totalProjectiles; - int damage = NPC.GetProjectileDamage(type); for (int i = 0; i < totalProjectiles; i++) { Vector2 spawnVector = player.Center + Vector2.Normalize(new Vector2(0f, -projectileVelocity).RotatedBy(radians * i)) * projectileDistance; @@ -788,12 +790,8 @@ namespace CalamityMod.NPCs.Leviathan NPC.spriteDirection = NPC.direction; } - float phaseTimer = 300f; - phaseTimer -= 50f * enrageScale; - if (!leviAlive || phase4) - phaseTimer -= 150f * (1f - lifeRatio); - - if (NPC.ai[1] >= phaseTimer) + // End behavior after attacking twice + if (NPC.ai[1] > attackDivisor * 2) { NPC.ai[0] = -1f; NPC.ai[1] = 2f; @@ -827,9 +825,11 @@ namespace CalamityMod.NPCs.Leviathan if (revenge) chargeVelocity += 2f + (death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio)); - if (Main.getGoodWorld) chargeVelocity *= 1.15f; + // Stunt velocity at the end of the charge attack to prevent her flying off + if (NPC.ai[0] == -1f) + chargeVelocity *= 0.3f; NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeVelocity; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); @@ -851,10 +851,9 @@ namespace CalamityMod.NPCs.Leviathan // Charge else if (NPC.ai[0] == 4f) { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.damage = (int)Math.Round(NPC.defDamage * 1.5); + NPC.damage = (int)Math.Round(NPC.defDamage * DashDamageMult); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge && NPC.ai[1] % 5f == 0f) + if (Main.zenithWorld && NPC.ai[1] % 5f == 0f) { SoundEngine.PlaySound(SoundID.Item85, NPC.Center); Vector2 bubbleSpawnPos = new Vector2(NPC.position.X + (NPC.width / 2) + (15 * NPC.direction * NPC.scale), NPC.position.Y + 30 * NPC.scale); @@ -981,7 +980,7 @@ namespace CalamityMod.NPCs.Leviathan if (DrawProjectileTelegraphTimer > 0) { Color telegraphColor = Color.Black; - switch (CalamityWorld.LegendaryMode && CalamityWorld.revenge ? LegendaryModeAttackChosen : (int)NPC.localAI[3]) + switch (Main.getGoodWorld ? GetGoodAttackChosen : (int)NPC.localAI[3]) { case 0: telegraphColor = new Color(55, 70, 240); @@ -1022,7 +1021,7 @@ namespace CalamityMod.NPCs.Leviathan //200x636 } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.GreaterHealingPotion; } @@ -1049,7 +1048,6 @@ namespace CalamityMod.NPCs.Leviathan public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/Leviathan/AnahitasIceShield.cs b/NPCs/Leviathan/AnahitasIceShield.cs index cd2355115a..eee7f16f4d 100644 --- a/NPCs/Leviathan/AnahitasIceShield.cs +++ b/NPCs/Leviathan/AnahitasIceShield.cs @@ -29,16 +29,16 @@ namespace CalamityMod.NPCs.Leviathan public override void SetDefaults() { + NPC.damage = 50; // 100 NPC.aiStyle = -1; AIType = -1; NPC.noTileCollide = true; NPC.coldDamage = true; - NPC.GetNPCDamage(); NPC.width = 100; NPC.height = 100; NPC.defense = 10; - NPC.DR_NERD(0.5f); - NPC.lifeMax = BossRushEvent.BossRushActive ? 1000 : 650; + NPC.DR_NERD(0.25f); + NPC.lifeMax = BossRushEvent.BossRushActive ? 2000 : 750; NPC.alpha = 255; NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath7; @@ -99,14 +99,6 @@ namespace CalamityMod.NPCs.Leviathan public override Color? GetAlpha(Color drawColor) => NPC.ai[1] == 1f ? Color.Transparent : new Color(200, 200, 200, drawColor.A) * NPC.Opacity; - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (NPC.ai[1] == 1f || hurtInfo.Damage <= 0) - return; - - target.AddBuff(BuffID.Frostburn, 240, true); - } - public override bool CheckActive() => false; public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Leviathan/AquaticAberration.cs b/NPCs/Leviathan/AquaticAberration.cs index 8a7e1f5543..3139380d39 100644 --- a/NPCs/Leviathan/AquaticAberration.cs +++ b/NPCs/Leviathan/AquaticAberration.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Events; -using CalamityMod.Items.Placeables.Banners; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -8,7 +7,6 @@ using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.Leviathan { @@ -36,9 +34,8 @@ namespace CalamityMod.NPCs.Leviathan public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 50; // 100 NPC.aiStyle = -1; - NPC.GetNPCDamage(); NPC.width = 50; NPC.height = 50; NPC.defense = 14; @@ -56,10 +53,6 @@ namespace CalamityMod.NPCs.Leviathan if (Main.getGoodWorld) NPC.scale *= 1.3f; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -96,10 +89,9 @@ namespace CalamityMod.NPCs.Leviathan // Avoid cheap bullshit NPC.damage = 0; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; NPC.TargetClosest(false); @@ -128,13 +120,13 @@ namespace CalamityMod.NPCs.Leviathan sirenAlive = false; } - float inertia = bossRush ? 24f : death ? 26f : revenge ? 27f : expertMode ? 28f : 30f; + float inertia = death ? 26f : revenge ? 27f : expertMode ? 28f : 30f; if (!sirenAlive || leviathanInPhase4) inertia *= 0.75f; if (NPC.ai[0] == 0f) { - float lungeSpeed = bossRush ? 14f : death ? 12f : revenge ? 11f : expertMode ? 10f : 8f; + float lungeSpeed = death ? 12f : revenge ? 11f : expertMode ? 10f : 8f; if (!sirenAlive || leviathanInPhase4) lungeSpeed *= 1.25f; @@ -279,12 +271,6 @@ namespace CalamityMod.NPCs.Leviathan } } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Bleeding, 240, true); - } - public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index 3e991ea360..e25f31ae91 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -7,7 +7,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Monoliths; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; @@ -34,6 +34,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Leviathan { [AutoloadBossHead] + [HasPierceResist(singleHitbox: true)] public class Leviathan : ModNPC { private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; @@ -56,21 +57,23 @@ namespace CalamityMod.NPCs.Leviathan AttackTexture = ModContent.Request("CalamityMod/NPCs/Leviathan/LeviathanAttack", AssetRequestMode.AsyncLoad); } + public static int BoulderDamage = 40; // 160 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 20f; - NPC.GetNPCDamage(); + NPC.damage = 100; // 200 NPC.width = 900; NPC.height = 450; NPC.defense = 40; - NPC.DR_NERD(0.3f); - NPC.LifeMaxNERB(60000, 72000, 600000); + NPC.DR_NERD(0.1f); + NPC.LifeMaxNERB(50000, 67500, 600000); NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; NPC.Opacity = 0f; - NPC.value = Item.buyPrice(0, 12, 50, 0); + NPC.value = Item.buyPrice(gold: 7, silver: 50); NPC.HitSound = SoundID.NPCHit56; NPC.DeathSound = SoundID.NPCDeath60; NPC.noTileCollide = true; @@ -88,9 +91,6 @@ namespace CalamityMod.NPCs.Leviathan if (Main.zenithWorld) NPC.scale *= 0.3f; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -130,10 +130,9 @@ namespace CalamityMod.NPCs.Leviathan if (CalamityGlobalNPC.LeviAndAna == -1) CalamityGlobalNPC.LeviAndAna = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; Vector2 npcCenter = NPC.Center; // Is in spawning animation @@ -200,7 +199,7 @@ namespace CalamityMod.NPCs.Leviathan bool notOcean = player.position.Y < 800f || player.position.Y > Main.worldSurface * 16D || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); // Enrage - if (notOcean && !bossRush) + if (notOcean && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) biomeEnrageTimer--; @@ -208,12 +207,12 @@ namespace CalamityMod.NPCs.Leviathan else biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; + bool biomeEnraged = biomeEnrageTimer <= 0; - float enrageScale = bossRush ? 1f : 0f; + float enrageScale = 0f; if (biomeEnraged) { - NPC.Calamity().CurrentlyEnraged = !bossRush; + NPC.Calamity().CurrentlyEnraged = true; enrageScale += 2f; } @@ -223,12 +222,10 @@ namespace CalamityMod.NPCs.Leviathan bool immuneToSlowingDebuffs = NPC.ai[0] == 2f; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; // Despawn @@ -394,7 +391,6 @@ namespace CalamityMod.NPCs.Leviathan { float speed = (sirenAlive && !phase4 && !death) ? 13.5f : 16f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); if (expertMode) speed = (sirenAlive && !phase4 && !death) ? 14f : 17f; @@ -413,12 +409,11 @@ namespace CalamityMod.NPCs.Leviathan if (Main.zenithWorld) { - type = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? ProjectileID.BouncyBoulder : ProjectileID.Boulder; + type = Main.rand.NextBool() ? ProjectileID.BouncyBoulder : ProjectileID.Boulder; leviCenter.Y -= 5; //Shoot a bit more up since boulders are affected by gravity - damage *= 2; } - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), leviCenter.X, leviCenter.Y, xDestination, yDestination, type, damage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), leviCenter.X, leviCenter.Y, xDestination, yDestination, type, BoulderDamage, 0f, Main.myPlayer); if (Main.zenithWorld) Main.projectile[proj].scale *= 5f; @@ -443,16 +438,8 @@ namespace CalamityMod.NPCs.Leviathan float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); NPC.ai[1] += 1f; - int activePlayerAmt = 0; - for (int i = 0; i < Main.maxPlayers; i++) - { - if (Main.player[i].active && !Main.player[i].dead && (npcCenter - Main.player[i].Center).Length() < 1000f) - activePlayerAmt++; - } - NPC.ai[1] += activePlayerAmt / 2; - bool spawnedAberration = false; - float aberrationSpawnDelay = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 20f : (!sirenAlive || phase4) ? 60f : 40f; + float aberrationSpawnDelay = Main.zenithWorld ? 20f : (!sirenAlive || phase4) ? 60f : 50f; if (NPC.ai[1] > aberrationSpawnDelay) { NPC.ai[1] = 0f; @@ -460,8 +447,8 @@ namespace CalamityMod.NPCs.Leviathan spawnedAberration = true; } - int spawnLimit = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10 : (sirenAlive && !phase4) ? 1 : (death ? 2 : 3); - if (spawnedAberration && NPC.CountNPCS(ModContent.NPCType()) < spawnLimit) + int spawnLimit = Main.zenithWorld ? 20 : Main.getGoodWorld ? 6 : (sirenAlive && !phase4) ? 0 : 2; + if (spawnedAberration && NPC.CountNPCS(ModContent.NPCType()) < spawnLimit && NPC.ai[2] <= spawnLimit) { SoundEngine.PlaySound(soundChoice with { Pitch = soundChoice.Pitch + extrapitch }, npcCenter); if (Main.netMode != NetmodeID.MultiplayerClient) @@ -810,7 +797,7 @@ namespace CalamityMod.NPCs.Leviathan } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.GreaterHealingPotion; } @@ -832,7 +819,7 @@ namespace CalamityMod.NPCs.Leviathan if (!Main.LocalPlayer.dead && Main.LocalPlayer.active) SoundEngine.PlaySound(CommonCalamitySounds.WyrmScreamSound, Main.LocalPlayer.Center); - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Mark Anahita & Leviathan as dead @@ -880,7 +867,8 @@ namespace CalamityMod.NPCs.Leviathan normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); normalOnly.Add(ModContent.ItemType(), 10); } @@ -891,10 +879,10 @@ namespace CalamityMod.NPCs.Leviathan // GFB Boulder, Pizza and Ring drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.BouncyBoulder, 1, 1, 9999, true); - GFBOnly.Add(ItemID.Boulder, 1, 1, 9999, true); - GFBOnly.Add(ItemID.Pizza, 1, 1, 9999, true); - GFBOnly.Add(ItemID.GreedyRing, hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.BouncyBoulder, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Boulder, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Pizza, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.GreedyRing), hideLootReport: true); } // Lore @@ -911,12 +899,6 @@ namespace CalamityMod.NPCs.Leviathan npcLoot.Add(ModContent.ItemType(), 10); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 180, true); - } - public override bool CheckActive() => false; public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -984,7 +966,6 @@ namespace CalamityMod.NPCs.Leviathan public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/LongDistanceNetSyncAttribute.cs b/NPCs/LongDistanceNetSyncAttribute.cs index b66d997580..7b04bbfb18 100644 --- a/NPCs/LongDistanceNetSyncAttribute.cs +++ b/NPCs/LongDistanceNetSyncAttribute.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria.ModLoader; namespace CalamityMod.NPCs { diff --git a/NPCs/NormalNPCs/AeroSlime.cs b/NPCs/NormalNPCs/AeroSlime.cs index a72b4648a6..78c8cc13cd 100644 --- a/NPCs/NormalNPCs/AeroSlime.cs +++ b/NPCs/NormalNPCs/AeroSlime.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Placeables.Ores; -using CalamityMod.World; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -30,7 +29,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 75; NPC.knockBackResist = 0.8f; AnimationType = NPCID.Slimer; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.alpha = 50; NPC.lavaImmune = false; NPC.noGravity = false; @@ -41,10 +40,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/ArmoredDiggerBody.cs b/NPCs/NormalNPCs/ArmoredDiggerBody.cs deleted file mode 100644 index a4ea0b9aeb..0000000000 --- a/NPCs/NormalNPCs/ArmoredDiggerBody.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System; -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Projectiles.Boss; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - [LongDistanceNetSync(SyncWith = typeof(ArmoredDiggerHead))] - public class ArmoredDiggerBody : ModNPC - { - public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.ArmoredDiggerHead.DisplayName"); - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - } - - public override void SetDefaults() - { - NPC.damage = 70; - NPC.width = 38; - NPC.height = 38; - NPC.defense = 20; - NPC.DR_NERD(0.2f); - NPC.lifeMax = 20000; - NPC.knockBackResist = 0f; - NPC.aiStyle = -1; - AIType = -1; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - NPC.dontCountMe = true; - Banner = ModContent.NPCType(); - BannerItem = ModContent.ItemType(); - NPC.Calamity().VulnerableToSickness = false; - NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (NPC.ai[3] > 0f && Main.npc[(int)NPC.ai[3]].type == ModContent.NPCType()) - { - NPC.realLife = (int)NPC.ai[3]; - } - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) - { - NPC.TargetClosest(true); - } - bool shouldDie = false; - if (NPC.ai[1] <= 0f) - { - shouldDie = true; - } - else if (Main.npc[(int)NPC.ai[1]].life <= 0) - { - shouldDie = true; - } - if (shouldDie) - { - if (!Main.zenithWorld) - { - NPC.life = 0; - NPC.HitEffect(0, 10.0); - NPC.checkDead(); - } - else - { - // find a new npc to attatch to in gfb, it's not a bug, it's a feature:tm: - foreach (NPC host in Main.ActiveNPCs) - { - 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; - break; - } - } - // if it goes through the loop without finding an npc to attatch to (aka, ai[1] never changes and the head is still dead) kill as normal - if (Main.npc[(int)NPC.ai[1]].life <= 0) - { - NPC.life = 0; - NPC.HitEffect(0, 10.0); - NPC.checkDead(); - } - } - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] += (float)Main.rand.Next(4); - if (NPC.localAI[0] >= (float)Main.rand.Next(1800, 26000)) - { - NPC.localAI[0] = 0f; - NPC.TargetClosest(true); - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, - Main.player[NPC.target].width, Main.player[NPC.target].height)) - { - float speed = 7f; - Vector2 projFirePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); - float projTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - projFirePosition.X + (float)Main.rand.Next(-20, 21); - float projTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - projFirePosition.Y + (float)Main.rand.Next(-20, 21); - float projTargetDist = (float)Math.Sqrt((double)(projTargetX * projTargetX + projTargetY * projTargetY)); - projTargetDist = speed / projTargetDist; - projTargetX *= projTargetDist; - projTargetY *= projTargetDist; - int projType = Main.zenithWorld ? ModContent.ProjectileType() : ProjectileID.SaucerScrap; - projFirePosition.X += projTargetX * 5f; - projFirePosition.Y += projTargetY * 5f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projFirePosition.X, projFirePosition.Y, projTargetX, projTargetY, projType, 30, 0f, Main.myPlayer, 0f, 0f); - NPC.netUpdate = true; - } - } - } - Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - targetXDist = (float)((int)(targetXDist / 16f) * 16); - targetYDist = (float)((int)(targetYDist / 16f) * 16); - segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); - segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); - targetXDist -= segmentPosition.X; - targetYDist -= segmentPosition.Y; - float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) - { - try - { - segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; - targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; - } - catch - { - } - NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; - targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - int segmentWidth = (int)(44f * NPC.scale); - targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; - targetXDist *= targetDistance; - targetYDist *= targetDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + targetXDist; - NPC.position.Y = NPC.position.Y + targetYDist; - } - - // Calculate contact damage based on velocity - float maxChaseSpeed = CalamityWorld.death ? 13.5f : 10f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } - } - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, hit.HitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - for (int k = 0; k < 10; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, hit.HitDirection, -1f, 0, default, 1f); - } - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("ArmoredDiggerBody").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("ArmoredDiggerBody2").Type, 1f); - } - } - } - - public override bool CheckActive() - { - return false; - } - - public override void ModifyTypeName(ref string typeName) - { - if (Main.zenithWorld) - { - typeName = CalamityUtils.GetTextValue("NPCs.MechanizedSerpent"); - } - } - - public override Color? GetAlpha(Color drawColor) - { - if (Main.zenithWorld) - { - Color lightColor = Color.Orange * drawColor.A; - return lightColor * NPC.Opacity; - } - else return null; - } - } -} diff --git a/NPCs/NormalNPCs/ArmoredDiggerBody.png b/NPCs/NormalNPCs/ArmoredDiggerBody.png deleted file mode 100644 index 6f582bdb3e..0000000000 Binary files a/NPCs/NormalNPCs/ArmoredDiggerBody.png and /dev/null differ diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs deleted file mode 100644 index 5f230ad2bb..0000000000 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ /dev/null @@ -1,523 +0,0 @@ -using System; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Summon; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - [LongDistanceNetSync] - public class ArmoredDiggerHead : ModNPC - { - bool TailSpawned = false; - - public override void SetStaticDefaults() - { - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - PortraitPositionXOverride = 40, - PortraitPositionYOverride = 40 - }; - value.Position.Y += 40; - value.Position.X += 48; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - } - - public override void SetDefaults() - { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.damage = 90; - NPC.npcSlots = 10f; - NPC.width = 54; - NPC.height = 54; - NPC.defense = 10; - NPC.DR_NERD(0.1f); - NPC.lifeMax = 20000; - NPC.knockBackResist = 0f; - NPC.aiStyle = -1; - AIType = -1; - NPC.value = Item.buyPrice(0, 5, 0, 0); - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - Banner = NPC.type; - BannerItem = ModContent.ItemType(); - NPC.Calamity().VulnerableToSickness = false; - NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Caverns, - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.ArmoredDigger") - }); - } - - public override void AI() - { - Point point = NPC.Center.ToTileCoordinates(); - Tile tileSafely = Framing.GetTileSafely(point); - bool createDust = tileSafely.HasUnactuatedTile && NPC.Distance(Main.player[NPC.target].Center) < 800f; - if (createDust) - { - if (Main.rand.NextBool()) - { - Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.TreasureSparkle, 0f, 0f, 150, default(Color), 0.3f); - dust.fadeIn = 0.75f; - dust.velocity *= 0.1f; - dust.noLight = true; - } - } - - bool death = CalamityWorld.death; - if (NPC.ai[3] > 0f) - { - NPC.realLife = (int)NPC.ai[3]; - } - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) - { - NPC.TargetClosest(true); - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!TailSpawned) - { - NPC.ai[3] = (float)NPC.whoAmI; - NPC.realLife = NPC.whoAmI; - int thisSegment = NPC.whoAmI; - int segmentAmt = 30; - for (int j = 0; j <= segmentAmt; j++) - { - int segmentType = ModContent.NPCType(); - if (j == segmentAmt) - { - segmentType = ModContent.NPCType(); - } - int newSegment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), segmentType, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[newSegment].ai[3] = (float)NPC.whoAmI; - Main.npc[newSegment].realLife = NPC.whoAmI; - Main.npc[newSegment].ai[1] = (float)thisSegment; - Main.npc[thisSegment].ai[0] = (float)newSegment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, newSegment, 0f, 0f, 0f, 0, 0, 0); - thisSegment = newSegment; - } - TailSpawned = true; - } - } - int tileXPosition = (int)(NPC.position.X / 16f) - 1; - int tileWidthXPos = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; - int tileYPosition = (int)(NPC.position.Y / 16f) - 1; - int tileWidthYPos = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; - if (tileXPosition < 0) - { - tileXPosition = 0; - } - if (tileWidthXPos > Main.maxTilesX) - { - tileWidthXPos = Main.maxTilesX; - } - if (tileYPosition < 0) - { - tileYPosition = 0; - } - if (tileWidthYPos > Main.maxTilesY) - { - tileWidthYPos = Main.maxTilesY; - } - bool flying = false; - if (!flying) - { - for (int k = tileXPosition; k < tileWidthXPos; k++) - { - for (int l = tileYPosition; l < tileWidthYPos; l++) - { - if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[k, l].TileType] || (Main.tileSolidTop[(int)Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) - { - Vector2 segmentPos; - segmentPos.X = (float)(k * 16); - segmentPos.Y = (float)(l * 16); - if (NPC.position.X + (float)NPC.width > segmentPos.X && NPC.position.X < segmentPos.X + 16f && NPC.position.Y + (float)NPC.height > segmentPos.Y && NPC.position.Y < segmentPos.Y + 16f) - { - flying = true; - break; - } - } - } - } - } - if (!flying) - { - NPC.localAI[1] = 1f; - Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int noFlyZone = 1000; - bool outsideNoFlyZone = true; - if (NPC.position.Y > Main.player[NPC.target].position.Y) - { - foreach (Player player in Main.ActivePlayers) - { - Rectangle noFlyArea = new Rectangle((int)player.position.X - noFlyZone, (int)player.position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); - if (rectangle.Intersects(noFlyArea)) - { - outsideNoFlyZone = false; - break; - } - } - if (outsideNoFlyZone) - { - flying = true; - } - } - } - else - { - NPC.localAI[1] = 0f; - } - float maxChaseSpeed = death ? 13.5f : 10f; - if (Main.player[NPC.target].dead || (!Main.zenithWorld && (double)Main.player[NPC.target].position.Y < Main.rockLayer * 16.0)) - { - flying = false; - NPC.velocity.Y = NPC.velocity.Y + 1f; - if ((double)NPC.position.Y > Main.rockLayer * 16.0) - { - NPC.velocity.Y = NPC.velocity.Y + 1f; - maxChaseSpeed *= 2f; - } - if ((double)NPC.position.Y > (double)(Main.UnderworldLayer * 16)) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || - Main.npc[a].type == ModContent.NPCType()) - { - Main.npc[a].active = false; - } - } - } - } - float acceleration = death ? 0.0675f : 0.05f; - float deceleration = death ? 0.10125f : 0.075f; - Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - targetXDist = (float)((int)(targetXDist / 16f) * 16); - targetYDist = (float)((int)(targetYDist / 16f) * 16); - segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); - segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); - targetXDist -= segmentPosition.X; - targetYDist -= segmentPosition.Y; - float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - if (!flying) - { - NPC.TargetClosest(true); - NPC.velocity.Y = NPC.velocity.Y + 0.15f; - if (NPC.velocity.Y > maxChaseSpeed) - { - NPC.velocity.Y = maxChaseSpeed; - } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.4) - { - if (NPC.velocity.X < 0f) - { - NPC.velocity.X = NPC.velocity.X - acceleration * 1.1f; - } - else - { - NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; - } - } - else if (NPC.velocity.Y == maxChaseSpeed) - { - if (NPC.velocity.X < targetXDist) - { - NPC.velocity.X = NPC.velocity.X + acceleration; - } - else if (NPC.velocity.X > targetXDist) - { - NPC.velocity.X = NPC.velocity.X - acceleration; - } - } - else if (NPC.velocity.Y > 4f) - { - if (NPC.velocity.X < 0f) - { - NPC.velocity.X = NPC.velocity.X + acceleration * 0.9f; - } - else - { - NPC.velocity.X = NPC.velocity.X - acceleration * 0.9f; - } - } - } - else - { - if (NPC.soundDelay == 0) - { - float soundDelay = targetDistance / 40f; - if (soundDelay < 10f) - { - soundDelay = 10f; - } - if (soundDelay > 20f) - { - soundDelay = 20f; - } - NPC.soundDelay = (int)soundDelay; - SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); - } - targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - float absoluteTargetX = Math.Abs(targetXDist); - float absoluteTargetY = Math.Abs(targetYDist); - float timeToReachTarget = maxChaseSpeed / targetDistance; - targetXDist *= timeToReachTarget; - targetYDist *= timeToReachTarget; - if (((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f)) && ((NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f))) - { - if (NPC.velocity.X < targetXDist) - { - NPC.velocity.X = NPC.velocity.X + deceleration; - } - else if (NPC.velocity.X > targetXDist) - { - NPC.velocity.X = NPC.velocity.X - deceleration; - } - if (NPC.velocity.Y < targetYDist) - { - NPC.velocity.Y = NPC.velocity.Y + deceleration; - } - else if (NPC.velocity.Y > targetYDist) - { - NPC.velocity.Y = NPC.velocity.Y - deceleration; - } - } - if ((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f) || (NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f)) - { - if (NPC.velocity.X < targetXDist) - { - NPC.velocity.X = NPC.velocity.X + acceleration; - } - else if (NPC.velocity.X > targetXDist) - { - NPC.velocity.X = NPC.velocity.X - acceleration; - } - if (NPC.velocity.Y < targetYDist) - { - NPC.velocity.Y = NPC.velocity.Y + acceleration; - } - else if (NPC.velocity.Y > targetYDist) - { - NPC.velocity.Y = NPC.velocity.Y - acceleration; - } - if ((double)Math.Abs(targetYDist) < (double)maxChaseSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDist < 0f) || (NPC.velocity.X < 0f && targetXDist > 0f))) - { - if (NPC.velocity.Y > 0f) - { - NPC.velocity.Y = NPC.velocity.Y + acceleration * 2f; - } - else - { - NPC.velocity.Y = NPC.velocity.Y - acceleration * 2f; - } - } - if ((double)Math.Abs(targetXDist) < (double)maxChaseSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDist < 0f) || (NPC.velocity.Y < 0f && targetYDist > 0f))) - { - if (NPC.velocity.X > 0f) - { - NPC.velocity.X = NPC.velocity.X + acceleration * 2f; - } - else - { - NPC.velocity.X = NPC.velocity.X - acceleration * 2f; - } - } - } - else if (absoluteTargetX > absoluteTargetY) - { - if (NPC.velocity.X < targetXDist) - { - NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; - } - else if (NPC.velocity.X > targetXDist) - { - NPC.velocity.X = NPC.velocity.X - acceleration * 1.1f; - } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.5) - { - if (NPC.velocity.Y > 0f) - { - NPC.velocity.Y = NPC.velocity.Y + acceleration; - } - else - { - NPC.velocity.Y = NPC.velocity.Y - acceleration; - } - } - } - else - { - if (NPC.velocity.Y < targetYDist) - { - NPC.velocity.Y = NPC.velocity.Y + acceleration * 1.1f; - } - else if (NPC.velocity.Y > targetYDist) - { - NPC.velocity.Y = NPC.velocity.Y - acceleration * 1.1f; - } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChaseSpeed * 0.5) - { - if (NPC.velocity.X > 0f) - { - NPC.velocity.X = NPC.velocity.X + acceleration; - } - else - { - NPC.velocity.X = NPC.velocity.X - acceleration; - } - } - } - } - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } - - NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f; - - if (flying) - { - if (NPC.localAI[0] != 1f) - { - NPC.netUpdate = true; - } - NPC.localAI[0] = 1f; - } - else - { - if (NPC.localAI[0] != 0f) - { - NPC.netUpdate = true; - } - NPC.localAI[0] = 0f; - } - if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) - { - NPC.netUpdate = true; - } - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - Player player = spawnInfo.Player; - bool gfbCondition = Main.zenithWorld && (player.ZoneHallow || player.ZoneUnderworldHeight) && NPC.downedMoonlord; - if ((gfbCondition || (player.ZoneRockLayerHeight && !player.ZoneUnderworldHeight && !player.ZoneJungle)) && !player.ZoneDungeon && !player.Calamity().ZoneSunkenSea && !player.Calamity().ZoneAbyss) - { - if (!CalamityPlayer.areThereAnyDamnBosses && NPC.downedPlantBoss && !NPC.AnyNPCs(ModContent.NPCType())) - { - float spawnRateDivisor = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 125f : CalamityWorld.revenge ? 425f : 500f; - return 1 / spawnRateDivisor; - } - } - return 0f; - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ItemID.GreaterHealingPotion; - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, hit.HitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - for (int k = 0; k < 10; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, hit.HitDirection, -1f, 0, default, 1f); - } - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("ArmoredDiggerHead").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("ArmoredDiggerHead2").Type, 1f); - } - } - } - - public override bool SpecialOnKill() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(NPC, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - NPC.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(ModContent.ItemType(), 1, 4, 8); - npcLoot.Add(ModContent.ItemType(), 1, 4, 8); - npcLoot.AddIf(() => Main.zenithWorld, ModContent.ItemType(), 1, 3, 6, ui: false); - npcLoot.AddIf(() => Main.zenithWorld, ModContent.ItemType(), 10, ui: false); - } - - public override void ModifyTypeName(ref string typeName) - { - if (Main.zenithWorld) - { - typeName = CalamityUtils.GetTextValue("NPCs.MechanizedSerpent"); - } - } - - public override Color? GetAlpha(Color drawColor) - { - if (Main.zenithWorld) - { - Color lightColor = Color.Orange * drawColor.A; - return lightColor * NPC.Opacity; - } - else return null; - } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - if (NPC.IsABestiaryIconDummy) - { - return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, TextureAssets.Npc[Type].Value, TextureAssets.Npc[ModContent.NPCType()].Value, 4, 26, 0.6f, new Vector2(10, -10), 4, 16); - } - return true; - } - } -} diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.png b/NPCs/NormalNPCs/ArmoredDiggerHead.png deleted file mode 100644 index ee6a1bdf46..0000000000 Binary files a/NPCs/NormalNPCs/ArmoredDiggerHead.png and /dev/null differ diff --git a/NPCs/NormalNPCs/ArmoredDiggerTail.cs b/NPCs/NormalNPCs/ArmoredDiggerTail.cs deleted file mode 100644 index 8aa015ef78..0000000000 --- a/NPCs/NormalNPCs/ArmoredDiggerTail.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - [LongDistanceNetSync(SyncWith = typeof(ArmoredDiggerHead))] - public class ArmoredDiggerTail : ModNPC - { - public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.ArmoredDiggerHead.DisplayName"); - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - } - - public override void SetDefaults() - { - NPC.damage = 55; - NPC.width = 34; - NPC.height = 34; - NPC.defense = 30; - NPC.DR_NERD(0.3f); - NPC.lifeMax = 20000; - NPC.knockBackResist = 0f; - NPC.aiStyle = -1; - AIType = -1; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - NPC.dontCountMe = true; - Banner = ModContent.NPCType(); - BannerItem = ModContent.ItemType(); - NPC.Calamity().VulnerableToSickness = false; - NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (NPC.ai[3] > 0f && Main.npc[(int)NPC.ai[3]].type == ModContent.NPCType()) - { - NPC.realLife = (int)NPC.ai[3]; - } - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) - { - NPC.TargetClosest(true); - } - bool shouldDie = false; - if (NPC.ai[1] <= 0f) - { - shouldDie = true; - } - else if (Main.npc[(int)NPC.ai[1]].life <= 0) - { - shouldDie = true; - } - if (shouldDie && !Main.zenithWorld) - { - NPC.life = 0; - NPC.HitEffect(0, 10.0); - NPC.checkDead(); - } - Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - targetXDist = (float)((int)(targetXDist / 16f) * 16); - targetYDist = (float)((int)(targetYDist / 16f) * 16); - segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); - segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); - targetXDist -= segmentPosition.X; - targetYDist -= segmentPosition.Y; - float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) - { - try - { - segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; - targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; - } - catch - { - } - NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; - targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - int segmentWidth = (int)(44f * NPC.scale); - targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; - targetXDist *= targetDistance; - targetYDist *= targetDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + targetXDist; - NPC.position.Y = NPC.position.Y + targetYDist; - } - - // Calculate contact damage based on velocity - float maxChaseSpeed = CalamityWorld.death ? 13.5f : 10f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, hit.HitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - for (int k = 0; k < 10; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, hit.HitDirection, -1f, 0, default, 1f); - } - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("ArmoredDiggerTail").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("ArmoredDiggerTail2").Type, 1f); - } - } - } - - public override void ModifyTypeName(ref string typeName) - { - if (Main.zenithWorld) - { - typeName = CalamityUtils.GetTextValue("NPCs.MechanizedSerpent"); - } - } - - public override Color? GetAlpha(Color drawColor) - { - if (Main.zenithWorld) - { - Color lightColor = Color.Orange * drawColor.A; - return lightColor * NPC.Opacity; - } - else return null; - } - } -} diff --git a/NPCs/NormalNPCs/ArmoredDiggerTail.png b/NPCs/NormalNPCs/ArmoredDiggerTail.png deleted file mode 100644 index ce25bd2ffe..0000000000 Binary files a/NPCs/NormalNPCs/ArmoredDiggerTail.png and /dev/null differ diff --git a/NPCs/NormalNPCs/AuroraSpirit.cs b/NPCs/NormalNPCs/AuroraSpirit.cs index 8c65b93520..95e4beec0b 100644 --- a/NPCs/NormalNPCs/AuroraSpirit.cs +++ b/NPCs/NormalNPCs/AuroraSpirit.cs @@ -32,8 +32,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 24; NPC.defense = 8; NPC.alpha = 100; - NPC.lifeMax = 65; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.lifeMax = 200; + NPC.value = Item.buyPrice(silver: 1); NPC.knockBackResist = 0f; NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath15; @@ -43,10 +43,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -105,8 +101,8 @@ namespace CalamityMod.NPCs.NormalNPCs { if (hurtInfo.Damage > 0) { - target.AddBuff(BuffID.Frostburn, 90, true); - target.AddBuff(BuffID.Chilled, 60, true); + target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(BuffID.Chilled, 60); } } diff --git a/NPCs/NormalNPCs/BloodlettingServant.cs b/NPCs/NormalNPCs/BloodlettingServant.cs deleted file mode 100644 index d2b172c462..0000000000 --- a/NPCs/NormalNPCs/BloodlettingServant.cs +++ /dev/null @@ -1,326 +0,0 @@ -using System; -using CalamityMod.Events; -using CalamityMod.Gores; -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; - -namespace CalamityMod.NPCs.NormalNPCs -{ - public class BloodlettingServant : ModNPC - { - 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[Type] = 6; - NPCID.Sets.TrailingMode[Type] = 1; - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); - } - - public override void SetDefaults() - { - NPC.aiStyle = -1; - AIType = -1; - NPC.GetNPCDamage(); - NPC.width = 44; - NPC.height = 30; - if (Main.tenthAnniversaryWorld) - NPC.scale *= 0.5f; - if (Main.getGoodWorld) - NPC.scale *= 1.1f; - - NPC.defense = 5; - NPC.lifeMax = 96; - NPC.knockBackResist = 0f; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToHeat = true; - NPC.Calamity().VulnerableToSickness = true; - } - - public override void AI() - { - Lighting.AddLight(NPC.Center, 0.3f, 0.3f, 0.3f); - - NPC.TargetClosest(); - Player target = Main.player[NPC.target]; - 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; - float xAccel = maxSpeedX * 0.01f; - float xAccelBoost1 = maxSpeedX * 0.01f; - float xAccelBoost2 = maxSpeedX * 0.0075f; - float yAccel = maxSpeedY * 0.01f; - float yAccelBoost1 = maxSpeedY * 0.01f; - float yAccelBoost2 = maxSpeedY * 0.0075f; - - 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.ForceNetUpdate(); - } - - 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.ForceNetUpdate(); - } - } - } - else - { - if (lookAt.X > 0f) - { - NPC.spriteDirection = 1; - NPC.rotation = lookAt.ToRotation(); - } - if (lookAt.X < 0f) - { - NPC.spriteDirection = -1; - NPC.rotation = lookAt.ToRotation() + 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.ForceNetUpdate(); - } - } - else - NPC.damage = NPC.defDamage; - - if (targetDead) - { - NPC.velocity.Y -= 0.04f; - - if (NPC.timeLeft > 10) - NPC.timeLeft = 10; - } - else if (!attemptingToCharge) - { - DemonEyeAI.DemonEyeBatMovement(NPC, maxSpeedX, maxSpeedY, xAccel, xAccelBoost1, xAccelBoost2, yAccel, yAccelBoost1, yAccelBoost2); - - NPC.ai[3] += enrageScale; - 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) - { - 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.ForceNetUpdate(); - } - - 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)) - { - Vector2 dustSpawnTopLeft = new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f); - Dust blood = Dust.NewDustDirect(dustSpawnTopLeft, NPC.width, NPC.height / 2, DustID.Blood, NPC.velocity.X, 2f, 0, new Color(128, 0, 0, 255 - NPC.alpha), 1f); - blood.velocity.X *= 0.5f; - blood.velocity.Y *= 0.1f; - } - } - - public override void FindFrame(int frameHeight) - { - NPC.frameCounter += 1D; - if (NPC.life < NPC.lifeMax * 0.5) - { - if (NPC.frame.Y < frameHeight * 3) - NPC.frame.Y = frameHeight * 3; - if (NPC.frameCounter >= 8D) - { - NPC.frameCounter = 0D; - NPC.frame.Y += frameHeight; - if (NPC.frame.Y > frameHeight * 5) - NPC.frame.Y = frameHeight * 3; - } - } - else - { - if (NPC.frameCounter >= 8D) - { - NPC.frameCounter = 0D; - NPC.frame.Y += frameHeight; - if (NPC.frame.Y > frameHeight * 2) - NPC.frame.Y = 0; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - if (NPC.ai[0] >= ChargeTelegraphGateValue) - { - Texture2D npcTexture = TextureAssets.Npc[Type].Value; - Color originalColor = NPC.GetAlpha(drawColor); - Color newColor = new Color(192, 0, 0, 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 (CalamityClientConfig.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[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 void HitEffect(NPC.HitInfo hit) - { - if (Main.dedServ) - return; - - if (NPC.life > 0) - { - for (int i = 0; i < hit.Damage / (double)NPC.lifeMax * 100; i++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f); - - if (NPC.life < NPC.lifeMax * 0.5f && NPC.localAI[0] == 0f) - { - NPC.localAI[0] = 1f; - Gore.NewGore(NPC.GetSource_FromThis(), NPC.Center, NPC.velocity, Mod.Find("BloodlettingServant1").Type); - for (int i = 0; i < 50; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 2f * hit.HitDirection, -2f); - Main.dust[dust].scale = Main.rand.NextFloat(1.6f, 2.4f); - Main.dust[dust].velocity *= Main.rand.NextFloat(1.6f, 2.4f); - Main.dust[dust].color = new Color(128, 0, 0, 255 - NPC.alpha); - } - } - } - else - { - for (int i = 0; i < 100; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 2f * hit.HitDirection, -2f); - Main.dust[dust].scale = Main.rand.NextFloat(1.6f, 2.4f); - Main.dust[dust].velocity *= Main.rand.NextFloat(1.6f, 2.4f); - Main.dust[dust].color = new Color(128, 0, 0, 255 - NPC.alpha); - } - for (int g = 2; g <= 4; g++) - { - Vector2 goreVel = NPC.velocity.RotatedByRandom(MathHelper.Pi); - Gore.NewGore(NPC.GetSource_Death(), NPC.Center, goreVel, Mod.Find("BloodlettingServant" + g).Type); - } - } - } - } -} diff --git a/NPCs/NormalNPCs/BloodlettingServant.png b/NPCs/NormalNPCs/BloodlettingServant.png deleted file mode 100644 index 5bb5258c6c..0000000000 Binary files a/NPCs/NormalNPCs/BloodlettingServant.png and /dev/null differ diff --git a/NPCs/NormalNPCs/BloomSlime.cs b/NPCs/NormalNPCs/BloomSlime.cs index bc4f8c9849..283baad070 100644 --- a/NPCs/NormalNPCs/BloomSlime.cs +++ b/NPCs/NormalNPCs/BloomSlime.cs @@ -23,11 +23,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 80; NPC.width = 40; NPC.height = 30; - NPC.defense = 25; - NPC.lifeMax = 1500; + NPC.defense = 40; + NPC.lifeMax = 2000; NPC.knockBackResist = 0.3f; AnimationType = NPCID.CorruptSlime; - NPC.value = Item.buyPrice(0, 0, 25, 0); + NPC.value = Item.buyPrice(silver: 25); NPC.alpha = 50; NPC.lavaImmune = false; NPC.noGravity = false; @@ -38,10 +38,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/Bohldohr.cs b/NPCs/NormalNPCs/Bohldohr.cs index a6a4b88510..f6af30ac41 100644 --- a/NPCs/NormalNPCs/Bohldohr.cs +++ b/NPCs/NormalNPCs/Bohldohr.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Placeables; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.SummonItems; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using CalamityMod.NPCs.Other; using CalamityMod.World; using Terraria; @@ -16,16 +15,15 @@ namespace CalamityMod.NPCs.NormalNPCs { public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; NPC.aiStyle = -1; AIType = -1; NPC.damage = 80; NPC.width = 40; NPC.height = 40; - NPC.defense = 18; - NPC.lifeMax = 375; + NPC.defense = 32; + NPC.lifeMax = 600; NPC.knockBackResist = 0.95f; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.HitSound = SoundID.NPCHit7; NPC.DeathSound = SoundID.NPCDeath35; NPC.behindTiles = true; @@ -33,10 +31,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -99,7 +93,6 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.LihzahrdBrick, 1, 10, 26); npcLoot.Add(ModContent.ItemType(), 1, 10, 26); npcLoot.Add(ItemID.LunarTabletFragment, 7, 10, 26); npcLoot.Add(ItemID.LihzahrdPowerCell, 50); diff --git a/NPCs/NormalNPCs/BucketZombie.cs b/NPCs/NormalNPCs/BucketZombie.cs index d0b4edf209..0038b3ed86 100644 --- a/NPCs/NormalNPCs/BucketZombie.cs +++ b/NPCs/NormalNPCs/BucketZombie.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using CalamityMod.Projectiles.Summon; -using CalamityMod.World; using Terraria; using Terraria.Audio; using Terraria.GameContent.Bestiary; @@ -25,30 +23,17 @@ namespace CalamityMod.NPCs.NormalNPCs AnimationType = NPCID.Zombie; NPC.aiStyle = NPCAIStyleID.Fighter; NPC.CloneDefaults(NPCID.Zombie); - NPC.lifeMax = 50; + NPC.lifeMax = 60; NPC.defense = 15; NPC.damage = 16; NPC.knockBackResist = 0.45f; - NPC.value = Item.buyPrice(0, 0, 1, 0); - Banner = NPCID.Zombie; + NPC.npcSlots = 1.15f; // Equal to the strongest variants + NPC.value = Item.buyPrice(silver: 1); + Banner = Item.NPCtoBanner(NPCID.Zombie); BannerItem = ItemID.ZombieBanner; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override bool PreAI() - { - if (CalamityWorld.revenge) - { - VanillaNPCAIOverrides.RegularEnemies.RevengeanceAndDeathAI.BuffedFighterAI(NPC, Mod); - return false; - } - return true; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CalamityRegularEnemyAI.cs b/NPCs/NormalNPCs/CalamityRegularEnemyAI.cs new file mode 100644 index 0000000000..edb77ef352 --- /dev/null +++ b/NPCs/NormalNPCs/CalamityRegularEnemyAI.cs @@ -0,0 +1,726 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.Crags; +using CalamityMod.NPCs.SulphurousSea; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.Projectiles.Enemy; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.NormalNPCs +{ + public static class CalamityRegularEnemyAI + { + #region Gem Crawler AI + public static void GemCrawlerAI(NPC npc, Mod mod, float speedDetect, float speedAdditive) + { + var turnAroundDelay = 30; + var unusedFlag = false; + var isRunning = false; + var shouldTurnAround = false; + if (npc.velocity.Y == 0f && (npc.velocity.X > 0f && npc.direction > 0 || npc.velocity.X < 0f && npc.direction < 0)) + { + isRunning = true; + npc.ai[3] += 1f; + } + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= turnAroundDelay) | isRunning) + { + npc.ai[3] += 1f; + shouldTurnAround = true; + } + else if (npc.ai[3] > 0f) + { + npc.ai[3] -= 1f; + } + if (npc.ai[3] > turnAroundDelay * 10) + { + npc.ai[3] = 0f; + } + if (npc.justHit) + { + npc.ai[3] = 0f; + } + if (npc.ai[3] == turnAroundDelay) + { + npc.netUpdate = true; + } + var npcPos = new Vector2(npc.Center.X, npc.Center.Y); + var xDist = Main.player[npc.target].Center.X - npcPos.X; + var yDist = Main.player[npc.target].Center.Y - npcPos.Y; + var targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); + if (targetDist < 200f && !shouldTurnAround) + { + npc.ai[3] = 0f; + } + if (npc.ai[3] < turnAroundDelay) + { + npc.TargetClosest(true); + } + else + { + if (npc.velocity.X == 0f) + { + if (npc.velocity.Y == 0f) + { + npc.ai[0] += 1f; + if (npc.ai[0] >= 2f) + { + npc.direction *= -1; + npc.spriteDirection = -npc.direction; + npc.ai[0] = 0f; + } + } + } + else + { + npc.ai[0] = 0f; + } + npc.directionY = -1; + if (npc.direction == 0) + { + npc.direction = 1; + } + } + var maxVelocity = speedDetect; //5 + var acceleration = speedAdditive; //0.05 + if (!unusedFlag && (npc.velocity.Y == 0f || npc.wet || npc.velocity.X <= 0f && npc.direction > 0 || npc.velocity.X >= 0f && npc.direction < 0)) + { + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < maxVelocity && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X > maxVelocity) + { + npc.velocity.X = maxVelocity; + } + } + else if (npc.velocity.X > -maxVelocity && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.velocity.X < -maxVelocity) + { + npc.velocity.X = -maxVelocity; + } + } + } + if (npc.velocity.Y >= 0f) + { + var faceDirection = 0; + if (npc.velocity.X < 0f) + { + faceDirection = -1; + } + if (npc.velocity.X > 0f) + { + faceDirection = 1; + } + var position = npc.position; + position.X += npc.velocity.X; + var x = (int)((position.X + npc.width / 2 + (npc.width / 2 + 1) * faceDirection) / 16f); + var y = (int)((position.Y + npc.height - 1f) / 16f); + if (x * 16 < position.X + npc.width && x * 16 + 16 > position.X && (Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[Main.tile[x, y].TileType] && !Main.tileSolidTop[Main.tile[x, y].TileType] || Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[Main.tile[x, y - 1].TileType] || Main.tileSolidTop[Main.tile[x, y - 1].TileType] || Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[Main.tile[x, y - 4].TileType] || Main.tileSolidTop[Main.tile[x, y - 4].TileType])) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[Main.tile[x, y - 2].TileType] || Main.tileSolidTop[Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[Main.tile[x, y - 3].TileType] || Main.tileSolidTop[Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[Main.tile[x - faceDirection, y - 3].TileType])) + { + var npcBottom = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) + { + npcBottom += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + npcBottom -= 8f; + } + if (npcBottom < position.Y + npc.height) + { + var percentageTileRisen = position.Y + npc.height - npcBottom; + if (percentageTileRisen <= 16.1f) + { + npc.gfxOffY += npc.position.Y + npc.height - npcBottom; + npc.position.Y = npcBottom - npc.height; + if (percentageTileRisen < 9f) + { + npc.stepSpeed = 1f; + } + else + { + npc.stepSpeed = 2f; + } + } + } + } + } + } + #endregion + + #region Dungeon Spirit AI + public static void DungeonSpiritAI(NPC npc, Mod mod, float speed, float rotation, bool lantern = false) + { + npc.TargetClosest(true); + var npcPos = new Vector2(npc.Center.X, npc.Center.Y); + var xDist = Main.player[npc.target].Center.X - npcPos.X; + var yDist = Main.player[npc.target].Center.Y - npcPos.Y; + var targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); + var homingSpeed = speed; + + if (lantern) + { + if (npc.localAI[0] < 85f) + { + homingSpeed = 0.1f; + targetDist = homingSpeed / targetDist; + xDist *= targetDist; + yDist *= targetDist; + npc.velocity = (npc.velocity * 100f + new Vector2(xDist, yDist)) / 101f; + npc.localAI[0] += 1f; + return; + } + + npc.dontTakeDamage = false; + } + + targetDist = homingSpeed / targetDist; + xDist *= targetDist; + yDist *= targetDist; + npc.velocity.X = (npc.velocity.X * 100f + xDist) / 101f; + npc.velocity.Y = (npc.velocity.Y * 100f + yDist) / 101f; + + if (lantern) + { + npc.rotation = npc.velocity.X * 0.08f; + npc.spriteDirection = npc.direction > 0 ? 1 : -1; + } + else + npc.rotation = (float)Math.Atan2((double)yDist, (double)xDist) + rotation; + } + #endregion + + #region Unicorn AI + public static void UnicornAI(NPC npc, Mod mod, bool spin, float bounciness, float speedDetect, float speedAdditive, float bouncy1 = -8.5f, float bouncy2 = -7.5f, float bouncy3 = -7f, float bouncy4 = -6f, float bouncy5 = -8f) + { + var DogPhase1 = npc.type == ModContent.NPCType() && npc.life > npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); + var DogPhase2 = npc.type == ModContent.NPCType() && npc.life <= npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); + var turnAroundDelay = 30; + var isRunning = false; + var shouldTurnAround = false; + if (npc.velocity.Y == 0f && (npc.velocity.X > 0f && npc.direction < 0 || npc.velocity.X < 0f && npc.direction > 0)) + { + isRunning = true; + npc.ai[3] += 1f; + } + var turnAroundDelayMult = DogPhase1 ? 10 : 4; + if (!DogPhase1) + { + var noYVelocity = npc.velocity.Y == 0f; + for (var i = 0; i < Main.maxNPCs; i++) + { + 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) < npc.width) + { + if (npc.position.X < Main.npc[i].position.X) + { + npc.velocity.X -= 0.05f; + } + else + { + npc.velocity.X += 0.05f; + } + if (npc.position.Y < Main.npc[i].position.Y) + { + npc.velocity.Y -= 0.05f; + } + else + { + npc.velocity.Y += 0.05f; + } + } + } + if (noYVelocity) + { + npc.velocity.Y = 0f; + } + } + if (npc.position.X == npc.oldPosition.X || npc.ai[3] >= turnAroundDelay || isRunning) + { + npc.ai[3] += 1f; + shouldTurnAround = true; + } + else if (npc.ai[3] > 0f) + { + npc.ai[3] -= 1f; + } + if (npc.ai[3] > turnAroundDelay * turnAroundDelayMult) + { + npc.ai[3] = 0f; + } + if (npc.justHit) + { + npc.ai[3] = 0f; + } + if (npc.ai[3] == turnAroundDelay) + { + npc.netUpdate = true; + } + var npcPos = new Vector2(npc.Center.X, npc.Center.Y); + var xDist = Main.player[npc.target].Center.X - npcPos.X; + var yDist = Main.player[npc.target].Center.Y - npcPos.Y; + var targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); + if (targetDist < 200f && !shouldTurnAround) + { + npc.ai[3] = 0f; + } + if (!DogPhase1) + { + if (npc.velocity.Y == 0f && Math.Abs(npc.velocity.X) > 3f && (npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f || npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f)) + { + npc.velocity.Y -= bounciness; + if (npc.type == ModContent.NPCType()) + { + SoundEngine.PlaySound(SoundID.Item14, npc.Center); + for (var k = 0; k < 10; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, -1f, 0, default, 1f); + } + if (Main.zenithWorld) + { + var screenShakePower = 2 * Utils.GetLerpValue(1300f, 0f, npc.Distance(Main.LocalPlayer.Center), true); + Main.LocalPlayer.SetScreenshake(screenShakePower); + } + } + if (npc.type == ModContent.NPCType()) + { + SoundEngine.PlaySound(SoundID.NPCHit7, npc.Center); + } + if (DogPhase2) + { + for (var k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Water, 0f, -1f, 0, default, 1f); + } + } + if (npc.type == ModContent.NPCType()) + { + for (var k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, DustID.Water, 0f, -1f, 0, default, 1f); + } + } + } + } + if (npc.ai[3] < turnAroundDelay) + { + npc.TargetClosest(true); + } + else + { + if (npc.velocity.X == 0f) + { + if (npc.velocity.Y == 0f) + { + npc.ai[0] += 1f; + if (npc.ai[0] >= 2f) + { + npc.direction *= -1; + npc.spriteDirection = npc.direction; + npc.ai[0] = 0f; + } + } + } + else + { + npc.ai[0] = 0f; + } + npc.directionY = -1; + if (npc.direction == 0) + { + npc.direction = 1; + } + } + + if (npc.velocity.Y == 0f || npc.wet || npc.velocity.X <= 0f && npc.direction < 0 || npc.velocity.X >= 0f && npc.direction > 0) + { + if (Math.Sign(npc.velocity.X) != npc.direction && !DogPhase1) + { + npc.velocity.X *= 0.92f; + } + var sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * Math.Sign(Main.windSpeedCurrent); + if (!Main.player[npc.target].ZoneSandstorm) + { + sandstormPush = 0f; + } + var maxVelocity = speedDetect; + var acceleration = speedAdditive; + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < maxVelocity && npc.direction == 1) + { + npc.velocity.X += acceleration; + if (npc.velocity.X > maxVelocity) + { + npc.velocity.X = maxVelocity; + } + } + else if (npc.velocity.X > -maxVelocity && npc.direction == -1) + { + npc.velocity.X -= acceleration; + if (npc.velocity.X < -maxVelocity) + { + npc.velocity.X = -maxVelocity; + } + } + } + if (npc.velocity.Y >= 0f) + { + var faceDirection = 0; + if (npc.velocity.X < 0f) + { + faceDirection = -1; + } + if (npc.velocity.X > 0f) + { + faceDirection = 1; + } + var position = npc.position; + position.X += npc.velocity.X; + var x = (int)((position.X + npc.width / 2 + (npc.width / 2 + 1) * faceDirection) / 16f); + var y = (int)((position.Y + npc.height - 1f) / 16f); + + // 21JAN2023: Ozzatron -- this is probably the single most unmaintainable if statement I've ever seen + // I have broken all the individual statements out even though I do not fully understand the code. + var t_xy = CalamityUtils.ParanoidTileRetrieval(x, y); + var t_xy1 = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + var t_xy2 = CalamityUtils.ParanoidTileRetrieval(x, y - 2); + var t_xy3 = CalamityUtils.ParanoidTileRetrieval(x, y - 3); + var t_xOffY3 = CalamityUtils.ParanoidTileRetrieval(x - faceDirection, y - 3); // 3 down, offset 1 in the direction of the NPC's movement + var t_xy4 = CalamityUtils.ParanoidTileRetrieval(x, y - 4); + var positionCheck = x * 16 < position.X + npc.width && x * 16 + 16 > position.X; + var tileSolidityCheck1 = t_xy.HasUnactuatedTile && !t_xy.TopSlope && !t_xy1.TopSlope && Main.tileSolid[t_xy.TileType] && !Main.tileSolidTop[t_xy.TileType]; + var oneBelowIsSolidHalf = t_xy1.IsHalfBlock && t_xy1.HasUnactuatedTile; + var canFallThrough = !t_xy1.HasUnactuatedTile || !Main.tileSolid[t_xy1.TileType] || Main.tileSolidTop[t_xy1.TileType] || t_xy1.IsHalfBlock && (!t_xy4.HasUnactuatedTile || !Main.tileSolid[t_xy4.TileType] || Main.tileSolidTop[t_xy4.TileType]); + var twoDownIsNonSolid = !t_xy2.HasUnactuatedTile || !Main.tileSolid[t_xy2.TileType] || Main.tileSolidTop[t_xy2.TileType]; + var threeDownIsNonSolid = !t_xy3.HasUnactuatedTile || !Main.tileSolid[t_xy3.TileType] || Main.tileSolidTop[t_xy3.TileType]; + // Notice it doesn't check for platforms in ther offset position. This is why walking AIs twirl on 1-wide platforms in hellevators. They have to turn around before this check succeeds. + var threeDownOffsetIsNonSolid = !t_xOffY3.HasUnactuatedTile || !Main.tileSolid[t_xOffY3.TileType]; + if (positionCheck && (tileSolidityCheck1 || oneBelowIsSolidHalf) && canFallThrough && twoDownIsNonSolid && threeDownIsNonSolid && threeDownOffsetIsNonSolid) + { + var tilePixelPosition = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) + { + tilePixelPosition += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + tilePixelPosition -= 8f; + } + if (tilePixelPosition < position.Y + npc.height) + { + var percentageTileRisen = position.Y + npc.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) + { + npc.gfxOffY += npc.position.Y + npc.height - tilePixelPosition; + npc.position.Y = tilePixelPosition - npc.height; + if (percentageTileRisen < 9f) + { + npc.stepSpeed = 1f; + } + else + { + npc.stepSpeed = 2f; + } + } + } + } + } + if (npc.velocity.Y == 0f) + { + var npcTileX = (int)((npc.position.X + npc.width / 2 + (npc.width / 2 + 2) * npc.direction + npc.velocity.X * 5f) / 16f); + var npcTileY = (int)((npc.position.Y + npc.height - 15f) / 16f); + var spriteDirection = npc.spriteDirection; + spriteDirection *= -1; + if (npc.velocity.X < 0f && spriteDirection == -1 || npc.velocity.X > 0f && spriteDirection == 1) + { + if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[Main.tile[npcTileX, npcTileY - 2].TileType]) + { + if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[Main.tile[npcTileX, npcTileY - 3].TileType]) + { + npc.velocity.Y = bouncy1; + npc.netUpdate = true; + } + else + { + npc.velocity.Y = bouncy2; + npc.netUpdate = true; + } + } + else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[Main.tile[npcTileX, npcTileY - 1].TileType]) + { + npc.velocity.Y = bouncy3; + npc.netUpdate = true; + } + else if (npc.position.Y + npc.height - npcTileY * 16 > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[Main.tile[npcTileX, npcTileY].TileType]) + { + npc.velocity.Y = bouncy4; + npc.netUpdate = true; + } + else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > 3f) && (!Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + npc.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[Main.tile[npcTileX + npc.direction, npcTileY + 3].TileType])) + { + npc.velocity.Y = bouncy5; + npc.netUpdate = true; + } + } + } + if (spin) + { + npc.rotation += npc.velocity.X * 0.05f; + npc.spriteDirection = -npc.direction; + } + } + #endregion + + #region Swimming AI + // Passiveness: + // 0 = Catfish, Flounder, Frogfish, Viperfish, Moray Eel, Laserfish + // 1 = Blinded Angler + // 2 = Prism-Back, Toxic Minnow + // 3 = Sea Minnow + public static void PassiveSwimmingAI(NPC npc, Mod mod, int passiveness, float detectRange, float xSpeed, float ySpeed, float speedLimitX, float speedLimitY, float rotation, bool spriteFacesLeft = true) + { + if (spriteFacesLeft) + npc.spriteDirection = npc.direction > 0 ? 1 : -1; + else + npc.spriteDirection = npc.direction > 0 ? -1 : 1; + + npc.noGravity = true; + if (npc.direction == 0) + npc.TargetClosest(); + + var target = Main.player[npc.target]; + if (npc.justHit && passiveness != 3) + npc.chaseable = true; + + if (npc.wet) + { + var hasWetTarget = npc.chaseable; + npc.TargetClosest(false); + target = Main.player[npc.target]; + + // Player detection behavior + if (passiveness != 2) + { + if (npc.type == ModContent.NPCType()) + { + if (target.wet && !target.dead) + { + hasWetTarget = true; + npc.chaseable = true; // Once the enemy has detected the player, let minions fuck it up + } + } + + if (npc.type == ModContent.NPCType()) + { + if (!target.dead) + { + hasWetTarget = true; + npc.chaseable = true; // Once the enemy has detected the player, let minions fuck it up + } + } + else if (target.wet && !target.dead && (target.Center - npc.Center).Length() < detectRange && Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) + { + hasWetTarget = true; + npc.chaseable = true; // Once the enemy has detected the player, let minions fuck it up + } + else + { + if (passiveness == 1) + hasWetTarget = false; + } + } + + if ((target.dead || !Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) && hasWetTarget) + hasWetTarget = false; + + // Swim back and forth + if (!hasWetTarget || passiveness == 2) + { + if (passiveness == 0) + { + npc.TargetClosest(false); + target = Main.player[npc.target]; + } + + if (npc.collideX) + { + npc.velocity.X *= -1f; + npc.direction *= -1; + npc.netUpdate = true; + } + + if (npc.collideY) + { + npc.netUpdate = true; + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; + npc.directionY = -1; + npc.ai[0] = -1f; + } + else if (npc.velocity.Y < 0f) + { + npc.velocity.Y = Math.Abs(npc.velocity.Y); + npc.directionY = 1; + npc.ai[0] = 1f; + } + } + } + + if (hasWetTarget && passiveness != 2) + { + npc.TargetClosest(); + target = Main.player[npc.target]; + + // Swim away from the player + if (passiveness == 3) + { + npc.velocity.X = npc.velocity.X - npc.direction * xSpeed; + npc.velocity.Y = npc.velocity.Y - npc.directionY * ySpeed; + } + // Swim toward the player + else + { + npc.velocity.X = npc.velocity.X + npc.direction * (CalamityWorld.death ? 2f * xSpeed : CalamityWorld.revenge ? 1.5f * xSpeed : xSpeed); + npc.velocity.Y = npc.velocity.Y + npc.directionY * (CalamityWorld.death ? 2f * ySpeed : CalamityWorld.revenge ? 1.5f * ySpeed : ySpeed); + } + + var velocityCapX = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitX : CalamityWorld.revenge ? 1.5f * speedLimitX : speedLimitX; + var velocityCapY = CalamityWorld.death && passiveness != 3 ? 2f * speedLimitY : CalamityWorld.revenge ? 1.5f * speedLimitY : speedLimitY; + npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -velocityCapX, velocityCapX); + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -velocityCapY, velocityCapY); + + if (npc.justHit) + npc.localAI[0] = 0f; + + // Laserfish shoot the player + if (npc.type == ModContent.NPCType()) + { + npc.localAI[0] += CalamityWorld.death ? 2f : CalamityWorld.revenge ? 1.5f : 1f; + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 120f) + { + npc.localAI[0] = 0f; + if (Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) + { + var speed = 5f; + var vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height / 2); + var velX = target.Center.X - vector.X + Main.rand.NextFloat(-20f, 20f); + var velY = target.Center.Y - vector.Y + Main.rand.NextFloat(-20f, 20f); + var dist = (float)Math.Sqrt((double)(velX * velX + velY * velY)); + dist = speed / dist; + velX *= dist; + velY *= dist; + var damage = Main.masterMode ? 34 : Main.expertMode ? 40 : 50; + var beam = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (npc.spriteDirection == 1 ? 25f : -25f), npc.Center.Y + (target.position.Y > npc.Center.Y ? 5f : -5f), velX, velY, ProjectileID.EyeBeam, damage, 0f, Main.myPlayer); + Main.projectile[beam].tileCollide = true; + } + } + } + + // Flounder shoot Sulphuric Mist at the player + if (npc.type == ModContent.NPCType()) + { + if ((target.Center - npc.Center).Length() < 350f) + { + npc.localAI[0] += CalamityWorld.death ? 3f : CalamityWorld.revenge ? 2f : 1f; + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 180f) + { + npc.localAI[0] = 0f; + if (Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) + { + var speed = 4f; + var vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height / 2); + var velX = target.Center.X - vector.X + Main.rand.NextFloat(-20f, 20f); + var velY = target.Center.Y - vector.Y + Main.rand.NextFloat(-20f, 20f); + var dist = (float)Math.Sqrt((double)(velX * velX + velY * velY)); + dist = speed / dist; + velX *= dist; + velY *= dist; + var damage = Main.masterMode ? 21 : Main.expertMode ? 25 : 35; + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (npc.spriteDirection == 1 ? 10f : -10f), npc.Center.Y, velX, velY, ModContent.ProjectileType(), damage, 0f, Main.myPlayer); + } + } + } + } + + // Sea Minnows face away from the player + if (npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType()) + npc.direction *= -1; + } + else + { + // No target behavior + npc.velocity.X += npc.direction * 0.1f; + if (npc.velocity.X < -2.5f || npc.velocity.X > 2.5f) + npc.velocity.X *= 0.95f; + + if (npc.ai[0] == -1f) + { + npc.velocity.Y -= 0.01f; + if (npc.velocity.Y < -0.3f) + npc.ai[0] = 1f; + } + else + { + npc.velocity.Y += 0.01f; + if (npc.velocity.Y > 0.3f) + npc.ai[0] = -1f; + } + } + + var npcTileX = (int)(npc.position.X + npc.width / 2) / 16; + var npcTileY = (int)(npc.position.Y + npc.height / 2) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) + { + if (Main.tile[npcTileX, npcTileY + 1].HasTile) + npc.ai[0] = -1f; + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) + npc.ai[0] = -1f; + } + + if (npc.velocity.Y > 0.4f || npc.velocity.Y < -0.4f) + npc.velocity.Y *= 0.95f; + } + else + { + // Out of water behavior + if (npc.velocity.Y == 0f) + { + npc.velocity.X *= 0.94f; + if (npc.velocity.X > -0.2f && npc.velocity.X < 0.2f) + npc.velocity.X = 0f; + } + + npc.velocity.Y += 0.4f; + if (npc.velocity.Y > 12f) + npc.velocity.Y = 12f; + + npc.ai[0] = 1f; + } + + npc.rotation = npc.velocity.Y * npc.direction * rotation; + var rotationLimit = 2f * rotation; + npc.rotation = MathHelper.Clamp(npc.rotation, -rotationLimit, rotationLimit); + } + #endregion + } +} diff --git a/NPCs/NormalNPCs/CladCrab.cs b/NPCs/NormalNPCs/CladCrab.cs index 7696168219..cbcf80f249 100644 --- a/NPCs/NormalNPCs/CladCrab.cs +++ b/NPCs/NormalNPCs/CladCrab.cs @@ -1,10 +1,5 @@ using System; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; @@ -35,7 +30,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 100; NPC.aiStyle = -1; NPC.knockBackResist = 0.4f; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.HitSound = SoundID.NPCHit41 with { Pitch = 0.6f }; NPC.DeathSound = SoundID.NPCDeath36 with { Pitch = -0.4f }; Banner = NPC.type; @@ -43,10 +38,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() @@ -111,7 +102,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (!NPC.justHit) NPC.velocity.X = MathHelper.Lerp(NPC.velocity.X, NPC.direction * movementSpeed, 0.05f); // Don't get stuck on 1 block obstacles - StepUp(); + NPC.StepUpBlocks(); } // Stand still else if (NPC.ai[0] == 1) @@ -147,7 +138,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Move if (!NPC.justHit) NPC.velocity.X = MathHelper.Lerp(NPC.velocity.X, NPC.direction * movementSpeed, 0.05f); - StepUp(); + NPC.StepUpBlocks(); } // Phase timer @@ -161,59 +152,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.spriteDirection = -NPC.direction; } - public static bool IsPassableTile(int x, int y) - { - return (!Main.tile[x, y].HasUnactuatedTile || - !Main.tileSolid[(int)Main.tile[x, y].TileType] || Main.tileSolidTop[(int)Main.tile[x, y].TileType]); - } - - public void StepUp() - { - Vector2 position = NPC.position; - position.X += NPC.velocity.X; - int x = (int)((position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1)) * NPC.direction) / 16f); - int y = (int)((position.Y + (float)NPC.height - 1f) / 16f); - - if ((float)(x * 16) >= position.X + (float)NPC.width || (float)(x * 16 + 16) <= position.X) - return; - - bool nextTileValid = Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]; - bool aboveTileHalfBlock = Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile; - bool aboveTileHasRoom = Main.tile[x, y - 1].IsHalfBlock && IsPassableTile(x, y - 4); - bool aboveTileEmpty = !Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || aboveTileHasRoom; - bool tile3AbovePassable = !Main.tile[x - NPC.direction, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - NPC.direction, y - 3].TileType]; - - if ((nextTileValid || aboveTileHalfBlock) && aboveTileEmpty && IsPassableTile(x, y - 2) && IsPassableTile(x, y - 3) && tile3AbovePassable) - { - float npcBottom = (float)(y * 16); - if (Main.tile[x, y].IsHalfBlock) - { - npcBottom += 8f; - } - if (Main.tile[x, y - 1].IsHalfBlock) - { - npcBottom -= 8f; - } - if (npcBottom < position.Y + (float)NPC.height) - { - float percentageTileRisen = position.Y + (float)NPC.height - npcBottom; - if (percentageTileRisen <= 16.1f) - { - NPC.gfxOffY += NPC.position.Y + (float)NPC.height - npcBottom; - NPC.position.Y = npcBottom - (float)NPC.height; - if (percentageTileRisen < 9f) - { - NPC.stepSpeed = 1f; - } - else - { - NPC.stepSpeed = 2f; - } - } - } - } - } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] diff --git a/NPCs/NormalNPCs/CloudElemental.cs b/NPCs/NormalNPCs/CloudElemental.cs index 11bbb3861e..59bdafb7f8 100644 --- a/NPCs/NormalNPCs/CloudElemental.cs +++ b/NPCs/NormalNPCs/CloudElemental.cs @@ -6,7 +6,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -75,10 +74,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 80; NPC.height = 140; NPC.defense = 18; - NPC.DR_NERD(0.05f); NPC.lifeMax = 6000; NPC.knockBackResist = 0.05f; - NPC.value = Item.buyPrice(0, 1, 50, 0); + NPC.value = Item.buyPrice(gold: 1, silver: 50); NPC.HitSound = SoundID.NPCHit23; NPC.DeathSound = SoundID.NPCDeath39; NPC.noGravity = true; @@ -91,10 +89,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToElectricity = false; NPC.Calamity().VulnerableToWater = false; NPC.Calamity().VulnerableToHeat = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/Cnidrion.cs b/NPCs/NormalNPCs/Cnidrion.cs index a1455124e3..836d928cba 100644 --- a/NPCs/NormalNPCs/Cnidrion.cs +++ b/NPCs/NormalNPCs/Cnidrion.cs @@ -35,11 +35,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 6; NPC.noGravity = true; NPC.noTileCollide = true; - NPC.DR_NERD(0.05f); NPC.lifeMax = 280; NPC.knockBackResist = 0.05f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 25, 0); + NPC.value = Item.buyPrice(silver: 25); NPC.HitSound = SoundID.NPCHit12; NPC.DeathSound = SoundID.NPCDeath18; NPC.rarity = 2; @@ -48,10 +47,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -98,14 +93,13 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { Player player = Main.player[NPC.target]; - bool expertMode = Main.expertMode; - bool masterMode = Main.masterMode; + NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; float movementSpeed = 1f; NPC.TargetClosest(true); bool stopMoving = false; int offsetX = 80; - int projectileDamage = masterMode ? 8 : expertMode ? 9 : 12; + int projectileDamage = Main.masterMode ? 8 : Main.expertMode ? 9 : 12; if (NPC.life < NPC.lifeMax * 0.33 && CalamityWorld.death) { movementSpeed = 2f; diff --git a/NPCs/NormalNPCs/CrawlerAmber.cs b/NPCs/NormalNPCs/CrawlerAmber.cs index f954995ab2..227d0ecc74 100644 --- a/NPCs/NormalNPCs/CrawlerAmber.cs +++ b/NPCs/NormalNPCs/CrawlerAmber.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -28,9 +27,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 44; NPC.height = 34; NPC.defense = 10; - NPC.lifeMax = 115; + NPC.lifeMax = 150; NPC.knockBackResist = 0.3f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrawlerAmethyst.cs b/NPCs/NormalNPCs/CrawlerAmethyst.cs index a4e87c0b90..6b16f0d70a 100644 --- a/NPCs/NormalNPCs/CrawlerAmethyst.cs +++ b/NPCs/NormalNPCs/CrawlerAmethyst.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -30,7 +29,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 75; NPC.knockBackResist = 0.75f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 0, 60); + NPC.value = Item.buyPrice(copper: 60); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrawlerCrystal.cs b/NPCs/NormalNPCs/CrawlerCrystal.cs index e1a0792b18..b8c0273439 100644 --- a/NPCs/NormalNPCs/CrawlerCrystal.cs +++ b/NPCs/NormalNPCs/CrawlerCrystal.cs @@ -2,8 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -27,11 +25,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 35; NPC.width = 44; NPC.height = 34; - NPC.defense = 12; - NPC.lifeMax = 375; + NPC.defense = 22; + NPC.lifeMax = 400; NPC.knockBackResist = 0.15f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -39,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrawlerDiamond.cs b/NPCs/NormalNPCs/CrawlerDiamond.cs index 09e32974f5..0ebb7f1a93 100644 --- a/NPCs/NormalNPCs/CrawlerDiamond.cs +++ b/NPCs/NormalNPCs/CrawlerDiamond.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -26,11 +25,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 24; NPC.width = 44; NPC.height = 34; - NPC.defense = 8; - NPC.lifeMax = 190; + NPC.defense = 10; + NPC.lifeMax = 180; NPC.knockBackResist = 0.35f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrawlerEmerald.cs b/NPCs/NormalNPCs/CrawlerEmerald.cs index 83098672ad..9b30b0aacc 100644 --- a/NPCs/NormalNPCs/CrawlerEmerald.cs +++ b/NPCs/NormalNPCs/CrawlerEmerald.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -30,7 +29,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 135; NPC.knockBackResist = 0.55f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 1, 20); + NPC.value = Item.buyPrice(silver: 1, copper: 20); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrawlerRuby.cs b/NPCs/NormalNPCs/CrawlerRuby.cs index 85e11808ee..1d25a513f7 100644 --- a/NPCs/NormalNPCs/CrawlerRuby.cs +++ b/NPCs/NormalNPCs/CrawlerRuby.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -27,10 +26,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 44; NPC.height = 34; NPC.defense = 8; - NPC.lifeMax = 170; + NPC.lifeMax = 150; NPC.knockBackResist = 0.45f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 1, 60); + NPC.value = Item.buyPrice(silver: 1, copper: 60); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrawlerSapphire.cs b/NPCs/NormalNPCs/CrawlerSapphire.cs index 82e676db37..e307c06005 100644 --- a/NPCs/NormalNPCs/CrawlerSapphire.cs +++ b/NPCs/NormalNPCs/CrawlerSapphire.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -27,10 +26,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 44; NPC.height = 34; NPC.defense = 6; - NPC.lifeMax = 115; + NPC.lifeMax = 120; NPC.knockBackResist = 0.65f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrawlerTopaz.cs b/NPCs/NormalNPCs/CrawlerTopaz.cs index 3ce4c15784..029c66b7bd 100644 --- a/NPCs/NormalNPCs/CrawlerTopaz.cs +++ b/NPCs/NormalNPCs/CrawlerTopaz.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -27,10 +26,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 44; NPC.height = 34; NPC.defense = 4; - NPC.lifeMax = 60; + NPC.lifeMax = 90; NPC.knockBackResist = 0.85f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 0, 60); + NPC.value = Item.buyPrice(copper: 60); NPC.HitSound = SoundID.NPCHit33; NPC.DeathSound = SoundID.NPCDeath36; Banner = NPC.type; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/CrimulanBlightSlime.cs b/NPCs/NormalNPCs/CrimulanBlightSlime.cs index 18f99bbfbf..71a4064edc 100644 --- a/NPCs/NormalNPCs/CrimulanBlightSlime.cs +++ b/NPCs/NormalNPCs/CrimulanBlightSlime.cs @@ -2,9 +2,11 @@ using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; + namespace CalamityMod.NPCs.NormalNPCs { public class CrimulanBlightSlime : ModNPC @@ -22,10 +24,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 60; NPC.height = 42; NPC.defense = 8; - NPC.lifeMax = 165; + NPC.lifeMax = 130; NPC.knockBackResist = 0.3f; AnimationType = NPCID.RainbowSlime; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.alpha = 105; NPC.lavaImmune = false; NPC.noGravity = false; @@ -36,10 +38,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -89,6 +87,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Gel, 1, 10, 14); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Blindfold, 100, 50)); npcLoot.Add(ModContent.ItemType(), 1, 15, 21); } } diff --git a/NPCs/NormalNPCs/CryoSlime.cs b/NPCs/NormalNPCs/CryoSlime.cs index 677e543ea6..30e71d6f11 100644 --- a/NPCs/NormalNPCs/CryoSlime.cs +++ b/NPCs/NormalNPCs/CryoSlime.cs @@ -22,11 +22,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 30; NPC.width = 40; NPC.height = 30; - NPC.defense = 8; - NPC.lifeMax = 180; + NPC.defense = 24; + NPC.lifeMax = 280; NPC.knockBackResist = 0.6f; AnimationType = NPCID.CorruptSlime; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.alpha = 50; NPC.lavaImmune = false; NPC.noGravity = false; @@ -39,10 +39,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -68,8 +64,8 @@ namespace CalamityMod.NPCs.NormalNPCs { if (hurtInfo.Damage > 0) { - target.AddBuff(BuffID.Frostburn, 120, true); - target.AddBuff(BuffID.Chilled, 90, true); + target.AddBuff(BuffID.Frostburn, 180); + target.AddBuff(BuffID.Chilled, 90); } } diff --git a/NPCs/NormalNPCs/Cryon.cs b/NPCs/NormalNPCs/Cryon.cs index 1467b1f3b6..7dad72a7b4 100644 --- a/NPCs/NormalNPCs/Cryon.cs +++ b/NPCs/NormalNPCs/Cryon.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using CalamityMod.World; using Terraria; using Terraria.GameContent.Bestiary; @@ -23,11 +22,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 42; NPC.width = 50; NPC.height = 64; - NPC.defense = 10; - NPC.DR_NERD(0.1f); - NPC.lifeMax = 375; + NPC.defense = 25; + NPC.lifeMax = 300; NPC.knockBackResist = 0.4f; - NPC.value = Item.buyPrice(0, 0, 3, 0); + NPC.value = Item.buyPrice(silver: 3); NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath7; Banner = NPC.type; @@ -36,10 +34,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -101,8 +95,8 @@ namespace CalamityMod.NPCs.NormalNPCs { if (hurtInfo.Damage > 0) { - target.AddBuff(BuffID.Frostburn, 120, true); - target.AddBuff(BuffID.Chilled, 90, true); + target.AddBuff(BuffID.Frostburn, 180); + target.AddBuff(BuffID.Chilled, 90); } } diff --git a/NPCs/NormalNPCs/EarthElemental.cs b/NPCs/NormalNPCs/EarthElemental.cs new file mode 100644 index 0000000000..d5c0c8b6f1 --- /dev/null +++ b/NPCs/NormalNPCs/EarthElemental.cs @@ -0,0 +1,312 @@ +using System; +using System.IO; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Enemy; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.NormalNPCs +{ + [LegacyName("Horse")] + public class EarthElemental : ModNPC + { + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 6; + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + { + Scale = 0.4f, + PortraitScale = 0.6f, + PortraitPositionYOverride = -20f + }; + value.Position.X += 28f; + value.Position.Y -= 56f; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + } + + public override void SetDefaults() + { + NPC.Calamity().canBreakPlayerDefense = true; + NPC.npcSlots = 3f; + NPC.damage = 50; + NPC.width = 230; + NPC.height = 230; + NPC.defense = 20; + NPC.lifeMax = 3800; + NPC.aiStyle = -1; + AIType = -1; + NPC.knockBackResist = 0.05f; + NPC.value = Item.buyPrice(gold: 1, silver: 50); + NPC.dontTakeDamage = true; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.HitSound = SoundID.NPCHit4; + NPC.rarity = 2; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToWater = true; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Caverns, + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.EarthElemental") + }); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.dontTakeDamage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.dontTakeDamage = reader.ReadBoolean(); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.PlayerSafe || !Main.hardMode || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea || !spawnInfo.Player.ZoneRockLayerHeight) + return 0f; + + // Keep this as a separate if check, because it's a loop and we don't want to be checking it constantly. + if (NPC.AnyNPCs(NPC.type)) + return 0f; + + return SpawnCondition.Cavern.Chance * 0.005f; + } + + public override void FindFrame(int frameHeight) + { + if (NPC.ai[0] == 0f && !NPC.IsABestiaryIconDummy) + return; + + NPC.frameCounter++; + if (NPC.frameCounter >= 8) + { + NPC.frame.Y = (NPC.frame.Y + frameHeight) % (Main.npcFrameCount[Type] * frameHeight); + NPC.frameCounter = 0; + } + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + var weapons = new int[] + { + ModContent.ItemType(), + ModContent.ItemType(), + }; + npcLoot.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, hit.HitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + SoundEngine.PlaySound(SoundID.Item14, NPC.Center); + NPC.position.X = NPC.position.X + (NPC.width / 2); + NPC.position.Y = NPC.position.Y + (NPC.height / 2); + NPC.width = 160; + NPC.height = 160; + NPC.position.X = NPC.position.X - (NPC.width / 2); + NPC.position.Y = NPC.position.Y - (NPC.height / 2); + for (int i = 0; i < 40; i++) + { + int earthDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, 0f, 0f, 100, default, 2f); + Main.dust[earthDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[earthDust].scale = 0.5f; + Main.dust[earthDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int j = 0; j < 70; j++) + { + int earthDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 3f); + Main.dust[earthDust2].noGravity = true; + Main.dust[earthDust2].velocity *= 5f; + earthDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); + Main.dust[earthDust2].velocity *= 2f; + } + + if (!Main.dedServ) + { + Vector2 goreSource = NPC.Center; + int goreAmt = 3; + Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); + for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) + { + float velocityMult = 0.33f; + if (goreIndex < (goreAmt / 3)) + { + velocityMult = 0.66f; + } + if (goreIndex >= (2 * goreAmt / 3)) + { + velocityMult = 1f; + } + Mod mod = ModContent.GetInstance(); + int type = Main.rand.Next(61, 64); + int smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); + Gore gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y += 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y += 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y -= 1f; + type = Main.rand.Next(61, 64); + smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); + gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X -= 1f; + gore.velocity.Y -= 1f; + } + } + } + } + + public override bool PreAI() + { + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + if (Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) < 480f) + { + if (NPC.ai[0] == 0f) + { + if (Main.zenithWorld) + { + SoundEngine.PlaySound(SoundID.ScaryScream, Main.player[NPC.target].Center); + } + NPC.ai[0] = 1f; + NPC.dontTakeDamage = false; + } + } + else + NPC.TargetClosest(); + + if (NPC.ai[0] == 0f) + return false; + + if (Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + if (NPC.velocity.Y < -2f) + NPC.velocity.Y = -2f; + NPC.velocity.Y += 0.1f; + if (NPC.velocity.Y > 12f) + NPC.velocity.Y = 12f; + + if (NPC.timeLeft > 60) + NPC.timeLeft = 60; + } + + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 300f) + { + NPC.localAI[0] = 0f; + SoundEngine.PlaySound(SoundID.NPCHit43, NPC.Center); + NPC.TargetClosest(); + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + float rockSpeed = 4f; + int damage = Main.masterMode ? 18 : Main.expertMode ? 22 : 30; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 projPosition = NPC.Center; + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; + float absoluteTargetX = Math.Abs(targetXDist) * 0.1f; + float targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y - absoluteTargetX; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = rockSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + int rockType = ModContent.ProjectileType(); + projPosition.X += targetXDist; + projPosition.Y += targetYDist; + for (int k = 0; k < 4; k++) + { + rockType = Main.rand.NextBool(4) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; + targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y; + targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = rockSpeed / targetDistance; + targetXDist += Main.rand.Next(-40, 41); + targetYDist += Main.rand.Next(-40, 41); + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), projPosition.X, projPosition.Y, targetXDist, targetYDist, rockType, damage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + } + + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; + + Vector2 direction = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); + float chargeGateValue = Main.expertMode ? 300f : 600f; + NPC.ai[1] += 1f; + if (NPC.ai[1] >= chargeGateValue) + { + // Set damage + NPC.damage = NPC.defDamage; + + float chargeVelocity = Main.expertMode ? 9f : 6f; + direction *= chargeVelocity; + NPC.velocity = direction; + NPC.ai[1] = -30f; + } + + if (Math.Sqrt((NPC.velocity.X * NPC.velocity.X) + (NPC.velocity.Y * NPC.velocity.Y)) > 1D && NPC.ai[1] >= 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.velocity *= 0.97f; + } + + if (Math.Sqrt((NPC.velocity.X * NPC.velocity.X) + (NPC.velocity.Y * NPC.velocity.Y)) <= 1.15) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.velocity = direction; + } + + return false; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage > 0) + target.AddBuff(ModContent.BuffType(), 300); + } + } +} diff --git a/NPCs/NormalNPCs/Horse.png b/NPCs/NormalNPCs/EarthElemental.png similarity index 100% rename from NPCs/NormalNPCs/Horse.png rename to NPCs/NormalNPCs/EarthElemental.png diff --git a/NPCs/NormalNPCs/EbonianBlightSlime.cs b/NPCs/NormalNPCs/EbonianBlightSlime.cs index 0511fb85cf..52d7ad737c 100644 --- a/NPCs/NormalNPCs/EbonianBlightSlime.cs +++ b/NPCs/NormalNPCs/EbonianBlightSlime.cs @@ -2,9 +2,11 @@ using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; + namespace CalamityMod.NPCs.NormalNPCs { public class EbonianBlightSlime : ModNPC @@ -22,10 +24,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 60; NPC.height = 42; NPC.defense = 8; - NPC.lifeMax = 165; + NPC.lifeMax = 130; NPC.knockBackResist = 0.3f; AnimationType = NPCID.RainbowSlime; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.alpha = 105; NPC.lavaImmune = false; NPC.noGravity = false; @@ -36,10 +38,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -89,6 +87,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Gel, 1, 10, 14); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.Vitamins, 100, 50)); npcLoot.Add(ModContent.ItemType(), 1, 15, 21); } } diff --git a/NPCs/NormalNPCs/Eidolist.cs b/NPCs/NormalNPCs/Eidolist.cs index fe9bf61205..bbf2719746 100644 --- a/NPCs/NormalNPCs/Eidolist.cs +++ b/NPCs/NormalNPCs/Eidolist.cs @@ -43,7 +43,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 80; NPC.lifeMax = 5000; NPC.knockBackResist = 0.5f; - NPC.value = Item.buyPrice(0, 0, 30, 0); + NPC.value = Item.buyPrice(silver: 30); NPC.Opacity = 0f; NPC.noGravity = true; NPC.noTileCollide = false; @@ -57,10 +57,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -316,7 +312,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - // waffles% stipulation: eidolists are accessible by beating cal clone, even without beating WoF + // Waffles% stipulation: Eidolists are accessible by beating Cal Clone, even without beating WoF bool hardmodeOrCalClone = Main.hardMode || DownedBossSystem.downedCalamitasClone; if (!hardmodeOrCalClone || !spawnInfo.Player.InAbyss()) return 0f; @@ -324,7 +320,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Keep this as a separate if check, because it's a loop and we don't want to be checking it constantly. if (NPC.AnyNPCs(NPC.type)) return 0f; - + if (spawnInfo.Player.Calamity().ZoneAbyssLayer3 && spawnInfo.Water) return Main.remixWorld ? 2.25f : 0.25f; diff --git a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs index 0877b823af..24943fe7b7 100644 --- a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs +++ b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs @@ -27,9 +27,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 36; NPC.height = 32; NPC.defense = Main.hardMode ? 10 : 2; - NPC.lifeMax = Main.hardMode ? 190 : 65; + NPC.lifeMax = Main.hardMode ? 150 : 50; NPC.knockBackResist = Main.hardMode ? 0.2f : 0.5f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Banner = NPC.type; @@ -38,10 +38,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -218,7 +214,7 @@ namespace CalamityMod.NPCs.NormalNPCs { int doorCheckX = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); int doorCheckY = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); - if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10 || Main.tile[doorCheckX, doorCheckY - 1].TileType == 388)) & unusedFlag) + if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.ClosedDoor || Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.TallGateClosed)) & unusedFlag) { NPC.ai[2] += 1f; NPC.ai[3] = 0f; @@ -226,7 +222,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.velocity.X = 0.5f * (float)-(float)NPC.direction; int doorOpenInc = 5; - if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.TallGateClosed) { doorOpenInc = 2; } @@ -241,7 +237,7 @@ namespace CalamityMod.NPCs.NormalNPCs WorldGen.KillTile(doorCheckX, doorCheckY - 1, true, false, false); if ((Main.netMode != NetmodeID.MultiplayerClient || !letMeIn) && letMeIn && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.ClosedDoor) { bool canOpenDoor = WorldGen.OpenDoor(doorCheckX, doorCheckY - 1, NPC.direction); if (!canOpenDoor) @@ -254,7 +250,7 @@ namespace CalamityMod.NPCs.NormalNPCs NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)doorCheckX, (float)(doorCheckY - 1), (float)NPC.direction, 0, 0, 0); } } - if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.TallGateClosed) { bool canOpenTallGate = WorldGen.ShiftTallGate(doorCheckX, doorCheckY - 1, false); if (!canOpenTallGate) @@ -401,15 +397,17 @@ namespace CalamityMod.NPCs.NormalNPCs bool instakill = false; List metarexNames = new List { "LordMetarex", "Metarex" }; foreach (string s in metarexNames) + { if (s.ToLower() == target.name.ToLower()) { instakill = true; break; } + } if (instakill) { - target.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Goldfish").Format(target.name)), 1000.0, 0, false); + target.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Goldfish").ToNetworkText(target.name)), 1000.0, 0, false); modifiers.FinalDamage *= target.statLifeMax2 * Main.rand.NextFloat(2.0f, 3.5f); } } diff --git a/NPCs/NormalNPCs/Foveanator.cs b/NPCs/NormalNPCs/Foveanator.cs deleted file mode 100644 index 30d5b09bca..0000000000 --- a/NPCs/NormalNPCs/Foveanator.cs +++ /dev/null @@ -1,977 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.DataStructures; -using CalamityMod.Events; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.Projectiles.Boss; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.Chat; -using Terraria.GameContent; -using Terraria.GameContent.Achievements; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - public class Foveanator : ModNPC - { - public static int phase1IconIndex; - public static int phase2IconIndex; - - public static Asset GlowTexture; - - public override void Load() - { - string phase1IconPath = "CalamityMod/NPCs/NormalNPCs/Foveanator_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/NormalNPCs/Foveanator_Phase2_Head_Boss"; - - phase1IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); - phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); - } - - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); - - if (!Main.dedServ) - GlowTexture = ModContent.Request("CalamityMod/NPCs/NormalNPCs/FoveanatorGlow", AssetRequestMode.AsyncLoad); - } - - public override void SetDefaults() - { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.aiStyle = -1; - AIType = -1; - NPC.GetNPCDamage(); - NPC.DR_NERD(0.2f); - - NPC.width = 100; - NPC.height = 100; - if (Main.tenthAnniversaryWorld) - NPC.scale *= 0.5f; - if (Main.getGoodWorld) - NPC.scale *= 0.8f; - - NPC.defense = 10; - NPC.lifeMax = 24000; - NPC.knockBackResist = 0f; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.boss = true; - NPC.SpawnWithHigherTime(30); - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToHeat = true; - NPC.Calamity().VulnerableToSickness = true; - AnimationType = NPCID.Retinazer; - Music = MusicID.Boss2; - - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(NPC.localAI[0]); - writer.Write(NPC.localAI[1]); - writer.Write(NPC.localAI[2]); - writer.Write(NPC.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(NPC.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - NPC.localAI[0] = reader.ReadSingle(); - NPC.localAI[1] = reader.ReadSingle(); - NPC.localAI[2] = reader.ReadSingle(); - NPC.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - NPC.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void BossHeadSlot(ref int index) => index = NPC.ai[0] >= 3f ? phase2IconIndex : phase1IconIndex; - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - - 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) - CalamityUtils.CalamityTargeting(NPC, default); - - float enrageScale = bossRush ? 0.5f : 0.3f; - if (Main.IsItDay() || bossRush) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - - // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; - - // Check for Retinazer - bool retAlive = false; - if (CalamityGlobalNPC.laserEye != -1) - retAlive = Main.npc[CalamityGlobalNPC.laserEye].active; - - // Check for Spazmatism or Retinazer - bool spazAlive = false; - if (CalamityGlobalNPC.fireEye != -1) - spazAlive = Main.npc[CalamityGlobalNPC.fireEye].active; - - // Explode if ret and spaz are dead - if (!retAlive && !spazAlive) - { - NPC.life = 0; - NPC.HitEffect(); - NPC.active = false; - NPC.netUpdate = true; - return; - } - - Vector2 lookDirection = NPC.Center - Main.player[NPC.target].Center; - int direction = (NPC.Center.X < Main.player[NPC.target].position.X + Main.player[NPC.target].width) ? -1 : 1; - - float hoverRotation = lookDirection.ToRotation() + MathHelper.PiOver2; - if (hoverRotation < 0f) - hoverRotation += MathHelper.TwoPi; - else if (hoverRotation > MathHelper.TwoPi) - hoverRotation -= MathHelper.TwoPi; - - // Rotate faster during energy bomb and laser barrage - float rotationRate = NPC.ai[1] == 3f ? 0.25f : 0.15f; - NPC.rotation = NPC.rotation.AngleTowards(hoverRotation, rotationRate); - - if (Main.rand.NextBool(5)) - { - int foveaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f), NPC.width, (int)(NPC.height * 0.5f), DustID.Blood, NPC.velocity.X, 2f, 0, default, 1f); - Dust dust = Main.dust[foveaDust]; - dust.velocity.X *= 0.5f; - dust.velocity.Y *= 0.1f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[NPC.target].dead && NPC.timeLeft < 10) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (i != NPC.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism || Main.npc[i].type == NPC.type) && Main.npc[i].timeLeft - 1 > NPC.timeLeft) - NPC.timeLeft = Main.npc[i].timeLeft - 1; - } - } - - // Phase HP ratios - float phase2LifeRatio = 0.85f; - float finalPhaseLifeRatio = 0.4f; - - // Movement variables - float phase1MaxSpeedIncrease = 2f; - float phase1MaxAccelerationIncrease = 0.025f; - float phase1MaxChargeSpeedIncrease = 1f; - - // Phase duration variables - float phase1MaxLaserPhaseDurationDecrease = 120f; - - // Go to phase 2 early if Spaz and Ret health total goes below 50% - // Go to final phase early if Spaz and Ret health total goes below 20% - float retAndSpazHPRatio = 0f; - if (CalamityGlobalNPC.fireEye != -1) - { - if (Main.npc[CalamityGlobalNPC.fireEye].active) - retAndSpazHPRatio += Main.npc[CalamityGlobalNPC.fireEye].life / (float)Main.npc[CalamityGlobalNPC.fireEye].lifeMax; - } - if (CalamityGlobalNPC.laserEye != -1) - { - if (Main.npc[CalamityGlobalNPC.laserEye].active) - retAndSpazHPRatio += Main.npc[CalamityGlobalNPC.laserEye].life / (float)Main.npc[CalamityGlobalNPC.laserEye].lifeMax; - } - - // Phase checks - bool phase2 = lifeRatio < phase2LifeRatio || retAndSpazHPRatio < 0.5f; - bool finalPhase = lifeRatio < finalPhaseLifeRatio || retAndSpazHPRatio < 0.2f; - - Vector2 mechQueenSpacing = Vector2.Zero; - if (NPC.IsMechQueenUp) - { - NPC NPC = Main.npc[NPC.mechQueen]; - Vector2 mechQueenCenter = NPC.GetMechQueenCenter(); - Vector2 eyePosition = new Vector2(0f, -300f); - eyePosition *= 0.75f; - float mechdusaRotation = NPC.velocity.X * 0.025f; - mechQueenSpacing = mechQueenCenter + eyePosition; - mechQueenSpacing = mechQueenSpacing.RotatedBy(mechdusaRotation, mechQueenCenter); - } - - NPC.reflectsProjectiles = false; - - // Despawn - if (Main.player[NPC.target].dead) - { - NPC.velocity.Y -= 0.04f; - if (NPC.timeLeft > 10) - { - NPC.timeLeft = 10; - return; - } - } - - else if (NPC.ai[0] == 0f) - { - if (NPC.ai[1] == 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - float maxVelocity = 8.5f; - float acceleration = 0.12f; - maxVelocity += 4.5f * enrageScale; - acceleration += 0.06f * enrageScale; - - if (death) - { - maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - acceleration += phase1MaxAccelerationIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - } - - if (Main.getGoodWorld) - { - maxVelocity *= 1.15f; - acceleration *= 1.15f; - } - - // Foveanator stays further away from the player than Retinazer (Retinazer distance is 300, Foveanator distance is 450) - float distanceFromTarget = 450f; - Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * distanceFromTarget * direction - Vector2.UnitY * distanceFromTarget; - float distanceFromDestination = (destination - NPC.Center).Length(); - Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); - - if (NPC.IsMechQueenUp) - { - maxVelocity = 14f; - - destination = mechQueenSpacing; - distanceFromDestination = (destination - NPC.Center).Length(); - idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitY); - - if (distanceFromDestination > maxVelocity) - idealVelocity *= maxVelocity / distanceFromDestination; - - float inertia = 60f; - NPC.velocity = (NPC.velocity * (inertia - 1f) + idealVelocity) / inertia; - } - else - NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - - // Foveanator stays in this phase longer than Retinazer (Foveanator time is 450, Retinazer time is 300) - // Foveanator has longer cooldown between firing projectiles than Retinazer (Foveanator cooldown is 60, Retinazer cooldown is 30) - float phaseGateValue = 450f - (death ? phase1MaxLaserPhaseDurationDecrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - float laserGateValue = 60f; - if (NPC.IsMechQueenUp) - { - phaseGateValue = 1350f; - laserGateValue = ((!NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody]) ? 120f : 180f); - } - - NPC.ai[2] += 1f; - if (NPC.ai[2] >= phaseGateValue) - { - NPC.ai[1] = 1f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - - CalamityUtils.CalamityTargeting(NPC, default); - - NPC.netUpdate = true; - } - else if (distanceFromDestination < (death ? 960f : 800f)) - { - if (!Main.player[NPC.target].dead) - { - NPC.ai[3] += 1f; - if (Main.getGoodWorld) - NPC.ai[3] += 0.5f; - } - - if (NPC.ai[3] >= laserGateValue) - { - NPC.ai[3] = 0f; - - SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float laserSpeed = 6f + 1.5f * enrageScale; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 laserVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 60f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - else if (NPC.ai[1] == 1f) - { - // Set damage - NPC.damage = NPC.defDamage; - - NPC.rotation = hoverRotation; - - float chargeSpeed = 4f; - chargeSpeed += 1f * enrageScale; - if (death) - chargeSpeed += phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - if (Main.getGoodWorld) - chargeSpeed += 1f; - - NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * chargeSpeed; - - NPC.ai[1] = 2f; - } - else if (NPC.ai[1] == 2f) - { - // Set damage - NPC.damage = NPC.defDamage; - - NPC.ai[2] += 1f; - float decelerateGateValue = 72f + (death ? 12f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - if (NPC.ai[2] >= decelerateGateValue) - { - // Avoid cheap bullshit - NPC.damage = 0; - - float decelerationMultiplier = 0.8f - (death ? 0.2f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - NPC.velocity *= decelerationMultiplier; - - if (Math.Abs(NPC.velocity.X) < 0.1) - NPC.velocity.X = 0f; - if (Math.Abs(NPC.velocity.Y) < 0.1) - NPC.velocity.Y = 0f; - } - else - { - // Accelerative charge - float maxVelocity = 24f; - maxVelocity += 6f * enrageScale; - if (death) - maxVelocity += (phase1MaxChargeSpeedIncrease * 6f) * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - if (Main.getGoodWorld) - maxVelocity += 6f; - - if (NPC.velocity.Length() < maxVelocity) - { - NPC.velocity *= 1.04f; - if (NPC.velocity.Length() > maxVelocity) - { - NPC.velocity.Normalize(); - NPC.velocity *= maxVelocity; - } - } - - NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; - } - - float delayBeforeChargingAgain = 96f - (death ? 6f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - if (NPC.ai[2] >= delayBeforeChargingAgain) - { - NPC.ai[3] += 1f; - NPC.ai[2] = 0f; - - NPC.rotation = hoverRotation; - - float totalCharges = death ? 3f : 2f; - if (NPC.ai[3] >= totalCharges) - { - NPC.ai[1] = 0f; - NPC.ai[3] = 0f; - - CalamityUtils.CalamityTargeting(NPC, default); - } - else - NPC.ai[1] = 1f; - } - } - - // Enter phase 2 - if (phase2) - { - NPC.ai[0] = 1f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - - CalamityUtils.CalamityTargeting(NPC, default); - - NPC.netUpdate = true; - } - } - - else if (NPC.ai[0] == 1f || NPC.ai[0] == 2f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - if (NPC.IsMechQueenUp) - NPC.reflectsProjectiles = true; - - if (NPC.ai[0] == 1f) - { - NPC.ai[2] += 0.005f; - if (NPC.ai[2] > 0.5f) - NPC.ai[2] = 0.5f; - } - else - { - NPC.ai[2] -= 0.005f; - if (NPC.ai[2] < 0f) - NPC.ai[2] = 0f; - } - - NPC.rotation += NPC.ai[2]; - - NPC.ai[1] += 1f; - if (NPC.ai[2] >= 0.2f) - { - if (NPC.ai[1] % 10f == 0f) - { - SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - bool shootLaser = NPC.ai[1] % 20f == 0f; - - int type = shootLaser ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - float projectileSpeed = shootLaser ? (6f + 1.5f * enrageScale) : 16f; - float ai0 = shootLaser ? 0f : (death ? 1f : 0f); - Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - int numProj = shootLaser ? 4 : 2; - int spread = shootLaser ? 15 : 30; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 60f, perturbedSpeed, type, damage, 0f, Main.myPlayer, ai0); - } - } - } - } - - if (NPC.ai[1] == 100f) - { - NPC.ai[0] += 1f; - NPC.ai[1] = 0f; - if (NPC.ai[0] == 3f) - { - NPC.ai[2] = 0f; - } - else - { - SoundEngine.PlaySound(SoundID.NPCHit1, NPC.Center); - - if (!Main.dedServ) - { - for (int i = 0; i < 2; i++) - { - Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), Mod.Find("Foveanator1").Type, NPC.scale); - Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, NPC.scale); - Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, NPC.scale); - } - } - - for (int j = 0; j < 20; j++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - - SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); - } - } - - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - - NPC.velocity *= 0.98f; - if (Math.Abs(NPC.velocity.X) < 0.1) - NPC.velocity.X = 0f; - if (Math.Abs(NPC.velocity.Y) < 0.1) - NPC.velocity.Y = 0f; - } - else - { - // If in phase 2 but Spaz or Ret aren't - bool spazOrRetInPhase1 = false; - if (CalamityGlobalNPC.fireEye != -1) - { - if (Main.npc[CalamityGlobalNPC.fireEye].active) - spazOrRetInPhase1 = Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 0f; - } - if (CalamityGlobalNPC.laserEye != -1) - { - if (Main.npc[CalamityGlobalNPC.laserEye].active) - spazOrRetInPhase1 = Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 0f; - } - - NPC.chaseable = !spazOrRetInPhase1; - - int setDamage = (int)Math.Round(NPC.defDamage * 1.5); - NPC.defense = NPC.defDefense + 14; - calamityGlobalNPC.DR = spazOrRetInPhase1 ? 0.9999f : 0.2f; - calamityGlobalNPC.unbreakableDR = spazOrRetInPhase1; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = spazOrRetInPhase1; - - NPC.HitSound = SoundID.NPCHit4; - - if (NPC.ai[1] == 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - float maxVelocity = 4f + (death ? 1.2f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float acceleration = 0.06f + (death ? 0.02f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - maxVelocity += 2f * enrageScale; - acceleration += 0.04f * enrageScale; - - float distanceFromTarget = 360f; - Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * distanceFromTarget * direction; - float distanceFromDestination = (destination - NPC.Center).Length(); - Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); - - if (!NPC.IsMechQueenUp) - { - // Boost speed if too far from target - if (distanceFromDestination > distanceFromTarget) - maxVelocity += MathHelper.Lerp(0f, 12f, MathHelper.Clamp((distanceFromDestination - distanceFromTarget) / 1000f, 0f, 1f)); - - if (Main.getGoodWorld) - { - maxVelocity *= 1.15f; - acceleration *= 1.15f; - } - - NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - } - - // Fire flamethrower for x seconds - NPC.ai[2] += (retAlive && spazAlive) ? 1f : 2f; - float phaseGateValue = NPC.IsMechQueenUp ? 1350f : 360f - (death ? 90f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - if (NPC.ai[2] >= phaseGateValue) - { - // Go to charge phase or fire large barrage of lasers and energy bombs if in final phase - NPC.ai[1] = finalPhase ? 3f : 1f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - } - - // Fire fireballs and flamethrower - else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) - { - // Play flame sound on timer - NPC.localAI[2] += 1f; - if (NPC.localAI[2] > 22f) - { - NPC.localAI[2] = 0f; - SoundEngine.PlaySound(SoundID.Item34, NPC.Center); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[1] += 1f; - if (NPC.localAI[1] > 4f) - { - NPC.localAI[1] = 0f; - - float foveanatorFlamethrowerSpeed = 4f + 2f * enrageScale; - float timeForFlamethrowerToReachMaxVelocity = (retAlive && spazAlive) ? 120f : 60f; - float flamethrowerSpeedScalar = MathHelper.Clamp(NPC.ai[2] / timeForFlamethrowerToReachMaxVelocity, 0f, 1f); - foveanatorFlamethrowerSpeed = MathHelper.Lerp(0.1f, foveanatorFlamethrowerSpeed, flamethrowerSpeedScalar); - - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 flamethrowerVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * foveanatorFlamethrowerSpeed + NPC.velocity * 0.5f; - - if (NPC.IsMechQueenUp) - flamethrowerVelocity = (NPC.rotation + MathHelper.PiOver2).ToRotationVector2() * foveanatorFlamethrowerSpeed + NPC.velocity * 0.5f; - - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 100f, flamethrowerVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - - if (NPC.IsMechQueenUp) - { - maxVelocity = 14f; - - destination = mechQueenSpacing; - distanceFromDestination = (destination - NPC.Center).Length(); - idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitY); - - if (distanceFromDestination > maxVelocity) - idealVelocity *= maxVelocity / distanceFromDestination; - - float inertia = 60f; - NPC.velocity = (NPC.velocity * (inertia - 1f) + idealVelocity) / inertia; - } - } - - // Charge - else if (NPC.ai[1] == 1f) - { - // Set damage - NPC.damage = setDamage; - - // Play charge sound - // TODO - Make this a jet turbine sound or something - //SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); - - // Set rotation and velocity - NPC.rotation = hoverRotation; - - float chargeSpeed = 4.5f + (death ? 1.25f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - chargeSpeed += 4f * enrageScale; - if (Main.getGoodWorld) - chargeSpeed *= 1.2f; - - NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * chargeSpeed; - - NPC.ai[1] = 2f; - } - - // Maintain charge velocity until deceleration - else if (NPC.ai[1] == 2f) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[2] += 1f; - - float chargeTime = 60f - (death ? 20f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - - // Slow down - if (NPC.ai[2] >= chargeTime) - { - // Avoid cheap bullshit - NPC.damage = 0; - - float deceleration = 0.8f - (death ? 0.15f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - NPC.velocity *= deceleration; - - if (Math.Abs(NPC.velocity.X) < 0.1) - NPC.velocity.X = 0f; - if (Math.Abs(NPC.velocity.Y) < 0.1) - NPC.velocity.Y = 0f; - } - else - { - // Accelerative charge - float maxVelocity = 27f; - maxVelocity += 6f * enrageScale; - if (death) - maxVelocity += 7.5f * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - if (Main.getGoodWorld) - maxVelocity *= 1.2f; - - // Spawn Energy Bombs along the way - float energyBombFireRate = 8f; - if (NPC.ai[2] % energyBombFireRate == 0f) - { - SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.velocity.SafeNormalize(Vector2.UnitY) * 60f, Vector2.Zero, type, damage, 0f, Main.myPlayer, death ? 2f : 1f); - } - } - - if (NPC.velocity.Length() < maxVelocity) - { - NPC.velocity *= 1.06f; - if (NPC.velocity.Length() > maxVelocity) - { - NPC.velocity.Normalize(); - NPC.velocity *= maxVelocity; - } - } - - NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; - } - - // Charge 2 times - if (NPC.ai[2] >= chargeTime * 1.3f) - { - NPC.ai[3] += 1f; - NPC.ai[2] = 0f; - - NPC.rotation = hoverRotation; - - float maxCharges = 2f; - if (NPC.ai[3] >= maxCharges) - { - NPC.ai[1] = 0f; - NPC.ai[3] = 0f; - } - else - NPC.ai[1] = 1f; - } - } - - // Laser and energy bomb barrage - else if (NPC.ai[1] == 3f) - { - float maxVelocity = 12f + (death ? 2.4f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float acceleration = 0.16f + (death ? 0.32f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - maxVelocity += 6f * enrageScale; - acceleration += 0.08f * enrageScale; - - if (Main.getGoodWorld) - { - maxVelocity *= 1.15f; - acceleration *= 1.15f; - } - - float distanceFromTarget = 640f; - Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * distanceFromTarget * direction; - float distanceFromDestination = (destination - NPC.Center).Length(); - Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); - - bool gettingIntoPosition = NPC.ai[2] == 0f; - if (NPC.Distance(Main.player[NPC.target].Center) < distanceFromTarget && gettingIntoPosition) - { - NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - } - else - { - NPC.SimpleFlyMovement(idealVelocity * maxVelocity * 0.5f, acceleration * 0.5f); - - // Fire 2 spreads (3 in Death Mode) of energy bombs and lasers - int totalSpreads = death ? 6 : 4; - - // Fire rates - float laserBarrageFireRate = 45f; - float energyBombFireRate = 90f; - - NPC.ai[2] += 1f; - - // Energy bombs - if (NPC.ai[2] % energyBombFireRate == 0f) - { - SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * 16f; - int numProj = 3; - int spread = 30; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 60f, perturbedSpeed, type, damage, 0f, Main.myPlayer, death ? 1f : 0f); - } - } - - NPC.ai[3] += 1f; - } - - else if (NPC.ai[2] % laserBarrageFireRate == 0f) - { - SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - float projectileSpeed = 8f + 2f * enrageScale; - Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - int numProj = 4; - int spread = 40; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 60f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } - } - - NPC.ai[3] += 1f; - } - - // Charge - if (NPC.ai[3] >= totalSpreads) - { - NPC.ai[1] = 1f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - } - } - } - } - } - - public override void BossLoot(ref string name, ref int potionType) => potionType = ItemID.GreaterHealingPotion; - - public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) - { - NPC.lifeMax = (int)(NPC.lifeMax * 0.75f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - spriteBatch.Draw(TextureAssets.Npc[Type].Value, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0f); - - Texture2D glowTexture = GlowTexture.Value; - spriteBatch.Draw(glowTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, Color.White, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life > 0) - { - for (int i = 0; (double)i < hit.Damage / (double)NPC.lifeMax * 100D; i++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f); - - return; - } - - for (int i = 0; i < 150; i++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 2 * hit.HitDirection, -2f); - - if (!Main.dedServ) - { - for (int i = 0; i < 2; i++) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 2, NPC.scale); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 7, NPC.scale); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 9, NPC.scale); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), Mod.Find("Foveanator2").Type, NPC.scale); - } - } - - for (int i = 0; i < 10; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 31, 0f, 0f, 100, default, 1.5f); - Main.dust[dust].velocity *= 1.4f; - } - - for (int i = 0; i < 5; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 6, 0f, 0f, 100, default, 2.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 5f; - dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 6, 0f, 0f, 100, default, 1.5f); - Main.dust[dust].velocity *= 3f; - } - - if (!Main.dedServ) - { - int gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default, Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X += 1f; - Main.gore[gore].velocity.Y += 1f; - gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default, Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X -= 1f; - Main.gore[gore].velocity.Y += 1f; - gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default, Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X += 1f; - Main.gore[gore].velocity.Y -= 1f; - gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default, Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X -= 1f; - Main.gore[gore].velocity.Y -= 1f; - } - } - } -} diff --git a/NPCs/NormalNPCs/Foveanator.png b/NPCs/NormalNPCs/Foveanator.png deleted file mode 100644 index 67291fe4aa..0000000000 Binary files a/NPCs/NormalNPCs/Foveanator.png and /dev/null differ diff --git a/NPCs/NormalNPCs/FoveanatorGlow.png b/NPCs/NormalNPCs/FoveanatorGlow.png deleted file mode 100644 index d8b3325658..0000000000 Binary files a/NPCs/NormalNPCs/FoveanatorGlow.png and /dev/null differ diff --git a/NPCs/NormalNPCs/Foveanator_Head_Boss.png b/NPCs/NormalNPCs/Foveanator_Head_Boss.png deleted file mode 100644 index 7c93efb49e..0000000000 Binary files a/NPCs/NormalNPCs/Foveanator_Head_Boss.png and /dev/null differ diff --git a/NPCs/NormalNPCs/Foveanator_Phase2_Head_Boss.png b/NPCs/NormalNPCs/Foveanator_Phase2_Head_Boss.png deleted file mode 100644 index 6a6b7c7532..0000000000 Binary files a/NPCs/NormalNPCs/Foveanator_Phase2_Head_Boss.png and /dev/null differ diff --git a/NPCs/NormalNPCs/Frogfish.cs b/NPCs/NormalNPCs/Frogfish.cs index 3c4fe4c6f8..0e64c5dc05 100644 --- a/NPCs/NormalNPCs/Frogfish.cs +++ b/NPCs/NormalNPCs/Frogfish.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Potions; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -26,7 +25,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 100; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.5f; @@ -37,10 +36,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/Horse.cs b/NPCs/NormalNPCs/Horse.cs deleted file mode 100644 index 9d463af369..0000000000 --- a/NPCs/NormalNPCs/Horse.cs +++ /dev/null @@ -1,318 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ModLoader.Utilities; - -namespace CalamityMod.NPCs.NormalNPCs -{ - public class Horse : ModNPC - { - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - Scale = 0.4f, - PortraitScale = 0.6f, - PortraitPositionYOverride = -20f - }; - value.Position.X += 28f; - value.Position.Y -= 56f; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - } - - public override void SetDefaults() - { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.npcSlots = 3f; - NPC.damage = 50; - NPC.width = 230; - NPC.height = 230; - NPC.defense = 20; - NPC.DR_NERD(0.1f); - NPC.lifeMax = 3800; - NPC.aiStyle = -1; - AIType = -1; - NPC.knockBackResist = 0.05f; - NPC.value = Item.buyPrice(0, 1, 50, 0); - NPC.dontTakeDamage = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.rarity = 2; - Banner = NPC.type; - BannerItem = ModContent.ItemType(); - NPC.Calamity().VulnerableToSickness = false; - NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Caverns, - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Horse") - }); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(NPC.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - NPC.dontTakeDamage = reader.ReadBoolean(); - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.PlayerSafe || !Main.hardMode || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea || !spawnInfo.Player.ZoneRockLayerHeight) - return 0f; - - // Keep this as a separate if check, because it's a loop and we don't want to be checking it constantly. - if (NPC.AnyNPCs(NPC.type)) - return 0f; - - return SpawnCondition.Cavern.Chance * 0.005f; - } - - public override void FindFrame(int frameHeight) - { - if (NPC.ai[0] == 0f && !NPC.IsABestiaryIconDummy) - return; - - NPC.frameCounter++; - if (NPC.frameCounter >= 8) - { - NPC.frame.Y = (NPC.frame.Y + frameHeight) % (Main.npcFrameCount[Type] * frameHeight); - NPC.frameCounter = 0; - } - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - var weapons = new int[] - { - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - }; - npcLoot.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); - } - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, hit.HitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - SoundEngine.PlaySound(SoundID.Item14, NPC.Center); - NPC.position.X = NPC.position.X + (NPC.width / 2); - NPC.position.Y = NPC.position.Y + (NPC.height / 2); - NPC.width = 160; - NPC.height = 160; - NPC.position.X = NPC.position.X - (NPC.width / 2); - NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int i = 0; i < 40; i++) - { - int earthDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, 0f, 0f, 100, default, 2f); - Main.dust[earthDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[earthDust].scale = 0.5f; - Main.dust[earthDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 70; j++) - { - int earthDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 3f); - Main.dust[earthDust2].noGravity = true; - Main.dust[earthDust2].velocity *= 5f; - earthDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); - Main.dust[earthDust2].velocity *= 2f; - } - - if (!Main.dedServ) - { - Vector2 goreSource = NPC.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(NPC.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } - } - } - } - - public override bool PreAI() - { - // Get a target - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) - NPC.TargetClosest(); - - if (Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) < 480f) - { - if (NPC.ai[0] == 0f) - { - if (Main.zenithWorld) - { - SoundEngine.PlaySound(SoundID.ScaryScream, Main.player[NPC.target].Center); - } - NPC.ai[0] = 1f; - NPC.dontTakeDamage = false; - } - } - else - NPC.TargetClosest(); - - if (NPC.ai[0] == 0f) - return false; - - if (Main.player[NPC.target].dead || !Main.player[NPC.target].active) - { - if (NPC.velocity.Y < -2f) - NPC.velocity.Y = -2f; - NPC.velocity.Y += 0.1f; - if (NPC.velocity.Y > 12f) - NPC.velocity.Y = 12f; - - if (NPC.timeLeft > 60) - NPC.timeLeft = 60; - } - - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= 300f) - { - NPC.localAI[0] = 0f; - SoundEngine.PlaySound(SoundID.NPCHit43, NPC.Center); - NPC.TargetClosest(); - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) - { - float rockSpeed = 4f; - int damage = Main.masterMode ? 18 : Main.expertMode ? 22 : 30; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 projPosition = NPC.Center; - float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; - float absoluteTargetX = Math.Abs(targetXDist) * 0.1f; - float targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y - absoluteTargetX; - float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); - targetDistance = rockSpeed / targetDistance; - targetXDist *= targetDistance; - targetYDist *= targetDistance; - int rockType = ModContent.ProjectileType(); - projPosition.X += targetXDist; - projPosition.Y += targetYDist; - for (int k = 0; k < 4; k++) - { - rockType = Main.rand.NextBool(4) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; - targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y; - targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); - targetDistance = rockSpeed / targetDistance; - targetXDist += Main.rand.Next(-40, 41); - targetYDist += Main.rand.Next(-40, 41); - targetXDist *= targetDistance; - targetYDist *= targetDistance; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projPosition.X, projPosition.Y, targetXDist, targetYDist, rockType, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - - float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; - NPC.direction = playerLocation < 0 ? 1 : -1; - NPC.spriteDirection = NPC.direction; - - Vector2 direction = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); - float chargeGateValue = Main.expertMode ? 300f : 600f; - NPC.ai[1] += 1f; - if (NPC.ai[1] >= chargeGateValue) - { - // Set damage - NPC.damage = NPC.defDamage; - - float chargeVelocity = Main.expertMode ? 9f : 6f; - direction *= chargeVelocity; - NPC.velocity = direction; - NPC.ai[1] = -30f; - } - - if (Math.Sqrt((NPC.velocity.X * NPC.velocity.X) + (NPC.velocity.Y * NPC.velocity.Y)) > 1D && NPC.ai[1] >= 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.velocity *= 0.97f; - } - - if (Math.Sqrt((NPC.velocity.X * NPC.velocity.X) + (NPC.velocity.Y * NPC.velocity.Y)) <= 1.15) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.velocity = direction; - } - - return false; - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 180); - } - } -} diff --git a/NPCs/NormalNPCs/IceClasper.cs b/NPCs/NormalNPCs/IceClasper.cs index 3bd82cae9d..eb0e0d1005 100644 --- a/NPCs/NormalNPCs/IceClasper.cs +++ b/NPCs/NormalNPCs/IceClasper.cs @@ -81,12 +81,12 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 50; NPC.height = 50; NPC.defense = 12; - NPC.lifeMax = 750; + NPC.lifeMax = 500; NPC.knockBackResist = 0.25f; NPC.noTileCollide = true; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath7; NPC.rarity = 2; @@ -96,10 +96,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -240,7 +236,7 @@ namespace CalamityMod.NPCs.NormalNPCs else if (AITimer >= TimeBetweenBurst / 2f && AITimer < TimeBetweenBurst) { Vector2 randPos = Main.rand.NextVector2CircularEdge(100f, 100f); - Dust telegraphDust = Dust.NewDustPerfect(NPC.Center + randPos, 172, NPC.DirectionFrom(NPC.Center + NPC.velocity + randPos) * Main.rand.NextFloat(5f, 7f), 0, default, 1.5f); + Dust telegraphDust = Dust.NewDustPerfect(NPC.Center + randPos, DustID.DungeonWater, NPC.DirectionFrom(NPC.Center + NPC.velocity + randPos) * Main.rand.NextFloat(5f, 7f), 0, default, 1.5f); telegraphDust.noGravity = true; NPC.netUpdate = true; } @@ -293,8 +289,8 @@ namespace CalamityMod.NPCs.NormalNPCs { if (hurtInfo.Damage > 0) { - target.AddBuff(BuffID.Frostburn, 180, true); - target.AddBuff(BuffID.Chilled, 120, true); + target.AddBuff(BuffID.Frostburn, 240); + target.AddBuff(BuffID.Chilled, 120); } } diff --git a/NPCs/NormalNPCs/ImpiousImmolator.cs b/NPCs/NormalNPCs/ImpiousImmolator.cs index 923a6e30ad..795dc0b4e7 100644 --- a/NPCs/NormalNPCs/ImpiousImmolator.cs +++ b/NPCs/NormalNPCs/ImpiousImmolator.cs @@ -3,7 +3,7 @@ using System.IO; using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Potions; +using CalamityMod.Items.Potions.Food; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Enemy; using CalamityMod.World; @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 3000; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 50, 0); + NPC.value = Item.buyPrice(silver: 50); NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath7; NPC.knockBackResist = 0.2f; @@ -46,10 +46,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/KingSlimeJewelEmerald.cs b/NPCs/NormalNPCs/KingSlimeJewelEmerald.cs deleted file mode 100644 index 18b6c3c052..0000000000 --- a/NPCs/NormalNPCs/KingSlimeJewelEmerald.cs +++ /dev/null @@ -1,312 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CalPlayer; -using CalamityMod.Events; -using CalamityMod.Graphics.Primitives; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Boss; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - public class KingSlimeJewelEmerald : ModNPC - { - public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewelEmerald"; - - private const int ChargePhaseGateValue = 120; - private const int ChargeGateValue = 60; - private const int ChargeGateValue_Death = 40; - private const float LightTelegraphDuration = 30f; - - public override void SetStaticDefaults() - { - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); - } - - public override void SetDefaults() - { - NPC.aiStyle = -1; - AIType = -1; - NPC.GetNPCDamage(); - NPC.width = 32; - NPC.height = 32; - NPC.defense = 15; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 240; - NPC.knockBackResist = 0.7f; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit5; - NPC.DeathSound = SoundID.NPCDeath15; - NPC.Calamity().VulnerableToSickness = false; - } - - public override void AI() - { - // Despawn - if (!CalamityPlayer.areThereAnyDamnBosses) - { - NPC.life = 0; - OnKill(); - NPC.active = false; - NPC.netUpdate = true; - return; - } - - Lighting.AddLight(NPC.Center, 0f, 0.8f, 0f); - - // Get a target - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) - { - CalamityUtils.CalamityTargeting(NPC, default); - } - - if (NPC.ai[3] == 1f) - { - NPC.knockBackResist = 0f; - - if (NPC.ai[0] == 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.velocity *= CalamityWorld.death ? 0.94f : 0.96f; - - NPC.ai[1] += 1f; - - float anglularSpeed = NPC.ai[1] / (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue); - anglularSpeed = 0.1f + anglularSpeed * 0.4f; - NPC.rotation += anglularSpeed * NPC.direction; - - if (NPC.ai[1] >= (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue)) - { - for (int dusty = 0; dusty < 10; dusty++) - { - 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; - if (Main.rand.NextBool()) - { - Main.dust[emerald].scale = 0.5f; - Main.dust[emerald].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - SoundEngine.PlaySound(SoundID.Item38, NPC.Center); - - NPC.ai[0] = 1f; - NPC.ai[1] = 0f; - NPC.netUpdate = true; - } - } - else if (NPC.ai[0] == 1f) - { - // Set damage - NPC.damage = NPC.defDamage; - - float chargeSpeed = CalamityWorld.death ? 24f : 16f; - NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f, -Vector2.UnitY) * chargeSpeed; - NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; - - NPC.ai[0] = 2f; - NPC.ai[1] = 0f; - NPC.ForceNetUpdate(); - } - else if (NPC.ai[0] == 2f) - { - // Set damage - NPC.damage = NPC.defDamage; - - NPC.rotation += MathHelper.ToRadians(Math.Sign(NPC.velocity.X) * 15); - - CustomSprite spriteParticle = new CustomSprite(NPC.Center - NPC.velocity, NPC.velocity * 0.8f, 10, "CalamityMod/NPCs/NormalNPCs/KingSlimeJewelEmerald", 1.2f, Color.DarkGreen.MultiplyRGBA(new Color(1f, 1f, 1f, 0f))); - spriteParticle.Rotation = NPC.rotation; - - GeneralParticleHandler.SpawnParticle(spriteParticle); - - NPC.ai[1] += 1f; - if (NPC.ai[1] >= (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue)) - { - // Avoid cheap bullshit - NPC.damage = 0; - - for (int dusty = 0; dusty < 10; dusty++) - { - Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); - 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; - if (Main.rand.NextBool()) - { - Main.dust[emerald].scale = 0.5f; - Main.dust[emerald].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - - NPC.velocity = Vector2.Zero; - } - } - } - else - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.knockBackResist = 0.7f; - - NPC.rotation = NPC.velocity.X / 15f; - - float velocity = 5f; - float acceleration = 0.2f; - - if (NPC.position.Y > Main.player[NPC.target].position.Y - 200f) - { - if (NPC.velocity.Y > 0f) - NPC.velocity.Y *= 0.98f; - - NPC.velocity.Y -= acceleration; - - if (NPC.velocity.Y > velocity) - NPC.velocity.Y = velocity; - } - else if (NPC.position.Y < Main.player[NPC.target].position.Y - 300f) - { - if (NPC.velocity.Y < 0f) - NPC.velocity.Y *= 0.98f; - - NPC.velocity.Y += acceleration; - - if (NPC.velocity.Y < -velocity) - NPC.velocity.Y = -velocity; - } - - if (NPC.Center.X > Main.player[NPC.target].Center.X + 200f) - { - if (NPC.velocity.X > 0f) - NPC.velocity.X *= 0.98f; - - NPC.velocity.X -= acceleration; - - if (NPC.velocity.X > 8f) - NPC.velocity.X = 8f; - } - if (NPC.Center.X < Main.player[NPC.target].Center.X - 200f) - { - if (NPC.velocity.X < 0f) - NPC.velocity.X *= 0.98f; - - NPC.velocity.X += acceleration; - - if (NPC.velocity.X < -8f) - NPC.velocity.X = -8f; - } - - NPC.ai[2] += 1f; - if (NPC.ai[2] >= ChargePhaseGateValue) - { - NPC.ai[2] = 0f; - NPC.ai[3] = 1f; - NPC.netUpdate = true; - } - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Color col = Color.DarkOliveGreen; - Color flashCol = Color.Lime; - - float alph = 0f; - - float colorTelegraphGateValue = (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue) - LightTelegraphDuration; - - if (NPC.ai[0] > colorTelegraphGateValue) - alph = MathHelper.Lerp(0f, 1f, (NPC.ai[0] - colorTelegraphGateValue) / LightTelegraphDuration); - - Asset tex = ModContent.Request(Texture); - Asset tex2 = ModContent.Request("CalamityMod/NPCs/NormalNPCs/KingSlimeJewelFlash"); - - Main.EntitySpriteDraw(tex.Value, NPC.Center - screenPos, tex.Frame(), Color.White, NPC.rotation, tex.Frame().Center(), 1f, SpriteEffects.None); - Main.EntitySpriteDraw(tex2.Value, NPC.Center - screenPos, tex2.Frame(), Color.Lerp(col, flashCol, alph).MultiplyRGBA(new Color(alph, alph, alph, 0f)), NPC.rotation, tex2.Frame().Center(), alph * 1.2f, SpriteEffects.None); - - return false; - } - - public override void OnKill() - { - for (int i = 0; i < 6; i++) - { - GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.DarkSeaGreen)); - GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Lime)); - } - - float start = Main.rand.NextFloat(MathHelper.TwoPi); - for (int i = 0; i < 3; i++) - GeneralParticleHandler.SpawnParticle(new CustomSprite(NPC.Center, new Vector2(0, -2).RotatedByRandom(start + MathHelper.ToRadians(20f)).RotatedBy(MathHelper.ToRadians(i * 125)), 120, "CalamityMod/Particles/KingSlimeEmeraldShards", 1f, new Color(255, 255, 255), Main.rand.NextFloat(0.2f, 0.6f), frameCount: 3, frame: i)); - - SoundEngine.PlaySound(KingSlimeJewelRuby.ShatterSound, NPC.Center); - } - - public override Color? GetAlpha(Color drawColor) => Color.White; - - public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) - { - NPC.lifeMax = (int)(NPC.lifeMax * balance); - } - - public override bool CheckActive() => false; - - public override void HitEffect(NPC.HitInfo hit) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, hit.HitDirection, -1f, 0, default, 1f); - Main.dust[dust].noGravity = true; - - if (NPC.life <= 0) - { - NPC.position = NPC.Center; - NPC.width = NPC.height = 45; - NPC.position.X = NPC.position.X - (NPC.width / 2); - NPC.position.Y = NPC.position.Y - (NPC.height / 2); - - for (int i = 0; i < 2; i++) - { - int emeraldDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); - Main.dust[emeraldDust].noGravity = true; - Main.dust[emeraldDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[emeraldDust].scale = 0.5f; - Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int j = 0; j < 10; j++) - { - int emeraldDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 3f); - Main.dust[emeraldDust2].noGravity = true; - Main.dust[emeraldDust2].velocity *= 5f; - emeraldDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); - Main.dust[emeraldDust2].noGravity = true; - Main.dust[emeraldDust2].velocity *= 2f; - } - } - } - } -} diff --git a/NPCs/NormalNPCs/KingSlimeJewelRuby.cs b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs index 9a644aa5ae..1352b941dd 100644 --- a/NPCs/NormalNPCs/KingSlimeJewelRuby.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using System.Runtime.InteropServices; +using System; using CalamityMod.CalPlayer; using CalamityMod.Events; -using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -11,10 +9,8 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; namespace CalamityMod.NPCs.NormalNPCs { @@ -22,11 +18,19 @@ namespace CalamityMod.NPCs.NormalNPCs { public static readonly SoundStyle ShatterSound = new SoundStyle("CalamityMod/Sounds/NPCKilled/CrownJewelShatter"); public static readonly SoundStyle ShootSound = new SoundStyle("CalamityMod/Sounds/Custom/RedJewelFire"); + public static readonly SoundStyle ModeShiftSound = new SoundStyle("CalamityMod/Sounds/Custom/RedJewelModeShift"); + private const int BoltShootGateValue = 60; - private const int BoltShootGateValue_Death = 75; - private const int BoltShootGateValue_BossRush = 45; - private const float LightTelegraphDuration = 45f; + private const int BoltShootGateValue_Death = 60; + private const float RubyLightTelegraphDuration = 45f; + + public static int JewelBoltDamage = 10; // 40 + + private const int EmeraldChargePhaseGateValue = 120; + private const int EmeraldChargeGateValue = 60; + private const int EmeraldChargeGateValue_Death = 40; + private const float EmeraldLightTelegraphDuration = 30f; public override void SetStaticDefaults() { @@ -39,7 +43,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.aiStyle = -1; AIType = -1; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 24; // 72. Contact damage only occurs in the "Emerald" phase, which is Death exclusive. NPC.width = 32; NPC.height = 32; NPC.defense = 10; @@ -55,8 +59,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Despawn if (!CalamityPlayer.areThereAnyDamnBosses) { NPC.life = 0; @@ -66,107 +70,383 @@ namespace CalamityMod.NPCs.NormalNPCs return; } - Lighting.AddLight(NPC.Center, 0.8f, 0f, 0f); - - // Float around the player - NPC.rotation = NPC.velocity.X / 15f; - - // Get a target - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC kingSlime = null; + foreach (NPC n in Main.npc) { - CalamityUtils.CalamityTargeting(NPC, default); - } - - float velocity = 5f; - float acceleration = 0.1f; - - if (NPC.position.Y > Main.player[NPC.target].position.Y - 350f) - { - if (NPC.velocity.Y > 0f) - NPC.velocity.Y *= 0.98f; - - NPC.velocity.Y -= acceleration; - - if (NPC.velocity.Y > velocity) - NPC.velocity.Y = velocity; - } - else if (NPC.position.Y < Main.player[NPC.target].position.Y - 450f) - { - if (NPC.velocity.Y < 0f) - NPC.velocity.Y *= 0.98f; - - NPC.velocity.Y += acceleration; - - if (NPC.velocity.Y < -velocity) - NPC.velocity.Y = -velocity; - } - - if (NPC.Center.X > Main.player[NPC.target].Center.X + 100f) - { - if (NPC.velocity.X > 0f) - NPC.velocity.X *= 0.98f; - - NPC.velocity.X -= acceleration; - - if (NPC.velocity.X > 8f) - NPC.velocity.X = 8f; - } - if (NPC.Center.X < Main.player[NPC.target].Center.X - 100f) - { - if (NPC.velocity.X < 0f) - NPC.velocity.X *= 0.98f; - - NPC.velocity.X += acceleration; - - if (NPC.velocity.X < -8f) - NPC.velocity.X = -8f; - } - - // Fire projectiles - NPC.ai[0] += 1f; - if (NPC.ai[0] >= (BossRushEvent.BossRushActive ? BoltShootGateValue_BossRush : CalamityWorld.death ? BoltShootGateValue_Death : BoltShootGateValue)) - { - NPC.ai[0] = 0f; - - Vector2 npcPos = NPC.Center; - float xDist = Main.player[NPC.target].Center.X - npcPos.X; - float yDist = Main.player[NPC.target].Center.Y - npcPos.Y; - Vector2 projVector = new Vector2(xDist, yDist); - float projLength = projVector.Length(); - - float speed = Main.masterMode ? 12f : 10f; - int type = ModContent.ProjectileType(); - - projLength = speed / projLength; - projVector.X *= projLength; - projVector.Y *= projLength; - - for (int i = 0; i < 6; i++) + if (n.active && n.type == NPCID.KingSlime) { - GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); - GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Pink)); + kingSlime = n; + break; } + } - SoundEngine.PlaySound(ShootSound, NPC.Center); + // Invincibility logic + if (death && kingSlime != null && kingSlime.active) + { + NPC.dontTakeDamage = true; + } + else + { + NPC.dontTakeDamage = false; + } - if (Main.netMode != NetmodeID.MultiplayerClient) + float kingSlimeLifeRatio = (kingSlime != null && kingSlime.active) ? (float)kingSlime.life / kingSlime.lifeMax : 1f; + + bool isInitialEmeraldPhase = death && (kingSlimeLifeRatio < 0.55f && kingSlimeLifeRatio >= 0.35f); + bool isAlternatingPhase = death && kingSlimeLifeRatio < 0.35f; + + // [0]: 0f = ruby AI, 1f = emerald AI + // [1]: Ruby attack counter + // [2]: Emerald attack counter + // [3]: Phase (0f = standard, 1f = initial Emerald, 2f = alternating) + if (isInitialEmeraldPhase) + { + if (NPC.localAI[3] != 1f) // Transition to initial Emerald phase { - int damage = NPC.GetProjectileDamage(type); - if (CalamityWorld.death || BossRushEvent.BossRushActive) + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[0] = 1f; // Become emerald + NPC.localAI[1] = 0; + NPC.localAI[2] = 0; + NPC.localAI[3] = 1f; // Set overall phase flag to initial Emerald + + SoundEngine.PlaySound(ModeShiftSound with { Volume = 0.5f }); + NPC.netUpdate = true; + + for (int i = 0; i < 6; i++) { - int numProj = Main.masterMode ? 5 : 4; - float rotation = MathHelper.ToRadians(18); - for (int i = 0; i < numProj; i++) + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Pink)); + } + } + } + + else if (isAlternatingPhase) + { + if (NPC.localAI[3] != 2f) // Transition to alternating phase + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[0] = 0f; // Become ruby + NPC.localAI[1] = 0; + NPC.localAI[2] = 0; + NPC.localAI[3] = 2f; // Flag as alternating + + SoundEngine.PlaySound(ModeShiftSound with { Volume = 0.4f }); + NPC.netUpdate = true; + + for (int i = 0; i < 6; i++) + { + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Pink)); + } + } + } + + else // Either rev, or death when above 55% + { + if (NPC.localAI[3] != 0f) // Standard ruby AI w/o alternating + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[0] = 0f; // Become ruby + NPC.localAI[1] = 0; + NPC.localAI[2] = 0; + NPC.localAI[3] = 0f; // Set overall phase flag to normal + NPC.netUpdate = true; + } + } + + bool currentModeIsEmerald = NPC.localAI[0] == 1f; + + if (currentModeIsEmerald) + { + Lighting.AddLight(NPC.Center, 0f, 0.8f, 0f); + + if (NPC.ai[3] == 1f) + { + NPC.knockBackResist = 0f; + + if (NPC.ai[0] == 0f) + { + NPC.damage = 0; + + NPC.velocity *= 0.94f; + + NPC.ai[1] += 1f; + + float anglularSpeed = NPC.ai[1] / EmeraldChargeGateValue_Death; + anglularSpeed = 0.1f + anglularSpeed * 0.4f; + NPC.rotation += anglularSpeed * NPC.direction; + + if (NPC.ai[1] >= EmeraldChargeGateValue_Death) { - Vector2 perturbedSpeed = projVector.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPos, perturbedSpeed, type, damage, 0f, Main.myPlayer); + for (int dusty = 0; dusty < 10; dusty++) + { + 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; + if (Main.rand.NextBool()) + { + Main.dust[emerald].scale = 0.5f; + Main.dust[emerald].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + SoundEngine.PlaySound(SoundID.Item38, NPC.Center); + + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } } - else - Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPos, projVector, type, damage, 0f, Main.myPlayer); + else if (NPC.ai[0] == 1f) + { + NPC.damage = NPC.defDamage; + + float chargeSpeed = 22f; + NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 10f, -Vector2.UnitY) * chargeSpeed; // Slightly predictive + NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; + + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.ForceNetUpdate(); + } + else if (NPC.ai[0] == 2f) + { + NPC.damage = NPC.defDamage; + + NPC.rotation += MathHelper.ToRadians(Math.Sign(NPC.velocity.X) * 15); + + CustomSprite spriteParticle = new CustomSprite(NPC.Center - NPC.velocity, NPC.velocity * 0.8f, 10, "CalamityMod/NPCs/NormalNPCs/KingSlimeJewelEmerald", 1.2f, Color.DarkGreen.MultiplyRGBA(new Color(1f, 1f, 1f, 0f))); + spriteParticle.Rotation = NPC.rotation; + + GeneralParticleHandler.SpawnParticle(spriteParticle); + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= EmeraldChargeGateValue_Death) + { + NPC.damage = 0; + + for (int dusty = 0; dusty < 10; dusty++) + { + Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + 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; + if (Main.rand.NextBool()) + { + Main.dust[emerald].scale = 0.5f; + Main.dust[emerald].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + + NPC.velocity = Vector2.Zero; + + if (isAlternatingPhase) + { + NPC.localAI[2]++; + if (NPC.localAI[2] >= 2) + { + NPC.localAI[0] = 0f; // Become ruby + NPC.localAI[1] = 0; // Reset ruby attack counter + NPC.localAI[2] = 0; // Reset emerald attack counter + + SoundEngine.PlaySound(ModeShiftSound with { Volume = 0.5f }); + NPC.netUpdate = true; + + for (int i = 0; i < 6; i++) + { + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Pink)); + } + } + } + } + } + } + else + { + NPC.damage = 0; + + NPC.knockBackResist = 0.7f; + + NPC.rotation = NPC.velocity.X / 15f; + + float velocity = 5f; + float acceleration = 0.2f; + + if (NPC.position.Y > Main.player[NPC.target].position.Y - 200f) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > velocity) + NPC.velocity.Y = velocity; + } + else if (NPC.position.Y < Main.player[NPC.target].position.Y - 300f) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y += acceleration; + + if (NPC.velocity.Y < -velocity) + NPC.velocity.Y = -velocity; + } + + if (NPC.Center.X > Main.player[NPC.target].Center.X + 200f) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X -= acceleration; + + if (NPC.velocity.X > 8f) + NPC.velocity.X = 8f; + } + if (NPC.Center.X < Main.player[NPC.target].Center.X - 200f) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X += acceleration; + + if (NPC.velocity.X < -8f) + NPC.velocity.X = -8f; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= EmeraldChargePhaseGateValue) + { + NPC.ai[2] = 0f; + NPC.ai[3] = 1f; + NPC.netUpdate = true; + } + } + } + else // Ruby AI + { + Lighting.AddLight(NPC.Center, 0.8f, 0f, 0f); + + NPC.rotation = NPC.velocity.X / 15f; + + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + CalamityUtils.CalamityTargeting(NPC, default); } - NPC.netUpdate = true; + float velocity = 5f; + float acceleration = 0.1f; + + if (NPC.position.Y > Main.player[NPC.target].position.Y - 350f) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > velocity) + NPC.velocity.Y = velocity; + } + else if (NPC.position.Y < Main.player[NPC.target].position.Y - 450f) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y += acceleration; + + if (NPC.velocity.Y < -velocity) + NPC.velocity.Y = -velocity; + } + + if (NPC.Center.X > Main.player[NPC.target].Center.X + 100f) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X -= acceleration; + + if (NPC.velocity.X > 8f) + NPC.velocity.X = 8f; + } + if (NPC.Center.X < Main.player[NPC.target].Center.X - 100f) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X += acceleration; + + if (NPC.velocity.X < -8f) + NPC.velocity.X = -8f; + } + + NPC.ai[0] += 1f; + if (NPC.ai[0] >= (death ? BoltShootGateValue_Death : BoltShootGateValue)) + { + NPC.ai[0] = 0f; + + Vector2 npcPos = NPC.Center; + float xDist = Main.player[NPC.target].Center.X - npcPos.X; + float yDist = Main.player[NPC.target].Center.Y - npcPos.Y; + Vector2 projVector = new Vector2(xDist, yDist); + float projLength = projVector.Length(); + + float speed = death ? 12f : 10f; + int type = ModContent.ProjectileType(); + + projLength = speed / projLength; + projVector.X *= projLength; + projVector.Y *= projLength; + + for (int i = 0; i < 6; i++) + { + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Pink)); + } + + SoundEngine.PlaySound(ShootSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPos, projVector, type, JewelBoltDamage, 0f, Main.myPlayer); + + NPC.netUpdate = true; + + if (isAlternatingPhase) + { + NPC.localAI[1]++; + if (NPC.localAI[1] >= 4) + { + NPC.localAI[0] = 1f; // Become emerald + NPC.localAI[1] = 0; // Reset ruby attack counter + NPC.localAI[2] = 0; // Reset emerald attack counter + + SoundEngine.PlaySound(ModeShiftSound with { Volume = 0.5f }); + NPC.netUpdate = true; + + for (int i = 0; i < 6; i++) + { + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Pink)); + } + } + } + } } } @@ -180,24 +460,39 @@ namespace CalamityMod.NPCs.NormalNPCs float start = Main.rand.NextFloat(MathHelper.TwoPi); for (int i = 0; i < 3; i++) + { GeneralParticleHandler.SpawnParticle(new CustomSprite(NPC.Center, new Vector2(0, -2).RotatedByRandom(start + MathHelper.ToRadians(20f)).RotatedBy(MathHelper.ToRadians(i * 125)), 120, "CalamityMod/Particles/KingSlimeRubyShards", 1f, new Color(255, 255, 255), Main.rand.NextFloat(0.2f, 0.6f), frameCount: 3, frame: i)); + } + SoundEngine.PlaySound(ShatterSound, NPC.Center); } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - Color col = Color.Red; - Color flashCol = Color.Pink; + bool emeraldMode = NPC.localAI[0] == 1f; + + Color col = emeraldMode ? Color.DarkOliveGreen : Color.Red; + Color flashCol = emeraldMode ? Color.Lime : Color.Pink; float alph = 0f; + float currentLightTelegraphDuration = emeraldMode ? EmeraldLightTelegraphDuration : RubyLightTelegraphDuration; + float currentColorTelegraphGateValue = (emeraldMode ? EmeraldChargeGateValue_Death : BoltShootGateValue_Death) - currentLightTelegraphDuration; - float colorTelegraphGateValue = (BossRushEvent.BossRushActive ? BoltShootGateValue_BossRush : (CalamityWorld.death ? BoltShootGateValue_Death : BoltShootGateValue)) - LightTelegraphDuration; + if (emeraldMode) + { + if (NPC.ai[0] == 0f && NPC.ai[1] > currentColorTelegraphGateValue) + { + alph = MathHelper.Lerp(0f, 1f, (NPC.ai[1] - currentColorTelegraphGateValue) / currentLightTelegraphDuration); + } + } + else + { + if (NPC.ai[0] > currentColorTelegraphGateValue) + alph = MathHelper.Lerp(0f, 1f, (NPC.ai[0] - currentColorTelegraphGateValue) / currentLightTelegraphDuration); + } - if (NPC.ai[0] > colorTelegraphGateValue) - alph = MathHelper.Lerp(0f, 1f, (NPC.ai[0] - colorTelegraphGateValue) / LightTelegraphDuration); - - Asset tex = ModContent.Request(Texture); + Asset tex = ModContent.Request(emeraldMode ? "CalamityMod/NPCs/NormalNPCs/KingSlimeJewelEmerald" : Texture); Asset tex2 = ModContent.Request("CalamityMod/NPCs/NormalNPCs/KingSlimeJewelFlash"); Main.EntitySpriteDraw(tex.Value, NPC.Center - screenPos, tex.Frame(), Color.White, NPC.rotation, tex.Frame().Center(), 1f, SpriteEffects.None); @@ -206,6 +501,18 @@ namespace CalamityMod.NPCs.NormalNPCs return false; } + public override void FindFrame(int frameHeight) + { + bool emeraldMode = NPC.localAI[0] == 1f; + + if (emeraldMode) + { + NPC.frameCounter = 2; + } + int frame = (int)NPC.frameCounter; + NPC.frame.Y = frame * frameHeight; + } + public override Color? GetAlpha(Color drawColor) => Color.White; public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) @@ -219,6 +526,44 @@ namespace CalamityMod.NPCs.NormalNPCs { for (int i = 0; i < 6; i++) GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.Red)); + + bool emeraldMode = NPC.localAI[0] == 1f; + if (emeraldMode) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, hit.HitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + + if (NPC.life <= 0) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = 45; + NPC.position.X = NPC.position.X - (NPC.width / 2); + NPC.position.Y = NPC.position.Y - (NPC.height / 2); + + for (int i = 0; i < 2; i++) + { + int emeraldDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emeraldDust].noGravity = true; + Main.dust[emeraldDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[emeraldDust].scale = 0.5f; + Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 10; j++) + { + int emeraldDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 3f); + Main.dust[emeraldDust2].noGravity = true; + Main.dust[emeraldDust2].velocity *= 5f; + emeraldDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emeraldDust2].noGravity = true; + Main.dust[emeraldDust2].velocity *= 2f; + } + } + } } } } + diff --git a/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs b/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs deleted file mode 100644 index fc02f5133c..0000000000 --- a/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs +++ /dev/null @@ -1,280 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CalPlayer; -using CalamityMod.Events; -using CalamityMod.Graphics.Primitives; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Boss; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - public class KingSlimeJewelSapphire : ModNPC - { - private const int BuffDustGateValue = 60; - private const float LightTelegraphDuration = 45f; - - public override void SetStaticDefaults() - { - NPCID.Sets.NeedsExpertScaling[Type] = true; - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); - } - - public override void SetDefaults() - { - NPC.aiStyle = -1; - AIType = -1; - NPC.damage = 0; - NPC.width = 32; - NPC.height = 32; - NPC.defense = 5; - NPC.DR_NERD(0.05f); - NPC.lifeMax = 120; - NPC.knockBackResist = 0.9f; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit5; - NPC.DeathSound = SoundID.NPCDeath15; - NPC.Calamity().VulnerableToSickness = false; - } - - public override void AI() - { - // Despawn - if (!CalamityPlayer.areThereAnyDamnBosses) - { - NPC.life = 0; - OnKill(); - NPC.active = false; - NPC.netUpdate = true; - return; - } - - Lighting.AddLight(NPC.Center, 0f, 0f, 0.8f); - - // Float around the player - NPC.rotation = NPC.velocity.X / 15f; - - // Get a target - if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) - { - CalamityUtils.CalamityTargeting(NPC, default); - } - - float velocity = 5f; - float acceleration = 0.1f; - - 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; - } - } - - Vector2 movementTarget = kingSlimeCenter == NPC.Center ? Main.player[NPC.target].Center : kingSlimeCenter; - if (NPC.position.Y > movementTarget.Y - 200f) - { - if (NPC.velocity.Y > 0f) - NPC.velocity.Y *= 0.98f; - - NPC.velocity.Y -= acceleration; - - if (NPC.velocity.Y > velocity) - NPC.velocity.Y = velocity; - } - else if (NPC.position.Y < movementTarget.Y - 250f) - { - if (NPC.velocity.Y < 0f) - NPC.velocity.Y *= 0.98f; - - NPC.velocity.Y += acceleration; - - if (NPC.velocity.Y < -velocity) - NPC.velocity.Y = -velocity; - } - - if (NPC.Center.X > movementTarget.X + 100f) - { - if (NPC.velocity.X > 0f) - NPC.velocity.X *= 0.98f; - - NPC.velocity.X -= acceleration; - - if (NPC.velocity.X > 8f) - NPC.velocity.X = 8f; - } - if (NPC.Center.X < movementTarget.X - 100f) - { - if (NPC.velocity.X < 0f) - NPC.velocity.X *= 0.98f; - - NPC.velocity.X += acceleration; - - if (NPC.velocity.X < -8f) - NPC.velocity.X = -8f; - } - - // Emit buff dust - NPC.ai[0] += 1f; - if (NPC.ai[0] >= BuffDustGateValue) - { - NPC.ai[0] = 0f; - - SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - - for (int dusty = 0; dusty < 10; dusty++) - { - 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; - if (Main.rand.NextBool()) - { - Main.dust[sapphire].scale = 0.5f; - Main.dust[sapphire].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - 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; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - Color col = Color.BlueViolet; - Color flashCol = Color.LightSkyBlue; - - NPC.localAI[1]++; - - float alph = 0.4f + (float)(Math.Sin(NPC.localAI[1] / 30f) * 0.4f); - - Asset tex = ModContent.Request(Texture); - Asset tex2 = ModContent.Request("CalamityMod/NPCs/NormalNPCs/KingSlimeJewelFlash"); - - Main.EntitySpriteDraw(tex.Value, NPC.Center - screenPos, tex.Frame(), Color.White, NPC.rotation, tex.Frame().Center(), 1f, SpriteEffects.None); - Main.EntitySpriteDraw(tex2.Value, NPC.Center - screenPos, tex2.Frame(), Color.Lerp(col, flashCol, alph).MultiplyRGBA(new Color(alph, alph, alph, 0f)), NPC.rotation, tex2.Frame().Center(), alph * 1.2f, SpriteEffects.None); - - return false; - } - - public override Color? GetAlpha(Color drawColor) - { - Color initialColor = new Color(100, 100, 175); - Color newColor = initialColor; - Color finalColor = new Color(150, 150, 255); - float colorTelegraphGateValue = BuffDustGateValue - LightTelegraphDuration; - if (NPC.ai[0] > colorTelegraphGateValue) - newColor = Color.Lerp(initialColor, finalColor, (NPC.ai[0] - colorTelegraphGateValue) / LightTelegraphDuration); - newColor.A = (byte)(255 * NPC.Opacity); - - return newColor; - } - - public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) - { - NPC.lifeMax = (int)(NPC.lifeMax * balance); - } - - public override void OnKill() - { - for (int i = 0; i < 6; i++) - { - GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.BlueViolet)); - GeneralParticleHandler.SpawnParticle(new PointParticle(NPC.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), false, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.LightSkyBlue)); - } - - float start = Main.rand.NextFloat(MathHelper.TwoPi); - for (int i = 0; i < 3; i++) - GeneralParticleHandler.SpawnParticle(new CustomSprite(NPC.Center, new Vector2(0, -2).RotatedByRandom(start + MathHelper.ToRadians(20f)).RotatedBy(MathHelper.ToRadians(i * 125)), 120, "CalamityMod/Particles/KingSlimeSapphireShards", 1f, new Color(255, 255, 255), Main.rand.NextFloat(0.2f, 0.6f), frameCount: 3, frame: i)); - - SoundEngine.PlaySound(KingSlimeJewelRuby.ShatterSound, NPC.Center); - } - - public override bool CheckActive() => false; - - public override void HitEffect(NPC.HitInfo hit) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, hit.HitDirection, -1f, 0, default, 1f); - Main.dust[dust].noGravity = true; - - if (NPC.life <= 0) - { - NPC.position = NPC.Center; - NPC.width = NPC.height = 45; - NPC.position.X = NPC.position.X - (NPC.width / 2); - NPC.position.Y = NPC.position.Y - (NPC.height / 2); - - for (int i = 0; i < 2; i++) - { - int rubyDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust].noGravity = true; - Main.dust[rubyDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[rubyDust].scale = 0.5f; - Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int j = 0; j < 10; j++) - { - int rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 3f); - Main.dust[rubyDust2].noGravity = true; - Main.dust[rubyDust2].velocity *= 5f; - rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust2].noGravity = true; - Main.dust[rubyDust2].velocity *= 2f; - } - } - } - } -} diff --git a/NPCs/NormalNPCs/KingSlimeJewelSapphire.png b/NPCs/NormalNPCs/KingSlimeJewelSapphire.png deleted file mode 100644 index 275d2722fa..0000000000 Binary files a/NPCs/NormalNPCs/KingSlimeJewelSapphire.png and /dev/null differ diff --git a/NPCs/NormalNPCs/LavaSlimeNoLavaDrop.cs b/NPCs/NormalNPCs/LavaSlimeNoLavaDrop.cs deleted file mode 100644 index 38cd0a6c25..0000000000 --- a/NPCs/NormalNPCs/LavaSlimeNoLavaDrop.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - public class LavaSlimeNoLavaDrop : ModNPC - { - public override string Texture => $"Terraria/Images/NPC_{NPCID.LavaSlime}"; - - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 2; - this.HideFromBestiary(); - } - - public override void SetDefaults() - { - NPC.aiStyle = NPCAIStyleID.Slime; - AIType = NPCID.LavaSlime; - AnimationType = NPCID.LavaSlime; - NPC.width = 24; - NPC.height = 18; - NPC.damage = 15; - NPC.defense = 10; - NPC.lifeMax = 50; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.scale = 1.1f; - NPC.alpha = 50; - NPC.lavaImmune = true; - NPC.value = 120f; - if (Main.remixWorld) - { - NPC.damage = 7; - NPC.defense = 2; - NPC.lifeMax = 25; - NPC.value = 25f; - } - //Banner = NPCID.LavaSlime; - //BannerItem = ItemID.LavaSlimeBanner; - - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToSickness = false; - NPC.Calamity().VulnerableToHeat = false; - NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life > 0) - { - for (int i = 0; (double)i < hit.Damage / (double)NPC.lifeMax * 80D; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 6, hit.HitDirection * 2, -1f, NPC.alpha, default, 1.5f); - if (Main.rand.Next(8) != 0) - Main.dust[dust].noGravity = true; - } - - return; - } - - for (int i = 0; i < 40; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 6, hit.HitDirection * 2, -1f, NPC.alpha, default, 1.5f); - if (Main.rand.Next(8) != 0) - Main.dust[dust].noGravity = true; - } - } - } -} diff --git a/NPCs/NormalNPCs/MantisShrimp.cs b/NPCs/NormalNPCs/MantisShrimp.cs index 5dd4b71209..5a5b41e7b8 100644 --- a/NPCs/NormalNPCs/MantisShrimp.cs +++ b/NPCs/NormalNPCs/MantisShrimp.cs @@ -4,6 +4,7 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; @@ -28,11 +29,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 40; NPC.height = 24; NPC.defense = 10; - NPC.DR_NERD(0.1f); - NPC.lifeMax = 50; + NPC.lifeMax = 60; NPC.aiStyle = NPCAIStyleID.Fighter; AIType = NPCID.Crab; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Banner = NPC.type; @@ -41,10 +41,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -104,6 +100,10 @@ namespace CalamityMod.NPCs.NormalNPCs { if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), target.Center, Vector2.Zero, ProjectileID.SolarWhipSwordExplosion, 0, 0f, Main.myPlayer); + + // Ouch, don't get hit twice in a row :) + if (hurtInfo.Damage > 0) + target.AddBuff(BuffID.BrokenArmor, 600, true); } public override void FindFrame(int frameHeight) @@ -125,6 +125,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.AddIf(() => NPC.downedPlantBoss, ModContent.ItemType(), 5); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.ArmorPolish, 100, 50)); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/OverloadedSoldier.cs b/NPCs/NormalNPCs/OverloadedSoldier.cs index 737a0269d0..1d219e290d 100644 --- a/NPCs/NormalNPCs/OverloadedSoldier.cs +++ b/NPCs/NormalNPCs/OverloadedSoldier.cs @@ -29,20 +29,15 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 18; NPC.height = 40; NPC.defense = 18; - NPC.DR_NERD(0.15f); - NPC.lifeMax = NPC.downedMoonlord ? 1700 : 170; + NPC.lifeMax = NPC.downedMoonlord ? 3000 : 300; NPC.knockBackResist = 0.3f; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.HitSound = SoundID.NPCHit2; NPC.DeathSound = SoundID.NPCDeath2; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -269,7 +264,7 @@ namespace CalamityMod.NPCs.NormalNPCs { int doorCheckX = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); int doorCheckY = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); - if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10 || Main.tile[doorCheckX, doorCheckY - 1].TileType == 388)) & unusedFlag) + if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.ClosedDoor || Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.TallGateClosed)) & unusedFlag) { NPC.ai[2] += 1f; NPC.ai[3] = 0f; @@ -277,7 +272,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.velocity.X = 0.5f * (float)-(float)NPC.direction; int doorOpenInc = 5; - if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.TallGateClosed) { doorOpenInc = 2; } @@ -292,7 +287,7 @@ namespace CalamityMod.NPCs.NormalNPCs WorldGen.KillTile(doorCheckX, doorCheckY - 1, true, false, false); if ((Main.netMode != NetmodeID.MultiplayerClient || !letMeIn) && letMeIn && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.ClosedDoor) { bool canOpenDoor = WorldGen.OpenDoor(doorCheckX, doorCheckY - 1, NPC.direction); if (!canOpenDoor) @@ -305,7 +300,7 @@ namespace CalamityMod.NPCs.NormalNPCs NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)doorCheckX, (float)(doorCheckY - 1), (float)NPC.direction, 0, 0, 0); } } - if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == TileID.TallGateClosed) { bool canOpenTallGate = WorldGen.ShiftTallGate(doorCheckX, doorCheckY - 1, false); if (!canOpenTallGate) @@ -387,7 +382,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/PerennialSlime.cs b/NPCs/NormalNPCs/PerennialSlime.cs index eb62be6480..623c3f6f76 100644 --- a/NPCs/NormalNPCs/PerennialSlime.cs +++ b/NPCs/NormalNPCs/PerennialSlime.cs @@ -22,11 +22,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 35; NPC.width = 40; NPC.height = 30; - NPC.defense = 12; - NPC.lifeMax = 225; + NPC.defense = 20; + NPC.lifeMax = 360; NPC.knockBackResist = 0.5f; AnimationType = NPCID.CorruptSlime; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.alpha = 50; NPC.lavaImmune = false; NPC.noGravity = false; @@ -37,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/PhantomSpirit.cs b/NPCs/NormalNPCs/PhantomSpirit.cs index 1f94654c10..1d05b99e30 100644 --- a/NPCs/NormalNPCs/PhantomSpirit.cs +++ b/NPCs/NormalNPCs/PhantomSpirit.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -23,12 +22,12 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 70; NPC.width = 16; NPC.height = 16; - NPC.defense = 10; - NPC.lifeMax = 1250; + NPC.defense = 40; + NPC.lifeMax = 1500; NPC.knockBackResist = 0.2f; AnimationType = NPCID.DungeonSpirit; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 20, 0); + NPC.value = Item.buyPrice(silver: 20); NPC.HitSound = SoundID.NPCHit36; NPC.DeathSound = SoundID.NPCDeath39; NPC.noGravity = true; @@ -36,10 +35,6 @@ namespace CalamityMod.NPCs.NormalNPCs Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/PhantomSpiritL.cs b/NPCs/NormalNPCs/PhantomSpiritL.cs index 2f7849b747..f533643661 100644 --- a/NPCs/NormalNPCs/PhantomSpiritL.cs +++ b/NPCs/NormalNPCs/PhantomSpiritL.cs @@ -3,7 +3,6 @@ using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -23,18 +22,20 @@ namespace CalamityMod.NPCs.NormalNPCs Main.npcFrameCount[Type] = 5; } + public static int ShotDamage = 60; // 240 + public override void SetDefaults() { + NPC.damage = 100; // 200 NPC.aiStyle = -1; - NPC.damage = 100; NPC.width = 32; NPC.height = 80; NPC.scale *= 1.2f; - NPC.defense = 30; - NPC.lifeMax = 3750; + NPC.defense = 60; + NPC.lifeMax = 3500; NPC.knockBackResist = 0.1f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 60, 0); + NPC.value = Item.buyPrice(silver: 60); NPC.HitSound = SoundID.NPCHit36; NPC.DeathSound = SoundID.NPCDeath39; NPC.noGravity = true; @@ -42,10 +43,6 @@ namespace CalamityMod.NPCs.NormalNPCs Banner = ModContent.NPCType(); BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -88,11 +85,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.ai[2] = 0f; float projSpeed = 10f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); targetDistance = projSpeed / targetDistance; targetXDist *= targetDistance; targetYDist *= targetDistance; - Projectile.NewProjectile(NPC.GetSource_FromAI(), spiritPosition.X, spiritPosition.Y, targetXDist, targetYDist, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spiritPosition.X, spiritPosition.Y, targetXDist, targetYDist, type, ShotDamage, 0f, Main.myPlayer, 0f, 0f); } } diff --git a/NPCs/NormalNPCs/PhantomSpiritM.cs b/NPCs/NormalNPCs/PhantomSpiritM.cs index 5d35236eba..e36da27bba 100644 --- a/NPCs/NormalNPCs/PhantomSpiritM.cs +++ b/NPCs/NormalNPCs/PhantomSpiritM.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -26,11 +25,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 32; NPC.height = 80; NPC.scale *= 1.1f; - NPC.defense = 25; + NPC.defense = 50; NPC.lifeMax = 2500; NPC.knockBackResist = 0.15f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 40, 0); + NPC.value = Item.buyPrice(silver: 40); NPC.HitSound = SoundID.NPCHit36; NPC.DeathSound = SoundID.NPCDeath39; NPC.noGravity = true; @@ -38,10 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs Banner = ModContent.NPCType(); BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/PhantomSpiritS.cs b/NPCs/NormalNPCs/PhantomSpiritS.cs index 9608b72321..75b6ca3667 100644 --- a/NPCs/NormalNPCs/PhantomSpiritS.cs +++ b/NPCs/NormalNPCs/PhantomSpiritS.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -25,11 +24,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = 80; NPC.width = 32; NPC.height = 80; - NPC.defense = 20; - NPC.lifeMax = 1875; + NPC.defense = 45; + NPC.lifeMax = 2000; NPC.knockBackResist = 0.2f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 30, 0); + NPC.value = Item.buyPrice(silver: 30); NPC.HitSound = SoundID.NPCHit36; NPC.DeathSound = SoundID.NPCDeath39; NPC.noGravity = true; @@ -37,10 +36,6 @@ namespace CalamityMod.NPCs.NormalNPCs Banner = ModContent.NPCType(); BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index 4b2106e519..9782a5d91d 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -34,7 +34,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.aiStyle = NPCAIStyleID.Passive; AIType = NPCID.Squirrel; NPC.knockBackResist = 0.99f; - NPC.value = Item.buyPrice(0, 2, 0, 0); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Banner = NPC.type; diff --git a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs index 1feaea149e..c4fa0d8395 100644 --- a/NPCs/NormalNPCs/PlanterasFreeTentacle.cs +++ b/NPCs/NormalNPCs/PlanterasFreeTentacle.cs @@ -1,17 +1,10 @@ using System; -using System.IO; -using CalamityMod.DataStructures; using CalamityMod.Events; -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Placeables.Ores; -using CalamityMod.NPCs.TownNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.NormalNPCs { @@ -28,11 +21,9 @@ namespace CalamityMod.NPCs.NormalNPCs public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 60; NPC.aiStyle = -1; AIType = -1; - NPC.GetNPCDamage(); - NPC.DR_NERD(0.1f); NPC.width = 24; NPC.height = 24; NPC.defense = 20; @@ -45,10 +36,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void FindFrame(int frameHeight) @@ -190,13 +177,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * balance); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Poisoned, 120); + NPC.damage = (int)(NPC.damage * 1.15f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/ProfanedEnergyBody.cs b/NPCs/NormalNPCs/ProfanedEnergyBody.cs index 31fd92aaa5..2942860f46 100644 --- a/NPCs/NormalNPCs/ProfanedEnergyBody.cs +++ b/NPCs/NormalNPCs/ProfanedEnergyBody.cs @@ -31,11 +31,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 72; NPC.height = 36; NPC.defense = 50; - NPC.DR_NERD(0.1f); NPC.lifeMax = 2500; NPC.knockBackResist = 0f; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 50, 0); + NPC.value = Item.buyPrice(silver: 50); NPC.lavaImmune = true; NPC.noGravity = true; NPC.HitSound = SoundID.NPCHit52; @@ -46,10 +45,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/Rimehound.cs b/NPCs/NormalNPCs/Rimehound.cs index 4fb5748983..b3e68cefb3 100644 --- a/NPCs/NormalNPCs/Rimehound.cs +++ b/NPCs/NormalNPCs/Rimehound.cs @@ -1,7 +1,6 @@ using System.IO; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; using CalamityMod.World; using Terraria; using Terraria.Audio; @@ -38,17 +37,17 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 56; NPC.height = 56; NPC.defense = 4; - NPC.lifeMax = 65; + NPC.lifeMax = 80; if (DownedBossSystem.downedCryogen) { NPC.damage = 60; NPC.defense = 10; - NPC.lifeMax = 1250; + NPC.lifeMax = 600; } NPC.knockBackResist = 0.3f; AnimationType = NPCID.Hellhound; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.HitSound = HitSound; NPC.DeathSound = SoundID.NPCDeath5; Banner = NPC.type; @@ -57,10 +56,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/NormalNPCs/Rotdog.cs b/NPCs/NormalNPCs/Rotdog.cs index c27214493c..fb733e8c7c 100644 --- a/NPCs/NormalNPCs/Rotdog.cs +++ b/NPCs/NormalNPCs/Rotdog.cs @@ -3,9 +3,11 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.GameContent.Bestiary; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; + namespace CalamityMod.NPCs.NormalNPCs { public class Rotdog : ModNPC @@ -25,7 +27,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 75; NPC.knockBackResist = 0.3f; AIType = NPCID.Wolf; - NPC.value = Item.buyPrice(0, 0, 1, 50); + NPC.value = Item.buyPrice(silver: 1, copper: 50); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath5; Banner = NPC.type; @@ -33,10 +35,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -136,7 +134,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.AdhesiveBandage, 50); + npcLoot.Add(ItemDropRule.NormalvsExpert(ItemID.AdhesiveBandage, 100, 50)); npcLoot.Add(ModContent.ItemType(), 8); } } diff --git a/NPCs/NormalNPCs/ScornEater.cs b/NPCs/NormalNPCs/ScornEater.cs index 595c902888..2891aa5e74 100644 --- a/NPCs/NormalNPCs/ScornEater.cs +++ b/NPCs/NormalNPCs/ScornEater.cs @@ -40,12 +40,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 160; NPC.height = 160; NPC.defense = 38; - NPC.DR_NERD(0.05f); NPC.lifeMax = 9000; - NPC.knockBackResist = 0.1f; + NPC.knockBackResist = 0f; AIType = -1; NPC.lavaImmune = true; - NPC.value = Item.buyPrice(0, 0, 75, 0); + NPC.value = Item.buyPrice(silver: 75); NPC.DeathSound = DeathSound; Banner = NPC.type; BannerItem = ModContent.ItemType(); @@ -53,10 +52,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -79,8 +74,6 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Y == 0f) { - NPC.knockBackResist = 0f; - // Avoid cheap bullshit NPC.damage = 0; @@ -141,8 +134,6 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - NPC.knockBackResist = 0.1f; - if (NPC.direction == 1 && NPC.velocity.X < 1f) { NPC.velocity.X += 0.1f; @@ -203,7 +194,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/ShockstormShuttle.cs b/NPCs/NormalNPCs/ShockstormShuttle.cs index c41c3b21dc..21d488ed85 100644 --- a/NPCs/NormalNPCs/ShockstormShuttle.cs +++ b/NPCs/NormalNPCs/ShockstormShuttle.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; @@ -28,12 +27,11 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 64; NPC.height = 38; NPC.defense = 15; - NPC.DR_NERD(0.15f); - NPC.lifeMax = 190; + NPC.lifeMax = 250; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0.5f; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath14; NPC.noGravity = true; @@ -42,10 +40,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -89,8 +83,8 @@ namespace CalamityMod.NPCs.NormalNPCs npcPos.X += velocity.X; npcPos.Y += velocity.Y; - int spread = Main.getGoodWorld ? 100 : 20; - for (int i = 0; i < (Main.getGoodWorld ? 10 : 2); i++) + int spread = 20; + for (int i = 0; i < 2; i++) { velocity = Main.player[NPC.target].Center - npcPos; targetDist = velocity.Length(); @@ -408,7 +402,7 @@ namespace CalamityMod.NPCs.NormalNPCs { return 0f; } - return SpawnCondition.Sky.Chance * (Main.getGoodWorld ? 0.5f : 0.1f); + return SpawnCondition.Sky.Chance * 0.1f; } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/NormalNPCs/Shroomble.cs b/NPCs/NormalNPCs/Shroomble.cs index 4e9f5de5f8..2b1abdee1b 100644 --- a/NPCs/NormalNPCs/Shroomble.cs +++ b/NPCs/NormalNPCs/Shroomble.cs @@ -1,5 +1,4 @@ using System; -using System.Numerics; using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Projectiles.Summon; @@ -39,6 +38,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.knockBackResist = 0.5f; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; + DrawOffsetY = -2; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.catchItem = (short)ModContent.ItemType(); @@ -105,7 +105,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneSulphur || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (!spawnInfo.Player.ZonePurity) { return 0f; } @@ -153,7 +153,7 @@ namespace CalamityMod.NPCs.NormalNPCs } } - public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Mushroom, 1, 1, 4); + public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Mushroom); public override void HitEffect(NPC.HitInfo hit) { @@ -165,7 +165,7 @@ namespace CalamityMod.NPCs.NormalNPCs { for (int k = 0; k < 15; k++) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Pixie, hit.HitDirection * 0.5f, -0.5f, 0, default, 0.5f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Pixie, hit.HitDirection * 0.5f, -0.5f, 0, default, 0.5f); } if (!Main.dedServ) { diff --git a/NPCs/NormalNPCs/SkeletronPrime2.cs b/NPCs/NormalNPCs/SkeletronPrime2.cs deleted file mode 100644 index dcbd25f0ae..0000000000 --- a/NPCs/NormalNPCs/SkeletronPrime2.cs +++ /dev/null @@ -1,922 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.DataStructures; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.Chat; -using Terraria.GameContent.Achievements; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.NormalNPCs -{ - [AutoloadBossHead] - public class SkeletronPrime2 : ModNPC - { - public override string BossHeadTexture => $"Terraria/Images/NPC_Head_Boss_18"; - - public static Asset EyeTexture; - - public const int BombTimeLeft = 600; - - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 6; - NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); - if (!Main.dedServ) - { - EyeTexture = ModContent.Request("CalamityMod/ExtraTextures/SkeletronPrime2HeadGlow"); - } - } - - public override void SetDefaults() - { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.aiStyle = NPCAIStyleID.SkeletronPrimeHead; - NPC.GetNPCDamage(); - NPC.DR_NERD(0.2f); - - NPC.width = 80; - NPC.height = 102; - if (Main.tenthAnniversaryWorld) - NPC.scale *= 0.5f; - if (Main.getGoodWorld) - NPC.scale *= 1.1f; - - NPC.defense = 24; - NPC.lifeMax = 28000; - NPC.knockBackResist = 0f; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.boss = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.Calamity().VulnerableToElectricity = true; - NPC.Calamity().VulnerableToSickness = false; - AnimationType = NPCID.SkeletronPrime; - Music = MusicID.Boss3; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(NPC.localAI[0]); - writer.Write(NPC.localAI[1]); - writer.Write(NPC.localAI[2]); - writer.Write(NPC.localAI[3]); - for (int i = 0; i < 4; i++) - writer.Write(NPC.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - NPC.localAI[0] = reader.ReadSingle(); - NPC.localAI[1] = reader.ReadSingle(); - NPC.localAI[2] = reader.ReadSingle(); - NPC.localAI[3] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - NPC.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void BossHeadRotation(ref float rotation) - { - rotation = (NPC.ai[1] == 1f || NPC.ai[1] == 2f) ? NPC.rotation : 0f; - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - - // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; - - // Spawn arms - if (calamityGlobalNPC.newAI[1] == 0f) - { - calamityGlobalNPC.newAI[1] = 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // This head owns the Cannon and the Vice in Master Mode - int arm = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PrimeCannon, NPC.whoAmI); - Main.npc[arm].ai[0] = -1f; - Main.npc[arm].ai[1] = NPC.whoAmI; - Main.npc[arm].target = NPC.target; - Main.npc[arm].netUpdate = true; - - arm = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PrimeVice, NPC.whoAmI); - Main.npc[arm].ai[0] = -1f; - Main.npc[arm].ai[1] = NPC.whoAmI; - Main.npc[arm].target = NPC.target; - Main.npc[arm].ai[3] = 150f; - Main.npc[arm].netUpdate = true; - } - - NPC.SyncExtraAI(); - } - - if (!Main.npc[(int)NPC.ai[0]].active || Main.npc[(int)NPC.ai[0]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - NPC.life = 0; - NPC.HitEffect(); - NPC.active = false; - NPC.netUpdate = true; - } - else - { - // Set direction to the other head's direction - NPC.direction = Main.npc[(int)NPC.ai[0]].direction; - - // 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; - - // Push away from the lead head if too close, pull closer if too far, if Mechdusa isn't real - if (!NPC.IsMechQueenUp) - { - float pushVelocity = 0.25f; - if (Vector2.Distance(NPC.Center, Main.npc[(int)NPC.ai[0]].Center) < 80f * NPC.scale) - { - if (NPC.position.X < Main.npc[(int)NPC.ai[0]].position.X) - NPC.velocity.X -= pushVelocity; - else - NPC.velocity.X += pushVelocity; - - if (NPC.position.Y < Main.npc[(int)NPC.ai[0]].position.Y) - NPC.velocity.Y -= pushVelocity; - else - NPC.velocity.Y += pushVelocity; - } - else if (Vector2.Distance(NPC.Center, Main.npc[(int)NPC.ai[0]].Center) > 240f * NPC.scale) - { - if (NPC.position.X < Main.npc[(int)NPC.ai[0]].position.X) - NPC.velocity.X += pushVelocity; - else - NPC.velocity.X -= pushVelocity; - - if (NPC.position.Y < Main.npc[(int)NPC.ai[0]].position.Y) - NPC.velocity.Y += pushVelocity; - else - NPC.velocity.Y -= pushVelocity; - } - } - } - - // Check if arms are alive - bool cannonAlive = false; - bool laserAlive = false; - bool viceAlive = false; - bool sawAlive = false; - if (CalamityGlobalNPC.primeCannon != -1) - { - if (Main.npc[CalamityGlobalNPC.primeCannon].active) - cannonAlive = true; - } - if (CalamityGlobalNPC.primeLaser != -1) - { - if (Main.npc[CalamityGlobalNPC.primeLaser].active) - laserAlive = true; - } - if (CalamityGlobalNPC.primeVice != -1) - { - if (Main.npc[CalamityGlobalNPC.primeVice].active) - viceAlive = true; - } - if (CalamityGlobalNPC.primeSaw != -1) - { - if (Main.npc[CalamityGlobalNPC.primeSaw].active) - sawAlive = true; - } - bool allArmsDead = !cannonAlive && !laserAlive && !viceAlive && !sawAlive; - NPC.chaseable = allArmsDead; - - NPC.defense = NPC.defDefense; - - // Phases - bool phase2 = lifeRatio < 0.66f; - bool phase3 = lifeRatio < 0.33f; - bool spawnSpazmatism = lifeRatio < 0.5f && !bossRush && NPC.localAI[2] == 0f; - - // Spawn Spazmatism in Master Mode (just like Oblivion from Avalon) - if (spawnSpazmatism) - { - Player spazmatismSpawnPlayer = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)]; - SoundEngine.PlaySound(SoundID.Roar, spazmatismSpawnPlayer.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int spazmatism = NPC.NewNPC(NPC.GetBossSpawnSource(spazmatismSpawnPlayer.whoAmI), (int)spazmatismSpawnPlayer.Center.X, (int)spazmatismSpawnPlayer.Center.Y - 810, NPCID.Retinazer, 1); - if (spazmatism != Main.maxNPCs) - { - Main.npc[spazmatism].target = spazmatismSpawnPlayer.whoAmI; - Main.npc[spazmatism].timeLeft *= 20; - Main.npc[spazmatism].localAI[3] = 1f; - Main.npc[spazmatism].SyncVanillaLocalAI(); - string typeName = Main.npc[spazmatism].TypeName; - if (Main.dedServ && spazmatism < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, spazmatism); - - AchievementsHelper.CheckMechaMayhem(); - } - } - - NPC.localAI[2] = 1f; - NPC.SyncVanillaLocalAI(); - } - - // Despawn - 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) - { - // Heal - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int healAmt = NPC.life - 300; - if (healAmt < 0) - { - int absHeal = Math.Abs(healAmt); - NPC.life += absHeal; - NPC.HealEffect(absHeal, true); - NPC.netUpdate = true; - } - } - - NPC.ai[1] = 2f; - SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); - } - - // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = NPC.ai[1] == 5f; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - - bool normalLaserRotation = NPC.localAI[1] % 2f == 0f; - - // Prevents cheap hits - 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) - { - // Avoid unfair bullshit - NPC.damage = 0; - - // Start other phases; if arms are dead, start with spin phase - bool otherHeadChargingOrSpinning = Main.npc[(int)NPC.ai[0]].ai[1] == 5f || Main.npc[(int)NPC.ai[0]].ai[1] == 1f; - - // Start spin phase after 1.875 seconds - 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[Main.npc[(int)NPC.ai[0]].target].position.Y - 320f && - 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; - - bool shouldCharge = !phase2 && !allArmsDead && !CalamityWorld.LegendaryMode; - if (shouldCharge) - { - NPC.ai[2] = 0f; - NPC.ai[1] = 1f; - NPC.netUpdate = true; - } - else if (shouldSpinAround || NPC.ai[1] != 4f) - { - if (shouldSpinAround) - { - NPC.localAI[3] = 300f; - NPC.SyncVanillaLocalAI(); - } - - NPC.ai[2] = 0f; - NPC.ai[1] = shouldSpinAround ? 5f : 1f; - NPC.netUpdate = true; - } - } - - if (NPC.IsMechQueenUp) - NPC.rotation = NPC.rotation.AngleLerp(NPC.velocity.X / 15f * 0.5f, 0.75f); - else - NPC.rotation = NPC.velocity.X / 15f; - - float acceleration = (bossRush ? 0.16f : 0.12f) + (death ? 0.05f * (1f - lifeRatio) : 0f); - float accelerationMult = 1f; - if (!cannonAlive) - { - acceleration += 0.0125f; - accelerationMult += 0.25f; - } - if (!laserAlive) - { - acceleration += 0.0125f; - accelerationMult += 0.25f; - } - if (!viceAlive) - acceleration += 0.0125f; - if (!sawAlive) - acceleration += 0.0125f; - acceleration *= accelerationMult; - - float topVelocity = acceleration * 100f; - float deceleration = 0.7f; - - float headDecelerationUpDist = 0f; - float headDecelerationDownDist = 0f; - float headDecelerationHorizontalDist = 0f; - 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; - headDecelerationUpDist = 50f; - headDecelerationDownDist = 50f; - } - - if (NPC.position.Y > Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - (320f + headDecelerationUpDist)) - { - if (NPC.velocity.Y > 0f) - NPC.velocity.Y *= deceleration; - - NPC.velocity.Y -= acceleration; - - if (NPC.velocity.Y > topVelocity) - NPC.velocity.Y = topVelocity; - } - else if (NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - (360f + headDecelerationDownDist)) - { - if (NPC.velocity.Y < 0f) - NPC.velocity.Y *= deceleration; - - NPC.velocity.Y += acceleration; - - if (NPC.velocity.Y < -topVelocity) - NPC.velocity.Y = -topVelocity; - } - - 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; - - NPC.velocity.X -= acceleration; - - if (NPC.velocity.X > topVelocity) - NPC.velocity.X = topVelocity; - } - 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; - - NPC.velocity.X += acceleration; - - if (NPC.velocity.X < -topVelocity) - NPC.velocity.X = -topVelocity; - } - } - - else - { - // Spinning - if (NPC.ai[1] == 1f) - { - NPC.defense *= 2; - NPC.damage = NPC.defDamage * 2; - - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = true; - - if (phase2 && Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= 60f) - { - NPC.localAI[0] = 0f; - - int totalProjectiles = bossRush ? 20 : death ? 12 : 10; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ProjectileID.FrostBeam; - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - float velocity = 4.5f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 laserFireDirection = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserFireDirection.SafeNormalize(Vector2.UnitY) * 140f, laserFireDirection, type, damage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 600; - } - NPC.localAI[1] += 1f; - } - } - - NPC.ai[2] += 1f; - if (NPC.ai[2] == 2f) - SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); - - // Spin for 3 seconds then return to floating phase - float phaseTimer = 240f; - if (phase2 && !phase3) - phaseTimer += 60f; - - if (NPC.ai[2] >= (phaseTimer - (death ? 60f * (1f - lifeRatio) : 0f))) - { - NPC.ai[2] = 0f; - NPC.ai[1] = 4f; - NPC.localAI[0] = 0f; - } - - if (NPC.IsMechQueenUp) - NPC.rotation = NPC.rotation.AngleLerp(NPC.velocity.X / 15f * 0.5f, 0.75f); - else - NPC.rotation += NPC.direction * 0.3f; - - Vector2 headPosition = NPC.Center; - 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; - if (phase2) - speed += 0.5f; - if (phase3) - speed += 0.5f; - - if (headTargetDistance > 150f) - { - float baseDistanceVelocityMult = 1f + MathHelper.Clamp((headTargetDistance - 150f) * 0.0015f, 0.05f, 1.5f); - speed *= baseDistanceVelocityMult; - } - - if (NPC.IsMechQueenUp) - { - float mechdusaSpeedMult = (NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody] ? 0.6f : 0.75f); - speed *= mechdusaSpeedMult; - } - - headTargetDistance = speed / headTargetDistance; - NPC.velocity.X = headTargetX * headTargetDistance; - NPC.velocity.Y = headTargetY * headTargetDistance; - - if (NPC.IsMechQueenUp) - { - float mechdusaAccelMult = Vector2.Distance(NPC.Center, Main.player[Main.npc[(int)NPC.ai[0]].target].Center); - if (mechdusaAccelMult < 0.1f) - mechdusaAccelMult = 0f; - - if (mechdusaAccelMult < speed) - NPC.velocity = NPC.velocity.SafeNormalize(Vector2.Zero) * mechdusaAccelMult; - } - } - - // Daytime enrage - if (NPC.ai[1] == 2f) - { - NPC.damage = 1000; - calamityGlobalNPC.DR = 0.9999f; - calamityGlobalNPC.unbreakableDR = true; - - calamityGlobalNPC.CurrentlyEnraged = true; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = true; - - if (NPC.IsMechQueenUp) - NPC.rotation = NPC.rotation.AngleLerp(NPC.velocity.X / 15f * 0.5f, 0.75f); - else - NPC.rotation += NPC.direction * 0.3f; - - Vector2 enragedHeadPosition = NPC.Center; - 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; - enragedHeadSpeed += enragedHeadTargetDist / 100f; - if (enragedHeadSpeed < 8f) - enragedHeadSpeed = 8f; - if (enragedHeadSpeed > 32f) - enragedHeadSpeed = 32f; - - enragedHeadTargetDist = enragedHeadSpeed / enragedHeadTargetDist; - NPC.velocity.X = enragedHeadTargetX * enragedHeadTargetDist; - NPC.velocity.Y = enragedHeadTargetY * enragedHeadTargetDist; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] += 1f; - if (NPC.localAI[0] >= 60f) - { - NPC.localAI[0] = 0f; - Vector2 headCenter = NPC.Center; - 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[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; - enragedHeadSkullTargetY *= enragedHeadSkullTargetDist; - - Vector2 value = new Vector2(enragedHeadSkullTargetX * 1f + Main.rand.Next(-50, 51) * 0.01f, enragedHeadSkullTargetY * 1f + Main.rand.Next(-50, 51) * 0.01f).SafeNormalize(Vector2.UnitY); - value *= enragedHeadSpeed; - value += NPC.velocity; - enragedHeadSkullTargetX = value.X; - enragedHeadSkullTargetY = value.Y; - - int type = ProjectileID.Skull; - headCenter += value * 5f; - int enragedSkulls = Projectile.NewProjectile(NPC.GetSource_FromAI(), headCenter.X, headCenter.Y, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, 250, 0f, Main.myPlayer, -1f, 0f); - Main.projectile[enragedSkulls].timeLeft = 300; - } - } - } - } - - // Despawning - if (NPC.ai[1] == 3f) - { - // Avoid unfair bullshit - NPC.damage = 0; - - if (NPC.IsMechQueenUp) - { - int mechdusaBossDespawning = NPC.FindFirstNPC(NPCID.Retinazer); - if (mechdusaBossDespawning >= 0) - Main.npc[mechdusaBossDespawning].EncourageDespawn(5); - - mechdusaBossDespawning = NPC.FindFirstNPC(NPCID.Spazmatism); - if (mechdusaBossDespawning >= 0) - Main.npc[mechdusaBossDespawning].EncourageDespawn(5); - - if (!NPC.AnyNPCs(NPCID.Retinazer) && !NPC.AnyNPCs(NPCID.Spazmatism)) - { - mechdusaBossDespawning = NPC.FindFirstNPC(NPCID.TheDestroyer); - if (mechdusaBossDespawning >= 0) - Main.npc[mechdusaBossDespawning].Transform(NPCID.TheDestroyerTail); - - NPC.EncourageDespawn(5); - } - - NPC.velocity.Y += 0.1f; - if (NPC.velocity.Y < 0f) - NPC.velocity.Y *= 0.95f; - - NPC.velocity.X *= 0.95f; - if (NPC.velocity.Y > 13f) - NPC.velocity.Y = 13f; - } - else - { - NPC.velocity.Y += 0.1f; - if (NPC.velocity.Y < 0f) - NPC.velocity.Y *= 0.9f; - - NPC.velocity.X *= 0.9f; - - if (NPC.timeLeft > 500) - NPC.timeLeft = 500; - } - } - - // Fly around in a circle - if (NPC.ai[1] == 5f) - { - // Avoid unfair bullshit - NPC.damage = 0; - - NPC.ai[2] += 1f; - - NPC.rotation = NPC.velocity.X / 50f; - - float bombSpawnDivisor = bossRush ? 14f : death ? 22f - (float)Math.Round(5f * (1f - lifeRatio)) : 22f; - float totalBombs = 6f; - int bombSpread = bossRush ? 250 : death ? 125 : 100; - - // Spin for about 3 seconds - float spinVelocity = 24f; - if (NPC.ai[2] == 2f) - { - // Play angry noise - SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); - - // Set spin direction - if (Main.player[Main.npc[(int)NPC.ai[0]].target].velocity.X > 0f) - calamityGlobalNPC.newAI[0] = 1f; - else if (Main.player[Main.npc[(int)NPC.ai[0]].target].velocity.X < 0f) - calamityGlobalNPC.newAI[0] = -1f; - else - 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; - NPC.velocity *= -calamityGlobalNPC.newAI[0]; - NPC.SyncExtraAI(); - NPC.netUpdate = true; - } - - // Maintain velocity and spit homing bombs - else if (NPC.ai[2] > 2f) - { - NPC.velocity = NPC.velocity.RotatedBy(MathHelper.Pi / spinVelocity * -calamityGlobalNPC.newAI[0]); - if (NPC.ai[2] == 3f) - NPC.velocity *= 0.6f; - - if (NPC.ai[2] % bombSpawnDivisor == 0f) - { - NPC.localAI[0] += 1f; - - 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)); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 headCenter = NPC.Center; - float enragedHeadSpeed = 6f + (death ? 2f * (1f - lifeRatio) : 0f); - 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; - enragedHeadBombTargetY *= enragedHeadBombTargetDist; - - Vector2 value = new Vector2(enragedHeadBombTargetX + Main.rand.Next(-bombSpread, bombSpread + 1) * 0.01f, enragedHeadBombTargetY + Main.rand.Next(-bombSpread, bombSpread + 1) * 0.01f).SafeNormalize(Vector2.UnitY); - value *= enragedHeadSpeed; - enragedHeadBombTargetX = value.X; - enragedHeadBombTargetY = value.Y; - - int type = ProjectileID.BombSkeletronPrime; - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - int enragedBombs = Projectile.NewProjectile(NPC.GetSource_FromAI(), headCenter.X, headCenter.Y + 30f, enragedHeadBombTargetX, enragedHeadBombTargetY, type, damage, 0f, Main.myPlayer, -1f); - Main.projectile[enragedBombs].timeLeft = BombTimeLeft; - Main.projectile[enragedBombs].tileCollide = false; - } - } - - // Go to floating phase, or spinning phase if in phase 2 - if (NPC.localAI[0] >= totalBombs) - { - NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY); - - // Fly overhead and spit spreads of bombs into the air if on low health - NPC.ai[1] = phase3 ? 6f : 1f; - NPC.ai[2] = 0f; - NPC.localAI[3] = 0f; - NPC.localAI[0] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - NPC.SyncVanillaLocalAI(); - NPC.SyncExtraAI(); - NPC.netUpdate = true; - } - } - } - } - - // Fly overhead and spit bombs - if (NPC.ai[1] == 6f) - { - // Avoid unfair bullshit - NPC.damage = 0; - - NPC.rotation = NPC.velocity.X / 15f; - - float flightVelocity = bossRush ? 28f : death ? 25f : 22f; - float flightAcceleration = bossRush ? 1.16f : death ? 0.96f : 0.76f; - - 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 - 420f); - NPC.SimpleFlyMovement((destination - NPC.Center).SafeNormalize(Vector2.UnitY) * flightVelocity, flightAcceleration); - - // Spit bombs and then go to floating phase - NPC.localAI[3] += 1f; - if (Vector2.Distance(NPC.Center, destination) < 160f || NPC.ai[2] > 0f || NPC.localAI[3] > 120f) - { - float bombSpawnDivisor = death ? 50f : 60f; - float totalBombSpreads = 2f; - NPC.ai[2] += 1f; - if (NPC.ai[2] % bombSpawnDivisor == 0f) - { - NPC.localAI[0] += 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalProjectiles = bossRush ? 24 : 12; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ProjectileID.BombSkeletronPrime; - int damage = NPC.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - float velocity = 12f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); - Vector2 upwardVelocity = Vector2.UnitY * velocity; - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 bombVelocity = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 30f + bombVelocity.SafeNormalize(Vector2.UnitY) * 15f, bombVelocity - upwardVelocity, type, damage, 0f, Main.myPlayer, -2f); - Main.projectile[proj].timeLeft = BombTimeLeft; - Main.projectile[proj].tileCollide = false; - } - NPC.localAI[1] += 1f; - } - - SoundEngine.PlaySound(SoundID.Item62, NPC.Center); - CreateParticles(NPC, new Vector2(NPC.Center.X, NPC.Center.Y + 4f), 5); - - if (NPC.localAI[0] >= totalBombSpreads) - { - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.localAI[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - NPC.localAI[0] = 0f; - NPC.SyncVanillaLocalAI(); - NPC.SyncExtraAI(); - NPC.netUpdate = true; - } - } - } - } - } - } - - private void CreateParticles(NPC npc, Vector2 position, int amountMultiplier = 1) - { - int firstDustCloudParticleAmount = 30 * amountMultiplier; - int secondDustCloudParticleAmount = 20 * amountMultiplier; - int goreAmount = 2 * amountMultiplier; - - for (int dustIndex = 0; dustIndex < firstDustCloudParticleAmount; dustIndex++) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[dust].velocity *= 1.4f; - } - - for (int dustIndex = 0; dustIndex < secondDustCloudParticleAmount; dustIndex++) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default(Color), 3.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 7f; - dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[dust].velocity *= 3f; - } - - for (int goreIndex = 0; goreIndex < goreAmount; goreIndex++) - { - float goreVelocityMultiplier = 0.4f; - if (goreIndex >= goreAmount / 2) - goreVelocityMultiplier = 0.8f; - - int gore = Gore.NewGore(npc.GetSource_FromAI(), npc.Center, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= goreVelocityMultiplier; - Main.gore[gore].velocity.X += 1f; - Main.gore[gore].velocity.Y += 1f; - gore = Gore.NewGore(npc.GetSource_FromAI(), npc.Center, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= goreVelocityMultiplier; - Main.gore[gore].velocity.X -= 1f; - Main.gore[gore].velocity.Y += 1f; - gore = Gore.NewGore(npc.GetSource_FromAI(), npc.Center, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= goreVelocityMultiplier; - Main.gore[gore].velocity.X += 1f; - Main.gore[gore].velocity.Y -= 1f; - gore = Gore.NewGore(npc.GetSource_FromAI(), npc.Center, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= goreVelocityMultiplier; - Main.gore[gore].velocity.X -= 1f; - Main.gore[gore].velocity.Y -= 1f; - } - } - - public override void BossLoot(ref string name, ref int potionType) => potionType = ItemID.GreaterHealingPotion; - - public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) - { - NPC.lifeMax = (int)(NPC.lifeMax * 0.75f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - - public override bool CheckActive() => false; - - public override bool CheckDead() - { - // Kill the lead head if he's still alive when this head dies - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC nPC = Main.npc[i]; - if (nPC.active && nPC.type == NPCID.SkeletronPrime && nPC.life > 0) - { - nPC.life = 0; - nPC.HitEffect(); - nPC.checkDead(); - nPC.active = false; - nPC.netUpdate = true; - } - } - - return true; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life <= 0) - { - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("SkeletronPrime2_1").Type, NPC.scale); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("SkeletronPrime2_2").Type, NPC.scale); - - int gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X += 1f; - Main.gore[gore].velocity.Y += 1f; - - gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X -= 1f; - Main.gore[gore].velocity.Y += 1f; - - gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X += 1f; - Main.gore[gore].velocity.Y -= 1f; - - gore = Gore.NewGore(NPC.GetSource_Death(), NPC.position, default(Vector2), Main.rand.Next(61, 64)); - Main.gore[gore].velocity *= 0.4f; - Main.gore[gore].velocity.X -= 1f; - Main.gore[gore].velocity.Y -= 1f; - } - - for (int i = 0; i < 10; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[dust].velocity *= 1.4f; - } - - for (int i = 0; i < 5; i++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 5f; - - dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[dust].velocity *= 3f; - } - } - } - } -} diff --git a/NPCs/NormalNPCs/SkeletronPrime2.png b/NPCs/NormalNPCs/SkeletronPrime2.png deleted file mode 100644 index c019c31308..0000000000 Binary files a/NPCs/NormalNPCs/SkeletronPrime2.png and /dev/null differ diff --git a/NPCs/NormalNPCs/SkeletronPrime2_Head_Boss.png b/NPCs/NormalNPCs/SkeletronPrime2_Head_Boss.png deleted file mode 100644 index 38362cb253..0000000000 Binary files a/NPCs/NormalNPCs/SkeletronPrime2_Head_Boss.png and /dev/null differ diff --git a/NPCs/NormalNPCs/Stormlion.cs b/NPCs/NormalNPCs/Stormlion.cs index 7a00d1fa3a..9616633e81 100644 --- a/NPCs/NormalNPCs/Stormlion.cs +++ b/NPCs/NormalNPCs/Stormlion.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 100; NPC.knockBackResist = 0.2f; AnimationType = NPCID.WalkingAntlion; - NPC.value = Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.HitSound = HitSound; NPC.DeathSound = DeathSound; Banner = NPC.type; @@ -39,10 +39,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -110,7 +106,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 120); } public override void ModifyNPCLoot(NPCLoot npcLoot) diff --git a/NPCs/NormalNPCs/Sunskater.cs b/NPCs/NormalNPCs/Sunskater.cs index f4776d4331..0147fce550 100644 --- a/NPCs/NormalNPCs/Sunskater.cs +++ b/NPCs/NormalNPCs/Sunskater.cs @@ -4,7 +4,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.NPCs.ExoMechs.Ares; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -34,10 +33,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 58; NPC.height = 22; NPC.defense = 4; - NPC.lifeMax = 125; + NPC.lifeMax = 160; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 3, 0); + NPC.value = Item.buyPrice(silver: 3); NPC.HitSound = SoundID.NPCHit50; NPC.DeathSound = Main.zenithWorld ? AresGaussNuke.NukeExplosionSound : DeathSound; NPC.knockBackResist = 0.7f; @@ -47,10 +46,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -261,7 +256,7 @@ namespace CalamityMod.NPCs.NormalNPCs target.AddBuff(ModContent.BuffType(), 90); } else - target.AddBuff(BuffID.OnFire, 150, true); + target.AddBuff(BuffID.OnFire, 180); } } @@ -282,8 +277,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.zenithWorld) { float screenShakePower = 16 * Utils.GetLerpValue(1300f, 0f, NPC.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; + Main.LocalPlayer.SetScreenshake(screenShakePower); } } } diff --git a/NPCs/NormalNPCs/SuperDummyNPC.cs b/NPCs/NormalNPCs/SuperDummyNPC.cs index f5a06984a4..36af233d6d 100644 --- a/NPCs/NormalNPCs/SuperDummyNPC.cs +++ b/NPCs/NormalNPCs/SuperDummyNPC.cs @@ -11,6 +11,7 @@ namespace CalamityMod.NPCs.NormalNPCs public class SuperDummyNPC : ModNPC { public int deathCounter = 0; + public RevengeanceAndDeathAI.MimicAI ZenithSeedMimicAI; public override void SetStaticDefaults() { @@ -28,10 +29,12 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lifeMax = 9999999; NPC.HitSound = null; NPC.DeathSound = SoundID.NPCDeath2; - NPC.value = 0f; NPC.knockBackResist = 0f; NPC.netAlways = true; NPC.aiStyle = NPCAIStyleID.FaceClosestPlayer; + + ZenithSeedMimicAI = new RevengeanceAndDeathAI.MimicAI(); + ZenithSeedMimicAI.NPC = NPC; } public override void SendExtraAI(BinaryWriter writer) @@ -53,7 +56,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (deathCounter >= 6000) { NPC.damage = NPC.lifeMax; - RevengeanceAndDeathAI.BuffedMimicAI(NPC, Mod); + ZenithSeedMimicAI.AI(Mod); return false; } } @@ -62,7 +65,8 @@ namespace CalamityMod.NPCs.NormalNPCs public override void UpdateLifeRegen(ref int damage) { - NPC.lifeRegen += 2000000; + if (NPC.lifeRegen >= 0) + NPC.lifeRegen += 2000000; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) => Main.zenithWorld; diff --git a/NPCs/NormalNPCs/WildBumblebirb.cs b/NPCs/NormalNPCs/WildBumblebirb.cs new file mode 100644 index 0000000000..0670a351ec --- /dev/null +++ b/NPCs/NormalNPCs/WildBumblebirb.cs @@ -0,0 +1,375 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.NormalNPCs +{ + public class WildBumblebirb : ModNPC + { + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 5; + NPCID.Sets.TrailingMode[Type] = 1; + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + { + Position = Vector2.UnitX * 36f + }; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + } + + public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly"; + + public override void SetDefaults() + { + NPC.npcSlots = 1f; + NPC.aiStyle = -1; + AIType = -1; + NPC.damage = 90; + NPC.width = 120; + NPC.height = 80; + NPC.defense = 20; + NPC.LifeMaxNERB(9375, 11250, 5000); // Old HP - 12000, 15000 + NPC.knockBackResist = 0.15f; + NPC.lavaImmune = true; + NPC.noTileCollide = true; + NPC.noGravity = true; + NPC.HitSound = SoundID.NPCHit51; + NPC.DeathSound = SoundID.NPCDeath46; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToSickness = true; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.WildBumblefuck") + }); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.PlayerSafe || !NPC.downedMoonlord || spawnInfo.Player.Calamity().ZoneSunkenSea || !spawnInfo.Player.ZoneJungle) + return 0f; + + // Keep this as a separate if check, because it's a loop and we don't want to be checking it constantly. + if (NPC.AnyNPCs(NPC.type)) + return 0f; + + return SpawnCondition.SurfaceJungle.Chance * 0.14f; + } + + public override void AI() + { + Player player = Main.player[NPC.target]; + + float rotationMult = 4f; + float rotationAmt = 0.04f; + + if (Vector2.Distance(player.Center, NPC.Center) > 5600f) + { + if (NPC.timeLeft > 5) + NPC.timeLeft = 5; + } + + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt * 1.25f) / 10f; + + if (NPC.ai[0] == 0f || NPC.ai[0] == 1f) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type) + { + Vector2 otherSwarmerDirection = Main.npc[i].Center - NPC.Center; + if (otherSwarmerDirection.Length() < (NPC.width + NPC.height)) + { + otherSwarmerDirection.Normalize(); + otherSwarmerDirection *= -0.1f; + NPC.velocity += otherSwarmerDirection; + NPC nPC6 = Main.npc[i]; + nPC6.velocity -= otherSwarmerDirection; + } + } + } + } + + if (NPC.target < 0 || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + NPC.TargetClosest(true); + Vector2 swarmerTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (Main.player[NPC.target].dead || swarmerTargetDist.Length() > 2800f) + NPC.ai[0] = -1f; + } + else + { + Vector2 swarmerCatchUpTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (NPC.ai[0] > 1f && swarmerCatchUpTargetDist.Length() > 3600f) + NPC.ai[0] = 1f; + } + + if (NPC.ai[0] == -1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + Vector2 swarmerDespawnVelMult = new Vector2(0f, -8f); + NPC.velocity = (NPC.velocity * 21f + swarmerDespawnVelMult) / 10f; + return; + } + + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.TargetClosest(true); + NPC.spriteDirection = NPC.direction; + + Vector2 swarmerIdleTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (swarmerIdleTargetDist.Length() > 2800f) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + } + else if (swarmerIdleTargetDist.Length() > 400f) + { + float swarmerIdleSpeed = 7f + swarmerIdleTargetDist.Length() / 100f + NPC.ai[1] / 15f; + swarmerIdleTargetDist.Normalize(); + swarmerIdleTargetDist *= swarmerIdleSpeed; + NPC.velocity = (NPC.velocity * 29f + swarmerIdleTargetDist) / 30f; + } + else if (NPC.velocity.Length() > 2f) + NPC.velocity *= 0.95f; + else if (NPC.velocity.Length() < 1f) + NPC.velocity *= 1.05f; + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 105f) + { + NPC.ai[1] = 0f; + NPC.ai[0] = 2f; + } + } + else + { + if (NPC.ai[0] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.target < 0 || !Main.player[NPC.target].active || Main.player[NPC.target].dead) + NPC.TargetClosest(true); + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult + NPC.velocity.X * rotationAmt) / 10f; + + Vector2 swarmerChargeTargetDist = Main.player[NPC.target].Center - NPC.Center; + if (swarmerChargeTargetDist.Length() < 800f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + } + + NPC.ai[2] += 0.0166666675f; + float swarmerChargeSpeed = 9f + NPC.ai[2] + swarmerChargeTargetDist.Length() / 150f; + float swarmerChargeVelMult = 25f; + swarmerChargeTargetDist.Normalize(); + swarmerChargeTargetDist *= swarmerChargeSpeed; + NPC.velocity = (NPC.velocity * (swarmerChargeVelMult - 1f) + swarmerChargeTargetDist) / swarmerChargeVelMult; + + NPC.ForceNetUpdate(); + + return; + } + + if (NPC.ai[0] == 2f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * rotationMult * 0.75f + NPC.velocity.X * rotationAmt * 1.25f) / 8f; + + Vector2 swarmerDecelerateTargetDist = Main.player[NPC.target].Center - NPC.Center; + swarmerDecelerateTargetDist.Y -= 8f; + float swarmerDecelerateSpeed = 14f; + float swarmerDecelerateVelMult = 8f; + swarmerDecelerateTargetDist.Normalize(); + swarmerDecelerateTargetDist *= swarmerDecelerateSpeed; + NPC.velocity = (NPC.velocity * (swarmerDecelerateVelMult - 1f) + swarmerDecelerateTargetDist) / swarmerDecelerateVelMult; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + + NPC.ai[1] += 1f; + if (NPC.ai[1] > 10f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.velocity = swarmerDecelerateTargetDist; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.ai[0] = 2.1f; + NPC.ai[1] = 0f; + } + } + else if (NPC.ai[0] == 2.1f) + { + // Set damage + NPC.damage = NPC.defDamage; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else if (NPC.velocity.X > 0f) + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + + NPC.velocity *= 1.01f; + + NPC.ai[1] += 1f; + if (NPC.ai[1] > 30f) + { + if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + return; + } + + if (NPC.ai[1] > 60f) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + } + } + } + } + + public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ModContent.ItemType(), 1, 5, 7); + public override void OnKill() + { + if (Main.zenithWorld) + { + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < 5; i++) + { + Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f); + Vector2 ai0 = NPC.Center - fireFrom; + float ai = Main.rand.Next(100); + Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), 45, 0f, Main.myPlayer, ai0.ToRotation(), ai); + } + } + } + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += NPC.ai[0] == 2.1f ? 1.5 : 1D; + if (Main.zenithWorld) + { + NPC.frameCounter += 2D; + } + if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base + { + NPC.frameCounter = 0D; + NPC.frame.Y += frameHeight; + } + if (NPC.frame.Y >= frameHeight * 4) + { + NPC.frame.Y = 0; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = TextureAssets.Npc[Type].Value; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2); + int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0; + + if (CalamityClientConfig.Instance.Afterimages) + { + for (int i = 1; i < afterimageAmt; i += 2) + { + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + } + + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + return false; + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 50; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); + } + } + } + } +} diff --git a/NPCs/NormalNPCs/WildBumblefuck.cs b/NPCs/NormalNPCs/WildBumblefuck.cs deleted file mode 100644 index b0be162495..0000000000 --- a/NPCs/NormalNPCs/WildBumblefuck.cs +++ /dev/null @@ -1,173 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ModLoader.Utilities; - -namespace CalamityMod.NPCs.NormalNPCs -{ - public class WildBumblefuck : ModNPC - { - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 5; - NPCID.Sets.TrailingMode[Type] = 1; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - Position = Vector2.UnitX * 36f - }; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - } - - public override string Texture => "CalamityMod/NPCs/Bumblebirb/BumbleFolly"; - - public override void SetDefaults() - { - NPC.npcSlots = 1f; - NPC.aiStyle = -1; - AIType = -1; - NPC.damage = 90; - NPC.width = 120; - NPC.height = 80; - NPC.defense = 20; - NPC.LifeMaxNERB(9375, 11250, 5000); // Old HP - 12000, 15000 - NPC.knockBackResist = 0.15f; - NPC.lavaImmune = true; - NPC.noTileCollide = true; - NPC.noGravity = true; - NPC.HitSound = SoundID.NPCHit51; - NPC.DeathSound = SoundID.NPCDeath46; - Banner = NPC.type; - BannerItem = ModContent.ItemType(); - NPC.Calamity().VulnerableToHeat = true; - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.Jungle, - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.WildBumblefuck") - }); - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.PlayerSafe || !NPC.downedMoonlord || spawnInfo.Player.Calamity().ZoneSunkenSea || !spawnInfo.Player.ZoneJungle) - return 0f; - - // Keep this as a separate if check, because it's a loop and we don't want to be checking it constantly. - if (NPC.AnyNPCs(NPC.type)) - return 0f; - - return SpawnCondition.SurfaceJungle.Chance * 0.14f; - } - - public override void AI() - { - BumblebirbAI.VanillaBumblebirb2AI(NPC, Mod, false); - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ModContent.ItemType(), 1, 5, 7); - public override void OnKill() - { - if (Main.zenithWorld) - { - SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, NPC.Center - Vector2.UnitY * 300f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < 5; i++) - { - Vector2 fireFrom = new Vector2(NPC.Center.X + (40 * i) - 120, NPC.Center.Y - 900f); - Vector2 ai0 = NPC.Center - fireFrom; - float ai = Main.rand.Next(100); - Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), NPC.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); - } - } - } - } - - public override void FindFrame(int frameHeight) - { - NPC.frameCounter += NPC.ai[0] == 2.1f ? 1.5 : 1D; - if (Main.zenithWorld) - { - NPC.frameCounter += 2D; - } - if (NPC.frameCounter > 4D) //iban said the time between frames was 5 so using that as a base - { - NPC.frameCounter = 0D; - NPC.frame.Y += frameHeight; - } - if (NPC.frame.Y >= frameHeight * 4) - { - NPC.frame.Y = 0; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2); - int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0; - - if (CalamityClientConfig.Instance.Afterimages) - { - for (int i = 1; i < afterimageAmt; i += 2) - { - Color afterimageColor = drawColor; - afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f); - afterimageColor = NPC.GetAlpha(afterimageColor); - afterimageColor *= (afterimageAmt - i) / 15f; - Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; - afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - } - - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); - } - if (NPC.life <= 0) - { - for (int k = 0; k < 50; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.CopperCoin, hit.HitDirection, -1f, 0, default, 1f); - } - } - } - } -} diff --git a/NPCs/NormalNPCs/WulfrumAmplifier.cs b/NPCs/NormalNPCs/WulfrumAmplifier.cs index 80a086b0d8..b0f259e82c 100644 --- a/NPCs/NormalNPCs/WulfrumAmplifier.cs +++ b/NPCs/NormalNPCs/WulfrumAmplifier.cs @@ -51,9 +51,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 44; NPC.height = 44; NPC.defense = 4; - NPC.lifeMax = Main.zenithWorld ? 90 : 58; + NPC.lifeMax = Main.zenithWorld ? 200 : 100; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.noGravity = false; NPC.noTileCollide = false; NPC.HitSound = Hit; @@ -64,10 +64,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToElectricity = true; if (Main.zenithWorld) NPC.scale = 1.5f; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -99,7 +95,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Spawn some off-screen enemies to act as threats if the player enters the field. if (Main.netMode != NetmodeID.MultiplayerClient) { - int enemiesToSpawn = CalamityWorld.LegendaryMode ? 4 : CalamityWorld.death ? 3 : CalamityWorld.revenge ? 2 : 1; + int enemiesToSpawn = Main.getGoodWorld ? 4 : CalamityWorld.death ? 3 : CalamityWorld.revenge ? 2 : 1; for (int i = 0; i < enemiesToSpawn; i++) { int tries = 0; @@ -123,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs else if (tries < 500 && Main.zenithWorld) { //Summon the army - int npcToSpawn = CalamityWorld.LegendaryMode ? 0 : Main.rand.Next(0, 4); + int npcToSpawn = Main.rand.Next(0, 4); switch (enemiesToSpawn) { case 0: @@ -157,7 +153,7 @@ namespace CalamityMod.NPCs.NormalNPCs for (int i = 0; i < dustCount; i++) { float angle = MathHelper.TwoPi * i / dustCount; - Dust dust = Dust.NewDustPerfect(NPC.Center, 229); + Dust dust = Dust.NewDustPerfect(NPC.Center, DustID.Vortex); dust.position = NPC.Center + angle.ToRotationVector2() * ChargeRadius; dust.scale = 0.7f; dust.noGravity = true; @@ -190,11 +186,11 @@ namespace CalamityMod.NPCs.NormalNPCs Dust.NewDust(npcAtIndex.position, npcAtIndex.width, npcAtIndex.height, DustID.Electric); } } - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) { laserDelay--; NPC.spriteDirection = (player.Center.X - NPC.Center.X < 0).ToDirectionInt(); - for (int times = CalamityWorld.LegendaryMode ? 3 : 2; times > 0 && laserDelay == 0; times--) + for (int times = 3; times > 0 && laserDelay == 0; times--) { Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitX * 6f * NPC.spriteDirection, NPC.SafeDirectionTo(player.Center, Vector2.UnitY) * 4.5f, ProjectileID.SaucerMissile, 10, 0f); } diff --git a/NPCs/NormalNPCs/WulfrumDrone.cs b/NPCs/NormalNPCs/WulfrumDrone.cs index 58beddcec3..f78416ae79 100644 --- a/NPCs/NormalNPCs/WulfrumDrone.cs +++ b/NPCs/NormalNPCs/WulfrumDrone.cs @@ -1,12 +1,10 @@ -using System; -using System.IO; +using System.IO; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Sounds; using CalamityMod.World; using Microsoft.Xna.Framework; -using Mono.Cecil; using Terraria; using Terraria.Audio; using Terraria.GameContent.Bestiary; @@ -70,9 +68,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 32; NPC.height = 32; NPC.defense = 4; - NPC.lifeMax = 27; + NPC.lifeMax = 25; NPC.knockBackResist = 0.35f; - NPC.value = Item.buyPrice(0, 0, 0, 80); + NPC.value = Item.buyPrice(copper: 80); NPC.noGravity = true; NPC.noTileCollide = true; NPC.HitSound = WulfrumAmplifier.Hit; @@ -81,10 +79,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -180,7 +174,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.zenithWorld) { int spread = 15; - for (int times = CalamityWorld.LegendaryMode ? 3 : 2; times > 0; times--) + for (int times = 3; times > 0; times--) { Vector2 velocity = NPC.SafeDirectionTo(player.Center, Vector2.UnitY) * 6f; Vector2 perturbedspeed = new Vector2(velocity.X + Main.rand.Next(-2, 3), velocity.Y + Main.rand.Next(-2, 3)).RotatedBy(MathHelper.ToRadians(spread)); @@ -211,7 +205,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Generate idle dust if (!Main.dedServ) { - Dust dust = Dust.NewDustPerfect(NPC.Bottom, 229); + Dust dust = Dust.NewDustPerfect(NPC.Bottom, DustID.Vortex); dust.color = Color.Green; dust.scale = 0.675f; } diff --git a/NPCs/NormalNPCs/WulfrumGyrator.cs b/NPCs/NormalNPCs/WulfrumGyrator.cs index 8427304eff..e4b9f253e0 100644 --- a/NPCs/NormalNPCs/WulfrumGyrator.cs +++ b/NPCs/NormalNPCs/WulfrumGyrator.cs @@ -4,7 +4,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Projectiles.Rogue; using CalamityMod.Sounds; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; @@ -55,19 +54,15 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.width = 40; NPC.height = 40; NPC.defense = 5; - NPC.lifeMax = 23; + NPC.lifeMax = 25; NPC.knockBackResist = 0.15f; - NPC.value = Item.buyPrice(0, 0, 0, 75); + NPC.value = Item.buyPrice(copper: 75); NPC.HitSound = WulfrumAmplifier.Hit; NPC.DeathSound = CommonCalamitySounds.WulfrumNPCDeathSound; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -132,8 +127,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.direction = direction; NPC.ForceNetUpdate(); } - //GOTTA GO FAST (Legendary only) - if (CalamityWorld.LegendaryMode) + //GOTTA GO FAST (FTW only) + if (Main.getGoodWorld) { NPC.velocity *= 1.01f; //Overcharged diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.cs b/NPCs/NormalNPCs/WulfrumHovercraft.cs index b278e299f7..e55ad29633 100644 --- a/NPCs/NormalNPCs/WulfrumHovercraft.cs +++ b/NPCs/NormalNPCs/WulfrumHovercraft.cs @@ -3,10 +3,8 @@ using System.IO; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Projectiles.Pets; using CalamityMod.Projectiles.Rogue; using CalamityMod.Sounds; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -79,7 +77,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 38; NPC.defense = 4; NPC.lifeMax = 25; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = WulfrumAmplifier.Hit; NPC.DeathSound = CommonCalamitySounds.WulfrumNPCDeathSound; NPC.noGravity = true; @@ -88,10 +86,6 @@ namespace CalamityMod.NPCs.NormalNPCs BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -179,7 +173,7 @@ namespace CalamityMod.NPCs.NormalNPCs { for (int i = 0; i < 2; i++) { - Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(8f, 8f), 226).scale = 0.7f; + Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(8f, 8f), DustID.Electric).scale = 0.7f; } } @@ -321,8 +315,8 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - //Become a spark piñata in Legendary - if (CalamityWorld.LegendaryMode && Supercharged) + //Become a spark piñata in FTW + if (Main.getGoodWorld && Supercharged) { for (int Sparks = Main.rand.Next(2, 5); Sparks > 0; Sparks--) { diff --git a/NPCs/NormalNPCs/WulfrumRover.cs b/NPCs/NormalNPCs/WulfrumRover.cs index 32f84de137..4b82f3e3e3 100644 --- a/NPCs/NormalNPCs/WulfrumRover.cs +++ b/NPCs/NormalNPCs/WulfrumRover.cs @@ -3,12 +3,10 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Sounds; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent.Bestiary; -using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; @@ -59,7 +57,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 4; NPC.lifeMax = 40; NPC.knockBackResist = Main.zenithWorld ? 0f : 0.15f; - NPC.value = Item.buyPrice(0, 0, 0, 75); + NPC.value = Item.buyPrice(copper: 75); NPC.HitSound = WulfrumAmplifier.Hit; NPC.DeathSound = CommonCalamitySounds.WulfrumNPCDeathSound; Banner = NPC.type; @@ -68,10 +66,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToElectricity = true; if (Main.zenithWorld) NPC.scale = 2f; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -101,11 +95,11 @@ namespace CalamityMod.NPCs.NormalNPCs if (Supercharged) { SuperchargeTimer--; - NPC.defense = CalamityWorld.LegendaryMode ? 20 : 13; + NPC.defense = Main.getGoodWorld ? 20 : 13; } else if (!Supercharged) { - NPC.defense = CalamityWorld.LegendaryMode ? 10 : 4; + NPC.defense = Main.getGoodWorld ? 10 : 4; } Player player = Main.player[NPC.target]; @@ -188,7 +182,7 @@ namespace CalamityMod.NPCs.NormalNPCs Main.projectile[mine].hostile = true; Main.projectile[mine].timeLeft = 60; } - mineDelay = CalamityWorld.LegendaryMode ? 3 : 5; + mineDelay = 3; } else if (Main.zenithWorld && mineDelay >= 1) mineDelay--; diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index a0aa82aad3..ea70d84fb2 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -1,6 +1,7 @@ using System; using System.IO; using CalamityMod.BiomeManagers; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; @@ -8,7 +9,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -17,8 +18,10 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.CalamityAIs.CalamityBossAIs; using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Systems; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -37,14 +40,32 @@ namespace CalamityMod.NPCs.OldDuke [AutoloadBossHead] public class OldDuke : ModNPC { + public static Color GlowColor = new Color(55, 255, 25, 0); + + // Old Duke doesn't have a phase 3 in normal mode + public const float LifePercentagePhase2_Normal = 0.5f; + public const float LifePercentagePhase2_Revenge = 0.7f; + public const float LifePercentagePhase2_Death = 0.8f; + public const float LifePercentagePhase3_Expert = 0.2f; + public const float LifePercentagePhase3_Revenge = 0.35f; + public const float LifePercentagePhase3_Death = 0.5f; + + public int Phase = 0; + public float NuclearOverlayVisual = 0f; + public static readonly SoundStyle HuffSound = new("CalamityMod/Sounds/Custom/OldDukeHuff"); public static readonly SoundStyle RoarSound = new("CalamityMod/Sounds/Custom/OldDukeRoar"); public static readonly SoundStyle VomitSound = new("CalamityMod/Sounds/Custom/OldDukeVomit"); - - public SlotId RoarSoundSlot; + public static readonly SoundStyle VortexSpawnSound = new("CalamityMod/Sounds/Custom/OldDukeVortexSpawn"); + public static readonly SoundStyle DashSound = new("CalamityMod/Sounds/Custom/OldDukeDash"); + public static readonly SoundStyle DashSoundP3 = new("CalamityMod/Sounds/Custom/OldDukeDashP3"); + private static Color FireGreen = new Color(155, 255, 55); + private SlotId RoarSoundSlot; public static Asset GlowTexture; + public float shake = 0f; + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 7; @@ -63,23 +84,33 @@ namespace CalamityMod.NPCs.OldDuke } } + public static float Phase2ContactDamageMult = 1.1f; // 308 + public static float Phase3ContactDamageMult = 1.2f; // 336 + public static int GoreDamage = 55; // 220 + public static int VortexDamage = 105; // 420 + + // GFB exclusive + public static int FartDamage = 80; // 320 + public override void SetDefaults() { + NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 140; // 280 + NPC.alpha = 255; NPC.width = 150; NPC.height = 100; NPC.aiStyle = -1; AIType = -1; - NPC.GetNPCDamage(); NPC.defense = 90; - NPC.DR_NERD(0.5f, null, null, null, true); - NPC.LifeMaxNERB(500000, 600000, 400000); + NPC.DR_NERD(0.5f); + NPC.LifeMaxNERB(400000, 600000, 400000); NPC.knockBackResist = 0f; NPC.noTileCollide = true; NPC.noGravity = true; NPC.npcSlots = 15f; NPC.HitSound = SoundID.NPCHit14; NPC.DeathSound = SoundID.NPCDeath20; - NPC.value = Item.buyPrice(2, 0, 0, 0); + NPC.value = Item.buyPrice(platinum: 1, gold: 50); NPC.boss = true; NPC.netAlways = true; NPC.timeLeft = NPC.activeTime * 30; @@ -88,9 +119,6 @@ namespace CalamityMod.NPCs.OldDuke NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -121,15 +149,1628 @@ namespace CalamityMod.NPCs.OldDuke NPC.Calamity().newAI[i] = reader.ReadSingle(); } + #region Visual Helper Methods + static void DoChargeBurst(NPC npc, int phase) + { + SoundEngine.PlaySound(phase > 1 ? DashSoundP3 : DashSound, npc.Center); + + if (phase > 1) + { + for (int i = 0; i < 30; i++) + { + float fl = Main.rand.NextFloat(-60f, 60f); + GeneralParticleHandler.SpawnParticle(new SparkParticle(npc.Center + (Vector2.Zero.DirectionTo(npc.velocity) * 20f) + new Vector2(0f, fl).RotatedBy(Vector2.Zero.AngleTo(npc.velocity)), (-npc.velocity * Main.rand.NextFloat(2f)).RotatedBy(MathHelper.ToRadians(fl)), false, 25, Main.rand.NextFloat(0.3f, 1.2f), FireGreen)); + } + + CalamityUtils.AddScreenshakeAt(npc.Center, 10f, 3000f); + + SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact, npc.Center); + SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, npc.Center); + GeneralParticleHandler.SpawnParticle(new CustomPulse(npc.Center, -npc.velocity / 3f, FireGreen, "CalamityMod/Particles/DustyCircleHardEdge", new Vector2(0.4f, 1.2f), Vector2.Zero.AngleTo(npc.velocity) + (Main.rand.NextBool() ? 0 : -MathHelper.Pi), 0.05f, 0.2f, 20)); + GeneralParticleHandler.SpawnParticle(new CustomPulse(npc.Center, -npc.velocity / 2f, FireGreen, "CalamityMod/Particles/FlameExplosion", new Vector2(0.4f, 1.2f), Vector2.Zero.AngleTo(npc.velocity) + (Main.rand.NextBool() ? 0 : -MathHelper.Pi), 0.1f, 0.4f, 20)); + } + } + static void DoChargeVisual(NPC npc, int phase) + { + float progress = npc.ai[2]; + int chargeTime = 36; + + Color col = Color.Lerp(phase > 0 ? FireGreen : new Color(100, 100, 100, 55), new Color(55, 55, 55, 55), progress / chargeTime); + + if (phase > 1) + { + if (Math.Floor(VisualTimerSystem.GlobalVisualTimer % 6f) < 1f) + GeneralParticleHandler.SpawnParticle(new CustomPulse(npc.Center, npc.velocity / 3f, col, "CalamityMod/Particles/DustyCircleHardEdge", new Vector2(0.4f, 1f), Vector2.Zero.AngleTo(npc.velocity) + (Main.rand.NextBool() ? 0 : -MathHelper.Pi), 0.04f, 0.1f, 20)); + + (npc.ModNPC as OldDuke).NuclearOverlayVisual = 1f; + } + + if (Main.rand.NextBool()) + GeneralParticleHandler.SpawnParticle(new CustomSpark(npc.Center - (npc.velocity * 2f), npc.velocity / 2f, "CalamityMod/Particles/ForwardSmear", false, 10, Main.rand.NextFloat(0.3f, 0.5f), col, new Vector2(1f, Main.rand.NextFloat(1.45f, 1.6f)), fadeIn: true, extraRotation: MathHelper.ToRadians(180f))); + } + #endregion + public override void AI() { - OldDukeAI.VanillaOldDukeAI(NPC, Mod); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + shake = MathHelper.Lerp(shake, 0f, 0.1f); + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Variables + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + float exhaustionGateValue = 360f; + if (Main.getGoodWorld) + exhaustionGateValue *= 0.5f; + + float numberOfAttacksBeforeExhaustion = 12f; + float exhaustionIncreasePerAttack = exhaustionGateValue * (1f / numberOfAttacksBeforeExhaustion); + bool exhausted = calamityGlobalNPC.newAI[1] == 1f; + bool phase2 = lifeRatio <= (death ? LifePercentagePhase2_Death : revenge ? LifePercentagePhase2_Revenge : LifePercentagePhase2_Normal); + bool phase3 = lifeRatio <= (death ? LifePercentagePhase3_Death : (revenge ? LifePercentagePhase3_Revenge : LifePercentagePhase3_Expert)) && expertMode; + bool phase2AI = NPC.ai[0] > 4f; + bool phase3AI = NPC.ai[0] > 9f; + + Phase = phase3 ? 2 : phase2 ? 1 : 0; + NuclearOverlayVisual = (Phase == 2 && NPC.Calamity().newAI[1] != 1) ? MathHelper.Lerp(NuclearOverlayVisual, 0.2f, 0.2f) : MathHelper.Lerp(NuclearOverlayVisual, 0f, 0.1f); + + bool charging = NPC.ai[3] < 10f; + if (calamityGlobalNPC.newAI[0] >= exhaustionGateValue) + calamityGlobalNPC.newAI[1] = 1f; + + float alphaScale = (255 - NPC.alpha) / 255f; + float redLight = (phase3AI ? 0.4f : phase2AI ? 0.64f : 0.88f) * alphaScale; + float greenLight = (phase3AI ? 1.2f : phase2AI ? 0.8f : 0.4f) * alphaScale; + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), redLight, greenLight, 0f); + + if (CalamityServerConfig.Instance.BossesStopWeather) + CalamityWorld.StopRain(); + else if (!Main.raining && !BossRushEvent.BossRushActive) + CalamityWorld.StartRain(); + + // Adjust stats + NPC.damage = NPC.defDamage; + calamityGlobalNPC.DR = exhausted ? 0f : 0.5f; + NPC.defense = exhausted ? 0 : NPC.defDefense; + if (phase3AI) + { + NPC.damage = (int)Math.Round(NPC.defDamage * Phase3ContactDamageMult); + NPC.defense = exhausted ? 0 : NPC.defDefense - 40; + } + else if (phase2AI) + { + NPC.damage = (int)Math.Round(NPC.defDamage * Phase2ContactDamageMult); + NPC.defense = exhausted ? 0 : NPC.defDefense - 20; + } + + int idlePhaseTimer = expertMode ? 55 : 60; + float idlePhaseAcceleration = expertMode ? 0.75f : 0.7f; + float idlePhaseVelocity = expertMode ? 14f : 13f; + if (phase3AI) + { + idlePhaseAcceleration = expertMode ? 0.6f : 0.55f; + idlePhaseVelocity = expertMode ? 12f : 11f; + } + else if (phase2AI & charging) + { + idlePhaseAcceleration = expertMode ? 0.8f : 0.75f; + idlePhaseVelocity = expertMode ? 15f : 14f; + } + + int chargeTime = expertMode ? 34 : 36; + float chargeVelocity = expertMode ? 20f : 19f; + if (phase3AI) + { + chargeTime = expertMode ? 28 : 30; + chargeVelocity = expertMode ? 26f : 25f; + } + else if (charging & phase2AI) + { + chargeTime = expertMode ? 31 : 33; + chargeVelocity = expertMode ? 24f : 23f; + } + + if (death) + { + idlePhaseTimer = 51; + idlePhaseAcceleration *= 1.05f; + idlePhaseVelocity *= 1.05f; + chargeTime -= 2; + chargeVelocity *= 1.1f; + } + else if (revenge) + { + idlePhaseTimer = 53; + idlePhaseAcceleration *= 1.025f; + idlePhaseVelocity *= 1.025f; + chargeTime -= 1; + chargeVelocity *= 1.05f; + } + + // The dumbest thing to ever exist + if (Main.zenithWorld) + chargeVelocity *= 1.25f; + + if (exhausted) + idlePhaseVelocity *= 0.25f; + + // Variables + int maxToothBallBelches = death ? 4 : 3; + int toothBallBelchPhaseDivisor = death ? 30 : 40; + int toothBallBelchPhaseTimer = toothBallBelchPhaseDivisor * maxToothBallBelches; + float toothBallBelchPhaseAcceleration = death ? 0.6f : 0.55f; + float toothBallBelchPhaseVelocity = death ? 10f : 9f; + float toothBallFinalVelocity = death ? 14f : revenge ? 13f : 12f; + float goreVelocityX = death ? 8f : revenge ? 7.5f : expertMode ? 7f : 6f; + float goreVelocityY = death ? 10.5f : revenge ? 10f : expertMode ? 9.5f : 8f; + float sharkronVelocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + int attackTimer = 120; + int phaseTransitionTimer = 180; + int teleportPauseTimer = 30; + int toothBallSpinPhaseDivisor = death ? 32 : 45; + int toothBallSpinTimer = maxToothBallBelches * toothBallSpinPhaseDivisor; + float spinTime = toothBallSpinTimer / 2f; + float toothBallSpinToothBallVelocity = death ? 9.5f : 9f; + float spinAttackSpeed = Main.zenithWorld ? 44f : 22f; + float spinSpeed = MathHelper.TwoPi / spinTime; + + Player player = Main.player[NPC.target]; + + // Get target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active) + { + NPC.TargetClosest(); + player = Main.player[NPC.target]; + NPC.netUpdate = true; + } + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + NPC.TargetClosest(); + + // Despawn + if (player.dead || Vector2.Distance(player.Center, NPC.Center) > 8800f) + { + NPC.TargetClosest(); + + NPC.velocity.Y -= 0.4f; + + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; + + if (NPC.timeLeft == 1) + { + AcidRainEvent.AccumulatedKillPoints = 0; + AcidRainEvent.HasTriedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + NPC.timeLeft = 0; + } + + if (NPC.ai[0] > 4f) + NPC.ai[0] = 5f; + else + NPC.ai[0] = 0f; + + NPC.ai[2] = 0f; + } + + if (exhausted) + { + // Disable contact damage while tired + NPC.damage = 0; + + // Play exhausted sound and huff fumes + if (calamityGlobalNPC.newAI[0] % 60f == 0f && Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < 2800f) + { + SoundEngine.PlaySound(HuffSound with { Volume = HuffSound.Volume * 1.25f }, Main.LocalPlayer.Center); + for (int i = 0; i < 40; i++) + { + float scale = Main.rand.NextFloat(1f, 3f); + Vector2 fumePos = NPC.Center + NPC.rotation.ToRotationVector2() * (Main.rand.NextBool() ? 100f : 80f) * NPC.direction; + Vector2 fumeVel = Vector2.UnitX * NPC.velocity.X + Vector2.UnitY.RotatedByRandom(MathHelper.ToRadians(12f)) * scale * -8f * Main.rand.NextFloat(1f, 1.25f); + MediumMistParticle fume = new(fumePos, fumeVel, GlowColor, Color.DarkSlateGray, scale, 150f); + GeneralParticleHandler.SpawnParticle(fume); + } + + Vector2 pulsePos = NPC.Center + NPC.rotation.ToRotationVector2() * 88f * NPC.direction; + CustomPulse pulse = new(pulsePos, Vector2.Zero, Color.White * 0.2f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.05f, 0.125f, 30); + GeneralParticleHandler.SpawnParticle(pulse); + } + + if (Main.zenithWorld) + { + float screenShakePower = 10 * Utils.GetLerpValue(800f, 0f, NPC.Distance(Main.LocalPlayer.Center), true); + Main.LocalPlayer.SetScreenshake(screenShakePower); + + if (calamityGlobalNPC.newAI[0] == exhaustionGateValue) + SoundEngine.PlaySound(SoundID.NPCDeath64 with { Pitch = SoundID.NPCDeath64.Pitch - 0.9f, Volume = SoundID.NPCDeath64.Volume + 0.4f }, player.Center); // fart + + if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[0] % 5f == 0f) + { + Vector2 dist = player.Center - NPC.Center; + dist.Normalize(); + dist *= 3; + dist.X += Main.rand.NextFloat(-0.5f, 0.5f); + dist.Y += Main.rand.NextFloat(-0.5f, 0.5f); + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, -dist, type, FartDamage, 0, Main.myPlayer); + } + } + + calamityGlobalNPC.newAI[0] -= 1f; + if (calamityGlobalNPC.newAI[0] <= 0f) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + } + } + + // Enrage variable + bool enrage = !BossRushEvent.BossRushActive && + (player.position.Y < 300f || player.position.Y > Main.worldSurface * 16.0 || + (player.position.X > 8000f && player.position.X < (Main.maxTilesX * 16 - 8000))); + + // Check for the flipped Abyss + if (Main.remixWorld) + { + enrage = !BossRushEvent.BossRushActive && + (player.position.Y < Main.UnderworldLayer * 16 * 0.8f || player.position.Y > Main.UnderworldLayer * 16 || + (player.position.X > 8000f && player.position.X < (Main.maxTilesX * 16 - 8000))); + } + + // Enrage + if (enrage) + { + if (NPC.localAI[1] > 0f) + NPC.localAI[1] -= 1f; + } + else + NPC.localAI[1] = CalamityGlobalNPC.biomeEnrageTimerMax; + + bool biomeEnraged = NPC.localAI[1] <= 0f; + + NPC.Calamity().CurrentlyEnraged = biomeEnraged; + + // Increased DR while transitioning phases and not exhausted + if (!exhausted) + calamityGlobalNPC.DR = (NPC.ai[0] == -1f || NPC.ai[0] == 4f || NPC.ai[0] == 9f) ? 0.75f : 0.5f; + + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = NPC.ai[0] == -1f || NPC.ai[0] == 4f || NPC.ai[0] == 9f; + + // Enrage + if (biomeEnraged) + { + toothBallBelchPhaseTimer = 60; + toothBallBelchPhaseDivisor = 20; + toothBallBelchPhaseAcceleration = 1f; + toothBallBelchPhaseVelocity = 15f; + goreVelocityX = 12f; + goreVelocityY = 16f; + sharkronVelocity = 20f; + idlePhaseTimer = 20; + idlePhaseAcceleration = 1.2f; + idlePhaseVelocity = 20f; + chargeTime = 25; + chargeVelocity += 8f; + toothBallSpinPhaseDivisor = 24; + toothBallSpinToothBallVelocity = 15f; + NPC.damage *= 2; + NPC.defense = NPC.defDefense * 3; + } + + // The dumbest thing to ever exist + if (Main.zenithWorld) + chargeTime *= 2; + + // Set variables for spawn effects + if (NPC.localAI[0] == 0f) + { + NPC.alpha = 255; + + NPC.velocity.Y = -12f; + NPC.velocity.X = Main.rand.NextFloat(-2f, 2f); + + NPC.localAI[0] = 1f; + NPC.rotation = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = -1f; + NPC.netUpdate = true; + } + } + + // Rotation + float rateOfRotation = 0.04f; + if (NPC.ai[0] == 1f || NPC.ai[0] == 6f || NPC.ai[0] == 7f || NPC.ai[0] == 14f) + rateOfRotation = 0f; + if (NPC.ai[0] == 3f || NPC.ai[0] == 4f) + rateOfRotation = 0.01f; + if (NPC.ai[0] == 8f || NPC.ai[0] == 13f) + rateOfRotation = 0.05f; + + Vector2 rotationVector = player.Center - NPC.Center; + if (calamityGlobalNPC.newAI[1] != 1f && !player.dead) + { + // Rotate to show direction of predictive charge + if (NPC.ai[0] == 0f && !phase2) + { + if (NPC.ai[3] < 6f) + { + rateOfRotation = 0.1f; + rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * chargeVelocity; + } + } + else if (NPC.ai[0] == 5f && !phase3) + { + if (NPC.ai[3] < 4f) + { + rateOfRotation = 0.1f; + rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * chargeVelocity; + } + } + else if (NPC.ai[0] == 10f) + { + if (NPC.ai[3] < 8f && NPC.ai[3] != 1f && NPC.ai[3] != 4f) + { + rateOfRotation = 0.1f; + rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - NPC.Center) * chargeVelocity; + } + } + } + + float dukeRotationSpeed = (float)Math.Atan2(rotationVector.Y, rotationVector.X); + if (NPC.spriteDirection == 1) + dukeRotationSpeed += MathHelper.Pi; + if (dukeRotationSpeed < 0f) + dukeRotationSpeed += MathHelper.TwoPi; + if (dukeRotationSpeed > MathHelper.TwoPi) + dukeRotationSpeed -= MathHelper.TwoPi; + if (NPC.ai[0] == -1f || NPC.ai[0] == 3f || NPC.ai[0] == 4f) + dukeRotationSpeed = 0f; + if (NPC.ai[0] == 8f || NPC.ai[0] == 13f) + dukeRotationSpeed = MathHelper.Pi * 0.1666666667f * NPC.spriteDirection; + + if (NPC.rotation < dukeRotationSpeed) + { + if (dukeRotationSpeed - NPC.rotation > MathHelper.Pi) + NPC.rotation -= rateOfRotation; + else + NPC.rotation += rateOfRotation; + } + if (NPC.rotation > dukeRotationSpeed) + { + if (NPC.rotation - dukeRotationSpeed > MathHelper.Pi) + NPC.rotation += rateOfRotation; + else + NPC.rotation -= rateOfRotation; + } + + if ((NPC.ai[0] != 8f && NPC.ai[0] != 13f) || NPC.spriteDirection == 1) + { + if (NPC.rotation > dukeRotationSpeed - rateOfRotation && NPC.rotation < dukeRotationSpeed + rateOfRotation) + NPC.rotation = dukeRotationSpeed; + if (NPC.rotation < 0f) + NPC.rotation += MathHelper.TwoPi; + if (NPC.rotation > MathHelper.TwoPi) + NPC.rotation -= MathHelper.TwoPi; + if (NPC.rotation > dukeRotationSpeed - rateOfRotation && NPC.rotation < dukeRotationSpeed + rateOfRotation) + NPC.rotation = dukeRotationSpeed; + } + + // Alpha adjustments + if (NPC.ai[0] != -1f && (NPC.ai[0] < 9f || NPC.ai[0] > 12f)) + { + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.alpha += 15; + else + NPC.alpha -= 15; + + if (NPC.alpha < 0) + NPC.alpha = 0; + if (NPC.alpha > 150) + NPC.alpha = 150; + } + + // Spawn effects + if (NPC.ai[0] == -1f) + { + NPC.alpha = (int)MathHelper.Lerp(NPC.alpha, 0, 0.2f); + + // Disable contact damage while spawning + NPC.damage = 0; + + // Velocity + if (NPC.Calamity().newAI[3] == 0f) + NPC.velocity *= 0.98f; + + // Direction + int dukeFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); + if (dukeFaceDirection != 0) + { + NPC.direction = dukeFaceDirection; + NPC.spriteDirection = -NPC.direction; + } + + // Alpha + if (NPC.ai[2] > 20f) + { + NPC.velocity *= 0.9f; + + NPC.alpha -= 5; + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.alpha += 15; + if (NPC.alpha < 0) + NPC.alpha = 0; + if (NPC.alpha > 150) + NPC.alpha = 150; + } + + if (NPC.ai[2] == 75) + { + RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); + + CalamityUtils.AddScreenshakeAt(NPC.Center, 14); + SoundEngine.PlaySound(SoundID.DD2_BetsyFlameBreath.WithPitchOffset(-0.5f), NPC.Center); + SoundEngine.PlaySound(DashSoundP3, NPC.Center); + } + + if (NPC.ai[2] >= 75f) + { + float sd = player.Center.X > NPC.Center.X ? -1f : 1f; + + shake = 2f; + NPC.rotation = MathHelper.Lerp(MathHelper.WrapAngle(NPC.rotation), MathHelper.ToRadians(sd == 1f ? 75f : -75f), 0.2f); + + if (NPC.ai[2] % 5f == 1f) + { + Vector2 mouthCenter = NPC.Center + new Vector2(-80 * sd, 0).RotatedBy(NPC.rotation); + + float factor = (NPC.ai[2] - 75f) / 50f; + + float a = MathHelper.Lerp(1f, 0f, factor); + + GeneralParticleHandler.SpawnParticle(new CustomPulse(mouthCenter, Vector2.Zero, new Color(55, 55, 55).MultiplyRGBA(new Color(a, a, a, a)), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.05f, 0.08f + (0.15f * factor), 10)); + } + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 125f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; + } + } + + // Phase 1 + else if (NPC.ai[0] == 0f && !player.dead) + { + // Velocity + if (NPC.ai[1] == 0f) + NPC.ai[1] = 500 * Math.Sign((NPC.Center - player.Center).X); + + Vector2 phase1IdleSpeed = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -300f) - NPC.Center - NPC.velocity) * idlePhaseVelocity; + NPC.SimpleFlyMovement(phase1IdleSpeed, idlePhaseAcceleration); + + // Rotation and direction + int dukeLookAt = Math.Sign(player.Center.X - NPC.Center.X); + if (dukeLookAt != 0) + { + if (NPC.ai[2] == 0f && dukeLookAt != NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.direction = dukeLookAt; + + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + // Phase switch + if (calamityGlobalNPC.newAI[1] != 1f || (phase2 && !phase2AI)) + { + NPC.ai[2] += 1f; + if (NPC.ai[2] >= idlePhaseTimer || (phase2 && !phase2AI)) + { + int oldDukeAttackPicker = 0; + switch ((int)NPC.ai[3]) + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + oldDukeAttackPicker = 1; + break; + case 6: + NPC.ai[3] = 1f; + oldDukeAttackPicker = 2; + break; + case 7: + NPC.ai[3] = 0f; + oldDukeAttackPicker = 3; + break; + } + + if (phase2) + oldDukeAttackPicker = 4; + + // Set velocity for charge + if (oldDukeAttackPicker == 1) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + // Velocity + Vector2 distanceVector = player.Center + player.velocity * 20f - NPC.Center; + NPC.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + DoChargeBurst(NPC, 0); + + // Direction + if (dukeLookAt != 0) + { + NPC.direction = dukeLookAt; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + } + + // Tooth Balls + else if (oldDukeAttackPicker == 2) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + // Call sharks from the sides of the screen + else if (oldDukeAttackPicker == 3) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + // Go to phase 2 + else if (oldDukeAttackPicker == 4) + { + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + NPC.netUpdate = true; + } + } + } + + // Charge + else if (NPC.ai[0] == 1f) + { + // The dumbest thing to ever exist + if (Main.zenithWorld && NPC.ai[2] % 10f == 0f) + { + // Rotation and direction + int dir = Math.Sign(player.Center.X - NPC.Center.X); + if (dir != 0) + { + if (NPC.ai[2] == 0f && dir != NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.direction = dir; + + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + Vector2 distanceVector = player.Center + player.velocity * 20f - NPC.Center; + NPC.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + // Direction + if (dir != 0) + { + NPC.direction = dir; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + } + else + { + // Accelerate + NPC.velocity *= 1.01f; + } + + // Spawn dust + Vector2 vel = NPC.velocity; + vel.Normalize(); + vel *= 55f; + + DoChargeVisual(NPC, Phase); + + GeneralParticleHandler.SpawnParticle(new SparkParticle(NPC.Center + vel + vel.RotatedBy(MathHelper.ToRadians(90)), vel / 7f, false, 20, 0.75f, new Color(155, 155, 155, 55), true)); + GeneralParticleHandler.SpawnParticle(new SparkParticle(NPC.Center + vel + vel.RotatedBy(MathHelper.ToRadians(-90)), vel / 7f, false, 20, 0.75f, new Color(155, 155, 155, 55), true)); + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= chargeTime) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] += 2f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Tooth Ball belch + else if (NPC.ai[0] == 2f) + { + // Velocity + if (NPC.ai[1] == 0f) + NPC.ai[1] = 500 * Math.Sign((NPC.Center - player.Center).X); + + Vector2 toothBallBelchPhaseSpeed = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -300f) - NPC.Center - NPC.velocity) * toothBallBelchPhaseVelocity; + NPC.SimpleFlyMovement(toothBallBelchPhaseSpeed, toothBallBelchPhaseAcceleration); + + // Play sounds and spawn Tooth Balls + if (NPC.ai[2] == 0f) + RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); + + if (NPC.ai[2] % toothBallBelchPhaseDivisor == 0f) + { + if (NPC.ai[2] != 0f) + SoundEngine.PlaySound(VomitSound, NPC.Center); + + Vector2 toothBallDirection = Vector2.Normalize(player.Center - NPC.Center) * (NPC.width + 20) / 2f + NPC.Center; + Vector2 toothBallVelocity = Vector2.Normalize(Main.player[NPC.target].Center - NPC.Center) * toothBallFinalVelocity; + Vector2 toothBallSpawnPos = new Vector2(toothBallDirection.X, toothBallDirection.Y + 45f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int toothBall = NPC.NewNPC(NPC.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); + Main.npc[toothBall].velocity = Vector2.Normalize(toothBallVelocity) * NPC.velocity.Length(); + Main.npc[toothBall].netUpdate = true; + } + + for (int i = 0; i < 50; i++) + { + int dustID; + switch (Main.rand.Next(6)) + { + case 0: + case 1: + case 2: + case 3: + dustID = (int)CalamityDusts.SulphurousSeaAcid; + break; + default: + dustID = DustID.Blood; + break; + } + + // Choose a random speed and angle to belch out the vomit + float dustSpeed = Main.rand.NextFloat(3.0f, 12.0f); + float angleRandom = 0.06f; + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(toothBallVelocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + + // Pick a size for the vomit particles + float scale = Main.rand.NextFloat(1f, 2f); + + // Actually spawn the vomit + int idx = Dust.NewDust(toothBallSpawnPos, 40, 40, dustID, dustVel.X, dustVel.Y, 0, default, scale); + Main.dust[idx].noGravity = true; + } + } + + // Direction + int toothBallLookAt = Math.Sign(player.Center.X - NPC.Center.X); + if (toothBallLookAt != 0) + { + NPC.direction = toothBallLookAt; + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + NPC.spriteDirection = -NPC.direction; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= toothBallBelchPhaseTimer) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Call sharks from the sides of the screen + else if (NPC.ai[0] == 3f) + { + // Velocity + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); + + // Play sound and spawn sharks + if (NPC.ai[2] == attackTimer - 30) + SoundEngine.PlaySound(VomitSound, NPC.Center); + + if (NPC.ai[2] >= attackTimer - 90) + { + if (NPC.ai[2] % 18f == 0f) + { + calamityGlobalNPC.newAI[2] += 100f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + 900f), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - 900f), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + 1800f), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - 1800f), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + } + } + } + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= attackTimer) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Transition to phase 2 and call sharks from below + else if (NPC.ai[0] == 4f) + { + // Velocity + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); + + // Sound + if (NPC.ai[2] == phaseTransitionTimer - 60) + RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); + + if (NPC.ai[2] >= phaseTransitionTimer - 60) + { + if (NPC.ai[2] % 18f == 0f) + { + calamityGlobalNPC.newAI[2] += 150f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(NPC.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(NPC.Center.Y + 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(NPC.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(NPC.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + } + } + } + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= phaseTransitionTimer) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Phase 2 + else if (NPC.ai[0] == 5f && !player.dead) + { + // Velocity + if (NPC.ai[1] == 0f) + NPC.ai[1] = 500 * Math.Sign((NPC.Center - player.Center).X); + + Vector2 dukePhase2IdleSpeed = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -300f) - NPC.Center - NPC.velocity) * idlePhaseVelocity; + NPC.SimpleFlyMovement(dukePhase2IdleSpeed, idlePhaseAcceleration); + + // Direction and rotation + int phase2FaceDirection = Math.Sign(player.Center.X - NPC.Center.X); + if (phase2FaceDirection != 0) + { + if (NPC.ai[2] == 0f && phase2FaceDirection != NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.direction = phase2FaceDirection; + + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + // Phase switch + if (calamityGlobalNPC.newAI[1] != 1f || (phase3 && !phase3AI)) + { + NPC.ai[2] += 1f; + if (NPC.ai[2] >= idlePhaseTimer || (phase3 && !phase3AI)) + { + int phase2AttackPicker = 0; + switch ((int)NPC.ai[3]) + { + case 0: + case 1: + case 2: + case 3: + phase2AttackPicker = 1; + break; + case 4: + NPC.ai[3] = 1f; + phase2AttackPicker = 2; + break; + case 5: + NPC.ai[3] = 0f; + phase2AttackPicker = 3; + break; + } + + if (phase3) + phase2AttackPicker = 4; + + // Set velocity for charge + if (phase2AttackPicker == 1) + { + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + // Velocity and rotation + Vector2 distanceVector = player.Center + player.velocity * 20f - NPC.Center; + NPC.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + // Direction + if (phase2FaceDirection != 0) + { + NPC.direction = phase2FaceDirection; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + DoChargeBurst(NPC, 1); + } + + // Set velocity for spin + else if (phase2AttackPicker == 2) + { + // Velocity and rotation + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * spinAttackSpeed; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + // Direction + if (phase2FaceDirection != 0) + { + NPC.direction = phase2FaceDirection; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + else if (phase2AttackPicker == 3) + { + NPC.ai[0] = 8f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + // Go to next phase + else if (phase2AttackPicker == 4) + { + NPC.ai[0] = 9f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + NPC.netUpdate = true; + } + } + } + + // Charge + else if (NPC.ai[0] == 6f) + { + // The dumbest thing to ever exist + if (Main.zenithWorld && NPC.ai[2] % 8f == 0f) + { + // Rotation and direction + int dir = Math.Sign(player.Center.X - NPC.Center.X); + if (dir != 0) + { + if (NPC.ai[2] == 0f && dir != NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.direction = dir; + + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + Vector2 distanceVector = player.Center + player.velocity * 20f - NPC.Center; + NPC.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + // Direction + if (dir != 0) + { + NPC.direction = dir; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + } + else + { + // Accelerate + NPC.velocity *= 1.01f; + } + + DoChargeVisual(NPC, Phase); + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= chargeTime) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] += 2f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Tooth Ball and Vortex spin + else if (NPC.ai[0] == 7f) + { + // Play sounds and spawn Tooth Balls and a Vortex + if (NPC.ai[2] == 0f) + { + RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); + + SoundEngine.PlaySound(VortexSpawnSound, NPC.Center); + int type = ModContent.ProjectileType(); + Vector2 vortexSpawn = NPC.Center + NPC.velocity.RotatedBy(MathHelper.PiOver2 * -NPC.direction) * spinTime / MathHelper.TwoPi; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), vortexSpawn, Vector2.Zero, type, VortexDamage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); + } + + if (NPC.ai[2] % toothBallSpinPhaseDivisor == 0f) + { + if (NPC.ai[2] != 0f) + SoundEngine.PlaySound(VomitSound, NPC.Center); + + Vector2 phase2ToothBallDirection = Vector2.Normalize(NPC.velocity) * (NPC.width + 20) / 2f + NPC.Center; + Vector2 toothBallVelocity = Vector2.Normalize(NPC.velocity).RotatedBy(MathHelper.PiOver2 * NPC.direction) * toothBallSpinToothBallVelocity; + Vector2 toothBallSpawnPos = new Vector2(phase2ToothBallDirection.X, phase2ToothBallDirection.Y + 45f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int toothBall = NPC.NewNPC(NPC.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); + Main.npc[toothBall].target = NPC.target; + Main.npc[toothBall].velocity = Vector2.Normalize(toothBallVelocity) * toothBallSpinToothBallVelocity * 0.5f; + Main.npc[toothBall].netUpdate = true; + Main.npc[toothBall].ai[3] = 30f; + } + + for (int i = 0; i < 50; i++) + { + int dustID; + switch (Main.rand.Next(6)) + { + case 0: + case 1: + case 2: + case 3: + dustID = (int)CalamityDusts.SulphurousSeaAcid; + break; + default: + dustID = DustID.Blood; + break; + } + + // Choose a random speed and angle to belch out the vomit + float dustSpeed = Main.rand.NextFloat(3.0f, 12.0f); + float angleRandom = 0.06f; + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(toothBallVelocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + + // Pick a size for the vomit particles + float scale = Main.rand.NextFloat(1f, 2f); + + // Actually spawn the vomit + int idx = Dust.NewDust(toothBallSpawnPos, 40, 40, dustID, dustVel.X, dustVel.Y, 0, default, scale); + Main.dust[idx].noGravity = true; + } + } + + // Velocity and rotation + NPC.velocity = NPC.velocity.RotatedBy(-(double)spinSpeed * (float)NPC.direction); + NPC.rotation -= spinSpeed * NPC.direction; + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= toothBallSpinTimer) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen + else if (NPC.ai[0] == 8f) + { + // Velocity + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); + + // Play sound + if (NPC.ai[2] == attackTimer - 30) + { + SoundEngine.PlaySound(VomitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 phase2GoreDirection = NPC.rotation.ToRotationVector2() * (Vector2.UnitX * NPC.direction) * (NPC.width + 20) / 2f + NPC.Center; + int type = ModContent.ProjectileType(); + int totalGore = Main.getGoodWorld ? 40 : 20; + for (int i = 0; i < totalGore; i++) + { + float velocityX = NPC.direction * goreVelocityX * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); + float velocityY = goreVelocityY * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); + + if (Main.getGoodWorld) + { + velocityX *= Main.rand.NextFloat() + 0.5f; + velocityY *= Main.rand.NextFloat() + 0.5f; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), phase2GoreDirection.X, phase2GoreDirection.Y, velocityX, -velocityY, type, GoreDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + + if (NPC.ai[2] >= attackTimer - 90) + { + if (NPC.ai[2] % 18f == 0f) + { + calamityGlobalNPC.newAI[2] += 100f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float x = 900f - calamityGlobalNPC.newAI[2]; + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + x), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - x), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + } + } + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= attackTimer) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Transition to phase 3 and summon sharks from above + else if (NPC.ai[0] == 9f) + { + // Velocity + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); + + // Sound + if (NPC.ai[2] == phaseTransitionTimer - 60) + RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); + + if (NPC.ai[2] >= phaseTransitionTimer - 60) + { + if (NPC.ai[2] % 18f == 0f) + { + calamityGlobalNPC.newAI[2] += 200f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + 50f + calamityGlobalNPC.newAI[2]), (int)(NPC.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, 1f, sharkronVelocity, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - 50f - calamityGlobalNPC.newAI[2]), (int)(NPC.Center.Y - 540f), ModContent.NPCType(), 0, 0f, 0f, -1f, sharkronVelocity, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + 50f + calamityGlobalNPC.newAI[2] * 0.5f), (int)(NPC.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, 1f, -sharkronVelocity, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - 50f - calamityGlobalNPC.newAI[2] * 0.5f), (int)(NPC.Center.Y + 270f), ModContent.NPCType(), 0, 0f, 0f, -1f, -sharkronVelocity, 255); + } + } + } + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= phaseTransitionTimer) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Phase 3 + else if (NPC.ai[0] == 10f && !player.dead) + { + // Alpha + NPC.alpha -= 25; + if (NPC.alpha < 0) + NPC.alpha = 0; + + // Movement location + if (NPC.ai[1] == 0f) + NPC.ai[1] = 500 * Math.Sign((NPC.Center - player.Center).X); + + Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(-NPC.ai[1], -300f) - NPC.Center - NPC.velocity) * idlePhaseVelocity; + NPC.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); + + // Rotation and direction + int phase3FaceDirection = Math.Sign(player.Center.X - NPC.Center.X); + if (phase3FaceDirection != 0) + { + if (NPC.ai[2] == 0f && phase3FaceDirection != NPC.direction) + { + NPC.rotation += MathHelper.Pi; + for (int l = 0; l < NPC.oldPos.Length; l++) + NPC.oldPos[l] = Vector2.Zero; + } + + NPC.direction = phase3FaceDirection; + + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + // Phase switch + if (calamityGlobalNPC.newAI[1] != 1f) + { + NPC.ai[2] += 1f; + if (NPC.ai[2] >= idlePhaseTimer) + { + int phase3AttackPicker = 0; + switch ((int)NPC.ai[3]) + { + case 0: + case 2: + case 3: + case 5: + case 6: + case 7: + phase3AttackPicker = 1; + break; + case 1: + case 8: + phase3AttackPicker = 2; + break; + case 4: + NPC.ai[3] = 1f; + phase3AttackPicker = 3; + break; + case 9: + NPC.ai[3] = 6f; + phase3AttackPicker = 4; + break; + } + + // Set velocity for charge + if (phase3AttackPicker == 1) + { + NPC.ai[0] = 11f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + // Velocity and rotation + Vector2 distanceVector = player.Center + player.velocity * 20f - NPC.Center; + NPC.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + // Direction + if (phase3FaceDirection != 0) + { + NPC.direction = phase3FaceDirection; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + DoChargeBurst(NPC, 2); + } + + // Pause + else if (phase3AttackPicker == 2) + { + NPC.ai[0] = 12f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + else if (phase3AttackPicker == 3) + { + NPC.ai[0] = 13f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + // Set velocity for spin + else if (phase3AttackPicker == 4) + { + // Velocity and rotation + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * spinAttackSpeed; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + // Direction + if (phase3FaceDirection != 0) + { + NPC.direction = phase3FaceDirection; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + NPC.ai[0] = 14f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + NPC.netUpdate = true; + } + } + } + + // Charge + else if (NPC.ai[0] == 11f) + { + // The dumbest thing to ever exist + if (Main.zenithWorld && NPC.ai[2] % 6f == 0f) + { + // Rotation and direction + int dir = Math.Sign(player.Center.X - NPC.Center.X); + if (dir != 0) + { + if (NPC.ai[2] == 0f && dir != NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.direction = dir; + + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + + Vector2 distanceVector = player.Center + player.velocity * 20f - NPC.Center; + NPC.velocity = Vector2.Normalize(distanceVector) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + + // Direction + if (dir != 0) + { + NPC.direction = dir; + + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + } + else + { + // Accelerate + NPC.velocity *= 1.01f; + } + + DoChargeVisual(NPC, Phase); + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= chargeTime) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] += 2f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Pause before teleport + else if (NPC.ai[0] == 12f) + { + // Disable contact damage during the teleporting phase + NPC.damage = 0; + + // Alpha + if (NPC.alpha < 255 && NPC.ai[2] >= teleportPauseTimer - 15f) + { + NPC.alpha += 17; + if (NPC.alpha > 255) + NPC.alpha = 255; + } + + // Velocity + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); + + // Play sound + if (NPC.ai[2] == teleportPauseTimer / 2) + RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == teleportPauseTimer - 1f) + { + // Teleport location + if (NPC.ai[1] == 0f) + NPC.ai[1] = 600 * Math.Sign((NPC.Center - player.Center).X); + + // Rotation and direction + Vector2 center = player.Center + new Vector2(NPC.ai[1], -300f); + Vector2 npcCenter = NPC.Center = center; + int phase3TeleportFaceDirection = Math.Sign(player.Center.X - npcCenter.X); + if (phase3TeleportFaceDirection != 0) + { + if (NPC.ai[2] == 0f && phase3TeleportFaceDirection != NPC.direction) + { + NPC.rotation += MathHelper.Pi; + for (int n = 0; n < NPC.oldPos.Length; n++) + NPC.oldPos[n] = Vector2.Zero; + } + + NPC.direction = phase3TeleportFaceDirection; + + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + + NPC.spriteDirection = -NPC.direction; + } + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= teleportPauseTimer) + { + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + + NPC.ai[3] += 2f; + if (NPC.ai[3] >= 9f) + NPC.ai[3] = 0f; + + NPC.netUpdate = true; + } + } + + // Vomit a huge amount of gore into the sky and call sharks from the sides of the screen + else if (NPC.ai[0] == 13f) + { + // Velocity + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); + + // Play sound + if (NPC.ai[2] == attackTimer - 30) + { + SoundEngine.PlaySound(VomitSound, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 phase3GoreDirection = NPC.rotation.ToRotationVector2() * (Vector2.UnitX * NPC.direction) * (NPC.width + 20) / 2f + NPC.Center; + int type = ModContent.ProjectileType(); + int totalGore = Main.getGoodWorld ? 40 : 20; + for (int i = 0; i < totalGore; i++) + { + float velocityX = NPC.direction * goreVelocityX * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); + float velocityY = goreVelocityY * (Main.rand.NextFloat(0.2f, 0.8f) + 0.5f); + + if (Main.getGoodWorld) + { + velocityX *= Main.rand.NextFloat() + 0.5f; + velocityY *= Main.rand.NextFloat() + 0.5f; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), phase3GoreDirection.X, phase3GoreDirection.Y, velocityX, -velocityY, type, GoreDamage, 0f, Main.myPlayer, 0f, 0f); + } + } + } + + if (NPC.ai[2] >= attackTimer - 90) + { + if (NPC.ai[2] % 18f == 0f) + { + calamityGlobalNPC.newAI[2] += 150f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float x = 900f - calamityGlobalNPC.newAI[2]; + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + x), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - x), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2]), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + + if (Main.getGoodWorld) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X + x), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X - x), (int)(NPC.Center.Y - calamityGlobalNPC.newAI[2] * 0.5f), ModContent.NPCType(), 0, 0f, 0f, NPC.whoAmI, 0f, 255); + } + } + } + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= attackTimer) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + // Tooth Ball and Vortex spin + else if (NPC.ai[0] == 14f) + { + // Play sounds and spawn Tooth Balls and a Vortex + if (NPC.ai[2] == 0f) + { + RoarSoundSlot = SoundEngine.PlaySound(RoarSound, NPC.Center); + + SoundEngine.PlaySound(VortexSpawnSound, NPC.Center); + int type = ModContent.ProjectileType(); + Vector2 vortexSpawn = NPC.Center + NPC.velocity.RotatedBy(MathHelper.PiOver2 * -NPC.direction) * spinTime / MathHelper.TwoPi; + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), vortexSpawn, Vector2.Zero, type, VortexDamage, 0f, Main.myPlayer, vortexSpawn.X, vortexSpawn.Y); + } + + if (NPC.ai[2] % toothBallSpinPhaseDivisor == 0f) + { + if (NPC.ai[2] != 0f) + SoundEngine.PlaySound(VomitSound, NPC.Center); + + Vector2 phase3ToothBallDirection = Vector2.Normalize(NPC.velocity) * (NPC.width + 20) / 2f + NPC.Center; + Vector2 toothBallVelocity = Vector2.Normalize(NPC.velocity).RotatedBy(MathHelper.PiOver2 * NPC.direction) * toothBallSpinToothBallVelocity; + Vector2 toothBallSpawnPos = new Vector2(phase3ToothBallDirection.X, phase3ToothBallDirection.Y + 45f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int toothBall = NPC.NewNPC(NPC.GetSource_FromAI(), (int)toothBallSpawnPos.X, (int)toothBallSpawnPos.Y, ModContent.NPCType(), 0, toothBallVelocity.X, toothBallVelocity.Y); + Main.npc[toothBall].target = NPC.target; + Main.npc[toothBall].velocity = Vector2.Normalize(toothBallVelocity) * toothBallSpinToothBallVelocity * 0.5f; + Main.npc[toothBall].netUpdate = true; + Main.npc[toothBall].ai[3] = 60f; + } + + for (int i = 0; i < 50; i++) + { + int dustID; + switch (Main.rand.Next(6)) + { + case 0: + case 1: + case 2: + case 3: + dustID = (int)CalamityDusts.SulphurousSeaAcid; + break; + default: + dustID = DustID.Blood; + break; + } + + // Choose a random speed and angle to belch out the vomit + float dustSpeed = Main.rand.NextFloat(3.0f, 12.0f); + float angleRandom = 0.06f; + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(toothBallVelocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + + // Pick a size for the vomit particles + float scale = Main.rand.NextFloat(1f, 2f); + + // Actually spawn the vomit + int idx = Dust.NewDust(toothBallSpawnPos, 40, 40, dustID, dustVel.X, dustVel.Y, 0, default, scale); + Main.dust[idx].noGravity = true; + } + } + + // Velocity and rotation + NPC.velocity = NPC.velocity.RotatedBy(-(double)spinSpeed * NPC.direction); + NPC.rotation -= spinSpeed * NPC.direction; + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= toothBallSpinTimer) + { + calamityGlobalNPC.newAI[0] += exhaustionIncreasePerAttack; + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.TargetClosest(); + NPC.netUpdate = true; + } + } + + if (SoundEngine.TryGetActiveSound(RoarSoundSlot, out var roarSound) && roarSound.IsPlaying) + roarSound.Position = NPC.Center; } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void ModifyTypeName(ref string typeName) @@ -206,10 +1847,23 @@ namespace CalamityMod.NPCs.OldDuke NPC.frame.Y = frameHeight * 6; } } + + if (NPC.ai[0] == -1f) + { + if (NPC.ai[2] >= 75f) + NPC.frame.Y = frameHeight * 6; + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + Color finalDrawColor = Color.Lerp(drawColor, Color.White, NuclearOverlayVisual); + Color overlayDrawColor = Color.Lerp(Color.Transparent, Color.LimeGreen.MultiplyRGBA(new Color(255, 255, 255, 0)), NuclearOverlayVisual); + finalDrawColor = Color.Lerp(finalDrawColor, Color.LimeGreen.MultiplyRGBA(new Color(255, 255, 255, 0)), NuclearOverlayVisual); + + finalDrawColor = Color.Lerp(finalDrawColor, Color.Transparent, (float)NPC.alpha / 255f); + overlayDrawColor = Color.Lerp(overlayDrawColor, Color.Transparent, (float)NPC.alpha / 255f); + SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) { @@ -265,6 +1919,7 @@ namespace CalamityMod.NPCs.OldDuke { Color afterimageColor = color; afterimageColor = Color.Lerp(afterimageColor, drawLerpColor, drawLerpValue); + afterimageColor = Color.Lerp(afterimageColor, overlayDrawColor, NuclearOverlayVisual); afterimageColor = NPC.GetAlpha(afterimageColor); afterimageColor *= (afterimageAmt - i) / 15f; Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; @@ -279,9 +1934,7 @@ namespace CalamityMod.NPCs.OldDuke float afterimageScale = 0f; if (NPC.ai[0] == -1f) - { secondAfterimageAmt = 0; - } if (NPC.ai[0] == 3f || NPC.ai[0] == 8f || NPC.ai[0] == 13f) { @@ -314,10 +1967,7 @@ namespace CalamityMod.NPCs.OldDuke { for (int j = 0; j < secondAfterimageAmt; j++) { - Color secondAfterimageColor = drawColor; - secondAfterimageColor = Color.Lerp(secondAfterimageColor, drawLerpColor, drawLerpValue); - secondAfterimageColor = NPC.GetAlpha(secondAfterimageColor); - secondAfterimageColor *= 1f - afterimageOpacity; + Color secondAfterimageColor = Color.Lerp(finalDrawColor, Color.Transparent, (float)j / (float)secondAfterimageAmt); Vector2 secondAfterimagePos = NPC.Center + (j / (float)secondAfterimageAmt * MathHelper.TwoPi + NPC.rotation).ToRotationVector2() * afterimageScale * afterimageOpacity - screenPos; secondAfterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; secondAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); @@ -325,13 +1975,18 @@ namespace CalamityMod.NPCs.OldDuke } } - Color finalDrawColor = drawColor; - finalDrawColor = Color.Lerp(finalDrawColor, drawLerpColor, drawLerpValue); - finalDrawColor = NPC.GetAlpha(finalDrawColor); Vector2 drawLocation = NPC.Center - screenPos; drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, (NPC.ai[0] > 9f ? finalDrawColor : NPC.GetAlpha(drawColor)), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + drawLocation += new Vector2(Main.rand.NextFloat(-shake, shake), Main.rand.NextFloat(-shake, shake)); + + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(finalDrawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(overlayDrawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + + float auraOutset = 6f + (float)(Math.Sin(VisualTimerSystem.GlobalVisualTimer / 10f) * 10f); + for (float i = 0f; i < 360f; i += 90f) + spriteBatch.Draw(texture2D15, drawLocation + new Vector2(auraOutset, 0).RotatedBy(MathHelper.ToRadians(i)), NPC.frame, NPC.GetAlpha(overlayDrawColor.MultiplyRGBA(new Color(0.4f, 0.4f, 0.4f, 0.4f))), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); if (NPC.ai[0] >= 4f && NPC.Calamity().newAI[1] != 1f) { @@ -398,7 +2053,7 @@ namespace CalamityMod.NPCs.OldDuke return false; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -411,7 +2066,7 @@ namespace CalamityMod.NPCs.OldDuke CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedBoomerDuke); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedBoomerDuke); // Mark Old Duke as dead DownedBossSystem.downedBoomerDuke = true; @@ -443,7 +2098,8 @@ namespace CalamityMod.NPCs.OldDuke normalOnly.Add(ModContent.ItemType(), 10); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -456,7 +2112,7 @@ namespace CalamityMod.NPCs.OldDuke npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Shattered Community drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedBoomerDuke, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -472,7 +2128,8 @@ namespace CalamityMod.NPCs.OldDuke { if (hurtInfo.Damage > 0) { - target.AddBuff(ModContent.BuffType(), 480); + target.AddBuff(ModContent.BuffType(), Phase == 2 ? 600 : Phase == 1 ? 480 : 360); + target.AddBuff(ModContent.BuffType(), Phase == 2 ? 300 : Phase == 1 ? 240 : 180); if (Main.zenithWorld) { target.AddBuff(BuffID.Rabies, Main.rand.Next(180, 601)); @@ -484,12 +2141,6 @@ namespace CalamityMod.NPCs.OldDuke { if (NPC.life > 0) { - int onHitDust = 0; - while (onHitDust < hit.Damage / NPC.lifeMax * 100.0) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulphurousSeaAcid, hit.HitDirection, -1f, 0, default, 1f); - onHitDust++; - } } else { diff --git a/NPCs/OldDuke/OldDukeToothBall.cs b/NPCs/OldDuke/OldDukeToothBall.cs index be2fa69fef..12edf3649d 100644 --- a/NPCs/OldDuke/OldDukeToothBall.cs +++ b/NPCs/OldDuke/OldDukeToothBall.cs @@ -1,10 +1,12 @@ using System; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,12 +20,15 @@ namespace CalamityMod.NPCs.OldDuke this.HideFromBestiary(); } + public static int ToothDamage = 55; // 220 + public static int CloudDamage = 70; // 280 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 120; // 240 NPC.aiStyle = -1; AIType = -1; - NPC.GetNPCDamage(); NPC.width = 40; NPC.height = 40; NPC.defense = 0; @@ -42,20 +47,15 @@ namespace CalamityMod.NPCs.OldDuke NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() { Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 0.65f, 0.55f, 0f); - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; NPC.rotation += NPC.velocity.X * 0.05f; @@ -114,7 +114,7 @@ namespace CalamityMod.NPCs.OldDuke float velocity = death ? 14f : revenge ? 13f : 12f; if (expertMode) { - float speedUpMult = bossRush ? 0.01f : 0.005f; + float speedUpMult = 0.005f; velocity += Vector2.Distance(player.Center, NPC.Center) * speedUpMult; } @@ -144,7 +144,7 @@ namespace CalamityMod.NPCs.OldDuke NPC.velocity.X = (NPC.velocity.X * inertia + targetXDist) / (inertia + 1f); NPC.velocity.Y = (NPC.velocity.Y * inertia + targetYDist) / (inertia + 1f); - float toothBallAccel = bossRush ? 0.65f : 0.5f; + float toothBallAccel = 0.5f; foreach (var n in Main.ActiveNPCs) { if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) @@ -167,6 +167,15 @@ namespace CalamityMod.NPCs.OldDuke public override void OnKill() { + for (int i = 0; i < 15; i++) + { + float sc = Main.rand.NextFloat(1f, 3f); + Vector2 vel = new Vector2(Main.rand.NextFloat(10, 25), 0).RotatedByRandom(MathHelper.TwoPi); + + GeneralParticleHandler.SpawnParticle(new CustomSpark(NPC.Center, vel, "CalamityMod/Projectiles/Boss/OldDukeToothBallSpike", true, 40, sc + 0.5f, OldDuke.GlowColor, Vector2.One)); + GeneralParticleHandler.SpawnParticle(new CustomSpark(NPC.Center, vel, "CalamityMod/Projectiles/Boss/OldDukeToothBallSpike", true, 40, sc, Color.White, Vector2.One, false, affectedByLight: true)); + } + int closestPlayer = Player.FindClosest(NPC.Center, 1, 1); if (Main.rand.NextBool(8) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); @@ -176,7 +185,6 @@ namespace CalamityMod.NPCs.OldDuke int totalProjectiles = CalamityWorld.death ? 5 : CalamityWorld.revenge ? 4 : 3; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); float velocity = 10f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; @@ -185,14 +193,13 @@ namespace CalamityMod.NPCs.OldDuke for (int k = 0; k < totalProjectiles; k++) { Vector2 toothSpikeRotation = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, toothSpikeRotation * 0.1f, type, damage, 0f, Main.myPlayer, toothSpikeRotation.X, toothSpikeRotation.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, toothSpikeRotation * 0.1f, type, ToothDamage, 0f, Main.myPlayer, toothSpikeRotation.X, toothSpikeRotation.Y); } if (Main.expertMode) { type = ModContent.ProjectileType(); - damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, CloudDamage, 0f, Main.myPlayer); } } @@ -204,26 +211,42 @@ namespace CalamityMod.NPCs.OldDuke int type = ModContent.ProjectileType(); for (int i = 0; i < 2; i++) Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center.X + Main.rand.Next(-spawnX, spawnX), NPC.Center.Y, - Main.rand.Next(-1, 2), Main.rand.Next(-6, -3), type, NPC.damage / 2, 0f, Main.myPlayer); + Main.rand.Next(-1, 2), Main.rand.Next(-6, -3), type, OldDuke.GoreDamage, 0f, Main.myPlayer); } } } - public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment)/* tModPorter Note: bossLifeScale -> balance (bossAdjustment is different, see the docs for details) */ - { - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = ImmunityCooldownID.Bosses; return true; } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 240); + float velDist = NPC.velocity.Length(); + + Vector2 vel = NPC.velocity; + vel.Normalize(); + + if (velDist > 5) + { + float sc = velDist - 5; + if (Main.rand.NextBool(3)) + GeneralParticleHandler.SpawnParticle(new SparkParticle(NPC.Center + new Vector2(Main.rand.NextFloat(5, 30), 0).RotatedBy(Main.rand.NextFloat(MathHelper.TwoPi)), NPC.velocity, false, 20, Main.rand.NextFloat(0.5f, 1.5f), OldDuke.GlowColor, true)); + } + + if (Main.rand.NextBool(3)) + GeneralParticleHandler.SpawnParticle(new MediumMistParticle(NPC.Center, -(vel * 4f).RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), OldDuke.GlowColor, Color.DarkSlateGray, Main.rand.NextFloat(0.5f, 1.5f), 150f)); + + Asset tex = ModContent.Request(Texture); + for (int i = 0; i < 360; i += 90) + { + Main.EntitySpriteDraw(tex.Value, NPC.Center + new Vector2(0, 4) - Main.screenPosition + new Vector2(4, 0).RotatedBy(MathHelper.ToRadians(i)), tex.Frame(), OldDuke.GlowColor, NPC.rotation, tex.Frame().Center(), NPC.scale, SpriteEffects.None); + Main.EntitySpriteDraw(tex.Value, NPC.Center + new Vector2(0, 4) - Main.screenPosition + new Vector2(8, 0).RotatedBy(MathHelper.ToRadians(i)), tex.Frame(), OldDuke.GlowColor, NPC.rotation, tex.Frame().Center(), NPC.scale, SpriteEffects.None); + } + + return base.PreDraw(spriteBatch, screenPos, drawColor); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/OldDuke/SulphurousSharkron.cs b/NPCs/OldDuke/SulphurousSharkron.cs index fd999977ae..dc51b1a0f1 100644 --- a/NPCs/OldDuke/SulphurousSharkron.cs +++ b/NPCs/OldDuke/SulphurousSharkron.cs @@ -1,7 +1,6 @@ using System; using System.IO; using CalamityMod.BiomeManagers; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; @@ -11,7 +10,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.GameContent; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -28,11 +26,11 @@ namespace CalamityMod.NPCs.OldDuke public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 120; // 240 NPC.aiStyle = -1; AIType = -1; NPC.width = 44; NPC.height = 44; - NPC.GetNPCDamage(); NPC.defense = 100; NPC.lifeMax = 6000; if (BossRushEvent.BossRushActive) @@ -52,10 +50,6 @@ namespace CalamityMod.NPCs.OldDuke NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SendExtraAI(BinaryWriter writer) @@ -74,10 +68,9 @@ namespace CalamityMod.NPCs.OldDuke { Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 0.7f * NPC.Opacity, 0.9f * NPC.Opacity, 0f); - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) { @@ -106,12 +99,12 @@ namespace CalamityMod.NPCs.OldDuke // Fly up bool upwardAI = NPC.ai[3] < 0f; - float flyTowardTargetGateValue = bossRush ? 60f : death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; - float extraTime = bossRush ? 60f : death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; + float flyTowardTargetGateValue = death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; + float extraTime = death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; float aiGateValue = flyTowardTargetGateValue + extraTime; float dieGateValue = aiGateValue + extraTime * 4f; float fallDownGateValue = aiGateValue + extraTime; - float maxVelocity = bossRush ? 22f : death ? 20f : revenge ? 19f : expertMode ? 18f : 16f; + float maxVelocity = death ? 20f : revenge ? 19f : expertMode ? 18f : 16f; if (NPC.ai[0] == 0f) { @@ -146,7 +139,7 @@ namespace CalamityMod.NPCs.OldDuke Vector2 targetDistance = Main.player[NPC.target].Center - NPC.Center; targetDistance.Normalize(); targetDistance *= scaleFactor2; - float inertia = bossRush ? 20f : death ? 23f : revenge ? 25f : expertMode ? 27f : 30f; + float inertia = death ? 23f : revenge ? 25f : expertMode ? 27f : 30f; NPC.velocity = (NPC.velocity * (inertia - 1f) + targetDistance) / inertia; NPC.velocity.Normalize(); NPC.velocity *= scaleFactor2; @@ -216,20 +209,14 @@ namespace CalamityMod.NPCs.OldDuke { int spawnX = NPC.width / 2; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); for (int i = 0; i < 10; i++) { Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X + Main.rand.Next(-spawnX, spawnX), NPC.Center.Y, - Main.rand.Next(-3, 4), Main.rand.Next(-12, -6), type, damage, 0f, Main.myPlayer); + Main.rand.Next(-3, 4), Main.rand.Next(-12, -6), type, OldDuke.GoreDamage, 0f, Main.myPlayer); } } } - public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment)/* tModPorter Note: bossLifeScale -> balance (bossAdjustment is different, see the docs for details) */ - { - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { if (NPC.IsABestiaryIconDummy) @@ -251,6 +238,7 @@ namespace CalamityMod.NPCs.OldDuke afterimageColor = Color.Lerp(afterimageColor, Color.Lime, 0.5f); afterimageColor = NPC.GetAlpha(afterimageColor); afterimageColor *= (afterimageAmt - i) / 15f; + afterimageColor.A = 0; Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); @@ -272,12 +260,6 @@ namespace CalamityMod.NPCs.OldDuke return NPC.Opacity == 1f; } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 240); - } - public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) diff --git a/NPCs/Other/CalamitasEnchantDemon.cs b/NPCs/Other/CalamitasEnchantDemon.cs index 831470fdd5..510e271faf 100644 --- a/NPCs/Other/CalamitasEnchantDemon.cs +++ b/NPCs/Other/CalamitasEnchantDemon.cs @@ -30,10 +30,9 @@ namespace CalamityMod.NPCs.Other NPC.DeathSound = SoundID.NPCDeath18; NPC.noGravity = true; NPC.noTileCollide = true; - NPC.value = 0f; NPC.knockBackResist = 0f; NPC.netAlways = true; - NPC.aiStyle = 0; + NPC.aiStyle = NPCAIStyleID.FaceClosestPlayer; NPC.Calamity().DoesNotDisappearInBossRush = true; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; diff --git a/NPCs/Other/DemonPortal.cs b/NPCs/Other/DemonPortal.cs index 4c870617d8..bef1ccef69 100644 --- a/NPCs/Other/DemonPortal.cs +++ b/NPCs/Other/DemonPortal.cs @@ -25,7 +25,6 @@ namespace CalamityMod.NPCs.Other NPC.lifeMax = 25000; NPC.noGravity = true; NPC.noTileCollide = true; - NPC.value = 0f; NPC.knockBackResist = 0f; NPC.netAlways = true; NPC.aiStyle = -1; diff --git a/NPCs/Other/ExhumedHeart.cs b/NPCs/Other/ExhumedHeart.cs index dd0a285bbe..d123d5aebe 100644 --- a/NPCs/Other/ExhumedHeart.cs +++ b/NPCs/Other/ExhumedHeart.cs @@ -32,7 +32,6 @@ namespace CalamityMod.NPCs.Other NPC.lifeMax = 50000; NPC.noGravity = true; NPC.noTileCollide = true; - NPC.value = 0f; NPC.HitSound = SoundID.NPCHit13; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0f; diff --git a/NPCs/Other/LecherousOrb.cs b/NPCs/Other/LecherousOrb.cs index 5d6d4e7e7d..78e0da2ce6 100644 --- a/NPCs/Other/LecherousOrb.cs +++ b/NPCs/Other/LecherousOrb.cs @@ -33,7 +33,6 @@ namespace CalamityMod.NPCs.Other NPC.lifeMax = 180000; NPC.noGravity = true; NPC.noTileCollide = true; - NPC.value = 0f; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath7; NPC.knockBackResist = 0f; @@ -98,7 +97,7 @@ namespace CalamityMod.NPCs.Other { for (int i = 0; i < 3; i++) { - Dust magic = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(12f, 12f), 264); + Dust magic = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(12f, 12f), DustID.PortalBoltTrail); magic.color = Color.Red; magic.velocity = Main.rand.NextVector2Circular(3f, 3f); magic.fadeIn = 0.9f; @@ -110,7 +109,7 @@ namespace CalamityMod.NPCs.Other { for (int i = 0; i < 15; i++) { - Dust magic = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(12f, 12f), 264); + Dust magic = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(12f, 12f), DustID.PortalBoltTrail); magic.color = Color.Red; magic.velocity = Main.rand.NextVector2Circular(6f, 6f); magic.fadeIn = 1.25f; diff --git a/NPCs/Other/THELORDE.cs b/NPCs/Other/THELORDE.cs index 360e1a19fa..3db309786d 100644 --- a/NPCs/Other/THELORDE.cs +++ b/NPCs/Other/THELORDE.cs @@ -3,9 +3,8 @@ using System.IO; using CalamityMod.Balancing; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Pets; -using CalamityMod.Items.Potions; +using CalamityMod.Items.Potions.Food; using CalamityMod.Projectiles.Boss; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -63,7 +62,7 @@ namespace CalamityMod.NPCs.Other NPC.defense = 100; NPC.lifeMax = 2500000; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(100, 0, 0, 0); + NPC.value = Item.buyPrice(platinum: 100); NPC.HitSound = SoundID.NPCHit13; NPC.DeathSound = null; NPC.boss = true; @@ -501,7 +500,7 @@ namespace CalamityMod.NPCs.Other { string key = "Mods.CalamityMod.Status.Boss.EdgyBossText8"; Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); // The hit which triggers antibutcher has its damage capped at 1, then THE LORDE heals for 1 so that it doesn't take any net damage. modifiers.SetMaxDamage(1); @@ -521,7 +520,7 @@ namespace CalamityMod.NPCs.Other { string key = "Mods.CalamityMod.Status.Boss.EdgyBossText8"; Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); // The hit which triggers antibutcher has its damage capped at 1, then THE LORDE heals for 1 so that it doesn't take any net damage. modifiers.SetMaxDamage(1); @@ -584,8 +583,7 @@ namespace CalamityMod.NPCs.Other public override void ModifyNPCLoot(NPCLoot npcLoot) { double pisquaredover6 = Math.Pow(MathHelper.Pi, 2) / 6; - npcLoot.AddIf(() => CalamityWorld.LegendaryMode && CalamityWorld.revenge, ModContent.ItemType()); // guaranteed in legendarev mode - npcLoot.AddIf(() => !(CalamityWorld.LegendaryMode && CalamityWorld.revenge), ModContent.ItemType(), 27); // otherwise 1 in 27 + npcLoot.Add(ModContent.ItemType()); npcLoot.Add(ModContent.ItemType(), 1, 22, (int)(pisquaredover6 * 100)); } } diff --git a/NPCs/Perforator/PerforatorBodyLarge.cs b/NPCs/Perforator/PerforatorBodyLarge.cs index 2154470e3a..4b13c70103 100644 --- a/NPCs/Perforator/PerforatorBodyLarge.cs +++ b/NPCs/Perforator/PerforatorBodyLarge.cs @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(PerforatorHeadLarge))] public class PerforatorBodyLarge : ModNPC { @@ -38,12 +39,12 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 20; // 40 NPC.width = 60; NPC.height = 60; NPC.defense = 8; - NPC.LifeMaxNERB(2700, 3240, 80000); + NPC.LifeMaxNERB(2000, 2600, 80000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -59,9 +60,7 @@ namespace CalamityMod.NPCs.Perforator NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -71,10 +70,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -106,13 +101,6 @@ namespace CalamityMod.NPCs.Perforator NPC.active = false; } - if (Main.npc[(int)NPC.ai[1]].alpha < 128) - { - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - } - if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -153,19 +141,30 @@ namespace CalamityMod.NPCs.Perforator NPC.spriteDirection = -1; } - // Calculate contact damage based on velocity - float maxChaseSpeed = 16f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) + if (Main.npc[(int)NPC.ai[1]].alpha >= 85) { - NPC.damage = 0; + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } - else + else if (NPC.alpha > 0) { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } } diff --git a/NPCs/Perforator/PerforatorBodyMedium.cs b/NPCs/Perforator/PerforatorBodyMedium.cs index a15339120e..4494237d73 100644 --- a/NPCs/Perforator/PerforatorBodyMedium.cs +++ b/NPCs/Perforator/PerforatorBodyMedium.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -15,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(PerforatorHeadMedium))] public class PerforatorBodyMedium : ModNPC { @@ -35,13 +35,13 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 14; // 28 NPC.npcSlots = 5f; NPC.width = 40; NPC.height = 40; NPC.defense = 6; - NPC.LifeMaxNERB(180, 216, 7000); + NPC.LifeMaxNERB(130, 170, 7000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -57,9 +57,7 @@ namespace CalamityMod.NPCs.Perforator NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -71,14 +69,12 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() { + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + NPC.realLife = -1; // Target @@ -88,13 +84,6 @@ namespace CalamityMod.NPCs.Perforator if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - if (Main.npc[(int)NPC.ai[1]].alpha < 128) - { - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - } - if (Main.netMode != NetmodeID.MultiplayerClient) { if (NPC.ai[0] == 0f) @@ -110,8 +99,16 @@ namespace CalamityMod.NPCs.Perforator } // Splitting effect + bool spawnedBlob = false; if (!Main.npc[(int)NPC.ai[1]].active && !Main.npc[(int)NPC.ai[0]].active) { + if (death) + { + spawnedBlob = true; + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Main.rand.NextVector2CircularEdge(3f, 3f), type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer, 0f, NPC.Center.Y); + } + NPC.life = 0; NPC.HitEffect(0, 10.0); NPC.checkDead(); @@ -120,6 +117,13 @@ namespace CalamityMod.NPCs.Perforator } if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPC.aiStyle) { + if (death && !spawnedBlob) + { + spawnedBlob = true; + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Main.rand.NextVector2CircularEdge(3f, 3f), type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer, 0f, NPC.Center.Y); + } + NPC.type = ModContent.NPCType(); int whoAmI = NPC.whoAmI; float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -128,11 +132,18 @@ namespace CalamityMod.NPCs.Perforator NPC.life = (int)(NPC.lifeMax * lifeRatio); NPC.ai[0] = ai0; NPC.TargetClosest(true); - NPC.netUpdate = true; + NPC.ForceNetUpdate(); NPC.whoAmI = whoAmI; + NPC.alpha = 0; } if (!Main.npc[(int)NPC.ai[0]].active || Main.npc[(int)NPC.ai[0]].aiStyle != NPC.aiStyle) { + if (death && !spawnedBlob) + { + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Main.rand.NextVector2CircularEdge(3f, 3f), type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer, 0f, NPC.Center.Y); + } + int whoAmI2 = NPC.whoAmI; float otherLifeRatio = NPC.life / (float)NPC.lifeMax; float ai1 = NPC.ai[1]; @@ -140,8 +151,9 @@ namespace CalamityMod.NPCs.Perforator NPC.life = (int)(NPC.lifeMax * otherLifeRatio); NPC.ai[1] = ai1; NPC.TargetClosest(true); - NPC.netUpdate = true; + NPC.ForceNetUpdate(); NPC.whoAmI = whoAmI2; + NPC.alpha = 0; } if (!NPC.active && Main.dedServ) @@ -184,20 +196,30 @@ namespace CalamityMod.NPCs.Perforator NPC.position.Y += targetY; } - // Calculate contact damage based on velocity - // This worm requires more velocity to deal damage with the body because it doesn't have spikes or metal bits or etc. - float maxChaseSpeed = 16f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.4f; - float minimalDamageVelocity = maxChaseSpeed * 0.8f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) + if (Main.npc[(int)NPC.ai[1]].alpha >= 85) { - NPC.damage = 0; + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.NextBool() ? DustID.Ichor : DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } - else + else if (NPC.alpha > 0) { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } } @@ -237,15 +259,14 @@ namespace CalamityMod.NPCs.Perforator if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.UnitY, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.UnitY, type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer); for (int i = -1; i < 2; i++) //releases 3 Ichor Shots { int type2 = ModContent.ProjectileType(); Vector2 baseVelocity = Vector2.UnitY * Main.rand.NextFloat(-12.5f, -5f); int spread = Main.rand.Next(16, 36); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread * i)), type2, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread * i)), type2, PerforatorHive.IchorShotDamage, 0f, Main.myPlayer); } } } @@ -273,7 +294,9 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + { + target.AddBuff(BuffID.Ichor, 240); + } } } } diff --git a/NPCs/Perforator/PerforatorBodySmall.cs b/NPCs/Perforator/PerforatorBodySmall.cs index 552626f6b9..d28c0259f5 100644 --- a/NPCs/Perforator/PerforatorBodySmall.cs +++ b/NPCs/Perforator/PerforatorBodySmall.cs @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(PerforatorHeadSmall))] public class PerforatorBodySmall : ModNPC { @@ -33,12 +34,12 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 12; // 24 NPC.width = 42; NPC.height = 42; NPC.defense = 4; - NPC.LifeMaxNERB(1200, 1440, 50000); + NPC.LifeMaxNERB(900, 1150, 50000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -54,9 +55,7 @@ namespace CalamityMod.NPCs.Perforator NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -66,10 +65,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -101,13 +96,6 @@ namespace CalamityMod.NPCs.Perforator NPC.active = false; } - if (Main.npc[(int)NPC.ai[1]].alpha < 128) - { - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - } - if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -148,20 +136,30 @@ namespace CalamityMod.NPCs.Perforator NPC.spriteDirection = -1; } - // Calculate contact damage based on velocity - // This worm requires more velocity to deal damage with the body because it doesn't have spikes or metal bits or etc. - float maxChaseSpeed = 16f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.4f; - float minimalDamageVelocity = maxChaseSpeed * 0.8f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) + if (Main.npc[(int)NPC.ai[1]].alpha >= 85) { - NPC.damage = 0; + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } - else + else if (NPC.alpha > 0) { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } } @@ -214,7 +212,7 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90, true); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index af7e943b92..9b872ecaba 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -12,11 +12,13 @@ using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { [AutoloadBossHead] + [HasPierceResist] [LongDistanceNetSync] public class PerforatorHeadLarge : ModNPC { @@ -24,8 +26,6 @@ namespace CalamityMod.NPCs.Perforator public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/PerfLargeDeath"); public static Asset GlowTexture; - - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private bool TailSpawned = false; public override void SetStaticDefaults() @@ -47,17 +47,20 @@ namespace CalamityMod.NPCs.Perforator } } + // GFB exclusive + public static int LaserWallDamage = 10; // 40 + public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 40; // 80 NPC.npcSlots = 5f; NPC.width = 70; NPC.height = 84; NPC.defense = 4; - NPC.LifeMaxNERB(2700, 3240, 80000); + NPC.LifeMaxNERB(2000, 2600, 80000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -72,9 +75,7 @@ namespace CalamityMod.NPCs.Perforator NPC.DeathSound = DeathSound; NPC.netAlways = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -84,10 +85,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -105,24 +102,21 @@ namespace CalamityMod.NPCs.Perforator public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); } public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -134,43 +128,102 @@ namespace CalamityMod.NPCs.Perforator Player player = Main.player[NPC.target]; - // Enrage - if ((!player.ZoneCrimson || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - - float enrageScale = bossRush ? 1f : 0f; - if (biomeEnraged && (!player.ZoneCrimson || bossRush)) - enrageScale += 1f; - if (biomeEnraged && ((NPC.position.Y / 16f) < Main.worldSurface || bossRush)) - enrageScale += 1f; - // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = 0.09f; - float turnSpeed = 0.06f; + float speed = 0.1f; + float turnSpeed = 0.07f; if (expertMode) { - float velocityScale = (death ? 0.12f : 0.1f) * enrageScale; + float velocityScale = death ? 0.1f : 0.07f; speed += velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.12f : 0.1f) * enrageScale; + float accelerationScale = death ? 0.07f : 0.05f; turnSpeed += accelerationScale * (1f - lifeRatio); } if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; + // Spit attack in Rev + // Spit ichor blobs in Death + float spitDistance = 960f; + float tooCloseToSpitDistance = 320f; + bool isInRangeToSpit = NPC.Distance(player.Center) <= spitDistance && NPC.Distance(player.Center) > tooCloseToSpitDistance; + bool headIsTurnedTowardsTarget = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation(); + bool canHitTarget = Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + bool alwaysAbleToSpit = NPC.Calamity().newAI[1] == 1f; + bool canSpit = (isInRangeToSpit && headIsTurnedTowardsTarget && canHitTarget) || alwaysAbleToSpit; + + if (canSpit) + { + float spitGateValue = 120f; + if (NPC.Calamity().newAI[0] < spitGateValue) + NPC.Calamity().newAI[0] += 1f; + + // Only spit if all the conditions are met, in order to make the attack actually dangerous + bool spit = NPC.Calamity().newAI[0] >= spitGateValue && isInRangeToSpit && headIsTurnedTowardsTarget && canHitTarget; + + // Telegraph for half a second, or for however long it takes for the spit conditions to be met + float telegraphSpitGateValue = spitGateValue - 30f; + bool telegraphSpit = NPC.Calamity().newAI[0] >= telegraphSpitGateValue; + + // Spit from the mouth hole thing...yeah + Vector2 spitLocation = NPC.Center + NPC.velocity.SafeNormalize(Vector2.UnitY) * 20f; + if (telegraphSpit) + { + NPC.Calamity().newAI[1] = 1f; + int dustType = Main.rand.NextBool() ? DustID.Ichor : DustID.Blood; + for (int k = 0; k < 10; k++) + { + int dust = Dust.NewDust(spitLocation, 1, 1, dustType); + Main.dust[dust].position = spitLocation + Main.rand.NextVector2CircularEdge(25f, 25f); + Main.dust[dust].velocity = (spitLocation - Main.dust[dust].position).SafeNormalize(Vector2.UnitY) * 2f; + Main.dust[dust].scale = dustType == DustID.Ichor ? 1f : 2f; + Main.dust[dust].noGravity = true; + } + } + + if (spit) + { + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; + + SoundEngine.PlaySound(SoundID.NPCDeath13, spitLocation); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int spitProjectileAmount = 8; + float spitProjectileBaseVelocity = 16f; + float spitProjectileRandomVelocityLimit = 3f; + for (int i = 0; i < spitProjectileAmount; i++) + { + int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = type == ModContent.ProjectileType() ? PerforatorHive.IchorShotDamage : PerforatorHive.BloodGeyserDamage; + Projectile.NewProjectile(NPC.GetSource_FromAI(), + spitLocation + Main.rand.NextVector2CircularEdge(8f, 8f), + NPC.velocity.SafeNormalize(Vector2.UnitY) * spitProjectileBaseVelocity + Main.rand.NextVector2CircularEdge(spitProjectileRandomVelocityLimit, spitProjectileRandomVelocityLimit), + type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + } + + // Spit blobs + if (death) + { + int spitBlobAmount = 3; + float spitBlobBaseVelocity = 8f; + float spitBlobRandomVelocityLimit = 2f; + for (int i = 0; i < spitBlobAmount; i++) + { + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_FromAI(), + spitLocation + Main.rand.NextVector2CircularEdge(8f, 8f), + NPC.velocity.SafeNormalize(Vector2.UnitY) * spitBlobBaseVelocity + Main.rand.NextVector2CircularEdge(spitBlobRandomVelocityLimit, spitBlobRandomVelocityLimit), + type, PerforatorHive.IchorShotDamage, 0f, Main.myPlayer, 0f, player.Center.Y); + } + } + } + } + } if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -282,31 +335,32 @@ namespace CalamityMod.NPCs.Perforator } // This is possibly the best or worst idea ever conceived - float laserOffset = 1500f; - float laserVelocity = 4f; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (Main.zenithWorld) - NPC.Calamity().newAI[3]++; - - if (NPC.Calamity().newAI[3] > 180f) // Effectively 10 seconds but give a little headstart in case players kill it too fast { - if (NPC.Calamity().newAI[3] % 60 == 59) - { - SoundEngine.PlaySound(SoundID.Item12, player.Center); - for (int i = -7; i < 8; i++) // 15 lasers - { - float laserGap = (i * 128f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + laserOffset, player.Center.Y + laserGap, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X - laserOffset, player.Center.Y + laserGap, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + laserGap, player.Center.Y + laserOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + laserGap, player.Center.Y + laserOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - } + float laserOffset = 1500f; + float laserVelocity = 4f; + int type = ModContent.ProjectileType(); + int damage = LaserWallDamage; - if (NPC.Calamity().newAI[3] >= 300f) - NPC.Calamity().newAI[3] = -300f; + NPC.Calamity().newAI[3]++; + if (NPC.Calamity().newAI[3] > 180f) // Effectively 10 seconds but give a little headstart in case players kill it too fast + { + if (NPC.Calamity().newAI[3] % 60 == 59) + { + SoundEngine.PlaySound(SoundID.Item12, player.Center); + for (int i = -7; i < 8; i++) // 15 lasers + { + float laserGap = (i * 128f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + laserOffset, player.Center.Y + laserGap, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X - laserOffset, player.Center.Y + laserGap, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + laserGap, player.Center.Y + laserOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + laserGap, player.Center.Y + laserOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); + } + } + + if (NPC.Calamity().newAI[3] >= 300f) + NPC.Calamity().newAI[3] = -300f; + } } float speedCopy = speed; @@ -386,127 +440,77 @@ namespace CalamityMod.NPCs.Perforator if (((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f)) && ((NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f))) { if (NPC.velocity.X < playerX) - { NPC.velocity.X = NPC.velocity.X + turnSpeedCopy; - } else if (NPC.velocity.X > playerX) - { NPC.velocity.X = NPC.velocity.X - turnSpeedCopy; - } if (NPC.velocity.Y < targettingPosition) - { NPC.velocity.Y = NPC.velocity.Y + turnSpeedCopy; - } else if (NPC.velocity.Y > targettingPosition) - { NPC.velocity.Y = NPC.velocity.Y - turnSpeedCopy; - } } if ((NPC.velocity.X > 0f && playerX > 0f) || (NPC.velocity.X < 0f && playerX < 0f) || (NPC.velocity.Y > 0f && targettingPosition > 0f) || (NPC.velocity.Y < 0f && targettingPosition < 0f)) { if (NPC.velocity.X < playerX) - { NPC.velocity.X = NPC.velocity.X + speedCopy; - } else if (NPC.velocity.X > playerX) - { NPC.velocity.X = NPC.velocity.X - speedCopy; - } if (NPC.velocity.Y < targettingPosition) - { NPC.velocity.Y = NPC.velocity.Y + speedCopy; - } else if (NPC.velocity.Y > targettingPosition) - { NPC.velocity.Y = NPC.velocity.Y - speedCopy; - } if ((double)Math.Abs(targettingPosition) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.X > 0f && playerX < 0f) || (NPC.velocity.X < 0f && playerX > 0f))) { if (NPC.velocity.Y > 0f) - { NPC.velocity.Y = NPC.velocity.Y + speedCopy * 2f; - } else - { NPC.velocity.Y = NPC.velocity.Y - speedCopy * 2f; - } } if ((double)Math.Abs(playerX) < (double)maxChargeSpeed * 0.2 && ((NPC.velocity.Y > 0f && targettingPosition < 0f) || (NPC.velocity.Y < 0f && targettingPosition > 0f))) { if (NPC.velocity.X > 0f) - { NPC.velocity.X = NPC.velocity.X + speedCopy * 2f; - } else - { NPC.velocity.X = NPC.velocity.X - speedCopy * 2f; - } } } else if (absoluteTargetX > absoluteTargetPos) { if (NPC.velocity.X < playerX) - { NPC.velocity.X = NPC.velocity.X + speedCopy * 1.1f; - } else if (NPC.velocity.X > playerX) - { NPC.velocity.X = NPC.velocity.X - speedCopy * 1.1f; - } if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5) { if (NPC.velocity.Y > 0f) - { NPC.velocity.Y = NPC.velocity.Y + speedCopy; - } else - { NPC.velocity.Y = NPC.velocity.Y - speedCopy; - } } } else { if (NPC.velocity.Y < targettingPosition) - { NPC.velocity.Y = NPC.velocity.Y + speedCopy * 1.1f; - } else if (NPC.velocity.Y > targettingPosition) - { NPC.velocity.Y = NPC.velocity.Y - speedCopy * 1.1f; - } if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)maxChargeSpeed * 0.5) { if (NPC.velocity.X > 0f) - { NPC.velocity.X = NPC.velocity.X + speedCopy; - } else - { NPC.velocity.X = NPC.velocity.X - speedCopy; - } } } } - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = maxChargeSpeed * 0.25f; - float minimalDamageVelocity = maxChargeSpeed * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } + if (NPC.Distance(player.Center) > 1280f) + NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2; @@ -527,6 +531,23 @@ namespace CalamityMod.NPCs.Perforator if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) NPC.netUpdate = true; + + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -557,23 +578,18 @@ namespace CalamityMod.NPCs.Perforator return false; } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) - { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); - } + if (NPC.life <= 0) { for (int k = 0; k < 10; k++) - { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); - } + if (!Main.dedServ) { Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("LargePerf").Type, NPC.scale); @@ -582,11 +598,8 @@ namespace CalamityMod.NPCs.Perforator } } - public override void BossLoot(ref string name, ref int potionType) - { - name = CalamityUtils.GetTextValue("NPCs.PerforatorLarge"); - potionType = ItemID.HealingPotion; - } + public override LocalizedText DeathMessage => CalamityUtils.GetText("NPCs.PerforatorLarge"); + public override void BossLoot(ref int potionType) => potionType = ItemID.HealingPotion; public override bool SpecialOnKill() { @@ -608,7 +621,7 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 300, true); + target.AddBuff(ModContent.BuffType(), 300); } } } diff --git a/NPCs/Perforator/PerforatorHeadMedium.cs b/NPCs/Perforator/PerforatorHeadMedium.cs index e3cf886284..033cd052fa 100644 --- a/NPCs/Perforator/PerforatorHeadMedium.cs +++ b/NPCs/Perforator/PerforatorHeadMedium.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -11,11 +10,13 @@ using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { [AutoloadBossHead] + [HasPierceResist] [LongDistanceNetSync] public class PerforatorHeadMedium : ModNPC { @@ -23,7 +24,6 @@ namespace CalamityMod.NPCs.Perforator public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/PerfMediumDeath"); public static Asset GlowTexture; - public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); @@ -47,13 +47,13 @@ namespace CalamityMod.NPCs.Perforator { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 24; // 48 NPC.npcSlots = 5f; NPC.width = 58; NPC.height = 68; NPC.defense = 2; - NPC.LifeMaxNERB(180, 216, 7000); + NPC.LifeMaxNERB(130, 170, 7000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -68,9 +68,7 @@ namespace CalamityMod.NPCs.Perforator NPC.DeathSound = DeathSound; NPC.netAlways = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -82,10 +80,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -103,28 +97,27 @@ namespace CalamityMod.NPCs.Perforator public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - float enrageScale = bossRush ? 1f : 0f; - if ((NPC.position.Y / 16f) < Main.worldSurface || bossRush) - enrageScale += 1f; - if (!Main.player[NPC.target].ZoneCrimson || bossRush) - enrageScale += 1f; + // Total body segments + float totalSegments = GetMediumPerforatorSegmentsCount(); - // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Count body segments remaining + float segmentCount = NPC.CountNPCS(ModContent.NPCType()); - float speed = 0.08f; - float turnSpeed = 0.06f; + // Percent body segments remaining + float lifeRatio = MathHelper.Clamp(segmentCount / totalSegments, 0f, 1f); + + float speed = 0.125f; + float turnSpeed = 0.085f; if (expertMode) { - float velocityScale = (death ? 0.08f : 0.07f) * enrageScale; + float velocityScale = death ? 0.125f : 0.085f; speed += velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.08f : 0.07f) * enrageScale; + float accelerationScale = death ? 0.085f : 0.06f; turnSpeed += accelerationScale * (1f - lifeRatio); } @@ -140,15 +133,10 @@ namespace CalamityMod.NPCs.Perforator Player player = Main.player[NPC.target]; - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) { if (NPC.ai[0] == 0f) { - int totalSegments = death ? 14 : revenge ? 13 : expertMode ? 12 : 10; NPC.ai[2] = totalSegments; NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (NPC.width / 2)), (int)(NPC.position.Y + NPC.height), ModContent.NPCType(), NPC.whoAmI); Main.npc[(int)NPC.ai[0]].ai[1] = NPC.whoAmI; @@ -157,8 +145,16 @@ namespace CalamityMod.NPCs.Perforator } // Splitting effect + bool spawnedBlob = false; if (!Main.npc[(int)NPC.ai[1]].active && !Main.npc[(int)NPC.ai[0]].active) { + if (death) + { + spawnedBlob = true; + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, NPC.velocity + Main.rand.NextVector2CircularEdge(3f, 3f), type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer, 0f, NPC.Center.Y); + } + NPC.life = 0; NPC.HitEffect(0, 10.0); NPC.checkDead(); @@ -167,6 +163,12 @@ namespace CalamityMod.NPCs.Perforator } if (!Main.npc[(int)NPC.ai[0]].active) { + if (death && !spawnedBlob) + { + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, NPC.velocity + Main.rand.NextVector2CircularEdge(3f, 3f), type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer, 0f, NPC.Center.Y); + } + NPC.life = 0; NPC.HitEffect(0, 10.0); NPC.checkDead(); @@ -420,18 +422,8 @@ namespace CalamityMod.NPCs.Perforator } } - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = maxChargeSpeed * 0.25f; - float minimalDamageVelocity = maxChargeSpeed * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } + if (NPC.Distance(player.Center) > 1280f) + NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; @@ -452,6 +444,28 @@ namespace CalamityMod.NPCs.Perforator if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) NPC.netUpdate = true; + + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.NextBool() ? DustID.Ichor : DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + } + + public static int GetMediumPerforatorSegmentsCount() + { + return Main.getGoodWorld ? 20 : (CalamityWorld.death || BossRushEvent.BossRushActive) ? 14 : CalamityWorld.revenge ? 13 : Main.expertMode ? 12 : 10; } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -516,31 +530,20 @@ namespace CalamityMod.NPCs.Perforator if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.UnitY, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.UnitY, type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer); for (int i = -1; i < 2; i++) //releases 3 Ichor Shots { int type2 = ModContent.ProjectileType(); Vector2 baseVelocity = Vector2.UnitY * Main.rand.NextFloat(-12.5f, -5f); int spread = Main.rand.Next(16, 36); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread * i)), type2, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread * i)), type2, PerforatorHive.IchorShotDamage, 0f, Main.myPlayer); } } - - // ???? - /*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) - { - name = CalamityUtils.GetTextValue("NPCs.PerforatorMedium"); - potionType = ItemID.HealingPotion; - } + public override LocalizedText DeathMessage => CalamityUtils.GetText("NPCs.PerforatorMedium"); + public override void BossLoot(ref int potionType) => potionType = ItemID.HealingPotion; public override bool SpecialOnKill() { @@ -555,7 +558,9 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 240, true); + { + target.AddBuff(BuffID.Ichor, 360); + } } } } diff --git a/NPCs/Perforator/PerforatorHeadSmall.cs b/NPCs/Perforator/PerforatorHeadSmall.cs index 1931ce9a48..8b6fbc6406 100644 --- a/NPCs/Perforator/PerforatorHeadSmall.cs +++ b/NPCs/Perforator/PerforatorHeadSmall.cs @@ -1,8 +1,6 @@ using System; -using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; -using CalamityMod.NPCs.Abyss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -12,11 +10,13 @@ using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { [AutoloadBossHead] + [HasPierceResist] [LongDistanceNetSync] public class PerforatorHeadSmall : ModNPC { @@ -24,9 +24,6 @@ namespace CalamityMod.NPCs.Perforator public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/PerfSmallDeath"); public static Asset GlowTexture; - - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private const int MsgType = 23; private bool TailSpawned = false; public override void SetStaticDefaults() @@ -52,12 +49,12 @@ namespace CalamityMod.NPCs.Perforator { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 22; // 44 NPC.npcSlots = 5f; NPC.width = 42; NPC.height = 62; - NPC.LifeMaxNERB(1200, 1440, 50000); + NPC.LifeMaxNERB(900, 1150, 50000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -72,9 +69,7 @@ namespace CalamityMod.NPCs.Perforator NPC.DeathSound = DeathSound; NPC.netAlways = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -84,10 +79,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -103,51 +94,23 @@ namespace CalamityMod.NPCs.Perforator }); } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(biomeEnrageTimer); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - biomeEnrageTimer = reader.ReadInt32(); - } - public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - // Enrage - if ((!Main.player[NPC.target].ZoneCrimson || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - - float enrageScale = bossRush ? 1f : 0f; - if (biomeEnraged && (!Main.player[NPC.target].ZoneCrimson || bossRush)) - enrageScale += 1f; - if (biomeEnraged && ((NPC.position.Y / 16f) < Main.worldSurface || bossRush)) - enrageScale += 1f; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = 0.15f; - float turnSpeed = 0.1f; + float speed = revenge ? 0.2f : 0.15f; + float turnSpeed = revenge ? 0.15f : 0.1f; if (expertMode) { - float velocityScale = (death ? 0.15f : 0.1f) * enrageScale; + float velocityScale = death ? 0.2f : 0.14f; speed += velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.12f : 0.1f) * enrageScale; + float accelerationScale = death ? 0.15f : 0.1f; turnSpeed += accelerationScale * (1f - lifeRatio); } @@ -164,10 +127,6 @@ namespace CalamityMod.NPCs.Perforator Player player = Main.player[NPC.target]; - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned) @@ -186,7 +145,7 @@ namespace CalamityMod.NPCs.Perforator Main.npc[lol].ai[2] = NPC.whoAmI; Main.npc[lol].ai[1] = Previous; Main.npc[Previous].ai[0] = lol; - NetMessage.SendData(MsgType, -1, -1, null, lol, 0f, 0f, 0f, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } @@ -454,18 +413,8 @@ namespace CalamityMod.NPCs.Perforator } } - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = maxChargeSpeed * 0.25f; - float minimalDamageVelocity = maxChargeSpeed * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } + if (NPC.Distance(player.Center) > 1280f) + NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2; @@ -486,6 +435,23 @@ namespace CalamityMod.NPCs.Perforator if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) NPC.netUpdate = true; + + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -540,11 +506,8 @@ namespace CalamityMod.NPCs.Perforator } } - public override void BossLoot(ref string name, ref int potionType) - { - name = CalamityUtils.GetTextValue("NPCs.PerforatorSmall"); - potionType = ItemID.HealingPotion; - } + public override LocalizedText DeathMessage => CalamityUtils.GetText("NPCs.PerforatorSmall"); + public override void BossLoot(ref int potionType) => potionType = ItemID.HealingPotion; public override bool SpecialOnKill() { @@ -566,7 +529,7 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 180, true); + target.AddBuff(ModContent.BuffType(), 240); } } } diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 6968d2f8cc..4699dddf4c 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -1,16 +1,13 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Ammo; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; @@ -18,6 +15,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -43,13 +41,21 @@ namespace CalamityMod.NPCs.Perforator public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/PerfHiveDeath"); public static Asset GlowTexture; + // Squash n' stretch won't affect actual hitbox size + private const int Width = 110; + private const int Height = 100; - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - private bool small = false; - private bool medium = false; - private bool large = false; + private bool smallSpawned = false; + private bool mediumSpawned = false; + private bool largeSpawned = false; private int wormsAlive = 0; + private float addedStretch; + private int squashTimer = 0; // Tracks current progress in scaling animation + private const int squashInterval = 24; + private const float maxSquash = 0.3f; // Upper intensity + private float wormSpawnStateTimer = 0f; // For managing worm spawn animation + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 10; @@ -63,19 +69,23 @@ namespace CalamityMod.NPCs.Perforator } } + public static int BloodGeyserDamage = 12; // 48 + public static int IchorShotDamage = 12; // 48 + public static int IchorBlobDamage = 12; // 48 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 18f; - NPC.GetNPCDamage(); - NPC.width = 110; - NPC.height = 100; + NPC.damage = 30; // 48 (1.6x expert scaling) + NPC.width = Width; + NPC.height = Height; NPC.defense = 4; - NPC.LifeMaxNERB(6000, 7200, 270000); + NPC.LifeMaxNERB(4000, 5750, 270000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 8, 0, 0); + NPC.value = Item.buyPrice(gold: 5); NPC.boss = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -84,9 +94,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -109,14 +116,22 @@ namespace CalamityMod.NPCs.Perforator public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); writer.Write(wormsAlive); + writer.Write(smallSpawned); + writer.Write(mediumSpawned); + writer.Write(largeSpawned); + writer.Write(NPC.localAI[2]); + writer.Write(wormSpawnStateTimer); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); wormsAlive = reader.ReadInt32(); + smallSpawned = reader.ReadBoolean(); + mediumSpawned = reader.ReadBoolean(); + largeSpawned = reader.ReadBoolean(); + NPC.localAI[2] = reader.ReadSingle(); + wormSpawnStateTimer = reader.ReadSingle(); } public override void AI() @@ -131,13 +146,12 @@ namespace CalamityMod.NPCs.Perforator if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) NPC.TargetClosest(); - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Variables for ichor blob phase - float blobPhaseGateValue = bossRush ? 450f : 600f; + float blobPhaseGateValue = 600f; bool floatAboveToFireBlobs = NPC.ai[2] >= blobPhaseGateValue - 120f; Player player = Main.player[NPC.target]; @@ -148,34 +162,15 @@ namespace CalamityMod.NPCs.Perforator // Phases based on life percentage bool phase2 = lifeRatio < 0.7f; - // Enrage - if ((!player.ZoneCrimson || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush) - { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; + bool spawnSmall = Main.getGoodWorld ? lifeRatio < 0.85f : lifeRatio < 0.75f; + bool spawnMedium = Main.getGoodWorld ? lifeRatio < 0.60f : lifeRatio < 0.50f; + bool spawnLarge = Main.getGoodWorld ? lifeRatio < 0.45f : lifeRatio < 0.25f; - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - - float enrageScale = bossRush ? 1f : 0f; - if (biomeEnraged && (!player.ZoneCrimson || bossRush)) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - if (biomeEnraged && ((NPC.position.Y / 16f) < Main.worldSurface || bossRush)) - { - NPC.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - - if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f) + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f || !(player.ZoneCrimson || BossRushEvent.BossRushActive)) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f) + if (!player.active || player.dead || Vector2.Distance(player.Center, NPC.Center) > 5600f || !(player.ZoneCrimson || BossRushEvent.BossRushActive)) { NPC.rotation = NPC.velocity.X * 0.04f; @@ -191,20 +186,22 @@ namespace CalamityMod.NPCs.Perforator return; } } + + // Natural despawn prevention else if (NPC.timeLeft < 1800) NPC.timeLeft = 1800; - //GFB seed shenanigans: Behavior during the suck + // GFB seed shenanigans: Behavior during the suck if (NPC.localAI[1] >= 6f) { - //Leak projectiles everywhere and start healing + // Leak projectiles everywhere and start healing int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = type == ModContent.ProjectileType() ? IchorShotDamage : BloodGeyserDamage; int spread = Main.rand.Next(-45, 46); Vector2 baseVelocity = Vector2.UnitY * Main.rand.NextFloat(-12.5f, -5f); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread)), type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - //Heals 10 times per second for 0.1% of its health each = 1% per second + // Heals 10 times per second for 0.1% of its health each = 1% per second if (Main.netMode != NetmodeID.MultiplayerClient) { int healAmt = (int)(NPC.lifeMax / 1000); @@ -233,73 +230,151 @@ namespace CalamityMod.NPCs.Perforator else wormsAlive = 0; - NPC.Calamity().DR = wormsAlive * 0.3f; - - if (NPC.ai[3] == 0f && NPC.life > 0) - NPC.ai[3] = NPC.lifeMax; - - bool canSpawnWorms = !small || !medium || !large || Main.getGoodWorld; - if (NPC.life > 0 && canSpawnWorms) + NPC.Calamity().DR = wormsAlive * 0.5f; + if (wormsAlive >= 1) + NPC.Calamity().CurrentlyIncreasingDefenseOrDR = true; + if (NPC.Calamity().DR >= 0.999f) { - if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.Calamity().DR = 0.999f; + NPC.Calamity().unbreakableDR = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && wormSpawnStateTimer == 0f) + { + if ((!smallSpawned && spawnSmall) || + (!mediumSpawned && spawnMedium) || + (!largeSpawned && spawnLarge)) { - int wormSpawnGateValue = (int)(NPC.lifeMax * (Main.getGoodWorld ? 0.15 : 0.25)); - if ((NPC.life + wormSpawnGateValue) < NPC.ai[3]) + wormSpawnStateTimer = 1f; // Start slowing down to spawn a worm + NPC.netUpdate = true; + } + } + + if (wormSpawnStateTimer > 0f) + { + + NPC.velocity *= 0.94f; // Slow down + NPC.rotation = NPC.velocity.X * 0.04f; // Update rotation to match velocity + + NPC.damage = 0; + + wormSpawnStateTimer++; + + int slowDownDuration = 20; + int waitBeforeSpawnDuration = 40; + int totalStateDuration = slowDownDuration + waitBeforeSpawnDuration; + + if (wormSpawnStateTimer >= slowDownDuration && wormSpawnStateTimer < totalStateDuration) + { + if (Main.rand.NextBool(7)) { - NPC.ai[3] = NPC.life; - int wormType = ModContent.NPCType(); - if (!small) - { - small = true; - } - else if (!medium) - { - medium = true; - wormType = ModContent.NPCType(); - } - else if (!large) - { - large = true; - wormType = ModContent.NPCType(); - } + int bloodLifetime = Main.rand.Next(20, 45); + float bloodScale = Main.rand.NextFloat(0.5f, 1f); + Color bloodColor = Color.Lerp(Color.Yellow, Color.DarkRed, Main.rand.NextFloat(0.7f)); + float randomSpeedMultiplier = Main.rand.NextFloat(0.8f, 1.6f); + Vector2 bloodVelocity = Main.rand.NextVector2Unit(5) * 1.5f * randomSpeedMultiplier; + bloodVelocity.Y -= 8f; - if (Main.getGoodWorld && lifeRatio < 0.5f) - { - if (lifeRatio > 0.35f) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), 1); - else if (lifeRatio > 0.2f) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), 1); - else if (lifeRatio > 0.05f) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), 1); - } - else - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, wormType, 1); + Vector2 randomOffset = Main.rand.NextVector2Unit() * Main.rand.NextFloat(25f, 50f); + Vector2 spawnPosition = NPC.Center + randomOffset; - NPC.TargetClosest(); - - SoundEngine.PlaySound(WormSpawn, NPC.Center); - - for (int i = 0; i < 16; i++) - { - int ichorDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Ichor, 0f, 0f, 100, default, 1f); - Main.dust[ichorDust].velocity *= 2f; - if (Main.rand.NextBool()) - { - Main.dust[ichorDust].scale = 0.25f; - Main.dust[ichorDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int j = 0; j < 32; j++) - { - int bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 1.5f); - Main.dust[bloodDust].noGravity = true; - Main.dust[bloodDust].velocity *= 3f; - bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 1f); - Main.dust[bloodDust].velocity *= 2f; - } + BloodParticle blood = new BloodParticle(spawnPosition, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); } } + + else if (wormSpawnStateTimer >= totalStateDuration) + { + // Blood vars change based on worm spawned + Color bloodColor = Color.Lerp(Color.Crimson, Color.DarkRed, Main.rand.NextFloat(0.9f)); + int bloodAmt = 0; + float minScale = 1f; + float maxScale = 1.8f; + int wormType = -1; + + if (!smallSpawned) + { + + smallSpawned = true; + wormType = ModContent.NPCType(); + + bloodAmt = 12; + } + else if (!mediumSpawned && spawnMedium) + { + mediumSpawned = true; + wormType = ModContent.NPCType(); + + bloodColor = Color.Lerp(Color.Yellow, Color.Orange, Main.rand.NextFloat(0.9f)); + bloodAmt = 12; + minScale = 1.5f; + maxScale = 2.4f; + } + else if (!largeSpawned && spawnLarge) + { + largeSpawned = true; + wormType = ModContent.NPCType(); + + bloodAmt = 18; + minScale = 1.4f; + maxScale = 2.2f; + } + + for (int i = 0; i < bloodAmt; ++i) + { + int bloodLifetime = Main.rand.Next(80, 140); + float bloodScale = Main.rand.NextFloat(minScale, maxScale); + + float randomSpeedMultiplier = Main.rand.NextFloat(1.4f, 2.2f); + Vector2 bloodVelocity = Main.rand.NextVector2Unit() * 4 * randomSpeedMultiplier; + bloodVelocity.Y -= 5f; + BloodParticle blood = new BloodParticle(NPC.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + + + if (Main.getGoodWorld && lifeRatio < 0.5f && Main.netMode != NetmodeID.MultiplayerClient) + { + if (lifeRatio > 0.35f) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + Main.rand.Next(-25, 26), (int)NPC.Center.Y + Main.rand.Next(-25, 26), ModContent.NPCType(), 1); + else if (lifeRatio > 0.2f) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + Main.rand.Next(-25, 26), (int)NPC.Center.Y + Main.rand.Next(-25, 26), ModContent.NPCType(), 1); + else if (lifeRatio > 0.05f) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + Main.rand.Next(-25, 26), (int)NPC.Center.Y + Main.rand.Next(-25, 26), ModContent.NPCType(), 1); + } + if (wormType != -1) + { + squashTimer = squashInterval; // Start scaling animation + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + Main.rand.Next(-25, 26), (int)NPC.Center.Y + Main.rand.Next(-25, 26), wormType, 1); + + // Spawn two small worms in Death + if (death) + { + if (wormType == ModContent.NPCType()) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + Main.rand.Next(-25, 26), (int)NPC.Center.Y + Main.rand.Next(-25, 26), wormType, 1); + } + } + } + + NPC.TargetClosest(); + SoundEngine.PlaySound(WormSpawn, NPC.Center); + wormSpawnStateTimer = 0f; // Resets for next time its called + NPC.netUpdate = true; + } + return; // Don't progress in the AI loop until a worm has finished spawning + } + + if (squashTimer > 0) + { + squashTimer--; + addedStretch = MathHelper.Lerp(0f, maxSquash, (float) squashTimer / squashInterval); + } + else + { + addedStretch = 0f; } if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) @@ -314,7 +389,7 @@ namespace CalamityMod.NPCs.Perforator // Emit ichor blobs if (phase2) { - if (wormsAlive == 0 || bossRush || floatAboveToFireBlobs || (CalamityWorld.LegendaryMode && CalamityWorld.revenge)) + if (wormsAlive == 0 || largeSpawned || floatAboveToFireBlobs || Main.getGoodWorld) { NPC.ai[2] += 1f; if (NPC.ai[2] >= blobPhaseGateValue) @@ -322,10 +397,30 @@ namespace CalamityMod.NPCs.Perforator if (NPC.ai[2] < blobPhaseGateValue + 300f) { if (NPC.velocity.Length() > 0.5f) - NPC.velocity *= bossRush ? 0.94f : 0.96f; + NPC.velocity *= 0.96f; else NPC.ai[2] = blobPhaseGateValue + 300f; + } + + if (NPC.ai[2] < blobPhaseGateValue + 180f) + { + if (Main.rand.NextBool(4)) + { + int bloodLifetime = Main.rand.Next(25, 35); + float bloodScale = Main.rand.NextFloat(0.6f, 0.95f); + Color bloodColor = Color.Lerp(Color.Yellow, Color.Orange, Main.rand.NextFloat(0.8f)); + float randomSpeedMultiplier = Main.rand.NextFloat(1.5f, 2.5f); + Vector2 bloodVelocity = Main.rand.NextVector2Unit() * randomSpeedMultiplier; + + Vector2 spawnPosition = NPC.Center; + spawnPosition.Y += 42; + + BloodParticle blood = new BloodParticle(spawnPosition, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + } + else { NPC.ai[2] = 0f; @@ -334,38 +429,37 @@ namespace CalamityMod.NPCs.Perforator for (int i = 0; i < 32; i++) { - int ichorDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Ichor, 0f, 0f, 100, default, 1f); + int ichorDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Ichor); float dustVelocityYAdd = Math.Abs(Main.dust[ichorDust].velocity.Y) * 0.5f; if (Main.dust[ichorDust].velocity.Y < 0f) Main.dust[ichorDust].velocity.Y = 2f + dustVelocityYAdd; + if (Main.rand.NextBool()) - { - Main.dust[ichorDust].scale = 0.25f; - Main.dust[ichorDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } + Main.dust[ichorDust].scale = 0.5f; } - int numBlobs = expertMode ? 6 : 3; + bool ichorBlobBigWormPhase = wormsAlive > 0 && largeSpawned; + int numBlobs = expertMode ? (ichorBlobBigWormPhase ? 4 : 6) : (ichorBlobBigWormPhase ? 2 : 4); if (Main.getGoodWorld) numBlobs *= 2; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int blobSpread = expertMode ? (ichorBlobBigWormPhase ? 66 : 100) : (ichorBlobBigWormPhase ? 33 : 66); for (int i = 0; i < numBlobs; i++) { - Vector2 blobVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + Vector2 blobVelocity = new Vector2(Main.rand.Next(-blobSpread, blobSpread + 1), Main.rand.Next(-blobSpread, blobSpread + 1)); blobVelocity.Normalize(); - blobVelocity *= Main.rand.Next(400, 801) * (bossRush ? 0.02f : 0.01f); + blobVelocity *= Main.rand.Next(400, 801) * 0.01f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) blobVelocity *= Main.rand.NextFloat() + 1f; - float blobVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.5f; + float blobVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.25f; if (blobVelocity.Y < 2f) blobVelocity.Y = 2f + blobVelocityYAdd; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 50f, blobVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 50f, blobVelocity, type, IchorBlobDamage, 0f, Main.myPlayer, 0f, player.Center.Y); } } @@ -374,9 +468,6 @@ namespace CalamityMod.NPCs.Perforator } } - // Movement velocities, increased while enraged - float velocityEnrageIncrease = enrageScale; - // When firing blobs, float above the target and don't call any other projectile firing or movement code if (floatAboveToFireBlobs) { @@ -384,9 +475,9 @@ namespace CalamityMod.NPCs.Perforator NPC.damage = 0; if (revenge) - Movement(player, 6f + velocityEnrageIncrease, 0.3f, 450f); + Movement(player, 9f, 0.3f, 450f); else - Movement(player, 5f + velocityEnrageIncrease, 0.2f, 450f); + Movement(player, 6f, 0.2f, 450f); return; } @@ -399,28 +490,6 @@ namespace CalamityMod.NPCs.Perforator NPC.localAI[0] = 0f; SoundEngine.PlaySound(GeyserShoot, NPC.Center); - for (int i = 0; i < 8; i++) - { - int ichorDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Ichor, 0f, 0f, 100, default, 1f); - Main.dust[ichorDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[ichorDust].scale = 0.25f; - Main.dust[ichorDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int j = 0; j < 16; j++) - { - int bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 1.5f); - Main.dust[bloodDust].noGravity = true; - Main.dust[bloodDust].velocity *= 5f; - bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 1f); - Main.dust[bloodDust].velocity *= 2f; - } - - int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); int numProj = death ? 16 : revenge ? 14 : expertMode ? 12 : 10; if (Main.getGoodWorld) numProj *= 2; @@ -428,13 +497,46 @@ namespace CalamityMod.NPCs.Perforator int spread = 75; float velocity = 8f; Vector2 destination = wormsAlive > 0 ? player.Center : NPC.Center - Vector2.UnitY * 100f; - Vector2 projectileVelocity = new Vector2(Vector2.Normalize(destination - NPC.Center).X * velocity, -velocity); + Vector2 projectileVelocity = new Vector2(Utils.DirectionTo(NPC.Center, destination).X * velocity, -velocity); float rotation = MathHelper.ToRadians(spread); + Vector2 dustSpawnBox = new Vector2(12f, 12f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { + bool ichor = Main.rand.NextBool(); + int type = ichor ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = ichor ? IchorShotDamage : BloodGeyserDamage; + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); Vector2 randomVelocity = new Vector2(Main.rand.NextFloat() - 0.5f, Main.rand.NextFloat() - 0.5f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 50f, perturbedSpeed + randomVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + Vector2 projectileSpawnLocation = NPC.Center + Vector2.Normalize(perturbedSpeed) * 50f; + Vector2 projectileVelocityRandomized = perturbedSpeed + randomVelocity; + + float dustSpeed = Main.rand.NextFloat(3.0f, 9.0f); + float angleRandom = 0.05f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0.0f).RotatedBy(projectileVelocityRandomized.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2.0f * angleRandom); + + if (ichor) + { + for (int j = 0; j < 4; j++) + { + int ichorDust = Dust.NewDust(projectileSpawnLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, DustID.Ichor); + Main.dust[ichorDust].velocity = dustVelocity; + } + } + else + { + for (int j = 0; j < 4; j++) + { + int bloodDust = Dust.NewDust(projectileSpawnLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, DustID.Blood); + Main.dust[bloodDust].velocity = dustVelocity; + Main.dust[bloodDust].scale = 2f; + } + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawnLocation, projectileVelocityRandomized, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); } } } @@ -448,14 +550,14 @@ namespace CalamityMod.NPCs.Perforator // Set damage NPC.damage = NPC.defDamage; - if (large || death) - Movement(player, 11f + velocityEnrageIncrease, death ? 0.1125f : 0.0975f, 20f); - else if (medium) - Movement(player, 10f + velocityEnrageIncrease, death ? 0.105f : 0.09f, 30f); - else if (small) - Movement(player, 9f + velocityEnrageIncrease, death ? 0.0975f : 0.0825f, 40f); + if (largeSpawned || death) + Movement(player, 13f, death ? 0.115f : 0.1f, 20f); + else if (mediumSpawned) + Movement(player, 12f, death ? 0.11f : 0.095f, 30f); + else if (smallSpawned) + Movement(player, 11f, death ? 0.105f : 0.09f, 40f); else - Movement(player, 8f + velocityEnrageIncrease, death ? 0.09f : 0.075f, 50f); + Movement(player, 10f, death ? 0.1f : 0.085f, 50f); break; @@ -464,7 +566,7 @@ namespace CalamityMod.NPCs.Perforator // Avoid cheap bullshit NPC.damage = 0; - Movement(player, 6f + velocityEnrageIncrease, 0.15f, 350f); + Movement(player, 8f, 0.2f, 350f); break; @@ -473,7 +575,7 @@ namespace CalamityMod.NPCs.Perforator // Avoid cheap bullshit NPC.damage = 0; - Movement(player, 6f + velocityEnrageIncrease, 0.15f, 275f); + Movement(player, 8f, 0.2f, 275f); break; @@ -482,7 +584,7 @@ namespace CalamityMod.NPCs.Perforator // Avoid cheap bullshit NPC.damage = 0; - Movement(player, 6f + velocityEnrageIncrease, 0.15f, 200f); + Movement(player, 8f, 0.2f, 200f); break; } @@ -492,7 +594,7 @@ namespace CalamityMod.NPCs.Perforator // Avoid cheap bullshit NPC.damage = 0; - Movement(player, 6f + velocityEnrageIncrease, 0.075f, 350f); + Movement(player, 6f, 0.15f, 350f); } } @@ -513,22 +615,19 @@ namespace CalamityMod.NPCs.Perforator public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = TextureAssets.Npc[Type].Value; + Color drawColorAlpha = NPC.GetAlpha(drawColor); - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2)); + Vector2 scaleStretch = new Vector2(1f - addedStretch, 1f + addedStretch) * NPC.scale; + float yOffset = addedStretch * 0.5f * NPC.height; // offset from stretching - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture.Value; + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f); + texture = GlowTexture.Value; Color glowmaskColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + // done again to fix glowmask not matching sprite + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, glowmaskColor, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f); return false; } @@ -536,10 +635,10 @@ namespace CalamityMod.NPCs.Perforator public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); + NPC.damage = (int)(NPC.damage * 0.8f); } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.HealingPotion; } @@ -559,7 +658,7 @@ namespace CalamityMod.NPCs.Perforator Color messageColor = Color.Cyan; AerialiteOreGen.Enchant(); - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Mark The Perforator Hive as dead @@ -590,12 +689,12 @@ namespace CalamityMod.NPCs.Perforator normalOnly.Add(ItemID.CrimtaneBar, 1, 10, 15); normalOnly.Add(ItemID.Vertebrae, 1, 10, 15); normalOnly.Add(ItemID.CrimsonSeeds, 1, 10, 15); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30)); normalOnly.Add(ItemDropRule.ByCondition(DropHelper.Hardmode(), ItemID.Ichor, 1, 10, 20)); // Equipment normalOnly.Add(ModContent.ItemType(), DropHelper.NormalWeaponDropRateFraction); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -609,18 +708,12 @@ namespace CalamityMod.NPCs.Perforator npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Bloodfin drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ModContent.ItemType(), 1, 1, 9999, true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 9999), true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedPerforator, ModContent.ItemType(), desc: DropHelper.FirstKillText); } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 180, true); - } - public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < hit.Damage / NPC.lifeMax * 100.0; k++) @@ -642,7 +735,7 @@ namespace CalamityMod.NPCs.Perforator NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 40; i++) + for (int i = 0; i < 12; i++) { int ichorDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); Main.dust[ichorDust].velocity *= 3f; @@ -652,7 +745,7 @@ namespace CalamityMod.NPCs.Perforator Main.dust[ichorDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int j = 0; j < 70; j++) + for (int j = 0; j < 20; j++) { int bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 3f); Main.dust[bloodDust].noGravity = true; @@ -660,6 +753,19 @@ namespace CalamityMod.NPCs.Perforator bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); Main.dust[bloodDust].velocity *= 2f; } + // Blood burst + for (int i = 0; i < 24; ++i) + { + int bloodLifetime = Main.rand.Next(120, 200); + float bloodScale = Main.rand.NextFloat(1.3f, 2.6f); + Color bloodColor = Color.Lerp(Color.Crimson, Color.DarkRed, Main.rand.NextFloat(0.9f)); + float randomSpeedMultiplier = Main.rand.NextFloat(4.5f, 9f); + Vector2 bloodVelocity = Main.rand.NextVector2Unit(6) * 2.5f * randomSpeedMultiplier; + bloodVelocity.Y -= 14f; + + BloodParticle blood = new BloodParticle(NPC.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } } } } diff --git a/NPCs/Perforator/PerforatorTailLarge.cs b/NPCs/Perforator/PerforatorTailLarge.cs index 20cfe2cf62..3c91794302 100644 --- a/NPCs/Perforator/PerforatorTailLarge.cs +++ b/NPCs/Perforator/PerforatorTailLarge.cs @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(PerforatorHeadLarge))] public class PerforatorTailLarge : ModNPC { @@ -33,12 +34,12 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 16; // 32 NPC.width = 60; NPC.height = 78; NPC.defense = 12; - NPC.LifeMaxNERB(2700, 3240, 80000); + NPC.LifeMaxNERB(2000, 2600, 80000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -54,9 +55,7 @@ namespace CalamityMod.NPCs.Perforator NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -66,10 +65,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -101,13 +96,6 @@ namespace CalamityMod.NPCs.Perforator NPC.active = false; } - if (Main.npc[(int)NPC.ai[1]].alpha < 128) - { - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - } - if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -149,19 +137,30 @@ namespace CalamityMod.NPCs.Perforator NPC.spriteDirection = -1; } - // Calculate contact damage based on velocity - float maxChaseSpeed = 16f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; - float minimalDamageVelocity = maxChaseSpeed * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) + if (Main.npc[(int)NPC.ai[1]].alpha >= 85) { - NPC.damage = 0; + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } - else + else if (NPC.alpha > 0) { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } } @@ -215,7 +214,7 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90, true); + target.AddBuff(ModContent.BuffType(), 180, true); } } } diff --git a/NPCs/Perforator/PerforatorTailMedium.cs b/NPCs/Perforator/PerforatorTailMedium.cs index 5363704b89..b7401df0b0 100644 --- a/NPCs/Perforator/PerforatorTailMedium.cs +++ b/NPCs/Perforator/PerforatorTailMedium.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -15,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(PerforatorHeadMedium))] public class PerforatorTailMedium : ModNPC { @@ -35,13 +35,13 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 12; // 24 NPC.npcSlots = 5f; NPC.width = 40; NPC.height = 50; NPC.defense = 10; - NPC.LifeMaxNERB(180, 216, 7000); + NPC.LifeMaxNERB(130, 170, 7000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -57,9 +57,7 @@ namespace CalamityMod.NPCs.Perforator NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -71,14 +69,12 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() { + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + NPC.realLife = -1; // Target @@ -88,18 +84,19 @@ namespace CalamityMod.NPCs.Perforator if (Main.player[NPC.target].dead) NPC.TargetClosest(false); - if (Main.npc[(int)NPC.ai[1]].alpha < 128) - { - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - } - if (Main.netMode != NetmodeID.MultiplayerClient) { // Splitting effect + bool spawnedBlob = false; if (!Main.npc[(int)NPC.ai[1]].active && !Main.npc[(int)NPC.ai[0]].active) { + if (death) + { + spawnedBlob = true; + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Main.rand.NextVector2CircularEdge(3f, 3f), type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer, 0f, NPC.Center.Y); + } + NPC.life = 0; NPC.HitEffect(0, 10.0); NPC.checkDead(); @@ -108,6 +105,12 @@ namespace CalamityMod.NPCs.Perforator } if (!Main.npc[(int)NPC.ai[1]].active) { + if (death && !spawnedBlob) + { + int type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Main.rand.NextVector2CircularEdge(3f, 3f), type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer, 0f, NPC.Center.Y); + } + NPC.life = 0; NPC.HitEffect(0, 10.0); NPC.checkDead(); @@ -155,20 +158,30 @@ namespace CalamityMod.NPCs.Perforator NPC.position.Y += targetY; } - // Calculate contact damage based on velocity - // This worm requires more velocity to deal damage with the body because it doesn't have spikes or metal bits or etc. - float maxChaseSpeed = 16f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.4f; - float minimalDamageVelocity = maxChaseSpeed * 0.8f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) + if (Main.npc[(int)NPC.ai[1]].alpha >= 85) { - NPC.damage = 0; + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, Main.rand.NextBool() ? DustID.Ichor : DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } - else + else if (NPC.alpha > 0) { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } } @@ -228,15 +241,14 @@ namespace CalamityMod.NPCs.Perforator if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.UnitY, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.UnitY, type, PerforatorHive.IchorBlobDamage, 0f, Main.myPlayer); for (int i = -1; i < 2; i++) //releases 3 Ichor Shots { int type2 = ModContent.ProjectileType(); Vector2 baseVelocity = Vector2.UnitY * Main.rand.NextFloat(-12.5f, -5f); int spread = Main.rand.Next(16, 36); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread * i)), type2, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread * i)), type2, PerforatorHive.IchorShotDamage, 0f, Main.myPlayer); } } } @@ -244,7 +256,9 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + { + target.AddBuff(BuffID.Ichor, 240); + } } } } diff --git a/NPCs/Perforator/PerforatorTailSmall.cs b/NPCs/Perforator/PerforatorTailSmall.cs index da90401b93..6ba7331758 100644 --- a/NPCs/Perforator/PerforatorTailSmall.cs +++ b/NPCs/Perforator/PerforatorTailSmall.cs @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Perforator { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(PerforatorHeadSmall))] public class PerforatorTailSmall : ModNPC { @@ -33,12 +34,12 @@ namespace CalamityMod.NPCs.Perforator public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 10; // 20 NPC.width = 40; NPC.height = 34; NPC.defense = 8; - NPC.LifeMaxNERB(1200, 1440, 50000); + NPC.LifeMaxNERB(900, 1150, 50000); if (Main.zenithWorld) NPC.lifeMax *= 4; @@ -54,9 +55,7 @@ namespace CalamityMod.NPCs.Perforator NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -66,10 +65,6 @@ namespace CalamityMod.NPCs.Perforator NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) @@ -101,13 +96,6 @@ namespace CalamityMod.NPCs.Perforator NPC.active = false; } - if (Main.npc[(int)NPC.ai[1]].alpha < 128) - { - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; - } - if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -149,20 +137,30 @@ namespace CalamityMod.NPCs.Perforator NPC.spriteDirection = -1; } - // Calculate contact damage based on velocity - // This worm requires more velocity to deal damage with the body because it doesn't have spikes or metal bits or etc. - float maxChaseSpeed = 16f; - float minimalContactDamageVelocity = maxChaseSpeed * 0.4f; - float minimalDamageVelocity = maxChaseSpeed * 0.8f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) + if (Main.npc[(int)NPC.ai[1]].alpha >= 85) { - NPC.damage = 0; + if (NPC.alpha > 0 && NPC.life > 0) + { + for (int dustIndex = 0; dustIndex < 2; dustIndex++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 2f); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + } + } + + if ((NPC.position - NPC.oldPosition).Length() > 2f) + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } } - else + else if (NPC.alpha > 0) { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } } @@ -215,7 +213,7 @@ namespace CalamityMod.NPCs.Perforator public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 120, true); } } } diff --git a/NPCs/PierceResistExceptionAttribute.cs b/NPCs/PierceResistExceptionAttribute.cs new file mode 100644 index 0000000000..e549dc2fea --- /dev/null +++ b/NPCs/PierceResistExceptionAttribute.cs @@ -0,0 +1,21 @@ +using System; + +namespace CalamityMod.NPCs +{ + /// + /// This attribute makes projectiles exempt from pierce resistance + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public sealed class PierceResistExceptionAttribute : Attribute + { + /// + /// Set this to true to indicate this projectile is only exempt from piercing resistance when attacking NPCs with a single large hitbox. + /// + public bool OnlyForSingleHitbox { get; } + + public PierceResistExceptionAttribute(bool onlyForSingleHitbox = false) + { + OnlyForSingleHitbox = onlyForSingleHitbox; + } + } +} diff --git a/NPCs/PlagueEnemies/Melter.cs b/NPCs/PlagueEnemies/Melter.cs index 4203d6ee5e..8b293fff79 100644 --- a/NPCs/PlagueEnemies/Melter.cs +++ b/NPCs/PlagueEnemies/Melter.cs @@ -31,20 +31,16 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.damage = 55; NPC.width = 38; NPC.height = 34; - NPC.defense = 15; - NPC.lifeMax = 630; + NPC.defense = 20; + NPC.lifeMax = 800; NPC.knockBackResist = 0.3f; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.HitSound = SoundID.NPCHit1; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -69,7 +65,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/PlagueEnemies/PestilentSlime.cs b/NPCs/PlagueEnemies/PestilentSlime.cs index 8e662822ae..404305cecf 100644 --- a/NPCs/PlagueEnemies/PestilentSlime.cs +++ b/NPCs/PlagueEnemies/PestilentSlime.cs @@ -31,11 +31,11 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.damage = 55; NPC.width = 40; NPC.height = 30; - NPC.defense = 12; - NPC.lifeMax = 440; + NPC.defense = 35; + NPC.lifeMax = 600; NPC.knockBackResist = 0.5f; AnimationType = NPCID.CorruptSlime; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.alpha = 60; NPC.lavaImmune = false; NPC.noGravity = false; @@ -45,10 +45,6 @@ namespace CalamityMod.NPCs.PlagueEnemies BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -157,7 +153,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90, true); + target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/NPCs/PlagueEnemies/PlagueCharger.cs b/NPCs/PlagueEnemies/PlagueCharger.cs index 54f956edec..03c4d3b92a 100644 --- a/NPCs/PlagueEnemies/PlagueCharger.cs +++ b/NPCs/PlagueEnemies/PlagueCharger.cs @@ -36,14 +36,14 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.damage = 37; NPC.width = 36; NPC.height = 30; - NPC.defense = 20; + NPC.defense = 32; NPC.scale *= 0.5f; - NPC.lifeMax = 250; + NPC.lifeMax = 720; NPC.aiStyle = NPCAIStyleID.Flying; AIType = NPCID.Bee; NPC.knockBackResist = 0.4f; AnimationType = NPCID.Bee; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit4; NPC.noGravity = true; NPC.noTileCollide = false; @@ -51,10 +51,6 @@ namespace CalamityMod.NPCs.PlagueEnemies BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -137,7 +133,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); + target.AddBuff(ModContent.BuffType(), 120); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/PlagueEnemies/PlagueChargerLarge.cs b/NPCs/PlagueEnemies/PlagueChargerLarge.cs index dad5fb445f..752dc4a30f 100644 --- a/NPCs/PlagueEnemies/PlagueChargerLarge.cs +++ b/NPCs/PlagueEnemies/PlagueChargerLarge.cs @@ -31,14 +31,14 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.damage = 45; NPC.width = 36; NPC.height = 30; - NPC.defense = 25; + NPC.defense = 36; NPC.scale *= 0.75f; - NPC.lifeMax = 380; + NPC.lifeMax = 840; NPC.aiStyle = NPCAIStyleID.Flying; AIType = NPCID.Bee; NPC.knockBackResist = 0.3f; AnimationType = NPCID.Bee; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.HitSound = SoundID.NPCHit4; NPC.noGravity = true; NPC.noTileCollide = false; @@ -46,10 +46,6 @@ namespace CalamityMod.NPCs.PlagueEnemies BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -132,7 +128,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs index db13bc4c31..4a8bfcc316 100644 --- a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs +++ b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs @@ -42,9 +42,8 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.width = 66; NPC.height = 66; NPC.defense = 24; - NPC.DR_NERD(0.2f); NPC.lifeMax = 8750; - NPC.value = Item.buyPrice(0, 1, 50, 0); + NPC.value = Item.buyPrice(gold: 1, silver: 50); NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; @@ -61,10 +60,6 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.scale = 2f; } - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -474,7 +469,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 240); } } } diff --git a/NPCs/PlagueEnemies/Plagueshell.cs b/NPCs/PlagueEnemies/Plagueshell.cs index 9e5acf2b08..4c728c12c0 100644 --- a/NPCs/PlagueEnemies/Plagueshell.cs +++ b/NPCs/PlagueEnemies/Plagueshell.cs @@ -27,11 +27,11 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.aiStyle = NPCAIStyleID.GiantTortoise; NPC.width = 46; NPC.height = 32; - NPC.defense = 32; - NPC.lifeMax = 1000; + NPC.defense = 50; + NPC.lifeMax = 1200; NPC.knockBackResist = 0.2f; AnimationType = NPCID.GiantTortoise; - NPC.value = Item.buyPrice(0, 0, 15, 0); + NPC.value = Item.buyPrice(silver: 15); NPC.HitSound = SoundID.NPCHit24; NPC.noGravity = false; Banner = NPC.type; @@ -39,10 +39,6 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -94,7 +90,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ModContent.ItemType(), 1, 3, 4); diff --git a/NPCs/PlagueEnemies/Viruling.cs b/NPCs/PlagueEnemies/Viruling.cs index d2c2f4d31f..df650e78ee 100644 --- a/NPCs/PlagueEnemies/Viruling.cs +++ b/NPCs/PlagueEnemies/Viruling.cs @@ -30,20 +30,16 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.damage = 60; NPC.width = 58; NPC.height = 44; - NPC.defense = 18; - NPC.lifeMax = 500; + NPC.defense = 32; + NPC.lifeMax = 900; NPC.knockBackResist = 0.3f; - NPC.value = Item.buyPrice(0, 0, 10, 0); + NPC.value = Item.buyPrice(silver: 10); NPC.HitSound = SoundID.NPCHit22; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -184,7 +180,7 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 90, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs index a65955b46d..8cd56e8f01 100644 --- a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs +++ b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs @@ -2,7 +2,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -31,8 +30,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 70; // 140 NPC.width = 22; NPC.height = 22; NPC.defense = 20; @@ -46,18 +44,13 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.noTileCollide = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; Lighting.AddLight(NPC.Center, 0.015f, 0.1f, 0f); @@ -112,7 +105,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { NPC.localAI[1] += 1f; float timeBeforeExploding = 480f + NPC.ai[3] * 2f; - float homingDuration = (bossRush ? 430f : death ? 340f : revenge ? 290f : expertMode ? 240f : 150f) + NPC.ai[3] * 2f; + float homingDuration = (death ? 340f : revenge ? 290f : expertMode ? 240f : 150f) + NPC.ai[3] * 2f; if (NPC.localAI[1] == timeBeforeExploding) { CheckDead(); @@ -134,7 +127,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { NPC.noTileCollide = false; - if (NPC.velocity.Length() < (bossRush ? 25f : 20f)) + if (NPC.velocity.Length() < 20f) NPC.velocity *= 1.01f; if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) @@ -165,7 +158,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2)); + Vector2 halfSizeTexture = NPC.frame.Size() / 2f; int afterimageAmt = 5; Vector2 drawLocation = NPC.Center - screenPos; @@ -262,11 +255,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { if (Main.zenithWorld) // it is the plague, you get very sick. { - target.AddBuff(ModContent.BuffType(), 240, true); - target.AddBuff(BuffID.Poisoned, 240, true); - target.AddBuff(BuffID.Venom, 240, true); + target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(BuffID.Poisoned, 240); + target.AddBuff(BuffID.Venom, 240); } - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 120); } } diff --git a/NPCs/PlaguebringerGoliath/PlagueMine.cs b/NPCs/PlaguebringerGoliath/PlagueMine.cs index e95079f7ee..2e39de458b 100644 --- a/NPCs/PlaguebringerGoliath/PlagueMine.cs +++ b/NPCs/PlaguebringerGoliath/PlagueMine.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; -using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -30,7 +29,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 80; // 160 NPC.width = 42; NPC.height = 42; NPC.defense = 20; @@ -44,17 +43,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.DeathSound = SoundID.NPCDeath14; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; Lighting.AddLight(NPC.Center, 0.03f, 0.2f, 0f); @@ -78,7 +72,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Vector2 vector = Main.player[NPC.target].Center - NPC.Center; float distanceRequiredForExplosion = 90f; - float timeBeforeExplosion = (bossRush ? 1000f : death ? 740f : revenge ? 520f : 400f) + NPC.ai[3] * 4f; + float timeBeforeExplosion = (death ? 740f : revenge ? 520f : 400f) + NPC.ai[3] * 4f; if (vector.Length() < distanceRequiredForExplosion || NPC.ai[0] >= timeBeforeExplosion) { CheckDead(); @@ -94,7 +88,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } NPC.TargetClosest(true); - float velocity = (bossRush ? 14f : death ? 12f : revenge ? 10f : 8f) + NPC.ai[3] * 0.04f; + float velocity = (death ? 12f : revenge ? 10f : 8f) + NPC.ai[3] * 0.04f; Vector2 npcDirection = new Vector2(NPC.Center.X + (float)(NPC.direction * 20), NPC.Center.Y + 6f); float targetX = player.position.X + (float)player.width * 0.5f - npcDirection.X; float targetY = player.Center.Y - npcDirection.Y; @@ -102,7 +96,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath float npcSpeed = velocity / targetDistance; targetX *= npcSpeed; targetY *= npcSpeed; - float inertia = (bossRush ? 35f : death ? 40f : revenge ? 45f : 50f) - NPC.ai[3] * 0.25f; + float inertia = (death ? 40f : revenge ? 45f : 50f) - NPC.ai[3] * 0.25f; NPC.velocity.X = (NPC.velocity.X * inertia + targetX) / (inertia + 1f); NPC.velocity.Y = (NPC.velocity.Y * inertia + targetY) / (inertia + 1f); } @@ -124,10 +118,10 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[Type].Value.Width / 2, TextureAssets.Npc[Type].Value.Height / 2); + Vector2 halfSizeTexture = NPC.frame.Size() / 2f; Vector2 drawLocation = NPC.Center - screenPos; drawLocation -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + drawLocation += halfSizeTexture * NPC.scale + Vector2.UnitY * NPC.gfxOffY; Color backAfterimageColor = PlaguebringerGoliath.BackglowColor * NPC.Opacity; for (int i = 0; i < 10; i++) @@ -152,11 +146,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { if (Main.zenithWorld) // it is the plague, you get very sick. { - target.AddBuff(ModContent.BuffType(), 300, true); - target.AddBuff(BuffID.Poisoned, 300, true); - target.AddBuff(BuffID.Venom, 300, true); + target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(BuffID.Poisoned, 300); + target.AddBuff(BuffID.Venom, 300); } - target.AddBuff(ModContent.BuffType(), 150, true); + target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index e9b5eeeb5b..47724c6a71 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -4,13 +4,12 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; @@ -84,30 +83,30 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } } + public static int StingerDamage = 28; // 112 + public static int NukeDamage = 35; // 140; Also applies to GFB Peanuts and Gauss Nukes + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 90; // 180 NPC.npcSlots = 64f; NPC.width = 198; NPC.height = 198; NPC.defense = 50; NPC.DR_NERD(0.3f); - NPC.LifeMaxNERB(87500, 105000, 370000); + NPC.LifeMaxNERB(70000, 105000, 370000); NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; NPC.boss = true; - NPC.value = Item.buyPrice(0, 30, 0, 0); + NPC.value = Item.buyPrice(gold: 25); NPC.noGravity = true; NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath14; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -158,10 +157,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.height = (int)(NPC.frame.Height * (charging ? 1.5f : 1.8f)); // Mode variables - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -186,12 +184,10 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath bool immuneToSlowingDebuffs = NPC.ai[0] == 0f || NPC.ai[0] == 4f; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; // Light @@ -202,7 +198,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { string key = "Mods.CalamityMod.Status.Boss.PlagueBossText"; Color messageColor = Color.Lime; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); SoundEngine.PlaySound(NukeWarningSound, NPC.Center); halfLife = true; @@ -210,7 +206,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Missile countdown if (halfLife && MissileCountdown == 0) - MissileCountdown = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 300 : 600; + MissileCountdown = Main.getGoodWorld ? 300 : 600; if (MissileCountdown > 1) MissileCountdown--; @@ -231,7 +227,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Vector2 distFromPlayer = player.Center - NPC.Center; // Enrage - if (!player.ZoneJungle && !bossRush) + if (!player.ZoneJungle && !BossRushEvent.BossRushActive) { if (biomeEnrageTimer > 0) biomeEnrageTimer--; @@ -239,12 +235,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath else biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; + bool biomeEnraged = biomeEnrageTimer <= 0; float enrageScale = death ? 0.5f : 0f; if (biomeEnraged) { - NPC.Calamity().CurrentlyEnraged = !bossRush; + NPC.Calamity().CurrentlyEnraged = true; enrageScale += 1.5f; } @@ -254,10 +250,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (Main.getGoodWorld) enrageScale += 0.5f; - if (bossRush) - enrageScale = 2f; - - bool diagonalDash = (revenge && phase2) || bossRush; + bool diagonalDash = (revenge && phase2); if (NPC.ai[0] != 0f && NPC.ai[0] != 4f) NPC.rotation = NPC.velocity.X * 0.02f; @@ -545,8 +538,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (calamityGlobalNPC.newAI[0] > 90f) NPC.velocity *= 1.01f; - // Spawn honey in legendary rev+ - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge && calamityGlobalNPC.newAI[0] % 6f == 0f) + // Spawn honey in the stupid seed + if (Main.zenithWorld && calamityGlobalNPC.newAI[0] % 6f == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -633,7 +626,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath calamityGlobalNPC.newAI[0] += 1f; if ((Vector2.Distance(NPC.Center, player.Center) < 640f && canHitTarget) || calamityGlobalNPC.newAI[0] >= 180f) { - NPC.ai[0] = (phase3 || bossRush) ? 5f : 1f; + NPC.ai[0] = phase3 ? 5f : 1f; NPC.ai[1] = 0f; calamityGlobalNPC.newAI[0] = 0f; @@ -804,7 +797,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.direction = playerLocation < 0 ? 1 : -1; NPC.spriteDirection = NPC.direction; - if (NPC.ai[2] > ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 3f : 5f)) + if (NPC.ai[2] > 5f) { NPC.ai[0] = -1f; NPC.ai[1] = 2f; @@ -869,7 +862,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath if (Main.zenithWorld) type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = type == ModContent.ProjectileType() ? NukeDamage : StingerDamage; Projectile.NewProjectile(NPC.GetSource_FromAI(), stingerSpawnPos.X, stingerSpawnPos.Y, projXDist, projYDist, type, damage, 0f, Main.myPlayer, challengeAmt, player.position.Y); NPC.netUpdate = true; } @@ -915,7 +908,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath missileVelocity += 2f * enrageScale; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = NukeDamage; int chargeDistanceX = 600; float chargeSpeed = revenge ? 28f : 26f; @@ -980,15 +973,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath baseVelocity *= 0.4f; } - int missiles = bossRush ? 16 : MissileProjectiles; - int spread = bossRush ? 18 : 24; + int spread = 24; if (!gaussMode) { - for (int i = 0; i < missiles; i++) + for (int i = 0; i < MissileProjectiles; i++) { - Vector2 spawn = NPC.Center; // Normal = 96, Boss Rush = 144 - spawn.X += i * (int)(spread * 1.125) - (missiles * (spread / 2)); // Normal = -96 to 93, Boss Rush = -144 to 156 - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-MissileAngleSpread / 2 + (MissileAngleSpread * i / missiles))); + Vector2 spawn = NPC.Center; + spawn.X += i * (int)(spread * 1.125) - (MissileProjectiles * (spread / 2)); + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-MissileAngleSpread / 2 + (MissileAngleSpread * i / MissileProjectiles))); Projectile.NewProjectile(NPC.GetSource_FromAI(), spawn, velocity, type, damage, 0f, Main.myPlayer, nukeBarrageChallengeAmt, player.position.Y); } } @@ -1316,7 +1308,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.GreaterHealingPotion; } @@ -1346,7 +1338,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), @@ -1358,10 +1350,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Materials normalOnly.Add(ItemID.Stinger, 1, 3, 5); normalOnly.Add(ModContent.ItemType(), 1, 15, 20); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30)); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 30, 40)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -1375,7 +1368,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Honey Bucket drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ItemID.BottomlessHoneyBucket, hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ItemID.BottomlessHoneyBucket), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedPlaguebringer, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -1384,7 +1377,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) @@ -1393,11 +1385,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { if (Main.zenithWorld) // it is the plague, you get very sick. { - target.AddBuff(ModContent.BuffType(), 480, true); - target.AddBuff(BuffID.Poisoned, 480, true); - target.AddBuff(BuffID.Venom, 480, true); + target.AddBuff(ModContent.BuffType(), 480); + target.AddBuff(BuffID.Poisoned, 480); + target.AddBuff(BuffID.Venom, 480); } - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(ModContent.BuffType(), 360); } } } diff --git a/NPCs/Polterghast/PhantomFuckYou.cs b/NPCs/Polterghast/PhantomFuckYou.cs index 5e0b097a77..c6671dc640 100644 --- a/NPCs/Polterghast/PhantomFuckYou.cs +++ b/NPCs/Polterghast/PhantomFuckYou.cs @@ -2,7 +2,6 @@ using System.IO; using CalamityMod.Dusts; using CalamityMod.Projectiles.Boss; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -23,19 +22,19 @@ namespace CalamityMod.NPCs.Polterghast NPCID.Sets.TrailingMode[Type] = 1; } + public static int MineDamage = 70; // 280 + public override void SetDefaults() { - NPC.aiStyle = -1; - AIType = -1; + NPC.damage = 0; // No contact damage NPC.width = 30; NPC.height = 30; NPC.defense = 45; - NPC.DR_NERD(0.1f); NPC.noGravity = true; NPC.noTileCollide = true; NPC.chaseable = false; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats NPC.lifeMax = 20000; + NPC.dontTakeDamage = true; NPC.HitSound = SoundID.NPCHit36; NPC.DeathSound = SoundID.NPCDeath39; NPC.Calamity().VulnerableToSickness = false; @@ -98,7 +97,7 @@ namespace CalamityMod.NPCs.Polterghast direction *= 0.5f; NPC.rotation = direction.ToRotation(); - if (!chargePhase || (CalamityWorld.LegendaryMode && CalamityWorld.revenge)) + if (!chargePhase || Main.getGoodWorld) { NPC.ai[2] += 1f; float shootMineGateValue = 150f; @@ -110,10 +109,9 @@ namespace CalamityMod.NPCs.Polterghast if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); float maxVelocity = 8f * tileEnrageMult; float acceleration = 1.15f + (tileEnrageMult - 1f) * 0.15f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, direction, type, damage, 1f, NPC.target, maxVelocity, acceleration); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, direction, type, MineDamage, 1f, NPC.target, maxVelocity, acceleration); } NPC.ai[2] = 0f; } diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index d5de2b05cd..d1e74b8527 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -38,13 +38,13 @@ namespace CalamityMod.NPCs.Polterghast { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 180; // 360 NPC.width = 90; NPC.height = 120; NPC.defense = 45; NPC.DR_NERD(0.1f); NPC.LifeMaxNERB(62500, 75000, 60000); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.zenithWorld) NPC.lifeMax *= 4; NPC.knockBackResist = 0f; @@ -57,9 +57,6 @@ namespace CalamityMod.NPCs.Polterghast NPC.HitSound = SoundID.NPCHit36; NPC.DeathSound = SoundID.NPCDeath39; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void BossHeadRotation(ref float rotation) @@ -97,10 +94,9 @@ namespace CalamityMod.NPCs.Polterghast { CalamityGlobalNPC.ghostBossClone = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) { @@ -142,7 +138,7 @@ namespace CalamityMod.NPCs.Polterghast float velocity = 3f; float acceleration = 0.03f; - if (!player.ZoneDungeon && !bossRush && player.position.Y < Main.worldSurface * 16.0) + if (!player.ZoneDungeon && !BossRushEvent.BossRushActive && player.position.Y < Main.worldSurface * 16.0) { despawnTimer--; if (despawnTimer <= 0) @@ -176,26 +172,21 @@ namespace CalamityMod.NPCs.Polterghast } // Predictiveness - Vector2 predictionVector = chargePhase && bossRush ? player.velocity * 20f : Vector2.Zero; - Vector2 lookAt = player.Center + predictionVector; + Vector2 lookAt = player.Center; Vector2 rotationVector = lookAt - vector; // Rotation if (NPC.Calamity().newAI[3] == 0f) { - float playerXDestination = player.Center.X + predictionVector.X - vector.X; - float playerYDestination = player.Center.Y + predictionVector.Y - vector.Y; + float playerXDestination = player.Center.X - vector.X; + float playerYDestination = player.Center.Y - vector.Y; NPC.rotation = (float)Math.Atan2(playerYDestination, playerXDestination) + MathHelper.PiOver2; } else NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; - int reducedSetDamage = (int)Math.Round(NPC.defDamage * 0.5); - if (!chargePhase) { - NPC.damage = reducedSetDamage; - // Set this here to avoid despawn issues reachedChargingPoint = false; @@ -232,7 +223,7 @@ namespace CalamityMod.NPCs.Polterghast float movementLimitedDistance = (float)Math.Sqrt(movementLimitedXDist * movementLimitedXDist + movementLimitedYDist * movementLimitedYDist); float maxDistanceFromHooks = expertMode ? 650f : 500f; - if (speedBoost || bossRush) + if (speedBoost) maxDistanceFromHooks += 250f; if (death) maxDistanceFromHooks += maxDistanceFromHooks * 0.1f * (1f - lifeRatio); @@ -311,23 +302,17 @@ namespace CalamityMod.NPCs.Polterghast if (NPC.Calamity().newAI[1] == 0f) { - NPC.damage = NPC.defDamage; - NPC.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; NPC.Calamity().newAI[1] = 1f; } else { - NPC.damage = NPC.defDamage; - NPC.Calamity().newAI[2] += 1f; // Slow down for a few frames float totalChargeTime = chargeDistance * 4f / chargeVelocity; float slowDownTime = chargeVelocity; { - NPC.damage = reducedSetDamage; - if (NPC.Calamity().newAI[2] >= totalChargeTime - slowDownTime) NPC.velocity *= 0.9f; } @@ -352,9 +337,6 @@ namespace CalamityMod.NPCs.Polterghast } else { - // Do not deal damage during movement to avoid cheap bullshit hits - NPC.damage = 0; - // Random location choice if (NPC.ai[0] == 0f) { @@ -544,7 +526,6 @@ namespace CalamityMod.NPCs.Polterghast public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index dba87d1578..684cccea79 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -39,7 +38,7 @@ namespace CalamityMod.NPCs.Polterghast { public static int phase1IconIndex; public static int phase3IconIndex; - + public override void Load() { string phase1IconPath = "CalamityMod/NPCs/Polterghast/Polterghast_Head_Boss"; @@ -65,27 +64,27 @@ namespace CalamityMod.NPCs.Polterghast public static List creepySounds = new List { - NPCs.DevourerofGods.DevourerofGodsHead.AttackSound, - NPCs.Providence.Providence.HolyRaySound, - NPCs.ExoMechs.Ares.AresBody.EnragedSound, - NPCs.ExoMechs.Ares.AresBody.LaserStartSound, - NPCs.ExoMechs.Thanatos.ThanatosHead.VentSound, - NPCs.SupremeCalamitas.SupremeCalamitas.SepulcherSummonSound, - NPCs.SupremeCalamitas.SupremeCalamitas.SpawnSound, - NPCs.Ravager.RavagerBody.LimbLossSound, - NPCs.HiveMind.HiveMind.RoarSound, - NPCs.Yharon.Yharon.RoarSound, - NPCs.DesertScourge.DesertScourgeHead.RoarSound, - NPCs.OldDuke.OldDuke.RoarSound, - NPCs.Abyss.ReaperShark.SearchRoarSound, - NPCs.Abyss.ReaperShark.EnragedRoarSound, - NPCs.Abyss.LuminousCorvina.ScreamSound, - NPCs.Abyss.DevilFish.MaskBreakSound, - NPCs.PrimordialWyrm.PrimordialWyrmHead.ChargeSound, - NPCs.GreatSandShark.GreatSandShark.RoarSound, - NPCs.AcidRain.Mauler.RoarSound, - NPCs.AstrumDeus.AstrumDeusHead.DeathSound, - NPCs.AstrumAureus.AstrumAureus.HitSound, + DevourerofGods.DevourerofGodsHead.AttackSound, + Providence.Providence.HolyRaySound, + ExoMechs.Ares.AresBody.EnragedSound, + ExoMechs.Ares.AresBody.LaserStartSound, + ExoMechs.Thanatos.ThanatosHead.VentSound, + SupremeCalamitas.SupremeCalamitas.SepulcherSummonSound, + SupremeCalamitas.SupremeCalamitas.SpawnSound, + Ravager.RavagerBody.LimbLossSound, + HiveMind.HiveMind.RoarSound, + Yharon.Yharon.RoarSound, + DesertScourge.DesertScourgeHead.RoarSound, + OldDuke.OldDuke.RoarSound, + ReaperShark.SearchRoarSound, + ReaperShark.EnragedRoarSound, + LuminousCorvina.ScreamSound, + DevilFish.MaskBreakSound, + PrimordialWyrm.PrimordialWyrmHead.ChargeSound, + GreatSandShark.GreatSandShark.RoarSound, + AcidRain.Mauler.RoarSound, + AstrumDeus.AstrumDeusHead.DeathSound, + AstrumAureus.AstrumAureus.HitSound, SoundID.ScaryScream, SoundID.DD2_KoboldFlyerHurt }; @@ -103,30 +102,33 @@ namespace CalamityMod.NPCs.Polterghast } } + public static float Phase2ContactDamageMult = 1.25f; // 300 + public static float Phase3ContactDamageMult = 1.5f; // 360 + public static int BlueShotDamage = 60; // 240 + public static int BlueBlastDamage = 65; // 260 + public static int RedShotDamage = 65; // 260 + public static int RedBlastDamage = 70; // 280 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 120; // 240 NPC.npcSlots = 50f; - NPC.GetNPCDamage(); NPC.width = 90; NPC.height = 120; NPC.defense = 90; NPC.DR_NERD(0.2f); - NPC.LifeMaxNERB(350000, 420000, 325000); + NPC.LifeMaxNERB(280000, 420000, 325000); NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(1, 50, 0, 0); + NPC.value = Item.buyPrice(platinum: 1); NPC.boss = true; NPC.noGravity = true; NPC.noTileCollide = true; NPC.netAlways = true; NPC.HitSound = HitSound; NPC.DeathSound = SoundID.NPCDeath39; - NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -203,12 +205,11 @@ namespace CalamityMod.NPCs.Polterghast // Variables Vector2 vector = NPC.Center; - bool bossRush = BossRushEvent.BossRushActive; bool speedBoost = false; bool despawnBoost = false; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Phases bool phase2 = lifeRatio < (death ? 0.9f : revenge ? 0.8f : expertMode ? 0.65f : 0.5f); @@ -331,7 +332,7 @@ namespace CalamityMod.NPCs.Polterghast } } - bool despawn = !player.ZoneDungeon && !bossRush && player.position.Y < Main.worldSurface * 16.0; + bool despawn = !player.ZoneDungeon && !BossRushEvent.BossRushActive && player.position.Y < Main.worldSurface * 16.0; if (despawn) { despawnTimer--; @@ -416,26 +417,19 @@ namespace CalamityMod.NPCs.Polterghast float baseProjectileVelocity = speedBoost ? 9.375f : 7.5f; // Predictiveness - Vector2 predictionVector = chargePhase && bossRush ? player.velocity * 20f : Vector2.Zero; - Vector2 lookAt = player.Center + predictionVector; + Vector2 lookAt = player.Center; Vector2 rotationVector = lookAt - vector; // Rotation if (calamityGlobalNPC.newAI[3] == 0f) { - float playerXDestination = player.Center.X + predictionVector.X - vector.X; - float playerYDestination = player.Center.Y + predictionVector.Y - vector.Y; + float playerXDestination = player.Center.X - vector.X; + float playerYDestination = player.Center.Y - vector.Y; NPC.rotation = (float)Math.Atan2(playerYDestination, playerXDestination) + MathHelper.PiOver2; } else NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; - int phase1ReducedSetDamage = (int)Math.Round(NPC.defDamage * 0.5); - int phase2Damage = (int)Math.Round(NPC.defDamage * 1.2); - int phase2ReducedSetDamage = (int)Math.Round(phase2Damage * 0.5); - int phase3Damage = (int)Math.Round(NPC.defDamage * 1.4); - int phase3ReducedSetDamage = (int)Math.Round(phase3Damage * 0.5); - if (!chargePhase) { NPC.ai[2] += 1f; @@ -472,7 +466,7 @@ namespace CalamityMod.NPCs.Polterghast float movementLimitedDistance = (float)Math.Sqrt(movementLimitedXDist * movementLimitedXDist + movementLimitedYDist * movementLimitedYDist); float maxDistanceFromHooks = expertMode ? 650f : 500f; - if (speedBoost || bossRush) + if (speedBoost) maxDistanceFromHooks += 250f; if (death) maxDistanceFromHooks += maxDistanceFromHooks * 0.1f * (1f - lifeRatio); @@ -542,15 +536,11 @@ namespace CalamityMod.NPCs.Polterghast if (calamityGlobalNPC.newAI[1] == 0f) { - NPC.damage = phase3 ? phase3Damage : phase2 ? phase2Damage : NPC.defDamage; - NPC.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; calamityGlobalNPC.newAI[1] = 1f; } else { - NPC.damage = phase3 ? phase3Damage : phase2 ? phase2Damage : NPC.defDamage; - calamityGlobalNPC.newAI[2] += 1f; // Slow down for a few frames @@ -558,8 +548,6 @@ namespace CalamityMod.NPCs.Polterghast float slowDownTime = chargeVelocity; if (calamityGlobalNPC.newAI[2] >= totalChargeTime - slowDownTime) { - NPC.damage = phase3 ? phase3ReducedSetDamage : phase2 ? phase2ReducedSetDamage : phase1ReducedSetDamage; - NPC.velocity *= 0.9f; } @@ -587,8 +575,6 @@ namespace CalamityMod.NPCs.Polterghast } else { - NPC.damage = phase3 ? phase3ReducedSetDamage : phase2 ? phase2ReducedSetDamage : phase1ReducedSetDamage; - // Pick a charging location // Set charge locations X if (vector.X >= player.Center.X) @@ -668,9 +654,7 @@ namespace CalamityMod.NPCs.Polterghast // Phase 1: "Polterghast" if (!phase2 && !phase3) { - if (!isInChargePhase) - NPC.damage = phase1ReducedSetDamage; - + NPC.damage = NPC.defDamage; NPC.defense = NPC.defDefense; if (Main.netMode != NetmodeID.MultiplayerClient && !isInChargePhase) @@ -693,13 +677,14 @@ namespace CalamityMod.NPCs.Polterghast if (notLiningUpCharge) { int type = ModContent.ProjectileType(); + int damage = BlueShotDamage; if (Main.rand.NextBool(3)) { NPC.localAI[1] = -30f; type = ModContent.ProjectileType(); + damage = BlueBlastDamage; } - int damage = NPC.GetProjectileDamage(type); Vector2 spreadVel = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * baseProjectileVelocity; Vector2 firingPos = NPC.Center + spreadVel * 3f; for (int i = 0; i < 6; i++) @@ -712,14 +697,13 @@ namespace CalamityMod.NPCs.Polterghast else { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 spreadVel = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (baseProjectileVelocity + 5f); Vector2 firingPos = NPC.Center + spreadVel * 3f; for (int i = 0; i < 6; i++) { float offset = MathHelper.ToRadians(MathHelper.Lerp(-40f, 40f, i / 5f)); - Projectile shot = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), firingPos, spreadVel.RotatedBy(offset), type, damage, 0f, Main.myPlayer); + Projectile shot = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), firingPos, spreadVel.RotatedBy(offset), type, BlueBlastDamage, 0f, Main.myPlayer); shot.timeLeft = 450; } } @@ -773,9 +757,7 @@ namespace CalamityMod.NPCs.Polterghast } } - if (!isInChargePhase) - NPC.damage = phase2ReducedSetDamage; - + NPC.damage = (int)Math.Round(NPC.defDamage * Phase2ContactDamageMult); NPC.defense = (int)Math.Round(NPC.defDefense * 0.8); if (Main.netMode != NetmodeID.MultiplayerClient && !isInChargePhase) @@ -798,13 +780,14 @@ namespace CalamityMod.NPCs.Polterghast if (notLiningUpCharge) { int type = ModContent.ProjectileType(); + int damage = RedShotDamage; if (Main.rand.NextBool(3)) { NPC.localAI[1] = -30f; type = ModContent.ProjectileType(); + damage = RedBlastDamage; } - int damage = NPC.GetProjectileDamage(type); Vector2 spreadVel = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (baseProjectileVelocity + 1f); Vector2 firingPos = NPC.Center + spreadVel * 3f; for (int i = 0; i < 7; i++) @@ -817,13 +800,12 @@ namespace CalamityMod.NPCs.Polterghast else { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 spreadVel = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (baseProjectileVelocity + 5f); Vector2 firingPos = NPC.Center + spreadVel * 3f; for (int i = 0; i < 7; i++) { float offset = MathHelper.ToRadians(MathHelper.Lerp(-50f, 50f, i / 6f)); - Projectile shot = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), firingPos, spreadVel.RotatedBy(offset), type, damage, 0f, Main.myPlayer); + Projectile shot = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), firingPos, spreadVel.RotatedBy(offset), type, RedBlastDamage, 0f, Main.myPlayer); shot.timeLeft = 450; } } @@ -894,9 +876,7 @@ namespace CalamityMod.NPCs.Polterghast } } - if (!isInChargePhase) - NPC.damage = phase3ReducedSetDamage; - + NPC.damage = (int)Math.Round(NPC.defDamage * Phase3ContactDamageMult); NPC.defense = (int)Math.Round(NPC.defDefense * 0.5); NPC.localAI[1] += 1f; @@ -907,8 +887,9 @@ namespace CalamityMod.NPCs.Polterghast { int numProj = (getPissed ? 10 : 8); float maxSpread = getPissed ? 125 : 110; - int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + bool red = Main.rand.NextBool(); + int type = red ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = red ? RedShotDamage : BlueShotDamage; Vector2 spreadVel = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * baseProjectileVelocity; Vector2 firingPos = NPC.Center + spreadVel * 3f; for (int i = 0; i < numProj; i++) @@ -949,7 +930,7 @@ namespace CalamityMod.NPCs.Polterghast } } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -962,7 +943,7 @@ namespace CalamityMod.NPCs.Polterghast CalamityGlobalNPC.SetNewBossJustDowned(NPC); - CalamityGlobalNPC.SetNewShopVariable(new int[] { NPCID.Cyborg }, DownedBossSystem.downedPolterghast); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { NPCID.Cyborg }, DownedBossSystem.downedPolterghast); // If Polterghast has not been killed, notify players about the Abyss minibosses now dropping items if (!DownedBossSystem.downedPolterghast) @@ -980,8 +961,8 @@ namespace CalamityMod.NPCs.Polterghast sulfSeaBoostMessage = "Mods.CalamityMod.Status.Progression.AprilFools2"; // Goddamn boomer duke moments } - CalamityUtils.DisplayLocalizedText(key, messageColor); - CalamityUtils.DisplayLocalizedText(sulfSeaBoostMessage, sulfSeaBoostColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(sulfSeaBoostMessage, sulfSeaBoostColor); } // Mark Polterghast as dead @@ -1010,10 +991,11 @@ namespace CalamityMod.NPCs.Polterghast normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Materials - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 7, 15)); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 20, 25)); normalOnly.Add(ModContent.ItemType(), 1, 30, 40); // Vanity @@ -1029,7 +1011,7 @@ namespace CalamityMod.NPCs.Polterghast // GFB Cell Phone drop var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.CellPhone, hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.CellPhone), hideLootReport: true); } // Lore @@ -1226,7 +1208,6 @@ namespace CalamityMod.NPCs.Polterghast public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Polterghast/PolterghastHook.cs b/NPCs/Polterghast/PolterghastHook.cs index a31142c7f1..9c4ce56079 100644 --- a/NPCs/Polterghast/PolterghastHook.cs +++ b/NPCs/Polterghast/PolterghastHook.cs @@ -32,11 +32,13 @@ namespace CalamityMod.NPCs.Polterghast } } + public static int ShotDamage = 55; // 220 + public override void SetDefaults() { + NPC.damage = 0; // No contact damage NPC.aiStyle = -1; AIType = -1; - NPC.damage = 0; NPC.width = 40; NPC.height = 40; NPC.lifeMax = 50000; @@ -150,7 +152,7 @@ namespace CalamityMod.NPCs.Polterghast NPC.ai[2] += 1f; if (NPC.ai[3] == 0f) { - if (NPC.ai[2] > ((CalamityWorld.LegendaryMode && revenge) ? 12f : 120f)) + if (NPC.ai[2] > (Main.getGoodWorld ? 40f : 120f)) { NPC.ai[2] = 0f; NPC.ai[3] = 1f; @@ -166,11 +168,10 @@ namespace CalamityMod.NPCs.Polterghast { float shotSpeed = 10f * tileEnrageMult; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); targetDistance = shotSpeed / targetDistance; targetX *= targetDistance; targetY *= targetDistance; - Projectile.NewProjectile(NPC.GetSource_FromAI(), hookPosition.X, hookPosition.Y, targetX, targetY, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), hookPosition.X, hookPosition.Y, targetX, targetY, type, ShotDamage, 0f, Main.myPlayer, 0f, 0f); } } return; @@ -262,7 +263,7 @@ namespace CalamityMod.NPCs.Polterghast int randTileY = playerTileY + Main.rand.Next(-randPlayerRadius, randPlayerRadius + 1); try { - if (WorldGen.SolidTile(randTileX, randTileY) || Main.tile[randTileX, randTileY].WallType > 0 || chargePhase) + if (WorldGen.SolidTile(randTileX, randTileY) || Main.tile[randTileX, randTileY].WallType > WallID.None || chargePhase) { canMoveToTile = true; NPC.ai[0] = randTileX; diff --git a/NPCs/PrimordialWyrm/AEWMusicScene.cs b/NPCs/PrimordialWyrm/AEWMusicScene.cs index b246ad62ed..2de4d89f11 100644 --- a/NPCs/PrimordialWyrm/AEWMusicScene.cs +++ b/NPCs/PrimordialWyrm/AEWMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.PrimordialWyrm; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs b/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs index b09d815870..3a77d83eb0 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmBody.cs @@ -21,6 +21,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void SetStaticDefaults() { + NPCID.Sets.NeedsExpertScaling[Type] = true; this.HideFromBestiary(); if (!Main.dedServ) { @@ -30,7 +31,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void SetDefaults() { - NPC.damage = 100; + NPC.damage = 0; // No contact damage NPC.width = 100; NPC.height = 88; NPC.defense = 0; @@ -64,8 +65,6 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void AI() { - NPC.damage = 0; - // Difficulty modes bool death = CalamityWorld.death; bool revenge = CalamityWorld.revenge; @@ -176,8 +175,14 @@ namespace CalamityMod.NPCs.PrimordialWyrm center += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture, center, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + // this math is so incredibly scuffed. please someone fix it i dont even know what any of this actually does + float brightness = 1f; + float nameWasTooLong = Main.GameUpdateCount * 0.01f; + float saneVelocity = MathHelper.Clamp((int)PrimordialWyrmHead.PWHeadVelocity, 6f, 8f); + brightness = MathF.Sin(nameWasTooLong * (6f + saneVelocity) - NPC.whoAmI); + brightness = MathHelper.Clamp(brightness, 0.25f, 1f); texture = GlowTexture.Value; - spriteBatch.Draw(texture, center, NPC.frame, Color.White * NPC.Opacity, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, center, NPC.frame, Color.White * (NPC.Opacity * brightness), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs b/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs index 07d140904b..755a0974c7 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmBodyAlt.cs @@ -20,6 +20,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.PrimordialWyrmHead.DisplayName"); public override void SetStaticDefaults() { + NPCID.Sets.NeedsExpertScaling[Type] = true; this.HideFromBestiary(); if (!Main.dedServ) { @@ -27,9 +28,11 @@ namespace CalamityMod.NPCs.PrimordialWyrm } } + public static int FireballDamage = 110; // 440 + public override void SetDefaults() { - NPC.damage = 100; + NPC.damage = 0; NPC.width = 110; NPC.height = 88; NPC.defense = 0; @@ -63,8 +66,6 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void AI() { - NPC.damage = 0; - // Difficulty modes bool death = CalamityWorld.death; bool revenge = CalamityWorld.revenge; @@ -134,8 +135,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm Vector2 destination = Main.player[Main.npc[(int)NPC.ai[2]].target].Center - NPC.Center; Vector2 velocity = Vector2.Normalize(destination) * fireballVelocity; int type = ProjectileID.CultistBossFireBallClone; - int damage = NPC.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, FireballDamage, 0f, Main.myPlayer); Main.projectile[proj].tileCollide = false; } } @@ -175,8 +175,14 @@ namespace CalamityMod.NPCs.PrimordialWyrm center += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture, center, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + // this math is so incredibly scuffed. please someone fix it i dont even know what any of this actually does + float brightness = 1f; + float nameWasTooLong = Main.GameUpdateCount * 0.01f; + float saneVelocity = MathHelper.Clamp((int)PrimordialWyrmHead.PWHeadVelocity, 6f, 8f); + brightness = MathF.Sin(nameWasTooLong * (6f + saneVelocity) - NPC.whoAmI); + brightness = MathHelper.Clamp(brightness, 0.25f, 1f); texture = GlowTexture.Value; - spriteBatch.Draw(texture, center, NPC.frame, Color.White * NPC.Opacity, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, center, NPC.frame, Color.White * (NPC.Opacity * brightness), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs index 086ac9f062..2bc598ef88 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs @@ -2,18 +2,16 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Potions; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.Perforator; using CalamityMod.Sounds; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -53,6 +51,9 @@ namespace CalamityMod.NPCs.PrimordialWyrm set => NPC.Calamity().newAI[0] = value; } + // Store velocity for use with other segments + public static float PWHeadVelocity; + // Base distance from the target for most attacks private const float baseDistance = 1000f; @@ -105,11 +106,18 @@ namespace CalamityMod.NPCs.PrimordialWyrm } } + public static int IceMistDamage = 110; // 440 + public static int LightningDamage = 140; // 560 + + // Reused Cultist projectiles + public static float LightDamageMult = 2.445f; // 440 + public static float DoomDamageMult = 2.445f; // 440 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 300; // 600 NPC.npcSlots = 50f; - NPC.GetNPCDamage(); NPC.width = 230; NPC.height = 138; NPC.LifeMaxNERB(2500000, 3000000); @@ -117,7 +125,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm AIType = -1; NPC.Opacity = 0f; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(5, 0, 0, 0); + NPC.value = Item.buyPrice(platinum: 5); NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; @@ -209,7 +217,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm // Target variable Player player = Main.player[NPC.target]; - bool targetDownDeep = player.Calamity().ZoneAbyssLayer4 || BossRushEvent.BossRushActive; + bool targetDownDeep = player.Calamity().ZoneAbyssLayer4; bool targetOnMount = player.mount.Active; // Check whether enraged for the sake of the HP bar UI @@ -337,12 +345,10 @@ namespace CalamityMod.NPCs.PrimordialWyrm bool immuneToSlowingDebuffs = AIState == (float)Phase.FinalPhase || AIState == (float)Phase.ShadowFireballSpin; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - NPC.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; // Adjust opacity @@ -645,22 +651,21 @@ namespace CalamityMod.NPCs.PrimordialWyrm float ai = Main.rand.Next(100); Vector2 projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; int type = ProjectileID.CultistBossLightningOrbArc; - int damage = NPC.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, LightningDamage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); Main.projectile[proj].tileCollide = false; // Opposite bolt projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt - NPC.Center; ai = Main.rand.Next(100); projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; - proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, LightningDamage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); Main.projectile[proj].tileCollide = false; // Normal bolt projectileDestination = targetCenterArray[i] - NPC.Center; ai = Main.rand.Next(100); projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * lightningVelocity; - proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, LightningDamage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); Main.projectile[proj].tileCollide = false; } } @@ -939,18 +944,17 @@ namespace CalamityMod.NPCs.PrimordialWyrm Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt - NPC.Center; Vector2 projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; int type = ProjectileID.CultistBossIceMist; - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, IceMistDamage, 0f, Main.myPlayer, 0f, 1f); // Opposite mist projectileDestination = targetCenterArray[i] - Main.player[whoAmIArray[i]].velocity * predictionAmt - NPC.Center; projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, IceMistDamage, 0f, Main.myPlayer, 0f, 1f); // Normal bolt projectileDestination = targetCenterArray[i] - NPC.Center; projectileVelocity = Vector2.Normalize(projectileDestination) * iceMistVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, IceMistDamage, 0f, Main.myPlayer, 0f, 1f); } } @@ -1146,13 +1150,12 @@ namespace CalamityMod.NPCs.PrimordialWyrm if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.CultistBossLightningOrbArc; - int damage = NPC.GetProjectileDamage(type); for (int i = 0; i < numLightningBolts; i++) { Vector2 projectileDestination = player.Center - lightningSpawnLocation; Vector2 projectileVelocity = Vector2.Normalize(projectileDestination.RotatedByRandom(MathHelper.PiOver4)) * baseVelocity * 0.5f; float ai = Main.rand.Next(100); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), lightningSpawnLocation, projectileVelocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), lightningSpawnLocation, projectileVelocity, type, LightningDamage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); Main.projectile[proj].tileCollide = false; lightningSpawnLocation.Y += distanceBetweenBolts; if (i == numLightningBolts / 2) @@ -1457,17 +1460,35 @@ namespace CalamityMod.NPCs.PrimordialWyrm center += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture, center, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + // this math is so incredibly scuffed. please someone fix it i dont even know what any of this actually does + float brightness = 1f; + float nameWasTooLong = Main.GameUpdateCount * 0.01f; + float saneVelocity = MathHelper.Clamp((int)NPC.velocity.Length(), 6f, 8f); + PWHeadVelocity = saneVelocity; + brightness = MathF.Sin(nameWasTooLong * (6f + saneVelocity) - NPC.whoAmI); + brightness = MathHelper.Clamp(brightness, 0.25f, 1f); texture = GlowTexture.Value; - spriteBatch.Draw(texture, center, NPC.frame, Color.White * NPC.Opacity, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, center, NPC.frame, Color.White * (NPC.Opacity * brightness), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + // if anyone needs to debug this piece of shit code, i leave this to you + //Main.NewText("vec length: " + NPC.velocity.Length()); + //Main.NewText("sane vel: " + saneVelocity); + //Main.NewText("brightness: " + brightness, new Color(255, 0, brightness * 128)); // this line doesnt even work LMAO return false; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } + public override void OnKill() + { + // Mark Primordial Wyrm as dead + DownedBossSystem.downedPrimordialWyrm = true; + CalamityNetcode.SyncWorld(); + } + public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType()); @@ -1505,7 +1526,6 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void ModifyTypeName(ref string typeName) @@ -1519,7 +1539,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (NPC.Opacity == 1f && hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 1200, true); + target.AddBuff(ModContent.BuffType(), 1200); } } } diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs b/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs index 83b94b364b..f1f0da9544 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmTail.cs @@ -19,6 +19,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.PrimordialWyrmHead.DisplayName"); public override void SetStaticDefaults() { + NPCID.Sets.NeedsExpertScaling[Type] = true; this.HideFromBestiary(); if (!Main.dedServ) { @@ -28,7 +29,7 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void SetDefaults() { - NPC.damage = 100; + NPC.damage = 0; NPC.width = 100; NPC.height = 120; NPC.defense = 0; @@ -52,8 +53,6 @@ namespace CalamityMod.NPCs.PrimordialWyrm public override void AI() { - NPC.damage = 0; - // Difficulty modes bool death = CalamityWorld.death; bool revenge = CalamityWorld.revenge; @@ -137,8 +136,14 @@ namespace CalamityMod.NPCs.PrimordialWyrm center += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture, center, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + // this math is so incredibly scuffed. please someone fix it i dont even know what any of this actually does + float brightness = 1f; + float nameWasTooLong = Main.GameUpdateCount * 0.01f; + float saneVelocity = MathHelper.Clamp((int)PrimordialWyrmHead.PWHeadVelocity, 6f, 8f); + brightness = MathF.Sin(nameWasTooLong * (6f + saneVelocity) - NPC.whoAmI); + brightness = MathHelper.Clamp(brightness, 0.25f, 1f); texture = GlowTexture.Value; - spriteBatch.Draw(texture, center, NPC.frame, Color.White * NPC.Opacity, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, center, NPC.frame, Color.White * (NPC.Opacity * brightness), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index c4fc204d4b..caf07e873e 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -8,13 +8,14 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Typeless; using CalamityMod.NPCs.Providence; using CalamityMod.Projectiles.Boss; using CalamityMod.UI.VanillaBossBars; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -23,7 +24,7 @@ using Terraria; using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; -using Terraria.Graphics.Effects; +using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Filters = Terraria.Graphics.Effects.Filters; @@ -65,33 +66,35 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } + public static int FireDamage = 36; // 144; HolyFire, HolyFire2 + public static int SpearDamage = 42; // 168; HolySpear, ProfanedSpear + public static int HolyBlastDamage = 60; // 240 + public static int RayDamage = 80; // 320 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 120; // 240 NPC.npcSlots = 20f; NPC.aiStyle = -1; - NPC.GetNPCDamage(); NPC.width = 228; NPC.height = 186; NPC.defense = 40; NPC.DR_NERD(0.3f); - NPC.LifeMaxNERB(100000, 120000, 200000); + NPC.LifeMaxNERB(80000, 120000, 200000); NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.noTileCollide = true; AIType = -1; NPC.boss = true; NPC.BossBar = ModContent.GetInstance(); - NPC.value = Item.buyPrice(1, 0, 0, 0); + NPC.value = Item.buyPrice(gold: 50); NPC.HitSound = SoundID.NPCHit52; NPC.DeathSound = SoundID.NPCDeath55; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -153,10 +156,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Rotation NPC.rotation = NPC.velocity.X * 0.005f; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -359,7 +361,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians float goLowOrHighDistance = 540f; // Side swap variables for Phase 2 - float defenderCommanderGuardPhase2Duration = bossRush ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float defenderCommanderGuardPhase2Duration = death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; float moveToOtherSideInPhase2GateValue = defenderCommanderGuardPhase2Duration - 120f; float timeBeforeMoveToOtherSideInPhase2Reset = moveToOtherSideInPhase2GateValue * 2f; float totalGoLowDurationPhase2 = 210f; @@ -367,13 +369,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge variables float chargeVelocityMult = 0.25f; - float maxChargeVelocity = bossRush ? 32f : death ? 28f : revenge ? 26f : expertMode ? 24f : 20f; + float maxChargeVelocity = death ? 28f : revenge ? 26f : expertMode ? 24f : 20f; if (Main.getGoodWorld) - maxChargeVelocity *= 1.15f; - if (CalamityWorld.LegendaryMode && revenge) maxChargeVelocity *= 2f; - float inertia = bossRush ? 40f : death ? 45f : revenge ? 47f : expertMode ? 50f : 55f; + float inertia = death ? 45f : revenge ? 47f : expertMode ? 50f : 55f; if (lifeRatio < 0.5f) inertia *= 0.8f; if (!phase1) @@ -456,7 +456,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (!goLow && !goLowPhase2 && !goHigh) calamityGlobalNPC.newAI[0] = -NPC.direction; - float velocity = bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float velocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) velocity *= 1.25f; if (healerAlive) @@ -493,7 +493,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 targetVector = destination - NPC.Center; Vector2 desiredVelocity = targetVector.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; - float phaseGateValue = bossRush ? 50f : death ? 66f : revenge ? 75f : expertMode ? 83f : 100f; + float phaseGateValue = death ? 66f : revenge ? 75f : expertMode ? 83f : 100f; bool continueShootingProjectiles = phase1 || (NPC.ai[2] < (phaseGateValue * 5f)); if (continueShootingProjectiles) @@ -507,7 +507,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Alternate between firing profaned spears and holy fire // Shoot holy blasts in final phase NPC.ai[2] += 1f; - float projectileShootGateValue = bossRush ? 40f : death ? 60f : revenge ? 90f : expertMode ? 100f : 150f; + float projectileShootGateValue = death ? 60f : revenge ? 90f : expertMode ? 100f : 150f; if (NPC.ai[2] % projectileShootGateValue == 0f) { if (phase1) @@ -521,10 +521,10 @@ namespace CalamityMod.NPCs.ProfanedGuardians } bool shootSpear = NPC.ai[2] % (projectileShootGateValue * 2f) == 0f; - float projectileVelocity = bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float projectileVelocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; Vector2 finalProjectileVelocity = Vector2.Normalize(player.Center - shootFrom) * projectileVelocity; int type = shootSpear ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = shootSpear ? SpearDamage : FireDamage; if (type == ModContent.ProjectileType()) finalProjectileVelocity *= 0.5f; @@ -534,8 +534,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (fireExtraProjectiles && shootSpear) { - int baseProjectileAmt = bossRush ? 4 : 2; - int spread = bossRush ? 18 : 10; + int baseProjectileAmt = 2; + int spread = 10; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < baseProjectileAmt; i++) { @@ -554,18 +554,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians else { // Shoot holy blasts - float holyBlastVelocity = bossRush ? 20f : death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; + float holyBlastVelocity = death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; int projTimeLeft = (int)(2000f / holyBlastVelocity); Vector2 finalHolyBlastVelocity = Vector2.Normalize(player.Center - shootFrom) * holyBlastVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) { - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, finalHolyBlastVelocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y, 1f); - Main.projectile[proj].timeLeft = projTimeLeft; - } + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, finalHolyBlastVelocity, ModContent.ProjectileType(), HolyBlastDamage, 0f, Main.myPlayer, player.position.X, player.position.Y, 1f); + Main.projectile[proj].timeLeft = projTimeLeft; } // Dust for blasting out the holy blasts @@ -667,7 +662,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.spriteDirection = Math.Sign(NPC.velocity.X); NPC.ai[1] += 1f; - float phaseGateValue = bossRush ? 90f : death ? 100f : revenge ? 110f : expertMode ? 120f : 135f; + float phaseGateValue = death ? 100f : revenge ? 110f : expertMode ? 120f : 135f; if (NPC.ai[1] >= phaseGateValue) { NPC.ai[0] = 3f; @@ -688,7 +683,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Accelerate if (NPC.velocity.Length() < maxChargeVelocity) { - float velocityMult = bossRush ? 1.053333f : death ? 1.05037f : revenge ? 1.047407f : expertMode ? 1.044444f : 1.04f; + float velocityMult = death ? 1.05037f : revenge ? 1.047407f : expertMode ? 1.044444f : 1.04f; NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); if (NPC.velocity.Length() > maxChargeVelocity) { @@ -732,10 +727,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians for (int k = 0; k < totalDustPerProjectile; k++) Dust.NewDust(shootFrom, 30, 30, (int)CalamityDusts.ProfanedFire, projectileVelocity.X, projectileVelocity.Y, 0, default, 1f); - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, ModContent.ProjectileType(), FireDamage, 0f, Main.myPlayer); } } } @@ -791,7 +784,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool targetRanAwayAndWillNowBeFucked = NPC.ai[2] == 1f; bool boostVelocityToCatchUp = NPC.ai[1] == 0f || targetRanAwayAndWillNowBeFucked; - float velocity = bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float velocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) velocity *= 1.25f; if (boostVelocityToCatchUp) @@ -803,7 +796,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 desiredVelocity = targetVector.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; float totalSpears = 12f; - float shootDuration = bossRush ? 240f : death ? 280f : revenge ? 300f : expertMode ? 320f : 360f; + float shootDuration = death ? 280f : revenge ? 300f : expertMode ? 320f : 360f; float dontShootTime = shootDuration * 0.3f; float phaseGateValue = dontShootTime + shootDuration; @@ -848,7 +841,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[1] % spearShootDivisor == 0f) { - float spearVelocity = bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float spearVelocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) spearVelocity *= 1.25f; if (boostVelocityToCatchUp) @@ -856,8 +849,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 velocity2 = Vector2.Normalize(player.Center - shootFrom) * spearVelocity; Vector2 knockbackVelocity = velocity2 * 0.1f; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, shootFrom); for (int k = 0; k < totalDustPerProjectile; k++) @@ -866,8 +857,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[1] % (spearShootDivisor * 3) == 0f || targetRanAwayAndWillNowBeFucked) { knockbackVelocity *= 2f; - int baseProjectileAmt = bossRush ? 8 : expertMode ? 6 : 4; - int spread = bossRush ? 60 : expertMode ? 50 : 40; + int baseProjectileAmt = expertMode ? 6 : 4; + int spread = expertMode ? 50 : 40; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < baseProjectileAmt; i++) { @@ -877,12 +868,12 @@ namespace CalamityMod.NPCs.ProfanedGuardians Dust.NewDust(shootFrom, 30, 30, (int)CalamityDusts.ProfanedFire, perturbedSpeed.X, perturbedSpeed.Y, 0, default, 1f); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, perturbedSpeed, type, damage, 0f, Main.myPlayer, targetRanAwayAndWillNowBeFucked ? -2f : -1f, -30f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, perturbedSpeed, ModContent.ProjectileType(), SpearDamage, 0f, Main.myPlayer, targetRanAwayAndWillNowBeFucked ? -2f : -1f, -30f); } } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, velocity2 * 0.85f, type, damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, velocity2 * 0.85f, ModContent.ProjectileType(), SpearDamage, 0f, Main.myPlayer, 1f, 0f); if (!targetRanAwayAndWillNowBeFucked) NPC.velocity = -knockbackVelocity; @@ -903,7 +894,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } float laserGateValue = 120f; - float velocity = bossRush ? 4.5f : death ? 4f : revenge ? 3.75f : expertMode ? 3.5f : 3f; + float velocity = death ? 4f : revenge ? 3.75f : expertMode ? 3.5f : 3f; if (NPC.ai[1] < laserGateValue) velocity *= 6f; if (Main.getGoodWorld) @@ -959,7 +950,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { if (NPC.ai[2] == laserGateValue) { - float rotation = bossRush ? 435f : death ? 445f : revenge ? 450f : expertMode ? 455f : 465f; + float rotation = death ? 445f : revenge ? 450f : expertMode ? 455f : 465f; if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < 2800f) SoundEngine.PlaySound(HolyRaySound, Main.LocalPlayer.Center); @@ -973,23 +964,20 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (laserVelocity.X < 0f) beamDirection = 1f; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - // 60 degrees offset laserVelocity = laserVelocity.RotatedBy(-(double)beamDirection * MathHelper.TwoPi / 6f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, laserVelocity, type, damage, 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, laserVelocity, ModContent.ProjectileType(), RayDamage, 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); // -60 degrees offset if (revenge) - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, -laserVelocity, type, damage, 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, -laserVelocity, ModContent.ProjectileType(), RayDamage, 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); - if (CalamityWorld.LegendaryMode && revenge) + if (CalamityWorld.death) { rotation *= 0.33f; laserVelocity = laserVelocity.RotatedBy(-(double)beamDirection * MathHelper.TwoPi / 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, laserVelocity, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, -laserVelocity, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, laserVelocity, ModContent.ProjectileType(), RayDamage, 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, -laserVelocity, ModContent.ProjectileType(), RayDamage, 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); } NPC.netUpdate = true; @@ -1194,28 +1182,36 @@ namespace CalamityMod.NPCs.ProfanedGuardians spriteBatch.Draw(shieldTexture, shieldDrawPos, shieldFrame, color2, NPC.rotation, origin, shieldScale * scaleMult * 0.95f, SpriteEffects.None, 0f); var matrix = Main.GameViewMatrix.TransformationMatrix; - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, shieldEffect, matrix); // Fetch shield heat overlay texture (this is the neutrons fed to the shader) Texture2D heatTex = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; Vector2 pos = NPC.Center + NPC.gfxOffY * Vector2.UnitY - Main.screenPosition; Main.spriteBatch.Draw(heatTex, shieldDrawPos, null, Color.White, 0, heatTex.Size() / 2f, shieldScale * scaleMult * 0.5f, 0, 0); - }); + Main.spriteBatch.End(); + } } return false; } - public override void BossLoot(ref string name, ref int potionType) => potionType = ItemID.SuperHealingPotion; + public override void BossLoot(ref int potionType) => potionType = ItemID.SuperHealingPotion; public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 4); npcLoot.Add(ModContent.ItemType(), 7); - npcLoot.Add(ModContent.ItemType(), 5); + + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // npcLoot.Add(ModContent.ItemType(), 1); + LeadingConditionRule expert = new LeadingConditionRule(new Conditions.IsExpert()); + expert.OnSuccess(ItemDropRule.Common(ModContent.ItemType(), 1)); + npcLoot.Add(expert); + npcLoot.Add(ModContent.ItemType(), 10); npcLoot.Add(ModContent.ItemType()); - npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 10, 15, 15, 20)); + npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 15, 20, 20, 25)); // Furniture npcLoot.Add(ModContent.ItemType(), ThankYouPainting.DropInt); @@ -1226,8 +1222,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians // GFB Chicken Nugget and Divine Geode drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.ChickenNugget, 1, 1, 9999, true); - GFBOnly.Add(ModContent.ItemType(), 1, 25, 30, true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.ChickenNugget, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30), true); } // Lore @@ -1273,13 +1269,12 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 200, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index d15b591dfc..25c30d0215 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -3,10 +3,10 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items.Accessories; -using CalamityMod.Items; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Providence; using CalamityMod.Projectiles.Boss; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -54,18 +54,23 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } + public static int FireDamage = 36; // 144; HolyFlare + public static int BlobDamage = 36; // 144 + public static int FireSentryDamage = 54; // 216; HolyBomb + public static int MoltenBlastDamage = 54; // 216 + public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 108; // 216 NPC.npcSlots = 3f; NPC.aiStyle = -1; - NPC.GetNPCDamage(); NPC.width = 228; NPC.height = 164; NPC.defense = 50; NPC.DR_NERD(0.4f); - NPC.LifeMaxNERB(40000, 48000, 35000); + NPC.LifeMaxNERB(32000, 48000, 35000); NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.noTileCollide = true; @@ -76,10 +81,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -242,17 +243,16 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Get the Guardian Commander's target Player player = Main.player[Main.npc[CalamityGlobalNPC.doughnutBoss].target]; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool phase1 = healerAlive; NPC.chaseable = !phase1; // Phase durations - float commanderGuardPhase2Duration = bossRush ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float commanderGuardPhase2Duration = death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; float timeBeforeRocksRespawnInPhase2 = 90f; float throwRocksGateValue = 60f; @@ -261,7 +261,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge variables float chargeVelocityMult = 0.25f; - float maxChargeVelocity = bossRush ? 25f : death ? 22f : revenge ? 20.5f : expertMode ? 19f : 16f; + float maxChargeVelocity = death ? 22f : revenge ? 20.5f : expertMode ? 19f : 16f; if (Main.getGoodWorld) maxChargeVelocity *= 1.15f; @@ -381,7 +381,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } - float moveVelocity = bossRush ? 24f : death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; + float moveVelocity = death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; if (Main.getGoodWorld) moveVelocity *= 1.25f; if (healerAlive) @@ -431,7 +431,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Lay a holy bomb every once in a while in phase 1 and while not doing the laser attack if (!commanderUsingLaser) { - float projectileShootGateValue = bossRush ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float projectileShootGateValue = death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; NPC.ai[1] += 1f; if (NPC.ai[1] >= projectileShootGateValue) { @@ -444,9 +444,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians projectileVelocityY += expertMode ? 4f : 3f; Vector2 projectileVelocity = new Vector2(NPC.velocity.X * 0.25f, projectileVelocityY); - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, ModContent.ProjectileType(), FireSentryDamage, 0f, Main.myPlayer); } } } @@ -501,18 +499,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians float shootMoltenBlastsGateValue = commanderGuardPhase2Duration / moltenBlastsDivisor; if (NPC.ai[1] % shootMoltenBlastsGateValue == 0f && !commanderGoingLowOrHighInPhase2) { - float moltenBlastVelocity = bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float moltenBlastVelocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; int projTimeLeft = (int)(2400f / moltenBlastVelocity); Vector2 velocity = Vector2.Normalize(player.Center - shootFrom) * moltenBlastVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) { - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, velocity, type, damage, 0f, Main.myPlayer, player.position.X, player.position.Y, 1f); - Main.projectile[proj].timeLeft = projTimeLeft; - } + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, velocity, ModContent.ProjectileType(), MoltenBlastDamage, 0f, Main.myPlayer, player.position.X, player.position.Y, 1f); + Main.projectile[proj].timeLeft = projTimeLeft; } // Dust for blasting out the molten blasts @@ -608,7 +601,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.spriteDirection = Math.Sign(NPC.velocity.X); NPC.ai[1] += 1f; - float phaseGateValue = bossRush ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; + float phaseGateValue = death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; if (NPC.ai[1] >= phaseGateValue) { NPC.ai[0] = 3f; @@ -629,7 +622,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Accelerate if (NPC.velocity.Length() < maxChargeVelocity) { - float velocityMult = bossRush ? 1.04f : death ? 1.036667f : revenge ? 1.035f : expertMode ? 1.033333f : 1.03f; + float velocityMult = death ? 1.036667f : revenge ? 1.035f : expertMode ? 1.033333f : 1.03f; NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); if (NPC.velocity.Length() > maxChargeVelocity) { @@ -641,7 +634,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians else if (NPC.localAI[2] == 1f) { // Charge towards target - float inertia = bossRush ? 57f : death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; + float inertia = death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; // Stop charging towards the player when within a certain distance @@ -672,9 +665,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians projectileVelocityY += expertMode ? 4f : 3f; Vector2 projectileVelocity = new Vector2(NPC.velocity.X * 0.25f, projectileVelocityY); - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, ModContent.ProjectileType(), FireSentryDamage, 0f, Main.myPlayer); } } } @@ -907,13 +898,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians spriteBatch.Draw(shieldTexture, shieldDrawPos, shieldFrame, color, NPC.rotation, origin, shieldScale * scaleMult, SpriteEffects.None, 0f); spriteBatch.Draw(shieldTexture, shieldDrawPos, shieldFrame, color2, NPC.rotation, origin, shieldScale * scaleMult * 0.95f, SpriteEffects.None, 0f); - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, shieldEffect, matrix); // Fetch shield heat overlay texture (this is the neutrons fed to the shader) Texture2D heatTex = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; Vector2 pos = NPC.Center + NPC.gfxOffY * Vector2.UnitY - Main.screenPosition; Main.spriteBatch.Draw(heatTex, shieldDrawPos, null, Color.White, 0, heatTex.Size() / 2f, shieldScale * scaleMult * 0.5f, 0, 0); - }); + Main.spriteBatch.End(); + } } return false; @@ -947,7 +940,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 160, true); + target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers) diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs index 1ea8449522..5dd7eda2b6 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs @@ -1,9 +1,8 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Providence; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -50,6 +49,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Main.npcFrameCount[Type] = 10; NPCID.Sets.TrailingMode[Type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); + NPCID.Sets.NeedsExpertScaling[Type] = true; NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { PortraitPositionXOverride = 0, @@ -67,18 +67,23 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } + public static int CrystalDamage = 48; // 192 + public static int StarDamage = 54; // 216; HolyBurnOrb + + public static int StarHeal = Main.expertMode ? 50 : 35; // HolyLight + public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 0; // No contact damage NPC.npcSlots = 3f; NPC.aiStyle = -1; - NPC.GetNPCDamage(); NPC.width = 228; NPC.height = 164; NPC.defense = 30; NPC.DR_NERD(0.2f); - NPC.LifeMaxNERB(60000, 72000, 50000); + NPC.LifeMaxNERB(48000, 72000, 50000); NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.noTileCollide = true; @@ -89,10 +94,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -108,7 +109,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians }); } - public float GetStarShootSlowDownGateValue() => BossRushEvent.BossRushActive ? 180f : CalamityWorld.death ? 210f : CalamityWorld.revenge ? 225f : Main.expertMode ? 240f : 270f; + public float GetStarShootSlowDownGateValue() => CalamityWorld.death ? 210f : CalamityWorld.revenge ? 225f : Main.expertMode ? 240f : 270f; public float GetStarShootGateValue() => GetStarShootSlowDownGateValue() + 60f; @@ -134,9 +135,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians { CalamityGlobalNPC.doughnutBossHealer = NPC.whoAmI; - // Avoid cheap bullshit - NPC.damage = 0; - Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1.1f, 0.9f, 0f); if (CalamityGlobalNPC.doughnutBoss < 0 || !Main.npc[CalamityGlobalNPC.doughnutBoss].active) @@ -164,10 +162,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Get the Guardian Commander's target Player player = Main.player[Main.npc[CalamityGlobalNPC.doughnutBoss].target]; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -193,7 +190,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[2] >= 45f) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); int totalProjectiles = 10; float radians = MathHelper.TwoPi / totalProjectiles; float projectileVelocity = 8f; @@ -201,7 +197,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, velocity2, type, 0, 0f, Main.myPlayer, 0f, damage); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, velocity2, type, 0, 0f, Main.myPlayer, 0f, StarHeal); } NPC.ai[2] = 0f; } @@ -216,7 +212,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } bool useCrystalShards = AIState == (float)Phase.CrystalShards; - float velocity = useCrystalShards ? (bossRush ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) : (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); + float velocity = useCrystalShards ? (death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) : (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); if (Main.getGoodWorld) velocity *= 1.25f; @@ -267,7 +263,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { // Increment timer AITimer += 1f; - float crystalShootGateValue = bossRush ? 140f : death ? 180f : revenge ? 200f : expertMode ? 220f : 260f; + float crystalShootGateValue = death ? 180f : revenge ? 200f : expertMode ? 220f : 260f; float crystalShootPhaseDuration = crystalShootGateValue + crystalShootGateValue * 0.25f; // Generate dust that scales with how close the crystals are to firing @@ -303,8 +299,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - int totalProjectiles = bossRush ? 18 : death ? 16 : revenge ? 14 : expertMode ? 12 : 10; + int totalProjectiles = death ? 16 : revenge ? 14 : expertMode ? 12 : 10; float speedX = -12f; float speedAdjustment = Math.Abs(speedX * 2f / (totalProjectiles - 1)); float speedY = -4f; @@ -320,7 +315,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians randomizedVelocity = revenge ? (new Vector2(randomFloatX, randomFloatY) * randomVelocityMult) : Vector2.Zero; } Vector2 projectileVelocity = new Vector2(speedX + speedAdjustment * i + distanceFromDestination.SafeNormalize(Vector2.Zero).X * Math.Abs(player.velocity.X), speedY) + randomizedVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, type, damage, 0f, Main.myPlayer, x4); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, type, CrystalDamage, 0f, Main.myPlayer, x4); } } } @@ -343,7 +338,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact, shootFrom); - int totalFlameProjectiles = bossRush ? 20 : 16; + int totalFlameProjectiles = 16; int totalRings = revenge ? 3 : 2; int healingStarChance = revenge ? 8 : expertMode ? 6 : 4; double radians = MathHelper.TwoPi / totalFlameProjectiles; @@ -360,16 +355,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 vector2 = spinningPoint.RotatedBy(radians * j); int type = ModContent.ProjectileType(); - int dmgAmt = NPC.GetProjectileDamage(type); if (Main.rand.NextBool(healingStarChance) && !death) { type = ModContent.ProjectileType(); - dmgAmt = NPC.GetProjectileDamageNoScaling(type); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, vector2, type, 0, 0f, Main.myPlayer, 0f, dmgAmt); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, vector2, type, 0, 0f, Main.myPlayer, 0f, StarHeal); } else if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, vector2, type, dmgAmt, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, vector2, type, StarDamage, 0f, Main.myPlayer); Color dustColor = Main.hslToRgb(Main.rgbToHsl(type == ModContent.ProjectileType() ? Color.Orange : Color.Green).X, 1f, 0.5f); dustColor.A = 255; @@ -404,7 +397,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Move towards a location above the player if (distanceFromDestination.Length() > idealDistanceFromDestination) { - float inertia = bossRush ? 28f : death ? 32f : revenge ? 34f : expertMode ? 36f : 40f; + float inertia = death ? 32f : revenge ? 34f : expertMode ? 36f : 40f; if (lifeRatio < 0.5f) inertia *= 0.8f; if (Main.getGoodWorld) @@ -568,12 +561,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians return minDist <= 80f; } - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); - } - public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) diff --git a/NPCs/ProfanedGuardians/ProfanedRocks.cs b/NPCs/ProfanedGuardians/ProfanedRocks.cs index cf2bb60939..d9988fbf75 100644 --- a/NPCs/ProfanedGuardians/ProfanedRocks.cs +++ b/NPCs/ProfanedGuardians/ProfanedRocks.cs @@ -14,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.ProfanedGuardians { + [HasPierceResist] public class ProfanedRocks : ModNPC { private bool start = true; @@ -42,9 +43,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 100; // 200 NPC.aiStyle = -1; AIType = -1; - NPC.GetNPCDamage(); NPC.dontTakeDamage = true; NPC.width = 50; NPC.height = 50; @@ -141,10 +142,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.timeLeft = 1800; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Spin and fly at the target if ((Main.npc[CalamityGlobalNPC.doughnutBossDefender].ai[0] != 0f && Main.npc[CalamityGlobalNPC.doughnutBossDefender].ai[1] >= -60f) || NPC.Calamity().newAI[0] < 0f) @@ -158,7 +158,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Distance the rock travels before it starts to fall down float maxChargeDistance = 4800f; - float chargeSpeed = bossRush ? 20f : death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; + float chargeSpeed = death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; float fallDownGateValue = maxChargeDistance / chargeSpeed; // Fall down after some time and blow up if inside tiles @@ -208,7 +208,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Start off slow Vector2 finalVelocity = NPC.SafeDirectionTo(player.Center, -Vector2.UnitY) * chargeSpeed; - if (CalamityWorld.LegendaryMode && revenge) + if (Main.getGoodWorld) finalVelocity *= Main.rand.NextFloat(1f, 1.7f); NPC.Calamity().newAI[2] = finalVelocity.X; @@ -228,7 +228,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Push away from each other in Death and Boss Rush if (death) { - float pushVelocity = bossRush ? 0.2f : 0.15f; + float pushVelocity = 0.15f; foreach (NPC n in Main.ActiveNPCs) { if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) @@ -256,7 +256,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Rotate faster and charge NPC.Calamity().newAI[1] += 1f; - float chargeGateValue = bossRush ? 60f : death ? 80f : revenge ? 90f : expertMode ? 100f : 120f; + float chargeGateValue = death ? 80f : revenge ? 90f : expertMode ? 100f : 120f; chargeGateValue += chargeGateValue * 0.5f * NPC.ai[1]; float anglularSpeed = NPC.Calamity().newAI[1] / chargeGateValue; anglularSpeed = 0.05f + anglularSpeed * 0.2f; @@ -278,7 +278,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.damage = 0; // Distance from Defender Guardian - double maxDistance = bossRush ? 360D : death ? 340D : revenge ? 330D : expertMode ? 320D : MinMaxDistance; + double maxDistance = death ? 340D : revenge ? 330D : expertMode ? 320D : MinMaxDistance; double rateOfChangeIncrease = (maxDistance / MinMaxDistance) - 1D; double rateOfChange = (NPC.ai[1] * 0.5f) + 2D + rateOfChangeIncrease; if (NPC.Calamity().newAI[0] == 0f) @@ -343,7 +343,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 80, true); + target.AddBuff(ModContent.BuffType(), 120); } public override bool CanHitPlayer(Player target, ref int cooldownSlot) diff --git a/NPCs/Providence/ProvSpawnDefense.cs b/NPCs/Providence/ProvSpawnDefense.cs index 378213ad2d..6189394f90 100644 --- a/NPCs/Providence/ProvSpawnDefense.cs +++ b/NPCs/Providence/ProvSpawnDefense.cs @@ -2,7 +2,6 @@ using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -29,7 +28,6 @@ namespace CalamityMod.NPCs.Providence public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 1f; NPC.aiStyle = -1; NPC.damage = 0; @@ -52,10 +50,6 @@ namespace CalamityMod.NPCs.Providence NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void FindFrame(int frameHeight) diff --git a/NPCs/Providence/ProvSpawnHealer.cs b/NPCs/Providence/ProvSpawnHealer.cs index a89548e32b..bc564f3ab9 100644 --- a/NPCs/Providence/ProvSpawnHealer.cs +++ b/NPCs/Providence/ProvSpawnHealer.cs @@ -2,7 +2,6 @@ using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -51,10 +50,6 @@ namespace CalamityMod.NPCs.Providence NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void FindFrame(int frameHeight) diff --git a/NPCs/Providence/ProvSpawnOffense.cs b/NPCs/Providence/ProvSpawnOffense.cs index 2466f1a134..7354728a61 100644 --- a/NPCs/Providence/ProvSpawnOffense.cs +++ b/NPCs/Providence/ProvSpawnOffense.cs @@ -2,7 +2,6 @@ using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -29,7 +28,6 @@ namespace CalamityMod.NPCs.Providence public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.Calamity().canBreakPlayerDefense = true; NPC.npcSlots = 1f; NPC.aiStyle = -1; NPC.damage = 0; @@ -52,10 +50,6 @@ namespace CalamityMod.NPCs.Providence NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void FindFrame(int frameHeight) diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 2130aad947..172e2d814e 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -3,10 +3,8 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Armor.Vanity; @@ -14,9 +12,10 @@ using CalamityMod.Items.Dyes; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; +using CalamityMod.Items.Potions.Food; using CalamityMod.Items.SummonItems; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; @@ -29,8 +28,9 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; -using CalamityMod.Tiles.FurnitureProfaned; +using CalamityMod.Systems.Graphic; using CalamityMod.Tiles.Ores; +using CalamityMod.Utilities.Daybreak; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -46,6 +46,7 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using Terraria.ModLoader.IO; using Filters = Terraria.Graphics.Effects.Filters; namespace CalamityMod.NPCs.Providence @@ -53,7 +54,7 @@ namespace CalamityMod.NPCs.Providence [AutoloadBossHead] public class Providence : ModNPC { - private enum Phase + private enum Phase : sbyte { PhaseChange = -1, HolyBlast = 0, @@ -85,10 +86,10 @@ namespace CalamityMod.NPCs.Providence private bool text = false; private bool useDefenseFrames = false; private float bossLife; - private int biomeType = 0; + private byte biomeType = 0; private int flightPath = 0; - private int phaseChange = 0; - private int frameUsed = 0; + private sbyte phaseChange = 0; + private byte frameUsed = 0; private int healTimer = 0; internal bool challenge = Main.expertMode; // Used to determine if Profaned Soul Crystal should drop, couldn't figure out mp mems always dropping it so challenge is singleplayer only. public bool hasBeenGivenFullPower = false; @@ -169,6 +170,7 @@ namespace CalamityMod.NPCs.Providence Main.npcFrameCount[Type] = 3; NPCID.Sets.TrailingMode[Type] = 1; NPCID.Sets.BossBestiaryPriority.Add(Type); + NPCID.Sets.NeedsExpertScaling[Type] = true; NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { Scale = 0.2f, @@ -237,19 +239,41 @@ namespace CalamityMod.NPCs.Providence base.ModifyHoverBoundingBox(ref boundingBox); } + public static int FireDamage = 36; // 144; HolyFire, HolyFire2, HolyFlare + public static int BlobDamage = 36; // 144 + public static int FireSentryDamage = 54; // 216; HolyBomb + public static int MoltenBlastDamage = 54; // 216 + public static int StarDamage = 54; // 216; HolyBurnOrb + public static int SpearDamage = 42; // 168 + public static int CrystalDamage = 48; // 192 + public static int HolyBlastDamage = 60; // 240 + public static int RayDamage = 100; // 400 + + public static int StarHeal = Main.expertMode ? 50 : 35; // HolyLight + + public override void Load() + { + GeneralDrawLayerSystem.OnBeforeAllTiles += DrawHolyInferno; + } + + public override void Unload() + { + GeneralDrawLayerSystem.OnBeforeAllTiles -= DrawHolyInferno; + } + public override void SetDefaults() { NPC.npcSlots = 36f; - NPC.damage = 100; + NPC.damage = 0; // No contact damage NPC.width = 600; NPC.height = 450; NPC.defense = 50; NPC.DR_NERD(normalDR); - NPC.LifeMaxNERB(312500, 375000, 1250000); // Old HP - 440000, 500000 + NPC.LifeMaxNERB(250000, 375000, 1250000); // Old HP - 440000, 500000 NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(1, 50, 0, 0); + NPC.value = Item.buyPrice(platinum: 1, gold: 50); NPC.boss = true; NPC.Opacity = 0f; NPC.noGravity = true; @@ -263,9 +287,6 @@ namespace CalamityMod.NPCs.Providence if (Main.getGoodWorld) NPC.scale *= 0.25f; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -280,24 +301,28 @@ namespace CalamityMod.NPCs.Providence public override void SendExtraAI(BinaryWriter writer) { - writer.Write(text); - writer.Write(useDefenseFrames); + var bits = new BitsByte(); + bits[0] = text; + bits[1] = useDefenseFrames; + bits[2] = NPC.dontTakeDamage; + bits[3] = NPC.chaseable; + bits[4] = Dying; + bits[5] = shouldDrawInfernoBorder; + bits[6] = flightPath != 0; + bits[7] = flightPath == 1; + writer.Write(bits); + writer.Write(biomeType); writer.Write(phaseChange); writer.Write(frameUsed); writer.Write(healTimer); - writer.Write(flightPath); - writer.Write(NPC.dontTakeDamage); - writer.Write(NPC.chaseable); writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); writer.Write(NPC.localAI[2]); writer.Write(NPC.localAI[3]); - writer.Write(SoundWarningLevel); - writer.Write(Dying); + writer.Write((Half)SoundWarningLevel); writer.Write(DeathAnimationTimer); writer.Write(borderRadius); - writer.Write(shouldDrawInfernoBorder); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -305,24 +330,28 @@ namespace CalamityMod.NPCs.Providence public override void ReceiveExtraAI(BinaryReader reader) { bool wasDyingBefore = Dying; - text = reader.ReadBoolean(); - useDefenseFrames = reader.ReadBoolean(); - biomeType = reader.ReadInt32(); - phaseChange = reader.ReadInt32(); - frameUsed = reader.ReadInt32(); + + var bits = reader.ReadBitsByte(); + text = bits[0]; + useDefenseFrames = bits[1]; + NPC.dontTakeDamage = bits[2]; + NPC.chaseable = bits[3]; + Dying = bits[4]; + shouldDrawInfernoBorder = bits[5]; + if (bits[6]) flightPath = bits[7] ? 1 : -1; + else flightPath = 0; + + biomeType = reader.ReadByte(); + phaseChange = reader.ReadSByte(); + frameUsed = reader.ReadByte(); healTimer = reader.ReadInt32(); - flightPath = reader.ReadInt32(); - NPC.dontTakeDamage = reader.ReadBoolean(); - NPC.chaseable = reader.ReadBoolean(); NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); NPC.localAI[2] = reader.ReadSingle(); NPC.localAI[3] = reader.ReadSingle(); - SoundWarningLevel = reader.ReadSingle(); - Dying = reader.ReadBoolean(); + SoundWarningLevel = (float)reader.ReadHalf(); DeathAnimationTimer = reader.ReadInt32(); borderRadius = reader.ReadSingle(); - shouldDrawInfernoBorder = reader.ReadBoolean(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); @@ -358,12 +387,10 @@ namespace CalamityMod.NPCs.Providence Player player = Main.player[NPC.target]; // Enraged bool and Color shifting - bool bossRush = BossRushEvent.BossRushActive; - bool getFuckedAI = Main.zenithWorld; if (getFuckedAI) NPC.localAI[1] = (float)BossMode.Rainbow; - else if (hasBeenGivenFullPower || bossRush) // Enraged behavior + else if (hasBeenGivenFullPower) // Enraged behavior NPC.localAI[1] = (float)BossMode.Enraged; else NPC.localAI[1] = (float)BossMode.Normal; @@ -414,24 +441,7 @@ namespace CalamityMod.NPCs.Providence NPC.ForceNetUpdate(false); } - // Increase all projectile damage while enraged, but reduce to 0 for Zenith - int projectileDamageMult = 1; - if (getFuckedAI) - projectileDamageMult = 0; - else if (fullPowerAI) - projectileDamageMult = 2; - - NPC.Calamity().CurrentlyEnraged = !bossRush && fullPowerAI; - - // Projectile damage values - int holyLaserDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int crystalDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holySpearDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyBombDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int moltenBlastDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyFireDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyBlastDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; - int holyStarDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; + NPC.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && fullPowerAI; // Change dust type while enraged int dustType = ProvUtils.GetDustID(); @@ -450,13 +460,9 @@ namespace CalamityMod.NPCs.Providence // Spear phase float spearRateIncrease = 1f - lifeRatio; - float bossRushSpearRateIncrease = 0.25f; float baseSpearRate = 18f; float spearRate = 1f + spearRateIncrease; - if (bossRush) - spearRate += bossRushSpearRateIncrease; - // Projectile fire rate multiplier double attackRateMult = 1D; @@ -654,20 +660,6 @@ namespace CalamityMod.NPCs.Providence return; } - // Damage - if (attackerAlive) - { - double damageMult = 1.25; - holyLaserDamage = (int)(holyLaserDamage * damageMult); - crystalDamage = (int)(crystalDamage * damageMult); - holySpearDamage = (int)(holySpearDamage * damageMult); - holyBombDamage = (int)(holyBombDamage * damageMult); - moltenBlastDamage = (int)(moltenBlastDamage * damageMult); - holyFireDamage = (int)(holyFireDamage * damageMult); - holyBlastDamage = (int)(holyBlastDamage * damageMult); - holyStarDamage = (int)(holyStarDamage * damageMult); - } - // Defense if (defenderAlive) NPC.defense = NPC.defDefense * 2; @@ -822,17 +814,22 @@ namespace CalamityMod.NPCs.Providence bool laserPhaseSlow = AIState == (int)Phase.Laser; // Change X direction of movement - if (flightPath == 0) + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (NPC.Center.X < player.Center.X) + if (flightPath == 0) { - flightPath = 1; - calamityGlobalNPC.newAI[0] = 0f; - } - else - { - flightPath = -1; - calamityGlobalNPC.newAI[0] = 0f; + if (NPC.Center.X < player.Center.X) + { + flightPath = 1; + calamityGlobalNPC.newAI[0] = 0f; + NPC.netUpdate = true; + } + else + { + flightPath = -1; + calamityGlobalNPC.newAI[0] = 0f; + NPC.netUpdate = true; + } } } @@ -849,10 +846,21 @@ namespace CalamityMod.NPCs.Providence changeDirectionThreshold += death ? 240f : revenge ? 180f : 120f; // Change X movement path if far enough away from target - if (NPC.Center.X < player.Center.X && flightPath < 0 && distanceX > changeDirectionThreshold) - flightPath = 0; - if (NPC.Center.X > player.Center.X && flightPath > 0 && distanceX > changeDirectionThreshold) - flightPath = 0; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.Center.X < player.Center.X && flightPath < 0 && distanceX > changeDirectionThreshold) + { + flightPath = 0; + NPC.netUpdate = true; + } + + if (NPC.Center.X > player.Center.X && flightPath > 0 && distanceX > changeDirectionThreshold) + { + flightPath = 0; + NPC.netUpdate = true; + } + } + // Predictive shot checks if ((NPC.velocity.X > 0f && (NPC.Center.X - player.Center.X) > 0f && player.velocity.X > 0f) || (NPC.velocity.X < 0f && (NPC.Center.X - player.Center.X) < 0f && player.velocity.X < 0f)) @@ -860,7 +868,7 @@ namespace CalamityMod.NPCs.Providence // Velocity and acceleration float speedIncreaseTimer = fullPowerAI ? 75f : death ? 120f : 150f; - bool increaseSpeed = calamityGlobalNPC.newAI[0] > speedIncreaseTimer || bossRush; + bool increaseSpeed = calamityGlobalNPC.newAI[0] > speedIncreaseTimer; float accelerationBoost = death ? 0.3f * (1f - lifeRatio) : 0.2f * (1f - lifeRatio); float velocityBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); float acceleration = (expertMode ? 1.1f : 1.05f) + accelerationBoost; @@ -878,10 +886,8 @@ namespace CalamityMod.NPCs.Providence else if (increaseSpeed) { velocity += (calamityGlobalNPC.newAI[0] - speedIncreaseTimer) * 0.04f; - if (velocity > 30f || bossRush) + if (velocity > 30f) velocity = 30f; - if (bossRush) - acceleration = 2f; } if (Main.getGoodWorld) @@ -919,7 +925,7 @@ namespace CalamityMod.NPCs.Providence // Phase switch switch ((int)AIState) { - case (int)Phase.PhaseChange: + case (int)Phase.PhaseChange when Main.netMode != NetmodeID.MultiplayerClient: // Only Server or SP should handle Phase Transition phaseChange++; if (phaseChange > 14) @@ -928,8 +934,8 @@ namespace CalamityMod.NPCs.Providence int phase = 0; // Holy ray in hallow, Crystal in hell - bool useLaser = (phase2 && biomeType == 1) || bossRush; - bool useCrystal = (phase2 && biomeType == 2) || bossRush; + bool useLaser = (phase2 && biomeType == 1) || BossRushEvent.BossRushActive; + bool useCrystal = (phase2 && biomeType == 2) || BossRushEvent.BossRushActive; // Unique pattern for Death Mode and Boss Rush if (death) @@ -1161,7 +1167,7 @@ namespace CalamityMod.NPCs.Providence NPC.ai[3] += 1f; int shootBoost = death ? (int)Math.Round(5f * (1f - lifeRatio)) : (int)Math.Round(4f * (1f - lifeRatio)); - int projectileShootGateValue = (bossRush ? 18 : expertMode ? 24 : 26) - shootBoost; + int projectileShootGateValue = (expertMode ? 24 : 26) - shootBoost; projectileShootGateValue = (int)(projectileShootGateValue * attackRateMult); @@ -1176,7 +1182,7 @@ namespace CalamityMod.NPCs.Providence Vector2 predictionAmount = player.velocity * 100f; Vector2 projectileVelocity = (player.Center + (predictiveShots ? predictionAmount : Vector2.Zero) - projectileFirePosition).SafeNormalize(Vector2.UnitY) * projSpeed * 0.1f; Vector2 explodePosition = predictiveShots ? (player.position + predictionAmount) : player.position; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileFirePosition, projectileVelocity, ModContent.ProjectileType(), holyBlastDamage, 0f, Main.myPlayer, explodePosition.X, explodePosition.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileFirePosition, projectileVelocity, ModContent.ProjectileType(), HolyBlastDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, explodePosition.X, explodePosition.Y); } } else if (NPC.ai[3] < 0f) @@ -1206,8 +1212,6 @@ namespace CalamityMod.NPCs.Providence int shootBoost = death ? (int)Math.Round(6f * (1f - lifeRatio)) : (int)Math.Round(5f * (1f - lifeRatio)); int projectileShootGateValue = (expertMode ? 36 : 39) - shootBoost; - if (bossRush) - projectileShootGateValue = 27; projectileShootGateValue = (int)(projectileShootGateValue * attackRateMult); @@ -1226,7 +1230,7 @@ namespace CalamityMod.NPCs.Providence if (fullPowerAI) projectileVelocityY *= 2f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom.X, shootFrom.Y, NPC.velocity.X * 0.25f, projectileVelocityY, ModContent.ProjectileType(), holyFireDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom.X, shootFrom.Y, NPC.velocity.X * 0.25f, projectileVelocityY, ModContent.ProjectileType(), FireDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer); } } @@ -1255,7 +1259,7 @@ namespace CalamityMod.NPCs.Providence } float divisor = (expertMode ? 2f : 3f) + (float)Math.Floor(3f * lifeRatio) + (attackRateMult > 1D ? (float)Math.Ceiling(attackRateMult * 1.6) : 0f); - int totalFlameProjectiles = bossRush ? 45 : 36; + int totalFlameProjectiles = 36; int chains = 4; float interval = totalFlameProjectiles / chains * divisor; double patternInterval = Math.Floor(NPC.ai[3] / interval); @@ -1276,17 +1280,13 @@ namespace CalamityMod.NPCs.Providence { Vector2 vector2 = spinningPoint.RotatedBy(radians * i + MathHelper.ToRadians(NPC.ai[2])); - int projectileType = ModContent.ProjectileType(); - int dmgAmt = holyStarDamage; if (Main.rand.NextBool(healingStarChance) && !death) { - projectileType = ModContent.ProjectileType(); - dmgAmt = NPC.GetProjectileDamageNoScaling(projectileType); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, dmgAmt); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, StarHeal); } else if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, projectileType, dmgAmt, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, ModContent.ProjectileType(), StarDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer); } // Radial offset @@ -1299,7 +1299,7 @@ namespace CalamityMod.NPCs.Providence { NPC.ai[2] = 0f; - totalFlameProjectiles = bossRush ? 20 : 16; + totalFlameProjectiles = 16; if (NPC.ai[3] % (divisor * totalFlameProjectiles) == 0f) { calamityGlobalNPC.newAI[1] += 1f; @@ -1313,17 +1313,13 @@ namespace CalamityMod.NPCs.Providence { Vector2 vector2 = spinningPoint.RotatedBy(radians * i); - int projectileType = ModContent.ProjectileType(); - int dmgAmt = holyStarDamage; if (Main.rand.NextBool(healingStarChance) && !death) { - projectileType = ModContent.ProjectileType(); - dmgAmt = NPC.GetProjectileDamageNoScaling(projectileType); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, projectileType, 0, 0f, Main.myPlayer, 0f, dmgAmt); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, StarHeal); } else if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, projectileType, dmgAmt, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, vector2, ModContent.ProjectileType(), StarDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer); } } } @@ -1343,9 +1339,8 @@ namespace CalamityMod.NPCs.Providence foreach (int t in targets) { Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - fireSparklesFrom) * cocoonProjVelocity * 1.5f; - int type = ModContent.ProjectileType(); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, velocity2, type, holyStarDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireSparklesFrom, velocity2, ModContent.ProjectileType(), StarDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer); Color dustColor = Main.hslToRgb(Main.rgbToHsl(fullPowerAI ? new Color(100, 200, 250) : Color.Orange).X, 1f, 0.5f); dustColor.A = 255; @@ -1379,7 +1374,7 @@ namespace CalamityMod.NPCs.Providence string key = "Mods.CalamityMod.Status.Boss.ProfanedBossText"; Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Inflict Icarus Folly @@ -1388,7 +1383,7 @@ namespace CalamityMod.NPCs.Providence if (!Main.dedServ) { Player player2 = Main.LocalPlayer; - bool inLiquid = (player2.wet || player2.honeyWet) && !player2.lavaWet; + bool inLiquid = player2.Calamity().countsAsAnyWet && !player2.lavaWet; if (!player2.dead && player2.active && Vector2.Distance(player2.Center, NPC.Center) < 2800f && !inLiquid) { @@ -1445,8 +1440,6 @@ namespace CalamityMod.NPCs.Providence int shootBoost = death ? (int)Math.Round(5f * (1f - lifeRatio)) : (int)Math.Round(4f * (1f - lifeRatio)); int projectileShootGateValue = (expertMode ? 24 : 26) - shootBoost; - if (bossRush) - projectileShootGateValue = 18; projectileShootGateValue = (int)(projectileShootGateValue * attackRateMult); @@ -1461,7 +1454,7 @@ namespace CalamityMod.NPCs.Providence Vector2 predictionAmount = player.velocity * 100f; Vector2 projectileVelocity = (player.Center + (predictiveShots ? predictionAmount : Vector2.Zero) - projectileFirePosition).SafeNormalize(Vector2.UnitY) * projSpeed * 0.1f; Vector2 explodePosition = predictiveShots ? (player.position + predictionAmount) : player.position; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileFirePosition, projectileVelocity, ModContent.ProjectileType(), moltenBlastDamage, 0f, Main.myPlayer, explodePosition.X, explodePosition.Y); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileFirePosition, projectileVelocity, ModContent.ProjectileType(), MoltenBlastDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, explodePosition.X, explodePosition.Y); } } else if (NPC.ai[3] < 0f) @@ -1490,7 +1483,7 @@ namespace CalamityMod.NPCs.Providence NPC.ai[3] += 1f; int shootBoost = death ? (int)Math.Round(12f * (1f - lifeRatio)) : (int)Math.Round(10f * (1f - lifeRatio)); - int projectileShootGateValue = (bossRush ? 54 : expertMode ? 73 : 77) - shootBoost; + int projectileShootGateValue = (expertMode ? 73 : 77) - shootBoost; projectileShootGateValue = (int)(projectileShootGateValue * attackRateMult); @@ -1506,7 +1499,7 @@ namespace CalamityMod.NPCs.Providence projectileVelocityY += expertMode ? 4f : 3f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom.X, shootFrom.Y, NPC.velocity.X * 0.25f, projectileVelocityY, ModContent.ProjectileType(), holyBombDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom.X, shootFrom.Y, NPC.velocity.X * 0.25f, projectileVelocityY, ModContent.ProjectileType(), FireSentryDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer); } } @@ -1549,7 +1542,7 @@ namespace CalamityMod.NPCs.Providence if (calamityGlobalNPC.newAI[2] % 2f == 0f) { - int totalSpearProjectiles = bossRush ? 15 : 12; + int totalSpearProjectiles = 12; double radians = MathHelper.TwoPi / totalSpearProjectiles; Vector2 spinningPoint = Vector2.Normalize(new Vector2(-calamityGlobalNPC.newAI[1], -cocoonProjVelocity)); @@ -1565,10 +1558,10 @@ namespace CalamityMod.NPCs.Providence if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, vector2, projectileType, holySpearDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, vector2, projectileType, SpearDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer); - if (CalamityWorld.LegendaryMode && revenge) - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, -vector2, projectileType, holySpearDamage, 0f, Main.myPlayer); + if (Main.getGoodWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, -vector2, projectileType, SpearDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer); } } @@ -1592,10 +1585,10 @@ namespace CalamityMod.NPCs.Providence if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, velocity2, projectileType, holySpearDamage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, velocity2, projectileType, SpearDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, 1f, 0f); - if (CalamityWorld.LegendaryMode && revenge) - Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, -velocity2, projectileType, holySpearDamage, 0f, Main.myPlayer, 1f, 0f); + if (Main.getGoodWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, -velocity2, projectileType, SpearDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, 1f, 0f); } } @@ -1684,7 +1677,7 @@ namespace CalamityMod.NPCs.Providence if (Main.netMode != NetmodeID.MultiplayerClient) { float timeLeft = fullPowerAI ? (float)(getFuckedAI ? gfbCrystalTime : enragedCrystalTime) : 0f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), crystalSpawnPos, Vector2.Zero, ModContent.ProjectileType(), crystalDamage, 0f, Main.myPlayer, lifeRatio, 0f, timeLeft); + Projectile.NewProjectile(NPC.GetSource_FromAI(), crystalSpawnPos, Vector2.Zero, ModContent.ProjectileType(), CrystalDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, lifeRatio, 0f, timeLeft); } } @@ -1746,20 +1739,20 @@ namespace CalamityMod.NPCs.Providence // 60 degrees offset velocity = velocity.RotatedBy(-(double)beamDirection * MathHelper.TwoPi / 6f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, velocity.X, velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, velocity.X, velocity.Y, ModContent.ProjectileType(), RayDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); // -60 degrees offset if (revenge) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, -velocity.X, -velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, -velocity.X, -velocity.Y, ModContent.ProjectileType(), RayDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); if (fullPowerAI && lifeRatio < 0.5f) { rotation *= 0.33f; velocity = velocity.RotatedBy(-(double)beamDirection * MathHelper.TwoPi / 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, velocity.X, velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, velocity.X, velocity.Y, ModContent.ProjectileType(), RayDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); if (revenge) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, -velocity.X, -velocity.Y, ModContent.ProjectileType(), holyLaserDamage, 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 64f * NPC.scale, -velocity.X, -velocity.Y, ModContent.ProjectileType(), RayDamage.CalculateProvidenceDamage(), 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI, ai2: 2f); } NPC.ForceNetUpdate(false); @@ -1816,7 +1809,7 @@ namespace CalamityMod.NPCs.Providence { CalamityUtils.AddScreenshakeAt(NPC.Center, 5, 2000); - Color hiColor = ProvUtils.GetProjectileColor( 255, false); + Color hiColor = ProvUtils.GetProjectileColor(255, false); Color loColor = ProvUtils.GetProjectileColor(0, true); for (int i = 0; i < 30; i++) @@ -1955,8 +1948,6 @@ namespace CalamityMod.NPCs.Providence } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; - public override bool CheckDead() { NPC.life = 1; @@ -2008,8 +1999,8 @@ namespace CalamityMod.NPCs.Providence CalamityUtils.SpawnOre(ModContent.TileType(), 17E-05, 0.55f, 0.9f, 8, 14, TileID.Mud); - CalamityUtils.DisplayLocalizedText(key2, messageColor2); - CalamityUtils.DisplayLocalizedText(key3, messageColor3); + CalamityUtils.BroadcastLocalizedText(key2, messageColor2); + CalamityUtils.BroadcastLocalizedText(key3, messageColor3); } if (challenge) @@ -2052,7 +2043,7 @@ namespace CalamityMod.NPCs.Providence { Providence prov = info.npc.ModNPC(); return prov.hasBeenGivenFullPower; - }, ModContent.ItemType(), 1, 30, 40); + }, ModContent.ItemType(), 1, 75, 90); // Normal drops: Everything that would otherwise be in the bag var normalOnly = npcLoot.DefineNormalOnlyDropSet(); @@ -2072,11 +2063,12 @@ namespace CalamityMod.NPCs.Providence normalOnly.Add(ModContent.ItemType(), 10); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Materials - normalOnly.Add(ModContent.ItemType(), 1, 25, 30); - normalOnly.Add(ModContent.ItemType(), 1, 20, 30); + normalOnly.Add(ModContent.ItemType(), 1, 50, 60); + normalOnly.Add(ModContent.ItemType(), 1, 30, 40); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -2091,15 +2083,15 @@ namespace CalamityMod.NPCs.Providence // GFB ASE and Blasphemous Donut drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), 1, 1, 99, true); - GFBOnly.Add(ModContent.ItemType(), 1, 1117, 2201, true); // Reference to the versions the guards were added and got their latest resprites + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 99), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1117, 2201), true); // Reference to the versions the guards were added and got their latest resprites } // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedProvidence, ModContent.ItemType(), desc: DropHelper.FirstKillText); } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -2425,13 +2417,15 @@ namespace CalamityMod.NPCs.Providence shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3()); var matrix = Main.GameViewMatrix.TransformationMatrix; - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () => + using (Main.spriteBatch.Scope()) { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, shieldEffect, matrix); // Fetch shield heat overlay texture (this is the neutrons fed to the shader) Texture2D heatTex = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; Vector2 pos = NPC.Center + NPC.gfxOffY * Vector2.UnitY - Main.screenPosition; Main.spriteBatch.Draw(heatTex, shieldDrawPos, null, Color.White, 0, heatTex.Size() / 2f, shieldScale * scaleMult * 0.5f, 0, 0); - }); + Main.spriteBatch.End(); + } } return false; } @@ -2534,6 +2528,64 @@ namespace CalamityMod.NPCs.Providence } } + private static Asset DiagonalNoise => field ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise"); + private static Asset UpwardPerlinNoise => field ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Perlin"); + private static Asset UpwardNoise => field ??= ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise"); + + private static void DrawHolyInferno() + { + if (Main.gameMenu || !shouldDrawInfernoBorder) + return; + + if (CalamityGlobalNPC.holyBoss == -1) + return; + + var npc = Main.npc[CalamityGlobalNPC.holyBoss]; + var borderDistance = borderRadius; + if (!npc.active || !npc.HasValidTarget) + return; + + var target = Main.LocalPlayer; + var holyInfernoIntensity = target.Calamity().holyInfernoFadeIntensity; + var prov = npc.ModNPC(); + if (prov == null) + return; + + //Begin drawing the inferno + var blackTile = TextureAssets.MagicPixel; + + var maxOpacity = 1f; + if (prov.Dying) + { + //Death animation timer ends at 345f. + maxOpacity = MathHelper.Lerp(1f, 0f, Utils.GetLerpValue(0f, 344f, prov.DeathAnimationTimer)); + } + + var shader = GameShaders.Misc["CalamityMod:HolyInfernoShader"].Shader; + shader.Parameters["colorMult"].SetValue(prov.hasBeenGivenFullPower ? 7.65f : 7.35f); //I want you to know it took considerable restraint to deliberately misspell colour. + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["radius"].SetValue(borderDistance); + shader.Parameters["anchorPoint"].SetValue(npc.Center); + shader.Parameters["screenPosition"].SetValue(Main.screenPosition); + shader.Parameters["screenSize"].SetValue(Main.ScreenSize.ToVector2()); + shader.Parameters["burnIntensity"].SetValue(holyInfernoIntensity); + shader.Parameters["playerPosition"].SetValue(target.Center); + shader.Parameters["maxOpacity"].SetValue(maxOpacity); + shader.Parameters["day"].SetValue(!prov.hasBeenGivenFullPower); + + Main.spriteBatch.GraphicsDevice.Textures[1] = DiagonalNoise.Value; + Main.spriteBatch.GraphicsDevice.Textures[2] = UpwardNoise.Value; + Main.spriteBatch.GraphicsDevice.Textures[3] = UpwardPerlinNoise.Value; + + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, shader, Main.Transform); + + Rectangle rekt = new(Main.screenWidth / 2, Main.screenHeight / 2, Main.screenWidth, Main.screenHeight); + Main.spriteBatch.Draw(blackTile.Value, rekt, null, default, 0f, blackTile.Value.Size() * 0.5f, 0, 0f); + + //Inferno drawing complete + Main.spriteBatch.End(); + } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { scale = 2f; @@ -2543,7 +2595,6 @@ namespace CalamityMod.NPCs.Providence public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * 0.8f); } public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) @@ -2661,28 +2712,56 @@ namespace CalamityMod.NPCs.Providence ///
public class ProvItemFloating : GlobalItem { - public override void Load() + // Leaving this for mod compatibility + public static readonly List FlameItemTypes = []; + + public override void SetStaticDefaults() { - On_CommonCode.ModifyItemDropFromNPC += On_CommonCode_ModifyItemDropFromNPC; + FlameItemTypes.AddRange([ + // Resources + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + + // Weapons + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + + // Equipment + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + + // Vanity + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + + // GFB + ModContent.ItemType(), + ModContent.ItemType() + ]); } - public override void Unload() + public override bool AppliesToEntity(Item entity, bool lateInstantiation) { - On_CommonCode.ModifyItemDropFromNPC -= On_CommonCode_ModifyItemDropFromNPC; - } + if (FlameItemTypes.Contains(entity.type)) + { + return true; + } - private void On_CommonCode_ModifyItemDropFromNPC(On_CommonCode.orig_ModifyItemDropFromNPC orig, NPC npc, int itemIndex) - { - if (npc.type == ModContent.NPCType() && !BossRushEvent.BossRushActive) - { - Main.item[itemIndex].GetGlobalItem().HolyFlame = 2f; - if ((npc.ModNPC as Providence).hasBeenGivenFullPower) - Main.item[itemIndex].GetGlobalItem().ProviWasEnraged = true; - } - else - { - orig(npc, itemIndex); - } + return false; } public override bool InstancePerEntity => true; @@ -2691,6 +2770,27 @@ namespace CalamityMod.NPCs.Providence public float FlameTimer = 0f; public bool ProviWasEnraged = false; + public override void OnSpawn(Item item, IEntitySource source) + { + if (!BossRushEvent.BossRushActive && source is EntitySource_Loot loot && loot.Entity is NPC npc && npc.ModNPC is Providence provi) + { + HolyFlame = 2f; + ProviWasEnraged = provi.hasBeenGivenFullPower; + } + } + + public override void NetSend(Item item, BinaryWriter writer) + { + writer.Write((Half)HolyFlame); + writer.Write(ProviWasEnraged); + } + + public override void NetReceive(Item item, BinaryReader reader) + { + HolyFlame = (float)reader.ReadHalf(); + ProviWasEnraged = reader.ReadBoolean(); + } + public override void Update(Item item, ref float gravity, ref float maxFallSpeed) { float clp = MathHelper.Clamp(HolyFlame, 0f, 1f); @@ -2765,7 +2865,29 @@ namespace CalamityMod.NPCs.Providence // These will be used for almost every single one of her projectiles, so it's useful to have. public static class ProvUtils { - public static bool StandardAI() => (CalamityGlobalNPC.holyBoss == -1 || !Main.npc[CalamityGlobalNPC.holyBoss].Calamity().CurrentlyEnraged) && !Main.zenithWorld && !BossRushEvent.BossRushActive; + public static bool StandardAI() => (CalamityGlobalNPC.holyBoss == -1 || !Main.npc[CalamityGlobalNPC.holyBoss].Calamity().CurrentlyEnraged) && !Main.zenithWorld; + + public static int CalculateProvidenceDamage(this int damage) + { + // GFB replaces conventional damage with negative healing + if (Main.zenithWorld) + return 0; + + // Enrage + if (CalamityGlobalNPC.holyBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.holyBoss].Calamity().CurrentlyEnraged) + damage *= 2; + } + + // Offense Guardian + if (CalamityGlobalNPC.holyBossAttacker != -1) + { + if (Main.npc[CalamityGlobalNPC.holyBossAttacker].active) + damage = (int)(damage * 1.25f); + } + return damage; + } // Simplified to day/night only. For PSC public static Color GetColorBasedOnEnrage(int Alpha, bool Outline = false) => GetColorBasedOnEnrage(!Main.IsItDay() && !Main.remixWorld, Alpha, Outline); @@ -2822,7 +2944,7 @@ namespace CalamityMod.NPCs.Providence return FinalColor; } - + public static Color GetProjectileColor(int Alpha, bool Outline = false) { Color FinalColor = new Color(255, Outline ? 0 : 155, Outline ? 0 : 25, Alpha); // Default to normal @@ -2960,7 +3082,7 @@ namespace CalamityMod.NPCs.Providence Target.statLife -= NegativeHealValue; if (Target.statLife < 0) { - PlayerDeathReason CustomSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ProvidenceAntiHealing").Format(Target.name)); + PlayerDeathReason CustomSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ProvidenceAntiHealing").ToNetworkText(Target.name)); Target.KillMe(CustomSource, NegativeHealValue, 0); } diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs index 78144eff7a..8a7abc4e6c 100644 --- a/NPCs/Ravager/FlamePillar.cs +++ b/NPCs/Ravager/FlamePillar.cs @@ -20,6 +20,7 @@ namespace CalamityMod.NPCs.Ravager public override void SetStaticDefaults() { this.HideFromBestiary(); + NPCID.Sets.ImmuneToAllBuffs[Type] = true; Main.npcFrameCount[Type] = 4; if (!Main.dedServ) { @@ -27,15 +28,16 @@ namespace CalamityMod.NPCs.Ravager } } + public static int FlameDamage = 30; // 120 + public static int PostProviFlameBuff = 20; // +80 = 200 + public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 75; // 150 NPC.width = 40; NPC.height = 150; - NPC.defense = 35; - NPC.DR_NERD(0.2f); NPC.chaseable = false; - NPC.lifeMax = DownedBossSystem.downedProvidence ? 14000 : 3500; + NPC.lifeMax = 1250; NPC.alpha = 255; NPC.aiStyle = -1; AIType = -1; @@ -44,10 +46,6 @@ namespace CalamityMod.NPCs.Ravager NPC.DeathSound = SoundID.NPCDeath14; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void FindFrame(int frameHeight) @@ -60,6 +58,10 @@ namespace CalamityMod.NPCs.Ravager public override void AI() { + if (NPC.lifeMax > 1250) + NPC.lifeMax = 1250; + if (NPC.life > NPC.lifeMax) + NPC.life = NPC.lifeMax; // Avoid cheap bullshit NPC.damage = 0; @@ -122,8 +124,8 @@ namespace CalamityMod.NPCs.Ravager } Vector2 velocity = new Vector2(speedX, speedY); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, 0f); + NPC.SimpleStrikeNPC(NPC.lifeMax/4,0,false,noPlayerInteraction:true); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, FlameDamage + (provy ? PostProviFlameBuff : 0), 0f, Main.myPlayer, 0f, 0f); } NPC.ai[2] += 1f; @@ -138,6 +140,7 @@ namespace CalamityMod.NPCs.Ravager } } } + public override bool? CanFallThroughPlatforms() => NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height; public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { @@ -214,5 +217,40 @@ namespace CalamityMod.NPCs.Ravager } } } + + public override void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers) + { + if (item.pick > 0) + { + modifiers.FlatBonusDamage += -10000; + modifiers.FinalDamage.Flat += item.pick - 1; + modifiers.SetCrit(); + } + else + { + modifiers.SetMaxDamage(1); + modifiers.DisableCrit(); + modifiers.HideCombatText(); + } + base.ModifyHitByItem(player, item, ref modifiers); + } + + public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers) + { + var item = Main.player[projectile.owner].HeldItem; + if (item.pick > 0 && projectile.CountsAsClass()) + { + modifiers.FlatBonusDamage += -10000; + modifiers.FinalDamage.Flat += item.pick-1; + modifiers.SetCrit(); + } + else + { + modifiers.SetMaxDamage(1); + modifiers.DisableCrit(); + modifiers.HideCombatText(); + } + base.ModifyHitByProjectile(projectile, ref modifiers); + } } } diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index e4ffb7b02e..8df6960258 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.Items.Accessories; @@ -7,7 +8,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.TreasureBags.MiscGrabBags; @@ -17,7 +18,6 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Enemy; using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -69,26 +69,32 @@ namespace CalamityMod.NPCs.Ravager } } + // GFB exclusive + public static int BlasterDamage = 92; // 368 + + // Legendary exclusive + public static int RockDamage = 60; // 240 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 90; // 180 NPC.lavaImmune = true; NPC.noGravity = true; NPC.npcSlots = 20f; NPC.aiStyle = -1; - NPC.GetNPCDamage(); NPC.width = 332; NPC.height = 214; NPC.defense = 55; - NPC.value = Item.buyPrice(0, 30, 0, 0); + NPC.value = Item.buyPrice(gold: 25); NPC.DR_NERD(0.35f); - NPC.LifeMaxNERB(45000, 54000, 460000); + NPC.LifeMaxNERB(30000, 54000, 460000); if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive) { NPC.damage = (int)(NPC.damage * 1.5); NPC.defense *= 2; NPC.lifeMax *= 4; - NPC.value *= 3f; + NPC.value *= 4f; } NPC.knockBackResist = 0f; AIType = -1; @@ -100,9 +106,6 @@ namespace CalamityMod.NPCs.Ravager NPC.DeathSound = DeathSound; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -149,10 +152,9 @@ namespace CalamityMod.NPCs.Ravager { CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -227,22 +229,14 @@ namespace CalamityMod.NPCs.Ravager if (immunePhase) { NPC.dontTakeDamage = true; - if (bossRush) - { - if (!Main.dedServ) - { - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && revenge) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); - } - } } else { NPC.dontTakeDamage = false; - if (!Main.dedServ) + foreach (Player p in Main.ActivePlayers) { - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && revenge) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + if (!p.dead && revenge) + p.AddBuff(ModContent.BuffType(), 2); } } @@ -253,7 +247,7 @@ namespace CalamityMod.NPCs.Ravager Vector2 Pos = player.Center; //Spawn projectiles based on player's center. Having it be based on the boss turned out weird. (Except for final) int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = BlasterDamage; if (finalStand) //Circle { Vector2 circleOffset = Pos + (Vector2.UnitY * 640f).RotatedBy(MathHelper.ToRadians(NPC.localAI[1] * 3f)); @@ -514,7 +508,7 @@ namespace CalamityMod.NPCs.Ravager player = Main.player[NPC.target]; bool shouldFall = player.position.Y >= NPC.Bottom.Y; - float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + float velocityXBoost = !anyHeadActive ? 6f : 4f * (1f - lifeRatio); float velocityX = 4f + velocityXBoost; if (velocityY != 16) @@ -526,11 +520,11 @@ namespace CalamityMod.NPCs.Ravager if (revenge) { - float multiplier = bossRush ? 0.003f : 0.0015f; + float multiplier = 0.0015f; if (distanceBelowTarget > 0f) calamityGlobalNPC.newAI[1] += 1f + distanceBelowTarget * multiplier; - float speedMultLimit = bossRush ? 3f : 2f; + float speedMultLimit = 2f; if (calamityGlobalNPC.newAI[1] > speedMultLimit) calamityGlobalNPC.newAI[1] = speedMultLimit; @@ -547,13 +541,13 @@ namespace CalamityMod.NPCs.Ravager { velocityX *= 2f; if (!shouldFall) - velocityY *= 0.5f; + velocityY *= 0.75f; } else if (calamityGlobalNPC.newAI[0] % 2f == 0f) { velocityX *= 1.5f; if (!shouldFall) - velocityY *= 0.75f; + velocityY *= 1f; } } @@ -591,57 +585,48 @@ namespace CalamityMod.NPCs.Ravager if (Main.netMode != NetmodeID.MultiplayerClient) { - bool anyRockPillars = NPC.AnyNPCs(ModContent.NPCType()); - bool anyFlamePillars = NPC.AnyNPCs(ModContent.NPCType()); - - if (CalamityWorld.LegendaryMode && revenge) - { - if (!expertMode || anyRockPillars || anyFlamePillars) - SoundEngine.PlaySound(PillarSound, NPC.Center); - - // Eruption of bouncing rock projectiles - float projectileVelocity = 12f; - int type = ModContent.ProjectileType(); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); - destination *= projectileVelocity; - int numProj = 11; - float rotation = MathHelper.ToRadians(90); - for (int i = 0; i < numProj; i++) - { - // Spawn projectiles 0, 1, 2, 3, 7, 8, 9 and 10 - if (i < 4 || i > 6) - { - Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 30f * NPC.scale + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed, type, 60, 0f, Main.myPlayer); - } - } - } - if (expertMode) { foreach (NPC n in Main.ActiveNPCs) { if (n.type == ModContent.NPCType() && n.ai[0] == 0f) { - n.ai[1] = -1f; + n.ai[1]++; n.direction = NPC.direction; n.netUpdate = true; } } int spawnDistance = 360; - - if (!anyRockPillars || !anyFlamePillars) + SoundEngine.PlaySound(PillarSound, NPC.Center); + if (death && phase2) { - SoundEngine.PlaySound(PillarSound, NPC.Center); + spawnDistance = 300; + var index = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X), (int)player.Center.Y - spawnDistance - 100, ModContent.NPCType()); + if (Main.npc.IndexInRange(index)) + { + var npc = Main.npc[index]; + (int, int) H_W = (npc.height, npc.width); + npc.position = npc.Center; + npc.height = H_W.Item2; + npc.width = H_W.Item1; + npc.rotation = -MathHelper.PiOver2; + npc.Center = npc.position; + npc.ModNPC.DrawOffsetY = npc.width / 2 - npc.height / 2; + + } } - if (!anyRockPillars || Main.getGoodWorld) + + bool anyRockPillars = Main.npc.Any(x => x.active && x.type == ModContent.NPCType() && x.ai[1] < 2); + bool anyFlamePillars = NPC.AnyNPCs(ModContent.NPCType()); + + if (!anyRockPillars || phase2) { NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X - spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType()); NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType()); } - else if (!anyFlamePillars || Main.getGoodWorld) + + if (!anyFlamePillars && !phase2) { float distanceMultiplier = finalPhase ? 2.5f : 2f; NPC.NewNPC(NPC.GetSource_FromAI(), (int)player.Center.X - (int)(spawnDistance * distanceMultiplier), (int)player.Center.Y - 100, ModContent.NPCType()); @@ -712,7 +697,7 @@ namespace CalamityMod.NPCs.Ravager else calamityGlobalNPC.newAI[2] = player.direction; - float maxOffsetScale = death ? 320f : 240f; + float maxOffsetScale = 240f; float maxOffset = maxOffsetScale * (1f - lifeRatio); float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f; int quarterWidth = (int)(NPC.width * 0.25f); @@ -721,7 +706,7 @@ namespace CalamityMod.NPCs.Ravager { if (phase2) { - float stopBeforeFallTime = bossRush ? 25f : 30f; + float stopBeforeFallTime = 30f; if (!anyHeadActive) stopBeforeFallTime -= 15f; else if (expertMode) @@ -738,7 +723,7 @@ namespace CalamityMod.NPCs.Ravager NPC.damage = NPC.defDamage; float fallSpeedBoost = !anyHeadActive ? 1.8f : death ? 1.8f * (1f - lifeRatio) : 1.2f * (1f - lifeRatio); - float fallSpeed = (bossRush ? 1.8f : 1.2f) + fallSpeedBoost; + float fallSpeed = 1.2f + fallSpeedBoost; if (calamityGlobalNPC.newAI[1] > 1f) fallSpeed *= calamityGlobalNPC.newAI[1]; @@ -754,8 +739,8 @@ namespace CalamityMod.NPCs.Ravager if (NPC.Bottom.Y < player.position.Y) { - float fallSpeedBoost = !anyHeadActive ? 0.9f : death ? 0.9f * (1f - lifeRatio) : 0.6f * (1f - lifeRatio); - float fallSpeed = (bossRush ? 0.9f : 0.6f) + fallSpeedBoost; + float fallSpeedBoost = !anyHeadActive ? 0.9f : 0.6f * (1f - lifeRatio); + float fallSpeed = 0.6f + fallSpeedBoost; if (calamityGlobalNPC.newAI[1] > 1f) fallSpeed *= calamityGlobalNPC.newAI[1]; @@ -766,10 +751,10 @@ namespace CalamityMod.NPCs.Ravager } else { - float velocityMult = bossRush ? 2f : 1.8f; + float velocityMult = 1.8f; float velocityXChange = 0.2f + Math.Abs(NPC.Center.X - player.Center.X) * 0.001f; - float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); + float velocityXBoost = !anyHeadActive ? 6f : 4f * (1f - lifeRatio); float velocityXCap = 8f + velocityXBoost + Math.Abs(NPC.Center.X - player.Center.X) * 0.001f; if (!rightClawActive) @@ -815,11 +800,6 @@ namespace CalamityMod.NPCs.Ravager { float gravity = phase2 ? 0f : 0.45f; float maxFallSpeed = reduceFallSpeed ? 12f : phase2 ? 24f : 15f; - if (bossRush && !reduceFallSpeed) - { - gravity *= 1.25f; - maxFallSpeed *= 1.25f; - } if (calamityGlobalNPC.newAI[1] > 1f && !reduceFallSpeed) maxFallSpeed *= calamityGlobalNPC.newAI[1]; @@ -836,7 +816,7 @@ namespace CalamityMod.NPCs.Ravager player = Main.player[NPC.target]; } - int distanceFromTarget = player.dead ? 1600 : bossRush ? 8400 : 5600; + int distanceFromTarget = player.dead ? 1600 : 5600; if (Vector2.Distance(NPC.Center, player.Center) > distanceFromTarget) { NPC.TargetClosest(); @@ -849,6 +829,7 @@ namespace CalamityMod.NPCs.Ravager } } } + public override bool? CanFallThroughPlatforms() => NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height; public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { @@ -908,7 +889,6 @@ namespace CalamityMod.NPCs.Ravager public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) @@ -1006,10 +986,10 @@ namespace CalamityMod.NPCs.Ravager public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 480, true); + target.AddBuff(ModContent.BuffType(), 480); } - public override void BossLoot(ref string name, ref int potionType) => potionType = ItemID.GreaterHealingPotion; + public override void BossLoot(ref int potionType) => potionType = ItemID.GreaterHealingPotion; public override void OnKill() { @@ -1049,7 +1029,8 @@ namespace CalamityMod.NPCs.Ravager normalOnly.Add(ItemDropRule.ByCondition(DropHelper.If(() => DownedBossSystem.downedProvidence), ModContent.ItemType()), hideLootReport: !DownedBossSystem.downedProvidence); // Equipment - normalOnly.Add(ModContent.ItemType(), 3); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(ModContent.ItemType(), 3); normalOnly.Add(ModContent.ItemType(), 3); normalOnly.Add(ItemDropRule.ByCondition(DropHelper.PostProv(), ModContent.ItemType())); @@ -1066,10 +1047,10 @@ namespace CalamityMod.NPCs.Ravager // GFB Sans drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ItemID.Skull, hideLootReport: true); - GFBOnly.Add(ItemID.Bone, 1, 1, 9999, true); - GFBOnly.Add(ItemID.Hotdog, 1, 1, 9999, true); - GFBOnly.Add(ModContent.ItemType(), 1, 1, 9999, true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Skull), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Bone, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ItemID.Hotdog, 1, 1, 9999), true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 1, 9999), true); } // Lore diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs index d891497c47..dc4ac07a20 100644 --- a/NPCs/Ravager/RavagerClawLeft.cs +++ b/NPCs/Ravager/RavagerClawLeft.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -13,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { + [HasPierceResist] public class RavagerClawLeft : ModNPC { public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.RavagerBody.DisplayName"); @@ -24,9 +24,9 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 75; // 150 NPC.lavaImmune = true; NPC.aiStyle = -1; - NPC.GetNPCDamage(); NPC.width = 80; NPC.height = 40; NPC.defense = 40; @@ -51,10 +51,6 @@ namespace CalamityMod.NPCs.Ravager } NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() @@ -66,7 +62,6 @@ namespace CalamityMod.NPCs.Ravager return; } - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.timeLeft < 1800) { NPC.timeLeft = 1800; @@ -97,17 +92,17 @@ namespace CalamityMod.NPCs.Ravager NPC.rotation = 0f; NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-120f, 50f); NPC.ai[1] += 1f; - if (NPC.life < NPC.lifeMax / 2 || death) + if (NPC.life < NPC.lifeMax / 2) { NPC.ai[1] += 1f; } - if (NPC.life < NPC.lifeMax / 3 || death) + if (NPC.life < NPC.lifeMax / 3) { NPC.ai[1] += 1f; } - if (NPC.life < NPC.lifeMax / 5 || death) + if (NPC.life < NPC.lifeMax / 5) { - NPC.ai[1] += 5f; + NPC.ai[1] += 2f; } if (NPC.ai[1] >= 60f) { @@ -147,17 +142,17 @@ namespace CalamityMod.NPCs.Ravager NPC.collideX = false; NPC.collideY = false; float clawSpeed = 12f; - if (NPC.life < NPC.lifeMax / 2 || death) + if (NPC.life < NPC.lifeMax / 2) { clawSpeed += 2f; } - if (NPC.life < NPC.lifeMax / 3 || death) + if (NPC.life < NPC.lifeMax / 3) { clawSpeed += 2f; } - if (NPC.life < NPC.lifeMax / 5 || death) + if (NPC.life < NPC.lifeMax / 5) { - clawSpeed += 5f; + clawSpeed += 4f; } Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y); float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X; @@ -204,7 +199,7 @@ namespace CalamityMod.NPCs.Ravager bodyReturnYDist += 40f; bodyReturnXDist -= 110f; float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist); - if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) + if ((bodyReturnDistance > 700f || NPC.collideX || NPC.collideY) | NPC.justHit) { // Avoid cheap bullshit NPC.damage = 0; @@ -313,11 +308,11 @@ namespace CalamityMod.NPCs.Ravager { if (DownedBossSystem.downedProvidence) { - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(ModContent.BuffType(), 240); } else { - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(ModContent.BuffType(), 240); } } } diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs index 731b46802d..8a0426db9e 100644 --- a/NPCs/Ravager/RavagerClawRight.cs +++ b/NPCs/Ravager/RavagerClawRight.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -13,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { + [HasPierceResist] public class RavagerClawRight : ModNPC { public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.RavagerBody.DisplayName"); @@ -24,9 +24,9 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 75; // 150 NPC.lavaImmune = true; NPC.aiStyle = -1; - NPC.GetNPCDamage(); NPC.width = 80; NPC.height = 40; NPC.defense = 40; @@ -51,15 +51,10 @@ namespace CalamityMod.NPCs.Ravager } NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() { - //Main.NewText(NPC.ai[0]); if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -67,7 +62,6 @@ namespace CalamityMod.NPCs.Ravager return; } - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (NPC.timeLeft < 1800) { NPC.timeLeft = 1800; @@ -98,17 +92,17 @@ namespace CalamityMod.NPCs.Ravager NPC.rotation = 0f; NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(120f, 50f); NPC.ai[1] += 1f; - if (NPC.life < NPC.lifeMax / 2 || death) + if (NPC.life < NPC.lifeMax / 2) { NPC.ai[1] += 1f; } - if (NPC.life < NPC.lifeMax / 3 || death) + if (NPC.life < NPC.lifeMax / 3) { NPC.ai[1] += 1f; } - if (NPC.life < NPC.lifeMax / 5 || death) + if (NPC.life < NPC.lifeMax / 5) { - NPC.ai[1] += 5f; + NPC.ai[1] += 2f; } if (NPC.ai[1] >= 60f) { @@ -148,17 +142,17 @@ namespace CalamityMod.NPCs.Ravager NPC.collideX = false; NPC.collideY = false; float clawSpeed = 12f; - if (NPC.life < NPC.lifeMax / 2 || death) + if (NPC.life < NPC.lifeMax / 2) { clawSpeed += 2f; } - if (NPC.life < NPC.lifeMax / 3 || death) + if (NPC.life < NPC.lifeMax / 3) { clawSpeed += 2f; } - if (NPC.life < NPC.lifeMax / 5 || death) + if (NPC.life < NPC.lifeMax / 5) { - clawSpeed += 5f; + clawSpeed += 4f; } Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y); float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X; @@ -205,7 +199,7 @@ namespace CalamityMod.NPCs.Ravager bodyReturnYDist += 40f; bodyReturnXDist += 110f; float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist); - if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit) + if ((bodyReturnDistance > 700f || NPC.collideX || NPC.collideY) | NPC.justHit) { // Avoid cheap bullshit NPC.damage = 0; @@ -314,11 +308,11 @@ namespace CalamityMod.NPCs.Ravager { if (DownedBossSystem.downedProvidence) { - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(ModContent.BuffType(), 240); } else { - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(ModContent.BuffType(), 240); } } } diff --git a/NPCs/Ravager/RavagerHead.cs b/NPCs/Ravager/RavagerHead.cs index e181a9e65d..b4cac0f67b 100644 --- a/NPCs/Ravager/RavagerHead.cs +++ b/NPCs/Ravager/RavagerHead.cs @@ -10,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { + [HasPierceResist] public class RavagerHead : ModNPC { public static readonly SoundStyle MissileSound = new("CalamityMod/Sounds/Custom/Ravager/RavagerMissileLaunch"); @@ -20,10 +21,13 @@ namespace CalamityMod.NPCs.Ravager NPCID.Sets.NeedsExpertScaling[Type] = true; } + public static int NukeDamage = 35; // 140 + public static int PostProviNukeBuff = 25; // +100 = 240 + public override void SetDefaults() { NPC.aiStyle = -1; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.width = 80; NPC.height = 80; NPC.defense = 40; @@ -48,10 +52,6 @@ namespace CalamityMod.NPCs.Ravager } NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() @@ -93,13 +93,12 @@ namespace CalamityMod.NPCs.Ravager NPC.TargetClosest(); NPC.ai[1] = 0f; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int type = ModContent.ProjectileType(); if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 shootFromVector = new Vector2(NPC.Center.X, NPC.Center.Y - 20f); Vector2 velocity = new Vector2(0f, -15f); - int nuke = Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFromVector, velocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, NPC.target, 0f); + int nuke = Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFromVector, velocity, type, NukeDamage + (provy ? PostProviNukeBuff : 0), 0f, Main.myPlayer, NPC.target, 0f); Main.projectile[nuke].velocity.Y = -15f; } } diff --git a/NPCs/Ravager/RavagerHead2.cs b/NPCs/Ravager/RavagerHead2.cs index f33e45eb6e..b1754dfac9 100644 --- a/NPCs/Ravager/RavagerHead2.cs +++ b/NPCs/Ravager/RavagerHead2.cs @@ -20,15 +20,18 @@ namespace CalamityMod.NPCs.Ravager NPCID.Sets.NeedsExpertScaling[Type] = true; } + public static int HomingDartDamage = 30; // 120 + public static int PostProviDartBuff = 20; // +80 == 200 + public override void SetDefaults() { NPC.aiStyle = -1; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.width = 80; NPC.height = 80; NPC.defense = 40; NPC.DR_NERD(0.15f); - NPC.lifeMax = 10000; + NPC.lifeMax = 20000; NPC.knockBackResist = 0f; AIType = -1; NPC.netAlways = true; @@ -39,7 +42,7 @@ namespace CalamityMod.NPCs.Ravager if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive) { NPC.defense *= 2; - NPC.lifeMax *= 4; + NPC.lifeMax *= 3; } if (BossRushEvent.BossRushActive) { @@ -47,10 +50,7 @@ namespace CalamityMod.NPCs.Ravager } NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); + NPC.dontTakeDamage = true; } public override void AI() @@ -65,9 +65,8 @@ namespace CalamityMod.NPCs.Ravager Player player = Main.player[Main.npc[CalamityGlobalNPC.scavenger].target]; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool provy = DownedBossSystem.downedProvidence && !bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool provy = DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive; if (NPC.timeLeft < 1800) NPC.timeLeft = 1800; @@ -107,11 +106,10 @@ namespace CalamityMod.NPCs.Ravager NPC.rotation = headRotation; NPC.ai[1] += 1f; - bool fireProjectiles = NPC.ai[1] >= (bossRush ? 240f : 480f); + bool fireProjectiles = NPC.ai[1] >= 480f; if (fireProjectiles && Vector2.Distance(NPC.Center, player.Center) > 80f) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); float projectileVelocity = death ? 8f : 6f; if (NPC.ai[1] >= 600f) @@ -122,20 +120,8 @@ namespace CalamityMod.NPCs.Ravager if (Main.netMode != NetmodeID.MultiplayerClient) { SoundEngine.PlaySound(RavagerHead.MissileSound, NPC.Center); - type = ModContent.ProjectileType(); - damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity * 0.25f, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, Main.npc[CalamityGlobalNPC.scavenger].target, 0f); - } - } - else - { - if (NPC.ai[1] % 40f == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - SoundEngine.PlaySound(SoundID.Item33, NPC.Center); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity, type, damage + (provy ? 30 : 0), 0f, Main.myPlayer, 0f, -1f); - } + type = ModContent.ProjectileType(); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity * 0.25f, type, RavagerHead.NukeDamage + (provy ? RavagerHead.PostProviNukeBuff : 0), 0f, Main.myPlayer, Main.npc[CalamityGlobalNPC.scavenger].target, 0f); } } } diff --git a/NPCs/Ravager/RavagerLegLeft.cs b/NPCs/Ravager/RavagerLegLeft.cs index 14e5723fe7..95d7ec3d32 100644 --- a/NPCs/Ravager/RavagerLegLeft.cs +++ b/NPCs/Ravager/RavagerLegLeft.cs @@ -7,6 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { + [HasPierceResist] public class RavagerLegLeft : ModNPC { public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.RavagerBody.DisplayName"); @@ -19,7 +20,7 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { NPC.aiStyle = -1; - NPC.damage = 0; + NPC.damage = 0; // No contact damage NPC.width = 60; NPC.height = 60; NPC.defense = 40; @@ -44,10 +45,6 @@ namespace CalamityMod.NPCs.Ravager } NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() diff --git a/NPCs/Ravager/RavagerLegRight.cs b/NPCs/Ravager/RavagerLegRight.cs index b3be683e4a..bcb5cf0a7f 100644 --- a/NPCs/Ravager/RavagerLegRight.cs +++ b/NPCs/Ravager/RavagerLegRight.cs @@ -7,6 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Ravager { + [HasPierceResist] public class RavagerLegRight : ModNPC { public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.RavagerBody.DisplayName"); @@ -19,7 +20,7 @@ namespace CalamityMod.NPCs.Ravager public override void SetDefaults() { NPC.aiStyle = -1; - NPC.damage = 0; + NPC.damage = 0; // No contact damage NPC.width = 60; NPC.height = 60; NPC.defense = 40; @@ -44,10 +45,6 @@ namespace CalamityMod.NPCs.Ravager } NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() diff --git a/NPCs/Ravager/RockPillar.cs b/NPCs/Ravager/RockPillar.cs index 4170c15cf3..ad80d16cc6 100644 --- a/NPCs/Ravager/RockPillar.cs +++ b/NPCs/Ravager/RockPillar.cs @@ -1,8 +1,6 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; -using CalamityMod.World; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -16,18 +14,18 @@ namespace CalamityMod.NPCs.Ravager public override void SetStaticDefaults() { this.HideFromBestiary(); + NPCID.Sets.ImmuneToAllBuffs[Type] = true; } public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 90; // 180 NPC.width = 60; NPC.height = 300; NPC.defense = 50; NPC.DR_NERD(0.3f); NPC.chaseable = false; - NPC.lifeMax = DownedBossSystem.downedProvidence ? 20000 : 5000; NPC.alpha = 255; NPC.aiStyle = -1; AIType = -1; @@ -36,14 +34,23 @@ namespace CalamityMod.NPCs.Ravager NPC.DeathSound = SoundID.NPCDeath14; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = true; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); + NPCID.Sets.ImmuneToAllBuffs[Type] = true; + NPC.lifeMax = 1800; } + //Disable dmg when stationary vertically or before jumping + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + if (NPC.velocity.Y == 0 || NPC.ai[0] == 0f) + return false; + return base.CanHitPlayer(target, ref cooldownSlot); + } public override void AI() { + if (NPC.lifeMax > 1800) + NPC.lifeMax = 1800; + if (NPC.life > NPC.lifeMax) + NPC.life = NPC.lifeMax; if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -57,19 +64,22 @@ namespace CalamityMod.NPCs.Ravager if (NPC.alpha > 0) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.alpha -= 10; if (NPC.alpha < 0) NPC.alpha = 0; } + else + { + } - if (NPC.ai[0] == 0f) + if (NPC.ai[0] == 0) { if (NPC.velocity.Y == 0f) { - // Avoid cheap bullshit - NPC.damage = 0; - - if (NPC.ai[1] == -1f) + if (NPC.ai[1] >= 2) { SoundEngine.PlaySound(SoundID.Item62, NPC.Center); @@ -92,28 +102,20 @@ namespace CalamityMod.NPCs.Ravager Main.dust[rockDust2].velocity *= 2f; } - // Set damage - if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive) - NPC.damage = (int)Math.Round(NPC.defDamage * 1.5); - else - NPC.damage = NPC.defDamage; - NPC.noTileCollide = true; - NPC.velocity.X = (BossRushEvent.BossRushActive ? 15 : 12) * NPC.direction; + if (NPC.rotation == 0) + NPC.velocity.X = 12 * NPC.direction; NPC.velocity.Y = -28.5f; NPC.ai[0] = 1f; - NPC.ai[1] = 0f; + NPC.ai[1] = 0; + NPC.damage = NPC.defDamage; + if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive) + NPC.damage = (int)(NPC.defDamage * 1.5); } } } else { - // Set damage - if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive) - NPC.damage = (int)Math.Round(NPC.defDamage * 1.5); - else - NPC.damage = NPC.defDamage; - if (NPC.velocity.Y == 0f || Vector2.Distance(NPC.Center, Main.npc[CalamityGlobalNPC.scavenger].Center) > 2800f) { SoundEngine.PlaySound(SoundID.Item14, NPC.Center); @@ -133,7 +135,7 @@ namespace CalamityMod.NPCs.Ravager } } } - + public override bool? CanFallThroughPlatforms() => NPC.ai[0] != 0 || ((NPC.alpha > 10) || (NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height)); public override bool CheckActive() => false; public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) @@ -141,7 +143,7 @@ namespace CalamityMod.NPCs.Ravager if (hurtInfo.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(ModContent.BuffType(), 240); SoundEngine.PlaySound(SoundID.Item14, NPC.Center); NPC.ai[0] = 0f; @@ -216,5 +218,40 @@ namespace CalamityMod.NPCs.Ravager } } } + + public override void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers) + { + if (item.pick > 0) + { + modifiers.FlatBonusDamage += -10000; + modifiers.FinalDamage.Flat += item.pick - 1; + modifiers.SetCrit(); + } + else + { + modifiers.SetMaxDamage(1); + modifiers.DisableCrit(); + modifiers.HideCombatText(); + } + base.ModifyHitByItem(player, item, ref modifiers); + } + + public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers) + { + var item = Main.player[projectile.owner].HeldItem; + if (item.pick > 0 && projectile.CountsAsClass()) + { + modifiers.FlatBonusDamage += -10000; + modifiers.FinalDamage.Flat += item.pick - 1; + modifiers.SetCrit(); + } + else + { + modifiers.SetMaxDamage(1); + modifiers.DisableCrit(); + modifiers.HideCombatText(); + } + base.ModifyHitByProjectile(projectile, ref modifiers); + } } } diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index dc5150c594..33d6c79feb 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -1,7 +1,6 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -26,30 +25,28 @@ namespace CalamityMod.NPCs.Signus { GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); } + NPCID.Sets.DontDoHardmodeScaling[Type] = true; //prevent HP from scaling. We manually scale the damage to compensate } public override void SetDefaults() { + NPC.damage = 120 * (Main.masterMode ? 3 : Main.expertMode ? 2 : 1); // 240 NPC.aiStyle = -1; AIType = -1; - NPC.GetNPCDamage(); NPC.width = 25; NPC.height = 25; NPC.defense = 50; - NPC.lifeMax = 25; + NPC.lifeMax = 3; NPC.alpha = 255; - NPC.knockBackResist = 0.85f; + NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.dontTakeDamage = true; NPC.chaseable = false; NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit53; NPC.DeathSound = SoundID.NPCDeath44; + NPC.SuperArmor = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -117,11 +114,14 @@ namespace CalamityMod.NPCs.Signus bool revenge = CalamityWorld.revenge; float playerDistNormMult = revenge ? 24f : 22f; - if (BossRushEvent.BossRushActive) - playerDistNormMult = 30f; CalamityRegularEnemyAI.DungeonSpiritAI(NPC, Mod, playerDistNormMult, 0f, true); } + public override void ModifyIncomingHit(ref NPC.HitModifiers modifiers) + { + modifiers.DisableCrit(); + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { SpriteEffects spriteEffects = SpriteEffects.None; diff --git a/NPCs/Signus/CosmicMine.cs b/NPCs/Signus/CosmicMine.cs index 69af4f8c13..8a2a83f901 100644 --- a/NPCs/Signus/CosmicMine.cs +++ b/NPCs/Signus/CosmicMine.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.Signus public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 140; // 280 NPC.width = 30; NPC.height = 30; NPC.lifeMax = 4800; @@ -38,10 +38,6 @@ namespace CalamityMod.NPCs.Signus NPC.HitSound = SoundID.NPCHit53; NPC.DeathSound = SoundID.NPCDeath44; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 344b2dbdec..9e4f9f9c79 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -8,7 +8,7 @@ using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -69,16 +69,22 @@ namespace CalamityMod.NPCs.Signus } } + public static int ScytheDamage = 60; // 240 + public static int DustDamage = 60; // 240; Also applies to Legendary Mode Peanuts + + // GFB exclusive + public static int StealthStrikeMult = 2; // 480 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 160; // 320 NPC.npcSlots = 32f; - NPC.GetNPCDamage(); NPC.width = 130; NPC.height = 130; NPC.defense = 60; - NPC.LifeMaxNERB(300000, 360000, 320000); - NPC.value = Item.buyPrice(1, 0, 0, 0); + NPC.LifeMaxNERB(250000, 375000, 380000); + NPC.value = Item.buyPrice(gold: 50); NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; @@ -89,9 +95,6 @@ namespace CalamityMod.NPCs.Signus NPC.HitSound = SoundID.NPCHit49; NPC.DeathSound = SoundID.NPCDeath51; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -129,10 +132,9 @@ namespace CalamityMod.NPCs.Signus CalamityGlobalNPC.signus = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; Vector2 vectorCenter = NPC.Center; @@ -141,8 +143,8 @@ namespace CalamityMod.NPCs.Signus lifeToAlpha = (int)((Main.getGoodWorld ? 200D : 100D) * (1D - lifeRatio)); int maxCharges = death ? 1 : revenge ? 2 : expertMode ? 3 : 4; int maxTeleports = (death && lifeRatio < 0.9) ? 1 : revenge ? 2 : expertMode ? 3 : 4; - float inertia = bossRush ? 9f : death ? 10f : revenge ? 11f : expertMode ? 12f : 14f; - float chargeVelocity = bossRush ? 16f : death ? 14f : revenge ? 13f : expertMode ? 12f : 10f; + float inertia = death ? 10f : revenge ? 11f : expertMode ? 12f : 14f; + float chargeVelocity = death ? 14f : revenge ? 13f : expertMode ? 12f : 10f; if (Main.getGoodWorld) { inertia *= 0.5f; @@ -237,9 +239,6 @@ namespace CalamityMod.NPCs.Signus if (NPC.ai[0] <= 2f) { - // Avoid cheap bullshit - NPC.damage = 0; - NPC.rotation = NPC.velocity.X * 0.04f; float playerLocation = vectorCenter.X - player.Center.X; NPC.direction = playerLocation < 0f ? 1 : -1; @@ -251,7 +250,7 @@ namespace CalamityMod.NPCs.Signus if (phase3 || revenge) NPC.knockBackResist = 0f; - float speed = bossRush ? 20f : revenge ? 15f : expertMode ? 14f : 12f; + float speed = revenge ? 15f : expertMode ? 14f : 12f; if (expertMode) speed += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); @@ -288,12 +287,9 @@ namespace CalamityMod.NPCs.Signus } else if (NPC.ai[0] == 0f) { - // Avoid cheap bullshit - NPC.damage = 0; - if (Main.netMode != NetmodeID.MultiplayerClient) { - NPC.localAI[1] += bossRush ? 1.5f : 1f; + NPC.localAI[1] += 1f; if (expertMode) NPC.localAI[1] += death ? 3f * (float)(1D - lifeRatio) : 2f * (float)(1D - lifeRatio); @@ -345,7 +341,7 @@ namespace CalamityMod.NPCs.Signus } else if (NPC.ai[0] == 1f) { - // Avoid cheap bullshit + // Disable contact damage for some time while fading away NPC.damage = 0; Vector2 position = new Vector2(NPC.ai[1] * 16f - (NPC.width / 2), NPC.ai[2] * 16f - (NPC.height / 2)); @@ -356,7 +352,7 @@ namespace CalamityMod.NPCs.Signus Main.dust[dust].fadeIn = 1f; } - NPC.alpha += bossRush ? 3 : 2; + NPC.alpha += 2; if (expertMode) NPC.alpha += death ? (int)Math.Round(4.5D * (1D - lifeRatio)) : (int)Math.Round(3D * (1D - lifeRatio)); @@ -381,12 +377,11 @@ namespace CalamityMod.NPCs.Signus } else if (NPC.ai[0] == 2f) { - // Avoid cheap bullshit - NPC.damage = 0; - NPC.alpha -= 50; if (NPC.alpha <= lifeToAlpha) { + // Restore contact damage once returned to proper opacity + NPC.damage = NPC.defDamage; if (Main.netMode != NetmodeID.MultiplayerClient && revenge) { SoundEngine.PlaySound(SoundID.Item122, NPC.Center); @@ -465,15 +460,12 @@ namespace CalamityMod.NPCs.Signus } else if (NPC.ai[0] == 3f) { - // Avoid cheap bullshit - NPC.damage = 0; - NPC.rotation = NPC.velocity.X * 0.04f; float playerLocation = vectorCenter.X - player.Center.X; NPC.direction = playerLocation < 0f ? 1 : -1; NPC.spriteDirection = NPC.direction; - float divisor = expertMode ? (bossRush ? 10f : death ? 12f : revenge ? 15f : 20f) - (float)Math.Ceiling(5D * (1D - lifeRatio)) : 20f; + float divisor = expertMode ? (death ? 12f : revenge ? 15f : 20f) - (float)Math.Ceiling(5D * (1D - lifeRatio)) : 20f; float scytheBarrageTime = divisor * 3f; float scytheBarrageCooldown = divisor * 3f; @@ -496,16 +488,14 @@ namespace CalamityMod.NPCs.Signus scytheXDist *= scytheDistance; scytheYDist *= scytheDistance; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist, scytheYDist, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist, scytheYDist, type, ScytheDamage, 0f, Main.myPlayer, 0f, NPC.target + 1); if (stealthTimer >= maxStealth) { - damage *= 2; SoundEngine.PlaySound(RaidersTalisman.StealthHitSound, NPC.Center); for (int i = 0; i < 4; i++) { Vector2 offset = new Vector2(Main.rand.Next(-5, 6), Main.rand.Next(-5, 6)); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist + offset.X, scytheYDist + offset.Y, type, damage, 0f, Main.myPlayer, 0f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, scytheXDist + offset.X, scytheYDist + offset.Y, type, ScytheDamage * StealthStrikeMult, 0f, Main.myPlayer, 0f, NPC.target + 1); } stealthTimer = 0; } @@ -513,8 +503,8 @@ namespace CalamityMod.NPCs.Signus } } - float maxVelocityY = bossRush ? 1.5f : death ? 2.5f : 3f; - float maxVelocityX = bossRush ? 5f : death ? 7f : 8f; + float maxVelocityY = death ? 2.5f : 3f; + float maxVelocityX = death ? 7f : 8f; if (NPC.position.Y > player.position.Y - 250f) { @@ -632,10 +622,7 @@ namespace CalamityMod.NPCs.Signus if (calamityGlobalNPC.newAI[0] == 0f) // Line up the charge { - // Avoid cheap bullshit - NPC.damage = 0; - - float velocity = bossRush ? 18f : revenge ? 16f : expertMode ? 15f : 14f; + float velocity = revenge ? 16f : expertMode ? 15f : 14f; if (expertMode) velocity += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); @@ -670,17 +657,11 @@ namespace CalamityMod.NPCs.Signus } else if (calamityGlobalNPC.newAI[0] == 1f) // Pause before charge { - // Avoid cheap bullshit - NPC.damage = 0; - NPC.velocity *= 0.8f; NPC.ai[1] += 1f; if (NPC.ai[1] >= 5f) { - // Set damage - NPC.damage = NPC.defDamage; - calamityGlobalNPC.newAI[0] = 2f; NPC.netUpdate = true; @@ -697,9 +678,6 @@ namespace CalamityMod.NPCs.Signus } else if (calamityGlobalNPC.newAI[0] == 2f) // Charging { - // Set damage - NPC.damage = NPC.defDamage; - if (Main.netMode != NetmodeID.MultiplayerClient) { bool buffed = false; @@ -712,15 +690,10 @@ namespace CalamityMod.NPCs.Signus if ((phase2 || buffed) && NPC.ai[2] % 3f == 0f) { SoundEngine.PlaySound(SoundID.Item73, NPC.Center); - int type = (CalamityWorld.LegendaryMode && revenge) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = (CalamityWorld.LegendaryMode && revenge) ? 60 : NPC.GetProjectileDamage(type); - Vector2 velocity = Main.zenithWorld ? new Vector2(Main.rand.Next(-10, 11), Main.rand.Next(-10, 11)) : Vector2.Zero; - if (Main.getGoodWorld && !Main.zenithWorld) - { - velocity = new Vector2(Main.rand.Next(-5, 6), Main.rand.Next(-5, 6)); - } + int type = Main.zenithWorld ? ModContent.ProjectileType() : ModContent.ProjectileType(); + Vector2 velocity = Main.rand.NextVector2Circular(Main.zenithWorld ? 10f : 0f, Main.zenithWorld ? 10f : 0f); int ai = buffed ? 69 : 0; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter, velocity, type, damage, 0f, Main.myPlayer, ai); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter, velocity, type, DustDamage, 0f, Main.myPlayer, ai); } } @@ -750,9 +723,6 @@ namespace CalamityMod.NPCs.Signus } else if (calamityGlobalNPC.newAI[0] == 3f) // Slow down after charging and reset { - // Avoid cheap bullshit - NPC.damage = 0; - if (stealthTimer >= maxStealth) { stealthTimer = 0; @@ -916,7 +886,7 @@ namespace CalamityMod.NPCs.Signus return false; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -951,10 +921,11 @@ namespace CalamityMod.NPCs.Signus normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); // Materials - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 5, 7)); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 10, 12)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -973,8 +944,8 @@ namespace CalamityMod.NPCs.Signus // GFB Nanotech and Ethereal Talisman drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); } // Lore @@ -984,7 +955,6 @@ namespace CalamityMod.NPCs.Signus public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } public override void HitEffect(NPC.HitInfo hit) @@ -1055,7 +1025,7 @@ namespace CalamityMod.NPCs.Signus public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 420, true); + target.AddBuff(ModContent.BuffType(), 420); } } } diff --git a/NPCs/SlimeGod/CorruptSlimeSpawn.cs b/NPCs/SlimeGod/CorruptSlimeSpawn.cs index bb36b36aca..1051c9a07e 100644 --- a/NPCs/SlimeGod/CorruptSlimeSpawn.cs +++ b/NPCs/SlimeGod/CorruptSlimeSpawn.cs @@ -1,6 +1,5 @@ using CalamityMod.Events; using CalamityMod.Projectiles.Boss; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; @@ -20,20 +19,20 @@ namespace CalamityMod.NPCs.SlimeGod NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; } + // GFB exclusive + public static int ShaderainDamage = 12; // 48 + public override void SetDefaults() { NPC.aiStyle = NPCAIStyleID.Bat; - NPC.GetNPCDamage(); + NPC.damage = 28; // 56 NPC.width = 40; NPC.height = 30; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.scale = 2f; NPC.defense = 6; - NPC.lifeMax = BossRushEvent.BossRushActive ? 10000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 360 : 180; + NPC.lifeMax = BossRushEvent.BossRushActive ? 10000 : 180; NPC.knockBackResist = 0.7f; - AnimationType = 121; - NPC.Opacity = 0.8f; + AnimationType = NPCID.Slimer; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -41,10 +40,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.DeathSound = SoundID.NPCDeath1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -60,6 +55,12 @@ namespace CalamityMod.NPCs.SlimeGod }); } + public override void AI() + { + Vector3 light = new Vector3(0.5f, 0.1f, 0.5f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + } + public override void HitEffect(NPC.HitInfo hit) { if (Main.netMode != NetmodeID.MultiplayerClient && NPC.life <= 0) @@ -70,25 +71,17 @@ namespace CalamityMod.NPCs.SlimeGod Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } public override void OnKill() { if (Main.zenithWorld && Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.Zero, type, ShaderainDamage, 0f, Main.myPlayer); } } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Weak, 90, true); - } } } diff --git a/NPCs/SlimeGod/CorruptSlimeSpawn2.cs b/NPCs/SlimeGod/CorruptSlimeSpawn2.cs index 535de4f3b2..97b149f3cd 100644 --- a/NPCs/SlimeGod/CorruptSlimeSpawn2.cs +++ b/NPCs/SlimeGod/CorruptSlimeSpawn2.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -22,17 +21,14 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { NPC.aiStyle = NPCAIStyleID.Slime; - NPC.GetNPCDamage(); + NPC.damage = 20; // 40 NPC.width = 40; NPC.height = 30; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.scale = 2f; NPC.defense = 4; - NPC.lifeMax = BossRushEvent.BossRushActive ? 5000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 180 : 90; + NPC.lifeMax = BossRushEvent.BossRushActive ? 5000 : 90; NPC.knockBackResist = 0.9f; AnimationType = NPCID.CorruptSlime; - NPC.Opacity = 0.8f; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -40,14 +36,13 @@ namespace CalamityMod.NPCs.SlimeGod NPC.DeathSound = SoundID.NPCDeath1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.5f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + NPC.damage = (NPC.velocity.Y == 0f || NPC.velocity.Length() < 3f) ? 0 : NPC.defDamage; } @@ -55,16 +50,14 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } } @@ -84,25 +77,16 @@ namespace CalamityMod.NPCs.SlimeGod double deltaAngleBoom = spreadBoom / 8f; double offsetAngleBoom; int iBoom; - int damageBoom = 30; for (iBoom = 0; iBoom < 5; iBoom++) { int projectileType = ModContent.ProjectileType(); offsetAngleBoom = startAngleBoom + deltaAngleBoom * (iBoom + iBoom * iBoom) / 2f + 32f * iBoom; float velocityfactor = 0.3f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), valueBoom.X, valueBoom.Y, (float)(Math.Sin(offsetAngleBoom) * velocityfactor), (float)(Math.Cos(offsetAngleBoom) * velocityfactor), projectileType, damageBoom, 0f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), valueBoom.X, valueBoom.Y, (float)(-Math.Sin(offsetAngleBoom) * velocityfactor), (float)(-Math.Cos(offsetAngleBoom) * velocityfactor), projectileType, damageBoom, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), valueBoom.X, valueBoom.Y, (float)(Math.Sin(offsetAngleBoom) * velocityfactor), (float)(Math.Cos(offsetAngleBoom) * velocityfactor), projectileType, SlimeGodCore.GlobDamage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), valueBoom.X, valueBoom.Y, (float)(-Math.Sin(offsetAngleBoom) * velocityfactor), (float)(-Math.Cos(offsetAngleBoom) * velocityfactor), projectileType, SlimeGodCore.GlobDamage, 0f, Main.myPlayer, 0f, 0f); } } } } - - public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Vitamins, 50); - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Weak, 90, true); - } } } diff --git a/NPCs/SlimeGod/CrimsonSlimeSpawn.cs b/NPCs/SlimeGod/CrimsonSlimeSpawn.cs index d080f997f1..3d701b8d58 100644 --- a/NPCs/SlimeGod/CrimsonSlimeSpawn.cs +++ b/NPCs/SlimeGod/CrimsonSlimeSpawn.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; @@ -21,17 +20,14 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { NPC.aiStyle = NPCAIStyleID.Slime; - NPC.GetNPCDamage(); + NPC.damage = 20; // 40 NPC.width = 40; NPC.height = 30; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.scale = 2f; NPC.defense = 4; - NPC.lifeMax = BossRushEvent.BossRushActive ? 10000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 220 : 110; + NPC.lifeMax = BossRushEvent.BossRushActive ? 10000 : 110; NPC.knockBackResist = 0.8f; AnimationType = NPCID.CorruptSlime; - NPC.Opacity = 0.8f; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -39,10 +35,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.DeathSound = SoundID.NPCDeath1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -60,6 +52,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.1f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + NPC.damage = (NPC.velocity.Y == 0f || NPC.velocity.Length() < 3f) ? 0 : NPC.defDamage; } @@ -67,16 +62,14 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } } @@ -108,13 +101,5 @@ namespace CalamityMod.NPCs.SlimeGod } } } - - public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Blindfold, 50); - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Darkness, 90, true); - } } } diff --git a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs index 2f75e80e5b..4666fb6d5e 100644 --- a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs +++ b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs @@ -2,7 +2,6 @@ using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; @@ -16,26 +15,27 @@ namespace CalamityMod.NPCs.SlimeGod public class CrimsonSlimeSpawn2 : ModNPC { public float spikeTimer = 60f; + public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.CrimsonSlimeSpawn.DisplayName"); + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 5; NPCID.Sets.BossBestiaryPriority.Add(Type); } + public static int SmallSpikeDamage = 11; // 44 + public override void SetDefaults() { NPC.aiStyle = NPCAIStyleID.Slime; - NPC.GetNPCDamage(); + NPC.damage = 28; // 56 NPC.width = 40; NPC.height = 30; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - NPC.scale = 2f; NPC.defense = 6; - NPC.lifeMax = BossRushEvent.BossRushActive ? 12000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 260 : 130; + NPC.lifeMax = BossRushEvent.BossRushActive ? 12000 : 130; NPC.knockBackResist = 0.7f; - NPC.Opacity = 0.8f; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -60,13 +60,18 @@ namespace CalamityMod.NPCs.SlimeGod public override void FindFrame(int frameHeight) { + Vector3 light = new Vector3(0.5f, 0.1f, 0.1f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + int frameY = 1; if (!Main.dedServ) { if (TextureAssets.Npc[Type].Value is null) return; + frameY = TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type]; } + int aiState = 0; if (NPC.aiAction == 0) aiState = NPC.velocity.Y >= 0f ? (NPC.velocity.Y <= 0f ? (NPC.velocity.X == 0f ? 0 : 1) : 3) : 2; @@ -78,6 +83,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.frameCounter++; if (aiState == 4) NPC.frameCounter++; + if (NPC.frameCounter >= 8f) { NPC.frame.Y += frameY; @@ -93,11 +99,10 @@ namespace CalamityMod.NPCs.SlimeGod spikeTimer -= 1f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); + int damage = SmallSpikeDamage; if (Main.zenithWorld) - { type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - } + if (!NPC.wet) { Vector2 faceDirection = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); @@ -108,9 +113,8 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) - { NPC.velocity.X = NPC.velocity.X * 0.9f; - } + if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { int projcount = Main.zenithWorld ? 12 : 5; @@ -130,9 +134,8 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) - { NPC.velocity.X = NPC.velocity.X * 0.9f; - } + if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { targetY = Main.player[NPC.target].position.Y - faceDirection.Y - (float)Main.rand.Next(0, 200); @@ -151,16 +154,14 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } } @@ -170,13 +171,5 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.rand.NextBool(8) && Main.player[closestPlayer].statLife < Main.player[closestPlayer].statLifeMax2) Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } - - public override void ModifyNPCLoot(NPCLoot npcLoot) => npcLoot.Add(ItemID.Blindfold, 50); - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Darkness, 90, true); - } } } diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index a91575514b..aee29b0cb9 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; @@ -20,24 +19,26 @@ namespace CalamityMod.NPCs.SlimeGod private float bossLife; private float addedStretch = 0f; private float landingRecoil = 0f; + private const int Width = 206; + private const int Height = 156; public override void SetStaticDefaults() { this.HideFromBestiary(); } + public static int BigSpikeDamage = 15; // 60 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); - NPC.width = 206; - NPC.height = 156; - NPC.scale = 1.1f; + NPC.damage = 42; // 84 + NPC.width = Width; + NPC.height = Height; NPC.defense = 12; NPC.LifeMaxNERB(7500, 9000, 160000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.knockBackResist = 0f; - NPC.value = 0f; NPC.Opacity = 1f; NPC.lavaImmune = false; NPC.noGravity = false; @@ -48,9 +49,6 @@ namespace CalamityMod.NPCs.SlimeGod AIType = -1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -75,22 +73,27 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(1f, 0.2f, 0.2f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); CalamityGlobalNPC.slimeGodRed = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || NPC.localAI[1] == 1f || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || NPC.localAI[1] == 1f || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Reset defense and damage NPC.defense = NPC.defDefense; int setDamage = NPC.defDamage; + + // Boost defense and damage while buffed by the Slime God if (NPC.localAI[1] == 1f) { NPC.defense = NPC.defDefense + 24; - setDamage += 25; + setDamage += SlimeGodCore.PossessionDamageBoost; } // Used for landing squash and stretch @@ -104,8 +107,16 @@ namespace CalamityMod.NPCs.SlimeGod addedStretch = -landingRecoil; - float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; + // Used for teleporting + float scale = Main.getGoodWorld ? 0.8f : 1f; + + // How fast the slime slams down + float slamVelocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + + // Used for how fast the slime animates NPC.aiAction = 0; + + // Reset tile collide and gravity NPC.noTileCollide = false; NPC.noGravity = false; @@ -115,6 +126,7 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; + // Despawn if (NPC.ai[0] != 3f) { if (player.dead || !player.active) @@ -135,27 +147,32 @@ namespace CalamityMod.NPCs.SlimeGod NPC.timeLeft = 1800; } + // Split into smaller slimes and fire spikes at half HP if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + // Spread of random globs in meme mode + if (Main.zenithWorld) { int type = ModContent.ProjectileType(); for (int i = 0; i < 30; i++) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, (float)Main.rand.Next(-1499, 1500) * 0.01f, (float)Main.rand.Next(-1499, 1500) * 0.01f, type, 35, 0f); } + // Spawn split slimes SoundEngine.PlaySound(SoundID.NPCDeath1, NPC.Center); Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnAt.X - 80, (int)spawnAt.Y, ModContent.NPCType(), 0, 0f, 0f, 0f); NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnAt.X + 80, (int)spawnAt.Y, ModContent.NPCType(), 0, 0f, 0f, 45f); - if (Main.zenithWorld && NPC.CountNPCS(ModContent.NPCType()) < 3) // Split into 3 slimes if the other large slime hasn't split yet. + + // Split into 3 additional slimes if the other large slime hasn't split yet + if (Main.zenithWorld && NPC.CountNPCS(ModContent.NPCType()) < 3) NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnAt.X, (int)spawnAt.Y - 80, ModContent.NPCType(), 0, 0f, 0f, 90f); - // Calculate stretch here so that the spike spread looks more natural. + // Calculate stretch here so that the spike spread looks more natural float stretch = NPC.velocity.Y * 0.03f; stretch = Math.Abs(stretch) + addedStretch; - // Stretch rapidly if about to jump or teleport, stretch normally while idle. + // Stretch rapidly if about to jump or teleport, stretch normally while idle if (NPC.velocity.Y == 0f) stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * (NPC.aiAction == 1 ? 15f : 2f)) / 2f + 0.5f); @@ -164,25 +181,47 @@ namespace CalamityMod.NPCs.SlimeGod Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; - // Spread of spikes. + // Spread of spikes float projectileVelocity = 2f; int type2 = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type2); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + Vector2 spawnLocation = new Vector2(NPC.Center.X, NPC.Center.Y + 50f * NPC.scale); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; int numProj = 9; float rotation = MathHelper.ToRadians(100); float maxVelocity = death ? 18f : revenge ? 16f : 14f; float acceleration = death ? 1.03f : revenge ? 1.025f : 1.02f; int spikeType = 0; + int dustType = DustID.TintableDust; + Color dustColor = Color.Crimson; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(40f, 40f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { spikeType = numProj - 1 - i; + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 20f * scaleStretch, perturbedSpeed, type2, damage, 0f, Main.myPlayer, maxVelocity, acceleration, spikeType); + Vector2 projectileLocation = spawnLocation + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 70f * scaleStretch; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 32; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type2, BigSpikeDamage, 0f, Main.myPlayer, maxVelocity, acceleration, spikeType); } + // Die NPC.life = 0; NPC.HitEffect(); NPC.active = false; @@ -197,15 +236,23 @@ namespace CalamityMod.NPCs.SlimeGod enraged = false; } - if (bossRush) - enraged = true; - if (NPC.localAI[1] != 1f) { if (enraged) NPC.defense = NPC.defDefense * 2; } + // Slow down dramatically while teleporting + if (NPC.ai[0] == 4f || NPC.ai[0] == 5f) + { + if (Math.Abs(NPC.velocity.X) > 0.1f) + { + NPC.velocity.X *= 0.8f; + if (Math.Abs(NPC.velocity.X) <= 0.1f) + NPC.velocity.X = 0f; + } + } + // Teleport float teleportGateValue = 720f; if (!player.dead && NPC.timeLeft > 10 && calamityGlobalNPC.newAI[0] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) @@ -213,10 +260,7 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - // Slow down dramatically - NPC.velocity.X *= 0.5f; - - NPC.ai[0] = 5f; + NPC.ai[0] = 4f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -270,32 +314,30 @@ namespace CalamityMod.NPCs.SlimeGod } } - // Get ready to teleport by increasing ai[3] + // Get ready to teleport if (calamityGlobalNPC.newAI[0] < teleportGateValue) { - if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) - calamityGlobalNPC.newAI[0] += death ? 3f : 2f; + // Teleport very soon if too far away + float catchUpDistance = 1500f; + bool fastTeleport = NPC.Distance(player.Center) > catchUpDistance; + if (fastTeleport) + { + calamityGlobalNPC.newAI[0] += 10f; + } else - calamityGlobalNPC.newAI[0] += 1f; + { + float teleportFasterDistance = 500f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > teleportFasterDistance) + calamityGlobalNPC.newAI[0] += death ? 3f : 2f; + else + calamityGlobalNPC.newAI[0] += 1f; + } } - float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); + float distanceSpeedBoost = NPC.Distance(player.Center) * 0.005f; if (NPC.ai[0] == 0f) { - bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > 2400f || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); - if (Main.netMode != NetmodeID.MultiplayerClient && phaseThroughTilesToReachTarget) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[0] = 4f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - } - if (NPC.velocity.Y == 0f) { // Avoid cheap bullshit @@ -324,7 +366,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] += 1f; float jumpGateValue = 50f; - float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; + float velocityX = death ? 14f : revenge ? 13f : expertMode ? 12f : 10f; if (revenge) { float moveBoost = death ? 22f * (1f - lifeRatio) : 14f * (1f - lifeRatio); @@ -333,7 +375,7 @@ namespace CalamityMod.NPCs.SlimeGod velocityX += speedBoost; } - float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); + float distanceBelowTarget = NPC.Top.Y - (player.Top.Y + 80f); float speedMult = 1f; if (distanceBelowTarget > 0f) speedMult += distanceBelowTarget * 0.002f; @@ -341,10 +383,7 @@ namespace CalamityMod.NPCs.SlimeGod if (speedMult > 2f) speedMult = 2f; - float velocityY = 8f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - velocityY += 4f; - + float velocityY = 6f; float jumpTelegraphGateValue2 = jumpGateValue - telegraphTime; if (NPC.ai[1] >= jumpGateValue) { @@ -399,15 +438,16 @@ namespace CalamityMod.NPCs.SlimeGod { switch ((int)NPC.localAI[2]) { + // Jump combo default: case 1: NPC.ai[0] = 2f; break; + // Slam case 2: NPC.ai[0] = 1f; break; - } if (NPC.ai[0] == 1f) @@ -416,7 +456,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = setDamage; NPC.noTileCollide = true; - NPC.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; + NPC.velocity.Y = death ? -12f : revenge ? -11f : expertMode ? -10f : -8f; } NPC.ai[1] = 0f; @@ -429,6 +469,8 @@ namespace CalamityMod.NPCs.SlimeGod landingRecoil += (NPC.ai[2] - jumpTelegraphGateValue) / telegraphTime; } } + + // Jump above for slam attack else if (NPC.ai[0] == 1f) { // Avoid cheap bullshit @@ -437,53 +479,55 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noTileCollide = true; NPC.noGravity = true; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.TargetClosest(); - Vector2 targetCenter = player.Center; - targetCenter.Y -= 350f; - Vector2 targetDist = targetCenter - NPC.Center; + + float distanceAboveTarget = 350f; + Vector2 velocity = player.Center - Vector2.UnitY * distanceAboveTarget - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - targetDist = player.Center - NPC.Center; - targetDist.Normalize(); - targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; - NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; - if (NPC.ai[1] > 12f) + float moveSpeed = slamVelocity - 6f; + float inertia = 5f; + velocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * moveSpeed; + NPC.velocity = (NPC.velocity * (inertia - 1f) + velocity) / inertia; + + float delayBeforeSlamming = 12f; + if (NPC.ai[1] > delayBeforeSlamming) { NPC.ai[1] = 0f; NPC.ai[0] = 1.1f; NPC.ai[2] = 0f; - NPC.velocity = targetDist; + NPC.velocity = velocity; } } else { - if (Math.Abs(NPC.Center.X - player.Center.X) < 40f && NPC.Center.Y < player.Center.Y - 300f) + if (Math.Abs(NPC.Center.X - player.Center.X) < 40f && NPC.Center.Y < player.Center.Y - (distanceAboveTarget - 50f)) { NPC.ai[1] = 0f; NPC.ai[2] = 1f; return; } - targetDist.Normalize(); - targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; + float moveSpeed = (death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) + distanceSpeedBoost; + float inertia = 6f; + velocity = velocity.SafeNormalize(Vector2.UnitY) * moveSpeed; + NPC.velocity = (NPC.velocity * (inertia - 1f) + velocity) / inertia; } } + + // Slam down else if (NPC.ai[0] == 1.1f) { // Set damage NPC.damage = setDamage; - bool atTargetPosition = NPC.position.Y + NPC.height >= player.position.Y; + bool atTargetPosition = NPC.Bottom.Y >= player.Top.Y; if (NPC.ai[2] == 0f && (atTargetPosition || NPC.localAI[1] == 0f) && Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { NPC.ai[2] = 1f; @@ -501,38 +545,57 @@ namespace CalamityMod.NPCs.SlimeGod SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - // Eruption of slime balls that fall down - float projectileVelocity = 8f; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + // Calculate stretch here so that the spike spread looks more natural + float stretch = NPC.velocity.Y * 0.03f; + stretch = Math.Abs(stretch) + addedStretch; + + // Stretch rapidly if about to jump or teleport, stretch normally while idle + if (NPC.velocity.Y == 0f) + stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * (NPC.aiAction == 1 ? 15f : 2f)) / 2f + 0.5f); + + if (stretch > 0.5f) + stretch = 0.5f; + + Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; + + // Spread of spikes + float projectileVelocity = 2f; + int type2 = ModContent.ProjectileType(); + Vector2 spawnLocation = new Vector2(NPC.Center.X, NPC.Center.Y + 50f * NPC.scale); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; - int numProj = 5; - float rotation = MathHelper.ToRadians(45); + int numProj = 9; + float rotation = MathHelper.ToRadians(100); + float maxVelocity = death ? 18f : revenge ? 16f : 14f; + float acceleration = death ? 1.03f : revenge ? 1.025f : 1.02f; + int spikeType = 0; + int dustType = DustID.TintableDust; + Color dustColor = Color.Crimson; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(40f, 40f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { + spikeType = numProj - 1 - i; + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed * 1.5f, type, damage, 0f, Main.myPlayer, 1f, 0f); - } + Vector2 projectileLocation = spawnLocation + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 70f * scaleStretch; - // Fire slime balls directly at players with a max of 2 - if (enraged && expertMode) - { - List targets = new List(); - foreach (Player plr in Main.ActivePlayers) - { - if (!plr.dead) - targets.Add(plr.whoAmI); + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); - if (targets.Count > 1) - break; - } - foreach (int t in targets) + for (int j = 0; j < 32; j++) { - Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type2, BigSpikeDamage, 0f, Main.myPlayer, maxVelocity, acceleration, spikeType); } } @@ -552,10 +615,11 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noGravity = true; NPC.velocity.Y += 0.5f; - float velocityLimit = bossRush ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; - if (NPC.velocity.Y > velocityLimit) - NPC.velocity.Y = velocityLimit; + if (NPC.velocity.Y > slamVelocity) + NPC.velocity.Y = slamVelocity; } + + // Jump in quick succession else if (NPC.ai[0] == 2f) { if (NPC.velocity.Y == 0f) @@ -567,30 +631,21 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.8f; NPC.ai[1] += 1f; - if (NPC.ai[1] > 15f) + float jumpGateValue = 15f; + if (NPC.ai[1] > jumpGateValue) { // Set damage NPC.damage = setDamage; NPC.ai[1] = 0f; - NPC.velocity.Y -= 3f; - if (player.position.Y + player.height < NPC.Center.Y) - NPC.velocity.Y -= 1.25f; - if (player.position.Y + player.height < NPC.Center.Y - 40f) - NPC.velocity.Y -= 1.5f; - if (player.position.Y + player.height < NPC.Center.Y - 80f) - NPC.velocity.Y -= 1.75f; - if (player.position.Y + player.height < NPC.Center.Y - 120f) - NPC.velocity.Y -= 2f; - if (player.position.Y + player.height < NPC.Center.Y - 160f) - NPC.velocity.Y -= 2.25f; - if (player.position.Y + player.height < NPC.Center.Y - 200f) - NPC.velocity.Y -= 2.5f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - NPC.velocity.Y -= 2f; + float jumpSpeedX = ((death ? 14f : revenge ? 13f : expertMode ? 12f : 10f) + distanceSpeedBoost) * NPC.direction; + float jumpSpeedY = -4f - (NPC.Top.Y > player.Bottom.Y ? ((NPC.Top.Y - player.Bottom.Y) * 0.05f) : 0f); + if (jumpSpeedY < -16f) + jumpSpeedY = -16f; + + NPC.velocity = new Vector2(jumpSpeedX, jumpSpeedY); - NPC.velocity.X = ((death ? 14f : revenge ? 13f : expertMode ? 12f : 11f) + distanceSpeedBoost) * NPC.direction; NPC.ai[2] += 1f; } else @@ -602,7 +657,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = setDamage; NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f); + float velocityLimit = (death ? 7f : revenge ? 6.5f : expertMode ? 6f : 5f); if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) NPC.velocity.X = -velocityLimit; if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) @@ -647,64 +702,28 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + // Teleport shit else if (NPC.ai[0] == 4f) - { - // Avoid cheap bullshit - NPC.damage = setDamage; - - if (NPC.velocity.X > 0f) - NPC.direction = 1; - else - NPC.direction = -1; - - NPC.spriteDirection = NPC.direction; - NPC.noTileCollide = true; - NPC.noGravity = true; - NPC.knockBackResist = 0f; - Vector2 distanceFromTarget = player.Center - NPC.Center; - distanceFromTarget.Y -= 16f; - if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromTarget.Length() < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && - Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - } - - if (distanceFromTarget.Length() > 12f) - { - distanceFromTarget.Normalize(); - distanceFromTarget *= 12f; - } - - NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; - } - else if (NPC.ai[0] == 5f) { // Avoid cheap bullshit NPC.damage = 0; NPC.aiAction = 1; NPC.ai[1] += 1f; - float teleportTime = bossRush ? 20f : death ? 30f : 40f; + float teleportTime = death ? 30f : 40f; scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); scale = 0.5f + scale * 0.5f; if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) { NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); - NPC.ai[0] = 6f; + NPC.ai[0] = 5f; NPC.ai[1] = 0f; NPC.netUpdate = true; } if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) { - NPC.ai[0] = 6f; + NPC.ai[0] = 5f; NPC.ai[1] = 0f; } @@ -713,18 +732,18 @@ namespace CalamityMod.NPCs.SlimeGod dustColor.A = 150; for (int i = 0; i < 10; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } } - else if (NPC.ai[0] == 6f) + else if (NPC.ai[0] == 5f) { // Avoid cheap bullshit NPC.damage = 0; NPC.ai[1] += 1f; - float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; + float teleportEndTime = death ? 15f : 20f; scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); scale = 0.5f + scale * 0.5f; if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) @@ -747,7 +766,7 @@ namespace CalamityMod.NPCs.SlimeGod dustColor.A = 150; for (int i = 0; i < 10; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } @@ -757,6 +776,7 @@ namespace CalamityMod.NPCs.SlimeGod if (landingRecoil > 0.36f) landingRecoil = 0.36f; + // Slime spawning and scale logic if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -768,11 +788,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio; - NPC.width = (int)(206f * NPC.scale); - NPC.height = (int)(156f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -783,12 +803,11 @@ namespace CalamityMod.NPCs.SlimeGod if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int slimeType = ModContent.NPCType(); - if (Main.rand.NextBool(3)) - slimeType = ModContent.NPCType(); + int offset = 16; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset * 2)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset * 2)); + int slimeType = Main.rand.NextBool(3) ? ModContent.NPCType() : ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; @@ -796,7 +815,7 @@ namespace CalamityMod.NPCs.SlimeGod Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); Main.npc[slimeSpawn].ai[1] = 0f; if (Main.dedServ && slimeSpawn < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn); } } } @@ -855,28 +874,48 @@ namespace CalamityMod.NPCs.SlimeGod return false; } - public static float SlimeRotationFactor(NPC npc) - { - return MathHelper.ToRadians(npc.velocity.X * (-npc.velocity.Y / 10)); - } + public static float SlimeRotationFactor(NPC npc) => MathHelper.ToRadians(npc.velocity.X * (-npc.velocity.Y * 0.1f)); public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + + if (NPC.life <= 0) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(160f * NPC.scale); + NPC.position.X = NPC.position.X - (float)(NPC.width / 2); + NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); + + for (int i = 0; i < 40; i++) + { + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 80; j++) + { + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; + } + } } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Darkness, 300, true); - } } } diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index afc2c59e00..d49b41c6cf 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -22,6 +22,8 @@ namespace CalamityMod.NPCs.SlimeGod private float addedStretch = 0f; private int wingFrameDrawn = 0; private const int TotalWingFrames = 8; + private const int Width = 134; + private const int Height = 150; public static Asset WingTexture; @@ -36,10 +38,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); - NPC.width = 134; - NPC.height = 150; - NPC.scale = 1.1f; + NPC.damage = 40; // 80 + NPC.width = Width; + NPC.height = Height; NPC.defense = 10; NPC.LifeMaxNERB(8000, 9600, 220000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; @@ -48,15 +49,11 @@ namespace CalamityMod.NPCs.SlimeGod NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = 0f; NPC.Opacity = 1f; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -79,13 +76,15 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(1f, 0.2f, 1f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); CalamityGlobalNPC.slimeGodPurple = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || NPC.localAI[1] == 1f || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || NPC.localAI[1] == 1f || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -94,10 +93,10 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.localAI[1] == 1f) { NPC.defense = NPC.defDefense + 20; - setDamage += 22; + setDamage += SlimeGodCore.PossessionDamageBoost; } - float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; + float scale = Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; // Get a target @@ -127,7 +126,7 @@ namespace CalamityMod.NPCs.SlimeGod if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.zenithWorld) { int type = ModContent.ProjectileType(); for (int i = 0; i < 30; i++) @@ -156,15 +155,100 @@ namespace CalamityMod.NPCs.SlimeGod enraged = false; } - if (bossRush) - { - enraged = true; - hyperMode = true; - } - // For animating the wings NPC.localAI[0] += 1f; + // Slow down dramatically while teleporting + if (NPC.ai[0] == 5f || NPC.ai[0] == 6f) + { + if (NPC.velocity.Length() > 0.1f) + { + NPC.velocity *= 0.8f; + if (NPC.velocity.Length() <= 0.1f) + NPC.velocity = Vector2.Zero; + } + } + + // Teleport + float teleportGateValue = 1080f; + if (!player.dead && NPC.timeLeft > 10 && calamityGlobalNPC.newAI[1] >= teleportGateValue && NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.netUpdate = true; + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + + float distanceAhead = 960f; + Vector2 randomDefault = Main.rand.NextBool() ? Vector2.UnitX : -Vector2.UnitX; + Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(randomDefault) * distanceAhead; + Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); + int randomPredictiveTeleportOffset = 5; + int teleportTries = 0; + while (teleportTries < 100) + { + teleportTries++; + int teleportTileX = Main.rand.Next(predictiveTeleportPoint.X - randomPredictiveTeleportOffset, predictiveTeleportPoint.X + randomPredictiveTeleportOffset + 1); + int teleportTileY = Main.rand.Next(predictiveTeleportPoint.Y - randomPredictiveTeleportOffset, predictiveTeleportPoint.Y); + + if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) + { + bool canTeleportToTile = true; + if (canTeleportToTile && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) + canTeleportToTile = false; + if (canTeleportToTile && !Collision.CanHitLine(NPC.Center, 0, 0, predictiveTeleportPoint.ToVector2() * 16, 0, 0)) + canTeleportToTile = false; + + if (canTeleportToTile) + { + calamityGlobalNPC.newAI[2] = teleportTileX * 16 + 8; + calamityGlobalNPC.newAI[3] = teleportTileY * 16 + 16; + calamityGlobalNPC.newAI[1] = 0f; + break; + } + else + predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; + } + else + predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; + } + + // Default teleport if the above conditions aren't met in 100 iterations + if (teleportTries >= 100) + { + Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; + calamityGlobalNPC.newAI[2] = bottom.X; + calamityGlobalNPC.newAI[3] = bottom.Y; + calamityGlobalNPC.newAI[1] = 0f; + } + } + } + + // Get ready to teleport + if (calamityGlobalNPC.newAI[1] < teleportGateValue) + { + // Teleport very soon if too far away + float catchUpDistance = 1500f; + bool fastTeleport = NPC.Distance(player.Center) > catchUpDistance; + if (fastTeleport) + { + calamityGlobalNPC.newAI[1] += 10f; + } + else + { + float teleportFasterDistance = 1000f; + if (NPC.Distance(player.Center) > teleportFasterDistance) + calamityGlobalNPC.newAI[1] += death ? 3f : 2f; + else + calamityGlobalNPC.newAI[1] += 1f; + } + } + if (NPC.ai[0] == 0f) { // Avoid cheap bullshit @@ -177,7 +261,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.timeLeft > 10) { NPC.ai[1] += 1f; - int idleTime = bossRush ? 30 : death ? 75 : revenge ? 90 : 120; + int idleTime = death ? 75 : revenge ? 90 : 120; if (NPC.ai[1] >= idleTime) { NPC.ai[1] = 0f; @@ -227,17 +311,72 @@ namespace CalamityMod.NPCs.SlimeGod int numProjectiles = Main.getGoodWorld ? 12 : death ? 6 : 4; float projectileVelocity = death ? 8f : 6f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y + 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; float rotation = MathHelper.ToRadians(80); + int dustType = DustID.TintableDust; + Color dustColor = Color.Lavender; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProjectiles; i++) { - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) destination *= Main.rand.NextFloat() + 0.5f; Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProjectiles - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Vector2 projectileLocation = NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer); + } + + // Fire slime balls directly at players with a max of 2 + if (enraged && expertMode) + { + List targets = new List(); + foreach (Player plr in Main.ActivePlayers) + { + if (!plr.dead) + targets.Add(plr.whoAmI); + + if (targets.Count > 1) + break; + } + foreach (int t in targets) + { + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Vector2 projectileLocation = NPC.Center + projFireDirection.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(projFireDirection.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, projFireDirection, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer); + } } } @@ -285,17 +424,37 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[1] == 1f) { NPC.ai[3] += 1f; - float slimeDropGateValue = bossRush ? 10f : death ? 20f : revenge ? 25f : expertMode ? 30f : 40f; + float slimeDropGateValue = death ? 20f : revenge ? 25f : expertMode ? 30f : 40f; if (NPC.ai[3] % slimeDropGateValue == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) { float projectileVelocity = 3f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y + 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + destination.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale, destination, type, damage, 0f, Main.myPlayer, 1f); + int dustType = DustID.TintableDust; + Color dustColor = Color.Lavender; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; + Vector2 projectileLocation = NPC.Center + destination.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(destination.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, destination, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer, 1f); } SoundEngine.PlaySound(SlimeGodCore.ShotSound, NPC.Center); @@ -319,17 +478,18 @@ namespace CalamityMod.NPCs.SlimeGod else if (NPC.ai[0] == 3f) { // Distance required to charge - float minChargeSafeDistance = 550f; + float minChargeSafeDistance = 650f; + + // Duration for slow down after charging + float slowDownDurationAfterCharge = revenge ? 90f : 120f; // Charge variables float chargeVelocityMult = 0.1f; - float maxChargeVelocity = (bossRush || enraged) ? 21f : death ? 18f : revenge ? 16.5f : expertMode ? 15f : 12f; + float maxChargeVelocity = enraged ? 12f : death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; if (Main.getGoodWorld) - maxChargeVelocity *= 1.15f; - if (CalamityWorld.LegendaryMode && revenge) maxChargeVelocity *= 2f; - float inertia = (bossRush || enraged) ? 100f : death ? 110f : revenge ? 114f : expertMode ? 120f : 130f; + float inertia = death ? 110f : revenge ? 114f : expertMode ? 120f : 130f; if (lifeRatio < 0.75f) inertia *= 0.8f; if (Main.getGoodWorld) @@ -369,14 +529,13 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = setDamage; NPC.ai[2] += 1f; - float phaseGateValue = (bossRush || enraged) ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; + float phaseGateValue = enraged ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; if (NPC.ai[2] >= phaseGateValue) { NPC.ai[1] = 2f; - float slowDownDurationAfterCharge = revenge ? 90f : 120f; NPC.ai[2] = slowDownDurationAfterCharge; NPC.localAI[2] = 0f; - NPC.velocity /= 2f; + NPC.velocity *= 0.5f; NPC.netUpdate = true; } else @@ -388,7 +547,7 @@ namespace CalamityMod.NPCs.SlimeGod // Accelerate if (NPC.velocity.Length() < maxChargeVelocity) { - float velocityMult = (bossRush || enraged) ? 1.15f : death ? 1.13f : revenge ? 1.12f : expertMode ? 1.11f : 1.1f; + float velocityMult = enraged ? 1.15f : death ? 1.13f : revenge ? 1.12f : expertMode ? 1.11f : 1.1f; NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); if (NPC.velocity.Length() > maxChargeVelocity) { @@ -425,7 +584,19 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - NPC.ai[2] -= 1f; + // Fly to a location that the player can hit + bool flyToHittableLocation = NPC.ai[2] == slowDownDurationAfterCharge && !Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1); + if (flyToHittableLocation) + { + Vector2 velocity = (player.Center - NPC.Center).SafeNormalize(new Vector2(NPC.direction, 0f)) * maxChargeVelocity; + NPC.SimpleFlyMovement(velocity, 0.25f); + } + else + { + NPC.velocity *= 0.95f; + NPC.ai[2] -= 1f; + } + if (NPC.ai[2] <= 0f) { NPC.Calamity().newAI[0] = NPC.ai[0]; @@ -437,8 +608,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.TargetClosest(); NPC.netUpdate = true; } - - NPC.velocity *= 0.95f; } } @@ -459,6 +628,76 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + // Teleport shit + else if (NPC.ai[0] == 5f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.aiAction = 1; + NPC.ai[1] += 1f; + float teleportTime = death ? 30f : 40f; + scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.Bottom = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) + { + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + } + + // Emit teleport dust + Color dustColor = Color.Lavender; + dustColor.A = 150; + for (int i = 0; i < 5; i++) + { + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; + } + } + else if (NPC.ai[0] == 6f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[1] += 1f; + float teleportEndTime = death ? 15f : 20f; + scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = 0f; + NPC.ai[1] = -10f; + NPC.netUpdate = true; + NPC.TargetClosest(); + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = -10f; + NPC.TargetClosest(); + } + + // Emit teleport dust + Color dustColor = Color.Lavender; + dustColor.A = 150; + for (int i = 0; i < 5; i++) + { + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); + Main.dust[corruptDust].noGravity = true; + Main.dust[corruptDust].velocity *= 0.5f; + } + } + if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -470,11 +709,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio; - NPC.width = (int)(134f * NPC.scale); - NPC.height = (int)(150f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -488,8 +727,9 @@ namespace CalamityMod.NPCs.SlimeGod int randSlimeAmt = Main.rand.Next(1, 3); for (int j = 0; j < randSlimeAmt; j++) { - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); + int offset = 16; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset * 2)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset * 2)); int slimeType = ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); @@ -508,14 +748,12 @@ namespace CalamityMod.NPCs.SlimeGod public static void FlyMovement(NPC npc, bool slimeBombardment = false) { // Difficulty bools - bool bossRush = BossRushEvent.BossRushActive; - bool masterMode = Main.masterMode; bool death = CalamityWorld.death; bool revenge = CalamityWorld.revenge; bool ableToDropSlime = npc.ai[1] == 1f; - float flyVelocity = bossRush ? 20f : death ? 15f : revenge ? 12.5f : 10f; - float flyAcceleration = bossRush ? 0.24f : death ? 0.18f : revenge ? 0.15f : 0.12f; + float flyVelocity = death ? 15f : revenge ? 12.5f : 10f; + float flyAcceleration = death ? 0.18f : revenge ? 0.15f : 0.12f; if (slimeBombardment) { @@ -528,7 +766,7 @@ namespace CalamityMod.NPCs.SlimeGod } float slimeBombardmentDistance = 720f; - float flyDistanceY = slimeBombardment ? -450f : masterMode ? -360f : -405f; + float flyDistanceY = slimeBombardment ? -450f : death ? -360f : -405f; float flyDistanceX = slimeBombardment ? (ableToDropSlime ? (slimeBombardmentDistance * -npc.ai[2]) : (slimeBombardmentDistance * npc.ai[2])) : 0f; Vector2 destination = Main.player[npc.target].Center + new Vector2(flyDistanceX, flyDistanceY); @@ -618,7 +856,7 @@ namespace CalamityMod.NPCs.SlimeGod if (hitboxBotRight < minDist) minDist = hitboxBotRight; - return minDist <= 65f * NPC.scale; + return minDist <= 55f * NPC.scale; } public override Color? GetAlpha(Color drawColor) @@ -703,19 +941,42 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + + if (NPC.life <= 0) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(160f * NPC.scale); + NPC.position.X = NPC.position.X - (float)(NPC.width / 2); + NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); + + for (int i = 0; i < 40; i++) + { + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 80; j++) + { + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; + } + } } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Weak, 300, true); - } } } diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index a25fc02f8b..eaa14ff1bb 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -1,22 +1,15 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using CalamityMod.CalPlayer; +using System.IO; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Boss; using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; @@ -36,6 +29,22 @@ namespace CalamityMod.NPCs.SlimeGod [AutoloadBossHead] public class SlimeGodCore : ModNPC { + private enum PaladinSlimeTypes + { + None, + Ebonian, + Crimulan + } + + private enum AggressionLevel + { + Neutral, + FireProjectiles, + ChargeAbovePlayer, + ChargeAtPlayer, + DoEverythingMoreOften + } + private bool slimesSpawned = false; private int buffedSlime = 0; @@ -44,7 +53,6 @@ namespace CalamityMod.NPCs.SlimeGod public static readonly SoundStyle ShotSound = new("CalamityMod/Sounds/Custom/SlimeGodShot", 2); public static readonly SoundStyle BigShotSound = new("CalamityMod/Sounds/Custom/SlimeGodBigShot", 2); - public static Asset ZenithSeedEyeTexture; public static Asset EyeTexture; public static Asset OverlayTexture; @@ -57,35 +65,26 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - Scale = 0.5f, - PortraitScale = 0.6f, - CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/SlimeGod_Bestiary", - PortraitPositionXOverride = 40, - PortraitPositionYOverride = 40 - }; - value.Position.X += 65; - value.Position.Y += 35; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.MPAllowedEnemies[Type] = true; if (!Main.dedServ) { - ZenithSeedEyeTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/SlimeGodEyes", AssetRequestMode.AsyncLoad); EyeTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEye", AssetRequestMode.AsyncLoad); OverlayTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreOverlay", AssetRequestMode.AsyncLoad); } } + public static int GlobDamage = 15; // 60 + public static int PossessionDamageBoost = 10; // +20 flat contact damage + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 40; // 80 NPC.npcSlots = 10f; NPC.width = 96; NPC.height = 98; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) NPC.scale = 2f; NPC.defense = 6; @@ -95,7 +94,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 12, 0, 0); + NPC.value = Item.buyPrice(gold: 8); NPC.Opacity = 0.8f; NPC.boss = true; NPC.BossBar = ModContent.GetInstance(); @@ -106,9 +105,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.DeathSound = SoundID.NPCDeath1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -132,7 +128,7 @@ namespace CalamityMod.NPCs.SlimeGod { if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active) { - if ((npc.ModNPC as SlimeGodCore).buffedSlime == 1) + if ((npc.ModNPC as SlimeGodCore).buffedSlime == (int)PaladinSlimeTypes.Ebonian) Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 1f; else Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 0f; @@ -155,7 +151,7 @@ namespace CalamityMod.NPCs.SlimeGod { if (Main.npc[CalamityGlobalNPC.slimeGodRed].active) { - if ((npc.ModNPC as SlimeGodCore).buffedSlime == 2) + if ((npc.ModNPC as SlimeGodCore).buffedSlime == (int)PaladinSlimeTypes.Crimulan) Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 1f; else Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 0f; @@ -192,14 +188,15 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + Vector3 light = new Vector3(0.5f, 0.5f, 0.5f) * NPC.Opacity; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); CalamityGlobalNPC.slimeGod = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // For animating the eye NPC.localAI[0] += 1f; @@ -226,17 +223,17 @@ namespace CalamityMod.NPCs.SlimeGod // Charge at level 2 // Follow the player around instead of the Paladins at level 3 // Buff a Paladin far sooner, fire more projectiles, and charge faster at level 4 - int aggressionLevel = 0; + int aggressionLevel = (int)AggressionLevel.Neutral; if (!NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType())) { - aggressionLevel = 1; + aggressionLevel = (int)AggressionLevel.FireProjectiles; int splitPaladinCount = NPC.CountNPCS(ModContent.NPCType()) + NPC.CountNPCS(ModContent.NPCType()); if (splitPaladinCount < 2) - aggressionLevel = 4; + aggressionLevel = (int)AggressionLevel.DoEverythingMoreOften; else if (splitPaladinCount < 3) - aggressionLevel = 3; + aggressionLevel = (int)AggressionLevel.ChargeAtPlayer; else if (splitPaladinCount < 4) - aggressionLevel = 2; + aggressionLevel = (int)AggressionLevel.ChargeAbovePlayer; } // Enrage based on large slimes @@ -324,7 +321,7 @@ namespace CalamityMod.NPCs.SlimeGod string key = "Mods.CalamityMod.Status.Boss.SlimeGodRun"; Color messageColor = Color.Magenta; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Set Slime God to have interacted with all players @@ -399,7 +396,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.timeLeft = 1800; // Hide inside large slime - float hideInsideLargeSlimePhaseGateValue = aggressionLevel == 4 ? 120f : phase2 ? 300f : 900f; + float hideInsideLargeSlimePhaseGateValue = aggressionLevel == (int)AggressionLevel.DoEverythingMoreOften ? 120f : phase2 ? 300f : 900f; float hideInsideLargeSlimePhaseDuration = 600f; float exitLargeSlimeGateValue = hideInsideLargeSlimePhaseGateValue + hideInsideLargeSlimePhaseDuration; calamityGlobalNPC.newAI[2] += 1f; @@ -410,27 +407,27 @@ namespace CalamityMod.NPCs.SlimeGod NPC.rotation += NPC.direction * 0.3f; - if (buffedSlime == 0) + if (buffedSlime == (int)PaladinSlimeTypes.None) { SoundEngine.PlaySound(PossessionSound, NPC.Center); if (purpleSlimeAlive && redSlimeAlive) buffedSlime = Main.rand.Next(2) + 1; else if (purpleSlimeAlive) - buffedSlime = 1; + buffedSlime = (int)PaladinSlimeTypes.Ebonian; else if (redSlimeAlive) - buffedSlime = 2; + buffedSlime = (int)PaladinSlimeTypes.Crimulan; } Vector2 purpleSlimeVector = new Vector2(calamityGlobalNPC.newAI[0], calamityGlobalNPC.newAI[1]); Vector2 redSlimeVector = new Vector2(NPC.ai[1], NPC.ai[2]); - Vector2 goToVector = buffedSlime == 1 ? purpleSlimeVector : redSlimeVector; + Vector2 goToVector = buffedSlime == (int)PaladinSlimeTypes.Ebonian ? purpleSlimeVector : redSlimeVector; Vector2 goToPosition = goToVector - NPC.Center; - NPC.velocity = Vector2.Normalize(goToPosition) * 24f; + NPC.velocity = goToPosition.SafeNormalize(Vector2.UnitY) * 24f; // Reduce velocity to 0 to avoid spastic movement when inside big slime. - float stickPositionAdjustment = buffedSlime == 1 ? 16f : 32f; + float stickPositionAdjustment = buffedSlime == (int)PaladinSlimeTypes.Ebonian ? 16f : 32f; if (Vector2.Distance(NPC.Center, goToVector) < 80f + stickPositionAdjustment) { NPC.velocity = Vector2.Zero; @@ -483,11 +480,11 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - if (expertMode && aggressionLevel >= 1) + if (expertMode && aggressionLevel >= (int)AggressionLevel.FireProjectiles) { - float divisor = bossRush ? 50f : death ? 90f : revenge ? 120f : 150f; + float divisor = death ? 90f : revenge ? 120f : 150f; divisor -= (aggressionLevel - 1) * 10f; - if (aggressionLevel == 4) + if (aggressionLevel == (int)AggressionLevel.DoEverythingMoreOften) divisor *= 0.5f; if (calamityGlobalNPC.newAI[2] % divisor == 0f) @@ -499,17 +496,15 @@ namespace CalamityMod.NPCs.SlimeGod { float projectileVelocity = 4f + (aggressionLevel - 1) * 2f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 velocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 0f, Main.myPlayer); + Vector2 velocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, GlobDamage, 0f, Main.myPlayer); } else { float projectileVelocity = 8f + (aggressionLevel - 1) * 2f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 velocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 0f, Main.myPlayer); + Vector2 velocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, GlobDamage, 0f, Main.myPlayer); } } } @@ -519,125 +514,69 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.Opacity > 0.8f) NPC.Opacity = 0.8f; - buffedSlime = 0; + buffedSlime = (int)PaladinSlimeTypes.None; float flySpeed = death ? 15f : revenge ? 13.5f : expertMode ? 12f : 9f; flySpeed += aggressionLevel; - if (aggressionLevel == 4) + if (aggressionLevel == (int)AggressionLevel.DoEverythingMoreOften) flySpeed += 3f; if (phase2) flySpeed *= 1.1f; - if (bossRush) - flySpeed *= 1.2f; if (Main.getGoodWorld) flySpeed *= 1.3f; - Vector2 flyDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - Vector2 flyDestination = aggressionLevel >= 3 ? player.Center : GetFlyDestination(player); - Vector2 idealVelocity = (flyDestination - flyDirection).SafeNormalize(Vector2.UnitY) * flySpeed; + Vector2 flyDestination = aggressionLevel >= (int)AggressionLevel.ChargeAtPlayer ? player.Center : player.Center - Vector2.UnitY * 320f; + Vector2 idealVelocity = (flyDestination - NPC.Center).SafeNormalize(Vector2.UnitY) * flySpeed; float distanceFromFlyDestination = NPC.Distance(flyDestination); - if (aggressionLevel >= 2) + if (aggressionLevel >= (int)AggressionLevel.ChargeAbovePlayer) { NPC.ai[0] -= 1f; - if (distanceFromFlyDestination < 200f || NPC.ai[0] > 0f) + float chargeGateDistance = aggressionLevel >= (int)AggressionLevel.ChargeAtPlayer ? 160f : 80f; + float chargeCooldown = 20f; + if (distanceFromFlyDestination < chargeGateDistance || NPC.ai[0] > 0f) { // Set damage NPC.damage = NPC.defDamage; - if (distanceFromFlyDestination < 200f) - NPC.ai[0] = 20f; - - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; + if (distanceFromFlyDestination < chargeGateDistance) + NPC.ai[0] = chargeCooldown; + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.rotation += NPC.direction * 0.3f; return; } } - if (distanceFromFlyDestination < 150f && aggressionLevel < 2) + float slowDownDistance = 160f; + if (distanceFromFlyDestination < slowDownDistance && aggressionLevel < (int)AggressionLevel.ChargeAbovePlayer) { - if (NPC.velocity.Length() > flySpeed * 0.2f) + if (NPC.velocity.Length() > flySpeed * 0.1f) NPC.velocity *= 0.9f; } else { - float inertia = 50f; - inertia -= aggressionLevel * 3f; + float minInertia = 6f; + float minInertiaDistance = 200f; + float maxInertia = 50f - aggressionLevel * 3f; + float maxInertiaDistance = 600f; + float totalInertiaAdjustmentDistance = maxInertiaDistance - minInertiaDistance; + float distanceFromInertiaAdjustmentCutoff = distanceFromFlyDestination - minInertiaDistance; if (Main.getGoodWorld) - inertia *= 0.8f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - inertia *= Main.rand.NextFloat(0.2f, 1f); + maxInertia *= 0.8f; + + float inertia = distanceFromFlyDestination >= maxInertiaDistance ? maxInertia : + distanceFromFlyDestination <= minInertiaDistance ? minInertia : + MathHelper.Lerp(minInertia, maxInertia, 1f - (totalInertiaAdjustmentDistance - distanceFromInertiaAdjustmentCutoff) / totalInertiaAdjustmentDistance); NPC.velocity = (NPC.velocity * inertia + idealVelocity) / (inertia + 1f); - if (distanceFromFlyDestination < 350f) - NPC.velocity = (NPC.velocity * 10f + idealVelocity) / 11f; - if (distanceFromFlyDestination < 300f) - NPC.velocity = (NPC.velocity * 7f + idealVelocity) / 8f; } NPC.rotation = NPC.velocity.X * 0.05f; } - public Vector2 GetFlyDestination(Player target) - { - // Find all large slimes in the world. - // If multiple slimes are present, and they are all relatively close together, try to stay in their general area. - // If they are far apart, try to stay towards the closest slime. - // If no slimes exist, or they are all extremely far away, try to stay near the target player instead. - - int largeCrimulanPaladin = ModContent.NPCType(); - int splitCrimulanPaladin = ModContent.NPCType(); - int largeEbonianPaladin = ModContent.NPCType(); - int splitEbonianPaladin = ModContent.NPCType(); - List largeSlimes = new(); - - float ignoreGeneralAreaDistanceThreshold = 750f; - float ignoreAllSlimesDistanceThreshold = 3200f; - - // Find all slimes within a generous area. - foreach (NPC n in Main.ActiveNPCs) - { - int npcType = n.type; - if (npcType != largeCrimulanPaladin && npcType != splitCrimulanPaladin && npcType != largeEbonianPaladin && npcType != splitEbonianPaladin) - continue; - - if (!NPC.WithinRange(n.Center, ignoreAllSlimesDistanceThreshold)) - continue; - - largeSlimes.Add(n); - } - - // If no slimes were found, don't bother doing any more calculations. Just use the player's center. - if (largeSlimes.Count <= 0) - return target.Center; - - // Find the closest slime. - NPC closestSlime = largeSlimes.OrderBy(n => n.Distance(NPC.Center)).First(); - - // Get the general area of all the slimes by averaging together their positions. - Vector2 generalSlimeArea = Vector2.Zero; - for (int i = 0; i < largeSlimes.Count; i++) - generalSlimeArea += largeSlimes[i].Center; - generalSlimeArea /= largeSlimes.Count; - - // Determine the average deviation of all slimes from the general area. - // This provides a general idea of how far apart all the slimes are from each-other. - float averageGeneralAreaDistanceDeviation = largeSlimes.Average(s => s.Distance(generalSlimeArea)); - - // The slimes are too far apart. Simply go with the closest slime. - if (averageGeneralAreaDistanceDeviation > ignoreGeneralAreaDistanceThreshold) - return closestSlime.Center; - - // Otherwise, use the average general position as a place to hover. - return generalSlimeArea; - } - public override Color? GetAlpha(Color drawColor) { Color newColor = new Color(255, 255, 255, 255); @@ -649,7 +588,7 @@ namespace CalamityMod.NPCs.SlimeGod float sc = 1f; if (!ShouldDespawn(NPC)) { - if (buffedSlime != 0f) + if (buffedSlime != (int)PaladinSlimeTypes.None) { NPC.scale = MathHelper.Lerp(NPC.scale, 0f, 0.2f); NPC.Opacity = MathHelper.Lerp(NPC.Opacity, 0.7f, 0.4f); @@ -662,17 +601,16 @@ namespace CalamityMod.NPCs.SlimeGod } SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Color drawColorAlpha = (buffedSlime != 0f && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); + Color drawColorAlpha = (buffedSlime != (int)PaladinSlimeTypes.None && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); Vector2 origin = NPC.frame.Size() * 0.5f; Vector2 halfSize = NPC.Size * 0.5f; Texture2D texture = TextureAssets.Npc[Type].Value; Texture2D eyeTexture = EyeTexture.Value; Texture2D overlayTexture = OverlayTexture.Value; - Texture2D pog = ZenithSeedEyeTexture.Value; // Used for animating the eye - if (NPC.localAI[0] % 6f == 0f) + if (NPC.localAI[0] % 6f == 0f && !NPC.IsABestiaryIconDummy) { eyeFrameDrawn++; if (eyeFrameX == 0) @@ -725,7 +663,7 @@ namespace CalamityMod.NPCs.SlimeGod } // Reset the color - drawColorAlpha = (buffedSlime != 0f && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); + drawColorAlpha = (buffedSlime != (int)PaladinSlimeTypes.None && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); // Draw the base texture spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); @@ -736,9 +674,6 @@ namespace CalamityMod.NPCs.SlimeGod // Draw the overlay spriteBatch.Draw(overlayTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); - if (Main.zenithWorld) - spriteBatch.Draw(pog, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); - return false; } @@ -763,7 +698,7 @@ namespace CalamityMod.NPCs.SlimeGod return minDist <= 40f * NPC.scale; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ItemID.HealingPotion; } @@ -812,7 +747,8 @@ namespace CalamityMod.NPCs.SlimeGod normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // Equipment - normalOnly.Add(ModContent.ItemType()); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(ModContent.ItemType()); } npcLoot.Add(ModContent.ItemType(), 10); @@ -821,7 +757,7 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); // GFB Gelatin Crystal drop - npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(ItemID.QueenSlimeCrystal, hideLootReport: true); + npcLoot.DefineConditionalDropSet(DropHelper.GFB).Add(DropHelper.PerPlayer(ItemID.QueenSlimeCrystal), hideLootReport: true); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedSlimeGod, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -842,9 +778,7 @@ namespace CalamityMod.NPCs.SlimeGod if (hurtInfo.Damage > 0) { int debufftype = Main.zenithWorld ? BuffID.VortexDebuff : BuffID.Slow; - target.AddBuff(debufftype, 180, true); - target.AddBuff(BuffID.Weak, 180, true); - target.AddBuff(BuffID.Darkness, 180, true); + target.AddBuff(debufftype, 180); } } } diff --git a/NPCs/SlimeGod/SlimeGodEyes.png b/NPCs/SlimeGod/SlimeGodEyes.png deleted file mode 100644 index dda0f23656..0000000000 Binary files a/NPCs/SlimeGod/SlimeGodEyes.png and /dev/null differ diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index 0de260db20..60b03274f5 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -21,6 +21,8 @@ namespace CalamityMod.NPCs.SlimeGod private float bossLife; private float addedStretch = 0f; private float landingRecoil = 0f; + private const int Width = 166; + private const int Height = 114; public override void SetStaticDefaults() { @@ -38,15 +40,13 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 36; // 72 NPC.LifeMaxNERB(1875, 2250, 80000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.GetNPCDamage(); - NPC.width = 166; - NPC.height = 114; - NPC.scale = 0.8f; + NPC.width = Width; + NPC.height = Height; NPC.defense = 10; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 1, 0, 0); NPC.Opacity = 1f; NPC.lavaImmune = false; NPC.noGravity = false; @@ -57,9 +57,6 @@ namespace CalamityMod.NPCs.SlimeGod AIType = -1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -90,22 +87,27 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.75f, 0.15f, 0.15f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + if (CalamityGlobalNPC.slimeGodRed < 0 || !Main.npc[CalamityGlobalNPC.slimeGodRed].active) CalamityGlobalNPC.slimeGodRed = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || NPC.localAI[1] == 1f || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || NPC.localAI[1] == 1f || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Reset defense and damage NPC.defense = NPC.defDefense; int setDamage = NPC.defDamage; + + // Boost defense and damage while buffed by the Slime God if (NPC.localAI[1] == 1f) { NPC.defense = NPC.defDefense + 20; - setDamage += 22; + setDamage += SlimeGodCore.PossessionDamageBoost; } // Used for landing squash and stretch @@ -119,8 +121,16 @@ namespace CalamityMod.NPCs.SlimeGod addedStretch = -landingRecoil; - float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; + // Used for teleporting + float scale = Main.getGoodWorld ? 0.8f : 1f; + + // How fast the slime slams down + float slamVelocity = death ? 18.25f : revenge ? 16.5f : expertMode ? 15.5f : 13.5f; + + // Used for how fast the slime animates NPC.aiAction = 0; + + // Reset tile collide and gravity NPC.noTileCollide = false; NPC.noGravity = false; @@ -130,6 +140,7 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; + // Despawn if (NPC.ai[0] != 3f) { if (player.dead || !player.active) @@ -156,15 +167,23 @@ namespace CalamityMod.NPCs.SlimeGod enraged = false; } - if (bossRush) - enraged = true; - if (NPC.localAI[1] != 1f) { if (enraged) NPC.defense = NPC.defDefense * 2; } + // Slow down dramatically while teleporting + if (NPC.ai[0] == 4f || NPC.ai[0] == 5f) + { + if (Math.Abs(NPC.velocity.X) > 0.1f) + { + NPC.velocity.X *= 0.8f; + if (Math.Abs(NPC.velocity.X) <= 0.1f) + NPC.velocity.X = 0f; + } + } + // Teleport float teleportGateValue = 720f; if (!player.dead && NPC.timeLeft > 10 && NPC.ai[3] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) @@ -172,10 +191,7 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - // Slow down dramatically - NPC.velocity.X *= 0.5f; - - NPC.ai[0] = 5f; + NPC.ai[0] = 4f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -229,32 +245,31 @@ namespace CalamityMod.NPCs.SlimeGod } } - // Get ready to teleport by increasing ai[3] + // Get ready to teleport // This only occurs in Rev and Death for the split Slime Gods if (NPC.ai[3] < teleportGateValue && revenge) { - if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) - NPC.ai[3] += death ? 3f : 2f; + // Teleport very soon if too far away + float catchUpDistance = 1500f; + bool fastTeleport = NPC.Distance(player.Center) > catchUpDistance; + if (fastTeleport) + { + NPC.ai[3] += 10f; + } else - NPC.ai[3] += 1f; + { + float teleportFasterDistance = 500f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > teleportFasterDistance) + NPC.ai[3] += death ? 3f : 2f; + else + NPC.ai[3] += 1f; + } } - float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); + float distanceSpeedBoost = NPC.Distance(player.Center) * 0.005f; if (NPC.ai[0] == 0f) { - bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > 2400f || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); - if (Main.netMode != NetmodeID.MultiplayerClient && phaseThroughTilesToReachTarget) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[0] = 4f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.netUpdate = true; - } - if (NPC.velocity.Y == 0f) { // Avoid cheap bullshit @@ -283,7 +298,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] += 1f; float jumpGateValue = 40f; - float velocityX = death ? 11.5f : revenge ? 10.5f : expertMode ? 9.5f : 7.5f; + float velocityX = death ? 16.25f : revenge ? 14.5f : expertMode ? 13.5f : 11.5f; if (revenge) { float moveBoost = death ? 11f * (1f - lifeRatio) : 7f * (1f - lifeRatio); @@ -292,7 +307,7 @@ namespace CalamityMod.NPCs.SlimeGod velocityX += speedBoost; } - float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); + float distanceBelowTarget = NPC.Top.Y - (player.Top.Y + 80f); float speedMult = 1f; if (distanceBelowTarget > 0f) speedMult += distanceBelowTarget * 0.002f; @@ -300,10 +315,7 @@ namespace CalamityMod.NPCs.SlimeGod if (speedMult > 2f) speedMult = 2f; - float velocityY = 8f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - velocityY += 4f; - + float velocityY = 6f; float jumpTelegraphGateValue2 = jumpGateValue - telegraphTime; if (NPC.ai[1] >= jumpGateValue) { @@ -352,11 +364,13 @@ namespace CalamityMod.NPCs.SlimeGod { switch ((int)NPC.localAI[2]) { + // Jump combo default: case 1: NPC.ai[0] = 2f; break; + // Slam case 2: NPC.ai[0] = 1f; break; @@ -368,7 +382,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = setDamage; NPC.noTileCollide = true; - NPC.velocity.Y = death ? -11f : revenge ? -10f : expertMode ? -9f : -8f; + NPC.velocity.Y = death ? -12f : revenge ? -11f : expertMode ? -10f : -8f; } NPC.ai[1] = 0f; @@ -380,6 +394,8 @@ namespace CalamityMod.NPCs.SlimeGod landingRecoil += (NPC.ai[2] - jumpTelegraphGateValue) / telegraphTime; } } + + // Jump above for slam attack else if (NPC.ai[0] == 1f) { // Avoid cheap bullshit @@ -388,53 +404,55 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noTileCollide = true; NPC.noGravity = true; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.TargetClosest(); - Vector2 targetCenter = player.Center; - targetCenter.Y -= 350f; - Vector2 targetDist = targetCenter - NPC.Center; + + float distanceAboveTarget = 300f; + Vector2 velocity = player.Center - Vector2.UnitY * distanceAboveTarget - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - targetDist = player.Center - NPC.Center; - targetDist.Normalize(); - targetDist *= death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; - NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; - if (NPC.ai[1] > 12f) + float moveSpeed = slamVelocity - 6f; + float inertia = 5f; + velocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * moveSpeed; + NPC.velocity = (NPC.velocity * (inertia - 1f) + velocity) / inertia; + + float delayBeforeSlamming = 12f; + if (NPC.ai[1] > delayBeforeSlamming) { NPC.ai[1] = 0f; NPC.ai[0] = 1.1f; NPC.ai[2] = 0f; - NPC.velocity = targetDist; + NPC.velocity = velocity; } } else { - if (Math.Abs(NPC.Center.X - player.Center.X) < 40f && NPC.Center.Y < player.Center.Y - 300f) + if (Math.Abs(NPC.Center.X - player.Center.X) < 40f && NPC.Center.Y < player.Center.Y - (distanceAboveTarget - 50f)) { NPC.ai[1] = 0f; NPC.ai[2] = 1f; return; } - targetDist.Normalize(); - targetDist *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; + float moveSpeed = (death ? 18.25f : revenge ? 16.5f : expertMode ? 15.5f : 13.5f) + distanceSpeedBoost; + float inertia = 6f; + velocity = velocity.SafeNormalize(Vector2.UnitY) * moveSpeed; + NPC.velocity = (NPC.velocity * (inertia - 1f) + velocity) / inertia; } } + + // Slam down else if (NPC.ai[0] == 1.1f) { // Set damage NPC.damage = setDamage; - bool atTargetPosition = NPC.position.Y + NPC.height >= player.position.Y; + bool atTargetPosition = NPC.Bottom.Y >= player.Top.Y; if (NPC.ai[2] == 0f && (atTargetPosition || NPC.localAI[1] == 0f) && Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { NPC.ai[2] = 1f; @@ -455,16 +473,35 @@ namespace CalamityMod.NPCs.SlimeGod // Eruption of slime balls that fall down float projectileVelocity = 8f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; int numProj = 3; float rotation = MathHelper.ToRadians(45); + int dustType = DustID.TintableDust; + Color dustColor = Color.Crimson; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed * 1.5f, type, damage, 0f, Main.myPlayer, 1f, 0f); + Vector2 projectileLocation = NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed * 1.5f, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer, 1f, 0f); } // Fire slime balls directly at players with a max of 2 @@ -481,8 +518,24 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = (Main.player[t].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; + Vector2 projectileLocation = NPC.Center + projFireDirection.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(projFireDirection.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, projFireDirection, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer); } } } @@ -501,11 +554,12 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noGravity = true; - NPC.velocity.Y += 0.5f; - float velocityLimit = bossRush ? 22f : death ? 16f : revenge ? 15f : expertMode ? 14f : 13f; - if (NPC.velocity.Y > velocityLimit) - NPC.velocity.Y = velocityLimit; + NPC.velocity.Y += 0.55f; + if (NPC.velocity.Y > slamVelocity) + NPC.velocity.Y = slamVelocity; } + + // Jump in quick succession else if (NPC.ai[0] == 2f) { if (NPC.velocity.Y == 0f) @@ -517,30 +571,21 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.8f; NPC.ai[1] += 1f; - if (NPC.ai[1] > 15f) + float jumpGateValue = 15f; + if (NPC.ai[1] > jumpGateValue) { // Set damage NPC.damage = setDamage; NPC.ai[1] = 0f; - NPC.velocity.Y -= 3f; - if (player.position.Y + player.height < NPC.Center.Y) - NPC.velocity.Y -= 1.25f; - if (player.position.Y + player.height < NPC.Center.Y - 40f) - NPC.velocity.Y -= 1.5f; - if (player.position.Y + player.height < NPC.Center.Y - 80f) - NPC.velocity.Y -= 1.75f; - if (player.position.Y + player.height < NPC.Center.Y - 120f) - NPC.velocity.Y -= 2f; - if (player.position.Y + player.height < NPC.Center.Y - 160f) - NPC.velocity.Y -= 2.25f; - if (player.position.Y + player.height < NPC.Center.Y - 200f) - NPC.velocity.Y -= 2.5f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - NPC.velocity.Y -= 2f; + float jumpSpeedX = ((death ? 16.25f : revenge ? 14.5f : expertMode ? 13.5f : 11.5f) + distanceSpeedBoost) * NPC.direction; + float jumpSpeedY = -4f - (NPC.Top.Y > player.Bottom.Y ? ((NPC.Top.Y - player.Bottom.Y) * 0.05f) : 0f); + if (jumpSpeedY < -16f) + jumpSpeedY = -16f; + + NPC.velocity = new Vector2(jumpSpeedX, jumpSpeedY); - NPC.velocity.X = ((death ? 14f : revenge ? 13f : expertMode ? 12f : 11f) + distanceSpeedBoost) * NPC.direction; NPC.ai[2] += 1f; } else @@ -552,7 +597,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = setDamage; NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f); + float velocityLimit = (death ? 7f : revenge ? 6.5f : expertMode ? 6f : 5f); if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) NPC.velocity.X = -velocityLimit; if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) @@ -596,83 +641,48 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + // Teleport shit else if (NPC.ai[0] == 4f) - { - // Set damage - NPC.damage = setDamage; - - if (NPC.velocity.X > 0f) - NPC.direction = 1; - else - NPC.direction = -1; - - NPC.spriteDirection = NPC.direction; - NPC.noTileCollide = true; - NPC.noGravity = true; - NPC.knockBackResist = 0f; - Vector2 distanceFromTarget = player.Center - NPC.Center; - distanceFromTarget.Y -= 16f; - if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromTarget.Length() < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && - Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.netUpdate = true; - } - - if (distanceFromTarget.Length() > 12f) - { - distanceFromTarget.Normalize(); - distanceFromTarget *= 12f; - } - - NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; - } - else if (NPC.ai[0] == 5f) { // Avoid cheap bullshit NPC.damage = 0; NPC.aiAction = 1; NPC.ai[1] += 1f; - float teleportTime = bossRush ? 20f : death ? 30f : 40f; + float teleportTime = death ? 30f : 40f; scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); scale = 0.5f + scale * 0.5f; if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) { NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); - NPC.ai[0] = 6f; + NPC.ai[0] = 5f; NPC.ai[1] = 0f; NPC.netUpdate = true; } if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) { - NPC.ai[0] = 6f; + NPC.ai[0] = 5f; NPC.ai[1] = 0f; } // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } } - else if (NPC.ai[0] == 6f) + else if (NPC.ai[0] == 5f) { // Avoid cheap bullshit NPC.damage = 0; NPC.ai[1] += 1f; - float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; + float teleportEndTime = death ? 15f : 20f; scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); scale = 0.5f + scale * 0.5f; if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) @@ -693,9 +703,9 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } @@ -705,6 +715,7 @@ namespace CalamityMod.NPCs.SlimeGod if (landingRecoil > 0.36f) landingRecoil = 0.36f; + // Slime spawning and scale logic if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -716,11 +727,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio * 0.75f; - NPC.width = (int)(166f * NPC.scale); - NPC.height = (int)(114f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -731,12 +742,11 @@ namespace CalamityMod.NPCs.SlimeGod if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int slimeType = ModContent.NPCType(); - if (Main.rand.NextBool(3)) - slimeType = ModContent.NPCType(); + int offset = 16; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset * 2)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset * 2)); + int slimeType = Main.rand.NextBool(3) ? ModContent.NPCType() : ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; @@ -744,7 +754,7 @@ namespace CalamityMod.NPCs.SlimeGod Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); Main.npc[slimeSpawn].ai[1] = 0f; if (Main.dedServ && slimeSpawn < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn); } } } @@ -820,21 +830,20 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(80f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 40; i++) + + for (int i = 0; i < 20; i++) { - int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); Main.dust[crimDust].velocity *= 3f; if (Main.rand.NextBool()) { @@ -842,12 +851,13 @@ namespace CalamityMod.NPCs.SlimeGod Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int j = 0; j < 70; j++) + + for (int j = 0; j < 40; j++) { - int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 3f); + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); Main.dust[crimDust2].noGravity = true; Main.dust[crimDust2].velocity *= 5f; - crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); Main.dust[crimDust2].velocity *= 2f; } } @@ -857,11 +867,5 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Darkness, 240, true); - } } } diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index 727a4065b5..d33fbeb648 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -21,6 +21,8 @@ namespace CalamityMod.NPCs.SlimeGod private float bossLife; private float addedStretch = 0f; private float landingRecoil = 0f; + private const int Width = 166; + private const int Height = 114; public override void SetStaticDefaults() { @@ -38,17 +40,15 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 36; // 72 NPC.LifeMaxNERB(2000, 2400, 110000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.GetNPCDamage(); - NPC.width = 166; - NPC.height = 114; - NPC.scale = 0.8f; + NPC.width = Width; + NPC.height = Height; NPC.defense = 8; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 1, 0, 0); NPC.Opacity = 1f; NPC.lavaImmune = false; NPC.noGravity = false; @@ -57,9 +57,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.DeathSound = SoundID.NPCDeath1; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToSickness = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -90,13 +87,15 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.75f, 0.15f, 0.75f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + if (CalamityGlobalNPC.slimeGodPurple < 0 || !Main.npc[CalamityGlobalNPC.slimeGodPurple].active) CalamityGlobalNPC.slimeGodPurple = NPC.whoAmI; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || NPC.localAI[1] == 1f || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || NPC.localAI[1] == 1f || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -105,7 +104,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.localAI[1] == 1f) { NPC.defense = NPC.defDefense + 16; - setDamage += 20; + setDamage += SlimeGodCore.PossessionDamageBoost; } // Used for landing squash and stretch @@ -119,7 +118,11 @@ namespace CalamityMod.NPCs.SlimeGod addedStretch = -landingRecoil; - float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; + float scale = Main.getGoodWorld ? 0.8f : 1f; + + // How fast the slime slams down + float slamVelocity = death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + NPC.aiAction = 0; NPC.noTileCollide = false; NPC.noGravity = false; @@ -157,10 +160,15 @@ namespace CalamityMod.NPCs.SlimeGod enraged = false; } - if (bossRush) + // Slow down dramatically while teleporting + if (NPC.ai[0] == 5f || NPC.ai[0] == 6f) { - enraged = true; - hyperMode = true; + if (Math.Abs(NPC.velocity.X) > 0.1f) + { + NPC.velocity.X *= 0.8f; + if (Math.Abs(NPC.velocity.X) <= 0.1f) + NPC.velocity.X = 0f; + } } // Teleport @@ -170,10 +178,7 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - // Slow down dramatically - NPC.velocity.X *= 0.5f; - - NPC.ai[0] = 6f; + NPC.ai[0] = 5f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -227,32 +232,31 @@ namespace CalamityMod.NPCs.SlimeGod } } - // Get ready to teleport by increasing ai[3] + // Get ready to teleport // This only occurs in Rev and Death for the split Slime Gods if (NPC.ai[3] < teleportGateValue && revenge) { - if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) - NPC.ai[3] += death ? 3f : 2f; + // Teleport very soon if too far away + float catchUpDistance = 1500f; + bool fastTeleport = NPC.Distance(player.Center) > catchUpDistance; + if (fastTeleport) + { + NPC.ai[3] += 10f; + } else - NPC.ai[3] += 1f; + { + float teleportFasterDistance = 500f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > teleportFasterDistance) + NPC.ai[3] += death ? 3f : 2f; + else + NPC.ai[3] += 1f; + } } - float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); + float distanceSpeedBoost = NPC.Distance(player.Center) * 0.005f; if (NPC.ai[0] == 0f) { - bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > 2400f || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); - if (Main.netMode != NetmodeID.MultiplayerClient && phaseThroughTilesToReachTarget) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[0] = 5f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.netUpdate = true; - } - if (NPC.velocity.Y == 0f) { // Avoid cheap bullshit @@ -281,7 +285,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] += hyperMode ? 2f : 1f; float jumpGateValue = 45f; - float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; + float velocityX = death ? 13f : revenge ? 12f : expertMode ? 11f : 9f; if (revenge) { float moveBoost = death ? 15f * (1f - lifeRatio) : 10f * (1f - lifeRatio); @@ -290,7 +294,7 @@ namespace CalamityMod.NPCs.SlimeGod velocityX += speedBoost; } - float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); + float distanceBelowTarget = NPC.Top.Y - (player.Top.Y + 80f); float speedMult = 1f; if (distanceBelowTarget > 0f) speedMult += distanceBelowTarget * 0.002f; @@ -299,9 +303,6 @@ namespace CalamityMod.NPCs.SlimeGod speedMult = 2f; float velocityY = 10f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - velocityY += 2f; - float jumpTelegraphGateValue2 = jumpGateValue - telegraphTime; if (NPC.ai[1] > jumpGateValue) { @@ -370,7 +371,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = setDamage; NPC.noTileCollide = true; - NPC.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; + NPC.velocity.Y = death ? -12f : revenge ? -11f : expertMode ? -10f : -8f; } NPC.ai[1] = 0f; @@ -397,13 +398,12 @@ namespace CalamityMod.NPCs.SlimeGod float slimeShotVelocity = 6f; Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * slimeShotVelocity; float minFiringDistance = 160f; // 10 tile distance - if (Vector2.Distance(NPC.Center, player.Center) > minFiringDistance) + if (NPC.Distance(player.Center) > minFiringDistance) { SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); int numProj = death ? 5 : 3; int spread = death ? 12 : 8; float rotation = MathHelper.ToRadians(spread); @@ -411,7 +411,7 @@ namespace CalamityMod.NPCs.SlimeGod { Vector2 randomVelocity = Main.rand.NextVector2CircularEdge(3f, 3f); Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))) + randomVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 45f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 45f * NPC.scale, perturbedSpeed, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer); } } } @@ -431,45 +431,44 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noTileCollide = true; NPC.noGravity = true; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.TargetClosest(); - Vector2 targetCenter = player.Center; - targetCenter.Y -= 350f; - Vector2 targetDist = targetCenter - NPC.Center; + + float distanceAboveTarget = 350f; + Vector2 velocity = player.Center - Vector2.UnitY * distanceAboveTarget - NPC.Center; if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - targetDist = player.Center - NPC.Center; - targetDist.Normalize(); - targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; - NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; + float moveSpeed = slamVelocity - 6f; + float inertia = 5f; + velocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * moveSpeed; + NPC.velocity = (NPC.velocity * (inertia - 1f) + velocity) / inertia; - if (NPC.ai[1] > 12f) + float delayBeforeSlamming = 12f; + if (NPC.ai[1] > delayBeforeSlamming) { NPC.ai[1] = 0f; NPC.ai[0] = 2.1f; NPC.ai[2] = 0f; - NPC.velocity = targetDist; + NPC.velocity = velocity; } } else { - if (Math.Abs(NPC.Center.X - player.Center.X) < 40f && NPC.Center.Y < player.Center.Y - 300f) + if (Math.Abs(NPC.Center.X - player.Center.X) < 40f && NPC.Center.Y < player.Center.Y - (distanceAboveTarget - 50f)) { NPC.ai[1] = 0f; NPC.ai[2] = 1f; return; } - targetDist.Normalize(); - targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; + float moveSpeed = (death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) + distanceSpeedBoost; + float inertia = 6f; + velocity = velocity.SafeNormalize(Vector2.UnitY) * moveSpeed; + NPC.velocity = (NPC.velocity * (inertia - 1f) + velocity) / inertia; } } else if (NPC.ai[0] == 2.1f) @@ -477,7 +476,7 @@ namespace CalamityMod.NPCs.SlimeGod // Set damage NPC.damage = setDamage; - bool atTargetPosition = NPC.position.Y + NPC.height >= player.position.Y; + bool atTargetPosition = NPC.Bottom.Y >= player.Top.Y; if (NPC.ai[2] == 0f && atTargetPosition && Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { NPC.ai[2] = 1f; @@ -498,19 +497,38 @@ namespace CalamityMod.NPCs.SlimeGod // Eruption of slime balls float projectileVelocity = 4f; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; int numProj = 9; float rotation = MathHelper.ToRadians(90); + int dustType = DustID.TintableDust; + Color dustColor = Color.Lavender; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { // Spawn projectiles 0, 1, 2, 6, 7 and 8 if (i < 3 || i > 5) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 30f * NPC.scale + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Vector2 projectileLocation = NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer); } } @@ -528,8 +546,24 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = (Main.player[t].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; + Vector2 projectileLocation = NPC.Center + projFireDirection.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(projFireDirection.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, projFireDirection, type, SlimeGodCore.GlobDamage, 0f, Main.myPlayer); } } } @@ -549,9 +583,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noGravity = true; NPC.velocity.Y += 0.5f; - float velocityLimit = bossRush ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; - if (NPC.velocity.Y > velocityLimit) - NPC.velocity.Y = velocityLimit; + if (NPC.velocity.Y > slamVelocity) + NPC.velocity.Y = slamVelocity; } else if (NPC.ai[0] == 3f) { @@ -564,30 +597,21 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.8f; NPC.ai[1] += 1f; - if (NPC.ai[1] > 15f) + float jumpGateValue = 15f; + if (NPC.ai[1] > jumpGateValue) { // Set damage NPC.damage = setDamage; NPC.ai[1] = 0f; - NPC.velocity.Y -= 6f; - if (player.position.Y + player.height < NPC.Center.Y) - NPC.velocity.Y -= 1.2f; - if (player.position.Y + player.height < NPC.Center.Y - 40f) - NPC.velocity.Y -= 1.4f; - if (player.position.Y + player.height < NPC.Center.Y - 80f) - NPC.velocity.Y -= 1.7f; - if (player.position.Y + player.height < NPC.Center.Y - 120f) - NPC.velocity.Y -= 2f; - if (player.position.Y + player.height < NPC.Center.Y - 160f) - NPC.velocity.Y -= 2.2f; - if (player.position.Y + player.height < NPC.Center.Y - 200f) - NPC.velocity.Y -= 2.4f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - NPC.velocity.Y -= 2f; + float jumpSpeedX = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 8f) + distanceSpeedBoost) * NPC.direction; + float jumpSpeedY = -6f - (NPC.Top.Y > player.Bottom.Y ? ((NPC.Top.Y - player.Bottom.Y) * 0.05f) : 0f); + if (jumpSpeedY < -18f) + jumpSpeedY = -18f; + + NPC.velocity = new Vector2(jumpSpeedX, jumpSpeedY); - NPC.velocity.X = ((death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost) * NPC.direction; NPC.ai[2] += 1f; } else @@ -599,7 +623,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = setDamage; NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f); + float velocityLimit = (death ? 7f : revenge ? 6.5f : expertMode ? 6f : 5f); if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) NPC.velocity.X = -velocityLimit; if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) @@ -643,83 +667,48 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + // Teleport shit else if (NPC.ai[0] == 5f) - { - // Set damage - NPC.damage = setDamage; - - if (NPC.velocity.X > 0f) - NPC.direction = 1; - else - NPC.direction = -1; - - NPC.spriteDirection = NPC.direction; - NPC.noTileCollide = true; - NPC.noGravity = true; - NPC.knockBackResist = 0f; - Vector2 distanceFromTarget = player.Center - NPC.Center; - distanceFromTarget.Y -= 16f; - if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromTarget.Length() < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && - Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.netUpdate = true; - } - - if (distanceFromTarget.Length() > 12f) - { - distanceFromTarget.Normalize(); - distanceFromTarget *= 12f; - } - - NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; - } - else if (NPC.ai[0] == 6f) { // Avoid cheap bullshit NPC.damage = 0; NPC.aiAction = 1; NPC.ai[1] += 1f; - float teleportTime = bossRush ? 20f : death ? 30f : 40f; + float teleportTime = death ? 30f : 40f; scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); scale = 0.5f + scale * 0.5f; if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) { NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); - NPC.ai[0] = 7f; + NPC.ai[0] = 6f; NPC.ai[1] = 0f; NPC.netUpdate = true; } if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) { - NPC.ai[0] = 7f; + NPC.ai[0] = 6f; NPC.ai[1] = 0f; } // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[corruptDust].noGravity = true; Main.dust[corruptDust].velocity *= 0.5f; } } - else if (NPC.ai[0] == 7f) + else if (NPC.ai[0] == 6f) { // Avoid cheap bullshit NPC.damage = 0; NPC.ai[1] += 1f; - float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; + float teleportEndTime = death ? 15f : 20f; scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); scale = 0.5f + scale * 0.5f; if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) @@ -740,9 +729,9 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[corruptDust].noGravity = true; Main.dust[corruptDust].velocity *= 0.5f; } @@ -763,11 +752,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio * 0.75f; - NPC.width = (int)(166f * NPC.scale); - NPC.height = (int)(114f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -778,8 +767,10 @@ namespace CalamityMod.NPCs.SlimeGod if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); + + int offset = 16; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset * 2)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset * 2)); int slimeType = ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); @@ -788,7 +779,7 @@ namespace CalamityMod.NPCs.SlimeGod Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); Main.npc[slimeSpawn].ai[1] = 0f; if (Main.dedServ && slimeSpawn < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn); } } } @@ -864,35 +855,35 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(80f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 40; i++) + + for (int i = 0; i < 20; i++) { - int corruptionDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[corruptionDust].velocity *= 3f; + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[corruptionDust].scale = 0.5f; - Main.dust[corruptionDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int j = 0; j < 70; j++) + + for (int j = 0; j < 40; j++) { - int corruptionDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 3f); - Main.dust[corruptionDust2].noGravity = true; - Main.dust[corruptionDust2].velocity *= 5f; - corruptionDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[corruptionDust2].velocity *= 2f; + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; } } } @@ -901,11 +892,5 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Weak, 240, true); - } } } diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index 90e0b51f13..70d85d9033 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -14,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(StormWeaverHead))] public class StormWeaverBody : ModNPC { @@ -31,9 +32,11 @@ namespace CalamityMod.NPCs.StormWeaver } } + public static int LaserDamage = 54; // 216 + public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 90; // 180 NPC.npcSlots = 5f; NPC.width = 40; NPC.height = 40; @@ -59,9 +62,7 @@ namespace CalamityMod.NPCs.StormWeaver NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -72,9 +73,6 @@ namespace CalamityMod.NPCs.StormWeaver NPC.scale *= 0.7f; NPC.Calamity().VulnerableToElectricity = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -100,10 +98,9 @@ namespace CalamityMod.NPCs.StormWeaver if (NPC.life > Main.npc[(int)NPC.ai[1]].life) NPC.life = Main.npc[(int)NPC.ai[1]].life; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Shed armor bool phase2 = NPC.life / (float)NPC.lifeMax < 0.8f; @@ -115,7 +112,7 @@ namespace CalamityMod.NPCs.StormWeaver Player player = Main.player[NPC.target]; // Update armored settings to naked settings - if (phase2 && (!CalamityWorld.LegendaryMode || !revenge)) + if (phase2 && (!Main.zenithWorld || !revenge)) { // Spawn armor gore and set other crucial variables if (!NPC.chaseable) @@ -145,7 +142,7 @@ namespace CalamityMod.NPCs.StormWeaver if (Main.netMode != NetmodeID.MultiplayerClient) { // Fire a barrage of lasers every 5 seconds - float laserBarrageGateValue = bossRush ? 200f : 300f; + float laserBarrageGateValue = 300f; if (Main.npc[(int)NPC.ai[2]].localAI[0] % laserBarrageGateValue == 0f) { float bodySegmentDivisor = death ? 6 : revenge ? 5 : expertMode ? 4 : 3; @@ -155,8 +152,7 @@ namespace CalamityMod.NPCs.StormWeaver float projectileVelocity = death ? 6.25f : revenge ? 5.75f : expertMode ? 5.5f : 5f; Vector2 velocityVector = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, damage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocityVector, type, LaserDamage, 0f, Main.myPlayer); Main.projectile[proj].timeLeft = 900; } } @@ -235,21 +231,6 @@ namespace CalamityMod.NPCs.StormWeaver else if (targetX > 0f) NPC.spriteDirection = 1; } - - // Calculate contact damage based on velocity - float velocity = (phase2 ? 12f : 10f) + (bossRush ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); - float minimalContactDamageVelocity = velocity * 0.25f; - float minimalDamageVelocity = velocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -261,18 +242,17 @@ namespace CalamityMod.NPCs.StormWeaver if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; - bool phase2 = lifeRatio < 0.8f && (!CalamityWorld.LegendaryMode || !revenge); + bool phase2 = lifeRatio < 0.8f && (!Main.zenithWorld || !revenge); bool phase3 = lifeRatio < 0.55f; // Gate value that decides when Storm Weaver will charge - float chargePhaseGateValue = bossRush ? 280f : death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; + float chargePhaseGateValue = death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; if (!phase3) chargePhaseGateValue *= 0.5f; @@ -298,23 +278,22 @@ namespace CalamityMod.NPCs.StormWeaver public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; bool phase3 = lifeRatio < 0.55f; // Gate value that decides when Storm Weaver will charge - float chargePhaseGateValue = bossRush ? 280f : death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; + float chargePhaseGateValue = death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; if (!phase3) chargePhaseGateValue *= 0.5f; - int buffDuration = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] >= chargePhaseGateValue ? 120 : 60; + int buffDuration = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] >= chargePhaseGateValue ? 240 : 120; if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Electrified, buffDuration, true); + target.AddBuff(BuffID.Electrified, buffDuration); } public override bool CheckActive() @@ -368,7 +347,6 @@ namespace CalamityMod.NPCs.StormWeaver public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 6132f87145..9c34dbc2f2 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -8,14 +8,13 @@ using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.NPCs.Perforator; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Enemy; using CalamityMod.Sounds; @@ -33,6 +32,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { + [HasPierceResist] [LongDistanceNetSync] public class StormWeaverHead : ModNPC { @@ -82,16 +82,20 @@ namespace CalamityMod.NPCs.StormWeaver } } + public static int LightningDamage = 64; // 256 + public static int FrostWaveDamage = 64; // 256 + public static int TornadoDamage = 72; // 288 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 180; // 360 NPC.npcSlots = 5f; NPC.width = 74; NPC.height = 74; NPC.lifeMax = 825000; NPC.LifeMaxNERB(NPC.lifeMax, NPC.lifeMax, 500000); - NPC.value = Item.buyPrice(1, 0, 0, 0); + NPC.value = Item.buyPrice(gold: 50); // Phase one settings CalamityGlobalNPC global = NPC.Calamity(); @@ -111,9 +115,7 @@ namespace CalamityMod.NPCs.StormWeaver NPC.noTileCollide = true; NPC.netAlways = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -124,9 +126,6 @@ namespace CalamityMod.NPCs.StormWeaver NPC.scale *= 0.7f; NPC.Calamity().VulnerableToElectricity = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -170,14 +169,13 @@ namespace CalamityMod.NPCs.StormWeaver { CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; if (CalamityServerConfig.Instance.BossesStopWeather) CalamityWorld.StopRain(); - else if (!Main.raining && !bossRush) + else if (!Main.raining && !BossRushEvent.BossRushActive) CalamityWorld.StartRain(); float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -192,7 +190,7 @@ namespace CalamityMod.NPCs.StormWeaver bool phase4 = lifeRatio < 0.3f; // Update armored settings to naked settings - if (phase2 && (!CalamityWorld.LegendaryMode || !revenge)) + if (phase2 && !Main.zenithWorld) { // Spawn armor gore, roar and set other crucial variables if (!NPC.chaseable) @@ -279,7 +277,7 @@ namespace CalamityMod.NPCs.StormWeaver } // Used for body and tail projectile firing timings in phase 1 - if (!phase2 || (CalamityWorld.LegendaryMode && revenge)) + if (!phase2 || Main.zenithWorld) NPC.localAI[0] += 1f; } @@ -332,8 +330,8 @@ namespace CalamityMod.NPCs.StormWeaver Vector2 npcCenter = NPC.Center; float targetCenterX = Main.player[NPC.target].Center.X; float targetCenterY = Main.player[NPC.target].Center.Y; - float velocity = (phase2 ? 12f : 10f) + (bossRush ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); - float acceleration = (phase2 ? 0.24f : 0.2f) + (bossRush ? 0.12f : revenge ? 0.08f : expertMode ? 0.04f : 0f); + float velocity = (phase2 ? 12f : 10f) + (revenge ? 1.5f : expertMode ? 1f : 0f); + float acceleration = (phase2 ? 0.24f : 0.2f) + (revenge ? 0.08f : expertMode ? 0.04f : 0f); // Start charging at the player when in phase 2 if (phase2) @@ -357,7 +355,7 @@ namespace CalamityMod.NPCs.StormWeaver bool useTornadoes = calamityGlobalNPC.newAI[3] % 2f != 0f; // Gate value that decides when Storm Weaver will charge - float chargePhaseGateValue = bossRush ? 280f : death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; + float chargePhaseGateValue = death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; if (!phase3) chargePhaseGateValue *= 0.5f; if (phase4 && expertMode) @@ -467,7 +465,6 @@ namespace CalamityMod.NPCs.StormWeaver if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.FrostWave; - int waveDamage = NPC.GetProjectileDamage(type); int totalWaves = death ? (phase4 ? 27 : 25) : (phase4 ? 25 : 23); int shotSpacing = death ? (phase4 ? 185 : 200) : (phase4 ? 200 : 215); float projectileSpawnX = Main.player[NPC.target].Center.X - totalWaves * shotSpacing * 0.5f; @@ -519,7 +516,7 @@ namespace CalamityMod.NPCs.StormWeaver // Frost Waves start moving after 30 frames // Frost Waves take 30 frames to reach full velocity Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawnX, Main.player[NPC.target].Center.Y - 1600f, 0f, velocityY * 0.5f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, velocityY); - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawnX, Main.player[NPC.target].Center.Y - 1600f, 0f, velocityY * 0.1f, type, waveDamage, 0f, Main.myPlayer, delayBeforeFiring, velocityY); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawnX, Main.player[NPC.target].Center.Y - 1600f, 0f, velocityY * 0.1f, type, FrostWaveDamage, 0f, Main.myPlayer, delayBeforeFiring, velocityY); projectileSpawnX += shotSpacing; } } @@ -539,13 +536,12 @@ namespace CalamityMod.NPCs.StormWeaver if (Main.netMode != NetmodeID.MultiplayerClient) { int projectileType = ModContent.ProjectileType(); - int tornadoDamage = NPC.GetProjectileDamage(projectileType); int totalTornadoes = revenge ? 7 : expertMode ? 5 : 3; float spawnDistance = revenge ? 750f : expertMode ? 900f : 1050f; for (int i = 0; i < totalTornadoes; i++) { Vector2 spawnPosition = Main.player[NPC.target].Center + Vector2.UnitX * spawnDistance * (i - totalTornadoes / 2); - Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition, Vector2.Zero, projectileType, 0, 0f, Main.myPlayer, tornadoDamage, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition, Vector2.Zero, projectileType, 0, 0f, Main.myPlayer, TornadoDamage, 1f); } } } @@ -554,6 +550,12 @@ namespace CalamityMod.NPCs.StormWeaver // Charge if (!phase4) { + if (calamityGlobalNPC.newAI[0] == chargePhaseGateValue - 70) + { + Vector2 soundCenter = Main.player[NPC.target].Center; + SoundStyle lightning = new("CalamityMod/Sounds/Custom/LightningTelegraph") { Volume = 0.7f }; + SoundEngine.PlaySound(lightning, soundCenter); + } if (calamityGlobalNPC.newAI[0] >= chargePhaseGateValue) { NPC.localAI[3] = 60f; @@ -670,8 +672,7 @@ namespace CalamityMod.NPCs.StormWeaver Vector2 aimDirection = Main.player[NPC.target].Center - source; float ai = Main.rand.Next(100); int type = ProjectileID.CultistBossLightningOrbArc; - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), source, boltVelocity, type, damage, 0f, Main.myPlayer, aimDirection.ToRotation(), ai); + Projectile.NewProjectile(NPC.GetSource_FromAI(), source, boltVelocity, type, LightningDamage, 0f, Main.myPlayer, aimDirection.ToRotation(), ai); } } } @@ -774,19 +775,6 @@ namespace CalamityMod.NPCs.StormWeaver } } - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = velocity * 0.25f; - float minimalDamageVelocity = velocity * 0.5f; - if (NPC.velocity.Length() <= minimalContactDamageVelocity) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp((float)Math.Round(NPC.defDamage * 0.5), NPC.defDamage, velocityDamageScalar); - } - NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; if (phase4) @@ -812,7 +800,7 @@ namespace CalamityMod.NPCs.StormWeaver SoundEngine.PlaySound(SoundID.Thunder, NPC.Center); // Start a storm when in third phase. Don't do this during Boss Rush - if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f || bossRush) + if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f || BossRushEvent.BossRushActive) return; CalamityWorld.StartRain(true, true); @@ -834,18 +822,17 @@ namespace CalamityMod.NPCs.StormWeaver CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; - bool phase2 = lifeRatio < 0.8f && (!CalamityWorld.LegendaryMode || !revenge); + bool phase2 = lifeRatio < 0.8f && !Main.zenithWorld; bool phase3 = lifeRatio < 0.55f; // Gate value that decides when Storm Weaver will charge - float chargePhaseGateValue = bossRush ? 280f : death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; + float chargePhaseGateValue = death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; if (!phase3) chargePhaseGateValue *= 0.5f; @@ -871,23 +858,22 @@ namespace CalamityMod.NPCs.StormWeaver public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; bool phase3 = lifeRatio < 0.55f; // Gate value that decides when Storm Weaver will charge - float chargePhaseGateValue = bossRush ? 280f : death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; + float chargePhaseGateValue = death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; if (!phase3) chargePhaseGateValue *= 0.5f; - int buffDuration = NPC.Calamity().newAI[0] >= chargePhaseGateValue ? 240 : 120; + int buffDuration = NPC.Calamity().newAI[0] >= chargePhaseGateValue ? 360 : 240; if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Electrified, buffDuration, true); + target.AddBuff(BuffID.Electrified, buffDuration); } public override bool CheckActive() @@ -948,7 +934,7 @@ namespace CalamityMod.NPCs.StormWeaver return true; } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -994,10 +980,11 @@ namespace CalamityMod.NPCs.StormWeaver normalOnly.Add(DropHelper.CalamityStyle(DropHelper.NormalWeaponDropRateFraction, weapons)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // Materials - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 5, 7)); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 10, 12)); // Vanity normalOnly.Add(ModContent.ItemType(), 7); @@ -1017,8 +1004,8 @@ namespace CalamityMod.NPCs.StormWeaver // GFB Elemental Gauntlet and Quiver drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); } // Lore diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 13bc6f7fc9..3608b9cc4d 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { + [HasPierceResist] [LongDistanceNetSync(SyncWith = typeof(StormWeaverHead))] public class StormWeaverTail : ModNPC { @@ -34,9 +35,11 @@ namespace CalamityMod.NPCs.StormWeaver } } + public static int LightningOrbDamage = 64; // 256 + public override void SetDefaults() { - NPC.GetNPCDamage(); + NPC.damage = 80; // 160 NPC.npcSlots = 5f; NPC.width = 48; NPC.height = 80; @@ -58,9 +61,7 @@ namespace CalamityMod.NPCs.StormWeaver NPC.netAlways = true; NPC.dontCountMe = true; - if (BossRushEvent.BossRushActive) - NPC.scale *= 1.25f; - else if (CalamityWorld.death) + if (CalamityWorld.death || BossRushEvent.BossRushActive) NPC.scale *= 1.2f; else if (CalamityWorld.revenge) NPC.scale *= 1.15f; @@ -71,9 +72,6 @@ namespace CalamityMod.NPCs.StormWeaver NPC.scale *= 0.7f; NPC.Calamity().VulnerableToElectricity = false; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SendExtraAI(BinaryWriter writer) @@ -113,15 +111,14 @@ namespace CalamityMod.NPCs.StormWeaver if (NPC.life > Main.npc[(int)NPC.ai[1]].life) NPC.life = Main.npc[(int)NPC.ai[1]].life; - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; // Shed armor bool phase2 = NPC.life / (float)NPC.lifeMax < 0.8f; // Update armored settings to naked settings - if (phase2 && (!CalamityWorld.LegendaryMode || !CalamityWorld.revenge)) + if (phase2 && (!Main.zenithWorld || !CalamityWorld.revenge)) { // Spawn armor gore and set other crucial variables if (NPC.takenDamageMultiplier == 2f) @@ -149,12 +146,11 @@ namespace CalamityMod.NPCs.StormWeaver if (Main.netMode != NetmodeID.MultiplayerClient) { // Fire a lightning orb every 5 seconds - float spawnOrbGateValue = bossRush ? 200f : 300f; + float spawnOrbGateValue = 300f; if (Main.npc[(int)NPC.ai[2]].localAI[0] % spawnOrbGateValue == 0f) { int type = ProjectileID.CultistBossLightningOrb; - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, LightningOrbDamage, 0f, Main.myPlayer); } } } @@ -231,21 +227,6 @@ namespace CalamityMod.NPCs.StormWeaver else if (targetX > 0f) NPC.spriteDirection = 1; } - - // Calculate contact damage based on velocity - float velocity = (phase2 ? 12f : 10f) + (bossRush ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); - float minimalContactDamageVelocity = velocity * 0.25f; - float minimalDamageVelocity = velocity * 0.5f; - float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - NPC.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); - } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -257,18 +238,17 @@ namespace CalamityMod.NPCs.StormWeaver if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; - bool phase2 = lifeRatio < 0.8f && (!CalamityWorld.LegendaryMode || !revenge); + bool phase2 = lifeRatio < 0.8f && (!Main.zenithWorld || !revenge); bool phase3 = lifeRatio < 0.55f; // Gate value that decides when Storm Weaver will charge - float chargePhaseGateValue = bossRush ? 280f : death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; + float chargePhaseGateValue = death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; if (!phase3) chargePhaseGateValue *= 0.5f; @@ -302,23 +282,22 @@ namespace CalamityMod.NPCs.StormWeaver public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; float lifeRatio = NPC.life / (float)NPC.lifeMax; bool phase3 = lifeRatio < 0.55f; // Gate value that decides when Storm Weaver will charge - float chargePhaseGateValue = bossRush ? 280f : death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; + float chargePhaseGateValue = death ? 320f : revenge ? 340f : expertMode ? 360f : 400f; if (!phase3) chargePhaseGateValue *= 0.5f; - int buffDuration = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] >= chargePhaseGateValue ? 60 : 30; + int buffDuration = Main.npc[(int)NPC.ai[2]].Calamity().newAI[0] >= chargePhaseGateValue ? 240 : 120; if (hurtInfo.Damage > 0) - target.AddBuff(BuffID.Electrified, buffDuration, true); + target.AddBuff(BuffID.Electrified, buffDuration); } public override void HitEffect(NPC.HitInfo hit) @@ -371,7 +350,6 @@ namespace CalamityMod.NPCs.StormWeaver public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } } } diff --git a/NPCs/SulphurousSea/AnthozoanCrab.cs b/NPCs/SulphurousSea/AnthozoanCrab.cs index 2c4804bbdd..dc21b19b4f 100644 --- a/NPCs/SulphurousSea/AnthozoanCrab.cs +++ b/NPCs/SulphurousSea/AnthozoanCrab.cs @@ -38,9 +38,9 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.width = 56; NPC.height = 42; NPC.defense = 22; - NPC.lifeMax = 1130; + NPC.lifeMax = 900; NPC.aiStyle = AIType = -1; - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.value = Item.buyPrice(silver: 8); NPC.HitSound = SoundID.NPCHit38; NPC.DeathSound = SoundID.NPCDeath46; NPC.knockBackResist = 0.04f; @@ -51,10 +51,6 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/SulphurousSea/AquaticUrchin.cs b/NPCs/SulphurousSea/AquaticUrchin.cs index 6d911aa579..f794e7757a 100644 --- a/NPCs/SulphurousSea/AquaticUrchin.cs +++ b/NPCs/SulphurousSea/AquaticUrchin.cs @@ -29,9 +29,9 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.width = 20; NPC.height = 20; NPC.defense = 10; - NPC.lifeMax = Main.hardMode ? 380 : 70; + NPC.lifeMax = Main.hardMode ? 300 : 100; NPC.knockBackResist = 0.8f; - NPC.value = Item.buyPrice(0, 0, 3, 0); + NPC.value = Item.buyPrice(silver: 3); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath15; NPC.behindTiles = true; @@ -46,10 +46,6 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -134,7 +130,7 @@ namespace CalamityMod.NPCs.SulphurousSea public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 120); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/SulphurousSea/BelchingCoral.cs b/NPCs/SulphurousSea/BelchingCoral.cs index 4034dc9a41..597eded883 100644 --- a/NPCs/SulphurousSea/BelchingCoral.cs +++ b/NPCs/SulphurousSea/BelchingCoral.cs @@ -36,9 +36,9 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.width = 54; NPC.height = 42; NPC.defense = 25; - NPC.lifeMax = 1250; + NPC.lifeMax = 1000; NPC.aiStyle = AIType = -1; - NPC.value = Item.buyPrice(0, 0, 8, 0); + NPC.value = Item.buyPrice(silver: 8); NPC.HitSound = SoundID.NPCHit42; NPC.DeathSound = SoundID.NPCDeath5; NPC.knockBackResist = 0f; @@ -49,10 +49,6 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/SulphurousSea/Gnasher.cs b/NPCs/SulphurousSea/Gnasher.cs index 4c7bda3af5..893ea62786 100644 --- a/NPCs/SulphurousSea/Gnasher.cs +++ b/NPCs/SulphurousSea/Gnasher.cs @@ -3,7 +3,7 @@ using CalamityMod.BiomeManagers; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -28,17 +28,15 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetDefaults() { NPC.noGravity = true; - NPC.Calamity().canBreakPlayerDefense = true; NPC.damage = 25; NPC.width = 50; NPC.height = 36; NPC.defense = 30; - NPC.DR_NERD(0.15f); NPC.lifeMax = 50; NPC.knockBackResist = 0.25f; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 0, 60); + NPC.value = Item.buyPrice(copper: 60); NPC.HitSound = SoundID.NPCHit50; NPC.DeathSound = SoundID.NPCDeath54; NPC.chaseable = false; @@ -49,10 +47,6 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/SulphurousSea/Sulflounder.cs b/NPCs/SulphurousSea/Sulflounder.cs index fcf3f4e3d8..602c085d80 100644 --- a/NPCs/SulphurousSea/Sulflounder.cs +++ b/NPCs/SulphurousSea/Sulflounder.cs @@ -2,7 +2,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Potions; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -30,10 +30,10 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.width = 42; NPC.height = 32; NPC.defense = 15; - NPC.lifeMax = 50; + NPC.lifeMax = 60; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 0, 80); + NPC.value = Item.buyPrice(copper: 80); NPC.HitSound = SoundID.NPCHit50; NPC.DeathSound = SoundID.NPCDeath53; NPC.knockBackResist = 0.35f; @@ -45,10 +45,6 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/SulphurousSea/Toxicatfish.cs b/NPCs/SulphurousSea/Toxicatfish.cs index 70e1136ec5..ac3bda6439 100644 --- a/NPCs/SulphurousSea/Toxicatfish.cs +++ b/NPCs/SulphurousSea/Toxicatfish.cs @@ -2,7 +2,7 @@ using CalamityMod.BiomeManagers; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -28,10 +28,10 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.width = 98; NPC.height = 40; NPC.defense = 12; - NPC.lifeMax = 150; + NPC.lifeMax = 120; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath40; NPC.knockBackResist = 0.8f; @@ -43,10 +43,6 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[2] { ModContent.GetInstance().Type, ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/SulphurousSea/Trasher.cs b/NPCs/SulphurousSea/Trasher.cs index eb6d2b20c1..0d74458909 100644 --- a/NPCs/SulphurousSea/Trasher.cs +++ b/NPCs/SulphurousSea/Trasher.cs @@ -32,16 +32,15 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; NPC.noGravity = true; NPC.damage = 50; NPC.width = 150; NPC.height = 40; NPC.defense = 22; - NPC.lifeMax = 250; + NPC.lifeMax = 200; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 3, 0); + NPC.value = Item.buyPrice(silver: 3); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath5; NPC.knockBackResist = 0.15f; @@ -52,10 +51,6 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) diff --git a/NPCs/SunkenSea/AlphaSeaMinnow.cs b/NPCs/SunkenSea/AlphaSeaMinnow.cs index 58d3a2aeff..a427360771 100644 --- a/NPCs/SunkenSea/AlphaSeaMinnow.cs +++ b/NPCs/SunkenSea/AlphaSeaMinnow.cs @@ -1,29 +1,62 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Items.Placeables.Banners; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; using CalamityMod.Items.Critters; +using CalamityMod.Pathfinding; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; -using Terraria.DataStructures; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; namespace CalamityMod.NPCs.SunkenSea { - public class AlphaSeaMinnow : ModNPC + public class AlphaSeaMinnow : SunkenSeaNPC { + public enum PhaseType + { + Idle = 0, + Flee = 1 + } + + public ref float CurrentBehavior => ref NPC.ai[1]; + + public static int IdleRandomMovementUnlikeliness = 250; + public static int IdleMinPathDistance = 100; + public static int IdleMaxPathDistance = 1200; + + public static int FleeTileAnticipationDistance = 64; + + public Vector2 randomPathPoint; + + public bool instantiated = false; + + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List() { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs | SunkenSeaBiomeFlags.GleamingBurrows; + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 8; Main.npcCatchable[Type] = true; NPCID.Sets.CountsAsCritter[Type] = true; + base.SetStaticDefaults(); } public override void SetDefaults() { - NPC.npcSlots = 0.1f; + base.SetDefaults(); + NPC.npcSlots = 0.5f; NPC.noGravity = true; NPC.damage = 0; NPC.width = 40; @@ -36,9 +69,12 @@ namespace CalamityMod.NPCs.SunkenSea NPC.DeathSound = SoundID.NPCDeath1; //Banner = NPC.type; //BannerItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; NPC.chaseable = false; NPC.catchItem = (short)ModContent.ItemType(); - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -56,8 +92,15 @@ namespace CalamityMod.NPCs.SunkenSea { return; } + NPC.TargetClosest(false); // Spawn a shoal of minnows - int fishCount = Main.rand.Next(5, 10); + int fishCount = Main.rand.Next(2, 7); + // More spawn in the Radiant Reefs + if (NPC.HasPlayerTarget) + { + if (Main.player[NPC.target].Calamity().ZoneRadiantReefs) + fishCount += 3; + } for (int i = 0; i < fishCount; i++) { int goldchance = NPC.type == ModContent.NPCType() ? 20 : 50; @@ -69,87 +112,108 @@ namespace CalamityMod.NPCs.SunkenSea public override void AI() { - CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 2, 150f, 0.25f, 0.15f, 6f, 6f, 0.05f); - NPC.direction = NPC.velocity.X > 0 ? 1 : -1; - NPC.noGravity = true; - if (NPC.direction == 0) + if (pathfinding == null) { - NPC.TargetClosest(true); + pathfinding = new PathfindingManager(this); + Acceleration = 0.6f; + MaxSpeed = 4f; } if (NPC.wet) { - NPC.TargetClosest(false); - NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * 0.1f; - if (NPC.velocity.X < -2.5f || NPC.velocity.X > 2.5f) + switch (CurrentBehavior) { - NPC.velocity.X = NPC.velocity.X * 0.95f; - } - if (NPC.ai[0] == -1f) - { - NPC.velocity.Y = NPC.velocity.Y - 0.01f; - if ((double)NPC.velocity.Y < -0.3) - { - NPC.ai[0] = 1f; - } - } - else - { - NPC.velocity.Y = NPC.velocity.Y + 0.01f; - if ((double)NPC.velocity.Y > 0.3) - { - NPC.ai[0] = -1f; - } - } - int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) - { - if (Main.tile[npcTileX, npcTileY + 1].HasTile) - { - NPC.ai[0] = -1f; - } - else if (Main.tile[npcTileX, npcTileY + 2].HasTile) - { - NPC.ai[0] = -1f; - } - } - if ((double)NPC.velocity.Y > 0.4 || (double)NPC.velocity.Y < -0.4) - { - NPC.velocity.Y = NPC.velocity.Y * 0.95f; + case (int)PhaseType.Idle: + IdleBehavior(); + break; + case (int)PhaseType.Flee: + FleeBehavior(); + break; } } else { - if (NPC.velocity.Y == 0f) - { - NPC.velocity.X = NPC.velocity.X * 0.94f; - if ((double)NPC.velocity.X > -0.2 && (double)NPC.velocity.X < 0.2) - { - NPC.velocity.X = 0f; - } - } - NPC.velocity.Y = NPC.velocity.Y + 0.3f; - if (NPC.velocity.Y > 10f) - { - NPC.velocity.Y = 10f; - } - NPC.ai[0] = 1f; - } - NPC.rotation = NPC.velocity.X * 0.05f; - if ((double)NPC.rotation < -0.1) - { - NPC.rotation = -0.1f; - } - if ((double)NPC.rotation > 0.1) - { - NPC.rotation = 0.1f; + BeachedBehavior(); } + int dir = NPC.velocity.X.DirectionalSign(); + NPC.rotation = NPC.velocity.ToRotation() + (dir == 1 ? 0 : MathHelper.Pi); + NPC.spriteDirection = NPC.direction = dir; if (NPC.type == ModContent.NPCType()) { NPC.ProduceGoldCritterDust(); } } + public void IdleBehavior() + { + // At random, the mob will choose a random nearby point and pathfind there. + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.Next(IdleMinPathDistance, IdleMaxPathDistance), SunkenSeaTileValidity)); + } + + public void FleeBehavior() + { + // If the predator is gone, go back to idling. + if (CurrentPredator == null) + { + CurrentBehavior = (int)PhaseType.Idle; + MaxSpeed = 4f; + return; + } + + MaxSpeed = 8f; + + // While it doesn't have any obstacles in front of it, run away in a straight line. + // Try to manuever if there are any obstacles. + Point lookAheadPosition = (NPC.Center + NPC.DirectionFrom(CurrentPredator.Center) * FleeTileAnticipationDistance).ToTileCoordinates(); + if (!CalamityUtils.ParanoidTileRetrieval(lookAheadPosition.X, lookAheadPosition.Y).IsTileSolid()) + { + NPC.velocity += NPC.DirectionFrom(CurrentPredator.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, CurrentPredator.Center); + randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, randomPathPoint, SunkenSeaTileValidity)); + } + } + + public void BeachedBehavior() + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X = NPC.velocity.X * 0.94f; + if ((double)NPC.velocity.X > -0.2 && (double)NPC.velocity.X < 0.2) + { + NPC.velocity.X = 0f; + } + } + NPC.velocity.Y = NPC.velocity.Y + 0.3f; + if (NPC.velocity.Y > 10f) + { + NPC.velocity.Y = 10f; + } + NPC.ai[0] = 1f; + } + + protected override bool NPCSearchFilter(NPC n) + { + return base.NPCSearchFilter(n) || n == CurrentPredator && Vector2.DistanceSquared(NPC.Center, n.Center) < 960f * 960f; + } + + protected override bool PlayerSearchFilter(Player p) + { + return base.PlayerSearchFilter(p) || p == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, p.Center) < 960f * 960f; + } + protected override void OnPredatorDetection(NPC predator) + { + CurrentBehavior = (int)PhaseType.Flee; + } + public override void ModifyTypeName(ref string typeName) { // Holy mackerel is that an Ultrakill reference!?!? @@ -177,7 +241,11 @@ namespace CalamityMod.NPCs.SunkenSea { if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.CaveJellyfish.Chance * 0.6f; + if (spawnInfo.Player.Calamity().ZoneRadiantReefs) + return SpawnCondition.CaveJellyfish.Chance * 0.6f; + if (spawnInfo.Player.Calamity().ZoneGleamingBurrows) + return SpawnCondition.CaveJellyfish.Chance * 0.3f; + } return 0f; } @@ -186,36 +254,32 @@ namespace CalamityMod.NPCs.SunkenSea { for (int k = 0; k < 5; k++) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, 68, hit.HitDirection, -1f, 0, default, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); } + CalamityUtils.SpawnGores(NPC, "AlphaSeaMinnow", 2); + } + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(randomPathPoint); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + randomPathPoint = reader.ReadVector2(); } } public class AlphaSeaMinnowGold : AlphaSeaMinnow { public override void SetStaticDefaults() { - Main.npcFrameCount[Type] = 8; - Main.npcCatchable[Type] = true; - NPCID.Sets.CountsAsCritter[Type] = true; this.HideFromBestiary(); + base.SetStaticDefaults(); } public override void SetDefaults() { - NPC.npcSlots = 0.1f; - NPC.noGravity = true; - NPC.damage = 0; - NPC.width = 40; - NPC.height = 32; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.aiStyle = -1; - AIType = -1; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - //Banner = NPC.type; - //BannerItem = ModContent.ItemType(); - NPC.chaseable = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + base.SetDefaults(); NPC.rarity = 3; NPC.catchItem = ModContent.ItemType(); } @@ -224,7 +288,11 @@ namespace CalamityMod.NPCs.SunkenSea { if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.CaveJellyfish.Chance * 0.03f; + if (spawnInfo.Player.Calamity().ZoneRadiantReefs) + return SpawnCondition.CaveJellyfish.Chance * 0.2f; + if (spawnInfo.Player.Calamity().ZoneGleamingBurrows) + return SpawnCondition.CaveJellyfish.Chance * 0.05f; + } return 0f; } diff --git a/NPCs/SunkenSea/BabyGhostBell.cs b/NPCs/SunkenSea/BabyGhostBell.cs index bfa05e9ab3..8d45a19a5f 100644 --- a/NPCs/SunkenSea/BabyGhostBell.cs +++ b/NPCs/SunkenSea/BabyGhostBell.cs @@ -1,6 +1,7 @@ using System; +using System.Collections.Generic; using System.IO; -using CalamityMod.BiomeManagers; +using CalamityMod.Enums; using CalamityMod.Items.Accessories; using CalamityMod.Items.Critters; using CalamityMod.Items.Fishing.SunkenSeaCatches; @@ -20,37 +21,50 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.SunkenSea { - public class BabyGhostBell : ModNPC + public class BabyGhostBell : SunkenSeaNPC { public bool hasBeenHit = false; - public static Texture2D RadiantTexture; - public static Texture2D VoltaicTexture; - public static Texture2D RedTexture; - public static Texture2D GreenTexture; - public static Texture2D GoldTexture; + public static Asset RadiantTexture; + public static Asset VoltaicTexture; + public static Asset PinkTexture; + public static Asset GreenTexture; + public static Asset GoldTexture; public ref float Variant => ref NPC.ai[1]; public enum JellyColor { Blue = 0, Green = 1, - Red = 2, + Pink = 2, Radiant = 3, Voltaic = 4, Gold = 5 } - public static Asset GlowTexture; + /// + /// The squish of this NPC while drawing. + /// + private Vector2 ScaleSquish = Vector2.One; + + // keeps track of the number of hops between a flip + public int flipCounter; + + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List(); + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.GleamingBurrows; + + public override void Load() + { + RadiantTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellRadiant"); + VoltaicTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellVoltaic"); + GreenTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGreen"); + PinkTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellPink"); + GoldTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGold"); + } public override void SetStaticDefaults() { - if (!Main.dedServ) - { - RadiantTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellRadiant", AssetRequestMode.ImmediateLoad).Value; - VoltaicTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellVoltaic", AssetRequestMode.ImmediateLoad).Value; - GreenTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGreen", AssetRequestMode.ImmediateLoad).Value; - RedTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellRed", AssetRequestMode.ImmediateLoad).Value; - GoldTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGold", AssetRequestMode.ImmediateLoad).Value; - } Main.npcFrameCount[Type] = 6; Main.npcCatchable[Type] = true; NPCID.Sets.CountsAsCritter[Type] = true; @@ -61,6 +75,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.npcSlots = 0.1f; NPC.noGravity = true; NPC.chaseable = false; + NPC.dontTakeDamageFromHostiles = true; NPC.aiStyle = -1; AIType = -1; NPC.damage = 0; @@ -69,13 +84,12 @@ namespace CalamityMod.NPCs.SunkenSea NPC.defense = 0; NPC.lifeMax = 5; NPC.knockBackResist = 1f; - NPC.alpha = 100; + NPC.alpha = 75; NPC.HitSound = SoundID.NPCHit25; NPC.DeathSound = SoundID.NPCDeath28; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.catchItem = (short)ModContent.ItemType(); - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -105,7 +119,7 @@ namespace CalamityMod.NPCs.SunkenSea { return; } - Variant = Main.rand.Next(1, 4); + Variant = Main.rand.Next(0, 3); if (Main.rand.NextBool(30)) { Variant = (int)JellyColor.Radiant; @@ -126,8 +140,8 @@ namespace CalamityMod.NPCs.SunkenSea case (int)JellyColor.Green: NPC.catchItem = ModContent.ItemType(); break; - case (int)JellyColor.Red: - NPC.catchItem = ModContent.ItemType(); + case (int)JellyColor.Pink: + NPC.catchItem = ModContent.ItemType(); break; case (int)JellyColor.Radiant: { @@ -173,19 +187,58 @@ namespace CalamityMod.NPCs.SunkenSea Main.dust[dust].scale *= 0.5f; } } - // Quick lil hops in random directions for movement + + // Reset any squish that is done to the Ghost Bells, and clamps its upper limit to prevent it from becoming too tall + if (ScaleSquish.Y > 1f) + ScaleSquish.Y = MathHelper.Clamp(ScaleSquish.Y, 1f, 1.5f); + ScaleSquish.Y = Math.Max(1f, ScaleSquish.Y - 0.025f); + + // Quick lil hops in semi-random directions for movement. its thursday if (NPC.wet) { NPC.height = (int)(36 * NPC.scale); - if (NPC.velocity.Length() < 1f) + if (NPC.velocity.Length() < 0.5f) { - NPC.velocity = Main.rand.NextVector2CircularEdge(8, 8); + // stretch a bit for ~ effect ~ + ScaleSquish.Y += 0.4f; + + // get a semi-random float that is equivalent to +- X (normalised) degrees around the current rotation + float semiRandomAngle = Main.rand.NextFloat(-0.7f, 0.7f); + // multiply velocity by a random amount to break up cycles and appear more natural + NPC.velocity *= Main.rand.NextFloat(12f, 15f); + // check if the velocity lands itself into a tile + bool bonk = CalamityUtils.DistanceToTileCollisionHit(NPC.position, NPC.velocity, 9) != null; + + // random chance if the last direction flip was 3+ hops ago OR if the ghost bell is about to bonk a tile + if ((flipCounter >= 3 && Main.rand.NextBool(6)) || bonk) + { + // send it in the opposite direction + NPC.velocity *= -1; + NPC.velocity = NPC.velocity.RotatedBy(semiRandomAngle); + flipCounter = 0; // reset the counter + //Main.NewText("flip! " + flipCounter + " " + NPC.velocity + " " + NPC.rotation); + } + else + { + // send it in a random direction + NPC.velocity = NPC.velocity.RotatedBy(semiRandomAngle); + ++flipCounter; // add to the counter + //Main.NewText("swim, " + flipCounter + " " + NPC.velocity + " " + NPC.rotation); + } } NPC.velocity *= 0.95f; NPC.rotation = MathHelper.Lerp(NPC.rotation, NPC.velocity.ToRotation() + MathHelper.PiOver2, 0.5f); + + if (NPC.velocity == Vector2.Zero) + { + // failsafe. turns out they love getting themselves stuck in walls, so this is necessary to prevent that + NPC.velocity = Main.rand.NextVector2CircularEdge(8, 8); + } } else { + // wouldnt want it flipping back into the air immediately, would we? + flipCounter = 0; // Height is changed so that the jelly looks like it's actually laying on the ground when rotated NPC.height = (int)(24 * NPC.scale); // Gravy @@ -214,7 +267,7 @@ namespace CalamityMod.NPCs.SunkenSea Color lightColor = Color.LightBlue; // Voltaic uses the same light blue switch (Variant) { - case (int)JellyColor.Red: + case (int)JellyColor.Pink: lightColor = Color.Pink; break; case (int)JellyColor.Green: @@ -229,7 +282,18 @@ namespace CalamityMod.NPCs.SunkenSea if (Variant == (int)JellyColor.Gold) { NPC.ProduceGoldCritterDust(); - NPC.rarity = 3; + } + } + + public override void ModifyTypeName(ref string typeName) + { + if (Variant == (int)JellyColor.Radiant) + { + typeName = CalamityUtils.GetTextValue("NPCs.RadiantBabyGhostBell"); + } + if (Variant == (int)JellyColor.Gold) + { + typeName = CalamityUtils.GetTextValue("NPCs.GoldBabyGhostBell"); } } @@ -252,7 +316,7 @@ namespace CalamityMod.NPCs.SunkenSea public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + if (spawnInfo.Player.Calamity().ZoneGleamingBurrows && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { return SpawnCondition.CaveJellyfish.Chance * 1.5f; } @@ -264,8 +328,8 @@ namespace CalamityMod.NPCs.SunkenSea int dustType = DustID.BlueCrystalShard; switch (Variant) { - case (int)JellyColor.Red: - dustType = DustID.RedTorch; + case (int)JellyColor.Pink: + dustType = DustID.PinkTorch; break; case (int)JellyColor.Green: dustType = DustID.GemEmerald; @@ -295,27 +359,27 @@ namespace CalamityMod.NPCs.SunkenSea Texture2D texture = TextureAssets.Npc[Type].Value; switch (Variant) { - case (int)JellyColor.Red: - texture = RedTexture; + case (int)JellyColor.Pink: + texture = PinkTexture.Value; break; case (int)JellyColor.Green: - texture = GreenTexture; + texture = GreenTexture.Value; break; case (int)JellyColor.Radiant: - texture = RadiantTexture; + texture = RadiantTexture.Value; break; case (int)JellyColor.Voltaic: - texture = VoltaicTexture; + texture = VoltaicTexture.Value; break; case (int)JellyColor.Gold: - texture = GoldTexture; + texture = GoldTexture.Value; break; } Vector2 origin = new Vector2(texture.Width / 2, texture.Height / Main.npcFrameCount[Type] / 2); Vector2 npcOffset = NPC.Center - screenPos; npcOffset -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, npcOffset, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, npcOffset, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, origin, ScaleSquish, spriteEffects, 0f); return false; } diff --git a/NPCs/SunkenSea/BabyGhostBell.png b/NPCs/SunkenSea/BabyGhostBell.png index 083f1c0909..798cf525ee 100644 Binary files a/NPCs/SunkenSea/BabyGhostBell.png and b/NPCs/SunkenSea/BabyGhostBell.png differ diff --git a/NPCs/SunkenSea/BabyGhostBellGold.png b/NPCs/SunkenSea/BabyGhostBellGold.png index 6a1935feff..198d7a739d 100644 Binary files a/NPCs/SunkenSea/BabyGhostBellGold.png and b/NPCs/SunkenSea/BabyGhostBellGold.png differ diff --git a/NPCs/SunkenSea/BabyGhostBellGreen.png b/NPCs/SunkenSea/BabyGhostBellGreen.png index c2d4a7604e..aa7ee07608 100644 Binary files a/NPCs/SunkenSea/BabyGhostBellGreen.png and b/NPCs/SunkenSea/BabyGhostBellGreen.png differ diff --git a/NPCs/SunkenSea/BabyGhostBellPink.png b/NPCs/SunkenSea/BabyGhostBellPink.png new file mode 100644 index 0000000000..46093d1e35 Binary files /dev/null and b/NPCs/SunkenSea/BabyGhostBellPink.png differ diff --git a/NPCs/SunkenSea/BabyGhostBellRadiant.png b/NPCs/SunkenSea/BabyGhostBellRadiant.png index 932587a820..701a3c69bc 100644 Binary files a/NPCs/SunkenSea/BabyGhostBellRadiant.png and b/NPCs/SunkenSea/BabyGhostBellRadiant.png differ diff --git a/NPCs/SunkenSea/BabyGhostBellRed.png b/NPCs/SunkenSea/BabyGhostBellRed.png deleted file mode 100644 index 2e4dd1d457..0000000000 Binary files a/NPCs/SunkenSea/BabyGhostBellRed.png and /dev/null differ diff --git a/NPCs/SunkenSea/BabyGhostBellVoltaic.png b/NPCs/SunkenSea/BabyGhostBellVoltaic.png index f714e78a35..a0d92340e2 100644 Binary files a/NPCs/SunkenSea/BabyGhostBellVoltaic.png and b/NPCs/SunkenSea/BabyGhostBellVoltaic.png differ diff --git a/NPCs/SunkenSea/CarrionSwallower.cs b/NPCs/SunkenSea/CarrionSwallower.cs new file mode 100644 index 0000000000..73c9da2325 --- /dev/null +++ b/NPCs/SunkenSea/CarrionSwallower.cs @@ -0,0 +1,231 @@ +using System.IO; +using CalamityMod.BiomeManagers; +using CalamityMod.Dusts; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Enemy; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class CarrionSwallower : ModNPC + { + public ref float Timer => ref NPC.ai[0]; + public ref float AttackState => ref NPC.ai[1]; + public ref float ExtraTimer => ref NPC.ai[2]; + public ref float PusAmount => ref NPC.ai[3]; + + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 1; + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { PortraitPositionXOverride = 20f }; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + } + + public override void SetDefaults() + { + NPC.width = 50; + NPC.height = 42; + NPC.lifeMax = 65; + NPC.damage = 25; + NPC.defense = 0; + NPC.knockBackResist = 0f; + NPC.HitSound = SoundID.DD2_SkeletonHurt; + NPC.DeathSound = SoundID.DD2_SkeletonDeath; + NPC.noGravity = true; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.localAI[0]); + writer.Write(NPC.localAI[1]); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.localAI[0] = reader.ReadSingle(); + NPC.localAI[1] = reader.ReadSingle(); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange( + [ + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.CarrionSwallower") + ]); + } + + public override void AI() + { + NPC.TargetClosest(false); + Player target = Main.player[NPC.target]; + NPC.spriteDirection = NPC.direction; + + // Passive when first spawned + if (NPC.localAI[0] == 0f) + { + NPC.damage = 0; + PusAmount = 3; + NPC.velocity.X = 5f * NPC.direction; + if (NPC.velocity.X == 0f) + NPC.direction = -NPC.direction; + + // Attack if get too close + if (target.Distance(NPC.Center) < 320f) + { + NPC.localAI[0] = 1f; + NPC.netUpdate = true; + } + } + // Attacking + else + { + NPC.direction = (NPC.velocity.X > 0f).ToDirectionInt(); + Timer++; + // Sac full + if (AttackState == 0f) + { + NPC.damage = 0; + if (Timer < 180f || (target.Distance(NPC.Center) > 400f && ExtraTimer == 0f)) + { + Vector2 targetDirection = Utils.DirectionTo(NPC.Center, target.Center); + NPC.velocity = (NPC.velocity * 55f + targetDirection * 7f) / 56f; + } + else + { + ExtraTimer++; + NPC.velocity *= 0.975f; + // Fire pus at the player + if (ExtraTimer == 40f) + { + SoundEngine.PlaySound(SoundID.NPCHit10, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 spawn = NPC.Center + Vector2.UnitX * 13f * NPC.spriteDirection; + Projectile.NewProjectile(NPC.GetSource_FromThis(), spawn, Utils.DirectionTo(spawn, target.Center) * 10f, ModContent.ProjectileType(), 12, 0f, Main.myPlayer); + } + + Timer = 0f; + ExtraTimer = 0f; + // Starts with 3 shots, after firing them all the sac empties and it switches to charge mode + PusAmount--; + if (PusAmount == 0) + AttackState = 1f; + } + else // Dust telegraph + { + Vector2 dustSpawn = NPC.Center + Vector2.UnitX * 20f * NPC.direction * NPC.scale; + Vector2 dustVel = (Vector2.UnitX * 3f).RotatedByRandom(MathHelper.Pi / 6f) * Main.rand.NextBool().ToDirectionInt(); + Dust dust = Dust.NewDustPerfect(dustSpawn, ModContent.DustType(), dustVel, 100, Main.rand.NextBool() ? Color.Yellow : Color.DarkRed, 0.6f); + dust.noLightEmittence = true; + } + } + } + // Sac empty + else + { + if (Timer < 180f || (target.Distance(NPC.Center) > 320f && ExtraTimer == 0f)) + { + Vector2 targetDirection = Utils.DirectionTo(NPC.Center, target.Center); + NPC.velocity = (NPC.velocity * 40f + targetDirection * 10f) / 41f; + } + else + { + ExtraTimer++; + // Charge + if (ExtraTimer == 40f) + { + SoundEngine.PlaySound(SoundID.NPCHit6, NPC.Center); + NPC.damage = NPC.defDamage; + NPC.velocity = Utils.DirectionTo(NPC.Center, target.Center) * 13.5f; + + CustomPulse woosh = new(NPC.Center, Vector2.Zero, Color.DarkRed, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0.1f, 0.6f, 15); + GeneralParticleHandler.SpawnParticle(woosh); + } + else if (ExtraTimer < 40f) + { + Vector2 dustSpawn = NPC.Center + Main.rand.NextVector2CircularEdge(35f, 35f); + Vector2 dustVel = Utils.DirectionTo(dustSpawn, NPC.Center) * 4f + NPC.velocity * 0.75f; + Dust dust = Dust.NewDustPerfect(dustSpawn, ModContent.DustType(), dustVel, 100, Color.DarkRed, 0.6f); + dust.noLightEmittence = true; + } + + NPC.velocity *= ExtraTimer > 60f ? 0.96f : ExtraTimer < 40f ? 0.98f : 1f; + + // Reset + if (ExtraTimer == 70f) + { + NPC.damage = 0; + Timer = 0f; + ExtraTimer = 0f; + if (NPC.localAI[1] == 1f) + { + NPC.localAI[1] = 0f; + AttackState = 0f; + PusAmount = 3; + } + } + } + } + + if (NPC.velocity.X == 0f) + NPC.velocity.X = -NPC.oldVelocity.X * 0.7f; + if (NPC.velocity.Y == 0f) + NPC.velocity.Y = -NPC.oldVelocity.Y * 0.7f; + } + } + + public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) + { + // This code has to be run in ModifyHitPlayer because otherwise shields prevent it from working + // We don't have to check the AttackState because it only deals contact damage while ramming + // localAI[1] is used a temp set for filling with pus so that the current charge can finish before starting pus shooting mode + NPC.localAI[1] = 1f; + NPC.ForceNetUpdate(); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.Cavern.Chance * 0.4f; + } + return 0f; + } + + /*public override void FindFrame(int frameHeight) + { + base.FindFrame(frameHeight); + }*/ + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = TextureAssets.Npc[Type].Value; + // If in the bestiary or is buffering the pus fill from hitting a charge, draw the sac; otherwise it's based on AttackState + Rectangle frame = tex.Frame(2, 1, NPC.IsABestiaryIconDummy || NPC.localAI[1] == 1f ? 0 : (int)AttackState, NPC.frame.Y); + + spriteBatch.Draw(tex, NPC.Center - screenPos, frame, drawColor, NPC.rotation, frame.Size() / 2f, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + return false; + } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType(), 1, 1, 2); + } + + public override void HitEffect(NPC.HitInfo hit) + { + CalamityUtils.SpawnGores(NPC, "CarrionSwallower", 2); + } + } +} diff --git a/NPCs/SunkenSea/CarrionSwallower.png b/NPCs/SunkenSea/CarrionSwallower.png new file mode 100644 index 0000000000..da8e034106 Binary files /dev/null and b/NPCs/SunkenSea/CarrionSwallower.png differ diff --git a/NPCs/SunkenSea/Clam.cs b/NPCs/SunkenSea/Clam.cs index de57dfa6b1..d282fb35f8 100644 --- a/NPCs/SunkenSea/Clam.cs +++ b/NPCs/SunkenSea/Clam.cs @@ -3,7 +3,15 @@ using CalamityMod.BiomeManagers; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Enemy; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -12,9 +20,57 @@ namespace CalamityMod.NPCs.SunkenSea { public class Clam : ModNPC { - private int hitAmount = 0; - private bool hasBeenHit = false; - private bool statChange = false; + public enum PersonalityTypes + { + Reefs = 0, + Burrows = 1, + Den = 2 + } + + public enum PhaseType + { + Idle = 0, + Attacking = 1, + Squirt = 2, + Pod = 3 + } + + public Player Target => Main.player[NPC.target]; + + public ref float CurrentPhase => ref NPC.ai[0]; + + public ref float Timer => ref NPC.ai[1]; + + public ref float Personality => ref NPC.ai[3]; + + public ref float ShellRotation => ref NPC.localAI[0]; + + public int originalDamage; + + #region Textures + + public static Asset bottomJawTex; + + public static Asset bottomJawTexAlgae; + + public static Asset bottomJawTexCoral; + + public static Asset algaeTex; + + public static Asset coralTex; + + public static Asset backTex; + #endregion + + public override void Load() + { + backTex = ModContent.Request(Texture + "Back"); + bottomJawTex = ModContent.Request(Texture + "Bottom"); + bottomJawTexAlgae = ModContent.Request(Texture + "BottomAlgae"); + bottomJawTexCoral = ModContent.Request(Texture + "BottomCoral"); + algaeTex = ModContent.Request(Texture + "Algae"); + coralTex = ModContent.Request(Texture + "Coral"); + } public override void SetStaticDefaults() { @@ -28,11 +84,10 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetDefaults() { - NPC.damage = Main.hardMode ? 60 : 30; - NPC.width = 56; - NPC.height = 38; + originalDamage = NPC.damage = Main.hardMode ? 60 : 30; + NPC.width = 50; + NPC.height = 30; NPC.defense = 9999; - NPC.DR_NERD(0.25f); NPC.lifeMax = Main.hardMode ? 300 : 150; if (Main.expertMode) { @@ -40,20 +95,17 @@ namespace CalamityMod.NPCs.SunkenSea } NPC.aiStyle = -1; AIType = -1; - NPC.value = Main.hardMode ? Item.buyPrice(0, 0, 5, 0) : Item.buyPrice(0, 0, 1, 0); + NPC.value = Main.hardMode ? Item.buyPrice(silver: 5) : Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit4; - NPC.knockBackResist = 0.05f; + NPC.knockBackResist = 0; Banner = NPC.type; BannerItem = ModContent.ItemType(); + NPC.GravityIgnoresLiquid = true; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); + SpawnModBiomes = new int[3] { ModContent.GetInstance().Type, ModContent.GetInstance().Type, ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -66,122 +118,272 @@ namespace CalamityMod.NPCs.SunkenSea public override void SendExtraAI(BinaryWriter writer) { - writer.Write(hitAmount); - writer.Write(NPC.chaseable); - writer.Write(hasBeenHit); - writer.Write(statChange); + writer.Write(NPC.localAI[0]); + writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); } public override void ReceiveExtraAI(BinaryReader reader) { - hitAmount = reader.ReadInt32(); - NPC.chaseable = reader.ReadBoolean(); - hasBeenHit = reader.ReadBoolean(); - statChange = reader.ReadBoolean(); + NPC.localAI[0] = reader.ReadSingle(); + NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + } + + public override void OnSpawn(IEntitySource source) + { + NPC.TargetClosest(); + + NPC.direction = Main.rand.NextBool().ToDirectionInt(); + NPC.localAI[1] = Main.rand.Next(0, 4); + + if (Target.Calamity().ZoneClamDen) + Personality = (int)PersonalityTypes.Den; + else if (Target.Calamity().ZoneGleamingBurrows) + Personality = (int)PersonalityTypes.Burrows; + else + Personality = (int)PersonalityTypes.Reefs; } public override void AI() { - NPC.TargetClosest(true); + // Rotation at its peak + float maxRotation = MathHelper.ToRadians(60); + NPC.TargetClosest(false); + // Always be mad during Clamity if (Main.player[NPC.target].Calamity().clamity) { - hitAmount = 3; - hasBeenHit = true; + Personality = (int)PersonalityTypes.Burrows; } - if (NPC.justHit && hitAmount < 3) + switch (CurrentPhase) { - ++hitAmount; - hasBeenHit = true; - } - NPC.chaseable = hasBeenHit; - if (hitAmount == 3) - { - if (!statChange) - { - NPC.defense = Main.hardMode ? 15 : 6; - NPC.damage = NPC.defDamage; - statChange = true; - } - if (NPC.ai[0] == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (NPC.velocity.X != 0f || NPC.velocity.Y < 0f || (double)NPC.velocity.Y > 0.9) - { - NPC.ai[0] = 1f; - NPC.netUpdate = true; - return; - } - NPC.ai[0] = 1f; - NPC.netUpdate = true; - return; - } - } - else if (NPC.velocity.Y == 0f) - { - NPC.ai[2] += 1f; - int decelerationTimer = 20; - if (NPC.ai[1] == 0f) - { - decelerationTimer = 12; - } - if (NPC.ai[2] < (float)decelerationTimer) + case (int)PhaseType.Idle: { + NPC.damage = 0; + NPC.chaseable = false; NPC.velocity.X *= 0.9f; - return; - } - NPC.ai[2] = 0f; - NPC.TargetClosest(true); - if (NPC.direction == 0) - { - NPC.direction = -1; - } - NPC.spriteDirection = -NPC.direction; - NPC.ai[1] += 1f; - NPC.ai[3] += 1f; - if (NPC.ai[3] >= 4f) - { - NPC.ai[3] = 0f; - if (NPC.ai[1] == 2f) + if (ShellRotation > 0) { - float multiplierX = (float)Main.rand.Next(3, 7); - NPC.velocity.X = (float)NPC.direction * multiplierX; - NPC.velocity.Y = -8f; - NPC.ai[1] = 0f; + ShellRotation -= 0.2f; + if (ShellRotation < 0) + ShellRotation = 0; + } + else if (ShellRotation < 0) + { + ShellRotation += 0.03f; + if (ShellRotation > 0) + { + ShellRotation = 0; + } + } + switch (Personality) + { + // Aggro immediately + case (int)PersonalityTypes.Den: + { + ChangePhase((int)PhaseType.Attacking); + } + break; + // Aggro if the player is near + case (int)PersonalityTypes.Burrows: + { + if (Target.Distance(NPC.Center) < 600 && NPC.HasSight(Target.Center)) + { + ChangePhase((int)PhaseType.Attacking); + } + } + break; + // Aggro if hurt + default: + { + if (NPC.life < (NPC.lifeMax - 2)) + { + ChangePhase((int)PhaseType.Attacking); + } + } + break; + } + } + break; + case (int)PhaseType.Attacking: + { + NPC.damage = 0; + NPC.knockBackResist = 0.05f; + NPC.defense = Main.hardMode ? 15 : 6; + NPC.chaseable = true; + Timer++; + if (NPC.velocity.Y == 0) + { + NPC.direction = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + NPC.velocity.X = 0; + NPC.ai[2]++; + if (NPC.ai[2] > Main.rand.Next(30, 60)) + { + NPC.velocity.Y = -4; + NPC.velocity.X = NPC.direction * 6; + NPC.ai[2] = 0; + } } else { - float multiplierX = (float)Main.rand.Next(5, 9); - NPC.velocity.X = (float)NPC.direction * multiplierX; - NPC.velocity.Y = -4f; + NPC.damage = originalDamage; + + if (NPC.velocity.Y < 0) + { + ShellRotation += 0.065f; + if (ShellRotation > maxRotation) + ShellRotation = maxRotation; + } + NPC.velocity.X *= 0.99f; + } + + if (NPC.position.Distance(NPC.oldPosition) < 8 && NPC.velocity.Y >= 0) + { + ShellRotation -= 0.065f; + if (ShellRotation < 0) + ShellRotation = 0; + } + + // Squirt + if (Timer > Main.rand.Next(220, 260) && NPC.HasSight(Target.Center) && ShellRotation == 0) + { + ChangePhase((int)PhaseType.Squirt); + NPC.direction = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + } + NPC.StepUpBlocks(); + } + break; + case (int)PhaseType.Squirt: + { + NPC.damage = 0; + NPC.chaseable = true; + // Slow down. Once the clam is rested, start incrementing Timer + if (NPC.velocity.Y == 0) + { + NPC.velocity.X *= 0.8f; + // Set ai[2] to 1 + NPC.ai[2] = 1; + } + + // Increment Timer is ai[2] is 1 + if (NPC.ai[2] == 1) + { + Timer++; + } + + // When to start opening + float startOpen = 30; + // When to end opening + float endOpen = startOpen + 30; + // When to start closing + float startClose = endOpen + 20; + // When to stop closing + float endClose = startClose + 5; + // When to go to the next attack + float reset = endClose + 60; + + // Direction the player is relative to the clam + int playerPosition = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + + // Shell animation + if (Timer >= startOpen && Timer <= endOpen) + { + ShellRotation = (float)Utils.AngleLerp(0, maxRotation, CalamityUtils.SineOutEasing(Utils.GetLerpValue(startOpen, endOpen, Timer, true), 0)); + } + else if (Timer >= startClose && Timer <= endClose) + { + ShellRotation = (float)Utils.AngleLerp(maxRotation, 0, CalamityUtils.SineOutEasing(Utils.GetLerpValue(startClose, endClose, Timer, true), 0)); + } + + // Fire the projectile + if (Timer == (endClose - 5)) + { + NPC.damage = originalDamage; + Vector2 velocity = NPC.SafeDirectionTo(Target.Center, Vector2.UnitY) * 5; + + // If the player is on the other side of the clam, flip the jet so that it doesn't fire backwards + if (playerPosition != NPC.direction) + velocity.X *= -1; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, velocity, ModContent.ProjectileType(), Main.hardMode ? 30 : 15, 1); + } + for (int i = 0; i < 9; i++) + { + GenericBubbleParticle waterFlavored = new GenericBubbleParticle(NPC.Center, Main.rand.NextFloat(16, 22) * velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(-45, 45))), Main.rand.NextFloat(0.3f, 0.5f), Main.rand.NextFloat(-4, 4), 5); + waterFlavored.AffectedByLight = true; + GeneralParticleHandler.SpawnParticle(waterFlavored); + } + + SoundEngine.PlaySound((Main.rand.NextBool(2) ? SoundID.Item85 : SoundID.Item86).WithPitchOffset(-0.5f), NPC.Center); + SoundEngine.PlaySound(SoundID.NPCDeath14.WithPitchOffset(1f), NPC.Center); + } + + // Go back to melee + if (Timer >= reset) + { + ChangePhase((int)PhaseType.Attacking); } } - NPC.netUpdate = true; - return; - } - else - { - if (NPC.direction == 1 && NPC.velocity.X < 1f) + break; + case (int)PhaseType.Pod: { - NPC.velocity.X = NPC.velocity.X + 0.1f; - return; + NPC.damage = 0; + + NPC.chaseable = true; + NPC pod = Main.npc[(int)NPC.localAI[2] - 1]; + // If the Pearlpod is invalid, go back to idling + if (pod == null || !pod.active || pod.life < 0 || pod.ModNPC == null || pod.ModNPC is not Pearlpod) + { + NPC.localAI[2] = 0; + ChangePhase((int)PhaseType.Idle); + } + else + { + // Face towards the Pearlpod while it's still out + if (pod.Opacity == 1) + NPC.direction = NPC.DirectionTo(pod.Center).X.DirectionalSign(); + // Start closing when the Pearlpod is nearby + if (pod.Distance(NPC.Center) > 30) + { + ShellRotation += 0.05f; + if (ShellRotation > maxRotation) + ShellRotation = maxRotation; + } + // Otherwise open up! + else + { + ShellRotation -= 0.2f; + if (ShellRotation < -0.2f) + ShellRotation = -0.2f; + } + } } - if (NPC.direction == -1 && NPC.velocity.X > -1f) - { - NPC.velocity.X = NPC.velocity.X - 0.1f; - return; - } - } + break; } - else - NPC.damage = 0; + NPC.spriteDirection = NPC.direction; + } + + public void ChangePhase(int phaseNum, bool resetai2 = true) + { + CurrentPhase = phaseNum; + Timer = 0; + if (resetai2) + NPC.ai[2] = 0; + NPC.netUpdate = true; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + return CurrentPhase > 0; } public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) { - return hasBeenHit; + return CurrentPhase > 0; } return null; } @@ -194,7 +396,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.frameCounter = 0.0; NPC.frame.Y = NPC.frame.Y + frameHeight; } - if (hitAmount < 3) + if (CurrentPhase == 0) { NPC.frame.Y = frameHeight * 4; } @@ -209,9 +411,16 @@ namespace CalamityMod.NPCs.SunkenSea public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water) + if (spawnInfo.Water) { - return SpawnCondition.CaveJellyfish.Chance * 1.2f; + if (spawnInfo.Player.Calamity().ZoneRadiantReefs) + return SpawnCondition.CaveJellyfish.Chance * 0.8f; + + if (spawnInfo.Player.Calamity().ZoneGleamingBurrows) + return SpawnCondition.CaveJellyfish.Chance * 1f; + + if (spawnInfo.Player.Calamity().ZoneClamDen) + return SpawnCondition.CaveJellyfish.Chance * 1.2f; } return 0f; } @@ -228,12 +437,14 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Obsidian, hit.HitDirection, -1f, 0, default, 1f); } - if (!Main.dedServ) + string name = NPC.localAI[1] switch { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("Clam1").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("Clam2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("Clam3").Type, 1f); - } + 1 => "ClamAlgae", + 2 => "ClamCoral", + _ => "Clam" + }; + + CalamityUtils.SpawnGores(NPC, name, 2); } } @@ -245,5 +456,42 @@ namespace CalamityMod.NPCs.SunkenSea npcLoot.Add(ItemID.PinkPearl, 40); npcLoot.AddIf(() => Main.hardMode, ModContent.ItemType(), 2); } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + Texture2D jaw = bottomJawTex.Value; + + switch (NPC.localAI[1]) + { + case 1: + { + tex = algaeTex.Value; + jaw = bottomJawTexAlgae.Value; + } + break; + case 2: + { + tex = coralTex.Value; + jaw = bottomJawTexCoral.Value; + } + break; + } + + Vector2 drawOffset = Vector2.UnitY * 8; + Vector2 topDrawOffset = drawOffset + new Vector2(NPC.spriteDirection * -22, -3); + bool facingRight = NPC.spriteDirection == 1; + if (facingRight) + { + topDrawOffset.X += 6; + } + Vector2 backOffset = topDrawOffset; + float trueShellRotation = ShellRotation * -NPC.spriteDirection; + if (ShellRotation == 0) + spriteBatch.Draw(backTex.Value, NPC.Center - screenPos + backOffset, null, NPC.GetAlpha(drawColor), NPC.rotation, new Vector2(facingRight ? 0 : tex.Width, tex.Height), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(tex, NPC.Center - screenPos + topDrawOffset, null, NPC.GetAlpha(drawColor), trueShellRotation, new Vector2(facingRight ? 0 : tex.Width, tex.Height), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(jaw, NPC.Center - screenPos + drawOffset, null, NPC.GetAlpha(drawColor), NPC.rotation, tex.Size() / 2, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + return false; + } } } diff --git a/NPCs/SunkenSea/Clam.png b/NPCs/SunkenSea/Clam.png index f7eb5f074a..acb6f0dd51 100644 Binary files a/NPCs/SunkenSea/Clam.png and b/NPCs/SunkenSea/Clam.png differ diff --git a/NPCs/SunkenSea/ClamAlgae.png b/NPCs/SunkenSea/ClamAlgae.png new file mode 100644 index 0000000000..e695d282f8 Binary files /dev/null and b/NPCs/SunkenSea/ClamAlgae.png differ diff --git a/NPCs/SunkenSea/ClamBack.png b/NPCs/SunkenSea/ClamBack.png new file mode 100644 index 0000000000..7eec13a3b9 Binary files /dev/null and b/NPCs/SunkenSea/ClamBack.png differ diff --git a/NPCs/SunkenSea/ClamBottom.png b/NPCs/SunkenSea/ClamBottom.png new file mode 100644 index 0000000000..3d9a5ddeeb Binary files /dev/null and b/NPCs/SunkenSea/ClamBottom.png differ diff --git a/NPCs/SunkenSea/ClamBottomAlgae.png b/NPCs/SunkenSea/ClamBottomAlgae.png new file mode 100644 index 0000000000..c3f133e6c0 Binary files /dev/null and b/NPCs/SunkenSea/ClamBottomAlgae.png differ diff --git a/NPCs/SunkenSea/ClamBottomCoral.png b/NPCs/SunkenSea/ClamBottomCoral.png new file mode 100644 index 0000000000..103aaa2e63 Binary files /dev/null and b/NPCs/SunkenSea/ClamBottomCoral.png differ diff --git a/NPCs/SunkenSea/ClamCoral.png b/NPCs/SunkenSea/ClamCoral.png new file mode 100644 index 0000000000..aad2819891 Binary files /dev/null and b/NPCs/SunkenSea/ClamCoral.png differ diff --git a/NPCs/SunkenSea/EutrophicRay.cs b/NPCs/SunkenSea/EutrophicRay.cs index 48e4ebabed..ec0d742125 100644 --- a/NPCs/SunkenSea/EutrophicRay.cs +++ b/NPCs/SunkenSea/EutrophicRay.cs @@ -1,61 +1,95 @@ -using System.IO; -using CalamityMod.BiomeManagers; +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Pathfinding; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.DataStructures; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; + namespace CalamityMod.NPCs.SunkenSea { - public class EutrophicRay : ModNPC + public class EutrophicRay : SunkenSeaNPC { - public bool hasBeenHit = false; - public static Asset GlowTexture; + public static Asset TailTexture; + public static Asset TailGlowTexture; + #region Fields + protected override List PreyIDs => []; + protected override List PredatorIDs => + [ + ModContent.NPCType(), + ModContent.NPCType(), + //ModContent.NPCType(), + //ModContent.NPCType() + ]; + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs | SunkenSeaBiomeFlags.GleamingBurrows; + + private bool hasBeenHit = false; + private bool shouldAttack => NPC.life < (int)(NPC.lifeMax * 0.6f); + private Entity AttackingEntity; + private Entity AvoidedEntity; + private Action _currentBehavior; + private Action CurrentBehavior + { + get => _currentBehavior; + set + { + if (value != _currentBehavior) + OnBehaviorChange(value); + _previousBehavior = _currentBehavior; + _currentBehavior = value; + } + } + private Action _previousBehavior; + #endregion + + public override void Load() + { + GlowTexture = ModContent.Request(Texture + "Glow"); + TailTexture = ModContent.Request(Texture + "Tail"); + TailGlowTexture = ModContent.Request(Texture + "TailGlow"); + } public override void SetStaticDefaults() { - Main.npcFrameCount[Type] = 5; - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers(); - value.Position.X += 24f; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } + Main.npcFrameCount[Type] = 7; + NPCID.Sets.TrailingMode[Type] = 3; + NPCID.Sets.TrailCacheLength[Type] = 15; + base.SetStaticDefaults(); } public override void SetDefaults() { - NPC.damage = Main.hardMode ? 50 : 20; - NPC.width = 116; - NPC.height = 36; - NPC.defense = Main.hardMode ? 15 : 5; - NPC.DR_NERD(0.05f); - NPC.lifeMax = Main.hardMode ? 500 : 150; - NPC.aiStyle = -1; - AIType = -1; - NPC.value = Main.hardMode ? Item.buyPrice(0, 0, 5, 0) : Item.buyPrice(0, 0, 1, 0); + base.SetDefaults(); + NPC.width = 54; + NPC.height = 68; + NPC.damage = 20; + NPC.defense = 5; + NPC.lifeMax = 200; + NPC.scale = 0.85f; + + NPC.noGravity = true; + NPC.noTileCollide = false; + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath55; NPC.knockBackResist = 0.5f; + Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -71,171 +105,295 @@ namespace CalamityMod.NPCs.SunkenSea writer.Write(NPC.chaseable); writer.Write(hasBeenHit); } - public override void ReceiveExtraAI(BinaryReader reader) { NPC.chaseable = reader.ReadBoolean(); hasBeenHit = reader.ReadBoolean(); } + public override void OnSpawn(IEntitySource source) + { + pathfinding = new PathfindingManager(this); + MaxSpeed = 4.85f; + Acceleration = 0.5f; + CurrentBehavior = IdleBehavior; + } + + #region AI Functions public override void AI() { - NPC.TargetClosest(true); - if (NPC.velocity.X > 0.25f) + if (pathfinding == null) { - NPC.spriteDirection = 1; - } - else if (NPC.velocity.X < 0.25f) - { - NPC.spriteDirection = -1; + pathfinding = new PathfindingManager(this); + MaxSpeed = 4.85f; + Acceleration = 0.5f; } + CurrentBehavior?.Invoke(); + + // If out of water, act like you're out of water. + if ((NPC.noTileCollide ? !(Collision.WetCollision(NPC.position, NPC.width, NPC.height) || Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) : !NPC.wet) && CurrentBehavior != OutOfWaterBehavior) + CurrentBehavior = OutOfWaterBehavior; + + // Used for determining if it should run from players. if (NPC.justHit && !hasBeenHit) - { hasBeenHit = true; - NPC.damage = NPC.defDamage; - NPC.noTileCollide = true; - NPC.noGravity = true; - if (NPC.Center.X < Main.player[NPC.target].Center.X) - { - NPC.ai[0] = 1f; - } - else - { - NPC.ai[0] = 2f; - } - } NPC.chaseable = hasBeenHit; - if (hasBeenHit) + + float curRot = NPC.rotation; + float newRot = NPC.velocity.ToRotation() + MathHelper.Pi; + if (Math.Abs(MathHelper.WrapAngle(curRot) - MathHelper.WrapAngle(newRot)) > MathHelper.PiOver4) { - float AccelerationY = Main.hardMode ? 0.4f : 0.2f; - float MaxSpeedY = Main.hardMode ? 4f : 2.5f; - float Rotation = 0; - if ((NPC.Center.Y + 0.4f) > Main.player[NPC.target].Center.Y) - { - NPC.velocity.Y -= AccelerationY; - if (NPC.velocity.Y < -MaxSpeedY) - { - NPC.velocity.Y = -MaxSpeedY; - } - } - else if ((NPC.Center.Y - 0.4f) < Main.player[NPC.target].Center.Y) - { - NPC.velocity.Y += AccelerationY; - if (NPC.velocity.Y > MaxSpeedY) - { - NPC.velocity.Y = MaxSpeedY; - } - } - float AccelerationX = Main.hardMode ? 0.4f : 0.25f; - float MaxSpeedX = Main.hardMode ? 6f : 4f; - - if (NPC.ai[0] == 1f) - { - Rotation = -0.05f; - NPC.velocity.X -= AccelerationX; - if (NPC.velocity.X < -MaxSpeedX) - { - NPC.velocity.X = -MaxSpeedX; - } - - if ((NPC.Center.X + 300f) < Main.player[NPC.target].Center.X) - { - NPC.ai[0] = 2f; - } - } - else if (NPC.ai[0] == 2f) - { - Rotation = 0.05f; - NPC.velocity.X += AccelerationX; - if (NPC.velocity.X > MaxSpeedX) - { - NPC.velocity.X = MaxSpeedX; - } - - if ((NPC.Center.X - 300f) > Main.player[NPC.target].Center.X) - { - NPC.ai[0] = 1f; - } - } - - NPC.rotation = NPC.velocity.Y * Rotation; - if (NPC.rotation < -0.1f) - { - NPC.rotation = -0.1f; - } - if (NPC.rotation > 0.1f) - { - NPC.rotation = 0.1f; - return; - } + NPC.rotation = Utils.AngleLerp(curRot, newRot, 0.1f); } else - NPC.damage = 0; + { + NPC.rotation = newRot; + } } + private void OnBehaviorChange(Action newBehavior) + { + if (newBehavior == OutOfWaterBehavior) + NPC.noGravity = false; + + MaxSpeed = newBehavior == FleeBehavior ? 6.5f : 5f; + } + + private void IdleBehavior() + { + // Don't deal damage while idling. + NPC.damage = 0; + // If inside solid tiles, attempt to get out of them by occasionally bursting in a random direction. + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + if (Main.rand.NextBool(150)) + NPC.velocity = Main.rand.NextVector2CircularEdge(7.5f, 7.5f); + + NPC.velocity *= 0.98f; + } + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(200f, 800f), SunkenSeaTileValidity)); + } + private void AttackBehavior() + { + // Check what specifically the hunted entity is. If there is none, go back to idling. + AttackingEntity = AttackingEntity is NPC ? CurrentPrey : CurrentPlayer; + if (AttackingEntity == null) + { + CurrentBehavior = IdleBehavior; + return; + } + + // Set damage while attacking. Clear idle behavior pathfinding to prevent it continuously trying to return to that path when attacking. + NPC.damage = NPC.defDamage; + pathfinding.ClearResults(); + NPC.noTileCollide = true; + + float maxSpeedX = 8.2f; + float maxSpeedY = 3.2f; + float accelX = 0.25f; + float accelY = 0.3f; + int directionX = (NPC.Center.X < AttackingEntity.Center.X).ToDirectionInt(); + int directionY = (NPC.Center.Y < AttackingEntity.Center.Y).ToDirectionInt(); + + NPC.velocity.X += accelX * directionX; + if (NPC.velocity.X > maxSpeedX) + NPC.velocity.X = maxSpeedX; + if (NPC.velocity.X < -maxSpeedX) + NPC.velocity.X = -maxSpeedX; + + NPC.velocity.Y += accelY * directionY; + if (NPC.velocity.Y > maxSpeedY) + NPC.velocity.Y = maxSpeedY; + if (NPC.velocity.Y < -maxSpeedY) + NPC.velocity.Y = -maxSpeedY; + } + private void FleeBehavior() + { + // Check what specifically the predator is. If there is none, go back to idling. + AvoidedEntity = AvoidedEntity is NPC ? CurrentPredator : CurrentPlayer; + if (AvoidedEntity == null) + { + CurrentBehavior = IdleBehavior; + return; + } + + // If you reach the attack threshold, start attacking. + if (shouldAttack && AvoidedEntity is Player) + { + CurrentBehavior = AttackBehavior; + AttackingEntity = AvoidedEntity; + AvoidedEntity = null; + return; + } + + // Don't deal damage while fleeing. + NPC.damage = 0; + NPC.noTileCollide = true; + + // Flee in a straight line if possible, otherwise pathfind away from the attacker. + if (!Main.tile[(NPC.Center + NPC.DirectionFrom(AvoidedEntity.Center) * 64f).ToTileCoordinates()].IsTileSolid()) + { + NPC.velocity += NPC.DirectionFrom(AvoidedEntity.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, AvoidedEntity.Center); + Vector2 pathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, pathPoint, SunkenSeaTileValidity)); + } + } + private void OutOfWaterBehavior() + { + NPC.damage = 0; + NPC.velocity.X *= 0.985f; + if (NPC.noTileCollide ? (Collision.WetCollision(NPC.position, NPC.width, NPC.height) || Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) : NPC.wet) + { + NPC.noGravity = true; + CurrentBehavior = _previousBehavior; + } + } + #endregion + + #region Creature Detection and Hit Logic + protected override bool PlayerSearchFilter(Player p) => (Vector2.DistanceSquared(NPC.Center, p.Center) < 262144f && hasBeenHit) || shouldAttack; + protected override bool NPCSearchFilter(NPC n) => Vector2.DistanceSquared(NPC.Center, n.Center) < 102400f && (PreyIDs.Contains(n.type) || PredatorIDs.Contains(n.type)); + protected override void OnPreyDetection(NPC prey) + { + if (CurrentPredator is not null) + { + CurrentBehavior = AttackBehavior; + NPC.noTileCollide = true; + AttackingEntity = prey; + } + } + public override bool CanHitNPC(NPC target) => PreyIDs.Contains(target.type); + protected override void OnPredatorDetection(NPC predator) + { + CurrentBehavior = FleeBehavior; + NPC.noTileCollide = false; + AvoidedEntity = predator; + } + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + protected override void OnPlayerDetection(Player player) + { + if (CurrentPredator is not null && !hasBeenHit) + return; + + if (shouldAttack) + { + CurrentBehavior = AttackBehavior; + AttackingEntity = player; + } + else if (hasBeenHit) + { + CurrentBehavior = FleeBehavior; + AvoidedEntity = player; + } + NPC.noTileCollide = shouldAttack; + } + #endregion public override void FindFrame(int frameHeight) { - NPC.frameCounter += (hasBeenHit || NPC.IsABestiaryIconDummy) ? 0.15f : 0f; + NPC.frameCounter += 0.15f; NPC.frameCounter %= Main.npcFrameCount[Type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2)); - Vector2 vector = center - screenPos; - vector -= new Vector2((float)GlowTexture.Value.Width, (float)(GlowTexture.Value.Height / Main.npcFrameCount[Type])) * 1f / 2f; - vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); - Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); - Main.spriteBatch.Draw(GlowTexture.Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); - } + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + Vector2 halfSizeTexture = new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[Type]); + Vector2 vector = NPC.Center - screenPos; + Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0); + spriteBatch.Draw(tex, vector, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, 0, 0f); + spriteBatch.Draw(GlowTexture.Value, vector, NPC.frame, color, NPC.rotation, halfSizeTexture, NPC.scale, 0, 0f); - public override bool? CanBeHitByProjectile(Projectile projectile) - { - if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) + // Position where the tail starts + Vector2 tailOffset = Vector2.UnitX.RotatedBy(NPC.rotation) * (tex.Width / 2 - 4); + + if (NPC.IsABestiaryIconDummy) { - return hasBeenHit; + for (int i = 0; i < NPC.oldRot.Length; i++) + { + NPC.oldRot[i] = 0; + } + for (int i = 0; i < NPC.oldPos.Length; i++) + { + NPC.oldPos[i] = Vector2.UnitX.RotatedBy(NPC.rotation) * ((tex.Width / 2 - 4) + i * 8); + } } - return null; + + float currentSegmentRotation = NPC.rotation; + List tailDrawPositions = new List(); + int segAmt = 7; + int tailLength = 40; + for (int i = 0; i < segAmt; i++) + { + float tailCompletionRatio = i / (float)segAmt; + float wrappedAngularOffset = MathHelper.WrapAngle(NPC.oldRot[i + 1] - currentSegmentRotation) * 0.6f; + float segmentRotationOffset = MathHelper.Clamp(wrappedAngularOffset, -0.24f, 0.24f); + + Vector2 Offset = Vector2.UnitX.RotatedBy(NPC.rotation); + Vector2 tailSegmentOffset = Vector2.UnitX.RotatedBy(currentSegmentRotation) * tailCompletionRatio * tailLength + Offset; + tailDrawPositions.Add(NPC.Center + tailSegmentOffset + tailOffset); + + currentSegmentRotation += segmentRotationOffset; + } + for (int i = 0; i < tailDrawPositions.Count; i++) + { + Vector2 pos = tailDrawPositions[i]; + float rot = pos.DirectionTo(NPC.Center + Vector2.UnitX.RotatedBy(NPC.rotation)).ToRotation(); + if (i > 0) + { + Vector2 oldPos = tailDrawPositions[i - 1]; + rot = pos.DirectionTo(oldPos).ToRotation(); + } + int frame = i switch + { + 1 => 10, + 5 => 20, + 6 => 32, + _ => 0 + }; + int height = 8; + if (i == 6) + height = 10; + rot += MathHelper.PiOver2; + + spriteBatch.Draw(TailTexture.Value, pos - screenPos, new Rectangle(0, frame, 10, height), NPC.GetAlpha(drawColor), rot, new Vector2(6, 4), NPC.scale, 0, 0f); + spriteBatch.Draw(TailGlowTexture.Value, pos - screenPos, new Rectangle(0, frame, 10, height), color, rot, new Vector2(6, 4), NPC.scale, 0, 0f); + } + + return false; } public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + if (spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.CaveJellyfish.Chance * 0.6f; + if (spawnInfo.Player.Calamity().ZoneRadiantReefs || spawnInfo.Player.Calamity().ZoneGleamingBurrows) + return SpawnCondition.CaveJellyfish.Chance * 0.6f; } return 0f; } public override void HitEffect(NPC.HitInfo hit) { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); - } if (NPC.life <= 0) { - for (int k = 0; k < 25; k++) + for (int k = 0; k < 15; k++) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); } - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("RayGore1").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("RayGore2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("RayGore3").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("RayGore4").Type, 1f); - } } + CalamityUtils.SpawnGores(NPC, "EutrophicRay", 2); } } } diff --git a/NPCs/SunkenSea/EutrophicRay.png b/NPCs/SunkenSea/EutrophicRay.png index f005213289..76f3c10590 100644 Binary files a/NPCs/SunkenSea/EutrophicRay.png and b/NPCs/SunkenSea/EutrophicRay.png differ diff --git a/NPCs/SunkenSea/EutrophicRayGlow.png b/NPCs/SunkenSea/EutrophicRayGlow.png index 585d222148..805039ba34 100644 Binary files a/NPCs/SunkenSea/EutrophicRayGlow.png and b/NPCs/SunkenSea/EutrophicRayGlow.png differ diff --git a/NPCs/SunkenSea/EutrophicRayTail.png b/NPCs/SunkenSea/EutrophicRayTail.png new file mode 100644 index 0000000000..f15d72f500 Binary files /dev/null and b/NPCs/SunkenSea/EutrophicRayTail.png differ diff --git a/NPCs/SunkenSea/EutrophicRayTailGlow.png b/NPCs/SunkenSea/EutrophicRayTailGlow.png new file mode 100644 index 0000000000..3c7ef2ce64 Binary files /dev/null and b/NPCs/SunkenSea/EutrophicRayTailGlow.png differ diff --git a/NPCs/SunkenSea/FesteringRemains.cs b/NPCs/SunkenSea/FesteringRemains.cs index 72137b1c30..68c0df7862 100644 --- a/NPCs/SunkenSea/FesteringRemains.cs +++ b/NPCs/SunkenSea/FesteringRemains.cs @@ -1,6 +1,5 @@ using CalamityMod.BiomeManagers; using CalamityMod.Particles; -using CalamityMod.Items.Placeables.Banners; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; @@ -11,6 +10,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; using System.IO; +using CalamityMod.Items.Materials; namespace CalamityMod.NPCs.SunkenSea { @@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.SunkenSea //Banner = NPC.type; //BannerItem = ModContent.ItemType(); NPC.chaseable = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -72,7 +72,7 @@ namespace CalamityMod.NPCs.SunkenSea bonePos = NPC.Center + new Vector2(Main.rand.Next(-extraDistX, extraDistX + 1), Main.rand.Next(-extraDistY, extraDistY + 1)); } } - Particle bone = new ChumBone(bonePos, Vector2.Zero, NPC.GetAlpha(Color.White), Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4), Main.rand.NextFloat(0.8f, 1.6f), 4, Main.rand.NextBool(), Main.rand.NextBool()); + Particle bone = new ChumBone(bonePos, Vector2.Zero, NPC.GetAlpha(Color.White), Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4), Main.rand.NextFloat(0.8f, 1.6f), 4, Main.rand.NextBool()); GeneralParticleHandler.SpawnParticle(bone); // Add to a list of bones bones.Add(bone); @@ -142,7 +142,7 @@ namespace CalamityMod.NPCs.SunkenSea { if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.Cavern.Chance * 0.6f; + return SpawnCondition.Cavern.Chance * 0.4f; } return 0f; } @@ -157,6 +157,7 @@ namespace CalamityMod.NPCs.SunkenSea { SoundEngine.PlaySound(SoundID.DD2_SkeletonHurt with { Volume = 0.8f, Pitch = 1.2f }, NPC.position); } + CalamityUtils.SpawnGores(NPC, "FesteringRemains", 1); } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -179,5 +180,9 @@ namespace CalamityMod.NPCs.SunkenSea } return true; } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType(), 1, 1, 2); + } } } diff --git a/NPCs/SunkenSea/GhostBell.cs b/NPCs/SunkenSea/GhostBell.cs index 156617ae6c..501570c573 100644 --- a/NPCs/SunkenSea/GhostBell.cs +++ b/NPCs/SunkenSea/GhostBell.cs @@ -1,12 +1,18 @@ -using System.IO; -using CalamityMod.BiomeManagers; +using System; +using System.Collections.Generic; +using System.IO; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.DataStructures; +using CalamityMod.Enums; using CalamityMod.Items.Accessories; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Pathfinding; +using CalamityMod.Projectiles.Enemy; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.DataStructures; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; @@ -16,34 +22,77 @@ using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.SunkenSea { - public class GhostBell : ModNPC + public class GhostBell : SunkenSeaNPC { - public bool hasBeenHit = false; + public static Asset PinkTexture; + public static Asset GreenTexture; - public static Asset GlowTexture; + public static int ElectrifyingPhaseDuration => 180; + public static int ElectrifyingPhaseDischarge => 60; + public static int ElectrifyingPhaseCooldown => 120; + + public ref float Phase => ref NPC.ai[0]; + + public ref float Variant => ref NPC.ai[1]; + + public ref float Timer => ref NPC.ai[3]; + + public enum PhaseType + { + Idle = 0, + Angry = 1, + Electrifying = 2 + } + + public enum JellyColor + { + Blue = 0, + Green = 1, + Pink = 2 + } + + public List> tentacles = []; + + protected override List PreyIDs => + [ + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ]; + + protected override List PredatorIDs => []; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.GleamingBurrows | SunkenSeaBiomeFlags.PolypForest; + + public override void Load() + { + GreenTexture = ModContent.Request(Texture + "Green"); + PinkTexture = ModContent.Request(Texture + "Pink"); + } public override void SetStaticDefaults() { - Main.npcFrameCount[Type] = 6; - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } + base.SetStaticDefaults(); + Main.npcFrameCount[Type] = 1; } public override void SetDefaults() { + base.SetDefaults(); NPC.noGravity = true; NPC.aiStyle = -1; AIType = -1; - NPC.damage = Main.hardMode ? 75 : 25; - NPC.width = 54; - NPC.height = 76; - NPC.defense = Main.hardMode ? 10 : 0; - NPC.lifeMax = Main.hardMode ? 400 : 120; + NPC.damage = 25; + NPC.width = 74; + NPC.height = 58; + NPC.defense = 0; + NPC.lifeMax = 120; NPC.knockBackResist = 0f; NPC.alpha = 100; - NPC.value = Main.hardMode ? Item.buyPrice(0, 0, 5, 0) : Item.buyPrice(0, 0, 1, 0); + NPC.value = Item.buyPrice(silver: 1); NPC.HitSound = SoundID.NPCHit25; NPC.DeathSound = SoundID.NPCDeath28; Banner = NPC.type; @@ -52,11 +101,6 @@ namespace CalamityMod.NPCs.SunkenSea NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = false; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -70,112 +114,390 @@ namespace CalamityMod.NPCs.SunkenSea public override void SendExtraAI(BinaryWriter writer) { writer.Write(NPC.chaseable); - writer.Write(hasBeenHit); } public override void ReceiveExtraAI(BinaryReader reader) { NPC.chaseable = reader.ReadBoolean(); - hasBeenHit = reader.ReadBoolean(); + } + + public override void OnSpawn(IEntitySource source) + { + NPC.TargetClosest(); + Variant = Main.rand.Next(0, 3); + if (Phase == (int)PhaseType.Idle) + { + // 1-3 in the Polyp Forest, 3-4 in the burrows + int jellyAmt = Main.player[NPC.target].Calamity().ZonePolypForest ? Main.rand.Next(2, 4) : Main.rand.Next(3, 5); + // A swarm of babies spawns if the jelly is in the Polyp Forest + if (Main.player[NPC.target].Calamity().ZonePolypForest) + { + for (int i = 0; i < jellyAmt; i++) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int bebe = NPC.NewNPC(NPC.GetSource_FromThis(), (int)(NPC.Center.X + Main.rand.NextFloat(1f, 2f)), (int)(NPC.Center.Y + Main.rand.NextFloat(1f, 2f)), ModContent.NPCType(), ai0: -1); + Main.npc[bebe].rotation = Main.rand.NextFloat(0, MathHelper.TwoPi); + } + } + } + // Spawn more adults + for (int i = 0; i < jellyAmt; i++) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromThis(), (int)(NPC.Center.X + Main.rand.NextFloat(1f, 2f)), (int)(NPC.Center.Y + Main.rand.NextFloat(1f, 2f)), Type, ai0: -1, ai2: Main.rand.Next(0, 60)); + } + } + } } public override void AI() { - Lighting.AddLight(NPC.Center, 0f, (255 - NPC.alpha) * 1.5f / 255f, (255 - NPC.alpha) * 1.5f / 255f); - if (NPC.justHit) + if (pathfinding == null) { - hasBeenHit = true; + pathfinding = new PathfindingManager(this); + Acceleration = 0.1f; + MaxSpeed = 1f; } - NPC.chaseable = hasBeenHit; - if (NPC.localAI[0] == 0f) + CreateTentacles(); + NPC.ai[2]++; + + // Lite + var lightColor = Variant switch { - NPC.localAI[0] = 1f; - NPC.velocity.Y = -6f; - NPC.netUpdate = true; + (int)JellyColor.Pink => Color.LightPink, + (int)JellyColor.Green => Color.MediumSpringGreen, + _ => Color.LightBlue, + }; + Lighting.AddLight(NPC.Center, (lightColor.R - NPC.alpha) * 1f / 255f, (lightColor.G - NPC.alpha) * 1f / 255f, (lightColor.B - NPC.alpha) * 1f / 255f); + + NPC.chaseable = Phase > 0; + NPC.noGravity = NPC.wet; + + NPC.netUpdate = true; + NPC.netSpam = 0; + + Entity target = CurrentPrey; + if (NPC.target > -1 && (int)Phase >= (int)PhaseType.Angry) + { + target = Main.player[NPC.target]; } - if (NPC.wet) + + // Ghost Bells are usually in groups, so make them not overlap + float SAImovement = 0.05f; + for (int k = 0; k < Main.maxNPCs; k++) { - NPC.noGravity = true; - if (NPC.localAI[2] > 0f) + NPC otherFish = Main.npc[k]; + // Short circuits to make the loop as fast as possible + if (!otherFish.active || k == NPC.whoAmI || otherFish.type != ModContent.NPCType()) + continue; + + float taxicabDist = Math.Abs(NPC.position.X - otherFish.position.X) + Math.Abs(NPC.position.Y - otherFish.position.Y); + if (taxicabDist < NPC.width * 2f) { - NPC.localAI[2] -= 1f; - } - if (NPC.localAI[2] <= 0f) - { - if (NPC.velocity.Y == 0f) - { - NPC.localAI[1] += 1f; - } + if (NPC.position.X < otherFish.position.X) + NPC.velocity.X -= SAImovement; else - { - NPC.localAI[1] = 0f; - } - NPC.velocity.Y += 0.1f; - if (NPC.velocity.Y > 3f || NPC.localAI[1] >= 6f) - { - NPC.velocity.Y = -3f; - } + NPC.velocity.X += SAImovement; + + if (NPC.position.Y < otherFish.position.Y) + NPC.velocity.Y -= SAImovement; + else + NPC.velocity.Y += SAImovement; } } - else + + if (Phase <= (int)PhaseType.Idle) { - NPC.noGravity = false; - NPC.velocity.Y = 2f; - NPC.localAI[2] = 75f; + NPC.velocity *= 0.8f; + } + + if (target == null || !target.active || target.Distance(NPC.Center) > 1000) + { + Timer = 0; + Phase = (int)PhaseType.Idle; NPC.netUpdate = true; + return; + } + + // Create an electrifying aura + if (Phase == (int)PhaseType.Electrifying) + { + // Slow down + NPC.velocity *= 0.9f; + pathfinding.ClearResults(); + Timer++; + // Create the aura + if (NPC.ai[3] == 1) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 12, 0, ai1: NPC.whoAmI + 1); + } + } + // Reset + if (Timer >= ElectrifyingPhaseDuration) + { + Timer = -ElectrifyingPhaseCooldown; + Phase = (int)PhaseType.Angry; + NPC.netUpdate = true; + } + } + // Move towards target + else if (target != null) + { + pathfinding.DoPathfinding(new PathfindingParameters(this, NPC.Center, target.Center, SunkenSeaTileValiditySizeless)); + if (pathfinding.Path.Count > 0) + if (pathfinding.Path[^1].Distance(target.Center) > 300) + { + pathfinding.ClearResults(); + } + if (Phase == (int)PhaseType.Angry) + { + if (target is Player && NPC.Distance(target.Center) < 300) + { + Timer++; + } + if (Timer > 120) + { + Timer = 0; + Phase = (int)PhaseType.Electrifying; + NPC.netUpdate = true; + } + } } } - public override void FindFrame(int frameHeight) + public void CreateTentacles() { - NPC.frameCounter += 0.1f; - NPC.frameCounter %= Main.npcFrameCount[Type]; - int frame = (int)NPC.frameCounter; - NPC.frame.Y = frame * frameHeight; + if (tentacles == null || tentacles.Count < 6) + { + // switches between tentacle indexes to determine how many segments should be on each + // aims for a more squid-like distribution, i dont know if it applies to jellyfish too + + // an embarrassing amount of time was spent figuring out these numbers + // i forgot they start at 0.. + int segmentCount = tentacles.Count switch + { + 0 or 5 => 9, + 1 or 4 => 12, + _ => 8 + }; + List segments = new List(segmentCount); + for (int i = 0; i < segmentCount; i++) + { + VerletSimulatedSegment segment = new VerletSimulatedSegment(NPC.Center - Vector2.UnitY * i * 5); + segments.Add(segment); + } + segments[0].locked = true; + tentacles.Add(segments); + } + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) + { + GetPissed(player.whoAmI); + } + + public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) + { + if (projectile.friendly && projectile.owner > -1) + { + GetPissed(projectile.owner); + } + } + + public void GetPissed(int player) + { + if (Phase <= (int)PhaseType.Idle) + { + Phase = (int)PhaseType.Angry; + NPC.netUpdate = true; + } + NPC.target = player; + + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type != Type) + continue; + if (n.Distance(NPC.Center) > 400) + continue; + if (n.ModNPC().Phase <= (int)PhaseType.Idle) + n.ModNPC().GetPissed(player); + } } public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + if (spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.CaveJellyfish.Chance * 0.9f; + if (spawnInfo.Player.Calamity().ZonePolypForest) + return SpawnCondition.CaveJellyfish.Chance * 0.5f; + if (spawnInfo.Player.Calamity().ZoneGleamingBurrows) + return SpawnCondition.CaveJellyfish.Chance * 0.3f; + } return 0f; } - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + public override void FindFrame(int frameHeight) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) + // For bestiary animation + if (NPC.IsABestiaryIconDummy) { - spriteEffects = SpriteEffects.FlipHorizontally; + NPC.ai[2]++; } - Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2)); - Vector2 vector = center - screenPos; - vector -= new Vector2((float)GlowTexture.Value.Width, (float)(GlowTexture.Value.Height / Main.npcFrameCount[Type])) * 1f / 2f; - vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); - Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); - Main.spriteBatch.Draw(GlowTexture.Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } - // Can only hit the target if they're touching the tentacles - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - Vector2 npcCenter = NPC.Center; - Rectangle tentacleHitbox = new Rectangle((int)(npcCenter.X - (NPC.width / 4f)), (int)npcCenter.Y, NPC.width / 2, NPC.height / 2); + // Underlying tentacle colour based on parent colour + Color baseCol = Variant switch + { // all of these colours are from the sprites but slightly darkened and desaturated + (int)JellyColor.Green => new Color(29, 54, 39), // 27, 61, 40 + (int)JellyColor.Pink => new Color(79, 39, 53), // 97, 38, 60 + _ => new Color(34, 50, 89) // 36, 55, 114 + }; + // Accent color is also based on parent color + Color col = Variant switch + { // these are also directly from the sprites, with no modifications; similar in luminance for visual consistency + (int)JellyColor.Green => new Color(59, 215, 194), + (int)JellyColor.Pink => new Color(255, 145, 238), + _ => new Color(84, 215, 254) + }; - Rectangle targetHitbox = target.Hitbox; - bool insideTentacleHitbox = targetHitbox.Intersects(tentacleHitbox); + Vector2 drawOffset = Vector2.Zero; // An added offset that gives the jellyfish a visual bobbing movement - return insideTentacleHitbox; + int fullTime = 180; // How long the bob animation lasts + int localTimer = (int)(NPC.ai[2] % fullTime); + float goUp = (int)(fullTime * 0.4f); // When should the jellyfish jet upwards + int height = 30; // The vertical range the jellyfish moves + + int endElectricity = 60; + + Vector2 squash = new Vector2(1.1f, 0.9f); + Vector2 stretch = new Vector2(0.8f, 1.2f); + Vector2 finalScale; + + // Move up and down while squashing and stretching + if (localTimer < goUp) + { + drawOffset.Y += MathHelper.Lerp(height, 0, CalamityUtils.CircOutEasing(Utils.GetLerpValue(0, goUp - 1, localTimer, true), 1)); + finalScale = Vector2.Lerp(stretch, squash, CalamityUtils.CircOutEasing(Utils.GetLerpValue(0, goUp - 1, localTimer, true), 1)); + } + else + { + drawOffset.Y += MathHelper.Lerp(0, height, CalamityUtils.SineInEasing(Utils.GetLerpValue(goUp, fullTime - 1, localTimer, true), 1)); + finalScale = Vector2.Lerp(squash, stretch, CalamityUtils.SineInEasing(Utils.GetLerpValue(goUp, fullTime - 1, localTimer, true), 1)); + } + // Use different squash n stretch when electrifying + if (Phase == (int)PhaseType.Electrifying) + { + squash = new Vector2(1.4f, 0.8f); + if (Timer < (ElectrifyingPhaseDuration - 80)) + finalScale = Vector2.Lerp(Vector2.One, squash, CalamityUtils.CircOutEasing(Utils.GetLerpValue(0, ElectrifyingPhaseDischarge, Timer, true), 1)); + else + finalScale = Vector2.Lerp(squash, Vector2.One, CalamityUtils.SineInEasing(Utils.GetLerpValue(endElectricity, ElectrifyingPhaseDuration, Timer, true), 1)); + } + // Keeps the hitbox centered + drawOffset.Y -= height / 2; + + if (NPC.IsABestiaryIconDummy) + { + drawOffset.Y -= 20; + } + + CreateTentacles(); + + // Update the chains + for (int i = 0; i < tentacles.Count; i++) + { + List segments = tentacles[i]; + + segments[0].oldPosition = segments[0].position; + segments[0].position = NPC.Center + new Vector2(MathHelper.Lerp(-20, 20, (i + 1) / (float)tentacles.Count), 10) + drawOffset; + + // While electrifying, flail tentacles around frantically + if (Phase == (int)PhaseType.Electrifying && Timer % 5 == 0 && Timer < endElectricity) + { + for (int j = 0; j < segments.Count; j++) + { + int randomness = (int)MathHelper.Lerp(6, 18, (1 + j) / segments.Count); + segments[j].oldPosition = segments[j].position; + segments[j].position += Main.rand.NextVector2Circular(randomness, randomness); + } + } + tentacles[i] = VerletSimulatedSegment.SimpleSimulation(segments, 5, loops: 1, gravity: 0.6f); + } + + // Draw tentacle chains + for (int t = 0; t < tentacles.Count; t++) + { + List segments = tentacles[t]; + for (int i = 0; i < segments.Count - 1; i++) + { + VerletSimulatedSegment seg = segments[i]; + float dist = i > 0 ? Vector2.Distance(seg.position, segments[i - 1].position) : 0; + if (dist <= 2) + dist = 2; + dist += 4; + if (i == segments.Count - 1) + { + dist = Vector2.Distance(seg.position, NPC.Center) + 2; + } + float rot = 0f; + if (i > 0) + rot = seg.position.DirectionTo(segments[i - 1].position).ToRotation(); + + // slight gradient to a lighter colour the higher the segment index + Color finalColor = baseCol; + finalColor *= 1 + (i * 0.15f); + + // Last few segments are way brighter + if (i > segments.Count - 3) + { + finalColor = col * (0.05f + segments.Count * 0.1f); + } + + // Color eases in and out while angry + if (Phase == (int)PhaseType.Angry || NPC.IsABestiaryIconDummy) + { + float mod = NPC.ai[2] % 30; + if (mod <= 10) + finalColor = Color.Lerp(finalColor, finalColor * 2, Utils.GetLerpValue(0, 10, mod, true)); + else if (mod >= 20) + finalColor = Color.Lerp(finalColor * 2, finalColor, Utils.GetLerpValue(20, 30, mod, true)); + else + finalColor *= 2; + } + // Color is at full brightness while electrifying + else if (Phase == (int)PhaseType.Electrifying) + finalColor *= 2; + // give the segments variable width (and an offset equal to half of the variance) to create more visual interest + // a side effect of this makes it look wiggly like some jellyfish tentacles are + SpriteEffects dir = NPC.Center.X > NPC.Center.X ? SpriteEffects.FlipVertically : SpriteEffects.None; + spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Vector2(seg.position.X - i * 0.1f, seg.position.Y) - screenPos, new Rectangle(0, 0, (int)(3 + i * 0.2), 8), finalColor, rot + MathHelper.PiOver2, new Vector2(4, 4), new Vector2(1, dist / 8), dir, 0); + } + } + + Texture2D tex = Variant switch + { + (int)JellyColor.Pink => PinkTexture.Value, + (int)JellyColor.Green => GreenTexture.Value, + _ => TextureAssets.Npc[Type].Value + }; + + Main.EntitySpriteDraw(tex, NPC.Center - screenPos + drawOffset, null, Color.White, NPC.rotation, tex.Size() / 2, finalScale * NPC.scale, 0); + return false; } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); + target.AddBuff(ModContent.BuffType(), 120); } public override void HitEffect(NPC.HitInfo hit) @@ -195,7 +517,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void ModifyNPCLoot(NPCLoot npcLoot) { - npcLoot.Add(ItemID.JellyfishNecklace, 100); + npcLoot.Add(ItemID.JellyfishNecklace, 30); LeadingConditionRule postDS = npcLoot.DefineConditionalDropSet(DropHelper.PostDS()); postDS.Add(ModContent.ItemType(), 5); } diff --git a/NPCs/SunkenSea/GhostBell.png b/NPCs/SunkenSea/GhostBell.png index 0a9a975802..8af8c6e258 100644 Binary files a/NPCs/SunkenSea/GhostBell.png and b/NPCs/SunkenSea/GhostBell.png differ diff --git a/NPCs/SunkenSea/GhostBellGlow.png b/NPCs/SunkenSea/GhostBellGlow.png deleted file mode 100644 index 0a9a975802..0000000000 Binary files a/NPCs/SunkenSea/GhostBellGlow.png and /dev/null differ diff --git a/NPCs/SunkenSea/GhostBellGreen.png b/NPCs/SunkenSea/GhostBellGreen.png new file mode 100644 index 0000000000..025fed69f0 Binary files /dev/null and b/NPCs/SunkenSea/GhostBellGreen.png differ diff --git a/NPCs/SunkenSea/GhostBellPink.png b/NPCs/SunkenSea/GhostBellPink.png new file mode 100644 index 0000000000..063a71e0d1 Binary files /dev/null and b/NPCs/SunkenSea/GhostBellPink.png differ diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index 664d6123eb..d22a59ec8c 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using CalamityMod.BiomeManagers; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Accessories; @@ -13,7 +12,6 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Enemy; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -66,11 +64,10 @@ namespace CalamityMod.NPCs.SunkenSea NPC.width = 160; NPC.height = 120; NPC.defense = 9999; - NPC.DR_NERD(0.3f); NPC.lifeMax = Main.hardMode ? 7500 : 1250; NPC.aiStyle = -1; AIType = -1; - NPC.value = Main.hardMode ? Item.buyPrice(0, 5, 0, 0) : Item.buyPrice(0, 1, 0, 0); + NPC.value = Main.hardMode ? Item.buyPrice(gold: 5) : Item.buyPrice(gold: 1); NPC.HitSound = SoundID.NPCHit4; NPC.knockBackResist = 0f; NPC.rarity = 2; @@ -78,11 +75,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -132,6 +125,12 @@ namespace CalamityMod.NPCs.SunkenSea hasBeenHit = true; } + if (!hasBeenHit) + { + // No contact damage while chillaxing + NPC.damage = 0; + } + NPC.chaseable = hasBeenHit; if (hitAmount == 5) diff --git a/NPCs/SunkenSea/GildedAxolotl.cs b/NPCs/SunkenSea/GildedAxolotl.cs new file mode 100644 index 0000000000..1808f03f64 --- /dev/null +++ b/NPCs/SunkenSea/GildedAxolotl.cs @@ -0,0 +1,589 @@ +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.BiomeManagers; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Dusts; +using CalamityMod.Enums; +using CalamityMod.Items.Critters; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Particles; +using CalamityMod.Pathfinding; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class GildedAxolotl : SunkenSeaNPC + { + private enum AnimationState { Water, Land } + private AnimationState Animation + { + get => (AnimationState)NPC.ai[1]; + set + { + if (value != Animation) + { + NPC.frame.Y = 0; + NPC.frameCounter = 0; + } + + NPC.ai[1] = (float)value; + } + } + + private enum PhaseType { Idle = 0, Flee = 1, Hunt = 2 } + public ref float CurrentBehavior => ref NPC.ai[0]; + public ref float GroundMovementTimer => ref NPC.ai[2]; + + public Vector2 targetPoint; + + public int IdleMinPathDistance = 400; + public int IdleMaxPathDistance = 1800; + public float FleeMaxSpeed = 8; + public float HuntMaxSpeed = 6; + public float IdleMaxSpeed = 3.2f; + + // Delays for effects triggering again after being executed + private int FleeFXCooldown = 300; + public int FleeTimer = 0; + private int PassiveSoundCooldown = 240; + public int PassiveSoundTimer = 0; + private int NoticeHeldItemSoundCooldown = 180; + public int NoticeHeldItemSoundTimer = 0; + + public bool PathfindToPlayer = false; + + public float auraFade = 0; + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + public override bool CanHitNPC(NPC target) => PreyIDs.Contains(target.type); + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public static readonly SoundStyle noticedBaitSound = new("CalamityMod/Sounds/Custom/GildedAxolotlNeuronActivation"); + public static readonly SoundStyle ambientNoise = new("CalamityMod/Sounds/Custom/GildedAxolotlVocalStim", 2); + public static readonly SoundStyle alert = new("CalamityMod/Sounds/Custom/GildedAxolotlAlert"); + + #region SunkenSea Fields + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs; + protected override List PreyIDs => new() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + + protected override List PredatorIDs => new() + { + ModContent.NPCType(), + ModContent.NPCType(), + // ModContent.NPCType(), + // ModContent.NPCType() + }; + + #endregion + + protected List ItemsOfInterest => new() + { + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() + }; + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + Main.npcFrameCount[Type] = 7; + NPCID.Sets.CountsAsCritter[Type] = true; + Main.npcCatchable[Type] = true; + } + + public override void SetDefaults() + { + base.SetDefaults(); + + NPC.aiStyle = -1; + NPC.width = 84; + NPC.height = 42; + + NPC.damage = 7; + NPC.defense = 7; + NPC.lifeMax = 77; + NPC.knockBackResist = 0f; + NPC.lavaImmune = true; + NPC.noGravity = true; + NPC.noTileCollide = false; + NPC.GravityIgnoresLiquid = true; + NPC.chaseable = false; + + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath9; + + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + + NPC.catchItem = ModContent.ItemType(); + + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToElectricity = false; + NPC.Calamity().VulnerableToWater = false; + NPC.Calamity().VulnerableToCold = true; + + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + #region Syncing + + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.ai[0] = reader.ReadSingle(); // CurrentBehavior + NPC.ai[1] = reader.ReadSingle(); // Anim state + NPC.ai[2] = reader.ReadSingle(); // Ground movement timer + targetPoint = reader.ReadVector2(); // For pathfinding points + auraFade = reader.ReadSingle(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.ai[0]); // CurrentBehavior + writer.Write(NPC.ai[1]); // Anim state + writer.Write(NPC.ai[2]); // Ground movement timer + writer.WriteVector2(targetPoint); // For pathfinding points + writer.Write(auraFade); + } + + #endregion + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.GildedAxolotl") + }); + } + + public override void AI() + { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.4f; + MaxSpeed = IdleMaxSpeed; + MinimumPointDistance = 60f; + } + + // Find nearby players + NPC.TargetClosest(false); + Player nearestPlayer = null; + float nearestPlayerDistance = 10000f; + + float detectionRange = 700f; + float buffRange = 290f; + + Player nearestPlayerForVisuals = null; + float nearestPlayerDistanceForVisuals = 10000f; + + // Handle aura buff for any nearby player + for (int i = 0; i < Main.maxPlayers; i++) + { + Player p = Main.player[i]; + if (!p.active || p.dead) + continue; + + float distance = Vector2.Distance(NPC.Center, p.Center); + + if (distance < buffRange && distance < nearestPlayerDistanceForVisuals) + { + nearestPlayerForVisuals = p; + nearestPlayerDistanceForVisuals = distance; + } + + if (distance < buffRange) + { + p.AddBuff(ModContent.BuffType(), 60, true); + } + + // Track the nearest player holding a target item + if (distance < detectionRange && ItemsOfInterest.Contains(p.HeldItem.type)) + { + if (distance < nearestPlayerDistance) + { + nearestPlayer = p; + nearestPlayerDistance = distance; + } + } + } + + // Handle aura vfx + float distanceForVisual = nearestPlayerForVisuals != null ? nearestPlayerDistanceForVisuals : buffRange; + float maxDistance = buffRange * 1.5f; + float minDistance = 120f; + auraFade = Utils.GetLerpValue(maxDistance, minDistance, distanceForVisual, clamped: true); + + // Allow NPCs to be buffed while in the aura, including this npc. + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC targetNPC = Main.npc[i]; + if (!targetNPC.active) + continue; + + float distance = Vector2.Distance(NPC.Center, targetNPC.Center); + + if (distance < buffRange) + { + targetNPC.AddBuff(ModContent.BuffType(), 60, true); + } + } + + // Handle dust which dynamically changes alpha based on distance and time + if (auraFade > 0f) + { + float pulse = 0.6f + 0.25f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2.5f); + int baseAlpha = (int)(255f * (1f - auraFade * 0.5f * pulse)); + if (baseAlpha < 0) baseAlpha = 0; + if (baseAlpha > 255) baseAlpha = 255; + + + int innerDustCount = Main.rand.Next(0, 2); + + for (int i = 0; i < innerDustCount; i++) + { + float areaSize = 255f; + Vector2 spawnSpot = NPC.Center + Main.rand.NextVector2Circular(areaSize, areaSize); + + Dust dust = Dust.NewDustPerfect(spawnSpot, ModContent.DustType()); + dust.scale = Main.rand.NextFloat(0.6f, 1.1f); + dust.noGravity = true; + dust.alpha = baseAlpha; + dust.color = (Main.rand.NextBool(2) ? Color.Silver : Color.Gold) * 2f; + dust.noLight = true; + dust.noLightEmittence = true; + dust.velocity *= 0.05f; + } + } + + // When detecting a player holding of one of the Axolotl's prey + if (nearestPlayer != null) + { + if (CurrentBehavior == (float)PhaseType.Idle) + { + if (NoticeHeldItemSoundTimer <= 0) + { + SoundEngine.PlaySound(noticedBaitSound with { Volume = 0.7f, Pitch = 0.1f, PitchVariance = 0.1f }, NPC.Center); + NoticeHeldItemSoundTimer = NoticeHeldItemSoundCooldown; + } + + CurrentBehavior = (float)PhaseType.Hunt; + PathfindToPlayer = true; + NPC.netUpdate = true; + pathfinding.ClearResults(); + } + } + + else + { + if (CurrentBehavior == (float)PhaseType.Hunt && PathfindToPlayer) + CurrentBehavior = CurrentPrey != null ? (float)PhaseType.Hunt : (float)PhaseType.Idle; + + PathfindToPlayer = false; + } + + Lighting.AddLight(NPC.Center, Color.Gold.ToVector3() * (auraFade * 0.8f)); // Passively emit light based on auraFade + + if (NPC.wet) + { + NPC.noGravity = true; + Animation = AnimationState.Water; + + switch ((PhaseType)CurrentBehavior) + { + case PhaseType.Idle: + IdleBehavior(); + break; + case PhaseType.Flee: + FleeBehavior(); + break; + case PhaseType.Hunt: + HuntBehavior(); + break; + } + + if (NPC.velocity != Vector2.Zero) + { + int dir = NPC.velocity.X.DirectionalSign(); + if (dir != 0) + NPC.spriteDirection = NPC.direction = dir; + + float targetRotation = NPC.velocity.ToRotation(); + if (NPC.spriteDirection == -1) + targetRotation = MathHelper.WrapAngle(targetRotation - MathHelper.Pi); + + NPC.rotation = MathHelper.Clamp(targetRotation, -MathHelper.PiOver2, MathHelper.PiOver2); + } + else + NPC.rotation = 0f; + } + + else // Refer to BeachedBehavior for grounded movement + { + Animation = AnimationState.Land; + BeachedBehavior(); + pathfinding.ClearResults(); + } + + // Timers + if (FleeTimer > 0) + FleeTimer--; + if (PassiveSoundTimer > 0) + PassiveSoundTimer--; + if (NoticeHeldItemSoundTimer > 0) + NoticeHeldItemSoundTimer--; + } + + public void IdleBehavior() + { + MaxSpeed = IdleMaxSpeed; + + // Always pathfind to a random point when idling +            pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(IdleMinPathDistance, IdleMaxPathDistance), SunkenSeaTileValidity)); + + if (Main.rand.NextBool(300) && PassiveSoundTimer <= 0) // Randomly emit a noise + { + SoundEngine.PlaySound(ambientNoise with { Volume = 0.66f, Pitch = 0.1f, PitchVariance = 0.15f }, NPC.Center); + PassiveSoundTimer = PassiveSoundCooldown; + } + } + + public void HuntBehavior() + { + MaxSpeed = HuntMaxSpeed; + + if (PathfindToPlayer) // Player is holding an item of interest +            { + Player target = Main.player[NPC.target]; + targetPoint = target.Center; + } + else + { +                // If prey is gone, go back to idling +                if (CurrentPrey == null) + { + CurrentBehavior = (float)PhaseType.Idle; + return; + } + targetPoint = CurrentPrey.Center; + } + + pathfinding.DoPathfinding(new(this, NPC.Center, targetPoint, tileValidity: SunkenSeaTileValidity)); + } + + public void FleeBehavior() + { + if (CurrentPredator == null) + { + CurrentBehavior = CurrentPrey != null ? (float)PhaseType.Hunt : (float)PhaseType.Idle; + FleeTimer = 0; + return; + } + + if (FleeTimer <= 0) // Specifically for VFX and SFX when fleeing + { + SoundEngine.PlaySound(alert with { Volume = 0.9f, PitchVariance = 0.1f }, NPC.Center); + + if (!Main.dedServ) + { + var emoteDirection = -Vector2.UnitY * Main.rand.NextFloat(2f, 3f); + GeneralParticleHandler.SpawnParticle(new EmoteExpressionParticle(NPC.Center + emoteDirection * 2f, emoteDirection, 2.2f, Color.Yellow, Main.rand.Next(30, 46), EmoteExpressionParticle.EmoteType.Exclamation)); + } + + FleeTimer = FleeFXCooldown; + } + + MaxSpeed = FleeMaxSpeed; + + // Try to find a safe point from predator + float distanceFromAvoided = Vector2.Distance(NPC.Center, CurrentPredator.Center); + Vector2 runDirection = NPC.DirectionFrom(CurrentPredator.Center); + targetPoint = NPC.Center + runDirection * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + + pathfinding.DoPathfinding(new(this, NPC.Center, targetPoint, SunkenSeaTileValidity)); + NPC.netUpdate = true; + } + + public void BeachedBehavior() + { + NPC.noGravity = false; // Gravity on while not swimming + if (NPC.collideY) + { + if (GroundMovementTimer <= 0) + { + NPC.velocity.X *= 0.94f; // Slow down +                    if (Math.Abs(NPC.velocity.X) < 0.2f) + NPC.velocity.X = 0f; + + if (Main.rand.NextBool(80)) + { + if (Main.rand.NextBool()) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + GroundMovementTimer = Main.rand.Next(30, 70); + NPC.velocity.X = 1.2f * NPC.direction; + NPC.netUpdate = true; + } + } + + else + GroundMovementTimer--; + } + + if (Math.Abs(NPC.velocity.X) > 0.01f) // Face chosen direction while moving + { + int dir = NPC.velocity.X.DirectionalSign(); + if (dir != 0) + NPC.spriteDirection = NPC.direction = dir; + } + + if (Main.rand.NextBool(300) && PassiveSoundTimer <= 0) // Randomly emit a noise + { + SoundEngine.PlaySound(ambientNoise with { Volume = 0.66f, Pitch = 0.1f, PitchVariance = 0.15f }, NPC.Center); + PassiveSoundTimer = PassiveSoundCooldown; + } + + NPC.rotation = 0f; // Rotation not needed when not in water + } + + protected override void OnPredatorDetection(NPC predator) + { + CurrentBehavior = (float)PhaseType.Flee; // Hit the bricks regardless of what the current action is + NPC.netUpdate = true; + } + + protected override void OnPreyDetection(NPC prey) + { + // Only start hunting if not fleeing from a pred + if ((PhaseType)CurrentBehavior != PhaseType.Flee) + { + CurrentBehavior = (float)PhaseType.Hunt; + NPC.netUpdate = true; + } + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter++; + int frameGate; + + if (Animation == AnimationState.Water) + { + frameGate = (NPC.velocity.Length() > 3.5f ? 5 : 7); // Flap limbs faster when going fast + } + + else // Land + { + if (Math.Abs(NPC.velocity.X) > 0.1f) + { + frameGate = 6; + } + else + { + NPC.frame.Y = 0; + NPC.frameCounter = 0; + return; + } + } + + if (NPC.frameCounter > frameGate) + { + NPC.frameCounter = 0; + NPC.frame.Y += frameHeight; + if (NPC.frame.Y > frameHeight * (Main.npcFrameCount[Type] - 1)) + { + NPC.frame.Y = 0; // Loop anim + } + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneRadiantReefs && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.Cavern.Chance * 0.1777f; + } + return 0f; + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 7; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GoldCoin, hit.HitDirection, -1f, 0, default, 1f); + } + CalamityUtils.SpawnGores(NPC, "GildedAxolotl", 3); + } + + public override void OnKill() + { + for (int k = 0; k < 7; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, ModContent.DustType(), Main.rand.NextFloat(0, MathHelper.TwoPi), Main.rand.NextFloat(-1f, 3f), 0, default, 1f); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.IsABestiaryIconDummy) + return true; + + // Draw aura circle behind the axolotl + float auraOpacity = auraFade * 0.4f; + if (auraOpacity > 0f) + { + Texture2D auraTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Main.EntitySpriteDraw(auraTexture, NPC.Center - screenPos, null, (Color.Gold * auraOpacity) with { A = 0 }, NPC.rotation, auraTexture.Size() * 0.5f, 7.77f, SpriteEffects.None, 0); + } + + // Main NPC drawing + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + Vector2 origin = new Vector2(tex.Width / 4, tex.Height / (Main.npcFrameCount[Type] * 2)); + + float yOffset = Animation == AnimationState.Land ? 2f : 0f; // Draws 2 pixels down out of water. The way it's sheeted makes it best to handle it this way as to not edit the hitbox. + Vector2 drawPos = NPC.Center - screenPos + Vector2.UnitY * (NPC.gfxOffY + yOffset); + + Rectangle frame = tex.Frame(2, Main.npcFrameCount[Type], (int)Animation, NPC.frame.Y / NPC.height); + + // Draw backglow that scales with auraFade + if (auraFade > 0f) + { + float glowScale = NPC.scale * (1f + (0.0777f * auraFade)); + float pulse = 0.8f + 0.15f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 10f); + Color glowColor = (Color.Gold * auraFade * pulse) with { A = 0 }; + + spriteBatch.Draw(tex, drawPos, frame, glowColor, NPC.rotation, origin, glowScale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + } + + spriteBatch.Draw(tex, drawPos, frame, NPC.GetAlpha(drawColor * (1f + auraFade * 3)), NPC.rotation, origin, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + return false; + } + } +} diff --git a/NPCs/SunkenSea/GildedAxolotl.png b/NPCs/SunkenSea/GildedAxolotl.png new file mode 100644 index 0000000000..e9c69adfb6 Binary files /dev/null and b/NPCs/SunkenSea/GildedAxolotl.png differ diff --git a/NPCs/SunkenSea/HauntedChum.cs b/NPCs/SunkenSea/HauntedChum.cs index 59ef4255be..28b16dbe2c 100644 --- a/NPCs/SunkenSea/HauntedChum.cs +++ b/NPCs/SunkenSea/HauntedChum.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using CalamityMod.BiomeManagers; using CalamityMod.DataStructures; using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Placeables.Banners; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -17,15 +18,17 @@ namespace CalamityMod.NPCs.SunkenSea { public class HauntedChum : ModNPC { - public static Texture2D jawTexture; + public static Asset jawTexture; public List Segments; + + public override void Load() + { + jawTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/HauntedChumMouth"); + } + public override void SetStaticDefaults() { this.HideFromBestiary(); - if (!Main.dedServ) - { - jawTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/HauntedChumMouth", AssetRequestMode.ImmediateLoad).Value; - } } public override void SetDefaults() { @@ -41,7 +44,9 @@ namespace CalamityMod.NPCs.SunkenSea NPC.DeathSound = SoundID.DD2_SkeletonDeath; NPC.noGravity = true; NPC.noTileCollide = true; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); } public override void AI() @@ -190,19 +195,19 @@ namespace CalamityMod.NPCs.SunkenSea NPC.ForceNetUpdate(); } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return MathHelper.Clamp(((float)Math.Cos(completionRatio * 60)) + 2, 1, 2) / 2; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { return (int)(completionRatio * 100) % 2 == 0 ? new Color(69, 52, 0) : new Color(); } - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 3f; + internal float BackgroundWidthFunction(float completionRatio, Vector2 vertexPos) => WidthFunction(completionRatio, vertexPos) * 3f; - internal Color BackgroundColorFunction(float completionRatio) + internal Color BackgroundColorFunction(float completionRatio, Vector2 vertexPos) { return Color.Black; } @@ -301,11 +306,11 @@ namespace CalamityMod.NPCs.SunkenSea // Draw the chum itself and its jaw, rotated by localai[0] Texture2D texture = TextureAssets.Npc[Type].Value; Vector2 origin = new Vector2(texture.Width / 2, texture.Height / 2); - Vector2 jawOrigin = new Vector2(NPC.spriteDirection == 1 ? jawTexture.Width - 22 : 22, 4); + Vector2 jawOrigin = new Vector2(NPC.spriteDirection == 1 ? jawTexture.Value.Width - 22 : 22, 4); Vector2 npcOffset = NPC.Center - screenPos; npcOffset -= new Vector2(texture.Width, texture.Height) * NPC.scale / 2f; npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(jawTexture, npcOffset + new Vector2(16 * -NPC.spriteDirection, 4), null, NPC.GetAlpha(drawColor), NPC.localAI[0] * NPC.spriteDirection, jawOrigin, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(jawTexture.Value, npcOffset + new Vector2(16 * -NPC.spriteDirection, 4), null, NPC.GetAlpha(drawColor), NPC.localAI[0] * NPC.spriteDirection, jawOrigin, NPC.scale, spriteEffects, 0f); spriteBatch.Draw(texture, npcOffset, null, NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, spriteEffects, 0f); return false; diff --git a/NPCs/SunkenSea/Jellyghoul.cs b/NPCs/SunkenSea/Jellyghoul.cs index d2dd52a8b2..e1912c55a2 100644 --- a/NPCs/SunkenSea/Jellyghoul.cs +++ b/NPCs/SunkenSea/Jellyghoul.cs @@ -1,12 +1,13 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Items.Placeables; +using System; +using System.Collections.Generic; +using CalamityMod.BiomeManagers; +using CalamityMod.DataStructures; +using CalamityMod.Items.Placeables.Banners; using CalamityMod.Particles; using CalamityMod.Projectiles.Enemy; -using CalamityMod.Tiles.SunkenSea; -using CalamityMod.Walls; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -14,6 +15,7 @@ using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.SunkenSea { @@ -32,6 +34,13 @@ namespace CalamityMod.NPCs.SunkenSea public static SoundStyle JellyGhoulScream = SoundID.NPCDeath51 with { Pitch = -1, Volume = 0.2f, MaxInstances = 0 }; + public static Asset tentacleTexture; + + public override void Load() + { + tentacleTexture = ModContent.Request(Texture + "Tentacle"); + } + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 1; @@ -54,9 +63,9 @@ namespace CalamityMod.NPCs.SunkenSea NPC.DeathSound = SoundID.NPCDeath3; NPC.chaseable = false; NPC.noTileCollide = true; - // Banner = NPC.type; - //BannerItem = ModContent.ItemType(); - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -69,7 +78,7 @@ namespace CalamityMod.NPCs.SunkenSea public override void OnSpawn(IEntitySource source) { - NPC.Center -= new Vector2(Main.rand.NextFloat(-16 * 16, 16 * 16), Main.rand.NextFloat(4 * 16, 16 * 16)); + NPC.position -= new Vector2(Main.rand.NextFloat(-16 * 16, 16 * 16), Main.rand.NextFloat(4 * 16, 16 * 16)); } public override void AI() { @@ -97,8 +106,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.ai[1]++; float screenShakePower = 2 * Utils.GetLerpValue(500f, 0f, NPC.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; + Main.LocalPlayer.SetScreenshake(screenShakePower); // After 1 second, stop shaking and set the scream on cooldown if (NPC.ai[1] > 60) @@ -118,6 +126,7 @@ namespace CalamityMod.NPCs.SunkenSea } if (NPC.ai[2] >= 1) { + NPC.chaseable = true; NPC.TargetClosest(false); NPC.ai[3]++; if (NPC.ai[3] >= 120 + (NPC.localAI[1] * 10)) @@ -133,8 +142,8 @@ namespace CalamityMod.NPCs.SunkenSea } if (Main.rand.NextBool(80)) { - Particle ash = new SquareAshParticle(Main.rand.NextVector2FromRectangle(NPC.getRect()), new Vector2(0, 2), Main.rand.Next(100, 200), Main.rand.NextFloat(0.8f, 1.2f), new Color(50, 50, 50)); - GeneralParticleHandler.SpawnParticle(ash); + Particle ash = new SquareAshParticle(Main.rand.NextVector2FromRectangle(NPC.getRect()), new Vector2(0, 2), Main.rand.Next(100, 200), Main.rand.NextFloat(0.8f, 1.2f), new Color(50, 50, 50)); + GeneralParticleHandler.SpawnParticle(ash); } } @@ -148,16 +157,11 @@ namespace CalamityMod.NPCs.SunkenSea public override float SpawnChance(NPCSpawnInfo spawnInfo) { - Tile tile = Framing.GetTileSafely(spawnInfo.SpawnTileX, spawnInfo.SpawnTileY); - - return !spawnInfo.Player.Calamity().clamity && tile.WallType == ModContent.WallType() ? 0.05f : 0f; - - //fuck this - //if (spawnInfo.Player.Calamity().ZoneSunkenSeaShores && !spawnInfo.Player.Calamity().clamity && tile.WallType == ModContent.WallType()) - //{ - // return 0.05f; - //} - //return 0f; + if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.Cavern.Chance * 0.9f; + } + return 0f; } public override void HitEffect(NPC.HitInfo hit) @@ -173,6 +177,7 @@ namespace CalamityMod.NPCs.SunkenSea Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.SpectreStaff, hit.HitDirection, -1f, 0, Color.DarkGray * 0.2f, 1f); } } + CalamityUtils.SpawnGores(NPC, "Jellyghoul", 2); } public override void OnKill() @@ -203,9 +208,6 @@ namespace CalamityMod.NPCs.SunkenSea public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - if (NPC.IsABestiaryIconDummy) - return true; - SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; @@ -217,13 +219,16 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 afterimageOffset = new Vector2((float)Math.Cos(Main.GlobalTimeWrappedHourly * afterimageRotationSpeed) + NPC.localAI[1], (float)Math.Sin(Main.GlobalTimeWrappedHourly * afterimageRotationSpeed) + NPC.localAI[1]) * afterimageDistance; // Spooky glowey aura effect - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - Texture2D bloom = ModContent.Request("CalamityMod/Particles/SmallBloom").Value; + if (!NPC.IsABestiaryIconDummy) + { + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Texture2D bloom = ModContent.Request("CalamityMod/Particles/SmallBloom").Value; - spriteBatch.Draw(bloom, NPC.Center - Main.screenPosition + afterimageOffset, null, FinalColor * 0.45f, 0f, bloom.Size() / 2f, 0.6f, SpriteEffects.None, 0); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.Draw(bloom, NPC.Center - screenPos + afterimageOffset, null, FinalColor * 0.45f, 0f, bloom.Size() / 2f, 0.6f, SpriteEffects.None, 0); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } Texture2D texture = TextureAssets.Npc[Type].Value; Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[Type] / 2)); @@ -235,6 +240,55 @@ namespace CalamityMod.NPCs.SunkenSea npcOffset -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[Type])) * NPC.scale / 2f; npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); + // Tentacles + Texture2D tentacle = tentacleTexture.Value; + for (int i = 0; i < 4; i++) + { + // Is the tentacle on the outside? + bool outerTentacle = i == 0 || i == 3; + // Is the tentacle one of the left ones? + int leftTentacle = i < 2 ? -1 : 1; + // Start position x offset + int xOffset = outerTentacle ? 4 : 2; + // How much the end position is rotated by + int endDeg = outerTentacle ? 20 : 5; + // Length of each tentacle + int tentacleLength = outerTentacle ? 60 : 50; + // A psuedo randomness value between tentacles and the NPC's index used to desync tentacles from each other + int randomness = i % 2 + NPC.whoAmI; + // Start position of the tentacle + Vector2 anchor = npcOffset + afterimageOffset + new Vector2(leftTentacle * xOffset, 10); + // End position of the tentacle + Vector2 end = npcOffset + afterimageOffset + Vector2.UnitY.RotatedBy(MathHelper.ToRadians(endDeg * -leftTentacle)).RotatedBy(MathHelper.ToRadians(MathF.Sin(Main.GlobalTimeWrappedHourly * 4) * 5 * -leftTentacle)) * tentacleLength; + + // Store the previous tentacle's location + Vector2 prevTentacle = npcOffset + afterimageOffset; + int segmentCount = 10; + Vector2 direction = anchor.DirectionTo(end).RotatedBy(MathHelper.PiOver2); + BezierCurve curve = new BezierCurve(anchor, anchor + (end - anchor) * 0.33f + direction * MathF.Sin(Main.GlobalTimeWrappedHourly * 4 + randomness) * 8, anchor + (end - anchor) * 0.66f + direction * MathF.Cos(Main.GlobalTimeWrappedHourly * 4 + randomness) * 16, end); + List points = curve.GetPoints(segmentCount); + for (int j = 0; j < segmentCount; j++) + { + // Which texture variant the tentacle uses is based on the horizontal position on its sheet + int texX = i == 0 ? 0 : i == (segmentCount - 1) ? 16 : 8; + // Which segment type. + // The first segment (0 is invisible) uses the first frame + // The final segment uses the last frame + // The rest alternate between frames 2 and 3 + int texY = j % 2 == 0 ? 16 : 8; + if (j == 1) + texY = 0; + else if (j == segmentCount - 1) + texY = 24; + + int segHeight = (j == segmentCount - 1) ? 8 : 6; + + if (j != 0) + spriteBatch.Draw(tentacle, points[j], new Rectangle(texX, texY, 6, segHeight), FinalColor * NPC.Opacity, points[j].DirectionTo(prevTentacle).ToRotation() + MathHelper.PiOver2, new Vector2(2), NPC.scale, spriteEffects, 0); + prevTentacle = points[j]; + } + } + // Draws transparent clones around itself to look woozy int cloneAmt = 4; for (int i = 0; i < cloneAmt; i++) diff --git a/NPCs/SunkenSea/Jellyghoul.png b/NPCs/SunkenSea/Jellyghoul.png index 26bfb3154d..4ca9f182b3 100644 Binary files a/NPCs/SunkenSea/Jellyghoul.png and b/NPCs/SunkenSea/Jellyghoul.png differ diff --git a/NPCs/SunkenSea/JellyghoulTentacle.png b/NPCs/SunkenSea/JellyghoulTentacle.png new file mode 100644 index 0000000000..573995d970 Binary files /dev/null and b/NPCs/SunkenSea/JellyghoulTentacle.png differ diff --git a/NPCs/SunkenSea/KelpieSeadragon.cs b/NPCs/SunkenSea/KelpieSeadragon.cs index 8494c30093..122f8e3d03 100644 --- a/NPCs/SunkenSea/KelpieSeadragon.cs +++ b/NPCs/SunkenSea/KelpieSeadragon.cs @@ -1,36 +1,61 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Items.Placeables; +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Pathfinding; using CalamityMod.Projectiles.Enemy; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.World; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using System; -using System.IO; using Terraria; using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; -using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; + namespace CalamityMod.NPCs.SunkenSea { - public class KelpieSeadragon : ModNPC + public class KelpieSeadragon : SunkenSeaNPC { public ref float SquishX => ref NPC.localAI[0]; public ref float SquishY => ref NPC.localAI[1]; + + public Vector2 randomPathPoint; + + public Entity currentTarget; + + public static int IdleRandomMovementUnlikeliness = 250; + public static int IdleMinPathDistance = 400; + public static int IdleMaxPathDistance = 800; + + public static int FleeTileAnticipationDistance = 64; + + protected override List PreyIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType() + }; + + protected override List PredatorIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + //ModContent.NPCType() + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.PolypForest; public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 13; + base.SetStaticDefaults(); } public override void SetDefaults() { + base.SetDefaults(); NPC.noGravity = true; NPC.damage = 10; NPC.width = 20; @@ -39,18 +64,17 @@ namespace CalamityMod.NPCs.SunkenSea NPC.lifeMax = 150; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.15f; - //Banner = NPC.type; - //BannerItem = ModContent.ItemType(); + Banner = NPC.type; + BannerItem = ModContent.ItemType(); NPC.chaseable = false; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -61,18 +85,14 @@ namespace CalamityMod.NPCs.SunkenSea }); } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(NPC.chaseable); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - NPC.chaseable = reader.ReadBoolean(); - } - public override void AI() { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.3f; + MaxSpeed = 3f; + } if (NPC.direction == 0) { NPC.TargetClosest(); @@ -83,7 +103,6 @@ namespace CalamityMod.NPCs.SunkenSea { NPC.ai[0] = 0; NPC.ai[1] = 0; - NPC.ai[2] = 0; NPC.velocity.X *= 0.98f; NPC.noGravity = false; NPC.rotation = MathHelper.Lerp(NPC.rotation, MathHelper.PiOver2, 0.1f); @@ -96,15 +115,6 @@ namespace CalamityMod.NPCs.SunkenSea // Idle AI. Mostly sits still but occasionally moves in a random direction for a bit. case 0: NPC.chaseable = false; - if (target != null && target.active && target.Distance(NPC.Center) < 400 && Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1)) - { - NPC.ai[0] = 1; - NPC.ai[1] = 0; - NPC.ai[2] = 0; - SquishX = 0.9f; - SquishY = 1.05f; - NPC.TargetClosest(); - } if (NPC.velocity.Length() < 0.1f) { NPC.ai[1]++; @@ -127,31 +137,33 @@ namespace CalamityMod.NPCs.SunkenSea NPC.velocity *= 0.99f; break; case 1: - if (target == null || !target.active || target.Distance(NPC.Center) > 600) + currentTarget = CurrentPrey != null ? CurrentPrey : CurrentPlayer; + if (currentTarget == null) { NPC.ai[0] = 0; NPC.ai[1] = 0; - NPC.ai[2] = 0; SquishX = 0; SquishY = 0; + break; } - NPC.chaseable = true; + if (currentTarget is Player) + NPC.chaseable = true; + bool hasSight = Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1); // If the target is too far from its shooting range or a tile is in the way, move closer - if (target.Distance(NPC.Center) > 300 || !Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1)) + if ((currentTarget.Distance(NPC.Center) > 300 || !hasSight) || currentTarget is NPC) { NPC.ai[1] = 0; - NPC.ai[2]++; - NPC.velocity = NPC.DirectionTo(target.Center).SafeNormalize(Vector2.Zero) * 3f; + + bool huntReady = NPC.ai[2] == 0; + if (huntReady) + NPC.ai[2] = Main.rand.Next(13, 30); + + // With sight, just go straight at him. Without it, try to pathfind over them. + pathfinding.DoPathfinding(new(this, NPC.Center, currentTarget.Center, SunkenSeaTileValidity), forceNewTask: huntReady); + + NPC.ai[2]--; + NPC.rotation = MathHelper.Lerp(NPC.rotation, NPC.direction * MathHelper.PiOver4 / 2, 0.05f); - // Loose interest if it can't reach the player for a few seconds - if (!Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1) && NPC.ai[2] > 180) - { - NPC.ai[0] = 0; - NPC.ai[1] = 0; - NPC.ai[2] = 0; - SquishX = 0; - SquishY = 0; - } } else { @@ -166,8 +178,8 @@ namespace CalamityMod.NPCs.SunkenSea if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 spawnPos = new Vector2(NPC.Center.X + NPC.direction * 18, NPC.position.Y + 22); - Vector2 projSpeed = spawnPos.DirectionTo(target.Center).SafeNormalize(Vector2.Zero) * 6; - Projectile.NewProjectile(NPC.GetSource_FromThis(), spawnPos, projSpeed, ModContent.ProjectileType(), NPC.damage, 0f); + Vector2 projSpeed = spawnPos.DirectionTo(currentTarget.Center).SafeNormalize(Vector2.Zero) * 6; + Projectile.NewProjectile(NPC.GetSource_FromThis(), spawnPos, projSpeed, ModContent.ProjectileType(), 10, 0f); } } // Squash and stretch @@ -191,9 +203,47 @@ namespace CalamityMod.NPCs.SunkenSea } else { - NPC.direction = NPC.Center.X > target.Center.X ? -1 : 1; + NPC.direction = NPC.Center.X > currentTarget.Center.X ? -1 : 1; } break; + case 2: + { + // If the avoided entity is gone, go back to idling. + if (CurrentPredator == null) + { + NPC.ai[0] = 0; + break; + } + + if (Math.Abs(NPC.velocity.X) > 0) + { + NPC.direction = NPC.velocity.X > 0 ? 1 : -1; + } + else + { + NPC.direction = NPC.Center.X > CurrentPredator.Center.X ? -1 : 1; + } + + // While it doesn't have any obstacles in front of it, run away in a straight line. + // Try to manuever if there are any obstacles. + if (!Main.tile[(NPC.Center + NPC.DirectionFrom(CurrentPredator.Center) * FleeTileAnticipationDistance).ToTileCoordinates()].IsTileSolid()) + { + NPC.velocity += NPC.DirectionFrom(CurrentPredator.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, CurrentPredator.Center); + randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, randomPathPoint, SunkenSeaTileValidity)); + } + break; + } } NPC.spriteDirection = NPC.direction; } @@ -226,16 +276,87 @@ namespace CalamityMod.NPCs.SunkenSea } } - public override bool? CanBeHitByProjectile(Projectile projectile) + protected override void OnPlayerDetection(Player player) { - return null; + if (CurrentPrey is null && CurrentPredator is null) + { + EnterAttackMode(); + currentTarget = player; + } + } + + protected override void OnPredatorDetection(NPC predator) + { + NPC.ai[0] = 2; + NPC.ai[1] = 0; + currentTarget = null; + } + + protected override void OnPreyDetection(NPC prey) + { + if (CurrentPredator == null) + { + EnterAttackMode(); + currentTarget = prey; + } + } + + public void EnterAttackMode() + { + NPC.ai[0] = 1; + NPC.ai[1] = 0; + SquishX = 0.9f; + SquishY = 1.05f; + } + + public override void AwaitingPathBehavior() + { + Player target = Main.player[NPC.target]; + bool hasSight = Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1); + if (NPC.ai[0] == 1f && (currentTarget.Distance(NPC.Center) > 300 || !hasSight || currentTarget is NPC)) + { + if (currentTarget != null) + { + NPC.velocity += NPC.DirectionTo(currentTarget.Center) * Acceleration; + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + NPC.velocity *= 0.95f; + } + else + base.AwaitingPathBehavior(); + } + + protected override bool NPCSearchFilter(NPC n) + { + return base.NPCSearchFilter(n) || (n == CurrentPredator || n == CurrentPrey) && Vector2.DistanceSquared(NPC.Center, n.Center) < 900f * 900f; + } + + protected override bool PlayerSearchFilter(Player p) + { + return base.PlayerSearchFilter(p) || p == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, p.Center) < 600f * 600f; + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type) || attacker.type == ModContent.NPCType(); + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(randomPathPoint); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + randomPathPoint = reader.ReadVector2(); } public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + if (spawnInfo.Player.Calamity().ZonePolypForest && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.CaveJellyfish.Chance * 0.9f; + return SpawnCondition.CaveJellyfish.Chance * 0.7f; } return 0f; } @@ -257,10 +378,12 @@ namespace CalamityMod.NPCs.SunkenSea public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + if (NPC.IsABestiaryIconDummy) + return true; Asset tex = TextureAssets.Npc[Type]; SpriteEffects fx = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 stretch = NPC.ai[0] == 1 && NPC.ai[1] > 0 ? new Vector2(SquishX, SquishY): Vector2.One; - spriteBatch.Draw(tex.Value, NPC.Center - Main.screenPosition + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColor, NPC.rotation, new Vector2(tex.Width() / 2, tex.Height() / 2 / Main.npcFrameCount[Type]), NPC.scale * stretch, fx, 0); + Vector2 stretch = NPC.ai[0] == 1 && NPC.ai[1] > 0 ? new Vector2(SquishX, SquishY) : Vector2.One; + spriteBatch.Draw(tex.Value, NPC.Center - Main.screenPosition + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColor, NPC.rotation, new Vector2(tex.Width() / 2, tex.Height() / 2 / Main.npcFrameCount[Type]), NPC.scale * stretch, fx, 0); return false; } } diff --git a/NPCs/SunkenSea/LazarusLampfish.cs b/NPCs/SunkenSea/LazarusLampfish.cs new file mode 100644 index 0000000000..62e5b3a275 --- /dev/null +++ b/NPCs/SunkenSea/LazarusLampfish.cs @@ -0,0 +1,395 @@ +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Pathfinding; +using CalamityMod.Projectiles.Enemy; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class LazarusLampfish : SunkenSeaNPC + { + public enum PhaseType + { + Idle = 0, + Attacking = 1, + Fleeing = 2 + } + + public static Asset cooldownTexture; + public static Asset attackTexture; + + public Vector2 randomPathPoint; + + public Entity currentTarget; + + public static int IdleRandomMovementUnlikeliness = 250; + public static int IdleMinPathDistance = 100; + public static int IdleMaxPathDistance = 800; + + public static int FleeTileAnticipationDistance = 64; + + public ref float CurrentPhase => ref NPC.ai[0]; + public ref float Timer => ref NPC.ai[1]; + + protected override List PreyIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + }; + + public static List PredatorList => new List() + { + ModContent.NPCType(), + }; + + protected override List PredatorIDs => PredatorList; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.GleamingBurrows | SunkenSeaBiomeFlags.ClamDen; + + public override void Load() + { + cooldownTexture = ModContent.Request(Texture + "Cooldown"); + attackTexture = ModContent.Request(Texture + "Attack"); + } + + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 6; + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + base.SetDefaults(); + NPC.noGravity = true; + NPC.damage = 40; + NPC.width = 50; + NPC.height = 30; + NPC.defense = 12; + NPC.lifeMax = 400; + NPC.aiStyle = -1; + AIType = -1; + NPC.value = Item.buyPrice(silver: 10); + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.knockBackResist = 0.1f; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.chaseable = false; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.LazarusLampfish") + }); + } + + public override void AI() + { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.2f; + MaxSpeed = 3f; + } + if (NPC.direction == 0) + { + NPC.TargetClosest(); + } + Player target = Main.player[NPC.target]; + // Fall and be useless if out of water + if (!NPC.wet) + { + CurrentPhase = (int)PhaseType.Idle; + Timer = 0; + NPC.velocity.X *= 0.98f; + NPC.noGravity = false; + return; + } + NPC.noGravity = true; + switch (CurrentPhase) + { + // Idle AI. Mostly sits still but occasionally moves in a random direction for a bit. + case (int)PhaseType.Idle: + NPC.chaseable = false; + NPC.ai[2]--; + if (CurrentPredator != null || CurrentPlayer != null) + { + EnterAttackMode(); + } + if (CurrentPrey != null) + { + bool huntReady = NPC.ai[2] == 0; + if (huntReady) + NPC.ai[2] = Main.rand.Next(13, 30); + + // With sight, just go straight at him. Without it, try to pathfind over them. + pathfinding.DoPathfinding(new(this, NPC.Center, CurrentPrey.Center, SunkenSeaTileValidity), forceNewTask: huntReady); + } + else + { + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.Next(IdleMinPathDistance, IdleMaxPathDistance), SunkenSeaTileValidity)); + } + break; + case (int)PhaseType.Attacking: + currentTarget = CurrentPredator != null ? CurrentPredator : CurrentPlayer; + if (currentTarget == null) + { + CurrentPhase = (int)PhaseType.Idle; + Timer = 0; + NPC.ai[2] = 0; + MaxSpeed = 3; + Acceleration = 0.2f; + break; + } + MaxSpeed = 8; + Acceleration = 0.3f; + NPC.chaseable = true; + bool hasSight = Collision.CanHitLine(NPC.Center, 1, 1, currentTarget.Center, 1, 1); + // If the target is too far from its shooting range or a tile is in the way, move closer + if (currentTarget.Distance(NPC.Center) > 200 || !hasSight) + { + bool restart = NPC.ai[2] == 0; + if (restart) + NPC.ai[2] = Main.rand.Next(13, 30); + + // With sight, just go straight at him. Without it, try to pathfind over them. + pathfinding.DoPathfinding(new(this, NPC.Center, currentTarget.Center, SunkenSeaTileValidity), forceNewTask: restart); + + NPC.ai[2]--; + } + // If close enough, start the timer for the flash + else if (Timer == 0) + { + Timer = 1; + } + // Flash! + if (Timer >= 1) + { + NPC.velocity *= 0.92f; + Timer++; + if (Timer == 60) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + (NPC.rotation - (NPC.spriteDirection == 1 ? 0 : MathHelper.Pi)).ToRotationVector2() * 40, Vector2.Zero, ModContent.ProjectileType(), 20, 1); + } + SoundEngine.PlaySound(SoundID.NPCDeath7 with { Pitch = 0.4f }, NPC.Center); + } + if (Timer >= 120) + { + Timer = 0; + NPC.ai[2] = 0; + CurrentPhase = (int)PhaseType.Fleeing; + } + } + break; + case (int)PhaseType.Fleeing: + { + // If the avoided entity is gone, go back to idling. + currentTarget = CurrentPredator != null ? CurrentPredator : CurrentPlayer; + if (currentTarget == null || Timer > 300) + { + CurrentPhase = currentTarget != null ? (int)PhaseType.Attacking : (int)PhaseType.Idle; + Timer = 0; + MaxSpeed = 3; + Acceleration = 0.2f; + NPC.ai[2] = currentTarget != null ? 0 : 120; + break; + } + if (Timer == 0) + { + NPC.spriteDirection = NPC.direction *= -1; + } + Timer++; + MaxSpeed = 8; + Acceleration = 0.4f; + + if (Math.Abs(NPC.velocity.X) > 0) + { + NPC.direction = NPC.velocity.X > 0 ? 1 : -1; + } + else + { + NPC.direction = NPC.Center.X > currentTarget.Center.X ? -1 : 1; + } + + // While it doesn't have any obstacles in front of it, run away in a straight line. + // Try to manuever if there are any obstacles. + if (!Main.tile[(NPC.Center + NPC.DirectionFrom(currentTarget.Center) * FleeTileAnticipationDistance).ToTileCoordinates()].IsTileSolid()) + { + NPC.velocity += NPC.DirectionFrom(currentTarget.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, currentTarget.Center); + randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, randomPathPoint, SunkenSeaTileValidity)); + } + break; + } + } + if (!(Timer >= 1 && CurrentPhase == (int)PhaseType.Attacking) && !(Timer < 3 && CurrentPhase == (int)PhaseType.Fleeing)) + { + int dir = NPC.velocity.X.DirectionalSign(); + NPC.rotation = NPC.velocity.ToRotation() + (dir == 1 ? 0 : MathHelper.Pi); + NPC.spriteDirection = NPC.direction = dir; + } + } + + public override void FindFrame(int frameHeight) + { + if (!NPC.wet && !NPC.IsABestiaryIconDummy) + return; + NPC.frameCounter++; + if (NPC.frameCounter > 5) + { + NPC.frame.Y += frameHeight; + NPC.frameCounter = 0; + } + if (NPC.frame.Y >= Main.npcFrameCount[Type] * frameHeight) + { + NPC.frame.Y = 0; + } + } + + protected override void OnPlayerDetection(Player player) + { + EnterAttackMode(); + } + + protected override void OnPredatorDetection(NPC predator) + { + EnterAttackMode(); + } + + public void EnterAttackMode() + { + CurrentPhase = (int)PhaseType.Attacking; + Timer = 0; + NPC.ai[2] = 0; + } + + protected override bool NPCSearchFilter(NPC n) + { + return base.NPCSearchFilter(n) || (n == CurrentPredator || n == CurrentPrey) && Vector2.DistanceSquared(NPC.Center, n.Center) < 700f * 700f; + } + + protected override bool PlayerSearchFilter(Player p) + { + return base.PlayerSearchFilter(p) || (p == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, p.Center) < 600f * 600f); + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override void AwaitingPathBehavior() + { + bool hasSight = false; + if (currentTarget != null) + hasSight = Collision.CanHitLine(NPC.Center, 1, 1, currentTarget.Center, 1, 1); + if (CurrentPhase == (int)PhaseType.Idle && CurrentPrey != null || CurrentPhase == (int)PhaseType.Attacking && currentTarget.Distance(NPC.Center) > 200 || !hasSight) + { + if (CurrentPrey != null) + { + NPC.velocity += NPC.DirectionTo(CurrentPrey.Center) * Acceleration; + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + NPC.velocity *= 0.95f; + } + else + base.AwaitingPathBehavior(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(randomPathPoint); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + randomPathPoint = reader.ReadVector2(); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if ((spawnInfo.Player.Calamity().ZoneGleamingBurrows || spawnInfo.Player.Calamity().ZoneClamDen) && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.CaveJellyfish.Chance * 0.3f; + } + return 0f; + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 25; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); + } + } + CalamityUtils.SpawnGores(NPC, "LazarusLampfish", 3); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.IsABestiaryIconDummy) + return true; + Asset tex = TextureAssets.Npc[Type]; + Rectangle frame = NPC.frame; + Vector2 origin = new Vector2(tex.Width() / 2, tex.Height() / 2 / Main.npcFrameCount[Type]); + + if (CurrentPhase == (int)PhaseType.Attacking && Timer > 0) + { + tex = attackTexture; + frame = tex.Frame(1, 11, 0, (int)MathHelper.Lerp(0, 10, Utils.GetLerpValue(0, 120, Timer, true))); + origin = new Vector2(tex.Width() / 2, tex.Height() / 22); + } + if (CurrentPhase == (int)PhaseType.Fleeing) + { + tex = cooldownTexture; + frame = tex.Frame(1, 4, 0, (int)MathHelper.Lerp(0, 3, Utils.GetLerpValue(0, 24, Timer % 24, true))); + origin = new Vector2(tex.Width() / 2, tex.Height() / 8); + } + SpriteEffects fx = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(tex.Value, NPC.Center - Main.screenPosition + new Vector2(0, NPC.gfxOffY), frame, drawColor, NPC.rotation, origin, NPC.scale, fx, 0); + return false; + } + } +} diff --git a/NPCs/SunkenSea/LazarusLampfish.png b/NPCs/SunkenSea/LazarusLampfish.png new file mode 100644 index 0000000000..8d06df2008 Binary files /dev/null and b/NPCs/SunkenSea/LazarusLampfish.png differ diff --git a/NPCs/SunkenSea/LazarusLampfishAttack.png b/NPCs/SunkenSea/LazarusLampfishAttack.png new file mode 100644 index 0000000000..d143d51cbb Binary files /dev/null and b/NPCs/SunkenSea/LazarusLampfishAttack.png differ diff --git a/NPCs/SunkenSea/LazarusLampfishCooldown.png b/NPCs/SunkenSea/LazarusLampfishCooldown.png new file mode 100644 index 0000000000..48eba44b4d Binary files /dev/null and b/NPCs/SunkenSea/LazarusLampfishCooldown.png differ diff --git a/NPCs/SunkenSea/Leerslug.cs b/NPCs/SunkenSea/Leerslug.cs new file mode 100644 index 0000000000..ef53844377 --- /dev/null +++ b/NPCs/SunkenSea/Leerslug.cs @@ -0,0 +1,311 @@ +using CalamityMod.BiomeManagers; +using CalamityMod.Items.Placeables.Banners; +using Microsoft.Xna.Framework; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; +using Terraria.Audio; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using CalamityMod.Particles; +using System; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Leerslug : ModNPC + { + public enum PhaseType + { + Idle = 0, + Rawr = 1, + Jumps = 2, + Dash = 3 + } + + public ref float CurrentPhase => ref NPC.ai[0]; + + public ref float Timer => ref NPC.ai[1]; + + /// + /// Handles the visual scale for the slug + /// + public Vector2 squish = new Vector2(); + public Player Target => Main.player[NPC.target]; + + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 5; + } + public override void SetDefaults() + { + NPC.aiStyle = -1; + NPC.damage = 30; + NPC.width = 56; + NPC.height = 30; + NPC.defense = 3; + NPC.lifeMax = 200; + NPC.knockBackResist = 0.2f; + NPC.value = Item.buyPrice(silver: 1); + NPC.lavaImmune = true; + NPC.noGravity = false; + NPC.noTileCollide = false; + NPC.HitSound = SoundID.NPCHit50; + NPC.DeathSound = SoundID.NPCDeath53; + NPC.GravityIgnoresLiquid = true; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToWater = true; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + squish = reader.ReadVector2(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(squish); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Leerslug") + }); + } + + public override void AI() + { + NPC.Calamity().newAI[1]++; + NPC.TargetClosest(false); + Lighting.AddLight(NPC.Center, 0.5f, 0.2f, 0); + if (NPC.direction == 0) + { + NPC.direction = Main.rand.NextBool().ToDirectionInt(); + squish = Vector2.One; + } + switch (CurrentPhase) + { + case (int)PhaseType.Idle: + { + // Flip direction and slow down if it's still moving from a previous cycle + if (Timer == 0 && Main.rand.NextBool()) + { + NPC.direction *= -1; + NPC.velocity.X *= 0.9f; + } + // Move horizontally in short bursts + else if (Timer >= Main.rand.Next(30, 90) && NPC.velocity.Y == 0 && Math.Abs(NPC.velocity.X) < 1 && NPC.ai[2] == 0) + { + NPC.ai[2] = 1; + NPC.velocity.X = Main.rand.NextFloat(2, 4) * Main.rand.NextBool().ToDirectionInt(); + } + + // Increment the timer before the burst ends + if (NPC.ai[2] == 1) + { + NPC.ai[3]++; + } + // Slowdown after a burst + else if (NPC.ai[2] == 2 && NPC.velocity.Y == 0) + { + NPC.velocity.X *= 0.9f; + NPC.ai[3]++; + } + + // Handle movement states + if (NPC.ai[3] > Main.rand.Next(20, 40)) + { + // If the slug is moving, enter slowdown + if (NPC.ai[2] == 1) + NPC.ai[2] = 2; + // If the slug is in slowdown, reset + else if (NPC.ai[2] == 2) + ChangePhase((int)PhaseType.Idle); + NPC.ai[3] = 0; + } + + NPC.direction = NPC.velocity.X.DirectionalSign(); + + // Aggro + if (Target.active && Target.Distance(NPC.Center) < 400 && NPC.HasSight(Target.Center)) + { + ChangePhase((int)PhaseType.Rawr); + } + } + break; + case (int)PhaseType.Rawr: + { + int roar = 40; + int startAI = 70; + NPC.velocity.X *= 0.9f; + // Roar in place with a lil jump + if (Timer == roar) + { + SoundEngine.PlaySound(SoundID.Zombie7 with { Pitch = 0.7f }, NPC.Center); + if (NPC.velocity.Y == 0) + { + NPC.velocity.Y = -3; + } + } + NPC.direction = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + if (Timer > startAI) + ChangePhase(Main.rand.NextBool() ? (int)PhaseType.Jumps : (int)PhaseType.Dash); + } + break; + case (int)PhaseType.Jumps: + { + // Do a few hops towards the player + int maxJumps = 3; + int jumpHeight = Target.Bottom.Y < NPC.Top.Y ? 8 : 5; + if (NPC.ai[2] >= maxJumps - 1 && NPC.velocity.Y == 0) + { + ChangePhase((int)PhaseType.Dash); + } + // Jump + if (NPC.velocity.Y == 0) + { + NPC.velocity.Y = -jumpHeight; + NPC.velocity.X = NPC.DirectionTo(Target.Center).X.DirectionalSign() * 4; + NPC.ai[2]++; + } + // Move towards the player if it fell in lava + else if (NPC.lavaWet) + { + NPC.velocity.X = NPC.DirectionTo(Target.Center).X.DirectionalSign() * 4; + if (Main.rand.NextBool(20)) + { + SoundEngine.PlaySound(SoundID.Zombie7 with { Pitch = 0.7f }, NPC.Center); + } + } + NPC.direction = NPC.velocity.X.DirectionalSign(); + } + break; + case (int)PhaseType.Dash: + { + // Squash and stretch to telegraph the dash + int squash = 30; + int stretch = 10; + Vector2 squashAmt = new Vector2(0.6f, 1.5f); + RawrAnimation(squash, stretch, squashAmt); + // Slow down before dashing + if (Timer < squash + 10) + { + NPC.velocity.X *= 0.95f; + NPC.direction = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + } + // Dash + else if (Timer == squash + 10) + { + NPC.velocity.X = NPC.DirectionTo(Target.Center).X.DirectionalSign() * 6; + SoundEngine.PlaySound(SoundID.DD2_SkyDragonsFuryShot, NPC.Center); + } + // Leave behind some hot mist particles + else + { + if (NPC.velocity.X == 0) + { + ChangePhase((int)PhaseType.Jumps); + break; + } + if (Timer < squash + 60) + { + if (Timer % 2 == 0) + { + MediumMistParticle particle = new MediumMistParticle(NPC.Center, -NPC.velocity, Color.Red, Color.Orange, Main.rand.NextFloat(0.8f, 1.2f), 255f, 0.2f); + GeneralParticleHandler.SpawnParticle(particle); + } + } + NPC.direction = NPC.velocity.X.DirectionalSign(); + } + if (Timer > 120 && NPC.velocity.Y == 0) + ChangePhase((int)PhaseType.Jumps); + } + break; + } + NPC.StepUpBlocks(); + NPC.spriteDirection = NPC.direction; + // Bounce on lava + if (NPC.lavaWet) + { + NPC.velocity.Y = MathHelper.Min(NPC.velocity.Y - 0.2f, -4); + } + Timer++; + } + + public void RawrAnimation(int squashDuration, int stretchDuration, Vector2 squashAmt) + { + int squash = squashDuration; + int stretch = squash + stretchDuration; + // rawrxd + if (Timer == squash) + { + SoundEngine.PlaySound(SoundID.Zombie7 with { Pitch = 0.7f }, NPC.Center); + } + // Squash + if (Timer < squash) + { + squish.X = MathHelper.Lerp(1, squashAmt.X, Utils.GetLerpValue(0, squash, Timer, true)); + squish.Y = MathHelper.Lerp(1, squashAmt.Y, Utils.GetLerpValue(0, squash, Timer, true)); + } + // Stretch + else if (Timer >= squash && Timer < stretch) + { + squish.X = MathHelper.Lerp(squashAmt.X, 1, Utils.GetLerpValue(squash, stretch, Timer, true)); + squish.Y = MathHelper.Lerp(squashAmt.Y, 1, Utils.GetLerpValue(squash, stretch, Timer, true)); + } + } + + public void ChangePhase(int phaseNum, bool resetai2 = true, bool resetai3 = true) + { + CurrentPhase = phaseNum; + Timer = 0; + if (resetai2) + NPC.ai[2] = 0; + if (resetai3) + NPC.ai[3] = 0; + NPC.netUpdate = true; + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter++; + if (NPC.frameCounter > 6) + { + NPC.frameCounter = 0; + NPC.frame.Y += frameHeight; + if (NPC.frame.Y > frameHeight * (Main.npcFrameCount[Type] - 1)) + { + NPC.frame.Y = 0; + } + } + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LavaMoss, hit.HitDirection, -1f, 0, default, 1f); + } + CalamityUtils.SpawnGores(NPC, "Leerslug", 2); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.IsABestiaryIconDummy) + return true; + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + Vector2 pos = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + + spriteBatch.Draw(tex, pos, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[NPC.type]), NPC.scale * squish, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : 0, 0); + + return false; + } + } +} diff --git a/NPCs/SunkenSea/Leerslug.png b/NPCs/SunkenSea/Leerslug.png new file mode 100644 index 0000000000..69dba75efd Binary files /dev/null and b/NPCs/SunkenSea/Leerslug.png differ diff --git a/NPCs/SunkenSea/LostShoal.cs b/NPCs/SunkenSea/LostShoal.cs index 71dc4e192a..b337deb76b 100644 --- a/NPCs/SunkenSea/LostShoal.cs +++ b/NPCs/SunkenSea/LostShoal.cs @@ -1,6 +1,5 @@ using CalamityMod.BiomeManagers; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Critters; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -11,16 +10,14 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.GameContent; using Terraria.DataStructures; -using CalamityMod.Particles; -using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.SunkenSea { public class LostShoal : ModNPC { - public static Texture2D RedTexture; - public static Texture2D BlueTexture; - public static Texture2D GoldTexture; + public static Asset RedTexture; + public static Asset BlueTexture; + public static Asset GoldTexture; public float RandomOpacityOffset; public ref float Variant => ref NPC.ai[1]; @@ -35,18 +32,20 @@ namespace CalamityMod.NPCs.SunkenSea Gold = 3 } + public override void Load() + { + RedTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/LostShoalRed"); + BlueTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/LostShoalBlue"); + GoldTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/LostShoalGold"); + } + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 8; NPCID.Sets.TrailingMode[Type] = 1; - if (!Main.dedServ) - { - RedTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/LostShoalRed", AssetRequestMode.ImmediateLoad).Value; - BlueTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/LostShoalBlue", AssetRequestMode.ImmediateLoad).Value; - GoldTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/LostShoalGold", AssetRequestMode.ImmediateLoad).Value; - } NPCID.Sets.CountsAsCritter[Type] = true; } + public override void SetDefaults() { NPC.npcSlots = 0.1f; @@ -62,14 +61,14 @@ namespace CalamityMod.NPCs.SunkenSea NPC.DeathSound = SoundID.NPCDeath6; NPC.noTileCollide = true; NPC.alpha = 120; - //Banner = NPC.type; - //BannerItem = ModContent.ItemType(); + Banner = NPC.type; + BannerItem = ModContent.ItemType(); NPC.chaseable = false; NPC.catchItem = ItemID.AshBlock; // yeah this is intentional NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -188,7 +187,7 @@ namespace CalamityMod.NPCs.SunkenSea if (Role == 0) { // the amount of fish to spawn - int fishCount = 5; + int fishCount = Main.rand.Next(3, 6); for (int i = 0; i < fishCount; i++) { int n = NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); @@ -368,6 +367,8 @@ namespace CalamityMod.NPCs.SunkenSea public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + if (NPC.IsABestiaryIconDummy) + return true; SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; @@ -399,13 +400,13 @@ namespace CalamityMod.NPCs.SunkenSea switch (Variant) { case (int)ShoalColor.Blue: - texture = BlueTexture; + texture = BlueTexture.Value; break; case (int)ShoalColor.Red: - texture = RedTexture; + texture = RedTexture.Value; break; case (int)ShoalColor.Gold: - texture = GoldTexture; + texture = GoldTexture.Value; break; } Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[Type] / 2)); diff --git a/NPCs/SunkenSea/Pearlpod.cs b/NPCs/SunkenSea/Pearlpod.cs index e69ffade75..2c05c81d00 100644 --- a/NPCs/SunkenSea/Pearlpod.cs +++ b/NPCs/SunkenSea/Pearlpod.cs @@ -1,5 +1,4 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Items.Critters; +using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; @@ -10,51 +9,76 @@ using Terraria.GameContent.Bestiary; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; using Terraria.Audio; +using CalamityMod.Enums; +using System.Collections.Generic; +using System; namespace CalamityMod.NPCs.SunkenSea { - public abstract class Pearlpod : ModNPC + public abstract class Pearlpod : SunkenSeaNPC { - public abstract int PearlType { get; } + public enum PhaseType + { + Idle = 0, + Eating = 1, + Fleeing = 2, + Hiding = 3 + } + + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List(); + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.GleamingBurrows | SunkenSeaBiomeFlags.ClamDen; + public abstract float SpawnRate { get; } public abstract int ItemType { get; } + public abstract string GoreName { get; } + + public ref float CurrentPhase => ref NPC.Calamity().newAI[0]; + + public ref float BiteCount => ref NPC.Calamity().newAI[1]; + + public NPC clam => NPC.Calamity().newAI[2] == 0 ? null : Main.npc[(int)NPC.Calamity().newAI[2] - 1]; + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + } + public override void SetDefaults() { + base.SetDefaults(); NPC.aiStyle = NPCAIStyleID.Snail; NPC.damage = 0; - NPC.width = 24; - NPC.height = 24; + NPC.width = 30; + NPC.height = 30; NPC.defense = 0; NPC.lifeMax = 20; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 5, 0); NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; NPC.HitSound = SoundID.NPCHit38; NPC.DeathSound = SoundID.NPCDeath1; NPC.GravityIgnoresLiquid = true; - AIType = NPCID.Snail; - //Banner = NPC.type; - //BannerItem = ModContent.ItemType(); NPC.catchItem = ItemType; NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void ReceiveExtraAI(BinaryReader reader) { - for (int i = 0; i < 2; i++) + for (int i = 0; i < 3; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); } public override void SendExtraAI(BinaryWriter writer) { - for (int i = 0; i < 2; i++) + for (int i = 0; i < 3; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -68,55 +92,252 @@ namespace CalamityMod.NPCs.SunkenSea public override void AI() { - Tile vine = Main.tile[(int)NPC.position.X / 16, (int)NPC.position.Y / 16]; - // Set newAI[0] to 1 if the Pearlpod is inside of a vine - if (vine.TileType == ModContent.TileType() && !NPC.justHit) + bool predatorAvailable = CurrentPredator != null || CurrentPlayer != null; + Tile vine = CalamityUtils.ParanoidTileRetrieval((int)NPC.position.X / 16, (int)NPC.position.Y / 16); + if (CurrentPhase < 2) { - NPC.Calamity().newAI[0] = 1; - } - // Otherwise reset eating-related variables - else - { - NPC.Calamity().newAI[1] = 0; - NPC.Calamity().newAI[0] = 0; - } - // Eating behavior - if (NPC.Calamity().newAI[0] == 1) - { - NPC.velocity.X *= 0.1f; - // Play a crunch sound and spawn some grass dust randomly - if (Main.rand.NextBool(20)) + // Set newAI[0] to 1 if the Pearlpod is inside of a vine + if (vine.TileType == ModContent.TileType() && !NPC.justHit) { - SoundEngine.PlaySound(SoundID.Item2 with { Volume = 0.4f, Pitch = 1.2f }, NPC.Center); - for (int i = 0; i < 4; i++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Grass, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1), 40); - } - NPC.Calamity().newAI[1]++; + CurrentPhase = (int)PhaseType.Eating; } - // After munching 10 times, the vine is broken and the Pearlpod continues about its day - if (NPC.Calamity().newAI[1] == 10) + // Otherwise reset eating-related variables + else { - if (vine.TileType == ModContent.TileType()) - { - WorldGen.KillTile((int)NPC.position.X / 16, (int)NPC.position.Y / 16); - } + BiteCount = 0; + CurrentPhase = (int)PhaseType.Idle; } } - if (NPC.type == ModContent.NPCType()) + + switch (CurrentPhase) { - NPC.ProduceGoldCritterDust(); + // :literallynothing: + case (int)PhaseType.Idle: + { + } + break; + // Eat kelp if found + case (int)PhaseType.Eating: + { + NPC.velocity.X *= 0.1f; + // Play a crunch sound and spawn some grass dust randomly + if (Main.rand.NextBool(20)) + { + SoundEngine.PlaySound(SoundID.Item2 with { Volume = 0.4f, Pitch = 1.2f }, NPC.Center); + for (int i = 0; i < 4; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Grass, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1), 40); + } + BiteCount++; + } + // After munching 10 times, the vine is broken and the Pearlpod continues about its day + if (BiteCount == 10) + { + if (vine.TileType == ModContent.TileType()) + { + WorldGen.KillTile((int)NPC.position.X / 16, (int)NPC.position.Y / 16); + } + } + } + break; + // Run into a clam + case (int)PhaseType.Fleeing: + { + BiteCount = 0; + bool clamValid = IsClamValid(); + // Stop running if the threat is gone + if (!predatorAvailable) + { + CurrentPhase = (int)PhaseType.Idle; + NPC.ShowNameOnHover = true; + ResetClam(); + break; + } + // Look for a clam if the current clam is no longer valid + if (!clamValid) + { + LookForClam(); + } + else + { + // Run boy run! + NPC.velocity.X = NPC.DirectionTo(clam.Center).X.DirectionalSign() * 3; + NPC.direction = NPC.velocity.X.DirectionalSign(); + NPC.StepUpBlocks(); + + // Minimum distances on both axes. Y is higher in case there's a ledge + Vector2 dif = NPC.Center - clam.Center; + bool xClose = Math.Abs(dif.X) < 20; + bool yClose = Math.Abs(dif.Y) < 60; + + // Enter the clam if close enough + if (xClose && yClose) + { + CurrentPhase = (int)PhaseType.Hiding; + } + // If close enough horizontally, but not vertically, jump + else if (xClose && !yClose && NPC.Center.Y < clam.Center.Y && NPC.velocity.Y == 0) + { + NPC.velocity.Y -= 4; + } + } + } + break; + // Hide inside a clam + case (int)PhaseType.Hiding: + { + BiteCount = 0; + bool clamValid = IsClamValid(); + // Exit the clam if the threat is gone + if (!predatorAvailable) + { + CurrentPhase = (int)PhaseType.Idle; + NPC.ShowNameOnHover = true; + ResetClam(); + break; + } + // If the clam is gone, exit the dead clam + if (!clamValid) + { + LookForClam(); + if (!IsClamValid()) + { + CurrentPhase = (int)PhaseType.Idle; + NPC.ShowNameOnHover = true; + ResetClam(); + } + } + // True hiding behaviour + else + { + // Become invisible + if (NPC.Opacity > 0) + NPC.Opacity -= 0.2f; + // When fully invisible lock into the clam's position + if (NPC.Opacity <= 0) + NPC.Center = clam.Center; + NPC.dontTakeDamage = true; + NPC.ShowNameOnHover = false; + } + } + break; + } + // Reset hiding stuff when not in danger + if (CurrentPhase < 2) + { + if (predatorAvailable && !IsClamValid()) + LookForClam(); + } + if (CurrentPhase != (int)PhaseType.Hiding) + { + if (NPC.Opacity < 1) + { + NPC.Opacity += 0.3f; + if (NPC.Opacity > 1) + NPC.Opacity = 1; + } + NPC.dontTakeDamage = false; } } + + /// + /// Puts the clam back into idle state + /// + public void ResetClam() + { + if (IsClamValid()) + { + clam.localAI[2] = 0; + Clam clamMod = clam.ModNPC(); + clamMod.ChangePhase((int)Clam.PhaseType.Idle); + clamMod.ShellRotation = MathHelper.ToRadians(60); + NPC.netUpdate = true; + clam.netUpdate = true; + } + } + + /// + /// Check if a clam is valid to hide in + /// + /// + public bool IsClamValid() + { + if (clam == null || !clam.active || clam.life < 0 || clam.type != ModContent.NPCType() || clam.localAI[2] <= 0 || (clam.ai[0] > 0 && clam.ai[0] < 3)) + { + return false; + } + return true; + } + + /// + /// Look for a clam + /// + public void LookForClam() + { + // Don't bother running the searches if no clams exist + if (NPC.AnyNPCs(ModContent.NPCType())) + { + NPC nearestClam = null; + foreach (NPC n in Main.ActiveNPCs) + { + float dist = Vector2.Distance(NPC.Center, n.Center); + // Find the nearest clam in a 200px radius which the pearlpod is able to see and doesn't already have a pearlpod going after it + if (dist < 200f && NPC.HasSight(n.Center) && n.type == ModContent.NPCType() && n.localAI[2] <= 0 && n.ai[0] == 0) + { + // if no clam has been attached yet and this is the nearest clam, mark it as a candidate + if (nearestClam == null || NPC.Distance(nearestClam.Center) < dist) + { + nearestClam = n; + } + } + } + // if a clam was found, update both NPCs' variables to have them cooperate + if (nearestClam != null) + { + nearestClam.localAI[2] = NPC.whoAmI + 1; + nearestClam.ai[0] = (int)Clam.PhaseType.Pod; + NPC.Calamity().newAI[2] = nearestClam.whoAmI + 1; + nearestClam.netUpdate = true; + NPC.netUpdate = true; + } + } + if (clam != null) + { + clam.localAI[2] = NPC.whoAmI + 1; + } + } + + protected override void OnPlayerDetection(Player player) + { + CurrentPhase = (int)PhaseType.Fleeing; + LookForClam(); + } + + protected override void OnPreyDetection(NPC prey) + { + CurrentPhase = (int)PhaseType.Fleeing; + LookForClam(); + } + + protected override bool NPCSearchFilter(NPC n) + { + return !(CurrentPhase == (int)PhaseType.Hiding && !IsClamValid()) && (base.NPCSearchFilter(n) || n == CurrentPredator && Vector2.DistanceSquared(NPC.Center, n.Center) < 900f * 900f); + } + + protected override bool PlayerSearchFilter(Player p) + { + return !(CurrentPhase == (int)PhaseType.Hiding && !IsClamValid()) && (base.PlayerSearchFilter(p) || p == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, p.Center) < 600f * 600f); + } + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); public override void FindFrame(int frameHeight) { NPC.frameCounter++; - if (NPC.frameCounter > 8) + if (NPC.frameCounter > 6) { NPC.frameCounter = 0; NPC.frame.Y += frameHeight; - if (NPC.frame.Y > frameHeight * 5) + if (NPC.frame.Y > frameHeight * 3) { NPC.frame.Y = 0; } @@ -138,11 +359,7 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Coralstone, hit.HitDirection, -1f, 0, default, 1f); } - } - - public override void ModifyNPCLoot(NPCLoot npcLoot) - { - npcLoot.Add(PearlType); + CalamityUtils.SpawnGores(NPC, GoreName, 3); } } @@ -150,78 +367,56 @@ namespace CalamityMod.NPCs.SunkenSea { public override void SetStaticDefaults() { - Main.npcFrameCount[Type] = 6; + base.SetStaticDefaults(); + Main.npcFrameCount[Type] = 4; + } + public override void SetDefaults() + { + base.SetDefaults(); + Banner = ModContent.NPCType(); + BannerItem = ModContent.ItemType(); } - public override int PearlType => ItemID.WhitePearl; public override float SpawnRate => 0.6f; public override int ItemType => ModContent.ItemType(); + + public override string GoreName => "PearlpodWhite"; } public class PearlpodPink : Pearlpod { public override void SetStaticDefaults() { + base.SetStaticDefaults(); this.HideFromBestiary(); - Main.npcFrameCount[Type] = 6; + Main.npcFrameCount[Type] = 4; } - - public override int PearlType => ItemID.PinkPearl; - public override float SpawnRate => 0.2f; + public override void SetDefaults() + { + base.SetDefaults(); + Banner = ModContent.NPCType(); + BannerItem = ModContent.ItemType(); + } + public override float SpawnRate => 0.05f; public override int ItemType => ModContent.ItemType(); + + public override string GoreName => "PearlpodPink"; } public class PearlpodBlack : Pearlpod { public override void SetStaticDefaults() { + base.SetStaticDefaults(); this.HideFromBestiary(); - Main.npcFrameCount[Type] = 6; - } - public override int PearlType => ItemID.BlackPearl; - public override float SpawnRate => 0.05f; - public override int ItemType => ModContent.ItemType(); - } - public class PearlpodGold : Pearlpod - { - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - Main.npcFrameCount[Type] = 6; + Main.npcFrameCount[Type] = 4; } public override void SetDefaults() { - NPC.aiStyle = NPCAIStyleID.Snail; - NPC.damage = 0; - NPC.width = 24; - NPC.height = 24; - NPC.defense = 0; - NPC.lifeMax = 20; - NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 5, 0); - NPC.lavaImmune = false; - NPC.noGravity = false; - NPC.noTileCollide = false; - NPC.HitSound = SoundID.NPCHit38; - NPC.DeathSound = SoundID.NPCDeath1; - NPC.GravityIgnoresLiquid = true; - AIType = NPCID.Snail; - //Banner = NPC.type; - //BannerItem = ModContent.ItemType(); - NPC.catchItem = ItemType; - NPC.Calamity().VulnerableToHeat = false; - NPC.Calamity().VulnerableToSickness = true; - NPC.Calamity().VulnerableToElectricity = true; - NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - NPC.rarity = 3; - } - public override int PearlType => ItemID.GoldCoin; - public override float SpawnRate => 0.0005f; - public override int ItemType => ModContent.ItemType(); - public override void HitEffect(NPC.HitInfo hit) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GoldCritter, hit.HitDirection, -1f, 0, default, 1f); - } + base.SetDefaults(); + Banner = ModContent.NPCType(); + BannerItem = ModContent.ItemType(); } + public override float SpawnRate => 0.2f; + public override int ItemType => ModContent.ItemType(); + + public override string GoreName => "PearlpodBlack"; } } diff --git a/NPCs/SunkenSea/PearlpodBlack.png b/NPCs/SunkenSea/PearlpodBlack.png index d5712b33f6..405f8278dd 100644 Binary files a/NPCs/SunkenSea/PearlpodBlack.png and b/NPCs/SunkenSea/PearlpodBlack.png differ diff --git a/NPCs/SunkenSea/PearlpodGold.png b/NPCs/SunkenSea/PearlpodGold.png deleted file mode 100644 index e6e92061d2..0000000000 Binary files a/NPCs/SunkenSea/PearlpodGold.png and /dev/null differ diff --git a/NPCs/SunkenSea/PearlpodPink.png b/NPCs/SunkenSea/PearlpodPink.png index 3c54290643..65ffef0598 100644 Binary files a/NPCs/SunkenSea/PearlpodPink.png and b/NPCs/SunkenSea/PearlpodPink.png differ diff --git a/NPCs/SunkenSea/PearlpodWhite.png b/NPCs/SunkenSea/PearlpodWhite.png index 97ccc73385..b23e06f817 100644 Binary files a/NPCs/SunkenSea/PearlpodWhite.png and b/NPCs/SunkenSea/PearlpodWhite.png differ diff --git a/NPCs/SunkenSea/PodobooKoi.cs b/NPCs/SunkenSea/PodobooKoi.cs new file mode 100644 index 0000000000..0278a4280a --- /dev/null +++ b/NPCs/SunkenSea/PodobooKoi.cs @@ -0,0 +1,558 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Pathfinding; +using CalamityMod.Projectiles.Enemy; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class PodobooKoi : SunkenSeaNPC + { + public enum PhaseType + { + Idle = 0, + Flee = 1, + Hunt = 2, + Hostile = 3 + } + public enum VariantType + { + Normal = 0, + Comet = 1, + BubbleEye = 2, + Oranda = 3 + } + + public ref float CurrentVariant => ref NPC.ai[0]; + + public ref float CurrentBehavior => ref NPC.ai[1]; + + public ref float ShootTimer => ref NPC.ai[2]; + + public static int IdleMinPathDistance = 50; + public static int IdleMaxPathDistance = 600; + + public static int FleeTileAnticipationDistance = 28; + + public Vector2 randomPathPoint; + public Vector2 lavaLine = Vector2.Zero; + + public static Asset cometTex; + public static Asset bubbleEyedTex; + public static Asset orandaTex; + + protected override List PreyIDs => new List() + { + ModContent.NPCType() + }; + + protected override List PredatorIDs => new List() + { + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.BasaltGully; + + public override void Load() + { + cometTex = ModContent.Request(Texture + "Comet"); + bubbleEyedTex = ModContent.Request(Texture + "BubbleEyed"); + orandaTex = ModContent.Request(Texture + "Oranda"); + } + + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 15; + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + base.SetDefaults(); + NPC.noGravity = true; + NPC.damage = 30; + NPC.width = 32; + NPC.height = 32; + NPC.defense = 10; + NPC.lifeMax = 1000; + NPC.aiStyle = -1; + AIType = -1; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.lavaImmune = true; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToWater = true; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.PodobooKoi") + }); + } + + public override void OnSpawn(IEntitySource source) + { + // 50% chance to be one of 3 variants + if (Main.rand.NextBool()) + { + CurrentVariant = Main.rand.Next(1, 4); + } + } + + public override void AI() + { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.5f; + MaxSpeed = 4f; + } + if (NPC.ai[3] <= 0) + { + lavaLine = FindLavaLine(); + NPC.ai[3] = 180; + } + NPC.ai[3]--; + NPC.chaseable = false; + if (NPC.lavaWet) + { + switch (CurrentBehavior) + { + case (int)PhaseType.Idle: + IdleBehavior(); + break; + case (int)PhaseType.Flee: + FleeBehavior(); + break; + case (int)PhaseType.Hunt: + HuntBehavior(); + break; + case (int)PhaseType.Hostile: + HostileBehavior(); + break; + } + } + else + { + BeachedBehavior(); + } + if (CurrentBehavior != (int)PhaseType.Hostile) + { + int dir = NPC.velocity.X.DirectionalSign(); + NPC.rotation = NPC.velocity.ToRotation() + (dir == 1 ? 0 : MathHelper.Pi); + NPC.spriteDirection = NPC.direction = dir; + } + } + + public void IdleBehavior() + { + // At random, the mob will choose a random nearby point and pathfind there. + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.Next(IdleMinPathDistance, IdleMaxPathDistance), LavaTileValidityLenient)); + } + + /// + /// Same as LavaTileValidity but without the requirement for a full tile of lava + /// + /// + /// + public bool LavaTileValidityLenient(Point point) + { + Point actualFuckingPoint = new Point(point.X * 16, point.Y * 16); + + return NPC.Hitbox.Contains(actualFuckingPoint) + || !NPC.GetIntersectingHitboxPoints( + actualFuckingPoint, 10, 10).Any(a => Main.tile[a].IsTileSolidGround() || Main.tile[a].LiquidAmount < 25 || Main.tile[a].LiquidType != LiquidID.Lava); + } + + public void FleeBehavior() + { + // If the predator is gone, go back to idling. + if (CurrentPredator == null) + { + CurrentBehavior = (int)PhaseType.Idle; + MaxSpeed = 4; + return; + } + + MaxSpeed = 8; + + // While it doesn't have any obstacles in front of it, run away in a straight line. + // Try to manuever if there are any obstacles. + if (!Main.tile[(NPC.Center + NPC.DirectionFrom(CurrentPredator.Center) * FleeTileAnticipationDistance).ToTileCoordinates()].IsTileSolid()) + { + NPC.velocity += NPC.DirectionFrom(CurrentPredator.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, CurrentPredator.Center); + randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, randomPathPoint, LavaTileValidityLenient)); + } + } + + public void HuntBehavior() + { + if (CurrentPrey == null) + { + MaxSpeed = 4; + CurrentBehavior = (int)PhaseType.Idle; + pathfinding.ClearResults(); + return; + } + MaxSpeed = 8; + pathfinding.DoPathfinding(new(this, NPC.Center, CurrentPrey.Center, LavaTileValidityLenient)); + } + + public void HostileBehavior() + { + // Reset + if (CurrentPlayer == null || !NPC.HasSight(CurrentPlayer.Center)) + { + MaxSpeed = 4; + CurrentBehavior = (int)PhaseType.Idle; + NPC.ai[2] = 0; + pathfinding.ClearResults(); + // Sometimes the fish gets stuck in air, so make it dive down when losing interest + NPC.velocity.Y = 4; + return; + } + + NPC.chaseable = true; + bool noLava = lavaLine == Vector2.Zero; + // If this is true, use its lava behavior + bool useLavaAI = CurrentPlayer.lavaWet && NPC.Distance(CurrentPlayer.Center) < 500; + // If this is true, but the above is not use its "air" behavior. This is set to true provided the fish is close enough to the lava line + bool useAirAI = false; + + // If the player is not in lava + if (lavaLine != Vector2.Zero && !CurrentPlayer.lavaWet) + { + // Use air AI if the fish is close enough to the lava line + useAirAI = NPC.Distance(lavaLine) < 80; + + // If the player is too far from the lava swim towards the player + bool farFromLava = CurrentPlayer.Distance(lavaLine) > 300; + // Distance from the destination the fish needs to be + float distNeeded = farFromLava ? 300 : 40; + + Vector2 destination = farFromLava ? new Vector2(CurrentPlayer.Center.X, lavaLine.Y) : lavaLine; + + // If it's still trying to chase the player, clear the pathfinding results + if (NPC.Calamity().newAI[0] == 1) + { + pathfinding.ClearResults(); + NPC.Calamity().newAI[0] = 0; + } + + // Go to the location if not close enough, otherwise slow down + if (NPC.Distance(destination) > distNeeded) + { + pathfinding.DoPathfinding(new(this, NPC.Center, destination)); + } + else + { + NPC.velocity *= 0.9f; + pathfinding.ClearResults(); + } + } + // If the player is in lava but far from the fish just swim to them + else if (NPC.Distance(CurrentPlayer.Center) > 150) + { + if (NPC.position == NPC.oldPosition) + { + NPC.velocity.Y = 4; + } + MaxSpeed = 6; + pathfinding.DoPathfinding(new(this, NPC.Center, CurrentPlayer.Center, LavaTileValidityLenient)); + // Mark the fish as currently trying to chase the player + NPC.Calamity().newAI[0] = 1; + } + // If the player is in lava and close to the fish just kinda float about + else + { + NPC.SimpleFlyMovement(Main.rand.NextVector2Circular(11, 11), 0.01f); + pathfinding.ClearResults(); + } + + // Normal variants fire basic projectiles + // Orandas fire a projectile that splits into 2 bouncing projectiles + // Bubble Eyes fire a projectile with some quirky homing + // Comet fires a very fast projectile + + int projType = CurrentVariant switch + { + (int)VariantType.Comet => ModContent.ProjectileType(), + (int)VariantType.Oranda => ModContent.ProjectileType(), + (int)VariantType.BubbleEye => ModContent.ProjectileType(), + _ => ModContent.ProjectileType() + }; + + int speed = CurrentVariant switch + { + (int)VariantType.Comet => 18, + (int)VariantType.Oranda => 8, + (int)VariantType.BubbleEye => 8, + _ => 10 + }; + + int fireRate = CurrentVariant switch + { + (int)VariantType.Comet => Main.rand.Next(90, 110), + (int)VariantType.Oranda => Main.rand.Next(70, 100), + (int)VariantType.BubbleEye => Main.rand.Next(80, 120), + _ => Main.rand.Next(50, 80) + }; + + float shotCompletion = Utils.GetLerpValue(0, -30, ShootTimer, true); + int soundFreq = (int)MathHelper.Lerp(10, 5, shotCompletion); + float pitch = MathHelper.Lerp(0, 0.6f, shotCompletion); + // Play bubbly sounds at increasing frequency and pitch + if (ShootTimer < 0 && ShootTimer % soundFreq == 0) + { + SoundEngine.PlaySound(SoundID.Item111 with { Pitch = pitch, MaxInstances = 0 }, NPC.Center); + // Star! + if (CurrentVariant == (int)VariantType.Comet) + { + SoundEngine.PlaySound(SoundID.Item9 with { Pitch = pitch * 0.5f + 0.2f, MaxInstances = 0, Volume = 0.4f }, NPC.Center); + } + } + + // Lava attack, directly shoot at the player + if (useLavaAI) + { + ShootTimer--; + if (ShootTimer < -30) + { + ShootTimer = fireRate; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int p = Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, NPC.SafeDirectionTo(CurrentPlayer.Center, Vector2.UnitY) * speed, projType, NPC.damage, 0); + Main.projectile[p].hostile = true; + Main.projectile[p].friendly = false; + } + } + } + // Air attack, shoot projectiles at the player in arches + else if (useAirAI) + { + MaxSpeed = 4; + ShootTimer--; + + if (ShootTimer <= -40) + { + ShootTimer = fireRate; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int p = Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, NPC.DirectionTo(CurrentPlayer.Center) * speed, projType, NPC.damage, 0, ai0: CurrentPlayer.whoAmI); + } + + for (int i = 0; i < 30; i++) + { + int d = Dust.NewDust(NPC.Center + NPC.DirectionTo(CurrentPlayer.Center) * NPC.width / 2, 10, 10, DustID.InfernoFork, Scale: Main.rand.NextFloat(0.8f, 1.4f)); + Main.dust[d].velocity = (NPC.DirectionTo(CurrentPlayer.Center) * Main.rand.Next(4, 10)).RotatedByRandom(Main.rand.NextFloat(-0.6f, 0.6f)); + Main.dust[d].noGravity = true; + } + + NPC.velocity.X = -NPC.DirectionTo(CurrentPlayer.Center).X * 4; + } + } + else + { + ShootTimer = 0; + } + int dir = NPC.DirectionTo(CurrentPlayer.Center).X.DirectionalSign(); + NPC.rotation = NPC.DirectionTo(CurrentPlayer.Center).ToRotation() + (dir == 1 ? 0 : MathHelper.Pi); + NPC.spriteDirection = NPC.direction = dir; + } + + public Vector2 FindLavaLine() + { + Vector2? tileFoundPosition = null; + Point npcPoint = NPC.Center.ToTileCoordinates(); + for (int i = npcPoint.Y; i > npcPoint.Y - 60; i--) + { + if (!Main.tile[npcPoint.X, i].HasTile && Main.tile[npcPoint.X, i].LiquidAmount < 255) + { + tileFoundPosition = new Point(npcPoint.X, i).ToWorldCoordinates() - Vector2.UnitY * 8; + break; + } + } + + if (tileFoundPosition.HasValue) + return tileFoundPosition.Value; + + return Vector2.Zero; + } + + public void BeachedBehavior() + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X = NPC.velocity.X * 0.94f; + if ((double)NPC.velocity.X > -0.2 && (double)NPC.velocity.X < 0.2) + { + NPC.velocity.X = 0f; + } + } + NPC.velocity.Y = NPC.velocity.Y + 0.3f; + if (NPC.velocity.Y > 10f) + { + NPC.velocity.Y = 10f; + } + NPC.rotation = 0; + } + + protected override bool NPCSearchFilter(NPC n) + { + return base.NPCSearchFilter(n) || n == CurrentPredator && Vector2.DistanceSquared(NPC.Center, n.Center) < 960f * 960f; + } + + protected override bool PlayerSearchFilter(Player p) + { + bool lavaFilter = p.lavaWet && Vector2.DistanceSquared(NPC.Center, p.Center) < 300f * 300f; + bool airFilter = false; + bool alreadyVisible = p == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, p.Center) < 600f * 600f; + if (lavaLine != Vector2.Zero) + { + Vector2 lavaDist = lavaLine - p.Center; + airFilter = !p.lavaWet && p.Center.Y <= lavaLine.Y && MathF.Abs(lavaDist.Y) < 300 && MathF.Abs(lavaDist.X) < 1000; + } + return NPC.HasSight(p.Center) && (lavaFilter || airFilter || alreadyVisible); + } + + protected override void OnPlayerDetection(Player player) + { + if (CurrentBehavior == (int)PhaseType.Idle) + { + CurrentBehavior = (int)PhaseType.Hostile; + lavaLine = FindLavaLine(); + } + } + + protected override void OnPreyDetection(NPC prey) + { + if (CurrentBehavior != (int)PhaseType.Flee) + CurrentBehavior = (int)PhaseType.Hunt; + } + + protected override void OnPredatorDetection(NPC predator) + { + CurrentBehavior = (int)PhaseType.Flee; + } + + public override void FindFrame(int frameHeight) + { + if (!NPC.wet && !NPC.IsABestiaryIconDummy) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = 0; + return; + } + bool shooting = ShootTimer <= -1; + int interval = shooting ? 12 : 6; + NPC.frameCounter++; + if (NPC.frameCounter > interval) + { + NPC.frame.Y++; + NPC.frameCounter = 0; + } + if (shooting) + { + if (NPC.frame.Y < 9) + { + NPC.frame.Y = 9; + } + if (NPC.frame.Y > 14) + { + NPC.frame.Y = 14; + } + } + else + { + if (NPC.frame.Y >= 9) + { + NPC.frame.Y = 0; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = TextureAssets.Npc[Type].Value; + switch (CurrentVariant) + { + case (int)VariantType.Comet: + tex = cometTex.Value; + break; + case (int)VariantType.Oranda: + tex = orandaTex.Value; + break; + case (int)VariantType.BubbleEye: + tex = bubbleEyedTex.Value; + break; + } + float animSped = MathHelper.Lerp(0, 10, Utils.GetLerpValue(0, -40, ShootTimer, true)); + Vector2 scale = Vector2.One + new Vector2(MathF.Cos(Main.GlobalTimeWrappedHourly * animSped), MathF.Sin(Main.GlobalTimeWrappedHourly * animSped)) * 0.05f; + spriteBatch.Draw(tex, NPC.Center - screenPos, tex.Frame(1, 15, 0, NPC.frame.Y), NPC.GetAlpha(drawColor), NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 30), scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + return false; + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Lava, hit.HitDirection, -1f, 0, default, 1f); + } + string goreName = (VariantType)CurrentVariant switch + { + VariantType.Comet => "PodobooKoiComet", + VariantType.Oranda => "PodobooKoiOranda", + VariantType.BubbleEye => "PodobooKoiBubbleEyed", + _ => "PodobooKoi" + }; + CalamityUtils.SpawnGores(NPC, goreName, 2); + } + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(randomPathPoint); + writer.WriteVector2(lavaLine); + writer.Write(NPC.Calamity().newAI[0]); + writer.Write(NPC.chaseable); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + randomPathPoint = reader.ReadVector2(); + lavaLine = reader.ReadVector2(); + NPC.Calamity().newAI[0] = reader.ReadSingle(); + NPC.chaseable = reader.ReadBoolean(); + } + } +} diff --git a/NPCs/SunkenSea/PodobooKoi.png b/NPCs/SunkenSea/PodobooKoi.png new file mode 100644 index 0000000000..a917e63dc3 Binary files /dev/null and b/NPCs/SunkenSea/PodobooKoi.png differ diff --git a/NPCs/SunkenSea/PodobooKoiBubbleEyed.png b/NPCs/SunkenSea/PodobooKoiBubbleEyed.png new file mode 100644 index 0000000000..ca341e7ea7 Binary files /dev/null and b/NPCs/SunkenSea/PodobooKoiBubbleEyed.png differ diff --git a/NPCs/SunkenSea/PodobooKoiComet.png b/NPCs/SunkenSea/PodobooKoiComet.png new file mode 100644 index 0000000000..85350e418e Binary files /dev/null and b/NPCs/SunkenSea/PodobooKoiComet.png differ diff --git a/NPCs/SunkenSea/PodobooKoiOranda.png b/NPCs/SunkenSea/PodobooKoiOranda.png new file mode 100644 index 0000000000..1f11720fca Binary files /dev/null and b/NPCs/SunkenSea/PodobooKoiOranda.png differ diff --git a/NPCs/SunkenSea/PolypPanasea.cs b/NPCs/SunkenSea/PolypPanasea.cs index fb5c240400..9827331ce7 100644 --- a/NPCs/SunkenSea/PolypPanasea.cs +++ b/NPCs/SunkenSea/PolypPanasea.cs @@ -1,37 +1,26 @@ -using CalamityMod.BiomeManagers; -using CalamityMod.Items.Placeables.Banners; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; using CalamityMod.Items.Critters; +using CalamityMod.Items.Potions; +using CalamityMod.Particles; +using CalamityMod.Pathfinding; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; namespace CalamityMod.NPCs.SunkenSea { - public class PolypPanasea : ModNPC + public class PolypPanasea : SunkenSeaNPC { - #region Textures - // Welcome to the fish texture wall, have a nice stay, or just collapse this region, either works - public static Texture2D RadiantTexture; - public static Texture2D GreenTexture; - public static Texture2D PurpleTexture; - public static Texture2D TurquoiseTexture; - public static Texture2D GoldTexture; - public static Texture2D TextureCoated; - public static Texture2D RadiantTextureCoated; - public static Texture2D GreenTextureCoated; - public static Texture2D PurpleTextureCoated; - public static Texture2D TurquoiseTextureCoated; - public static Texture2D GoldTextureCoated; - #endregion - public ref float Variant => ref NPC.ai[1]; public enum FishColor { Red = 0, @@ -41,29 +30,79 @@ namespace CalamityMod.NPCs.SunkenSea Gold = 4, Radiant = 5 } + public enum PhaseType + { + Idle = 0, + Flee = 1, + Hiding = 2 + } + public ref float CurrentBehavior => ref NPC.ai[0]; + public ref float Variant => ref NPC.ai[1]; + public ref float PanaceaTimer => ref NPC.ai[2]; + + #region Textures + // Welcome to the fish texture wall, have a nice stay, or just collapse this region, either works + public static Asset RadiantTexture; + public static Asset GreenTexture; + public static Asset PurpleTexture; + public static Asset TurquoiseTexture; + public static Asset GoldTexture; + public static Asset TextureCoated; + public static Asset RadiantTextureCoated; + public static Asset GreenTextureCoated; + public static Asset PurpleTextureCoated; + public static Asset TurquoiseTextureCoated; + public static Asset GoldTextureCoated; + #endregion + + public int PolypIndex = -1; + + public Vector2 randomPathPoint; + + public static int IdleRandomMovementUnlikeliness = 250; + public static int IdleMinPathDistance = 600; + public static int IdleMaxPathDistance = 1200; + + public static int FleeTileAnticipationDistance = 64; + + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.PolypForest; + + public override void Load() + { + RadiantTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaRadiant"); + GoldTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGold"); + GreenTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGreen"); + PurpleTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaPurple"); + TurquoiseTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaTurquoise"); + TextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaRedCoated"); + RadiantTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaRadiantCoated"); + GoldTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGoldCoated"); + GreenTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGreenCoated"); + PurpleTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaPurpleCoated"); + TurquoiseTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaTurquoiseCoated"); + base.Load(); + } + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 6; - if (!Main.dedServ) - { - RadiantTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaRadiant", AssetRequestMode.ImmediateLoad).Value; - GoldTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGold", AssetRequestMode.ImmediateLoad).Value; - GreenTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGreen", AssetRequestMode.ImmediateLoad).Value; - PurpleTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaPurple", AssetRequestMode.ImmediateLoad).Value; - TurquoiseTexture = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaTurquoise", AssetRequestMode.ImmediateLoad).Value; - TextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaRedCoated", AssetRequestMode.ImmediateLoad).Value; - RadiantTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaRadiantCoated", AssetRequestMode.ImmediateLoad).Value; - GoldTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGoldCoated", AssetRequestMode.ImmediateLoad).Value; - GreenTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaGreenCoated", AssetRequestMode.ImmediateLoad).Value; - PurpleTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaPurpleCoated", AssetRequestMode.ImmediateLoad).Value; - TurquoiseTextureCoated = ModContent.Request("CalamityMod/NPCs/SunkenSea/PolypPanaseaTurquoiseCoated", AssetRequestMode.ImmediateLoad).Value; - } Main.npcCatchable[Type] = true; NPCID.Sets.CountsAsCritter[Type] = true; + base.SetStaticDefaults(); } public override void SetDefaults() { + base.SetDefaults(); NPC.npcSlots = 0.1f; NPC.noGravity = true; NPC.damage = 0; @@ -83,7 +122,6 @@ namespace CalamityMod.NPCs.SunkenSea NPC.Calamity().VulnerableToSickness = false; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void OnSpawn(IEntitySource source) @@ -94,18 +132,18 @@ namespace CalamityMod.NPCs.SunkenSea return; } // Randomize the color of the fish - NPC.ai[1] = Main.rand.Next(0, 4); + Variant = Main.rand.Next(0, 4); // 1 in 30 chance for a rare fish variant (rfv) if (Main.rand.NextBool(30)) { - NPC.ai[1] = Main.rand.Next(4, 6); + Variant = Main.rand.Next(4, 6); } // 1 in 5 chance for a Panasea to be coated if (Main.rand.NextBool(5)) { - NPC.ai[2] = 61; + PanaceaTimer = 61; } - switch (NPC.ai[1]) + switch (Variant) { case (int)FishColor.Purple: NPC.catchItem = ModContent.ItemType(); @@ -117,15 +155,16 @@ namespace CalamityMod.NPCs.SunkenSea NPC.catchItem = ModContent.ItemType(); break; case (int)FishColor.Gold: - { - NPC.catchItem = ModContent.ItemType(); - NPC.rarity = 3; - } + NPC.catchItem = ModContent.ItemType(); break; case (int)FishColor.Radiant: NPC.catchItem = ModContent.ItemType(); break; } + if (Variant == (int)FishColor.Gold || Variant == (int)FishColor.Radiant) + { + NPC.rarity = 3; + } } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -138,19 +177,218 @@ namespace CalamityMod.NPCs.SunkenSea public override void AI() { - CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 3, 60f, 0.2f, 0.1f, 4f, 4f, 0.05f); - NPC.direction = NPC.velocity.X > 0 ? 1 : -1; - NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - NPC.noGravity = true; - // Assure it cant be caught when collecting panacea - if (NPC.ai[2] <= 60 && NPC.ai[2] > 0) + if (pathfinding == null) { - NPC.ai[2]--; + pathfinding = new PathfindingManager(this); + Acceleration = 0.5f; + MaxSpeed = 4f; + } + // Reset polyp index in case the polyp dies + if (PolypIndex > -1) + { + if (Main.npc[PolypIndex].type != ModContent.NPCType() || !Main.npc[PolypIndex].active || Main.npc[PolypIndex].life <= 0 || Main.npc[PolypIndex].Distance(NPC.Center) > 1000) + { + PolypIndex = -1; + } + } + if (NPC.wet) + { + switch (CurrentBehavior) + { + case (int)PhaseType.Idle: + IdleBehavior(); + break; + case (int)PhaseType.Flee: + FleeBehavior(); + break; + case (int)PhaseType.Hiding: + HideBehavior(); + break; + } + } + else + { + BeachedBehavior(); + } + + int dir = NPC.velocity.X.DirectionalSign(); + if (CurrentBehavior != (int)PhaseType.Hiding) + { + NPC.rotation = NPC.velocity.ToRotation() + (dir == 1 ? 0 : MathHelper.Pi); + } + else + { + NPC.rotation = 0; + } + NPC.spriteDirection = NPC.direction = dir; + // Assure it cant be caught when collecting panacea + if (PanaceaTimer <= 60 && PanaceaTimer > 0) + { + PanaceaTimer--; } if (Variant == (int)FishColor.Gold) { NPC.ProduceGoldCritterDust(); - NPC.rarity = 3; + } + } + + public void IdleBehavior() + { + // At random, the mob will choose a random nearby point and pathfind there. + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.Next(100, IdleMaxPathDistance), SunkenSeaTileValidity)); + } + public void HideBehavior() + { + // Once the threat is gone or if the polyp is destroyed, go out of hiding + if (PolypIndex <= -1 || (CurrentPredator == null && Main.rand.NextBool(120))) + { + NPC.dontTakeDamage = false; + CurrentBehavior = (int)PhaseType.Idle; + pathfinding.ClearResults(); + return; + } + + // Become invincible while hiding + NPC.dontTakeDamage = true; + MaxSpeed = 2; + + // At random, the mob will choose a random nearby point and pathfind there. + pathfinding.DoPathfinding(new(this, NPC.Center, Main.npc[PolypIndex].Center + Main.rand.NextVector2Unit() * Main.rand.Next(20, 30), SunkenSeaTileValidity)); + } + + public void FleeBehavior() + { + // If the predator is gone, go back to idling. + if (CurrentPredator == null && PolypIndex <= -1) + { + CurrentBehavior = (int)PhaseType.Idle; + MaxSpeed = 4; + return; + } + + MaxSpeed = 6; + + // If a polyp is found, try to run into it + if (PolypIndex > -1) + { + NPC.netUpdate = true; + Vector2 polypPos = Main.npc[PolypIndex].position; + pathfinding.DoPathfinding(new(this, NPC.Center, polypPos, SunkenSeaTileValidity)); + + if (NPC.Distance(Main.npc[PolypIndex].Center) < 50) + { + CurrentBehavior = (int)PhaseType.Hiding; + pathfinding.ClearResults(); + } + } + // While it doesn't have any obstacles in front of it, run away in a straight line. + // Try to manuever if there are any obstacles. + else if (!Main.tile[(NPC.Center + NPC.DirectionFrom(CurrentPredator.Center) * FleeTileAnticipationDistance).ToTileCoordinates()].IsTileSolid()) + { + NPC.velocity += NPC.DirectionFrom(CurrentPredator.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, CurrentPredator.Center); + randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, randomPathPoint, SunkenSeaTileValidity)); + } + } + + public void BeachedBehavior() + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X = NPC.velocity.X * 0.94f; + if ((double)NPC.velocity.X > -0.2 && (double)NPC.velocity.X < 0.2) + { + NPC.velocity.X = 0f; + } + } + NPC.velocity.Y = NPC.velocity.Y + 0.3f; + if (NPC.velocity.Y > 10f) + { + NPC.velocity.Y = 10f; + } + NPC.ai[0] = 1f; + } + + protected override bool NPCSearchFilter(NPC n) + { + return base.NPCSearchFilter(n) || n == CurrentPredator && Vector2.DistanceSquared(NPC.Center, n.Center) < 1960f * 1960f; + } + + protected override bool PlayerSearchFilter(Player p) + { + return base.PlayerSearchFilter(p) || p == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, p.Center) < 960f * 960f; + } + protected override void OnPredatorDetection(NPC predator) + { + if (CurrentBehavior == (int)PhaseType.Idle) + { + pathfinding?.ClearResults(); + CurrentBehavior = (int)PhaseType.Flee; + AlertPolyp(); + } + } + + public void AlertPolyp() + { + // Look for a nearby polyp to hide in + if (PolypIndex <= -1) + { + foreach (NPC n in Main.ActiveNPCs) + { + bool nCloser = PolypIndex <= -1 ? true : n.Distance(NPC.Center) < Main.npc[PolypIndex].Distance(NPC.Center); + if (n.type == ModContent.NPCType() && nCloser) + { + PolypIndex = n.whoAmI; + } + } + } + // If a polyp is found, cause both NPCs to signal each other with a ! + if (PolypIndex > -1) + { + SoundEngine.PlaySound(SoundID.NPCHit37 with { Pitch = 1 }, NPC.Center); + + if (!Main.dedServ) + { + var emoteDirection = -Vector2.UnitY * Main.rand.NextFloat(2f, 3f); + Particle emote = new EmoteExpressionParticle( + NPC.Center + emoteDirection * 2f, + emoteDirection, + 2.2f, + Color.Red, + Main.rand.Next(30, 46), + EmoteExpressionParticle.EmoteType.Exclamation); + GeneralParticleHandler.SpawnParticle(emote); + Particle emote2 = new EmoteExpressionParticle( + Main.npc[PolypIndex].Center + emoteDirection * 2f, + emoteDirection, + 2.2f, + Color.Yellow, + Main.rand.Next(30, 46), + EmoteExpressionParticle.EmoteType.Exclamation); + GeneralParticleHandler.SpawnParticle(emote2); + } + } + } + + public override void ModifyTypeName(ref string typeName) + { + if (Variant == (int)FishColor.Radiant) + { + typeName = CalamityUtils.GetTextValue("NPCs.RadiantPolypPanasea"); + } + if (Variant == (int)FishColor.Gold) + { + typeName = CalamityUtils.GetTextValue("NPCs.GoldPolypPanasea"); } } @@ -172,7 +410,7 @@ namespace CalamityMod.NPCs.SunkenSea { if (spawnInfo.Player.Calamity().ZonePolypForest && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.CaveJellyfish.Chance * 0.6f; + return SpawnCondition.CaveJellyfish.Chance * 0.8f; } return 0f; } @@ -183,6 +421,17 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); } + if (Variant < (int)FishColor.Gold) + { + string goreName = Variant switch + { + (int)FishColor.Turquoise => "PolypPanaseaTurquoise", + (int)FishColor.Purple => "PolypPanaseaPurple", + (int)FishColor.Green => "PolypPanaseaGreen", + _ => "PolypPanaseaRed", + }; + CalamityUtils.SpawnGores(NPC, goreName, 2); + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { @@ -190,26 +439,28 @@ namespace CalamityMod.NPCs.SunkenSea if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; + bool Coated = PanaceaTimer >= 61; + Texture2D texture = TextureAssets.Npc[Type].Value; switch (Variant) { case (int)FishColor.Radiant: - texture = NPC.ai[2] >= 61 ? RadiantTextureCoated : RadiantTexture; + texture = Coated ? RadiantTextureCoated.Value : RadiantTexture.Value; break; case (int)FishColor.Gold: - texture = NPC.ai[2] >= 61 ? GoldTextureCoated : GoldTexture; + texture = Coated ? GoldTextureCoated.Value : GoldTexture.Value; break; case (int)FishColor.Purple: - texture = NPC.ai[2] >= 61 ? PurpleTextureCoated : PurpleTexture; + texture = Coated ? PurpleTextureCoated.Value : PurpleTexture.Value; break; case (int)FishColor.Green: - texture = NPC.ai[2] >= 61 ? GreenTextureCoated : GreenTexture; + texture = Coated ? GreenTextureCoated.Value : GreenTexture.Value; break; case (int)FishColor.Turquoise: - texture = NPC.ai[2] >= 61 ? TurquoiseTextureCoated : TurquoiseTexture; + texture = Coated ? TurquoiseTextureCoated.Value : TurquoiseTexture.Value; break; case (int)FishColor.Red: - texture = NPC.ai[2] >= 61 ? TextureCoated : TextureAssets.Npc[Type].Value; + texture = Coated ? TextureCoated.Value : TextureAssets.Npc[Type].Value; break; } Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[Type] / 2)); @@ -223,16 +474,34 @@ namespace CalamityMod.NPCs.SunkenSea } public override bool? CanBeCaughtBy(Item item, Player player) { - if (NPC.ai[2] > 0) + if (PanaceaTimer > 0) { - if (NPC.ai[2] > 60) + if (PanaceaTimer > 60) { - Item.NewItem(NPC.GetSource_CatchEntity(NPC), (int)NPC.Center.X, (int)NPC.Center.Y, 1, 1, ItemID.FlaskofPoison); - NPC.ai[2] = 60; + Item.NewItem(NPC.GetSource_CatchEntity(NPC), (int)NPC.Center.X, (int)NPC.Center.Y, 1, 1, ModContent.ItemType()); + PanaceaTimer = 60; } return false; - } + } return null; } + public override bool CanBeHitByNPC(NPC attacker) + { + if (attacker.type == ModContent.NPCType() || attacker.type == ModContent.NPCType()) + return false; + return PredatorIDs.Contains(attacker.type); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(randomPathPoint); + writer.Write(PolypIndex); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + randomPathPoint = reader.ReadVector2(); + PolypIndex = reader.ReadInt32(); + } } } diff --git a/NPCs/SunkenSea/Polyperil.cs b/NPCs/SunkenSea/Polyperil.cs new file mode 100644 index 0000000000..c2b9208795 --- /dev/null +++ b/NPCs/SunkenSea/Polyperil.cs @@ -0,0 +1,210 @@ +using CalamityMod.Enums; +using CalamityMod.Items.Placeables.Banners; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Polyperil : SunkenSeaNPC + { + public ref float Color => ref NPC.ai[1]; + + public ref float Timer => ref NPC.ai[0]; + + public static Asset blueTexture = null; + + public static Asset greenTexture = null; + + public static Asset pinkTexture = null; + + public static Asset voltaicTexture = null; + + // The tentacles do all the work + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List() + { + ModContent.NPCType() + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs | SunkenSeaBiomeFlags.PolypForest; + + public override void Load() + { + pinkTexture = ModContent.Request(Texture + "Pink"); + blueTexture = ModContent.Request(Texture + "Blue"); + greenTexture = ModContent.Request(Texture + "Green"); + voltaicTexture = ModContent.Request(Texture + "Voltaic"); + } + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + base.SetDefaults(); + + NPC.damage = 20; + NPC.lifeMax = 200; + NPC.defense = 10; + NPC.knockBackResist = 0f; + NPC.chaseable = false; + + NPC.aiStyle = -1; + AIType = -1; + NPC.width = 32; + NPC.height = 36; + + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.value = Item.buyPrice(silver: 5); + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.chaseable); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.chaseable = reader.ReadBoolean(); + } + + public override void OnSpawn(IEntitySource source) + { + // Pick a random color + Color = Main.rand.Next(0, 3); + // 1 in 15 chance to be Voltaic + if (Main.rand.NextBool(15)) + Color = 3; + + // Spawn tentacles + int dist = 80; + int tentMin = 3; + int tentMax = 8; + for (int i = 0; i < Main.rand.Next(tentMin, tentMax + 1); i++) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 pos = NPC.Center + new Vector2(Main.rand.Next(-dist, dist), 20); + NPC tent = NPC.NewNPCDirect(NPC.GetSource_FromThis(), NPC.Center, ModContent.NPCType(), ai0: NPC.whoAmI); + tent.ModNPC().anchor = pos; + } + } + } + + public override void AI() + { + Timer++; + NPC.velocity.Y += 10; + + // While out of water, slowly lose health (suffocating) + if (!NPC.wet) + { + if (Timer % 60 == 0) + { + NPC.HitEffect(0, 5); + NPC.life -= 5; + if (NPC.life <= 0) + NPC.life = 1; + } + } + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Coralstone, hit.HitDirection, -1f, 0, default, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 25; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Coralstone, hit.HitDirection, -1f, 0, default, 1f); + } + } + if (Color < 3) + { + string goreName = Color switch + { + 1 => "PolyperilBlue", + 2 => "PolyperilGreen", + _ => "PolyperilPink" + }; + CalamityUtils.SpawnGores(NPC, goreName, 1); + } + } + + public override bool CanBeHitByNPC(NPC attacker) + { + return PredatorIDs.Contains(attacker.type); + } + + public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public void PlayerHurt() + { + NPC.chaseable = true; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + if (spawnInfo.Player.Calamity().ZonePolypForest) + return SpawnCondition.CaveJellyfish.Chance * 0.6f; + + else if (spawnInfo.Player.Calamity().ZoneRadiantReefs) + return SpawnCondition.CaveJellyfish.Chance * 0.05f; + } + return 0f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = Color switch + { + 1 => blueTexture.Value, + 2 => greenTexture.Value, + 3 => voltaicTexture.Value, + _ => pinkTexture.Value + }; + + spriteBatch.Draw(TextureAssets.Npc[Type].Value, NPC.Center - screenPos, null, NPC.GetAlpha(drawColor), NPC.rotation, tex.Size() / 2, NPC.scale, SpriteEffects.None, 0); + + // Desaturate in color when losing health, based on real anemones + float vibrance = MathHelper.Lerp(1, 0, Utils.GetLerpValue(1, 0.33f, NPC.life / (float)NPC.lifeMax, true)); + + spriteBatch.Draw(tex, NPC.Center - screenPos, null, NPC.GetAlpha(drawColor) * vibrance, NPC.rotation, tex.Size() / 2, NPC.scale, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/NPCs/SunkenSea/Polyperil.png b/NPCs/SunkenSea/Polyperil.png new file mode 100644 index 0000000000..5cec975ef0 Binary files /dev/null and b/NPCs/SunkenSea/Polyperil.png differ diff --git a/NPCs/SunkenSea/PolyperilBlue.png b/NPCs/SunkenSea/PolyperilBlue.png new file mode 100644 index 0000000000..4f91afe357 Binary files /dev/null and b/NPCs/SunkenSea/PolyperilBlue.png differ diff --git a/NPCs/SunkenSea/PolyperilGreen.png b/NPCs/SunkenSea/PolyperilGreen.png new file mode 100644 index 0000000000..74a51dcf1c Binary files /dev/null and b/NPCs/SunkenSea/PolyperilGreen.png differ diff --git a/NPCs/SunkenSea/PolyperilPink.png b/NPCs/SunkenSea/PolyperilPink.png new file mode 100644 index 0000000000..9c9747e5dd Binary files /dev/null and b/NPCs/SunkenSea/PolyperilPink.png differ diff --git a/NPCs/SunkenSea/PolyperilTentacle.cs b/NPCs/SunkenSea/PolyperilTentacle.cs new file mode 100644 index 0000000000..b1c2b87f05 --- /dev/null +++ b/NPCs/SunkenSea/PolyperilTentacle.cs @@ -0,0 +1,282 @@ +using CalamityMod.DataStructures; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class PolyperilTentacle : SunkenSeaNPC + { + public ref float ParentIndex => ref NPC.ai[0]; + + public ref float Timer => ref NPC.ai[1]; + + public List Segments; + + // Where the tentacle will hover when not attacking + public Vector2 anchor; + + // They attack everything + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List(); + + // Tentacles are not a natural enemy, they are manually spawned by Polyperils + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.None; + + public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.Polyperil.DisplayName"); + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + base.SetDefaults(); + + NPC.npcSlots = 0f; + NPC.damage = 20; + NPC.lifeMax = 200; + NPC.defense = 0; + NPC.knockBackResist = 0f; + NPC.chaseable = false; + NPC.dontTakeDamage = true; + NPC.noGravity = true; + NPC.noTileCollide = true; + + NPC.aiStyle = -1; + AIType = -1; + NPC.width = 20; + NPC.height = 20; + + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + // Banner = NPC.type; + // BannerItem = ModContent.ItemType(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(anchor.X); + writer.Write(anchor.Y); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + anchor = new Vector2(reader.ReadSingle(), reader.ReadSingle()); + } + + public override void AI() + { + NPC parent = Main.npc[(int)ParentIndex]; + if (parent == null || !parent.active || parent.life < 0 || parent.type != ModContent.NPCType()) + { + NPC.active = false; + return; + } + + // Create a chain + if (Segments == null || Segments.Count < 10) + { + Segments = new List(10); + for (int i = 0; i < 10; i++) + { + VerletSimulatedSegment segment = new VerletSimulatedSegment(parent.Center + Vector2.UnitY * i * 10); + Segments.Add(segment); + } + + Segments[0].locked = true; + Segments[^1].locked = true; + } + Entity targ = CurrentPrey != null ? CurrentPrey : CurrentPlayer; + // While aggro'd, launch at the target then retreat + if (targ != null) + { + // Remain stationary while at rest + if (Timer < 0) + { + NPC.velocity = Vector2.Zero; + } + // Launch + if (Timer == 0) + { + NPC.velocity = NPC.SafeDirectionTo(targ.Center) * 8; + SoundEngine.PlaySound(SoundID.Item152 with { Volume = 1.5f, Pitch = 0.4f }, NPC.Center); + } + // Retreat + if (Timer > 20) + { + NPC.velocity = NPC.SafeDirectionTo(anchor) * 5; + if (Timer == 21) + { + RecalculatePosition(parent.Center); + } + } + // Reset timer + if (Timer > 30 && NPC.Distance(anchor) < 20) + { + NPC.velocity = Vector2.Zero; + Timer = -120; + } + } + // Otherwise hover around the anchor position + else + { + NPC.velocity = NPC.SafeDirectionTo(anchor) * 3; + // Randomly relocate position + if (Timer > 300 && Main.rand.NextBool(180)) + { + RecalculatePosition(parent.Center); + Timer = 0; + } + } + // If the anchor is too far from the parent (usually happens if the parent is moved) recalculate the anchor position + if (anchor.Distance(parent.Center) > 200) + { + RecalculatePosition(parent.Center); + } + + // Repel other tentacles + float SAImovement = 0.05f; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC otherTentacle = Main.npc[k]; + // Short circuits to make the loop as fast as possible + if (!otherTentacle.active || k == NPC.whoAmI || (otherTentacle.type != ModContent.NPCType())) + continue; + + float taxicabDist = Math.Abs(NPC.position.X - otherTentacle.position.X) + Math.Abs(NPC.position.Y - otherTentacle.position.Y); + if (taxicabDist < NPC.width * 1.5f) + { + if (NPC.position.X < otherTentacle.position.X) + NPC.velocity.X -= SAImovement; + else + NPC.velocity.X += SAImovement; + + if (NPC.position.Y < otherTentacle.position.Y) + NPC.velocity.Y -= SAImovement; + else + NPC.velocity.Y += SAImovement; + } + } + NPC.rotation = NPC.DirectionTo(parent.Center).ToRotation(); + + // Update the chain + Segments[0].oldPosition = Segments[0].position; + Segments[0].position = parent.Center; + + Segments[^1].oldPosition = Segments[^1].position; + Segments[^1].position = parent.active ? NPC.Center : parent.Center; + + Segments = VerletSimulatedSegment.SimpleSimulation(Segments, 5, loops: 1, gravity: 0.3f); + + NPC.netUpdate = true; + NPC.netSpam = 0; + + Timer++; + } + + public void RecalculatePosition(Vector2 basePos, int dist = 50) + { + anchor = basePos + new Vector2(Main.rand.Next(-dist, dist), Main.rand.Next(-dist, dist)); + } + + protected override bool PlayerSearchFilter(Player p) + { + return base.PlayerSearchFilter(p) || p == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, p.Center) < 460f * 460f; + } + + protected override bool NPCSearchFilter(NPC n) + { + // The tentacles go after EVERYTHING + return (Vector2.DistanceSquared(NPC.Center, n.Center) < 660f * 660f && n.type != NPC.type && n.type != ModContent.NPCType() && n.type != ModContent.NPCType()); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // Kelpie Seadragons have high resistance to Polyperils as they eat them + if (target.type == ModContent.NPCType()) + { + modifiers.SourceDamage *= 0.05f; + } + } + + public override void ModifyTypeName(ref string typeName) + { + NPC parent = Main.npc[(int)ParentIndex]; + if (parent == null || !parent.active || parent.life < 0 || parent.type != ModContent.NPCType()) + { + return; + } + if (parent.ai[1] == 3) + { + typeName = CalamityUtils.GetTextValue("NPCs.RadiantPolyperil"); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + NPC parent = Main.npc[(int)ParentIndex]; + if (parent == null || !parent.active || parent.life < 0 || parent.type != ModContent.NPCType()) + { + return false; + } + + // Color is based on parent color + Color col = parent.ai[1] switch + { + 1 => new Color(27, 190, 255), + 2 => new Color(7, 255, 180), + 3 => new Color(122, 255, 240), + _ => new Color(255, 140, 248) + }; + + // Desaturate as parent's health lowers + float vibrance = MathHelper.Lerp(1, 0, Utils.GetLerpValue(1, 0.33f, parent.life / (float)parent.lifeMax, true)); + Color final = Color.Lerp(Color.White, col, vibrance); + + Texture2D tex = TextureAssets.Npc[Type].Value; + Rectangle tip = new Rectangle(0, 0, 8, 10); + Rectangle chain = new Rectangle(0, 12, 8, 8); + + if (Segments == null || Segments.Count <= 0) + { + spriteBatch.Draw(tex, NPC.Center - screenPos, tip, drawColor.MultiplyRGB(final), NPC.rotation, new Vector2(4, 10), NPC.scale, SpriteEffects.None, 0); + return false; + } + + // Draw tentacle chains + for (int i = 0; i < Segments.Count - 1; i++) + { + VerletSimulatedSegment seg = Segments[i]; + float dist = i > 0 ? Vector2.Distance(seg.position, Segments[i - 1].position) : 0; + if (dist <= 2) + dist = 2; + dist += 4; + if (i == Segments.Count - 1) + { + dist = Vector2.Distance(seg.position, parent.Center) + 2; + } + float rot = 0f; + if (i > 0) + rot = seg.position.DirectionTo(Segments[i - 1].position).ToRotation(); + SpriteEffects dir = NPC.Center.X > parent.Center.X ? SpriteEffects.FlipVertically : SpriteEffects.None; + spriteBatch.Draw(tex, seg.position - screenPos, chain, drawColor.MultiplyRGB(final), rot + MathHelper.PiOver2, new Vector2(4, 4), new Vector2(1, dist / 8), dir, 0); + } + + // Draw the tip + spriteBatch.Draw(tex, NPC.Center - screenPos, tip, drawColor.MultiplyRGB(final), NPC.rotation - MathHelper.PiOver2, new Vector2(4, 5), NPC.scale, SpriteEffects.None, 0); + return false; + } + } +} diff --git a/NPCs/SunkenSea/PolyperilTentacle.png b/NPCs/SunkenSea/PolyperilTentacle.png new file mode 100644 index 0000000000..b6795c38e8 Binary files /dev/null and b/NPCs/SunkenSea/PolyperilTentacle.png differ diff --git a/NPCs/SunkenSea/PolyperilVoltaic.png b/NPCs/SunkenSea/PolyperilVoltaic.png new file mode 100644 index 0000000000..184d259a00 Binary files /dev/null and b/NPCs/SunkenSea/PolyperilVoltaic.png differ diff --git a/NPCs/SunkenSea/PrismBack.cs b/NPCs/SunkenSea/PrismBack.cs index 1c73fd7386..dfb0d550fc 100644 --- a/NPCs/SunkenSea/PrismBack.cs +++ b/NPCs/SunkenSea/PrismBack.cs @@ -1,54 +1,73 @@ -using System.IO; -using CalamityMod.BiomeManagers; +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Pathfinding; +using CalamityMod.Projectiles.Enemy; +using CalamityMod.Tiles.SunkenSea; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; +using ReLogic.Content; using Terraria; -using Terraria.GameContent; +using Terraria.Audio; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; -using ReLogic.Content; -using CalamityMod.Items.Placeables.SunkenSea; namespace CalamityMod.NPCs.SunkenSea { - public class PrismBack : ModNPC + public class PrismBack : SunkenSeaNPC { public static Asset GlowTexture; + public ref float BiteCount => ref NPC.ai[0]; + public ref float ShardCooldown => ref NPC.ai[1]; + + /// + /// The horizontal coordinate of a located crystal + /// + public ref float TileX => ref NPC.ai[2]; + + /// + /// The vertical coordinate of a located crystal + /// + public ref float TileY => ref NPC.ai[3]; + + public Vector2 tilePosition => new Vector2(TileX, TileY); + protected override List PreyIDs => []; + protected override List PredatorIDs => []; + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs | SunkenSeaBiomeFlags.GleamingBurrows; + + public override void Load() => GlowTexture = ModContent.Request(Texture + "Glow"); public override void SetStaticDefaults() { - Main.npcFrameCount[Type] = 5; + //Main.npcFrameCount[Type] = 5; NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { PortraitPositionXOverride = 0 }; value.Position.X += 15; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } + base.SetStaticDefaults(); } public override void SetDefaults() { + base.SetDefaults(); NPC.noGravity = true; - NPC.damage = Main.hardMode ? 40 : 20; - NPC.width = 72; - NPC.height = 58; - NPC.defense = Main.hardMode ? 25 : 10; - NPC.DR_NERD(0.25f); - NPC.lifeMax = Main.hardMode ? 1000 : 350; + NPC.damage = 20; + NPC.width = 88; + NPC.height = 66; + NPC.defense = 15; + NPC.lifeMax = 500; NPC.aiStyle = -1; AIType = -1; - NPC.value = Main.hardMode ? Item.buyPrice(0, 0, 8, 0) : Item.buyPrice(0, 0, 2, 0); + NPC.value = Item.buyPrice(silver: 2); NPC.HitSound = SoundID.NPCHit24; NPC.DeathSound = SoundID.NPCDeath27; NPC.knockBackResist = 0.15f; @@ -59,11 +78,6 @@ namespace CalamityMod.NPCs.SunkenSea NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -78,7 +92,6 @@ namespace CalamityMod.NPCs.SunkenSea { writer.Write(NPC.chaseable); } - public override void ReceiveExtraAI(BinaryReader reader) { NPC.chaseable = reader.ReadBoolean(); @@ -86,73 +99,102 @@ namespace CalamityMod.NPCs.SunkenSea public override void AI() { - if ((NPC.Center.Y + 10f) > Main.player[NPC.target].Center.Y) + if (pathfinding == null) { - if (CalamityWorld.death) + pathfinding = new PathfindingManager(this); + MaxSpeed = 1.8f; + } + + NPC.spriteDirection = NPC.direction = MathF.Sign(NPC.velocity.X); + Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.75f / 255f, (255 - NPC.alpha) * 0.75f / 255f); + + if (ShardCooldown > 0) + ShardCooldown--; + + Tile t = CalamityUtils.ParanoidTileRetrieval((int)(TileX / 16), (int)(TileY / 16)); + + // TODO + // Change this to kelp when it's added + int tileType = ModContent.TileType(); + + // Assure the kelp still exists, if it's gone, clear the tile + if ((TileX != 0 || TileY != 0) && t.TileType != tileType) + { + TileX = 0; + TileY = 0; + } + + if (NPC.wet) + { + NPC.noGravity = true; + Vector2? tilePos = tilePosition; + // Find kelp + if (Main.rand.NextBool(300)) { - NPC.damage = NPC.defDamage * 3; + if (tilePos == null || tilePos == Vector2.Zero) + { + tilePos = CalamityUtils.NPCTileDetection(NPC, tileType, 300, true); + } } - else if (CalamityWorld.revenge) + + bool eatBehaviour = false; + // Go to the kelp if one exists nearby + if (tilePos != null && tilePos != Vector2.Zero) { - NPC.damage = (int)Math.Round(NPC.defDamage * 2.75); + TileX = tilePos.Value.X; + TileY = tilePos.Value.Y; + t = CalamityUtils.ParanoidTileRetrieval((int)(TileX / 16), (int)(TileY / 16)); + if (t.TileType == tileType) + { + eatBehaviour = true; + // Go to the vine if not far enough + if (tilePos.Value.Distance(NPC.Center) > 40 && BiteCount == 0) + { + pathfinding.DoPathfinding(new(this, NPC.Center, tilePos.Value, SunkenSeaTileValidity)); + } + // Slow down and eat the kelp + else + { + pathfinding.ClearResults(); + NPC.velocity *= 0.97f; + // Play a crunch sound and spawn some grass dust randomly + if (Main.rand.NextBool(50)) + { + SoundEngine.PlaySound(SoundID.Item2 with { Volume = 0.4f, Pitch = -0.4f }, NPC.Center); + for (int i = 0; i < 4; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Grass, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1), 40); + } + BiteCount++; + } + // After munching 5 times, the vine is broken and the turtle continues about its day + if (BiteCount == 5) + { + WorldGen.KillTile((int)TileX / 16, (int)TileY / 16); + TileX = 0; + TileY = 0; + BiteCount = 0; + NPC.netUpdate = true; + } + } + } } - else if (Main.expertMode) + // Just wander about if it's not trying to eat + else if (!eatBehaviour) { - NPC.damage = (int)Math.Round(NPC.defDamage * 2.5); - } - else - { - NPC.damage = (int)Math.Round(NPC.defDamage * 1.25); + TileX = 0; + TileY = 0; + BiteCount = 0; + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(200f, 800f), SunkenSeaTileValidity)); } } else { - if (CalamityWorld.death) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 2.5); - } - else if (CalamityWorld.revenge) - { - NPC.damage = (int)Math.Round(NPC.defDamage * 2.25); - } - else if (Main.expertMode) - { - NPC.damage = NPC.defDamage * 2; - } - else - { - NPC.damage = NPC.defDamage; - } + NPC.noGravity = false; } - Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.75f / 255f, (255 - NPC.alpha) * 0.75f / 255f); - CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 2, 0f, 0f, 0f, 0f, 0f, 0.1f); - } - - public override void FindFrame(int frameHeight) - { - NPC.frameCounter += (NPC.wet || NPC.IsABestiaryIconDummy) ? 0.1f : 0f; - NPC.frameCounter %= Main.npcFrameCount[Type]; - int frame = (int)NPC.frameCounter; - NPC.frame.Y = frame * frameHeight; - } - - public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type] / 2)); - Vector2 vector = center - screenPos; - vector -= new Vector2((float)GlowTexture.Value.Width, (float)(GlowTexture.Value.Height / Main.npcFrameCount[Type])) * 1f / 2f; - vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); - Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Blue); - Main.spriteBatch.Draw(GlowTexture.Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } + public override bool CanBeHitByNPC(NPC attacker) => false; public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) @@ -161,12 +203,35 @@ namespace CalamityMod.NPCs.SunkenSea } return null; } + public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) + { + if ((NPC.Center.Y + 10f) > target.Center.Y) + modifiers.SourceDamage *= CalamityWorld.death ? 3f : CalamityWorld.revenge ? 2.75f : Main.expertMode ? 2.5f : 1.25f; + } + + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) => SpawnShards(player); + public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) => SpawnShards(projectile); + private void SpawnShards(Entity e) + { + if (ShardCooldown > 0) + return; + + ShardCooldown = 20; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < 3; i++) + { + Vector2 shardVel = new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(1.25f) * -1); + Projectile.NewProjectile(NPC.GetSource_OnHurt(e), NPC.Center + Vector2.UnitX * Main.rand.NextFloat(-20f, 20f), shardVel, ModContent.ProjectileType(), 10, 0f, Main.myPlayer, Main.rand.Next(3), NPC.whoAmI); + } + } + } public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + if ((spawnInfo.Player.Calamity().ZoneRadiantReefs || spawnInfo.Player.Calamity().ZoneGleamingBurrows) && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - return SpawnCondition.CaveJellyfish.Chance * 0.9f; + return SpawnCondition.CaveJellyfish.Chance * 0.7f; } return 0f; } @@ -185,19 +250,28 @@ namespace CalamityMod.NPCs.SunkenSea } if (NPC.life <= 0) { - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("PrismTurtleGore1").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("PrismTurtleGore2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("PrismTurtleGore3").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("PrismTurtleGore4").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("PrismTurtleGore5").Type, 1f); - } for (int k = 0; k < 25; k++) { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); } } + CalamityUtils.SpawnGores(NPC, "Prismback", 3); + } + + /*public override void FindFrame(int frameHeight) + { + NPC.frameCounter += (NPC.wet || NPC.IsABestiaryIconDummy) ? 0.1f : 0f; + NPC.frameCounter %= Main.npcFrameCount[Type]; + int frame = (int)NPC.frameCounter; + NPC.frame.Y = frame * frameHeight; + }*/ + + public override void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Rectangle frame = GlowTexture.Value.Frame(1, Main.npcFrameCount[Type], 0, NPC.frame.Y); + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.Blue); + Main.spriteBatch.Draw(GlowTexture.Value, NPC.Center - screenPos, null, color, NPC.rotation, frame.Size() / 2f, 1f, spriteEffects, 0f); } } } diff --git a/NPCs/SunkenSea/PrismBack.png b/NPCs/SunkenSea/PrismBack.png index e0b6fe8eb9..80e7d02a14 100644 Binary files a/NPCs/SunkenSea/PrismBack.png and b/NPCs/SunkenSea/PrismBack.png differ diff --git a/NPCs/SunkenSea/PrismBackGlow.png b/NPCs/SunkenSea/PrismBackGlow.png index 55328bedde..544f81f34b 100644 Binary files a/NPCs/SunkenSea/PrismBackGlow.png and b/NPCs/SunkenSea/PrismBackGlow.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppy.cs b/NPCs/SunkenSea/PrismaticGuppy.cs new file mode 100644 index 0000000000..1d28a5484f --- /dev/null +++ b/NPCs/SunkenSea/PrismaticGuppy.cs @@ -0,0 +1,737 @@ +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; +using CalamityMod.Items.Critters; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Pathfinding; +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class PrismaticGuppy : SunkenSeaNPC + { + public enum PhaseType + { + Idle = 0, + Pawn = 1, + Fleeing = 2, + Hiding = 3 + } + + public enum FishColor + { + Blue = 0, + Green = 1, + Pink = 2, + Gold = 3, + Radiant = 4 + } + + // I do not know what to call the variants, so I'm going on intuition + public enum FishShape + { + Normal = 0, + Cube = 1, + Angel = 2 + } + + /// + /// AI State + /// + public ref float CurrentPhase => ref NPC.ai[0]; + + /// + /// The color to use + /// + public ref float CurrentColor => ref NPC.ai[1]; + + /// + /// The shape to use + /// + public ref float CurrentShape => ref NPC.ai[2]; + + /// + /// The fish's role + /// + public ref float Role => ref NPC.ai[3]; + + /// + /// The index of the guppy that this guppy should follow + /// + public ref float OwnerIndex => ref NPC.localAI[0]; + + /// + /// Timer for handling when the guppy goes out of hiding + /// + public ref float HideTimer => ref NPC.localAI[1]; + + /// + /// The horizontal coordinate of a located crystal + /// + public ref float TileX => ref NPC.localAI[2]; + + /// + /// The vertical coordinate of a located crystal + /// + public ref float TileY => ref NPC.localAI[3]; + + public Vector2 tilePosition => new Vector2(TileX, TileY); + + // Each shape has a different frame count + public int FrameCount => CurrentShape == (int)FishShape.Angel ? 5 : CurrentShape == (int)FishShape.Cube ? 4 : 6; + + public Entity avoidedEntity; + + public Vector2 randomPathPoint; + + public static int IdleRandomMovementUnlikeliness = 250; + public static int IdleMinPathDistance = 600; + public static int IdleMaxPathDistance = 1000; + + public static int FleeTileAnticipationDistance = 64; + + #region Textures + // Welcome to the fish texture wall, have a nice stay, or just collapse this region, either works + public static Asset RadiantTexture; + public static Asset GreenTexture; + public static Asset PinkTexture; + public static Asset GoldTexture; + + public static Asset Texture2; + public static Asset RadiantTexture2; + public static Asset GreenTexture2; + public static Asset PinkTexture2; + public static Asset GoldTexture2; + + public static Asset Texture3; + public static Asset RadiantTexture3; + public static Asset GreenTexture3; + public static Asset PinkTexture3; + public static Asset GoldTexture3; + #endregion + + protected override List PreyIDs => new List() + { + ModContent.NPCType() + }; + + protected override List PredatorIDs => new List() { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs | SunkenSeaBiomeFlags.GleamingBurrows | SunkenSeaBiomeFlags.ClamDen; + + public override void Load() + { + RadiantTexture = ModContent.Request(Texture + "Radiant"); + GoldTexture = ModContent.Request(Texture + "Gold"); + GreenTexture = ModContent.Request(Texture + "Green"); + PinkTexture = ModContent.Request(Texture + "Pink"); + + Texture2 = ModContent.Request(Texture + "2"); + RadiantTexture2 = ModContent.Request(Texture + "Radiant2"); + GoldTexture2 = ModContent.Request(Texture + "Gold2"); + GreenTexture2 = ModContent.Request(Texture + "Green2"); + PinkTexture2 = ModContent.Request(Texture + "Pink2"); + + Texture3 = ModContent.Request(Texture + "3"); + RadiantTexture3 = ModContent.Request(Texture + "Radiant3"); + GoldTexture3 = ModContent.Request(Texture + "Gold3"); + GreenTexture3 = ModContent.Request(Texture + "Green3"); + PinkTexture3 = ModContent.Request(Texture + "Pink3"); + + base.Load(); + } + + public override void SetStaticDefaults() + { + // This is technically redundant as variants handle this + Main.npcFrameCount[Type] = 6; + Main.npcCatchable[Type] = true; + NPCID.Sets.CountsAsCritter[Type] = true; + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + base.SetDefaults(); + NPC.npcSlots = 0f; + NPC.noGravity = true; + NPC.damage = 0; + NPC.width = 28; + NPC.height = 28; + NPC.defense = 0; + NPC.lifeMax = 5; + NPC.aiStyle = -1; + AIType = -1; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.chaseable = false; + NPC.catchItem = (short)ModContent.ItemType(); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.PrismaticGuppy") + }); + } + + public override void OnSpawn(IEntitySource source) + { + NPC.frameCounter = Main.rand.NextFloat(FrameCount); + CurrentShape = Main.rand.Next(0, 3); + // Guppies released by the player do not randomize when spawned + if (source is EntitySource_Parent parentSource && parentSource.Entity is Player) + { + return; + } + // Red/Green in reefs, Green/Blue elsewhere + if (Main.player[NPC.target].Calamity().ZoneRadiantReefs) + { + CurrentColor = Main.rand.Next(1, 3); + } + else + { + CurrentColor = Main.rand.Next(0, 2); + } + NPC.TargetClosest(); + // 1 in 30 chance for a rare fish variant (rfv) + if (Main.rand.NextBool(30)) + { + CurrentColor = Main.rand.Next(3, 5); + NPC.rarity = 3; + } + // Decide item.......................... + switch (CurrentColor) + { + case (int)FishColor.Pink: + NPC.catchItem = ModContent.ItemType(); + break; + case (int)FishColor.Green: + NPC.catchItem = ModContent.ItemType(); + break; + case (int)FishColor.Blue: + NPC.catchItem = ModContent.ItemType(); + break; + case (int)FishColor.Gold: + NPC.catchItem = ModContent.ItemType(); + break; + case (int)FishColor.Radiant: + NPC.catchItem = ModContent.ItemType(); + break; + } + } + public override void AI() + { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.5f; + MaxSpeed = 4f; + } + // Spawn more guppies if a leader/naturally spawned guppy + if (Role == 0 && NPC.releaseOwner == 255) + { + Role = 2; + NPC.TargetClosest(false); + // Spawn a shoal of guppies + int fishCount = Main.rand.Next(2, 4); + // More spawn in the Gleaming Burrows/Clam Den + if (NPC.HasPlayerTarget) + { + if (Main.player[NPC.target].Calamity().ZoneGleamingBurrows || Main.player[NPC.target].Calamity().ZoneClamDen) + fishCount += 5; + } + for (int i = 0; i < fishCount; i++) + { + int n = NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, Type); + Main.npc[n].ai[0] = (int)PhaseType.Pawn; + Main.npc[n].ai[3] = 1; // mark this guppy as a pawn + Main.npc[n].localAI[0] = NPC.whoAmI; // makes the spawned guppy recognize this one as the alpha + Main.npc[n].netUpdate = true; + } + } + NPC owner = Main.npc[(int)OwnerIndex]; + if (NPC.wet) + { + switch (CurrentPhase) + { + // Just do generic pathfinding if a leader. Target prey if one exists + case (int)PhaseType.Idle: + { + Acceleration = 0.5f; + MaxSpeed = 4; + if (CurrentPrey is not null) + pathfinding.DoPathfinding(new(this, NPC.Center, CurrentPrey.Center, SunkenSeaTileValidity)); + else + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.Next(IdleMinPathDistance, IdleMaxPathDistance), SunkenSeaTileValidity)); + } + break; + // The unenlightened masses, They cannot make the judgement call + case (int)PhaseType.Pawn: + { + if (owner == null || !owner.active || owner.type != ModContent.NPCType()) + { + CurrentPhase = (int)PhaseType.Idle; + Role = 2; + break; + } + + if (!owner.active) + return; + + if (NPC.Distance(owner.Center) > 20) + pathfinding.DoPathfinding(new(this, NPC.Center, owner.Center, SunkenSeaTileValidity)); + else + { + float passiveMvtFloat = 0.5f; + float range = 70f; + Vector2 fischPos = NPC.Center; + float xDist = owner.Center.X - fischPos.X; + float yDist = owner.Center.Y - fischPos.Y; + yDist += Main.rand.NextFloat(-10, 20); + xDist += Main.rand.NextFloat(-10, 20); + xDist += 20f * -(float)owner.direction; + Vector2 leaderVector = new Vector2(xDist, yDist); + float leaderDist = leaderVector.Length(); + float returnSpeed = 8f; + //If leader is close enough, resume normal + if (leaderDist < range && owner.velocity.Y == 0f && + NPC.Bottom.Y <= owner.Bottom.Y && + !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + if (NPC.velocity.Y < -6f) + { + NPC.velocity.Y = -6f; + } + } + + if (leaderDist < 50f) + { + if (Math.Abs(NPC.velocity.X) > 2f || Math.Abs(NPC.velocity.Y) > 2f) + { + NPC.velocity *= 0.99f; + } + passiveMvtFloat = 0.01f; + } + else + { + if (leaderDist < 100f) + { + passiveMvtFloat = 0.1f; + } + if (leaderDist > 300f) + { + passiveMvtFloat = 1f; + } + leaderDist = returnSpeed / leaderDist; + leaderVector.X *= leaderDist; + leaderVector.Y *= leaderDist; + } + if (NPC.velocity.X < leaderVector.X) + { + NPC.velocity.X += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.X < 0f) + { + NPC.velocity.X += passiveMvtFloat; + } + } + if (NPC.velocity.X > leaderVector.X) + { + NPC.velocity.X -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.X > 0f) + { + NPC.velocity.X -= passiveMvtFloat; + } + } + if (NPC.velocity.Y < leaderVector.Y) + { + NPC.velocity.Y += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.Y < 0f) + { + NPC.velocity.Y += passiveMvtFloat * 2f; + } + } + if (NPC.velocity.Y > leaderVector.Y) + { + NPC.velocity.Y -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.Y > 0f) + { + NPC.velocity.Y -= passiveMvtFloat * 2f; + } + } + if (NPC.velocity.X >= 0.25f) + { + NPC.direction = -1; + } + else if (NPC.velocity.X < -0.25f) + { + NPC.direction = 1; + } + NPC.spriteDirection = -NPC.direction; + } + + float SAImovement = 0.2f; + for (int k = 0; k < Main.maxNPCs; k++) + { + NPC otherFish = Main.npc[k]; + // Short circuits to make the loop as fast as possible + if (!otherFish.active || k == NPC.whoAmI || otherFish.type != ModContent.NPCType()) + continue; + + float taxicabDist = Math.Abs(NPC.position.X - otherFish.position.X) + Math.Abs(NPC.position.Y - otherFish.position.Y); + if (taxicabDist < NPC.width) + { + if (NPC.position.X < otherFish.position.X) + NPC.velocity.X -= SAImovement; + else + NPC.velocity.X += SAImovement; + + if (NPC.position.Y < otherFish.position.Y) + NPC.velocity.Y -= SAImovement; + else + NPC.velocity.Y += SAImovement; + } + } + } + break; + // Run from predators, attempting to find crystals to camo in + case (int)PhaseType.Fleeing: + { + if (CurrentPredator is not null) + { + Acceleration = 0.6f; + MaxSpeed = 6; + Vector2? tilePos = tilePosition; + + // Find a sea prism + if (tilePos == null || tilePos == Vector2.Zero) + { + tilePos = CalamityUtils.NPCTileDetection(NPC, ModContent.TileType(), 300); + } + + // Go to a Prism Shard if one exists nearby + if (tilePos != null && tilePos != Vector2.Zero) + { + TileX = tilePos.Value.X; + TileY = tilePos.Value.Y; + pathfinding.DoPathfinding(new(this, NPC.Center, tilePos.Value, SunkenSeaTileValiditySizeless)); + if (NPC.Distance(tilePos.Value) < 16) + { + CurrentPhase = (int)PhaseType.Hiding; + NPC.netUpdate = true; + break; + } + } + // While it doesn't have any obstacles in front of it, run away in a straight line. + // Try to manuever if there are any obstacles. + else if (!Main.tile[(NPC.Center + NPC.DirectionFrom(CurrentPredator.Center) * 96).ToTileCoordinates()].IsTileSolid()) + { + NPC.velocity += NPC.DirectionFrom(CurrentPredator.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, CurrentPredator.Center); + randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, randomPathPoint, SunkenSeaTileValidity)); + } + } + else + { + CurrentPhase = (int)PhaseType.Idle; + } + } + break; + // Hide + case (int)PhaseType.Hiding: + { + // Stay still + NPC.rotation = Utils.AngleLerp(NPC.rotation, 0, 0.05f); + NPC.velocity *= 0.95f; + Tile t = CalamityUtils.ParanoidTileRetrieval((int)(TileX / 16), (int)(TileY / 16)); + + // Assure the prism still exists, if the player breaks it, the disguise is gone + if (t.TileType != ModContent.TileType()) + { + CurrentPhase = (int)PhaseType.Idle; + NPC.netUpdate = true; + break; + } + + // Once the coast is clear, wait 2 seconds then go out + if (CurrentPredator is null) + { + HideTimer--; + if (HideTimer <= 0) + { + CurrentPhase = (int)PhaseType.Idle; + NPC.netUpdate = true; + } + } + // Face towards the predator and set the safety timer to 2 seconds + else + { + NPC.direction = NPC.DirectionTo(CurrentPredator.Center).X.DirectionalSign(); + HideTimer = 120; + } + } + break; + } + + NPC.dontTakeDamage = NPC.alpha > 0; + + int dir = NPC.velocity.X.DirectionalSign(); + // Become transparent while hiding and opaque otherwise + if (CurrentPhase != (int)PhaseType.Hiding) + { + NPC.rotation = NPC.velocity.ToRotation() + (dir == 1 ? 0 : MathHelper.Pi); + if (NPC.alpha > 0) + { + NPC.alpha -= 40; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + } + else + { + if (NPC.alpha < 150) + { + NPC.alpha += 10; + } + } + NPC.spriteDirection = NPC.direction = dir; + } + else + { + if (NPC.velocity.Y < 12) + NPC.velocity.Y += 1; + } + + if (Main.rand.NextBool(50)) + { + int dustid = DustID.WhiteTorch; + switch (CurrentColor) + { + case 0: + dustid = DustID.IceTorch; + break; + case 1: + dustid = DustID.CoralTorch; + break; + case 2: + dustid = DustID.PinkTorch; + break; + case 4: + dustid = DustID.BoneTorch; + break; + } + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, dustid, Scale: 1.5f); + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.color *= 0.5f; + dust.noLight = true; + } + + Color c = Color.White; + + switch (CurrentColor) + { + case 0: + c = Color.SkyBlue; + break; + case 1: + c = Color.SeaGreen; + break; + case 2: + c = Color.Pink; + break; + case 4: + c = Color.Cyan; + break; + } + Lighting.AddLight(NPC.Center, c.R / 255f, c.G / 255f, c.B / 255f); + + if (CurrentColor == (int)FishColor.Gold) + { + NPC.ProduceGoldCritterDust(); + } + } + + protected override void OnPredatorDetection(NPC predator) + { + // Don't reset the flee state while hiding + if (CurrentPhase != (int)PhaseType.Hiding) + CurrentPhase = (int)PhaseType.Fleeing; + } + + // Item sprite based on fish + public override void OnCaughtBy(Player player, Item item, bool failed) + { + if (item.ModItem != null) + { + if (item.ModItem is PrismaticGuppyItem gup) + { + if (CurrentShape == (int)FishShape.Cube) + gup.shapeVariant = 1; + + if (CurrentShape == (int)FishShape.Angel) + gup.shapeVariant = 2; + } + } + } + + public override void ModifyTypeName(ref string typeName) + { + if (CurrentColor == (int)FishColor.Radiant) + { + typeName = CalamityUtils.GetTextValue("NPCs.RadiantPrismaticGuppy"); + } + if (CurrentColor == (int)FishColor.Gold) + { + typeName = CalamityUtils.GetTextValue("NPCs.GoldPrismaticGuppy"); + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + if (spawnInfo.Player.Calamity().ZoneGleamingBurrows || spawnInfo.Player.Calamity().ZoneClamDen) + return SpawnCondition.CaveJellyfish.Chance * 0.2f; + if (spawnInfo.Player.Calamity().ZonePolypForest) + return SpawnCondition.CaveJellyfish.Chance * 0.1f; + } + return 0f; + } + + public override void FindFrame(int frameHeight) + { + if ((!NPC.wet && !NPC.IsABestiaryIconDummy) || CurrentPhase == (int)PhaseType.Hiding) + { + NPC.frameCounter = 0.0; + return; + } + NPC.frameCounter++; + if (NPC.frameCounter > 6) + { + NPC.frame.Y++; + NPC.frameCounter = 0; + } + if (NPC.frame.Y >= FrameCount - 1) + { + NPC.frame.Y = 0; + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + // 15 texture variants! + Asset textureAsset; + switch (CurrentColor) + { + case (int)FishColor.Radiant: + textureAsset = CurrentShape == (int)FishShape.Angel ? RadiantTexture3 : CurrentShape == (int)FishShape.Cube ? RadiantTexture2 : RadiantTexture; + break; + case (int)FishColor.Gold: + textureAsset = CurrentShape == (int)FishShape.Angel ? GoldTexture3 : CurrentShape == (int)FishShape.Cube ? GoldTexture2 : GoldTexture; + break; + case (int)FishColor.Green: + textureAsset = CurrentShape == (int)FishShape.Angel ? GreenTexture3 : CurrentShape == (int)FishShape.Cube ? GreenTexture2 : GreenTexture; + break; + case (int)FishColor.Pink: + textureAsset = CurrentShape == (int)FishShape.Angel ? PinkTexture3 : CurrentShape == (int)FishShape.Cube ? PinkTexture2 : PinkTexture; + break; + default: + textureAsset = CurrentShape == (int)FishShape.Angel ? Texture3 : CurrentShape == (int)FishShape.Cube ? Texture2 : TextureAssets.Npc[Type]; + break; + } + Texture2D texture = textureAsset.Value; + Vector2 origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / FrameCount / 2)); + Vector2 npcOffset = NPC.Center - screenPos; + npcOffset -= new Vector2((float)texture.Width, (float)(texture.Height / FrameCount)) * NPC.scale / 2f; + npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Rectangle frame = texture.Frame(1, FrameCount, 0, NPC.frame.Y); + spriteBatch.Draw(texture, npcOffset, frame, NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + return false; + } + + public override void HitEffect(NPC.HitInfo hit) + { + int dustType = DustID.BlueCrystalShard; + switch (CurrentColor) + { + case (int)FishColor.Pink: + dustType = DustID.PinkCrystalShard; + break; + case (int)FishColor.Green: + dustType = DustID.GemEmerald; + break; + case (int)FishColor.Gold: + dustType = DustID.GoldCritter; + break; + } + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, hit.HitDirection, -1f, 0, default, 1f); + } + if (CurrentColor < (int)FishColor.Gold) + { + string goreName = CurrentColor switch + { + (int)FishColor.Pink => "PrismaticGuppyPink", + (int)FishColor.Green => "PrismaticGuppyGreen", + _ => "PrismaticGuppyBlue", + }; + CalamityUtils.SpawnGores(NPC, goreName, 3); + } + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(randomPathPoint); + writer.Write(NPC.localAI[0]); + writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + randomPathPoint = reader.ReadVector2(); + NPC.localAI[0] = reader.ReadSingle(); + NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); + } + } +} diff --git a/NPCs/SunkenSea/PrismaticGuppy.png b/NPCs/SunkenSea/PrismaticGuppy.png new file mode 100644 index 0000000000..8f7a2ebc88 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppy.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppy2.png b/NPCs/SunkenSea/PrismaticGuppy2.png new file mode 100644 index 0000000000..62a654380c Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppy2.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppy3.png b/NPCs/SunkenSea/PrismaticGuppy3.png new file mode 100644 index 0000000000..4ebf0754fe Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppy3.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyGold.png b/NPCs/SunkenSea/PrismaticGuppyGold.png new file mode 100644 index 0000000000..a0e6d461d6 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyGold.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyGold2.png b/NPCs/SunkenSea/PrismaticGuppyGold2.png new file mode 100644 index 0000000000..14b7abe149 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyGold2.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyGold3.png b/NPCs/SunkenSea/PrismaticGuppyGold3.png new file mode 100644 index 0000000000..e4f2a4c278 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyGold3.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyGreen.png b/NPCs/SunkenSea/PrismaticGuppyGreen.png new file mode 100644 index 0000000000..1102a61baf Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyGreen.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyGreen2.png b/NPCs/SunkenSea/PrismaticGuppyGreen2.png new file mode 100644 index 0000000000..17abd52720 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyGreen2.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyGreen3.png b/NPCs/SunkenSea/PrismaticGuppyGreen3.png new file mode 100644 index 0000000000..a57b5a4212 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyGreen3.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyPink.png b/NPCs/SunkenSea/PrismaticGuppyPink.png new file mode 100644 index 0000000000..5abdaad83e Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyPink.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyPink2.png b/NPCs/SunkenSea/PrismaticGuppyPink2.png new file mode 100644 index 0000000000..bb75923212 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyPink2.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyPink3.png b/NPCs/SunkenSea/PrismaticGuppyPink3.png new file mode 100644 index 0000000000..b565f6a0b8 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyPink3.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyRadiant.png b/NPCs/SunkenSea/PrismaticGuppyRadiant.png new file mode 100644 index 0000000000..fb6a898a3c Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyRadiant.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyRadiant2.png b/NPCs/SunkenSea/PrismaticGuppyRadiant2.png new file mode 100644 index 0000000000..f5f4e21964 Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyRadiant2.png differ diff --git a/NPCs/SunkenSea/PrismaticGuppyRadiant3.png b/NPCs/SunkenSea/PrismaticGuppyRadiant3.png new file mode 100644 index 0000000000..ba40e9c3ab Binary files /dev/null and b/NPCs/SunkenSea/PrismaticGuppyRadiant3.png differ diff --git a/NPCs/SunkenSea/Probesnout.cs b/NPCs/SunkenSea/Probesnout.cs index e04e5115a0..e0248b265b 100644 --- a/NPCs/SunkenSea/Probesnout.cs +++ b/NPCs/SunkenSea/Probesnout.cs @@ -3,9 +3,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; -using System.Xml.XPath; using CalamityMod.Enums; +using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Pathfinding; using CalamityMod.Tiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -14,6 +15,7 @@ using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; using static CalamityMod.CalamityUtils; using static Terraria.ModLoader.ModContent; @@ -33,14 +35,14 @@ namespace CalamityMod.NPCs.SunkenSea protected override List PreyIDs => [ - // NPCType(), + NPCType(), ]; protected override List PredatorIDs => [ - // NPCType(), + NPCType(), NPCType(), - // NPCType(), + NPCType(), // NPCType(), // NPCType(), ]; @@ -105,10 +107,6 @@ namespace CalamityMod.NPCs.SunkenSea public Vector2 Velocity { get => NPC.velocity; set => NPC.velocity = value; } - public float Acceleration => 0.4f; - - public float MaxSpeed => 8f; - private Vector2 SpongeFoundPosition; private bool HasEatenSponge; @@ -129,20 +127,25 @@ namespace CalamityMod.NPCs.SunkenSea public override void OnSpawn(IEntitySource source) { + pathfinding = new PathfindingManager(this); + Acceleration = 0.4f; + MaxSpeed = 8f; + MinimumPointDistance = 60f; CurrentBehavior = IdlingBehavior; NPC.spriteDirection = Main.rand.NextBool().ToDirectionInt(); NPC.GravityMultiplier *= 2f; NPC.MaxFallSpeedMultiplier *= 2f; - pathfinding = new PathfindingManager(NPC) - { - Acceleration = 0.4f, - MaxSpeed = 8f, - MinimumPointDistance = 60f - }; } public override void AI() { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.4f; + MaxSpeed = 8f; + MinimumPointDistance = 60f; + } CurrentBehavior?.Invoke(); NPC.rotation = MathHelper.ToRadians(NPC.velocity.X * 3f); @@ -195,8 +198,8 @@ namespace CalamityMod.NPCs.SunkenSea private void IdlingBehavior() { // At random, the mob will choose a random nearby point and pathfind there. - pathfinding.DoPathfinding(new(NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(500f, 3000f), SunkenSeaTileValidity)); - pathfinding.MaxSpeed = 6f; + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(500f, 3000f), SunkenSeaTileValidity)); + MaxSpeed = 6f; } private void FleeingBehavior() @@ -224,8 +227,8 @@ namespace CalamityMod.NPCs.SunkenSea } while (!Main.tile[(NPC.Center + _randomPathPoint).ToTileCoordinates()].IsTileSolid()); NPC.netUpdate = true; - pathfinding.DoPathfinding(new(NPC.Center, NPC.Center + _randomPathPoint, SunkenSeaTileValidity)); - pathfinding.MaxSpeed = 8f; + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + _randomPathPoint, SunkenSeaTileValidity)); + MaxSpeed = 8f; } else { @@ -252,21 +255,8 @@ namespace CalamityMod.NPCs.SunkenSea HuntCooldown = Main.rand.Next(13, 30); // With sight, just go straight at him. Without it, try to pathfind over them. - pathfinding.DoPathfinding(new(NPC.Center, CurrentPrey.Center, tileValidity: SunkenSeaTileValidity), forceNewTask: huntReady); - pathfinding.MaxSpeed = 8f; - pathfinding.CustomIdleBehavior = () => - { - if (CurrentPrey != null) - { - NPC.velocity += NPC.DirectionTo(CurrentPrey.Center) * pathfinding.Acceleration; - - // Cap the speed if MaxSpeed has been surpassed. - if (NPC.velocity.LengthSquared() > pathfinding.MaxSpeed * pathfinding.MaxSpeed) - NPC.velocity = Vector2.Normalize(NPC.velocity) * pathfinding.MaxSpeed; - } - else - NPC.velocity *= 0.95f; - }; + pathfinding.DoPathfinding(new(this, NPC.Center, CurrentPrey.Center, tileValidity: SunkenSeaTileValidity), forceNewTask: huntReady); + MaxSpeed = 8f; HuntCooldown--; } @@ -288,8 +278,8 @@ namespace CalamityMod.NPCs.SunkenSea } else { - pathfinding.DoPathfinding(new(NPC.Center, SpongeFoundPosition, SunkenSeaTileValidity)); - pathfinding.MaxSpeed = 6f; + pathfinding.DoPathfinding(new(this, NPC.Center, SpongeFoundPosition, SunkenSeaTileValidity)); + MaxSpeed = 6f; } } @@ -345,11 +335,28 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, default, 1f); } - if (NPC.life <= 0) + SpawnGores(NPC, "Probesnout", 4); + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override void AwaitingPathBehavior() + { + if (CurrentBehavior == HuntBehavior) { - for (int i = 0; i < 4; i++) - Gore.NewGoreDirect(NPC.GetSource_Death(), NPC.Center, new Vector2(hit.HitDirection, -1f), Mod.Find($"{Name}{i + 1}").Type); + if (CurrentPrey != null) + { + NPC.velocity += NPC.DirectionTo(CurrentPrey.Center) * Acceleration; + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + NPC.velocity *= 0.95f; } + else + base.AwaitingPathBehavior(); } #endregion @@ -398,6 +405,7 @@ namespace CalamityMod.NPCs.SunkenSea { base.SetDefaults(); + Banner = Type; BannerItem = ItemType(); NPC.lifeMax = 5; @@ -411,7 +419,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.catchItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; @@ -419,6 +427,16 @@ namespace CalamityMod.NPCs.SunkenSea NPC.Calamity().VulnerableToWater = false; } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + if (spawnInfo.Player.Calamity().ZoneRadiantReefs) + return SpawnCondition.CaveJellyfish.Chance * 0.3f; + } + return 0f; + } + #endregion #region Syncing @@ -450,6 +468,7 @@ namespace CalamityMod.NPCs.SunkenSea { base.SetDefaults(); NPC.rarity = 3; + NPC.catchItem = ItemType(); } public override void HitEffect(NPC.HitInfo hit) @@ -458,11 +477,16 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GoldCritter, hit.HitDirection, -1f, 0, default, 1f); } - if (NPC.life <= 0) + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) { - for (int i = 0; i < 4; i++) - Gore.NewGoreDirect(NPC.GetSource_Death(), NPC.Center, new Vector2(hit.HitDirection, -1f), Mod.Find($"{Name}{i + 1}").Type); + if (spawnInfo.Player.Calamity().ZoneRadiantReefs) + return SpawnCondition.CaveJellyfish.Chance * 0.05f; } + return 0f; } } } diff --git a/NPCs/SunkenSea/SandProwler.cs b/NPCs/SunkenSea/SandProwler.cs index 3dad2ecb2e..fa0c0e958e 100644 --- a/NPCs/SunkenSea/SandProwler.cs +++ b/NPCs/SunkenSea/SandProwler.cs @@ -1,10 +1,11 @@ -using CalamityMod.BiomeManagers; +using CalamityMod.Enums; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using System; +using System.Collections.Generic; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -14,7 +15,7 @@ using Terraria.ModLoader; using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.SunkenSea { - public class SandProwler : ModNPC + public class SandProwler : SunkenSeaNPC { public const int maxLength = 14; public float speed = 3f; @@ -47,6 +48,20 @@ namespace CalamityMod.NPCs.SunkenSea public ref float CurrentFrame => ref NPC.localAI[0]; public ref float BlinkTimer => ref NPC.localAI[2]; + protected override List PreyIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + }; + + protected override List PredatorIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType() + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.PolypForest; public override void SetStaticDefaults() { @@ -72,10 +87,12 @@ namespace CalamityMod.NPCs.SunkenSea TailSprite = ModContent.Request("CalamityMod/NPCs/SunkenSea/SandProwler9", AssetRequestMode.AsyncLoad); } Main.npcFrameCount[Type] = 11; + base.SetStaticDefaults(); } public override void SetDefaults() { + base.SetDefaults(); NPC.damage = 50; NPC.width = 30; NPC.height = 24; @@ -84,22 +101,22 @@ namespace CalamityMod.NPCs.SunkenSea NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 20, 0); + NPC.value = Item.buyPrice(silver: 20); NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; NPC.netAlways = true; + NPC.chaseable = false; Banner = NPC.type; - BannerItem = ModContent.ItemType(); + BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; NPC.waterMovementSpeed = 1; NPC.GravityIgnoresLiquid = true; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -132,7 +149,7 @@ namespace CalamityMod.NPCs.SunkenSea { if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 204, 0f, 0f, 150, default(Color), 0.3f); + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.TreasureSparkle, 0f, 0f, 150, default(Color), 0.3f); dust.fadeIn = 0.75f; dust.velocity *= 0.1f; dust.noLight = true; @@ -218,40 +235,53 @@ namespace CalamityMod.NPCs.SunkenSea 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); - float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + Entity targ = CurrentPrey != null ? CurrentPrey : Main.player[NPC.target]; + float targetXDist = targ.position.X + (float)(targ.width / 2); + float targetYDist = targ.position.Y + (float)(targ.height / 2); bool coinTarget = false; - // Look for silver and gold coins to eat - for (int i = 0; i < Main.maxItems; i++) + // fucking run if it notices a predator + if (CurrentPredator != null) { - Item item = Main.item[i]; - // continue if not an active silver or gold coin - if (item == null || !item.active || (item.type != ItemID.SilverCoin && item.type != ItemID.GoldCoin)) - continue; - // can only look for coins in a 75 tile radius - if (item.Distance(NPC.Center) > 1200) - continue; - // if its head touches the coin, eat it - if (item.getRect().Intersects(NPC.getRect())) + Vector2 dirToPred = NPC.DirectionTo(CurrentPredator.Center); + targetXDist = -dirToPred.X * 300; + targetYDist = -dirToPred.Y * 300; + currentSpeed *= 2f; + currentTurnSpeed *= 11.5f; + } + else + { + // Look for silver and gold coins to eat + for (int i = 0; i < Main.maxItems; i++) { - SoundEngine.PlaySound(SoundID.Item2 with { Pitch = 1.2f, Volume = 0.8f }, NPC.Center); - SoundEngine.PlaySound(SoundID.CoinPickup, NPC.Center); - int dustType = item.type == ItemID.SilverCoin ? DustID.SilverCoin : DustID.GoldCoin; - for (int j = 0; j < 4; j++) + Item item = Main.item[i]; + // continue if not an active silver or gold coin + if (item == null || !item.active || (item.type != ItemID.SilverCoin && item.type != ItemID.GoldCoin)) + continue; + // can only look for coins in a 75 tile radius + if (item.Distance(NPC.Center) > 1200) + continue; + // if its head touches the coin, eat it + if (item.getRect().Intersects(NPC.getRect())) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1)); + SoundEngine.PlaySound(SoundID.Item2 with { Pitch = 1.2f, Volume = 0.8f }, NPC.Center); + SoundEngine.PlaySound(SoundID.CoinPickup, NPC.Center); + int dustType = item.type == ItemID.SilverCoin ? DustID.SilverCoin : DustID.GoldCoin; + for (int j = 0; j < 4; j++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1)); + } + item.active = false; + break; } - item.active = false; + // if it isn't touching the coin, go to it + targetXDist = item.Center.X; + targetYDist = item.Center.Y; + coinTarget = true; break; } - // if it isn't touching the coin, go to it - targetXDist = item.Center.X; - targetYDist = item.Center.Y; - coinTarget = true; - break; } // aggro on coins takes priority over players - if (NPC.life > NPC.lifeMax * 0.99 && !coinTarget) + if (CurrentPredator == null && (NPC.life > NPC.lifeMax * 0.99 && targ is Player) && !coinTarget) { targetYDist += 300; if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 250f) @@ -273,7 +303,7 @@ namespace CalamityMod.NPCs.SunkenSea BlinkTimer = Main.rand.NextBool(4) ? 48 : 24; } } - else + else if (CurrentPredator == null) { currentSpeed *= 1.5f; currentTurnSpeed *= 1.5f; @@ -306,7 +336,7 @@ namespace CalamityMod.NPCs.SunkenSea float timeToReachTarget = currentSpeed / targetDistance; targetXDist *= timeToReachTarget; targetYDist *= timeToReachTarget; - if (targetDistance < 128 && (NPC.life <= NPC.lifeMax * 0.99 || coinTarget)) + if (targetDistance < 128 && targ is NPC || (NPC.life <= NPC.lifeMax * 0.99 && targ is Player) || coinTarget) { CurrentAnimation = (int)AnimType.Bite; } @@ -429,7 +459,7 @@ namespace CalamityMod.NPCs.SunkenSea bool shouldDespawn = true; for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) + if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType() && Main.npc[i].ai[3] == 0) { shouldDespawn = false; break; @@ -542,7 +572,7 @@ namespace CalamityMod.NPCs.SunkenSea public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (Main.hardMode && spawnInfo.Player.Calamity().ZoneSunkenSea && spawnInfo.Water && + if (Main.hardMode && spawnInfo.Player.Calamity().ZonePolypForest && spawnInfo.Water && !NPC.AnyNPCs(ModContent.NPCType()) && !spawnInfo.Player.Calamity().clamity && !spawnInfo.PlayerSafe) return SpawnCondition.CaveJellyfish.Chance * 0.3f; @@ -554,6 +584,41 @@ namespace CalamityMod.NPCs.SunkenSea return IsHead; } + protected override bool NPCSearchFilter(NPC n) + { + float huntRange = 600f; + float avoidRange = 200f; + bool preyFilter = Vector2.DistanceSquared(NPC.Center, n.Center) < huntRange * huntRange && PreyIDs.Contains(n.type); + bool predFilter = Vector2.DistanceSquared(NPC.Center, n.Center) < avoidRange * avoidRange && PredatorIDs.Contains(n.type); + bool hidingGuppy = n.type == ModContent.NPCType() && n.alpha > 0; + return !hidingGuppy && (preyFilter || predFilter); + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override bool CanHitNPC(NPC target) + { + return IsHead; + } + + public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public void PlayerHurt() + { + if (IsHead) + NPC.chaseable = true; + else + Main.npc[NPC.realLife].chaseable = true; + } + public override void ModifyNPCLoot(NPCLoot npcLoot) => DefineSandProwlerLoot(npcLoot); public static void DefineSandProwlerLoot(NPCLoot npcLoot) diff --git a/NPCs/SunkenSea/SandProwlerNested.cs b/NPCs/SunkenSea/SandProwlerNested.cs index 0dd6be46cb..8a95c7e615 100644 --- a/NPCs/SunkenSea/SandProwlerNested.cs +++ b/NPCs/SunkenSea/SandProwlerNested.cs @@ -1,26 +1,21 @@ -using System; -using CalamityMod.BiomeManagers; -using CalamityMod.DataStructures; +using CalamityMod.DataStructures; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; using System.IO; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Utilities; using Terraria.GameContent.Bestiary; -using CalamityMod.NPCs.Crags; +using CalamityMod.Enums; namespace CalamityMod.NPCs.SunkenSea { - public class SandProwlerNested : ModNPC + public class SandProwlerNested : SunkenSeaNPC { public bool PeekingOut; public bool HasChosenSpotToHideIn => SpotToHideIn != Vector2.Zero; @@ -52,6 +47,19 @@ namespace CalamityMod.NPCs.SunkenSea public ref float InitialSnapDirection => ref NPC.localAI[1]; public ref float CurrentSnapDirection => ref NPC.localAI[2]; public override string Texture => "CalamityMod/NPCs/SunkenSea/SandProwler"; + protected override List PreyIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + }; + + protected override List PredatorIDs => new List() + { + ModContent.NPCType() + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.PolypForest; public override void SetStaticDefaults() { @@ -61,6 +69,7 @@ namespace CalamityMod.NPCs.SunkenSea NPCID.Sets.UsesNewTargetting[Type] = true; NPCID.Sets.CantTakeLunchMoney[Type] = true; Main.npcFrameCount[Type] = 11; + base.SetStaticDefaults(); } public override void SetDefaults() @@ -73,24 +82,20 @@ namespace CalamityMod.NPCs.SunkenSea NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - NPC.value = Item.buyPrice(0, 0, 20, 0); + NPC.value = Item.buyPrice(silver: 20); NPC.behindTiles = true; NPC.noGravity = true; NPC.noTileCollide = true; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; + NPC.chaseable = false; NPC.netAlways = true; - Banner = NPC.type; - BannerItem = ModContent.ItemType(); + Banner = ModContent.NPCType(); + BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToWater = false; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; - - // Scale stats in Expert and Master - CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC); - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC); NPC.waterMovementSpeed = 1f; } @@ -110,6 +115,7 @@ namespace CalamityMod.NPCs.SunkenSea writer.Write(InitialSnapDirection); writer.Write(CurrentSnapDirection); writer.Write(NPC.Calamity().newAI[1]); + writer.Write(NPC.chaseable); } public override void ReceiveExtraAI(BinaryReader reader) @@ -119,6 +125,7 @@ namespace CalamityMod.NPCs.SunkenSea InitialSnapDirection = reader.ReadSingle(); CurrentSnapDirection = reader.ReadSingle(); NPC.Calamity().newAI[1] = reader.ReadSingle(); + NPC.chaseable = reader.ReadBoolean(); } public override void AI() @@ -188,16 +195,8 @@ namespace CalamityMod.NPCs.SunkenSea { if (NPC.life > NPC.lifeMax * 0.99f) { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC n = Main.npc[i]; - if (n == null || !n.active || n.type != ModContent.NPCType()) - continue; - if (n.Distance(NPC.Center) <= 300 && Collision.CheckAABBvLineCollision(NPC.Center, NPC.Size, NPC.Center, n.Center)) - { - target = n; - } - } + if (CurrentPrey != null) + target = CurrentPrey; } // If you've pissed it off, it now goes after YOU else @@ -224,7 +223,7 @@ namespace CalamityMod.NPCs.SunkenSea // Also emit some particle effects as an indicator. if (InHidingSpot) { - Dust sparkle = Dust.NewDustDirect(TileCoordsToHideIn.ToWorldCoordinates(0, 0), 16, 16, 261); + Dust sparkle = Dust.NewDustDirect(TileCoordsToHideIn.ToWorldCoordinates(0, 0), 16, 16, DustID.AncientLight); sparkle.color = Color.Orange; sparkle.velocity = Main.rand.NextVector2Circular(4f, 4f); sparkle.noGravity = true; @@ -341,6 +340,21 @@ namespace CalamityMod.NPCs.SunkenSea } } + public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public void PlayerHurt() + { + NPC.chaseable = true; + } + public override void FindFrame(int frameHeight) { if (NPC.Calamity().newAI[1] == 1) @@ -439,6 +453,12 @@ namespace CalamityMod.NPCs.SunkenSea } return false; } + protected override bool NPCSearchFilter(NPC n) + { + return Vector2.DistanceSquared(NPC.Center, n.Center) < 200f * 200f && (PreyIDs.Contains(n.type) || PredatorIDs.Contains(n.type)); + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); public override bool CanHitPlayer(Player target, ref int cooldownSlot) { diff --git a/NPCs/SunkenSea/Scavenger.cs b/NPCs/SunkenSea/Scavenger.cs new file mode 100644 index 0000000000..a3875226c1 --- /dev/null +++ b/NPCs/SunkenSea/Scavenger.cs @@ -0,0 +1,999 @@ +using CalamityMod.BiomeManagers; +using CalamityMod.Enums; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.Critters; +using CalamityMod.Items.Fishing.SunkenSeaCatches; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; +using Terraria.Utilities; +using CalamityMod.Items.Placeables.Banners; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Scavenger : SunkenSeaNPC + { + public record ScavengerItem(int itemID, int minimum, int maximum, Func condition); + + public static Asset walkTexture; + + public static Asset inspectTexture; + + public static Asset giveTexture; + + public static Dictionary> ScavengerLoot = new Dictionary>() + { + { ItemID.WhitePearl, new WeightedRandom() }, + { ItemID.BlackPearl, new WeightedRandom() }, + { ItemID.PinkPearl, new WeightedRandom() }, + { ModContent.ItemType(), new WeightedRandom() }, + { ModContent.ItemType(), new WeightedRandom() }, + { ModContent.ItemType(), new WeightedRandom() }, + { ItemID.GalaxyPearl, new WeightedRandom() }, + { ModContent.ItemType(), new WeightedRandom() }, + }; + + public enum PhaseType + { + Idle = 0, + FoundItem = 1, + Bartering = 2, + Burrow = 3 + } + + // The in world index of the item the crab is going after + public int HeldItemIndex + { + get => (int)NPC.ai[1] - 1; + set => NPC.ai[1] = value + 1; + } + + // The type of currency the crab is currently holding + public int HeldItemType + { + get => (int)NPC.ai[2]; + set => NPC.ai[2] = value; + } + + // The crab's current behaviour + public ref float Phase => ref NPC.ai[0]; + + // Used during trading and as a cooldown + public ref float TradeTimer => ref NPC.ai[3]; + + public ref float WalkTimer => ref NPC.Calamity().newAI[0]; + + public ref float TurnTimer => ref NPC.Calamity().newAI[1]; + + public ref float WalkOrStand => ref NPC.Calamity().newAI[2]; + + public ref float StackMin => ref NPC.localAI[0]; + + public ref float StackMax => ref NPC.localAI[1]; + + public ref float OldItemType => ref NPC.localAI[2]; + + public bool ShouldUseWalkingFrames => NPC.velocity.X != 0 && ((WalkOrStand == 1 && Phase == (int)PhaseType.Idle) || (Phase == (int)PhaseType.FoundItem)); + + public bool ShouldUseInspectionFrames => Phase == (int)PhaseType.Bartering && TradeTimer < 80; + + public bool ShouldUseGivingFrames => Phase == (int)PhaseType.Bartering && TradeTimer >= 80; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.TimelessShores; + + protected override List PreyIDs => new List + { + + }; + + protected override List PredatorIDs => new List + { + ModContent.NPCType(), + ModContent.NPCType() + }; + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + Main.npcFrameCount[NPC.type] = 1; + NPCID.Sets.CantTakeLunchMoney[Type] = true; + Main.npcFrameCount[Type] = 7; + + InitializeScavengerLoot(); + + if (!Main.dedServ) + { + walkTexture = ModContent.Request(Texture + "Walking"); + inspectTexture = ModContent.Request(Texture + "Inspecting"); + giveTexture = ModContent.Request(Texture + "Giving"); + } + } + + #region Trades + + public static void InitializeScavengerLoot() + { + int white = ItemID.WhitePearl; + int black = ItemID.BlackPearl; + int pink = ItemID.PinkPearl; + int minBlock = 6; + int maxBlock = 17; + float coralBlockChance = 0.1f; + + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ItemID.WoodenCrate, 1, () => !Main.hardMode, 0.1f); + AddScavengerItem(white, ItemID.WoodenCrateHard, 1, () => Main.hardMode, 0.1f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.1f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.1f); + AddScavengerItem(white, ItemID.ScarabBomb, 3, 10, 0.1f); + AddScavengerItem(white, ItemID.Coral, 3, 10, 0.2f); + AddScavengerItem(white, ItemID.Starfish, 3, 10, 0.2f); + AddScavengerItem(white, ItemID.Seashell, 3, 10, 0.2f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.05f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.05f); + // Critters. Golds, Radiants, Pearlpods and any Basalt Gully/Timeless Shore critters are to be excluded + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.05f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + + AddScavengerItem(black, ModContent.ItemType(), 1, () => !Main.hardMode, 0.1f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.PirateMap, 1, () => Main.hardMode, 0.05f); + AddScavengerItem(black, ItemID.IronCrate, 1, () => !Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.IronCrateHard, 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.GoldenCrate, 1, () => !Main.hardMode, 0.02f); + AddScavengerItem(black, ItemID.GoldenCrateHard, 1, () => Main.hardMode, 0.02f); + AddScavengerItem(black, ItemID.WaterWalkingBoots, 1, 0.05f); + AddScavengerItem(black, ItemID.FishingBobber, 1, 0.05f); + AddScavengerItem(black, ItemID.JellyfishNecklace, 1, 0.05f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.05f); + //AddScavengerItem(black, ItemID.Nachos, 1, 0.05f); insert food item + AddScavengerItem(black, ModContent.ItemType(), 1, () => DownedBossSystem.downedDesertScourge, 0.3f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => DownedBossSystem.downedDesertScourge, 0.3f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.FinWings, 1, () => Main.hardMode, 0.1f); + + AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + AddScavengerItem(pink, ModContent.ItemType(), 1); + AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + AddScavengerItem(white, ModContent.ItemType(), 1, () => Main.hardMode); + AddScavengerItem(white, ModContent.ItemType(), 1, () => Main.hardMode); + + // Pearlpods can be used as a substitute for pearls + ScavengerLoot[ModContent.ItemType()] = ScavengerLoot[white]; + ScavengerLoot[ModContent.ItemType()] = ScavengerLoot[black]; + ScavengerLoot[ModContent.ItemType()] = ScavengerLoot[pink]; + + ScavengerLoot[ItemID.GalaxyPearl] = ScavengerLoot[white]; // Gives 1-2x the amount of white items + ScavengerLoot[ModContent.ItemType()] = ScavengerLoot[pink]; // Gives 2 pink items + + } + + #region Loot adding methods + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// The minimum amount to drop + /// The maximum amount to drop + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int min, int max, float weight = 1) + { + AddScavengerItem(currency, itemID, min, max, () => true, weight); + } + + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// How much should drop + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int amount, float weight = 1) + { + AddScavengerItem(currency, itemID, amount, amount, () => true, weight); + } + + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// How much should drop + /// A condition + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int amount, Func condition, float weight = 1) + { + AddScavengerItem(currency, itemID, amount, amount, condition, weight); + } + + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// The minimum amount to drop + /// The maximum amount to drop + /// A condition + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int min, int max, Func condition, float weight = 1) + { + if (ScavengerLoot.ContainsKey(currency)) + { + ScavengerLoot[currency].Add(new ScavengerItem(itemID, min, max, condition), weight); + } + else + { + ScavengerLoot.Add(currency, new WeightedRandom()); + ScavengerLoot[currency].Add(new ScavengerItem(itemID, min, max, condition), weight); + } + } + #endregion + #endregion + + public override void SetDefaults() + { + base.SetDefaults(); + NPC.damage = 20; + NPC.width = 48; + NPC.height = 48; + NPC.defense = 5; + NPC.lifeMax = 350; + NPC.aiStyle = -1; + AIType = -1; + NPC.value = Item.buyPrice(silver: 5); + NPC.HitSound = SoundID.NPCHit38; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.knockBackResist = 0.15f; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.chaseable = false; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Scavenger") + }); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.localAI[0] = reader.ReadSingle(); + NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.Calamity().newAI[0] = reader.ReadSingle(); + NPC.Calamity().newAI[1] = reader.ReadSingle(); + NPC.Calamity().newAI[2] = reader.ReadSingle(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.localAI[0]); + writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.Calamity().newAI[0]); + writer.Write(NPC.Calamity().newAI[1]); + writer.Write(NPC.Calamity().newAI[2]); + } + + public override void AI() + { + // Check to make sure the target item still exists + if (HeldItemIndex > 0) + { + Item targetItem = Main.item[HeldItemIndex]; + // If the item doesn't exist, reset its held item + if (targetItem == null || !targetItem.active) + { + HeldItemIndex = -1; + } + } + + // Initialize its direction + if (NPC.direction == 0) + NPC.direction = Main.rand.NextBool() ? -1 : 1; + + switch (Phase) + { + // Do idle stuff, actual behavior not determined rn + case (int)PhaseType.Idle: + { + // Decide if it should walk or sit + float movementSpeed = CurrentPrey != null || CurrentPredator != null ? 2 : 1; + bool startMovement = false; + if (WalkTimer <= 0) + { + WalkTimer = Main.rand.Next(180, 340); + WalkOrStand = WalkOrStand <= 0 ? 1 : -1; + if (WalkOrStand == 1 && Main.rand.NextBool() && CurrentPrey == null) + { + NPC.direction *= -1; + } + if (CurrentPrey != null) + { + NPC.direction = (int)(CurrentPrey.Center.X - NPC.Center.X); + } + startMovement = true; + } + bool lookingAtPredator = CurrentPredator != null && NPC.direction == Math.Sign(CurrentPredator.Center.X - NPC.Center.X); + bool waterCheck = WaterCheck(16); + // If it bumps into something, jump or turn around + if ((!startMovement && TurnTimer <= 0 && (NPC.velocity.X == 0 || waterCheck) && WalkOrStand == 1) || lookingAtPredator) + { + // Jump if there are a couple tiles and a space above + if (!waterCheck && JumpCheck() && NPC.velocity.Y == 0 && !lookingAtPredator) + { + NPC.velocity.Y -= 7; + NPC.velocity.X = movementSpeed * NPC.direction; + WalkOrStand = 1; + TurnTimer = 10; + } + // Turn around if it can't jump up or a pit/water is in the way + else + { + NPC.direction *= -1; + TurnTimer = 30; + } + } + // Move + if (!NPC.justHit) + { + if (WalkOrStand == 1) + NPC.velocity.X = MathHelper.Lerp(NPC.velocity.X, NPC.direction * movementSpeed, 0.05f); + else if (NPC.velocity.Y == 0) + NPC.velocity.X *= 0.95f; + } + else if (WalkOrStand == -1) + { + WalkTimer = 0; + if (CurrentPredator != null) + { + WalkOrStand = 1; + WalkTimer = Main.rand.Next(180, 340); + } + } + CalamityUtils.StepUpBlocks(NPC); + + // If the trade timer is 0 and the crab isn't looking ofr an item, look for an item + if (TradeTimer >= 0 && HeldItemIndex <= -1 && CurrentPredator == null) + { + float curDist = 0; + bool superRare = false; + foreach (Item i in Main.ActiveItems) + { + if (!i.active) + continue; + if (i.beingGrabbed) + continue; + float distance = i.Distance(NPC.Center); + if (distance > 460) + continue; + if (!NPC.HasSight(i.Center)) + continue; + if (Math.Abs(NPC.Center.Y - i.Center.Y) > 100) + continue; + + // Check if the item is a valid currency and is the closest possible currency + if (ScavengerLoot.ContainsKey(i.type)) + { + if (distance < curDist || curDist == 0) + { + HeldItemIndex = i.whoAmI; + superRare = i.type > ItemID.PinkPearl ? true : false; + } + curDist = distance; + } + } + // If an item was found, go after it + if (curDist != 0) + { + NPC.netUpdate = true; + Phase = (int)PhaseType.FoundItem; + TurnTimer = 0; + WalkTimer = 0; + if (NPC.velocity.Y == 0) + NPC.velocity.Y = -5; + NPC.direction = NPC.DirectionTo(Main.item[HeldItemIndex].Center).X.DirectionalSign(); + + SoundEngine.PlaySound(SoundID.NPCHit51 with { Pitch = -0.4f }, NPC.Center); + + EmoteExpressionParticle.EmoteType eType = superRare ? EmoteExpressionParticle.EmoteType.DoubleExclamation : EmoteExpressionParticle.EmoteType.Exclamation; + + var emoteDirection = -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(2f, 3f); + Particle emote = new EmoteExpressionParticle( + NPC.Center + emoteDirection * 2f, + emoteDirection, + 2.2f, + Color.YellowGreen, + Main.rand.Next(30, 46), + eType); + GeneralParticleHandler.SpawnParticle(emote); + } + } + // Increment the trade timer back to zero if it is below zero + if (TradeTimer < 0) + TradeTimer++; + } + break; + // Go to the item + case (int)PhaseType.FoundItem: + { + // If the item is no longer valid, go back to idle behaviour + if (HeldItemIndex <= -1 || CurrentPredator != null) + { + NPC.netUpdate = true; + Phase = (int)PhaseType.Idle; + HeldItemIndex = -1; + TurnTimer = 0; + WalkTimer = 0; + return; + } + + // If the item is suddenly no longer valid for some reason, go back to idle behaviour + Item targetItem = Main.item[HeldItemIndex]; + if (!targetItem.active || !ScavengerLoot.ContainsKey(targetItem.type)) + { + NPC.netUpdate = true; + targetItem.noGrabDelay = 0; + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, targetItem.whoAmI, 0f, 0f, 0f, 0, 0, 0); + } + HeldItemIndex = -1; + NPC.velocity = Vector2.Zero; + Phase = (int)PhaseType.Idle; + TurnTimer = 0; + WalkTimer = 0; + break; + } + + // Once the jump anim is done, go to the pearl + if (WalkTimer > 0) + { + float movementSpeed = 3; + bool waterCheck = WaterCheck(16); + // If it bumps into something, jump or turn around + if (TurnTimer <= 0 && (NPC.velocity.X == 0 || waterCheck) && NPC.velocity.Y == 0) + { + // Jump if there are a couple tiles and a space above + if (!waterCheck && JumpCheck()) + { + NPC.velocity.Y -= 8; + NPC.velocity.X = movementSpeed * NPC.direction; + TurnTimer = 10; + } + // Turn around if it can't jump up or a pit/water is in the way + else + { + NPC.direction *= -1; + TurnTimer = 30; + NPC.netUpdate = true; + targetItem.noGrabDelay = 0; + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, targetItem.whoAmI, 0f, 0f, 0f, 0, 0, 0); + } + HeldItemIndex = -1; + Phase = (int)PhaseType.Idle; + TurnTimer = 0; + WalkTimer = 0; + } + } + // Change direction if the item position changed + bool itemOnRight = targetItem.Center.X > NPC.Center.X; + if (itemOnRight && NPC.direction == -1) + { + NPC.direction *= -1; + } + else if (!itemOnRight && NPC.direction == 0) + { + NPC.direction *= -1; + } + TurnTimer--; + + NPC.velocity.X = NPC.direction * movementSpeed; + CalamityUtils.StepUpBlocks(NPC); + } + // While the jump animation is occurring, slow down horizontally + else + { + NPC.velocity.X *= 0.95f; + } + // Marks if the jump animation is finished + if (NPC.velocity.Y == 0) + { + WalkTimer++; + } + + // Pull the item if close enough + if (targetItem.Distance(NPC.Center) < 120) + { + targetItem.noGrabDelay = 100; + targetItem.velocity = targetItem.DirectionTo(NPC.Center) * 5; + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, targetItem.whoAmI, 0f, 0f, 0f, 0, 0, 0); + } + } + // Grab the item if close enough + if (targetItem.Distance(NPC.Center) < 10) + { + Phase = (int)PhaseType.Bartering; + // If the item's stack is 1, despawn the item. Otherwise decrement its stack by 1. + if (targetItem.stack == 1) + targetItem.active = false; + else + targetItem.stack--; + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, targetItem.whoAmI, 1, 0f, 0f, 0, 0, 0); + } + // Set the crab's held item type + HeldItemType = targetItem.type; + TurnTimer = 0; + WalkTimer = 0; + NPC.netUpdate = true; + } + } + break; + // Ponder the held item then give a reward back + case (int)PhaseType.Bartering: + { + if (CurrentPredator != null) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Item.NewItem(NPC.GetSource_FromThis(), NPC.getRect(), HeldItemType); + } + + NPC.netUpdate = true; + HeldItemIndex = -1; + Phase = (int)PhaseType.Idle; + TurnTimer = 0; + WalkTimer = 0; + OldItemType = 0; + StackMin = 0; + StackMax = 0; + + SoundEngine.PlaySound(SoundID.NPCHit51 with { Pitch = -0.3f }, NPC.Center); + + EmoteExpressionParticle.EmoteType eType = EmoteExpressionParticle.EmoteType.Exclamation; + + var emoteDirection = -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(2f, 3f); + Particle emote = new EmoteExpressionParticle( + NPC.Center + emoteDirection * 2f, + emoteDirection, + 2.2f, + Color.Red, + Main.rand.Next(30, 46), + eType); + GeneralParticleHandler.SpawnParticle(emote); + return; + } + NPC.velocity.X *= NPC.velocity.Y != 0 ? 0.96f : 0.9f; + TradeTimer++; + // Calculate the reward + if (TradeTimer == 132) + { + NPC.netUpdate = true; + OldItemType = HeldItemType; + HeldItemType = CalculateReward(out int min, out int max); + StackMin = min; + StackMax = max; + } + + // After some time, spit out a reward and go back to idle with a cooldown + if (TradeTimer > 160) + { + NPC.netUpdate = true; + HeldItemIndex = -1; + Phase = (int)PhaseType.Idle; + // This timer increments during its idle phase so it's set to a negative value + // Once the value hits zero, the crab will be able to trade again + TradeTimer = -CalamityUtils.SecondsToFrames(8); + + // Spawn the reward + if (HeldItemType > 0) + { + float stackMult = 1; + int dropAmt = 1; + if (ContentSamples.ItemsByType[HeldItemType].maxStack > 1) + { + if (OldItemType == ModContent.ItemType()) + stackMult *= 2; + if (OldItemType == ItemID.GalaxyPearl) + stackMult *= Main.rand.NextFloat(1.2f, 2f); + } + else + { + if (OldItemType == ModContent.ItemType()) + dropAmt *= 2; + if (OldItemType == ItemID.GalaxyPearl) + dropAmt *= 2; + } + for (int i = 0; i < dropAmt; i++) + { + SpawnItem(HeldItemType, stackMult); + } + } + HeldItemType = 0; + OldItemType = 0; + StackMin = 0; + StackMax = 0; + } + } + break; + // Burrow away and despawn + case (int)PhaseType.Burrow: + { + NPC.velocity.X *= 0.95f; + if (NPC.velocity.Y == 0) + { + WalkTimer++; + GeneralParticleHandler.SpawnParticle(new Particles.StoneDebrisParticle(Main.rand.NextVector2FromRectangle(NPC.getRect() with { Y = (int)NPC.Center.Y }), new Vector2(Main.rand.NextFloat(-6, 6), Main.rand.NextFloat(-6, -2)), Lighting.GetColor(NPC.Bottom.ToTileCoordinates()), Main.rand.NextFloat(0.5f, 1.2f), 10)); + } + if (WalkTimer % 10 == 0) + { + SoundEngine.PlaySound(SoundID.Dig, NPC.Center); + } + int startFall = 40; + if (WalkTimer >= startFall) + { + NPC.alpha += 5; + if (NPC.alpha > 255) + { + NPC.active = false; + } + } + } + break; + } + + if ((Phase != (int)PhaseType.FoundItem && Phase != (int)PhaseType.Burrow) && WalkTimer > 0) + WalkTimer--; + + if (TurnTimer > 0) + TurnTimer--; + + NPC.spriteDirection = NPC.direction; + } + + public void SpawnItem(int ID, float stackMult = 1f) + { + int stack = 1; + if (NPC.localAI[0] != NPC.localAI[1]) + { + stack = Main.rand.Next((int)NPC.localAI[0], (int)NPC.localAI[1] + 1); + } + stack = (int)(stack * stackMult); + int i = Item.NewItem(NPC.GetSource_FromThis(), new Rectangle((int)NPC.Center.X + NPC.direction * 20, (int)NPC.Center.Y - 20, NPC.width, NPC.height), ID, Stack: stack, noBroadcast: false); + Main.item[i].velocity = new Vector2(NPC.direction * Main.rand.NextFloat(3.7f, 4.3f), -Main.rand.NextFloat(-1.2f, 0.8f)); + if (Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, i); + } + } + + // Checks if the horizontal position in front of it has water or is a pit so that the crab can avoid it + public bool WaterCheck(int height) + { + Point startPos = NPC.direction == 1 ? NPC.Right.ToTileCoordinates() : NPC.Left.ToTileCoordinates(); + for (int i = 1; i < height; i++) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(startPos.X + NPC.direction, startPos.Y + i); + Tile above = CalamityUtils.ParanoidTileRetrieval(startPos.X + NPC.direction, startPos.Y + i - 1); + // If there's a tile, wegud + if (t.HasTile) + return false; + // If there's liquid or a pit, we not gud + if (t.LiquidAmount > 0 && !above.HasTile) + return true; + + } + return true; + } + + // Checks if the horizontal position in front of the crab can be jumped up + public bool JumpCheck() + { + Point startPos = NPC.direction == 1 ? NPC.BottomRight.ToTileCoordinates() : NPC.BottomLeft.ToTileCoordinates(); + bool canJump = false; + int add = NPC.direction == 1 ? 0 : -1; + int jumpHeight = 6; + for (int i = jumpHeight; i > 0; i--) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(startPos.X + add, startPos.Y - i); + // If there are tiles obfuscating the jump position, return false + if (i > (jumpHeight - 2) && t.HasTile) + return false; + // If there is a tile to jump on, return true + if (t.HasTile) + { + canJump = true; + break; + } + } + return canJump; + } + + public int CalculateReward(out int min, out int max) + { + min = 0; + max = 0; + // Make sure the held item type is valid + if (ScavengerLoot.TryGetValue(HeldItemType, out WeightedRandom value)) + { + // If the held item has no roll value, immediately return + if (value == null) + return 0; + + int tries = 100; + for (int i = 0; i < tries; i++) + { + var v = value.Get(); + if (v.condition.Invoke()) + { + min = v.minimum; + max = v.maximum; + return v.itemID; + } + } + + return 0; + } + else + { + return 0; + } + } + + public static bool IsPassableTile(int x, int y) + { + return (!Main.tile[x, y].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x, y].TileType] || Main.tileSolidTop[(int)Main.tile[x, y].TileType]); + } + + public void StepUp() + { + Vector2 position = NPC.position; + position.X += NPC.velocity.X; + int x = (int)((position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1)) * NPC.direction) / 16f); + int y = (int)((position.Y + (float)NPC.height - 1f) / 16f); + + if ((float)(x * 16) >= position.X + (float)NPC.width || (float)(x * 16 + 16) <= position.X) + return; + + bool nextTileValid = Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]; + bool aboveTileHalfBlock = Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile; + bool aboveTileHasRoom = Main.tile[x, y - 1].IsHalfBlock && IsPassableTile(x, y - 4); + bool aboveTileEmpty = !Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || aboveTileHasRoom; + bool tile3AbovePassable = !Main.tile[x - NPC.direction, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - NPC.direction, y - 3].TileType]; + + if ((nextTileValid || aboveTileHalfBlock) && aboveTileEmpty && IsPassableTile(x, y - 2) && IsPassableTile(x, y - 3) && tile3AbovePassable) + { + float npcBottom = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) + { + npcBottom += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + npcBottom -= 8f; + } + if (npcBottom < position.Y + (float)NPC.height) + { + float percentageTileRisen = position.Y + (float)NPC.height - npcBottom; + if (percentageTileRisen <= 16.1f) + { + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - npcBottom; + NPC.position.Y = npcBottom - (float)NPC.height; + if (percentageTileRisen < 9f) + { + NPC.stepSpeed = 1f; + } + else + { + NPC.stepSpeed = 2f; + } + } + } + } + } + + public override void FindFrame(int frameHeight) + { + float frameCount = Main.npcFrameCount[Type] - 1; + + if (ShouldUseWalkingFrames) + frameCount = 5; + else if (ShouldUseInspectionFrames) + frameCount = 23; + else if (ShouldUseGivingFrames) + frameCount = 12; + + NPC.frameCounter++; + if (NPC.frameCounter > 6) + { + NPC.frame.Y++; + NPC.frameCounter = 0; + } + + // Reset frame when transitioning to giving animation + if (NPC.frame.Y >= frameCount || (Phase == (int)PhaseType.Bartering && TradeTimer == 80)) + { + NPC.frame.Y = 0; + NPC.frameCounter = 0; + } + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.Cavern.Chance * 0.4f; + } + return 0f; + + //fuck this + //if (spawnInfo.Player.Calamity().ZoneSunkenSeaShores && !spawnInfo.Player.Calamity().clamity && tile.WallType == ModContent.WallType()) + //{ + // return 0.05f; + //} + //return 0f; + } + + public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) + { + PlayerHurt(); + } + + public void PlayerHurt() + { + if (Phase != (int)PhaseType.Burrow) + { + WalkTimer = 0; + Phase = (int)PhaseType.Burrow; + foreach (NPC n in Main.ActiveNPCs) + { + if (n == NPC) + continue; + if (n.type != NPC.type) + continue; + if (n.Distance(NPC.Center) > 600) + continue; + Scavenger scav = n.ModNPC(); + scav.PlayerHurt(); + scav.WalkTimer += Main.rand.Next(-20, 10); + } + } + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 2; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, Color.DarkGray * 0.2f, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 10; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, Color.DarkGray * 0.2f, 1f); + } + } + CalamityUtils.SpawnGores(NPC, "Scavenger", 3); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = TextureAssets.Npc[NPC.type].Value; + int frameCount = Main.npcFrameCount[Type]; + float extraPosOffset = 0; + if (ShouldUseWalkingFrames) + { + texture = walkTexture.Value; + frameCount = 6; + } + else if (ShouldUseInspectionFrames) + { + texture = inspectTexture.Value; + frameCount = 24; + extraPosOffset = 6; + } + else if (ShouldUseGivingFrames) + { + texture = giveTexture.Value; + frameCount = 13; + } + Vector2 origin = new Vector2(texture.Width / 2, texture.Height / frameCount / 2); + Vector2 npcOffset = NPC.Center - screenPos + Vector2.UnitY * extraPosOffset; + npcOffset -= new Vector2(texture.Width, texture.Height / frameCount) * NPC.scale / 2f; + npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); + int burrowHide = 0; + if (Phase == (int)PhaseType.Burrow) + { + float comp = Utils.GetLerpValue(40, 120, WalkTimer, true); + burrowHide = (int)MathHelper.Lerp(0, texture.Height / frameCount + 1, comp); + npcOffset.Y += MathHelper.Lerp(0, NPC.height, comp); + } + Rectangle frame = texture.Frame(1, frameCount, 0, NPC.frame.Y); + spriteBatch.Draw(texture, npcOffset, frame with { Height = frame.Height - burrowHide }, NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + // my dreams devoured + // legacy code for visually holding an item + /*Texture2D item = TextureAssets.Item[HeldItemType].Value; + Vector2 itemOffset = new Vector2(NPC.direction == 1 ? 8 : -8, 20); + if (TradeTimer < 80) + spriteBatch.Draw(item, npcOffset + itemOffset, null, drawColor, 0, new Vector2(item.Width / 2, item.Height), 1f, spriteEffects, 0); + */ + return false; + } + } +} diff --git a/NPCs/SunkenSea/Scavenger.png b/NPCs/SunkenSea/Scavenger.png new file mode 100644 index 0000000000..7e3f646f0d Binary files /dev/null and b/NPCs/SunkenSea/Scavenger.png differ diff --git a/NPCs/SunkenSea/ScavengerGiving.png b/NPCs/SunkenSea/ScavengerGiving.png new file mode 100644 index 0000000000..cd08777d65 Binary files /dev/null and b/NPCs/SunkenSea/ScavengerGiving.png differ diff --git a/NPCs/SunkenSea/ScavengerInspecting.png b/NPCs/SunkenSea/ScavengerInspecting.png new file mode 100644 index 0000000000..7db93e9712 Binary files /dev/null and b/NPCs/SunkenSea/ScavengerInspecting.png differ diff --git a/NPCs/SunkenSea/ScavengerWalking.png b/NPCs/SunkenSea/ScavengerWalking.png new file mode 100644 index 0000000000..229cc451c6 Binary files /dev/null and b/NPCs/SunkenSea/ScavengerWalking.png differ diff --git a/NPCs/SunkenSea/SeaFloaty.cs b/NPCs/SunkenSea/SeaFloaty.cs index 67acd56e5e..aa8b778d62 100644 --- a/NPCs/SunkenSea/SeaFloaty.cs +++ b/NPCs/SunkenSea/SeaFloaty.cs @@ -1,5 +1,7 @@ -using System.IO; -using CalamityMod.BiomeManagers; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; +using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -11,10 +13,21 @@ using Terraria.ModLoader; using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.SunkenSea { - public class SeaFloaty : ModNPC + public class SeaFloaty : SunkenSeaNPC { private bool hasBeenHit = false; + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + }; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs; + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 5; @@ -23,25 +36,28 @@ namespace CalamityMod.NPCs.SunkenSea SpriteDirection = -1 }; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + NPCID.Sets.CountsAsCritter[Type] = true; + base.SetStaticDefaults(); } public override void SetDefaults() { + base.SetDefaults(); NPC.npcSlots = 0.5f; NPC.aiStyle = -1; AIType = -1; - NPC.damage = 5; + NPC.damage = 0; NPC.width = 44; NPC.height = 22; NPC.defense = 0; - NPC.lifeMax = 50; + NPC.lifeMax = 5; NPC.knockBackResist = 0.5f; - NPC.value = Item.buyPrice(0, 0, 0, 50); NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; + NPC.chaseable = false; Banner = NPC.type; BannerItem = ModContent.ItemType(); - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + NPC.catchItem = ModContent.ItemType(); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -92,7 +108,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.netUpdate = true; } // panic when it gets hit or the player is close enough to it - if ((NPC.justHit || Main.player[NPC.target].Distance(NPC.Center) < 320) && !hasBeenHit) + if ((NPC.justHit || CurrentPlayer != null || CurrentPredator != null) && !hasBeenHit) { hasBeenHit = true; NPC.noTileCollide = true; @@ -148,6 +164,17 @@ namespace CalamityMod.NPCs.SunkenSea } } } + protected override bool NPCSearchFilter(NPC n) + { + return NPC.HasSight(n.Center) && Vector2.DistanceSquared(NPC.Center, n.Center) < 360f * 360f && PredatorIDs.Contains(n.type); + } + + protected override bool PlayerSearchFilter(Player p) + { + return NPC.HasSight(p.Center) && Vector2.DistanceSquared(NPC.Center, p.Center) < 360f * 360f; + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); public override void FindFrame(int frameHeight) { @@ -178,13 +205,8 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); } - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("SeaFloatyGore1").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("SeaFloatyGore2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("SeaFloatyGore3").Type, 1f); - } } + CalamityUtils.SpawnGores(NPC, "SeaFloaty", 1); } } } diff --git a/NPCs/SunkenSea/SeaMinnow.cs b/NPCs/SunkenSea/SeaMinnow.cs index c753fb8f07..7da60d1334 100644 --- a/NPCs/SunkenSea/SeaMinnow.cs +++ b/NPCs/SunkenSea/SeaMinnow.cs @@ -1,30 +1,50 @@ using System; -using CalamityMod.BiomeManagers; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.CalamityAIs.CalamityRegularEnemyAIs; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Pathfinding; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Utilities; namespace CalamityMod.NPCs.SunkenSea { - public class SeaMinnow : ModNPC + public class SeaMinnow : SunkenSeaNPC { + public Entity avoidedEntity; + + public Vector2 randomPathPoint; + protected override List PreyIDs => new List(); + + protected override List PredatorIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs | SunkenSeaBiomeFlags.GleamingBurrows; + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 8; Main.npcCatchable[Type] = true; NPCID.Sets.CountsAsCritter[Type] = true; + base.SetStaticDefaults(); } public override void SetDefaults() { - NPC.npcSlots = 0.1f; + base.SetDefaults(); + NPC.npcSlots = 0f; NPC.noGravity = true; NPC.damage = 0; NPC.width = 32; @@ -39,7 +59,6 @@ namespace CalamityMod.NPCs.SunkenSea BannerItem = ModContent.ItemType(); NPC.chaseable = false; NPC.catchItem = (short)ModContent.ItemType(); - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -56,122 +75,255 @@ namespace CalamityMod.NPCs.SunkenSea } public override void AI() { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.6f; + MaxSpeed = 5f; + } NPC owner = Main.npc[(int)NPC.ai[2]]; if (NPC.wet) { if (owner == null || !owner.active || (owner.type != ModContent.NPCType() && owner.type != ModContent.NPCType())) { - CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 3, 150f, 0.25f, 0.15f, 6f, 6f, 0.05f); - NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - NPC.noGravity = true; - bool shouldSwimAway = false; - if (NPC.direction == 0) + if (CurrentPredator == null) { - NPC.TargetClosest(true); - } - NPC.TargetClosest(false); - if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && - (Main.player[NPC.target].Center - NPC.Center).Length() < 150f) - { - shouldSwimAway = true; - } - if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && shouldSwimAway) - { - shouldSwimAway = false; - } - if (!shouldSwimAway) - { - if (NPC.collideX || NPC.velocity.X == 0f) + CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 3, 150f, 0.25f, 0.15f, 6f, 6f, 0.05f); + NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; + NPC.noGravity = true; + bool shouldSwimAway = false; + if (NPC.direction == 0) { - NPC.velocity.X = NPC.velocity.X * -3f; - NPC.direction *= -1; - NPC.netUpdate = true; + NPC.TargetClosest(true); } - if (NPC.collideY) + NPC.TargetClosest(false); + if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && + (Main.player[NPC.target].Center - NPC.Center).Length() < 150f) { - NPC.netUpdate = true; - if (NPC.velocity.Y > 0f) + shouldSwimAway = true; + } + if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && shouldSwimAway) + { + shouldSwimAway = false; + } + if (!shouldSwimAway) + { + if (NPC.collideX || NPC.velocity.X == 0f) + { + NPC.velocity.X = NPC.velocity.X * -3f; + NPC.direction *= -1; + NPC.netUpdate = true; + } + if (NPC.collideY) + { + NPC.netUpdate = true; + if (NPC.velocity.Y > 0f) + { + NPC.velocity.Y = Math.Abs(NPC.velocity.Y) * -3f; + NPC.directionY = -1; + NPC.ai[0] = -1f; + } + else if (NPC.velocity.Y < 0f) + { + NPC.velocity.Y = Math.Abs(NPC.velocity.Y); + NPC.directionY = 1; + NPC.ai[0] = 1f; + } + } + } + if (shouldSwimAway) + { + NPC.TargetClosest(true); + NPC.velocity.X = NPC.velocity.X - (float)NPC.direction * 0.25f; + NPC.velocity.Y = NPC.velocity.Y - (float)NPC.directionY * 0.15f; + if (NPC.velocity.X > 6f) + { + NPC.velocity.X = 6f; + } + if (NPC.velocity.X < -6f) + { + NPC.velocity.X = -6f; + } + if (NPC.velocity.Y > 6f) + { + NPC.velocity.Y = 6f; + } + if (NPC.velocity.Y < -6f) + { + NPC.velocity.Y = -6f; + } + NPC.direction *= -1; + } + else + { + NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * 0.1f; + if (NPC.velocity.X < -2.5f || NPC.velocity.X > 2.5f) + { + NPC.velocity.X = NPC.velocity.X * 0.95f; + } + if (NPC.ai[0] == -1f) + { + NPC.velocity.Y = NPC.velocity.Y - 0.01f; + if ((double)NPC.velocity.Y < -0.3) + { + NPC.ai[0] = 1f; + } + } + else + { + NPC.velocity.Y = NPC.velocity.Y + 0.01f; + if ((double)NPC.velocity.Y > 0.3) + { + NPC.ai[0] = -1f; + } + } + } + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) + { + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { - NPC.velocity.Y = Math.Abs(NPC.velocity.Y) * -3f; - NPC.directionY = -1; NPC.ai[0] = -1f; } - else if (NPC.velocity.Y < 0f) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { - NPC.velocity.Y = Math.Abs(NPC.velocity.Y); - NPC.directionY = 1; - NPC.ai[0] = 1f; + NPC.ai[0] = -1f; } } - } - if (shouldSwimAway) - { - NPC.TargetClosest(true); - NPC.velocity.X = NPC.velocity.X - (float)NPC.direction * 0.25f; - NPC.velocity.Y = NPC.velocity.Y - (float)NPC.directionY * 0.15f; - if (NPC.velocity.X > 6f) + if ((double)NPC.velocity.Y > 0.4 || (double)NPC.velocity.Y < -0.4) { - NPC.velocity.X = 6f; + NPC.velocity.Y = NPC.velocity.Y * 0.95f; } - if (NPC.velocity.X < -6f) - { - NPC.velocity.X = -6f; - } - if (NPC.velocity.Y > 6f) - { - NPC.velocity.Y = 6f; - } - if (NPC.velocity.Y < -6f) - { - NPC.velocity.Y = -6f; - } - NPC.direction *= -1; } else { - NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * 0.1f; - if (NPC.velocity.X < -2.5f || NPC.velocity.X > 2.5f) + // Check who is the avoided entity specifically. + avoidedEntity = avoidedEntity is NPC ? CurrentPredator : CurrentPlayer; + + if (avoidedEntity is not null) { - NPC.velocity.X = NPC.velocity.X * 0.95f; - } - if (NPC.ai[0] == -1f) - { - NPC.velocity.Y = NPC.velocity.Y - 0.01f; - if ((double)NPC.velocity.Y < -0.3) + // While it doesn't have any obstacles in front of it, run away in a straight line. + // Try to manuever if there are any obstacles. + if (!Main.tile[(NPC.Center + NPC.DirectionFrom(avoidedEntity.Center) * 96).ToTileCoordinates()].IsTileSolid()) { - NPC.ai[0] = 1f; + NPC.velocity += NPC.DirectionFrom(avoidedEntity.Center) * Acceleration; + pathfinding.ClearResults(); + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + { + float distanceFromAvoided = Vector2.Distance(NPC.Center, avoidedEntity.Center); + randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); + NPC.netUpdate = true; + pathfinding.DoPathfinding(new(this, NPC.Center, randomPathPoint, SunkenSeaTileValidity)); } } else { - NPC.velocity.Y = NPC.velocity.Y + 0.01f; - if ((double)NPC.velocity.Y > 0.3) - { - NPC.ai[0] = -1f; - } + pathfinding.DoPathfinding(new(this, NPC.Center, Main.rand.NextVector2Unit() * Main.rand.Next(300, 1000), SunkenSeaTileValidity)); } } - int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) - { - if (Main.tile[npcTileX, npcTileY + 1].HasTile) - { - NPC.ai[0] = -1f; - } - else if (Main.tile[npcTileX, npcTileY + 2].HasTile) - { - NPC.ai[0] = -1f; - } - } - if ((double)NPC.velocity.Y > 0.4 || (double)NPC.velocity.Y < -0.4) - { - NPC.velocity.Y = NPC.velocity.Y * 0.95f; - } } else { - float SAImovement = 0.05f; + if (!owner.active) + return; + + if (NPC.Distance(owner.Center) > 200) + pathfinding.DoPathfinding(new(this, NPC.Center, owner.Center, SunkenSeaTileValidity)); + else + { + float passiveMvtFloat = 0.5f; + float range = 100f; + Vector2 fischPos = NPC.Center; + float xDist = owner.Center.X - fischPos.X; + float yDist = owner.Center.Y - fischPos.Y; + yDist += Main.rand.NextFloat(-10, 20); + xDist += Main.rand.NextFloat(-10, 20); + xDist += 30f * -(float)owner.direction; + Vector2 leaderVector = new Vector2(xDist, yDist); + float leaderDist = leaderVector.Length(); + float returnSpeed = 8f; + //If leader is close enough, resume normal + if (leaderDist < range && owner.velocity.Y == 0f && + NPC.Bottom.Y <= owner.Bottom.Y && + !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + if (NPC.velocity.Y < -6f) + { + NPC.velocity.Y = -6f; + } + } + + if (leaderDist < 50f) + { + if (Math.Abs(NPC.velocity.X) > 2f || Math.Abs(NPC.velocity.Y) > 2f) + { + NPC.velocity *= 0.99f; + } + passiveMvtFloat = 0.01f; + } + else + { + if (leaderDist < 100f) + { + passiveMvtFloat = 0.1f; + } + if (leaderDist > 300f) + { + passiveMvtFloat = 1f; + } + leaderDist = returnSpeed / leaderDist; + leaderVector.X *= leaderDist; + leaderVector.Y *= leaderDist; + } + if (NPC.velocity.X < leaderVector.X) + { + NPC.velocity.X += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.X < 0f) + { + NPC.velocity.X += passiveMvtFloat; + } + } + if (NPC.velocity.X > leaderVector.X) + { + NPC.velocity.X -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.X > 0f) + { + NPC.velocity.X -= passiveMvtFloat; + } + } + if (NPC.velocity.Y < leaderVector.Y) + { + NPC.velocity.Y += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.Y < 0f) + { + NPC.velocity.Y += passiveMvtFloat * 2f; + } + } + if (NPC.velocity.Y > leaderVector.Y) + { + NPC.velocity.Y -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && NPC.velocity.Y > 0f) + { + NPC.velocity.Y -= passiveMvtFloat * 2f; + } + } + if (NPC.velocity.X >= 0.25f) + { + NPC.direction = -1; + } + else if (NPC.velocity.X < -0.25f) + { + NPC.direction = 1; + } + NPC.spriteDirection = -NPC.direction; + } + float SAImovement = 0.2f; for (int k = 0; k < Main.maxNPCs; k++) { NPC otherFish = Main.npc[k]; @@ -180,7 +332,7 @@ namespace CalamityMod.NPCs.SunkenSea continue; float taxicabDist = Math.Abs(NPC.position.X - otherFish.position.X) + Math.Abs(NPC.position.Y - otherFish.position.Y); - if (taxicabDist < NPC.width * 1.5f) + if (taxicabDist < NPC.width) { if (NPC.position.X < otherFish.position.X) NPC.velocity.X -= SAImovement; @@ -193,129 +345,31 @@ namespace CalamityMod.NPCs.SunkenSea NPC.velocity.Y += SAImovement; } } - - if (!owner.active) - return; - - float passiveMvtFloat = 0.5f; - float range = 100f; - Vector2 fischPos = NPC.Center; - float xDist = owner.Center.X - fischPos.X; - float yDist = owner.Center.Y - fischPos.Y; - yDist += Main.rand.NextFloat(-10, 20); - xDist += Main.rand.NextFloat(-10, 20); - xDist += 30f * -(float)owner.direction; - Vector2 leaderVector = new Vector2(xDist, yDist); - float leaderDist = leaderVector.Length(); - float returnSpeed = 8f; - //If leader is close enough, resume normal - if (leaderDist < range && owner.velocity.Y == 0f && - NPC.Bottom.Y <= owner.Bottom.Y && - !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) - { - if (NPC.velocity.Y < -6f) - { - NPC.velocity.Y = -6f; - } - } - - if (leaderDist < 50f) - { - if (Math.Abs(NPC.velocity.X) > 2f || Math.Abs(NPC.velocity.Y) > 2f) - { - NPC.velocity *= 0.99f; - } - passiveMvtFloat = 0.01f; - } - else - { - if (leaderDist < 100f) - { - passiveMvtFloat = 0.1f; - } - if (leaderDist > 300f) - { - passiveMvtFloat = 1f; - } - leaderDist = returnSpeed / leaderDist; - leaderVector.X *= leaderDist; - leaderVector.Y *= leaderDist; - } - if (NPC.velocity.X < leaderVector.X) - { - NPC.velocity.X += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && NPC.velocity.X < 0f) - { - NPC.velocity.X += passiveMvtFloat; - } - } - if (NPC.velocity.X > leaderVector.X) - { - NPC.velocity.X -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && NPC.velocity.X > 0f) - { - NPC.velocity.X -= passiveMvtFloat; - } - } - if (NPC.velocity.Y < leaderVector.Y) - { - NPC.velocity.Y += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && NPC.velocity.Y < 0f) - { - NPC.velocity.Y += passiveMvtFloat * 2f; - } - } - if (NPC.velocity.Y > leaderVector.Y) - { - NPC.velocity.Y -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && NPC.velocity.Y > 0f) - { - NPC.velocity.Y -= passiveMvtFloat * 2f; - } - } - if (NPC.velocity.X >= 0.25f) - { - NPC.direction = -1; - } - else if (NPC.velocity.X < -0.25f) - { - NPC.direction = 1; - } - NPC.spriteDirection = -NPC.direction; } + int dir = NPC.velocity.X.DirectionalSign(); + NPC.rotation = NPC.velocity.ToRotation() + (dir == 1 ? 0 : MathHelper.Pi); + NPC.spriteDirection = NPC.direction = dir; } else { + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X = NPC.velocity.X * 0.94f; + if ((double)NPC.velocity.X > -0.2 && (double)NPC.velocity.X < 0.2) + { + NPC.velocity.X = 0f; + } + } + NPC.velocity.Y = NPC.velocity.Y + 0.3f; + if (NPC.velocity.Y > 10f) + { + NPC.velocity.Y = 10f; + } + } - { - if (NPC.velocity.Y == 0f) - { - NPC.velocity.X = NPC.velocity.X * 0.94f; - if ((double)NPC.velocity.X > -0.2 && (double)NPC.velocity.X < 0.2) - { - NPC.velocity.X = 0f; - } - } - NPC.velocity.Y = NPC.velocity.Y + 0.3f; - if (NPC.velocity.Y > 10f) - { - NPC.velocity.Y = 10f; - } - NPC.ai[0] = 1f; - } - NPC.rotation = NPC.velocity.X * 0.05f; - if ((double)NPC.rotation < -0.1) - { - NPC.rotation = -0.1f; - } - if ((double)NPC.rotation > 0.1) - { - NPC.rotation = 0.1f; - } - if (NPC.type == ModContent.NPCType()) - { - NPC.ProduceGoldCritterDust(); - } + if (NPC.type == ModContent.NPCType()) + { + NPC.ProduceGoldCritterDust(); } } @@ -338,37 +392,36 @@ namespace CalamityMod.NPCs.SunkenSea { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BlueCrystalShard, hit.HitDirection, -1f, 0, default, 1f); } + CalamityUtils.SpawnGores(NPC, "SeaMinnow", 2); + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(randomPathPoint); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + randomPathPoint = reader.ReadVector2(); } } public class SeaMinnowGold : SeaMinnow { public override void SetStaticDefaults() { - Main.npcFrameCount[Type] = 8; - Main.npcCatchable[Type] = true; - NPCID.Sets.CountsAsCritter[Type] = true; this.HideFromBestiary(); + base.SetStaticDefaults(); } + public override void SetDefaults() { - NPC.npcSlots = 0.1f; - NPC.noGravity = true; - NPC.damage = 0; - NPC.width = 36; - NPC.height = 22; - NPC.defense = 0; - NPC.lifeMax = 5; - NPC.aiStyle = -1; - AIType = -1; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath1; - Banner = NPC.type; - BannerItem = ModContent.ItemType(); - NPC.chaseable = false; - NPC.catchItem = (short)ModContent.ItemType(); - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + base.SetDefaults(); + NPC.catchItem = (short)ModContent.ItemType(); NPC.rarity = 3; } + public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) diff --git a/NPCs/SunkenSea/Searslug.cs b/NPCs/SunkenSea/Searslug.cs new file mode 100644 index 0000000000..e90e0ec8cd --- /dev/null +++ b/NPCs/SunkenSea/Searslug.cs @@ -0,0 +1,195 @@ +using CalamityMod.Items.Critters; +using CalamityMod.Items.Placeables.Banners; +using Microsoft.Xna.Framework; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; +using Terraria.Audio; +using Terraria.DataStructures; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using CalamityMod.Particles; +using ReLogic.Content; +using CalamityMod.Enums; +using System.Collections.Generic; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Searslug : SunkenSeaNPC + { + public bool Skinwalker => NPC.Calamity()?.newAI[0] == 1; + public static Asset glowTexture; + + public override void Load() => glowTexture = ModContent.Request(Texture + "Glow"); + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.BasaltGully; + + protected override List PreyIDs => new(); + + protected override List PredatorIDs => new() + { + ModContent.NPCType() + }; + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + Main.npcFrameCount[Type] = 7; + } + public override void SetDefaults() + { + base.SetDefaults(); + NPC.aiStyle = NPCAIStyleID.Snail; + NPC.damage = 0; + NPC.width = 56; + NPC.height = 42; + NPC.defense = 0; + NPC.lifeMax = 20; + NPC.knockBackResist = 0f; + NPC.lavaImmune = true; + NPC.noGravity = false; + NPC.noTileCollide = false; + NPC.HitSound = SoundID.NPCHit38; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.GravityIgnoresLiquid = true; + NPC.chaseable = false; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.catchItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToWater = true; + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < 2; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < 2; i++) + writer.Write(NPC.Calamity().newAI[i]); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Searslug") + }); + } + + public override void OnSpawn(IEntitySource source) + { + // 1 in 10 chance to be a skinwalker + NPC.Calamity().newAI[0] = Main.rand.NextBool(10).ToInt(); + } + + public override void AI() + { + NPC.Calamity().newAI[1]++; + NPC.TargetClosest(false); + Lighting.AddLight(NPC.Center, 1, 0, 0); + if (Skinwalker) + { + // Randomly stutter + if (Main.rand.NextBool(300) && NPC.velocity.Y == 0) + NPC.velocity.X *= 0.7f; + + // If the player gets close enough, burst out and KILL the host + if (NPC.HasPlayerTarget && NPC.Calamity().newAI[1] > 120) + { + Player p = Main.player[NPC.target]; + if (p != null && p.active && p.Distance(NPC.Center) < 120 && Collision.CanHitLine(NPC.Center, 1, 1, p.Center, 1, 1)) + { + SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Pitch = 0.8f, Volume = 0.6f }, NPC.Center); + SoundEngine.PlaySound(SoundID.NPCDeath1 with { Pitch = 0.4f }, NPC.Center); + for (int i = 0; i < 10; i++) + { + int size = 12; + Vector2 position = NPC.Center; + Vector2 velocity = Main.rand.NextVector2Circular(size, size); + SquishyLightParticle energy = new(position, velocity, Main.rand.NextFloat(0.2f, 0.3f), Color.Orange, Main.rand.Next(5, 8), 1, 1.5f); + GeneralParticleHandler.SpawnParticle(energy); + Dust dust = Dust.NewDustPerfect(position, DustID.Torch, velocity, 0, default, Main.rand.NextFloat(1f, 1.6f)); + dust.noGravity = true; + } + NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + NPC.HitEffect(); + NPC.active = false; + } + } + } + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter++; + int frameGate = Skinwalker ? 8 : 6; + if (NPC.frameCounter > frameGate) + { + NPC.frameCounter = 0; + NPC.frame.Y += frameHeight; + if (NPC.frame.Y > frameHeight * (Main.npcFrameCount[Type] - 1)) + { + NPC.frame.Y = 0; + } + } + } + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneBasaltGully && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.Cavern.Chance * 0.2f; + } + return 0f; + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.LavaMoss, hit.HitDirection, -1f, 0, default, 1f); + } + CalamityUtils.SpawnGores(NPC, "Searslug", 2); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + Vector2 pos = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY - (Vector2.UnitY * 10).RotatedBy(NPC.rotation); + float colorMult = 1f; + // Shake if a skinwalker + if (Skinwalker) + { + pos += Main.rand.NextVector2Unit() * Main.rand.NextFloat(-1f, 1f); + colorMult = 0.8f; + } + spriteBatch.Draw(tex, pos, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[NPC.type]), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : 0, 0); + + spriteBatch.Draw(glowTexture.Value, pos, NPC.frame, Color.White * colorMult, NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[NPC.type]), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : 0, 0); + return false; + } + + public override bool? CanBeCaughtBy(Item item, Player player) + { + return ItemID.Sets.LavaproofCatchingTool[item.type]; + } + + public override void OnCaughtBy(Player player, Item item, bool failed) + { + // Wear protection! + if (failed) + { + player.AddBuff(BuffID.OnFire, CalamityUtils.SecondsToFrames(5)); + } + } + } +} diff --git a/NPCs/SunkenSea/Searslug.png b/NPCs/SunkenSea/Searslug.png new file mode 100644 index 0000000000..05aa97f86b Binary files /dev/null and b/NPCs/SunkenSea/Searslug.png differ diff --git a/NPCs/SunkenSea/SearslugGlow.png b/NPCs/SunkenSea/SearslugGlow.png new file mode 100644 index 0000000000..76f3ef5dd1 Binary files /dev/null and b/NPCs/SunkenSea/SearslugGlow.png differ diff --git a/NPCs/SunkenSea/Sharkoon.cs b/NPCs/SunkenSea/Sharkoon.cs index 11d3285bfa..08c54d3e58 100644 --- a/NPCs/SunkenSea/Sharkoon.cs +++ b/NPCs/SunkenSea/Sharkoon.cs @@ -4,6 +4,7 @@ using System.IO; using CalamityMod.Enums; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Particles; +using CalamityMod.Pathfinding; using CalamityMod.Projectiles.Enemy; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,6 +14,7 @@ using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; using static CalamityMod.CalamityUtils; using static Terraria.ModLoader.ModContent; @@ -24,13 +26,11 @@ namespace CalamityMod.NPCs.SunkenSea #region Static Fields - public static int IdleRandomMovementUnlikeliness = 250; + //public static int IdleRandomMovementUnlikeliness = 250; public static int IdleMinPathDistance = 200; public static int IdleMaxPathDistance = 400; public static int FleeTileAnticipationDistance = 64; - public static int FleeMinPathDistance = 80; - public static int FleeMaxPathDistance = 160; public static int ExplosionDistance = 80; public static int ExplosionRadius = 80; @@ -143,17 +143,20 @@ namespace CalamityMod.NPCs.SunkenSea protected override List PreyIDs => [ - // NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), + NPCType(), + NPCType(), NPCType(), ]; protected override List PredatorIDs => [ - // NPCType(), + NPCType(), // NPCType(), NPCType(), // NPCType, @@ -191,7 +194,7 @@ namespace CalamityMod.NPCs.SunkenSea NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; - NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.value = Item.buyPrice(silver: 5); NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToSickness = true; @@ -215,11 +218,9 @@ namespace CalamityMod.NPCs.SunkenSea public override void OnSpawn(IEntitySource source) { - pathfinding = new PathfindingManager(NPC) - { - Acceleration = 0.3f, - MaxSpeed = 6f, - }; + pathfinding = new PathfindingManager(this); + Acceleration = 0.3f; + MaxSpeed = 6f; CurrentBehavior = IdlingBehavior; NPC.spriteDirection = Main.rand.NextBool().ToDirectionInt(); NPC.GravityMultiplier *= 2f; @@ -228,6 +229,12 @@ namespace CalamityMod.NPCs.SunkenSea public override void AI() { + if (pathfinding == null) + { + pathfinding = new PathfindingManager(this); + Acceleration = 0.3f; + MaxSpeed = 6f; + } CurrentBehavior?.Invoke(); // Leans the Sharkoon towards the direction it's going. @@ -243,18 +250,20 @@ namespace CalamityMod.NPCs.SunkenSea } // When it gets outside of water, it'll try to gravitate downards towards the water. - if (!NPC.wet && !IsExploding) + if (!NPC.wet && !IsExploding && CurrentBehavior != OutsideWaterBehavior) CurrentBehavior = OutsideWaterBehavior; - // Reset any squish that is done to the Sharkoon. + + // Reset any squish that is done to the Sharkoon, and clamps its upper limit to prevent it from becoming too tall if (ScaleSquish.Y > 1f) - ScaleSquish.Y = Math.Max(1f, ScaleSquish.Y - 0.025f); + ScaleSquish.Y = MathHelper.Clamp(ScaleSquish.Y, 1f, 1.5f); + ScaleSquish.Y = Math.Max(1f, ScaleSquish.Y - 0.025f); } private void IdlingBehavior() { // At random, the mob will choose a random nearby point and pathfind there. - pathfinding.DoPathfinding(new(NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * 2000f, SunkenSeaTileValidity)); + pathfinding.DoPathfinding(new(this, NPC.Center, NPC.Center + Main.rand.NextVector2Unit() * Main.rand.Next(IdleMinPathDistance, IdleMaxPathDistance), SunkenSeaTileValidity)); } private void HuntingBehavior() @@ -271,20 +280,7 @@ namespace CalamityMod.NPCs.SunkenSea HuntCooldown = Main.rand.Next(13, 30); // With sight, just go straight at him. Without it, try to pathfind over them. - pathfinding.DoPathfinding(new(NPC.Center, CurrentPrey.Center, SunkenSeaTileValidity), forceNewTask: huntReady); - pathfinding.CustomIdleBehavior = () => - { - if (CurrentPrey != null) - { - NPC.velocity += NPC.DirectionTo(CurrentPrey.Center) * pathfinding.Acceleration; - - // Cap the speed if MaxSpeed has been surpassed. - if (NPC.velocity.LengthSquared() > pathfinding.MaxSpeed * pathfinding.MaxSpeed) - NPC.velocity = Vector2.Normalize(NPC.velocity) * pathfinding.MaxSpeed; - } - else - NPC.velocity *= 0.95f; - }; + pathfinding.DoPathfinding(new(this, NPC.Center, CurrentPrey.Center, SunkenSeaTileValidity), forceNewTask: huntReady); HuntCooldown--; } @@ -305,19 +301,19 @@ namespace CalamityMod.NPCs.SunkenSea // Try to manuever if there are any obstacles. if (!Main.tile[(NPC.Center + NPC.DirectionFrom(_avoidedEntity.Center) * FleeTileAnticipationDistance).ToTileCoordinates()].IsTileSolid()) { - NPC.velocity += NPC.DirectionFrom(_avoidedEntity.Center) * pathfinding.Acceleration; + NPC.velocity += NPC.DirectionFrom(_avoidedEntity.Center) * Acceleration; pathfinding.ClearResults(); // Cap the speed if MaxSpeed has been surpassed. - if (NPC.velocity.LengthSquared() > pathfinding.MaxSpeed * pathfinding.MaxSpeed) - NPC.velocity = Vector2.Normalize(NPC.velocity) * pathfinding.MaxSpeed; + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; } else { float distanceFromAvoided = Vector2.Distance(NPC.Center, _avoidedEntity.Center); _randomPathPoint = NPC.Center + Main.rand.NextVector2Unit() * Utils.Remap(distanceFromAvoided, 0f, 960f, 80f, 3200f); NPC.netUpdate = true; - pathfinding.DoPathfinding(new(NPC.Center, _randomPathPoint, SunkenSeaTileValidity)); + pathfinding.DoPathfinding(new(this, NPC.Center, _randomPathPoint, SunkenSeaTileValidity)); } // If it's capable of exploding and the predator's within distance, kaboom. @@ -365,7 +361,7 @@ namespace CalamityMod.NPCs.SunkenSea { Vector2 velOffset = RandomVelocity(50f, 20f, 70f, 0.04f); velOffset *= Main.rand.NextFloat(15, 20) * fade; - Dust dust = Dust.NewDustPerfect(NPC.Center + velOffset * 2.5f, 267, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.8f, 0.95f)); + Dust dust = Dust.NewDustPerfect(NPC.Center + velOffset * 2.5f, DustID.RainbowMk2, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.8f, 0.95f)); dust.noGravity = true; dust.color = Color.Aqua; } @@ -397,7 +393,7 @@ namespace CalamityMod.NPCs.SunkenSea if (newBehavior == OutsideWaterBehavior) NPC.noGravity = false; - pathfinding.MinimumPointDistance = newBehavior == HuntingBehavior ? 20f : 48f; + MinimumPointDistance = newBehavior == HuntingBehavior ? 20f : 48f; } protected override void OnPreyDetection(NPC prey) @@ -442,18 +438,18 @@ namespace CalamityMod.NPCs.SunkenSea { if (CanExplode) { - for (int i = 0; i < 4; i++) - Gore.NewGoreDirect(NPC.GetSource_Death(), NPC.Center, new Vector2(hit.HitDirection, -1f), Mod.Find($"{Name}{i + 1}").Type); + SpawnGores(NPC, "Sharkoon", 6); } else { - for (int i = 0; i < 2; i++) - Gore.NewGoreDirect(NPC.GetSource_Death(), NPC.Center, new Vector2(hit.HitDirection, -1f), Mod.Find($"{Name}Small{i + 1}").Type); + SpawnGores(NPC, "SharkoonSmall", 2); } } } - public override bool CanBeHitByNPC(NPC attacker) => attacker.type != Type; + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override bool CanHitNPC(NPC target) => PreyIDs.Contains(target.type); public override void OnHitByNPC(NPC attacker) { @@ -495,13 +491,13 @@ namespace CalamityMod.NPCs.SunkenSea { for (int i = 0; i < 10; i++) { - Dust dust = Dust.NewDustPerfect(NPC.Center, 278, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(0.9f, 1.1f)); + Dust dust = Dust.NewDustPerfect(NPC.Center, DustID.FireworksRGB, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(0.9f, 1.1f)); dust.noGravity = false; dust.color = Main.rand.NextBool() ? Color.OrangeRed : Color.Orange; } for (int i = 0; i < 18; i++) { - Dust dust = Dust.NewDustPerfect(NPC.Center, 267, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(0.9f, 1.1f)); + Dust dust = Dust.NewDustPerfect(NPC.Center, DustID.RainbowMk2, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), 0, default, Main.rand.NextFloat(0.9f, 1.1f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.OrangeRed : Color.Orange; } @@ -516,6 +512,35 @@ namespace CalamityMod.NPCs.SunkenSea } } + public override void AwaitingPathBehavior() + { + if (CurrentBehavior == HuntingBehavior) + { + if (CurrentPrey != null) + { + NPC.velocity += NPC.DirectionTo(CurrentPrey.Center) * Acceleration; + + // Cap the speed if MaxSpeed has been surpassed. + if (NPC.velocity.LengthSquared() > MaxSpeed * MaxSpeed) + NPC.velocity = Vector2.Normalize(NPC.velocity) * MaxSpeed; + } + else + NPC.velocity *= 0.95f; + } + else + base.AwaitingPathBehavior(); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + if (spawnInfo.Player.Calamity().ZoneRadiantReefs) + return SpawnCondition.CaveJellyfish.Chance * 0.2f; + } + return 0f; + } + #endregion #region Drawing & Animation diff --git a/NPCs/SunkenSea/Shoreskipper.cs b/NPCs/SunkenSea/Shoreskipper.cs new file mode 100644 index 0000000000..6a63d540ff --- /dev/null +++ b/NPCs/SunkenSea/Shoreskipper.cs @@ -0,0 +1,466 @@ +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Enums; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Enemy; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader.Utilities; +using static CalamityMod.CalamityUtils; +using static Terraria.ModLoader.ModContent; +using CalamityMod.BiomeManagers; +using CalamityMod.Items.Critters; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Shoreskipper : SunkenSeaNPC + { + public enum PhaseType + { + Idle = 0, + Roar = 1, + Jumps = 2, + } + + public ref float CurrentPhase => ref NPC.ai[0]; + + public ref float Timer => ref NPC.ai[1]; + public bool spawnedTackleHitbox = false; + public bool notLandedFromWater = false; // When in water or just got out of water but not yet landed on solid ground + public NPC Target; // Chosen target (can only be other shoreskippers) + + #region SunkenSea Fields + protected override List PreyIDs => + [ + NPCType(), + ]; + protected override List PredatorIDs => + [ + NPCType(), + ]; + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.TimelessShores; + + protected override bool NPCSearchFilter(NPC n) + { + // Only consider same-type NPCs within 450 pixels + return n.active && n.type == Type && Vector2.DistanceSquared(NPC.Center, n.Center) < 450f * 450f; + } + protected override void OnPreyDetection(NPC prey) + { + if (prey.active && NPC.HasSight(prey.Center) && (Target == null || !Target.active)) + { + ChangePhase((int)PhaseType.Roar); + Target = prey; + } + } + #endregion + + + public override bool CanBeHitByNPC(NPC attacker) => true; + public override bool CanHitNPC(NPC target) => target.type == NPC.type; + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + public override bool? CanBeHitByItem(Player player, Item item) => true; + public override bool? CanBeHitByProjectile(Projectile projectile) => true; + + // If not a Shoreskipper tackle, nullify knockback + public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers) + { + if (projectile.type != ProjectileType()) + projectile.knockBack = 0f; + } + public override void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers) => modifiers.DisableKnockback(); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.DisableKnockback(); + + #region Syncing + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.ai[0]); + writer.Write(NPC.ai[1]); + writer.Write(NPC.ai[2]); + writer.Write(NPC.ai[3]); + writer.Write(NPC.Calamity().newAI[0]); + writer.Write(NPC.Calamity().newAI[1]); + writer.Write(spawnedTackleHitbox); + writer.Write(notLandedFromWater); + + int targetWhoAmI = Target == null || !Target.active ? -1 : Target.whoAmI; + writer.Write(targetWhoAmI); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.ai[0] = reader.ReadSingle(); + NPC.ai[1] = reader.ReadSingle(); + NPC.ai[2] = reader.ReadSingle(); + NPC.ai[3] = reader.ReadSingle(); + NPC.Calamity().newAI[0] = reader.ReadSingle(); + NPC.Calamity().newAI[1] = reader.ReadSingle(); + spawnedTackleHitbox = reader.ReadBoolean(); + notLandedFromWater = reader.ReadBoolean(); + + int targetWhoAmI = reader.ReadInt32(); + if (targetWhoAmI >= 0 && targetWhoAmI < Main.maxNPCs) + Target = Main.npc[targetWhoAmI]; + else + Target = null; + } + #endregion + + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 7; + Main.npcCatchable[Type] = true; + } + + public override void SetDefaults() + { + NPC.aiStyle = -1; + NPC.damage = 15; + NPC.width = 64; + NPC.height = 32; + NPC.defense = 4; + NPC.lifeMax = 80; + NPC.noGravity = false; + NPC.noTileCollide = false; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath9; + NPC.GravityIgnoresLiquid = true; + + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + + NPC.catchItem = (short)ModContent.ItemType(); + + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToElectricity = false; + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToWater = false; + + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Shoreskipper") + }); + } + public override bool? CanFallThroughPlatforms() + { + // Fall to try to reach target + if (CurrentPhase == (int)PhaseType.Jumps && Target.Top.Y > NPC.Bottom.Y) + return true; + + return false; + } + + private bool HasActiveTackle() // Check for if their melee hitbox exists as to not spawn multiple at once + { + int tackleType = ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.type == tackleType && proj.ai[0] == NPC.whoAmI) + return true; + } + return false; + } + + public override void AI() + { + NPC.Calamity().newAI[1]++; // Mark as out of water + NPC.TargetClosest(false); + + if (NPC.direction == 0) + { + NPC.direction = Main.rand.NextBool().ToDirectionInt(); + } + int frameHeight = TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type]; + + + if (NPC.velocity.Y == 0 && NPC.oldVelocity.Y != 0f && notLandedFromWater && !NPC.wet) // Do not maintain velocity from skipping on water + { + NPC.velocity.X = 0f; + notLandedFromWater = false; + } + + if (notLandedFromWater && !NPC.wet && NPC.velocity.Length() > 6.5f && Timer % 4 == 0) // When skipping on water at high enough velocity, spawns trailing rings + GeneralParticleHandler.SpawnParticle(new DirectionalPulseRing(NPC.Center, -NPC.velocity * 0.33f, Color.DeepSkyBlue * 0.65f, new Vector2(0.5f, 1f), NPC.rotation, 0.12f, 0.24f, 18)); + + + switch (CurrentPhase) + { + case (int)PhaseType.Idle: + { + int frameDuration = 10; + int currentFrameIndex = (int)(NPC.frameCounter / frameDuration) % Main.npcFrameCount[Type]; + // If it's the third frame + bool isAllowedToMove = NPC.frame.Y / frameHeight == 2; + +                        // Move horizontally in short bursts +                        if (Timer >= 10 && NPC.velocity.Y == 0 && Math.Abs(NPC.velocity.X) < 1 && NPC.ai[2] == 0 && isAllowedToMove) + { + NPC.ai[2] = 1; + NPC.velocity.X = Main.rand.NextFloat(1.75f, 2.5f) * Main.rand.NextBool().ToDirectionInt(); + if (Main.rand.NextBool(4)) + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ShoreskipperGrunt", 2) { Volume = 0.9f, PitchVariance = 0.15f }, NPC.Center); + } + + // Increment the timer before the slide ends + if (NPC.ai[2] == 1) + { + NPC.ai[3]++; + } + + // Slow down quickly after sliding + else if (NPC.ai[2] == 2 && NPC.velocity.Y == 0) + { + NPC.velocity.X *= 0.835f; + NPC.ai[3]++; + } + + // Handle movement states + if (NPC.ai[3] > Main.rand.Next(20, 40)) + { + // If moving, enter slowdown + if (NPC.ai[2] == 1) + NPC.ai[2] = 2; + // If in slowdown, reset + else if (NPC.ai[2] == 2) + ChangePhase((int)PhaseType.Idle); + NPC.ai[3] = 0; + } + + NPC.direction = NPC.velocity.X.DirectionalSign(); + } + break; + + // Based off of Leerslug's initial detection phase. + case (int)PhaseType.Roar: + { + int roar = 20; + int startAI = 35; + NPC.velocity.X *= 0.9f; + + // Roar in place with a lil jump + if (Timer == roar) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ShoreskipperSighting") { Volume = 0.85f, Pitch = -0.1f, PitchVariance = 0.1f }, NPC.Center); + if (NPC.velocity.Y == 0) + { + NPC.velocity.Y = -2.5f; + } + } + + NPC.direction = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + + if (Timer <= startAI && Timer >= roar && Timer % 5 == 0) + GeneralParticleHandler.SpawnParticle(new DirectionalPulseRing(NPC.Center + new Vector2((NPC.direction == 1 ? 28f : -28f), 0), Vector2.Zero, Color.Gray * 0.55f, new Vector2(1f, 1f), NPC.rotation, 0.05f, 0.6f, 16)); + + if (Timer > startAI) + ChangePhase((int)PhaseType.Jumps); + + if ((!Target.active || Target == null || (Target.Distance(NPC.Center) > 580 && !NPC.HasSight(Target.Center)) || Target.Distance(NPC.Center) > 700) && (NPC.velocity.Y == 0 || NPC.wet)) // If target it dead/out of range and if this shoreskipper isnt midair + { + NPC.velocity.X *= 0.33f; + Target = null; + ChangePhase((int)PhaseType.Idle); + } + } + break; + + case (int)PhaseType.Jumps: + { + // Hops toward the target + int jumpHeight = Target.Bottom.Y < NPC.Top.Y ? 6 : 4; + + // Reset hitbox status when grounded or right after exiting water + if (NPC.oldVelocity.Y != 0 && NPC.velocity.Y == 0 || (NPC.Calamity().newAI[1] == 1f)) + { + spawnedTackleHitbox = false; + NPC.velocity.X = 0; + } + + // Keep facing target while on the ground/water + if (NPC.velocity.Y == 0 || NPC.wet) + NPC.direction = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + + // Check if the shoreskipper landed + bool isGrounded = NPC.velocity.Y == 0; + + // Jump at the target on the 4th frame + bool isAtJumpFrame = NPC.frame.Y / frameHeight == 3; + + if ((!spawnedTackleHitbox && (isGrounded && isAtJumpFrame)) || (NPC.Calamity().newAI[1] == 1f && HasActiveTackle() == false)) // Latter set of conditions allows spawning a hitbox while skipping on water + { + if (isGrounded) + NPC.velocity.Y = -jumpHeight; + + // Face and chase after target + NPC.velocity.X = NPC.DirectionTo(Target.Center).X.DirectionalSign() * 4; + + // Spawn hitbox while jumping + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ProjectileType(), (int)(NPC.damage * Main.rand.NextFloat(0.7f, 1.4f)), Main.rand.Next(3, 7), Main.myPlayer, NPC.whoAmI); + if (Main.rand.NextBool()) + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ShoreskipperGrunt", 2) { Volume = 1f, PitchVariance = 0.15f }, NPC.Center); + + spawnedTackleHitbox = true; + } + } + + if ((!Target.active || Target == null || (Target.Distance(NPC.Center) > 580 && !NPC.HasSight(Target.Center)) || Target.Distance(NPC.Center) > 700) && (NPC.velocity.Y == 0 || NPC.wet)) // If target it dead/out of range and if this shoreskipper isnt midair + { + NPC.velocity.X = 0f; + Target = null; + ChangePhase((int)PhaseType.Idle); + } + } + break; + } + + NPC.StepUpBlocks(); + NPC.spriteDirection = NPC.direction; + + // In / on top of water + if (NPC.wet) + { + if (NPC.Calamity().newAI[0] == 0f || Timer % 120 == 0) + { + int newWaterDirection = NPC.direction; + if (Target != null && Target.active) + newWaterDirection = NPC.DirectionTo(Target.Center).X.DirectionalSign(); + else if (Main.rand.NextBool(3)) + newWaterDirection *= -1; + + NPC.Calamity().newAI[0] = newWaterDirection; + NPC.Calamity().newAI[1] = 0f; + } + + NPC.direction = (int)NPC.Calamity().newAI[0]; + NPC.velocity.Y = MathHelper.Min(NPC.velocity.Y - 0.2f, -4); + notLandedFromWater = true; + + float waterAcceleration = 2.75f; + // Accelerate up to the cap of 12 + if (Math.Abs(NPC.velocity.X) < 12f) + NPC.velocity.X += NPC.direction * waterAcceleration; + NPC.velocity.X = MathHelper.Clamp(NPC.velocity.X, -12f, 12f); + } + + else + { + // Reset the water direction AI slot when the NPC leaves the water + NPC.Calamity().newAI[0] = 0f; + + if (NPC.Calamity().newAI[1] == 0f) // Just got out of water + { + NPC.Calamity().newAI[1] = 1f; // Will spawn a hitbox if aggroed + } + } + + Timer++; + } + + public void ChangePhase(int phaseNum, bool resetai2 = true, bool resetai3 = true) + { + CurrentPhase = phaseNum; + Timer = 0; + if (resetai2) + NPC.ai[2] = 0; + if (resetai3) + NPC.ai[3] = 0; + NPC.netUpdate = true; + + // Reset anim progress + NPC.frame.Y = 0; + NPC.frameCounter = 0; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (!spawnInfo.Player.Calamity().clamity) + { + if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water) + return SpawnCondition.Cavern.Chance * 0.6f; + else if (spawnInfo.Player.Calamity().ZoneTimelessShores && spawnInfo.Water) + return SpawnCondition.Cavern.Chance * 0.25f; + } + return 0f; + } + + #region FX + Drawing + public override void FindFrame(int frameHeight) + { + bool isMidAir = NPC.velocity.Y != 0 && !NPC.wet; + int currentFrameIndex = NPC.frame.Y / frameHeight; + + if (CurrentPhase == (int)PhaseType.Roar) + { + NPC.frame.Y = 0; + return; + } + + if (isMidAir && NPC.frame.Y >= frameHeight * 4) + { + NPC.frame.Y = frameHeight * 4; // Cannot progress from last airborne frame until grounded again + return; + } + + NPC.frameCounter++; + if (NPC.frameCounter > (CurrentPhase == (int)PhaseType.Jumps ? 5 : 8)) // Progress faster when in jump phase + { + NPC.frameCounter = 0; + NPC.frame.Y += frameHeight; + if (NPC.frame.Y > frameHeight * (Main.npcFrameCount[Type] - 1)) + { + NPC.frame.Y = 0; + } + } + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 6; k++) + { + GeneralParticleHandler.SpawnParticle(new GenericBubbleParticle(NPC.Center, new Vector2(Main.rand.NextFloat(3f, 7f) * hit.HitDirection, Main.rand.NextFloat(-5f, 5f)).RotatedByRandom(1), Main.rand.NextFloat(0.22f, 0.52f), NPC.rotation, Main.rand.Next(7, 11))); + } + + for (int k = 0; k < 6; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.BloodWater, hit.HitDirection, -3f, 0, default, 0.8f); + } + SpawnGores(NPC, "Shoreskipper", 2); + } + + public override void OnKill() + { + for (int k = 0; k < 10; k++) + { + GeneralParticleHandler.SpawnParticle(new GenericBubbleParticle(NPC.Center, new Vector2(Main.rand.NextFloat(3.25f, 8.5f), Main.rand.NextFloat(-5f, 5f)).RotatedByRandom(MathHelper.TwoPi), Main.rand.NextFloat(0.26f, 0.62f), NPC.rotation, Main.rand.Next(8, 13))); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + if (NPC.IsABestiaryIconDummy) + return true; + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + Vector2 pos = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + + spriteBatch.Draw(tex, pos, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[NPC.type]), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : 0, 0); + + return false; + } + #endregion + } +} diff --git a/NPCs/SunkenSea/Shoreskipper.png b/NPCs/SunkenSea/Shoreskipper.png new file mode 100644 index 0000000000..2c0a735cd7 Binary files /dev/null and b/NPCs/SunkenSea/Shoreskipper.png differ diff --git a/NPCs/SunkenSea/Slugbun.cs b/NPCs/SunkenSea/Slugbun.cs new file mode 100644 index 0000000000..66c5f257ea --- /dev/null +++ b/NPCs/SunkenSea/Slugbun.cs @@ -0,0 +1,256 @@ +using CalamityMod.Items.Critters; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Microsoft.Xna.Framework; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; +using Terraria.Audio; +using Terraria.DataStructures; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using ReLogic.Content; +using CalamityMod.Enums; +using System.Collections.Generic; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Slugbun : SunkenSeaNPC + { + public enum SlugSkin + { + Reef = 0, + Burrows = 1, + Polyp = 2, + Radiant = 3 + } + public ref float CurrentSkin => ref NPC.Calamity().newAI[2]; + + public static Asset burrowsTex; + public static Asset polypTex; + public static Asset radiantTex; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.RadiantReefs | SunkenSeaBiomeFlags.PolypForest | SunkenSeaBiomeFlags.GleamingBurrows; + + protected override List PredatorIDs => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + + protected override List PreyIDs => new List(); + + public override void Load() + { + burrowsTex = ModContent.Request(Texture + "Gleaming"); + polypTex = ModContent.Request(Texture + "Polyp"); + radiantTex = ModContent.Request(Texture + "Radiant"); + } + + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 4; + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + base.SetDefaults(); + NPC.aiStyle = NPCAIStyleID.Snail; + NPC.damage = 0; + NPC.width = 38; + NPC.height = 28; + NPC.defense = 0; + NPC.lifeMax = 20; + NPC.knockBackResist = 0f; + NPC.lavaImmune = false; + NPC.noGravity = false; + NPC.noTileCollide = false; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.GravityIgnoresLiquid = true; + NPC.chaseable = false; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.catchItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < 3; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < 3; i++) + writer.Write(NPC.Calamity().newAI[i]); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Slugbun") + }); + } + + public override void OnSpawn(IEntitySource source) + { + // Guppies released by the player do not randomize when spawned + if (source is EntitySource_Parent parentSource && parentSource.Entity is Player) + { + CurrentSkin = NPC.ai[1]; + return; + } + // Red/Green in reefs, Green/Blue elsewhere + if (Main.player[NPC.target].Calamity().ZoneGleamingBurrows) + { + CurrentSkin = (int)SlugSkin.Burrows; + } + else if (Main.player[NPC.target].Calamity().ZoneRadiantReefs) + { + CurrentSkin = (int)SlugSkin.Reef; + } + else + { + CurrentSkin = (int)SlugSkin.Polyp; + } + NPC.TargetClosest(); + // 1 in 30 chance for a rare fish variant (rfv) + if (Main.rand.NextBool(30)) + { + CurrentSkin = (int)SlugSkin.Radiant; + NPC.rarity = 3; + } + // Decide item.......................... + switch (CurrentSkin) + { + case (int)SlugSkin.Polyp: + NPC.catchItem = ModContent.ItemType(); + break; + case (int)SlugSkin.Burrows: + NPC.catchItem = ModContent.ItemType(); + break; + case (int)SlugSkin.Reef: + NPC.catchItem = ModContent.ItemType(); + break; + case (int)SlugSkin.Radiant: + NPC.catchItem = ModContent.ItemType(); + break; + } + } + + public override void AI() + { + Tile vine = CalamityUtils.ParanoidTileRetrieval((int)NPC.position.X / 16, (int)NPC.position.Y / 16); + // Set newAI[0] to 1 if the Slug is inside of a vine + if (vine.TileType == ModContent.TileType() && !NPC.justHit) + { + NPC.Calamity().newAI[0] = 1; + } + // Otherwise reset eating-related variables + else + { + NPC.Calamity().newAI[1] = 0; + NPC.Calamity().newAI[0] = 0; + } + // Eating behavior + if (NPC.Calamity().newAI[0] == 1) + { + NPC.velocity.X *= 0.1f; + // Play a crunch sound and spawn some grass dust randomly + if (Main.rand.NextBool(20)) + { + SoundEngine.PlaySound(SoundID.Item2 with { Volume = 0.4f, Pitch = 1.2f }, NPC.Center); + for (int i = 0; i < 4; i++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Grass, Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(-1, 1), 40); + } + NPC.Calamity().newAI[1]++; + } + // After munching 10 times, the vine is broken and the Slugbun continues about its day + if (NPC.Calamity().newAI[1] == 10) + { + if (vine.TileType == ModContent.TileType()) + { + WorldGen.KillTile((int)NPC.position.X / 16, (int)NPC.position.Y / 16); + } + } + } + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter++; + if (NPC.frameCounter > 8) + { + NPC.frameCounter = 0; + NPC.frame.Y += frameHeight; + if (NPC.frame.Y > frameHeight * 3) + { + NPC.frame.Y = 0; + } + } + } + + public override void ModifyTypeName(ref string typeName) + { + if (CurrentSkin == (int)SlugSkin.Radiant) + { + typeName = CalamityUtils.GetTextValue("NPCs.RadiantSlugbun"); + } + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneGleamingBurrows && spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.CaveJellyfish.Chance * 1f; + } + return 0f; + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GreenBlood, hit.HitDirection, -1f, 0, default, 1f); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + switch (CurrentSkin) + { + case (int)SlugSkin.Burrows: + tex = burrowsTex.Value; + break; + case (int)SlugSkin.Polyp: + tex = polypTex.Value; + break; + case (int)SlugSkin.Radiant: + tex = radiantTex.Value; + break; + } + Vector2 pos = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY - (Vector2.UnitY * 6).RotatedBy(NPC.rotation); + spriteBatch.Draw(tex, pos, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[NPC.type]), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : 0, 0); + + return false; + } + } +} diff --git a/NPCs/SunkenSea/Slugbun.png b/NPCs/SunkenSea/Slugbun.png new file mode 100644 index 0000000000..c0cedac24e Binary files /dev/null and b/NPCs/SunkenSea/Slugbun.png differ diff --git a/NPCs/SunkenSea/SlugbunGleaming.png b/NPCs/SunkenSea/SlugbunGleaming.png new file mode 100644 index 0000000000..30eabd798a Binary files /dev/null and b/NPCs/SunkenSea/SlugbunGleaming.png differ diff --git a/NPCs/SunkenSea/SlugbunPolyp.png b/NPCs/SunkenSea/SlugbunPolyp.png new file mode 100644 index 0000000000..f66d3f3e55 Binary files /dev/null and b/NPCs/SunkenSea/SlugbunPolyp.png differ diff --git a/NPCs/SunkenSea/SlugbunRadiant.png b/NPCs/SunkenSea/SlugbunRadiant.png new file mode 100644 index 0000000000..3959bf1228 Binary files /dev/null and b/NPCs/SunkenSea/SlugbunRadiant.png differ diff --git a/NPCs/SunkenSea/Steampod.cs b/NPCs/SunkenSea/Steampod.cs new file mode 100644 index 0000000000..c5630ab79a --- /dev/null +++ b/NPCs/SunkenSea/Steampod.cs @@ -0,0 +1,498 @@ +using CalamityMod.Items.Placeables.Banners; +using Microsoft.Xna.Framework; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.GameContent.Bestiary; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; +using Terraria.Audio; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using ReLogic.Content; +using CalamityMod.Enums; +using System.Collections.Generic; +using System; +using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Ranged; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Steampod : SunkenSeaNPC + { + public enum PhaseType + { + Idle = 0, + Hunting = 1, + LaunchUpSide = 2 + } + + public static Asset glowTex; + + public ref float CurrentPhase => ref NPC.ai[0]; + + public ref float Timer => ref NPC.ai[1]; + + public ref float Jetting => ref NPC.ai[2]; + + public ref float WalkTimer => ref NPC.Calamity().newAI[0]; + + public ref float TurnTimer => ref NPC.Calamity().newAI[1]; + + public ref float WalkOrStand => ref NPC.Calamity().newAI[2]; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.BasaltGully; + + protected override List PredatorIDs => new List() + { + ModContent.NPCType() + }; + + protected override List PreyIDs => new List() + { + ModContent.NPCType() + }; + + public override void Load() + { + glowTex = ModContent.Request(Texture + "Glow"); + } + + public override void SetStaticDefaults() + { + Main.npcFrameCount[Type] = 17; + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + base.SetDefaults(); + NPC.aiStyle = -1; + NPC.damage = 40; + NPC.width = 44; + NPC.height = 44; + NPC.defense = 10; + NPC.lifeMax = 200; + NPC.knockBackResist = 0f; + NPC.value = Item.buyPrice(silver: 20); + NPC.lavaImmune = true; + NPC.noGravity = false; + NPC.noTileCollide = false; + NPC.HitSound = SoundID.NPCHit38; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.chaseable = false; + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToWater = true; + NPC.Calamity().VulnerableToCold = true; + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < 3; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < 3; i++) + writer.Write(NPC.Calamity().newAI[i]); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Steampod") + }); + } + + public override void AI() + { + switch (CurrentPhase) + { + case (int)PhaseType.Idle: + { + // Initialize its direction + if (NPC.direction == 0) + NPC.direction = Main.rand.NextBool() ? -1 : 1; + // Decide if it should walk or sit + float movementSpeed = CurrentPredator != null ? 2 : 1; + bool startMovement = false; + if (WalkTimer <= 0) + { + WalkTimer = Main.rand.Next(120, 270); + WalkOrStand = WalkOrStand <= 0 ? 1 : -1; + if (WalkOrStand == 1 && Main.rand.NextBool() && CurrentPrey == null) + { + NPC.direction *= -1; + } + startMovement = true; + } + bool lookingAtPredator = CurrentPredator != null && NPC.direction == Math.Sign(CurrentPredator.Center.X - NPC.Center.X); + bool pitCheck = FallCheck(16); + // If it bumps into something, jump or turn around + if ((!startMovement && TurnTimer <= 0 && (NPC.velocity.X == 0 || pitCheck) && WalkOrStand == 1) || lookingAtPredator) + { + // Jump if there are a couple tiles and a space above + if (!pitCheck && NPC.velocity.Y == 0 && !lookingAtPredator) + { + // Chance to do a jet + bool jet = Main.rand.NextBool(4) && Jetting == 0 && !NPC.lavaWet; + if (jet) + { + if (JumpCheck(16)) + { + TurnTimer = 0; + WalkTimer = 0; + WalkOrStand = 0; + Timer = 0; + CurrentPhase = (int)PhaseType.LaunchUpSide; + } + } + else if (JumpCheck(6)) + { + NPC.velocity.Y -= 7; + NPC.velocity.X = movementSpeed * NPC.direction; + WalkOrStand = 1; + TurnTimer = 10; + } + } + // Jet upwards if a pit is in the way + else if (Jetting == 0 && !NPC.lavaWet) + { + TurnTimer = 0; + WalkTimer = 0; + WalkOrStand = 0; + Timer = 0; + CurrentPhase = (int)PhaseType.LaunchUpSide; + } + } + // Attack + Entity target = CurrentPrey != null ? CurrentPrey : CurrentPlayer; + if (target != null) + { + if (NPC.HasSight(target.Center) && Jetting == 0) + { + TurnTimer = 0; + WalkTimer = 0; + WalkOrStand = 0; + Timer = 0; + CurrentPhase = (int)PhaseType.Hunting; + } + } + + // Move + if (!NPC.justHit) + { + if (WalkOrStand == 1) + NPC.velocity.X = MathHelper.Lerp(NPC.velocity.X, NPC.direction * movementSpeed, 0.05f); + else if (NPC.velocity.Y == 0) + NPC.velocity.X *= 0.95f; + } + else if (WalkOrStand == -1) + { + WalkTimer = 0; + if (CurrentPredator != null) + { + WalkOrStand = 1; + WalkTimer = Main.rand.Next(180, 340); + } + } + // Bounce on lava + if (NPC.lavaWet) + { + NPC.velocity.Y = MathHelper.Min(NPC.velocity.Y - 0.2f, -4); + } + CalamityUtils.StepUpBlocks(NPC); + } + break; + case (int)PhaseType.LaunchUpSide: + { + int jumpUp = 60; // When to jet up + int jetSide = jumpUp + 40; // When to jet sideways + int jetRate = NPC.lavaWet ? 1 : 2; // How often particles spawn + + // Reset if on ground or hit ceiling + if (NPC.velocity.Y == 0 && Jetting > 0 && Timer > 5) + { + NPC.velocity.Y = 0; + Timer = 0; + Jetting = -120; + CurrentPhase = (int)PhaseType.Idle; + NPC.rotation = 0; + break; + } + + // Increment timer while on the ground + if (NPC.velocity.Y == 0 && Jetting == 0) + { + NPC.velocity.X *= 0.95f; + Timer++; + } + + // Jump + if (Timer == jumpUp && Jetting == 0) + { + Jetting = 1; + NPC.velocity.Y = -12 * (NPC.lavaWet ? 1.5f : 1); + SoundEngine.PlaySound(DragonsBreath.FireballSound with { Pitch = 0.4f }, NPC.Center); + } + // Release particles + else if (Jetting == 1) + { + Timer++; + if (Timer > jumpUp) + { + NPC.velocity.Y += 0.01f; + if (Timer % jetRate == 0) + { + SeaFoamParticle p = new SeaFoamParticle(NPC.Center, -NPC.velocity, Color.LightCyan, Color.Cyan, Main.rand.NextFloat(0.4f, 0.8f), 180f, 0.05f); + GeneralParticleHandler.SpawnParticle(p); + } + } + if (Timer == jetSide) + { + Timer = 0; + Jetting = 2; + } + } + // Jet sideways + else if (Jetting == 2) + { + NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; + Timer++; + if (Timer == 1) + { + SoundEngine.PlaySound(DragonsBreath.FireballSound with { Pitch = 0.4f }, NPC.Center); + NPC.velocity.X = NPC.direction * 16; + NPC.velocity.Y = -2; + } + else if (Timer % jetRate == 0) + { + SeaFoamParticle p = new SeaFoamParticle(NPC.Center, -NPC.velocity, Color.LightCyan, Color.Cyan, Main.rand.NextFloat(0.4f, 0.8f), 180f, 0.05f); + GeneralParticleHandler.SpawnParticle(p); + } + if (Timer > 1) + { + NPC.velocity.X += -NPC.direction * 0.01f; + } + // Failsafe if it gets trapped in jet mode + if (Timer > 300) + { + NPC.velocity.Y = 0; + Timer = 0; + Jetting = -120; + CurrentPhase = (int)PhaseType.Idle; + NPC.rotation = 0; + break; + } + } + } + break; + case (int)PhaseType.Hunting: + { + int jumpUp = 60; + int jetSide = jumpUp + 20; + int jetRate = 1; + + Entity target = CurrentPrey != null ? CurrentPrey : CurrentPlayer; + + // If the target is gone, reset + if ((NPC.velocity.Y == 0 && Jetting > 0 && Timer > jetSide) || target == null) + { + NPC.velocity.Y = 0; + NPC.velocity.X = 0; + Timer = 0; + Jetting = -120; + CurrentPhase = (int)PhaseType.Idle; + NPC.rotation = 0; + break; + } + + // Jet towards the target + if (NPC.velocity.Y == 0 && Jetting == 0) + { + NPC.velocity.X *= 0.95f; + Timer++; + if (Timer == jumpUp && Jetting == 0) + { + Jetting = 1; + NPC.velocity = NPC.SafeDirectionTo(target.Center) * 20; + SoundEngine.PlaySound(DragonsBreath.FireballSound with { Pitch = 0.4f }, NPC.Center); + } + } + // Release particles + if (Jetting == 1) + { + Timer++; + if (Timer % jetRate == 0) + { + SeaFoamParticle p = new SeaFoamParticle(NPC.Center, -NPC.velocity, Color.LightCyan, Color.Cyan, Main.rand.NextFloat(0.4f, 0.8f), 180f, 0.05f); + GeneralParticleHandler.SpawnParticle(p); + } + NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; + } + // Failsafe reset + if (Timer > 300) + { + NPC.velocity.Y = 0; + Timer = 0; + Jetting = -120; + CurrentPhase = (int)PhaseType.Idle; + NPC.rotation = 0; + break; + } + } + break; + } + + if (Jetting < 0) + Jetting++; + + if (WalkTimer > 0) + WalkTimer--; + + if (TurnTimer > 0) + TurnTimer--; + + NPC.spriteDirection = NPC.direction; + } + + // Checks if the horizontal position in front of it has lava or is a pit so that the pod can avoid it + public bool FallCheck(int height) + { + Point startPos = NPC.direction == 1 ? NPC.Right.ToTileCoordinates() : NPC.Left.ToTileCoordinates(); + for (int i = 1; i < height; i++) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(startPos.X + NPC.direction, startPos.Y + i); + Tile above = CalamityUtils.ParanoidTileRetrieval(startPos.X + NPC.direction, startPos.Y + i - 2); + // If there's a tile, wegud + if (t.HasTile) + return false; + // If there's liquid or a pit, we not gud + if (t.LiquidAmount > 0 && above.LiquidAmount > 0) + return true; + + } + return true; + } + + // Checks if the horizontal position in front of the pod can be jumped up + public bool JumpCheck(int height) + { + Point startPos = NPC.direction == 1 ? NPC.BottomRight.ToTileCoordinates() : NPC.BottomLeft.ToTileCoordinates(); + bool canJump = false; + int add = NPC.direction == 1 ? 0 : -1; + int jumpHeight = height; + for (int i = jumpHeight; i > 0; i--) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(startPos.X + add, startPos.Y - i); + // If there are tiles obfuscating the jump position, return false + if (i > (jumpHeight - 2) && t.HasTile) + return false; + // If there is a tile to jump on, return true + if (t.HasTile) + { + canJump = true; + break; + } + } + return canJump; + } + + public override void FindFrame(int frameHeight) + { + bool still = (CurrentPhase == (int)PhaseType.Idle && NPC.velocity.X == 0); + if (!still) + { + NPC.frameCounter++; + } + if (NPC.frameCounter > 6) + { + NPC.frameCounter = 0; + NPC.frame.Y += frameHeight; + } + // Jet + if (Jetting > 0) + { + if (NPC.frame.Y >= 17 * frameHeight || NPC.frame.Y < 12 * frameHeight) + { + NPC.frame.Y = 12 * frameHeight; + } + } + // Curl up + else if (CurrentPhase != (int)PhaseType.Idle) + { + if (NPC.frame.Y > 11 * frameHeight) + { + NPC.frame.Y = 11 * frameHeight; + } + if (NPC.frame.Y < 7 * frameHeight) + { + NPC.frame.Y = 7 * frameHeight; + } + } + // Nothing + else if (still) + { + NPC.frame.Y = 7 * frameHeight; + } + // Walk + else + { + if (NPC.frame.Y >= 7 * frameHeight) + { + NPC.frame.Y = 0; + } + } + } + + protected override bool NPCSearchFilter(NPC n) + { + return base.NPCSearchFilter(n) || n == CurrentPrey && Vector2.DistanceSquared(NPC.Center, n.Center) < 960f * 960f; + } + + protected override bool PlayerSearchFilter(Player n) + { + return base.PlayerSearchFilter(n) || n == CurrentPlayer && Vector2.DistanceSquared(NPC.Center, n.Center) < 960f * 960f; + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneBasaltGully && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.Cavern.Chance * 0.5f; + } + return 0f; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage <= 0) + return; + target.AddBuff(BuffID.OnFire, 120); + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Lava, hit.HitDirection, -1f, 0, default, 1f); + } + CalamityUtils.SpawnGores(NPC, "Steampod", 3); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = TextureAssets.Npc[NPC.type].Value; + spriteBatch.Draw(tex, NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[NPC.type]), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : 0, 0); + spriteBatch.Draw(glowTex.Value, NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY, NPC.frame, Color.White, NPC.rotation, new Vector2(tex.Width / 2, tex.Height / 2 / Main.npcFrameCount[NPC.type]), NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : 0, 0); + + return false; + } + } +} diff --git a/NPCs/SunkenSea/Steampod.png b/NPCs/SunkenSea/Steampod.png new file mode 100644 index 0000000000..dffa275d82 Binary files /dev/null and b/NPCs/SunkenSea/Steampod.png differ diff --git a/NPCs/SunkenSea/SteampodGlow.png b/NPCs/SunkenSea/SteampodGlow.png new file mode 100644 index 0000000000..58d243d0ea Binary files /dev/null and b/NPCs/SunkenSea/SteampodGlow.png differ diff --git a/NPCs/SunkenSea/StormlionSentry.cs b/NPCs/SunkenSea/StormlionSentry.cs new file mode 100644 index 0000000000..8f26a13bc2 --- /dev/null +++ b/NPCs/SunkenSea/StormlionSentry.cs @@ -0,0 +1,335 @@ +using System; +using System.IO; +using CalamityMod.BiomeManagers; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Projectiles.Enemy; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class StormlionSentry : ModNPC + { + public ref float time => ref NPC.ai[0]; + public ref float attackTimer => ref NPC.ai[1]; + public ref float jitter => ref NPC.ai[2]; + public ref float jitterRate => ref NPC.localAI[0]; + public ref float headRot => ref NPC.localAI[1]; + public ref float attackFeedback => ref NPC.localAI[2]; + public bool canBeMoved => NPC.localAI[3] == 0; + public enum Mode + { + Idle, + Agressive, + Leaping, + Digging + } + public Mode AIState + { + get => (Mode)(int)NPC.ai[3]; + set => NPC.ai[3] = (int)value; + } + + public float fxFade = 1; + public float fxFadeInv => attackFeedback - 1; + public float targetRange = 830; + public int attackRate = 180; + public int digDir = 1; + public Vector2 headPosition; + public Vector2 attackPosition; + + public static Asset headTexture; + public static Asset mandibleTexture; + public static Asset bodyTexture; + + public override void Load() + { + headTexture = ModContent.Request(Texture + "Head"); + mandibleTexture = ModContent.Request(Texture + "Mandible"); + bodyTexture = ModContent.Request(Texture + "Body"); + } + + public override void SetStaticDefaults() + { + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { PortraitPositionXOverride = 20f }; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; + } + + public override void SetDefaults() + { + NPC.width = 50; + NPC.height = 108; + NPC.lifeMax = 60; + NPC.damage = 15; + NPC.defense = 3; + NPC.knockBackResist = 0f; + NPC.value = Item.buyPrice(silver: 1); + NPC.HitSound = Effects.StormlionEffects.Hit; + NPC.DeathSound = Effects.StormlionEffects.Killed; + NPC.noGravity = true; + NPC.noTileCollide = true; // Custom tile collision + + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + + AIState = Mode.Idle; + attackFeedback = 1; + headRot = -MathHelper.PiOver2; + + Banner = NPC.type; + BannerItem = ModContent.ItemType(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.localAI[0]); + writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.localAI[0] = reader.ReadSingle(); + NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange( + [ + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.StormlionSentry") + ]); + } + + public override void AI() + { + NPC.TargetClosest(false); + Player target = Main.player[NPC.target]; + NPC.spriteDirection = NPC.direction; + + bool npcFullyInTiles = Collision.SolidCollision(NPC.Center - Vector2.UnitY * 13, 15, 15); + bool npcOnTiles = Collision.SolidCollision(NPC.Center + Vector2.UnitY * 10, 15, 15); + bool targetInRange = Utils.Distance(target.Center, NPC.Center) <= targetRange && Collision.CanHit(headPosition, 1, 1, target.Center, 1, 1); + + attackFeedback = MathHelper.Lerp(attackFeedback, 1, 0.025f); + fxFade = Utils.GetLerpValue(0, attackRate, attackTimer, true); + + if (!npcOnTiles) + { + if (NPC.velocity.Y < 0) + NPC.velocity.Y *= 0.97f; + if (NPC.velocity.Y < 20) + NPC.velocity.Y += 0.5f; + NPC.velocity.X *= 0.97f; + } + + if (!npcFullyInTiles && npcOnTiles && AIState != Mode.Digging) + { + NPC.localAI[3] = 5; + AIState = Mode.Digging; + } + if (AIState == Mode.Idle) + { + attackTimer = (int)MathHelper.Lerp(attackTimer, 0, 0.01f); + jitterRate = MathHelper.Lerp(jitterRate, 0.1f, 0.05f); + headRot = headRot.AngleLerp(-Vector2.UnitY.ToRotation(), 0.02f); + if (targetInRange && !canBeMoved) + AIState = Mode.Agressive; + + if (Main.rand.NextBool(15) && time % 60 == 0) + { + jitterRate = 4.7f; + SoundEngine.PlaySound((Main.rand.NextBool() ? Effects.StormlionEffects.Idle1 : Effects.StormlionEffects.Idle2) with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.2f, 0.1f) }, NPC.Center); + } + } + if (AIState == Mode.Agressive) + { + if (!targetInRange && attackTimer >= 0) + AIState = Mode.Idle; + + if (attackTimer >= 0) + { + jitterRate = MathHelper.Lerp(jitterRate, 1f + 3f * Utils.GetLerpValue(0, attackRate, attackTimer), 0.035f); + headRot = headRot.AngleLerp(NPC.Center.DirectionTo(target.Center).ToRotation(), 0.035f); + } + else + headRot = headRot.AngleLerp(NPC.Center.DirectionTo(target.Center).ToRotation(), 0.01f); + + if (attackTimer == attackRate) + { + SoundEngine.PlaySound(Effects.StormlionEffects.Attack with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, NPC.Center); + + Projectile.NewProjectile(NPC.GetSource_FromThis(), attackPosition, (headRot.ToRotationVector2() * 12), ModContent.ProjectileType(), 15, 0f, Main.myPlayer); + for (int i = 0; i <= 12; i++) + { + float variance = Main.rand.NextFloat(-0.6f, 0.6f); + int dustStyle = Effects.StormlionEffects.EnergyDust; + Dust dust2 = Dust.NewDustPerfect(attackPosition, dustStyle); + dust2.scale = Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance); + dust2.velocity = (headRot.ToRotationVector2() * 15).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)); + dust2.noGravity = true; + dust2.color = Effects.StormlionEffects.EnergyColor; + } + + attackFeedback = 2; + attackTimer = -60; + jitterRate = 0; + NPC.ForceNetUpdate(); + } + attackTimer++; + } + if (AIState == Mode.Digging) + { + if (time % 10 == 0) + { + NPC.velocity = Vector2.Zero; + headRot = MathHelper.ToRadians(4 * digDir) - MathHelper.PiOver2; + SoundEngine.PlaySound(SoundID.WormDig with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, NPC.Center); + NPC.Center += Vector2.UnitY * 2; + digDir *= -1; + } + if (npcFullyInTiles) + AIState = Mode.Idle; + } + + if (!canBeMoved) + NPC.velocity = Vector2.Zero; + + + bool dancing = false; // They will dance if a "music projectile" is on screen of if the player is using an instrument (except drums because that would be annoying to make work) + for (int x = 0; x < Main.maxProjectiles; x++) + { + if (Main.mouseLeft && (target.HeldItem.type == ItemID.Bell || target.HeldItem.type == ItemID.CarbonGuitar || target.HeldItem.type == ItemID.IvyGuitar || target.HeldItem.type == ItemID.Harp || target.HeldItem.type == ItemID.TheAxe)) + { + dancing = true; + } + Projectile projectile = Main.projectile[x]; + if (!dancing && projectile.active && (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ProjectileID.SparkleGuitar || projectile.type == ProjectileID.EighthNote || projectile.type == ProjectileID.QuarterNote || projectile.type == ProjectileID.TiedEighthNote)) + { + dancing = true; + } + } + + if (dancing) + { + float sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 14.37f / MathHelper.Pi); + if (Main.zenithWorld) + { + if (time % 2 == 0) + { + SoundEngine.PlaySound(Effects.StormlionEffects.Attack with { Volume = 0.2f, Pitch = 0.4f * sine, MaxInstances = 30 }, NPC.Center); + Projectile proj = Projectile.NewProjectileDirect(NPC.GetSource_FromThis(), attackPosition, (headRot.ToRotationVector2() * 6), ModContent.ProjectileType(), 15 * target.statLifeMax2, 0f, Main.myPlayer); + proj.friendly = true; + proj.hostile = false; + } + fxFade = 1; + attackTimer = attackRate * 0.9f; + } + else + attackTimer = 0; + jitterRate = 1; + NPC.dontTakeDamage = true; + headRot = MathHelper.ToRadians(100 * sine) - MathHelper.PiOver2; + AIState = Mode.Idle; + } + else + NPC.dontTakeDamage = false; + + float orbSine = (float)Math.Sin(time * 0.575f / MathHelper.Pi) * Utils.GetLerpValue(attackRate * 1.1f, 0, attackTimer); + headPosition = NPC.Center - (Vector2.UnitY * 27).RotatedBy(NPC.rotation) + headRot.ToRotationVector2() * 12 + NPC.velocity; + attackPosition = headPosition + headRot.ToRotationVector2() * (25 + 8 * orbSine); + NPC.rotation = Utils.AngleLerp(0, headRot + MathHelper.PiOver2, 0.35f); + + + if (fxFade > 0) + { + Lighting.AddLight(attackPosition, Effects.StormlionEffects.EnergyColor.ToVector3() * 0.7f * fxFade); + } + + time++; + jitter += jitterRate; + } + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 5; k++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, Effects.StormlionEffects.FleshDust, hit.HitDirection, -1f, 0, Effects.StormlionEffects.FleshColor, Main.rand.NextFloat(0.7f, 1.1f)); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 35; k++) + { + bool type = !Main.rand.NextBool(3); + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, type ? Effects.StormlionEffects.EnergyDust : Effects.StormlionEffects.FleshDust, hit.HitDirection, -1f, 0, type ? Effects.StormlionEffects.EnergyColor : Effects.StormlionEffects.FleshColor, Main.rand.NextFloat(0.7f, 1.1f)); + } + CalamityUtils.SpawnGores(NPC, "StormlionSentry", 3); + } + } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + return false; + } + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + Vector2 spawnPosition = new Vector2(spawnInfo.SpawnTileX * 16 + 8, spawnInfo.SpawnTileY * 16); + bool npcOnTiles = Collision.SolidCollision(spawnPosition + Vector2.UnitY * 50, 20, 20); + + if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity && npcOnTiles) + { + return SpawnCondition.Cavern.Chance * 8f; + } + return 0f; + } + public override void ModifyNPCLoot(NPCLoot npcLoot) + { + npcLoot.Add(ModContent.ItemType()); + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex = TextureAssets.Npc[Type].Value; + if (NPC.IsABestiaryIconDummy) + { + spriteBatch.Draw(tex, NPC.Center - screenPos, null, drawColor, NPC.rotation, tex.Size() / 2f, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + return false; + } + if (time == 0) + return false; + + Texture2D body = bodyTexture.Value; + Texture2D head = headTexture.Value; + Texture2D mandible = mandibleTexture.Value; + Texture2D attack = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + spriteBatch.Draw(body, NPC.Center - screenPos, null, drawColor, NPC.rotation, body.Size() / 2f, NPC.scale, SpriteEffects.None, 0f); + spriteBatch.Draw(head, headPosition - screenPos, null, drawColor, headRot + MathHelper.PiOver2, head.Size() / 2f, NPC.scale, SpriteEffects.None, 0f); + for (int i = -1; i <= 1; i += 2) + { + float sine = (float)Math.Sin(jitter * 0.575f / MathHelper.Pi) * Utils.GetLerpValue(4.8f, 0, jitterRate); + Vector2 madiblePos = headPosition + (Vector2.UnitX * 10 * i).RotatedBy(headRot + MathHelper.PiOver2); + Vector2 madibleOrigin = (new Vector2(i == 1 ? 0 : mandible.Width, mandible.Height)); + float mandibleRot = MathHelper.ToRadians(5 * i) + MathHelper.Lerp(MathHelper.ToRadians(20) * sine * i, MathHelper.ToRadians(50) * i * fxFadeInv, fxFadeInv); + spriteBatch.Draw(mandible, madiblePos - screenPos, null, drawColor, headRot + mandibleRot + MathHelper.PiOver2, madibleOrigin, NPC.scale, i == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + } + + if (attackTimer > 0) + { + float fade = (float)Math.Pow(fxFade, 2); + for (int i = 0; i < 3; i++) + spriteBatch.Draw(attack, attackPosition - screenPos, null, Color.Lerp(Effects.StormlionEffects.EnergyColor, Color.White, i * 0.3f) with { A = 0 } * fade, headRot, attack.Size() / 2f, (NPC.scale * 0.3f - (i * 0.08f)) * fade * Main.rand.NextFloat(0.8f, 1.1f), SpriteEffects.None, 0f); + } + return false; + } + } +} diff --git a/NPCs/SunkenSea/StormlionSentry.png b/NPCs/SunkenSea/StormlionSentry.png new file mode 100644 index 0000000000..8e5990842a Binary files /dev/null and b/NPCs/SunkenSea/StormlionSentry.png differ diff --git a/NPCs/SunkenSea/StormlionSentryBody.png b/NPCs/SunkenSea/StormlionSentryBody.png new file mode 100644 index 0000000000..0e8b945f4d Binary files /dev/null and b/NPCs/SunkenSea/StormlionSentryBody.png differ diff --git a/NPCs/SunkenSea/StormlionSentryHead.png b/NPCs/SunkenSea/StormlionSentryHead.png new file mode 100644 index 0000000000..eefe88b4e4 Binary files /dev/null and b/NPCs/SunkenSea/StormlionSentryHead.png differ diff --git a/NPCs/SunkenSea/StormlionSentryMandible.png b/NPCs/SunkenSea/StormlionSentryMandible.png new file mode 100644 index 0000000000..474cbbfaa0 Binary files /dev/null and b/NPCs/SunkenSea/StormlionSentryMandible.png differ diff --git a/NPCs/SunkenSea/SunkenSeaNPC.cs b/NPCs/SunkenSea/SunkenSeaNPC.cs index 7ed695128d..79991669b4 100644 --- a/NPCs/SunkenSea/SunkenSeaNPC.cs +++ b/NPCs/SunkenSea/SunkenSeaNPC.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Enums; +using CalamityMod.Pathfinding; +using CalamityMod.Pathfinding.Movements; using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Terraria; @@ -16,10 +18,10 @@ namespace CalamityMod.NPCs.SunkenSea /// An abstract class that provides the necessary members for an NPC to function as a Sunken Sea NPC.
/// These NPCs can hunt both players and other NPCs, and maintain lists of NPCs they hunt and avoid. ///
- public abstract class SunkenSeaNPC : ModNPC + public abstract class SunkenSeaNPC : ModNPC, IPathfinder { protected PathfindingManager pathfinding = null; - + private NPC _currentPrey; private NPC _currentPredator; private Player _currentPlayer; @@ -98,8 +100,6 @@ namespace CalamityMod.NPCs.SunkenSea BiomeDesignation.HasFlag(flag)) .Select(flag => SunkenSeaBiomeCorrespondentDict.Dict[flag].BiomeType) .ToArray(); - - Banner = Type; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -147,7 +147,7 @@ namespace CalamityMod.NPCs.SunkenSea ///
/// The NPC to evaluate. /// if the NPC is a valid target; otherwise, . - protected virtual bool NPCSearchFilter(NPC n) => NPC.HasSight(n.Center) && Vector2.DistanceSquared(NPC.Center, n.Center) < 72900f; + protected virtual bool NPCSearchFilter(NPC n) => NPC.HasSight(n.Center) && Vector2.DistanceSquared(NPC.Center, n.Center) < 72900f && (PreyIDs.Contains(n.type) || PredatorIDs.Contains(n.type)) && !(n.type == ModContent.NPCType() && n.alpha > 0); /// /// Updates the current targets of this creature, including prey, predators, and players, based on detection logic. @@ -155,29 +155,24 @@ namespace CalamityMod.NPCs.SunkenSea protected void UpdateTargets() { var searchResults = SearchForTarget(NPC, playerFilter: PlayerSearchFilter, npcFilter: NPCSearchFilter); - if (searchResults.FoundTarget) - { - if (searchResults.FoundNPC) - { - if (PredatorIDs.Contains(searchResults.NearestNPC.type)) - CurrentPredator = searchResults.NearestNPC; - else - CurrentPredator = null; - if (PreyIDs.Contains(searchResults.NearestNPC.type)) - CurrentPrey = searchResults.NearestNPC; - else - CurrentPrey = null; - } - - CurrentPlayer = searchResults.NearestTankOwner; - } - else + if (!searchResults.FoundTarget) { - CurrentPredator = null; - CurrentPrey = null; - CurrentPlayer = null; + (CurrentPredator, CurrentPrey, CurrentPlayer) = (null, null, null); + return; } + + CurrentPlayer = searchResults.NearestTankOwner; + + if (!searchResults.FoundNPC) + { + (CurrentPredator, CurrentPrey) = (null, null); + return; + } + + var nearestNPC = searchResults.NearestNPC; + CurrentPredator = PredatorIDs.Contains(nearestNPC.type) ? nearestNPC : null; + CurrentPrey = PreyIDs.Contains(nearestNPC.type) ? nearestNPC : null; } /// @@ -187,10 +182,79 @@ namespace CalamityMod.NPCs.SunkenSea /// if the tile is valid; otherwise, . protected bool SunkenSeaTileValidity(Point point) { - Point actualFuckingPoint = new Point(point.X * 16, point.Y * 16); - return NPC.Hitbox.Contains(actualFuckingPoint) - || !NPC.GetIntersectingHitboxPoints( - actualFuckingPoint, 10, 10).Any(a => Main.tile[a].IsTileSolidGround() || Main.tile[a].LiquidAmount < 255 || Main.tile[a].LiquidType != LiquidID.Water); + return SunkenSeaTileValidity(NPC, point); } + + /// + /// Checks whether a specific tile is valid for this NPC, considering water level. + /// + /// The tile location to check. + /// if the tile is valid; otherwise, . + protected bool SunkenSeaTileValiditySizeless(Point point) + { + return SunkenSeaTileValidity(NPC, point, false); + } + + /// + /// Checks whether a specific tile is valid for an NPC, considering water level and entity size if given. + /// + /// The npc to use for the check. + /// The tile location to check. + /// if the tile is valid; otherwise, . + public static bool SunkenSeaTileValidity(NPC npc, Point point, bool accountForSize = true) + { + Point actualFuckingPoint = new Point(point.X * 16, point.Y * 16); + + if (accountForSize) + { + return npc.Hitbox.Contains(actualFuckingPoint) + || !npc.GetIntersectingHitboxPoints( + actualFuckingPoint, 10, 10).Any(a => Main.tile[a].IsTileSolidGround() || Main.tile[a].LiquidAmount < 255 || Main.tile[a].LiquidType != LiquidID.Water); + } + else + { + return !(Main.tile[point].IsTileSolidGround() || Main.tile[point].LiquidAmount < 255 || Main.tile[point].LiquidType != LiquidID.Water); + } + } + + /// + /// Checks whether a specific tile is valid for a lava NPC, considering water level and entity size if given. + /// + /// The tile location to check. + /// if the tile is valid; otherwise, . + public bool LavaTileValidity(Point point) + { + Point actualFuckingPoint = new Point(point.X * 16, point.Y * 16); + + return NPC.Hitbox.Contains(actualFuckingPoint) + || !NPC.GetIntersectingHitboxPoints( + actualFuckingPoint, 10, 10).Any(a => Main.tile[a].IsTileSolidGround() || Main.tile[a].LiquidAmount < 255 || Main.tile[a].LiquidType != LiquidID.Lava); + } + + #region IPathfinder Implementation + + /// + /// The acceleration this PathfindingManager will impart to its Entity when making it follow a found path.
+ /// This has no impact on the Entity's other behaviors, AI, etc. + ///
+ public float Acceleration { get; set; } = 0.2f; + + /// + /// The maximum speed this PathfindingManager allow its Entity to move at when making it follow a found path.
+ /// This has no impact on the Entity's other behaviors, AI, etc. + ///
+ public float MaxSpeed { get; set; } = 4f; + + /// + /// The minimum distance this PathdingManager requires its Entity to reach from its target point before the point is marked as "reached".
+ /// This has no impact on the Entity's other behaviors, AI, etc. + ///
+ public float MinimumPointDistance { get; set; } = 48f; + + public virtual IEnumerable Movements => [new SunkenSeaSwimMovement(NPC)]; + + public virtual void AwaitingPathBehavior() => NPC.velocity *= 0.95f; + + #endregion } } diff --git a/NPCs/SupremeCalamitas/BrimstoneHeart.cs b/NPCs/SupremeCalamitas/BrimstoneHeart.cs index adca018fa0..67001bc4e5 100644 --- a/NPCs/SupremeCalamitas/BrimstoneHeart.cs +++ b/NPCs/SupremeCalamitas/BrimstoneHeart.cs @@ -10,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { + [HasPierceResist] public class BrimstoneHeart : ModNPC { public int ChainHeartIndex => (int)NPC.ai[0]; @@ -78,7 +79,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); } - public float PrimitiveWidthFunction(float completionRatio) + public float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float widthInterpolant = Utils.GetLerpValue(0f, 0.16f, completionRatio, true) * Utils.GetLerpValue(1f, 0.84f, completionRatio, true); widthInterpolant = (float)Math.Pow(widthInterpolant, 8D); @@ -87,7 +88,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas return baseWidth + pulseWidth; } - public Color PrimitiveColorFunction(float completionRatio) + public Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float colorInterpolant = MathHelper.SmoothStep(0f, 1f, Utils.GetLerpValue(0f, 0.34f, completionRatio, true) * Utils.GetLerpValue(1.07f, 0.66f, completionRatio, true)); return Color.Lerp(Color.DarkRed * 0.7f, Color.Red, colorInterpolant) * 0.425f; diff --git a/NPCs/SupremeCalamitas/CirrusHeadIcon.png b/NPCs/SupremeCalamitas/CirrusHeadIcon.png deleted file mode 100644 index b322de98ea..0000000000 Binary files a/NPCs/SupremeCalamitas/CirrusHeadIcon.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/CirrusHeadIcon2.png b/NPCs/SupremeCalamitas/CirrusHeadIcon2.png deleted file mode 100644 index 2052f7d75f..0000000000 Binary files a/NPCs/SupremeCalamitas/CirrusHeadIcon2.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SepulcherArm.cs b/NPCs/SupremeCalamitas/SepulcherArm.cs index ecc059ac8c..9ab0e52ae9 100644 --- a/NPCs/SupremeCalamitas/SepulcherArm.cs +++ b/NPCs/SupremeCalamitas/SepulcherArm.cs @@ -5,7 +5,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.GameContent; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/NPCs/SupremeCalamitas/SepulcherBodyEnergyBall.cs b/NPCs/SupremeCalamitas/SepulcherBodyEnergyBall.cs index 32fd48411e..a761da29c0 100644 --- a/NPCs/SupremeCalamitas/SepulcherBodyEnergyBall.cs +++ b/NPCs/SupremeCalamitas/SepulcherBodyEnergyBall.cs @@ -1,11 +1,8 @@ using System.IO; -using CalamityMod.Events; -using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -104,31 +101,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas else NPC.alpha = HeadSegment.alpha; - /*AttackTimer += BossRushEvent.BossRushActive ? 1.5f : 1f; - float attackgate = !HeadSegment.Calamity().unbreakableDR && Main.zenithWorld ? 450f : 900f; - if (AttackTimer >= attackgate && NoStartAttack <= 0) - { - AttackTimer = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - int totalProjectiles = 4; - float radians = MathHelper.TwoPi / totalProjectiles; - float velocity = 1f; - float projectileVelocityToPass = 15f; - - Vector2 spinningPoint = Vector2.Normalize(new Vector2(-velocity, -velocity)); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 projectileVelocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileVelocityToPass); - } - NPC.netUpdate = true; - } - SoundEngine.PlaySound(SupremeCalamitas.BrimstoneShotSound, NPC.Center); - }*/ - if (Main.npc.IndexInRange((int)NPC.ai[1])) { Vector2 offsetToAheadSegment = AheadSegment.Center - NPC.Center; diff --git a/NPCs/SupremeCalamitas/SepulcherHead.cs b/NPCs/SupremeCalamitas/SepulcherHead.cs index 244db411f1..450d89ee69 100644 --- a/NPCs/SupremeCalamitas/SepulcherHead.cs +++ b/NPCs/SupremeCalamitas/SepulcherHead.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Events; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -12,7 +11,6 @@ using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.NPCs.SupremeCalamitas { @@ -201,8 +199,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 segmentLocation = NPC.Center; float targetX = CalamityGlobalNPC.SCal < 0 ? 0 : Main.npc[CalamityGlobalNPC.SCal].position.X + (Main.player[NPC.target].width / 2); float targetY = CalamityGlobalNPC.SCal < 0 ? 0 : Main.npc[CalamityGlobalNPC.SCal].position.Y + (Main.player[NPC.target].height / 2); - float sepMaxSpeed = BossRushEvent.BossRushActive ? 22.5f : 20f; - float sepAcceleration = (BossRushEvent.BossRushActive ? 0.2f : 0.175f) + (0.37f - AttackCooldown * 0.0015f); + float sepMaxSpeed = 20f; + float sepAcceleration = 0.175f + (0.37f - AttackCooldown * 0.0015f); float fasterMaxSpeed = sepMaxSpeed * 1.3f; float slowerMaxSpeed = sepMaxSpeed * 0.7f; @@ -336,7 +334,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = (int)(NPC.GetProjectileDamage(type) * 0.5f); int totalProjectiles = 30; float radians = MathHelper.TwoPi / totalProjectiles; float velocity = 1f; @@ -345,7 +342,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int k = 0; k < totalProjectiles; k++) { Vector2 projectileVelocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 3f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projectileVelocity, type, SupremeCalamitas.DartDamage, 0f, Main.myPlayer, 0f, 3f, projectileVelocityToPass); } NPC.netUpdate = true; } diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs index ce3a029a3b..cbc4899fa3 100644 --- a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs +++ b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs @@ -1,8 +1,6 @@ using System.IO; using CalamityMod.Dusts; -using CalamityMod.Events; using CalamityMod.Projectiles.Boss; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -13,8 +11,6 @@ using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Particles; -using Steamworks; -using CalamityMod.Items.Weapons.Summon; namespace CalamityMod.NPCs.SupremeCalamitas { @@ -57,13 +53,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SetDefaults() { + NPC.damage = 0; // No contact damage NPC.aiStyle = -1; AIType = -1; NPC.width = 40; NPC.height = 40; NPC.noGravity = true; NPC.noTileCollide = true; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats NPC.defense = 60; NPC.DR_NERD(NormalDR); NPC.lifeMax = 28000; @@ -130,7 +126,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Increase DR if the target leaves SCal's arena. NPC.Calamity().DR = NormalDR; - if (SCal.ModNPC().IsTargetOutsideOfArena) + if (SCal.ModNPC().protectionBoost) NPC.Calamity().DR = SupremeCalamitas.enragedDR; // Get a target @@ -144,7 +140,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.spriteDirection = (Target.Center.X < NPC.Center.X).ToDirectionInt(); timer++; - int shootRate = BossRushEvent.BossRushActive ? 120 : 180; + int shootRate = 180; if (timer > shootRate) { foreach (NPC seeker in Main.ActiveNPCs) @@ -162,10 +158,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas { float targetDist = Vector2.Distance(Target.Center, NPC.Center); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (BossRushEvent.BossRushActive) - damage /= 2; - float velocity = 5f; float projectileVelocityToPass = velocity * 3f; Vector2 shootVelocity = (Target.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; @@ -181,7 +173,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else { - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, shootVelocity * 0.5f, type, damage, 1f, Main.myPlayer, 0f, 3f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, shootVelocity * 0.5f, type, SupremeCalamitas.DartDamage, 1f, Main.myPlayer, 0f, 3f, projectileVelocityToPass); for (int i = 0; i < 5; i++) { Dust ShotDust = Dust.NewDustPerfect(NPC.Center, Main.rand.NextBool(3) ? 60 : 114); diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 9b61f820d5..d27b72b1ba 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -2,19 +2,16 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using CalamityMod.Buffs.Alcohol; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items; -using CalamityMod.Items.Accessories; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Fishing.FishingRods; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -23,15 +20,19 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Items.Weapons.Typeless; using CalamityMod.NPCs.Bumblebirb; using CalamityMod.NPCs.DevourerofGods; -using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; +using CalamityMod.Systems.Collections; +using CalamityMod.Systems.Mechanic; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; +using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -40,12 +41,6 @@ using Terraria.GameContent.ItemDropRules; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; -using ReLogic.Utilities; -using CalamityMod.Projectiles.Ranged; -using Steamworks; -using CalamityMod.Particles; -using Terraria.Utilities.Terraria.Utilities; -using CalamityMod.Systems.Collections; namespace CalamityMod.NPCs.SupremeCalamitas { @@ -65,15 +60,37 @@ namespace CalamityMod.NPCs.SupremeCalamitas Count = 7 } + public static Color CurrentColor + { + get + { + if (CalamityGlobalNPC.SCal < 0) + return AcceptanceColor; + + var npc = Main.npc[CalamityGlobalNPC.SCal]; + if (npc == null || !npc.active) + return AcceptanceColor; + + if (npc.ModNPC is not SupremeCalamitas calamitas || calamitas.ArenaBox is null) + return AcceptanceColor; + + return calamitas.ArenaBox.borderColor; + } + } + public static Color GriefColor => Color.Crimson; + public static Color LamentColor => Color.RoyalBlue; + public static Color EpiphanyColor => new Color(219, 75, 2); + public static Color AcceptanceColor => Color.Gray; + public const int BulletHellDuration = 900; public const int SecondBulletHellEndValue = BulletHellDuration * 2; public const int ThirdBulletHellEndValue = BulletHellDuration * 3; public const int FourthBulletHellEndValue = BulletHellDuration * 4; public const int FifthBulletHellEndValue = BulletHellDuration * 5; - public const int CirrusPhotonRipperDamage = 3725; - private const float CirrusPhotonRipperDashVelocity = 6f; - private const float CirrusPhotonRipperMinDistanceFromTarget = 64f; - private const float CirrusPhotonRipperDashAcceleration = 0.3f; + public const int PermafrostAbsoluteZeroDamage = 3725; + private const float PermafrostPhotonRipperDashVelocity = 6f; + private const float PermafrostPhotonRipperMinDistanceFromTarget = 64f; + private const float PermafrostPhotonRipperDashAcceleration = 0.3f; public float bossLife; public float uDieLul = 1f; @@ -103,7 +120,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public bool spawnArena = false; public bool enteredBrothersPhase = false; public bool hasSummonedBrothers = false; - public bool cirrus = false; + public bool permafrost = false; public bool hasDoneDeathAnim = false; public bool postMusicHit = false; @@ -124,8 +141,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas public int bulletHellCounter2 = 0; public int attackCastDelay = 0; public int hitTimer = 0; - public int alicornFrame = 0; - public int alicornFrameCounter = 0; public int dashVisualCounter = 0; public int preventionPause = 15; // Helps prevent telefragging public int attackPause = 0; @@ -139,6 +154,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas public float rotateToPlayer = 0; public float rotateAwayPlayer = 0; + public float colorCompletion = 1; + + public ArenaWallSystem.Box ArenaBox = null; + public FrameAnimationType FrameType { get => (FrameAnimationType)(int)NPC.localAI[2]; @@ -185,23 +204,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas public Vector2 initialRitualPosition; public Rectangle safeBox = default; - public bool IsTargetOutsideOfArena => !Main.player[NPC.target].Hitbox.Intersects(safeBox); - public static int hoodedHeadIconIndex; public static int hoodedHeadIconP2Index; public static int hoodlessHeadIconIndex; public static int hoodlessHeadIconP2Index; - public static int cirrusHeadIconIndex; - public static int cirrusHeadIconP2Index; + public static int permafrostHeadIconIndex; public static float normalDR = 0.25f; public static float enragedDR = 0.9999f; public static readonly Color textColor = Color.Orange; - public static readonly Color cirrusTextColor = Color.Pink; + public static readonly Color permafrostTextColor = Color.LightCyan; public const int sepulcherSpawnCastTime = 75; public const int brothersSpawnCastTime = 150; - public const int MaxCirrusAlcohols = 20; - public const int MaxCirrusAlcoholDebuffDuration = 1500; // Sounds. public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/SupremeCalamitasSpawn") { Volume = 1.2f }; @@ -209,7 +223,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public static readonly SoundStyle BrimstoneShotSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneShoot"); public static readonly SoundStyle BrotherHit = new("CalamityMod/Sounds/Custom/SCalSounds/BrothersHurt", 2); public static readonly SoundStyle BrotherDeath = new("CalamityMod/Sounds/Custom/SCalSounds/BrothersDeath", 2); - public static readonly SoundStyle CatastropheSwing = new("CalamityMod/Sounds/Custom/SCalSounds/CatastropheResonanceSlash1"); + public static readonly SoundStyle CatastropheSwing = new("CalamityMod/Sounds/Custom/SCalSounds/CatastropheResonanceSlash"); public static readonly SoundStyle BrimstoneBigShotSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneBigShoot"); // DON'T YOU WANNA BE A [BIG SHOT] public static readonly SoundStyle DashSound = new("CalamityMod/Sounds/Custom/SCalSounds/SCalDash"); public static readonly SoundStyle HellblastSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneHellblastSound"); @@ -220,8 +234,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public SlotId BulletHellRumbleSlot; public static Asset HoodedTexture; - public static Asset CirrusTexture; - public static Asset CirrusTexture2; + public static Asset PermafrostTexture; public static Asset ShieldTopTexture; public static Asset ShieldBottomTexture; public static Asset ForcefieldTexture; @@ -231,13 +244,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas { string hoodedIconPath = "CalamityMod/NPCs/SupremeCalamitas/HoodedHeadIcon"; string hoodlessIconPath = "CalamityMod/NPCs/SupremeCalamitas/HoodlessHeadIcon"; - string cirrusIconPath = "CalamityMod/NPCs/SupremeCalamitas/CirrusHeadIcon"; - string cirrusIconP2Path = "CalamityMod/NPCs/SupremeCalamitas/CirrusHeadIcon2"; - + string permafrostIconPath = "CalamityMod/NPCs/TownNPCs/Archmage_Head"; + hoodedHeadIconIndex = CalamityMod.Instance.AddBossHeadTexture(hoodedIconPath, -1); hoodlessHeadIconIndex = CalamityMod.Instance.AddBossHeadTexture(hoodlessIconPath, -1); - cirrusHeadIconIndex = CalamityMod.Instance.AddBossHeadTexture(cirrusIconPath, -1); - cirrusHeadIconP2Index = CalamityMod.Instance.AddBossHeadTexture(cirrusIconP2Path, -1); + permafrostHeadIconIndex = CalamityMod.Instance.AddBossHeadTexture(permafrostIconPath, -1); } public override void SetStaticDefaults() @@ -254,24 +265,29 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!Main.dedServ) { HoodedTexture = ModContent.Request(Texture + "Hooded", AssetRequestMode.AsyncLoad); - CirrusTexture = ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SupremeCirrus", AssetRequestMode.AsyncLoad); - CirrusTexture2 = ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SupremeCirrus_Shimmered", AssetRequestMode.AsyncLoad); + PermafrostTexture = ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SupremePermafrost", AssetRequestMode.AsyncLoad); ShieldTopTexture = ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SupremeShieldTop", AssetRequestMode.AsyncLoad); ShieldBottomTexture = ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/SupremeShieldBottom", AssetRequestMode.AsyncLoad); ForcefieldTexture = ModContent.Request("CalamityMod/NPCs/SupremeCalamitas/ForcefieldTexture", AssetRequestMode.AsyncLoad); } } + public static int DartDamage = 80; // 320 + public static int SkullDamage = 85; // 340 + public static int HellblastDamage = 95; // 380 + public static int FireblastDamage = 95; // 380 + public static int GigablastDamage = 105; // 420 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; - NPC.GetNPCDamage(); + NPC.damage = 210; // 420 NPC.npcSlots = 50f; NPC.width = NPC.height = 44; NPC.defense = 100; NPC.DR_NERD(normalDR); - NPC.value = Item.buyPrice(3, 0, 0, 0); - NPC.LifeMaxNERB(960000, 1150000, 900000); + NPC.value = Item.buyPrice(platinum: 3); + NPC.LifeMaxNERB(750000, 1150000, 900000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -283,9 +299,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -300,9 +313,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void BossHeadSlot(ref int index) { bool inPhase2 = NPC.ai[0] == 3f; - if (cirrus) + if (permafrost) { - index = inPhase2 ? cirrusHeadIconP2Index : cirrusHeadIconIndex; + index = permafrostHeadIconIndex; } else { @@ -315,8 +328,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void ModifyTypeName(ref string typeName) { - if (cirrus) - typeName = CalamityUtils.GetTextValue("NPCs.SupremeCirrus"); + if (permafrost) + typeName = CalamityUtils.GetTextValue("NPCs.SupremePermafrost"); } public override void SendExtraAI(BinaryWriter writer) @@ -344,7 +357,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas writer.Write(spawnArena); writer.Write(hasSummonedBrothers); writer.Write(enteredBrothersPhase); - writer.Write(cirrus); + writer.Write(permafrost); writer.Write(NPC.dontTakeDamage); writer.Write(NPC.chaseable); @@ -396,7 +409,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas spawnArena = reader.ReadBoolean(); hasSummonedBrothers = reader.ReadBoolean(); enteredBrothersPhase = reader.ReadBoolean(); - cirrus = reader.ReadBoolean(); + permafrost = reader.ReadBoolean(); NPC.dontTakeDamage = reader.ReadBoolean(); NPC.chaseable = reader.ReadBoolean(); @@ -454,39 +467,19 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (CalamityServerConfig.Instance.BossesStopWeather) CalamityWorld.StopRain(); - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Used for Scal's teleport at the start of brothers phase bool teleport = false; - // cirrus and zenith scal are mutually exclusive unless it's legendary - bool zenithAI = Main.zenithWorld && (!cirrus || (CalamityWorld.LegendaryMode && revenge && cirrus)); + // permafrost and zenith scal are mutually exclusive + bool zenithAI = Main.zenithWorld && !permafrost; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; - // Projectile damage values - int bulletHellblastDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()); - int barrageDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()); - int fireblastDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()); - int gigablastDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()); - int monsterDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()); - int waveDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()); - int hellblastDamage = NPC.GetProjectileDamage(ModContent.ProjectileType()); - if (bossRush) - { - bulletHellblastDamage /= 2; - barrageDamage /= 2; - fireblastDamage /= 2; - gigablastDamage /= 2; - monsterDamage /= 2; - waveDamage /= 2; - hellblastDamage /= 2; - } - int bulletHellblast = zenithAI ? ModContent.ProjectileType() : ModContent.ProjectileType(); int barrage = ModContent.ProjectileType(); int gigablast = zenithAI ? ModContent.ProjectileType() : ModContent.ProjectileType(); @@ -515,14 +508,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!startText) { - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalSummonText"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusSummonText"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostSummonText"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } startText = true; } @@ -545,7 +538,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (NPC.dontTakeDamage && !hasDoneDeathAnim) // Dust visuals for shield when immune { Vector2 sustVel = new Vector2(-78 * Main.rand.NextFloat(0.95f, 1.05f), 0).RotatedBy(rotateToPlayer + MathHelper.PiOver2).RotatedByRandom(1.4); - Dust sust = Dust.NewDustPerfect(NPC.Center + sustVel, 269, sustVel * Main.rand.NextFloat(0.001f, 0.03f)); + Dust sust = Dust.NewDustPerfect(NPC.Center + sustVel, DustID.Sandnado, sustVel * Main.rand.NextFloat(0.001f, 0.03f)); sust.noGravity = true; sust.scale = Main.rand.NextFloat(0.5f, 0.9f); sust.alpha = 200; @@ -557,7 +550,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (NPC.Size != hitboxSize) NPC.Size = hitboxSize; bool shouldNotUseShield = bulletHellCounter2 % BulletHellDuration != 0 || attackCastDelay > 0 || - (cirrus ? NPC.AnyNPCs(ModContent.NPCType()) : (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()))) || + (permafrost ? NPC.AnyNPCs(ModContent.NPCType()) : (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()))) || NPC.ai[0] == 1f || NPC.ai[0] == 2f; // Make the shield and forcefield fade away in SCal's acceptance phase. @@ -582,12 +575,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas shieldRotation = shieldRotation.AngleTowards(idealRotation, 0.18f); } } - else if (!cirrus) + else if (!permafrost) { // Emit dust off the skull at the position of its eye socket. for (float num6 = 1f; num6 < 16f; num6 += 1f) { - Dust dust = Dust.NewDustPerfect(NPC.Center, 182); + Dust dust = Dust.NewDustPerfect(NPC.Center, DustID.TheDestroyer); dust.position = Vector2.Lerp(NPC.position, NPC.oldPosition, num6 / 16f) + NPC.Size * 0.5f; dust.position += shieldRotation.ToRotationVector2() * 42f; dust.position += (shieldRotation - MathHelper.PiOver2).ToRotationVector2() * (float)Math.Cos(NPC.velocity.ToRotation()) * -4f; @@ -618,7 +611,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas #endregion #region ArenaCreation - // Create the arena on the first frame. This does not run client-side. + // Set the variables on the first frame. This does not run client-side. // If this is done on the server, a sync must be performed so that the arena box is // known to the clients. Not doing this results in significant desyncs in regards to things like DR. if (!spawnArena) @@ -647,37 +640,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas int safeBoxTilesX = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; int safeBoxTilesY = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; int safeBoxTileWidth = safeBox.Width / 2 / 16 + 1; - for (int i = safeBoxTilesX - safeBoxTileWidth; i <= safeBoxTilesX + safeBoxTileWidth; i++) - { - for (int j = safeBoxTilesY - safeBoxTileWidth; j <= safeBoxTilesY + safeBoxTileWidth; j++) - { - if (!WorldGen.InWorld(i, j, 2)) - continue; - int xoffset = 0; - int yoffset = 0; - int maxoffset = 3; - if (zenithAI) - { - xoffset += Main.rand.Next(-maxoffset, maxoffset + 1); - yoffset += Main.rand.Next(-maxoffset, maxoffset + 1); - } - - if ((i == safeBoxTilesX - safeBoxTileWidth || i == safeBoxTilesX + safeBoxTileWidth || j == safeBoxTilesY - safeBoxTileWidth || j == safeBoxTilesY + safeBoxTileWidth) && !Main.tile[i + xoffset, j + yoffset].HasTile) - { - Main.tile[i + xoffset, j + yoffset].TileType = (ushort)ModContent.TileType(); - Main.tile[i + xoffset, j + yoffset].Get().HasTile = true; - } - if (Main.dedServ) - { - NetMessage.SendTileSquare(-1, i + xoffset, j + yoffset, 1, TileChangeType.None); - } - else - { - WorldGen.SquareTileFrame(i + xoffset, j + yoffset, true); - } - } - } if (initialRitualPosition == Vector2.Zero) { @@ -691,27 +654,164 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; } } + Vector4 GetArenaSize(bool brothersActive = false) + { + var baseSize = death ? new Vector4(1000) : new Vector4(1250); + if (wormAlive) + baseSize *= new Vector4(1, 1.15f, startFourthAttack ? 0.75f : 0.25f, 1.15f); + if (NPC.AnyNPCs(ModContent.NPCType())) + { + baseSize *= new Vector4(1.5f, 0.85f, 1.5f, 0.85f); + } + if (cataclysmAlive || catastropheAlive) + baseSize *= new Vector4(0.85f, 1.33f, 0.85f, 1.33f); + if (lifeRatio <= 0.01f) + baseSize = (Main.zenithWorld && !permafrost) ? new Vector4(22f, 22f, 22f, 22f) : new Vector4(400f, 500f, 73f, 500f); + else if (Main.zenithWorld && lifeRatio <= 0.08f && !wormAlive && !permafrost) // gfb + baseSize *= MathHelper.Lerp(0.22f, 1f, lifeRatio * 12.5f); // Scale down the lower health scal has + return baseSize; + } + + Color GetArenaColor(out Color oldColor) + { + if (permafrost) + { + oldColor = Color.LightBlue; + return Color.LightBlue; + } + var c = GriefColor; + oldColor = GriefColor; + if (startFifthAttack && gettingTired5 && (giveUpCounter < 1160 || hasDoneDeathAnim)) + { + c = AcceptanceColor; + oldColor = EpiphanyColor; + } + else if (lifeRatio <= 0.3f) + { + c = EpiphanyColor; + oldColor = LamentColor; + } + else if (lifeRatio <= 0.5f) + c = LamentColor; + return c; + } + + void UpdateArena(ArenaWallSystem.Box box) + { + if (Main.dedServ) + return; + + var x = 1f / TextureAssets.MagicPixel.Height(); + var p = ScalArenaMetaball.SpawnParticle((box.TopLeft + box.BottomLeft) * 0.5f - new Vector2(box.borderThickness * 0.5f + 2, 0), Vector2.Zero, 1); + p.SizeScaling = 0; + p.TextureToUse = TextureAssets.MagicPixel.Value; + p.Scale = new Vector2(box.borderThickness - 6, box.borderThickness * 2 + box.Size.Y - 4); + p.Scale.Y *= x; + + p = ScalArenaMetaball.SpawnParticle((box.TopRight + box.BottomRight) * 0.5f + new Vector2(box.borderThickness * 0.5f + 2, 0), Vector2.Zero, 1); + p.SizeScaling = 0; + p.TextureToUse = TextureAssets.MagicPixel.Value; + p.Scale = new Vector2(box.borderThickness - 6, box.borderThickness * 2 + box.Size.Y - 4); + p.Scale.Y *= x; + + p = ScalArenaMetaball.SpawnParticle((box.TopRight + box.TopLeft) * 0.5f - new Vector2(0, box.borderThickness * 0.5f + 2), Vector2.Zero, 1); + p.SizeScaling = 0; + p.TextureToUse = TextureAssets.MagicPixel.Value; + p.Scale = new Vector2(box.borderThickness * 2 + box.Size.X - 4, box.borderThickness - 6); + p.Scale.Y *= x; + + p = ScalArenaMetaball.SpawnParticle((box.BottomLeft + box.BottomRight) * 0.5f + new Vector2(0, box.borderThickness * 0.5f + 2), Vector2.Zero, 1); + p.SizeScaling = 0; + p.TextureToUse = TextureAssets.MagicPixel.Value; + p.Scale = new Vector2(box.borderThickness * 2 + box.Size.X - 4, box.borderThickness - 6); + p.Scale.Y *= x; + + for (var i2 = 0; i2 < box.Size.Y / 100f; i2++) + { + var point = Vector2.Lerp(box.BottomRight, box.TopRight, Main.rand.NextFloat()); + + p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitX * 8, Vector2.Zero, 16f); + p.SizeScaling = 0.95f; + + point = Vector2.Lerp(box.TopLeft, box.BottomLeft, Main.rand.NextFloat()); + p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitX * -8, Vector2.Zero, 16f); + p.SizeScaling = 0.95f; + + } + for (var i2 = 0; i2 < box.Size.X / 100f; i2++) + { + var point = Vector2.Lerp(box.TopLeft, box.TopRight, Main.rand.NextFloat()); + p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitY * -8, Vector2.Zero, 16f); + p.SizeScaling = 0.95f; + point = Vector2.Lerp(box.BottomRight, box.BottomLeft, Main.rand.NextFloat()); + p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitY * 8, Vector2.Zero, 16f); + p.SizeScaling = 0.95f; + } + } + + void DrawArena(ArenaWallSystem.Box box) + { + + var color = Color.Black * 0.15f; + //Inside Fill + box.DrawBoxWithOffset(box.borderThickness * 0.5f, box.borderThickness, Color.Black * 0.15f); + //Inner Border + box.DrawBoxWithOffset(4, 2, box.borderColor * 0.15f); + //Outer Border + box.DrawBoxWithOffset(box.borderThickness - 2, 2, box.borderColor); + } + + if (ArenaBox is null) + { + ArenaBox = new() + { + position = new Vector2(spawnX + (death ? 1000 : 1250), spawnY + (death ? 1000 : 1250)), + boxDimensions = GetArenaSize() * 2, + borderThickness = 2000, + RemovalCondition = () => !(Main.npc[NPC.whoAmI].active) || Main.npc[NPC.whoAmI].type != Type, + UpdateBox = UpdateArena, + DrawBox = DrawArena, + DespawnAction = (box) => + { + box.borderThickness *= 0.9f; + if (box.borderThickness < 4) + return true; + UpdateArena(box); + return false; + } + }; + ArenaWallSystem.ActiveBoxes.Add(ArenaBox); + } + ArenaBox.NewDimensions = Vector4.Lerp(ArenaBox.boxDimensions, GetArenaSize(), lifeRatio <= 0.01f ? 0.02f : startFourthAttack ? 0.05f : 0.1f); + var color = GetArenaColor(out Color oldColor); + if (colorCompletion > 1.1f && color != ArenaBox.borderColor) + colorCompletion = 0; + if (colorCompletion < 1) + ArenaBox.borderColor = Color.Lerp(oldColor, color, colorCompletion); + else + ArenaBox.borderColor = color; + colorCompletion += 0.003f; + #endregion #region Enrage and DR - if ((spawnArena && !player.Hitbox.Intersects(safeBox)) || bossRush) + if (ArenaWallSystem.ActiveBoxes.Count > 0 && !Collision.CheckAABBvAABBCollision(ArenaBox.TopLeft, ArenaBox.Size, player.position, player.Size)) { - float projectileVelocityMultCap = (!player.Hitbox.Intersects(safeBox) && spawnArena) ? 2f : 1.35f; + float projectileVelocityMultCap = 2f; uDieLul = MathHelper.Clamp(uDieLul * 1.01f, 1f, projectileVelocityMultCap); - protectionBoost = !bossRush; - if (!player.Hitbox.Intersects(safeBox)) - protectionBoost = true; + protectionBoost = true; + NPC.Calamity().CurrentlyEnraged = true; } else { uDieLul = MathHelper.Clamp(uDieLul * 0.99f, 1f, 2f); protectionBoost = false; + NPC.Calamity().CurrentlyEnraged = false; } - NPC.Calamity().CurrentlyEnraged = !player.Hitbox.Intersects(safeBox); - // Cirrus fucks mounts if you exit her arena. - if (cirrus) + // Permafrost fucks mounts if you exit his arena. + if (permafrost) { - if (!player.Hitbox.Intersects(safeBox) && player.mount.Active) + if (NPC.Calamity().CurrentlyEnraged && player.mount.Active) { player.ResetEffects(); player.head = -1; @@ -786,15 +886,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas forcefieldOpacity = Utils.GetLerpValue(0.1f, 0.6f, NPC.Opacity, true); if (NPC.alpha >= 230) { - if (DownedBossSystem.downedCalamitas && !bossRush) + if (DownedBossSystem.downedCalamitas && !BossRushEvent.BossRushActive) { // Create a teleport line effect - Dust.QuickDustLine(NPC.Center, initialRitualPosition, 500f, cirrus ? Color.Pink : Color.Red); + Dust.QuickDustLine(NPC.Center, initialRitualPosition, 500f, permafrost ? Color.Cyan : Color.Red); NPC.Center = initialRitualPosition; // Make the town NPC spawn. if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y + 12, cirrus ? ModContent.NPCType() : ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y + 12, permafrost ? ModContent.NPCType() : ModContent.NPCType()); } NPC.active = false; @@ -804,7 +904,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < MathHelper.Lerp(2f, 6f, 1f - NPC.Opacity); i++) { Dust brimstoneFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-24f, 24f), DustID.Torch); - brimstoneFire.color = cirrus ? Color.Pink : Color.Red; + brimstoneFire.color = permafrost ? Color.Cyan : Color.Red; brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 3.25f); brimstoneFire.scale = Main.rand.NextFloat(0.95f, 1.15f); brimstoneFire.noGravity = true; @@ -872,24 +972,24 @@ namespace CalamityMod.NPCs.SupremeCalamitas { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } if (bulletHellCounter2 < 300 && !Main.zenithWorld) // Blasts from above { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else if (bulletHellCounter2 < 600) // Blasts from left and right { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else // Blasts from above, left, and right { if (!Main.zenithWorld) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 3f * uDieLul, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 3f * uDieLul, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } @@ -900,9 +1000,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas { attackCastDelay = sepulcherSpawnCastTime; - Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); GeneralParticleHandler.SpawnParticle(pulse2); for (int i = 0; i < 100; i++) { @@ -948,9 +1048,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas failShotDust.velocity = dustVel * Main.rand.NextFloat(0.3f, 1.3f); failShotDust.scale = Main.rand.NextFloat(2f, 3.2f); } - Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); GeneralParticleHandler.SpawnParticle(pulse2); SoundEngine.PlaySound(BulletHellEndSound, NPC.Center); @@ -962,31 +1062,31 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { - // Cirrus throws alcohol bottles that explode into Fabstaff Rays - if (cirrus) + // Permafrost throws delicious meat that explode into more meat which doesn't split + if (permafrost) { if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 350, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 350, 0f, Main.myPlayer, 0f, 2f); } } if (bulletHellCounter2 < 1200) { if (bulletHellCounter2 % 180 == 0) // Blasts from top - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); } else if (bulletHellCounter2 < 1500 && bulletHellCounter2 > 1200) { if (bulletHellCounter2 % 180 == 0) // Blasts from right - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -5f * uDieLul, 0f, fireblast, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -5f * uDieLul, 0f, fireblast, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); } else if (bulletHellCounter2 > 1500) { if (bulletHellCounter2 % 180 == 0) // Blasts from top - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); } bulletHellCounter++; @@ -997,21 +1097,21 @@ namespace CalamityMod.NPCs.SupremeCalamitas { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } if (bulletHellCounter2 < 1200 && !Main.zenithWorld) // Blasts from below { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y + 1000f, 0f, -4f * uDieLul, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y + 1000f, 0f, -4f * uDieLul, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else if (bulletHellCounter2 < 1500) // Blasts from left { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else // Blasts from left and right { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } @@ -1023,7 +1123,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!startSecondAttack && lifeRatio <= 0.75f) { // Bouncy Boulders - if (cirrus) + if (permafrost) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1035,15 +1135,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalBH2Text"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusBH2Text"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostBH2Text"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } startSecondAttack = true; @@ -1079,23 +1179,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas failShotDust.velocity = dustVel * Main.rand.NextFloat(0.3f, 1.3f); failShotDust.scale = Main.rand.NextFloat(2f, 3.2f); } - Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); GeneralParticleHandler.SpawnParticle(pulse2); SoundEngine.PlaySound(BulletHellEndSound, NPC.Center); } #endregion - if (cirrus) + if (permafrost) { Vector2 destination = player.Center; Vector2 distanceFromDestination = destination - NPC.Center; - Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * CirrusPhotonRipperDashVelocity; + Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * PermafrostPhotonRipperDashVelocity; - if (Vector2.Distance(NPC.Center, destination) > CirrusPhotonRipperMinDistanceFromTarget) - NPC.SimpleFlyMovement(desiredVelocity * uDieLul, CirrusPhotonRipperDashAcceleration * uDieLul); + if (Vector2.Distance(NPC.Center, destination) > PermafrostPhotonRipperMinDistanceFromTarget) + NPC.SimpleFlyMovement(desiredVelocity * uDieLul, PermafrostPhotonRipperDashAcceleration * uDieLul); else NPC.velocity *= 0.9f; } @@ -1104,15 +1204,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { - // Cirrus uses Photon Ripper - if (bulletHellCounter2 == SecondBulletHellEndValue + 1 && cirrus) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.One, ModContent.ProjectileType(), CirrusPhotonRipperDamage, 0f, Main.myPlayer, 0f, 0f, NPC.whoAmI); + // Permafrost uses Absolute Zero which acts like Photon Ripper + if (bulletHellCounter2 == SecondBulletHellEndValue + 1 && permafrost) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.One, ModContent.ProjectileType(), PermafrostAbsoluteZeroDamage, 0f, Main.myPlayer, 0f, 0f, NPC.whoAmI); if (bulletHellCounter2 % 180 == 0) // Blasts from top - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); if (bulletHellCounter2 % 240 == 0) // Fireblasts from above - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, gigablast, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, gigablast, GigablastDamage, 0f, Main.myPlayer, 0f, 2f); bulletHellCounter++; if (bulletHellCounter >= baseBulletHellProjectileGateValue + 4) @@ -1122,21 +1222,21 @@ namespace CalamityMod.NPCs.SupremeCalamitas { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } if (bulletHellCounter2 < 2100 && !Main.zenithWorld) // Blasts from above { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else if (bulletHellCounter2 < 2400) // Blasts from right { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else // Blasts from left and right { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } @@ -1148,7 +1248,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!startThirdAttack && lifeRatio <= 0.5f) { // Bouncy Boulders - if (cirrus) + if (permafrost) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1160,15 +1260,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalBH3Text"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusBH3Text"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostBH3Text"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } startThirdAttack = true; @@ -1191,9 +1291,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (musicSyncCounter == 0 && !postMusicHit) { - Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 4f, 17); + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 4f, 17); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 3f, 19); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 3f, 19); GeneralParticleHandler.SpawnParticle(pulse2); for (int i = 0; i < 30; i++) { @@ -1217,7 +1317,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas fust.scale = Main.rand.NextFloat(0.3f, 0.8f); if (Main.rand.NextBool()) { - Dust sust = Dust.NewDustPerfect(NPC.Center + velOffset, 269, velOffset * Main.rand.NextFloat(0.01f, 0.1f)); + Dust sust = Dust.NewDustPerfect(NPC.Center + velOffset, DustID.Sandnado, velOffset * Main.rand.NextFloat(0.01f, 0.1f)); sust.noGravity = true; sust.scale = Main.rand.NextFloat(0.2f, 0.6f); sust.alpha = 200; @@ -1255,9 +1355,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas failShotDust.velocity = dustVel * Main.rand.NextFloat(0.3f, 1.3f); failShotDust.scale = Main.rand.NextFloat(2f, 3.2f); } - Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); GeneralParticleHandler.SpawnParticle(pulse2); SoundEngine.PlaySound(BulletHellEndSound, NPC.Center); @@ -1269,22 +1369,22 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) // More clustered attack { - // Cirrus throws alcohol bottles that explode into Fabstaff Rays - if (cirrus) + // Permafrost throws Delicious Meat that explodes into more meat that splits + if (permafrost) { if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer, 0f, 2f); } } if (bulletHellCounter2 % 180 == 0) // Blasts from top - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); if (bulletHellCounter2 % 240 == 0) // Fireblasts from above - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, gigablast, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, gigablast, GigablastDamage, 0f, Main.myPlayer, 0f, 2f); int divisor = revenge ? 225 : expertMode ? 450 : 675; @@ -1305,18 +1405,19 @@ namespace CalamityMod.NPCs.SupremeCalamitas { for (int i = 0; i < 90; i++) { - Dust spawnDust = Dust.NewDustPerfect(safeBox.Center(), cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 1.2f)); + Dust spawnDust = Dust.NewDustPerfect(safeBox.Center(), permafrost ? DustID.IceGolem : (int)CalamityDusts.Brimstone, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 1.2f)); spawnDust.noGravity = true; spawnDust.scale = Main.rand.NextFloat(1.2f, 2.3f); } for (int i = 0; i < 40; i++) { Vector2 sparkVel = new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.1f); - GlowOrbParticle orb = new GlowOrbParticle(safeBox.Center() + sparkVel * 2, sparkVel, false, 120, Main.rand.NextFloat(1.55f, 2.75f), cirrus ? Color.Magenta : Color.Lerp(Color.Red, Color.Magenta, 0.3f), true, true); + GlowOrbParticle orb = new GlowOrbParticle(safeBox.Center() + sparkVel * 2, sparkVel, false, 120, Main.rand.NextFloat(1.55f, 2.75f), permafrost ? Color.DarkCyan : Color.Lerp(Color.Red, Color.Magenta, 0.3f), true, true); GeneralParticleHandler.SpawnParticle(orb); } - Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnSpot, Vector2.Zero, ModContent.ProjectileType(), monsterDamage, 0f, Main.myPlayer, 0f); + // Whispering Maelstrom passes through normal CanHitPlayer hooks then overrides them. This needs it to have contact damage but the number itself doesn't matter. + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnSpot, Vector2.Zero, ModContent.ProjectileType(), 100, 0f, Main.myPlayer, 0f); } bulletHellCounter++; @@ -1327,21 +1428,21 @@ namespace CalamityMod.NPCs.SupremeCalamitas { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } if (bulletHellCounter2 < 3000 && !Main.zenithWorld) // Blasts from below { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y + 1000f, 0f, -4f * uDieLul, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y + 1000f, 0f, -4f * uDieLul, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else if (bulletHellCounter2 < 3300) // Blasts from left { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else // Blasts from left and right { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } @@ -1353,7 +1454,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!startFourthAttack && lifeRatio <= 0.3f) { // Bouncy Boulders - if (cirrus) + if (permafrost) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1365,15 +1466,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalBH4Text"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusBH4Text"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostBH4Text"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } startFourthAttack = true; @@ -1409,23 +1510,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas failShotDust.velocity = dustVel * Main.rand.NextFloat(0.3f, 1.3f); failShotDust.scale = Main.rand.NextFloat(2f, 3.2f); } - Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Pink : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.Cyan : Color.Lerp(Color.Red, Color.Magenta, 0.3f), new Vector2(1f, 1f), 0, 0.05f, 4f, 18); GeneralParticleHandler.SpawnParticle(pulse2); SoundEngine.PlaySound(BulletHellEndSound, NPC.Center); } #endregion - if (cirrus) + if (permafrost) { Vector2 destination = player.Center; Vector2 distanceFromDestination = destination - NPC.Center; - Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * CirrusPhotonRipperDashVelocity; + Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * PermafrostPhotonRipperDashVelocity; - if (Vector2.Distance(NPC.Center, destination) > CirrusPhotonRipperMinDistanceFromTarget) - NPC.SimpleFlyMovement(desiredVelocity * uDieLul, CirrusPhotonRipperDashAcceleration * uDieLul); + if (Vector2.Distance(NPC.Center, destination) > PermafrostPhotonRipperMinDistanceFromTarget) + NPC.SimpleFlyMovement(desiredVelocity * uDieLul, PermafrostPhotonRipperDashAcceleration * uDieLul); else NPC.velocity *= 0.9f; } @@ -1434,32 +1535,32 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { - // Cirrus throws alcohol bottles that explode into Fabstaff Rays - if (cirrus) + // Permafrost throws delicious meat that explode into more delicious meat that doesn't split + if (permafrost) { - // Cirrus uses Photon Ripper + // Permafrost uses Absolute Zero similarly to Photon Ripper if (bulletHellCounter2 == FourthBulletHellEndValue + 1) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.One, ModContent.ProjectileType(), CirrusPhotonRipperDamage, 0f, Main.myPlayer, 0f, 0f, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.One, ModContent.ProjectileType(), PermafrostAbsoluteZeroDamage, 0f, Main.myPlayer, 0f, 0f, NPC.whoAmI); if (bulletHellCounter2 % 90 == 0) { float bottleSpeed = 12f; Vector2 bottleVelocity = (player.Center + player.velocity * 20f - NPC.Center).SafeNormalize(Vector2.UnitY) * bottleSpeed; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bottleVelocity * uDieLul, ModContent.ProjectileType(), 125, 0f, Main.myPlayer); } } if (bulletHellCounter2 % 240 == 0) // Blasts from top - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, fireblast, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); if (bulletHellCounter2 % 360 == 0) // Fireblasts from above - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, gigablast, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, gigablast, GigablastDamage, 0f, Main.myPlayer, 0f, 2f); if (bulletHellCounter2 % 30 == 0) // Projectiles that move in wave pattern { int random = Main.rand.Next(-500, 501); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + random, -5f * uDieLul, 0f, wave, waveDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y - random, 5f * uDieLul, 0f, wave, waveDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + random, -5f * uDieLul, 0f, wave, SkullDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y - random, 5f * uDieLul, 0f, wave, SkullDamage, 0f, Main.myPlayer, 0f, 2f); } bulletHellCounter++; @@ -1470,25 +1571,25 @@ namespace CalamityMod.NPCs.SupremeCalamitas { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + distance, player.position.Y, velocity, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } if (bulletHellCounter2 < 3900 && !Main.zenithWorld) // Blasts from above { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 4f * uDieLul, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else if (bulletHellCounter2 < 4200) // Blasts from left and right { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3.5f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } else // Blasts from above, left, and right { if (!Main.zenithWorld) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 3f * uDieLul, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 3f * uDieLul, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3f * uDieLul, 0f, bulletHellblast, bulletHellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -3f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), 3f * uDieLul, 0f, bulletHellblast, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } @@ -1500,7 +1601,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!startFifthAttack && lifeRatio <= 0.1f) { // Bouncy Boulders - if (cirrus) + if (permafrost) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -1513,15 +1614,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas } string key = "Mods.CalamityMod.Status.Boss.SCalBH5Text"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusBH5Text"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostBH5Text"; - if (!bossRush) + if (!BossRushEvent.BossRushActive) { - if (DownedBossSystem.downedCalamitas && !cirrus) + if (DownedBossSystem.downedCalamitas && !permafrost) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } startFifthAttack = true; @@ -1533,7 +1634,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (gettingTired5) { - if (cirrus) + if (permafrost) { if (giveUpCounter > 1) { @@ -1546,7 +1647,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (blasterTimer % blasterDivisor == 0) { if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), circleOffset, player.Center, ModContent.ProjectileType(), 350, 0f, Main.myPlayer, 0f, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), circleOffset, player.Center, ModContent.ProjectileType(), 350, 0f, Main.myPlayer, 0f, 1f); } int beamDivisor = 60; @@ -1561,12 +1662,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int k = 0; k < totalProjectiles; k++) { Vector2 rayVelocity = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + (rayVelocity).SafeNormalize(Vector2.UnitY) * 16f, rayVelocity, ModContent.ProjectileType(), 250, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + (rayVelocity).SafeNormalize(Vector2.UnitY) * 16f, rayVelocity, ModContent.ProjectileType(), 250, 0f, Main.myPlayer); if (proj.WithinBounds(Main.maxProjectiles)) { Main.projectile[proj].DamageType = DamageClass.Default; Main.projectile[proj].friendly = false; Main.projectile[proj].hostile = true; + Main.projectile[proj].tileCollide = false; } } } @@ -1581,8 +1683,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (giveUpCounter == 1) { NPC.velocity = Vector2.Zero; - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.CirrusGiveUpText", cirrusTextColor); - Dust.QuickDustLine(NPC.Center, initialRitualPosition, 500f, Color.Pink); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.PermafrostGiveUpText", permafrostTextColor); + Dust.QuickDustLine(NPC.Center, initialRitualPosition, 500f, Color.Cyan); NPC.Center = initialRitualPosition; giveUpCounter--; } @@ -1600,7 +1702,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.active = false; NPC.netUpdate = true; - NPC.NPCLoot(); + + NPC.NPCLoot(); int cryo = NPC.FindFirstNPC(ModContent.NPCType()); + if (cryo > -1) + { + Main.npc[cryo].active = false; + Main.npc[cryo].netUpdate = true; + } } return; @@ -1609,21 +1717,21 @@ namespace CalamityMod.NPCs.SupremeCalamitas else // Scal gives up { // Clear Debuffs DOESNT WORK YET - for (int l = 0; l < NPC.maxBuffs ; ++l) + for (int l = 0; l < NPC.maxBuffs; ++l) { int buffID = NPC.buffType[l]; - bool shouldHalveDuration = DebuffsList.Includes(buffID); + bool shouldHalveDuration = CalamityBuffSets.IsDebuff[buffID]; if (shouldHalveDuration && NPC.buffTime[l] > 4) NPC.buffTime[l] = 4; } - if (!hasDoneDeathAnim && !bossRush) // Scrapped death animation for Scal + if (!hasDoneDeathAnim && !BossRushEvent.BossRushActive) // Scrapped death animation for Scal { attackPause = 5; - Dust.QuickDustLine(NPC.Center, safeBox.Center() + new Vector2(0, -30), 500f, cirrus ? Color.Pink : Color.Red); + Dust.QuickDustLine(NPC.Center, safeBox.Center() + new Vector2(0, -30), 500f, permafrost ? Color.Cyan : Color.Red); NPC.Center = safeBox.Center() + new Vector2(0, -30); NPC.velocity = new Vector2(10 * NPC.spriteDirection, -7); hasDoneDeathAnim = true; @@ -1635,7 +1743,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Teleport back to the arena on defeat if (giveUpCounter == GiveUpCounterMax) { - Dust.QuickDustLine(NPC.Center, initialRitualPosition + new Vector2(0, -30), 500f, cirrus ? Color.Pink : Color.Red); + Dust.QuickDustLine(NPC.Center, initialRitualPosition + new Vector2(0, -30), 500f, permafrost ? Color.Cyan : Color.Red); NPC.Center = initialRitualPosition + new Vector2(0, -30); NPC.noTileCollide = false; NPC.noGravity = false; @@ -1710,7 +1818,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else { - if (bossRush) + if (BossRushEvent.BossRushActive) NPC.Center = initialRitualPosition + new Vector2(0, -30); if (NPC.velocity.Y < 8f) @@ -1718,11 +1826,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) NPC.velocity.X *= 0.965f; - if (DownedBossSystem.downedCalamitas || bossRush) + if (DownedBossSystem.downedCalamitas || BossRushEvent.BossRushActive) { if (giveUpCounter == 720) { - if (bossRush) + if (BossRushEvent.BossRushActive) { NPC.chaseable = true; NPC.dontTakeDamage = false; @@ -1732,7 +1840,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 24; i++) { Dust brimstoneFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-24f, 24f), DustID.Torch); - brimstoneFire.color = cirrus ? Color.Pink : Color.Red; + brimstoneFire.color = permafrost ? Color.Cyan : Color.Red; brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 3.25f); brimstoneFire.scale = Main.rand.NextFloat(0.95f, 1.15f); brimstoneFire.fadeIn = 1.25f; @@ -1744,17 +1852,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.NPCLoot(); } } - else if (giveUpCounter == 900 && !bossRush) + else if (giveUpCounter == 900 && !BossRushEvent.BossRushActive) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.SCalAcceptanceText1", textColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.SCalAcceptanceText1", textColor); } - else if (giveUpCounter == 600 && !bossRush) + else if (giveUpCounter == 600 && !BossRushEvent.BossRushActive) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.SCalAcceptanceText2", textColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.SCalAcceptanceText2", textColor); } - else if (giveUpCounter == 300 && !bossRush) + else if (giveUpCounter == 300 && !BossRushEvent.BossRushActive) { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.SCalAcceptanceText3", textColor); + CalamityUtils.BroadcastLocalizedText("Mods.CalamityMod.Status.Boss.SCalAcceptanceText3", textColor); } if (giveUpCounter <= 0) @@ -1762,7 +1870,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 24; i++) { Dust brimstoneFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-24f, 24f), DustID.Torch); - brimstoneFire.color = cirrus ? Color.Pink : Color.Red; + brimstoneFire.color = permafrost ? Color.Cyan : Color.Red; brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 3.25f); brimstoneFire.scale = Main.rand.NextFloat(0.95f, 1.15f); brimstoneFire.fadeIn = 1.25f; @@ -1812,15 +1920,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalDesparationText4"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusBruhText"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostBruhText"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } gettingTired5 = true; @@ -1828,13 +1936,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else if (!gettingTired4 && lifeRatio <= 0.02f) { - if (!bossRush && !cirrus) + if (!BossRushEvent.BossRushActive && !permafrost) { string key = "Mods.CalamityMod.Status.Boss.SCalDesparationText3"; if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, textColor); + CalamityUtils.BroadcastLocalizedText(key, textColor); } gettingTired4 = true; @@ -1842,13 +1950,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else if (!gettingTired3 && lifeRatio <= 0.04f) { - if (!bossRush && !cirrus) + if (!BossRushEvent.BossRushActive && !permafrost) { string key = "Mods.CalamityMod.Status.Boss.SCalDesparationText2"; if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, textColor); + CalamityUtils.BroadcastLocalizedText(key, textColor); } gettingTired3 = true; @@ -1856,15 +1964,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else if (!gettingTired2 && lifeRatio <= 0.06f) { - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalDesparationText1"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusNonchalantText"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostNonchalantText"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } gettingTired2 = true; @@ -1875,7 +1983,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas attackCastDelay = sepulcherSpawnCastTime; for (int i = 0; i < 40; i++) { - Dust castFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-70f, 70f), cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone); + Dust castFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-70f, 70f), permafrost ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone); castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); castFire.fadeIn = 1.25f; @@ -1884,7 +1992,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 40; i++) { - Dust castFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-70f, 70f), cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone); + Dust castFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-70f, 70f), permafrost ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone); castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); castFire.fadeIn = 1.25f; @@ -1925,17 +2033,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas } #endregion #region TransformSeekerandBrotherTriggers - if (!halfLife && lifeRatio <= 0.45f && hasSummonedBrothers && (cirrus ? NPC.AnyNPCs(ModContent.NPCType()) : (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()))) == false) + if (!halfLife && lifeRatio <= 0.45f && hasSummonedBrothers && (permafrost ? NPC.AnyNPCs(ModContent.NPCType()) : (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()))) == false) { - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalPhase2Text"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusPhase2Text"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostPhase2Text"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } halfLife = true; @@ -1945,60 +2053,29 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (!secondStage) { - if (!bossRush) + if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalSeekerRingText"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusHallowBossSpamText"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostHallowBossSpamText"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } if (Main.netMode != NetmodeID.MultiplayerClient) { - if (cirrus) + if (permafrost) { - // Spawn 1 Providence, 2 Queen Slimes and 2 Empress of Lights - int maximumBullshit = 5; - int angleFromCirrus = 360 / maximumBullshit; - int distanceFromCirrus = 300; - for (int i = 0; i < maximumBullshit; i++) - { - switch (i) - { - case 0: - int npc = NPC.NewNPC(NPC.GetSource_FromAI(), - (int)(vectorCenter.X + (Math.Sin(i * angleFromCirrus) * distanceFromCirrus)), - (int)(vectorCenter.Y + (Math.Cos(i * angleFromCirrus) * distanceFromCirrus)), - ModContent.NPCType(), NPC.whoAmI); - Main.npc[npc].timeLeft *= 20; - CalamityUtils.BossAwakenMessage(npc); - break; - - case 1: - case 2: - int npc2 = NPC.NewNPC(NPC.GetSource_FromAI(), - (int)(vectorCenter.X + (Math.Sin(i * angleFromCirrus) * distanceFromCirrus)), - (int)(vectorCenter.Y + (Math.Cos(i * angleFromCirrus) * distanceFromCirrus)), - NPCID.HallowBoss, NPC.whoAmI); - Main.npc[npc2].timeLeft *= 20; - break; - - case 3: - case 4: - int npc3 = NPC.NewNPC(NPC.GetSource_FromAI(), - (int)(vectorCenter.X + (Math.Sin(i * angleFromCirrus) * distanceFromCirrus)), - (int)(vectorCenter.Y + (Math.Cos(i * angleFromCirrus) * distanceFromCirrus)), - NPCID.QueenSlimeBoss, NPC.whoAmI); - Main.npc[npc3].timeLeft *= 20; - break; - - default: - break; - } - } + // Spawn a buffed Pyrogen + int npc = NPC.NewNPC(NPC.GetSource_FromAI(), + (int)(vectorCenter.X), + (int)(vectorCenter.Y), + ModContent.NPCType(), NPC.whoAmI); + Main.npc[npc].timeLeft *= 20; + Main.npc[npc].lifeMax = Main.npc[npc].life *= 22; + CalamityUtils.BossAwakenMessage(npc); } else { @@ -2040,9 +2117,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; if (!teleport) { - Dust.QuickDustLine(NPC.Center, player.Center + new Vector2(0, -155), 500f, cirrus ? Color.Pink : Color.Red); + Vector2 goalPos = new Vector2(spawnX + (death ? 1000 : 1250), spawnY + (death ? 1000 : 1250)); // player.Center + new Vector2(0, -175) + Dust.QuickDustLine(NPC.Center, goalPos + new Vector2(0, -20), 500f, permafrost ? Color.Cyan : Color.Red); NPC.velocity = Vector2.Zero; - NPC.Center = player.Center + new Vector2(0, -175); + NPC.Center = goalPos; Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, Color.Red, new Vector2(1f, 1f), 0, 0.1f, 5f, 15); GeneralParticleHandler.SpawnParticle(pulse); for (int x = 0; x < Main.maxProjectiles; x++) @@ -2076,7 +2154,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.velocity *= 0.85f; return; } - + } } @@ -2096,6 +2174,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.dontTakeDamage = true; NPC.chaseable = false; NPC.damage = 0; + attackPause = 5; if (!canDespawn) NPC.velocity *= 0.95f; @@ -2263,17 +2342,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 9; i++) // fireblasts pre laugh { Vector2 velOffset = NPC.DirectionTo(player.Center).RotatedByRandom(0.6) * Main.rand.NextFloat(5f, 13f); - GlowOrbParticle spark2 = new GlowOrbParticle(projectileSpawn + velOffset * 2f, velOffset * 0.7f, false, 30, Main.rand.NextFloat(0.4f, 0.65f), cirrus ? Color.HotPink : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); + GlowOrbParticle spark2 = new GlowOrbParticle(projectileSpawn + velOffset * 2f, velOffset * 0.7f, false, 30, Main.rand.NextFloat(0.4f, 0.65f), permafrost ? Color.LightBlue : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); GeneralParticleHandler.SpawnParticle(spark2); } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && attackPause == 0) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, GigablastDamage, 0f, Main.myPlayer, 0f, 2f); NPC.netUpdate = true; } } - else if ((randomShot == 1 && canFireSplitingFireball) || fireFireblastFirst) // Firing gigablast while hovering above pre laugh + else if ((randomShot == 1 && canFireSplitingFireball) || fireFireblastFirst) // Firing gigablast while hovering above pre laugh { canFireSplitingFireball = false; randomShot = fireblast; @@ -2282,13 +2361,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 9; i++) { Vector2 velOffset = NPC.DirectionTo(player.Center).RotatedByRandom(0.6) * Main.rand.NextFloat(5f, 13f); - GlowOrbParticle spark2 = new GlowOrbParticle(projectileSpawn + velOffset * 2f, velOffset * 0.8f, false, 30, Main.rand.NextFloat(0.4f, 0.65f), cirrus ? Color.HotPink : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); + GlowOrbParticle spark2 = new GlowOrbParticle(projectileSpawn + velOffset * 2f, velOffset * 0.8f, false, 30, Main.rand.NextFloat(0.4f, 0.65f), permafrost ? Color.LightBlue : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); GeneralParticleHandler.SpawnParticle(spark2); } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && attackPause == 0) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); NPC.netUpdate = true; } } @@ -2304,15 +2383,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 6; i++) // Spread dust for pre laugh floating { Vector2 dustVel = (projectileVelocity * 2).RotatedByRandom(0.9) * (Main.rand.NextFloat(0.5f, 1.9f)); - GlowOrbParticle orb = new GlowOrbParticle(projectileSpawn, dustVel, false, 15, Main.rand.NextFloat(0.65f, 0.9f), cirrus ? Color.Magenta : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.3f)); + GlowOrbParticle orb = new GlowOrbParticle(projectileSpawn, dustVel, false, 15, Main.rand.NextFloat(0.65f, 0.9f), permafrost ? Color.Cyan : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.3f)); GeneralParticleHandler.SpawnParticle(orb); } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && attackPause == 0) { float projectileVelocityToPass = projectileVelocity.Length() * 1.3f; Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, perturbedSpeed, randomShot, barrageDamage, 0f, Main.myPlayer, 0, 4f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, perturbedSpeed, randomShot, DartDamage, 0f, Main.myPlayer, 0, 4f, projectileVelocityToPass); NPC.netUpdate = true; } } @@ -2341,13 +2420,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.netUpdate = true; SoundEngine.PlaySound(DashSound, NPC.Center); - if (cirrus) + if (permafrost) { if (Main.netMode != NetmodeID.MultiplayerClient) { SoundEngine.PlaySound(SoundID.Item60, NPC.Center); float velocity = 8; - int type = ModContent.ProjectileType(); + int type = ModContent.ProjectileType(); int damage = (int)(NPC.damage / 3); Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; float rotation = MathHelper.ToRadians(22); @@ -2361,6 +2440,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Main.projectile[p].DamageType = DamageClass.Default; Main.projectile[p].friendly = false; Main.projectile[p].hostile = true; + Main.projectile[p].tileCollide = true; } } } @@ -2476,7 +2556,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 6; i++) { Vector2 velOffset = NPC.DirectionTo(player.Center).RotatedByRandom(0.6) * Main.rand.NextFloat(5f, 13f); - PointParticle spark2 = new PointParticle(handPosition + velOffset * 2f, velOffset * 1.5f, false, 18, Main.rand.NextFloat(0.4f, 0.65f), cirrus ? Color.HotPink : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); + PointParticle spark2 = new PointParticle(handPosition + velOffset * 2f, velOffset * 1.5f, false, 18, Main.rand.NextFloat(0.4f, 0.65f), permafrost ? Color.Cyan : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); GeneralParticleHandler.SpawnParticle(spark2); } @@ -2487,14 +2567,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; if (attackPause == 0) - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, hellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } if (Main.rand.NextBool()) // Hand spray magic { - GlowOrbParticle orb = new GlowOrbParticle(handPosition, new Vector2(0, -6).RotatedByRandom(0.4) * Main.rand.NextFloat(0.8f, 1.4f), false, 15, Main.rand.NextFloat(0.85f, 1.2f), cirrus ? Color.Magenta : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.3f), true, true); + GlowOrbParticle orb = new GlowOrbParticle(handPosition, new Vector2(0, -6).RotatedByRandom(0.4) * Main.rand.NextFloat(0.8f, 1.4f), false, 15, Main.rand.NextFloat(0.85f, 1.2f), permafrost ? Color.LightBlue : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.3f), true, true); GeneralParticleHandler.SpawnParticle(orb); } @@ -2545,7 +2625,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 25; i++) { Vector2 velOffset = NPC.DirectionTo(player.Center).RotatedByRandom(0.6) * Main.rand.NextFloat(5f, 13f); - GlowOrbParticle spark2 = new GlowOrbParticle(handPosition + velOffset * 2f, velOffset * 1.5f, false, 9, Main.rand.NextFloat(0.4f, 0.65f), cirrus ? Color.HotPink : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); + GlowOrbParticle spark2 = new GlowOrbParticle(handPosition + velOffset * 2f, velOffset * 1.5f, false, 9, Main.rand.NextFloat(0.4f, 0.65f), permafrost ? Color.Cyan : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); GeneralParticleHandler.SpawnParticle(spark2); } NPC.localAI[1] = 0f; @@ -2557,7 +2637,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; projectileVelocity *= 5f * uDieLul; int projectileType = gigablast; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); + if (attackPause == 0) + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, GigablastDamage, 0f, Main.myPlayer, 0f, 2f); } } @@ -2571,8 +2652,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - // Previously the 0.4% health threshold transition - if (lifeRatio <= 0.45f && hasSummonedBrothers && (cirrus ? NPC.AnyNPCs(ModContent.NPCType()) : (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()))) == false) + // Previously the 40% health threshold transition + if (lifeRatio <= 0.45f && hasSummonedBrothers && (permafrost ? NPC.AnyNPCs(ModContent.NPCType()) : (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()))) == false) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; @@ -2617,17 +2698,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas { for (int i = 0; i < 90; i++) { - Dust spawnDust = Dust.NewDustPerfect(NPC.Center, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 1.2f)); + Dust spawnDust = Dust.NewDustPerfect(NPC.Center, permafrost ? DustID.IceGolem : (int)CalamityDusts.Brimstone, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 1.2f)); spawnDust.noGravity = true; spawnDust.scale = Main.rand.NextFloat(1.2f, 2.3f); } for (int i = 0; i < 40; i++) { Vector2 sparkVel = new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.1f); - GlowOrbParticle orb = new GlowOrbParticle(NPC.Center + sparkVel * 2, sparkVel, false, 120, Main.rand.NextFloat(1.55f, 2.75f), cirrus ? Color.Magenta : Color.Red, true, true); + GlowOrbParticle orb = new GlowOrbParticle(NPC.Center + sparkVel * 2, sparkVel, false, 120, Main.rand.NextFloat(1.55f, 2.75f), permafrost ? Color.LightBlue : Color.Red, true, true); GeneralParticleHandler.SpawnParticle(orb); } - Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, cirrus ? Color.Magenta : Color.Red, new Vector2(2f, 2f), 0, 0f, 1.1f, 25); + Particle pulse = new DirectionalPulseRing(NPC.Center, Vector2.Zero, permafrost ? Color.LightBlue : Color.Red, new Vector2(2f, 2f), 0, 0f, 1.1f, 25); GeneralParticleHandler.SpawnParticle(pulse); SoundEngine.PlaySound(SpawnSound, NPC.Center); @@ -2636,7 +2717,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 4; i++) { - Dust brimstoneFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-24f, 24f), cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone); + Dust brimstoneFire = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Square(-24f, 24f), permafrost ? DustID.IceGolem : (int)CalamityDusts.Brimstone); brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2.75f, 4.25f); brimstoneFire.noGravity = true; } @@ -2662,7 +2743,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } else { - if (cirrus ? NPC.AnyNPCs(ModContent.NPCType()) : NPC.AnyNPCs(ModContent.NPCType())) + if (permafrost ? NPC.AnyNPCs(ModContent.NPCType()) : NPC.AnyNPCs(ModContent.NPCType())) { NPC.dontTakeDamage = true; NPC.chaseable = false; @@ -2825,32 +2906,32 @@ namespace CalamityMod.NPCs.SupremeCalamitas canFireSplitingFireball = false; randomShot = gigablast; - Particle pulse = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1.2f, cirrus ? Color.Pink : Color.Red, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.92f, 0f, 55); + Particle pulse = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1.2f, permafrost ? Color.Cyan : Color.Red, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.92f, 0f, 55); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1f, cirrus ? Color.Pink : Color.Magenta, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.95f, 0.4f, 55); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1f, permafrost ? Color.Cyan : Color.Magenta, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.95f, 0.4f, 55); GeneralParticleHandler.SpawnParticle(pulse2); if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, GigablastDamage, 0f, Main.myPlayer, 0f, 2f); NPC.netUpdate = true; } } - else if ((randomShot == 1 && canFireSplitingFireball) || fireFireblastFirst) // Gigablast while floating post laugh + else if ((randomShot == 1 && canFireSplitingFireball) || fireFireblastFirst) // Gigablast while floating post laugh { SoundEngine.PlaySound(BrimstoneShotSound, NPC.Center); 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); + Particle pulse = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1.2f, permafrost ? Color.Cyan : Color.Red, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.95f, 0f, 55); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1f, cirrus ? Color.Pink : Color.Magenta, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.98f, 0.4f, 55); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, projectileVelocity * 1f, permafrost ? Color.Cyan : Color.Magenta, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.98f, 0.4f, 55); GeneralParticleHandler.SpawnParticle(pulse2); if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, FireblastDamage, 0f, Main.myPlayer, 0f, 2f); NPC.netUpdate = true; } } @@ -2866,7 +2947,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 7; i++) // Spred dust while floating post laugh { Vector2 dustVel = (projectileVelocity * 2).RotatedByRandom(0.9) * (Main.rand.NextFloat(0.5f, 1.9f)); - GlowOrbParticle orb = new GlowOrbParticle(projectileSpawn, dustVel, false, 15, Main.rand.NextFloat(0.75f, 1f), cirrus ? Color.Magenta : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.3f), true, true); + GlowOrbParticle orb = new GlowOrbParticle(projectileSpawn, dustVel, false, 15, Main.rand.NextFloat(0.75f, 1f), permafrost ? Color.LightBlue : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.3f), true, true); GeneralParticleHandler.SpawnParticle(orb); } @@ -2874,7 +2955,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { float projectileVelocityToPass = projectileVelocity.Length() * 1.3f; Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, perturbedSpeed, randomShot, barrageDamage, 0f, Main.myPlayer, 0f, 4f, projectileVelocityToPass); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, perturbedSpeed, randomShot, DartDamage, 0f, Main.myPlayer, 0f, 4f, projectileVelocityToPass); NPC.netUpdate = true; } } @@ -3009,7 +3090,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 9; i++) { Vector2 velOffset = NPC.DirectionTo(player.Center).RotatedByRandom(0.6) * Main.rand.NextFloat(5f, 13f); - PointParticle spark2 = new PointParticle(handPosition + velOffset * 2f, velOffset * 1.5f, false, 9, Main.rand.NextFloat(0.5f, 0.75f), cirrus ? Color.HotPink : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); + PointParticle spark2 = new PointParticle(handPosition + velOffset * 2f, velOffset * 1.5f, false, 9, Main.rand.NextFloat(0.5f, 0.75f), permafrost ? Color.Cyan : Main.rand.NextBool(3) ? Color.Lerp(Color.Red, Color.Magenta, 0.3f) : Color.Red); GeneralParticleHandler.SpawnParticle(spark2); } @@ -3020,14 +3101,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas projectileVelocity *= 10f * uDieLul; int projectileType = hellblast; if (attackPause == 0) - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, hellblastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, HellblastDamage, 0f, Main.myPlayer, 0f, 2f); } } } if (Main.rand.NextBool()) // Hand visual post laugh { - GlowOrbParticle orb = new GlowOrbParticle(handPosition, new Vector2(0, -6).RotatedByRandom(0.4) * Main.rand.NextFloat(0.8f, 1.4f), false, 15, Main.rand.NextFloat(0.95f, 1.45f), cirrus ? Color.Magenta : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.5f), true, true); + GlowOrbParticle orb = new GlowOrbParticle(handPosition, new Vector2(0, -6).RotatedByRandom(0.4) * Main.rand.NextFloat(0.8f, 1.4f), false, 15, Main.rand.NextFloat(0.95f, 1.45f), permafrost ? Color.LightBlue : Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.5f), true, true); GeneralParticleHandler.SpawnParticle(orb); } Dust fust = Dust.NewDustPerfect(handPosition, Main.rand.NextBool(3) ? 60 : 114); @@ -3085,9 +3166,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 projectileSpawn = NPC.Center + projectileVelocity * 8f; // Release a burst of magic dust when punching. - Particle pulse = new DirectionalPulseRing(NPC.Center, projectileVelocity * 9, cirrus ? Color.Pink : Color.Red, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.9f, 0f, 60); + Particle pulse = new DirectionalPulseRing(NPC.Center, projectileVelocity * 9, permafrost ? Color.Cyan : Color.Red, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.9f, 0f, 60); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(NPC.Center, projectileVelocity * 8, cirrus ? Color.Pink : Color.Magenta, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.93f, 0.4f, 60); + Particle pulse2 = new DirectionalPulseRing(NPC.Center, projectileVelocity * 8, permafrost ? Color.Cyan : Color.Magenta, new Vector2(0.5f, 1f), projectileVelocity.ToRotation(), 0.93f, 0.4f, 60); GeneralParticleHandler.SpawnParticle(pulse2); NPC.localAI[1] = 0f; @@ -3097,7 +3178,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas SoundEngine.PlaySound(BrimstoneBigShotSound, NPC.Center); projectileVelocity *= 5f * uDieLul; int projectileType = gigablast; - Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, GigablastDamage, 0f, Main.myPlayer, 0f, 2f); } } @@ -3129,7 +3210,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas SparkParticle spark5 = new SparkParticle(NPC.Center - offset - NPC.velocity.SafeNormalize(Vector2.UnitY) * 15f, -NPC.velocity * 0.85f, false, 10, 1.9f * MathHelper.Clamp(Utils.GetLerpValue(120, 0, dashVisualCounter), 0.5f, 1.1f), Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.5f)); GeneralParticleHandler.SpawnParticle(spark5); - Dust dashDust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height), 182); + Dust dashDust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height), DustID.TheDestroyer); dashDust.noGravity = true; dashDust.velocity = -NPC.velocity.RotatedByRandom(0.15f) * Main.rand.NextFloat(0.9f, 1.2f); dashDust.scale = Main.rand.NextFloat(0.6f, 1.4f); @@ -3166,35 +3247,35 @@ namespace CalamityMod.NPCs.SupremeCalamitas { Vector2 leftDustPosition = Vector2.CatmullRom(armPosition + Vector2.UnitY * 1000f, armPosition, heartSpawnPosition, heartSpawnPosition + Vector2.UnitY * 1000f, castCompletion); - Dust castMagicDust = Dust.NewDustPerfect(leftDustPosition, 267); + Dust castMagicDust = Dust.NewDustPerfect(leftDustPosition, DustID.RainbowMk2); castMagicDust.scale = 1.67f; castMagicDust.velocity = Main.rand.NextVector2CircularEdge(0.2f, 0.2f); castMagicDust.fadeIn = 0.67f; - castMagicDust.color = cirrus ? Color.Pink : Color.Red; + castMagicDust.color = permafrost ? Color.Cyan : Color.Red; castMagicDust.noGravity = true; } if (attackCastDelay == 0) { - string key = cirrus ? "Mods.CalamityMod.Status.Boss.CirrusBirbSwarmText" : "Mods.CalamityMod.Status.Boss.SCalStartText"; + string key = permafrost ? "Mods.CalamityMod.Status.Boss.PermafrostBirbSwarmText" : "Mods.CalamityMod.Status.Boss.SCalStartText"; if (NPC.life <= NPC.lifeMax * 0.08) - key = cirrus ? "Mods.CalamityMod.Status.Boss.CirrusSecondBirbSwarmText" : "Mods.CalamityMod.Status.Boss.SCalSepulcher2Text"; + key = permafrost ? "Mods.CalamityMod.Status.Boss.PermafrostSecondBirbSwarmText" : "Mods.CalamityMod.Status.Boss.SCalSepulcher2Text"; if (!BossRushEvent.BossRushActive) { - if (DownedBossSystem.downedCalamitas && !cirrus) + if (DownedBossSystem.downedCalamitas && !permafrost) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } foreach (Vector2 heartSpawnPosition in heartSpawnPositions) { // Make the hearts appear in a burst of flame. - // Spawn Dragonfollies if Cirrus exists. + // Spawn Dragonfollies if Permfroast exists. for (int i = 0; i < 20; i++) { - Dust castFire = Dust.NewDustPerfect(heartSpawnPosition + Main.rand.NextVector2Square(-30f, 30f), cirrus ? (int)CalamityDusts.Necroplasm : (int)CalamityDusts.Brimstone); + Dust castFire = Dust.NewDustPerfect(heartSpawnPosition + Main.rand.NextVector2Square(-30f, 30f), permafrost ? (int)CalamityDusts.Necroplasm : (int)CalamityDusts.Brimstone); castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); castFire.fadeIn = 1.25f; @@ -3208,14 +3289,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.netMode != NetmodeID.MultiplayerClient) { - if (cirrus) + if (permafrost) { for (int x = 0; x < 5; x++) { - NPC.NewNPC(NPC.GetSource_FromAI(), spawnX + 50, tempSpawnY, ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), spawnX + 50, tempSpawnY, ModContent.NPCType()); spawnX += spawnXAdd; - NPC.NewNPC(NPC.GetSource_FromAI(), spawnX2 - 50, tempSpawnY, ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), spawnX2 - 50, tempSpawnY, ModContent.NPCType()); spawnX2 -= spawnXAdd; tempSpawnY += spawnYAdd; } @@ -3276,9 +3357,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 leftDustPosition = Vector2.CatmullRom(leftOfCircle + Vector2.UnitY * 1000f, leftOfCircle, catastropheSpawnPosition, catastropheSpawnPosition + Vector2.UnitY * 1000f, castCompletion); Vector2 rightDustPosition = Vector2.CatmullRom(rightOfCircle + Vector2.UnitY * 1000f, rightOfCircle, cataclysmSpawnPosition, cataclysmSpawnPosition + Vector2.UnitY * 1000f, castCompletion); - GlowOrbParticle orb = new GlowOrbParticle(leftDustPosition, Vector2.Zero, false, 20, 2.8f - attackCastDelay * 0.01f, cirrus ? Color.Pink : Color.Red, true, true); + GlowOrbParticle orb = new GlowOrbParticle(leftDustPosition, Vector2.Zero, false, 20, 2.8f - attackCastDelay * 0.01f, permafrost ? Color.Cyan : Color.Red, true, true); GeneralParticleHandler.SpawnParticle(orb); - GlowOrbParticle orb2 = new GlowOrbParticle(rightDustPosition, Vector2.Zero, false, 20, 2.8f - attackCastDelay * 0.01f, cirrus ? Color.Pink : Color.Red, true, true); + GlowOrbParticle orb2 = new GlowOrbParticle(rightDustPosition, Vector2.Zero, false, 20, 2.8f - attackCastDelay * 0.01f, permafrost ? Color.Cyan : Color.Red, true, true); GeneralParticleHandler.SpawnParticle(orb2); } @@ -3323,12 +3404,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas SparkParticle spark2 = new SparkParticle(cataclysmSpawnPosition, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f), false, 35, Main.rand.NextFloat(1.2f, 1.45f), Main.rand.NextBool() ? new Color(80, 21, 77) : Color.Red); GeneralParticleHandler.SpawnParticle(spark2); - Dust catastrophedust = Dust.NewDustPerfect(catastropheSpawnPosition, 279, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.5f)); + Dust catastrophedust = Dust.NewDustPerfect(catastropheSpawnPosition, DustID.SilverFlame, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.5f)); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(1.5f, 1.85f); catastrophedust.color = Color.DeepSkyBlue; - Dust cataclysmdust = Dust.NewDustPerfect(cataclysmSpawnPosition, 279, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.5f)); + Dust cataclysmdust = Dust.NewDustPerfect(cataclysmSpawnPosition, DustID.SilverFlame, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.5f)); cataclysmdust.noGravity = true; cataclysmdust.scale = Main.rand.NextFloat(1.5f, 1.85f); cataclysmdust.color = new Color(80, 21, 77); @@ -3338,19 +3419,20 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!BossRushEvent.BossRushActive) { string key = "Mods.CalamityMod.Status.Boss.SCalBrothersText"; - if (cirrus) - key = "Mods.CalamityMod.Status.Boss.CirrusDoGText"; + if (permafrost) + key = "Mods.CalamityMod.Status.Boss.PermafrostDoGText"; else if (DownedBossSystem.downedCalamitas) key += "Rematch"; - CalamityUtils.DisplayLocalizedText(key, cirrus ? cirrusTextColor : textColor); + CalamityUtils.BroadcastLocalizedText(key, permafrost ? permafrostTextColor : textColor); } if (Main.netMode != NetmodeID.MultiplayerClient) { bool broDirection = Main.rand.NextBool(); - CalamityUtils.SpawnBossBetter(catastropheSpawnPosition, cirrus ? ModContent.NPCType() : ModContent.NPCType(), null, broDirection == false ? 1 : -1); - CalamityUtils.SpawnBossBetter(cataclysmSpawnPosition, cirrus ? ModContent.NPCType() : ModContent.NPCType(), null, broDirection == true ? 1 : -1); + CalamityUtils.SpawnBossBetter(catastropheSpawnPosition, permafrost ? ModContent.NPCType() : ModContent.NPCType(), null, broDirection == false ? 1 : -1); + if (!permafrost) + CalamityUtils.SpawnBossBetter(cataclysmSpawnPosition, ModContent.NPCType(), null, broDirection == true ? 1 : -1); } SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCKilled/RavagerDeath1") with { Pitch = -0.2f }, cataclysmSpawnPosition); @@ -3428,7 +3510,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } #region Loot - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -3447,7 +3529,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Spawn the SCal NPC directly where the boss was if (!BossRushEvent.BossRushActive) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y + 12, cirrus ? ModContent.NPCType() : ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y + 12, permafrost ? ModContent.NPCType() : ModContent.NPCType()); // Mark Calamitas as defeated DownedBossSystem.downedCalamitas = true; @@ -3478,7 +3560,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); // SCal vanity set (This drops all at once, or not at all) var scalVanitySet = ItemDropRule.Common(ModContent.ItemType(), 7); @@ -3503,11 +3586,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas // GFB Slurper Pole drops var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); } - // Legendary seed pony on a stick upgrade - npcLoot.Add(ItemDropRule.ByCondition(DropHelper.If(info => info.npc.type == ModContent.NPCType() && info.npc.ModNPC().cirrus, false), ModContent.ItemType())); + // Legendary seed Coldheart Icicle + npcLoot.Add(ItemDropRule.ByCondition(DropHelper.If(info => info.npc.type == ModContent.NPCType() && info.npc.ModNPC().permafrost, false), ModContent.ItemType())); // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedCalamitas, ModContent.ItemType(), desc: DropHelper.FirstKillText); @@ -3556,7 +3639,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas float _ = 0f; bool collidingWithShield = Collision.CheckAABBvLineCollision(target.TopLeft, target.Size, shieldTop, shieldBottom, 64f, ref _) && shieldOpacity > 0.55f; - return collidingWithShield || NPC.Hitbox.Intersects(target.Hitbox); + // CIT 16MAY2025: SCal must have contact damage set on the first frame to preserve difficulty mode stat scaling, sometimes leading to people getting hit if on top of her. + // Thus, also check if the arena has spawned, since that will not be true on the first frame. + return (collidingWithShield || NPC.Hitbox.Intersects(target.Hitbox)) && spawnArena; } public override void FindFrame(int frameHeight) @@ -3587,19 +3672,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.frameCounter %= 6; NPC.frame.Y = (int)NPC.frameCounter + (int)FrameType * 6; } - if (cirrus) - { - alicornFrameCounter++; - if (alicornFrameCounter > 6) - { - alicornFrame++; - alicornFrameCounter = 0; - } - if (alicornFrame > 14 || alicornFrame < 9) - { - alicornFrame = 9; - } - } } public override Color? GetAlpha(Color drawColor) => willCharge ? Color.Lerp(Color.Red, drawColor, 0.7f) * NPC.Opacity * 0.45f : null; @@ -3611,23 +3683,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = DownedBossSystem.downedCalamitas && !BossRushEvent.BossRushActive ? TextureAssets.Npc[Type].Value : HoodedTexture.Value; - Texture2D pony = ModContent.Request("CalamityMod/Items/Mounts/AlicornMount_Front").Value; - bool inPhase2 = NPC.ai[0] >= 3f && (NPC.life > NPC.lifeMax * 0.01 || cirrus); + bool inPhase2 = NPC.ai[0] >= 3f && (NPC.life > NPC.lifeMax * 0.01 || permafrost); - if (cirrus) - texture2D15 = inPhase2 ? CirrusTexture2.Value : CirrusTexture.Value; + if (permafrost) + texture2D15 = PermafrostTexture.Value; Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[Type] / 2f); - Vector2 ponyOrigin = new Vector2(pony.Width / 2f, pony.Height / 30f); int afterimageAmt = 7; Rectangle frame = texture2D15.Frame(2, Main.npcFrameCount[Type], NPC.frame.Y / Main.npcFrameCount[Type], NPC.frame.Y % Main.npcFrameCount[Type]); - Rectangle ponyFrame = pony.Frame(1, 15, 0, alicornFrame); - Vector2 ponyPos = NPC.Center - screenPos; - ponyPos -= new Vector2(pony.Width / 2f, pony.Height / 15) * NPC.scale / 2f; - ponyPos += ponyOrigin * NPC.scale + new Vector2(-20, NPC.gfxOffY); - if (CalamityClientConfig.Instance.Afterimages && !(cirrus && NPC.ai[1] == 2f)) + if (CalamityClientConfig.Instance.Afterimages && !(permafrost && NPC.ai[1] == 2f)) { for (int i = 1; i < afterimageAmt; i += 2) { @@ -3646,7 +3712,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas drawLocation -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[Type]) * NPC.scale / 2f; drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - if (!(cirrus && NPC.ai[1] == 2f)) + if (!(permafrost && NPC.ai[1] == 2f)) { if (inPhase2) { @@ -3655,7 +3721,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas drawLocation += Main.rand.NextVector2Circular(0.25f, 0.7f); // And gain a flaming aura. - Color auraColor = NPC.GetAlpha(cirrus ? Color.Pink : Color.Red) * 0.4f; + Color auraColor = NPC.GetAlpha(permafrost ? Color.Cyan : Color.Red) * 0.4f; for (int i = 0; i < 7; i++) { Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTimeWrappedHourly * 4f).ToRotationVector2(); @@ -3669,17 +3735,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!NPC.IsABestiaryIconDummy) { DrawForcefield(spriteBatch); - if (cirrus) - { - if (NPC.ai[1] == 2f) - { - spriteBatch.Draw(pony, ponyPos, ponyFrame, NPC.GetAlpha(drawColor), NPC.rotation, ponyOrigin, NPC.scale, spriteEffects, 0f); - } - } - else - { - DrawShield(spriteBatch); - } + DrawShield(spriteBatch); } return false; } @@ -3734,7 +3790,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas GameShaders.Misc["CalamityMod:SupremeShield"].UseImage1("Images/Misc/Perlin"); Color forcefieldColor = Color.DarkViolet; - Color secondaryForcefieldColor = (cirrus ? Color.HotPink : Color.Red) * 1.4f; + Color secondaryForcefieldColor = (permafrost ? Color.Cyan : Color.Red) * 1.4f; if (!NPC.dontTakeDamage && willCharge && NPC.ai[1] != 2f) { @@ -3813,7 +3869,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int k = 0; k < 5; k++) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, hit.HitDirection, -1f, 0, default, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, permafrost ? DustID.IceGolem : (int)CalamityDusts.Brimstone, hit.HitDirection, -1f, 0, default, 1f); } if (NPC.life <= 0) { @@ -3823,7 +3879,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.position.Y = NPC.position.Y - (NPC.height / 2); for (int i = 0; i < 40; i++) { - int onHitDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + int onHitDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, permafrost ? DustID.IceGolem : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); Main.dust[onHitDust].velocity *= 3f; if (Main.rand.NextBool()) { @@ -3833,10 +3889,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas } for (int j = 0; j < 70; j++) { - int onHitDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + int onHitDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, permafrost ? DustID.IceGolem : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); Main.dust[onHitDust2].noGravity = true; Main.dust[onHitDust2].velocity *= 5f; - onHitDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, cirrus ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + onHitDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, permafrost ? DustID.IceGolem : (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); Main.dust[onHitDust2].velocity *= 2f; } } @@ -3845,89 +3901,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - { - target.AddBuff(ModContent.BuffType(), 600); - InflictCirrusDebuffs(target); - } - } - - public void InflictCirrusDebuffs(Player target) - { - if (cirrus) - { - switch (Main.rand.Next(MaxCirrusAlcohols)) - { - case 0: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 1: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 2: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 3: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 4: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 5: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 6: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 7: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 8: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 9: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 10: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 11: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 12: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 13: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 14: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 15: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 16: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 17: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 18: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 19: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - case 20: - target.AddBuff(ModContent.BuffType(), MaxCirrusAlcoholDebuffDuration); - break; - } - } } } } diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index f20fb06bb9..16753e1d2c 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -74,10 +74,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } + public static int FistDamage = 100; // 400 + public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.npcSlots = 5f; NPC.width = 120; NPC.height = 120; @@ -94,9 +96,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.localAI[1] = 500; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -181,14 +180,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Increase DR if the target leaves SCal's arena. - NPC.Calamity().DR = SupremeCataclysm.NormalBrothersDR; - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().IsTargetOutsideOfArena) + NPC.Calamity().DR = NormalBrothersDR; + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().protectionBoost) NPC.Calamity().DR = SupremeCalamitas.enragedDR; float totalLifeRatio = NPC.life / (float)NPC.lifeMax; @@ -266,7 +264,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { for (int i = 0; i < 6; i++) { - Dust cataclysmdust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height) - NPC.velocity * 0.5f, 66, -NPC.velocity * Main.rand.NextFloat(0.1f, 0.6f)); + Dust cataclysmdust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height) - NPC.velocity * 0.5f, DustID.RainbowTorch, -NPC.velocity * Main.rand.NextFloat(0.1f, 0.6f)); cataclysmdust.noGravity = true; cataclysmdust.scale = Main.rand.NextFloat(0.7f, 1.3f); cataclysmdust.color = Color.Lerp(Color.Red, Color.Magenta, 0.5f); @@ -326,7 +324,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas else if (BigAttackTimer > PreBigAttackPause) { // Shoot fists. - float fireRate = BossRushEvent.BossRushActive ? 2f : MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (broIsAlive == false ? death ? 1.32f : 1.1f : 1); + float fireRate = MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (!broIsAlive ? death ? 1.32f : 1.1f : 1); PunchCounter += fireRate; if (PunchCounter >= PunchCounterLimit) @@ -339,9 +337,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.zenithWorld) type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (bossRush) - damage /= 2; + int damage = Main.zenithWorld ? SupremeCatastrophe.SlashDamage : FistDamage; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -379,7 +375,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 7; 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); + Dust cataclysmdust = Dust.NewDustPerfect(NPC.Center + vel * 2, DustID.SilverFlame, vel); cataclysmdust.noGravity = true; cataclysmdust.scale = Main.rand.NextFloat(1.2f, 1.8f); cataclysmdust.color = Color.Red; @@ -391,9 +387,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas else { // Shoot fists. - float fireRate = BossRushEvent.BossRushActive ? 2.8f : MathHelper.Lerp(2.5f, 3f, 1f - totalLifeRatio); + float fireRate = MathHelper.Lerp(2.5f, 3f, 1f - totalLifeRatio); if (broIsAlive == false) - fireRate = BossRushEvent.BossRushActive ? 3.5f + (29 - BigAttackLimit) * 0.45f : MathHelper.Lerp(3f, (4f + (29 - BigAttackLimit) * 0.45f), 1f - totalLifeRatio) * 1.2f; + fireRate = MathHelper.Lerp(3f, (4f + (29 - BigAttackLimit) * 0.45f), 1f - totalLifeRatio) * 1.2f; if (Phase2 && BigAttackLimit == 0) fireRate = 1; @@ -407,9 +403,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.zenithWorld) type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (bossRush) - damage /= 2; + int damage = Main.zenithWorld ? SupremeCatastrophe.SlashDamage : FistDamage; Vector2 fistSpawnPosition = NPC.Center + Vector2.UnitX * 74f * NPC.direction; if ((broIsAlive == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 1) && death) @@ -423,7 +417,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center) * 9.5f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, PunchingFromRight.ToInt(), 3); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center) * 9.5f, ModContent.ProjectileType(), FistDamage, 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); @@ -558,7 +552,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, DustID.SilverFlame, vel); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); catastrophedust.color = Color.DeepSkyBlue; diff --git a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index 596c9706a8..497d4a7f3b 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -67,10 +67,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } + public static int SlashDamage = 100; // 400 + public static int TrailedSlashDamage = 120; // 480 + public override void SetDefaults() { NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.damage = 0; // 0 contact damage, projectile damage is pulled from NPCStats + NPC.damage = 0; // No contact damage NPC.npcSlots = 5f; NPC.width = 120; NPC.height = 120; @@ -87,9 +90,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.localAI[1] = 500; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -175,14 +175,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Increase DR if the target leaves SCal's arena. NPC.Calamity().DR = SupremeCataclysm.NormalBrothersDR; - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().IsTargetOutsideOfArena) + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().protectionBoost) NPC.Calamity().DR = SupremeCalamitas.enragedDR; float totalLifeRatio = NPC.life / (float)NPC.lifeMax; @@ -259,7 +258,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { for (int i = 0; i < 6; i++) { - Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height) - NPC.velocity * 0.5f, 66, -NPC.velocity * Main.rand.NextFloat(0.1f, 0.6f)); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height) - NPC.velocity * 0.5f, DustID.RainbowTorch, -NPC.velocity * Main.rand.NextFloat(0.1f, 0.6f)); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(0.7f, 1.3f); catastrophedust.color = Color.Cyan; @@ -274,11 +273,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas dashAttackTimer--; int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (bossRush) - damage /= 2; - - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, NPC.velocity.SafeNormalize(Vector2.UnitY) * 0.1f, type, damage, 0f, Main.myPlayer, 0f, SlashingFromRight.ToInt(), 4 + dashes); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, NPC.velocity.SafeNormalize(Vector2.UnitY) * 0.1f, type, TrailedSlashDamage, 0f, Main.myPlayer, 0f, SlashingFromRight.ToInt(), 4 + dashes); dashes++; if (dashes == 30 && broIsAlive == false) { @@ -291,7 +286,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, DustID.SilverFlame, vel); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); catastrophedust.color = Color.DeepSkyBlue; @@ -308,12 +303,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas { 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); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.DirectionTo(Target.Center).RotatedBy(0.34f) * 130, NPC.DirectionTo(Target.Center).RotatedBy(0.34f) * 90f, type, TrailedSlashDamage, 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, TrailedSlashDamage, 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); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, DustID.SilverFlame, vel); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); catastrophedust.color = Color.DeepSkyBlue; @@ -373,7 +368,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas else if (BigAttackTimer > PreBigAttackPause) { // Shoot sword slashes. - float fireRate = BossRushEvent.BossRushActive ? 2f : MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (broIsAlive == false ? death ? 1.25f : 1.05f : 1); + float fireRate = MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (!broIsAlive ? death ? 1.25f : 1.05f : 1); SlashCounter += fireRate; if (SlashCounter >= SlashCounterLimit) { @@ -385,9 +380,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.zenithWorld) type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (bossRush) - damage /= 2; + int damage = Main.zenithWorld ? SupremeCataclysm.FistDamage : SlashDamage; Vector2 slashSpawnPosition = NPC.Center + Vector2.UnitX * 125f * NPC.direction; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -427,7 +420,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int i = 0; i < 7; 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); + Dust catastrophedust = Dust.NewDustPerfect(NPC.Center + vel * 2, DustID.SilverFlame, vel); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); catastrophedust.color = Color.DeepSkyBlue; @@ -439,7 +432,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas else { // Shoot sword slashes. - float fireRate = BossRushEvent.BossRushActive ? 2.8f : MathHelper.Lerp(2.5f, 3f, 1f - totalLifeRatio) * (broIsAlive == false ? 1.35f : 1); + float fireRate = MathHelper.Lerp(2.5f, 3f, 1f - totalLifeRatio) * (!broIsAlive ? 1.35f : 1); if (Phase2 && BigAttackLimit == 0) fireRate = 1; SlashCounter += fireRate; @@ -452,14 +445,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Main.zenithWorld) type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - if (bossRush) - damage /= 2; + int damage = Main.zenithWorld ? SupremeCataclysm.FistDamage : SlashDamage; Vector2 slashSpawnPosition = NPC.Center; Vector2 firingVelocity = (broIsAlive == false ? (NPC.DirectionTo(Target.Center) + Target.velocity * 0.032f).SafeNormalize(Vector2.UnitY) : NPC.DirectionTo(Target.Center)); if ((broIsAlive == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 1) && death) { + if (!Main.zenithWorld) + damage = TrailedSlashDamage; + 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); @@ -594,7 +588,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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); + Dust cataclysmdust = Dust.NewDustPerfect(NPC.Center + vel * 2, DustID.SilverFlame, vel); cataclysmdust.noGravity = true; cataclysmdust.scale = Main.rand.NextFloat(1.2f, 1.8f); cataclysmdust.color = Color.Red; diff --git a/NPCs/SupremeCalamitas/SupremeCirrus.png b/NPCs/SupremeCalamitas/SupremeCirrus.png deleted file mode 100644 index 4412c1c02b..0000000000 Binary files a/NPCs/SupremeCalamitas/SupremeCirrus.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SupremeCirrus_Shimmered.png b/NPCs/SupremeCalamitas/SupremeCirrus_Shimmered.png deleted file mode 100644 index 1ce3adfdf2..0000000000 Binary files a/NPCs/SupremeCalamitas/SupremeCirrus_Shimmered.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SupremePermafrost.png b/NPCs/SupremeCalamitas/SupremePermafrost.png new file mode 100644 index 0000000000..4e75ae0b28 Binary files /dev/null and b/NPCs/SupremeCalamitas/SupremePermafrost.png differ diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index 0a62a3a2f0..bba8fe588d 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -18,6 +18,7 @@ namespace CalamityMod.NPCs.TownNPCs public class AndroombaFriendly : ModNPC { public static Asset[] FaceTextures = new Asset[9]; + public static int AstralConversionType; // Allow for solutions from other mods. The first integer is the solution's item ID, the texture is what face shoul dappear, the Action is what modders should use for spread code public static List<(int, string, Action)> customConversionTypes = new List<(int, string, Action)>{}; @@ -44,6 +45,7 @@ namespace CalamityMod.NPCs.TownNPCs FaceTextures[7] = ModContent.Request(Texture + "_Forest", AssetRequestMode.AsyncLoad); FaceTextures[8] = ModContent.Request(Texture + "_Astral", AssetRequestMode.AsyncLoad); } + AstralConversionType = ModContent.GetInstance().Type; } public override void SetDefaults() @@ -65,6 +67,8 @@ namespace CalamityMod.NPCs.TownNPCs NPC.catchItem = (short)ModContent.ItemType(); SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; NPC.dontTakeDamage = true; + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToElectricity = true; } public override bool CanChat() => false; @@ -131,26 +135,12 @@ namespace CalamityMod.NPCs.TownNPCs // Stuff for vanilla solutions if (conversionType <= 7) { - ConvertType type = ConvertType.Pure; - switch (conversionType) - { - case 1: - type = ConvertType.Corrupt; - break; - case 2: - type = ConvertType.Hallow; - break; - case 4: - type = ConvertType.Crimson; - break; - } - 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) { - World.AstralBiome.ConvertToAstral(x - 2, x + 2, y - 2, y + 2); + WorldGen.Convert(x, y, AstralConversionType, 2); } // Solutions registered by other mods else diff --git a/NPCs/TownNPCs/Archmage.cs b/NPCs/TownNPCs/Archmage.cs index 1be98d5a41..d9f67f8926 100644 --- a/NPCs/TownNPCs/Archmage.cs +++ b/NPCs/TownNPCs/Archmage.cs @@ -3,7 +3,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Ammo; using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.Items.Potions; +using CalamityMod.Items.Potions.Food; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -65,6 +65,9 @@ namespace CalamityMod.NPCs.TownNPCs NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.8f; AnimationType = NPCID.Guide; + NPC.Calamity().VulnerableToCold = false; + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToSickness = true; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -84,7 +87,13 @@ namespace CalamityMod.NPCs.TownNPCs } } - public override bool CanTownNPCSpawn(int numTownNPCs) => DownedBossSystem.downedCryogen; + public override bool CanTownNPCSpawn(int numTownNPCs) + { + if (NPC.AnyNPCs(ModContent.NPCType()) && Main.zenithWorld) + return false; + + return DownedBossSystem.downedCryogen; + } public override List SetNPCNameList() => new List() { this.GetLocalizedValue("Name.Permafrost") }; @@ -146,25 +155,24 @@ namespace CalamityMod.NPCs.TownNPCs public override void AddShops() { NPCShop shop = new(Type); - shop.Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType(), Condition.DownedMechBossAll) - .Add(ModContent.ItemType(), Condition.DownedMechBossAll) - .Add(ModContent.ItemType(), Condition.DownedMechBossAll) - .Add(ModContent.ItemType(), Condition.DownedMechBossAll) - .Add(ModContent.ItemType(), Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) - .Add(ModContent.ItemType(), Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) - .Add(ModContent.ItemType(), Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) - .Add(ModContent.ItemType(), Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) - .Add(ModContent.ItemType(), Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) - .Add(ModContent.ItemType()) + shop.Add() + .Add() + .Add() + .Add(Condition.DownedMechBossAll) + .Add(Condition.DownedMechBossAll) + .Add(Condition.DownedMechBossAll) + .Add(Condition.DownedMechBossAll) + .Add(Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) + .Add(Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) + .Add(Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) + .Add(Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) + .Add(Condition.DownedEverscream, Condition.DownedSantaNK1, Condition.DownedIceQueen) + .Add() .Add(ItemID.SuperManaPotion) - .Add(ModContent.ItemType()) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(5)) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType(), Condition.PlayerCarriesItem(ModContent.ItemType())) - .Add(ItemID.IceCream, Condition.HappyEnoughToSellPylons, Condition.InSnow) + .Add() + .Add() + .Add() + .Add(Condition.PlayerCarriesItem(ModContent.ItemType())) .Register(); } diff --git a/NPCs/TownNPCs/Bandit.cs b/NPCs/TownNPCs/Bandit.cs index b102150c3c..8f4766b4cc 100644 --- a/NPCs/TownNPCs/Bandit.cs +++ b/NPCs/TownNPCs/Bandit.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; -using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Pets; +using CalamityMod.Items.Tools; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Packets; using CalamityMod.Projectiles.Rogue; @@ -70,6 +70,9 @@ namespace CalamityMod.NPCs.TownNPCs NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.5f; AnimationType = NPCID.PartyGirl; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToSickness = true; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -105,7 +108,7 @@ namespace CalamityMod.NPCs.TownNPCs public override List SetNPCNameList() => new List() { - // Patron names + // Dedicated names "Xplizzy", // <@!98826096237109248> (whitegiraffe) "Freakish", // <@!750363283520749598> (freak5650) "Calder", // <@!601897959176798228> (hardlightcaster) @@ -114,6 +117,10 @@ namespace CalamityMod.NPCs.TownNPCs "Jackson", // <@!525827730646892549> (chowchow360) "Altarca", // <@!1140673052108128337> (altarca_27226_49175) "Jackie", // <@!353241811717718016> (jackalchan) + "Ishmael", // <@!840416568000381046> (vanillaoyster) + "Ariallis", // <@!518231218806980609> (ariallis) + "Shade", // <@!613133259563466755> (shade__storm) + "Orion", // <@!119164557657636865> (canacx) // Original names this.GetLocalizedValue("Name.Laura"), @@ -161,11 +168,6 @@ namespace CalamityMod.NPCs.TownNPCs if (witch != -1) dialogue.Add(this.GetLocalization("Chat.BrimstoneWitch").Format(Main.npc[witch].GivenName)); - //please help me I'm stuck in a children's video game - Fabsol - int cirrusIndex = NPC.FindFirstNPC(ModContent.NPCType()); - if (cirrusIndex != -1) - dialogue.Add(this.GetLocalization("Chat.DrunkPrincess").Format(Main.npc[cirrusIndex].GivenName)); - int merchantIndex = NPC.FindFirstNPC(NPCID.Merchant); if (merchantIndex != -1) dialogue.Add(this.GetLocalization("Chat.Merchant").Format(Main.npc[merchantIndex].GivenName)); @@ -300,26 +302,23 @@ namespace CalamityMod.NPCs.TownNPCs } public override void AddShops() { - Condition downedCalclone = CalamityConditions.DownedCalamitasClone; - Condition downedDoG = CalamityConditions.DownedDevourerOfGods; - Condition downedYharon = CalamityConditions.DownedYharon; NPCShop shop = new(Type); - shop.AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 9)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 9)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 40)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 40)) + shop.Add() + .Add() + .Add() + .Add() .Add(ItemID.TigerClimbingGear) - .Add(ModContent.ItemType(), Condition.DownedPirates) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 60), Condition.DownedMechBossAll) - .Add(ModContent.ItemType(), downedCalclone) - .Add(ModContent.ItemType(), Condition.DownedPlantera) - .Add(ModContent.ItemType(), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(1), Condition.DownedGolem) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2), Condition.DownedMoonLord) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(25), downedDoG) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(40), downedYharon) - .Add(ModContent.ItemType()) //:BearWatchingYou: + .Add(Condition.DownedPirates) + .Add(Condition.DownedMechBossAll) + .Add(CalamityConditions.DownedCalamitasClone) + .Add(Condition.DownedPlantera) + .Add(Condition.DownedPlantera) + .Add(Condition.DownedGolem) + .Add(Condition.DownedMoonLord) + .Add(CalamityConditions.DownedDevourerOfGods) + .Add(CalamityConditions.DownedYharon) + .Add() //:BearWatchingYou: .Register(); } diff --git a/NPCs/TownNPCs/BrimstoneWitch.cs b/NPCs/TownNPCs/BrimstoneWitch.cs index 29717bcce1..aa3216af16 100644 --- a/NPCs/TownNPCs/BrimstoneWitch.cs +++ b/NPCs/TownNPCs/BrimstoneWitch.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using CalamityMod.BiomeManagers; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items; +using CalamityMod.Items.Tools; using CalamityMod.Projectiles.Magic; +using CalamityMod.Systems.Collections; using CalamityMod.UI.CalamitasEnchants; using Microsoft.Xna.Framework; using Terraria; -using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.Events; using Terraria.GameContent.Personalities; @@ -65,6 +65,9 @@ namespace CalamityMod.NPCs.TownNPCs NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath6; NPC.knockBackResist = 0.8f; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToSickness = true; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -673,10 +676,6 @@ namespace CalamityMod.NPCs.TownNPCs } } - int cirrus = NPC.FindFirstNPC(NPCType()); - if (cirrus != -1 && ChildSafety.Disabled) - dialogue.Add(this.GetLocalization("Chat.DrunkPrincess").Format(Main.npc[cirrus].GivenName), 1.45); - if (NPC.AnyNPCs(NPCType())) dialogue.Add(this.GetLocalizedValue("Chat.SeaKing"), 1.45); @@ -686,7 +685,11 @@ namespace CalamityMod.NPCs.TownNPCs return dialogue; } - public override void SetChatButtons(ref string button, ref string button2) => button = this.GetLocalizedValue("EnchantButton"); + public override void SetChatButtons(ref string button, ref string button2) + { + button = this.GetLocalizedValue("EnchantButton"); + button2 = this.GetLocalizedValue("DonorButton"); + } public override void OnChatButtonClicked(bool firstButton, ref string shopName) { @@ -702,6 +705,29 @@ namespace CalamityMod.NPCs.TownNPCs Main.LocalPlayer.Calamity().GivenBrimstoneLocus = true; } } + else + { + Main.npcChatText = GetRandomDonors(25); + } + } + + /// + /// Returns 25 random donator usernames. + /// + public string GetRandomDonors(int numDonors) + { + IList pickingList = [..DonatorsNameList.List]; + + string[] pickedDonors = new string[numDonors]; + for (int i = 0; i < numDonors; ++i) + { + int idxSelected = Main.rand.Next(pickingList.Count); + pickedDonors[i] = pickingList[idxSelected]; + pickingList.RemoveAt(idxSelected); + } + + string text = this.GetLocalization("DonorShoutout").Format(pickedDonors); + return text; } // Make this Town NPC teleport to the Queen statue when triggered. diff --git a/NPCs/TownNPCs/Cirrus.cs b/NPCs/TownNPCs/Cirrus.cs deleted file mode 100644 index 4b0de8366a..0000000000 --- a/NPCs/TownNPCs/Cirrus.cs +++ /dev/null @@ -1,1054 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Events; -using CalamityMod.Items.Mounts; -using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Items.Potions.Alcohol; -using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Summon; -using CalamityMod.Systems.Collections; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.GameContent.Bestiary; -using Terraria.GameContent.Events; -using Terraria.GameContent.Personalities; -using Terraria.GameContent.UI; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.Utilities; - -namespace CalamityMod.NPCs.TownNPCs -{ - [AutoloadHead] - [LegacyName("FAP")] - public class Cirrus : ModNPC - { - public static Asset AltTexture; - - public override void SetStaticDefaults() - { - Main.npcFrameCount[Type] = 27; - NPCID.Sets.ExtraFramesCount[Type] = 9; - NPCID.Sets.AttackFrameCount[Type] = 4; - NPCID.Sets.DangerDetectRange[Type] = 400; - NPCID.Sets.AttackType[Type] = 0; - NPCID.Sets.AttackTime[Type] = 60; - NPCID.Sets.AttackAverageChance[Type] = 15; - NPCID.Sets.ShimmerTownTransform[Type] = false; - // Happiness is so fucking dogshit, I swear to christ. - Fabsol - NPC.Happiness - .SetBiomeAffection(AffectionLevel.Love) - .SetBiomeAffection(AffectionLevel.Like) - .SetBiomeAffection(AffectionLevel.Dislike) - .SetBiomeAffection(AffectionLevel.Hate) - .SetNPCAffection(NPCID.Stylist, AffectionLevel.Love) - .SetNPCAffection(NPCID.BestiaryGirl, AffectionLevel.Love) - .SetNPCAffection(NPCID.DyeTrader, AffectionLevel.Like) - .SetNPCAffection(NPCID.PartyGirl, AffectionLevel.Like) - .SetNPCAffection(NPCID.DD2Bartender, AffectionLevel.Dislike) - .SetNPCAffection(NPCID.TaxCollector, AffectionLevel.Dislike) - .SetNPCAffection(NPCID.GoblinTinkerer, AffectionLevel.Hate) - .SetNPCAffection(NPCID.Angler, AffectionLevel.Hate); - NPCID.Sets.NPCBestiaryDrawModifiers drawModifiers = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - Velocity = 1f // Draws the NPC in the bestiary as if its walking +1 tiles in the x direction - }; - NPCID.Sets.NPCBestiaryDrawOffset.Add(NPC.type, drawModifiers); - if (!Main.dedServ) - { - AltTexture = ModContent.Request(Texture + "Alt", AssetRequestMode.AsyncLoad); - } - } - - public override void SetDefaults() - { - NPC.townNPC = true; - NPC.friendly = true; - NPC.lavaImmune = true; - NPC.width = 18; - NPC.height = 40; - NPC.aiStyle = NPCAIStyleID.Passive; - NPC.damage = 10; - NPC.defense = 15; - NPC.lifeMax = 20000; - NPC.HitSound = SoundID.NPCHit1; - NPC.DeathSound = SoundID.NPCDeath6; - NPC.knockBackResist = 0.5f; - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.TheHallow, - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Cirrus") - }); - } - - public override void FindFrame(int frameHeight) - { - int extraFrameAmt = (NPC.isLikeATownNPC ? NPCID.Sets.ExtraFramesCount[Type] : 0); - if (NPC.velocity.Y == 0f) - { - if (NPC.direction == 1) - NPC.spriteDirection = 1; - - if (NPC.direction == -1) - NPC.spriteDirection = -1; - - int nonAttackFrames = Main.npcFrameCount[Type] - NPCID.Sets.AttackFrameCount[Type]; - if (NPC.ai[0] == 23f) - { - NPC.frameCounter += 1D; - int currentFrameHeight = NPC.frame.Y / frameHeight; - int currentFrame = nonAttackFrames - currentFrameHeight; - if ((uint)(currentFrame - 1) > 1u && (uint)(currentFrame - 4) > 1u && currentFrameHeight != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int num239 = ((!(NPC.frameCounter < 6D)) ? (nonAttackFrames - 4) : (nonAttackFrames - 5)); - if (NPC.ai[1] < 6f) - num239 = nonAttackFrames - 5; - - NPC.frame.Y = frameHeight * num239; - } - else if (NPC.ai[0] >= 20f && NPC.ai[0] <= 22f) - { - int num240 = NPC.frame.Y / frameHeight; - switch ((int)NPC.ai[0]) - { - case 20: - case 21: - case 22: - break; - } - - NPC.frame.Y = num240 * frameHeight; - } - else if (NPC.ai[0] == 2f) - { - NPC.frameCounter += 1D; - if (NPC.frame.Y / frameHeight == nonAttackFrames - 1 && NPC.frameCounter >= 5D) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - else if (NPC.frame.Y / frameHeight == 0 && NPC.frameCounter >= 40D) - { - NPC.frame.Y = frameHeight * (nonAttackFrames - 1); - NPC.frameCounter = 0D; - } - else if (NPC.frame.Y != 0 && NPC.frame.Y != frameHeight * (nonAttackFrames - 1)) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - } - else if (NPC.ai[0] == 5f) // Sitting - { - NPC.frame.Y = frameHeight * (nonAttackFrames - 3); - NPC.frameCounter = 0D; - } - else if (NPC.ai[0] == 6f) // Throwing confetti - { - NPC.frameCounter += 1D; - int confettiFrameHeight = NPC.frame.Y / frameHeight; - int currentFrame = nonAttackFrames - confettiFrameHeight; - if ((uint)(currentFrame - 1) > 1u && (uint)(currentFrame - 4) > 1u && confettiFrameHeight != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int confettiFrame = ((!(NPC.frameCounter < 10D)) ? - ((NPC.frameCounter < 16D) ? - (nonAttackFrames - 5) : ((NPC.frameCounter < 46D) ? - (nonAttackFrames - 4) : ((NPC.frameCounter < 60D) ? - (nonAttackFrames - 5) : ((!(NPC.frameCounter < 66D)) ? - ((NPC.frameCounter < 72D) ? - (nonAttackFrames - 5) : ((NPC.frameCounter < 102D) ? - (nonAttackFrames - 4) : ((NPC.frameCounter < 108D) ? - (nonAttackFrames - 5) : ((!(NPC.frameCounter < 114D)) ? - ((NPC.frameCounter < 120D) ? - (nonAttackFrames - 5) : ((NPC.frameCounter < 150D) ? - (nonAttackFrames - 4) : ((NPC.frameCounter < 156D) ? - (nonAttackFrames - 5) : ((!(NPC.frameCounter < 162D)) ? - ((NPC.frameCounter < 168D) ? - (nonAttackFrames - 5) : ((NPC.frameCounter < 198D) ? - (nonAttackFrames - 4) : ((NPC.frameCounter < 204D) ? - (nonAttackFrames - 5) : ((!(NPC.frameCounter < 210D)) ? - ((NPC.frameCounter < 216D) ? - (nonAttackFrames - 5) : ((NPC.frameCounter < 246D) ? - (nonAttackFrames - 4) : ((NPC.frameCounter < 252D) ? - (nonAttackFrames - 5) : ((!(NPC.frameCounter < 258D)) ? - ((NPC.frameCounter < 264D) ? - (nonAttackFrames - 5) : ((NPC.frameCounter < 294D) ? - (nonAttackFrames - 4) : ((NPC.frameCounter < 300D) ? - (nonAttackFrames - 5) : 0))) : 0)))) : 0)))) : 0)))) : 0)))) : 0)))) : 0); - - if (confettiFrame == nonAttackFrames - 4 && confettiFrameHeight == nonAttackFrames - 5) - { - Vector2 vector4 = NPC.Center + new Vector2(10 * NPC.direction, -4f); - for (int n = 0; n < 8; n++) - { - int confettiDust = Main.rand.Next(139, 143); - int partyTime = Dust.NewDust(vector4, 0, 0, confettiDust, NPC.velocity.X + (float)NPC.direction, NPC.velocity.Y - 2.5f, 0, default(Color), 1.2f); - Main.dust[partyTime].velocity.X += (float)NPC.direction * 1.5f; - Dust dust = Main.dust[partyTime]; - dust.position -= new Vector2(4f); - dust = Main.dust[partyTime]; - dust.velocity *= 2f; - Main.dust[partyTime].scale = 0.7f + Main.rand.NextFloat() * 0.3f; - } - } - - NPC.frame.Y = frameHeight * confettiFrame; - if (NPC.frameCounter >= 300D) - NPC.frameCounter = 0D; - } - else if (NPC.ai[0] == 7f || NPC.ai[0] == 19f) // Talking to the player - { - NPC.frameCounter += 1D; - int playerTalkFrameHeight = NPC.frame.Y / frameHeight; - int currentFrame = nonAttackFrames - playerTalkFrameHeight; - if ((uint)(currentFrame - 1) > 1u && (uint)(currentFrame - 4) > 1u && playerTalkFrameHeight != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int playerTalkFrame = 0; - if (NPC.frameCounter < 16D) - playerTalkFrame = 0; - else if (NPC.frameCounter == 16D) - EmoteBubble.NewBubbleNPC(new WorldUIAnchor(NPC), 112); - else if (NPC.frameCounter < 128D) - playerTalkFrame = ((NPC.frameCounter % 16D < 8D) ? (nonAttackFrames - 2) : 0); - else if (NPC.frameCounter < 160D) - playerTalkFrame = 0; - else if (NPC.frameCounter != 160D) - playerTalkFrame = ((NPC.frameCounter < 220D) ? ((NPC.frameCounter % 12D < 6D) ? (nonAttackFrames - 2) : 0) : 0); - else - EmoteBubble.NewBubbleNPC(new WorldUIAnchor(NPC), 60); - - NPC.frame.Y = frameHeight * playerTalkFrame; - if (NPC.frameCounter >= 220D) - NPC.frameCounter = 0D; - } - else if (NPC.ai[0] == 9f) - { - NPC.frameCounter += 1D; - int num251 = NPC.frame.Y / frameHeight; - int currentFrame = nonAttackFrames - num251; - if ((uint)(currentFrame - 1) > 1u && (uint)(currentFrame - 4) > 1u && num251 != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int num252 = ((!(NPC.frameCounter < 10D)) ? ((!(NPC.frameCounter < 16D)) ? (nonAttackFrames - 4) : (nonAttackFrames - 5)) : 0); - if (NPC.ai[1] < 16f) - num252 = nonAttackFrames - 5; - - if (NPC.ai[1] < 10f) - num252 = 0; - - NPC.frame.Y = frameHeight * num252; - } - else if (NPC.ai[0] == 18f) - { - NPC.frameCounter += 1D; - int num253 = NPC.frame.Y / frameHeight; - int currentFrame = nonAttackFrames - num253; - if ((uint)(currentFrame - 1) > 1u && (uint)(currentFrame - 4) > 1u && num253 != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int num254 = 0; - if (NPC.frameCounter < 10D) - num254 = 0; - else if (NPC.frameCounter < 16D) - num254 = nonAttackFrames - 1; - else - num254 = nonAttackFrames - 2; - - if (NPC.ai[1] < 16f) - num254 = nonAttackFrames - 1; - - if (NPC.ai[1] < 10f) - num254 = 0; - - num254 = Main.npcFrameCount[Type] - 2; - NPC.frame.Y = frameHeight * num254; - } - else if (NPC.ai[0] == 10f || NPC.ai[0] == 13f) // Attacking - { - NPC.frameCounter += 1D; - int attackFrameHeight = NPC.frame.Y / frameHeight; - int currentFrame = attackFrameHeight - nonAttackFrames; - if ((uint)currentFrame > 3u && attackFrameHeight != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int attackTimingStart = 10; - int attackFrameTiming = 6; - int attackFrame = ((!(NPC.frameCounter < (double)attackTimingStart)) ? - ((NPC.frameCounter < (double)(attackTimingStart + attackFrameTiming)) ? - nonAttackFrames : ((NPC.frameCounter < (double)(attackTimingStart + attackFrameTiming * 2)) ? - (nonAttackFrames + 1) : ((NPC.frameCounter < (double)(attackTimingStart + attackFrameTiming * 3)) ? - (nonAttackFrames + 2) : ((NPC.frameCounter < (double)(attackTimingStart + attackFrameTiming * 4)) ? - (nonAttackFrames + 3) : 0)))) : 0); - - NPC.frame.Y = frameHeight * attackFrame; - } - else if (NPC.ai[0] == 15f) - { - NPC.frameCounter += 1D; - int num259 = NPC.frame.Y / frameHeight; - int currentFrame = num259 - nonAttackFrames; - if ((uint)currentFrame > 3u && num259 != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - float num260 = NPC.ai[1] / (float)NPCID.Sets.AttackTime[Type]; - int num261 = 0; - num261 = ((num260 > 0.65f) ? - nonAttackFrames : ((num260 > 0.5f) ? - (nonAttackFrames + 1) : ((num260 > 0.35f) ? - (nonAttackFrames + 2) : ((num260 > 0f) ? - (nonAttackFrames + 3) : 0)))); - - NPC.frame.Y = frameHeight * num261; - } - else if (NPC.ai[0] == 25f) - { - NPC.frame.Y = frameHeight; - } - else if (NPC.ai[0] == 12f) - { - NPC.frameCounter += 1D; - int num262 = NPC.frame.Y / frameHeight; - int currentFrame = num262 - nonAttackFrames; - if ((uint)currentFrame > 4u && num262 != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int num263 = nonAttackFrames + NPC.GetShootingFrame(NPC.ai[2]); - NPC.frame.Y = frameHeight * num263; - } - else if (NPC.ai[0] == 14f || NPC.ai[0] == 24f) - { - NPC.frameCounter += 1D; - int num264 = NPC.frame.Y / frameHeight; - int currentFrame = num264 - nonAttackFrames; - if ((uint)currentFrame > 1u && num264 != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - int num265 = 12; - int num266 = ((NPC.frameCounter % (double)num265 * 2D < (double)num265) ? nonAttackFrames : (nonAttackFrames + 1)); - NPC.frame.Y = frameHeight * num266; - if (NPC.ai[0] == 24f) - { - if (NPC.frameCounter == 60D) - EmoteBubble.NewBubble(EmoteID.EmoteConfused, new WorldUIAnchor(NPC), 60); - - if (NPC.frameCounter == 150D) - EmoteBubble.NewBubble(EmoteID.EmotionAlert, new WorldUIAnchor(NPC), 90); - - if (NPC.frameCounter >= 240D) - NPC.frame.Y = 0; - } - } - else if (NPC.ai[0] == 1001f) - { - NPC.frame.Y = frameHeight * (nonAttackFrames - 1); - NPC.frameCounter = 0D; - } - else if (NPC.CanTalk && (NPC.ai[0] == 3f || NPC.ai[0] == 4f)) // Talking to another NPC - { - NPC.frameCounter += 1D; - int npcTalkFrameHeight = NPC.frame.Y / frameHeight; - int currentFrame = nonAttackFrames - npcTalkFrameHeight; - if ((uint)(currentFrame - 1) > 1u && (uint)(currentFrame - 4) > 1u && npcTalkFrameHeight != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - bool displayEmote = NPC.ai[0] == 3f; - int npcTalkFrame = 0; - int npcTalkHandFrame = 0; - int emoteDisplayTime = -1; - int emoteDisplayTime2 = -1; - if (NPC.frameCounter < 10D) - npcTalkFrame = 0; - else if (NPC.frameCounter < 16D) - npcTalkFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 46D) - npcTalkFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 60D) - npcTalkFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 216D) - npcTalkFrame = 0; - else if (NPC.frameCounter == 216D && Main.netMode != NetmodeID.MultiplayerClient) - emoteDisplayTime = 70; - else if (NPC.frameCounter < 286D) - npcTalkFrame = ((NPC.frameCounter % 12D < 6D) ? (nonAttackFrames - 2) : 0); - else if (NPC.frameCounter < 320D) - npcTalkFrame = 0; - else if (NPC.frameCounter != 320D || Main.netMode == NetmodeID.MultiplayerClient) - npcTalkFrame = ((NPC.frameCounter < 420D) ? ((NPC.frameCounter % 16D < 8D) ? (nonAttackFrames - 2) : 0) : 0); - else - emoteDisplayTime = 100; - - if (NPC.frameCounter < 70D) - { - npcTalkHandFrame = 0; - } - else if (NPC.frameCounter != 70D || Main.netMode == NetmodeID.MultiplayerClient) - { - npcTalkHandFrame = ((NPC.frameCounter < 160D) ? - ((NPC.frameCounter % 16D < 8D) ? - (nonAttackFrames - 2) : 0) : ((NPC.frameCounter < 166D) ? - (nonAttackFrames - 5) : ((NPC.frameCounter < 186D) ? - (nonAttackFrames - 4) : ((NPC.frameCounter < 200D) ? - (nonAttackFrames - 5) : ((!(NPC.frameCounter < 320D)) ? - ((NPC.frameCounter < 326D) ? - (nonAttackFrames - 1) : 0) : 0))))); - } - else - emoteDisplayTime2 = 90; - - if (displayEmote) - { - NPC nPC = Main.npc[(int)NPC.ai[2]]; - if (emoteDisplayTime != -1) - EmoteBubble.NewBubbleNPC(new WorldUIAnchor(NPC), emoteDisplayTime, new WorldUIAnchor(nPC)); - - if (emoteDisplayTime2 != -1 && nPC.CanTalk) - EmoteBubble.NewBubbleNPC(new WorldUIAnchor(nPC), emoteDisplayTime2, new WorldUIAnchor(NPC)); - } - - NPC.frame.Y = frameHeight * (displayEmote ? npcTalkFrame : npcTalkHandFrame); - if (NPC.frameCounter >= 420D) - NPC.frameCounter = 0D; - } - else if (NPC.CanTalk && (NPC.ai[0] == 16f || NPC.ai[0] == 17f)) // Rock Paper Scissors - { - NPC.frameCounter += 1D; - int rpsFrameHeight = NPC.frame.Y / frameHeight; - int currentFrame = nonAttackFrames - rpsFrameHeight; - if ((uint)(currentFrame - 1) > 1u && (uint)(currentFrame - 4) > 1u && rpsFrameHeight != 0) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - - bool controlsRPS = NPC.ai[0] == 16f; - int rpsFrame = 0; - int emoteDisplayTime = -1; - if (NPC.frameCounter < 10D) - rpsFrame = 0; - else if (NPC.frameCounter < 16D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 22D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 28D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 34D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 40D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter == 40D && Main.netMode != NetmodeID.MultiplayerClient) - emoteDisplayTime = 45; - else if (NPC.frameCounter < 70D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 76D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 82D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 88D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 94D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 100D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter == 100D && Main.netMode != NetmodeID.MultiplayerClient) - emoteDisplayTime = 45; - else if (NPC.frameCounter < 130D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 136D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 142D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 148D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter < 154D) - rpsFrame = nonAttackFrames - 4; - else if (NPC.frameCounter < 160D) - rpsFrame = nonAttackFrames - 5; - else if (NPC.frameCounter != 160D || Main.netMode == NetmodeID.MultiplayerClient) - rpsFrame = ((NPC.frameCounter < 220D) ? (nonAttackFrames - 4) : ((NPC.frameCounter < 226D) ? (nonAttackFrames - 5) : 0)); - else - emoteDisplayTime = 75; - - if (controlsRPS && emoteDisplayTime != -1) - { - int npcPick = (int)NPC.localAI[2]; - int npcWins = (int)NPC.localAI[3]; - int opponentWins = (int)Main.npc[(int)NPC.ai[2]].localAI[3]; - int opponentPick = (int)Main.npc[(int)NPC.ai[2]].localAI[2]; - int rpsGameEnder = 3 - npcPick - npcWins; - int numGamesPlayed = 0; - if (NPC.frameCounter == 40D) - numGamesPlayed = 1; - - if (NPC.frameCounter == 100D) - numGamesPlayed = 2; - - if (NPC.frameCounter == 160D) - numGamesPlayed = 3; - - int gameCountdown = 3 - numGamesPlayed; - int rockPaperScissorsResultType = -1; - int gameFrameTimer = 0; - while (rockPaperScissorsResultType < 0) - { - currentFrame = gameFrameTimer + 1; - gameFrameTimer = currentFrame; - if (currentFrame >= 100) - break; - - rockPaperScissorsResultType = Main.rand.Next(2); - if (rockPaperScissorsResultType == 0 && opponentPick >= npcWins) - rockPaperScissorsResultType = -1; - - if (rockPaperScissorsResultType == 1 && opponentWins >= npcPick) - rockPaperScissorsResultType = -1; - - if (rockPaperScissorsResultType == -1 && gameCountdown <= rpsGameEnder) - rockPaperScissorsResultType = 2; - } - - if (rockPaperScissorsResultType == 0) - { - Main.npc[(int)NPC.ai[2]].localAI[3] += 1f; - opponentWins++; - } - - if (rockPaperScissorsResultType == 1) - { - Main.npc[(int)NPC.ai[2]].localAI[2] += 1f; - opponentPick++; - } - - int emoteType = Utils.SelectRandom(Main.rand, EmoteID.RPSPaper, EmoteID.RPSRock, EmoteID.RPSScissors); - int emoteType2 = emoteType; - switch (rockPaperScissorsResultType) - { - case 0: - switch (emoteType) - { - case EmoteID.RPSPaper: - emoteType2 = EmoteID.RPSRock; - break; - case EmoteID.RPSRock: - emoteType2 = EmoteID.RPSScissors; - break; - case EmoteID.RPSScissors: - emoteType2 = EmoteID.RPSPaper; - break; - } - break; - case 1: - switch (emoteType) - { - case EmoteID.RPSPaper: - emoteType2 = EmoteID.RPSScissors; - break; - case EmoteID.RPSRock: - emoteType2 = EmoteID.RPSPaper; - break; - case EmoteID.RPSScissors: - emoteType2 = EmoteID.RPSRock; - break; - } - break; - } - - if (gameCountdown == 0) - { - if (opponentWins >= 2) - emoteType -= 3; - - if (opponentPick >= 2) - emoteType2 -= 3; - } - - EmoteBubble.NewBubble(emoteType, new WorldUIAnchor(NPC), emoteDisplayTime); - EmoteBubble.NewBubble(emoteType2, new WorldUIAnchor(Main.npc[(int)NPC.ai[2]]), emoteDisplayTime); - } - - NPC.frame.Y = frameHeight * (controlsRPS ? rpsFrame : rpsFrame); - if (NPC.frameCounter >= 420D) - NPC.frameCounter = 0D; - } - else if (NPC.velocity.X == 0f) - { - NPC.frame.Y = 0; - NPC.frameCounter = 0D; - } - else // Walking - { - NPC.frameCounter += Math.Abs(NPC.velocity.X) * 2f; - NPC.frameCounter += 1D; - - int walkFrameHeightLimit = frameHeight * 2; - if (NPC.frame.Y < walkFrameHeightLimit) - NPC.frame.Y = walkFrameHeightLimit; - - int walkFrameTimer = 6; - if (NPC.frameCounter > (double)walkFrameTimer) - { - NPC.frame.Y += frameHeight; - NPC.frameCounter = 0D; - } - - if (NPC.frame.Y / frameHeight >= Main.npcFrameCount[Type] - extraFrameAmt) - NPC.frame.Y = walkFrameHeightLimit; - } - - return; - } - - NPC.frameCounter = 0D; - NPC.frame.Y = frameHeight; - } - - public override void AI() - { - if (!CalamityWorld.spawnedCirrus) - CalamityWorld.spawnedCirrus = true; - } - - // I'm not sure what to do here, because she's always called Cirrus. - Fabsol - /*public override void ModifyTypeName(ref string typeName) - { - int wife = NPC.FindFirstNPC(NPCID.Stylist); - bool wifeIsAround = wife != -1; - bool beLessDrunk = wifeIsAround && NPC.downedMoonlord; - - if (beLessDrunk) - typeName = "Cirrus"; - }*/ - - public override bool CanTownNPCSpawn(int numTownNPCs) - { - if (NPC.AnyNPCs(ModContent.NPCType()) && Main.zenithWorld) - return false; - - if (CalamityWorld.spawnedCirrus) - return true; - - foreach (Player player in Main.ActivePlayers) - { - bool hasVodka = player.InventoryHas(ModContent.ItemType()) || player.PortableStorageHas(ModContent.ItemType()); - if (hasVodka) - return Main.hardMode; - else - return DownedBossSystem.downedCalamitasClone || NPC.downedPlantBoss; - } - return false; - } - - public override List SetNPCNameList() => new List() { this.GetLocalizedValue("Name.Cirrus") }; - - public override string GetChat() - { - Player player = Main.LocalPlayer; - if (Main.zenithWorld) - { - player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.CirrusSlap" + Main.rand.Next(1, 2 + 1)).Format(player.name)), player.statLife / 2, -player.direction, false, false, -1, false); - SoundEngine.PlaySound(CnidarianJellyfishOnTheString.SlapSound, player.Center); - } - - bool worldIsSafer = NPC.downedMoonlord; - - if (CalamityUtils.AnyBossNPCS()) - { - if (!worldIsSafer) - return this.GetLocalizedValue("Chat.BossAlive"); - else - return this.GetLocalizedValue("Chat.BossAliveAlt"); - } - - if (NPC.homeless) - return this.GetLocalizedValue("Chat.Homeless" + Main.rand.Next(1, 2 + 1)); - - int wife = NPC.FindFirstNPC(NPCID.Stylist); - bool isHappy = Main.ShopHelper.GetShoppingSettings(player, NPC).PriceAdjustment < 1D; - bool wifeIsAround = wife != -1; - bool wifeIsHappy = wifeIsAround ? Main.ShopHelper.GetShoppingSettings(player, Main.npc[wife]).PriceAdjustment < 1D : false; - bool beLessDrunk = wifeIsAround && worldIsSafer; - - if (Main.bloodMoon) - { - if (Main.rand.NextBool(4)) - { - if (!beLessDrunk) - { - player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.CirrusSlap" + Main.rand.Next(1, 2 + 1)).Format(player.name)), player.statLife / 2, -player.direction, false, false, -1, false); ; - SoundEngine.PlaySound(CnidarianJellyfishOnTheString.SlapSound, player.Center); - return this.GetLocalizedValue("Chat.BloodMoonSlap1"); - } - else - return this.GetLocalizedValue("Chat.BloodMoonSlap2"); - } - return this.GetLocalizedValue("Chat.BloodMoon" + Main.rand.Next(1, 3 + 1)); - } - - WeightedRandom dialogue = new WeightedRandom(); - - if (!beLessDrunk) - { - dialogue.Add(this.GetLocalizedValue("Chat.Normal1")); - dialogue.Add(this.GetLocalizedValue("Chat.Normal2")); - - if (Main.zenithWorld) - dialogue.Add(this.GetLocalizedValue("Chat.Normal3")); - - if (ChildSafety.Disabled) - dialogue.Add(this.GetLocalizedValue("Chat.Normal4")); - } - else - { - dialogue.Add(this.GetLocalizedValue("Chat.Normal1Alt")); - dialogue.Add(this.GetLocalizedValue("Chat.Normal2Alt")); - dialogue.Add(this.GetLocalizedValue("Chat.Normal3Alt")); - - if (ChildSafety.Disabled) - dialogue.Add(this.GetLocalization("Chat.Normal4Alt").Format(Main.npc[wife].GivenName)); - - dialogue.Add(this.GetLocalizedValue("Chat.NewOutfit")); - } - - int tavernKeep = NPC.FindFirstNPC(NPCID.DD2Bartender); - if (tavernKeep != -1) - { - dialogue.Add(this.GetLocalization("Chat.Tavernkeep1").Format(Main.npc[tavernKeep].GivenName)); - dialogue.Add(this.GetLocalization("Chat.Tavernkeep2").Format(Main.npc[tavernKeep].GivenName)); - - if (ChildSafety.Disabled) - dialogue.Add(this.GetLocalizedValue("Chat.Tavernkeep3")); - } - - int permadong = NPC.FindFirstNPC(ModContent.NPCType()); - if (permadong != -1) - dialogue.Add(this.GetLocalization("Chat.Archmage").Format(Main.npc[permadong].GivenName)); - - int witch = NPC.FindFirstNPC(ModContent.NPCType()); - if (witch != -1) - dialogue.Add(this.GetLocalization("Chat.BrimstoneWitch").Format(Main.npc[witch].GivenName)); - - if (wifeIsAround) - { - if (worldIsSafer) - { - if (wifeIsHappy && isHappy) - dialogue.Add(this.GetLocalization("Chat.Stylist1Alt").Format(Main.npc[wife].GivenName)); - - if (ChildSafety.Disabled) - { - if (!wifeIsHappy || !isHappy) - dialogue.Add(this.GetLocalization("Chat.Stylist2Alt").Format(Main.npc[wife].GivenName)); - - dialogue.Add(this.GetLocalization("Chat.Stylist3Alt").Format(Main.npc[wife].GivenName)); - } - } - else - { - dialogue.Add(this.GetLocalization("Chat.Stylist1").Format(Main.npc[wife].GivenName)); - if (ChildSafety.Disabled) - { - dialogue.Add(this.GetLocalization("Chat.Stylist2").Format(Main.npc[wife].GivenName)); - dialogue.Add(this.GetLocalization("Chat.Stylist3").Format(Main.npc[wife].GivenName)); - } - } - } - - if (Main.dayTime) - { - if (!beLessDrunk) - { - dialogue.Add(this.GetLocalizedValue("Chat.Day1")); - dialogue.Add(this.GetLocalizedValue("Chat.Day2")); - dialogue.Add(this.GetLocalizedValue("Chat.Day3")); - } - else - { - dialogue.Add(this.GetLocalizedValue("Chat.Day1Alt")); - dialogue.Add(this.GetLocalizedValue("Chat.Day2Alt")); - dialogue.Add(this.GetLocalizedValue("Chat.Day3Alt")); - } - - if (!isHappy) - { - int annoyingChild = NPC.FindFirstNPC(NPCID.Angler); - if (annoyingChild != -1) - dialogue.Add(this.GetLocalization("Chat.Day4").Format(Main.npc[annoyingChild].GivenName)); - } - else - dialogue.Add(this.GetLocalizedValue("Chat.Day4Alt")); - - if (beLessDrunk) - { - dialogue.Add(this.GetLocalization("Chat.DayStylist1").Format(Main.npc[wife].GivenName)); - dialogue.Add(this.GetLocalization("Chat.DayStylist2").Format(Main.npc[wife].GivenName)); - } - else - { - dialogue.Add(this.GetLocalizedValue("Chat.DayDrunk1")); - dialogue.Add(this.GetLocalizedValue("Chat.DayDrunk2")); - } - } - else - { - dialogue.Add(this.GetLocalizedValue("Chat.Night1")); - - if (!isHappy) - { - if (Main.zenithWorld) - dialogue.Add(this.GetLocalizedValue("Chat.Night2")); - - dialogue.Add(this.GetLocalizedValue("Chat.Night3")); - } - else - { - dialogue.Add(this.GetLocalizedValue("Chat.Night2Alt")); - dialogue.Add(this.GetLocalizedValue("Chat.Night3Alt")); - } - - dialogue.Add(this.GetLocalizedValue("Chat.Night4")); - - if (wifeIsAround) - dialogue.Add(this.GetLocalization("Chat.NightStylist").Format(Main.npc[wife].GivenName)); - } - - // She needs to be drunk to enjoy festive events, otherwise, she dislikes them. - Fabsol - if (BirthdayParty.PartyIsUp) - { - if (!beLessDrunk) - dialogue.Add(this.GetLocalizedValue("Chat.Party")); - else - dialogue.Add(this.GetLocalizedValue("Chat.PartyAlt")); - } - - // She loves her hair and freaks out if it's threatened. Also a reference to the wicked witch of the west. - Fabsol - if (AcidRainEvent.AcidRainEventIsOngoing) - dialogue.Add(this.GetLocalizedValue("Chat.AcidRain")); - - // ayy lmao meme reference (this isn't 4th-wall breaking enough to be put in GFB-only imo). - Fabsol - if (Main.invasionType == InvasionID.MartianMadness) - dialogue.Add(this.GetLocalizedValue("Chat.Martians")); - - // Reference to insane thoughts I had years ago. - Fabsol - if (DownedBossSystem.downedCryogen && ChildSafety.Disabled) - dialogue.Add(this.GetLocalizedValue("Chat.CryogenDefeated")); - - // Reference to the old Leviathan sprite. - Fabsol - if (DownedBossSystem.downedLeviathan) - dialogue.Add(this.GetLocalizedValue("Chat.LeviathanDefeated")); - - // Risque tentacle implication... - Fabsol - if (NPC.downedMoonlord && ChildSafety.Disabled) - dialogue.Add(this.GetLocalizedValue("Chat.MoonLordDefeated")); - - // Reference to some crazy shit I thought up at one point. - Fabsol - if (DownedBossSystem.downedPolterghast) - dialogue.Add(this.GetLocalizedValue("Chat.PolterghastDefeated")); - - // MGS2 meme line. - Fabsol - if (DownedBossSystem.downedDoG && Main.zenithWorld) - dialogue.Add(this.GetLocalizedValue("Chat.DoGDefeated")); - - // Cirrus doesn't like the creature. - Fabsol - if (player.Calamity().chibii) - { - if (!isHappy) - dialogue.Add(this.GetLocalizedValue("Chat.HasChibii")); - else - dialogue.Add(this.GetLocalizedValue("Chat.HasChibiiAlt")); - } - - // She likes fish people (including Amidias, but she has no comments for him yet). - Fabsol - if (player.Calamity().aquaticHeart && !player.Calamity().aquaticHeartHide && ChildSafety.Disabled && isHappy) - dialogue.Add(this.GetLocalizedValue("Chat.HasAnahitaTrans")); - - if (player.Calamity().cirrusVodka) - dialogue.Add(this.GetLocalizedValue("Chat.HasVodka")); - - // These are all a bit too risque for children to be seeing lol - Fabsol - if (player.HasItem(ModContent.ItemType()) && ChildSafety.Disabled) - { - dialogue.Add(this.GetLocalizedValue("Chat.HasAlicorn1")); - dialogue.Add(this.GetLocalizedValue("Chat.HasAlicorn2")); - dialogue.Add(this.GetLocalizedValue("Chat.HasAlicorn3")); - } - - return dialogue; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - if (Main.LocalPlayer.Calamity().trippy) - return false; - - var something = NPC.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(BirthdayParty.PartyIsUp ? AltTexture.Value : TextureAssets.Npc[Type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY) - new Vector2(0f, 6f), NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, something, 0); - return false; - } - - public string Death() - { - int deaths = Main.LocalPlayer.numberOfDeathsPVE; - - string text = this.GetLocalization("DeathCount").Format(deaths); - - if (deaths > 10000) - text += " " + this.GetLocalizedValue("Death10000"); - else if (deaths > 5000) - text += " " + this.GetLocalizedValue("Death5000"); - else if (deaths > 2500) - text += " " + this.GetLocalizedValue("Death2500"); - else if (deaths > 1000) - text += " " + this.GetLocalizedValue("Death1000"); - else if (deaths > 500) - text += " " + this.GetLocalizedValue("Death500"); - else if (deaths > 250) - text += " " + this.GetLocalizedValue("Death250"); - else if (deaths > 100) - text += " " + this.GetLocalizedValue("Death100"); - - text += "\n\n" + this.GetLocalization("DonorShoutout").Format(DonatorsNameList.GetRandomDonors()); - - return text; - } - - public override void SetChatButtons(ref string button, ref string button2) - { - button = Language.GetTextValue("LegacyInterface.28"); - button2 = this.GetLocalizedValue("DeathCountButton"); - } - - public override void OnChatButtonClicked(bool firstButton, ref string shopName) - { - if (firstButton) - { - shopName = "Shop"; - } - else - { - Main.npcChatText = Death(); - } - } - - public override void AddShops() - { - Mod musicMod = ExternalMods.musicMod; - musicMod.TryFind("Interlude1MusicBox", out ModItem interlude1Box); - musicMod.TryFind("Interlude2MusicBox", out ModItem interlude2Box); - musicMod.TryFind("Interlude3MusicBox", out ModItem interlude3Box); - musicMod.TryFind("DevourerofGodsEulogyMusicBox", out ModItem eulogyBox); - - NPCShop shop = new(Type); - shop.AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(silver: 30)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), Condition.DownedMechBossAll) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), Condition.DownedMechBossAll) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), Condition.DownedMechBossAll) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) - .AddWithCustomValue(ItemID.EmpressButterfly, Item.buyPrice(gold: 10), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), CalamityConditions.DownedAstrumAureus) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), CalamityConditions.DownedAstrumAureus, Condition.BloodMoon) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), CalamityConditions.DownedAstrumAureus, Condition.TimeNight) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) - .AddWithCustomValue(ItemID.BloodyMoscato, Item.buyPrice(gold: 1), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) - .AddWithCustomValue(ItemID.BananaDaiquiri, Item.buyPrice(silver: 75), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) - .AddWithCustomValue(ItemID.PeachSangria, Item.buyPrice(silver: 50), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) - .AddWithCustomValue(ItemID.PinaColada, Item.buyPrice(gold: 1), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(1)) - .AddWithCustomValue(interlude1Box.Type, Item.buyPrice(gold: 10), CalamityConditions.DownedCalamitasClone) - .AddWithCustomValue(interlude2Box.Type, Item.buyPrice(gold: 10), Condition.DownedMoonLord) - .AddWithCustomValue(interlude3Box.Type, Item.buyPrice(gold: 10), CalamityConditions.DownedYharon) - .AddWithCustomValue(eulogyBox.Type, Item.buyPrice(gold: 10), CalamityConditions.DownedDevourerOfGods) - .AddWithCustomValue(ItemID.UnicornHorn, Item.buyPrice(0, 2, 50), Condition.HappyEnoughToSellPylons, Condition.InHallow) - .AddWithCustomValue(ItemID.Milkshake, Item.buyPrice(gold: 5), Condition.HappyEnoughToSellPylons, Condition.InHallow, Condition.NpcIsPresent(NPCID.Stylist)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 25), Condition.HappyEnoughToSellPylons, Condition.NpcIsPresent(NPCID.Stylist), Condition.NpcIsPresent(NPCID.BestiaryGirl)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 5), Condition.NpcIsPresent(NPCID.Painter)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 5), Condition.NpcIsPresent(NPCID.Painter)) - .Register(); - } - - // Make this Town NPC teleport to the Queen statue when triggered. - public override bool CanGoToStatue(bool toKingStatue) => !toKingStatue; - - public override void TownNPCAttackStrength(ref int damage, ref float knockback) - { - damage = 60; - knockback = 2f; - } - - public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) - { - cooldown = 60; - randExtraCooldown = 15; - } - - public override void TownNPCAttackProj(ref int projType, ref int attackDelay) - { - projType = ModContent.ProjectileType(); - attackDelay = 1; - } - - public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) - { - multiplier = 11.5f; - } - } -} diff --git a/NPCs/TownNPCs/Cirrus.png b/NPCs/TownNPCs/Cirrus.png deleted file mode 100644 index adf1db2d15..0000000000 Binary files a/NPCs/TownNPCs/Cirrus.png and /dev/null differ diff --git a/NPCs/TownNPCs/CirrusAlt.png b/NPCs/TownNPCs/CirrusAlt.png deleted file mode 100644 index 45895728f7..0000000000 Binary files a/NPCs/TownNPCs/CirrusAlt.png and /dev/null differ diff --git a/NPCs/TownNPCs/CirrusShimmered_Head.png b/NPCs/TownNPCs/CirrusShimmered_Head.png deleted file mode 100644 index 2de143f847..0000000000 Binary files a/NPCs/TownNPCs/CirrusShimmered_Head.png and /dev/null differ diff --git a/NPCs/TownNPCs/Cirrus_Head.png b/NPCs/TownNPCs/Cirrus_Head.png deleted file mode 100644 index d4b8a7cb82..0000000000 Binary files a/NPCs/TownNPCs/Cirrus_Head.png and /dev/null differ diff --git a/NPCs/TownNPCs/Cirrus_Shimmered.png b/NPCs/TownNPCs/Cirrus_Shimmered.png deleted file mode 100644 index 14c9b9f3a0..0000000000 Binary files a/NPCs/TownNPCs/Cirrus_Shimmered.png and /dev/null differ diff --git a/NPCs/TownNPCs/SeaKing.cs b/NPCs/TownNPCs/SeaKing.cs index 9e2c6cd3e8..50e6f0469b 100644 --- a/NPCs/TownNPCs/SeaKing.cs +++ b/NPCs/TownNPCs/SeaKing.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Items.Pets; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; @@ -9,7 +8,6 @@ using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Rogue; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Bestiary; using Terraria.GameContent.Personalities; using Terraria.ID; @@ -61,6 +59,10 @@ namespace CalamityMod.NPCs.TownNPCs NPC.DeathSound = SoundID.NPCDeath1; NPC.knockBackResist = 0.65f; AnimationType = NPCID.Guide; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToWater = false; } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -103,21 +105,16 @@ namespace CalamityMod.NPCs.TownNPCs dialogue.Add(this.GetLocalizedValue("Chat.Night3")); } - int lilBitch = NPC.FindFirstNPC(NPCID.Angler); - if (lilBitch != -1) + int angler = NPC.FindFirstNPC(NPCID.Angler); + if (angler != -1) { - dialogue.Add(this.GetLocalization("Chat.Angler1").Format(Main.npc[lilBitch].GivenName)); - dialogue.Add(this.GetLocalization("Chat.Angler2").Format(Main.npc[lilBitch].GivenName)); + dialogue.Add(this.GetLocalization("Chat.Angler").Format(Main.npc[angler].GivenName)); } int witch = NPC.FindFirstNPC(ModContent.NPCType()); if (witch != -1) dialogue.Add(this.GetLocalizedValue("Chat.BrimstoneWitch")); - int cirrus = NPC.FindFirstNPC(ModContent.NPCType()); - if (cirrus != -1) - dialogue.Add(this.GetLocalization("Chat.DrunkPrincess").Format(Main.npc[cirrus].GivenName)); - int partyGirl = NPC.FindFirstNPC(NPCID.PartyGirl); if (partyGirl != -1) dialogue.Add(this.GetLocalization("Chat.PartyGirl").Format(Main.npc[partyGirl].GivenName)); @@ -199,20 +196,16 @@ namespace CalamityMod.NPCs.TownNPCs } public override void AddShops() { - Condition downedOldDuke = CalamityConditions.DownedOldDuke; - NPCShop shop = new(Type); - shop.Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .Add(ModContent.ItemType()) - .AddWithCustomValue(ItemID.TruffleWorm, Item.buyPrice(gold: 20), Condition.Hardmode) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 40), downedOldDuke) - .AddWithCustomValue(ItemID.ShrimpPoBoy, Item.buyPrice(gold: 2, silver: 50), Condition.HappyEnoughToSellPylons, Condition.InBeach) - .AddWithCustomValue(ItemID.Fries, Item.buyPrice(gold: 2), Condition.HappyEnoughToSellPylons, Condition.InBeach, Condition.DownedEyeOfCthulhu) + shop.Add() + .Add() + .Add() + .Add() + .Add() + .Add() + .Add() + .AddWithCustomValue(ItemID.TruffleWorm, Item.buyPrice(gold: 25), Condition.Hardmode) + .AddWithCustomValue(Item.buyPrice(platinum: 1), CalamityConditions.DownedOldDuke) .Register(); } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainIllusion.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainIllusion.cs new file mode 100644 index 0000000000..e92335cefe --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainIllusion.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; + +[AutoloadBossHead] +public class BrainIllusion : ModNPC, ILocalizedModType +{ + public new string LocalizationCategory => "NPCs"; + public override string Texture => "Terraria/Images/NPC_266"; + public override string BossHeadTexture => "Terraria/Images/NPC_Head_Boss_23"; + + ref float Time => ref NPC.ai[0]; + + ref float AttackValue => ref NPC.ai[1]; + + ref float Angle => ref NPC.ai[2]; + + ref float TeleportDuration => ref NPC.localAI[0]; + + ref float TeleportTime => ref NPC.ai[3]; + + private Vector2 OldPos = Vector2.zeroVector; + + public override void SetStaticDefaults() + { + this.HideFromBestiary(); + Main.npcFrameCount[Type] = 8; + } + + public override void SetDefaults() + { + NPC.width = 160; + NPC.height = 110; + NPC.damage = 20; + NPC.lifeMax = 1; + NPC.knockBackResist = 0f; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.boss = true; + NPC.dontTakeDamage = true; + NPC.chaseable = false; + NPC.npcSlots = 0f; + NPC.netAlways = true; + Music = MusicID.Boss3; + SceneEffectPriority = (SceneEffectPriority)(-1); + } + + public override void OnSpawn(IEntitySource source) + { + TeleportDuration = AttackValue; + AttackValue = 0; + TeleportTime = Time; + NPC.netUpdate = true; + } + + public override void AI() + { + if (NPC.crimsonBoss == -1) + { + NPC.active = false; + return; + } + NPC brain = Main.npc[NPC.crimsonBoss]; + + if (brain.AIOverride().AIState == BrainOfCthulhuAI.BrainAIState.DeathAnimation) + { + NPC.damage = 0; + NPC.Opacity -= 0.1f; + if (NPC.Opacity <= 0) + NPC.active = false; + } + + Player target = Main.player[NPC.target]; + NPC.GivenName = brain.GivenOrTypeName + $": {brain.life}/{brain.lifeMax}"; + + #region Attack Start + if (Time < 30) + { + TeleportDuration = 30; + + if (Time == (TeleportDuration / 2f) && AttackValue == 0) + { + AttackValue = 1; + } + else + { + TeleportTime--; + } + + NPC.Opacity = 1 - (TeleportTime / (TeleportDuration / 2f)); + } + #endregion + else + { + if (Time == 30) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + OldPos = NPC.Center; + TeleportTime = 0; + AttackValue = 0; + NPC.netUpdate = true; + } + NPC.Opacity = 1f; + } + if (Time < 60) + { + float lerp = (Time - 30) / 30f; + float circleDist = MathHelper.Lerp(BrainOfCthulhuAI.IllusionDashTeleportDistance, BrainOfCthulhuAI.IllusionDashCloseInDistance, CalamityUtils.SineInOutEasing(lerp, 1)); + NPC.Center = Vector2.Lerp(OldPos, target.Center + (Angle.ToRotationVector2() * circleDist), lerp); + Angle += MathHelper.Lerp(0f, BrainOfCthulhuAI.IllusionDashStartingSpinSpeed, CalamityUtils.SineInEasing(lerp, 1)); + } + else if (Time <= 60f + BrainOfCthulhuAI.IllusionDashSpinDuration) + { + NPC.Center = target.Center + Angle.ToRotationVector2() * BrainOfCthulhuAI.IllusionDashCloseInDistance; + + Angle += MathHelper.Lerp(BrainOfCthulhuAI.IllusionDashStartingSpinSpeed, 0f, CalamityUtils.SineOutEasing((Time - 60) / (float)BrainOfCthulhuAI.IllusionDashSpinDuration, 1)); + } + else if (Time <= 90 + BrainOfCthulhuAI.IllusionDashSpinDuration) + { + float reelBackSpeedExponent = 2.6f; + float reelBackCompletion = Utils.GetLerpValue(0f, 30, Time - (60 + BrainOfCthulhuAI.IllusionDashSpinDuration), true); + float reelBackSpeed = MathHelper.Lerp(4f, 20f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent)); + Vector2 reelBackVelocity = (Angle + MathHelper.Pi).ToRotationVector2() * -reelBackSpeed; + NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f); + } + else if (Time == 91 + BrainOfCthulhuAI.IllusionDashSpinDuration) + NPC.velocity = (Angle + MathHelper.Pi).ToRotationVector2() * BrainOfCthulhuAI.IllusionDashVelocity; + else if (Time <= 91 + BrainOfCthulhuAI.IllusionDashSpinDuration + BrainOfCthulhuAI.IllusionDashTeleportDuration) + { + NPC.Opacity = MathHelper.Lerp(1f, 0.25f, CalamityUtils.SineInEasing((Time - (91 + BrainOfCthulhuAI.IllusionDashSpinDuration)) / (float)BrainOfCthulhuAI.IllusionDashTeleportDuration, 1)); + if (NPC.Opacity < 0.666f) + NPC.damage = 0; + } + else + NPC.active = false; + } + + Time++; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WritePackedWorldPosition(OldPos); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + OldPos = reader.ReadPackedWorldPosition(); + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += 1.0; + if (NPC.frameCounter > 6.0) + { + NPC.frameCounter = 0.0; + NPC.frame.Y += frameHeight; + } + + if (NPC.frame.Y < frameHeight * 4) + { + NPC.frame.Y = frameHeight * 4; + } + if (NPC.frame.Y > frameHeight * 7) + { + NPC.frame.Y = frameHeight * 4; + } + } + + public override bool? CanBeHitByItem(Player player, Item item) => false; + public override bool? CanBeHitByProjectile(Projectile projectile) => false; + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => target.whoAmI == NPC.target; + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Vector2 drawPos = NPC.Center + (Vector2.UnitY * 16) - Main.screenPosition; + Vector2 scale = Vector2.One; + float opacityMult = Main.LocalPlayer.whoAmI == NPC.target ? 1f : 0.25f; + + if (TeleportTime != 0) + { + //Color glowColor = Color.White * (teleportCounter / 30f); + scale = Vector2.Lerp(Vector2.One, new Vector2(0.5f + ((float)Math.Cos(Time / (TeleportDuration / 2f) * MathHelper.TwoPi) / 2f + 0.5f), 0.5f + ((float)Math.Sin(Time / (TeleportDuration / 2f) * MathHelper.TwoPi) / 2f + 0.5f)), CalamityUtils.SineInOutEasing(TeleportTime / (TeleportDuration / 2f), 1)); + + spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, drawPos, NPC.frame, Lighting.GetColor(NPC.Center.ToTileCoordinates()) * NPC.Opacity * opacityMult, NPC.rotation, NPC.frame.Size() * 0.5f, scale * NPC.scale, 0, 0); + //spriteBatch.Draw(GetBrainGlow(), drawPos, npc.frame, glowColor, npc.rotation, npc.frame.Size() * 0.5f, scale, 0, 0); + } + else + spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, drawPos, NPC.frame, Lighting.GetColor(NPC.Center.ToTileCoordinates()) * NPC.Opacity * opacityMult, NPC.rotation, NPC.frame.Size() * 0.5f, scale * NPC.scale, 0, 0); + return false; + } +} diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuAI.cs new file mode 100644 index 0000000000..36fcc3398c --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuAI.cs @@ -0,0 +1,3209 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.DataStructures; +using CalamityMod.Enums; +using CalamityMod.Events; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss.BrainOfCthulhu; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.World; +using Microsoft.CodeAnalysis; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics.PackedVector; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.Chat; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; + +public class BrainOfCthulhuAI : VanillaAIOverride +{ + private static SoundStyle StunnedHit = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit", 3); + private static SoundStyle ShieldDown = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Down") with { PauseBehavior = PauseBehavior.PauseWithGame }; + private static SoundStyle ShieldUp = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Up") with { PauseBehavior = PauseBehavior.PauseWithGame }; + private static SoundStyle IntroRoar = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Roar") with { PauseBehavior = PauseBehavior.PauseWithGame }; + private static SoundStyle Roar = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Short_Roar") with { PauseBehavior = PauseBehavior.PauseWithGame}; + public static SoundStyle Laugh = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Laugh") with { PauseBehavior = PauseBehavior.PauseWithGame }; + private static SoundStyle Growl = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl", 2) with { PauseBehavior = PauseBehavior.PauseWithGame }; + private static SoundStyle Death = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Death_Roar") with { PauseBehavior = PauseBehavior.PauseWithGame }; + private static SoundStyle BloodShot = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodShot"); + private static SoundStyle BloodExplosion = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion", 2); + + + internal static bool SummonedViaItem = false; + internal List BoCAfterImages = []; + internal float ShieldOpacity = 1f; + internal float ShieldScale = 1f; + private Vector2 BoCDrawOffset = Vector2.Zero; + private Rectangle BoCFrame = new(0, 0, 198, 180); + + #region Balancing Values + + internal static int BrainIllusionDamage => 15; + + #region Projectile Damage Values + internal static int BloodShotDamage => 12; // 48 + internal static int BloodScytheDamage => 12; // 48 + internal static int IchorShotDamage => 12; // 48 + internal static int CrimsonEyeDamage => 12; // 48 + #endregion + + internal static float Phase1DefenseMultiplier => 1.5f; //Multiplies BoC's default defense value by this amount when in Phase 1. + + #region Health Gates + internal static float DesperateOnslaughtCreeperHealthGate => 0.1f; //When the cumulative health % of all creepers falls below this value, BoC will begin its pre-stun attack upon entering its idle phase. + internal static float Phase2HealthGate => 0.5f; //When BoC's health % falls below this value, it will begin entering Phase 2 + #endregion + + internal static float DespawnRangeSQ => 36000000f; + internal static float DespawnRange => 6000f; + + #region Phase 1 Attack Values + + #region Idle Period + internal static int IdlePeriodDuration => 180; + internal static int CreeperChargeDelayMin => 70; + internal static int CreeperChargeDelayMax => 100; + internal static int CreeperChargePositioningTime => 60; + internal static int CreeperChargeWindUpTime => 22; + #endregion + + internal static int StunDuration => 480; + + #region Creeper Swipes + internal static int SwipesStartupDuration => 120; + internal int SwipeDuration => 60 + SwipeDelay; + internal int SwipeDelay => AttackFlag ? 30 : CalamityWorld.death ? 40 : 50; + internal static int SwipeAmount => 4; + internal int SwipeIchorDelay => 30 + SwipeDelay; + #endregion + + #region Creeper Crush + internal static int LightSwipeDelay => 60; + internal static int LightSwipeAmount => CalamityWorld.death ? 8 : 6; + internal static int LightSwipeTravelTime => 30; + internal static int LightSwipeAttackDelay => 10; + internal static int LightSwipeDuration => CalamityWorld.death ? 45 : 60; + internal static int StrongSwipeDelay => 90; + internal static int StrongSwipeAmount => CalamityWorld.death ? 7 : 5; + internal static int StrongSwipeTravelTime => 45; + internal static int StrongSwipeAttackDelay => 15; + internal static int StrongSwipeDuration => CalamityWorld.death ? 60 : 80; + #endregion + + #region Creeper Orbit + internal static int OrbitSetupDuration => 60; + internal static int OrbitDuration => 720; + internal static int OrbitAttackInterval => 120; + internal static int OrbitAttackParticipantCount => CalamityWorld.death ? 4 : 3; + internal static float OrbitStandardRadius => 320f; + internal static float OrbitTelegraphRadius => 480f; + internal static float BaseRotationSpeed => 0.0175f; + #endregion + + #region Creeper Spiral + internal static int SpiralDuration => 720; + internal static int SpiralSetupTime => 90; + internal static int TendrilCount => 3; + internal static float TendrilLength => 512; + internal static float TendrilStartDistance => 64; + internal static float MaxCreeperSway => 64; + internal static int StartingTimePerRevolutionMax => CalamityWorld.death ? 270 : 300; + internal static int StartingTimePerRevolutionMin => CalamityWorld.death ? 180 : 210; + internal static int EndingTimePerRevolutionMax => CalamityWorld.death ? 210 : 240; + internal static int EndingTimePerRevolutionMin => CalamityWorld.death ? 120 : 150; + internal static int SpeedUpDelayTime => 120; + internal static int SpeedUpExtensionTime => 120; + internal static float TurnAroundRatio => 0.6f; //In the second creeper phase, the creeper spiral will turn around at this completion percentage of the attack; + internal static float TurnAroundDurationRatio => CalamityWorld.death ? 0.1f : 0.125f; //The amount of time that it'll take for the creeper spiral to turn around + + #endregion + + #endregion + + #region Phase 2 Attack Values + + internal static float DefaultTeleportDistance => 360f; + + #region Idle Period + internal static int ChaseTime => 160; + internal static int MaxChases => 3; + internal static int IdleTeleportDuration => CalamityWorld.death ? 36 : 44; + internal static float ChaseMinSpeed => 3; + internal static float ChaseMaxSpeed => CalamityWorld.death ? 18 : 15; + + + #endregion + + #region Bloodletting + internal static int BloodlettingDuration => 765; + internal static Vector2 HoverDistance => new (420f, 270f); + internal static float HoverEndHeight => 300f; + internal static int IchorRate => CalamityWorld.death ? 9 : 10; + internal static float IchorSpread => 1.5f; + internal static float IchorVelocity => 3f; + internal static int BloodshotRate => 90; + internal static float BloodshotVelocity => 10f; + internal static int DashPrepTime => 90; + internal static int DashReelbackTime => 20; + internal static int DashDuration => 30; + internal static float DashVelocity => 32f; + internal static int DashScytheRate => CalamityWorld.death ? 5 : 6; + #endregion + + #region Sanguine Scythes + internal static int SanguineTeleportCount => 5; + internal static int SanguineScytheCount => CalamityWorld.death ? 12 : 10; + internal static int SanguineTeleportDuration => 30; + internal static float SanguineTeleportDistance => 440f; + internal static Vector2 SanguineFinalTeleportOffset => new(720, 300); + internal static int SanguineAttackEndDelay => 30; + internal static int SanguineAttackEndDuration => 100; + internal static int SanguineAttackEndIchorRate => 10; + + #endregion + + #region Crimson Eyes + internal static int CrimsonEyeAttackIdleDuration => 210; + internal static int CrimsonEyeAttackSetUpDuration => 30; + internal static int CrimsonEyeAttackBuildUpDuration => 120; + + internal static int CrimsonEyeRate => 60; + internal static int CrimsonEyeCap => 40; + + internal static int CrimsonEyeAttackDuration => 960; + internal static int CrimsonEyeAttackEndDuration => 210; + internal static float TurnAccelerationMultiplier => 0.01f; //Base multiplier for the boss' course correction rotation + internal static float TurnAccelerationDistanceBuffer => 160f; //Determines the minimum distance it must be at before it can begin redirecting. + internal static float TurnAccelerationDistanceDivisor => 72f; //Determines how much the distance affects its turn amount. Larger number means it must get further from the player in order to correct its course + #endregion + + #region Illusion Dash + internal static float IllusionDashTeleportDistance => 300f; + internal static int IllusionDashTeleportDuration => 30; + internal static float IllusionDashCloseInDistance => 280f; + internal static float IllusionDashStartingSpinSpeed => 0.125f; + internal static int IllusionDashSpinDuration => 100; + internal static int IllusionDashFakeoutTeleportDuration => 16; + internal static float IllusionDashVelocity => 30f; + + #endregion + + #region Illusion Trick + internal static int IllusionTrickAngleGroups => CalamityWorld.death ? 8 : 6; + internal static int IllusionTrickGroupSize => CalamityWorld.death ? 5 : 4; + internal static int IllusionTrickStunDuration => 120; + internal static int IllusionTrickTimeLimit => 960; + + #endregion + + #endregion + + #endregion + + internal enum BrainAIState : byte + { + //Spawn Animation + UndergroundSpawnAnimation, + SurfaceSpawnAnimation, + //Phase 1 + Phase1Idle, + CreeperSwipes, + CreeperSwings, + CreeperOrbit, + CreeperSpiral, + TelekineticOnslaught, + Stunned, + //Phase Transition + Phase2TransitionClosed, + Phase2TransitionOpen, + //Phase 2 + Phase2Idle, + CrimsonEyes, + SanguineScythes, + Bloodletting, + IllusionDash, + IllusionTrick, + //Defeat + DeathAnimation + } + + internal BrainAIState AIState { get => (BrainAIState)NPC.ai[0]; set => NPC.ai[0] = (float)value; } + internal BrainAIState PreviousAttack = BrainAIState.Phase1Idle; + internal ref float Time => ref NPC.ai[1]; + internal ref float DespawnTime => ref NPC.ai[2]; + internal ref float CachedRatio => ref NPC.ai[3]; + internal float TeleportTime = 0; + internal float TeleportDuration = 0; + internal float SpawnTime = 0; + internal int SpawnDelay = 0; + internal bool OnSecondCreeperPhase = false; + + private bool isNegative = false; + internal int AttackSign { get => isNegative ? -1 : 1; set => isNegative = value == -1; } + internal float AttackRotation = 0; + internal float AttackTime = 0; + internal int AttackCounter = 0; + internal bool AttackFlag = false; + internal Vector2 AttackPosition = Vector2.Zero; + internal List availableAttacks = []; + internal List AttackList = []; + internal HashSet TargetsSet = []; + + private Player Target => Main.player[NPC.target]; + + private static float CreeperHPRatio { get + { + float ratio = 0f; + foreach (NPC creeper in Main.npc.Where(n => n.active && n.type == NPCID.Creeper)) + ratio += creeper.life / (float)creeper.lifeMax; + if (ratio != 0f) + ratio /= GetBrainOfCthuluCreepersCountRevDeath(); + return ratio; + } + } + + private static float CreeperAmountRatio => NPC.CountNPCS(NPCID.Creeper) / (float)GetBrainOfCthuluCreepersCountRevDeath(); + + public override bool EnableMultiplayerSmoothingAheadOfAI => true; + + public override void SetDefaults(Mod mod) + { + NPC.damage = NPC.defDamage = 36; // 64 (1.8x expert scaling) + BoCDrawOffset = Vector2.Zero; + ShieldOpacity = 1f; + ShieldScale = 1f; + BrainOfCthulhuSystem.ScreenBlurStrength = 0f; + + if (!Main.dedServ) + { + int brainOfCthuluCreepersCount = GetBrainOfCthuluCreepersCountRevDeath(); + BrainOfCthulhuSystem.VerletTendrils = new (int creeper, List tendril, int reelInTimer)[brainOfCthuluCreepersCount]; + + for (int i = 0; i < brainOfCthuluCreepersCount; i++) + { + List tendril = []; + for (int j = 0; j < 28; j++) + tendril.Add(new(NPC.Center)); + + BrainOfCthulhuSystem.VerletTendrils[i].tendril = tendril; + } + } + } + + public override void OnSpawn(Mod mod) + { + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + // Ignore tank players, target low HP players, Brain is smart + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + options.finishThemOff = true; + CalamityUtils.CalamityTargeting(NPC, options); + } + Player target = Main.player[NPC.target]; + bool onSurface = target.Center.Y / 16 < Main.worldSurface; + + NPC.Center = target.Center + Vector2.UnitY * (onSurface ? 900 : -900); + DisableMultiplayerSmoothing = true; + NPC.dontTakeDamage = true; + + AIState = onSurface ? BrainAIState.SurfaceSpawnAnimation : BrainAIState.UndergroundSpawnAnimation; + PreviousAttack = BrainAIState.Phase1Idle; + SpawnDelay = (SummonedViaItem || BossRushEvent.BossRushActive) ? 2 : 60; + if (SummonedViaItem || BossRushEvent.BossRushActive) + SpawnTime = -1; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int brainOfCthuluCreepersCount = GetBrainOfCthuluCreepersCountRevDeath(); + for (int i = 0; i < brainOfCthuluCreepersCount; i++) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.Creeper, NPC.whoAmI, i, ai2: -1); + } + + NPC.netUpdate = true; + } + + public override bool AI(Mod mod) + { + // whoAmI variable + NPC.crimsonBoss = NPC.whoAmI; + bool phase2 = AIState >= BrainAIState.Phase2TransitionClosed; + + //Takes more damage in Phase 1 to account for invulnerability phases + if (phase2) + { + NPC.knockBackResist = 0f; + NPC.defense = NPC.defDefense; + + NPC.chaseable = (AIState != BrainAIState.IllusionDash && AIState != BrainAIState.IllusionTrick); + } + else + NPC.defense = (int)(NPC.defDefense * Phase1DefenseMultiplier); + + if (AIState <= BrainAIState.SurfaceSpawnAnimation) + NPC.damage = 0; + else + NPC.damage = NPC.defDamage; + + #region Targeting + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + // Ignore tank players, target low HP players, Brain is smart + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + options.finishThemOff = true; + options.maxSearchRange = DespawnRange; + CalamityUtils.CalamityTargeting(NPC, options); + } + #endregion + + #region Despawn + // Despawn check + if (!BossRushEvent.BossRushActive) + { + bool despawn = (Target.dead || !Target.ZoneCrimson); + if (despawn) + { + var v = GetAllValidTargets(NPC.Center); + if (v.Count > 0) + { + despawn = false; + NPC.target = v[0]; + } + } + + // Despawn + if (despawn) + { + if (DespawnTime < 90) + DespawnTime += 1f; + + if (DespawnTime == 90) + NPC.velocity.Y += 0.1f; + } + else if (DespawnTime > 0f) + DespawnTime -= 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Target.DistanceSQ(NPC.Center) > DespawnRangeSQ) + { + NPC.active = false; + NPC.life = 0; + + if (Main.dedServ) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI, 0f, 0f, 0f, 0, 0, 0); + } + } + + if (DespawnTime > 60) + return false; + } + #endregion + + #region Hit Sounds + if (AIState == BrainAIState.Stunned) + NPC.HitSound = StunnedHit; + else + NPC.HitSound = SoundID.NPCHit9; + #endregion + + #region Forced State Changes + if (!phase2 && CreeperHPRatio == 0f && AIState != BrainAIState.Stunned && AIState >= BrainAIState.Phase1Idle) + { + AIState = BrainAIState.Stunned; + Time = 0; + ResetAttackValues(); + foreach(Projectile p in Main.ActiveProjectiles) + { + if (p.type != ModContent.ProjectileType()) + continue; + + p.ai[1] = 0; + } + } + + if (AIState == BrainAIState.Stunned && (NPC.life / (float)NPC.lifeMax) < Phase2HealthGate) + { + AIState = BrainAIState.Phase2TransitionClosed; + Time = 0; + TeleportTime = 0; + } + #endregion + + switch (AIState) + { + #region Spawn Animations + case BrainAIState.UndergroundSpawnAnimation: + case BrainAIState.SurfaceSpawnAnimation: + SpawnAnimation(); + break; + #endregion + + #region Phase 1 + case BrainAIState.Phase1Idle: + Phase1Idle(); + break; + case BrainAIState.TelekineticOnslaught: + TelekineticOnslaught(); + break; + case BrainAIState.Stunned: + Stunned(); + break; + case BrainAIState.CreeperSwipes: + CreeperSwipes(); + break; + case BrainAIState.CreeperSwings: + CreeperSwings(); + break; + case BrainAIState.CreeperOrbit: + CreeperOrbit(); + break; + case BrainAIState.CreeperSpiral: + CreeperSpiral(); + break; + #endregion + + #region Phase Transition + case BrainAIState.Phase2TransitionClosed: + case BrainAIState.Phase2TransitionOpen: + PhaseTransition(); + break; + #endregion + + #region Phase 2 + case BrainAIState.Phase2Idle: + Phase2Idle(); + break; + case BrainAIState.Bloodletting: + Bloodletting(); + break; + case BrainAIState.SanguineScythes: + SanguineScythes(); + break; + case BrainAIState.CrimsonEyes: + CrimsonEyes(); + break; + case BrainAIState.IllusionDash: + IllusionDash(); + break; + case BrainAIState.IllusionTrick: + IllusionTrick(); + break; + #endregion + + case BrainAIState.DeathAnimation: + DeathAnimation(); + break; + } + + #region Projectile Altering + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type != ProjectileID.BloodNautilusShot || p.ai[0] == 0) + continue; + + int startUpTime = 20; + float speedUpTime = 30; + float slowDownMult = 0.96f; + float speedUpMult = 1.025f; + if(AIState == BrainAIState.IllusionDash) + { + startUpTime = 20; + speedUpTime = 30; + slowDownMult = 0.96f; + speedUpMult = 1.025f; + } + + if (p.ai[2] <= startUpTime) + p.velocity *= slowDownMult; + else + { + p.velocity *= speedUpMult; + if (p.ai[2] <= startUpTime + speedUpTime) + { + float newAngle = p.ai[1].AngleLerp(p.ai[0] - MathHelper.TwoPi, (p.ai[2] - startUpTime) / speedUpTime); + + p.velocity = newAngle.ToRotationVector2() * p.velocity.Length(); + } + } + p.ai[2]++; + } + #endregion + + NPC.oldVelocity = NPC.velocity; + Time++; + + if(AIState != BrainAIState.DeathAnimation && NPC.lifeRegen < 0 && Math.Abs(NPC.lifeRegen) >= NPC.life) + TriggerDeathAnimation(); + + return false; + } + + #region Attacks + Animations + + private void SpawnAnimation() + { + if (SpawnTime != 0) //BoC should begin appearing + { + float d = Main.LocalPlayer.DistanceSQ(NPC.Center); + float distanceScaleFactor = 1; + if (d > 592900) //770^2 + distanceScaleFactor = 1 / (1 + (((float)Math.Sqrt(d) - 770) / 32f)); + + float spawnCounter = Time - Math.Abs(SpawnTime); + + if (spawnCounter < 180) + { + float shakeIntensity = CalamityUtils.CircOutEasing(spawnCounter / 180f, 1) * 3f * distanceScaleFactor; + Main.LocalPlayer.SetScreenshake(shakeIntensity); + for (int i = 0; i < shakeIntensity; i++) + { + Point start = Target.Center.ToTileCoordinates() + new Point(Main.rand.Next(-64, 65), 48); + for (int j = 0; j < 96; j++) + { + Point current = start - new Point(0, j); + if (!Main.tile[current].IsTileSolid() && Main.tile[current - new Point(0, 1)].TileType == TileID.Crimstone) + Dust.NewDust(current.ToWorldCoordinates(0, -16), 16, 16, DustID.Crimstone, 0, 3); + } + } + } + if (spawnCounter == 180) + NPC.velocity = Vector2.UnitY * (AIState == BrainAIState.UndergroundSpawnAnimation ? 32 : -50); + else if (spawnCounter > 180) + { + NPC.velocity *= 0.955f; + + if (spawnCounter == 240) + { + SoundEngine.PlaySound(IntroRoar, NPC.Center); + + if (Main.netMode == NetmodeID.SinglePlayer) + Main.NewText(Language.GetTextValue("Announcement.HasAwoken", NPC.TypeName), 175, 75); + else if (Main.dedServ) + ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", NPC.TypeName), new Color(175, 75, 255)); + } + + if (spawnCounter > 240 && spawnCounter < 390) + { + BrainOfCthulhuSystem.ScreenBlurStrength = 0.5f;// 0.5f; + if (spawnCounter < 250) + BrainOfCthulhuSystem.ScreenBlurStrength = MathHelper.Lerp(0, 0.5f, (spawnCounter - 240) / 10f); + + NPC.frameCounter += 1f; + + BoCDrawOffset = Main.rand.NextVector2Circular(4, 4); + + for (int i = 0; i < 3; i++) + { + Point start = Target.Center.ToTileCoordinates() + new Point(Main.rand.Next(-64, 65), 48); + for (int j = 0; j < 96; j++) + { + Point current = start - new Point(0, j); + if (!Main.tile[current].IsTileSolid() && Main.tile[current - new Point(0, 1)].TileType == TileID.Crimstone) + Dust.NewDust(current.ToWorldCoordinates(0, -16), 16, 16, DustID.Crimstone, 0, 3); + } + } + + Main.LocalPlayer.SetScreenshake(6 * BrainOfCthulhuSystem.ScreenBlurStrength * distanceScaleFactor); + + if (spawnCounter % 15 == 0) + { + BossRoar pulse = new(NPC.Center, Color.Black, Main.rand.NextFloatDirection(), 0.1f, 3f, 30); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + else if (spawnCounter >= 390 && spawnCounter <= 420) + { + BrainOfCthulhuSystem.ScreenBlurStrength = MathHelper.Lerp(0.5f, 0f, (spawnCounter - 390) / 30f); + BoCDrawOffset *= 0.75f; + } + else if (spawnCounter > 420) + { + BrainOfCthulhuSystem.ScreenBlurStrength = 0f; + BoCDrawOffset = Vector2.Zero; + AIState = BrainAIState.Phase1Idle; + ResetAttackValues(); + Time = -1; + SpawnTime = -1; + Main.musicFade[Main.curMusic] = 1f; + return; + } + } + } + if (AttackCounter < GetBrainOfCthuluCreepersCountRevDeath()) + { + if (SpawnTime == 0) + { + NPC.Center = Target.Center + Vector2.UnitY * (AIState == BrainAIState.UndergroundSpawnAnimation ? -900 : 900); + DisableMultiplayerSmoothing = true; + } + + if(SpawnDelay == 1 && Main.netMode != NetmodeID.MultiplayerClient) + { + bool targetLeft = AttackCounter % 2 == 0; + List creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.AIOverride().Time == -1 && n.AIOverride().CreeperID % 2 == (targetLeft ? 0 : 1)).ToList(); + + if (creepers.Count > 0) + { + AttackTime = creepers[Main.rand.Next(creepers.Count)].whoAmI; + } + else + { + creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.AIOverride().Time == -1).ToList(); + AttackTime = creepers.Count == 0 ? -1 : creepers[Main.rand.Next(creepers.Count)].whoAmI; + } + + NPC.netUpdate = true; + } + + if (SpawnDelay <= 0) + { + if (AttackTime != -1) + { + NPC creeper = Main.npc[(int)AttackTime]; + creeper.AIOverride().Time = 1; + creeper.netUpdate = true; + AttackCounter++; + + if (SummonedViaItem || BossRushEvent.BossRushActive) + SpawnDelay = 2; + else + SpawnDelay = AttackCounter switch + { + 1 => 90, + 2 or 3 or 4 => 24, + 5 => 60, + 6 or 7 or 8 => 24, + 9 => 60, + _ => 4, + }; + } + else + SpawnTime = Time; + } + else + SpawnDelay--; + } + else if (SpawnTime == 0) + SpawnTime = Time; + } + + #region Phase 1 + + private void Phase1Idle() + { + BrainOfCthulhuSystem.ScreenBlurStrength = 0f; + + #region Attack Selection + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (CreeperHPRatio <= DesperateOnslaughtCreeperHealthGate) + { + Time = -1; + AIState = BrainAIState.TelekineticOnslaught; + AttackSign = Main.rand.NextBool() ? -1 : 1; + NPC.netUpdate = true; + } + else if (Time > IdlePeriodDuration) + { + Time = -1; + + ResetAttackValues(); + + if (availableAttacks.Count == 0) + { + availableAttacks = [BrainAIState.CreeperSwipes, BrainAIState.CreeperSwings, BrainAIState.CreeperOrbit, BrainAIState.CreeperSpiral]; + if (PreviousAttack != BrainAIState.Phase1Idle) + availableAttacks.Remove(PreviousAttack); + } + + int pick = Main.rand.Next(availableAttacks.Count); + AIState = availableAttacks[pick]; + availableAttacks.RemoveAt(pick); + PreviousAttack = AIState; + + foreach (NPC creep in Main.npc.Where(n => n.active && n.type == NPCID.Creeper)) + creep.AIOverride().Time = -1; + + SoundEngine.PlaySound(Growl, NPC.Center); + + NPC.netUpdate = true; + } + } + #endregion + + /* + #region Creeper Attacks + if (AttackCounter > 0) + AttackCounter--; + else if (Time < IdlePeriodDuration - 120) + { + if (Time >= 30) + { + bool targetLeft = target.Center.X < NPC.Center.X; + List creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.AIOverride().Time == -1 && n.AIOverride().CreeperID % 2 == (targetLeft ? 0 : 1)).ToList(); + if (creepers.Count == 0) + creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.AIOverride().Time == -1).ToList(); + + if (creepers.Count > 0) + { + int rand = Main.rand.Next(creepers.Count); + + NPC creeper = creepers[rand]; + creeper.AIOverride().Time = 0; + } + } + AttackCounter = (int)MathHelper.Lerp(CreeperChargeDelayMax, CreeperChargeDelayMin, 1 - CreeperAmountRatio); + } + #endregion + */ + + #region Movement + if (Time == 0) + { + AttackSign = Main.rand.NextBool() ? -1 : 1; + NPC.netUpdate = true; + foreach (NPC creeper in Main.ActiveNPCs) + { + if (creeper.type != NPCID.Creeper) + continue; + creeper.netUpdate = true; + } + } + + float rotateDir = AttackSign; + Vector2 fromTarget = NPC.DirectionFrom(Target.Center); + Vector2 dir = fromTarget.RotatedBy(Math.Sin(Time / 60f) * rotateDir) * new Vector2(2, 1); + float rayDist = CalamityUtils.PreciseDistanceToTileCollisionHit(Target.Center, dir.ToRotation(), 360, 1); + Vector2 offset = dir * (rayDist - NPC.width); + Vector2 goalPos = Target.Center + offset; + float distSQ = NPC.DistanceSQ(goalPos); + if (distSQ > 129600) + { + NPC.velocity = NPC.DirectionTo(goalPos) * (4 + (NPC.Distance(goalPos) - 360) / 64f); + } + else if (distSQ <= 2048) + { + NPC.velocity *= 0.9f; + } + else if (NPC.velocity.LengthSquared() < 16f) + { + NPC.velocity += NPC.DirectionTo(goalPos).SafeNormalize(Vector2.Zero) * 0.15f; + } + else + { + NPC.velocity = NPC.DirectionTo(goalPos).SafeNormalize(Vector2.Zero) * 6f; + } + #endregion + } + + private void TelekineticOnslaught() + { + #region Movement + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.velocity = NPC.DirectionTo(Target.Center) * 4f; + Time = -1; + } + else + { + float distSQ = NPC.DistanceSQ(Target.Center); + if (distSQ > 230400) //480^2 + NPC.velocity = NPC.DirectionTo(Target.Center) * (MathF.Sqrt(distSQ) - 480) / 128f; + else + NPC.velocity *= 0.9f; + } + #endregion + + float wrappedCounter = Time % 90; + + if (Time <= 60) + { + if (Time == 0) + { + SoundEngine.PlaySound(Roar, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + foreach (NPC creeper in Main.ActiveNPCs) + { + if (creeper.type != NPCID.Creeper) + continue; + + CreeperAI ai = creeper.AIOverride(); + int dirSign = ai.evenID ? -1 : 1; + Vector2 dir = Vector2.UnitX.RotatedBy(Main.rand.NextFloat(-MathHelper.TwoPi / 3f, MathHelper.TwoPi / 3f)) * dirSign; + if (Target.Center.Y / 16 < Main.worldSurface) //Makes creepers not go as high up when on the surface + { + float dirY = dir.Y; + dir.Y -= dirY * 0.5f; + dir.X += dirY * 0.5f * Math.Sign(dir.X); + dir.SafeNormalize(Vector2.unitXVector * dirSign); + } + ai.AttackAngle = dir.ToRotation(); + float rayDist = CalamityUtils.PreciseDistanceToTileCollisionHit(NPC.Center, ai.AttackAngle, 800, 4); + ai.AttackPosition = NPC.Center + (dir * (rayDist - 64)); + creeper.netUpdate = true; + } + + NPC.netUpdate = true; + } + } + if (Time < 30) + { + BrainOfCthulhuSystem.ScreenBlurStrength = 0.5f; + + NPC.frameCounter += 1f; + + for (int i = 0; i < 3; i++) + { + Point start = Target.Center.ToTileCoordinates() + new Point(Main.rand.Next(-64, 65), 48); + for (int j = 0; j < 96; j++) + { + Point current = start - new Point(0, j); + if (!Main.tile[current].IsTileSolid() && Main.tile[current - new Point(0, 1)].TileType == TileID.Crimstone) + Dust.NewDust(current.ToWorldCoordinates(0, -16), 16, 16, DustID.Crimstone, 0, 3); + } + } + + float d = Main.LocalPlayer.DistanceSQ(NPC.Center); + float distanceScaleFactor = 1; + if (d > 592900) //770^2 + distanceScaleFactor = 1 / (1 + (((float)Math.Sqrt(d) - 770) / 32f)); + + Main.LocalPlayer.SetScreenshake(4 * BrainOfCthulhuSystem.ScreenBlurStrength * distanceScaleFactor); + + if (Time % 15 == 0) + { + BossRoar pulse = new(NPC.Center, Color.Black, Main.rand.NextFloatDirection(), 0.1f, 3f, 30); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + else + BrainOfCthulhuSystem.ScreenBlurStrength = MathHelper.Lerp(0.5f, 0, CalamityUtils.CircOutEasing((Time - 30) / 30f, 1)); + } + else + { + BrainOfCthulhuSystem.ScreenBlurStrength = 0f; + if (wrappedCounter == 65) + { + if (Main.netMode != NetmodeID.SinglePlayer) + { + SelectNewTarget(); + NPC.netUpdate = true; + } + + int checkCount = 8; + float wallDist = CalamityUtils.PreciseDistanceToTileCollisionHit(NPC.Center, AttackSign == -1 ? MathHelper.Pi : 0, 480 + NPC.width) - NPC.width; + Vector2[] starts = new Vector2[checkCount]; + for (int i = 0; i < checkCount; i++) + { + float completion = (i + 1) / (float)(checkCount + 1); + starts[i] = NPC.Center + (Vector2.UnitX * ((wallDist * completion) + NPC.width) * AttackSign); + } + + Vector2[] ends = new Vector2[checkCount]; + List goodEnds = []; + List farEnds = []; + List closeEnds = []; + + for (int i = 0; i < checkCount; i++) + { + float maxDist = 960; + float floorDist = CalamityUtils.PreciseDistanceToTileCollisionHit(NPC.Center, Vector2.UnitY.ToRotation(), maxDist); + ends[i] = starts[i] + (Vector2.UnitY * (floorDist + 48)); + if (floorDist >= 600) + farEnds.Add(ends[i]); + else if (floorDist > 240) + goodEnds.Add(ends[i]); + else + closeEnds.Add(ends[i]); + } + + Vector2 chosenEnd; + + if (goodEnds.Count > 0) + chosenEnd = goodEnds[Main.rand.Next(goodEnds.Count)]; + else if (closeEnds.Count > 0) + chosenEnd = closeEnds[Main.rand.Next(closeEnds.Count)]; + else + chosenEnd = farEnds[Main.rand.Next(farEnds.Count)]; + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromThis(), chosenEnd, Vector2.Zero, ModContent.ProjectileType(), 10, 0.5f); + + AttackSign *= -1; + } + } + } + + private void Stunned() + { + #region Movement + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 6f); + if (Time == 0) + { + NPC.velocity = (NPC.Center - Target.Center).SafeNormalize(Vector2.UnitX) * 4f; + SoundEngine.PlaySound(ShieldDown, NPC.Center); + } + + if (NPC.velocity != Vector2.Zero) + { + if (Time >= StunDuration) + NPC.velocity *= 0.8f; + else + NPC.velocity *= 0.93f; + } + + if (Time < StunDuration) + NPC.position.Y += (float)Math.Sin(Time / 8f) * 2 * (1 - MathHelper.Clamp((Time - (StunDuration - 30)) / 30f, 0f, 1f)); + + if (Time <= StunDuration - 30) + { + if (AttackTime > 0) + { + float kbCounter = 30 - AttackTime; + if (kbCounter < 10) + { + float lerp = CalamityUtils.SineOutEasing(kbCounter / 10f, 1); + NPC.rotation = AttackRotation.AngleLerp(-AttackRotation, lerp); + } + else + { + float lerp = CalamityUtils.SineInOutEasing((kbCounter - 10) / 20f, 1); + NPC.rotation = (-AttackRotation).AngleLerp(0, lerp); + } + + } + else if (Math.Abs(NPC.oldVelocity.X) < Math.Abs(NPC.velocity.X) || Time <= 0) + { + AttackRotation = NPC.rotation; + TeleportTime = 0; + } + else + { + TeleportTime++; + NPC.rotation = MathHelper.Lerp(AttackRotation, MathHelper.Pi / 24f * NPC.oldVelocity.X, CalamityUtils.CircOutEasing(MathHelper.Clamp(TeleportTime / 30f, 0f, 1f), 1)); + } + } + #endregion + + #region Tile Collision + if (Time < StunDuration) + { + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.velocity = NPC.DirectionTo(Target.Center) * 4f; + } + else if (Collision.SolidCollision(NPC.position + NPC.velocity, NPC.width, NPC.height)) + { + if (NPC.velocity.X != NPC.oldVelocity.X) + NPC.velocity.X = -NPC.oldVelocity.X; + if (NPC.velocity.Y != NPC.oldVelocity.Y) + NPC.velocity.Y = -NPC.oldVelocity.Y; + //NPC.velocity *= 2f; + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 8f); + AttackTime = 30; + AttackRotation = NPC.rotation; + } + + if (AttackTime > 0) + { + NPC.knockBackResist = 0f; + AttackTime--; + if (AttackTime == 0) + { + NPC.velocity = Vector2.Zero; + AttackRotation = 0; + } + } + else + NPC.knockBackResist = 1f; + } + #endregion + + BrainOfCthulhuSystem.ScreenBlurStrength = 0f; + + NPC.dontTakeDamage = false; + + if (Time <= 15) + { + float lerp = Time / 15f; + ShieldOpacity = 1 - CalamityUtils.CircOutEasing(lerp, 1); + ShieldScale = MathHelper.Lerp(1f, 1.5f, lerp); + } + if(Time > 15 && Time < StunDuration) + { + ShieldOpacity = 0f; + ShieldScale = 1.5f; + } + + #region Recovery + if (OnSecondCreeperPhase && Time == StunDuration - 30) + { + AIState = BrainAIState.Phase2TransitionClosed; + Time = -1; + TeleportTime = 0; + return; + } + + if (Time > StunDuration - 30) + { + NPC.rotation = NPC.rotation.AngleLerp(0f, CalamityUtils.SineInOutEasing((Time - (StunDuration - 30)) / 30f, 1)); + if (Time == StunDuration - 15) + SoundEngine.PlaySound(ShieldUp, NPC.Center); + } + + if (Time >= StunDuration) + { + if (NPC.velocity.X < 0.001f && NPC.velocity.X < 0.001f) + NPC.velocity = Vector2.Zero; + + int creeperRate = 5; + float wrappedCounter = (Time - StunDuration) % creeperRate; + int spawnTime = GetBrainOfCthuluCreepersCountRevDeath() / 2 * creeperRate; + + if (Time == StunDuration) + AttackCounter = GetBrainOfCthuluCreepersCountRevDeath() - 1; + + NPC.knockBackResist = 0f; + NPC.dontTakeDamage = true; + NPC.rotation = 0f; + + float shieldAppearTime = 15f; + + float lerp = MathHelper.Clamp((Time - StunDuration) / shieldAppearTime, 0f, 1f); + if (lerp >= 1) + { + ShieldOpacity = 1f; + ShieldScale = 1f; + } + else + { + ShieldOpacity = CalamityUtils.CircOutEasing(lerp, 1); + ShieldScale = MathHelper.Lerp(1.5f, 1f, CalamityUtils.SineOutEasing(lerp, 1)); + } + + if (AttackCounter == -1 && Time > StunDuration + spawnTime + 30) + { + OnSecondCreeperPhase = true; + AIState = BrainAIState.Phase1Idle; + Time = -1; + } + else if (AttackCounter > -1 && wrappedCounter == 0) + { + for (int i = 0; i < 2; i++) + { + Vector2 dir = Vector2.UnitY.RotatedBy((AttackCounter % 2 == 0 ? 1 : -1) * (MathHelper.Pi / 16f + ((MathHelper.Pi - MathHelper.Pi / 8f) * (AttackCounter / 2f / (GetBrainOfCthuluCreepersCountRevDeath() / 2f))))); + Vector2 spawnPos = NPC.Center + (dir * 72f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC creeper = NPC.NewNPCDirect(NPC.GetSource_FromAI(), spawnPos, NPCID.Creeper, NPC.whoAmI, AttackCounter, ai2: -1, ai3: 1); + creeper.velocity = dir * 24f; + } + + for (int j = 0; j < 3; j++) + { + BloodParticle p = new(spawnPos, dir.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(8f, 12f), 32, 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + BloodParticle2 p2 = new(spawnPos, dir * 10f, 16, 0.5f, Color.Red); + GeneralParticleHandler.SpawnParticle(p2); + + AttackCounter--; + if (AttackCounter <= -1) + return; + } + + SoundEngine.PlaySound(SoundID.NPCHit9, NPC.Center); + } + } + #endregion + } + + private void CreeperSwipes() + { + //Hand Size check to determine if 1 hand variant should be used + if (Time == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + int leftAmt = 0; + int rightAmt = 0; + foreach (NPC creeper in Main.ActiveNPCs) + { + if (creeper.type != NPCID.Creeper) + continue; + + if (creeper.AIOverride().CreeperID % 2 == 0) + leftAmt++; + else + rightAmt++; + } + + if (leftAmt > 5 && rightAmt > 5) + { + AttackSign = Main.rand.NextBool() ? -1 : 1; + AttackFlag = false; + } + else + AttackFlag = true; + + NPC.damage = 0; + + NPC.netUpdate = true; + AttackList.Clear(); + TargetsSet.Clear(); + } + + float wrappedCount = Time % (SwipeDuration + SwipeDelay); + + if (Time >= SwipesStartupDuration) + { + NPC.damage = NPC.defDamage; + if (wrappedCount == 0) + { + bool useEven = Main.rand.NextBool(); + + bool anyActivated = false; + + foreach (NPC Npc in Main.ActiveNPCs) + { + if (Npc.type != NPCID.Creeper) + continue; + + if (AttackFlag || Npc.AIOverride().CreeperID % 2 == 0! ^ useEven) + { + AttackList.Add((byte)Npc.whoAmI); + //Npc.AIOverride().Time = 0; + anyActivated = true; + } + } + + if (!anyActivated) + foreach (NPC Npc in Main.ActiveNPCs) + { + if (Npc.type != NPCID.Creeper) + continue; + + AttackList.Add((byte)Npc.whoAmI); + //Npc.AIOverride().Time = 0; + } + + if (Main.netMode != NetmodeID.SinglePlayer) + SelectNewTarget(); + + NPC.netUpdate = true; + } + else if (wrappedCount == SwipeDuration && Main.netMode != NetmodeID.MultiplayerClient) + { + AttackSign *= -1; + AttackList.Clear(); + NPC.netUpdate = true; + } + + if (wrappedCount > 1 && wrappedCount <= SwipeIchorDelay && Time % 3 == 0) // Telegraphs ichor rain w/ dripping particles + { + Vector2 spawnPosition = NPC.Center; + spawnPosition.Y += Main.rand.NextFloat(38, 50); + spawnPosition.X += Main.rand.NextFloat(-56, 56); + + BloodParticle blood = new BloodParticle(spawnPosition, Main.rand.NextVector2Unit() * Main.rand.NextFloat(1.5f, 2.5f), Main.rand.Next(30, 40), Main.rand.NextFloat(0.6f, 1f), Color.Gold); + GeneralParticleHandler.SpawnParticle(blood); + } + + if (wrappedCount < 60f) // Vibrates during telegraph + { + Vector2 vibrationVector = Main.rand.NextVector2CircularEdge(1, 1) * MathHelper.Lerp(0f, 12f, CalamityUtils.CircInEasing(wrappedCount / 80f, 1)); + + BoCDrawOffset = vibrationVector; + } + else if (wrappedCount > 60f && wrappedCount < 80f) // Droops down when starting to fire ichor shots + { + float progress = (wrappedCount - 60f) / 20f; + BoCDrawOffset = new Vector2(0, MathHelper.Lerp(10, 0, 1f - (float)Math.Pow(1f - progress, 3f))); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + if (wrappedCount > SwipeIchorDelay && wrappedCount <= SwipeDuration && Time % 2 == 0) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + new Vector2(Main.rand.NextFloat(-72, 72), 56), Vector2.UnitY.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 4f, MathHelper.Pi / 4f)) * 4f, ProjectileID.GoldenShowerHostile, IchorShotDamage, 0.5f); + + if (Time >= SwipesStartupDuration + ((SwipeDuration + SwipeDelay) * SwipeAmount) && Main.netMode != NetmodeID.MultiplayerClient) + { + Time = 0; + AIState = BrainAIState.Phase1Idle; + NPC.netUpdate = true; + NPC.damage = NPC.defDamage; + AttackList.Clear(); + } + } + else + NPC.damage = 0; + + #region Movement + + Vector2 goalPos = Target.Center + (Vector2.UnitY * -270); + float distSQ = NPC.DistanceSQ(goalPos); + if ((Time > SwipesStartupDuration && wrappedCount > 30 && wrappedCount <= SwipeDuration) || NPC.DistanceSQ(goalPos) <= 2048) + NPC.velocity *= 0.9f; + else if (distSQ > 14400) + NPC.velocity = NPC.DirectionTo(goalPos) * (8 + (NPC.Distance(goalPos) - 120) / 16f); + else + NPC.velocity = NPC.DirectionTo(goalPos).SafeNormalize(Vector2.UnitX * -Target.direction) * (8f * distSQ / 14400f); + #endregion + } + + private void CreeperSwings() + { + NPC.damage = 0; + + #region Movement + Vector2 fromTarget; + if (Main.netMode == NetmodeID.SinglePlayer) + fromTarget = NPC.Center - Target.Center; + else + { + Vector2 averagePlayerPos = Vector2.zeroVector; + List targets = GetAllValidTargets(NPC.Center); + foreach (var p in targets) + averagePlayerPos += Main.player[p].Center; + averagePlayerPos /= targets.Count; + + fromTarget = NPC.Center - averagePlayerPos; + } + + Vector2 goalDir; + if (Math.Abs(fromTarget.X) > Math.Abs(fromTarget.Y)) + goalDir = Vector2.UnitX * Math.Sign(fromTarget.X); + else + goalDir = Vector2.UnitY * Math.Sign(fromTarget.Y); + + Vector2 goalPos = Target.Center + (goalDir * 360) - (Vector2.UnitY * 32); + if (NPC.DistanceSQ(goalPos) <= 2048) + NPC.velocity *= 0.9f; + else if (NPC.velocity.LengthSquared() <= 56.25f) //7.5^2 + NPC.velocity += NPC.DirectionTo(goalPos).SafeNormalize(Vector2.UnitX * -Target.direction) * 0.5f; + else + NPC.velocity = NPC.DirectionTo(goalPos).SafeNormalize(Vector2.UnitX * -Target.direction) * 8f; + #endregion + + float delay = OnSecondCreeperPhase ? StrongSwipeDelay : LightSwipeDelay; + if (Time == 0) + AttackList.Clear(); + + if (Time > delay) + { + foreach (NPC creeper in Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.AIOverride().Time == -1 && !AttackList.Contains((byte)n.whoAmI))) + creeper.position += NPC.velocity; + + int crushCount; + int attackDelay; + if (!OnSecondCreeperPhase) + { + crushCount = LightSwipeAmount; + attackDelay = LightSwipeDuration; + } + else + { + crushCount = StrongSwipeAmount; + attackDelay = StrongSwipeDuration; + } + int attackDur = attackDelay * crushCount; + + if (Time < delay + attackDur && Time % attackDelay == 0) + { + List creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.AIOverride().Time == -1 && !AttackList.Contains((byte)n.whoAmI)).ToList(); + if (creepers.Count > 1 && Main.netMode != NetmodeID.MultiplayerClient) + { + float rotation; + if (!OnSecondCreeperPhase) + { + rotation = Target.velocity.ToRotation(); + if (Target.velocity == Vector2.Zero) + rotation = Target.direction == 1 ? 0 : MathHelper.Pi; + rotation += Main.rand.NextFloat(-MathHelper.PiOver4 / 2f, MathHelper.PiOver4 / 2f); + } + else + rotation = Main.rand.NextFloat(0, MathHelper.TwoPi); + + int rand = Main.rand.Next(creepers.Count); + NPC first = creepers[rand]; + first.netUpdate = true; + CreeperAI creeper1 = first.AIOverride(); + AttackList.Add((byte)first.whoAmI); + //creeper1.Time = 0; + creeper1.AttackAngle = rotation; + creepers.RemoveAt(rand); + + NPC second = creepers[Main.rand.Next(creepers.Count)]; + second.netUpdate = true; + CreeperAI creeper2 = second.AIOverride(); + AttackList.Add((byte)second.whoAmI); + //creeper2.Time = 0; + creeper2.AttackAngle = rotation + MathHelper.Pi; + + creeper1.PartnerIndex = second.whoAmI; + creeper2.PartnerIndex = first.whoAmI; + + if (Main.netMode != NetmodeID.SinglePlayer) + SelectNewTarget(); + + NPC.netUpdate = true; + } + } + + if (Time > delay + attackDur + attackDelay) + { + Time = 0; + NPC.damage = NPC.defDamage; + AIState = BrainAIState.Phase1Idle; + AttackList.Clear(); + } + } + } + + private void CreeperOrbit() + { + #region Movement + Vector2 fromTarget = (NPC.Center - Target.Center).SafeNormalize(Vector2.UnitX); + Vector2 goalPos = Target.Center + (fromTarget * 440) - (Vector2.UnitY * 32); + float distSQ = NPC.DistanceSQ(goalPos); + if (distSQ > 14400) + NPC.velocity = NPC.DirectionTo(goalPos) * (4 + (NPC.Distance(goalPos) - 120) / 16f); + else + NPC.velocity = NPC.DirectionTo(goalPos).SafeNormalize(Vector2.Zero) * (2 + (2f * (distSQ / 14400))); + #endregion + + if (Time == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + AttackSign = Main.rand.NextBool() ? -1 : 1; + AttackPosition = Target.Center; + NPC.netUpdate = true; + + NPC.damage = 0; + + if (Main.netMode != NetmodeID.SinglePlayer) + { + List extraTargets = GetAllValidTargets(NPC.Center); + extraTargets.Remove(NPC.target); + + int targetCount = extraTargets.Count; + int creepersPerExtraPlayer = CalamityWorld.death ? 3 : 2; + int creepersDesired = targetCount * creepersPerExtraPlayer; + int creepersAlive = NPC.CountNPCS(NPCID.Creeper); + int creepersToSpare = creepersAlive - 4; + for (int i = 0; i < creepersPerExtraPlayer; i++) + { + if (creepersToSpare >= creepersDesired || creepersPerExtraPlayer == 1) + break; + + if (creepersToSpare < creepersDesired && creepersPerExtraPlayer > 1) + { + creepersPerExtraPlayer--; + creepersDesired = targetCount * creepersPerExtraPlayer; + } + } + int creepersSparedForTarget = 0; + + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type != NPCID.Creeper) + continue; + + n.TryGetAIOverride(out var creeper); + if (creepersDesired > 0 && creepersToSpare > 0) + { + creeper.CachedValue2 = extraTargets[0]; + creepersToSpare--; + creepersDesired--; + + creeper.Time -= 30 * creepersSparedForTarget; + + if (++creepersSparedForTarget >= creepersPerExtraPlayer) + { + extraTargets.RemoveAt(0); + creepersSparedForTarget = 0; + } + AttackCounter++; + } + else + creeper.CachedValue2 = -1; + } + } + else + { + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type != NPCID.Creeper) + continue; + + n.TryGetAIOverride(out var creeper); + creeper.CachedValue2 = -1; + } + } + } + + if (Time < OrbitSetupDuration) + { + AttackPosition = Target.Center; + } + else + { + float prox = Target.DistanceSQ(AttackPosition); + if (prox > 65536) //256^2 + AttackPosition += Target.DirectionFrom(AttackPosition) * (((float)Math.Sqrt(prox) - 256) / 16f); + } + + if (Time >= OrbitDuration + 30) + { + Time = -1; + AIState = BrainAIState.Phase1Idle; + AttackList.Clear(); + NPC.damage = NPC.defDamage; + foreach (NPC creep in Main.ActiveNPCs) + { + if (creep.type == NPCID.Creeper) + creep.AIOverride().Time = -1; + } + } + else if (Time >= OrbitAttackInterval && Time < OrbitDuration && Time % OrbitAttackInterval == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + List mainOrbitMembers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.TryGetAIOverride(out var ai) && ai.CachedValue2 == -1).ToList(); + if (mainOrbitMembers.Count > 0) + { + int rand = Main.rand.Next(mainOrbitMembers.Count); + for (int i = 0; i < OrbitAttackParticipantCount; i++) + { + if (rand >= mainOrbitMembers.Count) + rand -= mainOrbitMembers.Count; + NPC creeper = mainOrbitMembers[rand]; + AttackList.Add((byte)creeper.whoAmI); + //creeper.AIOverride().Time = 0; + rand += (int)Math.Round(mainOrbitMembers.Count / (float)OrbitAttackParticipantCount); + } + + NPC.netUpdate = true; + } + } + } + + private void CreeperSpiral() + { + if (Time == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + AttackSign = Main.rand.NextBool() ? -1 : 1; + AttackRotation = 0; + NPC.netUpdate = true; + } + float startTimePerRev = MathHelper.Lerp(StartingTimePerRevolutionMax, StartingTimePerRevolutionMin, 1 - CreeperAmountRatio); + float endTimePerRev = MathHelper.Lerp(EndingTimePerRevolutionMax, EndingTimePerRevolutionMin, 1 - CreeperAmountRatio); + float spinSpeedCompletion = MathHelper.Clamp((Time - SpeedUpDelayTime) / (SpiralDuration - SpeedUpDelayTime - SpeedUpExtensionTime), 0f, 1f); + + float timePerRev = MathHelper.Lerp(startTimePerRev, endTimePerRev, spinSpeedCompletion); + if (Time > SpiralDuration - 30) + timePerRev *= MathHelper.Lerp(1f, 10f, CalamityUtils.CircOutEasing(MathHelper.Clamp((Time - (SpiralDuration - 30)) / 30f, 0f, 1f), 1)); + else if (Time < SpiralSetupTime) + timePerRev *= MathHelper.Lerp(1f, 10f, CalamityUtils.CircInEasing(MathHelper.Clamp(Time / SpiralSetupTime, 0f, 1f), 1)); + + float rotToAdd = MathHelper.TwoPi / timePerRev * AttackSign; + if (OnSecondCreeperPhase) + { + float attackComplationRatio = Time / SpiralDuration; + float lerp = Utils.GetLerpValue(TurnAroundRatio - (TurnAroundDurationRatio / 2f), TurnAroundRatio + (TurnAroundDurationRatio / 2f), attackComplationRatio, true); + rotToAdd *= MathHelper.Lerp(1, -1, lerp); + } + AttackRotation += rotToAdd; + + if (NPC.DistanceSQ(Target.Center) > 57600) + NPC.velocity = NPC.DirectionTo(Target.Center) * (NPC.Distance(Target.Center) - 240) / 32f; + else + NPC.velocity *= 0.9f; + + if (Time > SpiralDuration) + { + Time = -1; + AIState = BrainAIState.Phase1Idle; + foreach (NPC creep in Main.ActiveNPCs) + { + if (creep.type == NPCID.Creeper) + creep.AIOverride().Time = -1; + } + } + } + + #endregion + + private void PhaseTransition() + { + NPC.dontTakeDamage = true; + NPC.rotation *= 0.9f; + TeleportTime = 0; + + float animCounter = Time - 60; + if (animCounter >= 0) + { + if (animCounter == 0) + NPC.velocity = Vector2.UnitY * 2f; + else if (animCounter < 60) + NPC.velocity *= 0.99f; + else if (animCounter == 60) + NPC.velocity = Vector2.UnitY * -8f; + else if (animCounter == 65) + { + AIState = BrainAIState.Phase2TransitionOpen; + PreviousAttack = BrainAIState.Phase1Idle; + availableAttacks.Clear(); + NPC.netUpdate = true; + + SoundEngine.PlaySound(SoundID.NPCHit1, NPC.Center); + + if (!Main.dedServ) + { + //Spawns all of BoC's Phase Transition Gores (GoreIDs 392 -> 395) + for (int i = 392; i <= 395; i++) + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, Main.rand.NextVector2Circular(6f, 6f), i); + } + + for (int j = 0; j < 20; j++) + { + Vector2 edgeBloodDir = Main.rand.NextVector2CircularEdge(1, 1); + BloodParticle b = new(NPC.Center - (Vector2.unitYVector * 32) + (edgeBloodDir * new Vector2(16, 24)), edgeBloodDir.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 10f, MathHelper.Pi / 10f)) * Main.rand.NextFloat(4f, 8f), 24, 0.75f, Color.Red); + GeneralParticleHandler.SpawnParticle(b); + + Dust.NewDustPerfect(Main.rand.NextVector2FromRectangle(NPC.Hitbox), DustID.Blood, Main.rand.NextVector2Circular(6f, 6f)); + } + + for (int i = 1; i <= 3; i++) + { + Color color = i switch + { + 1 => Color.Yellow, + 2 => Color.Orange, + _ => Color.Red, + }; + PulseRing ring = new(NPC.Center, NPC.velocity * 0.5f, color, 0f, 1f + i * 0.5f, 24); + GeneralParticleHandler.SpawnParticle(ring); + } + + BoCAfterImages = []; + + SoundEngine.PlaySound(Roar, NPC.Center); + } + else + NPC.velocity *= 0.9f; + + if (animCounter < 60f) + BoCDrawOffset = Main.rand.NextVector2CircularEdge(1, 1) * MathHelper.Lerp(0f, 16f, CalamityUtils.CircInEasing(animCounter / 60f, 1)); + else if (animCounter < 70f) + BoCDrawOffset = Main.rand.NextVector2CircularEdge(1, 1) * MathHelper.Lerp(16f, 0f, CalamityUtils.CircOutEasing((animCounter - 60) / 10f, 1)); + + if (animCounter >= 120f) + { + Time = 0; + ResetAttackValues(); + AIState = BrainAIState.Phase2Idle; + NPC.dontTakeDamage = false; + } + } + else + { + NPC.velocity *= 0.8f; + + #region Tile Collision + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.velocity = NPC.DirectionTo(Target.Center) * 4f; + } + else if (Collision.SolidCollision(NPC.position + NPC.velocity, NPC.width, NPC.height)) + { + if (NPC.velocity.X != NPC.oldVelocity.X) + NPC.velocity.X = -NPC.oldVelocity.X; + if (NPC.velocity.Y != NPC.oldVelocity.Y) + NPC.velocity.Y = -NPC.oldVelocity.Y; + NPC.velocity *= 2f; + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 8f); + } + #endregion + } + } + + #region Phase 2 + + private void Phase2Idle() + { + //goes from 3 at full health to 1 at low health + int chases = (int)Math.Ceiling(MaxChases * (NPC.life / (float)NPC.lifeMax)); + + NPC.rotation = NPC.velocity.X / 6f * MathHelper.Pi / 8f; + + if (Time == ChaseTime - 5) + AttackCounter++; + + if (Time <= ChaseTime) + { + float speedUp = MathHelper.Clamp((Time - 10) / 10f, 0f, 1f); + float slowDown = 1 - MathHelper.Clamp((Time - (ChaseTime - 15)) / 15f, 0f, 1f); + float angleChange = MathHelper.Lerp(MathHelper.Pi / 24f, 0f, MathHelper.Clamp(Time / (ChaseTime * 0.666f), 0f, 1f)); + NPC.velocity = NPC.velocity.RotateDirectionTowards(NPC.DirectionTo(Target.Center).ToRotation(), angleChange) * (MathHelper.Lerp(ChaseMinSpeed, ChaseMaxSpeed, Time / ChaseTime) * speedUp * slowDown); + + if (Time == ChaseTime) + { + if (Main.netMode != NetmodeID.SinglePlayer) + SelectNewTarget(); + Vector2 direction = Target.velocity.SafeNormalize(Vector2.UnitX * Target.direction).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 3f, MathHelper.Pi / 3f)); + AttackPosition = Target.Center + (direction * DefaultTeleportDistance); + BoCAfterImages = []; + NPC.netUpdate = true; + } + else + { + TeleportTime = 0; + NPC.Opacity = 1f; + } + } + else + { + TeleportDuration = IdleTeleportDuration; + + Vector2 endPoint = AttackPosition; + + NPC.velocity = Vector2.Zero; + + if (Time < ChaseTime + (TeleportDuration / 2f)) + { + if (Time % 4 == 0) + { + Vector2 startPoint = NPC.Center; + + Vector2 direction = endPoint - startPoint; + float curveIntensity = Main.rand.NextFloat(-0.2f, 0.2f); + Vector2 perpindicular = direction.RotatedBy(MathHelper.PiOver2); + + Vector2 controlPoint1 = startPoint + (direction * 0.25f) + (perpindicular * curveIntensity); + Vector2 controlPoint2 = startPoint + (direction * 0.75f) + (perpindicular * curveIntensity); + + BezierCurve path = new BezierCurve(startPoint, controlPoint1, controlPoint2, endPoint); + + BrainOfCthulhuAfterImage afterimage = new(path, NPC.rotation, Vector2.One, (int)(ChaseTime + (TeleportDuration * 0.75f) - Time), BoCFrame); + BoCAfterImages.Add(afterimage); + GeneralParticleHandler.SpawnParticle(afterimage); + } + TeleportTime++; + } + else if (Time == ChaseTime + (TeleportDuration / 2f) && !AttackFlag) + { + NPC.Center = endPoint; + DisableMultiplayerSmoothing = true; + AttackFlag = true; + NPC.netUpdate = true; + } + else + { + TeleportTime--; + if (TeleportTime < 0) + { + TeleportTime = 0; + Time = -1; + AttackFlag = false; + + #region Attack Selection + if (AttackCounter >= chases) //Pick attack + { + NPC.rotation = 0; + ResetAttackValues(); + + if (availableAttacks.Count == 0) + { + bool quickChoice = Main.rand.NextBool(); + availableAttacks = [ + BrainAIState.Bloodletting, + quickChoice ? BrainAIState.SanguineScythes : BrainAIState.IllusionDash, + Main.rand.NextBool() ? BrainAIState.Phase2Idle : BrainAIState.Bloodletting, + quickChoice ? BrainAIState.IllusionDash : BrainAIState.SanguineScythes, + BrainAIState.IllusionTrick + ]; + } + + AIState = availableAttacks[0]; + availableAttacks.RemoveAt(0); + PreviousAttack = AIState; + + if (AIState == BrainAIState.SanguineScythes) + { + Time = -31; + BoCAfterImages = []; + } + + NPC.netUpdate = true; + } + #endregion + } + } + + NPC.Opacity = 1 - (TeleportTime / (TeleportDuration / 2f)); + } + } + + private void Bloodletting() + { + float endTime = Time - BloodlettingDuration; + + #region Movement + + if (endTime < 0) + { + if (Time == 0) + { + AttackPosition = NPC.Center; + if (NPC.Center.X < Target.Center.X) + AttackSign = -1; + else + AttackSign = 1; + + CachedRatio = float.MaxValue; + AttackTime = float.MaxValue; + + NPC.netUpdate = true; + } + + if (Time == 30) + AttackPosition = Vector2.zeroVector; + + //Make sure we have an accurate view on who the furthest players + if (Main.netMode != NetmodeID.SinglePlayer && Time % 2 == 0) + { + Player furthestLeft = null; + Player furthestRight = null; + Player highestUp = null; + foreach (int who in GetAllValidTargets(NPC.Center)) + { + Player p = Main.player[who]; + + if (furthestLeft == null || p.Center.X < furthestLeft.Center.X) + furthestLeft = p; + + if (furthestRight == null || p.Center.X > furthestRight.Center.X) + furthestRight = p; + + if (highestUp == null || p.Center.Y < highestUp.Center.Y) + highestUp = p; + } + + AttackList.Clear(); + AttackList.Add((byte)furthestLeft.whoAmI); + AttackList.Add((byte)furthestRight.whoAmI); + AttackList.Add((byte)highestUp.whoAmI); + } + + float waveValue = Time * MathHelper.Pi / BloodshotRate; + Vector2 goalPos; + if (Main.netMode == NetmodeID.SinglePlayer) + goalPos = Target.Center + new Vector2((float)Math.Cos(waveValue) * HoverDistance.X * AttackSign, (float)(-0.5f * Math.Cos(2 * waveValue) + 0.5f) * -HoverDistance.Y); + else + { + Player furthestLeft = Main.player[AttackList[0]]; + Player furthestRight = Main.player[AttackList[1]]; + Player highestUp = Main.player[AttackList[2]]; + + Vector2 hoverCenter = (furthestLeft.Center + furthestRight.Center) / 2f; + float xDist = furthestRight.Center.X - furthestLeft.Center.X; + float yDist = hoverCenter.Y - highestUp.Center.Y; + + if (AttackPosition == Vector2.zeroVector) + AttackPosition = hoverCenter; + else + AttackPosition += (hoverCenter - AttackPosition) / 30f; + + if (CachedRatio == float.MaxValue || Math.Abs(xDist - CachedRatio) < 0.01f) + CachedRatio = xDist; + else + CachedRatio += (xDist - CachedRatio) / 30f; + + if (AttackTime == float.MaxValue || Math.Abs(yDist - AttackTime) < 0.01f) + AttackTime = yDist; + AttackTime += (yDist - AttackTime) / 30f; + + float xMag = (HoverDistance.X + CachedRatio); + float yMag = (HoverDistance.Y + AttackTime); + Vector2 destination = AttackPosition + new Vector2((float)Math.Cos(waveValue) * xMag * AttackSign, (float)(-0.5f * Math.Cos(2 * waveValue) + 0.5f) * -yMag); + + goalPos = destination; + } + + NPC.velocity = Vector2.Zero; + DisableMultiplayerSmoothing = true; + if (Time < 30f) + NPC.Center = Vector2.Lerp(AttackPosition, goalPos, CalamityUtils.SineOutEasing(Time / 30f, 1)); + else + NPC.Center = goalPos; + } + else if (endTime < DashPrepTime) + { + if (endTime == 0) + NPC.velocity = Vector2.UnitX * AttackSign * 8f; + else + { + Vector2 goalPos = Target.Center - Vector2.UnitY * HoverEndHeight; + Vector2 accel = new Vector2(0.5f, 1.5f); + + NPC.velocity += NPC.DirectionTo(goalPos).SafeNormalize(Vector2.Zero) * accel; + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 8f); + } + } + #endregion + + #region Main Attack + if (endTime < 0) + { + NPC.rotation = (float)Math.Sin(Time / 8f) * MathHelper.Pi / 8f; + BoCDrawOffset = Vector2.Zero; + + NPC.damage = 0; + + if (Time > BloodshotRate) //Doesnt fire first bloodshot + { + if (Time % IchorRate == 0) + { + if (Time % (IchorRate * 2) == 0) + SoundEngine.PlaySound(SoundID.Item17, NPC.Center); + + if(Main.netMode == NetmodeID.SinglePlayer) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + NPC.velocity + Main.rand.NextVector2Circular(72, 72), new Vector2(Main.rand.NextFloat(-IchorSpread, IchorSpread), -IchorVelocity), ModContent.ProjectileType(), IchorShotDamage, 0.5f); + else if(Main.dedServ) + { + Player furthestLeft = Main.player[AttackList[0]]; + Player furthestRight = Main.player[AttackList[1]]; + float xDist = furthestRight.Center.X - furthestLeft.Center.X; + int projCount = 1 + (int)(xDist / 360); + + for(int i = 0; i < projCount; i++) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + NPC.velocity + Main.rand.NextVector2Circular(72, 72), new Vector2(Main.rand.NextFloat(-IchorSpread, IchorSpread), -IchorVelocity), ModContent.ProjectileType(), IchorShotDamage, 0.5f); + } + } + + if (Time % BloodshotRate == 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 dir = NPC.DirectionTo(Target.Center); + + for (int i = -2; i <= 2; i++) + { + Vector2 initialDir = dir.RotatedBy(i * MathHelper.Pi / 4f); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, initialDir * BloodshotVelocity, ProjectileID.BloodNautilusShot, BloodShotDamage, 0.5f, ai0: dir.ToRotation() + MathHelper.TwoPi, ai1: initialDir.ToRotation()); + } + + if (CalamityWorld.death) + { + Vector2 initialDir = dir.RotatedBy(MathHelper.Pi / 6f); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, initialDir * BloodshotVelocity / 2.1f, ProjectileID.BloodNautilusShot, BloodShotDamage, 0.5f, ai0: dir.ToRotation() + MathHelper.TwoPi, ai1: initialDir.ToRotation()); + initialDir = dir.RotatedBy(-MathHelper.Pi / 6f); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, initialDir * BloodshotVelocity / 2.1f, ProjectileID.BloodNautilusShot, BloodShotDamage, 0.5f, ai0: dir.ToRotation() + MathHelper.TwoPi, ai1: initialDir.ToRotation()); + } + } + SoundEngine.PlaySound(BloodShot with { PitchVariance = 0.5f }, NPC.Center); + } + + } + } + #endregion + + #region Attack End + else + { + NPC.rotation *= 0.9f; + + NPC.damage = NPC.defDamage; + + if (endTime == 0) + SoundEngine.PlaySound(Roar, NPC.Center); + if (endTime >= DashPrepTime) + { + if (endTime < DashPrepTime + DashReelbackTime) + { + float reelBackSpeedExponent = 2.6f; + float reelBackCompletion = Utils.GetLerpValue(0f, 30, endTime - DashPrepTime, true); + float reelBackSpeed = MathHelper.Lerp(4f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent)); + Vector2 reelBackVelocity = Vector2.UnitY * -reelBackSpeed; + NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f); + } + else if (endTime == DashPrepTime + 20) + NPC.velocity = Vector2.UnitY * DashVelocity; + + if (endTime >= DashPrepTime + DashReelbackTime && Time % DashScytheRate == 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.UnitX * 16f, ModContent.ProjectileType(), BloodScytheDamage, 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.UnitX * -16f, ModContent.ProjectileType(), BloodScytheDamage, 0.5f); + } + } + + if (endTime > DashPrepTime + DashReelbackTime + DashDuration) + { + NPC.rotation = 0; + SetupForNextAttack(); + return; + } + } + } + #endregion + } + + private void SanguineScythes() + { + #region Attack Ending + if (AttackCounter > SanguineTeleportCount) + { + if (Time == SanguineAttackEndDelay) + { + SoundEngine.PlaySound(Roar, NPC.Center); + bool left = Target.Center.X > NPC.Center.X; + NPC.velocity = Vector2.UnitX * (left ? 18 : -18); + NPC.rotation = MathHelper.Pi / 8f * (left ? 1 : -1); + } + if (Time > SanguineAttackEndDelay + SanguineAttackEndDuration) + { + NPC.velocity *= 0.8f; + NPC.rotation *= 0.8f; + } + else if (Time >= SanguineAttackEndDelay && Time % SanguineAttackEndIchorRate == 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Vector2(Math.Sign(NPC.velocity.X), -2f), ModContent.ProjectileType(), IchorShotDamage, 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, new Vector2(Math.Sign(NPC.velocity.X), -6f), ModContent.ProjectileType(), IchorShotDamage, 0.5f); + } + } + + if (Time > SanguineAttackEndDelay + SanguineAttackEndDuration + (CalamityWorld.death ? 20 : 40)) + SetupForNextAttack(); + } + #endregion + #region Attack Start + else if (Time < 0) + { + if (Time == -25) + NPC.netUpdate = true; + + if (Time == -24) + { + SoundEngine.PlaySound(Roar, NPC.Center); + + for (int i = 1; i <= 3; i++) + { + Color color = i switch + { + 1 => Color.Yellow, + 2 => Color.Orange, + _ => Color.Red, + }; + PulseRing ring = new(NPC.Center, NPC.velocity * 0.5f, color, 0f, 1f + i * 0.5f, 24); + GeneralParticleHandler.SpawnParticle(ring); + } + } + if (Time == -1) + { + Vector2 direction = Target.velocity.SafeNormalize(Vector2.UnitX * Target.direction).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 3f, MathHelper.Pi / 3f)); + float distance = SanguineTeleportDistance; + AttackPosition = Target.Center + (direction * distance); + NPC.netUpdate = true; + } + } + #endregion + #region Teleport + else + { + TeleportDuration = SanguineTeleportDuration; + + Vector2 endPoint = AttackPosition; + + if (Time < (TeleportDuration / 2f)) + { + if (Time % 4 == 0) + { + Vector2 startPoint = NPC.Center; + + Vector2 direction = endPoint - startPoint; + float curveIntensity = Main.rand.NextFloat(-0.2f, 0.2f); + Vector2 perpindicular = direction.RotatedBy(MathHelper.PiOver2); + + Vector2 controlPoint1 = startPoint + (direction * 0.25f) + (perpindicular * curveIntensity); + Vector2 controlPoint2 = startPoint + (direction * 0.75f) + (perpindicular * curveIntensity); + + BezierCurve path = new BezierCurve(startPoint, controlPoint1, controlPoint2, endPoint); + + BrainOfCthulhuAfterImage afterimage = new(path, NPC.rotation, Vector2.One, (int)((TeleportDuration * 0.75f) - Time), BoCFrame); + BoCAfterImages.Add(afterimage); + GeneralParticleHandler.SpawnParticle(afterimage); + } + TeleportTime++; + } + else if (Time == (TeleportDuration / 2f) && !AttackFlag) + { + Vector2 start = NPC.Center; + NPC.Center = endPoint; + DisableMultiplayerSmoothing = true; + AttackFlag = true; + NPC.netUpdate = true; + } + else + { + TeleportTime--; + if (TeleportTime < 0) + { + TeleportTime = 0; + Time = -1; + AttackFlag = false; + AttackCounter++; + + if (AttackCounter <= SanguineTeleportCount) + { + SoundEngine.PlaySound(BloodExplosion, NPC.Center); + + for (int i = 0; i < SanguineScytheCount; i++) + { + float initalSpeed = 16f; + if (CalamityWorld.death && i % 2 == 0) + initalSpeed /= 2f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.UnitX.RotatedBy(MathHelper.TwoPi / SanguineScytheCount * i) * initalSpeed, ModContent.ProjectileType(), BloodScytheDamage, 0.5f); + } + } + + Vector2 direction; + if (AttackCounter < SanguineTeleportCount) + { + direction = Main.rand.NextFloat(0f, MathHelper.TwoPi).ToRotationVector2(); + AttackPosition = Target.Center + (direction * SanguineTeleportDistance); + } + else + { + direction = Vector2.UnitX * (Main.rand.NextBool() ? -1 : 1); + AttackPosition = Target.Center + (direction * SanguineFinalTeleportOffset.X) + (Vector2.UnitY * -SanguineFinalTeleportOffset.Y); + } + + NPC.netUpdate = true; + + BoCAfterImages = []; + NPC.Opacity = 1f; + } + } + + NPC.Opacity = 1 - (TeleportTime / (TeleportDuration / 2f)); + } + #endregion + } + + //Unused + private void CrimsonEyes() + { + #region Attack Start + if (Time <= 30) + { + if (Time >= 6 && Time <= 12) + { + if (Time == 6) + { + SoundEngine.PlaySound(Roar, NPC.Center); + + for (int i = 1; i <= 3; i++) + { + Color color = i switch + { + 1 => Color.Yellow, + 2 => Color.Orange, + _ => Color.Red, + }; + PulseRing ring = new(NPC.Center, NPC.velocity * 0.5f, color, 0f, 1f + i * 0.5f, 24); + GeneralParticleHandler.SpawnParticle(ring); + } + + CalamityUtils.AddScreenshakeAt(NPC.Center, 10f); + } + + for (int i = 0; i < 12; i++) + { + Point start = Target.Center.ToTileCoordinates() + new Point(Main.rand.Next(-64, 65), 48); + for (int j = 0; j < 96; j++) + { + Point current = start - new Point(0, j); + if (!Main.tile[current].IsTileSolid() && Main.tile[current - new Point(0, 1)].IsTileSolid()) + Dust.NewDust(current.ToWorldCoordinates(0, 0), 16, 16, DustID.Crimstone, 0, 3); + } + } + } + } + #endregion + #region Attack + else + { + #region Eye Spawning + if (Time < CrimsonEyeAttackDuration && CalamityUtils.CountProjectiles(ModContent.ProjectileType()) < CrimsonEyeCap && Time % CrimsonEyeRate == 0) + { + Vector2 spawnPos = Target.Center; + int i = 0; + for (i = 0; i <= 32; i++) + { + spawnPos = Target.Center + Main.rand.NextVector2Circular(256, 256); + + if (Collision.IsWorldPointSolid(spawnPos)) + continue; + + bool alreadyFilled = false; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type != ModContent.ProjectileType()) + continue; + + Rectangle hitbox = new((int)spawnPos.X - 50, (int)spawnPos.Y - 18, 100, 36); + + if (p.Hitbox.Intersects(hitbox)) + { + alreadyFilled = true; + break; + } + } + + if (alreadyFilled) + continue; + + if (Collision.CanHitLine(spawnPos, 1, 1, Target.position, Target.width, Target.height)) + break; + } + + if (i == 32) + spawnPos = Target.Center; + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromThis(), spawnPos, Vector2.Zero, ModContent.ProjectileType(), CrimsonEyeDamage, 0f); + } + #endregion + + #region Early Movement + if (Time < 180) + { + float dist = 210; + + Vector2 fromTarget = (NPC.Center - Target.Center).SafeNormalize(Vector2.UnitX); + Vector2 goalPos = Target.Center + (fromTarget * dist) - (Vector2.UnitY * 32); + if (NPC.DistanceSQ(goalPos) <= 2048) + NPC.velocity *= 0.9f; + else if (NPC.velocity.LengthSquared() < 16f) //7.5^2 + NPC.velocity += NPC.DirectionTo(goalPos).SafeNormalize(Vector2.Zero) * 0.1f; + else + NPC.velocity = NPC.DirectionTo(goalPos).SafeNormalize(Vector2.Zero) * 4f; + } + #endregion + + #region Scythe Movement + Attack + else + { + if (Time < CrimsonEyeAttackIdleDuration) + NPC.velocity *= 0.9f; + if (Time >= CrimsonEyeAttackIdleDuration + CrimsonEyeAttackSetUpDuration && Time < CrimsonEyeAttackDuration) + { + if (Time == CrimsonEyeAttackIdleDuration + CrimsonEyeAttackSetUpDuration) + NPC.velocity = NPC.DirectionTo(Target.Center); + + bool onSurface = Target.Center.Y / 16f < Main.worldSurface; + float speed = onSurface ? 10f : 8f; + if (Time < CrimsonEyeAttackIdleDuration + CrimsonEyeAttackSetUpDuration + CrimsonEyeAttackBuildUpDuration) + { + float lerp = CalamityUtils.SineInEasing((Time - (CrimsonEyeAttackIdleDuration + CrimsonEyeAttackSetUpDuration)) / CrimsonEyeAttackBuildUpDuration, 1); + speed = MathHelper.Lerp(0f, speed, lerp); + } + + float turnAmt = TurnAccelerationMultiplier * ((NPC.Distance(Target.Center) - TurnAccelerationDistanceBuffer) / TurnAccelerationDistanceDivisor); + + NPC.velocity = NPC.velocity.RotateDirectionTowards(NPC.AngleTo(Target.Center), turnAmt) * speed; + } + else + { + NPC.velocity *= 0.9f; + + if (Time == CrimsonEyeAttackDuration) + { + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type != ModContent.ProjectileType()) + continue; + + p.timeLeft = 60; + } + } + + if (Time > CrimsonEyeAttackDuration + CrimsonEyeAttackEndDuration) + SetupForNextAttack(); + } + + if (Time == CrimsonEyeAttackIdleDuration) + { + SoundEngine.PlaySound(BloodExplosion, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float projCount = 10; + for (int i = 0; i < projCount; i++) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), BloodScytheDamage, 0.5f, -1, MathHelper.TwoPi / projCount * i); + } + } + } + #endregion + } + #endregion + } + + private void IllusionDash() + { + #region Attack Start + if (Time < IllusionDashTeleportDuration) + { + if (Time == 0) + { + AttackPosition = Target.Center; + AttackRotation = Main.rand.NextFloat(0, MathHelper.TwoPi); + NPC.netUpdate = true; + } + + TeleportDuration = IllusionDashTeleportDuration; + + if (Time < (TeleportDuration / 2f)) + { + if (Time % 4 == 0) + { + Vector2 startPoint = NPC.Center; + + for (int i = 0; i < (CalamityWorld.death ? 8 : 4); i++) + { + Vector2 myEndPoint = AttackPosition + ((AttackRotation + (CalamityWorld.death ? MathHelper.PiOver4 : MathHelper.PiOver2) * i).ToRotationVector2() * IllusionDashTeleportDistance); + Vector2 direction = myEndPoint - startPoint; + + float curveIntensity = Main.rand.NextFloat(-0.2f, 0.2f); + Vector2 perpindicular = direction.RotatedBy(MathHelper.PiOver2); + + Vector2 controlPoint1 = startPoint + (direction * 0.25f) + (perpindicular * curveIntensity); + Vector2 controlPoint2 = startPoint + (direction * 0.75f) + (perpindicular * curveIntensity); + + BezierCurve path = new BezierCurve(startPoint, controlPoint1, controlPoint2, myEndPoint); + + BrainOfCthulhuAfterImage afterimage = new(path, NPC.rotation, Vector2.One, (int)((TeleportDuration * 0.75f) - Time), BoCFrame); + BoCAfterImages.Add(afterimage); + GeneralParticleHandler.SpawnParticle(afterimage); + } + } + TeleportTime++; + } + else if (Time == (TeleportDuration / 2f) && !AttackFlag) + { + AttackFlag = true; + + for (int i = 0; i < (CalamityWorld.death ? 8 : 4); i++) + { + float rot = AttackRotation + (CalamityWorld.death ? MathHelper.PiOver4 : MathHelper.PiOver2) * i; + Vector2 spawnPos = AttackPosition + (rot.ToRotationVector2() * IllusionDashTeleportDistance); + if (i == 0) + { + NPC.Center = spawnPos; + DisableMultiplayerSmoothing = true; + } + else if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPCDirect(NPC.GetSource_FromThis(), spawnPos, ModContent.NPCType(), 0, 15, 30, rot).target = NPC.target; + } + + if(Main.netMode != NetmodeID.SinglePlayer) + { + List targets = GetAllValidTargets(NPC.Center); + targets.Remove(Target.whoAmI); + + foreach (int who in targets) + { + Player p = Main.player[who]; + float baseRot = Main.rand.NextFloat(0, MathHelper.TwoPi); + for (int i = 0; i < (CalamityWorld.death ? 4 : 2); i++) + { + float rot = baseRot + (CalamityWorld.death ? MathHelper.PiOver2 : MathHelper.Pi) * i; + Vector2 spawnPos = p.Center + (rot.ToRotationVector2() * IllusionDashTeleportDistance); + + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPCDirect(NPC.GetSource_FromThis(), spawnPos, ModContent.NPCType(), 0, 15, 30, rot).target = p.whoAmI; + } + } + } + + NPC.netUpdate = true; + } + else + TeleportTime--; + + NPC.Opacity = 1 - (TeleportTime / (TeleportDuration / 2f)); + } + #endregion + else + { + float startTime = Time - IllusionDashTeleportDuration; + + if (startTime == 0) + { + AttackPosition = NPC.Center; + TeleportTime = 0; + AttackFlag = false; + + BoCAfterImages = []; + NPC.Opacity = 1f; + + GenericSparkle sparkle = new(NPC.Center + new Vector2(16, -8), Vector2.Zero, Color.Yellow, Color.Orange, 2f, 16, needed: true); + GeneralParticleHandler.SpawnParticle(sparkle); + + NPC.netUpdate = true; + + foreach (NPC n in Main.ActiveNPCs) + if (n.type == ModContent.NPCType()) + n.netUpdate = true; + } + if (startTime < 30) + { + float lerp = startTime / 30f; + float circleDist = MathHelper.Lerp(IllusionDashTeleportDistance, IllusionDashCloseInDistance, CalamityUtils.SineOutEasing(lerp, 1)); + NPC.Center = Vector2.Lerp(AttackPosition, Target.Center + (AttackRotation.ToRotationVector2() * circleDist), lerp); + AttackRotation += MathHelper.Lerp(0f, IllusionDashStartingSpinSpeed, CalamityUtils.SineInEasing(lerp, 1)); + DisableMultiplayerSmoothing = true; + } + else if (startTime <= 30 + IllusionDashSpinDuration) + { + NPC.Center = Target.Center + AttackRotation.ToRotationVector2() * IllusionDashCloseInDistance; + DisableMultiplayerSmoothing = true; + AttackRotation += MathHelper.Lerp(IllusionDashStartingSpinSpeed, 0f, CalamityUtils.SineOutEasing((startTime - 30) / (float)IllusionDashSpinDuration, 1)); + } + else if (startTime < 30 + IllusionDashSpinDuration + 30) + { + if (startTime < 30 + IllusionDashSpinDuration + 15) + { + float reelBackSpeedExponent = 2.6f; + float reelBackCompletion = Utils.GetLerpValue(0f, 30, startTime - 130, true); + float reelBackSpeed = MathHelper.Lerp(2.5f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent)); + Vector2 reelBackVelocity = (AttackRotation + MathHelper.Pi).ToRotationVector2() * -reelBackSpeed; + NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f); + } + else if (startTime == 30 + IllusionDashSpinDuration + 15) + NPC.velocity = (AttackRotation + MathHelper.Pi).ToRotationVector2() * -32; + else + NPC.velocity *= 0.9f; + } + else if (startTime <= 30 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration) //176 + { + NPC.velocity = Vector2.Zero; + + if (startTime == 30 + IllusionDashSpinDuration + 30) + { + AttackPosition = Target.Center; + AttackRotation = AttackRotation + MathHelper.Pi + Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2); + NPC.netUpdate = true; + } + + float wrappedCounter = startTime - (30 + IllusionDashSpinDuration + 30); + + TeleportDuration = IllusionDashFakeoutTeleportDuration; + + Vector2 endPoint = AttackPosition + (AttackRotation.ToRotationVector2() * 270); + + if (wrappedCounter < (TeleportDuration / 2f)) + { + if (wrappedCounter % 2 == 0) + { + Vector2 startPoint = NPC.Center; + + Vector2 direction = endPoint - startPoint; + + float curveIntensity = Main.rand.NextFloat(-0.2f, 0.2f); + Vector2 perpindicular = direction.RotatedBy(MathHelper.PiOver2); + + Vector2 controlPoint1 = startPoint + (direction * 0.25f) + (perpindicular * curveIntensity); + Vector2 controlPoint2 = startPoint + (direction * 0.75f) + (perpindicular * curveIntensity); + + BezierCurve path = new BezierCurve(startPoint, controlPoint1, controlPoint2, endPoint); + + BrainOfCthulhuAfterImage afterimage = new(path, NPC.rotation, Vector2.One, (int)((TeleportDuration * 0.75f) - wrappedCounter), BoCFrame); + BoCAfterImages.Add(afterimage); + GeneralParticleHandler.SpawnParticle(afterimage); + } + TeleportTime++; + } + else if (wrappedCounter == (int)(TeleportDuration / 2f) && !AttackFlag) + { + AttackFlag = true; + NPC.Center = endPoint; + DisableMultiplayerSmoothing = true; + } + else + { + TeleportTime--; + if (TeleportTime <= 0) + { + TeleportTime = 0; + BoCAfterImages = []; + ResetAttackValues(); + NPC.Opacity = 1f; + NPC.netUpdate = true; + AttackRotation = NPC.AngleTo(Target.Center); + } + } + + NPC.Opacity = 1 - (TeleportTime / (TeleportDuration / 2f)); + } + else if (startTime < 90 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration + 30) + { + NPC.velocity *= 0.9f; + if (startTime % 15 == 0 && startTime > 45 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration) + { + for (int i = 0; i < 2; i++) + { + Vector2 dir = NPC.DirectionTo(Target.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 initialDir = dir.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 4f, MathHelper.Pi / 4f)); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, initialDir * Main.rand.NextFloat(10f, 25f), ProjectileID.BloodNautilusShot, BloodShotDamage, 0.5f, ai0: dir.ToRotation() + MathHelper.TwoPi, ai1: initialDir.ToRotation()); + } + NPC.velocity -= dir * 2f; + } + } + } + else if (startTime >= 135 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration + 30) + { + foreach (NPC n in Main.ActiveNPCs) + if (n.type == ModContent.NPCType()) + n.active = false; + + SetupForNextAttack(); + } + } + } + + private void IllusionTrick() + { + if (Time >= 90) + { + if (Time == 90) + { + foreach (Projectile p in Main.ActiveProjectiles) + { + if (!p.friendly) + continue; + + p.Calamity().IgnoreBoCIllusions = true; + } + + int brainAngleSlot = Main.rand.Next(0, IllusionTrickAngleGroups); + int brainDistSlot = Main.rand.Next(0, IllusionTrickGroupSize); + + if (Main.netMode != NetmodeID.MultiplayerClient) + for (int a = 0; a < IllusionTrickAngleGroups; a++) + for (int d = 0; d < IllusionTrickGroupSize; d++) + { + if (a != brainAngleSlot || d != brainDistSlot) + NPC.NewNPC(NPC.GetSource_FromThis(), 0, 0, ModContent.NPCType(), 0, MathHelper.TwoPi / IllusionTrickAngleGroups * a, FalseBrain.TimeDivisor / IllusionTrickGroupSize * d); + } + + AttackTime = (int)(FalseBrain.TimeDivisor / IllusionTrickGroupSize * brainDistSlot); + AttackRotation = MathHelper.TwoPi / IllusionTrickAngleGroups * brainAngleSlot; + AttackFlag = false; + + if(Main.netMode == NetmodeID.SinglePlayer) + AttackPosition = Target.Center; + else + { + List nearbyPlayers = GetAllValidTargets(NPC.Center); + Vector2 averagePosition = Vector2.zeroVector; + foreach(int p in nearbyPlayers) + { + TargetsSet.Add(p); + averagePosition += Main.player[p].Center; + } + + averagePosition /= (float)nearbyPlayers.Count; + + AttackPosition = averagePosition; + } + + NPC.ShowNameOnHover = false; + NPC.netUpdate = true; + } + else + { + Vector2 goalPos; + if (Main.netMode == NetmodeID.SinglePlayer) + goalPos = Target.Center; + else + { + Vector2 averagePosition = Vector2.zeroVector; + foreach (int who in TargetsSet) + averagePosition += Main.player[who].Center; + + averagePosition /= (float)TargetsSet.Count; + + goalPos = averagePosition; + } + + float distSq = AttackPosition.DistanceSQ(goalPos); + + if (distSq > 90000) //300^2 + { + float dist = MathF.Sqrt(distSq); + Vector2 dir = (goalPos - AttackPosition).SafeNormalize(Vector2.zeroVector); + AttackPosition += dir * (dist - 300) / 60f; + } + } + + NPC.damage = 0; + + if (AttackFlag) + { + if (AttackCounter == 0) + { + NPC.ShowNameOnHover = true; + NPC.velocity = NPC.DirectionFrom(Target.Center) * 8f; + } + else + NPC.velocity *= 0.95f; + + if (AttackCounter >= IllusionTrickStunDuration) + { + NPC.damage = NPC.defDamage; + SetupForNextAttack(); + NPC.Opacity = 1f; + TeleportTime = 0; + return; + } + + AttackCounter++; + } + else if (Time >= IllusionTrickTimeLimit) //Players have failed to find the real BoC within the time limit + { + if (Time == IllusionTrickTimeLimit) + { + var targets = GetAllValidTargets(NPC.Center); + + AttackList.Clear(); + foreach (int p in targets) + AttackList.Add((byte)p); + + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type != ModContent.NPCType()) + continue; + + n.ModNPC().BeenHit = true; + } + + for (int i = 1; i <= 3; i++) + { + Color color = i switch + { + 1 => Color.Yellow, + 2 => Color.Orange, + _ => Color.Red, + }; + PulseRing ring = new(NPC.Center, NPC.velocity * 0.5f, color, 0f, 1f + i * 0.5f, 24); + GeneralParticleHandler.SpawnParticle(ring); + } + + NPC.netUpdate = true; + } + else if (Time % 30 == 0) + { + if (AttackList.Count > 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, -1, AttackList[0], 2f); + + AttackList.RemoveAt(0); + } + else + { + Vector2 direction = Target.velocity.SafeNormalize(Vector2.UnitX * Target.direction).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 3f, MathHelper.Pi / 3f)); + float distance = DefaultTeleportDistance; + AttackPosition = Target.Center + (direction * distance); + BoCAfterImages = []; + NPC.Opacity = 1f; + TeleportTime = 0; + Time = ChaseTime - 1; + NPC.damage = NPC.defDamage; + NPC.netUpdate = true; + ResetAttackValues(); + + AIState = BrainAIState.Phase2Idle; + } + } + } + else + { + CachedRatio = (float)Math.Cos(AttackTime * MathHelper.TwoPi / FalseBrain.TimeDivisor); + + float lerp = CalamityUtils.SineInOutEasing(MathHelper.Clamp((Time - 150) / 30f, 0f, 1f), 1); + float baseDist = 240; + float circleDist = 480; + if (Time - 150 < 30f) + { + baseDist = MathHelper.Lerp(480, 240, lerp); + circleDist = MathHelper.Lerp(240, 480, lerp); + } + NPC.Center = AttackPosition + Vector2.UnitX.RotatedBy(AttackRotation) * (baseDist + (circleDist * ((float)Math.Sin(-AttackTime * MathHelper.TwoPi / FalseBrain.TimeDivisor) / 2f + 0.5f))); + NPC.Center += Vector2.UnitX.RotatedBy(AttackRotation + MathHelper.PiOver2) * (90 * (float)Math.Cos(AttackTime * MathHelper.TwoPi / FalseBrain.TimeDivisor)); + NPC.Opacity = 1f; + DisableMultiplayerSmoothing = true; + AttackCounter = 0; + } + } + else if (Time <= 60) + { + TeleportDuration = 60; + TeleportTime++; + NPC.Opacity = 1 - (Time / 60f); + + if (Time < 50) + { + Vector2 startPoint = NPC.Center; + Vector2 endPoint = NPC.Center + Vector2.UnitX.RotatedBy(Main.rand.NextFloat(0, MathHelper.TwoPi)) * Main.rand.NextFloat(240, 480); + + Vector2 direction = endPoint - startPoint; + float curveIntensity = Main.rand.NextFloat(-0.2f, 0.2f); + Vector2 perpindicular = direction.RotatedBy(MathHelper.PiOver2); + + Vector2 controlPoint1 = startPoint + (direction * 0.25f) + (perpindicular * curveIntensity); + Vector2 controlPoint2 = startPoint + (direction * 0.75f) + (perpindicular * curveIntensity); + + BezierCurve path = new BezierCurve(startPoint, controlPoint1, controlPoint2, endPoint); + + BrainOfCthulhuAfterImage afterimage = new(path, NPC.rotation, Vector2.One, (int)(60 - Time), BoCFrame); + BoCAfterImages.Add(afterimage); + GeneralParticleHandler.SpawnParticle(afterimage); + } + } + else + { + NPC.Opacity = 0f; + BoCAfterImages = []; + } + + if (Time >= 180) + AttackTime++; + else if (Time >= 150) + AttackTime += (Time - 150) / 30f; + } + + #endregion + + private void DeathAnimation() + { + if (Time == 0) + NPC.velocity = NPC.DirectionFrom(Target.Center) * 6f; + else + NPC.velocity *= 0.95f; + + NPC.damage = 0; + + NPC.rotation = MathHelper.Pi / 24f * NPC.oldVelocity.X; + TeleportTime *= 0.6f; + if (TeleportTime < 0.005f) + TeleportTime = 0; + BoCDrawOffset *= 0.6f; + NPC.Opacity = BringOpacityTo(NPC.Opacity, 1, 0.1f); + + (float angle, Vector2 offset, int time)[] bloodGushingData = [ + (MathHelper.Pi / 6f, new(18, 12), 60), + (MathHelper.Pi, new(-30, -10), 150), + (-MathHelper.Pi / 4f, new(20, -40), 210), + (MathHelper.Pi + MathHelper.Pi / 4f, new(-20, -40), 240), + (MathHelper.Pi / 1.75f, new(-5, 22), 260) + ]; + float EndTime = 270f; + + for (int i = 0; i < bloodGushingData.Length; i++) + { + if (Time >= bloodGushingData[i].time) + { + if (Time == bloodGushingData[i].time) + { + if(i == 3) + SoundEngine.PlaySound(Death, NPC.Center); + + Vector2 bloodDir = bloodGushingData[i].angle.ToRotationVector2(); + BloodParticle2 p2 = new(NPC.Center + bloodGushingData[i].offset.RotatedBy(NPC.rotation), bloodDir * 7.5f, 16, 0.5f, Color.Red); + GeneralParticleHandler.SpawnParticle(p2); + NPC.velocity = bloodDir * -4f; + + SoundStyle bleed = BloodShot with + { + Pitch = i / (float)(bloodGushingData.Length - 1) + }; + SoundEngine.PlaySound(bleed, NPC.Center); + + Main.LocalPlayer.SetScreenshake(1f); + } + + for (int j = 0; j < 2; j++) + { + BloodParticle p = new(NPC.Center + bloodGushingData[i].offset.RotatedBy(NPC.rotation), (bloodGushingData[i].angle + Main.rand.NextFloat(-MathHelper.Pi / 10f, MathHelper.Pi / 10f)).ToRotationVector2() * Main.rand.NextFloat(5f, 10f), 32, 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + } + + } + + if (Time >= EndTime) + { + SoundEngine.PlaySound(BloodExplosion, NPC.Center); + SoundEngine.PlaySound(BloodShot, NPC.Center); + + Main.LocalPlayer.SetScreenshake(2f); + + int pCount = 10; + for (int i = 0; i < pCount; i++) + { + float initalSpeed = 24f; + Vector2 pVelo = Vector2.UnitX.RotatedBy(MathHelper.TwoPi / pCount * i) * initalSpeed; + + for (int j = 0; j < 2; j++) + { + BloodParticle p = new(NPC.Center, pVelo.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.5f, 1f), 32, 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + BloodParticle2 p2 = new(NPC.Center, pVelo * 0.75f, 16, 0.5f, Color.Red); + GeneralParticleHandler.SpawnParticle(p2); + } + + NPC.dontTakeDamage = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); + } + + float animationCompletion = Time / EndTime; + NPC.frameCounter += 2 * animationCompletion; + BoCDrawOffset = Main.rand.NextVector2Circular(4, 4) * animationCompletion; + + if (Main.rand.NextFloat(0.5f, 1f) < animationCompletion) + { + Vector2 edgeBloodDir = Main.rand.NextVector2CircularEdge(1, 1); + BloodParticle b = new(NPC.Center + (edgeBloodDir * NPC.Size * 0.75f), edgeBloodDir.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 10f, MathHelper.Pi / 10f)) * Main.rand.NextFloat(2f, 4f), 16, 0.75f, Color.Red); + GeneralParticleHandler.SpawnParticle(b); + } + } + + #endregion + + public override void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter) + { + binaryWriter.Write((byte)PreviousAttack); + + if (AIState == BrainAIState.Stunned || AIState >= BrainAIState.Phase2TransitionClosed) + { + binaryWriter.Write(TeleportTime); + binaryWriter.Write(TeleportDuration); + } + + if (AIState <= BrainAIState.SurfaceSpawnAnimation) + { + binaryWriter.Write(SpawnTime); + binaryWriter.Write(SpawnDelay); + } + + binaryWriter.WriteFlags(OnSecondCreeperPhase, isNegative, AttackFlag); + + binaryWriter.Write(AttackRotation); + binaryWriter.Write(AttackTime); + binaryWriter.Write(AttackCounter); + + binaryWriter.WritePackedWorldPosition(AttackPosition); + + binaryWriter.Write((byte)availableAttacks.Count); + + binaryWriter.Write(availableAttacks.Select(e => (byte)e).ToArray()); + + binaryWriter.Write((byte)AttackList.Count); + binaryWriter.Write(AttackList.ToArray()); + } + + public override void ReceiveExtraAI(BitReader bitReader, BinaryReader binaryReader) + { + PreviousAttack = (BrainAIState)binaryReader.ReadByte(); + + if (AIState == BrainAIState.Stunned || AIState >= BrainAIState.Phase2TransitionClosed) + { + TeleportTime = binaryReader.ReadSingle(); + TeleportDuration = binaryReader.ReadSingle(); + } + + if (AIState <= BrainAIState.SurfaceSpawnAnimation) + { + SpawnTime = binaryReader.ReadSingle(); + SpawnDelay = binaryReader.ReadInt32(); + } + + binaryReader.ReadFlags(out OnSecondCreeperPhase, out isNegative, out AttackFlag); + + AttackRotation = binaryReader.ReadSingle(); + AttackTime = binaryReader.ReadSingle(); + AttackCounter = binaryReader.ReadInt32(); + + AttackPosition = binaryReader.ReadPackedWorldPosition(); + + int availableLength = binaryReader.ReadByte(); + availableAttacks = binaryReader.ReadBytes(availableLength).Select(e => (BrainAIState)e).ToList(); + + byte attackLength = binaryReader.ReadByte(); + AttackList = binaryReader.ReadBytes(attackLength).ToList(); + } + + public override bool? CanBeHitByProjectile(Mod mod, Projectile projectile) + { + if (AIState == BrainAIState.IllusionTrick && !AttackFlag && projectile.Calamity().IgnoreBoCIllusions) + return false; + return base.CanBeHitByProjectile(mod, projectile); + } + + public override void ModifyHitByItem(Mod mod, Player player, Item item, ref NPC.HitModifiers modifiers) + { + if (AIState != BrainAIState.DeathAnimation) + modifiers.SetMaxDamage(NPC.life - 1); + } + + public override void ModifyHitByProjectile(Mod mod, Projectile projectile, ref NPC.HitModifiers modifiers) + { + if (AIState != BrainAIState.DeathAnimation) + modifiers.SetMaxDamage(NPC.life - 1); + } + + public override void HitEffect(Mod mod, NPC.HitInfo hit) + { + if (AIState != BrainAIState.DeathAnimation && (NPC.life + 1) <= hit.Damage) + { + TriggerDeathAnimation(); + return; + } + + if (AIState == BrainAIState.IllusionTrick && Time < 960) + { + AttackFlag = true; + NPC.netUpdate = true; + } + } + + private void TriggerDeathAnimation() + { + NPC.life = 1; + NPC.lifeRegen = 0; + NPC.BossBar = null; + NPC.dontTakeDamage = true; + + if (AIState == BrainAIState.Stunned || AIState == BrainAIState.IllusionTrick) + TeleportTime = 0; + + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type != ModContent.NPCType()) + continue; + + n.ModNPC().BeenHit = true; + } + + AIState = BrainAIState.DeathAnimation; + ResetAttackValues(); + Time = 0; + NPC.netUpdate = true; + } + + public override bool PreKill(Mod mod) => AIState == BrainAIState.DeathAnimation && !NPC.dontTakeDamage; + + public override void FindFrame(Mod mod, int frameHeight) + { + if (BoCFrame == Rectangle.Empty) + BoCFrame = TextureAssets.Npc[NPCID.BrainofCthulhu].Frame(verticalFrames: 8); + + if (NPC.frameCounter == 0) + BoCFrame.Y += frameHeight; + + if (AIState <= BrainAIState.Phase2TransitionClosed) + { + if (BoCFrame.Y > frameHeight * 3) + BoCFrame.Y = 0; + return; + } + if (BoCFrame.Y < frameHeight * 4) + BoCFrame.Y = frameHeight * 4; + + if (BoCFrame.Y > frameHeight * 7) + BoCFrame.Y = frameHeight * 4; + } + + public override bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + bool phase1 = AIState <= BrainAIState.Phase2TransitionOpen; + bool drawBrain = true; + + if (phase1) + { + List creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper).ToList(); + creepers.Sort((a, b) => b.DistanceSQ(NPC.Center).CompareTo(a.DistanceSQ(NPC.Center))); + + var tendrils = BrainOfCthulhuSystem.VerletTendrils.ToList(); + tendrils.Sort((a, b) => { + int bIndex = creepers.IndexOf(Main.npc[b.creeper]); + if (bIndex == -1) + bIndex = int.MaxValue; + int aIndex = creepers.IndexOf(Main.npc[a.creeper]); + if (aIndex == -1) + aIndex = int.MaxValue; + return bIndex.CompareTo(aIndex); + }); + + foreach (var v in tendrils) + { + List curvePoints = v.tendril; + if (curvePoints is null) + continue; + + NPC creeper = Main.npc[v.creeper]; + if (creeper == null || !creeper.active || creeper.type != NPCID.Creeper) + creeper = null; + + float glowIntensity = creeper == null ? 0 : creeper.AIOverride().ConnectionOpacity; + Color ichorLess = Color.Lerp(Color.Transparent, Color.OrangeRed * 0.333f, glowIntensity); + Color ichorful = Color.Lerp(Color.OrangeRed * 0.25f, Color.Orange * 0.666f, glowIntensity); + + for (int i = 0; i < curvePoints.Count; i++) + { + Vector2 start = curvePoints[i].position; + Vector2 end = i == curvePoints.Count - 1 ? (creeper == null ? curvePoints[i].position : creeper.Center) : curvePoints[i + 1].position; + Vector2 center = (end + start) / 2f; + start -= Main.screenPosition; + end -= Main.screenPosition; + + float rotation = (end - start).ToRotation() - MathHelper.PiOver2; + + float ichorRatio = 0; + + if (creeper != null) + { + float flowTime = creeper.AIOverride().FlowTime; + float flowAmt = creeper.AIOverride().FlowAmount; + ichorRatio = CalamityUtils.ExpInEasing((float)Math.Sin((flowTime + (i * flowAmt)) * 2f) / 2f + 0.5f, 1); + } + + Color glowColor = Color.Lerp(ichorLess, ichorful, ichorRatio); + + float dist = Vector2.Distance(start, end); + Vector2 tendrilScale = new(1f + (0.5f * (ichorRatio * (1 + (glowIntensity * 0.5f)))), dist / BrainOfCthulhuSystem.tendril.Height()); + + spriteBatch.Draw(BrainOfCthulhuSystem.tendril.Value, start, null, Lighting.GetColor(center.ToTileCoordinates()) * NPC.Opacity, rotation, BrainOfCthulhuSystem.tendril.Size() * Vector2.UnitX * 0.5f, tendrilScale, SpriteEffects.None, 0f); + spriteBatch.Draw(BrainOfCthulhuSystem.GetTendrilGlow(), start, null, glowColor * NPC.Opacity, rotation, BrainOfCthulhuSystem.GetTendrilGlow().Size() * Vector2.UnitX * 0.5f, tendrilScale, SpriteEffects.None, 0f); + } + } + + foreach (NPC creeper in creepers) + { + float glowIntensity = creeper.AIOverride().ConnectionOpacity; + + spriteBatch.Draw(BrainOfCthulhuSystem.GetCreeperGlow(), creeper.Center - Main.screenPosition, null, Color.Orange * glowIntensity, creeper.rotation, TextureAssets.Npc[NPCID.Creeper].Size() * 0.5f, creeper.scale * 1.15f, 0, 0); + + spriteBatch.Draw(TextureAssets.Npc[NPCID.Creeper].Value, creeper.Center - Main.screenPosition, null, Lighting.GetColor(creeper.Center.ToTileCoordinates()).MultiplyRGB(Color.Lerp(Color.White, new Color(255, 180, 180), glowIntensity)), creeper.rotation, TextureAssets.Npc[NPCID.Creeper].Size() * 0.5f, creeper.scale, 0, 0); + } + } + else + { + List falseBrains = Main.npc.Where(n => n.active && n.type == ModContent.NPCType()).ToList(); + if (falseBrains.Count > 0) + { + drawBrain = false; + + falseBrains.Add(NPC); + falseBrains.Sort((Comparison)((a, b) => + { + float aValue; + float bValue; + + if (a.ModNPC is FalseBrain falseA) + aValue = falseA.DrawPriority; + else + aValue = a.AIOverride().CachedRatio; + + if (b.ModNPC is FalseBrain falseB) + bValue = falseB.DrawPriority; + else + bValue = b.AIOverride().CachedRatio; + + return aValue.CompareTo(bValue); + })); + + foreach (NPC n in falseBrains) + { + if (n.ModNPC is FalseBrain falseBrain) + falseBrain.DrawSelf(spriteBatch, screenPos, Lighting.GetColor(n.Center.ToTileCoordinates())); + else if (AIState == BrainAIState.DeathAnimation) + drawBrain = true; + else + DrawBrainLikeFakes(spriteBatch, n); + } + } + } + + if (drawBrain) + DrawBrain(spriteBatch, NPC); + + return false; + } + + public static int GetBrainOfCthuluCreepersCountRevDeath() => CalamityWorld.death ? 30 : 21; + + public static List GetAllValidTargets(Vector2 brainPosition) + { + List validTargets = []; + + foreach(Player p in Main.ActivePlayers) + { + if(ValidateTarget(p, brainPosition)) + validTargets.Add(p.whoAmI); + } + + return validTargets; + } + + public static bool ValidateTarget(Player p, Vector2 brainPosition) => !p.dead && p.ZoneCrimson && p.Center.DistanceSQ(brainPosition) <= DespawnRangeSQ; + + private void SelectNewTarget() + { + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + options.finishThemOff = true; + options.maxSearchRange = DespawnRange; + options.targetType = NPCTargetType.ForceSwitch; + + var available = GetAllValidTargets(NPC.Center); + if (available.Any(p => !TargetsSet.Contains(p))) + options.excludedPlayers = TargetsSet; + else + { + TargetsSet.Clear(); + options.excludedPlayers = [NPC.target]; + } + + NPC.CalamityTargeting(options); + + TargetsSet.Add(NPC.target); + } + + internal static float BringOpacityTo(float currentOpacity, float goalOpacity, float changeAmount = 0.025f) + { + if (currentOpacity == goalOpacity) + return goalOpacity; + + if (currentOpacity < goalOpacity) + { + currentOpacity += changeAmount; + if (currentOpacity >= goalOpacity) + return goalOpacity; + else + return currentOpacity; + } + else + { + currentOpacity -= changeAmount; + if (currentOpacity <= goalOpacity) + return goalOpacity; + else + return currentOpacity; + } + } + + private static void DrawBrain(SpriteBatch spriteBatch, NPC brain) + { + BrainOfCthulhuAI ai = brain.AIOverride(); + bool phase1 = ai.AIState < BrainAIState.Phase2TransitionClosed; + + Vector2 drawPos = brain.Center + ai.BoCDrawOffset + (Vector2.UnitY * 16) - Main.screenPosition; + Vector2 scale = Vector2.One; + + if (!phase1 && ai.TeleportTime != 0) + { + ai.BoCAfterImages.RemoveAll(p => p.Time > p.Lifetime); + foreach (Particle p in ai.BoCAfterImages) + p.CustomDraw(spriteBatch); + + //Color glowColor = Color.White * (teleportCounter / 30f); + scale = Vector2.Lerp(Vector2.One, new Vector2(0.5f + ((float)Math.Cos(ai.Time / (ai.TeleportDuration / 2f) * MathHelper.TwoPi) / 2f + 0.5f), 0.5f + ((float)Math.Sin(ai.Time / (ai.TeleportDuration / 2f) * MathHelper.TwoPi) / 2f + 0.5f)), CalamityUtils.SineInOutEasing(ai.TeleportTime / (ai.TeleportDuration / 2f), 1)); + + spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, drawPos, ai.BoCFrame, Lighting.GetColor(brain.Center.ToTileCoordinates()) * brain.Opacity, brain.rotation, ai.BoCFrame.Size() * 0.5f, scale * brain.scale, 0, 0); + //spriteBatch.Draw(GetBrainGlow(), drawPos, NPC.frame, glowColor, NPC.rotation, NPC.frame.Size() * 0.5f, scale, 0, 0); + } + else + spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, drawPos, ai.BoCFrame, Lighting.GetColor(brain.Center.ToTileCoordinates()) * brain.Opacity, brain.rotation, ai.BoCFrame.Size() * 0.5f, scale * brain.scale, 0, 0); + } + + private static void DrawBrainLikeFakes(SpriteBatch spriteBatch, NPC brain) + { + BrainOfCthulhuAI ai = brain.AIOverride(); + + Vector2 scaleDistort = new Vector2((float)Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f); + + int spawnTime = 150 - ((int)ai.Time); + float startLerp = spawnTime / 60f; + + Color drawColor = Lighting.GetColor(brain.Center.ToTileCoordinates()); + + if (spawnTime > 0) + { + drawColor *= (1 - startLerp); + scaleDistort *= startLerp; + } + else + scaleDistort = Vector2.Zero; + + spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, brain.Center + (Vector2.UnitY * 16) - Main.screenPosition, ai.BoCFrame, drawColor, brain.rotation, ai.BoCFrame.Size() * 0.5f, (Vector2.One + scaleDistort) * brain.scale, 0, 0); + } + + private void SetupForNextAttack() + { + Player target = Main.player[NPC.target]; + + Vector2 direction = target.velocity.SafeNormalize(Vector2.UnitX * target.direction).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 3f, MathHelper.Pi / 3f)); + float distance = DefaultTeleportDistance; + AttackPosition = target.Center + (direction * distance); + BoCAfterImages = []; + Time = ChaseTime - 1; + ResetAttackValues(); + NPC.netUpdate = true; + + if (availableAttacks.Count != 0) + { + if (availableAttacks[0] != BrainAIState.Phase2Idle) + AttackCounter = 4; + else + availableAttacks.RemoveAt(0); + } + + AIState = BrainAIState.Phase2Idle; + } + + private void ResetAttackValues() + { + isNegative = false; + AttackRotation = 0; + AttackTime = 0; + AttackFlag = false; + AttackPosition = Vector2.Zero; + AttackCounter = 0; + } +} diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs new file mode 100644 index 0000000000..e2e80efb76 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuSystem.cs @@ -0,0 +1,424 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.DataStructures; +using CalamityMod.Particles; +using CalamityMod.Scenes.MusicScenes; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; + +public class BrainOfCthulhuSystem : ModSystem +{ + public static bool IsBrainOfCthulhuTextureVanilla => _vanillaBoCTexture; + private static bool _vanillaBoCTexture = true; + internal static Asset tendril; + private static Texture2D tendrilGlow = null; + private static Texture2D brainGlow = null; + private static Texture2D creeperGlow = null; + + internal static float ScreenBlurStrength = 0f; + + internal static (int creeper, List tendril, int reelInTimer)[] VerletTendrils; + + private static int previousMusic = -1; + public static int PreviousMusic => previousMusic; + + public override void OnModLoad() + { + if (!Main.dedServ) + tendril = ModContent.Request("Terraria/Images/Chain12"); + + On_NPC.SpawnBoss += SpawnBrainNoMessage; + On_Player.ItemCheck_UseBossSpawners += BlockRoar; + On_Main.UpdateAudio_DecideOnNewMusic += StopBoss3FromStarting; + On_Main.UpdateAudio_DecideOnTOWMusic += StopOWBoss1FromStarting; + } + + private void StopBoss3FromStarting(On_Main.orig_UpdateAudio_DecideOnNewMusic orig, Main self) + { + orig(self); + + if (NPC.crimsonBoss == -1 || !CalamityWorld.revenge || !Main.npc[NPC.crimsonBoss].active || !Main.npc[NPC.crimsonBoss].TryGetAIOverride(out var brainAI)) + return; + + if (previousMusic < 0 || previousMusic >= Main.musicFade.Length) + return; + + // The last part leaves one frame at the end of the spawn animation where the boss music starts playing, so that it can be instantly maxed out + if (brainAI.AIState < 0 && (brainAI.Time - Math.Abs(brainAI.SpawnTime) < 420)) + { + if (Main.newMusic == MusicID.Boss3) + Main.newMusic = previousMusic; + + if (Main.curMusic == MusicID.Boss3) + Main.curMusic = previousMusic; + } + + if (Main.newMusic == MusicID.Boss1) + Main.newMusic = previousMusic; + + if (Main.curMusic == MusicID.Boss1) + Main.curMusic = previousMusic; + } + + private void StopOWBoss1FromStarting(On_Main.orig_UpdateAudio_DecideOnTOWMusic orig, Main self) + { + orig(self); + + if (NPC.crimsonBoss == -1 || !CalamityWorld.revenge || !Main.npc[NPC.crimsonBoss].TryGetAIOverride(out var brainAI)) + return; + + if (previousMusic < 0 || previousMusic >= Main.musicFade.Length) + return; + + // The last part leaves one frame at the end of the spawn animation where the boss music starts playing, so that it can be instantly maxed out + if (brainAI.AIState < 0 && (brainAI.Time - Math.Abs(brainAI.SpawnTime) < 420)) + { + if (Main.newMusic == MusicID.OtherworldlyBoss1) + Main.newMusic = previousMusic; + + if (Main.curMusic == MusicID.OtherworldlyBoss1) + Main.curMusic = previousMusic; + } + } + + private void BlockRoar(On_Player.orig_ItemCheck_UseBossSpawners orig, Player self, int onWhichPlayer, Item sItem) + { + if (sItem.type != ItemID.BloodySpine || !CalamityWorld.revenge || !self.ItemTimeIsZero || self.itemAnimation <= 0) + { + orig(self, onWhichPlayer, sItem); + return; + } + + SoundEngine.PlaySound(SoundID.NPCDeath1, Main.LocalPlayer.Center); + + if (self.ZoneCrimson) + { + self.ApplyItemTime(sItem); + CalamityUtils.SpawnBossUsingItem(self, NPCID.BrainofCthulhu); + } + } + + private void SpawnBrainNoMessage(On_NPC.orig_SpawnBoss orig, int spawnPositionX, int spawnPositionY, int Type, int targetPlayerIndex) + { + if (Type != NPCID.BrainofCthulhu || !CalamityWorld.revenge) + { + orig(spawnPositionX, spawnPositionY, Type, targetPlayerIndex); + return; + } + + int num = NPC.NewNPC(NPC.GetBossSpawnSource(targetPlayerIndex), spawnPositionX, spawnPositionY, Type, 1); + + if (num == 200 || num == -1) + return; + + if (Main.player[targetPlayerIndex].HeldItem.type == ItemID.BloodySpine) + BrainOfCthulhuAI.SummonedViaItem = true; + + NPC.crimsonBoss = num; + Main.npc[num].target = targetPlayerIndex; + Main.npc[num].timeLeft *= 20; + + previousMusic = Main.curMusic; + + if (Main.netMode == NetmodeID.Server && num < 200) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num); + } + + internal static Texture2D GetTendrilGlow() + { + if (tendrilGlow == null) + { + var tex = new Texture2D(Main.graphics.GraphicsDevice, tendril.Value.Width, tendril.Value.Height); + + var BaseArray = new Color[tex.Width * tex.Height]; + var ColorArray = new Color[tex.Width * tex.Height]; + tendril.Value.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + tex.SetData(ColorArray); + tendrilGlow = tex; + } + + return tendrilGlow; + } + + internal static Texture2D GetBrainGlow() + { + if (brainGlow == null) + { + var tex = new Texture2D(Main.graphics.GraphicsDevice, TextureAssets.Npc[NPCID.BrainofCthulhu].Value.Width, TextureAssets.Npc[NPCID.BrainofCthulhu].Value.Height); + + var BaseArray = new Color[tex.Width * tex.Height]; + var ColorArray = new Color[tex.Width * tex.Height]; + TextureAssets.Npc[NPCID.BrainofCthulhu].Value.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + tex.SetData(ColorArray); + brainGlow = tex; + } + return brainGlow; + } + + internal static Texture2D GetCreeperGlow() + { + if (creeperGlow == null) + { + var tex = new Texture2D(Main.graphics.GraphicsDevice, TextureAssets.Npc[NPCID.Creeper].Value.Width, TextureAssets.Npc[NPCID.Creeper].Value.Height); + + var BaseArray = new Color[tex.Width * tex.Height]; + var ColorArray = new Color[tex.Width * tex.Height]; + TextureAssets.Npc[NPCID.Creeper].Value.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + tex.SetData(ColorArray); + creeperGlow = tex; + } + return creeperGlow; + } + + public override void OnWorldLoad() + { + if (!Main.dedServ) + { + Main.QueueMainThreadAction(() => + { + var reference = ModContent.Request("CalamityMod/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/ReferenceBrainOfCthulhu", AssetRequestMode.ImmediateLoad).Value; + + Main.instance.LoadNPC(NPCID.BrainofCthulhu); + var usedTexture = TextureAssets.Npc[NPCID.BrainofCthulhu].Value; + + int refSize = reference.Width * reference.Height; + var referenceArray = new Color[refSize]; + reference.GetData(referenceArray); + + int texSize = usedTexture.Width * usedTexture.Height; + var textureArray = new Color[texSize]; + usedTexture.GetData(textureArray); + + bool match = true; + + for (var i = 0; i < referenceArray.Length; i++) + if (referenceArray[i] != textureArray[i]) + { + match = false; + break; + } + + _vanillaBoCTexture = match; + }); + } + } + + public override void PostUpdateNPCs() + { + if (!NPC.AnyNPCs(NPCID.BrainofCthulhu)) + BrainOfCthulhuAI.SummonedViaItem = false; + + if (Main.netMode != NetmodeID.Server) + { + if (NPC.crimsonBoss != -1 && CalamityWorld.revenge && Main.npc[NPC.crimsonBoss].ai[0] <= (float)BrainOfCthulhuAI.BrainAIState.Phase2TransitionOpen) + { + bool shouldSpawnTendrilIfNeeded = Main.npc[NPC.crimsonBoss].ai[0] == (float)BrainOfCthulhuAI.BrainAIState.Stunned; + + //Handles sim for tendrils attached to creepers + int index = 0; + foreach (var member in VerletTendrils) + { + NPC creeper = Main.npc[member.creeper]; + + Vector2 startPoint = Main.npc[NPC.crimsonBoss].Center + Main.npc[NPC.crimsonBoss].netOffset + Vector2.UnitY * 32; + + float creeperRatio = index / (float)BrainOfCthulhuAI.GetBrainOfCthuluCreepersCountRevDeath(); + if (index % 2 == 0) + startPoint += new Vector2(MathHelper.Lerp(-24, 0, creeperRatio), 0); + else + startPoint += new Vector2(MathHelper.Lerp(24, 0, creeperRatio), 0); + + List vTendril = VerletTendrils[index].tendril; + + //Tendril's creeper is dead, dangle and reel in. + if (!creeper.active || creeper.type != NPCID.Creeper) + { + float reelInTime = 180; + VerletTendrils[index].reelInTimer++; + + float reelRatio = CalamityUtils.CircInEasing(VerletTendrils[index].reelInTimer / reelInTime, 1); + float reelInSegementedRatio = reelRatio * 28; + float segmentRatio = MathF.Truncate(reelInSegementedRatio); + + if (reelRatio >= 1 || VerletTendrils[index].tendril.Count <= 1) + { + VerletTendrils[index].tendril.Clear(); + index++; + continue; + } + + for(int i = 0; i < 28; i++) + { + var seg = vTendril[i]; + + if (i <= reelInSegementedRatio) + { + seg.position = startPoint; + seg.oldPosition = startPoint; + seg.locked = true; + continue; + } + + seg.position += Main.npc[NPC.crimsonBoss].velocity; + seg.oldPosition += Main.npc[NPC.crimsonBoss].velocity; + + if (i == MathF.Ceiling(reelRatio)) + { + seg.position = startPoint - (Vector2.unitYVector * MathHelper.Lerp(0, 16, segmentRatio)); + } + seg.locked = false; + } + + if (reelRatio < 0.75f && Main.rand.NextBool(3)) + { + Vector2 dir = (vTendril[^1].position - vTendril[^2].position).SafeNormalize(Vector2.unitYVector); + BloodParticle p = new(vTendril[^2].position, dir.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 10f, MathHelper.Pi / 10f)) * Main.rand.NextFloat(4f, 8f), 16, Main.rand.NextFloat(0.5f, 0.75f), Color.Red * 0.75f); + GeneralParticleHandler.SpawnParticle(p); + } + + VerletSimulatedSegment.SimpleSimulation(vTendril, 16, 10, 1.5f); + + index++; + continue; + } + + VerletTendrils[index].reelInTimer = -1; + + //Tendril is gone/getting reeled in, attach to newly spawned creeper. + if (vTendril.Count < 28 && shouldSpawnTendrilIfNeeded) + { + BrainOfCthulhuSystem.VerletTendrils[index] = new(creeper.whoAmI, [], -1); + for (int j = 0; j < 28; j++) + BrainOfCthulhuSystem.VerletTendrils[index].tendril.Add(new(creeper.Center)); + } + + Vector2 endPoint = creeper.Center + creeper.netOffset; + index++; + + if (vTendril is null || vTendril.Count == 0) + continue; + + vTendril[0].position = startPoint; + vTendril[0].locked = true; + vTendril[^1].position = endPoint; + vTendril[^1].locked = true; + + VerletSimulatedSegment.SimpleSimulation(vTendril, 16, 10, 3); + + } + } + } + } + + public override void PostDrawTiles() + { + if (Main.netMode != NetmodeID.Server) + { + if (NPC.crimsonBoss == -1 || !CalamityWorld.revenge || Main.npc[NPC.crimsonBoss].ai[0] >= (float)BrainOfCthulhuAI.BrainAIState.Phase2TransitionClosed || !Main.npc[NPC.crimsonBoss].TryGetAIOverride(out var ai)) + { + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseOpacity(0); + if (Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].IsActive()) + Filters.Scene.Deactivate("CalamityMod:BrainOfCthulhuForcefield"); + } + else + { + if (!Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].IsActive()) + Filters.Scene.Activate("CalamityMod:BrainOfCthulhuForcefield"); + + NPC target = Main.npc[NPC.crimsonBoss]; + Vector2 targetPos = target.Center + target.netOffset; + float shieldOpacity = ai.ShieldOpacity; + float shieldScale = ai.ShieldScale; + targetPos = Vector2.Transform(targetPos - Main.screenPosition, Main.GameViewMatrix.ZoomMatrix) / Main.ScreenSize.ToVector2(); + + Texture2D voronoi = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes3").Value; + Texture2D depthNoise = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Veins").Value; + + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().Shader.Parameters["voronoi"].SetValue(voronoi); + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().Shader.Parameters["depthNoise"].SetValue(depthNoise); + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().Shader.Parameters["uScreenResolution"].SetValue(new Vector2(Main.graphics.GraphicsDevice.Viewport.Width, Main.graphics.GraphicsDevice.Viewport.Height)); + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseProgress(0.15f * shieldScale); + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseOpacity(shieldOpacity); + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseColor(Color.Red); + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseSecondaryColor(new Color(255, 0, 90)); //Crimson color (R:220,G:20,B:60,A:255). // Magenta color (R:255,G:0,B:255,A:255). + Filters.Scene["CalamityMod:BrainOfCthulhuForcefield"].GetShader().UseDirection(targetPos); + } + + if (ScreenBlurStrength == 0f) + { + Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseIntensity(0); + if (Filters.Scene["CalamityMod:RadialBlurShader"].IsActive()) + Filters.Scene.Deactivate("CalamityMod:RadialBlurShader"); + return; + } + + if (NPC.crimsonBoss == -1) + { + ScreenBlurStrength = Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().Intensity * 0.9f; + Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseIntensity(ScreenBlurStrength); + if (ScreenBlurStrength < 0.01f) + ScreenBlurStrength = 0f; + return; + } + + if (Filters.Scene["CalamityMod:RadialBlurShader"].IsLoaded) + { + if (!Filters.Scene["CalamityMod:RadialBlurShader"].IsActive()) + Filters.Scene.Activate("CalamityMod:RadialBlurShader"); + NPC boss = Main.npc[NPC.crimsonBoss]; + float counter = boss.ai[1] - boss.ai[2] - 240; + float distSQ = Main.LocalPlayer.DistanceSQ(boss.Center); + float distanceScaleFactor = 1; + if (distSQ > 592900) //770^2 + distanceScaleFactor = 1 / (1 + (((float)Math.Sqrt(distSQ) - 770) / 32f)); + + Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseIntensity((ScreenBlurStrength + (((float)Math.Cos(counter * MathHelper.TwoPi / 15f) / 2f + 0.5f) * (0.4f * ScreenBlurStrength))) * distanceScaleFactor); + Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().Shader.Parameters["uSaturation"].SetValue(20); + + Vector2 targetPos = Vector2.Transform(boss.Center - Main.screenPosition, Main.GameViewMatrix.ZoomMatrix) / Main.ScreenSize.ToVector2(); + + Filters.Scene["CalamityMod:RadialBlurShader"].GetShader().UseDirection(targetPos); + + } + } + } + + public override void PostUpdateEverything() + { + bool allowBossMusic = false; + if (NPC.crimsonBoss != -1 && Main.npc[NPC.crimsonBoss].active && Main.npc[NPC.crimsonBoss].TryGetAIOverride(out var brainAI) && brainAI.AIState > BrainOfCthulhuAI.BrainAIState.SurfaceSpawnAnimation) + allowBossMusic = true; + + if (((Main.curMusic != MusicID.Boss3 && Main.curMusic != MusicID.OtherworldlyBoss1) || allowBossMusic) && Main.curMusic != MusicID.Boss1) + previousMusic = Main.curMusic; + + if (previousMusic == -1) + previousMusic = MusicID.Crimson; + } +} + diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/CreeperAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/CreeperAI.cs new file mode 100644 index 0000000000..b8c3e0dad8 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/CreeperAI.cs @@ -0,0 +1,779 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.DataStructures; +using CalamityMod.Events; +using CalamityMod.Particles; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; +using static CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu.BrainOfCthulhuAI; +using static CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies.RevengeanceAndDeathAI; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; + +public class CreeperAI : VanillaAIOverride +{ + internal float FlowTime = 0; + internal float FlowAmount => MathHelper.Lerp(0.1f, 0.15f, NPC.localAI[3]); + + internal enum CreeperAIState + { + Idle, + Charge + } + + internal int CreeperID { get => (int)NPC.ai[0]; set => NPC.ai[0] = value; } + internal CreeperAIState AIState { get => (CreeperAIState)NPC.ai[1]; set => NPC.ai[1] = (float)value; } + internal int Time = -1; + internal ref float AttackAngle => ref NPC.ai[2]; + internal ref float CachedValue1 => ref NPC.ai[3]; + internal int CachedValue2 = 0; + internal int PartnerIndex = -1; + internal Vector2 AttackPosition = Vector2.Zero; + internal float ConnectionOpacity = 0f; + + NPC brain => Main.npc[NPC.crimsonBoss]; + BrainOfCthulhuAI bocAI => brain.AIOverride(); + + float bossCounter => bocAI.Time; + + internal bool evenID => CreeperID % 2 == 0; + + int creeperCount + { + get + { + int c = NPC.CountNPCS(NPC.type); + if (c > GetBrainOfCthuluCreepersCountRevDeath()) + c = GetBrainOfCthuluCreepersCountRevDeath(); + return c; + } + } + + int localCreeperID => Main.npc.Where(n => n.active && n.type == NPCID.Creeper).ToList().IndexOf(NPC); + + float CreeperAmountRatio => creeperCount / (float)GetBrainOfCthuluCreepersCountRevDeath(); + + bool useBossAIState = true; + + public override bool EnableMultiplayerSmoothingAheadOfAI => true; + + public override void SetDefaults(Mod mod) + { + NPC.damage = NPC.defDamage = 36; // 64 (1.8x expert scaling) + } + + public override void OnSpawn(Mod mod) + { + NPC.damage = 0; + NPC.netUpdate = true; + } + + + public override bool AI(Mod mod) + { + #region Despawn + if (NPC.crimsonBoss < 0) + { + NPC.active = false; + NPC.netUpdate = true; + return false; + } + #endregion + + #region Targetting + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, default); + #endregion + + if(!Main.dedServ) + BrainOfCthulhuSystem.VerletTendrils[CreeperID].creeper = NPC.whoAmI; + + if (bocAI.AIState < BrainAIState.SurfaceSpawnAnimation) + NPC.damage = 0; + + List bossAIStatesToUse = [ + BrainAIState.UndergroundSpawnAnimation, + BrainAIState.SurfaceSpawnAnimation, + BrainAIState.Stunned, + BrainAIState.CreeperSwipes, + BrainAIState.CreeperSwings, + BrainAIState.CreeperOrbit, + BrainAIState.CreeperSpiral, + BrainAIState.TelekineticOnslaught + ]; + useBossAIState = bossAIStatesToUse.Contains(bocAI.AIState) && bossCounter >= 0; + + if (bocAI.AIState == BrainAIState.UndergroundSpawnAnimation || bocAI.AIState == BrainAIState.SurfaceSpawnAnimation || bocAI.AIState == BrainAIState.Stunned) + NPC.dontTakeDamage = true; + else + NPC.dontTakeDamage = false; + + if (useBossAIState) + switch (bocAI.AIState) + { + case BrainAIState.UndergroundSpawnAnimation: + case BrainAIState.SurfaceSpawnAnimation: + NPC.damage = 0; + SpawnAnimation(); + break; + case BrainAIState.TelekineticOnslaught: + TelekineticOnslaught(); + break; + case BrainAIState.Stunned: + //Only used for when the Creepers are spawned just as the stun is ending. + NPC.velocity *= 0.9f; + NPC.damage = 0; + break; + case BrainAIState.CreeperSwipes: + CreeperSwipes(); + break; + case BrainAIState.CreeperSwings: + CreeperSwings(); + break; + case BrainAIState.CreeperOrbit: + CreeperOrbit(); + break; + case BrainAIState.CreeperSpiral: + CreeperSpiral(); + break; + } + + else + switch (AIState) + { + case CreeperAIState.Idle: + CreeperIdle(); + break; + case CreeperAIState.Charge: + CreeperCharge(); + break; + } + + FlowTime += 0.01f * (2 * (1 + ConnectionOpacity)); + + return false; + } + + #region Attacks + Animations + + private void SpawnAnimation() + { + float baseRotation = MathHelper.TwoPi / (GetBrainOfCthuluCreepersCountRevDeath() / 2f) * (CreeperID / 2f); + Vector2 goalLocation; + float speedCap = 8f; + float accel = 1f; + float acceptableDist = 9216; + Player player = Main.player[brain.target]; + + if (bocAI.SpawnTime != 0 && Time >= 0) //Brain has appeared + { + float brainTime = bossCounter - Math.Abs(bocAI.SpawnTime); + + if (brainTime < 180) + { + Vector2 baseOffset = new Vector2(evenID ? -360 : 360, 0); + Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 120f * (evenID ? -1 : 1))) * 128; + goalLocation = player.Center + baseOffset + rotationOffset; + } + else if (brainTime < 240) + { + Vector2 baseOffset = new Vector2(evenID ? -200 : 200, 64); + Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 60f * (evenID ? -1 : 1))) * 32; + goalLocation = brain.Center + baseOffset + rotationOffset; + speedCap = 12; + accel = 2f; + acceptableDist = 4096; + } + else + { + Vector2 baseOffset = new Vector2(evenID ? -360 : 360, -64); + Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 60f * (evenID ? -1 : 1))) * 128; + goalLocation = brain.Center + baseOffset + rotationOffset; + speedCap = 12; + accel = 2f; + acceptableDist = 4096; + } + Time++; + } + else + { + if (Time >= 0) //Has been brought down + { + Vector2 baseOffset = new Vector2(evenID ? -360 : 360, 0); + Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 120f * (evenID ? -1 : 1))) * 128; + goalLocation = player.Center + baseOffset + rotationOffset; + Time++; + } + else //Hasnt been brought down + { + Vector2 baseOffset = new Vector2(evenID ? -256 : 256, 0); + Vector2 rotationOffset = Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 120f * (evenID ? -1 : 1))) * 64; + goalLocation = brain.Center + baseOffset + rotationOffset; + } + } + + if (NPC.DistanceSQ(goalLocation) > acceptableDist) + { + NPC.velocity += NPC.DirectionTo(goalLocation) * accel; + NPC.velocity = NPC.velocity.ClampMagnitude(0f, speedCap); + } + } + + private void TelekineticOnslaught() + { + if (Time > 0) + { + Point tileCoords = AttackPosition.ToTileCoordinates(); + if (WorldGen.SolidOrSlopedTile(tileCoords.X, tileCoords.Y)) + { + float rayDist = CalamityUtils.PreciseDistanceToTileCollisionHit(brain.Center, AttackAngle, 800, 4); + AttackPosition = brain.Center + (AttackAngle.ToRotationVector2() * (rayDist - 64)); + } + + if (NPC.DistanceSQ(AttackPosition) > 4096) + { + NPC.velocity += NPC.DirectionTo(AttackPosition); + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 10f); + } + else + NPC.velocity *= 0.8f; + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f); + NPC.damage = 0; + } + else + useBossAIState = false; + + Time++; + } + + private void CreeperSwipes() + { + Vector2 goalLocation; + if (bossCounter < 15) + { + useBossAIState = false; + Time = -1; + AIState = CreeperAIState.Idle; + } + + if (brain.AIOverride().AttackList.Contains((byte)NPC.whoAmI)) + { + if (Time < 0) + Time = 0; + } + else + { + if (Time >= 0) + Time = -1; + } + + float baseRotation = MathHelper.TwoPi / (GetBrainOfCthuluCreepersCountRevDeath() / 2f) * (CreeperID / 2f); + bool singleHand = bocAI.AttackFlag; + int handSide = bocAI.AttackSign; + + if (Time == -1) + { + NPC.damage = 0; + NPC.knockBackResist = 0.72f; + + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f); + + if (!singleHand) + goalLocation = brain.Center + (Vector2.UnitY * -32f) + (Vector2.UnitX * (evenID ? -256 : 256)) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * (evenID ? -1 : 1))) * new Vector2(32, 96)); + else + goalLocation = brain.Center + (Vector2.UnitY * -32f) + (Vector2.UnitX * 256 * handSide) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * handSide)) * new Vector2(32, 96)); + + goalLocation += Main.player[brain.target].velocity * 24f; + float distToGoal = NPC.Center.Distance(goalLocation); + NPC.velocity = NPC.DirectionTo(goalLocation) * (2f + MathHelper.Clamp(distToGoal / 24f, 0f, 64f)); + } + else + { + if (Time == 0) + NPC.netUpdate = true; + + NPC.damage = NPC.defDamage; + NPC.knockBackResist = 0f; + + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f); + + float accel = 2f; + float speed = 12f; + + if (Time < brain.AIOverride().SwipeDelay) + { + if (!singleHand) + goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * (evenID ? -300 : 300)) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * (evenID ? -1 : 1))) * new Vector2(32, 96)); + else + goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * 300 * handSide) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * handSide)) * new Vector2(32, 96)); + + goalLocation += Main.player[brain.target].velocity * 24f; + NPC.velocity += NPC.DirectionTo(goalLocation) * accel; + NPC.velocity = NPC.velocity.ClampMagnitude(0f, speed); + } + else + { + if (!singleHand) + goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * (evenID ? -256 : 256)) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * (evenID ? -1 : 1))) * new Vector2(32, 96)); + else + goalLocation = brain.Center + (Vector2.UnitY * -96f) + (Vector2.UnitX * 256 * handSide) + (Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 30f * handSide)) * new Vector2(32, 96)); + + goalLocation.Y += MathHelper.Lerp(0, 420, CalamityUtils.SineInOutEasing(MathHelper.Clamp((Time - brain.AIOverride().SwipeDelay) / 20f, 0f, 1f), 1)); + + if (!singleHand) + goalLocation.X += MathHelper.Lerp(0f, 900f, CalamityUtils.SineInOutEasing(MathHelper.Clamp((Time - (brain.AIOverride().SwipeDelay + 5)) / 55f, 0f, 1f), 1)) * (evenID ? 1 : -1); + else + goalLocation.X += MathHelper.Lerp(0f, 900f, CalamityUtils.SineInOutEasing(MathHelper.Clamp((Time - (brain.AIOverride().SwipeDelay + 5)) / 55f, 0f, 1f), 1)) * (handSide == -1 ? 1 : -1); + + NPC.Center = Vector2.Lerp(NPC.Center, goalLocation, MathHelper.Clamp((Time - brain.AIOverride().SwipeDelay) / 10f, 0f, 1f)); + DisableMultiplayerSmoothing = true; + } + + Time++; + } + } + + private void CreeperSwings() + { + if (brain.AIOverride().AttackList.Contains((byte)NPC.whoAmI)) + { + if (Time < 0) + { + Time = 0; + NPC.netUpdate = true; + if(Main.netMode != NetmodeID.MultiplayerClient) + AttackPosition = NPC.Center; + } + } + else + { + if (Time >= 0) + Time = -1; + } + + if (Time < 0) + { + float baseRotation = (brain.Center - Main.player[brain.target].Center).ToRotation(); + bool evenID = CreeperID % 2 == 0; + Vector2 goalLocation = brain.Center + Vector2.UnitX.RotatedBy(baseRotation + Math.Sin(bossCounter / 60f + CreeperID) * (evenID ? -1 : 1)) * (evenID ? 175 : 250); + if (NPC.DistanceSQ(goalLocation) > 9216) + { + NPC.velocity += NPC.DirectionTo(goalLocation); + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 8f); + } + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f); + } + else + { + Player sharedTarget = Main.player[brain.target]; + Vector2 dashDir = AttackAngle.ToRotationVector2(); + if (!bocAI.OnSecondCreeperPhase) // Swipe Attack + { + float positioningTime = LightSwipeTravelTime + LightSwipeAttackDelay; + + if (Time <= positioningTime) + { + Vector2 goalPosition = sharedTarget.Center - dashDir * 128; + goalPosition += dashDir.RotatedBy(MathHelper.PiOver2) * 16; + NPC.Center = Vector2.Lerp(AttackPosition, goalPosition, CalamityUtils.SineOutEasing(MathHelper.Clamp(Time / (float)LightSwipeTravelTime, 0f, 1f), 1)); + NPC.velocity = Vector2.Zero; + DisableMultiplayerSmoothing = true; + } + else + { + AttackPosition = Vector2.Zero; + NPC.damage = NPC.defDamage; + NPC.knockBackResist = 0f; + int reelbackTime = 22; + + if (Time < (positioningTime + reelbackTime)) + { + float reelBackSpeedExponent = 2.6f; + float reelBackCompletion = Utils.GetLerpValue(0f, reelbackTime, Time - positioningTime, true); + float reelBackSpeed = MathHelper.Lerp(2.5f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent)); + Vector2 reelBackVelocity = dashDir * -reelBackSpeed; + NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f); + + if (Time == positioningTime + reelbackTime - 5) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, NPC.Center); + } + else if (Time == (positioningTime + reelbackTime)) + NPC.velocity = dashDir * 32; + else + { + NPC.velocity *= 0.9f; + if (Time >= positioningTime + reelbackTime + 15) + { + NPC.damage = 0; + Time = -1; + brain.AIOverride().AttackList.Remove((byte)NPC.whoAmI); + AttackPosition = Vector2.Zero; + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f); + return; + } + } + } + } + else //Crush Attack + { + float positioningTime = StrongSwipeTravelTime + StrongSwipeAttackDelay; + + if (Time <= positioningTime) + { + if (AttackPosition == Vector2.Zero) + AttackPosition = NPC.Center; + Vector2 goalPosition = sharedTarget.Center - dashDir * 128; + NPC.Center = Vector2.Lerp(AttackPosition, goalPosition, CalamityUtils.SineOutEasing(MathHelper.Clamp(Time / (float)StrongSwipeTravelTime, 0f, 1f), 1)); + NPC.velocity = Vector2.Zero; + DisableMultiplayerSmoothing = true; + } + else + { + NPC.damage = NPC.defDamage; + NPC.knockBackResist = 0f; + int reelbackTime = 18; + float swingTime = 10f; + + if (Time <= (positioningTime + reelbackTime)) + { + float reelBackSpeedExponent = 2.6f; + float reelBackCompletion = Utils.GetLerpValue(0f, reelbackTime, Time - positioningTime, true); + float reelBackSpeed = MathHelper.Lerp(2.5f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent)); + Vector2 reelBackVelocity = dashDir * -reelBackSpeed; + NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f); + + if (Time == positioningTime + reelbackTime - 5) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, NPC.Center); + + if (Time == (positioningTime + reelbackTime)) + AttackPosition = NPC.Center; + } + else if (Time <= (positioningTime + reelbackTime + swingTime)) + { + if (Main.npc[PartnerIndex].active) + { + float moveDist = 196; + NPC.Center = Vector2.Lerp(AttackPosition, AttackPosition + dashDir * moveDist, (Time - (positioningTime + reelbackTime)) / swingTime); + NPC.velocity = Vector2.Zero; + DisableMultiplayerSmoothing = true; + if (Time == (positioningTime + reelbackTime + swingTime)) + { + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, NPC.Center); + SoundEngine.PlaySound(NPC.HitSound, NPC.Center); + NPC.velocity = dashDir * -8; + Vector2 attackCenter = AttackPosition + dashDir * 200; + if (dashDir.X <= 0) + { + //WaterFoam (0.25 -> 1), SoftRoundExplosion (0.025 -> 0.1), SmokeExplosion(0.05 -> 0.15) + CustomPulse splatter = new(attackCenter, Vector2.Zero, Color.Red, "CalamityMod/Particles/SmokeExplosion", Vector2.One, Main.rand.NextFloatDirection(), 0.05f, 0.15f, 24); + GeneralParticleHandler.SpawnParticle(splatter); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + for (int i = -1; i <= 1; i++) + Projectile.NewProjectile(NPC.GetSource_FromThis(), attackCenter, dashDir.RotatedBy(MathHelper.PiOver2 + (MathHelper.Pi / 6f * i)) * 8f, ProjectileID.BloodShot, BloodShotDamage, 0.5f); + } + } + else + NPC.velocity = dashDir * 19.6f; + } + else if (Time < (positioningTime + reelbackTime + swingTime + 30)) + { + NPC.velocity *= 0.96f; + } + else + { + NPC.damage = 0; + Time = -1; + brain.AIOverride().AttackList.Remove((byte)NPC.whoAmI); + AttackPosition = Vector2.Zero; + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0.5f); + return; + } + } + } + + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f); + Time++; + } + } + + private void CreeperOrbit() + { + if(Main.netMode != NetmodeID.SinglePlayer && CachedValue2 != -1) + { + CreeperCharge(); + return; + } + + var brainAI = brain.AIOverride(); + + if (Main.netMode == NetmodeID.SinglePlayer) + { + if (bossCounter == 0) + { + CachedValue1 = MathHelper.TwoPi / creeperCount * localCreeperID; + AttackPosition = NPC.Center; + AttackAngle = 0; + NPC.netUpdate = true; + } + } + else + { + if (bossCounter == 1) + { + List mainOrbitMembers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.TryGetAIOverride(out var ai) && ai.CachedValue2 == -1).ToList(); + CachedValue1 = MathHelper.TwoPi / mainOrbitMembers.Count * mainOrbitMembers.IndexOf(NPC); + } + else if (bossCounter == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + AttackPosition = NPC.Center; + AttackAngle = 0; + NPC.netUpdate = true; + } + } + float dist = OrbitStandardRadius + ((float)Math.Sin((CachedValue1 * 7) + bossCounter / 20f) * 24); + + if(Main.netMode != NetmodeID.MultiplayerClient) + if (brainAI.AttackList.Contains((byte)NPC.whoAmI)) + { + if (Time < 0) + { + Time = 0; + NPC.netUpdate = true; + } + } + else + { + if (Time >= 0) + { + Time = -1; + NPC.netUpdate = true; + } + } + + if (Time >= 0) + { + float telegraphPeriod = OrbitAttackInterval * 0.25f; + float shiftPeriod = (OrbitAttackInterval - telegraphPeriod) / 2f; + if (Time < telegraphPeriod) + dist = MathHelper.Lerp(dist, OrbitTelegraphRadius, CalamityUtils.SineOutEasing(Time / telegraphPeriod, 1)); + else if (Time < shiftPeriod + telegraphPeriod) + dist = MathHelper.Lerp(OrbitTelegraphRadius, 16, CalamityUtils.SineInOutEasing((Time - telegraphPeriod) / shiftPeriod, 1)); + else + { + dist = MathHelper.Lerp(16, dist, CalamityUtils.SineInOutEasing((Time - telegraphPeriod - shiftPeriod) / shiftPeriod, 1)); + if (Time > OrbitAttackInterval) + { + Time = -2; + brain.AIOverride().AttackList.Remove((byte)NPC.whoAmI); + } + } + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f, 0.1f); + Time++; + } + else + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f, 0.05f); + + float slowDown = (1 - MathHelper.Clamp((bossCounter - OrbitDuration) / 30f, 0f, 1f)); + AttackAngle += (BaseRotationSpeed * (MathHelper.Lerp(1f, 0.5f, CreeperAmountRatio) + (bocAI.OnSecondCreeperPhase ? 1f : 0.5f))) * slowDown * bocAI.AttackSign; + Vector2 rotation = Vector2.UnitX.RotatedBy(CachedValue1 + AttackAngle) * dist; + + if (bossCounter < OrbitSetupDuration) + { + NPC.damage = 0; + NPC.Center = Vector2.Lerp(AttackPosition, bocAI.AttackPosition + rotation, CalamityUtils.SineOutEasing(bossCounter / OrbitSetupDuration, 1)); + } + else + { + NPC.damage = NPC.defDamage; + NPC.Center = bocAI.AttackPosition + rotation; + } + + DisableMultiplayerSmoothing = true; + + } + + private void CreeperSpiral() + { + int tendrilID = (CreeperID % TendrilCount) + 1; + + if (bossCounter == 0 && Main.netMode != NetmodeID.MultiplayerClient) + { + AttackPosition = NPC.Center; + List myGroup = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && (n.ai[0] % TendrilCount) + 1 == tendrilID).ToList(); + CachedValue1 = myGroup.IndexOf(NPC); + CachedValue2 = myGroup.Count; + + AttackAngle = 0; + NPC.netUpdate = true; + } + + int index = (int)CachedValue1; + int groupCount = CachedValue2; + bool isLast = groupCount > 1 && index == (groupCount - 1); + float placementRatio = (index + 1) / (float)(groupCount + 1); + + float spiralAngle = bocAI.AttackRotation; + float goalAngle = spiralAngle + ((MathHelper.TwoPi / TendrilCount) * tendrilID); + + float angularVelocity = (goalAngle - AttackAngle) / (16f + (placementRatio * 16f)); + + AttackAngle += angularVelocity; + + float goalRadius = TendrilStartDistance + (TendrilLength * placementRatio); + goalRadius += (float)Math.Sin(bossCounter / 20f) * MathHelper.Lerp(MaxCreeperSway, 0, groupCount / (float)(GetBrainOfCthuluCreepersCountRevDeath() / 3)) * (index % 2 == 0 ? -1 : 1); + + Vector2 angleVec = AttackAngle.ToRotationVector2(); + Vector2 position = brain.Center + (angleVec * goalRadius); + if (bossCounter >= SpiralSetupTime) + { + NPC.Center = position; + DisableMultiplayerSmoothing = true; + + NPC.damage = NPC.defDamage; + NPC.knockBackResist = 0f; + + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f); + } + else if (bossCounter < SpiralSetupTime / 10f) + NPC.velocity *= 0.66f; + else + { + NPC.velocity = Vector2.Zero; + float lerp = (bossCounter - (SpiralSetupTime / 10f)) / (float)(SpiralSetupTime * 0.9f); + NPC.Center = Vector2.Lerp(AttackPosition, position, CalamityUtils.SineInOutEasing(MathHelper.Clamp(lerp, 0f, 1f), 1)); + DisableMultiplayerSmoothing = true; + } + + if (Main.dedServ && bossCounter > SpiralSetupTime && isLast && bossCounter % 15 == 0) //These projectiles are multiplayer exclusive to punish players outside the spiral + { + //explicitly does no knockback to allow player to more easily get back in the spiral + Projectile.NewProjectileDirect(NPC.GetSource_FromThis(), NPC.Center, angleVec.RotatedBy(MathHelper.Pi / 12f) * 18f, ProjectileID.BloodShot, BloodShotDamage, 0f).timeLeft /= 4; + Projectile.NewProjectileDirect(NPC.GetSource_FromThis(), NPC.Center, angleVec * 18f, ProjectileID.BloodShot, BloodShotDamage, 0f).timeLeft /= 4; + Projectile.NewProjectileDirect(NPC.GetSource_FromThis(), NPC.Center, angleVec.RotatedBy(-MathHelper.Pi / 12f) * 18f, ProjectileID.BloodShot, BloodShotDamage, 0f).timeLeft /= 4; + } + } + + private void CreeperIdle() + { + if (Time == 0) //Originally this would be set by Brain. This currently doesn't happen due to idle phase speed up + { + AIState = CreeperAIState.Charge; + return; + } + + NPC.knockBackResist = 0.72f; + NPC.damage = 0; + + float baseRotation = MathHelper.TwoPi / (GetBrainOfCthuluCreepersCountRevDeath() / 2f) * (CreeperID / 2f); + Vector2 goalLocation = brain.Center + (Vector2.UnitX * (evenID ? -256 : 256)) + Vector2.UnitX.RotatedBy(baseRotation + (bossCounter / 60f * (evenID ? -1 : 1))) * 64; + if (NPC.DistanceSQ(goalLocation) > 9216) + { + NPC.velocity += NPC.DirectionTo(goalLocation); + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 8f); + } + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f); + Time = -1; + CachedValue2 = -1; + AttackPosition = Vector2.Zero; + } + + private void CreeperCharge() + { + Player target = Main.player[CachedValue2]; + + if (Time < CreeperChargePositioningTime) + { + Vector2 goalLocation = target.Center + ((NPC.Center - target.Center).SafeNormalize(-Vector2.UnitY).RotatedBy((evenID ? -MathHelper.PiOver4 : MathHelper.PiOver4)) * 96); + if (NPC.DistanceSQ(goalLocation) > 4096) + { + NPC.velocity += NPC.DirectionTo(goalLocation); + NPC.velocity = NPC.velocity.ClampMagnitude(0f, 12f); + } + ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 1f); + } + else + { + NPC.damage = NPC.defDamage; + NPC.knockBackResist = 0f; + + if (Time < (CreeperChargePositioningTime + CreeperChargeWindUpTime)) + { + float reelBackSpeedExponent = 2.6f; + float reelBackCompletion = Utils.GetLerpValue(0f, CreeperChargeWindUpTime, Time - CreeperChargePositioningTime, true); + float reelBackSpeed = MathHelper.Lerp(2.5f, 16f, MathF.Pow(reelBackCompletion, reelBackSpeedExponent)); + Vector2 reelBackVelocity = NPC.DirectionTo(target.Center) * -reelBackSpeed; + NPC.velocity = Vector2.Lerp(NPC.velocity, reelBackVelocity, 0.25f); + + if (Time == CreeperChargePositioningTime + CreeperChargeWindUpTime - 5) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, NPC.Center); + } + else if (Time == CreeperChargePositioningTime + CreeperChargeWindUpTime) + NPC.velocity = NPC.DirectionTo(target.Center) * 24; + else + { + NPC.velocity *= 0.975f; + if (Time >= CreeperChargePositioningTime + CreeperChargeWindUpTime + 30) + { + NPC.damage = 0; + Time = -10; + AIState = CreeperAIState.Idle; + return; + } + } + } + Time++; + } + + #endregion + + public override void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter) + { + binaryWriter.Write(Time); + binaryWriter.Write(CachedValue2); + binaryWriter.Write(PartnerIndex); + + binaryWriter.WritePackedWorldPosition(AttackPosition); + } + + public override void ReceiveExtraAI(BitReader bitReader, BinaryReader binaryReader) + { + Time = binaryReader.ReadInt32(); + CachedValue2 = binaryReader.ReadInt32(); + PartnerIndex = binaryReader.ReadInt32(); + + AttackPosition = binaryReader.ReadPackedWorldPosition(); + } + + public override void HitEffect(Mod mod, NPC.HitInfo hit) + { + if (!Main.dedServ && NPC.life <= 0) + { + List verletTendril = BrainOfCthulhuSystem.VerletTendrils[CreeperID].tendril; + verletTendril[^1].position = NPC.Center; + verletTendril[^1].oldPosition = NPC.Center; + verletTendril[^1].locked = false; + + for (int i = 0; i < 5; i++) + { + Vector2 dir = (verletTendril[^1].position - verletTendril[^2].position).SafeNormalize(Vector2.unitYVector); + BloodParticle p = new(verletTendril[^2].position, dir.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 10f, MathHelper.Pi / 10f)) * Main.rand.NextFloat(6f, 10f), 24, Main.rand.NextFloat(0.5f, 1f), Color.Yellow * 0.75f); + GeneralParticleHandler.SpawnParticle(p); + } + } + } + + public override bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) => false; +} + diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.cs new file mode 100644 index 0000000000..2e454be5c8 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.cs @@ -0,0 +1,231 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; + +[AutoloadBossHead] +public class FalseBrain : ModNPC, ILocalizedModType +{ + public new string LocalizationCategory => "NPCs"; + public override string BossHeadTexture => "Terraria/Images/NPC_Head_Boss_23"; + + public override void SetStaticDefaults() + { + this.HideFromBestiary(); + Main.npcFrameCount[Type] = 4; + } + + public override void SetDefaults() + { + NPC.width = 160; + NPC.height = 110; + NPC.damage = 0; + NPC.lifeMax = 1; + NPC.knockBackResist = 0f; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.boss = true; + NPC.immortal = true; + NPC.dontTakeDamage = true; + NPC.chaseable = false; + NPC.npcSlots = 0f; + NPC.netAlways = true; + NPC.ShowNameOnHover = false; + Music = MusicID.Boss3; + SceneEffectPriority = (SceneEffectPriority)(-1); + + NPC.localAI[0] = Main.rand.Next(6); + + if(BrainOfCthulhuSystem.IsBrainOfCthulhuTextureVanilla) + NPC.localAI[1] = 1 + Main.rand.NextFloat(-0.25f, 0.25f); + else + NPC.localAI[1] = 1 + (Main.rand.NextFloat(0.25f, 0.75f) * (Main.rand.NextBool() ? -1 : 1)); + } + private int Variant => (int)NPC.localAI[0]; + private float Angle => NPC.ai[0]; + private ref float Time => ref NPC.ai[1]; + internal bool BeenHit = false; + int AttackTime = 0; + int SpawnTime = 60; + + internal static float TimeDivisor => 360f; + internal float DrawPriority => (float)Math.Cos(-Time * MathHelper.TwoPi / TimeDivisor); + internal static List blackListedProjectiles = []; + + public override void AI() + { + if (NPC.crimsonBoss == -1) + { + NPC.active = false; + return; + } + + NPC brain = Main.npc[NPC.crimsonBoss]; + NPC.GivenName = brain.GivenOrTypeName + $": {brain.life}/{brain.lifeMax}"; + + if (brain.AIOverride().AttackFlag) + BeenHit = true; + + if (BeenHit) + { + NPC.dontTakeDamage = true; + + if (AttackTime == 60) + NPC.active = false; + + AttackTime++; + } + else + { + float lerp = CalamityUtils.SineInOutEasing(MathHelper.Clamp(SpawnTime / -30f, 0f, 1f), 1); + float baseDist = 240; + float circleDist = 480; + if (SpawnTime != -30) + { + baseDist = MathHelper.Lerp(480, 240, lerp); + circleDist = MathHelper.Lerp(240, 480, lerp); + } + NPC.Center = brain.AIOverride().AttackPosition + Vector2.UnitX.RotatedBy(Angle) * (baseDist + (circleDist * ((float)Math.Sin(-Time * MathHelper.TwoPi / TimeDivisor) / 2f + 0.5f))); + NPC.Center += Vector2.UnitX.RotatedBy(Angle + MathHelper.PiOver2) * (90 * (float)Math.Cos(Time * MathHelper.TwoPi / TimeDivisor)); + } + + if (SpawnTime > 0) + { + if (--SpawnTime == 0) + NPC.dontTakeDamage = false; + } + else if (SpawnTime > -30) + Time += --SpawnTime / -30f; + else + Time++; + } + + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) + { + SmiteFool(player); + } + + public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) + { + if (!projectile.Calamity().IgnoreBoCIllusions && projectile.owner != -1) + SmiteFool(Main.player[projectile.owner]); + } + + private void SmiteFool(Player fool) + { + if (!BeenHit) + { + for (int i = 0; i < 6; i++) + { + Vector2 dir = fool.Center - NPC.Center; + int lifeTime = 24; + dir /= lifeTime / 2f * 5f; + dir *= i; + DirectionalPulseRing pulse = new(NPC.Center, dir, i % 2 == 0 ? Color.Red : Color.Orange, new Vector2(0.5f, 1), dir.ToRotation(), 0f, i / 5f, lifeTime + 8); + GeneralParticleHandler.SpawnParticle(pulse); + } + + BeenHit = true; + SoundEngine.PlaySound(BrainOfCthulhuAI.Laugh, NPC.Center); + fool.AddBuff(BuffID.Darkness, 900); + fool.AddBuff(BuffID.Bleeding, 900); + fool.AddBuff(BuffID.Confused, 60); + int timeToAdd = 600; + int bbIndex = fool.buffType.ToList().IndexOf(ModContent.BuffType()); + if (bbIndex != -1) + { + timeToAdd /= 2; + timeToAdd += fool.buffTime[bbIndex]; + } + fool.AddBuff(ModContent.BuffType(), timeToAdd); + + fool.Calamity().adrenaline = 0; + + NPC.dontTakeDamage = true; + } + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += 0.2f * NPC.localAI[1]; + if ((int)NPC.frameCounter > 3) + NPC.frameCounter = 0; + } + + internal void DrawSelf(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D tex; + Rectangle frame; + + Vector2 scaleDistort = new Vector2((float)Math.Cos(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi * 2) / 2f); + Vector2 scaleAddition = Vector2.zeroVector; + float endLerp = AttackTime / 60f; + float startLerp = SpawnTime / 60f; + + if (BrainOfCthulhuSystem.IsBrainOfCthulhuTextureVanilla) + { + tex = TextureAssets.Npc[Type].Value; + frame = tex.Frame(7, 4, Variant, (int)NPC.frameCounter); + } + else + { + tex = TextureAssets.Npc[NPCID.BrainofCthulhu].Value; + frame = tex.Frame(1, 8, 0, 4 + (int)NPC.frameCounter); + + switch(Variant) + { + case 0: + scaleAddition = new(-0.125f, 0.25f); + break; + case 1: + scaleAddition = new(0.25f, -0.125f); + break; + case 2: + drawColor = Color.Lerp(drawColor, Color.Red.MultiplyRGB(drawColor), 0.5f); + break; + case 3: + drawColor = Color.Lerp(drawColor, Color.Orange.MultiplyRGB(drawColor), 0.5f); + break; + case 4: + drawColor = Color.Lerp(drawColor, Color.Yellow.MultiplyRGB(drawColor), 0.5f); + break; + case 5: + scaleAddition = new(0.1625f, 0.1625f); + break; + case 6: + scaleAddition = new(-0.1625f, -0.1625f); + break; + + } + } + + if (SpawnTime > 0) + { + drawColor *= (1 - startLerp); + scaleDistort *= startLerp; + } + else if (AttackTime > 0) + { + drawColor = Color.Lerp(drawColor, Color.Red, endLerp) * (1 - endLerp); + scaleDistort *= endLerp; + } + else + scaleDistort = Vector2.Zero; + + spriteBatch.Draw(tex, NPC.Center + (Vector2.UnitY * 16) - screenPos, frame, drawColor, NPC.rotation, frame.Size() * 0.5f, (Vector2.One + scaleAddition + scaleDistort) * NPC.scale, 0, 0); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) => false; +} diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.png b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.png new file mode 100644 index 0000000000..9b8a74f078 Binary files /dev/null and b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.png differ diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/ReferenceBrainOfCthulhu.png b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/ReferenceBrainOfCthulhu.png new file mode 100644 index 0000000000..cdb94e0cda Binary files /dev/null and b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/ReferenceBrainOfCthulhu.png differ diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs deleted file mode 100644 index e458db81c1..0000000000 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs +++ /dev/null @@ -1,1519 +0,0 @@ -using System; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses -{ - public static class BrainOfCthulhuAI - { - public const float TimeBeforeCreeperAttack = 600f; - public const float CreeperTelegraphTime = 180f; - private const float SpinVelocity = 12f; - private const int SpinRadius = 45; - - public static bool BuffedBrainofCthulhuAI(NPC npc, Mod mod) - { - // whoAmI variable - NPC.crimsonBoss = npc.whoAmI; - - 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) - { - // Ignore tank players, target low HP players, Brain is smart - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - } - - bool enrage = true; - int targetTileX = (int)Main.player[npc.target].Center.X / 16; - int targetTileY = (int)Main.player[npc.target].Center.Y / 16; - - Tile tile = Framing.GetTileSafely(targetTileX, targetTileY); - if (tile.WallType == WallID.CrimstoneUnsafe) - enrage = false; - - float enrageScale = bossRush ? 1.5f : death ? 0.5f : 0f; - if (((npc.position.Y / 16f) < Main.worldSurface && enrage) || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 0.5f; - } - if (!Main.player[npc.target].ZoneCrimson || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } - - // Despawn check - bool despawn = Main.player[npc.target].dead && !bossRush; - - // Despawn - if (despawn) - { - if (npc.localAI[3] < 120f) - npc.localAI[3] += 1f; - - if (npc.localAI[3] > 60f) - npc.velocity.Y += (npc.localAI[3] - 60f) * 0.25f; - } - else if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - - // Extra distance for teleports if enraged - int teleportDistanceIncrease = (int)Math.Round(enrageScale * 3); - - // Spawn Creepers - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - int brainOfCthuluCreepersCount = GetBrainOfCthuluCreepersCountRevDeath(); - float attackTimerIncrement = 15f; - for (int i = 0; i < brainOfCthuluCreepersCount; i++) - { - float brainX = npc.Center.X; - float brainY = npc.Center.Y; - brainX += Main.rand.Next(-npc.width, npc.width); - brainY += Main.rand.Next(-npc.height, npc.height); - - int creeperSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)brainX, (int)brainY, NPCID.Creeper, 0, 0f, i * attackTimerIncrement); - Main.npc[creeperSpawn].velocity = new Vector2(Main.rand.Next(-30, 31) * 0.1f, Main.rand.Next(-30, 31) * 0.1f); - Main.npc[creeperSpawn].netUpdate = true; - } - } - - // Despawn - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 6000f) - { - npc.active = false; - npc.life = 0; - - if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } - } - - // Phase 2 - if (npc.ai[0] < 0f) - { - if (Main.getGoodWorld) - NPC.brainOfGravity = npc.whoAmI; - - // Spawn gore - if (npc.localAI[2] == 0f) - { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); - - npc.localAI[2] = 1f; - - if (!Main.dedServ) - { - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 392, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 393, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 394, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 395, 1f); - } - - for (int j = 0; j < 20; j++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Phases - - // Start spinning, create additional afterimages, shoot projectiles and charging phase - bool phase3 = lifeRatio < 0.8f; - - // Fire projectiles from 2 locations phase - bool phase4 = lifeRatio < 0.6f; - - // Fire projectiles from 4 locations phase - bool phase5 = lifeRatio < 0.4f; - - // Spin faster, shoot faster projectiles and begin teleporting from cardinal directions phase - bool phase6 = lifeRatio < 0.25f; - - // Super fast spin and charges phase - bool phase7 = lifeRatio < 0.1f; - - // Spawn Creepers in Master Mode - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 1f && death && phase3) - { - npc.localAI[0] = 2f; - SpawnMasterModeCreepers(); - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 2f && death && phase5) - { - npc.localAI[0] = 3f; - SpawnMasterModeCreepers(); - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 3f && death && phase7) - { - npc.localAI[0] = 4f; - SpawnMasterModeCreepers(); - } - - void SpawnMasterModeCreepers() - { - int brainOfCthuluCreepersCount = GetBrainOfCthuluCreepersCountRevDeath() / 4; - float attackTimerIncrement = 15f * 4; - for (int i = 0; i < brainOfCthuluCreepersCount; i++) - { - float brainX = npc.Center.X; - float brainY = npc.Center.Y; - brainX += Main.rand.Next(-npc.width, npc.width); - brainY += Main.rand.Next(-npc.height, npc.height); - - int creeperSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)brainX, (int)brainY, NPCID.Creeper, 0, 0f, i * attackTimerIncrement); - Main.npc[creeperSpawn].velocity = new Vector2(Main.rand.Next(-30, 31) * 0.1f, Main.rand.Next(-30, 31) * 0.1f); - Main.npc[creeperSpawn].netUpdate = true; - } - } - - // Whether the fucking thing is spinning or not, dipshit - bool spinning = npc.ai[0] == -4f; - - // Spin variables - float spinVelocity = SpinVelocity; - int spinRadius = SpinRadius; - if (phase7) - { - spinVelocity *= 2f; - spinRadius *= 2; - } - else if (phase6) - { - spinVelocity *= 1.5f; - spinRadius = (int)(SpinRadius * 1.5f); - } - - // Charge variables - float chargeVelocity = (death ? 18f : 15f) + 3f * enrageScale; - if (phase7) - chargeVelocity *= 1.2f; - - // KnockBack - float baseKnockBackResist = death ? 0.1f : 0.3f; - if (!phase3) - npc.knockBackResist = GetCrimsonBossKnockBack(npc, CalamityGlobalNPC.GetActivePlayerCount(), lifeRatio, baseKnockBackResist); - else - npc.knockBackResist = 0f; - - // Gain defense while spinning - npc.defense = npc.defDefense + (spinning ? 7 : 0); - - // Take damage - npc.dontTakeDamage = false; - - // Target distance X - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - - // Charge - if (!spinning) - { - // Not charging - if (npc.ai[0] != -5f) - { - // Rubber band movement - if (!despawn) - { - float velocityScale = death ? 6f : 4.5f; - float velocityBoost = velocityScale * (1f - lifeRatio); - float nonChargeSpeed = (death ? 24f : 18f) + velocityBoost + 3f * enrageScale; - if (Main.getGoodWorld) - nonChargeSpeed *= 1.15f; - - float minInertia = death ? 50f : 75f; - float maxInertia = death ? 70f : 100f; - float inertia = MathHelper.Lerp(minInertia, maxInertia, lifeRatio); - - Vector2 destination = Main.player[npc.target].Center + (death ? Main.player[npc.target].velocity * 20f * enrageScale : Vector2.Zero); - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitY) * nonChargeSpeed; - npc.velocity = (npc.velocity * (inertia - 1f) + idealVelocity) / inertia; - } - } - - // Charge, -5 - else - { - if (!despawn) - npc.ai[1] += 1f; - - float chargeDistance = 960f; // 60 tile charge distance - float chargeDuration = chargeDistance / chargeVelocity; - float chargeGateValue = 10f; - - if (npc.ai[1] < chargeGateValue) - { - // Avoid cheap bullshit - npc.damage = 0; - } - else - { - // Set damage - npc.damage = npc.defDamage; - } - - // Teleport - float timeGateValue = chargeDuration + chargeGateValue; - if (npc.ai[1] >= timeGateValue) - { - npc.ai[0] = -6f; - npc.ai[1] = 0f; - float maxTeleportPhaseDurationReduction = 60f; - float lerpHPScalar = (0.8f - lifeRatio) / 0.8f; - npc.localAI[1] = MathHelper.Lerp(0f, maxTeleportPhaseDurationReduction, lerpHPScalar); - npc.netUpdate = true; - } - - // Charge sound and velocity - else if (npc.ai[1] == chargeGateValue && !despawn) - { - // Sound - SoundEngine.PlaySound(SoundID.ForceRoarPitched, npc.Center); - - // Velocity - npc.velocity = (Main.player[npc.target].Center + (death ? Main.player[npc.target].velocity * 20f * enrageScale : Vector2.Zero) - npc.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; - if (Main.getGoodWorld) - npc.velocity *= 1.15f; - } - } - } - - // Circle around, -4 - if (spinning) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Charge sound - if (npc.ai[2] == 0f) - { - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - - if (CalamityWorld.LegendaryMode) - { - if (!Main.dedServ) - { - if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(BuffID.Confused, 90); - } - } - } - - // Velocity - float velocity = MathHelper.TwoPi / spinRadius; - npc.velocity = npc.velocity.RotatedBy(-(double)velocity * npc.ai[1]); - - npc.ai[2] += 1f; - - float timer = (death ? 0f : 30f) + npc.ai[3]; - - // Move the brain away from the target in order to ensure fairness - if (npc.ai[2] >= timer - 5f) - { - float minChargeDistance = 640f; // 40 tile distance - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < minChargeDistance) - { - npc.ai[2] -= 1f; - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * (-chargeVelocity - 2f * enrageScale); - if (death) - npc.velocity *= 1.5f; - if (Main.getGoodWorld) - npc.velocity *= 1.15f; - } - } - - // Charge at target - if (npc.ai[2] >= timer) - { - // Shoot projectiles from 4 directions, alternating between diagonal and cardinal - float bloodShotVelocity = (death ? 7.5f : 6f) + enrageScale; - - // Scale projectile velocity - float phase7ProjectileVelocityMult = 1.2f; - float phase6ProjectileVelocityMult = 1.1f; - if (phase7) - bloodShotVelocity *= phase7ProjectileVelocityMult; - else if (phase6) - bloodShotVelocity *= phase6ProjectileVelocityMult; - - if (phase4) - { - bool alternativeFire = npc.ai[3] % 2f == 0f; - bool diagonalShots = alternativeFire || !phase5; - bool otherQuadrants = Main.rand.NextBool(); - int startingIndex = (otherQuadrants && !phase5) ? 2 : 0; - int totalProjectileSpreads = (phase5 || startingIndex == 2) ? 4 : 2; - for (int i = startingIndex; i < totalProjectileSpreads; i++) - { - Vector2 position = npc.Center; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - - switch (i) - { - case 0: - - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - if (diagonalShots) - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - else - position.Y = Main.LocalPlayer.Center.Y; - - break; - - case 1: - - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - if (diagonalShots) - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - else - position.X = Main.LocalPlayer.Center.X; - - break; - - case 2: - - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - if (diagonalShots) - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - else - position.Y = Main.LocalPlayer.Center.Y; - - break; - - case 3: - - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - if (diagonalShots) - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - else - position.X = Main.LocalPlayer.Center.X; - - break; - - default: - break; - } - - Vector2 projectileVelocity = (Main.player[npc.target].Center - position).SafeNormalize(Vector2.UnitY) * bloodShotVelocity; - float minFiringDistance = 560f; // 35 tile distance - bool firedFromRealBrain = Vector2.Distance(position, npc.Center) < 8f; - if (Vector2.Distance(position, Main.player[npc.target].Center) > minFiringDistance && !firedFromRealBrain) // The projectiles can only be fired if the target is more than 15 tiles away from the firing position - { - bool canHit = Collision.CanHitLine(position, 1, 1, Main.player[npc.target].Center, 1, 1); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ProjectileID.BloodShot; - int damage = npc.GetProjectileDamage(type); - int numProj = death ? 9 : 4; - int spread = death ? 32 : 15; - if (phase7) - { - numProj = death ? 7 : 2; - spread = death ? 25 : 10; - } - else if (phase5) - { - numProj = death ? 8 : 3; - spread = death ? 40 : 20; - } - - float rotation = MathHelper.ToRadians(spread); - for (int j = 0; j < numProj; j++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), position + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 10f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; - if (!canHit) - Main.projectile[proj].tileCollide = false; - } - } - } - } - } - - Vector2 projectileVelocity2 = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * bloodShotVelocity; - bool canHit2 = Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ProjectileID.BloodNautilusShot; - int damage = npc.GetProjectileDamage(type); - int numProj = death ? 13 : 7; - int spread = death ? 60 : 40; - if (phase7) - { - numProj = death ? 7 : 2; - spread = death ? 23 : 5; - } - else if (phase5) - { - numProj = death ? 8 : 2; - spread = death ? 30 : 10; - } - else if (phase4) - { - numProj = death ? 9 : 3; - spread = death ? 30 : 10; - } - - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity2.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 10f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; - if (!canHit2) - Main.projectile[proj].tileCollide = false; - } - } - - // Complete stop - npc.velocity *= 0f; - - npc.ai[0] = -5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - - // Pick teleport location - else if (npc.ai[0] == -1f || npc.ai[0] == -6f) - { - // Set damage - npc.damage = npc.defDamage; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Go to phase 3 and spin - if (phase3 && npc.ai[0] == -1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * spinVelocity; - npc.ai[0] = -4f; - npc.ai[1] = playerLocation < 0 ? 1f : -1f; - npc.ai[2] = 0f; - - int maxRandomTime = phase7 ? (death ? 10 : 30) : (death ? 20 : 60); - npc.ai[3] = Main.rand.Next(maxRandomTime) + 1; - npc.localAI[1] = 0f; - npc.alpha = 0; - npc.netUpdate = true; - } - - if (!despawn) - npc.localAI[1] += 1f; - - if (npc.localAI[1] >= 210f) - { - npc.localAI[1] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - - int numTeleportTries = 0; - int maxTeleportTries = 100; - int teleportTileX; - int teleportTileY; - bool cardinal = Main.rand.NextBool(); - bool aboveOrBelow = Main.rand.NextBool(); - do - { - numTeleportTries++; - teleportTileX = (int)Main.player[npc.target].Center.X / 16; - teleportTileY = (int)Main.player[npc.target].Center.Y / 16; - - int minX = 14; - int maxX = 17; - int minY = 14; - int maxY = 17; - if (cardinal && phase6) - { - if (aboveOrBelow) - { - minX = 0; - maxX = 3; - minY = 21; - maxY = 24; - } - else - { - minX = 21; - maxX = 24; - minY = 0; - maxY = 3; - } - } - - int teleportX = Main.rand.Next(minX, maxX + 1) + teleportDistanceIncrease; - int teleportY = Main.rand.Next(minY, maxY + 1) + teleportDistanceIncrease; - - if (Main.rand.NextBool()) - teleportX *= -1; - - if (Main.rand.NextBool()) - teleportY *= -1; - - teleportTileX += teleportX; - teleportTileY += teleportY; - - if (numTeleportTries > maxTeleportTries || !WorldGen.SolidTile(teleportTileX, teleportTileY)) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[3] = 0f; - npc.ai[0] = npc.ai[0] == -6f ? -7f : -2f; - npc.ai[1] = teleportTileX; - npc.ai[2] = teleportTileY; - npc.ForceNetUpdate(); - - break; - } - else - { - cardinal = Main.rand.NextBool(); - aboveOrBelow = Main.rand.NextBool(); - } - } - while (numTeleportTries <= maxTeleportTries); - } - } - } - - // Teleport and turn invisible - else if (npc.ai[0] == -2f || npc.ai[0] == -7f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.9f; - - if (Main.netMode != NetmodeID.SinglePlayer) - npc.ai[3] += 15f; - else - npc.ai[3] += 25f; - - if (npc.ai[3] >= 255f) - { - npc.ai[3] = 255f; - npc.position.X = npc.ai[1] * 16f - (npc.width / 2); - npc.position.Y = npc.ai[2] * 16f - (npc.height / 2); - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - npc.ai[0] = npc.ai[0] == -7f ? -8f : -3f; - - // Move non-charging Creepers to new Brain location - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC creeper = Main.npc[i]; - if (creeper.active && creeper.type == NPCID.Creeper) - { - bool creeperCanTeleport = creeper.ai[0] == 0f; - if (creeperCanTeleport) - { - creeper.position.X = npc.position.X; - creeper.position.Y = npc.position.Y; - } - } - } - - npc.ForceNetUpdate(); - } - - npc.alpha = (int)npc.ai[3]; - } - - // Become visible - else if (npc.ai[0] == -3f || npc.ai[0] == -8f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.netMode != NetmodeID.SinglePlayer) - npc.ai[3] -= 15f; - else - npc.ai[3] -= 25f; - - if (npc.ai[3] <= 0f) - { - if (npc.ai[0] == -8f) - { - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * spinVelocity; - - npc.ai[0] = -4f; - npc.ai[1] = playerLocation < 0 ? 1f : -1f; - npc.ai[2] = 0f; - - int maxRandomTime = phase7 ? (death ? 10 : 30) : (death ? 20 : 60); - npc.ai[3] = Main.rand.Next(maxRandomTime) + 1; - } - else - { - npc.ai[3] = 0f; - npc.ai[2] = 0f; - npc.ai[1] = 0f; - npc.ai[0] = -1f; - } - npc.ForceNetUpdate(); - } - - npc.alpha = (int)npc.ai[3]; - } - } - - // Phase 1 - else - { - // Avoid cheap bullshit - npc.damage = 0; - - // Creeper count - int creeperCount = NPC.CountNPCS(NPCID.Creeper); - if (creeperCount > GetBrainOfCthuluCreepersCountRevDeath()) - creeperCount = GetBrainOfCthuluCreepersCountRevDeath(); - - float creeperRatio = creeperCount / (float)GetBrainOfCthuluCreepersCountRevDeath(); - float velocityScale = MathHelper.Lerp(0f, 2f, 1f - creeperRatio) + enrageScale; - - // Check for phase 2 - bool phase2 = creeperCount <= 0; - - // Go to phase 2 - if (phase2) - { - npc.ai[0] = -1f; - npc.localAI[1] = 0f; - npc.alpha = 0; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - return false; - } - - // Move towards target - if (!despawn) - { - Vector2 brainCenterPhase1 = npc.Center; - float targetXDistPhase1 = Main.player[npc.target].Center.X - brainCenterPhase1.X; - float targetYDistPhase1 = Main.player[npc.target].Center.Y - brainCenterPhase1.Y; - float targetDistancePhase1 = (float)Math.Sqrt(targetXDistPhase1 * targetXDistPhase1 + targetYDistPhase1 * targetYDistPhase1); - float maxMoveVelocity = (death ? 4f : 1.5f) + velocityScale; - if (Main.getGoodWorld) - maxMoveVelocity *= 2f; - - if (targetDistancePhase1 < maxMoveVelocity) - { - npc.velocity.X = targetXDistPhase1; - npc.velocity.Y = targetYDistPhase1; - } - else - { - targetDistancePhase1 = maxMoveVelocity / targetDistancePhase1; - npc.velocity.X = targetXDistPhase1 * targetDistancePhase1; - npc.velocity.Y = targetYDistPhase1 * targetDistancePhase1; - } - } - - // Pick a teleport location - if (npc.ai[0] == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!despawn) - npc.localAI[1] += (death ? 2f : 1f) + velocityScale; - - if (npc.localAI[1] >= (death ? 540f : 360f)) - { - // Teleport location - npc.localAI[1] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - - int phase1TeleportTries = 0; - int maxTeleportTries = 100; - int phase1TeleportTileX; - int phase1TeleportTileY; - do - { - phase1TeleportTries++; - phase1TeleportTileX = (int)Main.player[npc.target].Center.X / 16; - phase1TeleportTileY = (int)Main.player[npc.target].Center.Y / 16; - - int min = 28 + teleportDistanceIncrease; - int max = 30 + teleportDistanceIncrease; - - if (Main.rand.NextBool()) - phase1TeleportTileX += Main.rand.Next(min, max); - else - phase1TeleportTileX -= Main.rand.Next(min, max); - - if (Main.rand.NextBool()) - phase1TeleportTileY += Main.rand.Next(min, max); - else - phase1TeleportTileY -= Main.rand.Next(min, max); - - if (phase1TeleportTries > maxTeleportTries || (!WorldGen.SolidTile(phase1TeleportTileX, phase1TeleportTileY) && Collision.CanHit(new Vector2(phase1TeleportTileX * 16, phase1TeleportTileY * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))) - { - npc.ai[0] = 1f; - npc.ai[1] = phase1TeleportTileX; - npc.ai[2] = phase1TeleportTileY; - npc.netUpdate = true; - break; - } - } - while (phase1TeleportTries <= maxTeleportTries); - } - } - } - - // Turn invisible and teleport - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.alpha += 25; - if (npc.alpha >= 255) - { - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - npc.alpha = 255; - npc.position.X = npc.ai[1] * 16f - (npc.width / 2); - npc.position.Y = npc.ai[2] * 16f - (npc.height / 2); - npc.ai[0] = 2f; - - // Move non-charging Creepers to new Brain location - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC creeper = Main.npc[i]; - if (creeper.active && creeper.type == NPCID.Creeper) - { - bool creeperCanTeleport = creeper.ai[0] == 0f; - if (creeperCanTeleport) - { - creeper.position.X = npc.position.X; - creeper.position.Y = npc.position.Y; - } - } - } - } - } - - // Become visible - else if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.alpha -= 25; - if (npc.alpha <= 0) - { - npc.alpha = 0; - npc.ai[0] = 0f; - } - } - } - - return false; - } - - public static bool BuffedCreeperAI(NPC npc, Mod mod) - { - // Despawn if Brain is gone - if (NPC.crimsonBoss < 0) - { - npc.active = false; - npc.netUpdate = true; - return false; - } - - 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) - CalamityUtils.CalamityTargeting(npc, default); - - float enrageScaleMax = 2f; - float enrageScale = bossRush ? enrageScaleMax : death ? 0.5f : 0f; - if ((npc.position.Y / 16f) < Main.worldSurface) - enrageScale += 0.5f; - if (!Main.player[npc.target].ZoneCrimson) - enrageScale += 1f; - - if (enrageScale > enrageScaleMax) - enrageScale = enrageScaleMax; - - bool brainIsNotTeleportingOrCharging = Main.npc[NPC.crimsonBoss].ai[0] == 0f || Main.npc[NPC.crimsonBoss].ai[0] == -1f || Main.npc[NPC.crimsonBoss].ai[0] == -6f; - bool brainIsInPhase2 = Main.npc[NPC.crimsonBoss].ai[0] < 0f; - - // Creeper count - int creeperCount = NPC.CountNPCS(npc.type); - if (creeperCount > GetBrainOfCthuluCreepersCountRevDeath()) - creeperCount = GetBrainOfCthuluCreepersCountRevDeath(); - - float creeperRatio = 1f; - if (death && brainIsInPhase2) - { - bool brainIsInPhase3 = Main.npc[NPC.crimsonBoss].localAI[0] == 2f; - bool brainIsInPhase5 = Main.npc[NPC.crimsonBoss].localAI[0] == 3f; - bool brainIsInPhase7 = Main.npc[NPC.crimsonBoss].localAI[0] == 4f; - float creeperAmountScalar = (float)(GetBrainOfCthuluCreepersCountRevDeath() / 4); - creeperRatio = creeperCount / (creeperAmountScalar * (Main.npc[NPC.crimsonBoss].localAI[0] - 1f)); - } - else - creeperRatio = creeperCount / (float)GetBrainOfCthuluCreepersCountRevDeath(); - - // Scale the aggressiveness of the charges with amount of Creepers remaining - float chargeAggressionScale = creeperRatio <= 0.1f ? 1.75f : creeperRatio <= 0.2f ? 1.25f : creeperRatio <= 0.4f ? 0.875f : creeperRatio <= 0.6f ? 0.5f : creeperRatio <= 0.8f ? 0.25f : 0f; - if (enrageScale > 0f) - chargeAggressionScale *= 1f + enrageScale; - if (death) - chargeAggressionScale *= 1.25f; - - // Give off blood dust before charging - float beginTelegraphGateValue = TimeBeforeCreeperAttack - CreeperTelegraphTime; - bool showTelegraph = npc.ai[1] >= beginTelegraphGateValue || npc.ai[0] == 1f; - if (showTelegraph) - { - float dustScalar = npc.ai[0] == 1f ? 1f : MathHelper.Clamp((npc.ai[1] - beginTelegraphGateValue) / CreeperTelegraphTime, 0f, 1f); - int dustAmt = 1 + (int)Math.Round(4 * dustScalar); - Color dustColor = new Color(255, 50, 50, 0) * dustScalar; - for (int i = 0; i < dustAmt; i++) - { - Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, npc.velocity.X, npc.velocity.Y, 100, dustColor)]; - dust.noGravity = true; - dust.velocity = Vector2.Zero; - dust.scale = 1.2f; - } - } - - // Stay near Brain - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 creeperCenter = npc.Center; - float brainXDist = Main.npc[NPC.crimsonBoss].Center.X - creeperCenter.X; - float brainYDist = Main.npc[NPC.crimsonBoss].Center.Y - creeperCenter.Y; - float brainDistance = (float)Math.Sqrt(brainXDist * brainXDist + brainYDist * brainYDist); - float velocity = (death ? 16f : 8f) + chargeAggressionScale; - velocity += 2f * enrageScale; - if (brainIsInPhase2) - { - float velocityFloor = Main.npc[NPC.crimsonBoss].velocity.Length() + velocity * 0.5f; - if (velocity < velocityFloor) - velocity = velocityFloor; - } - - float maxDistanceFromBrain = 90f; - if (brainDistance > maxDistanceFromBrain) - { - brainDistance = velocity / brainDistance; - brainXDist *= brainDistance; - brainYDist *= brainDistance; - float inertia = brainIsInPhase2 ? 5f : 15f; - npc.velocity.X = (npc.velocity.X * inertia + brainXDist) / (inertia + 1f); - npc.velocity.Y = (npc.velocity.Y * inertia + brainYDist) / (inertia + 1f); - } - - // Increase speed - if (npc.velocity.Length() < velocity) - npc.velocity *= 1.05f; - - // Set alpha to brain alpha - npc.alpha = Main.npc[NPC.crimsonBoss].alpha; - - // Only increment the attack timer if the brain isn't teleporting - if (brainIsNotTeleportingOrCharging) - npc.ai[1] += (brainIsInPhase2 ? 2f : 1f) + chargeAggressionScale; - - // Charge at target - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= TimeBeforeCreeperAttack) - { - npc.ai[1] = 0f; - - CalamityUtils.CalamityTargeting(npc, default); - - creeperCenter = npc.Center; - brainXDist = Main.player[npc.target].Center.X - creeperCenter.X; - brainYDist = Main.player[npc.target].Center.Y - creeperCenter.Y; - brainDistance = (float)Math.Sqrt(brainXDist * brainXDist + brainYDist * brainYDist); - brainDistance = velocity / brainDistance; - npc.velocity.X = brainXDist * brainDistance; - npc.velocity.Y = brainYDist * brainDistance; - npc.ai[0] = 1f; - npc.netUpdate = true; - } - } - - // Charge - else - { - // Always fully visible while charging - npc.alpha = 0; - - float chargeVelocity = (death ? 12f : 6f) + chargeAggressionScale; - chargeVelocity += 2f * enrageScale; - float returnToBrainGateValue = 1f; - if (!brainIsInPhase2) - { - // Set damage - npc.damage = npc.defDamage; - - Vector2 destination = Main.player[npc.target].Center + (death ? Main.player[npc.target].velocity * 20f : Vector2.Zero); - Vector2 targetDirection = destination - npc.Center; - targetDirection = targetDirection.SafeNormalize(Vector2.UnitY); - if (Main.getGoodWorld) - { - targetDirection *= chargeVelocity + 6f; - npc.velocity = (npc.velocity * 49f + targetDirection) / 50f; - } - else - { - targetDirection *= chargeVelocity; - float inertia = death ? 75f : 100f; - npc.velocity = (npc.velocity * (inertia - 1f) + targetDirection) / inertia; - } - - // Return to Brain after a set time - float chargeDistance = death ? 900f : 600f; - returnToBrainGateValue = chargeDistance / chargeVelocity; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= returnToBrainGateValue || brainIsInPhase2) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Shoot blood shots - if (Vector2.Distance(npc.Center, Main.player[npc.target].Center) > 160f && npc.ai[2] == 0f) - { - bool canHit = Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1); - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int projectileType = ProjectileID.BloodShot; - int damage = npc.GetProjectileDamage(projectileType); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, projectileVelocity, projectileType, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; - if (!canHit) - Main.projectile[proj].tileCollide = false; - } - npc.ai[2] = 1f; - } - - if (brainIsNotTeleportingOrCharging) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - } - - return false; - } - - public static bool VanillaBrainofCthulhuAI(NPC npc, Mod mod) - { - NPC.crimsonBoss = npc.whoAmI; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - int brainOfCthuluCreepersCount = GetBrainOfCthuluCreepersCountVanilla(); - for (int num837 = 0; num837 < brainOfCthuluCreepersCount; num837++) - { - float x2 = npc.Center.X; - float y4 = npc.Center.Y; - x2 += (float)Main.rand.Next(-npc.width, npc.width); - y4 += (float)Main.rand.Next(-npc.height, npc.height); - int num838 = NPC.NewNPC(npc.GetSource_FromAI(), (int)x2, (int)y4, NPCID.Creeper); - Main.npc[num838].velocity = new Vector2((float)Main.rand.Next(-30, 31) * 0.1f, (float)Main.rand.Next(-30, 31) * 0.1f); - Main.npc[num838].netUpdate = true; - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - - int num839 = 6000; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > (float)num839) - { - npc.active = false; - npc.life = 0; - if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); - } - } - - if (npc.ai[0] < 0f) - { - // Set damage - npc.damage = npc.defDamage; - - if (Main.getGoodWorld) - NPC.brainOfGravity = npc.whoAmI; - - if (npc.localAI[2] == 0f) - { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); - npc.localAI[2] = 1f; - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 392); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 393); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 394); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 395); - for (int num840 = 0; num840 < 20; num840++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f); - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - - npc.dontTakeDamage = false; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - - Vector2 vector104 = npc.Center; - float num841 = Main.player[npc.target].Center.X - vector104.X; - float num842 = Main.player[npc.target].Center.Y - vector104.Y; - float num843 = (float)Math.Sqrt(num841 * num841 + num842 * num842); - float num844 = Main.masterMode ? 12f : 8f; - num843 = num844 / num843; - num841 *= num843; - num842 *= num843; - float inertia = Main.masterMode ? 40f : 50f; - npc.velocity.X = (npc.velocity.X * inertia + num841) / (inertia + 1f); - npc.velocity.Y = (npc.velocity.Y * inertia + num842) / (inertia + 1f); - if (npc.ai[0] == -1f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (npc.justHit) - npc.localAI[1] -= Main.rand.Next(Main.masterMode ? 3 : 5); - - int num845 = 60 + Main.rand.Next(Main.masterMode ? 60 : 120); - if (Main.netMode != NetmodeID.SinglePlayer) - num845 += Main.rand.Next(Main.masterMode ? 15 : 30, Main.masterMode ? 45 : 90); - - if (npc.localAI[1] >= (float)num845) - { - npc.localAI[1] = 0f; - - CalamityUtils.CalamityTargeting(npc, options); - - int num846 = 0; - Player player2 = Main.player[npc.target]; - do - { - num846++; - int num847 = (int)player2.Center.X / 16; - int num848 = (int)player2.Center.Y / 16; - int minValue = 10; - int num849 = 12; - float num850 = 16f; - int num851 = Main.rand.Next(minValue, num849 + 1); - int num852 = Main.rand.Next(minValue, num849 + 1); - if (Main.rand.NextBool()) - num851 *= -1; - - if (Main.rand.NextBool()) - num852 *= -1; - - Vector2 v = new Vector2(num851 * 16, num852 * 16); - if (Vector2.Dot(player2.velocity.SafeNormalize(Vector2.UnitY), v.SafeNormalize(Vector2.UnitY)) > 0f) - v += v.SafeNormalize(Vector2.Zero) * num850 * player2.velocity.Length(); - - num847 += (int)(v.X / 16f); - num848 += (int)(v.Y / 16f); - if (num846 > 100 || !WorldGen.SolidTile(num847, num848)) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[3] = 0f; - npc.ai[0] = -2f; - npc.ai[1] = num847; - npc.ai[2] = num848; - npc.ForceNetUpdate(); - break; - } - } - while (num846 <= 100); - } - } - } - else if (npc.ai[0] == -2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.9f; - if (Main.netMode != NetmodeID.SinglePlayer) - npc.ai[3] += 15f; - else - npc.ai[3] += 25f; - - if (npc.ai[3] >= 255f) - { - npc.ai[3] = 255f; - npc.position.X = npc.ai[1] * 16f - (float)(npc.width / 2); - npc.position.Y = npc.ai[2] * 16f - (float)(npc.height / 2); - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - npc.ai[0] = -3f; - npc.ForceNetUpdate(); - } - - npc.alpha = (int)npc.ai[3]; - } - else if (npc.ai[0] == -3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.netMode != NetmodeID.SinglePlayer) - npc.ai[3] -= 15f; - else - npc.ai[3] -= 25f; - - if (npc.ai[3] <= 0f) - { - npc.ai[3] = 0f; - npc.ai[0] = -1f; - npc.ForceNetUpdate(); - } - - npc.alpha = (int)npc.ai[3]; - } - } - else - { - // Avoid cheap bullshit - npc.damage = 0; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - - Vector2 vector105 = npc.Center; - float num853 = Main.player[npc.target].Center.X - vector105.X; - float num854 = Main.player[npc.target].Center.Y - vector105.Y; - float num855 = (float)Math.Sqrt(num853 * num853 + num854 * num854); - float num856 = Main.masterMode ? 2.5f : 1.5f; - if (Main.getGoodWorld) - num856 *= 3f; - - if (num855 < num856) - { - npc.velocity.X = num853; - npc.velocity.Y = num854; - } - else - { - num855 = num856 / num855; - npc.velocity.X = num853 * num855; - npc.velocity.Y = num854 * num855; - } - - if (npc.ai[0] == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num857 = 0; - for (int num858 = 0; num858 < Main.maxNPCs; num858++) - { - if (Main.npc[num858].active && Main.npc[num858].type == NPCID.Creeper) - num857++; - } - - if (num857 == 0) - { - npc.ai[0] = -1f; - npc.localAI[1] = 0f; - npc.alpha = 0; - npc.netUpdate = true; - } - - npc.localAI[1] += 1f; - if (npc.localAI[1] >= (float)(120 + Main.rand.Next(Main.masterMode ? 150 : 300))) - { - npc.localAI[1] = 0f; - - CalamityUtils.CalamityTargeting(npc, options); - - int num859 = 0; - Player player3 = Main.player[npc.target]; - do - { - num859++; - int num860 = (int)player3.Center.X / 16; - int num861 = (int)player3.Center.Y / 16; - int minValue2 = 12; - int num862 = 40; - float num863 = 16f; - int num864 = Main.rand.Next(minValue2, num862 + 1); - int num865 = Main.rand.Next(minValue2, num862 + 1); - if (Main.rand.NextBool()) - num864 *= -1; - - if (Main.rand.NextBool()) - num865 *= -1; - - Vector2 v2 = new Vector2(num864 * 16, num865 * 16); - if (Vector2.Dot(player3.velocity.SafeNormalize(Vector2.UnitY), v2.SafeNormalize(Vector2.UnitY)) > 0f) - v2 += v2.SafeNormalize(Vector2.Zero) * num863 * player3.velocity.Length(); - - num860 += (int)(v2.X / 16f); - num861 += (int)(v2.Y / 16f); - if (num859 > 100 || (!WorldGen.SolidTile(num860, num861) && (num859 > 75 || Collision.CanHit(new Vector2(num860 * 16, num861 * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)))) - { - npc.ai[0] = 1f; - npc.ai[1] = num860; - npc.ai[2] = num861; - npc.netUpdate = true; - break; - } - } - while (num859 <= 100); - } - } - } - else if (npc.ai[0] == 1f) - { - npc.alpha += 5; - if (npc.alpha >= 255) - { - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - npc.alpha = 255; - npc.position.X = npc.ai[1] * 16f - (float)(npc.width / 2); - npc.position.Y = npc.ai[2] * 16f - (float)(npc.height / 2); - npc.ai[0] = 2f; - } - } - else if (npc.ai[0] == 2f) - { - npc.alpha -= 5; - if (npc.alpha <= 0) - { - npc.alpha = 0; - npc.ai[0] = 0f; - } - } - } - - if (Main.player[npc.target].dead || !Main.player[npc.target].ZoneCrimson) - { - if (npc.localAI[3] < 120f) - npc.localAI[3]++; - - if (npc.localAI[3] > 60f) - npc.velocity.Y += (npc.localAI[3] - 60f) * 0.25f; - - npc.ai[0] = 2f; - npc.alpha = 10; - } - else if (npc.localAI[3] > 0f) - npc.localAI[3]--; - - return false; - } - - public static bool VanillaCreeperAI(NPC npc, Mod mod) - { - if (NPC.crimsonBoss < 0) - { - npc.active = false; - npc.netUpdate = true; - return false; - } - - if (Main.masterMode) - npc.knockBackResist = 0f; - - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[1] = 0f; - float maxVelocity = Main.masterMode ? 10f : 8f; - Vector2 vector106 = npc.Center; - float num866 = Main.npc[NPC.crimsonBoss].Center.X - vector106.X; - float num867 = Main.npc[NPC.crimsonBoss].Center.Y - vector106.Y; - float num868 = (float)Math.Sqrt(num866 * num866 + num867 * num867); - if (num868 > 90f) - { - num868 = maxVelocity / num868; - num866 *= num868; - num867 *= num868; - npc.velocity.X = (npc.velocity.X * 15f + num866) / 16f; - npc.velocity.Y = (npc.velocity.Y * 15f + num867) / 16f; - return false; - } - - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < maxVelocity) - { - float velocityMult = Main.masterMode ? 1.07f : 1.05f; - npc.velocity.Y *= velocityMult; - npc.velocity.X *= velocityMult; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && ((Main.expertMode && Main.rand.NextBool(Main.masterMode ? 50 : 100)) || Main.rand.NextBool(200))) - { - CalamityUtils.CalamityTargeting(npc, default); - - vector106 = npc.Center; - num866 = Main.player[npc.target].Center.X - vector106.X; - num867 = Main.player[npc.target].Center.Y - vector106.Y; - num868 = (float)Math.Sqrt(num866 * num866 + num867 * num867); - num868 = maxVelocity / num868; - npc.velocity.X = num866 * num868; - npc.velocity.Y = num867 * num868; - npc.ai[0] = 1f; - npc.netUpdate = true; - } - - return false; - } - - // Set damage - npc.damage = npc.defDamage; - - if (Main.expertMode) - { - Vector2 vector107 = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - if (Main.getGoodWorld) - { - vector107 *= 12f; - npc.velocity = (npc.velocity * 49f + vector107) / 50f; - } - else - { - float chargeVelocity = Main.masterMode ? 10f : 9f; - vector107 *= chargeVelocity; - float inertia = Main.masterMode ? 75f : 100f; - npc.velocity = (npc.velocity * (inertia - 1f) + vector107) / inertia; - } - } - - Vector2 vector108 = npc.Center; - float num869 = Main.npc[NPC.crimsonBoss].Center.X - vector108.X; - float num870 = Main.npc[NPC.crimsonBoss].Center.Y - vector108.Y; - float num871 = (float)Math.Sqrt(num869 * num869 + num870 * num870); - if (num871 > 700f) - { - npc.ai[0] = 0f; - } - else - { - if (!npc.justHit) - return false; - - if (npc.knockBackResist == 0f) - { - npc.ai[1] += 1f; - float returnToBrainGateValue = Main.masterMode ? 35f : 5f; - if (npc.ai[1] > returnToBrainGateValue) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[0] = 0f; - } - } - else - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[0] = 0f; - } - } - - return false; - } - - public static int GetBrainOfCthuluCreepersCountRevDeath() - { - return CalamityWorld.LegendaryMode ? 40 : Main.getGoodWorld ? 35 : (CalamityWorld.death || BossRushEvent.BossRushActive) ? 30 : 20; - } - - public static int GetBrainOfCthuluCreepersCountVanilla() - { - return Main.getGoodWorld ? 40 : Main.masterMode ? 30 : 20; - } - - private static float GetCrimsonBossKnockBack(NPC npc, int numPlayers, float lifeScale, float baseKnockBackResist) - { - float balance = 1f; - float boost = 0.35f; - - for (int i = 1; i < numPlayers; i++) - { - balance += boost; - boost += (1f - boost) / 3f; - } - - if (balance > 8f) - balance = (balance * 2f + 8f) / 3f; - if (balance > 1000f) - balance = 1000f; - - float KBResist = baseKnockBackResist * lifeScale; - float KBResistMultiplier = 1f - baseKnockBackResist * 0.4f; - for (float num = 1f; num < balance; num += 0.34f) - { - if (KBResist < 0.05) - { - KBResist = 0f; - break; - } - KBResist *= KBResistMultiplier; - } - - return KBResist; - } - } -} diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs index 2e195a2c06..ad778bbd19 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs @@ -11,14 +11,21 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class CultistAI + public class CultistAI : VanillaAIOverride { - public static bool BuffedCultistAI(NPC npc, Mod mod) + // Vanilla values + public static int CloneFireballDamage = 18; // 72 + public static int FireballDamage = 20; // 80 + public static int IceMistDamage = 1; // This attack never actually hits, so damage number is irrelevant + public static int LightningDamage = 30; // 120 + public static int DoomDamage = 45; // 180 (Also fixes Master Mode scaling) + + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // Chant sound - if (npc.ai[0] != -1f && Main.rand.NextBool(1000)) + if (NPC.ai[0] != -1f && Main.rand.NextBool(1000)) { SoundStyle chantSound = Utils.SelectRandom(Main.rand, new SoundStyle[] { @@ -28,15 +35,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses SoundID.Zombie91 }); - SoundEngine.PlaySound(chantSound, npc.Center); + SoundEngine.PlaySound(chantSound, NPC.Center); } // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phases - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool phase2 = lifeRatio < 0.85f || death; bool phase3 = lifeRatio < 0.7f || death; bool phase4 = lifeRatio < (death ? 0.8f : 0.55f); @@ -46,48 +52,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool phase8 = death && lifeRatio < 0.1f; // Variables - bool isCultist = npc.type == NPCID.CultistBoss; + bool isCultist = NPC.type == NPCID.CultistBoss; bool dontTakeDamage = false; float predictionDistance = 480f; float distanceAboveTarget = -240f; float moveSpeed = death ? 300f : 75f; - int iceMistDamage = isCultist ? npc.GetProjectileDamage(ProjectileID.CultistBossIceMist) : 0; - int fireballDamage = isCultist ? npc.GetProjectileDamage(ProjectileID.CultistBossFireBall) : npc.GetProjectileDamage(ProjectileID.CultistBossFireBallClone); - int lightningDamage = isCultist ? npc.GetProjectileDamage(ProjectileID.CultistBossLightningOrb) : 0; + int iceMistDamage = isCultist ? IceMistDamage : 0; + int fireballDamage = isCultist ? FireballDamage : CloneFireballDamage; + int lightningDamage = isCultist ? LightningDamage : 0; int iceMistFireRate = phase2 ? 50 : 60; - float iceMistSpeed = (phase6 ? 12f : 10f) + (death ? (1f - lifeRatio) : 0f); + float iceMistSpeed = 12f + (death ? 4f : 2f) * (1f - lifeRatio); int iceMistAmt = phase3 ? 2 : 1; - int fireballFireRate = (phase5 ? 10 : 12) - (death ? 6 : 0); + int fireballFireRate = (phase5 ? 20 : 24) - (death ? 5 : 0); float fireballSpeed = ((phase7 ? 8f : phase6 ? 7f : 6f) + (death ? (1f - lifeRatio) : 0f)) * (isCultist ? 1f : 0.5f); - int fireballAmt = death ? 20 : 4; + int fireballAmt = death ? 8 : 4; int lightningOrbPhaseTime = phase2 ? 90 : 120; int ancientLightSpawnRate = phase7 ? 20 : phase4 ? 25 : 30; int ancientLightAmt = phase7 ? 4 : phase4 ? 3 : 2; int ancientDoomLimit = 10; - int idleTime = phase8 ? 20 : phase7 ? 30 : phase3 ? 35 : 40; + int idleTime = phase8 ? 40 : phase7 ? 45 : phase3 ? 55 : 60; float timeToFinishRitual = phase8 ? 180f : phase7 ? 240f : phase5 ? 300f : 360f; - if (bossRush) - { - iceMistFireRate = 40; - iceMistSpeed = 14f; - iceMistAmt = 3; - fireballFireRate = 8; - fireballSpeed *= 1.2f; - lightningOrbPhaseTime = 90; - ancientLightSpawnRate = 20; - ancientLightAmt = 4; - idleTime = 20; - } - if (Main.getGoodWorld) { - iceMistFireRate = 30; + iceMistFireRate = 40; iceMistSpeed = 15f; - fireballFireRate = 6; + fireballFireRate = 8; fireballSpeed *= 1.25f; lightningOrbPhaseTime = 60; ancientLightSpawnRate = 10; @@ -96,19 +89,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Center and target - Player player = Main.player[npc.target]; - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) + Player player = Main.player[NPC.target]; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); + CalamityUtils.CalamityTargeting(NPC, options); - player = Main.player[npc.target]; - npc.netUpdate = true; + player = Main.player[NPC.target]; + NPC.netUpdate = true; } // Enrage - if (!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) || CalamityWorld.LegendaryMode) + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { calamityGlobalNPC.newAI[0] += 1f; if (calamityGlobalNPC.newAI[0] >= 120f) @@ -131,151 +124,161 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Cultist clone AI if (!isCultist) { - if (npc.ai[3] < 0f || !Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != NPCID.CultistBoss) + if (NPC.ai[3] < 0f || !Main.npc[(int)NPC.ai[3]].active || Main.npc[(int)NPC.ai[3]].type != NPCID.CultistBoss) { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; return false; } - npc.ai[0] = Main.npc[(int)npc.ai[3]].ai[0]; - npc.ai[1] = Main.npc[(int)npc.ai[3]].ai[1]; + NPC.ai[0] = Main.npc[(int)NPC.ai[3]].ai[0]; + NPC.ai[1] = Main.npc[(int)NPC.ai[3]].ai[1]; dontTakeDamage = true; + + if (NPC.ai[0] == 5f && NPC.ai[1] >= 120f && NPC.ai[1] < timeToFinishRitual) + { + dontTakeDamage = false; + if (NPC.justHit) + { + var mainCultist = Main.npc[(int)NPC.ai[3]]; + mainCultist.ai[1] = timeToFinishRitual; + } + } } // Stop spawning ritual if hit - else if (npc.ai[0] == 5f && npc.ai[1] >= 120f && npc.ai[1] < timeToFinishRitual && npc.justHit) + else if (NPC.ai[0] == 5f && NPC.ai[1] >= 120f && NPC.ai[1] < timeToFinishRitual && NPC.justHit) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); + CalamityUtils.CalamityTargeting(NPC, options); - npc.netUpdate = true; + NPC.netUpdate = true; + Main.projectile[(int)NPC.ai[2]].ai[1] = -1f; + Main.projectile[(int)NPC.ai[2]].netUpdate = true; - if (Main.netMode != NetmodeID.MultiplayerClient) + foreach (var item in Main.ActiveNPCs) { - if (!NPC.AnyNPCs(NPCID.AncientCultistSquidhead)) - NPC.NewNPC(npc.GetSource_FromAI(), (int)Main.projectile[(int)npc.ai[2]].Center.X, (int)Main.projectile[(int)npc.ai[2]].Center.Y, NPCID.AncientCultistSquidhead); + if (item.type == NPCID.CultistBossClone && item.ai[3] == NPC.whoAmI) + { + item.active = false; + item.ForceNetUpdate(); + } } - - Main.projectile[(int)npc.ai[2]].ai[1] = -1f; - Main.projectile[(int)npc.ai[2]].netUpdate = true; } // Despawn - if (player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) + if (player.dead || !player.active || Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f); for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == npc.whoAmI) + if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == NPC.whoAmI) { Main.npc[j].life = 0; Main.npc[j].HitEffect(0, 10.0); Main.npc[j].active = false; if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f); } } } // Clones set to Cultist phase - float clonePhase = npc.ai[3]; + float clonePhase = NPC.ai[3]; // Spawn and play sound - if (npc.localAI[0] == 0f) + if (NPC.localAI[0] == 0f) { - SoundEngine.PlaySound(SoundID.Zombie89, npc.Center); - npc.localAI[0] = 1f; - npc.alpha = 255; - npc.rotation = 0f; + SoundEngine.PlaySound(SoundID.Zombie89, NPC.Center); + NPC.localAI[0] = 1f; + NPC.alpha = 255; + NPC.rotation = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[0] = -1f; - npc.netUpdate = true; + NPC.ai[0] = -1f; + NPC.netUpdate = true; } } // Appear and do weird ritual shit with tablet - if (npc.ai[0] == -1f) + if (NPC.ai[0] == -1f) { - npc.alpha -= 5; - if (npc.alpha < 0) - npc.alpha = 0; + NPC.alpha -= 5; + if (NPC.alpha < 0) + NPC.alpha = 0; - npc.ai[1] += 1f; - if (npc.ai[1] >= 420f) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 420f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } - else if (npc.ai[1] > 360f) + else if (NPC.ai[1] > 360f) { - npc.velocity *= 0.95f; + NPC.velocity *= 0.95f; - if (npc.localAI[2] != 13f) - SoundEngine.PlaySound(SoundID.Zombie105, npc.Center); + if (NPC.localAI[2] != 13f) + SoundEngine.PlaySound(SoundID.Zombie105, NPC.Center); - npc.localAI[2] = 13f; + NPC.localAI[2] = 13f; } - else if (npc.ai[1] > 300f) + else if (NPC.ai[1] > 300f) { - npc.velocity = -Vector2.UnitY; - npc.localAI[2] = 10f; + NPC.velocity = -Vector2.UnitY; + NPC.localAI[2] = 10f; } - else if (npc.ai[1] > 120f) - npc.localAI[2] = 1f; + else if (NPC.ai[1] > 120f) + NPC.localAI[2] = 1f; else - npc.localAI[2] = 0f; + NPC.localAI[2] = 0f; dontTakeDamage = true; } // Phase switch - if (npc.ai[0] == 0f) + if (NPC.ai[0] == 0f) { - if (npc.ai[1] == 0f) + if (NPC.ai[1] == 0f) { CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); + CalamityUtils.CalamityTargeting(NPC, options); } - npc.localAI[2] = 10f; + NPC.localAI[2] = 10f; - int facePlayerDirection = Math.Sign(player.Center.X - npc.Center.X); + int facePlayerDirection = Math.Sign(player.Center.X - NPC.Center.X); if (facePlayerDirection != 0) - npc.direction = npc.spriteDirection = facePlayerDirection; + NPC.direction = NPC.spriteDirection = facePlayerDirection; - npc.ai[1] += 1f; - if (npc.ai[1] >= idleTime & isCultist) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= idleTime & isCultist) { // Phase switch int phase = 0; - switch ((int)npc.ai[3]) + switch ((int)NPC.ai[3]) { // Move to target case 0: - case 2: case 4: case 6: case 8: - case 10: case 12: case 14: case 16: @@ -284,6 +287,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses phase = 0; break; + case 2: + case 10: + phase = 0; + distanceAboveTarget *= 1.5f; + predictionDistance *= 1.5f; + break; // Fireball case 1: case 15: @@ -319,11 +328,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Dragon Summon case 21: phase = 4; - npc.ai[3] = -1f; + NPC.ai[3] = -1f; break; default: - npc.ai[3] = -1f; + NPC.ai[3] = -1f; break; } @@ -334,17 +343,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 0: // Set a location to move to Vector2 predictionVector = new Vector2(0f + player.velocity.SafeNormalize(Vector2.Zero).X * predictionDistance, distanceAboveTarget); - float moveDistance = (float)Math.Ceiling((player.Center + predictionVector - npc.Center).Length() / moveSpeed); + float moveDistance = (float)Math.Ceiling((player.Center + predictionVector - NPC.Center).Length() / moveSpeed); if (moveDistance == 0f) moveDistance = 1f; // Add self and clones to list List list2 = new List(); int cloneAmt = 0; - list2.Add(npc.whoAmI); + list2.Add(NPC.whoAmI); for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == npc.whoAmI) + if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == NPC.whoAmI) list2.Add(k); } @@ -365,7 +374,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses nPC2.ai[0] = 1f; nPC2.ai[1] = moveDistance; nPC2.velocity = finalClonePos / moveDistance * 2f; - if (npc.whoAmI >= nPC2.whoAmI) + if (NPC.whoAmI >= nPC2.whoAmI) nPC2.position -= nPC2.velocity; nPC2.netUpdate = true; @@ -375,84 +384,84 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Fireball case 1: - npc.ai[0] = 3f; - npc.ai[1] = 0f; + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; break; // Ice Mist case 2: - npc.ai[0] = 2f; - npc.ai[1] = 0f; + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; break; // Lightning Orb case 3: - npc.ai[0] = 4f; - npc.ai[1] = 0f; + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; break; // Dragon Summon case 4: - npc.ai[0] = 5f; - npc.ai[1] = 0f; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; break; // Ancient Light case 5: - npc.ai[0] = 7f; - npc.ai[1] = 0f; + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; break; // Ancient Doom case 6: - npc.ai[0] = 8f; - npc.ai[1] = 0f; + NPC.ai[0] = 8f; + NPC.ai[1] = 0f; break; default: break; } - npc.netUpdate = true; + NPC.netUpdate = true; } } // Movement, then switch to a different attack - else if (npc.ai[0] == 1f) + else if (NPC.ai[0] == 1f) { - npc.localAI[2] = 10f; + NPC.localAI[2] = 10f; - if (npc.ai[1] % 2f != 0f && npc.ai[1] != 1f) - npc.position -= npc.velocity; + if (NPC.ai[1] % 2f != 0f && NPC.ai[1] != 1f) + NPC.position -= NPC.velocity; - npc.ai[1] -= 1f; - if (npc.ai[1] <= 0f) + NPC.ai[1] -= 1f; + if (NPC.ai[1] <= 0f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } } // Ice Mist - else if (npc.ai[0] == 2f) + else if (NPC.ai[0] == 2f) { - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; - Vector2 vec = Vector2.Normalize(player.Center - npc.Center); + Vector2 vec = Vector2.Normalize(player.Center - NPC.Center); if (vec.HasNaNs()) - vec = new Vector2(npc.direction, 0f); + vec = new Vector2(NPC.direction, 0f); - if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % iceMistFireRate == 0) + if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % iceMistFireRate == 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { List list3 = new List(); for (int l = 0; l < Main.maxNPCs; l++) { - if (Main.npc[l].active && Main.npc[l].type == NPCID.CultistBossClone && Main.npc[l].ai[3] == npc.whoAmI) + if (Main.npc[l].active && Main.npc[l].type == NPCID.CultistBossClone && Main.npc[l].ai[3] == NPC.whoAmI) list3.Add(l); } @@ -467,55 +476,56 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses vec = Vector2.Normalize(player.Center - center3); if (vec.HasNaNs()) - vec = new Vector2(npc.direction, 0f); + vec = new Vector2(NPC.direction, 0f); - Vector2 shadowFireballDirection = center3 + new Vector2(npc.direction * 30, 12f); + Vector2 shadowFireballDirection = center3 + new Vector2(NPC.direction * 30, 12f); Vector2 shadowFireballVelocity = vec * (fireballSpeed + (float)Main.rand.NextDouble()); shadowFireballVelocity = shadowFireballVelocity.RotatedByRandom(Math.PI / 6D); - Projectile.NewProjectile(npc.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); } } if (Main.netMode != NetmodeID.MultiplayerClient) { - vec = Vector2.Normalize(player.Center - npc.Center); + vec = Vector2.Normalize(player.Center - NPC.Center); if (vec.HasNaNs()) - vec = new Vector2(npc.direction, 0f); + vec = new Vector2(NPC.direction, 0f); - Vector2 iceMistDirection = npc.Center + new Vector2(npc.direction * 30, 12f); + Vector2 iceMistDirection = NPC.Center + new Vector2(NPC.direction * 30, 12f); Vector2 iceMistVelocity = vec * iceMistSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), iceMistDirection, iceMistVelocity, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f); + var icemist = Main.projectile[Projectile.NewProjectile(NPC.GetSource_FromAI(), iceMistDirection, iceMistVelocity, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f)]; + icemist.timeLeft = 240; } } - npc.ai[1] += 1f; - if (npc.ai[1] >= (4 + iceMistFireRate * iceMistAmt)) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (4 + iceMistFireRate * iceMistAmt)) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } } // Fireballs - else if (npc.ai[0] == 3f) + else if (NPC.ai[0] == 3f) { - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; - Vector2 playerDirection = Vector2.Normalize(player.Center - npc.Center); + Vector2 playerDirection = Vector2.Normalize(player.Center - NPC.Center); if (playerDirection.HasNaNs()) - playerDirection = new Vector2(npc.direction, 0f); + playerDirection = new Vector2(NPC.direction, 0f); - if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % fireballFireRate == 0) + if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % fireballFireRate == 0) { - if ((int)(npc.ai[1] - 4f) / fireballFireRate == 2) + if ((int)(NPC.ai[1] - 4f) / fireballFireRate == 2) { List list4 = new List(); for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].active && Main.npc[i].type == NPCID.CultistBossClone && Main.npc[i].ai[3] == npc.whoAmI) + if (Main.npc[i].active && Main.npc[i].type == NPCID.CultistBossClone && Main.npc[i].ai[3] == NPC.whoAmI) list4.Add(i); } @@ -532,58 +542,59 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses playerDirection = Vector2.Normalize(player.Center - center4); if (playerDirection.HasNaNs()) - playerDirection = new Vector2(npc.direction, 0f); + playerDirection = new Vector2(NPC.direction, 0f); - Vector2 shadowFireballDirection = center4 + new Vector2(npc.direction * 30, 12f); + Vector2 shadowFireballDirection = center4 + new Vector2(NPC.direction * 30, 12f); Vector2 shadowFireballVelocity = playerDirection * (fireballSpeed + (float)Main.rand.NextDouble()); shadowFireballVelocity = shadowFireballVelocity.RotatedByRandom(Math.PI / 6D); - Projectile.NewProjectile(npc.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, CloneFireballDamage, 0f, Main.myPlayer); } } } - int cultistFireballFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + int cultistFireballFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (cultistFireballFaceDirection != 0) - npc.direction = npc.spriteDirection = cultistFireballFaceDirection; + NPC.direction = NPC.spriteDirection = cultistFireballFaceDirection; if (Main.netMode != NetmodeID.MultiplayerClient) { - playerDirection = Vector2.Normalize(player.Center - npc.Center); + playerDirection = NPC.DirectionTo(player.Center); if (playerDirection.HasNaNs()) - playerDirection = new Vector2(npc.direction, 0f); + playerDirection = new Vector2(NPC.direction, 0f); - Vector2 fireballDirection = npc.Center + new Vector2(npc.direction * 30, 12f); + Vector2 fireballDirection = NPC.Center + new Vector2(NPC.direction * 30, 12f); Vector2 fireballVelocity = playerDirection * (fireballSpeed + (float)Main.rand.NextDouble() * 2f); fireballVelocity = fireballVelocity.RotatedByRandom(Math.PI / 6D); - Projectile.NewProjectile(npc.GetSource_FromAI(), fireballDirection, fireballVelocity, ProjectileID.CultistBossFireBall, fireballDamage, 0f, Main.myPlayer); + for (var i = -1; i <= 1; i++) + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireballDirection, fireballVelocity.RotatedBy(1f * i), ProjectileID.CultistBossFireBall, fireballDamage, 0f, Main.myPlayer); } } - npc.ai[1] += 1f; - if (npc.ai[1] >= (4 + fireballFireRate * fireballAmt)) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (4 + fireballFireRate * fireballAmt)) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } } // Lightning Orb - else if (npc.ai[0] == 4f) + else if (NPC.ai[0] == 4f) { if (isCultist) - npc.localAI[2] = 12f; + NPC.localAI[2] = 12f; else - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; - if ((npc.ai[1] == 20f & isCultist) && Main.netMode != NetmodeID.MultiplayerClient) + if ((NPC.ai[1] == 20f & isCultist) && Main.netMode != NetmodeID.MultiplayerClient) { List list5 = new List(); for (int j = 0; j < Main.maxNPCs; j++) { - if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == npc.whoAmI) + if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == NPC.whoAmI) list5.Add(j); } @@ -598,70 +609,80 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 playerDirection = Vector2.Normalize(player.Center - center5); if (playerDirection.HasNaNs()) - playerDirection = new Vector2(npc.direction, 0f); + playerDirection = new Vector2(NPC.direction, 0f); - Vector2 shadowFireballDirection = center5 + new Vector2(npc.direction * 30, 12f); + Vector2 shadowFireballDirection = center5 + new Vector2(NPC.direction * 30, 12f); Vector2 shadowFireballVelocity = playerDirection * (fireballSpeed + (float)Main.rand.NextDouble()); shadowFireballVelocity = shadowFireballVelocity.RotatedByRandom(Math.PI / 6D); - Projectile.NewProjectile(npc.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shadowFireballDirection, shadowFireballVelocity, ProjectileID.CultistBossFireBallClone, fireballDamage, 0f, Main.myPlayer); } - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y + (death ? 210f : -100f), 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + (death ? 210f : -100f), 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer); if (death) { - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + 210f, npc.Center.Y - 210f, 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X - 210f, npc.Center.Y - 210f, 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X + 210f, NPC.Center.Y - 210f, 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X - 210f, NPC.Center.Y - 210f, 0f, 0f, ProjectileID.CultistBossLightningOrb, lightningDamage, 0f, Main.myPlayer); } } - npc.ai[1] += 1f; - if (npc.ai[1] >= (20 + lightningOrbPhaseTime)) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (20 + lightningOrbPhaseTime)) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } } // Spawn Clones, and Dragon or Cthulhu head - else if (npc.ai[0] == 5f) + else if (NPC.ai[0] == 5f) { - npc.localAI[2] = 10f; + NPC.localAI[2] = 10f; - if (Vector2.Normalize(player.Center - npc.Center).HasNaNs()) - new Vector2(npc.direction, 0f); + if (Vector2.Normalize(player.Center - NPC.Center).HasNaNs()) + new Vector2(NPC.direction, 0f); - if (npc.ai[1] >= 0f && npc.ai[1] < 30f) + if (NPC.ai[1] >= 0f && NPC.ai[1] < 30f) { dontTakeDamage = true; - float cultistAlphaControl = (npc.ai[1] - 0f) / 30f; - npc.alpha = (int)(cultistAlphaControl * 255f); + float cultistAlphaControl = (NPC.ai[1] - 0f) / 30f; + NPC.alpha = (int)(cultistAlphaControl * 255f); } - else if (npc.ai[1] >= 30f && npc.ai[1] < 90f) + else if (NPC.ai[1] >= 30f && NPC.ai[1] < 90f) { - if ((npc.ai[1] == 30f && Main.netMode != NetmodeID.MultiplayerClient) & isCultist) + if ((NPC.ai[1] == 30f && Main.netMode != NetmodeID.MultiplayerClient) & isCultist) { - npc.localAI[1] += 1f; + NPC.localAI[1] += 1f; Vector2 spinningpoint = new Vector2(180f, 0f); List list6 = new List(); for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == npc.whoAmI) + if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == NPC.whoAmI) list6.Add(k); } - - int potentialExtraClones = 6 - list6.Count; - if (potentialExtraClones > 2) - potentialExtraClones = 2; + int maxClonesSpawned = 2; + if (death) + maxClonesSpawned += 2; + if (lifeRatio < 0.75f) + maxClonesSpawned++; + if (lifeRatio < 0.5f) + maxClonesSpawned++; + if (lifeRatio < 0.25f) + maxClonesSpawned++; + if (lifeRatio < 0.1f) + maxClonesSpawned++; + int potentialExtraClones = 8 - list6.Count; + if (potentialExtraClones > maxClonesSpawned) + potentialExtraClones = maxClonesSpawned; int newCloneAmt = list6.Count + potentialExtraClones + 1; float[] array = new float[newCloneAmt]; for (int cloneInc = 0; cloneInc < array.Length; cloneInc++) - array[cloneInc] = Vector2.Distance(npc.Center + spinningpoint.RotatedBy(cloneInc * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2), player.Center); + array[cloneInc] = Vector2.Distance(NPC.Center + spinningpoint.RotatedBy(cloneInc * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2), player.Center); int rotateDistance = 0; for (int j = 1; j < array.Length; j++) @@ -680,13 +701,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (rotateDistance != k) { - Vector2 cloneRotation = npc.Center + spinningpoint.RotatedBy(k * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2); + Vector2 cloneRotation = NPC.Center + spinningpoint.RotatedBy(k * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2); if (clonesToSpawn-- > 0) { - int cloneSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)cloneRotation.X, (int)cloneRotation.Y + npc.height / 2, NPCID.CultistBossClone, npc.whoAmI); - Main.npc[cloneSpawn].ai[3] = npc.whoAmI; + int cloneSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)cloneRotation.X, (int)cloneRotation.Y + NPC.height / 2, NPCID.CultistBossClone, NPC.whoAmI); + Main.npc[cloneSpawn].ai[3] = NPC.whoAmI; Main.npc[cloneSpawn].netUpdate = true; - Main.npc[cloneSpawn].localAI[1] = npc.localAI[1]; + Main.npc[cloneSpawn].localAI[1] = NPC.localAI[1]; } else { @@ -697,157 +718,157 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.ai[2] = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, Vector2.Zero, ProjectileID.CultistRitual, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - npc.Center += spinningpoint.RotatedBy(rotateDistance * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2); - npc.netUpdate = true; + NPC.ai[2] = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ProjectileID.CultistRitual, 0, 0f, Main.myPlayer, 0f, NPC.whoAmI); + NPC.Center += spinningpoint.RotatedBy(rotateDistance * MathHelper.TwoPi / newCloneAmt - MathHelper.PiOver2); + NPC.netUpdate = true; list6.Clear(); } dontTakeDamage = true; - npc.alpha = 255; + NPC.alpha = 255; if (isCultist) { - Vector2 ritualCenterDirection = Main.projectile[(int)npc.ai[2]].Center; - ritualCenterDirection -= npc.Center; + Vector2 ritualCenterDirection = Main.projectile[(int)NPC.ai[2]].Center; + ritualCenterDirection -= NPC.Center; if (ritualCenterDirection == Vector2.Zero) ritualCenterDirection = -Vector2.UnitY; ritualCenterDirection.Normalize(); if (Math.Abs(ritualCenterDirection.Y) < 0.77f) - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; else if (ritualCenterDirection.Y < 0f) - npc.localAI[2] = 12f; + NPC.localAI[2] = 12f; else - npc.localAI[2] = 10f; + NPC.localAI[2] = 10f; int ritualFaceDirection = Math.Sign(ritualCenterDirection.X); if (ritualFaceDirection != 0) - npc.direction = npc.spriteDirection = ritualFaceDirection; + NPC.direction = NPC.spriteDirection = ritualFaceDirection; } else { - Vector2 ritualCenterFailDirection = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; - ritualCenterFailDirection -= npc.Center; + Vector2 ritualCenterFailDirection = Main.projectile[(int)Main.npc[(int)NPC.ai[3]].ai[2]].Center; + ritualCenterFailDirection -= NPC.Center; if (ritualCenterFailDirection == Vector2.Zero) ritualCenterFailDirection = -Vector2.UnitY; ritualCenterFailDirection.Normalize(); if (Math.Abs(ritualCenterFailDirection.Y) < 0.77f) - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; else if (ritualCenterFailDirection.Y < 0f) - npc.localAI[2] = 12f; + NPC.localAI[2] = 12f; else - npc.localAI[2] = 10f; + NPC.localAI[2] = 10f; int ritualFailFaceDirection = Math.Sign(ritualCenterFailDirection.X); if (ritualFailFaceDirection != 0) - npc.direction = npc.spriteDirection = ritualFailFaceDirection; + NPC.direction = NPC.spriteDirection = ritualFailFaceDirection; } } - else if (npc.ai[1] >= 90f && npc.ai[1] < 120f) + else if (NPC.ai[1] >= 90f && NPC.ai[1] < 120f) { dontTakeDamage = true; - float ritualAlphaControl = (npc.ai[1] - 90f) / 30f; - npc.alpha = 255 - (int)(ritualAlphaControl * 255f); + float ritualAlphaControl = (NPC.ai[1] - 90f) / 30f; + NPC.alpha = 255 - (int)(ritualAlphaControl * 255f); } - else if (npc.ai[1] >= 120f && npc.ai[1] < timeToFinishRitual) + else if (NPC.ai[1] >= 120f && NPC.ai[1] < timeToFinishRitual) { - npc.alpha = 0; + NPC.alpha = 0; if (isCultist) { - Vector2 ritualTimeAlmostUpCenterDirection = Main.projectile[(int)npc.ai[2]].Center; - ritualTimeAlmostUpCenterDirection -= npc.Center; + Vector2 ritualTimeAlmostUpCenterDirection = Main.projectile[(int)NPC.ai[2]].Center; + ritualTimeAlmostUpCenterDirection -= NPC.Center; if (ritualTimeAlmostUpCenterDirection == Vector2.Zero) ritualTimeAlmostUpCenterDirection = -Vector2.UnitY; ritualTimeAlmostUpCenterDirection.Normalize(); if (Math.Abs(ritualTimeAlmostUpCenterDirection.Y) < 0.77f) - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; else if (ritualTimeAlmostUpCenterDirection.Y < 0f) - npc.localAI[2] = 12f; + NPC.localAI[2] = 12f; else - npc.localAI[2] = 10f; + NPC.localAI[2] = 10f; int ritualTimeAlmostUpFaceDirection = Math.Sign(ritualTimeAlmostUpCenterDirection.X); if (ritualTimeAlmostUpFaceDirection != 0) - npc.direction = npc.spriteDirection = ritualTimeAlmostUpFaceDirection; + NPC.direction = NPC.spriteDirection = ritualTimeAlmostUpFaceDirection; } else { - Vector2 ritualTimeUpCenterDirection = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; - ritualTimeUpCenterDirection -= npc.Center; + Vector2 ritualTimeUpCenterDirection = Main.projectile[(int)Main.npc[(int)NPC.ai[3]].ai[2]].Center; + ritualTimeUpCenterDirection -= NPC.Center; if (ritualTimeUpCenterDirection == Vector2.Zero) ritualTimeUpCenterDirection = -Vector2.UnitY; ritualTimeUpCenterDirection.Normalize(); if (Math.Abs(ritualTimeUpCenterDirection.Y) < 0.77f) - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; else if (ritualTimeUpCenterDirection.Y < 0f) - npc.localAI[2] = 12f; + NPC.localAI[2] = 12f; else - npc.localAI[2] = 10f; + NPC.localAI[2] = 10f; int ritualTimeUpFaceDirection = Math.Sign(ritualTimeUpCenterDirection.X); if (ritualTimeUpFaceDirection != 0) - npc.direction = npc.spriteDirection = ritualTimeUpFaceDirection; + NPC.direction = NPC.spriteDirection = ritualTimeUpFaceDirection; } } - npc.ai[1] += 1f; - if (npc.ai[1] >= timeToFinishRitual) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= timeToFinishRitual) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); + CalamityUtils.CalamityTargeting(NPC, options); - npc.netUpdate = true; + NPC.netUpdate = true; } } // Pause - else if (npc.ai[0] == 6f) + else if (NPC.ai[0] == 6f) { - npc.localAI[2] = 13f; + NPC.localAI[2] = 13f; - npc.ai[1] += 1f; - if (npc.ai[1] >= (idleTime * 3)) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (idleTime * 3)) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } } // Ancient Light - else if (npc.ai[0] == 7f) + else if (NPC.ai[0] == 7f) { - npc.localAI[2] = 11f; + NPC.localAI[2] = 11f; - Vector2 playerDirection = Vector2.Normalize(player.Center - npc.Center); + Vector2 playerDirection = Vector2.Normalize(player.Center - NPC.Center); if (playerDirection.HasNaNs()) - playerDirection = new Vector2(npc.direction, 0f); + playerDirection = new Vector2(NPC.direction, 0f); - if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % ancientLightSpawnRate == 0) + if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % ancientLightSpawnRate == 0 && (int)(NPC.ai[1] - 4f) / ancientLightSpawnRate <= (death ? 4 : 3)) { - if ((int)(npc.ai[1] - 4f) / ancientLightSpawnRate == 2) + if ((int)(NPC.ai[1] - 4f) / ancientLightSpawnRate == 2) { List list7 = new List(); for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].active && Main.npc[i].type == NPCID.CultistBossClone && Main.npc[i].ai[3] == npc.whoAmI) + if (Main.npc[i].active && Main.npc[i].type == NPCID.CultistBossClone && Main.npc[i].ai[3] == NPC.whoAmI) list7.Add(i); } @@ -862,1563 +883,337 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - int cultistFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + int cultistFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (cultistFaceDirection != 0) - npc.direction = npc.spriteDirection = cultistFaceDirection; + NPC.direction = NPC.spriteDirection = cultistFaceDirection; if (Main.netMode != NetmodeID.MultiplayerClient) { - playerDirection = Vector2.Normalize(player.Center - npc.Center); + playerDirection = Vector2.Normalize(player.Center - NPC.Center); if (playerDirection.HasNaNs()) - playerDirection = new Vector2(npc.direction, 0f); + playerDirection = new Vector2(NPC.direction, 0f); - Vector2 ancientLightShootDirection = npc.Center + new Vector2(npc.direction * 30, 12f); - float scaleFactor = death ? 6f : 4f; + Vector2 ancientLightShootDirection = NPC.Center; + float scaleFactor = death ? 5f : 4f; - float ancientLightSpread = MathHelper.ToRadians(15f); - int ancientLightInc = 0; - float totalAncientLights = 5f; - while (ancientLightInc < totalAncientLights) + float ancientLightSpread = MathHelper.ToRadians(CalamityWorld.death ? 90f : 80f); + float totalAncientLights = death ? 9 : 7; + float adjustTotal = totalAncientLights - 1; + for (var i = 0; i < totalAncientLights; i++) { - Vector2 ancientLightSpeed = playerDirection * scaleFactor; - ancientLightSpeed = ancientLightSpeed.RotatedBy(ancientLightSpread * ancientLightInc - (MathHelper.Pi / totalAncientLights * 2f - ancientLightSpread) / 2f); - float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * MathHelper.TwoPi / 60f; - int ancientLightProj = NPC.NewNPC(npc.GetSource_FromAI(), (int)ancientLightShootDirection.X, (int)ancientLightShootDirection.Y + 7, NPCID.AncientLight, 0, 0f, ai, ancientLightSpeed.X, ancientLightSpeed.Y); + var shotgunscalar = Math.Abs(i - (adjustTotal * 0.5f)) / (adjustTotal * 0.5f); + float angleOffset = ancientLightSpread * (i / adjustTotal) - ancientLightSpread * 0.5f; + Vector2 ancientLightSpeed = playerDirection.RotatedBy(angleOffset) * scaleFactor * (0.75f + 1.5f * shotgunscalar); + float ai = (Main.rand.NextFloat() - 0.5f) * 0.2f * MathHelper.TwoPi / 60f; + int ancientLightProj = NPC.NewNPC(NPC.GetSource_FromAI(), (int)ancientLightShootDirection.X, (int)ancientLightShootDirection.Y + 7, NPCID.AncientLight, 0, 0f, ai, ancientLightSpeed.X, ancientLightSpeed.Y); Main.npc[ancientLightProj].velocity = ancientLightSpeed; - ancientLightInc++; } } } - npc.ai[1] += 1f; - if (npc.ai[1] >= (4 + ancientLightSpawnRate * ancientLightAmt)) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (30 + ancientLightSpawnRate * ancientLightAmt)) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } } // Ancient Doom - else if (npc.ai[0] == 8f) + else if (NPC.ai[0] == 8f) { - npc.localAI[2] = 13f; + NPC.localAI[2] = 13f; - if ((npc.ai[1] >= 4f & isCultist) && (int)(npc.ai[1] - 4f) % 20f == 0f) + if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % 20f == 0f && NPC.ai[1] <= 64) { List list8 = new List(); for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == npc.whoAmI) + if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == NPC.whoAmI) list8.Add(k); } - int ancientDoomAmt = list8.Count + 1; - if (ancientDoomAmt > 2) - ancientDoomAmt = 2; + int ancientDoomAmount = 2; + if (lifeRatio < 0.75f && death) + ancientDoomAmount++; + if (lifeRatio < 0.5f) + ancientDoomAmount++; + if (lifeRatio < 0.25f && death) + ancientDoomAmount++; - int ancientDoomFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + int ancientDoomFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (ancientDoomFaceDirection != 0) - npc.direction = npc.spriteDirection = ancientDoomFaceDirection; + NPC.direction = NPC.spriteDirection = ancientDoomFaceDirection; if (Main.netMode != NetmodeID.MultiplayerClient) { - if (phase4) - { // Spawn circle of Ancient Dooms around target - for (int i = 0; i < ancientDoomLimit; i++) + for (int i = 0; i < ancientDoomAmount; i++) { - float ai2 = i * 120; - NPC.NewNPC(npc.GetSource_FromAI(), (int)(player.Center.X + (float)(Math.Sin(i * 120) * 550)), (int)(player.Center.Y + (float)(Math.Cos(i * 120) * 550)), - NPCID.AncientDoom, 0, npc.whoAmI, 0f, ai2, 0f, Main.maxPlayers); + float ai2 = i * (360f/ancientDoomAmount); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + (float)(Math.Sin(i * 120) * 550)), (int)(player.Center.Y + (float)(Math.Cos(i * 120) * 550)), + NPCID.AncientDoom, 0, NPC.whoAmI, 0f, ai2, 0f, Main.maxPlayers); } - } - else - { - // Spawn Ancient Dooms randomly around the target - for (int i = 0; i < ancientDoomAmt; i++) - { - Point cultistCenterTileCoords = npc.Center.ToTileCoordinates(); - Point targetCenterTileCoords = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 targetDistanceDoom = Main.player[npc.target].Center - npc.Center; - int randSpawnOffset = 20; - int cultistCenterSpawnOffset = 3; - int targetCenterSpawnOffset = 7; - int tileCollisionRange = 2; - int spawnAttempts = 0; - bool doomSufficientlyFar = targetDistanceDoom.Length() > 2800f; - while (!doomSufficientlyFar && spawnAttempts < 100) - { - spawnAttempts++; - int ancientDoomSpawnX = Main.rand.Next(targetCenterTileCoords.X - randSpawnOffset, targetCenterTileCoords.X + randSpawnOffset + 1); - int ancientDoomSpawnY = Main.rand.Next(targetCenterTileCoords.Y - randSpawnOffset, targetCenterTileCoords.Y + randSpawnOffset + 1); - if ((ancientDoomSpawnY < targetCenterTileCoords.Y - targetCenterSpawnOffset || ancientDoomSpawnY > targetCenterTileCoords.Y + targetCenterSpawnOffset || ancientDoomSpawnX < targetCenterTileCoords.X - targetCenterSpawnOffset || ancientDoomSpawnX > targetCenterTileCoords.X + targetCenterSpawnOffset) && (ancientDoomSpawnY < cultistCenterTileCoords.Y - cultistCenterSpawnOffset || ancientDoomSpawnY > cultistCenterTileCoords.Y + cultistCenterSpawnOffset || ancientDoomSpawnX < cultistCenterTileCoords.X - cultistCenterSpawnOffset || ancientDoomSpawnX > cultistCenterTileCoords.X + cultistCenterSpawnOffset) && !Main.tile[ancientDoomSpawnX, ancientDoomSpawnY].HasUnactuatedTile) - { - bool notInsideTiles = true; - if (notInsideTiles && Collision.SolidTiles(ancientDoomSpawnX - tileCollisionRange, ancientDoomSpawnX + tileCollisionRange, ancientDoomSpawnY - tileCollisionRange, ancientDoomSpawnY + tileCollisionRange)) - notInsideTiles = false; - - if (notInsideTiles) - { - NPC.NewNPC(npc.GetSource_FromAI(), ancientDoomSpawnX * 16 + 8, ancientDoomSpawnY * 16 + 8, NPCID.AncientDoom, 0, npc.whoAmI); - break; - } - } - } - } - } } } - npc.ai[1] += 1f; - if (npc.ai[1] >= 64f) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 195f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] += 1f; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } } // Set Clones to Cultist phase if (!isCultist) - npc.ai[3] = clonePhase; + NPC.ai[3] = clonePhase; // Take damage or not - npc.dontTakeDamage = dontTakeDamage; - npc.chaseable = npc.ai[0] != -1f && npc.ai[0] != 5f; + NPC.dontTakeDamage = dontTakeDamage; + NPC.chaseable = NPC.ai[0] != -1f && NPC.ai[0] != 5f; return false; } - public static bool BuffedAncientLightAI(NPC npc, Mod mod) + public class AncientLightAI : VanillaAIOverride { - npc.dontTakeDamage = true; - - // Slow and kill code - if (npc.ai[0] == -1f) + public override bool AI(Mod mod) { - // Slow down over time - if (npc.velocity.Length() >= 0.2f) - { - npc.velocity *= 0.96f; - } - else - { - npc.velocity = Vector2.Zero; - npc.position = npc.oldPosition; + NPC.dontTakeDamage = true; - // Kill after 4 seconds - npc.ai[1] += 1f; - if (npc.ai[1] >= 240f) + // Slow and kill code + if (NPC.ai[0] == -1f) + { + // Slow down over time + if (NPC.velocity.Length() >= 0.2f) { - npc.HitEffect(0, 9999.0); - npc.active = false; - } - } - - return false; - } - - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - - // Set velocity and emit dust when spawned - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - npc.velocity.X = npc.ai[2]; - npc.velocity.Y = npc.ai[3]; - for (int i = 0; i < 13; i++) - { - int ancientLight = Dust.NewDust(npc.position, npc.width, npc.height, DustID.AncientLight, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); - Main.dust[ancientLight].noGravity = true; - Main.dust[ancientLight].fadeIn = 1f; - Dust dust = Main.dust[ancientLight]; - dust.velocity *= 4f; - Main.dust[ancientLight].noLight = true; - } - } - - // Spawn dust - for (int j = 0; j < 2; j++) - { - if (Main.rand.Next(10 - (int)Math.Min(7f, npc.velocity.Length())) < 1) - { - int ancientLight2 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.AncientLight, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); - Main.dust[ancientLight2].noGravity = true; - Dust dust = Main.dust[ancientLight2]; - dust.velocity *= 0.2f; - Main.dust[ancientLight2].fadeIn = 0.4f; - if (Main.rand.NextBool(6)) - { - dust = Main.dust[ancientLight2]; - dust.velocity *= 5f; - Main.dust[ancientLight2].noLight = true; + NPC.velocity *= 0.96f; } else - Main.dust[ancientLight2].velocity = npc.DirectionFrom(Main.dust[ancientLight2].position) * Main.dust[ancientLight2].velocity.Length(); - } - } - - if (npc.ai[0] >= 0f) - { - // Triple damage if the Primordial Wyrm is alive - if (npc.ai[0] == 0f) - { - if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) { - if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) - npc.damage *= 3; + NPC.velocity = Vector2.Zero; + NPC.position = NPC.oldPosition; + + // Kill after half a second + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 30f) + { + NPC.HitEffect(0, 9999.0); + NPC.active = false; } } - npc.ai[0] += 1f; - - float duration = 120f; - - // Increase velocity for 1 second - if (npc.ai[0] < duration - 60f) - { - if (npc.velocity.Length() < 20f) - npc.velocity *= 1.03f; - } - - // Intersect velocity paths with other Ancient Lights for 1 second - if (npc.ai[0] >= duration - 60f) - npc.velocity = npc.velocity.RotatedBy(npc.ai[1]); - - // Engage slow code - if (npc.ai[0] >= duration) - npc.ai[0] = -1f; - } - - return false; - } - - public static bool BuffedAncientDoomAI(NPC npc, Mod mod) - { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - npc.damage = npc.defDamage = 0; - float duration = 420f; - float spawnAnimTime = 120f; - int rateOfChange = death ? 2 : 1; - float splitProjVelocity = death ? 4.5f : 3f; - - // Percent life remaining for Cultist or Eidolon Wyrm - float lifeRatio = Main.npc[(int)npc.ai[0]].life / (float)Main.npc[(int)npc.ai[0]].lifeMax; - - bool phase2 = lifeRatio < 0.7f; - bool phase3 = lifeRatio < (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType() ? 0.6f : 0.55f); - bool phase4 = lifeRatio < 0.4f; - - bool kill = npc.ai[1] < 0f || !Main.npc[(int)npc.ai[0]].active; - int target = Main.maxPlayers; - if (Main.npc[(int)npc.ai[0]].type == NPCID.CultistBoss || Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) - { - if (target == Main.maxPlayers) - target = Main.npc[(int)npc.ai[0]].target; - - if (phase2 || death) - rateOfChange++; - - if (phase4 || death) - rateOfChange++; - - if (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) - npc.dontTakeDamage = true; - } - else - kill = true; - - npc.ai[1] += rateOfChange; - float growthRate = npc.ai[1] / spawnAnimTime; - growthRate = MathHelper.Clamp(growthRate, 0f, 1f); - npc.position = npc.Center; - npc.scale = MathHelper.Lerp(0f, 1f, growthRate); - npc.Center = npc.position; - npc.alpha = (int)(255f - growthRate * 255f); - - if (phase3) - { - if (npc.ai[3] == 0f) - npc.ai[3] = npc.ai[2]; - - double deg = npc.ai[3]; - double rad = deg * (Math.PI / 180); - double dist = 550; - if (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) - { - float aiGateValue = Main.npc[(int)npc.ai[0]].Calamity().newAI[2] - 30f; - int ancientDoomScale = (int)(aiGateValue / 120f); - dist += ancientDoomScale * 45; - } - npc.position.X = Main.player[target].Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; - npc.position.Y = Main.player[target].Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; - float spinVelocity = 8f * (1f - (npc.ai[1] / duration)); - npc.ai[3] += spinVelocity; - } - - if (Main.rand.NextBool(6)) - { - Vector2 shadowflameDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust shadowflameDust = Main.dust[Dust.NewDust(npc.Center - shadowflameDustRotate * 20f, 0, 0, DustID.Shadowflame, 0f, 0f, 0, default, 1f)]; - shadowflameDust.noGravity = true; - shadowflameDust.position = npc.Center - shadowflameDustRotate * Main.rand.Next(10, 21) * npc.scale; - shadowflameDust.velocity = shadowflameDustRotate.RotatedBy(MathHelper.PiOver2) * 4f; - shadowflameDust.scale = 0.5f + Main.rand.NextFloat(); - shadowflameDust.fadeIn = 0.5f; - } - if (Main.rand.NextBool(6)) - { - Vector2 darkDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust darkDust = Main.dust[Dust.NewDust(npc.Center - darkDustRotate * 30f, 0, 0, DustID.Granite, 0f, 0f, 0, default, 1f)]; - darkDust.noGravity = true; - darkDust.position = npc.Center - darkDustRotate * 20f * npc.scale; - darkDust.velocity = darkDustRotate.RotatedBy(-MathHelper.PiOver2) * 2f; - darkDust.scale = 0.5f + Main.rand.NextFloat(); - darkDust.fadeIn = 0.5f; - } - if (Main.rand.NextBool(6)) - { - Vector2 darkDustRotate2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust darkDust2 = Main.dust[Dust.NewDust(npc.Center - darkDustRotate2 * 30f, 0, 0, DustID.Granite, 0f, 0f, 0, default, 1f)]; - darkDust2.position = npc.Center - darkDustRotate2 * 20f * npc.scale; - darkDust2.velocity = Vector2.Zero; - darkDust2.scale = 0.5f + Main.rand.NextFloat(); - darkDust2.fadeIn = 0.5f; - darkDust2.noLight = true; - } - - npc.localAI[0] += (float)(Math.PI / 60D); - - npc.localAI[1] = 0.25f + Vector2.UnitY.RotatedBy(npc.ai[1] * MathHelper.TwoPi / 60f).Y * 0.25f; - - if (npc.ai[1] >= duration) - { - int type = ProjectileID.AncientDoomProjectile; - int damage = npc.GetProjectileDamage(type); - - // Triple damage if the Primordial Wyrm is alive - if (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) - damage *= 3; - - kill = true; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalProjectiles = CalamityWorld.LegendaryMode ? 9 : (Main.npc[(int)npc.ai[0]].type == NPCID.CultistBoss && !phase3) ? 8 : death ? 5 : 4; - float radians = MathHelper.TwoPi / totalProjectiles; - Vector2 spinningPoint = new Vector2(0f, -splitProjVelocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 doomProjRotate = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, doomProjRotate, type, damage, 0f, Main.myPlayer); - } - } - } - - if (kill) - { - npc.HitEffect(0, 9999.0); - npc.active = false; - } - - return false; - } - - public static bool VanillaCultistAI(NPC npc, Mod mod) - { - // Chant sound - if (npc.ai[0] != -1f && Main.rand.NextBool(1000)) - { - SoundStyle chantSound = Utils.SelectRandom(Main.rand, new SoundStyle[] - { - SoundID.Zombie88, - SoundID.Zombie89, - SoundID.Zombie90, - SoundID.Zombie91 - }); - - SoundEngine.PlaySound(chantSound, npc.Center); - } - - bool expertMode = Main.expertMode; - bool masterMode = Main.masterMode; - - bool phase2 = npc.life <= npc.lifeMax / 2; - - int iceMistPhaseTime = masterMode ? 60 : expertMode ? 90 : 120; - if (Main.getGoodWorld) - iceMistPhaseTime -= 30; - - int fireballPhaseTime = Main.getGoodWorld ? 8 : masterMode ? 10 : expertMode ? 12 : 18; - int fireballAmount = Main.getGoodWorld ? 6 : masterMode ? 5 : expertMode ? 4 : 3; - - int lightningOrbPhaseTime = masterMode ? 30 : expertMode ? 40 : 80; - if (Main.getGoodWorld) - lightningOrbPhaseTime -= 20; - - int ancientLightPhaseTime = masterMode ? 40 : expertMode ? 30 : 20; - int ancientLightAmount = masterMode ? 4 : expertMode ? 3 : 2; - - int ancientDoomPhaseTime = masterMode ? 30 : 20; - int ancientDoomAmount = masterMode ? 5 : 3; - - int ritualTimeMax = phase2 ? 240 : 300; - - bool flag2 = npc.type == NPCID.CultistBoss; - bool flag3 = false; - bool flag4 = false; - if (phase2) - npc.defense = (int)Math.Round(npc.defDefense * 0.65); - - if (!flag2) - { - if (npc.ai[3] < 0f || !Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != NPCID.CultistBoss) - { - npc.life = 0; - npc.HitEffect(); - npc.active = false; return false; } - npc.ai[0] = Main.npc[(int)npc.ai[3]].ai[0]; - npc.ai[1] = Main.npc[(int)npc.ai[3]].ai[1]; - if (npc.ai[0] == 5f) - { - if (npc.justHit) - { - npc.life = 0; - npc.HitEffect(); - npc.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; - NPC obj = Main.npc[(int)npc.ai[3]]; - obj.ai[0] = 6f; - obj.ai[1] = 0f; - obj.netUpdate = true; - } - } - else + // Set velocity and emit dust when spawned + if (NPC.localAI[0] == 0f) { - flag3 = true; - flag4 = true; - } - } - else if (npc.ai[0] == 5f && npc.ai[1] >= 120f && npc.ai[1] < ritualTimeMax && npc.justHit) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - List list = new List(); - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == NPCID.CultistBossClone && Main.npc[i].ai[3] == (float)npc.whoAmI) - list.Add(i); - } - - int num9 = expertMode ? 3 : 10; - foreach (int item in list) - { - NPC nPC = Main.npc[item]; - if (nPC.localAI[1] == npc.localAI[1] && num9 > 0) + NPC.localAI[0] = 1f; + NPC.velocity.X = NPC.ai[2]; + NPC.velocity.Y = NPC.ai[3]; + for (int i = 0; i < 13; i++) { - num9--; - nPC.life = 0; - nPC.HitEffect(); - nPC.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, item); - } - else if (num9 > 0) - { - num9--; - nPC.life = 0; - nPC.HitEffect(); - nPC.active = false; + int ancientLight = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.AncientLight, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 2.5f); + Main.dust[ancientLight].noGravity = true; + Main.dust[ancientLight].fadeIn = 1f; + Dust dust = Main.dust[ancientLight]; + dust.velocity *= 4f; + Main.dust[ancientLight].noLight = true; } } - if (Main.netMode != NetmodeID.MultiplayerClient) + // Spawn dust + for (int j = 0; j < 2; j++) { - if (expertMode) + if (Main.rand.Next(10 - (int)Math.Min(7f, NPC.velocity.Length())) < 1) { - if (!NPC.AnyNPCs(NPCID.AncientCultistSquidhead)) - NPC.NewNPC(npc.GetSource_FromAI(), (int)Main.projectile[(int)npc.ai[2]].Center.X, (int)Main.projectile[(int)npc.ai[2]].Center.Y, NPCID.AncientCultistSquidhead); - } - } - - Main.projectile[(int)npc.ai[2]].ai[1] = -1f; - Main.projectile[(int)npc.ai[2]].netUpdate = true; - } - - Vector2 center = npc.Center; - Player player = Main.player[npc.target]; - float num10 = 5600f; - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, center) > num10) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); - - player = Main.player[npc.target]; - npc.netUpdate = true; - } - - if (player.dead || !player.active || Vector2.Distance(player.Center, center) > num10) - { - npc.life = 0; - npc.HitEffect(); - npc.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); - - new List().Add(npc.whoAmI); - for (int j = 0; j < Main.maxNPCs; j++) - { - if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == (float)npc.whoAmI) - { - Main.npc[j].life = 0; - Main.npc[j].HitEffect(); - Main.npc[j].active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); - } - } - } - - float num11 = npc.ai[3]; - if (npc.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Zombie89, npc.Center); - npc.localAI[0] = 1f; - npc.alpha = 255; - npc.rotation = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = -1f; - npc.netUpdate = true; - } - } - - if (npc.ai[0] == -1f) - { - npc.alpha -= 5; - if (npc.alpha < 0) - npc.alpha = 0; - - npc.ai[1] += 1f; - if (npc.ai[1] >= 420f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - else if (npc.ai[1] > 360f) - { - npc.velocity *= 0.95f; - if (npc.localAI[2] != 13f) - SoundEngine.PlaySound(SoundID.Zombie105, npc.Center); - - npc.localAI[2] = 13f; - } - else if (npc.ai[1] > 300f) - { - npc.velocity = -Vector2.UnitY; - npc.localAI[2] = 10f; - } - else if (npc.ai[1] > 120f) - npc.localAI[2] = 1f; - else - npc.localAI[2] = 0f; - - flag3 = true; - flag4 = true; - } - - if (npc.ai[0] == 0f) - { - if (npc.ai[1] == 0f) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); - } - - npc.localAI[2] = 10f; - int num12 = Math.Sign(player.Center.X - center.X); - if (num12 != 0) - npc.direction = (npc.spriteDirection = num12); - - npc.ai[1] += 1f; - if (npc.ai[1] >= 40f && flag2) - { - int num13 = 0; - if (phase2) - { - switch ((int)npc.ai[3]) + int ancientLight2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.AncientLight, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 2.5f); + Main.dust[ancientLight2].noGravity = true; + Dust dust = Main.dust[ancientLight2]; + dust.velocity *= 0.2f; + Main.dust[ancientLight2].fadeIn = 0.4f; + if (Main.rand.NextBool(6)) { - case 0: - num13 = 0; - break; - case 1: - num13 = 1; - break; - case 2: - num13 = 0; - break; - case 3: - num13 = 5; - break; - case 4: - num13 = 0; - break; - case 5: - num13 = 3; - break; - case 6: - num13 = 0; - break; - case 7: - num13 = 5; - break; - case 8: - num13 = 0; - break; - case 9: - num13 = 2; - break; - case 10: - num13 = 0; - break; - case 11: - num13 = 3; - break; - case 12: - num13 = 0; - break; - case 13: - num13 = 4; - npc.ai[3] = -1f; - break; - default: - npc.ai[3] = -1f; - break; + dust = Main.dust[ancientLight2]; + dust.velocity *= 5f; + Main.dust[ancientLight2].noLight = true; } - } - else - { - switch ((int)npc.ai[3]) - { - case 0: - num13 = 0; - break; - case 1: - num13 = 1; - break; - case 2: - num13 = 0; - break; - case 3: - num13 = 2; - break; - case 4: - num13 = 0; - break; - case 5: - num13 = 3; - break; - case 6: - num13 = 0; - break; - case 7: - num13 = 1; - break; - case 8: - num13 = 0; - break; - case 9: - num13 = 2; - break; - case 10: - num13 = 0; - break; - case 11: - num13 = 4; - npc.ai[3] = -1f; - break; - default: - npc.ai[3] = -1f; - break; - } - } - - int maxValue = 6; - if (npc.life < npc.lifeMax / 3) - maxValue = 4; - if (npc.life < npc.lifeMax / 4) - maxValue = 3; - if (masterMode) - maxValue--; - - if (expertMode && phase2 && Main.rand.NextBool(maxValue) && num13 != 0 && num13 != 4 && num13 != 5 && NPC.CountNPCS(NPCID.AncientDoom) < 10) - num13 = 6; - - if (num13 == 0) - { - float num14 = (float)Math.Ceiling((player.Center + new Vector2(0f, -100f) - center).Length() / 50f); - if (num14 == 0f) - num14 = 1f; - - List list2 = new List(); - int num15 = 0; - list2.Add(npc.whoAmI); - for (int k = 0; k < Main.maxNPCs; k++) - { - if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == (float)npc.whoAmI) - list2.Add(k); - } - - bool flag5 = list2.Count % 2 == 0; - foreach (int item2 in list2) - { - NPC nPC2 = Main.npc[item2]; - Vector2 center2 = nPC2.Center; - float num16 = (float)((num15 + flag5.ToInt() + 1) / 2) * MathHelper.TwoPi * 0.4f / (float)list2.Count; - if (num15 % 2 == 1) - num16 *= -1f; - - if (list2.Count == 1) - num16 = 0f; - - Vector2 vector = new Vector2(0f, -1f).RotatedBy(num16) * new Vector2(300f, 200f); - Vector2 vector2 = player.Center + vector - center2; - nPC2.ai[0] = 1f; - nPC2.ai[1] = num14 * 2f; - nPC2.velocity = vector2 / num14; - if (npc.whoAmI >= nPC2.whoAmI) - nPC2.position -= nPC2.velocity; - - nPC2.netUpdate = true; - num15++; - } - } - - switch (num13) - { - case 1: - npc.ai[0] = 3f; - npc.ai[1] = 0f; - break; - case 2: - npc.ai[0] = 2f; - npc.ai[1] = 0f; - break; - case 3: - npc.ai[0] = 4f; - npc.ai[1] = 0f; - break; - case 4: - npc.ai[0] = 5f; - npc.ai[1] = 0f; - break; - } - - if (num13 == 5) - { - npc.ai[0] = 7f; - npc.ai[1] = 0f; - } - - if (num13 == 6) - { - npc.ai[0] = 8f; - npc.ai[1] = 0f; - } - - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 1f) - { - flag3 = true; - npc.localAI[2] = 10f; - if ((float)(int)npc.ai[1] % 2f != 0f && npc.ai[1] != 1f) - npc.position -= npc.velocity; - - npc.ai[1] -= 1f; - if (npc.ai[1] <= 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 2f) - { - npc.localAI[2] = 11f; - Vector2 vec = Vector2.Normalize(player.Center - center); - if (vec.HasNaNs()) - vec = new Vector2(npc.direction, 0f); - - if (npc.ai[1] >= 4f && flag2 && (int)(npc.ai[1] - 4f) % iceMistPhaseTime == 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - List list3 = new List(); - for (int l = 0; l < Main.maxNPCs; l++) - { - if (Main.npc[l].active && Main.npc[l].type == NPCID.CultistBossClone && Main.npc[l].ai[3] == (float)npc.whoAmI) - list3.Add(l); - } - - foreach (int item3 in list3) - { - NPC nPC3 = Main.npc[item3]; - Vector2 center3 = nPC3.Center; - int num17 = Math.Sign(player.Center.X - center3.X); - if (num17 != 0) - nPC3.direction = (nPC3.spriteDirection = num17); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - vec = Vector2.Normalize(player.Center - center3); - if (vec.HasNaNs()) - vec = new Vector2(npc.direction, 0f); - - Vector2 vector3 = center3 + new Vector2(npc.direction * 30, 12f); - int type = ProjectileID.CultistBossFireBallClone; - float velocity = masterMode ? 10f : expertMode ? 8f : 6f; - Vector2 spinninpoint = vec * (velocity + (float)Main.rand.NextDouble() * 4f); - spinninpoint = spinninpoint.RotatedByRandom(Math.PI / 6D); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector3, spinninpoint, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - } - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - vec = Vector2.Normalize(player.Center - center); - if (vec.HasNaNs()) - vec = new Vector2(npc.direction, 0f); - - Vector2 vector4 = npc.Center + new Vector2(npc.direction * 30, 12f); - int type = ProjectileID.CultistBossIceMist; - int numIceMists = masterMode ? 3 : expertMode ? 2 : 1; - float iceMistVelocity = masterMode ? 8f : expertMode ? 6f : 4f; - for (int n = 0; n < numIceMists; n++) - { - Vector2 vector5 = vec * (iceMistVelocity - n * 2f); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector4, vector5, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, 1f); - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(4 + iceMistPhaseTime)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 3f) - { - npc.localAI[2] = 11f; - Vector2 vec2 = Vector2.Normalize(player.Center - center); - if (vec2.HasNaNs()) - vec2 = new Vector2(npc.direction, 0f); - - if (npc.ai[1] >= 4f && flag2 && (int)(npc.ai[1] - 4f) % fireballPhaseTime == 0) - { - if ((int)(npc.ai[1] - 4f) / fireballPhaseTime == 2) - { - List list4 = new List(); - for (int num18 = 0; num18 < Main.maxNPCs; num18++) - { - if (Main.npc[num18].active && Main.npc[num18].type == NPCID.CultistBossClone && Main.npc[num18].ai[3] == (float)npc.whoAmI) - list4.Add(num18); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - foreach (int item4 in list4) - { - NPC nPC4 = Main.npc[item4]; - Vector2 center4 = nPC4.Center; - int num19 = Math.Sign(player.Center.X - center4.X); - if (num19 != 0) - nPC4.direction = (nPC4.spriteDirection = num19); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - vec2 = Vector2.Normalize(player.Center - center4); - if (vec2.HasNaNs()) - vec2 = new Vector2(npc.direction, 0f); - - Vector2 vector6 = center4 + new Vector2(npc.direction * 30, 12f); - int type = ProjectileID.CultistBossFireBallClone; - float velocity = masterMode ? 10f : expertMode ? 8f : 6f; - Vector2 spinninpoint2 = vec2 * (velocity + (float)Main.rand.NextDouble() * 4f); - spinninpoint2 = spinninpoint2.RotatedByRandom(Math.PI / 6D); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector6, spinninpoint2, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - } - } - } - } - - int num21 = Math.Sign(player.Center.X - center.X); - if (num21 != 0) - npc.direction = (npc.spriteDirection = num21); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - vec2 = Vector2.Normalize(player.Center - center); - if (vec2.HasNaNs()) - vec2 = new Vector2(npc.direction, 0f); - - Vector2 vector7 = npc.Center + new Vector2(npc.direction * 30, 12f); - int type = ProjectileID.CultistBossFireBall; - float velocity = masterMode ? 10f : expertMode ? 8f : 6f; - double spread = Math.PI / (masterMode ? 4D : expertMode ? 5D : 6D); - Vector2 spinninpoint3 = vec2 * (velocity + (float)Main.rand.NextDouble() * 4f); - spinninpoint3 = spinninpoint3.RotatedByRandom(spread); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector7, spinninpoint3, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(4 + fireballPhaseTime * fireballAmount)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 4f) - { - if (flag2) - npc.localAI[2] = 12f; - else - npc.localAI[2] = 11f; - - if (npc.ai[1] == 20f && flag2 && Main.netMode != NetmodeID.MultiplayerClient) - { - List list5 = new List(); - for (int num23 = 0; num23 < Main.maxNPCs; num23++) - { - if (Main.npc[num23].active && Main.npc[num23].type == NPCID.CultistBossClone && Main.npc[num23].ai[3] == (float)npc.whoAmI) - list5.Add(num23); - } - - foreach (int item5 in list5) - { - NPC nPC5 = Main.npc[item5]; - Vector2 center5 = nPC5.Center; - int num24 = Math.Sign(player.Center.X - center5.X); - if (num24 != 0) - nPC5.direction = (nPC5.spriteDirection = num24); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 vector8 = Vector2.Normalize(player.Center - center5); - if (vector8.HasNaNs()) - vector8 = new Vector2(npc.direction, 0f); - - Vector2 vector9 = center5 + new Vector2(npc.direction * 30, 12f); - int type = ProjectileID.CultistBossFireBallClone; - float velocity = masterMode ? 10f : expertMode ? 8f : 6f; - Vector2 spinninpoint4 = vector8 * (velocity + (float)Main.rand.NextDouble() * 4f); - spinninpoint4 = spinninpoint4.RotatedByRandom(Math.PI / 6D); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector9, spinninpoint4, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - } - } - - int type2 = ProjectileID.CultistBossLightningOrb; - if ((int)(npc.ai[1] - 20f) % lightningOrbPhaseTime == 0) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y - 100f, 0f, 0f, type2, npc.GetProjectileDamage(type2), 0f, Main.myPlayer); - - if (masterMode) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + 210f, npc.Center.Y - 210f, 0f, 0f, type2, npc.GetProjectileDamage(type2), 0f, Main.myPlayer); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X - 210f, npc.Center.Y - 210f, 0f, 0f, type2, npc.GetProjectileDamage(type2), 0f, Main.myPlayer); - } - else if (expertMode) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y + 100f, 0f, 0f, type2, npc.GetProjectileDamage(type2), 0f, Main.myPlayer); - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(20 + lightningOrbPhaseTime)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 5f) - { - npc.localAI[2] = 10f; - if (Vector2.Normalize(player.Center - center).HasNaNs()) - new Vector2(npc.direction, 0f); - - if (npc.ai[1] >= 0f && npc.ai[1] < 30f) - { - flag3 = true; - flag4 = true; - float num26 = (npc.ai[1] - 0f) / 30f; - npc.alpha = (int)(num26 * 255f); - } - else if (npc.ai[1] >= 30f && npc.ai[1] < 90f) - { - if (npc.ai[1] == 30f && Main.netMode != NetmodeID.MultiplayerClient && flag2) - { - npc.localAI[1] += 1f; - Vector2 spinningpoint = new Vector2(180f, 0f); - List list6 = new List(); - for (int num27 = 0; num27 < Main.maxNPCs; num27++) - { - if (Main.npc[num27].active && Main.npc[num27].type == NPCID.CultistBossClone && Main.npc[num27].ai[3] == (float)npc.whoAmI) - list6.Add(num27); - } - - int num28 = 6 - list6.Count; - if (num28 > 2) - num28 = 2; - - int num29 = list6.Count + num28 + 1; - float[] array = new float[num29]; - for (int num30 = 0; num30 < array.Length; num30++) - array[num30] = Vector2.Distance(npc.Center + spinningpoint.RotatedBy((float)num30 * MathHelper.TwoPi / (float)num29 - (float)Math.PI / 2f), player.Center); - - int num31 = 0; - for (int num32 = 1; num32 < array.Length; num32++) - { - if (array[num31] > array[num32]) - num31 = num32; - } - - num31 = ((num31 >= num29 / 2) ? (num31 - num29 / 2) : (num31 + num29 / 2)); - int num33 = num28; - for (int num34 = 0; num34 < array.Length; num34++) - { - if (num31 != num34) - { - Vector2 center6 = npc.Center + spinningpoint.RotatedBy((float)num34 * MathHelper.TwoPi / (float)num29 - (float)Math.PI / 2f); - if (num33-- > 0) - { - int num35 = NPC.NewNPC(npc.GetSource_FromAI(), (int)center6.X, (int)center6.Y + npc.height / 2, NPCID.CultistBossClone, npc.whoAmI); - Main.npc[num35].ai[3] = npc.whoAmI; - Main.npc[num35].netUpdate = true; - Main.npc[num35].localAI[1] = npc.localAI[1]; - } - else - { - int num36 = list6[-num33 - 1]; - Main.npc[num36].Center = center6; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num36); - } - } - } - - npc.ai[2] = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, Vector2.Zero, ProjectileID.CultistRitual, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - npc.Center += spinningpoint.RotatedBy((float)num31 * MathHelper.TwoPi / (float)num29 - (float)Math.PI / 2f); - npc.netUpdate = true; - list6.Clear(); - } - - flag3 = true; - flag4 = true; - npc.alpha = 255; - if (flag2) - { - Vector2 vector10 = Main.projectile[(int)npc.ai[2]].Center; - vector10 -= npc.Center; - if (vector10 == Vector2.Zero) - vector10 = -Vector2.UnitY; - - vector10.Normalize(); - if (Math.Abs(vector10.Y) < 0.77f) - npc.localAI[2] = 11f; - else if (vector10.Y < 0f) - npc.localAI[2] = 12f; else - npc.localAI[2] = 10f; - - int num37 = Math.Sign(vector10.X); - if (num37 != 0) - npc.direction = (npc.spriteDirection = num37); - } - else - { - Vector2 vector11 = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; - vector11 -= npc.Center; - if (vector11 == Vector2.Zero) - vector11 = -Vector2.UnitY; - - vector11.Normalize(); - if (Math.Abs(vector11.Y) < 0.77f) - npc.localAI[2] = 11f; - else if (vector11.Y < 0f) - npc.localAI[2] = 12f; - else - npc.localAI[2] = 10f; - - int num38 = Math.Sign(vector11.X); - if (num38 != 0) - npc.direction = (npc.spriteDirection = num38); - } - } - else if (npc.ai[1] >= 90f && npc.ai[1] < 120f) - { - flag3 = true; - flag4 = true; - float num39 = (npc.ai[1] - 90f) / 30f; - npc.alpha = 255 - (int)(num39 * 255f); - } - else if (npc.ai[1] >= 120f && npc.ai[1] < ritualTimeMax) - { - flag4 = true; - npc.alpha = 0; - if (flag2) - { - Vector2 vector12 = Main.projectile[(int)npc.ai[2]].Center; - vector12 -= npc.Center; - if (vector12 == Vector2.Zero) - vector12 = -Vector2.UnitY; - - vector12.Normalize(); - if (Math.Abs(vector12.Y) < 0.77f) - npc.localAI[2] = 11f; - else if (vector12.Y < 0f) - npc.localAI[2] = 12f; - else - npc.localAI[2] = 10f; - - int num40 = Math.Sign(vector12.X); - if (num40 != 0) - npc.direction = (npc.spriteDirection = num40); - } - else - { - Vector2 vector13 = Main.projectile[(int)Main.npc[(int)npc.ai[3]].ai[2]].Center; - vector13 -= npc.Center; - if (vector13 == Vector2.Zero) - vector13 = -Vector2.UnitY; - - vector13.Normalize(); - if (Math.Abs(vector13.Y) < 0.77f) - npc.localAI[2] = 11f; - else if (vector13.Y < 0f) - npc.localAI[2] = 12f; - else - npc.localAI[2] = 10f; - - int num41 = Math.Sign(vector13.X); - if (num41 != 0) - npc.direction = (npc.spriteDirection = num41); + Main.dust[ancientLight2].velocity = NPC.DirectionFrom(Main.dust[ancientLight2].position) * Main.dust[ancientLight2].velocity.Length(); } } - npc.ai[1] += 1f; - if (npc.ai[1] >= ritualTimeMax) + if (NPC.ai[0] >= 0f) { - flag4 = true; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 6f) - { - npc.localAI[2] = 13f; - npc.ai[1] += 1f; - if (npc.ai[1] >= 120f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 7f) - { - npc.localAI[2] = 11f; - Vector2 vec3 = Vector2.Normalize(player.Center - center); - if (vec3.HasNaNs()) - vec3 = new Vector2(npc.direction, 0f); - - if (npc.ai[1] >= 4f && flag2 && (int)(npc.ai[1] - 4f) % ancientLightPhaseTime == 0) - { - if ((int)(npc.ai[1] - 4f) / ancientLightPhaseTime == 2) + // Triple damage if the Primordial Wyrm is alive + if (NPC.ai[0] == 0f) { - List list7 = new List(); - for (int num42 = 0; num42 < Main.maxNPCs; num42++) + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) { - if (Main.npc[num42].active && Main.npc[num42].type == NPCID.CultistBossClone && Main.npc[num42].ai[3] == (float)npc.whoAmI) - list7.Add(num42); - } - - foreach (int item6 in list7) - { - NPC nPC6 = Main.npc[item6]; - Vector2 center7 = nPC6.Center; - int num43 = Math.Sign(player.Center.X - center7.X); - if (num43 != 0) - nPC6.direction = (nPC6.spriteDirection = num43); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - vec3 = Vector2.Normalize(player.Center - center7); - if (vec3.HasNaNs()) - vec3 = new Vector2(npc.direction, 0f); - - Vector2 vector14 = center7 + new Vector2(npc.direction * 30, 12f); - int type = ProjectileID.CultistBossFireBallClone; - float velocity = masterMode ? 10f : expertMode ? 8f : 6f; - for (int num44 = 0; (float)num44 < 5f; num44++) - { - Vector2 spinninpoint5 = vec3 * (velocity + (float)Main.rand.NextDouble() * 4f); - spinninpoint5 = spinninpoint5.RotatedByRandom(MathHelper.TwoPi / 5D); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector14, spinninpoint5, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - } - } + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + NPC.damage = (int)Math.Round(NPC.defDamage * PrimordialWyrmHead.LightDamageMult); } } - int num45 = Math.Sign(player.Center.X - center.X); - if (num45 != 0) - npc.direction = (npc.spriteDirection = num45); + NPC.ai[0] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + float duration = 120f; + + // Increase velocity for 1 second + if (NPC.ai[0] < duration - 60f) { - vec3 = Vector2.Normalize(player.Center - center); - if (vec3.HasNaNs()) - vec3 = new Vector2(npc.direction, 0f); - - Vector2 vector15 = npc.Center + new Vector2(npc.direction * 30, 12f); - float velocity = masterMode ? 14f : expertMode ? 12f : 10f; - float spread = MathHelper.ToRadians(masterMode ? 15f : expertMode ? 20f : 25f); - float ancientLightLimit = 5f; - for (int i = 0; (float)i < ancientLightLimit; i++) - { - Vector2 spinningpoint2 = vec3 * velocity; - spinningpoint2 = spinningpoint2.RotatedBy(spread * (float)i - (MathHelper.TwoPi / ancientLightLimit - spread) / 2f); - float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * MathHelper.TwoPi / 60f; - int num49 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector15.X, (int)vector15.Y + 7, NPCID.AncientLight, 0, 0f, ai, spinningpoint2.X, spinningpoint2.Y); - Main.npc[num49].velocity = spinningpoint2; - Main.npc[num49].netUpdate = true; - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(4 + ancientLightPhaseTime * ancientLightAmount)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 8f) - { - npc.localAI[2] = 13f; - if (npc.ai[1] >= 4f && flag2 && (int)(npc.ai[1] - 4f) % ancientDoomPhaseTime == 0) - { - List list8 = new List(); - for (int num50 = 0; num50 < Main.maxNPCs; num50++) - { - if (Main.npc[num50].active && Main.npc[num50].type == NPCID.CultistBossClone && Main.npc[num50].ai[3] == (float)npc.whoAmI) - list8.Add(num50); + if (NPC.velocity.Length() < 20f) + NPC.velocity *= 1.03f; } - int num51 = list8.Count + 1; - if (num51 > 3) - num51 = 3; + // Intersect velocity paths with other Ancient Lights for 1 second + if (NPC.ai[0] >= duration - 60f) + NPC.velocity = NPC.velocity.RotatedBy(NPC.ai[1]); - int num52 = Math.Sign(player.Center.X - center.X); - if (num52 != 0) - npc.direction = (npc.spriteDirection = num52); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int num53 = 0; num53 < num51; num53++) - { - Point point = npc.Center.ToTileCoordinates(); - Point point2 = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 vector16 = Main.player[npc.target].Center - npc.Center; - int num54 = 20; - int num55 = 3; - int num56 = 7; - int num57 = 2; - int num58 = 0; - bool flag6 = false; - if (vector16.Length() > 2000f) - flag6 = true; - - while (!flag6 && num58 < 100) - { - num58++; - int num59 = Main.rand.Next(point2.X - num54, point2.X + num54 + 1); - int num60 = Main.rand.Next(point2.Y - num54, point2.Y + num54 + 1); - if ((num60 < point2.Y - num56 || num60 > point2.Y + num56 || num59 < point2.X - num56 || num59 > point2.X + num56) && (num60 < point.Y - num55 || num60 > point.Y + num55 || num59 < point.X - num55 || num59 > point.X + num55) && !Main.tile[num59, num60].HasUnactuatedTile) - { - bool flag7 = true; - if (flag7 && Collision.SolidTiles(num59 - num57, num59 + num57, num60 - num57, num60 + num57)) - flag7 = false; - - if (flag7) - { - NPC.NewNPC(npc.GetSource_FromAI(), num59 * 16 + 8, num60 * 16 + 8, NPCID.AncientDoom, 0, npc.whoAmI); - flag6 = true; - break; - } - } - } - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= (float)(4 + ancientDoomPhaseTime * ancientDoomAmount)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[3] += 1f; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; - } - } - - if (!flag2) - npc.ai[3] = num11; - - npc.dontTakeDamage = flag3; - npc.chaseable = !flag4; - - return false; - } - - public static bool VanillaAncientLightAI(NPC npc, Mod mod) - { - npc.dontTakeDamage = true; - - // Slow and kill code - if (npc.ai[0] == -1f) - { - // Slow down over time - if (npc.velocity.Length() >= 0.2f) - { - npc.velocity *= 0.96f; - } - else - { - npc.velocity = Vector2.Zero; - npc.position = npc.oldPosition; - - // Kill after 2 seconds - npc.ai[1] += 1f; - if (npc.ai[1] >= 120f) - { - npc.HitEffect(0, 9999.0); - npc.active = false; - } + // Engage slow code + if (NPC.ai[0] >= duration) + NPC.ai[0] = -1f; } return false; } - - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - - // Set velocity and emit dust when spawned - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - npc.velocity.X = npc.ai[2]; - npc.velocity.Y = npc.ai[3]; - for (int i = 0; i < 13; i++) - { - int ancientLight = Dust.NewDust(npc.position, npc.width, npc.height, DustID.AncientLight, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); - Main.dust[ancientLight].noGravity = true; - Main.dust[ancientLight].fadeIn = 1f; - Dust dust = Main.dust[ancientLight]; - dust.velocity *= 4f; - Main.dust[ancientLight].noLight = true; - } - } - - // Spawn dust - for (int j = 0; j < 2; j++) - { - if (Main.rand.Next(10 - (int)Math.Min(7f, npc.velocity.Length())) < 1) - { - int ancientLight2 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.AncientLight, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 2.5f); - Main.dust[ancientLight2].noGravity = true; - Dust dust = Main.dust[ancientLight2]; - dust.velocity *= 0.2f; - Main.dust[ancientLight2].fadeIn = 0.4f; - if (Main.rand.NextBool(6)) - { - dust = Main.dust[ancientLight2]; - dust.velocity *= 5f; - Main.dust[ancientLight2].noLight = true; - } - else - Main.dust[ancientLight2].velocity = npc.DirectionFrom(Main.dust[ancientLight2].position) * Main.dust[ancientLight2].velocity.Length(); - } - } - - if (npc.ai[0] >= 0f) - { - npc.ai[0] += 1f; - - float duration = 120f; - - // Increase velocity for 1 second - if (npc.ai[0] < duration - 60f) - { - if (npc.velocity.Length() < 16f) - npc.velocity *= 1.005f; - } - - // Intersect velocity paths with other Ancient Lights for 1 second - if (npc.ai[0] >= duration - 60f) - npc.velocity = npc.velocity.RotatedBy(npc.ai[1]); - - // Engage slow code - if (npc.ai[0] >= duration) - npc.ai[0] = -1f; - } - - return false; } - public static bool VanillaAncientDoomAI(NPC npc, Mod mod) + public class AncientDoomAI : VanillaAIOverride { - npc.damage = npc.defDamage = 0; - float duration = 420f; - float spawnAnimTime = 120f; - int rateOfChange = 1; - float splitProjVelocity = Main.masterMode ? 10f : Main.expertMode ? 8f : 6f; - - // Percent life remaining for Cultist or Eidolon Wyrm - float lifeRatio = Main.npc[(int)npc.ai[0]].life / (float)Main.npc[(int)npc.ai[0]].lifeMax; - - bool phase2 = lifeRatio < 0.7f && Main.expertMode; - bool phase3 = lifeRatio < 0.4f && Main.masterMode; - - bool kill = npc.ai[1] < 0f || !Main.npc[(int)npc.ai[0]].active; - int target = Main.maxPlayers; - if (Main.npc[(int)npc.ai[0]].type == NPCID.CultistBoss) + public override bool AI(Mod mod) { - if (target == Main.maxPlayers) - target = Main.npc[(int)npc.ai[0]].target; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + NPC.damage = NPC.defDamage = 0; + float duration = 420f; + float spawnAnimTime = 120f; + int rateOfChange = 6; + float splitProjVelocity = death ? 4.5f : 3f; - if (phase2) - rateOfChange = 2; + // Percent life remaining for Cultist or Eidolon Wyrm + float lifeRatio = Main.npc[(int)NPC.ai[0]].life / (float)Main.npc[(int)NPC.ai[0]].lifeMax; - if (phase3) - rateOfChange = 3; + bool phase2 = lifeRatio < 0.7f; + bool phase3 = lifeRatio < (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType() ? 0.6f : 0.55f); + bool phase4 = lifeRatio < 0.4f; + + bool kill = NPC.ai[1] < 0f || !Main.npc[(int)NPC.ai[0]].active; + int target = Main.maxPlayers; + if (Main.npc[(int)NPC.ai[0]].type == NPCID.CultistBoss || Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType()) + { + if (target == Main.maxPlayers) + target = Main.npc[(int)NPC.ai[0]].target; + + if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType()) + NPC.dontTakeDamage = true; } else kill = true; - npc.ai[1] += rateOfChange; - float growthRate = npc.ai[1] / spawnAnimTime; - growthRate = MathHelper.Clamp(growthRate, 0f, 1f); - npc.position = npc.Center; - npc.scale = MathHelper.Lerp(0f, 1f, growthRate); - npc.Center = npc.position; - npc.alpha = (int)(255f - growthRate * 255f); + NPC.ai[1] += rateOfChange; + float growthRate = NPC.ai[1] / spawnAnimTime; + growthRate = MathHelper.Clamp(growthRate, 0f, 1f); + NPC.position = NPC.Center; + NPC.scale = MathHelper.Lerp(0f, 1f, growthRate); + NPC.Center = NPC.position; + NPC.alpha = (int)(255f - growthRate * 255f); - if (Main.rand.NextBool(6)) - { - Vector2 shadowflameDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust shadowflameDust = Main.dust[Dust.NewDust(npc.Center - shadowflameDustRotate * 20f, 0, 0, DustID.Shadowflame, 0f, 0f, 0, default, 1f)]; - shadowflameDust.noGravity = true; - shadowflameDust.position = npc.Center - shadowflameDustRotate * Main.rand.Next(10, 21) * npc.scale; - shadowflameDust.velocity = shadowflameDustRotate.RotatedBy(MathHelper.PiOver2) * 4f; - shadowflameDust.scale = 0.5f + Main.rand.NextFloat(); - shadowflameDust.fadeIn = 0.5f; - } - if (Main.rand.NextBool(6)) - { - Vector2 darkDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust darkDust = Main.dust[Dust.NewDust(npc.Center - darkDustRotate * 30f, 0, 0, DustID.Granite, 0f, 0f, 0, default, 1f)]; - darkDust.noGravity = true; - darkDust.position = npc.Center - darkDustRotate * 20f * npc.scale; - darkDust.velocity = darkDustRotate.RotatedBy(-MathHelper.PiOver2) * 2f; - darkDust.scale = 0.5f + Main.rand.NextFloat(); - darkDust.fadeIn = 0.5f; - } - if (Main.rand.NextBool(6)) - { - Vector2 darkDustRotate2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - Dust darkDust2 = Main.dust[Dust.NewDust(npc.Center - darkDustRotate2 * 30f, 0, 0, DustID.Granite, 0f, 0f, 0, default, 1f)]; - darkDust2.position = npc.Center - darkDustRotate2 * 20f * npc.scale; - darkDust2.velocity = Vector2.Zero; - darkDust2.scale = 0.5f + Main.rand.NextFloat(); - darkDust2.fadeIn = 0.5f; - darkDust2.noLight = true; - } + if (NPC.ai[3] == 0f) + NPC.ai[3] = NPC.ai[2]; - if (npc.ai[1] >= duration) - { - int type = ProjectileID.AncientDoomProjectile; - int damage = npc.GetProjectileDamage(type); + double deg = NPC.ai[3]; + double rad = deg * (Math.PI / 180); + double dist = 550; + if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType()) + { + float aiGateValue = Main.npc[(int)NPC.ai[0]].Calamity().newAI[2] - 30f; + int ancientDoomScale = (int)(aiGateValue / 120f); + dist += ancientDoomScale * 45; + } + NPC.position.X = Main.player[target].Center.X - (int)(Math.Cos(rad) * dist) - NPC.width / 2; + NPC.position.Y = Main.player[target].Center.Y - (int)(Math.Sin(rad) * dist) - NPC.height / 2; + float spinVelocity = 8f * (1f - (NPC.ai[1] / duration)); + NPC.ai[3] += spinVelocity; + + if (Main.rand.NextBool(6)) + { + Vector2 shadowflameDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust shadowflameDust = Main.dust[Dust.NewDust(NPC.Center - shadowflameDustRotate * 20f, 0, 0, DustID.Shadowflame, 0f, 0f, 0, default, 1f)]; + shadowflameDust.noGravity = true; + shadowflameDust.position = NPC.Center - shadowflameDustRotate * Main.rand.Next(10, 21) * NPC.scale; + shadowflameDust.velocity = shadowflameDustRotate.RotatedBy(MathHelper.PiOver2) * 4f; + shadowflameDust.scale = 0.5f + Main.rand.NextFloat(); + shadowflameDust.fadeIn = 0.5f; + } + if (Main.rand.NextBool(6)) + { + Vector2 darkDustRotate = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust darkDust = Main.dust[Dust.NewDust(NPC.Center - darkDustRotate * 30f, 0, 0, DustID.Granite, 0f, 0f, 0, default, 1f)]; + darkDust.noGravity = true; + darkDust.position = NPC.Center - darkDustRotate * 20f * NPC.scale; + darkDust.velocity = darkDustRotate.RotatedBy(-MathHelper.PiOver2) * 2f; + darkDust.scale = 0.5f + Main.rand.NextFloat(); + darkDust.fadeIn = 0.5f; + } + if (Main.rand.NextBool(6)) + { + Vector2 darkDustRotate2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + Dust darkDust2 = Main.dust[Dust.NewDust(NPC.Center - darkDustRotate2 * 30f, 0, 0, DustID.Granite, 0f, 0f, 0, default, 1f)]; + darkDust2.position = NPC.Center - darkDustRotate2 * 20f * NPC.scale; + darkDust2.velocity = Vector2.Zero; + darkDust2.scale = 0.5f + Main.rand.NextFloat(); + darkDust2.fadeIn = 0.5f; + darkDust2.noLight = true; + } + + NPC.localAI[0] += (float)(Math.PI / 60D); + + NPC.localAI[1] = 0.25f + Vector2.UnitY.RotatedBy(NPC.ai[1] * MathHelper.TwoPi / 60f).Y * 0.25f; + + if (NPC.ai[1] >= duration) + { + int type = ProjectileID.AncientDoomProjectile; + int damage = DoomDamage; + + // Increase damage if the Primordial Wyrm is alive + if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType()) + damage = (int)Math.Round(damage * PrimordialWyrmHead.DoomDamageMult); kill = true; if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = phase3 ? 6 : phase2 ? 5 : 4; + int totalProjectiles = Main.getGoodWorld ? 5 : 3; float radians = MathHelper.TwoPi / totalProjectiles; Vector2 spinningPoint = new Vector2(0f, -splitProjVelocity); + var rotOffset = NPC.DirectionTo(Main.player[target].Center).ToRotation(); for (int k = 0; k < totalProjectiles; k++) { - Vector2 doomProjRotate = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, doomProjRotate, type, damage, 0f, Main.myPlayer); + Vector2 doomProjRotate = spinningPoint.RotatedBy(rotOffset + MathHelper.Pi*((k+1)/(float)(totalProjectiles+1))); + var proj = Main.projectile[Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, doomProjRotate, type, damage, 0f, Main.myPlayer)]; + proj.tileCollide = false; } } } - if (kill) - { - npc.HitEffect(0, 9999.0); - npc.active = false; - } + if (kill) + { + NPC.HitEffect(0, 9999.0); + NPC.active = false; + } - return false; + return false; + } } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs index e981b3ac3c..b776aab1fb 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs @@ -1,73 +1,77 @@ using System; using CalamityMod.Events; +using CalamityMod.Graphics; +using CalamityMod.Systems.Graphic; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.GameContent; using Terraria.Graphics.CameraModifiers; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class DeerclopsAI + public class DeerclopsAI : VanillaAIOverride { - public static bool shouldDrawEnrageBorder = true; public static bool hasTargetBeenInRange = true; - public const float increaseDRTriggerDistance = 750f; - public const float maxDRIncreaseDistance = 1200f; - public static float borderDelay = 10f * 60f; - public static float innerBorder = 750f; - public static float outerBorder = 1200f; - public static float borderScalar = 0f; - public static Vector2 lastDeerclopsPosition; + public const float IncreaseDRTriggerDistance = 750f; + public const float MaxDRIncreaseDistance = 1200f; + public static float borderScale = 5f; + public static string ArenaTexPath = "CalamityMod/Particles/LargeBloom"; - public static bool BuffedDeerclopsAI(NPC npc, Mod mod) + // Vanilla values + public static int DebrisDamage = 18; // 72 + + // Rev+ exclusive + public static int IceSpikeDamage = 16; // 64 (buffed from 52) + public static int HandDamage = 13; // 52 (buffed from 40) + + public static Asset ArenaTex; + + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - NPC.deerclopsBoss = npc.whoAmI; + NPC.deerclopsBoss = NPC.whoAmI; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = (float)NPC.life / (float)NPC.lifeMax; // Difficulty bools - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Projectile types and damage int rubble = ProjectileID.DeerclopsRangedProjectile; - int rubbleDamage = npc.GetProjectileDamage(rubble); int iceSpike = ProjectileID.DeerclopsIceSpike; - int iceSpikeDamage = npc.GetProjectileDamage(iceSpike); int shadowHand = ProjectileID.InsanityShadowHostile; - int shadowHandDamage = npc.GetProjectileDamage(shadowHand); - if (npc.target.WithinBounds(Main.player.Length) && Main.player[npc.target].dead) + if (NPC.target.WithinBounds(Main.player.Length) && Main.player[NPC.target].dead) { hasTargetBeenInRange = false; - borderScalar = 0.9f; } // Target data - NPCAimedTarget targetData = npc.GetTargetData(); + NPCAimedTarget targetData = NPC.GetTargetData(); // Movement variables bool haltMovement = false; bool goHome = false; // Damage resistance based on distance from target - float distanceFromTarget = npc.Distance(targetData.Center); - bool triggerDRIncrease = distanceFromTarget >= increaseDRTriggerDistance; - float resistDamageAmount = MathHelper.Clamp((distanceFromTarget - increaseDRTriggerDistance) / (maxDRIncreaseDistance - increaseDRTriggerDistance), 0f, 1f); - npc.localAI[3] = MathHelper.Lerp(0f, 30f, resistDamageAmount); - float dustAndDRScalar = Utils.Remap(npc.localAI[3], 0f, 30f, 0f, 1f); - calamityGlobalNPC.DR = MathHelper.Lerp(0.05f, 0.9f, dustAndDRScalar); + float distanceFromTarget = NPC.Distance(targetData.Center); + bool triggerDRIncrease = distanceFromTarget >= IncreaseDRTriggerDistance; + float resistDamageAmount = MathHelper.Clamp((distanceFromTarget - IncreaseDRTriggerDistance) / (MaxDRIncreaseDistance - IncreaseDRTriggerDistance), 0f, 1f); + NPC.localAI[3] = MathHelper.Lerp(0f, 30f, resistDamageAmount); + float dustAndDRScalar = Utils.Remap(NPC.localAI[3], 0f, 30f, 0f, 1f); + calamityGlobalNPC.DR = MathHelper.Lerp(0f, 0.9f, dustAndDRScalar); - if (borderDelay > 0f) - borderDelay -= 1f; if (dustAndDRScalar > 0f) { @@ -75,178 +79,191 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses while (invincibleDustAmount > 0f) { invincibleDustAmount -= 1f; - Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Asphalt, 0f, -3f, 0, default(Color), 1.4f).noGravity = true; + Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Asphalt, 0f, -3f, 0, default(Color), 1.4f).noGravity = true; } } - else if (!hasTargetBeenInRange && npc.target.WithinBounds(Main.player.Length) && !Main.player[npc.target].dead) + else if (!hasTargetBeenInRange && NPC.target.WithinBounds(Main.player.Length) && !Main.player[NPC.target].dead) { // Target entered the border for the first time hasTargetBeenInRange = true; - if (borderDelay > 120f) - borderDelay = 120f; } - if (innerBorder != increaseDRTriggerDistance || maxDRIncreaseDistance != outerBorder) - { - // Adjust the border IF the new value is lower (helps prevent jumping if you enter the border early while it's on screen but not finished zooming in) - var LerpValue = Utils.GetLerpValue(hasTargetBeenInRange ? 120f : 180f, 0f, borderDelay, true); - var newInner = MathHelper.Lerp(maxDRIncreaseDistance * 5f, increaseDRTriggerDistance, LerpValue); - if (newInner < innerBorder) - innerBorder = newInner; - var newOuter = MathHelper.Lerp(maxDRIncreaseDistance * 5f, maxDRIncreaseDistance, LerpValue); - if (newOuter < outerBorder) - outerBorder = newOuter; - } - if ((hasTargetBeenInRange && borderScalar < 1f) || borderDelay > 0f) - { - // Fade in, with full opacity only available after being inside the border for the first time - borderScalar = MathHelper.Clamp(borderScalar + 0.015f, 0f, hasTargetBeenInRange ? 1f : 0.9f); - } - shouldDrawEnrageBorder = CalamityWorld.revenge || CalamityWorld.death; // Set the last deerclops position (used only for post-death border shenanigans) - lastDeerclopsPosition = npc.Center; + Main.LocalPlayer.Calamity().lastDeerclopsPosition = NPC.Center; // Spawn settings - if (npc.homeTileX == -1 && npc.homeTileY == -1) + if (NPC.homeTileX == -1 && NPC.homeTileY == -1) { - Point point = npc.Bottom.ToTileCoordinates(); - npc.homeTileX = point.X; - npc.homeTileY = point.Y; - npc.ai[2] = npc.homeTileX; - npc.ai[3] = npc.homeTileY; - npc.netUpdate = true; - npc.timeLeft = 86400; + Point point = NPC.Bottom.ToTileCoordinates(); + NPC.homeTileX = point.X; + NPC.homeTileY = point.Y; + NPC.ai[2] = NPC.homeTileX; + NPC.ai[3] = NPC.homeTileY; + NPC.netUpdate = true; + NPC.timeLeft = 86400; } // Decrease time left based on actual world updates - npc.timeLeft -= Main.worldEventUpdates; - if (npc.timeLeft < 0) - npc.timeLeft = 0; + NPC.timeLeft -= Main.worldEventUpdates; + if (NPC.timeLeft < 0) + NPC.timeLeft = 0; // Set home tile so Deerclops knows where to return to - npc.homeTileX = (int)npc.ai[2]; - npc.homeTileY = (int)npc.ai[3]; + NPC.homeTileX = (int)NPC.ai[2]; + NPC.homeTileY = (int)NPC.ai[3]; - // Spawn Shadow Hands - if (Main.netMode != NetmodeID.MultiplayerClient) - SpawnPassiveShadowHands(npc, lifeRatio, shadowHand, shadowHandDamage, death); + // Spawn Shadow Hands if the player enters the shadows + if (Main.netMode != NetmodeID.MultiplayerClient && hasTargetBeenInRange) + SpawnBorderShadowHands(NPC, lifeRatio, shadowHand, HandDamage, death); // AI states - switch ((int)npc.ai[0]) + switch ((int)NPC.ai[0]) { // This case is never used case -1: - npc.localAI[3] = -10f; + NPC.localAI[3] = -10f; break; // Choose an attack to use case 0: - npc.TargetClosest(); - targetData = npc.GetTargetData(); - if (ShouldRunAway(npc, ref targetData, isChasing: true)) + NPC.TargetClosest(); + targetData = NPC.GetTargetData(); + if (ShouldRunAway(NPC, ref targetData, isChasing: true)) { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; + NPC.netUpdate = true; break; } else { - if (npc.timeLeft < 86400) - npc.timeLeft = 86400; + if (NPC.timeLeft < 86400) + NPC.timeLeft = 86400; } float attackRate = 1f; - npc.ai[1] += attackRate; - Vector2 relativeCenter = npc.Bottom + new Vector2(0f, -32f); + NPC.ai[1] += attackRate; + Vector2 relativeCenter = NPC.Bottom + new Vector2(0f, -32f); Vector2 closestTargetPoint = targetData.Hitbox.ClosestPointInRect(relativeCenter); Vector2 distanceFromTarget2 = closestTargetPoint - relativeCenter; - (closestTargetPoint - npc.Center).Length(); + (closestTargetPoint - NPC.Center).Length(); float distanceCheckMultiplier = 0.6f; + bool useFrontIceSpikeAttack = Math.Abs(distanceFromTarget2.X) >= Math.Abs(distanceFromTarget2.Y) * distanceCheckMultiplier || distanceFromTarget2.Length() < 48f; bool useEitherIceSpikeAttack = distanceFromTarget2.Y <= (float)(100 + targetData.Height) && distanceFromTarget2.Y >= -200f; - if (Math.Abs(distanceFromTarget2.X) < 120f && useEitherIceSpikeAttack && npc.velocity.Y == 0f && npc.localAI[1] >= 2f) + + // Can only use ice spikes a maximum of three times in a row before doing something else + float iceSpikeAttackLimit = 3f; + bool doNotUseIceSpikes = calamityGlobalNPC.newAI[1] >= iceSpikeAttackLimit; + if (!doNotUseIceSpikes) { - npc.velocity.X = 0f; - npc.ai[0] = 4f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] -= 1f; - npc.SyncExtraAI(); - npc.netUpdate = true; - break; + // Deerclops must be this close to its target on the X axis to do the ice spike attack + // This distance increases at lower HP because the ice spikes get bigger + float iceSpikesDistanceGateValue = 120f + MathHelper.Lerp(0f, 60f, 1f - lifeRatio); + if (Math.Abs(distanceFromTarget2.X) < iceSpikesDistanceGateValue && useEitherIceSpikeAttack && NPC.velocity.Y == 0f && NPC.localAI[1] >= 2f) + { + NPC.velocity.X = 0f; + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] -= 1f; + calamityGlobalNPC.newAI[1] += 1f; + NPC.SyncExtraAI(); + NPC.netUpdate = true; + break; + } + + if (Math.Abs(distanceFromTarget2.X) < iceSpikesDistanceGateValue && useEitherIceSpikeAttack && NPC.velocity.Y == 0f && useFrontIceSpikeAttack) + { + NPC.velocity.X = 0f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.localAI[1] += 1f; + calamityGlobalNPC.newAI[0] -= 1f; + calamityGlobalNPC.newAI[1] += 1f; + NPC.SyncExtraAI(); + NPC.netUpdate = true; + break; + } } - if (Math.Abs(distanceFromTarget2.X) < 120f && useEitherIceSpikeAttack && npc.velocity.Y == 0f && useFrontIceSpikeAttack) + // Can only use rubble and ice spikes a maximum of four times in a row before doing something else + float rubbleAttackLimit = 4f; + bool doNotUseRubble = calamityGlobalNPC.newAI[1] >= rubbleAttackLimit; + float rubbleGateValue = death ? 160f : 200f; + if (!doNotUseRubble) { - npc.velocity.X = 0f; - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.localAI[1] += 1f; - calamityGlobalNPC.newAI[0] -= 1f; - npc.SyncExtraAI(); - npc.netUpdate = true; - break; + bool useRubbleAttack = NPC.ai[1] >= rubbleGateValue; + if (NPC.velocity.Y == 0f && NPC.velocity.X != 0f && useRubbleAttack) + { + NPC.velocity.X = 0f; + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] -= 1f; + calamityGlobalNPC.newAI[1] += 1f; + NPC.SyncExtraAI(); + NPC.netUpdate = true; + break; + } } - bool useRubbleAttack = npc.ai[1] >= 240f; - if (npc.velocity.Y == 0f && npc.velocity.X != 0f && useRubbleAttack) + float shadowHandGateValue = death ? 60f : 75f; + bool useShadowHandAttack = NPC.ai[1] >= shadowHandGateValue; + if (NPC.velocity.Y == 0f && NPC.velocity.X == 0f && useShadowHandAttack) { - npc.velocity.X = 0f; - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; + NPC.velocity.X = 0f; + NPC.ai[0] = targetData.Center.Y < NPC.Center.Y - 50f ? 5f : 3f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; calamityGlobalNPC.newAI[0] -= 1f; - npc.SyncExtraAI(); - npc.netUpdate = true; - break; - } - - bool useShadowHandAttack = npc.ai[1] >= 90f; - if (npc.velocity.Y == 0f && npc.velocity.X == 0f && useShadowHandAttack) - { - npc.velocity.X = 0f; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] -= 1f; - npc.SyncExtraAI(); - npc.netUpdate = true; + calamityGlobalNPC.newAI[1] = 0f; + NPC.SyncExtraAI(); + NPC.netUpdate = true; break; } // This replaced the slow debuff infliction - bool useSecondShadowHandAttack = npc.ai[1] >= 120f; - if (npc.velocity.Y == 0f && useSecondShadowHandAttack && Math.Abs(distanceFromTarget2.X) > 100f && calamityGlobalNPC.newAI[0] <= 0f) + // Must use 4 different attacks before being able to use this attack again + float secondShadowHandAttackCooldown = 4f; + float secondShadowHandGateValue = death ? 80f : 100f; + bool useSecondShadowHandAttack = NPC.ai[1] >= secondShadowHandGateValue; + if (NPC.velocity.Y == 0f && useSecondShadowHandAttack && Math.Abs(distanceFromTarget2.X) > 100f && calamityGlobalNPC.newAI[0] <= 0f) { - npc.velocity.X = 0f; - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 5f; - npc.SyncExtraAI(); - npc.netUpdate = true; + NPC.velocity.X = 0f; + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = secondShadowHandAttackCooldown; + calamityGlobalNPC.newAI[1] = 0f; + NPC.SyncExtraAI(); + NPC.netUpdate = true; } + // If Deerclops has been taking a while to attack, stop moving on the X axis to force a shadow hand attack + float haltMovementGateValue = doNotUseRubble ? (secondShadowHandGateValue + 20f) : doNotUseIceSpikes ? (rubbleGateValue + 20f) : 240f; + if (distanceFromTarget2.Length() < IncreaseDRTriggerDistance) + haltMovement = NPC.ai[1] >= haltMovementGateValue; + break; // Create spikes in front of Deerclops case 1: - npc.ai[1] += 1f; + NPC.ai[1] += 1f; haltMovement = true; - MakeSpikesForward(npc, 1, targetData, iceSpike, iceSpikeDamage, lifeRatio, death); + MakeSpikesForward(NPC, 1, targetData, iceSpike, IceSpikeDamage, lifeRatio, death); float iceSpikePhaseGateValue = 80f; - if (npc.ai[1] >= iceSpikePhaseGateValue) + if (NPC.ai[1] >= iceSpikePhaseGateValue) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -255,25 +272,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 2: int scoopRubbleGateValue = 32; - npc.ai[1] += 1f; - if (npc.ai[1] == (float)(scoopRubbleGateValue - 20)) - SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + NPC.ai[1] += 1f; + if (NPC.ai[1] == (float)(scoopRubbleGateValue - 20)) + SoundEngine.PlaySound(SoundID.DeerclopsScream, NPC.Center); - if (npc.ai[1] == (float)scoopRubbleGateValue) - SoundEngine.PlaySound(SoundID.DeerclopsRubbleAttack, npc.Center); + if (NPC.ai[1] == (float)scoopRubbleGateValue) + SoundEngine.PlaySound(SoundID.DeerclopsRubbleAttack, NPC.Center); haltMovement = true; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= (float)scoopRubbleGateValue) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] >= (float)scoopRubbleGateValue) { - Point sourceTileCoords = npc.Top.ToTileCoordinates(); + Point sourceTileCoords = NPC.Top.ToTileCoordinates(); int numRubble = death ? 60 : 20; int distancedByThisManyTiles = death ? 3 : 5; - sourceTileCoords.X += npc.direction * 3; + sourceTileCoords.X += NPC.direction * 3; sourceTileCoords.Y -= 10; - int screenShakeGateValue = (int)npc.ai[1] - scoopRubbleGateValue; + int screenShakeGateValue = (int)NPC.ai[1] - scoopRubbleGateValue; if (screenShakeGateValue == 0) { - PunchCameraModifier modifier4 = new PunchCameraModifier(npc.Center, new Vector2(0f, -1f), 20f, 6f, 30, 1000f, "Deerclops"); + PunchCameraModifier modifier4 = new PunchCameraModifier(NPC.Center, new Vector2(0f, -1f), 20f, 6f, 30, 1000f, "Deerclops"); Main.instance.CameraModifiers.Add(modifier4); } @@ -283,14 +300,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses rubbleLimit = rubbleStart; for (int rubbleIndex = rubbleStart; rubbleIndex < rubbleLimit && rubbleIndex < numRubble; rubbleIndex++) - ShootRubbleUp(npc, ref sourceTileCoords, numRubble, distancedByThisManyTiles, rubbleIndex, rubble, rubbleDamage, lifeRatio, death); + ShootRubbleUp(NPC, ref sourceTileCoords, numRubble, distancedByThisManyTiles, rubbleIndex, rubble, DebrisDamage, lifeRatio, death); } - if (npc.ai[1] >= 60f) + if (NPC.ai[1] >= 60f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -298,23 +315,23 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spawn shadow hands around the target with differing velocities case 3: - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + if (NPC.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, NPC.Center); - npc.ai[1] += 1f; + NPC.ai[1] += 1f; haltMovement = true; - if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + if ((int)NPC.ai[1] % 4 == 0 && NPC.ai[1] >= 28f) { - PunchCameraModifier modifier5 = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + PunchCameraModifier modifier5 = new PunchCameraModifier(NPC.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); Main.instance.CameraModifiers.Add(modifier5); } - if (npc.ai[1] == 30f) + if (NPC.ai[1] == 30f) { - npc.TargetClosest(); + NPC.TargetClosest(); if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = (death ? 7 : 5) + (int)MathHelper.Lerp(0f, 11f, 1f - lifeRatio); + int totalProjectiles = (death ? 11 : 9) + (int)MathHelper.Lerp(0f, 7f, 1f - lifeRatio); float velocityMultIncrement = ((totalProjectiles + 1) / (float)totalProjectiles) - 1f; float randomRadialOffset = MathHelper.ToRadians(MathHelper.Lerp(0f, death ? 270f : 180f, 1f - lifeRatio)); float radians = MathHelper.TwoPi / totalProjectiles + randomRadialOffset; @@ -324,16 +341,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { Vector2 actualVelocity = spinningPoint.RotatedBy(radians * k); float velocityMultiplier = 1f - k * velocityMultIncrement; - Projectile.NewProjectile(npc.GetSource_FromAI(), Main.player[npc.target].Center + Vector2.Normalize(actualVelocity) * 450f, actualVelocity * velocityMultiplier * -1f, shadowHand, shadowHandDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), Main.player[NPC.target].Center + Vector2.Normalize(actualVelocity) * 550f, actualVelocity * velocityMultiplier * -1f, shadowHand, HandDamage, 0f, Main.myPlayer); } } } - if (npc.ai[1] >= 60f) + if (NPC.ai[1] >= 60f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -341,54 +358,60 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spawn ice spikes on both sides case 4: - npc.ai[1] += 1f; + NPC.ai[1] += 1f; haltMovement = true; - npc.TargetClosest(); - MakeSpikesBothSides(npc, 1, targetData, iceSpike, iceSpikeDamage, lifeRatio, death); + NPC.TargetClosest(); + MakeSpikesBothSides(NPC, 1, targetData, iceSpike, IceSpikeDamage, lifeRatio, death); float doubleIceSpikePhaseGateValue = 90f; - if (npc.ai[1] >= doubleIceSpikePhaseGateValue) + if (NPC.ai[1] >= doubleIceSpikePhaseGateValue) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; - // Spawn shadow hands around the target with randomized AI + // Spawn shadow hands around the target (literally just a different variant of the other shadow hand attack with more spread and more velocity) case 5: - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + if (NPC.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, NPC.Center); - npc.ai[1] += 1f; + NPC.ai[1] += 1f; haltMovement = true; - if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + if ((int)NPC.ai[1] % 4 == 0 && NPC.ai[1] >= 28f) { - PunchCameraModifier modifier = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + PunchCameraModifier modifier = new PunchCameraModifier(NPC.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); Main.instance.CameraModifiers.Add(modifier); } - if (npc.ai[1] == 30f) + if (NPC.ai[1] == 30f) { - npc.TargetClosest(); + NPC.TargetClosest(); if (Main.netMode != NetmodeID.MultiplayerClient) { - int handAmount = (int)MathHelper.Lerp(death ? 5f : 3f, death ? 12f : 10f, 1f - lifeRatio); - for (int i = 0; i < handAmount; i++) + int totalProjectiles = (death ? 20 : 16) + (int)MathHelper.Lerp(0f, 7f, 1f - lifeRatio); + float velocityMultIncrement = ((totalProjectiles + 1) / (float)totalProjectiles) - 1f; + float randomRadialOffset = Main.rand.NextFloat(MathHelper.ToRadians(MathHelper.Lerp(0f, death ? 360f : 270f, 1f - lifeRatio))); + float radians = MathHelper.TwoPi / totalProjectiles + randomRadialOffset; + float velocity = 12f + MathHelper.Lerp(0f, 4f, 1f - lifeRatio); + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) { - RandomizeInsanityShadowFor(Main.player[npc.target], death, isHostile: true, out var spawnposition, out var spawnvelocity, out var ai, out var ai2); - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnposition, spawnvelocity, shadowHand, shadowHandDamage, 0f, Main.myPlayer, ai, ai2); + Vector2 actualVelocity = spinningPoint.RotatedBy(radians * k); + float velocityMultiplier = 1f - (k * velocityMultIncrement * 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), Main.player[NPC.target].Center + Vector2.Normalize(actualVelocity) * 550f, actualVelocity * velocityMultiplier * -1f, shadowHand, HandDamage, 0f, Main.myPlayer); } } } - if (npc.ai[1] >= 60f) + if (NPC.ai[1] >= 60f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -396,61 +419,61 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Try to go home case 6: - npc.TargetClosest(faceTarget: false); - targetData = npc.GetTargetData(); + NPC.TargetClosest(faceTarget: false); + targetData = NPC.GetTargetData(); - if (npc.timeLeft > 300) - npc.timeLeft = 300; + if (NPC.timeLeft > 300) + NPC.timeLeft = 300; if (Main.netMode != NetmodeID.MultiplayerClient) { - if (!ShouldRunAway(npc, ref targetData, isChasing: false)) + if (!ShouldRunAway(NPC, ref targetData, isChasing: false)) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; + NPC.netUpdate = true; break; } - if (npc.timeLeft <= 0) + if (NPC.timeLeft <= 0) { - npc.ai[0] = 8f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 8f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; + NPC.netUpdate = true; break; } } - if (npc.direction != npc.oldDirection) - npc.netUpdate = true; + if (NPC.direction != NPC.oldDirection) + NPC.netUpdate = true; goHome = true; - npc.ai[1] += 1f; - Vector2 homeVector = new Vector2(npc.homeTileX * 16, npc.homeTileY * 16); - bool farBelowHome = npc.Top.Y > homeVector.Y + 1600f; - bool closeToHome = npc.Distance(homeVector) < 1020f; - npc.Distance(targetData.Center); - float stopMovingGateValue = npc.ai[1] % 600f; + NPC.ai[1] += 1f; + Vector2 homeVector = new Vector2(NPC.homeTileX * 16, NPC.homeTileY * 16); + bool farBelowHome = NPC.Top.Y > homeVector.Y + 1600f; + bool closeToHome = NPC.Distance(homeVector) < 1020f; + NPC.Distance(targetData.Center); + float stopMovingGateValue = NPC.ai[1] % 600f; if (closeToHome && stopMovingGateValue < 420f) haltMovement = true; bool returnHome = false; int returnHomeDueToBelowHomeGateValue = 300; - if (farBelowHome && npc.ai[1] >= (float)returnHomeDueToBelowHomeGateValue) + if (farBelowHome && NPC.ai[1] >= (float)returnHomeDueToBelowHomeGateValue) returnHome = true; int returnHomeDueToFarFromHomeGateValue = 1500; - if (!closeToHome && npc.ai[1] >= (float)returnHomeDueToFarFromHomeGateValue) + if (!closeToHome && NPC.ai[1] >= (float)returnHomeDueToFarFromHomeGateValue) returnHome = true; if (returnHome) { - npc.ai[0] = 7f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + NPC.localAI[1] = 0f; + NPC.netUpdate = true; } break; @@ -458,32 +481,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Return home case 7: - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + if (NPC.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, NPC.Center); - npc.ai[1] += 1f; + NPC.ai[1] += 1f; haltMovement = true; - if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + if ((int)NPC.ai[1] % 4 == 0 && NPC.ai[1] >= 28f) { - PunchCameraModifier modifier3 = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + PunchCameraModifier modifier3 = new PunchCameraModifier(NPC.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); Main.instance.CameraModifiers.Add(modifier3); } - if (npc.ai[1] == 40f) + if (NPC.ai[1] == 40f) { - npc.TargetClosest(); + NPC.TargetClosest(); if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.netUpdate = true; - npc.Bottom = new Vector2(npc.homeTileX * 16, npc.homeTileY * 16); + NPC.netUpdate = true; + NPC.Bottom = new Vector2(NPC.homeTileX * 16, NPC.homeTileY * 16); } } - if (npc.ai[1] >= 60f) + if (NPC.ai[1] >= 60f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -491,24 +514,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Despawn case 8: - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.DeerclopsScream, npc.Center); + if (NPC.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.DeerclopsScream, NPC.Center); - npc.ai[1] += 1f; + NPC.ai[1] += 1f; haltMovement = true; - if ((int)npc.ai[1] % 4 == 0 && npc.ai[1] >= 28f) + if ((int)NPC.ai[1] % 4 == 0 && NPC.ai[1] >= 28f) { - PunchCameraModifier modifier2 = new PunchCameraModifier(npc.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); + PunchCameraModifier modifier2 = new PunchCameraModifier(NPC.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops"); Main.instance.CameraModifiers.Add(modifier2); } - if (npc.ai[1] >= 40f) + if (NPC.ai[1] >= 40f) { - npc.life = -1; - npc.HitEffect(); - npc.active = false; + NPC.life = -1; + NPC.HitEffect(); + NPC.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f); return false; } @@ -517,7 +540,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Movement - Movement(npc, lifeRatio, haltMovement, goHome, death); + Movement(NPC, lifeRatio, haltMovement, goHome, death); return false; } @@ -541,9 +564,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - private static void SpawnPassiveShadowHands(NPC npc, float lifeRatio, int shadowHand, int shadowHandDamage, bool death) + private static void SpawnBorderShadowHands(NPC npc, float lifeRatio, int shadowHand, int HandDamage, bool death) { - int shadowHandSpawnRate = (int)Utils.Remap(lifeRatio, 1f, 0f, death ? 60f : 80f, death ? 30f : 40f); + int shadowHandSpawnRate = death ? 15 : 20; npc.localAI[2] += 1f; int shadowHandTimer = (int)npc.localAI[2]; if (shadowHandTimer % shadowHandSpawnRate != 0) @@ -555,86 +578,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses foreach (Player player in Main.ActivePlayers) { - if (npc.Boss_CanShootExtraAt(player.whoAmI, rotation % 3, 3, 1200f, alwaysSkipMainTarget: false)) + // 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 = 360f; + float playerDistanceFromDeerclops = Vector2.Distance(npc.Center, player.Center); + if (playerDistanceFromDeerclops >= IncreaseDRTriggerDistance && playerDistanceFromDeerclops <= MaxDRIncreaseDistance) { - // Normal shadow hand spawn behavior - // Modified to make the shadow hand spawns fair - 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, player.Center); - if (playerDistanceFromDeerclops >= 450f) - { - 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); + Vector2 spawnPosition = npc.Center + (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * (playerDistanceFromDeerclops + minShadowHandSpawnDistanceFromPlayer); + float shadowHandVelocity = death ? 6f : 5f; + Vector2 spawnVelocity = (player.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * shadowHandVelocity; + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition, spawnVelocity, shadowHand, HandDamage, 0f, Main.myPlayer); } } } - private static void RandomizeInsanityShadowFor(Entity targetEntity, bool death, bool isHostile, out Vector2 spawnPosition, out Vector2 spawnVelocity, out float ai0, out float ai1) - { - int spawnDirection = Main.rand.NextBool() ? 1 : -1; - int shadowHandType = Main.rand.Next(4); - float spawnDistance = (isHostile ? 450f : 225f); - float velocityDivisor = (isHostile ? 30 : 20); - float velocityOffset = (isHostile ? 30 : 0); - float randomRotation = Main.rand.NextFloatDirection() * (float)Math.PI * 0.125f; - if (isHostile && targetEntity.velocity.X * (float)spawnDirection > 0f) - spawnDirection *= -1; - - if (shadowHandType == 0 && isHostile) - velocityDivisor += 10f; - - spawnPosition = targetEntity.Center + targetEntity.velocity * velocityOffset + new Vector2((float)spawnDirection * (0f - spawnDistance), 0f).RotatedBy(randomRotation); - spawnVelocity = new Vector2((float)spawnDirection * spawnDistance / velocityDivisor, 0f).RotatedBy(randomRotation); - ai0 = 0f; - ai1 = 0f; - - int velocityAdd = death ? 2 : 0; - if (shadowHandType == 1) - { - float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); - spawnPosition = targetEntity.Center - rotation.ToRotationVector2() * spawnDistance; - ai0 = 180f; - ai1 = rotation - (float)Math.PI / 2f; - spawnVelocity = rotation.ToRotationVector2() * (isHostile ? (4 + velocityAdd) : 2); - } - else if (shadowHandType == 2) - { - float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); - spawnPosition = targetEntity.Center - rotation.ToRotationVector2() * spawnDistance; - ai0 = 300f; - ai1 = rotation; - spawnVelocity = rotation.ToRotationVector2() * (isHostile ? (4 + velocityAdd) : 2); - } - else if (shadowHandType == 3) - { - float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); - float distance = (isHostile ? 150 : 75); - float spawnVelocityRotation = (float)Math.PI / 2f / distance * Main.rand.NextFloatDirection(); - spawnPosition = targetEntity.Center + targetEntity.velocity * distance; - if (Vector2.Distance(spawnPosition, targetEntity.Center) < spawnDistance) - spawnPosition = (spawnPosition - targetEntity.Center).SafeNormalize(Vector2.UnitY) * spawnDistance; - - Vector2 vector = rotation.ToRotationVector2() * (isHostile ? (8 + velocityAdd) : 3); - for (int i = 0; (float)i < distance; i++) - { - spawnPosition -= vector; - vector = vector.RotatedBy(0f - spawnVelocityRotation); - } - - spawnVelocity = vector; - ai0 = 390f; - ai1 = spawnVelocityRotation; - } - } - - private static void ShootRubbleUp(NPC npc, ref Point sourceTileCoords, int howMany, int distancedByThisManyTiles, int whichOne, int rubble, int rubbleDamage, float lifeRatio, bool death) + private static void ShootRubbleUp(NPC npc, ref Point sourceTileCoords, int howMany, int distancedByThisManyTiles, int whichOne, int rubble, int DebrisDamage, float lifeRatio, bool death) { // Loop to spawn rubble // The rubble attempts are used to offset the Y coordinates of the rubble spawns to make sure they can spawn in non-solid tiles @@ -646,23 +604,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int posY = sourceTileCoords.Y + rubbleSpawnAttempts; if (WorldGen.ActiveAndWalkableTile(posX, posY)) { - SpawnRubble(npc, posX, posY, howMany, whichOne, rubble, rubbleDamage, lifeRatio, death); + SpawnRubble(npc, posX, posY, howMany, whichOne, rubble, DebrisDamage, lifeRatio, death); break; } } } - private static void SpawnRubble(NPC npc, int posX, int posY, int howMany, int whichOne, int rubble, int rubbleDamage, float lifeRatio, bool death) + private static void SpawnRubble(NPC npc, int posX, int posY, int howMany, int whichOne, int rubble, int DebrisDamage, float lifeRatio, bool death) { Vector2 rubbleVelocity = new Vector2(0f, -1f).RotatedBy((float)(whichOne * npc.direction) * 0.7f * ((float)Math.PI / 4f / (float)howMany)); int ai1_FrameToUse = Main.rand.Next(Main.projFrames[rubble] * 4); ai1_FrameToUse = 6 + Main.rand.Next(6); - float delay = (int)MathHelper.Lerp(death ? 8f : 10f, death ? 16f : 20f, lifeRatio); - float ai2_DelayBeforeGoingUp = whichOne * delay; - Projectile.NewProjectile(npc.GetSource_FromAI(), new Vector2(posX * 16 + 8, posY * 16 - 8), rubbleVelocity * 0.01f, rubble, rubbleDamage, 0f, Main.myPlayer, 0f, ai1_FrameToUse, ai2_DelayBeforeGoingUp); + float delay = death ? 24f : 30f; + float ai2_DelayBeforeGoingUp = (whichOne + 1) * delay; + float velocityMultiplier = MathHelper.Lerp(0.01f, 0.015f, 1f - lifeRatio); + Projectile.NewProjectile(npc.GetSource_FromAI(), new Vector2(posX * 16 + 8, posY * 16 - 8), rubbleVelocity * velocityMultiplier, rubble, DebrisDamage, 0f, Main.myPlayer, 0f, ai1_FrameToUse, ai2_DelayBeforeGoingUp); } - private static void MakeSpikesForward(NPC npc, int AISLOT_PhaseCounter, NPCAimedTarget targetData, int iceSpike, int iceSpikeDamage, float lifeRatio, bool death) + private static void MakeSpikesForward(NPC npc, int AISLOT_PhaseCounter, NPCAimedTarget targetData, int iceSpike, int IceSpikeDamage, float lifeRatio, bool death) { if (Main.netMode == NetmodeID.MultiplayerClient) return; @@ -671,7 +630,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!(npc.ai[AISLOT_PhaseCounter] < (float)iceSpikeGateValue)) { Point sourceTileCoords = npc.Bottom.ToTileCoordinates(); - int numIceSpikes = lifeRatio < 0.5f ? 15 : 20; + int numIceSpikes = 20; int xOffsetMult = 1; sourceTileCoords.X += npc.direction * 3; int screenShakeGateValue = (int)npc.ai[AISLOT_PhaseCounter] - iceSpikeGateValue; @@ -686,17 +645,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (screenShakeGateValue % 4 != 0) iceSpikeLimit = iceSpikeStart; + // Ice spikes get fucking gigantic later on in the fight + float iceSpikeScaleIncrease = MathHelper.Lerp(1f, 2f, 1f - lifeRatio); for (int i = iceSpikeStart; i < iceSpikeLimit && i < numIceSpikes; i++) { - int xOffset = i * xOffsetMult; - TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, i, xOffset, iceSpike, iceSpikeDamage, lifeRatio, death); - if (lifeRatio < 0.5f) - TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, i, xOffset * 2, iceSpike, iceSpikeDamage, lifeRatio, death); + int xOffset = (int)Math.Round(i * xOffsetMult * iceSpikeScaleIncrease); + TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, i, xOffset, iceSpike, IceSpikeDamage, lifeRatio, death); } } } - private static void MakeSpikesBothSides(NPC npc, int AISLOT_PhaseCounter, NPCAimedTarget targetData, int iceSpike, int iceSpikeDamage, float lifeRatio, bool death) + private static void MakeSpikesBothSides(NPC npc, int AISLOT_PhaseCounter, NPCAimedTarget targetData, int iceSpike, int IceSpikeDamage, float lifeRatio, bool death) { if (Main.netMode == NetmodeID.MultiplayerClient) return; @@ -705,7 +664,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!(npc.ai[AISLOT_PhaseCounter] < (float)iceSpikeGateValue)) { Point sourceTileCoords = npc.Bottom.ToTileCoordinates(); - int numIceSpikes = lifeRatio < 0.5f ? 12 : 15; + int numIceSpikes = 15; int xOffsetMult = 1; int screenShakeGateValue = (int)npc.ai[AISLOT_PhaseCounter] - iceSpikeGateValue; if (screenShakeGateValue == 0) @@ -719,21 +678,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (screenShakeGateValue % 2 != 0) iceSpikeLimit = iceSpikeStart; + // Ice spikes get fucking gigantic later on in the fight + float iceSpikeScaleIncrease = MathHelper.Lerp(1f, 2f, 1f - lifeRatio); for (int iceSpikeIndex = iceSpikeStart; iceSpikeIndex >= 0 && iceSpikeIndex < iceSpikeLimit && iceSpikeIndex < numIceSpikes; iceSpikeIndex++) { - int xOffset = iceSpikeIndex * xOffsetMult; - TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, iceSpikeDamage, lifeRatio, death); - TryMakingSpike(npc, ref sourceTileCoords, -npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, iceSpikeDamage, lifeRatio, death); - if (lifeRatio < 0.5f) - { - TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, -iceSpikeIndex, xOffset * 2, iceSpike, iceSpikeDamage, lifeRatio, death); - TryMakingSpike(npc, ref sourceTileCoords, -npc.direction, numIceSpikes, -iceSpikeIndex, xOffset * 2, iceSpike, iceSpikeDamage, lifeRatio, death); - } + int xOffset = (int)Math.Round(iceSpikeIndex * xOffsetMult * iceSpikeScaleIncrease); + TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, IceSpikeDamage, lifeRatio, death); + TryMakingSpike(npc, ref sourceTileCoords, -npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, IceSpikeDamage, lifeRatio, death); } } } - private static void TryMakingSpike(NPC npc, ref Point sourceTileCoords, int dir, int howMany, int whichOne, int xOffset, int iceSpike, int iceSpikeDamage, float lifeRatio, bool death) + private static void TryMakingSpike(NPC npc, ref Point sourceTileCoords, int dir, int howMany, int whichOne, int xOffset, int iceSpike, int IceSpikeDamage, float lifeRatio, bool death) { int posX = sourceTileCoords.X + xOffset * dir; int posY = FindBestY(npc, ref sourceTileCoords, posX); @@ -741,8 +697,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { Vector2 iceSpikeSpawnPos = new Vector2(posX * 16 + 8, posY * 16 - 8); Vector2 iceSpikeVelocity = new Vector2(0f, -1f).RotatedBy((float)(whichOne * dir) * 0.7f * ((float)Math.PI / 4f / (float)howMany)); - float scaleIncrease = MathHelper.Lerp(0f, 0.55f, 1f - lifeRatio); - Projectile.NewProjectile(npc.GetSource_FromAI(), iceSpikeSpawnPos, iceSpikeVelocity, iceSpike, iceSpikeDamage, 0f, Main.myPlayer, 0f, 0.1f + Main.rand.NextFloat() * 0.1f + (float)xOffset * (1.1f + scaleIncrease) / (float)howMany); + float iceSpikeScale = 0.1f + Main.rand.NextFloat() * 0.1f + (float)xOffset * 1.1f / (float)howMany; + Projectile.NewProjectile(npc.GetSource_FromAI(), iceSpikeSpawnPos, iceSpikeVelocity, iceSpike, IceSpikeDamage, 0f, Main.myPlayer, 0f, iceSpikeScale); } } @@ -833,7 +789,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (stopMoving) { - npc.velocity.X *= 0.9f; + npc.velocity.X *= 0.8f; if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) npc.velocity.X = 0f; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index 2d1b34725c..bbfcf11786 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -1,6 +1,6 @@ using System; +using System.IO; using CalamityMod.Events; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -11,13 +11,13 @@ using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class DestroyerAI + public class DestroyerAI : VanillaAIOverride { public const float DRIncreaseTime = 600f; - public const float DeathModeLaserBreathGateValue = 600f; public const float LaserTelegraphTime = 120f; public const float SparkTelegraphTime = 30f; public const float FlightPhaseGateValue = 900f; @@ -27,21 +27,41 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public const float PhaseTransitionTelegraphTime = 180f; public const float GroundTelegraphStartGateValue = FlightPhaseResetGateValue - PhaseTransitionTelegraphTime; public const float FlightTelegraphStartGateValue = FlightPhaseGateValue - PhaseTransitionTelegraphTime; - private const int OneInXChanceToFireLaser = 200; public const float ProbeLaserGateValue_Mechdusa = 360f; public const float ProbeLaserGateValue_Rev = 240f; - public const float ProbeLaserGateValue_BossRush = 150f; public const float ProbeLaserGateValue = 120f; public const float ProbeLaserTelegraphTime = 60f; - public static bool BuffedDestroyerAI(NPC npc, Mod mod) + // Vanilla values + public static int ProbeLaserDamage = 22; // 88 + + // Rev+ exclusive + public static int LaserDamage = 25; // 100 (buffed); Applies to all Rev+ lasers + + /// + /// Destroyer laser colors, used for telegraphs.
+ /// None = -1, Red = 0, Green = 1, Cyan = 2 + ///
+ public sbyte LaserColor = -1; + + public override void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter) + { + binaryWriter.Write(LaserColor); + } + + public override void ReceiveExtraAI(BitReader bitReader, BinaryReader binaryReader) + { + LaserColor = binaryReader.ReadSByte(); + } + + public override bool AI(Mod mod) { int mechdusaCurvedSpineSegmentIndex = 0; int mechdusaCurvedSpineSegments = 10; - if (NPC.IsMechQueenUp && npc.type != NPCID.TheDestroyer) + if (NPC.IsMechQueenUp && NPC.type != NPCID.TheDestroyer) { - int mechdusaIndex = (int)npc.ai[1]; + int mechdusaIndex = (int)NPC.ai[1]; while (mechdusaIndex > 0 && mechdusaIndex < Main.maxNPCs) { if (Main.npc[mechdusaIndex].active && Main.npc[mechdusaIndex].type >= NPCID.TheDestroyer && Main.npc[mechdusaIndex].type <= NPCID.TheDestroyerTail) @@ -65,15 +85,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = calamityGlobalNPC.newAI[1] < DRIncreaseTime; // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phases based on life percentage bool phase2 = lifeRatio < 0.85f || death; @@ -110,50 +129,41 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Set worm variable for worms - if (npc.ai[3] > 0f) - npc.realLife = (int)npc.ai[3]; + if (NPC.ai[3] > 0f) + NPC.realLife = (int)NPC.ai[3]; // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - Player player = Main.player[npc.target]; + Player player = Main.player[NPC.target]; - bool increaseSpeed = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - - float enrageScale = bossRush ? 1f : 0f; - if (Main.IsItDay() || bossRush) - { - calamityGlobalNPC.CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } + bool increaseSpeed = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; + bool increaseSpeedMore = Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; // Phase for flying at the player bool flyAtTarget = (calamityGlobalNPC.newAI[3] >= FlightPhaseGateValue && startFlightPhase) || hasSpawnDR; // Dust on spawn and alpha effects - if (npc.type == NPCID.TheDestroyer || (npc.type != NPCID.TheDestroyer && Main.npc[(int)npc.ai[1]].alpha < 128)) + if (NPC.type == NPCID.TheDestroyer || (NPC.type != NPCID.TheDestroyer && Main.npc[(int)NPC.ai[1]].alpha < 128)) { - if (npc.alpha != 0) + if (NPC.alpha != 0) { for (int i = 0; i < 2; i++) { - int spawnDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.TheDestroyer, 0f, 0f, 100, default, 2f); + int spawnDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TheDestroyer, 0f, 0f, 100, default, 2f); Main.dust[spawnDust].noGravity = true; Main.dust[spawnDust].noLight = true; } } - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } // Check if other segments are still alive, if not, die - // Check for Oblivion too, since having a max power Destroyer during that fight would be turbo cancer - bool oblivionAlive = false; - if (npc.type > NPCID.TheDestroyer) + if (NPC.type > NPCID.TheDestroyer) { bool shouldDespawn = true; for (int i = 0; i < Main.maxNPCs; i++) @@ -166,31 +176,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (!shouldDespawn) { - if (npc.ai[1] <= 0f) + if (NPC.ai[1] <= 0f) shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) + else if (Main.npc[(int)NPC.ai[1]].life <= 0) shouldDespawn = true; } if (shouldDespawn) { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - } - else - { - if (death && !bossRush && npc.localAI[3] == 1f) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == NPCID.SkeletronPrime)) - { - oblivionAlive = true; - break; - } - } + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); + NPC.active = false; } } @@ -199,7 +195,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Calculate aggression based on how many broken segments there are float brokenSegmentAggressionMultiplier = 1f; - if (npc.type == NPCID.TheDestroyer && !oblivionAlive) + if (NPC.type == NPCID.TheDestroyer) { int numProbeSegments = 0; for (int i = 0; i < Main.maxNPCs; i++) @@ -210,284 +206,123 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses brokenSegmentAggressionMultiplier += (1f - MathHelper.Clamp(numProbeSegments / (float)totalSegments, 0f, 1f)) * 0.25f; } - // Death Mode laser spit bool - bool spitLaserSpreads = death; - // Height of the box used to calculate whether The Destroyer should fly at its target or not int noFlyZoneBoxHeight = death ? 1500 : 1800; // Speed and movement variables - float speed = death ? 0.2f : 0.1f; - float turnSpeed = death ? 0.3f : 0.15f; + float speed = death ? 0.12f : 0.1f; + float turnSpeed = death ? 0.18f : 0.15f; // Max velocity - float segmentVelocity = flyAtTarget ? (death ? 22.5f : 15f) : (death ? 30f : 20f); + float segmentVelocity = flyAtTarget ? 15f : 20f; // Increase velocity based on distance float velocityMultiplier = increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f; + noFlyZoneBoxHeight -= death ? 400 : (int)(400f * (1f - lifeRatio)); - // If Oblivion is alive, don't fly, don't spit laser spreads, use the default vanilla no fly zone, reduce segment count to 60, use base speed and use base turn speed - if (oblivionAlive) + float segmentVelocityBoost = death ? (flyAtTarget ? 4f : 5.25f) * (1f - lifeRatio) : (flyAtTarget ? 3f : 4f) * (1f - lifeRatio); + float speedBoost = death ? (flyAtTarget ? 0.10f : 0.135f) * (1f - lifeRatio) : (flyAtTarget ? 0.075f : 0.1f) * (1f - lifeRatio); + float turnSpeedBoost = death ? 0.15f * (1f - lifeRatio) : 0.12f * (1f - lifeRatio); + + segmentVelocity += segmentVelocityBoost; + speed += speedBoost; + turnSpeed += turnSpeedBoost; + + if (flyAtTarget) { - calamityGlobalNPC.newAI[3] = 0f; - totalSegments = Main.getGoodWorld ? 75 : 60; - spitLaserSpreads = false; - noFlyZoneBoxHeight = 2000; - } - else - { - noFlyZoneBoxHeight -= death ? 400 : (int)(400f * (1f - lifeRatio)); - - float segmentVelocityBoost = death ? (flyAtTarget ? 4.5f : 6f) * (1f - lifeRatio) : (flyAtTarget ? 3f : 4f) * (1f - lifeRatio); - float speedBoost = death ? (flyAtTarget ? 0.1125f : 0.15f) * (1f - lifeRatio) : (flyAtTarget ? 0.075f : 0.1f) * (1f - lifeRatio); - float turnSpeedBoost = death ? 0.18f * (1f - lifeRatio) : 0.12f * (1f - lifeRatio); - - segmentVelocity += segmentVelocityBoost; - speed += speedBoost; - turnSpeed += turnSpeedBoost; - - segmentVelocity += 5f * enrageScale; - speed += 0.05f * enrageScale; - turnSpeed += 0.075f * enrageScale; - - if (flyAtTarget) - { - float speedMultiplier = phase5 ? 1.8f : phase4 ? 1.65f : 1.5f; - speed *= speedMultiplier; - } - - segmentVelocity *= velocityMultiplier; - speed *= velocityMultiplier; - turnSpeed *= velocityMultiplier; - - segmentVelocity *= brokenSegmentAggressionMultiplier; - speed *= brokenSegmentAggressionMultiplier; - turnSpeed *= brokenSegmentAggressionMultiplier; - - if (Main.getGoodWorld) - { - segmentVelocity *= 1.2f; - speed *= 1.2f; - turnSpeed *= 1.2f; - } + float speedMultiplier = phase5 ? 1.8f : phase4 ? 1.65f : 1.5f; + speed *= speedMultiplier; } - bool probeLaunched = npc.ai[2] == 1f; - if (npc.type == NPCID.TheDestroyerBody) + segmentVelocity *= velocityMultiplier; + speed *= velocityMultiplier; + turnSpeed *= velocityMultiplier; + + segmentVelocity *= brokenSegmentAggressionMultiplier; + speed *= brokenSegmentAggressionMultiplier; + turnSpeed *= brokenSegmentAggressionMultiplier; + + if (Main.getGoodWorld) { - // Enrage, fire more cyan lasers - if (enrageScale > 0f && !bossRush) - { - if (calamityGlobalNPC.newAI[2] < 480f) - calamityGlobalNPC.newAI[2] += 1f; - } - else - { - if (calamityGlobalNPC.newAI[2] > 0f) - calamityGlobalNPC.newAI[2] -= 1f; - } - - // Regenerate Probes in Master Mode if the number of Probes is less than 40 and the number of living NPCs is less than the segment count + 40 (this limit is here just in case) - // This doesn't happen if Oblivion is alive - if (death && probeLaunched && !oblivionAlive) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] >= 600f) - { - int maxProbes = 40; - bool regenerateProbeSegment = NPC.CountNPCS(NPCID.Probe) < maxProbes; - if (regenerateProbeSegment) - { - int maxNPCs = totalSegments + maxProbes; - int numNPCs = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active) - { - numNPCs++; - if (numNPCs >= maxNPCs) - { - regenerateProbeSegment = false; - break; - } - } - } - } - - if (regenerateProbeSegment) - { - npc.ai[2] = 0f; - npc.netUpdate = true; - } - - npc.localAI[2] = 0f; - npc.SyncVanillaLocalAI(); - } - } + segmentVelocity *= 1.2f; + speed *= 1.2f; + turnSpeed *= 1.2f; } - if (npc.type == NPCID.TheDestroyer) + bool probeLaunched = NPC.ai[2] == 1f; + + if (NPC.type == NPCID.TheDestroyer) { // Spawn segments from head - if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[3] = npc.whoAmI; - npc.realLife = npc.whoAmI; - int index = npc.whoAmI; + NPC.ai[3] = NPC.whoAmI; + NPC.realLife = NPC.whoAmI; + int index = NPC.whoAmI; for (int j = 0; j <= totalSegments; j++) { int type = NPCID.TheDestroyerBody; if (j == totalSegments) type = NPCID.TheDestroyerTail; - int segment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + npc.height), type, npc.whoAmI); - Main.npc[segment].ai[3] = npc.whoAmI; - Main.npc[segment].realLife = npc.whoAmI; - Main.npc[segment].ai[1] = index; - Main.npc[index].ai[0] = segment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); - index = segment; - } - } - - // Laser breath in Death Mode - if (spitLaserSpreads) - { - // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1) - { - calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1; - npc.SyncDestroyerLaserColor(); - } - - float laserBreathGateValue = DeathModeLaserBreathGateValue; - if (calamityGlobalNPC.newAI[0] < laserBreathGateValue) - calamityGlobalNPC.newAI[0] += 1f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Sync newAI every 20 frames for the new telegraph - if (calamityGlobalNPC.newAI[0] % 20f == 10f) - 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) - { - 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 (CalamityServerConfig.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) - { - Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (death ? 9 : 7) : (death ? 6 : 4); - int spread = death ? 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(); - } + int segment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X), (int)(NPC.position.Y + NPC.height), type, NPC.whoAmI); + Main.npc[segment].ai[3] = NPC.whoAmI; + Main.npc[segment].realLife = NPC.whoAmI; + Main.npc[segment].ai[1] = index; + Main.npc[index].ai[0] = segment; + Main.npc[index].Calamity().newAI[0] = -90f - Main.npc[index].ai[0] * (death ? 8f : 3f); // This controls the delay between laser shots + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); + index = segment; } } } // Fire lasers - if (npc.type == NPCID.TheDestroyerBody) + if (NPC.type == NPCID.TheDestroyerBody) { - bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; + bool ableToFireLaser = LaserColor != -1; // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched) + if (LaserColor == -1 && !probeLaunched) { - if (Main.rand.NextBool(death ? OneInXChanceToFireLaser / (phase5 ? 4 : phase4 ? 3 : 2) : OneInXChanceToFireLaser)) + int random = phase3 ? 4 : phase2 ? 3 : 2; + switch (Main.rand.Next(random)) { - 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; - - npc.SyncDestroyerLaserColor(); + case 0: + case 1: + LaserColor = 0; + break; + case 2: + LaserColor = 1; + break; + case 3: + LaserColor = 2; + break; } + + NPC.netUpdate = true; } if (probeLaunched && ableToFireLaser) { - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); + LaserColor = -1; + NPC.netUpdate = true; } // Laser rate of fire - float shootProjectileTime = death ? (phase5 ? 120f : phase4 ? 150f : 180f) : 450f; - float bodySegmentTime = npc.ai[0] * (death ? 20f : 30f); - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; + float shootProjectileTime = death ? (phase5 ? 350f : phase4 ? 400f : 450f) : 450f; if (ableToFireLaser) - calamityGlobalNPC.newAI[0] += laserTimerIncrement; + calamityGlobalNPC.newAI[0] += 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { // Sync newAI every 20 frames for the new telegraph if (calamityGlobalNPC.newAI[0] % 20f == 10f && ableToFireLaser) - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } Color telegraphColor = Color.Transparent; - switch (calamityGlobalNPC.destroyerLaserColor) + switch (LaserColor) { case 0: telegraphColor = Color.Red; @@ -500,10 +335,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) + if (calamityGlobalNPC.newAI[0] == shootProjectileTime - LaserTelegraphTime) { Particle telegraph = new DestroyerReticleTelegraph( - npc, + NPC, telegraphColor, 1.5f, 0.15f, @@ -511,10 +346,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses GeneralParticleHandler.SpawnParticle(telegraph); } - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) + if (calamityGlobalNPC.newAI[0] == shootProjectileTime - SparkTelegraphTime) { Particle spark = new DestroyerSparkTelegraph( - npc, + NPC, telegraphColor * 2f, Color.White, 3f, @@ -525,47 +360,44 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Shoot lasers // Shoot nothing if probe has been launched - if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) + if (calamityGlobalNPC.newAI[0] >= shootProjectileTime && ableToFireLaser) { + 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 - LaserTelegraphTime, 1f - lerpAmount); + // Controls the fire rate getting slower as health lowers if (!death) { - int numProbeSegments = 0; - for (int i = 0; i < Main.maxNPCs; i++) + if (NPC.localAI[3] == 0f && phase3) { - if (Main.npc[i].active && Main.npc[i].type == npc.type && Main.npc[i].ai[2] == 0f) - numProbeSegments++; + NPC.localAI[3] = 1f; + NPC.SyncVanillaLocalAI(); + laserShootTimeBonus -= NPC.ai[0] * 2f; + } + else if (NPC.localAI[3] == 1f && startFlightPhase) + { + NPC.localAI[3] = 2f; + NPC.SyncVanillaLocalAI(); + laserShootTimeBonus -= NPC.ai[0] * 2f; } - 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(); - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); } + calamityGlobalNPC.newAI[0] = laserShootTimeBonus; + NPC.SyncExtraAI(); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { - if (death) - { - 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(); - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - } - // Laser speed - float projectileSpeed = (death ? 4.5f : 3.5f) + Main.rand.NextFloat() * 1.5f; - projectileSpeed += enrageScale; + float projectileSpeed = death ? 5f : 4f; // Set projectile damage and type int projectileType = ProjectileID.DeathLaser; - switch (calamityGlobalNPC.destroyerLaserColor) + switch (LaserColor) { default: case 0: @@ -581,61 +413,47 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // 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 (CalamityServerConfig.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) * projectileSpeed; + Vector2 projectileSpawn = NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 100f; if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, LaserDamage.CalculateMechDamage(), 0f, Main.myPlayer, 1f, 0f); Main.projectile[proj].timeLeft = 1200; } - npc.netUpdate = true; + NPC.netUpdate = true; if (death) { - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); + LaserColor = -1; + NPC.netUpdate = true; } } if (!death) { - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); + LaserColor = -1; + NPC.netUpdate = true; } } } - if (npc.type == NPCID.TheDestroyer) + if (NPC.type == NPCID.TheDestroyer) { - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; + if (NPC.life > Main.npc[(int)NPC.ai[0]].life) + NPC.life = Main.npc[(int)NPC.ai[0]].life; } else { - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; } - int tilePosX = (int)(npc.position.X / 16f) - 1; - int tileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2; - int tilePosY = (int)(npc.position.Y / 16f) - 1; - int tileWidthPosY = (int)((npc.position.Y + npc.height) / 16f) + 2; + int tilePosX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + NPC.width) / 16f) + 2; + int tilePosY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + NPC.height) / 16f) + 2; if (tilePosX < 0) tilePosX = 0; @@ -659,7 +477,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 tileConvertedPosition; tileConvertedPosition.X = k * 16; tileConvertedPosition.Y = l * 16; - if (npc.position.X + npc.width > tileConvertedPosition.X && npc.position.X < tileConvertedPosition.X + 16f && npc.position.Y + npc.height > tileConvertedPosition.Y && npc.position.Y < tileConvertedPosition.Y + 16f) + if (NPC.position.X + NPC.width > tileConvertedPosition.X && NPC.position.X < tileConvertedPosition.X + 16f && NPC.position.Y + NPC.height > tileConvertedPosition.Y && NPC.position.Y < tileConvertedPosition.Y + 16f) { shouldFly = true; break; @@ -672,15 +490,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Start flying if target is not within a certain distance if (!shouldFly) { - npc.localAI[1] = 1f; + NPC.localAI[1] = 1f; - if (npc.type == NPCID.TheDestroyer) + if (NPC.type == NPCID.TheDestroyer) { - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); int noFlyZone = 1000; bool outsideNoFlyZone = true; - if (npc.position.Y > player.position.Y) + if (NPC.position.Y > player.position.Y) { for (int m = 0; m < Main.maxPlayers; m++) { @@ -701,9 +519,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } else - npc.localAI[1] = 0f; + NPC.localAI[1] = 0f; - if (npc.type != NPCID.TheDestroyerBody || !probeLaunched) + if (NPC.type != NPCID.TheDestroyerBody || !probeLaunched) { Vector3 lightColor = Color.Red.ToVector3(); @@ -715,39 +533,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Telegraph for the laser breath and body lasers float telegraphProgress = 0f; - if (calamityGlobalNPC.destroyerLaserColor != -1) + if (LaserColor != -1) { - if (npc.type == NPCID.TheDestroyer && spitLaserSpreads) + if (NPC.type == NPCID.TheDestroyerBody) { - float telegraphGateValue = DeathModeLaserBreathGateValue - LaserTelegraphTime; + float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 400f : 450f; + float telegraphGateValue = shootProjectileTime - LaserTelegraphTime; if (calamityGlobalNPC.newAI[0] > telegraphGateValue) { - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); - break; - - case 2: - telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); - break; - } - telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); - } - } - else if (npc.type == NPCID.TheDestroyerBody) - { - float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 270f : 450f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; - if (calamityGlobalNPC.newAI[0] > telegraphGateValue) - { - switch (calamityGlobalNPC.destroyerLaserColor) + switch (LaserColor) { default: case 0: @@ -766,33 +560,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); + Lighting.AddLight(NPC.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); } // Despawn - bool oblivionFightDespawn = (oblivionAlive && lifeRatio < 0.8f) && npc.localAI[3] == 1f; - if (player.dead || oblivionFightDespawn) + if ((player.dead || Main.IsItDay()) && !BossRushEvent.BossRushActive) { shouldFly = false; - npc.velocity.Y += 2f; + NPC.velocity.Y += 2f; - if (npc.position.Y > Main.worldSurface * 16D) + if (NPC.position.Y > Main.worldSurface * 16D) { - npc.velocity.Y += 2f; + NPC.velocity.Y += 2f; segmentVelocity *= 2f; } - if (npc.position.Y > Main.rockLayer * 16D) + if (NPC.position.Y > Main.rockLayer * 16D) { for (int n = 0; n < Main.maxNPCs; n++) { - if (Main.npc[n].aiStyle == npc.aiStyle) + if (Main.npc[n].aiStyle == NPC.aiStyle) Main.npc[n].active = false; } } } - Vector2 npcCenter = npc.Center; + Vector2 npcCenter = NPC.Center; float targetTilePosX = player.Center.X; float targetTilePosY = player.Center.Y; targetTilePosX = (int)(targetTilePosX / 16f) * 16; @@ -803,14 +596,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses targetTilePosY -= npcCenter.Y; float targetTileDist = (float)Math.Sqrt(targetTilePosX * targetTilePosX + targetTilePosY * targetTilePosY); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { - int mechdusaSegmentScale = (int)(44f * npc.scale); + int mechdusaSegmentScale = (int)(44f * NPC.scale); try { - npcCenter = npc.Center; - targetTilePosX = Main.npc[(int)npc.ai[1]].Center.X - npcCenter.X; - targetTilePosY = Main.npc[(int)npc.ai[1]].Center.Y - npcCenter.Y; + npcCenter = NPC.Center; + targetTilePosX = Main.npc[(int)NPC.ai[1]].Center.X - npcCenter.X; + targetTilePosY = Main.npc[(int)NPC.ai[1]].Center.Y - npcCenter.Y; } catch { @@ -825,10 +618,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (absoluteTilePosX > (float)mechdusaSegmentScale) absoluteTilePosX = mechdusaSegmentScale; - targetTilePosY = Main.npc[(int)npc.ai[1]].Center.Y + absoluteTilePosX - npcCenter.Y; + targetTilePosY = Main.npc[(int)NPC.ai[1]].Center.Y + absoluteTilePosX - npcCenter.Y; } - npc.rotation = (float)Math.Atan2(targetTilePosY, targetTilePosX) + MathHelper.PiOver2; + NPC.rotation = (float)Math.Atan2(targetTilePosY, targetTilePosX) + MathHelper.PiOver2; targetTileDist = (float)Math.Sqrt(targetTilePosX * targetTilePosX + targetTilePosY * targetTilePosY); if (mechdusaCurvedSpineSegmentIndex > 0) mechdusaSegmentScale = mechdusaSegmentScale / mechdusaCurvedSpineSegments * mechdusaCurvedSpineSegmentIndex; @@ -836,58 +629,58 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses targetTileDist = (targetTileDist - mechdusaSegmentScale) / targetTileDist; targetTilePosX *= targetTileDist; targetTilePosY *= targetTileDist; - npc.velocity = Vector2.Zero; - npc.position.X += targetTilePosX; - npc.position.Y += targetTilePosY; + NPC.velocity = Vector2.Zero; + NPC.position.X += targetTilePosX; + NPC.position.Y += targetTilePosY; } else { if (!shouldFly) { - npc.velocity.Y += 0.15f; - if (death && npc.velocity.Y > 0f && Math.Abs(npc.Center.Y - player.Center.Y) > 360f) - npc.velocity.Y += 0.05f; + NPC.velocity.Y += 0.15f; + if (death && NPC.velocity.Y > 0f && Math.Abs(NPC.Center.Y - player.Center.Y) > 360f) + NPC.velocity.Y += 0.05f; - if (npc.velocity.Y > segmentVelocity) - npc.velocity.Y = segmentVelocity; + if (NPC.velocity.Y > segmentVelocity) + NPC.velocity.Y = segmentVelocity; // This bool exists to stop the strange wiggle behavior when worms are falling down - bool slowXVelocity = Math.Abs(npc.velocity.X) > speed; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.4) + bool slowXVelocity = Math.Abs(NPC.velocity.X) > speed; + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.4) { - if (npc.velocity.X < 0f) - npc.velocity.X -= speed * 1.1f; + if (NPC.velocity.X < 0f) + NPC.velocity.X -= speed * 1.1f; else - npc.velocity.X += speed * 1.1f; + NPC.velocity.X += speed * 1.1f; } - else if (npc.velocity.Y == segmentVelocity) + else if (NPC.velocity.Y == segmentVelocity) { if (slowXVelocity) { - if (npc.velocity.X < targetTilePosX) - npc.velocity.X += speed; - else if (npc.velocity.X > targetTilePosX) - npc.velocity.X -= speed; + if (NPC.velocity.X < targetTilePosX) + NPC.velocity.X += speed; + else if (NPC.velocity.X > targetTilePosX) + NPC.velocity.X -= speed; } else - npc.velocity.X = 0f; + NPC.velocity.X = 0f; } - else if (npc.velocity.Y > 4f) + else if (NPC.velocity.Y > 4f) { if (slowXVelocity) { - if (npc.velocity.X < 0f) - npc.velocity.X += speed * 0.9f; + if (NPC.velocity.X < 0f) + NPC.velocity.X += speed * 0.9f; else - npc.velocity.X -= speed * 0.9f; + NPC.velocity.X -= speed * 0.9f; } else - npc.velocity.X = 0f; + NPC.velocity.X = 0f; } } else { - if (npc.soundDelay == 0) + if (NPC.soundDelay == 0) { float soundDelay = targetTileDist / 40f; if (soundDelay < 10f) @@ -895,8 +688,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (soundDelay > 20f) soundDelay = 20f; - npc.soundDelay = (int)soundDelay; - SoundEngine.PlaySound(SoundID.WormDig, npc.Center); + NPC.soundDelay = (int)soundDelay; + SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } targetTileDist = (float)Math.Sqrt(targetTilePosX * targetTilePosX + targetTilePosY * targetTilePosY); @@ -910,27 +703,27 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (flyAtTarget) { float chargeDistance = 600f; - if (((npc.velocity.X > 0f && targetTilePosX < 0f) || (npc.velocity.X < 0f && targetTilePosX > 0f) || (npc.velocity.Y > 0f && targetTilePosY < 0f) || (npc.velocity.Y < 0f && targetTilePosY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > speed / 2f && targetTileDist < chargeDistance) + if (((NPC.velocity.X > 0f && targetTilePosX < 0f) || (NPC.velocity.X < 0f && targetTilePosX > 0f) || (NPC.velocity.Y > 0f && targetTilePosY < 0f) || (NPC.velocity.Y < 0f && targetTilePosY > 0f)) && Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) > speed / 2f && targetTileDist < chargeDistance) { flyWyvernMovement = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < segmentVelocity) - npc.velocity *= 1.1f; + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < segmentVelocity) + NPC.velocity *= 1.1f; } - if (npc.position.Y > player.position.Y) + if (NPC.position.Y > player.position.Y) { flyWyvernMovement = true; - if (Math.Abs(npc.velocity.X) < segmentVelocity / 2f) + if (Math.Abs(NPC.velocity.X) < segmentVelocity / 2f) { - if (npc.velocity.X == 0f) - npc.velocity.X -= npc.direction; + if (NPC.velocity.X == 0f) + NPC.velocity.X -= NPC.direction; - npc.velocity.X *= 1.1f; + NPC.velocity.X *= 1.1f; } - else if (npc.velocity.Y > -segmentVelocity) - npc.velocity.Y -= speed; + else if (NPC.velocity.Y > -segmentVelocity) + NPC.velocity.Y -= speed; } } @@ -938,111 +731,110 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!flyAtTarget) { - if (((npc.velocity.X > 0f && targetTilePosX > 0f) || (npc.velocity.X < 0f && targetTilePosX < 0f)) && ((npc.velocity.Y > 0f && targetTilePosY > 0f) || (npc.velocity.Y < 0f && targetTilePosY < 0f))) + if (((NPC.velocity.X > 0f && targetTilePosX > 0f) || (NPC.velocity.X < 0f && targetTilePosX < 0f)) && ((NPC.velocity.Y > 0f && targetTilePosY > 0f) || (NPC.velocity.Y < 0f && targetTilePosY < 0f))) { - if (npc.velocity.X < targetTilePosX) - npc.velocity.X += turnSpeed; - else if (npc.velocity.X > targetTilePosX) - npc.velocity.X -= turnSpeed; - if (npc.velocity.Y < targetTilePosY) - npc.velocity.Y += turnSpeed; - else if (npc.velocity.Y > targetTilePosY) - npc.velocity.Y -= turnSpeed; + if (NPC.velocity.X < targetTilePosX) + NPC.velocity.X += turnSpeed; + else if (NPC.velocity.X > targetTilePosX) + NPC.velocity.X -= turnSpeed; + if (NPC.velocity.Y < targetTilePosY) + NPC.velocity.Y += turnSpeed; + else if (NPC.velocity.Y > targetTilePosY) + NPC.velocity.Y -= turnSpeed; } } - if ((npc.velocity.X > 0f && targetTilePosX > 0f) || (npc.velocity.X < 0f && targetTilePosX < 0f) || (npc.velocity.Y > 0f && targetTilePosY > 0f) || (npc.velocity.Y < 0f && targetTilePosY < 0f)) + if ((NPC.velocity.X > 0f && targetTilePosX > 0f) || (NPC.velocity.X < 0f && targetTilePosX < 0f) || (NPC.velocity.Y > 0f && targetTilePosY > 0f) || (NPC.velocity.Y < 0f && targetTilePosY < 0f)) { - if (npc.velocity.X < targetTilePosX) - npc.velocity.X += speed; - else if (npc.velocity.X > targetTilePosX) - npc.velocity.X -= speed; - if (npc.velocity.Y < targetTilePosY) - npc.velocity.Y += speed; - else if (npc.velocity.Y > targetTilePosY) - npc.velocity.Y -= speed; + if (NPC.velocity.X < targetTilePosX) + NPC.velocity.X += speed; + else if (NPC.velocity.X > targetTilePosX) + NPC.velocity.X -= speed; + if (NPC.velocity.Y < targetTilePosY) + NPC.velocity.Y += speed; + else if (NPC.velocity.Y > targetTilePosY) + NPC.velocity.Y -= speed; - if (Math.Abs(targetTilePosY) < segmentVelocity * 0.2 && ((npc.velocity.X > 0f && targetTilePosX < 0f) || (npc.velocity.X < 0f && targetTilePosX > 0f))) + if (Math.Abs(targetTilePosY) < segmentVelocity * 0.2 && ((NPC.velocity.X > 0f && targetTilePosX < 0f) || (NPC.velocity.X < 0f && targetTilePosX > 0f))) { - if (npc.velocity.Y > 0f) - npc.velocity.Y += speed * 2f; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += speed * 2f; else - npc.velocity.Y -= speed * 2f; + NPC.velocity.Y -= speed * 2f; } - if (Math.Abs(targetTilePosX) < segmentVelocity * 0.2 && ((npc.velocity.Y > 0f && targetTilePosY < 0f) || (npc.velocity.Y < 0f && targetTilePosY > 0f))) + if (Math.Abs(targetTilePosX) < segmentVelocity * 0.2 && ((NPC.velocity.Y > 0f && targetTilePosY < 0f) || (NPC.velocity.Y < 0f && targetTilePosY > 0f))) { - if (npc.velocity.X > 0f) - npc.velocity.X += speed * 2f; + if (NPC.velocity.X > 0f) + NPC.velocity.X += speed * 2f; else - npc.velocity.X -= speed * 2f; + NPC.velocity.X -= speed * 2f; } } else if (absoluteTilePosX > absoluteTilePosY) { - if (npc.velocity.X < targetTilePosX) - npc.velocity.X += speed * 1.1f; - else if (npc.velocity.X > targetTilePosX) - npc.velocity.X -= speed * 1.1f; + if (NPC.velocity.X < targetTilePosX) + NPC.velocity.X += speed * 1.1f; + else if (NPC.velocity.X > targetTilePosX) + NPC.velocity.X -= speed * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) { - if (npc.velocity.Y > 0f) - npc.velocity.Y += speed; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += speed; else - npc.velocity.Y -= speed; + NPC.velocity.Y -= speed; } } else { - if (npc.velocity.Y < targetTilePosY) - npc.velocity.Y += speed * 1.1f; - else if (npc.velocity.Y > targetTilePosY) - npc.velocity.Y -= speed * 1.1f; + if (NPC.velocity.Y < targetTilePosY) + NPC.velocity.Y += speed * 1.1f; + else if (NPC.velocity.Y > targetTilePosY) + NPC.velocity.Y -= speed * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) { - if (npc.velocity.X > 0f) - npc.velocity.X += speed; + if (NPC.velocity.X > 0f) + NPC.velocity.X += speed; else - npc.velocity.X -= speed; + NPC.velocity.X -= speed; } } } } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; - if (npc.type == NPCID.TheDestroyer) + if (NPC.type == NPCID.TheDestroyer) { if (shouldFly) { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; + if (NPC.localAI[0] != 1f) + NPC.netUpdate = true; - npc.localAI[0] = 1f; + NPC.localAI[0] = 1f; } else { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; + if (NPC.localAI[0] != 0f) + NPC.netUpdate = true; - npc.localAI[0] = 0f; + NPC.localAI[0] = 0f; } - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + NPC.netUpdate = true; } } - // Force the fucker to turn around in ground phase in Master - // Turns slower if Oblivion is alive, for fairness - if (npc.type == NPCID.TheDestroyer && death && !flyAtTarget) + // Force the fucker to turn around in ground phase in Death + if (NPC.type == NPCID.TheDestroyer && death && !flyAtTarget) { - if (npc.Distance(player.Center) > 2000f) - npc.velocity += (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * (oblivionAlive ? speed : turnSpeed); + if (NPC.Distance(player.Center) > 2000f) + NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; } - if (NPC.IsMechQueenUp && npc.type == NPCID.TheDestroyer) + if (NPC.IsMechQueenUp && NPC.type == NPCID.TheDestroyer) { NPC nPC = Main.npc[NPC.mechQueen]; Vector2 mechQueenCenter = nPC.GetMechQueenCenter(); @@ -1050,1063 +842,202 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 spinningpoint = mechQueenCenter + mechdusaSpinningVector; float mechdusaRotation = nPC.velocity.X * 0.025f; spinningpoint = spinningpoint.RotatedBy(mechdusaRotation, mechQueenCenter); - npc.position = spinningpoint - npc.Size / 2f + nPC.velocity; - npc.velocity.X = 0f; - npc.velocity.Y = 0f; - npc.rotation = mechdusaRotation * 0.75f + (float)Math.PI; + NPC.position = spinningpoint - NPC.Size / 2f + nPC.velocity; + NPC.velocity.X = 0f; + NPC.velocity.Y = 0f; + NPC.rotation = mechdusaRotation * 0.75f + (float)Math.PI; } // 10 seconds of resistance to prevent spawn killing - if (calamityGlobalNPC.newAI[1] < DRIncreaseTime && ((npc.position - npc.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 0f)) + if (calamityGlobalNPC.newAI[1] < DRIncreaseTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 0f)) calamityGlobalNPC.newAI[1] += 1f; - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = segmentVelocity * 0.25f; - float minimalDamageVelocity = segmentVelocity * 0.5f; - if (npc.type == NPCID.TheDestroyer) - { - if (npc.velocity.Length() <= minimalContactDamageVelocity) - { - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar); - } - } - else - { - float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - npc.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar); - } - } - return false; } - public static bool VanillaDestroyerAI(NPC npc, Mod mod) + public class ProbeAI : VanillaAIOverride { - int num = 0; - int num2 = 10; - if (NPC.IsMechQueenUp && npc.type != NPCID.TheDestroyer) + public override bool AI(Mod mod) { - int num3 = (int)npc.ai[1]; - while (num3 > 0 && num3 < Main.maxNPCs) + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, default); + + NPCAimedTarget targetData = NPC.GetTargetData(); + bool targetDead = false; + if (targetData.Type == NPCTargetType.Player) + targetDead = Main.player[NPC.target].dead; + + float velocity = death ? 8.15f : 7.2f; + float acceleration = death ? 0.07f : 0.06f; + float deceleration = 1f - acceleration; + + if (targetDead) { - if (Main.npc[num3].active && Main.npc[num3].type >= NPCID.TheDestroyer && Main.npc[num3].type <= NPCID.TheDestroyerTail) + Vector2 destination = NPC.Center - Vector2.UnitY; + Vector2 idealVelocity = NPC.SafeDirectionTo(destination) * velocity * 0.5f; + idealVelocity.X *= NPC.direction; + idealVelocity.Y *= 2.5f; + NPC.SimpleFlyMovement(idealVelocity, acceleration); + NPC.EncourageDespawn(10); + } + else if (NPC.Distance(targetData.Center) > 400f) + { + Vector2 idealVelocity = NPC.SafeDirectionTo(targetData.Center) * velocity; + NPC.SimpleFlyMovement(idealVelocity, acceleration); + } + else + { + if (NPC.Distance(targetData.Center) < 160f) { - num++; - if (Main.npc[num3].type == NPCID.TheDestroyer) - break; - - if (num >= num2) - { - num = 0; - break; - } - - num3 = (int)Main.npc[num3].ai[1]; - continue; + Vector2 idealVelocity = NPC.SafeDirectionTo(targetData.Center) * velocity; + NPC.SimpleFlyMovement(-idealVelocity, acceleration); } - - num = 0; - break; - } - } - - npc.Calamity().CurrentlyIncreasingDefenseOrDR = npc.Calamity().newAI[1] < DRIncreaseTime; - - if (npc.ai[3] > 0f) - npc.realLife = (int)npc.ai[3]; - - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (npc.type >= NPCID.TheDestroyer && npc.type <= NPCID.TheDestroyerTail) - { - if (npc.type == NPCID.TheDestroyer || (npc.type != NPCID.TheDestroyer && Main.npc[(int)npc.ai[1]].alpha < 128)) - { - if (npc.alpha != 0) - { - for (int i = 0; i < 2; i++) - { - int num4 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.TheDestroyer, 0f, 0f, 100, default(Color), 2f); - Main.dust[num4].noGravity = true; - Main.dust[num4].noLight = true; - } - } - - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - } - - if (npc.type > NPCID.TheDestroyer) - { - bool flag = false; - if (npc.ai[1] <= 0f) - flag = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - flag = true; - - if (flag) - { - npc.life = 0; - npc.HitEffect(); - npc.checkDead(); - } - } - - int destroyerSegmentsCount = NPC.GetDestroyerSegmentsCount(); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[0] == 0f && npc.type == NPCID.TheDestroyer) - { - npc.ai[3] = npc.whoAmI; - npc.realLife = npc.whoAmI; - int num5 = 0; - int num6 = npc.whoAmI; - for (int j = 0; j <= destroyerSegmentsCount; j++) - { - int num7 = NPCID.TheDestroyerBody; - if (j == destroyerSegmentsCount) - num7 = NPCID.TheDestroyerTail; - - num5 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + (float)npc.height), num7, npc.whoAmI); - Main.npc[num5].ai[3] = npc.whoAmI; - Main.npc[num5].realLife = npc.whoAmI; - Main.npc[num5].ai[1] = num6; - Main.npc[num6].ai[0] = num5; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num5); - num6 = num5; - } - } - } - - if (npc.type == NPCID.TheDestroyerBody) - { - bool probeLaunched = npc.ai[2] == 1f; - bool ableToFireLaser = npc.Calamity().destroyerLaserColor != -1; - - if (npc.Calamity().destroyerLaserColor == -1 && !probeLaunched && Main.rand.NextBool(OneInXChanceToFireLaser)) - { - npc.Calamity().destroyerLaserColor = 0; - npc.SyncDestroyerLaserColor(); + else + NPC.velocity *= deceleration; } - if (probeLaunched && ableToFireLaser) - { - npc.Calamity().destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - } - - float shootProjectileTime = Main.masterMode ? 500f : Main.expertMode ? 700f : 900f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - - float laserTimerIncrement = (npc.localAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; - if (ableToFireLaser) - npc.localAI[0] += laserTimerIncrement; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Sync newAI every 20 frames for the new telegraph - if (npc.localAI[0] % 20f == 10f && ableToFireLaser) - npc.SyncVanillaLocalAI(); - } - - Color telegraphColor = Color.Transparent; - switch (npc.Calamity().destroyerLaserColor) - { - case 0: - telegraphColor = Color.Red; - break; - case 1: - telegraphColor = Color.Green; - break; - case 2: - telegraphColor = Color.Cyan; - break; - } - - if (npc.localAI[0] == shootProjectileGateValue - LaserTelegraphTime) - { - Particle telegraph = new DestroyerReticleTelegraph( - npc, - telegraphColor, - 1.5f, - 0.15f, - (int)LaserTelegraphTime); - GeneralParticleHandler.SpawnParticle(telegraph); - } - - if (npc.localAI[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); - } - - if (npc.localAI[0] >= shootProjectileGateValue && ableToFireLaser) - { - 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)destroyerSegmentsCount, 0f, 1f); - float laserShootTimeBonus = (int)MathHelper.Lerp(0f, (shootProjectileTime + bodySegmentTime * lerpAmount) - LaserTelegraphTime, 1f - lerpAmount); - npc.localAI[0] = laserShootTimeBonus; - npc.SyncVanillaLocalAI(); - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - float laserVelocity = (Main.masterMode ? 3.5f : Main.expertMode ? 3f : 2.5f) + Main.rand.NextFloat() * 1.5f; - Vector2 vector = npc.Center; - float num8 = Main.player[npc.target].Center.X - vector.X + (float)Main.rand.Next(-2, 3); - float num9 = Main.player[npc.target].Center.Y - vector.Y + (float)Main.rand.Next(-2, 3); - float num10 = (float)Math.Sqrt(num8 * num8 + num9 * num9); - num10 = laserVelocity / num10; - num8 *= num10; - num9 *= num10; - num8 += (float)Main.rand.Next(-2, 3) * 0.05f; - num9 += (float)Main.rand.Next(-2, 3) * 0.05f; - - int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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 laserVelocityActual = new Vector2(num8, num9); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num12 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector + laserVelocityActual.SafeNormalize(Vector2.UnitY) * 100f, laserVelocityActual, type, damage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[num12].timeLeft = 1200; - } - - npc.netUpdate = true; - } - - npc.Calamity().destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - } - } - - if (npc.type == NPCID.TheDestroyer) - { - if (npc.life > Main.npc[(int)npc.ai[0]].life) - npc.life = Main.npc[(int)npc.ai[0]].life; - } - else - { - if (npc.life > Main.npc[(int)npc.ai[1]].life) - npc.life = Main.npc[(int)npc.ai[1]].life; - } - - // Calculate aggression based on how many broken segments there are - float brokenSegmentAggressionMultiplier = 1f; - if (npc.type == NPCID.TheDestroyer) - { - int numProbeSegments = 0; for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].active && Main.npc[i].type == NPCID.TheDestroyerBody && Main.npc[i].ai[2] == 0f) - numProbeSegments++; - } - brokenSegmentAggressionMultiplier += (1f - MathHelper.Clamp(numProbeSegments / (float)destroyerSegmentsCount, 0f, 1f)) * 0.25f; - } - - int num13 = (int)(npc.position.X / 16f) - 1; - int num14 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num15 = (int)(npc.position.Y / 16f) - 1; - int num16 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num13 < 0) - num13 = 0; - - if (num14 > Main.maxTilesX) - num14 = Main.maxTilesX; - - if (num15 < 0) - num15 = 0; - - if (num16 > Main.maxTilesY) - num16 = Main.maxTilesY; - - bool flag2 = false; - if (!flag2) - { - Vector2 vector2 = default(Vector2); - for (int k = num13; k < num14; k++) - { - for (int l = num15; l < num16; l++) + if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type) { - if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[Main.tile[k, l].TileType] || (Main.tileSolidTop[Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) + Vector2 otherProbeDist = Main.npc[i].Center - NPC.Center; + if (otherProbeDist.Length() < (NPC.width + NPC.height)) { - vector2.X = k * 16; - vector2.Y = l * 16; - if (npc.position.X + (float)npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + (float)npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f) + otherProbeDist = otherProbeDist.SafeNormalize(Vector2.UnitY); + otherProbeDist *= -0.1f; + NPC.velocity += otherProbeDist; + Main.npc[i].velocity -= otherProbeDist; + } + } + } + + if (NPC.ai[3] != 0f) + { + if (NPC.IsMechQueenUp) + { + NPC nPC = Main.npc[NPC.mechQueen]; + Vector2 tileConvertedPosition = new Vector2(26f * NPC.ai[3], 0f); + int mechdusaProbe = (int)NPC.ai[2]; + if (mechdusaProbe < 0 || mechdusaProbe >= Main.maxNPCs) + { + mechdusaProbe = NPC.FindFirstNPC(NPCID.TheDestroyer); + NPC.ai[2] = mechdusaProbe; + NPC.netUpdate = true; + } + + if (mechdusaProbe > -1) + { + NPC nPC2 = Main.npc[mechdusaProbe]; + if (!nPC2.active || nPC2.type != NPCID.TheDestroyer) { - flag2 = true; - break; + NPC.dontTakeDamage = false; + if (NPC.ai[3] > 0f) + NPC.netUpdate = true; + + NPC.ai[3] = 0f; + } + else + { + Vector2 spinningpoint = nPC2.Center + tileConvertedPosition; + spinningpoint = spinningpoint.RotatedBy(nPC2.rotation, nPC2.Center); + NPC.Center = spinningpoint; + NPC.velocity = nPC.velocity; + NPC.dontTakeDamage = true; } } - } - } - } - - if (!flag2) - { - if (npc.type != NPCID.TheDestroyerBody || npc.ai[2] != 1f) - { - Vector3 lightColor = Color.Red.ToVector3(); - - // Light colors - Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); - Vector3 segmentColor = groundColor; - Vector3 telegraphColor = groundColor; - - // Telegraph for the laser breath and body lasers - float telegraphProgress = 0f; - if (npc.Calamity().destroyerLaserColor != -1) - { - if (npc.type == NPCID.TheDestroyerBody) + else { - float shootProjectileTime = Main.masterMode ? 500f : Main.expertMode ? 700f : 900f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; - if (npc.localAI[0] > telegraphGateValue) - telegraphProgress = MathHelper.Clamp((npc.localAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); + NPC.dontTakeDamage = false; + if (NPC.ai[3] > 0f) + NPC.netUpdate = true; + + NPC.ai[3] = 0f; } } - - Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); - } - - npc.localAI[1] = 1f; - if (npc.type == NPCID.TheDestroyer) - { - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num17 = 1000; - int height = (num17 * 2) - (Main.masterMode ? 700 : Main.expertMode ? 400 : 0); - bool flag3 = true; - if (npc.position.Y > Main.player[npc.target].position.Y) + else { - for (int m = 0; m < Main.maxPlayers; m++) + NPC.dontTakeDamage = false; + if (NPC.ai[3] > 0f) + NPC.netUpdate = true; + + NPC.ai[3] = 0f; + } + } + else + NPC.dontTakeDamage = false; + + NPC.localAI[0] += 1f; + if ((NPC.justHit && !death) || targetDead) + NPC.localAI[0] = 0f; + + float laserGateValue = NPC.IsMechQueenUp ? ProbeLaserGateValue_Mechdusa : ProbeLaserGateValue_Rev; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.localAI[0] >= laserGateValue) + { + NPC.localAI[0] = 0f; + if (targetData.Type != 0 && Collision.CanHit(NPC.position, NPC.width, NPC.height, targetData.Position, targetData.Width, targetData.Height)) + { + int type = ProjectileID.PinkLaser; + int totalProjectiles = 1; + Vector2 projectileVelocity = (targetData.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; + if (NPC.IsMechQueenUp) { - if (Main.player[m].active) + Vector2 v = targetData.Center - NPC.Center - targetData.Velocity * 20f; + projectileVelocity = v.SafeNormalize(Vector2.UnitY) * 8f; + } + for (int i = 0; i < totalProjectiles; i++) + { + float velocityMultiplier = 1f; + switch (i) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num17, (int)Main.player[m].position.Y - num17, num17 * 2, height); - if (rectangle.Intersects(rectangle2)) - { - flag3 = false; + case 0: + break; + case 1: + velocityMultiplier = 0.95f; + break; + case 2: + velocityMultiplier = 0.9f; break; - } } + Vector2 laserVelocity = projectileVelocity * velocityMultiplier; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 50f, laserVelocity, type, ProbeLaserDamage.CalculateMechDamage(), 0f, Main.myPlayer); } - if (flag3) - flag2 = true; + NPC.netUpdate = true; } } - } - else - npc.localAI[1] = 0f; - float num18 = (Main.masterMode ? 24f : Main.expertMode ? 20f : 16f) * brokenSegmentAggressionMultiplier; - if (Main.IsItDay() || Main.player[npc.target].dead) - { - flag2 = false; - npc.velocity.Y += 1f; - if ((double)npc.position.Y > Main.worldSurface * 16D) + int x = (int)NPC.Center.X / 16; + int y = (int)NPC.Center.Y / 16; + if (WorldGen.InWorld(x, y) && !WorldGen.SolidTile(x, y)) + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0.3f, 0.1f, 0.05f); + + if (targetData.Center.X - NPC.Center.X > 0f) { - npc.velocity.Y += 1f; - num18 *= 2f; - } - - if ((double)npc.position.Y > Main.rockLayer * 16D) - { - for (int n = 0; n < Main.maxNPCs; n++) - { - if (Main.npc[n].aiStyle == npc.aiStyle) - Main.npc[n].active = false; - } - } - } - - float num19 = 0.1f; - float num20 = 0.15f; - if (Main.expertMode) - { - num19 = Main.masterMode ? 0.2f : 0.15f; - num20 = Main.masterMode ? 0.3f : 0.225f; - } - - if (Main.getGoodWorld) - { - num19 *= 1.2f; - num20 *= 1.2f; - } - - num19 *= brokenSegmentAggressionMultiplier; - num20 *= brokenSegmentAggressionMultiplier; - - Vector2 vector3 = npc.Center; - float num21 = Main.player[npc.target].Center.X; - float num22 = Main.player[npc.target].Center.Y; - num21 = (int)(num21 / 16f) * 16; - num22 = (int)(num22 / 16f) * 16; - vector3.X = (int)(vector3.X / 16f) * 16; - vector3.Y = (int)(vector3.Y / 16f) * 16; - num21 -= vector3.X; - num22 -= vector3.Y; - float num23 = (float)Math.Sqrt(num21 * num21 + num22 * num22); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - int num24 = (int)(44f * npc.scale); - try - { - vector3 = npc.Center; - num21 = Main.npc[(int)npc.ai[1]].Center.X - vector3.X; - num22 = Main.npc[(int)npc.ai[1]].Center.Y - vector3.Y; - } - catch - { - } - - if (num > 0) - { - float num25 = (float)num24 - (float)num24 * (((float)num - 1f) * 0.1f); - if (num25 < 0f) - num25 = 0f; - - if (num25 > (float)num24) - num25 = num24; - - num22 = Main.npc[(int)npc.ai[1]].Center.Y + num25 - vector3.Y; - } - - npc.rotation = (float)Math.Atan2(num22, num21) + MathHelper.PiOver2; - num23 = (float)Math.Sqrt(num21 * num21 + num22 * num22); - if (num > 0) - num24 = num24 / num2 * num; - - num23 = (num23 - (float)num24) / num23; - num21 *= num23; - num22 *= num23; - npc.velocity = Vector2.Zero; - npc.position.X += num21; - npc.position.Y += num22; - num21 = Main.npc[(int)npc.ai[1]].Center.X - vector3.X; - num22 = Main.npc[(int)npc.ai[1]].Center.Y - vector3.Y; - npc.rotation = (float)Math.Atan2(num22, num21) + MathHelper.PiOver2; - } - else - { - if (!flag2) - { - npc.velocity.Y += 0.15f; - if (Main.masterMode && npc.velocity.Y > 0f) - npc.velocity.Y += 0.05f; - - if (npc.velocity.Y > num18) - npc.velocity.Y = num18; - - // This bool exists to stop the strange wiggle behavior when worms are falling down - bool slowXVelocity = Math.Abs(npc.velocity.X) > num19; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num18 * 0.4) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= num19 * 1.1f; - else - npc.velocity.X += num19 * 1.1f; - } - else if (npc.velocity.Y == num18) - { - if (slowXVelocity) - { - if (npc.velocity.X < num21) - npc.velocity.X += num19; - else if (npc.velocity.X > num21) - npc.velocity.X -= num19; - } - else - npc.velocity.X = 0f; - } - else if (npc.velocity.Y > 4f) - { - if (slowXVelocity) - { - if (npc.velocity.X < 0f) - npc.velocity.X += num19 * 0.9f; - else - npc.velocity.X -= num19 * 0.9f; - } - else - npc.velocity.X = 0f; - } + NPC.spriteDirection = 1; + NPC.rotation = (float)Math.Atan2(targetData.Center.Y - NPC.Center.Y, targetData.Center.X - NPC.Center.X); } else { - if (npc.soundDelay == 0) - { - float num26 = num23 / 40f; - if (num26 < 10f) - num26 = 10f; - - if (num26 > 20f) - num26 = 20f; - - npc.soundDelay = (int)num26; - SoundEngine.PlaySound(SoundID.WormDig, npc.Center); - } - - num23 = (float)Math.Sqrt(num21 * num21 + num22 * num22); - float num27 = Math.Abs(num21); - float num28 = Math.Abs(num22); - float num29 = num18 / num23; - num21 *= num29; - num22 *= num29; - if (((npc.velocity.X > 0f && num21 > 0f) || (npc.velocity.X < 0f && num21 < 0f)) && ((npc.velocity.Y > 0f && num22 > 0f) || (npc.velocity.Y < 0f && num22 < 0f))) - { - if (npc.velocity.X < num21) - npc.velocity.X += num20; - else if (npc.velocity.X > num21) - npc.velocity.X -= num20; - - if (npc.velocity.Y < num22) - npc.velocity.Y += num20; - else if (npc.velocity.Y > num22) - npc.velocity.Y -= num20; - } - - if ((npc.velocity.X > 0f && num21 > 0f) || (npc.velocity.X < 0f && num21 < 0f) || (npc.velocity.Y > 0f && num22 > 0f) || (npc.velocity.Y < 0f && num22 < 0f)) - { - if (npc.velocity.X < num21) - npc.velocity.X += num19; - else if (npc.velocity.X > num21) - npc.velocity.X -= num19; - - if (npc.velocity.Y < num22) - npc.velocity.Y += num19; - else if (npc.velocity.Y > num22) - npc.velocity.Y -= num19; - - if ((double)Math.Abs(num22) < (double)num18 * 0.2 && ((npc.velocity.X > 0f && num21 < 0f) || (npc.velocity.X < 0f && num21 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num19 * 2f; - else - npc.velocity.Y -= num19 * 2f; - } - - if ((double)Math.Abs(num21) < (double)num18 * 0.2 && ((npc.velocity.Y > 0f && num22 < 0f) || (npc.velocity.Y < 0f && num22 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num19 * 2f; - else - npc.velocity.X -= num19 * 2f; - } - } - else if (num27 > num28) - { - if (npc.velocity.X < num21) - npc.velocity.X += num19 * 1.1f; - else if (npc.velocity.X > num21) - npc.velocity.X -= num19 * 1.1f; - - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num18 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num19; - else - npc.velocity.Y -= num19; - } - } - else - { - if (npc.velocity.Y < num22) - npc.velocity.Y += num19 * 1.1f; - else if (npc.velocity.Y > num22) - npc.velocity.Y -= num19 * 1.1f; - - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num18 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num19; - else - npc.velocity.X -= num19; - } - } + NPC.spriteDirection = -1; + NPC.rotation = (float)Math.Atan2(targetData.Center.Y - NPC.Center.Y, targetData.Center.X - NPC.Center.X) + MathHelper.Pi; } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - if (npc.type == NPCID.TheDestroyer) + if (NPC.IsMechQueenUp && NPC.ai[2] == 0f) { - if (flag2) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - } - } - - if (NPC.IsMechQueenUp && npc.type == NPCID.TheDestroyer) - { - NPC nPC = Main.npc[NPC.mechQueen]; - Vector2 mechQueenCenter = nPC.GetMechQueenCenter(); - Vector2 vector4 = new Vector2(0f, 100f); - Vector2 spinningpoint = mechQueenCenter + vector4; - float num30 = nPC.velocity.X * 0.025f; - spinningpoint = spinningpoint.RotatedBy(num30, mechQueenCenter); - npc.position = spinningpoint - npc.Size / 2f + nPC.velocity; - npc.velocity.X = 0f; - npc.velocity.Y = 0f; - npc.rotation = num30 * 0.75f + (float)Math.PI; - } - - // 10 seconds of resistance to prevent spawn killing - if (npc.Calamity().newAI[1] < DRIncreaseTime && ((npc.position - npc.oldPosition).Length() > 2f || npc.Calamity().newAI[1] > 0f)) - npc.Calamity().newAI[1] += 1f; - - // Calculate contact damage based on velocity - float minimalContactDamageVelocity = num18 * 0.25f; - float minimalDamageVelocity = num18 * 0.5f; - if (npc.type == NPCID.TheDestroyer) - { - if (npc.velocity.Length() <= minimalContactDamageVelocity) - { - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar); - } - } - else - { - float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageVelocity) - { - npc.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar); - } - } - - return false; - } - - public static bool BuffedProbeAI(NPC npc, Mod mod) - { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool oblivionAlive = npc.ai[1] == 1f; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, default); - - NPCAimedTarget targetData = npc.GetTargetData(); - bool targetDead = false; - if (targetData.Type == NPCTargetType.Player) - targetDead = Main.player[npc.target].dead; - - float velocity = bossRush ? 12f : death ? 8.4f : 7.2f; - float acceleration = bossRush ? 0.1f : death ? 0.07f : 0.06f; - float deceleration = 1f - acceleration; - - if (targetDead) - { - Vector2 destination = npc.Center - Vector2.UnitY; - Vector2 idealVelocity = npc.SafeDirectionTo(destination) * velocity * 0.5f; - idealVelocity.X *= npc.direction; - idealVelocity.Y *= 2.5f; - npc.SimpleFlyMovement(idealVelocity, acceleration); - npc.EncourageDespawn(10); - } - else if (npc.Distance(targetData.Center) > 400f) - { - Vector2 idealVelocity = npc.SafeDirectionTo(targetData.Center) * velocity; - npc.SimpleFlyMovement(idealVelocity, acceleration); - } - else - { - if (npc.Distance(targetData.Center) < 160f) - { - Vector2 idealVelocity = npc.SafeDirectionTo(targetData.Center) * velocity; - npc.SimpleFlyMovement(-idealVelocity, acceleration); - } - else - npc.velocity *= deceleration; - } - - for (int i = 0; i < Main.maxNPCs; i++) - { - if (death && !bossRush && npc.ai[1] == 0f) - { - if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == NPCID.SkeletronPrime)) - npc.ai[1] = 1f; + Vector2 center = NPC.GetTargetData().Center; + Vector2 v2 = center - NPC.Center; + if (v2.Length() < 120f) + NPC.Center = center - v2.SafeNormalize(Vector2.UnitY) * 120; } - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type) - { - Vector2 otherProbeDist = Main.npc[i].Center - npc.Center; - if (otherProbeDist.Length() < (npc.width + npc.height)) - { - otherProbeDist = otherProbeDist.SafeNormalize(Vector2.UnitY); - otherProbeDist *= -0.1f; - npc.velocity += otherProbeDist; - Main.npc[i].velocity -= otherProbeDist; - } - } + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + NPC.netUpdate = true; + + return false; } - - if (npc.ai[3] != 0f) - { - if (NPC.IsMechQueenUp) - { - NPC nPC = Main.npc[NPC.mechQueen]; - Vector2 tileConvertedPosition = new Vector2(26f * npc.ai[3], 0f); - int mechdusaProbe = (int)npc.ai[2]; - if (mechdusaProbe < 0 || mechdusaProbe >= Main.maxNPCs) - { - mechdusaProbe = NPC.FindFirstNPC(NPCID.TheDestroyer); - npc.ai[2] = mechdusaProbe; - npc.netUpdate = true; - } - - if (mechdusaProbe > -1) - { - NPC nPC2 = Main.npc[mechdusaProbe]; - if (!nPC2.active || nPC2.type != NPCID.TheDestroyer) - { - npc.dontTakeDamage = false; - if (npc.ai[3] > 0f) - npc.netUpdate = true; - - npc.ai[3] = 0f; - } - else - { - Vector2 spinningpoint = nPC2.Center + tileConvertedPosition; - spinningpoint = spinningpoint.RotatedBy(nPC2.rotation, nPC2.Center); - npc.Center = spinningpoint; - npc.velocity = nPC.velocity; - npc.dontTakeDamage = true; - } - } - else - { - npc.dontTakeDamage = false; - if (npc.ai[3] > 0f) - npc.netUpdate = true; - - npc.ai[3] = 0f; - } - } - else - { - npc.dontTakeDamage = false; - if (npc.ai[3] > 0f) - npc.netUpdate = true; - - npc.ai[3] = 0f; - } - } - else - npc.dontTakeDamage = false; - - npc.localAI[0] += 1f; - if ((npc.justHit && !death) || targetDead) - npc.localAI[0] = 0f; - - float laserGateValue = NPC.IsMechQueenUp ? ProbeLaserGateValue_Mechdusa : bossRush ? ProbeLaserGateValue_BossRush : ProbeLaserGateValue_Rev; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= laserGateValue) - { - npc.localAI[0] = 0f; - if (targetData.Type != 0 && Collision.CanHit(npc.position, npc.width, npc.height, targetData.Position, targetData.Width, targetData.Height)) - { - int type = ProjectileID.PinkLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - int totalProjectiles = oblivionAlive ? 2 : death ? 3 : 1; - Vector2 projectileVelocity = (targetData.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - if (NPC.IsMechQueenUp) - { - Vector2 v = targetData.Center - npc.Center - targetData.Velocity * 20f; - projectileVelocity = v.SafeNormalize(Vector2.UnitY) * 8f; - } - for (int i = 0; i < totalProjectiles; i++) - { - float velocityMultiplier = 1f; - switch (i) - { - case 0: - break; - case 1: - velocityMultiplier = 0.95f; - break; - case 2: - velocityMultiplier = 0.9f; - break; - } - Vector2 laserVelocity = projectileVelocity * velocityMultiplier; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 50f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - - npc.netUpdate = true; - } - } - - int x = (int)npc.Center.X / 16; - int y = (int)npc.Center.Y / 16; - if (WorldGen.InWorld(x, y) && !WorldGen.SolidTile(x, y)) - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0.3f, 0.1f, 0.05f); - - if (targetData.Center.X - npc.Center.X > 0f) - { - npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2(targetData.Center.Y - npc.Center.Y, targetData.Center.X - npc.Center.X); - } - else - { - npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2(targetData.Center.Y - npc.Center.Y, targetData.Center.X - npc.Center.X) + MathHelper.Pi; - } - - if (NPC.IsMechQueenUp && npc.ai[2] == 0f) - { - Vector2 center = npc.GetTargetData().Center; - Vector2 v2 = center - npc.Center; - if (v2.Length() < 120f) - npc.Center = center - v2.SafeNormalize(Vector2.UnitY) * 120; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - - return false; - } - - public static bool VanillaProbeAI(NPC npc, Mod mod) - { - if (npc.target < 0 || npc.target <= Main.maxPlayers || Main.player[npc.target].dead) - CalamityUtils.CalamityTargeting(npc, default); - - NPCAimedTarget targetData = npc.GetTargetData(); - bool targetDead = false; - if (targetData.Type == NPCTargetType.Player) - targetDead = Main.player[npc.target].dead; - - float velocity = Main.zenithWorld ? 3f : Main.expertMode ? 7.2f : 6f; - float acceleration = Main.expertMode ? 0.06f : 0.05f; - float deceleration = 1f - acceleration; - - if (targetDead || Main.IsItDay()) - { - Vector2 destination = npc.Center - Vector2.UnitY; - Vector2 idealVelocity = npc.SafeDirectionTo(destination) * velocity * 0.5f; - idealVelocity.X *= npc.direction; - idealVelocity.Y *= 2.5f; - npc.SimpleFlyMovement(idealVelocity, acceleration); - npc.EncourageDespawn(10); - } - else if (npc.Distance(targetData.Center) > 400f) - { - Vector2 idealVelocity = npc.SafeDirectionTo(targetData.Center) * velocity; - npc.SimpleFlyMovement(idealVelocity, acceleration); - } - else - { - if (npc.Distance(targetData.Center) < 160f) - { - Vector2 idealVelocity = npc.SafeDirectionTo(targetData.Center) * velocity; - npc.SimpleFlyMovement(-idealVelocity, acceleration); - } - else - npc.velocity *= deceleration; - } - - if (npc.ai[3] != 0f) - { - if (NPC.IsMechQueenUp) - { - NPC nPC = Main.npc[NPC.mechQueen]; - Vector2 vector2 = new Vector2(26f * npc.ai[3], 0f); - int num9 = (int)npc.ai[2]; - if (num9 < 0 || num9 >= Main.maxNPCs) - { - num9 = NPC.FindFirstNPC(NPCID.TheDestroyer); - npc.ai[2] = num9; - npc.netUpdate = true; - } - - if (num9 > -1) - { - NPC nPC2 = Main.npc[num9]; - if (!nPC2.active || nPC2.type != NPCID.TheDestroyer) - { - npc.dontTakeDamage = false; - if (npc.ai[3] > 0f) - npc.netUpdate = true; - - npc.ai[3] = 0f; - } - else - { - Vector2 spinningpoint = nPC2.Center + vector2; - spinningpoint = spinningpoint.RotatedBy(nPC2.rotation, nPC2.Center); - npc.Center = spinningpoint; - npc.velocity = nPC.velocity; - npc.dontTakeDamage = true; - } - } - else - { - npc.dontTakeDamage = false; - if (npc.ai[3] > 0f) - npc.netUpdate = true; - - npc.ai[3] = 0f; - } - } - else - { - npc.dontTakeDamage = false; - if (npc.ai[3] > 0f) - npc.netUpdate = true; - - npc.ai[3] = 0f; - } - } - else - npc.dontTakeDamage = false; - - npc.localAI[0] += 1f; - if (npc.ai[3] != 0f) - npc.localAI[0] += 2f; - - if ((npc.justHit && !Main.masterMode) || targetDead) - npc.localAI[0] = 0f; - - float num10 = ProbeLaserGateValue; - if (NPC.IsMechQueenUp) - num10 = ProbeLaserGateValue_Mechdusa; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= num10) - { - npc.localAI[0] = 0f; - if (targetData.Type != 0 && Collision.CanHit(npc, targetData)) - { - int type = ProjectileID.PinkLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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 = (targetData.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - if (NPC.IsMechQueenUp) - { - Vector2 v = targetData.Center - npc.Center - targetData.Velocity * 20f; - projectileVelocity = v.SafeNormalize(Vector2.UnitY) * 8f; - } - - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f, projectileVelocity, type, damage, 0f, Main.myPlayer); - } - } - - int num13 = (int)npc.Center.X; - int num14 = (int)npc.Center.Y; - num13 /= 16; - num14 /= 16; - if (WorldGen.InWorld(num13, num14) && !WorldGen.SolidTile(num13, num14)) - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0.3f, 0.1f, 0.05f); - - if (targetData.Center.X - npc.Center.X > 0f) - { - npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2(targetData.Center.Y - npc.Center.Y, targetData.Center.X - npc.Center.X); - } - else - { - npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2(targetData.Center.Y - npc.Center.Y, targetData.Center.X - npc.Center.X) + MathHelper.Pi; - } - - if (NPC.IsMechQueenUp && npc.ai[2] == 0f) - { - Vector2 center = npc.GetTargetData().Center; - Vector2 v2 = center - npc.Center; - int num28 = 120; - if (v2.Length() < (float)num28) - npc.Center = center - v2.SafeNormalize(Vector2.UnitY) * num28; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs deleted file mode 100644 index b97169ace4..0000000000 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DreadnautilusAI.cs +++ /dev/null @@ -1,446 +0,0 @@ -using System; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses -{ - public static class DreadnautilusAI - { - public static bool BuffedDreadnautilusAI(NPC npc, Mod mod) - { - // Death Mode bool - bool death = CalamityWorld.death; - - // Attack variables - float goToAttackPositionAcceleration = death ? 0.2f : 0.15f; - float goToAttackPositionVelocity = death ? 10f : 7.5f; - float phaseSwitchPhaseTime = death ? 30f : 60f; - float dashChargeUpPhaseTime = 120f; - float dashPhaseTime = death ? 150f : 180f; - float bloodSpitChargeUpPhaseTime = 90f; - float bloodSpitPhaseTime = death ? 120f : 90f; - int numBloodSpitVolleys = death ? 3 : 2; - float bloodSquidPhaseTime = 180f; - int maxBloodSquids = death ? 3 : 2; - - // Spawn effect - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - npc.alpha = 255; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = -1f; - npc.netUpdate = true; - } - } - - // Create dust - if (npc.ai[0] != -1f && Main.rand.NextBool(4)) - { - npc.position += npc.netOffset; - Dust dust = Dust.NewDustDirect(npc.position + new Vector2(5f), npc.width - 10, npc.height - 10, DustID.Blood); - dust.velocity *= 0.5f; - if (dust.velocity.Y < 0f) - dust.velocity.Y *= -1f; - - dust.alpha = 120; - dust.scale = 1f + Main.rand.NextFloat() * 0.4f; - dust.velocity += npc.velocity * 0.3f; - npc.position -= npc.netOffset; - } - - // Get a target - if (npc.target == Main.maxPlayers) - { - npc.TargetClosest(); - npc.ai[2] = npc.direction; - } - - // Get a new target if the current target is dead or too far away - if (Main.player[npc.target].dead || Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 2000f) - npc.TargetClosest(); - - // Set to despawn - NPCAimedTarget nPCAimedTarget = npc.GetTargetData(); - if (Main.dayTime || !Main.bloodMoon) - nPCAimedTarget = default(NPCAimedTarget); - - // Attacks and shit - int attackType = -1; - switch ((int)npc.ai[0]) - { - // Spawn effects - case -1: - { - npc.velocity *= 0.98f; - int spawnFaceDirection = Math.Sign(nPCAimedTarget.Center.X - npc.Center.X); - if (spawnFaceDirection != 0) - { - npc.direction = spawnFaceDirection; - npc.spriteDirection = -npc.direction; - } - - if (npc.localAI[1] == 0f && npc.alpha < 100) - { - npc.localAI[1] = 1f; - int dustAmt = 36; - for (int l = 0; l < dustAmt; l++) - { - npc.position += npc.netOffset; - Vector2 dustRotation = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((l - (dustAmt / 2 - 1)) * ((float)Math.PI * 2f) / dustAmt) + npc.Center; - Vector2 dustVelocity = dustRotation - npc.Center; - int spawnDustBlood = Dust.NewDust(dustRotation + dustVelocity, 0, 0, DustID.Blood, dustVelocity.X * 2f, dustVelocity.Y * 2f, 100, default, 1.4f); - Main.dust[spawnDustBlood].noGravity = true; - Main.dust[spawnDustBlood].velocity = Vector2.Normalize(dustVelocity) * 3f; - npc.position -= npc.netOffset; - } - } - - if (npc.ai[2] > 5f) - { - npc.velocity.Y = -2.5f; - npc.alpha -= 10; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.alpha += 15; - if (npc.alpha > 150) - npc.alpha = 150; - } - - if (npc.alpha < 0) - npc.alpha = 0; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= 50f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - break; - } - - // Get in position for an attack and then choose an attack type - case 0: - { - Vector2 destination = nPCAimedTarget.Center + new Vector2((0f - npc.ai[2]) * 500f, -300f); - if (npc.Center.Distance(destination) > 50f) - { - Vector2 desiredVelocity = npc.DirectionTo(destination) * goToAttackPositionVelocity; - npc.SimpleFlyMovement(desiredVelocity, goToAttackPositionAcceleration); - } - - npc.direction = (npc.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); - float faceTargetDirection = npc.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; - if (npc.spriteDirection == -1) - faceTargetDirection += (float)Math.PI; - - if (npc.spriteDirection != npc.direction) - { - npc.spriteDirection = npc.direction; - npc.rotation = 0f - npc.rotation; - faceTargetDirection = 0f - faceTargetDirection; - } - - npc.rotation = npc.rotation.AngleTowards(faceTargetDirection, 0.02f); - npc.ai[1] += 1f; - if (npc.ai[1] > phaseSwitchPhaseTime) - { - int attackPicker = (int)npc.ai[3]; - if (attackPicker % 7 == 3 && NPC.CountNPCS(NPCID.BloodSquid) < maxBloodSquids) - { - attackType = 3; - } - else if (attackPicker % 2 == 0) - { - SoundEngine.PlaySound(SoundID.Item170, npc.Center); - attackType = 2; - } - else - { - SoundEngine.PlaySound(SoundID.Item170, npc.Center); - attackType = 1; - } - } - - break; - } - - // Dash - case 1: - { - npc.direction = (!(npc.Center.X < nPCAimedTarget.Center.X)) ? 1 : (-1); - float chargeFaceDirection = npc.Center.DirectionFrom(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; - if (npc.spriteDirection == -1) - chargeFaceDirection += (float)Math.PI; - - bool shouldStartCharge = npc.ai[1] < dashChargeUpPhaseTime; - if (npc.spriteDirection != npc.direction && shouldStartCharge) - { - npc.spriteDirection = npc.direction; - npc.rotation = 0f - npc.rotation; - chargeFaceDirection = 0f - chargeFaceDirection; - } - - if (npc.ai[1] < dashChargeUpPhaseTime) - { - if (npc.ai[1] == dashChargeUpPhaseTime - 1f) - SoundEngine.PlaySound(SoundID.Item172, npc.Center); - - npc.velocity *= 0.95f; - npc.rotation = npc.rotation.AngleLerp(chargeFaceDirection, 0.02f); - npc.position += npc.netOffset; - npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition4, out Vector2 mouthDirection4); - Dust chargeUpDust = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 60f - new Vector2(40f), 80, 80, DustID.Cloud, 0f, 0f, 150, Color.Transparent, 0.6f); - chargeUpDust.fadeIn = 1f; - chargeUpDust.velocity = chargeUpDust.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * chargeUpDust.velocity.Length(); - chargeUpDust.noGravity = true; - chargeUpDust = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 100f - new Vector2(30f), 60, 60, DustID.Cloud, 0f, 0f, 100, Color.Transparent, 0.9f); - chargeUpDust.fadeIn = 1.5f; - chargeUpDust.velocity = chargeUpDust.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * (chargeUpDust.velocity.Length() + 5f); - chargeUpDust.noGravity = true; - npc.position -= npc.netOffset; - } - else if (npc.ai[1] < dashChargeUpPhaseTime + dashPhaseTime) - { - npc.position += npc.netOffset; - npc.rotation = npc.rotation.AngleLerp(chargeFaceDirection, 0.07f); - npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition5, out Vector2 mouthDirection5); - - // Dash directly towards the target until within 15 tiles of the target, and then continue in the same direction for 18 frames (15 frames in Death Mode) - if (npc.ai[1] < dashChargeUpPhaseTime + dashPhaseTime * 0.9f) - { - if (npc.Center.Distance(nPCAimedTarget.Center) > 240f || npc.ai[1] == dashChargeUpPhaseTime) - npc.velocity = mouthDirection5 * -(death ? 20f : 16f) + npc.Center.DirectionTo(nPCAimedTarget.Center) * 2f; - else - npc.ai[1] = dashChargeUpPhaseTime + dashPhaseTime * 0.9f; - } - - for (int m = 0; m < 4; m++) - { - Dust chargeBloodDust = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 60f - new Vector2(15f), 30, 30, DustID.Blood, 0f, 0f, 0, Color.Transparent, 1.5f); - chargeBloodDust.velocity = chargeBloodDust.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(5f, 5f)) * chargeBloodDust.velocity.Length(); - chargeBloodDust.position -= mouthDirection5 * 60f; - chargeBloodDust = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 100f - new Vector2(20f), 40, 40, DustID.Blood, 0f, 0f, 100, Color.Transparent, 1.5f); - chargeBloodDust.velocity = chargeBloodDust.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(10f, 10f)) * (chargeBloodDust.velocity.Length() + 5f); - chargeBloodDust.position -= mouthDirection5 * 100f; - } - - npc.position -= npc.netOffset; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= dashChargeUpPhaseTime + dashPhaseTime) - attackType = 0; - - break; - } - - // Spit 3 spreads of blood projectiles - case 2: - { - npc.direction = (npc.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); - float bloodProjFaceDirection = npc.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * npc.spriteDirection; - if (npc.spriteDirection == -1) - bloodProjFaceDirection += (float)Math.PI; - - if (npc.spriteDirection != npc.direction) - { - npc.spriteDirection = npc.direction; - npc.rotation = 0f - npc.rotation; - bloodProjFaceDirection = 0f - bloodProjFaceDirection; - } - - npc.rotation = npc.rotation.AngleLerp(bloodProjFaceDirection, 0.2f); - if (npc.ai[1] < bloodSpitChargeUpPhaseTime) - { - npc.position += npc.netOffset; - npc.velocity *= 0.95f; - npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition2, out Vector2 mouthDirection2); - if (!Main.rand.NextBool(4)) - { - Dust bloodProjChargeUpDust = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 60f - new Vector2(60f), 120, 120, DustID.Cloud, 0f, 0f, 150, Color.Transparent, 0.6f); - bloodProjChargeUpDust.fadeIn = 1f; - bloodProjChargeUpDust.velocity = bloodProjChargeUpDust.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (bloodProjChargeUpDust.velocity.Length() + 3f); - bloodProjChargeUpDust.noGravity = true; - bloodProjChargeUpDust = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 100f - new Vector2(80f), 160, 160, DustID.Cloud, 0f, 0f, 100, Color.Transparent, 0.9f); - bloodProjChargeUpDust.fadeIn = 1.5f; - bloodProjChargeUpDust.velocity = bloodProjChargeUpDust.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (bloodProjChargeUpDust.velocity.Length() + 5f); - bloodProjChargeUpDust.noGravity = true; - } - - npc.position -= npc.netOffset; - } - else if (npc.ai[1] < bloodSpitChargeUpPhaseTime + bloodSpitPhaseTime) - { - npc.position += npc.netOffset; - npc.velocity *= 0.9f; - float bloodProjShootTimer = (npc.ai[1] - bloodSpitChargeUpPhaseTime) % (bloodSpitPhaseTime / numBloodSpitVolleys); - npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition3, out Vector2 mouthDirection3); - if (bloodProjShootTimer < bloodSpitPhaseTime / numBloodSpitVolleys * 0.8f) - { - for (int i = 0; i < 5; i++) - { - Dust bloodProjShootDust = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 50f - new Vector2(15f), 30, 30, DustID.Blood, 0f, 0f, 0, Color.Transparent, 1.5f); - bloodProjShootDust.velocity = bloodProjShootDust.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * bloodProjShootDust.velocity.Length(); - bloodProjShootDust.position -= mouthDirection3 * 60f; - bloodProjShootDust = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 90f - new Vector2(20f), 40, 40, DustID.Blood, 0f, 0f, 100, Color.Transparent, 1.5f); - bloodProjShootDust.velocity = bloodProjShootDust.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (bloodProjShootDust.velocity.Length() + 5f); - bloodProjShootDust.position -= mouthDirection3 * 100f; - } - } - - // Spit blood spread - if ((int)bloodProjShootTimer == 0) - { - // Recoil away with each spit - npc.velocity += mouthDirection3 * -8f; - - // Spawn dust with each spit - for (int j = 0; j < 20; j++) - { - Dust bloodProjShootDust2 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 60f - new Vector2(15f), 30, 30, DustID.Blood, 0f, 0f, 0, Color.Transparent, 1.5f); - bloodProjShootDust2.velocity = bloodProjShootDust2.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * bloodProjShootDust2.velocity.Length(); - bloodProjShootDust2.position -= mouthDirection3 * 60f; - bloodProjShootDust2 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 100f - new Vector2(20f), 40, 40, DustID.Blood, 0f, 0f, 100, Color.Transparent, 1.5f); - bloodProjShootDust2.velocity = bloodProjShootDust2.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (bloodProjShootDust2.velocity.Length() + 5f); - bloodProjShootDust2.position -= mouthDirection3 * 100f; - } - - // Spawn projectiles - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int projectileAmt = death ? 6 : 5; - int spread = death ? 35 : 30; - float rotation = MathHelper.ToRadians(spread); - Vector2 initialProjectileVelocity = mouthDirection3 * 10f; - int damage = npc.GetAttackDamage_ForProjectiles(30f, 25f); - for (int k = 0; k < projectileAmt + 1; k++) - { - Vector2 perturbedSpeed = initialProjectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, k / (float)(projectileAmt - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), mouthPosition3 - mouthDirection3 * 5f, initialProjectileVelocity + perturbedSpeed, ProjectileID.BloodNautilusShot, damage, 0f, Main.myPlayer); - } - } - } - - npc.position -= npc.netOffset; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= bloodSpitChargeUpPhaseTime + bloodSpitPhaseTime) - attackType = 0; - - break; - } - - // Spawn Blood Squids - case 3: - { - npc.direction = (npc.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); - float targetAngle = 0f; - npc.spriteDirection = npc.direction; - if (npc.ai[1] < bloodSquidPhaseTime) - { - npc.position += npc.netOffset; - float bloodSquidVelClamp = MathHelper.Clamp(1f - npc.ai[1] / bloodSquidPhaseTime * 1.5f, 0f, 1f); - npc.velocity = Vector2.Lerp(value2: new Vector2(0f, bloodSquidVelClamp * -1.5f), value1: npc.velocity, amount: 0.03f); - npc.velocity = Vector2.Zero; - npc.rotation = npc.rotation.AngleLerp(targetAngle, 0.02f); - npc.BloodNautilus_GetMouthPositionAndRotation(out Vector2 _, out Vector2 _); - float t = npc.ai[1] / bloodSquidPhaseTime; - float scaleFactor2 = Utils.GetLerpValue(0f, 0.5f, t) * Utils.GetLerpValue(1f, 0.5f, t); - Lighting.AddLight(npc.Center, new Vector3(1f, 0.5f, 0.5f) * scaleFactor2); - if (!Main.rand.NextBool(3)) - { - Dust bloodSquidSpawnDust = Dust.NewDustDirect(npc.Center - new Vector2(6f), 12, 12, DustID.Blood, 0f, 0f, 60, Color.Transparent, 1.4f); - bloodSquidSpawnDust.position += new Vector2(npc.spriteDirection * 12, 12f); - bloodSquidSpawnDust.velocity *= 0.1f; - } - - npc.position -= npc.netOffset; - } - - if (npc.ai[1] == 10f || (death && npc.ai[1] == 20f) || npc.ai[1] == 30f) - BloodNautilus_CallForHelp(npc); - - npc.ai[1] += 1f; - if (npc.ai[1] >= bloodSquidPhaseTime) - attackType = 0; - - break; - } - } - - // Set AI arrays for the next attack - if (attackType != -1) - { - npc.ai[0] = attackType; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - npc.TargetClosest(); - if (attackType == 0) - npc.ai[2] = npc.direction; - else - npc.ai[3] += 1f; - } - - // Always set this to false because it's fucking stupid - npc.reflectsProjectiles = false; - - return false; - } - - private static void BloodNautilus_CallForHelp(NPC npc) - { - if (Main.netMode == NetmodeID.MultiplayerClient || !Main.player[npc.target].active || Main.player[npc.target].dead || npc.Distance(Main.player[npc.target].Center) > 2000f) - return; - - Point npcCenterTileCoords = npc.Center.ToTileCoordinates(); - Point npcCenterTileCoordsCopy = npcCenterTileCoords; - int bloodTearRandSpawnOffset = 20; - int npcCenterTileRadius = 3; - int npcCenterCopyTileRadius = 8; - int bloodTearSpawnTileRadius = 2; - int attempts = 0; - int bloodTearTileX; - int bloodTearTileY; - while (true) - { - if (attempts >= 100) - return; - - attempts++; - bloodTearTileX = Main.rand.Next(npcCenterTileCoordsCopy.X - bloodTearRandSpawnOffset, npcCenterTileCoordsCopy.X + bloodTearRandSpawnOffset + 1); - bloodTearTileY = Main.rand.Next(npcCenterTileCoordsCopy.Y - bloodTearRandSpawnOffset, npcCenterTileCoordsCopy.Y + bloodTearRandSpawnOffset + 1); - if ((bloodTearTileY < npcCenterTileCoordsCopy.Y - npcCenterCopyTileRadius || bloodTearTileY > npcCenterTileCoordsCopy.Y + npcCenterCopyTileRadius || bloodTearTileX < npcCenterTileCoordsCopy.X - npcCenterCopyTileRadius || bloodTearTileX > npcCenterTileCoordsCopy.X + npcCenterCopyTileRadius) && (bloodTearTileY < npcCenterTileCoords.Y - npcCenterTileRadius || bloodTearTileY > npcCenterTileCoords.Y + npcCenterTileRadius || bloodTearTileX < npcCenterTileCoords.X - npcCenterTileRadius || bloodTearTileX > npcCenterTileCoords.X + npcCenterTileRadius) && !Main.tile[bloodTearTileX, bloodTearTileY].HasUnactuatedTile) - { - bool spawnBloodTear = true; - if (spawnBloodTear && Main.tile[bloodTearTileX, bloodTearTileY].LiquidType == LiquidID.Lava) - spawnBloodTear = false; - - if (spawnBloodTear && Collision.SolidTiles(bloodTearTileX - bloodTearSpawnTileRadius, bloodTearTileX + bloodTearSpawnTileRadius, bloodTearTileY - bloodTearSpawnTileRadius, bloodTearTileY + bloodTearSpawnTileRadius)) - spawnBloodTear = false; - - if (spawnBloodTear && !Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - spawnBloodTear = false; - - if (spawnBloodTear) - break; - } - } - - Projectile.NewProjectile(npc.GetSource_FromAI(), bloodTearTileX * 16 + 8, bloodTearTileY * 16 + 8, 0f, 0f, ProjectileID.BloodNautilusTears, 0, 0f, Main.myPlayer); - } - } -} diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs index 744526387f..3f33e6802b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs @@ -9,40 +9,42 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class DukeFishronAI + public class DukeFishronAI : VanillaAIOverride { - public static bool BuffedDukeFishronAI(NPC npc, Mod mod) + // Vanilla values + public static float Phase2ContactDamageMult = 1.436f; // 201 + public static float Phase3ContactDamageMult = 1.315f; // 184 + + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Variables - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool masterModeSurprise = lifeRatio >= 0.9f && death; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool phase2 = lifeRatio < (death ? 0.6f : 0.7f); bool phase3 = lifeRatio < (death ? 0.3f : 0.4f); bool phase4 = lifeRatio < (death ? 0.1f : 0.2f); - bool phase2AI = npc.ai[0] > 4f; - bool phase3AI = npc.ai[0] > 9f; - bool charging = npc.ai[3] < 10f; + bool phase2AI = NPC.ai[0] > 4f; + bool phase3AI = NPC.ai[0] > 9f; + bool charging = NPC.ai[3] < 10f; // Adjust stats - int setDamage = npc.defDamage; + NPC.damage = NPC.defDamage; if (phase3AI) { - setDamage = (int)Math.Round(setDamage * 1.32); - npc.defense = 0; + NPC.damage = (int)Math.Round(NPC.defDamage * Phase3ContactDamageMult); + NPC.defense = 0; } else if (phase2AI) { - setDamage = (int)Math.Round(setDamage * 1.44); - npc.defense = (int)Math.Round(npc.defDefense * 0.8); + NPC.damage = (int)Math.Round(NPC.defDamage * Phase2ContactDamageMult); + NPC.defense = (int)Math.Round(NPC.defDefense * 0.8); } else - npc.defense = npc.defDefense; + NPC.defense = NPC.defDefense; int idlePhaseTimer = 30; float idlePhaseAcceleration = 0.55f; @@ -83,7 +85,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses idlePhaseAcceleration *= 1.05f; idlePhaseVelocity *= 1.08f; chargeTime -= 1; - chargeVelocity *= 1.13f; + chargeVelocity *= 1.1f; } if (Main.getGoodWorld) @@ -106,7 +108,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int teleportPhaseTimer = 30; - int bubbleSpinPhaseTimer = bossRush ? 45 : death ? 90 : 120; + int bubbleSpinPhaseTimer = death ? 90 : 120; int bubbleSpinPhaseDivisor = death ? 3 : 4; float bubbleSpinBubbleVelocity = death ? 8f : 7f; float bubbleSpinPhaseVelocity = 20f; @@ -117,48 +119,48 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int spawnEffectPhaseTimer = 75; - Player player = Main.player[npc.target]; + Player player = Main.player[NPC.target]; // Get target - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) + if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - player = Main.player[npc.target]; - npc.netUpdate = true; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + player = Main.player[NPC.target]; + NPC.netUpdate = true; } // Despawn - if (player.dead || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) + if (player.dead || Vector2.Distance(player.Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { - npc.velocity.Y -= 0.4f; + NPC.velocity.Y -= 0.4f; - if (npc.timeLeft > 10) - npc.timeLeft = 10; + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; - if (npc.ai[0] > 4f) - npc.ai[0] = 5f; + if (NPC.ai[0] > 4f) + NPC.ai[0] = 5f; else - npc.ai[0] = 0f; + NPC.ai[0] = 0f; - npc.ai[2] = 0f; + NPC.ai[2] = 0f; } // Enrage variable - bool enrage = !bossRush && + bool enrage = !BossRushEvent.BossRushActive && (player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400))); - calamityGlobalNPC.CurrentlyEnraged = !bossRush && enrage; + calamityGlobalNPC.CurrentlyEnraged = enrage; // Make him always able to take damage - npc.dontTakeDamage = false; + NPC.dontTakeDamage = false; // Increased DR during phase transitions - calamityGlobalNPC.DR = (npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f) ? (bossRush ? 0.99f : 0.625f) : 0.15f; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f; + calamityGlobalNPC.DR = (NPC.ai[0] == -1f || NPC.ai[0] == 4f || NPC.ai[0] == 9f) ? 0.625f : 0.15f; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = NPC.ai[0] == -1f || NPC.ai[0] == 4f || NPC.ai[0] == 9f; // Enrage - if (enrage || bossRush) + if (enrage) { bubbleBelchPhaseTimer = 20; bubbleBelchPhaseDivisor = 1; @@ -172,27 +174,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bubbleSpinPhaseDivisor = 1; bubbleSpinBubbleVelocity = 15f; - if (!bossRush) - { - setDamage *= 2; - npc.defense = npc.defDefense * 3; - } + NPC.damage *= 2; + NPC.defense = NPC.defDefense * 3; } if (death) { - idlePhaseTimer -= 6; - idlePhaseAcceleration *= 1.2f; - idlePhaseVelocity *= 1.2f; - chargeTime -= 4; - chargeVelocity += 3f; + chargeTime -= 2; + chargeVelocity += 1f; } - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) chargeTime += Main.rand.Next(5, 66); // Spawn cthulhunadoes in phase 3 - if (phase3AI && ((!phase4 && !masterModeSurprise) || Main.getGoodWorld)) + if (phase3AI && ((!phase4) || Main.getGoodWorld)) { calamityGlobalNPC.newAI[0] += 1f; float timeGateValue = 600f; @@ -201,162 +197,150 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[0] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, Vector2.Zero, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, npc.target + 1, (enrage || death) ? 1 : 0); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, NPC.target + 1, (enrage || death) ? 1 : 0); - npc.netUpdate = true; + NPC.netUpdate = true; } } // Set variables for spawn effects - if (npc.localAI[0] == 0f) + if (NPC.localAI[0] == 0f) { - npc.localAI[0] = 1f; - npc.alpha = 255; - npc.rotation = 0f; + NPC.localAI[0] = 1f; + NPC.alpha = 255; + NPC.rotation = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[0] = masterModeSurprise ? 9f : -1f; - npc.netUpdate = true; + NPC.ai[0] = -1f; + NPC.netUpdate = true; } } // Rotation float rateOfRotation = 0.04f; - if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 7f) + if (NPC.ai[0] == 1f || NPC.ai[0] == 6f || NPC.ai[0] == 7f) rateOfRotation = 0f; - if (npc.ai[0] == 3f || npc.ai[0] == 4f || npc.ai[0] == 8f) + if (NPC.ai[0] == 3f || NPC.ai[0] == 4f || NPC.ai[0] == 8f) rateOfRotation = 0.01f; - Vector2 rotationVector = player.Center - npc.Center; - if (!player.dead && bossRush && phase4) - { - // Rotate to show direction of predictive charge - if (npc.ai[0] == 10f) - { - rateOfRotation = 0.1f; - rotationVector = Vector2.Normalize(player.Center + player.velocity * 20f - npc.Center) * chargeVelocity; - } - } + Vector2 rotationVector = player.Center - NPC.Center; float rotationSpeed = (float)Math.Atan2(rotationVector.Y, rotationVector.X); - if (npc.spriteDirection == 1) + if (NPC.spriteDirection == 1) rotationSpeed += MathHelper.Pi; if (rotationSpeed < 0f) rotationSpeed += MathHelper.TwoPi; if (rotationSpeed > MathHelper.TwoPi) rotationSpeed -= MathHelper.TwoPi; - if (npc.ai[0] == -1f || npc.ai[0] == 3f || npc.ai[0] == 4f || npc.ai[0] == 8f) + if (NPC.ai[0] == -1f || NPC.ai[0] == 3f || NPC.ai[0] == 4f || NPC.ai[0] == 8f) rotationSpeed = 0f; if (rateOfRotation != 0f) - npc.rotation = npc.rotation.AngleTowards(rotationSpeed, rateOfRotation); + NPC.rotation = NPC.rotation.AngleTowards(rotationSpeed, rateOfRotation); // Alpha adjustments - if (npc.ai[0] != -1f && npc.ai[0] < 9f) + if (NPC.ai[0] != -1f && NPC.ai[0] < 9f) { - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.alpha += 15; else - npc.alpha -= 15; + NPC.alpha -= 15; - if (npc.alpha < 0) - npc.alpha = 0; - if (npc.alpha > 150) - npc.alpha = 150; + if (NPC.alpha < 0) + NPC.alpha = 0; + if (NPC.alpha > 150) + NPC.alpha = 150; } // Spawn effects - if (npc.ai[0] == -1f) + if (NPC.ai[0] == -1f) { - // Avoid cheap bullshit - npc.damage = 0; + // Disable contact damage while spawning + NPC.damage = 0; // Velocity - npc.velocity *= 0.98f; + NPC.velocity *= 0.98f; // Direction - int faceDirection = Math.Sign(player.Center.X - npc.Center.X); + int faceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (faceDirection != 0) { - npc.direction = faceDirection; - npc.spriteDirection = -npc.direction; + NPC.direction = faceDirection; + NPC.spriteDirection = -NPC.direction; } // Alpha - if (npc.ai[2] > 20f) + if (NPC.ai[2] > 20f) { - npc.velocity.Y = -2f; + NPC.velocity.Y = -2f; - npc.alpha -= 5; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - if (npc.alpha < 0) - npc.alpha = 0; - if (npc.alpha > 150) - npc.alpha = 150; + NPC.alpha -= 5; + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.alpha += 15; + if (NPC.alpha < 0) + NPC.alpha = 0; + if (NPC.alpha > 150) + NPC.alpha = 150; } // Spawn dust and play sound - if (npc.ai[2] == sharknadoPhaseTimer - 30) + if (NPC.ai[2] == sharknadoPhaseTimer - 30) { int dustAmt = 36; for (int i = 0; i < dustAmt; i++) { - Vector2 dust = (Vector2.Normalize(npc.velocity) * new Vector2(npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt) + npc.Center; - Vector2 sharknadoDustDirection = dust - npc.Center; + Vector2 dust = (Vector2.Normalize(NPC.velocity) * new Vector2(NPC.width / 2f, NPC.height) * 0.75f * 0.5f).RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt) + NPC.Center; + Vector2 sharknadoDustDirection = dust - NPC.Center; int sharknadoDust = Dust.NewDust(dust + sharknadoDustDirection, 0, 0, DustID.DungeonWater, sharknadoDustDirection.X * 2f, sharknadoDustDirection.Y * 2f, 100, default, 1.4f); Main.dust[sharknadoDust].noGravity = true; Main.dust[sharknadoDust].noLight = true; Main.dust[sharknadoDust].velocity = Vector2.Normalize(sharknadoDustDirection) * 3f; } - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); + SoundEngine.PlaySound(SoundID.Zombie20, NPC.Center); } - npc.ai[2] += 1f; - if (npc.ai[2] >= spawnEffectPhaseTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= spawnEffectPhaseTimer) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } } // Phase 1 - else if (npc.ai[0] == 0f && !player.dead) + else if (NPC.ai[0] == 0f && !player.dead) { - // Avoid cheap bullshit - npc.damage = 0; - // Velocity - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((npc.Center - player.Center).X); + if (NPC.ai[1] == 0f) + NPC.ai[1] = 300 * Math.Sign((NPC.Center - player.Center).X); - Vector2 idlePhaseDirection = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(idlePhaseDirection, idlePhaseAcceleration); + Vector2 idlePhaseDirection = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - NPC.Center - NPC.velocity) * idlePhaseVelocity; + NPC.SimpleFlyMovement(idlePhaseDirection, idlePhaseAcceleration); // Rotation and direction - int playerFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + int playerFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (playerFaceDirection != 0) { - if (npc.ai[2] == 0f && playerFaceDirection != npc.direction) - npc.rotation += MathHelper.Pi; + if (NPC.ai[2] == 0f && playerFaceDirection != NPC.direction) + NPC.rotation += MathHelper.Pi; - npc.direction = playerFaceDirection; + NPC.direction = playerFaceDirection; - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } // Phase switch - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer || CalamityWorld.LegendaryMode) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= idlePhaseTimer || Main.zenithWorld) { int attackPicker = 0; - switch ((int)npc.ai[3]) + switch ((int)NPC.ai[3]) { case 0: case 1: @@ -371,11 +355,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses attackPicker = 1; break; case 10: - npc.ai[3] = 1f; + NPC.ai[3] = 1f; attackPicker = 2; break; case 11: - npc.ai[3] = 0f; + NPC.ai[3] = 0f; attackPicker = 3; break; } @@ -389,237 +373,222 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set velocity for charge if (attackPicker == 1) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; // Velocity - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); // Direction if (playerFaceDirection != 0) { - npc.direction = playerFaceDirection; + NPC.direction = playerFaceDirection; - if (npc.spriteDirection == 1) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } } // Bubbles else if (attackPicker == 2) { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; } // Spawn sharknadoes else if (attackPicker == 3) { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; if (enrage) - npc.ai[2] = sharknadoPhaseTimer - 40; + NPC.ai[2] = sharknadoPhaseTimer - 40; else if (death) - npc.ai[2] = sharknadoPhaseTimer - 60; + NPC.ai[2] = sharknadoPhaseTimer - 40; } // Go to phase 2 else if (attackPicker == 4) { - npc.ai[0] = 4f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; } - npc.netUpdate = true; + NPC.netUpdate = true; } } // Charge - else if (npc.ai[0] == 1f) + else if (NPC.ai[0] == 1f) { - // Set damage - npc.damage = setDamage; - // Accelerate - npc.velocity *= 1.01f; + NPC.velocity *= 1.01f; // Spawn dust int chargeDustAmt = 7; for (int j = 0; j < chargeDustAmt; j++) { - Vector2 arg_E1C_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((j - (chargeDustAmt / 2 - 1)) * MathHelper.Pi / chargeDustAmt) + npc.Center; + Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f).RotatedBy((j - (chargeDustAmt / 2 - 1)) * MathHelper.Pi / chargeDustAmt) + NPC.Center; Vector2 chargeDustDirection = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int chargeDust = Dust.NewDust(arg_E1C_0 + chargeDustDirection, 0, 0, DustID.DungeonWater, chargeDustDirection.X * 2f, chargeDustDirection.Y * 2f, 100, default, 1.4f); Main.dust[chargeDust].noGravity = true; Main.dust[chargeDust].noLight = true; Main.dust[chargeDust].velocity /= 4f; - Main.dust[chargeDust].velocity -= npc.velocity; + Main.dust[chargeDust].velocity -= NPC.velocity; } - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= chargeTime) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] += 2f; + NPC.netUpdate = true; } } // Bubble belch - else if (npc.ai[0] == 2f) + else if (NPC.ai[0] == 2f) { - // Avoid cheap bullshit - npc.damage = 0; - // Velocity - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((npc.Center - player.Center).X); + if (NPC.ai[1] == 0f) + NPC.ai[1] = 300 * Math.Sign((NPC.Center - player.Center).X); - Vector2 bubbleAttackDirection = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * bubbleBelchPhaseVelocity; - npc.SimpleFlyMovement(bubbleAttackDirection, bubbleBelchPhaseAcceleration); + Vector2 bubbleAttackDirection = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - NPC.Center - NPC.velocity) * bubbleBelchPhaseVelocity; + NPC.SimpleFlyMovement(bubbleAttackDirection, bubbleBelchPhaseAcceleration); // Play sounds and spawn bubbles - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); + if (NPC.ai[2] == 0f) + SoundEngine.PlaySound(SoundID.Zombie20, NPC.Center); - if (npc.ai[2] % bubbleBelchPhaseDivisor == 0f) + if (NPC.ai[2] % bubbleBelchPhaseDivisor == 0f) { - SoundEngine.PlaySound(SoundID.NPCDeath19, npc.Center); + SoundEngine.PlaySound(SoundID.NPCDeath19, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 bubbleSpawnDirection = Vector2.Normalize(player.Center - npc.Center) * (npc.width + 20) / 2f + npc.Center; - NPC.NewNPC(npc.GetSource_FromAI(), (int)bubbleSpawnDirection.X, (int)bubbleSpawnDirection.Y + 45, NPCID.DetonatingBubble); + Vector2 bubbleSpawnDirection = Vector2.Normalize(player.Center - NPC.Center) * (NPC.width + 20) / 2f + NPC.Center; + NPC.NewNPC(NPC.GetSource_FromAI(), (int)bubbleSpawnDirection.X, (int)bubbleSpawnDirection.Y + 45, NPCID.DetonatingBubble); } } // Direction - int bubbleSpriteFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + int bubbleSpriteFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (bubbleSpriteFaceDirection != 0) { - npc.direction = bubbleSpriteFaceDirection; - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.direction = bubbleSpriteFaceDirection; + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; + NPC.spriteDirection = -NPC.direction; } - npc.ai[2] += 1f; - if (npc.ai[2] >= bubbleBelchPhaseTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= bubbleBelchPhaseTimer) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } } // Sharknado spawn - else if (npc.ai[0] == 3f) + else if (NPC.ai[0] == 3f) { - // Avoid cheap bullshit - npc.damage = 0; - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); // Play sound and spawn sharknadoes - if (npc.ai[2] == (sharknadoPhaseTimer - 30)) - SoundEngine.PlaySound(SoundID.Zombie9, npc.Center); + if (NPC.ai[2] == (sharknadoPhaseTimer - 30)) + SoundEngine.PlaySound(SoundID.Zombie9, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == sharknadoPhaseTimer - 30) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == sharknadoPhaseTimer - 30) { - Vector2 sharknadoSpawnerDirection = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + npc.Center; + Vector2 sharknadoSpawnerDirection = NPC.rotation.ToRotationVector2() * (Vector2.UnitX * NPC.direction) * (NPC.width + 20) / 2f + NPC.Center; bool normal = Main.rand.NextBool(); float velocityY = normal ? 8f : -4f; float ai1 = normal ? 0f : -1f; - Projectile.NewProjectile(npc.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); - Projectile.NewProjectile(npc.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, -(float)npc.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, NPC.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, -(float)NPC.direction * 3, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); velocityY = normal ? -4f : 8f; ai1 = normal ? -1f : 0f; - Projectile.NewProjectile(npc.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, 0f, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), sharknadoSpawnerDirection.X, sharknadoSpawnerDirection.Y, 0f, velocityY, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, ai1); } - npc.ai[2] += 1f; - if (npc.ai[2] >= sharknadoPhaseTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= sharknadoPhaseTimer) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } } // Transition to phase 2 - else if (npc.ai[0] == 4f) + else if (NPC.ai[0] == 4f) { - // Avoid cheap bullshit - npc.damage = 0; - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); // Sound - if (npc.ai[2] == phaseTransitionTimer - 60) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); + if (NPC.ai[2] == phaseTransitionTimer - 60) + SoundEngine.PlaySound(SoundID.Zombie20, NPC.Center); - npc.ai[2] += 1f; - if (npc.ai[2] >= phaseTransitionTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= phaseTransitionTimer) { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; } } // Phase 2 - else if (npc.ai[0] == 5f && !player.dead) + else if (NPC.ai[0] == 5f && !player.dead) { - // Avoid cheap bullshit - npc.damage = 0; - // Velocity - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((npc.Center - player.Center).X); + if (NPC.ai[1] == 0f) + NPC.ai[1] = 300 * Math.Sign((NPC.Center - player.Center).X); - Vector2 phase2IdleDirection = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(phase2IdleDirection, idlePhaseAcceleration); + Vector2 phase2IdleDirection = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - NPC.Center - NPC.velocity) * idlePhaseVelocity; + NPC.SimpleFlyMovement(phase2IdleDirection, idlePhaseAcceleration); // Direction and rotation - int phase2SpriteFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + int phase2SpriteFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (phase2SpriteFaceDirection != 0) { - if (npc.ai[2] == 0f && phase2SpriteFaceDirection != npc.direction) - npc.rotation += MathHelper.Pi; + if (NPC.ai[2] == 0f && phase2SpriteFaceDirection != NPC.direction) + NPC.rotation += MathHelper.Pi; - npc.direction = phase2SpriteFaceDirection; + NPC.direction = phase2SpriteFaceDirection; - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } // Phase switch - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer || CalamityWorld.LegendaryMode) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= idlePhaseTimer || Main.zenithWorld) { int phase2AttackPicker = 0; - switch ((int)npc.ai[3]) + switch ((int)NPC.ai[3]) { case 0: case 1: @@ -630,11 +599,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses phase2AttackPicker = 1; break; case 6: - npc.ai[3] = 1f; + NPC.ai[3] = 1f; phase2AttackPicker = 2; break; case 7: - npc.ai[3] = 0f; + NPC.ai[3] = 0f; phase2AttackPicker = 3; break; } @@ -648,23 +617,23 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set velocity for charge if (phase2AttackPicker == 1) { - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); // Direction if (phase2SpriteFaceDirection != 0) { - npc.direction = phase2SpriteFaceDirection; + NPC.direction = phase2SpriteFaceDirection; - if (npc.spriteDirection == 1) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } } @@ -672,243 +641,228 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (phase2AttackPicker == 2) { // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * bubbleSpinPhaseVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * bubbleSpinPhaseVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); // Direction if (phase2SpriteFaceDirection != 0) { - npc.direction = phase2SpriteFaceDirection; + NPC.direction = phase2SpriteFaceDirection; - if (npc.spriteDirection == 1) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } - npc.ai[0] = 7f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; } // Spawn cthulhunado else if (phase2AttackPicker == 3) { - npc.ai[0] = 8f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 8f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; } // Go to next phase else if (phase2AttackPicker == 4) { - npc.ai[0] = 9f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 9f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; } - npc.netUpdate = true; + NPC.netUpdate = true; } } // Charge - else if (npc.ai[0] == 6f) + else if (NPC.ai[0] == 6f) { - // Set damage - npc.damage = setDamage; - // Accelerate - npc.velocity *= 1.01f; + NPC.velocity *= 1.01f; // Spawn dust int phase2ChargeDustAmt = 7; for (int k = 0; k < phase2ChargeDustAmt; k++) { - Vector2 arg_1A97_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((k - (phase2ChargeDustAmt / 2 - 1)) * MathHelper.Pi / phase2ChargeDustAmt) + npc.Center; + Vector2 arg_1A97_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f).RotatedBy((k - (phase2ChargeDustAmt / 2 - 1)) * MathHelper.Pi / phase2ChargeDustAmt) + NPC.Center; Vector2 phase2ChargeDustDirection = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int phase2ChargeDust = Dust.NewDust(arg_1A97_0 + phase2ChargeDustDirection, 0, 0, DustID.DungeonWater, phase2ChargeDustDirection.X * 2f, phase2ChargeDustDirection.Y * 2f, 100, default, 1.4f); Main.dust[phase2ChargeDust].noGravity = true; Main.dust[phase2ChargeDust].noLight = true; Main.dust[phase2ChargeDust].velocity /= 4f; - Main.dust[phase2ChargeDust].velocity -= npc.velocity; + Main.dust[phase2ChargeDust].velocity -= NPC.velocity; } - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= chargeTime) { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.netUpdate = true; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] += 2f; + NPC.netUpdate = true; } } // Bubble spin - else if (npc.ai[0] == 7f) + else if (NPC.ai[0] == 7f) { - // Set damage - npc.damage = 0; - // Play sounds and spawn bubbles - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); + if (NPC.ai[2] == 0f) + SoundEngine.PlaySound(SoundID.Zombie20, NPC.Center); - if (npc.ai[2] % bubbleSpinPhaseDivisor == 0f) + if (NPC.ai[2] % bubbleSpinPhaseDivisor == 0f) { - SoundEngine.PlaySound(SoundID.NPCDeath19, npc.Center); + SoundEngine.PlaySound(SoundID.NPCDeath19, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 phase2BubbleSharkronDirection = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + npc.Center; - int phase2Bubbles = NPC.NewNPC(npc.GetSource_FromAI(), (int)phase2BubbleSharkronDirection.X, (int)phase2BubbleSharkronDirection.Y + 45, NPCID.DetonatingBubble); - Main.npc[phase2Bubbles].target = npc.target; - Main.npc[phase2Bubbles].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * npc.direction) * bubbleSpinBubbleVelocity * (CalamityWorld.LegendaryMode ? (Main.rand.NextFloat() + 0.5f) : 1f); + Vector2 phase2BubbleSharkronDirection = Vector2.Normalize(NPC.velocity) * (NPC.width + 20) / 2f + NPC.Center; + int phase2Bubbles = NPC.NewNPC(NPC.GetSource_FromAI(), (int)phase2BubbleSharkronDirection.X, (int)phase2BubbleSharkronDirection.Y + 45, NPCID.DetonatingBubble); + Main.npc[phase2Bubbles].target = NPC.target; + Main.npc[phase2Bubbles].velocity = Vector2.Normalize(NPC.velocity).RotatedBy(MathHelper.PiOver2 * NPC.direction) * bubbleSpinBubbleVelocity * (Main.getGoodWorld ? (Main.rand.NextFloat() + 0.5f) : 1f); Main.npc[phase2Bubbles].netUpdate = true; Main.npc[phase2Bubbles].ai[3] = Main.rand.Next(80, 121) / 100f; - if (npc.ai[2] % (bubbleSpinPhaseDivisor * 5) == 0f) + if (NPC.ai[2] % (bubbleSpinPhaseDivisor * 5) == 0f) { - int phase2BubbleSharkrons = NPC.NewNPC(npc.GetSource_FromAI(), (int)phase2BubbleSharkronDirection.X, (int)phase2BubbleSharkronDirection.Y + 45, NPCID.Sharkron2); + int phase2BubbleSharkrons = NPC.NewNPC(NPC.GetSource_FromAI(), (int)phase2BubbleSharkronDirection.X, (int)phase2BubbleSharkronDirection.Y + 45, NPCID.Sharkron2); Main.npc[phase2BubbleSharkrons].ai[1] = 89f; } } } // Velocity and rotation - npc.velocity = npc.velocity.RotatedBy(-(double)bubbleSpinPhaseRotation * (float)npc.direction); - npc.rotation -= bubbleSpinPhaseRotation * npc.direction; + NPC.velocity = NPC.velocity.RotatedBy(-(double)bubbleSpinPhaseRotation * (float)NPC.direction); + NPC.rotation -= bubbleSpinPhaseRotation * NPC.direction; - npc.ai[2] += 1f; - if (npc.ai[2] >= bubbleSpinPhaseTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= bubbleSpinPhaseTimer) { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } } // Spawn cthulhunado - else if (npc.ai[0] == 8f) + else if (NPC.ai[0] == 8f) { - // Avoid cheap bullshit - npc.damage = 0; - // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); // Play sound and spawn cthulhunado - if (npc.ai[2] == sharknadoPhaseTimer - 30) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); + if (NPC.ai[2] == sharknadoPhaseTimer - 30) + SoundEngine.PlaySound(SoundID.Zombie20, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == sharknadoPhaseTimer - 30) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, Vector2.Zero, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, npc.target + 1, (enrage || death) ? 1 : 0); + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == sharknadoPhaseTimer - 30) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, NPC.target + 1, (enrage || death) ? 1 : 0); - npc.ai[2] += 1f; - if (npc.ai[2] >= sharknadoPhaseTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= sharknadoPhaseTimer) { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } } // Transition to phase 3 - else if (npc.ai[0] == 9f) + else if (NPC.ai[0] == 9f) { - // Avoid cheap bullshit - npc.damage = 0; - // Alpha adjustments - if (npc.ai[2] < phaseTransitionTimer - 90) + if (NPC.ai[2] < phaseTransitionTimer - 90) { - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.alpha += 15; else - npc.alpha -= 15; + NPC.alpha -= 15; - if (npc.alpha < 0) - npc.alpha = 0; - if (npc.alpha > 150) - npc.alpha = 150; + if (NPC.alpha < 0) + NPC.alpha = 0; + if (NPC.alpha > 150) + NPC.alpha = 150; } - else if (npc.alpha < 255) + else if (NPC.alpha < 255) { - npc.alpha += 4; - if (npc.alpha > 255) - npc.alpha = 255; + NPC.alpha += 4; + if (NPC.alpha > 255) + NPC.alpha = 255; } // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == phaseTransitionTimer - 60) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); + if (NPC.ai[2] == phaseTransitionTimer - 60) + SoundEngine.PlaySound(SoundID.Zombie20, NPC.Center); - npc.ai[2] += 1f; - if (npc.ai[2] >= phaseTransitionTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= phaseTransitionTimer) { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; } } // Phase 3 - else if (npc.ai[0] == 10f && !player.dead) + else if (NPC.ai[0] == 10f && !player.dead) { - // Avoid cheap bullshit - npc.damage = 0; - // Alpha - if (npc.alpha < 255) + if (NPC.alpha < 255) { - npc.alpha += 25; - if (npc.alpha > 255) - npc.alpha = 255; + NPC.alpha += 25; + if (NPC.alpha > 255) + NPC.alpha = 255; } // Teleport location - if (npc.ai[1] == 0f) - npc.ai[1] = 360 * Math.Sign((npc.Center - player.Center).X); + if (NPC.ai[1] == 0f) + NPC.ai[1] = 360 * Math.Sign((NPC.Center - player.Center).X); - Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - npc.Center - npc.velocity) * idlePhaseVelocity; - npc.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); + Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - NPC.Center - NPC.velocity) * idlePhaseVelocity; + NPC.SimpleFlyMovement(desiredVelocity, idlePhaseAcceleration); // Rotation and direction - int phase3SpriteFaceDirection = Math.Sign(player.Center.X - npc.Center.X); + int phase3SpriteFaceDirection = Math.Sign(player.Center.X - NPC.Center.X); if (phase3SpriteFaceDirection != 0) { - if (npc.ai[2] == 0f && phase3SpriteFaceDirection != npc.direction) + if (NPC.ai[2] == 0f && phase3SpriteFaceDirection != NPC.direction) { - npc.rotation += MathHelper.Pi; - for (int l = 0; l < npc.oldPos.Length; l++) - npc.oldPos[l] = Vector2.Zero; + NPC.rotation += MathHelper.Pi; + for (int l = 0; l < NPC.oldPos.Length; l++) + NPC.oldPos[l] = Vector2.Zero; } - npc.direction = phase3SpriteFaceDirection; + NPC.direction = phase3SpriteFaceDirection; - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } // Phase switch - npc.ai[2] += 1f; - if (npc.ai[2] >= idlePhaseTimer || CalamityWorld.LegendaryMode) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= idlePhaseTimer || Main.zenithWorld) { int phase3AttackPicker = 0; if (phase4) { - switch ((int)npc.ai[3]) + switch ((int)NPC.ai[3]) { case 0: case 1: @@ -930,7 +884,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } else { - switch ((int)npc.ai[3]) + switch ((int)NPC.ai[3]) { case 0: case 2: @@ -948,1272 +902,272 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - // Go back to normalcy after dropping below 90% HP - if (!masterModeSurprise && !phase3) - phase3AttackPicker = 3; - // Set velocity for charge if (phase3AttackPicker == 1) { - npc.ai[0] = 11f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 11f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; // Velocity and rotation - npc.velocity = Vector2.Normalize(player.Center + (bossRush && phase4 ? player.velocity * 20f : Vector2.Zero) - npc.Center) * chargeVelocity; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeVelocity; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); // Direction if (phase3SpriteFaceDirection != 0) { - npc.direction = phase3SpriteFaceDirection; + NPC.direction = phase3SpriteFaceDirection; - if (npc.spriteDirection == 1) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection == 1) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } } // Pause else if (phase3AttackPicker == 2) { - npc.ai[0] = 12f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 12f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; } // Go to next phase else if (phase3AttackPicker == 3) { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = -1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; } - npc.netUpdate = true; + NPC.netUpdate = true; } } // Charge - else if (npc.ai[0] == 11f) + else if (NPC.ai[0] == 11f) { - // Set damage - npc.damage = setDamage; - // Accelerate - npc.velocity *= 1.01f; + NPC.velocity *= 1.01f; // Alpha - npc.alpha -= 25; - if (npc.alpha < 0) - npc.alpha = 0; + NPC.alpha -= 25; + if (NPC.alpha < 0) + NPC.alpha = 0; // Spawn dust int phase3ChargeDustAmt = 7; for (int m = 0; m < phase3ChargeDustAmt; m++) { - Vector2 arg_2444_0 = (Vector2.Normalize(npc.velocity) * new Vector2((npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((m - (phase3ChargeDustAmt / 2 - 1)) * MathHelper.Pi / phase3ChargeDustAmt) + npc.Center; + Vector2 arg_2444_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f).RotatedBy((m - (phase3ChargeDustAmt / 2 - 1)) * MathHelper.Pi / phase3ChargeDustAmt) + NPC.Center; Vector2 phase3ChargeDustDirection = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int phase3ChargeDust = Dust.NewDust(arg_2444_0 + phase3ChargeDustDirection, 0, 0, DustID.DungeonWater, phase3ChargeDustDirection.X * 2f, phase3ChargeDustDirection.Y * 2f, 100, default, 1.4f); Main.dust[phase3ChargeDust].noGravity = true; Main.dust[phase3ChargeDust].noLight = true; Main.dust[phase3ChargeDust].velocity /= 4f; - Main.dust[phase3ChargeDust].velocity -= npc.velocity; + Main.dust[phase3ChargeDust].velocity -= NPC.velocity; } - // Spawn bubbles during charge in Master Mode (these bubbles have special behavior that makes them float upward, doing no damage, before returning to their normal behavior) - if (death && phase4) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= chargeTime) { - if (npc.ai[2] % (bubbleBelchPhaseDivisor * 2) == 0f) - { - SoundEngine.PlaySound(SoundID.NPCDeath19, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 bubbleSpawnDirection = Vector2.Normalize(player.Center - npc.Center) * (npc.width + 20) / 2f + npc.Center; - NPC.NewNPC(npc.GetSource_FromAI(), (int)bubbleSpawnDirection.X, (int)bubbleSpawnDirection.Y + 45, NPCID.DetonatingBubble, 0, 0f, -60f); - } - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= chargeTime) - { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; if (!phase4 || !death) - npc.ai[3] += 1f; + NPC.ai[3] += 1f; - npc.netUpdate = true; + NPC.netUpdate = true; } } // Pause before teleport - else if (npc.ai[0] == 12f) + else if (NPC.ai[0] == 12f) { - // Avoid cheap bullshit - npc.damage = 0; + // Disable contact damage during the teleporting phase + NPC.damage = 0; // Alpha - if (npc.alpha < 255) + if (NPC.alpha < 255) { - npc.alpha += 17; - if (npc.alpha > 255) - npc.alpha = 255; + NPC.alpha += 17; + if (NPC.alpha > 255) + NPC.alpha = 255; } // Velocity - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + NPC.velocity *= 0.98f; + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, 0f, 0.02f); // Play sound - if (npc.ai[2] == teleportPhaseTimer / 2) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); + if (NPC.ai[2] == teleportPhaseTimer / 2) + SoundEngine.PlaySound(SoundID.Zombie20, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == teleportPhaseTimer / 2) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == teleportPhaseTimer / 2) { // Teleport location - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((npc.Center - player.Center).X); + if (NPC.ai[1] == 0f) + NPC.ai[1] = 300 * Math.Sign((NPC.Center - player.Center).X); // Rotation and direction - Vector2 center = player.Center + new Vector2(-npc.ai[1], -200f); - npc.Center = center; - int phase3PlayerDirection = Math.Sign(player.Center.X - npc.Center.X); + Vector2 center = player.Center + new Vector2(-NPC.ai[1], -200f); + NPC.Center = center; + int phase3PlayerDirection = Math.Sign(player.Center.X - NPC.Center.X); if (phase3PlayerDirection != 0) { - if (npc.ai[2] == 0f && phase3PlayerDirection != npc.direction) + if (NPC.ai[2] == 0f && phase3PlayerDirection != NPC.direction) { - npc.rotation += MathHelper.Pi; - for (int n = 0; n < npc.oldPos.Length; n++) - npc.oldPos[n] = Vector2.Zero; + NPC.rotation += MathHelper.Pi; + for (int n = 0; n < NPC.oldPos.Length; n++) + NPC.oldPos[n] = Vector2.Zero; } - npc.direction = phase3PlayerDirection; + NPC.direction = phase3PlayerDirection; - if (npc.spriteDirection != -npc.direction) - npc.rotation += MathHelper.Pi; + if (NPC.spriteDirection != -NPC.direction) + NPC.rotation += MathHelper.Pi; - npc.spriteDirection = -npc.direction; + NPC.spriteDirection = -NPC.direction; } } - npc.ai[2] += 1f; - if (npc.ai[2] >= teleportPhaseTimer) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= teleportPhaseTimer) { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; + NPC.ai[0] = 10f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; - npc.ai[3] += 1f; - if (npc.ai[3] >= 9f) - npc.ai[3] = 0f; + NPC.ai[3] += 1f; + if (NPC.ai[3] >= 9f) + NPC.ai[3] = 0f; - npc.netUpdate = true; + NPC.netUpdate = true; } } return false; } - public static bool BuffedDetonatingBubbleAI(NPC npc, Mod mod) + public class DetonatingBubbleAI : VanillaAIOverride { - bool driftUpward = npc.ai[1] < 0f; - npc.damage = driftUpward ? 0 : npc.defDamage; - - if (driftUpward) + public override bool AI(Mod mod) { - npc.ai[1] += 1f; + bool driftUpward = NPC.ai[1] < 0f; + NPC.damage = driftUpward ? 0 : NPC.defDamage; - if (npc.velocity.Y > -2f) - npc.velocity.Y -= 0.04f; - - return false; - } - - if (npc.target == Main.maxPlayers) - { - CalamityUtils.CalamityTargeting(npc, default); - npc.ai[3] = (float)Main.rand.Next(100, 151) / 100f; - float startingVelocity = (float)Main.rand.Next(250, 351) / 15f; - npc.velocity = (Main.player[npc.target].Center - npc.Center + new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101))).SafeNormalize(Vector2.UnitY) * startingVelocity; - npc.netUpdate = true; - } - - bool pop = npc.ai[0] == 1f; - - Vector2 velocityVector = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - float inertia = 30f; - float velocity = 23f; - npc.velocity = (npc.velocity * inertia + velocityVector * velocity) / (inertia + 1f); - - npc.scale = npc.ai[3]; - - npc.alpha -= 30; - if (npc.alpha < 50) - npc.alpha = 50; - npc.alpha = 50; - - float inertia2 = inertia + 10f; - npc.velocity.X = (npc.velocity.X * inertia2 + (float)Main.rand.Next(-10, 11) * 0.1f) / (inertia2 + 1f); - npc.velocity.Y = (npc.velocity.Y * inertia2 + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / (inertia2 + 1f); - if (npc.velocity.Y > 0f) - npc.velocity.Y -= 0.04f; - - // Push Bubbles away from each other. - float spreadOutStrength = (CalamityWorld.death || BossRushEvent.BossRushActive) ? -0.08f : -0.06f; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type) + if (driftUpward) { - Vector2 otherBubbleDist = Main.npc[i].Center - npc.Center; - if (otherBubbleDist.Length() < (npc.width + npc.height)) - { - otherBubbleDist = otherBubbleDist.SafeNormalize(Vector2.UnitY); - otherBubbleDist *= spreadOutStrength; - npc.velocity += otherBubbleDist; - Main.npc[i].velocity -= otherBubbleDist; - } - } - } + NPC.ai[1] += 1f; - if (npc.ai[0] == 0f) - { - int size = 40; - Rectangle rect = npc.getRect(); - rect.X -= size + npc.width / 2; - rect.Y -= size + npc.height / 2; - rect.Width += size * 2; - rect.Height += size * 2; - for (int i = 0; i < Main.maxPlayers; i++) - { - Player player = Main.player[i]; - if (player.active && !player.dead && rect.Intersects(player.getRect())) - { - npc.ai[0] = 1f; - npc.ai[1] = 4f; - npc.netUpdate = true; - break; - } - } - } + if (NPC.velocity.Y > -2f) + NPC.velocity.Y -= 0.04f; - if (npc.ai[0] == 0f) - { - npc.ai[1] += 1f; - float timeBeforePopping = 300f; - if (npc.ai[1] >= timeBeforePopping) - { - npc.ai[0] = 1f; - npc.ai[1] = 4f; - } - } - - if (pop) - { - npc.ai[1] -= 1f; - if (npc.ai[1] <= 0f) - { - npc.life = 0; - npc.HitEffect(); - npc.active = false; return false; } - } - if (pop) - { - npc.position = npc.Center; - npc.width = npc.height = 100; - npc.position = new Vector2(npc.position.X - (float)(npc.width / 2), npc.position.Y - (float)(npc.height / 2)); - npc.EncourageDespawn(3); - } - - return false; - } - - public static bool VanillaDukeFishronAI(NPC npc, Mod mod) - { - bool expertMode = Main.expertMode; - bool masterMode = Main.masterMode; - - double damageScale = expertMode ? 1.2 : 1D; - float phase2LifeRatio = masterMode ? 0.6f : 0.5f; - float phase3LifeRatio = masterMode ? 0.25f : 0.15f; - bool flag = npc.life <= npc.lifeMax * phase2LifeRatio; - bool flag2 = expertMode && npc.life <= npc.lifeMax * phase3LifeRatio; - bool flag3 = npc.ai[0] > 4f; - bool flag4 = npc.ai[0] > 9f; - bool flag5 = npc.ai[3] < 10f; - - int setDamage = npc.defDamage; - if (flag4) - { - setDamage = (int)Math.Round(setDamage * 1.1 * damageScale); - npc.defense = 0; - } - else if (flag3) - { - setDamage = (int)Math.Round(setDamage * 1.2 * damageScale); - npc.defense = (int)Math.Round(npc.defDefense * 0.8); - } - else - npc.defense = npc.defDefense; - - int num2 = (masterMode ? 30 : expertMode ? 40 : 60); - float num3 = (masterMode ? 0.65f : expertMode ? 0.55f : 0.45f); - float num4 = (masterMode ? 9.5f : expertMode ? 8.5f : 7.5f); - if (flag4) - { - num3 = masterMode ? 0.8f : 0.7f; - num4 = masterMode ? 13f : 12f; - num2 = masterMode ? 20 : 30; - } - else if (flag3 && flag5) - { - num3 = (masterMode ? 0.7f : expertMode ? 0.6f : 0.5f); - num4 = (masterMode ? 12f : expertMode ? 10f : 8f); - num2 = (masterMode ? 35 : expertMode ? 40 : 20); - } - else if (flag5 && !flag3 && !flag4) - num2 = masterMode ? 25 : 30; - - int num5 = (masterMode ? 25 : expertMode ? 28 : 30); - float num6 = (masterMode ? 18f : expertMode ? 17f : 16f); - if (flag4) - { - num5 = masterMode ? 20 : 25; - num6 = masterMode ? 29f : 27f; - } - else if (flag5 && flag3) - { - num5 = (masterMode ? 24 : expertMode ? 27 : 30); - if (expertMode) - num6 = masterMode ? 24f : 21f; - } - - int num7 = masterMode ? 40 : 80; - int num8 = masterMode ? 2 : 4; - float num9 = masterMode ? 0.5f : 0.3f; - float num10 = masterMode ? 8f : 5f; - int num11 = masterMode ? 60 : 90; - int num12 = 180; - int num13 = 180; - int num14 = 30; - int num15 = masterMode ? 60 : 120; - int num16 = masterMode ? 2 : 4; - float num17 = masterMode ? 9f : 6f; - float num18 = 20f; - float num19 = MathHelper.TwoPi / (float)(num15 / 2); - int num20 = masterMode ? 50 : 75; - Vector2 center = npc.Center; - Player player = Main.player[npc.target]; - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, center) > 5600f) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - player = Main.player[npc.target]; - npc.netUpdate = true; - } - - if (player.dead || Vector2.Distance(player.Center, center) > 5600f) - { - npc.velocity.Y -= 0.4f; - npc.EncourageDespawn(10); - if (npc.ai[0] > 4f) - npc.ai[0] = 5f; - else - npc.ai[0] = 0f; - - npc.ai[2] = 0f; - } - - bool enrage = player.position.Y < 800f || (double)player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (float)(Main.maxTilesX * 16 - 6400)); - - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && enrage; - - // Increased DR during phase transitions - npc.Calamity().DR = (npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f) ? (BossRushEvent.BossRushActive ? 0.99f : 0.625f) : 0.15f; - npc.Calamity().CurrentlyIncreasingDefenseOrDR = npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f; - - if (enrage) - { - num2 = masterMode ? 5 : 10; - setDamage *= 2; - npc.defense = npc.defDefense * 2; - num6 += (masterMode ? 12f : 6f); - } - - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - npc.alpha = 255; - npc.rotation = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.target == Main.maxPlayers) { - npc.ai[0] = -1f; - npc.netUpdate = true; - } - } - - float num21 = (float)Math.Atan2(player.Center.Y - center.Y, player.Center.X - center.X); - if (npc.spriteDirection == 1) - num21 += (float)Math.PI; - - if (num21 < 0f) - num21 += MathHelper.TwoPi; - - if (num21 > MathHelper.TwoPi) - num21 -= MathHelper.TwoPi; - - if (npc.ai[0] == -1f) - num21 = 0f; - - if (npc.ai[0] == 3f) - num21 = 0f; - - if (npc.ai[0] == 4f) - num21 = 0f; - - if (npc.ai[0] == 8f) - num21 = 0f; - - float num22 = 0.04f; - if (npc.ai[0] == 1f || npc.ai[0] == 6f) - num22 = 0f; - - if (npc.ai[0] == 7f) - num22 = 0f; - - if (npc.ai[0] == 3f) - num22 = 0.01f; - - if (npc.ai[0] == 4f) - num22 = 0.01f; - - if (npc.ai[0] == 8f) - num22 = 0.01f; - - if (npc.rotation < num21) - { - if ((double)(num21 - npc.rotation) > Math.PI) - npc.rotation -= num22; - else - npc.rotation += num22; - } - - if (npc.rotation > num21) - { - if ((double)(npc.rotation - num21) > Math.PI) - npc.rotation += num22; - else - npc.rotation -= num22; - } - - if (npc.rotation > num21 - num22 && npc.rotation < num21 + num22) - npc.rotation = num21; - - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - - if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - - if (npc.rotation > num21 - num22 && npc.rotation < num21 + num22) - npc.rotation = num21; - - if (npc.ai[0] != -1f && npc.ai[0] < 9f) - { - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - else - npc.alpha -= 15; - - if (npc.alpha < 0) - npc.alpha = 0; - - if (npc.alpha > 150) - npc.alpha = 150; - } - - if (npc.ai[0] == -1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.98f; - int num23 = Math.Sign(player.Center.X - center.X); - if (num23 != 0) - { - npc.direction = num23; - npc.spriteDirection = -npc.direction; + CalamityUtils.CalamityTargeting(NPC, default); + NPC.ai[3] = (float)Main.rand.Next(100, 151) / 100f; + float startingVelocity = (float)Main.rand.Next(250, 351) / 15f; + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center + new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101))).SafeNormalize(Vector2.UnitY) * startingVelocity; + NPC.netUpdate = true; } - if (npc.ai[2] > 20f) + bool pop = NPC.ai[0] == 1f; + + Vector2 velocityVector = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); + float inertia = 30f; + float velocity = 20f; + NPC.velocity = (NPC.velocity * inertia + velocityVector * velocity) / (inertia + 1f); + + NPC.scale = NPC.ai[3]; + + NPC.alpha -= 30; + if (NPC.alpha < 50) + NPC.alpha = 50; + NPC.alpha = 50; + + float inertia2 = inertia + 10f; + NPC.velocity.X = (NPC.velocity.X * inertia2 + (float)Main.rand.Next(-10, 11) * 0.1f) / (inertia2 + 1f); + NPC.velocity.Y = (NPC.velocity.Y * inertia2 + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / (inertia2 + 1f); + if (NPC.velocity.Y > 0f) + NPC.velocity.Y -= 0.04f; + + // Push Bubbles away from each other. + float spreadOutStrength = (CalamityWorld.death || BossRushEvent.BossRushActive) ? -0.08f : -0.06f; + for (int i = 0; i < Main.maxNPCs; i++) { - npc.velocity.Y = -2f; - npc.alpha -= 5; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - - if (npc.alpha < 0) - npc.alpha = 0; - - if (npc.alpha > 150) - npc.alpha = 150; - } - - if (npc.ai[2] == (float)(num11 - 30)) - { - int num24 = 36; - for (int i = 0; i < num24; i++) + if (i != NPC.whoAmI && Main.npc[i].active && Main.npc[i].type == NPC.type) { - Vector2 vector = (Vector2.Normalize(npc.velocity) * new Vector2((float)npc.width / 2f, npc.height) * 0.75f * 0.5f).RotatedBy((float)(i - (num24 / 2 - 1)) * MathHelper.TwoPi / (float)num24) + npc.Center; - Vector2 vector2 = vector - npc.Center; - int num25 = Dust.NewDust(vector + vector2, 0, 0, DustID.DungeonWater, vector2.X * 2f, vector2.Y * 2f, 100, default(Color), 1.4f); - Main.dust[num25].noGravity = true; - Main.dust[num25].noLight = true; - Main.dust[num25].velocity = Vector2.Normalize(vector2) * 3f; - } - - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num20) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 0f && !player.dead) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((center - player.Center).X); - - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - center - npc.velocity) * num4; - if (npc.velocity.X < vector3.X) - { - npc.velocity.X += num3; - if (npc.velocity.X < 0f && vector3.X > 0f) - npc.velocity.X += num3; - } - else if (npc.velocity.X > vector3.X) - { - npc.velocity.X -= num3; - if (npc.velocity.X > 0f && vector3.X < 0f) - npc.velocity.X -= num3; - } - - if (npc.velocity.Y < vector3.Y) - { - npc.velocity.Y += num3; - if (npc.velocity.Y < 0f && vector3.Y > 0f) - npc.velocity.Y += num3; - } - else if (npc.velocity.Y > vector3.Y) - { - npc.velocity.Y -= num3; - if (npc.velocity.Y > 0f && vector3.Y < 0f) - npc.velocity.Y -= num3; - } - - int num26 = Math.Sign(player.Center.X - center.X); - if (num26 != 0) - { - if (npc.ai[2] == 0f && num26 != npc.direction) - npc.rotation += (float)Math.PI; - - npc.direction = num26; - if (npc.spriteDirection != -npc.direction) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2) - { - int num27 = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - num27 = 1; - break; - case 10: - npc.ai[3] = 1f; - num27 = 2; - break; - case 11: - npc.ai[3] = 0f; - num27 = 3; - break; - } - - if (enrage && num27 == 2) - num27 = 3; - - if (flag) - num27 = 4; - - switch (num27) - { - case 1: - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.velocity = Vector2.Normalize(player.Center - center) * num6; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (num26 != 0) - { - npc.direction = num26; - if (npc.spriteDirection == 1) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - break; - - case 2: - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - - case 3: - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - if (enrage) - npc.ai[2] = num11 - 40; - break; - - case 4: - npc.ai[0] = 4f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - } - - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 1f) - { - // Set damage - npc.damage = setDamage; - - int num28 = 7; - for (int j = 0; j < num28; j++) - { - Vector2 vector4 = (Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((double)(j - (num28 / 2 - 1)) * Math.PI / (double)(float)num28) + center; - Vector2 vector5 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num29 = Dust.NewDust(vector4 + vector5, 0, 0, DustID.DungeonWater, vector5.X * 2f, vector5.Y * 2f, 100, default(Color), 1.4f); - Main.dust[num29].noGravity = true; - Main.dust[num29].noLight = true; - Main.dust[num29].velocity /= 4f; - Main.dust[num29].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num5) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((center - player.Center).X); - - Vector2 vector6 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - center - npc.velocity) * num10; - if (npc.velocity.X < vector6.X) - { - npc.velocity.X += num9; - if (npc.velocity.X < 0f && vector6.X > 0f) - npc.velocity.X += num9; - } - else if (npc.velocity.X > vector6.X) - { - npc.velocity.X -= num9; - if (npc.velocity.X > 0f && vector6.X < 0f) - npc.velocity.X -= num9; - } - - if (npc.velocity.Y < vector6.Y) - { - npc.velocity.Y += num9; - if (npc.velocity.Y < 0f && vector6.Y > 0f) - npc.velocity.Y += num9; - } - else if (npc.velocity.Y > vector6.Y) - { - npc.velocity.Y -= num9; - if (npc.velocity.Y > 0f && vector6.Y < 0f) - npc.velocity.Y -= num9; - } - - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - - if (npc.ai[2] % (float)num8 == 0f) - { - SoundEngine.PlaySound(SoundID.NPCDeath19, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 vector7 = Vector2.Normalize(player.Center - center) * (npc.width + 20) / 2f + center; - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector7.X, (int)vector7.Y + 45, NPCID.DetonatingBubble); - } - } - - int num30 = Math.Sign(player.Center.X - center.X); - if (num30 != 0) - { - npc.direction = num30; - if (npc.spriteDirection != -npc.direction) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num7) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == (float)(num11 - 30)) - SoundEngine.PlaySound(SoundID.Zombie9, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num11 - 30)) - { - Vector2 vector8 = npc.rotation.ToRotationVector2() * (Vector2.UnitX * npc.direction) * (npc.width + 20) / 2f + center; - Vector2 sharknadoBoltVelocity = new Vector2(npc.direction * 2, masterMode ? 12f : 8f); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector8, sharknadoBoltVelocity, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer); - sharknadoBoltVelocity = new Vector2(npc.direction * -2, masterMode ? 12f : 8f); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector8, sharknadoBoltVelocity, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer); - if (masterMode) - { - sharknadoBoltVelocity = new Vector2(npc.direction * 2, masterMode ? -12f : -8f); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector8, sharknadoBoltVelocity, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, -1f); - sharknadoBoltVelocity = new Vector2(npc.direction * -2, masterMode ? -12f : -8f); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector8, sharknadoBoltVelocity, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 0f, -1f); - } - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num11) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == (float)(num12 - 60)) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num12) - { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 5f && !player.dead) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((center - player.Center).X); - - Vector2 vector9 = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - center - npc.velocity) * num4; - if (npc.velocity.X < vector9.X) - { - npc.velocity.X += num3; - if (npc.velocity.X < 0f && vector9.X > 0f) - npc.velocity.X += num3; - } - else if (npc.velocity.X > vector9.X) - { - npc.velocity.X -= num3; - if (npc.velocity.X > 0f && vector9.X < 0f) - npc.velocity.X -= num3; - } - - if (npc.velocity.Y < vector9.Y) - { - npc.velocity.Y += num3; - if (npc.velocity.Y < 0f && vector9.Y > 0f) - npc.velocity.Y += num3; - } - else if (npc.velocity.Y > vector9.Y) - { - npc.velocity.Y -= num3; - if (npc.velocity.Y > 0f && vector9.Y < 0f) - npc.velocity.Y -= num3; - } - - int num31 = Math.Sign(player.Center.X - center.X); - if (num31 != 0) - { - if (npc.ai[2] == 0f && num31 != npc.direction) - npc.rotation += (float)Math.PI; - - npc.direction = num31; - if (npc.spriteDirection != -npc.direction) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2) - { - int num32 = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - num32 = 1; - break; - case 6: - npc.ai[3] = 1f; - num32 = 2; - break; - case 7: - npc.ai[3] = 0f; - num32 = 3; - break; - } - - if (flag2) - num32 = 4; - - if (enrage && num32 == 2) - num32 = 3; - - switch (num32) - { - case 1: - npc.ai[0] = 6f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.velocity = Vector2.Normalize(player.Center - center) * num6; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (num31 != 0) - { - npc.direction = num31; - if (npc.spriteDirection == 1) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - break; - - case 2: - npc.velocity = Vector2.Normalize(player.Center - center) * num18; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (num31 != 0) - { - npc.direction = num31; - if (npc.spriteDirection == 1) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - npc.ai[0] = 7f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - - case 3: - npc.ai[0] = 8f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - - case 4: - npc.ai[0] = 9f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - } - - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 6f) - { - // Set damage - npc.damage = setDamage; - - int num33 = 7; - for (int k = 0; k < num33; k++) - { - Vector2 vector10 = (Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((double)(k - (num33 / 2 - 1)) * Math.PI / (double)(float)num33) + center; - Vector2 vector11 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num34 = Dust.NewDust(vector10 + vector11, 0, 0, DustID.DungeonWater, vector11.X * 2f, vector11.Y * 2f, 100, default(Color), 1.4f); - Main.dust[num34].noGravity = true; - Main.dust[num34].noLight = true; - Main.dust[num34].velocity /= 4f; - Main.dust[num34].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num5) - { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 2f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 7f) - { - // Set damage - npc.damage = 0; - - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - - if (npc.ai[2] % (float)num16 == 0f) - { - SoundEngine.PlaySound(SoundID.NPCDeath19, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 vector12 = Vector2.Normalize(npc.velocity) * (npc.width + 20) / 2f + center; - int num35 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector12.X, (int)vector12.Y + 45, NPCID.DetonatingBubble); - Main.npc[num35].target = npc.target; - Main.npc[num35].velocity = Vector2.Normalize(npc.velocity).RotatedBy(MathHelper.PiOver2 * (float)npc.direction) * num17; - Main.npc[num35].netUpdate = true; - Main.npc[num35].ai[3] = (float)Main.rand.Next(80, 121) / 100f; - } - } - - npc.velocity = npc.velocity.RotatedBy((0f - num19) * (float)npc.direction); - npc.rotation -= num19 * (float)npc.direction; - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num15) - { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 8f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == (float)(num11 - 30)) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num11 - 30)) - Projectile.NewProjectile(npc.GetSource_FromAI(), center, Vector2.Zero, ProjectileID.SharknadoBolt, 0, 0f, Main.myPlayer, 1f, npc.target + 1, (enrage || masterMode) ? 1 : 0); - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num11) - { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 9f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.ai[2] < (float)(num13 - 90)) - { - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.alpha += 15; - else - npc.alpha -= 15; - - if (npc.alpha < 0) - npc.alpha = 0; - - if (npc.alpha > 150) - npc.alpha = 150; - } - else if (npc.alpha < 255) - { - npc.alpha += 4; - if (npc.alpha > 255) - npc.alpha = 255; - } - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == (float)(num13 - 60)) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num13) - { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 10f && !player.dead) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.alpha < 255) - { - npc.alpha += 25; - if (npc.alpha > 255) - npc.alpha = 255; - } - - if (npc.ai[1] == 0f) - npc.ai[1] = 360 * Math.Sign((center - player.Center).X); - - Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(npc.ai[1], -200f) - center - npc.velocity) * num4; - npc.SimpleFlyMovement(desiredVelocity, num3); - int num36 = Math.Sign(player.Center.X - center.X); - if (num36 != 0) - { - if (npc.ai[2] == 0f && num36 != npc.direction) - { - npc.rotation += (float)Math.PI; - for (int l = 0; l < npc.oldPos.Length; l++) - npc.oldPos[l] = Vector2.Zero; - } - - npc.direction = num36; - if (npc.spriteDirection != -npc.direction) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num2) - { - int num37 = 0; - switch ((int)npc.ai[3]) - { - case 0: - case 2: - case 3: - case 5: - case 6: - case 7: - num37 = 1; - break; - case 1: - case 4: - case 8: - num37 = 2; - break; - } - - switch (num37) - { - case 1: - npc.ai[0] = 11f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.velocity = Vector2.Normalize(player.Center - center) * num6; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (num36 != 0) - { - npc.direction = num36; - if (npc.spriteDirection == 1) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; - } - break; - - case 2: - npc.ai[0] = 12f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - - case 3: - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - break; - } - - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 11f) - { - // Set damage - npc.damage = setDamage; - - npc.alpha -= 25; - if (npc.alpha < 0) - npc.alpha = 0; - - int num38 = 7; - for (int m = 0; m < num38; m++) - { - Vector2 vector13 = (Vector2.Normalize(npc.velocity) * new Vector2((float)(npc.width + 50) / 2f, npc.height) * 0.75f).RotatedBy((double)(m - (num38 / 2 - 1)) * Math.PI / (double)(float)num38) + center; - Vector2 vector14 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num39 = Dust.NewDust(vector13 + vector14, 0, 0, DustID.DungeonWater, vector14.X * 2f, vector14.Y * 2f, 100, default(Color), 1.4f); - Main.dust[num39].noGravity = true; - Main.dust[num39].noLight = true; - Main.dust[num39].velocity /= 4f; - Main.dust[num39].velocity -= npc.velocity; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num5) - { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 12f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.alpha < 255) - { - npc.alpha += 17; - if (npc.alpha > 255) - npc.alpha = 255; - } - - npc.velocity *= 0.98f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == (float)(num14 / 2)) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == (float)(num14 / 2)) - { - if (npc.ai[1] == 0f) - npc.ai[1] = 300 * Math.Sign((center - player.Center).X); - - Vector2 vector15 = player.Center + new Vector2(0f - npc.ai[1], -200f); - Vector2 vector17 = (npc.Center = vector15); - center = vector17; - int num40 = Math.Sign(player.Center.X - center.X); - if (num40 != 0) - { - if (npc.ai[2] == 0f && num40 != npc.direction) + Vector2 otherBubbleDist = Main.npc[i].Center - NPC.Center; + if (otherBubbleDist.Length() < (NPC.width + NPC.height)) { - npc.rotation += (float)Math.PI; - for (int n = 0; n < npc.oldPos.Length; n++) - npc.oldPos[n] = Vector2.Zero; + otherBubbleDist = otherBubbleDist.SafeNormalize(Vector2.UnitY); + otherBubbleDist *= spreadOutStrength; + NPC.velocity += otherBubbleDist; + Main.npc[i].velocity -= otherBubbleDist; } - - npc.direction = num40; - if (npc.spriteDirection != -npc.direction) - npc.rotation += (float)Math.PI; - - npc.spriteDirection = -npc.direction; } } - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num14) + if (NPC.ai[0] == 0f) { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; - if (npc.ai[3] >= 9f) - npc.ai[3] = 0f; - - npc.netUpdate = true; + int size = 40; + Rectangle rect = NPC.getRect(); + rect.X -= size + NPC.width / 2; + rect.Y -= size + NPC.height / 2; + rect.Width += size * 2; + rect.Height += size * 2; + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player.active && !player.dead && rect.Intersects(player.getRect())) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 4f; + NPC.netUpdate = true; + break; + } + } } - } - else if (npc.ai[0] == 13f) - { - // Avoid cheap bullshit - npc.damage = 0; - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.Zombie20, npc.Center); - - npc.velocity = npc.velocity.RotatedBy((0f - num19) * (float)npc.direction); - npc.rotation -= num19 * (float)npc.direction; - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num15) + if (NPC.ai[0] == 0f) { - npc.ai[0] = 10f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; - npc.netUpdate = true; + NPC.ai[1] += 1f; + float timeBeforePopping = 300f; + if (NPC.ai[1] >= timeBeforePopping) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 4f; + } } + + if (pop) + { + NPC.ai[1] -= 1f; + if (NPC.ai[1] <= 0f) + { + NPC.life = 0; + NPC.HitEffect(); + NPC.active = false; + return false; + } + } + + if (pop) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = 100; + NPC.position = new Vector2(NPC.position.X - (float)(NPC.width / 2), NPC.position.Y - (float)(NPC.height / 2)); + NPC.EncourageDespawn(3); + } + + return false; } - - // Make him always able to take damage - npc.dontTakeDamage = false; - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs index a246c16b25..71945eabe4 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs @@ -11,51 +11,40 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class EaterOfWorldsAI + public class EaterOfWorldsAI : VanillaAIOverride { - private const int TotalMasterModeWorms = 4; + private const float ProjectileTelegraphDuration = 30f; + private const int TotalDeathModeWorms = 4; public const float DRIncreaseTime = 600f; - public static bool BuffedEaterofWorldsAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Rev+ exclusive + public static float HeadDamageMult = 1.25f; // 60 (buffed from 48) + public static float BodyDamageMult = 1.5f; // 30 (buffed from 20) + public static float TailDamageMult = 1.5f; // 26 (buffed from 17) + public static int FireballDamage = 12; // 48; Applies to both Cursed Flames and (Death) Shadowflame fireballs - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Set contact damage + NPC.damage = (int)Math.Round(NPC.defDamage * (NPC.type == NPCID.EaterofWorldsHead ? HeadDamageMult : NPC.type == NPCID.EaterofWorldsBody ? BodyDamageMult : TailDamageMult)); // Causes it to split far more in death mode - if ((((npc.ai[2] % 2f == 0f && npc.type == NPCID.EaterofWorldsBody) || npc.type == NPCID.EaterofWorldsHead) && death) || CalamityWorld.LegendaryMode) + if ((((NPC.ai[2] % 2f == 0f && NPC.type == NPCID.EaterofWorldsBody) || NPC.type == NPCID.EaterofWorldsHead) && death) || Main.getGoodWorld) { calamityGlobalNPC.DR = 0.5f; - npc.defense = npc.defDefense * 2; + NPC.defense = NPC.defDefense * 2; } - if (CalamityWorld.LegendaryMode && npc.type == NPCID.EaterofWorldsHead) - npc.reflectsProjectiles = true; + if (Main.getGoodWorld && NPC.type == NPCID.EaterofWorldsHead) + NPC.reflectsProjectiles = true; // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - bool enrage = true; - int targetTileX = (int)Main.player[npc.target].Center.X / 16; - int targetTileY = (int)Main.player[npc.target].Center.Y / 16; - - Tile tile = Framing.GetTileSafely(targetTileX, targetTileY); - if (tile.WallType == WallID.EbonstoneUnsafe) - enrage = false; - - float enrageScale = 0f; - if (((npc.position.Y / 16f) < Main.worldSurface && enrage) || bossRush) - { - calamityGlobalNPC.CurrentlyEnraged = !bossRush; - enrageScale += 0.5f; - } - if (!Main.player[npc.target].ZoneCorrupt || bossRush) - { - calamityGlobalNPC.CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); // Total body segments float totalSegments = GetEaterOfWorldsSegmentsCountRevDeath(); @@ -77,7 +66,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Boost velocity by 50% phase bool phase4 = lifeRatio < (death ? 0.5f : 0.2f); - // Go fucking crazy in Master Mode + // Go fucking crazy in Death Mode bool phase5 = lifeRatio < 0.1f && death; bool phase6 = lifeRatio < 0.05f && death; @@ -85,81 +74,77 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { // Vile spit - if (npc.type == NPCID.EaterofWorldsBody) + if (NPC.type == NPCID.EaterofWorldsBody) { - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - npc.localAI[1] += 1f; + if (Collision.CanHitLine(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + NPC.localAI[1] += 1f; else - npc.localAI[1] -= 1f; + NPC.localAI[1] -= 1f; int vileSpitGateValue = (int)MathHelper.Lerp(death ? 45f : 90f, 900f, lifeRatio); if (Main.getGoodWorld) vileSpitGateValue = (int)(vileSpitGateValue * 0.5f); - Vector2 vileSpitShootLocation = npc.Center + npc.velocity; - if (npc.localAI[1] >= vileSpitGateValue) + Vector2 vileSpitShootLocation = NPC.Center + NPC.velocity; + if (NPC.localAI[1] >= vileSpitGateValue) { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - NPC.NewNPC(npc.GetSource_FromAI(), (int)vileSpitShootLocation.X, (int)vileSpitShootLocation.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 1f); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - npc.localAI[1] = 0f; + if (Collision.CanHitLine(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)vileSpitShootLocation.X, (int)vileSpitShootLocation.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 1f); + + NPC.localAI[1] = 0f; } - if (npc.localAI[1] > vileSpitGateValue - 30f) + if (NPC.localAI[1] > vileSpitGateValue - ProjectileTelegraphDuration) { Vector2 dustCenter = vileSpitShootLocation + Main.rand.NextVector2CircularEdge(5f, 5f); - Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, 18, npc.velocity.X * 0.1f, npc.velocity.Y * 0.1f, 80, default, 2f); + Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, DustID.CorruptGibs, NPC.velocity.X * 0.1f, NPC.velocity.Y * 0.1f, 80, default, 2f); dust.noGravity = true; dust.velocity *= 0.3f; } } // Cursed flames (shadowflames in death mode) - else if (npc.type == NPCID.EaterofWorldsHead) + else if (NPC.type == NPCID.EaterofWorldsHead) { if (phase2) { - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - calamityGlobalNPC.newAI[0] += ((npc.justHit && death && calamityGlobalNPC.newAI[0] < 30f) ? 10f : 1f); + float timer = 120f; + float shootBoost = lifeRatio * 90f; + timer += shootBoost; + + float showTelegraphGateValue = timer - ProjectileTelegraphDuration; + + if (Collision.CanHitLine(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + if (NPC.justHit && death && calamityGlobalNPC.newAI[0] < showTelegraphGateValue) + { + calamityGlobalNPC.newAI[0] += 10f; + if (calamityGlobalNPC.newAI[0] > showTelegraphGateValue) + calamityGlobalNPC.newAI[0] = showTelegraphGateValue; + } + else + calamityGlobalNPC.newAI[0] += 1f; + } else calamityGlobalNPC.newAI[0] -= 1f; - float timer = enrageScale > 0f ? 60f : 90f; - float shootBoost = lifeRatio * 60f; - timer += shootBoost; - - if (enrageScale >= 2f) - timer = 60f; - if (calamityGlobalNPC.newAI[0] >= timer) { - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1) && - (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(npc.velocity.ToRotation(), MathHelper.PiOver4) == npc.velocity.ToRotation()) + if (Collision.CanHitLine(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1) && + (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) { calamityGlobalNPC.newAI[0] = 0f; - Vector2 cursedFlameDirection = npc.Center; - float targetXDirection = Main.player[npc.target].Center.X - cursedFlameDirection.X; - float targetYDirection = Main.player[npc.target].Center.Y - cursedFlameDirection.Y; - float projSpeed = 7f + enrageScale * 2f; - float flameTargetDistance = (float)Math.Sqrt(targetXDirection * targetXDirection + targetYDirection * targetYDirection); - flameTargetDistance = projSpeed / flameTargetDistance; - targetXDirection *= flameTargetDistance; - targetYDirection *= flameTargetDistance; - targetYDirection += npc.velocity.Y * 0.5f; - targetXDirection += npc.velocity.X * 0.5f; - cursedFlameDirection.X -= targetXDirection; - cursedFlameDirection.Y -= targetYDirection; - + Vector2 cursedFlameDirection = Utils.DirectionTo(NPC.Center, Main.player[NPC.target].Center) * 7f + (NPC.velocity * 0.5f); int type = (death && phase3) ? ModContent.ProjectileType() : ProjectileID.CursedFlameHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), cursedFlameDirection.X, cursedFlameDirection.Y, targetXDirection, targetYDirection, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.velocity, cursedFlameDirection, type, FireballDamage, 0f, Main.myPlayer); } } - if (calamityGlobalNPC.newAI[0] > timer - 30f) + if (calamityGlobalNPC.newAI[0] > showTelegraphGateValue) { - Vector2 dustCenter = npc.Center + Main.rand.NextVector2CircularEdge(10f, 10f); + Vector2 dustCenter = NPC.Center + Main.rand.NextVector2CircularEdge(10f, 10f); int dustType = (death && phase3) ? DustID.Shadowflame : DustID.CursedTorch; Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, dustType, 0f, 0f, 0, default, 3f); dust.noGravity = true; @@ -170,26 +155,26 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawn - if (Main.player[npc.target].dead) + if (Main.player[NPC.target].dead) { - if (npc.timeLeft > 300) - npc.timeLeft = 300; + if (NPC.timeLeft > 300) + NPC.timeLeft = 300; } // All functions that modify the active worm segments are here. This includes spawning the worm originally and splitting effects. if (Main.netMode != NetmodeID.MultiplayerClient) { // If this segment is a head or a body without a next-segment defined, then it needs to spawn its own next segment. - if ((npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody) && npc.ai[0] == 0f) + if ((NPC.type == NPCID.EaterofWorldsHead || NPC.type == NPCID.EaterofWorldsBody) && NPC.ai[0] == 0f) { - int spawnX = (int)npc.position.X; - int spawnY = (int)npc.position.Y; + int spawnX = (int)NPC.position.X; + int spawnY = (int)NPC.position.Y; // A head sets the length variable (npc.ai[2]) and then sets its next segment to a freshly spawned body. - if (npc.type == NPCID.EaterofWorldsHead) + if (NPC.type == NPCID.EaterofWorldsHead) { // Amount of segments to spawn. - int segmentSpawnAmount = (int)(death ? (totalSegments / TotalMasterModeWorms) : totalSegments); + int segmentSpawnAmount = (int)(death ? (totalSegments / TotalDeathModeWorms) : totalSegments); // Spawn additional worms of reduced length in Master Mode. if (death) @@ -197,10 +182,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 additionalWormSpawnLocation = new Vector2(spawnX, spawnY); int randomXLimit = 80; int randomYLimit = 80; - for (int i = 1; i < TotalMasterModeWorms; i++) + for (int i = 1; i < TotalDeathModeWorms; i++) { additionalWormSpawnLocation += new Vector2((Main.rand.Next(randomXLimit + 1) + randomXLimit) * (Main.rand.NextBool() ? -1f : 1f), Main.rand.Next(randomYLimit + 1) + randomYLimit); - int wormHead = NPC.NewNPC(npc.GetSource_FromAI(), (int)additionalWormSpawnLocation.X, (int)additionalWormSpawnLocation.Y, NPCID.EaterofWorldsHead, npc.whoAmI + segmentSpawnAmount * i + 1); + int wormHead = NPC.NewNPC(NPC.GetSource_FromAI(), (int)additionalWormSpawnLocation.X, (int)additionalWormSpawnLocation.Y, NPCID.EaterofWorldsHead, NPC.whoAmI + segmentSpawnAmount * i + 1); Main.npc[wormHead].ai[2] = segmentSpawnAmount; Main.npc[wormHead].ai[0] = NPC.NewNPC(Main.npc[wormHead].GetSource_FromAI(), (int)additionalWormSpawnLocation.X, (int)additionalWormSpawnLocation.Y, NPCID.EaterofWorldsBody, Main.npc[wormHead].whoAmI); Main.npc[(int)Main.npc[wormHead].ai[0]].ai[1] = Main.npc[wormHead].whoAmI; @@ -210,104 +195,104 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Set head's "length beyond this point" to be the total length of the worm. - npc.ai[2] = segmentSpawnAmount; + NPC.ai[2] = segmentSpawnAmount; // Body spawn - npc.ai[0] = NPC.NewNPC(npc.GetSource_FromAI(), spawnX, spawnY, NPCID.EaterofWorldsBody, npc.whoAmI); + NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), spawnX, spawnY, NPCID.EaterofWorldsBody, NPC.whoAmI); } // A body with a "length beyond this point" greater than zero just sets its next spawned segment to a freshly spawned body. - else if (npc.type == NPCID.EaterofWorldsBody && npc.ai[2] > 0f) - npc.ai[0] = NPC.NewNPC(npc.GetSource_FromAI(), spawnX, spawnY, NPCID.EaterofWorldsBody, npc.whoAmI); + else if (NPC.type == NPCID.EaterofWorldsBody && NPC.ai[2] > 0f) + NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), spawnX, spawnY, NPCID.EaterofWorldsBody, NPC.whoAmI); // If the worm stops here ("length beyond this point" is zero), then spawn a tail instead. else - npc.ai[0] = NPC.NewNPC(npc.GetSource_FromAI(), spawnX, spawnY, NPCID.EaterofWorldsTail, npc.whoAmI); + NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), spawnX, spawnY, NPCID.EaterofWorldsTail, NPC.whoAmI); // Maintain the linked list of worm segments, and correctly set the "length beyond this point" of this segment. - Main.npc[(int)npc.ai[0]].ai[1] = npc.whoAmI; - Main.npc[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f; - npc.netUpdate = true; + Main.npc[(int)NPC.ai[0]].ai[1] = NPC.whoAmI; + Main.npc[(int)NPC.ai[0]].ai[2] = NPC.ai[2] - 1f; + NPC.netUpdate = true; } // Helper function to destroy this Eater of Worlds worm segment. void DestroyThisSegment() { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.checkDead(); } // If this segment's previous and next segments are both dead, make it explode instantly. Single segments cannot live. - if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) + if (!Main.npc[(int)NPC.ai[1]].active && !Main.npc[(int)NPC.ai[0]].active) DestroyThisSegment(); // If this segment is a head and its next segment is dead, make it explode instantly. It's been decapitated. - if (npc.type == NPCID.EaterofWorldsHead && !Main.npc[(int)npc.ai[0]].active) + if (NPC.type == NPCID.EaterofWorldsHead && !Main.npc[(int)NPC.ai[0]].active) DestroyThisSegment(); // If this segment is a tail and its previous segment is dead, make it explode instantly. It's been chopped off. - if (npc.type == NPCID.EaterofWorldsTail && !Main.npc[(int)npc.ai[1]].active) + if (NPC.type == NPCID.EaterofWorldsTail && !Main.npc[(int)NPC.ai[1]].active) DestroyThisSegment(); // If this segment is a body and its previous segment is dead (or was rendered into a tail), transform into a head. - if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle)) + if (NPC.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPC.aiStyle)) { - npc.type = NPCID.EaterofWorldsHead; - float segmentLifeRatio = MathHelper.Lerp(0.5f, 1f, npc.life / (float)npc.lifeMax); - int whoAmI = npc.whoAmI; - float ai0Holdover = npc.ai[0]; + NPC.type = NPCID.EaterofWorldsHead; + float segmentLifeRatio = MathHelper.Lerp(0.5f, 1f, NPC.life / (float)NPC.lifeMax); + int whoAmI = NPC.whoAmI; + float ai0Holdover = NPC.ai[0]; float newAI1Holdover = calamityGlobalNPC.newAI[1]; int slowingDebuffResistTimer = calamityGlobalNPC.debuffResistanceTimer; // Actually transform the body segment into a head segment. - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)(npc.lifeMax * segmentLifeRatio); - npc.whoAmI = whoAmI; - npc.ai[0] = ai0Holdover; + NPC.SetDefaultsKeepPlayerInteraction(NPC.type); + NPC.life = (int)(NPC.lifeMax * segmentLifeRatio); + NPC.whoAmI = whoAmI; + NPC.ai[0] = ai0Holdover; // Heads spawned mid fight by splitting do not get reset spawn invincibility. - CalamityGlobalNPC newCGN = npc.Calamity(); + CalamityGlobalNPC newCGN = NPC.Calamity(); newCGN.newAI[1] = newAI1Holdover; newCGN.debuffResistanceTimer = slowingDebuffResistTimer; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.ForceNetUpdate(); - npc.alpha = 0; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + NPC.ForceNetUpdate(); + NPC.alpha = 0; } // If this segment is a body and its next segment is dead (or was rendered into a head), transform into a tail. - if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle)) + if (NPC.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)NPC.ai[0]].active || Main.npc[(int)NPC.ai[0]].aiStyle != NPC.aiStyle)) { - npc.type = NPCID.EaterofWorldsTail; - float segmentLifeRatio = MathHelper.Lerp(0.5f, 1f, npc.life / (float)npc.lifeMax); - int whoAmI = npc.whoAmI; - float ai1Holdover = npc.ai[1]; + NPC.type = NPCID.EaterofWorldsTail; + float segmentLifeRatio = MathHelper.Lerp(0.5f, 1f, NPC.life / (float)NPC.lifeMax); + int whoAmI = NPC.whoAmI; + float ai1Holdover = NPC.ai[1]; int slowingDebuffResistTimer = calamityGlobalNPC.debuffResistanceTimer; // Actually transform the body segment into a tail segment. - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)(npc.lifeMax * segmentLifeRatio); - npc.whoAmI = whoAmI; - npc.ai[1] = ai1Holdover; - npc.Calamity().debuffResistanceTimer = slowingDebuffResistTimer; + NPC.SetDefaultsKeepPlayerInteraction(NPC.type); + NPC.life = (int)(NPC.lifeMax * segmentLifeRatio); + NPC.whoAmI = whoAmI; + NPC.ai[1] = ai1Holdover; + NPC.Calamity().debuffResistanceTimer = slowingDebuffResistTimer; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.ForceNetUpdate(); - npc.alpha = 0; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + NPC.ForceNetUpdate(); + NPC.alpha = 0; } // If for any reason this segment was deleted, send info to clients so they also see it die. - if (!npc.active && Main.dedServ) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); + if (!NPC.active && Main.dedServ) + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f); } // Movement - int tilePositionX = (int)(npc.position.X / 16f) - 1; - int tileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2; - int tilePositionY = (int)(npc.position.Y / 16f) - 1; - int tileWidthPosY = (int)((npc.position.Y + npc.height) / 16f) + 2; + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + NPC.height) / 16f) + 2; if (tilePositionX < 0) tilePositionX = 0; if (tileWidthPosX > Main.maxTilesX) @@ -330,7 +315,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 vector; vector.X = i * 16; vector.Y = j * 16; - if (npc.position.X + npc.width > vector.X && npc.position.X < vector.X + 16f && npc.position.Y + npc.height > vector.Y && npc.position.Y < vector.Y + 16f) + if (NPC.position.X + NPC.width > vector.X && NPC.position.X < vector.X + 16f && NPC.position.Y + NPC.height > vector.Y && NPC.position.Y < vector.Y + 16f) { inTiles = true; if (Main.rand.NextBool(100) && Main.tile[i, j].HasUnactuatedTile) @@ -341,13 +326,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (!inTiles && npc.type == NPCID.EaterofWorldsHead) + if (!inTiles && NPC.type == NPCID.EaterofWorldsHead) { - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int noFlyZone = death ? (800 - (phase5 ? 400 : 200)) : 900; - noFlyZone -= (int)(enrageScale * 200f); - if (noFlyZone < 100) - noFlyZone = 100; + Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); + int noFlyZone = death ? (phase5 ? 400 : 600) : 900; bool freeMoveAnyway = true; for (int k = 0; k < Main.maxPlayers; k++) @@ -368,38 +350,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Velocity and acceleration - float velocityScale = (death ? 4.8f : 2.4f) * enrageScale; + float velocityScale = death ? 4.8f : 2.4f; float velocityBoost = velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.06f : 0.03f) * enrageScale; + float accelerationScale = death ? 0.06f : 0.03f; float accelerationBoost = accelerationScale * (1f - lifeRatio); float segmentVelocity = 12f + velocityBoost; float segmentAcceleration = 0.15f + accelerationBoost; if (phase6) { - segmentVelocity += (death ? 2.4f : 4f) * (enrageScale + 1f); - segmentAcceleration += 0.2f * (enrageScale + 1f); + segmentVelocity += 2.4f; + segmentAcceleration += 0.12f; } else if (phase5) { - segmentVelocity += (death ? 2.2f : 3f) * (enrageScale + 1f); - segmentAcceleration += 0.15f * (enrageScale + 1f); + segmentVelocity += 1.8f; + segmentAcceleration += 0.09f; } else if (phase4) { - segmentVelocity += 2f * (enrageScale + 1f); - segmentAcceleration += 0.1f * (enrageScale + 1f); + segmentVelocity += 1.2f; + segmentAcceleration += 0.06f; } else if (phase3) { - segmentVelocity += 0.8f * (enrageScale + 1f); - segmentAcceleration += 0.04f * (enrageScale + 1f); + segmentVelocity += 0.6f; + segmentAcceleration += 0.03f; } if (death) { - segmentVelocity += (npc.justHit ? 8f : 2f); - segmentAcceleration += (npc.justHit ? 0.16f : 0.04f); + segmentVelocity += (NPC.justHit ? 8f : 2f); + segmentAcceleration += (NPC.justHit ? 0.16f : 0.04f); } if (Main.getGoodWorld) @@ -408,8 +390,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses segmentAcceleration += 0.05f; } - Vector2 segmentDirection = npc.Center; - Vector2 destination = Main.player[npc.target].Center + (phase6 ? Main.player[npc.target].velocity * 20f : Vector2.Zero); + Vector2 segmentDirection = NPC.Center; + Vector2 destination = Main.player[NPC.target].Center + (phase6 ? Main.player[NPC.target].velocity * 20f : Vector2.Zero); float targetPosX = destination.X; float targetPosY = destination.Y; @@ -422,22 +404,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float targetDistance = (float)Math.Sqrt(targetPosX * targetPosX + targetPosY * targetPosY); // Does this worm segment have a "previous segment" defined? - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) { try { - segmentDirection = npc.Center; - targetPosX = Main.npc[(int)npc.ai[1]].Center.X - segmentDirection.X; - targetPosY = Main.npc[(int)npc.ai[1]].Center.Y - segmentDirection.Y; + segmentDirection = NPC.Center; + targetPosX = Main.npc[(int)NPC.ai[1]].Center.X - segmentDirection.X; + targetPosY = Main.npc[(int)NPC.ai[1]].Center.Y - segmentDirection.Y; } catch { } - npc.rotation = (float)Math.Atan2(targetPosY, targetPosX) + MathHelper.PiOver2; + NPC.rotation = (float)Math.Atan2(targetPosY, targetPosX) + MathHelper.PiOver2; targetDistance = (float)Math.Sqrt(targetPosX * targetPosX + targetPosY * targetPosY); - int npcWidth = npc.width; - npcWidth = (int)(npcWidth * npc.scale); + int npcWidth = NPC.width; + npcWidth = (int)(npcWidth * NPC.scale); if (Main.getGoodWorld) npcWidth = 62; @@ -445,9 +427,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses targetDistance = (targetDistance - npcWidth) / targetDistance; targetPosX *= targetDistance; targetPosY *= targetDistance; - npc.velocity = Vector2.Zero; - npc.position.X += targetPosX; - npc.position.Y += targetPosY; + NPC.velocity = Vector2.Zero; + NPC.position.X += targetPosX; + NPC.position.Y += targetPosY; } // Otherwise this is a head. (Why does this not just check for head NPC type?) @@ -460,57 +442,57 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set velocity for when a new head spawns // Only set this if the head is far enough away from the player, to avoid unfair hits - if (npc.Distance(Main.player[npc.target].Center) > segmentVelocity * 20f) - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * (segmentVelocity * (death ? 0.75f : 0.5f)); + if (NPC.Distance(Main.player[NPC.target].Center) > segmentVelocity * 20f) + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * (segmentVelocity * (death ? 0.75f : 0.5f)); } if (!inTiles) { - npc.velocity.Y += death ? 0.1375f : 0.11f; - if (death && npc.velocity.Y > 0f) - npc.velocity.Y += 0.07f; + NPC.velocity.Y += death ? 0.1375f : 0.11f; + if (death && NPC.velocity.Y > 0f) + NPC.velocity.Y += 0.07f; - if (npc.velocity.Y > segmentVelocity) - npc.velocity.Y = segmentVelocity; + if (NPC.velocity.Y > segmentVelocity) + NPC.velocity.Y = segmentVelocity; // This bool exists to stop the strange wiggle behavior when worms are falling down - bool slowXVelocity = Math.Abs(npc.velocity.X) > segmentAcceleration; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.4) + bool slowXVelocity = Math.Abs(NPC.velocity.X) > segmentAcceleration; + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.4) { - if (npc.velocity.X < 0f) - npc.velocity.X -= segmentAcceleration * 1.1f; + if (NPC.velocity.X < 0f) + NPC.velocity.X -= segmentAcceleration * 1.1f; else - npc.velocity.X += segmentAcceleration * 1.1f; + NPC.velocity.X += segmentAcceleration * 1.1f; } - else if (npc.velocity.Y == segmentVelocity) + else if (NPC.velocity.Y == segmentVelocity) { if (slowXVelocity) { - if (npc.velocity.X < targetPosX) - npc.velocity.X += segmentAcceleration; - else if (npc.velocity.X > targetPosX) - npc.velocity.X -= segmentAcceleration; + if (NPC.velocity.X < targetPosX) + NPC.velocity.X += segmentAcceleration; + else if (NPC.velocity.X > targetPosX) + NPC.velocity.X -= segmentAcceleration; } else - npc.velocity.X = 0f; + NPC.velocity.X = 0f; } - else if (npc.velocity.Y > (death ? 5f : 4f)) + else if (NPC.velocity.Y > (death ? 5f : 4f)) { if (slowXVelocity) { - if (npc.velocity.X < 0f) - npc.velocity.X += segmentAcceleration * 0.9f; + if (NPC.velocity.X < 0f) + NPC.velocity.X += segmentAcceleration * 0.9f; else - npc.velocity.X -= segmentAcceleration * 0.9f; + NPC.velocity.X -= segmentAcceleration * 0.9f; } else - npc.velocity.X = 0f; + NPC.velocity.X = 0f; } } else { // Sound - if (npc.soundDelay == 0) + if (NPC.soundDelay == 0) { float soundDelay = targetDistance / 40f; if (soundDelay < 10f) @@ -518,8 +500,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (soundDelay > 20f) soundDelay = 20f; - npc.soundDelay = (int)soundDelay; - SoundEngine.PlaySound(SoundID.WormDig, npc.Center); + NPC.soundDelay = (int)soundDelay; + SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } targetDistance = (float)Math.Sqrt(targetPosX * targetPosX + targetPosY * targetPosY); @@ -530,13 +512,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses targetPosY *= timeToReachTarget; // Despawn - bool shouldDespawn = npc.type == NPCID.EaterofWorldsHead && Main.player[npc.target].dead; - if (shouldDespawn && !bossRush) + bool shouldDespawn = NPC.type == NPCID.EaterofWorldsHead && (Main.player[NPC.target].dead || !Main.player[NPC.target].ZoneCorrupt || !Main.player[NPC.target].ZoneCrimson) && !BossRushEvent.BossRushActive; + if (shouldDespawn) { bool everyoneDead = true; - 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 && p.ZoneCorrupt) { everyoneDead = false; break; @@ -545,93 +527,93 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (everyoneDead) { - if (Main.netMode != NetmodeID.MultiplayerClient && (npc.position.Y / 16f) > (Main.rockLayer + Main.maxTilesY) / 2.0) + if (Main.netMode != NetmodeID.MultiplayerClient && (NPC.position.Y / 16f) > (Main.rockLayer + Main.maxTilesY) / 2.0) { - npc.active = false; - int segmentAmt = (int)npc.ai[0]; + NPC.active = false; + int segmentAmt = (int)NPC.ai[0]; - while (segmentAmt > 0 && segmentAmt < Main.maxNPCs && Main.npc[segmentAmt].active && Main.npc[segmentAmt].aiStyle == npc.aiStyle) + while (segmentAmt > 0 && segmentAmt < Main.maxNPCs && Main.npc[segmentAmt].active && Main.npc[segmentAmt].aiStyle == NPC.aiStyle) { int attachedSegments = (int)Main.npc[segmentAmt].ai[0]; Main.npc[segmentAmt].active = false; - npc.life = 0; + NPC.life = 0; if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segmentAmt, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segmentAmt); segmentAmt = attachedSegments; } if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI); } targetPosX = 0f; targetPosY = segmentVelocity; } } - if ((npc.velocity.X > 0f && targetPosX > 0f) || (npc.velocity.X < 0f && targetPosX < 0f) || (npc.velocity.Y > 0f && targetPosY > 0f) || (npc.velocity.Y < 0f && targetPosY < 0f)) + if ((NPC.velocity.X > 0f && targetPosX > 0f) || (NPC.velocity.X < 0f && targetPosX < 0f) || (NPC.velocity.Y > 0f && targetPosY > 0f) || (NPC.velocity.Y < 0f && targetPosY < 0f)) { - if (npc.velocity.X < targetPosX) - npc.velocity.X += segmentAcceleration; - else if (npc.velocity.X > targetPosX) - npc.velocity.X -= segmentAcceleration; - if (npc.velocity.Y < targetPosY) - npc.velocity.Y += segmentAcceleration; - else if (npc.velocity.Y > targetPosY) - npc.velocity.Y -= segmentAcceleration; + if (NPC.velocity.X < targetPosX) + NPC.velocity.X += segmentAcceleration; + else if (NPC.velocity.X > targetPosX) + NPC.velocity.X -= segmentAcceleration; + if (NPC.velocity.Y < targetPosY) + NPC.velocity.Y += segmentAcceleration; + else if (NPC.velocity.Y > targetPosY) + NPC.velocity.Y -= segmentAcceleration; - if (Math.Abs(targetPosY) < segmentVelocity * 0.2 && ((npc.velocity.X > 0f && targetPosX < 0f) || (npc.velocity.X < 0f && targetPosX > 0f))) + if (Math.Abs(targetPosY) < segmentVelocity * 0.2 && ((NPC.velocity.X > 0f && targetPosX < 0f) || (NPC.velocity.X < 0f && targetPosX > 0f))) { - if (npc.velocity.Y > 0f) - npc.velocity.Y += segmentAcceleration * 2f; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += segmentAcceleration * 2f; else - npc.velocity.Y -= segmentAcceleration * 2f; + NPC.velocity.Y -= segmentAcceleration * 2f; } - if (Math.Abs(targetPosX) < segmentVelocity * 0.2 && ((npc.velocity.Y > 0f && targetPosY < 0f) || (npc.velocity.Y < 0f && targetPosY > 0f))) + if (Math.Abs(targetPosX) < segmentVelocity * 0.2 && ((NPC.velocity.Y > 0f && targetPosY < 0f) || (NPC.velocity.Y < 0f && targetPosY > 0f))) { - if (npc.velocity.X > 0f) - npc.velocity.X += segmentAcceleration * 2f; + if (NPC.velocity.X > 0f) + NPC.velocity.X += segmentAcceleration * 2f; else - npc.velocity.X -= segmentAcceleration * 2f; + NPC.velocity.X -= segmentAcceleration * 2f; } } else if (absoluteTargetX > absoluteTargetY) { - if (npc.velocity.X < targetPosX) - npc.velocity.X += segmentAcceleration * 1.1f; - else if (npc.velocity.X > targetPosX) - npc.velocity.X -= segmentAcceleration * 1.1f; + if (NPC.velocity.X < targetPosX) + NPC.velocity.X += segmentAcceleration * 1.1f; + else if (NPC.velocity.X > targetPosX) + NPC.velocity.X -= segmentAcceleration * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) { - if (npc.velocity.Y > 0f) - npc.velocity.Y += segmentAcceleration; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += segmentAcceleration; else - npc.velocity.Y -= segmentAcceleration; + NPC.velocity.Y -= segmentAcceleration; } } else { - if (npc.velocity.Y < targetPosY) - npc.velocity.Y += segmentAcceleration * 1.1f; - else if (npc.velocity.Y > targetPosY) - npc.velocity.Y -= segmentAcceleration * 1.1f; + if (NPC.velocity.Y < targetPosY) + NPC.velocity.Y += segmentAcceleration * 1.1f; + else if (NPC.velocity.Y > targetPosY) + NPC.velocity.Y -= segmentAcceleration * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) + if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) { - if (npc.velocity.X > 0f) - npc.velocity.X += segmentAcceleration; + if (NPC.velocity.X > 0f) + NPC.velocity.X += segmentAcceleration; else - npc.velocity.X -= segmentAcceleration; + NPC.velocity.X -= segmentAcceleration; } } } if (death) { - int numHeads = NPC.CountNPCS(npc.type); + int numHeads = NPC.CountNPCS(NPC.type); if (numHeads > 0) { // Limit this variable so that the following calculation never goes too low @@ -641,25 +623,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float pushDistanceLowerLimit = 14f - numHeads; float pushDistanceUpperLimit = 140f - numHeads * 10f; - float pushDistance = MathHelper.Lerp(pushDistanceLowerLimit, pushDistanceUpperLimit, 1f - lifeRatio) * npc.scale; - float pushVelocity = 0.25f + enrageScale * 0.125f; + float pushDistance = MathHelper.Lerp(pushDistanceLowerLimit, pushDistanceUpperLimit, 1f - lifeRatio) * NPC.scale; + float pushVelocity = 0.25f; for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active) { - if (i != npc.whoAmI && Main.npc[i].type == npc.type) + if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) { - if (Vector2.Distance(npc.Center, Main.npc[i].Center) < pushDistance) + if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < pushDistance) { - if (npc.position.X < Main.npc[i].position.X) - npc.velocity.X -= pushVelocity; + if (NPC.position.X < Main.npc[i].position.X) + NPC.velocity.X -= pushVelocity; else - npc.velocity.X += pushVelocity; + NPC.velocity.X += pushVelocity; - if (npc.position.Y < Main.npc[i].position.Y) - npc.velocity.Y -= pushVelocity; + if (NPC.position.Y < Main.npc[i].position.Y) + NPC.velocity.Y -= pushVelocity; else - npc.velocity.Y += pushVelocity; + NPC.velocity.Y += pushVelocity; } } } @@ -667,633 +649,63 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; - if (npc.type == NPCID.EaterofWorldsHead) + if (NPC.type == NPCID.EaterofWorldsHead) { if (inTiles) { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; + if (NPC.localAI[0] != 1f) + NPC.netUpdate = true; - npc.localAI[0] = 1f; + NPC.localAI[0] = 1f; } else { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; + if (NPC.localAI[0] != 0f) + NPC.netUpdate = true; - npc.localAI[0] = 0f; + NPC.localAI[0] = 0f; } - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + NPC.netUpdate = true; } } // 10 seconds of resistance to prevent spawn killing - if (calamityGlobalNPC.newAI[1] < DRIncreaseTime && ((npc.position - npc.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 0f)) + if (calamityGlobalNPC.newAI[1] < DRIncreaseTime && ((NPC.position - NPC.oldPosition).Length() > 2f || calamityGlobalNPC.newAI[1] > 0f)) calamityGlobalNPC.newAI[1] += 1f; - // Calculate contact damage based on velocity - // This worm requires more velocity to deal damage with the body because it doesn't have spikes or metal bits or etc. - float minimalContactDamageHeadVelocity = segmentVelocity * 0.25f; - float minimalDamageHeadVelocity = segmentVelocity * 0.5f; - float minimalContactDamageBodyVelocity = segmentVelocity * 0.4f; - float minimalDamageBodyVelocity = segmentVelocity * 0.8f; - if (npc.type == NPCID.EaterofWorldsHead) + if (NPC.type == NPCID.EaterofWorldsHead || (NPC.type != NPCID.EaterofWorldsHead && Main.npc[(int)NPC.ai[1]].alpha >= 85)) { - if (npc.velocity.Length() <= minimalContactDamageHeadVelocity) - { - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageHeadVelocity) / minimalDamageHeadVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar); - } - } - else - { - float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageBodyVelocity) - { - npc.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageBodyVelocity) / minimalDamageBodyVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar); - } - } - - if (npc.type == NPCID.EaterofWorldsHead || (npc.type != NPCID.EaterofWorldsHead && Main.npc[(int)npc.ai[1]].alpha >= 85)) - { - if (npc.alpha > 0 && npc.life > 0) + if (NPC.alpha > 0 && NPC.life > 0) { for (int dustIndex = 0; dustIndex < 2; dustIndex++) { - int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Demonite, 0f, 0f, 100, default(Color), 2f); + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); Main.dust[dust].noGravity = true; Main.dust[dust].noLight = true; } } - if ((npc.position - npc.oldPosition).Length() > 2f) + if ((NPC.position - NPC.oldPosition).Length() > 2f) { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } } - else if (npc.type > NPCID.EaterofWorldsHead && npc.alpha > 0) + else if (NPC.type > NPCID.EaterofWorldsHead && NPC.alpha > 0) { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; } // Manually sync newAI because there is no GlobalNPC.SendExtraAI - if (npc.active && npc.netUpdate && Main.dedServ) + if (NPC.active && NPC.netUpdate && Main.dedServ) { - SyncCalamityNPCAIArrayPacket.Send(npc); - } - - return false; - } - - public static bool VanillaEaterofWorldsAI(NPC npc, Mod mod) - { - if (Main.netMode != NetmodeID.MultiplayerClient && Main.expertMode) - { - if (npc.type == NPCID.EaterofWorldsBody && ((double)(npc.position.Y / 16f) < Main.worldSurface || Main.getGoodWorld)) - { - int num7 = (int)(npc.Center.X / 16f); - int num8 = (int)(npc.Center.Y / 16f); - if (WorldGen.InWorld(num7, num8) && Main.tile[num7, num8].WallType == WallID.None) - { - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - npc.localAI[1] += 1f; - else - npc.localAI[1] -= 1f; - - int vileSpitGateValue = Main.masterMode ? 600 : 900; - if (Main.getGoodWorld) - vileSpitGateValue = (int)(vileSpitGateValue * 0.5f); - - Vector2 vileSpitShootLocation = npc.Center + npc.velocity; - if (npc.localAI[1] >= vileSpitGateValue) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - NPC.NewNPC(npc.GetSource_FromAI(), (int)vileSpitShootLocation.X, (int)vileSpitShootLocation.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 1f); - - npc.localAI[1] = 0f; - } - - if (npc.localAI[1] > vileSpitGateValue - 30f) - { - Vector2 dustCenter = vileSpitShootLocation + Main.rand.NextVector2CircularEdge(5f, 5f); - Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, 18, npc.velocity.X * 0.1f, npc.velocity.Y * 0.1f, 80, default, 2f); - dust.noGravity = true; - dust.velocity *= 0.3f; - } - } - } - else if (npc.type == NPCID.EaterofWorldsHead) - { - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - npc.localAI[1] += 1f; - else - npc.localAI[1] -= 1f; - - int vileSpitGateValue = Main.masterMode ? 45 : 90; - vileSpitGateValue += (int)((float)npc.life / (float)npc.lifeMax * 300f); - - Vector2 vileSpitShootLocation = npc.Center + npc.velocity; - if (npc.localAI[1] >= vileSpitGateValue) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - NPC.NewNPC(npc.GetSource_FromAI(), (int)vileSpitShootLocation.X, (int)vileSpitShootLocation.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 1f); - - npc.localAI[1] = 0f; - } - - if (npc.localAI[1] > vileSpitGateValue - 30f) - { - Vector2 dustCenter = vileSpitShootLocation + Main.rand.NextVector2CircularEdge(5f, 5f); - Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, 18, npc.velocity.X * 0.1f, npc.velocity.Y * 0.1f, 80, default, 2f); - dust.noGravity = true; - dust.velocity *= 0.3f; - } - } - } - - npc.realLife = -1; - - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (Main.player[npc.target].dead) - npc.EncourageDespawn(300); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if ((npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody) && npc.ai[0] == 0f) - { - if (npc.type == NPCID.EaterofWorldsHead) - { - npc.ai[2] = GetEaterOfWorldsSegmentsCountVanilla(); - npc.ai[0] = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI); - Main.npc[(int)npc.ai[0]].CopyInteractions(npc); - } - else if (npc.type == NPCID.EaterofWorldsBody && npc.ai[2] > 0f) - { - npc.ai[0] = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + (float)npc.height), npc.type, npc.whoAmI); - Main.npc[(int)npc.ai[0]].CopyInteractions(npc); - } - else - { - npc.ai[0] = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI); - Main.npc[(int)npc.ai[0]].CopyInteractions(npc); - } - - Main.npc[(int)npc.ai[0]].ai[1] = npc.whoAmI; - Main.npc[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f; - npc.netUpdate = true; - } - - if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); - return false; - } - - if (npc.type == NPCID.EaterofWorldsHead && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); - return false; - } - - if (npc.type == NPCID.EaterofWorldsTail && !Main.npc[(int)npc.ai[1]].active) - { - npc.life = 0; - npc.HitEffect(); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); - return false; - } - - if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle)) - { - npc.type = NPCID.EaterofWorldsHead; - int num38 = npc.whoAmI; - float num39 = (float)npc.life / (float)npc.lifeMax; - float num40 = npc.ai[0]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num39); - npc.ai[0] = num40; - - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.netUpdate = true; - npc.whoAmI = num38; - npc.alpha = 0; - } - - if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle)) - { - npc.type = NPCID.EaterofWorldsTail; - int num41 = npc.whoAmI; - float num42 = (float)npc.life / (float)npc.lifeMax; - float num43 = npc.ai[1]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num42); - npc.ai[1] = num43; - - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.netUpdate = true; - npc.whoAmI = num41; - npc.alpha = 0; - } - - if (!npc.active && Main.dedServ) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); - } - - int num44 = (int)(npc.position.X / 16f) - 1; - int num45 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num46 = (int)(npc.position.Y / 16f) - 1; - int num47 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num44 < 0) - num44 = 0; - - if (num45 > Main.maxTilesX) - num45 = Main.maxTilesX; - - if (num46 < 0) - num46 = 0; - - if (num47 > Main.maxTilesY) - num47 = Main.maxTilesY; - - bool flag2 = false; - - if (!flag2) - { - Vector2 vector2 = default(Vector2); - for (int num48 = num44; num48 < num45; num48++) - { - for (int num49 = num46; num49 < num47; num49++) - { - if (Main.tile[num48, num49] == null || ((!Main.tile[num48, num49].HasUnactuatedTile || (!Main.tileSolid[Main.tile[num48, num49].TileType] && (!Main.tileSolidTop[Main.tile[num48, num49].TileType] || Main.tile[num48, num49].TileFrameY != 0))) && Main.tile[num48, num49].LiquidAmount <= 64)) - continue; - - vector2.X = num48 * 16; - vector2.Y = num49 * 16; - if (npc.position.X + (float)npc.width > vector2.X && npc.position.X < vector2.X + 16f && npc.position.Y + (float)npc.height > vector2.Y && npc.position.Y < vector2.Y + 16f) - { - flag2 = true; - if (Main.rand.NextBool(100) && Main.tile[num48, num49].HasUnactuatedTile && Main.tileSolid[Main.tile[num48, num49].TileType]) - WorldGen.KillTile(num48, num49, fail: true, effectOnly: true); - } - } - } - } - - if (!flag2 && npc.type == NPCID.EaterofWorldsHead) - { - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num50 = Main.masterMode ? 750 : 1000; - bool flag3 = true; - for (int num51 = 0; num51 < Main.maxPlayers; num51++) - { - if (Main.player[num51].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[num51].position.X - num50, (int)Main.player[num51].position.Y - num50, num50 * 2, num50 * 2); - if (rectangle.Intersects(rectangle2)) - { - flag3 = false; - break; - } - } - } - - if (flag3) - flag2 = true; - } - - float num52 = 10f; - float num53 = 0.07f; - if (Main.expertMode) - { - num52 = Main.masterMode ? 15f : 12f; - num53 = Main.masterMode ? 0.2f : 0.15f; - } - - if (Main.getGoodWorld) - { - num52 += 4f; - num53 += 0.05f; - } - - Vector2 vector5 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num55 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num56 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num55 = (int)(num55 / 16f) * 16; - num56 = (int)(num56 / 16f) * 16; - vector5.X = (int)(vector5.X / 16f) * 16; - vector5.Y = (int)(vector5.Y / 16f) * 16; - num55 -= vector5.X; - num56 -= vector5.Y; - float num68 = (float)Math.Sqrt(num55 * num55 + num56 * num56); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - try - { - vector5 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num55 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector5.X; - num56 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector5.Y; - } - catch - { - } - - npc.rotation = (float)Math.Atan2(num56, num55) + MathHelper.PiOver2; - num68 = (float)Math.Sqrt(num55 * num55 + num56 * num56); - int num69 = npc.width; - num69 = (int)((float)num69 * npc.scale); - - if (Main.getGoodWorld) - num69 = 62; - - num68 = (num68 - (float)num69) / num68; - num55 *= num68; - num56 *= num68; - npc.velocity = Vector2.Zero; - npc.position.X += num55; - npc.position.Y += num56; - } - else - { - if (!flag2) - { - npc.velocity.Y += 0.11f; - if (Main.masterMode && npc.velocity.Y > 0f) - npc.velocity.Y += 0.07f; - - if (npc.velocity.Y > num52) - npc.velocity.Y = num52; - - // This bool exists to stop the strange wiggle behavior when worms are falling down - bool slowXVelocity = Math.Abs(npc.velocity.X) > num53; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num52 * 0.4) - { - if (npc.velocity.X < 0f) - npc.velocity.X -= num53 * 1.1f; - else - npc.velocity.X += num53 * 1.1f; - } - else if (npc.velocity.Y == num52) - { - if (slowXVelocity) - { - if (npc.velocity.X < num55) - npc.velocity.X += num53; - else if (npc.velocity.X > num55) - npc.velocity.X -= num53; - } - else - npc.velocity.X = 0f; - } - else if (npc.velocity.Y > 4f) - { - if (slowXVelocity) - { - if (npc.velocity.X < 0f) - npc.velocity.X += num53 * 0.9f; - else - npc.velocity.X -= num53 * 0.9f; - } - else - npc.velocity.X = 0f; - } - } - else - { - if (npc.soundDelay == 0) - { - float num70 = num68 / 40f; - if (num70 < 10f) - num70 = 10f; - - if (num70 > 20f) - num70 = 20f; - - npc.soundDelay = (int)num70; - SoundEngine.PlaySound(SoundID.WormDig, npc.Center); - } - - num68 = (float)Math.Sqrt(num55 * num55 + num56 * num56); - float num71 = Math.Abs(num55); - float num72 = Math.Abs(num56); - float num73 = num52 / num68; - num55 *= num73; - num56 *= num73; - bool flag4 = false; - if (npc.type == NPCID.EaterofWorldsHead && ((!Main.player[npc.target].ZoneCorrupt && !Main.player[npc.target].ZoneCrimson) || Main.player[npc.target].dead)) - flag4 = true; - - if (flag4) - { - bool flag5 = true; - for (int num74 = 0; num74 < Main.maxPlayers; num74++) - { - if (Main.player[num74].active && !Main.player[num74].dead && Main.player[num74].ZoneCorrupt) - flag5 = false; - } - - if (flag5) - { - if (Main.netMode != NetmodeID.MultiplayerClient && (double)(npc.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0) - { - npc.active = false; - int num75 = (int)npc.ai[0]; - while (num75 > 0 && num75 < Main.maxNPCs && Main.npc[num75].active && Main.npc[num75].aiStyle == npc.aiStyle) - { - int num76 = (int)Main.npc[num75].ai[0]; - Main.npc[num75].active = false; - npc.life = 0; - if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num75); - - num75 = num76; - } - - if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); - } - - num55 = 0f; - num56 = num52; - } - } - - if ((npc.velocity.X > 0f && num55 > 0f) || (npc.velocity.X < 0f && num55 < 0f) || (npc.velocity.Y > 0f && num56 > 0f) || (npc.velocity.Y < 0f && num56 < 0f)) - { - if (npc.velocity.X < num55) - npc.velocity.X += num53; - else if (npc.velocity.X > num55) - npc.velocity.X -= num53; - - if (npc.velocity.Y < num56) - npc.velocity.Y += num53; - else if (npc.velocity.Y > num56) - npc.velocity.Y -= num53; - - if ((double)Math.Abs(num56) < (double)num52 * 0.2 && ((npc.velocity.X > 0f && num55 < 0f) || (npc.velocity.X < 0f && num55 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num53 * 2f; - else - npc.velocity.Y -= num53 * 2f; - } - - if ((double)Math.Abs(num55) < (double)num52 * 0.2 && ((npc.velocity.Y > 0f && num56 < 0f) || (npc.velocity.Y < 0f && num56 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num53 * 2f; - else - npc.velocity.X -= num53 * 2f; - } - } - else if (num71 > num72) - { - if (npc.velocity.X < num55) - npc.velocity.X += num53 * 1.1f; - else if (npc.velocity.X > num55) - npc.velocity.X -= num53 * 1.1f; - - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num52 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y += num53; - else - npc.velocity.Y -= num53; - } - } - else - { - if (npc.velocity.Y < num56) - npc.velocity.Y += num53 * 1.1f; - else if (npc.velocity.Y > num56) - npc.velocity.Y -= num53 * 1.1f; - - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num52 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X += num53; - else - npc.velocity.X -= num53; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - if (npc.type == NPCID.EaterofWorldsHead) - { - if (flag2) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - } - } - - // 10 seconds of resistance to prevent spawn killing - if (npc.Calamity().newAI[1] < DRIncreaseTime && ((npc.position - npc.oldPosition).Length() > 2f || npc.Calamity().newAI[1] > 0f)) - npc.Calamity().newAI[1] += 1f; - - // Calculate contact damage based on velocity - // This worm requires more velocity to deal damage with the body because it doesn't have spikes or metal bits or etc. - float minimalContactDamageHeadVelocity = num52 * 0.25f; - float minimalDamageHeadVelocity = num52 * 0.5f; - float minimalContactDamageBodyVelocity = num52 * 0.4f; - float minimalDamageBodyVelocity = num52 * 0.8f; - if (npc.type == NPCID.EaterofWorldsHead) - { - if (npc.velocity.Length() <= minimalContactDamageHeadVelocity) - { - npc.damage = (int)Math.Round(npc.defDamage * 0.5); - } - else - { - float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageHeadVelocity) / minimalDamageHeadVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp((float)Math.Round(npc.defDamage * 0.5), npc.defDamage, velocityDamageScalar); - } - } - else - { - float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length(); - if (bodyAndTailVelocity <= minimalContactDamageBodyVelocity) - { - npc.damage = 0; - } - else - { - float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageBodyVelocity) / minimalDamageBodyVelocity, 0f, 1f); - npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar); - } - } - - if (npc.type == NPCID.EaterofWorldsHead || (npc.type != NPCID.EaterofWorldsHead && Main.npc[(int)npc.ai[1]].alpha >= 85)) - { - if (npc.alpha > 0 && npc.life > 0) - { - for (int num80 = 0; num80 < 2; num80++) - { - int num81 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Demonite, 0f, 0f, 100, default(Color), 2f); - Main.dust[num81].noGravity = true; - Main.dust[num81].noLight = true; - } - } - - if ((npc.position - npc.oldPosition).Length() > 2f) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - } - else if (npc.type > NPCID.EaterofWorldsHead && npc.alpha > 0) - { - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; + SyncCalamityNPCAIArrayPacket.Send(NPC); } return false; @@ -1301,14 +713,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int GetEaterOfWorldsSegmentsCountRevDeath() { - return CalamityWorld.LegendaryMode ? 100 : - (CalamityWorld.death || BossRushEvent.BossRushActive) ? ((Main.masterMode || BossRushEvent.BossRushActive) ? 60 : 57) : - ((Main.masterMode || BossRushEvent.BossRushActive) ? 68 : 62); - } - - public static int GetEaterOfWorldsSegmentsCountVanilla() - { - return (Main.masterMode || BossRushEvent.BossRushActive) ? 75 : Main.expertMode ? 70 : 65; + return Main.getGoodWorld ? 100 : (CalamityWorld.death || BossRushEvent.BossRushActive) ? 57 : 62; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs index 778d63ffa4..426c1fad95 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EmpressofLightAI.cs @@ -10,47 +10,73 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class EmpressofLightAI + public static class EmpressOfLightAIUtils { - public static bool BuffedEmpressofLightAI(NPC npc, Mod mod) + public static int CalculateDamageForEnrage(this int damage) => NPC.ShouldEmpressBeEnraged() ? 9999 : damage; + } + + public class EmpressofLightAI : VanillaAIOverride + { + // NOTE: This is applied to all difficulties, in CalamityPlayerHitHurt + public static float EverlastingRainbowTrailDamageMult = 0.75f; + + // Vanilla values + public static float DashDamageMult = 1.5f; // 165 + public static int PrismaticBoltDamage = 30; // 120 + public static int EverlastingRainbowDamage = 30; // 120 + public static int EtherealLanceDamage = 30; // 120 + public static int SunDanceDamage = 35; // 140 + public static int Phase2PrismaticBoltDamage = 35; // 140 + public static int Phase2EverlastingRainbowDamage = 35; // 140 + public static int Phase2EtherealLanceDamage = 35; // 140 + public static int Phase2SunDanceDamage = 40; // 160 + + // Vanilla sets her defDamage to 184 (80 * 2 * 1.15) in Expert Mode + // However, some weird contraption in her Expert AI that knocks her base contact damage to the intended value of 110 + // This hasn't been found anywhere so our solution for now is avoid using defDamage altogether + public static int ContactDamageCorrection = Main.masterMode ? 248 : 110; + + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // Difficulty bools. - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Rotation - npc.rotation = npc.velocity.X * 0.005f; + NPC.rotation = NPC.velocity.X * 0.005f; // Reset DR every frame. calamityGlobalNPC.DR = 0.15f; // Percent life remaining. - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; float phase2LifeRatio = death ? 0.7f : 0.6f; float phase3LifeRatio = death ? 0.3f : 0.15f; - bool phase2 = npc.AI_120_HallowBoss_IsInPhase2(); + bool phase2 = NPC.AI_120_HallowBoss_IsInPhase2(); bool phase3 = lifeRatio <= phase3LifeRatio; + int boltDamage = (phase2 ? Phase2PrismaticBoltDamage : PrismaticBoltDamage).CalculateDamageForEnrage(); + int rainbowDamage = (phase2 ? Phase2EverlastingRainbowDamage : EverlastingRainbowDamage).CalculateDamageForEnrage(); + int lanceDamage = (phase2 ? Phase2EtherealLanceDamage : EtherealLanceDamage).CalculateDamageForEnrage(); + int sunDanceDamage = (phase2 ? Phase2SunDanceDamage : SunDanceDamage).CalculateDamageForEnrage(); + bool shouldBeInPhase2ButIsStillInPhase1 = lifeRatio <= phase2LifeRatio && !phase2; if (shouldBeInPhase2ButIsStillInPhase1) calamityGlobalNPC.DR = 0.99f; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = shouldBeInPhase2ButIsStillInPhase1 || npc.ai[0] == 6f; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = shouldBeInPhase2ButIsStillInPhase1 || NPC.ai[0] == 6f; bool dayTimeEnrage = NPC.ShouldEmpressBeEnraged(); - if (npc.life == npc.lifeMax && dayTimeEnrage && !npc.AI_120_HallowBoss_IsGenuinelyEnraged()) - npc.ai[3] += 2f; + if (NPC.life == NPC.lifeMax && dayTimeEnrage && !NPC.AI_120_HallowBoss_IsGenuinelyEnraged()) + NPC.ai[3] += 2f; - npc.Calamity().CurrentlyEnraged = !bossRush && dayTimeEnrage; + NPC.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && dayTimeEnrage; - int projectileDamageMultiplier = dayTimeEnrage ? 2 : 1; - - Vector2 rainbowStreakDistance = new Vector2(-250f, -350f); - Vector2 everlastingRainbowDistance = new Vector2(0f, -450f); - Vector2 etherealLanceDistance = new Vector2(0f, -450f); + Vector2 rainbowStreakDistance = new Vector2(-150f, -250f); + Vector2 everlastingRainbowDistance = new Vector2(0f, -350f); + Vector2 etherealLanceDistance = new Vector2(0f, -350f); Vector2 sunDanceDistance = new Vector2(-80f, -500f); float acceleration = death ? 0.66f : 0.6f; @@ -90,56 +116,56 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (phase3) { if (calamityGlobalNPC.newAI[0] == playSpawnSoundTime) - SoundEngine.PlaySound(SoundID.Item161, npc.Center); + SoundEngine.PlaySound(SoundID.Item161, NPC.Center); if (calamityGlobalNPC.newAI[0] > playSpawnSoundTime && calamityGlobalNPC.newAI[0] < stopSpawningDustTime) - CreateSpawnDust(npc, false); + CreateSpawnDust(NPC, false); calamityGlobalNPC.newAI[0] += 1f; if (calamityGlobalNPC.newAI[0] >= stopSpawningDustTime) { calamityGlobalNPC.newAI[0] = playSpawnSoundTime + 1f; - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } } - switch ((int)npc.ai[0]) + switch ((int)NPC.ai[0]) { // Spawn animation. case 0: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == 0f) + if (NPC.ai[1] == 0f) { - npc.velocity = new Vector2(0f, 5f); + NPC.velocity = new Vector2(0f, 5f); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + new Vector2(0f, -80f), Vector2.Zero, ProjectileID.HallowBossDeathAurora, 0, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + new Vector2(0f, -80f), Vector2.Zero, ProjectileID.HallowBossDeathAurora, 0, 0f, Main.myPlayer); } - if (npc.ai[1] == playSpawnSoundTime) - SoundEngine.PlaySound(SoundID.Item161, npc.Center); + if (NPC.ai[1] == playSpawnSoundTime) + SoundEngine.PlaySound(SoundID.Item161, NPC.Center); - npc.velocity *= 0.95f; + NPC.velocity *= 0.95f; - if (npc.ai[1] > playSpawnSoundTime && npc.ai[1] < stopSpawningDustTime) - CreateSpawnDust(npc); + if (NPC.ai[1] > playSpawnSoundTime && NPC.ai[1] < stopSpawningDustTime) + CreateSpawnDust(NPC); - npc.ai[1] += 1f; + NPC.ai[1] += 1f; visible = false; takeDamage = false; - npc.Opacity = MathHelper.Clamp(npc.ai[1] / spawnTime, 0f, 1f); + NPC.Opacity = MathHelper.Clamp(NPC.ai[1] / spawnTime, 0f, 1f); - if (npc.ai[1] >= spawnTime) + if (NPC.ai[1] >= spawnTime) { - if (dayTimeEnrage && !npc.AI_120_HallowBoss_IsGenuinelyEnraged()) - npc.ai[3] += 2f; + if (dayTimeEnrage && !NPC.AI_120_HallowBoss_IsGenuinelyEnraged()) + NPC.ai[3] += 2f; - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); } break; @@ -148,7 +174,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 1: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; float idleTimer = phase2 ? (death ? 10f : 15f) : (death ? 20f : 30f); if (Main.getGoodWorld) @@ -156,29 +182,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (idleTimer < 10f) idleTimer = 10f; - if (npc.ai[1] <= 10f) + if (NPC.ai[1] <= 10f) { - if (npc.ai[1] == 0f) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.ai[1] == 0f) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); // Despawn. - NPCAimedTarget targetData4 = npc.GetTargetData(); + NPCAimedTarget targetData4 = NPC.GetTargetData(); if (targetData4.Invalid) { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] += 1f; - npc.velocity /= 4f; - npc.netUpdate = true; + NPC.ai[0] = 13f; + NPC.ai[1] = 0f; + NPC.ai[2] += 1f; + NPC.velocity /= 4f; + NPC.netUpdate = true; break; } Vector2 center = targetData4.Center; center += new Vector2(0f, -400f); - if (npc.Distance(center) > 200f) - center -= npc.DirectionTo(center) * 100f; + if (NPC.Distance(center) > 200f) + center -= NPC.DirectionTo(center) * 100f; - Vector2 targetDirection = center - npc.Center; + Vector2 targetDirection = center - NPC.Center; float lerpValue = Utils.GetLerpValue(100f, 600f, targetDirection.Length()); float targetDistance = targetDirection.Length(); @@ -186,16 +212,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (targetDistance > maxVelocity) targetDistance = maxVelocity; - npc.velocity = Vector2.Lerp(targetDirection.SafeNormalize(Vector2.Zero) * targetDistance, targetDirection / 6f, lerpValue); - npc.netUpdate = true; + NPC.velocity = Vector2.Lerp(targetDirection.SafeNormalize(Vector2.Zero) * targetDistance, targetDirection / 6f, lerpValue); + NPC.netUpdate = true; } - npc.velocity *= 0.92f; - npc.ai[1] += 1f; - if (!(npc.ai[1] >= idleTimer)) + NPC.velocity *= 0.92f; + NPC.ai[1] += 1f; + if (!(NPC.ai[1] >= idleTimer)) break; - int attackPatternLength = (int)npc.ai[2]; + int attackPatternLength = (int)NPC.ai[2]; int attackType = 2; int attackIncrement = 0; @@ -229,7 +255,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[3] = Main.rand.Next(2); // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } if (attackPatternLength % attackIncrement == phase1Attack5) @@ -249,7 +275,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[3] = Main.rand.Next(2); // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } if (attackPatternLength % attackIncrement == phase1Attack9) @@ -283,7 +309,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[2] = Main.rand.Next(2); // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } if (attackPatternLength % attackIncrement == phase2Attack2) @@ -308,7 +334,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[2] = Main.rand.Next(2); // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } else attackType = 6; @@ -324,7 +350,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[3] = Main.rand.Next(2); // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } else attackType = 6; @@ -338,7 +364,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[3] = Main.rand.Next(2); // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } if (attackPatternLength % attackIncrement == phase2Attack9) @@ -351,10 +377,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses attackType = 12; } - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - NPCAimedTarget targetData5 = npc.GetTargetData(); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPCAimedTarget targetData5 = NPC.GetTargetData(); bool despawnFlag = false; - if (npc.AI_120_HallowBoss_IsGenuinelyEnraged() && !bossRush) + if (NPC.AI_120_HallowBoss_IsGenuinelyEnraged() && !BossRushEvent.BossRushActive) { if (!Main.dayTime) despawnFlag = true; @@ -364,20 +390,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawn. - if (targetData5.Invalid || npc.Distance(targetData5.Center) > despawnDistanceGateValue || despawnFlag) + if (targetData5.Invalid || NPC.Distance(targetData5.Center) > despawnDistanceGateValue || despawnFlag) attackType = 13; // Set charge direction. - if (attackType == 8 && targetData5.Center.X > npc.Center.X) + if (attackType == 8 && targetData5.Center.X > NPC.Center.X) attackType = 9; if (attackType != 5 && attackType != 12) - npc.velocity = npc.DirectionFrom(targetData5.Center).SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2 * (targetData5.Center.X > npc.Center.X).ToDirectionInt()) * 24f; + NPC.velocity = NPC.DirectionFrom(targetData5.Center).SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2 * (targetData5.Center.X > NPC.Center.X).ToDirectionInt()) * 24f; - npc.ai[0] = attackType; - npc.ai[1] = 0f; - npc.ai[2] += Main.rand.Next(2) + 1f; - npc.netUpdate = true; + NPC.ai[0] = attackType; + NPC.ai[1] = 0f; + NPC.ai[2] += Main.rand.Next(2) + 1f; + NPC.netUpdate = true; break; @@ -385,30 +411,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 2: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item164, npc.Center); + if (NPC.ai[1] == 0f) + SoundEngine.PlaySound(SoundID.Item164, NPC.Center); Vector2 randomStreakOffset = new Vector2(-55f, -30f); - NPCAimedTarget targetData11 = npc.GetTargetData(); - Vector2 targetCenter = targetData11.Invalid ? npc.Center : targetData11.Center; - if (npc.Distance(targetCenter + rainbowStreakDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + rainbowStreakDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); + NPCAimedTarget targetData11 = NPC.GetTargetData(); + Vector2 targetCenter = targetData11.Invalid ? NPC.Center : targetData11.Center; + if (NPC.Distance(targetCenter + rainbowStreakDistance) > movementDistanceGateValue) + NPC.SimpleFlyMovement(NPC.DirectionTo(targetCenter + rainbowStreakDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); - if (npc.ai[1] < 60f) - AI_120_HallowBoss_DoMagicEffect(npc.Center + randomStreakOffset, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); + if (NPC.ai[1] < 60f) + AI_120_HallowBoss_DoMagicEffect(NPC.Center + randomStreakOffset, 1, Utils.GetLerpValue(0f, 60f, NPC.ai[1], clamped: true), NPC); - int streakSpawnFrequency = CalamityWorld.LegendaryMode ? 1 : 2; + int streakSpawnFrequency = Main.getGoodWorld ? 1 : 2; if (phase3) streakSpawnFrequency *= 2; - if ((int)npc.ai[1] % streakSpawnFrequency == 0 && npc.ai[1] < 60f) + if ((int)NPC.ai[1] % streakSpawnFrequency == 0 && NPC.ai[1] < 60f) { int projectileType = ProjectileID.HallowBossRainbowStreak; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = boltDamage; - float ai3 = npc.ai[1] / 60f; + float ai3 = NPC.ai[1] / 60f; Vector2 rainbowStreakVelocity = new Vector2(0f, death ? -10f : -8f).RotatedBy(MathHelper.PiOver2 * Main.rand.NextFloatDirection()); if (phase2) rainbowStreakVelocity = new Vector2(0f, death ? -12f : -10f).RotatedBy(MathHelper.TwoPi * Main.rand.NextFloat()); @@ -418,43 +444,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + randomStreakOffset, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, ai3); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + randomStreakOffset, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, NPC.target, ai3); if (phase3) { - int proj2 = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + randomStreakOffset, -rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, 1f - ai3); - if (Main.rand.NextBool(60) && CalamityWorld.LegendaryMode) - { - Main.projectile[proj2].extraUpdates += 1; - Main.projectile[proj2].netUpdate = true; - } - } - - if (Main.rand.NextBool(60) && CalamityWorld.LegendaryMode) - { - Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].netUpdate = true; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + randomStreakOffset, -rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, NPC.target, 1f - ai3); } } // Spawn extra homing Rainbow Streaks per player. if (Main.netMode != NetmodeID.MultiplayerClient) { - int multiplayerStreakSpawnFrequency = (int)(npc.ai[1] / streakSpawnFrequency); + int multiplayerStreakSpawnFrequency = (int)(NPC.ai[1] / streakSpawnFrequency); for (int i = 0; i < Main.maxPlayers; i++) { - if (npc.Boss_CanShootExtraAt(i, multiplayerStreakSpawnFrequency % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + randomStreakOffset, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, i, ai3); + if (NPC.Boss_CanShootExtraAt(i, multiplayerStreakSpawnFrequency % 3, 3, 2400f)) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + randomStreakOffset, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, i, ai3); } } } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? (death ? 30f : 36f) : (death ? 60f : 72f)) + 30f * lessTimeSpentPerPhaseMultiplier; - if (npc.ai[1] >= 60f + extraPhaseTime) + if (NPC.ai[1] >= 60f + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -488,31 +503,31 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 4: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item162, npc.Center); + if (NPC.ai[1] == 0f) + SoundEngine.PlaySound(SoundID.Item162, NPC.Center); float lanceGateValue = death ? 75f : 100f; - if (npc.ai[1] >= 6f && npc.ai[1] < 54f) + if (NPC.ai[1] >= 6f && NPC.ai[1] < 54f) { - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(-55f, -20f), 2, Utils.GetLerpValue(0f, lanceGateValue, npc.ai[1], clamped: true), npc); - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(55f, -20f), 4, Utils.GetLerpValue(0f, lanceGateValue, npc.ai[1], clamped: true), npc); + AI_120_HallowBoss_DoMagicEffect(NPC.Center + new Vector2(-55f, -20f), 2, Utils.GetLerpValue(0f, lanceGateValue, NPC.ai[1], clamped: true), NPC); + AI_120_HallowBoss_DoMagicEffect(NPC.Center + new Vector2(55f, -20f), 4, Utils.GetLerpValue(0f, lanceGateValue, NPC.ai[1], clamped: true), NPC); } - NPCAimedTarget targetData10 = npc.GetTargetData(); - targetCenter = targetData10.Invalid ? npc.Center : targetData10.Center; - if (npc.Distance(targetCenter + etherealLanceDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); + NPCAimedTarget targetData10 = NPC.GetTargetData(); + targetCenter = targetData10.Invalid ? NPC.Center : targetData10.Center; + if (NPC.Distance(targetCenter + etherealLanceDistance) > movementDistanceGateValue) + NPC.SimpleFlyMovement(NPC.DirectionTo(targetCenter + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); int lanceRotation = death ? 10 : 8; - if (npc.ai[1] % (dayTimeEnrage ? 2f : 3f) == 0f && npc.ai[1] < lanceGateValue) + if (NPC.ai[1] % (dayTimeEnrage ? 2f : 3f) == 0f && NPC.ai[1] < lanceGateValue) { int lanceAmount = phase3 ? 2 : 1; for (int i = 0; i < lanceAmount; i++) { - int lanceFrequency = (int)(npc.ai[1] / (dayTimeEnrage ? 2f : 3f)); + int lanceFrequency = (int)(NPC.ai[1] / (dayTimeEnrage ? 2f : 3f)); lanceRotation += (death ? 5 : 4) * i; Vector2 lanceDirection = Vector2.UnitX.RotatedBy((float)Math.PI / (lanceRotation * 2) + lanceFrequency * ((float)Math.PI / lanceRotation)); if (calamityGlobalNPC.newAI[3] == 0f) @@ -522,7 +537,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float spawnDistance = 600f; Vector2 playerCenter = targetData10.Center; - if (npc.Distance(playerCenter) > 2400f) + if (NPC.Distance(playerCenter) > 2400f) continue; if (Vector2.Dot(targetData10.Velocity.SafeNormalize(Vector2.UnitY), lanceDirection) > 0f) @@ -540,11 +555,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } int projectileType = ProjectileID.FairyQueenLance; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = lanceDamage; Vector2 v3 = targetHoverPos - spawnLocation; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v3.ToRotation(), npc.ai[1] / lanceGateValue); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v3.ToRotation(), NPC.ai[1] / lanceGateValue); if (Main.netMode == NetmodeID.MultiplayerClient) continue; @@ -552,7 +567,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spawn extra Ethereal Lances per player. for (int j = 0; j < Main.maxPlayers; j++) { - if (!npc.Boss_CanShootExtraAt(j, lanceFrequency % 3, 3, 2400f)) + if (!NPC.Boss_CanShootExtraAt(j, lanceFrequency % 3, 3, 2400f)) continue; Player extraPlayer = Main.player[j]; @@ -572,22 +587,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } v3 = extraPlayerSpawnLocation - spawnLocation; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v3.ToRotation(), npc.ai[1] / lanceGateValue); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v3.ToRotation(), NPC.ai[1] / lanceGateValue); } } } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? 24f : 48f) + 20f * lessTimeSpentPerPhaseMultiplier; - if (npc.ai[1] >= lanceGateValue + extraPhaseTime) + if (NPC.ai[1] >= lanceGateValue + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; calamityGlobalNPC.newAI[3] = 0f; - npc.netUpdate = true; + NPC.netUpdate = true; // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } break; @@ -596,33 +611,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 5: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item163, npc.Center); + if (NPC.ai[1] == 0f) + SoundEngine.PlaySound(SoundID.Item163, NPC.Center); Vector2 magicSpawnOffset = new Vector2(55f, -30f); - Vector2 everlastingRainbowSpawn = npc.Center + magicSpawnOffset; - if (npc.ai[1] < 42f) - AI_120_HallowBoss_DoMagicEffect(npc.Center + magicSpawnOffset, 3, Utils.GetLerpValue(0f, 42f, npc.ai[1], clamped: true), npc); + Vector2 everlastingRainbowSpawn = NPC.Center + magicSpawnOffset; + if (NPC.ai[1] < 42f) + AI_120_HallowBoss_DoMagicEffect(NPC.Center + magicSpawnOffset, 3, Utils.GetLerpValue(0f, 42f, NPC.ai[1], clamped: true), NPC); - NPCAimedTarget targetData7 = npc.GetTargetData(); - targetCenter = targetData7.Invalid ? npc.Center : targetData7.Center; - if (npc.Distance(targetCenter + everlastingRainbowDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + everlastingRainbowDistance).SafeNormalize(Vector2.Zero) * velocity * 0.5f, acceleration * 0.75f); + NPCAimedTarget targetData7 = NPC.GetTargetData(); + targetCenter = targetData7.Invalid ? NPC.Center : targetData7.Center; + if (NPC.Distance(targetCenter + everlastingRainbowDistance) > movementDistanceGateValue) + NPC.SimpleFlyMovement(NPC.DirectionTo(targetCenter + everlastingRainbowDistance).SafeNormalize(Vector2.Zero) * velocity * 0.5f, acceleration * 0.75f); - if (npc.ai[1] % 42f == 0f && npc.ai[1] < 42f) + if (NPC.ai[1] % 42f == 0f && NPC.ai[1] < 42f) { float projRotation = MathHelper.TwoPi * Main.rand.NextFloat(); - float totalProjectiles = CalamityWorld.LegendaryMode ? 30f : death ? (dayTimeEnrage ? 22f : 15f) : (dayTimeEnrage ? 18f : 13f); + float totalProjectiles = Main.getGoodWorld ? 30f : death ? (dayTimeEnrage ? 22f : 15f) : (dayTimeEnrage ? 18f : 13f); int projIndex = 0; bool inversePhase2SpreadPattern = Main.rand.NextBool(); for (float i = 0f; i < 1f; i += 1f / totalProjectiles) { int projectileType = ProjectileID.HallowBossLastingRainbow; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = rainbowDamage; int projectileType2 = ProjectileID.HallowBossRainbowStreak; - int projectileDamage2 = npc.GetProjectileDamage(projectileType2) * projectileDamageMultiplier; + int projectileDamage2 = boltDamage; float projRotationMultiplier = i; Vector2 spinningpoint = Vector2.UnitY.RotatedBy(MathHelper.PiOver2 + MathHelper.TwoPi * projRotationMultiplier + projRotation); @@ -630,7 +645,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float initialVelocity = death ? 2f : 1.75f; if (dayTimeEnrage && projIndex % 2 == 0) initialVelocity *= 2f; - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) initialVelocity *= 1.5f; // Given that maxAddedVelocity = 2 @@ -645,12 +660,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(npc.GetSource_FromAI(), everlastingRainbowSpawn + spinningpoint.RotatedBy(-MathHelper.PiOver2) * 30f, spinningpoint * initialVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, 0f, projRotationMultiplier); + Projectile.NewProjectile(NPC.GetSource_FromAI(), everlastingRainbowSpawn + spinningpoint.RotatedBy(-MathHelper.PiOver2) * 30f, spinningpoint * initialVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, 0f, projRotationMultiplier); if (phase3) { if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), everlastingRainbowSpawn + spinningpoint.RotatedBy(-MathHelper.PiOver2) * 30f, spinningpoint * (death ? 3f : 2f) * initialVelocity, projectileType2, projectileDamage2, 0f, Main.myPlayer, npc.target, projRotationMultiplier); + Projectile.NewProjectile(NPC.GetSource_FromAI(), everlastingRainbowSpawn + spinningpoint.RotatedBy(-MathHelper.PiOver2) * 30f, spinningpoint * (death ? 3f : 2f) * initialVelocity, projectileType2, projectileDamage2, 0f, Main.myPlayer, NPC.target, projRotationMultiplier); } } @@ -658,13 +673,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? 36f : 72f) + 30f * lessTimeSpentPerPhaseMultiplier; - if (npc.ai[1] >= 72f + extraPhaseTime) + if (NPC.ai[1] >= 72f + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -673,30 +688,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 6: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; // Increase durability. - calamityGlobalNPC.DR = shouldBeInPhase2ButIsStillInPhase1 ? 0.99f : (bossRush ? 0.99f : 0.575f); + calamityGlobalNPC.DR = shouldBeInPhase2ButIsStillInPhase1 ? 0.99f : 0.575f; int totalSunDances = phase2 ? 2 : 3; float sunDanceGateValue = dayTimeEnrage ? 35f : death ? 40f : 50f; float totalSunDancePhaseTime = totalSunDances * sunDanceGateValue; Vector2 sunDanceHoverOffset = new Vector2(0f, -100f); - Vector2 position = npc.Center + sunDanceHoverOffset; + Vector2 position = NPC.Center + sunDanceHoverOffset; - NPCAimedTarget targetData2 = npc.GetTargetData(); - targetCenter = targetData2.Invalid ? npc.Center : targetData2.Center; - if (npc.Distance(targetCenter + sunDanceDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + sunDanceDistance).SafeNormalize(Vector2.Zero) * velocity * 0.3f, acceleration * 0.7f); + NPCAimedTarget targetData2 = NPC.GetTargetData(); + targetCenter = targetData2.Invalid ? NPC.Center : targetData2.Center; + if (NPC.Distance(targetCenter + sunDanceDistance) > movementDistanceGateValue) + NPC.SimpleFlyMovement(NPC.DirectionTo(targetCenter + sunDanceDistance).SafeNormalize(Vector2.Zero) * velocity * 0.3f, acceleration * 0.7f); - if (npc.ai[1] % sunDanceGateValue == 0f && npc.ai[1] < totalSunDancePhaseTime) + if (NPC.ai[1] % sunDanceGateValue == 0f && NPC.ai[1] < totalSunDancePhaseTime) { int projectileType = ProjectileID.FairyQueenSunDance; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = sunDanceDamage; - int sunDanceExtension = (int)(npc.ai[1] / sunDanceGateValue); - int targetFloatDirection = (targetData2.Center.X > npc.Center.X) ? 1 : 0; + int sunDanceExtension = (int)(NPC.ai[1] / sunDanceGateValue); + int targetFloatDirection = (targetData2.Center.X > NPC.Center.X) ? 1 : 0; float projAmount = phase2 ? 8f : 6f; float projRotation = 1f / projAmount; for (float j = 0f; j < 1f; j += projRotation) @@ -704,17 +719,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float projDirection = (j + projRotation * 0.5f + sunDanceExtension * projRotation * 0.5f) % 1f; float ai = MathHelper.TwoPi * (projDirection + targetFloatDirection); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), position, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, ai, npc.whoAmI); + Projectile.NewProjectile(NPC.GetSource_FromAI(), position, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, ai, NPC.whoAmI); } } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? (death ? 105f : 110f) : (death ? 140f : 150f)) + 30f * lessTimeSpentPerPhaseMultiplier; // 112.5 is too little - if (npc.ai[1] >= totalSunDancePhaseTime + extraPhaseTime) + if (NPC.ai[1] >= totalSunDancePhaseTime + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -723,33 +738,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 7: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; // Expert attack or not. bool expertAttack = calamityGlobalNPC.newAI[2] == 0f; int numLanceWalls = expertAttack ? 6 : 4; - float lanceWallSpawnGateValue = expertAttack ? 36f : 54f; + float lanceWallSpawnGateValue = expertAttack ? (death ? 42f : 36f) : 54f; if (dayTimeEnrage) lanceWallSpawnGateValue -= expertAttack ? 4f : 6f; float lanceWallPhaseTime = lanceWallSpawnGateValue * numLanceWalls; - NPCAimedTarget targetData9 = npc.GetTargetData(); - destination = targetData9.Invalid ? npc.Center : targetData9.Center; - if (npc.Distance(destination + etherealLanceDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(destination + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity * 0.4f, acceleration); + NPCAimedTarget targetData9 = NPC.GetTargetData(); + destination = targetData9.Invalid ? NPC.Center : targetData9.Center; + if (NPC.Distance(destination + etherealLanceDistance) > movementDistanceGateValue) + NPC.SimpleFlyMovement(NPC.DirectionTo(destination + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity * 0.4f, acceleration); - if ((int)npc.ai[1] % lanceWallSpawnGateValue == 0f && npc.ai[1] < lanceWallPhaseTime) + if ((int)NPC.ai[1] % lanceWallSpawnGateValue == 0f && NPC.ai[1] < lanceWallPhaseTime) { - SoundEngine.PlaySound(SoundID.Item162, npc.Center); + SoundEngine.PlaySound(SoundID.Item162, NPC.Center); float totalProjectiles = death ? 18f : 15f; float lanceSpacing = death ? 150f : 175f; float lanceWallSize = totalProjectiles * lanceSpacing; Vector2 lanceSpawnOffset = targetData9.Center; - if (npc.Distance(lanceSpawnOffset) <= 3200f) + if (NPC.Distance(lanceSpawnOffset) <= 3200f) { Vector2 lanceWallStartingPosition = Vector2.Zero; Vector2 lanceWallDirection = Vector2.UnitY; @@ -757,7 +772,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float lanceWallSizeMult = 1.4f; totalProjectiles += 5f; lanceSpacing += 50f; - lanceWallSize *= (death ? 0.75f : 0.5f); + lanceWallSize *= (death ? 0.7f : 0.5f); float direction = 1f; int randomLanceWallType; @@ -771,7 +786,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[1] += 1f; // Sync the Calamity AI variables. - npc.SyncExtraAI(); + NPC.SyncExtraAI(); switch (randomLanceWallType) { @@ -813,7 +828,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } int projectileType = ProjectileID.FairyQueenLance; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = lanceDamage; for (float i = 0f; i <= 1f; i += 1f / totalProjectiles) { @@ -827,29 +842,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v2.ToRotation(), i); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnLocation, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v2.ToRotation(), i); } } // Chance to stop using the lance walls and switch to a different attack after 3 lance walls are used. if (Main.rand.NextBool(5 - ((int)calamityGlobalNPC.newAI[1] - 2)) && calamityGlobalNPC.newAI[1] >= 2f) { - npc.ai[1] = lanceWallPhaseTime; - npc.netUpdate = true; + NPC.ai[1] = lanceWallPhaseTime; + NPC.netUpdate = true; } } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? 24f : 48f) + 20f * lessTimeSpentPerPhaseMultiplier; - if (npc.ai[1] >= lanceWallPhaseTime + extraPhaseTime) + if (NPC.ai[1] >= lanceWallPhaseTime + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; calamityGlobalNPC.newAI[3] = 0f; calamityGlobalNPC.newAI[1] = 0f; calamityGlobalNPC.newAI[2] = 0f; - npc.SyncExtraAI(); - npc.netUpdate = true; + NPC.SyncExtraAI(); + NPC.netUpdate = true; } break; @@ -858,9 +873,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 8: case 9: - int chargeDirection = (npc.ai[0] != 8f) ? 1 : (-1); + int chargeDirection = (NPC.ai[0] != 8f) ? 1 : (-1); - AI_120_HallowBoss_DoMagicEffect(npc.Center, 5, Utils.GetLerpValue(40f, 90f, npc.ai[1], clamped: true), npc); + AI_120_HallowBoss_DoMagicEffect(NPC.Center, 5, Utils.GetLerpValue(40f, 90f, NPC.ai[1], clamped: true), NPC); float chargeGateValue = 40f; float playChargeSoundTime = 20f; @@ -870,34 +885,34 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float chargeVelocity = phase3 ? 100f : 70f; float chargeAcceleration = phase3 ? 0.1f : 0.07f; - if (npc.ai[1] <= chargeGateValue) + if (NPC.ai[1] <= chargeGateValue) { // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == playChargeSoundTime) - SoundEngine.PlaySound(SoundID.Item160, npc.Center); + if (NPC.ai[1] == playChargeSoundTime) + SoundEngine.PlaySound(SoundID.Item160, NPC.Center); - NPCAimedTarget targetData3 = npc.GetTargetData(); - destination = (targetData3.Invalid ? npc.Center : targetData3.Center) + new Vector2(chargeDirection * -chargeStartDistance, 0f); - npc.SimpleFlyMovement(npc.DirectionTo(destination).SafeNormalize(Vector2.Zero) * velocity, acceleration * 2f); + NPCAimedTarget targetData3 = NPC.GetTargetData(); + destination = (targetData3.Invalid ? NPC.Center : targetData3.Center) + new Vector2(chargeDirection * -chargeStartDistance, 0f); + NPC.SimpleFlyMovement(NPC.DirectionTo(destination).SafeNormalize(Vector2.Zero) * velocity, acceleration * 2f); - if (npc.ai[1] == chargeGateValue) - npc.velocity *= 0.3f; + if (NPC.ai[1] == chargeGateValue) + NPC.velocity *= 0.3f; } - else if (npc.ai[1] <= chargeGateValue + chargeDuration) + else if (NPC.ai[1] <= chargeGateValue + chargeDuration) { // Spawn Rainbow Streaks during charge. - if (npc.ai[1] == chargeGateValue + 1f) - SoundEngine.PlaySound(SoundID.Item164, npc.Center); + if (NPC.ai[1] == chargeGateValue + 1f) + SoundEngine.PlaySound(SoundID.Item164, NPC.Center); float rainbowStreakGateValue = 2f; - if ((npc.ai[1] - 1f) % rainbowStreakGateValue == 0f) + if ((NPC.ai[1] - 1f) % rainbowStreakGateValue == 0f) { int projectileType = ProjectileID.HallowBossRainbowStreak; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = boltDamage; - float ai3 = (npc.ai[1] - chargeGateValue - 1f) / chargeDuration; + float ai3 = (NPC.ai[1] - chargeGateValue - 1f) / chargeDuration; Vector2 rainbowStreakVelocity = new Vector2(0f, death ? -5f : -4f).RotatedBy(MathHelper.PiOver2 * Main.rand.NextFloatDirection()); if (phase2) rainbowStreakVelocity = new Vector2(0f, death ? -6f : -5f).RotatedBy(MathHelper.TwoPi * Main.rand.NextFloat()); @@ -911,51 +926,49 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, ai3); - if (Main.rand.NextBool(30) && CalamityWorld.LegendaryMode) - { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, NPC.target, ai3); + if (Main.getGoodWorld) Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].netUpdate = true; - } } // Spawn extra homing Rainbow Streaks per player. if (Main.netMode != NetmodeID.MultiplayerClient) { - int multiplayerStreakSpawnFrequency = (int)((npc.ai[1] - chargeGateValue - 1f) / rainbowStreakGateValue); + int multiplayerStreakSpawnFrequency = (int)((NPC.ai[1] - chargeGateValue - 1f) / rainbowStreakGateValue); for (int i = 0; i < Main.maxPlayers; i++) { - if (npc.Boss_CanShootExtraAt(i, multiplayerStreakSpawnFrequency % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, i, ai3); + if (NPC.Boss_CanShootExtraAt(i, multiplayerStreakSpawnFrequency % 3, 3, 2400f)) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, rainbowStreakVelocity, projectileType, projectileDamage, 0f, Main.myPlayer, i, ai3); } } } - npc.velocity = Vector2.Lerp(value2: new Vector2(chargeDirection * chargeVelocity, 0f), value1: npc.velocity, amount: chargeAcceleration); + NPC.velocity = Vector2.Lerp(value2: new Vector2(chargeDirection * chargeVelocity, 0f), value1: NPC.velocity, amount: chargeAcceleration); - if (npc.ai[1] == chargeGateValue + chargeDuration) - npc.velocity *= 0.45f; + if (NPC.ai[1] == chargeGateValue + chargeDuration) + NPC.velocity *= 0.45f; - npc.damage = (int)Math.Round(npc.defDamage * (dayTimeEnrage ? 3D : 1.5)); + // Unlike other temporary damage boosts from bosses, vanilla Empress AI increases damage as defDamage while dashing, so we don't need to account for it + NPC.damage = (int)Math.Round(ContactDamageCorrection.CalculateDamageForEnrage() * DashDamageMult); } else { // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - npc.velocity *= 0.92f; + NPC.velocity *= 0.92f; } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? 60f : 120f) * (lessTimeSpentPerPhaseMultiplier < 1 ? lessTimeSpentPerPhaseMultiplier * 1.5f : lessTimeSpentPerPhaseMultiplier); - if (npc.ai[1] >= totalPhaseTime && npc.ai[1] <= totalPhaseTime + 10f) + if (NPC.ai[1] >= totalPhaseTime && NPC.ai[1] <= totalPhaseTime + 10f) { - Vector2 center = npc.GetTargetData().Center; + Vector2 center = NPC.GetTargetData().Center; center += new Vector2(0f, -200f); - if (npc.Distance(center) > 200f) - center -= npc.DirectionTo(center) * 100f; + if (NPC.Distance(center) > 200f) + center -= NPC.DirectionTo(center) * 100f; - Vector2 targetDirection = center - npc.Center; + Vector2 targetDirection = center - NPC.Center; float lerpValue = Utils.GetLerpValue(100f, 600f, targetDirection.Length()); float targetDistance = targetDirection.Length(); @@ -963,14 +976,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (targetDistance > maxVelocity) targetDistance = maxVelocity; - npc.velocity = Vector2.Lerp(targetDirection.SafeNormalize(Vector2.Zero) * targetDistance, targetDirection / 6f, lerpValue); - npc.netUpdate = true; + NPC.velocity = Vector2.Lerp(targetDirection.SafeNormalize(Vector2.Zero) * targetDistance, targetDirection / 6f, lerpValue); + NPC.netUpdate = true; } - if (npc.ai[1] >= totalPhaseTime + extraPhaseTime) + if (NPC.ai[1] >= totalPhaseTime + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -979,65 +992,64 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 10: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item161, npc.Center); + if (NPC.ai[1] == 0f) + SoundEngine.PlaySound(SoundID.Item161, NPC.Center); - takeDamage = !(npc.ai[1] >= 30f) || !(npc.ai[1] <= 170f); + takeDamage = !(NPC.ai[1] >= 30f) || !(NPC.ai[1] <= 170f); - npc.velocity *= 0.95f; + NPC.velocity *= 0.95f; - if (npc.ai[1] == 90f) + if (NPC.ai[1] == 90f) { - if (npc.ai[3] == 0f) - npc.ai[3] = 1f; + if (NPC.ai[3] == 0f) + NPC.ai[3] = 1f; - if (npc.ai[3] == 2f) - npc.ai[3] = 3f; + if (NPC.ai[3] == 2f) + NPC.ai[3] = 3f; - npc.Center = npc.GetTargetData().Center + new Vector2(0f, -250f); - npc.netUpdate = true; + NPC.Center = NPC.GetTargetData().Center + new Vector2(0f, -250f); + NPC.netUpdate = true; } - npc.ai[1] += 1f; - if (npc.ai[1] >= 180f) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 180f) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } break; // Spawn Ethereal Lances ahead of the target. case 11: - // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item162, npc.Center); + if (NPC.ai[1] == 0f) + SoundEngine.PlaySound(SoundID.Item162, NPC.Center); float lanceGateValue2 = death ? 75f : 100f; - if (npc.ai[1] >= 6f && npc.ai[1] < 54f) + if (NPC.ai[1] >= 6f && NPC.ai[1] < 54f) { - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(-55f, -20f), 2, Utils.GetLerpValue(0f, lanceGateValue2, npc.ai[1], clamped: true), npc); - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(55f, -20f), 4, Utils.GetLerpValue(0f, lanceGateValue2, npc.ai[1], clamped: true), npc); + AI_120_HallowBoss_DoMagicEffect(NPC.Center + new Vector2(-55f, -20f), 2, Utils.GetLerpValue(0f, lanceGateValue2, NPC.ai[1], clamped: true), NPC); + AI_120_HallowBoss_DoMagicEffect(NPC.Center + new Vector2(55f, -20f), 4, Utils.GetLerpValue(0f, lanceGateValue2, NPC.ai[1], clamped: true), NPC); } - NPCAimedTarget targetData6 = npc.GetTargetData(); - targetCenter = targetData6.Invalid ? npc.Center : targetData6.Center; - if (npc.Distance(targetCenter + etherealLanceDistance) > movementDistanceGateValue) - npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); + NPCAimedTarget targetData6 = NPC.GetTargetData(); + targetCenter = targetData6.Invalid ? NPC.Center : targetData6.Center; + if (NPC.Distance(targetCenter + etherealLanceDistance) > movementDistanceGateValue) + NPC.SimpleFlyMovement(NPC.DirectionTo(targetCenter + etherealLanceDistance).SafeNormalize(Vector2.Zero) * velocity, acceleration); float etherealLanceGateValue = death ? 5f : 6f; if (dayTimeEnrage) etherealLanceGateValue -= 1f; - if (npc.ai[1] % etherealLanceGateValue == 0f && npc.ai[1] < lanceGateValue2) + if (NPC.ai[1] % etherealLanceGateValue == 0f && NPC.ai[1] < lanceGateValue2) { int numLances = phase3 ? 4 : 3; for (int i = 0; i < numLances; i++) @@ -1050,7 +1062,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float spawnDistance = 100f + (i * 100f); targetCenter = targetData6.Center; - if (npc.Distance(targetCenter) > 2400f) + if (NPC.Distance(targetCenter) > 2400f) continue; Vector2 straightLanceSpawnPredict = targetCenter + (oppositeLance ? -targetData6.Velocity : targetData6.Velocity) * 90; @@ -1065,19 +1077,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } int projectileType = ProjectileID.FairyQueenLance; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = lanceDamage; Vector2 v = straightLanceSpawnPredict - straightLanceSpawnDirection; if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), straightLanceSpawnDirection, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), npc.ai[1] / lanceGateValue2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), straightLanceSpawnDirection, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), NPC.ai[1] / lanceGateValue2); if (Main.netMode == NetmodeID.MultiplayerClient) continue; - int multiplayerExtraStraightLances = (int)(npc.ai[1] / etherealLanceGateValue); + int multiplayerExtraStraightLances = (int)(NPC.ai[1] / etherealLanceGateValue); for (int l = 0; l < Main.maxPlayers; l++) { - if (!npc.Boss_CanShootExtraAt(l, multiplayerExtraStraightLances % 3, 3, 2400f)) + if (!NPC.Boss_CanShootExtraAt(l, multiplayerExtraStraightLances % 3, 3, 2400f)) continue; Player player = Main.player[l]; @@ -1096,18 +1108,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } v = extraPlayerLancePredict - straightLanceSpawnDirection; - Projectile.NewProjectile(npc.GetSource_FromAI(), straightLanceSpawnDirection, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), npc.ai[1] / lanceGateValue2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), straightLanceSpawnDirection, Vector2.Zero, projectileType, projectileDamage, 0f, Main.myPlayer, v.ToRotation(), NPC.ai[1] / lanceGateValue2); } } } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? 24f : 48f) * lessTimeSpentPerPhaseMultiplier; - if (npc.ai[1] >= lanceGateValue2 + extraPhaseTime) + if (NPC.ai[1] >= lanceGateValue2 + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -1116,21 +1128,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 12: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; Vector2 projRandomOffset = new Vector2(-55f, -30f); - if (npc.ai[1] == 0f) + if (NPC.ai[1] == 0f) { - SoundEngine.PlaySound(SoundID.Item165, npc.Center); - npc.velocity = new Vector2(0f, -12f); + SoundEngine.PlaySound(SoundID.Item165, NPC.Center); + NPC.velocity = new Vector2(0f, -12f); } - npc.velocity *= 0.95f; + NPC.velocity *= 0.95f; - bool shouldSpawnStreaks = npc.ai[1] < 60f && npc.ai[1] >= 10f; + bool shouldSpawnStreaks = NPC.ai[1] < 60f && NPC.ai[1] >= 10f; if (shouldSpawnStreaks) - AI_120_HallowBoss_DoMagicEffect(npc.Center + projRandomOffset, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); + AI_120_HallowBoss_DoMagicEffect(NPC.Center + projRandomOffset, 1, Utils.GetLerpValue(0f, 60f, NPC.ai[1], clamped: true), NPC); int stationaryStreakSpawnFrequency = 4; if (dayTimeEnrage) @@ -1138,52 +1150,46 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (phase3) stationaryStreakSpawnFrequency *= 2; - float streakHomeTime = (npc.ai[1] - 10f) / 50f; - if ((int)npc.ai[1] % stationaryStreakSpawnFrequency == 0 && shouldSpawnStreaks) + float streakHomeTime = (NPC.ai[1] - 10f) / 50f; + if ((int)NPC.ai[1] % stationaryStreakSpawnFrequency == 0 && shouldSpawnStreaks) { int projectileType = ProjectileID.HallowBossRainbowStreak; - int projectileDamage = npc.GetProjectileDamage(projectileType) * projectileDamageMultiplier; + int projectileDamage = boltDamage; Vector2 vector = new Vector2(0f, (death ? -24f : -22f) - (phase3 ? ((death ? 6f : 4f) * streakHomeTime) : 0f)).RotatedBy(MathHelper.TwoPi * streakHomeTime); if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projRandomOffset, vector, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, streakHomeTime); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projRandomOffset, vector, projectileType, projectileDamage, 0f, Main.myPlayer, NPC.target, streakHomeTime); if (phase3) { - int proj2 = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projRandomOffset, -vector, projectileType, projectileDamage, 0f, Main.myPlayer, npc.target, 1f - streakHomeTime); - if (Main.rand.NextBool(15) && CalamityWorld.LegendaryMode) + int proj2 = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projRandomOffset, -vector, projectileType, projectileDamage, 0f, Main.myPlayer, NPC.target, 1f - streakHomeTime); + if (Main.getGoodWorld) { Main.projectile[proj2].extraUpdates += 1; Main.projectile[proj2].netUpdate = true; } } - - if (Main.rand.NextBool(15) && CalamityWorld.LegendaryMode) - { - Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].netUpdate = true; - } } // Spawn extra homing Rainbow Streaks per player. if (Main.netMode != NetmodeID.MultiplayerClient) { - int extraStationaryStreakSpawnFrequency = (int)(npc.ai[1] % stationaryStreakSpawnFrequency); + int extraStationaryStreakSpawnFrequency = (int)(NPC.ai[1] % stationaryStreakSpawnFrequency); for (int j = 0; j < Main.maxPlayers; j++) { - if (npc.Boss_CanShootExtraAt(j, extraStationaryStreakSpawnFrequency % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projRandomOffset, vector, projectileType, projectileDamage, 0f, Main.myPlayer, j, streakHomeTime); + if (NPC.Boss_CanShootExtraAt(j, extraStationaryStreakSpawnFrequency % 3, 3, 2400f)) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projRandomOffset, vector, projectileType, projectileDamage, 0f, Main.myPlayer, j, streakHomeTime); } } } - npc.ai[1] += 1f; + NPC.ai[1] += 1f; extraPhaseTime = (dayTimeEnrage ? 36f : 72f) + 30f * lessTimeSpentPerPhaseMultiplier; - if (npc.ai[1] >= (death ? 105f : 120f) + extraPhaseTime) + if (NPC.ai[1] >= (death ? 105f : 120f) + extraPhaseTime) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } break; @@ -1192,18 +1198,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 13: // Avoid cheap bullshit. - npc.damage = 0; + NPC.damage = 0; - if (npc.ai[1] == 0f) + if (NPC.ai[1] == 0f) { - SoundEngine.PlaySound(SoundID.Item165, npc.Center); - npc.velocity = new Vector2(0f, -7f); + SoundEngine.PlaySound(SoundID.Item165, NPC.Center); + NPC.velocity = new Vector2(0f, -7f); } - npc.velocity *= 0.95f; + NPC.velocity *= 0.95f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - NPCAimedTarget targetData = npc.GetTargetData(); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPCAimedTarget targetData = NPC.GetTargetData(); visible = false; @@ -1211,7 +1217,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool shouldDespawn = false; if (!trueDespawnFlag) { - if (npc.AI_120_HallowBoss_IsGenuinelyEnraged() && !bossRush) + if (NPC.AI_120_HallowBoss_IsGenuinelyEnraged() && !BossRushEvent.BossRushActive) { if (!Main.dayTime) shouldDespawn = true; @@ -1225,20 +1231,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!trueDespawnFlag) { - bool hasNoTarget = targetData.Invalid || npc.Distance(targetData.Center) > despawnDistanceGateValue; + bool hasNoTarget = targetData.Invalid || NPC.Distance(targetData.Center) > despawnDistanceGateValue; trueDespawnFlag = trueDespawnFlag || hasNoTarget; } - npc.alpha = Utils.Clamp(npc.alpha + trueDespawnFlag.ToDirectionInt() * 5, 0, 255); - bool alphaExtreme = npc.alpha == 0 || npc.alpha == 255; + NPC.alpha = Utils.Clamp(NPC.alpha + trueDespawnFlag.ToDirectionInt() * 5, 0, 255); + bool alphaExtreme = NPC.alpha == 0 || NPC.alpha == 255; int despawnDustAmt = 5; for (int i = 0; i < despawnDustAmt; i++) { - float despawnDustOpacity = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity); + float despawnDustOpacity = MathHelper.Lerp(1.3f, 0.7f, NPC.Opacity); Color newColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f); - int despawnRainbowDust = Dust.NewDust(npc.position - npc.Size * 0.5f, npc.width * 2, npc.height * 2, DustID.RainbowMk2, 0f, 0f, 0, newColor); - Main.dust[despawnRainbowDust].position = npc.Center + Main.rand.NextVector2Circular(npc.width, npc.height); + int despawnRainbowDust = Dust.NewDust(NPC.position - NPC.Size * 0.5f, NPC.width * 2, NPC.height * 2, DustID.RainbowMk2, 0f, 0f, 0, newColor); + Main.dust[despawnRainbowDust].position = NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height); Main.dust[despawnRainbowDust].velocity *= Main.rand.NextFloat() * 0.8f; Main.dust[despawnRainbowDust].noGravity = true; Main.dust[despawnRainbowDust].scale = 0.9f + Main.rand.NextFloat() * 1.2f; @@ -1254,1089 +1260,41 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 20f && alphaExtreme)) + NPC.ai[1] += 1f; + if (!(NPC.ai[1] >= 20f && alphaExtreme)) break; - if (npc.alpha == 255) + if (NPC.alpha == 255) { - npc.active = false; + NPC.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI); return false; } - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; break; } - npc.dontTakeDamage = !takeDamage; + NPC.dontTakeDamage = !takeDamage; if (phase3) - npc.defense = (int)Math.Round(npc.defDefense * 0.8); + NPC.defense = (int)Math.Round(NPC.defDefense * 0.8); else if (phase2) - npc.defense = (int)Math.Round(npc.defDefense * 1.2); + NPC.defense = (int)Math.Round(NPC.defDefense * 1.2); else - npc.defense = npc.defDefense; + NPC.defense = NPC.defDefense; - if ((npc.localAI[0] += 1f) >= 44f) - npc.localAI[0] = 0f; + if ((NPC.localAI[0] += 1f) >= 44f) + NPC.localAI[0] = 0f; if (visible) - npc.alpha = Utils.Clamp(npc.alpha - 5, 0, 255); + NPC.alpha = Utils.Clamp(NPC.alpha - 5, 0, 255); - Lighting.AddLight(npc.Center, Vector3.One * npc.Opacity); - - return false; - } - - public static bool VanillaEmpressofLightAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - Vector2 stopMovingLocation = new Vector2(-250f, -350f); - Vector2 stopMovingLocation3 = new Vector2(0f, -450f); - Vector2 stopMovingLocation4 = new Vector2(0f, -450f); - Vector2 stopMovingLocation5 = new Vector2(-80f, -500f); - - // Rotation - npc.rotation = npc.velocity.X * 0.005f; - - // Reset DR every frame - calamityGlobalNPC.DR = 0.15f; - - bool phase2 = npc.AI_120_HallowBoss_IsInPhase2(); - bool expertMode = Main.expertMode; - bool masterMode = Main.masterMode; - bool expertModePhase2 = phase2 && expertMode; - bool masterModePhase2 = phase2 && masterMode; - float phase2LifeRatio = masterMode ? 0.7f : expertMode ? 0.6f : 0.5f; - float phase3LifeRatio = masterMode ? 0.3f : 0.15f; - bool genuinePhase2 = npc.life / (float)npc.lifeMax <= phase2LifeRatio; - bool phase3 = npc.life / (float)npc.lifeMax <= phase3LifeRatio && expertMode; - - bool shouldBeInPhase2ButIsStillInPhase1 = npc.life / (float)npc.lifeMax <= phase2LifeRatio && !phase2; - if (shouldBeInPhase2ButIsStillInPhase1) - calamityGlobalNPC.DR = 0.99f; - - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = shouldBeInPhase2ButIsStillInPhase1 || npc.ai[0] == 6f; - - bool enraged = NPC.ShouldEmpressBeEnraged(); - if (npc.life == npc.lifeMax && enraged && !npc.AI_120_HallowBoss_IsGenuinelyEnraged()) - npc.ai[3] += 2f; - - calamityGlobalNPC.CurrentlyEnraged = !BossRushEvent.BossRushActive && enraged; - - int projectileDamageMultiplier = enraged ? 2 : 1; - - bool becomeVisible = true; - - float moveSpeed = masterMode ? 0.6f : expertMode ? 0.55f : 0.5f; - float desiredVelocity = masterMode ? 14.4f : expertMode ? 13.2f : 12f; - float stopMovingDistance = 40f; - float despawnDistance = 6400f; - int lanceDamage = npc.GetProjectileDamage(ProjectileID.FairyQueenLance); - int rainbowStreakDamage = npc.GetProjectileDamage(ProjectileID.HallowBossRainbowStreak); - int lastingRainbowDamage = npc.GetProjectileDamage(ProjectileID.HallowBossLastingRainbow); - int sunDanceDamage = npc.GetProjectileDamage(ProjectileID.FairyQueenSunDance); - - lanceDamage *= projectileDamageMultiplier; - rainbowStreakDamage *= projectileDamageMultiplier; - lastingRainbowDamage *= projectileDamageMultiplier; - sunDanceDamage *= projectileDamageMultiplier; - - if (enraged) - expertMode = true; - - bool takeDamage = true; - int reducedAttackCooldown = 0; - if (phase2) - reducedAttackCooldown += 15; - if (expertMode) - reducedAttackCooldown += 5; - - // Variables for dust visuals on spawn and in phase 3 - float playSpawnSoundTime = 10f; - float stopSpawningDustTime = 150f; - float spawnTime = 180f; - - // Do visual stuff in phase 3 - float maxOpacity = phase3 ? 0.7f : 1f; - int minAlpha = 255 - (int)(255 * maxOpacity); - if (phase3) - { - if (calamityGlobalNPC.newAI[0] == playSpawnSoundTime) - SoundEngine.PlaySound(SoundID.Item161, npc.Center); - - if (calamityGlobalNPC.newAI[0] > playSpawnSoundTime && calamityGlobalNPC.newAI[0] < stopSpawningDustTime) - CreateSpawnDust(npc, false); - - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= stopSpawningDustTime) - { - calamityGlobalNPC.newAI[0] = playSpawnSoundTime + 1f; - npc.SyncExtraAI(); - } - } - - switch ((int)npc.ai[0]) - { - case 0: - - // Avoid cheap bullshit. - npc.damage = 0; - - if (npc.ai[1] == 0f) - { - npc.velocity = new Vector2(0f, 5f); - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + new Vector2(0f, -80f), Vector2.Zero, ProjectileID.HallowBossDeathAurora, 0, 0f, Main.myPlayer); - } - - if (npc.ai[1] == playSpawnSoundTime) - SoundEngine.PlaySound(SoundID.Item161, npc.Center); - - npc.velocity *= 0.95f; - if (npc.ai[1] > playSpawnSoundTime && npc.ai[1] < stopSpawningDustTime) - CreateSpawnDust(npc); - - npc.ai[1] += 1f; - becomeVisible = false; - takeDamage = false; - npc.Opacity = MathHelper.Clamp(npc.ai[1] / spawnTime, 0f, 1f); - if (npc.ai[1] >= spawnTime) - { - if (enraged && !npc.AI_120_HallowBoss_IsGenuinelyEnraged()) - npc.ai[3] += 2f; - - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - } - - break; - - case 1: - { - // Avoid cheap bullshit. - npc.damage = 0; - - float phaseTime = (phase2 ? 20f : 45f); - if (masterMode) - phaseTime /= 2f; - if (Main.getGoodWorld) - phaseTime /= 2f; - if (phaseTime < 10f) - phaseTime = 10f; - - if (npc.ai[1] <= 10f) - { - if (npc.ai[1] == 0f) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - NPCAimedTarget targetData = npc.GetTargetData(); - if (targetData.Invalid) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] += 1f; - npc.velocity /= 4f; - npc.netUpdate = true; - break; - } - - Vector2 center = targetData.Center; - npc.DirectionTo(center); - center += new Vector2(0f, -300f); - if (npc.Distance(center) > 200f) - center -= npc.DirectionTo(center) * 100f; - - Vector2 distanceFromTarget = center - npc.Center; - float lerpValue = Utils.GetLerpValue(100f, 600f, distanceFromTarget.Length(), clamped: true); - float movementVelocity = distanceFromTarget.Length(); - if (movementVelocity > 18f) - movementVelocity = 18f; - - npc.velocity = Vector2.Lerp(distanceFromTarget.SafeNormalize(Vector2.Zero) * movementVelocity, distanceFromTarget / 6f, lerpValue); - - npc.netUpdate = true; - } - - if (npc.velocity.Length() > 16f && npc.ai[1] > 10f) - npc.velocity /= 2f; - - npc.velocity *= 0.92f; - npc.ai[1] += 1f; - if (!(npc.ai[1] >= phaseTime)) - break; - - int phaseIncrement = (int)npc.ai[2]; - int phase = 2; - int phaseDivisor = 0; - if (!phase2) - { - int num38 = phaseDivisor++; - int num39 = phaseDivisor++; - int num40 = phaseDivisor++; - int num41 = phaseDivisor++; - int num42 = phaseDivisor++; - int num43 = phaseDivisor++; - int num44 = phaseDivisor++; - int num45 = phaseDivisor++; - int num46 = phaseDivisor++; - int num47 = phaseDivisor++; - if (phaseIncrement % phaseDivisor == num38) - phase = 2; - - if (phaseIncrement % phaseDivisor == num39) - phase = 8; - - if (phaseIncrement % phaseDivisor == num40) - phase = 6; - - if (phaseIncrement % phaseDivisor == num41) - phase = 8; - - if (phaseIncrement % phaseDivisor == num42) - phase = 5; - - if (phaseIncrement % phaseDivisor == num43) - phase = 2; - - if (phaseIncrement % phaseDivisor == num44) - phase = 8; - - if (phaseIncrement % phaseDivisor == num45) - phase = 4; - - if (phaseIncrement % phaseDivisor == num46) - phase = 8; - - if (phaseIncrement % phaseDivisor == num47) - phase = 5; - - if (genuinePhase2) - phase = 10; - } - - if (phase2) - { - int num48 = phaseDivisor++; - int num49 = phaseDivisor++; - int num50 = phaseDivisor++; - int num51 = -1; - if (expertMode) - num51 = phaseDivisor++; - - int num52 = phaseDivisor++; - int num53 = phaseDivisor++; - int num54 = phaseDivisor++; - int num55 = phaseDivisor++; - int num56 = phaseDivisor++; - int num57 = phaseDivisor++; - if (phaseIncrement % phaseDivisor == num48) - phase = 7; - - if (phaseIncrement % phaseDivisor == num49) - phase = phase3 ? 8 : 2; - - if (phaseIncrement % phaseDivisor == num50) - phase = 8; - - if (phaseIncrement % phaseDivisor == num52) - phase = 5; - - if (phaseIncrement % phaseDivisor == num53) - phase = 2; - - if (phaseIncrement % phaseDivisor == num54) - phase = phase3 ? 4 : 6; - - if (phaseIncrement % phaseDivisor == num54) - phase = phase3 ? 7 : 6; - - if (phaseIncrement % phaseDivisor == num55) - phase = 4; - - if (phaseIncrement % phaseDivisor == num56) - phase = 8; - - if (phaseIncrement % phaseDivisor == num51) - phase = 11; - - if (phaseIncrement % phaseDivisor == num57) - phase = 12; - } - - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - NPCAimedTarget targetData2 = npc.GetTargetData(); - bool transitionToEnrage = false; - if (npc.AI_120_HallowBoss_IsGenuinelyEnraged()) - { - if (!Main.dayTime) - transitionToEnrage = true; - - if (Main.dayTime && Main.time >= 53400D) - transitionToEnrage = true; - } - - if (targetData2.Invalid || npc.Distance(targetData2.Center) > despawnDistance || transitionToEnrage) - phase = 13; - - if (phase == 8 && targetData2.Center.X > npc.Center.X) - phase = 9; - - if (expertMode && phase != 5 && phase != 12) - npc.velocity = npc.DirectionFrom(targetData2.Center).SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2 * (float)(targetData2.Center.X > npc.Center.X).ToDirectionInt()) * 20f; - - npc.ai[0] = phase; - npc.ai[1] = 0f; - - int oneInXChance = masterMode ? 3 : 4; - if (phase3) - oneInXChance--; - - float numPhaseIncrements = expertMode ? (Main.rand.NextBool(oneInXChance) ? 2f : 1f) : 1f; - npc.ai[2] += numPhaseIncrements; - npc.netUpdate = true; - - break; - } - - case 2: - { - // Avoid cheap bullshit. - npc.damage = 0; - - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item164, npc.Center); - - float extraPhaseTime = (masterMode ? 30f : expertMode ? 60f : 90f) - (float)reducedAttackCooldown; - Vector2 offset = new Vector2(-55f, -30f); - NPCAimedTarget targetData11 = npc.GetTargetData(); - Vector2 targetCenter = (targetData11.Invalid ? npc.Center : targetData11.Center); - if (npc.Distance(targetCenter + stopMovingLocation) > stopMovingDistance) - npc.SimpleFlyMovement(npc.DirectionTo(targetCenter + stopMovingLocation).SafeNormalize(Vector2.Zero) * desiredVelocity, moveSpeed); - - if (npc.ai[1] < 60f) - AI_120_HallowBoss_DoMagicEffect(npc.Center + offset, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); - - int rainbowStreakGateValue = 3; - if (expertMode) - rainbowStreakGateValue = 2; - if (phase3) - rainbowStreakGateValue *= 2; - - if ((int)npc.ai[1] % rainbowStreakGateValue == 0 && npc.ai[1] < 60f) - { - float ai3 = npc.ai[1] / 60f; - Vector2 rainbowStreakVelocity = new Vector2(0f, -6f - (masterMode ? (ai3 * 4f) : expertMode ? (ai3 * 2f) : 0f)).RotatedBy(MathHelper.PiOver2 * Main.rand.NextFloatDirection()); - if (expertModePhase2) - rainbowStreakVelocity = new Vector2(0f, -10f - (masterMode ? (ai3 * 5f) : expertMode ? (ai3 * 2.5f) : 0f)).RotatedBy(MathHelper.TwoPi * Main.rand.NextFloat()); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, rainbowStreakVelocity, ProjectileID.HallowBossRainbowStreak, rainbowStreakDamage, 0f, Main.myPlayer, npc.target, ai3); - if (phase3) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, -rainbowStreakVelocity, ProjectileID.HallowBossRainbowStreak, rainbowStreakDamage, 0f, Main.myPlayer, npc.target, 1f - ai3); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num92 = (int)(npc.ai[1] / (float)rainbowStreakGateValue); - for (int num93 = 0; num93 < Main.maxPlayers; num93++) - { - if (npc.Boss_CanShootExtraAt(num93, num92 % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, rainbowStreakVelocity, ProjectileID.HallowBossRainbowStreak, rainbowStreakDamage, 0f, Main.myPlayer, num93, ai3); - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= 60f + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - /*case 3: - { - npc.ai[1] += 1f; - NPCAimedTarget targetData8 = npc.GetTargetData(); - Vector2 vector23 = (targetData8.Invalid ? npc.Center : targetData8.Center); - if (npc.Distance(vector23 + vector2) > num3) - npc.SimpleFlyMovement(npc.DirectionTo(vector23 + vector2).SafeNormalize(Vector2.Zero) * num2, num); - - if ((int)npc.ai[1] % 180 == 0) - { - Vector2 vector24 = new Vector2(0f, -100f); - Projectile.NewProjectile(npc.GetSource_FromAI(), targetData8.Center + vector24, Vector2.Zero, ProjectileID.HallowBossDeathAurora, num5, 0f, Main.myPlayer); - } - - if (npc.ai[1] >= 120f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - }*/ - - case 4: - { - // Avoid cheap bullshit. - npc.damage = 0; - - float extraPhaseTime = 20 - reducedAttackCooldown; - - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item162, npc.Center); - - float lanceGateValue = masterMode ? 75f : 100f; - if (npc.ai[1] >= 6f && npc.ai[1] < 54f) - { - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(-55f, -20f), 2, Utils.GetLerpValue(0f, lanceGateValue, npc.ai[1], clamped: true), npc); - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(55f, -20f), 4, Utils.GetLerpValue(0f, lanceGateValue, npc.ai[1], clamped: true), npc); - } - - NPCAimedTarget targetData = npc.GetTargetData(); - Vector2 targetLocation = (targetData.Invalid ? npc.Center : targetData.Center); - if (npc.Distance(targetLocation + stopMovingLocation3) > stopMovingDistance) - npc.SimpleFlyMovement(npc.DirectionTo(targetLocation + stopMovingLocation3).SafeNormalize(Vector2.Zero) * desiredVelocity, moveSpeed); - - int radialSpawnOffset = masterMode ? 6 : expertMode ? 5 : 4; - int lanceSpawnGateValue = masterMode ? 3 : 4; - if ((int)npc.ai[1] % lanceSpawnGateValue == 0 && npc.ai[1] < lanceGateValue) - { - int lanceAmount = phase3 ? 2 : 1; - for (int i = 0; i < lanceAmount; i++) - { - int num85 = (int)npc.ai[1] / lanceSpawnGateValue; - radialSpawnOffset += (masterMode ? 3 : 2) * i; - Vector2 radialOffset = Vector2.UnitX.RotatedBy((float)Math.PI / (float)(radialSpawnOffset * 2) + (float)num85 * ((float)Math.PI / (float)radialSpawnOffset) + 0f); - if (masterMode) - radialOffset.X += (radialOffset.X > 0f ? -0.5f : 0.5f); - else if (!expertMode) - radialOffset.X += (radialOffset.X > 0f ? 0.5f : -0.5f); - - radialOffset = radialOffset.SafeNormalize(Vector2.UnitY); - float lanceSpawnDistance = 300f; - if (expertMode) - lanceSpawnDistance = 450f; - - Vector2 targetCenter = targetData.Center; - if (npc.Distance(targetCenter) > 2400f) - continue; - - if (Vector2.Dot(targetData.Velocity.SafeNormalize(Vector2.UnitY), radialOffset) > 0f) - radialOffset *= -1f; - - int targetVelocityOffset = 90; - Vector2 vector31 = targetCenter + targetData.Velocity * targetVelocityOffset; - Vector2 vector32 = targetCenter + radialOffset * lanceSpawnDistance - targetData.Velocity * 30f; - if (vector32.Distance(targetCenter) < lanceSpawnDistance) - { - Vector2 vector33 = targetCenter - vector32; - if (vector33 == Vector2.Zero) - vector33 = radialOffset; - - vector32 = targetCenter - vector33.SafeNormalize(Vector2.UnitY) * lanceSpawnDistance; - } - - Vector2 v3 = vector31 - vector32; - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector32, Vector2.Zero, ProjectileID.FairyQueenLance, lanceDamage, 0f, Main.myPlayer, v3.ToRotation(), npc.ai[1] / lanceGateValue); - - if (Main.netMode == NetmodeID.MultiplayerClient) - continue; - - int num88 = (int)(npc.ai[1] / (float)lanceSpawnGateValue); - for (int num89 = 0; num89 < Main.maxPlayers; num89++) - { - if (!npc.Boss_CanShootExtraAt(num89, num88 % 3, 3, 2400f)) - continue; - - Player player2 = Main.player[num89]; - targetCenter = player2.Center; - if (Vector2.Dot(player2.velocity.SafeNormalize(Vector2.UnitY), radialOffset) > 0f) - radialOffset *= -1f; - - Vector2 vector34 = targetCenter + player2.velocity * targetVelocityOffset; - vector32 = targetCenter + radialOffset * lanceSpawnDistance - player2.velocity * 30f; - if (vector32.Distance(targetCenter) < lanceSpawnDistance) - { - Vector2 vector35 = targetCenter - vector32; - if (vector35 == Vector2.Zero) - vector35 = radialOffset; - - vector32 = targetCenter - vector35.SafeNormalize(Vector2.UnitY) * lanceSpawnDistance; - } - - v3 = vector34 - vector32; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector32, Vector2.Zero, ProjectileID.FairyQueenLance, lanceDamage, 0f, Main.myPlayer, v3.ToRotation(), npc.ai[1] / lanceGateValue); - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= lanceGateValue + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 5: - { - // Avoid cheap bullshit. - npc.damage = 0; - - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item163, npc.Center); - - float extraPhaseTime = masterMode ? 22f : 30f; - extraPhaseTime -= (float)reducedAttackCooldown; - - Vector2 offset = new Vector2(55f, -30f); - Vector2 lastingRainbowInitialSpawnLocation = npc.Center + offset; - - float lastingRainbowGateValue = 42f; - if (npc.ai[1] < lastingRainbowGateValue) - AI_120_HallowBoss_DoMagicEffect(npc.Center + offset, 3, Utils.GetLerpValue(0f, lastingRainbowGateValue, npc.ai[1], clamped: true), npc); - - NPCAimedTarget targetData = npc.GetTargetData(); - Vector2 targetLocation = (targetData.Invalid ? npc.Center : targetData.Center); - if (npc.Distance(targetLocation + stopMovingLocation4) > stopMovingDistance) - npc.SimpleFlyMovement(npc.DirectionTo(targetLocation + stopMovingLocation4).SafeNormalize(Vector2.Zero) * desiredVelocity, moveSpeed); - - if ((int)npc.ai[1] % (int)lastingRainbowGateValue == 0 && npc.ai[1] < lastingRainbowGateValue) - { - float lastingRainbowRandomRotation = MathHelper.TwoPi * Main.rand.NextFloat(); - float numLastingRainbows = 13f; - for (float i = 0f; i < 1f; i += 1f / numLastingRainbows) - { - float ai1 = i; - Vector2 lastingRainbowVelocity = Vector2.UnitY.RotatedBy(MathHelper.PiOver2 + MathHelper.TwoPi * ai1 + lastingRainbowRandomRotation); - Vector2 lastingRainbowSpawnLocation = lastingRainbowInitialSpawnLocation + lastingRainbowVelocity.RotatedBy(-MathHelper.PiOver2) * 30f; - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), lastingRainbowSpawnLocation, lastingRainbowVelocity * (masterMode ? 10f : 8f), ProjectileID.HallowBossLastingRainbow, lastingRainbowDamage, 0f, Main.myPlayer, 0f, ai1); - - if (phase3) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), lastingRainbowSpawnLocation, lastingRainbowVelocity * (masterMode ? 12f : 10f), ProjectileID.HallowBossRainbowStreak, rainbowStreakDamage, 0f, Main.myPlayer, npc.target, ai1); - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= lastingRainbowGateValue + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 6: - { - // Avoid cheap bullshit. - npc.damage = 0; - - // Increase durability. - calamityGlobalNPC.DR = shouldBeInPhase2ButIsStillInPhase1 ? 0.99f : (BossRushEvent.BossRushActive ? 0.99f : 0.575f); - - float extraPhaseTime = (masterMode ? 105 : expertMode ? 120 : 135) - reducedAttackCooldown; - Vector2 offset = new Vector2(0f, -100f); - Vector2 sunDanceSpawnLocation = npc.Center + offset; - NPCAimedTarget targetData = npc.GetTargetData(); - Vector2 targetLocation = (targetData.Invalid ? npc.Center : targetData.Center); - if (npc.Distance(targetLocation + stopMovingLocation5) > stopMovingDistance) - npc.SimpleFlyMovement(npc.DirectionTo(targetLocation + stopMovingLocation5).SafeNormalize(Vector2.Zero) * desiredVelocity * 0.3f, moveSpeed * 0.7f); - - float phaseGateValue = masterMode ? 120f : 180f; - int sunDanceGateValue = 60; - if ((int)npc.ai[1] % sunDanceGateValue == 0 && npc.ai[1] < phaseGateValue) - { - int sunDanceSpawnOffset = (int)npc.ai[1] / sunDanceGateValue; - int targetLocationX = ((targetData.Center.X > npc.Center.X) ? 1 : 0); - float numSunDancePetals = masterMode ? 9f : expertMode ? 8f : 6f; - float sunDanceIncrement = 1f / numSunDancePetals; - for (float i = 0f; i < 1f; i += sunDanceIncrement) - { - float radialOffset = (i + sunDanceIncrement * 0.5f + (float)sunDanceSpawnOffset * sunDanceIncrement * 0.5f) % 1f; - float ai = MathHelper.TwoPi * (radialOffset + (float)targetLocationX); - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), sunDanceSpawnLocation, Vector2.Zero, ProjectileID.FairyQueenSunDance, sunDanceDamage, 0f, Main.myPlayer, ai, npc.whoAmI); - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= phaseGateValue + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 7: - { - // Avoid cheap bullshit. - npc.damage = 0; - - float extraPhaseTime = masterMode ? 34f : expertMode ? 40f : 20f; - float lanceGateValue = masterMode ? 34f : expertMode ? 40f : 60f; - float totalLanceWalls = expertMode ? 6f : 4f; - float lancePhaseTime = lanceGateValue * totalLanceWalls; - - extraPhaseTime -= (float)reducedAttackCooldown; - NPCAimedTarget targetData = npc.GetTargetData(); - Vector2 vector25 = (targetData.Invalid ? npc.Center : targetData.Center); - if (npc.Distance(vector25 + stopMovingLocation4) > stopMovingDistance) - npc.SimpleFlyMovement(npc.DirectionTo(vector25 + stopMovingLocation4).SafeNormalize(Vector2.Zero) * desiredVelocity * 0.4f, moveSpeed); - - if ((float)(int)npc.ai[1] % lanceGateValue == 0f && npc.ai[1] < lancePhaseTime) - { - SoundEngine.PlaySound(SoundID.Item162, npc.Center); - Main.rand.NextFloat(); - int lanceWallType = (int)npc.ai[1] / (int)lanceGateValue; - float numLances = phase3 ? (masterMode ? 18f : 15f) : 13f; - float distanceBetweenLances = phase3 ? (masterMode ? 125f : 135f) : 150f; - float lanceWallLength = numLances * distanceBetweenLances; - Vector2 lanceSpawnOffset = targetData.Center; - if (npc.Distance(lanceSpawnOffset) <= 3200f) - { - Vector2 vector26 = Vector2.Zero; - Vector2 lanceDirection = Vector2.UnitY; - float num77 = 0.4f; - float num78 = 1.4f; - float num79 = 1f; - if (expertMode) - { - numLances += 5f; - distanceBetweenLances += 50f; - lanceWallLength *= (masterMode ? 0.75f : 0.5f); - } - - switch (lanceWallType) - { - case 0: - lanceSpawnOffset += new Vector2((0f - lanceWallLength) / 2f, 0f) * num79; - vector26 = new Vector2(0f, lanceWallLength); - lanceDirection = Vector2.UnitX; - break; - case 1: - lanceSpawnOffset += new Vector2(lanceWallLength / 2f, distanceBetweenLances / 2f) * num79; - vector26 = new Vector2(0f, lanceWallLength); - lanceDirection = -Vector2.UnitX; - break; - case 2: - lanceSpawnOffset += new Vector2(0f - lanceWallLength, 0f - lanceWallLength) * num77 * num79; - vector26 = new Vector2(lanceWallLength * num78, 0f); - lanceDirection = new Vector2(1f, 1f); - break; - case 3: - lanceSpawnOffset += new Vector2(lanceWallLength * num77 + distanceBetweenLances / 2f, (0f - lanceWallLength) * num77) * num79; - vector26 = new Vector2((0f - lanceWallLength) * num78, 0f); - lanceDirection = new Vector2(-1f, 1f); - break; - case 4: - lanceSpawnOffset += new Vector2(0f - lanceWallLength, lanceWallLength) * num77 * num79; - vector26 = new Vector2(lanceWallLength * num78, 0f); - lanceDirection = lanceSpawnOffset.DirectionTo(targetData.Center); - break; - case 5: - lanceSpawnOffset += new Vector2(lanceWallLength * num77 + distanceBetweenLances / 2f, lanceWallLength * num77) * num79; - vector26 = new Vector2((0f - lanceWallLength) * num78, 0f); - lanceDirection = lanceSpawnOffset.DirectionTo(targetData.Center); - break; - } - - for (float lance = 0f; lance <= 1f; lance += 1f / numLances) - { - Vector2 origin = lanceSpawnOffset + vector26 * (lance - 0.5f); - Vector2 lanceRotation = lanceDirection; - if (expertMode) - { - Vector2 predictionVector = targetData.Velocity * 20f * lance; - Vector2 value2 = origin.DirectionTo(targetData.Center + predictionVector); - lanceRotation = Vector2.Lerp(lanceDirection, value2, 0.75f).SafeNormalize(Vector2.UnitY); - } - - float ai2 = lance; - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), origin, Vector2.Zero, ProjectileID.FairyQueenLance, lanceDamage, 0f, Main.myPlayer, lanceRotation.ToRotation(), ai2); - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= lancePhaseTime + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 8: - case 9: - { - float extraPhaseTime = 20 - reducedAttackCooldown; - float startDashTime = 40f; - float playDashSoundTime = 20f; - float endDashTime = phase3 ? 75f : 90f; - int dashStartDistance = phase3 ? 750 : 550; - int dashVelocity = phase3 ? 80 : 50; - float dashAcceleration = phase3 ? 0.08f : 0.05f; - - int dashDirection = (npc.ai[0] != 8f ? 1 : -1); - AI_120_HallowBoss_DoMagicEffect(npc.Center, 5, Utils.GetLerpValue(startDashTime, endDashTime, npc.ai[1], clamped: true), npc); - - if (npc.ai[1] <= startDashTime) - { - // Avoid cheap bullshit. - npc.damage = 0; - - if (npc.ai[1] == playDashSoundTime) - SoundEngine.PlaySound(SoundID.Item160, npc.Center); - - NPCAimedTarget targetData = npc.GetTargetData(); - Vector2 destination = (targetData.Invalid ? npc.Center : targetData.Center) + new Vector2(dashDirection * -dashStartDistance, 0f); - npc.SimpleFlyMovement(npc.DirectionTo(destination).SafeNormalize(Vector2.Zero) * desiredVelocity, moveSpeed * 2f); - if (npc.ai[1] == startDashTime) - npc.velocity *= 0.3f; - } - else if (npc.ai[1] <= endDashTime) - { - npc.velocity = Vector2.Lerp(value2: new Vector2(dashDirection * dashVelocity, 0f), value1: npc.velocity, amount: dashAcceleration); - if (npc.ai[1] == endDashTime) - npc.velocity *= 0.7f; - - npc.damage = (int)Math.Round(npc.defDamage * (enraged ? 3D : 1.5)); - } - else - { - // Avoid cheap bullshit. - npc.damage = 0; - - npc.velocity *= 0.92f; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= endDashTime + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 10: - { - // Avoid cheap bullshit. - npc.damage = 0; - - float extraPhaseTime = 20 - reducedAttackCooldown; - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item161, npc.Center); - - takeDamage = !(npc.ai[1] >= 30f) || !(npc.ai[1] <= 170f); - npc.velocity *= 0.95f; - if (npc.ai[1] == 90f) - { - if (npc.ai[3] == 0f) - npc.ai[3] = 1f; - - if (npc.ai[3] == 2f) - npc.ai[3] = 3f; - - npc.Center = npc.GetTargetData().Center + new Vector2(0f, -250f); - npc.netUpdate = true; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= 180f + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 11: - { - // Avoid cheap bullshit. - npc.damage = 0; - - if (npc.ai[1] == 0f) - SoundEngine.PlaySound(SoundID.Item162, npc.Center); - - float extraPhaseTime = 20 - reducedAttackCooldown; - float lanceGateValue = masterMode ? 75f : 100f; - if (npc.ai[1] >= 6f && npc.ai[1] < 54f) - { - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(-55f, -20f), 2, Utils.GetLerpValue(0f, lanceGateValue, npc.ai[1], clamped: true), npc); - AI_120_HallowBoss_DoMagicEffect(npc.Center + new Vector2(55f, -20f), 4, Utils.GetLerpValue(0f, lanceGateValue, npc.ai[1], clamped: true), npc); - } - - NPCAimedTarget targetData = npc.GetTargetData(); - Vector2 targetLocation = (targetData.Invalid ? npc.Center : targetData.Center); - if (npc.Distance(targetLocation + stopMovingLocation3) > stopMovingDistance) - npc.SimpleFlyMovement(npc.DirectionTo(targetLocation + stopMovingLocation3).SafeNormalize(Vector2.Zero) * desiredVelocity, moveSpeed); - - if ((int)npc.ai[1] % 3 == 0 && npc.ai[1] < lanceGateValue) - { - int numLances = phase3 ? 2 : 1; - for (int i = 0; i < numLances; i++) - { - // Spawn another lance in the opposite location - bool oppositeLance = i == 1; - - Vector2 vector13 = oppositeLance ? targetData.Velocity : -targetData.Velocity; - vector13.SafeNormalize(-Vector2.UnitY); - float lanceSpawnOffset = 100f; - Vector2 targetCenter = targetData.Center; - if (npc.Distance(targetCenter) > 2400f) - continue; - - int targetVelocityOffset = 90; - Vector2 vector14 = targetCenter + (oppositeLance ? -targetData.Velocity : targetData.Velocity) * targetVelocityOffset; - Vector2 lanceSpawnLocation = targetCenter + vector13 * lanceSpawnOffset; - if (lanceSpawnLocation.Distance(targetCenter) < lanceSpawnOffset) - { - Vector2 vector16 = targetCenter - lanceSpawnLocation; - if (vector16 == Vector2.Zero) - vector16 = vector13; - - lanceSpawnLocation = targetCenter - vector16.SafeNormalize(Vector2.UnitY) * lanceSpawnOffset; - } - - Vector2 rotationVector = vector14 - lanceSpawnLocation; - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), lanceSpawnLocation, Vector2.Zero, ProjectileID.FairyQueenLance, lanceDamage, 0f, Main.myPlayer, rotationVector.ToRotation(), npc.ai[1] / lanceGateValue); - - if (Main.netMode == NetmodeID.MultiplayerClient) - continue; - - int rotationIndex = (int)(npc.ai[1] / 3f); - for (int l = 0; l < Main.maxPlayers; l++) - { - if (!npc.Boss_CanShootExtraAt(l, rotationIndex % 3, 3, 2400f)) - continue; - - Player player = Main.player[l]; - vector13 = oppositeLance ? player.velocity : -player.velocity; - vector13.SafeNormalize(-Vector2.UnitY); - lanceSpawnOffset = 100f; - targetCenter = player.Center; - targetVelocityOffset = 90; - Vector2 lanceDestination = targetCenter + (oppositeLance ? -player.velocity : player.velocity) * targetVelocityOffset; - lanceSpawnLocation = targetCenter + vector13 * lanceSpawnOffset; - if (lanceSpawnLocation.Distance(targetCenter) < lanceSpawnOffset) - { - Vector2 vector18 = targetCenter - lanceSpawnLocation; - if (vector18 == Vector2.Zero) - vector18 = vector13; - - lanceSpawnLocation = targetCenter - vector18.SafeNormalize(Vector2.UnitY) * lanceSpawnOffset; - } - - rotationVector = lanceDestination - lanceSpawnLocation; - Projectile.NewProjectile(npc.GetSource_FromAI(), lanceSpawnLocation, Vector2.Zero, ProjectileID.FairyQueenLance, lanceDamage, 0f, Main.myPlayer, rotationVector.ToRotation(), npc.ai[1] / lanceGateValue); - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= lanceGateValue + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 12: - { - // Avoid cheap bullshit. - npc.damage = 0; - - float extraPhaseTime = (masterMode ? 30f : expertMode ? 60f : 90f) - (float)reducedAttackCooldown; - Vector2 offset = new Vector2(-55f, -30f); - if (npc.ai[1] == 0f) - { - SoundEngine.PlaySound(SoundID.Item165, npc.Center); - npc.velocity = new Vector2(0f, -12f); - } - - npc.velocity *= 0.95f; - bool shootRainbowStreaks = npc.ai[1] < 60f && npc.ai[1] >= 10f; - if (shootRainbowStreaks) - AI_120_HallowBoss_DoMagicEffect(npc.Center + offset, 1, Utils.GetLerpValue(0f, 60f, npc.ai[1], clamped: true), npc); - - int rainbowStreakGateValue = 6; - if (expertMode) - rainbowStreakGateValue = 4; - if (phase3) - rainbowStreakGateValue *= 2; - - float radialOffset = (npc.ai[1] - 10f) / 50f; - if ((int)npc.ai[1] % rainbowStreakGateValue == 0 && shootRainbowStreaks) - { - Vector2 rainbowStreakVelocity = (rainbowStreakVelocity = new Vector2(0f, -20f - (phase3 ? ((masterMode ? 10f : 5f) * radialOffset) : 0f)).RotatedBy(MathHelper.TwoPi * radialOffset)); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, rainbowStreakVelocity, ProjectileID.HallowBossRainbowStreak, rainbowStreakDamage, 0f, Main.myPlayer, npc.target, radialOffset); - if (phase3) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, -rainbowStreakVelocity, ProjectileID.HallowBossRainbowStreak, rainbowStreakDamage, 0f, Main.myPlayer, npc.target, 1f - radialOffset); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num24 = (int)(npc.ai[1] % (float)rainbowStreakGateValue); - for (int j = 0; j < Main.maxPlayers; j++) - { - if (npc.Boss_CanShootExtraAt(j, num24 % 3, 3, 2400f)) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + offset, rainbowStreakVelocity, ProjectileID.HallowBossRainbowStreak, rainbowStreakDamage, 0f, Main.myPlayer, j, radialOffset); - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= 60f + extraPhaseTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - break; - } - - case 13: - { - // Avoid cheap bullshit. - npc.damage = 0; - - if (npc.ai[1] == 0f) - { - SoundEngine.PlaySound(SoundID.Item165, npc.Center); - npc.velocity = new Vector2(0f, -7f); - } - - npc.velocity *= 0.95f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - NPCAimedTarget targetData = npc.GetTargetData(); - becomeVisible = false; - bool turnInvisible = false; - bool despawn = false; - if (!turnInvisible) - { - if (npc.AI_120_HallowBoss_IsGenuinelyEnraged()) - { - if (!Main.dayTime) - despawn = true; - - if (Main.dayTime && Main.time >= 53400D) - despawn = true; - } - - turnInvisible = turnInvisible || despawn; - } - - if (!turnInvisible) - { - bool noValidTarget = targetData.Invalid || npc.Distance(targetData.Center) > despawnDistance; - turnInvisible = turnInvisible || noValidTarget; - } - - npc.alpha = Utils.Clamp(npc.alpha + turnInvisible.ToDirectionInt() * 5, 0, 255); - bool flag10 = npc.alpha == 0 || npc.alpha == 255; - int totalDust = 5; - for (int i = 0; i < totalDust; i++) - { - float num19 = MathHelper.Lerp(1.3f, 0.7f, npc.Opacity); - Color newColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f); - int num20 = Dust.NewDust(npc.position - npc.Size * 0.5f, npc.width * 2, npc.height * 2, DustID.RainbowMk2, 0f, 0f, 0, newColor); - Main.dust[num20].position = npc.Center + Main.rand.NextVector2Circular(npc.width, npc.height); - Main.dust[num20].velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[num20].noGravity = true; - Main.dust[num20].scale = 0.9f + Main.rand.NextFloat() * 1.2f; - Main.dust[num20].fadeIn = 0.4f + Main.rand.NextFloat() * 1.2f * num19; - Main.dust[num20].velocity += Vector2.UnitY * -2f; - Main.dust[num20].scale = 0.35f; - if (num20 != Main.maxDust) - { - Dust dust = Dust.CloneDust(num20); - dust.scale /= 2f; - dust.fadeIn *= 0.85f; - dust.color = new Color(255, 255, 255, 255); - } - } - - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 20f && flag10)) - break; - - if (npc.alpha == 255) - { - npc.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); - - return false; - } - - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - break; - } - } - - npc.dontTakeDamage = !takeDamage; - - if (phase3) - npc.defense = (int)Math.Round(npc.defDefense * 0.8); - else if (phase2) - npc.defense = (int)Math.Round(npc.defDefense * 1.2); - else - npc.defense = npc.defDefense; - - if ((npc.localAI[0] += 1f) >= 44f) - npc.localAI[0] = 0f; - - if (becomeVisible) - npc.alpha = Utils.Clamp(npc.alpha - 5, minAlpha, 255); - - Lighting.AddLight(npc.Center, Vector3.One * npc.Opacity); + Lighting.AddLight(NPC.Center, Vector3.One * NPC.Opacity); return false; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs index a44b972fce..2ac3965086 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Events; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -10,21 +9,26 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class EyeOfCthulhuAI + public class EyeOfCthulhuAI : VanillaAIOverride { private const float ProjectileOffset = 50f; - public static bool BuffedEyeofCthulhuAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Rev+ exclusive + public static float Phase1ContactDamageMult = 1.333f; // 40 (buffed from 30) + public static float Phase2ContactDamageMult = 1.6f; // 48 (buffed from 36) + public static float Phase3ContactDamageMult = 1.8f; // 54 (buffed from 40) + public static int BloodShotDamage = 8; // 32 - Lighting.AddLight(npc.Center, 0.5f, 0.5f, 0.5f); + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + Lighting.AddLight(NPC.Center, 0.5f, 0.5f, 0.5f); // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Phases float phase2LifeRatio = death ? 0.75f : 0.6f; @@ -40,25 +44,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float lineUpDist = death ? 15f : 20f; + // Set contact damage + NPC.damage = (int)Math.Round(NPC.defDamage * (phase3 ? Phase3ContactDamageMult : phase2 ? Phase2ContactDamageMult : Phase1ContactDamageMult)); + // Servant and projectile velocity, the projectile velocity is multiplied by 2 - float servantAndProjectileVelocity = death ? 10f : 6f; - - float enrageScale = bossRush ? 2.25f : death ? 0.5f : 0f; - if (Main.IsItDay()) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 2f; - } - - npc.reflectsProjectiles = false; + float servantAndProjectileVelocity = death ? 7f : 6f; + NPC.reflectsProjectiles = false; // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - bool dead = Main.player[npc.target].dead; - float targetXDistance = npc.Center.X - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); - float targetYDistance = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); + bool dead = Main.player[NPC.target].dead; + float targetXDistance = NPC.Center.X - Main.player[NPC.target].position.X - (Main.player[NPC.target].width / 2); + float targetYDistance = NPC.position.Y + NPC.height - 59f - Main.player[NPC.target].position.Y - (Main.player[NPC.target].height / 2); float eyeRotation = (float)Math.Atan2(targetYDistance, targetXDistance) + MathHelper.PiOver2; if (eyeRotation < 0f) @@ -67,82 +66,72 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses eyeRotation -= MathHelper.TwoPi; float eyeRotationAcceleration = 0f; - if (npc.ai[0] == 0f && npc.ai[1] == 0f) + if (NPC.ai[0] == 0f && NPC.ai[1] == 0f) eyeRotationAcceleration = 0.04f; - if (npc.ai[0] == 0f && npc.ai[1] == 2f && npc.ai[2] > 40f) + if (NPC.ai[0] == 0f && NPC.ai[1] == 2f && NPC.ai[2] > 40f) eyeRotationAcceleration = 0.1f; - if (npc.ai[0] == 3f && npc.ai[1] == 0f) + if (NPC.ai[0] == 3f && NPC.ai[1] == 0f) eyeRotationAcceleration = 0.1f; - if (npc.ai[0] == 3f && npc.ai[1] == 2f && npc.ai[2] > 40f) + if (NPC.ai[0] == 3f && NPC.ai[1] == 2f && NPC.ai[2] > 40f) eyeRotationAcceleration = 0.16f; - if (npc.ai[0] == 3f && npc.ai[1] == 4f && npc.ai[2] > lineUpDist) + if (NPC.ai[0] == 3f && NPC.ai[1] == 4f && NPC.ai[2] > lineUpDist) eyeRotationAcceleration = 0.3f; - if (npc.ai[0] == 3f && npc.ai[1] == 5f) + if (NPC.ai[0] == 3f && NPC.ai[1] == 5f) eyeRotationAcceleration = 0.1f; - if (npc.rotation < eyeRotation) + if (NPC.rotation < eyeRotation) { - if ((eyeRotation - npc.rotation) > MathHelper.Pi) - npc.rotation -= eyeRotationAcceleration; + if ((eyeRotation - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= eyeRotationAcceleration; else - npc.rotation += eyeRotationAcceleration; + NPC.rotation += eyeRotationAcceleration; } - else if (npc.rotation > eyeRotation) + else if (NPC.rotation > eyeRotation) { - if ((npc.rotation - eyeRotation) > MathHelper.Pi) - npc.rotation += eyeRotationAcceleration; + if ((NPC.rotation - eyeRotation) > MathHelper.Pi) + NPC.rotation += eyeRotationAcceleration; else - npc.rotation -= eyeRotationAcceleration; + NPC.rotation -= eyeRotationAcceleration; } - if (npc.rotation > eyeRotation - eyeRotationAcceleration && npc.rotation < eyeRotation + eyeRotationAcceleration) - npc.rotation = eyeRotation; - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if (npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - if (npc.rotation > eyeRotation - eyeRotationAcceleration && npc.rotation < eyeRotation + eyeRotationAcceleration) - npc.rotation = eyeRotation; + if (NPC.rotation > eyeRotation - eyeRotationAcceleration && NPC.rotation < eyeRotation + eyeRotationAcceleration) + NPC.rotation = eyeRotation; + if (NPC.rotation < 0f) + NPC.rotation += MathHelper.TwoPi; + else if (NPC.rotation > MathHelper.TwoPi) + NPC.rotation -= MathHelper.TwoPi; + if (NPC.rotation > eyeRotation - eyeRotationAcceleration && NPC.rotation < eyeRotation + eyeRotationAcceleration) + NPC.rotation = eyeRotation; if (Main.rand.NextBool(5)) { - int randomBlood = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), DustID.Blood, npc.velocity.X, 2f, 0, default, 1f); + int randomBlood = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f), NPC.width, (int)(NPC.height * 0.5f), DustID.Blood, NPC.velocity.X, 2f, 0, default, 1f); Dust dust = Main.dust[randomBlood]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } - bool shootProjectile = Collision.CanHitLine(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1) && - npc.SafeDirectionTo(Main.player[npc.target].Center).AngleBetween((npc.rotation + MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(18f) && - Vector2.Distance(npc.Center, Main.player[npc.target].Center) > 240f; + bool shootProjectile = Collision.CanHitLine(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1) && + NPC.SafeDirectionTo(Main.player[NPC.target].Center).AngleBetween((NPC.rotation + MathHelper.PiOver2).ToRotationVector2()) < MathHelper.ToRadians(18f) && + Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) > 240f; - bool charge = Vector2.Distance(Main.player[npc.target].Center, npc.Center) >= 320f; // 20 tile distance + bool charge = Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) >= 320f; // 20 tile distance - if (dead) + if ((dead || Main.IsItDay()) && !BossRushEvent.BossRushActive) { - npc.velocity.Y -= 0.04f; + NPC.velocity.Y -= 0.04f; - if (npc.timeLeft > 10) - npc.timeLeft = 10; + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; + return false; } - else if (npc.ai[0] == 0f) + else if (NPC.ai[0] == 0f) { - if (npc.ai[1] == 0f) + if (NPC.ai[1] == 0f) { - // Avoid cheap bullshit - npc.damage = 0; - - float hoverSpeed = 7f; - float hoverAcceleration = 0.15f; - hoverSpeed += 5f * enrageScale; - hoverAcceleration += 0.1f * enrageScale; - - if (death) - { - hoverSpeed += 7f * (1f - lifeRatio); - hoverAcceleration += 0.15f * (1f - lifeRatio); - } + float hoverSpeed = death ? 7f + 3f * (1f - lifeRatio) : 7f; + float hoverAcceleration = death ? 0.15f + 0.1f * (1f - lifeRatio) : 0.15f; if (Main.getGoodWorld) { @@ -151,39 +140,39 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } float attackSwitchTimer = death ? (120f - 180f * (1f - lifeRatio)) : 180f; - bool timeToCharge = npc.ai[2] >= attackSwitchTimer; - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * 400f; - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * (hoverSpeed + (timeToCharge ? ((npc.ai[2] - attackSwitchTimer) * 0.01f) : 0f)); - npc.SimpleFlyMovement(idealVelocity, hoverAcceleration + (timeToCharge ? ((npc.ai[2] - attackSwitchTimer) * 0.001f) : 0f)); + bool timeToCharge = NPC.ai[2] >= attackSwitchTimer; + Vector2 hoverDestination = Main.player[NPC.target].Center - Vector2.UnitY * 400f; + Vector2 idealVelocity = NPC.SafeDirectionTo(hoverDestination) * (hoverSpeed + (timeToCharge ? ((NPC.ai[2] - attackSwitchTimer) * 0.01f) : 0f)); + NPC.SimpleFlyMovement(idealVelocity, hoverAcceleration + (timeToCharge ? ((NPC.ai[2] - attackSwitchTimer) * 0.001f) : 0f)); - npc.ai[2] += 1f; + NPC.ai[2] += 1f; if (timeToCharge && charge) { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.netUpdate = true; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + NPC.netUpdate = true; } - else if (npc.WithinRange(hoverDestination, 900f)) + else if (NPC.WithinRange(hoverDestination, 900f)) { - if (!Main.player[npc.target].dead) - npc.ai[3] += 1f; + if (!Main.player[NPC.target].dead) + NPC.ai[3] += 1f; - float servantSpawnGateValue = death ? 10f : 40f; + float servantSpawnGateValue = death ? 15f : 40f; if (Main.getGoodWorld) servantSpawnGateValue *= 0.8f; - if (npc.ai[3] >= servantSpawnGateValue && shootProjectile) + if (NPC.ai[3] >= servantSpawnGateValue && shootProjectile) { - npc.ai[3] = 0f; - npc.rotation = eyeRotation; + NPC.ai[3] = 0f; + NPC.rotation = eyeRotation; - Vector2 servantSpawnVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * servantAndProjectileVelocity; - Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; - int maxServants = 4; + Vector2 servantSpawnVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * servantAndProjectileVelocity; + Vector2 servantSpawnCenter = NPC.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; + int maxServants = 3; bool spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; if (spawnServant) SoundEngine.PlaySound(SoundID.NPCHit1, servantSpawnCenter); @@ -192,7 +181,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (spawnServant) { - int eye = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu, 0, 0f, 0f, enrageScale); + //Phase 1 Servant Spawn + int eye = NPC.NewNPC(NPC.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu); Main.npc[eye].velocity = servantSpawnVelocity; if (Main.dedServ && eye < Main.maxNPCs) @@ -201,8 +191,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else { int projType = ProjectileID.BloodNautilusShot; - int projDamage = npc.GetProjectileDamage(projType); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset, servantSpawnVelocity * 2f, projType, projDamage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset, servantSpawnVelocity * 2f, projType, BloodShotDamage, 0f, Main.myPlayer); Main.projectile[proj].timeLeft = 600; } } @@ -215,231 +204,176 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } } - else if (npc.ai[1] == 1f) + else if (NPC.ai[1] == 1f) { - // Set damage - npc.damage = npc.defDamage; - - npc.rotation = eyeRotation; + NPC.rotation = eyeRotation; float additionalVelocityPerCharge = 2f; - float chargeSpeed = 8f + npc.ai[3] * additionalVelocityPerCharge; - chargeSpeed += 5f * enrageScale; + float chargeSpeed = (death ? 10.5f : 8f) + NPC.ai[3] * additionalVelocityPerCharge; if (death) chargeSpeed += 10f * (1f - lifeRatio); if (Main.getGoodWorld) chargeSpeed += 4f; - npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * chargeSpeed; + NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * chargeSpeed; - npc.ai[1] = 2f; - npc.ForceNetUpdate(false); + NPC.ai[1] = 2f; + NPC.ForceNetUpdate(false); } - else if (npc.ai[1] == 2f) + else if (NPC.ai[1] == 2f) { - // Set damage - npc.damage = npc.defDamage; - int chargeDelay = death ? (75 - (int)Math.Round(30f * (1f - lifeRatio))) : 95; if (Main.getGoodWorld) chargeDelay -= 30; float slowDownGateValue = chargeDelay * (death ? 0.85f : 0.65f); - npc.ai[2] += 1f; - if (npc.ai[2] >= slowDownGateValue) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= slowDownGateValue) { - // Avoid cheap bullshit - npc.damage = 0; - float decelerationScalar = death ? ((lifeRatio - phase2LifeRatio) / (1f - phase2LifeRatio)) : 1f; if (decelerationScalar < 0f) decelerationScalar = 0f; - npc.velocity *= (MathHelper.Lerp(death ? 0.76f : 0.92f, death ? 0.88f : 0.96f, decelerationScalar)); + NPC.velocity *= (MathHelper.Lerp(death ? 0.76f : 0.92f, death ? 0.88f : 0.96f, decelerationScalar)); if (Main.getGoodWorld) - npc.velocity *= 0.99f; + NPC.velocity *= 0.99f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; } else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; - if (npc.ai[2] >= chargeDelay) + if (NPC.ai[2] >= chargeDelay) { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = eyeRotation; + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; + NPC.rotation = eyeRotation; float numCharges = death ? 4f : 3f; - if (npc.ai[3] >= numCharges) + if (NPC.ai[3] >= numCharges) { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[1] = 0f; - npc.ai[3] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; } else - npc.ai[1] = 1f; + NPC.ai[1] = 1f; } } if (phase2) { - // Avoid cheap bullshit - npc.damage = 0; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.ForceNetUpdate(false); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPC.ForceNetUpdate(false); } } - else if (npc.ai[0] == 1f || npc.ai[0] == 2f) + else if (NPC.ai[0] == 1f || NPC.ai[0] == 2f) { - // Avoid cheap bullshit - npc.damage = 0; - if (Main.getGoodWorld) - npc.reflectsProjectiles = true; + NPC.reflectsProjectiles = true; - if (npc.ai[0] == 1f) + if (NPC.ai[0] == 1f) { - npc.ai[2] += 0.005f; - if (npc.ai[2] > 0.5f) - npc.ai[2] = 0.5f; + NPC.ai[2] += 0.005f; + if (NPC.ai[2] > 0.5f) + NPC.ai[2] = 0.5f; } else { - npc.ai[2] -= 0.005f; - if (npc.ai[2] < 0f) - npc.ai[2] = 0f; + NPC.ai[2] -= 0.005f; + if (NPC.ai[2] < 0f) + NPC.ai[2] = 0f; } - npc.rotation += npc.ai[2]; + NPC.rotation += NPC.ai[2]; float phaseChangeRate = death ? 2f : 1f; float servantSpawnGateValue = Main.getGoodWorld ? 4f : 20f; - npc.ai[1] += phaseChangeRate; - if (npc.ai[1] % servantSpawnGateValue == 0f) + NPC.ai[1] += phaseChangeRate; + if (NPC.ai[1] % servantSpawnGateValue == 0f) { - float servantVelocity = death ? 11.3f : 5.65f; + float servantVelocity = death ? 9.3f : 5.65f; Vector2 servantSpawnVelocity = Main.rand.NextVector2CircularEdge(servantVelocity, servantVelocity); if (Main.getGoodWorld) servantSpawnVelocity *= 3f; - Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; + Vector2 servantSpawnCenter = NPC.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; if (Main.netMode != NetmodeID.MultiplayerClient) { - int spawnType = NPCID.ServantofCthulhu; - if (death) - { - int maxBloodServants = 2; - bool spawnBloodServant = NPC.CountNPCS(ModContent.NPCType()) < maxBloodServants; - if (spawnBloodServant) - spawnType = ModContent.NPCType(); - } - - int servantSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, spawnType, 0, 0f, 0f, enrageScale); + //Phase Transition Servant Spawn + int servantSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu); Main.npc[servantSpawn].velocity.X = servantSpawnVelocity.X; Main.npc[servantSpawn].velocity.Y = servantSpawnVelocity.Y; if (Main.dedServ && servantSpawn < Main.maxNPCs) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, servantSpawn); - - if (CalamityWorld.LegendaryMode) - { - int type = ProjectileID.BloodNautilusShot; - Vector2 projectileVelocity = Main.rand.NextVector2CircularEdge(15f, 15f); - int numProj = 3; - int spread = 20; - 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) * ProjectileOffset, perturbedSpeed, type, 15, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; - } - } } for (int n = 0; n < 10; n++) Dust.NewDust(servantSpawnCenter, 20, 20, DustID.Blood, servantSpawnVelocity.X * 0.4f, servantSpawnVelocity.Y * 0.4f, 0, default, 1f); } - if (npc.ai[1] == 100f) + if (NPC.ai[1] == 100f) { - npc.ai[0] += 1f; - npc.ai[1] = 0f; + NPC.ai[0] += 1f; + NPC.ai[1] = 0f; - if (npc.ai[0] == 3f) + if (NPC.ai[0] == 3f) { - npc.ai[2] = 0f; + NPC.ai[2] = 0f; } else { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); + SoundEngine.PlaySound(SoundID.NPCHit1, NPC.Center); if (!Main.dedServ) { for (int phase2Gore = 0; phase2Gore < 2; phase2Gore++) { - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 8, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 8, 1f); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); } } for (int i = 0; i < 20; i++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - SoundEngine.PlaySound(SoundID.Roar, npc.Center); + SoundEngine.PlaySound(SoundID.Roar, NPC.Center); } } - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - npc.velocity *= 0.98f; + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + NPC.velocity *= 0.98f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; } else { - npc.defense = 0; - int setDamage = (int)Math.Round(npc.defDamage * (phase3 ? 1.4 : 1.2)); - int reducedSetDamage = (int)Math.Round(setDamage * 0.5); + NPC.defense = 0; - if (npc.ai[1] == 0f & phase3) - npc.ai[1] = 5f; + if (NPC.ai[1] == 0f & phase3) + NPC.ai[1] = 5f; - if (npc.ai[1] == 0f) + if (NPC.ai[1] == 0f) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; + float hoverSpeed = (death ? 7.5f : 5.5f) + (death ? 8.5f : 3f) * (phase2LifeRatio - lifeRatio); + float hoverAcceleration = (death ? 0.08f : 0.06f) + (death ? 0.08f : 0.02f) * (phase2LifeRatio - lifeRatio); - float hoverSpeed = 5.5f + 3f * (phase2LifeRatio - lifeRatio); - float hoverAcceleration = 0.06f + 0.02f * (phase2LifeRatio - lifeRatio); - hoverSpeed += 4f * enrageScale; - hoverAcceleration += 0.04f * enrageScale; - - if (death) - { - hoverSpeed += 5.5f * (phase2LifeRatio - lifeRatio); - hoverAcceleration += 0.06f * (phase2LifeRatio - lifeRatio); - } - - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * 400f; - float distanceFromHoverDestination = npc.Distance(hoverDestination); + Vector2 hoverDestination = Main.player[NPC.target].Center - Vector2.UnitY * 400f; + float distanceFromHoverDestination = NPC.Distance(hoverDestination); if (distanceFromHoverDestination > 400f) { @@ -464,140 +398,121 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } float phaseLimit = death ? (160f - 150f * (phase2LifeRatio - lifeRatio)) : 200f; - bool timeToCharge = npc.ai[2] >= phaseLimit; - Vector2 idealHoverVelocity = npc.SafeDirectionTo(hoverDestination) * (hoverSpeed + (timeToCharge ? ((npc.ai[2] - phaseLimit) * 0.01f) : 0f)); - npc.SimpleFlyMovement(idealHoverVelocity, hoverAcceleration + (timeToCharge ? ((npc.ai[2] - phaseLimit) * 0.001f) : 0f)); + bool timeToCharge = NPC.ai[2] >= phaseLimit; + Vector2 idealHoverVelocity = NPC.SafeDirectionTo(hoverDestination) * (hoverSpeed + (timeToCharge ? ((NPC.ai[2] - phaseLimit) * 0.01f) : 0f)); + NPC.SimpleFlyMovement(idealHoverVelocity, hoverAcceleration + (timeToCharge ? ((NPC.ai[2] - phaseLimit) * 0.001f) : 0f)); - npc.ai[2] += 1f; - float projectileGateValue = (lifeRatio < 0.5f && death) ? 40f : (death ? 60f : 80f); - if (npc.ai[2] % projectileGateValue == 0f && shootProjectile) + NPC.ai[2] += 1f; + + if (death) { - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity * 2f; - Vector2 projectileSpawnCenter = npc.Center + projectileVelocity; - if (Main.netMode != NetmodeID.MultiplayerClient) + float projectileGateValue = lifeRatio < 0.5f ? 40f : 60f; + if (NPC.ai[2] % projectileGateValue == 0f && shootProjectile) { - int type = ProjectileID.BloodNautilusShot; - int damage = npc.GetProjectileDamage(type); - int numProj = death ? 4 : 3; - int spread = death ? 12 : 10; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity * 2f; + Vector2 projectileSpawnCenter = NPC.Center + projectileVelocity; + if (Main.netMode != NetmodeID.MultiplayerClient) { - 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) * ProjectileOffset, perturbedSpeed, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; + int type = ProjectileID.BloodNautilusShot; + int numProj = 3; + int spread = 18; + 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) * ProjectileOffset, perturbedSpeed, type, BloodShotDamage, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = 600; + } } } } if (timeToCharge && charge) { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; } } - else if (npc.ai[1] == 1f) + else if (NPC.ai[1] == 1f) { - // Set damage - npc.damage = setDamage; - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - npc.rotation = eyeRotation; + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); + NPC.rotation = eyeRotation; float additionalVelocityPerCharge = 3f; - float chargeSpeed = 10f + (3.5f * (phase2LifeRatio - lifeRatio)) + npc.ai[3] * additionalVelocityPerCharge; - chargeSpeed += 4f * enrageScale; - if (death) - chargeSpeed += 6.5f * (phase2LifeRatio - lifeRatio); - if (npc.ai[3] == 1f) + float chargeSpeed = (death ? 12f : 10f) + ((death ? 10f : 3.5f) * (phase2LifeRatio - lifeRatio)) + NPC.ai[3] * additionalVelocityPerCharge; + if (NPC.ai[3] == 1f) chargeSpeed *= 1.15f; - if (npc.ai[3] == 2f) + if (NPC.ai[3] == 2f) chargeSpeed *= 1.3f; if (Main.getGoodWorld) chargeSpeed *= 1.2f; - npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * chargeSpeed; - npc.ai[1] = 2f; - npc.ForceNetUpdate(false); + NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * chargeSpeed; + NPC.ai[1] = 2f; + NPC.ForceNetUpdate(false); } - else if (npc.ai[1] == 2f) + else if (NPC.ai[1] == 2f) { - // Set damage - npc.damage = setDamage; - int phase2ChargeDelay = death ? (70 - (int)Math.Round(25f * (phase2LifeRatio - lifeRatio))) : 85; float slowDownGateValue = phase2ChargeDelay * (death ? 0.9f : 0.75f); - npc.ai[2] += 1f; - if (npc.ai[2] >= slowDownGateValue) + NPC.ai[2] += 1f; + if (NPC.ai[2] >= slowDownGateValue) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - float decelerationScalar = death ? ((lifeRatio - phase3LifeRatio) / (phase2LifeRatio - phase3LifeRatio)) : 1f; if (decelerationScalar < 0f) decelerationScalar = 0f; - npc.velocity *= (MathHelper.Lerp(death ? 0.6f : 0.9f, death ? 0.7f : 0.95f, decelerationScalar)); - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; + NPC.velocity *= (MathHelper.Lerp(death ? 0.6f : 0.9f, death ? 0.7f : 0.95f, decelerationScalar)); + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; } else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; - if (npc.ai[2] >= phase2ChargeDelay) + if (NPC.ai[2] >= phase2ChargeDelay) { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = eyeRotation; + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; + NPC.rotation = eyeRotation; float numCharges = death ? 4f : 3f; - if (npc.ai[3] >= numCharges) + if (NPC.ai[3] >= numCharges) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - - npc.ai[1] = 0f; - npc.ai[3] = 0f; - npc.ForceNetUpdate(false); + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + NPC.ForceNetUpdate(false); } else - npc.ai[1] = 1f; + NPC.ai[1] = 1f; } } - else if (npc.ai[1] == 3f) + else if (NPC.ai[1] == 3f) { - if ((npc.ai[3] == 4f & phase3) && npc.Center.Y > Main.player[npc.target].Center.Y) + if ((NPC.ai[3] == 4f & phase3) && NPC.Center.Y > Main.player[NPC.target].Center.Y) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.ForceNetUpdate(false); + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.ForceNetUpdate(false); } else if (Main.netMode != NetmodeID.MultiplayerClient) { - // Set damage - npc.damage = setDamage; - float speedBoost = death ? 10f * (phase3LifeRatio - lifeRatio) : 7f * (phase3LifeRatio - lifeRatio); - float finalChargeSpeed = 18f + speedBoost; - finalChargeSpeed += 10f * enrageScale; + float finalChargeSpeed = (death ? 23f : 18f) + speedBoost; - Vector2 eyeChargeDirection = npc.Center; - float targetX = Main.player[npc.target].Center.X - eyeChargeDirection.X; - float targetY = Main.player[npc.target].Center.Y - eyeChargeDirection.Y; - float targetVelocity = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; + Vector2 eyeChargeDirection = NPC.Center; + float targetX = Main.player[NPC.target].Center.X - eyeChargeDirection.X; + float targetY = Main.player[NPC.target].Center.Y - eyeChargeDirection.Y; + float targetVelocity = Math.Abs(Main.player[NPC.target].velocity.X) + Math.Abs(Main.player[NPC.target].velocity.Y) / 4f; targetVelocity += 10f - targetVelocity; if (targetVelocity < (death ? 2f : 5f)) @@ -605,134 +520,119 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (targetVelocity > (death ? 6f : 15f)) targetVelocity = (death ? 6f : 15f); - if (npc.ai[2] == -1f) + if (NPC.ai[2] == -1f) { targetVelocity *= 4f; finalChargeSpeed *= 1.3f; } - targetX -= Main.player[npc.target].velocity.X * targetVelocity; - targetY -= Main.player[npc.target].velocity.Y * targetVelocity / 4f; + targetX -= Main.player[NPC.target].velocity.X * targetVelocity; + targetY -= Main.player[NPC.target].velocity.Y * targetVelocity / 4f; float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); float targetDistCopy = targetDistance; targetDistance = finalChargeSpeed / targetDistance; - npc.velocity.X = targetX * targetDistance; - npc.velocity.Y = targetY * targetDistance; + NPC.velocity.X = targetX * targetDistance; + NPC.velocity.Y = targetY * targetDistance; if (targetDistCopy < 100f) { - if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) + if (Math.Abs(NPC.velocity.X) > Math.Abs(NPC.velocity.Y)) { - float absoluteXVel = Math.Abs(npc.velocity.X); - float absoluteYVel = Math.Abs(npc.velocity.Y); + float absoluteXVel = Math.Abs(NPC.velocity.X); + float absoluteYVel = Math.Abs(NPC.velocity.Y); - if (npc.Center.X > Main.player[npc.target].Center.X) + if (NPC.Center.X > Main.player[NPC.target].Center.X) absoluteYVel *= -1f; - if (npc.Center.Y > Main.player[npc.target].Center.Y) + if (NPC.Center.Y > Main.player[NPC.target].Center.Y) absoluteXVel *= -1f; - npc.velocity.X = absoluteYVel; - npc.velocity.Y = absoluteXVel; + NPC.velocity.X = absoluteYVel; + NPC.velocity.Y = absoluteXVel; } } - else if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) + else if (Math.Abs(NPC.velocity.X) > Math.Abs(NPC.velocity.Y)) { - float absoluteEyeVel = (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) / 2f; + float absoluteEyeVel = (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) / 2f; float absoluteEyeVelBackup = absoluteEyeVel; - if (npc.Center.X > Main.player[npc.target].Center.X) + if (NPC.Center.X > Main.player[NPC.target].Center.X) absoluteEyeVelBackup *= -1f; - if (npc.Center.Y > Main.player[npc.target].Center.Y) + if (NPC.Center.Y > Main.player[NPC.target].Center.Y) absoluteEyeVel *= -1f; - npc.velocity.X = absoluteEyeVelBackup; - npc.velocity.Y = absoluteEyeVel; + NPC.velocity.X = absoluteEyeVelBackup; + NPC.velocity.Y = absoluteEyeVel; } - npc.ai[1] = 4f; - npc.ForceNetUpdate(false); + NPC.ai[1] = 4f; + NPC.ForceNetUpdate(false); } } - else if (npc.ai[1] == 4f) + else if (NPC.ai[1] == 4f) { - // Set damage - npc.damage = setDamage; - - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.ForceRoarPitched, npc.Center); + if (NPC.ai[2] == 0f) + SoundEngine.PlaySound(SoundID.ForceRoarPitched, NPC.Center); float lineUpDistControl = lineUpDist; - npc.ai[2] += 1f; + NPC.ai[2] += 1f; - if (npc.ai[2] == lineUpDistControl && Vector2.Distance(npc.position, Main.player[npc.target].position) < 200f) - npc.ai[2] -= 1f; + if (NPC.ai[2] == lineUpDistControl && Vector2.Distance(NPC.position, Main.player[NPC.target].position) < 200f) + NPC.ai[2] -= 1f; - if (npc.ai[2] >= lineUpDistControl) + if (NPC.ai[2] >= lineUpDistControl) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - - npc.velocity *= 0.95f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; + NPC.velocity *= 0.95f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; } else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; float lineUpDistNetUpdate = lineUpDistControl + 13f; - if (npc.ai[2] >= lineUpDistNetUpdate) + if (NPC.ai[2] >= lineUpDistNetUpdate) { - npc.ForceNetUpdate(false); + NPC.ForceNetUpdate(false); - npc.ai[3] += 1f; - npc.ai[2] = 0f; + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; float maxCharges = death ? (finalPhaseDeath ? 0f : penultimatePhaseDeath ? 1f : 2f) : finalPhaseRev ? 2f : 3f; - if (npc.ai[3] >= maxCharges) + if (NPC.ai[3] >= maxCharges) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - - npc.ai[1] = 0f; - npc.ai[3] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; } else - npc.ai[1] = 3f; + NPC.ai[1] = 3f; } } - else if (npc.ai[1] == 5f) + else if (NPC.ai[1] == 5f) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - float offset = death ? 540f : 600f; float speedBoost = death ? 15f * (phase3LifeRatio - lifeRatio) : 5f * (phase3LifeRatio - lifeRatio); float accelerationBoost = death ? 0.425f * (phase3LifeRatio - lifeRatio) : 0.125f * (phase3LifeRatio - lifeRatio); - float hoverSpeed = 8f + speedBoost; - float hoverAcceleration = 0.25f + accelerationBoost; + float hoverSpeed = (death ? 10f : 8f) + speedBoost; + float hoverAcceleration = (death ? 0.3125f : 0.25f) + accelerationBoost; bool horizontalCharge = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 3f; - float timeGateValue = horizontalCharge ? (110f - (death ? 60f * (phase3LifeRatio - lifeRatio) : 0f)) : (95f - (death ? 55f * (phase3LifeRatio - lifeRatio) : 0f)); - if (npc.ai[2] > timeGateValue) + float timeGateValue = horizontalCharge ? (110f - (death ? 30f * (phase3LifeRatio - lifeRatio) : 0f)) : (95f - (death ? 55f * (phase3LifeRatio - lifeRatio) : 0f)); + if (NPC.ai[2] > timeGateValue) { - float velocityScalar = npc.ai[2] - timeGateValue; + float velocityScalar = NPC.ai[2] - timeGateValue; hoverSpeed += velocityScalar * 0.05f; hoverAcceleration += velocityScalar * 0.0025f; } - hoverSpeed += enrageScale * 4f; - hoverAcceleration += enrageScale * 0.125f; - - Vector2 eyeLineUpChargeDirection = npc.Center; - float lineUpChargeTargetX = Main.player[npc.target].Center.X - eyeLineUpChargeDirection.X; - float lineUpChargeTargetY = Main.player[npc.target].Center.Y + offset - eyeLineUpChargeDirection.Y; - Vector2 hoverDestination = Main.player[npc.target].Center + Vector2.UnitY * offset; + Vector2 eyeLineUpChargeDirection = NPC.Center; + float lineUpChargeTargetX = Main.player[NPC.target].Center.X - eyeLineUpChargeDirection.X; + float lineUpChargeTargetY = Main.player[NPC.target].Center.Y + offset - eyeLineUpChargeDirection.Y; + Vector2 hoverDestination = Main.player[NPC.target].Center + Vector2.UnitY * offset; if (horizontalCharge) { @@ -740,115 +640,103 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses offset = calamityGlobalNPC.newAI[0] == 1f ? -horizontalChargeOffset : horizontalChargeOffset; hoverSpeed *= 1.5f; hoverAcceleration *= 1.5f; - hoverDestination = Main.player[npc.target].Center + Vector2.UnitX * offset; + hoverDestination = Main.player[NPC.target].Center + Vector2.UnitX * offset; } - Vector2 idealHoverVelocity = npc.SafeDirectionTo(hoverDestination) * hoverSpeed; - npc.SimpleFlyMovement(idealHoverVelocity, hoverAcceleration); + Vector2 idealHoverVelocity = NPC.SafeDirectionTo(hoverDestination) * hoverSpeed; + NPC.SimpleFlyMovement(idealHoverVelocity, hoverAcceleration); float servantSpawnGateValue = horizontalCharge ? (death ? 23f : 35f) : (death ? 17f : 27f); float maxServantSpawnsPerAttack = 2f; - npc.ai[2] += 1f; - if (npc.ai[2] % servantSpawnGateValue == 0f && shootProjectile && npc.ai[2] <= servantSpawnGateValue * maxServantSpawnsPerAttack) + NPC.ai[2] += 1f; + if (NPC.ai[2] % servantSpawnGateValue == 0f && shootProjectile && NPC.ai[2] <= servantSpawnGateValue * maxServantSpawnsPerAttack) { - Vector2 servantSpawnVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity; - Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; - - int spawnType = NPCID.ServantofCthulhu; - bool spawnServant = false; - float enrageScaleToPass = enrageScale; + //phase 3 servant spawning + Vector2 servantSpawnVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity; + Vector2 servantSpawnCenter = NPC.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; if (death) { - int maxBloodServants = 2; - bool spawnBloodServant = NPC.CountNPCS(ModContent.NPCType()) < maxBloodServants; - if (spawnBloodServant) - { - spawnType = ModContent.NPCType(); - spawnServant = true; - enrageScaleToPass += 0.5f; - } - else - { - int maxServants = death ? 1 : 2; - spawnServant = (penultimatePhaseDeath || finalPhaseRev) ? false : NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; - } - } - else - { - int maxServants = death ? (finalPhaseDeath ? 1 : penultimatePhaseDeath ? 2 : 3) : (finalPhaseRev ? 2 : 4); - spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; + servantSpawnCenter = Main.player[NPC.target].Center + Main.rand.NextVector2CircularEdge(1600, 1600); + servantSpawnVelocity = (Main.player[NPC.target].Center - servantSpawnCenter).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity * 2; } + int maxServants = death ? (finalPhaseDeath ? 2 : penultimatePhaseDeath ? 3 : 4) : (finalPhaseRev ? 2 : 4); + bool spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; if (spawnServant) + { SoundEngine.PlaySound(SoundID.NPCDeath13, servantSpawnCenter); + for (int m = 0; m < 10; m++) + Dust.NewDust(servantSpawnCenter, 20, 20, DustID.Blood, servantSpawnVelocity.X * 0.4f, servantSpawnVelocity.Y * 0.4f, 0, default, 1f); + } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (spawnServant) { - int eye = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, spawnType, 0, 0f, 0f, enrageScaleToPass); + //Final Phase Servant Spawn + int eye = NPC.NewNPC(NPC.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu); Main.npc[eye].velocity.X = servantSpawnVelocity.X; Main.npc[eye].velocity.Y = servantSpawnVelocity.Y; if (Main.dedServ && eye < Main.maxNPCs) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, eye); } - else if (!CalamityWorld.LegendaryMode) + else if (!Main.getGoodWorld) { - int projType = ProjectileID.BloodNautilusShot; - int projDamage = npc.GetProjectileDamage(projType); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset, servantSpawnVelocity * 2f, projType, projDamage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 600; + var spawnVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity; + int amount = death ? 3 : 1; + for (var i = 0; i < amount; i++) + { + Vector2 perturbedSpeed = spawnVelocity.RotatedBy(MathHelper.Lerp(-0.5f, 0.5f, i / (float)(amount - 1))) * (death ? 1.25f : 1f); + int projType = ProjectileID.BloodNautilusShot; + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * ProjectileOffset, perturbedSpeed * 2f, projType, BloodShotDamage, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = 600; + } } - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) { int type = ProjectileID.BloodNautilusShot; Vector2 projectileVelocity = servantSpawnVelocity * 3f; - int numProj = 3; + int numProj = death ? 5 : 3; int spread = 20; 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) * ProjectileOffset, perturbedSpeed, type, 15, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * ProjectileOffset, perturbedSpeed, type, 15, 0f, Main.myPlayer); Main.projectile[proj].timeLeft = 600; } } } - - if (spawnServant) - { - for (int m = 0; m < 10; m++) - Dust.NewDust(servantSpawnCenter, 20, 20, DustID.Blood, servantSpawnVelocity.X * 0.4f, servantSpawnVelocity.Y * 0.4f, 0, default, 1f); - } } float requiredDistanceForHorizontalCharge = 160f; - if (npc.ai[2] >= timeGateValue && (npc.Distance(hoverDestination) < requiredDistanceForHorizontalCharge || !horizontalCharge)) + if (NPC.ai[2] >= timeGateValue && (NPC.Distance(hoverDestination) < requiredDistanceForHorizontalCharge || !horizontalCharge)) { switch ((int)calamityGlobalNPC.newAI[0]) { case 0: // Normal Eye behavior - npc.ai[1] = 3f; - npc.ai[2] = -1f; - npc.ai[3] = -1f; + NPC.ai[1] = 3f; + NPC.ai[2] = -1f; + NPC.ai[3] = -1f; break; case 1: // Charge from the left - npc.ai[1] = 6f; - npc.ai[2] = 0f; + NPC.ai[1] = 6f; + NPC.ai[2] = 0f; break; case 2: // Normal Eye behavior - npc.ai[1] = 3f; - npc.ai[2] = -1f; + NPC.ai[1] = 3f; + NPC.ai[2] = -1f; break; case 3: // Charge from the right - npc.ai[1] = 6f; - npc.ai[2] = 0f; + NPC.ai[1] = 6f; + NPC.ai[2] = 0f; break; default: @@ -859,889 +747,59 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (calamityGlobalNPC.newAI[0] > 3f) calamityGlobalNPC.newAI[0] = death ? Main.rand.Next(2) : 0f; - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } - npc.ForceNetUpdate(false); + NPC.ForceNetUpdate(false); } - else if (npc.ai[1] == 6f) + else if (NPC.ai[1] == 6f) { - // Set damage - npc.damage = setDamage; - if (Main.netMode != NetmodeID.MultiplayerClient) { float speedBoost = death ? 15f * (phase3LifeRatio - lifeRatio) : 5f * (phase3LifeRatio - lifeRatio); - float chargeSpeed = 18f + speedBoost; - chargeSpeed += 10f * enrageScale; - npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * chargeSpeed; + float chargeSpeed = (death ? 23f : 18f) + speedBoost; + NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * chargeSpeed; - npc.ai[1] = 7f; - npc.ForceNetUpdate(false); + NPC.ai[1] = 7f; + NPC.ForceNetUpdate(false); } } - else if (npc.ai[1] == 7f) + else if (NPC.ai[1] == 7f) { - // Set damage - npc.damage = setDamage; - - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + if (NPC.ai[2] == 0f) + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); float lineUpDistControl = (float)Math.Round(lineUpDist * 2.5f); - npc.ai[2] += 1f; + NPC.ai[2] += 1f; - if (npc.ai[2] == lineUpDistControl && Vector2.Distance(npc.position, Main.player[npc.target].position) < 200f) - npc.ai[2] -= 1f; + if (NPC.ai[2] == lineUpDistControl && Vector2.Distance(NPC.position, Main.player[NPC.target].position) < 200f) + NPC.ai[2] -= 1f; - if (npc.ai[2] >= lineUpDistControl) + if (NPC.ai[2] >= lineUpDistControl) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - - npc.velocity *= 0.95f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; + NPC.velocity *= 0.95f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + if (NPC.velocity.Y > -0.1 && NPC.velocity.Y < 0.1) + NPC.velocity.Y = 0f; } else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; float lineUpDistNetUpdate = lineUpDistControl + 13f; - if (npc.ai[2] >= lineUpDistNetUpdate) + if (NPC.ai[2] >= lineUpDistNetUpdate) { - // Deal less damage overall while not charging - npc.damage = reducedSetDamage; - npc.ForceNetUpdate(false); + NPC.ForceNetUpdate(false); - npc.ai[2] = 0f; - npc.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[1] = 0f; } } } return false; } - - // If you think for a fucking second that I'm going to refactor this... - public static bool VanillaEyeofCthulhuAI(NPC npc, Mod mod) - { - Lighting.AddLight(npc.Center, 0.5f, 0.5f, 0.5f); - - bool flag2 = false; - if (Main.expertMode && (double)npc.life < (double)npc.lifeMax * (Main.masterMode ? 0.2 : 0.12)) - flag2 = true; - - bool flag3 = false; - if (Main.expertMode && (double)npc.life < (double)npc.lifeMax * (Main.masterMode ? 0.08 : 0.04)) - flag3 = true; - - float num4 = Main.masterMode ? 15f : 20f; - if (flag3) - num4 = Main.masterMode ? 8f : 10f; - - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - bool dead = Main.player[npc.target].dead; - float num5 = npc.Center.X - Main.player[npc.target].position.X - (float)(Main.player[npc.target].width / 2); - float num6 = npc.position.Y + (float)npc.height - 59f - Main.player[npc.target].position.Y - (float)(Main.player[npc.target].height / 2); - float num7 = (float)Math.Atan2(num6, num5) + MathHelper.PiOver2; - if (num7 < 0f) - num7 += MathHelper.TwoPi; - else if ((double)num7 > MathHelper.TwoPi) - num7 -= MathHelper.TwoPi; - - float num8 = 0f; - if (npc.ai[0] == 0f && npc.ai[1] == 0f) - num8 = 0.02f; - - if (npc.ai[0] == 0f && npc.ai[1] == 2f && npc.ai[2] > 40f) - num8 = 0.05f; - - if (npc.ai[0] == 3f && npc.ai[1] == 0f) - num8 = 0.05f; - - if (npc.ai[0] == 3f && npc.ai[1] == 2f && npc.ai[2] > 40f) - num8 = 0.08f; - - if (npc.ai[0] == 3f && npc.ai[1] == 4f && npc.ai[2] > num4) - num8 = 0.15f; - - if (npc.ai[0] == 3f && npc.ai[1] == 5f) - num8 = 0.05f; - - if (Main.expertMode) - num8 *= (Main.masterMode ? 2f : 1.5f); - - if (flag3 && Main.expertMode) - num8 = 0f; - - if (npc.rotation < num7) - { - if ((double)(num7 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num8; - else - npc.rotation += num8; - } - else if (npc.rotation > num7) - { - if ((double)(npc.rotation - num7) > MathHelper.Pi) - npc.rotation += num8; - else - npc.rotation -= num8; - } - - if (npc.rotation > num7 - num8 && npc.rotation < num7 + num8) - npc.rotation = num7; - - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if ((double)npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - - if (npc.rotation > num7 - num8 && npc.rotation < num7 + num8) - npc.rotation = num7; - - if (Main.rand.NextBool(5)) - { - int num9 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), DustID.Blood, npc.velocity.X, 2f); - Main.dust[num9].velocity.X *= 0.5f; - Main.dust[num9].velocity.Y *= 0.1f; - } - - npc.reflectsProjectiles = false; - if (Main.IsItDay() || dead) - { - npc.velocity.Y -= 0.04f; - npc.EncourageDespawn(10); - return false; - } - - if (npc.ai[0] == 0f) - { - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float num10 = 5f; - float num11 = 0.04f; - if (Main.expertMode) - { - num11 = Main.masterMode ? 0.2f : 0.15f; - num10 = Main.masterMode ? 9f : 7f; - } - - if (Main.getGoodWorld) - { - num11 += 0.05f; - num10 += 1f; - } - - Vector2 vector = npc.Center; - float num12 = Main.player[npc.target].Center.X - vector.X; - float num13 = Main.player[npc.target].Center.Y - 200f - vector.Y; - float num14 = (float)Math.Sqrt(num12 * num12 + num13 * num13); - float num15 = num14; - num14 = num10 / num14; - num12 *= num14; - num13 *= num14; - if (npc.velocity.X < num12) - { - npc.velocity.X += num11; - if (npc.velocity.X < 0f && num12 > 0f) - npc.velocity.X += num11; - } - else if (npc.velocity.X > num12) - { - npc.velocity.X -= num11; - if (npc.velocity.X > 0f && num12 < 0f) - npc.velocity.X -= num11; - } - - if (npc.velocity.Y < num13) - { - npc.velocity.Y += num11; - if (npc.velocity.Y < 0f && num13 > 0f) - npc.velocity.Y += num11; - } - else if (npc.velocity.Y > num13) - { - npc.velocity.Y -= num11; - if (npc.velocity.Y > 0f && num13 < 0f) - npc.velocity.Y -= num11; - } - - npc.ai[2] += 1f; - float num16 = Main.masterMode ? 400f : 600f; - if (Main.expertMode) - num16 *= 0.35f; - - if (npc.ai[2] >= num16) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.netUpdate = true; - } - else if ((npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && num15 < 500f) || (Main.expertMode && num15 < (Main.masterMode ? 750f : 500f))) - { - if (!Main.player[npc.target].dead) - npc.ai[3] += 1f; - - float num17 = Main.masterMode ? 70f : 110f; - if (Main.expertMode) - num17 *= 0.4f; - - if (Main.getGoodWorld) - num17 *= 0.8f; - - if (npc.ai[3] >= num17) - { - npc.ai[3] = 0f; - npc.rotation = num7; - float num18 = 5f; - if (Main.expertMode) - num18 = 6f; - if (Main.masterMode) - num18 = 9f; - - float num19 = Main.player[npc.target].Center.X - vector.X; - float num20 = Main.player[npc.target].Center.Y - vector.Y; - float num21 = (float)Math.Sqrt(num19 * num19 + num20 * num20); - num21 = num18 / num21; - Vector2 vector2 = vector; - Vector2 vector3 = default(Vector2); - vector3.X = num19 * num21; - vector3.Y = num20 * num21; - vector2.X += vector3.X * 10f; - vector2.Y += vector3.Y * 10f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num22 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector2.X, (int)vector2.Y, NPCID.ServantofCthulhu); - Main.npc[num22].velocity.X = vector3.X; - Main.npc[num22].velocity.Y = vector3.Y; - if (Main.dedServ && num22 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num22); - } - - SoundEngine.PlaySound(SoundID.NPCHit1, vector2); - for (int m = 0; m < 10; m++) - Dust.NewDust(vector2, 20, 20, DustID.Blood, vector3.X * 0.4f, vector3.Y * 0.4f); - } - } - } - else if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.rotation = num7; - float num23 = 6f; - if (Main.expertMode) - num23 = 7f; - if (Main.masterMode) - num23 = 9f; - - if (Main.getGoodWorld) - num23 += 1f; - - Vector2 vector4 = npc.Center; - float num24 = Main.player[npc.target].Center.X - vector4.X; - float num25 = Main.player[npc.target].Center.Y - vector4.Y; - float num26 = (float)Math.Sqrt(num24 * num24 + num25 * num25); - num26 = num23 / num26; - npc.velocity.X = num24 * num26; - npc.velocity.Y = num25 * num26; - npc.ai[1] = 2f; - npc.ForceNetUpdate(false); - } - else if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f; - if (npc.ai[2] >= 40f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity *= 0.98f; - if (Main.expertMode) - npc.velocity *= 0.985f; - if (Main.masterMode) - npc.velocity *= 0.99f; - - if (Main.getGoodWorld) - npc.velocity *= 0.99f; - - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - int num27 = 150; - if (Main.expertMode) - num27 = 100; - if (Main.masterMode) - num27 = 80; - - if (Main.getGoodWorld) - num27 -= 15; - - if (npc.ai[2] >= (float)num27) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = num7; - if (npc.ai[3] >= (Main.masterMode ? 4f : 3f)) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[1] = 0f; - npc.ai[3] = 0f; - } - else - npc.ai[1] = 1f; - } - } - - float num28 = 0.5f; - if (Main.expertMode) - num28 = 0.65f; - if (Main.masterMode) - num28 = 0.75f; - - if ((float)npc.life < (float)npc.lifeMax * num28) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.ForceNetUpdate(false); - } - - return false; - } - - if (npc.ai[0] == 1f || npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.ai[0] == 1f || npc.ai[3] == 1f) - { - npc.ai[2] += 0.005f; - if ((double)npc.ai[2] > 0.5) - npc.ai[2] = 0.5f; - } - else - { - npc.ai[2] -= 0.005f; - if (npc.ai[2] < 0f) - npc.ai[2] = 0f; - } - - npc.rotation += npc.ai[2]; - npc.ai[1] += 1f; - if (Main.getGoodWorld) - npc.reflectsProjectiles = true; - - int num29 = 20; - if (Main.getGoodWorld && npc.life < npc.lifeMax / 3) - num29 = 10; - - if (Main.expertMode && npc.ai[1] % (float)num29 == 0f) - { - float num30 = Main.masterMode ? 8f : 5f; - Vector2 vector5 = npc.Center; - float num31 = Main.rand.Next(-200, 200); - float num32 = Main.rand.Next(-200, 200); - if (Main.getGoodWorld) - { - num31 *= 3f; - num32 *= 3f; - } - - float num33 = (float)Math.Sqrt(num31 * num31 + num32 * num32); - num33 = num30 / num33; - Vector2 vector6 = vector5; - Vector2 vector7 = default(Vector2); - vector7.X = num31 * num33; - vector7.Y = num32 * num33; - vector6.X += vector7.X * 10f; - vector6.Y += vector7.Y * 10f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num34 = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector6.X, (int)vector6.Y, NPCID.ServantofCthulhu); - Main.npc[num34].velocity.X = vector7.X; - Main.npc[num34].velocity.Y = vector7.Y; - if (Main.dedServ && num34 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num34); - } - - for (int n = 0; n < 10; n++) - Dust.NewDust(vector6, 20, 20, DustID.Blood, vector7.X * 0.4f, vector7.Y * 0.4f); - } - - if (npc.ai[1] >= 100f) - { - if (npc.ai[3] == 1f) - { - npc.ai[3] = 0f; - npc.ai[1] = 0f; - } - else - { - npc.ai[0] += 1f; - npc.ai[1] = 0f; - if (npc.ai[0] == 3f) - { - npc.ai[2] = 0f; - } - else - { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); - for (int num35 = 0; num35 < 2; num35++) - { - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 8); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 7); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 6); - } - - for (int num36 = 0; num36 < 20; num36++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f); - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - } - } - - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f); - npc.velocity *= 0.98f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - - return false; - } - - npc.defense = 0; - if (Main.expertMode) - { - if (flag2) - npc.defense = -(Main.masterMode ? 10 : 15); - if (flag3) - npc.defense = -(Main.masterMode ? 20 : 30); - } - - double phase2DamageMultiplier = 1.5; - npc.damage = (int)Math.Round(npc.defDamage * phase2DamageMultiplier); - int reducedSetDamage = (int)Math.Round(npc.damage * 0.5); - - if (npc.ai[1] == 0f && flag2) - npc.ai[1] = 5f; - - if (npc.ai[1] == 0f) - { - // Deal less damage while not charging - npc.damage = reducedSetDamage; - - float num39 = Main.masterMode ? 8f : 6f; - float num40 = Main.masterMode ? 0.1f : 0.07f; - Vector2 vector8 = npc.Center; - float num41 = Main.player[npc.target].Center.X - vector8.X; - float num42 = Main.player[npc.target].Center.Y - 120f - vector8.Y; - float num43 = (float)Math.Sqrt(num41 * num41 + num42 * num42); - float distanceVelocityIncrease = Main.masterMode ? 1.5f : 1f; - float distanceAccelerationIncrease = Main.masterMode ? 0.08f : 0.05f; - if (num43 > 400f && Main.expertMode) - { - num39 += distanceVelocityIncrease; - num40 += distanceAccelerationIncrease; - if (num43 > 600f) - { - num39 += distanceVelocityIncrease; - num40 += distanceAccelerationIncrease; - if (num43 > 800f) - { - num39 += distanceVelocityIncrease; - num40 += distanceAccelerationIncrease; - } - } - } - - if (Main.getGoodWorld) - { - num39 += 1f; - num40 += 0.1f; - } - - num43 = num39 / num43; - num41 *= num43; - num42 *= num43; - if (npc.velocity.X < num41) - { - npc.velocity.X += num40; - if (npc.velocity.X < 0f && num41 > 0f) - npc.velocity.X += num40; - } - else if (npc.velocity.X > num41) - { - npc.velocity.X -= num40; - if (npc.velocity.X > 0f && num41 < 0f) - npc.velocity.X -= num40; - } - - if (npc.velocity.Y < num42) - { - npc.velocity.Y += num40; - if (npc.velocity.Y < 0f && num42 > 0f) - npc.velocity.Y += num40; - } - else if (npc.velocity.Y > num42) - { - npc.velocity.Y -= num40; - if (npc.velocity.Y > 0f && num42 < 0f) - npc.velocity.Y -= num40; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (Main.masterMode ? 120f : 200f)) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - if (Main.expertMode && (double)npc.life < (double)npc.lifeMax * (Main.masterMode ? 0.45 : 0.35)) - npc.ai[1] = 3f; - - npc.netUpdate = true; - } - - if (Main.expertMode && flag3) - { - npc.netUpdate = true; - npc.ai[1] = 3f; - npc.ai[2] = 0f; - npc.ai[3] -= 1000f; - } - } - else if (npc.ai[1] == 1f) - { - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - npc.rotation = num7; - float num44 = Main.masterMode ? 8f : 6.8f; - if (Main.expertMode && npc.ai[3] == 1f) - num44 *= 1.15f; - - if (Main.expertMode && npc.ai[3] == 2f) - num44 *= 1.3f; - - if (Main.getGoodWorld) - num44 *= 1.2f; - - Vector2 vector9 = npc.Center; - float num45 = Main.player[npc.target].Center.X - vector9.X; - float num46 = Main.player[npc.target].Center.Y - vector9.Y; - float num47 = (float)Math.Sqrt(num45 * num45 + num46 * num46); - num47 = num44 / num47; - npc.velocity.X = num45 * num47; - npc.velocity.Y = num46 * num47; - npc.ai[1] = 2f; - npc.ForceNetUpdate(false); - } - else if (npc.ai[1] == 2f) - { - float num48 = 40f; - npc.ai[2] += 1f; - if (Main.expertMode) - num48 = 50f; - if (Main.masterMode) - num48 = 60f; - - if (npc.ai[2] >= num48) - { - // Deal less damage while not charging - npc.damage = reducedSetDamage; - - npc.velocity *= 0.97f; - if (Main.expertMode) - npc.velocity *= 0.98f; - if (Main.masterMode) - npc.velocity *= 0.99f; - - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - int num49 = 130; - if (Main.expertMode) - num49 = 90; - if (Main.masterMode) - num49 = 80; - - if (npc.ai[2] >= (float)num49) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = num7; - if (npc.ai[3] >= 3f) - { - // Deal less damage while not charging - npc.damage = reducedSetDamage; - - npc.ai[1] = 0f; - npc.ai[3] = 0f; - if (Main.expertMode && Main.netMode != NetmodeID.MultiplayerClient && (double)npc.life < (double)npc.lifeMax * (Main.masterMode ? 0.6 : 0.5)) - { - npc.ai[1] = 3f; - npc.ai[3] += Main.rand.Next(1, 4); - } - - npc.ForceNetUpdate(false); - } - else - npc.ai[1] = 1f; - } - } - else if (npc.ai[1] == 3f) - { - if (npc.ai[3] == 4f && flag2 && npc.Center.Y > Main.player[npc.target].Center.Y) - { - // Deal less damage while not charging - npc.damage = reducedSetDamage; - - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.ForceNetUpdate(false); - } - else if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num50 = Main.masterMode ? 24f : 20f; - Vector2 vector10 = npc.Center; - float num51 = Main.player[npc.target].Center.X - vector10.X; - float num52 = Main.player[npc.target].Center.Y - vector10.Y; - float num53 = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; - num53 += 10f - num53; - if (num53 < 5f) - num53 = 5f; - - if (num53 > 15f) - num53 = 15f; - - if (npc.ai[2] == -1f && !flag3) - { - num53 *= 4f; - num50 *= 1.3f; - } - - if (flag3) - num53 *= 2f; - - num51 -= Main.player[npc.target].velocity.X * num53; - num52 -= Main.player[npc.target].velocity.Y * num53 / 4f; - num51 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f; - num52 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f; - if (flag3) - { - num51 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f; - num52 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f; - } - - float num54 = (float)Math.Sqrt(num51 * num51 + num52 * num52); - float num55 = num54; - num54 = num50 / num54; - npc.velocity.X = num51 * num54; - npc.velocity.Y = num52 * num54; - npc.velocity.X += (float)Main.rand.Next(-20, 21) * 0.1f; - npc.velocity.Y += (float)Main.rand.Next(-20, 21) * 0.1f; - if (flag3) - { - npc.velocity.X += (float)Main.rand.Next(-50, 51) * 0.1f; - npc.velocity.Y += (float)Main.rand.Next(-50, 51) * 0.1f; - float num56 = Math.Abs(npc.velocity.X); - float num57 = Math.Abs(npc.velocity.Y); - if (npc.Center.X > Main.player[npc.target].Center.X) - num57 *= -1f; - - if (npc.Center.Y > Main.player[npc.target].Center.Y) - num56 *= -1f; - - npc.velocity.X = num57 + npc.velocity.X; - npc.velocity.Y = num56 + npc.velocity.Y; - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); - npc.velocity *= num50; - npc.velocity.X += (float)Main.rand.Next(-20, 21) * 0.1f; - npc.velocity.Y += (float)Main.rand.Next(-20, 21) * 0.1f; - } - else if (num55 < 100f) - { - if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) - { - float num58 = Math.Abs(npc.velocity.X); - float num59 = Math.Abs(npc.velocity.Y); - if (npc.Center.X > Main.player[npc.target].Center.X) - num59 *= -1f; - - if (npc.Center.Y > Main.player[npc.target].Center.Y) - num58 *= -1f; - - npc.velocity.X = num59; - npc.velocity.Y = num58; - } - } - else if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) - { - float num60 = (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) / 2f; - float num61 = num60; - if (npc.Center.X > Main.player[npc.target].Center.X) - num61 *= -1f; - - if (npc.Center.Y > Main.player[npc.target].Center.Y) - num60 *= -1f; - - npc.velocity.X = num61; - npc.velocity.Y = num60; - } - - npc.ai[1] = 4f; - npc.ForceNetUpdate(false); - } - } - else if (npc.ai[1] == 4f) - { - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.ForceRoarPitched, npc.Center); - - float num62 = num4; - npc.ai[2] += 1f; - if (npc.ai[2] == num62 && Vector2.Distance(npc.position, Main.player[npc.target].position) < 200f) - npc.ai[2] -= 1f; - - if (npc.ai[2] >= num62) - { - // Deal less damage while not charging - npc.damage = reducedSetDamage; - - npc.velocity *= 0.95f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - float num63 = num62 + 13f; - if (npc.ai[2] >= num63) - { - npc.ForceNetUpdate(false); - - npc.ai[3] += 1f; - npc.ai[2] = 0f; - if (npc.ai[3] >= 5f) - { - // Deal less damage while not charging - npc.damage = reducedSetDamage; - - npc.ai[1] = 0f; - npc.ai[3] = 0f; - if (npc.target >= 0 && Main.getGoodWorld && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, npc.width, npc.height)) - { - SoundEngine.PlaySound(SoundID.ForceRoarPitched, npc.Center); - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 1f; - npc.netUpdate = true; - } - } - else - npc.ai[1] = 3f; - } - } - else if (npc.ai[1] == 5f) - { - // Deal less damage while not charging - npc.damage = reducedSetDamage; - - float num64 = 600f; - float num65 = Main.masterMode ? 12f : 9f; - float num66 = Main.masterMode ? 0.4f : 0.3f; - Vector2 vector11 = npc.Center; - float num67 = Main.player[npc.target].Center.X - vector11.X; - float num68 = Main.player[npc.target].Center.Y + num64 - vector11.Y; - float num69 = (float)Math.Sqrt(num67 * num67 + num68 * num68); - num69 = num65 / num69; - num67 *= num69; - num68 *= num69; - if (npc.velocity.X < num67) - { - npc.velocity.X += num66; - if (npc.velocity.X < 0f && num67 > 0f) - npc.velocity.X += num66; - } - else if (npc.velocity.X > num67) - { - npc.velocity.X -= num66; - if (npc.velocity.X > 0f && num67 < 0f) - npc.velocity.X -= num66; - } - - if (npc.velocity.Y < num68) - { - npc.velocity.Y += num66; - if (npc.velocity.Y < 0f && num68 > 0f) - npc.velocity.Y += num66; - } - else if (npc.velocity.Y > num68) - { - npc.velocity.Y -= num66; - if (npc.velocity.Y > 0f && num68 < 0f) - npc.velocity.Y -= num66; - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= (Main.masterMode ? 40f : 70f)) - { - npc.ai[1] = 3f; - npc.ai[2] = -1f; - npc.ai[3] = Main.rand.Next(-3, 1); - npc.netUpdate = true; - } - } - - if (flag3 && npc.ai[1] == 5f) - npc.ai[1] = 3f; - - return false; - } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs index e75fd3ccdd..e5ffa7b8ab 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs @@ -1,108 +1,108 @@ using System; using CalamityMod.Events; +using CalamityMod.Particles; +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; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class GolemAI + public class GolemAI : VanillaAIOverride { - public static bool BuffedGolemAI(NPC npc, Mod mod) + // Rev+ exclusive + public static int FireballDamage = 24; // 96 (modified to be always at maximum Expert damage and does not scale) + public static int LaserDamage = 29; // 116 (modified to be always at maximum Expert damage and does not scale) + public static int InfernoBoltDamage = 35; // 140 + + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // whoAmI variable - NPC.golemBoss = npc.whoAmI; + NPC.golemBoss = NPC.whoAmI; // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phases - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; bool phase2 = lifeRatio < 0.75f; bool phase3 = lifeRatio < 0.5f; bool phase4 = lifeRatio < 0.25f; // Spawn parts - if (npc.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] = 1f; - int numFists = death ? 2 : 1; - for (int i = 0; i < numFists; i++) - { - float fistPunchTimeOffset = i * 30f; - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X - 84, (int)npc.Center.Y - 9, NPCID.GolemFistLeft, 0, 0f, fistPunchTimeOffset); - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X + 78, (int)npc.Center.Y - 9, NPCID.GolemFistRight, 0, 0f, fistPunchTimeOffset); - } - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X - 3, (int)npc.Center.Y - 57, NPCID.GolemHead); + NPC.localAI[0] = 1f; + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X - 84, (int)NPC.Center.Y - 9, NPCID.GolemFistLeft, 0); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + 78, (int)NPC.Center.Y - 9, NPCID.GolemFistRight, 0); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X - 3, (int)NPC.Center.Y - 57, NPCID.GolemHead); } // Despawn - if (npc.target >= 0 && Main.player[npc.target].dead) + if (NPC.target >= 0 && Main.player[NPC.target].dead) { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - if (Main.player[npc.target].dead) - npc.noTileCollide = true; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + if (Main.player[NPC.target].dead) + NPC.noTileCollide = true; } // Enrage if the target isn't inside the temple - // Turbo enrage if target isn't inside the temple and it's Boss Rush or For the Worthy - bool enrage = true; + // Turbo enrage if target isn't inside the temple and it's For the Worthy + bool enrage = !BossRushEvent.BossRushActive; bool turboEnrage = false; - if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) + if (Main.player[NPC.target].Center.Y > Main.worldSurface * 16.0) { - int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; - int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; + int targetTilePosX = (int)Main.player[NPC.target].Center.X / 16; + int targetTilePosY = (int)Main.player[NPC.target].Center.Y / 16; Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); if (tile.WallType == WallID.LihzahrdBrickUnsafe) enrage = false; else - turboEnrage = bossRush || Main.getGoodWorld; + turboEnrage = Main.getGoodWorld; } else - turboEnrage = bossRush || Main.getGoodWorld; + turboEnrage = Main.getGoodWorld; - if (bossRush || Main.getGoodWorld) + if (Main.getGoodWorld) enrage = true; - npc.Calamity().CurrentlyEnraged = !bossRush && (enrage || turboEnrage); + NPC.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && (enrage || turboEnrage); - bool reduceFallSpeed = npc.velocity.Y > 0f && Collision.SolidCollision(npc.position + Vector2.UnitY * 1.1f * npc.velocity.Y, npc.width, npc.height); + bool reduceFallSpeed = NPC.velocity.Y > 0f && Collision.SolidCollision(NPC.position + Vector2.UnitY * 1.1f * NPC.velocity.Y, NPC.width, NPC.height); // Alpha - if (npc.alpha > 0) + if (NPC.alpha > 0) { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; + NPC.alpha -= 10; + if (NPC.alpha < 0) + NPC.alpha = 0; - npc.ai[1] = 0f; + NPC.ai[1] = 0f; } // Check for body parts bool headAlive = NPC.AnyNPCs(NPCID.GolemHead); bool leftFistAlive = NPC.AnyNPCs(NPCID.GolemFistLeft); bool rightFistAlive = NPC.AnyNPCs(NPCID.GolemFistRight); - npc.dontTakeDamage = (headAlive || leftFistAlive || rightFistAlive) && !CalamityWorld.LegendaryMode; - - // Phase 2, check for free head - bool freeHeadAlive = NPC.AnyNPCs(NPCID.GolemHeadFree); + NPC.dontTakeDamage = headAlive || leftFistAlive || rightFistAlive; // Distance required for despawning int despawnDistance = turboEnrage ? 7500 : enrage ? 6000 : 4500; // Deactivate torches - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && npc.velocity.Y > 0f) + if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && NPC.velocity.Y > 0f) { - for (int j = (int)(npc.position.X / 16f); (float)j < (npc.position.X + (float)npc.width) / 16f; j++) + for (int j = (int)(NPC.position.X / 16f); (float)j < (NPC.position.X + (float)NPC.width) / 16f; j++) { - for (int k = (int)(npc.position.Y / 16f); (float)k < (npc.position.Y + (float)npc.width) / 16f; k++) + for (int k = (int)(NPC.position.Y / 16f); (float)k < (NPC.position.Y + (float)NPC.width) / 16f; k++) { if (Main.tile[j, k].TileType == TileID.Torches) { @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!leftFistAlive) { - int lostLeftFistDust = Dust.NewDust(new Vector2(npc.Center.X - 80f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Smoke, 0f, 0f, 100, default, 1f); + int lostLeftFistDust = Dust.NewDust(new Vector2(NPC.Center.X - 80f * NPC.scale, NPC.Center.Y - 9f), 8, 8, DustID.Smoke, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[lostLeftFistDust]; dust.alpha += Main.rand.Next(100); dust.velocity *= 0.2f; @@ -128,7 +128,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.rand.NextBool(10)) { - lostLeftFistDust = Dust.NewDust(new Vector2(npc.Center.X - 80f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Torch, 0f, 0f, 0, default, 1f); + lostLeftFistDust = Dust.NewDust(new Vector2(NPC.Center.X - 80f * NPC.scale, NPC.Center.Y - 9f), 8, 8, DustID.Torch, 0f, 0f, 0, default, 1f); if (!Main.rand.NextBool(20)) { Main.dust[lostLeftFistDust].noGravity = true; @@ -140,7 +140,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (!rightFistAlive) { - int lostRightFistDust = Dust.NewDust(new Vector2(npc.Center.X + 62f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Smoke, 0f, 0f, 100, default, 1f); + int lostRightFistDust = Dust.NewDust(new Vector2(NPC.Center.X + 62f * NPC.scale, NPC.Center.Y - 9f), 8, 8, DustID.Smoke, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[lostRightFistDust]; dust.alpha += Main.rand.Next(100); dust.velocity *= 0.2f; @@ -149,7 +149,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.rand.NextBool(10)) { - lostRightFistDust = Dust.NewDust(new Vector2(npc.Center.X + 62f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Torch, 0f, 0f, 0, default, 1f); + lostRightFistDust = Dust.NewDust(new Vector2(NPC.Center.X + 62f * NPC.scale, NPC.Center.Y - 9f), 8, 8, DustID.Torch, 0f, 0f, 0, default, 1f); if (!Main.rand.NextBool(20)) { Main.dust[lostRightFistDust].noGravity = true; @@ -161,346 +161,221 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (npc.noTileCollide && !Main.player[npc.target].dead) + if (NPC.noTileCollide && !Main.player[NPC.target].dead) { - if (npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) - npc.noTileCollide = false; - else if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.noTileCollide = false; + if (NPC.velocity.Y > 0f && NPC.Bottom.Y > Main.player[NPC.target].Top.Y) + NPC.noTileCollide = false; + else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.noTileCollide = false; } // Jump - if (npc.ai[0] == 0f) + if (NPC.ai[0] == 0f) { - if (npc.velocity.Y == 0f || npc.ai[2] > 0f) + if (NPC.velocity.Y == 0f || NPC.ai[2] > 0f) { // Avoid cheap bullshit - npc.damage = 0; - - // Laser fire when head is dead - if (Main.netMode != NetmodeID.MultiplayerClient && (!headAlive || turboEnrage || CalamityWorld.LegendaryMode) && npc.ai[2] == 0f) - { - npc.localAI[1] += 1f; - - float divisor = 15f - - (phase2 ? 4f : 0f) - - (phase3 ? 3f : 0f) - - (phase4 ? 2f : 0f); - - if (enrage) - divisor = 5f; - - if (turboEnrage && Main.getGoodWorld) - divisor = 2f; - - Vector2 projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y - 60f); - if (npc.localAI[1] % divisor == 0f && (Vector2.Distance(Main.player[npc.target].Center, projectileFirePos) > 160f || !freeHeadAlive)) - { - float laserSpeed = turboEnrage ? 16f : enrage ? 12f : 6f; - float laserTargetXDist = Main.player[npc.target].Center.X - projectileFirePos.X; - float laserTargetYDist = Main.player[npc.target].Center.Y - projectileFirePos.Y; - float laserTargetDistance = (float)Math.Sqrt(laserTargetXDist * laserTargetXDist + laserTargetYDist * laserTargetYDist); - - laserTargetDistance = laserSpeed / laserTargetDistance; - laserTargetXDist *= laserTargetDistance; - laserTargetYDist *= laserTargetDistance; - - Vector2 laserVelocity = new Vector2(laserTargetXDist, laserTargetYDist); - int type = ProjectileID.EyeBeam; - int damage = npc.GetProjectileDamage(type); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int bodyLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[bodyLaser].timeLeft = enrage ? 720 : 360; - if (turboEnrage && Main.getGoodWorld) - Main.projectile[bodyLaser].extraUpdates += 1; - } - } - - if (npc.localAI[1] >= 15f) - npc.localAI[1] = 0f; - } + NPC.damage = 0; // Delay before jumping - if (npc.ai[2] == 0f) + if (NPC.ai[2] == 0f) { - npc.velocity.X *= 0.8f; - npc.ai[1] += 1f; + NPC.velocity.X *= 0.8f; + NPC.ai[1] += 1f; } - if (npc.ai[1] > 0f) + if (NPC.ai[1] > 0f) { - npc.ai[1] += (death ? 2f : 1f); + NPC.ai[1] += death ? 1.5f : 1f; if (Main.getGoodWorld) - npc.ai[1] += 100f; + NPC.ai[1] += 100f; if (enrage || death) { - npc.ai[1] += 18f; + NPC.ai[1] += 18f; } else { if (!leftFistAlive) - npc.ai[1] += 6f; + NPC.ai[1] += 6f; if (!rightFistAlive) - npc.ai[1] += 6f; - if (!headAlive) - npc.ai[1] += 6f; + NPC.ai[1] += 6f; } } - if (npc.ai[1] >= 300f) + bool canJump = (!headAlive || Main.npc[NPC.FindFirstNPC(NPCID.GolemHead)].ai[0] <= 1f) && (!NPC.AnyNPCs(NPCID.GolemHeadFree) || Main.npc[NPC.FindFirstNPC(NPCID.GolemHeadFree)].ai[0] != 3); + if (NPC.ai[1] >= 300f && canJump) { - npc.ai[1] = -20f; - npc.frameCounter = 0D; + NPC.ai[1] = -20f; + NPC.frameCounter = 0D; } - else if (npc.ai[1] == -1f) + else if (NPC.ai[1] == -1f) { // Set jump velocity if (!headAlive) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); // Set damage - npc.damage = npc.defDamage; + NPC.damage = NPC.defDamage; - if (death) + if (NPC.ai[3] == 0f) + NPC.ai[3] = (death ? !leftFistAlive && !rightFistAlive : !headAlive) ? Main.rand.Next(1, 2 + 1) : 1f; + + switch ((int)NPC.ai[3]) { - float straightUpJumpHeight = 640f; - if (npc.ai[3] == 0f) - npc.ai[3] = (!headAlive && npc.Bottom.Y - straightUpJumpHeight > Main.player[npc.target].Top.Y) ? Main.rand.Next(3) + 1f : (!leftFistAlive && !rightFistAlive) ? Main.rand.Next(2) + 1f : 1f; + default: + case 0: + case 1: + NormalJump(canJump); + break; - switch ((int)npc.ai[3]) - { - default: - case 0: - case 1: - NormalJump(); - break; - - // Jump directly above the target's head and slam down - case 2: - - npc.noTileCollide = true; - - npc.ai[2] += 1f; - float jumpVelocity = 26f; - if (enrage) - jumpVelocity *= 1.25f; - if (turboEnrage) - jumpVelocity *= 1.25f; - - float minJumpTime = 15f; - float maxJumpTime = 45f; - if ((npc.ai[2] >= minJumpTime && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) <= jumpVelocity) || npc.ai[2] >= maxJumpTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.velocity.Y = -3f; - npc.netUpdate = true; - } - - Vector2 center = npc.Center; - if (!Main.player[npc.target].dead && Main.player[npc.target].active && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) <= despawnDistance) - center = Main.player[npc.target].Center; - - center.Y -= 480f; - if (npc.velocity.Y == 0f) - { - npc.velocity = center - npc.Center; - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero); - npc.velocity *= jumpVelocity; - - float distanceBelowTarget = npc.position.Y - (Main.player[npc.target].position.Y + 80f); - float speedMult = 1f; - - float multiplier = turboEnrage ? 0.0025f : enrage ? 0.002f : 0.0015f; - if (distanceBelowTarget > 0f && ((!leftFistAlive && !rightFistAlive) || turboEnrage || CalamityWorld.LegendaryMode)) - speedMult += distanceBelowTarget * multiplier; - - float speedMultLimit = turboEnrage ? 3.25f : enrage ? 3f : 2.5f; - if (speedMult > speedMultLimit) - speedMult = speedMultLimit; - - if (Main.player[npc.target].position.Y < npc.Bottom.Y) - npc.velocity.Y *= speedMult; - } - else - npc.velocity.Y *= 0.95f; - - break; - - // Jump straight up and create a wall of lasers on both sides - case 3: - - npc.velocity.Y = (((!freeHeadAlive && !headAlive) || turboEnrage || CalamityWorld.LegendaryMode) ? -15.1f : -12.1f) + (enrage ? -4f : 0f); - - npc.noTileCollide = true; - - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 2f; - - float jumpDuration = (float)Math.Floor(straightUpJumpHeight / Math.Abs(npc.velocity.Y)); - npc.ai[3] = jumpDuration; - - npc.netUpdate = true; - - break; - } - } - else - { - if (npc.ai[3] == 0f) - npc.ai[3] = !headAlive ? Main.rand.Next(2) + 1f : 1f; - - switch ((int)npc.ai[3]) - { - default: - case 0: - case 1: - NormalJump(); - break; - - // Jump directly above the target's head and slam down - case 2: - - npc.noTileCollide = true; - - npc.ai[2] += 1f; - float jumpVelocity = 21f; - if (enrage) - jumpVelocity *= 1.25f; - if (turboEnrage) - jumpVelocity *= 1.25f; - - float minJumpTime = 15f; - float maxJumpTime = 45f; - if ((npc.ai[2] >= minJumpTime && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) <= jumpVelocity) || npc.ai[2] >= maxJumpTime) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.velocity.Y = -3f; - npc.netUpdate = true; - } - - Vector2 center = npc.Center; - if (!Main.player[npc.target].dead && Main.player[npc.target].active && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) <= despawnDistance) - center = Main.player[npc.target].Center; - - center.Y -= 480f; - if (npc.velocity.Y == 0f) - { - npc.velocity = center - npc.Center; - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero); - npc.velocity *= jumpVelocity; - - float distanceBelowTarget = npc.position.Y - (Main.player[npc.target].position.Y + 80f); - float speedMult = 1f; - - float multiplier = turboEnrage ? 0.0025f : enrage ? 0.002f : 0.0015f; - if (distanceBelowTarget > 0f && ((!leftFistAlive && !rightFistAlive) || turboEnrage || CalamityWorld.LegendaryMode)) - speedMult += distanceBelowTarget * multiplier; - - float speedMultLimit = turboEnrage ? 3.25f : enrage ? 3f : 2.5f; - if (speedMult > speedMultLimit) - speedMult = speedMultLimit; - - if (Main.player[npc.target].position.Y < npc.Bottom.Y) - npc.velocity.Y *= speedMult; - } - else - npc.velocity.Y *= 0.95f; - - break; - } + // Jump directly above the target's head and slam down + case 2: + SlamJump(canJump); + break; } - void NormalJump() + void NormalJump(bool jump) { - float velocityBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - float velocityX = (death ? 9f : 6f) + velocityBoost; + if (!jump) + return; + + float velocityBoost = (death ? 5f : 3.8f) * (1f - (lifeRatio / 2)); + float velocityX = (death ? 6f : 4f) + velocityBoost; if (enrage) velocityX *= 1.5f; - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - calamityGlobalNPC.newAI[1] = npc.direction; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + calamityGlobalNPC.newAI[1] = NPC.direction; - npc.velocity.X = velocityX * npc.direction; + NPC.velocity.X = velocityX * NPC.direction; - float distanceBelowTarget = npc.position.Y - (Main.player[npc.target].position.Y + 80f); + float distanceBelowTarget = NPC.position.Y - (Main.player[NPC.target].position.Y + 80f); float speedMult = 1f; - float multiplier = turboEnrage ? 0.0025f : enrage ? 0.002f : 0.0015f; - if (distanceBelowTarget > 0f && ((!leftFistAlive && !rightFistAlive) || turboEnrage || CalamityWorld.LegendaryMode)) + float multiplier = turboEnrage ? 0.00275f : enrage ? 0.0025f : 0.00175f; + if (distanceBelowTarget > 0f && ((!leftFistAlive && !rightFistAlive) || turboEnrage)) speedMult += distanceBelowTarget * multiplier; float speedMultLimit = turboEnrage ? 3.25f : enrage ? 3f : 2.5f; if (speedMult > speedMultLimit) speedMult = speedMultLimit; - if (Main.player[npc.target].position.Y < npc.Bottom.Y) - npc.velocity.Y = ((((!freeHeadAlive && !headAlive) || turboEnrage || CalamityWorld.LegendaryMode) ? -15.1f : -12.1f) + (enrage ? -4f : 0f)) * speedMult; + if (Main.player[NPC.target].position.Y < NPC.Bottom.Y) + NPC.velocity.Y = ((turboEnrage ? -15.5f : -11.75f) + (enrage ? -4f : 0f)) * speedMult; else - npc.velocity.Y = 1f; + NPC.velocity.Y = 1f; - npc.noTileCollide = true; + NPC.noTileCollide = true; - npc.ai[0] = 1f; - npc.ai[1] = 0f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; - npc.netUpdate = true; - npc.SyncExtraAI(); + NPC.netUpdate = true; + NPC.SyncExtraAI(); + } + + void SlamJump(bool jump) + { + NPC.noTileCollide = true; + + NPC.ai[2] += 1f; + float jumpVelocity = death ? 26f : 21f; + if (enrage) + jumpVelocity *= 1.25f; + if (turboEnrage) + jumpVelocity *= 1.25f; + + float minJumpTime = 15f; + float maxJumpTime = 45f; + if ((NPC.ai[2] >= minJumpTime && Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) <= jumpVelocity) || NPC.ai[2] >= maxJumpTime || !jump) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 1f; + NPC.velocity.Y = -3f; + NPC.netUpdate = true; + } + + if (!jump) + return; + + Vector2 center = NPC.Center; + if (!Main.player[NPC.target].dead && Main.player[NPC.target].active && Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) <= despawnDistance) + center = Main.player[NPC.target].Center; + + center.Y -= 480f; + if (NPC.velocity.Y == 0f) + { + NPC.velocity = center - NPC.Center; + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.Zero); + NPC.velocity *= jumpVelocity; + + float distanceBelowTarget = NPC.position.Y - (Main.player[NPC.target].position.Y + 80f); + float speedMult = 1f; + + float multiplier = turboEnrage ? 0.0025f : enrage ? 0.002f : 0.0015f; + if (distanceBelowTarget > 0f && ((!leftFistAlive && !rightFistAlive) || turboEnrage)) + speedMult += distanceBelowTarget * multiplier; + + float speedMultLimit = turboEnrage ? 3.25f : enrage ? 3f : 2.5f; + if (speedMult > speedMultLimit) + speedMult = speedMultLimit; + + if (Main.player[NPC.target].position.Y < NPC.Bottom.Y) + NPC.velocity.Y *= speedMult; + } + else + NPC.velocity.Y *= 0.95f; } } } // Don't run custom gravity when starting a jump - if (npc.ai[0] != 1f && npc.ai[2] == 0f) + if (NPC.ai[0] != 1f && NPC.ai[2] == 0f) CustomGravity(false); } // Fall down - else if (npc.ai[0] == 1f) + else if (NPC.ai[0] == 1f) { - if (npc.velocity.Y == 0f) + if (NPC.velocity.Y == 0f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; // Play sound - SoundEngine.PlaySound(SoundID.Item14, npc.Center); + SoundEngine.PlaySound(SoundID.Item14, NPC.Center); - npc.ai[0] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + NPC.ai[0] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; calamityGlobalNPC.newAI[1] = 0f; - npc.SyncExtraAI(); + NPC.SyncExtraAI(); // Dust and gore - for (int i = (int)npc.position.X - 20; i < (int)npc.position.X + npc.width + 40; i += 20) + for (int i = (int)NPC.position.X - 20; i < (int)NPC.position.X + NPC.width + 40; i += 20) { for (int j = 0; j < 4; j++) { - int fallDust = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + npc.height), npc.width + 20, 4, DustID.Smoke, 0f, 0f, 100, default, 1.5f); + int fallDust = Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y + NPC.height), NPC.width + 20, 4, DustID.Smoke, 0f, 0f, 100, default, 1.5f); Dust dust = Main.dust[fallDust]; dust.velocity *= 0.2f; } if (!Main.dedServ) { - int fallGore = Gore.NewGore(npc.GetSource_FromAI(), new Vector2(i - 20, npc.position.Y + npc.height - 8f), default, Main.rand.Next(61, 64), 1f); + int fallGore = Gore.NewGore(NPC.GetSource_FromAI(), new Vector2(i - 20, NPC.position.Y + NPC.height - 8f), default, Main.rand.Next(61, 64), 1f); Gore gore = Main.gore[fallGore]; gore.velocity *= 0.4f; } } // Fireball explosion when head is detached - if (Main.netMode != NetmodeID.MultiplayerClient && (!headAlive || turboEnrage || CalamityWorld.LegendaryMode)) + if (Main.netMode != NetmodeID.MultiplayerClient && (!headAlive || turboEnrage)) { for (int i = 0; i < 10; i++) { - int fiery = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 2f); + int fiery = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); Main.dust[fiery].velocity.Y *= 6f; Main.dust[fiery].velocity.X *= 3f; if (Main.rand.NextBool()) @@ -511,2002 +386,1048 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } for (int j = 0; j < 20; j++) { - int fiery2 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 3f); + int fiery2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 3f); Main.dust[fiery2].noGravity = true; Main.dust[fiery2].velocity.Y *= 10f; - fiery2 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default, 2f); + fiery2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); Main.dust[fiery2].velocity.X *= 2f; } - float projectileVelocity = death ? 11.25f : 7.5f; + float projectileVelocity = death ? 7.5f : 4.75f; if (enrage) projectileVelocity *= 1.5f; if (turboEnrage) projectileVelocity *= 1.25f; int type = ProjectileID.Fireball; - int damage = npc.GetProjectileDamage(type); - Vector2 destination = new Vector2(npc.Center.X, npc.Center.Y - 100f) - npc.Center; + int damage = FireballDamage; + Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; destination.Normalize(); destination *= projectileVelocity; int totalFireballsPerSide = 3; - int totalIterations = (turboEnrage && Main.getGoodWorld) ? 11 : death ? 25 : 35; + int totalIterations = turboEnrage ? 11 : death ? 40 : 60; float rotation = MathHelper.ToRadians(90); for (int i = 0; i < totalIterations; i++) { - // Spawn projectiles 0, 1, 2, 22, 23, and 24 (in non-master) + // Spawn projectiles 0, 1, 2, 22, 23, and 24 if (i < totalFireballsPerSide || i >= totalIterations - totalFireballsPerSide) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(totalIterations - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.UnitY * (npc.height / 2 * 0.8f) * npc.scale + Vector2.Normalize(perturbedSpeed) * (npc.width / 3) * npc.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = enrage ? 480 : 240; - if (turboEnrage && Main.getGoodWorld) + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * (NPC.height / 2 * 0.8f) * NPC.scale + Vector2.Normalize(perturbedSpeed) * (NPC.width / 3) * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = enrage ? 480 : 150; // The difference is meant to be this stark. + if (turboEnrage) Main.projectile[proj].extraUpdates += 1; } } - npc.netUpdate = true; + NPC.netUpdate = true; } } else { // Set damage - npc.damage = npc.defDamage; + NPC.damage = NPC.defDamage; // Velocity when falling - if (npc.ai[2] == 2f) + if ((NPC.position.X < Main.player[NPC.target].position.X && NPC.position.X + NPC.width > Main.player[NPC.target].position.X + Main.player[NPC.target].width) || NPC.ai[2] == 1f) { - // Do not collide with tiles while doing this crazy shit - npc.noTileCollide = true; + NPC.velocity.X *= NPC.ai[2] == 1f ? 0.5f : 0.8f; - float laserShootGateValue = death ? 6f : 9f; - if (npc.ai[3] % laserShootGateValue == 0f) + if (NPC.Bottom.Y < Main.player[NPC.target].position.Y || NPC.ai[2] == 1f) { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 fireFrom = new Vector2(npc.Center.X, npc.Center.Y - 60f); - int projectileAmt = 2; - int type = ProjectileID.EyeBeam; - int damage = npc.GetProjectileDamage(type); - Vector2 laserVelocity = Vector2.UnitY * npc.velocity.Y * (turboEnrage ? 2f : enrage ? 1f : 0.5f); - for (int i = 0; i < projectileAmt; i++) - { - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int j = 0; j < totalProjectiles; j++) - { - Vector2 projVelocity = laserVelocity.RotatedBy(radians * j + MathHelper.PiOver2); - int bodyLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom, projVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[bodyLaser].timeLeft = enrage ? 720 : 360; - if (turboEnrage && Main.getGoodWorld) - Main.projectile[bodyLaser].extraUpdates += 1; - } - } - } - } + float fallSpeedBoost = death ? 0.9f * (1f - (lifeRatio / 2)) : 0.75f * (1f - (lifeRatio / 2)); + float fallSpeed = (death ? 0.3f : 0.2f) + fallSpeedBoost; + if (enrage) + fallSpeed *= 2f; - npc.ai[3] -= 1f; - if (npc.ai[3] <= 0f) - { - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.ForceNetUpdate(); + NPC.velocity.Y += fallSpeed; } } else { - if ((npc.position.X < Main.player[npc.target].position.X && npc.position.X + npc.width > Main.player[npc.target].position.X + Main.player[npc.target].width) || npc.ai[2] == 1f) - { - npc.velocity.X *= npc.ai[2] == 1f ? 0.5f : 0.8f; + float velocityChangeBoost = death ? 0.16f * (1f - (lifeRatio / 2)) : 0.12f * (1f - (lifeRatio / 2)); + float velocityXChange = (death ? 0.285f : 0.2f) + velocityChangeBoost; + if (NPC.direction < 0) + NPC.velocity.X -= velocityXChange; + else if (NPC.direction > 0) + NPC.velocity.X += velocityXChange; - if (npc.Bottom.Y < Main.player[npc.target].position.Y || npc.ai[2] == 1f) - { - float fallSpeedBoost = death ? 1.2f * (1f - lifeRatio) : 0.8f * (1f - lifeRatio); - float fallSpeed = (death ? 0.3f : 0.2f) + fallSpeedBoost; - if (enrage) - fallSpeed *= 2f; + float velocityBoost = death ? 5.75f * (1f - (lifeRatio / 2)) : 4f * (1f - (lifeRatio / 2)); + float velocityXCap = (death ? 6f : 4f) + velocityBoost; + if (enrage) + velocityXCap *= 3f; - npc.velocity.Y += fallSpeed; - } - } - else - { - float velocityChangeBoost = death ? 0.18f * (1f - lifeRatio) : 0.12f * (1f - lifeRatio); - float velocityXChange = (death ? 0.3f : 0.2f) + velocityChangeBoost; - if (npc.direction < 0) - npc.velocity.X -= velocityXChange; - else if (npc.direction > 0) - npc.velocity.X += velocityXChange; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + int directionRelativeToTarget = playerLocation < 0 ? 1 : -1; + bool slowDown = directionRelativeToTarget != calamityGlobalNPC.newAI[1]; - float velocityBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - float velocityXCap = (death ? 9f : 6f) + velocityBoost; - if (enrage) - velocityXCap *= 3f; + if (slowDown) + velocityXCap *= (enrage ? 0.2f : 0.5f); - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - int directionRelativeToTarget = playerLocation < 0 ? 1 : -1; - bool slowDown = directionRelativeToTarget != calamityGlobalNPC.newAI[1]; - - if (slowDown) - velocityXCap *= (enrage ? 0.2f : 0.5f); - - if (npc.velocity.X < -velocityXCap) - npc.velocity.X = -velocityXCap; - if (npc.velocity.X > velocityXCap) - npc.velocity.X = velocityXCap; - } - - CustomGravity(npc.ai[2] == 1f); + if (NPC.velocity.X < -velocityXCap) + NPC.velocity.X = -velocityXCap; + if (NPC.velocity.X > velocityXCap) + NPC.velocity.X = velocityXCap; } + + CustomGravity(NPC.ai[2] == 1f); } } void CustomGravity(bool isSlamming) { - float gravity = turboEnrage ? (Main.getGoodWorld ? 1.15f : 0.85f) : enrage ? 0.75f : (!leftFistAlive && !rightFistAlive) ? 0.45f : 0.3f; - float maxFallSpeed = reduceFallSpeed ? 12f : turboEnrage ? (Main.getGoodWorld ? 40f : 30f) : enrage ? 25f : (!leftFistAlive && !rightFistAlive) ? 15f : 10f; + float gravity = turboEnrage ? 0.85f : enrage ? 0.75f : (!leftFistAlive && !rightFistAlive) ? 0.45f : 0.3f; + float maxFallSpeed = reduceFallSpeed ? 12f : turboEnrage ? 30f : enrage ? 25f : (!leftFistAlive && !rightFistAlive) ? 15f : 10f; if (isSlamming && !reduceFallSpeed) { gravity *= 4f; maxFallSpeed *= 2f; } - npc.velocity.Y += gravity; - if (npc.velocity.Y > maxFallSpeed) - npc.velocity.Y = maxFallSpeed; + NPC.velocity.Y += gravity; + if (NPC.velocity.Y > maxFallSpeed) + NPC.velocity.Y = maxFallSpeed; } // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); // Despawn - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > despawnDistance) + if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) + Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > despawnDistance) { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > despawnDistance) + if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) + Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > despawnDistance) { - npc.active = false; - npc.netUpdate = true; + NPC.active = false; + NPC.netUpdate = true; } } return false; } - public static bool BuffedGolemFistAI(NPC npc, Mod mod) + public class FistAI : VanillaAIOverride { - if (NPC.golemBoss < 0) + public override bool AI(Mod mod) { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - - return false; - } - - if (npc.alpha > 0) - { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - NPC golem = Main.npc[NPC.golemBoss]; - Player player = Main.player[npc.target]; - - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - - // Enrage if the target isn't inside the temple - // Turbo enrage if target isn't inside the temple and it's Boss Rush or For the Worthy - bool enrage = true; - bool turboEnrage = false; - if (player.Center.Y > Main.worldSurface * 16.0) - { - int targetTilePosX = (int)player.Center.X / 16; - int targetTilePosY = (int)player.Center.Y / 16; - - Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); - if (tile.WallType == WallID.LihzahrdBrickUnsafe) - enrage = false; - else - turboEnrage = bossRush || Main.getGoodWorld; - } - else - turboEnrage = bossRush || Main.getGoodWorld; - - if (bossRush || Main.getGoodWorld) - enrage = true; - - float aggression = turboEnrage ? (Main.getGoodWorld ? 4f : 3f) : enrage ? 2f : death ? 1.7f : 1f; - - Vector2 fistCenter = golem.Center + golem.velocity + new Vector2(0f, -9f * npc.scale); - fistCenter.X += (float)((npc.type == NPCID.GolemFistLeft) ? -84 : 78) * npc.scale; - Vector2 distanceFromFistCenter = fistCenter - npc.Center; - float distanceFromRestPosition = distanceFromFistCenter.Length(); - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.noTileCollide = true; - - float fistSpeed = 28f; - fistSpeed *= (aggression + 3f) / 4f; - if (fistSpeed > 48f) - fistSpeed = 48f; - - float fistRestDistance = distanceFromRestPosition; - if (fistRestDistance < 12f + fistSpeed) + if (NPC.golemBoss < 0) { - npc.rotation = 0f; - npc.velocity.X = distanceFromFistCenter.X; - npc.velocity.Y = distanceFromFistCenter.Y; + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); - bool canPunch = npc.alpha == 0 && (npc.type == NPCID.GolemFistLeft && npc.Center.X + 100f > player.Center.X) || (npc.type == NPCID.GolemFistRight && npc.Center.X - 100f < player.Center.X); - if (canPunch) - { - float fistShootSpeed = death ? Main.rand.NextFloat(aggression * 0.5f, aggression * 2f) : aggression; - npc.ai[1] += fistShootSpeed; - if (npc.life < npc.lifeMax / 2) - npc.ai[1] += fistShootSpeed; - if (npc.life < npc.lifeMax / 4) - npc.ai[1] += fistShootSpeed; - } + return false; + } - float fistPunchGateValue = death ? 120f : 40f; - if (npc.ai[1] >= fistPunchGateValue) - { - if (canPunch) - { - npc.ai[1] = 0f; - npc.ai[0] = 1f; - } - else - npc.ai[1] = 0f; + if (NPC.alpha > 0) + { + NPC.alpha -= 10; + if (NPC.alpha < 0) + NPC.alpha = 0; + } - // Net update in Master due to rng - if (death) - npc.ForceNetUpdate(); - } + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + NPC golem = Main.npc[NPC.golemBoss]; + Player player = Main.player[NPC.target]; + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Enrage if the target isn't inside the temple + // Turbo enrage if target isn't inside the temple and it's For the Worthy + bool enrage = !BossRushEvent.BossRushActive; + bool turboEnrage = false; + if (player.Center.Y > Main.worldSurface * 16.0 && !BossRushEvent.BossRushActive) + { + int targetTilePosX = (int)player.Center.X / 16; + int targetTilePosY = (int)player.Center.Y / 16; + + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); + if (tile.WallType == WallID.LihzahrdBrickUnsafe) + enrage = false; + else + turboEnrage = Main.getGoodWorld; } else - { - fistRestDistance = fistSpeed / fistRestDistance; - npc.velocity.X = distanceFromFistCenter.X * fistRestDistance; - npc.velocity.Y = distanceFromFistCenter.Y * fistRestDistance; + turboEnrage = Main.getGoodWorld; - npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); - if (npc.type == NPCID.GolemFistLeft) - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - } - } - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; + if (Main.getGoodWorld) + enrage = true; - npc.ai[1] += 1f; - npc.Center = fistCenter; - npc.rotation = 0f; - npc.velocity = Vector2.Zero; - if (npc.ai[1] <= 15f) - { - for (int i = 0; i < 1; i++) - { - Vector2 largeRandDustRadius = Main.rand.NextVector2Circular(80f, 80f); - Vector2 largeRandDustRecoil = largeRandDustRadius * -1f * 0.05f; - Vector2 smallRandDustRadius = Main.rand.NextVector2Circular(20f, 20f); - Dust dust = Dust.NewDustPerfect(npc.Center + largeRandDustRecoil + largeRandDustRadius + smallRandDustRadius, 228, largeRandDustRecoil); - dust.fadeIn = 1.5f; - dust.scale = 0.5f; - if (Main.getGoodWorld) - dust.noLight = true; + float aggression = turboEnrage ? 3f : enrage ? 2f : death ? 1.7f : 1f; - dust.noGravity = true; - } - } - - if (npc.ai[1] >= 30f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.noTileCollide = true; - npc.collideX = false; - npc.collideY = false; - - float fistReturnSpeed = 24f; - fistReturnSpeed *= (aggression + 3f) / 4f; - if (fistReturnSpeed > 48f) - fistReturnSpeed = 48f; - - Vector2 fistCent = npc.Center; - float fistTargetXDist = player.Center.X - fistCent.X; - float fistTargetYDist = player.Center.Y - fistCent.Y; - float fistTargetDistance = (float)Math.Sqrt(fistTargetXDist * fistTargetXDist + fistTargetYDist * fistTargetYDist); - fistTargetDistance = fistReturnSpeed / fistTargetDistance; - npc.velocity.X = fistTargetXDist * fistTargetDistance; - npc.velocity.Y = fistTargetYDist * fistTargetDistance; - npc.ai[0] = 2f; - npc.ai[1] = 0f; - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (npc.type == NPCID.GolemFistLeft) - npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); - } - } - else if (npc.ai[0] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld) - { - for (int j = (int)(npc.position.X / 16f) - 1; (float)j < (npc.position.X + (float)npc.width) / 16f + 1f; j++) - { - for (int k = (int)(npc.position.Y / 16f) - 1; (float)k < (npc.position.Y + (float)npc.width) / 16f + 1f; k++) - { - if (Main.tile[j, k].TileType == TileID.Torches) - { - Main.tile[j, k].Get().HasTile = false; - if (Main.dedServ) - NetMessage.SendTileSquare(-1, j, k); - } - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] == 1f) - SoundEngine.PlaySound(SoundID.Item14, npc.Center); - - if (Main.rand.NextBool()) - { - Vector2 halfVelocityDust = npc.velocity * 0.5f; - Vector2 randDustRadius = Main.rand.NextVector2Circular(20f, 20f); - Dust.NewDustPerfect(npc.Center + halfVelocityDust + randDustRadius, 306, halfVelocityDust, 0, Main.OurFavoriteColor).scale = 2f; - } - - if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) - { - if (npc.velocity.X > 0f && npc.Center.X > player.Center.X) - npc.noTileCollide = false; - - if (npc.velocity.X < 0f && npc.Center.X < player.Center.X) - npc.noTileCollide = false; - } - else - { - if (npc.velocity.Y > 0f && npc.Center.Y > player.Center.Y) - npc.noTileCollide = false; - - if (npc.velocity.Y < 0f && npc.Center.Y < player.Center.Y) - npc.noTileCollide = false; - } - - float maxPunchDistance = 700f; - int explosionLimit = 2; - if (death) - { - if (npc.life < npc.lifeMax / 2) - { - maxPunchDistance += MathHelper.Lerp(-175f, 75f, Main.rand.NextFloat()); - explosionLimit++; - } - if (npc.life < npc.lifeMax / 4) - { - maxPunchDistance += MathHelper.Lerp(-175f, 75f, Main.rand.NextFloat()); - explosionLimit++; - } - } - - if (distanceFromRestPosition > maxPunchDistance || npc.collideX || npc.collideY) + Vector2 fistCenter = golem.Center + golem.velocity + new Vector2(0f, -9f * NPC.scale); + fistCenter.X += (float)((NPC.type == NPCID.GolemFistLeft) ? -84 : 78) * NPC.scale; + Vector2 distanceFromFistCenter = fistCenter - NPC.Center; + float distanceFromRestPosition = distanceFromFistCenter.Length(); + if (NPC.ai[0] == 0f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.noTileCollide = true; - npc.ai[0] = 0f; + NPC.noTileCollide = true; - if (death) + float fistSpeed = 28f; + fistSpeed *= (aggression + 3f) / 4f; + if (fistSpeed > 48f) + fistSpeed = 48f; + + float fistRestDistance = distanceFromRestPosition; + if (fistRestDistance < 12f + fistSpeed) { - int type = ProjectileID.InfernoHostileBlast; - bool shootExplosion = true; - int numExplosions = 0; - for (int i = 0; i < Main.maxProjectiles; i++) + NPC.rotation = 0f; + NPC.velocity.X = distanceFromFistCenter.X; + NPC.velocity.Y = distanceFromFistCenter.Y; + + bool canPunch = NPC.alpha == 0 && (NPC.type == NPCID.GolemFistLeft && NPC.Center.X + 100f > player.Center.X) || (NPC.type == NPCID.GolemFistRight && NPC.Center.X - 100f < player.Center.X); + if (canPunch) { - if (Main.projectile[i].active && Main.projectile[i].type == type) + float fistShootSpeed = death ? Main.rand.NextFloat(aggression * 0.5f, aggression * 2f) : aggression; + NPC.ai[1] += fistShootSpeed; + if (NPC.life < NPC.lifeMax / 2) + NPC.ai[1] += fistShootSpeed; + if (NPC.life < NPC.lifeMax / 4) + NPC.ai[1] += fistShootSpeed; + } + + float fistPunchGateValue = death ? 120f : 40f; + if (NPC.ai[1] >= fistPunchGateValue) + { + if (canPunch) { - numExplosions++; - if (numExplosions >= explosionLimit) + NPC.ai[1] = 0f; + NPC.ai[0] = 1f; + } + else + NPC.ai[1] = 0f; + + // Net update in Master due to rng + if (death) + NPC.ForceNetUpdate(); + } + } + else + { + fistRestDistance = fistSpeed / fistRestDistance; + NPC.velocity.X = distanceFromFistCenter.X * fistRestDistance; + NPC.velocity.Y = distanceFromFistCenter.Y * fistRestDistance; + + NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); + if (NPC.type == NPCID.GolemFistLeft) + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + } + } + else if (NPC.ai[0] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[1] += 1f; + NPC.Center = fistCenter; + NPC.rotation = 0f; + NPC.velocity = Vector2.Zero; + if (NPC.ai[1] <= 15f) + { + for (int i = 0; i < 1; i++) + { + Vector2 largeRandDustRadius = Main.rand.NextVector2Circular(80f, 80f); + Vector2 largeRandDustRecoil = largeRandDustRadius * -1f * 0.05f; + Vector2 smallRandDustRadius = Main.rand.NextVector2Circular(20f, 20f); + Dust dust = Dust.NewDustPerfect(NPC.Center + largeRandDustRecoil + largeRandDustRadius + smallRandDustRadius, DustID.GoldFlame, largeRandDustRecoil); + dust.fadeIn = 1.5f; + dust.scale = 0.5f; + if (Main.getGoodWorld) + dust.noLight = true; + + dust.noGravity = true; + } + } + + if (NPC.ai[1] >= 30f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.noTileCollide = true; + NPC.collideX = false; + NPC.collideY = false; + + float fistReturnSpeed = 24f; + fistReturnSpeed *= (aggression + 3f) / 4f; + if (fistReturnSpeed > 48f) + fistReturnSpeed = 48f; + + Vector2 fistCent = NPC.Center; + float fistTargetXDist = player.Center.X - fistCent.X; + float fistTargetYDist = player.Center.Y - fistCent.Y; + float fistTargetDistance = (float)Math.Sqrt(fistTargetXDist * fistTargetXDist + fistTargetYDist * fistTargetYDist); + fistTargetDistance = fistReturnSpeed / fistTargetDistance; + NPC.velocity.X = fistTargetXDist * fistTargetDistance; + NPC.velocity.Y = fistTargetYDist * fistTargetDistance; + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + if (NPC.type == NPCID.GolemFistLeft) + NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); + } + } + else if (NPC.ai[0] == 2f) + { + // Set damage + NPC.damage = NPC.defDamage; + + if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld) + { + for (int j = (int)(NPC.position.X / 16f) - 1; (float)j < (NPC.position.X + (float)NPC.width) / 16f + 1f; j++) + { + for (int k = (int)(NPC.position.Y / 16f) - 1; (float)k < (NPC.position.Y + (float)NPC.width) / 16f + 1f; k++) + { + if (Main.tile[j, k].TileType == TileID.Torches) { - shootExplosion = false; - break; + Main.tile[j, k].Get().HasTile = false; + if (Main.dedServ) + NetMessage.SendTileSquare(-1, j, k); } } } + } - if (shootExplosion) + NPC.ai[1] += 1f; + if (NPC.ai[1] == 1f) + SoundEngine.PlaySound(SoundID.Item14, NPC.Center); + + if (Main.rand.NextBool()) + { + Vector2 halfVelocityDust = NPC.velocity * 0.5f; + Vector2 randDustRadius = Main.rand.NextVector2Circular(20f, 20f); + Dust.NewDustPerfect(NPC.Center + halfVelocityDust + randDustRadius, DustID.SparkForLightDisc, halfVelocityDust, 0, Main.OurFavoriteColor).scale = 2f; + } + + if (Math.Abs(NPC.velocity.X) > Math.Abs(NPC.velocity.Y)) + { + if (NPC.velocity.X > 0f && NPC.Center.X > player.Center.X) + NPC.noTileCollide = false; + + if (NPC.velocity.X < 0f && NPC.Center.X < player.Center.X) + NPC.noTileCollide = false; + } + else + { + if (NPC.velocity.Y > 0f && NPC.Center.Y > player.Center.Y) + NPC.noTileCollide = false; + + if (NPC.velocity.Y < 0f && NPC.Center.Y < player.Center.Y) + NPC.noTileCollide = false; + } + + float maxPunchDistance = 700f; + if (death) + { + if (NPC.life < NPC.lifeMax / 2) + maxPunchDistance += MathHelper.Lerp(-175f, 75f, Main.rand.NextFloat()); + if (NPC.life < NPC.lifeMax / 4) + maxPunchDistance += MathHelper.Lerp(-175f, 75f, Main.rand.NextFloat()); + } + + if (distanceFromRestPosition > maxPunchDistance || NPC.collideX || NPC.collideY) + { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.noTileCollide = true; + NPC.ai[0] = 0f; + } + } + else + { + if (NPC.ai[0] != 3f) + return false; + + // Set damage + NPC.damage = NPC.defDamage; + + NPC.noTileCollide = true; + float fistAcceleration = 0.4f; + Vector2 returningFistCenter = NPC.Center; + float returningTargetX = player.Center.X - returningFistCenter.X; + float returningTargetY = player.Center.Y - returningFistCenter.Y; + float returningTargetDist = (float)Math.Sqrt(returningTargetX * returningTargetX + returningTargetY * returningTargetY); + returningTargetDist = 12f / returningTargetDist; + returningTargetX *= returningTargetDist; + returningTargetY *= returningTargetDist; + + if (NPC.velocity.X < returningTargetX) + { + NPC.velocity.X += fistAcceleration; + if (NPC.velocity.X < 0f && returningTargetX > 0f) + NPC.velocity.X += fistAcceleration * 2f; + } + else if (NPC.velocity.X > returningTargetX) + { + NPC.velocity.X -= fistAcceleration; + if (NPC.velocity.X > 0f && returningTargetX < 0f) + NPC.velocity.X -= fistAcceleration * 2f; + } + + if (NPC.velocity.Y < returningTargetY) + { + NPC.velocity.Y += fistAcceleration; + if (NPC.velocity.Y < 0f && returningTargetY > 0f) + NPC.velocity.Y += fistAcceleration * 2f; + } + else if (NPC.velocity.Y > returningTargetY) + { + NPC.velocity.Y -= fistAcceleration; + if (NPC.velocity.Y > 0f && returningTargetY < 0f) + NPC.velocity.Y -= fistAcceleration * 2f; + } + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); + if (NPC.type == NPCID.GolemFistLeft) + NPC.rotation = (float)Math.Atan2(-NPC.velocity.Y, -NPC.velocity.X); + } + + return false; + } + } + + public class HeadAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + // Don't collide + NPC.noTileCollide = true; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + options.finishThemOff = true; + CalamityUtils.CalamityTargeting(NPC, options); + } + + // Die if body is gone + if (NPC.golemBoss < 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); + + return false; + } + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Count body parts + bool leftFistAlive = NPC.AnyNPCs(NPCID.GolemFistLeft); + bool rightFistAlive = NPC.AnyNPCs(NPCID.GolemFistRight); + NPC.dontTakeDamage = leftFistAlive || rightFistAlive; + + // Stay in position on top of body + NPC.Center = Main.npc[NPC.golemBoss].Center - new Vector2(3f, 57f) * NPC.scale; + NPC.velocity = Main.npc[NPC.golemBoss].velocity; + + // Enrage if the target isn't inside the temple + bool enrage = !BossRushEvent.BossRushActive; + bool turboEnrage = false; + if (Main.player[NPC.target].Center.Y > Main.worldSurface * 16.0 && !BossRushEvent.BossRushActive) + { + int targetTilePosX = (int)Main.player[NPC.target].Center.X / 16; + int targetTilePosY = (int)Main.player[NPC.target].Center.Y / 16; + + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); + if (tile.WallType == WallID.LihzahrdBrickUnsafe) + enrage = false; + else + turboEnrage = Main.getGoodWorld; + } + else + turboEnrage = Main.getGoodWorld; + + if (Main.getGoodWorld) + enrage = true; + + // Alpha + if (NPC.alpha > 0) + { + NPC.alpha -= 10; + if (NPC.alpha < 0) + NPC.alpha = 0; + + NPC.ai[1] = 30f; + } + + // Spit fireballs if arms are alive + if (NPC.ai[0] == 0f) + { + NPC.ai[1] += 1f; + float openMouthGateValue = (!rightFistAlive || !leftFistAlive) ? 10f : 20f; + float shootFireballGateValue = (!rightFistAlive || !leftFistAlive) ? 60f : 120f; + if (NPC.ai[1] < openMouthGateValue || NPC.ai[1] > shootFireballGateValue - openMouthGateValue) + NPC.localAI[0] = 1f; + else + NPC.localAI[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] >= shootFireballGateValue) + { + NPC.ai[1] = 0f; + + Vector2 headCent = new Vector2(NPC.Center.X, NPC.Center.Y + 10f * NPC.scale); + float headFireballSpeed = turboEnrage ? 24f : enrage ? 18f : 9f; + float headFireballTargetX = Main.player[NPC.target].Center.X - headCent.X; + float headFireballTargetY = Main.player[NPC.target].Center.Y - headCent.Y; + float headFireballTargetDist = (float)Math.Sqrt(headFireballTargetX * headFireballTargetX + headFireballTargetY * headFireballTargetY); + + headFireballTargetDist = headFireballSpeed / headFireballTargetDist; + headFireballTargetX *= headFireballTargetDist; + headFireballTargetY *= headFireballTargetDist; + + int type = ProjectileID.Fireball; + int damage = FireballDamage; + + int fireballAmount = death ? 2 : 1; + Vector2 fireballVelocity = new Vector2(headFireballTargetX, headFireballTargetY); + for (int i = 0; i < fireballAmount; i++) + Projectile.NewProjectile(NPC.GetSource_FromAI(), headCent, fireballVelocity * (1f / (i + 1)), type, damage, 0f, Main.myPlayer); + + NPC.netUpdate = true; + } + } + + // Shoot lasers and fireballs if arms are dead + else if (NPC.ai[0] == 1f) + { + // Fire projectiles from eye positions + Vector2 projectileFirePos = new Vector2(NPC.Center.X, NPC.Center.Y + 10f * NPC.scale); + if (Main.player[NPC.target].Center.X < NPC.Center.X - NPC.width) + { + NPC.localAI[1] = -1f; + projectileFirePos.X -= 40f * NPC.scale; + } + else if (Main.player[NPC.target].Center.X > NPC.Center.X + NPC.width) + { + NPC.localAI[1] = 1f; + projectileFirePos.X += 40f * NPC.scale; + } + else + NPC.localAI[1] = 0f; + + // Timer for special laser attack + NPC.ai[3]++; + if (NPC.ai[3] >= 600f && Main.npc[NPC.golemBoss].velocity.Y == 0f && MathF.Abs(Main.npc[NPC.golemBoss].velocity.X) < 0.5f) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.localAI[1] = (Main.player[NPC.target].Center.X > NPC.Center.X).ToDirectionInt(); + NPC.netUpdate = true; + } + + // Fireballs + NPC.ai[1] += 1f; + float openMouthGateValue = 20f - (death ? 15f * (1f - (lifeRatio / 2)) : 10f * (1f - (lifeRatio / 2))); + float shootFireballGateValue = 120f - (death ? 75f * (1f - (lifeRatio / 2)) : 50f * (1f - (lifeRatio / 2))); + if (NPC.ai[1] < openMouthGateValue || NPC.ai[1] > shootFireballGateValue - openMouthGateValue) + NPC.localAI[0] = 1f; + else + NPC.localAI[0] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] >= shootFireballGateValue) + { + NPC.ai[1] = 0f; + + float fireballSpeedFistsDed = turboEnrage ? 28f : enrage ? 21f : 10.5f; + float fireballFistsDedTargetX = Main.player[NPC.target].Center.X - projectileFirePos.X; + float fireballFistsDedTargetY = Main.player[NPC.target].Center.Y - projectileFirePos.Y; + float fireballFistsDedTargetDist = (float)Math.Sqrt(fireballFistsDedTargetX * fireballFistsDedTargetX + fireballFistsDedTargetY * fireballFistsDedTargetY); + + fireballFistsDedTargetDist = fireballSpeedFistsDed / fireballFistsDedTargetDist; + fireballFistsDedTargetX *= fireballFistsDedTargetDist; + fireballFistsDedTargetY *= fireballFistsDedTargetDist; + + int type = ProjectileID.Fireball; + int damage = FireballDamage; + + int fireballAmount = death ? 2 : 1; + Vector2 fireballVelocity = new Vector2(fireballFistsDedTargetX, fireballFistsDedTargetY); + for (int i = 0; i < fireballAmount; i++) { - int damage = npc.GetProjectileDamage(type); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileFirePos, fireballVelocity * (1f / (i + 1)), type, damage, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = 225; + } + + NPC.netUpdate = true; + } + + // Lasers + float shootBoost2 = death ? 4.5f * (1f - (lifeRatio / 2)) : 2.75f * (1f - (lifeRatio / 2)); + NPC.ai[2] += 1f + shootBoost2; + if (enrage) + NPC.ai[2] += 4f; + + if (NPC.ai[2] >= 300f) + { + NPC.ai[2] = 0f; + + int projType = ProjectileID.EyeBeam; + int dmg = LaserDamage; + + if (NPC.localAI[1] == 0f) + { + for (int i = 0; i < 2; i++) + { + projectileFirePos = new Vector2(NPC.Center.X, NPC.Center.Y - 22f * NPC.scale); + if (i == 0) + projectileFirePos.X -= 18f * NPC.scale; + else + projectileFirePos.X += 18f * NPC.scale; + + float laserSpeed = death ? 15f : 12f; + float laserTargetXDist = Main.player[NPC.target].Center.X - projectileFirePos.X; + float laserTargetYDist = Main.player[NPC.target].Center.Y - projectileFirePos.Y; + float laserTargetDistance = (float)Math.Sqrt(laserTargetXDist * laserTargetXDist + laserTargetYDist * laserTargetYDist); + + laserTargetDistance = laserSpeed / laserTargetDistance; + laserTargetXDist *= laserTargetDistance; + laserTargetYDist *= laserTargetDistance; + + Vector2 laserVelocity = new Vector2(laserTargetXDist, laserTargetYDist); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int bodyLaser = Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileFirePos + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, projType, dmg, 0f, Main.myPlayer); + Main.projectile[bodyLaser].timeLeft = enrage ? 600 : 300; + if (turboEnrage) + Main.projectile[bodyLaser].extraUpdates += 1; + + NPC.netUpdate = true; + } + } + } + else if (NPC.localAI[1] != 0f) + { + projectileFirePos = new Vector2(NPC.Center.X, NPC.Center.Y - 22f * NPC.scale); + if (NPC.localAI[1] == -1f) + projectileFirePos.X -= 30f * NPC.scale; + else if (NPC.localAI[1] == 1f) + projectileFirePos.X += 30f * NPC.scale; + + float extraLaserSpeed = death ? 15f : 12f; + float extraLaserTargetX = Main.player[NPC.target].Center.X - projectileFirePos.X; + float extraLaserTargetY = Main.player[NPC.target].Center.Y - projectileFirePos.Y; + float extraLaserTargetDist = (float)Math.Sqrt(extraLaserTargetX * extraLaserTargetX + extraLaserTargetY * extraLaserTargetY); + + extraLaserTargetDist = extraLaserSpeed / extraLaserTargetDist; + extraLaserTargetX *= extraLaserTargetDist; + extraLaserTargetY *= extraLaserTargetDist; + + Vector2 laserVelocity = new Vector2(extraLaserTargetX, extraLaserTargetY); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, 0f, 0f, 1f); + { + int extraLasers = Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileFirePos + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, projType, dmg, 0f, Main.myPlayer); + Main.projectile[extraLasers].timeLeft = enrage ? 600 : 300; + if (turboEnrage) + Main.projectile[extraLasers].extraUpdates += 1; + + NPC.netUpdate = true; + } } } } - } - else - { - if (npc.ai[0] != 3f) - return false; - // Set damage - npc.damage = npc.defDamage; - - npc.noTileCollide = true; - float fistAcceleration = 0.4f; - Vector2 returningFistCenter = npc.Center; - float returningTargetX = player.Center.X - returningFistCenter.X; - float returningTargetY = player.Center.Y - returningFistCenter.Y; - float returningTargetDist = (float)Math.Sqrt(returningTargetX * returningTargetX + returningTargetY * returningTargetY); - returningTargetDist = 12f / returningTargetDist; - returningTargetX *= returningTargetDist; - returningTargetY *= returningTargetDist; - - if (npc.velocity.X < returningTargetX) + // Special laser spread attack + else if (NPC.ai[0] == 2f || NPC.ai[0] == 3f) { - npc.velocity.X += fistAcceleration; - if (npc.velocity.X < 0f && returningTargetX > 0f) - npc.velocity.X += fistAcceleration * 2f; - } - else if (npc.velocity.X > returningTargetX) - { - npc.velocity.X -= fistAcceleration; - if (npc.velocity.X > 0f && returningTargetX < 0f) - npc.velocity.X -= fistAcceleration * 2f; + int telegraphTime = 60; + int endTime = 120; + Vector2 spawnLocation = new Vector2(NPC.Center.X + (30f * NPC.scale * NPC.localAI[1]), NPC.Center.Y - 22f * NPC.scale); + if (NPC.ai[1] == 1f) + { + SparkleParticle eyeTele = new(spawnLocation, Vector2.Zero, Color.Yellow, Color.White, 1.25f * NPC.scale, telegraphTime, MathHelper.Pi * 0.02f, needed: true); + GeneralParticleHandler.SpawnParticle(eyeTele); + } + + NPC.ai[1]++; + if (NPC.ai[1] >= telegraphTime && NPC.ai[1] < endTime && NPC.ai[1] % 2f == 0f) + { + // Manually plays the sound at a slower rate (the sound from the lasers is disabled by setting ai[1]) + if (NPC.ai[1] % 10f == 0f) + SoundEngine.PlaySound(SoundID.Item33, spawnLocation); + + float laserFireAngle = MathHelper.ToRadians((NPC.ai[1] - telegraphTime + 20) * (death ? 2.45f : 2f)); + Vector2 laserVelocity = Vector2.UnitY.RotatedBy(laserFireAngle * -NPC.localAI[1]) * (death ? 15f : 12f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int extraLasers = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnLocation + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, ProjectileID.EyeBeam, LaserDamage, 0f, Main.myPlayer, 0f, 1f); + Main.projectile[extraLasers].timeLeft = enrage ? 600 : 300; + if (turboEnrage) + Main.projectile[extraLasers].extraUpdates += 1; + + NPC.netUpdate = true; + } + } + + // Do another attack in the opposite direction in Death Mode + if (death && NPC.ai[0] == 2f && NPC.ai[1] >= endTime) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.localAI[1] = -NPC.localAI[1]; + NPC.netUpdate = true; + } + + if (NPC.ai[1] >= endTime + 30) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } } - if (npc.velocity.Y < returningTargetY) + // Laser fire if arms are dead + if ((!leftFistAlive && !rightFistAlive) || death || Main.getGoodWorld) { - npc.velocity.Y += fistAcceleration; - if (npc.velocity.Y < 0f && returningTargetY > 0f) - npc.velocity.Y += fistAcceleration * 2f; + if (NPC.ai[0] <= 1f) + NPC.ai[0] = 1f; } - else if (npc.velocity.Y > returningTargetY) - { - npc.velocity.Y -= fistAcceleration; - if (npc.velocity.Y > 0f && returningTargetY < 0f) - npc.velocity.Y -= fistAcceleration * 2f; - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (npc.type == NPCID.GolemFistLeft) - npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); - } - - return false; - } - - public static bool BuffedGolemHeadAI(NPC npc, Mod mod) - { - // Don't collide - npc.noTileCollide = true; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - } - - // Die if body is gone - if (NPC.golemBoss < 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); + else + NPC.ai[0] = 0f; return false; } - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - - // Count body parts - bool leftFistAlive = NPC.AnyNPCs(NPCID.GolemFistLeft); - bool rightFistAlive = NPC.AnyNPCs(NPCID.GolemFistRight); - npc.dontTakeDamage = (leftFistAlive || rightFistAlive) && !CalamityWorld.LegendaryMode; - - // Stay in position on top of body - npc.Center = Main.npc[NPC.golemBoss].Center - new Vector2(3f, 57f) * npc.scale; - - // Enrage if the target isn't inside the temple - bool enrage = true; - bool turboEnrage = false; - if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) + public override void FindFrame(Mod mod, int frameHeight) { - int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; - int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; - - Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); - if (tile.WallType == WallID.LihzahrdBrickUnsafe) - enrage = false; - else - turboEnrage = bossRush || Main.getGoodWorld; - } - else - turboEnrage = bossRush || Main.getGoodWorld; - - if (bossRush || Main.getGoodWorld) - enrage = true; - - // Alpha - if (npc.alpha > 0) - { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; - - npc.ai[1] = 30f; - } - - // Spit fireballs if arms are alive - if (npc.ai[0] == 0f) - { - npc.ai[1] += 1f; - float openMouthGateValue = (!rightFistAlive || !leftFistAlive) ? 10f : 20f; - float shootFireballGateValue = (!rightFistAlive || !leftFistAlive) ? 60f : 120f; - if (npc.ai[1] < openMouthGateValue || npc.ai[1] > shootFireballGateValue - openMouthGateValue) - npc.localAI[0] = 1f; - else - npc.localAI[0] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) + // Used to force the head to look to the sides for the laser spread attack + if (NPC.ai[0] == 2f || NPC.ai[0] == 3f) { - npc.ai[1] = 0f; - - Vector2 headCent = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); - float headFireballSpeed = turboEnrage ? 24f : enrage ? 18f : 9f; - float headFireballTargetX = Main.player[npc.target].Center.X - headCent.X; - float headFireballTargetY = Main.player[npc.target].Center.Y - headCent.Y; - float headFireballTargetDist = (float)Math.Sqrt(headFireballTargetX * headFireballTargetX + headFireballTargetY * headFireballTargetY); - - headFireballTargetDist = headFireballSpeed / headFireballTargetDist; - headFireballTargetX *= headFireballTargetDist; - headFireballTargetY *= headFireballTargetDist; - - int type = ProjectileID.Fireball; - int damage = npc.GetProjectileDamage(type); - - int fireballAmount = death ? 2 : 1; - Vector2 fireballVelocity = new Vector2(headFireballTargetX, headFireballTargetY); - for (int i = 0; i < fireballAmount; i++) - Projectile.NewProjectile(npc.GetSource_FromAI(), headCent, fireballVelocity * (1f / (i + 1)), type, damage, 0f, Main.myPlayer); - - npc.netUpdate = true; + if (NPC.localAI[1] == 1f) + NPC.frame.Y = frameHeight * 2; + else + NPC.frame.Y = frameHeight * 4; } } + } - // Shoot lasers and fireballs if arms are dead - else if (npc.ai[0] == 1f) + public class HeadFreeAI : VanillaAIOverride + { + public override bool AI(Mod mod) { - // Fire projectiles from eye positions - Vector2 projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); - if (Main.player[npc.target].Center.X < npc.Center.X - npc.width) + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) { - npc.localAI[1] = -1f; - projectileFirePos.X -= 40f * npc.scale; + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + options.finishThemOff = true; + CalamityUtils.CalamityTargeting(NPC, options); } - else if (Main.player[npc.target].Center.X > npc.Center.X + npc.width) + + // Die if body is gone + if (NPC.golemBoss < 0) { - npc.localAI[1] = 1f; - projectileFirePos.X += 40f * npc.scale; + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); + + return false; + } + + // Percent life remaining + float golemLifeRatio = Main.npc[NPC.golemBoss].life / (float)Main.npc[NPC.golemBoss].lifeMax; + float PosDelay = 270f; + + // Phases + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool phase2 = golemLifeRatio < 0.66f; + bool phase3 = golemLifeRatio < 0.33f; + + // Enrage if the target isn't inside the temple + bool enrage = !BossRushEvent.BossRushActive; + bool turboEnrage = false; + if (Main.player[NPC.target].Center.Y > Main.worldSurface * 16.0 && !BossRushEvent.BossRushActive) + { + int targetTilePosX = (int)Main.player[NPC.target].Center.X / 16; + int targetTilePosY = (int)Main.player[NPC.target].Center.Y / 16; + + Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); + if (tile.WallType == WallID.LihzahrdBrickUnsafe) + enrage = false; + else + turboEnrage = Main.getGoodWorld; } else - npc.localAI[1] = 0f; + turboEnrage = Main.getGoodWorld; - // Fireballs - npc.ai[1] += 1f; - float openMouthGateValue = 20f - (death ? 15f * (1f - lifeRatio) : 10f * (1f - lifeRatio)); - float shootFireballGateValue = 120f - (death ? 90f * (1f - lifeRatio) : 60f * (1f - lifeRatio)); - if (npc.ai[1] < openMouthGateValue || npc.ai[1] > shootFireballGateValue - openMouthGateValue) - npc.localAI[0] = 1f; - else - npc.localAI[0] = 0f; + if (Main.getGoodWorld) + enrage = true; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) + // Float through tiles or not + NPC.noTileCollide = !Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1) || phase2 || turboEnrage; + + // Immediately trigger the laser spread attack at phase transition thresholds + if (phase2 && NPC.ai[0] == 0f || phase3 && NPC.ai[0] == 1f) { - npc.ai[1] = 0f; + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = PosDelay; + calamityGlobalNPC.newAI[3] = 0; + NPC.netUpdate = true; + NPC.SyncExtraAI(); + } - float fireballSpeedFistsDed = turboEnrage ? 28f : enrage ? 21f : 10.5f; - float fireballFistsDedTargetX = Main.player[npc.target].Center.X - projectileFirePos.X; - float fireballFistsDedTargetY = Main.player[npc.target].Center.Y - projectileFirePos.Y; - float fireballFistsDedTargetDist = (float)Math.Sqrt(fireballFistsDedTargetX * fireballFistsDedTargetX + fireballFistsDedTargetY * fireballFistsDedTargetY); - - fireballFistsDedTargetDist = fireballSpeedFistsDed / fireballFistsDedTargetDist; - fireballFistsDedTargetX *= fireballFistsDedTargetDist; - fireballFistsDedTargetY *= fireballFistsDedTargetDist; - - int type = ProjectileID.Fireball; - int damage = npc.GetProjectileDamage(type); - - int fireballAmount = death ? 3 : 1; - Vector2 fireballVelocity = new Vector2(fireballFistsDedTargetX, fireballFistsDedTargetY); - for (int i = 0; i < fireballAmount; i++) + // Move to new location + float maxDistanceDiagonal = 360f; + float maxDistanceStraight = 480f; + if (NPC.ai[3] <= 0f) + { + NPC.ai[3] = PosDelay; + calamityGlobalNPC.newAI[3] += phase2 ? 1 : 0; + if (calamityGlobalNPC.newAI[3] >= 7) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos, fireballVelocity * (1f / (i + 1)), type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 450; + calamityGlobalNPC.newAI[3] = 0; + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[3] = PosDelay; } - npc.netUpdate = true; + // Four positions around target + if (!(phase3 || turboEnrage)) + { + if (phase2) + { + // 0 is top left, then goes counter-clockwise + switch ((int)(calamityGlobalNPC.newAI[3] % 4)) + { + case 0: + calamityGlobalNPC.newAI[0] = -maxDistanceDiagonal; + calamityGlobalNPC.newAI[1] = -maxDistanceDiagonal; + break; + case 1: + calamityGlobalNPC.newAI[0] = -maxDistanceDiagonal; + calamityGlobalNPC.newAI[1] = maxDistanceDiagonal; + break; + case 2: + calamityGlobalNPC.newAI[0] = maxDistanceDiagonal; + calamityGlobalNPC.newAI[1] = maxDistanceDiagonal; + break; + case 3: + calamityGlobalNPC.newAI[0] = maxDistanceDiagonal; + calamityGlobalNPC.newAI[1] = -maxDistanceDiagonal; + break; + } + } + + // Above target + else + { + calamityGlobalNPC.newAI[0] = Main.rand.NextFloat(-150f, 150f); + calamityGlobalNPC.newAI[1] = -maxDistanceStraight * 0.85f; + } + } + + NPC.netSpam = 5; + NPC.SyncExtraAI(); + NPC.ForceNetUpdate(); + } + + float positioningInc = enrage ? 6f : phase3 ? 2.5f : phase2 ? 1.8f : 1f; + NPC.ai[3] -= positioningInc; + + // Move in a circle around the player in final phase + if (phase3 || turboEnrage) + { + float spinSpeedMult = enrage ? 2.5f : death ? 1.35f : 1.2f; + calamityGlobalNPC.newAI[0] = maxDistanceStraight * MathF.Sin(MathHelper.ToRadians(NPC.ai[2] * spinSpeedMult)); + calamityGlobalNPC.newAI[1] = maxDistanceStraight * MathF.Cos(MathHelper.ToRadians(NPC.ai[2] * spinSpeedMult)); + } + // Always move above the player during laser spread attack + if (NPC.ai[0] == 3f) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = -maxDistanceStraight * 0.8f; + } + + float offsetX = calamityGlobalNPC.newAI[0]; + float offsetY = calamityGlobalNPC.newAI[1]; + Vector2 destination = Main.player[NPC.target].Center + new Vector2(offsetX, offsetY); + + // Velocity and acceleration + float velocity = (turboEnrage ? 15f : 10f) + + (turboEnrage ? 7.5f : phase2 ? 10f : 0f) + + (turboEnrage ? 7.5f : phase3 ? 15f : 0f); + + if (enrage) + velocity = (phase3 || turboEnrage) ? 35f : 25f; + + float acceleration = NPC.ai[0] == 3f ? 1.5f : phase2 ? 0f : turboEnrage ? 5f : enrage ? 3f : 0.3f; + + // How far Golem's Head is from where it's supposed to be + Vector2 distanceFromDestination = destination - NPC.Center; + // Whether Golem can fire projectiles + bool canFireProjectiles = (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 160f && NPC.ai[0] != 3f) || enrage; + + // Ensure the free head stays still during the attack + if (NPC.ai[0] == 3f && NPC.ai[1] >= 60f) + NPC.velocity = Vector2.Zero; + else + CalamityUtils.SmoothMovement(NPC, 80f, distanceFromDestination, velocity, acceleration, !phase2 || NPC.ai[0] == 3f); + + // Laser spread attack, followed by lingering flame bolts + if (NPC.ai[0] == 3f) + { + int telegraphTime = 60; + int laserEndTime = 120; + int fireballStartTime = 160; + + NPC.ai[1]++; + // Grrrrr stop incrementing the damn timer + NPC.ai[3] = PosDelay; + // Laser spread + if (NPC.ai[1] >= telegraphTime && NPC.ai[1] < laserEndTime && NPC.ai[1] % 2f == 0f) + { + // Manually plays the sound at a slower rate (the sound from the lasers is disabled by setting ai[1]) + if (NPC.ai[1] % 10f == 0f) + SoundEngine.PlaySound(SoundID.Item33, NPC.Center); + + for (int i = -1; i <= 1; i += 2) + { + Vector2 spawnLocation = new Vector2(NPC.Center.X + 14f * NPC.scale * i, NPC.Center.Y - 20f * NPC.scale); + float laserFireAngle = MathHelper.ToRadians((NPC.ai[1] - telegraphTime + 20) * (death ? 2.1f : 2f)); + Vector2 laserVelocity = -Vector2.UnitY.RotatedBy(laserFireAngle * i) * (death ? 15f : 12f); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int spreadLasers = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnLocation + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, ProjectileID.EyeBeam, LaserDamage, 0f, Main.myPlayer, 0f, 1f); + Main.projectile[spreadLasers].timeLeft = enrage ? 600 : 300; + if (turboEnrage) + Main.projectile[spreadLasers].extraUpdates += 1; + + NPC.netUpdate = true; + } + } + } + // Sets the mouth to be open for the upcoming flame bolts + if (NPC.ai[1] > laserEndTime) + NPC.localAI[0] = 1f; + + // Flame bolts + if (NPC.ai[1] >= fireballStartTime && NPC.ai[1] % 30 == 10f) + { + Vector2 spawnLocation = NPC.Center + Vector2.UnitY * 20f * NPC.scale; + Vector2 fireBoltVelocity = Utils.DirectionTo(spawnLocation, Main.player[NPC.target].Center) * (enrage ? 30f : death ? 16f : 12f); + + int type = ModContent.ProjectileType(); + int damage = InfernoBoltDamage; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnLocation, fireBoltVelocity, type, damage, 0f, Main.myPlayer, Main.player[NPC.target].Center.X, Main.player[NPC.target].Center.Y); + } + + // Death fires 2 bolts, Rev fires just 1 + if (NPC.ai[1] >= fireballStartTime + (death ? 40 : 10)) + { + NPC.ai[0] = phase3 ? 2f : 1f; + NPC.ai[1] = 0f; + if (phase3) + calamityGlobalNPC.newAI[2] = Main.rand.Next(120); // Used as a random start point for phase 3 circling + NPC.ai[2] = calamityGlobalNPC.newAI[2]; + NPC.localAI[0] = 0f; + // Needs to be done to properly put it in the top left corner afterwards in phase 2 + calamityGlobalNPC.newAI[0] = -maxDistanceDiagonal; + NPC.netUpdate = true; + NPC.SyncExtraAI(); + } } // Lasers - float shootBoost2 = death ? 5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); - npc.ai[2] += 1f + shootBoost2; - if (enrage) - npc.ai[2] += 4f; + NPC.ai[2] += 1f; - if (npc.ai[2] >= 300f) + int laserGateValue = (int)(PosDelay / positioningInc); + if (canFireProjectiles && Main.netMode != NetmodeID.MultiplayerClient && ((NPC.ai[2] - calamityGlobalNPC.newAI[2]) % (laserGateValue / 2) == 0f)) { - npc.ai[2] = 0f; - - int projType = ProjectileID.EyeBeam; - int dmg = npc.GetProjectileDamage(projType); - - if (npc.localAI[1] == 0f) + int numLasers = 2; + for (int i = 0; i < numLasers; i++) { - for (int i = 0; i < 2; i++) - { - projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y - 22f * npc.scale); - if (i == 0) - projectileFirePos.X -= 18f * npc.scale; - else - projectileFirePos.X += 18f * npc.scale; + Vector2 freeHeadProjSpawn = new Vector2(NPC.Center.X, NPC.Center.Y - 20f * NPC.scale); + freeHeadProjSpawn.X += 14f * NPC.scale * (i == 1).ToDirectionInt(); - float laserSpeed = death ? 15f : 12f; - float laserTargetXDist = Main.player[npc.target].Center.X - projectileFirePos.X; - float laserTargetYDist = Main.player[npc.target].Center.Y - projectileFirePos.Y; - float laserTargetDistance = (float)Math.Sqrt(laserTargetXDist * laserTargetXDist + laserTargetYDist * laserTargetYDist); + float freeHeadProjSpeed = 7f + (5f * (1f - golemLifeRatio)); + Vector2 laserVelocity = Main.player[NPC.target].Center - freeHeadProjSpawn; + laserVelocity = laserVelocity.SafeNormalize(Vector2.UnitY) * freeHeadProjSpeed; - laserTargetDistance = laserSpeed / laserTargetDistance; - laserTargetXDist *= laserTargetDistance; - laserTargetYDist *= laserTargetDistance; - - Vector2 laserVelocity = new Vector2(laserTargetXDist, laserTargetYDist); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int bodyLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, projType, dmg, 0f, Main.myPlayer); - Main.projectile[bodyLaser].timeLeft = enrage ? 600 : 300; - if (turboEnrage && Main.getGoodWorld) - Main.projectile[bodyLaser].extraUpdates += 1; - - npc.netUpdate = true; - } - } - } - else if (npc.localAI[1] != 0f) - { - projectileFirePos = new Vector2(npc.Center.X, npc.Center.Y - 22f * npc.scale); - if (npc.localAI[1] == -1f) - projectileFirePos.X -= 30f * npc.scale; - else if (npc.localAI[1] == 1f) - projectileFirePos.X += 30f * npc.scale; - - float extraLaserSpeed = death ? 15f : 12f; - float extraLaserTargetX = Main.player[npc.target].Center.X - projectileFirePos.X; - float extraLaserTargetY = Main.player[npc.target].Center.Y - projectileFirePos.Y; - float extraLaserTargetDist = (float)Math.Sqrt(extraLaserTargetX * extraLaserTargetX + extraLaserTargetY * extraLaserTargetY); - - extraLaserTargetDist = extraLaserSpeed / extraLaserTargetDist; - extraLaserTargetX *= extraLaserTargetDist; - extraLaserTargetY *= extraLaserTargetDist; - - Vector2 laserVelocity = new Vector2(extraLaserTargetX, extraLaserTargetY); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int extraLasers = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileFirePos + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, projType, dmg, 0f, Main.myPlayer); - Main.projectile[extraLasers].timeLeft = enrage ? 600 : 300; - if (turboEnrage && Main.getGoodWorld) - Main.projectile[extraLasers].extraUpdates += 1; - - npc.netUpdate = true; - } - } - } - } - - // Laser fire if arms are dead - if ((!leftFistAlive && !rightFistAlive) || death || CalamityWorld.LegendaryMode) - { - npc.ai[0] = 1f; - return false; - } - npc.ai[0] = 0f; - - return false; - } - - public static bool BuffedGolemHeadFreeAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - } - - // Die if body is gone - if (NPC.golemBoss < 0) - { - calamityGlobalNPC.DR = 0.25f; - calamityGlobalNPC.unbreakableDR = false; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = false; - - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - - return false; - } - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - float golemLifeRatio = Main.npc[NPC.golemBoss].life / (float)Main.npc[NPC.golemBoss].lifeMax; - - // Phases - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool phase2 = lifeRatio < 0.7f || golemLifeRatio < 0.85f || death; - bool phase3 = lifeRatio < 0.55f || golemLifeRatio < 0.7f || death; - bool phase4 = lifeRatio < 0.4f || golemLifeRatio < 0.55f || death; - - // Enrage if the target isn't inside the temple - bool enrage = true; - bool turboEnrage = false; - if (Main.player[npc.target].Center.Y > Main.worldSurface * 16.0) - { - int targetTilePosX = (int)Main.player[npc.target].Center.X / 16; - int targetTilePosY = (int)Main.player[npc.target].Center.Y / 16; - - Tile tile = Framing.GetTileSafely(targetTilePosX, targetTilePosY); - if (tile.WallType == WallID.LihzahrdBrickUnsafe) - enrage = false; - else - turboEnrage = bossRush || Main.getGoodWorld; - } - else - turboEnrage = bossRush || Main.getGoodWorld; - - if (bossRush || Main.getGoodWorld) - enrage = true; - - if (turboEnrage) - { - calamityGlobalNPC.DR = 0.9999f; - calamityGlobalNPC.unbreakableDR = true; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = true; - } - - // Float through tiles or not - bool canPassThroughTiles = false; - if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1) || phase3 || turboEnrage) - { - npc.noTileCollide = true; - canPassThroughTiles = true; - } - else - npc.noTileCollide = false; - - // Move to new location - if (npc.ai[3] <= 0f) - { - npc.ai[3] = 400f; - - float maxDistance = 400f; - - // Four corners around target - if (phase3 || turboEnrage) - { - if (calamityGlobalNPC.newAI[1] == -maxDistance) - { - switch ((int)calamityGlobalNPC.newAI[0]) - { - case 0: - case 400: - calamityGlobalNPC.newAI[0] = -maxDistance; - break; - case -400: - calamityGlobalNPC.newAI[1] = maxDistance; - break; - default: - break; - } - } - else - { - switch ((int)calamityGlobalNPC.newAI[0]) - { - case 0: - case -400: - calamityGlobalNPC.newAI[0] = maxDistance; - break; - case 400: - calamityGlobalNPC.newAI[1] = -maxDistance; - break; - default: - break; - } + int type = ProjectileID.EyeBeam; + int damage = LaserDamage; + int freeHeadLaser = Projectile.NewProjectile(NPC.GetSource_FromAI(), freeHeadProjSpawn + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, type, damage, 0f, Main.myPlayer); + Main.projectile[freeHeadLaser].timeLeft = enrage ? 600 : 300; + if (turboEnrage) + Main.projectile[freeHeadLaser].extraUpdates += 1; } } - // Above target - else if (phase2) + if (!Main.getGoodWorld) { - switch ((int)calamityGlobalNPC.newAI[0]) - { - case 0: - calamityGlobalNPC.newAI[0] = maxDistance; - break; - case 400: - calamityGlobalNPC.newAI[0] = -maxDistance; - break; - case -400: - calamityGlobalNPC.newAI[0] = 0f; - break; - default: - break; - } - } - else - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = -maxDistance; - } - - npc.netSpam = 5; - npc.SyncExtraAI(); - npc.ForceNetUpdate(); - } - - npc.ai[3] -= 1f + - (turboEnrage ? 1f : phase2 ? 0.5f : 0f) + - (turboEnrage ? 1f : phase3 ? 0.5f : 0f) + - (turboEnrage ? 2f : phase4 ? 1f : 0f); - - float offsetX = calamityGlobalNPC.newAI[0]; - float offsetY = calamityGlobalNPC.newAI[1]; - Vector2 destination = Main.player[npc.target].Center + new Vector2(offsetX, offsetY); - - // Velocity and acceleration - float velocity = (turboEnrage ? 15f : 10f) + - (turboEnrage ? 7.5f : phase2 ? 5f : 0f) + - (turboEnrage ? 7.5f : phase3 ? 5f : 0f); - - if (enrage) - velocity = (phase3 || turboEnrage) ? 35f : 25f; - - float acceleration = phase3 ? 0f : turboEnrage ? 6f : enrage ? 4.8f : phase2 ? 1.2f : 0.8f; - - // How far Golem's Head is from where it's supposed to be - Vector2 distanceFromDestination = destination - npc.Center; - - // Whether Golem can fire projectiles - bool canFireProjectiles = distanceFromDestination.Length() < 120f || enrage; - - CalamityUtils.SmoothMovement(npc, 80f, distanceFromDestination, velocity, acceleration, !phase3); - - if (death && calamityGlobalNPC.newAI[2] < 120f) - { - calamityGlobalNPC.newAI[2] += 1f; - - if (calamityGlobalNPC.newAI[2] % 15f == 0f) - { - npc.netUpdate = true; - npc.SyncExtraAI(); + NPC.position += NPC.netOffset; + int randDustOffset = Main.rand.Next(2) * 2 - 1; + Vector2 randDustPos = NPC.Bottom + new Vector2((float)(randDustOffset * 22) * NPC.scale, -22f * NPC.scale); + Dust getGoodDust = Dust.NewDustPerfect(randDustPos, DustID.GoldFlame, (MathHelper.PiOver2 + -MathHelper.PiOver2 * (float)randDustOffset + Main.rand.NextFloatDirection() * MathHelper.PiOver4).ToRotationVector2() * (2f + Main.rand.NextFloat())); + Dust dust = getGoodDust; + dust.velocity += NPC.velocity; + getGoodDust.noGravity = true; + getGoodDust = Dust.NewDustPerfect(NPC.Bottom + new Vector2(Main.rand.NextFloatDirection() * 6f * NPC.scale, (Main.rand.NextFloat() * -4f - 8f) * NPC.scale), DustID.GoldFlame, Vector2.UnitY * (2f + Main.rand.NextFloat())); + getGoodDust.fadeIn = 0f; + getGoodDust.scale = 0.7f + Main.rand.NextFloat() * 0.5f; + getGoodDust.noGravity = true; + dust = getGoodDust; + dust.velocity += NPC.velocity; + NPC.position -= NPC.netOffset; } return false; } - // Fireballs - if (canFireProjectiles) - npc.ai[1] += 1f; - - float combinedLifeRatio = (lifeRatio + golemLifeRatio) * 0.5f; - float openMouthGateValue = 20f - (death ? 15f * (1f - combinedLifeRatio) : 10f * (1f - combinedLifeRatio)); - float shootFireballGateValue = 240f - (death ? 180f * (1f - combinedLifeRatio) : 120f * (1f - combinedLifeRatio)); - if (npc.ai[1] < openMouthGateValue || npc.ai[1] > shootFireballGateValue - openMouthGateValue) - npc.localAI[0] = 1f; - else - npc.localAI[0] = 0f; - - if (canPassThroughTiles && !phase3) - npc.ai[1] = openMouthGateValue; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) + public override bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - npc.ai[1] = 0f; + // Draw the head as usual. + Texture2D golemHeadTexture = TextureAssets.Npc[NPC.type].Value; + Vector2 headDrawPosition = NPC.Center - screenPos; + spriteBatch.Draw(golemHeadTexture, headDrawPosition, NPC.frame, NPC.GetAlpha(drawColor), 0f, NPC.frame.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); - Vector2 freeHeadCenter = new Vector2(npc.Center.X, npc.Center.Y + 20f * npc.scale); - float freeHeadSpeed = turboEnrage ? 24f : enrage ? 18f : 6f; - if (death) - freeHeadSpeed *= 1.25f; + // Draw the eyes. The way vanilla handles this is hardcoded bullshit that cannot handle different hitboxes and thus requires rewriting. + Color eyeColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, 0); + Vector2 eyesDrawPosition = headDrawPosition - NPC.scale * new Vector2(1f, 12f); + Rectangle eyesFrame = new Rectangle(0, 0, TextureAssets.Golem[1].Value.Width, TextureAssets.Golem[1].Value.Height / 2); + spriteBatch.Draw(TextureAssets.Golem[1].Value, eyesDrawPosition, eyesFrame, eyeColor, 0f, eyesFrame.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); - float freeHeadTargetX = Main.player[npc.target].Center.X - freeHeadCenter.X; - float freeHeadTargetY = Main.player[npc.target].Center.Y - freeHeadCenter.Y; - float freeHeadTargetDist = (float)Math.Sqrt(freeHeadTargetX * freeHeadTargetX + freeHeadTargetY * freeHeadTargetY); + // Draw the glowmasks. + int frameCounter = (int)NPC.frameCounter / 4; + Rectangle frame = TextureAssets.Extra[ExtrasID.GolemLights4].Value.Frame(1, 8); + frame.Y += frame.Height * 2 * frameCounter + NPC.frame.Y; + Rectangle glowFrame = frame; + spriteBatch.Draw(TextureAssets.Extra[ExtrasID.GolemLights4].Value, eyesDrawPosition, glowFrame, eyeColor, 0f, glowFrame.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); + frame = NPC.frame; + Rectangle glowFrame2 = frame; + spriteBatch.Draw(TextureAssets.Extra[ExtrasID.GolemLights5].Value, eyesDrawPosition, glowFrame2, eyeColor, 0f, glowFrame2.Size() * 0.5f, NPC.scale, SpriteEffects.None, 0f); - freeHeadTargetDist = freeHeadSpeed / freeHeadTargetDist; - freeHeadTargetX *= freeHeadTargetDist; - freeHeadTargetY *= freeHeadTargetDist; - - int projectileType = (phase3 || death) ? ProjectileID.InfernoHostileBolt : ProjectileID.Fireball; - int damage = npc.GetProjectileDamage(projectileType); - float ai0 = projectileType == ProjectileID.InfernoHostileBolt ? Main.player[npc.target].Center.X : 0f; - float ai1 = projectileType == ProjectileID.InfernoHostileBolt ? Main.player[npc.target].Center.Y : 0f; - float ai2 = projectileType == ProjectileID.InfernoHostileBolt ? 1f : 0f; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), freeHeadCenter.X, freeHeadCenter.Y, freeHeadTargetX, freeHeadTargetY, projectileType, damage, 0f, Main.myPlayer, ai0, ai1, ai2); - if (projectileType == ProjectileID.InfernoHostileBolt) + // Draw the sparkle telegraphs for the laser spread attack if applicable. + if (NPC.ai[0] == 3f && NPC.ai[1] <= 60f) { - Main.projectile[proj].timeLeft = 300; - Main.projectile[proj].netUpdate = true; + spriteBatch.SetBlendState(BlendState.Additive); + for (int i = -1; i <= 1; i += 2) + { + Texture2D sparkle = ModContent.Request("CalamityMod/Particles/Sparkle2").Value; + Vector2 sparkleDraw = headDrawPosition + new Vector2(14f * i, -15f) * NPC.scale; + var drawFade = Color.Yellow * Utils.GetLerpValue(0, 30, 60f - NPC.ai[1], true); + spriteBatch.Draw(sparkle, sparkleDraw, null, drawFade, MathHelper.Pi * 0.02f * NPC.ai[1] * i, sparkle.Size() / 2f, 1.25f * NPC.scale, SpriteEffects.None, 0f); + } + spriteBatch.SetBlendState(BlendState.AlphaBlend); } - else - Main.projectile[proj].timeLeft = 450; - - npc.netUpdate = true; - } - - // Lasers - if (canFireProjectiles) - npc.ai[2] += 1f; - - float laserGateValue = 300f - (death ? 240f * (1f - combinedLifeRatio) : 180f * (1f - combinedLifeRatio)); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] >= laserGateValue) - { - npc.ai[2] = 0f; - - int numLasers = 2; - bool leftLaserIsFast = Main.rand.NextBool(); - for (int i = 0; i < numLasers; i++) - { - Vector2 freeHeadProjSpawn = new Vector2(npc.Center.X, npc.Center.Y - 20f * npc.scale); - if (i == 0) - freeHeadProjSpawn.X -= 14f * npc.scale; - else if (i == 1) - freeHeadProjSpawn.X += 14f * npc.scale; - - float freeHeadProjSpeed = 5f + (death ? 5f * (1f - combinedLifeRatio) : 3f * (1f - combinedLifeRatio)); - if (death) - { - if (i == 0) - { - if (leftLaserIsFast) - freeHeadProjSpeed *= 1.25f; - else - freeHeadProjSpeed *= 0.75f; - } - else - { - if (!leftLaserIsFast) - freeHeadProjSpeed *= 1.25f; - else - freeHeadProjSpeed *= 0.75f; - } - } - - float freeHeadProjTargetX = Main.player[npc.target].Center.X - freeHeadProjSpawn.X; - float freeHeadProjTargetY = Main.player[npc.target].Center.Y - freeHeadProjSpawn.Y; - float freeHeadProjTargetDist = (float)Math.Sqrt(freeHeadProjTargetX * freeHeadProjTargetX + freeHeadProjTargetY * freeHeadProjTargetY); - - freeHeadProjTargetDist = freeHeadProjSpeed / freeHeadProjTargetDist; - freeHeadProjTargetX *= freeHeadProjTargetDist; - freeHeadProjTargetY *= freeHeadProjTargetDist; - - Vector2 laserVelocity = new Vector2(freeHeadProjTargetX, freeHeadProjTargetY); - int type = ProjectileID.EyeBeam; - int damage = npc.GetProjectileDamage(type); - int freeHeadLaser = Projectile.NewProjectile(npc.GetSource_FromAI(), freeHeadProjSpawn + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[freeHeadLaser].timeLeft = enrage ? 600 : 300; - if (turboEnrage && Main.getGoodWorld) - Main.projectile[freeHeadLaser].extraUpdates += 1; - } - } - - if (!Main.getGoodWorld) - { - npc.position += npc.netOffset; - int randDustOffset = Main.rand.Next(2) * 2 - 1; - Vector2 randDustPos = npc.Bottom + new Vector2((float)(randDustOffset * 22) * npc.scale, -22f * npc.scale); - Dust getGoodDust = Dust.NewDustPerfect(randDustPos, 228, (MathHelper.PiOver2 + -MathHelper.PiOver2 * (float)randDustOffset + Main.rand.NextFloatDirection() * MathHelper.PiOver4).ToRotationVector2() * (2f + Main.rand.NextFloat())); - Dust dust = getGoodDust; - dust.velocity += npc.velocity; - getGoodDust.noGravity = true; - getGoodDust = Dust.NewDustPerfect(npc.Bottom + new Vector2(Main.rand.NextFloatDirection() * 6f * npc.scale, (Main.rand.NextFloat() * -4f - 8f) * npc.scale), 228, Vector2.UnitY * (2f + Main.rand.NextFloat())); - getGoodDust.fadeIn = 0f; - getGoodDust.scale = 0.7f + Main.rand.NextFloat() * 0.5f; - getGoodDust.noGravity = true; - dust = getGoodDust; - dust.velocity += npc.velocity; - npc.position -= npc.netOffset; - } - - return false; - } - - public static bool VanillaGolemAI(NPC npc, Mod mod) - { - NPC.golemBoss = npc.whoAmI; - float enrageScale = npc.GetMyBalance(); - if (Main.expertMode) - enrageScale += 0.5f; - if (Main.masterMode) - enrageScale += 0.5f; - if (Main.getGoodWorld) - enrageScale += 2f; - - if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16D) - { - enrageScale *= 2f; - npc.Calamity().CurrentlyEnraged = true; - } - - if (npc.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] = 1f; - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X - 84, (int)npc.Center.Y - 9, NPCID.GolemFistLeft); - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X + 78, (int)npc.Center.Y - 9, NPCID.GolemFistRight); - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X - 3, (int)npc.Center.Y - 57, NPCID.GolemHead); - } - - if (npc.target >= 0 && Main.player[npc.target].dead) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - if (Main.player[npc.target].dead) - npc.noTileCollide = true; - } - - if (npc.alpha > 0) - { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; - - npc.ai[1] = 0f; - } - - bool flag = false; - bool flag2 = false; - bool flag3 = false; - npc.dontTakeDamage = false; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == NPCID.GolemHead) - flag = true; - - if (Main.npc[i].active && Main.npc[i].type == NPCID.GolemFistLeft) - flag2 = true; - - if (Main.npc[i].active && Main.npc[i].type == NPCID.GolemFistRight) - flag3 = true; - } - - npc.dontTakeDamage = flag; - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && npc.velocity.Y > 0f) - { - for (int j = (int)(npc.position.X / 16f); (float)j < (npc.position.X + (float)npc.width) / 16f; j++) - { - for (int k = (int)(npc.position.Y / 16f); (float)k < (npc.position.Y + (float)npc.width) / 16f; k++) - { - if (Main.tile[j, k].TileType == TileID.Torches) - { - Main.tile[j, k].Get().HasTile = false; - if (Main.dedServ) - NetMessage.SendTileSquare(-1, j, k); - } - } - } - } - - npc.position += npc.netOffset; - if (!Main.getGoodWorld) - { - if (!flag2) - { - int num2 = Dust.NewDust(new Vector2(npc.Center.X - 80f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Smoke, 0f, 0f, 100); - Main.dust[num2].alpha += Main.rand.Next(100); - Main.dust[num2].velocity *= 0.2f; - Main.dust[num2].velocity.Y -= 0.5f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num2].fadeIn = 0.5f + (float)Main.rand.Next(10) * 0.1f; - if (Main.rand.NextBool(10)) - { - num2 = Dust.NewDust(new Vector2(npc.Center.X - 80f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Torch); - if (!Main.rand.NextBool(20)) - { - Main.dust[num2].noGravity = true; - Main.dust[num2].scale *= 1f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num2].velocity.Y -= 1f; - } - } - } - - if (!flag3) - { - int num3 = Dust.NewDust(new Vector2(npc.Center.X + 62f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Smoke, 0f, 0f, 100); - Main.dust[num3].alpha += Main.rand.Next(100); - Main.dust[num3].velocity *= 0.2f; - Main.dust[num3].velocity.Y -= 0.5f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num3].fadeIn = 0.5f + (float)Main.rand.Next(10) * 0.1f; - if (Main.rand.NextBool(10)) - { - num3 = Dust.NewDust(new Vector2(npc.Center.X + 62f * npc.scale, npc.Center.Y - 9f), 8, 8, DustID.Torch); - if (!Main.rand.NextBool(20)) - { - Main.dust[num3].noGravity = true; - Main.dust[num3].scale *= 1f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num3].velocity.Y -= 1f; - } - } - } - } - - npc.position -= npc.netOffset; - if (npc.noTileCollide && !Main.player[npc.target].dead) - { - if (npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) - npc.noTileCollide = false; - else if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidTiles(npc.position, npc.width, npc.height)) - npc.noTileCollide = false; - } - - if (npc.ai[0] == 0f) - { - if (npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.X *= 0.8f; - float num4 = 1f; - if (npc.ai[1] > 0f) - { - if (!flag2) - num4 += 2f; - - if (!flag3) - num4 += 2f; - - if (!flag) - num4 += 2f; - - if (npc.life < npc.lifeMax) - num4 += 1f; - - if (npc.life < npc.lifeMax / 2) - num4 += 4f; - - if (npc.life < npc.lifeMax / 3) - num4 += 8f; - - num4 *= enrageScale; - if (Main.getGoodWorld) - num4 += 100f; - } - - npc.ai[1] += num4; - if (npc.ai[1] >= 300f) - { - npc.ai[1] = -20f; - npc.frameCounter = 0D; - } - else if (npc.ai[1] == -1f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.noTileCollide = true; - - if (!flag) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.velocity.X = 4 * npc.direction; - if (npc.life < npc.lifeMax) - { - npc.velocity.Y = -12.1f * (enrageScale + 9f) / 10f; - if ((double)npc.velocity.Y < -19.1) - npc.velocity.Y = -19.1f; - } - else - npc.velocity.Y = -12.1f; - - npc.ai[0] = 1f; - npc.ai[1] = 0f; - } - } - } - else if (npc.ai[0] == 1f) - { - if (npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - SoundEngine.PlaySound(SoundID.Item14, npc.Center); - npc.ai[0] = 0f; - for (int l = (int)npc.position.X - 20; l < (int)npc.position.X + npc.width + 40; l += 20) - { - for (int m = 0; m < 4; m++) - { - int num5 = Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y + (float)npc.height), npc.width + 20, 4, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[num5].velocity *= 0.2f; - } - - int num6 = Gore.NewGore(npc.GetSource_FromAI(), new Vector2(l - 20, npc.position.Y + (float)npc.height - 8f), default(Vector2), Main.rand.Next(61, 64)); - Main.gore[num6].velocity *= 0.4f; - } - } - else - { - // Set damage - npc.damage = npc.defDamage; - - if (npc.position.X < Main.player[npc.target].position.X && npc.position.X + (float)npc.width > Main.player[npc.target].position.X + (float)Main.player[npc.target].width) - { - npc.velocity.X *= 0.9f; - if (npc.Bottom.Y < Main.player[npc.target].position.Y) - npc.velocity.Y += 0.2f * (enrageScale + 1f) / 2f; - } - else - { - if (npc.direction < 0) - npc.velocity.X -= 0.2f; - else if (npc.direction > 0) - npc.velocity.X += 0.2f; - - float num7 = 3f; - if (npc.life < npc.lifeMax) - num7 += 1f; - - if (npc.life < npc.lifeMax / 2) - num7 += 1f; - - if (npc.life < npc.lifeMax / 4) - num7 += 1f; - - num7 *= (enrageScale + 1f) / 2f; - if (npc.velocity.X < 0f - num7) - npc.velocity.X = 0f - num7; - - if (npc.velocity.X > num7) - npc.velocity.X = num7; - } - } - } - - if (npc.target <= 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - int num8 = 3000; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > (float)num8) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > (float)num8) - npc.active = false; - } - - return false; - } - - public static bool VanillaGolemFistAI(NPC npc, Mod mod) - { - float enrageScale = npc.GetMyBalance(); - if (Main.expertMode) - enrageScale += 1f; - if (Main.masterMode) - enrageScale += 1f; - if (Main.getGoodWorld) - enrageScale += 3f; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) - enrageScale *= 2f; - - if (NPC.golemBoss < 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - return false; } - - if (npc.alpha > 0) - { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; - - npc.ai[1] = 0f; - } - - Player player = Main.player[npc.target]; - NPC nPC = Main.npc[NPC.golemBoss]; - Vector2 vector = nPC.Center + nPC.velocity + new Vector2(0f, -9f * npc.scale); - vector.X += (float)((npc.type == NPCID.GolemFistLeft) ? -84 : 78) * npc.scale; - Vector2 vector2 = vector - npc.Center; - float num2 = vector2.Length(); - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.noTileCollide = true; - float num3 = 14f; - if (npc.life < npc.lifeMax / 2) - num3 += 3f; - - if (npc.life < npc.lifeMax / 4) - num3 += 3f; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax) - num3 += 8f; - - num3 *= (enrageScale + 3f) / 4f; - if (num3 > 32f) - num3 = 32f; - - float x = vector2.X; - float y = vector2.Y; - float num4 = num2; - if (num4 < 12f + num3) - { - npc.rotation = 0f; - npc.velocity.X = x; - npc.velocity.Y = y; - float num5 = enrageScale; - npc.ai[1] += num5; - if (npc.life < npc.lifeMax / 2) - npc.ai[1] += num5; - - if (npc.life < npc.lifeMax / 4) - npc.ai[1] += num5; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax) - npc.ai[1] += 10f * num5; - - if (npc.ai[1] >= 60f) - { - if ((npc.type == NPCID.GolemFistLeft && npc.Center.X + 100f > Main.player[npc.target].Center.X) || (npc.type == NPCID.GolemFistRight && npc.Center.X - 100f < Main.player[npc.target].Center.X)) - { - npc.ai[1] = 0f; - npc.ai[0] = 1f; - } - else - npc.ai[1] = 0f; - } - } - else - { - num4 = num3 / num4; - npc.velocity.X = x * num4; - npc.velocity.Y = y * num4; - npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); - if (npc.type == NPCID.GolemFistLeft) - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - } - } - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[1] += 1f; - npc.Center = vector; - npc.rotation = 0f; - npc.velocity = Vector2.Zero; - if (npc.ai[1] <= 15f) - { - for (int i = 0; i < 1; i++) - { - Vector2 vector3 = Main.rand.NextVector2Circular(80f, 80f); - Vector2 vector4 = vector3 * -1f * 0.05f; - Vector2 vector5 = Main.rand.NextVector2Circular(20f, 20f); - Dust dust = Dust.NewDustPerfect(npc.Center + vector4 + vector3 + vector5, 228, vector4); - dust.fadeIn = 1.5f; - dust.scale = 0.5f; - if (Main.getGoodWorld) - dust.noLight = true; - - dust.noGravity = true; - } - } - - if (npc.ai[1] >= 30f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.noTileCollide = true; - npc.collideX = false; - npc.collideY = false; - npc.ai[0] = 2f; - npc.ai[1] = 0f; - float num6 = 12f; - if (npc.life < npc.lifeMax / 2) - num6 += 4f; - - if (npc.life < npc.lifeMax / 4) - num6 += 4f; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax) - num6 += 10f; - - num6 *= (enrageScale + 3f) / 4f; - if (num6 > 48f) - num6 = 48f; - - Vector2 vector6 = npc.Center; - float num7 = Main.player[npc.target].Center.X - vector6.X; - float num8 = Main.player[npc.target].Center.Y - vector6.Y; - float num9 = (float)Math.Sqrt(num7 * num7 + num8 * num8); - num9 = num6 / num9; - npc.velocity.X = num7 * num9; - npc.velocity.Y = num8 * num9; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (npc.type == NPCID.GolemFistLeft) - npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); - } - } - else if (npc.ai[0] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld) - { - for (int j = (int)(npc.position.X / 16f) - 1; (float)j < (npc.position.X + (float)npc.width) / 16f + 1f; j++) - { - for (int k = (int)(npc.position.Y / 16f) - 1; (float)k < (npc.position.Y + (float)npc.width) / 16f + 1f; k++) - { - if (Main.tile[j, k].TileType == TileID.Torches) - { - Main.tile[j, k].Get().HasTile = false; - if (Main.dedServ) - NetMessage.SendTileSquare(-1, j, k); - } - } - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] == 1f) - SoundEngine.PlaySound(SoundID.Item14, npc.Center); - - if (Main.rand.NextBool()) - { - Vector2 vector7 = npc.velocity * 0.5f; - Vector2 vector8 = Main.rand.NextVector2Circular(20f, 20f); - Dust.NewDustPerfect(npc.Center + vector7 + vector8, 306, vector7, 0, Main.OurFavoriteColor).scale = 2f; - } - - if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) - { - if (npc.velocity.X > 0f && npc.Center.X > player.Center.X) - npc.noTileCollide = false; - - if (npc.velocity.X < 0f && npc.Center.X < player.Center.X) - npc.noTileCollide = false; - } - else - { - if (npc.velocity.Y > 0f && npc.Center.Y > player.Center.Y) - npc.noTileCollide = false; - - if (npc.velocity.Y < 0f && npc.Center.Y < player.Center.Y) - npc.noTileCollide = false; - } - - if (num2 > 700f || npc.collideX || npc.collideY) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.noTileCollide = true; - npc.ai[0] = 0f; - } - } - else - { - if (npc.ai[0] != 3f) - return false; - - // Set damage - npc.damage = npc.defDamage; - - npc.noTileCollide = true; - float num10 = 0.4f; - Vector2 vector9 = npc.Center; - float num11 = Main.player[npc.target].Center.X - vector9.X; - float num12 = Main.player[npc.target].Center.Y - vector9.Y; - float num13 = (float)Math.Sqrt(num11 * num11 + num12 * num12); - num13 = 12f / num13; - num11 *= num13; - num12 *= num13; - if (npc.velocity.X < num11) - { - npc.velocity.X += num10; - if (npc.velocity.X < 0f && num11 > 0f) - npc.velocity.X += num10 * 2f; - } - else if (npc.velocity.X > num11) - { - npc.velocity.X -= num10; - if (npc.velocity.X > 0f && num11 < 0f) - npc.velocity.X -= num10 * 2f; - } - - if (npc.velocity.Y < num12) - { - npc.velocity.Y += num10; - if (npc.velocity.Y < 0f && num12 > 0f) - npc.velocity.Y += num10 * 2f; - } - else if (npc.velocity.Y > num12) - { - npc.velocity.Y -= num10; - if (npc.velocity.Y > 0f && num12 < 0f) - npc.velocity.Y -= num10 * 2f; - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (npc.type == NPCID.GolemFistLeft) - npc.rotation = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X); - } - - return false; - } - - public static bool VanillaGolemHeadAI(NPC npc, Mod mod) - { - float enrageScale = npc.GetMyBalance(); - if (Main.expertMode) - enrageScale += 1f; - if (Main.masterMode) - enrageScale += 1f; - if (Main.getGoodWorld) - enrageScale += 3f; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - } - - if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) - enrageScale *= 2f; - - npc.noTileCollide = true; - if (NPC.golemBoss < 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - - return false; - } - - float num707 = 100f; - Vector2 vector89 = npc.Center; - float num708 = Main.npc[NPC.golemBoss].Center.X - vector89.X; - float num709 = Main.npc[NPC.golemBoss].Center.Y - vector89.Y; - num709 -= 57f * npc.scale; - num708 -= 3f * npc.scale; - float num710 = (float)Math.Sqrt(num708 * num708 + num709 * num709); - if (num710 < num707) - { - npc.rotation = 0f; - npc.velocity.X = num708; - npc.velocity.Y = num709; - } - else - { - num710 = num707 / num710; - npc.velocity.X = num708 * num710; - npc.velocity.Y = num709 * num710; - npc.rotation = npc.velocity.X * 0.1f; - } - - if (npc.alpha > 0) - { - npc.alpha -= 10; - if (npc.alpha < 0) - npc.alpha = 0; - - npc.ai[1] = 30f; - } - - if (npc.ai[0] == 0f) - { - npc.ai[1] += 1f; - int num711 = 300; - if (npc.ai[1] < 20f || npc.ai[1] > (float)(num711 - 20)) - { - npc.ai[1] += 2f * (enrageScale - 1f) / 3f; - npc.localAI[0] = 1f; - } - else - { - npc.ai[1] += 1f * (enrageScale - 1f) / 2f; - npc.localAI[0] = 0f; - } - - if (npc.ai[1] >= (float)num711) - { - npc.ai[1] = 0f; - Vector2 vector90 = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); - float num712 = 8f; - float num713 = Main.player[npc.target].Center.X - vector90.X; - float num714 = Main.player[npc.target].Center.Y - vector90.Y; - float num715 = (float)Math.Sqrt(num713 * num713 + num714 * num714); - num715 = num712 / num715; - num713 *= num715; - num714 *= num715; - - int type = ProjectileID.Fireball; - int damage = npc.GetProjectileDamage(type); - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector90.X, vector90.Y, num713, num714, type, damage, 0f, Main.myPlayer); - } - } - else if (npc.ai[0] == 1f) - { - Vector2 vector91 = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); - if (Main.player[npc.target].Center.X < npc.Center.X - (float)npc.width) - { - npc.localAI[1] = -1f; - vector91.X -= 40f * npc.scale; - } - else if (Main.player[npc.target].Center.X > npc.Center.X + (float)npc.width) - { - npc.localAI[1] = 1f; - vector91.X += 40f * npc.scale; - } - else - npc.localAI[1] = 0f; - - float num719 = (enrageScale + 3f) / 4f; - npc.ai[1] += num719; - if ((double)npc.life < (double)npc.lifeMax * 0.4) - npc.ai[1] += num719; - - if ((double)npc.life < (double)npc.lifeMax * 0.2) - npc.ai[1] += num719; - - int num720 = 300; - if (npc.ai[1] < 20f || npc.ai[1] > (float)(num720 - 20)) - npc.localAI[0] = 1f; - else - npc.localAI[0] = 0f; - - if (npc.ai[1] >= (float)num720) - { - npc.ai[1] = 0f; - float num721 = 8f; - float num722 = Main.player[npc.target].Center.X - vector91.X; - float num723 = Main.player[npc.target].Center.Y - vector91.Y; - float num724 = (float)Math.Sqrt(num722 * num722 + num723 * num723); - num724 = num721 / num724; - num722 *= num724; - num723 *= num724; - - int type = ProjectileID.Fireball; - int damage = npc.GetProjectileDamage(type); - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector91.X, vector91.Y, num722, num723, type, damage, 0f, Main.myPlayer); - } - - npc.ai[2] += num719; - if (npc.life < npc.lifeMax / 3) - npc.ai[2] += num719; - - if (npc.life < npc.lifeMax / 4) - npc.ai[2] += num719; - - if (npc.life < npc.lifeMax / 5) - npc.ai[2] += num719; - - if (npc.ai[2] > (float)(60 + Main.rand.Next(600))) - { - npc.ai[2] = 0f; - - int type = ProjectileID.EyeBeam; - int damage = npc.GetProjectileDamage(type); - - if (npc.localAI[1] == 0f) - { - for (int num730 = 0; num730 < 2; num730++) - { - vector91 = new Vector2(npc.Center.X, npc.Center.Y - 22f * npc.scale); - if (num730 == 0) - vector91.X -= 18f * npc.scale; - else - vector91.X += 18f * npc.scale; - - float num731 = 11f; - float num732 = Main.player[npc.target].Center.X - vector91.X; - float num733 = Main.player[npc.target].Center.Y - vector91.Y; - float num734 = (float)Math.Sqrt(num732 * num732 + num733 * num733); - num734 = num731 / num734; - num732 *= num734; - num733 *= num734; - - Vector2 laserVelocity = new Vector2(num732, num733); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num735 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector91 + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[num735].timeLeft = 300; - } - } - } - else if (npc.localAI[1] != 0f) - { - vector91 = new Vector2(npc.Center.X, npc.Center.Y - 22f * npc.scale); - if (npc.localAI[1] == -1f) - vector91.X -= 30f * npc.scale; - else if (npc.localAI[1] == 1f) - vector91.X += 30f * npc.scale; - - float num736 = 12f; - float num737 = Main.player[npc.target].Center.X - vector91.X; - float num738 = Main.player[npc.target].Center.Y - vector91.Y; - float num739 = (float)Math.Sqrt(num737 * num737 + num738 * num738); - num739 = num736 / num739; - num737 *= num739; - num738 *= num739; - - Vector2 laserVelocity = new Vector2(num737, num738); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num740 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector91 + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[num740].timeLeft = 300; - } - } - } - } - - if (npc.life < npc.lifeMax / 2) - npc.ai[0] = 1f; - else - npc.ai[0] = 0f; - - return false; - } - - public static bool VanillaGolemHeadFreeAI(NPC npc, Mod mod) - { - bool flag37 = false; - float enrageScale = npc.GetMyBalance(); - if (Main.expertMode) - enrageScale += 1f; - if (Main.masterMode) - enrageScale += 1f; - if (Main.getGoodWorld) - enrageScale += 3f; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - } - - if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) - enrageScale *= 2f; - - if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.noTileCollide = true; - flag37 = true; - } - else if (npc.noTileCollide && Collision.SolidTiles(npc.position, npc.width, npc.height)) - npc.noTileCollide = false; - - if (NPC.golemBoss < 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - - return false; - } - - float num742 = 7f; - float num743 = 0.05f; - Vector2 vector92 = npc.Center; - float num744 = Main.player[npc.target].Center.X - vector92.X; - float num745 = Main.player[npc.target].Center.Y - vector92.Y - 300f; - float num746 = (float)Math.Sqrt(num744 * num744 + num745 * num745); - num746 = num742 / num746; - num744 *= num746; - num745 *= num746; - if (npc.velocity.X < num744) - { - npc.velocity.X += num743; - if (npc.velocity.X < 0f && num744 > 0f) - npc.velocity.X += num743; - } - else if (npc.velocity.X > num744) - { - npc.velocity.X -= num743; - if (npc.velocity.X > 0f && num744 < 0f) - npc.velocity.X -= num743; - } - - if (npc.velocity.Y < num745) - { - npc.velocity.Y += num743; - if (npc.velocity.Y < 0f && num745 > 0f) - npc.velocity.Y += num743; - } - else if (npc.velocity.Y > num745) - { - npc.velocity.Y -= num743; - if (npc.velocity.Y > 0f && num745 < 0f) - npc.velocity.Y -= num743; - } - - float num747 = (enrageScale + 4f) / 5f; - npc.ai[1] += num747; - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.8) - npc.ai[1] += num747; - - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.6) - npc.ai[1] += num747; - - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.2) - npc.ai[1] += num747; - - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.1) - npc.ai[1] += num747; - - int num748 = 300; - if (npc.ai[1] < 20f || npc.ai[1] > (float)(num748 - 20)) - npc.localAI[0] = 1f; - else - npc.localAI[0] = 0f; - - if (flag37) - npc.ai[1] = 20f; - - if (npc.ai[1] >= (float)num748) - { - npc.ai[1] = 0f; - Vector2 vector93 = new Vector2(npc.Center.X, npc.Center.Y + 20f * npc.scale); - float num749 = 8f; - - int type = ProjectileID.Fireball; - int damage = npc.GetProjectileDamage(type); - - float num752 = Main.player[npc.target].Center.X - vector93.X; - float num753 = Main.player[npc.target].Center.Y - vector93.Y; - float num754 = (float)Math.Sqrt(num752 * num752 + num753 * num753); - num754 = num749 / num754; - num752 *= num754; - num753 *= num754; - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), vector93.X, vector93.Y, num752, num753, type, damage, 0f, Main.myPlayer); - } - - float num756 = enrageScale; - npc.ai[2] += num756; - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax / 1.25) - npc.ai[2] += num756; - - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax / 1.5) - npc.ai[2] += num756; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 2) - npc.ai[2] += num756; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 3) - npc.ai[2] += num756; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 4) - npc.ai[2] += num756; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 5) - npc.ai[2] += num756; - - if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 6) - npc.ai[2] += num756; - - if (npc.ai[2] > (float)(100 + Main.rand.Next(4800))) - { - npc.ai[2] = 0f; - for (int num757 = 0; num757 < 2; num757++) - { - Vector2 vector94 = new Vector2(npc.Center.X, npc.Center.Y - 20f * npc.scale); - switch (num757) - { - case 0: - vector94.X -= 14f * npc.scale; - break; - case 1: - vector94.X += 14f * npc.scale; - break; - } - - float num758 = 11f; - int type = ProjectileID.EyeBeam; - int damage = npc.GetProjectileDamage(type); - - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.5) - num758 += 0.25f; - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.4) - num758 += 0.25f; - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.3) - num758 += 0.25f; - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.2) - num758 += 0.25f; - if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.1) - num758 += 0.25f; - - float num761 = Main.player[npc.target].Center.X; - float num762 = Main.player[npc.target].Center.Y; - num761 -= vector94.X; - num762 -= vector94.Y; - float num763 = (float)Math.Sqrt(num761 * num761 + num762 * num762); - num763 = num758 / num763; - num761 *= num763; - num762 *= num763; - - Vector2 laserVelocity = new Vector2(num761, num762); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num764 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector94 + laserVelocity.SafeNormalize(Vector2.UnitY) * 40f, laserVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[num764].timeLeft = 300; - } - } - } - - if (!Main.getGoodWorld) - { - npc.position += npc.netOffset; - int num765 = Main.rand.Next(2) * 2 - 1; - Vector2 vector95 = npc.Bottom + new Vector2((float)(num765 * 22) * npc.scale, -22f * npc.scale); - Dust dust5 = Dust.NewDustPerfect(vector95, 228, (MathHelper.PiOver2 + -MathHelper.PiOver2 * (float)num765 + Main.rand.NextFloatDirection() * MathHelper.PiOver4).ToRotationVector2() * (2f + Main.rand.NextFloat())); - Dust dust = dust5; - dust.velocity += npc.velocity; - dust5.noGravity = true; - dust5 = Dust.NewDustPerfect(npc.Bottom + new Vector2(Main.rand.NextFloatDirection() * 6f * npc.scale, (Main.rand.NextFloat() * -4f - 8f) * npc.scale), 228, Vector2.UnitY * (2f + Main.rand.NextFloat())); - dust5.fadeIn = 0f; - dust5.scale = 0.7f + Main.rand.NextFloat() * 0.5f; - dust5.noGravity = true; - dust = dust5; - dust.velocity += npc.velocity; - npc.position -= npc.netOffset; - } - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs index b41e77b6e9..468b5c73d7 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Events; using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.UI; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -11,21 +10,20 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class KingSlimeAI + public class KingSlimeAI : VanillaAIOverride { public static readonly SoundStyle SpawnCrystalSound = new SoundStyle("CalamityMod/Sounds/Custom/KingSlimeJewelSpawn"); + public static readonly SoundStyle ShootSound = new SoundStyle("CalamityMod/Sounds/Custom/RedJewelFire"); - public static bool BuffedKingSlimeAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; float lifeRatio2 = lifeRatio; - // Variables float teleportScale = 1f; bool teleporting = false; bool teleported = false; - npc.aiAction = 0; + NPC.aiAction = 0; float teleportScaleSpeed = 2f; if (Main.getGoodWorld) { @@ -33,414 +31,271 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses teleportScale *= teleportScaleSpeed; } - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - - // Phases based on life percentage + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Higher velocity jumps phase bool phase2 = lifeRatio < 0.75f; - // Spawn Emerald Crystal phase - bool spawnGreenCrystal = lifeRatio < 0.7f; + // In death: 75-55 = ruby, 50-35 = emerald, 35-0 = switches back and forth + bool rubySpawnPhaseActive = death ? (lifeRatio < 0.75f) : (lifeRatio < 0.5f); - // Spawn Ruby Crystal phase - bool phase3 = lifeRatio < 0.5f; + bool redCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - // Spawn Sapphire Crystal phase - bool spawnBlueCrystal = lifeRatio < 0.3f; + // npc.Calamity().newAI[0] as a flag for Ruby spawn state: 0f = can spawn, 1f = spawned + bool rubySpawnedForCurrentPhase = NPC.Calamity().newAI[0] == 1f; - // Check if the crystals are alive - bool redCrystalAlive = true; - bool blueCrystalAlive = false; - bool greenCrystalAlive = true; + int setDamage = NPC.defDamage; // Defined externally + NPC.defense = NPC.defDefense; - if (spawnGreenCrystal) + if (rubySpawnPhaseActive && !redCrystalAlive && !rubySpawnedForCurrentPhase) { - if (death) - greenCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - } + NPC.Calamity().newAI[0] = 1f; + NPC.SyncExtraAI(); - if (phase3) - redCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - - if (spawnBlueCrystal) - { - if (death) - blueCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - } - - // Sapphire Crystal buffs - int setDamage = npc.defDamage; - npc.defense = npc.defDefense; - if (blueCrystalAlive) - { - setDamage = (int)Math.Round(setDamage * 1.5); - npc.defense *= 2; - } - - // Dust color when the blue crystal is alive - Color dustColor = Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f); - - // Death Mode Crystal spawning - if (death) - { - if (spawnGreenCrystal && npc.Calamity().newAI[0] == 0f) + Vector2 vector = NPC.Center + new Vector2(-40f, -(float)NPC.height / 2) * NPC.scale; + int totalDustPerCrystalSpawn = 20; + for (int i = 0; i < totalDustPerCrystalSpawn; i++) { - npc.Calamity().newAI[0] = 1f; - npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; - int totalDustPerCrystalSpawn = 20; - for (int i = 0; i < totalDustPerCrystalSpawn; i++) + int rubyDust = Dust.NewDust(vector, NPC.width / 2, NPC.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 2f; + Main.dust[rubyDust].noGravity = true; + if (Main.rand.NextBool()) { - int emeraldDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemEmerald, 0f, 0f, 100, default, 2f); - Main.dust[emeraldDust].velocity *= 2f; - Main.dust[emeraldDust].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[emeraldDust].scale = 0.5f; - Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - SoundEngine.PlaySound(SpawnCrystalSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int jewel = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); - Main.npc[jewel].localAI[2] = npc.whoAmI; - Main.npc[jewel].velocity.Y = -6; + Main.dust[rubyDust].scale = 0.5f; + Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - if (phase3 && npc.Calamity().newAI[0] == 1f) + SoundEngine.PlaySound(SpawnCrystalSound with { Volume = 2f }, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.Calamity().newAI[0] = 2f; - npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; - int totalDustPerCrystalSpawn = 20; - for (int i = 0; i < totalDustPerCrystalSpawn; i++) - { - int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust].velocity *= 2f; - Main.dust[rubyDust].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[rubyDust].scale = 0.5f; - Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - SoundEngine.PlaySound(SpawnCrystalSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int jewel = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - Main.npc[jewel].localAI[2] = npc.whoAmI; - Main.npc[jewel].velocity.Y = -6; - } - } - - if (spawnBlueCrystal && npc.Calamity().newAI[0] == 2f) - { - npc.Calamity().newAI[0] = 3f; - npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; - int totalDustPerCrystalSpawn = 20; - for (int i = 0; i < totalDustPerCrystalSpawn; i++) - { - int sapphireDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemSapphire, 0f, 0f, 100, default, 2f); - Main.dust[sapphireDust].velocity *= 2f; - Main.dust[sapphireDust].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[sapphireDust].scale = 0.5f; - Main.dust[sapphireDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - SoundEngine.PlaySound(SpawnCrystalSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int jewel = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); - Main.npc[jewel].localAI[2] = npc.whoAmI; - Main.npc[jewel].velocity.Y = -6; - } + int jewel = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + Main.npc[jewel].localAI[2] = NPC.whoAmI; + Main.npc[jewel].velocity.Y = -6; } } - else + else if (rubySpawnedForCurrentPhase && !rubySpawnPhaseActive) { - // Spawn crystal in phase 2 - if (phase3 && npc.Calamity().newAI[0] == 0f) - { - npc.Calamity().newAI[0] = 1f; - npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; - int totalDustPerCrystalSpawn = 20; - for (int i = 0; i < totalDustPerCrystalSpawn; i++) - { - int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust].velocity *= 2f; - Main.dust[rubyDust].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[rubyDust].scale = 0.5f; - Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - SoundEngine.PlaySound(SpawnCrystalSound, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int jewel = NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - Main.npc[jewel].localAI[2] = npc.whoAmI; - Main.npc[jewel].velocity.Y = -6; - } - } + NPC.Calamity().newAI[0] = 0f; + NPC.SyncExtraAI(); } // Set up health value for spawning slimes - if (npc.ai[3] == 0f && npc.life > 0) - npc.ai[3] = npc.lifeMax; + if (NPC.ai[3] == 0f && NPC.life > 0) + NPC.ai[3] = NPC.lifeMax; // Spawn with attack delay - if (npc.localAI[3] == 0f) + if (NPC.localAI[3] == 0f) { - npc.localAI[3] = 1f; + NPC.localAI[3] = 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[0] = -100f; + NPC.ai[0] = -100f; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - npc.netUpdate = true; + NPC.netUpdate = true; } } // Despawn int despawnDistance = 60; int forceDespawnDistance = 300; - if ((Main.player[npc.target].dead && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistance) || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > forceDespawnDistance) + if ((Main.player[NPC.target].dead && Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistance) || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > forceDespawnDistance) { - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - if ((Main.player[npc.target].dead && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistance) || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > forceDespawnDistance) + if ((Main.player[NPC.target].dead && Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistance) || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > forceDespawnDistance) { - if (npc.timeLeft > 10) - npc.timeLeft = 10; + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; - if (Main.player[npc.target].Center.X < npc.Center.X) - npc.direction = 1; + if (Main.player[NPC.target].Center.X < NPC.Center.X) + NPC.direction = 1; else - npc.direction = -1; + NPC.direction = -1; } } // Faster fall - if (npc.velocity.Y > 0f) + if (NPC.velocity.Y > 0f) { - float fallSpeedBonus = (bossRush ? 0.2f : death ? 0.15f : 0f) + (!redCrystalAlive ? 0.1f : 0f); - npc.velocity.Y += fallSpeedBonus; + float fallSpeedBonus = (death ? 0.1f : 0f) + (!redCrystalAlive ? 0.1f : 0f); + NPC.velocity.Y += fallSpeedBonus; } // Activate teleport float teleportGateValue = 480f; - if (!Main.player[npc.target].dead && npc.ai[2] >= teleportGateValue && npc.ai[1] < 5f && npc.velocity.Y == 0f) + if (!Main.player[NPC.target].dead && NPC.ai[2] >= teleportGateValue && NPC.ai[1] < 5f && NPC.velocity.Y == 0f) { - // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.ai[2] = 0f; - npc.ai[0] = 0f; - npc.ai[1] = 5f; + NPC.ai[2] = 0f; + NPC.ai[0] = 0f; + NPC.ai[1] = 5f; if (Main.netMode != NetmodeID.MultiplayerClient) - GetPlaceToTeleportTo(npc); + GetPlaceToTeleportTo(NPC); } - if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > 160f) + if (!Collision.CanHitLine(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0) || Math.Abs(NPC.Top.Y - Main.player[NPC.target].Bottom.Y) > 160f) { if (Main.netMode != NetmodeID.MultiplayerClient) - npc.localAI[0] += 1f; + NPC.localAI[0] += 1f; } else if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] -= 1f; + NPC.localAI[0] -= 1f; - if (npc.localAI[0] < 0f) - npc.localAI[0] = 0f; + if (NPC.localAI[0] < 0f) + NPC.localAI[0] = 0f; } - if (npc.timeLeft < 10 && (npc.ai[0] != 0f || npc.ai[1] != 0f)) + if (NPC.timeLeft < 10 && (NPC.ai[0] != 0f || NPC.ai[1] != 0f)) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; teleporting = false; } - // Get closer to activating teleport - if (npc.ai[2] < teleportGateValue) + // Closer to activating teleport + if (NPC.ai[2] < teleportGateValue) { - if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > (death ? 160f : 320f)) - npc.ai[2] += death ? 3f : 2f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0) || Math.Abs(NPC.Top.Y - Main.player[NPC.target].Bottom.Y) > (death ? 160f : 320f)) + NPC.ai[2] += death ? 3f : 2f; else - npc.ai[2] += 1f; + NPC.ai[2] += 1f; + } + + // Slow down while teleporting + if (NPC.ai[1] == 5f || NPC.ai[1] == 6f) + { + if (Math.Abs(NPC.velocity.X) > 0.1f) + { + NPC.velocity.X *= 0.8f; + if (Math.Abs(NPC.velocity.X) <= 0.1f) + NPC.velocity.X = 0f; + } } // Teleport - if (npc.ai[1] == 5f) + if (NPC.ai[1] == 5f) { - // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; teleporting = true; - npc.aiAction = 1; - + NPC.aiAction = 1; + float teleportRate = redCrystalAlive ? 1f : 2f; if (death) teleportRate *= 2f; - npc.ai[0] += teleportRate; - teleportScale = MathHelper.Clamp((60f - npc.ai[0]) / 60f, 0f, 1f); + NPC.ai[0] += teleportRate; + teleportScale = MathHelper.Clamp((60f - NPC.ai[0]) / 60f, 0f, 1f); teleportScale = 0.5f + teleportScale * 0.5f; if (Main.getGoodWorld) teleportScale *= teleportScaleSpeed; - if (npc.ai[0] >= 60f) + if (NPC.ai[0] >= 60f) teleported = true; - if (npc.ai[0] == 60f && !Main.dedServ) - Gore.NewGore(npc.GetSource_FromAI(), npc.Center + new Vector2(-40f, -(float)npc.height / 2), npc.velocity, 734, 1f); + if (NPC.ai[0] == 60f && !Main.dedServ) + Gore.NewGore(NPC.GetSource_FromAI(), NPC.Center + new Vector2(-40f, -(float)NPC.height / 2), NPC.velocity, 734, 1f); - if (npc.ai[0] >= 60f && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[0] >= 60f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.Bottom = new Vector2(npc.localAI[1], npc.localAI[2]); - npc.ai[1] = 6f; - npc.ai[0] = 0f; - npc.netUpdate = true; + NPC.Bottom = new Vector2(NPC.localAI[1], NPC.localAI[2]); + NPC.ai[1] = 6f; + NPC.ai[0] = 0f; + NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[0] >= 120f) + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[0] >= 120f) { - npc.ai[1] = 6f; - npc.ai[0] = 0f; + NPC.ai[1] = 6f; + NPC.ai[0] = 0f; } if (!teleported) { for (int i = 0; i < 10; i++) { - int slimeDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, blueCrystalAlive ? DustID.GemSapphire : DustID.TintableDust, npc.velocity.X, npc.velocity.Y, blueCrystalAlive ? 100 : 150, blueCrystalAlive ? dustColor : new Color(78, 136, 255, 80), 2f); + int slimeDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); Main.dust[slimeDust].noGravity = true; - Main.dust[slimeDust].velocity *= blueCrystalAlive ? 0f : 0.5f; + Main.dust[slimeDust].velocity *= 0.5f; } } } // Post-teleport - else if (npc.ai[1] == 6f) + else if (NPC.ai[1] == 6f) { - // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; teleporting = true; - npc.aiAction = 0; + NPC.aiAction = 0; float teleportRate = redCrystalAlive ? 1f : 2f; if (death) teleportRate *= 2f; - if (npc.ai[0] == 0f) - { - // Move Blue Crystal - if (blueCrystalAlive) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC blueCrystal = Main.npc[i]; - if (blueCrystal.active && blueCrystal.type == ModContent.NPCType()) - { - blueCrystal.position.X = npc.position.X; - blueCrystal.position.Y = npc.position.Y - 200f; - for (int dusty = 0; dusty < 10; dusty++) - { - Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); - int sapphire = Dust.NewDust(blueCrystal.Center, blueCrystal.width, blueCrystal.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); - Main.dust[sapphire].velocity = dustVel * Main.rand.NextFloat(1f, 2f); - Main.dust[sapphire].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[sapphire].scale = 0.5f; - Main.dust[sapphire].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - break; - } - } - } - } - - npc.ai[0] += teleportRate; - teleportScale = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); + NPC.ai[0] += teleportRate; + teleportScale = MathHelper.Clamp(NPC.ai[0] / 30f, 0f, 1f); teleportScale = 0.5f + teleportScale * 0.5f; if (Main.getGoodWorld) teleportScale *= teleportScaleSpeed; - if (npc.ai[0] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[0] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[1] = 0f; - npc.ai[0] = -15f; - npc.netUpdate = true; + NPC.ai[1] = 0f; + NPC.ai[0] = -15f; + NPC.netUpdate = true; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); } - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[0] >= 60f) + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[0] >= 60f) { - npc.ai[1] = 0f; - npc.ai[0] = -15f; + NPC.ai[1] = 0f; + NPC.ai[0] = -15f; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); } for (int j = 0; j < 10; j++) { - int slimyDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, blueCrystalAlive ? DustID.GemSapphire : DustID.TintableDust, npc.velocity.X, npc.velocity.Y, blueCrystalAlive ? 100 : 150, blueCrystalAlive ? dustColor : new Color(78, 136, 255, 80), 2f); + int slimyDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); Main.dust[slimyDust].noGravity = true; - Main.dust[slimyDust].velocity *= blueCrystalAlive ? 0f : 2f; + Main.dust[slimyDust].velocity *= 2f; } } - npc.noTileCollide = false; + NPC.noTileCollide = false; // Jump - if (npc.velocity.Y == 0f) + if (NPC.velocity.Y == 0f) { - // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.velocity.X *= 0.8f; - if (npc.velocity.X > -0.1f && npc.velocity.X < 0.1f) - npc.velocity.X = 0f; + NPC.velocity.X *= 0.8f; + if (NPC.velocity.X > -0.1f && NPC.velocity.X < 0.1f) + NPC.velocity.X = 0f; if (!teleporting) { - npc.ai[0] += (bossRush ? 15f : MathHelper.Lerp(1f, 8f, 1f - lifeRatio)); - if (npc.ai[0] >= 0f) + NPC.ai[0] += MathHelper.Lerp(1f, 8f, 1f - lifeRatio); + if (NPC.ai[0] >= 0f) { - // Set damage - npc.damage = setDamage; + NPC.damage = setDamage; - npc.netUpdate = true; + NPC.netUpdate = true; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - float distanceBelowTarget = npc.position.Y - (Main.player[npc.target].position.Y + 80f); + float distanceBelowTarget = NPC.position.Y - (Main.player[NPC.target].position.Y + 80f); float speedMult = 1f; if (distanceBelowTarget > 0f) speedMult += distanceBelowTarget * 0.002f; @@ -448,149 +303,129 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (speedMult > 2f) speedMult = 2f; - bool deathModeRapidHops = death && lifeRatio < 0.3f; + bool deathModeRapidHops = death && lifeRatio < 0.2f; if (deathModeRapidHops) - npc.ai[1] = 2f; + NPC.ai[1] = 2f; - float bossRushJumpSpeedMult = 1.5f; - - // Jump type - if (npc.ai[1] == 3f) + if (NPC.ai[1] == 3f) { - npc.velocity.Y = -10f * speedMult; - npc.velocity.X += (phase2 ? (death ? 5.5f : 4.5f) : 3.5f) * npc.direction; - npc.ai[0] = -100f; - npc.ai[1] = 0f; + NPC.velocity.Y = -10f * speedMult; + NPC.velocity.X += (phase2 ? (death ? 5.35f : 4.5f) : 3.5f) * NPC.direction; + NPC.ai[0] = -100f; + NPC.ai[1] = 0f; } - else if (npc.ai[1] == 2f) + else if (NPC.ai[1] == 2f) { - npc.velocity.Y = -6f * speedMult; - npc.velocity.X += (phase2 ? (deathModeRapidHops ? 8f : death ? 6.5f : 5.5f) : 4.5f) * npc.direction; - npc.ai[0] = -60f; + NPC.velocity.Y = -6f * speedMult; + NPC.velocity.X += (phase2 ? (deathModeRapidHops ? 7.65f : death ? 6.25f : 5.5f) : 4.5f) * NPC.direction; + NPC.ai[0] = -60f; - // Use the quick forward jump over and over while at low HP in death mode if (!deathModeRapidHops) - npc.ai[1] += 1f; + NPC.ai[1] += 1f; } else { - npc.velocity.Y = -8f * speedMult; - npc.velocity.X += (phase2 ? (death ? 6f : 5f) : 4f) * npc.direction; - npc.ai[0] = -60f; - npc.ai[1] += 1f; - } - - if (!greenCrystalAlive) - { - npc.velocity.X *= 1.2f; - npc.velocity.Y *= 0.6f; + NPC.velocity.Y = -8f * speedMult; + NPC.velocity.X += (phase2 ? (death ? 5.75f : 5f) : 4f) * NPC.direction; + NPC.ai[0] = -60f; + NPC.ai[1] += 1f; } if (death) - npc.velocity.X *= 1.4f; + NPC.velocity.X *= 1.2f; - if (bossRush) - npc.velocity.X *= bossRushJumpSpeedMult; - - npc.noTileCollide = true; + NPC.noTileCollide = true; } - else if (npc.ai[0] >= -30f) - npc.aiAction = 1; + else if (NPC.ai[0] >= -30f) + NPC.aiAction = 1; } } - // Change jump velocity - else if (npc.target < Main.maxPlayers) + else if (NPC.target < Main.maxPlayers) // Velocity factoring { float jumpVelocityLimit = redCrystalAlive ? 3f : 4.5f; if (death) - jumpVelocityLimit += 3f; + jumpVelocityLimit += 2.25f; if (Main.getGoodWorld) jumpVelocityLimit = 8f; - if ((npc.direction == 1 && npc.velocity.X < jumpVelocityLimit) || (npc.direction == -1 && npc.velocity.X > -jumpVelocityLimit)) + if ((NPC.direction == 1 && NPC.velocity.X < jumpVelocityLimit) || (NPC.direction == -1 && NPC.velocity.X > -jumpVelocityLimit)) { - if ((npc.direction == -1 && npc.velocity.X < 0.1) || (npc.direction == 1 && npc.velocity.X > -0.1)) + if ((NPC.direction == -1 && NPC.velocity.X < 0.1) || (NPC.direction == 1 && NPC.velocity.X > -0.1)) { - npc.velocity.X += (bossRush ? 0.4f : death ? 0.25f : 0.2f) * npc.direction; + NPC.velocity.X += (death ? 0.25f : 0.2f) * NPC.direction; if (death) - npc.velocity.X += 0.3f * npc.direction; + NPC.velocity.X += 0.25f * NPC.direction; } else { - npc.velocity.X *= bossRush ? 0.9f : death ? 0.92f : 0.93f; + NPC.velocity.X *= death ? 0.92f : 0.93f; if (death) - npc.velocity.X *= 0.9f; + NPC.velocity.X *= 0.9f; } } - if (!Main.player[npc.target].dead) + if (!Main.player[NPC.target].dead) { - if (npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) - npc.noTileCollide = false; - else if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.noTileCollide = false; + if (NPC.velocity.Y > 0f && NPC.Bottom.Y > Main.player[NPC.target].Top.Y) + NPC.noTileCollide = false; + else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.noTileCollide = false; else - npc.noTileCollide = true; + NPC.noTileCollide = true; } } - int idleSlimeDust = Dust.NewDust(npc.position, npc.width, npc.height, blueCrystalAlive ? DustID.GemSapphire : DustID.TintableDust, npc.velocity.X, npc.velocity.Y, blueCrystalAlive ? 100 : 255, blueCrystalAlive ? dustColor : new Color(0, 80, 255, 80), npc.scale * 1.2f); + int idleSlimeDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 255, new Color(0, 80, 255, 80), NPC.scale * 1.2f); Main.dust[idleSlimeDust].noGravity = true; - Main.dust[idleSlimeDust].velocity *= blueCrystalAlive ? 0f : 0.5f; + Main.dust[idleSlimeDust].velocity *= 0.5f; - if (npc.life <= 0) + if (NPC.life <= 0) return false; - // Adjust size based on HP - float maxScale = death ? (Main.getGoodWorld ? 6f : 2.5f) : (Main.getGoodWorld ? 3f : 1.5f); - float minScale = death ? 0.5f : 0.75f; + // Adjust size based on max health + float maxScale = Main.getGoodWorld ? 3f : death ? 2.5f : 1.5f; + float minScale = 0.75f; float maxScaledValue = maxScale - minScale; - // Inversed scale in FTW + // Inverse scaling in FTW if (Main.getGoodWorld) lifeRatio = (maxScaledValue - lifeRatio * maxScaledValue) + minScale; else lifeRatio = lifeRatio * maxScaledValue + minScale; lifeRatio *= teleportScale; - if (lifeRatio != npc.scale) + if (lifeRatio != NPC.scale) { - npc.position.X += npc.width / 2; - npc.position.Y += npc.height; - npc.scale = lifeRatio; - npc.width = (int)(98f * npc.scale); - npc.height = (int)(92f * npc.scale); - npc.position.X -= npc.width / 2; - npc.position.Y -= npc.height; + NPC.position.X += NPC.width / 2; + NPC.position.Y += NPC.height; + NPC.scale = lifeRatio; + NPC.width = (int)(98f * NPC.scale); + NPC.height = (int)(92f * NPC.scale); + NPC.position.X -= NPC.width / 2; + NPC.position.Y -= NPC.height; } - // Slime spawning if (Main.netMode != NetmodeID.MultiplayerClient) { - int slimeSpawnThreshold = (int)(npc.lifeMax * 0.03); - if (npc.life + slimeSpawnThreshold < npc.ai[3]) + int slimeSpawnThreshold = (int)(NPC.lifeMax * 0.03); + if (NPC.life + slimeSpawnThreshold < NPC.ai[3]) { - npc.ai[3] = npc.life; + NPC.ai[3] = NPC.life; int slimeAmt = death ? 1 : Main.rand.Next(1, 3); for (int i = 0; i < slimeAmt; i++) { - float minLowerLimit = 0f; - float maxLowerLimit = 2f; - int minTypeChoice = (int)MathHelper.Lerp(minLowerLimit, 5f, 1f - lifeRatio2); - int maxTypeChoice = (int)MathHelper.Lerp(maxLowerLimit, 7f, 1f - lifeRatio2); + int minTypeChoice = (int)MathHelper.Lerp(0f, 5f, 1f - lifeRatio2); + int maxTypeChoice = (int)MathHelper.Lerp(2f, 7f, 1f - lifeRatio2); int npcType; switch (Main.rand.Next(minTypeChoice, maxTypeChoice + 1)) { - default: - npcType = NPCID.SlimeSpiked; - break; case 0: npcType = NPCID.GreenSlime; break; case 1: - npcType = Main.player[npc.target].ZoneJungle ? NPCID.JungleSlime : Main.player[npc.target].ZoneSnow ? NPCID.IceSlime : NPCID.BlueSlime; + npcType = NPCID.BlueSlime; break; case 2: npcType = Main.raining ? NPCID.UmbrellaSlime : NPCID.BlueSlime; @@ -604,41 +439,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 5: npcType = NPCID.YellowSlime; break; - case 6: - npcType = Main.player[npc.target].ZoneJungle ? NPCID.SpikedJungleSlime : Main.player[npc.target].ZoneSnow ? NPCID.SpikedIceSlime : NPCID.SlimeSpiked; + default: + npcType = NPCID.SlimeSpiked; break; } - if (((Main.raining && Main.hardMode) || bossRush) && Main.rand.NextBool(50)) + if ((Main.raining && Main.hardMode) && Main.rand.NextBool(50)) npcType = NPCID.RainbowSlime; - if (death) - { - switch (Main.rand.Next(3)) - { - case 0: - npcType = NPCID.SlimeSpiked; - break; - case 1: - npcType = NPCID.SpikedIceSlime; - break; - case 2: - npcType = NPCID.SpikedJungleSlime; - break; - } - } + if (death && Main.rand.NextBool()) // 50% chance to spawn a spiked slime instead of the above npcType value + npcType = NPCID.SlimeSpiked; if (Main.rand.NextBool(100)) npcType = NPCID.Pinky; - if (CalamityWorld.LegendaryMode) + if (Main.zenithWorld) npcType = NPCID.RainbowSlime; - int spawnZoneWidth = npc.width - 32; - int spawnZoneHeight = npc.height - 32; - int x = (int)(npc.position.X + Main.rand.Next(spawnZoneWidth)); - int y = (int)(npc.position.Y + Main.rand.Next(spawnZoneHeight)); - int slimeSpawns = NPC.NewNPC(npc.GetSource_FromAI(), x, y, npcType); + int offset = 16; + int spawnZoneWidth = NPC.width - offset * 2; + int spawnZoneHeight = NPC.height - offset * 2; + int x = (int)(NPC.position.X + offset + Main.rand.Next(spawnZoneWidth)); + int y = (int)(NPC.position.Y + offset + Main.rand.Next(spawnZoneHeight)); + int slimeSpawns = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, npcType); Main.npc[slimeSpawns].SetDefaults(npcType); Main.npc[slimeSpawns].velocity.X = Main.rand.Next(-15, 16) * 0.1f; Main.npc[slimeSpawns].velocity.Y = Main.rand.Next(-30, 31) * 0.1f; @@ -653,367 +476,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - // If you think for a fucking second that I'm going to refactor this... - public static bool VanillaKingSlimeAI(NPC npc, Mod mod) - { - float num236 = 1f; - float num237 = 1f; - bool flag6 = false; - bool flag7 = false; - bool flag8 = false; - float num238 = 2f; - if (Main.getGoodWorld) - { - num238 -= 1f - (float)npc.life / (float)npc.lifeMax; - num237 *= num238; - } - - npc.aiAction = 0; - if (npc.ai[3] == 0f && npc.life > 0) - npc.ai[3] = npc.lifeMax; - - if (npc.localAI[3] == 0f) - { - npc.localAI[3] = 1f; - flag6 = true; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = -100f; - - CalamityUtils.CalamityTargeting(npc, default); - - npc.netUpdate = true; - } - } - - int num239 = 3000; - if (Main.player[npc.target].dead || Vector2.Distance(npc.Center, Main.player[npc.target].Center) > (float)num239) - { - CalamityUtils.CalamityTargeting(npc, default); - - if (Main.player[npc.target].dead || Vector2.Distance(npc.Center, Main.player[npc.target].Center) > (float)num239) - { - npc.EncourageDespawn(10); - if (Main.player[npc.target].Center.X < npc.Center.X) - npc.direction = 1; - else - npc.direction = -1; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] != 5f) - { - npc.netUpdate = true; - npc.ai[2] = 0f; - npc.ai[0] = 0f; - npc.ai[1] = 5f; - npc.localAI[1] = Main.maxTilesX * 16; - npc.localAI[2] = Main.maxTilesY * 16; - } - } - } - - if (!Main.player[npc.target].dead && npc.timeLeft > 10 && npc.ai[2] >= 300f && npc.ai[1] < 5f && npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] = 0f; - npc.ai[0] = 0f; - npc.ai[1] = 5f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - CalamityTargetingParameters options = CalamityTargetingParameters.Defaults; - options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); - - Point point3 = npc.Center.ToTileCoordinates(); - Point point4 = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 vector30 = Main.player[npc.target].Center - npc.Center; - int num240 = 10; - int num241 = 0; - int num242 = 7; - int num243 = 0; - bool flag9 = false; - if (npc.localAI[0] >= 360f || vector30.Length() > 2000f) - { - if (npc.localAI[0] >= 360f) - npc.localAI[0] = 360f; - - flag9 = true; - num243 = 100; - } - - while (!flag9 && num243 < 100) - { - num243++; - int num244 = Main.rand.Next(point4.X - num240, point4.X + num240 + 1); - int num245 = Main.rand.Next(point4.Y - num240, point4.Y + 1); - if ((num245 >= point4.Y - num242 && num245 <= point4.Y + num242 && num244 >= point4.X - num242 && num244 <= point4.X + num242) || (num245 >= point3.Y - num241 && num245 <= point3.Y + num241 && num244 >= point3.X - num241 && num244 <= point3.X + num241) || Main.tile[num244, num245].HasUnactuatedTile) - continue; - - int num246 = num245; - int num247 = 0; - if (Main.tile[num244, num246].HasUnactuatedTile && Main.tileSolid[Main.tile[num244, num246].TileType] && !Main.tileSolidTop[Main.tile[num244, num246].TileType]) - { - num247 = 1; - } - else - { - for (; num247 < 150 && num246 + num247 < Main.maxTilesY; num247++) - { - int num248 = num246 + num247; - if (Main.tile[num244, num248].HasUnactuatedTile && Main.tileSolid[Main.tile[num244, num248].TileType] && !Main.tileSolidTop[Main.tile[num244, num248].TileType]) - { - num247--; - break; - } - } - } - - num245 += num247; - bool flag10 = true; - if (flag10 && Main.tile[num244, num245].LiquidType == LiquidID.Lava) - flag10 = false; - - if (flag10 && !Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - flag10 = false; - - if (flag10) - { - npc.localAI[1] = num244 * 16 + 8; - npc.localAI[2] = num245 * 16 + 16; - flag9 = true; - break; - } - } - - if (num243 >= 100) - { - Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; - npc.localAI[1] = bottom.X; - npc.localAI[2] = bottom.Y; - } - } - } - - if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > 160f) - { - npc.ai[2]++; - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.localAI[0]++; - } - else if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0]--; - if (npc.localAI[0] < 0f) - npc.localAI[0] = 0f; - } - - if (npc.timeLeft < 10 && (npc.ai[0] != 0f || npc.ai[1] != 0f)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; - flag7 = false; - } - - Dust dust; - if (npc.ai[1] == 5f) - { - // Avoid cheap bullshit - npc.damage = 0; - - flag7 = true; - npc.aiAction = 1; - npc.ai[0]++; - num236 = MathHelper.Clamp((60f - npc.ai[0]) / 60f, 0f, 1f); - num236 = 0.5f + num236 * 0.5f; - if (npc.ai[0] >= 60f) - flag8 = true; - - if (npc.ai[0] == 60f) - Gore.NewGore(npc.GetSource_FromAI(), npc.Center + new Vector2(-40f, -npc.height / 2), npc.velocity, 734); - - if (npc.ai[0] >= 60f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Bottom = new Vector2(npc.localAI[1], npc.localAI[2]); - npc.ai[1] = 6f; - npc.ai[0] = 0f; - npc.netUpdate = true; - } - - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[0] >= 120f) - { - npc.ai[1] = 6f; - npc.ai[0] = 0f; - } - - if (!flag8) - { - for (int num249 = 0; num249 < 10; num249++) - { - int num250 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); - Main.dust[num250].noGravity = true; - dust = Main.dust[num250]; - dust.velocity *= 0.5f; - } - } - } - else if (npc.ai[1] == 6f) - { - // Avoid cheap bullshit - npc.damage = 0; - - flag7 = true; - npc.aiAction = 0; - npc.ai[0]++; - num236 = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); - num236 = 0.5f + num236 * 0.5f; - if (npc.ai[0] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = 0f; - npc.ai[0] = -15f; - - npc.netUpdate = true; - - CalamityUtils.CalamityTargeting(npc, default); - } - - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[0] >= 60f) - { - npc.ai[1] = 0f; - npc.ai[0] = -15f; - - CalamityUtils.CalamityTargeting(npc, default); - } - - for (int num251 = 0; num251 < 10; num251++) - { - int num252 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); - Main.dust[num252].noGravity = true; - dust = Main.dust[num252]; - dust.velocity *= 2f; - } - } - - npc.dontTakeDamage = (npc.hide = flag8); - if (npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.X *= 0.8f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if (!flag7) - { - npc.ai[0] += (MathHelper.Lerp(1f, 13f, 1f - npc.life / (float)npc.lifeMax)); - if (npc.ai[0] >= 0f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.netUpdate = true; - - CalamityUtils.CalamityTargeting(npc, default); - - if (npc.ai[1] == 3f) - { - npc.velocity.Y = -13f; - npc.velocity.X += (Main.masterMode ? 5.25f : 3.5f) * (float)npc.direction; - npc.ai[0] = -(Main.masterMode ? 140f : 180f); - npc.ai[1] = 0f; - } - else if (npc.ai[1] == 2f) - { - npc.velocity.Y = -6f; - npc.velocity.X += (Main.masterMode ? 6.75f : 4.5f) * (float)npc.direction; - npc.ai[0] = -(Main.masterMode ? 80f : 100f); - npc.ai[1] += 1f; - } - else - { - npc.velocity.Y = -8f; - npc.velocity.X += (Main.masterMode ? 6f : 4f) * (float)npc.direction; - npc.ai[0] = -(Main.masterMode ? 80f : 100f); - npc.ai[1] += 1f; - } - } - else if (npc.ai[0] >= -30f) - { - npc.aiAction = 1; - } - } - } - else if (npc.target < Main.maxPlayers) - { - float num253 = Main.masterMode ? 4.5f : 3f; - if (Main.getGoodWorld) - num253 = 6f; - - if ((npc.direction == 1 && npc.velocity.X < num253) || (npc.direction == -1 && npc.velocity.X > 0f - num253)) - { - if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) - npc.velocity.X += (Main.masterMode ? 0.3f : 0.2f) * (float)npc.direction; - else - npc.velocity.X *= (Main.masterMode ? 0.86f : 0.93f); - } - } - - int num254 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 255, new Color(0, 80, 255, 80), npc.scale * 1.2f); - Main.dust[num254].noGravity = true; - dust = Main.dust[num254]; - dust.velocity *= 0.5f; - if (npc.life <= 0) - return false; - - float num255 = (float)npc.life / (float)npc.lifeMax; - num255 = num255 * 0.5f + 0.75f; - num255 *= num236; - num255 *= num237; - if (num255 != npc.scale || flag6) - { - npc.position.X += npc.width / 2; - npc.position.Y += npc.height; - npc.scale = num255; - npc.width = (int)(98f * npc.scale); - npc.height = (int)(92f * npc.scale); - npc.position.X -= npc.width / 2; - npc.position.Y -= npc.height; - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - return false; - - int num256 = (int)((double)npc.lifeMax * 0.05); - if (!((float)(npc.life + num256) < npc.ai[3])) - return false; - - npc.ai[3] = npc.life; - int num257 = Main.rand.Next(1, 4); - for (int num258 = 0; num258 < num257; num258++) - { - int x = (int)(npc.position.X + (float)Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + (float)Main.rand.Next(npc.height - 32)); - int num259 = 1; - - int chanceForSpikedSlime = Main.masterMode ? 2 : 4; - if (Main.expertMode && Main.rand.NextBool(chanceForSpikedSlime)) - num259 = NPCID.SlimeSpiked; - - int num260 = NPC.NewNPC(npc.GetSource_FromAI(), x, y, num259); - Main.npc[num260].SetDefaults(num259); - Main.npc[num260].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num260].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num260].ai[0] = -1000 * Main.rand.Next(3); - Main.npc[num260].ai[1] = 0f; - if (Main.dedServ && num260 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num260); - } - - return false; - } - public static void GetPlaceToTeleportTo(NPC npc) { CalamityTargetingParameters options = CalamityTargetingParameters.Defaults; @@ -1074,7 +536,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - // Default teleport if the above conditions aren't met in 100 iterations if (teleportTries >= 100) { Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs index cd9481844a..5ba3fc0e7e 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs @@ -10,22 +10,35 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - // This is the most horrible abomination of code I have ever seen in my life, by a fucking landslide. - // This took hours of my time to attempt to clean up, and quite frankly I'd be surprised if even half of it is accurate. - // I do not want to look at this crime against humanity for a very long time. -CIT - public static class MoonLordAI + // This is the most horrible abomination of code I have ever seen in my life. + // CIT 20OCT2025: Despite this, I still got bored enough that I decided to refactor the entire thing. + // Hopefully it should be far more readable. + public class MoonLordAI : VanillaAIOverride { public static readonly SoundStyle DeathrayChargeSound = new("CalamityMod/Sounds/Custom/MoonLordLaserCharge"); - public static bool BuffedMoonLordAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Vanilla values + public static int BoltDamage = 30; // 120 + public static int EyeDamage = 30; // 120 + public static int SphereDamage = 40; // 160 + public static int DeathrayDamage = 75; // 300 - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + public static int TrueEyeBoltDamage = 35; // 140 + public static int TrueEyeEyeDamage = 35; // 140 + public static int TrueEyeDeathrayDamage = 50; // 200 + public static int TrueEyeSphereDamage = 55; // 220 + + // Vanilla values (GFB) + public static int MoonBoulderDamage = 70; // 280 + + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; int aggressionLevel = 4; - if (npc.type == NPCID.MoonLordCore || npc.type == NPCID.MoonLordHand || npc.type == NPCID.MoonLordHead) + if (NPC.type == NPCID.MoonLordCore || NPC.type == NPCID.MoonLordHand || NPC.type == NPCID.MoonLordHead) { switch (NPC.CountNPCS(NPCID.MoonLordFreeEye)) { @@ -45,19 +58,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (bossRush) + if (death) aggressionLevel = 5; - if (Main.getGoodWorld) aggressionLevel = 6; - if (npc.type == NPCID.MoonLordCore) + if (NPC.type == NPCID.MoonLordCore) + BuffedMoonLordCoreAI(aggressionLevel); + else if (NPC.type == NPCID.MoonLordHead) + BuffedMoonLordHeadAI(aggressionLevel); + else if (NPC.type == NPCID.MoonLordHand) + BuffedMoonLordHandAI(aggressionLevel); + else if (NPC.type == NPCID.MoonLordFreeEye) + BuffedTrueEyeAI(); + else if (NPC.type == NPCID.MoonLordLeechBlob) + BuffedMoonLeechBlobAI(); + + return false; + } + + public void BuffedMoonLordCoreAI(int aggressionLevel) + { + // Play a random Moon Lord sound + if (NPC.ai[0] != -1f && NPC.ai[0] != 2f && Main.rand.NextBool(200)) { - // Play a random Moon Lord sound - if (npc.ai[0] != -1f && npc.ai[0] != 2f && Main.rand.NextBool(200)) - { - SoundStyle voiceSound = Utils.SelectRandom(Main.rand, new SoundStyle[] - { + SoundStyle voiceSound = Utils.SelectRandom(Main.rand, + [ SoundID.Zombie93, SoundID.Zombie94, SoundID.Zombie95, @@ -65,855 +91,1030 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses SoundID.Zombie97, SoundID.Zombie98, SoundID.Zombie99 - }); - SoundEngine.PlaySound(voiceSound, npc.Center); - } + ]); + SoundEngine.PlaySound(voiceSound, NPC.Center); + } - // Start the AI - if (npc.localAI[3] == 0f) + // Start the AI + if (NPC.localAI[3] == 0f) + { + NPC.netUpdate = true; + NPC.localAI[3] = 1f; + NPC.ai[0] = -1f; + } + + // Teleport when target gets too far + if (NPC.ai[0] == -2f) + { + NPC.dontTakeDamage = true; + + NPC.ai[1] += 1f; + if (NPC.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.Zombie92, NPC.Center); + + if (NPC.ai[1] < 60f) + MoonlordDeathDrama.RequestLight(NPC.ai[1] / 30f, NPC.Center); + + if (NPC.ai[1] == 60f) { - npc.netUpdate = true; - npc.localAI[3] = 1f; - npc.ai[0] = -1f; - } - - if (npc.ai[0] == -2f) - { - npc.dontTakeDamage = true; - - npc.ai[1] += 1f; - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.Zombie92, npc.Center); - - if (npc.ai[1] < 60f) - MoonlordDeathDrama.RequestLight(npc.ai[1] / 30f, npc.Center); - - if (npc.ai[1] == 60f) - { - npc.ai[1] = 0f; - npc.ai[0] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.type == NPCID.MoonLordCore) - { - npc.ai[2] = Main.rand.Next(3); - npc.ai[2] = 0f; - npc.netUpdate = true; - } - } - } - - // Spawn head and hands - if (npc.ai[0] == -1f) - { - npc.dontTakeDamage = true; - - npc.ai[1] += 1f; - if (npc.ai[1] == 30f) - SoundEngine.PlaySound(SoundID.Zombie92, npc.Center); - - if (npc.ai[1] < 60f) - MoonlordDeathDrama.RequestLight(npc.ai[1] / 30f, npc.Center); - - if (npc.ai[1] == 60f) - { - npc.ai[1] = 0f; - npc.ai[0] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.type == NPCID.MoonLordCore) - { - npc.ai[2] = Main.rand.Next(3); - npc.ai[2] = 0f; - - npc.netUpdate = true; - int[] array5 = new int[3]; - int handsSpawned = 0; - int totalSpawns; - - for (int i = 0; i < 2; i = totalSpawns + 1) - { - int handSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X + i * 800 - 400, (int)npc.Center.Y - 100, NPCID.MoonLordHand, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[handSpawn].ai[2] = i; - Main.npc[handSpawn].netUpdate = true; - int[] arg_381A6_0 = array5; - totalSpawns = handsSpawned; - handsSpawned = totalSpawns + 1; - arg_381A6_0[totalSpawns] = handSpawn; - totalSpawns = i; - } - - int headSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y - 400, NPCID.MoonLordHead, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[headSpawn].netUpdate = true; - int[] arg_3823F_0 = array5; - totalSpawns = handsSpawned; - handsSpawned = totalSpawns + 1; - arg_3823F_0[totalSpawns] = headSpawn; - - for (int j = 0; j < 3; j = totalSpawns + 1) - { - Main.npc[array5[j]].ai[3] = npc.whoAmI; - totalSpawns = j; - } - for (int k = 0; k < 3; k = totalSpawns + 1) - { - npc.localAI[k] = array5[k]; - totalSpawns = k; - } - } - } - } - - int trueEyesThatShouldBeActive = 0; - if (Main.npc[(int)npc.localAI[0]].Calamity().newAI[0] == 1f) - trueEyesThatShouldBeActive++; - if (Main.npc[(int)npc.localAI[1]].Calamity().newAI[0] == 1f) - trueEyesThatShouldBeActive++; - if (Main.npc[(int)npc.localAI[2]].Calamity().newAI[0] == 1f) - trueEyesThatShouldBeActive++; - - if (NPC.CountNPCS(NPCID.MoonLordFreeEye) < trueEyesThatShouldBeActive) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int totalSpawns = NPC.NewNPC(npc.GetSource_FromAI(), (int)Main.npc[(int)npc.localAI[2]].Center.X, (int)Main.npc[(int)npc.localAI[2]].Center.Y, NPCID.MoonLordFreeEye); - Main.npc[totalSpawns].ai[3] = npc.whoAmI; - Main.npc[totalSpawns].netUpdate = true; - } - } - - // Fly near target, don't take damage - if (npc.ai[0] == 0f) - { - npc.dontTakeDamage = true; - npc.TargetClosest(false); - - Vector2 targetDistance = Main.player[npc.target].Center - npc.Center; - if (targetDistance.Length() > 20f) - { - float velocity = death ? 9.5f : 9.25f; - switch (aggressionLevel) - { - case 6: - velocity += 4f; - break; - case 5: - velocity += 2f; - break; - case 4: - break; - case 3: - velocity -= 0.25f; - break; - case 2: - velocity -= 0.5f; - break; - case 1: - velocity -= 0.75f; - break; - default: - break; - } - // Move slower if the head is doing the phantasmal deathray - if (Main.npc[(int)npc.localAI[2]].ai[0] == 1f) - velocity -= 2.25f; - - Vector2 desiredVelocity = Vector2.Normalize(targetDistance - npc.velocity) * velocity; - Vector2 velocity2 = npc.velocity; - npc.SimpleFlyMovement(desiredVelocity, 0.5f); - npc.velocity = Vector2.Lerp(npc.velocity, velocity2, 0.5f); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Despawn if other parts aren't there - bool shouldDespawn = false; - if (npc.localAI[0] < 0f || npc.localAI[1] < 0f || npc.localAI[2] < 0f) - shouldDespawn = true; - else if (!Main.npc[(int)npc.localAI[0]].active || Main.npc[(int)npc.localAI[0]].type != NPCID.MoonLordHand) - shouldDespawn = true; - else if (!Main.npc[(int)npc.localAI[1]].active || Main.npc[(int)npc.localAI[1]].type != NPCID.MoonLordHand) - shouldDespawn = true; - else if (!Main.npc[(int)npc.localAI[2]].active || Main.npc[(int)npc.localAI[2]].type != NPCID.MoonLordHead) - shouldDespawn = true; - - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - } - - // Take damage if other parts are down - bool coreIsOpen = true; - if (Main.npc[(int)npc.localAI[0]].Calamity().newAI[0] != 1f) - coreIsOpen = false; - if (Main.npc[(int)npc.localAI[1]].Calamity().newAI[0] != 1f) - coreIsOpen = false; - if (Main.npc[(int)npc.localAI[2]].Calamity().newAI[0] != 1f) - coreIsOpen = false; - - if (coreIsOpen) - { - npc.ai[0] = 1f; - npc.dontTakeDamage = false; - npc.netUpdate = true; - } - } - } - - // Fly near target, take damage - else if (npc.ai[0] == 1f) - { - npc.dontTakeDamage = false; - npc.TargetClosest(false); - - Vector2 targetDistanceVulnerable = Main.player[npc.target].Center - npc.Center; - if (targetDistanceVulnerable.Length() > 20f) - { - float velocity = death ? 9.5f : 9.25f; - switch (aggressionLevel) - { - case 6: - velocity += 4f; - break; - case 5: - velocity += 2f; - break; - case 4: - break; - case 3: - velocity -= 0.25f; - break; - case 2: - velocity -= 0.5f; - break; - case 1: - velocity -= 0.75f; - break; - default: - break; - } - // Move slower if the head is doing the phantasmal deathray - if (Main.npc[(int)npc.localAI[2]].ai[0] == 1f) - velocity -= 2f; - - Vector2 desiredVelocity2 = Vector2.Normalize(targetDistanceVulnerable - npc.velocity) * velocity; - Vector2 currentVelocity = npc.velocity; - npc.SimpleFlyMovement(desiredVelocity2, 0.5f); - npc.velocity = Vector2.Lerp(npc.velocity, currentVelocity, 0.5f); - } - } - - // Death effects - else if (npc.ai[0] == 2f) - { - npc.dontTakeDamage = true; - npc.Calamity().ShouldCloseHPBar = true; - Vector2 dyingVelocity = new Vector2(npc.direction, -0.5f); - npc.velocity = Vector2.Lerp(npc.velocity, dyingVelocity, 0.98f); - - npc.ai[1] += 1f; - float ai1 = npc.ai[1]; - if (npc.ai[1] < 60f) - MoonlordDeathDrama.RequestLight(npc.ai[1] / 60f, npc.Center); - - if (npc.ai[1] == 60f) - { - foreach (Projectile projectile in Main.ActiveProjectiles) - { - if ((projectile.type == ProjectileID.MoonLeech || projectile.type == ProjectileID.PhantasmalBolt || - projectile.type == ProjectileID.PhantasmalDeathray || projectile.type == ProjectileID.PhantasmalEye || - projectile.type == ProjectileID.PhantasmalSphere)) - projectile.Kill(); - } - - foreach (NPC nPC3 in Main.ActiveNPCs) - { - if (nPC3.type == NPCID.MoonLordFreeEye) - { - nPC3.HitEffect(0, 9999.0); - nPC3.active = false; - } - } - } - - if (npc.ai[1] % 3f == 0f && npc.ai[1] < 580f && npc.ai[1] > 60f) - { - Vector2 randPositionOffset = Utils.RandomVector2(Main.rand, -1f, 1f); - if (randPositionOffset != Vector2.Zero) - randPositionOffset.Normalize(); - - randPositionOffset *= 20f + Main.rand.NextFloat() * 400f; - Vector2 npcPosition = npc.Center + randPositionOffset; - Point npcPositionTileCoords = npcPosition.ToTileCoordinates(); - - bool inOpenSpace = true; - if (!WorldGen.InWorld(npcPositionTileCoords.X, npcPositionTileCoords.Y, 0)) - inOpenSpace = false; - if (inOpenSpace && WorldGen.SolidTile(npcPositionTileCoords.X, npcPositionTileCoords.Y)) - inOpenSpace = false; - - float randDustAmt = Main.rand.Next(6, 19); - float twoPiOverRand = MathHelper.TwoPi * Main.rand.NextFloat(); - float dustVelocityMult = 1f + Main.rand.NextFloat() * 2f; - float dustScale = 1f + Main.rand.NextFloat(); - float fadeIn = 0.4f + Main.rand.NextFloat(); - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 31, - 229 - }); - - if (inOpenSpace) - { - //MoonlordDeathDrama.AddExplosion(npcPosition); - for (float j = 0f; j < randDustAmt * 2f; j = ai1 + 1f) - { - Dust vortex = Main.dust[Dust.NewDust(npcPosition, 0, 0, DustID.Vortex, 0f, 0f, 0, default, 1f)]; - vortex.noGravity = true; - vortex.position = npcPosition; - vortex.velocity = Vector2.UnitY.RotatedBy(twoPiOverRand + (MathHelper.TwoPi / randDustAmt) * j) * dustVelocityMult * (Main.rand.NextFloat() * 1.6f + 1.6f); - vortex.fadeIn = fadeIn; - vortex.scale = dustScale; - ai1 = j; - } - } - - for (float k = 0f; k < npc.ai[1] / 60f; k = ai1 + 1f) - { - Vector2 randPosOffset = Utils.RandomVector2(Main.rand, -1f, 1f); - if (randPosOffset != Vector2.Zero) - randPosOffset.Normalize(); - - randPosOffset *= 20f + Main.rand.NextFloat() * 800f; - Vector2 npcPositioning = npc.Center + randPosOffset; - Point npcPositioningTileCoords = npcPositioning.ToTileCoordinates(); - - bool isInOpenness = true; - if (!WorldGen.InWorld(npcPositioningTileCoords.X, npcPositioningTileCoords.Y, 0)) - isInOpenness = false; - if (isInOpenness && WorldGen.SolidTile(npcPositioningTileCoords.X, npcPositioningTileCoords.Y)) - isInOpenness = false; - - if (isInOpenness) - { - Dust openDust = Main.dust[Dust.NewDust(npcPositioning, 0, 0, dustType, 0f, 0f, 0, default, 1f)]; - openDust.noGravity = true; - openDust.position = npcPositioning; - openDust.velocity = -Vector2.UnitY * dustVelocityMult * (Main.rand.NextFloat() * 0.9f + 1.6f); - openDust.fadeIn = fadeIn; - openDust.scale = dustScale; - } - - ai1 = k; - } - } - - if (npc.ai[1] % 15f == 0f && npc.ai[1] < 480f && npc.ai[1] >= 90f && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 randomOffset = Utils.RandomVector2(Main.rand, -1f, 1f); - if (randomOffset != Vector2.Zero) - randomOffset.Normalize(); - - randomOffset *= 20f + Main.rand.NextFloat() * 400f; - bool stillInTheOpen = true; - Vector2 npcOffsetPos = npc.Center + randomOffset; - Point npcOffsetPosTileCoords = npcOffsetPos.ToTileCoordinates(); - - if (!WorldGen.InWorld(npcOffsetPosTileCoords.X, npcOffsetPosTileCoords.Y, 0)) - stillInTheOpen = false; - if (stillInTheOpen && WorldGen.SolidTile(npcOffsetPosTileCoords.X, npcOffsetPosTileCoords.Y)) - stillInTheOpen = false; - - if (stillInTheOpen) - { - float smokeRotation = (Main.rand.Next(4) < 2).ToDirectionInt() * (0.3926991f + MathHelper.PiOver4 * Main.rand.NextFloat()); - Vector2 smokePosition = new Vector2(0f, -Main.rand.NextFloat() * 0.5f - 0.5f).RotatedBy(smokeRotation) * 6f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npcOffsetPos.X, npcOffsetPos.Y, smokePosition.X, smokePosition.Y, ProjectileID.BlowupSmokeMoonlord, 0, 0f, Main.myPlayer, 0f, 0f); - } - } - - if (npc.ai[1] == 1f) - SoundEngine.PlaySound(SoundID.NPCDeath61, npc.Center); - - if (npc.ai[1] >= 480f) - MoonlordDeathDrama.RequestLight((npc.ai[1] - 480f) / 120f, npc.Center); - - if (npc.ai[1] >= 600f) - { - npc.life = 0; - npc.HitEffect(0, 1337.0); - npc.checkDead(); - - foreach (NPC nPC5 in Main.ActiveNPCs) - { - if (nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead) - { - nPC5.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, nPC5.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } - } - - npc.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); - - return false; - } - } - - // Despawn effects - else if (npc.ai[0] == 3f) - { - npc.dontTakeDamage = true; - Vector2 despawnVelocityLerp = new Vector2(npc.direction, -0.5f); - npc.velocity = Vector2.Lerp(npc.velocity, despawnVelocityLerp, 0.98f); - - npc.ai[1] += 1f; - if (npc.ai[1] < 60f) - MoonlordDeathDrama.RequestLight(npc.ai[1] / 40f, npc.Center); - - if (npc.ai[1] == 40f) - { - foreach (Projectile projectile2 in Main.ActiveProjectiles) - { - 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, projectile2.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } - } - - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC nPC4 = Main.npc[k]; - if (nPC4.active && nPC4.type == NPCID.MoonLordFreeEye) - { - nPC4.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, nPC4.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } - } - - for (int l = 0; l < Main.maxGore; l++) - { - Gore gore2 = Main.gore[l]; - if (gore2.active && gore2.type >= GoreID.MoonLordHeart1 && gore2.type <= GoreID.MoonLordHeart4) - gore2.active = false; - } - } - - if (npc.ai[1] >= 60f) - { - foreach (NPC nPC5 in Main.ActiveNPCs) - { - if (nPC5.type == NPCID.MoonLordFreeEye || nPC5.type == NPCID.MoonLordHand || nPC5.type == NPCID.MoonLordHead) - { - nPC5.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, nPC5.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } - } - - npc.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); - - NPC.LunarApocalypseIsUp = false; - if (Main.dedServ) - NetMessage.SendData(MessageID.WorldData, -1, -1, null, 0, 0f, 0f, 0f, 0, 0, 0); - - return false; - } - } - - // Despawn - bool preventDespawn = false; - if (npc.ai[0] == -2f || npc.ai[0] == -1f || npc.ai[0] == -2f || npc.ai[0] == 3f) - preventDespawn = true; - if (Main.player[npc.target].active && !Main.player[npc.target].dead) - preventDespawn = true; - - if (!preventDespawn) - { - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && !Main.player[p].dead) - { - preventDespawn = true; - break; - } - } - } - if (!preventDespawn) - { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - // Teleport - if (npc.ai[0] >= 0f && npc.ai[0] < 2f && Main.netMode != NetmodeID.MultiplayerClient && npc.Distance(Main.player[npc.target].Center) > 1800f) - { - npc.ai[0] = -2f; - npc.netUpdate = true; - Vector2 value8 = Main.player[npc.target].Center - Vector2.UnitY * 150f - npc.Center; - npc.position += value8; - - if (Main.npc[(int)npc.localAI[0]].active) - { - NPC nPC6 = Main.npc[(int)npc.localAI[0]]; - nPC6.position += value8; - Main.npc[(int)npc.localAI[0]].netUpdate = true; - } - if (Main.npc[(int)npc.localAI[1]].active) - { - NPC nPC6 = Main.npc[(int)npc.localAI[1]]; - nPC6.position += value8; - Main.npc[(int)npc.localAI[1]].netUpdate = true; - } - if (Main.npc[(int)npc.localAI[2]].active) - { - NPC nPC6 = Main.npc[(int)npc.localAI[2]]; - nPC6.position += value8; - Main.npc[(int)npc.localAI[2]].netUpdate = true; - } - - foreach (NPC nPC7 in Main.ActiveNPCs) - { - if (nPC7.active && nPC7.type == NPCID.MoonLordFreeEye) - { - nPC7.position += value8; - nPC7.netUpdate = true; - } - } + NPC.ai[1] = 0f; + NPC.ai[0] = 0f; } } - else if (npc.type == NPCID.MoonLordHead) + + // Spawn head and hands + if (NPC.ai[0] == -1f) { - // Despawn - if (!Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != NPCID.MoonLordCore) + NPC.dontTakeDamage = true; + + NPC.ai[1] += 1f; + if (NPC.ai[1] == 30f) + SoundEngine.PlaySound(SoundID.Zombie92, NPC.Center); + + if (NPC.ai[1] < 60f) + MoonlordDeathDrama.RequestLight(NPC.ai[1] / 30f, NPC.Center); + + if (NPC.ai[1] == 60f) { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - } + NPC.ai[1] = 0f; + NPC.ai[0] = 0f; - // Variables - npc.dontTakeDamage = npc.localAI[3] >= 15f; - if (calamityGlobalNPC.newAI[0] == 1f) - npc.dontTakeDamage = true; - - npc.velocity = Vector2.Zero; - npc.Center = Main.npc[(int)npc.ai[3]].Center + new Vector2(0f, -400f); - Vector2 boltAndDeathrayVector = new Vector2(27f, 59f); - float attackTimer = 0f; - float attackTimerComparison = 0f; - int headVulnerability = 0; - int deathrayCheck = 0; - - // Invulnerable - if (npc.ai[0] >= 0f || npc.ai[0] == -2f) - { - if (npc.ai[0] == -2f) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.type == NPCID.MoonLordCore) { - if (calamityGlobalNPC.newAI[0] != 1f) - calamityGlobalNPC.newAI[0] = 1f; + NPC.netUpdate = true; - npc.life = npc.lifeMax; - npc.netUpdate = true; - npc.dontTakeDamage = true; - } - - // Go to die - if (Main.npc[(int)npc.ai[3]].ai[0] == 2f) - { - npc.ai[0] = -3f; - return false; - } - - // Set up attacks - float ai0CrossCheck = npc.ai[0]; - npc.ai[1] += 1f; - int attackType = (int)Main.npc[(int)npc.ai[3]].ai[2]; - int fiveFrameCounter = 0; - int attackTimerIncrement = 0; - - while (fiveFrameCounter < 5) - { - attackTimerComparison = NPC.MoonLordAttacksArray[attackType, 2, 1, fiveFrameCounter]; - if (attackTimerComparison + attackTimerIncrement > npc.ai[1]) - break; - - attackTimerIncrement += (int)attackTimerComparison; - int totalSpawns = fiveFrameCounter; - fiveFrameCounter = totalSpawns + 1; - } - - if (fiveFrameCounter == 5) - { - fiveFrameCounter = 0; - npc.ai[1] = 0f; - attackTimerComparison = NPC.MoonLordAttacksArray[attackType, 2, 1, fiveFrameCounter]; - attackTimerIncrement = 0; - } - - npc.ai[0] = NPC.MoonLordAttacksArray[attackType, 2, 0, fiveFrameCounter]; - attackTimer = (int)npc.ai[1] - attackTimerIncrement; - - if (npc.ai[0] != ai0CrossCheck) - npc.netUpdate = true; - } - - // Die - if (npc.ai[0] == -3f) - { - npc.dontTakeDamage = true; - npc.rotation = MathHelper.Lerp(npc.rotation, 0.2617994f, 0.07f); - - npc.ai[1] += 1f; - if (npc.ai[1] >= 32f) - npc.ai[1] = 0f; - if (npc.ai[1] < 0f) - npc.ai[1] = 0f; - - if (npc.localAI[2] < 14f) - npc.localAI[2] += 1f; - } - - // Set variables for deathray - else if (npc.ai[0] == 0f) - { - deathrayCheck = 3; - npc.TargetClosest(false); - - Vector2 v3 = Main.player[npc.target].Center - npc.Center - new Vector2(0f, -22f); - float deathrayTravelDist = v3.Length() / 500f; - if (deathrayTravelDist > 1f) - deathrayTravelDist = 1f; - - deathrayTravelDist = 1f - deathrayTravelDist; - deathrayTravelDist *= 2f; - if (deathrayTravelDist > 1f) - deathrayTravelDist = 1f; - - npc.localAI[0] = v3.ToRotation(); - npc.localAI[1] = deathrayTravelDist; - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); - } - - // Deathray - if (npc.ai[0] == 1f) - { - if (attackTimer < 180f) - { - npc.localAI[1] -= 0.05f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - - if (attackTimer >= 60f) + for (int i = 0; i < 2; i++) { - Vector2 center20 = npc.Center; - - // Hopefully it plays - if (attackTimer == 60f) - SoundEngine.PlaySound(DeathrayChargeSound, center20); - - int deathrayAttackDustAmt = 0; - if (attackTimer >= 120f) - deathrayAttackDustAmt = 1; - - for (int i = 0; i < 1 + deathrayAttackDustAmt; i++) - { - float deathrayAttackDustScale = 0.8f; - if (i % 2 == 1) - deathrayAttackDustScale = 1.65f; - - Vector2 deathrayAttackDustRotation = center20 + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * boltAndDeathrayVector / 2f; - int deathrayAttackDust = Dust.NewDust(deathrayAttackDustRotation - Vector2.One * 8f, 16, 16, DustID.Vortex, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); - Main.dust[deathrayAttackDust].velocity = Vector2.Normalize(center20 - deathrayAttackDustRotation) * 3.5f * (10f - deathrayAttackDustAmt * 2f) / 10f; - Main.dust[deathrayAttackDust].noGravity = true; - Main.dust[deathrayAttackDust].scale = deathrayAttackDustScale; - Main.dust[deathrayAttackDust].customData = npc; - } - } - } - else if (attackTimer < attackTimerComparison - 15f) - { - if (calamityGlobalNPC.newAI[1] == 0f) - { - calamityGlobalNPC.newAI[1] = 420f; - if (death) - calamityGlobalNPC.newAI[1] -= 60f; - - switch (aggressionLevel) - { - case 6: - calamityGlobalNPC.newAI[1] -= 180f; - break; - case 5: - calamityGlobalNPC.newAI[1] -= 90f; - break; - case 4: - break; - case 3: - calamityGlobalNPC.newAI[1] += 120f; - break; - case 2: - calamityGlobalNPC.newAI[1] += 240f; - break; - case 1: - calamityGlobalNPC.newAI[1] += 360f; - break; - default: - break; - } + int handSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + i * 800 - 400, (int)NPC.Center.Y - 100, NPCID.MoonLordHand, NPC.whoAmI); + Main.npc[handSpawn].ai[2] = i; // Used to differentiate between left and right hands + Main.npc[handSpawn].ai[3] = NPC.whoAmI; + Main.npc[handSpawn].netUpdate = true; + NPC.localAI[i] = handSpawn; } - if (attackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) - { - int projectileType = ProjectileID.PhantasmalDeathray; - int damage = npc.GetProjectileDamage(projectileType); - - npc.TargetClosest(false); - Vector2 deathrayRotationSpeed = Main.player[npc.target].Center - npc.Center; - deathrayRotationSpeed.Normalize(); - - float deathrayRotationDirection = -1f; - if (deathrayRotationSpeed.X < 0f) - deathrayRotationDirection = 1f; - - deathrayRotationSpeed = deathrayRotationSpeed.RotatedBy(-(double)deathrayRotationDirection * MathHelper.TwoPi / 6f); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, deathrayRotationSpeed.X, deathrayRotationSpeed.Y, projectileType, damage, 0f, Main.myPlayer, deathrayRotationDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], npc.whoAmI); - npc.ai[2] = (deathrayRotationSpeed.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * deathrayRotationDirection; - npc.netUpdate = true; - } - - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 1f) - npc.localAI[1] = 1f; - - float deathrayFaceDirection = (npc.ai[2] >= 0f).ToDirectionInt(); - float deathrayTimer = npc.ai[2]; - if (deathrayTimer < 0f) - deathrayTimer *= -1f; - - deathrayTimer += -(MathHelper.Pi + MathHelper.TwoPi); - deathrayTimer += deathrayFaceDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; - npc.localAI[0] = deathrayTimer; - npc.ai[2] = (deathrayTimer + MathHelper.Pi + MathHelper.TwoPi) * deathrayFaceDirection; - } - else - { - calamityGlobalNPC.newAI[1] = 0f; - - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) - { - npc.localAI[1] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && Main.remixWorld) - { - for (int k = 0; k < 30; k++) - { - if (!WorldGen.SolidTile((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f))) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, (float)Main.rand.Next(-1599, 1600) * 0.01f, (float)Main.rand.Next(-1599, 1) * 0.01f, ProjectileID.MoonBoulder, 70, 10f); - } - } - } - - deathrayCheck = 3; + int headSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y - 400, NPCID.MoonLordHead, NPC.whoAmI); + Main.npc[headSpawn].ai[3] = NPC.whoAmI; + Main.npc[headSpawn].netUpdate = true; + NPC.localAI[2] = headSpawn; } } + // In summary, localAI[0] holds the index of the left hand, localAI[1] holds the index of the right hand, and localAI[2] holds the index of the head. + } - // Moon Leech thing - else if (npc.ai[0] == 2f) + // If for whatever reason there are less True Eyes of Cthulhu than there should be, spawn more. + int trueEyesThatShouldBeActive = 0; + if (Main.npc[(int)NPC.localAI[0]].Calamity().newAI[0] == 1f) + trueEyesThatShouldBeActive++; + if (Main.npc[(int)NPC.localAI[1]].Calamity().newAI[0] == 1f) + trueEyesThatShouldBeActive++; + if (Main.npc[(int)NPC.localAI[2]].Calamity().newAI[0] == 1f) + trueEyesThatShouldBeActive++; + + if (NPC.CountNPCS(NPCID.MoonLordFreeEye) < trueEyesThatShouldBeActive) + { + if (Main.netMode != NetmodeID.MultiplayerClient) { - headVulnerability = 2; - deathrayCheck = 3; - Vector2 leechCenterOffset = new Vector2(0f, 216f); - - if (attackTimer == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 leechNPCCenter = npc.Center + leechCenterOffset; - foreach (Player player6 in Main.ActivePlayers) - { - 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, player6.whoAmI); - } - } - } - - if ((attackTimer == 120f || attackTimer == 150f || attackTimer == 180f || attackTimer == 210f || attackTimer == 240f) && Main.netMode != NetmodeID.MultiplayerClient) - { - foreach (Projectile projectile6 in Main.ActiveProjectiles) - { - 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] = projectile6.whoAmI; - } - } - } + int totalSpawns = NPC.NewNPC(NPC.GetSource_FromAI(), (int)Main.npc[(int)NPC.localAI[2]].Center.X, (int)Main.npc[(int)NPC.localAI[2]].Center.Y, NPCID.MoonLordFreeEye); + Main.npc[totalSpawns].ai[3] = NPC.whoAmI; + Main.npc[totalSpawns].netUpdate = true; } + } - // Phantasmal Bolts - else if (npc.ai[0] == 3f) + // Fly near target, don't take damage + if (NPC.ai[0] == 0f) + { + NPC.dontTakeDamage = true; + NPC.TargetClosest(false); + + Vector2 targetDistance = Main.player[NPC.target].Center - NPC.Center; + if (targetDistance.Length() > 20f) { - if (attackTimer == 0f) - { - npc.TargetClosest(false); - npc.netUpdate = true; - } - - Vector2 v4 = Main.player[npc.target].Center - npc.Center; - bool shootFirstBolt = attackTimer == attackTimerComparison - 14f; - bool shootSecondBolt = attackTimer == attackTimerComparison - 7f; - bool shootThirdBolt = attackTimer == attackTimerComparison; + float velocity = 9.25f; switch (aggressionLevel) { case 6: - v4 = Main.player[npc.target].Center + Main.player[npc.target].velocity * 30f - npc.Center; + velocity += 4f; break; case 5: - v4 = Main.player[npc.target].Center + Main.player[npc.target].velocity * 20f - npc.Center; + velocity += 2f; break; case 4: break; case 3: + velocity -= 0.25f; + break; case 2: - shootSecondBolt = false; + velocity -= 0.5f; break; case 1: - shootSecondBolt = false; - shootThirdBolt = false; + velocity -= 0.75f; + break; + default: + break; + } + // Move slower if the head is doing the phantasmal deathray + if (Main.npc[(int)NPC.localAI[2]].ai[0] == 1f) + velocity -= 2.25f; + + Vector2 desiredVelocity = Vector2.Normalize(targetDistance - NPC.velocity) * velocity; + Vector2 currentVelocity = NPC.velocity; + NPC.SimpleFlyMovement(desiredVelocity, 0.5f); + NPC.velocity = Vector2.Lerp(NPC.velocity, currentVelocity, 0.5f); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Despawn if other parts aren't there + bool shouldDespawn = false; + if (NPC.localAI[0] < 0f || NPC.localAI[1] < 0f || NPC.localAI[2] < 0f) + shouldDespawn = true; + else if (!Main.npc[(int)NPC.localAI[0]].active || Main.npc[(int)NPC.localAI[0]].type != NPCID.MoonLordHand) + shouldDespawn = true; + else if (!Main.npc[(int)NPC.localAI[1]].active || Main.npc[(int)NPC.localAI[1]].type != NPCID.MoonLordHand) + shouldDespawn = true; + else if (!Main.npc[(int)NPC.localAI[2]].active || Main.npc[(int)NPC.localAI[2]].type != NPCID.MoonLordHead) + shouldDespawn = true; + + if (shouldDespawn) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + + // Take damage if other parts are down + bool coreIsOpen = true; + if (Main.npc[(int)NPC.localAI[0]].Calamity().newAI[0] != 1f) + coreIsOpen = false; + if (Main.npc[(int)NPC.localAI[1]].Calamity().newAI[0] != 1f) + coreIsOpen = false; + if (Main.npc[(int)NPC.localAI[2]].Calamity().newAI[0] != 1f) + coreIsOpen = false; + + if (coreIsOpen) + { + NPC.ai[0] = 1f; + NPC.dontTakeDamage = false; + NPC.netUpdate = true; + } + } + } + + // Fly near target, take damage + else if (NPC.ai[0] == 1f) + { + NPC.dontTakeDamage = false; + NPC.TargetClosest(false); + + Vector2 targetDistanceVulnerable = Main.player[NPC.target].Center - NPC.Center; + if (targetDistanceVulnerable.Length() > 20f) + { + float velocity = 9.25f; + switch (aggressionLevel) + { + case 6: + velocity += 4f; + break; + case 5: + velocity += 2f; + break; + case 4: + break; + case 3: + velocity -= 0.25f; + break; + case 2: + velocity -= 0.5f; + break; + case 1: + velocity -= 0.75f; + break; + default: + break; + } + // Move slower if the head is doing the phantasmal deathray + if (Main.npc[(int)NPC.localAI[2]].ai[0] == 1f) + velocity -= 2f; + + Vector2 desiredVelocity = Vector2.Normalize(targetDistanceVulnerable - NPC.velocity) * velocity; + Vector2 currentVelocity = NPC.velocity; + NPC.SimpleFlyMovement(desiredVelocity, 0.5f); + NPC.velocity = Vector2.Lerp(NPC.velocity, currentVelocity, 0.5f); + } + } + + // Death effects + else if (NPC.ai[0] == 2f) + { + NPC.dontTakeDamage = true; + NPC.Calamity().ShouldCloseHPBar = true; + NPC.velocity = new Vector2(NPC.direction, -0.5f); + + NPC.ai[1] += 1f; + if (NPC.ai[1] < 60f) + MoonlordDeathDrama.RequestLight(NPC.ai[1] / 60f, NPC.Center); + + // Kill all projectiles and the True Eyes once the screen fades to white + if (NPC.ai[1] == 60f) + { + foreach (Projectile projectile in Main.ActiveProjectiles) + { + if ((projectile.type == ProjectileID.MoonLeech || projectile.type == ProjectileID.PhantasmalBolt || + projectile.type == ProjectileID.PhantasmalDeathray || projectile.type == ProjectileID.PhantasmalEye || + projectile.type == ProjectileID.PhantasmalSphere)) + projectile.Kill(); + } + + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type == NPCID.MoonLordFreeEye) + { + n.HitEffect(0, 9999.0); + n.active = false; + } + } + } + + // Dust and smoke effects + if (NPC.ai[1] % 3f == 0f && NPC.ai[1] < 580f && NPC.ai[1] > 60f) + { + Vector2 randPositionOffset = Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(20f, 420f); + Vector2 dustPos = NPC.Center + randPositionOffset; + Point dustPosTileCoords = dustPos.ToTileCoordinates(); + bool inOpenSpace = WorldGen.InWorld(dustPosTileCoords.X, dustPosTileCoords.Y, 0) && !WorldGen.SolidTile(dustPosTileCoords.X, dustPosTileCoords.Y); + + float dustScale = Main.rand.NextFloat(1f, 2f); + float fadeIn = Main.rand.NextFloat(0.4f, 1.4f); + + if (inOpenSpace) + { + float randDustAmt = Main.rand.Next(6, 19); + //MoonlordDeathDrama.AddExplosion(npcPosition); + for (int j = 0; j < randDustAmt * 2; j++) + { + float dustRotation = Main.rand.NextFloat(MathHelper.TwoPi) + MathHelper.TwoPi / randDustAmt * j; + Dust vortex = Dust.NewDustPerfect(dustPos, DustID.Vortex, Vector2.UnitY.RotatedBy(dustRotation) * Main.rand.NextFloat(1.6f, 9.6f), Scale: dustScale); + vortex.noGravity = true; + vortex.fadeIn = fadeIn; + } + } + + for (float k = 0f; k < NPC.ai[1] / 60f; k++) + { + Vector2 randPosOffset = Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(20f, 820f); + Vector2 smokePos = NPC.Center + randPosOffset; + Point smokePosTileCoords = smokePos.ToTileCoordinates(); + bool smokeOpenSpace = WorldGen.InWorld(smokePosTileCoords.X, smokePosTileCoords.Y, 0) && !WorldGen.SolidTile(smokePosTileCoords.X, smokePosTileCoords.Y); + + if (smokeOpenSpace) + { + Dust openDust = Dust.NewDustPerfect(smokePos, Main.rand.NextBool() ? DustID.Smoke : DustID.Vortex, -Vector2.UnitY * Main.rand.NextFloat(0.9f, 7.5f), Scale: dustScale); + openDust.noGravity = true; + openDust.fadeIn = fadeIn; + } + } + + } + + // Explosion effects + if (NPC.ai[1] % 15f == 0f && NPC.ai[1] < 480f && NPC.ai[1] >= 90f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 randomOffset = Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(20f, 420f); + Vector2 npcOffset = NPC.Center + randomOffset; + Point npcOffsetTileCoords = npcOffset.ToTileCoordinates(); + bool inOpenSpace = WorldGen.InWorld(npcOffsetTileCoords.X, npcOffsetTileCoords.Y, 0) && !WorldGen.SolidTile(npcOffsetTileCoords.X, npcOffsetTileCoords.Y); + + if (inOpenSpace) + { + float smokeRotation = Main.rand.NextBool().ToDirectionInt() * (MathHelper.Pi / 8f + Main.rand.NextFloat(MathHelper.PiOver4)); + Vector2 smokeVelocity = -Vector2.UnitY.RotatedBy(smokeRotation) * Main.rand.NextFloat(3f, 6f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcOffset, smokeVelocity, ProjectileID.BlowupSmokeMoonlord, 0, 0f, Main.myPlayer); + } + } + + if (NPC.ai[1] == 1f) + SoundEngine.PlaySound(SoundID.NPCDeath61, NPC.Center); + + if (NPC.ai[1] >= 480f) + MoonlordDeathDrama.RequestLight((NPC.ai[1] - 480f) / 120f, NPC.Center); + + // Actually kill the boss at the end of the animation. + if (NPC.ai[1] >= 600f) + { + NPC.life = 0; + NPC.HitEffect(0, 1337.0); // A HitEffect that deals exactly 1337 damage is what tells the game to spawn Moon Lord's skeleton gores. + NPC.checkDead(); + + // Despawn all the other parts + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type == NPCID.MoonLordHand || n.type == NPCID.MoonLordHead) + { + n.active = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, n.whoAmI); + } + } + + NPC.active = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI); + + return; + } + } + + // Despawn effects + else if (NPC.ai[0] == 3f) + { + NPC.dontTakeDamage = true; + Vector2 despawnVelocityLerp = new Vector2(NPC.direction, -0.5f); + NPC.velocity = Vector2.Lerp(NPC.velocity, despawnVelocityLerp, 0.98f); + + NPC.ai[1] += 1f; + if (NPC.ai[1] < 60f) + MoonlordDeathDrama.RequestLight(NPC.ai[1] / 40f, NPC.Center); + + // Kill all projectiles, True Eyes, and gores once the screen fades to white + if (NPC.ai[1] == 40f) + { + foreach (Projectile projectile in Main.ActiveProjectiles) + { + if ((projectile.type == ProjectileID.MoonLeech || projectile.type == ProjectileID.PhantasmalBolt || + projectile.type == ProjectileID.PhantasmalDeathray || projectile.type == ProjectileID.PhantasmalEye || + projectile.type == ProjectileID.PhantasmalSphere)) + projectile.Kill(); + } + + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type == NPCID.MoonLordFreeEye) + { + n.HitEffect(0, 9999.0); + n.active = false; + } + } + + for (int l = 0; l < Main.maxGore; l++) + { + Gore gore2 = Main.gore[l]; + if (gore2.active && gore2.type >= GoreID.MoonLordHeart1 && gore2.type <= GoreID.MoonLordHeart4) + gore2.active = false; + } + } + + if (NPC.ai[1] >= 60f) + { + // Despawn all the other parts first + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type == NPCID.MoonLordHand || n.type == NPCID.MoonLordHead) + { + n.active = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, n.whoAmI); + } + } + + NPC.active = false; + if (Main.netMode != NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI); + + NPC.LunarApocalypseIsUp = false; + if (Main.dedServ) + NetMessage.SendData(MessageID.WorldData, -1, -1, null); + + return; + } + } + + // Despawn + bool preventDespawn = NPC.ai[0] == -2f || NPC.ai[0] == -1f || NPC.ai[0] == 2f || NPC.ai[0] == 3f || (Main.player[NPC.target].active && !Main.player[NPC.target].dead); + if (!preventDespawn) + { + foreach (Player p in Main.ActivePlayers) + { + if (!p.dead) + { + preventDespawn = true; + break; + } + } + } + if (!preventDespawn) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + // Teleport + if (NPC.ai[0] >= 0f && NPC.ai[0] < 2f && Main.netMode != NetmodeID.MultiplayerClient && NPC.Distance(Main.player[NPC.target].Center) > 1800f) + { + NPC.ai[0] = -2f; + NPC.netUpdate = true; + // Teleports the core + Vector2 teleportOffset = Main.player[NPC.target].Center - Vector2.UnitY * 150f - NPC.Center; + NPC.position += teleportOffset; + + // Teleports the left hand + if (Main.npc[(int)NPC.localAI[0]].active) + { + Main.npc[(int)NPC.localAI[0]].position += teleportOffset; + Main.npc[(int)NPC.localAI[0]].netUpdate = true; + } + // Teleports the right hand + if (Main.npc[(int)NPC.localAI[1]].active) + { + Main.npc[(int)NPC.localAI[1]].position += teleportOffset; + Main.npc[(int)NPC.localAI[1]].netUpdate = true; + } + // Teleports the head + if (Main.npc[(int)NPC.localAI[2]].active) + { + Main.npc[(int)NPC.localAI[2]].position += teleportOffset; + Main.npc[(int)NPC.localAI[2]].netUpdate = true; + } + // Teleports the True Eyes + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type == NPCID.MoonLordFreeEye) + { + n.position += teleportOffset; + n.netUpdate = true; + } + } + } + } + + public void BuffedMoonLordHeadAI(int aggressionLevel) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Despawn + if (!Main.npc[(int)NPC.ai[3]].active || Main.npc[(int)NPC.ai[3]].type != NPCID.MoonLordCore) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + + // Trigger Daybreak projectiles + if (NPC.localAI[3] == 13f && !NPC.dontTakeDamage) + NPC.PopAllAttachedProjectilesAndTakeDamageForThem(); + + // Variables + NPC.dontTakeDamage = NPC.localAI[3] >= 15f; + if (calamityGlobalNPC.newAI[0] == 1f) + NPC.dontTakeDamage = true; + + NPC.velocity = Vector2.Zero; + NPC.Center = Main.npc[(int)NPC.ai[3]].Center - Vector2.UnitY * 400f; + Vector2 eyeSizeVector = new Vector2(27f, 59f); + float attackTimer = 0f; + int phaseAttackTime = 0; + int mouthAnimationCheck = 0; + int eyeAnimationCheck = 0; + + // Invulnerable + if (NPC.ai[0] >= 0f || NPC.ai[0] == -2f) + { + // Vanilla sets ai[0] to -2 in checkDead, Calamity makes the head continue to attack after being killed + if (NPC.ai[0] == -2f) + { + if (calamityGlobalNPC.newAI[0] != 1f) + calamityGlobalNPC.newAI[0] = 1f; + + NPC.life = NPC.lifeMax; + NPC.netUpdate = true; + NPC.dontTakeDamage = true; + } + + // Go to death animation + if (Main.npc[(int)NPC.ai[3]].ai[0] == 2f) + { + NPC.ai[0] = -3f; + return; + } + + // Set up attacks + float ai0CrossCheck = NPC.ai[0]; + NPC.ai[1] += 1f; + int attackIncrement = 0; + int totalAttackTimer = 0; + + // Yes, it is completely true: Moon Lord uses a 4D array to organize its attack pattern. + // I will use this opportunity to explain to the best of my abilities how this 4D array is organized. + // The first value is unused; it is always 0. There is vanilla code suggesting this was originally going to be set to a random value from 0-2, but alas. + // The second value determines what body part to get attacks for. 0 is left hand, 1 is right hand, 2 is head. + // The third value holds what is actually passed to the AI. 0 contains the value for ai[0], and 1 contains the attack duration in frames, used for ai[1] comparison. + // The fourth value is what number attack it is in the pattern, from 0-4. + while (attackIncrement < 5) + { + phaseAttackTime = NPC.MoonLordAttacksArray[0, 2, 1, attackIncrement]; + if (phaseAttackTime + totalAttackTimer > NPC.ai[1]) + break; + + totalAttackTimer += phaseAttackTime; + attackIncrement++; + } + + if (attackIncrement == 5) + { + attackIncrement = 0; + NPC.ai[1] = 0f; + phaseAttackTime = NPC.MoonLordAttacksArray[0, 2, 1, attackIncrement]; + totalAttackTimer = 0; + } + + NPC.ai[0] = NPC.MoonLordAttacksArray[0, 2, 0, attackIncrement]; + attackTimer = (int)NPC.ai[1] - totalAttackTimer; + + if (NPC.ai[0] != ai0CrossCheck) + NPC.netUpdate = true; + } + + // Death animation behavior + if (NPC.ai[0] == -3f) + { + NPC.dontTakeDamage = true; + NPC.rotation = MathHelper.Lerp(NPC.rotation, MathHelper.Pi / 12f, 0.07f); + + // ai[1] is used here for animating the head, localAI[2] is used here for ensuring the mouth is open + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 32f) + NPC.ai[1] = 0f; + if (NPC.ai[1] < 0f) + NPC.ai[1] = 0f; + + if (NPC.localAI[2] < 14f) + NPC.localAI[2] += 1f; + } + + // Setup phase for deathray and leech attacks + else if (NPC.ai[0] == 0f) + { + eyeAnimationCheck = 3; + NPC.TargetClosest(false); + + Vector2 targetDist = Main.player[NPC.target].Center - NPC.Center + Vector2.UnitY * 22f; + float deathrayTravelDist = targetDist.Length() / 500f; + if (deathrayTravelDist > 1f) + deathrayTravelDist = 1f; + deathrayTravelDist = 1f - deathrayTravelDist; + deathrayTravelDist *= 2f; + if (deathrayTravelDist > 1f) + deathrayTravelDist = 1f; + + NPC.localAI[0] = targetDist.ToRotation(); // localAI[0] controls the angle of the deathray + NPC.localAI[1] = deathrayTravelDist; // localAI[1] controls the draw location of the eye's pupil, which also controls the relative location of the deathray + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 1f, 0.2f); // localAI[2] controls the animation of the mouth, this makes it close + } + + // Deathray + if (NPC.ai[0] == 1f) + { + if (attackTimer < 180f) + { + // When localAI[1] is 0, the pupil draws in the center of the eye + NPC.localAI[1] -= 0.05f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + + if (attackTimer >= 60f) + { + // Play a chargeup sound for the deathray + if (attackTimer == 60f) + SoundEngine.PlaySound(DeathrayChargeSound, Main.player[NPC.target].Center); + + // Dust telegraph + int deathrayDustAmt = attackTimer >= 120f ? 2 : 1; + for (int i = 0; i < deathrayDustAmt; i++) + { + float deathrayDustScale = i % 2 == 1 ? 1.65f : 0.8f; + Vector2 deathrayDustRotation = NPC.Center + Main.rand.NextFloat(MathHelper.TwoPi).ToRotationVector2() * eyeSizeVector / 2f; + + Dust deathrayDust = Dust.NewDustDirect(deathrayDustRotation - Vector2.One * 8f, 16, 16, DustID.Vortex, 0f, 0f, Scale: deathrayDustScale); + deathrayDust.velocity = Utils.DirectionTo(deathrayDustRotation, NPC.Center) * 0.35f * (10f - deathrayDustAmt * 2f); + deathrayDust.noGravity = true; + deathrayDust.customData = NPC; + } + } + } + else if (attackTimer < phaseAttackTime - 15f) + { + // Controls the angular speed of the deathray, lower number means it rotates faster + if (calamityGlobalNPC.newAI[1] == 0f) + { + calamityGlobalNPC.newAI[1] = 420f; + + switch (aggressionLevel) + { + case 6: + calamityGlobalNPC.newAI[1] -= 180f; + break; + case 5: + calamityGlobalNPC.newAI[1] -= 90f; + break; + case 4: + break; + case 3: + calamityGlobalNPC.newAI[1] += 120f; + break; + case 2: + calamityGlobalNPC.newAI[1] += 240f; + break; + case 1: + calamityGlobalNPC.newAI[1] += 360f; + break; + default: + break; + } + } + + // Fire the deathray + if (attackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.TargetClosest(false); + Vector2 deathrayRotationSpeed = Utils.DirectionTo(NPC.Center, Main.player[NPC.target].Center); + int deathrayRotationDirection = (deathrayRotationSpeed.X < 0).ToDirectionInt(); + deathrayRotationSpeed = deathrayRotationSpeed.RotatedBy(-deathrayRotationDirection * MathHelper.TwoPi / 6f); + float angularSpeed = deathrayRotationDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; + + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, deathrayRotationSpeed, ProjectileID.PhantasmalDeathray, DeathrayDamage, 0f, Main.myPlayer, angularSpeed, NPC.whoAmI); + NPC.ai[2] = (deathrayRotationSpeed.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * deathrayRotationDirection; + NPC.netUpdate = true; + } + + // When localAI[1] is 1, the pupil draws at the edge of the eye, in the direction determined by localAI[0] + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 1f) + NPC.localAI[1] = 1f; + + float deathrayFaceDirection = (NPC.ai[2] >= 0f).ToDirectionInt(); + float deathrayTimer = NPC.ai[2]; + if (deathrayTimer < 0f) + deathrayTimer *= -1f; + + deathrayTimer += deathrayFaceDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1] - MathHelper.Pi; + NPC.localAI[0] = deathrayTimer; + NPC.ai[2] = (deathrayTimer + MathHelper.Pi) * deathrayFaceDirection; // ai[2] is used as a temporary buffer to facilitate incrementing localAI[0] + } + else + { + // Reset deathray angular speed + calamityGlobalNPC.newAI[1] = 0f; + + // Reset pupil draw location + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + { + NPC.localAI[1] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld) // GFB moon boulder bullshit thanks Red + { + for (int k = 0; k < 30; k++) + { + if (!WorldGen.SolidTile((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f))) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, (float)Main.rand.Next(-1599, 1600) * 0.01f, (float)Main.rand.Next(-1599, 1) * 0.01f, ProjectileID.MoonBoulder, 70, 10f); + } + } + } + + eyeAnimationCheck = 3; + } + } + + // Moon Leech thing + else if (NPC.ai[0] == 2f) + { + mouthAnimationCheck = 2; + eyeAnimationCheck = 3; + Vector2 mouthOffset = Vector2.UnitY * 216f; + + // Spawn the leech tongue(s) + if (attackTimer == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 leechSpawnPos = NPC.Center + mouthOffset; + foreach (Player p in Main.ActivePlayers) + { + if (!p.dead && Vector2.Distance(p.Center, leechSpawnPos) <= 3000f) + { + Vector2 targetLeechDist = Utils.SafeNormalize(Main.player[NPC.target].Center - leechSpawnPos, Vector2.Zero); + Projectile.NewProjectile(NPC.GetSource_FromAI(), leechSpawnPos, targetLeechDist, ProjectileID.MoonLeech, 0, 0f, Main.myPlayer, NPC.whoAmI + 1, p.whoAmI); + } + } + } + + // Spawn Moon Leech Clots from players with a leech tongue on them + if (attackTimer >= 120f && attackTimer <= 240f && attackTimer % 30f == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ProjectileID.MoonLeech && Main.player[(int)p.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, 0, NPC.whoAmI + 1, p.whoAmI); + Main.npc[moonLeech].netUpdate = true; + } + } + } + } + + // Phantasmal Bolts + else if (NPC.ai[0] == 3f) + { + if (attackTimer == 1f) + { + NPC.TargetClosest(false); + NPC.netUpdate = true; + } + + Vector2 aimDirection = Main.player[NPC.target].Center - NPC.Center; + bool shootFirstBolt = attackTimer == phaseAttackTime - 14f; + bool shootSecondBolt = attackTimer == phaseAttackTime - 7f; + bool shootThirdBolt = attackTimer == phaseAttackTime; + switch (aggressionLevel) + { + // Higher aggression gives the phantasmal bolts predictive aim + case 6: + aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 30f - NPC.Center; + break; + case 5: + aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f - NPC.Center; + break; + case 4: + break; + case 3: + // Lower aggression fires less phantasmal bolts + case 2: + shootSecondBolt = false; + break; + case 1: + shootSecondBolt = false; + shootThirdBolt = false; + break; + default: + break; + } + + // localAI[0] and localAI[1] are again used to control where the eye's pupil draws + NPC.localAI[0] = NPC.localAI[0].AngleLerp(aimDirection.ToRotation(), 0.5f); + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 1f) + NPC.localAI[1] = 1f; + + if (attackTimer == phaseAttackTime - 35f) + SoundEngine.PlaySound(SoundID.NPCDeath6, NPC.Center); + + // Fire the phantasmal bolts + if ((shootFirstBolt || shootSecondBolt || shootThirdBolt) && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 boltDirection = Utils.Vector2FromElipse(NPC.localAI[0].ToRotationVector2(), eyeSizeVector * NPC.localAI[1]); + + float velocity = 6.25f; + switch (aggressionLevel) + { + case 6: + case 5: + case 4: + break; + // Lower aggression reduces the speed of phantasmal bolts + case 3: + velocity -= 0.25f; + break; + case 2: + velocity -= 0.5f; + break; + case 1: + velocity -= 0.75f; break; default: break; } - npc.localAI[0] = npc.localAI[0].AngleLerp(v4.ToRotation(), 0.5f); - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 1f) - npc.localAI[1] = 1f; + Vector2 boltVelocity = Vector2.Normalize(aimDirection) * velocity; + int type = ProjectileID.PhantasmalBolt; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + boltDirection, boltVelocity, type, BoltDamage, 0f, Main.myPlayer); + } + } - if (attackTimer == attackTimerComparison - 35f) - SoundEngine.PlaySound(SoundID.NPCDeath6, npc.Center); + // localAI[2] is used to control the animation of the mouth opening and closing + int headEyeVulnerableCheck = mouthAnimationCheck * 7; + if (headEyeVulnerableCheck > NPC.localAI[2]) + NPC.localAI[2] += 1f; + if (headEyeVulnerableCheck < NPC.localAI[2]) + NPC.localAI[2] -= 1f; + if (NPC.localAI[2] < 0f) + NPC.localAI[2] = 0f; + if (NPC.localAI[2] > 14f) + NPC.localAI[2] = 14f; - if ((shootFirstBolt || shootSecondBolt || shootThirdBolt) && Main.netMode != NetmodeID.MultiplayerClient) + // localAI[3] is used to control the animation of the head eye opening and closing + // It also controls whether or not the head can be damaged + int headEyeDeathrayCheck = eyeAnimationCheck * 5; + if (headEyeDeathrayCheck > NPC.localAI[3]) + NPC.localAI[3] += 1f; + if (headEyeDeathrayCheck < NPC.localAI[3]) + NPC.localAI[3] -= 1f; + if (NPC.localAI[3] < 0f) + NPC.localAI[2] = 0f; + if (NPC.localAI[3] > 15f) + NPC.localAI[2] = 15f; + } + + public void BuffedMoonLordHandAI(int aggressionLevel) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Start attack array + NPC.InitializeMoonLordAttacks(); + + // Despawn + if (!Main.npc[(int)NPC.ai[3]].active || Main.npc[(int)NPC.ai[3]].type != NPCID.MoonLordCore) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + + // Variables + bool isLeftHand = NPC.ai[2] == 0f; + float handFaceDirection = -isLeftHand.ToDirectionInt(); + NPC.spriteDirection = (int)handFaceDirection; + + // Trigger Daybreak projectiles + if (NPC.frameCounter == 19.0 && !NPC.dontTakeDamage) + NPC.PopAllAttachedProjectilesAndTakeDamageForThem(); + + NPC.dontTakeDamage = NPC.frameCounter >= 21.0; + if (calamityGlobalNPC.newAI[0] == 1f) + NPC.dontTakeDamage = true; + + Vector2 eyeSizeVector = new Vector2(30f, 66f); + Vector2 coreCenter = Main.npc[(int)NPC.ai[3]].Center; + float handAttackTimer = 0f; + float phaseAttackTime = 0f; + int handFrameCheck = 0; + + // Go to death animation + if (Main.npc[(int)NPC.ai[3]].ai[0] == 2f) + NPC.ai[0] = -2f; + + // Choose attacks + if (NPC.ai[0] != -2f || (NPC.ai[0] == -2f && Main.npc[(int)NPC.ai[3]].ai[0] != 2f)) + { + // Vanilla sets ai[0] to -2 in checkDead, Calamity makes the hands continue to attack after being killed + if (NPC.ai[0] == -2f && Main.npc[(int)NPC.ai[3]].ai[0] != 2f) + { + if (calamityGlobalNPC.newAI[0] != 1f) + calamityGlobalNPC.newAI[0] = 1f; + + NPC.life = NPC.lifeMax; + NPC.netUpdate = true; + NPC.dontTakeDamage = true; + } + + // Set up attacks + float ai0CrossCheck = NPC.ai[0]; + NPC.ai[1] += 1f; + int handType = isLeftHand ? 0 : 1; + int attackIncrement = 0; + int totalAttackTimer = 0; + + // Yes, it is completely true: Moon Lord uses a 4D array to organize its attack pattern. + // I will use this opportunity to explain to the best of my abilities how this 4D array is organized. + // The first value is unused; it is always 0. There is vanilla code suggesting this was originally going to be set to a random value from 0-2, but alas. + // The second value determines what body part to get attacks for. 0 is left hand, 1 is right hand, 2 is head. + // The third value holds what is actually passed to the AI. 0 contains the value for ai[0], and 1 contains the attack duration in frames, used for ai[1] comparison. + // The fourth value is what number attack it is in the pattern, from 0-4. + while (attackIncrement < 5) + { + phaseAttackTime = NPC.MoonLordAttacksArray[0, handType, 1, attackIncrement]; + if (phaseAttackTime + totalAttackTimer > NPC.ai[1]) + break; + + totalAttackTimer += (int)phaseAttackTime; + attackIncrement++; + } + + if (attackIncrement == 5) + { + attackIncrement = 0; + NPC.ai[1] = 0f; + phaseAttackTime = NPC.MoonLordAttacksArray[0, handType, 1, attackIncrement]; + totalAttackTimer = 0; + } + + NPC.ai[0] = NPC.MoonLordAttacksArray[0, handType, 0, attackIncrement]; + handAttackTimer = (int)NPC.ai[1] - totalAttackTimer; + if (NPC.ai[0] != ai0CrossCheck) + NPC.netUpdate = true; + } + + if (NPC.ai[0] == -2f) + { + handFrameCheck = 0; + NPC.dontTakeDamage = true; + NPC.velocity = Main.npc[(int)NPC.ai[3]].velocity; + } + + // Move + else if (NPC.ai[0] == 0f) + { + handFrameCheck = 3; + // When localAI[1] is 0, the pupil draws in the center of the eye + NPC.localAI[1] -= 0.05f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + + Vector2 handMovementVector = coreCenter + new Vector2(350f * handFaceDirection, -100f); + Vector2 handMovementDirection = handMovementVector - NPC.Center; + + if (handMovementDirection.Length() > 20f) + { + handMovementDirection.Normalize(); + + float velocity = 7.5f; + switch (aggressionLevel) { - Vector2 boltDirection = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), boltAndDeathrayVector * npc.localAI[1]); + case 6: + velocity += 3f; + break; + case 5: + velocity += 1.5f; + break; + case 4: + break; + case 3: + velocity -= 0.4f; + break; + case 2: + velocity -= 0.8f; + break; + case 1: + velocity -= 1.2f; + break; + default: + break; + } - float velocity = death ? 6.75f : 6.25f; + handMovementDirection *= velocity; + Vector2 currentVelocity = NPC.velocity; + if (handMovementDirection != Vector2.Zero) + NPC.SimpleFlyMovement(handMovementDirection, 0.3f); + NPC.velocity = Vector2.Lerp(currentVelocity, NPC.velocity, 0.5f); + } + } + + // Phantasmal Eyes + else if (NPC.ai[0] == 1f) + { + handFrameCheck = 0; + float divisor = 6f; + switch (aggressionLevel) + { + case 6: + divisor = 3f; + break; + case 5: + divisor = 4f; + break; + case 4: + break; + case 3: + divisor = 8f; + break; + case 2: + divisor = 10f; + break; + case 1: + divisor = 12f; + break; + default: + break; + } + + if (handAttackTimer >= 56) + { + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + } + else if (handAttackTimer >= 28) + { + // Higher values of localAI[1] make the pupil draw closer to the edge of the eye + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 0.75f) + NPC.localAI[1] = 0.75f; + + // localAI[0] controls the angle in which the eye looks + float handPauseDirection = MathHelper.TwoPi * (handAttackTimer % 28) / 28 - MathHelper.PiOver2; + NPC.localAI[0] = new Vector2(MathF.Cos(handPauseDirection) * eyeSizeVector.X, MathF.Sin(handPauseDirection) * eyeSizeVector.Y).ToRotation(); + + // Spawn phantasmal eyes + if (handAttackTimer % divisor == 0f) + { + float velocity = 3f; switch (aggressionLevel) { case 6: @@ -921,148 +1122,211 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 4: break; case 3: - velocity -= 0.25f; + velocity += 0.5f; break; case 2: - velocity -= 0.5f; + velocity += 1f; break; case 1: - velocity -= 0.75f; + velocity += 1.5f; break; default: break; } - Vector2 boltVelocity = Vector2.Normalize(v4) * velocity; - int type = ProjectileID.PhantasmalBolt; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + boltDirection.X, npc.Center.Y + boltDirection.Y, boltVelocity.X, boltVelocity.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); + Vector2 eyeDirection = Utils.Vector2FromElipse(NPC.localAI[0].ToRotationVector2(), eyeSizeVector * NPC.localAI[1]); + Vector2 eyeSpawn = NPC.Center + Vector2.Normalize(eyeDirection) * eyeSizeVector.Length() * 0.4f + new Vector2(-handFaceDirection, 3f); + Vector2 eyeVelocity = Vector2.Normalize(eyeDirection) * velocity; + float ai = (Main.rand.NextFloat(MathHelper.TwoPi) - MathHelper.Pi) / 30f + MathHelper.Pi / 180f * handFaceDirection; + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), eyeSpawn, eyeVelocity, ProjectileID.PhantasmalEye, EyeDamage, 0f, Main.myPlayer, 0f, ai, aggressionLevel); + Main.projectile[proj].timeLeft = 1200; } } + else + { + NPC.localAI[1] += 0.02f; + if (NPC.localAI[1] > 0.75f) + NPC.localAI[1] = 0.75f; - // Dictates whether this npc is vulnerable or not - int headEyeVulnerableCheck = headVulnerability * 7; - if (headEyeVulnerableCheck > npc.localAI[2]) - npc.localAI[2] += 1f; - if (headEyeVulnerableCheck < npc.localAI[2]) - npc.localAI[2] -= 1f; - if (npc.localAI[2] < 0f) - npc.localAI[2] = 0f; - if (npc.localAI[2] > 14f) - npc.localAI[2] = 14f; - - int headEyeDeathrayCheck = deathrayCheck * 5; - if (headEyeDeathrayCheck > npc.localAI[3]) - npc.localAI[3] += 1f; - if (headEyeDeathrayCheck < npc.localAI[3]) - npc.localAI[3] -= 1f; - if (npc.localAI[3] < 0f) - npc.localAI[2] = 0f; - if (npc.localAI[3] > 15f) - npc.localAI[2] = 15f; + float handPauseDirection = MathHelper.TwoPi * (handAttackTimer % 28) / 28 - MathHelper.PiOver2; + NPC.localAI[0] = new Vector2(MathF.Cos(handPauseDirection) * eyeSizeVector.X, MathF.Sin(handPauseDirection) * eyeSizeVector.Y).ToRotation(); + } } - else if (npc.type == NPCID.MoonLordHand) + + // Phantasmal Spheres + else if (NPC.ai[0] == 2f) { - // Start attack array - NPC.InitializeMoonLordAttacks(); + // localAI[1] is again used to control the pupil draw position + NPC.localAI[1] -= 0.05f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; - // Despawn - if (!Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != NPCID.MoonLordCore) + Vector2 sphereHandDirection = coreCenter + new Vector2(320f * handFaceDirection, -110f); + Vector2 sphereHandDirectionMaxBound = new Vector2(400f * handFaceDirection, -60f); + + float velocityMultiplier = 0.885f; + switch (aggressionLevel) { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; + case 6: + velocityMultiplier -= 0.04f; + break; + case 5: + velocityMultiplier -= 0.02f; + break; + case 4: + break; + case 3: + velocityMultiplier += 0.004f; + break; + case 2: + velocityMultiplier += 0.008f; + break; + case 1: + velocityMultiplier += 0.012f; + break; + default: + break; } - // Variables - bool isLeftHand = npc.ai[2] == 0f; - float handFaceDirection = -isLeftHand.ToDirectionInt(); - npc.spriteDirection = (int)handFaceDirection; - - npc.dontTakeDamage = npc.frameCounter >= 21.0; - if (calamityGlobalNPC.newAI[0] == 1f) - npc.dontTakeDamage = true; - - Vector2 handBehaviorVector = new Vector2(30f, 66f); - float handAttackTimer = 0f; - float handAttackTimerComparison = 0f; - int handFrameCheck = 0; - - // Go to die - if (Main.npc[(int)npc.ai[3]].ai[0] == 2f) - npc.ai[0] = -2f; - - // Choose attacks - if (npc.ai[0] != -2f || (npc.ai[0] == -2f && Main.npc[(int)npc.ai[3]].ai[0] != 2f)) + if (handAttackTimer < 30f) { - if (npc.ai[0] == -2f && Main.npc[(int)npc.ai[3]].ai[0] != 2f) + // Set the hand's velocity for moving away from the body + Vector2 sphereHandTravelVelocity = sphereHandDirection - NPC.Center; + if (sphereHandTravelVelocity != Vector2.Zero) { - if (calamityGlobalNPC.newAI[0] != 1f) - calamityGlobalNPC.newAI[0] = 1f; + Vector2 sphereHandTravelDist = Vector2.Normalize(sphereHandTravelVelocity); - npc.life = npc.lifeMax; - npc.netUpdate = true; - npc.dontTakeDamage = true; + float velocity = 10f; + switch (aggressionLevel) + { + case 6: + velocity += 4f; + break; + case 5: + velocity += 2f; + break; + case 4: + break; + case 3: + velocity -= 0.5f; + break; + case 2: + velocity -= 1f; + break; + case 1: + velocity -= 1.5f; + break; + default: + break; + } + + NPC.velocity = Vector2.SmoothStep(NPC.velocity, sphereHandTravelDist * Math.Min(velocity, sphereHandTravelVelocity.Length()), 0.2f); } + } + else if (handAttackTimer < 210f) + { + // Set the frame to slightly closed + handFrameCheck = 1; + int sphereHandSpeed = (int)handAttackTimer - 30; - float handAI0CrossCheck = npc.ai[0]; - npc.ai[1] += 1f; - int handAttackType = (int)Main.npc[(int)npc.ai[3]].ai[2]; - int handType = isLeftHand ? 0 : 1; - int handFiveFrameTimer = 0; - int handAttackTimerIncrement = 0; - - while (handFiveFrameTimer < 5) + int divisor = 30; + switch (aggressionLevel) { - handAttackTimerComparison = NPC.MoonLordAttacksArray[handAttackType, handType, 1, handFiveFrameTimer]; - if (handAttackTimerComparison + handAttackTimerIncrement > npc.ai[1]) + case 6: + divisor = 15; + break; + case 5: + divisor = 20; + break; + case 4: + break; + case 3: + divisor = 45; + break; + case 2: + divisor = 60; + break; + case 1: + divisor = 90; + break; + default: break; - - handAttackTimerIncrement += (int)handAttackTimerComparison; - int totalSpawns = handFiveFrameTimer; - handFiveFrameTimer = totalSpawns + 1; } - if (handFiveFrameTimer == 5) + // Spawn the phantasmal spheres + if (sphereHandSpeed % divisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) { - handFiveFrameTimer = 0; - npc.ai[1] = 0f; - handAttackTimerComparison = NPC.MoonLordAttacksArray[handAttackType, handType, 1, handFiveFrameTimer]; - handAttackTimerIncrement = 0; + int finalSphereHandSpeed = sphereHandSpeed / 30; + Vector2 sphereFireDirection = new Vector2(5f * handFaceDirection, finalSphereHandSpeed - 12.5f); + sphereFireDirection.X += (finalSphereHandSpeed - 3.5f) * handFaceDirection * 3f; + sphereFireDirection *= 1.2f; + + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, sphereFireDirection, ProjectileID.PhantasmalSphere, SphereDamage, 1f, Main.myPlayer, 0f, NPC.whoAmI); + Main.projectile[proj].timeLeft = 1200; } - npc.ai[0] = NPC.MoonLordAttacksArray[handAttackType, handType, 0, handFiveFrameTimer]; - handAttackTimer = (int)npc.ai[1] - handAttackTimerIncrement; - if (npc.ai[0] != handAI0CrossCheck) - npc.netUpdate = true; - } + // Set the hand's velocity for moving away from the body + Vector2 handSmoothMovement = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, (handAttackTimer - 30f) / 180f) - NPC.Center; + if (handSmoothMovement != Vector2.Zero) + { + Vector2 handSmoothMoveNormalize = handSmoothMovement; + handSmoothMoveNormalize.Normalize(); - if (npc.ai[0] == -2f) + float velocity = 24f; + switch (aggressionLevel) + { + case 6: + velocity += 4f; + break; + case 5: + velocity += 2f; + break; + case 4: + break; + case 3: + velocity -= 1f; + break; + case 2: + velocity -= 2f; + break; + case 1: + velocity -= 3f; + break; + default: + break; + } + + NPC.velocity = Vector2.Lerp(NPC.velocity, handSmoothMoveNormalize * Math.Min(velocity, handSmoothMovement.Length()), 0.5f); + } + } + // Slow the hand down at the end of the attack + else if (handAttackTimer < 282f) { handFrameCheck = 0; - - npc.dontTakeDamage = true; - - npc.velocity = Main.npc[(int)npc.ai[3]].velocity; + NPC.velocity *= velocityMultiplier; } - - // Move - else if (npc.ai[0] == 0f) + else if (handAttackTimer < 287f) + { + handFrameCheck = 1; + NPC.velocity *= velocityMultiplier; + } + else if (handAttackTimer < 292f) + { + handFrameCheck = 2; + NPC.velocity *= velocityMultiplier; + } + else if (handAttackTimer < 300f) { handFrameCheck = 3; - npc.localAI[1] -= 0.05f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - Vector2 handCenter = Main.npc[(int)npc.ai[3]].Center; - Vector2 handMovementVector = handCenter + new Vector2(350f * handFaceDirection, -100f); - Vector2 handMovementDirection = handMovementVector - npc.Center; - - if (handMovementDirection.Length() > 20f) + // Cause phantasmal spheres to start moving + if (handAttackTimer == 292f && Main.netMode != NetmodeID.MultiplayerClient) { - handMovementDirection.Normalize(); + // Determine the direction to make phantasmal spheres move + int closestPlayer = Player.FindClosest(NPC.position, NPC.width, NPC.height); + Vector2 sphereVelocity = Utils.SafeNormalize(Main.player[closestPlayer].Center - (NPC.Center + Vector2.UnitY * -350f), Vector2.UnitY); - float velocity = death ? 7.75f : 7.5f; + float velocity = 2f; switch (aggressionLevel) { case 6: @@ -1071,453 +1335,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 5: velocity += 1.5f; break; - case 4: - break; - case 3: - velocity -= 0.4f; - break; - case 2: - velocity -= 0.8f; - break; - case 1: - velocity -= 1.2f; - break; - default: - break; - } - - handMovementDirection *= velocity; - Vector2 handVelocity = npc.velocity; - - if (handMovementDirection != Vector2.Zero) - npc.SimpleFlyMovement(handMovementDirection, 0.3f); - - npc.velocity = Vector2.Lerp(handVelocity, npc.velocity, 0.5f); - } - } - - // Phantasmal Eyes - else if (npc.ai[0] == 1f) - { - handFrameCheck = 0; - float divisor = 6f; - switch (aggressionLevel) - { - case 6: - divisor = 3f; - break; - case 5: - divisor = 4f; - break; - case 4: - break; - case 3: - divisor = 8f; - break; - case 2: - divisor = 10f; - break; - case 1: - divisor = 12f; - break; - default: - break; - } - - if (handAttackTimer >= 56) - { - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - } - else if (handAttackTimer >= 28) - { - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 0.75f) - npc.localAI[1] = 0.75f; - - float handLocalAI = MathHelper.TwoPi * (handAttackTimer % 28) / 28 - MathHelper.PiOver2; - npc.localAI[0] = new Vector2((float)Math.Cos(handLocalAI) * handBehaviorVector.X, (float)Math.Sin(handLocalAI) * handBehaviorVector.Y).ToRotation(); - - if (handAttackTimer % divisor == 0f) - { - Vector2 handAttackVector = new Vector2(1f * -handFaceDirection, 3f); - Vector2 handAttackRotation = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), handBehaviorVector * npc.localAI[1]); - Vector2 handAttackMovement = npc.Center + Vector2.Normalize(handAttackRotation) * handBehaviorVector.Length() * 0.4f + handAttackVector; - - float velocity = death ? 3.5f : 3f; - switch (aggressionLevel) - { - case 6: - case 5: - case 4: - break; - case 3: - velocity += 0.5f; - break; - case 2: - velocity += 1f; - break; - case 1: - velocity += 1.5f; - break; - default: - break; - } - - Vector2 handAttackDirection = Vector2.Normalize(handAttackRotation) * velocity; - float ai = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * handFaceDirection; - int type = ProjectileID.PhantasmalEye; - int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), handAttackMovement, handAttackDirection, type, damage, 0f, Main.myPlayer, 0f, ai); - Main.projectile[proj].timeLeft = 1200; - Main.projectile[proj].Calamity().lineColor = bossRush ? 1 : aggressionLevel; - } - } - else - { - npc.localAI[1] += 0.02f; - if (npc.localAI[1] > 0.75f) - npc.localAI[1] = 0.75f; - - float handPauseDirection = MathHelper.TwoPi * (handAttackTimer % 28) / 28 - MathHelper.PiOver2; - npc.localAI[0] = new Vector2((float)Math.Cos(handPauseDirection) * handBehaviorVector.X, (float)Math.Sin(handPauseDirection) * handBehaviorVector.Y).ToRotation(); - } - } - - // Phantasmal Spheres - else if (npc.ai[0] == 2f) - { - npc.localAI[1] -= 0.05f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - - Vector2 handCenter = Main.npc[(int)npc.ai[3]].Center; - Vector2 sphereHandDirection = new Vector2(220f * handFaceDirection, -60f) + handCenter; - sphereHandDirection += new Vector2(handFaceDirection * 100f, -50f); - Vector2 sphereHandDirectionMaxBound = new Vector2(400f * handFaceDirection, -60f); - - float velocityMultiplier = death ? 0.88f : 0.885f; - switch (aggressionLevel) - { - case 6: - velocityMultiplier -= 0.04f; - break; - case 5: - velocityMultiplier -= 0.02f; - break; - case 4: - break; - case 3: - velocityMultiplier += 0.004f; - break; - case 2: - velocityMultiplier += 0.008f; - break; - case 1: - velocityMultiplier += 0.012f; - break; - default: - break; - } - - if (handAttackTimer < 30f) - { - Vector2 sphereHandTravelVelocity = sphereHandDirection - npc.Center; - if (sphereHandTravelVelocity != Vector2.Zero) - { - Vector2 sphereHandTravelDist = sphereHandTravelVelocity; - sphereHandTravelDist.Normalize(); - - float velocity = death ? 11f : 10f; - switch (aggressionLevel) - { - case 6: - velocity += 4f; - break; - case 5: - velocity += 2f; - break; - case 4: - break; - case 3: - velocity -= 0.5f; - break; - case 2: - velocity -= 1f; - break; - case 1: - velocity -= 1.5f; - break; - default: - break; - } - - npc.velocity = Vector2.SmoothStep(npc.velocity, sphereHandTravelDist * Math.Min(velocity, sphereHandTravelVelocity.Length()), 0.2f); - } - } - else if (handAttackTimer < 210f) - { - handFrameCheck = 1; - int sphereHandSpeed = (int)handAttackTimer - 30; - - int divisor = 30; - switch (aggressionLevel) - { - case 6: - divisor = 15; - break; - case 5: - divisor = 20; - break; - case 4: - break; - case 3: - divisor = 45; - break; - case 2: - divisor = 60; - break; - case 1: - divisor = 90; - break; - default: - break; - } - - if (sphereHandSpeed % divisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 sphereFireDirection = new Vector2(5f * handFaceDirection, -8f); - int finalSphereHandSpeed = sphereHandSpeed / 30; - sphereFireDirection.X += (finalSphereHandSpeed - 3.5f) * handFaceDirection * 3f; - sphereFireDirection.Y += (finalSphereHandSpeed - 4.5f) * 1f; - sphereFireDirection *= 1.2f; - int type = ProjectileID.PhantasmalSphere; - int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, sphereFireDirection.X, sphereFireDirection.Y, type, damage, 1f, Main.myPlayer, 0f, npc.whoAmI); - Main.projectile[proj].timeLeft = 1200; - } - - Vector2 handSmoothMovement = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, (handAttackTimer - 30f) / 180f) - npc.Center; - if (handSmoothMovement != Vector2.Zero) - { - Vector2 handSmoothMoveNormalize = handSmoothMovement; - handSmoothMoveNormalize.Normalize(); - - float velocity = death ? 26.5f : 24f; - switch (aggressionLevel) - { - case 6: - velocity += 4f; - break; - case 5: - velocity += 2f; - break; - case 4: - break; - case 3: - velocity -= 1f; - break; - case 2: - velocity -= 2f; - break; - case 1: - velocity -= 3f; - break; - default: - break; - } - - npc.velocity = Vector2.Lerp(npc.velocity, handSmoothMoveNormalize * Math.Min(velocity, handSmoothMovement.Length()), 0.5f); - } - } - else if (handAttackTimer < 282f) - { - handFrameCheck = 0; - npc.velocity *= velocityMultiplier; - } - else if (handAttackTimer < 287f) - { - handFrameCheck = 1; - npc.velocity *= velocityMultiplier; - } - else if (handAttackTimer < 292f) - { - handFrameCheck = 2; - npc.velocity *= velocityMultiplier; - } - else if (handAttackTimer < 300f) - { - handFrameCheck = 3; - - if (handAttackTimer == 292f && Main.netMode != NetmodeID.MultiplayerClient) - { - int closestPlayer = Player.FindClosest(npc.position, npc.width, npc.height); - Vector2 sphereVelocity = Vector2.Normalize(Main.player[closestPlayer].Center - (npc.Center + Vector2.UnitY * -350f)); - if (float.IsNaN(sphereVelocity.X) || float.IsNaN(sphereVelocity.Y)) - sphereVelocity = Vector2.UnitY; - - float velocity = death ? 2.2f : 2f; - switch (aggressionLevel) - { - case 6: - velocity += 3f; - break; - case 5: - velocity += 1.5f; - break; - case 4: - break; - case 3: - velocity -= 0.25f; - break; - case 2: - velocity -= 0.5f; - break; - case 1: - velocity -= 0.75f; - break; - default: - break; - } - - sphereVelocity *= velocity; - foreach (Projectile currentProjectile in Main.ActiveProjectiles) - { - if (currentProjectile.type == ProjectileID.PhantasmalSphere && currentProjectile.ai[1] == npc.whoAmI && currentProjectile.ai[0] != -1f) - { - currentProjectile.ai[0] = -1f; - currentProjectile.velocity = sphereVelocity; - currentProjectile.netUpdate = true; - } - } - } - - Vector2 handPauseSmoothSpeed = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, 1f - (handAttackTimer - 270f) / 30f) - npc.Center; - if (handPauseSmoothSpeed != Vector2.Zero) - { - Vector2 handPauseDirection = handPauseSmoothSpeed; - handPauseDirection.Normalize(); - - float velocity = death ? 19.75f : 17.5f; - switch (aggressionLevel) - { - case 6: - velocity += 4f; - break; - case 5: - velocity += 2f; - break; - case 4: - break; - case 3: - velocity -= 1f; - break; - case 2: - velocity -= 2f; - break; - case 1: - velocity -= 3f; - break; - default: - break; - } - - npc.velocity = Vector2.Lerp(npc.velocity, handPauseDirection * Math.Min(velocity, handPauseSmoothSpeed.Length()), 0.1f); - } - } - else - { - handFrameCheck = 3; - - Vector2 handReturnSmoothSpeed = sphereHandDirection - npc.Center; - if (handReturnSmoothSpeed != Vector2.Zero) - { - Vector2 handReturnDirection = handReturnSmoothSpeed; - handReturnDirection.Normalize(); - - float velocity = death ? 11f : 10f; - switch (aggressionLevel) - { - case 6: - velocity += 4f; - break; - case 5: - velocity += 2f; - break; - case 4: - break; - case 3: - velocity -= 0.5f; - break; - case 2: - velocity -= 1f; - break; - case 1: - velocity -= 1.5f; - break; - default: - break; - } - - npc.velocity = Vector2.SmoothStep(npc.velocity, handReturnDirection * Math.Min(velocity, handReturnSmoothSpeed.Length()), 0.2f); - } - } - } - - // Phantasmal Bolts - else if (npc.ai[0] == 3f) - { - if (handAttackTimer == 0f) - { - npc.TargetClosest(false); - npc.netUpdate = true; - } - - Vector2 v = Main.player[npc.target].Center - npc.Center; - bool shootFirstBolt = handAttackTimer == handAttackTimerComparison - 14f; - bool shootSecondBolt = handAttackTimer == handAttackTimerComparison - 7f; - bool shootThirdBolt = handAttackTimer == handAttackTimerComparison; - switch (aggressionLevel) - { - case 6: - v = Main.player[npc.target].Center + Main.player[npc.target].velocity * 30f - npc.Center; - break; - case 5: - v = Main.player[npc.target].Center + Main.player[npc.target].velocity * 20f - npc.Center; - break; - case 4: - break; - case 3: - case 2: - shootSecondBolt = false; - break; - case 1: - shootSecondBolt = false; - shootThirdBolt = false; - break; - default: - break; - } - - npc.localAI[0] = npc.localAI[0].AngleLerp(v.ToRotation(), 0.5f); - - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 1f) - npc.localAI[1] = 1f; - - if (handAttackTimer == handAttackTimerComparison - 35f) - SoundEngine.PlaySound(SoundID.NPCDeath6, npc.Center); - - if ((shootFirstBolt || shootSecondBolt || shootThirdBolt) && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 boltShootDirection = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), handBehaviorVector * npc.localAI[1]); - - float velocity = death ? 6.75f : 6.25f; - switch (aggressionLevel) - { - case 6: - case 5: case 4: break; case 3: @@ -1533,714 +1350,860 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - Vector2 boltShootSpeed = Vector2.Normalize(v) * velocity; - int type = ProjectileID.PhantasmalBolt; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + boltShootDirection.X, npc.Center.Y + boltShootDirection.Y, boltShootSpeed.X, boltShootSpeed.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - - // Center - Vector2 handCentering = Main.npc[(int)npc.ai[3]].Center; - Vector2 handDirection = new Vector2(220f * handFaceDirection, -60f) + handCentering; - Vector2 minHandFaceDirection = handDirection + new Vector2(handFaceDirection * 110f, -150f); - Vector2 maxHandFaceDirection = minHandFaceDirection + new Vector2(handFaceDirection * 370f, 150f); - - if (minHandFaceDirection.X > maxHandFaceDirection.X) - Utils.Swap(ref minHandFaceDirection.X, ref maxHandFaceDirection.X); - if (minHandFaceDirection.Y > maxHandFaceDirection.Y) - Utils.Swap(ref minHandFaceDirection.Y, ref maxHandFaceDirection.Y); - - Vector2 handVelocity2 = Vector2.Clamp(npc.Center + npc.velocity, minHandFaceDirection, maxHandFaceDirection); - if (handVelocity2 != npc.Center + npc.velocity) - npc.Center = handVelocity2 - npc.velocity; - - // Frames - int handFrameTimer = handFrameCheck * 7; - if (handFrameTimer > npc.frameCounter) - { - double handFrameControl = npc.frameCounter; - npc.frameCounter = handFrameControl + 1.0; - } - if (handFrameTimer < npc.frameCounter) - { - double handFrameControl = npc.frameCounter; - npc.frameCounter = handFrameControl - 1.0; - } - - if (npc.frameCounter < 0.0) - npc.frameCounter = 0.0; - if (npc.frameCounter > 21.0) - npc.frameCounter = 21.0; - } - else if (npc.type == NPCID.MoonLordFreeEye) - { - if (Main.npc[(int)npc.ai[3]].ai[0] == 2f) - { - npc.HitEffect(0, 9999.0); - npc.active = false; - } - - if (calamityGlobalNPC.newAI[0] == 0f) - { - int eyeCount = NPC.CountNPCS(npc.type); - if (eyeCount > 1) - { - int eyesSynced = 1; - foreach (NPC n in Main.ActiveNPCs) + sphereVelocity *= velocity; + foreach (Projectile sp in Main.ActiveProjectiles) { - if (n.whoAmI != npc.whoAmI && n.type == npc.type) + if (sp.type == ProjectileID.PhantasmalSphere && sp.ai[1] == NPC.whoAmI && sp.ai[0] != -1f) { - 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; + sp.ai[0] = -1f; + sp.velocity = sphereVelocity; + sp.netUpdate = true; } } } - else - calamityGlobalNPC.newAI[0] = 1f; - } - if (Main.rand.NextBool(420)) - SoundEngine.PlaySound(Main.rand.NextBool() ? SoundID.Zombie100 : SoundID.Zombie101, npc.Center); - - Vector2 thirtyVector = new Vector2(30f); - - if (!Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != NPCID.MoonLordCore) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - } - - float secondAttackPicker = 0f; - float ai0Copy = npc.ai[0]; - - npc.ai[1] += 1f; - - int secondAttackArrayInc = 0; - int secondAttackPickerInc = 0; - while (secondAttackArrayInc < 10) - { - secondAttackPicker = NPC.MoonLordAttacksArray2[1, secondAttackArrayInc]; - if (secondAttackPicker + secondAttackPickerInc > npc.ai[1]) - break; - - secondAttackPickerInc += (int)secondAttackPicker; - secondAttackArrayInc += 1; - } - - if (secondAttackArrayInc == 10) - { - secondAttackArrayInc = 0; - npc.ai[1] = 0f; - secondAttackPicker = NPC.MoonLordAttacksArray2[1, secondAttackArrayInc]; - secondAttackPickerInc = 0; - } - - npc.ai[0] = NPC.MoonLordAttacksArray2[0, secondAttackArrayInc]; - float secondAttackTimer = (int)npc.ai[1] - secondAttackPickerInc; - - if (npc.ai[0] != ai0Copy) - npc.netUpdate = true; - - if (npc.ai[0] == -1f) - { - npc.ai[1] += 1f; - if (npc.ai[1] > 180f) - npc.ai[1] = 0f; - - float localAI2Lerp; - if (npc.ai[1] < 60f) + Vector2 handPauseSmoothSpeed = Vector2.SmoothStep(sphereHandDirection, sphereHandDirection + sphereHandDirectionMaxBound, 1f - (handAttackTimer - 270f) / 30f) - NPC.Center; + if (handPauseSmoothSpeed != Vector2.Zero) { - localAI2Lerp = 0.75f; + Vector2 handPauseDirection = handPauseSmoothSpeed; + handPauseDirection.Normalize(); - npc.localAI[0] = 0f; - - npc.localAI[1] = (float)Math.Sin(npc.ai[1] * MathHelper.TwoPi / 15f) * 0.35f; - if (npc.localAI[1] < 0f) - npc.localAI[0] = MathHelper.Pi; - } - else if (npc.ai[1] < 120f) - { - localAI2Lerp = 1f; - - if (npc.localAI[1] < 0.5f) - npc.localAI[1] += 0.025f; - - npc.localAI[0] += 0.209439516f; - } - else - { - localAI2Lerp = 1.15f; - - npc.localAI[1] -= 0.05f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - } - - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], localAI2Lerp, 0.3f); - } - - if (npc.ai[0] == 0f) - { - npc.TargetClosest(false); - - Vector2 v7 = Main.player[npc.target].Center - npc.Center; - - npc.localAI[0] = npc.localAI[0].AngleLerp(v7.ToRotation(), 0.5f); - - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 0.7f) - npc.localAI[1] = 0.7f; - - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); - - float velocity = death ? 38f : 36f; - Vector2 freeEyeCenter = npc.Center; - Vector2 freeEyeTargetCenter = Main.player[npc.target].Center; - Vector2 freeEyeTargetDistance = freeEyeTargetCenter - freeEyeCenter; - freeEyeTargetDistance = Vector2.Normalize(freeEyeTargetDistance) * velocity; - - if (Vector2.Distance(freeEyeCenter, freeEyeTargetCenter) > 300f) - { - npc.velocity.X = (npc.velocity.X * 29 + freeEyeTargetDistance.X) / 30; - npc.velocity.Y = (npc.velocity.Y * 29 + freeEyeTargetDistance.Y) / 30; - } - else - { - npc.velocity *= 0.8f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; - } - - // Fly towards Moon Lord Head and stay away from other True Eyes - float freeEyeAccel = 0.5f; - foreach (NPC n in Main.ActiveNPCs) - { - if (n.whoAmI != npc.whoAmI && n.type == npc.type) + float velocity = 17.5f; + switch (aggressionLevel) { - if (Vector2.Distance(npc.Center, n.Center) < 150f) - { - 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; - } - } - } - return false; - } - - if (npc.ai[0] == 1f) - { - if (secondAttackTimer == 0f) - { - npc.TargetClosest(false); - npc.netUpdate = true; - } - - npc.velocity *= 0.95f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; - - Vector2 v8 = Main.player[npc.target].Center - npc.Center; - - npc.localAI[0] = npc.localAI[0].AngleLerp(v8.ToRotation(), 0.5f); - - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 1f) - npc.localAI[1] = 1f; - - if (secondAttackTimer < 20f) - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1.1f, 0.2f); - else - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 0.4f, 0.2f); - - if (secondAttackTimer == secondAttackPicker - 35f) - SoundEngine.PlaySound(SoundID.NPCDeath6, npc.Center); - - if ((secondAttackTimer == secondAttackPicker - 14f || secondAttackTimer == secondAttackPicker - 7f || secondAttackTimer == secondAttackPicker) && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 freeEyeBoltDirection = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), thirtyVector * npc.localAI[1]); - float velocity = death ? 9f : 8f; - Vector2 freeEyeBoltVel = Vector2.Normalize(v8) * velocity; - int type = ProjectileID.PhantasmalBolt; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + freeEyeBoltDirection.X, npc.Center.Y + freeEyeBoltDirection.Y, freeEyeBoltVel.X, freeEyeBoltVel.Y, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - else if (npc.ai[0] == 2f || npc.ai[0] == 4f) - { - int type = ProjectileID.PhantasmalSphere; - int damage = npc.GetProjectileDamage(type); - - if (secondAttackTimer < 15f) - { - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 0.4f, 0.2f); - - npc.velocity *= 0.8f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; - } - else if (secondAttackTimer < 75f) - { - float freeEyeAttackPattern = (secondAttackTimer - 15f) / 10f; - int freeEyeRotateValue = 0; - int freeEyeRotateValue2 = 0; - switch ((int)freeEyeAttackPattern) - { - case 0: - freeEyeRotateValue = 0; - freeEyeRotateValue2 = 2; - break; - case 1: - freeEyeRotateValue = 2; - freeEyeRotateValue2 = 5; - break; - case 2: - freeEyeRotateValue = 5; - freeEyeRotateValue2 = 3; - break; - case 3: - freeEyeRotateValue = 3; - freeEyeRotateValue2 = 1; - break; - case 4: - freeEyeRotateValue = 1; - freeEyeRotateValue2 = 4; + case 6: + velocity += 4f; break; case 5: - freeEyeRotateValue = 4; - freeEyeRotateValue2 = 0; + velocity += 2f; + break; + case 4: + break; + case 3: + velocity -= 1f; + break; + case 2: + velocity -= 2f; + break; + case 1: + velocity -= 3f; + break; + default: break; } - Vector2 spinningpoint2 = Vector2.UnitY * -30f; - Vector2 freeEyeRotateLerpValue = spinningpoint2.RotatedBy(freeEyeRotateValue * MathHelper.TwoPi / 6f); - Vector2 freeEyeRotateLerpValue2 = spinningpoint2.RotatedBy(freeEyeRotateValue2 * MathHelper.TwoPi / 6f); - Vector2 freeEyeRotation = Vector2.Lerp(freeEyeRotateLerpValue, freeEyeRotateLerpValue2, freeEyeAttackPattern - (int)freeEyeAttackPattern); - float freeEyeRotationDist = freeEyeRotation.Length() / 30f; - - npc.localAI[0] = freeEyeRotation.ToRotation(); - npc.localAI[1] = MathHelper.Lerp(npc.localAI[1], freeEyeRotationDist, 0.5f); - - for (int k = 0; k < 2; k++) - { - int trueEyeDust = Dust.NewDust(npc.Center + freeEyeRotation - Vector2.One * 4f, 0, 0, DustID.Vortex, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[trueEyeDust]; - dust.velocity += freeEyeRotation / 15f; - Main.dust[trueEyeDust].noGravity = true; - } - - if ((secondAttackTimer - 15f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 trueEyeSphereDirection = Vector2.Normalize(freeEyeRotation); - if (trueEyeSphereDirection.HasNaNs()) - trueEyeSphereDirection = Vector2.UnitY * -1f; - - float spreadVelocity = death ? 4.5f : 4f; - trueEyeSphereDirection *= 4f; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + freeEyeRotation.X, npc.Center.Y + freeEyeRotation.Y, trueEyeSphereDirection.X, trueEyeSphereDirection.Y, type, 0, 0f, Main.myPlayer, 30f, npc.whoAmI); - Main.projectile[proj].timeLeft = 1200; - - if (CalamityWorld.LegendaryMode) - { - for (int k = 0; k < 3; k++) - { - if (!WorldGen.SolidTile((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f))) - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, (float)Main.rand.Next(-1599, 1600) * 0.01f, (float)Main.rand.Next(-1599, 1) * 0.01f, ProjectileID.MoonBoulder, 70, 10f); - } - } - } - } - else - { - if (secondAttackTimer < 105f) - { - npc.localAI[0] = npc.localAI[0].AngleLerp(npc.ai[2] - MathHelper.PiOver2, 0.2f); - - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 0.75f, 0.2f); - - if (secondAttackTimer == 75f) - { - npc.TargetClosest(false); - - npc.netUpdate = true; - - npc.velocity = Vector2.UnitY * -7f; - - foreach (Projectile trueEyeSpheres in Main.ActiveProjectiles) - { - if (trueEyeSpheres.type == type && trueEyeSpheres.ai[1] == npc.whoAmI && trueEyeSpheres.ai[0] != -1f) - { - trueEyeSpheres.velocity += npc.velocity; - trueEyeSpheres.netUpdate = true; - } - } - } - - npc.velocity.Y = npc.velocity.Y * 0.96f; - - npc.ai[2] = (Main.player[npc.target].Center - npc.Center).ToRotation() + MathHelper.PiOver2; - - npc.rotation = npc.rotation.AngleTowards(npc.ai[2], MathHelper.Pi / 30f); - - return false; - } - - if (secondAttackTimer < 120f) - { - SoundEngine.PlaySound(SoundID.Zombie102, npc.Center); - - if (secondAttackTimer == 105f) - npc.netUpdate = true; - - float velocity = death ? 13.25f : 12f; - Vector2 trueEyeSphereVelocity = (npc.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; - npc.velocity = trueEyeSphereVelocity * 2f; - - foreach (Projectile trueEyeSphereProj in Main.ActiveProjectiles) - { - if (trueEyeSphereProj.type == type && trueEyeSphereProj.ai[1] == npc.whoAmI && trueEyeSphereProj.ai[0] != -1f) - { - trueEyeSphereProj.ai[0] = -1f; - trueEyeSphereProj.damage = damage; - trueEyeSphereProj.velocity = trueEyeSphereVelocity; - trueEyeSphereProj.netUpdate = true; - } - } - - return false; - } - - npc.velocity *= 0.92f; - npc.rotation = npc.rotation.AngleLerp(0f, 0.2f); + NPC.velocity = Vector2.Lerp(NPC.velocity, handPauseDirection * Math.Min(velocity, handPauseSmoothSpeed.Length()), 0.1f); } } - else if (npc.ai[0] == 3f) + else { - if (secondAttackTimer < 15f) - { - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; + handFrameCheck = 3; - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 0.4f, 0.2f); - - npc.velocity *= 0.9f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; - } - else if (secondAttackTimer < 45f) + // Make the hand return back to being close to the body + Vector2 handReturnSmoothSpeed = sphereHandDirection - NPC.Center; + if (handReturnSmoothSpeed != Vector2.Zero) { - npc.localAI[0] = 0f; + Vector2 handReturnDirection = handReturnSmoothSpeed; + handReturnDirection.Normalize(); - npc.localAI[1] = (float)Math.Sin((secondAttackTimer - 15f) * MathHelper.TwoPi / 15f) * 0.5f; - if (npc.localAI[1] < 0f) - npc.localAI[0] = MathHelper.Pi; - } - else - { - if (secondAttackTimer >= 185f) + float velocity = 10f; + switch (aggressionLevel) { - npc.velocity *= 0.88f; - - npc.rotation = npc.rotation.AngleLerp(0f, 0.2f); - - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); - return false; + case 6: + velocity += 4f; + break; + case 5: + velocity += 2f; + break; + case 4: + break; + case 3: + velocity -= 0.5f; + break; + case 2: + velocity -= 1f; + break; + case 1: + velocity -= 1.5f; + break; + default: + break; } - if (secondAttackTimer == 45f) - { - npc.ai[2] = Main.rand.NextBool().ToDirectionInt() * MathHelper.TwoPi / 40f; - npc.netUpdate = true; - } - - if ((secondAttackTimer - 15f - 30f) % 40f == 0f) - npc.ai[2] *= 0.95f; - - npc.localAI[0] += npc.ai[2]; - - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 1f) - npc.localAI[1] = 1f; - - Vector2 trueEyeDirection = npc.localAI[0].ToRotationVector2() * thirtyVector * npc.localAI[1]; - float trueEyeVelScale = MathHelper.Lerp(8f, 20f, (secondAttackTimer - 15f - 30f) / 140f); - - npc.velocity = Vector2.Normalize(trueEyeDirection) * trueEyeVelScale; - npc.rotation = npc.rotation.AngleLerp(npc.velocity.ToRotation() + MathHelper.PiOver2, 0.2f); - - if ((secondAttackTimer - 15f - 30f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 trueEyeEyeDirection = npc.Center + Vector2.Normalize(trueEyeDirection) * thirtyVector.Length() * 0.4f; - float velocity = death ? 6f : 5f; - Vector2 trueEyeEyeSpeed = Vector2.Normalize(trueEyeDirection) * velocity; - float ai3 = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * npc.ai[2]; - int type = ProjectileID.PhantasmalEye; - int damage = npc.GetProjectileDamage(type); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), trueEyeEyeDirection, trueEyeEyeSpeed, type, damage, 0f, Main.myPlayer, 0f, ai3); - Main.projectile[proj].timeLeft = 1200; - } - } - } - else if (npc.ai[0] == 4f) - { - if (secondAttackTimer == 0f) - { - npc.TargetClosest(false); - npc.netUpdate = true; - } - - if (secondAttackTimer < 180f) - { - npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); - - npc.localAI[1] -= 0.05f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; - - npc.velocity *= 0.95f; - if (npc.velocity.Length() < 1f) - npc.velocity = Vector2.Zero; - - if (secondAttackTimer >= 60f) - { - Vector2 trueEyeCentering = npc.Center; - - int dustAmt = 0; - if (secondAttackTimer >= 120f) - dustAmt = 1; - - for (int j = 0; j < 1 + dustAmt; j++) - { - float dustScale = 0.8f; - if (j % 2 == 1) - dustScale = 1.65f; - - Vector2 trueEyeDustDirection = trueEyeCentering + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * thirtyVector / 2f; - int trueEyeDust = Dust.NewDust(trueEyeDustDirection - Vector2.One * 8f, 16, 16, DustID.Vortex, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, default, 1f); - Main.dust[trueEyeDust].velocity = Vector2.Normalize(trueEyeCentering - trueEyeDustDirection) * 3.5f * (10f - dustAmt * 2f) / 10f; - Main.dust[trueEyeDust].noGravity = true; - Main.dust[trueEyeDust].scale = dustScale; - Main.dust[trueEyeDust].customData = npc; - } - } - } - else - { - if (secondAttackTimer < secondAttackPicker - 15f) - { - if (calamityGlobalNPC.newAI[1] == 0f) - calamityGlobalNPC.newAI[1] = 600f; - - if (secondAttackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) - { - // If head is in deathray phase - if (Main.npc[(int)Main.npc[(int)npc.ai[3]].localAI[2]].ai[0] == 1f) - calamityGlobalNPC.newAI[1] *= 1.5f; - - npc.TargetClosest(false); - - Vector2 deathrayTargetDist = Main.player[npc.target].Center - npc.Center; - deathrayTargetDist.Normalize(); - - float deathraySweepDirection = -1f; - if (deathrayTargetDist.X < 0f) - deathraySweepDirection = 1f; - - deathrayTargetDist = deathrayTargetDist.RotatedBy(-(double)deathraySweepDirection * MathHelper.TwoPi / 6f); - int type = ProjectileID.PhantasmalDeathray; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, deathrayTargetDist.X, deathrayTargetDist.Y, type, damage, 0f, Main.myPlayer, deathraySweepDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], npc.whoAmI); - npc.ai[2] = (deathrayTargetDist.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * deathraySweepDirection; - npc.netUpdate = true; - } - - npc.localAI[1] += 0.05f; - if (npc.localAI[1] > 1f) - npc.localAI[1] = 1f; - - float deathrayRotationDirection = (npc.ai[2] >= 0f).ToDirectionInt(); - float deathrayRotation = npc.ai[2]; - if (deathrayRotation < 0f) - deathrayRotation *= -1f; - - deathrayRotation += -(MathHelper.Pi + MathHelper.TwoPi); - deathrayRotation += deathrayRotationDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1]; - - npc.localAI[0] = deathrayRotation; - npc.ai[2] = (deathrayRotation + MathHelper.Pi + MathHelper.TwoPi) * deathrayRotationDirection; - - return false; - } - - calamityGlobalNPC.newAI[1] = 0f; - - npc.localAI[1] -= 0.07f; - if (npc.localAI[1] < 0f) - npc.localAI[1] = 0f; + NPC.velocity = Vector2.SmoothStep(NPC.velocity, handReturnDirection * Math.Min(velocity, handReturnSmoothSpeed.Length()), 0.2f); } } } - else if (npc.type == NPCID.MoonLordLeechBlob) + + // Phantasmal Bolts + else if (NPC.ai[0] == 3f) { - // Variables - Vector2 mouthMovement = new Vector2(0f, 216f); - int headNPCType = (int)Math.Abs(npc.ai[0]) - 1; - int moonLordHead = (int)npc.ai[1]; - - // Despawn - if (!Main.npc[headNPCType].active || Main.npc[headNPCType].type != NPCID.MoonLordHead) + if (handAttackTimer == 0f) { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - return false; + NPC.TargetClosest(false); + NPC.netUpdate = true; } - // Heal the Moon Lord - npc.ai[2] += 1f; - if (npc.ai[2] >= 180f) + Vector2 aimDirection = Main.player[NPC.target].Center - NPC.Center; + bool shootFirstBolt = handAttackTimer == phaseAttackTime - 14f; + bool shootSecondBolt = handAttackTimer == phaseAttackTime - 7f; + bool shootThirdBolt = handAttackTimer == phaseAttackTime; + switch (aggressionLevel) { - if (Main.netMode != NetmodeID.MultiplayerClient) + // Higher aggression gives the phantasmal bolts predictive aim + case 6: + aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 30f - NPC.Center; + break; + case 5: + aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f - NPC.Center; + break; + case 4: + break; + // Lower aggression fires less phantasmal bolts + case 3: + case 2: + shootSecondBolt = false; + break; + case 1: + shootSecondBolt = false; + shootThirdBolt = false; + break; + default: + break; + } + + // localAI[0] and localAI[1] are again used to control where the eye's pupil draws + NPC.localAI[0] = NPC.localAI[0].AngleLerp(aimDirection.ToRotation(), 0.5f); + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 1f) + NPC.localAI[1] = 1f; + + if (handAttackTimer == phaseAttackTime - 35f) + SoundEngine.PlaySound(SoundID.NPCDeath6, NPC.Center); + + // Fire the phantasmal bolts + if ((shootFirstBolt || shootSecondBolt || shootThirdBolt) && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 boltShootDirection = Utils.Vector2FromElipse(NPC.localAI[0].ToRotationVector2(), eyeSizeVector * NPC.localAI[1]); + + float velocity = 6.25f; + switch (aggressionLevel) { - int k = (int)Main.npc[headNPCType].ai[3]; - int leftHandHeal = -1; - int rightHandHeal = -1; - int headHeal = headNPCType; + case 6: + case 5: + case 4: + break; + // Lower aggression reduces the speed of phantasmal bolts + case 3: + velocity -= 0.25f; + break; + case 2: + velocity -= 0.5f; + break; + case 1: + velocity -= 0.75f; + break; + default: + break; + } - foreach (NPC n in Main.ActiveNPCs) + Vector2 boltShootSpeed = Vector2.Normalize(aimDirection) * velocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + boltShootDirection, boltShootSpeed, ProjectileID.PhantasmalBolt, BoltDamage, 0f, Main.myPlayer); + } + } + + // Movement of hands when not attacking + Vector2 handDirection = coreCenter + new Vector2(220f * handFaceDirection, -60f); + Vector2 minHandFaceDirection = handDirection + new Vector2(handFaceDirection * 110f, -150f); + Vector2 maxHandFaceDirection = minHandFaceDirection + new Vector2(handFaceDirection * 370f, 150f); + + if (minHandFaceDirection.X > maxHandFaceDirection.X) + Utils.Swap(ref minHandFaceDirection.X, ref maxHandFaceDirection.X); + if (minHandFaceDirection.Y > maxHandFaceDirection.Y) + Utils.Swap(ref minHandFaceDirection.Y, ref maxHandFaceDirection.Y); + + Vector2 defaultHandVelocity = Vector2.Clamp(NPC.Center + NPC.velocity, minHandFaceDirection, maxHandFaceDirection); + if (defaultHandVelocity != NPC.Center + NPC.velocity) + NPC.Center = defaultHandVelocity - NPC.velocity; + + // Frame control, also controls when the hands are immune to damage + int handFrameTimer = handFrameCheck * 7; + if (handFrameTimer > NPC.frameCounter) + { + double handFrameControl = NPC.frameCounter; + NPC.frameCounter = handFrameControl + 1.0; + } + if (handFrameTimer < NPC.frameCounter) + { + double handFrameControl = NPC.frameCounter; + NPC.frameCounter = handFrameControl - 1.0; + } + + if (NPC.frameCounter < 0.0) + NPC.frameCounter = 0.0; + if (NPC.frameCounter > 21.0) + NPC.frameCounter = 21.0; + } + + public void BuffedTrueEyeAI() + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Despawn if the main boss is dying. + if (Main.npc[(int)NPC.ai[3]].ai[0] == 2f) + { + NPC.HitEffect(0, 9999.0); + NPC.active = false; + } + + // Sync up the behavior of True Eyes. + if (calamityGlobalNPC.newAI[0] == 0f) + { + int eyeCount = NPC.CountNPCS(NPC.type); + if (eyeCount > 1) + { + int eyesSynced = 1; + foreach (NPC n in Main.ActiveNPCs) + { + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) { - if (n.ai[3] == k) + 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; + } + } + } + else + calamityGlobalNPC.newAI[0] = 1f; + } + + if (Main.rand.NextBool(420)) + SoundEngine.PlaySound(Main.rand.NextBool() ? SoundID.Zombie100 : SoundID.Zombie101, NPC.Center); + + // Despawn if the main boss despawned. + if (!Main.npc[(int)NPC.ai[3]].active || Main.npc[(int)NPC.ai[3]].type != NPCID.MoonLordCore) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + + // Set up attacks + Vector2 eyeSizeVector = new Vector2(30f); + float phaseAttackTime = 0f; + float ai0CrossCheck = NPC.ai[0]; + NPC.ai[1] += 1f; + + // True Eyes of Cthulhu use a separate attack array from Moon Lord which, thankfully, is only a 2D array. It is organized as follows: + // The first value holds what is actually passed to the AI. 0 contains the value for ai[0], and 1 contains the attack duration in frames, used for ai[1] comparison. + // The second value is what number attack it is in the pattern, from 0-9. + int attackIncrement = 0; + int totalAttackTimer = 0; + while (attackIncrement < 10) + { + phaseAttackTime = NPC.MoonLordAttacksArray2[1, attackIncrement]; + if (phaseAttackTime + totalAttackTimer > NPC.ai[1]) + break; + + totalAttackTimer += (int)phaseAttackTime; + attackIncrement += 1; + } + + if (attackIncrement == 10) + { + attackIncrement = 0; + NPC.ai[1] = 0f; + phaseAttackTime = NPC.MoonLordAttacksArray2[1, attackIncrement]; + totalAttackTimer = 0; + } + + NPC.ai[0] = NPC.MoonLordAttacksArray2[0, attackIncrement]; + float secondAttackTimer = (int)NPC.ai[1] - totalAttackTimer; + + if (NPC.ai[0] != ai0CrossCheck) + NPC.netUpdate = true; + + // Completely unused state as far as I can tell. + if (NPC.ai[0] == -1f) + { + NPC.ai[1] += 1f; + if (NPC.ai[1] > 180f) + NPC.ai[1] = 0f; + + float localAI2Lerp; + if (NPC.ai[1] < 60f) + { + localAI2Lerp = 0.75f; + + NPC.localAI[0] = 0f; + + NPC.localAI[1] = (float)Math.Sin(NPC.ai[1] * MathHelper.TwoPi / 15f) * 0.35f; + if (NPC.localAI[1] < 0f) + NPC.localAI[0] = MathHelper.Pi; + } + else if (NPC.ai[1] < 120f) + { + localAI2Lerp = 1f; + + if (NPC.localAI[1] < 0.5f) + NPC.localAI[1] += 0.025f; + + NPC.localAI[0] += 0.209439516f; + } + else + { + localAI2Lerp = 1.15f; + + NPC.localAI[1] -= 0.05f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + } + + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], localAI2Lerp, 0.3f); + } + + // Move towards the target. + if (NPC.ai[0] == 0f) + { + NPC.TargetClosest(false); + + Vector2 v7 = Main.player[NPC.target].Center - NPC.Center; + + // localAI[0] controls the angle in which the eye looks. + // localAI[1] controls how close to the edge the pupil draws. + NPC.localAI[0] = NPC.localAI[0].AngleLerp(v7.ToRotation(), 0.5f); + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 0.7f) + NPC.localAI[1] = 0.7f; + // localAI[2] controls the size of the pupil, such as when it gets smaller while firing phantasmal bolts. + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 1f, 0.2f); + + // Actual movement. + float velocity = 36f; + Vector2 freeEyeTargetCenter = Main.player[NPC.target].Center; + Vector2 freeEyeTargetDistance = Utils.SafeNormalize(freeEyeTargetCenter - NPC.Center, Vector2.Zero) * velocity; + + if (Vector2.Distance(NPC.Center, freeEyeTargetCenter) > 300f) + { + NPC.velocity.X = (NPC.velocity.X * 29 + freeEyeTargetDistance.X) / 30; + NPC.velocity.Y = (NPC.velocity.Y * 29 + freeEyeTargetDistance.Y) / 30; + } + else + { + NPC.velocity *= 0.8f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; + } + + // Push away from other True Eyes. + float freeEyeAccel = 0.5f; + foreach (NPC n in Main.ActiveNPCs) + { + if (n.whoAmI != NPC.whoAmI && n.type == NPC.type) + { + if (Vector2.Distance(NPC.Center, n.Center) < 150f) + { + if (NPC.position.X < n.position.X) + NPC.velocity.X -= freeEyeAccel; + else + NPC.velocity.X += freeEyeAccel; + + if (NPC.position.Y < n.position.Y) + NPC.velocity.Y -= freeEyeAccel; + else + NPC.velocity.Y += freeEyeAccel; + } + } + } + return; + } + + // Phantasmal bolts. + if (NPC.ai[0] == 1f) + { + if (secondAttackTimer == 0f) + { + NPC.TargetClosest(false); + NPC.netUpdate = true; + } + + // Slow down before firing. + NPC.velocity *= 0.95f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; + + Vector2 aimDirection = Main.player[NPC.target].Center - NPC.Center; + + NPC.localAI[0] = NPC.localAI[0].AngleLerp(aimDirection.ToRotation(), 0.5f); + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 1f) + NPC.localAI[1] = 1f; + + if (secondAttackTimer < 20f) + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 1.1f, 0.2f); + else + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 0.4f, 0.2f); + + if (secondAttackTimer == phaseAttackTime - 35f) + SoundEngine.PlaySound(SoundID.NPCDeath6, NPC.Center); + + // Fire the phantasmal bolts. + if ((secondAttackTimer == phaseAttackTime - 14f || secondAttackTimer == phaseAttackTime - 7f || secondAttackTimer == phaseAttackTime) && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 freeEyeBoltDirection = Utils.Vector2FromElipse(NPC.localAI[0].ToRotationVector2(), eyeSizeVector * NPC.localAI[1]); + float velocity = 8f; + Vector2 freeEyeBoltVel = Vector2.Normalize(aimDirection) * velocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + freeEyeBoltDirection, freeEyeBoltVel, ProjectileID.PhantasmalBolt, TrueEyeBoltDamage, 0f, Main.myPlayer); + } + } + // Phantasmal spheres. This also covers an ai[0] of 4, which is normally the phantasmal deathray in vanilla. + else if (NPC.ai[0] == 2f || NPC.ai[0] == 4f) + { + int type = ProjectileID.PhantasmalSphere; + + // Slow down before attacking. + if (secondAttackTimer < 15f) + { + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 0.4f, 0.2f); + + NPC.velocity *= 0.8f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; + } + // Start spawning the phantasmal spheres around the eye in a hexagon. + else if (secondAttackTimer < 75f) + { + float freeEyeAttackPattern = (secondAttackTimer - 15f) / 10f; + int freeEyeRotateValue = 0; + int freeEyeRotateTransition = 0; + switch ((int)freeEyeAttackPattern) + { + case 0: + freeEyeRotateValue = 0; + freeEyeRotateTransition = 2; + break; + case 1: + freeEyeRotateValue = 2; + freeEyeRotateTransition = 5; + break; + case 2: + freeEyeRotateValue = 5; + freeEyeRotateTransition = 3; + break; + case 3: + freeEyeRotateValue = 3; + freeEyeRotateTransition = 1; + break; + case 4: + freeEyeRotateValue = 1; + freeEyeRotateTransition = 4; + break; + case 5: + freeEyeRotateValue = 4; + freeEyeRotateTransition = 0; + break; + } + + Vector2 basePoint = -Vector2.UnitY * 30f; + Vector2 freeEyeRotateLerp = basePoint.RotatedBy(freeEyeRotateValue * MathHelper.TwoPi / 6f); + Vector2 freeEyeTransitionLerp = basePoint.RotatedBy(freeEyeRotateTransition * MathHelper.TwoPi / 6f); + // Your first thought may be to see this and think "Why is there a lerp which has a lerp value that is always 0?" + // It is not always 0 though, because freeEyeAttackPattern is a float, so it's a decimal number subtracted from a truncated integer. + // This is necessary for the pupil location to smoothly transition between each point. + Vector2 freeEyeRotation = Vector2.Lerp(freeEyeRotateLerp, freeEyeTransitionLerp, freeEyeAttackPattern - (int)freeEyeAttackPattern); + float freeEyeRotationDist = freeEyeRotation.Length() / 30f; + // localAI[0] and localAI[1] are again used to control where the eye's pupil draws. + NPC.localAI[0] = freeEyeRotation.ToRotation(); + NPC.localAI[1] = MathHelper.Lerp(NPC.localAI[1], freeEyeRotationDist, 0.5f); + + // Dust telegraph + for (int k = 0; k < 2; k++) + { + Dust trueEyeDust = Dust.NewDustDirect(NPC.Center + freeEyeRotation - Vector2.One * 4f, 0, 0, DustID.Vortex, 0f, 0f); + trueEyeDust.velocity += freeEyeRotation / 15f; + trueEyeDust.noGravity = true; + } + + // Spawn the phantasmal spheres in their initial positions around the True Eye. + if ((secondAttackTimer - 15f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 trueEyeSphereDirection = Utils.SafeNormalize(freeEyeRotation, -Vector2.UnitY) * 4f; + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + freeEyeRotation, trueEyeSphereDirection, type, 0, 0f, Main.myPlayer, 30f, NPC.whoAmI); + Main.projectile[proj].timeLeft = 1200; + + if (Main.zenithWorld) + { + for (int k = 0; k < 3; k++) // GFB moon boulder bullshit thanks Red { - 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; + if (!WorldGen.SolidTile((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f))) + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, Main.rand.NextFloat(-16f, 16f), Main.rand.NextFloat(-16f, 0f), ProjectileID.MoonBoulder, MoonBoulderDamage, 10f); + } + } + } + } + // Launching of the phantasmal spheres. + else + { + // Brief upwards motion before the launch. + if (secondAttackTimer < 105f) + { + NPC.localAI[0] = NPC.localAI[0].AngleLerp(NPC.ai[2] - MathHelper.PiOver2, 0.2f); + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 0.75f, 0.2f); + + if (secondAttackTimer == 75f) + { + NPC.TargetClosest(false); + NPC.netUpdate = true; + NPC.velocity = -Vector2.UnitY * 7f; + + foreach (Projectile sp in Main.ActiveProjectiles) + { + if (sp.type == type && sp.ai[1] == NPC.whoAmI && sp.ai[0] != -1f) + { + sp.velocity += NPC.velocity; + sp.netUpdate = true; + } } } - // Heal limits - int maxHealAmt = death ? 1500 : 1250; - int totalHealth = Main.npc[k].lifeMax - Main.npc[k].life; - int leftHandHealth = Main.npc[leftHandHeal].lifeMax - Main.npc[leftHandHeal].life; - int rightHandHealth = Main.npc[rightHandHeal].lifeMax - Main.npc[rightHandHeal].life; - int headHealth = Main.npc[headHeal].lifeMax - Main.npc[headHeal].life; + // Slow down, rotate towards the target. + NPC.velocity.Y = NPC.velocity.Y * 0.96f; + NPC.ai[2] = (Main.player[NPC.target].Center - NPC.Center).ToRotation() + MathHelper.PiOver2; + NPC.rotation = NPC.rotation.AngleTowards(NPC.ai[2], MathHelper.Pi / 30f); - // Healing - if (headHealth > 0 && maxHealAmt > 0) + return; + } + + // Actually launch the spheres. + if (secondAttackTimer < 120f) + { + SoundEngine.PlaySound(SoundID.Zombie102, NPC.Center); + + if (secondAttackTimer == 105f) + NPC.netUpdate = true; + + float velocity = 12f; + Vector2 trueEyeSphereVelocity = (NPC.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; + NPC.velocity = trueEyeSphereVelocity * 2f; + + // Set damage and velocity. + foreach (Projectile sp in Main.ActiveProjectiles) { - int maxHealthFailsafe = headHealth - maxHealAmt; - if (maxHealthFailsafe > 0) + if (sp.type == type && sp.ai[1] == NPC.whoAmI && sp.ai[0] != -1f) { - maxHealthFailsafe = 0; + sp.ai[0] = -1f; + sp.damage = TrueEyeSphereDamage; + sp.velocity = trueEyeSphereVelocity; + sp.netUpdate = true; } - int headHealingAmt = maxHealAmt + maxHealthFailsafe; - maxHealAmt -= headHealingAmt; - NPC nPC6 = Main.npc[headHeal]; - nPC6.life += headHealingAmt; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[headHeal].Center, new Vector2(50f)), headHealingAmt, true); } - if (totalHealth > 0 && maxHealAmt > 0) + + return; + } + + NPC.velocity *= 0.92f; + NPC.rotation = NPC.rotation.AngleLerp(0f, 0.2f); + } + } + // Phantasmal eyes. + else if (NPC.ai[0] == 3f) + { + // Slow down, set pupil drawing variables. + if (secondAttackTimer < 15f) + { + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 0.4f, 0.2f); + + NPC.velocity *= 0.9f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; + } + else if (secondAttackTimer < 45f) + { + NPC.localAI[0] = 0f; + + NPC.localAI[1] = (float)Math.Sin((secondAttackTimer - 15f) * MathHelper.TwoPi / 15f) * 0.5f; + if (NPC.localAI[1] < 0f) + NPC.localAI[0] = MathHelper.Pi; + } + else + { + // Reset velocity and rotation. + if (secondAttackTimer >= 185f) + { + NPC.velocity *= 0.88f; + NPC.rotation = NPC.rotation.AngleLerp(0f, 0.2f); + + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 1f, 0.2f); + return; + } + + // Set the direction rotate in. + if (secondAttackTimer == 45f) + { + NPC.ai[2] = Main.rand.NextBool().ToDirectionInt() * MathHelper.TwoPi / 40f; + NPC.netUpdate = true; + } + + if ((secondAttackTimer - 15f - 30f) % 40f == 0f) + NPC.ai[2] *= 0.95f; + + // localAI[0] and localAI[1] are again used to control where the eye's pupil draws. + NPC.localAI[0] += NPC.ai[2]; + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 1f) + NPC.localAI[1] = 1f; + + // Spin around in a circle. + Vector2 trueEyeDirection = NPC.localAI[0].ToRotationVector2() * eyeSizeVector * NPC.localAI[1]; + float trueEyeVelScale = MathHelper.Lerp(8f, 20f, (secondAttackTimer - 15f - 30f) / 140f); + NPC.velocity = Vector2.Normalize(trueEyeDirection) * trueEyeVelScale; + NPC.rotation = NPC.rotation.AngleLerp(NPC.velocity.ToRotation() + MathHelper.PiOver2, 0.2f); + + // Spawn the phantasmal eyes. + if ((secondAttackTimer - 45f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 trueEyeEyeDirection = NPC.Center + Vector2.Normalize(trueEyeDirection) * eyeSizeVector.Length() * 0.4f; + Vector2 trueEyeEyeSpeed = Vector2.Normalize(trueEyeDirection) * 5f; + float ai1 = (Main.rand.NextFloat(MathHelper.TwoPi) - MathHelper.Pi) / 30f + MathHelper.Pi / 180f * NPC.ai[2]; + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), trueEyeEyeDirection, trueEyeEyeSpeed, ProjectileID.PhantasmalEye, TrueEyeEyeDamage, 0f, Main.myPlayer, 0f, ai1); + Main.projectile[proj].timeLeft = 1200; + } + } + } + // Phantasmal deathray. This code is never reached in Rev+ as the phantasmal deathray is replaced with another phantasmal sphere attack. + else if (NPC.ai[0] == 4f) + { + if (secondAttackTimer == 0f) + { + NPC.TargetClosest(false); + NPC.netUpdate = true; + } + + // Slow down, set pupil draw variables. + if (secondAttackTimer < 180f) + { + NPC.localAI[2] = MathHelper.Lerp(NPC.localAI[2], 1f, 0.2f); + + NPC.localAI[1] -= 0.05f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + + NPC.velocity *= 0.95f; + if (NPC.velocity.Length() < 1f) + NPC.velocity = Vector2.Zero; + + // Dust telegraph + if (secondAttackTimer >= 60f) + { + int dustAmt = secondAttackTimer >= 120f ? 2 : 1; + for (int j = 0; j < dustAmt; j++) { - int totalHealthFailsafe = totalHealth - maxHealAmt; - if (totalHealthFailsafe > 0) - { - totalHealthFailsafe = 0; - } - int totalHealingAmt = maxHealAmt + totalHealthFailsafe; - maxHealAmt -= totalHealingAmt; - NPC nPC6 = Main.npc[k]; - nPC6.life += totalHealingAmt; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[k].Center, new Vector2(50f)), totalHealingAmt, true); + float dustScale = j % 2 == 1 ? 1.65f : 0.8f; + + Vector2 trueEyeDustDirection = NPC.Center + Main.rand.NextFloat(MathHelper.TwoPi).ToRotationVector2() * eyeSizeVector / 2f; + Dust trueEyeDust = Dust.NewDustDirect(trueEyeDustDirection - Vector2.One * 8f, 16, 16, DustID.Vortex, 0f, 0f, Scale: dustScale); + trueEyeDust.velocity = Vector2.Normalize(NPC.Center - trueEyeDustDirection) * 0.35f * (10f - dustAmt * 2f); + trueEyeDust.noGravity = true; + trueEyeDust.customData = NPC; } - if (leftHandHealth > 0 && maxHealAmt > 0) + } + } + else + { + if (secondAttackTimer < phaseAttackTime - 15f) + { + if (calamityGlobalNPC.newAI[1] == 0f) + calamityGlobalNPC.newAI[1] = 600f; + + // Fire the phantasmal deathray. + if (secondAttackTimer == 180f && Main.netMode != NetmodeID.MultiplayerClient) { - int leftHandHealthFailsafe = leftHandHealth - maxHealAmt; - if (leftHandHealthFailsafe > 0) - { - leftHandHealthFailsafe = 0; - } - int leftHandHealingAmt = maxHealAmt + leftHandHealthFailsafe; - maxHealAmt -= leftHandHealingAmt; - NPC nPC6 = Main.npc[leftHandHeal]; - nPC6.life += leftHandHealingAmt; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[leftHandHeal].Center, new Vector2(50f)), leftHandHealingAmt, true); + // Deathray sweeps slower if the head is doing the deathray attack. + if (Main.npc[(int)Main.npc[(int)NPC.ai[3]].localAI[2]].ai[0] == 1f) + calamityGlobalNPC.newAI[1] *= 1.5f; + + NPC.TargetClosest(false); + + Vector2 deathrayTargetDist = Utils.DirectionTo(NPC.Center, Main.player[NPC.target].Center); + int deathraySweepDirection = (deathrayTargetDist.X < 0f).ToDirectionInt(); + + deathrayTargetDist = deathrayTargetDist.RotatedBy(-(double)deathraySweepDirection * MathHelper.TwoPi / 6f); + int type = ProjectileID.PhantasmalDeathray; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, deathrayTargetDist, type, TrueEyeDeathrayDamage, 0f, Main.myPlayer, deathraySweepDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1], NPC.whoAmI); + NPC.ai[2] = (deathrayTargetDist.ToRotation() + MathHelper.Pi + MathHelper.TwoPi) * deathraySweepDirection; + NPC.netUpdate = true; } - if (rightHandHealth > 0 && maxHealAmt > 0) + + NPC.localAI[1] += 0.05f; + if (NPC.localAI[1] > 1f) + NPC.localAI[1] = 1f; + + float deathrayRotationDirection = (NPC.ai[2] >= 0f).ToDirectionInt(); + float deathrayRotation = NPC.ai[2]; + if (deathrayRotation < 0f) + deathrayRotation *= -1f; + + deathrayRotation += deathrayRotationDirection * MathHelper.TwoPi / calamityGlobalNPC.newAI[1] - MathHelper.Pi; + NPC.localAI[0] = deathrayRotation; + NPC.ai[2] = (deathrayRotation + MathHelper.Pi) * deathrayRotationDirection; + + return; + } + + calamityGlobalNPC.newAI[1] = 0f; + + NPC.localAI[1] -= 0.07f; + if (NPC.localAI[1] < 0f) + NPC.localAI[1] = 0f; + } + } + } + + public void BuffedMoonLeechBlobAI() + { + // Variables + Vector2 mouthMovement = Vector2.UnitY * 216f; + int headIndex = (int)Math.Abs(NPC.ai[0]) - 1; + int leechTongue = (int)NPC.ai[1]; + + // Despawn if the head despawned. + if (!Main.npc[headIndex].active || Main.npc[headIndex].type != NPCID.MoonLordHead) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + return; + } + + // Heal a Moon Lord part after reaching the mouth. + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 180f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int coreIndex = (int)Main.npc[headIndex].ai[3]; + int leftHandHeal = -1; + int rightHandHeal = -1; + int headHeal = headIndex; + + // Find the indices of the left and right hands. + foreach (NPC n in Main.ActiveNPCs) + { + if (n.ai[3] == coreIndex) { - int rightHandHealthFailsafe = rightHandHealth - maxHealAmt; - if (rightHandHealthFailsafe > 0) - { - rightHandHealthFailsafe = 0; - } - int rightHandHealingAmt = maxHealAmt + rightHandHealthFailsafe; - NPC nPC6 = Main.npc[rightHandHeal]; - nPC6.life += rightHandHealingAmt; - NPC.HealEffect(Utils.CenteredRectangle(Main.npc[rightHandHeal].Center, new Vector2(50f)), rightHandHealingAmt, true); + 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) + break; } } - // Die - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - return false; + // Find heal limits for each part. Death Mode can heal more health. + int maxHealAmt = CalamityWorld.death ? 1500 : 1250; + int coreMissingHP = Main.npc[coreIndex].lifeMax - Main.npc[coreIndex].life; + int leftHandMissingHP = Main.npc[leftHandHeal].lifeMax - Main.npc[leftHandHeal].life; + int rightHandMissingHP = Main.npc[rightHandHeal].lifeMax - Main.npc[rightHandHeal].life; + int headMissingHP = Main.npc[headHeal].lifeMax - Main.npc[headHeal].life; + + // Head healing. + if (headMissingHP > 0 && maxHealAmt > 0) + { + // Each failsafe threshold ensures it will either heal the Leech's maximum heal or up to the NPC's max health. + int headHealthFailsafe = headMissingHP - maxHealAmt; + if (headHealthFailsafe > 0) + headHealthFailsafe = 0; + + int headHealingAmt = maxHealAmt + headHealthFailsafe; + // maxHealAmt gets subtracted from, if this is still greater than 0 then it can heal additional parts. + maxHealAmt -= headHealingAmt; + Main.npc[headHeal].life += headHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[headHeal].Center, new Vector2(50f)), headHealingAmt); + } + if (coreMissingHP > 0 && maxHealAmt > 0) + { + int coreHealthFailsafe = coreMissingHP - maxHealAmt; + if (coreHealthFailsafe > 0) + coreHealthFailsafe = 0; + + int coreHealingAmt = maxHealAmt + coreHealthFailsafe; + maxHealAmt -= coreHealingAmt; + Main.npc[coreIndex].life += coreHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[coreIndex].Center, new Vector2(50f)), coreHealingAmt); + } + if (leftHandMissingHP > 0 && maxHealAmt > 0) + { + int leftHandHealthFailsafe = leftHandMissingHP - maxHealAmt; + if (leftHandHealthFailsafe > 0) + leftHandHealthFailsafe = 0; + + int leftHandHealingAmt = maxHealAmt + leftHandHealthFailsafe; + maxHealAmt -= leftHandHealingAmt; + Main.npc[leftHandHeal].life += leftHandHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[leftHandHeal].Center, new Vector2(50f)), leftHandHealingAmt); + } + if (rightHandMissingHP > 0 && maxHealAmt > 0) + { + int rightHandHealthFailsafe = rightHandMissingHP - maxHealAmt; + if (rightHandHealthFailsafe > 0) + rightHandHealthFailsafe = 0; + + int rightHandHealingAmt = maxHealAmt + rightHandHealthFailsafe; + Main.npc[rightHandHeal].life += rightHandHealingAmt; + NPC.HealEffect(Utils.CenteredRectangle(Main.npc[rightHandHeal].Center, new Vector2(50f)), rightHandHealingAmt); + } } - // Move towards the Moon Lord mouth - npc.velocity = Vector2.Zero; - npc.Center = Vector2.Lerp(Main.projectile[moonLordHead].Center, Main.npc[(int)Math.Abs(npc.ai[0]) - 1].Center + mouthMovement, npc.ai[2] / 180f); + // Die after healing. + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + return; + } - // Emit dust - Vector2 spinningpoint3 = Vector2.UnitY * -npc.height / 2f; - for (int i = 0; i < 4; i++) - { - int leechDust = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(i * MathHelper.TwoPi / 6f), 0, 0, DustID.Vortex, 0f, 0f, 0, default, 1f); - Main.dust[leechDust].velocity = -Vector2.UnitY; - Main.dust[leechDust].noGravity = true; - Main.dust[leechDust].scale = 0.7f; - Main.dust[leechDust].customData = npc; - } + // Move towards Moon Lord's mouth. + NPC.velocity = Vector2.Zero; + NPC.Center = Vector2.Lerp(Main.projectile[leechTongue].Center, Main.npc[(int)Math.Abs(NPC.ai[0]) - 1].Center + mouthMovement, NPC.ai[2] / 180f); - spinningpoint3 = Vector2.UnitY * -npc.height / 6f; - for (int j = 0; j < 2; j++) - { - int leechDust2 = Dust.NewDust(npc.Center - Vector2.One * 4f + spinningpoint3.RotatedBy(j * MathHelper.TwoPi / 6f), 0, 0, DustID.Vortex, 0f, -2f, 0, default, 1f); - Main.dust[leechDust2].noGravity = true; - Main.dust[leechDust2].scale = 1.5f; - Main.dust[leechDust2].customData = npc; - } + // Dust effects + Vector2 basePos = -Vector2.UnitY * NPC.height / 2f; + for (int i = 0; i < 4; i++) + { + Dust leechDust = Dust.NewDustPerfect(NPC.Center - Vector2.One * 4f + basePos.RotatedBy(i * MathHelper.TwoPi / 6f), DustID.Vortex, -Vector2.UnitY, Scale: 0.7f); + leechDust.noGravity = true; + leechDust.customData = NPC; + } + + basePos = -Vector2.UnitY * NPC.height / 6f; + for (int j = 0; j < 2; j++) + { + int leechDust2 = Dust.NewDust(NPC.Center - Vector2.One * 4f + basePos.RotatedBy(j * MathHelper.TwoPi / 6f), 0, 0, DustID.Vortex, 0f, -2f, Scale: 1.5f); + Main.dust[leechDust2].noGravity = true; + Main.dust[leechDust2].customData = NPC; } - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs index b228164acb..23517398bb 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs @@ -4,14 +4,16 @@ using CalamityMod.NPCs.NormalNPCs; 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; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class PlanteraAI + public class PlanteraAI : VanillaAIOverride { public const float SeedGatlingGateValue = 600f; public const float SeedGatlingDuration = 300f; @@ -27,19 +29,34 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public const float StopChargeGateValue = BeginChargeSlowDownGateValue - 30f; public const float MovementVelocityMultiplierForSlowAttacks = 0.5f; - public static bool BuffedPlanteraAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Vanilla values + public static float Phase2ContactDamageMult = 1.4f; // 140 + public static int PinkSeedDamage = 19; // 76 + public static int PoisonSeedDamage = 24; // 96 + public static int ThornBallDamage = 27; // 108 - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + // Expert AI has uses a magic number which we have to correct for + public static int ContactDamageCorrection = Main.masterMode ? 150 : 100; + + // Rev+ exclusive + public static int ThornBallSpikeDamage = 22; // 88 + public static int GasBulbDamage = 27; // 108 + public static int PinkCloudDamage = 22; // 88 + public static int GreenCloudDamage = 24; // 96 + public static float DashDamageMult = 1.25f; // 175 + + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phases based on HP float phase2LifeRatio = 0.5f; @@ -48,29 +65,26 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool useNewGatlingAttackVariant = addSporeGasBlastToGatlingAttack && death; bool phase2 = lifeRatio <= phase2LifeRatio; bool phase3 = lifeRatio < 0.35f; - bool vomitFreeTentacles = lifeRatio < 0.25f && death; bool phase4 = lifeRatio < 0.2f; - // Contact damage values for phase 2 - int setDamage = (int)Math.Round(npc.defDamage * 1.4); - int reducedSetDamage = (int)Math.Round(setDamage * 0.5); + NPC.damage = (int)Math.Round(ContactDamageCorrection * (phase2 ? Phase2ContactDamageMult : 1f)); // Variables and target - bool enrage = bossRush; + bool enrage = false; bool despawn = false; // Check for Jungle - bool surface = !bossRush && Main.player[npc.target].position.Y < Main.worldSurface * 16.0; + bool surface = !BossRushEvent.BossRushActive && Main.player[NPC.target].position.Y < Main.worldSurface * 16.0; // Tentacle limits int maxTentaclesAfterFirstTentaclePhase = death ? 4 : 2; int maxFreeTentaclesAfterFirstTentaclePhase = maxTentaclesAfterFirstTentaclePhase * 2; float speedUpDistance = 480f; - bool speedUp = Vector2.Distance(Main.player[npc.target].Center, npc.Center) > speedUpDistance; // 30 or 40 tile distance + bool speedUp = Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > speedUpDistance; // 30 or 40 tile distance // Despawn - if (Main.player[npc.target].dead) + if (Main.player[NPC.target].dead) { despawn = true; enrage = true; @@ -79,23 +93,23 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Despawn if too far from target if (Main.netMode != NetmodeID.MultiplayerClient) { - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 6000f) + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6000f) { - npc.active = false; - npc.life = 0; + NPC.active = false; + NPC.life = 0; if (Main.dedServ) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI); } } // Set whoAmI variable and spawn hooks - NPC.plantBoss = npc.whoAmI; - if (npc.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + NPC.plantBoss = NPC.whoAmI; + if (NPC.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] = 1f; - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasHook, npc.whoAmI); - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasHook, npc.whoAmI); - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasHook, npc.whoAmI); + NPC.localAI[0] = 1f; + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PlanterasHook, NPC.whoAmI); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PlanterasHook, NPC.whoAmI); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PlanterasHook, NPC.whoAmI); } // Find positions of hooks @@ -121,29 +135,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses hookPositionY /= numHooksSpawned; // Velocity and acceleration - float velocity = bossRush ? 12f : phase4 ? 7f : phase3 ? 6.5f : phase2 ? 6f : 4f; - float acceleration = bossRush ? 0.12f : phase3 ? 0.06f : 0.04f; - float chargeLineUpVelocity = bossRush ? 20f : phase4 ? 12f : phase3 ? 10f : 8f; - float chargeLineUpAcceleration = bossRush ? 0.8f : phase4 ? 0.6f : phase3 ? 0.5f : 0.4f; - float chargeVelocity = bossRush ? 30f : phase4 ? 22f : phase3 ? 20f : 18f; - float chargeDeceleration = bossRush ? 0.85f : phase4 ? 0.92f : phase3 ? 0.95f : 0.96f; + float velocity = phase4 ? 7f : phase3 ? 6.5f : phase2 ? 6f : 4f; + float acceleration = phase3 ? 0.06f : 0.04f; + float chargeLineUpVelocity = phase4 ? 12f : phase3 ? 10f : 8f; + float chargeLineUpAcceleration = phase4 ? 0.6f : phase3 ? 0.5f : 0.4f; + float chargeVelocity = phase4 ? 22f : phase3 ? 20f : 18f; + float chargeDeceleration = phase4 ? 0.92f : phase3 ? 0.95f : 0.96f; // Enrage if target is on the surface - if (!bossRush && (surface || Main.player[npc.target].position.Y > Main.UnderworldLayer * 16)) + if (!BossRushEvent.BossRushActive && (surface || Main.player[NPC.target].position.Y > Main.UnderworldLayer * 16)) { enrage = true; velocity += 8f; acceleration = 0.15f; } - npc.Calamity().CurrentlyEnraged = !bossRush && enrage; + NPC.Calamity().CurrentlyEnraged = enrage; // Movement relative to the target and hook positions Vector2 npcCenterAccountingForHooks = new Vector2(hookPositionX, hookPositionY); - 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) < 240f && 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; + 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) < 240f && 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; @@ -161,8 +175,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) { - velocity += velocity * 0.35f * (1f - lifeRatio); - acceleration += acceleration * 0.35f * (1f - lifeRatio); + velocity += velocity * 0.35f * ((1f - lifeRatio) / 2); + acceleration += acceleration * 0.35f * ((1f - lifeRatio) / 2); if (phase2) { float aggressionScale = (phase2LifeRatio - lifeRatio) / phase2LifeRatio; @@ -182,17 +196,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Slow down and fire a gatling of projectiles // These projectiles are slower than normal // Glow gradually more green the closer the gatling attack is to ending - bool usingSeedGatling = npc.ai[1] > SeedGatlingGateValue; - bool slowedDuringTentaclePhase = npc.ai[2] > 0f; - bool doneWithTentaclePhase = npc.ai[2] == -1f; - bool charging = npc.ai[3] <= -2f; + bool usingSeedGatling = NPC.ai[1] > SeedGatlingGateValue; + bool slowedDuringTentaclePhase = NPC.ai[2] > 0f; + bool doneWithTentaclePhase = NPC.ai[2] == -1f; + bool charging = NPC.ai[3] <= -2f; bool secondCharge = calamityGlobalNPC.newAI[2] == 1f; if (!phase2) { - npc.ai[1] += 1f; + NPC.ai[1] += 1f; if (usingSeedGatling) { - float currentSeedGatlingTime = npc.ai[1] - SeedGatlingGateValue; + float currentSeedGatlingTime = NPC.ai[1] - SeedGatlingGateValue; // Slow down more and more as gatling attack continues velocity *= MathHelper.Lerp(MovementVelocityMultiplierForSlowAttacks, 1f, (float)Math.Pow(currentSeedGatlingTime / SeedGatlingDuration, 2D)); @@ -208,15 +222,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (currentSeedGatlingTime >= 60f) shootProjectileGateValue = useNewGatlingAttackVariant ? 30f : 15f; - if (npc.ai[1] % shootProjectileGateValue == 0f) + if (NPC.ai[1] % shootProjectileGateValue == 0f) { - bool shootThornBall = npc.ai[1] % 90f == 0f && addThornBallsToGatlingAttack && !useNewGatlingAttackVariant; - bool shootPoisonSeed = npc.ai[1] % 9f == 0f && !shootThornBall; + bool shootThornBall = NPC.ai[1] % 90f == 0f && addThornBallsToGatlingAttack && !useNewGatlingAttackVariant; + bool shootPoisonSeed = NPC.ai[1] % 9f == 0f && !shootThornBall; float projectileSpeed = 14f; int projectileType = shootThornBall ? ProjectileID.ThornBall : shootPoisonSeed ? ProjectileID.PoisonSeedPlantera : ProjectileID.SeedPlantera; - int damage = npc.GetProjectileDamage(projectileType); - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - Vector2 spawnOffset = npc.Center + projectileVelocity * 70f; + int damage = shootThornBall ? ThornBallDamage : shootPoisonSeed ? PoisonSeedDamage : PinkSeedDamage; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); + Vector2 spawnOffset = NPC.Center + projectileVelocity * 70f; if (useNewGatlingAttackVariant) { @@ -245,7 +259,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, perturbedSpeed * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnOffset, perturbedSpeed * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); } } else @@ -264,7 +278,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { float ai2 = projectileType == ProjectileID.ThornBall && (Main.rand.NextBool() || !Main.zenithWorld) ? 1f : 0f; - Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer, 0f, 0f, ai2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), adjustProjectileShootLocation ? NPC.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer, 0f, 0f, ai2); } } } @@ -273,42 +287,41 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spore Gas vomit color telegraph if (addSporeGasBlastToGatlingAttack) { - bool startEmittingDust = npc.ai[1] > SeedGatlingColorChangeGateValue; + bool startEmittingDust = NPC.ai[1] > SeedGatlingColorChangeGateValue; if (startEmittingDust) { - float dustEmitAmount = npc.ai[1] - SeedGatlingColorChangeGateValue; + float dustEmitAmount = NPC.ai[1] - SeedGatlingColorChangeGateValue; int dustInXChanceMin = 2; int dustInXChanceMax = 8; int dustChance = (int)Math.Round(MathHelper.Lerp(dustInXChanceMin, dustInXChanceMax, 1f - dustEmitAmount / SeedGatlingColorChangeDuration)); if (Main.rand.NextBool(dustChance)) { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.GreenFairy, 0f, 0f, 0, default, 1.4f); + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GreenFairy, 0f, 0f, 0, default, 1.4f); Vector2 vector = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)).SafeNormalize(Vector2.UnitY); vector *= Main.rand.Next(50, 100) * 0.04f; Main.dust[dust].velocity = vector; vector = vector.SafeNormalize(Vector2.UnitY); vector *= 86f; - Main.dust[dust].position = npc.Center - vector; + Main.dust[dust].position = NPC.Center - vector; } } } - if (npc.ai[1] >= SeedGatlingStopValue) + if (NPC.ai[1] >= SeedGatlingStopValue) { // Vomit dense spread of spore gas at the end of the gatling attack if (addSporeGasBlastToGatlingAttack) { - SoundEngine.PlaySound(SoundID.Item74, npc.Center); + SoundEngine.PlaySound(SoundID.Item74, NPC.Center); int totalProjectiles = death ? 36 : 30; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity2 = CalamityWorld.LegendaryMode ? 10f : 5f; + float velocity2 = Main.getGoodWorld ? 10f : 5f; Vector2 spinningPoint = new Vector2(0f, -velocity2); for (int k = 0; k < totalProjectiles; k++) { Vector2 projectileVelocity = spinningPoint.RotatedBy(radians * k); - Vector2 spawnOffset = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f; + Vector2 spawnOffset = NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f; float randomSpeed = Main.rand.NextFloat(0.8f, death ? 1.5f : 1.2f); int dustType = 74; @@ -321,22 +334,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float ai0 = Main.rand.Next(3); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * randomSpeed, type, damage, 0f, Main.myPlayer, ai0); + Projectile.NewProjectile(NPC.GetSource_FromAI(), adjustProjectileShootLocation ? NPC.Center : spawnOffset, projectileVelocity * randomSpeed, type, GreenCloudDamage, 0f, Main.myPlayer, ai0); } } - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - npc.ai[1] = -SeedGatlingDuration; + NPC.ai[1] = -SeedGatlingDuration; } } else { - npc.ai[1] = 0f; + NPC.ai[1] = 0f; // Slow down for a while after tentacles are spawned if (slowedDuringTentaclePhase) - velocity *= MathHelper.Lerp(MovementVelocityMultiplierForSlowAttacks, 1f, (float)Math.Pow(1f - npc.ai[2] / TentaclePhaseSlowDuration, 2D)); + velocity *= MathHelper.Lerp(MovementVelocityMultiplierForSlowAttacks, 1f, (float)Math.Pow(1f - NPC.ai[2] / TentaclePhaseSlowDuration, 2D)); // Prepare to charge // More charges are used in a row at lower HP @@ -346,17 +359,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) timeToChargeIncrement *= 2f; - npc.ai[3] += timeToChargeIncrement; - if (npc.ai[3] >= ChargePhaseGateValue) - npc.ai[3] = -2f; + NPC.ai[3] += timeToChargeIncrement; + if (NPC.ai[3] >= ChargePhaseGateValue) + NPC.ai[3] = -2f; } } // Move slowly for a bit after finishing gatling attack - bool slowedAfterGatlingAttack = npc.ai[1] < 0f && !phase2; + bool slowedAfterGatlingAttack = NPC.ai[1] < 0f && !phase2; if (slowedAfterGatlingAttack) { - float absValueOfTimer = Math.Abs(npc.ai[1]); + float absValueOfTimer = Math.Abs(NPC.ai[1]); velocity *= MathHelper.Lerp(MovementVelocityMultiplierForSlowAttacks, 1f, (float)Math.Pow(absValueOfTimer / SeedGatlingDuration, 2D)); // Shoot homing pink bulb projectiles that leave behind lingering pink clouds @@ -368,9 +381,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { float projectileSpeed = 9f; int projectileType = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(projectileType); - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - Vector2 spawnOffset = npc.Center + projectileVelocity * 70f; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); + Vector2 spawnOffset = NPC.Center + projectileVelocity * 70f; int dustType = 73; Vector2 dustVelocity = projectileVelocity * projectileSpeed; @@ -382,30 +394,27 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), adjustProjectileShootLocation ? NPC.Center : spawnOffset, projectileVelocity * projectileSpeed, projectileType, GasBulbDamage, 0f, Main.myPlayer); } } if (charging) { // Slow down and return to normal behavior - if (npc.ai[3] <= BeginChargeSlowDownGateValue) + if (NPC.ai[3] <= BeginChargeSlowDownGateValue) { - // Avoid cheap bullshit - npc.damage = reducedSetDamage; - - npc.velocity *= chargeDeceleration; - float timeToDecelerateDecrement = bossRush ? 2f : phase4 ? 1.5f : 1f; - npc.ai[3] -= timeToDecelerateDecrement; - if (npc.ai[3] <= StopChargeGateValue) + NPC.velocity *= chargeDeceleration; + float timeToDecelerateDecrement = phase4 ? 1.5f : 1f; + NPC.ai[3] -= timeToDecelerateDecrement; + if (NPC.ai[3] <= StopChargeGateValue) { - bool canChargeAgain = phase4 ? true : phase3 ? Main.rand.NextBool() : false; + bool canChargeAgain = phase4 || (phase3 && Main.rand.NextBool()); bool chargeAgain = canChargeAgain && death && calamityGlobalNPC.newAI[2] == 0f; - npc.ai[3] = chargeAgain ? -2f : 0f; + NPC.ai[3] = chargeAgain ? -2f : 0f; calamityGlobalNPC.newAI[2] = (death && calamityGlobalNPC.newAI[2] == 0f && chargeAgain) ? 1f : 0f; - npc.SyncExtraAI(); + NPC.SyncExtraAI(); - if (!vomitFreeTentacles && !secondCharge) + if (!secondCharge) { // Spawn a few tentacles if (Main.netMode != NetmodeID.MultiplayerClient) @@ -416,7 +425,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (NPC.CountNPCS(ModContent.NPCType()) < maxFreeTentaclesAfterFirstTentaclePhase) { for (int i = 0; i < maxTentaclesAfterFirstTentaclePhase; i++) - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasTentacle, npc.whoAmI, 0f, 0f, 1f, 0f); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PlanterasTentacle, NPC.whoAmI, 0f, 0f, 1f, 0f); } } } @@ -426,19 +435,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Maintain charge velocity // Emit spore gas in phase 3 - else if (npc.ai[3] <= BeginChargeGateValue) + else if (NPC.ai[3] <= BeginChargeGateValue) { - // Set damage - npc.damage = setDamage; - + NPC.damage = (int)Math.Round(ContactDamageCorrection * Phase2ContactDamageMult * DashDamageMult); float sporeGasDashGateValue = death ? 6f : 9f; - if (phase3 && npc.ai[3] % sporeGasDashGateValue == 0f) + if (phase3 && NPC.ai[3] % sporeGasDashGateValue == 0f) { int projectileType = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(projectileType); float randomVelocityMultiplier = secondCharge ? 0.05f : death ? 0.3f : 0.2f; - Vector2 projectileVelocity = npc.velocity * Main.rand.NextVector2CircularEdge(randomVelocityMultiplier, randomVelocityMultiplier); - Vector2 spawnOffset = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 30f; + Vector2 projectileVelocity = NPC.velocity * Main.rand.NextVector2CircularEdge(randomVelocityMultiplier, randomVelocityMultiplier); + Vector2 spawnOffset = NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 30f; int dustType = 74; Vector2 dustVelocity = projectileVelocity; @@ -450,72 +456,66 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float ai0 = Main.rand.Next(3); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, ai0); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnOffset, projectileVelocity, projectileType, GasBulbDamage, 0f, Main.myPlayer, ai0); } - npc.ai[3] -= 1f; - if (npc.ai[3] <= BeginChargeSlowDownGateValue) - npc.ai[3] = BeginChargeSlowDownGateValue; + NPC.ai[3] -= 1f; + if (NPC.ai[3] <= BeginChargeSlowDownGateValue) + NPC.ai[3] = BeginChargeSlowDownGateValue; } // Move a specified distance away from the target and charge once that distance is reached else { - // Avoid cheap bullshit - npc.damage = reducedSetDamage; - // Line up before charging - if (npc.Calamity().newAI[0] == 0f) + if (NPC.Calamity().newAI[0] == 0f) { - npc.Calamity().newAI[0] = Math.Sign((npc.Center - Main.player[npc.target].Center).X); - npc.SyncExtraAI(); + NPC.Calamity().newAI[0] = Math.Sign((NPC.Center - Main.player[NPC.target].Center).X); + NPC.SyncExtraAI(); } - Vector2 destination = Main.player[npc.target].Center + new Vector2(npc.Calamity().newAI[0], 0); - Vector2 distanceFromDestination = destination - npc.Center; - Vector2 desiredVelocity = (distanceFromDestination - npc.velocity).SafeNormalize(Vector2.UnitY) * chargeLineUpVelocity; + Vector2 destination = Main.player[NPC.target].Center + new Vector2(NPC.Calamity().newAI[0], 0); + Vector2 distanceFromDestination = destination - NPC.Center; + Vector2 desiredVelocity = (distanceFromDestination - NPC.velocity).SafeNormalize(Vector2.UnitY) * chargeLineUpVelocity; - if (Vector2.Distance(npc.Center, destination) > ReduceSpeedForChargeDistance) - npc.SimpleFlyMovement(desiredVelocity, chargeLineUpAcceleration); + if (Vector2.Distance(NPC.Center, destination) > ReduceSpeedForChargeDistance) + NPC.SimpleFlyMovement(desiredVelocity, chargeLineUpAcceleration); else - npc.velocity *= 0.98f; + NPC.velocity *= 0.98f; // Emit dust to show that a spore and charge attack are about to happen - float dustEmitAmount = Math.Abs(BeginChargeGateValue) - Math.Abs(npc.ai[3]); + float dustEmitAmount = Math.Abs(BeginChargeGateValue) - Math.Abs(NPC.ai[3]); int dustInXChanceMin = 2; int dustInXChanceMax = 8; int dustChance = (int)Math.Round(MathHelper.Lerp(dustInXChanceMin, dustInXChanceMax, 1f - dustEmitAmount / Math.Abs(BeginChargeGateValue))); if (Main.rand.NextBool(dustChance)) { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.GreenFairy, 0f, 0f, 0, default, 1.4f); + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GreenFairy, 0f, 0f, 0, default, 1.4f); Vector2 vector = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)).SafeNormalize(Vector2.UnitY); vector *= Main.rand.Next(50, 100) * 0.04f; Main.dust[dust].velocity = vector; vector = vector.SafeNormalize(Vector2.UnitY); vector *= 86f; - Main.dust[dust].position = npc.Center - vector; + Main.dust[dust].position = NPC.Center - vector; } float timeToLineUpChargeDecrement = phase4 ? 2f : 1f; if (death) timeToLineUpChargeDecrement *= 2f; - npc.ai[3] -= timeToLineUpChargeDecrement; - if (npc.ai[3] <= BeginChargeGateValue) + NPC.ai[3] -= timeToLineUpChargeDecrement; + if (NPC.ai[3] <= BeginChargeGateValue) { - // Set damage - npc.damage = setDamage; - // Charge - npc.ai[3] = BeginChargeGateValue; - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; - SoundEngine.PlaySound(SoundID.Item74, npc.Center); + NPC.ai[3] = BeginChargeGateValue; + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; + SoundEngine.PlaySound(SoundID.Item74, NPC.Center); // Spore dust cloud - Vector2 dustVelocity = npc.velocity * -0.25f; + Vector2 dustVelocity = NPC.velocity * -0.25f; for (int k = 0; k < 30; k++) { - Dust dust = Dust.NewDustDirect(npc.Center, npc.width, npc.height, DustID.JungleSpore, dustVelocity.X, dustVelocity.Y, 250, default, 0.8f); + Dust dust = Dust.NewDustDirect(NPC.Center, NPC.width, NPC.height, DustID.JungleSpore, dustVelocity.X, dustVelocity.Y, 250, default, 0.8f); dust.fadeIn = 0.7f; } @@ -523,13 +523,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int totalProjectiles = secondCharge ? 6 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float velocity2 = CalamityWorld.LegendaryMode ? 10f : 5f; + float velocity2 = Main.getGoodWorld ? 10f : 5f; Vector2 spinningPoint = new Vector2(0f, -velocity2); for (int k = 0; k < totalProjectiles; k++) { Vector2 projectileVelocity = spinningPoint.RotatedBy(radians * k); - Vector2 spawnOffset = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f; + Vector2 spawnOffset = NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f; float randomSpeed = Main.rand.NextFloat(0.8f, secondCharge ? 1f : death ? 1.5f : 1.2f); int dustType = 74; @@ -542,21 +541,18 @@ 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(), spawnOffset, projectileVelocity * randomSpeed, type, GasBulbDamage, 0f, Main.myPlayer, ai0); } } // Rotation - float rotationX = Main.player[npc.target].Center.X - npc.Center.X; - float rotationY = Main.player[npc.target].Center.Y - npc.Center.Y; - npc.rotation = (float)Math.Atan2(rotationY, rotationX) + MathHelper.PiOver2; + float rotationX = Main.player[NPC.target].Center.X - NPC.Center.X; + float rotationY = Main.player[NPC.target].Center.Y - NPC.Center.Y; + NPC.rotation = (float)Math.Atan2(rotationY, rotationX) + MathHelper.PiOver2; } } else { - // Avoid cheap bullshit - npc.damage = phase2 ? reducedSetDamage : 0; - // Velocity ranges from 4 to 7.2, Acceleration ranges from 0.04 to 0.072, non-enraged phase 1 // Velocity ranges from 7 to 12.6, Acceleration ranges from 0.07 to 0.126, non-enraged phase 2 // Velocity ranges from 9 to 16.2, Acceleration ranges from 0.07 to 0.126, non-enraged phase 3 @@ -568,7 +564,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses maxDistanceFromHooks += 150f; if (death) { - maxDistanceFromHooks += maxDistanceFromHooks * 0.2f * (1f - lifeRatio); + maxDistanceFromHooks += maxDistanceFromHooks * 0.2f * ((1f - lifeRatio) / 2); maxDistanceFromHooks += 200f; } @@ -581,15 +577,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses hookPositionX += maxVelocityX; hookPositionY += maxVelocityY; - npcCenterAccountingForHooks = npc.Center; + npcCenterAccountingForHooks = NPC.Center; maxVelocityX = hookPositionX - npcCenterAccountingForHooks.X; maxVelocityY = hookPositionY - npcCenterAccountingForHooks.Y; distanceFromTarget = (float)Math.Sqrt(maxVelocityX * maxVelocityX + maxVelocityY * maxVelocityY); if (distanceFromTarget < velocity) { - maxVelocityX = npc.velocity.X; - maxVelocityY = npc.velocity.Y; + maxVelocityX = NPC.velocity.X; + maxVelocityY = NPC.velocity.Y; } else { @@ -598,64 +594,64 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses maxVelocityY *= distanceFromTarget; } - if (npc.velocity.X < maxVelocityX) + if (NPC.velocity.X < maxVelocityX) { - npc.velocity.X += acceleration; - if (npc.velocity.X < 0f && maxVelocityX > 0f) - npc.velocity.X += acceleration * 2f; + NPC.velocity.X += acceleration; + if (NPC.velocity.X < 0f && maxVelocityX > 0f) + NPC.velocity.X += acceleration * 2f; } - else if (npc.velocity.X > maxVelocityX) + else if (NPC.velocity.X > maxVelocityX) { - npc.velocity.X -= acceleration; - if (npc.velocity.X > 0f && maxVelocityX < 0f) - npc.velocity.X -= acceleration * 2f; + NPC.velocity.X -= acceleration; + if (NPC.velocity.X > 0f && maxVelocityX < 0f) + NPC.velocity.X -= acceleration * 2f; } - if (npc.velocity.Y < maxVelocityY) + if (NPC.velocity.Y < maxVelocityY) { - npc.velocity.Y += acceleration; - if (npc.velocity.Y < 0f && maxVelocityY > 0f) - npc.velocity.Y += acceleration * 2f; + NPC.velocity.Y += acceleration; + if (NPC.velocity.Y < 0f && maxVelocityY > 0f) + NPC.velocity.Y += acceleration * 2f; } - else if (npc.velocity.Y > maxVelocityY) + else if (NPC.velocity.Y > maxVelocityY) { - npc.velocity.Y -= acceleration; - if (npc.velocity.Y > 0f && maxVelocityY < 0f) - npc.velocity.Y -= acceleration * 2f; + NPC.velocity.Y -= acceleration; + if (NPC.velocity.Y > 0f && maxVelocityY < 0f) + NPC.velocity.Y -= acceleration * 2f; } // Rotation - float rotationX = Main.player[npc.target].Center.X - npc.Center.X; - float rotationY = Main.player[npc.target].Center.Y - npc.Center.Y; - npc.rotation = (float)Math.Atan2(rotationY, rotationX) + MathHelper.PiOver2; + float rotationX = Main.player[NPC.target].Center.X - NPC.Center.X; + float rotationY = Main.player[NPC.target].Center.Y - NPC.Center.Y; + NPC.rotation = (float)Math.Atan2(rotationY, rotationX) + MathHelper.PiOver2; } // Phase 1 if (!phase2) { // Emit light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.8f, 0.2f, 0.4f); + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 0.8f, 0.2f, 0.4f); // Adjust stats calamityGlobalNPC.DR = 0.15f; calamityGlobalNPC.unbreakableDR = false; - npc.defense = 32; + NPC.defense = 32; // Fire projectiles if (!usingSeedGatling && !slowedAfterGatlingAttack) { float shootBoost = 2f * (1f - lifeRatio); - npc.localAI[1] += 1f + shootBoost; + NPC.localAI[1] += 1f + shootBoost; if (enrage) - npc.localAI[1] += 2f; + NPC.localAI[1] += 2f; if (Main.getGoodWorld) - npc.localAI[1] += 1f; + NPC.localAI[1] += 1f; - float shootProjectileGateValue = death ? 30f : 60f; - if (npc.localAI[1] >= shootProjectileGateValue) + float shootProjectileGateValue = death ? 40f : 60f; + if (NPC.localAI[1] >= shootProjectileGateValue) { - npc.localAI[1] = 0f; + NPC.localAI[1] = 0f; bool shootThornBall = false; if (useNewGatlingAttackVariant) @@ -676,12 +672,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - bool shootPoisonSeed = (CalamityWorld.LegendaryMode || Main.rand.NextBool(death ? 2 : 4)) && !shootThornBall; + bool shootPoisonSeed = (Main.getGoodWorld || Main.rand.NextBool(death ? 2 : 4)) && !shootThornBall; int projectileType = shootThornBall ? ProjectileID.ThornBall : shootPoisonSeed ? ProjectileID.PoisonSeedPlantera : ProjectileID.SeedPlantera; float projectileSpeed = death ? 16f : 14f; - int damage = npc.GetProjectileDamage(projectileType); - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - Vector2 spawnOffset = npc.Center + projectileVelocity * 70f; + int damage = shootThornBall ? ThornBallDamage : shootPoisonSeed ? PoisonSeedDamage : PinkSeedDamage; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); + Vector2 spawnOffset = NPC.Center + projectileVelocity * 70f; int dustType = shootPoisonSeed ? 74 : 73; int dustSpawnBoxSize = shootThornBall ? 38 : 14; @@ -696,7 +692,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), adjustProjectileShootLocation ? npc.Center : 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; } @@ -708,34 +704,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else { // Emit light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.4f, 0.8f, 0.2f); + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 0.4f, 0.8f, 0.2f); // Spore dust if (Main.rand.NextBool(10)) { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.JungleSpore, 0f, 0f, 250, default, 0.6f); + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.JungleSpore, 0f, 0f, 250, default, 0.6f); dust.fadeIn = 0.7f; } // Adjust stats calamityGlobalNPC.DR = 0.15f; calamityGlobalNPC.unbreakableDR = false; - npc.defense = 10; + NPC.defense = 10; // Spawn tentacles if (Main.netMode != NetmodeID.MultiplayerClient) { - if (npc.localAI[0] == 1f) + if (NPC.localAI[0] == 1f) { - npc.localAI[0] = 2f; - int totalTentacles = death ? 12 : 8; + NPC.localAI[0] = 2f; + int totalTentacles = death ? 11 : 8; if (Main.getGoodWorld) - totalTentacles += 6; - if (CalamityWorld.LegendaryMode) totalTentacles *= 2; for (int i = 0; i < totalTentacles; i++) - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasTentacle, npc.whoAmI); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PlanterasTentacle, NPC.whoAmI); if (Main.getGoodWorld) { @@ -745,7 +739,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { 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); + int hookIndex = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PlanterasTentacle, NPC.whoAmI); Main.npc[hookIndex].ai[3] = n.whoAmI + 1; } } @@ -757,8 +751,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Slow down for 20 seconds after transitioning to phase 2 // This gives players time to handle the tentacles before Plantera starts attack again // Decrement the timer far faster if there aren't any tentacles alive - if (npc.ai[2] == 0f) - npc.ai[2] = TentaclePhaseSlowDuration; + if (NPC.ai[2] == 0f) + NPC.ai[2] = TentaclePhaseSlowDuration; if (slowedDuringTentaclePhase) { @@ -768,35 +762,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) tentacleIdleTimerDecrement *= 2f; - npc.ai[2] -= tentacleIdleTimerDecrement; - if (npc.ai[2] <= 0f) - npc.ai[2] = -1f; + NPC.ai[2] -= tentacleIdleTimerDecrement; + if (NPC.ai[2] <= 0f) + NPC.ai[2] = -1f; } // Spawn gore - if (npc.localAI[2] == 0f) + if (NPC.localAI[2] == 0f) { if (!Main.dedServ) { - Gore.NewGore(npc.GetSource_FromAI(), new Vector2(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height)), npc.velocity, 378, npc.scale); - Gore.NewGore(npc.GetSource_FromAI(), new Vector2(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height)), npc.velocity, 379, npc.scale); - Gore.NewGore(npc.GetSource_FromAI(), new Vector2(npc.position.X + Main.rand.Next(npc.width), npc.position.Y + Main.rand.Next(npc.height)), npc.velocity, 380, npc.scale); + Gore.NewGore(NPC.GetSource_FromAI(), new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(NPC.height)), NPC.velocity, 378, NPC.scale); + Gore.NewGore(NPC.GetSource_FromAI(), new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(NPC.height)), NPC.velocity, 379, NPC.scale); + Gore.NewGore(NPC.GetSource_FromAI(), new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(NPC.height)), NPC.velocity, 380, NPC.scale); } - npc.localAI[2] = 1f; + NPC.localAI[2] = 1f; } if (!charging) { // Fire spreads of poison seeds - npc.localAI[3] += 1f; + NPC.localAI[3] += 1f; float shootProjectileGateValue = slowedDuringTentaclePhase ? 120f : 90f; - if (npc.localAI[3] >= shootProjectileGateValue) + if (NPC.localAI[3] >= shootProjectileGateValue) { float projectileSpeed = 14f; - if (bossRush) - projectileSpeed += 4f; - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); int spread = 8 + (int)Math.Round((0.5f - lifeRatio) * 16f); // 8 to 16, wider spread is harder to avoid int numProj = spread / 2; @@ -806,11 +798,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses numProj++; int type = ProjectileID.PoisonSeedPlantera; - int damage = npc.GetProjectileDamage(type); + int damage = PoisonSeedDamage; float rotation = MathHelper.ToRadians(spread); - bool vomitTentacles = vomitFreeTentacles && NPC.CountNPCS(ModContent.NPCType()) < maxTentaclesAfterFirstTentaclePhase; - if (vomitTentacles) - SoundEngine.PlaySound(SoundID.NPCDeath11, npc.Center); for (int i = 0; i < numProj; i++) { @@ -818,15 +807,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (shootPinkSeed) { type = ProjectileID.SeedPlantera; - damage = npc.GetProjectileDamage(type); + damage = PinkSeedDamage; } else type = ProjectileID.PoisonSeedPlantera; Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Vector2 spawnOffset = npc.Center + perturbedSpeed * 50f; + Vector2 spawnOffset = NPC.Center + perturbedSpeed * 50f; - int dustType = (shootPinkSeed && !vomitTentacles) ? 73 : 74; + int dustType = shootPinkSeed ? 73 : 74; Vector2 dustVelocity = perturbedSpeed * projectileSpeed; for (int k = 0; k < 5; k++) { @@ -836,17 +825,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (vomitTentacles) - { - int tentacle = NPC.NewNPC(npc.GetSource_FromAI(), (int)spawnOffset.X, (int)spawnOffset.Y, ModContent.NPCType(), 0, 120f, projectileSpeed); - Main.npc[tentacle].velocity.X = (perturbedSpeed * projectileSpeed * 0.5f).X; - Main.npc[tentacle].velocity.Y = (perturbedSpeed * projectileSpeed * 0.5f).Y; - Main.npc[tentacle].netUpdate = true; - } - else - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, perturbedSpeed * projectileSpeed * 0.5f, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileSpeed); - } + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnOffset, perturbedSpeed * projectileSpeed * 0.5f, type, damage, 0f, Main.myPlayer, 0f, 0f, projectileSpeed); } if (death) @@ -870,15 +849,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (shootThornBall) { type = ProjectileID.ThornBall; - damage = npc.GetProjectileDamage(type); - Vector2 spawnOffset = npc.Center + projectileVelocity * 50f; + damage = ThornBallDamage; + Vector2 spawnOffset = NPC.Center + projectileVelocity * 50f; if (Main.netMode != NetmodeID.MultiplayerClient) { float ai2 = 0f; if (Main.rand.NextBool() || !Main.zenithWorld) ai2 = 1f; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnOffset, projectileVelocity * projectileSpeed, type, damage, 0f, Main.myPlayer, 0f, 0f, ai2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnOffset, projectileVelocity * projectileSpeed, type, damage, 0f, Main.myPlayer, 0f, 0f, ai2); } } } @@ -887,13 +866,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { float sporeSpeed = 12f; Vector2 sporeVelocity = projectileVelocity * sporeSpeed; - int spore = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.Spore); + int spore = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.Spore); Main.npc[spore].velocity.X = sporeVelocity.X; Main.npc[spore].velocity.Y = sporeVelocity.Y; Main.npc[spore].netUpdate = true; } - npc.localAI[3] = 0f; + NPC.localAI[3] = 0f; } } } @@ -903,7 +882,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (Main.rand.NextBool(Main.IsItDay() ? 3 : 6)) { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Pixie, 0f, 0f, 200, default, 0.5f); + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Pixie, 0f, 0f, 200, default, 0.5f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0.75f; Main.dust[dust].fadeIn = 1.3f; @@ -912,7 +891,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Main.dust[dust].velocity = vector; vector = vector.SafeNormalize(Vector2.UnitY); vector *= 86f; - Main.dust[dust].position = npc.Center - vector; + Main.dust[dust].position = NPC.Center - vector; } // Heal, 100 (50 during daytime) seconds to reach full HP from 0 @@ -920,40 +899,40 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (calamityGlobalNPC.newAI[1] >= (Main.IsItDay() ? 30f : 60f)) { calamityGlobalNPC.newAI[1] = 0f; - npc.SyncExtraAI(); + NPC.SyncExtraAI(); if (Main.netMode != NetmodeID.MultiplayerClient) { - int healAmt = npc.lifeMax / 100; - if (healAmt > npc.lifeMax - npc.life) - healAmt = npc.lifeMax - npc.life; + int healAmt = NPC.lifeMax / 100; + if (healAmt > NPC.lifeMax - NPC.life) + healAmt = NPC.lifeMax - NPC.life; if (healAmt > 0) { - npc.life += healAmt; - npc.HealEffect(healAmt, true); - npc.netUpdate = true; + NPC.life += healAmt; + NPC.HealEffect(healAmt, true); + NPC.netUpdate = true; } } } } - if (npc.ai[0] == 0f && npc.life > 0) - npc.ai[0] = npc.lifeMax; + if (NPC.ai[0] == 0f && NPC.life > 0) + NPC.ai[0] = NPC.lifeMax; - if (npc.life > 0) + if (NPC.life > 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { - int healthInterval = death ? (int)(npc.lifeMax * 0.03) : (int)(npc.lifeMax * 0.04); - if ((npc.life + healthInterval) < npc.ai[0]) + int healthInterval = death ? (int)(NPC.lifeMax * 0.03) : (int)(NPC.lifeMax * 0.04); + if ((NPC.life + healthInterval) < NPC.ai[0]) { - npc.ai[0] = npc.life; + NPC.ai[0] = NPC.life; if (phase2) { - int spore = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.Spore, npc.whoAmI); - float sporeSpeed = death ? 9f : 6f; - Vector2 sporeVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * sporeSpeed; + int spore = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.Spore, NPC.whoAmI); + float sporeSpeed = death ? 8f : 6f; + Vector2 sporeVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * sporeSpeed; Main.npc[spore].velocity.X = sporeVelocity.X; Main.npc[spore].velocity.Y = sporeVelocity.Y; Main.npc[spore].netUpdate = true; @@ -965,714 +944,413 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedPlanterasHookAI(NPC npc, Mod mod) + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - // Variables - bool enrage = BossRushEvent.BossRushActive; - bool despawn = false; - bool death = CalamityWorld.death || enrage; + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + Texture2D npcTexture = TextureAssets.Npc[NPC.type].Value; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + var originalColor = NPC.GetAlpha(drawColor); + Color newColor = new Color(100, 255, 100, 255); + Vector2 glowOffset = Vector2.UnitY * -4f; + Vector2 drawPosition = NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY) + glowOffset; + var origin = NPC.frame.Size() / 2; - // Despawn if Plantera is gone - if (NPC.plantBoss < 0) + bool phase2 = lifeRatio <= 0.5f; + if (!phase2) { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - - return false; - } - - // Percent life remaining, Plantera - float lifeRatio = Main.npc[NPC.plantBoss].life / (float)Main.npc[NPC.plantBoss].lifeMax; - - // Despawn if Plantera's target is dead - if (Main.player[Main.npc[NPC.plantBoss].target].dead && !enrage) - despawn = true; - - // Enrage if Plantera's target is on the surface - if (!enrage && ((Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16.0 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > Main.UnderworldLayer * 16) | despawn)) - { - npc.localAI[0] -= 4f; - enrage = true; - } - - // Set centers for movement - if (Main.netMode == NetmodeID.MultiplayerClient) - { - if (npc.ai[0] == 0f) - npc.ai[0] = (int)(npc.Center.X / 16f); - if (npc.ai[1] == 0f) - npc.ai[1] = (int)(npc.Center.X / 16f); - } - - // Find new spot to move to after set time has passed - if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Move immediately - if (npc.ai[0] == 0f || npc.ai[1] == 0f) - npc.localAI[0] = 0f; - - // Timer dictating whether to pick a new location or not - float moveBoost = death ? 6f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - npc.localAI[0] -= 1f + moveBoost; - if (enrage) - npc.localAI[0] -= 6f; - - // Set timer to new amount if a different hook is currently moving - if (!despawn && npc.localAI[0] <= 0f && npc.ai[0] != 0f) + float telegraphTimer = Math.Abs(NPC.ai[1]); + bool startSeedGatlingSporeGasTelegraph = NPC.ai[1] > SeedGatlingColorChangeGateValue; + bool endSeedGatlingSporeGasTelegraph = NPC.ai[1] < -SeedGatlingDuration + SeedGatlingColorChangeDuration; + if (startSeedGatlingSporeGasTelegraph) { - foreach (NPC n in Main.ActiveNPCs) - { - 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); - } + float telegraphScalar = MathHelper.Clamp((telegraphTimer - SeedGatlingColorChangeGateValue) / SeedGatlingColorChangeDuration, 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); } - // Pick a location to move to - if (npc.localAI[0] <= 0f) + // -300 to -120 + else if (endSeedGatlingSporeGasTelegraph) { - // Reset timer - npc.localAI[0] = Main.rand.Next(300, 601); - - // Pick location - bool hookCanMove = false; - int hookMoveTries = 0; - while (!hookCanMove && hookMoveTries <= 1000) - { - hookMoveTries++; - - int targetTilePosX = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.X / 16f); - int targetTilePosY = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.Y / 16f); - - if (npc.ai[0] == 0f) - { - targetTilePosX = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.X + Main.npc[NPC.plantBoss].Center.X) / 32f); - targetTilePosY = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.Y + Main.npc[NPC.plantBoss].Center.Y) / 32f); - } - - if (despawn) - { - targetTilePosX = (int)Main.npc[NPC.plantBoss].position.X / 16; - targetTilePosY = (int)(Main.npc[NPC.plantBoss].position.Y + 400f) / 16; - } - - int hookTileOffset = 20; - hookTileOffset += (int)(100f * (hookMoveTries / 1000f)); - int hookTileX = targetTilePosX + Main.rand.Next(-hookTileOffset, hookTileOffset + 1); - int hookTileY = targetTilePosY + Main.rand.Next(-hookTileOffset, hookTileOffset + 1); - - try - { - if (WorldGen.SolidTile(hookTileX, hookTileY) || (Main.tile[hookTileX, hookTileY].WallType > 0 && (hookMoveTries > 500 || lifeRatio < 0.5f))) - { - hookCanMove = true; - npc.ai[0] = hookTileX; - npc.ai[1] = hookTileY; - npc.netUpdate = true; - } - } - catch - { - } - } + float telegraphScalar = MathHelper.Clamp((telegraphTimer - (SeedGatlingDuration - SeedGatlingColorChangeDuration)) / SeedGatlingColorChangeDuration, 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); } } - - // Movement to new location - if (npc.ai[0] > 0f && npc.ai[1] > 0f) - { - // Hook movement velocity - float velocityBoost = death ? 9f * (1f - lifeRatio) : 3f * (1f - lifeRatio); - float velocity = 7f + velocityBoost; - if (enrage) - velocity *= 2f; - if (despawn) - velocity *= 2f; - - // Moving to new location - Vector2 hookCenter = new Vector2(npc.Center.X, npc.Center.Y); - float hookMoveX = npc.ai[0] * 16f - 8f - hookCenter.X; - float hookMoveY = npc.ai[1] * 16f - 8f - hookCenter.Y; - float hookMoveDistance = (float)Math.Sqrt(hookMoveX * hookMoveX + hookMoveY * hookMoveY); - if (hookMoveDistance < 12f + velocity) - { - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && npc.localAI[3] == 1f) - { - npc.localAI[3] = 0f; - WorldGen.SpawnPlanteraThorns(npc.Center); - } - - npc.velocity.X = hookMoveX; - npc.velocity.Y = hookMoveY; - } - else - { - if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld) - npc.localAI[3] = 1f; - - hookMoveDistance = velocity / hookMoveDistance; - npc.velocity.X = hookMoveX * hookMoveDistance; - npc.velocity.Y = hookMoveY * hookMoveDistance; - } - - // Rotation - Vector2 hookCenterRotation = new Vector2(npc.Center.X, npc.Center.Y); - float plantXDirection = Main.npc[NPC.plantBoss].Center.X - hookCenterRotation.X; - float plantYDirection = Main.npc[NPC.plantBoss].Center.Y - hookCenterRotation.Y; - npc.rotation = (float)Math.Atan2(plantYDirection, plantXDirection) - MathHelper.PiOver2; - } - - return false; - } - - public static bool BuffedPlanterasTentacleAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - // Emit light - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0.2f, 0.4f, 0.1f); - - // Spore dust - if (Main.rand.NextBool(10)) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.JungleSpore, 0f, 0f, 250, default, 0.4f); - dust.fadeIn = 0.7f; - } - - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - - if (Main.getGoodWorld) - { - if (Main.rand.NextBool(5)) - npc.reflectsProjectiles = true; - else - npc.reflectsProjectiles = false; - } - - // Die if Plantera is gone - if (NPC.plantBoss < 0) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - - return false; - } - - // Set Plantera to a variable - int plantBoss = NPC.plantBoss; - - // Retract to be near Plantera while she's charging - bool planteraIsCharging = Main.npc[plantBoss].ai[3] <= -2f; - - // Become free if Plantera gets sick of your shit - if (Main.npc[plantBoss].ai[2] == -1f && npc.ai[2] != 1f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - npc.StrikeInstantKill(); - - return false; - } - - // 3 seconds of extending from Plantera to max length to prevent unfair hits - float extendTime = 180f; - if (planteraIsCharging) - { - npc.damage = 0; - - if (npc.localAI[0] > 0f) - { - npc.localAI[0] = 0f; - npc.SyncExtraAI(); - } - } - else if (npc.localAI[0] < extendTime) - { - npc.damage = npc.defDamage; - npc.localAI[0] += 1f; - if (npc.localAI[0] >= extendTime) - npc.SyncExtraAI(); - } - - // Movement variables - int maxOffset = 100; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[0] == 0f || npc.ai[1] == 0f) - { - npc.ai[0] = Main.rand.Next(-maxOffset, maxOffset + 1); - npc.ai[1] = Main.rand.Next(-maxOffset, maxOffset + 1); - npc.netUpdate = true; - } - } - - // Velocity and acceleration - float tentacleAcceleration = death ? 2.4f : 1.6f; - float extendedDistanceFromPlantera = Math.Abs(npc.ai[0] + npc.ai[1]) / maxOffset; - float tentacleDistance = MathHelper.Lerp(50f, 100f + (extendedDistanceFromPlantera * 300f), npc.localAI[0] / extendTime); - float deceleration = (death ? 0.5f : 0.8f) / (1f + extendedDistanceFromPlantera); - - if (death) - { - tentacleAcceleration *= 1.2f; - extendedDistanceFromPlantera *= 1.1f; - tentacleDistance *= 1.2f; - deceleration *= 0.75f; - } - - if (Main.getGoodWorld) - tentacleAcceleration += 4f; - - // Fast retraction - if (planteraIsCharging) - { - tentacleAcceleration *= 2f; - deceleration *= 0.5f; - } - - // Despawn if Plantera is gone - if (!Main.npc[plantBoss].active) - { - npc.active = false; - return false; - } - - // Movement - Vector2 planteraCenter = Main.npc[plantBoss].Center; - float plantXOffset = planteraCenter.X + npc.ai[0]; - float plantYOffset = planteraCenter.Y + npc.ai[1]; - float plantXDist = plantXOffset - planteraCenter.X; - float plantYDist = plantYOffset - planteraCenter.Y; - float plantTotalDist = (float)Math.Sqrt(plantXDist * plantXDist + plantYDist * plantYDist); - plantTotalDist = tentacleDistance / plantTotalDist; - plantXDist *= plantTotalDist; - plantYDist *= plantTotalDist; - - if (npc.position.X < planteraCenter.X + plantXDist) - { - npc.velocity.X += tentacleAcceleration; - if (npc.velocity.X < 0f && plantXDist > 0f) - npc.velocity.X *= deceleration; - } - else if (npc.position.X > planteraCenter.X + plantXDist) - { - npc.velocity.X -= tentacleAcceleration; - if (npc.velocity.X > 0f && plantXDist < 0f) - npc.velocity.X *= deceleration; - } - if (npc.position.Y < planteraCenter.Y + plantYDist) - { - npc.velocity.Y += tentacleAcceleration; - if (npc.velocity.Y < 0f && plantYDist > 0f) - npc.velocity.Y *= deceleration; - } - else if (npc.position.Y > planteraCenter.Y + plantYDist) - { - npc.velocity.Y -= tentacleAcceleration; - if (npc.velocity.Y > 0f && plantYDist < 0f) - npc.velocity.Y *= deceleration; - } - - float velocityLimit = 12f + 6f * extendedDistanceFromPlantera; - if (planteraIsCharging) - velocityLimit *= 1.5f; - if (npc.velocity.X > velocityLimit) - npc.velocity.X = velocityLimit; - if (npc.velocity.X < -velocityLimit) - npc.velocity.X = -velocityLimit; - if (npc.velocity.Y > velocityLimit) - npc.velocity.Y = velocityLimit; - if (npc.velocity.Y < -velocityLimit) - npc.velocity.Y = -velocityLimit; - - // Direction and rotation - if (plantXDist > 0f) - { - npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2(plantYDist, plantXDist); - } - if (plantXDist < 0f) - { - npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2(plantYDist, plantXDist) + MathHelper.Pi; - } - - return false; - } - - public static bool VanillaPlanteraAI(NPC npc, Mod mod) - { - bool flag39 = false; - bool flag40 = false; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (Main.player[npc.target].dead) - { - flag40 = true; - flag39 = true; - } - else if (Main.netMode != NetmodeID.MultiplayerClient && npc.target >= 0 && npc.target < Main.maxPlayers) - { - int despawnDistance = 4800; - if (npc.timeLeft < NPC.activeTime && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < (float)despawnDistance) - npc.timeLeft = NPC.activeTime; - } - - NPC.plantBoss = npc.whoAmI; - if (npc.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] = 1f; - int hook = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasHook, npc.whoAmI); - hook = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasHook, npc.whoAmI); - hook = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasHook, npc.whoAmI); - } - - int[] array2 = new int[3]; - float num775 = 0f; - float num776 = 0f; - int num777 = 0; - for (int num778 = 0; num778 < Main.maxNPCs; num778++) - { - if (Main.npc[num778].active && Main.npc[num778].aiStyle == NPCAIStyleID.PlanteraHook) - { - num775 += Main.npc[num778].Center.X; - num776 += Main.npc[num778].Center.Y; - array2[num777] = num778; - num777++; - if (num777 > 2) - break; - } - } - - num775 /= (float)num777; - num776 /= (float)num777; - float num779 = 2.5f; - float num780 = 0.025f; - if (npc.life < npc.lifeMax / 2) - { - num779 = 5f; - num780 = 0.05f; - } - - if (npc.life < npc.lifeMax / 4) - num779 = 7f; - - if (!Main.player[npc.target].ZoneJungle || (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 || Main.player[npc.target].position.Y > (float)(Main.UnderworldLayer * 16)) - { - flag39 = true; - num779 += 8f; - num780 = 0.15f; - } - - npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && flag39; - - if (Main.expertMode) - { - num779 += (Main.masterMode ? 2f : 1f); - num779 *= (Main.masterMode ? 1.2f : 1.1f); - num780 += (Main.masterMode ? 0.02f : 0.01f); - num780 *= (Main.masterMode ? 1.2f : 1.1f); - } - - if (Main.getGoodWorld) - { - num779 *= 1.15f; - num780 *= 1.15f; - } - - Vector2 vector97 = new Vector2(num775, num776); - 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; - num781 *= -1f; - num779 += 8f; - } - else if (phase1MoveAway) - { - num782 *= -1f; - num781 *= -1f; - num779 *= 1.5f; - num780 *= 2f; - } - - float num783 = (float)Math.Sqrt(num781 * num781 + num782 * num782); - int num784 = 500; - if (flag39) - num784 += 350; - - if (Main.expertMode) - num784 += (Main.masterMode ? 300 : 150); - - if (num783 >= (float)num784) - { - num783 = (float)num784 / num783; - num781 *= num783; - num782 *= num783; - } - - num775 += num781; - num776 += num782; - vector97 = npc.Center; - num781 = num775 - vector97.X; - num782 = num776 - vector97.Y; - num783 = (float)Math.Sqrt(num781 * num781 + num782 * num782); - if (num783 < num779) - { - num781 = npc.velocity.X; - num782 = npc.velocity.Y; - } else { - num783 = num779 / num783; - num781 *= num783; - num782 *= num783; - } + float telegraphTimer = Math.Abs(NPC.ai[3]); + bool startChargeTelegraph = NPC.ai[3] > ChargeTelegraphColorChangeGateValue; + bool endChargeTelegraph = NPC.ai[3] <= -2f; + if (startChargeTelegraph) + { + float telegraphScalar = MathHelper.Clamp((telegraphTimer - ChargeTelegraphColorChangeGateValue) / SeedGatlingColorChangeDuration, 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); + spriteBatch.Draw(npcTexture, drawPosition, NPC.frame, telegraphColor, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + } - if (npc.velocity.X < num781) - { - npc.velocity.X += num780; - if (npc.velocity.X < 0f && num781 > 0f) - npc.velocity.X += num780 * 2f; - } - else if (npc.velocity.X > num781) - { - npc.velocity.X -= num780; - if (npc.velocity.X > 0f && num781 < 0f) - npc.velocity.X -= num780 * 2f; - } + // -195 to -2 + else if (endChargeTelegraph) + { + float telegraphScalar = MathHelper.Clamp((Math.Abs(StopChargeGateValue) - telegraphTimer) / Math.Abs(StopChargeGateValue), 0f, 1f); + Color telegraphColor = Color.Lerp(originalColor, newColor, telegraphScalar); - if (npc.velocity.Y < num782) - { - npc.velocity.Y += num780; - if (npc.velocity.Y < 0f && num782 > 0f) - npc.velocity.Y += num780 * 2f; + if (CalamityClientConfig.Instance.Afterimages) + { + 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) + glowOffset; + 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); + } } - else if (npc.velocity.Y > num782) + } + + public class HookAI : VanillaAIOverride + { + public override bool AI(Mod mod) { - npc.velocity.Y -= num780; - if (npc.velocity.Y > 0f && num782 < 0f) - npc.velocity.Y -= num780 * 2f; - } + // Variables + bool enrage = false; + bool despawn = false; + bool death = CalamityWorld.death || enrage; - Vector2 vector98 = npc.Center; - float num785 = Main.player[npc.target].Center.X - vector98.X; - float num786 = Main.player[npc.target].Center.Y - vector98.Y; - npc.rotation = (float)Math.Atan2(num786, num785) + MathHelper.PiOver2; - if (npc.life > npc.lifeMax / 2) - { - npc.defense = 36; - if (flag39) - npc.defense *= 2; + // Despawn if Plantera is gone + if (NPC.plantBoss < 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.netMode == NetmodeID.MultiplayerClient) return false; + } - npc.localAI[1] += 1f; - if ((double)npc.life < (double)npc.lifeMax * 0.9) - npc.localAI[1] += 1f; + // Percent life remaining, Plantera + float lifeRatio = Main.npc[NPC.plantBoss].life / (float)Main.npc[NPC.plantBoss].lifeMax; - if ((double)npc.life < (double)npc.lifeMax * 0.8) - npc.localAI[1] += 1f; + // Despawn if Plantera's target is dead + if (Main.player[Main.npc[NPC.plantBoss].target].dead && !enrage) + despawn = true; - if ((double)npc.life < (double)npc.lifeMax * 0.7) - npc.localAI[1] += 1f; + // Enrage if Plantera's target is on the surface + if (!enrage && !BossRushEvent.BossRushActive && ((Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16.0 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > Main.UnderworldLayer * 16) | despawn)) + { + NPC.localAI[0] -= 4f; + enrage = true; + } - if ((double)npc.life < (double)npc.lifeMax * 0.6) - npc.localAI[1] += 1f; + // Set centers for movement + if (Main.netMode == NetmodeID.MultiplayerClient) + { + if (NPC.ai[0] == 0f) + NPC.ai[0] = (int)(NPC.Center.X / 16f); + if (NPC.ai[1] == 0f) + NPC.ai[1] = (int)(NPC.Center.X / 16f); + } - if (flag39) - npc.localAI[1] += 3f; + // Find new spot to move to after set time has passed + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Move immediately + if (NPC.ai[0] == 0f || NPC.ai[1] == 0f) + NPC.localAI[0] = 0f; - if (Main.expertMode) - npc.localAI[1] += (Main.masterMode ? 2f : 1f); + // Timer dictating whether to pick a new location or not + float moveBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + NPC.localAI[0] -= 1f + moveBoost; + if (enrage) + NPC.localAI[0] -= 6f; - if (Main.expertMode && npc.justHit && Main.rand.NextBool()) - npc.localAI[3] = (Main.masterMode ? 2f : 1f); + // Set timer to new amount if a different hook is currently moving + if (!despawn && NPC.localAI[0] <= 0f && NPC.ai[0] != 0f) + { + foreach (NPC n in Main.ActiveNPCs) + { + 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); + } + } + + // Pick a location to move to + if (NPC.localAI[0] <= 0f) + { + // Reset timer + NPC.localAI[0] = Main.rand.Next(300, 601); + + // Pick location + bool hookCanMove = false; + int hookMoveTries = 0; + while (!hookCanMove && hookMoveTries <= 1000) + { + hookMoveTries++; + + int targetTilePosX = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.X / 16f); + int targetTilePosY = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.Y / 16f); + + if (NPC.ai[0] == 0f) + { + targetTilePosX = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.X + Main.npc[NPC.plantBoss].Center.X) / 32f); + targetTilePosY = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.Y + Main.npc[NPC.plantBoss].Center.Y) / 32f); + } + + if (despawn) + { + targetTilePosX = (int)Main.npc[NPC.plantBoss].position.X / 16; + targetTilePosY = (int)(Main.npc[NPC.plantBoss].position.Y + 400f) / 16; + } + + int hookTileOffset = 20; + hookTileOffset += (int)(100f * (hookMoveTries / 1000f)); + int hookTileX = targetTilePosX + Main.rand.Next(-hookTileOffset, hookTileOffset + 1); + int hookTileY = targetTilePosY + Main.rand.Next(-hookTileOffset, hookTileOffset + 1); + + try + { + if (WorldGen.SolidTile(hookTileX, hookTileY) || (Main.tile[hookTileX, hookTileY].WallType > WallID.None && (hookMoveTries > 500 || lifeRatio < 0.5f))) + { + hookCanMove = true; + NPC.ai[0] = hookTileX; + NPC.ai[1] = hookTileY; + NPC.netUpdate = true; + } + } + catch + { + } + } + } + } + + // Movement to new location + if (NPC.ai[0] > 0f && NPC.ai[1] > 0f) + { + // Hook movement velocity + float velocityBoost = death ? 6f * (1f - lifeRatio) : 3f * (1f - lifeRatio); + float velocity = 7f + velocityBoost; + if (enrage) + velocity *= 2f; + if (despawn) + velocity *= 2f; + + // Moving to new location + Vector2 hookCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float hookMoveX = NPC.ai[0] * 16f - 8f - hookCenter.X; + float hookMoveY = NPC.ai[1] * 16f - 8f - hookCenter.Y; + float hookMoveDistance = (float)Math.Sqrt(hookMoveX * hookMoveX + hookMoveY * hookMoveY); + if (hookMoveDistance < 12f + velocity) + { + if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld && NPC.localAI[3] == 1f) + { + NPC.localAI[3] = 0f; + WorldGen.SpawnPlanteraThorns(NPC.Center); + } + + NPC.velocity.X = hookMoveX; + NPC.velocity.Y = hookMoveY; + } + else + { + if (Main.netMode != NetmodeID.MultiplayerClient && Main.getGoodWorld) + NPC.localAI[3] = 1f; + + hookMoveDistance = velocity / hookMoveDistance; + NPC.velocity.X = hookMoveX * hookMoveDistance; + NPC.velocity.Y = hookMoveY * hookMoveDistance; + } + + // Rotation + Vector2 hookCenterRotation = new Vector2(NPC.Center.X, NPC.Center.Y); + float plantXDirection = Main.npc[NPC.plantBoss].Center.X - hookCenterRotation.X; + float plantYDirection = Main.npc[NPC.plantBoss].Center.Y - hookCenterRotation.Y; + NPC.rotation = (float)Math.Atan2(plantYDirection, plantXDirection) - MathHelper.PiOver2; + } + + return false; + } + } + + public class TentacleAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + // Emit light + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0.2f, 0.4f, 0.1f); + + // Spore dust + if (Main.rand.NextBool(10)) + { + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.JungleSpore, 0f, 0f, 250, default, 0.4f); + dust.fadeIn = 0.7f; + } + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (Main.getGoodWorld) - npc.localAI[1] += 1f; + { + if (Main.rand.NextBool(5)) + NPC.reflectsProjectiles = true; + else + NPC.reflectsProjectiles = false; + } + + // Die if Plantera is gone + if (NPC.plantBoss < 0) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); - if (!(npc.localAI[1] > 80f)) return false; - - npc.localAI[1] = 0f; - bool flag41 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - if (npc.localAI[3] > 0f) - { - flag41 = true; - npc.localAI[3] = 0f; } - if (flag41) + // Set Plantera to a variable + int plantBoss = NPC.plantBoss; + + // Retract to be near Plantera while she's charging + bool planteraIsCharging = Main.npc[plantBoss].ai[3] <= -2f; + + // Become free if Plantera gets sick of your shit + if (Main.npc[plantBoss].ai[2] == -1f && NPC.ai[2] != 1f) { - Vector2 vector99 = npc.Center; - float num788 = 15f; - if (Main.expertMode) - num788 = Main.masterMode ? 19f : 17f; + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.StrikeInstantKill(); - float num789 = Main.player[npc.target].Center.X - vector99.X; - float num790 = Main.player[npc.target].Center.Y - vector99.Y; - float num791 = (float)Math.Sqrt(num789 * num789 + num790 * num790); - num791 = num788 / num791; - num789 *= num791; - num790 *= num791; - int type = Main.masterMode ? ProjectileID.PoisonSeedPlantera : ProjectileID.SeedPlantera; - int maxValue2 = 4; - int thornBallChance = 8; - if (Main.expertMode) + return false; + } + + // 3 seconds of extending from Plantera to max length to prevent unfair hits + float extendTime = 180f; + if (planteraIsCharging) + { + if (NPC.localAI[0] > 0f) { - maxValue2 = 2; - thornBallChance = Main.masterMode ? 5 : 6; + NPC.localAI[0] = 0f; + NPC.SyncExtraAI(); } + } + else if (NPC.localAI[0] < extendTime) + { + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= extendTime) + NPC.SyncExtraAI(); + } - if ((double)npc.life < npc.lifeMax * 0.8 && Main.rand.NextBool(maxValue2) && !Main.masterMode) + // Movement variables + int maxOffset = 100; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.ai[0] == 0f || NPC.ai[1] == 0f) { - npc.localAI[1] = -30f; - type = ProjectileID.PoisonSeedPlantera; + NPC.ai[0] = Main.rand.Next(-maxOffset, maxOffset + 1); + NPC.ai[1] = Main.rand.Next(-maxOffset, maxOffset + 1); + NPC.netUpdate = true; } - else if ((double)npc.life < npc.lifeMax * 0.8 && Main.rand.NextBool(thornBallChance)) - { - bool shootThornBall = true; - int numThornBalls = 0; - int thornBallLimit = 3; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active && Main.projectile[i].type == ProjectileID.ThornBall) - { - numThornBalls++; - if (numThornBalls >= thornBallLimit) - { - shootThornBall = false; - break; - } - } - } + } - npc.localAI[1] = shootThornBall ? -120f : -30f; - type = shootThornBall ? ProjectileID.ThornBall : ProjectileID.PoisonSeedPlantera; - } - else if (Main.masterMode) - npc.localAI[1] = -30f; + // Velocity and acceleration + float tentacleAcceleration = 1.6f; + float extendedDistanceFromPlantera = Math.Abs(NPC.ai[0] + NPC.ai[1]) / maxOffset; + float tentacleDistance = MathHelper.Lerp(50f, 100f + (extendedDistanceFromPlantera * 300f), NPC.localAI[0] / extendTime); + float deceleration = (death ? 0.5f : 0.8f) / (1f + extendedDistanceFromPlantera); - int damage = npc.GetProjectileDamage(type); - if (flag39) - damage *= 2; + if (death) + { + tentacleAcceleration *= 1.2f; + extendedDistanceFromPlantera *= 1.1f; + tentacleDistance *= 1.2f; + deceleration *= 0.75f; + } - Vector2 projectileVelocity = new Vector2(num789, num790); - 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; + if (Main.getGoodWorld) + tentacleAcceleration += 4f; + + // Fast retraction + if (planteraIsCharging) + { + tentacleAcceleration *= 2f; + deceleration *= 0.5f; + } + + // Despawn if Plantera is gone + if (!Main.npc[plantBoss].active) + { + NPC.active = false; + return false; + } + + // Movement + Vector2 planteraCenter = Main.npc[plantBoss].Center; + float plantXOffset = planteraCenter.X + NPC.ai[0]; + float plantYOffset = planteraCenter.Y + NPC.ai[1]; + float plantXDist = plantXOffset - planteraCenter.X; + float plantYDist = plantYOffset - planteraCenter.Y; + float plantTotalDist = (float)Math.Sqrt(plantXDist * plantXDist + plantYDist * plantYDist); + plantTotalDist = tentacleDistance / plantTotalDist; + plantXDist *= plantTotalDist; + plantYDist *= plantTotalDist; + + if (NPC.position.X < planteraCenter.X + plantXDist) + { + NPC.velocity.X += tentacleAcceleration; + if (NPC.velocity.X < 0f && plantXDist > 0f) + NPC.velocity.X *= deceleration; + } + else if (NPC.position.X > planteraCenter.X + plantXDist) + { + NPC.velocity.X -= tentacleAcceleration; + if (NPC.velocity.X > 0f && plantXDist < 0f) + NPC.velocity.X *= deceleration; + } + if (NPC.position.Y < planteraCenter.Y + plantYDist) + { + NPC.velocity.Y += tentacleAcceleration; + if (NPC.velocity.Y < 0f && plantYDist > 0f) + NPC.velocity.Y *= deceleration; + } + else if (NPC.position.Y > planteraCenter.Y + plantYDist) + { + NPC.velocity.Y -= tentacleAcceleration; + if (NPC.velocity.Y > 0f && plantYDist < 0f) + NPC.velocity.Y *= deceleration; + } + + float velocityLimit = 12f + 6f * extendedDistanceFromPlantera; + if (planteraIsCharging) + velocityLimit *= 1.5f; + if (NPC.velocity.X > velocityLimit) + NPC.velocity.X = velocityLimit; + if (NPC.velocity.X < -velocityLimit) + NPC.velocity.X = -velocityLimit; + if (NPC.velocity.Y > velocityLimit) + NPC.velocity.Y = velocityLimit; + if (NPC.velocity.Y < -velocityLimit) + NPC.velocity.Y = -velocityLimit; + + // Direction and rotation + if (plantXDist > 0f) + { + NPC.spriteDirection = 1; + NPC.rotation = (float)Math.Atan2(plantYDist, plantXDist); + } + if (plantXDist < 0f) + { + NPC.spriteDirection = -1; + NPC.rotation = (float)Math.Atan2(plantYDist, plantXDist) + MathHelper.Pi; } return false; } - - npc.defense = 10; - int setDamage = (int)Math.Round(npc.defDamage * 1.4); - if (flag39) - { - npc.defense *= 4; - setDamage *= 2; - } - - npc.damage = setDamage; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.localAI[0] == 1f) - { - npc.localAI[0] = 2f; - int num796 = Main.masterMode ? 12 : 8; - if (Main.getGoodWorld) - num796 += 6; - - for (int num797 = 0; num797 < num796; num797++) - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasTentacle, npc.whoAmI); - - if (Main.expertMode) - { - for (int num799 = 0; num799 < Main.maxNPCs; num799++) - { - if (Main.npc[num799].active && Main.npc[num799].aiStyle == NPCAIStyleID.PlanteraHook) - { - for (int num800 = 0; num800 < num796 / 2 - 1; num800++) - { - int num801 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasTentacle, npc.whoAmI); - Main.npc[num801].ai[3] = num799 + 1; - } - } - } - } - } - else if (Main.expertMode && Main.rand.NextBool(Main.masterMode ? 50 : 60)) - { - int num802 = 0; - for (int num803 = 0; num803 < Main.maxNPCs; num803++) - { - if (Main.npc[num803].active && Main.npc[num803].type == NPCID.PlanterasTentacle && Main.npc[num803].ai[3] == 0f) - num802++; - } - - if (num802 < (Main.masterMode ? 12 : 8) && Main.rand.Next((num802 + 1) * 10) <= 1) - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PlanterasTentacle, npc.whoAmI); - } - } - - if (npc.localAI[2] == 0f) - { - Gore.NewGore(npc.GetSource_FromAI(), new Vector2(npc.position.X + (float)Main.rand.Next(npc.width), npc.position.Y + (float)Main.rand.Next(npc.height)), npc.velocity, 378, npc.scale); - Gore.NewGore(npc.GetSource_FromAI(), new Vector2(npc.position.X + (float)Main.rand.Next(npc.width), npc.position.Y + (float)Main.rand.Next(npc.height)), npc.velocity, 379, npc.scale); - Gore.NewGore(npc.GetSource_FromAI(), new Vector2(npc.position.X + (float)Main.rand.Next(npc.width), npc.position.Y + (float)Main.rand.Next(npc.height)), npc.velocity, 380, npc.scale); - npc.localAI[2] = 1f; - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - return false; - - npc.localAI[1] += 1f; - if ((double)npc.life < (double)npc.lifeMax * 0.4) - npc.localAI[1] += 1f; - - if ((double)npc.life < (double)npc.lifeMax * 0.3) - npc.localAI[1] += 1f; - - if ((double)npc.life < (double)npc.lifeMax * 0.2) - npc.localAI[1] += 1f; - - if ((double)npc.life < (double)npc.lifeMax * 0.1) - npc.localAI[1] += 1f; - - if (npc.localAI[1] >= (Main.masterMode ? 200f : Main.expertMode ? 275f : 350f)) - { - float num805 = Main.masterMode ? 12f : Main.expertMode ? 10f : 8f; - Vector2 vector100 = npc.Center; - float num806 = Main.player[npc.target].Center.X - vector100.X; - float num807 = Math.Abs(num806 * 0.2f); - float num808 = Main.player[npc.target].Center.Y - vector100.Y; - if (num808 > 0f) - num807 = 0f; - - num808 -= num807; - float num809 = (float)Math.Sqrt(num806 * num806 + num808 * num808); - num809 = num805 / num809; - num806 *= num809; - num808 *= num809; - int num810 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.Spore); - Main.npc[num810].velocity.X = num806; - Main.npc[num810].velocity.Y = num808; - Main.npc[num810].netUpdate = true; - npc.localAI[1] = 0f; - } - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs index 65dc62059c..8c3203650f 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs @@ -13,22 +13,24 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class QueenBeeAI + public class QueenBeeAI : VanillaAIOverride { - public static bool BuffedQueenBeeAI(NPC npc, Mod mod) + // Vanilla values + public static int StingerDamage = 11; // 44; Also applies to GFB stinger replacements + + public override bool AI(Mod mod) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - bool enrage = true; - int targetTileX = (int)Main.player[npc.target].Center.X / 16; - int targetTileY = (int)Main.player[npc.target].Center.Y / 16; + bool enrage = !BossRushEvent.BossRushActive; + int targetTileX = (int)Main.player[NPC.target].Center.X / 16; + int targetTileY = (int)Main.player[NPC.target].Center.Y / 16; Tile tile = Framing.GetTileSafely(targetTileX, targetTileY); if (tile.WallType == WallID.HiveUnsafe) @@ -36,28 +38,25 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float maxEnrageScale = 2f; float enrageScale = death ? 0.5f : 0f; - if (((npc.position.Y / 16f) < Main.worldSurface && enrage) || bossRush) + if ((NPC.position.Y / 16f) < Main.worldSurface && enrage) { - calamityGlobalNPC.CurrentlyEnraged = !bossRush; - enrageScale += 0.5f; + calamityGlobalNPC.CurrentlyEnraged = true; + enrageScale += 1f; } - if (!Main.player[npc.target].ZoneJungle || bossRush) + if (!Main.player[NPC.target].ZoneJungle && enrage) { - calamityGlobalNPC.CurrentlyEnraged = !bossRush; - enrageScale += 0.5f; + calamityGlobalNPC.CurrentlyEnraged = true; + enrageScale += 1f; } if (Main.getGoodWorld) - enrageScale += ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 1f : 0.5f); - - if (bossRush) - enrageScale = 2f; + enrageScale += 0.5f; if (enrageScale > maxEnrageScale) enrageScale = maxEnrageScale; // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Bee spawn limit int beeLimit = death ? 9 : 15; @@ -81,7 +80,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Hornet spawn limit - int hornetLimit = 3; + int hornetLimit = 2; bool hornetLimitReached = false; // Only run this when necessary @@ -113,7 +112,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Become more aggressive and start firing double stingers (triple in death mode) phase bool phase2 = lifeRatio < 0.85f; - // Begin launching beehives instead of bees phase + // Stingers have slightly higher velocity bool phase3 = lifeRatio < 0.7f; // Stop spawning bees from ass and start performing stinger arcs + diagonal dashes, spawn bees while charging and become more aggressive phase @@ -126,104 +125,104 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool phase6 = lifeRatio < 0.1f; // Despawn - float distanceFromTarget = Vector2.Distance(npc.Center, Main.player[npc.target].Center); - if (npc.ai[0] != 6f) + float distanceFromTarget = Vector2.Distance(NPC.Center, Main.player[NPC.target].Center); + if (NPC.ai[0] != 7f) { - if (npc.timeLeft < 60) - npc.timeLeft = 60; + if (NPC.timeLeft < 60) + NPC.timeLeft = 60; if (distanceFromTarget > 3000f) - npc.ai[0] = 4f; + NPC.ai[0] = 4f; } - if (Main.player[npc.target].dead) - npc.ai[0] = 6f; + if (Main.player[NPC.target].dead) + NPC.ai[0] = 7f; // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = npc.ai[0] == 0f; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + bool immuneToSlowingDebuffs = NPC.ai[0] == 0f; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; // Always start in enemy spawning phase if (calamityGlobalNPC.newAI[3] == 0f) { calamityGlobalNPC.newAI[3] = 1f; - npc.ai[0] = 2f; - npc.netUpdate = true; - npc.SyncExtraAI(); + NPC.ai[0] = 2f; + NPC.netUpdate = true; + NPC.SyncExtraAI(); } // Despawn phase - if (npc.ai[0] == 6f) + if (NPC.ai[0] == 7f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.velocity.Y *= 0.98f; + NPC.velocity.Y *= 0.98f; - if (npc.velocity.X < 0f) - npc.direction = -1; + if (NPC.velocity.X < 0f) + NPC.direction = -1; else - npc.direction = 1; + NPC.direction = 1; - npc.spriteDirection = npc.direction; + NPC.spriteDirection = NPC.direction; - if (npc.position.X < (Main.maxTilesX * 8)) + if (NPC.position.X < (Main.maxTilesX * 8)) { - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= 0.98f; else - npc.localAI[0] = 1f; + NPC.localAI[0] = 1f; - npc.velocity.X -= 0.08f; + NPC.velocity.X -= 0.08f; } else { - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; + if (NPC.velocity.X < 0f) + NPC.velocity.X *= 0.98f; else - npc.localAI[0] = 1f; + NPC.localAI[0] = 1f; - npc.velocity.X += 0.08f; + NPC.velocity.X += 0.08f; } - if (npc.timeLeft > 10) - npc.timeLeft = 10; + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; } // Pick a random phase - else if (npc.ai[0] == -1f) + else if (NPC.ai[0] == -1f) { if (Main.netMode != NetmodeID.MultiplayerClient) { int phase; - int maxRandom = phase4 ? 5 : 4; + int maxRandom = phase4 ? (death ? 5 : 4) : 4; do phase = Main.rand.Next(maxRandom); - while (phase == npc.ai[1] || phase == 1 || (phase == 2 && phase4) || (death && phase6 && phase == 3)); + while (phase == NPC.ai[1] || phase == 1 || (phase == 2 && phase4) || (death && phase6 && phase == 3)); bool charging = phase == 0; + bool stingerArcs = phase == 4; // 5 is stinger arc and charge - if (phase == 4) + if (stingerArcs) phase = 5; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.ai[0] = phase; - npc.ai[1] = 0f; + + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPC.ai[0] = phase; + NPC.ai[1] = 0f; // Movement direction for the stinger arcs - npc.ai[2] = (phase == 5 && phase5) ? (Main.rand.NextBool() ? 1f : -1f) : phase == 5 ? 1f : 0f; + NPC.ai[2] = (phase == 5 && phase5) ? (Main.rand.NextBool() ? 1f : -1f) : phase == 5 ? 1f : 0f; // Velocity for the charges if (death) - npc.ai[3] = charging ? ((phase6 ? 27f : phase5 ? 16f : phase4 ? 27f : phase2 ? 22f : 17f) + 3f * enrageScale) : 0f; + NPC.ai[3] = charging ? ((phase6 ? 27f : phase5 ? 16f : phase4 ? 27f : phase2 ? 22f : 17f) + 3f * enrageScale) : 0f; else - npc.ai[3] = charging ? ((phase6 ? 25f : phase5 ? 14f : phase4 ? 25f : phase2 ? 20f : 15f) + 3f * enrageScale) : 0f; + NPC.ai[3] = charging ? ((phase6 ? 25f : phase5 ? 14f : phase4 ? 25f : phase2 ? 20f : 15f) + 3f * enrageScale) : 0f; // Distance for the charges if (death) @@ -231,12 +230,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else calamityGlobalNPC.newAI[1] = charging ? ((phase6 ? 750f : phase5 ? 350f : phase4 ? 650f : phase2 ? 550f : 450f) - 50f * enrageScale) : 0f; - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } } // Charging phase - else if (npc.ai[0] == 0f) + else if (NPC.ai[0] == 0f) { // Charging distance from player int chargeDistanceX = (int)calamityGlobalNPC.newAI[1]; @@ -246,179 +245,177 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) chargeAmt = phase6 ? 1 : phase5 ? 3 : phase4 ? 2 : 1; - int masterModeChargeLimit = death ? (phase5 ? 2 : 1) : (phase5 ? 3 : 2); - if (death && chargeAmt > masterModeChargeLimit) - chargeAmt = masterModeChargeLimit; + int deathChargeLimit = phase5 ? 3 : 2; + if (death && chargeAmt > deathChargeLimit) + chargeAmt = deathChargeLimit; // Switch to a random phase if chargeAmt has been exceeded - if (npc.ai[1] > (2 * chargeAmt) && npc.ai[1] % 2f == 0f) + if (NPC.ai[1] > (2 * chargeAmt) && NPC.ai[1] % 2f == 0f) { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = -1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; return false; } // Charge velocity - float velocity = npc.ai[3]; + float velocity = NPC.ai[3]; // Line up and initiate charge - if (npc.ai[1] % 2f == 0f) + if (NPC.ai[1] % 2f == 0f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; // Initiate charge float chargeDistanceY = phase6 ? 100f : phase4 ? 50f : 20f; chargeDistanceY += 50f * enrageScale; if (death) { - chargeDistanceY += MathHelper.Lerp(0f, 100f, 1f - lifeRatio); + chargeDistanceY += MathHelper.Lerp(0f, 100f, 1f - (lifeRatio / 2)); chargeDistanceY *= 2f; } - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y); + float distanceFromTargetX = Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X); + float distanceFromTargetY = Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y); if (distanceFromTargetY < chargeDistanceY && distanceFromTargetX >= chargeDistanceX) { // Set damage - npc.damage = npc.defDamage; + NPC.damage = NPC.defDamage; // Set AI variables and speed - npc.localAI[0] = 1f; - npc.ai[1] += 1f; - npc.ai[2] = 0f; + NPC.localAI[0] = 1f; + NPC.ai[1] += 1f; + NPC.ai[2] = 0f; // Get target location - Vector2 beeLocation = npc.Center; - float targetXDist = Main.player[npc.target].Center.X - beeLocation.X; - float targetYDist = Main.player[npc.target].Center.Y - beeLocation.Y; + Vector2 beeLocation = NPC.Center; + float targetXDist = Main.player[NPC.target].Center.X - beeLocation.X; + float targetYDist = Main.player[NPC.target].Center.Y - beeLocation.Y; float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); targetDistance = velocity / targetDistance; - npc.velocity.X = targetXDist * targetDistance; - npc.velocity.Y = targetYDist * targetDistance; + NPC.velocity.X = targetXDist * targetDistance; + NPC.velocity.Y = targetYDist * targetDistance; // Face the correct direction and play charge sound - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; - SoundEngine.PlaySound(SoundID.Zombie125, npc.Center); + SoundEngine.PlaySound(SoundID.Zombie125, NPC.Center); return false; } // Velocity variables - npc.localAI[0] = 0f; + NPC.localAI[0] = 0f; float chargeVelocityX = (phase4 ? 24f : phase2 ? 20f : 16f) + 8f * enrageScale; float chargeVelocityY = (phase4 ? 18f : phase2 ? 15f : 12f) + 6f * enrageScale; - float chargeAccelerationX = (phase4 ? 0.9f : phase2 ? 0.7f : 0.5f) + 0.25f * enrageScale; - float chargeAccelerationY = (phase4 ? 0.45f : phase2 ? 0.35f : 0.25f) + 0.125f * enrageScale; + float chargeAccelerationX = (phase4 ? 0.7f : phase2 ? 0.6f : 0.5f) + 0.25f * enrageScale; + float chargeAccelerationY = (phase4 ? 0.35f : phase2 ? 0.3f : 0.25f) + 0.125f * enrageScale; if (death) { - chargeVelocityX += 2f; - chargeVelocityY += 4f; - chargeAccelerationX += 0.15f; - chargeAccelerationY += 0.3f; + chargeVelocityX += 1f; + chargeVelocityY += 2f; + chargeAccelerationX += 0.1f; + chargeAccelerationY += 0.2f; } // Velocity calculations - if (npc.Center.Y < Main.player[npc.target].Center.Y - chargeDistanceY) - npc.velocity.Y += chargeAccelerationY; - else if (npc.Center.Y > Main.player[npc.target].Center.Y + chargeDistanceY) - npc.velocity.Y -= chargeAccelerationY; + if (NPC.Center.Y < Main.player[NPC.target].Center.Y - chargeDistanceY) + NPC.velocity.Y += chargeAccelerationY; + else if (NPC.Center.Y > Main.player[NPC.target].Center.Y + chargeDistanceY) + NPC.velocity.Y -= chargeAccelerationY; else - npc.velocity.Y *= 0.7f; + NPC.velocity.Y *= 0.7f; - if (npc.velocity.Y < -chargeVelocityY) - npc.velocity.Y = -chargeVelocityY; - if (npc.velocity.Y > chargeVelocityY) - npc.velocity.Y = chargeVelocityY; + if (NPC.velocity.Y < -chargeVelocityY) + NPC.velocity.Y = -chargeVelocityY; + if (NPC.velocity.Y > chargeVelocityY) + NPC.velocity.Y = chargeVelocityY; float distanceXMax = 100f; float distanceXMin = 20f; if (distanceFromTargetX > chargeDistanceX + distanceXMax) - npc.velocity.X += chargeAccelerationX * npc.direction; + NPC.velocity.X += chargeAccelerationX * NPC.direction; else if (distanceFromTargetX < chargeDistanceX + distanceXMin) - npc.velocity.X -= chargeAccelerationX * npc.direction; + NPC.velocity.X -= chargeAccelerationX * NPC.direction; else - npc.velocity.X *= 0.7f; + NPC.velocity.X *= 0.7f; // Limit velocity - if (npc.velocity.X < -chargeVelocityX) - npc.velocity.X = -chargeVelocityX; - if (npc.velocity.X > chargeVelocityX) - npc.velocity.X = chargeVelocityX; + if (NPC.velocity.X < -chargeVelocityX) + NPC.velocity.X = -chargeVelocityX; + if (NPC.velocity.X > chargeVelocityX) + NPC.velocity.X = chargeVelocityX; // Face the correct direction - float playerLocation2 = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation2 < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - npc.ForceNetUpdate(false); + float playerLocation2 = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation2 < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; + NPC.ForceNetUpdate(false); } else { // Set damage - npc.damage = npc.defDamage; + NPC.damage = NPC.defDamage; // Face the correct direction - if (npc.velocity.X < 0f) - npc.direction = -1; + if (NPC.velocity.X < 0f) + NPC.direction = -1; else - npc.direction = 1; + NPC.direction = 1; - npc.spriteDirection = npc.direction; + NPC.spriteDirection = NPC.direction; // Get which side of the player the boss is on int chargeDirection = 1; - if (npc.Center.X < Main.player[npc.target].Center.X) + if (NPC.Center.X < Main.player[NPC.target].Center.X) chargeDirection = -1; // If boss is in correct position, slow down, if not, reset bool shouldCharge = false; - if (npc.direction == chargeDirection && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > chargeDistanceX) + if (NPC.direction == chargeDirection && Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) > chargeDistanceX) { - npc.ai[2] = 1f; + NPC.ai[2] = 1f; shouldCharge = true; } - if (Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > chargeDistanceX * 1.5f) + if (Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > chargeDistanceX * 1.5f) { - npc.ai[2] = 1f; + NPC.ai[2] = 1f; shouldCharge = true; } if (enrageScale > 0f && shouldCharge) - npc.velocity *= MathHelper.Lerp(0.5f, death ? 0.9f : 1f, 1f - enrageScale / maxEnrageScale); + NPC.velocity *= MathHelper.Lerp(0.5f, death ? 0.9f : 1f, 1f - enrageScale / maxEnrageScale); // Keep moving - if (npc.ai[2] != 1f) + if (NPC.ai[2] != 1f) { // Velocity fix if Queen Bee is slowed - if (npc.velocity.Length() < velocity) - npc.velocity.X = velocity * npc.direction; + if (NPC.velocity.Length() < velocity) + NPC.velocity.X = velocity * NPC.direction; float accelerateGateValue = phase6 ? 30f : phase5 ? 10f : 90f; - if (death) - accelerateGateValue *= 0.75f; if (enrageScale > 0f) accelerateGateValue *= 0.75f; calamityGlobalNPC.newAI[0] += 1f; if (calamityGlobalNPC.newAI[0] > accelerateGateValue) { - npc.SyncExtraAI(); + NPC.SyncExtraAI(); float velocityXLimit = velocity * 2f; - if (Math.Abs(npc.velocity.X) < velocityXLimit) - npc.velocity.X *= (death ? 1.02f : 1.01f); + if (Math.Abs(NPC.velocity.X) < velocityXLimit) + NPC.velocity.X *= (death ? 1.02f : 1.01f); } // Spawn bees - float beeSpawnGateValue = death ? 16f : 20f; - bool spawnBee = phase4 && calamityGlobalNPC.newAI[0] % beeSpawnGateValue == 0f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + float beeSpawnGateValue = 20f; + bool spawnBee = phase4 && calamityGlobalNPC.newAI[0] % beeSpawnGateValue == 0f && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); if (spawnBee) { - SoundEngine.PlaySound(SoundID.NPCHit18, npc.Center); + SoundEngine.PlaySound(SoundID.NPCHit18, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -463,8 +460,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!beeLimitReached || !hornetLimitReached) { - int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, spawnType); - Vector2 beeVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); + int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, spawnType); + Vector2 beeVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); Main.npc[spawn].velocity = beeVelocity; Main.npc[spawn].velocity *= 5f; if (!Main.zenithWorld) @@ -478,226 +475,221 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.localAI[0] = 1f; + NPC.localAI[0] = 1f; return false; } // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; // Slow down - npc.localAI[0] = 0f; - npc.velocity *= (death ? 0.8f : 0.9f); + NPC.localAI[0] = 0f; + NPC.velocity *= (death ? 0.8f : 0.9f); float chargeDeceleration = death ? 0.2f : 0.1f; if (phase2) { - npc.velocity *= 0.9f; + NPC.velocity *= 0.9f; chargeDeceleration += 0.05f; } if (phase4) { - npc.velocity *= 0.8f; + NPC.velocity *= 0.8f; chargeDeceleration += 0.1f; } if (enrageScale > 0f) - npc.velocity *= MathHelper.Lerp(0.7f, 1f, 1f - enrageScale / maxEnrageScale); + NPC.velocity *= MathHelper.Lerp(0.7f, 1f, 1f - enrageScale / maxEnrageScale); - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < chargeDeceleration) + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < chargeDeceleration) { - npc.ai[2] = 0f; - npc.ai[1] += 1f; + NPC.ai[2] = 0f; + NPC.ai[1] += 1f; calamityGlobalNPC.newAI[0] = 0f; - npc.SyncExtraAI(); + NPC.SyncExtraAI(); } - npc.ForceNetUpdate(false); + NPC.ForceNetUpdate(false); } } // Fly above target before bee spawning phase - else if (npc.ai[0] == 2f) + else if (NPC.ai[0] == 2f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; // Direction - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; // Get target location - float beeAttackAccel = death ? 0.6f : 0.24f; + float beeAttackAccel = death ? 0.48f : 0.24f; float beeAttackSpeed = 12f + enrageScale * 3f; if (death) - beeAttackSpeed *= 1.5f; + beeAttackSpeed *= 1.35f; - bool canHitTarget = Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + bool canHitTarget = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); float distanceAboveTarget = !canHitTarget ? 0f : 320f; - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * distanceAboveTarget; - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * beeAttackSpeed; + Vector2 hoverDestination = Main.player[NPC.target].Center - Vector2.UnitY * distanceAboveTarget; + Vector2 idealVelocity = NPC.SafeDirectionTo(hoverDestination) * beeAttackSpeed; // Go to bee spawn phase calamityGlobalNPC.newAI[0] += 1f; - if ((Vector2.Distance(npc.Center, hoverDestination) < 400f && canHitTarget) || calamityGlobalNPC.newAI[0] >= (death ? 90f : 180f)) + if ((Vector2.Distance(NPC.Center, hoverDestination) < 400f && canHitTarget) || calamityGlobalNPC.newAI[0] >= (death ? 90f : 180f)) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; calamityGlobalNPC.newAI[0] = 0f; - npc.netUpdate = true; - npc.SyncExtraAI(); + NPC.netUpdate = true; + NPC.SyncExtraAI(); return false; } - npc.SimpleFlyMovement(idealVelocity, beeAttackAccel); + NPC.SimpleFlyMovement(idealVelocity, beeAttackAccel); } // Bee spawn phase - else if (npc.ai[0] == 1f) + else if (NPC.ai[0] == 1f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.localAI[0] = 0f; + NPC.localAI[0] = 0f; // Get target location and spawn bees from ass float beeAttackHoverSpeed = 16f + enrageScale * 4f; - float beeAttackHoverAccel = death ? 0.8f : 0.3f; + float beeAttackHoverAccel = death ? 0.6f : 0.3f; if (death) - beeAttackHoverSpeed *= 1.5f; + beeAttackHoverSpeed *= 1.35f; - Vector2 beeSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + Vector2 beeSpawnLocation = new Vector2(NPC.Center.X + (Main.rand.Next(20) * NPC.direction), NPC.position.Y + NPC.height * 0.8f); Vector2 beeSpawnCollisionLocation = new Vector2(beeSpawnLocation.X, beeSpawnLocation.Y - 30f); - bool canHitTarget = Collision.CanHit(beeSpawnCollisionLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : 320f); - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * beeAttackHoverSpeed; + bool canHitTarget = Collision.CanHit(beeSpawnCollisionLocation, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + Vector2 hoverDestination = Main.player[NPC.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : 320f); + Vector2 idealVelocity = NPC.SafeDirectionTo(hoverDestination) * beeAttackHoverSpeed; // Bee spawn timer - npc.ai[1] += 1f; + NPC.ai[1] += 1f; int beeSpawnTimer = 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) + if (Main.player[i].active && !Main.player[i].dead && (NPC.Center - Main.player[i].Center).Length() < 1000f) beeSpawnTimer++; } - npc.ai[1] += beeSpawnTimer / 2; + NPC.ai[1] += beeSpawnTimer / 2; if (phase2) - npc.ai[1] += 1f; + NPC.ai[1] += 1f; bool spawnBee = false; - float beeSpawnCheck = (phase3 ? 45f : 15f) - (phase3 ? 18f : 6f) * enrageScale; - if (npc.ai[1] > beeSpawnCheck) + float beeSpawnCheck = 9 * enrageScale; + if (NPC.ai[1] > beeSpawnCheck) { - npc.ai[1] = 0f; - npc.ai[2] += 1f; + NPC.ai[1] = 0f; + NPC.ai[2] += 1f; spawnBee = true; } // Spawn bees - if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && spawnBee && (!beeLimitReached || !hornetLimitReached)) + if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && spawnBee && (!beeLimitReached || !hornetLimitReached)) { SoundEngine.PlaySound(SoundID.NPCHit18, beeSpawnLocation); if (Main.netMode != NetmodeID.MultiplayerClient) { - if (phase3) + + int spawnType = Main.rand.Next(NPCID.Bee, NPCID.BeeSmall + 1); + if (Main.zenithWorld) { - Projectile.NewProjectile(npc.GetSource_FromAI(), beeSpawnLocation, (Main.player[npc.target].Center - beeSpawnLocation).SafeNormalize(Vector2.UnitY), ProjectileID.BeeHive, 0, 0f, Main.myPlayer, 0f, 0f, 1f); + if (phase3) + spawnType = Main.rand.NextBool(3) ? ModContent.NPCType() : ModContent.NPCType(); + else + spawnType = NPCID.Hellbat; } - else + else if (death) { - int spawnType = Main.rand.Next(NPCID.Bee, NPCID.BeeSmall + 1); - if (Main.zenithWorld) + int random = hornetLimitReached ? 0 : beeLimitReached ? Main.rand.Next(6, 12) : Main.rand.Next(12); + switch (random) { - if (phase3) - spawnType = Main.rand.NextBool(3) ? ModContent.NPCType() : ModContent.NPCType(); - else - spawnType = NPCID.Hellbat; + default: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + + case 6: + case 7: + case 8: + spawnType = NPCID.LittleHornetHoney; + break; + + case 9: + case 10: + spawnType = NPCID.HornetHoney; + break; + + case 11: + spawnType = NPCID.BigHornetHoney; + break; } - else if (death) - { - int random = hornetLimitReached ? 0 : beeLimitReached ? Main.rand.Next(6, 12) : Main.rand.Next(12); - switch (random) - { - default: - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - break; - - case 6: - case 7: - case 8: - spawnType = NPCID.LittleHornetHoney; - break; - - case 9: - case 10: - spawnType = NPCID.HornetHoney; - break; - - case 11: - spawnType = NPCID.BigHornetHoney; - break; - } - } - - int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)beeSpawnLocation.X, (int)beeSpawnLocation.Y, spawnType); - Vector2 beeVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - Main.npc[spawn].velocity = beeVelocity; - Main.npc[spawn].velocity *= 5f; - if (!Main.zenithWorld) - { - Main.npc[spawn].ai[2] = enrageScale; - Main.npc[spawn].ai[3] = 1f; - } - Main.npc[spawn].timeLeft = 600; - Main.npc[spawn].netUpdate = true; } + + int spawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)beeSpawnLocation.X, (int)beeSpawnLocation.Y, spawnType); + Vector2 beeVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); + Main.npc[spawn].velocity = beeVelocity; + Main.npc[spawn].velocity *= 5f; + if (!Main.zenithWorld) + { + Main.npc[spawn].ai[2] = enrageScale; + Main.npc[spawn].ai[3] = 1f; + } + Main.npc[spawn].timeLeft = 600; + Main.npc[spawn].netUpdate = true; + } } // Velocity calculations if target is too far away if (Vector2.Distance(beeSpawnLocation, hoverDestination) > 400f || !canHitTarget) - npc.SimpleFlyMovement(idealVelocity, beeAttackHoverAccel); + NPC.SimpleFlyMovement(idealVelocity, beeAttackHoverAccel); else - npc.velocity *= (death ? 0.8f : 0.85f); + NPC.velocity *= (death ? 0.8f : 0.85f); // Face the correct direction - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; // Go to a random phase - float numSpawns = phase3 ? (death ? 1f : 2f) : (death ? 3f : 5f); - if (npc.ai[2] > numSpawns || (beeLimitReached && hornetLimitReached)) + float numSpawns = death ? 3f : 5f; + if (NPC.ai[2] > numSpawns || (beeLimitReached && hornetLimitReached)) { - npc.ai[0] = -1f; - npc.ai[1] = 2f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = -1f; + NPC.ai[1] = 2f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } } // Stinger phase - else if (npc.ai[0] == 3f) + else if (NPC.ai[0] == 3f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; // Direction - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; // Get target location and shoot from ass float stingerAttackSpeed = 16f + enrageScale * 4f; @@ -707,23 +699,23 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) { - stingerAttackSpeed *= 1.1f; - stingerAttackAccel *= 1.2f; + stingerAttackSpeed *= 1.08f; + stingerAttackAccel *= 1.18f; } - Vector2 stingerSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - bool canHitTarget = Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : phase4 ? 400f : phase2 ? 360f : 320f); - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * stingerAttackSpeed; + Vector2 stingerSpawnLocation = new Vector2(NPC.Center.X + (Main.rand.Next(20) * NPC.direction), NPC.position.Y + NPC.height * 0.8f); + bool canHitTarget = Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + Vector2 hoverDestination = Main.player[NPC.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : phase4 ? 400f : phase2 ? 360f : 320f); + Vector2 idealVelocity = NPC.SafeDirectionTo(hoverDestination) * stingerAttackSpeed; - npc.ai[1] += 1f; + NPC.ai[1] += 1f; int stingerAttackTimer = phase6 ? 40 : phase2 ? 30 : 20; stingerAttackTimer -= (int)Math.Ceiling((phase6 ? 16f : phase2 ? 12f : 8f) * enrageScale); if (stingerAttackTimer < 5) stingerAttackTimer = 5; // Fire stingers - if (npc.ai[1] % stingerAttackTimer == (stingerAttackTimer - 1) && npc.Bottom.Y < Main.player[npc.target].Top.Y && Collision.CanHit(stingerSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (NPC.ai[1] % stingerAttackTimer == (stingerAttackTimer - 1) && NPC.Bottom.Y < Main.player[NPC.target].Top.Y && Collision.CanHit(stingerSpawnLocation, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { SoundEngine.PlaySound(SoundID.Item17, stingerSpawnLocation); if (Main.netMode != NetmodeID.MultiplayerClient) @@ -732,8 +724,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) stingerSpeed += 1f; - float stingerTargetX = Main.player[npc.target].Center.X - stingerSpawnLocation.X; - float stingerTargetY = Main.player[npc.target].Center.Y - stingerSpawnLocation.Y; + float stingerTargetX = Main.player[NPC.target].Center.X - stingerSpawnLocation.X; + float stingerTargetY = Main.player[NPC.target].Center.Y - stingerSpawnLocation.Y; float stingerTargetDist = (float)Math.Sqrt(stingerTargetX * stingerTargetX + stingerTargetY * stingerTargetY); stingerTargetDist = stingerSpeed / stingerTargetDist; stingerTargetX *= stingerTargetDist; @@ -741,7 +733,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 stingerVelocity = new Vector2(stingerTargetX, stingerTargetY); int type = Main.zenithWorld ? (phase3 ? ModContent.ProjectileType() : ProjectileID.FlamingWood) : ProjectileID.QueenBeeStinger; - int projectile = Projectile.NewProjectile(npc.GetSource_FromAI(), stingerSpawnLocation, stingerVelocity, type, Main.zenithWorld ? 25 : npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, (Main.zenithWorld && phase3) ? Main.player[npc.target].position.Y : 0f); + int projectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), stingerSpawnLocation, stingerVelocity, type, StingerDamage, 0f, Main.myPlayer, 0f, (Main.zenithWorld && phase3) ? Main.player[NPC.target].position.Y : 0f); Main.projectile[projectile].timeLeft = 1200; Main.projectile[projectile].extraUpdates = 1; @@ -750,7 +742,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int numExtraStingers = death ? (phase6 ? 4 : 2) : (phase6 ? 2 : 1); for (int i = 0; i < numExtraStingers; i++) { - projectile = Projectile.NewProjectile(npc.GetSource_FromAI(), stingerSpawnLocation + Main.rand.NextVector2CircularEdge(16f, 16f) * (i + 1), stingerVelocity * MathHelper.Lerp(0.75f, 1f, i / (float)numExtraStingers), type, Main.zenithWorld ? 25 : npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, (Main.zenithWorld && phase3) ? Main.player[npc.target].position.Y : 0f); + projectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), stingerSpawnLocation + Main.rand.NextVector2CircularEdge(16f, 16f) * (i + 1), stingerVelocity * MathHelper.Lerp(0.75f, 1f, i / (float)numExtraStingers), type, StingerDamage, 0f, Main.myPlayer, 0f, (Main.zenithWorld && phase3) ? Main.player[NPC.target].position.Y : 0f); Main.projectile[projectile].timeLeft = 1200; Main.projectile[projectile].extraUpdates = 1; } @@ -760,57 +752,57 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Movement calculations if (Vector2.Distance(stingerSpawnLocation, hoverDestination) > 40f || !canHitTarget) - npc.SimpleFlyMovement(idealVelocity, stingerAttackAccel); + NPC.SimpleFlyMovement(idealVelocity, stingerAttackAccel); // Go to a random phase float numStingerShots = phase6 ? 5f : phase2 ? 8f : 15f; if (death) numStingerShots = (float)Math.Round(numStingerShots * 0.5f); - if (npc.ai[1] > stingerAttackTimer * numStingerShots) + if (NPC.ai[1] > stingerAttackTimer * numStingerShots) { - npc.ai[0] = -1f; - npc.ai[1] = 3f; - npc.netUpdate = true; + NPC.ai[0] = -1f; + NPC.ai[1] = 3f; + NPC.netUpdate = true; } } - else if (npc.ai[0] == 4f) + else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.localAI[0] = 1f; + NPC.localAI[0] = 1f; float despawnVelMult = 14f; - Vector2 despawnTargetDist = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); + Vector2 despawnTargetDist = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY); despawnTargetDist *= 14f; - npc.velocity = (npc.velocity * despawnVelMult + despawnTargetDist) / (despawnVelMult + 1f); - if (npc.velocity.X < 0f) - npc.direction = -1; + NPC.velocity = (NPC.velocity * despawnVelMult + despawnTargetDist) / (despawnVelMult + 1f); + if (NPC.velocity.X < 0f) + NPC.direction = -1; else - npc.direction = 1; + NPC.direction = 1; - npc.spriteDirection = npc.direction; + NPC.spriteDirection = NPC.direction; if (distanceFromTarget < 2000f) { - npc.ai[0] = -1f; - npc.localAI[0] = 0f; + NPC.ai[0] = -1f; + NPC.localAI[0] = 0f; } } // Stinger arcs above the player - else if (npc.ai[0] == 5f) + else if (NPC.ai[0] == 5f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; // Direction - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0 ? 1 : -1; + NPC.spriteDirection = NPC.direction; // Get target location and shoot spreads from ass float stingerAttackSpeed = 20f + enrageScale * 4f; @@ -835,18 +827,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float stingerAttackTimer = (float)Math.Ceiling(phaseLimit / (numStingerArcs + 1)); float maxDistance = 480f; - float xLocationScale = MathHelper.Lerp(-maxDistance, maxDistance, npc.ai[1] / phaseLimit) * npc.ai[2]; - Vector2 stingerSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - bool canHitTarget = Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - Vector2 hoverDestination = Main.player[npc.target].Center + Vector2.UnitX * xLocationScale * (death ? 1.5f : 1.25f) - Vector2.UnitY * maxDistance; - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * stingerAttackSpeed; + float xLocationScale = MathHelper.Lerp(-maxDistance, maxDistance, NPC.ai[1] / phaseLimit) * NPC.ai[2]; + Vector2 stingerSpawnLocation = new Vector2(NPC.Center.X + (Main.rand.Next(20) * NPC.direction), NPC.position.Y + NPC.height * 0.8f); + bool canHitTarget = Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + Vector2 hoverDestination = Main.player[NPC.target].Center + Vector2.UnitX * xLocationScale * (death ? 1.35f : 1.25f) - Vector2.UnitY * maxDistance; + Vector2 idealVelocity = NPC.SafeDirectionTo(hoverDestination) * stingerAttackSpeed; // Fire stingers - bool canFireStingers = stingerSpawnLocation.Y < Main.player[npc.target].Top.Y - maxDistance * 0.8f || !canHitTarget; - if (canFireStingers && npc.ai[1] < phaseLimit) + bool canFireStingers = stingerSpawnLocation.Y < Main.player[NPC.target].Top.Y - maxDistance * 0.8f || !canHitTarget; + if (canFireStingers && NPC.ai[1] < phaseLimit) { - npc.ai[1] += 1f; - if (npc.ai[1] % stingerAttackTimer == 0f && npc.ai[1] != 0f && npc.ai[1] != phaseLimit) + NPC.ai[1] += 1f; + if (NPC.ai[1] % stingerAttackTimer == 0f && NPC.ai[1] != 0f && NPC.ai[1] != phaseLimit) { SoundEngine.PlaySound(SoundID.Item17, stingerSpawnLocation); if (Main.netMode != NetmodeID.MultiplayerClient) @@ -855,7 +847,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) stingerSpeed += 1f; - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * stingerSpeed; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * stingerSpeed; int type = Main.zenithWorld ? ModContent.ProjectileType() : ProjectileID.QueenBeeStinger; int numProj = death ? (phase6 ? 7 : phase5 ? 11 : 15) : (phase6 ? 5 : phase5 ? 9 : 13); int spread = phase6 ? 30 : phase5 ? 50 : 60; @@ -873,7 +865,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (i % 2f != 0f) perturbedSpeed *= 0.8f; - int projectile = Projectile.NewProjectile(npc.GetSource_FromAI(), stingerSpawnLocation + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 10f, perturbedSpeed, type, Main.zenithWorld ? 25 : npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, Main.player[npc.target].position.Y); + int projectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), stingerSpawnLocation + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 10f, perturbedSpeed, type, StingerDamage, 0f, Main.myPlayer, 0f, Main.player[NPC.target].position.Y); Main.projectile[projectile].timeLeft = 1200; Main.projectile[projectile].extraUpdates = 1; @@ -885,608 +877,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Go to a random phase after pausing for a bit - if (npc.ai[1] >= phaseLimit) + if (NPC.ai[1] >= phaseLimit) { - npc.ai[1] += 1f; + NPC.ai[1] += 1f; - if (npc.Distance(Main.player[npc.target].Center) > 400f || !canHitTarget) + if (NPC.Distance(Main.player[NPC.target].Center) > 400f || !canHitTarget) { - idealVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * stingerAttackSpeed; - npc.SimpleFlyMovement(idealVelocity * 0.5f, stingerAttackAccel * 0.5f); + idealVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * stingerAttackSpeed; + NPC.SimpleFlyMovement(idealVelocity * 0.5f, stingerAttackAccel * 0.5f); } else - npc.velocity *= 0.8f; + NPC.velocity *= 0.8f; - float idleTime = death ? 120f : 180f; - if (npc.ai[1] >= phaseLimit + idleTime) + float idleTime = death ? 140f : 180f; + if (NPC.ai[1] >= phaseLimit + idleTime) { - npc.ai[0] = -1f; - npc.ai[1] = 4f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.ai[0] = -1f; + NPC.ai[1] = 4f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } } else - npc.SimpleFlyMovement(idealVelocity, stingerAttackAccel); + NPC.SimpleFlyMovement(idealVelocity, stingerAttackAccel); } if (Main.dedServ) - npc.ForceNetUpdate(); - - return false; - } - - public static bool VanillaQueenBeeAI(NPC npc, Mod mod) - { - if (Main.expertMode) - { - int num643 = (int)(20f * (1f - (float)npc.life / (float)npc.lifeMax)); - npc.defense = npc.defDefense + num643; - } - - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - bool enrage = true; - int targetTileX = (int)Main.player[npc.target].Center.X / 16; - int targetTileY = (int)Main.player[npc.target].Center.Y / 16; - - Tile tile = Framing.GetTileSafely(targetTileX, targetTileY); - if (tile.WallType == WallID.HiveUnsafe) - enrage = false; - - bool dead4 = Main.player[npc.target].dead; - float num644 = 0f; - if ((double)(npc.position.Y / 16f) < Main.worldSurface && enrage) - num644 += 1f; - - if (!Main.player[npc.target].ZoneJungle) - num644 += 1f; - - npc.Calamity().CurrentlyEnraged = num644 > 0f; - - if (Main.getGoodWorld) - num644 += 0.5f; - - float num645 = Vector2.Distance(npc.Center, Main.player[npc.target].Center); - if (npc.ai[0] != 5f) - { - if (npc.timeLeft < 60) - npc.timeLeft = 60; - - if (num645 > 3000f) - { - npc.ai[0] = 4f; - npc.netUpdate = true; - } - } - - if (dead4) - { - npc.ai[0] = 5f; - npc.netUpdate = true; - } - - if (npc.ai[0] == 5f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.Y *= 0.98f; - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - if (npc.position.X < (float)(Main.maxTilesX * 8)) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; - else - npc.localAI[0] = 1f; - - npc.velocity.X -= 0.08f; - } - else - { - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; - else - npc.localAI[0] = 1f; - - npc.velocity.X += 0.08f; - } - - npc.EncourageDespawn(10); - } - else if (npc.ai[0] == -1f) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - return false; - - float num646 = npc.ai[1]; - int num647; - do - { - num647 = Main.rand.Next(3); - switch (num647) - { - case 1: - num647 = 2; - break; - case 2: - num647 = 3; - break; - } - } - while ((float)num647 == num646); - - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.ai[0] = num647; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - else if (npc.ai[0] == 0f) - { - // Charging distance from player - int chargeDistanceX = Main.masterMode ? 425 : 600; - if (Main.expertMode) - { - int chargeDistanceReduction = Main.masterMode ? 25 : 50; - if ((double)npc.life < (double)npc.lifeMax * 0.1) - chargeDistanceX -= chargeDistanceReduction * 6; - else if ((double)npc.life < (double)npc.lifeMax * 0.25) - chargeDistanceX -= chargeDistanceReduction * 3; - else if ((double)npc.life < (double)npc.lifeMax * 0.5) - chargeDistanceX -= chargeDistanceReduction * 2; - else if ((double)npc.life < (double)npc.lifeMax * 0.75) - chargeDistanceX -= chargeDistanceReduction; - } - chargeDistanceX -= (int)(100f * num644); - - int num648 = Main.masterMode ? 1 : 2; - if (Main.expertMode) - { - if (npc.life < npc.lifeMax / 2 && !Main.masterMode) - num648++; - - if (npc.life < npc.lifeMax / 3) - num648++; - - if (npc.life < npc.lifeMax / 5) - num648++; - } - - num648 += (int)(1f * num644); - if (npc.ai[1] > (float)(2 * num648) && npc.ai[1] % 2f == 0f) - { - npc.ai[0] = -1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - return false; - } - - if (npc.ai[1] % 2f == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float chargeDistanceY = 20f; - chargeDistanceY += 20f * num644; - - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); - float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y); - if (distanceFromTargetY < chargeDistanceY && distanceFromTargetX >= chargeDistanceX) - { - // Set damage - npc.damage = npc.defDamage; - - npc.localAI[0] = 1f; - npc.ai[1] += 1f; - npc.ai[2] = 0f; - npc.netUpdate = true; - float num650 = 12f; - if (Main.expertMode) - { - num650 = Main.masterMode ? 20f : 16f; - float chargeVelocityIncrease = Main.masterMode ? 1.5f : 2f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - num650 += chargeVelocityIncrease; - - if ((double)npc.life < (double)npc.lifeMax * 0.5) - num650 += chargeVelocityIncrease; - - if ((double)npc.life < (double)npc.lifeMax * 0.25) - num650 += chargeVelocityIncrease; - - if ((double)npc.life < (double)npc.lifeMax * 0.1) - num650 += chargeVelocityIncrease; - } - - num650 += 7f * num644; - Vector2 vector82 = npc.Center; - float num651 = Main.player[npc.target].Center.X - vector82.X; - float num652 = Main.player[npc.target].Center.Y - vector82.Y; - float num653 = (float)Math.Sqrt(num651 * num651 + num652 * num652); - num653 = num650 / num653; - npc.velocity.X = num651 * num653; - npc.velocity.Y = num652 * num653; - - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - - SoundEngine.PlaySound(SoundID.Zombie125, npc.Center); - - return false; - } - - npc.localAI[0] = 0f; - float num654 = Main.masterMode ? 16f : 12f; - float num655 = Main.masterMode ? 0.3f : 0.15f; - if (Main.expertMode) - { - float chargeLineUpVelocityIncrease = Main.masterMode ? 0.5f : 1f; - float chargeLineUpAccelerationIncrease = Main.masterMode ? 0.025f : 0.05f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - { - num654 += chargeLineUpVelocityIncrease; - num655 += chargeLineUpAccelerationIncrease; - } - - if ((double)npc.life < (double)npc.lifeMax * 0.5) - { - num654 += chargeLineUpVelocityIncrease; - num655 += chargeLineUpAccelerationIncrease; - } - - if ((double)npc.life < (double)npc.lifeMax * 0.25) - { - num654 += chargeLineUpVelocityIncrease * 2f; - num655 += chargeLineUpAccelerationIncrease; - } - - if ((double)npc.life < (double)npc.lifeMax * 0.1) - { - num654 += chargeLineUpVelocityIncrease * 2f; - num655 += chargeLineUpAccelerationIncrease * 2f; - } - } - - num654 += 3f * num644; - num655 += 0.5f * num644; - - // Velocity calculations - if (npc.Center.Y < Main.player[npc.target].Center.Y - chargeDistanceY) - npc.velocity.Y += num655; - else if (npc.Center.Y > Main.player[npc.target].Center.Y + chargeDistanceY) - npc.velocity.Y -= num655; - else - npc.velocity.Y *= 0.7f; - - if (npc.velocity.Y < -num654) - npc.velocity.Y = -num654; - if (npc.velocity.Y > num654) - npc.velocity.Y = num654; - - float distanceXMax = 100f; - float distanceXMin = 20f; - if (distanceFromTargetX > chargeDistanceX + distanceXMax) - npc.velocity.X += 0.15f * npc.direction; - else if (distanceFromTargetX < chargeDistanceX + distanceXMin) - npc.velocity.X -= 0.15f * npc.direction; - else - npc.velocity.X *= 0.7f; - - if (npc.velocity.X < -16f) - npc.velocity.X = -16f; - if (npc.velocity.X > 16f) - npc.velocity.X = 16f; - - // Face the correct direction - float playerLocation2 = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation2 < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - - return false; - } - - // Set damage - npc.damage = npc.defDamage; - - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - - int num657 = 1; - if (npc.Center.X < Main.player[npc.target].Center.X) - num657 = -1; - - bool flag34 = false; - if (npc.direction == num657 && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > (float)chargeDistanceX) - { - npc.ai[2] = 1f; - flag34 = true; - } - - if (Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > (float)chargeDistanceX * 1.5f) - { - npc.ai[2] = 1f; - flag34 = true; - } - - if (num644 > 0f && flag34) - npc.velocity *= 0.5f; - - if (npc.ai[2] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - - npc.localAI[0] = 0f; - - npc.velocity *= (Main.masterMode ? 0.8f : 0.9f); - float num658 = Main.masterMode ? 0.2f : 0.1f; - if (Main.expertMode) - { - float velocityMultiplier = Main.masterMode ? 0.925f : 0.9f; - float velocityGateValueIncrease = Main.masterMode ? 0.025f : 0.05f; - if (npc.life < npc.lifeMax / 2) - { - npc.velocity *= velocityMultiplier; - num658 += velocityGateValueIncrease; - } - - if (npc.life < npc.lifeMax / 3) - { - npc.velocity *= velocityMultiplier; - num658 += velocityGateValueIncrease; - } - - if (npc.life < npc.lifeMax / 5) - { - npc.velocity *= velocityMultiplier; - num658 += velocityGateValueIncrease; - } - } - - if (num644 > 0f) - npc.velocity *= 0.7f; - - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num658) - { - npc.ai[2] = 0f; - npc.ai[1] += 1f; - npc.netUpdate = true; - } - } - else - npc.localAI[0] = 1f; - } - else if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - - float num659 = Main.masterMode ? 14f : 12f; - float num660 = 0.14f; - if (Main.expertMode) - num660 = Main.masterMode ? 0.3f : 0.2f; - - bool canHitTarget = Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - float distanceAboveTarget = !canHitTarget ? 0f : 320f; - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * distanceAboveTarget; - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * num659; - - if (Vector2.Distance(npc.Center, hoverDestination) < 200f && canHitTarget) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - return false; - } - - npc.SimpleFlyMovement(idealVelocity, num660); - } - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.localAI[0] = 0f; - - float num672 = Main.masterMode ? 16f : 14f; - float num673 = Main.masterMode ? 0.15f : 0.1f; - - Vector2 beeSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - Vector2 beeSpawnCollisionLocation = new Vector2(beeSpawnLocation.X, beeSpawnLocation.Y - 30f); - bool canHitTarget = Collision.CanHit(beeSpawnCollisionLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : 320f); - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * num672; - - npc.ai[1] += (Main.masterMode ? 2f : 1f); - if (Main.expertMode) - { - int num667 = 0; - for (int num668 = 0; num668 < Main.maxPlayers; num668++) - { - if (Main.player[num668].active && !Main.player[num668].dead && (npc.Center - Main.player[num668].Center).Length() < 1000f) - num667++; - } - - npc.ai[1] += num667 / 2; - float beeTimerIncrease = Main.masterMode ? 0.125f : 0.25f; - if ((double)npc.life < (double)npc.lifeMax * 0.75) - npc.ai[1] += beeTimerIncrease; - - if ((double)npc.life < (double)npc.lifeMax * 0.5) - npc.ai[1] += beeTimerIncrease; - - if ((double)npc.life < (double)npc.lifeMax * 0.25) - npc.ai[1] += beeTimerIncrease; - - if ((double)npc.life < (double)npc.lifeMax * 0.1) - npc.ai[1] += beeTimerIncrease; - } - - bool flag35 = false; - int num669 = (int)(40f - 18f * num644); - if (npc.ai[1] > (float)num669) - { - npc.ai[1] = 0f; - npc.ai[2]++; - flag35 = true; - } - - if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && flag35) - { - SoundEngine.PlaySound(SoundID.NPCHit18, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num670 = Main.rand.Next(NPCID.Bee, NPCID.BeeSmall + 1); - int num671 = NPC.NewNPC(npc.GetSource_FromAI(), (int)beeSpawnLocation.X, (int)beeSpawnLocation.Y, num670); - Vector2 beeVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - Main.npc[num671].velocity = beeVelocity; - Main.npc[num671].velocity *= 5f; - Main.npc[num671].CanBeReplacedByOtherNPCs = true; - Main.npc[num671].localAI[0] = 60f; - Main.npc[num671].netUpdate = true; - } - } - - // Velocity calculations if target is too far away - if (Vector2.Distance(beeSpawnLocation, hoverDestination) > 400f || !canHitTarget) - npc.SimpleFlyMovement(idealVelocity, num673); - else - npc.velocity *= (Main.masterMode ? 0.8f : 0.9f); - - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - - float maxBees = Main.masterMode ? 8f : 5f; - if (npc.ai[2] > maxBees) - { - npc.ai[0] = -1f; - npc.ai[1] = 1f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - - float num674 = 12f; - float num675 = 0.1f; - if (Main.expertMode) - { - num675 = Main.masterMode ? 0.2f : 0.15f; - num674 = Main.masterMode ? 16f : 14f; - } - num675 += 0.2f * num644; - num674 += 6f * num644; - - Vector2 stingerSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - bool canHitTarget = Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : 300f); - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * num674; - - npc.ai[1] += 1f; - int num679 = 40; - if (Main.masterMode) - num679 = (((double)npc.life < (double)npc.lifeMax * 0.1) ? 10 : ((npc.life < npc.lifeMax / 3) ? 15 : ((npc.life >= npc.lifeMax / 2) ? 25 : 20))); - else if (Main.expertMode) - num679 = (((double)npc.life < (double)npc.lifeMax * 0.1) ? 15 : ((npc.life < npc.lifeMax / 3) ? 25 : ((npc.life >= npc.lifeMax / 2) ? 35 : 30))); - - num679 -= (int)((Main.masterMode ? 3f : 5f) * num644); - if (npc.ai[1] % (float)num679 == (float)(num679 - 1) && npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && Collision.CanHit(stingerSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - SoundEngine.PlaySound(SoundID.Item17, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num680 = Main.masterMode ? 11f : 8f; - float stingerVelocityIncrease = Main.masterMode ? 1f : 2f; - if (Main.expertMode) - num680 += stingerVelocityIncrease; - - if (Main.expertMode && (double)npc.life < (double)npc.lifeMax * 0.1) - num680 += stingerVelocityIncrease * 1.5f; - - num680 += 7f * num644; - int num681 = (int)(12f - 5f * num644); - int num682 = (int)(6f - 2f * num644); - if (num681 < 1) - num681 = 1; - - if (num682 < 1) - num682 = 1; - - float num683 = Main.player[npc.target].Center.X - stingerSpawnLocation.X + (float)Main.rand.Next(-num681, num681 + 1); - float num684 = Main.player[npc.target].Center.Y - stingerSpawnLocation.Y + (float)Main.rand.Next(-num682, num682 + 1); - float num685 = (float)Math.Sqrt(num683 * num683 + num684 * num684); - num685 = num680 / num685; - num683 *= num685; - num684 *= num685; - int type = ProjectileID.QueenBeeStinger; - int num688 = Projectile.NewProjectile(npc.GetSource_FromAI(), stingerSpawnLocation.X, stingerSpawnLocation.Y, num683, num684, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - Main.projectile[num688].timeLeft = 300; - } - } - - if (Vector2.Distance(stingerSpawnLocation, hoverDestination) > 40f || !canHitTarget) - npc.SimpleFlyMovement(idealVelocity, num675); - - float num689 = Main.masterMode ? 16f : 20f; - num689 -= 5f * num644; - if (npc.ai[1] > (float)num679 * num689) - { - npc.ai[0] = -1f; - npc.ai[1] = 3f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.localAI[0] = 1f; - float num690 = 14f; - float num691 = 14f; - Vector2 vector88 = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); - vector88 *= num690; - npc.velocity = (npc.velocity * num691 + vector88) / (num691 + 1f); - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - if (num645 < 2000f) - { - npc.ai[0] = -1f; - npc.localAI[0] = 0f; - } - } + NPC.ForceNetUpdate(); return false; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs index 9e895f7809..04e40a86a0 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs @@ -10,16 +10,21 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class QueenSlimeAI + public class QueenSlimeAI : VanillaAIOverride { - public static bool BuffedQueenSlimeAI(NPC npc, Mod mod) + // Vanilla values + public static int SmallGelDamage = Main.masterMode ? 20 : 17; // 68 + public static int SpikeDamage = Main.masterMode ? 20 : 17; // 68 + public static int LargeGelDamage = 30; // 120 + public static int SlamDamage = 40; // 160 + + public override bool AI(Mod mod) { // Difficulty bools - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; float slimeScale = 1f; bool teleported = false; @@ -29,53 +34,64 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool phase5 = lifeRatio <= 0.25f && death; // Spawn settings - if (npc.localAI[0] == 0f) + if (NPC.localAI[0] == 0f) { - npc.ai[1] = -20f; - npc.localAI[0] = npc.lifeMax; + NPC.ai[1] = -20f; + NPC.localAI[0] = NPC.lifeMax; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - npc.netUpdate = true; + NPC.netUpdate = true; } // Emit light - Lighting.AddLight(npc.Center, 1f, 0.7f, 0.9f); + Lighting.AddLight(NPC.Center, 1f, 0.7f, 0.9f); // Despawn int despawnDistanceInTiles = 500; - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) { - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) { - npc.EncourageDespawn(10); - if (Main.player[npc.target].Center.X < npc.Center.X) - npc.direction = 1; + NPC.EncourageDespawn(10); + if (Main.player[NPC.target].Center.X < NPC.Center.X) + NPC.direction = 1; else - npc.direction = -1; + NPC.direction = -1; + } + } + + // Slow down dramatically while teleporting + if (NPC.ai[0] == 1f || NPC.ai[0] == 2f) + { + if (Math.Abs(NPC.velocity.X) > 0.1f) + { + NPC.velocity.X *= 0.8f; + if (Math.Abs(NPC.velocity.X) <= 0.1f) + NPC.velocity.X = 0f; } } // Teleport float teleportGateValue = death ? 300f : 600f; - if (!Main.player[npc.target].dead && npc.timeLeft > 10 && !phase2 && npc.ai[3] >= teleportGateValue && npc.ai[0] == 0f && npc.velocity.Y == 0f) + if (!Main.player[NPC.target].dead && NPC.timeLeft > 10 && !phase2 && NPC.ai[3] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.ai[0] = 2f; - npc.ai[1] = 0f; + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.netUpdate = true; - + NPC.netUpdate = true; + CalamityTargetingParameters options = CalamityTargetingParameters.Defaults; options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); + CalamityUtils.CalamityTargeting(NPC, options); - Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; + Vector2 vectorAimedAheadOfTarget = Main.player[NPC.target].Center + new Vector2((float)Math.Round(Main.player[NPC.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); int randomTeleportOffset = 5; int teleportTries = 0; @@ -90,14 +106,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool canTeleportToTile = true; if (canTeleportToTile && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) canTeleportToTile = false; - if (canTeleportToTile && !Collision.CanHitLine(npc.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + if (canTeleportToTile && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) canTeleportToTile = false; if (canTeleportToTile) { - npc.localAI[1] = teleportTileX * 16 + 8; - npc.localAI[2] = teleportTileY * 16 + 16; - npc.ai[3] = 0f; + NPC.localAI[1] = teleportTileX * 16 + 8; + NPC.localAI[2] = teleportTileY * 16 + 16; + NPC.ai[3] = 0f; break; } } @@ -105,10 +121,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Default teleport if the above conditions aren't met in 100 iterations if (teleportTries >= 100) { - Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; - npc.localAI[1] = bottom.X; - npc.localAI[2] = bottom.Y; - npc.ai[3] = 0f; + Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; + NPC.localAI[1] = bottom.X; + NPC.localAI[2] = bottom.Y; + NPC.ai[3] = 0f; } } } @@ -116,169 +132,169 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Get ready to teleport by increasing ai[3] if (!phase2) { - if (npc.ai[3] < teleportGateValue) + if (NPC.ai[3] < teleportGateValue) { - if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > 320f) - npc.ai[3] += death ? 3f : 2f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0) || Math.Abs(NPC.Top.Y - Main.player[NPC.target].Bottom.Y) > 320f) + NPC.ai[3] += death ? 3f : 2f; else - npc.ai[3] += 1f; + NPC.ai[3] += 1f; } } else { - float teleportNetUpdate = npc.ai[3]; - npc.ai[3] -= 1f; - if (npc.ai[3] < 0f) + float teleportNetUpdate = NPC.ai[3]; + NPC.ai[3] -= 1f; + if (NPC.ai[3] < 0f) { if (Main.netMode != NetmodeID.MultiplayerClient && teleportNetUpdate > 0f) - npc.netUpdate = true; + NPC.netUpdate = true; - npc.ai[3] = 0f; + NPC.ai[3] = 0f; } } // Reset variables if despawning - if (npc.timeLeft <= 10 && ((phase2 && npc.ai[0] != 0f) || (!phase2 && npc.ai[0] != 3f))) + if (NPC.timeLeft <= 10 && ((phase2 && NPC.ai[0] != 0f) || (!phase2 && NPC.ai[0] != 3f))) { if (phase2) - npc.ai[0] = 0f; + NPC.ai[0] = 0f; else - npc.ai[0] = 3f; + NPC.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; } - npc.noTileCollide = false; - npc.noGravity = false; + NPC.noTileCollide = false; + NPC.noGravity = false; // Frame data shit I guess? if (phase2) { - npc.localAI[3] += 1f; - if (npc.localAI[3] >= 24f) - npc.localAI[3] = 0f; + NPC.localAI[3] += 1f; + if (NPC.localAI[3] >= 24f) + NPC.localAI[3] = 0f; - if ((npc.ai[0] == 4f || npc.ai[0] == 6f) && npc.ai[2] == 1f) - npc.localAI[3] = 6f; + if ((NPC.ai[0] == 4f || NPC.ai[0] == 6f) && NPC.ai[2] == 1f) + NPC.localAI[3] = 6f; - if (npc.ai[0] == 5f && npc.ai[2] != 1f) - npc.localAI[3] = 7f; + if (NPC.ai[0] == 5f && NPC.ai[2] != 1f) + NPC.localAI[3] = 7f; } // Phases - switch ((int)npc.ai[0]) + switch ((int)NPC.ai[0]) { // Phase switch phase case 0: // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; if (phase2) { - QueenSlime_FlyMovement(npc); + QueenSlime_FlyMovement(NPC); } else { - npc.noTileCollide = false; - npc.noGravity = false; - if (npc.velocity.Y == 0f) + NPC.noTileCollide = false; + NPC.noGravity = false; + if (NPC.velocity.Y == 0f) { - npc.velocity.X *= 0.8f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; + NPC.velocity.X *= 0.8f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; } } - if (npc.timeLeft <= 10 || (!phase2 && npc.velocity.Y != 0f)) + if (NPC.timeLeft <= 10 || (!phase2 && NPC.velocity.Y != 0f)) break; - npc.ai[1] += 1f; - int idleTime = bossRush ? 20 : death ? 30 : 40; + NPC.ai[1] += 1f; + int idleTime = death ? 30 : 40; if (phase2) - idleTime = bossRush ? 40 : death ? 60 : 80; + idleTime = death ? 60 : 80; if (phase4) idleTime /= 2; - if (!(npc.ai[1] > idleTime)) + if (!(NPC.ai[1] > idleTime)) break; - npc.ai[1] = 0f; + NPC.ai[1] = 0f; if (phase2) { - Player player = Main.player[npc.target]; + Player player = Main.player[NPC.target]; - switch ((int)npc.Calamity().newAI[0]) + switch ((int)NPC.Calamity().newAI[0]) { default: - npc.ai[0] = Main.rand.NextBool() ? 6f : 5f; + NPC.ai[0] = Main.rand.NextBool() ? 6f : 5f; break; case 5: - npc.ai[0] = phase4 ? 6f : Main.rand.NextBool() ? 4f : 6f; + NPC.ai[0] = phase4 ? 6f : Main.rand.NextBool() ? 4f : 6f; break; case 6: - npc.ai[0] = phase4 ? 5f : Main.rand.NextBool() ? 5f : 4f; + NPC.ai[0] = phase4 ? 5f : Main.rand.NextBool() ? 5f : 4f; break; } - if (npc.ai[0] == 4f || npc.ai[0] == 6f) + if (NPC.ai[0] == 4f || NPC.ai[0] == 6f) { - npc.ai[2] = 1f; - if (player != null && player.active && !player.dead && (player.Bottom.Y < npc.Bottom.Y || Math.Abs(player.Center.X - npc.Center.X) > 450f)) + NPC.ai[2] = 1f; + if (player != null && player.active && !player.dead && (player.Bottom.Y < NPC.Bottom.Y || Math.Abs(player.Center.X - NPC.Center.X) > 450f)) { - npc.ai[0] = 5f; - npc.ai[2] = 0f; + NPC.ai[0] = 5f; + NPC.ai[2] = 0f; } } } else { - switch ((int)npc.Calamity().newAI[0]) + switch ((int)NPC.Calamity().newAI[0]) { default: - npc.ai[0] = Main.rand.NextBool() ? 5f : 4f; + NPC.ai[0] = Main.rand.NextBool() ? 5f : 4f; break; case 4: - npc.ai[0] = Main.rand.NextBool() ? 3f : 5f; + NPC.ai[0] = Main.rand.NextBool() ? 3f : 5f; break; case 5: - npc.ai[0] = Main.rand.NextBool() ? 4f : 3f; + NPC.ai[0] = Main.rand.NextBool() ? 4f : 3f; break; } } - npc.netUpdate = true; + NPC.netUpdate = true; break; // Enlarge after teleport case 1: // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.rotation = 0f; - npc.ai[1] += 1f; - float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; - slimeScale = MathHelper.Clamp(npc.ai[1] / teleportEndTime, 0f, 1f); + NPC.rotation = 0f; + NPC.ai[1] += 1f; + float teleportEndTime = death ? 15f : 20f; + slimeScale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); slimeScale = 0.5f + slimeScale * 0.5f; - if (npc.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); } - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[1] >= teleportEndTime * 2f) + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) { - npc.ai[0] = 0f; - npc.ai[1] = 0f; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); } // Emit teleport dust @@ -286,7 +302,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses newColor2.A = 150; for (int i = 0; i < 10; i++) { - int queenSlimeDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 50, newColor2, 1.5f); + int queenSlimeDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 50, newColor2, 1.5f); Main.dust[queenSlimeDust].noGravity = true; Main.dust[queenSlimeDust].velocity *= 2f; } @@ -297,21 +313,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 2: // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.rotation = 0f; - npc.ai[1] += 1f; - float teleportTime = bossRush ? 20f : death ? 30f : 40f; - slimeScale = MathHelper.Clamp((teleportTime - npc.ai[1]) / teleportTime, 0f, 1f); + NPC.rotation = 0f; + NPC.ai[1] += 1f; + float teleportTime = death ? 30f : 40f; + slimeScale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); slimeScale = 0.5f + slimeScale * 0.5f; - if (npc.ai[1] >= teleportTime) + if (NPC.ai[1] >= teleportTime) teleported = true; // Spawn crown gore - if (npc.ai[1] == teleportTime) + if (NPC.ai[1] == teleportTime) { - Gore.NewGore(npc.GetSource_FromAI(), npc.Center + new Vector2(-40f, -npc.height / 2), npc.velocity, GoreID.QueenSlimeCrown); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.Center + new Vector2(-40f, -NPC.height / 2), NPC.velocity, GoreID.QueenSlimeCrown); // Spawn spread of projectiles in Master Mode if (death) @@ -322,7 +338,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float gelVelocity = death ? 20f : 16f; int type = ProjectileID.QueenSlimeGelAttack; - int damage = npc.GetProjectileDamage(type); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -330,31 +345,31 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { Vector2 spinningpoint = new Vector2(gelVelocity, 0f); - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) spinningpoint *= Main.rand.NextFloat() + 0.5f; spinningpoint = spinningpoint.RotatedBy((float)(-j) * MathHelper.TwoPi / (float)numGelProjectiles, Vector2.Zero); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, spinningpoint, type, damage, 0f, Main.myPlayer, 0f, -2f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, spinningpoint, type, LargeGelDamage, 0f, Main.myPlayer, 0f, -2f); Main.projectile[proj].timeLeft = 900; } } - SoundEngine.PlaySound(SoundID.Item155, npc.Center); + SoundEngine.PlaySound(SoundID.Item155, NPC.Center); } } - if (npc.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) { - npc.Bottom = new Vector2(npc.localAI[1], npc.localAI[2]); - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; + NPC.Bottom = new Vector2(NPC.localAI[1], NPC.localAI[2]); + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[1] >= teleportTime * 2f) + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; } // Emit teleport dust @@ -364,7 +379,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses newColor.A = 150; for (int n = 0; n < 10; n++) { - int queenSlimeDust2 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 50, newColor, 1.5f); + int queenSlimeDust2 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 50, newColor, 1.5f); Main.dust[queenSlimeDust2].noGravity = true; Main.dust[queenSlimeDust2].velocity *= 0.5f; } @@ -376,33 +391,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 3: // Faster fall - if (npc.velocity.Y > 0f) - npc.velocity.Y += bossRush ? 0.1f : death ? 0.05f : 0f; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += death ? 0.05f : 0f; - npc.rotation = 0f; - if (npc.velocity.Y == 0f) + NPC.rotation = 0f; + if (NPC.velocity.Y == 0f) { // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.velocity.X *= 0.8f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; + NPC.velocity.X *= 0.8f; + if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; - float timerIncrement = bossRush ? 7f : death ? 6f : 5f; - npc.ai[1] += timerIncrement; + float timerIncrement = death ? 6f : 5f; + NPC.ai[1] += timerIncrement; if (lifeRatio < 0.85f) - npc.ai[1] += timerIncrement; + NPC.ai[1] += timerIncrement; if (lifeRatio < 0.7f) - npc.ai[1] += timerIncrement; + NPC.ai[1] += timerIncrement; - if (!(npc.ai[1] >= 0f)) + if (!(NPC.ai[1] >= 0f)) break; // Set damage - npc.damage = npc.defDamage; + NPC.damage = NPC.defDamage; - float distanceBelowTarget = npc.position.Y - (Main.player[npc.target].position.Y + 80f); + float distanceBelowTarget = NPC.position.Y - (Main.player[NPC.target].position.Y + 80f); float speedMult = 1f; if (distanceBelowTarget > 0f) speedMult += distanceBelowTarget * 0.002f; @@ -410,70 +425,70 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (speedMult > 2f) speedMult = 2f; - npc.netUpdate = true; + NPC.netUpdate = true; - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - if (npc.ai[2] == 3f) + if (NPC.ai[2] == 3f) { - npc.velocity.Y = -13f * speedMult; - npc.velocity.X += (bossRush ? 7f : death ? 6f : 5.5f) * npc.direction; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - if (npc.timeLeft > 10) + NPC.velocity.Y = -13f * speedMult; + NPC.velocity.X += (death ? 6f : 5.5f) * NPC.direction; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + if (NPC.timeLeft > 10) { - npc.Calamity().newAI[0] = npc.ai[0]; - npc.SyncExtraAI(); - npc.ai[0] = 0f; + NPC.Calamity().newAI[0] = NPC.ai[0]; + NPC.SyncExtraAI(); + NPC.ai[0] = 0f; } else - npc.ai[1] = -60f; + NPC.ai[1] = -60f; } - else if (npc.ai[2] == 2f) + else if (NPC.ai[2] == 2f) { - npc.velocity.Y = -(bossRush ? 10f : death ? 8f : 6f) * speedMult; - npc.velocity.X += (bossRush ? 8.5f : death ? 7.5f : 7f) * npc.direction; - npc.ai[1] = -40f; - npc.ai[2] += 1f; + NPC.velocity.Y = -(death ? 8f : 6f) * speedMult; + NPC.velocity.X += (death ? 7.5f : 7f) * NPC.direction; + NPC.ai[1] = -40f; + NPC.ai[2] += 1f; } else { - npc.velocity.Y = -(bossRush ? 12f : death ? 10f : 8f) * speedMult; - npc.velocity.X += (bossRush ? 7.5f : death ? 6.5f : 6f) * npc.direction; - npc.ai[1] = -40f; - npc.ai[2] += 1f; + NPC.velocity.Y = -(death ? 10f : 8f) * speedMult; + NPC.velocity.X += (death ? 6.5f : 6f) * NPC.direction; + NPC.ai[1] = -40f; + NPC.ai[2] += 1f; } if (death) - npc.velocity.X *= (death ? 1.4f : 1.2f); + NPC.velocity.X *= (death ? 1.4f : 1.2f); - npc.noTileCollide = true; + NPC.noTileCollide = true; } else { - if (npc.target >= Main.maxPlayers) + if (NPC.target >= Main.maxPlayers) break; - float jumpVelocity = bossRush ? 9f : death ? 7f : 4.5f; + float jumpVelocity = death ? 7f : 4.5f; if (Main.getGoodWorld) jumpVelocity = 12f; - if ((npc.direction == 1 && npc.velocity.X < jumpVelocity) || (npc.direction == -1 && npc.velocity.X > 0f - jumpVelocity)) + if ((NPC.direction == 1 && NPC.velocity.X < jumpVelocity) || (NPC.direction == -1 && NPC.velocity.X > 0f - jumpVelocity)) { - if ((npc.direction == -1 && npc.velocity.X < 0.1) || (npc.direction == 1 && npc.velocity.X > -0.1)) - npc.velocity.X += (bossRush ? 1f : death ? 0.45f : 0.3f) * npc.direction; + if ((NPC.direction == -1 && NPC.velocity.X < 0.1) || (NPC.direction == 1 && NPC.velocity.X > -0.1)) + NPC.velocity.X += (death ? 0.45f : 0.3f) * NPC.direction; else - npc.velocity.X *= bossRush ? 0.8f : death ? 0.85f : 0.91f; + NPC.velocity.X *= death ? 0.85f : 0.91f; } - if (!Main.player[npc.target].dead) + if (!Main.player[NPC.target].dead) { - if (npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) - npc.noTileCollide = false; - else if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.noTileCollide = false; + if (NPC.velocity.Y > 0f && NPC.Bottom.Y > Main.player[NPC.target].Top.Y) + NPC.noTileCollide = false; + else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.noTileCollide = false; else - npc.noTileCollide = true; + NPC.noTileCollide = true; } } @@ -486,16 +501,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 6: // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.rotation *= 0.9f; - npc.noTileCollide = true; - npc.noGravity = true; + NPC.rotation *= 0.9f; + NPC.noTileCollide = true; + NPC.noGravity = true; - if (npc.ai[2] == 1f) + if (NPC.ai[2] == 1f) { - npc.noTileCollide = false; - npc.noGravity = false; + NPC.noTileCollide = false; + NPC.noGravity = false; int slamDelay = 30; if (phase2) @@ -504,14 +519,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) slamDelay = 0; - if (npc.velocity.Y == 0f) + if (NPC.velocity.Y == 0f) { - SoundEngine.PlaySound(SoundID.Item167, npc.Center); + SoundEngine.PlaySound(SoundID.Item167, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.QueenSlimeSmash; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Bottom, Vector2.Zero, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Bottom, Vector2.Zero, type, SlamDamage, 0f, Main.myPlayer); // Line of explosions in Master Mode if (death) @@ -519,7 +533,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float expandDelay = 0f; int maxSmashes = death ? 22 : 16; float maxSmashOffset = maxSmashes * 100f; - Vector2 extraSmashPosition = npc.Bottom + Vector2.UnitX * maxSmashOffset; + Vector2 extraSmashPosition = NPC.Bottom + Vector2.UnitX * maxSmashOffset; int maxSmashesPerSide = maxSmashes / 2; float maxExpandDelay = (death ? 10f : 15f) * maxSmashesPerSide; float smashSpawnDistanceOffset = 200f; @@ -527,36 +541,35 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { expandDelay = MathHelper.Lerp(0f, maxExpandDelay, Math.Abs(i - maxSmashesPerSide) / (float)maxSmashesPerSide); if (i != maxSmashesPerSide) - Projectile.NewProjectile(npc.GetSource_FromAI(), extraSmashPosition, Vector2.Zero, type, damage, 0f, Main.myPlayer, -expandDelay); + Projectile.NewProjectile(NPC.GetSource_FromAI(), extraSmashPosition, Vector2.Zero, type, SlamDamage, 0f, Main.myPlayer, -expandDelay); extraSmashPosition -= Vector2.UnitX * smashSpawnDistanceOffset; } } // Eruption of crystals in phase 3 - if (npc.ai[0] == 6f && phase3) + if (NPC.ai[0] == 6f && phase3) { float projectileVelocity = death ? 18f : 12f; type = ProjectileID.QueenSlimeMinionBlueSpike; - damage = npc.GetProjectileDamage(type); - Vector2 destination = (new Vector2(npc.Center.X, npc.Center.Y - 100f) - npc.Center).SafeNormalize(Vector2.UnitY); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; int numProj = 20; float rotation = MathHelper.ToRadians(100); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, -2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, SpikeDamage, 0f, Main.myPlayer, 0f, -2f); } if (phase5) { numProj = 15; - destination *= 0.75f; + destination *= 0.65f; for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, -2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, SpikeDamage, 0f, Main.myPlayer, 0f, -2f); } } } @@ -564,79 +577,78 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses for (int l = 0; l < 20; l++) { - int slamDust = Dust.NewDust(npc.Bottom - new Vector2(npc.width / 2, 30f), npc.width, 30, DustID.Smoke, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor()); + int slamDust = Dust.NewDust(NPC.Bottom - new Vector2(NPC.width / 2, 30f), NPC.width, 30, DustID.Smoke, NPC.velocity.X, NPC.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor()); Main.dust[slamDust].noGravity = true; Main.dust[slamDust].velocity.Y = -5f + Main.rand.NextFloat() * -3f; Main.dust[slamDust].velocity.X *= 7f; } - npc.Calamity().newAI[0] = npc.ai[0]; - npc.SyncExtraAI(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.Calamity().newAI[0] = NPC.ai[0]; + NPC.SyncExtraAI(); + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } - else if (npc.ai[1] >= slamDelay) + else if (NPC.ai[1] >= slamDelay) { for (int m = 0; m < 4; m++) { - Vector2 position = npc.Bottom - new Vector2(Main.rand.NextFloatDirection() * 16f, Main.rand.Next(8)); - int slamDust2 = Dust.NewDust(position, 2, 2, DustID.Smoke, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.4f); + Vector2 position = NPC.Bottom - new Vector2(Main.rand.NextFloatDirection() * 16f, Main.rand.Next(8)); + int slamDust2 = Dust.NewDust(position, 2, 2, DustID.Smoke, NPC.velocity.X, NPC.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.4f); Main.dust[slamDust2].position = position; Main.dust[slamDust2].noGravity = true; - Main.dust[slamDust2].velocity.Y = npc.velocity.Y * 0.9f; + Main.dust[slamDust2].velocity.Y = NPC.velocity.Y * 0.9f; Main.dust[slamDust2].velocity.X = (Main.rand.NextBool() ? (-10f) : 10f) + Main.rand.NextFloatDirection() * 3f; } } - npc.velocity.X *= 0.8f; - float slamNetUpdate = npc.ai[1]; - npc.ai[1] += 1f; - if (npc.ai[1] >= slamDelay) + NPC.velocity.X *= 0.8f; + float slamNetUpdate = NPC.ai[1]; + NPC.ai[1] += 1f; + if (NPC.ai[1] >= slamDelay) { if (slamNetUpdate < slamDelay) - npc.netUpdate = true; + NPC.netUpdate = true; - if (phase2 && npc.ai[1] > (slamDelay + 120)) + if (phase2 && NPC.ai[1] > (slamDelay + 120)) { - npc.Calamity().newAI[0] = npc.ai[0]; - npc.SyncExtraAI(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.velocity.Y *= 0.8f; - npc.netUpdate = true; + NPC.Calamity().newAI[0] = NPC.ai[0]; + NPC.SyncExtraAI(); + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.velocity.Y *= 0.8f; + NPC.netUpdate = true; break; } // Set damage - npc.damage = npc.defDamage; + NPC.damage = NPC.defDamage; - npc.velocity.Y += bossRush ? 2f : death ? 1.75f : 1.5f; - float slamVelocity = bossRush ? 15.99f : death ? 15.5f : 15f; + NPC.velocity.Y += death ? 1.75f : 1.5f; + float slamVelocity = death ? 15.5f : 15f; if (Main.getGoodWorld) { - npc.velocity.Y += 1f; + NPC.velocity.Y += 1f; slamVelocity = 15.99f; } - if (npc.velocity.Y == 0f) - npc.velocity.Y = 0.01f; + if (NPC.velocity.Y == 0f) + NPC.velocity.Y = 0.01f; - if (npc.velocity.Y >= slamVelocity) - npc.velocity.Y = slamVelocity; + if (NPC.velocity.Y >= slamVelocity) + NPC.velocity.Y = slamVelocity; // Cascade of crystals in phase 3 or 4 while falling down - if (((npc.ai[0] == 4f && phase3) || phase4) && npc.ai[1] % 12f == 0f) + if (((NPC.ai[0] == 4f && phase3) || phase4) && NPC.ai[1] % 12f == 0f) { - SoundEngine.PlaySound(SoundID.Item154, npc.Center); + SoundEngine.PlaySound(SoundID.Item154, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 fireFrom = npc.Center; + Vector2 fireFrom = NPC.Center; int projectileAmt = 2; int type = ProjectileID.QueenSlimeMinionBlueSpike; - int damage = npc.GetProjectileDamage(type); Vector2 velocityIncrease = death ? (Vector2.UnitY * 4f) : Vector2.Zero; for (int i = 0; i < projectileAmt; i++) { @@ -644,56 +656,56 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float radians = MathHelper.TwoPi / totalProjectiles; for (int j = 0; j < totalProjectiles; j++) { - Vector2 projVelocity = (npc.velocity + velocityIncrease).RotatedBy(radians * j + MathHelper.PiOver2); - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom, projVelocity, type, damage, 0f, Main.myPlayer, 0f, -1f); + Vector2 projVelocity = (NPC.velocity + velocityIncrease).RotatedBy(radians * j + MathHelper.PiOver2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fireFrom, projVelocity, type, SpikeDamage, 0f, Main.myPlayer, 0f, -1f); } } } } } else - npc.velocity.Y *= 0.8f; + NPC.velocity.Y *= 0.8f; break; } - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] == 0f) { - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - npc.netUpdate = true; + NPC.netUpdate = true; } - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 30f)) + NPC.ai[1] += 1f; + if (!(NPC.ai[1] >= 30f)) break; - if (npc.ai[1] >= 60f) + if (NPC.ai[1] >= 60f) { - npc.ai[1] = 60f; + NPC.ai[1] = 60f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.velocity.Y = -3f; - npc.netUpdate = true; + NPC.ai[1] = 0f; + NPC.ai[2] = 1f; + NPC.velocity.Y = -3f; + NPC.netUpdate = true; } } - Player player3 = Main.player[npc.target]; - Vector2 center = npc.Center; - if (!player3.dead && player3.active && Math.Abs(npc.Center.X - player3.Center.X) / 16f <= despawnDistanceInTiles) + Player player3 = Main.player[NPC.target]; + Vector2 center = NPC.Center; + if (!player3.dead && player3.active && Math.Abs(NPC.Center.X - player3.Center.X) / 16f <= despawnDistanceInTiles) center = player3.Center; center.Y -= 384f; - if (npc.velocity.Y == 0f) + if (NPC.velocity.Y == 0f) { - npc.velocity = center - npc.Center; - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero); - npc.velocity *= bossRush ? 30f : death ? 27.3f : 24f; + NPC.velocity = center - NPC.Center; + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.Zero); + NPC.velocity *= death ? 27.3f : 24f; } else - npc.velocity.Y *= 0.95f; + NPC.velocity.Y *= 0.95f; break; @@ -701,44 +713,41 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses case 5: // Avoid cheap bullshit - npc.damage = 0; + NPC.damage = 0; - npc.rotation *= 0.9f; - npc.noTileCollide = true; - npc.noGravity = true; + NPC.rotation *= 0.9f; + NPC.noTileCollide = true; + NPC.noGravity = true; if (phase2) - npc.ai[3] = 0f; + NPC.ai[3] = 0f; - if (npc.ai[2] == 1f) + if (NPC.ai[2] == 1f) { - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 10f)) + NPC.ai[1] += 1f; + if (!(NPC.ai[1] >= 10f)) break; if (Main.netMode != NetmodeID.MultiplayerClient) { int numGelProjectiles = phase4 ? Main.rand.Next(9, 12) : phase2 ? Main.rand.Next(6, 9) : 12; - if (phase5) - numGelProjectiles += 6; if (Main.getGoodWorld) - numGelProjectiles = 20; + numGelProjectiles = 15; float projectileVelocity = death ? 12f : 10.5f; int type = ProjectileID.QueenSlimeGelAttack; - int damage = npc.GetProjectileDamage(type); if (phase2) { - Vector2 destination = (new Vector2(npc.Center.X, npc.Center.Y + 100f) - npc.Center).SafeNormalize(Vector2.UnitY); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y + 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; float rotation = MathHelper.ToRadians(120); for (int i = 0; i < numGelProjectiles; i++) { - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) destination *= Main.rand.NextFloat() + 0.5f; Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numGelProjectiles - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, -2f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, LargeGelDamage, 0f, Main.myPlayer, 0f, -2f); Main.projectile[proj].timeLeft = 900; } } @@ -748,11 +757,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { Vector2 spinningpoint = new Vector2(projectileVelocity, 0f); - if (CalamityWorld.LegendaryMode) + if (Main.getGoodWorld) spinningpoint *= Main.rand.NextFloat() + 0.5f; spinningpoint = spinningpoint.RotatedBy((-j) * MathHelper.TwoPi / numGelProjectiles, Vector2.Zero); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, spinningpoint, type, damage, 0f, Main.myPlayer, 0f, -2f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, spinningpoint, type, LargeGelDamage, 0f, Main.myPlayer, 0f, -2f); Main.projectile[proj].timeLeft = 900; } } @@ -769,109 +778,111 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } foreach (int t in targets) { - Vector2 velocity2 = (Main.player[t].Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity2, type, damage, 0f, Main.myPlayer, 0f, -2f); + Vector2 velocity2 = (Main.player[t].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, LargeGelDamage, 0f, Main.myPlayer, 0f, -2f); Main.projectile[proj].timeLeft = 900; } } - SoundEngine.PlaySound(SoundID.Item155, npc.Center); - npc.Calamity().newAI[0] = npc.ai[0]; - npc.SyncExtraAI(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + SoundEngine.PlaySound(SoundID.Item155, NPC.Center); + NPC.Calamity().newAI[0] = NPC.ai[0]; + NPC.SyncExtraAI(); + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; break; } - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] == 0f) { - CalamityUtils.CalamityTargeting(npc, default); + CalamityUtils.CalamityTargeting(NPC, default); - npc.netUpdate = true; + NPC.netUpdate = true; } - npc.ai[1] += 1f; - if (npc.ai[1] >= 50f) + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 50f) { - npc.ai[1] = 50f; + NPC.ai[1] = 50f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.netUpdate = true; + NPC.ai[1] = 0f; + NPC.ai[2] = 1f; + NPC.netUpdate = true; } } float slamDustRadius = 100f; for (int k = 0; k < 4; k++) { - Vector2 slamDustArea = npc.Center + Main.rand.NextVector2CircularEdge(slamDustRadius, slamDustRadius); + Vector2 slamDustArea = NPC.Center + Main.rand.NextVector2CircularEdge(slamDustRadius, slamDustRadius); if (!phase2) slamDustArea += new Vector2(0f, 20f); - Vector2 v = slamDustArea - npc.Center; + Vector2 v = slamDustArea - NPC.Center; v = v.SafeNormalize(Vector2.Zero) * -8f; int superSlamDust = Dust.NewDust(slamDustArea, 2, 2, DustID.Smoke, v.X, v.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.8f); Main.dust[superSlamDust].position = slamDustArea; Main.dust[superSlamDust].noGravity = true; Main.dust[superSlamDust].alpha = 250; Main.dust[superSlamDust].velocity = v; - Main.dust[superSlamDust].customData = npc; + Main.dust[superSlamDust].customData = NPC; } if (phase2) - QueenSlime_FlyMovement(npc); + QueenSlime_FlyMovement(NPC); break; } // Don't take damage while teleporting - npc.dontTakeDamage = npc.hide = teleported; + NPC.dontTakeDamage = NPC.hide = teleported; // Adjust size with HP - if (slimeScale != npc.scale) + if (slimeScale != NPC.scale) { - npc.position.X += npc.width / 2; - npc.position.Y += npc.height; - npc.scale = slimeScale; - npc.width = (int)(114f * npc.scale); - npc.height = (int)(100f * npc.scale); - npc.position.X -= npc.width / 2; - npc.position.Y -= npc.height; + NPC.position.X += NPC.width / 2; + NPC.position.Y += NPC.height; + NPC.scale = slimeScale; + NPC.width = (int)(114f * NPC.scale); + NPC.height = (int)(100f * NPC.scale); + NPC.position.X -= NPC.width / 2; + NPC.position.Y -= NPC.height; } // Spawn small slimes // Don't spawn any slimes in final phase - if (npc.life <= 0 || (phase4 && !death)) + if (NPC.life <= 0 || (phase4 && !death)) return false; if (Main.netMode == NetmodeID.MultiplayerClient) return false; // Reset numerous variables when phase 2 begins - if (npc.localAI[0] >= (npc.lifeMax / 2) && npc.life < npc.lifeMax / 2) + if (NPC.localAI[0] >= (NPC.lifeMax / 2) && NPC.life < NPC.lifeMax / 2) { - npc.localAI[0] = npc.life; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; + NPC.localAI[0] = NPC.life; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; } - float slimeSpawnHealthGateValue = CalamityWorld.LegendaryMode ? 0.01f : phase3 ? 0.04f : phase2 ? 0.03f : 0.025f; + float slimeSpawnHealthGateValue = Main.zenithWorld ? 0.01f : phase3 ? 0.04f : phase2 ? 0.03f : 0.025f; if (death) slimeSpawnHealthGateValue *= 0.5f; - int slimeSpawnThreshold = (int)(npc.lifeMax * slimeSpawnHealthGateValue); + int slimeSpawnThreshold = (int)(NPC.lifeMax * slimeSpawnHealthGateValue); - if (!((npc.life + slimeSpawnThreshold) < npc.localAI[0])) + if (!((NPC.life + slimeSpawnThreshold) < NPC.localAI[0])) return false; - npc.localAI[0] = npc.life; - int x = (int)(npc.position.X + Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + Main.rand.Next(npc.height - 32)); + NPC.localAI[0] = NPC.life; + + int offset = 16; + int x = (int)(NPC.position.X + offset + Main.rand.Next(NPC.width - offset * 2)); + int y = (int)(NPC.position.Y + offset + Main.rand.Next(NPC.height - offset * 2)); int random = Main.rand.Next(2); if (phase2) @@ -893,7 +904,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - int slimeScale2 = NPC.NewNPC(npc.GetSource_FromAI(), x, y, typeToSpawn); + int slimeScale2 = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, typeToSpawn); Main.npc[slimeScale2].SetDefaults(typeToSpawn); Main.npc[slimeScale2].velocity.X = Main.rand.Next(-15, 16) * 0.1f; Main.npc[slimeScale2].velocity.Y = Main.rand.Next(-30, 1) * 0.1f; @@ -905,752 +916,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool VanillaQueenSlimeAI(NPC npc, Mod mod) - { - float num3 = 1f; - bool flag = false; - bool flag2 = npc.life <= npc.lifeMax / 2; - if (npc.localAI[0] == 0f) - { - npc.ai[1] = -100f; - npc.localAI[0] = npc.lifeMax; - - CalamityUtils.CalamityTargeting(npc, default); - - npc.netUpdate = true; - } - - Lighting.AddLight(npc.Center, 1f, 0.7f, 0.9f); - int num4 = 500; - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > (float)num4) - { - CalamityUtils.CalamityTargeting(npc, default); - - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > (float)num4) - { - npc.EncourageDespawn(10); - if (Main.player[npc.target].Center.X < npc.Center.X) - npc.direction = 1; - else - npc.direction = -1; - } - } - - if (!Main.player[npc.target].dead && npc.timeLeft > 10 && !flag2 && npc.ai[3] >= 300f && npc.ai[0] == 0f && npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[0] = 2f; - npc.ai[1] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.netUpdate = true; - - CalamityTargetingParameters options = CalamityTargetingParameters.Defaults; - options.faceTarget = false; - CalamityUtils.CalamityTargeting(npc, options); - - Point point = npc.Center.ToTileCoordinates(); - Point point2 = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 vector = Main.player[npc.target].Center - npc.Center; - int num5 = 10; - int num6 = 0; - int num7 = 7; - int num8 = 0; - bool flag3 = false; - if (npc.ai[3] >= 360f || vector.Length() > 2000f) - { - if (npc.ai[3] > 360f) - npc.ai[3] = 360f; - - flag3 = true; - num8 = 100; - } - - while (!flag3 && num8 < 100) - { - num8++; - int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); - int num10 = Main.rand.Next(point2.Y - num5, point2.Y + 1); - if ((num10 >= point2.Y - num7 && num10 <= point2.Y + num7 && num9 >= point2.X - num7 && num9 <= point2.X + num7) || (num10 >= point.Y - num6 && num10 <= point.Y + num6 && num9 >= point.X - num6 && num9 <= point.X + num6) || Main.tile[num9, num10].HasUnactuatedTile) - continue; - - int num11 = num10; - int i = 0; - if (Main.tile[num9, num11].HasUnactuatedTile && Main.tileSolid[Main.tile[num9, num11].TileType] && !Main.tileSolidTop[Main.tile[num9, num11].TileType]) - { - i = 1; - } - else - { - for (; i < 150 && num11 + i < Main.maxTilesY; i++) - { - int num12 = num11 + i; - if (Main.tile[num9, num12].HasUnactuatedTile && Main.tileSolid[Main.tile[num9, num12].TileType] && !Main.tileSolidTop[Main.tile[num9, num12].TileType]) - { - i--; - break; - } - } - } - - num10 += i; - bool flag4 = true; - if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) - flag4 = false; - - if (flag4 && !Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - flag4 = false; - - if (flag4) - { - npc.localAI[1] = num9 * 16 + 8; - npc.localAI[2] = num10 * 16 + 16; - flag3 = true; - break; - } - } - - if (num8 >= 100) - { - Vector2 bottom = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; - npc.localAI[1] = bottom.X; - npc.localAI[2] = bottom.Y; - npc.ai[3] = 0f; - } - } - } - - if (!flag2 && (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > 320f)) - { - npc.ai[3] += (Main.masterMode ? 3f : Main.expertMode ? 2f : 1.5f); - } - else - { - float num13 = npc.ai[3]; - npc.ai[3] -= 1f; - if (npc.ai[3] < 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient && num13 > 0f) - npc.netUpdate = true; - - npc.ai[3] = 0f; - } - } - - if (npc.timeLeft <= 10 && ((flag2 && npc.ai[0] != 0f) || (!flag2 && npc.ai[0] != 3f))) - { - if (flag2) - npc.ai[0] = 0f; - else - npc.ai[0] = 3f; - - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - npc.noTileCollide = false; - npc.noGravity = false; - if (flag2) - { - npc.localAI[3] += 1f; - if (npc.localAI[3] >= 24f) - npc.localAI[3] = 0f; - - if (npc.ai[0] == 4f && npc.ai[2] == 1f) - npc.localAI[3] = 6f; - - if (npc.ai[0] == 5f && npc.ai[2] != 1f) - npc.localAI[3] = 7f; - } - - switch ((int)npc.ai[0]) - { - case 0: - { - // Avoid cheap bullshit - npc.damage = 0; - - if (flag2) - { - QueenSlime_FlyMovement_Vanilla(npc); - } - else - { - npc.noTileCollide = false; - npc.noGravity = false; - if (npc.velocity.Y == 0f) - { - npc.velocity.X *= 0.8f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - } - } - - if (npc.timeLeft <= 10 || (!flag2 && npc.velocity.Y != 0f)) - break; - - npc.ai[1] += 1f; - int num18 = 60; - if (flag2) - num18 = 120; - if (Main.masterMode) - num18 /= 2; - - if (!(npc.ai[1] > (float)num18)) - break; - - npc.ai[1] = 0f; - if (flag2) - { - Player player = Main.player[npc.target]; - int num19 = Main.rand.Next(2); - if (num19 != 1) - npc.ai[0] = 4f; - else - npc.ai[0] = 5f; - - if (npc.ai[0] == 4f) - { - npc.ai[2] = 1f; - if (player != null && player.active && !player.dead && (player.Bottom.Y < npc.Bottom.Y || Math.Abs(player.Center.X - npc.Center.X) > 250f)) - { - npc.ai[0] = 5f; - npc.ai[2] = 0f; - } - } - } - else - { - switch (Main.rand.Next(3)) - { - default: - npc.ai[0] = 3f; - break; - case 1: - npc.ai[0] = 4f; - break; - case 2: - npc.ai[0] = 5f; - break; - } - } - - npc.netUpdate = true; - break; - } - - case 1: - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.rotation = 0f; - npc.ai[1] += (Main.masterMode ? 2f : 1f); - num3 = MathHelper.Clamp(npc.ai[1] / 30f, 0f, 1f); - num3 = 0.5f + num3 * 0.5f; - if (npc.ai[1] >= 30f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; - - CalamityUtils.CalamityTargeting(npc, default); - } - - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[1] >= 60f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - - CalamityUtils.CalamityTargeting(npc, default); - } - - Color newColor2 = NPC.AI_121_QueenSlime_GetDustColor(); - newColor2.A = 150; - for (int num27 = 0; num27 < 10; num27++) - { - int num28 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 50, newColor2, 1.5f); - Main.dust[num28].noGravity = true; - Main.dust[num28].velocity *= 2f; - } - - break; - } - - case 2: - - // Avoid cheap bullshit - npc.damage = 0; - - npc.rotation = 0f; - npc.ai[1] += (Main.masterMode ? 2f : 1f); - num3 = MathHelper.Clamp((60f - npc.ai[1]) / 60f, 0f, 1f); - num3 = 0.5f + num3 * 0.5f; - - if (npc.ai[1] >= 60f) - flag = true; - - if (npc.ai[1] == 60f) - { - Gore.NewGore(npc.GetSource_FromAI(), npc.Center + new Vector2(-40f, -npc.height / 2), npc.velocity, GoreID.QueenSlimeCrown); - - if (Main.masterMode) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num14 = 10; - if (Main.getGoodWorld) - num14 = 15; - - float gelVelocity = 12f; - int type = ProjectileID.QueenSlimeGelAttack; - for (int j = 0; j < num14; j++) - { - Vector2 spinningpoint = new Vector2(gelVelocity, 0f); - spinningpoint = spinningpoint.RotatedBy((float)(-j) * MathHelper.TwoPi / (float)num14, Vector2.Zero); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, spinningpoint, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - } - } - - SoundEngine.PlaySound(SoundID.Item155, npc.Center); - } - } - - if (npc.ai[1] >= 60f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Bottom = new Vector2(npc.localAI[1], npc.localAI[2]); - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[1] >= 120f) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - } - - if (!flag) - { - Color newColor = NPC.AI_121_QueenSlime_GetDustColor(); - newColor.A = 150; - for (int n = 0; n < 10; n++) - { - int num26 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 50, newColor, 1.5f); - Main.dust[num26].noGravity = true; - Main.dust[num26].velocity *= 0.5f; - } - } - break; - - case 3: - npc.rotation = 0f; - if (npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.X *= 0.8f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - npc.ai[1] += 4f; - if ((double)npc.life < (double)npc.lifeMax * 0.8) - npc.ai[1] += 4f; - - if ((double)npc.life < (double)npc.lifeMax * 0.6) - npc.ai[1] += 4f; - - if (!(npc.ai[1] >= 0f)) - break; - - // Set damage - npc.damage = npc.defDamage; - - npc.netUpdate = true; - - CalamityUtils.CalamityTargeting(npc, default); - - if (npc.ai[2] == 3f) - { - npc.velocity.Y = -13f; - npc.velocity.X += 3.5f * (float)npc.direction; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - if (npc.timeLeft > 10) - npc.ai[0] = 0f; - else - npc.ai[1] = -60f; - } - else if (npc.ai[2] == 2f) - { - npc.velocity.Y = -6f; - npc.velocity.X += 4.5f * (float)npc.direction; - npc.ai[1] = -40f; - npc.ai[2] += 1f; - } - else - { - npc.velocity.Y = -8f; - npc.velocity.X += 4f * (float)npc.direction; - npc.ai[1] = -40f; - npc.ai[2] += 1f; - } - - if (Main.expertMode) - { - npc.velocity.X *= 1.5f; - npc.velocity.Y *= 1.25f; - } - - if (Main.masterMode) - { - npc.velocity.X *= 1.3f; - npc.velocity.Y *= 1.1f; - } - } - else - { - if (npc.target >= Main.maxPlayers) - break; - - float num20 = Main.masterMode ? 5f : 3f; - if (Main.getGoodWorld) - num20 = 7f; - - if ((npc.direction == 1 && npc.velocity.X < num20) || (npc.direction == -1 && npc.velocity.X > 0f - num20)) - { - if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) - npc.velocity.X += 0.2f * (float)npc.direction; - else - npc.velocity.X *= 0.93f; - } - } - break; - - case 4: - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.rotation *= 0.9f; - npc.noTileCollide = true; - npc.noGravity = true; - if (npc.ai[2] == 1f) - { - npc.noTileCollide = false; - npc.noGravity = false; - int num21 = 30; - if (flag2) - num21 = 10; - - if (Main.getGoodWorld) - num21 = 0; - - Player player2 = Main.player[npc.target]; - if (npc.velocity.Y == 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - SoundEngine.PlaySound(SoundID.Item167, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ProjectileID.QueenSlimeSmash; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Bottom, Vector2.Zero, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - - if (Main.masterMode) - { - float expandDelay = 0f; - int maxSmashes = 10; - float maxSmashOffset = maxSmashes * 100f; - Vector2 extraSmashPosition = npc.Bottom + Vector2.UnitX * maxSmashOffset; - int maxSmashesPerSide = maxSmashes / 2; - float maxExpandDelay = 20f * maxSmashesPerSide; - float smashSpawnDistanceOffset = 200f; - for (int i = 0; i < maxSmashes + 1; i++) - { - expandDelay = MathHelper.Lerp(0f, maxExpandDelay, Math.Abs(i - maxSmashesPerSide) / (float)maxSmashesPerSide); - if (i != maxSmashesPerSide) - Projectile.NewProjectile(npc.GetSource_FromAI(), extraSmashPosition, Vector2.Zero, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer, -expandDelay); - - extraSmashPosition -= Vector2.UnitX * smashSpawnDistanceOffset; - } - } - } - - for (int l = 0; l < 20; l++) - { - int num22 = Dust.NewDust(npc.Bottom - new Vector2(npc.width / 2, 30f), npc.width, 30, DustID.Smoke, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor()); - Main.dust[num22].noGravity = true; - Main.dust[num22].velocity.Y = -5f + Main.rand.NextFloat() * -3f; - Main.dust[num22].velocity.X *= 7f; - } - } - else if (npc.ai[1] >= (float)num21) - { - for (int m = 0; m < 4; m++) - { - Vector2 vector3 = npc.Bottom - new Vector2(Main.rand.NextFloatDirection() * 16f, Main.rand.Next(8)); - int num23 = Dust.NewDust(vector3, 2, 2, DustID.Smoke, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.4f); - Main.dust[num23].position = vector3; - Main.dust[num23].noGravity = true; - Main.dust[num23].velocity.Y = npc.velocity.Y * 0.9f; - Main.dust[num23].velocity.X = (Main.rand.NextBool() ? (-10f) : 10f) + Main.rand.NextFloatDirection() * 3f; - } - } - - npc.velocity.X *= 0.8f; - float num24 = npc.ai[1]; - npc.ai[1] += 1f; - if (npc.ai[1] >= (float)num21) - { - if (num24 < (float)num21) - npc.netUpdate = true; - - if (flag2 && npc.ai[1] > (float)(num21 + 120)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.velocity.Y *= 0.8f; - npc.netUpdate = true; - break; - } - - // Set damage - npc.damage = npc.defDamage; - - npc.velocity.Y += 1f; - float num25 = 14f; - if (Main.getGoodWorld) - { - npc.velocity.Y += 1f; - num25 = 15.99f; - } - - if (npc.velocity.Y == 0f) - npc.velocity.Y = 0.01f; - - if (npc.velocity.Y >= num25) - npc.velocity.Y = num25; - } - else - npc.velocity.Y *= 0.8f; - - break; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) - { - CalamityUtils.CalamityTargeting(npc, default); - - npc.netUpdate = true; - } - - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 30f)) - break; - - if (npc.ai[1] >= 60f) - { - npc.ai[1] = 60f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.velocity.Y = -3f; - npc.netUpdate = true; - } - } - - Player player3 = Main.player[npc.target]; - Vector2 center = npc.Center; - if (!player3.dead && player3.active && Math.Abs(npc.Center.X - player3.Center.X) / 16f <= (float)num4) - center = player3.Center; - - center.Y -= 384f; - if (npc.velocity.Y == 0f) - { - npc.velocity = center - npc.Center; - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero); - npc.velocity *= (Main.masterMode ? 28f : Main.expertMode ? 24f : 20f); - } - else - npc.velocity.Y *= 0.95f; - - break; - } - - case 5: - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.rotation *= 0.9f; - npc.noTileCollide = true; - npc.noGravity = true; - if (flag2) - npc.ai[3] = 0f; - - if (npc.ai[2] == 1f) - { - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 10f)) - break; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int num14 = 10; - if (Main.getGoodWorld) - num14 = 15; - - int num15 = num14; - if (!flag2) - num15 = 6; - - int type = ProjectileID.QueenSlimeGelAttack; - for (int j = 0; j < num15; j++) - { - Vector2 spinningpoint = new Vector2(Main.masterMode ? 10.5f : 9f, 0f); - spinningpoint = spinningpoint.RotatedBy((float)(-j) * MathHelper.TwoPi / (float)num14, Vector2.Zero); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, spinningpoint, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - } - } - - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - break; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) - { - CalamityUtils.CalamityTargeting(npc, default); - - npc.netUpdate = true; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= 50f) - { - npc.ai[1] = 50f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.netUpdate = true; - } - } - - float num16 = 100f; - for (int k = 0; k < 4; k++) - { - Vector2 vector2 = npc.Center + Main.rand.NextVector2CircularEdge(num16, num16); - if (!flag2) - vector2 += new Vector2(0f, 20f); - - Vector2 v = vector2 - npc.Center; - v = v.SafeNormalize(Vector2.Zero) * -8f; - int num17 = Dust.NewDust(vector2, 2, 2, DustID.Smoke, v.X, v.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.8f); - Main.dust[num17].position = vector2; - Main.dust[num17].noGravity = true; - Main.dust[num17].alpha = 250; - Main.dust[num17].velocity = v; - Main.dust[num17].customData = npc; - } - - if (flag2) - QueenSlime_FlyMovement_Vanilla(npc); - - break; - } - } - - npc.dontTakeDamage = (npc.hide = flag); - if (num3 != npc.scale) - { - npc.position.X += npc.width / 2; - npc.position.Y += npc.height; - npc.scale = num3; - npc.width = (int)(114f * npc.scale); - npc.height = (int)(100f * npc.scale); - npc.position.X -= npc.width / 2; - npc.position.Y -= npc.height; - } - - if (npc.life <= 0) - return false; - - if (Main.netMode == NetmodeID.MultiplayerClient) - return false; - - if (npc.localAI[0] >= (float)(npc.lifeMax / 2) && npc.life < npc.lifeMax / 2) - { - npc.localAI[0] = npc.life; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - - int num29 = (int)((float)npc.lifeMax * 0.02f); - if (flag2) - num29 = (int)((float)npc.lifeMax * 0.015f); - - if (!((float)(npc.life + num29) < npc.localAI[0])) - return false; - - npc.localAI[0] = npc.life; - int num30 = Main.rand.Next(Main.masterMode ? 2 : 1, Main.masterMode ? 4 : 3); - for (int num31 = 0; num31 < num30; num31++) - { - int x = (int)(npc.position.X + (float)Main.rand.Next(npc.width - 32)); - int y = (int)(npc.position.Y + (float)Main.rand.Next(npc.height - 32)); - int num32 = NPCID.QueenSlimeMinionBlue; - switch (Main.rand.Next(3)) - { - case 0: - num32 = NPCID.QueenSlimeMinionBlue; - break; - case 1: - num32 = NPCID.QueenSlimeMinionPink; - break; - case 2: - num32 = NPCID.QueenSlimeMinionPurple; - break; - } - - int num33 = NPC.NewNPC(npc.GetSource_FromAI(), x, y, num32); - Main.npc[num33].SetDefaults(num32); - Main.npc[num33].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; - Main.npc[num33].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f; - Main.npc[num33].ai[0] = -500 * Main.rand.Next(3); - Main.npc[num33].ai[1] = 0f; - if (Main.dedServ && num33 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num33); - } - - return false; - } - public static void QueenSlime_FlyMovement(NPC npc) { // Difficulty bools - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; npc.noTileCollide = true; npc.noGravity = true; - float flyVelocity = bossRush ? 24f : death ? 21f : 16f; - float flyAcceleration = bossRush ? 0.3f : death ? 0.18f : 0.12f; + float flyVelocity = death ? 19f : 16f; + float flyAcceleration = death ? 0.15f : 0.12f; float flyDistanceY = death ? 350f : 450f; Vector2 desiredVelocity = npc.Center; @@ -1713,406 +988,349 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.rotation = -0.5f; } - public static void QueenSlime_FlyMovement_Vanilla(NPC npc) + public class CrystalSlimeAI : VanillaAIOverride { - npc.noTileCollide = true; - npc.noGravity = true; - float num = Main.masterMode ? 18f : Main.expertMode ? 15f : 12f; - float num2 = Main.masterMode ? 0.12f : Main.expertMode ? 0.1f : 0.085f; - float num3 = 250f; - Vector2 desiredVelocity = npc.Center; - if (npc.timeLeft > 10) + public override bool AI(Mod mod) { - if (!Collision.CanHit(npc, Main.player[npc.target])) + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + if (NPC.localAI[0] > 0f) + NPC.localAI[0] -= 1f; + + if (!NPC.wet && Main.player[NPC.target].active && !Main.player[NPC.target].dead && !Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - bool flag = false; - Vector2 center = Main.player[npc.target].Center; - for (int i = 0; i < 16; i++) + Player obj = Main.player[NPC.target]; + Vector2 center = NPC.Center; + float num19 = obj.Center.X - center.X; + float num20 = obj.Center.Y - center.Y; + float num21 = (float)Math.Sqrt(num19 * num19 + num20 * num20); + int num22 = NPC.CountNPCS(NPCID.QueenSlimeMinionBlue); + if (Main.expertMode && num22 < 5 && Math.Abs(num19) < 500f && Math.Abs(num20) < 550f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { - float num4 = 16 * i; - Point point = (center + new Vector2(0f, 0f - num4)).ToTileCoordinates(); - if (WorldGen.SolidOrSlopedTile(point.X, point.Y)) + NPC.ai[0] = -40f; + if (NPC.velocity.Y == 0f) + NPC.velocity.X *= 0.9f; + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.localAI[0] == 0f) { - desiredVelocity = center + new Vector2(0f, 0f - num4 + 16f) - npc.Center; - flag = true; - break; + for (int k = 0; k < 3; k++) + { + Vector2 vector6 = new Vector2(k - 1, -4f); + vector6.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + vector6.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + vector6.Normalize(); + vector6 *= 6f + (float)Main.rand.Next(-50, 51) * 0.01f; + if (num21 > 350f) + vector6 *= 2f; + else if (num21 > 250f) + vector6 *= 1.5f; + + int type = ProjectileID.QueenSlimeMinionBlueSpike; + Projectile.NewProjectile(NPC.GetSource_FromAI(), center, vector6 * (death ? 0.8f : 0.5f), type, SpikeDamage, 0f, Main.myPlayer); + NPC.localAI[0] = 25f; + if (num22 > 4) + break; + } } } - - if (!flag) - desiredVelocity = center - npc.Center; - } - else - desiredVelocity = Main.player[npc.target].Center + new Vector2(0f, 0f - num3) - npc.Center; - } - else - desiredVelocity = npc.Center + new Vector2(500f * (float)npc.direction, 0f - num3) - npc.Center; - - float num5 = desiredVelocity.Length(); - if (Math.Abs(desiredVelocity.X) < 40f) - desiredVelocity.X = npc.velocity.X; - - float num6 = num - 2f; - if (num5 > 100f && ((npc.velocity.X < 0f - num6 && desiredVelocity.X > 0f) || (npc.velocity.X > num6 && desiredVelocity.X < 0f))) - num2 *= 2f; - - if (num5 < 40f) - { - desiredVelocity = npc.velocity; - } - else if (num5 < 80f) - { - desiredVelocity = desiredVelocity.SafeNormalize(Vector2.UnitY); - desiredVelocity *= num * 0.65f; - } - else - { - desiredVelocity = desiredVelocity.SafeNormalize(Vector2.UnitY); - desiredVelocity *= num; - } - - npc.SimpleFlyMovement(desiredVelocity, num2); - npc.rotation = npc.velocity.X * 0.1f; - if (npc.rotation > 0.5f) - npc.rotation = 0.5f; - - if (npc.rotation < -0.5f) - npc.rotation = -0.5f; - } - - public static bool QueenSlimeCrystalSlimeAI(NPC npc, Mod mod) - { - if (npc.localAI[0] > 0f) - npc.localAI[0] -= 1f; - - if (!npc.wet && Main.player[npc.target].active && !Main.player[npc.target].dead && !Main.player[npc.target].npcTypeNoAggro[npc.type]) - { - Player obj = Main.player[npc.target]; - Vector2 center = npc.Center; - float num19 = obj.Center.X - center.X; - float num20 = obj.Center.Y - center.Y; - float num21 = (float)Math.Sqrt(num19 * num19 + num20 * num20); - int num22 = NPC.CountNPCS(NPCID.QueenSlimeMinionBlue); - if (Main.expertMode && num22 < 5 && Math.Abs(num19) < 500f && Math.Abs(num20) < 550f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && npc.velocity.Y == 0f) - { - npc.ai[0] = -40f; - if (npc.velocity.Y == 0f) - npc.velocity.X *= 0.9f; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) + else if (Math.Abs(num19) < 500f && Math.Abs(num20) < 550f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { - for (int k = 0; k < 3; k++) + float num23 = num21; + NPC.ai[0] = -40f; + if (NPC.velocity.Y == 0f) + NPC.velocity.X *= 0.9f; + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.localAI[0] == 0f) { - Vector2 vector6 = new Vector2(k - 1, -4f); - vector6.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector6.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector6.Normalize(); - vector6 *= 6f + (float)Main.rand.Next(-50, 51) * 0.01f; - if (num21 > 350f) - vector6 *= 2f; - else if (num21 > 250f) - vector6 *= 1.5f; - - int type = ProjectileID.QueenSlimeMinionBlueSpike; - Projectile.NewProjectile(npc.GetSource_FromAI(), center, vector6 * ((Main.masterMode || BossRushEvent.BossRushActive) ? 0.8f : 0.5f), type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); - npc.localAI[0] = 25f; - if (num22 > 4) - break; - } - } - } - else if (Math.Abs(num19) < 500f && Math.Abs(num20) < 550f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && npc.velocity.Y == 0f) - { - float num23 = num21; - npc.ai[0] = -40f; - if (npc.velocity.Y == 0f) - npc.velocity.X *= 0.9f; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) - { - num20 = Main.player[npc.target].position.Y - center.Y - (float)Main.rand.Next(0, 200); - num21 = (float)Math.Sqrt(num19 * num19 + num20 * num20); - num21 = 4.5f / num21; - num21 *= 2f; - if (num23 > 350f) + num20 = Main.player[NPC.target].position.Y - center.Y - (float)Main.rand.Next(0, 200); + num21 = (float)Math.Sqrt(num19 * num19 + num20 * num20); + num21 = 4.5f / num21; num21 *= 2f; - else if (num23 > 250f) - num21 *= 1.5f; + if (num23 > 350f) + num21 *= 2f; + else if (num23 > 250f) + num21 *= 1.5f; - num19 *= num21; - num20 *= num21; - npc.localAI[0] = 50f; - int type = ProjectileID.QueenSlimeMinionBlueSpike; - Vector2 spikeVelocity = new Vector2(num19, num20) * ((Main.masterMode || BossRushEvent.BossRushActive) ? 0.8f : 0.5f); - Projectile.NewProjectile(npc.GetSource_FromAI(), center, spikeVelocity, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); + num19 *= num21; + num20 *= num21; + NPC.localAI[0] = 50f; + int type = ProjectileID.QueenSlimeMinionBlueSpike; + Vector2 spikeVelocity = new Vector2(num19, num20) * (death ? 0.8f : 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), center, spikeVelocity, type, SpikeDamage, 0f, Main.myPlayer); + } } } - } - if (npc.ai[2] > 1f) - npc.ai[2] -= 1f; + if (NPC.ai[2] > 1f) + NPC.ai[2] -= 1f; - if (npc.wet) - { - if (npc.collideY) - npc.velocity.Y = -2f; - - if (npc.velocity.Y < 0f && npc.ai[3] == npc.position.X) + if (NPC.wet) { - npc.direction *= -1; - npc.ai[2] = 200f; - } + if (NPC.collideY) + NPC.velocity.Y = -2f; - if (npc.velocity.Y > 0f) - npc.ai[3] = npc.position.X; - - if (npc.velocity.Y > 2f) - npc.velocity.Y *= 0.9f; - - npc.velocity.Y -= 0.5f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - - if (npc.ai[2] == 1f) - CalamityUtils.CalamityTargeting(npc, default); - } - - npc.aiAction = 0; - if (npc.ai[2] == 0f) - { - npc.ai[0] = -100f; - npc.ai[2] = 1f; - CalamityUtils.CalamityTargeting(npc, default); - } - - if (npc.velocity.Y == 0f) - { - if (npc.collideY && npc.oldVelocity.Y != 0f && Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.position.X -= npc.velocity.X + (float)npc.direction; - - if (npc.ai[3] == npc.position.X) - { - npc.direction *= -1; - npc.ai[2] = 200f; - } - - npc.ai[3] = 0f; - npc.velocity.X *= 0.8f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - npc.ai[0] += (Main.masterMode ? 16f : Main.expertMode ? 10f : 7f); - - float num33 = -1000f; - - int num34 = 0; - if (npc.ai[0] >= 0f) - num34 = 1; - - if (npc.ai[0] >= num33 && npc.ai[0] <= num33 * 0.5f) - num34 = 2; - - if (npc.ai[0] >= num33 * 2f && npc.ai[0] <= num33 * 1.5f) - num34 = 3; - - if (num34 > 0) - { - npc.netUpdate = true; - if (npc.ai[2] == 1f) - CalamityUtils.CalamityTargeting(npc, default); - - if (num34 == 3) + if (NPC.velocity.Y < 0f && NPC.ai[3] == NPC.position.X) { - npc.velocity.Y = -8f; - npc.velocity.X += (Main.masterMode ? 9 : Main.expertMode ? 6 : 3) * npc.direction; - npc.ai[0] = -200f; - npc.ai[3] = npc.position.X; + NPC.direction *= -1; + NPC.ai[2] = 200f; } - else + + if (NPC.velocity.Y > 0f) + NPC.ai[3] = NPC.position.X; + + if (NPC.velocity.Y > 2f) + NPC.velocity.Y *= 0.9f; + + NPC.velocity.Y -= 0.5f; + if (NPC.velocity.Y < -4f) + NPC.velocity.Y = -4f; + + if (NPC.ai[2] == 1f) + CalamityUtils.CalamityTargeting(NPC, default); + } + + NPC.aiAction = 0; + if (NPC.ai[2] == 0f) + { + NPC.ai[0] = -100f; + NPC.ai[2] = 1f; + CalamityUtils.CalamityTargeting(NPC, default); + } + + if (NPC.velocity.Y == 0f) + { + if (NPC.collideY && NPC.oldVelocity.Y != 0f && Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.position.X -= NPC.velocity.X + (float)NPC.direction; + + if (NPC.ai[3] == NPC.position.X) { - npc.velocity.Y = -6f; - npc.velocity.X += (Main.masterMode ? 6 : Main.expertMode ? 4 : 2) * npc.direction; - npc.ai[0] = -120f; - if (num34 == 1) - npc.ai[0] += num33; + NPC.direction *= -1; + NPC.ai[2] = 200f; + } + + NPC.ai[3] = 0f; + NPC.velocity.X *= 0.8f; + if ((double)NPC.velocity.X > -0.1 && (double)NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + + NPC.ai[0] += (death ? 16f : Main.expertMode ? 10f : 7f); + + float num33 = -1000f; + + int num34 = 0; + if (NPC.ai[0] >= 0f) + num34 = 1; + + if (NPC.ai[0] >= num33 && NPC.ai[0] <= num33 * 0.5f) + num34 = 2; + + if (NPC.ai[0] >= num33 * 2f && NPC.ai[0] <= num33 * 1.5f) + num34 = 3; + + if (num34 > 0) + { + NPC.netUpdate = true; + if (NPC.ai[2] == 1f) + CalamityUtils.CalamityTargeting(NPC, default); + + if (num34 == 3) + { + NPC.velocity.Y = -8f; + NPC.velocity.X += (death ? 9 : Main.expertMode ? 6 : 3) * NPC.direction; + NPC.ai[0] = -200f; + NPC.ai[3] = NPC.position.X; + } else - npc.ai[0] += num33 * 2f; + { + NPC.velocity.Y = -6f; + NPC.velocity.X += (death ? 6 : Main.expertMode ? 4 : 2) * NPC.direction; + NPC.ai[0] = -120f; + if (num34 == 1) + NPC.ai[0] += num33; + else + NPC.ai[0] += num33 * 2f; + } } + else if (NPC.ai[0] >= -30f) + NPC.aiAction = 1; } - else if (npc.ai[0] >= -30f) - npc.aiAction = 1; + else if (NPC.target < Main.maxPlayers && ((NPC.direction == 1 && NPC.velocity.X < 3f) || (NPC.direction == -1 && NPC.velocity.X > -3f))) + { + if (NPC.collideX && Math.Abs(NPC.velocity.X) == 0.2f) + NPC.position.X -= 1.4f * (float)NPC.direction; + + if (NPC.collideY && NPC.oldVelocity.Y != 0f && Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.position.X -= NPC.velocity.X + (float)NPC.direction; + + if ((NPC.direction == -1 && (double)NPC.velocity.X < 0.01) || (NPC.direction == 1 && (double)NPC.velocity.X > -0.01)) + NPC.velocity.X += 0.2f * (float)NPC.direction; + else + NPC.velocity.X *= 0.93f; + } + + return false; } - else if (npc.target < Main.maxPlayers && ((npc.direction == 1 && npc.velocity.X < 3f) || (npc.direction == -1 && npc.velocity.X > -3f))) - { - if (npc.collideX && Math.Abs(npc.velocity.X) == 0.2f) - npc.position.X -= 1.4f * (float)npc.direction; - - if (npc.collideY && npc.oldVelocity.Y != 0f && Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.position.X -= npc.velocity.X + (float)npc.direction; - - if ((npc.direction == -1 && (double)npc.velocity.X < 0.01) || (npc.direction == 1 && (double)npc.velocity.X > -0.01)) - npc.velocity.X += 0.2f * (float)npc.direction; - else - npc.velocity.X *= 0.93f; - } - - return false; } - public static bool QueenSlimeBouncySlimeAI(NPC npc, Mod mod) + public class BouncySlimeAI : VanillaAIOverride { - if (npc.localAI[0] > 0f) - npc.localAI[0] -= 1f; - - if (!npc.wet && Main.player[npc.target].active && !Main.player[npc.target].dead && !Main.player[npc.target].npcTypeNoAggro[npc.type]) + public override bool AI(Mod mod) { - Player obj2 = Main.player[npc.target]; - Vector2 center2 = npc.Center; - float num24 = obj2.Center.X - center2.X; - float num25 = obj2.Center.Y - center2.Y; - float num26 = (float)Math.Sqrt(num24 * num24 + num25 * num25); - float num27 = num26; - if (Math.Abs(num24) < 500f && Math.Abs(num25) < 550f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && npc.velocity.Y == 0f) + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + if (NPC.localAI[0] > 0f) + NPC.localAI[0] -= 1f; + + if (!NPC.wet && Main.player[NPC.target].active && !Main.player[NPC.target].dead && !Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - npc.ai[0] = -40f; - if (npc.velocity.Y == 0f) - npc.velocity.X *= 0.9f; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) + Player obj2 = Main.player[NPC.target]; + Vector2 center2 = NPC.Center; + float num24 = obj2.Center.X - center2.X; + float num25 = obj2.Center.Y - center2.Y; + float num26 = (float)Math.Sqrt(num24 * num24 + num25 * num25); + float num27 = num26; + if (Math.Abs(num24) < 500f && Math.Abs(num25) < 550f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { - num25 = Main.player[npc.target].position.Y - center2.Y - (float)Main.rand.Next(0, 200); - num26 = (float)Math.Sqrt(num24 * num24 + num25 * num25); - num26 = 4.5f / num26; - num26 *= 2f; - if (num27 > 350f) - num26 *= 1.75f; - else if (num27 > 250f) - num26 *= 1.25f; + NPC.ai[0] = -40f; + if (NPC.velocity.Y == 0f) + NPC.velocity.X *= 0.9f; - num24 *= num26; - num25 *= num26; - npc.localAI[0] = 40f; - if (Main.expertMode) - npc.localAI[0] = 30f; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.localAI[0] == 0f) + { + num25 = Main.player[NPC.target].position.Y - center2.Y - (float)Main.rand.Next(0, 200); + num26 = (float)Math.Sqrt(num24 * num24 + num25 * num25); + num26 = 4.5f / num26; + num26 *= 2f; + if (num27 > 350f) + num26 *= 1.75f; + else if (num27 > 250f) + num26 *= 1.25f; - int type = ProjectileID.QueenSlimeMinionPinkBall; - Vector2 pinkBallVelocity = new Vector2(num24, num25) * ((Main.masterMode || BossRushEvent.BossRushActive) ? 0.8f : 0.5f); - Projectile.NewProjectile(npc.GetSource_FromAI(), center2, pinkBallVelocity, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer); + num24 *= num26; + num25 *= num26; + NPC.localAI[0] = 40f; + if (Main.expertMode) + NPC.localAI[0] = 30f; + + int type = ProjectileID.QueenSlimeMinionPinkBall; + Vector2 pinkBallVelocity = new Vector2(num24, num25) * (death ? 0.8f : 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), center2, pinkBallVelocity, type, SmallGelDamage, 0f, Main.myPlayer); + } } } - } - if (npc.ai[2] > 1f) - npc.ai[2] -= 1f; + if (NPC.ai[2] > 1f) + NPC.ai[2] -= 1f; - if (npc.wet) - { - if (npc.collideY) - npc.velocity.Y = -2f; - - if (npc.velocity.Y < 0f && npc.ai[3] == npc.position.X) + if (NPC.wet) { - npc.direction *= -1; - npc.ai[2] = 200f; - } + if (NPC.collideY) + NPC.velocity.Y = -2f; - if (npc.velocity.Y > 0f) - npc.ai[3] = npc.position.X; - - if (npc.velocity.Y > 2f) - npc.velocity.Y *= 0.9f; - - npc.velocity.Y -= 0.5f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - - if (npc.ai[2] == 1f) - CalamityUtils.CalamityTargeting(npc, default); - } - - npc.aiAction = 0; - if (npc.ai[2] == 0f) - { - npc.ai[0] = -100f; - npc.ai[2] = 1f; - CalamityUtils.CalamityTargeting(npc, default); - } - - if (npc.velocity.Y == 0f) - { - if (npc.collideY && npc.oldVelocity.Y != 0f && Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.position.X -= npc.velocity.X + (float)npc.direction; - - if (npc.ai[3] == npc.position.X) - { - npc.direction *= -1; - npc.ai[2] = 200f; - } - - npc.ai[3] = 0f; - npc.velocity.X *= 0.8f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - npc.ai[0] += (Main.masterMode ? 11f : Main.expertMode ? 7f : 5f); - - float num33 = -500f; - - int num34 = 0; - if (npc.ai[0] >= 0f) - num34 = 1; - - if (npc.ai[0] >= num33 && npc.ai[0] <= num33 * 0.5f) - num34 = 2; - - if (npc.ai[0] >= num33 * 2f && npc.ai[0] <= num33 * 1.5f) - num34 = 3; - - if (num34 > 0) - { - npc.netUpdate = true; - if (npc.ai[2] == 1f) - CalamityUtils.CalamityTargeting(npc, default); - - if (num34 == 3) + if (NPC.velocity.Y < 0f && NPC.ai[3] == NPC.position.X) { - npc.velocity.Y = -8f; - npc.velocity.X += (Main.masterMode ? 9 : Main.expertMode ? 6 : 3) * npc.direction; - npc.ai[0] = -200f; - npc.ai[3] = npc.position.X; + NPC.direction *= -1; + NPC.ai[2] = 200f; } - else + + if (NPC.velocity.Y > 0f) + NPC.ai[3] = NPC.position.X; + + if (NPC.velocity.Y > 2f) + NPC.velocity.Y *= 0.9f; + + NPC.velocity.Y -= 0.5f; + if (NPC.velocity.Y < -4f) + NPC.velocity.Y = -4f; + + if (NPC.ai[2] == 1f) + CalamityUtils.CalamityTargeting(NPC, default); + } + + NPC.aiAction = 0; + if (NPC.ai[2] == 0f) + { + NPC.ai[0] = -100f; + NPC.ai[2] = 1f; + CalamityUtils.CalamityTargeting(NPC, default); + } + + if (NPC.velocity.Y == 0f) + { + if (NPC.collideY && NPC.oldVelocity.Y != 0f && Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.position.X -= NPC.velocity.X + (float)NPC.direction; + + if (NPC.ai[3] == NPC.position.X) { - npc.velocity.Y = -6f; - npc.velocity.X += (Main.masterMode ? 6 : Main.expertMode ? 4 : 2) * npc.direction; - npc.ai[0] = -120f; - if (num34 == 1) - npc.ai[0] += num33; + NPC.direction *= -1; + NPC.ai[2] = 200f; + } + + NPC.ai[3] = 0f; + NPC.velocity.X *= 0.8f; + if ((double)NPC.velocity.X > -0.1 && (double)NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + + NPC.ai[0] += (death ? 11f : Main.expertMode ? 7f : 5f); + + float num33 = -500f; + + int num34 = 0; + if (NPC.ai[0] >= 0f) + num34 = 1; + + if (NPC.ai[0] >= num33 && NPC.ai[0] <= num33 * 0.5f) + num34 = 2; + + if (NPC.ai[0] >= num33 * 2f && NPC.ai[0] <= num33 * 1.5f) + num34 = 3; + + if (num34 > 0) + { + NPC.netUpdate = true; + if (NPC.ai[2] == 1f) + CalamityUtils.CalamityTargeting(NPC, default); + + if (num34 == 3) + { + NPC.velocity.Y = -8f; + NPC.velocity.X += (death ? 9 : Main.expertMode ? 6 : 3) * NPC.direction; + NPC.ai[0] = -200f; + NPC.ai[3] = NPC.position.X; + } else - npc.ai[0] += num33 * 2f; + { + NPC.velocity.Y = -6f; + NPC.velocity.X += (death ? 6 : Main.expertMode ? 4 : 2) * NPC.direction; + NPC.ai[0] = -120f; + if (num34 == 1) + NPC.ai[0] += num33; + else + NPC.ai[0] += num33 * 2f; + } + + NPC.velocity.Y *= 1.6f; + NPC.velocity.X *= 1.2f; } - - npc.velocity.Y *= 1.6f; - npc.velocity.X *= 1.2f; + else if (NPC.ai[0] >= -30f) + NPC.aiAction = 1; } - else if (npc.ai[0] >= -30f) - npc.aiAction = 1; + else if (NPC.target < Main.maxPlayers && ((NPC.direction == 1 && NPC.velocity.X < 3f) || (NPC.direction == -1 && NPC.velocity.X > -3f))) + { + if (NPC.collideX && Math.Abs(NPC.velocity.X) == 0.2f) + NPC.position.X -= 1.4f * (float)NPC.direction; + + if (NPC.collideY && NPC.oldVelocity.Y != 0f && Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.position.X -= NPC.velocity.X + (float)NPC.direction; + + if ((NPC.direction == -1 && (double)NPC.velocity.X < 0.01) || (NPC.direction == 1 && (double)NPC.velocity.X > -0.01)) + NPC.velocity.X += 0.2f * (float)NPC.direction; + else + NPC.velocity.X *= 0.93f; + } + + return false; } - else if (npc.target < Main.maxPlayers && ((npc.direction == 1 && npc.velocity.X < 3f) || (npc.direction == -1 && npc.velocity.X > -3f))) - { - if (npc.collideX && Math.Abs(npc.velocity.X) == 0.2f) - npc.position.X -= 1.4f * (float)npc.direction; - - if (npc.collideY && npc.oldVelocity.Y != 0f && Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.position.X -= npc.velocity.X + (float)npc.direction; - - if ((npc.direction == -1 && (double)npc.velocity.X < 0.01) || (npc.direction == 1 && (double)npc.velocity.X > -0.01)) - npc.velocity.X += 0.2f * (float)npc.direction; - else - npc.velocity.X *= 0.93f; - } - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index d182231f38..ca6f324c7f 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -2,14 +2,16 @@ using CalamityMod.Events; 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; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class SkeletronAI + public class SkeletronAI : VanillaAIOverride { public const float ChargeGateValue = 600f; public const float ChargeTelegraphTime = 120f; @@ -18,23 +20,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public const float HandSwipeDistance = 960f; // 60 tiles public const float HandSwipeDistance_Master = 1280f; // 80 tiles - public static bool BuffedSkeletronAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Vanilla values + public static float SpinDamageMult = 1.3f; // 91 + public static int SkullDamage = 17; // 68; Also applies to crossbones - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + public override void SetDefaults(Mod mod) + { + DisableMultiplayerSmoothing = true; + } + + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phases float phase2LifeRatio = death ? 1f : 0.85f; float phase3LifeRatio = death ? 0.9f : 0.7f; float respawnHandsLifeRatio = 0.5f; float phase4LifeRatio = death ? 0.4f : 0.3f; - float useSkullSpreadsAfterChargeLifeRatio = death ? 0.3f : 0.2f; - float phase5LifeRatio = death ? 0.2f : 0.1f; + float phase5LifeRatio = death ? 0.15f : 0.1f; // Begin firing spreads of skulls phase bool phase2 = lifeRatio < phase2LifeRatio; @@ -48,101 +57,99 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Fire giant cursed skull projectiles (yes, these curse you if you get hit) during charge attack and hands fire skulls phase bool phase4 = lifeRatio < phase4LifeRatio; - // Self-explanatory - bool useSkullSpreadsAfterCharge = lifeRatio < useSkullSpreadsAfterChargeLifeRatio; - // Rapid teleport and charge, stop using idle phase bool phase5 = lifeRatio < phase5LifeRatio; // Set defense - npc.defense = npc.defDefense; + NPC.defense = NPC.defDefense; + NPC.damage = NPC.defDamage; - npc.reflectsProjectiles = false; + NPC.reflectsProjectiles = false; // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); // Spawn hands if (Main.netMode != NetmodeID.MultiplayerClient) { - if (npc.ai[0] == 0f) + if (NPC.ai[0] == 0f) { - npc.ai[0] = 1f; + NPC.ai[0] = 1f; SpawnHands(); - npc.netUpdate = true; + NPC.netUpdate = true; } // Respawn hands - if (respawnHands && calamityGlobalNPC.newAI[0] == 0f && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) + if (respawnHands && calamityGlobalNPC.newAI[0] == 0f && Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 160f) { calamityGlobalNPC.newAI[0] = 1f; - SoundEngine.PlaySound(SoundID.ForceRoar with { Pitch = SoundID.ForceRoar.Pitch - 0.25f }, npc.Center); + SoundEngine.PlaySound(SoundID.ForceRoar with { Pitch = SoundID.ForceRoar.Pitch - 0.25f }, NPC.Center); SpawnHands(); - npc.netUpdate = true; - npc.SyncExtraAI(); + NPC.netUpdate = true; + NPC.SyncExtraAI(); } void SpawnHands() { - int skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); + int skeletronHand = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.SkeletronHand, NPC.whoAmI); Main.npc[skeletronHand].ai[0] = death ? -1.3f : -1f; - Main.npc[skeletronHand].ai[1] = npc.whoAmI; - Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].ai[1] = NPC.whoAmI; + Main.npc[skeletronHand].target = NPC.target; Main.npc[skeletronHand].netUpdate = true; - skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); + skeletronHand = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.SkeletronHand, NPC.whoAmI); Main.npc[skeletronHand].ai[0] = death ? 1.3f : 1f; - Main.npc[skeletronHand].ai[1] = npc.whoAmI; + Main.npc[skeletronHand].ai[1] = NPC.whoAmI; Main.npc[skeletronHand].ai[3] = 150f; Main.npc[skeletronHand].Calamity().newAI[2] = 150f; - Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].target = NPC.target; Main.npc[skeletronHand].netUpdate = true; // Spawn two additional hands with different attack timings if (death) { - skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); + skeletronHand = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.SkeletronHand, NPC.whoAmI); Main.npc[skeletronHand].ai[0] = -1.3f; Main.npc[skeletronHand].Calamity().newAI[0] = -1f; - Main.npc[skeletronHand].ai[1] = npc.whoAmI; + Main.npc[skeletronHand].ai[1] = NPC.whoAmI; Main.npc[skeletronHand].ai[3] = respawnHands ? -75f : 0f; Main.npc[skeletronHand].Calamity().newAI[2] = respawnHands ? -75f : 0f; - Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].target = NPC.target; Main.npc[skeletronHand].netUpdate = true; - skeletronHand = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); + skeletronHand = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.SkeletronHand, NPC.whoAmI); Main.npc[skeletronHand].ai[0] = 1.3f; Main.npc[skeletronHand].Calamity().newAI[0] = -1f; - Main.npc[skeletronHand].ai[1] = npc.whoAmI; + Main.npc[skeletronHand].ai[1] = NPC.whoAmI; Main.npc[skeletronHand].ai[3] = respawnHands ? 75f : 150f; Main.npc[skeletronHand].Calamity().newAI[2] = respawnHands ? 75f : 150f; - Main.npc[skeletronHand].target = npc.target; + Main.npc[skeletronHand].target = NPC.target; Main.npc[skeletronHand].netUpdate = true; } } } // Despawn - if (npc.ai[1] != 3f) + if (NPC.ai[1] != 3f) { int despawnDistanceInTiles = 500; - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) - npc.ai[1] = 3f; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) + NPC.ai[1] = 3f; } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } // Daytime enrage - if (Main.IsItDay() && !bossRush && npc.ai[1] != 3f && npc.ai[1] != 2f) + if (Main.IsItDay() && !BossRushEvent.BossRushActive && NPC.ai[1] != 3f && NPC.ai[1] != 2f) { - npc.ai[1] = 2f; - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + NPC.ai[1] = 2f; + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); } // Hand count @@ -157,38 +164,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool handsDead = numHandsAlive == 0; int numProj = Main.getGoodWorld ? 22 : death ? 5 : 3; float spread = Main.getGoodWorld ? 180 : 60; - float headSpinVelocityMult = bossRush ? (phase3 ? 18f : 9f) : (phase3 ? 12f : 4.5f); + float headSpinVelocityMult = phase3 ? 12f : 4.5f; switch (numHandsAlive) { case 0: numProj = Main.getGoodWorld ? 36 : death ? 9 : 7; spread = Main.getGoodWorld ? 180 : death ? 90 : 82; - headSpinVelocityMult = bossRush ? (phase3 ? 18f : 12f) : (phase3 ? 12f : 6f); + headSpinVelocityMult = phase3 ? 12f : 6f; break; case 1: numProj = Main.getGoodWorld ? 27 : death ? 7 : 5; spread = Main.getGoodWorld ? 150 : death ? 76 : 68; - headSpinVelocityMult = bossRush ? (phase3 ? 15f : 10f) : (phase3 ? 11.5f : 5f); + headSpinVelocityMult = phase3 ? 11.5f : 5f; break; case 2: numProj = Main.getGoodWorld ? 18 : death ? 6 : 4; spread = Main.getGoodWorld ? 140 : death ? 70 : 62; - headSpinVelocityMult = bossRush ? (phase3 ? 13.5f : 9f) : (phase3 ? 11f : 4.5f); + headSpinVelocityMult = phase3 ? 11f : 4.5f; break; case 3: numProj = Main.getGoodWorld ? 15 : death ? 5 : 3; spread = Main.getGoodWorld ? 130 : death ? 64 : 56; - headSpinVelocityMult = bossRush ? (phase3 ? 12f : 8f) : (phase3 ? 10.5f : 4f); + headSpinVelocityMult = phase3 ? 10.5f : 4f; break; case 4: numProj = Main.getGoodWorld ? 12 : death ? 4 : 3; spread = Main.getGoodWorld ? 120 : 56; - headSpinVelocityMult = bossRush ? (phase3 ? 10f : 7f) : (phase3 ? 10f : 3.5f); + headSpinVelocityMult = phase3 ? 10f : 3.5f; break; } @@ -202,16 +209,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (death) - headSpinVelocityMult *= 1.2f; + headSpinVelocityMult *= 1.08f; // Very volatile value // Velocity used to move Skeletron away from the target before charging float moveAwayVelocity = headSpinVelocityMult; if (!phase3) - moveAwayVelocity *= (bossRush ? 1.5f : 2f); + moveAwayVelocity *= 2f; // Hand DR, scale DR up if the hands are still alive as Skeletron's HP lowers - npc.chaseable = handsDead; - float minDR = 0.05f; + NPC.chaseable = handsDead; + float minDR = 0f; float maxDR = 0.9999f; calamityGlobalNPC.DR = !handsDead ? (float)Math.Sqrt(MathHelper.Lerp(minDR, maxDR, respawnHands ? (respawnHandsLifeRatio - lifeRatio) / respawnHandsLifeRatio : 2f - lifeRatio / respawnHandsLifeRatio)) : minDR; calamityGlobalNPC.unbreakableDR = !handsDead; @@ -221,48 +228,47 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int teleportGateValue = phase5 ? 180 : 300; // Bool to disable skull firing after charging if teleport was recent or is about to happen - bool disableSkullsAfterCharge = npc.ai[3] <= 60f || npc.ai[3] > teleportGateValue + 60f; + bool disableSkullsAfterCharge = NPC.ai[3] <= 60f || NPC.ai[3] > teleportGateValue + 60f; // Teleport while not despawning - if (npc.ai[1] != 3f) + if (NPC.ai[1] != 3f) { int dustType = DustID.GemDiamond; // Post-teleport - if (npc.ai[3] == -60f) + if (NPC.ai[3] == -60f) { - npc.ai[3] = 0f; + NPC.ai[3] = 0f; - SoundEngine.PlaySound(SoundID.Item66, npc.Center); + SoundEngine.PlaySound(SoundID.Item66, NPC.Center); // Fire skulls after teleport - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.Skull; - int damage = npc.GetProjectileDamage(type); // Inverse parabolic projectile spreads - Vector2 baseVel = npc.SafeDirectionTo(Main.player[npc.target].Center) * (death ? 6f : 5f); - Vector2 firingPos = npc.Center + baseVel * 5f; + Vector2 baseVel = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (death ? 6f : 5f); + Vector2 firingPos = NPC.Center + baseVel * 5f; float centralCount = 0.5f * (numProj - 1f); for (int i = 0; i < numProj; i++) { float offset = MathHelper.ToRadians(MathHelper.Lerp(-spread * 0.5f, spread * 0.5f, i / (numProj - 1f))); float velocityMult = MathHelper.Lerp(0.5f, 1.5f, MathF.Abs(centralCount - i) / centralCount); - Projectile shot = Projectile.NewProjectileDirect(npc.GetSource_FromAI(), firingPos, baseVel.RotatedBy(offset) * velocityMult, type, damage, 0f, Main.myPlayer, -2f); + Projectile shot = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), firingPos, baseVel.RotatedBy(offset) * velocityMult, type, SkullDamage, 0f, Main.myPlayer, -2f); shot.timeLeft = 600; } - npc.netUpdate = true; + NPC.netUpdate = true; } } // Teleport dust for (int m = 0; m < 30; m++) { - int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 3f); + int teleportDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[teleportDust].noGravity = true; Main.dust[teleportDust].velocity.X *= 2f; } @@ -272,20 +278,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // If hands are dead: 7 seconds // If hands are not dead: 14 seconds // If hands are dead in phase 2: 4.7 seconds - npc.ai[3] += 1f + (((phase2 && handsDead) || bossRush || phase4) ? 0.5f : 0f) - ((handsDead || bossRush) ? 0f : 0.5f); + NPC.ai[3] += 1f + (((phase2 && handsDead) || phase4) ? 0.5f : 0f) - (handsDead ? 0f : 0.5f); // Dust to show teleport - int ai3 = (int)npc.ai[3]; // 0 to 30, and -60 - bool emitDust = false; + int ai3 = (int)NPC.ai[3]; // 0 to 30, and -60 - if (ai3 >= teleportGateValue && calamityGlobalNPC.newAI[2] == 0f && calamityGlobalNPC.newAI[3] == 0f) + if (NPC.localAI[0] == 1f && calamityGlobalNPC.newAI[2] == 0f && calamityGlobalNPC.newAI[3] == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 skullFaceDirection = npc.Center + new Vector2(npc.direction * 20, 6f); - Vector2 skullTargetDirection = Main.player[npc.target].Center - skullFaceDirection; - Point skullTileCoords = npc.Center.ToTileCoordinates(); - Point targetTileCoords = Main.player[npc.target].Center.ToTileCoordinates(); + Vector2 skullFaceDirection = NPC.Center + new Vector2(NPC.direction * 20, 6f); + Vector2 skullTargetDirection = Main.player[NPC.target].Center - skullFaceDirection; + Point skullTileCoords = NPC.Center.ToTileCoordinates(); + Point targetTileCoords = Main.player[NPC.target].Center.ToTileCoordinates(); int randomTeleportOffset = 20 - (int)Math.Ceiling(MathHelper.Lerp(0f, 10f, 1f - lifeRatio)); int skullPositionOffset = 4; int targetPositionOffset = randomTeleportOffset - 4; @@ -303,144 +308,123 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if ((teleportTileY < targetTileCoords.Y - targetPositionOffset || teleportTileY > targetTileCoords.Y + targetPositionOffset || teleportTileX < targetTileCoords.X - targetPositionOffset || teleportTileX > targetTileCoords.X + targetPositionOffset) && (teleportTileY < skullTileCoords.Y - skullPositionOffset || teleportTileY > skullTileCoords.Y + skullPositionOffset || teleportTileX < skullTileCoords.X - skullPositionOffset || teleportTileX > skullTileCoords.X + skullPositionOffset) && !Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) { // New location params - calamityGlobalNPC.newAI[2] = teleportTileX * 16 - npc.width / 2; - calamityGlobalNPC.newAI[3] = teleportTileY * 16 - npc.height; - npc.SyncExtraAI(); + calamityGlobalNPC.newAI[2] = teleportTileX * 16 - NPC.width / 2; + calamityGlobalNPC.newAI[3] = teleportTileY * 16 - NPC.height; + NPC.SyncExtraAI(); break; } } } } + // Teleport location telegraph if (calamityGlobalNPC.newAI[2] != 0f && calamityGlobalNPC.newAI[3] != 0f) { for (int m = 0; m < 5; m++) { Vector2 position = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); - int teleportDust = Dust.NewDust(position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 2f); + int teleportDust = Dust.NewDust(position, NPC.width, NPC.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[teleportDust].noGravity = true; } } - if (ai3 >= teleportGateValue + 90) - { - emitDust = true; - } - else if (ai3 >= teleportGateValue + 30) - { - if (Main.rand.Next(teleportGateValue + 10, ai3 + 1) >= teleportGateValue + 25) - emitDust = true; - } - - if (emitDust) - { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 1.5f); - Main.dust[dust].noGravity = true; - } - // Teleport - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[3] >= teleportGateValue + 120 && (!(npc.ai[1] == 1f && phase3) || death)) + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.localAI[0] == 0f && NPC.ai[1] != 1f && calamityGlobalNPC.newAI[2] != 0f && calamityGlobalNPC.newAI[3] != 0f) { // Teleport dust for (int m = 0; m < 30; m++) { - int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 3f); + int teleportDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[teleportDust].noGravity = true; Main.dust[teleportDust].velocity.X *= 2f; } // New location - npc.Center = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); + 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; + NPC.ai[3] = -60f; calamityGlobalNPC.newAI[2] = calamityGlobalNPC.newAI[3] = 0f; - npc.SyncExtraAI(); - npc.netUpdate = true; + NPC.SyncExtraAI(); + NPC.netUpdate = true; } } // Skull shooting - if ((handsDead || death) && npc.ai[1] == 0f && !phase4) + if ((handsDead) && NPC.ai[1] == 0f && !phase4) { - float skullProjFrequency = bossRush ? 15f : phase2 ? (48f - (death ? 17.5f * (1f - lifeRatio) : 0f)) : 60f; + float skullProjFrequency = phase2 ? (48f - (death ? 10f * (1f - lifeRatio) : 0f)) : 60f; if (Main.getGoodWorld) skullProjFrequency *= 0.8f; skullProjFrequency = (float)Math.Ceiling(skullProjFrequency); if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[1] % skullProjFrequency == 0f && calamityGlobalNPC.newAI[1] > 45f) { - Vector2 skullFiringPos = npc.Center; - float skullProjTargetX = Main.player[npc.target].Center.X - skullFiringPos.X; - float skullProjTargetY = Main.player[npc.target].Center.Y - skullFiringPos.Y; - if (Collision.CanHit(skullFiringPos, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + Vector2 skullFiringPos = NPC.Center; + float skullProjTargetX = Main.player[NPC.target].Center.X - skullFiringPos.X; + float skullProjTargetY = Main.player[NPC.target].Center.Y - skullFiringPos.Y; + if (Collision.CanHit(skullFiringPos, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float skullProjSpeed = phase2 ? (5f + (death ? 3f * (1f - lifeRatio) : 0f)) : 4f; - int spread2 = bossRush ? 100 : 50; + float skullProjSpeed = phase2 ? (5f + (death ? 1f * (1f - lifeRatio) : 0f)) : 4f; + int spread2 = 50; Vector2 skullProjDirection = new Vector2(skullProjTargetX + Main.rand.Next(-spread2, spread2 + 1) * 0.01f, skullProjTargetY + Main.rand.Next(-spread2, spread2 + 1) * 0.01f).SafeNormalize(Vector2.UnitY); skullProjDirection *= skullProjSpeed; - skullProjDirection += npc.velocity; + skullProjDirection += NPC.velocity; skullFiringPos += skullProjDirection * 5f; int type = ProjectileID.Skull; - int damage = npc.GetProjectileDamage(type); - int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), skullFiringPos, skullProjDirection, type, damage, 0f, Main.myPlayer, -1f); + int skullProjectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), skullFiringPos, skullProjDirection, type, SkullDamage, 0f, Main.myPlayer, -1f); Main.projectile[skullProjectile].timeLeft = 600; if (death && handsDead) { skullProjDirection = new Vector2(skullProjTargetX, skullProjTargetY).SafeNormalize(Vector2.UnitY); skullProjDirection *= skullProjSpeed * 2f; - int skullProjectile2 = Projectile.NewProjectile(npc.GetSource_FromAI(), skullFiringPos, skullProjDirection, type, damage, 0f, Main.myPlayer, -2f); + int skullProjectile2 = Projectile.NewProjectile(NPC.GetSource_FromAI(), skullFiringPos, skullProjDirection, type, SkullDamage, 0f, Main.myPlayer, -2f); Main.projectile[skullProjectile2].timeLeft = 600; } - npc.netUpdate = true; + NPC.netUpdate = true; } } } // Float above target - if (npc.ai[1] == 0f) + if (NPC.ai[1] == 0f) { - // Avoid cheap bullshit - npc.damage = 0; - calamityGlobalNPC.newAI[1] += 1f; - float chargePhaseChangeRateBoost = phase5 ? (death ? 24f : 14f) : phase4 ? (death ? 8f : 6f) : ((death ? 6f : 4f) * ((1f - lifeRatio) / (1f - phase4LifeRatio))); + float chargePhaseChangeRateBoost = phase5 ? (death ? 24f : 8f) : phase4 ? (death ? 6f : 4f) : ((death ? 4.5f : 3f) * ((1f - lifeRatio) / (1f - phase4LifeRatio))); if (!handsDead) - chargePhaseChangeRateBoost *= 0.5f; + chargePhaseChangeRateBoost *= 0.25f; float chargePhaseChangeRate = chargePhaseChangeRateBoost + 1f; - npc.ai[2] += chargePhaseChangeRate; - npc.localAI[1] += chargePhaseChangeRate; + NPC.ai[2] += chargePhaseChangeRate; + NPC.localAI[1] += chargePhaseChangeRate; float chargePhaseGateValue = ChargeGateValue; - if (npc.localAI[1] > chargePhaseGateValue) - npc.localAI[1] = chargePhaseGateValue; + if (NPC.localAI[1] > chargePhaseGateValue) + NPC.localAI[1] = chargePhaseGateValue; - float forcedMoveAwayTime = death ? 15f : 45f; - float canChargeDistance = phase3 ? 480f : 320f; // 20 tile distance, 30 tile distance in phase 3 - bool hasMovedForcedDistance = npc.localAI[2] >= forcedMoveAwayTime; - bool canCharge = Vector2.Distance(Main.player[npc.target].Center, npc.Center) >= canChargeDistance; - bool charge = npc.ai[2] >= chargePhaseGateValue && canCharge; - bool forceCharge = npc.ai[2] > chargePhaseGateValue + 120f * chargePhaseChangeRate; + float forcedMoveAwayTime = death ? 30f : 45f; + float canChargeDistance = 320f; // 20 tile distance + bool hasMovedForcedDistance = NPC.localAI[2] >= forcedMoveAwayTime; + bool canCharge = Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) >= canChargeDistance; + bool charge = NPC.ai[2] >= chargePhaseGateValue && canCharge; + bool forceCharge = NPC.ai[2] > chargePhaseGateValue + 120f; if (charge || forceCharge) { - npc.localAI[2] += 1f; - if (hasMovedForcedDistance || !phase3) + NPC.localAI[2] += 1f; + if ((hasMovedForcedDistance || !phase3) && Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[2] = 0f; - npc.ai[1] = 1f; - npc.localAI[1] = chargePhaseGateValue; - npc.localAI[2] = 0f; + NPC.ai[2] = 0f; + NPC.ai[1] = 1f; + NPC.localAI[0] = 1f; + NPC.localAI[1] = chargePhaseGateValue; + NPC.localAI[2] = 0f; calamityGlobalNPC.newAI[1] = 0f; - npc.SyncExtraAI(); - npc.SyncVanillaLocalAI(); - npc.netUpdate = true; + NPC.SyncExtraAI(); + NPC.SyncVanillaLocalAI(); + NPC.netUpdate = true; } } @@ -450,20 +434,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float headXTopSpeed = headXAcceleration * 100f; float deceleration = Main.getGoodWorld ? 0.83f : death ? 0.86f : 0.89f; - if (bossRush) - { - headYAcceleration *= 1.25f; - headXAcceleration *= 1.25f; - } - float moveAwayGateValue = chargePhaseGateValue - (5f + chargePhaseChangeRate); - bool moveAwayBeforeCharge = npc.ai[2] >= moveAwayGateValue; + bool moveAwayBeforeCharge = NPC.ai[2] >= moveAwayGateValue; if (moveAwayBeforeCharge) { if (!canCharge || !hasMovedForcedDistance) { - float phase5Multiplier = 1.33f; - float maxVelocity = (npc.ai[2] - moveAwayGateValue) * (moveAwayVelocity * 0.008f); + float phase5Multiplier = 1.2f; + float maxVelocity = (NPC.ai[2] - moveAwayGateValue) * (moveAwayVelocity * 0.002f); if (phase5) maxVelocity *= phase5Multiplier; @@ -473,93 +451,88 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (maxVelocity > maxVelocityCap) maxVelocity = maxVelocityCap; - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * -maxVelocity; - - npc.SyncMotionToServer(); + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * -maxVelocity; } // New charge attack if (phase3) { - npc.rotation += npc.direction * 0.3f; + NPC.rotation += NPC.direction * 0.3f; - if (npc.localAI[0] == 0f) + if (NPC.localAI[0] == 0f) { - npc.localAI[0] = 1f; - npc.SyncVanillaLocalAI(); + NPC.localAI[0] = 1f; + NPC.SyncVanillaLocalAI(); - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); } } else - npc.rotation = npc.velocity.X / 15f; + NPC.rotation = NPC.velocity.X / 15f; return false; } - npc.rotation = npc.velocity.X / 15f; + NPC.rotation = NPC.velocity.X / 15f; - if (npc.Top.Y > Main.player[npc.target].Top.Y - 250f) + if (NPC.Top.Y > Main.player[NPC.target].Top.Y - 250f) { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.98f; - npc.velocity.Y -= headYAcceleration; - if (npc.velocity.Y > headYTopSpeed) - npc.velocity.Y = headYTopSpeed; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.98f; + NPC.velocity.Y -= headYAcceleration; + if (NPC.velocity.Y > headYTopSpeed) + NPC.velocity.Y = headYTopSpeed; } - else if (npc.Top.Y < Main.player[npc.target].Top.Y - 250f) + else if (NPC.Top.Y < Main.player[NPC.target].Top.Y - 250f) { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.98f; - npc.velocity.Y += headYAcceleration; - if (npc.velocity.Y < -headYTopSpeed) - npc.velocity.Y = -headYTopSpeed; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.98f; + NPC.velocity.Y += headYAcceleration; + if (NPC.velocity.Y < -headYTopSpeed) + NPC.velocity.Y = -headYTopSpeed; } - if (npc.Center.X > Main.player[npc.target].Center.X) + if (NPC.Center.X > Main.player[NPC.target].Center.X) { - if (npc.velocity.X > 0f) - npc.velocity.X *= 0.98f; - npc.velocity.X -= headXAcceleration; - if (npc.velocity.X > headXTopSpeed) - npc.velocity.X = headXTopSpeed; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= 0.98f; + NPC.velocity.X -= headXAcceleration; + if (NPC.velocity.X > headXTopSpeed) + NPC.velocity.X = headXTopSpeed; } - if (npc.Center.X < Main.player[npc.target].Center.X) + if (NPC.Center.X < Main.player[NPC.target].Center.X) { - if (npc.velocity.X < 0f) - npc.velocity.X *= 0.98f; - npc.velocity.X += headXAcceleration; - if (npc.velocity.X < -headXTopSpeed) - npc.velocity.X = -headXTopSpeed; + if (NPC.velocity.X < 0f) + NPC.velocity.X *= 0.98f; + NPC.velocity.X += headXAcceleration; + if (NPC.velocity.X < -headXTopSpeed) + NPC.velocity.X = -headXTopSpeed; } } // Spin charge - else if (npc.ai[1] == 1f) + else if (NPC.ai[1] == 1f) { - // Set damage - npc.damage = npc.defDamage; - if (Main.getGoodWorld) { - npc.reflectsProjectiles = true; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == 0f) + NPC.reflectsProjectiles = true; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == 0f) { if (NPC.CountNPCS(NPCID.DarkCaster) < 6) { for (int i = 0; i < 1000; i++) { - int headYAcceleration = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); + int headYAcceleration = (int)(NPC.Center.X / 16f) + Main.rand.Next(-50, 51); int headYTopSpeed; - for (headYTopSpeed = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) + for (headYTopSpeed = (int)(NPC.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) { } headYTopSpeed--; if (!WorldGen.SolidTile(headYAcceleration, headYTopSpeed)) { - int headXAcceleration = NPC.NewNPC(npc.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DarkCaster); + int headXAcceleration = NPC.NewNPC(NPC.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DarkCaster); if (Main.dedServ && headXAcceleration < Main.maxNPCs) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, headXAcceleration); @@ -568,22 +541,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (CalamityWorld.LegendaryMode) + if (Main.zenithWorld) { if (!NPC.AnyNPCs(NPCID.DiabolistWhite)) { for (int i = 0; i < 1000; i++) { - int headYAcceleration = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); + int headYAcceleration = (int)(NPC.Center.X / 16f) + Main.rand.Next(-50, 51); int headYTopSpeed; - for (headYTopSpeed = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) + for (headYTopSpeed = (int)(NPC.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) { } headYTopSpeed--; if (!WorldGen.SolidTile(headYAcceleration, headYTopSpeed)) { - int headXAcceleration = NPC.NewNPC(npc.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DiabolistWhite); + int headXAcceleration = NPC.NewNPC(NPC.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DiabolistWhite); if (Main.dedServ && headXAcceleration < Main.maxNPCs) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, headXAcceleration); @@ -595,52 +568,31 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.defense -= 10; + NPC.defense = NPC.defDefense - 10; + NPC.damage = (int)Math.Round(NPC.defDamage * SpinDamageMult); float phaseChangeRateBoost = phase3 ? 0f : 1f - (lifeRatio - phase3LifeRatio) / (1f - phase3LifeRatio); - npc.ai[2] += 1f + phaseChangeRateBoost; + NPC.ai[2] += 1f + phaseChangeRateBoost; calamityGlobalNPC.newAI[1] += 1f; if (calamityGlobalNPC.newAI[1] == 2f) - SoundEngine.PlaySound(phase3 ? SoundID.ForceRoarPitched : SoundID.ForceRoar, npc.Center); - - // Shoot shadowflames (giant cursed skull projectiles) while charging in phase 4 - if (phase4 && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - float shadowFlameGateValue = 20f; - int shadowFlameLimit = death ? 3 : 2; - if (calamityGlobalNPC.newAI[1] % shadowFlameGateValue == 0f && calamityGlobalNPC.newAI[1] < shadowFlameGateValue * shadowFlameLimit) - { - // Spawn projectiles - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 240f) - { - float shadowFlameProjectileSpeed = death ? 6f : 4f; - Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * shadowFlameProjectileSpeed; - int type = ProjectileID.Shadowflames; - int damage = npc.GetProjectileDamage(type); - int shadowFlameProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); - Main.projectile[shadowFlameProjectile].timeLeft = 600; - } - } - } - } + SoundEngine.PlaySound(phase3 ? SoundID.ForceRoarPitched : SoundID.ForceRoar, NPC.Center); // Reset telegraph timer to create color fade - if (npc.localAI[1] > 0f) + if (NPC.localAI[1] > 0f) { - npc.localAI[1] -= 2f; - if (npc.localAI[1] <= 0f) + NPC.localAI[1] -= 2f; + if (NPC.localAI[1] <= 0f) { - npc.localAI[1] = 0f; - npc.SyncVanillaLocalAI(); + NPC.localAI[1] = 0f; + NPC.SyncVanillaLocalAI(); } } bool dontGoMach10 = false; float dashPhaseTime = death ? 210f : 300f; - if (npc.ai[2] >= dashPhaseTime) + //Netmode check fixes issues where attack ends at different times for server vs clients + if (NPC.ai[2] >= dashPhaseTime && Main.netMode != NetmodeID.MultiplayerClient) { if (Main.getGoodWorld) { @@ -648,16 +600,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { for (int j = 0; j < 1000; j++) { - int headYAcceleration = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); + int headYAcceleration = (int)(NPC.Center.X / 16f) + Main.rand.Next(-50, 51); int headYTopSpeed; - for (headYTopSpeed = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) + for (headYTopSpeed = (int)(NPC.Center.Y / 16f) + Main.rand.Next(-50, 51); headYTopSpeed < Main.maxTilesY - 10 && !WorldGen.SolidTile(headYAcceleration, headYTopSpeed); headYTopSpeed++) { } headYTopSpeed--; if (!WorldGen.SolidTile(headYAcceleration, headYTopSpeed)) { - int headXAcceleration = NPC.NewNPC(npc.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DarkCaster); + int headXAcceleration = NPC.NewNPC(NPC.GetSource_FromAI(), headYAcceleration * 16 + 8, headYTopSpeed * 16, NPCID.DarkCaster); if (Main.dedServ && headXAcceleration < Main.maxNPCs) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, headXAcceleration); @@ -667,60 +619,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (useSkullSpreadsAfterCharge && !disableSkullsAfterCharge && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - // Spawn projectiles - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int chargeSkullAmt = death ? 5 : 3; - int chargeSkullSpread = death ? 80 : 60; - float rotation = MathHelper.ToRadians(chargeSkullSpread); - float skullProjSpeed = phase5 ? (6f + (death ? 2f * ((phase5LifeRatio - lifeRatio) / phase5LifeRatio) : 0f)) : 4f; - Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; - int type = ProjectileID.Skull; - int damage = npc.GetProjectileDamage(type); - for (int k = 0; k < chargeSkullAmt + 1; k++) - { - Vector2 perturbedSpeed = initialProjectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, k / (float)(chargeSkullAmt - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center - perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, -1f); - Main.projectile[proj].timeLeft = 600; - if (death) - { - int proj2 = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center - perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, -2f); - Main.projectile[proj2].timeLeft = 600; - } - } - } - } - - npc.ai[2] = 0f; - npc.ai[1] = 0f; - npc.localAI[0] = 0f; - npc.localAI[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[1] = 0f; + NPC.localAI[0] = 0f; + NPC.localAI[1] = 0f; calamityGlobalNPC.newAI[1] = 0f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.SyncVanillaLocalAI(); - npc.SyncExtraAI(); - npc.netUpdate = true; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPC.SyncVanillaLocalAI(); + NPC.SyncExtraAI(); + NPC.netUpdate = true; dontGoMach10 = true; } - npc.rotation += npc.direction * 0.3f; + NPC.rotation += NPC.direction * 0.3f; - Vector2 headSpinPos = npc.Center; - float headSpinTargetX = Main.player[npc.target].Center.X - headSpinPos.X; - float headSpinTargetY = Main.player[npc.target].Center.Y - headSpinPos.Y; + Vector2 headSpinPos = NPC.Center; + float headSpinTargetX = Main.player[NPC.target].Center.X - headSpinPos.X; + float headSpinTargetY = Main.player[NPC.target].Center.Y - headSpinPos.Y; float headSpinTargetDist = (float)Math.Sqrt(headSpinTargetX * headSpinTargetX + headSpinTargetY * headSpinTargetY); // Increase speed while charging - npc.damage = (int)Math.Round(npc.defDamage * 1.3); - if (!phase3) { float velocityBoost = MathHelper.Lerp(0f, 3f, (1f - lifeRatio) / (1f - phase3LifeRatio)); - if (handsDead || bossRush) + if (handsDead) headSpinVelocityMult += velocityBoost; } @@ -745,76 +669,73 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Dash directly towards the target until within 15 tiles of the target, and then continue in the same direction float altDashPhaseTime = dashPhaseTime * (death ? 0.9f : 0.85f); - if (npc.ai[2] < altDashPhaseTime) + if (NPC.ai[2] < altDashPhaseTime) { - if (npc.Center.Distance(Main.player[npc.target].Center) > altDashStopDistance || npc.ai[2] == 1f + phaseChangeRateBoost) - npc.velocity = headSpinVelocity.SafeNormalize(Vector2.UnitY) * headSpinVelocityMult + npc.Center.DirectionTo(Main.player[npc.target].Center + (bossRush ? Main.player[npc.target].velocity * 20f : Vector2.Zero)) * 2f; + if (NPC.Center.Distance(Main.player[NPC.target].Center) > altDashStopDistance || NPC.ai[2] == 1f + phaseChangeRateBoost) + NPC.velocity = headSpinVelocity.SafeNormalize(Vector2.UnitY) * headSpinVelocityMult + NPC.Center.DirectionTo(Main.player[NPC.target].Center) * 2f; else - npc.ai[2] = altDashPhaseTime; + NPC.ai[2] = altDashPhaseTime; } } else - npc.velocity = headSpinVelocity; + NPC.velocity = headSpinVelocity; } } // Daytime enrage - else if (npc.ai[1] == 2f) + else if (NPC.ai[1] == 2f) { - npc.damage = 1000; + NPC.damage = 1000; calamityGlobalNPC.DR = 0.9999f; calamityGlobalNPC.unbreakableDR = true; calamityGlobalNPC.CurrentlyEnraged = true; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = true; - npc.rotation += npc.direction * 0.3f; - Vector2 enrageSpinPos = npc.Center; - float enrageSpinTargetX = Main.player[npc.target].Center.X - enrageSpinPos.X; - float enrageSpinTargetY = Main.player[npc.target].Center.Y - enrageSpinPos.Y; + NPC.rotation += NPC.direction * 0.3f; + Vector2 enrageSpinPos = NPC.Center; + float enrageSpinTargetX = Main.player[NPC.target].Center.X - enrageSpinPos.X; + float enrageSpinTargetY = Main.player[NPC.target].Center.Y - enrageSpinPos.Y; float enrageSpinTargetDist = (float)Math.Sqrt(enrageSpinTargetX * enrageSpinTargetX + enrageSpinTargetY * enrageSpinTargetY); enrageSpinTargetDist = 8f / enrageSpinTargetDist; - npc.velocity.X = enrageSpinTargetX * enrageSpinTargetDist; - npc.velocity.Y = enrageSpinTargetY * enrageSpinTargetDist; + NPC.velocity.X = enrageSpinTargetX * enrageSpinTargetDist; + NPC.velocity.Y = enrageSpinTargetY * enrageSpinTargetDist; } // Despawn - else if (npc.ai[1] == 3f) + else if (NPC.ai[1] == 3f) { // Disable teleports - if (npc.ai[3] != 0f || calamityGlobalNPC.newAI[2] != 0f || calamityGlobalNPC.newAI[3] != 0f) + if (NPC.ai[3] != 0f || calamityGlobalNPC.newAI[2] != 0f || calamityGlobalNPC.newAI[3] != 0f) { - npc.ai[3] = 0f; + NPC.ai[3] = 0f; calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; - npc.SyncExtraAI(); - npc.netUpdate = true; + NPC.SyncExtraAI(); + NPC.netUpdate = true; } - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.Y += 0.1f; - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.95f; - npc.velocity.X *= 0.95f; - if (npc.timeLeft > 50) - npc.timeLeft = 50; + NPC.velocity.Y += 0.1f; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.95f; + NPC.velocity.X *= 0.95f; + if (NPC.timeLeft > 50) + NPC.timeLeft = 50; } // Emit dust - if (npc.ai[1] != 2f && npc.ai[1] != 3f && numHandsAlive != 0) + if (NPC.ai[1] != 2f && NPC.ai[1] != 3f && numHandsAlive != 0) { - int idleDust = Dust.NewDust(new Vector2(npc.Center.X - 15f - npc.velocity.X * 5f, npc.position.Y + npc.height - 2f), 30, 10, DustID.Blood, -npc.velocity.X * 0.2f, 3f, 0, default, 2f); + int idleDust = Dust.NewDust(new Vector2(NPC.Center.X - 15f - NPC.velocity.X * 5f, NPC.position.Y + NPC.height - 2f), 30, 10, DustID.Blood, -NPC.velocity.X * 0.2f, 3f, 0, default, 2f); Main.dust[idleDust].noGravity = true; Main.dust[idleDust].velocity.X = Main.dust[idleDust].velocity.X * 1.3f; - Main.dust[idleDust].velocity.X = Main.dust[idleDust].velocity.X + npc.velocity.X * 0.4f; - Main.dust[idleDust].velocity.Y = Main.dust[idleDust].velocity.Y + (2f + npc.velocity.Y); + Main.dust[idleDust].velocity.X = Main.dust[idleDust].velocity.X + NPC.velocity.X * 0.4f; + Main.dust[idleDust].velocity.Y = Main.dust[idleDust].velocity.Y + (2f + NPC.velocity.Y); for (int j = 0; j < 2; j++) { - idleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 120f), npc.width, 60, DustID.Blood, npc.velocity.X, npc.velocity.Y, 0, default, 2f); + idleDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 120f), NPC.width, 60, DustID.Blood, NPC.velocity.X, NPC.velocity.Y, 0, default, 2f); Main.dust[idleDust].noGravity = true; - Main.dust[idleDust].velocity -= npc.velocity; + Main.dust[idleDust].velocity -= NPC.velocity; Main.dust[idleDust].velocity.Y = Main.dust[idleDust].velocity.Y + 5f; } } @@ -822,990 +743,419 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedSkeletronHandAI(NPC npc, Mod mod) + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - 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) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - float yMultiplier = 1f; - if (calamityGlobalNPC.newAI[0] != 0f) - yMultiplier = calamityGlobalNPC.newAI[0]; - if (death) - yMultiplier *= 1.3f; - - // Inflict 0 damage for 3 seconds after spawning - if (calamityGlobalNPC.newAI[1] < 180f) + // Telegraph for charges + float beginTelegraphGateValue = ChargeGateValue - ChargeTelegraphTime; + if (NPC.localAI[1] > beginTelegraphGateValue) { - calamityGlobalNPC.newAI[1] += 1f; - if (calamityGlobalNPC.newAI[1] % 15f == 0f) - npc.SyncExtraAI(); + float colorScale = MathHelper.Clamp((NPC.localAI[1] - beginTelegraphGateValue) / ChargeTelegraphTime, 0f, 1f); + Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; + var halfSize = NPC.frame.Size() / 2; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - npc.damage = 0; - } - else - npc.damage = npc.defDamage; - - npc.spriteDirection = -(int)npc.ai[0]; - - if (Main.npc[(int)npc.ai[1]].ai[3] == -60f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) + for (int i = 0; i < 2; i++) { - // Teleport dust - for (int m = 0; m < 10; m++) - { - int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.GemDiamond, 0f, 0f, 200, default, 3f); - Main.dust[teleportDust].noGravity = true; - Main.dust[teleportDust].velocity.X *= 2f; - } - - // New location - npc.Center = Main.npc[(int)npc.ai[1]].Center; - npc.velocity = Vector2.Zero; - npc.netUpdate = true; + spriteBatch.Draw(TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, + drawColor2, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); } } + } - float skeletronLifeRatio = 1f; - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronHead) + public class SkeletronHandAI : VanillaAIOverride + { + public override bool AI(Mod mod) { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + float yMultiplier = 1f; + if (calamityGlobalNPC.newAI[0] != 0f) + yMultiplier = calamityGlobalNPC.newAI[0]; + if (death) + yMultiplier *= 1.3f; + + // Inflict 0 damage for 3 seconds after spawning + if (calamityGlobalNPC.newAI[1] < 180f) { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] % 15f == 0f) + NPC.SyncExtraAI(); + + NPC.damage = 0; } - } - else - skeletronLifeRatio = Main.npc[(int)npc.ai[1]].life / (float)Main.npc[(int)npc.ai[1]].lifeMax; + else + NPC.damage = NPC.defDamage; - // This bool exists for fairness so the hands don't slap when Skeletron is in phase 3 and getting ready to do the new charge - bool cancelSlap = Main.npc[(int)npc.ai[1]].ai[2] >= ChargeGateValue; + NPC.spriteDirection = -(int)NPC.ai[0]; - // Fire skulls from hands at the end of each slap phase (master mode only) - bool phase2 = skeletronLifeRatio < 0.5f; - - // Attack far more often if still alive - bool phase3 = skeletronLifeRatio < 0.3f; - - float velocityMultiplier = MathHelper.Lerp(death ? 0.6f : 0.7f, 1f, skeletronLifeRatio); - float velocityIncrement = MathHelper.Lerp(0.2f, death ? 0.4f : 0.3f, 1f - skeletronLifeRatio); - float handSwipeVelocity = MathHelper.Lerp(16f, death ? 24f : 20f, 1f - skeletronLifeRatio); - float deceleration = Main.getGoodWorld ? 0.78f : death ? 0.82f : 0.86f; - - if (death) - { - velocityMultiplier *= 0.75f; - velocityIncrement *= 1.5f; - handSwipeVelocity *= 1.35f; - deceleration *= 0.75f; - } - - float handSwipeDistance = death ? HandSwipeDistance_Master : HandSwipeDistance; - float handSwipeDuration = handSwipeDistance / handSwipeVelocity; - float slapGateValue = HandSlapGateValue; - - float slapTimerIncrement = MathHelper.Lerp(death ? 1.5f : 1f, death ? 3f : 2f, 1f - skeletronLifeRatio); - if (phase3) - slapTimerIncrement *= (death ? 2.5f : 2f); - else if (phase2) - slapTimerIncrement *= (death ? 2f : 1.5f); - - if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) - npc.timeLeft = 10; - - if (Main.npc[(int)npc.ai[1]].ai[1] != 0f || cancelSlap) + if (Main.npc[(int)NPC.ai[1]].ai[3] == -60f) { - deceleration *= 0.75f; - velocityIncrement *= 1.5f; - - float maxX = velocityIncrement * 100f * velocityMultiplier; - float maxY = velocityIncrement * 100f * velocityMultiplier; - - if (npc.Top.Y > Main.npc[(int)npc.ai[1]].Top.Y - 100f * yMultiplier) + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - npc.velocity.Y -= velocityIncrement; - if (npc.velocity.Y > maxY) - npc.velocity.Y = maxY; - } - else if (npc.Top.Y < Main.npc[(int)npc.ai[1]].Top.Y - 100f * yMultiplier) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - npc.velocity.Y += velocityIncrement; - if (npc.velocity.Y < -maxY) - npc.velocity.Y = -maxY; + // Teleport dust + for (int m = 0; m < 10; m++) + { + int teleportDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemDiamond, 0f, 0f, 200, default, 3f); + Main.dust[teleportDust].noGravity = true; + Main.dust[teleportDust].velocity.X *= 2f; + } + + // New location + NPC.Center = Main.npc[(int)NPC.ai[1]].Center; + NPC.velocity = Vector2.Zero; + NPC.netUpdate = true; } + } - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) + float skeletronLifeRatio = 1f; + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPCAIStyleID.SkeletronHead) + { + NPC.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - npc.velocity.X -= velocityIncrement; - if (npc.velocity.X > maxX) - npc.velocity.X = maxX; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - npc.velocity.X += velocityIncrement; - if (npc.velocity.X < -maxX) - npc.velocity.X = -maxX; + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; } } else + skeletronLifeRatio = Main.npc[(int)NPC.ai[1]].life / (float)Main.npc[(int)NPC.ai[1]].lifeMax; + + // This bool exists for fairness so the hands don't slap when Skeletron is in phase 3 and getting ready to do the new charge + bool cancelSlap = Main.npc[(int)NPC.ai[1]].ai[2] >= ChargeGateValue; + + // Fire skulls from hands at the end of each slap phase (master mode only) + bool phase2 = skeletronLifeRatio < 0.5f; + + // Attack far more often if still alive + bool phase3 = skeletronLifeRatio < 0.3f; + + float velocityMultiplier = MathHelper.Lerp(death ? 0.6f : 0.7f, 1f, skeletronLifeRatio); + float velocityIncrement = MathHelper.Lerp(0.2f, death ? 0.4f : 0.3f, 1f - skeletronLifeRatio); + float handSwipeVelocity = MathHelper.Lerp(16f, death ? 24f : 20f, 1f - skeletronLifeRatio); + float deceleration = Main.getGoodWorld ? 0.78f : death ? 0.82f : 0.86f; + + if (death) { - if (calamityGlobalNPC.newAI[3] == 1f) + velocityMultiplier *= 0.75f; + velocityIncrement *= 1.5f; + handSwipeVelocity *= 1.35f; + deceleration *= 0.75f; + } + + float handSwipeDistance = death ? HandSwipeDistance_Master : HandSwipeDistance; + float handSwipeDuration = handSwipeDistance / handSwipeVelocity; + float slapGateValue = HandSlapGateValue; + + float slapTimerIncrement = MathHelper.Lerp(death ? 1.5f : 1f, death ? 3f : 2f, 1f - skeletronLifeRatio); + if (phase3) + slapTimerIncrement *= (death ? 2.5f : 2f); + else if (phase2) + slapTimerIncrement *= (death ? 2f : 1.5f); + + if (NPC.ai[2] == 0f || NPC.ai[2] == 3f) + { + if (Main.npc[(int)NPC.ai[1]].ai[1] == 3f && NPC.timeLeft > 10) + NPC.timeLeft = 10; + + if (Main.npc[(int)NPC.ai[1]].ai[1] != 0f || cancelSlap) { - calamityGlobalNPC.newAI[2] += slapTimerIncrement; - npc.ai[3] += slapTimerIncrement; - if (npc.ai[3] >= slapGateValue) + deceleration *= 0.75f; + velocityIncrement *= 1.5f; + + float maxX = velocityIncrement * 100f * velocityMultiplier; + float maxY = velocityIncrement * 100f * velocityMultiplier; + + if (NPC.Top.Y > Main.npc[(int)NPC.ai[1]].Top.Y - 100f * yMultiplier) { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.ai[2] += 1f; - npc.ai[3] = calamityGlobalNPC.newAI[2] = slapGateValue; - calamityGlobalNPC.newAI[3] = 0f; - npc.netUpdate = true; - npc.SyncExtraAI(); + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; + NPC.velocity.Y -= velocityIncrement; + if (NPC.velocity.Y > maxY) + NPC.velocity.Y = maxY; + } + else if (NPC.Top.Y < Main.npc[(int)NPC.ai[1]].Top.Y - 100f * yMultiplier) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; + NPC.velocity.Y += velocityIncrement; + if (NPC.velocity.Y < -maxY) + NPC.velocity.Y = -maxY; + } + + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X - 120f * NPC.ai[0]) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; + NPC.velocity.X -= velocityIncrement; + if (NPC.velocity.X > maxX) + NPC.velocity.X = maxX; + } + + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 120f * NPC.ai[0]) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; + NPC.velocity.X += velocityIncrement; + if (NPC.velocity.X < -maxX) + NPC.velocity.X = -maxX; } } else { - calamityGlobalNPC.newAI[2] -= slapTimerIncrement * 2f; - if (calamityGlobalNPC.newAI[2] <= 0f) + if (calamityGlobalNPC.newAI[3] == 1f) { - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 1f; - npc.SyncExtraAI(); + calamityGlobalNPC.newAI[2] += slapTimerIncrement; + NPC.ai[3] += slapTimerIncrement; + if (NPC.ai[3] >= slapGateValue) + { + NPC.target = Main.npc[(int)NPC.ai[1]].target; + NPC.ai[2] += 1f; + NPC.ai[3] = calamityGlobalNPC.newAI[2] = slapGateValue; + calamityGlobalNPC.newAI[3] = 0f; + NPC.netUpdate = true; + NPC.SyncExtraAI(); + } + } + else + { + calamityGlobalNPC.newAI[2] -= slapTimerIncrement * 2f; + if (calamityGlobalNPC.newAI[2] <= 0f) + { + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 1f; + NPC.SyncExtraAI(); + } + } + + float maxX = velocityIncrement * 100f * velocityMultiplier; + float maxY = velocityIncrement * 100f * velocityMultiplier; + + if (NPC.Top.Y > Main.npc[(int)NPC.ai[1]].Top.Y + 230f * yMultiplier) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; + NPC.velocity.Y -= velocityIncrement; + if (NPC.velocity.Y > maxY) + NPC.velocity.Y = maxY; + } + else if (NPC.Top.Y < Main.npc[(int)NPC.ai[1]].Top.Y + 230f * yMultiplier) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; + NPC.velocity.Y += velocityIncrement; + if (NPC.velocity.Y < -maxY) + NPC.velocity.Y = -maxY; + } + + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0]) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; + NPC.velocity.X -= velocityIncrement; + if (NPC.velocity.X > maxX) + NPC.velocity.X = maxX; + } + + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0]) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; + NPC.velocity.X += velocityIncrement; + if (NPC.velocity.X < -maxX) + NPC.velocity.X = -maxX; } } - float maxX = velocityIncrement * 100f * velocityMultiplier; - float maxY = velocityIncrement * 100f * velocityMultiplier; + Vector2 handCurrentPos = NPC.Center; + float handIdleXPos = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - handCurrentPos.X; + float handIdleYPos = Main.npc[(int)NPC.ai[1]].Top.Y + 230f - handCurrentPos.Y; + float handIdleDist = (float)Math.Sqrt(handIdleXPos * handIdleXPos + handIdleYPos * handIdleYPos); + NPC.rotation = (float)Math.Atan2(handIdleYPos, handIdleXPos) + MathHelper.PiOver2; - if (npc.Top.Y > Main.npc[(int)npc.ai[1]].Top.Y + 230f * yMultiplier) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - npc.velocity.Y -= velocityIncrement; - if (npc.velocity.Y > maxY) - npc.velocity.Y = maxY; - } - else if (npc.Top.Y < Main.npc[(int)npc.ai[1]].Top.Y + 230f * yMultiplier) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - npc.velocity.Y += velocityIncrement; - if (npc.velocity.Y < -maxY) - npc.velocity.Y = -maxY; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - npc.velocity.X -= velocityIncrement; - if (npc.velocity.X > maxX) - npc.velocity.X = maxX; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - npc.velocity.X += velocityIncrement; - if (npc.velocity.X < -maxX) - npc.velocity.X = -maxX; - } + return false; } - Vector2 handCurrentPos = npc.Center; - float handIdleXPos = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - handCurrentPos.X; - float handIdleYPos = Main.npc[(int)npc.ai[1]].Top.Y + 230f - handCurrentPos.Y; - float handIdleDist = (float)Math.Sqrt(handIdleXPos * handIdleXPos + handIdleYPos * handIdleYPos); - npc.rotation = (float)Math.Atan2(handIdleYPos, handIdleXPos) + MathHelper.PiOver2; + if (NPC.ai[2] == 1f) + { + Vector2 handCurrentPosition = NPC.Center; + float handDrawbackXPos = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - handCurrentPosition.X; + float handDrawbackYPos = Main.npc[(int)NPC.ai[1]].Top.Y + 230f - handCurrentPosition.Y; + float handDrawbackDist = (float)Math.Sqrt(handDrawbackXPos * handDrawbackXPos + handDrawbackYPos * handDrawbackYPos); + NPC.rotation = (float)Math.Atan2(handDrawbackYPos, handDrawbackXPos) + MathHelper.PiOver2; + NPC.velocity.X *= 0.95f; + NPC.velocity.Y -= velocityIncrement; + + if (NPC.velocity.Y < -14f) + NPC.velocity.Y = -14f; + else if (NPC.velocity.Y > 10f) + NPC.velocity.Y = 10f; + + if (NPC.Top.Y < Main.npc[(int)NPC.ai[1]].Top.Y - 200f) + { + NPC.ai[2] = 2f; + NPC.ai[3] = 0f; + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; + NPC.netUpdate = true; + } + } + else if (NPC.ai[2] == 2f) + { + NPC.ai[3] += 1f; + if (NPC.ai[3] >= handSwipeDuration || Vector2.Distance(Main.npc[(int)NPC.ai[1]].Center, NPC.Center) > handSwipeDistance || cancelSlap) + { + NPC.ai[2] = 3f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + + // Spawn projectiles + if (death && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && !cancelSlap) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (phase2 && Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 160f) + { + float skullProjSpeed = handSwipeVelocity * (phase3 ? 0.6f : 0.2f); + Vector2 initialProjectileVelocity = NPC.Center.DirectionTo(Main.player[NPC.target].Center) * skullProjSpeed; + int type = ProjectileID.Skull; + int skullProjectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, initialProjectileVelocity, type, SkullDamage, 0f, Main.myPlayer, -(phase3 ? 2f : 1f)); + Main.projectile[skullProjectile].timeLeft = 600; + } + } + } + } + } + else if (NPC.ai[2] == 4f) + { + Vector2 handStrikeCurrentPos = NPC.Center; + float handStrikeXPos = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - handStrikeCurrentPos.X; + float handStrikeYPos = Main.npc[(int)NPC.ai[1]].Top.Y + 230f - handStrikeCurrentPos.Y; + float handStrikeDist = (float)Math.Sqrt(handStrikeXPos * handStrikeXPos + handStrikeYPos * handStrikeYPos); + NPC.rotation = (float)Math.Atan2(handStrikeYPos, handStrikeXPos) + MathHelper.PiOver2; + NPC.velocity.Y *= 0.95f; + NPC.velocity.X += velocityIncrement * -NPC.ai[0]; + + if (NPC.velocity.X < -10f) + NPC.velocity.X = -10f; + else if (NPC.velocity.X > 14f) + NPC.velocity.X = 14f; + + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 500f || NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X + 500f) + { + NPC.ai[2] = 5f; + NPC.ai[3] = 0f; + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; + NPC.netUpdate = true; + } + } + else if (NPC.ai[2] == 5f) + { + NPC.ai[3] += 1f; + if (NPC.ai[3] >= handSwipeDuration || Vector2.Distance(Main.npc[(int)NPC.ai[1]].Center, NPC.Center) > handSwipeDistance || cancelSlap) + { + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + + // Spawn projectiles + if (death && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && !cancelSlap) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (phase2 && Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 160f) + { + float skullProjSpeed = handSwipeVelocity * (phase3 ? 0.6f : 0.2f); + Vector2 initialProjectileVelocity = NPC.Center.DirectionTo(Main.player[NPC.target].Center) * skullProjSpeed; + int type = ProjectileID.Skull; + int skullProjectile = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, initialProjectileVelocity, type, SkullDamage, 0f, Main.myPlayer, -(phase3 ? 2f : 1f)); + Main.projectile[skullProjectile].timeLeft = 600; + } + } + } + } + } return false; } - if (npc.ai[2] == 1f) + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 handCurrentPosition = npc.Center; - float handDrawbackXPos = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - handCurrentPosition.X; - float handDrawbackYPos = Main.npc[(int)npc.ai[1]].Top.Y + 230f - handCurrentPosition.Y; - float handDrawbackDist = (float)Math.Sqrt(handDrawbackXPos * handDrawbackXPos + handDrawbackYPos * handDrawbackYPos); - npc.rotation = (float)Math.Atan2(handDrawbackYPos, handDrawbackXPos) + MathHelper.PiOver2; - npc.velocity.X *= 0.95f; - npc.velocity.Y -= velocityIncrement; - - if (npc.velocity.Y < -14f) - npc.velocity.Y = -14f; - else if (npc.velocity.Y > 10f) - npc.velocity.Y = 10f; - - if (npc.Top.Y < Main.npc[(int)npc.ai[1]].Top.Y - 200f) + var calNPC = NPC.GetGlobalNPC(); + float beginTelegraphGateValue = HandSlapGateValue - HandSlapTelegraphTime; + if (calNPC.newAI[2] > beginTelegraphGateValue) { - // Set damage - npc.damage = npc.defDamage; + float colorScale = MathHelper.Clamp((calNPC.newAI[2] - beginTelegraphGateValue) / HandSlapTelegraphTime, 0f, 1f); + Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; + var halfSize = NPC.frame.Size() / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - npc.ai[2] = 2f; - npc.ai[3] = 0f; - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; - npc.netUpdate = true; + Vector2 glowOffset = Vector2.UnitY * 8f; + for (int i = 0; i < 2; i++) + { + spriteBatch.Draw(TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY) - glowOffset, NPC.frame, + drawColor2, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); + } } } - else if (npc.ai[2] == 2f) + } + + public class DungeonGuardianAI : VanillaAIOverride + { + public override bool AI(Mod mod) { - // Set damage - npc.damage = npc.defDamage; + return true; + } - npc.ai[3] += 1f; - if (npc.ai[3] >= handSwipeDuration || Vector2.Distance(Main.npc[(int)npc.ai[1]].Center, npc.Center) > handSwipeDistance || cancelSlap) + public override void PostAI(Mod mod) + { + Player target = Main.player[NPC.target]; + if (NPC.ai[1] != 3f) { - npc.ai[2] = 3f; - npc.ai[3] = 0f; - npc.netUpdate = true; - - // Spawn projectiles - if (death && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && !cancelSlap) + Vector2 targetVector = target.Center - NPC.Center; + float targetDist = targetVector.Length(); + targetDist = 12f / targetDist; + NPC.velocity.X = targetVector.X * targetDist; + NPC.velocity.Y = targetVector.Y * targetDist; + if (Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.localAI[1]++ % 60f == 59f) { - if (phase2 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) + Vector2 source = NPC.Center; + if (Collision.CanHit(source, 1, 1, target.Center, target.width, target.height)) { - float skullProjSpeed = handSwipeVelocity * (phase3 ? 0.6f : 0.2f); - Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; - int type = ProjectileID.Skull; - int damage = npc.GetProjectileDamage(type); - int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer, -(phase3 ? 2f : 1f)); - Main.projectile[skullProjectile].timeLeft = 600; + float speed = 5f; + float xDist = target.Center.X - source.X + Main.rand.Next(-20, 21); + float yDist = target.Center.Y - source.Y + Main.rand.Next(-20, 21); + Vector2 velocity = new Vector2(xDist, yDist); + float distTarget = velocity.Length(); + distTarget = speed / distTarget; + velocity.X *= distTarget; + velocity.Y *= distTarget; + Vector2 offset = new Vector2(velocity.X * 1f + Main.rand.Next(-50, 51) * 0.01f, velocity.Y * 1f + Main.rand.Next(-50, 51) * 0.01f).SafeNormalize(Vector2.UnitY); + offset *= speed; + offset += NPC.velocity; + velocity.X = offset.X; + velocity.Y = offset.Y; + int damage = 2500; + int projType = ProjectileID.Skull; + source += offset * 5f; + int skull = Projectile.NewProjectile(NPC.GetSource_FromAI(), source, velocity, projType, damage, 0f, Main.myPlayer, -1f); + Main.projectile[skull].timeLeft = 600; + Main.projectile[skull].tileCollide = false; } } } } } - else if (npc.ai[2] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 handStrikeCurrentPos = npc.Center; - float handStrikeXPos = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - handStrikeCurrentPos.X; - float handStrikeYPos = Main.npc[(int)npc.ai[1]].Top.Y + 230f - handStrikeCurrentPos.Y; - float handStrikeDist = (float)Math.Sqrt(handStrikeXPos * handStrikeXPos + handStrikeYPos * handStrikeYPos); - npc.rotation = (float)Math.Atan2(handStrikeYPos, handStrikeXPos) + MathHelper.PiOver2; - npc.velocity.Y *= 0.95f; - npc.velocity.X += velocityIncrement * -npc.ai[0]; - - if (npc.velocity.X < -10f) - npc.velocity.X = -10f; - else if (npc.velocity.X > 14f) - npc.velocity.X = 14f; - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 500f || npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 500f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] = 5f; - npc.ai[3] = 0f; - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 5f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[3] += 1f; - if (npc.ai[3] >= handSwipeDuration || Vector2.Distance(Main.npc[(int)npc.ai[1]].Center, npc.Center) > handSwipeDistance || cancelSlap) - { - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - - // Spawn projectiles - if (death && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && !cancelSlap) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (phase2 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) - { - float skullProjSpeed = handSwipeVelocity * (phase3 ? 0.6f : 0.2f); - Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; - int type = ProjectileID.Skull; - int damage = npc.GetProjectileDamage(type); - int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer, -(phase3 ? 2f : 1f)); - Main.projectile[skullProjectile].timeLeft = 600; - } - } - } - } - } - - return false; } - public static void RevengeanceDungeonGuardianAI(NPC npc) - { - Player target = Main.player[npc.target]; - if (npc.ai[1] != 3f) - { - Vector2 targetVector = target.Center - npc.Center; - float targetDist = targetVector.Length(); - targetDist = 12f / targetDist; - npc.velocity.X = targetVector.X * targetDist; - npc.velocity.Y = targetVector.Y * targetDist; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.localAI[1]++ % 60f == 59f) - { - Vector2 source = npc.Center; - if (Collision.CanHit(source, 1, 1, target.Center, target.width, target.height)) - { - float speed = 5f; - float xDist = target.Center.X - source.X + Main.rand.Next(-20, 21); - float yDist = target.Center.Y - source.Y + Main.rand.Next(-20, 21); - Vector2 velocity = new Vector2(xDist, yDist); - float distTarget = velocity.Length(); - distTarget = speed / distTarget; - velocity.X *= distTarget; - velocity.Y *= distTarget; - Vector2 offset = new Vector2(velocity.X * 1f + Main.rand.Next(-50, 51) * 0.01f, velocity.Y * 1f + Main.rand.Next(-50, 51) * 0.01f).SafeNormalize(Vector2.UnitY); - offset *= speed; - offset += npc.velocity; - velocity.X = offset.X; - velocity.Y = offset.Y; - int damage = 2500; - int projType = ProjectileID.Skull; - source += offset * 5f; - int skull = Projectile.NewProjectile(npc.GetSource_FromAI(), source, velocity, projType, damage, 0f, Main.myPlayer, -1f); - Main.projectile[skull].timeLeft = 600; - Main.projectile[skull].tileCollide = false; - } - } - } - } - } - - public static bool VanillaSkeletronAI(NPC npc, Mod mod) - { - npc.reflectsProjectiles = false; - npc.defense = npc.defDefense; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = 1f; - int num148 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); - Main.npc[num148].ai[0] = -1f; - Main.npc[num148].ai[1] = npc.whoAmI; - Main.npc[num148].target = npc.target; - Main.npc[num148].netUpdate = true; - num148 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); - Main.npc[num148].ai[0] = 1f; - Main.npc[num148].ai[1] = npc.whoAmI; - Main.npc[num148].ai[3] = 150f; - Main.npc[num148].target = npc.target; - Main.npc[num148].netUpdate = true; - } - - if (Main.netMode == NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) - npc.ai[1] = 3f; - } - - if (Main.IsItDay() && npc.ai[1] != 3f && npc.ai[1] != 2f) - { - npc.ai[1] = 2f; - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - - int numHands = 0; - int maxHands = 2; - if (Main.expertMode) - { - for (int num150 = 0; num150 < Main.maxNPCs; num150++) - { - if (Main.npc[num150].active && Main.npc[num150].type == NPCID.SkeletronHand) - numHands++; - } - - npc.defense += numHands * (Main.masterMode ? 15 : 10); - npc.Calamity().CurrentlyIncreasingDefenseOrDR = numHands > 0; - npc.chaseable = numHands == 0; - if ((numHands < maxHands || (double)npc.life < (double)npc.lifeMax * 0.75 || Main.masterMode) && npc.ai[1] == 0f) - { - float num151 = 80f; - if (numHands == 0 || Main.masterMode) - num151 /= 2f; - - if (Main.getGoodWorld) - num151 *= 0.8f; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % num151 == 0f) - { - Vector2 center3 = npc.Center; - float num152 = Main.player[npc.target].Center.X - center3.X; - float num153 = Main.player[npc.target].Center.Y - center3.Y; - float num154 = (float)Math.Sqrt(num152 * num152 + num153 * num153); - if (Collision.CanHit(center3, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - float num155 = 3f; - if (numHands == 0 || Main.masterMode) - num155 += 2f; - - float num156 = Main.player[npc.target].Center.X - center3.X + (float)Main.rand.Next(-5, 6); - float num157 = Main.player[npc.target].Center.Y - center3.Y + (float)Main.rand.Next(-5, 6); - float num158 = (float)Math.Sqrt(num156 * num156 + num157 * num157); - num158 = num155 / num158; - num156 *= num158; - num157 *= num158; - Vector2 vector19 = new Vector2(num156 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f, num157 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f).SafeNormalize(Vector2.UnitY); - vector19 *= num155; - vector19 += npc.velocity; - num156 = vector19.X; - num157 = vector19.Y; - int type = ProjectileID.Skull; - center3 += vector19 * 5f; - int num160 = Projectile.NewProjectile(npc.GetSource_FromAI(), center3.X, center3.Y, num156, num157, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer, -1f); - Main.projectile[num160].timeLeft = 300; - } - } - } - } - - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] += 1f; - float chargeGateValue = Main.masterMode ? (600f - (maxHands - numHands) * 200f) : 800f; - if (npc.ai[2] >= chargeGateValue) - { - npc.ai[2] = 0f; - npc.ai[1] = 1f; - npc.netUpdate = true; - } - - npc.rotation = npc.velocity.X / 15f; - float accelerationY = Main.getGoodWorld ? 0.05f : Main.masterMode ? 0.04f : Main.expertMode ? 0.03f : 0.02f; - float maxVelocityY = accelerationY * 100f; - float accelerationX = Main.getGoodWorld ? 0.093f : Main.masterMode ? 0.088f : Main.expertMode ? 0.076f : 0.064f; - float maxVelocityX = accelerationX * 100f; - float deceleration = Main.getGoodWorld ? 0.83f : Main.masterMode ? 0.86f : Main.expertMode ? 0.89f : 0.92f; - - if (npc.position.Y > Main.player[npc.target].position.Y - 250f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= accelerationY; - if (npc.velocity.Y > maxVelocityY) - npc.velocity.Y = maxVelocityY; - } - else if (npc.position.Y < Main.player[npc.target].position.Y - 250f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += accelerationY; - if (npc.velocity.Y < -maxVelocityY) - npc.velocity.Y = -maxVelocityY; - } - - if (npc.Center.X > Main.player[npc.target].Center.X) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= accelerationX; - if (npc.velocity.X > maxVelocityX) - npc.velocity.X = maxVelocityX; - } - - if (npc.Center.X < Main.player[npc.target].Center.X) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += accelerationX; - if (npc.velocity.X < 0f - maxVelocityX) - npc.velocity.X = 0f - maxVelocityX; - } - } - else if (npc.ai[1] == 1f) - { - if (Main.getGoodWorld) - { - if (numHands > 0) - { - npc.reflectsProjectiles = true; - } - else if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] % 200f == 0f && NPC.CountNPCS(NPCID.DarkCaster) < 6) - { - int num165 = 1; - for (int num166 = 0; num166 < num165; num166++) - { - int num167 = 1000; - for (int num168 = 0; num168 < num167; num168++) - { - int num169 = (int)(npc.Center.X / 16f) + Main.rand.Next(-50, 51); - int num170; - for (num170 = (int)(npc.Center.Y / 16f) + Main.rand.Next(-50, 51); num170 < Main.maxTilesY - 10 && !WorldGen.SolidTile(num169, num170); num170++) - { - } - - num170--; - if (!WorldGen.SolidTile(num169, num170)) - { - int num171 = NPC.NewNPC(npc.GetSource_FromAI(), num169 * 16 + 8, num170 * 16, NPCID.DarkCaster); - if (Main.dedServ && num171 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num171); - - break; - } - } - } - } - } - - npc.defense -= 10; - npc.ai[2] += 1f; - if (npc.ai[2] == 2f) - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - - float idlePhaseGateValue = Main.masterMode ? (300f - (maxHands - numHands) * 100f) : 400f; - if (npc.ai[2] >= idlePhaseGateValue) - { - npc.ai[2] = 0f; - npc.ai[1] = 0f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - } - - npc.rotation += (float)npc.direction * 0.3f; - Vector2 vector20 = npc.Center; - float num172 = Main.player[npc.target].Center.X - vector20.X; - float num173 = Main.player[npc.target].Center.Y - vector20.Y; - float num174 = (float)Math.Sqrt(num172 * num172 + num173 * num173); - float num175 = 3f; - npc.damage = (int)Math.Round(npc.defDamage * 1.3); - if (Main.expertMode) - { - num175 = Main.masterMode ? (5f - numHands * 0.5f) : 3.5f; - if (num174 > 150f) - num175 *= 1.05f; - - if (num174 > 200f) - num175 *= 1.1f; - - if (num174 > 250f) - num175 *= 1.1f; - - if (num174 > 300f) - num175 *= 1.1f; - - if (num174 > 350f) - num175 *= 1.1f; - - if (num174 > 400f) - num175 *= 1.1f; - - if (num174 > 450f) - num175 *= 1.1f; - - if (num174 > 500f) - num175 *= 1.1f; - - if (num174 > 550f) - num175 *= 1.1f; - - if (num174 > 600f) - num175 *= 1.1f; - - switch (numHands) - { - case 0: - num175 *= 1.1f; - break; - case 1: - num175 *= 1.05f; - break; - } - } - - if (Main.getGoodWorld) - num175 *= 1.3f; - - num174 = num175 / num174; - npc.velocity.X = num172 * num174; - npc.velocity.Y = num173 * num174; - } - else if (npc.ai[1] == 2f) - { - npc.damage = 1000; - npc.defense = 9999; - - npc.Calamity().CurrentlyEnraged = true; - npc.Calamity().CurrentlyIncreasingDefenseOrDR = true; - - npc.rotation += (float)npc.direction * 0.3f; - Vector2 vector21 = npc.Center; - float num176 = Main.player[npc.target].Center.X - vector21.X; - float num177 = Main.player[npc.target].Center.Y - vector21.Y; - float num178 = (float)Math.Sqrt(num176 * num176 + num177 * num177); - num178 = 8f / num178; - npc.velocity.X = num176 * num178; - npc.velocity.Y = num177 * num178; - } - else if (npc.ai[1] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.Y += 0.1f; - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.X *= 0.95f; - npc.EncourageDespawn(50); - } - - if (npc.ai[1] != 2f && npc.ai[1] != 3f && (numHands != 0 || !Main.expertMode)) - { - int num179 = Dust.NewDust(new Vector2(npc.Center.X - 15f - npc.velocity.X * 5f, npc.position.Y + (float)npc.height - 2f), 30, 10, DustID.Blood, (0f - npc.velocity.X) * 0.2f, 3f, 0, default(Color), 2f); - Main.dust[num179].noGravity = true; - Main.dust[num179].velocity.X *= 1.3f; - Main.dust[num179].velocity.X += npc.velocity.X * 0.4f; - Main.dust[num179].velocity.Y += 2f + npc.velocity.Y; - for (int num180 = 0; num180 < 2; num180++) - { - num179 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 120f), npc.width, 60, DustID.Blood, npc.velocity.X, npc.velocity.Y, 0, default(Color), 2f); - Main.dust[num179].noGravity = true; - Dust dust = Main.dust[num179]; - dust.velocity -= npc.velocity; - Main.dust[num179].velocity.Y += 5f; - } - } - - return false; - } - - public static bool VanillaSkeletronHandAI(NPC npc, Mod mod) - { - npc.spriteDirection = -(int)npc.ai[0]; - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) - { - npc.life = -1; - npc.HitEffect(); - npc.active = false; - } - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f) - npc.EncourageDespawn(10); - - if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) - { - float accelerationY = Main.getGoodWorld ? 0.1f : Main.masterMode ? 0.09f : Main.expertMode ? 0.08f : 0.07f; - float maxVelocityY = accelerationY * 100f; - float accelerationX = Main.getGoodWorld ? 0.16f : Main.masterMode ? 0.14f : Main.expertMode ? 0.12f : 0.1f; - float maxVelocityX = accelerationX * 100f; - float deceleration = Main.getGoodWorld ? 0.81f : Main.masterMode ? 0.84f : Main.expertMode ? 0.87f : 0.9f; - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= accelerationY; - if (npc.velocity.Y > maxVelocityY) - npc.velocity.Y = maxVelocityY; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += accelerationY; - if (npc.velocity.Y < -maxVelocityY) - npc.velocity.Y = -maxVelocityY; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= accelerationX; - if (npc.velocity.X > maxVelocityX) - npc.velocity.X = maxVelocityX; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += accelerationX; - if (npc.velocity.X < -maxVelocityX) - npc.velocity.X = -maxVelocityX; - } - } - else - { - npc.ai[3] += 1f; - if (Main.expertMode) - npc.ai[3] += 0.5f; - if (Main.masterMode) - npc.ai[3] += 0.5f; - - if (npc.ai[3] >= 300f) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - float accelerationY = Main.getGoodWorld ? 0.07f : Main.masterMode ? 0.06f : Main.expertMode ? 0.05f : 0.04f; - float maxVelocityY = accelerationY * 100f; - float accelerationX = Main.getGoodWorld ? 0.13f : Main.masterMode ? 0.11f : Main.expertMode ? 0.09f : 0.07f; - float maxVelocityX = accelerationX * 100f; - float deceleration = Main.getGoodWorld ? 0.88f : Main.masterMode ? 0.9f : Main.expertMode ? 0.92f : 0.94f; - - if (Main.expertMode) - { - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 230f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= accelerationY; - if (npc.velocity.Y > maxVelocityY) - npc.velocity.Y = maxVelocityY; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y + 230f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += accelerationY; - if (npc.velocity.Y < -maxVelocityY) - npc.velocity.Y = -maxVelocityY; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= accelerationX; - if (npc.velocity.X > maxVelocityX) - npc.velocity.X = maxVelocityX; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += accelerationX; - if (npc.velocity.X < -maxVelocityX) - npc.velocity.X = -maxVelocityX; - } - } - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 230f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= accelerationY; - if (npc.velocity.Y > maxVelocityY) - npc.velocity.Y = maxVelocityY; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y + 230f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += accelerationY; - if (npc.velocity.Y < -maxVelocityY) - npc.velocity.Y = -maxVelocityY; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= accelerationX; - if (npc.velocity.X > maxVelocityX) - npc.velocity.X = maxVelocityX; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += accelerationX; - if (npc.velocity.X < -maxVelocityX) - npc.velocity.X = -maxVelocityX; - } - } - - Vector2 vector22 = npc.Center; - float num181 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector22.X; - float num182 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector22.Y; - float num183 = (float)Math.Sqrt(num181 * num181 + num182 * num182); - npc.rotation = (float)Math.Atan2(num182, num181) + MathHelper.PiOver2; - } - else if (npc.ai[2] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 vector23 = npc.Center; - float num184 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector23.X; - float num185 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector23.Y; - float num186 = (float)Math.Sqrt(num184 * num184 + num185 * num185); - npc.rotation = (float)Math.Atan2(num185, num184) + MathHelper.PiOver2; - npc.velocity.X *= 0.95f; - npc.velocity.Y -= 0.1f; - if (Main.expertMode) - { - npc.velocity.Y -= (Main.masterMode ? 0.09f : 0.06f); - if (npc.velocity.Y < -13f) - npc.velocity.Y = -13f; - } - else if (npc.velocity.Y < -8f) - npc.velocity.Y = -8f; - - if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] = 2f; - vector23 = npc.Center; - num184 = Main.player[npc.target].Center.X - vector23.X; - num185 = Main.player[npc.target].Center.Y - vector23.Y; - num186 = (float)Math.Sqrt(num184 * num184 + num185 * num185); - num186 = ((!Main.expertMode) ? (18f / num186) : ((Main.masterMode ? 24f : 21f) / num186)); - npc.velocity.X = num184 * num186; - npc.velocity.Y = num185 * num186; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] = 3f; - } - } - else if (npc.ai[2] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - Vector2 vector24 = npc.Center; - float num187 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector24.X; - float num188 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector24.Y; - float num189 = (float)Math.Sqrt(num187 * num187 + num188 * num188); - npc.rotation = (float)Math.Atan2(num188, num187) + MathHelper.PiOver2; - npc.velocity.Y *= 0.95f; - npc.velocity.X += 0.1f * (0f - npc.ai[0]); - if (Main.expertMode) - { - npc.velocity.X += (Main.masterMode ? 0.1f : 0.07f) * (0f - npc.ai[0]); - if (npc.velocity.X < -12f) - npc.velocity.X = -12f; - else if (npc.velocity.X > 12f) - npc.velocity.X = 12f; - } - else if (npc.velocity.X < -8f) - npc.velocity.X = -8f; - else if (npc.velocity.X > 8f) - npc.velocity.X = 8f; - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 500f || npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 500f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] = 5f; - vector24 = npc.Center; - num187 = Main.player[npc.target].Center.X - vector24.X; - num188 = Main.player[npc.target].Center.Y - vector24.Y; - num189 = (float)Math.Sqrt(num187 * num187 + num188 * num188); - num189 = ((!Main.expertMode) ? (17f / num189) : ((Main.masterMode ? 25f : 22f) / num189)); - npc.velocity.X = num187 * num189; - npc.velocity.Y = num188 * num189; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X < 0f && npc.Center.X < Main.player[npc.target].Center.X))) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] = 0f; - } - - return false; - } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs index de242d0fac..da0d5b69d4 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs @@ -2,147 +2,80 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.Chat; -using Terraria.GameContent.Achievements; +using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class SkeletronPrimeAI + public class SkeletronPrimeAI : VanillaAIOverride { - public static bool BuffedSkeletronPrimeAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Vanilla values + public static int SpinDamageMult = 2; // 158 + public static int LaserDamage = 25; // 100 - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + // Rev+ exclusive + public static int SkullDamage = 22; // 88 + public static int RocketDamage = 30; // 120 + + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; - if (npc.ai[3] != 0f) - NPC.mechQueen = npc.whoAmI; + if (NPC.ai[3] != 0f) + NPC.mechQueen = NPC.whoAmI; // Spawn arms if (calamityGlobalNPC.newAI[1] == 0f) { + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); calamityGlobalNPC.newAI[1] = 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { - // Spawn second head in Master Mode - // The main head owns the Saw and the Laser in Master Mode - if (death) - { - 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; + int arm = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PrimeCannon, NPC.whoAmI); + Main.npc[arm].ai[0] = -1f; + Main.npc[arm].ai[1] = NPC.whoAmI; + Main.npc[arm].target = NPC.target; + Main.npc[arm].netUpdate = true; - int arm = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeSaw, npc.whoAmI); - Main.npc[arm].ai[0] = 1f; - Main.npc[arm].ai[1] = npc.whoAmI; - Main.npc[arm].target = npc.target; - Main.npc[arm].netUpdate = true; + arm = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PrimeSaw, NPC.whoAmI); + Main.npc[arm].ai[0] = 1f; + Main.npc[arm].ai[1] = NPC.whoAmI; + Main.npc[arm].target = NPC.target; + Main.npc[arm].netUpdate = true; - arm = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeLaser, npc.whoAmI); - Main.npc[arm].ai[0] = 1f; - Main.npc[arm].ai[1] = npc.whoAmI; - Main.npc[arm].target = npc.target; - Main.npc[arm].netUpdate = true; - Main.npc[arm].ai[3] = 150f; - } - else - { - int arm = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeCannon, npc.whoAmI); - Main.npc[arm].ai[0] = -1f; - Main.npc[arm].ai[1] = npc.whoAmI; - Main.npc[arm].target = npc.target; - Main.npc[arm].netUpdate = true; + arm = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PrimeVice, NPC.whoAmI); + Main.npc[arm].ai[0] = -1f; + Main.npc[arm].ai[1] = NPC.whoAmI; + Main.npc[arm].target = NPC.target; + Main.npc[arm].ai[3] = 150f; + Main.npc[arm].netUpdate = true; - arm = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeSaw, npc.whoAmI); - Main.npc[arm].ai[0] = 1f; - Main.npc[arm].ai[1] = npc.whoAmI; - Main.npc[arm].target = npc.target; - Main.npc[arm].netUpdate = true; - - arm = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeVice, npc.whoAmI); - Main.npc[arm].ai[0] = -1f; - Main.npc[arm].ai[1] = npc.whoAmI; - Main.npc[arm].target = npc.target; - Main.npc[arm].ai[3] = 150f; - Main.npc[arm].netUpdate = true; - - arm = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeLaser, npc.whoAmI); - Main.npc[arm].ai[0] = 1f; - Main.npc[arm].ai[1] = npc.whoAmI; - Main.npc[arm].target = npc.target; - Main.npc[arm].netUpdate = true; - Main.npc[arm].ai[3] = 150f; - } + arm = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.PrimeLaser, NPC.whoAmI); + Main.npc[arm].ai[0] = 1f; + Main.npc[arm].ai[1] = NPC.whoAmI; + Main.npc[arm].target = NPC.target; + Main.npc[arm].netUpdate = true; + Main.npc[arm].ai[3] = 150f; } - npc.netUpdate = true; - npc.SyncExtraAI(); - } - - if (death) - { - if (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.life = 0; - npc.HitEffect(); - npc.active = false; - npc.netUpdate = true; - } - else - { - // 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; - - // Push away from the lead head if too close, pull closer if too far, if Mechdusa isn't real - if (!NPC.IsMechQueenUp) - { - float pushVelocity = 0.25f; - if (Vector2.Distance(npc.Center, Main.npc[(int)npc.ai[0]].Center) < 80f * npc.scale) - { - if (npc.position.X < Main.npc[(int)npc.ai[0]].position.X) - npc.velocity.X -= pushVelocity; - else - npc.velocity.X += pushVelocity; - - if (npc.position.Y < Main.npc[(int)npc.ai[0]].position.Y) - npc.velocity.Y -= pushVelocity; - else - npc.velocity.Y += pushVelocity; - } - else if (Vector2.Distance(npc.Center, Main.npc[(int)npc.ai[0]].Center) > 240f * npc.scale) - { - if (npc.position.X < Main.npc[(int)npc.ai[0]].position.X) - npc.velocity.X += pushVelocity; - else - npc.velocity.X -= pushVelocity; - - if (npc.position.Y < Main.npc[(int)npc.ai[0]].position.Y) - npc.velocity.Y += pushVelocity; - else - npc.velocity.Y -= pushVelocity; - } - } - } + NPC.netUpdate = true; + NPC.SyncExtraAI(); } // Check if arms are alive @@ -171,177 +104,97 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses sawAlive = true; } bool allArmsDead = !cannonAlive && !laserAlive && !viceAlive && !sawAlive; - npc.chaseable = allArmsDead; + NPC.chaseable = allArmsDead; - npc.defense = npc.defDefense; + NPC.defense = NPC.defDefense; + NPC.damage = NPC.defDamage; // Phases bool phase2 = lifeRatio < 0.66f; - bool spawnDestroyer = lifeRatio < 0.75f && death && !bossRush && npc.localAI[2] == 0f; bool phase3 = lifeRatio < 0.33f; - bool spawnRetinazer = lifeRatio < 0.5f && death && !bossRush && npc.localAI[2] == 1f; - - // Spawn The Destroyer in Master Mode (just like Oblivion from Avalon) - if (spawnDestroyer) - { - Player destroyerSpawnPlayer = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)]; - SoundEngine.PlaySound(SoundID.Roar, destroyerSpawnPlayer.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int destroyer = NPC.NewNPC(NPC.GetBossSpawnSource(destroyerSpawnPlayer.whoAmI), (int)destroyerSpawnPlayer.Center.X, (int)destroyerSpawnPlayer.Center.Y + 810, NPCID.TheDestroyer, 1); - if (destroyer != Main.maxNPCs) - { - Main.npc[destroyer].target = destroyerSpawnPlayer.whoAmI; - Main.npc[destroyer].timeLeft *= 20; - Main.npc[destroyer].localAI[3] = 1f; - Main.npc[destroyer].SyncVanillaLocalAI(); - string typeName = Main.npc[destroyer].TypeName; - if (Main.dedServ && destroyer < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, destroyer); - - AchievementsHelper.CheckMechaMayhem(); - - if (Main.netMode == NetmodeID.SinglePlayer) - Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), 175, 75); - else if (Main.dedServ) - ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", Main.npc[destroyer].GetTypeNetName()), new Color(175, 75, 255)); - } - } - - npc.localAI[2] = 1f; - npc.SyncVanillaLocalAI(); - } - - // Spawn Retinazer in Master Mode (just like Oblivion from Avalon) - if (spawnRetinazer) - { - Player retinazerSpawnPlayer = Main.player[Player.FindClosest(npc.position, npc.width, npc.height)]; - SoundEngine.PlaySound(SoundID.Roar, retinazerSpawnPlayer.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int retinazer = NPC.NewNPC(NPC.GetBossSpawnSource(retinazerSpawnPlayer.whoAmI), (int)retinazerSpawnPlayer.Center.X, (int)retinazerSpawnPlayer.Center.Y - 810, NPCID.Retinazer, 1); - if (retinazer != Main.maxNPCs) - { - Main.npc[retinazer].target = retinazerSpawnPlayer.whoAmI; - Main.npc[retinazer].timeLeft *= 20; - Main.npc[retinazer].localAI[3] = 1f; - Main.npc[retinazer].SyncVanillaLocalAI(); - string typeName = Main.npc[retinazer].TypeName; - if (Main.dedServ && retinazer < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, retinazer); - - AchievementsHelper.CheckMechaMayhem(); - - if (Main.netMode == NetmodeID.SinglePlayer) - Main.NewText(Lang.misc[48].Value, 175, 75); - else if (Main.dedServ) - ChatHelper.BroadcastChatMessage(Lang.misc[48].ToNetworkText(), new Color(175, 75, 255)); - } - } - - npc.localAI[2] = 2f; - npc.SyncVanillaLocalAI(); - } // Despawn - if (npc.ai[1] != 3f) + if (NPC.ai[1] != 3f) { int despawnDistanceInTiles = 500; - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) - npc.ai[1] = 3f; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + if (Main.player[NPC.target].dead || Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) / 16f > despawnDistanceInTiles) + NPC.ai[1] = 3f; } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } // Activate daytime enrage - if (Main.IsItDay() && !bossRush && npc.ai[1] != 3f && npc.ai[1] != 2f) + if (Main.IsItDay() && !BossRushEvent.BossRushActive && NPC.ai[1] != 3f && NPC.ai[1] != 2f) { // Heal if (Main.netMode != NetmodeID.MultiplayerClient) { - int healAmt = npc.life - 300; + int healAmt = NPC.life - 300; if (healAmt < 0) { int absHeal = Math.Abs(healAmt); - npc.life += absHeal; - npc.HealEffect(absHeal, true); - npc.netUpdate = true; + NPC.life += absHeal; + NPC.HealEffect(absHeal, true); + NPC.netUpdate = true; } } - npc.ai[1] = 2f; - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + NPC.ai[1] = 2f; + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); } // Adjust slowing debuff immunity - bool immuneToSlowingDebuffs = npc.ai[1] == 5f; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; - npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + bool immuneToSlowingDebuffs = NPC.ai[1] == 5f; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[ModContent.BuffType()] = immuneToSlowingDebuffs; + NPC.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - bool normalLaserRotation = npc.localAI[1] % 2f == 0f; - - // Prevents cheap hits - bool canUseAttackInMaster = npc.position.Y < Main.player[npc.target].position.Y - 350f; + bool normalLaserRotation = NPC.localAI[1] % 2f == 0f; // Float near player - if (npc.ai[1] == 0f || npc.ai[1] == 4f) + if (NPC.ai[1] == 0f || NPC.ai[1] == 4f) { - // Avoid unfair bullshit - npc.damage = 0; - // Start other phases; if arms are dead, start with spin phase - bool otherHeadChargingOrSpinning = Main.npc[(int)npc.ai[0]].ai[1] == 5f || Main.npc[(int)npc.ai[0]].ai[1] == 1f; - if (phase2 || CalamityWorld.LegendaryMode || allArmsDead || death) + if (phase2 || Main.getGoodWorld || allArmsDead) { // Start spin phase after 1.5 seconds - npc.ai[2] += phase3 ? 1.5f : 1f; - if (npc.ai[2] >= (90f - (death ? 15f * (1f - lifeRatio) : 0f)) && (!otherHeadChargingOrSpinning || !death || phase3) && (canUseAttackInMaster || !death)) + NPC.ai[2] += phase3 ? 1.5f : 1f; + if (NPC.ai[2] >= (90f - (death ? 15f * (1f - lifeRatio) : 0f))) { - bool shouldSpinAround = npc.ai[1] == 4f && npc.position.Y < Main.player[npc.target].position.Y - 320f && - 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[NPC.target].position.Y - 320f && + Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) < 600f && Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 400f; - bool shouldCharge = death && !phase2 && !allArmsDead && !CalamityWorld.LegendaryMode; - if (shouldCharge) - { - npc.ai[2] = 0f; - npc.ai[1] = 1f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.netUpdate = true; - } - else if (shouldSpinAround || npc.ai[1] != 4f) + if (shouldSpinAround || NPC.ai[1] != 4f) { if (shouldSpinAround) { - npc.localAI[3] = 300f; - npc.SyncVanillaLocalAI(); + NPC.localAI[3] = 300f; + NPC.localAI[1] = 0; + NPC.SyncVanillaLocalAI(); } - npc.ai[2] = 0f; - npc.ai[1] = shouldSpinAround ? 5f : 1f; - npc.netUpdate = true; + NPC.ai[2] = 0f; + NPC.ai[1] = shouldSpinAround ? 5f : 1f; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPC.netUpdate = true; } } } if (NPC.IsMechQueenUp) - npc.rotation = npc.rotation.AngleLerp(npc.velocity.X / 15f * 0.5f, 0.75f); + NPC.rotation = NPC.rotation.AngleLerp(NPC.velocity.X / 15f * 0.5f, 0.75f); else - npc.rotation = npc.velocity.X / 15f; + NPC.rotation = NPC.velocity.X / 15f; - float acceleration = bossRush ? 0.2f : (death ? (0.12f + 0.05f * (1f - lifeRatio)) : 0.1f); + float acceleration = death ? (0.125f + 0.05f * (1f - lifeRatio)) : 0.1f; float accelerationMult = 1f; if (!cannonAlive) { @@ -366,7 +219,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses 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[NPC.target].Center.X < NPC.Center.X)) ? 1 : (-1)); if (NPC.IsMechQueenUp) { headDecelerationHorizontalDist = -150f * (float)headHorizontalDirection; @@ -374,81 +227,69 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses headDecelerationDownDist = -100f; } - if (npc.position.Y > Main.player[npc.target].position.Y - (320f + headDecelerationUpDist)) + if (NPC.position.Y > Main.player[NPC.target].position.Y - (320f + headDecelerationUpDist)) { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y -= acceleration; + NPC.velocity.Y -= acceleration; - if (npc.velocity.Y > topVelocity) - npc.velocity.Y = topVelocity; + if (NPC.velocity.Y > topVelocity) + NPC.velocity.Y = topVelocity; } - else if (npc.position.Y < Main.player[npc.target].position.Y - (360f + headDecelerationDownDist)) + else if (NPC.position.Y < Main.player[NPC.target].position.Y - (360f + headDecelerationDownDist)) { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y += acceleration; + NPC.velocity.Y += acceleration; - if (npc.velocity.Y < -topVelocity) - npc.velocity.Y = -topVelocity; + if (NPC.velocity.Y < -topVelocity) + NPC.velocity.Y = -topVelocity; } - if (npc.Center.X > Main.player[npc.target].Center.X + (400f + headDecelerationHorizontalDist)) + if (NPC.Center.X > Main.player[NPC.target].Center.X + (400f + headDecelerationHorizontalDist)) { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X -= acceleration; + NPC.velocity.X -= acceleration; - if (npc.velocity.X > topVelocity) - npc.velocity.X = topVelocity; + 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[NPC.target].Center.X - (400f + headDecelerationHorizontalDist)) { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X += acceleration; + NPC.velocity.X += acceleration; - if (npc.velocity.X < -topVelocity) - npc.velocity.X = -topVelocity; + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; } } else { // Spinning - if (npc.ai[1] == 1f) + if (NPC.ai[1] == 1f) { - npc.defense *= 2; - npc.damage = npc.defDamage * 2; + NPC.defense = NPC.defDefense * 2; + NPC.damage = NPC.defDamage * SpinDamageMult; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = true; if (phase2 && Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 45f) + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 45f) { - npc.localAI[0] = 0f; + NPC.localAI[0] = 0f; - int totalProjectiles = bossRush ? 24 : death ? 15 : 12; + int totalProjectiles = death ? 15 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } float velocity = 3f; double angleA = radians * 0.5; @@ -458,41 +299,41 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses for (int k = 0; k < totalProjectiles; k++) { Vector2 laserFireDirection = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserFireDirection.SafeNormalize(Vector2.UnitY) * 100f, laserFireDirection, type, damage, 0f, Main.myPlayer, 1f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserFireDirection.SafeNormalize(Vector2.UnitY) * 100f, laserFireDirection, type, LaserDamage.CalculateMechDamage(), 0f, Main.myPlayer, 1f, 0f); Main.projectile[proj].timeLeft = 900; } - npc.localAI[1] += 1f; + NPC.localAI[1] += 1f; } } - npc.ai[2] += 1f; - if (npc.ai[2] == 2f) - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + NPC.ai[2] += 1f; + if (NPC.ai[2] == 2f) + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); // Spin for 3 seconds then return to floating phase float phaseTimer = 240f; if (phase2 && !phase3) phaseTimer += 60f; - if (npc.ai[2] >= (phaseTimer - (death ? 60f * (1f - lifeRatio) : 0f))) + if (NPC.ai[2] >= (phaseTimer - (death ? 60f * (1f - lifeRatio) : 0f))) { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.ai[2] = 0f; - npc.ai[1] = 4f; - npc.localAI[0] = 0f; + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPC.ai[2] = 0f; + NPC.ai[1] = 4f; + NPC.localAI[0] = 0f; } if (NPC.IsMechQueenUp) - npc.rotation = npc.rotation.AngleLerp(npc.velocity.X / 15f * 0.5f, 0.75f); + NPC.rotation = NPC.rotation.AngleLerp(NPC.velocity.X / 15f * 0.5f, 0.75f); else - npc.rotation += npc.direction * 0.3f; + 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; + 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 headTargetDistance = (float)Math.Sqrt(headTargetX * headTargetX + headTargetY * headTargetY); - float speed = bossRush ? 12f : death ? 8f : 6f; + float speed = death ? 8f : 6f; if (phase2) speed += 0.5f; if (phase3) @@ -511,24 +352,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } headTargetDistance = speed / headTargetDistance; - npc.velocity.X = headTargetX * headTargetDistance; - npc.velocity.Y = headTargetY * headTargetDistance; + NPC.velocity.X = headTargetX * headTargetDistance; + NPC.velocity.Y = headTargetY * headTargetDistance; if (NPC.IsMechQueenUp) { - float mechdusaAccelMult = Vector2.Distance(npc.Center, Main.player[npc.target].Center); + float mechdusaAccelMult = Vector2.Distance(NPC.Center, Main.player[NPC.target].Center); if (mechdusaAccelMult < 0.1f) mechdusaAccelMult = 0f; if (mechdusaAccelMult < speed) - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * mechdusaAccelMult; + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.Zero) * mechdusaAccelMult; } } // Daytime enrage - if (npc.ai[1] == 2f) + if (NPC.ai[1] == 2f) { - npc.damage = 1000; + NPC.damage = 1000; calamityGlobalNPC.DR = 0.9999f; calamityGlobalNPC.unbreakableDR = true; @@ -536,13 +377,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = true; if (NPC.IsMechQueenUp) - npc.rotation = npc.rotation.AngleLerp(npc.velocity.X / 15f * 0.5f, 0.75f); + NPC.rotation = NPC.rotation.AngleLerp(NPC.velocity.X / 15f * 0.5f, 0.75f); else - npc.rotation += npc.direction * 0.3f; + 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; + 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 enragedHeadTargetDist = (float)Math.Sqrt(enragedHeadTargetX * enragedHeadTargetX + enragedHeadTargetY * enragedHeadTargetY); float enragedHeadSpeed = 10f; @@ -553,21 +394,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses enragedHeadSpeed = 32f; enragedHeadTargetDist = enragedHeadSpeed / enragedHeadTargetDist; - npc.velocity.X = enragedHeadTargetX * enragedHeadTargetDist; - npc.velocity.Y = enragedHeadTargetY * enragedHeadTargetDist; + NPC.velocity.X = enragedHeadTargetX * enragedHeadTargetDist; + NPC.velocity.Y = enragedHeadTargetY * enragedHeadTargetDist; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 60f) + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 60f) { - 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)) + 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)) { 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[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 enragedHeadSkullTargetDist = (float)Math.Sqrt(enragedHeadSkullTargetX * enragedHeadSkullTargetX + enragedHeadSkullTargetY * enragedHeadSkullTargetY); enragedHeadSkullTargetDist = enragedHeadSpeed / enragedHeadSkullTargetDist; enragedHeadSkullTargetX *= enragedHeadSkullTargetDist; @@ -575,13 +416,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 value = new Vector2(enragedHeadSkullTargetX * 1f + Main.rand.Next(-50, 51) * 0.01f, enragedHeadSkullTargetY * 1f + Main.rand.Next(-50, 51) * 0.01f).SafeNormalize(Vector2.UnitY); value *= enragedHeadSpeed; - value += npc.velocity; + value += NPC.velocity; enragedHeadSkullTargetX = value.X; enragedHeadSkullTargetY = value.Y; int type = ProjectileID.Skull; headCenter += value * 5f; - int enragedSkulls = Projectile.NewProjectile(npc.GetSource_FromAI(), headCenter.X, headCenter.Y, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, 250, 0f, Main.myPlayer, -3f, 0f); + int enragedSkulls = Projectile.NewProjectile(NPC.GetSource_FromAI(), headCenter.X, headCenter.Y, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, 250, 0f, Main.myPlayer, -3f, 0f); Main.projectile[enragedSkulls].timeLeft = 300; } } @@ -589,11 +430,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawning - if (npc.ai[1] == 3f) + if (NPC.ai[1] == 3f) { - // Avoid unfair bullshit - npc.damage = 0; - if (NPC.IsMechQueenUp) { int mechdusaBossDespawning = NPC.FindFirstNPC(NPCID.Retinazer); @@ -610,86 +448,83 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (mechdusaBossDespawning >= 0) Main.npc[mechdusaBossDespawning].Transform(NPCID.TheDestroyerTail); - npc.EncourageDespawn(5); + NPC.EncourageDespawn(5); } - npc.velocity.Y += 0.1f; - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.95f; + NPC.velocity.Y += 0.1f; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.95f; - npc.velocity.X *= 0.95f; - if (npc.velocity.Y > 13f) - npc.velocity.Y = 13f; + NPC.velocity.X *= 0.95f; + if (NPC.velocity.Y > 13f) + NPC.velocity.Y = 13f; } else { - npc.velocity.Y += 0.1f; - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.9f; + NPC.velocity.Y += 0.1f; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.9f; - npc.velocity.X *= 0.9f; + NPC.velocity.X *= 0.9f; - if (npc.timeLeft > 500) - npc.timeLeft = 500; + if (NPC.timeLeft > 500) + NPC.timeLeft = 500; } } // Fly around in a circle - if (npc.ai[1] == 5f) + if (NPC.ai[1] == 5f) { - // Avoid unfair bullshit - npc.damage = 0; + NPC.ai[2] += 1f; - npc.ai[2] += 1f; + NPC.rotation = NPC.velocity.X / 50f; - npc.rotation = npc.velocity.X / 50f; - - float skullSpawnDivisor = bossRush ? 9f : death ? 15f - (float)Math.Round(3f * (1f - lifeRatio)) : 15f; + float skullSpawnDivisor = death ? 15f - (float)Math.Round(3f * (1f - lifeRatio)) : 15f; float totalSkulls = 12f; - int skullSpread = bossRush ? 250 : death ? 125 : 100; + int skullSpread = death ? 125 : 100; // Spin for about 3 seconds // Decreasing this number will INCREASE how fast he moves while spinning float spinVelocity = 30f; - if (npc.ai[2] == 2f) + if (NPC.ai[2] == 2f) { // Play angry noise - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); // Set spin direction - if (Main.player[npc.target].velocity.X > 0f) + if (Main.player[NPC.target].velocity.X > 0f) calamityGlobalNPC.newAI[0] = 1f; - else if (Main.player[npc.target].velocity.X < 0f) + else if (Main.player[NPC.target].velocity.X < 0f) calamityGlobalNPC.newAI[0] = -1f; else - calamityGlobalNPC.newAI[0] = Main.player[npc.target].direction; + calamityGlobalNPC.newAI[0] = Main.player[NPC.target].direction; // Set spin velocity - npc.velocity.X = MathHelper.Pi * npc.localAI[3] / spinVelocity; - npc.velocity *= -calamityGlobalNPC.newAI[0]; - npc.SyncExtraAI(); - npc.netUpdate = true; + NPC.velocity.X = MathHelper.Pi * NPC.localAI[3] / spinVelocity; + NPC.velocity *= -calamityGlobalNPC.newAI[0]; + NPC.SyncExtraAI(); + NPC.netUpdate = true; } // Maintain velocity and spit skulls - else if (npc.ai[2] > 2f) + else if (NPC.ai[2] > 2f) { - npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocity * -calamityGlobalNPC.newAI[0]); - if (npc.ai[2] == 3f) - npc.velocity *= 0.6f; + NPC.velocity = NPC.velocity.RotatedBy(MathHelper.Pi / spinVelocity * -calamityGlobalNPC.newAI[0]); + if (NPC.ai[2] == 3f) + NPC.velocity *= 0.6f; - if (npc.ai[2] % skullSpawnDivisor == 0f) + if (NPC.ai[2] % skullSpawnDivisor == 0f) { - npc.localAI[0] += 1f; + NPC.localAI[0] += 1f; - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 96f) + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 96f) { if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 headCenter = npc.Center; + Vector2 headCenter = NPC.Center; float enragedHeadSpeed = death ? (5f + (1f - lifeRatio)) : 4f; - 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[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 enragedHeadSkullTargetDist = (float)Math.Sqrt(enragedHeadSkullTargetX * enragedHeadSkullTargetX + enragedHeadSkullTargetY * enragedHeadSkullTargetY); enragedHeadSkullTargetDist = enragedHeadSpeed / enragedHeadSkullTargetDist; enragedHeadSkullTargetX *= enragedHeadSkullTargetDist; @@ -701,111 +536,79 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses enragedHeadSkullTargetY = value.Y; int type = ProjectileID.Skull; - int damage = npc.GetProjectileDamage(type); - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 (npc.localAI[0] % 3f == 0f) - { - int probeLimit = death ? 3 : 2; - if (NPC.CountNPCS(NPCID.Probe) < probeLimit) - NPC.NewNPC(npc.GetSource_FromAI(), (int)headCenter.X, (int)headCenter.Y + 30, NPCID.Probe); - } - - int enragedSkulls = Projectile.NewProjectile(npc.GetSource_FromAI(), headCenter.X, headCenter.Y + 30f, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, damage, 0f, Main.myPlayer, -3f, 0f); + int enragedSkulls = Projectile.NewProjectile(NPC.GetSource_FromAI(), headCenter.X, headCenter.Y + 30f, enragedHeadSkullTargetX, enragedHeadSkullTargetY, type, SkullDamage.CalculateMechDamage(), 0f, Main.myPlayer, -3f, 0f); Main.projectile[enragedSkulls].timeLeft = 480; Main.projectile[enragedSkulls].tileCollide = false; } } // Go to floating phase, or spinning phase if in phase 2 - if (npc.localAI[0] >= totalSkulls) + // NetMode check here fixes the strange teleporting issue prime had. The issue was that this attack was ending on the client + // and then some time later ending a second time on the server, causing major de-sync and the issues of prime seeming to teleport. + if (NPC.localAI[0] >= totalSkulls && Main.netMode != NetmodeID.MultiplayerClient) { - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); + NPC.velocity = NPC.velocity.SafeNormalize(Vector2.UnitY); // Fly overhead and spit missiles if on low health - npc.ai[1] = phase3 ? 6f : 1f; - npc.ai[2] = 0f; - npc.localAI[3] = 0f; - npc.localAI[0] = 0f; + NPC.ai[1] = phase3 ? 6f : 1f; + NPC.ai[2] = 0f; + NPC.localAI[3] = 0f; + NPC.localAI[0] = 0f; calamityGlobalNPC.newAI[0] = 0f; - npc.SyncVanillaLocalAI(); - npc.SyncExtraAI(); - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.netUpdate = true; + NPC.SyncVanillaLocalAI(); + NPC.SyncExtraAI(); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPC.netUpdate = true; } } } } // Fly overhead and spit missiles - if (npc.ai[1] == 6f) + if (NPC.ai[1] == 6f) { - // Avoid unfair bullshit - npc.damage = 0; + NPC.rotation = NPC.velocity.X / 15f; - npc.rotation = npc.velocity.X / 15f; + float flightVelocity = death ? 25f : 18f; + float flightAcceleration = death ? 0.96f : 0.6f; - float flightVelocity = bossRush ? 29f : death ? 25f : 18f; - float flightAcceleration = bossRush ? 1.12f : death ? 0.96f : 0.6f; - - Vector2 destination = new Vector2(Main.player[npc.target].Center.X, Main.player[npc.target].Center.Y - 420f); - npc.SimpleFlyMovement((destination - npc.Center).SafeNormalize(Vector2.UnitY) * flightVelocity, flightAcceleration); + Vector2 destination = new Vector2(Main.player[NPC.target].Center.X, Main.player[NPC.target].Center.Y - 420f); + NPC.SimpleFlyMovement((destination - NPC.Center).SafeNormalize(Vector2.UnitY) * flightVelocity, flightAcceleration); // Spit homing missiles and then go to floating phase - npc.localAI[3] += 1f; - if (Vector2.Distance(npc.Center, destination) < 80f || npc.ai[2] > 0f || npc.localAI[3] > 120f) + NPC.localAI[3] += 1f; + if (Vector2.Distance(NPC.Center, destination) < 80f || NPC.ai[2] > 0f || NPC.localAI[3] > 120f) { - float missileSpawnDivisor = death ? 10f : 12f; - float totalMissiles = death ? 12f : 10f; - npc.ai[2] += 1f; - if (npc.ai[2] % missileSpawnDivisor == 0f) + float missileSpawnDivisor = 12f; + float totalMissiles = 10f; + NPC.ai[2] += 1f; + if (NPC.ai[2] % missileSpawnDivisor == 0f) { - npc.localAI[0] += 1f; + NPC.localAI[0] += 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 velocity = (-Vector2.UnitY * 3f).RotatedByRandom(MathHelper.Pi / 8f); int type = ProjectileID.RocketSkeleton; - int damage = npc.GetProjectileDamage(type); - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + Main.rand.Next(npc.width / 2), npc.Center.Y + 30f, velocity.X, velocity.Y, type, damage, 0f, Main.myPlayer, npc.target, 1f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X + Main.rand.Next(NPC.width / 2), NPC.Center.Y + 30f, velocity.X, velocity.Y, type, RocketDamage.CalculateMechDamage(), 0f, Main.myPlayer, NPC.target, 1f); Main.projectile[proj].timeLeft = 540; } - SoundEngine.PlaySound(SoundID.Item62, npc.Center); + SoundEngine.PlaySound(SoundID.Item62, NPC.Center); - if (npc.localAI[0] >= totalMissiles) + if (NPC.localAI[0] >= totalMissiles) { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[3] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.localAI[3] = 0f; calamityGlobalNPC.newAI[0] = 0f; - npc.localAI[0] = 0f; - npc.SyncVanillaLocalAI(); - npc.SyncExtraAI(); - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.netUpdate = true; + NPC.localAI[0] = 0f; + NPC.SyncVanillaLocalAI(); + NPC.SyncExtraAI(); + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + NPC.netUpdate = true; } } } @@ -815,632 +618,115 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedPrimeLaserAI(NPC npc, Mod mod) + public override bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + if (NPC.IsMechQueenUp) + return true; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - // Set direction - npc.spriteDirection = -(int)npc.ai[0]; - - // Despawn if head is gone - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) + // Allows correct frames to draw in Rev+ phases + // GFB can rot for all I care + var calNPC = NPC.GetGlobalNPC(); + int frameHeight = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + if (NPC.ai[1] == 0f || NPC.ai[1] == 4f) { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) + calNPC.newAI[2] += 1f; + if (calNPC.newAI[2] >= 12f) { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; + calNPC.newAI[2] = 0f; + calNPC.newAI[3] += frameHeight; + + if (calNPC.newAI[3] / frameHeight >= 2f) + calNPC.newAI[3] = 0f; } } - CalamityGlobalNPC.primeLaser = npc.whoAmI; - - // Check if arms are alive - bool cannonAlive = false; - bool viceAlive = false; - bool sawAlive = false; - if (CalamityGlobalNPC.primeCannon != -1) + // Spinning probe spawn or fly over phase + else if (NPC.ai[1] == 5f || NPC.ai[1] == 6f) { - if (Main.npc[CalamityGlobalNPC.primeCannon].active) - cannonAlive = true; - } - if (CalamityGlobalNPC.primeVice != -1) - { - if (Main.npc[CalamityGlobalNPC.primeVice].active) - viceAlive = true; - } - if (CalamityGlobalNPC.primeSaw != -1) - { - if (Main.npc[CalamityGlobalNPC.primeSaw].active) - sawAlive = true; + calNPC.newAI[2] = 0f; + calNPC.newAI[3] = frameHeight; } - // Inflict 0 damage for 3 seconds after spawning - float timeToNotAttack = 180f; - bool dontAttack = npc.Calamity().newAI[2] < timeToNotAttack; - if (dontAttack) - { - npc.Calamity().newAI[2] += 1f; - if (npc.Calamity().newAI[2] >= timeToNotAttack) - npc.SyncExtraAI(); - } - - // Avoid cheap bullshit - npc.damage = 0; - - bool normalLaserRotation = npc.localAI[1] % 2f == 0f; - - // Movement - float acceleration = bossRush ? 0.6f : death ? 0.375f : 0.25f; - float accelerationMult = 1f; - if (!cannonAlive) - { - acceleration += 0.025f; - accelerationMult += 0.5f; - } - if (!viceAlive) - acceleration += 0.025f; - if (!sawAlive) - acceleration += 0.025f; - if (death) - acceleration *= accelerationMult; - - float topVelocity = acceleration * 100f; - float deceleration = death ? 0.6f : 0.8f; - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 70f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= acceleration; - - if (npc.velocity.Y > topVelocity) - npc.velocity.Y = topVelocity; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += acceleration; - - if (npc.velocity.Y < -topVelocity) - npc.velocity.Y = -topVelocity; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 130f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= acceleration; - - if (npc.velocity.X > topVelocity) - npc.velocity.X = topVelocity; - } - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 160f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += acceleration; - - if (npc.velocity.X < -topVelocity) - npc.velocity.X = -topVelocity; - } - - // Phase 1 - if (npc.ai[2] == 0f) - { - // Despawn if head is despawning - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) - npc.timeLeft = 10; - - // Go to other phase after 13.3 seconds (change this as each arm dies) - npc.ai[3] += 1f; - if (!cannonAlive) - npc.ai[3] += 1f; - if (!viceAlive) - npc.ai[3] += 1f; - if (!sawAlive) - npc.ai[3] += 1f; - - if (npc.ai[3] >= (death ? 200f : 800f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - Vector2 laserArmPosition = npc.Center; - float laserArmTargetX = Main.player[npc.target].Center.X - laserArmPosition.X; - float laserArmTargetY = Main.player[npc.target].Center.Y - laserArmPosition.Y; - float laserArmTargetDist = (float)Math.Sqrt(laserArmTargetX * laserArmTargetX + laserArmTargetY * laserArmTargetY); - npc.rotation = (float)Math.Atan2(laserArmTargetY, laserArmTargetX) - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) - { - // Fire laser every 0.8 seconds (change this as each arm dies to fire more aggressively) - npc.localAI[0] += 1f; - if (!cannonAlive) - npc.localAI[0] += 1f; - if (!viceAlive) - npc.localAI[0] += 1f; - if (!sawAlive) - npc.localAI[0] += 1f; - - if (npc.localAI[0] >= 48f) - { - npc.localAI[0] = 0f; - float laserSpeed = bossRush ? 5f : 4f; - int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - laserArmTargetDist = laserSpeed / laserArmTargetDist; - laserArmTargetX *= laserArmTargetDist; - laserArmTargetY *= laserArmTargetDist; - Vector2 laserVelocity = new Vector2(laserArmTargetX, laserArmTargetY); - Projectile.NewProjectile(npc.GetSource_FromAI(), laserArmPosition + laserVelocity.SafeNormalize(Vector2.UnitY) * 100f, laserVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f); - } - } - } - - // Other phase, get closer to the player and fire ring of lasers - else if (npc.ai[2] == 1f) - { - // Go to phase 1 after 2 seconds (change this as each arm dies to stay in this phase for longer) - npc.ai[3] += 1f; - - float timeLimit = 135f; - float timeMult = 1.882075f; - if (!cannonAlive) - timeLimit *= timeMult; - if (!viceAlive) - timeLimit *= timeMult; - if (!sawAlive) - timeLimit *= timeMult; - - if (npc.ai[3] >= timeLimit) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - Vector2 laserRingArmPosition = npc.Center; - float laserRingTargetX = Main.player[npc.target].Center.X - laserRingArmPosition.X; - float laserRingTargetY = Main.player[npc.target].Center.Y - laserRingArmPosition.Y; - npc.rotation = (float)Math.Atan2(laserRingTargetY, laserRingTargetX) - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) - { - // Fire laser every 1.5 seconds (change this as each arm dies to fire more aggressively) - npc.localAI[0] += 1f; - if (!cannonAlive) - npc.localAI[0] += 0.5f; - if (!viceAlive) - npc.localAI[0] += 0.5f; - if (!sawAlive) - npc.localAI[0] += 0.5f; - - if (npc.localAI[0] >= 120f) - { - npc.localAI[0] = 0f; - int totalProjectiles = bossRush ? 32 : death ? 24 : 16; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - float velocity = 3f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float laserVelocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-laserVelocityX, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 laserFireDirection = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserFireDirection.SafeNormalize(Vector2.UnitY) * 100f, laserFireDirection, type, damage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 900; - } - npc.localAI[1] += 1f; - } - } - } - - return false; - } - - public static bool BuffedPrimeCannonAI(NPC npc, Mod mod) - { - 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) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.spriteDirection = -(int)npc.ai[0]; - - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) - { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; - } - } - - CalamityGlobalNPC.primeCannon = npc.whoAmI; - - // Check if arms are alive - bool laserAlive = false; - bool viceAlive = false; - bool sawAlive = false; - if (CalamityGlobalNPC.primeLaser != -1) - { - if (Main.npc[CalamityGlobalNPC.primeLaser].active) - laserAlive = true; - } - if (CalamityGlobalNPC.primeVice != -1) - { - if (Main.npc[CalamityGlobalNPC.primeVice].active) - viceAlive = true; - } - if (CalamityGlobalNPC.primeSaw != -1) - { - if (Main.npc[CalamityGlobalNPC.primeSaw].active) - sawAlive = true; - } - - // Inflict 0 damage for 3 seconds after spawning - float timeToNotAttack = 180f; - bool dontAttack = npc.Calamity().newAI[2] < timeToNotAttack; - if (dontAttack) - { - npc.Calamity().newAI[2] += 1f; - if (npc.Calamity().newAI[2] >= timeToNotAttack) - npc.SyncExtraAI(); - } - - // Avoid cheap bullshit - npc.damage = 0; - - bool fireSlower = false; - if (laserAlive) - { - // If laser is firing ring of lasers - if (Main.npc[CalamityGlobalNPC.primeLaser].ai[2] == 1f) - fireSlower = true; - } + // Spinning phase else { - fireSlower = npc.ai[2] == 0f; - - if (fireSlower) - { - // Go to other phase after 13.33 seconds (change this as each arm dies) - npc.ai[3] += 1f; - if (!laserAlive) - npc.ai[3] += 1f; - if (!viceAlive) - npc.ai[3] += 1f; - if (!sawAlive) - npc.ai[3] += 1f; - - if (npc.ai[3] >= (death ? 200f : 800f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 1f; - fireSlower = false; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - else - { - // Go to phase 1 after 2 seconds (change this as each arm dies to stay in this phase for longer) - npc.ai[3] += 1f; - - float timeLimit = 120f; - float timeMult = 1.882075f; - if (!laserAlive) - timeLimit *= timeMult; - if (!viceAlive) - timeLimit *= timeMult; - if (!sawAlive) - timeLimit *= timeMult; - - if (npc.ai[3] >= timeLimit) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 0f; - fireSlower = true; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } + calNPC.newAI[2] = 0f; + calNPC.newAI[3] = frameHeight * 2; } - // Movement - float acceleration = bossRush ? 0.6f : death ? 0.375f : 0.25f; - float accelerationMult = 1f; - if (!laserAlive) - { - acceleration += 0.025f; - accelerationMult += 0.5f; - } - if (!viceAlive) - acceleration += 0.025f; - if (!sawAlive) - acceleration += 0.025f; - if (death) - acceleration *= accelerationMult; - - float topVelocity = acceleration * 100f; - float deceleration = death ? 0.6f : 0.8f; - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 70f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= acceleration; - - if (npc.velocity.Y > topVelocity) - npc.velocity.Y = topVelocity; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += acceleration; - - if (npc.velocity.Y < -topVelocity) - npc.velocity.Y = -topVelocity; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 130f) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= acceleration; - - if (npc.velocity.X > topVelocity) - npc.velocity.X = topVelocity; - } - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X + 160f) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += acceleration; - - if (npc.velocity.X < -topVelocity) - npc.velocity.X = -topVelocity; - } - - if (fireSlower) - { - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) - npc.timeLeft = 10; - - Vector2 cannonArmPosition = npc.Center; - float cannonArmTargetX = Main.player[npc.target].Center.X - cannonArmPosition.X; - float cannonArmTargetY = Main.player[npc.target].Center.Y - cannonArmPosition.Y; - float cannonArmTargetDist = (float)Math.Sqrt(cannonArmTargetX * cannonArmTargetX + cannonArmTargetY * cannonArmTargetY); - npc.rotation = (float)Math.Atan2(cannonArmTargetY, cannonArmTargetX) - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) - { - // Fire rocket every 2 seconds (change this as each arm dies to fire more aggressively) - npc.localAI[0] += 1f; - if (!laserAlive) - npc.localAI[0] += 1f; - if (!viceAlive) - npc.localAI[0] += 1f; - if (!sawAlive) - npc.localAI[0] += 1f; - - if (npc.localAI[0] >= 120f) - { - SoundEngine.PlaySound(SoundID.Item62, npc.Center); - npc.localAI[0] = 0f; - int type = ProjectileID.RocketSkeleton; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - float rocketSpeed = 10f; - cannonArmTargetDist = rocketSpeed / cannonArmTargetDist; - cannonArmTargetX *= cannonArmTargetDist; - cannonArmTargetY *= cannonArmTargetDist; - - Vector2 rocketVelocity = new Vector2(cannonArmTargetX, cannonArmTargetY); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), cannonArmPosition + rocketVelocity.SafeNormalize(Vector2.UnitY) * 40f, rocketVelocity, type, damage, 0f, Main.myPlayer, npc.target, 2f); - Main.projectile[proj].timeLeft = 540; - } - } - } - else - { - Vector2 cannonSpreadArmPosition = npc.Center; - float cannonSpreadArmTargetX = Main.player[npc.target].Center.X - cannonSpreadArmPosition.X; - float cannonSpreadArmTargetY = Main.player[npc.target].Center.Y - cannonSpreadArmPosition.Y; - npc.rotation = (float)Math.Atan2(cannonSpreadArmTargetY, cannonSpreadArmTargetX) - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) - { - // Fire rockets every 2 seconds (change this as each arm dies to fire more aggressively) - npc.localAI[0] += 1f; - if (!laserAlive) - npc.localAI[0] += 0.5f; - if (!viceAlive) - npc.localAI[0] += 0.5f; - if (!sawAlive) - npc.localAI[0] += 0.5f; - - if (npc.localAI[0] >= 180f) - { - SoundEngine.PlaySound(SoundID.Item62, npc.Center); - npc.localAI[0] = 0f; - int type = ProjectileID.RocketSkeleton; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } - - float rocketSpeed = 10f; - Vector2 cannonSpreadTargetDist = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * rocketSpeed; - int numProj = bossRush ? 5 : 3; - float rotation = MathHelper.ToRadians(bossRush ? 15 : 9); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = cannonSpreadTargetDist.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 40f, perturbedSpeed, type, damage, 0f, Main.myPlayer, npc.target, 2f); - Main.projectile[proj].timeLeft = 600; - } - } - } - } - - return false; + NPC.frame.Y = (int)calNPC.newAI[3]; + return true; } - public static bool BuffedPrimeViceAI(NPC npc, Mod mod) + public class PrimeLaserAI : VanillaAIOverride { - 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) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - // Direction - npc.spriteDirection = -(int)npc.ai[0]; - - // Where the vice should be in relation to the head - Vector2 viceArmPosition = npc.Center; - float viceArmIdleXPos = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - viceArmPosition.X; - float viceArmIdleYPos = Main.npc[(int)npc.ai[1]].Center.Y + 230f - viceArmPosition.Y; - float viceArmIdleDistance = (float)Math.Sqrt(viceArmIdleXPos * viceArmIdleXPos + viceArmIdleYPos * viceArmIdleYPos); - - // Return the vice to its proper location in relation to the head if it's too far away - if (npc.ai[2] != 99f) + public override bool AI(Mod mod) { - if (viceArmIdleDistance > 800f) - npc.ai[2] = 99f; - } - else if (viceArmIdleDistance < 400f) - npc.ai[2] = 0f; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Despawn if head is gone - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + // Set direction + NPC.spriteDirection = -(int)NPC.ai[0]; + + // Despawn if head is gone + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; + NPC.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) + { + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } } - } - CalamityGlobalNPC.primeVice = npc.whoAmI; + CalamityGlobalNPC.primeLaser = NPC.whoAmI; - // Check if arms are alive - bool cannonAlive = false; - bool laserAlive = false; - bool sawAlive = false; - if (CalamityGlobalNPC.primeCannon != -1) - { - if (Main.npc[CalamityGlobalNPC.primeCannon].active) - cannonAlive = true; - } - if (CalamityGlobalNPC.primeLaser != -1) - { - if (Main.npc[CalamityGlobalNPC.primeLaser].active) - laserAlive = true; - } - if (CalamityGlobalNPC.primeSaw != -1) - { - if (Main.npc[CalamityGlobalNPC.primeSaw].active) - sawAlive = true; - } + // Check if arms are alive + bool cannonAlive = false; + bool viceAlive = false; + bool sawAlive = false; + if (CalamityGlobalNPC.primeCannon != -1) + { + if (Main.npc[CalamityGlobalNPC.primeCannon].active) + cannonAlive = true; + } + if (CalamityGlobalNPC.primeVice != -1) + { + if (Main.npc[CalamityGlobalNPC.primeVice].active) + viceAlive = true; + } + if (CalamityGlobalNPC.primeSaw != -1) + { + if (Main.npc[CalamityGlobalNPC.primeSaw].active) + sawAlive = true; + } - // Avoid cheap bullshit - npc.damage = 0; + // Inflict 0 damage for 3 seconds after spawning + float timeToNotAttack = 180f; + bool dontAttack = NPC.Calamity().newAI[2] < timeToNotAttack; + if (dontAttack) + { + NPC.Calamity().newAI[2] += 1f; + if (NPC.Calamity().newAI[2] >= timeToNotAttack) + NPC.SyncExtraAI(); + } - // Return to the head - if (npc.ai[2] == 99f) - { - float acceleration = bossRush ? 0.6f : death ? 0.375f : 0.25f; + bool normalLaserRotation = NPC.localAI[1] % 2f == 0f; + + // Movement + float acceleration = death ? 0.385f : 0.25f; float accelerationMult = 1f; if (!cannonAlive) { acceleration += 0.025f; accelerationMult += 0.5f; } - if (!laserAlive) - { + if (!viceAlive) acceleration += 0.025f; - accelerationMult += 0.5f; - } if (!sawAlive) acceleration += 0.025f; if (death) @@ -1449,77 +735,492 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float topVelocity = acceleration * 100f; float deceleration = death ? 0.6f : 0.8f; - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 20f) + if (NPC.position.Y > Main.npc[(int)NPC.ai[1]].position.Y - 70f) { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y -= acceleration; + NPC.velocity.Y -= acceleration; - if (npc.velocity.Y > topVelocity) - npc.velocity.Y = topVelocity; + if (NPC.velocity.Y > topVelocity) + NPC.velocity.Y = topVelocity; } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 20f) + else if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y - 100f) { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y += acceleration; + NPC.velocity.Y += acceleration; - if (npc.velocity.Y < -topVelocity) - npc.velocity.Y = -topVelocity; + if (NPC.velocity.Y < -topVelocity) + NPC.velocity.Y = -topVelocity; } - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 20f) + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X - 130f * NPC.ai[0]) { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X -= acceleration * 2f; + NPC.velocity.X -= acceleration; - if (npc.velocity.X > topVelocity) - npc.velocity.X = topVelocity; + if (NPC.velocity.X > topVelocity) + NPC.velocity.X = topVelocity; } - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 20f) + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 160f * NPC.ai[0]) { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X += acceleration * 2f; + NPC.velocity.X += acceleration; - if (npc.velocity.X < -topVelocity) - npc.velocity.X = -topVelocity; + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; } - } - // Other phases - else - { - // Stay near the head - if (npc.ai[2] == 0f || npc.ai[2] == 3f) + // Phase 1 + if (NPC.ai[2] == 0f) { // Despawn if head is despawning - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) - npc.timeLeft = 10; + if (Main.npc[(int)NPC.ai[1]].ai[1] == 3f && NPC.timeLeft > 10) + NPC.timeLeft = 10; - // Start charging after 10 seconds (change this as each arm dies) - npc.ai[3] += 1f; + // Go to other phase after 13.3 seconds (change this as each arm dies) + NPC.ai[3] += 1f; if (!cannonAlive) - npc.ai[3] += 1f; - if (!laserAlive) - npc.ai[3] += 1f; + NPC.ai[3] += 1f; + if (!viceAlive) + NPC.ai[3] += 1f; if (!sawAlive) - npc.ai[3] += 1f; + NPC.ai[3] += 1f; - if (npc.ai[3] >= (death ? 150f : 600f)) + if (NPC.ai[3] >= (death ? 200f : 800f)) { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; + NPC.target = Main.npc[(int)NPC.ai[1]].target; + NPC.localAI[0] = 0f; + NPC.ai[2] = 1f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; } - float acceleration = bossRush ? 0.6f : death ? 0.375f : 0.25f; + Vector2 laserArmPosition = NPC.Center; + float laserArmTargetX = Main.player[NPC.target].Center.X - laserArmPosition.X; + float laserArmTargetY = Main.player[NPC.target].Center.Y - laserArmPosition.Y; + float laserArmTargetDist = (float)Math.Sqrt(laserArmTargetX * laserArmTargetX + laserArmTargetY * laserArmTargetY); + NPC.rotation = (float)Math.Atan2(laserArmTargetY, laserArmTargetX) - MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) + { + // Fire laser every 0.8 seconds (change this as each arm dies to fire more aggressively) + NPC.localAI[0] += 1f; + if (!cannonAlive) + NPC.localAI[0] += 1f; + if (!viceAlive) + NPC.localAI[0] += 1f; + if (!sawAlive) + NPC.localAI[0] += 1f; + + if (NPC.localAI[0] >= 48f) + { + NPC.localAI[0] = 0f; + float laserSpeed = 4f; + int type = ProjectileID.DeathLaser; + + laserArmTargetDist = laserSpeed / laserArmTargetDist; + laserArmTargetX *= laserArmTargetDist; + laserArmTargetY *= laserArmTargetDist; + Vector2 laserVelocity = new Vector2(laserArmTargetX, laserArmTargetY); + Projectile.NewProjectile(NPC.GetSource_FromAI(), laserArmPosition + laserVelocity.SafeNormalize(Vector2.UnitY) * 100f, laserVelocity, type, LaserDamage.CalculateMechDamage(), 0f, Main.myPlayer, 1f, 0f); + } + } + } + + // Other phase, get closer to the player and fire ring of lasers + else if (NPC.ai[2] == 1f) + { + // Go to phase 1 after 2 seconds (change this as each arm dies to stay in this phase for longer) + NPC.ai[3] += 1f; + + float timeLimit = 135f; + float timeMult = 1.882075f; + if (!cannonAlive) + timeLimit *= timeMult; + if (!viceAlive) + timeLimit *= timeMult; + if (!sawAlive) + timeLimit *= timeMult; + + if (NPC.ai[3] >= timeLimit) + { + NPC.target = Main.npc[(int)NPC.ai[1]].target; + NPC.localAI[0] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + Vector2 laserRingArmPosition = NPC.Center; + float laserRingTargetX = Main.player[NPC.target].Center.X - laserRingArmPosition.X; + float laserRingTargetY = Main.player[NPC.target].Center.Y - laserRingArmPosition.Y; + NPC.rotation = (float)Math.Atan2(laserRingTargetY, laserRingTargetX) - MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) + { + // Fire laser every 1.5 seconds (change this as each arm dies to fire more aggressively) + NPC.localAI[0] += 1f; + if (!cannonAlive) + NPC.localAI[0] += 0.5f; + if (!viceAlive) + NPC.localAI[0] += 0.5f; + if (!sawAlive) + NPC.localAI[0] += 0.5f; + + if (NPC.localAI[0] >= 120f) + { + NPC.localAI[0] = 0f; + int totalProjectiles = death ? 24 : 16; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ProjectileID.DeathLaser; + + float velocity = 3f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float laserVelocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-laserVelocityX, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 laserFireDirection = spinningPoint.RotatedBy(radians * k); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserFireDirection.SafeNormalize(Vector2.UnitY) * 100f, laserFireDirection, type, LaserDamage.CalculateMechDamage(), 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 900; + } + NPC.localAI[1] += 1f; + } + } + } + + return false; + } + } + + public class PrimeCannonAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + NPC.spriteDirection = -(int)NPC.ai[0]; + + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) + { + NPC.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) + { + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + } + + CalamityGlobalNPC.primeCannon = NPC.whoAmI; + + // Check if arms are alive + bool laserAlive = false; + bool viceAlive = false; + bool sawAlive = false; + if (CalamityGlobalNPC.primeLaser != -1) + { + if (Main.npc[CalamityGlobalNPC.primeLaser].active) + laserAlive = true; + } + if (CalamityGlobalNPC.primeVice != -1) + { + if (Main.npc[CalamityGlobalNPC.primeVice].active) + viceAlive = true; + } + if (CalamityGlobalNPC.primeSaw != -1) + { + if (Main.npc[CalamityGlobalNPC.primeSaw].active) + sawAlive = true; + } + + // Inflict 0 damage for 3 seconds after spawning + float timeToNotAttack = 180f; + bool dontAttack = NPC.Calamity().newAI[2] < timeToNotAttack; + if (dontAttack) + { + NPC.Calamity().newAI[2] += 1f; + if (NPC.Calamity().newAI[2] >= timeToNotAttack) + NPC.SyncExtraAI(); + } + + bool fireSlower = false; + if (laserAlive) + { + // If laser is firing ring of lasers + if (Main.npc[CalamityGlobalNPC.primeLaser].ai[2] == 1f) + fireSlower = true; + } + else + { + fireSlower = NPC.ai[2] == 0f; + + if (fireSlower) + { + // Go to other phase after 13.33 seconds (change this as each arm dies) + NPC.ai[3] += 1f; + if (!laserAlive) + NPC.ai[3] += 1f; + if (!viceAlive) + NPC.ai[3] += 1f; + if (!sawAlive) + NPC.ai[3] += 1f; + + if (NPC.ai[3] >= (death ? 200f : 800f)) + { + NPC.target = Main.npc[(int)NPC.ai[1]].target; + NPC.localAI[0] = 0f; + NPC.ai[2] = 1f; + fireSlower = false; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + } + else + { + // Go to phase 1 after 2 seconds (change this as each arm dies to stay in this phase for longer) + NPC.ai[3] += 1f; + + float timeLimit = 120f; + float timeMult = 1.882075f; + if (!laserAlive) + timeLimit *= timeMult; + if (!viceAlive) + timeLimit *= timeMult; + if (!sawAlive) + timeLimit *= timeMult; + + if (NPC.ai[3] >= timeLimit) + { + NPC.target = Main.npc[(int)NPC.ai[1]].target; + NPC.localAI[0] = 0f; + NPC.ai[2] = 0f; + fireSlower = true; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + } + } + + // Movement + float acceleration = death ? 0.385f : 0.25f; + float accelerationMult = 1f; + if (!laserAlive) + { + acceleration += 0.025f; + accelerationMult += 0.5f; + } + if (!viceAlive) + acceleration += 0.025f; + if (!sawAlive) + acceleration += 0.025f; + if (death) + acceleration *= accelerationMult; + + float topVelocity = acceleration * 100f; + float deceleration = death ? 0.6f : 0.8f; + + if (NPC.position.Y > Main.npc[(int)NPC.ai[1]].position.Y - 70f) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > topVelocity) + NPC.velocity.Y = topVelocity; + } + else if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y - 100f) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y += acceleration; + + if (NPC.velocity.Y < -topVelocity) + NPC.velocity.Y = -topVelocity; + } + + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X + 130f) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X -= acceleration; + + if (NPC.velocity.X > topVelocity) + NPC.velocity.X = topVelocity; + } + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X + 160f) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X += acceleration; + + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; + } + + if (fireSlower) + { + if (Main.npc[(int)NPC.ai[1]].ai[1] == 3f && NPC.timeLeft > 10) + NPC.timeLeft = 10; + + Vector2 cannonArmPosition = NPC.Center; + float cannonArmTargetX = Main.player[NPC.target].Center.X - cannonArmPosition.X; + float cannonArmTargetY = Main.player[NPC.target].Center.Y - cannonArmPosition.Y; + float cannonArmTargetDist = (float)Math.Sqrt(cannonArmTargetX * cannonArmTargetX + cannonArmTargetY * cannonArmTargetY); + NPC.rotation = (float)Math.Atan2(cannonArmTargetY, cannonArmTargetX) - MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) + { + // Fire rocket every 2 seconds (change this as each arm dies to fire more aggressively) + NPC.localAI[0] += 1f; + if (!laserAlive) + NPC.localAI[0] += 1f; + if (!viceAlive) + NPC.localAI[0] += 1f; + if (!sawAlive) + NPC.localAI[0] += 1f; + + if (NPC.localAI[0] >= 120f) + { + SoundEngine.PlaySound(SoundID.Item62, NPC.Center); + NPC.localAI[0] = 0f; + int type = ProjectileID.RocketSkeleton; + + float rocketSpeed = 10f; + cannonArmTargetDist = rocketSpeed / cannonArmTargetDist; + cannonArmTargetX *= cannonArmTargetDist; + cannonArmTargetY *= cannonArmTargetDist; + + Vector2 rocketVelocity = new Vector2(cannonArmTargetX, cannonArmTargetY); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), cannonArmPosition + rocketVelocity.SafeNormalize(Vector2.UnitY) * 40f, rocketVelocity, type, RocketDamage.CalculateMechDamage(), 0f, Main.myPlayer, NPC.target, 2f); + Main.projectile[proj].timeLeft = 540; + } + } + } + else + { + Vector2 cannonSpreadArmPosition = NPC.Center; + float cannonSpreadArmTargetX = Main.player[NPC.target].Center.X - cannonSpreadArmPosition.X; + float cannonSpreadArmTargetY = Main.player[NPC.target].Center.Y - cannonSpreadArmPosition.Y; + NPC.rotation = (float)Math.Atan2(cannonSpreadArmTargetY, cannonSpreadArmTargetX) - MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.MultiplayerClient && !dontAttack) + { + // Fire rockets every 2 seconds (change this as each arm dies to fire more aggressively) + NPC.localAI[0] += 1f; + if (!laserAlive) + NPC.localAI[0] += 0.5f; + if (!viceAlive) + NPC.localAI[0] += 0.5f; + if (!sawAlive) + NPC.localAI[0] += 0.5f; + + if (NPC.localAI[0] >= 180f) + { + SoundEngine.PlaySound(SoundID.Item62, NPC.Center); + NPC.localAI[0] = 0f; + int type = ProjectileID.RocketSkeleton; + + float rocketSpeed = 10f; + Vector2 cannonSpreadTargetDist = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * rocketSpeed; + int numProj = 3; + float rotation = MathHelper.ToRadians(9); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = cannonSpreadTargetDist.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 40f, perturbedSpeed, type, RocketDamage.CalculateMechDamage(), 0f, Main.myPlayer, NPC.target, 2f); + Main.projectile[proj].timeLeft = 600; + } + } + } + } + + return false; + } + } + + public class PrimeViceAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); + + // Direction + NPC.spriteDirection = -(int)NPC.ai[0]; + + // Where the vice should be in relation to the head + Vector2 viceArmPosition = NPC.Center; + float viceArmIdleXPos = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - viceArmPosition.X; + float viceArmIdleYPos = Main.npc[(int)NPC.ai[1]].Center.Y + 230f - viceArmPosition.Y; + float viceArmIdleDistance = (float)Math.Sqrt(viceArmIdleXPos * viceArmIdleXPos + viceArmIdleYPos * viceArmIdleYPos); + + // Return the vice to its proper location in relation to the head if it's too far away + if (NPC.ai[2] != 99f) + { + if (viceArmIdleDistance > 800f) + NPC.ai[2] = 99f; + } + else if (viceArmIdleDistance < 400f) + NPC.ai[2] = 0f; + + // Despawn if head is gone + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) + { + NPC.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) + { + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + } + + CalamityGlobalNPC.primeVice = NPC.whoAmI; + + // Check if arms are alive + bool cannonAlive = false; + bool laserAlive = false; + bool sawAlive = false; + if (CalamityGlobalNPC.primeCannon != -1) + { + if (Main.npc[CalamityGlobalNPC.primeCannon].active) + cannonAlive = true; + } + if (CalamityGlobalNPC.primeLaser != -1) + { + if (Main.npc[CalamityGlobalNPC.primeLaser].active) + laserAlive = true; + } + if (CalamityGlobalNPC.primeSaw != -1) + { + if (Main.npc[CalamityGlobalNPC.primeSaw].active) + sawAlive = true; + } + + // Return to the head + if (NPC.ai[2] == 99f) + { + float acceleration = death ? 0.385f : 0.25f; float accelerationMult = 1f; if (!cannonAlive) { @@ -1539,106 +1240,250 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float topVelocity = acceleration * 100f; float deceleration = death ? 0.6f : 0.8f; - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 100f) + if (NPC.position.Y > Main.npc[(int)NPC.ai[1]].position.Y + 20f) { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y -= acceleration; + NPC.velocity.Y -= acceleration; - if (npc.velocity.Y > topVelocity) - npc.velocity.Y = topVelocity; + if (NPC.velocity.Y > topVelocity) + NPC.velocity.Y = topVelocity; } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y + 70f) + else if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y - 20f) { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y += acceleration; + NPC.velocity.Y += acceleration; - if (npc.velocity.Y < -topVelocity) - npc.velocity.Y = -topVelocity; + if (NPC.velocity.Y < -topVelocity) + NPC.velocity.Y = -topVelocity; } - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 160f) + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X + 20f) { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X -= acceleration; + NPC.velocity.X -= acceleration * 2f; - if (npc.velocity.X > topVelocity) - npc.velocity.X = topVelocity; + if (NPC.velocity.X > topVelocity) + NPC.velocity.X = topVelocity; } - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X + 130f) + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 20f) { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X += acceleration; + NPC.velocity.X += acceleration * 2f; - if (npc.velocity.X < -topVelocity) - npc.velocity.X = -topVelocity; + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; } - - Vector2 viceArmReelbackCurrentPos = npc.Center; - float viceArmReelbackXDest = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - viceArmReelbackCurrentPos.X; - float viceArmReelbackYDest = Main.npc[(int)npc.ai[1]].position.Y + 230f - viceArmReelbackCurrentPos.Y; - npc.rotation = (float)Math.Atan2(viceArmReelbackYDest, viceArmReelbackXDest) + MathHelper.PiOver2; - return false; } - // Charge towards the player - if (npc.ai[2] == 1f) + // Other phases + else { - float deceleration = death ? 0.75f : 0.8f; - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - Vector2 viceArmChargePosition = npc.Center; - float viceArmChargeTargetX = Main.npc[(int)npc.ai[1]].Center.X - 280f * npc.ai[0] - viceArmChargePosition.X; - float viceArmChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - viceArmChargePosition.Y; - npc.rotation = (float)Math.Atan2(viceArmChargeTargetY, viceArmChargeTargetX) + MathHelper.PiOver2; - - npc.velocity.X = (npc.velocity.X * 5f + Main.npc[(int)npc.ai[1]].velocity.X) / 6f; - npc.velocity.X += 0.5f; - - npc.velocity.Y -= 0.5f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 280f) + // Stay near the head + if (NPC.ai[2] == 0f || NPC.ai[2] == 3f) { - // Set damage - npc.damage = npc.defDamage; + // Despawn if head is despawning + if (Main.npc[(int)NPC.ai[1]].ai[1] == 3f && NPC.timeLeft > 10) + NPC.timeLeft = 10; - float chargeVelocity = bossRush ? 20f : 16f; + // Start charging after 10 seconds (change this as each arm dies) + NPC.ai[3] += 1f; if (!cannonAlive) - chargeVelocity += 1.5f; + NPC.ai[3] += 1f; if (!laserAlive) - chargeVelocity += 1.5f; + NPC.ai[3] += 1f; if (!sawAlive) - chargeVelocity += 1.5f; + NPC.ai[3] += 1f; - npc.ai[2] = 2f; - viceArmChargePosition = npc.Center; - viceArmChargeTargetX = Main.player[npc.target].Center.X - viceArmChargePosition.X; - viceArmChargeTargetY = Main.player[npc.target].Center.Y - viceArmChargePosition.Y; - float viceArmChargeTargetDist = (float)Math.Sqrt(viceArmChargeTargetX * viceArmChargeTargetX + viceArmChargeTargetY * viceArmChargeTargetY); - viceArmChargeTargetDist = chargeVelocity / viceArmChargeTargetDist; - npc.velocity.X = viceArmChargeTargetX * viceArmChargeTargetDist; - npc.velocity.Y = viceArmChargeTargetY * viceArmChargeTargetDist; - npc.netUpdate = true; + if (NPC.ai[3] >= (death ? 150f : 600f)) + { + NPC.target = Main.npc[(int)NPC.ai[1]].target; + NPC.ai[2] += 1f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + float acceleration = death ? 0.385f : 0.25f; + float accelerationMult = 1f; + if (!cannonAlive) + { + acceleration += 0.025f; + accelerationMult += 0.5f; + } + if (!laserAlive) + { + acceleration += 0.025f; + accelerationMult += 0.5f; + } + if (!sawAlive) + acceleration += 0.025f; + if (death) + acceleration *= accelerationMult; + + float topVelocity = acceleration * 100f; + float deceleration = death ? 0.6f : 0.8f; + + if (NPC.position.Y > Main.npc[(int)NPC.ai[1]].position.Y + 100f) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > topVelocity) + NPC.velocity.Y = topVelocity; + } + else if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y + 70f) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y += acceleration; + + if (NPC.velocity.Y < -topVelocity) + NPC.velocity.Y = -topVelocity; + } + + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X + 160f) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X -= acceleration; + + if (NPC.velocity.X > topVelocity) + NPC.velocity.X = topVelocity; + } + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X + 130f) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X += acceleration; + + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; + } + + Vector2 viceArmReelbackCurrentPos = NPC.Center; + float viceArmReelbackXDest = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - viceArmReelbackCurrentPos.X; + float viceArmReelbackYDest = Main.npc[(int)NPC.ai[1]].position.Y + 230f - viceArmReelbackCurrentPos.Y; + NPC.rotation = (float)Math.Atan2(viceArmReelbackYDest, viceArmReelbackXDest) + MathHelper.PiOver2; + return false; } - } - // Charge 4 times (more if arms are dead) - else if (npc.ai[2] == 2f) - { - // Set damage - npc.damage = npc.defDamage; + // Charge towards the player + if (NPC.ai[2] == 1f) + { + float deceleration = death ? 0.75f : 0.8f; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f) + Vector2 viceArmChargePosition = NPC.Center; + float viceArmChargeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - 280f * NPC.ai[0] - viceArmChargePosition.X; + float viceArmChargeTargetY = Main.npc[(int)NPC.ai[1]].position.Y + 230f - viceArmChargePosition.Y; + NPC.rotation = (float)Math.Atan2(viceArmChargeTargetY, viceArmChargeTargetX) + MathHelper.PiOver2; + + NPC.velocity.X = (NPC.velocity.X * 5f + Main.npc[(int)NPC.ai[1]].velocity.X) / 6f; + NPC.velocity.X += 0.5f; + + NPC.velocity.Y -= 0.5f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; + + if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y - 280f) + { + float chargeVelocity = 16f; + if (!cannonAlive) + chargeVelocity += 1.5f; + if (!laserAlive) + chargeVelocity += 1.5f; + if (!sawAlive) + chargeVelocity += 1.5f; + + NPC.ai[2] = 2f; + viceArmChargePosition = NPC.Center; + viceArmChargeTargetX = Main.player[NPC.target].Center.X - viceArmChargePosition.X; + viceArmChargeTargetY = Main.player[NPC.target].Center.Y - viceArmChargePosition.Y; + float viceArmChargeTargetDist = (float)Math.Sqrt(viceArmChargeTargetX * viceArmChargeTargetX + viceArmChargeTargetY * viceArmChargeTargetY); + viceArmChargeTargetDist = chargeVelocity / viceArmChargeTargetDist; + NPC.velocity.X = viceArmChargeTargetX * viceArmChargeTargetDist; + NPC.velocity.Y = viceArmChargeTargetY * viceArmChargeTargetDist; + NPC.netUpdate = true; + } + } + + // Charge 4 times (more if arms are dead) + else if (NPC.ai[2] == 2f) + { + if (NPC.position.Y > Main.player[NPC.target].position.Y || NPC.velocity.Y < 0f) + { + float chargeAmt = 4f; + if (!cannonAlive) + chargeAmt += 1f; + if (!laserAlive) + chargeAmt += 1f; + if (!sawAlive) + chargeAmt += 1f; + + if (NPC.ai[3] >= chargeAmt) + { + // Return to head + NPC.ai[2] = 3f; + NPC.ai[3] = 0f; + return false; + } + + NPC.ai[2] = 1f; + NPC.ai[3] += 1f; + } + } + + // Different type of charge + else if (NPC.ai[2] == 4f) + { + Vector2 viceArmOtherChargePosition = NPC.Center; + float viceArmOtherChargeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - viceArmOtherChargePosition.X; + float viceArmOtherChargeTargetY = Main.npc[(int)NPC.ai[1]].position.Y + 230f - viceArmOtherChargePosition.Y; + NPC.rotation = (float)Math.Atan2(viceArmOtherChargeTargetY, viceArmOtherChargeTargetX) + MathHelper.PiOver2; + + NPC.velocity.Y = (NPC.velocity.Y * 5f + Main.npc[(int)NPC.ai[1]].velocity.Y) / 6f; + + NPC.velocity.X += 0.5f; + if (NPC.velocity.X > 12f) + NPC.velocity.X = 12f; + + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 500f || NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X + 500f) + { + float chargeVelocity = 14f; + if (!cannonAlive) + chargeVelocity += 1f; + if (!laserAlive) + chargeVelocity += 1f; + if (!sawAlive) + chargeVelocity += 1f; + + NPC.ai[2] = 5f; + viceArmOtherChargePosition = NPC.Center; + viceArmOtherChargeTargetX = Main.player[NPC.target].Center.X - viceArmOtherChargePosition.X; + viceArmOtherChargeTargetY = Main.player[NPC.target].Center.Y - viceArmOtherChargePosition.Y; + float viceArmOtherChargeTargetDist = (float)Math.Sqrt(viceArmOtherChargeTargetX * viceArmOtherChargeTargetX + viceArmOtherChargeTargetY * viceArmOtherChargeTargetY); + viceArmOtherChargeTargetDist = chargeVelocity / viceArmOtherChargeTargetDist; + NPC.velocity.X = viceArmOtherChargeTargetX * viceArmOtherChargeTargetDist; + NPC.velocity.Y = viceArmOtherChargeTargetY * viceArmOtherChargeTargetDist; + NPC.netUpdate = true; + } + } + + // Charge 4 times (more if arms are dead) + else if (NPC.ai[2] == 5f && NPC.Center.X < Main.player[NPC.target].Center.X - 100f) { float chargeAmt = 4f; if (!cannonAlive) @@ -1648,240 +1493,84 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!sawAlive) chargeAmt += 1f; - if (npc.ai[3] >= chargeAmt) + if (NPC.ai[3] >= chargeAmt) { // Return to head - npc.ai[2] = 3f; - npc.ai[3] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; return false; } - npc.ai[2] = 1f; - npc.ai[3] += 1f; + NPC.ai[2] = 4f; + NPC.ai[3] += 1f; } } - // Different type of charge - else if (npc.ai[2] == 4f) - { - Vector2 viceArmOtherChargePosition = npc.Center; - float viceArmOtherChargeTargetX = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - viceArmOtherChargePosition.X; - float viceArmOtherChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - viceArmOtherChargePosition.Y; - npc.rotation = (float)Math.Atan2(viceArmOtherChargeTargetY, viceArmOtherChargeTargetX) + MathHelper.PiOver2; - - npc.velocity.Y = (npc.velocity.Y * 5f + Main.npc[(int)npc.ai[1]].velocity.Y) / 6f; - - npc.velocity.X += 0.5f; - if (npc.velocity.X > 12f) - npc.velocity.X = 12f; - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 500f || npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 500f) - { - // Set damage - npc.damage = npc.defDamage; - - float chargeVelocity = bossRush ? 17.5f : 14f; - if (!cannonAlive) - chargeVelocity += 1f; - if (!laserAlive) - chargeVelocity += 1f; - if (!sawAlive) - chargeVelocity += 1f; - - npc.ai[2] = 5f; - viceArmOtherChargePosition = npc.Center; - viceArmOtherChargeTargetX = Main.player[npc.target].Center.X - viceArmOtherChargePosition.X; - viceArmOtherChargeTargetY = Main.player[npc.target].Center.Y - viceArmOtherChargePosition.Y; - float viceArmOtherChargeTargetDist = (float)Math.Sqrt(viceArmOtherChargeTargetX * viceArmOtherChargeTargetX + viceArmOtherChargeTargetY * viceArmOtherChargeTargetY); - viceArmOtherChargeTargetDist = chargeVelocity / viceArmOtherChargeTargetDist; - npc.velocity.X = viceArmOtherChargeTargetX * viceArmOtherChargeTargetDist; - npc.velocity.Y = viceArmOtherChargeTargetY * viceArmOtherChargeTargetDist; - npc.netUpdate = true; - } - } - - // Charge 4 times (more if arms are dead) - else if (npc.ai[2] == 5f && npc.Center.X < Main.player[npc.target].Center.X - 100f) - { - // Set damage - npc.damage = npc.defDamage; - - float chargeAmt = 4f; - if (!cannonAlive) - chargeAmt += 1f; - if (!laserAlive) - chargeAmt += 1f; - if (!sawAlive) - chargeAmt += 1f; - - if (npc.ai[3] >= chargeAmt) - { - // Return to head - npc.ai[2] = 0f; - npc.ai[3] = 0f; - return false; - } - - npc.ai[2] = 4f; - npc.ai[3] += 1f; - } + return false; } - - return false; } - public static bool BuffedPrimeSawAI(NPC npc, Mod mod) + public class PrimeSawAI : VanillaAIOverride { - 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) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - Vector2 sawArmLocation = npc.Center; - float sawArmIdleXPos = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - sawArmLocation.X; - float sawArmIdleYPos = Main.npc[(int)npc.ai[1]].Center.Y + 230f - sawArmLocation.Y; - float sawArmIdleDistance = (float)Math.Sqrt(sawArmIdleXPos * sawArmIdleXPos + sawArmIdleYPos * sawArmIdleYPos); - - if (npc.ai[2] != 99f) + public override bool AI(Mod mod) { - if (sawArmIdleDistance > 800f) - npc.ai[2] = 99f; - } - else if (sawArmIdleDistance < 400f) - npc.ai[2] = 0f; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - npc.spriteDirection = -(int)npc.ai[0]; + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + CalamityUtils.CalamityTargeting(NPC, CalamityTargetingParameters.BossDefaults); - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) + Vector2 sawArmLocation = NPC.Center; + float sawArmIdleXPos = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - sawArmLocation.X; + float sawArmIdleYPos = Main.npc[(int)NPC.ai[1]].Center.Y + 230f - sawArmLocation.Y; + float sawArmIdleDistance = (float)Math.Sqrt(sawArmIdleXPos * sawArmIdleXPos + sawArmIdleYPos * sawArmIdleYPos); + + if (NPC.ai[2] != 99f) { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; + if (sawArmIdleDistance > 800f) + NPC.ai[2] = 99f; } - } + else if (sawArmIdleDistance < 400f) + NPC.ai[2] = 0f; - CalamityGlobalNPC.primeSaw = npc.whoAmI; + NPC.spriteDirection = -(int)NPC.ai[0]; - // Check if arms are alive - bool cannonAlive = false; - bool laserAlive = false; - bool viceAlive = false; - if (CalamityGlobalNPC.primeCannon != -1) - { - if (Main.npc[CalamityGlobalNPC.primeCannon].active) - cannonAlive = true; - } - if (CalamityGlobalNPC.primeLaser != -1) - { - if (Main.npc[CalamityGlobalNPC.primeLaser].active) - laserAlive = true; - } - if (CalamityGlobalNPC.primeVice != -1) - { - if (Main.npc[CalamityGlobalNPC.primeVice].active) - viceAlive = true; - } - - // Min saw damage - int reducedSetDamage = (int)Math.Round(npc.defDamage * 0.5); - - // Avoid cheap bullshit - npc.damage = reducedSetDamage; - - if (npc.ai[2] == 99f) - { - float acceleration = bossRush ? 0.6f : death ? 0.375f : 0.25f; - float accelerationMult = 1f; - if (!cannonAlive) + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) { - acceleration += 0.025f; - accelerationMult += 0.5f; - } - if (!laserAlive) - { - acceleration += 0.025f; - accelerationMult += 0.5f; - } - if (!viceAlive) - acceleration += 0.025f; - if (death) - acceleration *= accelerationMult; - - float topVelocity = acceleration * 100f; - float deceleration = death ? 0.6f : 0.8f; - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 20f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= acceleration; - - if (npc.velocity.Y > topVelocity) - npc.velocity.Y = topVelocity; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 20f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += acceleration; - - if (npc.velocity.Y < -topVelocity) - npc.velocity.Y = -topVelocity; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 20f) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= acceleration * 2f; - - if (npc.velocity.X > topVelocity) - npc.velocity.X = topVelocity; - } - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 20f) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += acceleration * 2f; - - if (npc.velocity.X < -topVelocity) - npc.velocity.X = -topVelocity; - } - } - else - { - if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) - npc.timeLeft = 10; - - // Start charging after 3 seconds (change this as each arm dies) - npc.ai[3] += 1f; - if (!cannonAlive) - npc.ai[3] += 1f; - if (!laserAlive) - npc.ai[3] += 1f; - if (!viceAlive) - npc.ai[3] += 1f; - - if (npc.ai[3] >= (death ? 90f : 180f)) + NPC.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; } + } - float acceleration = bossRush ? 0.6f : death ? 0.375f : 0.25f; + CalamityGlobalNPC.primeSaw = NPC.whoAmI; + + // Check if arms are alive + bool cannonAlive = false; + bool laserAlive = false; + bool viceAlive = false; + if (CalamityGlobalNPC.primeCannon != -1) + { + if (Main.npc[CalamityGlobalNPC.primeCannon].active) + cannonAlive = true; + } + if (CalamityGlobalNPC.primeLaser != -1) + { + if (Main.npc[CalamityGlobalNPC.primeLaser].active) + laserAlive = true; + } + if (CalamityGlobalNPC.primeVice != -1) + { + if (Main.npc[CalamityGlobalNPC.primeVice].active) + viceAlive = true; + } + + if (NPC.ai[2] == 99f) + { + float acceleration = death ? 0.385f : 0.25f; float accelerationMult = 1f; if (!cannonAlive) { @@ -1901,1655 +1590,261 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float topVelocity = acceleration * 100f; float deceleration = death ? 0.6f : 0.8f; - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 100f) + if (NPC.position.Y > Main.npc[(int)NPC.ai[1]].position.Y + 20f) { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y -= acceleration; + NPC.velocity.Y -= acceleration; - if (npc.velocity.Y > topVelocity) - npc.velocity.Y = topVelocity; + if (NPC.velocity.Y > topVelocity) + NPC.velocity.Y = topVelocity; } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y + 70f) + else if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y - 20f) { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y += acceleration; + NPC.velocity.Y += acceleration; - if (npc.velocity.Y < -topVelocity) - npc.velocity.Y = -topVelocity; + if (NPC.velocity.Y < -topVelocity) + NPC.velocity.Y = -topVelocity; } - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 130f) + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X + 20f) { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X -= acceleration * 1.5f; + NPC.velocity.X -= acceleration * 2f; - if (npc.velocity.X > topVelocity) - npc.velocity.X = topVelocity; + if (NPC.velocity.X > topVelocity) + NPC.velocity.X = topVelocity; } - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 160f) + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 20f) { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; - npc.velocity.X += acceleration * 1.5f; + NPC.velocity.X += acceleration * 2f; - if (npc.velocity.X < -topVelocity) - npc.velocity.X = -topVelocity; - } - - Vector2 sawArmReelbackCurrentPos = npc.Center; - float sawArmReelbackXDest = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - sawArmReelbackCurrentPos.X; - float sawArmReelbackYDest = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmReelbackCurrentPos.Y; - npc.rotation = (float)Math.Atan2(sawArmReelbackYDest, sawArmReelbackXDest) + MathHelper.PiOver2; - return false; - } - - if (npc.ai[2] == 1f) - { - Vector2 sawArmChargePos = npc.Center; - float sawArmChargeTargetX = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - sawArmChargePos.X; - float sawArmChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmChargePos.Y; - npc.rotation = (float)Math.Atan2(sawArmChargeTargetY, sawArmChargeTargetX) + MathHelper.PiOver2; - - float deceleration = death ? 0.875f : 0.9f; - npc.velocity.X *= deceleration; - npc.velocity.Y -= 0.5f; - if (npc.velocity.Y < -12f) - npc.velocity.Y = -12f; - - if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) - { - // Set damage - npc.damage = npc.defDamage; - - float chargeVelocity = bossRush ? 27.5f : 22f; - if (!cannonAlive) - chargeVelocity += 1.5f; - if (!laserAlive) - chargeVelocity += 1.5f; - if (!viceAlive) - chargeVelocity += 1.5f; - - npc.ai[2] = 2f; - sawArmChargePos = npc.Center; - sawArmChargeTargetX = Main.player[npc.target].Center.X - sawArmChargePos.X; - sawArmChargeTargetY = Main.player[npc.target].Center.Y - sawArmChargePos.Y; - float sawArmChargeTargetDist = (float)Math.Sqrt(sawArmChargeTargetX * sawArmChargeTargetX + sawArmChargeTargetY * sawArmChargeTargetY); - sawArmChargeTargetDist = chargeVelocity / sawArmChargeTargetDist; - npc.velocity.X = sawArmChargeTargetX * sawArmChargeTargetDist; - npc.velocity.Y = sawArmChargeTargetY * sawArmChargeTargetDist; - npc.netUpdate = true; + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; } } - - else if (npc.ai[2] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f) - npc.ai[2] = 3f; - } - else { - if (npc.ai[2] == 4f) + if (NPC.ai[2] == 0f || NPC.ai[2] == 3f) { - // Set damage - npc.damage = npc.defDamage; + if (Main.npc[(int)NPC.ai[1]].ai[1] == 3f && NPC.timeLeft > 10) + NPC.timeLeft = 10; - float chargeVelocity = bossRush ? 13.5f : 11f; + // Start charging after 3 seconds (change this as each arm dies) + NPC.ai[3] += 1f; if (!cannonAlive) - chargeVelocity += 1.5f; + NPC.ai[3] += 1f; if (!laserAlive) - chargeVelocity += 1.5f; + NPC.ai[3] += 1f; if (!viceAlive) - chargeVelocity += 1.5f; + NPC.ai[3] += 1f; + + if (NPC.ai[3] >= (death ? 90f : 180f)) + { + NPC.target = Main.npc[(int)NPC.ai[1]].target; + NPC.ai[2] += 1f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + float acceleration = death ? 0.385f : 0.25f; + float accelerationMult = 1f; + if (!cannonAlive) + { + acceleration += 0.025f; + accelerationMult += 0.5f; + } + if (!laserAlive) + { + acceleration += 0.025f; + accelerationMult += 0.5f; + } + if (!viceAlive) + acceleration += 0.025f; if (death) - chargeVelocity *= 1.25f; + acceleration *= accelerationMult; - Vector2 sawArmOtherChargePos = npc.Center; - float sawArmOtherChargeTargetX = Main.player[npc.target].Center.X - sawArmOtherChargePos.X; - float sawArmOtherChargeTargetY = Main.player[npc.target].Center.Y - sawArmOtherChargePos.Y; - float sawArmOtherChargeTargetDist = (float)Math.Sqrt(sawArmOtherChargeTargetX * sawArmOtherChargeTargetX + sawArmOtherChargeTargetY * sawArmOtherChargeTargetY); - sawArmOtherChargeTargetDist = chargeVelocity / sawArmOtherChargeTargetDist; - sawArmOtherChargeTargetX *= sawArmOtherChargeTargetDist; - sawArmOtherChargeTargetY *= sawArmOtherChargeTargetDist; - - float acceleration = bossRush ? 0.3f : death ? 0.125f : 0.08f; + float topVelocity = acceleration * 100f; float deceleration = death ? 0.6f : 0.8f; - if (npc.velocity.X > sawArmOtherChargeTargetX) + if (NPC.position.Y > Main.npc[(int)NPC.ai[1]].position.Y + 100f) { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.X -= acceleration; + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > topVelocity) + NPC.velocity.Y = topVelocity; } - if (npc.velocity.X < sawArmOtherChargeTargetX) + else if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y + 70f) { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.X += acceleration; - } - if (npc.velocity.Y > sawArmOtherChargeTargetY) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; + NPC.velocity.Y += acceleration; - npc.velocity.Y -= acceleration; - } - if (npc.velocity.Y < sawArmOtherChargeTargetY) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += acceleration; + if (NPC.velocity.Y < -topVelocity) + NPC.velocity.Y = -topVelocity; } - npc.ai[3] += 1f; - if (npc.justHit) - npc.ai[3] += 2f; - - if (npc.ai[3] >= 600f) + if (NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X - 130f) { - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X -= acceleration * 1.5f; + + if (NPC.velocity.X > topVelocity) + NPC.velocity.X = topVelocity; + } + if (NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X - 160f) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X += acceleration * 1.5f; + + if (NPC.velocity.X < -topVelocity) + NPC.velocity.X = -topVelocity; } - sawArmOtherChargePos = npc.Center; - sawArmOtherChargeTargetX = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - sawArmOtherChargePos.X; - sawArmOtherChargeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmOtherChargePos.Y; - npc.rotation = (float)Math.Atan2(sawArmOtherChargeTargetY, sawArmOtherChargeTargetX) + MathHelper.PiOver2; + Vector2 sawArmReelbackCurrentPos = NPC.Center; + float sawArmReelbackXDest = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - sawArmReelbackCurrentPos.X; + float sawArmReelbackYDest = Main.npc[(int)NPC.ai[1]].position.Y + 230f - sawArmReelbackCurrentPos.Y; + NPC.rotation = (float)Math.Atan2(sawArmReelbackYDest, sawArmReelbackXDest) + MathHelper.PiOver2; return false; } - if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X < 0f && npc.Center.X < Main.player[npc.target].Center.X))) - npc.ai[2] = 0f; - } - } - - return false; - } - - public static bool VanillaSkeletronPrimeAI(NPC npc, Mod mod) - { - npc.defense = npc.defDefense; - if (npc.ai[3] != 0f) - NPC.mechQueen = npc.whoAmI; - - npc.reflectsProjectiles = false; - if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - npc.ai[0] = 1f; - int num495 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeCannon, npc.whoAmI); - Main.npc[num495].ai[0] = -1f; - Main.npc[num495].ai[1] = npc.whoAmI; - Main.npc[num495].target = npc.target; - Main.npc[num495].netUpdate = true; - num495 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeSaw, npc.whoAmI); - Main.npc[num495].ai[0] = 1f; - Main.npc[num495].ai[1] = npc.whoAmI; - Main.npc[num495].target = npc.target; - Main.npc[num495].netUpdate = true; - num495 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeVice, npc.whoAmI); - Main.npc[num495].ai[0] = -1f; - Main.npc[num495].ai[1] = npc.whoAmI; - Main.npc[num495].target = npc.target; - Main.npc[num495].ai[3] = 150f; - Main.npc[num495].netUpdate = true; - num495 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.PrimeLaser, npc.whoAmI); - Main.npc[num495].ai[0] = 1f; - Main.npc[num495].ai[1] = npc.whoAmI; - Main.npc[num495].target = npc.target; - Main.npc[num495].netUpdate = true; - Main.npc[num495].ai[3] = 150f; - } - - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 6000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 6000f) - { - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 6000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 6000f) - npc.ai[1] = 3f; - } - - if (Main.IsItDay() && npc.ai[1] != 3f && npc.ai[1] != 2f) - { - npc.ai[1] = 2f; - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - - if (npc.ai[1] == 0f) - { - npc.damage = 0; - - npc.ai[2] += 1f; - if (npc.ai[2] >= (Main.masterMode ? 300f : 600f)) - { - npc.ai[2] = 0f; - npc.ai[1] = 1f; - npc.netUpdate = true; - } - - if (NPC.IsMechQueenUp) - npc.rotation = npc.rotation.AngleLerp(npc.velocity.X / 15f * 0.5f, 0.75f); - else - npc.rotation = npc.velocity.X / 15f; - - float num496 = 0.1f; - float num497 = 2f; - float num498 = 0.1f; - float num499 = 8f; - float deceleration = Main.masterMode ? 0.94f : Main.expertMode ? 0.96f : 0.98f; - int num500 = 200; - int num501 = 500; - float num502 = 0f; - int num503 = ((!(Main.player[npc.target].Center.X < npc.Center.X)) ? 1 : (-1)); - if (NPC.IsMechQueenUp) - { - num502 = -450f * (float)num503; - num500 = 300; - num501 = 350; - } - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.05f : 0.03f; - num497 = Main.masterMode ? 5f : 4f; - num498 = Main.masterMode ? 0.15f : 0.12f; - num499 = Main.masterMode ? 11f : 9.5f; - } - - if (npc.position.Y > Main.player[npc.target].position.Y - (float)num500) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.player[npc.target].position.Y - (float)num501) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.player[npc.target].Center.X + 100f + num502) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.player[npc.target].Center.X - 100f + num502) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < 0f - num499) - npc.velocity.X = 0f - num499; - } - } - else if (npc.ai[1] == 1f) - { - npc.defense *= 2; - npc.damage = npc.defDamage * 2; - - npc.Calamity().CurrentlyIncreasingDefenseOrDR = true; - - npc.ai[2] += 1f; - if (npc.ai[2] == 2f) - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - - if (npc.ai[2] >= (Main.masterMode ? 300f : 400f)) - { - npc.ai[2] = 0f; - npc.ai[1] = 0f; - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - } - - if (NPC.IsMechQueenUp) - npc.rotation = npc.rotation.AngleLerp(npc.velocity.X / 15f * 0.5f, 0.75f); - else - npc.rotation += (float)npc.direction * 0.3f; - - Vector2 vector54 = npc.Center; - float num504 = Main.player[npc.target].Center.X - vector54.X; - float num505 = Main.player[npc.target].Center.Y - vector54.Y; - float num506 = (float)Math.Sqrt(num504 * num504 + num505 * num505); - float num507 = 5f; - if (Main.expertMode) - { - num507 = Main.masterMode ? 7f : 6f; - if (num506 > 150f) - num507 *= (Main.masterMode ? 1.075f : 1.05f); - - float additionalMultiplier = Main.masterMode ? 1.15f : 1.1f; - if (num506 > 200f) - num507 *= additionalMultiplier; - - if (num506 > 250f) - num507 *= additionalMultiplier; - - if (num506 > 300f) - num507 *= additionalMultiplier; - - if (num506 > 350f) - num507 *= additionalMultiplier; - - if (num506 > 400f) - num507 *= additionalMultiplier; - - if (num506 > 450f) - num507 *= additionalMultiplier; - - if (num506 > 500f) - num507 *= additionalMultiplier; - - if (num506 > 550f) - num507 *= additionalMultiplier; - - if (num506 > 600f) - num507 *= additionalMultiplier; - } - - if (NPC.IsMechQueenUp) - { - float num508 = (NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody] ? 0.6f : 0.75f); - num507 *= num508; - } - - num506 = num507 / num506; - npc.velocity.X = num504 * num506; - npc.velocity.Y = num505 * num506; - if (NPC.IsMechQueenUp) - { - float num509 = Vector2.Distance(npc.Center, Main.player[npc.target].Center); - if (num509 < 0.1f) - num509 = 0f; - - if (num509 < num507) - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * num509; - } - } - else if (npc.ai[1] == 2f) - { - npc.damage = 1000; - npc.defense = 9999; - - npc.Calamity().CurrentlyEnraged = true; - npc.Calamity().CurrentlyIncreasingDefenseOrDR = true; - - if (NPC.IsMechQueenUp) - npc.rotation = npc.rotation.AngleLerp(npc.velocity.X / 15f * 0.5f, 0.75f); - else - npc.rotation += (float)npc.direction * 0.3f; - - Vector2 vector55 = npc.Center; - float num510 = Main.player[npc.target].Center.X - vector55.X; - float num511 = Main.player[npc.target].Center.Y - vector55.Y; - float num512 = (float)Math.Sqrt(num510 * num510 + num511 * num511); - float num513 = 10f; - num513 += num512 / 100f; - if (num513 < 8f) - num513 = 8f; - - if (num513 > 32f) - num513 = 32f; - - num512 = num513 / num512; - npc.velocity.X = num510 * num512; - npc.velocity.Y = num511 * num512; - } - else - { - if (npc.ai[1] != 3f) - return false; - - if (NPC.IsMechQueenUp) - { - int num514 = NPC.FindFirstNPC(NPCID.Retinazer); - if (num514 >= 0) - Main.npc[num514].EncourageDespawn(5); - - num514 = NPC.FindFirstNPC(NPCID.Spazmatism); - if (num514 >= 0) - Main.npc[num514].EncourageDespawn(5); - - if (!NPC.AnyNPCs(NPCID.Retinazer) && !NPC.AnyNPCs(NPCID.Spazmatism)) + if (NPC.ai[2] == 1f) { - num514 = NPC.FindFirstNPC(NPCID.TheDestroyer); - if (num514 >= 0) - Main.npc[num514].Transform(NPCID.TheDestroyerTail); + Vector2 sawArmChargePos = NPC.Center; + float sawArmChargeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - sawArmChargePos.X; + float sawArmChargeTargetY = Main.npc[(int)NPC.ai[1]].position.Y + 230f - sawArmChargePos.Y; + NPC.rotation = (float)Math.Atan2(sawArmChargeTargetY, sawArmChargeTargetX) + MathHelper.PiOver2; - npc.EncourageDespawn(5); - } + float deceleration = death ? 0.875f : 0.9f; + NPC.velocity.X *= deceleration; + NPC.velocity.Y -= 0.5f; + if (NPC.velocity.Y < -12f) + NPC.velocity.Y = -12f; - npc.velocity.Y += 0.1f; - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.X *= 0.95f; - if (npc.velocity.Y > 13f) - npc.velocity.Y = 13f; - } - else - { - npc.EncourageDespawn(500); - npc.velocity.Y += 0.1f; - if (npc.velocity.Y < 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.X *= 0.95f; - } - } - - return false; - } - - public static bool VanillaPrimeLaserAI(NPC npc, Mod mod) - { - npc.spriteDirection = -(int)npc.ai[0]; - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) - { - npc.life = -1; - npc.HitEffect(); - npc.active = false; - } - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.damage = 0; - - if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f) - npc.EncourageDespawn(10); - - if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) - { - float num496 = 0.07f; - float num497 = 6f; - float num498 = 0.1f; - float num499 = 8f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.11f : 0.09f; - num497 = Main.masterMode ? 8f : 7f; - num498 = Main.masterMode ? 0.15f : 0.12f; - num499 = Main.masterMode ? 11f : 9.5f; - } - - npc.localAI[0] += 3f; - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; - } - } - else - { - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 600f : 800f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - float num496 = 0.1f; - float num497 = 3f; - float num498 = 0.14f; - float num499 = 8f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.14f : 0.12f; - num497 = Main.masterMode ? 5f : 4f; - num498 = Main.masterMode ? 0.2f : 0.17f; - num499 = Main.masterMode ? 11f : 9.5f; - } - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 180f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 180f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; - } - } - - Vector2 vector68 = npc.Center; - float num559 = Main.player[npc.target].Center.X - vector68.X; - float num560 = Main.player[npc.target].Center.Y - vector68.Y; - float num561 = (float)Math.Sqrt(num559 * num559 + num560 * num560); - npc.rotation = (float)Math.Atan2(num560, num559) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] > (Main.masterMode ? 80f : Main.expertMode ? 140f : 200f)) - { - npc.localAI[0] = 0f; - float num562 = 8f; - - int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y - 200f) { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); + float chargeVelocity = 22f; + if (!cannonAlive) + chargeVelocity += 1.5f; + if (!laserAlive) + chargeVelocity += 1.5f; + if (!viceAlive) + chargeVelocity += 1.5f; + + NPC.ai[2] = 2f; + sawArmChargePos = NPC.Center; + sawArmChargeTargetX = Main.player[NPC.target].Center.X - sawArmChargePos.X; + sawArmChargeTargetY = Main.player[NPC.target].Center.Y - sawArmChargePos.Y; + float sawArmChargeTargetDist = (float)Math.Sqrt(sawArmChargeTargetX * sawArmChargeTargetX + sawArmChargeTargetY * sawArmChargeTargetY); + sawArmChargeTargetDist = chargeVelocity / sawArmChargeTargetDist; + NPC.velocity.X = sawArmChargeTargetX * sawArmChargeTargetDist; + NPC.velocity.Y = sawArmChargeTargetY * sawArmChargeTargetDist; + NPC.netUpdate = true; } - - num561 = num562 / num561; - num559 *= num561; - num560 *= num561; - Vector2 laserVelocity = new Vector2(num559, num560); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector68 + laserVelocity.SafeNormalize(Vector2.UnitY) * 100f, laserVelocity, type, damage, 0f, Main.myPlayer); } - } - } - else - { - if (npc.ai[2] != 1f) - return false; - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 150f : Main.expertMode ? 175f : 200f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - Vector2 vector69 = npc.Center; - float num566 = Main.player[npc.target].Center.X - 350f - vector69.X; - float num567 = Main.player[npc.target].Center.Y - 20f - vector69.Y; - float num568 = (float)Math.Sqrt(num566 * num566 + num567 * num567); - num568 = (Main.masterMode ? 9f : Main.expertMode ? 8f : 7f) / num568; - num566 *= num568; - num567 *= num568; - - float num496 = 0.1f; - float num498 = 0.03f; - float deceleration = Main.masterMode ? 0.8f : Main.expertMode ? 0.85f : 0.9f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.14f : 0.12f; - num498 = Main.masterMode ? 0.05f : 0.04f; - } - - if (npc.velocity.X > num566) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num496; - } - - if (npc.velocity.X < num566) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num496; - } - - if (npc.velocity.Y > num567) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num498; - } - - if (npc.velocity.Y < num567) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num498; - } - - vector69 = npc.Center; - num566 = Main.player[npc.target].Center.X - vector69.X; - num567 = Main.player[npc.target].Center.Y - vector69.Y; - num568 = (float)Math.Sqrt(num566 * num566 + num567 * num567); - npc.rotation = (float)Math.Atan2(num567, num566) - MathHelper.PiOver2; - if (Main.netMode == NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] > (Main.masterMode ? 40f : Main.expertMode ? 60f : 80f)) + else if (NPC.ai[2] == 2f) { - npc.localAI[0] = 0f; - float num569 = 10f; - - int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); - } - - num568 = num569 / num568; - num566 *= num568; - num567 *= num568; - Vector2 laserVelocity = new Vector2(num566, num567); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector69 + laserVelocity.SafeNormalize(Vector2.UnitY) * 100f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - - return false; - } - - public static bool VanillaPrimeCannonAI(NPC npc, Mod mod) - { - npc.spriteDirection = -(int)npc.ai[0]; - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) - { - npc.life = -1; - npc.HitEffect(); - npc.active = false; - } - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - npc.damage = 0; - - if (npc.ai[2] == 0f) - { - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f) - npc.EncourageDespawn(10); - - if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) - { - float num496 = 0.07f; - float num497 = 6f; - float num498 = 0.1f; - float num499 = 8f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.11f : 0.09f; - num497 = Main.masterMode ? 8f : 7f; - num498 = Main.masterMode ? 0.15f : 0.12f; - num499 = Main.masterMode ? 11f : 9.5f; + if (NPC.position.Y > Main.player[NPC.target].position.Y || NPC.velocity.Y < 0f) + NPC.ai[2] = 3f; } - npc.localAI[0] += 2f; - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 100f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 120f * npc.ai[0]) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; - } - } - else - { - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 700f : Main.expertMode ? 900f : 1100f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - float num496 = 0.04f; - float num497 = 3f; - float num498 = 0.2f; - float num499 = 8f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.06f : 0.05f; - num497 = Main.masterMode ? 5f : 4f; - num498 = Main.masterMode ? 0.28f : 0.24f; - num499 = Main.masterMode ? 11f : 9.5f; - } - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 150f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 150f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 200f) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X + 160f) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; - } - } - - Vector2 vector66 = npc.Center; - float num545 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector66.X; - float num546 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector66.Y; - float num547 = (float)Math.Sqrt(num545 * num545 + num546 * num546); - npc.rotation = (float)Math.Atan2(num546, num545) + MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] > (Main.masterMode ? 60f : Main.expertMode ? 100f : 140f)) - { - npc.localAI[0] = 0f; - float num548 = 12f; - int num549 = 0; - int num550 = ProjectileID.BombSkeletronPrime; - num547 = num548 / num547; - num545 = (0f - num545) * num547; - num546 = (0f - num546) * num547; - vector66.X += num545 * 4f; - vector66.Y += num546 * 4f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector66.X, vector66.Y, num545, num546, num550, num549, 0f, Main.myPlayer); - } - } - } - else - { - if (npc.ai[2] != 1f) - return false; - - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 180f : Main.expertMode ? 240f : 300f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.localAI[0] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - Vector2 vector67 = npc.Center; - float num552 = Main.npc[(int)npc.ai[1]].Center.X - vector67.X; - float num553 = Main.npc[(int)npc.ai[1]].position.Y - vector67.Y; - num553 = Main.player[npc.target].Center.Y - 80f - vector67.Y; - float num554 = (float)Math.Sqrt(num552 * num552 + num553 * num553); - num554 = (Main.masterMode ? 8f : Main.expertMode ? 7f : 6f) / num554; - num552 *= num554; - num553 *= num554; - - float num496 = 0.04f; - float num498 = 0.08f; - float deceleration = Main.masterMode ? 0.8f : Main.expertMode ? 0.85f : 0.9f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.08f : 0.06f; - num498 = Main.masterMode ? 0.12f : 0.1f; - } - - if (npc.velocity.X > num552) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num496; - } - - if (npc.velocity.X < num552) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num496; - } - - if (npc.velocity.Y > num553) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num498; - } - - if (npc.velocity.Y < num553) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num498; - } - - vector67 = npc.Center; - num552 = Main.player[npc.target].Center.X - vector67.X; - num553 = Main.player[npc.target].Center.Y - vector67.Y; - num554 = (float)Math.Sqrt(num552 * num552 + num553 * num553); - npc.rotation = (float)Math.Atan2(num553, num552) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] > (Main.masterMode ? 20f : Main.expertMode ? 30f : 40f)) - { - npc.localAI[0] = 0f; - float num555 = 10f; - int num556 = 0; - int num557 = ProjectileID.BombSkeletronPrime; - num554 = num555 / num554; - num552 *= num554; - num553 *= num554; - vector67.X += num552 * 4f; - vector67.Y += num553 * 4f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector67.X, vector67.Y, num552, num553, num557, num556, 0f, Main.myPlayer); - } - } - } - - return false; - } - - public static bool VanillaPrimeViceAI(NPC npc, Mod mod) - { - npc.spriteDirection = -(int)npc.ai[0]; - Vector2 vector61 = npc.Center; - float num530 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector61.X; - float num531 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector61.Y; - float num532 = (float)Math.Sqrt(num530 * num530 + num531 * num531); - if (npc.ai[2] != 99f) - { - if (num532 > 800f) - npc.ai[2] = 99f; - } - else if (num532 < 400f) - npc.ai[2] = 0f; - - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) - { - npc.life = -1; - npc.HitEffect(); - npc.active = false; - } - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.ai[2] == 99f) - { - float num496 = 0.1f; - float num497 = 8f; - float num498 = 0.5f; - float num499 = 12f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.14f : 0.12f; - num497 = Main.masterMode ? 11f : 9.5f; - num498 = Main.masterMode ? 0.6f : 0.55f; - num499 = Main.masterMode ? 16f : 14f; - } - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; - } - } - else if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f) - npc.EncourageDespawn(10); - - if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) - { - if (Main.player[npc.target].dead) - { - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 16f) - npc.velocity.Y = 16f; - } else { - Vector2 vector62 = npc.Center; - float num533 = Main.player[npc.target].Center.X - vector62.X; - float num534 = Main.player[npc.target].Center.Y - vector62.Y; - float num535 = (float)Math.Sqrt(num533 * num533 + num534 * num534); - num535 = (Main.masterMode ? 16f : Main.expertMode ? 14f : 12f) / num535; - num533 *= num535; - num534 *= num535; - npc.rotation = (float)Math.Atan2(num534, num533) - MathHelper.PiOver2; - float deceleration = Main.masterMode ? 0.93f : Main.expertMode ? 0.95f : 0.97f; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < 2f) + if (NPC.ai[2] == 4f) { - npc.rotation = (float)Math.Atan2(num534, num533) - MathHelper.PiOver2; - npc.velocity.X = num533; - npc.velocity.Y = num534; - npc.netUpdate = true; - } - else - npc.velocity *= deceleration; + float chargeVelocity = 11f; + if (!cannonAlive) + chargeVelocity += 1.5f; + if (!laserAlive) + chargeVelocity += 1.5f; + if (!viceAlive) + chargeVelocity += 1.5f; + if (death) + chargeVelocity *= 1.25f; - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 500f : 600f)) - { - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - } - else - { - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 500f : 600f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } + Vector2 sawArmOtherChargePos = NPC.Center; + float sawArmOtherChargeTargetX = Main.player[NPC.target].Center.X - sawArmOtherChargePos.X; + float sawArmOtherChargeTargetY = Main.player[NPC.target].Center.Y - sawArmOtherChargePos.Y; + float sawArmOtherChargeTargetDist = (float)Math.Sqrt(sawArmOtherChargeTargetX * sawArmOtherChargeTargetX + sawArmOtherChargeTargetY * sawArmOtherChargeTargetY); + sawArmOtherChargeTargetDist = chargeVelocity / sawArmOtherChargeTargetDist; + sawArmOtherChargeTargetX *= sawArmOtherChargeTargetDist; + sawArmOtherChargeTargetY *= sawArmOtherChargeTargetDist; - float num496 = 0.1f; - float num497 = 3f; - float num498 = 0.2f; - float num499 = 8f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; + float acceleration = death ? 0.125f : 0.08f; + float deceleration = death ? 0.6f : 0.8f; - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.14f : 0.12f; - num497 = Main.masterMode ? 5f : 4f; - num498 = Main.masterMode ? 0.28f : 0.24f; - num499 = Main.masterMode ? 11f : 9.5f; - } + if (NPC.velocity.X > sawArmOtherChargeTargetX) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 300f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; + NPC.velocity.X -= acceleration; + } + if (NPC.velocity.X < sawArmOtherChargeTargetX) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y + 230f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; + NPC.velocity.X += acceleration; + } + if (NPC.velocity.Y > sawArmOtherChargeTargetY) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } + NPC.velocity.Y -= acceleration; + } + if (NPC.velocity.Y < sawArmOtherChargeTargetY) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 250f) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= (deceleration - 0.02f); + NPC.velocity.Y += acceleration; + } - npc.velocity.X -= (num498 * 1.5f); - if (npc.velocity.X > num499 + 1f) - npc.velocity.X = num499 + 1f; - } + NPC.ai[3] += 1f; + if (NPC.justHit) + NPC.ai[3] += 2f; - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= (deceleration - 0.02f); + if (NPC.ai[3] >= 600f) + { + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; - } - } - - Vector2 vector63 = npc.Center; - float num536 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector63.X; - float num537 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector63.Y; - float num538 = (float)Math.Sqrt(num536 * num536 + num537 * num537); - npc.rotation = (float)Math.Atan2(num537, num536) + MathHelper.PiOver2; - } - else if (npc.ai[2] == 1f) - { - float deceleration = Main.masterMode ? 0.8f : Main.expertMode ? 0.85f : 0.9f; - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - Vector2 vector64 = npc.Center; - float num539 = Main.npc[(int)npc.ai[1]].Center.X - 280f * npc.ai[0] - vector64.X; - float num540 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector64.Y; - float num541 = (float)Math.Sqrt(num539 * num539 + num540 * num540); - npc.rotation = (float)Math.Atan2(num540, num539) + MathHelper.PiOver2; - npc.velocity.X = (npc.velocity.X * 5f + Main.npc[(int)npc.ai[1]].velocity.X) / 6f; - npc.velocity.X += 0.5f; - npc.velocity.Y -= 0.5f; - if (npc.velocity.Y < -9f) - npc.velocity.Y = -9f; - - if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 280f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] = 2f; - vector64 = npc.Center; - num539 = Main.player[npc.target].Center.X - vector64.X; - num540 = Main.player[npc.target].Center.Y - vector64.Y; - num541 = (float)Math.Sqrt(num539 * num539 + num540 * num540); - num541 = (Main.masterMode ? 24f : Main.expertMode ? 22f : 20f) / num541; - npc.velocity.X = num539 * num541; - npc.velocity.Y = num540 * num541; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f) - { - float numCharges = Main.masterMode ? 2f : Main.expertMode ? 3f : 4f; - if (npc.ai[3] >= numCharges) - { - npc.ai[2] = 3f; - npc.ai[3] = 0f; - } - else - { - npc.ai[2] = 1f; - npc.ai[3] += 1f; - } - } - } - else if (npc.ai[2] == 4f) - { - Vector2 vector65 = npc.Center; - float num542 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector65.X; - float num543 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector65.Y; - float num544 = (float)Math.Sqrt(num542 * num542 + num543 * num543); - npc.rotation = (float)Math.Atan2(num543, num542) + MathHelper.PiOver2; - npc.velocity.Y = (npc.velocity.Y * 5f + Main.npc[(int)npc.ai[1]].velocity.Y) / 6f; - npc.velocity.X += 0.5f; - if (npc.velocity.X > 12f) - npc.velocity.X = 12f; - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 500f || npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X + 500f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] = 5f; - vector65 = npc.Center; - num542 = Main.player[npc.target].Center.X - vector65.X; - num543 = Main.player[npc.target].Center.Y - vector65.Y; - num544 = (float)Math.Sqrt(num542 * num542 + num543 * num543); - num544 = (Main.masterMode ? 20f : Main.expertMode ? 18.5f : 17f) / num544; - npc.velocity.X = num542 * num544; - npc.velocity.Y = num543 * num544; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 5f && npc.Center.X < Main.player[npc.target].Center.X - 100f) - { - // Set damage - npc.damage = npc.defDamage; - - float numCharges = Main.masterMode ? 2f : Main.expertMode ? 3f : 4f; - if (npc.ai[3] >= numCharges) - { - npc.ai[2] = 0f; - npc.ai[3] = 0f; - } - else - { - npc.ai[2] = 4f; - npc.ai[3] += 1f; - } - } - - return false; - } - - public static bool VanillaPrimeSawAI(NPC npc, Mod mod) - { - Vector2 vector56 = npc.Center; - float num515 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector56.X; - float num516 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector56.Y; - float num517 = (float)Math.Sqrt(num515 * num515 + num516 * num516); - if (npc.ai[2] != 99f) - { - if (num517 > 800f) - npc.ai[2] = 99f; - } - else if (num517 < 400f) - npc.ai[2] = 0f; - - npc.spriteDirection = -(int)npc.ai[0]; - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) - { - npc.ai[2] += 10f; - if (npc.ai[2] > 50f || !Main.dedServ) - { - npc.life = -1; - npc.HitEffect(); - npc.active = false; - } - } - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); - - // Min saw damage - int reducedSetDamage = (int)Math.Round(npc.defDamage * 0.5); - - // Avoid cheap bullshit - npc.damage = reducedSetDamage; - - if (npc.ai[2] == 99f) - { - float num496 = 0.1f; - float num497 = 8f; - float num498 = 0.5f; - float num499 = 12f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.14f : 0.12f; - num497 = Main.masterMode ? 11f : 9.5f; - num498 = Main.masterMode ? 0.6f : 0.55f; - num499 = Main.masterMode ? 16f : 14f; - } - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; - } - } - else if (npc.ai[2] == 0f || npc.ai[2] == 3f) - { - if (Main.npc[(int)npc.ai[1]].ai[1] == 3f) - npc.EncourageDespawn(10); - - if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) - { - if (Main.player[npc.target].dead) - { - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 16f) - npc.velocity.Y = 16f; - } - else - { - Vector2 vector57 = npc.Center; - float num518 = Main.player[npc.target].Center.X - vector57.X; - float num519 = Main.player[npc.target].Center.Y - vector57.Y; - float num520 = (float)Math.Sqrt(num518 * num518 + num519 * num519); - num520 = (Main.masterMode ? 9f : Main.expertMode ? 8f : 7f) / num520; - num518 *= num520; - num519 *= num520; - npc.rotation = (float)Math.Atan2(num519, num518) - MathHelper.PiOver2; - - float deceleration = Main.masterMode ? 0.93f : Main.expertMode ? 0.95f : 0.97f; - float acceleration = Main.masterMode ? 0.07f : Main.expertMode ? 0.06f : 0.05f; - if (npc.velocity.X > num518) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= acceleration; + sawArmOtherChargePos = NPC.Center; + sawArmOtherChargeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - 200f * NPC.ai[0] - sawArmOtherChargePos.X; + sawArmOtherChargeTargetY = Main.npc[(int)NPC.ai[1]].position.Y + 230f - sawArmOtherChargePos.Y; + NPC.rotation = (float)Math.Atan2(sawArmOtherChargeTargetY, sawArmOtherChargeTargetX) + MathHelper.PiOver2; + return false; } - if (npc.velocity.X < num518) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += acceleration; - } - - if (npc.velocity.Y > num519) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= acceleration; - } - - if (npc.velocity.Y < num519) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += acceleration; - } - } - - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 500f : 600f)) - { - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - else - { - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 180f : Main.expertMode ? 240f : 300f)) - { - npc.target = Main.npc[(int)npc.ai[1]].target; - npc.ai[2] += 1f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - float num496 = 0.04f; - float num497 = 3f; - float num498 = 0.3f; - float num499 = 12f; - float deceleration = Main.masterMode ? 0.92f : Main.expertMode ? 0.94f : 0.96f; - - if (Main.expertMode) - { - num496 = Main.masterMode ? 0.06f : 0.05f; - num497 = Main.masterMode ? 5f : 4f; - num498 = Main.masterMode ? 0.4f : 0.35f; - num499 = Main.masterMode ? 16f : 14f; - } - - if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 320f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= num496; - if (npc.velocity.Y > num497) - npc.velocity.Y = num497; - } - else if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y + 260f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += num496; - if (npc.velocity.Y < -num497) - npc.velocity.Y = -num497; - } - - if (npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= num498; - if (npc.velocity.X > num499) - npc.velocity.X = num499; - } - - if (npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X - 250f) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += num498; - if (npc.velocity.X < -num499) - npc.velocity.X = -num499; + if (NPC.ai[2] == 5f && ((NPC.velocity.X > 0f && NPC.Center.X > Main.player[NPC.target].Center.X) || (NPC.velocity.X < 0f && NPC.Center.X < Main.player[NPC.target].Center.X))) + NPC.ai[2] = 0f; } } - Vector2 vector58 = npc.Center; - float num521 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector58.X; - float num522 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector58.Y; - float num523 = (float)Math.Sqrt(num521 * num521 + num522 * num522); - npc.rotation = (float)Math.Atan2(num522, num521) + MathHelper.PiOver2; + return false; } - else if (npc.ai[2] == 1f) - { - Vector2 vector59 = npc.Center; - float num524 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector59.X; - float num525 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector59.Y; - float num526 = (float)Math.Sqrt(num524 * num524 + num525 * num525); - npc.rotation = (float)Math.Atan2(num525, num524) + MathHelper.PiOver2; - - float deceleration = Main.masterMode ? 0.85f : Main.expertMode ? 0.9f : 0.95f; - npc.velocity.X *= deceleration; - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -8f) - npc.velocity.Y = -8f; - - if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] = 2f; - vector59 = npc.Center; - num524 = Main.player[npc.target].Center.X - vector59.X; - num525 = Main.player[npc.target].Center.Y - vector59.Y; - num526 = (float)Math.Sqrt(num524 * num524 + num525 * num525); - num526 = (Main.masterMode ? 26f : Main.expertMode ? 24f : 22f) / num526; - npc.velocity.X = num524 * num526; - npc.velocity.Y = num525 * num526; - npc.netUpdate = true; - } - } - else if (npc.ai[2] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f) - npc.ai[2] = 3f; - } - else if (npc.ai[2] == 4f) - { - // Set damage - npc.damage = npc.defDamage; - - Vector2 vector60 = npc.Center; - float num527 = Main.player[npc.target].Center.X - vector60.X; - float num528 = Main.player[npc.target].Center.Y - vector60.Y; - float num529 = (float)Math.Sqrt(num527 * num527 + num528 * num528); - num529 = (Main.masterMode ? 9f : Main.expertMode ? 8f : 7f) / num529; - num527 *= num529; - num528 *= num529; - - float deceleration = Main.masterMode ? 0.93f : Main.expertMode ? 0.95f : 0.97f; - float acceleration = Main.masterMode ? 0.07f : Main.expertMode ? 0.06f : 0.05f; - - if (npc.velocity.X > num527) - { - if (npc.velocity.X > 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X -= acceleration; - } - - if (npc.velocity.X < num527) - { - if (npc.velocity.X < 0f) - npc.velocity.X *= deceleration; - - npc.velocity.X += acceleration; - } - - if (npc.velocity.Y > num528) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y -= acceleration; - } - - if (npc.velocity.Y < num528) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y *= deceleration; - - npc.velocity.Y += acceleration; - } - - npc.ai[3] += 1f; - if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 500f : 600f)) - { - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - vector60 = npc.Center; - num527 = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - vector60.X; - num528 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector60.Y; - num529 = (float)Math.Sqrt(num527 * num527 + num528 * num528); - npc.rotation = (float)Math.Atan2(num528, num527) + MathHelper.PiOver2; - } - else if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X < 0f && npc.Center.X < Main.player[npc.target].Center.X))) - npc.ai[2] = 0f; - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs index 9f3d027fee..f30880b7a5 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Events; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -13,548 +12,140 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { public static class TwinsAI { - public static bool BuffedRetinazerAI(NPC npc, Mod mod) + // Vanilla values + public static float RapidFireDamageMult = 0.75f; // 80 (buffed) + public static float RetinazerPhase2ContactDamageMult = 1.5f; // 114 + public static float SpazmatismPhase2ContactDamageMult = 1.5f; // 127 + public static int FlamethrowerDamage = 27; // 108; Applies to both flamethrower types + public static int FireballDamage = 22; // 88; Applies to both fireball types + + // Rev+ exclusive + public static int LaserDamage = 21; // 84 (buffed) + public static int RedLaserDamage = 27; // 108 (buffed) + public static int HomingDartDamage = 27; // 108 + + public static int CalculateMechDamage(this int damage) { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - 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) + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); + 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); } + return damage; + } - float enrageScale = bossRush ? 0.5f : death ? 0.3f : 0f; - if (Main.IsItDay() || bossRush) + public class RetinazerAI : VanillaAIOverride + { + public override bool AI(Mod mod) { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Easier to send info to Spazmatism - CalamityGlobalNPC.laserEye = npc.whoAmI; - - // Check for Spazmatism - bool spazAlive = false; - if (CalamityGlobalNPC.fireEye != -1) - spazAlive = Main.npc[CalamityGlobalNPC.fireEye].active; - - // I'm not commenting this entire fucking thing, already did spaz, I'm not doing ret - Vector2 hoverDestination = new Vector2(npc.Center.X - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2), npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2)); - int direction = (npc.Center.X < Main.player[npc.target].position.X + Main.player[npc.target].width) ? -1 : 1; - - float hoverRotation = hoverDestination.ToRotation() + MathHelper.PiOver2; - if (hoverRotation < 0f) - hoverRotation += MathHelper.TwoPi; - else if (hoverRotation > MathHelper.TwoPi) - hoverRotation -= MathHelper.TwoPi; - - float rotationRate = 0.15f; - npc.rotation = npc.rotation.AngleTowards(hoverRotation, rotationRate); - - if (Main.rand.NextBool(5)) - { - int retiDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), DustID.Blood, npc.velocity.X, 2f, 0, default, 1f); - Dust dust = Main.dust[retiDust]; - dust.velocity.X *= 0.5f; - dust.velocity.Y *= 0.1f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[npc.target].dead && npc.timeLeft < 10) - { - for (int i = 0; i < Main.maxNPCs; i++) + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) { - if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism || Main.npc[i].type == ModContent.NPCType()) && Main.npc[i].timeLeft - 1 > npc.timeLeft) - npc.timeLeft = Main.npc[i].timeLeft - 1; - } - } - - // Check for Oblivion in Master Mode - bool oblivionAlive = false; - if (death && !bossRush && npc.localAI[3] == 1f) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == NPCID.SkeletronPrime)) - { - oblivionAlive = true; - break; - } - } - } - - // Foveanator spawn - if (!oblivionAlive && death && calamityGlobalNPC.newAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient && !bossRush) - { - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - calamityGlobalNPC.newAI[0] = 1f; - npc.SyncExtraAI(); - } - - bool foveanatorAlive = NPC.AnyNPCs(ModContent.NPCType()); - - // Phase HP ratios - float phase2LifeRatio = oblivionAlive ? 0.5f : death ? 0.85f : 0.7f; - float finalPhaseLifeRatio = death ? 0.4f : 0.25f; - - // Movement variables - float phase1MaxSpeedIncrease = death ? 2f : 4f; - float phase1MaxAccelerationIncrease = death ? 0.025f : 0.05f; - float phase1MaxChargeSpeedIncrease = death ? 3f : 6f; - - // Phase duration variables - float phase1MaxLaserPhaseDurationDecrease = death ? 120f : 300f; - - // If Oblivion is alive reduce aggression of all attacks - if (oblivionAlive) - { - phase1MaxSpeedIncrease = death ? 1f : 2f; - phase1MaxAccelerationIncrease = death ? 0.0125f : 0.025f; - phase1MaxChargeSpeedIncrease = death ? 1.5f : 3f; - - phase1MaxLaserPhaseDurationDecrease = death ? 60f : 150f; - } - - // Phase checks - bool phase2 = lifeRatio < phase2LifeRatio; - bool finalPhase = lifeRatio < finalPhaseLifeRatio; - - Vector2 mechQueenSpacing = Vector2.Zero; - if (NPC.IsMechQueenUp) - { - NPC nPC = Main.npc[NPC.mechQueen]; - Vector2 mechQueenCenter = nPC.GetMechQueenCenter(); - Vector2 eyePosition = new Vector2(-150f, -250f); - eyePosition *= 0.75f; - float mechdusaRotation = nPC.velocity.X * 0.025f; - mechQueenSpacing = mechQueenCenter + eyePosition; - mechQueenSpacing = mechQueenSpacing.RotatedBy(mechdusaRotation, mechQueenCenter); - } - - npc.reflectsProjectiles = false; - - // Despawn - bool oblivionFightDespawn = ((oblivionAlive && lifeRatio < 0.8f) || (oblivionAlive && !spazAlive && lifeRatio < 0.95f)) && npc.localAI[3] == 1f; - if (Main.player[npc.target].dead || oblivionFightDespawn) - { - npc.velocity.Y -= 0.04f; - if (npc.timeLeft > 10) - { - npc.timeLeft = 10; - return false; - } - } - - else if (npc.ai[0] == 0f) - { - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float maxVelocity = 8.25f; - float acceleration = 0.115f; - maxVelocity += 4f * enrageScale; - acceleration += 0.05f * enrageScale; - - if (death) - { - maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - acceleration += phase1MaxAccelerationIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - } - - if (Main.getGoodWorld) - { - maxVelocity *= 1.15f; - acceleration *= 1.15f; - } - - float distanceFromTarget = 300f; - Vector2 destination = Main.player[npc.target].Center + Vector2.UnitX * distanceFromTarget * direction - Vector2.UnitY * distanceFromTarget; - float distanceFromDestination = (destination - npc.Center).Length(); - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction); - - if (NPC.IsMechQueenUp) - { - maxVelocity = 14f; - - destination = mechQueenSpacing; - distanceFromDestination = (destination - npc.Center).Length(); - idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitY); - - if (distanceFromDestination > maxVelocity) - idealVelocity *= maxVelocity / distanceFromDestination; - - float inertia = 60f; - npc.velocity = (npc.velocity * (inertia - 1f) + idealVelocity) / inertia; - } - else - npc.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - - float phaseGateValue = death ? (300f - phase1MaxLaserPhaseDurationDecrease * ((1f - lifeRatio) / (1f - phase2LifeRatio))) : 450f; - float laserGateValue = oblivionAlive ? 60f : foveanatorAlive ? 45f : 30f; - if (NPC.IsMechQueenUp) - { - phaseGateValue = 900f; - laserGateValue = ((!NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody]) ? 60f : 90f); - } - - npc.ai[2] += 1f; - if (npc.ai[2] >= phaseGateValue) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } - else if (distanceFromDestination < (death ? 960f : 800f)) - { - if (!Main.player[npc.target].dead) - { - npc.ai[3] += 1f; - if (Main.getGoodWorld) - npc.ai[3] += 0.5f; - } - - if (npc.ai[3] >= laserGateValue) - { - npc.ai[3] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float laserSpeed = 10.5f; - laserSpeed += 3f * enrageScale; - - int type = ProjectileID.EyeLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 laserVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 90f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - - else if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.rotation = hoverRotation; - - float chargeSpeed = 15f; - chargeSpeed += 10f * enrageScale; - if (death) - chargeSpeed += phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - if (Main.getGoodWorld) - chargeSpeed += 2f; - - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; - - npc.ai[1] = 2f; - } - else if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f; - float decelerateGateValue = (death ? 36f : 32f) + (death ? 6f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - if (npc.ai[2] >= decelerateGateValue) - { - // Avoid cheap bullshit - npc.damage = 0; - - float decelerationMultiplier = (death ? 0.84f : 0.92f) - (death ? 0.16f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - npc.velocity *= decelerationMultiplier; - - if (Math.Abs(npc.velocity.X) < 0.1) - npc.velocity.X = 0f; - if (Math.Abs(npc.velocity.Y) < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - - float delayBeforeChargingAgain = (death ? 48f : 56f) - (death ? 3f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - if (npc.ai[2] >= delayBeforeChargingAgain + (oblivionAlive ? 15f : 0f)) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - - npc.rotation = hoverRotation; - - float totalCharges = death ? 6f : 5f; - if (foveanatorAlive) - totalCharges -= 1f; - - if (npc.ai[3] >= totalCharges) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - } - else - npc.ai[1] = 1f; - } - } - - // Enter phase 2 - if (phase2) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } - } - - else if (npc.ai[0] == 1f || npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (NPC.IsMechQueenUp) - npc.reflectsProjectiles = true; - - if (npc.ai[0] == 1f) - { - npc.ai[2] += 0.005f; - if (npc.ai[2] > 0.5) - npc.ai[2] = 0.5f; - } - else - { - npc.ai[2] -= 0.005f; - if (npc.ai[2] < 0f) - npc.ai[2] = 0f; + CalamityUtils.CalamityTargeting(NPC, options); } - npc.rotation += npc.ai[2]; + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; - npc.ai[1] += 1f; - if (death && npc.ai[2] >= 0.2f) - { - if (npc.ai[1] % 10f == 0f) - { - SoundEngine.PlaySound(SoundID.Item33, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - bool shootLaser = npc.ai[1] % 20f == 0f; - int type = shootLaser ? ProjectileID.DeathLaser : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + // Easier to send info to Spazmatism + CalamityGlobalNPC.laserEye = NPC.whoAmI; - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * (oblivionAlive ? 6f : 7f); - int numProj = shootLaser ? 6 : 2; - int spread = shootLaser ? 20 : 80; - float rotation = MathHelper.ToRadians(spread); - float offset = shootLaser ? 90f : 50f; - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * offset, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } - } - } - } - - if (npc.ai[1] == 100f) - { - npc.ai[0] += 1f; - npc.ai[1] = 0f; - if (npc.ai[0] == 3f) - { - npc.ai[2] = 0f; - } - else - { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); - - if (!Main.dedServ) - { - for (int i = 0; i < 2; i++) - { - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 143, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); - } - } - - for (int j = 0; j < 20; j++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - } - - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - - npc.velocity *= 0.98f; - if (Math.Abs(npc.velocity.X) < 0.1) - npc.velocity.X = 0f; - if (Math.Abs(npc.velocity.Y) < 0.1) - npc.velocity.Y = 0f; - } - else - { - // If in phase 2 but Spaz isn't - bool spazInPhase1 = false; + // Check for Spazmatism + bool spazAlive = false; if (CalamityGlobalNPC.fireEye != -1) + spazAlive = Main.npc[CalamityGlobalNPC.fireEye].active; + + // I'm not commenting this entire fucking thing, already did spaz, I'm not doing ret + Vector2 hoverDestination = new Vector2(NPC.Center.X - Main.player[NPC.target].position.X - (Main.player[NPC.target].width / 2), NPC.position.Y + NPC.height - 59f - Main.player[NPC.target].position.Y - (Main.player[NPC.target].height / 2)); + int direction = (NPC.Center.X < Main.player[NPC.target].position.X + Main.player[NPC.target].width) ? -1 : 1; + + float hoverRotation = hoverDestination.ToRotation() + MathHelper.PiOver2; + if (hoverRotation < 0f) + hoverRotation += MathHelper.TwoPi; + else if (hoverRotation > MathHelper.TwoPi) + hoverRotation -= MathHelper.TwoPi; + + float rotationRate = 0.15f; + NPC.rotation = NPC.rotation.AngleTowards(hoverRotation, rotationRate); + + if (Main.rand.NextBool(5)) { - if (Main.npc[CalamityGlobalNPC.fireEye].active) - spazInPhase1 = Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 0f; + int retiDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f), NPC.width, (int)(NPC.height * 0.5f), DustID.Blood, NPC.velocity.X, 2f, 0, default, 1f); + Dust dust = Main.dust[retiDust]; + dust.velocity.X *= 0.5f; + dust.velocity.Y *= 0.1f; } - npc.chaseable = !spazInPhase1; - - int setDamage = (int)Math.Round(npc.defDamage * 1.5); - npc.defense = npc.defDefense + 10; - calamityGlobalNPC.DR = spazInPhase1 ? 0.9999f : 0.2f; - calamityGlobalNPC.unbreakableDR = spazInPhase1; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = spazInPhase1; - - npc.HitSound = SoundID.NPCHit4; - - if (npc.ai[1] == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[NPC.target].dead && NPC.timeLeft < 10) { - // Avoid cheap bullshit - npc.damage = 0; - - float maxVelocity = 9.5f + (death ? 3f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float acceleration = 0.175f + (death ? 0.05f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - maxVelocity += 4.5f * enrageScale; - acceleration += 0.075f * enrageScale; - - if (Main.getGoodWorld) + for (int i = 0; i < Main.maxNPCs; i++) { - maxVelocity *= 1.15f; - acceleration *= 1.15f; + if (i != NPC.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism) && Main.npc[i].timeLeft - 1 > NPC.timeLeft) + NPC.timeLeft = Main.npc[i].timeLeft - 1; } + } - float distanceFromTarget = oblivionAlive ? 480f : 420f; - Vector2 destination = Main.player[npc.target].Center - Vector2.UnitY * distanceFromTarget; - float distanceFromDestination = (destination - npc.Center).Length(); - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction); + // Phase HP ratios + float phase2LifeRatio = death ? 0.85f : 0.7f; + float finalPhaseLifeRatio = death ? 0.4f : 0.25f; - if (NPC.IsMechQueenUp) + // Movement variables + float phase1MaxSpeedIncrease = 1f; + float phase1MaxChargeSpeedIncrease = 1.5f; + + // Phase duration variables + float phase1MaxLaserPhaseDurationDecrease = death ? 120f : 300f; + + // Phase checks + bool phase2 = lifeRatio < phase2LifeRatio; + bool finalPhase = lifeRatio < finalPhaseLifeRatio; + + Vector2 mechQueenSpacing = Vector2.Zero; + if (NPC.IsMechQueenUp) + { + NPC nPC = Main.npc[NPC.mechQueen]; + Vector2 mechQueenCenter = nPC.GetMechQueenCenter(); + Vector2 eyePosition = new Vector2(-150f, -250f); + eyePosition *= 0.75f; + float mechdusaRotation = nPC.velocity.X * 0.025f; + mechQueenSpacing = mechQueenCenter + eyePosition; + mechQueenSpacing = mechQueenSpacing.RotatedBy(mechdusaRotation, mechQueenCenter); + } + + NPC.reflectsProjectiles = false; + + // Despawn + if ((Main.player[NPC.target].dead || Main.IsItDay()) && !BossRushEvent.BossRushActive) + { + NPC.velocity.Y -= 0.04f; + if (NPC.timeLeft > 10) { - maxVelocity = 14f; - - destination = mechQueenSpacing; - distanceFromDestination = (destination - npc.Center).Length(); - idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitY); - - if (distanceFromDestination > maxVelocity) - idealVelocity *= maxVelocity / distanceFromDestination; - - float inertia = 5f; - npc.velocity = (npc.velocity * (inertia - 1f) + idealVelocity) / inertia; + NPC.timeLeft = 10; + return false; } - else - npc.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); + } - npc.ai[2] += spazAlive ? 1f : 1.5f; - float phaseGateValue = NPC.IsMechQueenUp ? 900f : 300f - (death ? 120f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - if (npc.ai[2] >= phaseGateValue) + else if (NPC.ai[0] == 0f) + { + if (NPC.ai[1] == 0f) { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); + float maxVelocity = death ? 9.25f : 8.25f; + float acceleration = death ? 0.13f : 0.115f; - npc.netUpdate = true; - } - - npc.rotation = (Main.player[npc.target].Center - npc.Center).ToRotation() - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f + (death ? (phase2LifeRatio - lifeRatio) / phase2LifeRatio : 0f); - if (npc.localAI[1] >= (spazAlive ? (oblivionAlive ? 76f : foveanatorAlive ? 64f : 52f) : foveanatorAlive ? 39f : 26f)) + if (death) { - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.localAI[1] = 0f; - - float laserSpeed = 10f; - laserSpeed += enrageScale; - int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 laserVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); - } + maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); } - } - } - else - { - if (npc.ai[1] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float maxVelocity = 9.5f + (death ? 3f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float acceleration = 0.25f + (death ? 0.075f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - maxVelocity += 4.5f * enrageScale; - acceleration += 0.15f * enrageScale; if (Main.getGoodWorld) { @@ -562,679 +153,244 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses acceleration *= 1.15f; } - float distanceFromTarget = oblivionAlive ? 480f : 420f; - Vector2 destination = Main.player[npc.target].Center + Vector2.UnitX * distanceFromTarget * direction; - float distanceFromDestination = (destination - npc.Center).Length(); - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction); - npc.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); + float distanceFromTarget = 300f; + Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * distanceFromTarget * direction - Vector2.UnitY * distanceFromTarget; + float distanceFromDestination = (destination - NPC.Center).Length(); + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); - npc.rotation = (Main.player[npc.target].Center - npc.Center).ToRotation() - MathHelper.PiOver2; - - if (Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.IsMechQueenUp) { - npc.localAI[1] += 1f + (death ? (phase2LifeRatio - lifeRatio) / phase2LifeRatio : 0f); - if (npc.localAI[1] > (spazAlive ? (oblivionAlive ? 30f : foveanatorAlive ? 25f : 20f) : foveanatorAlive ? 15f : 10f)) + maxVelocity = 14f; + + destination = mechQueenSpacing; + distanceFromDestination = (destination - NPC.Center).Length(); + idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitY); + + if (distanceFromDestination > maxVelocity) + idealVelocity *= maxVelocity / distanceFromDestination; + + float inertia = 60f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + idealVelocity) / inertia; + } + else + NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); + + float phaseGateValue = death ? (300f - phase1MaxLaserPhaseDurationDecrease * ((1f - lifeRatio) / (1f - phase2LifeRatio))) : 450f; + float laserGateValue = 30f; + if (NPC.IsMechQueenUp) + { + phaseGateValue = 900f; + laserGateValue = ((!NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody]) ? 60f : 90f); + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= phaseGateValue) + { + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + CalamityUtils.CalamityTargeting(NPC, options); + + NPC.netUpdate = true; + } + else if (distanceFromDestination < (death ? 960f : 800f)) + { + if (!Main.player[NPC.target].dead) { - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + NPC.ai[3] += 1f; + if (Main.getGoodWorld) + NPC.ai[3] += 0.5f; + } + + if (NPC.ai[3] >= laserGateValue) + { + NPC.ai[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[1] = 0f; + float laserSpeed = death ? 11.25f : 10.5f; - float laserSpeed = 9f; - laserSpeed += enrageScale; - int type = ProjectileID.DeathLaser; - int damage = (int)Math.Round(npc.GetProjectileDamage(type) * 0.75); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 laserVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); + int type = ProjectileID.EyeLaser; + int damage = LaserDamage.CalculateMechDamage(); + Vector2 laserVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 90f, laserVelocity, type, damage, 0f, Main.myPlayer); } } } - - npc.ai[2] += spazAlive ? 1f : 1.5f; - if (npc.ai[2] >= (death ? 150f : 180f) - (death ? 60f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) - { - npc.ai[1] = finalPhase ? 4f : 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } } - // Charge - else if (npc.ai[1] == 2f) + else if (NPC.ai[1] == 1f) { - // Set damage - npc.damage = setDamage; + NPC.rotation = hoverRotation; - // Set rotation and velocity - npc.rotation = hoverRotation; - - float chargeSpeed = 22f + (death ? 8f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - chargeSpeed += 10f * enrageScale; - if (!spazAlive) - chargeSpeed += 2f; + float chargeSpeed = death ? 17.5f : 15f; + if (death) + chargeSpeed += phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); if (Main.getGoodWorld) chargeSpeed += 2f; - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * chargeSpeed; + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; - npc.ai[1] = 3f; + NPC.ai[1] = 2f; } - - else if (npc.ai[1] == 3f) + else if (NPC.ai[1] == 2f) { - // Set damage - npc.damage = setDamage; - - npc.ai[2] += 1f; - - float chargeTime = spazAlive ? 45f : 30f; - if (npc.ai[3] % 3f == 0f) - chargeTime = spazAlive ? 90f : 60f; - if (death) - chargeTime -= chargeTime * 0.25f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio); - chargeTime -= chargeTime / 5 * enrageScale; - - // Slow down - if (npc.ai[2] >= chargeTime) + NPC.ai[2] += 1f; + float decelerateGateValue = (death ? 36f : 32f) + (death ? 4f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); + if (NPC.ai[2] >= decelerateGateValue) { - // Avoid cheap bullshit - npc.damage = 0; + float decelerationMultiplier = (death ? 0.84f : 0.92f) - (death ? 0.16f * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); + NPC.velocity *= decelerationMultiplier; - npc.velocity *= 0.93f; - - if (Math.Abs(npc.velocity.X) < 0.1) - npc.velocity.X = 0f; - if (Math.Abs(npc.velocity.Y) < 0.1) - npc.velocity.Y = 0f; + if (Math.Abs(NPC.velocity.X) < 0.1) + NPC.velocity.X = 0f; + if (Math.Abs(NPC.velocity.Y) < 0.1) + NPC.velocity.Y = 0f; } else + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; + + float delayBeforeChargingAgain = death ? 48f : 56f; + if (NPC.ai[2] >= delayBeforeChargingAgain) { - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; - if (npc.ai[3] % 3f == 0f) + NPC.rotation = hoverRotation; + + float totalCharges = death ? 6f : 5f; + + if (NPC.ai[3] >= totalCharges) { - float fireRate = spazAlive ? 13f : foveanatorAlive ? 11f : 9f; - if (npc.ai[2] % fireRate == 0f) - { - SoundEngine.PlaySound(SoundID.Item33, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float laserDartSpeed = (death ? 9f : 6f) * (spazAlive ? 1f : 1.5f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 laserDartVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserDartSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + npc.velocity.SafeNormalize(Vector2.UnitY) * 60f, laserDartVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - - // Charge four times - float chargeGateValue = 30f; - chargeGateValue -= chargeGateValue / 4 * enrageScale; - if (npc.ai[2] >= chargeTime + chargeGateValue) - { - npc.ai[2] = 0f; - - float chargeIncrement = 1f; - if (death && Main.rand.NextBool() && npc.ai[3] < (spazAlive ? 1f : 3f)) - { - chargeIncrement = 2f; - - // Net update due to the randomness in Master Mode - npc.netUpdate = true; - } - - npc.rotation = hoverRotation; - - npc.ai[3] += chargeIncrement; - float maxChargeAmt = spazAlive ? 2f : 4f; - if (npc.ai[3] >= maxChargeAmt) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); + CalamityUtils.CalamityTargeting(NPC, options); } else - npc.ai[1] = 4f; + NPC.ai[1] = 1f; } } - // Get in position for charge - else if (npc.ai[1] == 4f) + // Enter phase 2 + if (phase2) { - // Avoid cheap bullshit - npc.damage = 0; + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; - float chargeLineUpDistance = spazAlive ? 600f : 500f; - float chargeSpeed = 18f + (death ? 6f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float chargeAcceleration = 0.45f + (death ? 0.15f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - chargeSpeed += 6f * enrageScale; - chargeAcceleration += 0.15f * enrageScale; + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + CalamityUtils.CalamityTargeting(NPC, options); - if (spazAlive) - { - chargeSpeed *= 0.75f; - chargeAcceleration *= 0.75f; - } - - if (Main.getGoodWorld) - { - chargeSpeed *= 1.15f; - chargeAcceleration *= 1.15f; - } - - Vector2 destination = Main.player[npc.target].Center + Vector2.UnitX * chargeLineUpDistance * direction; - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; - npc.SimpleFlyMovement(idealVelocity, chargeAcceleration); - - // Take 1.25 or 1 second to get in position, then charge - npc.ai[2] += 1f; - if (npc.ai[2] >= (spazAlive ? 75f : 60f) - (death ? 20f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) - { - npc.ai[1] = 2f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } + NPC.netUpdate = true; } } - } - return false; - } - - public static bool BuffedSpazmatismAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - 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) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - } - - float enrageScale = bossRush ? 0.5f : death ? 0.3f : 0f; - if (Main.IsItDay() || bossRush) - { - npc.Calamity().CurrentlyEnraged = !bossRush; - enrageScale += 1f; - } - - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; - - // Easier to send info to Retinazer - CalamityGlobalNPC.fireEye = npc.whoAmI; - - // Check for Retinazer - bool retAlive = false; - if (CalamityGlobalNPC.laserEye != -1) - retAlive = Main.npc[CalamityGlobalNPC.laserEye].active; - - // Rotation - Vector2 hoverDestination = new Vector2(npc.Center.X - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2), npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2)); - int direction = (npc.Center.X < Main.player[npc.target].position.X + Main.player[npc.target].width) ? -1 : 1; - - float hoverRotation = hoverDestination.ToRotation() + MathHelper.PiOver2; - if (hoverRotation < 0f) - hoverRotation += MathHelper.TwoPi; - else if (hoverRotation > MathHelper.TwoPi) - hoverRotation -= MathHelper.TwoPi; - - float rotationRate = 0.15f; - if (NPC.IsMechQueenUp && npc.ai[0] == 3f && npc.ai[1] == 0f) - rotationRate *= 0.25f; - - npc.rotation = npc.rotation.AngleTowards(hoverRotation, rotationRate); - - // Dust - if (Main.rand.NextBool(5)) - { - int spazDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f), npc.width, (int)(npc.height * 0.5f), DustID.Blood, npc.velocity.X, 2f, 0, default, 1f); - Dust dust = Main.dust[spazDust]; - dust.velocity.X *= 0.5f; - dust.velocity.Y *= 0.1f; - } - - // Despawn Twins at the same time - if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[npc.target].dead && npc.timeLeft < 10) - { - for (int i = 0; i < Main.maxNPCs; i++) + else if (NPC.ai[0] == 1f || NPC.ai[0] == 2f) { - if (i != npc.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism || Main.npc[i].type == ModContent.NPCType()) && Main.npc[i].timeLeft - 1 > npc.timeLeft) - npc.timeLeft = Main.npc[i].timeLeft - 1; - } - } - - // Check for Oblivion in Master Mode - bool oblivionAlive = false; - if (death && !bossRush && npc.localAI[3] == 1f) - { - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && (Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == NPCID.SkeletronPrime)) - { - oblivionAlive = true; - break; - } - } - } - - bool foveanatorAlive = NPC.AnyNPCs(ModContent.NPCType()); - - // Phase HP ratios - float phase2LifeRatio = oblivionAlive ? 0.5f : death ? 0.85f : 0.7f; - float finalPhaseLifeRatio = death ? 0.3f : 0.15f; - - // Movement variables - float phase1MaxSpeedIncrease = death ? 2.25f : 4.5f; - float phase1MaxAccelerationIncrease = death ? 0.075f : 0.15f; - float phase1MaxChargeSpeedIncrease = death ? 3f : 6f; - - // Phase duration variables - float phase1MaxCursedFlamePhaseDurationDecrease = death ? 80f : 200f; - float phase1MaxChargesDecrease = death ? 2f : 4f; - - // If Oblivion is alive reduce aggression of all attacks - if (oblivionAlive) - { - phase1MaxSpeedIncrease = death ? 1.125f : 2.25f; - phase1MaxAccelerationIncrease = death ? 0.0375f : 0.075f; - phase1MaxChargeSpeedIncrease = death ? 1.5f : 3f; - - phase1MaxCursedFlamePhaseDurationDecrease = death ? 40f : 100f; - phase1MaxChargesDecrease = death ? 1f : 2f; - } - - // Phase checks - bool phase2 = lifeRatio < phase2LifeRatio; - bool finalPhase = lifeRatio < finalPhaseLifeRatio; - - Vector2 mechQueenSpacing = Vector2.Zero; - if (NPC.IsMechQueenUp) - { - NPC nPC2 = Main.npc[NPC.mechQueen]; - Vector2 mechQueenCenter2 = nPC2.GetMechQueenCenter(); - Vector2 mechdusaSpacingVector = new Vector2(150f, -250f); - mechdusaSpacingVector *= 0.75f; - float mechdusaSpacingVel = nPC2.velocity.X * 0.025f; - mechQueenSpacing = mechQueenCenter2 + mechdusaSpacingVector; - mechQueenSpacing = mechQueenSpacing.RotatedBy(mechdusaSpacingVel, mechQueenCenter2); - } - - npc.reflectsProjectiles = false; - - // Despawn - bool oblivionFightDespawn = ((oblivionAlive && lifeRatio < 0.8f) || (oblivionAlive && !retAlive && lifeRatio < 0.95f)) && npc.localAI[3] == 1f; - if (Main.player[npc.target].dead || oblivionFightDespawn) - { - npc.velocity.Y -= 0.04f; - if (npc.timeLeft > 10) - { - npc.timeLeft = 10; - return false; - } - } - - // Phase 1 - else if (npc.ai[0] == 0f) - { - // Cursed fireball phase - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - // Velocity - float maxVelocity = 12f; - float acceleration = 0.4f; - maxVelocity += 6f * enrageScale; - acceleration += 0.2f * enrageScale; - - if (death) - { - maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - acceleration += phase1MaxAccelerationIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - } - - if (Main.getGoodWorld) - { - maxVelocity *= 1.15f; - acceleration *= 1.15f; - } - - float distanceFromTarget = oblivionAlive ? 480f : 400f; - Vector2 destination = Main.player[npc.target].Center + Vector2.UnitX * distanceFromTarget * direction; - float distanceFromDestination = (destination - npc.Center).Length(); - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction); - if (NPC.IsMechQueenUp) + NPC.reflectsProjectiles = true; + + if (NPC.ai[0] == 1f) { - maxVelocity = 14f; - - destination = mechQueenSpacing; - distanceFromDestination = (destination - npc.Center).Length(); - idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitY); - - if (distanceFromDestination > maxVelocity) - idealVelocity *= maxVelocity / distanceFromDestination; - - float inertia = 5f; - npc.velocity = (npc.velocity * (inertia - 1f) + idealVelocity) / inertia; - } - else - npc.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - - // Fire cursed flames for 5 seconds - npc.ai[2] += 1f; - float phaseGateValue = NPC.IsMechQueenUp ? 900f : 300f - (death ? phase1MaxCursedFlamePhaseDurationDecrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); - if (npc.ai[2] >= phaseGateValue) - { - // Reset AI array and go to charging phase - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + NPC.ai[2] += 0.005f; + if (NPC.ai[2] > 0.5) + NPC.ai[2] = 0.5f; } else { - // Fire cursed flame every half second - if (!Main.player[npc.target].dead) - { - npc.ai[3] += 1f; - if (Main.getGoodWorld) - npc.ai[3] += 0.4f; - } + NPC.ai[2] -= 0.005f; + if (NPC.ai[2] < 0f) + NPC.ai[2] = 0f; + } - if (npc.ai[3] >= (oblivionAlive ? 60f : foveanatorAlive ? 45f : 30f)) - { - npc.ai[3] = 0f; + NPC.rotation += NPC.ai[2]; + NPC.ai[1] += 1f; + if (death && NPC.ai[2] >= 0.2f) + { + if (NPC.ai[1] % 10f == 0f) + { + SoundEngine.PlaySound(SoundID.Item33, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - float cursedFireballSpeed = 15f; - cursedFireballSpeed += 3f * enrageScale; - int type = ProjectileID.CursedFlameHostile; - int damage = npc.GetProjectileDamage(type); + int type = ProjectileID.DeathLaser; - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 fireballVelocity = ((Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * cursedFireballSpeed) + new Vector2(Main.rand.Next(-10, 11), Main.rand.Next(-10, 11)) * 0.05f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + fireballVelocity.SafeNormalize(Vector2.UnitY) * 50f, fireballVelocity, type, damage, 0f, Main.myPlayer); + Vector2 projectileVelocity = NPC.rotation.ToRotationVector2() * 7f; + float offset = 90f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projectileVelocity) * offset, projectileVelocity, type, LaserDamage.CalculateMechDamage(), 0f, Main.myPlayer); } } } - } - // Charging phase - else if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = npc.defDamage; - - // Rotation and velocity - npc.rotation = hoverRotation; - - float chargeSpeed = 18f; - chargeSpeed += 8f * enrageScale; - if (death) - chargeSpeed += phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); - if (Main.getGoodWorld) - chargeSpeed *= 1.2f; - - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; - - npc.ai[1] = 2f; - } - else if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f; - - float timeBeforeSlowDown = death ? 30f : 10f; - if (npc.ai[2] >= timeBeforeSlowDown) + if (NPC.ai[1] == 100f) { - // Avoid cheap bullshit - npc.damage = 0; - - // Slow down - npc.velocity *= 0.8f; - - if (Math.Abs(npc.velocity.X) < 0.1) - npc.velocity.X = 0f; - if (Math.Abs(npc.velocity.Y) < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - - // Charge 8 times - float chargeTime = death ? 45f : 25f; - if (npc.ai[2] >= chargeTime + (oblivionAlive ? 15f : 0f)) - { - // Reset AI array and go to cursed fireball phase - npc.ai[3] += 1f; - npc.ai[2] = 0f; - - npc.rotation = hoverRotation; - - float totalCharges = foveanatorAlive ? 6f : 8f; - if (death) - totalCharges -= (float)Math.Round(phase1MaxChargesDecrease * ((1f - lifeRatio) / (1f - phase2LifeRatio))); - - if (npc.ai[3] >= totalCharges) + NPC.ai[0] += 1f; + NPC.ai[1] = 0f; + if (NPC.ai[0] == 3f) { - npc.ai[1] = 0f; - npc.ai[3] = 0f; + NPC.ai[2] = 0f; } else - npc.ai[1] = 1f; + { + SoundEngine.PlaySound(SoundID.NPCHit1, NPC.Center); + + if (!Main.dedServ) + { + for (int i = 0; i < 2; i++) + { + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 143, 1f); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); + } + } + + for (int j = 0; j < 20; j++) + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); + } } - } - // Enter phase 2 - if (phase2) - { - // Reset AI array and go to transition phase - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } - } - - // Transition phase - else if (npc.ai[0] == 1f || npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (NPC.IsMechQueenUp) - npc.reflectsProjectiles = true; - - // AI timer for rotation - if (npc.ai[0] == 1f) - { - npc.ai[2] += 0.005f; - if (npc.ai[2] > 0.5) - npc.ai[2] = 0.5f; + NPC.velocity *= 0.98f; + if (Math.Abs(NPC.velocity.X) < 0.1) + NPC.velocity.X = 0f; + if (Math.Abs(NPC.velocity.Y) < 0.1) + NPC.velocity.Y = 0f; } else { - npc.ai[2] -= 0.005f; - if (npc.ai[2] < 0f) - npc.ai[2] = 0f; - } - - // Spin around like a moron while flinging blood and gore everywhere - npc.rotation += npc.ai[2]; - - npc.ai[1] += 1f; - if (death && npc.ai[2] >= 0.2f) - { - if (npc.ai[1] % 10f == 0f) + // If in phase 2 but Spaz isn't + bool spazInPhase1 = false; + if (CalamityGlobalNPC.fireEye != -1) { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = npc.ai[1] % 20f == 0f ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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 = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * (oblivionAlive ? 12f : 16f) + Main.rand.NextVector2CircularEdge(3f, 3f); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 1f); - Main.projectile[proj].tileCollide = false; - } + if (Main.npc[CalamityGlobalNPC.fireEye].active) + spazInPhase1 = Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 0f; } - } - if (npc.ai[1] == 100f) - { - npc.ai[0] += 1f; - npc.ai[1] = 0f; + NPC.chaseable = !spazInPhase1; - if (npc.ai[0] == 3f) + NPC.damage = (int)Math.Round(NPC.defDamage * RetinazerPhase2ContactDamageMult); + NPC.defense = NPC.defDefense + 10; + calamityGlobalNPC.DR = spazInPhase1 ? 0.9999f : 0.2f; + calamityGlobalNPC.unbreakableDR = spazInPhase1; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = spazInPhase1; + + NPC.HitSound = SoundID.NPCHit4; + + if (NPC.ai[1] == 0f) { - npc.ai[2] = 0f; - } - else - { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); - - if (!Main.dedServ) - { - for (int i = 0; i < 2; i++) - { - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 144, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); - } - } - - for (int j = 0; j < 20; j++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - } - - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - - npc.velocity *= 0.98f; - if (Math.Abs(npc.velocity.X) < 0.1) - npc.velocity.X = 0f; - if (Math.Abs(npc.velocity.Y) < 0.1) - npc.velocity.Y = 0f; - } - - // Phase 2 - else - { - // If in phase 2 but Ret isn't - bool retInPhase1 = false; - if (CalamityGlobalNPC.laserEye != -1) - { - if (Main.npc[CalamityGlobalNPC.laserEye].active) - retInPhase1 = Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 0f; - } - - npc.chaseable = !retInPhase1; - - // Increase defense and damage - int setDamage = (int)Math.Round(npc.defDamage * 1.5); - int reducedSetDamage = (int)Math.Round(setDamage * 0.5); - npc.defense = npc.defDefense + 18; - calamityGlobalNPC.DR = retInPhase1 ? 0.9999f : 0.2f; - calamityGlobalNPC.unbreakableDR = retInPhase1; - calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = retInPhase1; - - // Change hit sound to metal - npc.HitSound = SoundID.NPCHit4; - - // Shadowflamethrower phase - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = reducedSetDamage; - - float maxVelocity = 6.2f + (death ? 2f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float acceleration = 0.1f + (death ? 0.03f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - maxVelocity += 3f * enrageScale; - acceleration += 0.06f * enrageScale; - - float distanceFromTarget = 180f; - Vector2 destination = Main.player[npc.target].Center + Vector2.UnitX * distanceFromTarget * direction; - float distanceFromDestination = (destination - npc.Center).Length(); - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction); - - if (!NPC.IsMechQueenUp) - { - // Boost speed if too far from target - if (distanceFromDestination > distanceFromTarget) - maxVelocity += MathHelper.Lerp(0f, oblivionAlive ? 3f : death ? 8f : 6f, MathHelper.Clamp((distanceFromDestination - distanceFromTarget) / 1000f, 0f, 1f)); + float maxVelocity = death ? 10.65f + (1.5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio)) : 9.5f; + float acceleration = death ? 0.1975f : 0.175f; if (Main.getGoodWorld) { @@ -1242,1677 +398,943 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses acceleration *= 1.15f; } - npc.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - } + float distanceFromTarget = 420f; + Vector2 destination = Main.player[NPC.target].Center - Vector2.UnitY * distanceFromTarget; + float distanceFromDestination = (destination - NPC.Center).Length(); + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); - // Fire flamethrower for x seconds - npc.ai[2] += retAlive ? 1f : 2f; - float phaseGateValue = NPC.IsMechQueenUp ? 900f : 180f - (death ? 60f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - if (npc.ai[2] >= phaseGateValue) - { - npc.ai[1] = finalPhase ? 5f : 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - // Fire fireballs and flamethrower - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - // Play flame sound on timer - npc.localAI[2] += 1f; - if (npc.localAI[2] > 22f) + if (NPC.IsMechQueenUp) { - npc.localAI[2] = 0f; - SoundEngine.PlaySound(SoundID.Item34, npc.Center); + maxVelocity = 14f; + + destination = mechQueenSpacing; + distanceFromDestination = (destination - NPC.Center).Length(); + idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitY); + + if (distanceFromDestination > maxVelocity) + idealVelocity *= maxVelocity / distanceFromDestination; + + float inertia = 5f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + idealVelocity) / inertia; } + else + NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); + + NPC.ai[2] += spazAlive ? 1f : 1.5f; + float phaseGateValue = NPC.IsMechQueenUp ? 900f : 300f - (death ? 80f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + if (NPC.ai[2] >= phaseGateValue) + { + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + CalamityUtils.CalamityTargeting(NPC, options); + + NPC.netUpdate = true; + } + + NPC.rotation = (Main.player[NPC.target].Center - NPC.Center).ToRotation() - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[1] += 1f; - if (npc.localAI[1] > 2f) + NPC.localAI[1] += 1f + (death ? ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) / 2 : 0f); + if (NPC.localAI[1] >= (spazAlive ? 52f : 26f)) { - npc.ai[3] += 1f; - npc.localAI[1] = 0f; - - float flamethrowerSpeed = foveanatorAlive ? 5f : 6f; - flamethrowerSpeed += 3f * enrageScale; - float timeForFlamethrowerToReachMaxVelocity = 60f; - float flamethrowerSpeedScalar = MathHelper.Clamp(npc.ai[2] / timeForFlamethrowerToReachMaxVelocity, 0f, 1f); - flamethrowerSpeed = MathHelper.Lerp(0.1f, flamethrowerSpeed, flamethrowerSpeedScalar); - int type = npc.ai[3] % 2f == 0f ? ModContent.ProjectileType() : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - 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); - } + NPC.localAI[1] = 0f; - Vector2 flamethrowerVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * flamethrowerSpeed + npc.velocity * 0.5f; + float laserSpeed = 10f; + int type = ProjectileID.DeathLaser; - if (NPC.IsMechQueenUp) - flamethrowerVelocity = (npc.rotation + MathHelper.PiOver2).ToRotationVector2() * flamethrowerSpeed + npc.velocity * 0.5f; - - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 25f, flamethrowerVelocity, type, damage, 0f, Main.myPlayer); - if (death && npc.ai[3] % 30f == 0f) - { - type = npc.ai[3] % 60f == 0f ? ModContent.ProjectileType() : ProjectileID.CursedFlameHostile; - damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 50f, flamethrowerVelocity * 2f, type, damage, 0f, Main.myPlayer); + Vector2 laserVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, RedLaserDamage.CalculateMechDamage(), 0f, Main.myPlayer); } } } } - - if (NPC.IsMechQueenUp) + else { - maxVelocity = 14f; - - destination = mechQueenSpacing; - distanceFromDestination = (destination - npc.Center).Length(); - idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitY); - - if (distanceFromDestination > maxVelocity) - idealVelocity *= maxVelocity / distanceFromDestination; - - float inertia = 60f; - npc.velocity = (npc.velocity * (inertia - 1f) + idealVelocity) / inertia; - } - } - - // Charging phase - else - { - // Charge - if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = setDamage; - - // Play charge sound - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - - // Set rotation and velocity - npc.rotation = hoverRotation; - - float chargeSpeed = 18f + (death ? 5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - chargeSpeed += 16f * enrageScale; - if (Main.getGoodWorld) - chargeSpeed *= 1.2f; - - npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; - - npc.ai[1] = 2f; - - return false; - } - - if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = setDamage; - - npc.ai[2] += retAlive ? 1f : 1.25f; - - float chargeTime = 30f - (death ? 10f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - - // Slow down - if (npc.ai[2] >= chargeTime) + if (NPC.ai[1] == 1f) { - // Avoid cheap bullshit - npc.damage = reducedSetDamage; + float maxVelocity = death ? 10.65f + (1.5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio)) : 9.5f; + float acceleration = death ? 0.295f : 0.25f; - float deceleration = 0.85f - (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - npc.velocity *= deceleration; - - if (Math.Abs(npc.velocity.X) < 0.1) - npc.velocity.X = 0f; - if (Math.Abs(npc.velocity.Y) < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - - // Charges 5 times - if (npc.ai[2] >= (chargeTime * 1.6f) + (oblivionAlive ? 15f : 0f)) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - - npc.rotation = hoverRotation; - - float totalCharges = foveanatorAlive ? 4f : 5f; - if (npc.ai[3] >= totalCharges) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - return false; - } - - npc.ai[1] = 1f; - } - } - - // Crazy charge - else if (npc.ai[1] == 3f) - { - // Avoid cheap bullshit - npc.damage = reducedSetDamage; - - // Reset AI array and go to shadowflamethrower phase or fireball phase if ret is dead - float secondFastCharge = 4f; - if (npc.ai[3] >= (retAlive ? secondFastCharge : secondFastCharge + 1f)) - { - npc.ai[1] = retAlive ? 0f : 5f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - if (npc.ai[1] == 0f) - npc.localAI[1] = -20f; - - npc.ForceNetUpdate(false); - } - - // Set charging velocity - else if (Main.netMode != NetmodeID.MultiplayerClient) - { - // Velocity - float spazmatismPhase3ChargeSpeed = 20f + (death ? 6f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - spazmatismPhase3ChargeSpeed += 10f * enrageScale; - if (npc.ai[2] == -1f || (!retAlive && npc.ai[3] == secondFastCharge)) - spazmatismPhase3ChargeSpeed *= 1.3f; if (Main.getGoodWorld) - spazmatismPhase3ChargeSpeed *= 1.2f; - - Vector2 distanceVector = Main.player[npc.target].Center + (!retAlive && bossRush ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center; - npc.velocity = distanceVector.SafeNormalize(Vector2.UnitY) * spazmatismPhase3ChargeSpeed; - - if (retAlive) { - if (npc.Distance(Main.player[npc.target].Center) < 100f) + maxVelocity *= 1.15f; + acceleration *= 1.15f; + } + + float distanceFromTarget = 420f; + Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * distanceFromTarget * direction; + float distanceFromDestination = (destination - NPC.Center).Length(); + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); + NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); + + NPC.rotation = (Main.player[NPC.target].Center - NPC.Center).ToRotation() - MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 1f + (death ? ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) / 2 : 0f); + if (NPC.localAI[1] > (spazAlive ? 20f : 10f)) { - if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float absoluteSpazXVel = Math.Abs(npc.velocity.X); - float absoluteSpazYVel = Math.Abs(npc.velocity.Y); + NPC.localAI[1] = 0f; - if (npc.Center.X > Main.player[npc.target].Center.X) - absoluteSpazYVel *= -1f; - if (npc.Center.Y > Main.player[npc.target].Center.Y) - absoluteSpazXVel *= -1f; + float laserSpeed = 9f; + int type = ProjectileID.DeathLaser; + int damage = (int)Math.Round(RedLaserDamage.CalculateMechDamage() * RapidFireDamageMult); - npc.velocity = new Vector2(absoluteSpazYVel, absoluteSpazXVel); + Vector2 laserVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); } } } - if (death) + NPC.ai[2] += spazAlive ? 1f : 1.5f; + if (NPC.ai[2] >= (death ? 150f : 180f) - (death ? 25f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) { - float projectileSpeed = spazmatismPhase3ChargeSpeed * 0.5f; - int type = (!retAlive && npc.ai[3] % 2f == 0f) ? ModContent.ProjectileType() : ProjectileID.CursedFlameHostile; - int damage = npc.GetProjectileDamage(type); + NPC.ai[1] = finalPhase ? 4f : 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + CalamityUtils.CalamityTargeting(NPC, options); + + NPC.netUpdate = true; + } + } + + // Charge + else if (NPC.ai[1] == 2f) + { + // Set rotation and velocity + NPC.rotation = hoverRotation; + + float chargeSpeed = (death ? 25f : 22f) + (death ? 3f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + if (!spazAlive) + chargeSpeed += 2f; + if (Main.getGoodWorld) + chargeSpeed += 2f; + + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * chargeSpeed; + + NPC.ai[1] = 3f; + } + + else if (NPC.ai[1] == 3f) + { + NPC.ai[2] += 1f; + + float chargeTime = spazAlive ? 45f : 30f; + if (NPC.ai[3] % 3f == 0f) + chargeTime = spazAlive ? 90f : 60f; + if (death) + chargeTime -= chargeTime * 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio); + chargeTime -= chargeTime * (death ? 0.06f : 0f); + + // Slow down + if (NPC.ai[2] >= chargeTime) + { + NPC.velocity *= 0.93f; + + if (Math.Abs(NPC.velocity.X) < 0.1) + NPC.velocity.X = 0f; + if (Math.Abs(NPC.velocity.Y) < 0.1) + NPC.velocity.Y = 0f; + } + else + { + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; + + if (NPC.ai[3] % 3f == 0f) { - 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); - } + float fireRate = spazAlive ? 13f : 9f; + if (NPC.ai[2] % fireRate == 0f) + { + SoundEngine.PlaySound(SoundID.Item33, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float laserDartSpeed = (death ? 7.25f : 6f) * (spazAlive ? 1f : 1.5f); + int type = ModContent.ProjectileType(); + int damage = HomingDartDamage.CalculateMechDamage(); - Vector2 projectileVelocity = (Main.player[npc.target].Center + ((!retAlive && bossRush) ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - int numProj = 3; - int spread = 15; - float rotation = MathHelper.ToRadians(spread); + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityServerConfig.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); + } - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 25f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Vector2 laserDartVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * laserDartSpeed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.velocity.SafeNormalize(Vector2.UnitY) * 60f, laserDartVelocity, type, damage, 0f, Main.myPlayer); + } + } } } - npc.ai[1] = 4f; - npc.ForceNetUpdate(false); + // Charge four times + float chargeGateValue = 30f; + chargeGateValue -= chargeGateValue * (death ? 0.07f : 0f); + if (NPC.ai[2] >= chargeTime + chargeGateValue) + { + NPC.ai[2] = 0f; + + float chargeIncrement = 1f; + if (death && Main.rand.NextBool() && NPC.ai[3] < (spazAlive ? 1f : 3f)) + { + chargeIncrement = 2f; + + // Net update due to the randomness in Master Mode + NPC.netUpdate = true; + } + + NPC.rotation = hoverRotation; + + NPC.ai[3] += chargeIncrement; + float maxChargeAmt = spazAlive ? 2f : 4f; + if (NPC.ai[3] >= maxChargeAmt) + { + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.aggroRatio = -1f; + CalamityUtils.CalamityTargeting(NPC, options); + } + else + NPC.ai[1] = 4f; + } + } + + // Get in position for charge + else if (NPC.ai[1] == 4f) + { + float chargeLineUpDistance = spazAlive ? 600f : 500f; + float chargeSpeed = (death ? 20f : 18f) + (death ? 1.5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + float chargeAcceleration = death ? 0.495f : 0.45f; + + if (spazAlive) + { + chargeSpeed *= 0.75f; + chargeAcceleration *= 0.75f; + } + + if (Main.getGoodWorld) + { + chargeSpeed *= 1.15f; + chargeAcceleration *= 1.15f; + } + + Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * chargeLineUpDistance * direction; + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; + NPC.SimpleFlyMovement(idealVelocity, chargeAcceleration); + + // Take 1.25 or 1 second to get in position, then charge + NPC.ai[2] += 1f; + if (NPC.ai[2] >= (spazAlive ? 75f : 60f) - (death ? 5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) + { + NPC.ai[1] = 2f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; + } } } + } - // Crazy charge - else if (npc.ai[1] == 4f) + return false; + } + } + + public class SpazmatismAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + { + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.finishThemOff = true; + CalamityUtils.CalamityTargeting(NPC, options); + } + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Easier to send info to Retinazer + CalamityGlobalNPC.fireEye = NPC.whoAmI; + + // Check for Retinazer + bool retAlive = false; + if (CalamityGlobalNPC.laserEye != -1) + retAlive = Main.npc[CalamityGlobalNPC.laserEye].active; + + // Rotation + Vector2 hoverDestination = new Vector2(NPC.Center.X - Main.player[NPC.target].position.X - (Main.player[NPC.target].width / 2), NPC.position.Y + NPC.height - 59f - Main.player[NPC.target].position.Y - (Main.player[NPC.target].height / 2)); + int direction = (NPC.Center.X < Main.player[NPC.target].position.X + Main.player[NPC.target].width) ? -1 : 1; + + float hoverRotation = hoverDestination.ToRotation() + MathHelper.PiOver2; + if (hoverRotation < 0f) + hoverRotation += MathHelper.TwoPi; + else if (hoverRotation > MathHelper.TwoPi) + hoverRotation -= MathHelper.TwoPi; + + float rotationRate = 0.15f; + if (NPC.IsMechQueenUp && NPC.ai[0] == 3f && NPC.ai[1] == 0f) + rotationRate *= 0.25f; + + NPC.rotation = NPC.rotation.AngleTowards(hoverRotation, rotationRate); + + // Dust + if (Main.rand.NextBool(5)) + { + int spazDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f), NPC.width, (int)(NPC.height * 0.5f), DustID.Blood, NPC.velocity.X, 2f, 0, default, 1f); + Dust dust = Main.dust[spazDust]; + dust.velocity.X *= 0.5f; + dust.velocity.Y *= 0.1f; + } + + // Despawn Twins at the same time + if (Main.netMode != NetmodeID.MultiplayerClient && !Main.player[NPC.target].dead && NPC.timeLeft < 10) + { + for (int i = 0; i < Main.maxNPCs; i++) { - // Set damage - npc.damage = setDamage; - - if (npc.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - - float spazmatismRetDeadChargeSpeed = ((!retAlive && npc.ai[3] == 4f) ? 75f : 50f) - (float)Math.Round(death ? ((!retAlive && npc.ai[3] == 4f) ? 15f : 10f) * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - - npc.ai[2] += 1f; - - if (npc.ai[2] == spazmatismRetDeadChargeSpeed && Vector2.Distance(npc.position, Main.player[npc.target].position) < (retAlive ? 200f : 150f)) - npc.ai[2] -= 1f; - - // Slow down - if (npc.ai[2] >= spazmatismRetDeadChargeSpeed) - { - // Avoid cheap bullshit - npc.damage = reducedSetDamage; - - npc.velocity *= 0.93f; - if (Math.Abs(npc.velocity.X) < 0.1) - npc.velocity.X = 0f; - if (Math.Abs(npc.velocity.Y) < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; - - // Charge 3 times - float spazmatismRetDeadChargeTimer = spazmatismRetDeadChargeSpeed + 25f; - if (npc.ai[2] >= spazmatismRetDeadChargeTimer) - { - npc.ForceNetUpdate(false); - - float chargeIncrement = 1f; - if (death && Main.rand.NextBool() && npc.ai[3] < (retAlive ? 2f : 3f)) - chargeIncrement = 2f; - - npc.ai[3] += chargeIncrement; - npc.ai[2] = 0f; - npc.ai[1] = 3f; - } + if (i != NPC.whoAmI && Main.npc[i].active && (Main.npc[i].type == NPCID.Retinazer || Main.npc[i].type == NPCID.Spazmatism) && Main.npc[i].timeLeft - 1 > NPC.timeLeft) + NPC.timeLeft = Main.npc[i].timeLeft - 1; } + } - // Get in position for charge - else if (npc.ai[1] == 5f) + // Phase HP ratios + float phase2LifeRatio = death ? 0.85f : 0.7f; + float finalPhaseLifeRatio = death ? 0.4f : 0.25f; + + // Movement variables + float phase1MaxSpeedIncrease = 1.125f; + float phase1MaxChargeSpeedIncrease = 1.4f; + + // Phase duration variables + float phase1MaxCursedFlamePhaseDurationDecrease = death ? 80f : 200f; + float phase1MaxChargesDecrease = 2f; + + // Phase checks + bool phase2 = lifeRatio < phase2LifeRatio; + bool finalPhase = lifeRatio < finalPhaseLifeRatio; + + Vector2 mechQueenSpacing = Vector2.Zero; + if (NPC.IsMechQueenUp) + { + NPC nPC2 = Main.npc[NPC.mechQueen]; + Vector2 mechQueenCenter2 = nPC2.GetMechQueenCenter(); + Vector2 mechdusaSpacingVector = new Vector2(150f, -250f); + mechdusaSpacingVector *= 0.75f; + float mechdusaSpacingVel = nPC2.velocity.X * 0.025f; + mechQueenSpacing = mechQueenCenter2 + mechdusaSpacingVector; + mechQueenSpacing = mechQueenSpacing.RotatedBy(mechdusaSpacingVel, mechQueenCenter2); + } + + NPC.reflectsProjectiles = false; + + // Despawn + if ((Main.player[NPC.target].dead || Main.IsItDay()) && !BossRushEvent.BossRushActive) + { + NPC.velocity.Y -= 0.04f; + if (NPC.timeLeft > 10) { - // Avoid cheap bullshit - npc.damage = reducedSetDamage; + NPC.timeLeft = 10; + return false; + } + } - float chargeLineUpDistance = retAlive ? 600f : 500f; - float chargeSpeed = 16f + (death ? 5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float chargeAcceleration = 0.4f + (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - chargeSpeed += 5.333f * enrageScale; - chargeAcceleration += 0.133f * enrageScale; + // Phase 1 + else if (NPC.ai[0] == 0f) + { + // Cursed fireball phase + if (NPC.ai[1] == 0f) + { + // Velocity + float maxVelocity = death ? 13.5f : 12f; + float acceleration = death ? 0.46f : 0.4f; - if (retAlive) + if (death) { - chargeSpeed *= 0.75f; - chargeAcceleration *= 0.75f; + maxVelocity += phase1MaxSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)); } if (Main.getGoodWorld) { - chargeSpeed *= 1.15f; - chargeAcceleration *= 1.15f; + maxVelocity *= 1.15f; + acceleration *= 1.15f; } - Vector2 destination = Main.player[npc.target].Center + Vector2.UnitY * chargeLineUpDistance; - Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; - npc.SimpleFlyMovement(idealVelocity, chargeAcceleration); + float distanceFromTarget = 400f; + Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * distanceFromTarget * direction; + float distanceFromDestination = (destination - NPC.Center).Length(); + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); - npc.ai[2] += 1f; - - // Fire shadowflames and cursed fireballs - float fireRate = retAlive ? 30f : foveanatorAlive ? 25f : 20f; - if (npc.ai[2] % fireRate == 0f) + if (NPC.IsMechQueenUp) { - npc.ai[3] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float projectileSpeed = 16f; - int type = npc.ai[3] % 2f == 0f ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + maxVelocity = 14f; - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.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); - } + destination = mechQueenSpacing; + distanceFromDestination = (destination - NPC.Center).Length(); + idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitY); - Vector2 projectileVelocity = (Main.player[npc.target].Center + (!retAlive && bossRush ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 25f, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, retAlive ? 0f : 1f); - } - } + if (distanceFromDestination > maxVelocity) + idealVelocity *= maxVelocity / distanceFromDestination; - // Take 3 seconds to get in position, then charge - if (npc.ai[2] >= (retAlive ? 180f : 135f) - (death ? 45f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) - { - npc.ai[1] = 3f; - npc.ai[2] = -1f; - npc.ai[3] = 0f; - } - - npc.ForceNetUpdate(false); - } - } - } - - return false; - } - - public static bool VanillaRetinazerAI(NPC npc, Mod mod) - { - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - } - - float phase2LifeRatio = Main.masterMode ? 0.6f : 0.4f; - - bool dead2 = Main.player[npc.target].dead; - float num412 = npc.Center.X - Main.player[npc.target].position.X - (float)(Main.player[npc.target].width / 2); - float num413 = npc.position.Y + (float)npc.height - 59f - Main.player[npc.target].position.Y - (float)(Main.player[npc.target].height / 2); - float num414 = (float)Math.Atan2(num413, num412) + MathHelper.PiOver2; - if (num414 < 0f) - num414 += MathHelper.TwoPi; - else if ((double)num414 > MathHelper.TwoPi) - num414 -= MathHelper.TwoPi; - - float num415 = 0.1f; - if (npc.rotation < num414) - { - if ((double)(num414 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num415; - else - npc.rotation += num415; - } - else if (npc.rotation > num414) - { - if ((double)(npc.rotation - num414) > MathHelper.Pi) - npc.rotation += num415; - else - npc.rotation -= num415; - } - - if (npc.rotation > num414 - num415 && npc.rotation < num414 + num415) - npc.rotation = num414; - - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if ((double)npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - - if (npc.rotation > num414 - num415 && npc.rotation < num414 + num415) - npc.rotation = num414; - - if (Main.rand.NextBool(5)) - { - int num416 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), DustID.Blood, npc.velocity.X, 2f); - Main.dust[num416].velocity.X *= 0.5f; - Main.dust[num416].velocity.Y *= 0.1f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && !Main.IsItDay() && !dead2 && npc.timeLeft < 10) - { - for (int num417 = 0; num417 < Main.maxNPCs; num417++) - { - if (num417 != npc.whoAmI && Main.npc[num417].active && (Main.npc[num417].type == NPCID.Retinazer || Main.npc[num417].type == NPCID.Spazmatism)) - npc.DiscourageDespawn(Main.npc[num417].timeLeft - 1); - } - } - - Vector2 vector41 = Vector2.Zero; - if (NPC.IsMechQueenUp) - { - NPC nPC = Main.npc[NPC.mechQueen]; - Vector2 mechQueenCenter = nPC.GetMechQueenCenter(); - Vector2 vector42 = new Vector2(-150f, -250f); - vector42 *= 0.75f; - float num418 = nPC.velocity.X * 0.025f; - vector41 = mechQueenCenter + vector42; - vector41 = vector41.RotatedBy(num418, mechQueenCenter); - } - - npc.reflectsProjectiles = false; - if (Main.IsItDay() || dead2) - { - npc.velocity.Y -= 0.04f; - npc.EncourageDespawn(10); - return false; - } - - if (npc.ai[0] == 0f) - { - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float num419 = 7f; - float num420 = 0.1f; - if (Main.expertMode) - { - num419 = Main.masterMode ? 9.5f : 8.25f; - num420 = Main.masterMode ? 0.13f : 0.115f; - } - - if (Main.getGoodWorld) - { - num419 *= 1.15f; - num420 *= 1.15f; - } - - int num421 = 1; - if (npc.Center.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) - num421 = -1; - - Vector2 vector43 = npc.Center; - float num422 = Main.player[npc.target].Center.X + (float)(num421 * 300) - vector43.X; - float num423 = Main.player[npc.target].Center.Y - 300f - vector43.Y; - if (NPC.IsMechQueenUp) - { - num419 = 14f; - num422 = vector41.X; - num423 = vector41.Y; - num422 -= vector43.X; - num423 -= vector43.Y; - } - - float num424 = (float)Math.Sqrt(num422 * num422 + num423 * num423); - float num425 = num424; - if (NPC.IsMechQueenUp) - { - if (num424 > num419) - { - num424 = num419 / num424; - num422 *= num424; - num423 *= num424; - } - - float num426 = 60f; - npc.velocity.X = (npc.velocity.X * (num426 - 1f) + num422) / num426; - npc.velocity.Y = (npc.velocity.Y * (num426 - 1f) + num423) / num426; - } - else - { - num424 = num419 / num424; - num422 *= num424; - num423 *= num424; - if (npc.velocity.X < num422) - { - npc.velocity.X += num420; - if (npc.velocity.X < 0f && num422 > 0f) - npc.velocity.X += num420; - } - else if (npc.velocity.X > num422) - { - npc.velocity.X -= num420; - if (npc.velocity.X > 0f && num422 < 0f) - npc.velocity.X -= num420; - } - - if (npc.velocity.Y < num423) - { - npc.velocity.Y += num420; - if (npc.velocity.Y < 0f && num423 > 0f) - npc.velocity.Y += num420; - } - else if (npc.velocity.Y > num423) - { - npc.velocity.Y -= num420; - if (npc.velocity.Y > 0f && num423 < 0f) - npc.velocity.Y -= num420; - } - } - - int num427 = 600; - int num428 = 60; - if (NPC.IsMechQueenUp) - { - num427 = 1200; - num428 = ((!NPC.npcsFoundForCheckActive[NPCID.TheDestroyerBody]) ? 90 : 120); - } - - if (Main.expertMode) - num428 = (int)(num428 * 0.8f); - - if (Main.masterMode) - num427 /= 2; - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num427) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } - else if (npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && num425 < (Main.masterMode ? 720f : Main.expertMode ? 560f : 400f)) - { - if (!Main.player[npc.target].dead) - { - npc.ai[3] += 1f; - - if (Main.expertMode) - npc.ai[3] += MathHelper.Lerp(0f, Main.masterMode ? 2.5f : 1.5f, 1f - (npc.life / (float)npc.lifeMax - phase2LifeRatio) / (1f - phase2LifeRatio)); - - if (Main.getGoodWorld) - npc.ai[3] += 0.5f; - } - - if (npc.ai[3] >= (float)num428) - { - npc.ai[3] = 0f; - vector43 = npc.Center; - num422 = Main.player[npc.target].Center.X - vector43.X; - num423 = Main.player[npc.target].Center.Y - vector43.Y; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num429 = Main.expertMode ? 10.5f : 9f; - int type = ProjectileID.EyeLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); - } - - num424 = (float)Math.Sqrt(num422 * num422 + num423 * num423); - num424 = num429 / num424; - num422 *= num424; - num423 *= num424; - int inaccuracy = Main.masterMode ? 3 : Main.expertMode ? 6 : 9; - num422 += (float)Main.rand.Next(-inaccuracy, inaccuracy + 1) * 0.08f; - num423 += (float)Main.rand.Next(-inaccuracy, inaccuracy + 1) * 0.08f; - - Vector2 laserVelocity = new Vector2(num422, num423); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector43 + laserVelocity.SafeNormalize(Vector2.UnitY) * 90f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - else if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.rotation = num414; - float num432 = 12f; - if (Main.expertMode) - num432 = Main.masterMode ? 18f : 15f; - - if (Main.getGoodWorld) - num432 += 2f; - - Vector2 vector44 = npc.Center; - float num433 = Main.player[npc.target].Center.X - vector44.X; - float num434 = Main.player[npc.target].Center.Y - vector44.Y; - float num435 = (float)Math.Sqrt(num433 * num433 + num434 * num434); - num435 = num432 / num435; - npc.velocity.X = num433 * num435; - npc.velocity.Y = num434 * num435; - npc.ai[1] = 2f; - } - else if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f; - float decelerateGateValue = Main.masterMode ? 38f : Main.expertMode ? 32f : 25f; - if (npc.ai[2] >= decelerateGateValue) - { - // Avoid cheap bullshit - npc.damage = 0; - - float decelerationMultiplier = Main.masterMode ? 0.78f : Main.expertMode ? 0.92f : 0.96f; - npc.velocity *= decelerationMultiplier; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - float delayBeforeChargingAgain = Main.masterMode ? 47f : Main.expertMode ? 56f : 70f; - if (npc.ai[2] >= delayBeforeChargingAgain) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = num414; - float numCharges = Main.masterMode ? 6f : Main.expertMode ? 5f : 4f; - if (npc.ai[3] >= numCharges) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.ai[1] = 0f; - npc.ai[3] = 0f; + float inertia = 5f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + idealVelocity) / inertia; } else - npc.ai[1] = 1f; + NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); + + // Fire cursed flames for 5 seconds + NPC.ai[2] += 1f; + float phaseGateValue = NPC.IsMechQueenUp ? 900f : 300f - (death ? phase1MaxCursedFlamePhaseDurationDecrease * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); + if (NPC.ai[2] >= phaseGateValue) + { + // Reset AI array and go to charging phase + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + else + { + // Fire cursed flame every half second + if (!Main.player[NPC.target].dead) + { + NPC.ai[3] += 1f; + if (Main.getGoodWorld) + NPC.ai[3] += 0.4f; + } + + if (NPC.ai[3] >= 30f) + { + NPC.ai[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float cursedFireballSpeed = death ? 15.9f : 15f; + int type = ProjectileID.CursedFlameHostile; + + Vector2 fireballVelocity = ((Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * cursedFireballSpeed) + new Vector2(Main.rand.Next(-10, 11), Main.rand.Next(-10, 11)) * 0.05f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + fireballVelocity.SafeNormalize(Vector2.UnitY) * 50f, fireballVelocity, type, FireballDamage.CalculateMechDamage(), 0f, Main.myPlayer); + } + } + } + } + + // Charging phase + else if (NPC.ai[1] == 1f) + { + // Rotation and velocity + NPC.rotation = hoverRotation; + + float chargeSpeed = death ? 19.25f + (phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio))) : 18f; + if (Main.getGoodWorld) + chargeSpeed *= 1.2f; + + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; + + NPC.ai[1] = 2f; + } + else if (NPC.ai[1] == 2f) + { + NPC.ai[2] += 1f; + + float timeBeforeSlowDown = death ? 14f : 10f; + if (NPC.ai[2] >= timeBeforeSlowDown) + { + // Slow down + NPC.velocity *= 0.8f; + + if (Math.Abs(NPC.velocity.X) < 0.1) + NPC.velocity.X = 0f; + if (Math.Abs(NPC.velocity.Y) < 0.1) + NPC.velocity.Y = 0f; + } + else + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; + + // Charge 8 times + float chargeTime = death ? 35f : 25f; + if (NPC.ai[2] >= chargeTime) + { + // Reset AI array and go to cursed fireball phase + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; + + NPC.rotation = hoverRotation; + + float totalCharges = 8f; + if (death) + totalCharges -= (float)Math.Round(phase1MaxChargesDecrease * ((1f - lifeRatio) / (1f - phase2LifeRatio))); + + if (NPC.ai[3] >= totalCharges) + { + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + } + else + NPC.ai[1] = 1f; + } + } + + // Enter phase 2 + if (phase2) + { + // Reset AI array and go to transition phase + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + + CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; + options.finishThemOff = true; + CalamityUtils.CalamityTargeting(NPC, options); + + NPC.netUpdate = true; } } - if (npc.life < npc.lifeMax * phase2LifeRatio) + // Transition phase + else if (NPC.ai[0] == 1f || NPC.ai[0] == 2f) { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } + if (NPC.IsMechQueenUp) + NPC.reflectsProjectiles = true; - return false; - } - - if (npc.ai[0] == 1f || npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (NPC.IsMechQueenUp) - npc.reflectsProjectiles = true; - - if (npc.ai[0] == 1f) - { - npc.ai[2] += 0.005f; - if ((double)npc.ai[2] > 0.5) - npc.ai[2] = 0.5f; - } - else - { - npc.ai[2] -= 0.005f; - if (npc.ai[2] < 0f) - npc.ai[2] = 0f; - } - - npc.rotation += npc.ai[2]; - - npc.ai[1] += 1f; - if (Main.masterMode && npc.ai[2] >= 0.2f) - { - if (npc.ai[1] % 10f == 0f) + // AI timer for rotation + if (NPC.ai[0] == 1f) { - if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.ai[2] += 0.005f; + if (NPC.ai[2] > 0.5) + NPC.ai[2] = 0.5f; + } + else + { + NPC.ai[2] -= 0.005f; + if (NPC.ai[2] < 0f) + NPC.ai[2] = 0f; + } + + // Spin around like a moron while flinging blood and gore everywhere + NPC.rotation += NPC.ai[2]; + + NPC.ai[1] += 1f; + if (death && NPC.ai[2] >= 0.2f) + { + if (NPC.ai[1] % 10f == 0f) { - int type = ProjectileID.EyeLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + if (Main.netMode != NetmodeID.MultiplayerClient) { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); - } + int type = NPC.ai[1] % 20f == 0f ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * 7f; - int numProj = 3; - int spread = 10; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 90f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * 16f + Main.rand.NextVector2CircularEdge(3f, 3f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f, projectileVelocity, type, FireballDamage.CalculateMechDamage(), 0f, Main.myPlayer, 0f, 1f); Main.projectile[proj].tileCollide = false; } } } - } - if (npc.ai[1] >= 100f) - { - npc.ai[0] += 1f; - npc.ai[1] = 0f; - if (npc.ai[0] == 3f) + if (NPC.ai[1] == 100f) { - npc.ai[2] = 0f; - } - else - { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); - for (int num436 = 0; num436 < 2; num436++) + NPC.ai[0] += 1f; + NPC.ai[1] = 0f; + + if (NPC.ai[0] == 3f) { - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 143); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 7); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 6); - } - - for (int num437 = 0; num437 < 20; num437++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f); - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - } - - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f); - - npc.velocity *= 0.98f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - - return false; - } - - // Avoid cheap bullshit - npc.damage = 0; - - npc.defense = npc.defDefense + 10; - npc.HitSound = SoundID.NPCHit4; - - if (npc.ai[1] == 0f) - { - float num438 = 8f; - float num439 = 0.15f; - if (Main.expertMode) - { - num438 = Main.masterMode ? 11f : 9.5f; - num439 = Main.masterMode ? 0.2f : 0.175f; - } - - if (Main.getGoodWorld) - { - num438 *= 1.15f; - num439 *= 1.15f; - } - - Vector2 vector45 = npc.Center; - float num440 = Main.player[npc.target].Center.X - vector45.X; - float num441 = Main.player[npc.target].Center.Y - 420f - vector45.Y; - if (NPC.IsMechQueenUp) - { - num438 = 14f; - num440 = vector41.X; - num441 = vector41.Y; - num440 -= vector45.X; - num441 -= vector45.Y; - } - - float num442 = (float)Math.Sqrt(num440 * num440 + num441 * num441); - if (NPC.IsMechQueenUp) - { - if (num442 > num438) - { - num442 = num438 / num442; - num440 *= num442; - num441 *= num442; - } - - npc.velocity.X = (npc.velocity.X * 4f + num440) / 5f; - npc.velocity.Y = (npc.velocity.Y * 4f + num441) / 5f; - } - else - { - num442 = num438 / num442; - num440 *= num442; - num441 *= num442; - if (npc.velocity.X < num440) - { - npc.velocity.X += num439; - if (npc.velocity.X < 0f && num440 > 0f) - npc.velocity.X += num439; - } - else if (npc.velocity.X > num440) - { - npc.velocity.X -= num439; - if (npc.velocity.X > 0f && num440 < 0f) - npc.velocity.X -= num439; - } - - if (npc.velocity.Y < num441) - { - npc.velocity.Y += num439; - if (npc.velocity.Y < 0f && num441 > 0f) - npc.velocity.Y += num439; - } - else if (npc.velocity.Y > num441) - { - npc.velocity.Y -= num439; - if (npc.velocity.Y > 0f && num441 < 0f) - npc.velocity.Y -= num439; - } - } - - int num443 = 300; - if (NPC.IsMechQueenUp) - num443 = 1200; - - if (Main.masterMode) - num443 = (int)(num443 * 0.8f); - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num443) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } - - vector45 = npc.Center; - num440 = Main.player[npc.target].Center.X - vector45.X; - num441 = Main.player[npc.target].Center.Y - vector45.Y; - npc.rotation = (float)Math.Atan2(num441, num440) - MathHelper.PiOver2; - if (Main.netMode == NetmodeID.MultiplayerClient) - return false; - - npc.localAI[1] += 1f; - - npc.localAI[1] += MathHelper.Lerp(0f, Main.masterMode ? 7f : Main.expertMode ? 6f : 5f, 1f - (npc.life / (float)npc.lifeMax) / phase2LifeRatio); - - if (npc.localAI[1] > 180f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.localAI[1] = 0f; - float num444 = Main.expertMode ? 10f : 8.5f; - int type = ProjectileID.DeathLaser; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); - } - - num442 = (float)Math.Sqrt(num440 * num440 + num441 * num441); - num442 = num444 / num442; - num440 *= num442; - num441 *= num442; - - Vector2 laserVelocity = new Vector2(num440, num441); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector45 + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - - return false; - } - - int num447 = 1; - if (npc.Center.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) - num447 = -1; - - float num448 = 8f; - float num449 = 0.2f; - if (Main.expertMode) - { - num448 = Main.masterMode ? 11f : 9.5f; - num449 = Main.masterMode ? 0.3f : 0.25f; - } - - if (Main.getGoodWorld) - { - num448 *= 1.15f; - num449 *= 1.15f; - } - - Vector2 vector46 = npc.Center; - float num450 = Main.player[npc.target].Center.X + (num447 * 420f) - vector46.X; - float num451 = Main.player[npc.target].Center.Y - vector46.Y; - float num452 = (float)Math.Sqrt(num450 * num450 + num451 * num451); - num452 = num448 / num452; - num450 *= num452; - num451 *= num452; - if (npc.velocity.X < num450) - { - npc.velocity.X += num449; - if (npc.velocity.X < 0f && num450 > 0f) - npc.velocity.X += num449; - } - else if (npc.velocity.X > num450) - { - npc.velocity.X -= num449; - if (npc.velocity.X > 0f && num450 < 0f) - npc.velocity.X -= num449; - } - - if (npc.velocity.Y < num451) - { - npc.velocity.Y += num449; - if (npc.velocity.Y < 0f && num451 > 0f) - npc.velocity.Y += num449; - } - else if (npc.velocity.Y > num451) - { - npc.velocity.Y -= num449; - if (npc.velocity.Y > 0f && num451 < 0f) - npc.velocity.Y -= num449; - } - - vector46 = npc.Center; - num450 = Main.player[npc.target].Center.X - vector46.X; - num451 = Main.player[npc.target].Center.Y - vector46.Y; - npc.rotation = (float)Math.Atan2(num451, num450) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - - npc.localAI[1] += MathHelper.Lerp(0f, Main.masterMode ? 6f : Main.expertMode ? 5.25f : 3.75f, 1f - (npc.life / (float)npc.lifeMax) / phase2LifeRatio); - - if (npc.localAI[1] > 60f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.localAI[1] = 0f; - float num453 = 9f; - int type = ProjectileID.DeathLaser; - int damage = (int)Math.Round(npc.GetProjectileDamage(type) * 0.75); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); - } - - num452 = (float)Math.Sqrt(num450 * num450 + num451 * num451); - num452 = num453 / num452; - num450 *= num452; - num451 *= num452; - - Vector2 laserVelocity = new Vector2(num450, num451); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector46 + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - } - - npc.ai[2] += 1f; - float rapidLaserPhaseGateValue = Main.masterMode ? 120f : Main.expertMode ? 150f : 180f; - if (npc.ai[2] >= rapidLaserPhaseGateValue) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.aggroRatio = -1f; - CalamityUtils.CalamityTargeting(npc, options); - - npc.netUpdate = true; - } - - return false; - } - - public static bool VanillaSpazmatismAI(NPC npc, Mod mod) - { - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); - } - - float phase2LifeRatio = Main.masterMode ? 0.6f : 0.4f; - - bool dead3 = Main.player[npc.target].dead; - float num456 = npc.Center.X - Main.player[npc.target].position.X - (float)(Main.player[npc.target].width / 2); - float num457 = npc.position.Y + (float)npc.height - 59f - Main.player[npc.target].position.Y - (float)(Main.player[npc.target].height / 2); - float num458 = (float)Math.Atan2(num457, num456) + MathHelper.PiOver2; - if (num458 < 0f) - num458 += MathHelper.TwoPi; - else if ((double)num458 > MathHelper.TwoPi) - num458 -= MathHelper.TwoPi; - - float num459 = 0.15f; - if (NPC.IsMechQueenUp && npc.ai[0] == 3f && npc.ai[1] == 0f) - num459 *= 0.25f; - - if (npc.rotation < num458) - { - if ((double)(num458 - npc.rotation) > MathHelper.Pi) - npc.rotation -= num459; - else - npc.rotation += num459; - } - else if (npc.rotation > num458) - { - if ((double)(npc.rotation - num458) > MathHelper.Pi) - npc.rotation += num459; - else - npc.rotation -= num459; - } - - if (npc.rotation > num458 - num459 && npc.rotation < num458 + num459) - npc.rotation = num458; - - if (npc.rotation < 0f) - npc.rotation += MathHelper.TwoPi; - else if ((double)npc.rotation > MathHelper.TwoPi) - npc.rotation -= MathHelper.TwoPi; - - if (npc.rotation > num458 - num459 && npc.rotation < num458 + num459) - npc.rotation = num458; - - if (Main.rand.NextBool(5)) - { - int num460 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), DustID.Blood, npc.velocity.X, 2f); - Main.dust[num460].velocity.X *= 0.5f; - Main.dust[num460].velocity.Y *= 0.1f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && !Main.IsItDay() && !dead3 && npc.timeLeft < 10) - { - for (int num461 = 0; num461 < Main.maxNPCs; num461++) - { - if (num461 != npc.whoAmI && Main.npc[num461].active && (Main.npc[num461].type == NPCID.Retinazer || Main.npc[num461].type == NPCID.Spazmatism)) - npc.DiscourageDespawn(Main.npc[num461].timeLeft - 1); - } - } - - Vector2 vector47 = Vector2.Zero; - if (NPC.IsMechQueenUp) - { - NPC nPC2 = Main.npc[NPC.mechQueen]; - Vector2 mechQueenCenter2 = nPC2.GetMechQueenCenter(); - Vector2 vector48 = new Vector2(150f, -250f); - vector48 *= 0.75f; - float num462 = nPC2.velocity.X * 0.025f; - vector47 = mechQueenCenter2 + vector48; - vector47 = vector47.RotatedBy(num462, mechQueenCenter2); - } - - npc.reflectsProjectiles = false; - if (Main.IsItDay() || dead3) - { - npc.velocity.Y -= 0.04f; - npc.EncourageDespawn(10); - return false; - } - - if (npc.ai[0] == 0f) - { - if (npc.ai[1] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float num463 = 12f; - float num464 = 0.4f; - if (Main.expertMode) - { - num463 = Main.masterMode ? 13.2f : 12.6f; - num464 = Main.masterMode ? 0.48f : 0.44f; - } - - if (Main.getGoodWorld) - { - num463 *= 1.15f; - num464 *= 1.15f; - } - - int num465 = 1; - if (npc.Center.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) - num465 = -1; - - Vector2 vector49 = npc.Center; - float num466 = Main.player[npc.target].Center.X + (float)(num465 * 400) - vector49.X; - float num467 = Main.player[npc.target].Center.Y - vector49.Y; - if (NPC.IsMechQueenUp) - { - num463 = 14f; - num466 = vector47.X; - num467 = vector47.Y; - num466 -= vector49.X; - num467 -= vector49.Y; - } - - float num468 = (float)Math.Sqrt(num466 * num466 + num467 * num467); - float num469 = num468; - if (NPC.IsMechQueenUp) - { - if (num468 > num463) - { - num468 = num463 / num468; - num466 *= num468; - num467 *= num468; - } - - npc.velocity.X = (npc.velocity.X * 4f + num466) / 5f; - npc.velocity.Y = (npc.velocity.Y * 4f + num467) / 5f; - } - else - { - num468 = num463 / num468; - num466 *= num468; - num467 *= num468; - if (npc.velocity.X < num466) - { - npc.velocity.X += num464; - if (npc.velocity.X < 0f && num466 > 0f) - npc.velocity.X += num464; - } - else if (npc.velocity.X > num466) - { - npc.velocity.X -= num464; - if (npc.velocity.X > 0f && num466 < 0f) - npc.velocity.X -= num464; - } - - if (npc.velocity.Y < num467) - { - npc.velocity.Y += num464; - if (npc.velocity.Y < 0f && num467 > 0f) - npc.velocity.Y += num464; - } - else if (npc.velocity.Y > num467) - { - npc.velocity.Y -= num464; - if (npc.velocity.Y > 0f && num467 < 0f) - npc.velocity.Y -= num464; - } - } - - int num470 = 600; - if (NPC.IsMechQueenUp) - num470 = 1200; - - if (Main.masterMode) - num470 = (int)(num470 * 0.75f); - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num470) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - else - { - if (!Main.player[npc.target].dead) - { - npc.ai[3] += 1f; - - if (Main.expertMode) - npc.ai[3] += MathHelper.Lerp(0f, Main.masterMode ? 1.8f : 1.2f, 1f - (npc.life / (float)npc.lifeMax - phase2LifeRatio) / (1f - phase2LifeRatio)); - - if (Main.getGoodWorld) - npc.ai[3] += 0.4f; - } - - if (npc.ai[3] >= 60f) - { - npc.ai[3] = 0f; - vector49 = npc.Center; - num466 = Main.player[npc.target].Center.X - vector49.X; - num467 = Main.player[npc.target].Center.Y - vector49.Y; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float num471 = Main.expertMode ? 14f : 12f; - int type = ProjectileID.CursedFlameHostile; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); - } - - num468 = (float)Math.Sqrt(num466 * num466 + num467 * num467); - num468 = num471 / num468; - num466 *= num468; - num467 *= num468; - int inaccuracy = Main.masterMode ? 10 : Main.expertMode ? 15 : 20; - num466 += (float)Main.rand.Next(-inaccuracy, inaccuracy + 1) * 0.05f; - num467 += (float)Main.rand.Next(-inaccuracy, inaccuracy + 1) * 0.05f; - - Vector2 fireballVelocity = new Vector2(num466, num467); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector49 + fireballVelocity.SafeNormalize(Vector2.UnitY) * 50f, fireballVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - } - else if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.rotation = num458; - float num474 = 13f; - - if (Main.expertMode) - num474 += MathHelper.Lerp(0f, Main.masterMode ? 11.2f : 5.6f, 1f - (npc.life / (float)npc.lifeMax - phase2LifeRatio) / (1f - phase2LifeRatio)); - - if (Main.getGoodWorld) - num474 *= 1.2f; - - Vector2 vector50 = npc.Center; - float num475 = Main.player[npc.target].Center.X - vector50.X; - float num476 = Main.player[npc.target].Center.Y - vector50.Y; - float num477 = (float)Math.Sqrt(num475 * num475 + num476 * num476); - num477 = num474 / num477; - npc.velocity.X = num475 * num477; - npc.velocity.Y = num476 * num477; - npc.ai[1] = 2f; - } - else if (npc.ai[1] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[2] += 1f; - float decelerateGateValue = Main.masterMode ? 12f : Main.expertMode ? 10f : 8f; - if (npc.ai[2] >= decelerateGateValue) - { - // Avoid cheap bullshit - npc.damage = 0; - - float decelerationMultiplier = Main.masterMode ? 0.78f : Main.expertMode ? 0.85f : 0.9f; - npc.velocity *= decelerationMultiplier; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - float delayBeforeChargingAgain = Main.masterMode ? 28f : Main.expertMode ? 34f : 42f; - if (npc.ai[2] >= delayBeforeChargingAgain) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = num458; - float numCharges = Main.masterMode ? 6f : Main.expertMode ? 8f : 10f; - if (npc.ai[3] >= numCharges) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; + NPC.ai[2] = 0f; } else - npc.ai[1] = 1f; + { + SoundEngine.PlaySound(SoundID.NPCHit1, NPC.Center); + + if (!Main.dedServ) + { + for (int i = 0; i < 2; i++) + { + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 144, 1f); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 7, 1f); + Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, new Vector2(Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f), 6, 1f); + } + } + + for (int j = 0; j < 20; j++) + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); + } } + + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + + NPC.velocity *= 0.98f; + if (Math.Abs(NPC.velocity.X) < 0.1) + NPC.velocity.X = 0f; + if (Math.Abs(NPC.velocity.Y) < 0.1) + NPC.velocity.Y = 0f; } - if (npc.life < npc.lifeMax * phase2LifeRatio) + // Phase 2 + else { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; + // If in phase 2 but Ret isn't + bool retInPhase1 = false; + if (CalamityGlobalNPC.laserEye != -1) + { + if (Main.npc[CalamityGlobalNPC.laserEye].active) + retInPhase1 = Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 0f; + } - CalamityTargetingParameters options = CalamityTargetingParameters.BossDefaults; - options.finishThemOff = true; - CalamityUtils.CalamityTargeting(npc, options); + NPC.chaseable = !retInPhase1; - npc.netUpdate = true; + // Increase defense and damage + NPC.damage = (int)Math.Round(NPC.defDamage * SpazmatismPhase2ContactDamageMult); + NPC.defense = NPC.defDefense + 18; + calamityGlobalNPC.DR = retInPhase1 ? 0.9999f : 0.2f; + calamityGlobalNPC.unbreakableDR = retInPhase1; + calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = retInPhase1; + + // Change hit sound to metal + NPC.HitSound = SoundID.NPCHit4; + + // Shadowflamethrower phase + if (NPC.ai[1] == 0f) + { + float maxVelocity = 7.1f + (death ? 0.7f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + float acceleration = 0.118f + (death ? 0.0175f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + + float distanceFromTarget = 180f; + Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitX * distanceFromTarget * direction; + float distanceFromDestination = (destination - NPC.Center).Length(); + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction); + + if (!NPC.IsMechQueenUp) + { + // Boost speed if too far from target + if (distanceFromDestination > distanceFromTarget) + maxVelocity += MathHelper.Lerp(0f, 6f, MathHelper.Clamp((distanceFromDestination - distanceFromTarget) / 1000f, 0f, 1f)); + + if (Main.getGoodWorld) + { + maxVelocity *= 1.15f; + acceleration *= 1.15f; + } + + NPC.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); + } + + // Fire flamethrower for x seconds + NPC.ai[2] += retAlive ? 1f : 2f; + float phaseGateValue = NPC.IsMechQueenUp ? 900f : 180f - (death ? 30f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + if (NPC.ai[2] >= phaseGateValue) + { + NPC.ai[1] = finalPhase ? 5f : 1f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + // Fire fireballs and flamethrower + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + // Play flame sound on timer + NPC.localAI[2] += 1f; + if (NPC.localAI[2] > 22f) + { + NPC.localAI[2] = 0f; + SoundEngine.PlaySound(SoundID.Item34, NPC.Center); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 1f; + if (NPC.localAI[1] > 2f) + { + NPC.ai[3] += 1f; + NPC.localAI[1] = 0f; + + float flamethrowerSpeed = death ? 6.9f : 6f; + float timeForFlamethrowerToReachMaxVelocity = 60f; + float flamethrowerSpeedScalar = MathHelper.Clamp(NPC.ai[2] / timeForFlamethrowerToReachMaxVelocity, 0f, 1f); + flamethrowerSpeed = MathHelper.Lerp(0.1f, flamethrowerSpeed, flamethrowerSpeedScalar); + int type = NPC.ai[3] % 2f == 0f ? ModContent.ProjectileType() : ModContent.ProjectileType(); + + Vector2 flamethrowerVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * flamethrowerSpeed + NPC.velocity * 0.5f; + + if (NPC.IsMechQueenUp) + flamethrowerVelocity = (NPC.rotation + MathHelper.PiOver2).ToRotationVector2() * flamethrowerSpeed + NPC.velocity * 0.5f; + + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 25f, flamethrowerVelocity, type, FlamethrowerDamage.CalculateMechDamage(), 0f, Main.myPlayer); + if (death && NPC.ai[3] % 30f == 0f) + { + type = NPC.ai[3] % 60f == 0f ? ModContent.ProjectileType() : ProjectileID.CursedFlameHostile; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 50f, flamethrowerVelocity * 2f, type, FireballDamage.CalculateMechDamage(), 0f, Main.myPlayer); + } + } + } + } + + if (NPC.IsMechQueenUp) + { + maxVelocity = 14f; + + destination = mechQueenSpacing; + distanceFromDestination = (destination - NPC.Center).Length(); + idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitY); + + if (distanceFromDestination > maxVelocity) + idealVelocity *= maxVelocity / distanceFromDestination; + + float inertia = 60f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + idealVelocity) / inertia; + } + } + + // Charging phase + else + { + // Charge + if (NPC.ai[1] == 1f) + { + // Play charge sound + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); + + // Set rotation and velocity + NPC.rotation = hoverRotation; + + float chargeSpeed = death ? 19.25f + (phase1MaxChargeSpeedIncrease * ((1f - lifeRatio) / (1f - phase2LifeRatio))) : 18f; + if (Main.getGoodWorld) + chargeSpeed *= 1.2f; + + NPC.velocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; + + NPC.ai[1] = 2f; + + return false; + } + + if (NPC.ai[1] == 2f) + { + NPC.ai[2] += retAlive ? 1f : 1.25f; + + float chargeTime = 30f - (death ? 3f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + + // Slow down + if (NPC.ai[2] >= chargeTime) + { + float deceleration = 0.85f - (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + NPC.velocity *= deceleration; + + if (Math.Abs(NPC.velocity.X) < 0.1) + NPC.velocity.X = 0f; + if (Math.Abs(NPC.velocity.Y) < 0.1) + NPC.velocity.Y = 0f; + } + else + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; + + // Charges 5 times + if (NPC.ai[2] >= chargeTime * 1.6f) + { + NPC.ai[3] += 1f; + NPC.ai[2] = 0f; + + NPC.rotation = hoverRotation; + + float totalCharges = 5f; + if (NPC.ai[3] >= totalCharges) + { + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + return false; + } + + NPC.ai[1] = 1f; + } + } + + // Crazy charge + else if (NPC.ai[1] == 3f) + { + // Reset AI array and go to shadowflamethrower phase or fireball phase if ret is dead + float secondFastCharge = 4f; + if (NPC.ai[3] >= (retAlive ? secondFastCharge : secondFastCharge + 1f)) + { + NPC.ai[1] = retAlive ? 0f : 5f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + + if (NPC.ai[1] == 0f) + NPC.localAI[1] = -20f; + + NPC.ForceNetUpdate(false); + } + + // Set charging velocity + else if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Velocity + float spazmatismPhase3ChargeSpeed = (death ? 22.5f : 20f) + (death ? 3f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + if (NPC.ai[2] == -1f || (!retAlive && NPC.ai[3] == secondFastCharge)) + spazmatismPhase3ChargeSpeed *= 1.3f; + if (Main.getGoodWorld) + spazmatismPhase3ChargeSpeed *= 1.2f; + + Vector2 distanceVector = Main.player[NPC.target].Center - NPC.Center; + NPC.velocity = distanceVector.SafeNormalize(Vector2.UnitY) * spazmatismPhase3ChargeSpeed; + + if (retAlive) + { + if (NPC.Distance(Main.player[NPC.target].Center) < 100f) + { + if (Math.Abs(NPC.velocity.X) > Math.Abs(NPC.velocity.Y)) + { + float absoluteSpazXVel = Math.Abs(NPC.velocity.X); + float absoluteSpazYVel = Math.Abs(NPC.velocity.Y); + + if (NPC.Center.X > Main.player[NPC.target].Center.X) + absoluteSpazYVel *= -1f; + if (NPC.Center.Y > Main.player[NPC.target].Center.Y) + absoluteSpazXVel *= -1f; + + NPC.velocity = new Vector2(absoluteSpazYVel, absoluteSpazXVel); + } + } + } + + if (death) + { + float projectileSpeed = spazmatismPhase3ChargeSpeed * 0.5f; + int type = (!retAlive && NPC.ai[3] % 2f == 0f) ? ModContent.ProjectileType() : ProjectileID.CursedFlameHostile; + + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; + int numProj = 3; + int spread = 15; + float rotation = MathHelper.ToRadians(spread); + + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 25f, perturbedSpeed, type, FireballDamage.CalculateMechDamage(), 0f, Main.myPlayer); + } + } + + NPC.ai[1] = 4f; + NPC.ForceNetUpdate(false); + } + } + + // Crazy charge + else if (NPC.ai[1] == 4f) + { + if (NPC.ai[2] == 0f) + SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); + + float spazmatismRetDeadChargeSpeed = ((!retAlive && NPC.ai[3] == 4f) ? 75f : 50f) - (float)Math.Round(death ? ((!retAlive && NPC.ai[3] == 4f) ? 15f : 10f) * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + + NPC.ai[2] += 1f; + + if (NPC.ai[2] == spazmatismRetDeadChargeSpeed && Vector2.Distance(NPC.position, Main.player[NPC.target].position) < (retAlive ? 200f : 150f)) + NPC.ai[2] -= 1f; + + // Slow down + if (NPC.ai[2] >= spazmatismRetDeadChargeSpeed) + { + NPC.velocity *= 0.93f; + if (Math.Abs(NPC.velocity.X) < 0.1) + NPC.velocity.X = 0f; + if (Math.Abs(NPC.velocity.Y) < 0.1) + NPC.velocity.Y = 0f; + } + else + NPC.rotation = NPC.velocity.ToRotation() - MathHelper.PiOver2; + + // Charge 3 times + float spazmatismRetDeadChargeTimer = spazmatismRetDeadChargeSpeed + 25f; + if (NPC.ai[2] >= spazmatismRetDeadChargeTimer) + { + NPC.ForceNetUpdate(false); + + float chargeIncrement = 1f; + if (death && Main.rand.NextBool() && NPC.ai[3] < (retAlive ? 2f : 3f)) + chargeIncrement = 2f; + + NPC.ai[3] += chargeIncrement; + NPC.ai[2] = 0f; + NPC.ai[1] = 3f; + } + } + + // Get in position for charge + else if (NPC.ai[1] == 5f) + { + float chargeLineUpDistance = retAlive ? 600f : 500f; + float chargeSpeed = (death ? 17.5f : 16f) + (death ? 5f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + float chargeAcceleration = (death ? 0.44f : 0.4f) + (death ? 0.1f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + + if (retAlive) + { + chargeSpeed *= 0.75f; + chargeAcceleration *= 0.75f; + } + + if (Main.getGoodWorld) + { + chargeSpeed *= 1.15f; + chargeAcceleration *= 1.15f; + } + + Vector2 destination = Main.player[NPC.target].Center + Vector2.UnitY * chargeLineUpDistance; + Vector2 idealVelocity = (destination - NPC.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; + NPC.SimpleFlyMovement(idealVelocity, chargeAcceleration); + + NPC.ai[2] += 1f; + + // Fire shadowflames and cursed fireballs + float fireRate = retAlive ? 30f : 20f; + if (NPC.ai[2] % fireRate == 0f) + { + NPC.ai[3] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float projectileSpeed = 16f; + int type = NPC.ai[3] % 2f == 0f ? ProjectileID.CursedFlameHostile : ModContent.ProjectileType(); + + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 25f, projectileVelocity, type, FireballDamage.CalculateMechDamage(), 0f, Main.myPlayer, 0f, retAlive ? 0f : 1f); + } + } + + // Take 3 seconds to get in position, then charge + if (NPC.ai[2] >= (retAlive ? 180f : 135f) - (death ? 45f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) + { + NPC.ai[1] = 3f; + NPC.ai[2] = -1f; + NPC.ai[3] = 0f; + } + + NPC.ForceNetUpdate(false); + } + } } return false; } - - if (npc.ai[0] == 1f || npc.ai[0] == 2f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (NPC.IsMechQueenUp) - npc.reflectsProjectiles = true; - - if (npc.ai[0] == 1f) - { - npc.ai[2] += 0.005f; - if ((double)npc.ai[2] > 0.5) - npc.ai[2] = 0.5f; - } - else - { - npc.ai[2] -= 0.005f; - if (npc.ai[2] < 0f) - npc.ai[2] = 0f; - } - - npc.rotation += npc.ai[2]; - - npc.ai[1] += 1f; - if (Main.masterMode && npc.ai[2] >= 0.2f) - { - if (npc.ai[1] % 10f == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ProjectileID.CursedFlameHostile; - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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 = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * 16f + Main.rand.NextVector2CircularEdge(3f, 3f); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f, projectileVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].tileCollide = false; - } - } - } - - if (npc.ai[1] >= 100f) - { - npc.ai[0] += 1f; - npc.ai[1] = 0f; - if (npc.ai[0] == 3f) - { - npc.ai[2] = 0f; - } - else - { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); - for (int num478 = 0; num478 < 2; num478++) - { - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 144); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 7); - Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 6); - } - - for (int num479 = 0; num479 < 20; num479++) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f); - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - } - } - - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f); - - npc.velocity *= 0.98f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - - return false; - } - - npc.HitSound = SoundID.NPCHit4; - int setDamage = (int)Math.Round(npc.defDamage * 1.5); - int reducedSetDamage = (int)Math.Round(setDamage * 0.5); - npc.defense = npc.defDefense + 18; - - if (npc.ai[1] == 0f) - { - // Bites your fucking ass - npc.damage = reducedSetDamage; - - float num480 = 4f; - float num481 = Main.masterMode ? 0.12f : 0.1f; - int num482 = 1; - if (npc.Center.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) - num482 = -1; - - Vector2 vector51 = npc.Center; - int flamethrowerDistance = 180; - float num483 = Main.player[npc.target].Center.X + (float)(num482 * flamethrowerDistance) - vector51.X; - float num484 = Main.player[npc.target].Center.Y - vector51.Y; - float num485 = (float)Math.Sqrt(num483 * num483 + num484 * num484); - if (!NPC.IsMechQueenUp) - { - if (num485 > flamethrowerDistance) - num480 += MathHelper.Lerp(0f, Main.masterMode ? 8f : 6f, MathHelper.Clamp((num485 - flamethrowerDistance) / 1000f, 0f, 1f)); - - if (Main.getGoodWorld) - { - num480 *= 1.15f; - num481 *= 1.15f; - } - - num485 = num480 / num485; - num483 *= num485; - num484 *= num485; - if (npc.velocity.X < num483) - { - npc.velocity.X += num481; - if (npc.velocity.X < 0f && num483 > 0f) - npc.velocity.X += num481; - } - else if (npc.velocity.X > num483) - { - npc.velocity.X -= num481; - if (npc.velocity.X > 0f && num483 < 0f) - npc.velocity.X -= num481; - } - - if (npc.velocity.Y < num484) - { - npc.velocity.Y += num481; - if (npc.velocity.Y < 0f && num484 > 0f) - npc.velocity.Y += num481; - } - else if (npc.velocity.Y > num484) - { - npc.velocity.Y -= num481; - if (npc.velocity.Y > 0f && num484 < 0f) - npc.velocity.Y -= num481; - } - } - - int num486 = 400; - if (NPC.IsMechQueenUp) - num486 = 1200; - - if (Main.masterMode) - num486 = (int)(num486 * 0.8f); - - npc.ai[2] += 1f; - if (npc.ai[2] >= (float)num486) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] > 22f) - { - npc.localAI[2] = 0f; - SoundEngine.PlaySound(SoundID.Item34, npc.Center); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - - npc.localAI[1] += MathHelper.Lerp(0f, 5f, 1f - (npc.life / (float)npc.lifeMax) / phase2LifeRatio); - - if (npc.localAI[1] > 8f) - { - npc.localAI[1] = 0f; - float num487 = 6f + (Main.expertMode ? MathHelper.Lerp(0f, Main.masterMode ? 3f : 1.5f, 1f - (npc.life / (float)npc.lifeMax) / phase2LifeRatio) : 0f); - float timeForFlamethrowerToReachMaxVelocity = 60f; - float flamethrowerSpeedScalar = MathHelper.Clamp(npc.ai[2] / timeForFlamethrowerToReachMaxVelocity, 0f, 1f); - num487 = MathHelper.Lerp(0.1f, num487, flamethrowerSpeedScalar); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Classic; - double secondMechMultiplier = Main.expertMode ? CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert : CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Classic; - 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); - } - - vector51 = npc.Center; - num483 = Main.player[npc.target].Center.X - vector51.X; - num484 = Main.player[npc.target].Center.Y - vector51.Y; - num485 = (float)Math.Sqrt(num483 * num483 + num484 * num484); - num485 = num487 / num485; - num483 *= num485; - num484 *= num485; - int inaccuracy = Main.masterMode ? 10 : Main.expertMode ? 15 : 20; - num484 += (float)Main.rand.Next(-inaccuracy, inaccuracy + 1) * 0.01f; - num483 += (float)Main.rand.Next(-inaccuracy, inaccuracy + 1) * 0.01f; - num484 += npc.velocity.Y * 0.5f; - num483 += npc.velocity.X * 0.5f; - - if (NPC.IsMechQueenUp) - { - Vector2 vector52 = (npc.rotation + (float)Math.PI / 2f).ToRotationVector2() * num487 + npc.velocity * 0.5f; - num483 = vector52.X; - num484 = vector52.Y; - vector51 = npc.Center - vector52 * 3f; - } - - Vector2 flamethrowerVelocity = new Vector2(num483, num484); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector51 + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 50f, flamethrowerVelocity, type, damage, 0f, Main.myPlayer); - } - } - } - - if (NPC.IsMechQueenUp) - { - num480 = 14f; - num483 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector51.X; - num484 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 300f - vector51.Y; - num483 = vector47.X; - num484 = vector47.Y; - num483 -= vector51.X; - num484 -= vector51.Y; - num485 = (float)Math.Sqrt(num483 * num483 + num484 * num484); - if (num485 > num480) - { - num485 = num480 / num485; - num483 *= num485; - num484 *= num485; - } - - int num490 = 60; - npc.velocity.X = (npc.velocity.X * (float)(num490 - 1) + num483) / (float)num490; - npc.velocity.Y = (npc.velocity.Y * (float)(num490 - 1) + num484) / (float)num490; - } - } - else if (npc.ai[1] == 1f) - { - // Set damage - npc.damage = setDamage; - - SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); - npc.rotation = num458; - float num491 = 14f; - if (Main.expertMode) - num491 += 2.5f; - if (Main.masterMode) - num491 += 3.5f; - - Vector2 vector53 = npc.Center; - float num492 = Main.player[npc.target].Center.X - vector53.X; - float num493 = Main.player[npc.target].Center.Y - vector53.Y; - float num494 = (float)Math.Sqrt(num492 * num492 + num493 * num493); - num494 = num491 / num494; - npc.velocity.X = num492 * num494; - npc.velocity.Y = num493 * num494; - npc.ai[1] = 2f; - } - else - { - if (npc.ai[1] != 2f) - return false; - - // Set damage - npc.damage = setDamage; - - npc.ai[2] += 1f; - if (Main.expertMode) - npc.ai[2] += 0.5f; - if (Main.masterMode) - npc.ai[2] += 0.5f; - - if (npc.ai[2] >= 50f) - { - // Bites your fucking ass - npc.damage = reducedSetDamage; - - npc.velocity *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) - npc.velocity.Y = 0f; - } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - - if (npc.ai[2] >= 80f) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.rotation = num458; - float numCharges = Main.masterMode ? Main.rand.Next(4, 7) : 6f; - if (npc.ai[3] >= numCharges) - { - npc.ai[1] = 0f; - npc.ai[3] = 0f; - } - else - npc.ai[1] = 1f; - - // Due to the random number of charges in Master Mode - if (Main.masterMode) - npc.netUpdate = true; - } - } - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs index 9b0df45190..0dca2a085f 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs @@ -1,42 +1,48 @@ using System; using CalamityMod.Events; +using CalamityMod.ExtraTextures; 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; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { - public static class WallOfFleshAI + public class WallOfFleshAI : VanillaAIOverride { public const float LaserShootGateValue = 400f; public const float LaserShootTelegraphTime = LaserShootGateValue * 0.5f; public const float TotalLasersPerBarrage = 3f; public const float EnragedLaserFiringDuration = 300f; - public static bool BuffedWallofFleshAI(NPC npc, Mod mod) - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + // Rev+ exclusive + public static int LaserDamage = 15; // 60 (modified to be always at maximum Expert damage and does not scale) + public static int SickleDamage = 22; // 88 - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + public override bool AI(Mod mod) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; // Despawn - if (npc.position.X < 160f || npc.position.X > ((Main.maxTilesX - 10) * 16)) - npc.active = false; + if (NPC.position.X < 160f || NPC.position.X > ((Main.maxTilesX - 10) * 16)) + NPC.active = false; // Set Wall of Flesh variables - if (npc.localAI[0] == 0f) + if (NPC.localAI[0] == 0f) { - npc.localAI[0] = 1f; + NPC.localAI[0] = 1f; Main.wofDrawAreaBottom = -1; Main.wofDrawAreaTop = -1; } // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + float lifeRatio = NPC.life / (float)NPC.lifeMax; // Clamp life ratio to prevent bad velocity math. lifeRatio = MathHelper.Clamp(lifeRatio, 0f, 1f); @@ -51,12 +57,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { for (int i = 0; i < 1000; i++) { - int targetTileX = (int)(npc.Center.X / 16f); - int targetTileY = (int)(npc.Center.Y / 16f); - if (npc.target >= 0) + int targetTileX = (int)(NPC.Center.X / 16f); + int targetTileY = (int)(NPC.Center.Y / 16f); + if (NPC.target >= 0) { - targetTileX = (int)(Main.player[npc.target].Center.X / 16f); - targetTileY = (int)(Main.player[npc.target].Center.Y / 16f); + targetTileX = (int)(Main.player[NPC.target].Center.X / 16f); + targetTileY = (int)(Main.player[NPC.target].Center.Y / 16f); } targetTileX += Main.rand.Next(-50, 51); @@ -67,7 +73,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses targetTileY--; if (!WorldGen.SolidTile(targetTileX, targetTileY)) { - int impSpawn = NPC.NewNPC(npc.GetSource_FromAI(), targetTileX * 16 + 8, targetTileY * 16, NPCID.FireImp); + int impSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), targetTileX * 16 + 8, targetTileY * 16, NPCID.FireImp); if (Main.dedServ && impSpawn < Main.maxNPCs) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, impSpawn); @@ -78,94 +84,70 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Start leech spawning based on HP - npc.ai[1] += 1f; - if (npc.ai[2] == 0f) + NPC.ai[1] += 1f; + if (NPC.ai[2] == 0f) { if (death) - npc.ai[1] += 2f; + NPC.ai[1] += 1f; if (phase2) - npc.ai[1] += 1f; + NPC.ai[1] += 1f; if (phase3) - npc.ai[1] += 1f; - if (bossRush) - npc.ai[1] += 3f; - if (CalamityWorld.LegendaryMode) - npc.ai[1] += 9f; + NPC.ai[1] += 1f; + if (Main.getGoodWorld) + NPC.ai[1] += 9f; - if (npc.ai[1] > 2700f) - npc.ai[2] = 1f; + if (NPC.ai[1] > 2700f) + NPC.ai[2] = 1f; } // Leech spawn - if (npc.ai[2] > 0f && npc.ai[1] > 60f) + if (NPC.ai[2] > 0f && NPC.ai[1] > 60f) { int leechAmt = phase3 ? 3 : 2; - npc.ai[2] += 1f; - npc.ai[1] = 0f; - if (npc.ai[2] > leechAmt) - npc.ai[2] = 0f; + NPC.ai[2] += 1f; + NPC.ai[1] = 0f; + if (NPC.ai[2] > leechAmt) + NPC.ai[2] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { if (NPC.CountNPCS(NPCID.LeechHead) < 10) { - int leechSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.Center.Y + 20f), NPCID.LeechHead, 1); + int leechSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.Center.X), (int)(NPC.Center.Y + 20f), NPCID.LeechHead, 1); int leechVelocity = death ? 12 : 9; - Main.npc[leechSpawn].velocity.X = npc.direction * leechVelocity; + Main.npc[leechSpawn].velocity.X = NPC.direction * leechVelocity; } if (phase2 || death) { // Get target vector - Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * npc.velocity.Length(); - Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * NPC.velocity.Length(); + Vector2 projectileSpawn = NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 50f; - int damage = npc.GetProjectileDamage(ProjectileID.DemonSickle); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, ProjectileID.DemonSickle, damage, 0f, Main.myPlayer, 0f, projectileVelocity.Length() * 3f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, ProjectileID.DemonSickle, SickleDamage, 0f, Main.myPlayer, 0f, projectileVelocity.Length() * 3f); Main.projectile[proj].timeLeft = 600; Main.projectile[proj].tileCollide = false; - - if (death) - { - float fireballVelocity = npc.velocity.Length() + 3f; - projectileVelocity = projectileVelocity.SafeNormalize(Vector2.UnitY) * fireballVelocity; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ProjectileID.Fireball; - damage = npc.GetProjectileDamage(type); - int numProj = 3; - int spread = 15; - float rotation = MathHelper.ToRadians(spread); - fireballVelocity *= 0.1f; - for (int j = 0; j < numProj; j++) - { - Vector2 randomVelocity = Main.rand.NextVector2CircularEdge(fireballVelocity, fireballVelocity); - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))) + randomVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 50f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } - } - } } } } // Play sound - npc.localAI[3] += 1f; - if (npc.localAI[3] >= (600 + Main.rand.Next(1000))) + NPC.localAI[3] += 1f; + if (NPC.localAI[3] >= (600 + Main.rand.Next(1000))) { - npc.localAI[3] = -Main.rand.Next(200); - SoundEngine.PlaySound(SoundID.NPCDeath10, npc.Center); + NPC.localAI[3] = -Main.rand.Next(200); + SoundEngine.PlaySound(SoundID.NPCDeath10, NPC.Center); } // Set whoAmI variable - Main.wofNPCIndex = npc.whoAmI; + Main.wofNPCIndex = NPC.whoAmI; // Set eye positions - int currentEyeTileCenterX = (int)(npc.position.X / 16f); - int currentEyeTileWidthX = (int)((npc.position.X + npc.width) / 16f); - int currentEyeTileHeightY = (int)(npc.Center.Y / 16f); + int currentEyeTileCenterX = (int)(NPC.position.X / 16f); + int currentEyeTileWidthX = (int)((NPC.position.X + NPC.width) / 16f); + int currentEyeTileHeightY = (int)(NPC.Center.Y / 16f); int eyeMovementTries = 0; int eyeMovementTileY = currentEyeTileHeightY + 7; while (eyeMovementTries < 15 && eyeMovementTileY > Main.UnderworldLayer) @@ -231,18 +213,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Set Y position - float mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2 - npc.height / 2; + float mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2 - NPC.height / 2; int worldBottomTileY = (Main.maxTilesY - 180) * 16; if (mouthYPosition < worldBottomTileY) mouthYPosition = worldBottomTileY; - npc.position.Y = mouthYPosition; + NPC.position.Y = mouthYPosition; - float targetPosition = Main.player[npc.target].Center.X; - float npcPosition = npc.Center.X; + float targetPosition = Main.player[NPC.target].Center.X; + float npcPosition = NPC.Center.X; // Speed up if target is too far, slow down if too close float distanceFromTarget; - if (npc.velocity.X < 0f) + if (NPC.velocity.X < 0f) distanceFromTarget = npcPosition - targetPosition; else distanceFromTarget = targetPosition - npcPosition; @@ -252,9 +234,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float timeBeforeEnrage = death ? (150f - 130f * (1f - lifeRatio)) : 600f; float speedMult = 1f; - if (bossRush) - timeBeforeEnrage *= 0.25f; - if (calamityGlobalNPC.newAI[0] < timeBeforeEnrage) { if (distanceFromTarget > halfAverageScreenWidth) @@ -268,10 +247,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses calamityGlobalNPC.newAI[1] = 1f; // Tell eyes to fire different lasers - npc.ai[3] = 1f; + NPC.ai[3] = 1f; // Play roar sound on players nearby - if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, npc.Center) < 2800f) + if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < 2800f) SoundEngine.PlaySound(SoundID.NPCDeath10 with { Pitch = SoundID.NPCDeath10.Pitch - 0.25f }, Main.LocalPlayer.Center); } } @@ -298,34 +277,31 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { calamityGlobalNPC.newAI[0] = 0f; calamityGlobalNPC.newAI[1] = 0f; - npc.ai[3] = 0f; + NPC.ai[3] = 0f; } } - calamityGlobalNPC.CurrentlyEnraged = distanceFromTarget > halfAverageScreenWidth || npc.ai[3] == 1f; + calamityGlobalNPC.CurrentlyEnraged = distanceFromTarget > halfAverageScreenWidth || NPC.ai[3] == 1f; - if (bossRush) - speedMult += 0.2f; - - float masterModeVelocityBoost = 0f; + float deathModeVelocityBoost = 0f; if (death) { float velocityBoostStartDistance = distanceBeforeSlowingDown; float velocityBoostMaxDistance = velocityBoostStartDistance * 1.5f; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); + float distanceFromTargetX = Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X); float lerpAmount = MathHelper.Clamp((distanceFromTargetX - velocityBoostStartDistance) / velocityBoostMaxDistance, 0f, 1f); - masterModeVelocityBoost = MathHelper.Lerp(0f, 8f, lerpAmount); + deathModeVelocityBoost = MathHelper.Lerp(0f, 4f, lerpAmount); } // NOTE: Max velocity is 8 in Expert Mode // NOTE: Max velocity is 9 in For The Worthy float velocityBoost = 4f * (1f - lifeRatio); - float velocityX = (bossRush ? 7f : death ? 3.5f : 2f) + masterModeVelocityBoost + velocityBoost; + float velocityX = 2f + deathModeVelocityBoost + velocityBoost; velocityX *= speedMult; if (death) - velocityX *= 1.2f; + velocityX *= 1.1f; if (Main.getGoodWorld) { @@ -339,85 +315,85 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Max velocity with enrage is 18 // Set X velocity - if (npc.velocity.X == 0f) + if (NPC.velocity.X == 0f) { - npc.TargetClosest(); - if (Main.player[npc.target].dead) + NPC.TargetClosest(); + if (Main.player[NPC.target].dead) { float wallVelocity = float.PositiveInfinity; int wallDirection = 0; for (int i = 0; i < Main.maxPlayers; i++) { - Player player = Main.player[npc.target]; + Player player = Main.player[NPC.target]; if (player.active) { - float playerDist = npc.Distance(player.Center); + float playerDist = NPC.Distance(player.Center); if (wallVelocity > playerDist) { wallVelocity = playerDist; - wallDirection = (npc.Center.X < player.Center.X) ? 1 : -1; + wallDirection = (NPC.Center.X < player.Center.X) ? 1 : -1; } } } - npc.direction = wallDirection; + NPC.direction = wallDirection; } - npc.velocity.X = npc.direction; + NPC.velocity.X = NPC.direction; } - if (npc.velocity.X < 0f) + if (NPC.velocity.X < 0f) { - npc.velocity.X = -velocityX; - npc.direction = -1; + NPC.velocity.X = -velocityX; + NPC.direction = -1; } else { - npc.velocity.X = velocityX; - npc.direction = 1; + NPC.velocity.X = velocityX; + NPC.direction = 1; } - if (Main.player[npc.target].dead || !Main.player[npc.target].gross) - npc.TargetClosest_WOF(); + if (Main.player[NPC.target].dead || !Main.player[NPC.target].gross) + NPC.TargetClosest_WOF(); - if (Main.player[npc.target].dead) + if (Main.player[NPC.target].dead) { - npc.localAI[1] += 0.0055555557f; - if (npc.localAI[1] >= 1f) + NPC.localAI[1] += 0.0055555557f; + if (NPC.localAI[1] >= 1f) { - SoundEngine.PlaySound(SoundID.NPCDeath10, npc.Center); - npc.life = 0; - npc.active = false; + SoundEngine.PlaySound(SoundID.NPCDeath10, NPC.Center); + NPC.life = 0; + NPC.active = false; if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f); return false; } } else - npc.localAI[1] = MathHelper.Clamp(npc.localAI[1] - 1f / 30f, 0f, 1f); + NPC.localAI[1] = MathHelper.Clamp(NPC.localAI[1] - 1f / 30f, 0f, 1f); // Direction - npc.spriteDirection = npc.direction; - Vector2 mouthLocation = npc.Center; - float mouthTargetX = Main.player[npc.target].Center.X - mouthLocation.X; - float mouthTargetY = Main.player[npc.target].Center.Y - mouthLocation.Y; + NPC.spriteDirection = NPC.direction; + Vector2 mouthLocation = NPC.Center; + float mouthTargetX = Main.player[NPC.target].Center.X - mouthLocation.X; + float mouthTargetY = Main.player[NPC.target].Center.Y - mouthLocation.Y; float mouthTargetDist = (float)Math.Sqrt(mouthTargetX * mouthTargetX + mouthTargetY * mouthTargetY); mouthTargetX *= mouthTargetDist; mouthTargetY *= mouthTargetDist; // Rotation based on direction - if (npc.direction > 0) + if (NPC.direction > 0) { - if (Main.player[npc.target].Center.X > npc.Center.X) - npc.rotation = (float)Math.Atan2(-mouthTargetY, -mouthTargetX) + MathHelper.Pi; + if (Main.player[NPC.target].Center.X > NPC.Center.X) + NPC.rotation = (float)Math.Atan2(-mouthTargetY, -mouthTargetX) + MathHelper.Pi; else - npc.rotation = 0f; + NPC.rotation = 0f; } - else if (Main.player[npc.target].Center.X < npc.Center.X) - npc.rotation = (float)Math.Atan2(mouthTargetY, mouthTargetX) + MathHelper.Pi; + else if (Main.player[NPC.target].Center.X < NPC.Center.X) + NPC.rotation = (float)Math.Atan2(mouthTargetY, mouthTargetX) + MathHelper.Pi; else - npc.rotation = 0f; + NPC.rotation = 0f; // Expert hungry respawn over time if (Main.netMode != NetmodeID.MultiplayerClient) @@ -439,9 +415,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Range of 64 to 268 chance *= 2; - if (bossRush) - chance /= 4; - else if (death) + if (death) chance /= 2; if (chance < 2) @@ -449,7 +423,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.rand.NextBool(chance)) { - int maxHungriesBasedOnHP = (int)Math.Round(MathHelper.Lerp(death ? 2f : 1f, death ? 8f : 4f, npc.life / (float)npc.lifeMax)); + int maxHungriesBasedOnHP = (int)Math.Round(MathHelper.Lerp(death ? 2f : 1f, death ? 6f : 4f, NPC.life / (float)NPC.lifeMax)); if (NPC.CountNPCS(NPCID.TheHungry) < maxHungriesBasedOnHP) { int hungryAmt = 0; @@ -495,7 +469,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } if (spawnHungryControl >= 0) { - int hungryRespawns = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.TheHungry, npc.whoAmI); + int hungryRespawns = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X, (int)mouthYPosition, NPCID.TheHungry, NPC.whoAmI); Main.npc[hungryRespawns].ai[0] = spawnHungryControl * 0.1f - 0.05f; } } @@ -504,20 +478,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Spawn eyes and hungries - if (npc.localAI[0] == 1f && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.localAI[0] == 1f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] = 2f; + NPC.localAI[0] = 2f; mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; mouthYPosition = (mouthYPosition + Main.wofDrawAreaTop) / 2f; - int eyeSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.WallofFleshEye, npc.whoAmI); + int eyeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X, (int)mouthYPosition, NPCID.WallofFleshEye, NPC.whoAmI); Main.npc[eyeSpawn].ai[0] = 1f; if (death) Main.npc[eyeSpawn].ai[3] = 1f; mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; mouthYPosition = (mouthYPosition + Main.wofDrawAreaBottom) / 2f; - eyeSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.WallofFleshEye, npc.whoAmI); + eyeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X, (int)mouthYPosition, NPCID.WallofFleshEye, NPC.whoAmI); Main.npc[eyeSpawn].ai[0] = -1f; if (death) Main.npc[eyeSpawn].ai[3] = -1f; @@ -525,11 +499,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses mouthYPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; mouthYPosition = (mouthYPosition + Main.wofDrawAreaBottom) / 2f; - int maxHungries = death ? 16 : 11; + int maxHungries = death ? 14 : 11; float maxOffset = death ? (0.2f / 3f) : 0.1f; for (int j = 0; j < maxHungries; j++) { - int hungrySpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)mouthYPosition, NPCID.TheHungry, npc.whoAmI); + int hungrySpawn = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X, (int)mouthYPosition, NPCID.TheHungry, NPC.whoAmI); Main.npc[hungrySpawn].ai[0] = j * maxOffset - 0.05f; } } @@ -537,998 +511,403 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - public static bool BuffedHungryAI(NPC npc, Mod mod) + public class HungryAI : VanillaAIOverride { - if (npc.justHit) - npc.ai[1] = 10f; - - if (Main.wofNPCIndex < 0) + public override bool AI(Mod mod) { - npc.active = false; + if (NPC.justHit) + NPC.ai[1] = 10f; + + if (Main.wofNPCIndex < 0) + { + NPC.active = false; + return false; + } + + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + CalamityUtils.CalamityTargeting(NPC, default); + float acceleration = death ? 0.15f : 0.12f; + float distanceFromWall = 300f; + NPC.damage = NPC.defDamage; + NPC.defense = NPC.defDefense; + if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.5) + { + NPC.damage = NPC.defDamage * 2; + NPC.defense = 30; + acceleration += death ? 0.1f : 0.08f; + } + else if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.75) + { + NPC.damage = (int)Math.Round(NPC.defDamage * 1.5f); + NPC.defense = 20; + acceleration += death ? 0.05f : 0.04f; + } + + if (NPC.whoAmI % 4 == 0) + distanceFromWall *= 1.75f; + + if (NPC.whoAmI % 4 == 1) + distanceFromWall *= 1.5f; + + if (NPC.whoAmI % 4 == 2) + distanceFromWall *= 1.25f; + + if (NPC.whoAmI % 3 == 0) + distanceFromWall *= 1.5f; + + if (NPC.whoAmI % 3 == 1) + distanceFromWall *= 1.25f; + + distanceFromWall *= 0.75f; + + float num404 = Main.npc[Main.wofNPCIndex].Center.X; + float y3 = Main.npc[Main.wofNPCIndex].position.Y; + float num405 = Main.wofDrawAreaBottom - Main.wofDrawAreaTop; + y3 = (float)Main.wofDrawAreaTop + num405 * NPC.ai[0]; + NPC.ai[2] += 1f; + if (NPC.ai[2] > 100f) + { + distanceFromWall = (int)(distanceFromWall * 1.3f); + if (NPC.ai[2] > 200f) + NPC.ai[2] = 0f; + } + + Vector2 vector40 = new Vector2(num404, y3); + float num406 = Main.player[NPC.target].Center.X - (float)(NPC.width / 2) - vector40.X; + float num407 = Main.player[NPC.target].Center.Y - (float)(NPC.height / 2) - vector40.Y; + float num408 = (float)Math.Sqrt(num406 * num406 + num407 * num407); + if (NPC.ai[1] == 0f) + { + if (num408 > distanceFromWall) + { + num408 = distanceFromWall / num408; + num406 *= num408; + num407 *= num408; + } + + if (NPC.position.X < num404 + num406) + { + NPC.velocity.X += acceleration; + if (NPC.velocity.X < 0f && num406 > 0f) + NPC.velocity.X += acceleration * 2.5f; + } + else if (NPC.position.X > num404 + num406) + { + NPC.velocity.X -= acceleration; + if (NPC.velocity.X > 0f && num406 < 0f) + NPC.velocity.X -= acceleration * 2.5f; + } + + if (NPC.position.Y < y3 + num407) + { + NPC.velocity.Y += acceleration; + if (NPC.velocity.Y < 0f && num407 > 0f) + NPC.velocity.Y += acceleration * 2.5f; + } + else if (NPC.position.Y > y3 + num407) + { + NPC.velocity.Y -= acceleration; + if (NPC.velocity.Y > 0f && num407 < 0f) + NPC.velocity.Y -= acceleration * 2.5f; + } + + float maxVelocity = 4f; + if (Main.wofNPCIndex >= 0) + { + float velocityBoost = 1.5f; + float wallLifeRatio = Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; + if (wallLifeRatio < 0.75f) + velocityBoost += 0.7f; + + if (wallLifeRatio < 0.5f) + velocityBoost += 0.7f; + + if (wallLifeRatio < 0.25f) + velocityBoost += 0.9f; + + if (wallLifeRatio < 0.1f) + velocityBoost += 0.9f; + + velocityBoost *= death ? 1.4f : 1.25f; + velocityBoost += 0.3f; + maxVelocity += velocityBoost * 0.35f; + if (NPC.Center.X < Main.npc[Main.wofNPCIndex].Center.X && Main.npc[Main.wofNPCIndex].velocity.X > 0f) + maxVelocity += 6f; + + if (NPC.Center.X > Main.npc[Main.wofNPCIndex].Center.X && Main.npc[Main.wofNPCIndex].velocity.X < 0f) + maxVelocity += 6f; + } + + if (NPC.velocity.X > maxVelocity) + NPC.velocity.X = maxVelocity; + + if (NPC.velocity.X < -maxVelocity) + NPC.velocity.X = -maxVelocity; + + if (NPC.velocity.Y > maxVelocity) + NPC.velocity.Y = maxVelocity; + + if (NPC.velocity.Y < -maxVelocity) + NPC.velocity.Y = -maxVelocity; + } + else if (NPC.ai[1] > 0f) + NPC.ai[1] -= 1f; + else + NPC.ai[1] = 0f; + + if (num406 > 0f) + { + NPC.spriteDirection = 1; + NPC.rotation = (float)Math.Atan2(num407, num406); + } + + if (num406 < 0f) + { + NPC.spriteDirection = -1; + NPC.rotation = (float)Math.Atan2(num407, num406) + MathHelper.Pi; + } + + Lighting.AddLight(NPC.Center, 0.3f, 0.2f, 0.1f); + return false; } - - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - - CalamityUtils.CalamityTargeting(npc, default); - float acceleration = death ? 0.15f : 0.12f; - float distanceFromWall = 300f; - npc.damage = npc.defDamage; - npc.defense = npc.defDefense; - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.5) - { - npc.damage = death ? 180 : 120; - npc.defense = 30; - acceleration += death ? 0.1f : 0.08f; - } - else if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.75) - { - npc.damage = death ? 135 : 90; - npc.defense = 20; - acceleration += death ? 0.05f : 0.04f; - } - - if (npc.whoAmI % 4 == 0) - distanceFromWall *= 1.75f; - - if (npc.whoAmI % 4 == 1) - distanceFromWall *= 1.5f; - - if (npc.whoAmI % 4 == 2) - distanceFromWall *= 1.25f; - - if (npc.whoAmI % 3 == 0) - distanceFromWall *= 1.5f; - - if (npc.whoAmI % 3 == 1) - distanceFromWall *= 1.25f; - - distanceFromWall *= 0.75f; - - float num404 = Main.npc[Main.wofNPCIndex].Center.X; - float y3 = Main.npc[Main.wofNPCIndex].position.Y; - float num405 = Main.wofDrawAreaBottom - Main.wofDrawAreaTop; - y3 = (float)Main.wofDrawAreaTop + num405 * npc.ai[0]; - npc.ai[2] += 1f; - if (npc.ai[2] > 100f) - { - distanceFromWall = (int)(distanceFromWall * 1.3f); - if (npc.ai[2] > 200f) - npc.ai[2] = 0f; - } - - Vector2 vector40 = new Vector2(num404, y3); - float num406 = Main.player[npc.target].Center.X - (float)(npc.width / 2) - vector40.X; - float num407 = Main.player[npc.target].Center.Y - (float)(npc.height / 2) - vector40.Y; - float num408 = (float)Math.Sqrt(num406 * num406 + num407 * num407); - if (npc.ai[1] == 0f) - { - if (num408 > distanceFromWall) - { - num408 = distanceFromWall / num408; - num406 *= num408; - num407 *= num408; - } - - if (npc.position.X < num404 + num406) - { - npc.velocity.X += acceleration; - if (npc.velocity.X < 0f && num406 > 0f) - npc.velocity.X += acceleration * 2.5f; - } - else if (npc.position.X > num404 + num406) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X > 0f && num406 < 0f) - npc.velocity.X -= acceleration * 2.5f; - } - - if (npc.position.Y < y3 + num407) - { - npc.velocity.Y += acceleration; - if (npc.velocity.Y < 0f && num407 > 0f) - npc.velocity.Y += acceleration * 2.5f; - } - else if (npc.position.Y > y3 + num407) - { - npc.velocity.Y -= acceleration; - if (npc.velocity.Y > 0f && num407 < 0f) - npc.velocity.Y -= acceleration * 2.5f; - } - - float maxVelocity = 4f; - if (Main.wofNPCIndex >= 0) - { - float velocityBoost = 1.5f; - float wallLifeRatio = Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; - if (wallLifeRatio < 0.75f) - velocityBoost += 0.7f; - - if (wallLifeRatio < 0.5f) - velocityBoost += 0.7f; - - if (wallLifeRatio < 0.25f) - velocityBoost += 0.9f; - - if (wallLifeRatio < 0.1f) - velocityBoost += 0.9f; - - velocityBoost *= death ? 1.5f : 1.25f; - velocityBoost += 0.3f; - maxVelocity += velocityBoost * 0.35f; - if (npc.Center.X < Main.npc[Main.wofNPCIndex].Center.X && Main.npc[Main.wofNPCIndex].velocity.X > 0f) - maxVelocity += 6f; - - if (npc.Center.X > Main.npc[Main.wofNPCIndex].Center.X && Main.npc[Main.wofNPCIndex].velocity.X < 0f) - maxVelocity += 6f; - } - - if (npc.velocity.X > maxVelocity) - npc.velocity.X = maxVelocity; - - if (npc.velocity.X < -maxVelocity) - npc.velocity.X = -maxVelocity; - - if (npc.velocity.Y > maxVelocity) - npc.velocity.Y = maxVelocity; - - if (npc.velocity.Y < -maxVelocity) - npc.velocity.Y = -maxVelocity; - } - else if (npc.ai[1] > 0f) - npc.ai[1] -= 1f; - else - npc.ai[1] = 0f; - - if (num406 > 0f) - { - npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2(num407, num406); - } - - if (num406 < 0f) - { - npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2(num407, num406) + MathHelper.Pi; - } - - Lighting.AddLight(npc.Center, 0.3f, 0.2f, 0.1f); - - return false; } - public static bool BuffedWallofFleshEyeAI(NPC npc, Mod mod) + public class EyeAI : VanillaAIOverride { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - - // Avoid cheap bullshit - npc.damage = 0; - - // Despawn - if (Main.wofNPCIndex < 0) + public override bool AI(Mod mod) { - npc.active = false; - return false; - } + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); - npc.realLife = Main.wofNPCIndex; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (Main.npc[Main.wofNPCIndex].life > 0) - npc.life = Main.npc[Main.wofNPCIndex].life; + // Avoid cheap bullshit + NPC.damage = 0; - // Percent life remaining - float lifeRatio = Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.target = Main.npc[Main.wofNPCIndex].target; - - // Velocity, direction, and position - bool shouldFireLasers = true; - float phase2LifeRatio = 0.5f; - bool masterModeDetach = lifeRatio < phase2LifeRatio && death; - bool canHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - if (!masterModeDetach) - { - npc.position.X = Main.npc[Main.wofNPCIndex].position.X; - npc.direction = Main.npc[Main.wofNPCIndex].direction; - npc.spriteDirection = npc.direction; - - float expectedPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; - if (npc.ai[0] > 0f) - expectedPosition = (expectedPosition + Main.wofDrawAreaTop) / 2f; - else - expectedPosition = (expectedPosition + Main.wofDrawAreaBottom) / 2f; - expectedPosition -= npc.height / 2; - - bool belowExpectedPosition = npc.position.Y > expectedPosition + 1f; - bool aboveExpectedPosition = npc.position.Y < expectedPosition - 1f; - if (belowExpectedPosition) + // Despawn + if (Main.wofNPCIndex < 0) { - float distanceBelowExpectedPosition = npc.position.Y - expectedPosition + 1f; - float movementVelocity = MathHelper.Clamp(distanceBelowExpectedPosition * 0.03125f, 1f, 5f); - npc.velocity.Y = -movementVelocity; - } - else if (aboveExpectedPosition) - { - float distanceAboveExpectedPosition = expectedPosition - 1f - npc.position.Y; - float movementVelocity = MathHelper.Clamp(distanceAboveExpectedPosition * 0.03125f, 1f, 5f); - npc.velocity.Y = movementVelocity; - } - else - { - npc.velocity.Y = 0f; - npc.position.Y = expectedPosition; - } - } - else - { - float distanceAboveTarget = (canHit ? 240f : 120f) * npc.ai[0]; - float distanceAwayFromTargetX = 560f; - float distanceAwayFromTargetXLeeway = 40f; - float distanceAwayFromTargetY = Main.player[npc.target].Center.Y - npc.Center.Y; - float distanceAwayFromTargetYLeeway = 40f; - float absoluteDistanceX = Math.Abs(Main.player[npc.target].Center.X - npc.Center.X); - bool tooFarX = absoluteDistanceX > distanceAwayFromTargetX + distanceAwayFromTargetXLeeway || absoluteDistanceX < distanceAwayFromTargetX - distanceAwayFromTargetXLeeway; - bool tooFarY = distanceAwayFromTargetY > distanceAboveTarget + distanceAwayFromTargetYLeeway || distanceAwayFromTargetY < distanceAboveTarget - distanceAwayFromTargetYLeeway; - bool tooFar = tooFarX || tooFarY; - Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * distanceAboveTarget + Vector2.UnitX * distanceAwayFromTargetX * npc.ai[3]; - if (tooFar) - { - Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * 16f; - npc.SimpleFlyMovement(idealVelocity, 0.36f); + NPC.active = false; + return false; } - if (npc.Distance(Main.player[npc.target].Center) < distanceAwayFromTargetX || npc.Distance(hoverDestination) > 120f) - shouldFireLasers = false; + NPC.realLife = Main.wofNPCIndex; - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0f ? 1 : -1; - npc.spriteDirection = npc.direction; + if (Main.npc[Main.wofNPCIndex].life > 0) + NPC.life = Main.npc[Main.wofNPCIndex].life; - if (npc.ai[1] == 0f) + // Percent life remaining + float lifeRatio = Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.target = Main.npc[Main.wofNPCIndex].target; + + // Velocity, direction, and position + bool shouldFireLasers = true; + float phase2LifeRatio = 0.4f; + bool deathModeDetach = lifeRatio < phase2LifeRatio && death; + bool canHit = Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + if (!deathModeDetach) { - npc.ai[1] = 1f; - SoundEngine.PlaySound(SoundID.NPCDeath12, npc.Center); - for (int i = 0; i < 100; i++) + NPC.position.X = Main.npc[Main.wofNPCIndex].position.X; + NPC.direction = Main.npc[Main.wofNPCIndex].direction; + NPC.spriteDirection = NPC.direction; + + float expectedPosition = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; + if (NPC.ai[0] > 0f) + expectedPosition = (expectedPosition + Main.wofDrawAreaTop) / 2f; + else + expectedPosition = (expectedPosition + Main.wofDrawAreaBottom) / 2f; + expectedPosition -= NPC.height / 2; + + bool belowExpectedPosition = NPC.position.Y > expectedPosition + 1f; + bool aboveExpectedPosition = NPC.position.Y < expectedPosition - 1f; + if (belowExpectedPosition) { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, npc.velocity.X, npc.velocity.Y); - Main.dust[dust].scale = Main.rand.NextFloat(1.5f, 4f); - Main.dust[dust].velocity *= Main.rand.NextFloat(0.5f, 1.5f); + float distanceBelowExpectedPosition = NPC.position.Y - expectedPosition + 1f; + float movementVelocity = MathHelper.Clamp(distanceBelowExpectedPosition * 0.03125f, 1f, 5f); + NPC.velocity.Y = -movementVelocity; + } + else if (aboveExpectedPosition) + { + float distanceAboveExpectedPosition = expectedPosition - 1f - NPC.position.Y; + float movementVelocity = MathHelper.Clamp(distanceAboveExpectedPosition * 0.03125f, 1f, 5f); + NPC.velocity.Y = movementVelocity; + } + else + { + NPC.velocity.Y = 0f; + NPC.position.Y = expectedPosition; } } - - // 50% chance to change Y position - float eyePositionRandomChangeGateValue = MathHelper.Lerp(death ? 180f : 240f, death ? 480f : 720f, lifeRatio / phase2LifeRatio); - if (npc.ai[2] >= eyePositionRandomChangeGateValue) + else { - npc.ai[2] = 0f; - npc.ai[0] = Main.rand.NextBool() ? 1f : -1f; - npc.netUpdate = true; + float distanceAboveTarget = (canHit ? 240f : 120f) * NPC.ai[0]; + float distanceAwayFromTargetX = 560f; + float distanceAwayFromTargetXLeeway = 40f; + float distanceAwayFromTargetY = Main.player[NPC.target].Center.Y - NPC.Center.Y; + float distanceAwayFromTargetYLeeway = 40f; + float absoluteDistanceX = Math.Abs(Main.player[NPC.target].Center.X - NPC.Center.X); + bool tooFarX = absoluteDistanceX > distanceAwayFromTargetX + distanceAwayFromTargetXLeeway || absoluteDistanceX < distanceAwayFromTargetX - distanceAwayFromTargetXLeeway; + bool tooFarY = distanceAwayFromTargetY > distanceAboveTarget + distanceAwayFromTargetYLeeway || distanceAwayFromTargetY < distanceAboveTarget - distanceAwayFromTargetYLeeway; + bool tooFar = tooFarX || tooFarY; + Vector2 hoverDestination = Main.player[NPC.target].Center - Vector2.UnitY * distanceAboveTarget + Vector2.UnitX * distanceAwayFromTargetX * NPC.ai[3]; + if (tooFar) + { + Vector2 idealVelocity = NPC.SafeDirectionTo(hoverDestination) * 16f; + NPC.SimpleFlyMovement(idealVelocity, 0.36f); + } + + if (NPC.Distance(Main.player[NPC.target].Center) < distanceAwayFromTargetX || NPC.Distance(hoverDestination) > 120f) + shouldFireLasers = false; + + float playerLocation = NPC.Center.X - Main.player[NPC.target].Center.X; + NPC.direction = playerLocation < 0f ? 1 : -1; + NPC.spriteDirection = NPC.direction; + + if (NPC.ai[1] == 0f) + { + NPC.ai[1] = 1f; + SoundEngine.PlaySound(SoundID.NPCDeath12, NPC.Center); + for (int i = 0; i < 100; i++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, NPC.velocity.X, NPC.velocity.Y); + Main.dust[dust].scale = Main.rand.NextFloat(1.5f, 4f); + Main.dust[dust].velocity *= Main.rand.NextFloat(0.5f, 1.5f); + } + } + + // 50% chance to change Y position + float eyePositionRandomChangeGateValue = MathHelper.Lerp(death ? 180f : 240f, death ? 480f : 720f, lifeRatio / phase2LifeRatio); + if (NPC.ai[2] >= eyePositionRandomChangeGateValue) + { + NPC.ai[2] = 0f; + NPC.ai[0] = Main.rand.NextBool() ? 1f : -1f; + NPC.netUpdate = true; + } + NPC.ai[2] += 1f; } - npc.ai[2] += 1f; - } - Vector2 eyeLocation = npc.Center; - float predictionAmount = MathHelper.Lerp(0f, 20f, (float)Math.Sqrt(1f - lifeRatio)); - Vector2 lookAt = Main.player[npc.target].Center + (bossRush ? (Main.player[npc.target].velocity * predictionAmount) : Vector2.Zero); - float eyeTargetX = lookAt.X - eyeLocation.X; - float eyeTargetY = lookAt.Y - eyeLocation.Y; - float wallVelocity = (float)Math.Sqrt(eyeTargetX * eyeTargetX + eyeTargetY * eyeTargetY); - eyeTargetX *= wallVelocity; - eyeTargetY *= wallVelocity; + Vector2 eyeLocation = NPC.Center; + Vector2 lookAt = Main.player[NPC.target].Center; + float eyeTargetX = lookAt.X - eyeLocation.X; + float eyeTargetY = lookAt.Y - eyeLocation.Y; + float wallVelocity = (float)Math.Sqrt(eyeTargetX * eyeTargetX + eyeTargetY * eyeTargetY); + eyeTargetX *= wallVelocity; + eyeTargetY *= wallVelocity; - // Rotation based on direction and whether to fire lasers or not - if (npc.direction > 0) - { - if (Main.player[npc.target].Center.X > npc.Center.X) + // Rotation based on direction and whether to fire lasers or not + if (NPC.direction > 0) { - npc.rotation = (float)Math.Atan2(-eyeTargetY, -eyeTargetX) + MathHelper.Pi; + if (Main.player[NPC.target].Center.X > NPC.Center.X) + { + NPC.rotation = (float)Math.Atan2(-eyeTargetY, -eyeTargetX) + MathHelper.Pi; + } + else + { + NPC.rotation = 0f; + if (!deathModeDetach) + shouldFireLasers = false; + } + } + else if (Main.player[NPC.target].Center.X < NPC.Center.X) + { + NPC.rotation = (float)Math.Atan2(eyeTargetY, eyeTargetX) + MathHelper.Pi; } else { - npc.rotation = 0f; - if (!masterModeDetach) + NPC.rotation = 0f; + if (!deathModeDetach) shouldFireLasers = false; } - } - else if (Main.player[npc.target].Center.X < npc.Center.X) - { - npc.rotation = (float)Math.Atan2(eyeTargetY, eyeTargetX) + MathHelper.Pi; - } - else - { - npc.rotation = 0f; - if (!masterModeDetach) - shouldFireLasers = false; - } - // Fire lasers - if (Main.netMode != NetmodeID.MultiplayerClient) - { - bool charging = Main.npc[Main.wofNPCIndex].ai[3] == 1f; - - // Set up enraged laser firing timer - float enragedLaserTimer = EnragedLaserFiringDuration; - if (charging) - npc.localAI[3] = enragedLaserTimer; - - bool fireEnragedLasers = npc.localAI[3] > 0f && npc.localAI[3] < enragedLaserTimer; - - // Decrement the enraged laser timer - if (npc.localAI[3] > 0f) + // Fire lasers + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[3] -= 1f; + bool charging = Main.npc[Main.wofNPCIndex].ai[3] == 1f; - // Stop firing normal lasers when enrage ends - if (npc.localAI[3] == 0f) - npc.localAI[1] = 0f; - } + // Set up enraged laser firing timer + float enragedLaserTimer = EnragedLaserFiringDuration; + if (charging) + NPC.localAI[3] = enragedLaserTimer; - float shootBoost = fireEnragedLasers ? (death ? 5f : 4f) : (death ? 3f : 3f * (1f - lifeRatio)); - npc.localAI[1] += 1f + shootBoost; + bool fireEnragedLasers = NPC.localAI[3] > 0f && NPC.localAI[3] < enragedLaserTimer; - if (npc.localAI[2] == 0f) - { - if (npc.localAI[1] > LaserShootGateValue) + // Decrement the enraged laser timer + if (NPC.localAI[3] > 0f) { - npc.localAI[2] = 1f; - npc.localAI[1] = 0f; + NPC.localAI[3] -= 1f; + + // Stop firing normal lasers when enrage ends + if (NPC.localAI[3] == 0f) + NPC.localAI[1] = 0f; } - } - else if (npc.localAI[1] > 45f && (canHit || masterModeDetach) && !charging) - { - npc.localAI[1] = 0f; - npc.localAI[2] += 1f; - if (npc.localAI[2] >= TotalLasersPerBarrage + 1f) - npc.localAI[2] = 0f; - if (shouldFireLasers) + float shootBoost = fireEnragedLasers ? (death ? 5f : 4f) : (death ? 3f : 3f * (1f - lifeRatio)); + NPC.localAI[1] += 1f + shootBoost; + + if (NPC.localAI[2] == 0f) { - float velocity = (fireEnragedLasers ? 3f : 4f) + shootBoost; - int projectileType = ProjectileID.EyeLaser; - int damage = npc.GetProjectileDamage(projectileType); - - bool targetTooClose = npc.Distance(Main.player[npc.target].Center) < 160f; - float projectileOffset = targetTooClose ? 60f : 150f; - Vector2 projectileVelocity = (lookAt - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; - Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileOffset; - - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 900; - - if (!canHit) - Main.projectile[proj].tileCollide = false; + if (NPC.localAI[1] > LaserShootGateValue) + { + NPC.localAI[2] = 1f; + NPC.localAI[1] = 0f; + } } - } - } - - return false; - } - - public static bool VanillaWallofFleshAI(NPC npc, Mod mod) - { - if (npc.position.X < 160f || npc.position.X > (float)((Main.maxTilesX - 10) * 16)) - npc.active = false; - - if (npc.localAI[0] == 0f) - { - npc.localAI[0] = 1f; - Main.wofDrawAreaBottom = -1; - Main.wofDrawAreaTop = -1; - } - - if (Main.getGoodWorld && Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(180) && NPC.CountNPCS(NPCID.FireImp) < 4) - { - int num349 = 1; - for (int num350 = 0; num350 < num349; num350++) - { - int num351 = 1000; - for (int num352 = 0; num352 < num351; num352++) + else if (NPC.localAI[1] > 45f && (canHit || deathModeDetach) && !charging) { - int num353 = (int)(npc.Center.X / 16f); - int num354 = (int)(npc.Center.Y / 16f); - if (npc.target >= 0) - { - num353 = (int)(Main.player[npc.target].Center.X / 16f); - num354 = (int)(Main.player[npc.target].Center.Y / 16f); - } + NPC.localAI[1] = 0f; + NPC.localAI[2] += 1f; + if (NPC.localAI[2] >= TotalLasersPerBarrage + 1f) + NPC.localAI[2] = 0f; - num353 += Main.rand.Next(-50, 51); - for (num354 += Main.rand.Next(-50, 51); num354 < Main.maxTilesY - 10 && !WorldGen.SolidTile(num353, num354); num354++) + if (shouldFireLasers) { - } + float velocity = (fireEnragedLasers ? 3f : 4f) + shootBoost; + int projectileType = ProjectileID.EyeLaser; - num354--; - if (!WorldGen.SolidTile(num353, num354)) - { - int num355 = NPC.NewNPC(npc.GetSource_FromAI(), num353 * 16 + 8, num354 * 16, 24); - if (Main.dedServ && num355 < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num355); + bool targetTooClose = NPC.Distance(Main.player[NPC.target].Center) < 160f; + float projectileOffset = targetTooClose ? 60f : 150f; + Vector2 projectileVelocity = (lookAt - NPC.Center).SafeNormalize(Vector2.UnitY) * velocity; + Vector2 projectileSpawn = NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileOffset; - break; + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, LaserDamage, 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 900; + + if (!canHit) + Main.projectile[proj].tileCollide = false; } } } - } - npc.ai[1] += 1f; - if (npc.ai[2] == 0f) - { - if (Main.masterMode) - npc.ai[1] += 2f; - - if ((double)npc.life < (double)npc.lifeMax * 0.5) - npc.ai[1] += 1f; - - if ((double)npc.life < (double)npc.lifeMax * 0.2) - npc.ai[1] += 1f; - - if (npc.ai[1] > 2700f) - npc.ai[2] = 1f; - } - - int num356 = Main.masterMode ? 30 : 60; - if (npc.ai[2] > 0f && npc.ai[1] > (float)num356) - { - int num357 = 3; - if ((double)npc.life < (double)npc.lifeMax * 0.3) - num357++; - - npc.ai[2] += 1f; - npc.ai[1] = 0f; - if (npc.ai[2] > (float)num357) - npc.ai[2] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(NPCID.LeechHead) < 10) - { - int num358 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.Center.Y + 20f), NPCID.LeechHead, 1); - int leechVelocity = Main.masterMode ? 12 : 8; - Main.npc[num358].velocity.X = npc.direction * leechVelocity; - } - } - - npc.localAI[3] += 1f; - if (npc.localAI[3] >= (float)(600 + Main.rand.Next(1000))) - { - npc.localAI[3] = -Main.rand.Next(200); - SoundEngine.PlaySound(SoundID.NPCDeath10, npc.Center); - } - - int num359 = Main.UnderworldLayer + 10; - int num360 = num359 + 70; - Main.wofNPCIndex = npc.whoAmI; - int num361 = (int)(npc.position.X / 16f); - int num362 = (int)((npc.position.X + (float)npc.width) / 16f); - int num363 = (int)(npc.Center.Y / 16f); - int num364 = 0; - int num365 = num363 + 7; - while (num364 < 15 && num365 > Main.UnderworldLayer) - { - num365++; - if (num365 > Main.maxTilesY - 10) - { - num365 = Main.maxTilesY - 10; - break; - } - - if (num365 < num359) - continue; - - for (int num366 = num361; num366 <= num362; num366++) - { - try - { - if (WorldGen.InWorld(num366, num365, 2) && (WorldGen.SolidTile(num366, num365) || Main.tile[num366, num365].LiquidAmount > 0)) - num364++; - } - catch - { - num364 += 15; - } - } - } - - num365 += 4; - if (Main.wofDrawAreaBottom == -1) - { - Main.wofDrawAreaBottom = num365 * 16; - } - else if (Main.wofDrawAreaBottom > num365 * 16) - { - Main.wofDrawAreaBottom--; - if (Main.wofDrawAreaBottom < num365 * 16) - Main.wofDrawAreaBottom = num365 * 16; - } - else if (Main.wofDrawAreaBottom < num365 * 16) - { - Main.wofDrawAreaBottom++; - if (Main.wofDrawAreaBottom > num365 * 16) - Main.wofDrawAreaBottom = num365 * 16; - } - - num364 = 0; - num365 = num363 - 7; - while (num364 < 15 && num365 < Main.maxTilesY - 10) - { - num365--; - if (num365 <= 10) - { - num365 = 10; - break; - } - - if (num365 > num360) - continue; - - if (num365 < num359) - { - num365 = num359; - break; - } - - for (int num367 = num361; num367 <= num362; num367++) - { - try - { - if (WorldGen.InWorld(num367, num365, 2) && (WorldGen.SolidTile(num367, num365) || Main.tile[num367, num365].LiquidAmount > 0)) - num364++; - } - catch - { - num364 += 15; - } - } - } - - num365 -= 4; - if (Main.wofDrawAreaTop == -1) - { - Main.wofDrawAreaTop = num365 * 16; - } - else if (Main.wofDrawAreaTop > num365 * 16) - { - Main.wofDrawAreaTop--; - if (Main.wofDrawAreaTop < num365 * 16) - Main.wofDrawAreaTop = num365 * 16; - } - else if (Main.wofDrawAreaTop < num365 * 16) - { - Main.wofDrawAreaTop++; - if (Main.wofDrawAreaTop > num365 * 16) - Main.wofDrawAreaTop = num365 * 16; - } - - Main.wofDrawAreaTop = (int)MathHelper.Clamp(Main.wofDrawAreaTop, (float)num359 * 16f, (float)num360 * 16f); - Main.wofDrawAreaBottom = (int)MathHelper.Clamp(Main.wofDrawAreaBottom, (float)num359 * 16f, (float)num360 * 16f); - if (Main.wofDrawAreaTop > Main.wofDrawAreaBottom - 160) - Main.wofDrawAreaTop = Main.wofDrawAreaBottom - 160; - else if (Main.wofDrawAreaBottom < Main.wofDrawAreaTop + 160) - Main.wofDrawAreaBottom = Main.wofDrawAreaTop + 160; - - float num368 = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2 - npc.height / 2; - if (npc.position.Y > num368 + 1f) - npc.velocity.Y = -1f; - else if (npc.position.Y < num368 - 1f) - npc.velocity.Y = 1f; - - npc.velocity.Y = 0f; - npc.position.Y = num368; - - float targetPosition = Main.player[npc.target].Center.X; - float npcPosition = npc.Center.X; - - // Slow down if close - float distanceFromTarget; - if (npc.velocity.X < 0f) - distanceFromTarget = npcPosition - targetPosition; - else - distanceFromTarget = targetPosition - npcPosition; - - float distanceBeforeSlowingDown = 640f; - float speedMult = 1f; - - if (distanceFromTarget < distanceBeforeSlowingDown) - speedMult += (distanceFromTarget - distanceBeforeSlowingDown) * 0.002f; - - speedMult = MathHelper.Clamp(speedMult, 0.4f, 1f); - - float masterModeVelocityBoost = 0f; - if (Main.masterMode) - { - float velocityBoostStartDistance = distanceBeforeSlowingDown; - float velocityBoostMaxDistance = velocityBoostStartDistance * 1.5f; - float distanceFromTargetX = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); - float lerpAmount = MathHelper.Clamp((distanceFromTargetX - velocityBoostStartDistance) / velocityBoostMaxDistance, 0f, 1f); - masterModeVelocityBoost = MathHelper.Lerp(0f, 8f, lerpAmount); - } - - float num369 = (Main.expertMode ? 3.5f : 2.5f) + masterModeVelocityBoost; - if (!Main.expertMode) - { - // 4.7 is the max in classic - if ((double)npc.life < (double)npc.lifeMax * 0.75) - num369 += 0.4f; - - if ((double)npc.life < (double)npc.lifeMax * 0.5) - num369 += 0.5f; - - if ((double)npc.life < (double)npc.lifeMax * 0.25) - num369 += 0.6f; - - if ((double)npc.life < (double)npc.lifeMax * 0.1) - num369 += 0.7f; - } - else - { - // 6.5 is the max in expert - if ((double)npc.life < (double)npc.lifeMax * 0.8) - num369 += 0.3f; - - if ((double)npc.life < (double)npc.lifeMax * 0.6) - num369 += 0.3f; - - if ((double)npc.life < (double)npc.lifeMax * 0.4) - num369 += 0.5f; - - if ((double)npc.life < (double)npc.lifeMax * 0.2) - num369 += 0.5f; - - if ((double)npc.life < (double)npc.lifeMax * 0.1) - num369 += 0.7f; - - if ((double)npc.life < (double)npc.lifeMax * 0.05) - num369 += 0.7f; - - // 8.3 is the max in master - if (Main.masterMode) - { - if ((double)npc.life < (double)npc.lifeMax * 0.025) - num369 += 0.9f; - - if ((double)npc.life < (double)npc.lifeMax * 0.01) - num369 += 0.9f; - } - } - - if (Main.getGoodWorld) - { - num369 *= 1.1f; - num369 += 0.2f; - } - - num369 *= speedMult; - - if (npc.velocity.X == 0f) - { - npc.TargetClosest(); - if (Main.player[npc.target].dead) - { - float num370 = float.PositiveInfinity; - int num371 = 0; - for (int num372 = 0; num372 < Main.maxPlayers; num372++) - { - Player player = Main.player[npc.target]; - if (player.active) - { - float num373 = npc.Distance(player.Center); - if (num370 > num373) - { - num370 = num373; - num371 = ((npc.Center.X < player.Center.X) ? 1 : (-1)); - } - } - } - - npc.direction = num371; - } - - npc.velocity.X = npc.direction; - } - - if (npc.velocity.X < 0f) - { - npc.velocity.X = -num369; - npc.direction = -1; - } - else - { - npc.velocity.X = num369; - npc.direction = 1; - } - - if (Main.player[npc.target].dead || !Main.player[npc.target].gross) - npc.TargetClosest_WOF(); - - if (Main.player[npc.target].dead) - { - npc.localAI[1] += 1f / 180f; - if (npc.localAI[1] >= 1f) - { - SoundEngine.PlaySound(SoundID.NPCDeath10, npc.Center); - npc.life = 0; - npc.active = false; - if (Main.netMode != NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f); - - return false; - } - } - else - npc.localAI[1] = MathHelper.Clamp(npc.localAI[1] - 1f / 30f, 0f, 1f); - - npc.spriteDirection = npc.direction; - Vector2 vector38 = npc.Center; - float num374 = Main.player[npc.target].Center.X - vector38.X; - float num375 = Main.player[npc.target].Center.Y - vector38.Y; - float num376 = (float)Math.Sqrt(num374 * num374 + num375 * num375); - float num377 = num376; - num374 *= num376; - num375 *= num376; - if (npc.direction > 0) - { - if (Main.player[npc.target].Center.X > npc.Center.X) - npc.rotation = (float)Math.Atan2(0f - num375, 0f - num374) + MathHelper.Pi; - else - npc.rotation = 0f; - } - else if (Main.player[npc.target].Center.X < npc.Center.X) - npc.rotation = (float)Math.Atan2(num375, num374) + MathHelper.Pi; - else - npc.rotation = 0f; - - if (Main.expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - int chanceToSpawnHungry = (int)(1f + (float)npc.life / (float)npc.lifeMax * 10f); - chanceToSpawnHungry *= chanceToSpawnHungry; - if (chanceToSpawnHungry < 400) - chanceToSpawnHungry = (chanceToSpawnHungry * 19 + 400) / 20; - - if (chanceToSpawnHungry < 60) - chanceToSpawnHungry = (chanceToSpawnHungry * 3 + 60) / 4; - - if (chanceToSpawnHungry < 20) - chanceToSpawnHungry = (chanceToSpawnHungry + 20) / 2; - - chanceToSpawnHungry = (int)((double)chanceToSpawnHungry * (Main.masterMode ? 0.5 : 0.7)); - if (chanceToSpawnHungry < 2) - chanceToSpawnHungry = 2; - - if (Main.rand.NextBool(chanceToSpawnHungry)) - { - int maxHungriesBasedOnHP = (int)Math.Round(MathHelper.Lerp(Main.masterMode ? 2f : 1f, Main.masterMode ? 8f : 4f, npc.life / (float)npc.lifeMax)); - if (NPC.CountNPCS(NPCID.TheHungry) < maxHungriesBasedOnHP) - { - int hungryCount = 0; - int maxHungries = 10; - float[] hungryArray = new float[maxHungries]; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (hungryCount < maxHungries && Main.npc[i].active && Main.npc[i].type == NPCID.TheHungry) - { - hungryArray[hungryCount] = Main.npc[i].ai[0]; - hungryCount++; - } - } - - int maxValue = 1 + hungryCount * 2; - if (Main.masterMode) - maxValue /= 2; - if (maxValue < 2) - maxValue = 2; - - if (hungryCount < maxHungries && Main.rand.Next(maxValue) <= 1) - { - int ai0 = -1; - for (int i = 0; i < 1000; i++) - { - int randomHungryLocation = Main.rand.Next(maxHungries); - float hungryLocation = (float)randomHungryLocation * 0.1f - 0.05f; - bool spawnHungry = true; - for (int j = 0; j < hungryCount; j++) - { - if (hungryLocation == hungryArray[j]) - { - spawnHungry = false; - break; - } - } - - if (spawnHungry) - { - ai0 = randomHungryLocation; - break; - } - } - - if (ai0 >= 0) - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num368, NPCID.TheHungry, npc.whoAmI, (float)ai0 * 0.1f - 0.05f); - } - } - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 1f) - { - npc.localAI[0] = 2f; - float num386 = (npc.Center.Y + (float)Main.wofDrawAreaTop) / 2f; - int num387 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num386, NPCID.WallofFleshEye, npc.whoAmI, 1f); - float num388 = (npc.Center.Y + (float)Main.wofDrawAreaBottom) / 2f; - num387 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num388, NPCID.WallofFleshEye, npc.whoAmI, -1f); - float num389 = (npc.Center.Y + (float)Main.wofDrawAreaBottom) / 2f; - int maxHungries = Main.masterMode ? 16 : 11; - float maxOffset = Main.masterMode ? (0.2f / 3f) : 0.1f; - for (int i = 0; i < maxHungries; i++) - num387 = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X, (int)num389, NPCID.TheHungry, npc.whoAmI, i * maxOffset - 0.05f); - } - - return false; - } - - public static bool VanillaWallofFleshEyeAI(NPC npc, Mod mod) - { - if (Main.wofNPCIndex < 0) - { - npc.active = false; return false; } - npc.realLife = Main.wofNPCIndex; - if (Main.npc[Main.wofNPCIndex].life > 0) - npc.life = Main.npc[Main.wofNPCIndex].life; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.target = Main.npc[Main.wofNPCIndex].target; - - // Avoid cheap bullshit - npc.damage = 0; - - npc.position.X = Main.npc[Main.wofNPCIndex].position.X; - npc.direction = Main.npc[Main.wofNPCIndex].direction; - npc.spriteDirection = npc.direction; - float num391 = (Main.wofDrawAreaBottom + Main.wofDrawAreaTop) / 2; - num391 = ((!(npc.ai[0] > 0f)) ? ((num391 + (float)Main.wofDrawAreaBottom) / 2f) : ((num391 + (float)Main.wofDrawAreaTop) / 2f)); - num391 -= (float)(npc.height / 2); - if (npc.position.Y > num391 + 1f) + public override void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - npc.velocity.Y = -1f; - } - else if (npc.position.Y < num391 - 1f) - { - npc.velocity.Y = 1f; - } - else - { - npc.velocity.Y = 0f; - npc.position.Y = num391; - } - - if (npc.velocity.Y > 5f) - npc.velocity.Y = 5f; - - if (npc.velocity.Y < -5f) - npc.velocity.Y = -5f; - - Vector2 vector39 = npc.Center; - float num392 = Main.player[npc.target].Center.X - vector39.X; - float num393 = Main.player[npc.target].Center.Y - vector39.Y; - float num394 = (float)Math.Sqrt(num392 * num392 + num393 * num393); - float num395 = num394; - num392 *= num394; - num393 *= num394; - bool flag27 = true; - if (npc.direction > 0) - { - if (Main.player[npc.target].Center.X > npc.Center.X) + // Laser telegraph + bool enraged = NPC.localAI[3] > 0f; + float eyeTelegraphGateValue = LaserShootGateValue - LaserShootTelegraphTime; + if (NPC.localAI[1] > eyeTelegraphGateValue || NPC.localAI[2] > 0f || enraged) { - npc.rotation = (float)Math.Atan2(0f - num393, 0f - num392) + MathHelper.Pi; - } - else - { - npc.rotation = 0f; - flag27 = false; + Texture2D glowTexture = CalamityClientConfig.Instance.EnableVanillaTextureEdits ? ExtraTextureRefs.WallOfFleshEyeGlowmask.Value : TextureAssets.Npc[NPC.type].Value; + var halfSize = NPC.frame.Size() / 2; + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float colorScale = enraged ? MathHelper.Clamp(NPC.localAI[3] / EnragedLaserFiringDuration, 0f, 1f) : + NPC.localAI[2] > 0f ? 1f - ((NPC.localAI[2] - 1f) / TotalLasersPerBarrage) : + MathHelper.Clamp((NPC.localAI[1] - eyeTelegraphGateValue) / LaserShootTelegraphTime, 0f, 1f); + + Color drawColor2 = new Color(100, 0, 200, 192) * colorScale; + for (int i = 0; i < 2; i++) + { + spriteBatch.Draw(glowTexture, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, + drawColor2, NPC.rotation, halfSize, NPC.scale, spriteEffects, 0f); + } } } - else if (Main.player[npc.target].Center.X < npc.Center.X) - { - npc.rotation = (float)Math.Atan2(num393, num392) + MathHelper.Pi; - } - else - { - npc.rotation = 0f; - flag27 = false; - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - return false; - - int num396 = 4; - npc.localAI[1] += 1f; - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.75) - { - npc.localAI[1] += 1f; - num396++; - } - - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.5) - { - npc.localAI[1] += 1f; - num396++; - } - - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.25) - { - npc.localAI[1] += 1f; - num396 += 2; - } - - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.1) - { - npc.localAI[1] += 2f; - num396 += 3; - } - - if (Main.expertMode) - { - npc.localAI[1] += 0.5f; - num396++; - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.1) - { - npc.localAI[1] += 2f; - num396 += 3; - } - } - - if (npc.localAI[2] == 0f) - { - if (npc.localAI[1] > 600f) - { - npc.localAI[2] = 1f; - npc.localAI[1] = 0f; - } - } - else - { - if (!(npc.localAI[1] > 45f) || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - return false; - - npc.localAI[1] = 0f; - npc.localAI[2] += 1f; - if (npc.localAI[2] >= (float)num396) - npc.localAI[2] = 0f; - - if (flag27) - { - float num397 = 4f; - int type = ProjectileID.EyeLaser; - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.5) - num397 += 1f; - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.25) - num397 += 1f; - if ((double)Main.npc[Main.wofNPCIndex].life < (double)Main.npc[Main.wofNPCIndex].lifeMax * 0.1) - num397 += 1f; - - num392 = Main.player[npc.target].Center.X - npc.Center.X; - num393 = Main.player[npc.target].Center.Y - npc.Center.Y; - num394 = (float)Math.Sqrt(num392 * num392 + num393 * num393); - num394 = num397 / num394; - num392 *= num394; - num393 *= num394; - - bool targetTooClose = npc.Distance(Main.player[npc.target].Center) < 160f; - float projectileOffset = targetTooClose ? 60f : 150f; - Vector2 projectileVelocity = new Vector2(num392, num393); - Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * projectileOffset; - Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, type, npc.GetProjectileDamage(type), 0f, Main.myPlayer, 1f, 0f); - } - } - - return false; } } } diff --git a/NPCs/VanillaNPCAIOverrides/MiniBosses/DreadnautilusAI.cs b/NPCs/VanillaNPCAIOverrides/MiniBosses/DreadnautilusAI.cs new file mode 100644 index 0000000000..ffbe94e885 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/MiniBosses/DreadnautilusAI.cs @@ -0,0 +1,446 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses +{ + public class DreadnautilusAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + // Death Mode bool + bool death = CalamityWorld.death; + + // Attack variables + float goToAttackPositionAcceleration = death ? 0.2f : 0.15f; + float goToAttackPositionVelocity = death ? 10f : 7.5f; + float phaseSwitchPhaseTime = death ? 30f : 60f; + float dashChargeUpPhaseTime = 120f; + float dashPhaseTime = death ? 150f : 180f; + float bloodSpitChargeUpPhaseTime = 90f; + float bloodSpitPhaseTime = death ? 120f : 90f; + int numBloodSpitVolleys = death ? 3 : 2; + float bloodSquidPhaseTime = 180f; + int maxBloodSquids = death ? 3 : 2; + + // Spawn effect + if (NPC.localAI[0] == 0f) + { + NPC.localAI[0] = 1f; + NPC.alpha = 255; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = -1f; + NPC.netUpdate = true; + } + } + + // Create dust + if (NPC.ai[0] != -1f && Main.rand.NextBool(4)) + { + NPC.position += NPC.netOffset; + Dust dust = Dust.NewDustDirect(NPC.position + new Vector2(5f), NPC.width - 10, NPC.height - 10, DustID.Blood); + dust.velocity *= 0.5f; + if (dust.velocity.Y < 0f) + dust.velocity.Y *= -1f; + + dust.alpha = 120; + dust.scale = 1f + Main.rand.NextFloat() * 0.4f; + dust.velocity += NPC.velocity * 0.3f; + NPC.position -= NPC.netOffset; + } + + // Get a target + if (NPC.target == Main.maxPlayers) + { + NPC.TargetClosest(); + NPC.ai[2] = NPC.direction; + } + + // Get a new target if the current target is dead or too far away + if (Main.player[NPC.target].dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 2000f) + NPC.TargetClosest(); + + // Set to despawn + NPCAimedTarget nPCAimedTarget = NPC.GetTargetData(); + if (Main.dayTime || !Main.bloodMoon) + nPCAimedTarget = default(NPCAimedTarget); + + // Attacks and shit + int attackType = -1; + switch ((int)NPC.ai[0]) + { + // Spawn effects + case -1: + { + NPC.velocity *= 0.98f; + int spawnFaceDirection = Math.Sign(nPCAimedTarget.Center.X - NPC.Center.X); + if (spawnFaceDirection != 0) + { + NPC.direction = spawnFaceDirection; + NPC.spriteDirection = -NPC.direction; + } + + if (NPC.localAI[1] == 0f && NPC.alpha < 100) + { + NPC.localAI[1] = 1f; + int dustAmt = 36; + for (int l = 0; l < dustAmt; l++) + { + NPC.position += NPC.netOffset; + Vector2 dustRotation = (Vector2.Normalize(NPC.velocity) * new Vector2(NPC.width / 2f, NPC.height) * 0.75f * 0.5f).RotatedBy((l - (dustAmt / 2 - 1)) * ((float)Math.PI * 2f) / dustAmt) + NPC.Center; + Vector2 dustVelocity = dustRotation - NPC.Center; + int spawnDustBlood = Dust.NewDust(dustRotation + dustVelocity, 0, 0, DustID.Blood, dustVelocity.X * 2f, dustVelocity.Y * 2f, 100, default, 1.4f); + Main.dust[spawnDustBlood].noGravity = true; + Main.dust[spawnDustBlood].velocity = Vector2.Normalize(dustVelocity) * 3f; + NPC.position -= NPC.netOffset; + } + } + + if (NPC.ai[2] > 5f) + { + NPC.velocity.Y = -2.5f; + NPC.alpha -= 10; + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.alpha += 15; + if (NPC.alpha > 150) + NPC.alpha = 150; + } + + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 50f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + break; + } + + // Get in position for an attack and then choose an attack type + case 0: + { + Vector2 destination = nPCAimedTarget.Center + new Vector2((0f - NPC.ai[2]) * 500f, -300f); + if (NPC.Center.Distance(destination) > 50f) + { + Vector2 desiredVelocity = NPC.DirectionTo(destination) * goToAttackPositionVelocity; + NPC.SimpleFlyMovement(desiredVelocity, goToAttackPositionAcceleration); + } + + NPC.direction = (NPC.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); + float faceTargetDirection = NPC.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * NPC.spriteDirection; + if (NPC.spriteDirection == -1) + faceTargetDirection += (float)Math.PI; + + if (NPC.spriteDirection != NPC.direction) + { + NPC.spriteDirection = NPC.direction; + NPC.rotation = 0f - NPC.rotation; + faceTargetDirection = 0f - faceTargetDirection; + } + + NPC.rotation = NPC.rotation.AngleTowards(faceTargetDirection, 0.02f); + NPC.ai[1] += 1f; + if (NPC.ai[1] > phaseSwitchPhaseTime) + { + int attackPicker = (int)NPC.ai[3]; + if (attackPicker % 7 == 3 && NPC.CountNPCS(NPCID.BloodSquid) < maxBloodSquids) + { + attackType = 3; + } + else if (attackPicker % 2 == 0) + { + SoundEngine.PlaySound(SoundID.Item170, NPC.Center); + attackType = 2; + } + else + { + SoundEngine.PlaySound(SoundID.Item170, NPC.Center); + attackType = 1; + } + } + + break; + } + + // Dash + case 1: + { + NPC.direction = (!(NPC.Center.X < nPCAimedTarget.Center.X)) ? 1 : (-1); + float chargeFaceDirection = NPC.Center.DirectionFrom(nPCAimedTarget.Center).ToRotation() - 213f / 452f * NPC.spriteDirection; + if (NPC.spriteDirection == -1) + chargeFaceDirection += (float)Math.PI; + + bool shouldStartCharge = NPC.ai[1] < dashChargeUpPhaseTime; + if (NPC.spriteDirection != NPC.direction && shouldStartCharge) + { + NPC.spriteDirection = NPC.direction; + NPC.rotation = 0f - NPC.rotation; + chargeFaceDirection = 0f - chargeFaceDirection; + } + + if (NPC.ai[1] < dashChargeUpPhaseTime) + { + if (NPC.ai[1] == dashChargeUpPhaseTime - 1f) + SoundEngine.PlaySound(SoundID.Item172, NPC.Center); + + NPC.velocity *= 0.95f; + NPC.rotation = NPC.rotation.AngleLerp(chargeFaceDirection, 0.02f); + NPC.position += NPC.netOffset; + NPC.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition4, out Vector2 mouthDirection4); + Dust chargeUpDust = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 60f - new Vector2(40f), 80, 80, DustID.Cloud, 0f, 0f, 150, Color.Transparent, 0.6f); + chargeUpDust.fadeIn = 1f; + chargeUpDust.velocity = chargeUpDust.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * chargeUpDust.velocity.Length(); + chargeUpDust.noGravity = true; + chargeUpDust = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 100f - new Vector2(30f), 60, 60, DustID.Cloud, 0f, 0f, 100, Color.Transparent, 0.9f); + chargeUpDust.fadeIn = 1.5f; + chargeUpDust.velocity = chargeUpDust.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * (chargeUpDust.velocity.Length() + 5f); + chargeUpDust.noGravity = true; + NPC.position -= NPC.netOffset; + } + else if (NPC.ai[1] < dashChargeUpPhaseTime + dashPhaseTime) + { + NPC.position += NPC.netOffset; + NPC.rotation = NPC.rotation.AngleLerp(chargeFaceDirection, 0.07f); + NPC.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition5, out Vector2 mouthDirection5); + + // Dash directly towards the target until within 15 tiles of the target, and then continue in the same direction for 18 frames (15 frames in Death Mode) + if (NPC.ai[1] < dashChargeUpPhaseTime + dashPhaseTime * 0.9f) + { + if (NPC.Center.Distance(nPCAimedTarget.Center) > 240f || NPC.ai[1] == dashChargeUpPhaseTime) + NPC.velocity = mouthDirection5 * -(death ? 20f : 16f) + NPC.Center.DirectionTo(nPCAimedTarget.Center) * 2f; + else + NPC.ai[1] = dashChargeUpPhaseTime + dashPhaseTime * 0.9f; + } + + for (int m = 0; m < 4; m++) + { + Dust chargeBloodDust = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 60f - new Vector2(15f), 30, 30, DustID.Blood, 0f, 0f, 0, Color.Transparent, 1.5f); + chargeBloodDust.velocity = chargeBloodDust.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(5f, 5f)) * chargeBloodDust.velocity.Length(); + chargeBloodDust.position -= mouthDirection5 * 60f; + chargeBloodDust = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 100f - new Vector2(20f), 40, 40, DustID.Blood, 0f, 0f, 100, Color.Transparent, 1.5f); + chargeBloodDust.velocity = chargeBloodDust.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(10f, 10f)) * (chargeBloodDust.velocity.Length() + 5f); + chargeBloodDust.position -= mouthDirection5 * 100f; + } + + NPC.position -= NPC.netOffset; + } + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= dashChargeUpPhaseTime + dashPhaseTime) + attackType = 0; + + break; + } + + // Spit 3 spreads of blood projectiles + case 2: + { + NPC.direction = (NPC.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); + float bloodProjFaceDirection = NPC.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 213f / 452f * NPC.spriteDirection; + if (NPC.spriteDirection == -1) + bloodProjFaceDirection += (float)Math.PI; + + if (NPC.spriteDirection != NPC.direction) + { + NPC.spriteDirection = NPC.direction; + NPC.rotation = 0f - NPC.rotation; + bloodProjFaceDirection = 0f - bloodProjFaceDirection; + } + + NPC.rotation = NPC.rotation.AngleLerp(bloodProjFaceDirection, 0.2f); + if (NPC.ai[1] < bloodSpitChargeUpPhaseTime) + { + NPC.position += NPC.netOffset; + NPC.velocity *= 0.95f; + NPC.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition2, out Vector2 mouthDirection2); + if (!Main.rand.NextBool(4)) + { + Dust bloodProjChargeUpDust = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 60f - new Vector2(60f), 120, 120, DustID.Cloud, 0f, 0f, 150, Color.Transparent, 0.6f); + bloodProjChargeUpDust.fadeIn = 1f; + bloodProjChargeUpDust.velocity = bloodProjChargeUpDust.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (bloodProjChargeUpDust.velocity.Length() + 3f); + bloodProjChargeUpDust.noGravity = true; + bloodProjChargeUpDust = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 100f - new Vector2(80f), 160, 160, DustID.Cloud, 0f, 0f, 100, Color.Transparent, 0.9f); + bloodProjChargeUpDust.fadeIn = 1.5f; + bloodProjChargeUpDust.velocity = bloodProjChargeUpDust.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (bloodProjChargeUpDust.velocity.Length() + 5f); + bloodProjChargeUpDust.noGravity = true; + } + + NPC.position -= NPC.netOffset; + } + else if (NPC.ai[1] < bloodSpitChargeUpPhaseTime + bloodSpitPhaseTime) + { + NPC.position += NPC.netOffset; + NPC.velocity *= 0.9f; + float bloodProjShootTimer = (NPC.ai[1] - bloodSpitChargeUpPhaseTime) % (bloodSpitPhaseTime / numBloodSpitVolleys); + NPC.BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition3, out Vector2 mouthDirection3); + if (bloodProjShootTimer < bloodSpitPhaseTime / numBloodSpitVolleys * 0.8f) + { + for (int i = 0; i < 5; i++) + { + Dust bloodProjShootDust = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 50f - new Vector2(15f), 30, 30, DustID.Blood, 0f, 0f, 0, Color.Transparent, 1.5f); + bloodProjShootDust.velocity = bloodProjShootDust.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * bloodProjShootDust.velocity.Length(); + bloodProjShootDust.position -= mouthDirection3 * 60f; + bloodProjShootDust = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 90f - new Vector2(20f), 40, 40, DustID.Blood, 0f, 0f, 100, Color.Transparent, 1.5f); + bloodProjShootDust.velocity = bloodProjShootDust.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (bloodProjShootDust.velocity.Length() + 5f); + bloodProjShootDust.position -= mouthDirection3 * 100f; + } + } + + // Spit blood spread + if ((int)bloodProjShootTimer == 0) + { + // Recoil away with each spit + NPC.velocity += mouthDirection3 * -8f; + + // Spawn dust with each spit + for (int j = 0; j < 20; j++) + { + Dust bloodProjShootDust2 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 60f - new Vector2(15f), 30, 30, DustID.Blood, 0f, 0f, 0, Color.Transparent, 1.5f); + bloodProjShootDust2.velocity = bloodProjShootDust2.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * bloodProjShootDust2.velocity.Length(); + bloodProjShootDust2.position -= mouthDirection3 * 60f; + bloodProjShootDust2 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 100f - new Vector2(20f), 40, 40, DustID.Blood, 0f, 0f, 100, Color.Transparent, 1.5f); + bloodProjShootDust2.velocity = bloodProjShootDust2.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (bloodProjShootDust2.velocity.Length() + 5f); + bloodProjShootDust2.position -= mouthDirection3 * 100f; + } + + // Spawn projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int projectileAmt = death ? 6 : 5; + int spread = death ? 35 : 30; + float rotation = MathHelper.ToRadians(spread); + Vector2 initialProjectileVelocity = mouthDirection3 * 10f; + int damage = NPC.GetAttackDamage_ForProjectiles(30f, 25f); + for (int k = 0; k < projectileAmt + 1; k++) + { + Vector2 perturbedSpeed = initialProjectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, k / (float)(projectileAmt - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition3 - mouthDirection3 * 5f, initialProjectileVelocity + perturbedSpeed, ProjectileID.BloodNautilusShot, damage, 0f, Main.myPlayer); + } + } + } + + NPC.position -= NPC.netOffset; + } + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= bloodSpitChargeUpPhaseTime + bloodSpitPhaseTime) + attackType = 0; + + break; + } + + // Spawn Blood Squids + case 3: + { + NPC.direction = (NPC.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1); + float targetAngle = 0f; + NPC.spriteDirection = NPC.direction; + if (NPC.ai[1] < bloodSquidPhaseTime) + { + NPC.position += NPC.netOffset; + float bloodSquidVelClamp = MathHelper.Clamp(1f - NPC.ai[1] / bloodSquidPhaseTime * 1.5f, 0f, 1f); + NPC.velocity = Vector2.Lerp(value2: new Vector2(0f, bloodSquidVelClamp * -1.5f), value1: NPC.velocity, amount: 0.03f); + NPC.velocity = Vector2.Zero; + NPC.rotation = NPC.rotation.AngleLerp(targetAngle, 0.02f); + NPC.BloodNautilus_GetMouthPositionAndRotation(out Vector2 _, out Vector2 _); + float t = NPC.ai[1] / bloodSquidPhaseTime; + float scaleFactor2 = Utils.GetLerpValue(0f, 0.5f, t) * Utils.GetLerpValue(1f, 0.5f, t); + Lighting.AddLight(NPC.Center, new Vector3(1f, 0.5f, 0.5f) * scaleFactor2); + if (!Main.rand.NextBool(3)) + { + Dust bloodSquidSpawnDust = Dust.NewDustDirect(NPC.Center - new Vector2(6f), 12, 12, DustID.Blood, 0f, 0f, 60, Color.Transparent, 1.4f); + bloodSquidSpawnDust.position += new Vector2(NPC.spriteDirection * 12, 12f); + bloodSquidSpawnDust.velocity *= 0.1f; + } + + NPC.position -= NPC.netOffset; + } + + if (NPC.ai[1] == 10f || (death && NPC.ai[1] == 20f) || NPC.ai[1] == 30f) + BloodNautilus_CallForHelp(NPC); + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= bloodSquidPhaseTime) + attackType = 0; + + break; + } + } + + // Set AI arrays for the next attack + if (attackType != -1) + { + NPC.ai[0] = attackType; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; + NPC.TargetClosest(); + if (attackType == 0) + NPC.ai[2] = NPC.direction; + else + NPC.ai[3] += 1f; + } + + // Always set this to false because it's fucking stupid + NPC.reflectsProjectiles = false; + + return false; + } + + private static void BloodNautilus_CallForHelp(NPC npc) + { + if (Main.netMode == NetmodeID.MultiplayerClient || !Main.player[npc.target].active || Main.player[npc.target].dead || npc.Distance(Main.player[npc.target].Center) > 2000f) + return; + + Point npcCenterTileCoords = npc.Center.ToTileCoordinates(); + Point npcCenterTileCoordsCopy = npcCenterTileCoords; + int bloodTearRandSpawnOffset = 20; + int npcCenterTileRadius = 3; + int npcCenterCopyTileRadius = 8; + int bloodTearSpawnTileRadius = 2; + int attempts = 0; + int bloodTearTileX; + int bloodTearTileY; + while (true) + { + if (attempts >= 100) + return; + + attempts++; + bloodTearTileX = Main.rand.Next(npcCenterTileCoordsCopy.X - bloodTearRandSpawnOffset, npcCenterTileCoordsCopy.X + bloodTearRandSpawnOffset + 1); + bloodTearTileY = Main.rand.Next(npcCenterTileCoordsCopy.Y - bloodTearRandSpawnOffset, npcCenterTileCoordsCopy.Y + bloodTearRandSpawnOffset + 1); + if ((bloodTearTileY < npcCenterTileCoordsCopy.Y - npcCenterCopyTileRadius || bloodTearTileY > npcCenterTileCoordsCopy.Y + npcCenterCopyTileRadius || bloodTearTileX < npcCenterTileCoordsCopy.X - npcCenterCopyTileRadius || bloodTearTileX > npcCenterTileCoordsCopy.X + npcCenterCopyTileRadius) && (bloodTearTileY < npcCenterTileCoords.Y - npcCenterTileRadius || bloodTearTileY > npcCenterTileCoords.Y + npcCenterTileRadius || bloodTearTileX < npcCenterTileCoords.X - npcCenterTileRadius || bloodTearTileX > npcCenterTileCoords.X + npcCenterTileRadius) && !Main.tile[bloodTearTileX, bloodTearTileY].HasUnactuatedTile) + { + bool spawnBloodTear = true; + if (spawnBloodTear && Main.tile[bloodTearTileX, bloodTearTileY].LiquidType == LiquidID.Lava) + spawnBloodTear = false; + + if (spawnBloodTear && Collision.SolidTiles(bloodTearTileX - bloodTearSpawnTileRadius, bloodTearTileX + bloodTearSpawnTileRadius, bloodTearTileY - bloodTearSpawnTileRadius, bloodTearTileY + bloodTearSpawnTileRadius)) + spawnBloodTear = false; + + if (spawnBloodTear && !Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + spawnBloodTear = false; + + if (spawnBloodTear) + break; + } + } + + Projectile.NewProjectile(npc.GetSource_FromAI(), bloodTearTileX * 16 + 8, bloodTearTileY * 16 + 8, 0f, 0f, ProjectileID.BloodNautilusTears, 0, 0f, Main.myPlayer); + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/MiniBosses/IceQueenAI.cs b/NPCs/VanillaNPCAIOverrides/MiniBosses/IceQueenAI.cs new file mode 100644 index 0000000000..cb1857ff62 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/MiniBosses/IceQueenAI.cs @@ -0,0 +1,282 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses +{ + public class IceQueenAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (Main.dayTime) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X += 0.25f; + else + NPC.velocity.X -= 0.25f; + + NPC.velocity.Y -= 0.1f; + NPC.rotation = NPC.velocity.X * 0.05f; + } + else if (NPC.ai[0] == 0f) + { + if (NPC.ai[2] == 0f) + { + NPC.TargetClosest(true); + + if (NPC.Center.X < Main.player[NPC.target].Center.X) + NPC.ai[2] = 1f; + else + NPC.ai[2] = -1f; + } + + NPC.TargetClosest(true); + float iceQueenTargetDist = Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X); + + if (NPC.Center.X < Main.player[NPC.target].Center.X && NPC.ai[2] < 0f && iceQueenTargetDist > 800f) + NPC.ai[2] = 0f; + if (NPC.Center.X > Main.player[NPC.target].Center.X && NPC.ai[2] > 0f && iceQueenTargetDist > 800f) + NPC.ai[2] = 0f; + + float iceQueenAcceleration = 0.6f; + float iceQueenMaxVelocity = 10f; + if ((double)NPC.life < (double)NPC.lifeMax * 0.75) + { + iceQueenAcceleration = 0.7f; + iceQueenMaxVelocity = 12f; + } + if ((double)NPC.life < (double)NPC.lifeMax * 0.5) + { + iceQueenAcceleration = 0.8f; + iceQueenMaxVelocity = 14f; + } + if ((double)NPC.life < (double)NPC.lifeMax * 0.25) + { + iceQueenAcceleration = 0.95f; + iceQueenMaxVelocity = 16f; + } + + NPC.velocity.X += NPC.ai[2] * iceQueenAcceleration; + if (NPC.velocity.X > iceQueenMaxVelocity) + NPC.velocity.X = iceQueenMaxVelocity; + if (NPC.velocity.X < -iceQueenMaxVelocity) + NPC.velocity.X = -iceQueenMaxVelocity; + + float iceQueenHoverHeight = Main.player[NPC.target].position.Y - (NPC.position.Y + (float)NPC.height); + if (iceQueenHoverHeight < 150f) + NPC.velocity.Y -= 0.2f; + if (iceQueenHoverHeight > 200f) + NPC.velocity.Y += 0.2f; + if (NPC.velocity.Y > 9f) + NPC.velocity.Y = 9f; + if (NPC.velocity.Y < -9f) + NPC.velocity.Y = -9f; + + NPC.rotation = NPC.velocity.X * 0.05f; + + if ((iceQueenTargetDist < 500f || NPC.ai[3] < 0f) && NPC.position.Y < Main.player[NPC.target].position.Y) + { + NPC.ai[3] += 1f; + int frostWaveFireDelay = 8; + if ((double)NPC.life < (double)NPC.lifeMax * 0.75) + frostWaveFireDelay = 7; + if ((double)NPC.life < (double)NPC.lifeMax * 0.5) + frostWaveFireDelay = 6; + if ((double)NPC.life < (double)NPC.lifeMax * 0.25) + frostWaveFireDelay = 5; + + frostWaveFireDelay++; + if (NPC.ai[3] > (float)frostWaveFireDelay) + NPC.ai[3] = (float)-(float)frostWaveFireDelay; + + if (NPC.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 frostWavePosition = new Vector2(NPC.Center.X, NPC.Center.Y); + frostWavePosition.X += NPC.velocity.X * 7f; + float frostWaveTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - frostWavePosition.X; + float frostWaveTargetY = Main.player[NPC.target].Center.Y - frostWavePosition.Y; + float frostWaveTargetDist = (float)Math.Sqrt((double)(frostWaveTargetX * frostWaveTargetX + frostWaveTargetY * frostWaveTargetY)); + + float frostWaveSpeed = 8f; + if ((double)NPC.life < (double)NPC.lifeMax * 0.75) + frostWaveSpeed = 9f; + if ((double)NPC.life < (double)NPC.lifeMax * 0.5) + frostWaveSpeed = 10f; + if ((double)NPC.life < (double)NPC.lifeMax * 0.25) + frostWaveSpeed = 11f; + + frostWaveTargetDist = frostWaveSpeed / frostWaveTargetDist; + frostWaveTargetX *= frostWaveTargetDist; + frostWaveTargetY *= frostWaveTargetDist; + + Projectile.NewProjectile(NPC.GetSource_FromAI(), frostWavePosition.X, frostWavePosition.Y, frostWaveTargetX, frostWaveTargetY, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); + } + } + else if (NPC.ai[3] < 0f) + NPC.ai[3] += 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[1] += (float)Main.rand.Next(1, 4); + + if (NPC.ai[1] > 600f && iceQueenTargetDist < 600f) + NPC.ai[0] = -1f; + } + } + else if (NPC.ai[0] == 1f) + { + NPC.TargetClosest(true); + + float icicleAttackAcceleration = 0.2f; + float icicleAttackMaxVelocity = 10f; + if ((double)NPC.life < (double)NPC.lifeMax * 0.75) + { + icicleAttackAcceleration = 0.24f; + icicleAttackMaxVelocity = 12f; + } + if ((double)NPC.life < (double)NPC.lifeMax * 0.5) + { + icicleAttackAcceleration = 0.28f; + icicleAttackMaxVelocity = 14f; + } + if ((double)NPC.life < (double)NPC.lifeMax * 0.25) + { + icicleAttackAcceleration = 0.32f; + icicleAttackMaxVelocity = 16f; + } + icicleAttackAcceleration -= 0.05f; + icicleAttackMaxVelocity -= 1f; + + if (NPC.Center.X < Main.player[NPC.target].Center.X) + { + NPC.velocity.X += icicleAttackAcceleration; + if (NPC.velocity.X < 0f) + NPC.velocity.X *= 0.98f; + } + if (NPC.Center.X > Main.player[NPC.target].Center.X) + { + NPC.velocity.X -= icicleAttackAcceleration; + if (NPC.velocity.X > 0f) + NPC.velocity.X *= 0.98f; + } + if (NPC.velocity.X > icicleAttackMaxVelocity || NPC.velocity.X < -icicleAttackMaxVelocity) + NPC.velocity.X *= 0.95f; + + float icicleAttackHoverHeight = Main.player[NPC.target].position.Y - (NPC.position.Y + (float)NPC.height); + if (icicleAttackHoverHeight < 180f) + NPC.velocity.Y -= 0.1f; + if (icicleAttackHoverHeight > 200f) + NPC.velocity.Y += 0.1f; + + if (NPC.velocity.Y > 7f) + NPC.velocity.Y = 7f; + if (NPC.velocity.Y < -7f) + NPC.velocity.Y = -7f; + + NPC.rotation = NPC.velocity.X * 0.01f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[3] += 1f; + int icicleFireDelay = 10; + if ((double)NPC.life < (double)NPC.lifeMax * 0.75) + icicleFireDelay = 8; + if ((double)NPC.life < (double)NPC.lifeMax * 0.5) + icicleFireDelay = 6; + if ((double)NPC.life < (double)NPC.lifeMax * 0.25) + icicleFireDelay = 4; + if ((double)NPC.life < (double)NPC.lifeMax * 0.1) + icicleFireDelay = 2; + + icicleFireDelay += 3; + if (NPC.ai[3] >= (float)icicleFireDelay) + { + NPC.ai[3] = 0f; + Vector2 icicleSpawnPos = new Vector2(NPC.Center.X, NPC.position.Y + (float)NPC.height - 14f); + int i2 = (int)(icicleSpawnPos.X / 16f); + int j2 = (int)(icicleSpawnPos.Y / 16f); + if (!WorldGen.SolidTile(i2, j2)) + { + float icicleFallSpeed = NPC.velocity.Y; + + if (icicleFallSpeed < 0f) + icicleFallSpeed = 0f; + + icicleFallSpeed += 3f; + float speedX2 = NPC.velocity.X * 0.25f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), icicleSpawnPos.X, icicleSpawnPos.Y, speedX2, icicleFallSpeed, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); + } + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[1] += (float)Main.rand.Next(1, 4); + + if (NPC.ai[1] > 450f) + NPC.ai[0] = -1f; + } + } + else if (NPC.ai[0] == 2f) + { + NPC.TargetClosest(true); + + Vector2 iceRainPosition = new Vector2(NPC.Center.X, NPC.Center.Y - 20f); + float iceRainXVel = (float)Main.rand.Next(-1000, 1001); + float iceRainYVel = (float)Main.rand.Next(-1000, 1001); + float iceRainVelocity = (float)Math.Sqrt((double)(iceRainXVel * iceRainXVel + iceRainYVel * iceRainYVel)); + float iceRainSpeed = 20f; + + NPC.velocity *= 0.95f; + iceRainVelocity = iceRainSpeed / iceRainVelocity; + iceRainXVel *= iceRainVelocity; + iceRainYVel *= iceRainVelocity; + NPC.rotation += 0.2f; + iceRainPosition.X += iceRainXVel * 4f; + iceRainPosition.Y += iceRainYVel * 4f; + + NPC.ai[3] += 1f; + int iceRainFireDelay = 7; + if ((double)NPC.life < (double)NPC.lifeMax * 0.75) + iceRainFireDelay--; + if ((double)NPC.life < (double)NPC.lifeMax * 0.5) + iceRainFireDelay -= 2; + if ((double)NPC.life < (double)NPC.lifeMax * 0.25) + iceRainFireDelay -= 3; + if ((double)NPC.life < (double)NPC.lifeMax * 0.1) + iceRainFireDelay -= 4; + + if (NPC.ai[3] > (float)iceRainFireDelay) + { + NPC.ai[3] = 0f; + int iceRainAttack = Projectile.NewProjectile(NPC.GetSource_FromAI(), iceRainPosition.X, iceRainPosition.Y, iceRainXVel, iceRainYVel, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[1] += (float)Main.rand.Next(1, 4); + + if (NPC.ai[1] > 300f) + NPC.ai[0] = -1f; + } + } + if (NPC.ai[0] == -1f) + { + int attackPicker = Main.rand.Next(3); + NPC.TargetClosest(true); + + if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) > 1000f) + attackPicker = 0; + + NPC.ai[0] = (float)attackPicker; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/MiniBosses/MothronAI.cs b/NPCs/VanillaNPCAIOverrides/MiniBosses/MothronAI.cs new file mode 100644 index 0000000000..a112f4fda6 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/MiniBosses/MothronAI.cs @@ -0,0 +1,459 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses +{ + public class MothronAI : VanillaAIOverride + { + internal enum MothronAIState + { + DespawnYeet = -1, + NewAISelection = 0, + FlyTowardsPlayer = 1, + AccelerateTowardsPlayer = 2, + ChargeRedirect = 3, + ChargePreparation = 4, + DoTheFuckingCharge = 5, + PickSpotToLayEgg = 6, + FlyToEggSpot = 7, + LayEgg = 8 + } + + public override bool AI(Mod mod) + { + NPC.noTileCollide = false; + NPC.noGravity = true; + NPC.knockBackResist = 0f; + + ref float aiState = ref NPC.ai[0]; + + // Percent life remaining + float lifeRatio = NPC.life / (float)NPC.lifeMax; + + // Phases + bool phase2 = lifeRatio < 0.4f; + bool phase3 = lifeRatio < 0.1f; + + Player target = Main.player[NPC.target]; + + // Despawn if no valid target exists or there's no ongoing eclipse. + if (!Main.eclipse) + aiState = (int)MothronAIState.DespawnYeet; + else if (NPC.target < 0 || target.dead || !target.active) + { + NPC.TargetClosest(true); + if (target.dead) + { + aiState = (int)MothronAIState.DespawnYeet; + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.netUpdate = true; + } + } + + float flyInertia; + float chargeSpeed = 32f; + Vector2 idealFlyVelocity; + switch ((MothronAIState)(int)aiState) + { + case MothronAIState.DespawnYeet: + NPC.damage = 0; + Vector2 idealVelocity = Vector2.UnitY * -34f; + NPC.velocity = (NPC.velocity * 4f + idealVelocity) / 5f; + NPC.noTileCollide = true; + NPC.dontTakeDamage = true; + return false; + + case MothronAIState.NewAISelection: + NPC.damage = 0; + + ref float aiTimer = ref NPC.ai[1]; + + NPC.TargetClosest(true); + + if (NPC.Center.X < target.Center.X - 2f) + NPC.direction = 1; + if (NPC.Center.X > target.Center.X + 2f) + NPC.direction = -1; + + NPC.spriteDirection = NPC.direction; + NPC.rotation = (NPC.rotation * 9f + NPC.velocity.X * 0.025f) / 10f; + + // Rebounding on tile collision. + if (NPC.collideX) + { + NPC.velocity.X *= -NPC.oldVelocity.X * 0.5f; + NPC.velocity.X = MathHelper.Clamp(NPC.velocity.X, -4f, 4f); + } + if (NPC.collideY) + { + NPC.velocity.Y *= -NPC.oldVelocity.Y * 0.5f; + NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y, -4f, 4f); + } + + Vector2 destinationAboveTarget = target.Center - Vector2.UnitY * 200f; + float distanceFromAboveTarget = NPC.Distance(destinationAboveTarget); + if (distanceFromAboveTarget > 3000f) + { + aiState = (int)MothronAIState.FlyTowardsPlayer; + aiTimer = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + // Otherwise fly towards the destination if relatively far from it. + else if (distanceFromAboveTarget > 600f) + { + flyInertia = 30f; + idealFlyVelocity = NPC.SafeDirectionTo(destinationAboveTarget, -Vector2.UnitY) * 15f; + NPC.velocity = (NPC.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; + } + + // And otherwise, if near the destination, slow down a bit. + else if (NPC.velocity.Length() > 2f) + NPC.velocity *= 0.95f; + else if (NPC.velocity.Length() < 1f) + NPC.velocity *= 1.05f; + + aiTimer++; + + // Select a new AI state after 10 frames. + if (aiTimer >= 10f && Main.netMode != NetmodeID.MultiplayerClient) + { + aiTimer = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + + while ((MothronAIState)(int)aiState == MothronAIState.NewAISelection) + { + int selection = Main.rand.Next(3); + if (phase3) + selection = 1; + else if (phase2) + selection = Main.rand.Next(2); + + if (selection == 0 && Collision.CanHit(NPC.Center, 1, 1, target.Center, 1, 1)) + aiState = (int)MothronAIState.AccelerateTowardsPlayer; + else if (selection == 1) + aiState = (int)MothronAIState.ChargeRedirect; + else if (selection == 2 && NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 2) + aiState = (int)MothronAIState.PickSpotToLayEgg; + } + NPC.ForceNetUpdate(); + } + break; + + case MothronAIState.FlyTowardsPlayer: + NPC.damage = 0; + + NPC.collideX = false; + NPC.collideY = false; + NPC.noTileCollide = true; + + if (NPC.target < 0 || !target.active || target.dead) + NPC.TargetClosest(true); + + NPC.spriteDirection = NPC.direction = (NPC.velocity.X > 0).ToDirectionInt(); + NPC.rotation = (NPC.rotation * 9f + NPC.velocity.X * 0.02f) / 10f; + + // Don't bother flying anymore if we're stuck and the target is somewhat close. + if (NPC.WithinRange(target.Center, 500f) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + aiState = (int)MothronAIState.NewAISelection; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + float flySpeed = 18f + NPC.Distance(target.Center) / 100f; + flyInertia = 25f; + idealFlyVelocity = NPC.SafeDirectionTo(target.Center, -Vector2.UnitY) * flySpeed; + NPC.velocity = (NPC.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; + break; + + case MothronAIState.AccelerateTowardsPlayer: + NPC.damage = (int)Math.Round(NPC.defDamage * 0.5); + + aiTimer = ref NPC.ai[1]; + ref float flySpeedAdditive = ref NPC.ai[2]; + + // If no valid target exists, try to find a new one and select a new attack. + if (NPC.target < 0 || !target.active || target.dead) + { + NPC.TargetClosest(true); + aiState = (int)MothronAIState.NewAISelection; + aiTimer = 0f; + flySpeedAdditive = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + NPC.spriteDirection = NPC.direction = (NPC.velocity.X > 0).ToDirectionInt(); + NPC.rotation = (NPC.rotation * 4f + NPC.velocity.X * 0.025f) / 5f; + + // Rebounding on tile collision. + if (NPC.collideX) + { + NPC.velocity.X *= -NPC.oldVelocity.X * 0.5f; + NPC.velocity.X = MathHelper.Clamp(NPC.velocity.X, -4f, 4f); + } + if (NPC.collideY) + { + NPC.velocity.Y *= -NPC.oldVelocity.Y * 0.5f; + NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y, -4f, 4f); + } + + Vector2 destination = target.Center - Vector2.UnitY * 20f; + + flySpeedAdditive += 0.0222222228f; + if (Main.expertMode) + flySpeedAdditive += 0.0166666675f; + + flySpeed = 12f + flySpeedAdditive + NPC.Distance(destination) / 120f; + flyInertia = 20f; + idealFlyVelocity = NPC.SafeDirectionTo(destination, -Vector2.UnitY) * flySpeed; + NPC.velocity = (NPC.velocity * (flyInertia - 1f) + idealFlyVelocity) / flyInertia; + + aiTimer++; + // Stop flying if there's an obstacle between the npc and target. + if (aiTimer >= 120f || !Collision.CanHit(NPC.Center, 1, 1, target.Center, 1, 1)) + { + aiState = (int)MothronAIState.NewAISelection; + aiTimer = 0f; + flySpeedAdditive = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + break; + + case MothronAIState.ChargeRedirect: + NPC.damage = 0; + + flySpeedAdditive = ref NPC.ai[2]; + NPC.noTileCollide = true; + + NPC.spriteDirection = NPC.direction = (NPC.velocity.X > 0).ToDirectionInt(); + NPC.rotation = (NPC.rotation * 4f + NPC.velocity.X * 0.0175f) / 5f; + + destination = target.Center; + destination -= Vector2.UnitY * 12f; + + float xOffset = 600f; + if (NPC.Center.X > target.Center.X) + destination.X += xOffset; + else + destination.X -= xOffset; + + // If close to the destination beside the player, enter the charge phase. + if (Main.netMode != NetmodeID.MultiplayerClient && + Math.Abs(NPC.Center.X - target.Center.X) > xOffset - 50f && Math.Abs(NPC.Center.Y - target.Center.Y) < 20f) + { + aiState = (int)MothronAIState.ChargePreparation; + flySpeedAdditive = 0f; + NPC.ForceNetUpdate(); + } + + flySpeedAdditive += 0.0333333351f; + flySpeed = 24f + flySpeedAdditive; + flyInertia = 4f; + idealVelocity = NPC.SafeDirectionTo(destination, -Vector2.UnitY) * flySpeed; + NPC.velocity = (NPC.velocity * (flyInertia - 1f) + idealVelocity) / flyInertia; + break; + + case MothronAIState.ChargePreparation: + NPC.damage = 0; + + aiTimer = ref NPC.ai[1]; + ref float chargeDirection = ref NPC.ai[2]; + + NPC.noTileCollide = true; + NPC.rotation = (NPC.rotation * 4f + NPC.velocity.X * 0.0175f) / 5f; + + destination = target.Center - Vector2.UnitY * 12f; + + float chargePreperationInertia = 8f; + Vector2 chargeVelocity = NPC.SafeDirectionTo(destination, -Vector2.UnitY) * chargeSpeed; + NPC.velocity = (NPC.velocity * (chargePreperationInertia - 1f) + chargeVelocity) / chargePreperationInertia; + NPC.spriteDirection = NPC.direction = (NPC.velocity.X > 0).ToDirectionInt(); + + // Redirect for 10 frames. After that time has been spent, immediately charge as usual. + if (Main.netMode != NetmodeID.MultiplayerClient) + { + aiTimer++; + if (aiTimer > 10f) + { + NPC.velocity = chargeVelocity; + + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + aiState = (int)MothronAIState.DoTheFuckingCharge; + chargeDirection = NPC.direction; + NPC.ForceNetUpdate(); + } + } + break; + + case MothronAIState.DoTheFuckingCharge: + chargeDirection = ref NPC.ai[2]; + flySpeedAdditive = ref NPC.ai[3]; + + NPC.damage = (int)Math.Round(NPC.defDamage * 1.2); + NPC.collideX = false; + NPC.collideY = false; + NPC.noTileCollide = true; + flySpeedAdditive += 0.0333333351f; + NPC.velocity.X = (chargeSpeed + flySpeedAdditive) * chargeDirection; + + float chargeDistance = 460f; + if (Main.netMode != NetmodeID.MultiplayerClient && + (chargeDirection > 0f && NPC.Center.X > target.Center.X + chargeDistance) || + (chargeDirection < 0f && NPC.Center.X < target.Center.X - chargeDistance)) + { + // If not stuck, pick a new attack. + if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + aiState = (int)MothronAIState.NewAISelection; + chargeDirection = 0f; + flySpeedAdditive = 0f; + NPC.ForceNetUpdate(); + } + + // Otherwise, if somewhat horizontally far from the target, go to typical flying by default. + else if (Math.Abs(NPC.Center.X - target.Center.X) > chargeDistance * 2f - 120f) + { + aiState = (int)MothronAIState.FlyTowardsPlayer; + chargeDirection = 0f; + flySpeedAdditive = 0f; + NPC.ForceNetUpdate(); + } + } + NPC.rotation = (NPC.rotation * 4f + NPC.velocity.X * 0.0175f) / 5f; + break; + + case MothronAIState.PickSpotToLayEgg: + NPC.damage = 0; + + ref float laySpotPositionX = ref NPC.ai[2]; + ref float laySpotPositionY = ref NPC.ai[3]; + // Fallback if the spot selection fails. + NPC.TargetClosest(true); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + aiState = (int)MothronAIState.NewAISelection; + laySpotPositionX = laySpotPositionY = -1f; + + for (int i = 0; i < 1000; i++) + { + int potentialSpotX = (int)target.Center.X / 16; + int potentialSpotY = (int)target.Center.Y / 16; + + // Become more open to positions to search the more failed tries that have been accumulated. + int checkAreaX = 30 + i / 50; + int checkAreaY = 20 + i / 75; + + potentialSpotX += Main.rand.Next(-checkAreaX, checkAreaX + 1); + potentialSpotY += Main.rand.Next(-checkAreaY, checkAreaY + 1); + + if (!WorldGen.SolidTile(potentialSpotX, potentialSpotY)) + { + // Search downward until a solid tile is reached. + // Stop checking if the spot is below the world surface, to prevent potential infinite loops. + while (!WorldGen.SolidTile(potentialSpotX, potentialSpotY) && potentialSpotY < Main.worldSurface) + potentialSpotY++; + + // And ensure that the spot isn't too far away. + if (NPC.WithinRange(new Vector2(potentialSpotX, potentialSpotY).ToWorldCoordinates(), 1600f)) + { + aiState = (int)MothronAIState.FlyToEggSpot; + laySpotPositionX = potentialSpotX; + laySpotPositionY = potentialSpotY; + break; + } + } + } + NPC.ForceNetUpdate(); + } + break; + + case MothronAIState.FlyToEggSpot: + NPC.damage = 0; + + NPC.spriteDirection = NPC.direction = (NPC.velocity.X > 0).ToDirectionInt(); + NPC.rotation = (NPC.rotation * 9f + NPC.velocity.X * 0.025f) / 10f; + NPC.noTileCollide = true; + + Vector2 spotToLayEgg = new Vector2(NPC.ai[2], NPC.ai[3]).ToWorldCoordinates(8f, -20f); + float distanceFromSpot = NPC.Distance(spotToLayEgg); + flySpeed = 12f + distanceFromSpot / 150f; + + if (flySpeed > 20f) + flySpeed = 20f; + + if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 10f) + { + aiState = (int)MothronAIState.LayEgg; + NPC.netUpdate = true; + } + + flyInertia = 10f; + NPC.velocity = (NPC.velocity * (flyInertia - 1f) + NPC.SafeDirectionTo(spotToLayEgg, -Vector2.UnitY) * flySpeed) / flyInertia; + break; + + case MothronAIState.LayEgg: + NPC.damage = 0; + + NPC.rotation = (NPC.rotation * 9f + NPC.velocity.X * 0.025f) / 10f; + NPC.noTileCollide = false; + + spotToLayEgg = new Vector2(NPC.ai[2], NPC.ai[3]).ToWorldCoordinates(8f, -28f); + distanceFromSpot = NPC.Distance(spotToLayEgg); + float hoverSpeed = 4f; + float hoverInertia = 2f; + + if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromSpot < 44f) + { + ref float attackTimer = ref NPC.ai[1]; + int eggLayTime = 20; + if (Main.expertMode) + eggLayTime = (int)(eggLayTime * 0.75); + int waitTime = eggLayTime; + + attackTimer++; + if (attackTimer == eggLayTime) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)spotToLayEgg.X, (int)spotToLayEgg.Y + 20, NPCID.MothronEgg, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + else if (attackTimer == eggLayTime + waitTime) + { + aiState = (int)MothronAIState.NewAISelection; + attackTimer = 0f; + NPC.ai[2] = NPC.ai[3] = 0f; + + // Try to lay another egg at a 66% chance if the amount of eggs + spawns is not at the limit. + if (NPC.CountNPCS(NPCID.MothronEgg) + NPC.CountNPCS(NPCID.MothronSpawn) < 3 && !Main.rand.NextBool(3)) + aiState = (int)MothronAIState.PickSpotToLayEgg; + else if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + aiState = (int)MothronAIState.FlyTowardsPlayer; + NPC.netUpdate = true; + } + } + + if (distanceFromSpot < hoverSpeed) + hoverSpeed = distanceFromSpot; + + Vector2 hoverVelocity = NPC.SafeDirectionTo(spotToLayEgg) * hoverSpeed; + NPC.velocity = (NPC.velocity * (hoverInertia - 1f) + hoverVelocity) / hoverInertia; + if (NPC.velocity.HasNaNs()) + NPC.velocity = Vector2.Zero; + break; + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/MiniBosses/PumpkingAI.cs b/NPCs/VanillaNPCAIOverrides/MiniBosses/PumpkingAI.cs new file mode 100644 index 0000000000..9f8078df3a --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/MiniBosses/PumpkingAI.cs @@ -0,0 +1,372 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.MiniBosses +{ + public class PumpkingAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.localAI[0] += 1f; + if (NPC.localAI[0] > 6f) + { + NPC.localAI[0] = 0f; + NPC.localAI[1] += 1f; + + if (NPC.localAI[1] > 4f) + NPC.localAI[1] = 0f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[2] += 1f; + if (NPC.localAI[2] > 300f) + { + NPC.ai[3] = (float)Main.rand.Next(3); + NPC.localAI[2] = 0f; + } + else if (NPC.ai[3] == 0f && NPC.localAI[2] % 30f == 0f && NPC.localAI[2] > 30f) + { + float greekFireSpeed = 10f; + Vector2 greekFireSpawnPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f + 30f); + if (!WorldGen.SolidTile((int)greekFireSpawnPos.X / 16, (int)greekFireSpawnPos.Y / 16)) + { + float greekFireTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - greekFireSpawnPos.X; + float greekFireTargetY = Main.player[NPC.target].position.Y - greekFireSpawnPos.Y; + greekFireTargetX += (float)Main.rand.Next(-50, 51); + greekFireTargetY += (float)Main.rand.Next(50, 201); + greekFireTargetY *= 0.2f; + float greekFireTargetDist = (float)Math.Sqrt((double)(greekFireTargetX * greekFireTargetX + greekFireTargetY * greekFireTargetY)); + greekFireTargetDist = greekFireSpeed / greekFireTargetDist; + greekFireTargetX *= greekFireTargetDist; + greekFireTargetY *= greekFireTargetDist; + greekFireTargetX *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + greekFireTargetY *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), greekFireSpawnPos.X, greekFireSpawnPos.Y, greekFireTargetX, greekFireTargetY, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); + } + } + } + + if (NPC.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.TargetClosest(true); + NPC.ai[0] = 1f; + + int pumpkingBlades = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)NPC.position.Y + NPC.height / 2, NPCID.PumpkingBlade, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[pumpkingBlades].ai[0] = -1f; + Main.npc[pumpkingBlades].ai[1] = (float)NPC.whoAmI; + Main.npc[pumpkingBlades].target = NPC.target; + Main.npc[pumpkingBlades].netUpdate = true; + + pumpkingBlades = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)NPC.position.Y + NPC.height / 2, NPCID.PumpkingBlade, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[pumpkingBlades].ai[0] = 1f; + Main.npc[pumpkingBlades].ai[1] = (float)NPC.whoAmI; + Main.npc[pumpkingBlades].ai[3] = 150f; + Main.npc[pumpkingBlades].target = NPC.target; + Main.npc[pumpkingBlades].netUpdate = true; + } + + if (Main.player[NPC.target].dead || Math.Abs(NPC.position.X - Main.player[NPC.target].position.X) > 2000f || Math.Abs(NPC.position.Y - Main.player[NPC.target].position.Y) > 2000f) + { + NPC.TargetClosest(true); + + if (Main.player[NPC.target].dead || Math.Abs(NPC.position.X - Main.player[NPC.target].position.X) > 2000f || Math.Abs(NPC.position.Y - Main.player[NPC.target].position.Y) > 2000f) + NPC.ai[1] = 2f; + } + + if (Main.dayTime) + { + NPC.velocity.Y += 0.3f; + NPC.velocity.X *= 0.9f; + } + else if (NPC.ai[1] == 0f) + { + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 300f) + { + if (NPC.ai[3] != 1f) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + else + { + NPC.ai[2] = 0f; + NPC.ai[1] = 1f; + NPC.TargetClosest(true); + NPC.netUpdate = true; + } + } + + Vector2 aggressivePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float aggressiveTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - aggressivePosition.X; + float aggressiveTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 200f - aggressivePosition.Y; + float aggressiveTargetDist = (float)Math.Sqrt((double)(aggressiveTargetX * aggressiveTargetX + aggressiveTargetY * aggressiveTargetY)); + float aggressiveSpeed = 8f; + + if (NPC.ai[3] == 1f) + { + if (aggressiveTargetDist > 900f) + aggressiveSpeed = 14f; + else if (aggressiveTargetDist > 600f) + aggressiveSpeed = 12f; + else if (aggressiveTargetDist > 300f) + aggressiveSpeed = 10f; + } + + if (aggressiveTargetDist > 50f) + { + aggressiveTargetDist = aggressiveSpeed / aggressiveTargetDist; + NPC.velocity.X = (NPC.velocity.X * 14f + aggressiveTargetX * aggressiveTargetDist) / 15f; + NPC.velocity.Y = (NPC.velocity.Y * 14f + aggressiveTargetY * aggressiveTargetDist) / 15f; + } + } + else if (NPC.ai[1] == 1f) + { + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 600f || NPC.ai[3] != 1f) + { + NPC.ai[2] = 0f; + NPC.ai[1] = 0f; + } + + Vector2 scytheAttackPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float scytheAttackTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - scytheAttackPosition.X; + float scytheAttackTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - scytheAttackPosition.Y; + float scytheAttackTargetDist = (float)Math.Sqrt((double)(scytheAttackTargetX * scytheAttackTargetX + scytheAttackTargetY * scytheAttackTargetY)); + scytheAttackTargetDist = 20f / scytheAttackTargetDist; + + NPC.velocity.X = (NPC.velocity.X * 49f + scytheAttackTargetX * scytheAttackTargetDist) / 50f; + NPC.velocity.Y = (NPC.velocity.Y * 49f + scytheAttackTargetY * scytheAttackTargetDist) / 50f; + } + else if (NPC.ai[1] == 2f) + { + NPC.ai[1] = 3f; + NPC.velocity.Y += 0.1f; + + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.95f; + + NPC.velocity.X *= 0.95f; + + if (NPC.timeLeft > 500) + NPC.timeLeft = 500; + } + NPC.rotation = NPC.velocity.X * -0.02f; + + return false; + } + + public class BladeAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.spriteDirection = -(int)NPC.ai[0]; + + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPCAIStyleID.Pumpking) + { + NPC.ai[2] += 10f; + if (NPC.ai[2] > 50f || !Main.dedServ) + { + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient && Main.npc[(int)NPC.ai[1]].ai[3] == 2f) + { + NPC.localAI[1] += 1f; + if (NPC.localAI[1] > 30f) + { + NPC.localAI[1] = 0f; + + float scytheProjSpeed = 0.01f; + Vector2 scytheProjSpawn = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f + 30f); + float scytheProjTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - scytheProjSpawn.X; + float scytheProjTargetY = Main.player[NPC.target].position.Y - scytheProjSpawn.Y; + float scytheProjTargetDist = (float)Math.Sqrt((double)(scytheProjTargetX * scytheProjTargetX + scytheProjTargetY * scytheProjTargetY)); + + scytheProjTargetDist = scytheProjSpeed / scytheProjTargetDist; + scytheProjTargetX *= scytheProjTargetDist; + scytheProjTargetY *= scytheProjTargetDist; + + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, scytheProjTargetX, scytheProjTargetY, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, NPC.rotation, (float)NPC.spriteDirection); + } + } + + if (Main.dayTime) + { + NPC.velocity.Y += 0.3f; + NPC.velocity.X *= 0.9f; + return false; + } + + if (NPC.ai[2] == 0f || NPC.ai[2] == 3f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (Main.npc[(int)NPC.ai[1]].ai[1] == 3f && NPC.timeLeft > 10) + NPC.timeLeft = 10; + + NPC.ai[3] += 1f; + if (NPC.ai[3] >= 180f) + { + NPC.ai[2] += 1f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + Vector2 scytheSwipePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float scytheSwipeTargetX = (Main.player[NPC.target].Center.X + Main.npc[(int)NPC.ai[1]].Center.X) / 2f; + float scytheSwipeTargetY = (Main.player[NPC.target].Center.Y + Main.npc[(int)NPC.ai[1]].Center.Y) / 2f; + scytheSwipeTargetX += -170f * NPC.ai[0] - scytheSwipePosition.X; + scytheSwipeTargetY += 90f - scytheSwipePosition.Y; + + float scytheSwipeReelbackDist = Math.Abs(Main.player[NPC.target].Center.X - Main.npc[(int)NPC.ai[1]].Center.X) + Math.Abs(Main.player[NPC.target].Center.Y - Main.npc[(int)NPC.ai[1]].Center.Y); + if (scytheSwipeReelbackDist > 700f) + { + scytheSwipeTargetX = Main.npc[(int)NPC.ai[1]].Center.X - 170f * NPC.ai[0] - scytheSwipePosition.X; + scytheSwipeTargetY = Main.npc[(int)NPC.ai[1]].Center.Y + 90f - scytheSwipePosition.Y; + } + + float scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); + float scytheSwipeSpeed = 8f; + if (scytheSwipeTargetDist > 1000f) + scytheSwipeSpeed = 23f; + else if (scytheSwipeTargetDist > 800f) + scytheSwipeSpeed = 20f; + else if (scytheSwipeTargetDist > 600f) + scytheSwipeSpeed = 17f; + else if (scytheSwipeTargetDist > 400f) + scytheSwipeSpeed = 14f; + else if (scytheSwipeTargetDist > 200f) + scytheSwipeSpeed = 11f; + + if (NPC.ai[0] < 0f && NPC.Center.X > Main.npc[(int)NPC.ai[1]].Center.X) + scytheSwipeTargetX -= 4f; + if (NPC.ai[0] > 0f && NPC.Center.X < Main.npc[(int)NPC.ai[1]].Center.X) + scytheSwipeTargetX += 4f; + + scytheSwipeTargetDist = scytheSwipeSpeed / scytheSwipeTargetDist; + NPC.velocity.X = (NPC.velocity.X * 14f + scytheSwipeTargetX * scytheSwipeTargetDist) / 15f; + NPC.velocity.Y = (NPC.velocity.Y * 14f + scytheSwipeTargetY * scytheSwipeTargetDist) / 15f; + scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); + + if (scytheSwipeTargetDist > 20f) + NPC.rotation = (float)Math.Atan2((double)scytheSwipeTargetY, (double)scytheSwipeTargetX) + MathHelper.PiOver2; + } + else if (NPC.ai[2] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + Vector2 scytheReturnPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float scytheReturnTargetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - 200f * NPC.ai[0] - scytheReturnPosition.X; + float scytheReturnTargetY = Main.npc[(int)NPC.ai[1]].position.Y + 230f - scytheReturnPosition.Y; + float scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); + + NPC.rotation = (float)Math.Atan2((double)scytheReturnTargetY, (double)scytheReturnTargetX) + MathHelper.PiOver2; + NPC.velocity.X *= 0.95f; + NPC.velocity.Y -= 0.3f; + + if (NPC.velocity.Y < -18f) + NPC.velocity.Y = -18f; + + if (NPC.position.Y < Main.npc[(int)NPC.ai[1]].position.Y - 200f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.TargetClosest(true); + NPC.ai[2] = 2f; + + scytheReturnPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + scytheReturnTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - scytheReturnPosition.X; + scytheReturnTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - scytheReturnPosition.Y; + scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); + scytheReturnTargetDist = 24f / scytheReturnTargetDist; + + NPC.velocity.X = scytheReturnTargetX * scytheReturnTargetDist; + NPC.velocity.Y = scytheReturnTargetY * scytheReturnTargetDist; + NPC.netUpdate = true; + } + } + else if (NPC.ai[2] == 2f) + { + // Avoid cheap bullshit + NPC.damage = NPC.defDamage; + + float scytheReturnDestination = Math.Abs(NPC.Center.X - Main.npc[(int)NPC.ai[1]].Center.X) + Math.Abs(NPC.Center.Y - Main.npc[(int)NPC.ai[1]].Center.Y); + + if (NPC.position.Y > Main.player[NPC.target].position.Y || NPC.velocity.Y < 0f || scytheReturnDestination > 800f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[2] = 3f; + } + } + else if (NPC.ai[2] == 4f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + Vector2 scytheLesserSwipePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float scytheLesserSwipeTargetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - 200f * NPC.ai[0] - scytheLesserSwipePos.X; + float scytheLesserSwipeTargetY = Main.npc[(int)NPC.ai[1]].position.Y + 230f - scytheLesserSwipePos.Y; + float scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); + + NPC.rotation = (float)Math.Atan2((double)scytheLesserSwipeTargetY, (double)scytheLesserSwipeTargetX) + MathHelper.PiOver2; + NPC.velocity.Y *= 0.95f; + NPC.velocity.X += 0.3f * -NPC.ai[0]; + + if (NPC.velocity.X < -18f) + NPC.velocity.X = -18f; + if (NPC.velocity.X > 18f) + NPC.velocity.X = 18f; + + if (NPC.position.X + (float)(NPC.width / 2) < Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - 500f || NPC.position.X + (float)(NPC.width / 2) > Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) + 500f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.TargetClosest(true); + NPC.ai[2] = 5f; + + scytheLesserSwipePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + scytheLesserSwipeTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - scytheLesserSwipePos.X; + scytheLesserSwipeTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - scytheLesserSwipePos.Y; + scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); + scytheLesserSwipeTargetDist = 17f / scytheLesserSwipeTargetDist; + + NPC.velocity.X = scytheLesserSwipeTargetX * scytheLesserSwipeTargetDist; + NPC.velocity.Y = scytheLesserSwipeTargetY * scytheLesserSwipeTargetDist; + NPC.netUpdate = true; + } + } + else if (NPC.ai[2] == 5f) + { + // Set damage + NPC.damage = NPC.defDamage; + + float scytheLesserSwipeReturnDest = Math.Abs(NPC.Center.X - Main.npc[(int)NPC.ai[1]].Center.X) + Math.Abs(NPC.Center.Y - Main.npc[(int)NPC.ai[1]].Center.Y); + + if ((NPC.velocity.X > 0f && NPC.position.X + (float)(NPC.width / 2) > Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2)) || (NPC.velocity.X < 0f && NPC.position.X + (float)(NPC.width / 2) < Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2)) || scytheLesserSwipeReturnDest > 800f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[2] = 0f; + } + } + + return false; + } + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/DemonEyeAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/DemonEyeAI.cs index 0c81735975..c60dd9f39c 100644 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/DemonEyeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/DemonEyeAI.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies { - public static class DemonEyeAI + public class DemonEyeAI : VanillaAIOverride { // Subtypes of enemies with this AI. Made for programmer convenience. public static List NightTimeEnemies => new List() @@ -104,71 +104,71 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies } } - public static bool BuffedDemonEyeAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { // Randomly play pigron noises if the NPC is a pigron. - if (Pigrons.Contains(npc.type) && Main.rand.NextBool(1000)) - SoundEngine.PlaySound(SoundID.Zombie9, npc.Center); + if (Pigrons.Contains(NPC.type) && Main.rand.NextBool(1000)) + SoundEngine.PlaySound(SoundID.Zombie9, NPC.Center); // Disable gravity. - npc.noGravity = true; + NPC.noGravity = true; // Handle tile collision rebounds if applicable. - if (!npc.noTileCollide) + if (!NPC.noTileCollide) { // Bounce off of tiles on the X axis. - if (npc.collideX) + if (NPC.collideX) { - npc.velocity.X = npc.oldVelocity.X * -0.5f; - if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - npc.velocity.X = 2f; + NPC.velocity.X = NPC.oldVelocity.X * -0.5f; + if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) + NPC.velocity.X = 2f; - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) + if (NPC.direction == 1 && NPC.velocity.X < 0f && NPC.velocity.X > -2f) { - npc.velocity.X = -2f; + NPC.velocity.X = -2f; } } // Bounce off of tiles on the Y axis. - if (npc.collideY) + if (NPC.collideY) { - npc.velocity.Y = npc.oldVelocity.Y * -0.5f; - if (npc.velocity.Y > 0f && npc.velocity.Y < 1f) - npc.velocity.Y = 1f; - if (npc.velocity.Y < 0f && npc.velocity.Y > -1f) - npc.velocity.Y = -1f; + NPC.velocity.Y = NPC.oldVelocity.Y * -0.5f; + if (NPC.velocity.Y > 0f && NPC.velocity.Y < 1f) + NPC.velocity.Y = 1f; + if (NPC.velocity.Y < 0f && NPC.velocity.Y > -1f) + NPC.velocity.Y = -1f; } } // If the NPC is supposed to only appear during the night, disappear if above-ground and it's daytime. - if (Main.dayTime && npc.position.Y <= Main.worldSurface * 16.0 && NightTimeEnemies.Contains(npc.type)) + if (Main.dayTime && NPC.position.Y <= Main.worldSurface * 16.0 && NightTimeEnemies.Contains(NPC.type)) { - if (npc.timeLeft > 10) - npc.timeLeft = 10; + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; // Adjust directions - npc.direction = (npc.velocity.X > 0f).ToDirectionInt(); - npc.directionY = (npc.velocity.X > 0f).ToDirectionInt(); + NPC.direction = (NPC.velocity.X > 0f).ToDirectionInt(); + NPC.directionY = (NPC.velocity.X > 0f).ToDirectionInt(); } // Otherwise constantly search for the closest target. else - npc.TargetClosest(); + NPC.TargetClosest(); - Player target = Main.player[npc.target]; - ref float fadeThroughWallsTimer = ref npc.ai[0]; - ref float fadeThroughWallsFlag = ref npc.ai[1]; + Player target = Main.player[NPC.target]; + ref float fadeThroughWallsTimer = ref NPC.ai[0]; + ref float fadeThroughWallsFlag = ref NPC.ai[1]; // Fade away and go through walls if the NPC is a pigron or Calamity eye. - if (Pigrons.Contains(npc.type) || npc.type == ModContent.NPCType()) + if (Pigrons.Contains(NPC.type) || NPC.type == ModContent.NPCType()) { // Stop going through walls if the target can be reached. - if (Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, target.position, target.width, target.height)) { - if (fadeThroughWallsFlag != 0f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + if (fadeThroughWallsFlag != 0f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { fadeThroughWallsFlag = 0f; fadeThroughWallsTimer = 0f; - npc.netUpdate = true; + NPC.netUpdate = true; } } else if (fadeThroughWallsFlag == 0f) @@ -178,84 +178,84 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies { fadeThroughWallsFlag = 1f; fadeThroughWallsTimer = 0f; - npc.netUpdate = true; + NPC.netUpdate = true; } if (fadeThroughWallsFlag == 0f) { - npc.alpha = 0; - npc.noTileCollide = false; + NPC.alpha = 0; + NPC.noTileCollide = false; } else { - npc.wet = false; - npc.alpha = 200; - npc.noTileCollide = true; + NPC.wet = false; + NPC.alpha = 200; + NPC.noTileCollide = true; } - npc.rotation = npc.velocity.Y * 0.1f * npc.direction; - npc.TargetClosest(true); + NPC.rotation = NPC.velocity.Y * 0.1f * NPC.direction; + NPC.TargetClosest(true); - DemonEyeBatMovement(npc); + DemonEyeBatMovement(NPC); } - else if (npc.type == NPCID.TheHungryII) + else if (NPC.type == NPCID.TheHungryII) { - npc.TargetClosest(true); + NPC.TargetClosest(true); // Emit light for some reason. - Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.3f, 0.2f, 0.1f); + Lighting.AddLight((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16, 0.3f, 0.2f, 0.1f); - DemonEyeBatMovement(npc, CalamityWorld.death ? 10f : 8f, CalamityWorld.death ? 5f : 3.5f, 0.12f, 0.12f, 0.25f, 0.06f, 0.07f, 0.2f); + DemonEyeBatMovement(NPC, CalamityWorld.death ? 10f : 8f, CalamityWorld.death ? 5f : 3.5f, 0.12f, 0.12f, 0.25f, 0.06f, 0.07f, 0.2f); if (Main.rand.NextBool(40)) { - Vector2 dustSpawnTopLeft = new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f); - Dust blood = Dust.NewDustDirect(dustSpawnTopLeft, npc.width, npc.height / 2, DustID.Blood, npc.velocity.X, 2f, 0, default, 1f); + Vector2 dustSpawnTopLeft = new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f); + Dust blood = Dust.NewDustDirect(dustSpawnTopLeft, NPC.width, NPC.height / 2, DustID.Blood, NPC.velocity.X, 2f, 0, default, 1f); blood.velocity.X *= 0.5f; blood.velocity.Y *= 0.1f; } } - else if (npc.type == NPCID.WanderingEye) + else if (NPC.type == NPCID.WanderingEye) { // Move faster when close to dying. - if (npc.life < npc.lifeMax * 0.5) - DemonEyeBatMovement(npc, CalamityWorld.death ? 10f : 8f, CalamityWorld.death ? 8f : 6f, 0.12f, 0.12f, 0.07f, 0.12f, 0.12f, 0.07f); + if (NPC.life < NPC.lifeMax * 0.5) + DemonEyeBatMovement(NPC, CalamityWorld.death ? 10f : 8f, CalamityWorld.death ? 8f : 6f, 0.12f, 0.12f, 0.07f, 0.12f, 0.12f, 0.07f); else - DemonEyeBatMovement(npc, CalamityWorld.death ? 8f : 6f, CalamityWorld.death ? 4f : 2.5f, 0.12f, 0.12f, 0.07f, 0.06f, 0.07f, 0.05f); + DemonEyeBatMovement(NPC, CalamityWorld.death ? 8f : 6f, CalamityWorld.death ? 4f : 2.5f, 0.12f, 0.12f, 0.07f, 0.06f, 0.07f, 0.05f); } else { float maxSpeedX = CalamityWorld.death ? 6f : 5f; float maxSpeedY = CalamityWorld.death ? 2.5f : 2f; - maxSpeedX *= 1f + (1f - npc.scale); - maxSpeedY *= 1f + (1f - npc.scale); - DemonEyeBatMovement(npc, maxSpeedX, maxSpeedY, 0.08f, 0.08f, 0.03f, 0.02f, 0.03f, 0.015f); + maxSpeedX *= 1f + (1f - NPC.scale); + maxSpeedY *= 1f + (1f - NPC.scale); + DemonEyeBatMovement(NPC, maxSpeedX, maxSpeedY, 0.08f, 0.08f, 0.03f, 0.02f, 0.03f, 0.015f); } // Make actual eyes emit blood randomly - if (npc.type == NPCID.DemonEye || - npc.type == NPCID.WanderingEye || - npc.type == ModContent.NPCType() || - (npc.type >= NPCID.CataractEye && npc.type <= NPCID.PurpleEye)) + if (NPC.type == NPCID.DemonEye || + NPC.type == NPCID.WanderingEye || + NPC.type == ModContent.NPCType() || + (NPC.type >= NPCID.CataractEye && NPC.type <= NPCID.PurpleEye)) { if (Main.rand.NextBool(40)) { - Vector2 dustSpawnTopLeft = new Vector2(npc.position.X, npc.position.Y + npc.height * 0.25f); - Dust blood = Dust.NewDustDirect(dustSpawnTopLeft, npc.width, npc.height / 2, DustID.Blood, npc.velocity.X, 2f, 0, default, 1f); + Vector2 dustSpawnTopLeft = new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f); + Dust blood = Dust.NewDustDirect(dustSpawnTopLeft, NPC.width, NPC.height / 2, DustID.Blood, NPC.velocity.X, 2f, 0, default, 1f); blood.velocity.X *= 0.5f; blood.velocity.Y *= 0.1f; } } // Avoid entering water. This does not apply to pigrons. - if (npc.wet && !Pigrons.Contains(npc.type)) + if (NPC.wet && !Pigrons.Contains(NPC.type)) { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.95f; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.95f; - npc.velocity.Y -= 0.6f; - if (npc.velocity.Y < -5f) - npc.velocity.Y = -5f; + NPC.velocity.Y -= 0.6f; + if (NPC.velocity.Y < -5f) + NPC.velocity.Y = -5f; - npc.TargetClosest(true); + NPC.TargetClosest(true); } return false; } diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs deleted file mode 100644 index 12cb14f419..0000000000 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs +++ /dev/null @@ -1,11589 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.NPCs.Astral; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.PlagueEnemies; -using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using ReLogic.Utilities; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.Events; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Utilities; - -namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies -{ - public static class RevengeanceAndDeathAI - { - #region Constants - - public const float ClingerShootGateValue = 120f; - public const float ClingerShootGateValue_Rev = 90f; - public const float ClingerTelegraphTime = 30f; - - public const float IchorStickerShootGateValue = 120f; - public const float IchorStickerShootGateValue_Rev = 90f; - public const float IchorStickerShootGateValue_Death = 60f; - public const float IchorStickerTelegraphTime = 30f; - - public const float SpiderWebSpitGateValue = 420f; - public const float SpiderWebSpitGateValue_Rev = 300f; - public const float SpiderWebSpitGateValue_Death = 180f; - public const float SpiderWebSpitTelegraphTime = 30f; - - public const float AntlionSandSpitGateValue = 200f; - public const float AntlionSandSpitTelegraphTime = 30f; - - public const float BlazingWheelFlameGateValue = 120f; - public const float BlazingWheelFlameGateValue_Death = 90f; - public const float BlazingWheelTelegraphTime = 30f; - - public const float HarpyFeatherGateValue = 600f; - public const float HarpyFeatherTelegraphTime = 30f; - - public const float DemonScytheGateValue = 450f; - public const float DemonScytheTelegraphTime = 30f; - - public const float RedDevilTridentGateValue = 375f; - public const float RedDevilTridentTelegraphTime = 30f; - - public const float IceElementalFrostBlastGateValue = 180f; - public const float IceElementalFrostBlastGateValue_Death = 120f; - public const float IceElementalFrostBlastTelegraphTime = 30f; - - public const float FungiBulbSporeShootGateValue = 240f; - public const float GiantFungiBulbSporeShootGateValue = 150f; - public const float GiantFungiBulbSporeShootGateValue_Rev = 120f; - public const float FungiBulbSporeTelegraphTime = 30f; - - public const float CorruptorVileSpitGateValue = 180f; - public const float CorruptorVileSpitTelegraphTime = 30f; - - public const float BloodSquidBloodShotGateValue = 120f; - public const float BloodSquidBloodShotTelegraphTime = 30f; - - public const float IceGolemFrostBeamGateValue = 120f; - public const float IceGolemFrostBeamGateValue_Rev = 90f; - public const float IceGolemFrostBeamGateValue_Death = 60f; - public const float IceGolemFrostBeamTelegraphTime = 30f; - - public const float EyezorLaserGateValue = 120f; - public const float EyezorLaserGateValue_Rev = 90f; - public const float EyezorLaserGateValue_Death = 60f; - public const float EyezorLaserTelegraphTime = 30f; - - #endregion - - #region Revengeance and Death Mode non-boss NPC AIs - - #region Fighter AI - - // Methods for AIs that are always terminated via a return in the Fighter AI code. More specialized and general - // functions are given summaries of their specifics - public static void BuffedPsychoAI(NPC npc) - { - int psychoAlphaMax = 200; - // Standing still - if (npc.ai[2] == 0f) - { - npc.alpha = psychoAlphaMax; - npc.TargetClosest(true); - if (!Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() < 170f) - { - npc.ai[2] = -16f; - } - if (npc.velocity.X != 0f || npc.velocity.Y < 0f || npc.velocity.Y > 2f || npc.justHit) - { - npc.ai[2] = -16f; - } - } - // Active - if (npc.ai[2] < 0f) - { - if (npc.alpha > 0) - { - npc.alpha -= psychoAlphaMax / 16; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - npc.ai[2] += 1f; - if (npc.ai[2] == 0f) - { - npc.ai[2] = 1f; - npc.velocity.X = (float)(npc.direction * 2); - } - } - } - public static void BuffedSwampThingAI(NPC npc) - { - if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(240)) - { - npc.ai[2] = (float)Main.rand.Next(-480, -60); - npc.netUpdate = true; - } - if (npc.ai[2] < 0f) - { - npc.TargetClosest(true); - if (npc.justHit) - { - npc.ai[2] = 0f; - } - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[2] = 0f; - } - } - if (npc.ai[2] < 0f) - { - npc.velocity.X *= 0.9f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - { - npc.velocity.X = 0f; - } - npc.ai[2] += 1f; - if (npc.ai[2] == 0f) - { - npc.velocity.X = (float)npc.direction * 0.1f; - } - } - } - // Misc effects used more than once in the Fighter AI - public static void MedusaHeadDustEffect(NPC npc, float time) - { - Vector2 headPosition = npc.Top + new Vector2((float)(npc.spriteDirection * 6), 6f); - float rotationVectorMult = MathHelper.Lerp(20f, 30f, (time * 3f + 50f) / 182f); - Main.rand.NextFloat(); - for (float i = 0f; i < 2f; i += 1f) - { - Vector2 rotationVector = Vector2.UnitY.RotatedByRandom(Math.PI * 2.0) * (Main.rand.NextFloat() * 0.5f + 0.5f); - Dust dust = Dust.NewDustDirect(headPosition, 0, 0, DustID.GoldFlame, 0f, 0f, 0, default, 1f); - dust.position = headPosition + rotationVector * rotationVectorMult; - dust.noGravity = true; - dust.velocity = rotationVector * 2f; - dust.scale = 0.5f + Main.rand.NextFloat() * 0.5f; - } - } - - /// - /// Causes an NPC to run on the X axis until it hits the maximum speed and decclerates as needed. - /// Works best with fighter AI based NPCs. - /// - /// The NPC to manipulate - /// The max speed to run at. - /// The rate at which the X velocity changes with time. - /// The X velocity deceleration multiplier when the NPC will turn to another direction. - /// Causes the NPC to slow down faster when not jumping for direction turning if true. - /// The X velocity deceleration multiplier when the NPC will turn to another direction. - /// The X velocity deceleration multiplier used by . - public static void FighterRunningAI(NPC npc, float velocityMax, float acceleration, float turnDeceleration, - bool extraDeceleration = false, float extraDecelerationFactor = 0.99f) - { - if (npc.velocity.X < -velocityMax || npc.velocity.X > velocityMax) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= turnDeceleration; - } - } - else if (npc.velocity.X < velocityMax && npc.direction == 1) - { - npc.velocity.X += acceleration; - - if (extraDeceleration && npc.velocity.Y == 0f && npc.velocity.X < 0f) - npc.velocity.X *= extraDecelerationFactor; - - if (npc.velocity.X > velocityMax) - { - npc.velocity.X = velocityMax; - } - } - else if (npc.velocity.X > -velocityMax && npc.direction == -1) - { - if (extraDeceleration && npc.velocity.Y == 0f && npc.velocity.X > 0f) - npc.velocity.X *= extraDecelerationFactor; - npc.velocity.X -= acceleration; - if (npc.velocity.X < -velocityMax) - { - npc.velocity.X = -velocityMax; - } - } - } - - public static void TryConvertToWallClimber(NPC npc) - { - // Note: The Possessed rely on an AI shift rather than a transformation NPC - // As a result, they are not included in this method - - List spiders = new List() - { - NPCID.BlackRecluse, - NPCID.BloodCrawler, - NPCID.DesertScorpionWalk, - NPCID.JungleCreeper, - NPCID.WallCreeper, - ModContent.NPCType() - }; - // These checks are not required if the npc is not a real spider - if (!spiders.Contains(npc.type)) - return; - int tileCoordsX = (int)npc.Center.X / 16; - int tileCoordsY = (int)npc.Center.Y / 16; - bool climbWalls = false; - for (int x = tileCoordsX - 1; x <= tileCoordsX + 1; x++) - { - for (int y = tileCoordsY - 1; y <= tileCoordsY + 1; y++) - { - if (Main.tile[x, y].WallType > 0) - { - climbWalls = true; - } - } - } - int transformType = -1; - if (climbWalls) - { - if (npc.type == ModContent.NPCType()) - { - transformType = ModContent.NPCType(); - } - else - { - switch (npc.type) - { - case NPCID.BlackRecluse: - transformType = NPCID.BlackRecluseWall; - break; - case NPCID.BloodCrawler: - transformType = NPCID.BloodCrawlerWall; - break; - case NPCID.DesertScorpionWalk: - transformType = NPCID.DesertScorpionWall; - break; - case NPCID.JungleCreeper: - transformType = NPCID.JungleCreeperWall; - break; - case NPCID.WallCreeper: - transformType = NPCID.WallCreeperWall; - break; - } - } - if (transformType != -1) - { - npc.Transform(transformType); - } - } - } - - public static bool BuffedFighterAI(NPC npc, Mod mod) - { - int npcType = npc.type; - if (npc.ModNPC != null) - { - if (npc.ModNPC.AIType != 0) - npcType = npc.ModNPC.AIType; - } - - if (npcType == NPCID.Psycho) - { - BuffedPsychoAI(npc); - } - - if (npcType == NPCID.SwampThing) - { - BuffedSwampThingAI(npc); - } - - if (npcType == NPCID.CreatureFromTheDeep) - { - // Swimming - if (npc.wet) - { - npc.knockBackResist = 0f; - npc.ai[3] = -0.10101f; - npc.noGravity = true; - npc.width = 34; - npc.height = 24; - npc.position = npc.Center - npc.Size / 2f; - npc.TargetClosest(true); - if (npc.collideX) - { - npc.velocity.X = -npc.oldVelocity.X; - } - if (npc.velocity.X < 0f) - { - npc.direction = -1; - } - if (npc.velocity.X > 0f) - { - npc.direction = 1; - } - - // If there's nothing in the way of the player, swim towards them - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1)) - { - npc.velocity = (npc.velocity * 19f + npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 10f) / 20f; - return false; - } - - float velocityMultiplier = 10f; - if (npc.velocity.Y > 0f) - { - velocityMultiplier = 6f; - } - if (npc.velocity.Y < 0f) - { - velocityMultiplier = 16f; - } - Vector2 directionVectorNormalized = new Vector2((float)npc.direction, -1f); - directionVectorNormalized.Normalize(); - directionVectorNormalized *= velocityMultiplier; - - // If the speed is low, make the turn speed higher - if (velocityMultiplier < 5f) - { - npc.velocity = (npc.velocity * 24f + directionVectorNormalized) / 25f; - return false; - } - npc.velocity = (npc.velocity * 9f + directionVectorNormalized) / 10f; - return false; - } - else - { - npc.knockBackResist = CalamityWorld.death ? 0.1f : 0.2f; - npc.noGravity = false; - npc.width = 18; - npc.height = 40; - npc.position = npc.Center - npc.Size / 2f; - - // If was just swimming, set values to return to land - if (npc.ai[3] == -0.10101f) - { - npc.ai[3] = 0f; - // Adjust velocity from the one the NPC had when swimming - float velocityMagnitude = npc.velocity.Length(); - velocityMagnitude *= 2f; - if (velocityMagnitude > 12f) - { - velocityMagnitude = 12f; - } - npc.velocity.Normalize(); - npc.velocity *= velocityMagnitude; - npc.direction = npc.spriteDirection = (npc.velocity.X > 0).ToDirectionInt(); - } - } - } - - if (npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite) - { - // Pissed off - if (npc.ai[3] < 0f) - { - npc.damage = 0; - npc.velocity.X *= 0.93f; - if (npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - { - npc.velocity.X = 0f; - } - int targetNPC = (int)(-npc.ai[3] - 1f); - int directionToTarget = Math.Sign(Main.npc[targetNPC].Center.X - npc.Center.X); - if (directionToTarget != npc.direction) - { - npc.velocity.X = 0f; - npc.direction = directionToTarget; - npc.netUpdate = true; - } - if (npc.justHit && Main.netMode != NetmodeID.MultiplayerClient && Main.npc[targetNPC].localAI[0] == 0f) - { - Main.npc[targetNPC].localAI[0] = 1f; - } - if (npc.ai[0] < 1000f) - { - npc.ai[0] = 1000f; - } - npc.ai[0] += 1f; - if (npc.ai[0] >= 1300f) - { - npc.ai[0] = 1000f; - npc.netUpdate = true; - } - return false; - } - // Not pissed off - if (npc.ai[0] >= 1000f) - { - npc.ai[0] = 0f; - } - npc.damage = npc.defDamage; - } - - if (npcType == NPCID.MartianOfficer && npc.ai[2] == 0f && npc.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - // If Martian Officer is ready to generate shield, generate it. - int shield = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.ForceBubble, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - npc.ai[2] = (float)(shield + 1); - npc.localAI[0] = -1f; - npc.netUpdate = true; - Main.npc[shield].ai[0] = (float)npc.whoAmI; - Main.npc[shield].netUpdate = true; - } - - if (npcType == NPCID.MartianOfficer) - { - int shield = (int)npc.ai[2] - 1; - if (shield != -1 && Main.npc[shield].active && Main.npc[shield].type == NPCID.ForceBubble) - { - npc.dontTakeDamage = true; - } - else - { - npc.dontTakeDamage = false; - npc.ai[2] = 0f; - if (npc.localAI[0] == -1f) - { - npc.localAI[0] = CalamityWorld.death ? 60f : 120f; - } - if (npc.localAI[0] > 0f) - { - npc.localAI[0] -= 1f; - } - } - } - - if (npcType == NPCID.GraniteGolem) - { - int activeTime = 300; - int defendTime = 120; - - // Set damage - npc.damage = npc.defDamage; - - npc.defense = npc.defDefense; - - if (npc.ai[2] < 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.defense = npc.defDefense + 15; - npc.ai[2] += 1f; - npc.velocity.X *= 0.9f; - if (Math.Abs(npc.velocity.X) < 0.001) - { - npc.velocity.X = 0.001f * (float)npc.direction; - } - if (Math.Abs(npc.velocity.Y) > 1f) - { - npc.ai[2] += 10f; - } - if (npc.ai[2] >= 0f) - { - npc.netUpdate = true; - npc.velocity.X += (float)npc.direction * 0.3f; - } - return false; - } - if (npc.ai[2] < activeTime) - { - if (npc.justHit) - { - npc.ai[2] += 15f; - } - npc.ai[2] += 1f; - } - else if (npc.velocity.Y == 0f) - { - npc.ai[2] = defendTime * -1f; - npc.netUpdate = true; - } - } - - if (npcType == NPCID.Medusa) - { - int afterHitTime = 90; - int afterWaitTime = 210; - int maxTime = 270; - int debuffTime = (CalamityWorld.death ? 4 : 2) * 60; // 2 seconds in Rev, 4 seconds in Death - int turnToStoneTime = 20; - float mesudaActiveDistance = CalamityWorld.death ? 1500f : 900f; - float medusaEffectDistance = CalamityWorld.death ? 1600f : 1000f; - if (npc.ai[2] > 0f) - { - npc.ai[2] -= 1f; - } - else if (npc.ai[2] == 0f) - { - if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && npc.velocity.Y == 0f && npc.Distance(Main.player[npc.target].Center) < mesudaActiveDistance && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[2] = (float)(maxTime * -1f - turnToStoneTime); - npc.netUpdate = true; - } - } - else - { - if (npc.ai[2] < 0f && npc.ai[2] < maxTime * -1f) - { - npc.velocity.X *= 0.9f; - if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit) - { - npc.ai[2] = afterHitTime; - } - else - { - npc.ai[2] += 1f; - if (npc.ai[2] == 0f) - { - npc.ai[2] = afterWaitTime; - } - } - float time = npc.ai[2] + maxTime + turnToStoneTime; - if (time == 1f) - { - SoundEngine.PlaySound(SoundID.NPCDeath17, npc.Center); - } - if (time < turnToStoneTime) - { - MedusaHeadDustEffect(npc, time); - } - Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f); - return false; - } - if (npc.ai[2] < 0f && npc.ai[2] >= maxTime * -1f) - { - Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f); - npc.velocity.X *= 0.9f; - if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit) - { - npc.ai[2] = afterHitTime; - } - else - { - npc.ai[2] += 1f; - if (npc.ai[2] == 0f) - { - npc.ai[2] = afterWaitTime; - } - } - float time = npc.ai[2] + maxTime; - if (time < 180f && (Main.rand.NextBool(3) || npc.ai[2] % 3f == 0f)) - { - MedusaHeadDustEffect(npc, time); - } - if (!Main.dedServ) - { - Player player = Main.LocalPlayer; - if (!player.dead && player.active && player.FindBuffIndex(BuffID.Stoned) == -1) - { - if (npc.Distance(player.Center) < medusaEffectDistance) - { - bool canTurnPlayerToStone = npc.Distance(player.Center) < 30f; - if (!canTurnPlayerToStone) - { - // Used to be "float x = 0.7853982f.ToRotationVector2().X;" - // cos(pi/4) should do the job too, though. If you want/need to revert this to the - // code above, do so. - float x = (float)Math.Cos(MathHelper.PiOver4); - Vector2 vector6 = Vector2.Normalize(player.Center - npc.Center); - if (vector6.X > x || vector6.X < -x) - { - canTurnPlayerToStone = true; - } - } - if (((player.Center.X < npc.Center.X && npc.direction < 0 && player.direction > 0) || (player.Center.X > npc.Center.X && npc.direction > 0 && player.direction < 0)) && canTurnPlayerToStone && (Collision.CanHitLine(npc.Center, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center - Vector2.UnitY * 16f, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center + Vector2.UnitY * 8f, 1, 1, player.Center, 1, 1))) - { - player.AddBuff(BuffID.Stoned, debuffTime + (int)npc.ai[2] * -1, true); - } - } - } - } - return false; - } - } - } - - if (npcType == NPCID.GoblinSummoner) - { - // Shit out minion things - if (npc.ai[3] < 0f) - { - npc.knockBackResist = 0f; - npc.defense = (int)Math.Round(npc.defDefense * 1.3); - npc.noGravity = true; - npc.noTileCollide = true; - npc.direction = (npc.velocity.X > 0).ToDirectionInt(); - npc.rotation = npc.velocity.X * 0.1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[3] += 1f; - if (npc.localAI[3] > (float)Main.rand.Next(20, CalamityWorld.death ? 40 : 120)) - { - npc.localAI[3] = 0f; - Vector2 spawnPosition = npc.Center; - spawnPosition += npc.velocity; - NPC.NewNPC(npc.GetSource_FromAI(), (int)spawnPosition.X, (int)spawnPosition.Y, NPCID.ChaosBall); - } - } - } - else - { - npc.localAI[3] = 0f; - npc.knockBackResist = 0.2f; - npc.rotation *= 0.9f; - npc.defense = npc.defDefense; - npc.noGravity = false; - npc.noTileCollide = false; - } - if (npc.ai[3] == 1f) - { - npc.knockBackResist = 0f; - npc.defense += 10; - } - if (npc.ai[3] == -1f) - { - npc.TargetClosest(true); - float velocityMultiplier = 10f; - float turnValue = 40f; - Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; - float playerDistance = targetDirection.Length(); - velocityMultiplier += playerDistance / 200f; - targetDirection.Normalize(); - targetDirection *= velocityMultiplier; - npc.velocity = (npc.velocity * (turnValue - 1f) + targetDirection) / turnValue; - if (playerDistance < 500f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - // Go back to normal AI - npc.ai[3] = 0f; - npc.ai[2] = 0f; - } - return false; - } - // Go up on the Y axis and slow down on the X axis - if (npc.ai[3] == -2f) - { - npc.velocity.Y -= 0.2f; - if (npc.velocity.Y < -12f) - { - npc.velocity.Y = -12f; - } - if (Main.player[npc.target].Center.Y - npc.Center.Y > 200f) - { - npc.TargetClosest(true); - npc.ai[3] = -3f; - if (Main.player[npc.target].Center.X > npc.Center.X) - { - npc.ai[2] = 1f; - } - else - { - npc.ai[2] = -1f; - } - } - npc.velocity.X *= 0.99f; - return false; - } - // Similar to above, but more quick - if (npc.ai[3] == -3f) - { - if (npc.direction == 0) - { - npc.TargetClosest(true); - } - if (npc.ai[2] == 0f) - { - npc.ai[2] = (float)npc.direction; - } - npc.velocity.Y *= 0.9f; - npc.velocity.X += npc.ai[2] * 0.3f; - if (npc.velocity.X > 10f) - { - npc.velocity.X = 10f; - } - if (npc.velocity.X < -10f) - { - npc.velocity.X = -10f; - } - float playerDistance = Main.player[npc.target].Center.X - npc.Center.X; - if ((npc.ai[2] < 0f && playerDistance > 300f) || (npc.ai[2] > 0f && playerDistance < -300f)) - { - npc.ai[3] = -4f; - npc.ai[2] = 0f; - return false; - } - if (Math.Abs(Main.player[npc.target].Center.X - npc.Center.X) > 800f) - { - npc.ai[3] = -1f; - npc.ai[2] = 0f; - } - return false; - } - else - { - if (npc.ai[3] == -4f) - { - npc.ai[2] += 1f; - npc.velocity.Y += 0.1f; - // Don't go very fast - if (npc.velocity.Length() > 4f) - { - npc.velocity *= 0.9f; - } - int tileAtCenterX = (int)npc.Center.X / 16; - int tileAtBottom = (int)(npc.position.Y + (float)npc.height + 12f) / 16; - bool ableToRestart = false; - for (int i = tileAtCenterX - 1; i <= tileAtCenterX + 1; i++) - { - if (Main.tile[i, tileAtBottom].HasTile && Main.tileSolid[(int)Main.tile[i, tileAtBottom].TileType]) - { - ableToRestart = true; - } - } - if (ableToRestart && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[3] = 0f; - npc.ai[2] = 0f; - } - else if (npc.ai[2] > 300f || npc.Center.Y > Main.player[npc.target].Center.Y + 200f) - { - npc.ai[3] = -1f; - npc.ai[2] = 0f; - } - } - // Barf out the shadowflame skull things - else - { - if (npc.ai[3] == 1f) - { - Vector2 spawnPosiion = npc.Center; - spawnPosiion.Y -= 70f; - npc.velocity.X *= 0.8f; - npc.ai[2] += 1f; - if (npc.ai[2] == (CalamityWorld.death ? 15f : 30f)) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)spawnPosiion.X, (int)spawnPosiion.Y + 18, NPCID.ShadowFlameApparition, 0, 0f, 0f, 0f, 0f, 255); - } - } - else if (npc.ai[2] >= 90f) - { - npc.ai[3] = -2f; - npc.ai[2] = 0f; - } - for (int j = 0; j < 2; j++) - { - // Randomize and normalize. You know the drill - Vector2 dustVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - dustVelocity *= (float)Main.rand.Next(0, 100) * 0.1f; - dustVelocity.Normalize(); - dustVelocity *= (float)Main.rand.Next(50, 90) * 0.1f; - int dustIdx = Dust.NewDust(spawnPosiion, 1, 1, DustID.Shadowflame, 0f, 0f, 0, default, 1f); - Main.dust[dustIdx].velocity = -dustVelocity * 0.3f; - Main.dust[dustIdx].alpha = 100; - if (Main.rand.NextBool()) - { - Main.dust[dustIdx].noGravity = true; - Main.dust[dustIdx].scale += 0.3f; - } - } - return false; - } - npc.ai[2] += 1f; - int maxSkullCount = 10; - if (npc.velocity.Y == 0f && NPC.CountNPCS(NPCID.ShadowFlameApparition) < maxSkullCount) - { - if (npc.ai[2] >= 180f) - { - npc.ai[2] = 0f; - npc.ai[3] = 1f; - } - } - else - { - if (NPC.CountNPCS(NPCID.ShadowFlameApparition) >= maxSkullCount) - { - npc.ai[2] += 1f; - } - if (npc.ai[2] >= 360f) - { - npc.ai[2] = 0f; - npc.ai[3] = -2f; - npc.velocity.Y -= 3f; - } - } - if (npc.target >= 0 && !Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() > 800f) - { - npc.ai[3] = -1f; - npc.ai[2] = 0f; - } - } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(true); - if (Main.player[npc.target].dead && npc.timeLeft > 1) - { - npc.timeLeft = 1; - } - } - } - } - - if (npcType == NPCID.SolarSolenian) - { - npc.reflectsProjectiles = false; - npc.takenDamageMultiplier = 1f; - int chargeTime = 6; - int yFlyTime = 10; - float velocityMultiplier = 20f; - if (npc.ai[2] > 0f) - { - npc.ai[2] -= 1f; - } - if (npc.ai[2] == 0f) - { - if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[2] = -1f; - npc.netUpdate = true; - npc.TargetClosest(true); - } - } - else - { - if (npc.ai[2] < 0f && npc.ai[2] > chargeTime * -1f) - { - npc.ai[2] -= 1f; - npc.velocity.X *= 0.9f; - return false; - } - if (npc.ai[2] == chargeTime * -1f) - { - npc.ai[2] -= 1f; - npc.TargetClosest(true); - Vector2 vectorToPlayer = npc.SafeDirectionTo(Main.player[npc.target].Top - Vector2.UnitY * 30f, Vector2.Normalize(new Vector2(npc.spriteDirection, -1f))); - - npc.velocity = vectorToPlayer * velocityMultiplier; - npc.netUpdate = true; - return false; - } - if (npc.ai[2] < chargeTime * -1f) - { - npc.ai[2] -= 1f; - if (npc.velocity.Y == 0f) - { - npc.ai[2] = CalamityWorld.death ? 60f : 90f; - } - else if (npc.ai[2] < (float)(chargeTime * -1f - yFlyTime)) - { - npc.velocity.Y += 0.15f; - if (npc.velocity.Y > 24f) - { - npc.velocity.Y = 24f; - } - } - npc.reflectsProjectiles = true; - npc.takenDamageMultiplier = CalamityWorld.death ? 2f : 3f; - if (npc.justHit) - { - npc.ai[2] = CalamityWorld.death ? 60f : 90f; - npc.netUpdate = true; - } - return false; - } - } - } - - if (npcType == NPCID.SolarDrakomire) - { - int timeToReset = 42; - int timeToBreathFire = 18; - if (npc.justHit) - { - npc.ai[2] = CalamityWorld.death ? 30f : 60f; - npc.netUpdate = true; - } - if (npc.ai[2] > 0f) - { - npc.ai[2] -= 1f; - } - if (npc.ai[2] == 0f) - { - int solarFlareCount = 0; - int maxFlareCount = 6; - for (int k = 0; k < Main.maxNPCs; k++) - { - if (Main.npc[k].active && Main.npc[k].type == NPCID.SolarFlare) - { - solarFlareCount++; - } - } - if (solarFlareCount > maxFlareCount) - { - npc.ai[2] = CalamityWorld.death ? 30f : 60f; - } - else if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[2] = -1f; - npc.netUpdate = true; - npc.TargetClosest(true); - } - } - else if (npc.ai[2] < 0f && npc.ai[2] > (float)(-(float)timeToReset)) - { - npc.ai[2] -= 1f; - if (npc.ai[2] == (float)(-(float)timeToReset)) - { - npc.ai[2] = (float)(180 + 10 * Main.rand.Next(10)); - } - npc.velocity.X *= 0.8f; - if (npc.ai[2] == (float)(-(float)timeToBreathFire) || npc.ai[2] == (float)(-(float)timeToBreathFire - 8) || npc.ai[2] == (float)(-(float)timeToBreathFire - 16)) - { - for (int l = 0; l < 20; l++) - { - Vector2 spawnPosition = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * 40f; - Dust dust = Main.dust[Dust.NewDust(spawnPosition, 0, 0, DustID.SolarFlare, 0f, 0f, 0, default, 1f)]; - Vector2 velocity = Vector2.UnitY.RotatedByRandom(Math.PI * 2.0); - dust.position = spawnPosition + velocity * 4f; - dust.velocity = velocity * 2f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * 3f; - dust.scale = 0.3f + velocity.X * (float)(-(float)npc.spriteDirection); - dust.fadeIn = 0.7f; - dust.noGravity = true; - } - if (npc.velocity.X > -0.5f && npc.velocity.X < 0.5f) - { - npc.velocity.X = 0f; - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X + npc.spriteDirection * 45, (int)npc.Center.Y + 8, NPCID.SolarFlare, 0, 0f, 0f, 0f, 0f, npc.target); - } - } - return false; - } - } - - if (npcType == NPCID.VortexLarva) - { - if (NPC.CountNPCS(NPCID.VortexHornet) < 6) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= (CalamityWorld.death ? 90f : CalamityWorld.revenge ? 150f : 300f)) - { - int centerTileX = (int)npc.Center.X / 16 - 1; - int centerTileY = (int)npc.Center.Y / 16 - 1; - if (!Collision.SolidTiles(centerTileX, centerTileX + 2, centerTileY, centerTileY + 1) && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Transform(NPCID.VortexHornet); - npc.life = npc.lifeMax; - npc.localAI[0] = 0f; - return false; - } - } - int maxValue; - if (npc.localAI[0] < (CalamityWorld.revenge ? 30f : 60f)) - { - maxValue = 16; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 45f : CalamityWorld.revenge ? 60f : 120f)) - { - maxValue = 8; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 60f : CalamityWorld.revenge ? 90f : 180f)) - { - maxValue = 4; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 75f : CalamityWorld.revenge ? 120f : 240f)) - { - maxValue = 2; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 90f : CalamityWorld.revenge ? 150f : 300f)) - { - maxValue = 1; - } - else - { - maxValue = 1; - } - if (Main.rand.NextBool(maxValue)) - { - Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, DustID.Vortex, 0f, 0f, 0, default, 1f)]; - dust.noGravity = true; - dust.scale = 1f; - dust.noLight = true; - dust.velocity = npc.DirectionFrom(dust.position) * dust.velocity.Length(); - dust.position -= dust.velocity * 5f; - dust.position.X += (float)(npc.direction * 6); - dust.position.Y += 4f; - } - } - } - - if (npcType == NPCID.VortexHornet) - { - if (NPC.CountNPCS(NPCID.VortexHornetQueen) < 3) - { - npc.localAI[0] += 1f; - npc.localAI[0] += Math.Abs(npc.velocity.X) / 2f; - if (npc.localAI[0] >= (CalamityWorld.death ? 300f : CalamityWorld.revenge ? 600f : 1200f) && Main.netMode != NetmodeID.MultiplayerClient) - { - int centerTileX = (int)npc.Center.X / 16 - 2; - int centerTileY = (int)npc.Center.Y / 16 - 3; - if (!Collision.SolidTiles(centerTileX, centerTileX + 4, centerTileY, centerTileY + 4)) - { - npc.Transform(NPCID.VortexHornetQueen); - npc.life = npc.lifeMax; - npc.localAI[0] = 0f; - return false; - } - } - int maxValue2; - if (npc.localAI[0] < (CalamityWorld.death ? 60f : CalamityWorld.revenge ? 120f : 240f)) - { - maxValue2 = 32; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 120f : CalamityWorld.revenge ? 240f : 480f)) - { - maxValue2 = 16; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 180f : CalamityWorld.revenge ? 360f : 720f)) - { - maxValue2 = 6; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 240f : CalamityWorld.revenge ? 480f : 960f)) - { - maxValue2 = 2; - } - else if (npc.localAI[0] < (CalamityWorld.death ? 300f : CalamityWorld.revenge ? 600f : 1200f)) - { - maxValue2 = 1; - } - else - { - maxValue2 = 1; - } - if (Main.rand.NextBool(maxValue2)) - { - Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, DustID.Vortex, 0f, 0f, 0, default, 1f)]; - dust.noGravity = true; - dust.scale = 1f; - dust.noLight = true; - } - } - } - - bool jump = false; - if (npc.velocity.X == 0f) - { - jump = true; - } - if (npc.justHit) - { - jump = false; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npcType == NPCID.Lihzahrd && (double)npc.life <= (double)npc.lifeMax * 0.9) - { - npc.Transform(NPCID.LihzahrdCrawler); - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npcType == NPCID.Nutcracker && (double)npc.life <= (double)npc.lifeMax * 0.9) - { - npc.Transform(NPCID.NutcrackerSpinning); - } - - // This variable seems to have a lot of purposes. - // I wasn't sure what I could name it that isn't very vague - int aiGateValue = 60; - if (npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType()) - { - aiGateValue = 180; - if (npc.ai[3] == -30f) - { - npc.velocity *= 0f; - npc.ai[3] = 0f; - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - float distX = npc.oldPos[2].X + (float)npc.width * 0.5f - npc.Center.X; - float distY = npc.oldPos[2].Y + (float)npc.height * 0.5f - npc.Center.Y; - float distance = (float)Math.Sqrt((distX * distX + distY * distY)); - distance = 2f / distance; - distX *= distance; - distY *= distance; - for (int m = 0; m < 20; m++) - { - int dustIdx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.UndergroundHallowedEnemies, distX, distY, 200, default, 2f); - Main.dust[dustIdx].noGravity = true; - Dust dust = Main.dust[dustIdx]; - dust.velocity.X *= 2f; - } - for (int n = 0; n < 20; n++) - { - int dustIdx = Dust.NewDust(npc.oldPos[2], npc.width, npc.height, DustID.UndergroundHallowedEnemies, -distX, -distY, 200, default, 2f); - Main.dust[dustIdx].noGravity = true; - Dust dust = Main.dust[dustIdx]; - dust.velocity.X *= 2f; - } - } - } - - bool canIncrementAI3 = false; - bool reset = true; - if (npcType == NPCID.Yeti || npcType == NPCID.CorruptBunny || npcType == NPCID.Crab || npcType == NPCID.Clown || npcType == NPCID.SkeletonArcher || npcType == NPCID.GoblinArcher || npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType() - || npcType == NPCID.BlackRecluse || npcType == NPCID.WallCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.CorruptPenguin || npcType == NPCID.LihzahrdCrawler || npcType == NPCID.IcyMerman || npcType == NPCID.PirateDeadeye - || npcType == NPCID.PirateCrossbower || npcType == NPCID.PirateCaptain || npcType == NPCID.CochinealBeetle || npcType == NPCID.CyanBeetle || npcType == NPCID.LacBeetle || npcType == NPCID.SeaSnail || npcType == NPCID.FlyingSnake - || npcType == NPCID.IceGolem || npcType == NPCID.Eyezor || npcType == NPCID.AnomuraFungus || npcType == NPCID.MushiLadybug || npcType == NPCID.Paladin || npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton - || npcType == NPCID.SkeletonCommando || npcType == NPCID.Scarecrow1 || npcType == NPCID.Scarecrow2 || npcType == NPCID.Scarecrow3 || npcType == NPCID.Scarecrow4 || npcType == NPCID.Scarecrow5 || npcType == NPCID.Nutcracker - || npcType == NPCID.NutcrackerSpinning || npcType == NPCID.ElfArcher || npcType == NPCID.Krampus || npcType == NPCID.CultistArcherBlue || (npcType >= 430 && npcType <= 436) - || (npcType == NPCID.CultistArcherWhite || npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianOfficer || npcType == NPCID.MartianEngineer || npcType == NPCID.Scutlix - || (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4)) || (npcType == NPCID.Psycho || npcType == NPCID.CrimsonBunny || npcType == NPCID.SwampThing || npcType == NPCID.ThePossessed || npcType == NPCID.DrManFly - || npcType == NPCID.GoblinSummoner || npcType == NPCID.CrimsonPenguin || npcType == NPCID.Medusa || npcType == NPCID.GreekSkeleton || npcType == NPCID.GraniteGolem || npcType == NPCID.StardustSoldier || npcType == NPCID.NebulaSoldier - || npcType == NPCID.StardustSpiderBig || (npcType >= 494 && npcType <= 506)) || (npcType == NPCID.VortexRifleman || npcType == NPCID.VortexHornet || npcType == NPCID.VortexHornetQueen || npcType == NPCID.VortexLarva - || npcType == NPCID.WalkingAntlion || npcType == NPCID.SolarDrakomire || npcType == NPCID.SolarSolenian || npcType == NPCID.MartianWalker || (npcType >= 524 && npcType <= 527)) || npcType == NPCID.DesertLamiaLight - || npcType == NPCID.DesertLamiaDark || npcType == NPCID.DesertScorpionWalk || npcType == NPCID.DesertBeast) - { - reset = false; - } - - bool ableToAlterAI3 = false; - if (npcType == NPCID.VortexRifleman || npcType == NPCID.GoblinSummoner) - { - ableToAlterAI3 = true; - } - - bool npcTimer = npc.ai[2] <= 0f; - if (npcType <= NPCID.RayGunner) - { - if (npcType <= NPCID.PirateCaptain) - { - if (npcType - 110 > 1 && npcType != NPCID.IcyMerman && npcType - NPCID.PirateDeadeye > 2) - { - goto PrepareToShoot; - } - } - else if (npcType - NPCID.SkeletonSniper > 2 && npcType != NPCID.ElfArcher && npcType - NPCID.CultistArcherBlue > 3) - { - goto PrepareToShoot; - } - } - else if (npcType <= NPCID.NebulaSoldier) - { - if (npcType != NPCID.StardustSpiderSmall && npcType != NPCID.StardustSoldier && npcType != NPCID.NebulaSoldier) - { - goto PrepareToShoot; - } - } - else if (npcType <= NPCID.Psycho) - { - if (npcType != NPCID.VortexHornetQueen && npcType != NPCID.Psycho) - { - goto PrepareToShoot; - } - } - else if (npcType - 498 > 8 && npcType != NPCID.MartianWalker) - { - goto PrepareToShoot; - } - -// If anyone can give me an explanation of the real noticable differences between -//& and && (same with | and ||) with booleans, -// I'd greatly appreciate it -PrepareToShoot: - if (!ableToAlterAI3 & npcTimer) - { - if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) - { - canIncrementAI3 = true; - } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)aiGateValue) | canIncrementAI3) - { - npc.ai[3] += 1f; - } - else if (Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f) - { - npc.ai[3] -= 1f; - } - if (npc.ai[3] > (float)(aiGateValue * 10)) - { - npc.ai[3] = 0f; - } - if (npc.justHit) - { - npc.ai[3] = 0f; - } - if (npc.ai[3] == (float)aiGateValue) - { - npc.netUpdate = true; - } - } - - if (npcType == NPCID.Nailhead && Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.localAI[3] > 0f) - npc.localAI[3] -= 1f; - - if (npc.justHit && npc.localAI[3] <= 0f) - { - npc.localAI[3] = CalamityWorld.death ? 45f : CalamityWorld.revenge ? 60f : 75f; - - float nailVelocity = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; - int type = ProjectileID.Nail; - int damage = (int)(npc.damage * 0.15); - Vector2 destination = new Vector2(npc.Center.X, npc.Center.Y - 100f) - npc.Center; - destination = destination.SafeNormalize(-Vector2.UnitY); - destination *= nailVelocity; - int numProj = Main.rand.Next(3, 6); - float rotation = MathHelper.ToRadians(numProj * 15); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center - Vector2.UnitY * (npc.width / 4), perturbedSpeed, type, damage, 1f, Main.maxPlayers); - } - } - } - - if (npcType == NPCID.Butcher) - { - if (npc.velocity.Y < -0.3f || npc.velocity.Y > 0.3f) - { - npc.knockBackResist = 0f; - } - else - { - npc.knockBackResist = 0.1f; - } - } - - if (npcType == NPCID.ThePossessed) - { - npc.knockBackResist = 0.25f; - if (npc.ai[2] == 1f) - { - npc.knockBackResist = 0f; - } - bool spiderAI = false; - int centerTileX = (int)npc.Center.X / 16; - int centerTileY = (int)npc.Center.Y / 16; - for (int x = centerTileX - 1; x <= centerTileX + 1; x++) - { - for (int y = centerTileY - 1; y <= centerTileY + 1; y++) - { - if (Main.tile[x, y] != null && Main.tile[x, y].WallType > 0) - { - spiderAI = true; - break; - } - } - if (spiderAI) - { - break; - } - } - if (npc.ai[2] == 0f & spiderAI) - { - if (npc.velocity.Y == 0f) - { - npc.velocity.Y = -4.6f; - npc.velocity.X *= 1.5f; - } - else if (npc.velocity.Y > 0f) - { - npc.ai[2] = 1f; - } - } - if (spiderAI && npc.ai[2] == 1f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - Vector2 distanceVector = Main.player[npc.target].Center - npc.Center; - float distanceMagnitude = distanceVector.Length(); - distanceVector = distanceVector.SafeNormalize(-Vector2.UnitY); - distanceVector *= 6f + distanceMagnitude / 300f; - npc.velocity = (npc.velocity * 29f + distanceVector) / 30f; - npc.noGravity = true; - npc.ai[2] = 1f; - return false; - } - npc.noGravity = false; - npc.ai[2] = 0f; - } - - if (npcType == NPCID.Fritz && npc.velocity.Y == 0f && (Main.player[npc.target].Center - npc.Center).Length() < 150f && Math.Abs(npc.velocity.X) > 3f && ((npc.velocity.X < 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X > 0f && npc.Center.X < Main.player[npc.target].Center.X))) - { - npc.velocity.X *= 2f; - npc.velocity.Y -= 4.5f; - if (npc.Center.Y - Main.player[npc.target].Center.Y > 20f) - { - npc.velocity.Y -= 0.5f; - } - if (npc.Center.Y - Main.player[npc.target].Center.Y > 40f) - { - npc.velocity.Y -= 1f; - } - if (npc.Center.Y - Main.player[npc.target].Center.Y > 80f) - { - npc.velocity.Y -= 1.5f; - } - if (npc.Center.Y - Main.player[npc.target].Center.Y > 100f) - { - npc.velocity.Y -= 1.5f; - } - if (Math.Abs(npc.velocity.X) > 9f) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = -9f; - } - else - { - npc.velocity.X = 9f; - } - } - } - - if (npc.ai[3] < (float)aiGateValue && (Main.eclipse || !Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0 || (Main.invasionType == InvasionID.GoblinArmy && (npcType == NPCID.Yeti || npcType == NPCID.ElfArcher)) || (Main.invasionType == InvasionID.GoblinArmy && (npcType == NPCID.GoblinPeon || npcType == NPCID.GoblinThief || npcType == NPCID.GoblinWarrior || npcType == NPCID.GoblinArcher || npcType == NPCID.GoblinSummoner)) || (npcType == NPCID.GoblinScout || (Main.invasionType == InvasionID.PirateInvasion && npcType >= 212 && npcType <= 216)) || (Main.invasionType == InvasionID.MartianMadness && (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianOfficer || npcType == NPCID.GrayGrunt || npcType == NPCID.MartianEngineer || npcType == NPCID.GigaZapper || npcType == NPCID.Scutlix || npcType == NPCID.MartianWalker)) || (npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.CorruptBunny || npcType == NPCID.Crab || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.Mummy || npcType == NPCID.DarkMummy || npcType == NPCID.LightMummy || npcType == NPCID.SkeletonArcher || npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType() || npcType == NPCID.CorruptPenguin || npcType == NPCID.FaceMonster || npcType == NPCID.SnowFlinx || npcType == NPCID.Lihzahrd || npcType == NPCID.LihzahrdCrawler || npcType == NPCID.IcyMerman || npcType == NPCID.CochinealBeetle || npcType == NPCID.CyanBeetle || npcType == NPCID.LacBeetle || npcType == NPCID.SeaSnail || npcType == NPCID.BloodCrawler || npcType == NPCID.IceGolem || npcType == NPCID.ZombieMushroom || npcType == NPCID.ZombieMushroomHat || npcType == NPCID.AnomuraFungus || npcType == NPCID.MushiLadybug || npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton || npcType == NPCID.SkeletonCommando || npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite || npcType == NPCID.CrimsonBunny || npcType == NPCID.CrimsonPenguin || npcType == NPCID.NebulaSoldier || (npcType == NPCID.StardustSoldier && (npc.ai[1] >= 180f || npc.ai[1] < 90f))) || (npcType == NPCID.StardustSpiderBig || npcType == NPCID.VortexRifleman || npcType == NPCID.VortexSoldier || npcType == NPCID.VortexHornet || npcType == NPCID.VortexLarva || npcType == NPCID.WalkingAntlion || npcType == NPCID.SolarDrakomire || npcType == NPCID.SolarSolenian || (npcType >= 524 && npcType <= 527)) || npcType == NPCID.DesertLamiaLight || npcType == NPCID.DesertLamiaDark || npcType == NPCID.DesertScorpionWalk || npcType == NPCID.DesertBeast)) - { - if ((npcType == NPCID.Zombie || npcType == NPCID.ZombieXmas || npcType == NPCID.ZombieSweater || npcType == NPCID.Skeleton || (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) || npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.SkeletonArcher || npcType == NPCID.BaldZombie || npcType == NPCID.UndeadViking || npcType == NPCID.ZombieEskimo || npcType == NPCID.Frankenstein || npcType == NPCID.PincushionZombie || npcType == NPCID.SlimedZombie || npcType == NPCID.SwampZombie || npcType == NPCID.TwiggyZombie || npcType == NPCID.ArmoredViking || npcType == NPCID.FemaleZombie || npcType == NPCID.HeadacheSkeleton || npcType == NPCID.MisassembledSkeleton || npcType == NPCID.PantlessSkeleton || npcType == NPCID.ZombieRaincoat || npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton || npcType == NPCID.SkeletonCommando || npcType == NPCID.ZombieSuperman || npcType == NPCID.ZombiePixie || npcType == NPCID.ZombieDoctor || npcType == NPCID.GreekSkeleton || npcType == ModContent.NPCType()) && Main.rand.NextBool(1000)) - { - SoundEngine.PlaySound(SoundID.ZombieMoan, npc.Center); - } - if (npcType == NPCID.BloodZombie && Main.rand.NextBool(800)) - { - SoundEngine.PlaySound(SoundID.ZombieMoan, npc.Center); //There was a npcType thing afterwards but its not really useable now. Hilarious, frankly - } - if ((npcType == NPCID.Mummy || npcType == NPCID.DarkMummy || npcType == NPCID.LightMummy) && Main.rand.NextBool(500)) - { - SoundEngine.PlaySound(SoundID.Mummy, npc.Center); - } - if (npcType == NPCID.Vampire && Main.rand.NextBool(500)) - { - SoundEngine.PlaySound(SoundID.Zombie7, npc.Center); - } - if (npcType == NPCID.Frankenstein && Main.rand.NextBool(500)) - { - SoundEngine.PlaySound(SoundID.Zombie6, npc.Center); - } - if (npcType == NPCID.FaceMonster && Main.rand.NextBool(500)) - { - SoundEngine.PlaySound(SoundID.Zombie8, npc.Center); - } - if (npcType >= 269 && npcType <= 280 && Main.rand.NextBool(1000)) - { - SoundEngine.PlaySound(SoundID.ZombieMoan, npc.Center); - } - npc.TargetClosest(true); - } - else if (npc.ai[2] <= 0f || - (npcType != NPCID.SkeletonArcher && - npcType != NPCID.GoblinArcher && - npcType != NPCID.IcyMerman && - npcType != NPCID.PirateDeadeye && - npcType != NPCID.PirateCrossbower && - npcType != NPCID.PirateCaptain && - npcType != NPCID.SkeletonSniper && - npcType != NPCID.TacticalSkeleton && - npcType != NPCID.SkeletonCommando && - npcType != NPCID.ElfArcher && - npcType != NPCID.BrainScrambler && - npcType != NPCID.RayGunner && - npcType != NPCID.MartianOfficer && - npcType != NPCID.GrayGrunt && - npcType != NPCID.MartianEngineer && - npcType != NPCID.GigaZapper && - npcType != NPCID.Scutlix && - npcType != NPCID.ThePossessed && - npcType != NPCID.SwampThing && - npcType != NPCID.Psycho && - npcType != NPCID.GoblinSummoner && - npcType != NPCID.StardustSoldier && - npcType != NPCID.StardustSpiderSmall && - npcType != NPCID.NebulaSoldier && - npcType != NPCID.VortexRifleman && - npcType != NPCID.VortexHornetQueen && - npcType != NPCID.SolarDrakomire && - npcType != NPCID.SolarSolenian && - npcType != NPCID.MartianWalker)) - { - if (Main.dayTime && (double)(npc.position.Y / 16f) < Main.worldSurface && npc.timeLeft > 10) - { - npc.timeLeft = 10; - } - if (npc.velocity.X == 0f) - { - if (npc.velocity.Y == 0f) - { - npc.ai[0] += 1f; - if (npc.ai[0] >= 2f) - { - npc.direction *= -1; - - npc.spriteDirection = npc.direction; - - npc.ai[0] = 0f; - } - } - } - else - { - npc.ai[0] = 0f; - } - if (npc.direction == 0) - { - npc.direction = 1; - } - } - - if (npcType == NPCID.Vampire || npcType == NPCID.NutcrackerSpinning) - { - if (npcType == NPCID.Vampire && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) - { - npc.velocity.X *= 0.95f; - } - if (npc.velocity.X < -8f || npc.velocity.X > 8f) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < 8f && npc.direction == 1) - { - if (npc.velocity.Y == 0f && npc.velocity.X < 0f) - { - npc.velocity.X *= 0.99f; - } - npc.velocity.X += 0.09f; - if (npc.velocity.X > 8f) - { - npc.velocity.X = 8f; - } - } - else if (npc.velocity.X > -8f && npc.direction == -1) - { - if (npc.velocity.Y == 0f && npc.velocity.X > 0f) - { - npc.velocity.X *= 0.99f; - } - npc.velocity.X -= 0.09f; - if (npc.velocity.X < -8f) - { - npc.velocity.X = -8f; - } - } - } - else if (npcType == NPCID.LihzahrdCrawler) - { - FighterRunningAI(npc, CalamityWorld.death ? 8f : 6f, 0.12f, 0.8f, true, 0.8f); - } - else if (npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType() || npcType == NPCID.SwampThing || npcType == NPCID.PirateCorsair || npcType == NPCID.MushiLadybug || npcType == NPCID.DesertLamiaLight || npcType == NPCID.DesertLamiaDark) - { - FighterRunningAI(npc, CalamityWorld.death ? 6f : 4f, 0.09f, 0.8f, true, 0.8f); - } - else if (npcType == NPCID.CreatureFromTheDeep || npcType == NPCID.GoblinThief || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.Werewolf || npcType == NPCID.BlackRecluse || npcType == NPCID.Frankenstein || npcType == NPCID.Nymph || npcType == NPCID.ArmoredViking || npcType == NPCID.PirateDeckhand || npcType == NPCID.AnomuraFungus || npcType == NPCID.Splinterling || npcType == NPCID.Yeti || npcType == NPCID.Nutcracker || npcType == NPCID.Krampus || (npcType >= 524 && npcType <= 527) || npcType == NPCID.DesertScorpionWalk) - { - FighterRunningAI(npc, CalamityWorld.death ? 3f : 2.5f, 0.09f, 0.8f); - } - else if (npcType == NPCID.Clown) - { - FighterRunningAI(npc, CalamityWorld.death ? 5f : 4f, 0.06f, 0.8f); - } - else if (npcType == NPCID.Skeleton || npcType == NPCID.SporeSkeleton || npcType == NPCID.GoblinPeon || npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.CorruptBunny || npcType == NPCID.GoblinScout || npcType == NPCID.PossessedArmor || npcType == NPCID.WallCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.UndeadViking || npcType == NPCID.CorruptPenguin || npcType == NPCID.SnowFlinx || npcType == NPCID.Lihzahrd || npcType == NPCID.HeadacheSkeleton || npcType == NPCID.MisassembledSkeleton || npcType == NPCID.PantlessSkeleton || npcType == NPCID.CochinealBeetle || npcType == NPCID.CyanBeetle || npcType == NPCID.LacBeetle || npcType == NPCID.FlyingSnake || npcType == NPCID.FaceMonster || npcType == NPCID.ZombieMushroom || npcType == NPCID.ZombieElf || npcType == NPCID.ZombieElfBeard || npcType == NPCID.ZombieElfGirl || npcType == NPCID.GingerbreadMan || npcType == NPCID.GrayGrunt || npcType == NPCID.GigaZapper || npcType == NPCID.Fritz || npcType == NPCID.Nailhead || npcType == NPCID.Psycho || npcType == NPCID.CrimsonBunny || npcType == NPCID.ThePossessed || npcType == NPCID.CrimsonPenguin || npcType == NPCID.Medusa || npcType == NPCID.GraniteGolem || npcType == NPCID.VortexRifleman || npcType == NPCID.VortexSoldier) - { - float maxVelocity = 1.5f; - if (npcType == NPCID.AngryBonesBig) - { - maxVelocity = 2f; - } - else if (npcType == NPCID.AngryBonesBigMuscle) - { - maxVelocity = 1.75f; - } - else if (npcType == NPCID.AngryBonesBigHelmet) - { - maxVelocity = 1.25f; - } - else if (npcType == NPCID.HeadacheSkeleton) - { - maxVelocity = 1.1f; - } - else if (npcType == NPCID.MisassembledSkeleton) - { - maxVelocity = 0.9f; - } - else if (npcType == NPCID.PantlessSkeleton) - { - maxVelocity = 1.2f; - } - else if (npcType == NPCID.ZombieElf) - { - maxVelocity = 1.75f; - } - else if (npcType == NPCID.ZombieElfBeard) - { - maxVelocity = 1.25f; - } - else if (npcType == NPCID.ZombieElfGirl) - { - maxVelocity = 2f; - } - else if (npcType == NPCID.GrayGrunt) - { - maxVelocity = 1.8f; - } - else if (npcType == NPCID.GigaZapper) - { - maxVelocity = 2.25f; - } - else if (npcType == NPCID.Fritz) - { - maxVelocity = 4f; - } - else if (npcType == NPCID.Nailhead) - { - maxVelocity = CalamityWorld.revenge ? 0.75f : 0.6f; - } - else if (npcType == NPCID.Psycho) - { - maxVelocity = 3.75f; - } - else if (npcType == NPCID.ThePossessed) - { - maxVelocity = 3.25f; - } - else if (npcType == NPCID.Medusa) - { - maxVelocity = 1.5f + (1f - (float)npc.life / (float)npc.lifeMax) * 2f; - } - else if (npcType == NPCID.VortexRifleman) - { - maxVelocity = CalamityWorld.revenge ? 6f : 4.8f; - } - else if (npcType == NPCID.VortexSoldier) - { - maxVelocity = 4f; - } - if (npcType == NPCID.Skeleton || npcType == NPCID.HeadacheSkeleton || npcType == NPCID.MisassembledSkeleton || npcType == NPCID.PantlessSkeleton || npcType == NPCID.GingerbreadMan) - { - maxVelocity *= 1f + (1f - npc.scale); - } - maxVelocity *= 1.25f; - if (CalamityWorld.death) - maxVelocity *= 1.25f; - - bool extraSlowdown = npc.velocity.Y == 0f && npcType == NPCID.Fritz && ((npc.direction > 0 && npc.velocity.X < 0f) || (npc.direction < 0 && npc.velocity.X > 0f)); - FighterRunningAI(npc, maxVelocity, 0.09f, 0.9f, extraSlowdown, 0.9f); - } - else if (npcType >= NPCID.RustyArmoredBonesAxe && npcType <= NPCID.HellArmoredBonesSword) - { - float maxVelocity = 1.5f; - if (npcType == NPCID.RustyArmoredBonesAxe) - { - maxVelocity = 2f; - } - if (npcType == NPCID.RustyArmoredBonesFlail) - { - maxVelocity = 1f; - } - if (npcType == NPCID.RustyArmoredBonesSword) - { - maxVelocity = 1.5f; - } - if (npcType == NPCID.RustyArmoredBonesSwordNoArmor) - { - maxVelocity = 3f; - } - if (npcType == NPCID.BlueArmoredBones) - { - maxVelocity = 1.25f; - } - if (npcType == NPCID.BlueArmoredBonesMace) - { - maxVelocity = 3f; - } - if (npcType == NPCID.BlueArmoredBonesNoPants) - { - maxVelocity = 3.25f; - } - if (npcType == NPCID.BlueArmoredBonesSword) - { - maxVelocity = 2f; - } - if (npcType == NPCID.HellArmoredBones) - { - maxVelocity = 2.75f; - } - if (npcType == NPCID.HellArmoredBonesSpikeShield) - { - maxVelocity = 1.8f; - } - if (npcType == NPCID.HellArmoredBonesMace) - { - maxVelocity = 1.3f; - } - if (npcType == NPCID.HellArmoredBonesSword) - { - maxVelocity = 2.5f; - } - maxVelocity *= 1f + (1f - npc.scale); - maxVelocity *= 1.25f; - if (CalamityWorld.death) - maxVelocity *= 1.25f; - - FighterRunningAI(npc, maxVelocity, 0.09f, 0.8f, false); - } - else if (npcType >= 305 && npcType <= 314) - { - float maxVelocity = 1.5f; - if (npcType == NPCID.Scarecrow1 || npcType == NPCID.Scarecrow6) - { - maxVelocity = 2f; - } - if (npcType == NPCID.Scarecrow2 || npcType == NPCID.Scarecrow7) - { - maxVelocity = 1.25f; - } - if (npcType == NPCID.Scarecrow3 || npcType == NPCID.Scarecrow8) - { - maxVelocity = 2.25f; - } - if (npcType == NPCID.Scarecrow4 || npcType == NPCID.Scarecrow9) - { - maxVelocity = 1.5f; - } - if (npcType == NPCID.Scarecrow5 || npcType == NPCID.Scarecrow10) - { - maxVelocity = 1f; - } - maxVelocity *= 1.25f; - if (CalamityWorld.death) - maxVelocity *= 1.25f; - - if (npcType < 310) //Pogo stick Scarecrows - { - if (npc.velocity.Y == 0f) - { - npc.velocity.X *= 0.85f; - if (npc.velocity.X > -0.3f && npc.velocity.X < 0.3f) - { - npc.velocity.Y = -9f; //-7f normally - npc.velocity.X = maxVelocity * (float)npc.direction; - } - } - else if (npc.spriteDirection == npc.direction) - { - npc.velocity.X = (npc.velocity.X * 10f + maxVelocity * npc.direction) / 11f; - } - } - else - { - FighterRunningAI(npc, maxVelocity, 0.09f, 0.8f, false); - } - } - else if (npcType == NPCID.Crab || npcType == NPCID.SeaSnail || npcType == NPCID.VortexLarva) - { - FighterRunningAI(npc, CalamityWorld.death ? 4f : CalamityWorld.revenge ? 1f : 0.5f, CalamityWorld.revenge ? 0.06f : 0.05f, 0.7f); - } - else if (npcType == NPCID.Mummy || npcType == NPCID.DarkMummy || npcType == NPCID.LightMummy) - { - float maxVelocity = 3f; - float acceleration = 0.15f; - if (npcType == NPCID.DarkMummy) - { - maxVelocity *= 1.5f; - } - if (CalamityWorld.death) - { - maxVelocity *= 1.25f; - } - FighterRunningAI(npc, maxVelocity, acceleration, 0.7f); - } - else if (npcType == NPCID.BoneLee) - { - FighterRunningAI(npc, CalamityWorld.death ? 7f : CalamityWorld.revenge ? 6f : 5f, CalamityWorld.revenge ? 0.3f : 0.2f, 0.7f); - } - else if (npcType == NPCID.IceGolem) - { - FighterRunningAI(npc, CalamityWorld.death ? 4.5f : CalamityWorld.revenge ? 3f : 2f, CalamityWorld.revenge ? 0.3f : 0.2f, 0.7f); - } - else if (npcType == NPCID.Eyezor) - { - FighterRunningAI(npc, CalamityWorld.death ? 5f : CalamityWorld.revenge ? 3.5f : 2.5f, CalamityWorld.revenge ? 0.3f : 0.2f, 0.8f); - } - else if (npcType == NPCID.MartianEngineer) - { - if (npc.ai[2] > 0f) - { - if (npc.velocity.Y == 0f) - npc.velocity.X *= 0.8f; - } - else - FighterRunningAI(npc, CalamityWorld.death ? 5f : 3.5f, 0.2f, 0.8f); - } - else if (npcType == NPCID.Butcher) - { - float acceleration = 0.2f; - if (Math.Abs(npc.velocity.X) > 2f) - { - acceleration *= 0.8f; - } - if (Math.Abs(npc.velocity.X) > 2.5) - { - acceleration *= 0.8f; - } - if (Math.Abs(npc.velocity.X) > 3f) - { - acceleration *= 0.8f; - } - if (Math.Abs(npc.velocity.X) > 3.5) - { - acceleration *= 0.8f; - } - if (Math.Abs(npc.velocity.X) > 4f) - { - acceleration *= 0.8f; - } - if (Math.Abs(npc.velocity.X) > 4.5f) - { - acceleration *= 0.8f; - } - if (Math.Abs(npc.velocity.X) > 5f) - { - acceleration *= 0.8f; - } - if (Math.Abs(npc.velocity.X) > 5.5) - { - acceleration *= 0.8f; - } - FighterRunningAI(npc, CalamityWorld.death ? 10f : 7f, acceleration, 0.8f); - } - else if (npcType == NPCID.GiantWalkingAntlion || npcType == NPCID.WalkingAntlion || npcType == NPCID.LarvaeAntlion) - { - float xAdditive = CalamityWorld.death ? 3.5f : 3f; - float turnValue = 90f; - float absoluteVelocityX = Math.Abs(npc.velocity.X); - if (absoluteVelocityX > 2.75f) - { - xAdditive = CalamityWorld.death ? 7f : 6f; - turnValue += 100f; - } - else if (absoluteVelocityX > 2.25) - { - xAdditive = CalamityWorld.death ? 5f : 4.25f; - turnValue += 80f; - } - if (Math.Abs(npc.velocity.Y) < 0.5) - { - if (npc.velocity.X > 0f && npc.direction < 0) - { - npc.velocity *= 0.9f; - } - if (npc.velocity.X < 0f && npc.direction > 0) - { - npc.velocity *= 0.9f; - } - } - if (Math.Abs(npc.velocity.Y) > 0.3f) - { - turnValue *= 3f; - } - if (npc.velocity.X <= 0f && npc.direction < 0) - { - npc.velocity.X = (npc.velocity.X * turnValue - xAdditive) / (turnValue + 1f); - } - else if (npc.velocity.X >= 0f && npc.direction > 0) - { - npc.velocity.X = (npc.velocity.X * turnValue + xAdditive) / (turnValue + 1f); - } - else if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 20f && Math.Abs(npc.velocity.Y) <= 0.3f) - { - npc.velocity.X *= 0.99f; - npc.velocity.X += npc.direction * 0.025f; - } - } - else if (npcType == NPCID.Scutlix || npcType == NPCID.VortexHornet || npcType == NPCID.SolarDrakomire || npcType == NPCID.SolarSolenian || npcType == NPCID.SolarSpearman || npcType == NPCID.DesertBeast) - { - float maxVelocity = 5f; - float acceleration = 0.25f; - float turnMultiplier = 0.7f; - if (npcType == NPCID.VortexHornet) - { - maxVelocity = 6f; - acceleration = 0.2f; - turnMultiplier = 0.8f; - } - else if (npcType == NPCID.SolarDrakomire) - { - maxVelocity = 4f; - acceleration = 0.1f; - turnMultiplier = 0.95f; - } - else if (npcType == NPCID.SolarSolenian) - { - maxVelocity = 6f; - acceleration = 0.15f; - turnMultiplier = 0.85f; - } - else if (npcType == NPCID.SolarSpearman) - { - maxVelocity = 5f; - acceleration = 0.1f; - turnMultiplier = 0.95f; - } - else if (npcType == NPCID.DesertBeast) - { - maxVelocity = 5f; - acceleration = 0.15f; - turnMultiplier = 0.98f; - } - if (CalamityWorld.revenge) - { - maxVelocity *= 1.25f; - acceleration *= 1.25f; - } - if (CalamityWorld.death) - { - maxVelocity *= 1.25f; - acceleration *= 1.25f; - } - FighterRunningAI(npc, maxVelocity, acceleration, turnMultiplier); - } - else if ((npcType >= NPCID.ArmedZombie && npcType <= NPCID.ArmedZombieCenx) || npcType == NPCID.Crawdad || npcType == NPCID.Crawdad2) - { - if (npc.ai[2] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - float maxVelocity = CalamityWorld.death ? 2.5f : 1.5f; - maxVelocity *= 1f + (1f - npc.scale); - FighterRunningAI(npc, maxVelocity, 0.09f, 0.8f, true, 0.8f); - if (npc.velocity.Y == 0f && (!Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0) && !Main.player[npc.target].dead) - { - Vector2 playerDistance = npc.Center - Main.player[npc.target].Center; - int slowdownDistance = 50; - if (npcType >= NPCID.Crawdad && npcType <= NPCID.Crawdad2) - { - slowdownDistance = 42; - } - if (playerDistance.Length() < slowdownDistance && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.velocity.X *= 0.7f; - npc.ai[2] = 1f; - } - } - } - else - { - // Set damage - npc.damage = (int)Math.Round(npc.defDamage * 1.4); - - npc.ai[3] = 1f; - npc.velocity.X *= 0.9f; - if (Math.Abs(npc.velocity.X) < 0.1f) - { - npc.velocity.X = 0f; - } - npc.ai[2] += 1f; - if (npc.ai[2] >= 20f || npc.velocity.Y != 0f || (Main.dayTime && (double)npc.position.Y < Main.worldSurface * 16.0)) - { - npc.ai[2] = 0f; - } - } - } - else if (npcType != NPCID.SkeletonArcher && - npcType != NPCID.GoblinArcher && - npcType != NPCID.IcyMerman && - npcType != NPCID.PirateDeadeye && - npcType != NPCID.PirateCrossbower && - npcType != NPCID.PirateCaptain && - npcType != NPCID.Paladin && - npcType != NPCID.SkeletonSniper && - npcType != NPCID.TacticalSkeleton && - npcType != NPCID.SkeletonCommando && - npcType != NPCID.ElfArcher && - npcType != NPCID.CultistArcherBlue && - npcType != NPCID.CultistArcherWhite && - npcType != NPCID.BrainScrambler && - npcType != NPCID.RayGunner && - (npcType < NPCID.BoneThrowingSkeleton || npcType > NPCID.BoneThrowingSkeleton4) && - npcType != NPCID.DrManFly && - npcType != NPCID.GreekSkeleton && - npcType != NPCID.StardustSoldier && - npcType != NPCID.StardustSpiderSmall && - (npcType < NPCID.Salamander || npcType > NPCID.Salamander9) && - npcType != NPCID.NebulaSoldier && - npcType != NPCID.VortexSoldier && - npcType != NPCID.MartianWalker) - { - float velocityMax = 1f; - if (npcType == NPCID.PincushionZombie) - { - velocityMax = 1.1f; - } - if (npcType == NPCID.SlimedZombie) - { - velocityMax = 0.9f; - } - if (npcType == NPCID.SwampZombie) - { - velocityMax = 1.2f; - } - if (npcType == NPCID.TwiggyZombie) - { - velocityMax = 0.8f; - } - if (npcType == NPCID.BaldZombie) - { - velocityMax = 0.95f; - } - if (npcType == NPCID.FemaleZombie) - { - velocityMax = 0.87f; - } - if (npcType == NPCID.ZombieRaincoat) - { - velocityMax = 1.05f; - } - if (npcType == ModContent.NPCType()) - { - velocityMax = 0.85f; - } - if (npcType == NPCID.BloodZombie) - { - float playerDistance = (Main.player[npc.target].Center - npc.Center).Length(); - playerDistance *= 0.0025f; - if (playerDistance > 1.5) - { - playerDistance = 1.5f; - } - if (Main.expertMode) - { - velocityMax = 3f - playerDistance; - } - else - { - velocityMax = 2.5f - playerDistance; - } - velocityMax *= 0.8f; - } - if (npcType == NPCID.BloodZombie || npcType == NPCID.Zombie || npcType == NPCID.BaldZombie || npcType == NPCID.PincushionZombie || npcType == NPCID.SlimedZombie || npcType == NPCID.SwampZombie || npcType == NPCID.TwiggyZombie || npcType == NPCID.FemaleZombie || npcType == NPCID.ZombieRaincoat || npcType == NPCID.ZombieXmas || npcType == NPCID.ZombieSweater || npcType == ModContent.NPCType()) - { - velocityMax *= 1f + (1f - npc.scale); - } - if (CalamityWorld.revenge) - velocityMax *= 1.25f; - if (CalamityWorld.death) - velocityMax *= 1.25f; - FighterRunningAI(npc, velocityMax, 0.09f, 0.8f, true, 0.8f); - } - - if (npcType >= 277 && npcType <= 280) - { - Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.2f, 0.1f, 0f); - } - else if (npcType == NPCID.MartianWalker) - { - Lighting.AddLight(npc.Top + new Vector2(0f, 20f), 0.3f, 0.3f, 0.7f); - } - else if (npcType == NPCID.DesertGhoulCorruption) - { - Vector3 rgb = new Vector3(0.7f, 1f, 0.2f) * 0.5f; - Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb); - } - else if (npcType == NPCID.DesertGhoulCrimson) - { - Vector3 rgb2 = new Vector3(1f, 1f, 0.5f) * 0.4f; - Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb2); - } - else if (npcType == NPCID.DesertGhoulHallow) - { - Vector3 rgb3 = new Vector3(0.6f, 0.3f, 1f) * 0.4f; - Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb3); - } - else if (npcType == NPCID.SolarDrakomire) - { - npc.hide = false; - // I'd assume the Drakomire is drawn by the rider if it's present - foreach (NPC n in Main.ActiveNPCs) - { - if (n.type == NPCID.SolarDrakomireRider && n.ai[0] == (float)npc.whoAmI) - { - npc.hide = true; - break; - } - } - } - else if (npcType == NPCID.MushiLadybug) - { - if (npc.velocity.Y != 0f) - { - npc.TargetClosest(true); - npc.spriteDirection = npc.direction; - if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > 0f) - { - npc.velocity.X *= 0.95f; - } - else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 0f) - { - npc.velocity.X *= 0.95f; - } - if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > -5f) - { - npc.velocity.X -= 0.1f; - } - else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 5f) - { - npc.velocity.X += 0.1f; - } - } - else if (Main.player[npc.target].Center.Y + 50f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.velocity.Y = -9f; - } - } - else if (npcType == NPCID.VortexRifleman) - { - if (npc.velocity.Y == 0f) - { - npc.ai[2] = 0f; - } - if (npc.velocity.Y != 0f && npc.ai[2] == 1f) - { - npc.TargetClosest(true); - npc.spriteDirection = -npc.direction; - if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - { - float idealLocationX = Main.player[npc.target].Center.X - (float)(npc.direction * 600) - npc.Center.X; - float idealLocationY = Main.player[npc.target].Bottom.Y - npc.Bottom.Y; - if (idealLocationX < 0f && npc.velocity.X > 0f) - { - npc.velocity.X *= 0.9f; - } - else if (idealLocationX > 0f && npc.velocity.X < 0f) - { - npc.velocity.X *= 0.9f; - } - if (idealLocationX < 0f && npc.velocity.X > -7f) - { - npc.velocity.X -= 0.12f; - } - else if (idealLocationX > 0f && npc.velocity.X < 7f) - { - npc.velocity.X += 0.12f; - } - if (npc.velocity.X > 8f) - { - npc.velocity.X = 8f; - } - if (npc.velocity.X < -8f) - { - npc.velocity.X = -8f; - } - if (idealLocationY < -20f && npc.velocity.Y > 0f) - { - npc.velocity.Y *= 0.8f; - } - else if (idealLocationY > 20f && npc.velocity.Y < 0f) - { - npc.velocity.Y *= 0.8f; - } - if (idealLocationY < -20f && npc.velocity.Y > -7f) - { - npc.velocity.Y -= 0.35f; - } - else if (idealLocationY > 20f && npc.velocity.Y < 7f) - { - npc.velocity.Y += 0.35f; - } - } - if (Main.rand.NextBool(3)) - { - Vector2 position = npc.Center + new Vector2((float)(npc.direction * -14), -8f) - Vector2.One * 4f; - Vector2 velocity = new Vector2((float)(npc.direction * -6), 12f) * 0.2f + Utils.RandomVector2(Main.rand, -1f, 1f) * 0.1f; - Dust dust = Main.dust[Dust.NewDust(position, 8, 8, DustID.Vortex, velocity.X, velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 0.5f)]; - dust.noGravity = true; - dust.velocity = velocity; - dust.customData = npc; - } - // Adjust velocity based on the other storm drivers who want to pump your face full of bullets - foreach (NPC n in Main.ActiveNPCs) - { - 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 < n.position.X) - { - npc.velocity.X -= 0.05f; - } - else - { - npc.velocity.X += 0.05f; - } - if (npc.position.Y < n.position.Y) - { - npc.velocity.Y -= 0.05f; - } - else - { - npc.velocity.Y += 0.05f; - } - } - } - } - else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.velocity.Y = -7f; - npc.ai[2] = 1f; - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[2]++; - bool closeToPlayer = npc.Distance(Main.player[npc.target].Center) < 600f && Math.Abs(npc.SafeDirectionTo(Main.player[npc.target].Center).Y) < 0.5f; - float vortexShotgunGateValue = CalamityWorld.death ? 240f : CalamityWorld.revenge ? 360f : 480f; - if (npc.localAI[2] >= vortexShotgunGateValue && closeToPlayer && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - { - npc.localAI[2] = 0f; - Vector2 spawnPosition = npc.Center + new Vector2(npc.direction * 30f, 2f); - float vortexLaserVelocity = CalamityWorld.death ? 7f : CalamityWorld.revenge ? 6f : 5f; - Vector2 baseLaserVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center, Vector2.UnitX * npc.direction) * vortexLaserVelocity; - - int damage = Main.expertMode ? 50 : 75; - float maxSpread = CalamityWorld.death ? 0.7f : CalamityWorld.revenge ? 0.6f : 0.5f; - for (int i = 0; i < 4; i++) - { - Vector2 randomizedVelocity = baseLaserVelocity + Utils.RandomVector2(Main.rand, -maxSpread, maxSpread); - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition, randomizedVelocity, ProjectileID.VortexLaser, damage, 1f, Main.myPlayer); - } - } - } - } - else if (npcType == NPCID.VortexHornet) - { - if (npc.velocity.Y == 0f) - { - npc.ai[2] = 0f; - npc.rotation = 0f; - } - else - { - npc.rotation = npc.velocity.X * 0.1f; - } - if (npc.velocity.Y != 0f && npc.ai[2] == 1f) - { - npc.TargetClosest(true); - npc.spriteDirection = -npc.direction; - if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - { - float playerDistX = Main.player[npc.target].Center.X - npc.Center.X; - float playerDistY = Main.player[npc.target].Center.Y - npc.Center.Y; - if (playerDistX < 0f && npc.velocity.X > 0f) - { - npc.velocity.X *= 0.98f; - } - else if (playerDistX > 0f && npc.velocity.X < 0f) - { - npc.velocity.X *= 0.98f; - } - if (playerDistX < -20f && npc.velocity.X > -(CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X -= CalamityWorld.revenge ? 0.025f : 0.015f; - } - else if (playerDistX > 20f && npc.velocity.X < (CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X += CalamityWorld.revenge ? 0.025f : 0.015f; - } - if (npc.velocity.X > (CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X = CalamityWorld.revenge ? 8f : 6f; - } - if (npc.velocity.X < -(CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X = -(CalamityWorld.revenge ? 8f : 6f); - } - if (playerDistY < -20f && npc.velocity.Y > 0f) - { - npc.velocity.Y *= 0.98f; - } - else if (playerDistY > 20f && npc.velocity.Y < 0f) - { - npc.velocity.Y *= 0.98f; - } - if (playerDistY < -20f && npc.velocity.Y > -(CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.Y -= CalamityWorld.revenge ? 0.25f : 0.15f; - } - else if (playerDistY > 20f && npc.velocity.Y < (CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.Y += CalamityWorld.revenge ? 0.25f : 0.15f; - } - } - foreach (NPC n in Main.ActiveNPCs) - { - 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 < n.position.X) - { - npc.velocity.X -= 0.05f; - } - else - { - npc.velocity.X += 0.05f; - } - if (npc.position.Y < n.position.Y) - { - npc.velocity.Y -= 0.05f; - } - else - { - npc.velocity.Y += 0.05f; - } - } - } - } - else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.velocity.Y = -(CalamityWorld.revenge ? 7f : 5f); - npc.ai[2] = 1f; - } - } - else if (npcType == NPCID.VortexHornetQueen) - { - if (npc.ai[1] > 0f && npc.velocity.Y > 0f) - { - npc.velocity.Y *= 0.85f; - if (npc.velocity.Y == 0f) - { - npc.velocity.Y = -0.4f; - } - } - if (npc.velocity.Y != 0f) - { - npc.TargetClosest(true); - npc.spriteDirection = npc.direction; - if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - { - float distanceToLocationX = Main.player[npc.target].Center.X - (float)(npc.direction * (CalamityWorld.revenge ? 450 : 300)) - npc.Center.X; - if (distanceToLocationX < 40f && npc.velocity.X > 0f) - { - npc.velocity.X *= 0.98f; - } - else if (distanceToLocationX > 40f && npc.velocity.X < 0f) - { - npc.velocity.X *= 0.98f; - } - if (distanceToLocationX < 40f && npc.velocity.X > -(CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X -= CalamityWorld.revenge ? 0.25f : 0.2f; - } - else if (distanceToLocationX > 40f && npc.velocity.X < (CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X += CalamityWorld.revenge ? 0.25f : 0.2f; - } - if (npc.velocity.X > (CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X = CalamityWorld.revenge ? 8f : 6f; - } - if (npc.velocity.X < -(CalamityWorld.revenge ? 8f : 6f)) - { - npc.velocity.X = -(CalamityWorld.revenge ? 8f : 6f); - } - } - } - else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.velocity.Y = -(CalamityWorld.revenge ? 8f : 6f); - } - foreach (NPC n in Main.ActiveNPCs) - { - 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 < n.position.X) - { - npc.velocity.X -= 0.1f; - } - else - { - npc.velocity.X += 0.1f; - } - if (npc.position.Y < n.position.Y) - { - npc.velocity.Y -= 0.1f; - } - else - { - npc.velocity.Y += 0.1f; - } - } - } - if (Main.rand.NextBool(6) && npc.ai[1] <= 20f) - { - Dust dust = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, DustID.Vortex, npc.velocity.X, npc.velocity.Y, 100, default, 1f)]; - dust.velocity = dust.velocity / 4f + npc.velocity / 2f; - dust.scale = 0.6f; - dust.noLight = true; - } - if (npc.ai[1] >= 57f) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 161, - 229 - }); - Dust dust = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, dustType, npc.velocity.X, npc.velocity.Y, 100, default, 1f)]; - dust.velocity = dust.velocity / 4f + npc.SafeDirectionTo(Main.player[npc.target].Top); - dust.scale = 1.2f; - dust.noLight = true; - } - if (Main.rand.NextBool(6)) - { - Dust dust = Main.dust[Dust.NewDust(npc.Center, 2, 2, DustID.Vortex, 0f, 0f, 0, default, 1f)]; - dust.position = npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 26 : -26), 24f); - dust.velocity.X = 0f; - if (dust.velocity.Y < 0f) - { - dust.velocity.Y = 0f; - } - dust.noGravity = true; - dust.scale = 1f; - dust.noLight = true; - } - } - else if (npcType == NPCID.SnowFlinx) - { - if (npc.velocity.Y == 0f) - { - npc.rotation = 0f; - npc.localAI[0] = 0f; - } - else if (npc.localAI[0] == 1f) - { - npc.rotation += npc.velocity.X * 0.05f; - } - } - else if (npcType == NPCID.VortexLarva) - { - if (npc.velocity.Y == 0f) - { - npc.rotation = 0f; - } - else - { - npc.rotation += npc.velocity.X * 0.08f; - } - } - - // Turn into a bat - if (npcType == NPCID.Vampire && Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.Distance(Main.player[npc.target].Center) > 300f) - { - npc.Transform(NPCID.VampireBat); - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.velocity.Y == 0f) - TryConvertToWallClimber(npc); - - bool prehardmodeSpiders = (npc.type == NPCID.WallCreeper || npc.type == NPCID.WallCreeperWall || npc.type == NPCID.BloodCrawler || npc.type == NPCID.BloodCrawlerWall) && CalamityWorld.revenge; - if (Main.netMode != NetmodeID.MultiplayerClient && Main.expertMode && npc.target >= 0 && (npcType == NPCID.BlackRecluse || npcType == NPCID.BlackRecluseWall || npc.type == NPCID.JungleCreeper || npc.type == NPCID.JungleCreeperWall || prehardmodeSpiders) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.localAI[0] += 1f; - if (npc.justHit) - npc.localAI[0] = 0f; - - float webSpitGateValue = CalamityWorld.death ? SpiderWebSpitGateValue_Death : CalamityWorld.revenge ? SpiderWebSpitGateValue_Rev : SpiderWebSpitGateValue; - - // Emit web dust from mouth when about to fire - Vector2 mouth = new Vector2(npc.Center.X + (npc.direction == -1 ? -22f : 12f), npc.Center.Y - 4f); - if (npc.localAI[0] > webSpitGateValue - SpiderWebSpitTelegraphTime) - { - Dust dust = Dust.NewDustDirect(mouth, 1, 1, DustID.Web, 0f, 0f, 100, default, 1.5f); - dust.noGravity = true; - dust.velocity *= 0f; - } - - if (npc.localAI[0] >= webSpitGateValue) - { - npc.localAI[0] = 0f; - Vector2 velocity = (Main.player[npc.target].Center - mouth).SafeNormalize(-Vector2.UnitY) * (prehardmodeSpiders ? 6f : 10f); - Projectile.NewProjectile(npc.GetSource_FromAI(), mouth, velocity, ProjectileID.WebSpit, 18, 0f, Main.myPlayer); - } - } - else - npc.localAI[0] = 0f; - - if (npcType == NPCID.IceGolem) - { - if (npc.justHit || npc.confused || npc.velocity.Y != 0f || Main.player[npc.target].dead || Main.player[npc.target].frozen || !((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.ai[2] = 0f; - - npc.ai[2] += 1f; - Vector2 eyeLocation = npc.Center + Vector2.UnitX * (npc.direction == -1 ? -14f : 6f) - Vector2.UnitY * 40f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] >= (CalamityWorld.death ? IceGolemFrostBeamGateValue_Death : CalamityWorld.revenge ? IceGolemFrostBeamGateValue_Rev : IceGolemFrostBeamGateValue) && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.netUpdate = true; - float iceLaserVelocity = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; - Vector2 spawnPosition = eyeLocation; - Vector2 velocity = (Main.player[npc.target].Center - spawnPosition).SafeNormalize(-Vector2.UnitY) * iceLaserVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition + velocity.SafeNormalize(-Vector2.UnitY) * 100f, velocity, ProjectileID.FrostBeam, 32, 0f, Main.myPlayer); - npc.ai[2] = 0f; - } - - // Emit ice dust from eye when about to fire - if (npc.ai[2] > (CalamityWorld.death ? IceGolemFrostBeamGateValue_Death : CalamityWorld.revenge ? IceGolemFrostBeamGateValue_Rev : IceGolemFrostBeamGateValue) - IceGolemFrostBeamTelegraphTime) - { - Dust dust = Dust.NewDustDirect(eyeLocation, 1, 1, DustID.Frost, 0f, 0f, 200, default, 1.5f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } - - if (npcType == NPCID.Eyezor) - { - if (npc.justHit || npc.confused || npc.velocity.Y != 0f || Main.player[npc.target].dead || !((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.ai[2] = 0f; - - npc.ai[2] += 1f; - Vector2 eyeLocation = new Vector2(npc.position.X + (npc.direction == -1 ? -12f : 6f) + (float)npc.width * 0.5f, npc.position.Y + 6f); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] >= (CalamityWorld.death ? EyezorLaserGateValue_Death : CalamityWorld.revenge ? EyezorLaserGateValue_Rev : EyezorLaserGateValue) && npc.velocity.Y == 0f && !Main.player[npc.target].dead && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - float eyeLaserVelocity = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; - Vector2 spawnPosition = eyeLocation; - Vector2 velocity = (Main.player[npc.target].Center - spawnPosition).SafeNormalize(-Vector2.UnitY) * eyeLaserVelocity; - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition + velocity.SafeNormalize(-Vector2.UnitY) * 80f, velocity, ProjectileID.EyeLaser, 40, 0f, Main.myPlayer); - npc.ai[2] = 0f; - } - - // Emit demon dust from eye when about to fire - if (npc.ai[2] > (CalamityWorld.death ? EyezorLaserGateValue_Death : CalamityWorld.revenge ? EyezorLaserGateValue_Rev : EyezorLaserGateValue) - EyezorLaserTelegraphTime) - { - Dust dust = Dust.NewDustDirect(eyeLocation, 1, 1, 27, 0f, 0f, 100, default, 1.5f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } - - if (npcType == NPCID.MartianEngineer) - { - if (npc.confused) - { - npc.ai[2] = -40f; - } - else - { - if (npc.ai[2] < 40f) - { - npc.ai[2] += 1f; - } - if (npc.ai[2] > 0f && NPC.CountNPCS(NPCID.MartianTurret) >= 4 * NPC.CountNPCS(NPCID.MartianEngineer)) - { - npc.ai[2] = 0f; - } - if (npc.justHit) - { - npc.ai[2] = -20f; - } - if (npc.ai[2] == 20f) - { - int centerTileX = (int)npc.position.X / 16; - int centerTileY = (int)npc.position.Y / 16; - int centerTileX2 = (int)npc.position.X / 16; - int centerTileY2 = (int)npc.position.Y / 16; - int maxTurretDistX = 5; - int maxTurretDistanceY = 2; - int tryCounter = 0; - bool createdTurret = false; - while (!createdTurret && tryCounter < 100) - { - tryCounter++; - int turretSpawnX = Main.rand.Next(centerTileX - maxTurretDistX, centerTileX + maxTurretDistX); - for (int y = Main.rand.Next(centerTileY - maxTurretDistX, centerTileY + maxTurretDistX); y < centerTileY + maxTurretDistX; y++) - { - if ((y < centerTileY - maxTurretDistanceY || y > centerTileY + maxTurretDistanceY || turretSpawnX < centerTileX - maxTurretDistanceY || turretSpawnX > centerTileX + maxTurretDistanceY) && (y < centerTileY2 || y > centerTileY2 || turretSpawnX < centerTileX2 || turretSpawnX > centerTileX2) && Main.tile[turretSpawnX, y].HasUnactuatedTile) - { - bool notLava = true; - if (Main.tile[turretSpawnX, y - 1].LiquidType == LiquidID.Lava) - { - notLava = false; - } - if (notLava && Main.tileSolid[(int)Main.tile[turretSpawnX, y].TileType] && !Collision.SolidTiles(turretSpawnX - 1, turretSpawnX + 1, y - 4, y - 1)) - { - int turretIdx = NPC.NewNPC(npc.GetSource_FromAI(), turretSpawnX * 16 - npc.width / 2, y * 16, NPCID.MartianTurret, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[turretIdx].position.Y = (float)(y * 16 - Main.npc[turretIdx].height); - createdTurret = true; - npc.netUpdate = true; - break; - } - } - } - } - } - if (npc.ai[2] == 40f) - { - npc.ai[2] = -90f; - } - } - } - - if (npcType == NPCID.GigaZapper) - { - if (npc.confused) - { - npc.ai[2] = -40f; - } - else - { - if (npc.ai[2] < 20f) - { - npc.ai[2] += 1f; - } - if (npc.justHit) - { - npc.ai[2] = -20f; - } - if (npc.ai[2] == 20f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[2] = (float)(-10 + Main.rand.Next(3) * -10); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y + 8f, (float)(npc.direction * 8), 0f, ProjectileID.GigaZapperSpear, 25, 1f, Main.myPlayer); - } - } - } - - if (npcType == NPCID.SkeletonArcher || - npcType == NPCID.GoblinArcher || - npcType == NPCID.IcyMerman || - npcType == NPCID.PirateDeadeye || - npcType == NPCID.PirateCrossbower || - npcType == NPCID.PirateCaptain || - npcType == NPCID.Paladin || - npcType == NPCID.SkeletonSniper || - npcType == NPCID.TacticalSkeleton || - npcType == NPCID.SkeletonCommando || - npcType == NPCID.ElfArcher || - npcType == NPCID.CultistArcherBlue || - npcType == NPCID.CultistArcherWhite || - npcType == NPCID.BrainScrambler || - npcType == NPCID.RayGunner || - (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) || - (npcType == NPCID.DrManFly || - npcType == NPCID.GreekSkeleton || - npcType == NPCID.StardustSoldier || - npcType == NPCID.StardustSpiderBig || - (npcType >= NPCID.Salamander && npcType <= NPCID.Salamander9)) || - npcType == NPCID.NebulaSoldier || - npcType == NPCID.VortexHornetQueen || - npcType == NPCID.MartianWalker) - { - bool npcAllowedToShoot = npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker; - bool isAlienQueen = npcType == NPCID.VortexHornetQueen; - bool canShootAtTarget = true; - int stardustGateValue = -1; - int stardustGateValueAdd = -1; - if (npcType == NPCID.StardustSoldier) - { - npcAllowedToShoot = true; - stardustGateValue = 90; - stardustGateValueAdd = 90; - if (npc.ai[1] <= 150f) - { - canShootAtTarget = false; - } - } - if (npc.confused) - { - npc.ai[2] = 0f; - } - else - { - if (npc.ai[1] > 0f) - { - npc.ai[1] -= 1f; - } - if (npc.justHit) - { - npc.ai[1] = 30f; - npc.ai[2] = 0f; - } - int attackTimeMax = 70; - if (npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite) - { - attackTimeMax = 80; - } - if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) - { - attackTimeMax = 80; - } - if (npcType == NPCID.MartianWalker) - { - attackTimeMax = 15; - } - if (npcType == NPCID.ElfArcher) - { - attackTimeMax = 110; - } - if (npcType == NPCID.SkeletonSniper) - { - attackTimeMax = 200; - } - if (npcType == NPCID.TacticalSkeleton) - { - attackTimeMax = 120; - } - if (npcType == NPCID.SkeletonCommando) - { - attackTimeMax = 90; - } - if (npcType == NPCID.GoblinArcher) - { - attackTimeMax = 180; - } - if (npcType == NPCID.IcyMerman) - { - attackTimeMax = 50; - } - if (npcType == NPCID.GreekSkeleton) - { - attackTimeMax = 100; - } - if (npcType == NPCID.PirateDeadeye) - { - attackTimeMax = 40; - } - if (npcType == NPCID.PirateCrossbower) - { - attackTimeMax = 80; - } - if (npcType == NPCID.Paladin) - { - attackTimeMax = 30; - } - if (npcType == NPCID.StardustSoldier) - { - attackTimeMax = 300; - } - if (npcType == NPCID.StardustSpiderBig) - { - attackTimeMax = 60; - } - if (npcType == NPCID.NebulaSoldier) - { - attackTimeMax = 180; - } - if (npcType == NPCID.VortexHornetQueen) - { - attackTimeMax = 60; - } - bool priateCaptainBoost = false; - if (npcType == NPCID.PirateCaptain) - { - if (npc.localAI[2] >= 20f) - { - priateCaptainBoost = true; - } - if (priateCaptainBoost) - { - attackTimeMax = 60; - } - else - { - attackTimeMax = 8; - } - } - - if (CalamityWorld.revenge) - attackTimeMax = (int)(attackTimeMax * 0.75); - - int modifiedAttackTime = attackTimeMax / 2; - if (npcType == NPCID.NebulaSoldier) - { - modifiedAttackTime = attackTimeMax - 1; - } - if (npcType == NPCID.VortexHornetQueen) - { - modifiedAttackTime = attackTimeMax - 1; - } - if (npc.ai[2] > 0f) - { - if (canShootAtTarget) - { - npc.TargetClosest(true); - } - if (npc.ai[1] == (float)modifiedAttackTime) - { - if (npcType == NPCID.PirateCaptain) - { - npc.localAI[2] += 1f; - } - float projSpeed = CalamityWorld.death ? 6f : 11f; - if (npcType == NPCID.GoblinArcher) - { - projSpeed = CalamityWorld.death ? 5f : 9f; - } - if (npcType == NPCID.IcyMerman) - { - projSpeed = CalamityWorld.death ? 4f : 7f; - } - if (npcType == NPCID.Paladin) - { - projSpeed = CalamityWorld.death ? 5f : 9f; - } - if (npcType == NPCID.SkeletonCommando) - { - projSpeed = CalamityWorld.death ? 2.5f : 4f; - } - if (npcType == NPCID.PirateDeadeye) - { - projSpeed = CalamityWorld.death ? 8f : 14f; - } - if (npcType == NPCID.PirateCrossbower) - { - projSpeed = CalamityWorld.death ? 9f : 16f; - } - if (npcType == NPCID.RayGunner) - { - projSpeed = CalamityWorld.death ? 4f : 7f; - } - if (npcType == NPCID.MartianWalker) - { - projSpeed = CalamityWorld.death ? 5f : 8f; - } - if (npcType == NPCID.StardustSpiderBig) - { - projSpeed = 4f; - } - if (npcType >= 449 && npcType <= 452) - { - projSpeed = CalamityWorld.death ? 4f : 7f; - } - if (npcType == NPCID.GreekSkeleton) - { - projSpeed = CalamityWorld.death ? 5f : 8f; - } - if (npcType == NPCID.DrManFly) - { - projSpeed = CalamityWorld.death ? 4.5f : 7.5f; - } - if (npcType == NPCID.StardustSoldier) - { - projSpeed = 1f; - } - if (npcType >= 498 && npcType <= 506) - { - projSpeed = CalamityWorld.death ? 4f : 7f; - } - - if (CalamityWorld.revenge) - projSpeed *= 1.25f; - - Vector2 spawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - if (npcType == NPCID.GreekSkeleton) - { - spawnPosition.Y -= 14f; - } - if (npcType == NPCID.IcyMerman) - { - spawnPosition.Y -= 10f; - } - if (npcType == NPCID.Paladin) - { - spawnPosition.Y -= 10f; - } - if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) - { - spawnPosition.Y += 6f; - } - if (npcType == NPCID.MartianWalker) - { - spawnPosition.Y = npc.position.Y + 20f; - } - if (npcType >= 498 && npcType <= 506) - { - spawnPosition.Y -= 8f; - } - if (npcType == NPCID.VortexHornetQueen) - { - spawnPosition += new Vector2((float)(npc.spriteDirection * 2), -12f); - projSpeed = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 9f : 7f; - } - float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - spawnPosition.X; - float projOffset = Math.Abs(distX) * 0.1f; - if (npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton) - { - projOffset = 0f; - } - if (npcType == NPCID.PirateCrossbower) - { - projOffset = Math.Abs(distX) * 0.08f; - } - if (npcType == NPCID.PirateDeadeye || (npcType == NPCID.PirateCaptain && !priateCaptainBoost)) - { - projOffset = 0f; - } - if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker) - { - projOffset = 0f; - } - if (npcType >= 449 && npcType <= 452) - { - projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; - } - if (npcType == NPCID.DrManFly) - { - projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; - } - if (npcType == NPCID.GreekSkeleton) - { - projOffset = Math.Abs(distX) * (float)Main.rand.Next(-10, 11) * 0.0035f; - } - if (npcType >= 498 && npcType <= 506) - { - projOffset = Math.Abs(distX) * (float)Main.rand.Next(1, 11) * 0.0025f; - } - float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - spawnPosition.Y - projOffset; - float magnitude = (float)Math.Sqrt((distX * distX + distY * distY)); - npc.netUpdate = true; - magnitude = projSpeed / magnitude; - distX *= magnitude; - distY *= magnitude; - int damage = 35; - int projectileType = ProjectileID.FlamingArrow; - if (npcType == NPCID.ElfArcher) - { - damage = 45; - } - if (npcType == NPCID.GoblinArcher) - { - projectileType = ProjectileID.WoodenArrowHostile; - damage = 11; - } - if (npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite) - { - projectileType = ProjectileID.WoodenArrowHostile; - damage = 40; - } - if (npcType == NPCID.BrainScrambler) - { - projectileType = ProjectileID.BrainScramblerBolt; - damage = 24; - } - if (npcType == NPCID.RayGunner) - { - projectileType = ProjectileID.RayGunnerLaser; - damage = 30; - } - if (npcType == NPCID.MartianWalker) - { - projectileType = ProjectileID.MartianWalkerLaser; - damage = 35; - } - if (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) - { - projectileType = ProjectileID.SkeletonBone; - damage = 20; - } - if (npcType >= NPCID.Salamander && npcType <= NPCID.Salamander9) - { - projectileType = ProjectileID.SalamanderSpit; - damage = 14; - } - if (npcType == NPCID.GreekSkeleton) - { - projectileType = ProjectileID.JavelinHostile; - damage = 18; - } - if (npcType == NPCID.IcyMerman) - { - projectileType = ProjectileID.IcewaterSpit; - damage = 37; - } - if (npcType == NPCID.DrManFly) - { - projectileType = ProjectileID.DrManFlyFlask; - damage = 50; - } - if (npcType == NPCID.StardustSoldier) - { - projectileType = ProjectileID.StardustSoldierLaser; - damage = (Main.expertMode ? 45 : 60); - } - if (npcType == NPCID.NebulaSoldier) - { - projectileType = ProjectileID.NebulaBolt; - damage = (Main.expertMode ? 45 : 60); - } - if (npcType == NPCID.VortexHornetQueen) - { - projectileType = ProjectileID.VortexAcid; - damage = (Main.expertMode ? 45 : 60); - } - if (npcType == NPCID.SkeletonSniper) - { - projectileType = ProjectileID.SniperBullet; - damage = 100; - } - if (npcType == NPCID.Paladin) - { - projectileType = ProjectileID.PaladinsHammerHostile; - damage = 60; - } - if (npcType == NPCID.SkeletonCommando) - { - projectileType = ProjectileID.RocketSkeleton; - damage = 60; - } - if (npcType == NPCID.PirateDeadeye) - { - projectileType = ProjectileID.BulletDeadeye; - damage = 25; - } - if (npcType == NPCID.PirateCrossbower) - { - projectileType = ProjectileID.FlamingArrow; - damage = 40; - } - if (npcType == NPCID.TacticalSkeleton) - { - damage = 50; - projectileType = ProjectileID.BulletDeadeye; - } - if (npcType == NPCID.PirateCaptain) - { - projectileType = ProjectileID.BulletDeadeye; - damage = 30; - if (priateCaptainBoost) - { - damage = 100; - projectileType = ProjectileID.CannonballHostile; - npc.localAI[2] = 0f; - } - } - spawnPosition.X += distX; - spawnPosition.Y += distY; - if (Main.expertMode && npcType == NPCID.Paladin) - { - damage = (int)(damage * 0.75); - } - if (Main.expertMode && npcType >= 381 && npcType <= 392) - { - damage = (int)(damage * 0.8); - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npcType == NPCID.TacticalSkeleton) - { - Vector2 bulletSpawnPosition = npc.Center; - for (int num147 = 0; num147 < 4; num147++) - { - distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - spawnPosition.X; - distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - spawnPosition.Y; - magnitude = (float)Math.Sqrt((distX * distX + distY * distY)); - magnitude = (CalamityWorld.death ? 8f : CalamityWorld.revenge ? 7f : 6f) / magnitude; - int shotgunSpread = 20; - distX += (float)Main.rand.Next(-shotgunSpread, shotgunSpread + 1); - distY += (float)Main.rand.Next(-shotgunSpread, shotgunSpread + 1); - distX *= magnitude; - distY *= magnitude; - Vector2 bulletVelocity = new Vector2(distX, distY); - Projectile.NewProjectile(npc.GetSource_FromAI(), bulletSpawnPosition + bulletVelocity.SafeNormalize(-Vector2.UnitY) * 30f, bulletVelocity, projectileType, damage, 0f, Main.myPlayer); - } - } - else if (npcType == NPCID.StardustSoldier) - { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, distX, distY, projectileType, damage, 0f, Main.myPlayer, 0f, (float)npc.whoAmI); - if (CalamityWorld.death) - { - Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].timeLeft = 480; - } - } - else if (npcType == NPCID.NebulaSoldier) - { - for (int i = 0; i < 4; i++) - { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X - (float)(npc.spriteDirection * 4), npc.Center.Y + 6f, (float)(-3 + 2 * i) * 0.15f, (float)(-(float)Main.rand.Next(0, 3)) * 0.2f - 0.1f, projectileType, damage, 0f, Main.myPlayer, 0f, (float)npc.whoAmI); - if (CalamityWorld.death) - { - Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].timeLeft = 1200; - } - } - } - else if (npcType == NPCID.StardustSpiderBig) - { - int idx = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.StardustSpiderSmall, npc.whoAmI); - Main.npc[idx].velocity = new Vector2(distX, -6f + distY); - } - else - { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, distX, distY, projectileType, damage, 0f, Main.myPlayer); - if (CalamityWorld.death) - { - Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].timeLeft = 1200; - } - } - } - if (Math.Abs(distY) > Math.Abs(distX) * 2f) - { - if (distY > 0f) - { - npc.ai[2] = 1f; - } - else - { - npc.ai[2] = 5f; - } - } - else if (Math.Abs(distX) > Math.Abs(distY) * 2f) - { - npc.ai[2] = 3f; - } - else if (distY > 0f) - { - npc.ai[2] = 2f; - } - else - { - npc.ai[2] = 4f; - } - } - if ((npc.velocity.Y != 0f && !isAlienQueen) || npc.ai[1] <= 0f) - { - npc.ai[2] = 0f; - npc.ai[1] = 0f; - } - else if (!npcAllowedToShoot || (stardustGateValue != -1 && npc.ai[1] >= (float)stardustGateValue && npc.ai[1] < (float)(stardustGateValue + stardustGateValueAdd) && (!isAlienQueen || npc.velocity.Y == 0f))) - { - npc.velocity.X *= 0.9f; - npc.spriteDirection = npc.direction; - } - } - - if (npcType == NPCID.DrManFly && !Main.eclipse) - { - npcAllowedToShoot = true; - } - else if ((npc.ai[2] <= 0f | npcAllowedToShoot) && (npc.velocity.Y == 0f | isAlienQueen) && npc.ai[1] <= 0f && !Main.player[npc.target].dead) - { - bool canAttack = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - if (npcType == NPCID.MartianWalker) - { - canAttack = Collision.CanHitLine(npc.Top + new Vector2(0f, 20f), 0, 0, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - } - if (Main.player[npc.target].stealth == 0f && Main.player[npc.target].itemAnimation == 0) - { - canAttack = false; - } - if (canAttack) - { - Vector2 projSpawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - projSpawnPosition.X; - float distXAbsolute = Math.Abs(distX) * 0.1f; - float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - projSpawnPosition.Y - distXAbsolute; - distX += (float)Main.rand.Next(-40, 41); - distY += (float)Main.rand.Next(-40, 41); - float playerDistance = (float)Math.Sqrt(distX * distX + distY * distY); - float maxAttackDistance = 700f; - if (npcType == NPCID.PirateDeadeye) - { - maxAttackDistance = 550f; - } - if (npcType == NPCID.PirateCrossbower) - { - maxAttackDistance = 800f; - } - if (npcType >= NPCID.Salamander && npcType <= NPCID.Salamander9) - { - maxAttackDistance = 190f; - } - if (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) - { - maxAttackDistance = 200f; - } - if (npcType == NPCID.GreekSkeleton) - { - maxAttackDistance = 400f; - } - if (npcType == NPCID.DrManFly) - { - maxAttackDistance = 400f; - } - if (CalamityWorld.death) - { - maxAttackDistance *= 1.25f; - } - if (playerDistance < maxAttackDistance) - { - npc.netUpdate = true; - npc.velocity.X *= 0.5f; - playerDistance = 10f / playerDistance; - distX *= playerDistance; - distY *= playerDistance; - npc.ai[2] = 3f; - npc.ai[1] = (float)attackTimeMax; - if (Math.Abs(distY) > Math.Abs(distX) * 2f) - { - if (distY > 0f) - { - npc.ai[2] = 1f; - } - else - { - npc.ai[2] = 5f; - } - } - else if (Math.Abs(distX) > Math.Abs(distY) * 2f) - { - npc.ai[2] = 3f; - } - else if (distY > 0f) - { - npc.ai[2] = 2f; - } - else - { - npc.ai[2] = 4f; - } - } - } - } - - if (npc.ai[2] <= 0f || (npcAllowedToShoot && (stardustGateValue == -1 || npc.ai[1] < (float)stardustGateValue || npc.ai[1] >= (float)(stardustGateValue + stardustGateValueAdd)))) - { - float maxVelocity = 1f; - float acceleration = 0.07f; - float decelerationFactor = 0.8f; - if (npcType == NPCID.PirateDeadeye) - { - maxVelocity = 2f; - acceleration = 0.09f; - } - else if (npcType == NPCID.PirateCrossbower) - { - maxVelocity = 1.5f; - acceleration = 0.08f; - } - else if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) - { - maxVelocity = 2f; - acceleration = 0.5f; - } - else if (npcType == NPCID.MartianWalker) - { - maxVelocity = 4f; - acceleration = 1f; - decelerationFactor = 0.7f; - } - else if (npcType == NPCID.StardustSoldier) - { - maxVelocity = 2f; - acceleration = 0.5f; - } - else if (npcType == NPCID.StardustSpiderBig) - { - maxVelocity = 2f; - acceleration = 0.5f; - } - else if (npc.type == NPCID.VortexHornetQueen) - { - maxVelocity = 4f; - acceleration = 0.6f; - decelerationFactor = 0.95f; - } - if (CalamityWorld.revenge) - { - maxVelocity *= 1.5f; - acceleration *= 1.5f; - } - bool forceDeceleration = false; - if ((npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 300f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - { - forceDeceleration = true; - npc.ai[3] = 0f; - } - if (npcType == NPCID.MartianWalker && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 400f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) - { - forceDeceleration = true; - npc.ai[3] = 0f; - } - // The extra OR conditional is the reason the special method I created above isn't used. - // It has enough parameters. Another one for 1 specific purpose isn't worth it anymore - if ((npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) | forceDeceleration) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= decelerationFactor; - } - } - else if (npc.velocity.X < maxVelocity && npc.direction == 1) - { - npc.velocity.X += acceleration; - if (npc.velocity.X > maxVelocity) - { - npc.velocity.X = maxVelocity; - } - } - else if (npc.velocity.X > -maxVelocity && npc.direction == -1) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X < -maxVelocity) - { - npc.velocity.X = -maxVelocity; - } - } - } - - if (npcType == NPCID.MartianWalker) - { - npc.localAI[2] += 1f; - if (npc.localAI[2] >= 6f) - { - npc.localAI[2] = 0f; - npc.localAI[3] = Main.player[npc.target].DirectionFrom(npc.Top + new Vector2(0f, 20f)).ToRotation(); - } - } - } - } - - if (npcType == NPCID.Clown && Main.netMode != NetmodeID.MultiplayerClient && !Main.player[npc.target].dead) - { - if (npc.justHit) - npc.ai[2] = 0f; - - npc.ai[2] += 1f; - float bombDelay = CalamityWorld.death ? 60f : 180f; - if (npc.ai[2] > bombDelay) - { - Vector2 spawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f - (float)(npc.direction * 24), npc.position.Y + 4f); - if (!Main.rand.NextBool(5) || NPC.AnyNPCs(NPCID.ChatteringTeethBomb)) - { - int velocityX = 3 * npc.direction; - int velocityY = -5; - int clownBomb = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, velocityX, velocityY, ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[clownBomb].timeLeft = 300; - if (CalamityWorld.death) - { - Main.projectile[clownBomb].extraUpdates += 1; - Main.projectile[clownBomb].timeLeft = 600; - } - npc.ai[2] = 0f; - } - else - { - npc.ai[2] = -bombDelay * 2; - int chatteringTeethBomb = NPC.NewNPC(npc.GetSource_FromAI(), (int)spawnPosition.X, (int)spawnPosition.Y, NPCID.ChatteringTeethBomb); - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, chatteringTeethBomb, 0f, 0f, 0f, 0, 0, 0); - } - } - } - - bool canOpenDoors = false; - if (npc.velocity.Y == 0f) - { - int j = (int)(npc.position.Y + (float)npc.height + 7f) / 16; - int npcLeft = (int)npc.position.X / 16; - int npcRight = (int)(npc.position.X + (float)npc.width) / 16; - for (int i = npcLeft; i <= npcRight; i++) - { - if (Main.tile[i, j].HasUnactuatedTile && Main.tileSolid[Main.tile[i, j].TileType]) - { - canOpenDoors = true; - break; - } - } - } - - if (npcType == NPCID.VortexLarva) - { - canOpenDoors = false; - } - - if (npc.velocity.Y >= 0f) - { - int velocitySign = 0; - if (npc.velocity.X < 0f) - { - velocitySign = -1; - } - if (npc.velocity.X > 0f) - { - velocitySign = 1; - } - Vector2 positionDelta = npc.position; - positionDelta.X += npc.velocity.X; - int x = (int)((positionDelta.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * velocitySign)) / 16f); - int y = (int)((positionDelta.Y + (float)npc.height - 1f) / 16f); - if (x * 16 < positionDelta.X + (float)npc.width && - (x + 1) * 16 > positionDelta.X && ((Main.tile[x, y].HasUnactuatedTile && - !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && - Main.tileSolid[(int)Main.tile[x, y].TileType] && - !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || - (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && - (!Main.tile[x, y - 1].HasUnactuatedTile || - !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || - Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || - (Main.tile[x, y - 1].IsHalfBlock && - (!Main.tile[x, y - 4].HasUnactuatedTile || - !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || - Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && - (!Main.tile[x, y - 2].HasUnactuatedTile || - !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || - Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && - (!Main.tile[x, y - 3].HasUnactuatedTile || - !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || - Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && - (!Main.tile[x - velocitySign, y - 3].HasUnactuatedTile || - !Main.tileSolid[(int)Main.tile[x - velocitySign, y - 3].TileType])) - { - float yAdjust = y * 16f; - if (Main.tile[x, y].IsHalfBlock) - { - yAdjust += 8f; - } - if (Main.tile[x, y - 1].IsHalfBlock) - { - yAdjust -= 8f; - } - if (yAdjust < positionDelta.Y + (float)npc.height) - { - float gfxOffRelativeToDelta = positionDelta.Y + (float)npc.height - yAdjust; - float yOffsetFloor = 16.1f; - if (npcType == NPCID.BlackRecluse || npcType == NPCID.WallCreeper || npcType == NPCID.JungleCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.DesertScorpionWalk) - { - yOffsetFloor += 8f; - } - if (gfxOffRelativeToDelta <= yOffsetFloor) - { - npc.gfxOffY += npc.position.Y + (float)npc.height - yAdjust; - npc.position.Y = yAdjust - (float)npc.height; - if (gfxOffRelativeToDelta < 9f) - { - npc.stepSpeed = 1f; - } - else - { - npc.stepSpeed = 2f; - } - } - } - } - } - - if (canOpenDoors) - { - int x = (int)((npc.Center.X + (float)(15 * npc.direction)) / 16f); - int y = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - if (npcType == NPCID.Clown || npcType == NPCID.BlackRecluse || npcType == NPCID.WallCreeper || npcType == NPCID.LihzahrdCrawler || npcType == NPCID.JungleCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.AnomuraFungus || npcType == NPCID.MushiLadybug || npcType == NPCID.Paladin || npcType == NPCID.Scutlix || npcType == NPCID.VortexRifleman || npcType == NPCID.VortexHornet || npcType == NPCID.VortexHornetQueen || npcType == NPCID.WalkingAntlion || npcType == NPCID.SolarDrakomire || npcType == NPCID.DesertScorpionWalk || npcType == NPCID.DesertBeast) - { - x = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 16) * npc.direction)) / 16f); - } - if ((Main.tile[x, y - 1].HasUnactuatedTile && - (Main.tile[x, y - 1].TileType == TileID.ClosedDoor || - Main.tile[x, y - 1].TileType == TileID.TallGateClosed)) & reset) - { - npc.ai[2] += 1f; - npc.ai[3] = 0f; - if (npc.ai[2] >= 60f) - { - npc.velocity.X = -0.5f * npc.direction; - int timerIncrement = 5; - if (Main.tile[x, y - 1].TileType == TileID.TallGateClosed) - { - timerIncrement = 2; - } - npc.ai[1] += timerIncrement; - // Special increments - if (npcType == NPCID.GoblinThief) - { - npc.ai[1] += 1f; - } - if (npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet) - { - npc.ai[1] += 6f; - } - npc.ai[2] = 0f; - bool readyToOpenDoor = false; - if (npc.ai[1] >= 10f) - { - readyToOpenDoor = true; - npc.ai[1] = 10f; - } - if (npcType == NPCID.Butcher) - { - readyToOpenDoor = true; - } - WorldGen.KillTile(x, y - 1, true, false, false); - if ((Main.netMode != NetmodeID.MultiplayerClient || !readyToOpenDoor) && readyToOpenDoor && Main.netMode != NetmodeID.MultiplayerClient) - { - if (npcType == NPCID.GoblinPeon) - { - WorldGen.KillTile(x, y - 1, false, false, false); - if (Main.dedServ) - { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)x, (float)(y - 1), 0f, 0, 0, 0); - } - } - else - { - if (Main.tile[x, y - 1].TileType == TileID.ClosedDoor) - { - bool canOpenDoor = WorldGen.OpenDoor(x, y - 1, npc.direction); - if (!canOpenDoor) - { - npc.ai[3] = (float)aiGateValue; - npc.netUpdate = true; - } - if (Main.dedServ & canOpenDoor) - { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)x, (float)(y - 1), (float)npc.direction, 0, 0, 0); - } - } - if (Main.tile[x, y - 1].TileType == TileID.TallGateClosed) - { - bool canOpenTallGate = WorldGen.ShiftTallGate(x, y - 1, false); - if (!canOpenTallGate) - { - npc.ai[3] = (float)aiGateValue; - npc.netUpdate = true; - } - if (Main.dedServ & canOpenTallGate) - { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)x, (float)(y - 1), 0f, 0, 0, 0); - } - } - } - } - } - } - else - { - int alteredDirection = npc.spriteDirection; - if (npcType == NPCID.VortexRifleman) - { - alteredDirection *= -1; - } - if ((npc.velocity.X < 0f && alteredDirection == -1) || (npc.velocity.X > 0f && alteredDirection == 1)) - { - if (npc.height >= 32 && Main.tile[x, y - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y - 2].TileType]) - { - if (Main.tile[x, y - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y - 3].TileType]) - { - npc.velocity.Y = -9f; - npc.netUpdate = true; - } - else - { - npc.velocity.Y = -8f; - npc.netUpdate = true; - } - } - else if (Main.tile[x, y - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y - 1].TileType]) - { - npc.velocity.Y = -7f; - npc.netUpdate = true; - } - else if (npc.position.Y + (float)npc.height - (float)(y * 16) > 20f && Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType]) - { - npc.velocity.Y = -6f; - npc.netUpdate = true; - } - else if (npc.directionY < 0 && npcType != 67 && (!Main.tile[x, y + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y + 1].TileType]) && (!Main.tile[x + npc.direction, y + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x + npc.direction, y + 1].TileType])) - { - npc.velocity.Y = -9f; - npc.velocity.X *= 2f; - npc.netUpdate = true; - } - else if (reset) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - if ((npc.velocity.Y == 0f & jump) && npc.ai[3] == 1f) - { - npc.velocity.Y = -6f; - } - } - if ((npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.CorruptBunny || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.Werewolf || npcType == NPCID.CorruptPenguin || npcType == NPCID.Nymph || npcType == NPCID.GrayGrunt || npcType == NPCID.GigaZapper || npcType == NPCID.CrimsonBunny || npcType == NPCID.CrimsonPenguin || (npcType >= 524 && npcType <= 527)) && npc.velocity.Y == 0f && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 100f && Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f))) - { - npc.velocity.X *= 3f; - if (npc.velocity.X > 4f) - { - npc.velocity.X = 4f; - } - if (npc.velocity.X < -4f) - { - npc.velocity.X = -4f; - } - npc.velocity.Y = -5f; - npc.netUpdate = true; - } - if ((npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType()) && npc.velocity.Y < 0f) - { - npc.velocity.Y *= 1.1f; - } - if (npcType == NPCID.BoneLee && npc.velocity.Y == 0f && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 150f && Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f))) - { - npc.velocity.X = (float)((CalamityWorld.death ? 9 : CalamityWorld.revenge ? 8 : 7) * npc.direction); - npc.velocity.Y = -(CalamityWorld.death ? 4f : CalamityWorld.revenge ? 3.5f : 3f); - npc.netUpdate = true; - } - if (npcType == NPCID.BoneLee && npc.velocity.Y < 0f) - { - npc.velocity.X *= CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1.15f : 1.1f; - npc.velocity.Y *= CalamityWorld.death ? 1.1f : CalamityWorld.revenge ? 1.075f : 1.05f; - } - if (npcType == NPCID.Butcher && npc.velocity.Y < 0f) - { - npc.velocity.X *= 1.35f; - npc.velocity.Y *= 1.15f; - } - } - } - else if (reset) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - - // Teleport (Chaos elementals) - if (Main.netMode != NetmodeID.MultiplayerClient && (npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType()) && npc.ai[3] >= (float)aiGateValue) - { - int targetTileX = (int)Main.player[npc.target].Center.X / 16; - int targetTileY = (int)Main.player[npc.target].Center.Y / 16; - Vector2 chosenTile = Vector2.Zero; - if (npc.AI_AttemptToFindTeleportSpot(ref chosenTile, targetTileX, targetTileY, 20, 9)) - { - npc.position.X = chosenTile.X * 16f - (float)(npc.width / 2); - npc.position.Y = chosenTile.Y * 16f - (float)npc.height; - npc.ai[3] = -30f; - npc.netUpdate = true; - } - } - return false; - } - #endregion - - #region Flying AI - public static bool BuffedFlyingAI(NPC npc, Mod mod) - { - if (npc.target < 0 || npc.target <= Main.maxPlayers || Main.player[npc.target].dead) - npc.TargetClosest(); - - if (npc.type == NPCID.BloodSquid) - { - if (Main.dayTime) - { - npc.velocity.Y -= 0.3f; - npc.EncourageDespawn(60); - } - - npc.position += npc.netOffset; - if (npc.alpha == 255) - { - npc.spriteDirection = npc.direction; - npc.velocity.Y = -6f; - for (int i = 0; i < 35; i++) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Blood); - dust.velocity *= 1f; - dust.scale = 1f + Main.rand.NextFloat() * 0.5f; - dust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust.velocity += npc.velocity * 0.5f; - } - } - - npc.alpha -= 15; - if (npc.alpha < 0) - npc.alpha = 0; - - if (npc.alpha != 0) - { - for (int j = 0; j < 2; j++) - { - Dust eyeFishDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Blood); - eyeFishDust.velocity *= 1f; - eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; - eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - eyeFishDust.velocity += npc.velocity * 0.3f; - } - } - - npc.position -= npc.netOffset; - } - - NPCAimedTarget targetData = npc.GetTargetData(); - bool targetDead = false; - if (targetData.Type == NPCTargetType.Player) - targetDead = Main.player[npc.target].dead; - - bool queenBeeHornet = npc.type == NPCID.HornetHoney && npc.ai[3] == 1f; - if (queenBeeHornet) - { - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - if (npc.localAI[1] != 0f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.localAI[1] = 0f; - npc.localAI[2] = 0f; - npc.SyncVanillaLocalAI(); - } - } - else if (npc.localAI[1] == 0f) - npc.localAI[2]++; - - if (npc.localAI[2] >= (CalamityWorld.death ? 60f : 120f)) - { - npc.localAI[1] = 1f; - npc.localAI[2] = 0f; - npc.SyncVanillaLocalAI(); - } - - if (npc.localAI[1] == 0f) - { - npc.alpha = 0; - npc.noTileCollide = false; - } - else - { - npc.wet = false; - npc.alpha = 200; - npc.noTileCollide = true; - } - } - - bool deathModeVelocityBuff = true; - float maxVelocity = 6f; - float acceleration = 0.05f; - if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Crimera) - { - maxVelocity = 4f; - acceleration = 0.035f; - } - else if (npc.type == NPCID.Corruptor) - { - maxVelocity = 4.2f; - acceleration = 0.022f; - } - else if (npc.type == NPCID.BloodSquid) - { - maxVelocity = 6f; - acceleration = 0.1f; - } - else if (npc.type == NPCID.Hornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) - { - maxVelocity = 3.5f; - acceleration = 0.021f; - if (npc.type == NPCID.HornetFatty) - { - maxVelocity = 3f; - acceleration = 0.017f; - } - - maxVelocity *= 1f - npc.scale; - acceleration *= 1f - npc.scale; - - // Despawn - if ((double)(npc.position.Y / 16f) < Main.worldSurface && !queenBeeHornet) - { - if (Main.player[npc.target].position.Y - npc.position.Y > 300f && npc.velocity.Y < 0f) - npc.velocity.Y *= 0.97f; - - if (Main.player[npc.target].position.Y - npc.position.Y < 80f && npc.velocity.Y > 0f) - npc.velocity.Y *= 0.97f; - } - - // Master Mode Queen Bee Hornets - if (queenBeeHornet) - { - maxVelocity *= 1.4f; - acceleration *= 1.8f; - maxVelocity += npc.ai[2] * 1.5f; - acceleration += npc.ai[2] * 0.01f; - } - } - else if (npc.type == NPCID.MossHornet) - { - maxVelocity = 4f; - acceleration = 0.017f; - } - else if (npc.type == NPCID.Parrot) - { - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - maxVelocity = 6f; - acceleration = 0.1f; - } - else - { - acceleration = 0.01f; - maxVelocity = 2f; - } - } - else if (npc.type == NPCID.Moth) - { - maxVelocity = 7f; - acceleration = 0.06f; - } - else if (npc.type == NPCID.MeteorHead) - { - maxVelocity = 2f; - acceleration = 0.05f; - } - else if (npc.type == NPCID.ServantofCthulhu) - { - maxVelocity = 5f + npc.ai[2] * 2f; - acceleration = 0.03f + npc.ai[2] * 0.03f; - } - else if (npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) - { - bool notQueenBeeBee = npc.ai[3] == 0f; - if (notQueenBeeBee) - { - npc.ai[1] += 1f; - float originalFlyAwayTime = 60f; - float flyAwayTime = CalamityWorld.death ? 30f : 40f; - float originalFlyAwayVelocity = 6f; - float flyAwayDistance = originalFlyAwayTime * originalFlyAwayVelocity; - float flyAwayVelocity = flyAwayDistance / flyAwayTime; - float flyAwayAccel = (npc.ai[1] - flyAwayTime) / flyAwayTime; - if (flyAwayAccel > 1f) - { - flyAwayAccel = 1f; - } - else - { - if (npc.velocity.X > flyAwayVelocity) - npc.velocity.X = flyAwayVelocity; - - if (npc.velocity.X < -flyAwayVelocity) - npc.velocity.X = -flyAwayVelocity; - - if (npc.velocity.Y > flyAwayVelocity) - npc.velocity.Y = flyAwayVelocity; - - if (npc.velocity.Y < -flyAwayVelocity) - npc.velocity.Y = -flyAwayVelocity; - } - - maxVelocity = 5f; - acceleration = 0.1f * flyAwayAccel; - } - else - { - deathModeVelocityBuff = false; - maxVelocity = 5f + npc.ai[2] * 2f; - acceleration = 0.1f + npc.ai[2] * 0.04f; - } - } - - if (CalamityWorld.revenge) - { - maxVelocity *= 1.25f; - acceleration *= 1.25f; - } - - if (CalamityWorld.death && deathModeVelocityBuff) - { - maxVelocity *= 1.25f; - acceleration *= 1.25f; - } - - if (queenBeeHornet) - { - float deceleration = 1f - acceleration; - if (targetDead) - { - Vector2 destination = npc.Center - Vector2.UnitY; - Vector2 idealVelocity = npc.SafeDirectionTo(destination) * maxVelocity * 0.5f; - idealVelocity.X *= npc.direction; - idealVelocity.Y *= 2.5f; - npc.SimpleFlyMovement(idealVelocity, acceleration); - npc.EncourageDespawn(10); - npc.wet = false; - npc.noTileCollide = true; - } - else if (npc.Distance(targetData.Center) > 400f) - { - Vector2 idealVelocity = npc.SafeDirectionTo(targetData.Center) * maxVelocity; - npc.SimpleFlyMovement(idealVelocity, acceleration); - } - else - { - if (npc.Distance(targetData.Center) < 160f) - { - Vector2 idealVelocity = npc.SafeDirectionTo(targetData.Center) * maxVelocity; - npc.SimpleFlyMovement(-idealVelocity, acceleration); - } - else - npc.velocity *= deceleration; - } - - if (targetData.Center.X - npc.Center.X > 0f) - npc.spriteDirection = -1; - else - npc.spriteDirection = 1; - - npc.rotation = npc.velocity.X * 0.1f; - - float reboundSpeed = 0.7f; - if (npc.collideX) - { - npc.netUpdate = true; - npc.velocity.X = npc.oldVelocity.X * -reboundSpeed; - if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - npc.velocity.X = 2f; - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - npc.velocity.X = -2f; - } - - if (npc.collideY) - { - npc.netUpdate = true; - npc.velocity.Y = npc.oldVelocity.Y * -reboundSpeed; - if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5) - npc.velocity.Y = 2f; - if (npc.velocity.Y < 0f && (double)npc.velocity.Y > -1.5) - npc.velocity.Y = -2f; - } - } - else - { - Vector2 vector = npc.Center; - float targetXDist = Main.player[npc.target].Center.X; - float targetYDist = Main.player[npc.target].Center.Y; - targetXDist = (float)((int)(targetXDist / 8f) * 8); - targetYDist = (float)((int)(targetYDist / 8f) * 8); - vector.X = (float)((int)(vector.X / 8f) * 8); - vector.Y = (float)((int)(vector.Y / 8f) * 8); - targetXDist -= vector.X; - targetYDist -= vector.Y; - float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - float targetDistCheck = targetDistance; - - if (targetDistance == 0f) - { - targetXDist = npc.velocity.X; - targetYDist = npc.velocity.Y; - } - else - { - targetDistance = maxVelocity / targetDistance; - targetXDist *= targetDistance; - targetYDist *= targetDistance; - } - - if (npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy) || npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.Moth || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid) - { - if (targetDistCheck > 100f || npc.type == NPCID.Corruptor || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) - { - npc.ai[0] += 1f; - if (npc.ai[0] > 0f) - npc.velocity.Y += CalamityWorld.revenge ? 0.03f : 0.023f; - else - npc.velocity.Y -= CalamityWorld.revenge ? 0.03f : 0.023f; - - if (npc.ai[0] < -100f || npc.ai[0] > 100f) - npc.velocity.X += CalamityWorld.revenge ? 0.03f : 0.023f; - else - npc.velocity.X -= CalamityWorld.revenge ? 0.03f : 0.023f; - - if (npc.ai[0] > 200f) - npc.ai[0] = -200f; - } - - if (targetDistCheck < 150f && (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid)) - { - npc.velocity.X += targetXDist * (CalamityWorld.revenge ? 0.009f : 0.007f); - npc.velocity.Y += targetYDist * (CalamityWorld.revenge ? 0.009f : 0.007f); - } - - // Master Mode Queen Bee Bees - if (npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) - { - if (npc.ai[3] == 1f) - { - float pushVelocity = 0.5f + npc.ai[2] * 0.2f; - 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) < 32f * 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; - } - } - } - } - } - } - } - - if (targetDead) - { - targetXDist = (float)npc.direction * maxVelocity / 2f; - targetYDist = -maxVelocity / 2f; - } - - if (npc.velocity.X < targetXDist) - { - npc.velocity.X += acceleration; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.BloodSquid && npc.velocity.X < 0f && targetXDist > 0f) - npc.velocity.X += acceleration; - } - else if (npc.velocity.X > targetXDist) - { - npc.velocity.X -= acceleration; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.BloodSquid && npc.velocity.X > 0f && targetXDist < 0f) - npc.velocity.X -= acceleration; - } - - if (npc.velocity.Y < targetYDist) - { - npc.velocity.Y += acceleration; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.BloodSquid && npc.velocity.Y < 0f && targetYDist > 0f) - npc.velocity.Y += acceleration; - } - else if (npc.velocity.Y > targetYDist) - { - npc.velocity.Y -= acceleration; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.BloodSquid && npc.velocity.Y > 0f && targetYDist < 0f) - npc.velocity.Y -= acceleration; - } - - if (npc.type == NPCID.ServantofCthulhu) - { - float pushVelocity = 0.5f + npc.ai[2] * 0.25f; - 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; - } - } - } - } - } - - if (npc.type == NPCID.MeteorHead) - { - if (targetXDist > 0f) - { - npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); - } - else if (targetXDist < 0f) - { - npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + MathHelper.Pi; - } - } - else if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid) - { - npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) - MathHelper.PiOver2; - } - else if (npc.type == NPCID.Moth || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) - { - if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - - npc.rotation = npc.velocity.X * 0.1f; - } - else - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) - MathHelper.PiOver2; - - if (npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy) || npc.type == NPCID.EaterofSouls || npc.type == NPCID.MeteorHead || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.Moth || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid) - { - float reboundSpeed = 0.7f; - if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Crimera) - reboundSpeed = 0.4f; - - if (npc.collideX) - { - npc.netUpdate = true; - npc.velocity.X = npc.oldVelocity.X * -reboundSpeed; - if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - npc.velocity.X = 2f; - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - npc.velocity.X = -2f; - } - - if (npc.collideY) - { - npc.netUpdate = true; - npc.velocity.Y = npc.oldVelocity.Y * -reboundSpeed; - if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5) - npc.velocity.Y = 2f; - if (npc.velocity.Y < 0f && (double)npc.velocity.Y > -1.5) - npc.velocity.Y = -2f; - } - - if (npc.type == NPCID.BloodSquid) - { - int bloodDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100); - Main.dust[bloodDust].velocity *= 0.5f; - } - else if (npc.type == NPCID.MeteorHead) - { - int meteorDust = Dust.NewDust(new Vector2(npc.position.X - npc.velocity.X, npc.position.Y - npc.velocity.Y), npc.width, npc.height, DustID.Torch, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Dust dust = Main.dust[meteorDust]; - dust.noGravity = true; - dust.velocity.X *= 0.3f; - dust.velocity.Y *= 0.3f; - } - else if (npc.type != NPCID.Moth && npc.type != NPCID.Parrot && npc.type != NPCID.Bee && npc.type != NPCID.BeeSmall && Main.rand.NextBool(20)) - { - int dustType = 18; - if (npc.type == NPCID.Crimera) - dustType = 5; - - int idleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), dustType, npc.velocity.X, 2f, 75, npc.color, npc.scale); - Dust dust = Main.dust[idleDust]; - dust.velocity.X *= 0.5f; - dust.velocity.Y *= 0.1f; - } - } - else if (npc.type != NPCID.Parrot && Main.rand.NextBool(40)) - { - int otherIdleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), DustID.Blood, npc.velocity.X, 2f, 0, default(Color), 1f); - Dust dust = Main.dust[otherIdleDust]; - dust.velocity.X *= 0.5f; - dust.velocity.Y *= 0.1f; - } - - if ((npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid) && npc.wet) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.Y -= CalamityWorld.revenge ? 0.4f : 0.3f; - if (npc.velocity.Y < -(CalamityWorld.revenge ? 3f : 2f)) - npc.velocity.Y = -(CalamityWorld.revenge ? 3f : 2f); - } - - if (npc.type == NPCID.Moth && npc.wet) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.Y -= 0.7f; - if (npc.velocity.Y < -6f) - npc.velocity.Y = -6f; - - npc.TargetClosest(); - } - } - - if (npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) - { - if (npc.wet) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.Y -= 0.5f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - - npc.TargetClosest(); - } - - if (npc.ai[1] == 301f) - { - SoundEngine.PlaySound(SoundID.Item17, npc.Center); - npc.ai[1] = 0f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] += ((npc.type == NPCID.MossHornet || queenBeeHornet) ? 2f : 1f) + npc.ai[2]; - if (npc.justHit && !queenBeeHornet) - npc.ai[1] = 0f; - - if (npc.ai[1] >= 240f) - { - if (targetData.Type != 0 && Collision.CanHit(npc, targetData)) - { - float projSpeed = (CalamityWorld.death || Main.hardMode) ? 5f : 8f; - projSpeed += npc.ai[2] * ((CalamityWorld.death || Main.hardMode) ? 2f : 4f); - if (queenBeeHornet) - projSpeed += 2f; - - Vector2 projSpawnPosition = npc.Center; - float projTargetXDist = targetData.Center.X - projSpawnPosition.X; - float projTargetYDist = targetData.Center.Y - projSpawnPosition.Y; - if ((projTargetXDist < 0f && npc.velocity.X < 0f) || (projTargetXDist > 0f && npc.velocity.X > 0f)) - { - float projTargetDistance = (float)Math.Sqrt(projTargetXDist * projTargetXDist + projTargetYDist * projTargetYDist); - projTargetDistance = projSpeed / projTargetDistance; - projTargetXDist *= projTargetDistance; - projTargetYDist *= projTargetDistance; - - // Master Mode Queen Bee Hornets deal increased damage - int projDamage = (int)((queenBeeHornet ? 15f : 10f) * npc.scale); - if (npc.type == NPCID.MossHornet) - projDamage = (int)(30f * npc.scale); - - int stingerType = ProjectileID.Stinger; - int stingerSpawn = Projectile.NewProjectile(npc.GetSource_FromAI(), projSpawnPosition.X, projSpawnPosition.Y, projTargetXDist, projTargetYDist, stingerType, projDamage, 0f, Main.myPlayer); - Main.projectile[stingerSpawn].timeLeft = (CalamityWorld.death || Main.hardMode) ? 600 : 300; - Main.projectile[stingerSpawn].extraUpdates += (CalamityWorld.death || Main.hardMode) ? 1 : 0; - npc.ai[1] = 301f; - npc.netUpdate = true; - } - else - npc.ai[1] = 0f; - } - else - npc.ai[1] = 0f; - } - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient && !targetDead) - { - if (Main.getGoodWorld && npc.type == NPCID.EaterofSouls) - { - if (NPC.AnyNPCs(NPCID.EaterofWorldsHead)) - { - if (npc.justHit) - npc.localAI[0] = 0f; - - npc.localAI[0] += 1f; - if (npc.localAI[0] == 60f) - { - if (targetData.Type != 0 && Collision.CanHit(npc, targetData)) - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2) + npc.velocity.X), (int)(npc.position.Y + (float)(npc.height / 2) + npc.velocity.Y), NPCID.VileSpitEaterOfWorlds); - - npc.localAI[0] = 0f; - } - } - } - - if (npc.type == NPCID.Corruptor) - { - if (npc.justHit || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.localAI[0] = 0f; - - npc.localAI[0] += 1f; - if (npc.localAI[0] == CorruptorVileSpitGateValue) - { - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2) + npc.velocity.X), (int)(npc.position.Y + (float)(npc.height / 2) + npc.velocity.Y), NPCID.VileSpit); - - npc.localAI[0] = 0f; - } - - if (npc.localAI[0] > CorruptorVileSpitGateValue - CorruptorVileSpitTelegraphTime) - { - Vector2 dustCenter = npc.Center + npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 25f + Main.rand.NextVector2CircularEdge(3f, 3f); - Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, 18, npc.velocity.X * 0.1f, npc.velocity.Y * 0.1f, 80, default, 1.3f); - dust.noGravity = true; - dust.velocity *= 0.3f; - } - } - - if (npc.type == NPCID.BloodSquid) - { - if (npc.justHit || targetData.Type == 0 || !Collision.CanHit(npc, targetData)) - npc.localAI[0] = 0f; - - npc.localAI[0] += 1f; - if (npc.localAI[0] >= BloodSquidBloodShotGateValue) - { - if (targetData.Type != 0 && Collision.CanHit(npc, targetData)) - { - if ((npc.Center - targetData.Center).Length() < 400f) - { - Vector2 bloodShotPosition = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); - npc.velocity = -bloodShotPosition * 5f; - npc.netUpdate = true; - npc.localAI[0] = 0f; - bloodShotPosition = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, bloodShotPosition * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer); - if (CalamityWorld.death) - { - Main.projectile[proj].extraUpdates += 1; - Main.projectile[proj].timeLeft = 1200; - } - } - else - npc.localAI[0] = 0f; - } - else - npc.localAI[0] = 0f; - } - - if (npc.localAI[0] > BloodSquidBloodShotGateValue - BloodSquidBloodShotTelegraphTime) - { - Vector2 dustCenter = npc.Center + npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 25f + Main.rand.NextVector2CircularEdge(5f, 5f); - Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, DustID.Blood, 0f, 0f, 100, default, 3f); - dust.fadeIn = 1.7f; - dust.noGravity = true; - dust.velocity *= 0f; - } - } - } - - if (!queenBeeHornet) - { - if ((Main.dayTime && npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.MeteorHead && npc.type != NPCID.Bee && npc.type != NPCID.BeeSmall && npc.type != NPCID.Corruptor && npc.type != NPCID.Moth && npc.type != NPCID.Parrot && npc.type != NPCID.BloodSquid) || Main.player[npc.target].dead) - { - npc.velocity.Y -= acceleration * 2f; - if (npc.timeLeft > 10) - npc.timeLeft = 10; - } - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - npc.netUpdate = true; - - return false; - } - #endregion - - #region Worm AI - public static bool BuffedWormAI(NPC npc, Mod mod) - { - if (npc.type == NPCID.LeechHead && npc.localAI[1] == 0f) - { - npc.localAI[1] = 1f; - SoundEngine.PlaySound(SoundID.NPCDeath13, npc.Center); - int dustVelocity = 1; - if (npc.velocity.X < 0f) - { - dustVelocity = -1; - } - for (int i = 0; i < 20; i++) - { - Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y - 20f), npc.width + 40, npc.height + 40, DustID.Blood, (float)(dustVelocity * 8), -1f, 0, default(Color), 1f); - } - } - - if (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail) - { - npc.position += npc.netOffset; - npc.dontTakeDamage = (npc.alpha > 0); - if (npc.type == NPCID.BloodEelHead || (npc.type != NPCID.BloodEelHead && Main.npc[(int)npc.ai[1]].alpha < 85)) - { - if (npc.dontTakeDamage) - { - for (int k = 0; k < 2; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, 0f, 0f, 100); - } - } - - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - if (npc.alpha == 0 && Main.rand.NextBool(5)) - Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, 0f, 0f, 100); - - npc.position -= npc.netOffset; - } - else if (npc.type == NPCID.StardustWormHead && npc.ai[1] == 0f) - { - npc.ai[1] = Main.rand.Next(-2, 0); - npc.netUpdate = true; - } - - bool wormHead = npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || (!Main.player[npc.target].ZoneUndergroundDesert && npc.type == NPCID.TombCrawlerHead); - float acceleration = npc.type == NPCID.TombCrawlerHead ? 0.1f : 0.2f; - - bool isSplittingNPC = (npc.type >= NPCID.DiggerHead && npc.type <= NPCID.DiggerTail) || (npc.type >= NPCID.SeekerHead && npc.type <= NPCID.SeekerTail) || (npc.type >= NPCID.DuneSplicerHead && npc.type <= NPCID.DuneSplicerTail); - - bool isSplittingNPCHead = npc.type == NPCID.DiggerHead || npc.type == NPCID.SeekerHead || npc.type == NPCID.DuneSplicerHead; - - bool isSplittingNPCBody = npc.type == NPCID.DiggerBody || npc.type == NPCID.SeekerBody || npc.type == NPCID.DuneSplicerBody; - - bool isSplittingNPCTail = npc.type == NPCID.DiggerTail || npc.type == NPCID.SeekerTail || npc.type == NPCID.DuneSplicerTail; - - if (isSplittingNPC) - { - npc.realLife = -1; - } - else - { - npc.defense = (int)Math.Round(npc.defDefense * 1.3); - - if (npc.ai[3] > 0f) - npc.realLife = (int)npc.ai[3]; - } - - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || (wormHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) - { - npc.TargetClosest(true); - } - - if (Main.player[npc.target].dead || (wormHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) - { - if (npc.timeLeft > 300) - { - npc.timeLeft = 300; - } - if (wormHead) - { - npc.velocity.Y = npc.velocity.Y + acceleration; - } - } - - if (npc.type == NPCID.BloodEelHead && Main.dayTime) - { - npc.EncourageDespawn(60); - npc.velocity.Y += 1f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.type == NPCID.WyvernHead && npc.ai[0] == 0f) - { - int maxParts = CalamityWorld.death ? 30 : 21; - npc.ai[3] = (float)npc.whoAmI; - npc.realLife = npc.whoAmI; - int currentNPC = npc.whoAmI; - for (int k = 0; k < maxParts; k++) - { - int wyvernSegmentType = NPCID.WyvernBody; - if (k == 1 || k == 12) - { - wyvernSegmentType = NPCID.WyvernLegs; - } - else if (k == maxParts - 3) - { - wyvernSegmentType = NPCID.WyvernBody2; - } - else if (k == maxParts - 2) - { - wyvernSegmentType = NPCID.WyvernBody3; - } - else if (k == maxParts - 1) - { - wyvernSegmentType = NPCID.WyvernTail; - } - int wyvernSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), wyvernSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[wyvernSegment].ai[3] = (float)npc.whoAmI; - Main.npc[wyvernSegment].realLife = npc.whoAmI; - Main.npc[wyvernSegment].ai[1] = (float)currentNPC; - Main.npc[currentNPC].ai[0] = (float)wyvernSegment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, wyvernSegment, 0f, 0f, 0f, 0, 0, 0); - currentNPC = wyvernSegment; - } - } - - if (npc.type == NPCID.TombCrawlerHead && npc.ai[0] == 0f) - { - npc.ai[3] = (float)npc.whoAmI; - npc.realLife = npc.whoAmI; - int currentTombCrawler = npc.whoAmI; - int tombCrawlerSegments = Main.rand.Next(11, CalamityWorld.death ? 25 : 15); - for (int m = 0; m < tombCrawlerSegments; m++) - { - int tombCrawlerSegmentType = NPCID.TombCrawlerBody; - if (m == tombCrawlerSegments - 1) - { - tombCrawlerSegmentType = NPCID.TombCrawlerTail; - } - int tombCrawlerSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), tombCrawlerSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[tombCrawlerSegment].ai[3] = (float)npc.whoAmI; - Main.npc[tombCrawlerSegment].realLife = npc.whoAmI; - Main.npc[tombCrawlerSegment].ai[1] = (float)currentTombCrawler; - Main.npc[currentTombCrawler].ai[0] = (float)tombCrawlerSegment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, tombCrawlerSegment, 0f, 0f, 0f, 0, 0, 0); - currentTombCrawler = tombCrawlerSegment; - } - } - - if (npc.type == NPCID.SolarCrawltipedeHead && npc.ai[0] == 0f) - { - npc.ai[3] = (float)npc.whoAmI; - npc.realLife = npc.whoAmI; - int projTargetDistance = npc.whoAmI; - int crawltipedeSegments = CalamityWorld.death ? 70 : 50; - for (int n = 0; n < crawltipedeSegments; n++) - { - int crawltipedeSegmentType = NPCID.SolarCrawltipedeBody; - if (n == crawltipedeSegments - 1) - { - crawltipedeSegmentType = NPCID.SolarCrawltipedeTail; - } - int crawltipedeSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), crawltipedeSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[crawltipedeSegment].ai[3] = (float)npc.whoAmI; - Main.npc[crawltipedeSegment].realLife = npc.whoAmI; - Main.npc[crawltipedeSegment].ai[1] = (float)projTargetDistance; - Main.npc[projTargetDistance].ai[0] = (float)crawltipedeSegment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, crawltipedeSegment, 0f, 0f, 0f, 0, 0, 0); - projTargetDistance = crawltipedeSegment; - } - } - - if (npc.type == NPCID.BloodEelHead && npc.ai[0] == 0f) - { - npc.ai[3] = npc.whoAmI; - npc.realLife = npc.whoAmI; - int bloodEelSegment = 0; - int currentBloodEel = npc.whoAmI; - int bloodEelSegments = CalamityWorld.death ? 44 : 34; - for (int p = 0; p < bloodEelSegments; p++) - { - int bloodEelSegmentType = NPCID.BloodEelBody; - if (p == bloodEelSegments - 1) - bloodEelSegmentType = NPCID.BloodEelTail; - - bloodEelSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), bloodEelSegmentType, npc.whoAmI); - Main.npc[bloodEelSegment].ai[3] = npc.whoAmI; - Main.npc[bloodEelSegment].realLife = npc.whoAmI; - Main.npc[bloodEelSegment].ai[1] = currentBloodEel; - Main.npc[bloodEelSegment].CopyInteractions(npc); - Main.npc[currentBloodEel].ai[0] = bloodEelSegment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, bloodEelSegment); - currentBloodEel = bloodEelSegment; - } - } - else if ((isSplittingNPCHead || isSplittingNPCBody || npc.type == NPCID.GiantWormHead || npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerHead || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechHead || npc.type == NPCID.LeechBody) && npc.ai[0] == 0f) - { - if (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead) - { - if (!isSplittingNPCHead) - { - npc.ai[3] = (float)npc.whoAmI; - npc.realLife = npc.whoAmI; - } - - switch (npc.type) - { - case NPCID.DevourerHead: - npc.ai[2] = (float)Main.rand.Next(13, CalamityWorld.death ? 30 : 19); - break; - case NPCID.GiantWormHead: - npc.ai[2] = (float)Main.rand.Next(25, CalamityWorld.death ? 50 : 31); - break; - case NPCID.BoneSerpentHead: - npc.ai[2] = (float)Main.rand.Next(16, CalamityWorld.death ? 33 : 23); - break; - case NPCID.DiggerHead: - npc.ai[2] = (float)Main.rand.Next(12, CalamityWorld.death ? 27 : 18); - break; - case NPCID.SeekerHead: - npc.ai[2] = (float)Main.rand.Next(27, CalamityWorld.death ? 45 : 33); - break; - case NPCID.LeechHead: - npc.ai[2] = (float)Main.rand.Next(CalamityWorld.death ? 3 : 5, CalamityWorld.death ? 5 : 8); - break; - case NPCID.DuneSplicerHead: - npc.ai[2] = (float)Main.rand.Next(15, CalamityWorld.death ? 35 : 24); - break; - } - - npc.ai[0] = (float)NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - } - else if ((isSplittingNPCBody || npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechBody) && npc.ai[2] > 0f) - { - npc.ai[0] = (float)NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - } - else - { - npc.ai[0] = (float)NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - } - - if (!isSplittingNPC) - { - Main.npc[(int)npc.ai[0]].ai[3] = npc.ai[3]; - Main.npc[(int)npc.ai[0]].realLife = npc.realLife; - } - Main.npc[(int)npc.ai[0]].ai[1] = (float)npc.whoAmI; - Main.npc[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f; - npc.netUpdate = true; - } - - if (!isSplittingNPC) - { - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - } - if (npc.ai[0] > 0f && npc.ai[0] < (float)Main.npc.Length) - { - if (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - } - } - else - { - if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (isSplittingNPCHead && !Main.npc[(int)npc.ai[0]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (isSplittingNPCTail && !Main.npc[(int)npc.ai[1]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - if (isSplittingNPCBody && (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle)) - { - npc.type = npc.type - 1; - int whoAmI = npc.whoAmI; - float currentHealthAmt = (float)npc.life / (float)npc.lifeMax; - float newSegment = npc.ai[0]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * currentHealthAmt); - npc.ai[0] = newSegment; - npc.TargetClosest(true); - npc.netUpdate = true; - npc.whoAmI = whoAmI; - } - if (isSplittingNPCBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle)) - { - int whoAmI2 = npc.whoAmI; - float currentHealthAmt2 = (float)npc.life / (float)npc.lifeMax; - float newSegment = npc.ai[1]; - npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * currentHealthAmt2); - npc.ai[1] = newSegment; - npc.TargetClosest(true); - npc.netUpdate = true; - npc.whoAmI = whoAmI2; - } - } - - if (!npc.active && Main.dedServ) - { - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - } - - int tilePositionX = (int)(npc.position.X / 16f) - 1; - int tileWidthPosX = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int tilePositionY = (int)(npc.position.Y / 16f) - 1; - int tileWidthPosY = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (tilePositionX < 0) - { - tilePositionX = 0; - } - if (tileWidthPosX > Main.maxTilesX) - { - tileWidthPosX = Main.maxTilesX; - } - if (tilePositionY < 0) - { - tilePositionY = 0; - } - if (tileWidthPosY > Main.maxTilesY) - { - tileWidthPosY = Main.maxTilesY; - } - - bool flying = false; - if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) - { - flying = true; - } - if (npc.type == NPCID.StardustWormHead && npc.ai[1] == -1f) - { - flying = true; - } - if (npc.type >= NPCID.SolarCrawltipedeHead && npc.type <= NPCID.SolarCrawltipedeTail) - { - flying = true; - } - if (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail) - { - flying = true; - } - if (!flying) - { - for (int x = tilePositionX; x < tileWidthPosX; x++) - { - for (int y = tilePositionY; y < tileWidthPosY; y++) - { - if (Main.tile[x, y] != null && ((Main.tile[x, y].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[x, y].TileType] || (Main.tileSolidTop[(int)Main.tile[x, y].TileType] && Main.tile[x, y].TileFrameY == 0))) || Main.tile[x, y].LiquidAmount > 64)) - { - Vector2 flyingPos; - flyingPos.X = (float)(x * 16); - flyingPos.Y = (float)(y * 16); - if (npc.position.X + (float)npc.width > flyingPos.X && npc.position.X < flyingPos.X + 16f && npc.position.Y + (float)npc.height > flyingPos.Y && npc.position.Y < flyingPos.Y + 16f) - { - flying = true; - if (Main.rand.NextBool(100) && npc.type != NPCID.LeechHead && Main.tile[x, y].HasUnactuatedTile) - { - WorldGen.KillTile(x, y, true, true, false); - } - } - } - } - } - } - - if (!flying && (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead || npc.type == NPCID.TombCrawlerHead)) - { - Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int noFlyZone = 1000; - bool outsideNoFlyZone = true; - for (int f = 0; f < Main.maxPlayers; f++) - { - if (Main.player[f].active) - { - Rectangle rectangle2 = new Rectangle((int)Main.player[f].position.X - noFlyZone, (int)Main.player[f].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); - if (rectangle.Intersects(rectangle2)) - { - outsideNoFlyZone = false; - break; - } - } - } - if (outsideNoFlyZone) - { - flying = true; - } - } - - if ((npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) || (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail)) - { - if (npc.velocity.X < 0f) - { - npc.spriteDirection = 1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = -1; - } - } - - if (npc.type == NPCID.SolarCrawltipedeTail) - { - if (npc.justHit) - { - npc.localAI[3] = 3f; - } - if (npc.localAI[2] > 0f) - { - npc.localAI[2] -= 16f; - if (npc.localAI[2] == 0f) - { - npc.localAI[2] = -128f; - } - } - else if (npc.localAI[2] < 0f) - { - npc.localAI[2] += 16f; - } - else if (npc.localAI[3] > 0f) - { - npc.localAI[2] = 128f; - npc.localAI[3] -= 1f; - } - } - - if (npc.type == NPCID.SolarCrawltipedeHead) - { - Vector2 crawltipedeDustPos = npc.Center + (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 8f; - Vector2 crawltipedeDustRotation = npc.rotation.ToRotationVector2() * 16f; - Dust crawltipedeDust = Main.dust[Dust.NewDust(crawltipedeDustPos + crawltipedeDustRotation, 0, 0, DustID.Torch, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; - crawltipedeDust.noGravity = true; - crawltipedeDust.noLight = true; - crawltipedeDust.position -= new Vector2(4f); - crawltipedeDust.fadeIn = 1f; - crawltipedeDust.velocity = Vector2.Zero; - Dust crawltipedeDust2 = Main.dust[Dust.NewDust(crawltipedeDustPos - crawltipedeDustRotation, 0, 0, DustID.Torch, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; - crawltipedeDust2.noGravity = true; - crawltipedeDust2.noLight = true; - crawltipedeDust2.position -= new Vector2(4f); - crawltipedeDust2.fadeIn = 1f; - crawltipedeDust2.velocity = Vector2.Zero; - } - - float wormSpeed = 10f; - float wormAccel = 0.09f; - if (npc.type == NPCID.DiggerHead) - { - wormSpeed = 6.5f; - wormAccel = 0.05f; - } - if (npc.type == NPCID.GiantWormHead) - { - wormSpeed = 7.5f; - wormAccel = 0.06f; - } - if (npc.type == NPCID.TombCrawlerHead) - { - wormSpeed = 8f; - wormAccel = 0.13f; - } - if (npc.type == NPCID.DuneSplicerHead) - { - if (!Main.player[npc.target].dead && Main.player[npc.target].ZoneSandstorm) - { - wormSpeed = 16f; - wormAccel = 0.35f; - } - else - { - wormAccel = 0.25f; - } - } - if (npc.type == NPCID.WyvernHead) - { - wormSpeed = 11f; - wormAccel = 0.3f; - } - if (npc.type == NPCID.StardustWormHead) - { - wormSpeed = 9f; - wormAccel = 0.25f; - } - if (npc.type == NPCID.LeechHead && Main.wofNPCIndex >= 0) - { - float lifeRatio = (float)Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; - if (lifeRatio < 0.75f) - { - wormSpeed += 1f; - wormAccel += 0.1f; - } - if (lifeRatio < 0.5f) - { - wormSpeed += 1f; - wormAccel += 0.1f; - } - if (lifeRatio < 0.25f) - { - wormSpeed += 2f; - wormAccel += 0.1f; - } - } - if (npc.type == NPCID.BloodEelHead) - { - wormSpeed = 18f; - wormAccel = 0.6f; - } - - if (CalamityWorld.death) - { - wormSpeed *= 1.25f; - wormAccel *= 1.25f; - } - - Vector2 segmentPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float wormTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float wormTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - - if (npc.type == NPCID.SolarCrawltipedeHead) - { - wormSpeed = 12f; - wormAccel = 0.32f; - int crawltipedeTargetY = -1; - int targetTileX = (int)(Main.player[npc.target].Center.X / 16f); - int targetTileY = (int)(Main.player[npc.target].Center.Y / 16f); - for (int i = targetTileX - 2; i <= targetTileX + 2; i++) - { - for (int j = targetTileY; j <= targetTileY + 15; j++) - { - if (WorldGen.SolidTile2(i, j)) - { - crawltipedeTargetY = j; - break; - } - } - if (crawltipedeTargetY > 0) - { - break; - } - } - if (crawltipedeTargetY > 0) - { - crawltipedeTargetY *= 16; - float crawltipedeYTarget = (float)(crawltipedeTargetY - 800); - if (Main.player[npc.target].position.Y > crawltipedeYTarget) - { - wormTargetY = crawltipedeYTarget; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 500f) - { - if (npc.velocity.X > 0f) - { - wormTargetX = Main.player[npc.target].Center.X + 600f; - } - else - { - wormTargetX = Main.player[npc.target].Center.X - 600f; - } - } - } - } - else - { - wormSpeed = 28f; - wormAccel = 0.8f; - } - float maxWormSpeed = wormSpeed * 1.3f; - float minWormSpeed = wormSpeed * 0.7f; - float velocityCheck = npc.velocity.Length(); - if (velocityCheck > 0f) - { - if (velocityCheck > maxWormSpeed) - { - npc.velocity.Normalize(); - npc.velocity *= maxWormSpeed; - } - else if (velocityCheck < minWormSpeed) - { - npc.velocity.Normalize(); - npc.velocity *= minWormSpeed; - } - } - if (crawltipedeTargetY > 0) - { - for (int k = 0; k < Main.maxNPCs; k++) - { - if (Main.npc[k].active && Main.npc[k].type == npc.type && k != npc.whoAmI) - { - Vector2 targetDirection = Main.npc[k].Center - npc.Center; - if (targetDirection.Length() < 400f) - { - targetDirection.Normalize(); - targetDirection *= 1000f; - wormTargetX -= targetDirection.X; - wormTargetY -= targetDirection.Y; - } - } - } - } - else - { - for (int l = 0; l < Main.maxNPCs; l++) - { - if (Main.npc[l].active && Main.npc[l].type == npc.type && l != npc.whoAmI) - { - Vector2 idleDirection = Main.npc[l].Center - npc.Center; - if (idleDirection.Length() < 60f) - { - idleDirection.Normalize(); - idleDirection *= 200f; - wormTargetX -= idleDirection.X; - wormTargetY -= idleDirection.Y; - } - } - } - } - } - - wormTargetX = (float)((int)(wormTargetX / 16f) * 16); - wormTargetY = (float)((int)(wormTargetY / 16f) * 16); - segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); - segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); - wormTargetX -= segmentPosition.X; - wormTargetY -= segmentPosition.Y; - float wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); - - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - try - { - segmentPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - wormTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - segmentPosition.X; - wormTargetY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - segmentPosition.Y; - } - catch - { - } - npc.rotation = (float)Math.Atan2((double)wormTargetY, (double)wormTargetX) + MathHelper.PiOver2; - wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); - int segmentWidth = npc.width; - if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) - { - segmentWidth = 42; - } - if (npc.type >= NPCID.SolarCrawltipedeHead && npc.type <= NPCID.SolarCrawltipedeTail) - { - segmentWidth += 6; - } - if (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail) - { - segmentWidth = 24; - } - wormTargetDist = (wormTargetDist - (float)segmentWidth) / wormTargetDist; - wormTargetX *= wormTargetDist; - wormTargetY *= wormTargetDist; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + wormTargetX; - npc.position.Y = npc.position.Y + wormTargetY; - if ((npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) || (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail)) - { - if (wormTargetX < 0f) - { - npc.spriteDirection = 1; - } - else if (wormTargetX > 0f) - { - npc.spriteDirection = -1; - } - } - } - else - { - if (!flying) - { - npc.TargetClosest(true); - npc.velocity.Y = npc.velocity.Y + 0.11f; - if (npc.velocity.Y > wormSpeed) - { - npc.velocity.Y = wormSpeed; - } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.4) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X - wormAccel * 1.1f; - } - else - { - npc.velocity.X = npc.velocity.X + wormAccel * 1.1f; - } - } - else if (npc.velocity.Y == wormSpeed) - { - if (npc.velocity.X < wormTargetX) - { - npc.velocity.X = npc.velocity.X + wormAccel; - } - else if (npc.velocity.X > wormTargetX) - { - npc.velocity.X = npc.velocity.X - wormAccel; - } - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X + wormAccel * 0.9f; - } - else - { - npc.velocity.X = npc.velocity.X - wormAccel * 0.9f; - } - } - } - else - { - if (npc.type != NPCID.WyvernHead && npc.type != NPCID.LeechHead && npc.type != NPCID.SolarCrawltipedeHead && npc.type != NPCID.BloodEelHead && npc.soundDelay == 0) - { - float soundDelay = wormTargetDist / 40f; - if (soundDelay < 10f) - { - soundDelay = 10f; - } - if (soundDelay > 20f) - { - soundDelay = 20f; - } - npc.soundDelay = (int)soundDelay; - SoundEngine.PlaySound(SoundID.WormDig, npc.Center); - } - - wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); - float absoluteTargetX = Math.Abs(wormTargetX); - float absoluteTargetY = Math.Abs(wormTargetY); - float timeToReachTarget = wormSpeed / wormTargetDist; - wormTargetX *= timeToReachTarget; - wormTargetY *= timeToReachTarget; - - bool wormShouldFlee = false; - if (npc.type == NPCID.DevourerHead && ((!Main.player[npc.target].ZoneCorrupt && !Main.player[npc.target].ZoneCrimson) || Main.player[npc.target].dead)) - { - wormShouldFlee = true; - } - if ((npc.type == NPCID.TombCrawlerHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 && !Main.player[npc.target].ZoneSandstorm && !Main.player[npc.target].ZoneUndergroundDesert) || Main.player[npc.target].dead) - { - wormShouldFlee = true; - } - if ((npc.type == NPCID.DuneSplicerHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 && !Main.player[npc.target].ZoneSandstorm && !Main.player[npc.target].ZoneUndergroundDesert) || Main.player[npc.target].dead) - { - wormShouldFlee = true; - } - if (wormShouldFlee) - { - bool definitelyFlee = true; - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && !Main.player[p].dead && Main.player[p].ZoneCorrupt) - { - definitelyFlee = false; - } - } - if (definitelyFlee) - { - if (Main.netMode != NetmodeID.MultiplayerClient && (double)(npc.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0) - { - npc.active = false; - int q = (int)npc.ai[0]; - while (q > 0 && q < Main.maxNPCs && Main.npc[q].active && Main.npc[q].aiStyle == npc.aiStyle) - { - int differentSegment = (int)Main.npc[q].ai[0]; - Main.npc[q].active = false; - npc.life = 0; - if (Main.dedServ) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, q, 0f, 0f, 0f, 0, 0, 0); - } - q = differentSegment; - } - if (Main.dedServ) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); - } - } - wormTargetX = 0f; - wormTargetY = wormSpeed; - } - } - - bool shouldSwoopDown = false; - if (npc.type == NPCID.WyvernHead) - { - if (((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f) || (npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > wormAccel / 2f && wormTargetDist < 300f) - { - shouldSwoopDown = true; - - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < wormSpeed) - npc.velocity *= 1.1f; - } - if (npc.position.Y > Main.player[npc.target].position.Y || (double)(Main.player[npc.target].position.Y / 16f) > Main.worldSurface || Main.player[npc.target].dead) - { - shouldSwoopDown = true; - - if (Math.Abs(npc.velocity.X) < wormSpeed / 2f) - { - if (npc.velocity.X == 0f) - npc.velocity.X = npc.velocity.X - npc.direction; - - npc.velocity.X = npc.velocity.X * 1.1f; - } - else if (npc.velocity.Y > -wormSpeed) - npc.velocity.Y = npc.velocity.Y - wormAccel; - } - } - - if (npc.type == NPCID.BloodEelHead) - { - if (((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f) || (npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > wormAccel / 2f && wormTargetDist < 120f) - { - shouldSwoopDown = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < wormSpeed) - npc.velocity *= 1.1f; - } - if (npc.position.Y > Main.player[npc.target].position.Y || Main.player[npc.target].dead) - { - shouldSwoopDown = true; - if (Math.Abs(npc.velocity.X) < wormSpeed / 2f) - { - if (npc.velocity.X == 0f) - npc.velocity.X -= npc.direction; - - npc.velocity.X *= 1.1f; - } - else if (npc.velocity.Y > 0f - wormSpeed) - npc.velocity.Y -= wormAccel; - } - } - - if (!shouldSwoopDown) - { - if ((npc.velocity.X > 0f && wormTargetX > 0f) || (npc.velocity.X < 0f && wormTargetX < 0f) || (npc.velocity.Y > 0f && wormTargetY > 0f) || (npc.velocity.Y < 0f && wormTargetY < 0f)) - { - if (npc.velocity.X < wormTargetX) - npc.velocity.X = npc.velocity.X + wormAccel; - else if (npc.velocity.X > wormTargetX) - npc.velocity.X = npc.velocity.X - wormAccel; - - if (npc.velocity.Y < wormTargetY) - npc.velocity.Y = npc.velocity.Y + wormAccel; - else if (npc.velocity.Y > wormTargetY) - npc.velocity.Y = npc.velocity.Y - wormAccel; - - if ((double)Math.Abs(wormTargetY) < (double)wormSpeed * 0.2 && ((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + wormAccel * 2f; - else - npc.velocity.Y = npc.velocity.Y - wormAccel * 2f; - } - - if ((double)Math.Abs(wormTargetX) < (double)wormSpeed * 0.2 && ((npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + wormAccel * 2f; - else - npc.velocity.X = npc.velocity.X - wormAccel * 2f; - } - } - else if (absoluteTargetX > absoluteTargetY) - { - if (npc.velocity.X < wormTargetX) - npc.velocity.X = npc.velocity.X + wormAccel * 1.1f; - else if (npc.velocity.X > wormTargetX) - npc.velocity.X = npc.velocity.X - wormAccel * 1.1f; - - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + wormAccel; - else - npc.velocity.Y = npc.velocity.Y - wormAccel; - } - } - else - { - if (npc.velocity.Y < wormTargetY) - npc.velocity.Y = npc.velocity.Y + wormAccel * 1.1f; - else if (npc.velocity.Y > wormTargetY) - npc.velocity.Y = npc.velocity.Y - wormAccel * 1.1f; - - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + wormAccel; - else - npc.velocity.X = npc.velocity.X - wormAccel; - } - } - } - } - - npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + MathHelper.PiOver2; - if (npc.type == NPCID.DevourerHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.SeekerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || npc.type == NPCID.TombCrawlerHead) - { - if (flying) - { - if (npc.localAI[0] != 1f) - npc.netUpdate = true; - - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - npc.netUpdate = true; - - npc.localAI[0] = 0f; - } - - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - { - npc.netUpdate = true; - } - } - } - return false; - } - #endregion - - #region Caster AI - public static bool BuffedCasterAI(NPC npc, Mod mod) - { - npc.TargetClosest(); - npc.velocity.X *= 0.93f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - npc.velocity.X = 0f; - - if (npc.ai[0] == 0f) - npc.ai[0] = 500f; - - if (npc.type == NPCID.RuneWizard) - { - if (npc.alpha < 255) - npc.alpha++; - if (npc.justHit) - npc.alpha = 0; - } - - if (npc.ai[2] != 0f && npc.ai[3] != 0f) - { - if (npc.type == NPCID.RuneWizard) - npc.alpha = 255; - - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - - for (int i = 0; i < 50; i++) - { - if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) - { - int goblinDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); - Dust dust = Main.dust[goblinDust]; - dust.velocity *= 3f; - if (Main.dust[goblinDust].scale > 1f) - Main.dust[goblinDust].noGravity = true; - } - else if (npc.type == NPCID.DarkCaster) - { - int darkCasterDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.DungeonWater, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[darkCasterDust]; - dust.velocity *= 3f; - Main.dust[darkCasterDust].noGravity = true; - } - else if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) - { - int necromancerDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.ShadowbeamStaff, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[necromancerDust]; - dust.velocity *= 2f; - Main.dust[necromancerDust].scale = 1.4f; - } - else if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) - { - int diabolistDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.InfernoFork, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[diabolistDust]; - dust.velocity *= 3f; - Main.dust[diabolistDust].noGravity = true; - } - else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) - { - int raggedCasterDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.SpectreStaff, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[raggedCasterDust]; - dust.velocity *= 3f; - Main.dust[raggedCasterDust].noGravity = true; - } - else if (npc.type == NPCID.RuneWizard) - { - int runeWizardDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.RuneWizard, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[runeWizardDust]; - dust.velocity *= 3f; - Main.dust[runeWizardDust].noGravity = true; - } - else if (npc.type == NPCID.DesertDjinn) - { - int desertSpiritDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[desertSpiritDust]; - dust.velocity *= 3f; - Main.dust[desertSpiritDust].noGravity = true; - } - else - { - int fireImpDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[fireImpDust]; - dust.velocity *= 3f; - Main.dust[fireImpDust].noGravity = true; - } - } - - npc.position.X = npc.ai[2] * 16f - (float)(npc.width / 2) + 8f; - npc.position.Y = npc.ai[3] * 16f - (float)npc.height; - - npc.velocity.X = 0f; - npc.velocity.Y = 0f; - - npc.ai[2] = 0f; - npc.ai[3] = 0f; - - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - - for (int j = 0; j < 50; j++) - { - if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) - { - int goblinCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); - Dust dust = Main.dust[goblinCastDust]; - dust.velocity *= 3f; - if (Main.dust[goblinCastDust].scale > 1f) - Main.dust[goblinCastDust].noGravity = true; - } - else if (npc.type == NPCID.DarkCaster) - { - int darkCasterCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.DungeonWater, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[darkCasterCastDust]; - dust.velocity *= 3f; - Main.dust[darkCasterCastDust].noGravity = true; - } - else if (npc.type == NPCID.RuneWizard) - { - int runeWizardCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.RuneWizard, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[runeWizardCastDust]; - dust.velocity *= 3f; - Main.dust[runeWizardCastDust].noGravity = true; - } - else if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) - { - int necromancerCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.ShadowbeamStaff, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[necromancerCastDust]; - dust.velocity *= 2f; - Main.dust[necromancerCastDust].scale = 1.4f; - } - else if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) - { - int diabolistCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.InfernoFork, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[diabolistCastDust]; - dust.velocity *= 3f; - Main.dust[diabolistCastDust].noGravity = true; - } - else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) - { - int raggedCasterCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.SpectreStaff, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[raggedCasterCastDust]; - dust.velocity *= 3f; - Main.dust[raggedCasterCastDust].noGravity = true; - } - else if (npc.type == NPCID.DesertDjinn) - { - int desertSpiritCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[desertSpiritCastDust]; - dust.velocity *= 3f; - Main.dust[desertSpiritCastDust].noGravity = true; - } - else - { - int fireImpCastDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[fireImpCastDust]; - dust.velocity *= 3f; - Main.dust[fireImpCastDust].noGravity = true; - } - } - } - - if (npc.justHit) - npc.ai[0] = (npc.type == NPCID.RuneWizard && Main.zenithWorld) ? 5f : CalamityWorld.revenge ? 2f : 1f; - - npc.ai[0] += (npc.type == NPCID.RuneWizard && Main.zenithWorld) ? 5f : CalamityWorld.revenge ? 2f : 1f; - - if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) - { - if (npc.ai[0] % 50f == 0f && npc.ai[0] <= 250f) - { - npc.ai[1] = 55f; - npc.netUpdate = true; - } - - if (npc.ai[0] >= 400f) - npc.ai[0] = 700f; - } - else if (npc.type == NPCID.RuneWizard) - { - if (npc.ai[0] == 80f || npc.ai[0] == 150f || npc.ai[0] == 230f || npc.ai[0] == 300f || npc.ai[0] == 380f || npc.ai[0] == 450f) - { - npc.ai[1] = 55f; - npc.netUpdate = true; - } - } - else if (npc.type == NPCID.DesertDjinn) - { - if (npc.ai[0] == 180f) - { - npc.ai[1] = 181f; - npc.netUpdate = true; - } - } - else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) - { - if (npc.ai[0] == 20f || npc.ai[0] == 40f || npc.ai[0] == 60f || npc.ai[0] == 120f || npc.ai[0] == 140f || npc.ai[0] == 160f || npc.ai[0] == 220f || npc.ai[0] == 240f || npc.ai[0] == 260f) - { - npc.ai[1] = 55f; - npc.netUpdate = true; - } - - if (npc.ai[0] >= 460f) - npc.ai[0] = 700f; - } - else - { - if (Main.getGoodWorld && npc.type == NPCID.FireImp) - { - if (NPC.AnyNPCs(NPCID.WallofFlesh)) - { - npc.ai[0] += 1f; - if (npc.ai[0] % 2f == 1f) - npc.ai[0] -= 1f; - } - } - - if (npc.ai[0] % 100f == 0f && npc.ai[0] <= 300f) - { - npc.ai[1] = 55f; - npc.netUpdate = true; - } - } - - if ((npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) && npc.ai[0] > 400f) - npc.ai[0] = 650f; - - if (npc.type == NPCID.DesertDjinn && npc.ai[0] >= 360f) - npc.ai[0] = 650f; - - if (npc.ai[0] >= 650f && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = CalamityWorld.revenge ? 2f : 1f; - int targetTileX = (int)Main.player[npc.target].position.X / 16; - int targetTileY = (int)Main.player[npc.target].position.Y / 16; - Vector2 chosenTile = Vector2.Zero; - if (npc.AI_AttemptToFindTeleportSpot(ref chosenTile, targetTileX, targetTileY)) - { - npc.ai[1] = 20f; - npc.ai[2] = chosenTile.X; - npc.ai[3] = chosenTile.Y; - } - - npc.netUpdate = true; - } - - if (npc.ai[1] > 0f) - { - npc.ai[1] -= 1f; - if (npc.type == NPCID.DesertDjinn) - { - if (npc.ai[1] % 30f == 0f && npc.ai[1] / 30f < 5f) - { - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Point spiritCenter = npc.Center.ToTileCoordinates(); - Point targetCenter = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; - int randProjRadius = 6; - int spiritSpawnRadius = 6; - int targetSpawnRadius = 0; - int solidTileCheckRadius = 2; - int projSpawnTries = 0; - bool targetTooFar = false; - if (targetDirection.Length() > 2000f) - targetTooFar = true; - - while (!targetTooFar) - { - if (projSpawnTries >= 50) - break; - - projSpawnTries++; - int spiritProjSpawnX = Main.rand.Next(targetCenter.X - randProjRadius, targetCenter.X + randProjRadius + 1); - int spiritProjSpawnY = Main.rand.Next(targetCenter.Y - randProjRadius, targetCenter.Y + randProjRadius + 1); - if ((spiritProjSpawnY < targetCenter.Y - targetSpawnRadius || spiritProjSpawnY > targetCenter.Y + targetSpawnRadius || spiritProjSpawnX < targetCenter.X - targetSpawnRadius || spiritProjSpawnX > targetCenter.X + targetSpawnRadius) && (spiritProjSpawnY < spiritCenter.Y - spiritSpawnRadius || spiritProjSpawnY > spiritCenter.Y + spiritSpawnRadius || spiritProjSpawnX < spiritCenter.X - spiritSpawnRadius || spiritProjSpawnX > spiritCenter.X + spiritSpawnRadius) && !Main.tile[spiritProjSpawnX, spiritProjSpawnY].HasUnactuatedTile) - { - bool canSpawnProj = true; - if (canSpawnProj && Main.tile[spiritProjSpawnX, spiritProjSpawnY].LiquidType == LiquidID.Lava) - canSpawnProj = false; - if (canSpawnProj && Collision.SolidTiles(spiritProjSpawnX - solidTileCheckRadius, spiritProjSpawnX + solidTileCheckRadius, spiritProjSpawnY - solidTileCheckRadius, spiritProjSpawnY + solidTileCheckRadius)) - canSpawnProj = false; - - if (canSpawnProj) - { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), (float)(spiritProjSpawnX * 16 + 8), (float)(spiritProjSpawnY * 16 + 8), 0f, 0f, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)npc.target, 0f); - if (CalamityWorld.death) - Main.projectile[proj].extraUpdates += 1; - - break; - } - } - } - } - } - } - else if (npc.ai[1] == 25f) - { - if (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float dungeonCasterProjSpeed = CalamityWorld.death ? 8f : 6f; - if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) - dungeonCasterProjSpeed = CalamityWorld.death ? 10f : 8f; - if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) - dungeonCasterProjSpeed = CalamityWorld.death ? 5f : 4f; - - Vector2 dungeonCasterPos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y); - float dungeonCasterTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - dungeonCasterPos.X; - float dungeonCasterTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - dungeonCasterPos.Y; - float dungeonCasterTargetDist = (float)Math.Sqrt((double)(dungeonCasterTargetX * dungeonCasterTargetX + dungeonCasterTargetY * dungeonCasterTargetY)); - dungeonCasterTargetDist = dungeonCasterProjSpeed / dungeonCasterTargetDist; - dungeonCasterTargetX *= dungeonCasterTargetDist; - dungeonCasterTargetY *= dungeonCasterTargetDist; - - int damage = 16; - int projType = ProjectileID.ShadowBeamHostile; - if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) - { - projType = ProjectileID.InfernoHostileBolt; - damage = 32; - } - if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) - { - projType = ProjectileID.LostSoulHostile; - damage = 32; - } - - int dungeonCasterProj = Projectile.NewProjectile(npc.GetSource_FromAI(), dungeonCasterPos.X, dungeonCasterPos.Y, dungeonCasterTargetX, dungeonCasterTargetY, projType, damage, 0f, Main.myPlayer); - Main.projectile[dungeonCasterProj].timeLeft = 300; - if (projType == ProjectileID.InfernoHostileBolt) - { - Main.projectile[dungeonCasterProj].ai[0] = Main.player[npc.target].Center.X; - Main.projectile[dungeonCasterProj].ai[1] = Main.player[npc.target].Center.Y; - Main.projectile[dungeonCasterProj].netUpdate = true; - } - - npc.localAI[0] = 0f; - } - } - else - { - if (npc.type != NPCID.RuneWizard) - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X + npc.width / 2, (int)npc.position.Y - 8, NPCID.ChaosBall); - } - else if (npc.type == NPCID.DarkCaster) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X + npc.width / 2, (int)npc.position.Y - 8, NPCID.WaterSphere); - } - else if (npc.type == NPCID.RuneWizard) - { - float runeWizardProjSpeed = CalamityWorld.death ? 12f : 10f; - Vector2 vector14 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float runeWizardTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector14.X; - float runeWizardTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector14.Y; - float runeWizardTargetDist = (float)Math.Sqrt((double)(runeWizardTargetX * runeWizardTargetX + runeWizardTargetY * runeWizardTargetY)); - runeWizardTargetDist = runeWizardProjSpeed / runeWizardTargetDist; - runeWizardTargetX *= runeWizardTargetDist; - runeWizardTargetY *= runeWizardTargetDist; - int runeWizardProj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector14.X, vector14.Y, runeWizardTargetX, runeWizardTargetY, ProjectileID.RuneBlast, 40, 0f, Main.myPlayer); - Main.projectile[runeWizardProj].timeLeft = 300; - npc.localAI[0] = 0f; - } - else - NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.position.X + npc.width / 2 + npc.direction * 8, (int)npc.position.Y + 20, NPCID.BurningSphere); - } - } - } - } - - if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) - { - if (Main.rand.NextBool(5)) - { - int shadowflameSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.Shadowflame, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.5f); - Dust dust = Main.dust[shadowflameSpawnDust]; - dust.noGravity = true; - dust.velocity.X *= 0.5f; - dust.velocity.Y = -2f; - } - } - else if (npc.type == NPCID.DarkCaster) - { - if (!Main.rand.NextBool(3)) - { - int waterSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.DungeonWater, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.9f); - Dust dust = Main.dust[waterSpawnDust]; - dust.noGravity = true; - dust.velocity.X *= 0.3f; - dust.velocity.Y *= 0.2f; - dust.velocity.Y -= 1f; - } - } - else - { - if (npc.type == NPCID.RuneWizard) - { - int runeWizardDustAmt = 1; - if (npc.alpha == 255) - runeWizardDustAmt = 2; - - for (int r = 0; r < runeWizardDustAmt; r++) - { - if (Main.rand.Next(255) > 255 - npc.alpha) - { - int runeSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.RuneWizard, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.2f); - Dust dust = Main.dust[runeSpawnDust]; - dust.noGravity = true; - dust.velocity.X *= (0.1f + (float)Main.rand.Next(30) * 0.01f); - dust.velocity.Y *= (0.1f + (float)Main.rand.Next(30) * 0.01f); - dust.scale *= 1f + (float)Main.rand.Next(6) * 0.1f; - } - } - - return false; - } - - if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) - { - if (Main.rand.NextBool()) - { - int necroSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.ShadowbeamStaff, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[necroSpawnDust]; - dust.velocity.X *= 0.5f; - dust.velocity.Y *= 0.5f; - } - } - else if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) - { - if (Main.rand.NextBool()) - { - int flameSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.InfernoFork, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1f); - Dust dust = Main.dust[flameSpawnDust]; - dust.noGravity = true; - dust.velocity *= 0.4f; - dust.velocity.Y -= 0.7f; - return false; - } - } - else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) - { - if (Main.rand.NextBool()) - { - int ghostSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.SpectreStaff, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.1f); - Dust dust = Main.dust[ghostSpawnDust]; - dust.noGravity = true; - dust.velocity *= 0.5f; - dust.fadeIn = 1.2f; - } - } - else - { - if (npc.type == NPCID.DesertDjinn) - { - Lighting.AddLight(npc.Top, 0.6f, 0.6f, 0.3f); - return false; - } - - if (Main.rand.NextBool()) - { - int desertSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, DustID.Torch, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Dust dust = Main.dust[desertSpawnDust]; - dust.noGravity = true; - dust.velocity.X *= 1f; - dust.velocity.Y *= 1f; - } - } - } - - return false; - } - #endregion - - #region Plant AI - public static bool BuffedPlantAI(NPC npc, Mod mod) - { - if (npc.ai[0] < 0f || npc.ai[0] >= (float)Main.maxTilesX || npc.ai[1] < 0f || npc.ai[1] >= (float)Main.maxTilesX) - return false; - - if (!Main.tile[(int)npc.ai[0], (int)npc.ai[1]].HasTile) - { - npc.life = -1; - npc.HitEffect(0, 10.0); - npc.active = false; - return false; - } - - FixExploitManEaters.ProtectSpot((int)npc.ai[0], (int)npc.ai[1]); - - npc.TargetClosest(); - - float acceleration = 0.035f; - float minDistance = 250f; - switch (npc.type) - { - case NPCID.ManEater: - minDistance = 350f; - break; - case NPCID.Clinger: - minDistance = 225f; - break; - case NPCID.FungiBulb: - minDistance = !CalamityWorld.revenge ? 100f : 200f; - break; - case NPCID.AngryTrapper: - acceleration = 0.05f; - minDistance = 500f; - break; - case NPCID.GiantFungiBulb: - acceleration = 0.15f; - minDistance = CalamityWorld.revenge ? 450f : 350f; - break; - } - - if (CalamityWorld.death) - { - acceleration *= 1.25f; - minDistance *= 1.25f; - } - - float maxVelocity = 2f + - (npc.type == NPCID.ManEater ? 1f : 0f) + - (npc.type == NPCID.AngryTrapper ? 2f : 0f); - - npc.ai[2] += 1f; - if (npc.ai[2] > 300f) - { - minDistance *= 1.3f; - - if (CalamityWorld.revenge) - maxVelocity += 2f; - - if (npc.ai[2] > 450f) - npc.ai[2] = 0f; - } - - Vector2 anchorPosition = new Vector2(npc.ai[0] * 16f + 8f, npc.ai[1] * 16f + 8f); - Vector2 distanceVector = Main.player[npc.target].Center - anchorPosition; - float distanceMagnitude = distanceVector.Length(); - if (distanceMagnitude > minDistance) - { - float normalizedMagnitude = minDistance / distanceMagnitude; - distanceVector *= normalizedMagnitude; - } - - if (npc.position.X < npc.ai[0] * 16f + 8f + distanceVector.X) - { - npc.velocity.X += acceleration; - if (npc.velocity.X < 0f && distanceVector.X > 0f) - npc.velocity.X += acceleration * 1.5f; - } - else if (npc.position.X > npc.ai[0] * 16f + 8f + distanceVector.X) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X > 0f && distanceVector.X < 0f) - npc.velocity.X -= acceleration * 1.5f; - } - if (npc.position.Y < npc.ai[1] * 16f + 8f + distanceVector.Y) - { - npc.velocity.Y += acceleration; - if (npc.velocity.Y < 0f && distanceVector.Y > 0f) - npc.velocity.Y += acceleration * 1.5f; - } - else if (npc.position.Y > npc.ai[1] * 16f + 8f + distanceVector.Y) - { - npc.velocity.Y -= acceleration; - if (npc.velocity.Y > 0f && distanceVector.Y < 0f) - npc.velocity.Y -= acceleration * 1.5f; - } - - npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-maxVelocity), new Vector2(maxVelocity)); - - if (npc.type == NPCID.FungiBulb || npc.type == NPCID.GiantFungiBulb) - { - npc.rotation = npc.AngleTo(Main.player[npc.target].Center) + MathHelper.PiOver2; - } - else - { - npc.spriteDirection = (distanceVector.X > 0f).ToDirectionInt(); - npc.rotation = npc.AngleTo(Main.player[npc.target].Center) + (distanceVector.X < 0f).ToInt() * MathHelper.Pi; - } - - if (npc.collideX) - { - npc.netUpdate = true; - npc.velocity.X = npc.oldVelocity.X * -0.7f; - if (npc.velocity.X > 0f && npc.velocity.X < 2f) - npc.velocity.X = 2f; - if (npc.velocity.X < 0f && npc.velocity.X > -2f) - npc.velocity.X = -2f; - } - if (npc.collideY) - { - npc.netUpdate = true; - npc.velocity.Y = npc.oldVelocity.Y * -0.7f; - if (npc.velocity.Y > 0f && npc.velocity.Y < 2f) - npc.velocity.Y = 2f; - if (npc.velocity.Y < 0f && npc.velocity.Y > -2f) - npc.velocity.Y = -2f; - } - - if ((npc.type == NPCID.GiantFungiBulb || npc.type == NPCID.FungiBulb) && !Main.player[npc.target].DeadOrGhost) - { - if (npc.localAI[0] > ((npc.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? GiantFungiBulbSporeShootGateValue_Rev : GiantFungiBulbSporeShootGateValue) : FungiBulbSporeShootGateValue) - FungiBulbSporeTelegraphTime)) - { - Vector2 dustCenter = npc.Center + npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * (npc.type == NPCID.GiantFungiBulb ? 20f : 12f) + Main.rand.NextVector2CircularEdge(5f, 5f); - Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, DustID.BlueTorch, 0f, 0f, 100, default, 3f); - dust.noGravity = true; - dust.velocity *= 0f; - } - - if (npc.localAI[0] == (npc.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? GiantFungiBulbSporeShootGateValue_Rev : GiantFungiBulbSporeShootGateValue) : FungiBulbSporeShootGateValue) - 1) - SoundEngine.PlaySound(SoundID.Item17, npc.Center); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.type == NPCID.Clinger && !Main.player[npc.target].DeadOrGhost) - { - if (npc.justHit) - npc.localAI[0] = 0f; - - npc.localAI[0] += 1f; - if (npc.localAI[0] >= ClingerShootGateValue_Rev) - { - if (!Collision.SolidCollision(npc.position, npc.width, npc.height) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - int damage = 17; - int type = ProjectileID.CursedFlameHostile; - Vector2 flameVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * 12f; - - int flame = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, flameVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[flame].timeLeft = 180; - npc.localAI[0] = 0f; - } - else - npc.localAI[0] = ClingerShootGateValue_Rev - 15f; - } - } - - if ((npc.type == NPCID.GiantFungiBulb || npc.type == NPCID.FungiBulb) && !Main.player[npc.target].DeadOrGhost) - { - if (npc.justHit || Collision.SolidCollision(npc.position, npc.width, npc.height) || !Collision.CanHit(npc, Main.player[npc.target])) - npc.localAI[0] = 0f; - - npc.localAI[0] += 1f; - float sporeSpawnGateValue = npc.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? GiantFungiBulbSporeShootGateValue_Rev : GiantFungiBulbSporeShootGateValue) : FungiBulbSporeShootGateValue; - if (npc.localAI[0] >= sporeSpawnGateValue) - { - if (!Collision.SolidCollision(npc.position, npc.width, npc.height) && Collision.CanHit(npc, Main.player[npc.target])) - { - float speed = npc.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? 16f : 14f) : 8f; - distanceVector.X = Main.player[npc.target].Center.X - npc.Center.X; - float absoluteYDistance = Math.Abs(distanceVector.X * 0.1f); - if (Main.player[npc.target].Center.Y - npc.Center.Y > 0f) - absoluteYDistance = 0f; - - Vector2 velocity = npc.SafeDirectionTo(Main.player[npc.target].Center - npc.Center - Vector2.UnitY * absoluteYDistance, -Vector2.UnitY) * speed; - - int idx = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.FungiSpore); - Main.npc[idx].velocity = velocity; - Main.npc[idx].netUpdate = true; - } - - npc.localAI[0] = 0f; - } - } - } - return false; - } - #endregion - - #region Bat AI - public static bool BuffedBatAI(NPC npc, Mod mod) - { - if (npc.type == NPCID.Hellbat || npc.type == NPCID.Lavabat) - { - int lavaDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Main.dust[lavaDust].noGravity = true; - } - - if (npc.type == NPCID.IceBat && Main.rand.NextBool(10)) - { - int iceDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.IceRod, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[iceDust].noGravity = true; - Dust dust = Main.dust[iceDust]; - dust.velocity *= 0.2f; - Main.dust[iceDust].noLight = true; - } - - npc.noGravity = true; - - // Collision on the X axis. - if (npc.collideX) - { - npc.velocity.X = npc.oldVelocity.X * -0.5f; - if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - npc.velocity.X = 2f; - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - npc.velocity.X = -2f; - } - - // Collision on Y axis. - if (npc.collideY) - { - npc.velocity.Y = npc.oldVelocity.Y * -0.5f; - if (npc.velocity.Y > 0f && npc.velocity.Y < 1f) - npc.velocity.Y = 1f; - if (npc.velocity.Y < 0f && npc.velocity.Y > -1f) - npc.velocity.Y = -1f; - } - - if (npc.type == NPCID.FlyingSnake) - { - int direction = 1; - int directionY = 1; - if (npc.velocity.X < 0f) - direction = -1; - if (npc.velocity.Y < 0f) - directionY = -1; - - npc.TargetClosest(); - - if (!Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.direction = direction; - npc.directionY = directionY; - } - } - else - npc.TargetClosest(); - - float maxSpeedX = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; - float maxSpeedY = CalamityWorld.death ? 2.5f : CalamityWorld.revenge ? 2f : 1.5f; - - float xAccel = CalamityWorld.revenge ? 0.12f : 0.1f; - float xAccelBoost1 = CalamityWorld.revenge ? 0.12f : 0.1f; - float xAccelBoost2 = CalamityWorld.revenge ? 0.06f : 0.04f; - - float yAccel = CalamityWorld.revenge ? 0.06f : 0.04f; - float yAccelBoost1 = CalamityWorld.revenge ? 0.07f : 0.05f; - float yAccelBoost2 = CalamityWorld.revenge ? 0.05f : 0.03f; - - if (npc.type == NPCID.VampireBat) - { - if (npc.position.Y < Main.worldSurface * 16.0 && Main.dayTime && !Main.eclipse) - { - npc.directionY = -1; - npc.direction *= -1; - } - - maxSpeedX = maxSpeedY = CalamityWorld.death ? 11f : 9f; - xAccel = yAccel = 0.3f; - xAccelBoost1 = yAccelBoost1 = 0.12f; - xAccelBoost2 = yAccelBoost2 = 0.07f; - } - else if (npc.type == NPCID.FlyingSnake) - { - maxSpeedX = CalamityWorld.death ? 9f : 6f; - maxSpeedY = CalamityWorld.death ? 5f : 3.5f; - - xAccel = 0.3f; - xAccelBoost1 = 0.12f; - xAccelBoost2 = 0.07f; - - yAccel = 0.12f; - yAccelBoost1 = 0.07f; - yAccelBoost2 = 0.05f; - } - - DemonEyeAI.DemonEyeBatMovement(npc, maxSpeedX, maxSpeedY, xAccel, xAccelBoost1, xAccelBoost2, yAccel, yAccelBoost1, yAccelBoost2); - - if (npc.type == NPCID.CaveBat || - npc.type == NPCID.JungleBat || - npc.type == NPCID.Hellbat || - npc.type == NPCID.Demon || - npc.type == NPCID.VoodooDemon || - npc.type == NPCID.GiantBat || - npc.type == NPCID.IlluminantBat || - npc.type == NPCID.IceBat || - npc.type == NPCID.Lavabat || - npc.type == NPCID.GiantFlyingFox || - npc.type == ModContent.NPCType()) - { - maxSpeedX = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; - maxSpeedY = CalamityWorld.death ? 2.5f : CalamityWorld.revenge ? 2f : 1.5f; - if (npc.wet) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.Y -= CalamityWorld.revenge ? 0.6f : 0.5f; - if (npc.velocity.Y < -5f) - npc.velocity.Y = -5f; - - npc.TargetClosest(); - } - - if (npc.type == NPCID.Hellbat) - { - xAccel = 0.12f; - xAccelBoost1 = 0.09f; - xAccelBoost2 = 0.05f; - - yAccel = 0.06f; - yAccelBoost1 = 0.05f; - yAccelBoost2 = 0.03f; - } - else - { - xAccel = CalamityWorld.revenge ? 0.12f : 0.1f; - xAccelBoost1 = CalamityWorld.revenge ? 0.12f : 0.1f; - xAccelBoost2 = CalamityWorld.revenge ? 0.07f : 0.05f; - - yAccel = CalamityWorld.revenge ? 0.06f : 0.04f; - yAccelBoost1 = CalamityWorld.revenge ? 0.07f : 0.05f; - yAccelBoost2 = CalamityWorld.revenge ? 0.05f : 0.03f; - } - - DemonEyeAI.DemonEyeBatMovement(npc, maxSpeedX, maxSpeedY, xAccel, xAccelBoost1, xAccelBoost2, yAccel, yAccelBoost1, yAccelBoost2); - } - - if (npc.type == NPCID.Harpy && npc.wet) - { - npc.ai[0] = 0f; - - if (npc.velocity.Y > 0f) - npc.velocity.Y *= 0.95f; - - npc.velocity.Y -= CalamityWorld.revenge ? 0.6f : 0.5f; - if (npc.velocity.Y < -5f) - npc.velocity.Y = -5f; - - npc.TargetClosest(); - } - - // Turn back into a walking bat when possible - if (npc.type == NPCID.VampireBat && Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.Distance(Main.player[npc.target].Center) < 200f && - npc.Center.Y < Main.player[npc.target].Center.Y && - Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.Transform(NPCID.Vampire); - } - } - - npc.ai[1] += CalamityWorld.revenge ? 2f : 1f; - if (npc.type == NPCID.VampireBat) - npc.ai[1] += 1f; - - if (npc.ai[1] > 200f) - { - if (!Main.player[npc.target].wet && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.ai[1] = 0f; - - xAccel = CalamityWorld.revenge ? 0.25f : 0.2f; - yAccel = CalamityWorld.revenge ? 0.12f : 0.1f; - - float maxVelocityX = CalamityWorld.revenge ? 4.6f : 4f; - float maxVelocityY = CalamityWorld.revenge ? 1.8f : 1.5f; - - if (npc.type == NPCID.Harpy || npc.type == NPCID.Demon || npc.type == NPCID.VoodooDemon) - { - xAccel = CalamityWorld.revenge ? 0.15f : 0.12f; - yAccel = CalamityWorld.revenge ? 0.1f : 0.07f; - maxVelocityX = CalamityWorld.revenge ? 3.5f : 3f; - maxVelocityY = CalamityWorld.revenge ? 1.5f : 1.25f; - } - - if (npc.ai[1] > 1000f) - npc.ai[1] = 0f; - - npc.ai[2] += 1f; - if (npc.ai[2] > 0f) - { - if (npc.velocity.Y < maxVelocityY) - npc.velocity.Y += yAccel; - } - else if (npc.velocity.Y > -maxVelocityY) - npc.velocity.Y -= yAccel; - - if (npc.ai[2] < -150f || npc.ai[2] > 150f) - { - if (npc.velocity.X < maxVelocityX) - npc.velocity.X += xAccel; - } - else if (npc.velocity.X > -maxVelocityX) - npc.velocity.X -= xAccel; - - if (npc.ai[2] > 300f) - npc.ai[2] = -300f; - } - - if (npc.type == NPCID.Harpy) - { - // Emit feather dust from center when about to shoot - if (npc.ai[0] > HarpyFeatherGateValue - HarpyFeatherTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.Center + Main.rand.NextVector2CircularEdge(5f, 5f), 1, 1, 172, 0f, 0f, 0, default, 1.5f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } - else if (npc.type == NPCID.Demon || npc.type == NPCID.VoodooDemon) - { - // Emit shadowflame dust from center when about to shoot - if (npc.ai[0] > DemonScytheGateValue - DemonScytheTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default, 3f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } - else if (npc.type == NPCID.RedDevil) - { - // Emit shadowflame dust from center when about to shoot - if (npc.ai[0] > RedDevilTridentGateValue - RedDevilTridentTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default, 3f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.type == NPCID.Harpy) - { - float featherShootCutOffValue = CalamityWorld.revenge ? 90f : 60f; - if (npc.justHit || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.ai[0] = featherShootCutOffValue + 1f; - - if (npc.ai[0] >= HarpyFeatherGateValue) - { - npc.ai[0] = 0f; - } - else if (npc.ai[0] % 30f == 0f && npc.ai[0] <= featherShootCutOffValue) - { - npc.ai[0] += 1f; - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - int damage = 15; - int type = ProjectileID.HarpyFeather; - Vector2 featherVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * (CalamityWorld.death ? 4f : 6f); - - int feather = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, featherVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[feather].timeLeft = 300; - if (CalamityWorld.death) - { - Main.projectile[feather].extraUpdates += 1; - Main.projectile[feather].timeLeft = 600; - } - } - } - else - npc.ai[0] += 1f; - } - - if (npc.type == NPCID.Demon || npc.type == NPCID.VoodooDemon) - { - float scytheShootCutOffValue = CalamityWorld.revenge ? 80f : 60f; - if (npc.justHit || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.ai[0] = scytheShootCutOffValue + 1f; - - if (npc.ai[0] >= DemonScytheGateValue) - { - npc.ai[0] = 0f; - } - else if (npc.ai[0] % 20f == 0f && npc.ai[0] <= scytheShootCutOffValue) - { - npc.ai[0] += 1f; - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - int damage = 21; - int type = ProjectileID.DemonSickle; - Vector2 sickleVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * (CalamityWorld.death ? 0.15f : 0.2f); - - int sickle = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, sickleVelocity, type, damage, 0f, Main.myPlayer); - Main.projectile[sickle].timeLeft = 300; - if (CalamityWorld.death) - { - Main.projectile[sickle].extraUpdates += 1; - Main.projectile[sickle].timeLeft = 600; - } - } - } - else - npc.ai[0] += 1f; - } - - if (npc.type == NPCID.RedDevil) - { - float tridentShootCutOffValue = 80f; - if (npc.justHit || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.ai[0] = tridentShootCutOffValue + 1f; - - if (npc.ai[0] >= RedDevilTridentGateValue) - { - npc.ai[0] = 0f; - } - else if (npc.ai[0] % 20f == 0f && npc.ai[0] <= tridentShootCutOffValue) - { - npc.ai[0] += 1f; - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - Vector2 spawnPosition = npc.Center; - - float tridentSpeed = CalamityWorld.death ? 0.15f : 0.2f; - Vector2 tridentVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * tridentSpeed; - spawnPosition += npc.velocity * 5f; - - int damage = 80; - int type = ProjectileID.UnholyTridentHostile; - int trident = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition + tridentVelocity * 100f, tridentVelocity, type, damage, 3f, Main.myPlayer); - Main.projectile[trident].timeLeft = 300; - if (CalamityWorld.death) - { - Main.projectile[trident].extraUpdates += 1; - Main.projectile[trident].timeLeft = 600; - } - } - } - else - npc.ai[0] += 1f; - } - } - return false; - } - #endregion - - #region Swimming AI - public static bool BuffedSwimmingAI(NPC npc, Mod mod) - { - if (npc.direction == 0) - { - npc.TargetClosest(true); - } - if (npc.wet) - { - bool noWetTargets = false; - npc.TargetClosest(false); - if ((Main.player[npc.target].wet || (CalamityWorld.death && npc.Distance(Main.player[npc.target].Center) < 400f)) && !Main.player[npc.target].dead) - { - noWetTargets = true; - } - if (!noWetTargets) - { - if (npc.collideX) - { - npc.velocity.X *= -1f; - npc.direction *= -1; - npc.netUpdate = true; - } - if (npc.collideY) - { - npc.netUpdate = true; - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; - npc.directionY = -1; - npc.ai[0] = -1f; - } - else if (npc.velocity.Y < 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y); - npc.directionY = 1; - npc.ai[0] = 1f; - } - } - } - if (npc.type == NPCID.AnglerFish) - { - Lighting.AddLight((int)(npc.position.X + (float)(npc.width / 2) + (float)(npc.direction * (npc.width + 8))) / 16, (int)(npc.position.Y + 2f) / 16, 0.07f, 0.04f, 0.025f); - } - if (noWetTargets) - { - npc.TargetClosest(true); - if (npc.type == NPCID.Arapaima) - { - // Check if the direction value signs match - if ((npc.velocity.X > 0).ToDirectionInt() != (npc.velocity.X > 0).ToDirectionInt()) - { - npc.velocity.X *= 0.95f; - } - npc.velocity.X += npc.direction * 0.5f; - npc.velocity.Y += npc.directionY * 0.4f; - - // I don't really understand why a boundary break penalty of 2 is used here, but just to be safe, I'll leave it alone. - if (npc.velocity.X > 16f) - { - npc.velocity.X = 14f; - } - if (npc.velocity.X < -16f) - { - npc.velocity.X = -14f; - } - if (npc.velocity.Y > 10f) - { - npc.velocity.Y = 8f; - } - if (npc.velocity.Y < -10f) - { - npc.velocity.Y = -8f; - } - } - else if (npc.type == NPCID.Shark || npc.type == NPCID.AnglerFish) - { - npc.velocity.X += npc.direction * 0.3f; - npc.velocity.Y += npc.directionY * 0.3f; - if (npc.velocity.X > 10f) - { - npc.velocity.X = 10f; - } - if (npc.velocity.X < -10f) - { - npc.velocity.X = -10f; - } - if (npc.velocity.Y > 6f) - { - npc.velocity.Y = 6f; - } - if (npc.velocity.Y < -6f) - { - npc.velocity.Y = -6f; - } - npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-10f, -6f), new Vector2(10f, 6f)); - } - else - { - npc.velocity.X += npc.direction * 0.2f; - npc.velocity.Y += npc.directionY * 0.2f; - npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-6f, -4f), new Vector2(6f, 4f)); - } - } - else - { - if (npc.type == NPCID.Arapaima) - { - npc.directionY = (Main.player[npc.target].position.Y > npc.position.Y).ToDirectionInt(); - npc.velocity.X += npc.direction * 0.2f; - if (npc.velocity.X < -2f || npc.velocity.X > 2f) - { - npc.velocity.X *= 0.95f; - } - // Bob up and down in the water - if (npc.ai[0] == -1f) - { - float yVelocityMin = -0.6f; - if (npc.directionY < 0) - { - yVelocityMin = -1f; - } - if (npc.directionY > 0) - { - yVelocityMin = -0.2f; - } - npc.velocity.Y -= 0.02f; - if (npc.velocity.Y < yVelocityMin) - { - npc.ai[0] = 1f; - } - } - else - { - float yVelocityMin = 0.6f; - if (npc.directionY < 0) - { - yVelocityMin = 0.2f; - } - if (npc.directionY > 0) - { - yVelocityMin = 1f; - } - npc.velocity.Y += 0.02f; - if (npc.velocity.Y > yVelocityMin) - { - npc.ai[0] = -1f; - } - } - } - else - { - npc.velocity.X += npc.direction * 0.1f; - if (npc.velocity.X < -1f || npc.velocity.X > 1f) - { - npc.velocity.X *= 0.95f; - } - if (npc.ai[0] == -1f) - { - npc.velocity.Y -= 0.01f; - if (npc.velocity.Y < -0.3f) - { - npc.ai[0] = 1f; - } - } - else - { - npc.velocity.Y += 0.01f; - if (npc.velocity.Y > 0.3) - { - npc.ai[0] = -1f; - } - } - } - int x = (int)npc.Center.X / 16; - int y = (int)npc.Center.Y / 16; - if (Main.tile[x, y - 1].LiquidAmount > 128) - { - if (Main.tile[x, y + 1].HasTile) - { - npc.ai[0] = -1f; - } - else if (Main.tile[x, y + 2].HasTile) - { - npc.ai[0] = -1f; - } - } - if (npc.type != NPCID.Arapaima && Math.Abs(npc.velocity.Y) < 0.4f) - { - npc.velocity.Y *= 0.95f; - } - } - } - else - { - if (npc.velocity.Y == 0f) - { - // Sit helplessly on land and do absolutely nothing. - if (npc.type == NPCID.Shark) - { - npc.velocity.X *= 0.94f; - if (Math.Abs(npc.velocity.X) < 0.2) - { - npc.velocity.X = 0f; - } - } - // Flop around - else if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.velocity.Y = Main.rand.NextFloat(-5f, -2f); - npc.velocity.X = Main.rand.NextFloat(-2f, -2f); - npc.netUpdate = true; - } - } - npc.velocity.Y += 0.3f; - if (npc.velocity.Y > 10f) - { - npc.velocity.Y = 10f; - } - npc.ai[0] = 1f; - } - npc.rotation = npc.velocity.Y * npc.direction * 0.1f; - npc.rotation = MathHelper.Clamp(npc.rotation, -0.2f, 0.2f); - return false; - } - #endregion - - #region Jellyfish AI - public static bool BuffedJellyfishAI(NPC npc, Mod mod) - { - // Avoid cheap bullshit - float damagingVelocity = npc.type == NPCID.GreenJellyfish ? 7.2f : 5.6f; - npc.damage = (npc.dontTakeDamage || npc.velocity.Length() > damagingVelocity) ? npc.defDamage : 0; - - // Stop moving because we're emitting electricity and don't take damage - bool endEarly = false; - if (npc.wet && npc.ai[1] == 1f) - { - endEarly = true; - } - else - { - npc.dontTakeDamage = false; - } - if (npc.type == NPCID.BlueJellyfish || npc.type == NPCID.PinkJellyfish || npc.type == NPCID.GreenJellyfish || npc.type == NPCID.BloodJelly) - { - if (npc.wet) - { - if (npc.target >= 0 && Main.player[npc.target].wet && !Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() < 200f) - { - if (npc.ai[1] == 0f) - { - npc.ai[2] += 2f; - } - else - { - npc.ai[2] -= 0.25f; - } - } - if (endEarly) - { - npc.dontTakeDamage = true; - npc.ai[2] += 1f; - if (npc.ai[2] >= 90f) - { - npc.ai[1] = 0f; - } - } - else - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 300f) - { - npc.ai[1] = 1f; - npc.ai[2] = 0f; - } - } - } - else - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } - } - float lightIntensity = 1f; - if (endEarly) - { - lightIntensity += 0.5f; - } - if (npc.type == NPCID.BlueJellyfish) - { - Lighting.AddLight((int)(npc.Center.X) / 16, (int)(npc.Center.Y) / 16, 0.05f * lightIntensity, 0.15f * lightIntensity, 0.4f * lightIntensity); - } - else if (npc.type == NPCID.GreenJellyfish) - { - Lighting.AddLight((int)(npc.Center.X) / 16, (int)(npc.Center.Y) / 16, 0.05f * lightIntensity, 0.45f * lightIntensity, 0.1f * lightIntensity); - } - else if (npc.type != NPCID.Squid && npc.type != NPCID.BloodJelly) - { - Lighting.AddLight((int)(npc.Center.X) / 16, (int)(npc.Center.Y) / 16, 0.35f * lightIntensity, 0.05f * lightIntensity, 0.2f * lightIntensity); - } - if (npc.direction == 0) - { - npc.TargetClosest(true); - } - if (endEarly) - { - return false; - } - if (!npc.wet) - { - npc.rotation += npc.velocity.X * 0.1f; - if (npc.velocity.Y == 0f) - { - npc.velocity.X *= 0.98f; - if (Math.Abs(npc.velocity.X) < 0.01f) - { - npc.velocity.X = 0f; - } - } - npc.velocity.Y += 0.2f; - if (npc.velocity.Y > 10f) - { - npc.velocity.Y = 10f; - } - npc.ai[0] = 1f; - return false; - } - // Collision - // Turn around on X collision - if (npc.collideX) - { - npc.velocity.X *= 1f; - npc.direction *= -1; - } - // Manipulate the sign of the Y velocity - if (npc.collideY) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y) * -1f; - npc.directionY = -1; - npc.ai[0] = -1f; - } - else if (npc.velocity.Y < 0f) - { - npc.velocity.Y = Math.Abs(npc.velocity.Y); - npc.directionY = 1; - npc.ai[0] = 1f; - } - } - bool targetInWater = false; - if (!npc.friendly) - { - npc.TargetClosest(false); - if ((Main.player[npc.target].wet || (CalamityWorld.death && npc.Distance(Main.player[npc.target].Center) < 400f)) && !Main.player[npc.target].dead) - { - targetInWater = true; - } - } - // Slow down. When slow enough, charge again. - if (targetInWater) - { - npc.localAI[2] = 1f; - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - npc.velocity *= 0.96f; - float minimumSpeed = 0.2f; - if (npc.type == NPCID.GreenJellyfish) - { - npc.velocity *= 0.98f; - minimumSpeed = 0.6f; - } - if (npc.type == NPCID.Squid) - { - npc.velocity *= 0.99f; - minimumSpeed = 1f; - } - if (npc.type == NPCID.BloodJelly) - { - npc.velocity *= 0.995f; - minimumSpeed = 3f; - } - minimumSpeed *= 0.8f; - if (npc.velocity.Length() < minimumSpeed) - { - if (npc.type == NPCID.Squid) - { - npc.localAI[0] = 1f; - } - npc.TargetClosest(true); - - float lungeSpeed = npc.type == NPCID.GreenJellyfish ? 18f : 14f; - npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * lungeSpeed; - } - } - // General floating around. - else - { - npc.localAI[2] = 0f; - npc.velocity.X += npc.direction * 0.02f; - npc.rotation = npc.velocity.X * 0.4f; - if (npc.velocity.X < -1f || npc.velocity.X > 1f) - { - npc.velocity.X *= 0.95f; - } - if (npc.ai[0] == -1f) - { - npc.velocity.Y -= 0.01f; - if (npc.velocity.Y < -1f) - { - npc.ai[0] = 1f; - } - } - else - { - npc.velocity.Y += 0.01f; - if (npc.velocity.Y > 1f) - { - npc.ai[0] = -1f; - } - } - int x = (int)npc.Center.X / 16; - int y = (int)npc.Center.Y / 16; - if (Main.tile[x, y - 1].LiquidAmount > 128) - { - if (Main.tile[x, y + 1].HasTile) - { - npc.ai[0] = -1f; - } - else if (Main.tile[x, y + 2].HasTile) - { - npc.ai[0] = -1f; - } - } - else - { - npc.ai[0] = 1f; - } - if (Math.Abs(npc.velocity.Y) > 1.2) - { - npc.velocity.Y *= 0.99f; - } - } - return false; - } - #endregion - - #region Antlion AI - public static bool BuffedAntlionAI(NPC npc, Mod mod) - { - npc.TargetClosest(); - - // Calculate speed and velocity of the sand balls - float speed = 12f; - float xVel = Main.player[npc.target].Center.X - npc.Center.X; - float yVel = Main.player[npc.target].position.Y - npc.Center.Y; - Vector2 velocity = new Vector2(xVel, yVel); - float targetDist = velocity.Length(); - - targetDist = speed / targetDist; - velocity.X *= targetDist; - velocity.Y *= targetDist; - - // Adjust rotation and velocity - bool canShoot = false; - if (npc.directionY < 0) - { - // Set rotation based on the target location - npc.rotation = velocity.ToRotation() + MathHelper.PiOver2; - - // Antlions can only shoot if rotated between a certain cone of spread based on the target location - canShoot = Math.Abs(npc.rotation) <= 1.2f; - - // Hardcap rotation so it doesn't look weird, but since the above calculation happens first, it ignores this cap - if (npc.rotation < -0.8f) - npc.rotation = -0.8f; - else if (npc.rotation > 0.8f) - npc.rotation = 0.8f; - - // Antlions generally don't move horizontally so prevent that as needed - if (npc.velocity.X != 0f) - { - npc.velocity.X *= 0.9f; - if (Math.Abs(npc.velocity.X) < 0.1f) - { - npc.netUpdate = true; - npc.velocity.X = 0f; - } - } - } - - bool lineofSight = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - - if (npc.justHit || !lineofSight) - npc.ai[0] = AntlionSandSpitGateValue - 1f; - - // Decrement the firing cooldown, play a sound if at full meaning it just fired - if (npc.ai[0] > 0f) - { - if (npc.ai[0] == AntlionSandSpitGateValue) - SoundEngine.PlaySound(SoundID.NPCDeath13, npc.Center); - - npc.ai[0] -= 1f; - } - - // Emit sand dust from mouth when about to fire - if (npc.ai[0] <= AntlionSandSpitTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.Center + velocity.SafeNormalize(-Vector2.UnitY) * 16f + Main.rand.NextVector2CircularEdge(6f, 6f), 1, 1, DustID.Sand, 0f, 0f, 0, default, 1.5f); - dust.noGravity = true; - dust.velocity *= 0f; - } - - // Antlions should only fire if the target is in the shooting cone and has a line of sight as well as not being on cooldown. - if (Main.netMode != NetmodeID.MultiplayerClient && canShoot && npc.ai[0] == 0f && lineofSight) - { - // Reset the firing cooldown to 3.3333 seconds - npc.ai[0] = AntlionSandSpitGateValue; - - // With the Rev and Death damage calculations, this becomes 56 damage. - int damage = 10; - - int projType = ProjectileID.SandBallFalling; - - // 2 to 3 in Rev, 3 to 5 in Death, if FTW is also enabled, 8 to 13 (random chance for 10x the amount) - int projAmt = CalamityWorld.revenge ? Main.rand.Next(CalamityWorld.death ? 3 : 2, CalamityWorld.death ? 6 : 4) : 1; - if (Main.getGoodWorld) - { - projAmt = Main.rand.Next(8, 14); - if (Main.rand.NextBool(1000) || Main.zenithWorld) - projAmt = Main.rand.Next(80, 131); - } - - for (int i = 0; i < projAmt; i++) - { - // Adjust the velocity to make it a shotgun-like spread - velocity.X += (float)Main.rand.Next(-30, 31) * 0.05f; - velocity.Y += (float)Main.rand.Next(-30, 31) * 0.05f; - - int sandBall = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, projType, damage, 0f, Main.myPlayer); - Main.projectile[sandBall].ai[0] = 2f; - Main.projectile[sandBall].timeLeft = 300; - Main.projectile[sandBall].friendly = false; - NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, sandBall, 0f, 0f, 0f, 0, 0, 0); - } - - npc.netUpdate = true; - } - - try - { - // This tile checking behavior is used for when Antlions cover themselves in sand and need to rise upward to get to the surface - int xLeft = (int)npc.position.X / 16; - int xCenter = (int)npc.Center.X / 16; - int xRight = (int)(npc.position.X + (float)npc.width) / 16; - int y = (int)(npc.position.Y + (float)npc.height) / 16; - bool tileClimbing = false; - if ((Main.tile[xLeft, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xLeft, y].TileType]) || (Main.tile[xCenter, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xCenter, y].TileType]) || (Main.tile[xRight, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xRight, y].TileType])) - tileClimbing = true; - - if (tileClimbing) - { - npc.noGravity = true; - npc.noTileCollide = true; - npc.velocity.Y = -0.2f; - } - - // If not rising up through tiles, occasionally spawn some dust - else - { - npc.noGravity = false; - npc.noTileCollide = false; - if (Main.rand.NextBool()) - { - int sand = Dust.NewDust(new Vector2(npc.position.X - 4f, npc.position.Y + (float)npc.height - 8f), npc.width + 8, 24, DustID.Sand, 0f, npc.velocity.Y / 2f, 0, default(Color), 1f); - Dust dust = Main.dust[sand]; - dust.velocity.X *= 0.4f; - dust.velocity.Y *= -1f; - if (Main.rand.NextBool()) - { - dust.noGravity = true; - dust.scale += 0.2f; - } - } - } - } - catch - { - } - - return false; - } - #endregion - - #region Spike Ball AI - public static bool BuffedSpikeBallAI(NPC npc, Mod mod) - { - if (npc.ai[0] == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.TargetClosest(true); - npc.direction *= -1; - npc.directionY *= -1; - npc.position.Y = npc.position.Y + (float)(npc.height / 2 + 8); - npc.ai[1] = npc.position.X + (float)(npc.width / 2); - npc.ai[2] = npc.position.Y + (float)(npc.height / 2); - if (npc.direction == 0) - { - npc.direction = 1; - } - if (npc.directionY == 0) - { - npc.directionY = 1; - } - npc.ai[3] = 1f + (float)Main.rand.Next(15) * 0.1f; - npc.velocity.Y = (float)(npc.directionY * 6) * npc.ai[3]; - npc.ai[0] += 1f; - npc.netUpdate = true; - return false; - } - npc.ai[1] = npc.position.X + (float)(npc.width / 2); - npc.ai[2] = npc.position.Y + (float)(npc.height / 2); - } - else - { - float maxSpinSpeed = (CalamityWorld.death ? 12f : 9f) * npc.ai[3]; - float spinAcceleration = (CalamityWorld.death ? 0.4f : 0.3f) * npc.ai[3]; - float timeToReachMaxSpeed = maxSpinSpeed / spinAcceleration / 2f; - if (npc.ai[0] >= 1f && npc.ai[0] < (float)((int)timeToReachMaxSpeed)) - { - npc.velocity.Y = (float)npc.directionY * maxSpinSpeed; - npc.ai[0] += 1f; - return false; - } - if (npc.ai[0] >= (float)((int)timeToReachMaxSpeed)) - { - npc.velocity.Y = 0f; - npc.directionY *= -1; - npc.velocity.X = maxSpinSpeed * (float)npc.direction; - npc.ai[0] = -1f; - return false; - } - if (npc.directionY > 0) - { - if (npc.velocity.Y >= maxSpinSpeed) - { - npc.directionY *= -1; - npc.velocity.Y = maxSpinSpeed; - } - } - else if (npc.directionY < 0 && npc.velocity.Y <= -maxSpinSpeed) - { - npc.directionY *= -1; - npc.velocity.Y = -maxSpinSpeed; - } - if (npc.direction > 0) - { - if (npc.velocity.X >= maxSpinSpeed) - { - npc.direction *= -1; - npc.velocity.X = maxSpinSpeed; - } - } - else if (npc.direction < 0 && npc.velocity.X <= -maxSpinSpeed) - { - npc.direction *= -1; - npc.velocity.X = -maxSpinSpeed; - } - npc.velocity.X = npc.velocity.X + spinAcceleration * (float)npc.direction; - npc.velocity.Y = npc.velocity.Y + spinAcceleration * (float)npc.directionY; - } - return false; - } - #endregion - - #region Blazing Wheel AI - public static bool BuffedBlazingWheelAI(NPC npc, Mod mod) - { - if (npc.ai[0] == 0f) - { - npc.TargetClosest(); - npc.directionY = 1; - npc.ai[0] = 1f; - } - - int wheelVelocity = CalamityWorld.death ? 9 : 6; - if (npc.ai[1] == 0f) - { - npc.rotation += (float)(npc.direction * npc.directionY) * 0.13f; - - if (npc.collideY) - npc.ai[0] = 2f; - - if (!npc.collideY && npc.ai[0] == 2f) - { - npc.direction = -npc.direction; - npc.ai[1] = 1f; - npc.ai[0] = 1f; - } - - if (npc.collideX) - { - npc.directionY = -npc.directionY; - npc.ai[1] = 1f; - } - } - else - { - npc.rotation -= (float)(npc.direction * npc.directionY) * 0.13f; - - if (npc.collideX) - npc.ai[0] = 2f; - - if (!npc.collideX && npc.ai[0] == 2f) - { - npc.directionY = -npc.directionY; - npc.ai[1] = 0f; - npc.ai[0] = 1f; - } - - if (npc.collideY) - { - npc.direction = -npc.direction; - npc.ai[1] = 0f; - } - } - - npc.velocity.X = (float)(wheelVelocity * npc.direction); - npc.velocity.Y = (float)(wheelVelocity * npc.directionY); - - float lighting = (float)(270 - (int)Main.mouseTextColor) / 400f; - Lighting.AddLight((int)(npc.position.X + (float)(npc.width / 2)) / 16, (int)(npc.position.Y + (float)(npc.height / 2)) / 16, 0.9f, 0.3f + lighting, 0.2f); - - // Emit fire dust from center when about to fire - if (npc.localAI[0] > (CalamityWorld.death ? BlazingWheelFlameGateValue_Death : BlazingWheelFlameGateValue) - BlazingWheelTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.Center + Main.rand.NextVector2CircularEdge(5f, 5f), 1, 1, DustID.Torch, 0f, 0f, 0, default, 3f); - dust.noGravity = true; - dust.velocity *= 0f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= (CalamityWorld.death ? BlazingWheelFlameGateValue_Death : BlazingWheelFlameGateValue)) - { - npc.localAI[0] = 0f; - for (int i = 0; i < 4; i++) - { - Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(MathHelper.PiOver2 * (float)i)); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, vector255, ProjectileID.FlamesTrap, 20, 0f, Main.myPlayer); - Main.projectile[proj].tileCollide = false; - Main.projectile[proj].friendly = false; - Main.projectile[proj].trap = false; - } - } - } - - return false; - } - #endregion - - #region Hovering AI - public static bool BuffedHoveringAI(NPC npc, Mod mod) - { - bool hoverDownDistCheck = false; - bool runAway = npc.type == NPCID.Poltergeist && !Main.pumpkinMoon; - - if (npc.type == NPCID.Reaper && !Main.eclipse) - { - runAway = true; - } - if (npc.type == NPCID.Drippler && Main.dayTime) - { - runAway = true; - } - - if (!runAway) - { - if (npc.ai[2] >= 0f) - { - int hoverDistance = 16; - bool changeDirectionX = false; - bool changeDirectionY = false; - if (npc.position.X > npc.ai[0] - (float)hoverDistance && npc.position.X < npc.ai[0] + (float)hoverDistance) - { - changeDirectionX = true; - } - else if ((npc.velocity.X < 0f && npc.direction > 0) || (npc.velocity.X > 0f && npc.direction < 0)) - { - changeDirectionX = true; - } - hoverDistance += 24; - if (npc.position.Y > npc.ai[1] - (float)hoverDistance && npc.position.Y < npc.ai[1] + (float)hoverDistance) - { - changeDirectionY = true; - } - if (changeDirectionX & changeDirectionY) - { - npc.ai[2] += 1f; - if (npc.ai[2] >= 40f) - { - npc.ai[2] = -200f; - npc.direction *= -1; - npc.velocity.X = npc.velocity.X * -1f; - npc.collideX = false; - } - } - else - { - npc.ai[0] = npc.position.X; - npc.ai[1] = npc.position.Y; - npc.ai[2] = 0f; - } - npc.TargetClosest(true); - } - else if (npc.type == NPCID.Reaper) - { - npc.TargetClosest(true); - npc.ai[2] += 30f; - } - else - { - if (npc.type == NPCID.Poltergeist) - { - npc.ai[2] += 5f; - } - else - { - npc.ai[2] += 15f; - } - if (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) > npc.position.X + (float)(npc.width / 2)) - { - npc.direction = -1; - } - else - { - npc.direction = 1; - } - } - } - - int npcTileX = (int)((npc.position.X + (float)(npc.width / 2)) / 16f) + npc.direction * 2; - int npcTileY = (int)((npc.position.Y + (float)npc.height) / 16f); - bool hoverDownwards = true; - bool canOpenDoor = false; - int tileCheckLoopAmt = 6; - - if (npc.type == NPCID.Gastropod) - { - float gastropodProjSpeed = 6f; - Vector2 gastropodPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float gastropodTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - gastropodPosition.X; - float gastropodTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - gastropodPosition.Y; - float gastropodTargetDist = (float)Math.Sqrt((double)(gastropodTargetX * gastropodTargetX + gastropodTargetY * gastropodTargetY)); - - gastropodTargetDist = gastropodProjSpeed / gastropodTargetDist; - gastropodTargetX *= gastropodTargetDist; - gastropodTargetY *= gastropodTargetDist; - - if (npc.justHit) - { - npc.localAI[1] = 0f; - npc.ai[3] = 0f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[3] == 32f && !Main.player[npc.target].npcTypeNoAggro[npc.type]) - { - int damage = 25; - int projType = ProjectileID.PinkLaser; - Projectile.NewProjectile(npc.GetSource_FromAI(), gastropodPosition.X, gastropodPosition.Y, gastropodTargetX, gastropodTargetY, projType, damage, 0f, Main.myPlayer, 0f, 0f); - } - - tileCheckLoopAmt = 12; - - if (npc.ai[3] > 0f) - { - npc.ai[3] += 1f; - if (npc.ai[3] >= 64f) - { - npc.ai[3] = 0f; - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[3] == 0f) - { - npc.localAI[1] += 1f; - if (npc.localAI[1] > (CalamityWorld.death ? 60f : 120f) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && !Main.player[npc.target].npcTypeNoAggro[npc.type]) - { - npc.localAI[1] = 0f; - npc.ai[3] = 1f; - npc.netUpdate = true; - } - } - } - else if (npc.type == NPCID.Pixie) - { - tileCheckLoopAmt = 8; - - if (Main.rand.NextBool(6)) - { - int pixieDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Pixie, 0f, 0f, 200, npc.color, 1f); - Dust dust = Main.dust[pixieDust]; - dust.velocity *= 0.3f; - } - - if (Main.rand.NextBool(40)) - { - SoundEngine.PlaySound(SoundID.Pixie, npc.Center); - } - } - else if (npc.type == NPCID.IceElemental) - { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.6f, 0.75f); - - npc.alpha = 30; - - if (Main.rand.NextBool(3)) - { - int iceEleDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Frost, 0f, 0f, 200, default, 1f); - Dust dust = Main.dust[iceEleDust]; - dust.velocity *= 0.3f; - Main.dust[iceEleDust].noGravity = true; - } - - float iceElementalProjSpeed = 6f; - Vector2 iceElementalPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float iceElementalTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - iceElementalPosition.X; - float iceElementalTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - iceElementalPosition.Y; - float iceElementalTargetDist = (float)Math.Sqrt((double)(iceElementalTargetX * iceElementalTargetX + iceElementalTargetY * iceElementalTargetY)); - - iceElementalTargetDist = iceElementalProjSpeed / iceElementalTargetDist; - iceElementalTargetX *= iceElementalTargetDist; - iceElementalTargetY *= iceElementalTargetDist; - - if (iceElementalTargetX > 0f) - npc.direction = 1; - else - npc.direction = -1; - - npc.spriteDirection = npc.direction; - - if (npc.direction < 0) - npc.rotation = (float)Math.Atan2((double)(-(double)iceElementalTargetY), (double)(-(double)iceElementalTargetX)); - else - npc.rotation = (float)Math.Atan2((double)iceElementalTargetY, (double)iceElementalTargetX); - - if (npc.justHit || !Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - npc.localAI[1] = 0f; - - tileCheckLoopAmt = 15; - - // Emit frost dust when about to fire - if (npc.localAI[1] > (CalamityWorld.death ? IceElementalFrostBlastGateValue_Death : IceElementalFrostBlastGateValue) - IceElementalFrostBlastTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Frost, 0f, 0f, 200, default, 2f); - dust.noGravity = true; - dust.velocity *= 0f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += 1f; - if (npc.localAI[1] > (CalamityWorld.death ? IceElementalFrostBlastGateValue_Death : IceElementalFrostBlastGateValue) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.localAI[1] = 0f; - - int dmg = 45; - int projType = ProjectileID.FrostBlastHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), iceElementalPosition.X, iceElementalPosition.Y, iceElementalTargetX, iceElementalTargetY, projType, dmg, 0f, Main.myPlayer); - - npc.netUpdate = true; - } - } - } - else if (npc.type == NPCID.IchorSticker) - { - npc.rotation = npc.velocity.X * 0.1f; - - if (Main.player[npc.target].Center.Y < npc.Center.Y) - tileCheckLoopAmt = 18; - else - tileCheckLoopAmt = 9; - - if (npc.justHit) - npc.ai[3] = 0f; - - if (Main.netMode != NetmodeID.MultiplayerClient && !npc.confused) - { - npc.ai[3] += 1f; - if (npc.ai[3] >= (CalamityWorld.death ? IchorStickerShootGateValue_Death : CalamityWorld.revenge ? IchorStickerShootGateValue_Rev : IchorStickerShootGateValue)) - { - npc.ai[3] = 0f; - Vector2 ichorStickerPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f - 4f, npc.position.Y + (float)npc.height * 0.7f); - if (Collision.CanHit(ichorStickerPosition, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - float ichorStickerProjSpeed = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; - float ichorStickerTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - ichorStickerPosition.X; - float ichorStickerAbsTargetX = Math.Abs(ichorStickerTargetX) * 0.1f; - float ichorStickerTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - ichorStickerPosition.Y - ichorStickerAbsTargetX; - float ichorStickerTargetDist = (float)Math.Sqrt((double)(ichorStickerTargetX * ichorStickerTargetX + ichorStickerTargetY * ichorStickerTargetY)); - ichorStickerTargetDist = ichorStickerProjSpeed / ichorStickerTargetDist; - ichorStickerTargetX *= ichorStickerTargetDist; - ichorStickerTargetY *= ichorStickerTargetDist; - int dmg = 40; - int projType = ProjectileID.GoldenShowerHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), ichorStickerPosition.X, ichorStickerPosition.Y, ichorStickerTargetX, ichorStickerTargetY, projType, dmg, 0f, Main.myPlayer); - } - } - } - } - - if (npc.type == NPCID.Drippler) - { - tileCheckLoopAmt = 8; - - if (npc.target >= 0) - { - float dripperTargetDist = (Main.player[npc.target].Center - npc.Center).Length(); - dripperTargetDist /= 70f; - if (dripperTargetDist > 8f) - { - dripperTargetDist = 8f; - } - tileCheckLoopAmt += (int)dripperTargetDist; - } - } - - for (int y = npcTileY; y < npcTileY + tileCheckLoopAmt; y++) - { - if ((Main.tile[npcTileX, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, y].TileType]) || Main.tile[npcTileX, y].LiquidAmount > 0) - { - if (y <= npcTileY + 1) - { - canOpenDoor = true; - } - hoverDownwards = false; - break; - } - } - - if (Main.player[npc.target].npcTypeNoAggro[npc.type]) - { - bool canOpenTallGate = false; - for (int yInc = npcTileY; yInc < npcTileY + tileCheckLoopAmt - 2; yInc++) - { - if ((Main.tile[npcTileX, yInc].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, yInc].TileType]) || Main.tile[npcTileX, yInc].LiquidAmount > 0) - { - canOpenTallGate = true; - break; - } - } - npc.directionY = (!canOpenTallGate).ToDirectionInt(); - } - - if (npc.type == NPCID.IceElemental || npc.type == NPCID.IchorSticker) - { - for (int iceIchorY = npcTileY - 3; iceIchorY < npcTileY; iceIchorY++) - { - if ((Main.tile[npcTileX, iceIchorY].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, iceIchorY].TileType]) || Main.tile[npcTileX, iceIchorY].LiquidAmount > 0) - { - canOpenDoor = false; - hoverDownDistCheck = true; - break; - } - } - } - - if (hoverDownDistCheck) - { - hoverDownwards = true; - if (npc.type == NPCID.IchorSticker) - npc.velocity.Y += (CalamityWorld.revenge ? 3f : 2f); - } - - if (hoverDownwards) - { - if (npc.type == NPCID.Pixie || npc.type == NPCID.IceElemental) - { - npc.velocity.Y += CalamityWorld.revenge ? 0.3f : 0.2f; - if (npc.velocity.Y > (CalamityWorld.revenge ? 3f : 2f)) - npc.velocity.Y = CalamityWorld.revenge ? 3f : 2f; - } - else if (npc.type == NPCID.Drippler) - { - npc.velocity.Y += 0.05f; - if (npc.velocity.Y > 1f) - npc.velocity.Y = 1f; - } - else - { - npc.velocity.Y += 0.15f; - if (npc.velocity.Y > 4f) - npc.velocity.Y = 4f; - } - } - else - { - if (npc.type == NPCID.Pixie || npc.type == NPCID.IceElemental) - { - if ((npc.directionY < 0 && npc.velocity.Y > 0f) | canOpenDoor) - npc.velocity.Y -= CalamityWorld.revenge ? 0.3f : 0.2f; - } - else if (npc.type == NPCID.Drippler) - { - if ((npc.directionY < 0 && npc.velocity.Y > 0f) | canOpenDoor) - npc.velocity.Y -= 0.1f; - if (npc.velocity.Y < -1f) - npc.velocity.Y = -1f; - } - else if (npc.directionY < 0 && npc.velocity.Y > 0f) - npc.velocity.Y -= 0.15f; - - if (npc.velocity.Y < -(CalamityWorld.revenge ? 5.5f : 4f)) - npc.velocity.Y = -(CalamityWorld.revenge ? 5.5f : 4f); - } - - if (npc.type == NPCID.Pixie && npc.wet) - { - npc.velocity.Y = npc.velocity.Y - 0.3f; - if (npc.velocity.Y < -3f) - { - npc.velocity.Y = -3f; - } - } - - if (npc.collideX) - { - npc.velocity.X = npc.oldVelocity.X * -0.4f; - if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 1f) - { - npc.velocity.X = 1f; - } - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -1f) - { - npc.velocity.X = -1f; - } - } - if (npc.collideY) - { - npc.velocity.Y = npc.oldVelocity.Y * -0.25f; - if (npc.velocity.Y > 0f && npc.velocity.Y < 1f) - { - npc.velocity.Y = 1f; - } - if (npc.velocity.Y < 0f && npc.velocity.Y > -1f) - { - npc.velocity.Y = -1f; - } - } - - float maxHoverVel = 2f; - if (npc.type == NPCID.Pixie) - { - maxHoverVel = 3f; - } - if (npc.type == NPCID.Reaper) - { - maxHoverVel = 4f; - } - if (npc.type == NPCID.Drippler) - { - maxHoverVel = 1.5f; - } - if (CalamityWorld.death) - { - maxHoverVel *= 1.25f; - } - - if (npc.type == NPCID.Poltergeist) - { - npc.alpha = 0; - maxHoverVel = 6f; - if (!runAway) - { - npc.TargetClosest(); - } - else if (npc.timeLeft > 10) - { - npc.timeLeft = 10; - } - if (npc.direction < 0 && npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X * 0.8f; - } - if (npc.direction > 0 && npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X * 0.8f; - } - } - - if (npc.direction == -1 && npc.velocity.X > -maxHoverVel) - { - npc.velocity.X -= CalamityWorld.revenge ? 0.15f : 0.1f; - if (npc.velocity.X > maxHoverVel) - npc.velocity.X -= CalamityWorld.revenge ? 0.15f : 0.1f; - else if (npc.velocity.X > 0f) - npc.velocity.X += CalamityWorld.revenge ? 0.1f : 0.05f; - - if (npc.velocity.X < -maxHoverVel) - npc.velocity.X = -maxHoverVel; - } - else if (npc.direction == 1 && npc.velocity.X < maxHoverVel) - { - npc.velocity.X += CalamityWorld.revenge ? 0.15f : 0.1f; - if (npc.velocity.X < -maxHoverVel) - npc.velocity.X += CalamityWorld.revenge ? 0.15f : 0.1f; - else if (npc.velocity.X < 0f) - npc.velocity.X -= CalamityWorld.revenge ? 0.1f : 0.05f; - - if (npc.velocity.X > maxHoverVel) - npc.velocity.X = maxHoverVel; - } - - if (npc.type == NPCID.Drippler) - maxHoverVel = 1.5f; - else - maxHoverVel = CalamityWorld.revenge ? 2.5f : 1.5f; - - if (CalamityWorld.death) - maxHoverVel *= 1.25f; - - if (npc.directionY == -1 && npc.velocity.Y > -maxHoverVel) - { - npc.velocity.Y -= CalamityWorld.revenge ? 0.06f : 0.04f; - if (npc.velocity.Y > maxHoverVel) - npc.velocity.Y -= CalamityWorld.revenge ? 0.1f : 0.05f; - else if (npc.velocity.Y > 0f) - npc.velocity.Y += CalamityWorld.revenge ? 0.05f : 0.03f; - - if (npc.velocity.Y < -maxHoverVel) - npc.velocity.Y = -maxHoverVel; - } - else if (npc.directionY == 1 && npc.velocity.Y < maxHoverVel) - { - npc.velocity.Y += CalamityWorld.revenge ? 0.06f : 0.04f; - if (npc.velocity.Y < -maxHoverVel) - npc.velocity.Y += CalamityWorld.revenge ? 0.1f : 0.05f; - else if (npc.velocity.Y < 0f) - npc.velocity.Y -= CalamityWorld.revenge ? 0.05f : 0.03f; - - if (npc.velocity.Y > maxHoverVel) - npc.velocity.Y = maxHoverVel; - } - - if (npc.type == NPCID.Gastropod) - Lighting.AddLight((int)npc.position.X / 16, (int)npc.position.Y / 16, 0.4f, 0f, 0.25f); - - return false; - } - #endregion - - #region Flying Weapon AI - public static bool BuffedFlyingWeaponAI(NPC npc, Mod mod) - { - npc.knockBackResist = 0f; - npc.noGravity = true; - npc.noTileCollide = true; - if (npc.type == NPCID.EnchantedSword) - { - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0.2f, 0.05f, 0.3f); - } - else if (npc.type == NPCID.CrimsonAxe) - { - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0.3f, 0.15f, 0.05f); - } - else - { - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0.05f, 0.2f, 0.3f); - } - // Adjust target if we don't have one. - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - // Charge - if (npc.ai[0] == 0f) - { - float chargeSpeed = CalamityWorld.death ? 16f : 12f; - npc.velocity = npc.SafeDirectionTo(Main.player[npc.target].Center, -Vector2.UnitY) * chargeSpeed; - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver4; - - // Slow down - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - return false; - } - // Slow down - if (npc.ai[0] == 1f) - { - npc.velocity *= CalamityWorld.death ? 0.98f : 0.99f; - npc.ai[1] += 1f; - // Get ready to spin and then charge again. - if (npc.ai[1] >= (CalamityWorld.death ? 50f : 100f)) - { - npc.netUpdate = true; - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.velocity = Vector2.Zero; - } - } - // Spin - else - { - npc.velocity *= CalamityWorld.death ? 0.94f : 0.96f; - npc.ai[1] += 1f; - - float anglularSpeed = npc.ai[1] / (CalamityWorld.death ? 90f : 150f); - anglularSpeed = 0.1f + anglularSpeed * 0.4f; - npc.rotation += anglularSpeed * npc.direction; - - // Charge - if (npc.ai[1] >= (CalamityWorld.death ? 90f : 150f)) - { - npc.netUpdate = true; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - } - } - return false; - } - #endregion - - #region Mimic AI - public static bool BuffedMimicAI(NPC npc, Mod mod) - { - bool isLostHoppingPresent = npc.type == NPCID.PresentMimic && !Main.snowMoon; - - if (npc.ai[3] == 0f) - { - npc.position.X += 8f; - if (npc.position.Y / 16f > Main.UnderworldLayer) - { - npc.ai[3] = 3f; - } - else if (npc.position.Y / 16f > Main.worldSurface) - { - npc.TargetClosest(true); - npc.ai[3] = 2f; - } - else - { - npc.ai[3] = 1f; - } - } - - // Never wait. Go straight for the player. - if (npc.type == NPCID.PresentMimic || npc.type == NPCID.IceMimic) - { - npc.ai[3] = 1f; - } - - npc.dontTakeDamage = npc.ai[0] == 0f; - - // Sitting around, waiting for a potential player - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (!isLostHoppingPresent) - { - npc.TargetClosest(true); - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.velocity.X != 0f || npc.velocity.Y < 0f || npc.velocity.Y > 0.3f) - { - npc.ai[0] = 1f; - npc.netUpdate = true; - return false; - } - - Rectangle detectionZone = new Rectangle((int)npc.position.X - 80, (int)npc.position.Y - 80, npc.width + 160, npc.height + 160); - // If a player is nearby, become active. - if (detectionZone.Intersects(Main.player[npc.target].Hitbox) || npc.life < npc.lifeMax) - { - npc.ai[0] = 1f; - npc.netUpdate = true; - } - } - } - else if (npc.velocity.Y == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[2] += 1f; - - int timeSpentStopping = 20; - if (npc.ai[1] == 0f) - { - timeSpentStopping = 12; - } - if (npc.ai[2] < timeSpentStopping) - { - npc.velocity.X *= 0.9f; - return false; - } - - npc.ai[2] = 0f; - - if (!isLostHoppingPresent) - { - npc.TargetClosest(true); - } - if (npc.direction == 0) - { - npc.direction = -1; - } - - npc.spriteDirection = npc.direction; - - npc.ai[1] += 1f; - // Hop - if (npc.ai[1] == 2f) - { - npc.velocity.X = npc.direction * 4f; - npc.velocity.Y = -8f; - npc.ai[1] = 0f; - } - else - { - npc.velocity.X = npc.direction * 5.5f; - npc.velocity.Y = -4f; - } - - npc.netUpdate = true; - } - else - { - // Set damage - npc.damage = npc.defDamage; - - if (npc.direction == 1 && npc.velocity.X < 1f) - { - npc.velocity.X += 0.1f; - return false; - } - - if (npc.direction == -1 && npc.velocity.X > -1f) - { - npc.velocity.X -= 0.1f; - } - } - return false; - } - #endregion - - #region Unicorn AI - public static bool BuffedUnicornAI(NPC npc, Mod mod) - { - int turnAroundDelay = 30; - int turnAroundDelayMult = 8; - - bool flag = false; - bool isRunning = false; - bool shouldTurnAround = false; - - if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) - { - isRunning = true; - npc.ai[3] += 1f; - } - - if (npc.type == NPCID.Tumbleweed) - { - turnAroundDelayMult = 3; - bool noYVelocity = npc.velocity.Y == 0f; - foreach (NPC n in Main.ActiveNPCs) - { - 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 < n.position.X) - { - npc.velocity.X -= 0.05f; - } - else - { - npc.velocity.X += 0.05f; - } - if (npc.position.Y < n.position.Y) - { - npc.velocity.Y -= 0.05f; - } - else - { - npc.velocity.Y += 0.05f; - } - } - } - if (noYVelocity) - { - npc.velocity.Y = 0f; - } - } - - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay) | isRunning) - { - npc.ai[3] += 1f; - shouldTurnAround = true; - } - else if (npc.ai[3] > 0f) - { - npc.ai[3] -= 1f; - } - - if (npc.ai[3] > (float)(turnAroundDelay * turnAroundDelayMult)) - { - npc.ai[3] = 0f; - } - - if (npc.justHit) - { - npc.ai[3] = 0f; - } - - if (npc.ai[3] == (float)turnAroundDelay) - { - npc.netUpdate = true; - } - - Vector2 npcPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float targetXDist = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - npcPosition.X; - float targetYDist = Main.player[npc.target].position.Y - npcPosition.Y; - float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - - if (targetDistance < 200f && !shouldTurnAround) - { - npc.ai[3] = 0f; - } - - if (npc.type == NPCID.StardustSpiderSmall) - { - npc.ai[1] += 1f; - bool spawnTwinkle = npc.ai[1] >= (CalamityWorld.death ? 60f : 120f); - if (!spawnTwinkle && npc.velocity.Y == 0f) - { - foreach (Player plr in Main.ActivePlayers) - { - 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; - } - } - } - - if (spawnTwinkle && Main.netMode != NetmodeID.MultiplayerClient) - { - for (int k = 0; k < 3; k++) - { - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, (Main.rand.NextFloat() - 0.5f) * 2f, -4f - 10f * Main.rand.NextFloat(), ProjectileID.Twinkle, 50, 0f, Main.myPlayer, 0f, 0f); - } - npc.HitEffect(9999, 10.0); - npc.active = false; - return false; - } - } - else if (npc.type == NPCID.NebulaBeast) - { - if (npc.ai[2] == 1f) - { - npc.ai[1] += 1f; - npc.velocity.X = npc.velocity.X * 0.7f; - if (npc.ai[1] < 30f) - { - Vector2 nebulaBeastDustRotation = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; - Dust nebulaBeastDust = Main.dust[Dust.NewDust(nebulaBeastDustRotation, 0, 0, DustID.PinkTorch, 0f, 0f, 0, default(Color), 1f)]; - Vector2 nebulaBeastDustVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - nebulaBeastDust.position = nebulaBeastDustRotation + nebulaBeastDustVelocity * 20f; - nebulaBeastDust.velocity = -nebulaBeastDustVelocity * 2f; - nebulaBeastDust.scale = 0.5f + nebulaBeastDustVelocity.X * (float)(-(float)npc.spriteDirection); - nebulaBeastDust.fadeIn = 1f; - nebulaBeastDust.noGravity = true; - } - else if (npc.ai[1] == 30f) - { - for (int l = 0; l < 20; l++) - { - Vector2 nebulaBeastDustRotation2 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; - Dust nebulaBeastDust2 = Main.dust[Dust.NewDust(nebulaBeastDustRotation2, 0, 0, DustID.PinkTorch, 0f, 0f, 0, default(Color), 1f)]; - Vector2 nebulaBeastDustVelocity2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - nebulaBeastDust2.position = nebulaBeastDustRotation2 + nebulaBeastDustVelocity2 * 4f; - nebulaBeastDust2.velocity = nebulaBeastDustVelocity2 * 4f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * -5f; - nebulaBeastDust2.scale = 0.5f + nebulaBeastDustVelocity2.X * (float)(-(float)npc.spriteDirection); - nebulaBeastDust2.fadeIn = 1f; - nebulaBeastDust2.noGravity = true; - } - } - - if (npc.velocity.X > -0.5f && npc.velocity.X < 0.5f) - { - npc.velocity.X = 0f; - } - - if (npc.ai[1] == 30f && Main.netMode != NetmodeID.MultiplayerClient) - { - int nebulaBeastProjDamage = Main.expertMode ? 35 : 50; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (float)(npc.spriteDirection * -20), npc.Center.Y, (float)(npc.spriteDirection * -7), 0f, ProjectileID.NebulaSphere, nebulaBeastProjDamage, 0f, Main.myPlayer, (float)npc.target, 0f); - } - - if (npc.ai[1] >= 60f) - { - npc.ai[1] = (float)(-(float)Main.rand.Next(320, CalamityWorld.death ? 361 : 601)); - npc.ai[2] = 0f; - } - } - else - { - npc.ai[1] += 1f; - if (npc.ai[1] >= 180f && targetDistance < 500f && npc.velocity.Y == 0f) - { - flag = true; - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.netUpdate = true; - } - else if (npc.velocity.Y == 0f && targetDistance < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) - { - npc.velocity.Y = npc.velocity.Y - 6f; - } - } - } - else if (npc.type == NPCID.Wolf || npc.type == NPCID.Hellhound || npc.type == ModContent.NPCType()) - { - if (npc.velocity.Y == 0f && targetDistance < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X > 0f) || (npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X < 0f))) - { - npc.velocity.Y -= 6f; - } - } - - else if (npc.type == NPCID.Tumbleweed && npc.velocity.Y == 0f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) - { - npc.velocity.Y -= 6f; - SoundEngine.PlaySound(SoundID.NPCHit11, npc.Center); - } - - if (npc.ai[3] < (float)turnAroundDelay) - { - if ((npc.type == NPCID.Hellhound || npc.type == NPCID.HeadlessHorseman) && !Main.pumpkinMoon) - { - if (npc.timeLeft > 10) - { - npc.timeLeft = 10; - } - } - else - { - npc.TargetClosest(true); - } - } - else - { - if (npc.velocity.X == 0f) - { - if (npc.velocity.Y == 0f) - { - npc.ai[0] += 1f; - if (npc.ai[0] >= 2f) - { - npc.direction *= -1; - npc.spriteDirection = npc.direction; - npc.ai[0] = 0f; - } - } - } - else - { - npc.ai[0] = 0f; - } - npc.directionY = -1; - if (npc.direction == 0) - { - npc.direction = 1; - } - } - - float maxVelocity = 9f; - float acceleration = 0.1f; - if (CalamityWorld.death) - { - maxVelocity *= 1.25f; - acceleration *= 1.25f; - } - - if (!flag && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction < 0) || (npc.velocity.X >= 0f && npc.direction > 0))) - { - if (npc.type == ModContent.NPCType()) - { - npc.velocity.X *= 0.99f; - } - if (npc.type == NPCID.Wolf) - { - if (npc.velocity.X > 0f && npc.direction < 0) - { - npc.velocity.X *= 0.9f; - } - if (npc.velocity.X < 0f && npc.direction > 0) - { - npc.velocity.X *= 0.9f; - } - } - else if (npc.type == NPCID.Hellhound) - { - if (npc.velocity.X > 0f && npc.direction < 0) - { - npc.velocity.X *= 0.2f; - } - if (npc.velocity.X < 0f && npc.direction > 0) - { - npc.velocity.X *= 0.2f; - } - if (npc.direction > 0 && npc.velocity.X < 3f) - { - npc.velocity.X += 0.15f; - } - if (npc.direction < 0 && npc.velocity.X > -3f) - { - npc.velocity.X -= 0.15f; - } - } - else if (npc.type == NPCID.HeadlessHorseman) - { - if (npc.velocity.X > 0f && npc.direction < 0) - { - npc.velocity.X *= 0.9f; - } - if (npc.velocity.X < 0f && npc.direction > 0) - { - npc.velocity.X *= 0.9f; - } - if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < maxVelocity && npc.direction == 1) - { - npc.velocity.X += 0.1f; - if (npc.velocity.X > maxVelocity) - { - npc.velocity.X = maxVelocity; - } - } - else if (npc.velocity.X > -maxVelocity && npc.direction == -1) - { - npc.velocity.X -= 0.1f; - if (npc.velocity.X < -maxVelocity) - { - npc.velocity.X = -maxVelocity; - } - } - } - else if (npc.type == NPCID.StardustSpiderSmall) - { - if (Math.Sign(npc.velocity.X) != npc.direction) - { - npc.velocity.X *= 0.8f; - } - acceleration = 0.2f; - } - else if (npc.type == NPCID.NebulaBeast) - { - if (Math.Sign(npc.velocity.X) != npc.direction) - { - npc.velocity.X *= 0.8f; - } - maxVelocity = 12f; - acceleration = 0.2f; - } - else if (npc.type == NPCID.Tumbleweed) - { - if (Math.Sign(npc.velocity.X) != npc.direction) - { - npc.velocity.X *= 0.9f; - } - float sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); - if (!Main.player[npc.target].ZoneSandstorm) - { - sandstormPush = 0f; - } - maxVelocity = 6f + sandstormPush * (float)npc.direction * 4f; - acceleration = 0.2f; - } - if (CalamityWorld.death) - { - maxVelocity *= 1.25f; - acceleration *= 1.25f; - } - if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < maxVelocity && npc.direction == 1) - { - npc.velocity.X = npc.velocity.X + acceleration; - if (npc.velocity.X > maxVelocity) - { - npc.velocity.X = maxVelocity; - } - } - else if (npc.velocity.X > -maxVelocity && npc.direction == -1) - { - npc.velocity.X = npc.velocity.X - acceleration; - if (npc.velocity.X < -maxVelocity) - { - npc.velocity.X = -maxVelocity; - } - } - } - - if (npc.velocity.Y >= 0f) - { - int faceDirection = 0; - if (npc.velocity.X < 0f) - { - faceDirection = -1; - } - if (npc.velocity.X > 0f) - { - faceDirection = 1; - } - - Vector2 position = npc.position; - position.X += npc.velocity.X; - int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); - int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - - if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - faceDirection, y - 3].TileType])) - { - float tilePixelPosition = (float)(y * 16); - if (Main.tile[x, y].IsHalfBlock) - { - tilePixelPosition += 8f; - } - if (Main.tile[x, y - 1].IsHalfBlock) - { - tilePixelPosition -= 8f; - } - if (tilePixelPosition < position.Y + (float)npc.height) - { - float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; - if ((double)percentageTileRisen <= 16.1) - { - npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; - npc.position.Y = tilePixelPosition - (float)npc.height; - if (percentageTileRisen < 9f) - { - npc.stepSpeed = 1f; - } - else - { - npc.stepSpeed = 2f; - } - } - } - } - } - - if (npc.velocity.Y == 0f) - { - int npcTileX = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); - int npcTileY = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - - int spriteDirection = npc.spriteDirection; - if (npc.type == NPCID.NebulaBeast || npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.Tumbleweed) - { - spriteDirection *= -1; - } - - if ((npc.velocity.X < 0f && spriteDirection == -1) || (npc.velocity.X > 0f && spriteDirection == 1)) - { - bool pillarEnemy = npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.NebulaBeast; - - if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 2].TileType]) - { - if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 3].TileType]) - { - npc.velocity.Y = -10.5f; - npc.netUpdate = true; - } - else - { - npc.velocity.Y = -9.5f; - npc.netUpdate = true; - } - } - else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 1].TileType]) - { - npc.velocity.Y = -9f; - npc.netUpdate = true; - } - else if (npc.position.Y + (float)npc.height - (float)(npcTileY * 16) > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType]) - { - npc.velocity.Y = -7f; - npc.netUpdate = true; - } - else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > 3f) && (!pillarEnemy || !Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + npc.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX + npc.direction, npcTileY + 3].TileType])) - { - npc.velocity.Y = -10f; - npc.netUpdate = true; - } - } - } - - if (npc.type == NPCID.NebulaBeast && Math.Abs(npc.velocity.X) >= maxVelocity * 0.95f) - { - Rectangle hitbox = npc.Hitbox; - for (int m = 0; m < 2; m++) - { - if (Main.rand.NextBool(3)) - { - Dust nebulaBeastIdleDust = Main.dust[Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, DustID.PinkTorch, 0f, 0f, 0, default(Color), 1f)]; - nebulaBeastIdleDust.velocity = Vector2.Zero; - nebulaBeastIdleDust.noGravity = true; - nebulaBeastIdleDust.fadeIn = 1f; - nebulaBeastIdleDust.scale = 0.5f + Main.rand.NextFloat(); - } - } - } - - if (npc.type == NPCID.Tumbleweed) - { - npc.rotation += npc.velocity.X * 0.05f; - npc.spriteDirection = -npc.direction; - } - - return false; - } - #endregion - - #region Tortoise AI - public static bool BuffedTortoiseAI(NPC npc, Mod mod) - { - if (npc.target < 0 || Main.player[npc.target].dead || npc.direction == 0) - { - npc.TargetClosest(true); - } - - int turtleFaceDirection = 0; - if (npc.velocity.X < 0f) - { - turtleFaceDirection = -1; - } - if (npc.velocity.X > 0f) - { - turtleFaceDirection = 1; - } - - Vector2 position = npc.position; - position.X += npc.velocity.X; - int turtleTileX = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * turtleFaceDirection)) / 16f); - int turtleTileY = (int)((position.Y + (float)npc.height - 1f) / 16f); - - if ((float)(turtleTileX * 16) < position.X + (float)npc.width && (float)(turtleTileX * 16 + 16) > position.X && ((Main.tile[turtleTileX, turtleTileY].HasUnactuatedTile && !Main.tile[turtleTileX, turtleTileY].TopSlope && !Main.tile[turtleTileX, turtleTileY - 1].TopSlope && ((Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY].TileType] && !Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType]) || (Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType] && (!Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || !Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile) && Main.tile[turtleTileX, turtleTileY].TileType != 16 && Main.tile[turtleTileX, turtleTileY].TileType != 18 && Main.tile[turtleTileX, turtleTileY].TileType != 134))) || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile)) && (!Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && (!Main.tile[turtleTileX, turtleTileY - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType]))) && (!Main.tile[turtleTileX, turtleTileY - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType]) && (!Main.tile[turtleTileX, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType]) && (!Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType])) - { - float tilePixelPosition = (float)(turtleTileY * 16); - if (Main.tile[turtleTileX, turtleTileY].IsHalfBlock) - { - tilePixelPosition += 8f; - } - if (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock) - { - tilePixelPosition -= 8f; - } - - if (tilePixelPosition < position.Y + (float)npc.height) - { - float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; - if ((double)percentageTileRisen <= 16.1) - { - npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; - npc.position.Y = tilePixelPosition - (float)npc.height; - if (percentageTileRisen < 9f) - { - npc.stepSpeed = 0.75f; - } - else - { - npc.stepSpeed = 1.5f; - } - } - } - } - - if (npc.type == NPCID.IceTortoise && Main.rand.NextBool(10)) - { - int iceTortoiseDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.IceRod, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[iceTortoiseDust].noGravity = true; - Dust dust = Main.dust[iceTortoiseDust]; - dust.velocity *= 0.2f; - } - - if (npc.ai[0] == 0f) - { - if (npc.velocity.X < 0f) - { - npc.direction = -1; - } - else if (npc.velocity.X > 0f) - { - npc.direction = 1; - } - - npc.spriteDirection = npc.direction; - - Vector2 tortoisePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float tortoiseTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - tortoisePosition.X; - float tortoiseTargetY = Main.player[npc.target].position.Y - tortoisePosition.Y; - float tortoiseTargetDist = (float)Math.Sqrt((double)(tortoiseTargetX * tortoiseTargetX + tortoiseTargetY * tortoiseTargetY)); - - bool canHitPlayer = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) - { - if (tortoiseTargetDist > 200f & canHitPlayer) - { - npc.ai[1] += 3f; - } - if (tortoiseTargetDist > 600f && (canHitPlayer || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) - { - npc.ai[1] += 6f; - } - } - else - { - if (tortoiseTargetDist > 200f & canHitPlayer) - { - npc.ai[1] += 6f; - } - if (tortoiseTargetDist > 600f && (canHitPlayer || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) - { - npc.ai[1] += 15f; - } - } - - if (npc.wet) - { - npc.ai[1] = 1000f; - } - - npc.defense = npc.defDefense; - - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) - { - npc.knockBackResist = 0.5f; - } - else - { - npc.knockBackResist = 0.15f; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= (CalamityWorld.death ? 400f : 500f)) - { - npc.ai[1] = 0f; - npc.ai[0] = 1f; - } - - if (!npc.justHit && npc.velocity.X != npc.oldVelocity.X) - { - npc.direction *= -1; - } - - if (npc.velocity.Y == 0f && Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) - { - int tortoiseLeftTileX; - int tortoiseRightTileX; - if (npc.direction > 0) - { - tortoiseLeftTileX = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); - tortoiseRightTileX = tortoiseLeftTileX + 3; - } - else - { - tortoiseRightTileX = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); - tortoiseLeftTileX = tortoiseRightTileX - 3; - } - - int tortoiseBotTileY = (int)((npc.position.Y + (float)npc.height + 2f) / 16f) - 1; - int tortoiseTopTileY = tortoiseBotTileY + 4; - bool onSolidTile = false; - for (int x = tortoiseLeftTileX; x <= tortoiseRightTileX; x++) - { - for (int y = tortoiseBotTileY; y <= tortoiseTopTileY; y++) - { - if (Main.tile[x, y] != null && Main.tile[x, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y].TileType]) - { - onSolidTile = true; - } - } - } - - if (!onSolidTile) - { - npc.direction *= -1; - npc.velocity.X = 0.1f * (float)npc.direction; - } - } - - if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) - { - float giantShellyMaxVel = 1f; - if (npc.velocity.X < -giantShellyMaxVel || npc.velocity.X > giantShellyMaxVel) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < giantShellyMaxVel && npc.direction == 1) - { - npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X > giantShellyMaxVel) - { - npc.velocity.X = giantShellyMaxVel; - } - } - else if (npc.velocity.X > -giantShellyMaxVel && npc.direction == -1) - { - npc.velocity.X = npc.velocity.X - 0.1f; - if (npc.velocity.X < -giantShellyMaxVel) - { - npc.velocity.X = -giantShellyMaxVel; - } - } - } - else - { - float tortoiseMaxVel = 2f; - if (tortoiseTargetDist < 400f) - { - if (npc.velocity.X < -tortoiseMaxVel || npc.velocity.X > tortoiseMaxVel) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < tortoiseMaxVel && npc.direction == 1) - { - npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X > tortoiseMaxVel) - { - npc.velocity.X = tortoiseMaxVel; - } - } - else if (npc.velocity.X > -tortoiseMaxVel && npc.direction == -1) - { - npc.velocity.X = npc.velocity.X - 0.1f; - if (npc.velocity.X < -tortoiseMaxVel) - { - npc.velocity.X = -tortoiseMaxVel; - } - } - } - else if (npc.velocity.X < -3f || npc.velocity.X > 3f) - { - if (npc.velocity.Y == 0f) - { - npc.velocity *= 0.8f; - } - } - else if (npc.velocity.X < 3f && npc.direction == 1) - { - npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X > 3f) - { - npc.velocity.X = 3f; - } - } - else if (npc.velocity.X > -3f && npc.direction == -1) - { - npc.velocity.X = npc.velocity.X - 0.1f; - if (npc.velocity.X < -3f) - { - npc.velocity.X = -3f; - } - } - } - } - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.X = npc.velocity.X * 0.5f; - - if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) - { - npc.ai[1] += 1f; - } - else - { - npc.ai[1] += 2f; - } - - if (npc.ai[1] >= 30f) - { - npc.netUpdate = true; - npc.TargetClosest(true); - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[0] = 3f; - - if (npc.type == NPCID.SolarSroller) - { - npc.ai[0] = 6f; - npc.ai[2] = (float)Main.rand.Next(2, 5); - } - } - } - else - { - if (npc.ai[0] == 3f) - { - if (npc.type == NPCID.IceTortoise && Main.rand.Next(3) < 2) - { - int iceTortoiseSpinDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.IceRod, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[iceTortoiseSpinDust].noGravity = true; - Dust dust = Main.dust[iceTortoiseSpinDust]; - dust.velocity *= 0.2f; - } - - if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) - { - npc.damage = (int)Math.Round(npc.defDamage * 1.2); - } - else - { - npc.damage = (int)Math.Round(npc.defDamage * 1.4); - } - - npc.defense = npc.defDefense * 2; - - npc.ai[1] += 1f; - if (npc.ai[1] == 1f) - { - npc.netUpdate = true; - npc.TargetClosest(true); - - npc.ai[2] += 0.3f; - npc.rotation += npc.ai[2] * (float)npc.direction; - npc.ai[1] += 1f; - - bool spinAttackCanHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - float spinAttackSpeed = 15f; - if (!spinAttackCanHit) - { - spinAttackSpeed = 6f; - } - if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) - { - spinAttackSpeed *= 0.75f; - } - - Vector2 spinAttackPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float spinAttackTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - spinAttackPosition.X; - float absoluteSpinTargetX = Math.Abs(spinAttackTargetX) * 0.2f; - if (npc.directionY > 0) - { - absoluteSpinTargetX = 0f; - } - float spinAttackTargetY = Main.player[npc.target].position.Y - spinAttackPosition.Y - absoluteSpinTargetX; - float spinAttackTargetDist = (float)Math.Sqrt((double)(spinAttackTargetX * spinAttackTargetX + spinAttackTargetY * spinAttackTargetY)); - npc.netUpdate = true; - - spinAttackTargetDist = spinAttackSpeed / spinAttackTargetDist; - spinAttackTargetX *= spinAttackTargetDist; - spinAttackTargetY *= spinAttackTargetDist; - - if (!spinAttackCanHit) - { - spinAttackTargetY = -10f; - } - - npc.velocity.X = spinAttackTargetX; - npc.velocity.Y = spinAttackTargetY; - npc.ai[3] = npc.velocity.X; - } - else - { - if (npc.position.X + (float)npc.width > Main.player[npc.target].position.X && npc.position.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width && npc.position.Y < Main.player[npc.target].position.Y + (float)Main.player[npc.target].height) - { - npc.velocity.X = npc.velocity.X * 0.8f; - npc.ai[3] = 0f; - if (npc.velocity.Y < 0f) - { - npc.velocity.Y = npc.velocity.Y + 0.3f; - } - } - - if (npc.ai[3] != 0f) - { - npc.velocity.X = npc.ai[3]; - npc.velocity.Y = npc.velocity.Y - 0.33f; - } - - if (npc.ai[1] >= 90f) - { - npc.noGravity = false; - npc.ai[1] = 0f; - npc.ai[0] = 4f; - } - } - - if (npc.wet && npc.directionY < 0) - { - npc.velocity.Y = npc.velocity.Y - 0.45f; - } - - npc.rotation += npc.ai[2] * (float)npc.direction; - - return false; - } - - if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - if (npc.wet && npc.directionY < 0) - { - npc.velocity.Y = npc.velocity.Y - 0.45f; - } - - npc.velocity.X = npc.velocity.X * 0.95f; - - if (npc.ai[2] > 0f) - { - npc.ai[2] -= 0.01f; - npc.rotation += npc.ai[2] * (float)npc.direction; - } - else if (npc.velocity.Y >= 0f) - { - npc.rotation = 0f; - } - - if (npc.ai[2] <= 0f && (npc.velocity.Y == 0f || npc.wet)) - { - npc.netUpdate = true; - npc.rotation = 0f; - npc.ai[2] = 0f; - npc.ai[1] = 0f; - npc.ai[0] = 5f; - } - } - else - { - if (npc.ai[0] == 6f) - { - npc.damage = (int)Math.Round(npc.defDamage * 1.2); - npc.defense = npc.defDefense * 2; - npc.knockBackResist = 0f; - - if (Main.rand.Next(3) < 2) - { - int spinAttackDust = Dust.NewDust(npc.Center - new Vector2(30f), 60, 60, DustID.Torch, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Dust dust = Main.dust[spinAttackDust]; - dust.noGravity = true; - dust.velocity *= 0.2f; - dust.fadeIn = 1f; - } - - npc.ai[1] += 1f; - if (npc.ai[3] > 0f) - { - if (npc.ai[3] == 1f) - { - Vector2 vector68 = npc.Center - new Vector2(50f); - for (int i = 0; i < 32; i++) - { - int spinEndDust = Dust.NewDust(vector68, 100, 100, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[spinEndDust]; - dust.noGravity = true; - dust.velocity *= 3f; - spinEndDust = Dust.NewDust(vector68, 100, 100, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f); - dust.velocity *= 2f; - dust.noGravity = true; - } - - if (!Main.dedServ) - { - for (int j = 0; j < 4; j++) - { - int spinEndGore = Gore.NewGore(npc.GetSource_FromAI(), vector68 + new Vector2((float)(50 * Main.rand.Next(100)) / 100f, (float)(50 * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[spinEndGore]; - gore.velocity *= 0.3f; - gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; - gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; - } - } - } - - for (int k = 0; k < 5; k++) - { - int moreSpinEndDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[moreSpinEndDust].velocity *= Main.rand.NextFloat(); - } - - npc.ai[3] += 1f; - if (npc.ai[3] >= 10f) - { - npc.ai[3] = 0f; - } - } - - if (npc.ai[1] == 1f) - { - npc.netUpdate = true; - npc.TargetClosest(true); - - bool spinAboveCanHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - float spinAboveSpeed = 24f; - if (!spinAboveCanHit) - { - spinAboveSpeed = 10f; - } - - Vector2 vector69 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float spinAboveTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector69.X; - float absoluteSpinAboveTargetX = Math.Abs(spinAboveTargetX) * 0.2f; - if (npc.directionY > 0) - { - absoluteSpinAboveTargetX = 0f; - } - float spinAboveTargetY = Main.player[npc.target].position.Y - vector69.Y - absoluteSpinAboveTargetX; - float spinAboveTargetDist = (float)Math.Sqrt((double)(spinAboveTargetX * spinAboveTargetX + spinAboveTargetY * spinAboveTargetY)); - npc.netUpdate = true; - - spinAboveTargetDist = spinAboveSpeed / spinAboveTargetDist; - spinAboveTargetX *= spinAboveTargetDist; - spinAboveTargetY *= spinAboveTargetDist; - - if (!spinAboveCanHit) - { - spinAboveTargetY = -12f; - } - - npc.velocity.X = spinAboveTargetX; - npc.velocity.Y = spinAboveTargetY; - } - else - { - if (npc.position.X + (float)npc.width > Main.player[npc.target].position.X && npc.position.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width && npc.position.Y < Main.player[npc.target].position.Y + (float)Main.player[npc.target].height) - { - npc.velocity.X = npc.velocity.X * 0.9f; - if (npc.velocity.Y < 0f) - { - npc.velocity.Y = npc.velocity.Y + 0.3f; - } - } - - if (npc.ai[2] == 0f || npc.ai[1] >= 1200f) - { - npc.ai[1] = 0f; - npc.ai[0] = 5f; - } - } - - if (npc.wet && npc.directionY < 0) - { - npc.velocity.Y = npc.velocity.Y - 0.45f; - } - - npc.rotation += MathHelper.Clamp(npc.velocity.X / 10f * (float)npc.direction, -0.314159274f, 0.314159274f); - - return false; - } - - if (npc.ai[0] == 5f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.rotation = 0f; - npc.velocity.X = 0f; - - if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) - { - npc.ai[1] += 1f; - } - else - { - npc.ai[1] += 2f; - } - - if (npc.ai[1] >= 30f) - { - npc.TargetClosest(true); - npc.netUpdate = true; - npc.ai[1] = 0f; - npc.ai[0] = 0f; - } - - if (npc.wet) - { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - } - } - } - } - - return false; - } - #endregion - - #region Spider AI - public static bool BuffedSpiderAI(NPC npc, Mod mod) - { - //Find a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - - float speed = 2.5f; - float mvtAdjust = 0.1f; - if (npc.type == NPCID.DesertScorpionWall) - { - speed = 5f; - mvtAdjust = 0.2f; - } - if (CalamityWorld.death) - { - speed *= 1.25f; - mvtAdjust *= 1.25f; - } - - //Calculate how to reach the target - Vector2 npcPos = npc.Center; - Vector2 targetPos = Main.player[npc.target].Center; - targetPos.X = (float)((int)(targetPos.X / 8f) * 8); - targetPos.Y = (float)((int)(targetPos.Y / 8f) * 8); - npcPos.X = (float)((int)(npcPos.X / 8f) * 8); - npcPos.Y = (float)((int)(npcPos.Y / 8f) * 8); - targetPos.X -= npcPos.X; - targetPos.Y -= npcPos.Y; - float targetDist = targetPos.Length(); - if (targetDist == 0f) - { - targetPos.X = npc.velocity.X; - targetPos.Y = npc.velocity.Y; - } - else - { - targetDist = speed / targetDist; - targetPos.X *= targetDist; - targetPos.Y *= targetDist; - } - - //If the target is dead, nobody cares - if (Main.player[npc.target].dead) - { - targetPos.X = (float)npc.direction * speed / 2f; - targetPos.Y = -speed / 2f; - } - - //Sprite direction - npc.spriteDirection = -1; - - //If you can't see the target, wander around - if (!Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - npc.ai[0] += 1f; - if (npc.ai[0] > 0f) - { - npc.velocity.Y += 0.023f; - } - else - { - npc.velocity.Y -= 0.023f; - } - if (npc.ai[0] < -100f || npc.ai[0] > 100f) - { - npc.velocity.X += 0.023f; - } - else - { - npc.velocity.X -= 0.023f; - } - if (npc.ai[0] > 200f) - { - npc.ai[0] = -200f; - } - npc.velocity.X += targetPos.X * 0.009f; - npc.velocity.Y += targetPos.Y * 0.009f; - npc.rotation = npc.velocity.ToRotation(); - if (npc.velocity.X > 2.5f) - { - npc.velocity.X *= 0.9f; - } - if (npc.velocity.X < -2.5f) - { - npc.velocity.X *= 0.9f; - } - if (npc.velocity.Y > 2.5f) - { - npc.velocity.Y *= 0.9f; - } - if (npc.velocity.Y < -2.5f) - { - npc.velocity.Y *= 0.9f; - } - npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -4f, 4f); - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -4f, 4f); - } - //If target is in sight, move toward target - else - { - if (npc.velocity.X < targetPos.X) - { - npc.velocity.X += mvtAdjust; - if (npc.velocity.X < 0f && targetPos.X > 0f) - { - npc.velocity.X += mvtAdjust; - } - } - else if (npc.velocity.X > targetPos.X) - { - npc.velocity.X -= mvtAdjust; - if (npc.velocity.X > 0f && targetPos.X < 0f) - { - npc.velocity.X -= mvtAdjust; - } - } - if (npc.velocity.Y < targetPos.Y) - { - npc.velocity.Y += mvtAdjust; - if (npc.velocity.Y < 0f && targetPos.Y > 0f) - { - npc.velocity.Y += mvtAdjust; - } - } - else if (npc.velocity.Y > targetPos.Y) - { - npc.velocity.Y -= mvtAdjust; - if (npc.velocity.Y > 0f && targetPos.Y < 0f) - { - npc.velocity.Y -= mvtAdjust; - } - } - npc.rotation = targetPos.ToRotation(); - } - - //Desert Scorpion has a different sprite orientation - if (npc.type == NPCID.DesertScorpionWall) - { - npc.rotation += MathHelper.PiOver2; - } - - //Wall collision behavior? - float half = 0.5f; - if (npc.collideX) - { - npc.netUpdate = true; - npc.velocity.X = npc.oldVelocity.X * -half; - if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) - { - npc.velocity.X = 2f; - } - if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) - { - npc.velocity.X = -2f; - } - } - if (npc.collideY) - { - npc.netUpdate = true; - npc.velocity.Y = npc.oldVelocity.Y * -half; - if (npc.velocity.Y > 0f && npc.velocity.Y < 1.5f) - { - npc.velocity.Y = 2f; - } - if (npc.velocity.Y < 0f && npc.velocity.Y > -1.5f) - { - npc.velocity.Y = -2f; - } - } - - // Net update for changing directions - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - { - npc.netUpdate = true; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - bool prehardmodeSpiders = (npc.type == NPCID.WallCreeper || npc.type == NPCID.WallCreeperWall || npc.type == NPCID.BloodCrawler || npc.type == NPCID.BloodCrawlerWall) && CalamityWorld.revenge; - if (npc.target >= 0 && Main.expertMode && (npc.type == NPCID.BlackRecluse || npc.type == NPCID.BlackRecluseWall || npc.type == NPCID.JungleCreeper || npc.type == NPCID.JungleCreeperWall || prehardmodeSpiders) && - Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.localAI[0] += 1f; - if (npc.justHit) - npc.localAI[0] = 0f; - - float webSpitGateValue = CalamityWorld.death ? SpiderWebSpitGateValue_Death : CalamityWorld.revenge ? SpiderWebSpitGateValue_Rev : SpiderWebSpitGateValue; - - // Emit web dust from mouth when about to fire - if (npc.localAI[0] > webSpitGateValue - SpiderWebSpitTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.Center, 1, 1, DustID.Web, 0f, 0f, 100, default, 1.5f); - dust.noGravity = true; - dust.velocity *= 0f; - } - - if (npc.localAI[0] >= webSpitGateValue) - { - npc.localAI[0] = 0f; - Vector2 velocity = Main.player[npc.target].Center - npc.Center; - velocity.Normalize(); - velocity *= prehardmodeSpiders ? 5f : 8f; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, velocity, ProjectileID.WebSpit, 18, 0f, Main.myPlayer); - } - } - else - npc.localAI[0] = 0f; - - // Check for walls - int npcX = (int)npc.Center.X / 16; - int npcY = (int)npc.Center.Y / 16; - bool climbingWall = false; - for (int i = npcX - 1; i <= npcX + 1; i++) - { - for (int j = npcY - 1; j <= npcY + 1; j++) - { - if (Main.tile[i, j].WallType > 0) - { - climbingWall = true; - } - } - } - //If not on a wall, transform to fighter form - if (!climbingWall) - { - if (npc.type == NPCID.JungleCreeperWall) - { - npc.Transform(NPCID.JungleCreeper); - return false; - } - if (npc.type == NPCID.BlackRecluseWall) - { - npc.Transform(NPCID.BlackRecluse); - return false; - } - if (npc.type == NPCID.BloodCrawlerWall) - { - npc.Transform(NPCID.BloodCrawler); - return false; - } - if (npc.type == NPCID.DesertScorpionWall) - { - npc.Transform(NPCID.DesertScorpionWalk); - return false; - } - npc.Transform(NPCID.WallCreeper); - } - } - return false; - } - #endregion - - #region Herpling AI - public static bool BuffedHerplingAI(NPC npc, Mod mod) - { - if (npc.ai[2] > 1f) - { - npc.ai[2] -= 1f; - } - - if (npc.ai[2] == 0f) - { - npc.ai[0] = -100f; - npc.ai[2] = 1f; - npc.TargetClosest(true); - npc.spriteDirection = npc.direction; - } - - if (npc.type == NPCID.ChatteringTeethBomb) - { - Vector2 dustOffset = new Vector2(-6f, -10f); - dustOffset.X *= npc.spriteDirection; - if (npc.ai[1] != 5f && Main.rand.NextBool(3)) - { - npc.position += npc.netOffset; - int dustID = Dust.NewDust(npc.Center + dustOffset - Vector2.One * 5f, 4, 4, DustID.Torch); - Dust dust = Main.dust[dustID]; - dust.scale = 1.5f; - dust.noGravity = true; - dust.velocity = dust.velocity * 0.25f + Vector2.Normalize(dustOffset) * 1f; - dust.velocity = dust.velocity.RotatedBy(-(float)Math.PI / 2f * (float)npc.direction); - npc.position -= npc.netOffset; - } - if (npc.ai[1] == 5f) - { - npc.velocity = Vector2.Zero; - npc.position.X += npc.width / 2; - npc.position.Y += npc.height / 2; - npc.width = 160; - npc.height = 160; - npc.position.X -= npc.width / 2; - npc.position.Y -= npc.height / 2; - npc.dontTakeDamage = true; - npc.position += npc.netOffset; - if (npc.ai[2] > 7f) - { - for (int i = 0; i < 8; i++) - { - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); - } - for (int i = 0; i < 32; i++) - { - int dustID = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[dustID]; - dust.velocity *= 3f; - dust.noGravity = true; - dustID = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f); - dust = Main.dust[dustID]; - dust.velocity *= 2f; - dust.noGravity = true; - } - for (int i = 0; i < 2; i++) - { - int goreID = Gore.NewGore(npc.GetSource_FromThis(), npc.position + new Vector2((float)(npc.width * Main.rand.Next(100)) / 100f, (float)(npc.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(GoreID.Smoke1, GoreID.Smoke3 + 1)); - Gore gore = Main.gore[goreID]; - gore.velocity *= 0.3f; - gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; - gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; - } - if (npc.ai[2] == 9f) - { - SoundEngine.PlaySound(SoundID.Item14, npc.position); - } - } - if (npc.ai[2] == 1f) - { - npc.life = -1; - npc.HitEffect(); - npc.active = false; - } - npc.position -= npc.netOffset; - return false; - } - } - - if (npc.type == NPCID.ChatteringTeethBomb && npc.ai[1] != 5f) - { - if (npc.wet || Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 64f) - { - npc.ai[1] = 5f; - npc.ai[2] = 10f; - npc.netUpdate = true; - return false; - } - } - else if (npc.wet && npc.type != NPCID.Derpling) - { - if (npc.collideX) - { - npc.direction *= -1; // Fixed bug where herplings didn't change direction from left to right - npc.spriteDirection = npc.direction; - } - - if (npc.collideY) - { - npc.TargetClosest(true); - - if (npc.oldVelocity.Y < 0f) - { - npc.velocity.Y = 5f; - } - else - { - npc.velocity.Y = npc.velocity.Y - 2f; - } - - npc.spriteDirection = npc.direction; - } - - if (npc.velocity.Y > 4f) - { - npc.velocity.Y = npc.velocity.Y * 0.9f; - } - - npc.velocity.Y = npc.velocity.Y - 0.45f; - - if (npc.velocity.Y < -6f) - { - npc.velocity.Y = -6f; - } - } - - // Avoid cheap bullshit - npc.damage = (npc.velocity.Y == 0f || npc.velocity.Length() < 3f) ? 0 : npc.defDamage; - - if (npc.velocity.Y == 0f) - { - if (npc.ai[3] == npc.position.X) - { - npc.direction *= -1; - npc.ai[2] = 300f; - } - - npc.ai[3] = 0f; - - npc.velocity.X = npc.velocity.X * 0.8f; - if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) - { - npc.velocity.X = 0f; - } - - if (npc.type == NPCID.Derpling) - { - npc.ai[0] += 3f; - } - else - { - npc.ai[0] += 10f; - } - - Vector2 herplingPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float herplingTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - herplingPosition.X; - float herplingTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - herplingPosition.Y; - float herplingTargetDist = (float)Math.Sqrt((double)(herplingTargetX * herplingTargetX + herplingTargetY * herplingTargetY)); - float herplingJumpHeight = 400f / herplingTargetDist; - - if (npc.type == NPCID.Derpling) - { - herplingJumpHeight *= 5f; - } - else - { - herplingJumpHeight *= 10f; - } - - if (herplingJumpHeight > 30f) - { - herplingJumpHeight = 30f; - } - - npc.ai[0] += (float)((int)herplingJumpHeight); - - if (npc.ai[0] >= 0f) - { - npc.netUpdate = true; - - if (npc.ai[2] == 1f) - { - npc.TargetClosest(true); - } - - if (npc.type == NPCID.Derpling) - { - if (npc.ai[1] == 2f) - { - npc.velocity.Y = -14f; - npc.velocity.X = npc.velocity.X + 3f * (float)npc.direction; - if (herplingTargetDist < 350f && herplingTargetDist > 200f) - { - npc.velocity.X = npc.velocity.X + (float)npc.direction; - } - npc.ai[0] = CalamityWorld.death ? -100f : -200f; - npc.ai[1] = 0f; - npc.ai[3] = npc.position.X; - } - else - { - npc.velocity.Y = -10f; - npc.velocity.X = npc.velocity.X + (float)(5 * npc.direction); - if (herplingTargetDist < 350f && herplingTargetDist > 200f) - { - npc.velocity.X = npc.velocity.X + (float)npc.direction; - } - npc.ai[0] = CalamityWorld.death ? -60f : -120f; - npc.ai[1] += 1f; - } - } - else - { - if (npc.type == NPCID.ChatteringTeethBomb) - { - SoundEngine.PlaySound(SoundID.Zombie124, npc.position); - } - if (npc.ai[1] == 3f) - { - npc.velocity.Y = -9f; - npc.velocity.X = npc.velocity.X + (float)(2 * npc.direction); - if (herplingTargetDist < 350f && herplingTargetDist > 200f) - { - npc.velocity.X = npc.velocity.X + (float)npc.direction; - } - npc.ai[0] = CalamityWorld.death ? -100f : -200f; - npc.ai[1] = 0f; - npc.ai[3] = npc.position.X; - } - else - { - npc.velocity.Y = -5f; - npc.velocity.X = npc.velocity.X + (float)(4 * npc.direction); - if (herplingTargetDist < 350f && herplingTargetDist > 200f) - { - npc.velocity.X = npc.velocity.X + (float)npc.direction; - } - npc.ai[0] = CalamityWorld.death ? -60f : -120f; - npc.ai[1] += 1f; - } - } - } - else if (npc.ai[0] >= -30f) - { - npc.aiAction = 1; - } - - npc.spriteDirection = npc.direction; - - return false; - } - - if (npc.target < Main.maxPlayers) - { - if (npc.type == NPCID.Derpling) - { - bool derplingDropOnTarget = false; - if (npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && npc.position.X + (float)npc.width > Main.player[npc.target].position.X && npc.position.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) - { - derplingDropOnTarget = true; - npc.velocity.X = npc.velocity.X * 0.9f; - if (npc.velocity.Y < 0f) - { - npc.velocity.Y = npc.velocity.Y * 0.9f; - npc.velocity.Y = npc.velocity.Y + 0.15f; - } - } - - if (!derplingDropOnTarget && ((npc.direction == 1 && npc.velocity.X < 4f) || (npc.direction == -1 && npc.velocity.X > -4f))) - { - if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) - { - npc.velocity.X = npc.velocity.X + 0.3f * (float)npc.direction; - return false; - } - npc.velocity.X = npc.velocity.X * 0.9f; - } - } - else if ((npc.direction == 1 && npc.velocity.X < 3f) || (npc.direction == -1 && npc.velocity.X > -3f)) - { - if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) - { - npc.velocity.X = npc.velocity.X + 0.3f * (float)npc.direction; - return false; - } - npc.velocity.X = npc.velocity.X * 0.9f; - } - } - - return false; - } - #endregion - - #region Flying Fish AI - public static bool BuffedFlyingFishAI(NPC npc, Mod mod) - { - npc.noGravity = true; - if (npc.collideX) - { - if (npc.oldVelocity.X > 0f) - { - npc.direction = -1; - } - else - { - npc.direction = 1; - } - npc.velocity.X = (float)npc.direction; - } - if (npc.collideY) - { - if (npc.oldVelocity.Y > 0f) - { - npc.directionY = -1; - } - else - { - npc.directionY = 1; - } - npc.velocity.Y = (float)npc.directionY; - } - if (npc.type == NPCID.EyeballFlyingFish) - { - npc.position += npc.netOffset; - if (npc.alpha == 255) - { - npc.velocity.Y = -6f; - npc.netUpdate = true; - for (int i = 0; i < 15; i++) - { - Dust eyeFishDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Blood); - Dust dust = eyeFishDust; - dust.velocity *= 0.5f; - eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; - eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust = eyeFishDust; - dust.velocity += npc.velocity * 0.5f; - } - } - - npc.alpha -= 15; - if (npc.alpha < 0) - npc.alpha = 0; - - if (npc.alpha != 0) - { - for (int j = 0; j < 2; j++) - { - Dust eyeFishDust2 = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Blood); - Dust dust = eyeFishDust2; - dust.velocity *= 1f; - eyeFishDust2.scale = 1f + Main.rand.NextFloat() * 0.5f; - eyeFishDust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust = eyeFishDust2; - dust.velocity += npc.velocity * 0.3f; - } - } - - if (Main.rand.NextBool(3)) - { - Dust eyeFishIdleDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Blood); - Dust dust = eyeFishIdleDust; - dust.velocity *= 0f; - eyeFishIdleDust.alpha = 120; - eyeFishIdleDust.scale = 0.7f + Main.rand.NextFloat() * 0.5f; - dust = eyeFishIdleDust; - dust.velocity += npc.velocity * 0.3f; - } - - npc.position -= npc.netOffset; - } - int fishTarget = npc.target; - int fishDirection = npc.direction; - if (npc.target == Main.maxPlayers || (Main.player[npc.target].wet && npc.type != NPCID.EyeballFlyingFish) || Main.player[npc.target].dead || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 90f; - npc.TargetClosest(true); - } - else if (npc.ai[0] > 0f) - { - npc.ai[0] -= 1f; - npc.TargetClosest(true); - } - if (npc.netUpdate && fishTarget == npc.target && fishDirection == npc.direction) - { - npc.netUpdate = false; - } - float acceleration = 0.05f; - float verticalAcceleration = 0.01f; - float maxVelocity = 6f; - float maxYSpeed = 3f; - float turnAroundXDist = 30f; - float turnAroundYDist = 100f; - float targetXDist = Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))); - float targetYDist = Main.player[npc.target].position.Y - (float)(npc.height / 2); - if (npc.type == NPCID.FlyingAntlion || npc.type == NPCID.GiantFlyingAntlion) - { - acceleration = 0.09f; - verticalAcceleration = 0.03f; - maxVelocity = 9f; - maxYSpeed = 6f; - turnAroundXDist = 40f; - turnAroundYDist = 150f; - targetYDist = Main.player[npc.target].Center.Y - (float)(npc.height / 2); - npc.rotation = npc.velocity.X * 0.1f; - int playerInc; - for (int p = 0; p < Main.maxNPCs; p = playerInc + 1) - { - if (p != npc.whoAmI && Main.npc[p].active && Main.npc[p].type == npc.type && Math.Abs(npc.position.X - Main.npc[p].position.X) + Math.Abs(npc.position.Y - Main.npc[p].position.Y) < (float)npc.width) - { - if (npc.position.X < Main.npc[p].position.X) - { - npc.velocity.X = npc.velocity.X - 0.05f; - } - else - { - npc.velocity.X = npc.velocity.X + 0.05f; - } - if (npc.position.Y < Main.npc[p].position.Y) - { - npc.velocity.Y = npc.velocity.Y - 0.05f; - } - else - { - npc.velocity.Y = npc.velocity.Y + 0.05f; - } - } - playerInc = p; - } - } - else if (npc.type == NPCID.EyeballFlyingFish) - { - acceleration = 0.16f; - verticalAcceleration = 0.12f; - maxVelocity = 9f; - maxYSpeed = 5f; - turnAroundXDist = 0f; - turnAroundYDist = 250f; - targetYDist = Main.player[npc.target].position.Y; - if (Main.dayTime) - { - targetYDist = 0f; - npc.direction *= -1; - } - } - if (CalamityWorld.death) - { - maxVelocity *= 1.25f; - acceleration *= 1.25f; - } - if (npc.ai[0] <= 0f) - { - maxVelocity *= 0.8f; - acceleration *= 0.7f; - targetYDist = npc.Center.Y + (float)(npc.directionY * 1000); - if (npc.velocity.X < 0f) - { - npc.direction = -1; - } - else if (npc.velocity.X > 0f || npc.direction == 0) - { - npc.direction = 1; - } - } - if (targetXDist > turnAroundXDist) - { - if (npc.direction == -1 && npc.velocity.X > -maxVelocity) - { - npc.velocity.X = npc.velocity.X - acceleration; - if (npc.velocity.X > maxVelocity) - { - npc.velocity.X = npc.velocity.X - acceleration; - } - else if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X - acceleration / 2f; - } - if (npc.velocity.X < -maxVelocity) - { - npc.velocity.X = -maxVelocity; - } - } - else if (npc.direction == 1 && npc.velocity.X < maxVelocity) - { - npc.velocity.X = npc.velocity.X + acceleration; - if (npc.velocity.X < -maxVelocity) - { - npc.velocity.X = npc.velocity.X + acceleration; - } - else if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X + acceleration / 2f; - } - if (npc.velocity.X > maxVelocity) - { - npc.velocity.X = maxVelocity; - } - } - } - if (targetXDist > turnAroundYDist) - { - targetYDist -= turnAroundYDist / 2f; - } - if (npc.position.Y < targetYDist) - { - npc.velocity.Y = npc.velocity.Y + verticalAcceleration; - if (npc.velocity.Y < 0f) - { - npc.velocity.Y = npc.velocity.Y + verticalAcceleration; - } - } - else - { - npc.velocity.Y = npc.velocity.Y - verticalAcceleration; - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y - verticalAcceleration; - } - } - if (npc.velocity.Y < -maxYSpeed) - { - npc.velocity.Y = -maxYSpeed; - } - if (npc.velocity.Y > maxYSpeed) - { - npc.velocity.Y = maxYSpeed; - } - if (npc.wet && npc.type != NPCID.EyeballFlyingFish) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y * 0.95f; - } - npc.velocity.Y = npc.velocity.Y - 0.7f; - if (npc.velocity.Y < -6f) - { - npc.velocity.Y = -6f; - } - } - return false; - } - #endregion - - #region Angry Nimbus AI - public static bool BuffedAngryNimbusAI(NPC npc, Mod mod) - { - npc.noGravity = true; - npc.TargetClosest(true); - float speed = CalamityWorld.death ? 9f : 6f; - float acceleration = CalamityWorld.death ? 0.3f : 0.25f; - - Vector2 idealVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center - 300f * Vector2.UnitY) * speed; - float playerDistance = npc.Distance(Main.player[npc.target].Center); - if (playerDistance < 20f) - idealVelocity = npc.velocity; - - // Yes, I understand that npc.SimpleFlyMovement exists. However, the "acceleration * 2f" is not a part of that method. - // It is not identical to what is being achieved here. - if (npc.velocity.X < idealVelocity.X) - { - npc.velocity.X += acceleration; - if (npc.velocity.X < 0f && idealVelocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + acceleration * 2f; - } - } - else if (npc.velocity.X > idealVelocity.X) - { - npc.velocity.X -= acceleration; - if (npc.velocity.X > 0f && idealVelocity.X < 0f) - { - npc.velocity.X -= acceleration * 2f; - } - } - if (npc.velocity.Y < idealVelocity.Y) - { - npc.velocity.Y += acceleration; - if (npc.velocity.Y < 0f && idealVelocity.Y > 0f) - { - npc.velocity.Y += acceleration * 2f; - } - } - else if (npc.velocity.Y > idealVelocity.Y) - { - npc.velocity.Y -= acceleration; - if (npc.velocity.Y > 0f && idealVelocity.Y < 0f) - { - npc.velocity.Y -= acceleration * 2f; - } - } - - // Make it rain - float minXRainDistance = CalamityWorld.death ? 200f : 150f; - if (npc.Center.X > Main.player[npc.target].position.X - minXRainDistance && - npc.position.X < Main.player[npc.target].Center.X + minXRainDistance && - npc.Center.Y < Main.player[npc.target].position.Y && - Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && - Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.justHit) - npc.ai[0] = 0f; - - npc.ai[0] += 1f; - if (npc.ai[0] % 8f == 0f) - { - Vector2 rainSpawnPosition = npc.position + new Vector2(10f + Main.rand.Next(npc.width - 20), npc.height + 4f); - - Projectile.NewProjectile(npc.GetSource_FromAI(), rainSpawnPosition, Vector2.UnitY * 5f, ProjectileID.RainNimbus, 20, 0f, Main.myPlayer, 0f, 0f); - if (npc.ai[0] % 16f == 0f) - { - float speedX = (float)Main.rand.NextFloat(CalamityWorld.death ? -6f : -3f, CalamityWorld.death ? 6f : 3f) * (Main.rand.NextFloat() - 0.5f); - Projectile.NewProjectile(npc.GetSource_FromAI(), rainSpawnPosition, new Vector2(speedX, 5f), ProjectileID.FrostShard, 20, 0f, Main.myPlayer, 0f, 0f); - } - } - if (npc.ai[0] >= 607f) - npc.ai[0] = 0f; - } - return false; - } - #endregion - - #region Spore AI - public static bool BuffedSporeAI(NPC npc, Mod mod) - { - if (npc.type == NPCID.Spore) - Lighting.AddLight(npc.Center, 0.5f, 0.2f, 0.5f); - - if (npc.timeLeft > 5) - npc.timeLeft = 5; - - npc.noTileCollide = true; - npc.velocity.Y += 0.02f; - - // Ensure slow fall - if (npc.velocity.Y > 1f) - npc.velocity.Y = 1f; - - // Use regular AI if not spawned by a Giant Plantera Bulb - if (npc.ai[0] != -1f) - { - npc.TargetClosest(true); - float acceleration = Main.masterMode ? 0.25f : Main.expertMode ? 0.2f : 0.1f; - float velocity = Main.masterMode ? 6f : Main.expertMode ? 5f : 3f; - if (CalamityWorld.death) - { - acceleration *= 1.25f; - velocity *= 1.25f; - } - - // Simple movement AI. You shouldn't need any help from comments to parse this. - if (npc.Center.X < Main.player[npc.target].position.X) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X *= 0.96f; - } - npc.velocity.X += acceleration; - } - else if (npc.position.X > Main.player[npc.target].Center.X) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X *= 0.96f; - } - npc.velocity.X -= acceleration; - } - if (npc.velocity.X > velocity || npc.velocity.X < -velocity) - { - npc.velocity.X *= 0.97f; - } - } - else - { - npc.velocity.X *= 0.98f; - npc.damage = npc.defDamage = 0; - } - - npc.rotation = npc.velocity.X * 0.2f; - - return false; - } - #endregion - - #region Tesla Turret AI - public static bool BuffedTeslaTurretAI(NPC npc, Mod mod) - { - npc.TargetClosest(false); - - npc.spriteDirection = npc.direction; - - npc.velocity.X *= 0.93f; - if (Math.Abs(npc.velocity.X) < 0.1f) - { - npc.velocity.X = 0f; - } - - float appearTime = 120f; - float alphaFadeinTime = 60f; - - // Spend the first "appearTime" frames sitting around and spawning. - if (npc.ai[1] < appearTime) - { - npc.ai[1] += 1f; - if (npc.ai[1] > appearTime - alphaFadeinTime) - { - float alphaRatio = (npc.ai[1] - alphaFadeinTime) / (appearTime - alphaFadeinTime); - npc.alpha = (int)((1f - alphaRatio) * 255f); - } - else - { - npc.alpha = 255; - } - - npc.dontTakeDamage = true; - - npc.frameCounter = 0.0; - npc.frame.Y = 0; - - // Circular dust - float angularRatio = npc.ai[1] / alphaFadeinTime; - Vector2 spinningpoint = new Vector2(0f, -30f).RotatedBy(angularRatio * 1.5f * MathHelper.TwoPi) * new Vector2(1f, 0.4f); - - for (int i = 0; i < 4; i++) - { - Vector2 dustSpawnDelta = Vector2.Zero; - float scaleFactor2 = 1f; - switch (i) - { - case 0: - dustSpawnDelta = Vector2.UnitY * -15f; - scaleFactor2 = 0.15f; - break; - case 1: - dustSpawnDelta = Vector2.UnitY * -5f; - scaleFactor2 = 0.3f; - break; - case 2: - dustSpawnDelta = Vector2.UnitY * 5f; - scaleFactor2 = 0.6f; - break; - case 3: - dustSpawnDelta = Vector2.UnitY * 20f; - scaleFactor2 = 0.45f; - break; - } - - int idx = Dust.NewDust(npc.Center, 0, 0, DustID.Electric, 0f, 0f, 100, default, 0.5f); - Main.dust[idx].noGravity = true; - Main.dust[idx].position = npc.Center + spinningpoint * scaleFactor2 + dustSpawnDelta; - Main.dust[idx].velocity = Vector2.Zero; - spinningpoint *= -1f; - - idx = Dust.NewDust(npc.Center, 0, 0, DustID.Electric, 0f, 0f, 100, default, 0.5f); - Main.dust[idx].noGravity = true; - Main.dust[idx].position = npc.Center + spinningpoint * scaleFactor2 + dustSpawnDelta; - Main.dust[idx].velocity = Vector2.Zero; - } - - Lighting.AddLight((int)npc.Center.X / 16, (int)(npc.Center.Y - 10f) / 16, 0.1f * angularRatio, 0.5f * angularRatio, 0.7f * angularRatio); - - return false; - } - - Lighting.AddLight((int)npc.Center.X / 16, (int)(npc.Center.Y - 10f) / 16, 0.1f, 0.5f, 0.7f); - npc.dontTakeDamage = false; - - if (npc.ai[0] < 60f) - { - npc.ai[0] += 1f; - } - - // Reset laser shoot counter - if (npc.justHit) - { - npc.ai[0] = 0f; - } - - // Shoot laser - if (npc.ai[0] == 60f) - { - npc.ai[0] = CalamityWorld.death ? -60f : -120f; - - // The "+ Main.player[npc.target].velocity * 20f" part ensures the turret will aim ahead of the player - Vector2 distanceVector = Main.player[npc.target].Center + Main.player[npc.target].velocity * 20f - (npc.Center - Vector2.UnitY * 10f); - - if (distanceVector.HasNaNs()) - { - distanceVector = -Vector2.UnitY; - } - Vector2 velocity = Vector2.Normalize(distanceVector) * 14f; - - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center - Vector2.UnitY * 10f, velocity, ProjectileID.MartianTurretBolt, 28, 0f, Main.myPlayer, 0f, 0f); - } - - return false; - } - #endregion - - #region Corite AI - public static bool BuffedCoriteAI(NPC npc, Mod mod) - { - npc.TargetClosest(false); - - npc.rotation = npc.velocity.ToRotation(); - - if (Math.Sign(npc.velocity.X) != 0) - { - npc.spriteDirection = -Math.Sign(npc.velocity.X); - } - if (npc.rotation < -MathHelper.PiOver2) - { - npc.rotation += MathHelper.Pi; - } - if (npc.rotation > MathHelper.PiOver2) - { - npc.rotation -= MathHelper.Pi; - } - - if (npc.type == NPCID.SolarCorite) - { - npc.spriteDirection = Math.Sign(npc.velocity.X); - } - - float npcKBResist = 0.4f; - - float upwardChargeSpeed = 12f; - float idealUpwardDelta = 200f; - float maximumDistanceBeforeCharge = 900f; - float upwardMovementIntertia = 30f; - - float chargePhaseWait = 30f; - float chargeWaitSlowdownMult = 0.95f; - int chargeRandomness = 50; - float chargeSpeed = 14f; - float maximumChargeTime = 30f; - float chargeDistanceCheck = 100f; - float chargeIntertia = 20f; - float chargeAcceleration = 0f; - - // Stops charging if speed is less than this when charging. - float minimumChargeSpeed = 7f; - - bool hasCoolDustPhase = true; - - if (npc.type == NPCID.SolarCorite) - { - npcKBResist = 0.3f; - upwardChargeSpeed = 10f; - idealUpwardDelta = 300f; - maximumDistanceBeforeCharge = 1000f; - upwardMovementIntertia = 60f; - chargePhaseWait = 5f; - chargeWaitSlowdownMult = 0.8f; - chargeRandomness = 0; - chargeSpeed = 10f; - chargeDistanceCheck = 150f; - chargeIntertia = 60f; - chargeAcceleration = 0.333333343f; - minimumChargeSpeed = 8f; - hasCoolDustPhase = false; - } - - chargeAcceleration *= chargeIntertia; - - if (CalamityWorld.death) - { - upwardChargeSpeed *= 1.25f; - chargeSpeed *= 1.25f; - } - - // Drone dust - if (npc.type == NPCID.MartianDrone && npc.ai[0] != 3f) - { - int idx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Electric, 0f, 0f, 100, default, 0.5f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity = npc.velocity / 5f; - Vector2 rotationVector = new Vector2(-10f, 10f); - - if (npc.spriteDirection == 1) - { - rotationVector.X *= -1f; - } - - rotationVector = rotationVector.RotatedBy(npc.rotation); - Main.dust[idx].position = npc.Center + rotationVector; - } - - if (npc.type == NPCID.SolarCorite) - { - int dustSpawnChance = (npc.ai[0] == 2f) ? 2 : 1; - int dustSpawnAreaSize = (npc.ai[0] == 2f) ? 30 : 20; - for (int i = 0; i < 2; i++) - { - if (Main.rand.Next(3) < dustSpawnChance) - { - int idx = Dust.NewDust(npc.Center - new Vector2(dustSpawnAreaSize), dustSpawnAreaSize * 2, dustSpawnAreaSize * 2, DustID.Torch, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default, 1.5f); - Main.dust[idx].noGravity = true; - Dust dust = Main.dust[idx]; - dust.velocity *= 0.2f; - Main.dust[idx].fadeIn = 1f; - } - } - } - - // Move upward. - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.knockBackResist = npcKBResist; - Vector2 playerDistanceNorm = Main.player[npc.target].Center - npc.Center; - Vector2 upwardVelocity = playerDistanceNorm - Vector2.UnitY * idealUpwardDelta; - float playerDistance = npc.Distance(Main.player[npc.target].Center); - playerDistanceNorm = Vector2.Normalize(playerDistanceNorm) * upwardChargeSpeed; - upwardVelocity = Vector2.Normalize(upwardVelocity) * upwardChargeSpeed; - bool closeAngleDistance = Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1); - - if (npc.ai[3] >= 120f) - { - closeAngleDistance = true; - } - - // In simpler terms, this means that we incoporate a bool which states: - // The angular distance between this and the player is greater than pi/8 or - // less than pi - pi/8. - // into the already existing boolean. - closeAngleDistance &= npc.AngleTo(Main.player[npc.target].Center) > (MathHelper.Pi / 8f) && - npc.AngleTo(Main.player[npc.target].Center) < (MathHelper.Pi - MathHelper.Pi / 8f); - - // If in a relatively close area of the player, or we meet the angle criteria above, prepare for charge. - if (playerDistance < maximumDistanceBeforeCharge || closeAngleDistance) - { - npc.ai[0] = 1f; - npc.ai[2] = playerDistanceNorm.X; - npc.ai[3] = playerDistanceNorm.Y; - npc.netUpdate = true; - } - // Otherwise, resume upward movement. - else - { - npc.velocity = (npc.velocity * (upwardMovementIntertia - 1f) + upwardVelocity) / upwardMovementIntertia; - - if (!closeAngleDistance) - { - npc.ai[3] += 1f; - if (npc.ai[3] == 120f) - { - npc.netUpdate = true; - } - } - else - { - npc.ai[3] = 0f; - } - } - } - // Slow down and prepare for charge. - else if (npc.ai[0] == 1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.knockBackResist = 0f; - - bool decelerate = true; - if (npc.type == NPCID.SolarCorite) - { - decelerate = npc.velocity.Length() > 2f; - if (!decelerate && npc.target >= 0 && !Main.player[npc.target].DeadOrGhost) - { - Vector2 maxVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.Zero) * 0.1f; - npc.velocity = Vector2.Lerp(npc.velocity, maxVelocity, 0.25f); - } - } - - if (decelerate) - npc.velocity *= chargeWaitSlowdownMult; - - npc.ai[1] += 1f; - // If enough time has passed, charge. - if (npc.ai[1] >= chargePhaseWait) - { - // Set damage - npc.damage = npc.defDamage; - - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.netUpdate = true; - Vector2 velocity = new Vector2(npc.ai[2], npc.ai[3]) + new Vector2(Main.rand.Next(-chargeRandomness, chargeRandomness + 1), Main.rand.Next(-chargeRandomness, chargeRandomness + 1)) * 0.04f; - velocity.Normalize(); - velocity *= chargeSpeed; - npc.velocity = velocity; - } - - // Spawn some cool dust. - if (npc.type == NPCID.MartianDrone && Main.rand.NextBool(4)) - { - int idx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Electric, 0f, 0f, 100, default, 0.5f); - Main.dust[idx].noGravity = true; - Dust dust = Main.dust[idx]; - dust.velocity *= 2f; - Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - npc.Center); - } - } - else if (npc.ai[0] == 2f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.knockBackResist = 0f; - - npc.ai[1] += 1f; - bool aboveAndFar = Vector2.Distance(npc.Center, Main.player[npc.target].Center) > chargeDistanceCheck && npc.Center.Y > Main.player[npc.target].Center.Y; - // If time is up and the player is (relatively) far, or the velocity is (relatively) low, reset. - if ((npc.ai[1] >= maximumChargeTime & aboveAndFar) || npc.velocity.Length() < minimumChargeSpeed) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.velocity /= 2f; - npc.netUpdate = true; - - if (npc.type == NPCID.SolarCorite) - { - npc.ai[1] = 45f; - npc.ai[0] = 4f; - } - } - else - { - Vector2 distanceNormalized = Vector2.Normalize(Main.player[npc.target].Center - npc.Center); - - if (distanceNormalized.HasNaNs()) - { - distanceNormalized = new Vector2(npc.direction, 0f); - } - - npc.velocity = (npc.velocity * (chargeIntertia - 1f) + distanceNormalized * (npc.velocity.Length() + chargeAcceleration)) / chargeIntertia; - } - - if (hasCoolDustPhase && Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[1] -= 3f; - if (npc.ai[1] <= 0f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - npc.velocity *= CalamityWorld.death ? 0.9f : 0.95f; - } - - if (hasCoolDustPhase && npc.ai[0] != 3f && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 64f) - { - npc.ai[0] = 3f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - // Explode - if (npc.ai[0] == 3f) - { - // Set damage - npc.damage = npc.defDamage; - - npc.position = npc.Center; - npc.width = npc.height = CalamityWorld.death ? 360 : 240; - npc.position -= npc.Size; - - npc.velocity = Vector2.Zero; - - npc.alpha = 255; - Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.2f, 0.7f, 1.1f); - - for (int i = 0; i < 10; i++) - { - int idx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Smoke, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[idx]; - dust.velocity *= 1.4f; - Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + npc.Center; - } - - for (int i = 0; i < 40; i++) - { - int idx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Electric, 0f, 0f, 100, default, 0.5f); - Main.dust[idx].noGravity = true; - Dust dust = Main.dust[idx]; - dust.velocity *= 2f; - Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + npc.Center; - Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - npc.Center); - - if (Main.rand.NextBool()) - { - idx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Electric, 0f, 0f, 100, default, 0.9f); - Main.dust[idx].noGravity = true; - dust = Main.dust[idx]; - dust.velocity *= 1.2f; - Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + npc.Center; - Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - npc.Center); - } - - if (Main.rand.NextBool(4)) - { - idx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Electric, 0f, 0f, 100, default, 0.7f); - dust = Main.dust[idx]; - dust.velocity *= 1.2f; - Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + npc.Center; - Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - npc.Center); - } - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= 3f) - { - SoundEngine.PlaySound(SoundID.Item14, npc.Center); - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - } - } - - return false; - } - #endregion - - #region Martian Probe AI - public static bool BuffedMartianProbeAI(NPC npc, Mod mod) - { - // Float around - if (npc.ai[0] == 0f) - { - if (npc.direction == 0) - { - npc.TargetClosest(true); - npc.netUpdate = true; - } - - if (npc.collideX) - { - npc.direction = -npc.direction; - npc.netUpdate = true; - } - - npc.velocity.X = 6f * (float)npc.direction; - Point centerTileCoords = npc.Center.ToTileCoordinates(); - int distanceFromGround = 30; - - if (WorldGen.InWorld(centerTileCoords.X, centerTileCoords.Y, 30)) - { - for (int y = 0; y < 30; y++) - { - if (WorldGen.SolidTile(centerTileCoords.X, centerTileCoords.Y + y)) - { - distanceFromGround = y; - break; - } - } - } - - if (distanceFromGround < 15) - { - npc.velocity.Y = Math.Max(npc.velocity.Y - 0.05f, -3.5f); - } - else if (distanceFromGround < 20) - { - npc.velocity.Y *= 0.95f; - } - else - { - npc.velocity.Y = Math.Min(npc.velocity.Y + 0.05f, 1.5f); - } - - int playerIndex = npc.FindClosestPlayer(out float distanceFromPlayer); - if (playerIndex == -1 || Main.player[playerIndex].dead) - { - return false; - } - - // If a player is below and nearby the probe, become active - if (distanceFromPlayer < 440f && Main.player[playerIndex].Center.Y > npc.Center.Y) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - } - // Wait - else if (npc.ai[0] == 1f) - { - npc.ai[1] += 1f; - - npc.velocity *= 0.93f; - - if (npc.ai[1] >= (CalamityWorld.death ? 5f : 45f)) - { - npc.ai[1] = 0f; - npc.ai[0] = 2f; - - int closetPlayer = npc.FindClosestPlayer(); - // Update the X acceleration - npc.ai[3] = closetPlayer != -1 ? (Main.player[closetPlayer].Center.X < npc.Center.X).ToDirectionInt() : 1f; - - npc.netUpdate = true; - } - } - // And fly away - else if (npc.ai[0] == 2f) - { - npc.noTileCollide = true; - - npc.ai[1] += 1f; - - npc.velocity.Y = Math.Max(npc.velocity.Y - 0.2f, -12f); - npc.velocity.X = Math.Min(npc.velocity.X + npc.ai[3] * 0.1f, 6f); - - // If above the world or enough time has passed, summon the naked grey gods. - if ((npc.position.Y < -npc.height || npc.ai[1] >= 135f) && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.StartInvasion(InvasionID.MartianMadness); - npc.active = false; - npc.netUpdate = true; - } - } - - Vector3 lightColor = Color.SkyBlue.ToVector3(); - if (npc.ai[0] == 2f) - { - lightColor = Color.Red.ToVector3(); - } - lightColor *= 0.65f; - - Lighting.AddLight(npc.Center, lightColor); - - return false; - } - #endregion - - #region Mothron Egg AI - public static bool BuffedMothronEggAI(NPC npc, Mod mod) - { - // Define what exactly is going to be shit out of this egg when it's ready. - if (npc.ai[1] == 0f) - { - npc.ai[1] = (Main.rand.NextBool(10) && NPC.CountNPCS(NPCID.Mothron) < 2) ? NPCID.Mothron : NPCID.MothronSpawn; - - if ((int)npc.ai[1] == NPCID.Mothron) - { - npc.defense = (int)Math.Round(npc.defDefense * 1.5); - npc.scale *= 2f; - npc.width = npc.height = (int)(34f * npc.scale); - npc.netUpdate = true; - } - } - - // Fall to the side like a sack of potatoes - if (npc.velocity.Y == 0f) - { - npc.velocity.X *= 0.9f; - npc.rotation += npc.velocity.X * 0.02f; - } - else - { - npc.velocity.X *= 0.99f; - npc.rotation += npc.velocity.X * 0.04f; - } - - // How much time is needed before the egg hatches - float hatchTimer = ((int)npc.ai[1] == NPCID.Mothron ? 480f : 240f); - if (CalamityWorld.death) - hatchTimer *= 0.5f; - - npc.ai[0] += 1f; - if (npc.ai[0] >= hatchTimer) - { - int hatchType = NPC.CountNPCS(NPCID.Mothron) < 2 ? (int)npc.ai[1] : NPCID.MothronSpawn; - npc.Transform(hatchType); - } - - // Jump around sometimes - if (Main.netMode != NetmodeID.MultiplayerClient && npc.velocity.Y == 0f && Math.Abs(npc.velocity.X) < 0.2f && npc.ai[0] >= hatchTimer * 0.75f) - { - float hatchCompleteness = npc.ai[0] - hatchTimer * 0.75f; - hatchCompleteness /= hatchTimer * 0.25f; - if (Main.rand.Next(-10, 120) < hatchCompleteness * 100f) - { - npc.velocity.Y -= Main.rand.Next(20, 40) * 0.025f; - npc.velocity.X += Main.rand.Next(-20, 20) * 0.025f; - npc.velocity *= 1f + hatchCompleteness * 2f; - npc.netUpdate = true; - } - } - - return false; - } - #endregion - - #region Granite Elemental AI - public static bool BuffedGraniteElementalAI(NPC npc, Mod mod) - { - npc.noGravity = true; - npc.noTileCollide = false; - - // Set damage - npc.damage = npc.defDamage; - - npc.defense = npc.defDefense; - - if (npc.justHit && Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(10)) - { - npc.netUpdate = true; - npc.ai[0] = -1f; - npc.ai[1] = 0f; - } - if (npc.ai[0] == -1f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.defense = npc.defDefense + 10; - - npc.noGravity = false; - npc.velocity.X *= 0.98f; - npc.ai[1] += 1f; - if (npc.ai[1] >= 120f) - { - npc.ai[0] = (npc.ai[1] = (npc.ai[2] = (npc.ai[3] = 0f))); - } - } - else if (npc.ai[0] == 0f) - { - npc.TargetClosest(true); - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 1f; - return false; - } - Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; - targetDirection.Y -= (float)(Main.player[npc.target].height / 4); - float attackTimeMax1 = targetDirection.Length(); - if (attackTimeMax1 > (CalamityWorld.death ? 400f : 800f)) - { - npc.ai[0] = 2f; - return false; - } - Vector2 elementalCenter = npc.Center; - elementalCenter.X = Main.player[npc.target].Center.X; - Vector2 targetDistance = elementalCenter - npc.Center; - if (targetDistance.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = elementalCenter.X; - npc.ai[2] = elementalCenter.Y; - Vector2 elementalCenter2 = npc.Center; - elementalCenter2.Y = Main.player[npc.target].Center.Y; - if (targetDistance.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter2, 1, 1) && Collision.CanHit(elementalCenter2, 1, 1, Main.player[npc.target].position, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = elementalCenter2.X; - npc.ai[2] = elementalCenter2.Y; - } - } - else - { - elementalCenter = npc.Center; - elementalCenter.Y = Main.player[npc.target].Center.Y; - if ((elementalCenter - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = elementalCenter.X; - npc.ai[2] = elementalCenter.Y; - } - } - if (npc.ai[0] == 0f) - { - npc.localAI[0] = 0f; - targetDirection.Normalize(); - targetDirection *= 0.5f; - npc.velocity += targetDirection; - npc.ai[0] = 4f; - npc.ai[1] = 0f; - } - } - else if (npc.ai[0] == 1f) - { - Vector2 targetDirectionAgain = Main.player[npc.target].Center - npc.Center; - float attackTimeMax2 = targetDirectionAgain.Length(); - float attackTimeMax3 = 2f; - attackTimeMax3 += attackTimeMax2 / (CalamityWorld.death ? 160f : 180f); - int attackTimeMax4 = 50; - targetDirectionAgain.Normalize(); - targetDirectionAgain *= attackTimeMax3; - npc.velocity = (npc.velocity * (float)(attackTimeMax4 - 1) + targetDirectionAgain) / (float)attackTimeMax4; - if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - } - } - else if (npc.ai[0] == 2f) - { - npc.noTileCollide = true; - Vector2 targetDirection3 = Main.player[npc.target].Center - npc.Center; - float attackTimeMax5 = targetDirection3.Length(); - float scaleFactor23 = CalamityWorld.death ? 3f : 2.5f; - int attackTimeMax6 = 4; - targetDirection3.Normalize(); - targetDirection3 *= scaleFactor23; - npc.velocity = (npc.velocity * (float)(attackTimeMax6 - 1) + targetDirection3) / (float)attackTimeMax6; - if (attackTimeMax5 < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[0] = 0f; - } - } - else if (npc.ai[0] == 3f) - { - Vector2 elementalCenter3 = new Vector2(npc.ai[1], npc.ai[2]); - Vector2 elementalDirection = elementalCenter3 - npc.Center; - float attackTimeMax7 = elementalDirection.Length(); - float attackTimeMax8 = 2f; - float attackTimeMax9 = 3f; - elementalDirection.Normalize(); - elementalDirection *= attackTimeMax8; - npc.velocity = (npc.velocity * (attackTimeMax9 - 1f) + elementalDirection) / attackTimeMax9; - if (npc.collideX || npc.collideY) - { - npc.ai[0] = 4f; - npc.ai[1] = 0f; - } - if (attackTimeMax7 < attackTimeMax8 || attackTimeMax7 > 800f || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 0f; - } - } - else if (npc.ai[0] == 4f) - { - if (npc.collideX) - { - npc.velocity.X = npc.velocity.X * -0.8f; - } - if (npc.collideY) - { - npc.velocity.Y = npc.velocity.Y * -0.8f; - } - Vector2 stationaryTargetDist; - if (npc.velocity.X == 0f && npc.velocity.Y == 0f) - { - stationaryTargetDist = Main.player[npc.target].Center - npc.Center; - stationaryTargetDist.Y -= (float)(Main.player[npc.target].height / 4); - stationaryTargetDist.Normalize(); - npc.velocity = stationaryTargetDist * 0.1f; - } - float scaleFactor24 = CalamityWorld.death ? 2.5f : 2f; - stationaryTargetDist = npc.velocity; - stationaryTargetDist.Normalize(); - stationaryTargetDist *= scaleFactor24; - npc.velocity = (npc.velocity * 19f + stationaryTargetDist) / 20f; - npc.ai[1] += 1f; - if (npc.ai[1] > 180f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - } - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 0f; - } - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 5f && !Collision.SolidCollision(npc.position - new Vector2(10f, 10f), npc.width + 20, npc.height + 20)) - { - npc.localAI[0] = 0f; - Vector2 elementalCenter4 = npc.Center; - elementalCenter4.X = Main.player[npc.target].Center.X; - if (Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, elementalCenter4, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = elementalCenter4.X; - npc.ai[2] = elementalCenter4.Y; - return false; - } - elementalCenter4 = npc.Center; - elementalCenter4.Y = Main.player[npc.target].Center.Y; - if (Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, elementalCenter4, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = elementalCenter4.X; - npc.ai[2] = elementalCenter4.Y; - } - } - } - return false; - } - #endregion - - #region Star Cell AI - public static bool BuffedStarCellAI(NPC npc, Mod mod) - { - npc.noTileCollide = false; - if (npc.ai[0] == 0f) - { - // Avoid cheap bullshit - if (npc.type == NPCID.DeadlySphere || npc.type == NPCID.NebulaHeadcrab) - npc.damage = 0; - - npc.TargetClosest(); - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 1f; - } - else - { - Vector2 cellTargetDirection = Main.player[npc.target].Center - npc.Center; - cellTargetDirection.Y -= Main.player[npc.target].height / 4; - float cellTargetDist = cellTargetDirection.Length(); - if (cellTargetDist > 800f) - { - npc.ai[0] = 2f; - } - else - { - Vector2 cellCenter = npc.Center; - cellCenter.X = Main.player[npc.target].Center.X; - Vector2 cellFaceDirection = cellCenter - npc.Center; - if (cellFaceDirection.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = cellCenter.X; - npc.ai[2] = cellCenter.Y; - Vector2 cellCenter2 = npc.Center; - cellCenter2.Y = Main.player[npc.target].Center.Y; - if (cellFaceDirection.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter2, 1, 1) && Collision.CanHit(cellCenter2, 1, 1, Main.player[npc.target].position, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = cellCenter2.X; - npc.ai[2] = cellCenter2.Y; - } - } - else - { - cellCenter = npc.Center; - cellCenter.Y = Main.player[npc.target].Center.Y; - if ((cellCenter - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = cellCenter.X; - npc.ai[2] = cellCenter.Y; - } - } - - if (npc.ai[0] == 0f) - { - npc.localAI[0] = 0f; - cellTargetDirection.Normalize(); - cellTargetDirection *= 0.5f; - npc.velocity += cellTargetDirection; - npc.ai[0] = 4f; - npc.ai[1] = 0f; - } - } - } - } - else if (npc.ai[0] == 1f) - { - // Set damage or avoid cheap bullshit - if (npc.type == NPCID.DeadlySphere) - npc.damage = npc.defDamage; - else if (npc.type == NPCID.NebulaHeadcrab) - npc.damage = 0; - - npc.rotation += npc.direction * 0.3f; - Vector2 attacktargetDirection = Main.player[npc.target].Center - npc.Center; - if (npc.type == NPCID.NebulaHeadcrab) - attacktargetDirection = Main.player[npc.target].Top - npc.Center; - - float attackTargetDist = attacktargetDirection.Length(); - float attackVelocity = CalamityWorld.death ? 9f : 7.5f; - attackVelocity += attackTargetDist / 100f; - int attackVelocityMult = CalamityWorld.death ? 40 : 45; - attacktargetDirection.Normalize(); - attacktargetDirection *= attackVelocity; - npc.velocity = (npc.velocity * (attackVelocityMult - 1) + attacktargetDirection) / attackVelocityMult; - if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - } - - if (npc.type == NPCID.NebulaHeadcrab && attackTargetDist < 40f && Main.player[npc.target].active && !Main.player[npc.target].dead) - { - bool headcrabAttach = true; - for (int p = 0; p < Main.maxNPCs; p++) - { - NPC nPC7 = Main.npc[p]; - if (nPC7.active && nPC7.type == npc.type && nPC7.ai[0] == 5f && nPC7.target == npc.target) - { - headcrabAttach = false; - break; - } - } - - if (headcrabAttach) - { - npc.Center = Main.player[npc.target].Top; - npc.velocity = Vector2.Zero; - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - } - } - else if (npc.ai[0] == 2f) - { - // Avoid cheap bullshit - if (npc.type == NPCID.DeadlySphere || npc.type == NPCID.NebulaHeadcrab) - npc.damage = 0; - - npc.rotation = npc.velocity.X * 0.1f; - npc.noTileCollide = true; - Vector2 idleTargetDirection = Main.player[npc.target].Center - npc.Center; - float idleTargetDist = idleTargetDirection.Length(); - float idleVelocity = CalamityWorld.death ? 6f : 4.5f; - int idleVelocityMult = 2; - idleTargetDirection.Normalize(); - idleTargetDirection *= idleVelocity; - npc.velocity = (npc.velocity * (idleVelocityMult - 1) + idleTargetDirection) / idleVelocityMult; - if (idleTargetDist < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.ai[0] = 0f; - } - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - if (npc.type == NPCID.DeadlySphere || npc.type == NPCID.NebulaHeadcrab) - npc.damage = 0; - - npc.rotation = npc.velocity.X * 0.1f; - Vector2 blockedCellCenter = new Vector2(npc.ai[1], npc.ai[2]); - Vector2 blockedCellDirection = blockedCellCenter - npc.Center; - float blockedTargetDist = blockedCellDirection.Length(); - float blockedVelocity = CalamityWorld.death ? 4f : 3f; - float blockedVelocityMult = 2f; - blockedCellDirection.Normalize(); - blockedCellDirection *= blockedVelocity; - npc.velocity = (npc.velocity * (blockedVelocityMult - 1f) + blockedCellDirection) / blockedVelocityMult; - if (npc.collideX || npc.collideY) - { - npc.ai[0] = 4f; - npc.ai[1] = 0f; - } - - if (blockedTargetDist < blockedVelocity || blockedTargetDist > 800f || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - npc.ai[0] = 0f; - } - else if (npc.ai[0] == 4f) - { - // Avoid cheap bullshit - if (npc.type == NPCID.DeadlySphere || npc.type == NPCID.NebulaHeadcrab) - npc.damage = 0; - - npc.rotation = npc.velocity.X * 0.1f; - if (npc.collideX) - npc.velocity.X *= -0.8f; - - if (npc.collideY) - npc.velocity.Y *= -0.8f; - - Vector2 smolCellDirection; - if (npc.velocity.X == 0f && npc.velocity.Y == 0f) - { - smolCellDirection = Main.player[npc.target].Center - npc.Center; - smolCellDirection.Y -= Main.player[npc.target].height / 4; - smolCellDirection.Normalize(); - npc.velocity = smolCellDirection * 0.1f; - } - - float smolCellVelocity = CalamityWorld.death ? 4f : 3f; - float smolCellVelocityMult = CalamityWorld.death ? 16f : 18f; - smolCellDirection = npc.velocity; - smolCellDirection.Normalize(); - smolCellDirection *= smolCellVelocity; - npc.velocity = (npc.velocity * (smolCellVelocityMult - 1f) + smolCellDirection) / smolCellVelocityMult; - npc.ai[1] += 1f; - if (npc.ai[1] > 180f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - } - - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - npc.ai[0] = 0f; - - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 5f && !Collision.SolidCollision(npc.position - new Vector2(10f, 10f), npc.width + 20, npc.height + 20)) - { - npc.localAI[0] = 0f; - Vector2 cellCentered = npc.Center; - cellCentered.X = Main.player[npc.target].Center.X; - if (Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, cellCentered, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = cellCentered.X; - npc.ai[2] = cellCentered.Y; - } - else - { - cellCentered = npc.Center; - cellCentered.Y = Main.player[npc.target].Center.Y; - if (Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, cellCentered, 1, 1)) - { - npc.ai[0] = 3f; - npc.ai[1] = cellCentered.X; - npc.ai[2] = cellCentered.Y; - } - } - } - } - else if (npc.ai[0] == 5f) - { - Player player8 = Main.player[npc.target]; - if (!player8.active || player8.dead) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - else - { - // Set damage - npc.damage = npc.defDamage; - - npc.Center = ((player8.gravDir == 1f) ? player8.Top : player8.Bottom) + new Vector2(player8.direction * 4, 0f); - npc.gfxOffY = player8.gfxOffY; - npc.velocity = Vector2.Zero; - if (!player8.creativeGodMode) - player8.AddBuff(BuffID.Obstructed, 59); - } - } - - if (npc.type == NPCID.StardustCellBig) - { - npc.rotation = 0f; - for (int r = 0; r < Main.maxNPCs; r++) - { - if (r != npc.whoAmI && Main.npc[r].active && Main.npc[r].type == npc.type && Math.Abs(npc.position.X - Main.npc[r].position.X) + Math.Abs(npc.position.Y - Main.npc[r].position.Y) < npc.width) - { - if (npc.position.X < Main.npc[r].position.X) - npc.velocity.X -= 0.05f; - else - npc.velocity.X += 0.05f; - - if (npc.position.Y < Main.npc[r].position.Y) - npc.velocity.Y -= 0.05f; - else - npc.velocity.Y += 0.05f; - } - } - } - else - { - if (npc.type != NPCID.NebulaHeadcrab) - return false; - - npc.hide = npc.ai[0] == 5f; - npc.rotation = npc.velocity.X * 0.1f; - for (int s = 0; s < Main.maxNPCs; s++) - { - if (s != npc.whoAmI && Main.npc[s].active && Main.npc[s].type == npc.type && Math.Abs(npc.position.X - Main.npc[s].position.X) + Math.Abs(npc.position.Y - Main.npc[s].position.Y) < npc.width) - { - if (npc.position.X < Main.npc[s].position.X) - npc.velocity.X -= 0.05f; - else - npc.velocity.X += 0.05f; - - if (npc.position.Y < Main.npc[s].position.Y) - npc.velocity.Y -= 0.05f; - else - npc.velocity.Y += 0.05f; - } - } - } - - return false; - } - #endregion - - #region Ancient Vision AI - public static bool BuffedAncientVisionAI(NPC npc, Mod mod) - { - if (npc.alpha > 0) - { - npc.alpha -= 30; - if (npc.alpha < 0) - npc.alpha = 0; - } - - npc.noGravity = true; - npc.noTileCollide = true; - npc.knockBackResist = 0f; - - foreach (NPC n in Main.ActiveNPCs) - { - if (n.whoAmI == npc.whoAmI || n.type != npc.type) - continue; - - Vector2 targetDirection = n.Center - npc.Center; - if (!(targetDirection.Length() < 50f)) - continue; - - targetDirection.Normalize(); - if (targetDirection.X == 0f && targetDirection.Y == 0f) - { - if (n.whoAmI > npc.whoAmI) - targetDirection.X = 1f; - else - targetDirection.X = -1f; - } - - targetDirection *= 0.4f; - npc.velocity -= targetDirection; - n.velocity += targetDirection; - } - - if (npc.type == NPCID.ShadowFlameApparition) - { - if (npc.localAI[0] < 120f) - { - if (npc.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - npc.TargetClosest(); - if (npc.direction > 0) - npc.velocity.X += 2f; - else - npc.velocity.X -= 2f; - - npc.position += npc.netOffset; - for (int j = 0; j < 20; j++) - { - Vector2 apparitionCenter = npc.Center; - apparitionCenter.Y -= 18f; - Vector2 apparitionRandVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - apparitionRandVelocity.Normalize(); - apparitionRandVelocity *= Main.rand.Next(0, 100) * 0.1f; - apparitionCenter += apparitionRandVelocity; - apparitionRandVelocity.Normalize(); - apparitionRandVelocity *= Main.rand.Next(50, 90) * 0.2f; - int shadowflameDust = Dust.NewDust(apparitionCenter, 1, 1, DustID.Shadowflame); - Main.dust[shadowflameDust].velocity = -apparitionRandVelocity * 0.3f; - Main.dust[shadowflameDust].alpha = 100; - if (Main.rand.NextBool()) - { - Main.dust[shadowflameDust].noGravity = true; - Dust dust = Main.dust[shadowflameDust]; - dust.scale += 0.3f; - } - } - - npc.position -= npc.netOffset; - } - - npc.localAI[0] += 1f; - float localAIDustControl = 1f - npc.localAI[0] / 120f; - float dustAmt = localAIDustControl * 20f; - for (int k = 0; k < dustAmt; k++) - { - if (Main.rand.NextBool(5)) - { - npc.position += npc.netOffset; - int idleShadowflameDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Shadowflame); - Main.dust[idleShadowflameDust].alpha = 100; - Dust dust = Main.dust[idleShadowflameDust]; - dust.velocity *= 0.3f; - dust = Main.dust[idleShadowflameDust]; - dust.velocity += npc.velocity * 0.75f; - Main.dust[idleShadowflameDust].noGravity = true; - npc.position -= npc.netOffset; - } - } - } - } - - if (npc.type == NPCID.AncientCultistSquidhead) - { - if (npc.localAI[0] < 120f) - { - if (npc.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item8, npc.Center); - npc.TargetClosest(); - if (npc.direction > 0) - npc.velocity.X += 2f; - else - npc.velocity.X -= 2f; - } - - npc.localAI[0] += 1f; - int dustPosition = 10; - for (int l = 0; l < 2; l++) - { - npc.position += npc.netOffset; - int visionDust = Dust.NewDust(npc.position - new Vector2(dustPosition), npc.width + dustPosition * 2, npc.height + dustPosition * 2, DustID.GoldFlame, 0f, 0f, 100, default(Color), 2f); - Main.dust[visionDust].noGravity = true; - Main.dust[visionDust].noLight = true; - npc.position -= npc.netOffset; - } - } - } - - if (npc.ai[0] == 0f) - { - npc.TargetClosest(); - npc.ai[0] = 1f; - npc.ai[1] = npc.direction; - } - else if (npc.ai[0] == 1f) - { - npc.TargetClosest(); - float xVelocityMult1 = 0.5f; - float maxXVelocity1 = 10f; - float maxYVelocity1 = 4f; - float turnAroundDist1 = 550f; - float yVelocityMult1 = 3f; - if (npc.type == NPCID.AncientCultistSquidhead) - { - xVelocityMult1 = 0.8f; - maxXVelocity1 = 16f; - turnAroundDist1 = 440f; - maxYVelocity1 = 6f; - } - if (CalamityWorld.death) - { - xVelocityMult1 *= 1.25f; - maxXVelocity1 *= 1.25f; - turnAroundDist1 *= 0.9f; - yVelocityMult1 -= 1f; - } - - npc.velocity.X += npc.ai[1] * xVelocityMult1; - if (npc.velocity.X > maxXVelocity1) - npc.velocity.X = maxXVelocity1; - - if (npc.velocity.X < 0f - maxXVelocity1) - npc.velocity.X = 0f - maxXVelocity1; - - float targetYDist1 = Main.player[npc.target].Center.Y - npc.Center.Y; - if (Math.Abs(targetYDist1) > maxYVelocity1) - yVelocityMult1 = CalamityWorld.death ? 10f : 12f; - - if (targetYDist1 > maxYVelocity1) - targetYDist1 = maxYVelocity1; - else if (targetYDist1 < 0f - maxYVelocity1) - targetYDist1 = 0f - maxYVelocity1; - - npc.velocity.Y = (npc.velocity.Y * (yVelocityMult1 - 1f) + targetYDist1) / yVelocityMult1; - if ((npc.ai[1] > 0f && Main.player[npc.target].Center.X - npc.Center.X < 0f - turnAroundDist1) || (npc.ai[1] < 0f && Main.player[npc.target].Center.X - npc.Center.X > turnAroundDist1)) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - if (npc.Center.Y + 20f > Main.player[npc.target].Center.Y) - npc.ai[1] = -1f; - else - npc.ai[1] = 1f; - } - } - else if (npc.ai[0] == 2f) - { - float decelYVelocityMult = 0.6f; - float deceleration = 0.93f; - float decelerationDist = 7f; - if (npc.type == NPCID.AncientCultistSquidhead) - { - decelYVelocityMult = 0.45f; - decelerationDist = 10f; - deceleration = 0.87f; - } - if (CalamityWorld.death) - { - decelYVelocityMult *= 1.25f; - deceleration *= 0.9f; - decelerationDist *= 1.25f; - } - - npc.velocity.Y += npc.ai[1] * decelYVelocityMult; - if (npc.velocity.Length() > decelerationDist) - npc.velocity *= deceleration; - - if (npc.velocity.X > -1f && npc.velocity.X < 1f) - { - npc.TargetClosest(); - npc.ai[0] = 3f; - npc.ai[1] = npc.direction; - } - } - else if (npc.ai[0] == 3f) - { - float xVelocityMult3 = 0.6f; - float yAlignSpeed = 0.3f; - float decelerationDist3 = 7f; - float deceleration3 = 0.93f; - if (npc.type == NPCID.AncientCultistSquidhead) - { - xVelocityMult3 = 0.8f; - yAlignSpeed = 0.45f; - decelerationDist3 = 9f; - deceleration3 = 0.87f; - } - if (CalamityWorld.death) - { - xVelocityMult3 *= 1.25f; - yAlignSpeed *= 1.25f; - decelerationDist3 *= 1.25f; - deceleration3 *= 0.9f; - } - - npc.velocity.X += npc.ai[1] * xVelocityMult3; - if (npc.Center.Y > Main.player[npc.target].Center.Y) - npc.velocity.Y -= yAlignSpeed; - else - npc.velocity.Y += yAlignSpeed; - - if (npc.velocity.Length() > decelerationDist3) - npc.velocity *= deceleration3; - - if (npc.velocity.Y > -1f && npc.velocity.Y < 1f) - { - npc.TargetClosest(); - npc.ai[0] = 0f; - npc.ai[1] = npc.direction; - } - } - - if (npc.type == NPCID.AncientCultistSquidhead) - { - int squidDustVelocity = 10; - npc.position += npc.netOffset; - - int squidDust = Dust.NewDust(npc.position - new Vector2(squidDustVelocity), npc.width + squidDustVelocity * 2, npc.height + squidDustVelocity * 2, DustID.GoldFlame, 0f, 0f, 100, default(Color), 2f); - Main.dust[squidDust].noGravity = true; - Main.dust[squidDust].noLight = true; - - npc.position -= npc.netOffset; - } - - return false; - } - #endregion - - #region Big Mimic AI - public static bool BuffedBigMimicAI(NPC npc, Mod mod) - { - // Set damage - npc.damage = npc.defDamage; - - npc.knockBackResist = 0.2f * Main.GameModeInfo.KnockbackToEnemiesMultiplier; - npc.dontTakeDamage = false; - npc.noTileCollide = false; - npc.noGravity = false; - npc.reflectsProjectiles = false; - if (npc.ai[0] != 7f && Main.player[npc.target].dead) - { - npc.TargetClosest(); - if (Main.player[npc.target].dead) - { - npc.ai[0] = 7f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - - if (npc.ai[0] == 0f) - { - npc.TargetClosest(); - Vector2 mimicTargetDirection = Main.player[npc.target].Center - npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient && (npc.velocity.X != 0f || npc.velocity.Y > 100f || npc.justHit || mimicTargetDirection.Length() < 80f)) - { - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 1f) - { - npc.ai[1] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > 36f) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 2f) - { - Vector2 mimicTargetDirection2 = Main.player[npc.target].Center - npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient && mimicTargetDirection2.Length() > 600f) - { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - if (npc.velocity.Y == 0f) - { - npc.TargetClosest(); - npc.velocity.X *= 0.85f; - npc.ai[1] += 1f; - float jumpDelay = 10f + (CalamityWorld.death ? 10f : 20f) * (npc.life / (float)npc.lifeMax); - float jumpXVelocity = 5f + (CalamityWorld.death ? 7f : 5f) * (1f - npc.life / (float)npc.lifeMax); - float jumpYVelocity = CalamityWorld.death ? 7f : 5f; - if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - jumpYVelocity += 2f; - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > jumpDelay) - { - npc.ai[3] += 1f; - if (npc.ai[3] >= 3f) - { - npc.ai[3] = 0f; - jumpYVelocity *= 2f; - jumpXVelocity /= 2f; - } - - npc.ai[1] = 0f; - npc.velocity.Y -= jumpYVelocity; - npc.velocity.X = jumpXVelocity * npc.direction; - npc.netUpdate = true; - } - } - else - { - npc.knockBackResist = 0f; - npc.velocity.X *= 0.99f; - if (npc.direction < 0 && npc.velocity.X > -1f) - npc.velocity.X = -1f; - - if (npc.direction > 0 && npc.velocity.X < 1f) - npc.velocity.X = 1f; - } - - npc.ai[2] += 1f; - if (npc.ai[2] > (CalamityWorld.death ? 130f : 170f) && npc.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) - { - switch (Main.rand.Next(3)) - { - case 0: - npc.ai[0] = 3f; - break; - case 1: - npc.ai[0] = 4f; - npc.noTileCollide = true; - npc.velocity.Y = CalamityWorld.death ? -12f : -10f; - break; - case 2: - npc.ai[0] = 6f; - break; - default: - npc.ai[0] = 2f; - break; - } - - if (Main.tenthAnniversaryWorld && npc.type == NPCID.BigMimicJungle && npc.ai[0] == 3f && Main.rand.NextBool()) - npc.ai[0] = 8f; - - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 3f) - { - // Avoid cheap bullshit - npc.damage = 0; - - npc.velocity.X *= 0.85f; - npc.dontTakeDamage = true; - npc.ai[1] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= (CalamityWorld.death ? 60f : 90f)) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - - if (Main.expertMode) - { - npc.ReflectProjectiles(npc.Hitbox); - npc.reflectsProjectiles = true; - } - } - else if (npc.ai[0] == 4f) - { - npc.noTileCollide = true; - npc.noGravity = true; - npc.knockBackResist = 0f; - if (npc.velocity.X < 0f) - npc.direction = -1; - else - npc.direction = 1; - - npc.spriteDirection = npc.direction; - npc.TargetClosest(); - Vector2 mimicTargetCenter = Main.player[npc.target].Center; - mimicTargetCenter.Y -= 350f; - Vector2 mimicTargetDirection = mimicTargetCenter - npc.Center; - if (npc.ai[2] == 1f) - { - npc.ai[1] += 1f; - mimicTargetDirection = Main.player[npc.target].Center - npc.Center; - mimicTargetDirection.Normalize(); - mimicTargetDirection *= CalamityWorld.death ? 12f : 10f; - npc.velocity = (npc.velocity * 4f + mimicTargetDirection) / 5f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > 6f) - { - npc.ai[1] = 0f; - npc.ai[0] = 4.1f; - npc.ai[2] = 0f; - npc.velocity = mimicTargetDirection; - npc.netUpdate = true; - } - } - else if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 40f && npc.Center.Y < Main.player[npc.target].Center.Y - 300f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.netUpdate = true; - } - } - else - { - mimicTargetDirection.Normalize(); - mimicTargetDirection *= CalamityWorld.death ? 16f : 14f; - npc.velocity = (npc.velocity * 5f + mimicTargetDirection) / 6f; - } - } - else if (npc.ai[0] == 4.1f) - { - npc.knockBackResist = 0f; - if (npc.ai[2] == 0f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.ai[2] = 1f; - - if (npc.position.Y + npc.height >= Main.player[npc.target].position.Y || npc.velocity.Y <= 0f) - { - npc.ai[1] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > 10f) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - if (Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.ai[0] = 5f; - } - } - else if (npc.ai[2] == 0f) - { - npc.noTileCollide = true; - npc.noGravity = true; - npc.knockBackResist = 0f; - } - - npc.velocity.Y += CalamityWorld.death ? 0.3f : 0.25f; - if (npc.velocity.Y > (CalamityWorld.death ? 24f : 20f)) - npc.velocity.Y = CalamityWorld.death ? 24f : 20f; - } - else if (npc.ai[0] == 5f) - { - if (npc.velocity.X > 0f) - npc.direction = 1; - else - npc.direction = -1; - - npc.spriteDirection = npc.direction; - npc.noTileCollide = true; - npc.noGravity = true; - npc.knockBackResist = 0f; - Vector2 chaseTargetDirection = Main.player[npc.target].Center - npc.Center; - chaseTargetDirection.Y -= 4f; - if (Main.netMode != NetmodeID.MultiplayerClient && chaseTargetDirection.Length() < 200f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - - if (chaseTargetDirection.Length() > 10f) - { - chaseTargetDirection.Normalize(); - chaseTargetDirection *= CalamityWorld.death ? 15f : 12.5f; - } - - npc.velocity = (npc.velocity * 4f + chaseTargetDirection) / 5f; - } - else if (npc.ai[0] == 6f) - { - npc.knockBackResist = 0f; - if (npc.velocity.Y == 0f) - { - npc.TargetClosest(); - npc.velocity.X *= 0.8f; - npc.ai[1] += 1f; - if (npc.ai[1] > 5f) - { - npc.ai[1] = 0f; - npc.velocity.Y -= 4f; - if (Main.player[npc.target].position.Y + Main.player[npc.target].height < npc.Center.Y) - npc.velocity.Y -= 1.25f; - - if (Main.player[npc.target].position.Y + Main.player[npc.target].height < npc.Center.Y - 40f) - npc.velocity.Y -= 1.5f; - - if (Main.player[npc.target].position.Y + Main.player[npc.target].height < npc.Center.Y - 80f) - npc.velocity.Y -= 1.75f; - - if (Main.player[npc.target].position.Y + Main.player[npc.target].height < npc.Center.Y - 120f) - npc.velocity.Y -= 2f; - - if (Main.player[npc.target].position.Y + Main.player[npc.target].height < npc.Center.Y - 160f) - npc.velocity.Y -= 2.25f; - - if (Main.player[npc.target].position.Y + Main.player[npc.target].height < npc.Center.Y - 200f) - npc.velocity.Y -= 2.5f; - - if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - npc.velocity.Y -= 2f; - - npc.velocity.X = (CalamityWorld.death ? 16 : 14) * npc.direction; - npc.ai[2] += 1f; - npc.netUpdate = true; - } - } - else - { - npc.velocity.X *= 0.98f; - if (npc.direction < 0 && npc.velocity.X > -8f) - npc.velocity.X = -8f; - - if (npc.direction > 0 && npc.velocity.X < 8f) - npc.velocity.X = 8f; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] >= 3f && npc.velocity.Y == 0f) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; - } - } - else if (npc.ai[0] == 7f) - { - npc.damage = 0; - npc.life = npc.lifeMax; - npc.defense = 9999; - npc.noTileCollide = true; - npc.alpha += 7; - if (npc.alpha > 255) - npc.alpha = 255; - - npc.velocity.X *= 0.98f; - } - else - { - if (npc.ai[0] != 8f) - return false; - - npc.velocity.X *= 0.85f; - npc.ai[1] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!Main.tenthAnniversaryWorld || npc.ai[1] >= 180f) - { - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.netUpdate = true; - } - else if (npc.ai[1] % 20f == 0f) - { - int num = 10; - for (int i = 0; i < num; i++) - { - int itemID = ItemID.Sets.ItemsForStuffCannon[Main.rand.Next(ItemID.Sets.ItemsForStuffCannon.Length)]; - int item = Item.NewItem(npc.GetSource_Loot(), (int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, itemID, 1, noBroadcast: false, -1, noGrabDelay: true); - float randomSpeed = Main.rand.Next(10, 26); - Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - Vector2 vector2 = Main.player[npc.target].Center - new Vector2(0f, 120f); - float targetXDist = vector2.X - vector.X; - float targetYDist = vector2.Y - vector.Y; - targetXDist += Main.rand.Next(-50, 51) * 0.1f; - targetYDist += Main.rand.Next(-50, 51) * 0.1f; - float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); - targetDistance = randomSpeed / targetDistance; - targetXDist *= targetDistance; - targetYDist *= targetDistance; - targetXDist += Main.rand.Next(-50, 51) * 0.1f; - targetYDist += Main.rand.Next(-50, 51) * 0.1f; - Main.item[item].velocity.X = targetXDist; - Main.item[item].velocity.Y = targetYDist; - Main.item[item].noGrabDelay = 100; - if (Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.SyncItem, -1, -1, null, item); - } - } - } - } - return false; - } - #endregion - - #region Small Star Cell AI - public static bool BuffedSmallStarCellAI(NPC npc, Mod mod) - { - float turnBigDelay = CalamityWorld.death ? 100f : 200f; - if (npc.velocity.Length() > 4f) - npc.velocity *= 0.95f; - - npc.velocity *= 0.99f; - npc.ai[0]++; - float cellScale = MathHelper.Clamp(npc.ai[0] / turnBigDelay, 0f, 1f); - npc.scale = 1f + 0.3f * cellScale; - if (npc.ai[0] >= turnBigDelay) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.Transform(NPCID.StardustCellBig); - npc.netUpdate = true; - } - - return false; - } - - npc.rotation += npc.velocity.X * 0.1f; - if (!(npc.ai[0] > 20f)) - return false; - - Vector2 cellCenter = npc.Center; - int dustAmt = (int)(npc.ai[0] / (turnBigDelay / 2f)); - for (int i = 0; i < dustAmt + 1; i++) - { - if (Main.rand.NextBool()) - { - float dustScale = 0.4f; - if (i % 2 == 1) - { - dustScale = 0.65f; - } - - Vector2 dustRotation = cellCenter + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - dustAmt * 2); - int cellDust = Dust.NewDust(dustRotation - Vector2.One * 12f, 24, 24, DustID.Electric, npc.velocity.X / 2f, npc.velocity.Y / 2f); - Dust dust = Main.dust[cellDust]; - dust.position -= new Vector2(2f); - Main.dust[cellDust].velocity = Vector2.Normalize(cellCenter - dustRotation) * 1.5f * (10f - dustAmt * 2f) / 10f; - Main.dust[cellDust].noGravity = true; - Main.dust[cellDust].scale = dustScale; - Main.dust[cellDust].customData = npc; - } - } - - return false; - } - #endregion - - #region Flow Invader AI - public static bool BuffedFlowInvaderAI(NPC npc, Mod mod) - { - float velocityMult = CalamityWorld.death ? 8f : 6.5f; - float moveSpeed = CalamityWorld.death ? 0.25f : 0.2f; - npc.TargetClosest(); - Vector2 desiredVelocity3 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, -300f); - float velocityCheck = desiredVelocity3.Length(); - if (velocityCheck < 20f) - { - desiredVelocity3 = npc.velocity; - } - else if (velocityCheck < 40f) - { - desiredVelocity3.Normalize(); - desiredVelocity3 *= velocityMult * 0.35f; - } - else if (velocityCheck < 80f) - { - desiredVelocity3.Normalize(); - desiredVelocity3 *= velocityMult * 0.65f; - } - else - { - desiredVelocity3.Normalize(); - desiredVelocity3 *= velocityMult; - } - - npc.SimpleFlyMovement(desiredVelocity3, moveSpeed); - npc.rotation = npc.velocity.X * 0.1f; - if (!((npc.ai[0] += 1f) >= (CalamityWorld.death ? 30f : 50f))) - return false; - - npc.ai[0] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 projDirection = Vector2.Zero; - while (Math.Abs(projDirection.X) < 1.5f) - projDirection = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * new Vector2(5f, 3f); - - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, projDirection, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); - Main.projectile[proj].extraUpdates += 1; - } - - return false; - } - #endregion - - #endregion - } -} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AncientVisionAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AncientVisionAI.cs new file mode 100644 index 0000000000..034a28fa8b --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AncientVisionAI.cs @@ -0,0 +1,275 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class AncientVisionAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.alpha > 0) + { + NPC.alpha -= 30; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.knockBackResist = 0f; + + foreach (NPC n in Main.ActiveNPCs) + { + if (n.whoAmI == NPC.whoAmI || n.type != NPC.type) + continue; + + Vector2 targetDirection = n.Center - NPC.Center; + if (!(targetDirection.Length() < 50f)) + continue; + + targetDirection.Normalize(); + if (targetDirection.X == 0f && targetDirection.Y == 0f) + { + if (n.whoAmI > NPC.whoAmI) + targetDirection.X = 1f; + else + targetDirection.X = -1f; + } + + targetDirection *= 0.4f; + NPC.velocity -= targetDirection; + n.velocity += targetDirection; + } + + if (NPC.type == NPCID.ShadowFlameApparition) + { + if (NPC.localAI[0] < 120f) + { + if (NPC.localAI[0] == 0f) + { + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + NPC.TargetClosest(); + if (NPC.direction > 0) + NPC.velocity.X += 2f; + else + NPC.velocity.X -= 2f; + + NPC.position += NPC.netOffset; + for (int j = 0; j < 20; j++) + { + Vector2 apparitionCenter = NPC.Center; + apparitionCenter.Y -= 18f; + Vector2 apparitionRandVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + apparitionRandVelocity.Normalize(); + apparitionRandVelocity *= Main.rand.Next(0, 100) * 0.1f; + apparitionCenter += apparitionRandVelocity; + apparitionRandVelocity.Normalize(); + apparitionRandVelocity *= Main.rand.Next(50, 90) * 0.2f; + int shadowflameDust = Dust.NewDust(apparitionCenter, 1, 1, DustID.Shadowflame); + Main.dust[shadowflameDust].velocity = -apparitionRandVelocity * 0.3f; + Main.dust[shadowflameDust].alpha = 100; + if (Main.rand.NextBool()) + { + Main.dust[shadowflameDust].noGravity = true; + Dust dust = Main.dust[shadowflameDust]; + dust.scale += 0.3f; + } + } + + NPC.position -= NPC.netOffset; + } + + NPC.localAI[0] += 1f; + float localAIDustControl = 1f - NPC.localAI[0] / 120f; + float dustAmt = localAIDustControl * 20f; + for (int k = 0; k < dustAmt; k++) + { + if (Main.rand.NextBool(5)) + { + NPC.position += NPC.netOffset; + int idleShadowflameDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Shadowflame); + Main.dust[idleShadowflameDust].alpha = 100; + Dust dust = Main.dust[idleShadowflameDust]; + dust.velocity *= 0.3f; + dust = Main.dust[idleShadowflameDust]; + dust.velocity += NPC.velocity * 0.75f; + Main.dust[idleShadowflameDust].noGravity = true; + NPC.position -= NPC.netOffset; + } + } + } + } + + if (NPC.type == NPCID.AncientCultistSquidhead) + { + if (NPC.localAI[0] < 120f) + { + if (NPC.localAI[0] == 0f) + { + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + NPC.TargetClosest(); + if (NPC.direction > 0) + NPC.velocity.X += 2f; + else + NPC.velocity.X -= 2f; + } + + NPC.localAI[0] += 1f; + int dustPosition = 10; + for (int l = 0; l < 2; l++) + { + NPC.position += NPC.netOffset; + int visionDust = Dust.NewDust(NPC.position - new Vector2(dustPosition), NPC.width + dustPosition * 2, NPC.height + dustPosition * 2, DustID.GoldFlame, 0f, 0f, 100, default(Color), 2f); + Main.dust[visionDust].noGravity = true; + Main.dust[visionDust].noLight = true; + NPC.position -= NPC.netOffset; + } + } + } + + if (NPC.ai[0] == 0f) + { + NPC.TargetClosest(); + NPC.ai[0] = 1f; + NPC.ai[1] = NPC.direction; + } + else if (NPC.ai[0] == 1f) + { + NPC.TargetClosest(); + float xVelocityMult1 = 0.5f; + float maxXVelocity1 = 10f; + float maxYVelocity1 = 4f; + float turnAroundDist1 = 550f; + float yVelocityMult1 = 3f; + if (NPC.type == NPCID.AncientCultistSquidhead) + { + xVelocityMult1 = 0.8f; + maxXVelocity1 = 16f; + turnAroundDist1 = 440f; + maxYVelocity1 = 6f; + } + if (CalamityWorld.death) + { + xVelocityMult1 *= 1.25f; + maxXVelocity1 *= 1.25f; + turnAroundDist1 *= 0.9f; + yVelocityMult1 -= 1f; + } + + NPC.velocity.X += NPC.ai[1] * xVelocityMult1; + if (NPC.velocity.X > maxXVelocity1) + NPC.velocity.X = maxXVelocity1; + + if (NPC.velocity.X < 0f - maxXVelocity1) + NPC.velocity.X = 0f - maxXVelocity1; + + float targetYDist1 = Main.player[NPC.target].Center.Y - NPC.Center.Y; + if (Math.Abs(targetYDist1) > maxYVelocity1) + yVelocityMult1 = CalamityWorld.death ? 10f : 12f; + + if (targetYDist1 > maxYVelocity1) + targetYDist1 = maxYVelocity1; + else if (targetYDist1 < 0f - maxYVelocity1) + targetYDist1 = 0f - maxYVelocity1; + + NPC.velocity.Y = (NPC.velocity.Y * (yVelocityMult1 - 1f) + targetYDist1) / yVelocityMult1; + if ((NPC.ai[1] > 0f && Main.player[NPC.target].Center.X - NPC.Center.X < 0f - turnAroundDist1) || (NPC.ai[1] < 0f && Main.player[NPC.target].Center.X - NPC.Center.X > turnAroundDist1)) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + if (NPC.Center.Y + 20f > Main.player[NPC.target].Center.Y) + NPC.ai[1] = -1f; + else + NPC.ai[1] = 1f; + } + } + else if (NPC.ai[0] == 2f) + { + float decelYVelocityMult = 0.6f; + float deceleration = 0.93f; + float decelerationDist = 7f; + if (NPC.type == NPCID.AncientCultistSquidhead) + { + decelYVelocityMult = 0.45f; + decelerationDist = 10f; + deceleration = 0.87f; + } + if (CalamityWorld.death) + { + decelYVelocityMult *= 1.25f; + deceleration *= 0.9f; + decelerationDist *= 1.25f; + } + + NPC.velocity.Y += NPC.ai[1] * decelYVelocityMult; + if (NPC.velocity.Length() > decelerationDist) + NPC.velocity *= deceleration; + + if (NPC.velocity.X > -1f && NPC.velocity.X < 1f) + { + NPC.TargetClosest(); + NPC.ai[0] = 3f; + NPC.ai[1] = NPC.direction; + } + } + else if (NPC.ai[0] == 3f) + { + float xVelocityMult3 = 0.6f; + float yAlignSpeed = 0.3f; + float decelerationDist3 = 7f; + float deceleration3 = 0.93f; + if (NPC.type == NPCID.AncientCultistSquidhead) + { + xVelocityMult3 = 0.8f; + yAlignSpeed = 0.45f; + decelerationDist3 = 9f; + deceleration3 = 0.87f; + } + if (CalamityWorld.death) + { + xVelocityMult3 *= 1.25f; + yAlignSpeed *= 1.25f; + decelerationDist3 *= 1.25f; + deceleration3 *= 0.9f; + } + + NPC.velocity.X += NPC.ai[1] * xVelocityMult3; + if (NPC.Center.Y > Main.player[NPC.target].Center.Y) + NPC.velocity.Y -= yAlignSpeed; + else + NPC.velocity.Y += yAlignSpeed; + + if (NPC.velocity.Length() > decelerationDist3) + NPC.velocity *= deceleration3; + + if (NPC.velocity.Y > -1f && NPC.velocity.Y < 1f) + { + NPC.TargetClosest(); + NPC.ai[0] = 0f; + NPC.ai[1] = NPC.direction; + } + } + + if (NPC.type == NPCID.AncientCultistSquidhead) + { + int squidDustVelocity = 10; + NPC.position += NPC.netOffset; + + int squidDust = Dust.NewDust(NPC.position - new Vector2(squidDustVelocity), NPC.width + squidDustVelocity * 2, NPC.height + squidDustVelocity * 2, DustID.GoldFlame, 0f, 0f, 100, default(Color), 2f); + Main.dust[squidDust].noGravity = true; + Main.dust[squidDust].noLight = true; + + NPC.position -= NPC.netOffset; + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AngryNimbusAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AngryNimbusAI.cs new file mode 100644 index 0000000000..43ce56abda --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AngryNimbusAI.cs @@ -0,0 +1,89 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class AngryNimbusAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.noGravity = true; + NPC.TargetClosest(true); + float speed = CalamityWorld.death ? 9f : 6f; + float acceleration = CalamityWorld.death ? 0.3f : 0.25f; + + Vector2 idealVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center - 300f * Vector2.UnitY) * speed; + float playerDistance = NPC.Distance(Main.player[NPC.target].Center); + if (playerDistance < 20f) + idealVelocity = NPC.velocity; + + // Yes, I understand that npc.SimpleFlyMovement exists. However, the "acceleration * 2f" is not a part of that method. + // It is not identical to what is being achieved here. + if (NPC.velocity.X < idealVelocity.X) + { + NPC.velocity.X += acceleration; + if (NPC.velocity.X < 0f && idealVelocity.X > 0f) + { + NPC.velocity.X = NPC.velocity.X + acceleration * 2f; + } + } + else if (NPC.velocity.X > idealVelocity.X) + { + NPC.velocity.X -= acceleration; + if (NPC.velocity.X > 0f && idealVelocity.X < 0f) + { + NPC.velocity.X -= acceleration * 2f; + } + } + if (NPC.velocity.Y < idealVelocity.Y) + { + NPC.velocity.Y += acceleration; + if (NPC.velocity.Y < 0f && idealVelocity.Y > 0f) + { + NPC.velocity.Y += acceleration * 2f; + } + } + else if (NPC.velocity.Y > idealVelocity.Y) + { + NPC.velocity.Y -= acceleration; + if (NPC.velocity.Y > 0f && idealVelocity.Y < 0f) + { + NPC.velocity.Y -= acceleration * 2f; + } + } + + // Make it rain + float minXRainDistance = CalamityWorld.death ? 200f : 150f; + if (NPC.Center.X > Main.player[NPC.target].position.X - minXRainDistance && + NPC.position.X < Main.player[NPC.target].Center.X + minXRainDistance && + NPC.Center.Y < Main.player[NPC.target].position.Y && + Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && + Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.justHit) + NPC.ai[0] = 0f; + + NPC.ai[0] += 1f; + if (NPC.ai[0] % 8f == 0f) + { + Vector2 rainSpawnPosition = NPC.position + new Vector2(10f + Main.rand.Next(NPC.width - 20), NPC.height + 4f); + + Projectile.NewProjectile(NPC.GetSource_FromAI(), rainSpawnPosition, Vector2.UnitY * 5f, ProjectileID.RainNimbus, 20, 0f, Main.myPlayer, 0f, 0f); + if (NPC.ai[0] % 16f == 0f) + { + float speedX = (float)Main.rand.NextFloat(CalamityWorld.death ? -6f : -3f, CalamityWorld.death ? 6f : 3f) * (Main.rand.NextFloat() - 0.5f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), rainSpawnPosition, new Vector2(speedX, 5f), ProjectileID.FrostShard, 20, 0f, Main.myPlayer, 0f, 0f); + } + } + if (NPC.ai[0] >= 607f) + NPC.ai[0] = 0f; + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AntlionAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AntlionAI.cs new file mode 100644 index 0000000000..42b40d7359 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/AntlionAI.cs @@ -0,0 +1,152 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class AntlionAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.TargetClosest(); + + // Calculate speed and velocity of the sand balls + float speed = 12f; + float xVel = Main.player[NPC.target].Center.X - NPC.Center.X; + float yVel = Main.player[NPC.target].position.Y - NPC.Center.Y; + Vector2 velocity = new Vector2(xVel, yVel); + float targetDist = velocity.Length(); + + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + + // Adjust rotation and velocity + bool canShoot = false; + if (NPC.directionY < 0) + { + // Set rotation based on the target location + NPC.rotation = velocity.ToRotation() + MathHelper.PiOver2; + + // Antlions can only shoot if rotated between a certain cone of spread based on the target location + canShoot = Math.Abs(NPC.rotation) <= 1.2f; + + // Hardcap rotation so it doesn't look weird, but since the above calculation happens first, it ignores this cap + if (NPC.rotation < -0.8f) + NPC.rotation = -0.8f; + else if (NPC.rotation > 0.8f) + NPC.rotation = 0.8f; + + // Antlions generally don't move horizontally so prevent that as needed + if (NPC.velocity.X != 0f) + { + NPC.velocity.X *= 0.9f; + if (Math.Abs(NPC.velocity.X) < 0.1f) + { + NPC.netUpdate = true; + NPC.velocity.X = 0f; + } + } + } + + bool lineofSight = Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + + if (NPC.justHit || !lineofSight) + NPC.ai[0] = AntlionSandSpitGateValue - 1f; + + // Decrement the firing cooldown, play a sound if at full meaning it just fired + if (NPC.ai[0] > 0f) + { + if (NPC.ai[0] == AntlionSandSpitGateValue) + SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); + + NPC.ai[0] -= 1f; + } + + // Emit sand dust from mouth when about to fire + if (NPC.ai[0] <= AntlionSandSpitTelegraphTime) + { + Dust dust = Dust.NewDustDirect(NPC.Center + velocity.SafeNormalize(-Vector2.UnitY) * 16f + Main.rand.NextVector2CircularEdge(6f, 6f), 1, 1, DustID.Sand, 0f, 0f, 0, default, 1.5f); + dust.noGravity = true; + dust.velocity *= 0f; + } + + // Antlions should only fire if the target is in the shooting cone and has a line of sight as well as not being on cooldown. + if (Main.netMode != NetmodeID.MultiplayerClient && canShoot && NPC.ai[0] == 0f && lineofSight) + { + // Reset the firing cooldown to 3.3333 seconds + NPC.ai[0] = AntlionSandSpitGateValue; + + // With the Rev and Death damage calculations, this becomes 56 damage. + int damage = 10; + + int projType = ProjectileID.SandBallFalling; + + // In FTW, can fire 8 sand balls (100 in stupid meme seed) + int projAmt = Main.zenithWorld ? 100 : Main.getGoodWorld ? 8 : 1; + for (int i = 0; i < projAmt; i++) + { + // Adjust the velocity to make it a shotgun-like spread + velocity.X += (float)Main.rand.Next(-30, 31) * 0.05f; + velocity.Y += (float)Main.rand.Next(-30, 31) * 0.05f; + + int sandBall = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, projType, damage, 0f, Main.myPlayer); + Main.projectile[sandBall].ai[0] = 2f; + Main.projectile[sandBall].timeLeft = 300; + Main.projectile[sandBall].friendly = false; + NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, sandBall, 0f, 0f, 0f, 0, 0, 0); + } + + NPC.netUpdate = true; + } + + try + { + // This tile checking behavior is used for when Antlions cover themselves in sand and need to rise upward to get to the surface + int xLeft = (int)NPC.position.X / 16; + int xCenter = (int)NPC.Center.X / 16; + int xRight = (int)(NPC.position.X + (float)NPC.width) / 16; + int y = (int)(NPC.position.Y + (float)NPC.height) / 16; + bool tileClimbing = false; + if ((Main.tile[xLeft, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xLeft, y].TileType]) || (Main.tile[xCenter, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xCenter, y].TileType]) || (Main.tile[xRight, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xRight, y].TileType])) + tileClimbing = true; + + if (tileClimbing) + { + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.velocity.Y = -0.2f; + } + + // If not rising up through tiles, occasionally spawn some dust + else + { + NPC.noGravity = false; + NPC.noTileCollide = false; + if (Main.rand.NextBool()) + { + int sand = Dust.NewDust(new Vector2(NPC.position.X - 4f, NPC.position.Y + (float)NPC.height - 8f), NPC.width + 8, 24, DustID.Sand, 0f, NPC.velocity.Y / 2f, 0, default(Color), 1f); + Dust dust = Main.dust[sand]; + dust.velocity.X *= 0.4f; + dust.velocity.Y *= -1f; + if (Main.rand.NextBool()) + { + dust.noGravity = true; + dust.scale += 0.2f; + } + } + } + } + catch + { + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs new file mode 100644 index 0000000000..dca24249e1 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs @@ -0,0 +1,371 @@ +using CalamityMod.NPCs.PlagueEnemies; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class BatAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.type == NPCID.Hellbat || NPC.type == NPCID.Lavabat) + { + int lavaDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 2f); + Main.dust[lavaDust].noGravity = true; + } + + if (NPC.type == NPCID.IceBat && Main.rand.NextBool(10)) + { + int iceDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.IceRod, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceDust].noGravity = true; + Dust dust = Main.dust[iceDust]; + dust.velocity *= 0.2f; + Main.dust[iceDust].noLight = true; + } + + NPC.noGravity = true; + + // Collision on the X axis. + if (NPC.collideX) + { + NPC.velocity.X = NPC.oldVelocity.X * -0.5f; + if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) + NPC.velocity.X = 2f; + if (NPC.direction == 1 && NPC.velocity.X < 0f && NPC.velocity.X > -2f) + NPC.velocity.X = -2f; + } + + // Collision on Y axis. + if (NPC.collideY) + { + NPC.velocity.Y = NPC.oldVelocity.Y * -0.5f; + if (NPC.velocity.Y > 0f && NPC.velocity.Y < 1f) + NPC.velocity.Y = 1f; + if (NPC.velocity.Y < 0f && NPC.velocity.Y > -1f) + NPC.velocity.Y = -1f; + } + + if (NPC.type == NPCID.FlyingSnake) + { + int direction = 1; + int directionY = 1; + if (NPC.velocity.X < 0f) + direction = -1; + if (NPC.velocity.Y < 0f) + directionY = -1; + + NPC.TargetClosest(); + + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.direction = direction; + NPC.directionY = directionY; + } + } + else + NPC.TargetClosest(); + + float maxSpeedX = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; + float maxSpeedY = CalamityWorld.death ? 2.5f : CalamityWorld.revenge ? 2f : 1.5f; + + float xAccel = CalamityWorld.revenge ? 0.12f : 0.1f; + float xAccelBoost1 = CalamityWorld.revenge ? 0.12f : 0.1f; + float xAccelBoost2 = CalamityWorld.revenge ? 0.06f : 0.04f; + + float yAccel = CalamityWorld.revenge ? 0.06f : 0.04f; + float yAccelBoost1 = CalamityWorld.revenge ? 0.07f : 0.05f; + float yAccelBoost2 = CalamityWorld.revenge ? 0.05f : 0.03f; + + if (NPC.type == NPCID.VampireBat) + { + if (NPC.position.Y < Main.worldSurface * 16.0 && Main.dayTime && !Main.eclipse) + { + NPC.directionY = -1; + NPC.direction *= -1; + } + + maxSpeedX = maxSpeedY = CalamityWorld.death ? 11f : 9f; + xAccel = yAccel = 0.3f; + xAccelBoost1 = yAccelBoost1 = 0.12f; + xAccelBoost2 = yAccelBoost2 = 0.07f; + } + else if (NPC.type == NPCID.FlyingSnake) + { + maxSpeedX = CalamityWorld.death ? 9f : 6f; + maxSpeedY = CalamityWorld.death ? 5f : 3.5f; + + xAccel = 0.3f; + xAccelBoost1 = 0.12f; + xAccelBoost2 = 0.07f; + + yAccel = 0.12f; + yAccelBoost1 = 0.07f; + yAccelBoost2 = 0.05f; + } + + DemonEyeAI.DemonEyeBatMovement(NPC, maxSpeedX, maxSpeedY, xAccel, xAccelBoost1, xAccelBoost2, yAccel, yAccelBoost1, yAccelBoost2); + + if (NPC.type == NPCID.CaveBat || + NPC.type == NPCID.JungleBat || + NPC.type == NPCID.Hellbat || + NPC.type == NPCID.Demon || + NPC.type == NPCID.VoodooDemon || + NPC.type == NPCID.GiantBat || + NPC.type == NPCID.IlluminantBat || + NPC.type == NPCID.IceBat || + NPC.type == NPCID.Lavabat || + NPC.type == NPCID.GiantFlyingFox || + NPC.type == ModContent.NPCType()) + { + maxSpeedX = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; + maxSpeedY = CalamityWorld.death ? 2.5f : CalamityWorld.revenge ? 2f : 1.5f; + if (NPC.wet) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.95f; + + NPC.velocity.Y -= CalamityWorld.revenge ? 0.6f : 0.5f; + if (NPC.velocity.Y < -5f) + NPC.velocity.Y = -5f; + + NPC.TargetClosest(); + } + + if (NPC.type == NPCID.Hellbat) + { + xAccel = 0.12f; + xAccelBoost1 = 0.09f; + xAccelBoost2 = 0.05f; + + yAccel = 0.06f; + yAccelBoost1 = 0.05f; + yAccelBoost2 = 0.03f; + } + else + { + xAccel = CalamityWorld.revenge ? 0.12f : 0.1f; + xAccelBoost1 = CalamityWorld.revenge ? 0.12f : 0.1f; + xAccelBoost2 = CalamityWorld.revenge ? 0.07f : 0.05f; + + yAccel = CalamityWorld.revenge ? 0.06f : 0.04f; + yAccelBoost1 = CalamityWorld.revenge ? 0.07f : 0.05f; + yAccelBoost2 = CalamityWorld.revenge ? 0.05f : 0.03f; + } + + DemonEyeAI.DemonEyeBatMovement(NPC, maxSpeedX, maxSpeedY, xAccel, xAccelBoost1, xAccelBoost2, yAccel, yAccelBoost1, yAccelBoost2); + } + + if (NPC.type == NPCID.Harpy && NPC.wet) + { + NPC.ai[0] = 0f; + + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.95f; + + NPC.velocity.Y -= CalamityWorld.revenge ? 0.6f : 0.5f; + if (NPC.velocity.Y < -5f) + NPC.velocity.Y = -5f; + + NPC.TargetClosest(); + } + + // Turn back into a walking bat when possible + if (NPC.type == NPCID.VampireBat && Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.Distance(Main.player[NPC.target].Center) < 200f && + NPC.Center.Y < Main.player[NPC.target].Center.Y && + Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.Transform(NPCID.Vampire); + } + } + + NPC.ai[1] += CalamityWorld.revenge ? 2f : 1f; + if (NPC.type == NPCID.VampireBat) + NPC.ai[1] += 1f; + + if (NPC.ai[1] > 200f) + { + if (!Main.player[NPC.target].wet && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.ai[1] = 0f; + + xAccel = CalamityWorld.revenge ? 0.25f : 0.2f; + yAccel = CalamityWorld.revenge ? 0.12f : 0.1f; + + float maxVelocityX = CalamityWorld.revenge ? 4.6f : 4f; + float maxVelocityY = CalamityWorld.revenge ? 1.8f : 1.5f; + + if (NPC.type == NPCID.Harpy || NPC.type == NPCID.Demon || NPC.type == NPCID.VoodooDemon) + { + xAccel = CalamityWorld.revenge ? 0.15f : 0.12f; + yAccel = CalamityWorld.revenge ? 0.1f : 0.07f; + maxVelocityX = CalamityWorld.revenge ? 3.5f : 3f; + maxVelocityY = CalamityWorld.revenge ? 1.5f : 1.25f; + } + + if (NPC.ai[1] > 1000f) + NPC.ai[1] = 0f; + + NPC.ai[2] += 1f; + if (NPC.ai[2] > 0f) + { + if (NPC.velocity.Y < maxVelocityY) + NPC.velocity.Y += yAccel; + } + else if (NPC.velocity.Y > -maxVelocityY) + NPC.velocity.Y -= yAccel; + + if (NPC.ai[2] < -150f || NPC.ai[2] > 150f) + { + if (NPC.velocity.X < maxVelocityX) + NPC.velocity.X += xAccel; + } + else if (NPC.velocity.X > -maxVelocityX) + NPC.velocity.X -= xAccel; + + if (NPC.ai[2] > 300f) + NPC.ai[2] = -300f; + } + + if (NPC.type == NPCID.Harpy) + { + // Emit feather dust from center when about to shoot + if (NPC.ai[0] > HarpyFeatherGateValue - HarpyFeatherTelegraphTime) + { + Dust dust = Dust.NewDustDirect(NPC.Center + Main.rand.NextVector2CircularEdge(5f, 5f), 1, 1, DustID.DungeonWater, 0f, 0f, 0, default, 1.5f); + dust.noGravity = true; + dust.velocity *= 0f; + } + } + else if (NPC.type == NPCID.Demon || NPC.type == NPCID.VoodooDemon) + { + // Emit shadowflame dust from center when about to shoot + if (NPC.ai[0] > DemonScytheGateValue - DemonScytheTelegraphTime) + { + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Shadowflame, 0f, 0f, 100, default, 3f); + dust.noGravity = true; + dust.velocity *= 0f; + } + } + else if (NPC.type == NPCID.RedDevil) + { + // Emit shadowflame dust from center when about to shoot + if (NPC.ai[0] > RedDevilTridentGateValue - RedDevilTridentTelegraphTime) + { + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Shadowflame, 0f, 0f, 100, default, 3f); + dust.noGravity = true; + dust.velocity *= 0f; + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.type == NPCID.Harpy) + { + float featherShootCutOffValue = CalamityWorld.revenge ? 90f : 60f; + if (NPC.justHit || !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.ai[0] = featherShootCutOffValue + 1f; + + if (NPC.ai[0] >= HarpyFeatherGateValue) + { + NPC.ai[0] = 0f; + } + else if (NPC.ai[0] % 30f == 0f && NPC.ai[0] <= featherShootCutOffValue) + { + NPC.ai[0] += 1f; + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + int damage = 15; + int type = ProjectileID.HarpyFeather; + Vector2 featherVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (CalamityWorld.death ? 4f : 6f); + + int feather = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, featherVelocity, type, damage, 0f, Main.myPlayer); + Main.projectile[feather].timeLeft = 300; + if (CalamityWorld.death) + { + Main.projectile[feather].extraUpdates += 1; + Main.projectile[feather].timeLeft = 600; + } + } + } + else + NPC.ai[0] += 1f; + } + + if (NPC.type == NPCID.Demon || NPC.type == NPCID.VoodooDemon) + { + float scytheShootCutOffValue = CalamityWorld.revenge ? 80f : 60f; + if (NPC.justHit || !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.ai[0] = scytheShootCutOffValue + 1f; + + if (NPC.ai[0] >= DemonScytheGateValue) + { + NPC.ai[0] = 0f; + } + else if (NPC.ai[0] % 20f == 0f && NPC.ai[0] <= scytheShootCutOffValue) + { + NPC.ai[0] += 1f; + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + int damage = 21; + int type = ProjectileID.DemonSickle; + Vector2 sickleVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (CalamityWorld.death ? 0.15f : 0.2f); + + int sickle = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, sickleVelocity, type, damage, 0f, Main.myPlayer); + Main.projectile[sickle].timeLeft = 300; + if (CalamityWorld.death) + { + Main.projectile[sickle].extraUpdates += 1; + Main.projectile[sickle].timeLeft = 600; + } + } + } + else + NPC.ai[0] += 1f; + } + + if (NPC.type == NPCID.RedDevil) + { + float tridentShootCutOffValue = 80f; + if (NPC.justHit || !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.ai[0] = tridentShootCutOffValue + 1f; + + if (NPC.ai[0] >= RedDevilTridentGateValue) + { + NPC.ai[0] = 0f; + } + else if (NPC.ai[0] % 20f == 0f && NPC.ai[0] <= tridentShootCutOffValue) + { + NPC.ai[0] += 1f; + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + Vector2 spawnPosition = NPC.Center; + + float tridentSpeed = CalamityWorld.death ? 0.15f : 0.2f; + Vector2 tridentVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * tridentSpeed; + spawnPosition += NPC.velocity * 5f; + + int damage = 80; + int type = ProjectileID.UnholyTridentHostile; + int trident = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition + tridentVelocity * 100f, tridentVelocity, type, damage, 3f, Main.myPlayer); + Main.projectile[trident].timeLeft = 300; + if (CalamityWorld.death) + { + Main.projectile[trident].extraUpdates += 1; + Main.projectile[trident].timeLeft = 600; + } + } + } + else + NPC.ai[0] += 1f; + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BigMimicAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BigMimicAI.cs new file mode 100644 index 0000000000..da72c9f7ed --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BigMimicAI.cs @@ -0,0 +1,383 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class BigMimicAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.knockBackResist = 0.2f * Main.GameModeInfo.KnockbackToEnemiesMultiplier; + NPC.dontTakeDamage = false; + NPC.noTileCollide = false; + NPC.noGravity = false; + NPC.reflectsProjectiles = false; + if (NPC.ai[0] != 7f && Main.player[NPC.target].dead) + { + NPC.TargetClosest(); + if (Main.player[NPC.target].dead) + { + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + } + + if (NPC.ai[0] == 0f) + { + NPC.TargetClosest(); + Vector2 mimicTargetDirection = Main.player[NPC.target].Center - NPC.Center; + if (Main.netMode != NetmodeID.MultiplayerClient && (NPC.velocity.X != 0f || NPC.velocity.Y > 100f || NPC.justHit || mimicTargetDirection.Length() < 80f)) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + } + else if (NPC.ai[0] == 1f) + { + NPC.ai[1] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] > 36f) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + } + else if (NPC.ai[0] == 2f) + { + Vector2 mimicTargetDirection2 = Main.player[NPC.target].Center - NPC.Center; + if (Main.netMode != NetmodeID.MultiplayerClient && mimicTargetDirection2.Length() > 600f) + { + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + if (NPC.velocity.Y == 0f) + { + NPC.TargetClosest(); + NPC.velocity.X *= 0.85f; + NPC.ai[1] += 1f; + float jumpDelay = 10f + (CalamityWorld.death ? 10f : 20f) * (NPC.life / (float)NPC.lifeMax); + float jumpXVelocity = 5f + (CalamityWorld.death ? 7f : 5f) * (1f - NPC.life / (float)NPC.lifeMax); + float jumpYVelocity = CalamityWorld.death ? 7f : 5f; + if (!Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + jumpYVelocity += 2f; + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] > jumpDelay) + { + NPC.ai[3] += 1f; + if (NPC.ai[3] >= 3f) + { + NPC.ai[3] = 0f; + jumpYVelocity *= 2f; + jumpXVelocity /= 2f; + } + + NPC.ai[1] = 0f; + NPC.velocity.Y -= jumpYVelocity; + NPC.velocity.X = jumpXVelocity * NPC.direction; + NPC.netUpdate = true; + } + } + else + { + NPC.knockBackResist = 0f; + NPC.velocity.X *= 0.99f; + if (NPC.direction < 0 && NPC.velocity.X > -1f) + NPC.velocity.X = -1f; + + if (NPC.direction > 0 && NPC.velocity.X < 1f) + NPC.velocity.X = 1f; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] > (CalamityWorld.death ? 130f : 170f) && NPC.velocity.Y == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + switch (Main.rand.Next(3)) + { + case 0: + NPC.ai[0] = 3f; + break; + case 1: + NPC.ai[0] = 4f; + NPC.noTileCollide = true; + NPC.velocity.Y = CalamityWorld.death ? -12f : -10f; + break; + case 2: + NPC.ai[0] = 6f; + break; + default: + NPC.ai[0] = 2f; + break; + } + + if (Main.tenthAnniversaryWorld && NPC.type == NPCID.BigMimicJungle && NPC.ai[0] == 3f && Main.rand.NextBool()) + NPC.ai[0] = 8f; + + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + } + else if (NPC.ai[0] == 3f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.velocity.X *= 0.85f; + NPC.dontTakeDamage = true; + NPC.ai[1] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] >= (CalamityWorld.death ? 60f : 90f)) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + if (Main.expertMode) + { + NPC.ReflectProjectiles(NPC.Hitbox); + NPC.reflectsProjectiles = true; + } + } + else if (NPC.ai[0] == 4f) + { + NPC.noTileCollide = true; + NPC.noGravity = true; + NPC.knockBackResist = 0f; + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + NPC.spriteDirection = NPC.direction; + NPC.TargetClosest(); + Vector2 mimicTargetCenter = Main.player[NPC.target].Center; + mimicTargetCenter.Y -= 350f; + Vector2 mimicTargetDirection = mimicTargetCenter - NPC.Center; + if (NPC.ai[2] == 1f) + { + NPC.ai[1] += 1f; + mimicTargetDirection = Main.player[NPC.target].Center - NPC.Center; + mimicTargetDirection.Normalize(); + mimicTargetDirection *= CalamityWorld.death ? 12f : 10f; + NPC.velocity = (NPC.velocity * 4f + mimicTargetDirection) / 5f; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] > 6f) + { + NPC.ai[1] = 0f; + NPC.ai[0] = 4.1f; + NPC.ai[2] = 0f; + NPC.velocity = mimicTargetDirection; + NPC.netUpdate = true; + } + } + else if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 40f && NPC.Center.Y < Main.player[NPC.target].Center.Y - 300f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 1f; + NPC.netUpdate = true; + } + } + else + { + mimicTargetDirection.Normalize(); + mimicTargetDirection *= CalamityWorld.death ? 16f : 14f; + NPC.velocity = (NPC.velocity * 5f + mimicTargetDirection) / 6f; + } + } + else if (NPC.ai[0] == 4.1f) + { + NPC.knockBackResist = 0f; + if (NPC.ai[2] == 0f && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.ai[2] = 1f; + + if (NPC.position.Y + NPC.height >= Main.player[NPC.target].position.Y || NPC.velocity.Y <= 0f) + { + NPC.ai[1] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] > 10f) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + if (Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.ai[0] = 5f; + } + } + else if (NPC.ai[2] == 0f) + { + NPC.noTileCollide = true; + NPC.noGravity = true; + NPC.knockBackResist = 0f; + } + + NPC.velocity.Y += CalamityWorld.death ? 0.3f : 0.25f; + if (NPC.velocity.Y > (CalamityWorld.death ? 24f : 20f)) + NPC.velocity.Y = CalamityWorld.death ? 24f : 20f; + } + else if (NPC.ai[0] == 5f) + { + if (NPC.velocity.X > 0f) + NPC.direction = 1; + else + NPC.direction = -1; + + NPC.spriteDirection = NPC.direction; + NPC.noTileCollide = true; + NPC.noGravity = true; + NPC.knockBackResist = 0f; + Vector2 chaseTargetDirection = Main.player[NPC.target].Center - NPC.Center; + chaseTargetDirection.Y -= 4f; + if (Main.netMode != NetmodeID.MultiplayerClient && chaseTargetDirection.Length() < 200f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + if (chaseTargetDirection.Length() > 10f) + { + chaseTargetDirection.Normalize(); + chaseTargetDirection *= CalamityWorld.death ? 15f : 12.5f; + } + + NPC.velocity = (NPC.velocity * 4f + chaseTargetDirection) / 5f; + } + else if (NPC.ai[0] == 6f) + { + NPC.knockBackResist = 0f; + if (NPC.velocity.Y == 0f) + { + NPC.TargetClosest(); + NPC.velocity.X *= 0.8f; + NPC.ai[1] += 1f; + if (NPC.ai[1] > 5f) + { + NPC.ai[1] = 0f; + NPC.velocity.Y -= 4f; + if (Main.player[NPC.target].position.Y + Main.player[NPC.target].height < NPC.Center.Y) + NPC.velocity.Y -= 1.25f; + + if (Main.player[NPC.target].position.Y + Main.player[NPC.target].height < NPC.Center.Y - 40f) + NPC.velocity.Y -= 1.5f; + + if (Main.player[NPC.target].position.Y + Main.player[NPC.target].height < NPC.Center.Y - 80f) + NPC.velocity.Y -= 1.75f; + + if (Main.player[NPC.target].position.Y + Main.player[NPC.target].height < NPC.Center.Y - 120f) + NPC.velocity.Y -= 2f; + + if (Main.player[NPC.target].position.Y + Main.player[NPC.target].height < NPC.Center.Y - 160f) + NPC.velocity.Y -= 2.25f; + + if (Main.player[NPC.target].position.Y + Main.player[NPC.target].height < NPC.Center.Y - 200f) + NPC.velocity.Y -= 2.5f; + + if (!Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + NPC.velocity.Y -= 2f; + + NPC.velocity.X = (CalamityWorld.death ? 16 : 14) * NPC.direction; + NPC.ai[2] += 1f; + NPC.netUpdate = true; + } + } + else + { + NPC.velocity.X *= 0.98f; + if (NPC.direction < 0 && NPC.velocity.X > -8f) + NPC.velocity.X = -8f; + + if (NPC.direction > 0 && NPC.velocity.X < 8f) + NPC.velocity.X = 8f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] >= 3f && NPC.velocity.Y == 0f) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + } + else if (NPC.ai[0] == 7f) + { + NPC.damage = 0; + NPC.life = NPC.lifeMax; + NPC.defense = 9999; + NPC.noTileCollide = true; + NPC.alpha += 7; + if (NPC.alpha > 255) + NPC.alpha = 255; + + NPC.velocity.X *= 0.98f; + } + else + { + if (NPC.ai[0] != 8f) + return false; + + NPC.velocity.X *= 0.85f; + NPC.ai[1] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!Main.tenthAnniversaryWorld || NPC.ai[1] >= 180f) + { + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + else if (NPC.ai[1] % 20f == 0f) + { + int num = 10; + for (int i = 0; i < num; i++) + { + int itemID = ItemID.Sets.ItemsForStuffCannon[Main.rand.Next(ItemID.Sets.ItemsForStuffCannon.Length)]; + int item = Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, itemID, 1, noBroadcast: false, -1, noGrabDelay: true); + float randomSpeed = Main.rand.Next(10, 26); + Vector2 vector = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + Vector2 vector2 = Main.player[NPC.target].Center - new Vector2(0f, 120f); + float targetXDist = vector2.X - vector.X; + float targetYDist = vector2.Y - vector.Y; + targetXDist += Main.rand.Next(-50, 51) * 0.1f; + targetYDist += Main.rand.Next(-50, 51) * 0.1f; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = randomSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist += Main.rand.Next(-50, 51) * 0.1f; + targetYDist += Main.rand.Next(-50, 51) * 0.1f; + Main.item[item].velocity.X = targetXDist; + Main.item[item].velocity.Y = targetYDist; + Main.item[item].noGrabDelay = 100; + if (Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, item); + } + } + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BlazingWheelAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BlazingWheelAI.cs new file mode 100644 index 0000000000..e2d7596b4e --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BlazingWheelAI.cs @@ -0,0 +1,98 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class BlazingWheelAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.ai[0] == 0f) + { + NPC.TargetClosest(); + NPC.directionY = 1; + NPC.ai[0] = 1f; + } + + int wheelVelocity = CalamityWorld.death ? 9 : 6; + if (NPC.ai[1] == 0f) + { + NPC.rotation += (float)(NPC.direction * NPC.directionY) * 0.13f; + + if (NPC.collideY) + NPC.ai[0] = 2f; + + if (!NPC.collideY && NPC.ai[0] == 2f) + { + NPC.direction = -NPC.direction; + NPC.ai[1] = 1f; + NPC.ai[0] = 1f; + } + + if (NPC.collideX) + { + NPC.directionY = -NPC.directionY; + NPC.ai[1] = 1f; + } + } + else + { + NPC.rotation -= (float)(NPC.direction * NPC.directionY) * 0.13f; + + if (NPC.collideX) + NPC.ai[0] = 2f; + + if (!NPC.collideX && NPC.ai[0] == 2f) + { + NPC.directionY = -NPC.directionY; + NPC.ai[1] = 0f; + NPC.ai[0] = 1f; + } + + if (NPC.collideY) + { + NPC.direction = -NPC.direction; + NPC.ai[1] = 0f; + } + } + + NPC.velocity.X = (float)(wheelVelocity * NPC.direction); + NPC.velocity.Y = (float)(wheelVelocity * NPC.directionY); + + float lighting = (float)(270 - (int)Main.mouseTextColor) / 400f; + Lighting.AddLight((int)(NPC.position.X + (float)(NPC.width / 2)) / 16, (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16, 0.9f, 0.3f + lighting, 0.2f); + + // Emit fire dust from center when about to fire + if (NPC.localAI[0] > (CalamityWorld.death ? BlazingWheelFlameGateValue_Death : BlazingWheelFlameGateValue) - BlazingWheelTelegraphTime) + { + Dust dust = Dust.NewDustDirect(NPC.Center + Main.rand.NextVector2CircularEdge(5f, 5f), 1, 1, DustID.Torch, 0f, 0f, 0, default, 3f); + dust.noGravity = true; + dust.velocity *= 0f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= (CalamityWorld.death ? BlazingWheelFlameGateValue_Death : BlazingWheelFlameGateValue)) + { + NPC.localAI[0] = 0f; + for (int i = 0; i < 4; i++) + { + Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(MathHelper.PiOver2 * (float)i)); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector255, ProjectileID.FlamesTrap, 20, 0f, Main.myPlayer); + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].friendly = false; + Main.projectile[proj].trap = false; + } + } + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs new file mode 100644 index 0000000000..165932bcf7 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs @@ -0,0 +1,493 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class CasterAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.TargetClosest(); + NPC.velocity.X *= 0.93f; + if ((double)NPC.velocity.X > -0.1 && (double)NPC.velocity.X < 0.1) + NPC.velocity.X = 0f; + + if (NPC.ai[0] == 0f) + NPC.ai[0] = 500f; + + if (NPC.type == NPCID.RuneWizard) + { + if (NPC.alpha < 255) + NPC.alpha++; + if (NPC.justHit) + NPC.alpha = 0; + } + + if (NPC.ai[2] != 0f && NPC.ai[3] != 0f) + { + if (NPC.type == NPCID.RuneWizard) + NPC.alpha = 255; + + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + for (int i = 0; i < 50; i++) + { + if (NPC.type == NPCID.GoblinSorcerer || NPC.type == NPCID.Tim) + { + int goblinDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); + Dust dust = Main.dust[goblinDust]; + dust.velocity *= 3f; + if (Main.dust[goblinDust].scale > 1f) + Main.dust[goblinDust].noGravity = true; + } + else if (NPC.type == NPCID.DarkCaster) + { + int darkCasterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.DungeonWater, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[darkCasterDust]; + dust.velocity *= 3f; + Main.dust[darkCasterDust].noGravity = true; + } + else if (NPC.type == NPCID.Necromancer || NPC.type == NPCID.NecromancerArmored) + { + int necromancerDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.ShadowbeamStaff, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necromancerDust]; + dust.velocity *= 2f; + Main.dust[necromancerDust].scale = 1.4f; + } + else if (NPC.type == NPCID.DiabolistRed || NPC.type == NPCID.DiabolistWhite) + { + int diabolistDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.InfernoFork, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[diabolistDust]; + dust.velocity *= 3f; + Main.dust[diabolistDust].noGravity = true; + } + else if (NPC.type == NPCID.RaggedCaster || NPC.type == NPCID.RaggedCasterOpenCoat) + { + int raggedCasterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.SpectreStaff, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[raggedCasterDust]; + dust.velocity *= 3f; + Main.dust[raggedCasterDust].noGravity = true; + } + else if (NPC.type == NPCID.RuneWizard) + { + int runeWizardDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.RuneWizard, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[runeWizardDust]; + dust.velocity *= 3f; + Main.dust[runeWizardDust].noGravity = true; + } + else if (NPC.type == NPCID.DesertDjinn) + { + int desertSpiritDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[desertSpiritDust]; + dust.velocity *= 3f; + Main.dust[desertSpiritDust].noGravity = true; + } + else + { + int fireImpDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[fireImpDust]; + dust.velocity *= 3f; + Main.dust[fireImpDust].noGravity = true; + } + } + + NPC.position.X = NPC.ai[2] * 16f - (float)(NPC.width / 2) + 8f; + NPC.position.Y = NPC.ai[3] * 16f - (float)NPC.height; + + NPC.velocity.X = 0f; + NPC.velocity.Y = 0f; + + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + for (int j = 0; j < 50; j++) + { + if (NPC.type == NPCID.GoblinSorcerer || NPC.type == NPCID.Tim) + { + int goblinCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); + Dust dust = Main.dust[goblinCastDust]; + dust.velocity *= 3f; + if (Main.dust[goblinCastDust].scale > 1f) + Main.dust[goblinCastDust].noGravity = true; + } + else if (NPC.type == NPCID.DarkCaster) + { + int darkCasterCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.DungeonWater, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[darkCasterCastDust]; + dust.velocity *= 3f; + Main.dust[darkCasterCastDust].noGravity = true; + } + else if (NPC.type == NPCID.RuneWizard) + { + int runeWizardCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.RuneWizard, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[runeWizardCastDust]; + dust.velocity *= 3f; + Main.dust[runeWizardCastDust].noGravity = true; + } + else if (NPC.type == NPCID.Necromancer || NPC.type == NPCID.NecromancerArmored) + { + int necromancerCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.ShadowbeamStaff, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necromancerCastDust]; + dust.velocity *= 2f; + Main.dust[necromancerCastDust].scale = 1.4f; + } + else if (NPC.type == NPCID.DiabolistRed || NPC.type == NPCID.DiabolistWhite) + { + int diabolistCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.InfernoFork, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[diabolistCastDust]; + dust.velocity *= 3f; + Main.dust[diabolistCastDust].noGravity = true; + } + else if (NPC.type == NPCID.RaggedCaster || NPC.type == NPCID.RaggedCasterOpenCoat) + { + int raggedCasterCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.SpectreStaff, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[raggedCasterCastDust]; + dust.velocity *= 3f; + Main.dust[raggedCasterCastDust].noGravity = true; + } + else if (NPC.type == NPCID.DesertDjinn) + { + int desertSpiritCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Shadowflame, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[desertSpiritCastDust]; + dust.velocity *= 3f; + Main.dust[desertSpiritCastDust].noGravity = true; + } + else + { + int fireImpCastDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[fireImpCastDust]; + dust.velocity *= 3f; + Main.dust[fireImpCastDust].noGravity = true; + } + } + } + + if (NPC.justHit) + NPC.ai[0] = (NPC.type == NPCID.RuneWizard && Main.zenithWorld) ? 5f : CalamityWorld.revenge ? 2f : 1f; + + NPC.ai[0] += (NPC.type == NPCID.RuneWizard && Main.zenithWorld) ? 5f : CalamityWorld.revenge ? 2f : 1f; + + if (NPC.type == NPCID.Necromancer || NPC.type == NPCID.NecromancerArmored) + { + if (NPC.ai[0] % 50f == 0f && NPC.ai[0] <= 250f) + { + NPC.ai[1] = 55f; + NPC.netUpdate = true; + } + + if (NPC.ai[0] >= 400f) + NPC.ai[0] = 700f; + } + else if (NPC.type == NPCID.RuneWizard) + { + if (NPC.ai[0] == 80f || NPC.ai[0] == 150f || NPC.ai[0] == 230f || NPC.ai[0] == 300f || NPC.ai[0] == 380f || NPC.ai[0] == 450f) + { + NPC.ai[1] = 55f; + NPC.netUpdate = true; + } + } + else if (NPC.type == NPCID.DesertDjinn) + { + if (NPC.ai[0] == 180f) + { + NPC.ai[1] = 181f; + NPC.netUpdate = true; + } + } + else if (NPC.type == NPCID.RaggedCaster || NPC.type == NPCID.RaggedCasterOpenCoat) + { + if (NPC.ai[0] == 20f || NPC.ai[0] == 40f || NPC.ai[0] == 60f || NPC.ai[0] == 120f || NPC.ai[0] == 140f || NPC.ai[0] == 160f || NPC.ai[0] == 220f || NPC.ai[0] == 240f || NPC.ai[0] == 260f) + { + NPC.ai[1] = 55f; + NPC.netUpdate = true; + } + + if (NPC.ai[0] >= 460f) + NPC.ai[0] = 700f; + } + else + { + if (Main.getGoodWorld && NPC.type == NPCID.FireImp) + { + if (NPC.AnyNPCs(NPCID.WallofFlesh)) + { + NPC.ai[0] += 1f; + if (NPC.ai[0] % 2f == 1f) + NPC.ai[0] -= 1f; + } + } + + if (NPC.ai[0] % 100f == 0f && NPC.ai[0] <= 300f) + { + NPC.ai[1] = 55f; + NPC.netUpdate = true; + } + } + + if ((NPC.type == NPCID.DiabolistRed || NPC.type == NPCID.DiabolistWhite) && NPC.ai[0] > 400f) + NPC.ai[0] = 650f; + + if (NPC.type == NPCID.DesertDjinn && NPC.ai[0] >= 360f) + NPC.ai[0] = 650f; + + if (NPC.ai[0] >= 650f && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = CalamityWorld.revenge ? 2f : 1f; + int targetTileX = (int)Main.player[NPC.target].position.X / 16; + int targetTileY = (int)Main.player[NPC.target].position.Y / 16; + Vector2 chosenTile = Vector2.Zero; + if (NPC.AI_AttemptToFindTeleportSpot(ref chosenTile, targetTileX, targetTileY)) + { + NPC.ai[1] = 20f; + NPC.ai[2] = chosenTile.X; + NPC.ai[3] = chosenTile.Y; + } + + NPC.netUpdate = true; + } + + if (NPC.ai[1] > 0f) + { + NPC.ai[1] -= 1f; + if (NPC.type == NPCID.DesertDjinn) + { + if (NPC.ai[1] % 30f == 0f && NPC.ai[1] / 30f < 5f) + { + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Point spiritCenter = NPC.Center.ToTileCoordinates(); + Point targetCenter = Main.player[NPC.target].Center.ToTileCoordinates(); + Vector2 targetDirection = Main.player[NPC.target].Center - NPC.Center; + int randProjRadius = 6; + int spiritSpawnRadius = 6; + int targetSpawnRadius = 0; + int solidTileCheckRadius = 2; + int projSpawnTries = 0; + bool targetTooFar = false; + if (targetDirection.Length() > 2000f) + targetTooFar = true; + + while (!targetTooFar) + { + if (projSpawnTries >= 50) + break; + + projSpawnTries++; + int spiritProjSpawnX = Main.rand.Next(targetCenter.X - randProjRadius, targetCenter.X + randProjRadius + 1); + int spiritProjSpawnY = Main.rand.Next(targetCenter.Y - randProjRadius, targetCenter.Y + randProjRadius + 1); + if ((spiritProjSpawnY < targetCenter.Y - targetSpawnRadius || spiritProjSpawnY > targetCenter.Y + targetSpawnRadius || spiritProjSpawnX < targetCenter.X - targetSpawnRadius || spiritProjSpawnX > targetCenter.X + targetSpawnRadius) && (spiritProjSpawnY < spiritCenter.Y - spiritSpawnRadius || spiritProjSpawnY > spiritCenter.Y + spiritSpawnRadius || spiritProjSpawnX < spiritCenter.X - spiritSpawnRadius || spiritProjSpawnX > spiritCenter.X + spiritSpawnRadius) && !Main.tile[spiritProjSpawnX, spiritProjSpawnY].HasUnactuatedTile) + { + bool canSpawnProj = true; + if (canSpawnProj && Main.tile[spiritProjSpawnX, spiritProjSpawnY].LiquidType == LiquidID.Lava) + canSpawnProj = false; + if (canSpawnProj && Collision.SolidTiles(spiritProjSpawnX - solidTileCheckRadius, spiritProjSpawnX + solidTileCheckRadius, spiritProjSpawnY - solidTileCheckRadius, spiritProjSpawnY + solidTileCheckRadius)) + canSpawnProj = false; + + if (canSpawnProj) + { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), (float)(spiritProjSpawnX * 16 + 8), (float)(spiritProjSpawnY * 16 + 8), 0f, 0f, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)NPC.target, 0f); + if (CalamityWorld.death) + Main.projectile[proj].extraUpdates += 1; + + break; + } + } + } + } + } + } + else if (NPC.ai[1] == 25f) + { + if (NPC.type >= NPCID.RaggedCaster && NPC.type <= NPCID.DiabolistWhite) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float dungeonCasterProjSpeed = CalamityWorld.death ? 8f : 6f; + if (NPC.type == NPCID.DiabolistRed || NPC.type == NPCID.DiabolistWhite) + dungeonCasterProjSpeed = CalamityWorld.death ? 10f : 8f; + if (NPC.type == NPCID.RaggedCaster || NPC.type == NPCID.RaggedCasterOpenCoat) + dungeonCasterProjSpeed = CalamityWorld.death ? 5f : 4f; + + Vector2 dungeonCasterPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y); + float dungeonCasterTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - dungeonCasterPos.X; + float dungeonCasterTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - dungeonCasterPos.Y; + float dungeonCasterTargetDist = (float)Math.Sqrt((double)(dungeonCasterTargetX * dungeonCasterTargetX + dungeonCasterTargetY * dungeonCasterTargetY)); + dungeonCasterTargetDist = dungeonCasterProjSpeed / dungeonCasterTargetDist; + dungeonCasterTargetX *= dungeonCasterTargetDist; + dungeonCasterTargetY *= dungeonCasterTargetDist; + + int damage = 16; + int projType = ProjectileID.ShadowBeamHostile; + if (NPC.type == NPCID.DiabolistRed || NPC.type == NPCID.DiabolistWhite) + { + projType = ProjectileID.InfernoHostileBolt; + damage = 32; + } + if (NPC.type == NPCID.RaggedCaster || NPC.type == NPCID.RaggedCasterOpenCoat) + { + projType = ProjectileID.LostSoulHostile; + damage = 32; + } + + int dungeonCasterProj = Projectile.NewProjectile(NPC.GetSource_FromAI(), dungeonCasterPos.X, dungeonCasterPos.Y, dungeonCasterTargetX, dungeonCasterTargetY, projType, damage, 0f, Main.myPlayer); + Main.projectile[dungeonCasterProj].timeLeft = 300; + if (projType == ProjectileID.InfernoHostileBolt) + { + Main.projectile[dungeonCasterProj].ai[0] = Main.player[NPC.target].Center.X; + Main.projectile[dungeonCasterProj].ai[1] = Main.player[NPC.target].Center.Y; + Main.projectile[dungeonCasterProj].netUpdate = true; + } + + NPC.localAI[0] = 0f; + } + } + else + { + if (NPC.type != NPCID.RuneWizard) + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.type == NPCID.GoblinSorcerer || NPC.type == NPCID.Tim) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + NPC.width / 2, (int)NPC.position.Y - 8, NPCID.ChaosBall); + } + else if (NPC.type == NPCID.DarkCaster) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + NPC.width / 2, (int)NPC.position.Y - 8, NPCID.WaterSphere); + } + else if (NPC.type == NPCID.RuneWizard) + { + float runeWizardProjSpeed = CalamityWorld.death ? 12f : 10f; + Vector2 vector14 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float runeWizardTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector14.X; + float runeWizardTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector14.Y; + float runeWizardTargetDist = (float)Math.Sqrt((double)(runeWizardTargetX * runeWizardTargetX + runeWizardTargetY * runeWizardTargetY)); + runeWizardTargetDist = runeWizardProjSpeed / runeWizardTargetDist; + runeWizardTargetX *= runeWizardTargetDist; + runeWizardTargetY *= runeWizardTargetDist; + int runeWizardProj = Projectile.NewProjectile(NPC.GetSource_FromAI(), vector14.X, vector14.Y, runeWizardTargetX, runeWizardTargetY, ProjectileID.RuneBlast, 40, 0f, Main.myPlayer); + Main.projectile[runeWizardProj].timeLeft = 300; + NPC.localAI[0] = 0f; + } + else + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + NPC.width / 2 + NPC.direction * 8, (int)NPC.position.Y + 20, NPCID.BurningSphere); + } + } + } + } + + if (NPC.type == NPCID.GoblinSorcerer || NPC.type == NPCID.Tim) + { + if (Main.rand.NextBool(5)) + { + int shadowflameSpawnDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 2f), NPC.width, NPC.height, DustID.Shadowflame, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 1.5f); + Dust dust = Main.dust[shadowflameSpawnDust]; + dust.noGravity = true; + dust.velocity.X *= 0.5f; + dust.velocity.Y = -2f; + } + } + else if (NPC.type == NPCID.DarkCaster) + { + if (!Main.rand.NextBool(3)) + { + int waterSpawnDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 2f), NPC.width, NPC.height, DustID.DungeonWater, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 0.9f); + Dust dust = Main.dust[waterSpawnDust]; + dust.noGravity = true; + dust.velocity.X *= 0.3f; + dust.velocity.Y *= 0.2f; + dust.velocity.Y -= 1f; + } + } + else + { + if (NPC.type == NPCID.RuneWizard) + { + int runeWizardDustAmt = 1; + if (NPC.alpha == 255) + runeWizardDustAmt = 2; + + for (int r = 0; r < runeWizardDustAmt; r++) + { + if (Main.rand.Next(255) > 255 - NPC.alpha) + { + int runeSpawnDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 2f), NPC.width, NPC.height, DustID.RuneWizard, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 1.2f); + Dust dust = Main.dust[runeSpawnDust]; + dust.noGravity = true; + dust.velocity.X *= (0.1f + (float)Main.rand.Next(30) * 0.01f); + dust.velocity.Y *= (0.1f + (float)Main.rand.Next(30) * 0.01f); + dust.scale *= 1f + (float)Main.rand.Next(6) * 0.1f; + } + } + + return false; + } + + if (NPC.type == NPCID.Necromancer || NPC.type == NPCID.NecromancerArmored) + { + if (Main.rand.NextBool()) + { + int necroSpawnDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 2f), NPC.width, NPC.height, DustID.ShadowbeamStaff, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necroSpawnDust]; + dust.velocity.X *= 0.5f; + dust.velocity.Y *= 0.5f; + } + } + else if (NPC.type == NPCID.DiabolistRed || NPC.type == NPCID.DiabolistWhite) + { + if (Main.rand.NextBool()) + { + int flameSpawnDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 2f), NPC.width, NPC.height, DustID.InfernoFork, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 1f); + Dust dust = Main.dust[flameSpawnDust]; + dust.noGravity = true; + dust.velocity *= 0.4f; + dust.velocity.Y -= 0.7f; + return false; + } + } + else if (NPC.type == NPCID.RaggedCaster || NPC.type == NPCID.RaggedCasterOpenCoat) + { + if (Main.rand.NextBool()) + { + int ghostSpawnDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 2f), NPC.width, NPC.height, DustID.SpectreStaff, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 0.1f); + Dust dust = Main.dust[ghostSpawnDust]; + dust.noGravity = true; + dust.velocity *= 0.5f; + dust.fadeIn = 1.2f; + } + } + else + { + if (NPC.type == NPCID.DesertDjinn) + { + Lighting.AddLight(NPC.Top, 0.6f, 0.6f, 0.3f); + return false; + } + + if (Main.rand.NextBool()) + { + int desertSpawnDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + 2f), NPC.width, NPC.height, DustID.Torch, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 2f); + Dust dust = Main.dust[desertSpawnDust]; + dust.noGravity = true; + dust.velocity.X *= 1f; + dust.velocity.Y *= 1f; + } + } + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CoriteAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CoriteAI.cs new file mode 100644 index 0000000000..88ad2ed1a3 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CoriteAI.cs @@ -0,0 +1,360 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class CoriteAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.TargetClosest(false); + + NPC.rotation = NPC.velocity.ToRotation(); + + if (Math.Sign(NPC.velocity.X) != 0) + { + NPC.spriteDirection = -Math.Sign(NPC.velocity.X); + } + if (NPC.rotation < -MathHelper.PiOver2) + { + NPC.rotation += MathHelper.Pi; + } + if (NPC.rotation > MathHelper.PiOver2) + { + NPC.rotation -= MathHelper.Pi; + } + + if (NPC.type == NPCID.SolarCorite) + { + NPC.spriteDirection = Math.Sign(NPC.velocity.X); + } + + float npcKBResist = 0.4f; + + float upwardChargeSpeed = 12f; + float idealUpwardDelta = 200f; + float maximumDistanceBeforeCharge = 900f; + float upwardMovementIntertia = 30f; + + float chargePhaseWait = 30f; + float chargeWaitSlowdownMult = 0.95f; + int chargeRandomness = 50; + float chargeSpeed = 14f; + float maximumChargeTime = 30f; + float chargeDistanceCheck = 100f; + float chargeIntertia = 20f; + float chargeAcceleration = 0f; + + // Stops charging if speed is less than this when charging. + float minimumChargeSpeed = 7f; + + bool hasCoolDustPhase = true; + + if (NPC.type == NPCID.SolarCorite) + { + npcKBResist = 0.3f; + upwardChargeSpeed = 10f; + idealUpwardDelta = 300f; + maximumDistanceBeforeCharge = 1000f; + upwardMovementIntertia = 60f; + chargePhaseWait = 5f; + chargeWaitSlowdownMult = 0.8f; + chargeRandomness = 0; + chargeSpeed = 10f; + chargeDistanceCheck = 150f; + chargeIntertia = 60f; + chargeAcceleration = 0.333333343f; + minimumChargeSpeed = 8f; + hasCoolDustPhase = false; + } + + chargeAcceleration *= chargeIntertia; + + if (CalamityWorld.death) + { + upwardChargeSpeed *= 1.25f; + chargeSpeed *= 1.25f; + } + + // Drone dust + if (NPC.type == NPCID.MartianDrone && NPC.ai[0] != 3f) + { + int idx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric, 0f, 0f, 100, default, 0.5f); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity = NPC.velocity / 5f; + Vector2 rotationVector = new Vector2(-10f, 10f); + + if (NPC.spriteDirection == 1) + { + rotationVector.X *= -1f; + } + + rotationVector = rotationVector.RotatedBy(NPC.rotation); + Main.dust[idx].position = NPC.Center + rotationVector; + } + + if (NPC.type == NPCID.SolarCorite) + { + int dustSpawnChance = (NPC.ai[0] == 2f) ? 2 : 1; + int dustSpawnAreaSize = (NPC.ai[0] == 2f) ? 30 : 20; + for (int i = 0; i < 2; i++) + { + if (Main.rand.Next(3) < dustSpawnChance) + { + int idx = Dust.NewDust(NPC.Center - new Vector2(dustSpawnAreaSize), dustSpawnAreaSize * 2, dustSpawnAreaSize * 2, DustID.Torch, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default, 1.5f); + Main.dust[idx].noGravity = true; + Dust dust = Main.dust[idx]; + dust.velocity *= 0.2f; + Main.dust[idx].fadeIn = 1f; + } + } + } + + // Move upward. + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.knockBackResist = npcKBResist; + Vector2 playerDistanceNorm = Main.player[NPC.target].Center - NPC.Center; + Vector2 upwardVelocity = playerDistanceNorm - Vector2.UnitY * idealUpwardDelta; + float playerDistance = NPC.Distance(Main.player[NPC.target].Center); + playerDistanceNorm = Vector2.Normalize(playerDistanceNorm) * upwardChargeSpeed; + upwardVelocity = Vector2.Normalize(upwardVelocity) * upwardChargeSpeed; + bool closeAngleDistance = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1); + + if (NPC.ai[3] >= 120f) + { + closeAngleDistance = true; + } + + // In simpler terms, this means that we incoporate a bool which states: + // The angular distance between this and the player is greater than pi/8 or + // less than pi - pi/8. + // into the already existing boolean. + closeAngleDistance &= NPC.AngleTo(Main.player[NPC.target].Center) > (MathHelper.Pi / 8f) && + NPC.AngleTo(Main.player[NPC.target].Center) < (MathHelper.Pi - MathHelper.Pi / 8f); + + // If in a relatively close area of the player, or we meet the angle criteria above, prepare for charge. + if (playerDistance < maximumDistanceBeforeCharge || closeAngleDistance) + { + NPC.ai[0] = 1f; + NPC.ai[2] = playerDistanceNorm.X; + NPC.ai[3] = playerDistanceNorm.Y; + NPC.netUpdate = true; + } + // Otherwise, resume upward movement. + else + { + NPC.velocity = (NPC.velocity * (upwardMovementIntertia - 1f) + upwardVelocity) / upwardMovementIntertia; + + if (!closeAngleDistance) + { + NPC.ai[3] += 1f; + if (NPC.ai[3] == 120f) + { + NPC.netUpdate = true; + } + } + else + { + NPC.ai[3] = 0f; + } + } + } + // Slow down and prepare for charge. + else if (NPC.ai[0] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.knockBackResist = 0f; + + bool decelerate = true; + if (NPC.type == NPCID.SolarCorite) + { + decelerate = NPC.velocity.Length() > 2f; + if (!decelerate && NPC.target >= 0 && !Main.player[NPC.target].DeadOrGhost) + { + Vector2 maxVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.Zero) * 0.1f; + NPC.velocity = Vector2.Lerp(NPC.velocity, maxVelocity, 0.25f); + } + } + + if (decelerate) + NPC.velocity *= chargeWaitSlowdownMult; + + NPC.ai[1] += 1f; + // If enough time has passed, charge. + if (NPC.ai[1] >= chargePhaseWait) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + Vector2 velocity = new Vector2(NPC.ai[2], NPC.ai[3]) + new Vector2(Main.rand.Next(-chargeRandomness, chargeRandomness + 1), Main.rand.Next(-chargeRandomness, chargeRandomness + 1)) * 0.04f; + velocity.Normalize(); + velocity *= chargeSpeed; + NPC.velocity = velocity; + } + + // Spawn some cool dust. + if (NPC.type == NPCID.MartianDrone && Main.rand.NextBool(4)) + { + int idx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric, 0f, 0f, 100, default, 0.5f); + Main.dust[idx].noGravity = true; + Dust dust = Main.dust[idx]; + dust.velocity *= 2f; + Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - NPC.Center); + } + } + else if (NPC.ai[0] == 2f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.knockBackResist = 0f; + + NPC.ai[1] += 1f; + bool aboveAndFar = Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) > chargeDistanceCheck && NPC.Center.Y > Main.player[NPC.target].Center.Y; + // If time is up and the player is (relatively) far, or the velocity is (relatively) low, reset. + if ((NPC.ai[1] >= maximumChargeTime & aboveAndFar) || NPC.velocity.Length() < minimumChargeSpeed) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.velocity /= 2f; + NPC.netUpdate = true; + + if (NPC.type == NPCID.SolarCorite) + { + NPC.ai[1] = 45f; + NPC.ai[0] = 4f; + } + } + else + { + Vector2 distanceNormalized = Vector2.Normalize(Main.player[NPC.target].Center - NPC.Center); + + if (distanceNormalized.HasNaNs()) + { + distanceNormalized = new Vector2(NPC.direction, 0f); + } + + NPC.velocity = (NPC.velocity * (chargeIntertia - 1f) + distanceNormalized * (NPC.velocity.Length() + chargeAcceleration)) / chargeIntertia; + } + + if (hasCoolDustPhase && Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + } + else if (NPC.ai[0] == 4f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[1] -= 3f; + if (NPC.ai[1] <= 0f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + NPC.velocity *= CalamityWorld.death ? 0.9f : 0.95f; + } + + if (hasCoolDustPhase && NPC.ai[0] != 3f && Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) < 64f) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + + // Explode + if (NPC.ai[0] == 3f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.position = NPC.Center; + NPC.width = NPC.height = CalamityWorld.death ? 360 : 240; + NPC.position -= NPC.Size; + + NPC.velocity = Vector2.Zero; + + NPC.alpha = 255; + Lighting.AddLight((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16, 0.2f, 0.7f, 1.1f); + + for (int i = 0; i < 10; i++) + { + int idx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[idx]; + dust.velocity *= 1.4f; + Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + NPC.Center; + } + + for (int i = 0; i < 40; i++) + { + int idx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric, 0f, 0f, 100, default, 0.5f); + Main.dust[idx].noGravity = true; + Dust dust = Main.dust[idx]; + dust.velocity *= 2f; + Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + NPC.Center; + Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - NPC.Center); + + if (Main.rand.NextBool()) + { + idx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric, 0f, 0f, 100, default, 0.9f); + Main.dust[idx].noGravity = true; + dust = Main.dust[idx]; + dust.velocity *= 1.2f; + Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + NPC.Center; + Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - NPC.Center); + } + + if (Main.rand.NextBool(4)) + { + idx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Electric, 0f, 0f, 100, default, 0.7f); + dust = Main.dust[idx]; + dust.velocity *= 1.2f; + Main.dust[idx].position = ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * ((float)Main.rand.NextDouble() * 96f) + NPC.Center; + Main.dust[idx].velocity = Main.dust[idx].velocity / 2f + Vector2.Normalize(Main.dust[idx].position - NPC.Center); + } + } + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 3f) + { + SoundEngine.PlaySound(SoundID.Item14, NPC.Center); + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + } + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs new file mode 100644 index 0000000000..a7378e9b3b --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs @@ -0,0 +1,3498 @@ +using System; +using System.Collections.Generic; +using CalamityMod.NPCs.Astral; +using CalamityMod.NPCs.Crags; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class FighterAI : VanillaAIOverride + { + // Methods for AIs that are always terminated via a return in the Fighter AI code. More specialized and general + // functions are given summaries of their specifics + public static void BuffedPsychoAI(NPC npc) + { + int psychoAlphaMax = 200; + // Standing still + if (npc.ai[2] == 0f) + { + npc.alpha = psychoAlphaMax; + npc.TargetClosest(true); + if (!Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() < 170f) + { + npc.ai[2] = -16f; + } + if (npc.velocity.X != 0f || npc.velocity.Y < 0f || npc.velocity.Y > 2f || npc.justHit) + { + npc.ai[2] = -16f; + } + } + // Active + if (npc.ai[2] < 0f) + { + if (npc.alpha > 0) + { + npc.alpha -= psychoAlphaMax / 16; + if (npc.alpha < 0) + { + npc.alpha = 0; + } + } + npc.ai[2] += 1f; + if (npc.ai[2] == 0f) + { + npc.ai[2] = 1f; + npc.velocity.X = (float)(npc.direction * 2); + } + } + } + public static void BuffedSwampThingAI(NPC npc) + { + if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(240)) + { + npc.ai[2] = (float)Main.rand.Next(-480, -60); + npc.netUpdate = true; + } + if (npc.ai[2] < 0f) + { + npc.TargetClosest(true); + if (npc.justHit) + { + npc.ai[2] = 0f; + } + if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + npc.ai[2] = 0f; + } + } + if (npc.ai[2] < 0f) + { + npc.velocity.X *= 0.9f; + if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + { + npc.velocity.X = 0f; + } + npc.ai[2] += 1f; + if (npc.ai[2] == 0f) + { + npc.velocity.X = (float)npc.direction * 0.1f; + } + } + } + // Misc effects used more than once in the Fighter AI + public static void MedusaHeadDustEffect(NPC npc, float time) + { + Vector2 headPosition = npc.Top + new Vector2((float)(npc.spriteDirection * 6), 6f); + float rotationVectorMult = MathHelper.Lerp(20f, 30f, (time * 3f + 50f) / 182f); + Main.rand.NextFloat(); + for (float i = 0f; i < 2f; i += 1f) + { + Vector2 rotationVector = Vector2.UnitY.RotatedByRandom(Math.PI * 2.0) * (Main.rand.NextFloat() * 0.5f + 0.5f); + Dust dust = Dust.NewDustDirect(headPosition, 0, 0, DustID.GoldFlame, 0f, 0f, 0, default, 1f); + dust.position = headPosition + rotationVector * rotationVectorMult; + dust.noGravity = true; + dust.velocity = rotationVector * 2f; + dust.scale = 0.5f + Main.rand.NextFloat() * 0.5f; + } + } + + /// + /// Causes an NPC to run on the X axis until it hits the maximum speed and decclerates as needed. + /// Works best with fighter AI based NPCs. + /// + /// The NPC to manipulate + /// The max speed to run at. + /// The rate at which the X velocity changes with time. + /// The X velocity deceleration multiplier when the NPC will turn to another direction. + /// Causes the NPC to slow down faster when not jumping for direction turning if true. + /// The X velocity deceleration multiplier when the NPC will turn to another direction. + /// The X velocity deceleration multiplier used by . + public static void FighterRunningAI(NPC npc, float velocityMax, float acceleration, float turnDeceleration, + bool extraDeceleration = false, float extraDecelerationFactor = 0.99f) + { + if (npc.velocity.X < -velocityMax || npc.velocity.X > velocityMax) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= turnDeceleration; + } + } + else if (npc.velocity.X < velocityMax && npc.direction == 1) + { + npc.velocity.X += acceleration; + + if (extraDeceleration && npc.velocity.Y == 0f && npc.velocity.X < 0f) + npc.velocity.X *= extraDecelerationFactor; + + if (npc.velocity.X > velocityMax) + { + npc.velocity.X = velocityMax; + } + } + else if (npc.velocity.X > -velocityMax && npc.direction == -1) + { + if (extraDeceleration && npc.velocity.Y == 0f && npc.velocity.X > 0f) + npc.velocity.X *= extraDecelerationFactor; + npc.velocity.X -= acceleration; + if (npc.velocity.X < -velocityMax) + { + npc.velocity.X = -velocityMax; + } + } + } + + public static void TryConvertToWallClimber(NPC npc) + { + // Note: The Possessed rely on an AI shift rather than a transformation NPC + // As a result, they are not included in this method + + List spiders = new List() + { + NPCID.BlackRecluse, + NPCID.BloodCrawler, + NPCID.DesertScorpionWalk, + NPCID.JungleCreeper, + NPCID.WallCreeper, + ModContent.NPCType() + }; + // These checks are not required if the npc is not a real spider + if (!spiders.Contains(npc.type)) + return; + int tileCoordsX = (int)npc.Center.X / 16; + int tileCoordsY = (int)npc.Center.Y / 16; + bool climbWalls = false; + for (int x = tileCoordsX - 1; x <= tileCoordsX + 1; x++) + { + for (int y = tileCoordsY - 1; y <= tileCoordsY + 1; y++) + { + if (Main.tile[x, y].WallType > WallID.None) + { + climbWalls = true; + } + } + } + int transformType = -1; + if (climbWalls) + { + if (npc.type == ModContent.NPCType()) + { + transformType = ModContent.NPCType(); + } + else + { + switch (npc.type) + { + case NPCID.BlackRecluse: + transformType = NPCID.BlackRecluseWall; + break; + case NPCID.BloodCrawler: + transformType = NPCID.BloodCrawlerWall; + break; + case NPCID.DesertScorpionWalk: + transformType = NPCID.DesertScorpionWall; + break; + case NPCID.JungleCreeper: + transformType = NPCID.JungleCreeperWall; + break; + case NPCID.WallCreeper: + transformType = NPCID.WallCreeperWall; + break; + } + } + if (transformType != -1) + { + npc.Transform(transformType); + } + } + } + + public override bool AI(Mod mod) + { + int npcType = NPC.type; + if (NPC.ModNPC != null) + { + if (NPC.ModNPC.AIType != NPCID.None) + npcType = NPC.ModNPC.AIType; + } + + if (npcType == NPCID.Psycho) + { + BuffedPsychoAI(NPC); + } + + if (npcType == NPCID.SwampThing) + { + BuffedSwampThingAI(NPC); + } + + if (npcType == NPCID.CreatureFromTheDeep) + { + // Swimming + if (NPC.wet) + { + NPC.knockBackResist = 0f; + NPC.ai[3] = -0.10101f; + NPC.noGravity = true; + NPC.width = 34; + NPC.height = 24; + NPC.position = NPC.Center - NPC.Size / 2f; + NPC.TargetClosest(true); + if (NPC.collideX) + { + NPC.velocity.X = -NPC.oldVelocity.X; + } + if (NPC.velocity.X < 0f) + { + NPC.direction = -1; + } + if (NPC.velocity.X > 0f) + { + NPC.direction = 1; + } + + // If there's nothing in the way of the player, swim towards them + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].Center, 1, 1)) + { + NPC.velocity = (NPC.velocity * 19f + NPC.SafeDirectionTo(Main.player[NPC.target].Center, -Vector2.UnitY) * 10f) / 20f; + return false; + } + + float velocityMultiplier = 10f; + if (NPC.velocity.Y > 0f) + { + velocityMultiplier = 6f; + } + if (NPC.velocity.Y < 0f) + { + velocityMultiplier = 16f; + } + Vector2 directionVectorNormalized = new Vector2((float)NPC.direction, -1f); + directionVectorNormalized.Normalize(); + directionVectorNormalized *= velocityMultiplier; + + // If the speed is low, make the turn speed higher + if (velocityMultiplier < 5f) + { + NPC.velocity = (NPC.velocity * 24f + directionVectorNormalized) / 25f; + return false; + } + NPC.velocity = (NPC.velocity * 9f + directionVectorNormalized) / 10f; + return false; + } + else + { + NPC.knockBackResist = CalamityWorld.death ? 0.1f : 0.2f; + NPC.noGravity = false; + NPC.width = 18; + NPC.height = 40; + NPC.position = NPC.Center - NPC.Size / 2f; + + // If was just swimming, set values to return to land + if (NPC.ai[3] == -0.10101f) + { + NPC.ai[3] = 0f; + // Adjust velocity from the one the NPC had when swimming + float velocityMagnitude = NPC.velocity.Length(); + velocityMagnitude *= 2f; + if (velocityMagnitude > 12f) + { + velocityMagnitude = 12f; + } + NPC.velocity.Normalize(); + NPC.velocity *= velocityMagnitude; + NPC.direction = NPC.spriteDirection = (NPC.velocity.X > 0).ToDirectionInt(); + } + } + } + + if (npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite) + { + // Pissed off + if (NPC.ai[3] < 0f) + { + NPC.damage = 0; + NPC.velocity.X *= 0.93f; + if (NPC.velocity.X > -0.1 && (double)NPC.velocity.X < 0.1) + { + NPC.velocity.X = 0f; + } + int targetNPC = (int)(-NPC.ai[3] - 1f); + int directionToTarget = Math.Sign(Main.npc[targetNPC].Center.X - NPC.Center.X); + if (directionToTarget != NPC.direction) + { + NPC.velocity.X = 0f; + NPC.direction = directionToTarget; + NPC.netUpdate = true; + } + if (NPC.justHit && Main.netMode != NetmodeID.MultiplayerClient && Main.npc[targetNPC].localAI[0] == 0f) + { + Main.npc[targetNPC].localAI[0] = 1f; + } + if (NPC.ai[0] < 1000f) + { + NPC.ai[0] = 1000f; + } + NPC.ai[0] += 1f; + if (NPC.ai[0] >= 1300f) + { + NPC.ai[0] = 1000f; + NPC.netUpdate = true; + } + return false; + } + // Not pissed off + if (NPC.ai[0] >= 1000f) + { + NPC.ai[0] = 0f; + } + NPC.damage = NPC.defDamage; + } + + if (npcType == NPCID.MartianOfficer && NPC.ai[2] == 0f && NPC.localAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + // If Martian Officer is ready to generate shield, generate it. + int shield = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.ForceBubble, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + NPC.ai[2] = (float)(shield + 1); + NPC.localAI[0] = -1f; + NPC.netUpdate = true; + Main.npc[shield].ai[0] = (float)NPC.whoAmI; + Main.npc[shield].netUpdate = true; + } + + if (npcType == NPCID.MartianOfficer) + { + int shield = (int)NPC.ai[2] - 1; + if (shield != -1 && Main.npc[shield].active && Main.npc[shield].type == NPCID.ForceBubble) + { + NPC.dontTakeDamage = true; + } + else + { + NPC.dontTakeDamage = false; + NPC.ai[2] = 0f; + if (NPC.localAI[0] == -1f) + { + NPC.localAI[0] = CalamityWorld.death ? 60f : 120f; + } + if (NPC.localAI[0] > 0f) + { + NPC.localAI[0] -= 1f; + } + } + } + + if (npcType == NPCID.GraniteGolem) + { + int activeTime = 300; + int defendTime = 120; + + // Set damage + NPC.damage = NPC.defDamage; + + NPC.defense = NPC.defDefense; + + if (NPC.ai[2] < 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.defense = NPC.defDefense + 15; + NPC.ai[2] += 1f; + NPC.velocity.X *= 0.9f; + if (Math.Abs(NPC.velocity.X) < 0.001) + { + NPC.velocity.X = 0.001f * (float)NPC.direction; + } + if (Math.Abs(NPC.velocity.Y) > 1f) + { + NPC.ai[2] += 10f; + } + if (NPC.ai[2] >= 0f) + { + NPC.netUpdate = true; + NPC.velocity.X += (float)NPC.direction * 0.3f; + } + return false; + } + if (NPC.ai[2] < activeTime) + { + if (NPC.justHit) + { + NPC.ai[2] += 15f; + } + NPC.ai[2] += 1f; + } + else if (NPC.velocity.Y == 0f) + { + NPC.ai[2] = defendTime * -1f; + NPC.netUpdate = true; + } + } + + if (npcType == NPCID.Medusa) + { + int afterHitTime = 90; + int afterWaitTime = 210; + int maxTime = 270; + int debuffTime = (CalamityWorld.death ? 4 : 2) * 60; // 2 seconds in Rev, 4 seconds in Death + int turnToStoneTime = 20; + float mesudaActiveDistance = CalamityWorld.death ? 1500f : 900f; + float medusaEffectDistance = CalamityWorld.death ? 1600f : 1000f; + if (NPC.ai[2] > 0f) + { + NPC.ai[2] -= 1f; + } + else if (NPC.ai[2] == 0f) + { + if (((Main.player[NPC.target].Center.X < NPC.Center.X && NPC.direction < 0) || (Main.player[NPC.target].Center.X > NPC.Center.X && NPC.direction > 0)) && NPC.velocity.Y == 0f && NPC.Distance(Main.player[NPC.target].Center) < mesudaActiveDistance && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[2] = (float)(maxTime * -1f - turnToStoneTime); + NPC.netUpdate = true; + } + } + else + { + if (NPC.ai[2] < 0f && NPC.ai[2] < maxTime * -1f) + { + NPC.velocity.X *= 0.9f; + if (NPC.velocity.Y < -2f || NPC.velocity.Y > 4f || NPC.justHit) + { + NPC.ai[2] = afterHitTime; + } + else + { + NPC.ai[2] += 1f; + if (NPC.ai[2] == 0f) + { + NPC.ai[2] = afterWaitTime; + } + } + float time = NPC.ai[2] + maxTime + turnToStoneTime; + if (time == 1f) + { + SoundEngine.PlaySound(SoundID.NPCDeath17, NPC.Center); + } + if (time < turnToStoneTime) + { + MedusaHeadDustEffect(NPC, time); + } + Lighting.AddLight(NPC.Center, 0.9f, 0.75f, 0.1f); + return false; + } + if (NPC.ai[2] < 0f && NPC.ai[2] >= maxTime * -1f) + { + Lighting.AddLight(NPC.Center, 0.9f, 0.75f, 0.1f); + NPC.velocity.X *= 0.9f; + if (NPC.velocity.Y < -2f || NPC.velocity.Y > 4f || NPC.justHit) + { + NPC.ai[2] = afterHitTime; + } + else + { + NPC.ai[2] += 1f; + if (NPC.ai[2] == 0f) + { + NPC.ai[2] = afterWaitTime; + } + } + float time = NPC.ai[2] + maxTime; + if (time < 180f && (Main.rand.NextBool(3) || NPC.ai[2] % 3f == 0f)) + { + MedusaHeadDustEffect(NPC, time); + } + if (!Main.dedServ) + { + Player player = Main.LocalPlayer; + if (!player.dead && player.active && player.FindBuffIndex(BuffID.Stoned) == -1) + { + if (NPC.Distance(player.Center) < medusaEffectDistance) + { + bool canTurnPlayerToStone = NPC.Distance(player.Center) < 30f; + if (!canTurnPlayerToStone) + { + // Used to be "float x = 0.7853982f.ToRotationVector2().X;" + // cos(pi/4) should do the job too, though. If you want/need to revert this to the + // code above, do so. + float x = (float)Math.Cos(MathHelper.PiOver4); + Vector2 vector6 = Vector2.Normalize(player.Center - NPC.Center); + if (vector6.X > x || vector6.X < -x) + { + canTurnPlayerToStone = true; + } + } + if (((player.Center.X < NPC.Center.X && NPC.direction < 0 && player.direction > 0) || (player.Center.X > NPC.Center.X && NPC.direction > 0 && player.direction < 0)) && canTurnPlayerToStone && (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(NPC.Center - Vector2.UnitY * 16f, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(NPC.Center + Vector2.UnitY * 8f, 1, 1, player.Center, 1, 1))) + { + player.AddBuff(BuffID.Stoned, debuffTime + (int)NPC.ai[2] * -1, true); + } + } + } + } + return false; + } + } + } + + if (npcType == NPCID.GoblinSummoner) + { + // Shit out minion things + if (NPC.ai[3] < 0f) + { + NPC.knockBackResist = 0f; + NPC.defense = (int)Math.Round(NPC.defDefense * 1.3); + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.direction = (NPC.velocity.X > 0).ToDirectionInt(); + NPC.rotation = NPC.velocity.X * 0.1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[3] += 1f; + if (NPC.localAI[3] > (float)Main.rand.Next(20, CalamityWorld.death ? 40 : 120)) + { + NPC.localAI[3] = 0f; + Vector2 spawnPosition = NPC.Center; + spawnPosition += NPC.velocity; + NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnPosition.X, (int)spawnPosition.Y, NPCID.ChaosBall); + } + } + } + else + { + NPC.localAI[3] = 0f; + NPC.knockBackResist = 0.2f; + NPC.rotation *= 0.9f; + NPC.defense = NPC.defDefense; + NPC.noGravity = false; + NPC.noTileCollide = false; + } + if (NPC.ai[3] == 1f) + { + NPC.knockBackResist = 0f; + NPC.defense += 10; + } + if (NPC.ai[3] == -1f) + { + NPC.TargetClosest(true); + float velocityMultiplier = 10f; + float turnValue = 40f; + Vector2 targetDirection = Main.player[NPC.target].Center - NPC.Center; + float playerDistance = targetDirection.Length(); + velocityMultiplier += playerDistance / 200f; + targetDirection.Normalize(); + targetDirection *= velocityMultiplier; + NPC.velocity = (NPC.velocity * (turnValue - 1f) + targetDirection) / turnValue; + if (playerDistance < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + // Go back to normal AI + NPC.ai[3] = 0f; + NPC.ai[2] = 0f; + } + return false; + } + // Go up on the Y axis and slow down on the X axis + if (NPC.ai[3] == -2f) + { + NPC.velocity.Y -= 0.2f; + if (NPC.velocity.Y < -12f) + { + NPC.velocity.Y = -12f; + } + if (Main.player[NPC.target].Center.Y - NPC.Center.Y > 200f) + { + NPC.TargetClosest(true); + NPC.ai[3] = -3f; + if (Main.player[NPC.target].Center.X > NPC.Center.X) + { + NPC.ai[2] = 1f; + } + else + { + NPC.ai[2] = -1f; + } + } + NPC.velocity.X *= 0.99f; + return false; + } + // Similar to above, but more quick + if (NPC.ai[3] == -3f) + { + if (NPC.direction == 0) + { + NPC.TargetClosest(true); + } + if (NPC.ai[2] == 0f) + { + NPC.ai[2] = (float)NPC.direction; + } + NPC.velocity.Y *= 0.9f; + NPC.velocity.X += NPC.ai[2] * 0.3f; + if (NPC.velocity.X > 10f) + { + NPC.velocity.X = 10f; + } + if (NPC.velocity.X < -10f) + { + NPC.velocity.X = -10f; + } + float playerDistance = Main.player[NPC.target].Center.X - NPC.Center.X; + if ((NPC.ai[2] < 0f && playerDistance > 300f) || (NPC.ai[2] > 0f && playerDistance < -300f)) + { + NPC.ai[3] = -4f; + NPC.ai[2] = 0f; + return false; + } + if (Math.Abs(Main.player[NPC.target].Center.X - NPC.Center.X) > 800f) + { + NPC.ai[3] = -1f; + NPC.ai[2] = 0f; + } + return false; + } + else + { + if (NPC.ai[3] == -4f) + { + NPC.ai[2] += 1f; + NPC.velocity.Y += 0.1f; + // Don't go very fast + if (NPC.velocity.Length() > 4f) + { + NPC.velocity *= 0.9f; + } + int tileAtCenterX = (int)NPC.Center.X / 16; + int tileAtBottom = (int)(NPC.position.Y + (float)NPC.height + 12f) / 16; + bool ableToRestart = false; + for (int i = tileAtCenterX - 1; i <= tileAtCenterX + 1; i++) + { + if (Main.tile[i, tileAtBottom].HasTile && Main.tileSolid[(int)Main.tile[i, tileAtBottom].TileType]) + { + ableToRestart = true; + } + } + if (ableToRestart && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[3] = 0f; + NPC.ai[2] = 0f; + } + else if (NPC.ai[2] > 300f || NPC.Center.Y > Main.player[NPC.target].Center.Y + 200f) + { + NPC.ai[3] = -1f; + NPC.ai[2] = 0f; + } + } + // Barf out the shadowflame skull things + else + { + if (NPC.ai[3] == 1f) + { + Vector2 spawnPosiion = NPC.Center; + spawnPosiion.Y -= 70f; + NPC.velocity.X *= 0.8f; + NPC.ai[2] += 1f; + if (NPC.ai[2] == (CalamityWorld.death ? 15f : 30f)) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnPosiion.X, (int)spawnPosiion.Y + 18, NPCID.ShadowFlameApparition, 0, 0f, 0f, 0f, 0f, 255); + } + } + else if (NPC.ai[2] >= 90f) + { + NPC.ai[3] = -2f; + NPC.ai[2] = 0f; + } + for (int j = 0; j < 2; j++) + { + // Randomize and normalize. You know the drill + Vector2 dustVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + dustVelocity *= (float)Main.rand.Next(0, 100) * 0.1f; + dustVelocity.Normalize(); + dustVelocity *= (float)Main.rand.Next(50, 90) * 0.1f; + int dustIdx = Dust.NewDust(spawnPosiion, 1, 1, DustID.Shadowflame, 0f, 0f, 0, default, 1f); + Main.dust[dustIdx].velocity = -dustVelocity * 0.3f; + Main.dust[dustIdx].alpha = 100; + if (Main.rand.NextBool()) + { + Main.dust[dustIdx].noGravity = true; + Main.dust[dustIdx].scale += 0.3f; + } + } + return false; + } + NPC.ai[2] += 1f; + int maxSkullCount = 10; + if (NPC.velocity.Y == 0f && NPC.CountNPCS(NPCID.ShadowFlameApparition) < maxSkullCount) + { + if (NPC.ai[2] >= 180f) + { + NPC.ai[2] = 0f; + NPC.ai[3] = 1f; + } + } + else + { + if (NPC.CountNPCS(NPCID.ShadowFlameApparition) >= maxSkullCount) + { + NPC.ai[2] += 1f; + } + if (NPC.ai[2] >= 360f) + { + NPC.ai[2] = 0f; + NPC.ai[3] = -2f; + NPC.velocity.Y -= 3f; + } + } + if (NPC.target >= 0 && !Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() > 800f) + { + NPC.ai[3] = -1f; + NPC.ai[2] = 0f; + } + } + if (Main.player[NPC.target].dead) + { + NPC.TargetClosest(true); + if (Main.player[NPC.target].dead && NPC.timeLeft > 1) + { + NPC.timeLeft = 1; + } + } + } + } + + if (npcType == NPCID.SolarSolenian) + { + NPC.reflectsProjectiles = false; + NPC.takenDamageMultiplier = 1f; + int chargeTime = 6; + int yFlyTime = 10; + float velocityMultiplier = 20f; + if (NPC.ai[2] > 0f) + { + NPC.ai[2] -= 1f; + } + if (NPC.ai[2] == 0f) + { + if (((Main.player[NPC.target].Center.X < NPC.Center.X && NPC.direction < 0) || (Main.player[NPC.target].Center.X > NPC.Center.X && NPC.direction > 0)) && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[2] = -1f; + NPC.netUpdate = true; + NPC.TargetClosest(true); + } + } + else + { + if (NPC.ai[2] < 0f && NPC.ai[2] > chargeTime * -1f) + { + NPC.ai[2] -= 1f; + NPC.velocity.X *= 0.9f; + return false; + } + if (NPC.ai[2] == chargeTime * -1f) + { + NPC.ai[2] -= 1f; + NPC.TargetClosest(true); + Vector2 vectorToPlayer = NPC.SafeDirectionTo(Main.player[NPC.target].Top - Vector2.UnitY * 30f, Vector2.Normalize(new Vector2(NPC.spriteDirection, -1f))); + + NPC.velocity = vectorToPlayer * velocityMultiplier; + NPC.netUpdate = true; + return false; + } + if (NPC.ai[2] < chargeTime * -1f) + { + NPC.ai[2] -= 1f; + if (NPC.velocity.Y == 0f) + { + NPC.ai[2] = CalamityWorld.death ? 60f : 90f; + } + else if (NPC.ai[2] < (float)(chargeTime * -1f - yFlyTime)) + { + NPC.velocity.Y += 0.15f; + if (NPC.velocity.Y > 24f) + { + NPC.velocity.Y = 24f; + } + } + NPC.reflectsProjectiles = true; + NPC.takenDamageMultiplier = CalamityWorld.death ? 2f : 3f; + if (NPC.justHit) + { + NPC.ai[2] = CalamityWorld.death ? 60f : 90f; + NPC.netUpdate = true; + } + return false; + } + } + } + + if (npcType == NPCID.SolarDrakomire) + { + int timeToReset = 42; + int timeToBreathFire = 18; + if (NPC.justHit) + { + NPC.ai[2] = CalamityWorld.death ? 30f : 60f; + NPC.netUpdate = true; + } + if (NPC.ai[2] > 0f) + { + NPC.ai[2] -= 1f; + } + if (NPC.ai[2] == 0f) + { + int solarFlareCount = 0; + int maxFlareCount = 6; + for (int k = 0; k < Main.maxNPCs; k++) + { + if (Main.npc[k].active && Main.npc[k].type == NPCID.SolarFlare) + { + solarFlareCount++; + } + } + if (solarFlareCount > maxFlareCount) + { + NPC.ai[2] = CalamityWorld.death ? 30f : 60f; + } + else if (((Main.player[NPC.target].Center.X < NPC.Center.X && NPC.direction < 0) || (Main.player[NPC.target].Center.X > NPC.Center.X && NPC.direction > 0)) && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[2] = -1f; + NPC.netUpdate = true; + NPC.TargetClosest(true); + } + } + else if (NPC.ai[2] < 0f && NPC.ai[2] > (float)(-(float)timeToReset)) + { + NPC.ai[2] -= 1f; + if (NPC.ai[2] == (float)(-(float)timeToReset)) + { + NPC.ai[2] = (float)(180 + 10 * Main.rand.Next(10)); + } + NPC.velocity.X *= 0.8f; + if (NPC.ai[2] == (float)(-(float)timeToBreathFire) || NPC.ai[2] == (float)(-(float)timeToBreathFire - 8) || NPC.ai[2] == (float)(-(float)timeToBreathFire - 16)) + { + for (int l = 0; l < 20; l++) + { + Vector2 spawnPosition = NPC.Center + Vector2.UnitX * (float)NPC.spriteDirection * 40f; + Dust dust = Main.dust[Dust.NewDust(spawnPosition, 0, 0, DustID.SolarFlare, 0f, 0f, 0, default, 1f)]; + Vector2 velocity = Vector2.UnitY.RotatedByRandom(Math.PI * 2.0); + dust.position = spawnPosition + velocity * 4f; + dust.velocity = velocity * 2f + Vector2.UnitX * Main.rand.NextFloat() * (float)NPC.spriteDirection * 3f; + dust.scale = 0.3f + velocity.X * (float)(-(float)NPC.spriteDirection); + dust.fadeIn = 0.7f; + dust.noGravity = true; + } + if (NPC.velocity.X > -0.5f && NPC.velocity.X < 0.5f) + { + NPC.velocity.X = 0f; + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X + NPC.spriteDirection * 45, (int)NPC.Center.Y + 8, NPCID.SolarFlare, 0, 0f, 0f, 0f, 0f, NPC.target); + } + } + return false; + } + } + + if (npcType == NPCID.VortexLarva) + { + if (NPC.CountNPCS(NPCID.VortexHornet) < 6) + { + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= (CalamityWorld.death ? 90f : CalamityWorld.revenge ? 150f : 300f)) + { + int centerTileX = (int)NPC.Center.X / 16 - 1; + int centerTileY = (int)NPC.Center.Y / 16 - 1; + if (!Collision.SolidTiles(centerTileX, centerTileX + 2, centerTileY, centerTileY + 1) && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.Transform(NPCID.VortexHornet); + NPC.life = NPC.lifeMax; + NPC.localAI[0] = 0f; + return false; + } + } + int maxValue; + if (NPC.localAI[0] < (CalamityWorld.revenge ? 30f : 60f)) + { + maxValue = 16; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 45f : CalamityWorld.revenge ? 60f : 120f)) + { + maxValue = 8; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 60f : CalamityWorld.revenge ? 90f : 180f)) + { + maxValue = 4; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 75f : CalamityWorld.revenge ? 120f : 240f)) + { + maxValue = 2; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 90f : CalamityWorld.revenge ? 150f : 300f)) + { + maxValue = 1; + } + else + { + maxValue = 1; + } + if (Main.rand.NextBool(maxValue)) + { + Dust dust = Main.dust[Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Vortex, 0f, 0f, 0, default, 1f)]; + dust.noGravity = true; + dust.scale = 1f; + dust.noLight = true; + dust.velocity = NPC.DirectionFrom(dust.position) * dust.velocity.Length(); + dust.position -= dust.velocity * 5f; + dust.position.X += (float)(NPC.direction * 6); + dust.position.Y += 4f; + } + } + } + + if (npcType == NPCID.VortexHornet) + { + if (NPC.CountNPCS(NPCID.VortexHornetQueen) < 3) + { + NPC.localAI[0] += 1f; + NPC.localAI[0] += Math.Abs(NPC.velocity.X) / 2f; + if (NPC.localAI[0] >= (CalamityWorld.death ? 300f : CalamityWorld.revenge ? 600f : 1200f) && Main.netMode != NetmodeID.MultiplayerClient) + { + int centerTileX = (int)NPC.Center.X / 16 - 2; + int centerTileY = (int)NPC.Center.Y / 16 - 3; + if (!Collision.SolidTiles(centerTileX, centerTileX + 4, centerTileY, centerTileY + 4)) + { + NPC.Transform(NPCID.VortexHornetQueen); + NPC.life = NPC.lifeMax; + NPC.localAI[0] = 0f; + return false; + } + } + int maxValue2; + if (NPC.localAI[0] < (CalamityWorld.death ? 60f : CalamityWorld.revenge ? 120f : 240f)) + { + maxValue2 = 32; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 120f : CalamityWorld.revenge ? 240f : 480f)) + { + maxValue2 = 16; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 180f : CalamityWorld.revenge ? 360f : 720f)) + { + maxValue2 = 6; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 240f : CalamityWorld.revenge ? 480f : 960f)) + { + maxValue2 = 2; + } + else if (NPC.localAI[0] < (CalamityWorld.death ? 300f : CalamityWorld.revenge ? 600f : 1200f)) + { + maxValue2 = 1; + } + else + { + maxValue2 = 1; + } + if (Main.rand.NextBool(maxValue2)) + { + Dust dust = Main.dust[Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Vortex, 0f, 0f, 0, default, 1f)]; + dust.noGravity = true; + dust.scale = 1f; + dust.noLight = true; + } + } + } + + bool jump = false; + if (NPC.velocity.X == 0f) + { + jump = true; + } + if (NPC.justHit) + { + jump = false; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && npcType == NPCID.Lihzahrd && (double)NPC.life <= (double)NPC.lifeMax * 0.9) + { + NPC.Transform(NPCID.LihzahrdCrawler); + } + + if (Main.netMode != NetmodeID.MultiplayerClient && npcType == NPCID.Nutcracker && (double)NPC.life <= (double)NPC.lifeMax * 0.9) + { + NPC.Transform(NPCID.NutcrackerSpinning); + } + + // This variable seems to have a lot of purposes. + // I wasn't sure what I could name it that isn't very vague + int aiGateValue = 60; + if (npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType()) + { + aiGateValue = 180; + if (NPC.ai[3] == -30f) + { + NPC.velocity *= 0f; + NPC.ai[3] = 0f; + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + float distX = NPC.oldPos[2].X + (float)NPC.width * 0.5f - NPC.Center.X; + float distY = NPC.oldPos[2].Y + (float)NPC.height * 0.5f - NPC.Center.Y; + float distance = (float)Math.Sqrt((distX * distX + distY * distY)); + distance = 2f / distance; + distX *= distance; + distY *= distance; + for (int m = 0; m < 20; m++) + { + int dustIdx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.UndergroundHallowedEnemies, distX, distY, 200, default, 2f); + Main.dust[dustIdx].noGravity = true; + Dust dust = Main.dust[dustIdx]; + dust.velocity.X *= 2f; + } + for (int n = 0; n < 20; n++) + { + int dustIdx = Dust.NewDust(NPC.oldPos[2], NPC.width, NPC.height, DustID.UndergroundHallowedEnemies, -distX, -distY, 200, default, 2f); + Main.dust[dustIdx].noGravity = true; + Dust dust = Main.dust[dustIdx]; + dust.velocity.X *= 2f; + } + } + } + + bool canIncrementAI3 = false; + bool reset = true; + if (npcType == NPCID.Yeti || npcType == NPCID.CorruptBunny || npcType == NPCID.Crab || npcType == NPCID.Clown || npcType == NPCID.SkeletonArcher || npcType == NPCID.GoblinArcher || npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType() + || npcType == NPCID.BlackRecluse || npcType == NPCID.WallCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.CorruptPenguin || npcType == NPCID.LihzahrdCrawler || npcType == NPCID.IcyMerman || npcType == NPCID.PirateDeadeye + || npcType == NPCID.PirateCrossbower || npcType == NPCID.PirateCaptain || npcType == NPCID.CochinealBeetle || npcType == NPCID.CyanBeetle || npcType == NPCID.LacBeetle || npcType == NPCID.SeaSnail || npcType == NPCID.FlyingSnake + || npcType == NPCID.IceGolem || npcType == NPCID.Eyezor || npcType == NPCID.AnomuraFungus || npcType == NPCID.MushiLadybug || npcType == NPCID.Paladin || npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton + || npcType == NPCID.SkeletonCommando || npcType == NPCID.Scarecrow1 || npcType == NPCID.Scarecrow2 || npcType == NPCID.Scarecrow3 || npcType == NPCID.Scarecrow4 || npcType == NPCID.Scarecrow5 || npcType == NPCID.Nutcracker + || npcType == NPCID.NutcrackerSpinning || npcType == NPCID.ElfArcher || npcType == NPCID.Krampus || npcType == NPCID.CultistArcherBlue || (npcType >= 430 && npcType <= 436) + || (npcType == NPCID.CultistArcherWhite || npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianOfficer || npcType == NPCID.MartianEngineer || npcType == NPCID.Scutlix + || (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4)) || (npcType == NPCID.Psycho || npcType == NPCID.CrimsonBunny || npcType == NPCID.SwampThing || npcType == NPCID.ThePossessed || npcType == NPCID.DrManFly + || npcType == NPCID.GoblinSummoner || npcType == NPCID.CrimsonPenguin || npcType == NPCID.Medusa || npcType == NPCID.GreekSkeleton || npcType == NPCID.GraniteGolem || npcType == NPCID.StardustSoldier || npcType == NPCID.NebulaSoldier + || npcType == NPCID.StardustSpiderBig || (npcType >= 494 && npcType <= 506)) || (npcType == NPCID.VortexRifleman || npcType == NPCID.VortexHornet || npcType == NPCID.VortexHornetQueen || npcType == NPCID.VortexLarva + || npcType == NPCID.WalkingAntlion || npcType == NPCID.SolarDrakomire || npcType == NPCID.SolarSolenian || npcType == NPCID.MartianWalker || (npcType >= 524 && npcType <= 527)) || npcType == NPCID.DesertLamiaLight + || npcType == NPCID.DesertLamiaDark || npcType == NPCID.DesertScorpionWalk || npcType == NPCID.DesertBeast) + { + reset = false; + } + + bool ableToAlterAI3 = false; + if (npcType == NPCID.VortexRifleman || npcType == NPCID.GoblinSummoner) + { + ableToAlterAI3 = true; + } + + bool npcTimer = NPC.ai[2] <= 0f; + if (npcType <= NPCID.RayGunner) + { + if (npcType <= NPCID.PirateCaptain) + { + if (npcType - 110 > 1 && npcType != NPCID.IcyMerman && npcType - NPCID.PirateDeadeye > 2) + { + goto PrepareToShoot; + } + } + else if (npcType - NPCID.SkeletonSniper > 2 && npcType != NPCID.ElfArcher && npcType - NPCID.CultistArcherBlue > 3) + { + goto PrepareToShoot; + } + } + else if (npcType <= NPCID.NebulaSoldier) + { + if (npcType != NPCID.StardustSpiderSmall && npcType != NPCID.StardustSoldier && npcType != NPCID.NebulaSoldier) + { + goto PrepareToShoot; + } + } + else if (npcType <= NPCID.Psycho) + { + if (npcType != NPCID.VortexHornetQueen && npcType != NPCID.Psycho) + { + goto PrepareToShoot; + } + } + else if (npcType - 498 > 8 && npcType != NPCID.MartianWalker) + { + goto PrepareToShoot; + } + +// If anyone can give me an explanation of the real noticable differences between +//& and && (same with | and ||) with booleans, +// I'd greatly appreciate it +PrepareToShoot: + if (!ableToAlterAI3 & npcTimer) + { + if (NPC.velocity.Y == 0f && ((NPC.velocity.X > 0f && NPC.direction < 0) || (NPC.velocity.X < 0f && NPC.direction > 0))) + { + canIncrementAI3 = true; + } + if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)aiGateValue) | canIncrementAI3) + { + NPC.ai[3] += 1f; + } + else if (Math.Abs(NPC.velocity.X) > 0.9 && NPC.ai[3] > 0f) + { + NPC.ai[3] -= 1f; + } + if (NPC.ai[3] > (float)(aiGateValue * 10)) + { + NPC.ai[3] = 0f; + } + if (NPC.justHit) + { + NPC.ai[3] = 0f; + } + if (NPC.ai[3] == (float)aiGateValue) + { + NPC.netUpdate = true; + } + } + + if (npcType == NPCID.Nailhead && Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.localAI[3] > 0f) + NPC.localAI[3] -= 1f; + + if (NPC.justHit && NPC.localAI[3] <= 0f) + { + NPC.localAI[3] = CalamityWorld.death ? 45f : CalamityWorld.revenge ? 60f : 75f; + + float nailVelocity = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; + int type = ProjectileID.Nail; + int damage = (int)(NPC.damage * 0.15); + Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; + destination = destination.SafeNormalize(-Vector2.UnitY); + destination *= nailVelocity; + int numProj = Main.rand.Next(3, 6); + float rotation = MathHelper.ToRadians(numProj * 15); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center - Vector2.UnitY * (NPC.width / 4), perturbedSpeed, type, damage, 1f, Main.maxPlayers); + } + } + } + + if (npcType == NPCID.Butcher) + { + if (NPC.velocity.Y < -0.3f || NPC.velocity.Y > 0.3f) + { + NPC.knockBackResist = 0f; + } + else + { + NPC.knockBackResist = 0.1f; + } + } + + if (npcType == NPCID.ThePossessed) + { + NPC.knockBackResist = 0.25f; + if (NPC.ai[2] == 1f) + { + NPC.knockBackResist = 0f; + } + bool spiderAI = false; + int centerTileX = (int)NPC.Center.X / 16; + int centerTileY = (int)NPC.Center.Y / 16; + for (int x = centerTileX - 1; x <= centerTileX + 1; x++) + { + for (int y = centerTileY - 1; y <= centerTileY + 1; y++) + { + if (Main.tile[x, y] != null && Main.tile[x, y].WallType > WallID.None) + { + spiderAI = true; + break; + } + } + if (spiderAI) + { + break; + } + } + if (NPC.ai[2] == 0f & spiderAI) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity.Y = -4.6f; + NPC.velocity.X *= 1.5f; + } + else if (NPC.velocity.Y > 0f) + { + NPC.ai[2] = 1f; + } + } + if (spiderAI && NPC.ai[2] == 1f && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + Vector2 distanceVector = Main.player[NPC.target].Center - NPC.Center; + float distanceMagnitude = distanceVector.Length(); + distanceVector = distanceVector.SafeNormalize(-Vector2.UnitY); + distanceVector *= 6f + distanceMagnitude / 300f; + NPC.velocity = (NPC.velocity * 29f + distanceVector) / 30f; + NPC.noGravity = true; + NPC.ai[2] = 1f; + return false; + } + NPC.noGravity = false; + NPC.ai[2] = 0f; + } + + if (npcType == NPCID.Fritz && NPC.velocity.Y == 0f && (Main.player[NPC.target].Center - NPC.Center).Length() < 150f && Math.Abs(NPC.velocity.X) > 3f && ((NPC.velocity.X < 0f && NPC.Center.X > Main.player[NPC.target].Center.X) || (NPC.velocity.X > 0f && NPC.Center.X < Main.player[NPC.target].Center.X))) + { + NPC.velocity.X *= 2f; + NPC.velocity.Y -= 4.5f; + if (NPC.Center.Y - Main.player[NPC.target].Center.Y > 20f) + { + NPC.velocity.Y -= 0.5f; + } + if (NPC.Center.Y - Main.player[NPC.target].Center.Y > 40f) + { + NPC.velocity.Y -= 1f; + } + if (NPC.Center.Y - Main.player[NPC.target].Center.Y > 80f) + { + NPC.velocity.Y -= 1.5f; + } + if (NPC.Center.Y - Main.player[NPC.target].Center.Y > 100f) + { + NPC.velocity.Y -= 1.5f; + } + if (Math.Abs(NPC.velocity.X) > 9f) + { + if (NPC.velocity.X < 0f) + { + NPC.velocity.X = -9f; + } + else + { + NPC.velocity.X = 9f; + } + } + } + + if (NPC.ai[3] < (float)aiGateValue && (Main.eclipse || !Main.dayTime || (double)NPC.position.Y > Main.worldSurface * 16.0 || (Main.invasionType == InvasionID.GoblinArmy && (npcType == NPCID.Yeti || npcType == NPCID.ElfArcher)) || (Main.invasionType == InvasionID.GoblinArmy && (npcType == NPCID.GoblinPeon || npcType == NPCID.GoblinThief || npcType == NPCID.GoblinWarrior || npcType == NPCID.GoblinArcher || npcType == NPCID.GoblinSummoner)) || (npcType == NPCID.GoblinScout || (Main.invasionType == InvasionID.PirateInvasion && npcType >= 212 && npcType <= 216)) || (Main.invasionType == InvasionID.MartianMadness && (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianOfficer || npcType == NPCID.GrayGrunt || npcType == NPCID.MartianEngineer || npcType == NPCID.GigaZapper || npcType == NPCID.Scutlix || npcType == NPCID.MartianWalker)) || (npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.CorruptBunny || npcType == NPCID.Crab || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.Mummy || npcType == NPCID.DarkMummy || npcType == NPCID.LightMummy || npcType == NPCID.SkeletonArcher || npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType() || npcType == NPCID.CorruptPenguin || npcType == NPCID.FaceMonster || npcType == NPCID.SnowFlinx || npcType == NPCID.Lihzahrd || npcType == NPCID.LihzahrdCrawler || npcType == NPCID.IcyMerman || npcType == NPCID.CochinealBeetle || npcType == NPCID.CyanBeetle || npcType == NPCID.LacBeetle || npcType == NPCID.SeaSnail || npcType == NPCID.BloodCrawler || npcType == NPCID.IceGolem || npcType == NPCID.ZombieMushroom || npcType == NPCID.ZombieMushroomHat || npcType == NPCID.AnomuraFungus || npcType == NPCID.MushiLadybug || npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton || npcType == NPCID.SkeletonCommando || npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite || npcType == NPCID.CrimsonBunny || npcType == NPCID.CrimsonPenguin || npcType == NPCID.NebulaSoldier || (npcType == NPCID.StardustSoldier && (NPC.ai[1] >= 180f || NPC.ai[1] < 90f))) || (npcType == NPCID.StardustSpiderBig || npcType == NPCID.VortexRifleman || npcType == NPCID.VortexSoldier || npcType == NPCID.VortexHornet || npcType == NPCID.VortexLarva || npcType == NPCID.WalkingAntlion || npcType == NPCID.SolarDrakomire || npcType == NPCID.SolarSolenian || (npcType >= 524 && npcType <= 527)) || npcType == NPCID.DesertLamiaLight || npcType == NPCID.DesertLamiaDark || npcType == NPCID.DesertScorpionWalk || npcType == NPCID.DesertBeast)) + { + if ((npcType == NPCID.Zombie || npcType == NPCID.ZombieXmas || npcType == NPCID.ZombieSweater || npcType == NPCID.Skeleton || (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) || npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.SkeletonArcher || npcType == NPCID.BaldZombie || npcType == NPCID.UndeadViking || npcType == NPCID.ZombieEskimo || npcType == NPCID.Frankenstein || npcType == NPCID.PincushionZombie || npcType == NPCID.SlimedZombie || npcType == NPCID.SwampZombie || npcType == NPCID.TwiggyZombie || npcType == NPCID.ArmoredViking || npcType == NPCID.FemaleZombie || npcType == NPCID.HeadacheSkeleton || npcType == NPCID.MisassembledSkeleton || npcType == NPCID.PantlessSkeleton || npcType == NPCID.ZombieRaincoat || npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton || npcType == NPCID.SkeletonCommando || npcType == NPCID.ZombieSuperman || npcType == NPCID.ZombiePixie || npcType == NPCID.ZombieDoctor || npcType == NPCID.GreekSkeleton || npcType == ModContent.NPCType()) && Main.rand.NextBool(1000)) + { + SoundEngine.PlaySound(SoundID.ZombieMoan, NPC.Center); + } + if (npcType == NPCID.BloodZombie && Main.rand.NextBool(800)) + { + SoundEngine.PlaySound(SoundID.ZombieMoan, NPC.Center); //There was a npcType thing afterwards but its not really useable now. Hilarious, frankly + } + if ((npcType == NPCID.Mummy || npcType == NPCID.DarkMummy || npcType == NPCID.LightMummy) && Main.rand.NextBool(500)) + { + SoundEngine.PlaySound(SoundID.Mummy, NPC.Center); + } + if (npcType == NPCID.Vampire && Main.rand.NextBool(500)) + { + SoundEngine.PlaySound(SoundID.Zombie7, NPC.Center); + } + if (npcType == NPCID.Frankenstein && Main.rand.NextBool(500)) + { + SoundEngine.PlaySound(SoundID.Zombie6, NPC.Center); + } + if (npcType == NPCID.FaceMonster && Main.rand.NextBool(500)) + { + SoundEngine.PlaySound(SoundID.Zombie8, NPC.Center); + } + if (npcType >= 269 && npcType <= 280 && Main.rand.NextBool(1000)) + { + SoundEngine.PlaySound(SoundID.ZombieMoan, NPC.Center); + } + NPC.TargetClosest(true); + } + else if (NPC.ai[2] <= 0f || + (npcType != NPCID.SkeletonArcher && + npcType != NPCID.GoblinArcher && + npcType != NPCID.IcyMerman && + npcType != NPCID.PirateDeadeye && + npcType != NPCID.PirateCrossbower && + npcType != NPCID.PirateCaptain && + npcType != NPCID.SkeletonSniper && + npcType != NPCID.TacticalSkeleton && + npcType != NPCID.SkeletonCommando && + npcType != NPCID.ElfArcher && + npcType != NPCID.BrainScrambler && + npcType != NPCID.RayGunner && + npcType != NPCID.MartianOfficer && + npcType != NPCID.GrayGrunt && + npcType != NPCID.MartianEngineer && + npcType != NPCID.GigaZapper && + npcType != NPCID.Scutlix && + npcType != NPCID.ThePossessed && + npcType != NPCID.SwampThing && + npcType != NPCID.Psycho && + npcType != NPCID.GoblinSummoner && + npcType != NPCID.StardustSoldier && + npcType != NPCID.StardustSpiderSmall && + npcType != NPCID.NebulaSoldier && + npcType != NPCID.VortexRifleman && + npcType != NPCID.VortexHornetQueen && + npcType != NPCID.SolarDrakomire && + npcType != NPCID.SolarSolenian && + npcType != NPCID.MartianWalker)) + { + if (Main.dayTime && (double)(NPC.position.Y / 16f) < Main.worldSurface && NPC.timeLeft > 10) + { + NPC.timeLeft = 10; + } + if (NPC.velocity.X == 0f) + { + if (NPC.velocity.Y == 0f) + { + NPC.ai[0] += 1f; + if (NPC.ai[0] >= 2f) + { + NPC.direction *= -1; + + NPC.spriteDirection = NPC.direction; + + NPC.ai[0] = 0f; + } + } + } + else + { + NPC.ai[0] = 0f; + } + if (NPC.direction == 0) + { + NPC.direction = 1; + } + } + + if (npcType == NPCID.Vampire || npcType == NPCID.NutcrackerSpinning) + { + if (npcType == NPCID.Vampire && ((NPC.velocity.X > 0f && NPC.direction < 0) || (NPC.velocity.X < 0f && NPC.direction > 0))) + { + NPC.velocity.X *= 0.95f; + } + if (NPC.velocity.X < -8f || NPC.velocity.X > 8f) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity *= 0.8f; + } + } + else if (NPC.velocity.X < 8f && NPC.direction == 1) + { + if (NPC.velocity.Y == 0f && NPC.velocity.X < 0f) + { + NPC.velocity.X *= 0.99f; + } + NPC.velocity.X += 0.09f; + if (NPC.velocity.X > 8f) + { + NPC.velocity.X = 8f; + } + } + else if (NPC.velocity.X > -8f && NPC.direction == -1) + { + if (NPC.velocity.Y == 0f && NPC.velocity.X > 0f) + { + NPC.velocity.X *= 0.99f; + } + NPC.velocity.X -= 0.09f; + if (NPC.velocity.X < -8f) + { + NPC.velocity.X = -8f; + } + } + } + else if (npcType == NPCID.LihzahrdCrawler) + { + FighterRunningAI(NPC, CalamityWorld.death ? 8f : 6f, 0.12f, 0.8f, true, 0.8f); + } + else if (npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType() || npcType == NPCID.SwampThing || npcType == NPCID.PirateCorsair || npcType == NPCID.MushiLadybug || npcType == NPCID.DesertLamiaLight || npcType == NPCID.DesertLamiaDark) + { + FighterRunningAI(NPC, CalamityWorld.death ? 6f : 4f, 0.09f, 0.8f, true, 0.8f); + } + else if (npcType == NPCID.CreatureFromTheDeep || npcType == NPCID.GoblinThief || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.Werewolf || npcType == NPCID.BlackRecluse || npcType == NPCID.Frankenstein || npcType == NPCID.Nymph || npcType == NPCID.ArmoredViking || npcType == NPCID.PirateDeckhand || npcType == NPCID.AnomuraFungus || npcType == NPCID.Splinterling || npcType == NPCID.Yeti || npcType == NPCID.Nutcracker || npcType == NPCID.Krampus || (npcType >= 524 && npcType <= 527) || npcType == NPCID.DesertScorpionWalk) + { + FighterRunningAI(NPC, CalamityWorld.death ? 3f : 2.5f, 0.09f, 0.8f); + } + else if (npcType == NPCID.Clown) + { + FighterRunningAI(NPC, CalamityWorld.death ? 5f : 4f, 0.06f, 0.8f); + } + else if (npcType == NPCID.Skeleton || npcType == NPCID.SporeSkeleton || npcType == NPCID.GoblinPeon || npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.CorruptBunny || npcType == NPCID.GoblinScout || npcType == NPCID.PossessedArmor || npcType == NPCID.WallCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.UndeadViking || npcType == NPCID.CorruptPenguin || npcType == NPCID.SnowFlinx || npcType == NPCID.Lihzahrd || npcType == NPCID.HeadacheSkeleton || npcType == NPCID.MisassembledSkeleton || npcType == NPCID.PantlessSkeleton || npcType == NPCID.CochinealBeetle || npcType == NPCID.CyanBeetle || npcType == NPCID.LacBeetle || npcType == NPCID.FlyingSnake || npcType == NPCID.FaceMonster || npcType == NPCID.ZombieMushroom || npcType == NPCID.ZombieElf || npcType == NPCID.ZombieElfBeard || npcType == NPCID.ZombieElfGirl || npcType == NPCID.GingerbreadMan || npcType == NPCID.GrayGrunt || npcType == NPCID.GigaZapper || npcType == NPCID.Fritz || npcType == NPCID.Nailhead || npcType == NPCID.Psycho || npcType == NPCID.CrimsonBunny || npcType == NPCID.ThePossessed || npcType == NPCID.CrimsonPenguin || npcType == NPCID.Medusa || npcType == NPCID.GraniteGolem || npcType == NPCID.VortexRifleman || npcType == NPCID.VortexSoldier) + { + float maxVelocity = 1.5f; + if (npcType == NPCID.AngryBonesBig) + { + maxVelocity = 2f; + } + else if (npcType == NPCID.AngryBonesBigMuscle) + { + maxVelocity = 1.75f; + } + else if (npcType == NPCID.AngryBonesBigHelmet) + { + maxVelocity = 1.25f; + } + else if (npcType == NPCID.HeadacheSkeleton) + { + maxVelocity = 1.1f; + } + else if (npcType == NPCID.MisassembledSkeleton) + { + maxVelocity = 0.9f; + } + else if (npcType == NPCID.PantlessSkeleton) + { + maxVelocity = 1.2f; + } + else if (npcType == NPCID.ZombieElf) + { + maxVelocity = 1.75f; + } + else if (npcType == NPCID.ZombieElfBeard) + { + maxVelocity = 1.25f; + } + else if (npcType == NPCID.ZombieElfGirl) + { + maxVelocity = 2f; + } + else if (npcType == NPCID.GrayGrunt) + { + maxVelocity = 1.8f; + } + else if (npcType == NPCID.GigaZapper) + { + maxVelocity = 2.25f; + } + else if (npcType == NPCID.Fritz) + { + maxVelocity = 4f; + } + else if (npcType == NPCID.Nailhead) + { + maxVelocity = CalamityWorld.revenge ? 0.75f : 0.6f; + } + else if (npcType == NPCID.Psycho) + { + maxVelocity = 3.75f; + } + else if (npcType == NPCID.ThePossessed) + { + maxVelocity = 3.25f; + } + else if (npcType == NPCID.Medusa) + { + maxVelocity = 1.5f + (1f - (float)NPC.life / (float)NPC.lifeMax) * 2f; + } + else if (npcType == NPCID.VortexRifleman) + { + maxVelocity = CalamityWorld.revenge ? 6f : 4.8f; + } + else if (npcType == NPCID.VortexSoldier) + { + maxVelocity = 4f; + } + if (npcType == NPCID.Skeleton || npcType == NPCID.HeadacheSkeleton || npcType == NPCID.MisassembledSkeleton || npcType == NPCID.PantlessSkeleton || npcType == NPCID.GingerbreadMan) + { + maxVelocity *= 1f + (1f - NPC.scale); + } + maxVelocity *= 1.25f; + if (CalamityWorld.death) + maxVelocity *= 1.25f; + + bool extraSlowdown = NPC.velocity.Y == 0f && npcType == NPCID.Fritz && ((NPC.direction > 0 && NPC.velocity.X < 0f) || (NPC.direction < 0 && NPC.velocity.X > 0f)); + FighterRunningAI(NPC, maxVelocity, 0.09f, 0.9f, extraSlowdown, 0.9f); + } + else if (npcType >= NPCID.RustyArmoredBonesAxe && npcType <= NPCID.HellArmoredBonesSword) + { + float maxVelocity = 1.5f; + if (npcType == NPCID.RustyArmoredBonesAxe) + { + maxVelocity = 2f; + } + if (npcType == NPCID.RustyArmoredBonesFlail) + { + maxVelocity = 1f; + } + if (npcType == NPCID.RustyArmoredBonesSword) + { + maxVelocity = 1.5f; + } + if (npcType == NPCID.RustyArmoredBonesSwordNoArmor) + { + maxVelocity = 3f; + } + if (npcType == NPCID.BlueArmoredBones) + { + maxVelocity = 1.25f; + } + if (npcType == NPCID.BlueArmoredBonesMace) + { + maxVelocity = 3f; + } + if (npcType == NPCID.BlueArmoredBonesNoPants) + { + maxVelocity = 3.25f; + } + if (npcType == NPCID.BlueArmoredBonesSword) + { + maxVelocity = 2f; + } + if (npcType == NPCID.HellArmoredBones) + { + maxVelocity = 2.75f; + } + if (npcType == NPCID.HellArmoredBonesSpikeShield) + { + maxVelocity = 1.8f; + } + if (npcType == NPCID.HellArmoredBonesMace) + { + maxVelocity = 1.3f; + } + if (npcType == NPCID.HellArmoredBonesSword) + { + maxVelocity = 2.5f; + } + maxVelocity *= 1f + (1f - NPC.scale); + maxVelocity *= 1.25f; + if (CalamityWorld.death) + maxVelocity *= 1.25f; + + FighterRunningAI(NPC, maxVelocity, 0.09f, 0.8f, false); + } + else if (npcType >= 305 && npcType <= 314) + { + float maxVelocity = 1.5f; + if (npcType == NPCID.Scarecrow1 || npcType == NPCID.Scarecrow6) + { + maxVelocity = 2f; + } + if (npcType == NPCID.Scarecrow2 || npcType == NPCID.Scarecrow7) + { + maxVelocity = 1.25f; + } + if (npcType == NPCID.Scarecrow3 || npcType == NPCID.Scarecrow8) + { + maxVelocity = 2.25f; + } + if (npcType == NPCID.Scarecrow4 || npcType == NPCID.Scarecrow9) + { + maxVelocity = 1.5f; + } + if (npcType == NPCID.Scarecrow5 || npcType == NPCID.Scarecrow10) + { + maxVelocity = 1f; + } + maxVelocity *= 1.25f; + if (CalamityWorld.death) + maxVelocity *= 1.25f; + + if (npcType < 310) //Pogo stick Scarecrows + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X *= 0.85f; + if (NPC.velocity.X > -0.3f && NPC.velocity.X < 0.3f) + { + NPC.velocity.Y = -9f; //-7f normally + NPC.velocity.X = maxVelocity * (float)NPC.direction; + } + } + else if (NPC.spriteDirection == NPC.direction) + { + NPC.velocity.X = (NPC.velocity.X * 10f + maxVelocity * NPC.direction) / 11f; + } + } + else + { + FighterRunningAI(NPC, maxVelocity, 0.09f, 0.8f, false); + } + } + else if (npcType == NPCID.Crab || npcType == NPCID.SeaSnail || npcType == NPCID.VortexLarva) + { + FighterRunningAI(NPC, CalamityWorld.death ? 4f : CalamityWorld.revenge ? 1f : 0.5f, CalamityWorld.revenge ? 0.06f : 0.05f, 0.7f); + } + else if (npcType == NPCID.Mummy || npcType == NPCID.DarkMummy || npcType == NPCID.LightMummy) + { + float maxVelocity = 3f; + float acceleration = 0.15f; + if (npcType == NPCID.DarkMummy) + { + maxVelocity *= 1.5f; + } + if (CalamityWorld.death) + { + maxVelocity *= 1.25f; + } + FighterRunningAI(NPC, maxVelocity, acceleration, 0.7f); + } + else if (npcType == NPCID.BoneLee) + { + FighterRunningAI(NPC, CalamityWorld.death ? 7f : CalamityWorld.revenge ? 6f : 5f, CalamityWorld.revenge ? 0.3f : 0.2f, 0.7f); + } + else if (npcType == NPCID.IceGolem) + { + FighterRunningAI(NPC, CalamityWorld.death ? 4.5f : CalamityWorld.revenge ? 3f : 2f, CalamityWorld.revenge ? 0.3f : 0.2f, 0.7f); + } + else if (npcType == NPCID.Eyezor) + { + FighterRunningAI(NPC, CalamityWorld.death ? 5f : CalamityWorld.revenge ? 3.5f : 2.5f, CalamityWorld.revenge ? 0.3f : 0.2f, 0.8f); + } + else if (npcType == NPCID.MartianEngineer) + { + if (NPC.ai[2] > 0f) + { + if (NPC.velocity.Y == 0f) + NPC.velocity.X *= 0.8f; + } + else + FighterRunningAI(NPC, CalamityWorld.death ? 5f : 3.5f, 0.2f, 0.8f); + } + else if (npcType == NPCID.Butcher) + { + float acceleration = 0.2f; + if (Math.Abs(NPC.velocity.X) > 2f) + { + acceleration *= 0.8f; + } + if (Math.Abs(NPC.velocity.X) > 2.5) + { + acceleration *= 0.8f; + } + if (Math.Abs(NPC.velocity.X) > 3f) + { + acceleration *= 0.8f; + } + if (Math.Abs(NPC.velocity.X) > 3.5) + { + acceleration *= 0.8f; + } + if (Math.Abs(NPC.velocity.X) > 4f) + { + acceleration *= 0.8f; + } + if (Math.Abs(NPC.velocity.X) > 4.5f) + { + acceleration *= 0.8f; + } + if (Math.Abs(NPC.velocity.X) > 5f) + { + acceleration *= 0.8f; + } + if (Math.Abs(NPC.velocity.X) > 5.5) + { + acceleration *= 0.8f; + } + FighterRunningAI(NPC, CalamityWorld.death ? 10f : 7f, acceleration, 0.8f); + } + else if (npcType == NPCID.GiantWalkingAntlion || npcType == NPCID.WalkingAntlion || npcType == NPCID.LarvaeAntlion) + { + float xAdditive = CalamityWorld.death ? 3.5f : 3f; + float turnValue = 90f; + float absoluteVelocityX = Math.Abs(NPC.velocity.X); + if (absoluteVelocityX > 2.75f) + { + xAdditive = CalamityWorld.death ? 7f : 6f; + turnValue += 100f; + } + else if (absoluteVelocityX > 2.25) + { + xAdditive = CalamityWorld.death ? 5f : 4.25f; + turnValue += 80f; + } + if (Math.Abs(NPC.velocity.Y) < 0.5) + { + if (NPC.velocity.X > 0f && NPC.direction < 0) + { + NPC.velocity *= 0.9f; + } + if (NPC.velocity.X < 0f && NPC.direction > 0) + { + NPC.velocity *= 0.9f; + } + } + if (Math.Abs(NPC.velocity.Y) > 0.3f) + { + turnValue *= 3f; + } + if (NPC.velocity.X <= 0f && NPC.direction < 0) + { + NPC.velocity.X = (NPC.velocity.X * turnValue - xAdditive) / (turnValue + 1f); + } + else if (NPC.velocity.X >= 0f && NPC.direction > 0) + { + NPC.velocity.X = (NPC.velocity.X * turnValue + xAdditive) / (turnValue + 1f); + } + else if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) > 20f && Math.Abs(NPC.velocity.Y) <= 0.3f) + { + NPC.velocity.X *= 0.99f; + NPC.velocity.X += NPC.direction * 0.025f; + } + } + else if (npcType == NPCID.Scutlix || npcType == NPCID.VortexHornet || npcType == NPCID.SolarDrakomire || npcType == NPCID.SolarSolenian || npcType == NPCID.SolarSpearman || npcType == NPCID.DesertBeast) + { + float maxVelocity = 5f; + float acceleration = 0.25f; + float turnMultiplier = 0.7f; + if (npcType == NPCID.VortexHornet) + { + maxVelocity = 6f; + acceleration = 0.2f; + turnMultiplier = 0.8f; + } + else if (npcType == NPCID.SolarDrakomire) + { + maxVelocity = 4f; + acceleration = 0.1f; + turnMultiplier = 0.95f; + } + else if (npcType == NPCID.SolarSolenian) + { + maxVelocity = 6f; + acceleration = 0.15f; + turnMultiplier = 0.85f; + } + else if (npcType == NPCID.SolarSpearman) + { + maxVelocity = 5f; + acceleration = 0.1f; + turnMultiplier = 0.95f; + } + else if (npcType == NPCID.DesertBeast) + { + maxVelocity = 5f; + acceleration = 0.15f; + turnMultiplier = 0.98f; + } + if (CalamityWorld.revenge) + { + maxVelocity *= 1.25f; + acceleration *= 1.25f; + } + if (CalamityWorld.death) + { + maxVelocity *= 1.25f; + acceleration *= 1.25f; + } + FighterRunningAI(NPC, maxVelocity, acceleration, turnMultiplier); + } + else if ((npcType >= NPCID.ArmedZombie && npcType <= NPCID.ArmedZombieCenx) || npcType == NPCID.Crawdad || npcType == NPCID.Crawdad2) + { + if (NPC.ai[2] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + float maxVelocity = CalamityWorld.death ? 2.5f : 1.5f; + maxVelocity *= 1f + (1f - NPC.scale); + FighterRunningAI(NPC, maxVelocity, 0.09f, 0.8f, true, 0.8f); + if (NPC.velocity.Y == 0f && (!Main.dayTime || (double)NPC.position.Y > Main.worldSurface * 16.0) && !Main.player[NPC.target].dead) + { + Vector2 playerDistance = NPC.Center - Main.player[NPC.target].Center; + int slowdownDistance = 50; + if (npcType >= NPCID.Crawdad && npcType <= NPCID.Crawdad2) + { + slowdownDistance = 42; + } + if (playerDistance.Length() < slowdownDistance && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.velocity.X *= 0.7f; + NPC.ai[2] = 1f; + } + } + } + else + { + // Set damage + NPC.damage = (int)Math.Round(NPC.defDamage * 1.4); + + NPC.ai[3] = 1f; + NPC.velocity.X *= 0.9f; + if (Math.Abs(NPC.velocity.X) < 0.1f) + { + NPC.velocity.X = 0f; + } + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 20f || NPC.velocity.Y != 0f || (Main.dayTime && (double)NPC.position.Y < Main.worldSurface * 16.0)) + { + NPC.ai[2] = 0f; + } + } + } + else if (npcType != NPCID.SkeletonArcher && + npcType != NPCID.GoblinArcher && + npcType != NPCID.IcyMerman && + npcType != NPCID.PirateDeadeye && + npcType != NPCID.PirateCrossbower && + npcType != NPCID.PirateCaptain && + npcType != NPCID.Paladin && + npcType != NPCID.SkeletonSniper && + npcType != NPCID.TacticalSkeleton && + npcType != NPCID.SkeletonCommando && + npcType != NPCID.ElfArcher && + npcType != NPCID.CultistArcherBlue && + npcType != NPCID.CultistArcherWhite && + npcType != NPCID.BrainScrambler && + npcType != NPCID.RayGunner && + (npcType < NPCID.BoneThrowingSkeleton || npcType > NPCID.BoneThrowingSkeleton4) && + npcType != NPCID.DrManFly && + npcType != NPCID.GreekSkeleton && + npcType != NPCID.StardustSoldier && + npcType != NPCID.StardustSpiderSmall && + (npcType < NPCID.Salamander || npcType > NPCID.Salamander9) && + npcType != NPCID.NebulaSoldier && + npcType != NPCID.VortexSoldier && + npcType != NPCID.MartianWalker) + { + float velocityMax = 1f; + if (npcType == NPCID.PincushionZombie) + { + velocityMax = 1.1f; + } + if (npcType == NPCID.SlimedZombie) + { + velocityMax = 0.9f; + } + if (npcType == NPCID.SwampZombie) + { + velocityMax = 1.2f; + } + if (npcType == NPCID.TwiggyZombie) + { + velocityMax = 0.8f; + } + if (npcType == NPCID.BaldZombie) + { + velocityMax = 0.95f; + } + if (npcType == NPCID.FemaleZombie) + { + velocityMax = 0.87f; + } + if (npcType == NPCID.ZombieRaincoat) + { + velocityMax = 1.05f; + } + if (npcType == ModContent.NPCType()) + { + velocityMax = 0.85f; + } + if (npcType == NPCID.BloodZombie) + { + float playerDistance = (Main.player[NPC.target].Center - NPC.Center).Length(); + playerDistance *= 0.0025f; + if (playerDistance > 1.5) + { + playerDistance = 1.5f; + } + if (Main.expertMode) + { + velocityMax = 3f - playerDistance; + } + else + { + velocityMax = 2.5f - playerDistance; + } + velocityMax *= 0.8f; + } + if (npcType == NPCID.BloodZombie || npcType == NPCID.Zombie || npcType == NPCID.BaldZombie || npcType == NPCID.PincushionZombie || npcType == NPCID.SlimedZombie || npcType == NPCID.SwampZombie || npcType == NPCID.TwiggyZombie || npcType == NPCID.FemaleZombie || npcType == NPCID.ZombieRaincoat || npcType == NPCID.ZombieXmas || npcType == NPCID.ZombieSweater || npcType == ModContent.NPCType()) + { + velocityMax *= 1f + (1f - NPC.scale); + } + if (CalamityWorld.revenge) + velocityMax *= 1.25f; + if (CalamityWorld.death) + velocityMax *= 1.25f; + FighterRunningAI(NPC, velocityMax, 0.09f, 0.8f, true, 0.8f); + } + + if (npcType >= 277 && npcType <= 280) + { + Lighting.AddLight((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16, 0.2f, 0.1f, 0f); + } + else if (npcType == NPCID.MartianWalker) + { + Lighting.AddLight(NPC.Top + new Vector2(0f, 20f), 0.3f, 0.3f, 0.7f); + } + else if (npcType == NPCID.DesertGhoulCorruption) + { + Vector3 rgb = new Vector3(0.7f, 1f, 0.2f) * 0.5f; + Lighting.AddLight(NPC.Top + new Vector2(0f, 15f), rgb); + } + else if (npcType == NPCID.DesertGhoulCrimson) + { + Vector3 rgb2 = new Vector3(1f, 1f, 0.5f) * 0.4f; + Lighting.AddLight(NPC.Top + new Vector2(0f, 15f), rgb2); + } + else if (npcType == NPCID.DesertGhoulHallow) + { + Vector3 rgb3 = new Vector3(0.6f, 0.3f, 1f) * 0.4f; + Lighting.AddLight(NPC.Top + new Vector2(0f, 15f), rgb3); + } + else if (npcType == NPCID.SolarDrakomire) + { + NPC.hide = false; + // I'd assume the Drakomire is drawn by the rider if it's present + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type == NPCID.SolarDrakomireRider && n.ai[0] == (float)NPC.whoAmI) + { + NPC.hide = true; + break; + } + } + } + else if (npcType == NPCID.MushiLadybug) + { + if (NPC.velocity.Y != 0f) + { + NPC.TargetClosest(true); + NPC.spriteDirection = NPC.direction; + if (Main.player[NPC.target].Center.X < NPC.position.X && NPC.velocity.X > 0f) + { + NPC.velocity.X *= 0.95f; + } + else if (Main.player[NPC.target].Center.X > NPC.position.X + (float)NPC.width && NPC.velocity.X < 0f) + { + NPC.velocity.X *= 0.95f; + } + if (Main.player[NPC.target].Center.X < NPC.position.X && NPC.velocity.X > -5f) + { + NPC.velocity.X -= 0.1f; + } + else if (Main.player[NPC.target].Center.X > NPC.position.X + (float)NPC.width && NPC.velocity.X < 5f) + { + NPC.velocity.X += 0.1f; + } + } + else if (Main.player[NPC.target].Center.Y + 50f < NPC.position.Y && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.velocity.Y = -9f; + } + } + else if (npcType == NPCID.VortexRifleman) + { + if (NPC.velocity.Y == 0f) + { + NPC.ai[2] = 0f; + } + if (NPC.velocity.Y != 0f && NPC.ai[2] == 1f) + { + NPC.TargetClosest(true); + NPC.spriteDirection = -NPC.direction; + if (Collision.CanHit(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0)) + { + float idealLocationX = Main.player[NPC.target].Center.X - (float)(NPC.direction * 600) - NPC.Center.X; + float idealLocationY = Main.player[NPC.target].Bottom.Y - NPC.Bottom.Y; + if (idealLocationX < 0f && NPC.velocity.X > 0f) + { + NPC.velocity.X *= 0.9f; + } + else if (idealLocationX > 0f && NPC.velocity.X < 0f) + { + NPC.velocity.X *= 0.9f; + } + if (idealLocationX < 0f && NPC.velocity.X > -7f) + { + NPC.velocity.X -= 0.12f; + } + else if (idealLocationX > 0f && NPC.velocity.X < 7f) + { + NPC.velocity.X += 0.12f; + } + if (NPC.velocity.X > 8f) + { + NPC.velocity.X = 8f; + } + if (NPC.velocity.X < -8f) + { + NPC.velocity.X = -8f; + } + if (idealLocationY < -20f && NPC.velocity.Y > 0f) + { + NPC.velocity.Y *= 0.8f; + } + else if (idealLocationY > 20f && NPC.velocity.Y < 0f) + { + NPC.velocity.Y *= 0.8f; + } + if (idealLocationY < -20f && NPC.velocity.Y > -7f) + { + NPC.velocity.Y -= 0.35f; + } + else if (idealLocationY > 20f && NPC.velocity.Y < 7f) + { + NPC.velocity.Y += 0.35f; + } + } + if (Main.rand.NextBool(3)) + { + Vector2 position = NPC.Center + new Vector2((float)(NPC.direction * -14), -8f) - Vector2.One * 4f; + Vector2 velocity = new Vector2((float)(NPC.direction * -6), 12f) * 0.2f + Utils.RandomVector2(Main.rand, -1f, 1f) * 0.1f; + Dust dust = Main.dust[Dust.NewDust(position, 8, 8, DustID.Vortex, velocity.X, velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 0.5f)]; + dust.noGravity = true; + dust.velocity = velocity; + dust.customData = NPC; + } + // Adjust velocity based on the other storm drivers who want to pump your face full of bullets + foreach (NPC n in Main.ActiveNPCs) + { + 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 < n.position.X) + { + NPC.velocity.X -= 0.05f; + } + else + { + NPC.velocity.X += 0.05f; + } + if (NPC.position.Y < n.position.Y) + { + NPC.velocity.Y -= 0.05f; + } + else + { + NPC.velocity.Y += 0.05f; + } + } + } + } + else if (Main.player[NPC.target].Center.Y + 100f < NPC.position.Y && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.velocity.Y = -7f; + NPC.ai[2] = 1f; + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[2]++; + bool closeToPlayer = NPC.Distance(Main.player[NPC.target].Center) < 600f && Math.Abs(NPC.SafeDirectionTo(Main.player[NPC.target].Center).Y) < 0.5f; + float vortexShotgunGateValue = CalamityWorld.death ? 240f : CalamityWorld.revenge ? 360f : 480f; + if (NPC.localAI[2] >= vortexShotgunGateValue && closeToPlayer && Collision.CanHitLine(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0)) + { + NPC.localAI[2] = 0f; + Vector2 spawnPosition = NPC.Center + new Vector2(NPC.direction * 30f, 2f); + float vortexLaserVelocity = CalamityWorld.death ? 7f : CalamityWorld.revenge ? 6f : 5f; + Vector2 baseLaserVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center, Vector2.UnitX * NPC.direction) * vortexLaserVelocity; + + int damage = Main.expertMode ? 50 : 75; + float maxSpread = CalamityWorld.death ? 0.7f : CalamityWorld.revenge ? 0.6f : 0.5f; + for (int i = 0; i < 4; i++) + { + Vector2 randomizedVelocity = baseLaserVelocity + Utils.RandomVector2(Main.rand, -maxSpread, maxSpread); + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition, randomizedVelocity, ProjectileID.VortexLaser, damage, 1f, Main.myPlayer); + } + } + } + } + else if (npcType == NPCID.VortexHornet) + { + if (NPC.velocity.Y == 0f) + { + NPC.ai[2] = 0f; + NPC.rotation = 0f; + } + else + { + NPC.rotation = NPC.velocity.X * 0.1f; + } + if (NPC.velocity.Y != 0f && NPC.ai[2] == 1f) + { + NPC.TargetClosest(true); + NPC.spriteDirection = -NPC.direction; + if (Collision.CanHit(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0)) + { + float playerDistX = Main.player[NPC.target].Center.X - NPC.Center.X; + float playerDistY = Main.player[NPC.target].Center.Y - NPC.Center.Y; + if (playerDistX < 0f && NPC.velocity.X > 0f) + { + NPC.velocity.X *= 0.98f; + } + else if (playerDistX > 0f && NPC.velocity.X < 0f) + { + NPC.velocity.X *= 0.98f; + } + if (playerDistX < -20f && NPC.velocity.X > -(CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X -= CalamityWorld.revenge ? 0.025f : 0.015f; + } + else if (playerDistX > 20f && NPC.velocity.X < (CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X += CalamityWorld.revenge ? 0.025f : 0.015f; + } + if (NPC.velocity.X > (CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X = CalamityWorld.revenge ? 8f : 6f; + } + if (NPC.velocity.X < -(CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X = -(CalamityWorld.revenge ? 8f : 6f); + } + if (playerDistY < -20f && NPC.velocity.Y > 0f) + { + NPC.velocity.Y *= 0.98f; + } + else if (playerDistY > 20f && NPC.velocity.Y < 0f) + { + NPC.velocity.Y *= 0.98f; + } + if (playerDistY < -20f && NPC.velocity.Y > -(CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.Y -= CalamityWorld.revenge ? 0.25f : 0.15f; + } + else if (playerDistY > 20f && NPC.velocity.Y < (CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.Y += CalamityWorld.revenge ? 0.25f : 0.15f; + } + } + foreach (NPC n in Main.ActiveNPCs) + { + 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 < n.position.X) + { + NPC.velocity.X -= 0.05f; + } + else + { + NPC.velocity.X += 0.05f; + } + if (NPC.position.Y < n.position.Y) + { + NPC.velocity.Y -= 0.05f; + } + else + { + NPC.velocity.Y += 0.05f; + } + } + } + } + else if (Main.player[NPC.target].Center.Y + 100f < NPC.position.Y && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.velocity.Y = -(CalamityWorld.revenge ? 7f : 5f); + NPC.ai[2] = 1f; + } + } + else if (npcType == NPCID.VortexHornetQueen) + { + if (NPC.ai[1] > 0f && NPC.velocity.Y > 0f) + { + NPC.velocity.Y *= 0.85f; + if (NPC.velocity.Y == 0f) + { + NPC.velocity.Y = -0.4f; + } + } + if (NPC.velocity.Y != 0f) + { + NPC.TargetClosest(true); + NPC.spriteDirection = NPC.direction; + if (Collision.CanHit(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0)) + { + float distanceToLocationX = Main.player[NPC.target].Center.X - (float)(NPC.direction * (CalamityWorld.revenge ? 450 : 300)) - NPC.Center.X; + if (distanceToLocationX < 40f && NPC.velocity.X > 0f) + { + NPC.velocity.X *= 0.98f; + } + else if (distanceToLocationX > 40f && NPC.velocity.X < 0f) + { + NPC.velocity.X *= 0.98f; + } + if (distanceToLocationX < 40f && NPC.velocity.X > -(CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X -= CalamityWorld.revenge ? 0.25f : 0.2f; + } + else if (distanceToLocationX > 40f && NPC.velocity.X < (CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X += CalamityWorld.revenge ? 0.25f : 0.2f; + } + if (NPC.velocity.X > (CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X = CalamityWorld.revenge ? 8f : 6f; + } + if (NPC.velocity.X < -(CalamityWorld.revenge ? 8f : 6f)) + { + NPC.velocity.X = -(CalamityWorld.revenge ? 8f : 6f); + } + } + } + else if (Main.player[NPC.target].Center.Y + 100f < NPC.position.Y && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.velocity.Y = -(CalamityWorld.revenge ? 8f : 6f); + } + foreach (NPC n in Main.ActiveNPCs) + { + 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 < n.position.X) + { + NPC.velocity.X -= 0.1f; + } + else + { + NPC.velocity.X += 0.1f; + } + if (NPC.position.Y < n.position.Y) + { + NPC.velocity.Y -= 0.1f; + } + else + { + NPC.velocity.Y += 0.1f; + } + } + } + if (Main.rand.NextBool(6) && NPC.ai[1] <= 20f) + { + Dust dust = Main.dust[Dust.NewDust(NPC.Center + new Vector2((float)((NPC.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, DustID.Vortex, NPC.velocity.X, NPC.velocity.Y, 100, default, 1f)]; + dust.velocity = dust.velocity / 4f + NPC.velocity / 2f; + dust.scale = 0.6f; + dust.noLight = true; + } + if (NPC.ai[1] >= 57f) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 161, + 229 + }); + Dust dust = Main.dust[Dust.NewDust(NPC.Center + new Vector2((float)((NPC.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, dustType, NPC.velocity.X, NPC.velocity.Y, 100, default, 1f)]; + dust.velocity = dust.velocity / 4f + NPC.SafeDirectionTo(Main.player[NPC.target].Top); + dust.scale = 1.2f; + dust.noLight = true; + } + if (Main.rand.NextBool(6)) + { + Dust dust = Main.dust[Dust.NewDust(NPC.Center, 2, 2, DustID.Vortex, 0f, 0f, 0, default, 1f)]; + dust.position = NPC.Center + new Vector2((float)((NPC.spriteDirection == 1) ? 26 : -26), 24f); + dust.velocity.X = 0f; + if (dust.velocity.Y < 0f) + { + dust.velocity.Y = 0f; + } + dust.noGravity = true; + dust.scale = 1f; + dust.noLight = true; + } + } + else if (npcType == NPCID.SnowFlinx) + { + if (NPC.velocity.Y == 0f) + { + NPC.rotation = 0f; + NPC.localAI[0] = 0f; + } + else if (NPC.localAI[0] == 1f) + { + NPC.rotation += NPC.velocity.X * 0.05f; + } + } + else if (npcType == NPCID.VortexLarva) + { + if (NPC.velocity.Y == 0f) + { + NPC.rotation = 0f; + } + else + { + NPC.rotation += NPC.velocity.X * 0.08f; + } + } + + // Turn into a bat + if (npcType == NPCID.Vampire && Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.Distance(Main.player[NPC.target].Center) > 300f) + { + NPC.Transform(NPCID.VampireBat); + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.velocity.Y == 0f) + TryConvertToWallClimber(NPC); + + bool prehardmodeSpiders = (NPC.type == NPCID.WallCreeper || NPC.type == NPCID.WallCreeperWall || NPC.type == NPCID.BloodCrawler || NPC.type == NPCID.BloodCrawlerWall) && CalamityWorld.revenge; + if (Main.netMode != NetmodeID.MultiplayerClient && Main.expertMode && NPC.target >= 0 && (npcType == NPCID.BlackRecluse || npcType == NPCID.BlackRecluseWall || NPC.type == NPCID.JungleCreeper || NPC.type == NPCID.JungleCreeperWall || prehardmodeSpiders) && Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.localAI[0] += 1f; + if (NPC.justHit) + NPC.localAI[0] = 0f; + + float webSpitGateValue = CalamityWorld.death ? SpiderWebSpitGateValue_Death : CalamityWorld.revenge ? SpiderWebSpitGateValue_Rev : SpiderWebSpitGateValue; + + // Emit web dust from mouth when about to fire + Vector2 mouth = new Vector2(NPC.Center.X + (NPC.direction == -1 ? -22f : 12f), NPC.Center.Y - 4f); + if (NPC.localAI[0] > webSpitGateValue - SpiderWebSpitTelegraphTime) + { + Dust dust = Dust.NewDustDirect(mouth, 1, 1, DustID.Web, 0f, 0f, 100, default, 1.5f); + dust.noGravity = true; + dust.velocity *= 0f; + } + + if (NPC.localAI[0] >= webSpitGateValue) + { + NPC.localAI[0] = 0f; + Vector2 velocity = (Main.player[NPC.target].Center - mouth).SafeNormalize(-Vector2.UnitY) * (prehardmodeSpiders ? 6f : 10f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), mouth, velocity, ProjectileID.WebSpit, 18, 0f, Main.myPlayer); + } + } + else if (npcType == NPCID.BlackRecluse || npcType == NPCID.BlackRecluseWall || NPC.type == NPCID.JungleCreeper || NPC.type == NPCID.JungleCreeperWall || prehardmodeSpiders) + NPC.localAI[0] = 0f; + + if (npcType == NPCID.IceGolem) + { + if (NPC.justHit || NPC.confused || NPC.velocity.Y != 0f || Main.player[NPC.target].dead || Main.player[NPC.target].frozen || !((NPC.direction > 0 && NPC.Center.X < Main.player[NPC.target].Center.X) || (NPC.direction < 0 && NPC.Center.X > Main.player[NPC.target].Center.X)) || !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.ai[2] = 0f; + + NPC.ai[2] += 1f; + Vector2 eyeLocation = NPC.Center + Vector2.UnitX * (NPC.direction == -1 ? -14f : 6f) - Vector2.UnitY * 40f; + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] >= (CalamityWorld.death ? IceGolemFrostBeamGateValue_Death : CalamityWorld.revenge ? IceGolemFrostBeamGateValue_Rev : IceGolemFrostBeamGateValue) && NPC.velocity.Y == 0f && !Main.player[NPC.target].dead && !Main.player[NPC.target].frozen && ((NPC.direction > 0 && NPC.Center.X < Main.player[NPC.target].Center.X) || (NPC.direction < 0 && NPC.Center.X > Main.player[NPC.target].Center.X)) && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.netUpdate = true; + float iceLaserVelocity = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; + Vector2 spawnPosition = eyeLocation; + Vector2 velocity = (Main.player[NPC.target].Center - spawnPosition).SafeNormalize(-Vector2.UnitY) * iceLaserVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition + velocity.SafeNormalize(-Vector2.UnitY) * 100f, velocity, ProjectileID.FrostBeam, 32, 0f, Main.myPlayer); + NPC.ai[2] = 0f; + } + + // Emit ice dust from eye when about to fire + if (NPC.ai[2] > (CalamityWorld.death ? IceGolemFrostBeamGateValue_Death : CalamityWorld.revenge ? IceGolemFrostBeamGateValue_Rev : IceGolemFrostBeamGateValue) - IceGolemFrostBeamTelegraphTime) + { + Dust dust = Dust.NewDustDirect(eyeLocation, 1, 1, DustID.Frost, 0f, 0f, 200, default, 1.5f); + dust.noGravity = true; + dust.velocity *= 0f; + } + } + + if (npcType == NPCID.Eyezor) + { + if (NPC.justHit || NPC.confused || NPC.velocity.Y != 0f || Main.player[NPC.target].dead || !((NPC.direction > 0 && NPC.Center.X < Main.player[NPC.target].Center.X) || (NPC.direction < 0 && NPC.Center.X > Main.player[NPC.target].Center.X)) || !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.ai[2] = 0f; + + NPC.ai[2] += 1f; + Vector2 eyeLocation = new Vector2(NPC.position.X + (NPC.direction == -1 ? -12f : 6f) + (float)NPC.width * 0.5f, NPC.position.Y + 6f); + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] >= (CalamityWorld.death ? EyezorLaserGateValue_Death : CalamityWorld.revenge ? EyezorLaserGateValue_Rev : EyezorLaserGateValue) && NPC.velocity.Y == 0f && !Main.player[NPC.target].dead && ((NPC.direction > 0 && NPC.Center.X < Main.player[NPC.target].Center.X) || (NPC.direction < 0 && NPC.Center.X > Main.player[NPC.target].Center.X)) && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + float eyeLaserVelocity = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; + Vector2 spawnPosition = eyeLocation; + Vector2 velocity = (Main.player[NPC.target].Center - spawnPosition).SafeNormalize(-Vector2.UnitY) * eyeLaserVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition + velocity.SafeNormalize(-Vector2.UnitY) * 80f, velocity, ProjectileID.EyeLaser, 40, 0f, Main.myPlayer); + NPC.ai[2] = 0f; + } + + // Emit demon dust from eye when about to fire + if (NPC.ai[2] > (CalamityWorld.death ? EyezorLaserGateValue_Death : CalamityWorld.revenge ? EyezorLaserGateValue_Rev : EyezorLaserGateValue) - EyezorLaserTelegraphTime) + { + Dust dust = Dust.NewDustDirect(eyeLocation, 1, 1, DustID.Shadowflame, 0f, 0f, 100, default, 1.5f); + dust.noGravity = true; + dust.velocity *= 0f; + } + } + + if (npcType == NPCID.MartianEngineer) + { + if (NPC.confused) + { + NPC.ai[2] = -40f; + } + else + { + if (NPC.ai[2] < 40f) + { + NPC.ai[2] += 1f; + } + if (NPC.ai[2] > 0f && NPC.CountNPCS(NPCID.MartianTurret) >= 4 * NPC.CountNPCS(NPCID.MartianEngineer)) + { + NPC.ai[2] = 0f; + } + if (NPC.justHit) + { + NPC.ai[2] = -20f; + } + if (NPC.ai[2] == 20f) + { + int centerTileX = (int)NPC.position.X / 16; + int centerTileY = (int)NPC.position.Y / 16; + int centerTileX2 = (int)NPC.position.X / 16; + int centerTileY2 = (int)NPC.position.Y / 16; + int maxTurretDistX = 5; + int maxTurretDistanceY = 2; + int tryCounter = 0; + bool createdTurret = false; + while (!createdTurret && tryCounter < 100) + { + tryCounter++; + int turretSpawnX = Main.rand.Next(centerTileX - maxTurretDistX, centerTileX + maxTurretDistX); + for (int y = Main.rand.Next(centerTileY - maxTurretDistX, centerTileY + maxTurretDistX); y < centerTileY + maxTurretDistX; y++) + { + if ((y < centerTileY - maxTurretDistanceY || y > centerTileY + maxTurretDistanceY || turretSpawnX < centerTileX - maxTurretDistanceY || turretSpawnX > centerTileX + maxTurretDistanceY) && (y < centerTileY2 || y > centerTileY2 || turretSpawnX < centerTileX2 || turretSpawnX > centerTileX2) && Main.tile[turretSpawnX, y].HasUnactuatedTile) + { + bool notLava = true; + if (Main.tile[turretSpawnX, y - 1].LiquidType == LiquidID.Lava) + { + notLava = false; + } + if (notLava && Main.tileSolid[(int)Main.tile[turretSpawnX, y].TileType] && !Collision.SolidTiles(turretSpawnX - 1, turretSpawnX + 1, y - 4, y - 1)) + { + int turretIdx = NPC.NewNPC(NPC.GetSource_FromAI(), turretSpawnX * 16 - NPC.width / 2, y * 16, NPCID.MartianTurret, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[turretIdx].position.Y = (float)(y * 16 - Main.npc[turretIdx].height); + createdTurret = true; + NPC.netUpdate = true; + break; + } + } + } + } + } + if (NPC.ai[2] == 40f) + { + NPC.ai[2] = -90f; + } + } + } + + if (npcType == NPCID.GigaZapper) + { + if (NPC.confused) + { + NPC.ai[2] = -40f; + } + else + { + if (NPC.ai[2] < 20f) + { + NPC.ai[2] += 1f; + } + if (NPC.justHit) + { + NPC.ai[2] = -20f; + } + if (NPC.ai[2] == 20f && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[2] = (float)(-10 + Main.rand.Next(3) * -10); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y + 8f, (float)(NPC.direction * 8), 0f, ProjectileID.GigaZapperSpear, 25, 1f, Main.myPlayer); + } + } + } + + if (npcType == NPCID.SkeletonArcher || + npcType == NPCID.GoblinArcher || + npcType == NPCID.IcyMerman || + npcType == NPCID.PirateDeadeye || + npcType == NPCID.PirateCrossbower || + npcType == NPCID.PirateCaptain || + npcType == NPCID.Paladin || + npcType == NPCID.SkeletonSniper || + npcType == NPCID.TacticalSkeleton || + npcType == NPCID.SkeletonCommando || + npcType == NPCID.ElfArcher || + npcType == NPCID.CultistArcherBlue || + npcType == NPCID.CultistArcherWhite || + npcType == NPCID.BrainScrambler || + npcType == NPCID.RayGunner || + (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) || + (npcType == NPCID.DrManFly || + npcType == NPCID.GreekSkeleton || + npcType == NPCID.StardustSoldier || + npcType == NPCID.StardustSpiderBig || + (npcType >= NPCID.Salamander && npcType <= NPCID.Salamander9)) || + npcType == NPCID.NebulaSoldier || + npcType == NPCID.VortexHornetQueen || + npcType == NPCID.MartianWalker) + { + bool npcAllowedToShoot = npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker; + bool isAlienQueen = npcType == NPCID.VortexHornetQueen; + bool canShootAtTarget = true; + int stardustGateValue = -1; + int stardustGateValueAdd = -1; + if (npcType == NPCID.StardustSoldier) + { + npcAllowedToShoot = true; + stardustGateValue = 90; + stardustGateValueAdd = 90; + if (NPC.ai[1] <= 150f) + { + canShootAtTarget = false; + } + } + if (NPC.confused) + { + NPC.ai[2] = 0f; + } + else + { + if (NPC.ai[1] > 0f) + { + NPC.ai[1] -= 1f; + } + if (NPC.justHit) + { + NPC.ai[1] = 30f; + NPC.ai[2] = 0f; + } + int attackTimeMax = 70; + if (npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite) + { + attackTimeMax = 80; + } + if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) + { + attackTimeMax = 80; + } + if (npcType == NPCID.MartianWalker) + { + attackTimeMax = 15; + } + if (npcType == NPCID.ElfArcher) + { + attackTimeMax = 110; + } + if (npcType == NPCID.SkeletonSniper) + { + attackTimeMax = 200; + } + if (npcType == NPCID.TacticalSkeleton) + { + attackTimeMax = 120; + } + if (npcType == NPCID.SkeletonCommando) + { + attackTimeMax = 90; + } + if (npcType == NPCID.GoblinArcher) + { + attackTimeMax = 180; + } + if (npcType == NPCID.IcyMerman) + { + attackTimeMax = 50; + } + if (npcType == NPCID.GreekSkeleton) + { + attackTimeMax = 100; + } + if (npcType == NPCID.PirateDeadeye) + { + attackTimeMax = 40; + } + if (npcType == NPCID.PirateCrossbower) + { + attackTimeMax = 80; + } + if (npcType == NPCID.Paladin) + { + attackTimeMax = 30; + } + if (npcType == NPCID.StardustSoldier) + { + attackTimeMax = 300; + } + if (npcType == NPCID.StardustSpiderBig) + { + attackTimeMax = 60; + } + if (npcType == NPCID.NebulaSoldier) + { + attackTimeMax = 180; + } + if (npcType == NPCID.VortexHornetQueen) + { + attackTimeMax = 60; + } + bool priateCaptainBoost = false; + if (npcType == NPCID.PirateCaptain) + { + if (NPC.localAI[2] >= 20f) + { + priateCaptainBoost = true; + } + if (priateCaptainBoost) + { + attackTimeMax = 60; + } + else + { + attackTimeMax = 8; + } + } + + if (CalamityWorld.revenge) + attackTimeMax = (int)(attackTimeMax * 0.75); + + int modifiedAttackTime = attackTimeMax / 2; + if (npcType == NPCID.NebulaSoldier) + { + modifiedAttackTime = attackTimeMax - 1; + } + if (npcType == NPCID.VortexHornetQueen) + { + modifiedAttackTime = attackTimeMax - 1; + } + if (NPC.ai[2] > 0f) + { + if (canShootAtTarget) + { + NPC.TargetClosest(true); + } + if (NPC.ai[1] == (float)modifiedAttackTime) + { + if (npcType == NPCID.PirateCaptain) + { + NPC.localAI[2] += 1f; + } + float projSpeed = CalamityWorld.death ? 6f : 11f; + if (npcType == NPCID.GoblinArcher) + { + projSpeed = CalamityWorld.death ? 5f : 9f; + } + if (npcType == NPCID.IcyMerman) + { + projSpeed = CalamityWorld.death ? 4f : 7f; + } + if (npcType == NPCID.Paladin) + { + projSpeed = CalamityWorld.death ? 5f : 9f; + } + if (npcType == NPCID.SkeletonCommando) + { + projSpeed = CalamityWorld.death ? 2.5f : 4f; + } + if (npcType == NPCID.PirateDeadeye) + { + projSpeed = CalamityWorld.death ? 8f : 14f; + } + if (npcType == NPCID.PirateCrossbower) + { + projSpeed = CalamityWorld.death ? 9f : 16f; + } + if (npcType == NPCID.RayGunner) + { + projSpeed = CalamityWorld.death ? 4f : 7f; + } + if (npcType == NPCID.MartianWalker) + { + projSpeed = CalamityWorld.death ? 5f : 8f; + } + if (npcType == NPCID.StardustSpiderBig) + { + projSpeed = 4f; + } + if (npcType >= 449 && npcType <= 452) + { + projSpeed = CalamityWorld.death ? 4f : 7f; + } + if (npcType == NPCID.GreekSkeleton) + { + projSpeed = CalamityWorld.death ? 5f : 8f; + } + if (npcType == NPCID.DrManFly) + { + projSpeed = CalamityWorld.death ? 4.5f : 7.5f; + } + if (npcType == NPCID.StardustSoldier) + { + projSpeed = 1f; + } + if (npcType >= 498 && npcType <= 506) + { + projSpeed = CalamityWorld.death ? 4f : 7f; + } + + if (CalamityWorld.revenge) + projSpeed *= 1.25f; + + Vector2 spawnPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + if (npcType == NPCID.GreekSkeleton) + { + spawnPosition.Y -= 14f; + } + if (npcType == NPCID.IcyMerman) + { + spawnPosition.Y -= 10f; + } + if (npcType == NPCID.Paladin) + { + spawnPosition.Y -= 10f; + } + if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) + { + spawnPosition.Y += 6f; + } + if (npcType == NPCID.MartianWalker) + { + spawnPosition.Y = NPC.position.Y + 20f; + } + if (npcType >= 498 && npcType <= 506) + { + spawnPosition.Y -= 8f; + } + if (npcType == NPCID.VortexHornetQueen) + { + spawnPosition += new Vector2((float)(NPC.spriteDirection * 2), -12f); + projSpeed = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 9f : 7f; + } + float distX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - spawnPosition.X; + float projOffset = Math.Abs(distX) * 0.1f; + if (npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton) + { + projOffset = 0f; + } + if (npcType == NPCID.PirateCrossbower) + { + projOffset = Math.Abs(distX) * 0.08f; + } + if (npcType == NPCID.PirateDeadeye || (npcType == NPCID.PirateCaptain && !priateCaptainBoost)) + { + projOffset = 0f; + } + if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker) + { + projOffset = 0f; + } + if (npcType >= 449 && npcType <= 452) + { + projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; + } + if (npcType == NPCID.DrManFly) + { + projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; + } + if (npcType == NPCID.GreekSkeleton) + { + projOffset = Math.Abs(distX) * (float)Main.rand.Next(-10, 11) * 0.0035f; + } + if (npcType >= 498 && npcType <= 506) + { + projOffset = Math.Abs(distX) * (float)Main.rand.Next(1, 11) * 0.0025f; + } + float distY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - spawnPosition.Y - projOffset; + float magnitude = (float)Math.Sqrt((distX * distX + distY * distY)); + NPC.netUpdate = true; + magnitude = projSpeed / magnitude; + distX *= magnitude; + distY *= magnitude; + int damage = 35; + int projectileType = ProjectileID.FlamingArrow; + if (npcType == NPCID.ElfArcher) + { + damage = 45; + } + if (npcType == NPCID.GoblinArcher) + { + projectileType = ProjectileID.WoodenArrowHostile; + damage = 11; + } + if (npcType == NPCID.CultistArcherBlue || npcType == NPCID.CultistArcherWhite) + { + projectileType = ProjectileID.WoodenArrowHostile; + damage = 40; + } + if (npcType == NPCID.BrainScrambler) + { + projectileType = ProjectileID.BrainScramblerBolt; + damage = 24; + } + if (npcType == NPCID.RayGunner) + { + projectileType = ProjectileID.RayGunnerLaser; + damage = 30; + } + if (npcType == NPCID.MartianWalker) + { + projectileType = ProjectileID.MartianWalkerLaser; + damage = 35; + } + if (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) + { + projectileType = ProjectileID.SkeletonBone; + damage = 20; + } + if (npcType >= NPCID.Salamander && npcType <= NPCID.Salamander9) + { + projectileType = ProjectileID.SalamanderSpit; + damage = 14; + } + if (npcType == NPCID.GreekSkeleton) + { + projectileType = ProjectileID.JavelinHostile; + damage = 18; + } + if (npcType == NPCID.IcyMerman) + { + projectileType = ProjectileID.IcewaterSpit; + damage = 37; + } + if (npcType == NPCID.DrManFly) + { + projectileType = ProjectileID.DrManFlyFlask; + damage = 50; + } + if (npcType == NPCID.StardustSoldier) + { + projectileType = ProjectileID.StardustSoldierLaser; + damage = (Main.expertMode ? 45 : 60); + } + if (npcType == NPCID.NebulaSoldier) + { + projectileType = ProjectileID.NebulaBolt; + damage = (Main.expertMode ? 45 : 60); + } + if (npcType == NPCID.VortexHornetQueen) + { + projectileType = ProjectileID.VortexAcid; + damage = (Main.expertMode ? 45 : 60); + } + if (npcType == NPCID.SkeletonSniper) + { + projectileType = ProjectileID.SniperBullet; + damage = 100; + } + if (npcType == NPCID.Paladin) + { + projectileType = ProjectileID.PaladinsHammerHostile; + damage = 60; + } + if (npcType == NPCID.SkeletonCommando) + { + projectileType = ProjectileID.RocketSkeleton; + damage = 60; + } + if (npcType == NPCID.PirateDeadeye) + { + projectileType = ProjectileID.BulletDeadeye; + damage = 25; + } + if (npcType == NPCID.PirateCrossbower) + { + projectileType = ProjectileID.FlamingArrow; + damage = 40; + } + if (npcType == NPCID.TacticalSkeleton) + { + damage = 50; + projectileType = ProjectileID.BulletDeadeye; + } + if (npcType == NPCID.PirateCaptain) + { + projectileType = ProjectileID.BulletDeadeye; + damage = 30; + if (priateCaptainBoost) + { + damage = 100; + projectileType = ProjectileID.CannonballHostile; + NPC.localAI[2] = 0f; + } + } + spawnPosition.X += distX; + spawnPosition.Y += distY; + if (Main.expertMode && npcType == NPCID.Paladin) + { + damage = (int)(damage * 0.75); + } + if (Main.expertMode && npcType >= 381 && npcType <= 392) + { + damage = (int)(damage * 0.8); + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (npcType == NPCID.TacticalSkeleton) + { + Vector2 bulletSpawnPosition = NPC.Center; + for (int num147 = 0; num147 < 4; num147++) + { + distX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - spawnPosition.X; + distY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - spawnPosition.Y; + magnitude = (float)Math.Sqrt((distX * distX + distY * distY)); + magnitude = (CalamityWorld.death ? 8f : CalamityWorld.revenge ? 7f : 6f) / magnitude; + int shotgunSpread = 20; + distX += (float)Main.rand.Next(-shotgunSpread, shotgunSpread + 1); + distY += (float)Main.rand.Next(-shotgunSpread, shotgunSpread + 1); + distX *= magnitude; + distY *= magnitude; + Vector2 bulletVelocity = new Vector2(distX, distY); + Projectile.NewProjectile(NPC.GetSource_FromAI(), bulletSpawnPosition + bulletVelocity.SafeNormalize(-Vector2.UnitY) * 30f, bulletVelocity, projectileType, damage, 0f, Main.myPlayer); + } + } + else if (npcType == NPCID.StardustSoldier) + { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, distX, distY, projectileType, damage, 0f, Main.myPlayer, 0f, (float)NPC.whoAmI); + if (CalamityWorld.death) + { + Main.projectile[proj].extraUpdates += 1; + Main.projectile[proj].timeLeft = 480; + } + } + else if (npcType == NPCID.NebulaSoldier) + { + for (int i = 0; i < 4; i++) + { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X - (float)(NPC.spriteDirection * 4), NPC.Center.Y + 6f, (float)(-3 + 2 * i) * 0.15f, (float)(-(float)Main.rand.Next(0, 3)) * 0.2f - 0.1f, projectileType, damage, 0f, Main.myPlayer, 0f, (float)NPC.whoAmI); + if (CalamityWorld.death) + { + Main.projectile[proj].extraUpdates += 1; + Main.projectile[proj].timeLeft = 1200; + } + } + } + else if (npcType == NPCID.StardustSpiderBig) + { + int idx = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.StardustSpiderSmall, NPC.whoAmI); + Main.npc[idx].velocity = new Vector2(distX, -6f + distY); + } + else + { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, distX, distY, projectileType, damage, 0f, Main.myPlayer); + if (CalamityWorld.death) + { + Main.projectile[proj].extraUpdates += 1; + Main.projectile[proj].timeLeft = 1200; + } + } + } + if (Math.Abs(distY) > Math.Abs(distX) * 2f) + { + if (distY > 0f) + { + NPC.ai[2] = 1f; + } + else + { + NPC.ai[2] = 5f; + } + } + else if (Math.Abs(distX) > Math.Abs(distY) * 2f) + { + NPC.ai[2] = 3f; + } + else if (distY > 0f) + { + NPC.ai[2] = 2f; + } + else + { + NPC.ai[2] = 4f; + } + } + if ((NPC.velocity.Y != 0f && !isAlienQueen) || NPC.ai[1] <= 0f) + { + NPC.ai[2] = 0f; + NPC.ai[1] = 0f; + } + else if (!npcAllowedToShoot || (stardustGateValue != -1 && NPC.ai[1] >= (float)stardustGateValue && NPC.ai[1] < (float)(stardustGateValue + stardustGateValueAdd) && (!isAlienQueen || NPC.velocity.Y == 0f))) + { + NPC.velocity.X *= 0.9f; + NPC.spriteDirection = NPC.direction; + } + } + + if (npcType == NPCID.DrManFly && !Main.eclipse) + { + npcAllowedToShoot = true; + } + else if ((NPC.ai[2] <= 0f | npcAllowedToShoot) && (NPC.velocity.Y == 0f | isAlienQueen) && NPC.ai[1] <= 0f && !Main.player[NPC.target].dead) + { + bool canAttack = Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + if (npcType == NPCID.MartianWalker) + { + canAttack = Collision.CanHitLine(NPC.Top + new Vector2(0f, 20f), 0, 0, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + } + if (Main.player[NPC.target].stealth == 0f && Main.player[NPC.target].itemAnimation == 0) + { + canAttack = false; + } + if (canAttack) + { + Vector2 projSpawnPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float distX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - projSpawnPosition.X; + float distXAbsolute = Math.Abs(distX) * 0.1f; + float distY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - projSpawnPosition.Y - distXAbsolute; + distX += (float)Main.rand.Next(-40, 41); + distY += (float)Main.rand.Next(-40, 41); + float playerDistance = (float)Math.Sqrt(distX * distX + distY * distY); + float maxAttackDistance = 700f; + if (npcType == NPCID.PirateDeadeye) + { + maxAttackDistance = 550f; + } + if (npcType == NPCID.PirateCrossbower) + { + maxAttackDistance = 800f; + } + if (npcType >= NPCID.Salamander && npcType <= NPCID.Salamander9) + { + maxAttackDistance = 190f; + } + if (npcType >= NPCID.BoneThrowingSkeleton && npcType <= NPCID.BoneThrowingSkeleton4) + { + maxAttackDistance = 200f; + } + if (npcType == NPCID.GreekSkeleton) + { + maxAttackDistance = 400f; + } + if (npcType == NPCID.DrManFly) + { + maxAttackDistance = 400f; + } + if (CalamityWorld.death) + { + maxAttackDistance *= 1.25f; + } + if (playerDistance < maxAttackDistance) + { + NPC.netUpdate = true; + NPC.velocity.X *= 0.5f; + playerDistance = 10f / playerDistance; + distX *= playerDistance; + distY *= playerDistance; + NPC.ai[2] = 3f; + NPC.ai[1] = (float)attackTimeMax; + if (Math.Abs(distY) > Math.Abs(distX) * 2f) + { + if (distY > 0f) + { + NPC.ai[2] = 1f; + } + else + { + NPC.ai[2] = 5f; + } + } + else if (Math.Abs(distX) > Math.Abs(distY) * 2f) + { + NPC.ai[2] = 3f; + } + else if (distY > 0f) + { + NPC.ai[2] = 2f; + } + else + { + NPC.ai[2] = 4f; + } + } + } + } + + if (NPC.ai[2] <= 0f || (npcAllowedToShoot && (stardustGateValue == -1 || NPC.ai[1] < (float)stardustGateValue || NPC.ai[1] >= (float)(stardustGateValue + stardustGateValueAdd)))) + { + float maxVelocity = 1f; + float acceleration = 0.07f; + float decelerationFactor = 0.8f; + if (npcType == NPCID.PirateDeadeye) + { + maxVelocity = 2f; + acceleration = 0.09f; + } + else if (npcType == NPCID.PirateCrossbower) + { + maxVelocity = 1.5f; + acceleration = 0.08f; + } + else if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) + { + maxVelocity = 2f; + acceleration = 0.5f; + } + else if (npcType == NPCID.MartianWalker) + { + maxVelocity = 4f; + acceleration = 1f; + decelerationFactor = 0.7f; + } + else if (npcType == NPCID.StardustSoldier) + { + maxVelocity = 2f; + acceleration = 0.5f; + } + else if (npcType == NPCID.StardustSpiderBig) + { + maxVelocity = 2f; + acceleration = 0.5f; + } + else if (NPC.type == NPCID.VortexHornetQueen) + { + maxVelocity = 4f; + acceleration = 0.6f; + decelerationFactor = 0.95f; + } + if (CalamityWorld.revenge) + { + maxVelocity *= 1.5f; + acceleration *= 1.5f; + } + bool forceDeceleration = false; + if ((npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner) && Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) < 300f && Collision.CanHitLine(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0)) + { + forceDeceleration = true; + NPC.ai[3] = 0f; + } + if (npcType == NPCID.MartianWalker && Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) < 400f && Collision.CanHitLine(NPC.Center, 0, 0, Main.player[NPC.target].Center, 0, 0)) + { + forceDeceleration = true; + NPC.ai[3] = 0f; + } + // The extra OR conditional is the reason the special method I created above isn't used. + // It has enough parameters. Another one for 1 specific purpose isn't worth it anymore + if ((NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) | forceDeceleration) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity *= decelerationFactor; + } + } + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) + { + NPC.velocity.X += acceleration; + if (NPC.velocity.X > maxVelocity) + { + NPC.velocity.X = maxVelocity; + } + } + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) + { + NPC.velocity.X -= acceleration; + if (NPC.velocity.X < -maxVelocity) + { + NPC.velocity.X = -maxVelocity; + } + } + } + + if (npcType == NPCID.MartianWalker) + { + NPC.localAI[2] += 1f; + if (NPC.localAI[2] >= 6f) + { + NPC.localAI[2] = 0f; + NPC.localAI[3] = Main.player[NPC.target].DirectionFrom(NPC.Top + new Vector2(0f, 20f)).ToRotation(); + } + } + } + } + + if (npcType == NPCID.Clown && Main.netMode != NetmodeID.MultiplayerClient && !Main.player[NPC.target].dead) + { + if (NPC.justHit) + NPC.ai[2] = 0f; + + NPC.ai[2] += 1f; + float bombDelay = CalamityWorld.death ? 60f : 180f; + if (NPC.ai[2] > bombDelay) + { + Vector2 spawnPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f - (float)(NPC.direction * 24), NPC.position.Y + 4f); + if (!Main.rand.NextBool(5) || NPC.AnyNPCs(NPCID.ChatteringTeethBomb)) + { + int velocityX = 3 * NPC.direction; + int velocityY = -5; + int clownBomb = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, velocityX, velocityY, ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[clownBomb].timeLeft = 300; + if (CalamityWorld.death) + { + Main.projectile[clownBomb].extraUpdates += 1; + Main.projectile[clownBomb].timeLeft = 600; + } + NPC.ai[2] = 0f; + } + else + { + NPC.ai[2] = -bombDelay * 2; + int chatteringTeethBomb = NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnPosition.X, (int)spawnPosition.Y, NPCID.ChatteringTeethBomb); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, chatteringTeethBomb, 0f, 0f, 0f, 0, 0, 0); + } + } + } + + bool canOpenDoors = false; + if (NPC.velocity.Y == 0f) + { + int j = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; + int npcLeft = (int)NPC.position.X / 16; + int npcRight = (int)(NPC.position.X + (float)NPC.width) / 16; + for (int i = npcLeft; i <= npcRight; i++) + { + if (Main.tile[i, j].HasUnactuatedTile && Main.tileSolid[Main.tile[i, j].TileType]) + { + canOpenDoors = true; + break; + } + } + } + + if (npcType == NPCID.VortexLarva) + { + canOpenDoors = false; + } + + if (NPC.velocity.Y >= 0f) + { + int velocitySign = 0; + if (NPC.velocity.X < 0f) + { + velocitySign = -1; + } + if (NPC.velocity.X > 0f) + { + velocitySign = 1; + } + Vector2 positionDelta = NPC.position; + positionDelta.X += NPC.velocity.X; + int x = (int)((positionDelta.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * velocitySign)) / 16f); + int y = (int)((positionDelta.Y + (float)NPC.height - 1f) / 16f); + if (x * 16 < positionDelta.X + (float)NPC.width && + (x + 1) * 16 > positionDelta.X && ((Main.tile[x, y].HasUnactuatedTile && + !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && + Main.tileSolid[(int)Main.tile[x, y].TileType] && + !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || + (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && + (!Main.tile[x, y - 1].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || + Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || + (Main.tile[x, y - 1].IsHalfBlock && + (!Main.tile[x, y - 4].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || + Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && + (!Main.tile[x, y - 2].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || + Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && + (!Main.tile[x, y - 3].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || + Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && + (!Main.tile[x - velocitySign, y - 3].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x - velocitySign, y - 3].TileType])) + { + float yAdjust = y * 16f; + if (Main.tile[x, y].IsHalfBlock) + { + yAdjust += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + yAdjust -= 8f; + } + if (yAdjust < positionDelta.Y + (float)NPC.height) + { + float gfxOffRelativeToDelta = positionDelta.Y + (float)NPC.height - yAdjust; + float yOffsetFloor = 16.1f; + if (npcType == NPCID.BlackRecluse || npcType == NPCID.WallCreeper || npcType == NPCID.JungleCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.DesertScorpionWalk) + { + yOffsetFloor += 8f; + } + if (gfxOffRelativeToDelta <= yOffsetFloor) + { + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - yAdjust; + NPC.position.Y = yAdjust - (float)NPC.height; + if (gfxOffRelativeToDelta < 9f) + { + NPC.stepSpeed = 1f; + } + else + { + NPC.stepSpeed = 2f; + } + } + } + } + } + + if (canOpenDoors) + { + int x = (int)((NPC.Center.X + (float)(15 * NPC.direction)) / 16f); + int y = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); + if (npcType == NPCID.Clown || npcType == NPCID.BlackRecluse || npcType == NPCID.WallCreeper || npcType == NPCID.LihzahrdCrawler || npcType == NPCID.JungleCreeper || npcType == NPCID.BloodCrawler || npcType == NPCID.AnomuraFungus || npcType == NPCID.MushiLadybug || npcType == NPCID.Paladin || npcType == NPCID.Scutlix || npcType == NPCID.VortexRifleman || npcType == NPCID.VortexHornet || npcType == NPCID.VortexHornetQueen || npcType == NPCID.WalkingAntlion || npcType == NPCID.SolarDrakomire || npcType == NPCID.DesertScorpionWalk || npcType == NPCID.DesertBeast) + { + x = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 16) * NPC.direction)) / 16f); + } + if ((Main.tile[x, y - 1].HasUnactuatedTile && + (Main.tile[x, y - 1].TileType == TileID.ClosedDoor || + Main.tile[x, y - 1].TileType == TileID.TallGateClosed)) & reset) + { + NPC.ai[2] += 1f; + NPC.ai[3] = 0f; + if (NPC.ai[2] >= 60f) + { + NPC.velocity.X = -0.5f * NPC.direction; + int timerIncrement = 5; + if (Main.tile[x, y - 1].TileType == TileID.TallGateClosed) + { + timerIncrement = 2; + } + NPC.ai[1] += timerIncrement; + // Special increments + if (npcType == NPCID.GoblinThief) + { + NPC.ai[1] += 1f; + } + if (npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet) + { + NPC.ai[1] += 6f; + } + NPC.ai[2] = 0f; + bool readyToOpenDoor = false; + if (NPC.ai[1] >= 10f) + { + readyToOpenDoor = true; + NPC.ai[1] = 10f; + } + if (npcType == NPCID.Butcher) + { + readyToOpenDoor = true; + } + WorldGen.KillTile(x, y - 1, true, false, false); + if ((Main.netMode != NetmodeID.MultiplayerClient || !readyToOpenDoor) && readyToOpenDoor && Main.netMode != NetmodeID.MultiplayerClient) + { + if (npcType == NPCID.GoblinPeon) + { + WorldGen.KillTile(x, y - 1, false, false, false); + if (Main.dedServ) + { + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)x, (float)(y - 1), 0f, 0, 0, 0); + } + } + else + { + if (Main.tile[x, y - 1].TileType == TileID.ClosedDoor) + { + bool canOpenDoor = WorldGen.OpenDoor(x, y - 1, NPC.direction); + if (!canOpenDoor) + { + NPC.ai[3] = (float)aiGateValue; + NPC.netUpdate = true; + } + if (Main.dedServ & canOpenDoor) + { + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)x, (float)(y - 1), (float)NPC.direction, 0, 0, 0); + } + } + if (Main.tile[x, y - 1].TileType == TileID.TallGateClosed) + { + bool canOpenTallGate = WorldGen.ShiftTallGate(x, y - 1, false); + if (!canOpenTallGate) + { + NPC.ai[3] = (float)aiGateValue; + NPC.netUpdate = true; + } + if (Main.dedServ & canOpenTallGate) + { + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)x, (float)(y - 1), 0f, 0, 0, 0); + } + } + } + } + } + } + else + { + int alteredDirection = NPC.spriteDirection; + if (npcType == NPCID.VortexRifleman) + { + alteredDirection *= -1; + } + if ((NPC.velocity.X < 0f && alteredDirection == -1) || (NPC.velocity.X > 0f && alteredDirection == 1)) + { + if (NPC.height >= 32 && Main.tile[x, y - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y - 2].TileType]) + { + if (Main.tile[x, y - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y - 3].TileType]) + { + NPC.velocity.Y = -9f; + NPC.netUpdate = true; + } + else + { + NPC.velocity.Y = -8f; + NPC.netUpdate = true; + } + } + else if (Main.tile[x, y - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y - 1].TileType]) + { + NPC.velocity.Y = -7f; + NPC.netUpdate = true; + } + else if (NPC.position.Y + (float)NPC.height - (float)(y * 16) > 20f && Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType]) + { + NPC.velocity.Y = -6f; + NPC.netUpdate = true; + } + else if (NPC.directionY < 0 && npcType != 67 && (!Main.tile[x, y + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y + 1].TileType]) && (!Main.tile[x + NPC.direction, y + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x + NPC.direction, y + 1].TileType])) + { + NPC.velocity.Y = -9f; + NPC.velocity.X *= 2f; + NPC.netUpdate = true; + } + else if (reset) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + if ((NPC.velocity.Y == 0f & jump) && NPC.ai[3] == 1f) + { + NPC.velocity.Y = -6f; + } + } + if ((npcType == NPCID.AngryBones || npcType == NPCID.AngryBonesBig || npcType == NPCID.AngryBonesBigMuscle || npcType == NPCID.AngryBonesBigHelmet || npcType == NPCID.CorruptBunny || npcType == NPCID.ArmoredSkeleton || npcType == NPCID.Werewolf || npcType == NPCID.CorruptPenguin || npcType == NPCID.Nymph || npcType == NPCID.GrayGrunt || npcType == NPCID.GigaZapper || npcType == NPCID.CrimsonBunny || npcType == NPCID.CrimsonPenguin || (npcType >= 524 && npcType <= 527)) && NPC.velocity.Y == 0f && Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))) < 100f && Math.Abs(NPC.position.Y + (float)(NPC.height / 2) - (Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2))) < 50f && ((NPC.direction > 0 && NPC.velocity.X >= 1f) || (NPC.direction < 0 && NPC.velocity.X <= -1f))) + { + NPC.velocity.X *= 3f; + if (NPC.velocity.X > 4f) + { + NPC.velocity.X = 4f; + } + if (NPC.velocity.X < -4f) + { + NPC.velocity.X = -4f; + } + NPC.velocity.Y = -5f; + NPC.netUpdate = true; + } + if ((npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType()) && NPC.velocity.Y < 0f) + { + NPC.velocity.Y *= 1.1f; + } + if (npcType == NPCID.BoneLee && NPC.velocity.Y == 0f && Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 150f && Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) < 50f && ((NPC.direction > 0 && NPC.velocity.X >= 1f) || (NPC.direction < 0 && NPC.velocity.X <= -1f))) + { + NPC.velocity.X = (float)((CalamityWorld.death ? 9 : CalamityWorld.revenge ? 8 : 7) * NPC.direction); + NPC.velocity.Y = -(CalamityWorld.death ? 4f : CalamityWorld.revenge ? 3.5f : 3f); + NPC.netUpdate = true; + } + if (npcType == NPCID.BoneLee && NPC.velocity.Y < 0f) + { + NPC.velocity.X *= CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1.15f : 1.1f; + NPC.velocity.Y *= CalamityWorld.death ? 1.1f : CalamityWorld.revenge ? 1.075f : 1.05f; + } + if (npcType == NPCID.Butcher && NPC.velocity.Y < 0f) + { + NPC.velocity.X *= 1.35f; + NPC.velocity.Y *= 1.15f; + } + } + } + else if (reset) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + + // Teleport (Chaos elementals) + if (Main.netMode != NetmodeID.MultiplayerClient && (npcType == NPCID.ChaosElemental || npcType == ModContent.NPCType()) && NPC.ai[3] >= (float)aiGateValue) + { + int targetTileX = (int)Main.player[NPC.target].Center.X / 16; + int targetTileY = (int)Main.player[NPC.target].Center.Y / 16; + Vector2 chosenTile = Vector2.Zero; + if (NPC.AI_AttemptToFindTeleportSpot(ref chosenTile, targetTileX, targetTileY, 20, 9)) + { + NPC.position.X = chosenTile.X * 16f - (float)(NPC.width / 2); + NPC.position.Y = chosenTile.Y * 16f - (float)NPC.height; + NPC.ai[3] = -30f; + NPC.netUpdate = true; + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs new file mode 100644 index 0000000000..6ae95decd4 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs @@ -0,0 +1,60 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class FlowInvaderAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + float velocityMult = CalamityWorld.death ? 8f : 6.5f; + float moveSpeed = CalamityWorld.death ? 0.25f : 0.2f; + NPC.TargetClosest(); + Vector2 desiredVelocity3 = Main.player[NPC.target].Center - NPC.Center + new Vector2(0f, -300f); + float velocityCheck = desiredVelocity3.Length(); + if (velocityCheck < 20f) + { + desiredVelocity3 = NPC.velocity; + } + else if (velocityCheck < 40f) + { + desiredVelocity3.Normalize(); + desiredVelocity3 *= velocityMult * 0.35f; + } + else if (velocityCheck < 80f) + { + desiredVelocity3.Normalize(); + desiredVelocity3 *= velocityMult * 0.65f; + } + else + { + desiredVelocity3.Normalize(); + desiredVelocity3 *= velocityMult; + } + + NPC.SimpleFlyMovement(desiredVelocity3, moveSpeed); + NPC.rotation = NPC.velocity.X * 0.1f; + if (!((NPC.ai[0] += 1f) >= (CalamityWorld.death ? 30f : 50f))) + return false; + + NPC.ai[0] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 projDirection = Vector2.Zero; + while (Math.Abs(projDirection.X) < 1.5f) + projDirection = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * new Vector2(5f, 3f); + + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projDirection, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, NPC.whoAmI); + Main.projectile[proj].extraUpdates += 1; + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs new file mode 100644 index 0000000000..1c582877aa --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs @@ -0,0 +1,717 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class FlyingAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.target < 0 || NPC.target <= Main.maxPlayers || Main.player[NPC.target].dead) + NPC.TargetClosest(); + + if (NPC.type == NPCID.BloodSquid) + { + if (Main.dayTime) + { + NPC.velocity.Y -= 0.3f; + NPC.EncourageDespawn(60); + } + + NPC.position += NPC.netOffset; + if (NPC.alpha == 255) + { + NPC.spriteDirection = NPC.direction; + NPC.velocity.Y = -6f; + for (int i = 0; i < 35; i++) + { + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Blood); + dust.velocity *= 1f; + dust.scale = 1f + Main.rand.NextFloat() * 0.5f; + dust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + dust.velocity += NPC.velocity * 0.5f; + } + } + + NPC.alpha -= 15; + if (NPC.alpha < 0) + NPC.alpha = 0; + + if (NPC.alpha != 0) + { + for (int j = 0; j < 2; j++) + { + Dust eyeFishDust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Blood); + eyeFishDust.velocity *= 1f; + eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.velocity += NPC.velocity * 0.3f; + } + } + + NPC.position -= NPC.netOffset; + } + + NPCAimedTarget targetData = NPC.GetTargetData(); + bool targetDead = false; + if (targetData.Type == NPCTargetType.Player) + targetDead = Main.player[NPC.target].dead; + + bool queenBeeHornet = NPC.type == NPCID.HornetHoney && NPC.ai[3] == 1f; + if (queenBeeHornet) + { + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + if (NPC.localAI[1] != 0f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.localAI[1] = 0f; + NPC.localAI[2] = 0f; + NPC.SyncVanillaLocalAI(); + } + } + else if (NPC.localAI[1] == 0f) + NPC.localAI[2]++; + + if (NPC.localAI[2] >= (CalamityWorld.death ? 60f : 120f)) + { + NPC.localAI[1] = 1f; + NPC.localAI[2] = 0f; + NPC.SyncVanillaLocalAI(); + } + + if (NPC.localAI[1] == 0f) + { + NPC.alpha = 0; + NPC.noTileCollide = false; + } + else + { + NPC.wet = false; + NPC.alpha = 200; + NPC.noTileCollide = true; + } + } + + bool deathModeVelocityBuff = true; + float maxVelocity = 6f; + float acceleration = 0.05f; + if (NPC.type == NPCID.EaterofSouls || NPC.type == NPCID.Crimera) + { + maxVelocity = 4f; + acceleration = 0.035f; + } + else if (NPC.type == NPCID.Corruptor) + { + maxVelocity = 4.2f; + acceleration = 0.022f; + } + else if (NPC.type == NPCID.BloodSquid) + { + maxVelocity = 6f; + acceleration = 0.1f; + } + else if (NPC.type == NPCID.Hornet || (NPC.type >= NPCID.HornetFatty && NPC.type <= NPCID.HornetStingy)) + { + maxVelocity = 3.5f; + acceleration = 0.021f; + if (NPC.type == NPCID.HornetFatty) + { + maxVelocity = 3f; + acceleration = 0.017f; + } + + maxVelocity *= 1f - NPC.scale; + acceleration *= 1f - NPC.scale; + + // Despawn + if ((double)(NPC.position.Y / 16f) < Main.worldSurface && !queenBeeHornet) + { + if (Main.player[NPC.target].position.Y - NPC.position.Y > 300f && NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.97f; + + if (Main.player[NPC.target].position.Y - NPC.position.Y < 80f && NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.97f; + } + + // Master Mode Queen Bee Hornets + if (queenBeeHornet) + { + maxVelocity *= 1.4f; + acceleration *= 1.8f; + maxVelocity += NPC.ai[2] * 1.5f; + acceleration += NPC.ai[2] * 0.01f; + } + } + else if (NPC.type == NPCID.MossHornet) + { + maxVelocity = 4f; + acceleration = 0.017f; + } + else if (NPC.type == NPCID.Parrot) + { + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + maxVelocity = 6f; + acceleration = 0.1f; + } + else + { + acceleration = 0.01f; + maxVelocity = 2f; + } + } + else if (NPC.type == NPCID.Moth) + { + maxVelocity = 7f; + acceleration = 0.06f; + } + else if (NPC.type == NPCID.MeteorHead) + { + maxVelocity = 2f; + acceleration = 0.05f; + } + else if (NPC.type == NPCID.ServantofCthulhu) + { + maxVelocity = 5f + NPC.ai[2] * 2f; + acceleration = 0.03f + NPC.ai[2] * 0.03f; + } + else if (NPC.type == NPCID.Bee || NPC.type == NPCID.BeeSmall) + { + bool notQueenBeeBee = NPC.ai[3] == 0f; + if (notQueenBeeBee) + { + NPC.ai[1] += 1f; + float originalFlyAwayTime = 60f; + float flyAwayTime = CalamityWorld.death ? 30f : 40f; + float originalFlyAwayVelocity = 6f; + float flyAwayDistance = originalFlyAwayTime * originalFlyAwayVelocity; + float flyAwayVelocity = flyAwayDistance / flyAwayTime; + float flyAwayAccel = (NPC.ai[1] - flyAwayTime) / flyAwayTime; + if (flyAwayAccel > 1f) + { + flyAwayAccel = 1f; + } + else + { + if (NPC.velocity.X > flyAwayVelocity) + NPC.velocity.X = flyAwayVelocity; + + if (NPC.velocity.X < -flyAwayVelocity) + NPC.velocity.X = -flyAwayVelocity; + + if (NPC.velocity.Y > flyAwayVelocity) + NPC.velocity.Y = flyAwayVelocity; + + if (NPC.velocity.Y < -flyAwayVelocity) + NPC.velocity.Y = -flyAwayVelocity; + } + + maxVelocity = 5f; + acceleration = 0.1f * flyAwayAccel; + } + else + { + deathModeVelocityBuff = false; + maxVelocity = 5f + NPC.ai[2] * 2f; + acceleration = 0.1f + NPC.ai[2] * 0.04f; + } + } + + if (CalamityWorld.revenge) + { + maxVelocity *= 1.25f; + acceleration *= 1.25f; + } + + if (CalamityWorld.death && deathModeVelocityBuff) + { + maxVelocity *= 1.25f; + acceleration *= 1.25f; + } + + if (queenBeeHornet) + { + float deceleration = 1f - acceleration; + if (targetDead) + { + Vector2 destination = NPC.Center - Vector2.UnitY; + Vector2 idealVelocity = NPC.SafeDirectionTo(destination) * maxVelocity * 0.5f; + idealVelocity.X *= NPC.direction; + idealVelocity.Y *= 2.5f; + NPC.SimpleFlyMovement(idealVelocity, acceleration); + NPC.EncourageDespawn(10); + NPC.wet = false; + NPC.noTileCollide = true; + } + else if (NPC.Distance(targetData.Center) > 400f) + { + Vector2 idealVelocity = NPC.SafeDirectionTo(targetData.Center) * maxVelocity; + NPC.SimpleFlyMovement(idealVelocity, acceleration); + } + else + { + if (NPC.Distance(targetData.Center) < 160f) + { + Vector2 idealVelocity = NPC.SafeDirectionTo(targetData.Center) * maxVelocity; + NPC.SimpleFlyMovement(-idealVelocity, acceleration); + } + else + NPC.velocity *= deceleration; + } + + if (targetData.Center.X - NPC.Center.X > 0f) + NPC.spriteDirection = 1; + else + NPC.spriteDirection = -1; + + NPC.rotation = NPC.velocity.X * 0.1f; + + float reboundSpeed = 0.7f; + if (NPC.collideX) + { + NPC.netUpdate = true; + NPC.velocity.X = NPC.oldVelocity.X * -reboundSpeed; + if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) + NPC.velocity.X = 2f; + if (NPC.direction == 1 && NPC.velocity.X < 0f && NPC.velocity.X > -2f) + NPC.velocity.X = -2f; + } + + if (NPC.collideY) + { + NPC.netUpdate = true; + NPC.velocity.Y = NPC.oldVelocity.Y * -reboundSpeed; + if (NPC.velocity.Y > 0f && (double)NPC.velocity.Y < 1.5) + NPC.velocity.Y = 2f; + if (NPC.velocity.Y < 0f && (double)NPC.velocity.Y > -1.5) + NPC.velocity.Y = -2f; + } + } + else + { + Vector2 vector = NPC.Center; + float targetXDist = Main.player[NPC.target].Center.X; + float targetYDist = Main.player[NPC.target].Center.Y; + targetXDist = (float)((int)(targetXDist / 8f) * 8); + targetYDist = (float)((int)(targetYDist / 8f) * 8); + vector.X = (float)((int)(vector.X / 8f) * 8); + vector.Y = (float)((int)(vector.Y / 8f) * 8); + targetXDist -= vector.X; + targetYDist -= vector.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float targetDistCheck = targetDistance; + + if (targetDistance == 0f) + { + targetXDist = NPC.velocity.X; + targetYDist = NPC.velocity.Y; + } + else + { + targetDistance = maxVelocity / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + } + + if (NPC.type == NPCID.Hornet || NPC.type == NPCID.MossHornet || (NPC.type >= NPCID.HornetFatty && NPC.type <= NPCID.HornetStingy) || NPC.type == NPCID.EaterofSouls || NPC.type == NPCID.Corruptor || NPC.type == NPCID.Crimera || NPC.type == NPCID.Moth || NPC.type == NPCID.Bee || NPC.type == NPCID.BeeSmall || NPC.type == NPCID.BloodSquid) + { + if (targetDistCheck > 100f || NPC.type == NPCID.Corruptor || NPC.type == NPCID.Bee || NPC.type == NPCID.BeeSmall || NPC.type == NPCID.BloodSquid || NPC.type == NPCID.Hornet || NPC.type == NPCID.MossHornet || (NPC.type >= NPCID.HornetFatty && NPC.type <= NPCID.HornetStingy)) + { + NPC.ai[0] += 1f; + if (NPC.ai[0] > 0f) + NPC.velocity.Y += CalamityWorld.revenge ? 0.03f : 0.023f; + else + NPC.velocity.Y -= CalamityWorld.revenge ? 0.03f : 0.023f; + + if (NPC.ai[0] < -100f || NPC.ai[0] > 100f) + NPC.velocity.X += CalamityWorld.revenge ? 0.03f : 0.023f; + else + NPC.velocity.X -= CalamityWorld.revenge ? 0.03f : 0.023f; + + if (NPC.ai[0] > 200f) + NPC.ai[0] = -200f; + } + + if (targetDistCheck < 150f && (NPC.type == NPCID.EaterofSouls || NPC.type == NPCID.Corruptor || NPC.type == NPCID.Crimera || NPC.type == NPCID.BloodSquid)) + { + NPC.velocity.X += targetXDist * (CalamityWorld.revenge ? 0.009f : 0.007f); + NPC.velocity.Y += targetYDist * (CalamityWorld.revenge ? 0.009f : 0.007f); + } + + // Master Mode Queen Bee Bees + if (NPC.type == NPCID.Bee || NPC.type == NPCID.BeeSmall) + { + if (NPC.ai[3] == 1f) + { + float pushVelocity = 0.5f + NPC.ai[2] * 0.2f; + 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) < 32f * 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; + } + } + } + } + } + } + } + + if (targetDead) + { + targetXDist = (float)NPC.direction * maxVelocity / 2f; + targetYDist = -maxVelocity / 2f; + } + + if (NPC.velocity.X < targetXDist) + { + NPC.velocity.X += acceleration; + if (NPC.type != NPCID.Crimera && NPC.type != NPCID.EaterofSouls && NPC.type != NPCID.Corruptor && NPC.type != NPCID.BloodSquid && NPC.velocity.X < 0f && targetXDist > 0f) + NPC.velocity.X += acceleration; + } + else if (NPC.velocity.X > targetXDist) + { + NPC.velocity.X -= acceleration; + if (NPC.type != NPCID.Crimera && NPC.type != NPCID.EaterofSouls && NPC.type != NPCID.Corruptor && NPC.type != NPCID.BloodSquid && NPC.velocity.X > 0f && targetXDist < 0f) + NPC.velocity.X -= acceleration; + } + + if (NPC.velocity.Y < targetYDist) + { + NPC.velocity.Y += acceleration; + if (NPC.type != NPCID.Crimera && NPC.type != NPCID.EaterofSouls && NPC.type != NPCID.Corruptor && NPC.type != NPCID.BloodSquid && NPC.velocity.Y < 0f && targetYDist > 0f) + NPC.velocity.Y += acceleration; + } + else if (NPC.velocity.Y > targetYDist) + { + NPC.velocity.Y -= acceleration; + if (NPC.type != NPCID.Crimera && NPC.type != NPCID.EaterofSouls && NPC.type != NPCID.Corruptor && NPC.type != NPCID.BloodSquid && NPC.velocity.Y > 0f && targetYDist < 0f) + NPC.velocity.Y -= acceleration; + } + + if (NPC.type == NPCID.ServantofCthulhu) + { + float pushVelocity = 0.5f + NPC.ai[2] * 0.25f; + 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; + } + } + } + } + } + + if (NPC.type == NPCID.MeteorHead) + { + if (targetXDist > 0f) + { + NPC.spriteDirection = 1; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); + } + else if (targetXDist < 0f) + { + NPC.spriteDirection = -1; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + MathHelper.Pi; + } + } + else if (NPC.type == NPCID.EaterofSouls || NPC.type == NPCID.Corruptor || NPC.type == NPCID.Crimera || NPC.type == NPCID.BloodSquid) + { + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) - MathHelper.PiOver2; + } + else if (NPC.type == NPCID.Moth || NPC.type == NPCID.Hornet || NPC.type == NPCID.MossHornet || (NPC.type >= NPCID.HornetFatty && NPC.type <= NPCID.HornetStingy)) + { + if (NPC.velocity.X > 0f) + NPC.spriteDirection = 1; + if (NPC.velocity.X < 0f) + NPC.spriteDirection = -1; + + NPC.rotation = NPC.velocity.X * 0.1f; + } + else + NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) - MathHelper.PiOver2; + + if (NPC.type == NPCID.Hornet || NPC.type == NPCID.MossHornet || (NPC.type >= NPCID.HornetFatty && NPC.type <= NPCID.HornetStingy) || NPC.type == NPCID.EaterofSouls || NPC.type == NPCID.MeteorHead || NPC.type == NPCID.Corruptor || NPC.type == NPCID.Crimera || NPC.type == NPCID.Moth || NPC.type == NPCID.Bee || NPC.type == NPCID.BeeSmall || NPC.type == NPCID.BloodSquid) + { + float reboundSpeed = 0.7f; + if (NPC.type == NPCID.EaterofSouls || NPC.type == NPCID.Crimera) + reboundSpeed = 0.4f; + + if (NPC.collideX) + { + NPC.netUpdate = true; + NPC.velocity.X = NPC.oldVelocity.X * -reboundSpeed; + if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) + NPC.velocity.X = 2f; + if (NPC.direction == 1 && NPC.velocity.X < 0f && NPC.velocity.X > -2f) + NPC.velocity.X = -2f; + } + + if (NPC.collideY) + { + NPC.netUpdate = true; + NPC.velocity.Y = NPC.oldVelocity.Y * -reboundSpeed; + if (NPC.velocity.Y > 0f && (double)NPC.velocity.Y < 1.5) + NPC.velocity.Y = 2f; + if (NPC.velocity.Y < 0f && (double)NPC.velocity.Y > -1.5) + NPC.velocity.Y = -2f; + } + + if (NPC.type == NPCID.BloodSquid) + { + int bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100); + Main.dust[bloodDust].velocity *= 0.5f; + } + else if (NPC.type == NPCID.MeteorHead) + { + int meteorDust = Dust.NewDust(new Vector2(NPC.position.X - NPC.velocity.X, NPC.position.Y - NPC.velocity.Y), NPC.width, NPC.height, DustID.Torch, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default(Color), 2f); + Dust dust = Main.dust[meteorDust]; + dust.noGravity = true; + dust.velocity.X *= 0.3f; + dust.velocity.Y *= 0.3f; + } + else if (NPC.type != NPCID.Moth && NPC.type != NPCID.Parrot && NPC.type != NPCID.Bee && NPC.type != NPCID.BeeSmall && Main.rand.NextBool(20)) + { + int dustType = 18; + if (NPC.type == NPCID.Crimera) + dustType = 5; + + int idleDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + (float)NPC.height * 0.25f), NPC.width, (int)((float)NPC.height * 0.5f), dustType, NPC.velocity.X, 2f, 75, NPC.color, NPC.scale); + Dust dust = Main.dust[idleDust]; + dust.velocity.X *= 0.5f; + dust.velocity.Y *= 0.1f; + } + } + else if (NPC.type != NPCID.Parrot && Main.rand.NextBool(40)) + { + int otherIdleDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y + (float)NPC.height * 0.25f), NPC.width, (int)((float)NPC.height * 0.5f), DustID.Blood, NPC.velocity.X, 2f, 0, default(Color), 1f); + Dust dust = Main.dust[otherIdleDust]; + dust.velocity.X *= 0.5f; + dust.velocity.Y *= 0.1f; + } + + if ((NPC.type == NPCID.EaterofSouls || NPC.type == NPCID.Corruptor || NPC.type == NPCID.Crimera || NPC.type == NPCID.BloodSquid) && NPC.wet) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.95f; + + NPC.velocity.Y -= CalamityWorld.revenge ? 0.4f : 0.3f; + if (NPC.velocity.Y < -(CalamityWorld.revenge ? 3f : 2f)) + NPC.velocity.Y = -(CalamityWorld.revenge ? 3f : 2f); + } + + if (NPC.type == NPCID.Moth && NPC.wet) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.95f; + + NPC.velocity.Y -= 0.7f; + if (NPC.velocity.Y < -6f) + NPC.velocity.Y = -6f; + + NPC.TargetClosest(); + } + } + + if (NPC.type == NPCID.Hornet || NPC.type == NPCID.MossHornet || (NPC.type >= NPCID.HornetFatty && NPC.type <= NPCID.HornetStingy)) + { + if (NPC.wet) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.95f; + + NPC.velocity.Y -= 0.5f; + if (NPC.velocity.Y < -4f) + NPC.velocity.Y = -4f; + + NPC.TargetClosest(); + } + + if (NPC.ai[1] == 301f) + { + SoundEngine.PlaySound(SoundID.Item17, NPC.Center); + NPC.ai[1] = 0f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[1] += ((NPC.type == NPCID.MossHornet || queenBeeHornet) ? 2f : 1f) + NPC.ai[2]; + if (NPC.justHit && !queenBeeHornet) + NPC.ai[1] = 0f; + + if (NPC.ai[1] >= 240f) + { + if (targetData.Type != 0 && Collision.CanHit(NPC, targetData)) + { + float projSpeed = (CalamityWorld.death || Main.hardMode) ? 5f : 8f; + projSpeed += NPC.ai[2] * ((CalamityWorld.death || Main.hardMode) ? 2f : 4f); + if (queenBeeHornet) + projSpeed += 2f; + + Vector2 projSpawnPosition = NPC.Center; + float projTargetXDist = targetData.Center.X - projSpawnPosition.X; + float projTargetYDist = targetData.Center.Y - projSpawnPosition.Y; + if ((projTargetXDist < 0f && NPC.velocity.X < 0f) || (projTargetXDist > 0f && NPC.velocity.X > 0f)) + { + float projTargetDistance = (float)Math.Sqrt(projTargetXDist * projTargetXDist + projTargetYDist * projTargetYDist); + projTargetDistance = projSpeed / projTargetDistance; + projTargetXDist *= projTargetDistance; + projTargetYDist *= projTargetDistance; + + // Master Mode Queen Bee Hornets deal increased damage + int projDamage = (int)((queenBeeHornet ? 15f : 10f) * NPC.scale); + if (NPC.type == NPCID.MossHornet) + projDamage = (int)(30f * NPC.scale); + + int stingerType = ProjectileID.Stinger; + int stingerSpawn = Projectile.NewProjectile(NPC.GetSource_FromAI(), projSpawnPosition.X, projSpawnPosition.Y, projTargetXDist, projTargetYDist, stingerType, projDamage, 0f, Main.myPlayer); + Main.projectile[stingerSpawn].timeLeft = (CalamityWorld.death || Main.hardMode) ? 600 : 300; + Main.projectile[stingerSpawn].extraUpdates += (CalamityWorld.death || Main.hardMode) ? 1 : 0; + NPC.ai[1] = 301f; + NPC.netUpdate = true; + } + else + NPC.ai[1] = 0f; + } + else + NPC.ai[1] = 0f; + } + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient && !targetDead) + { + if (Main.getGoodWorld && NPC.type == NPCID.EaterofSouls) + { + if (NPC.AnyNPCs(NPCID.EaterofWorldsHead)) + { + if (NPC.justHit) + NPC.localAI[0] = 0f; + + NPC.localAI[0] += 1f; + if (NPC.localAI[0] == 60f) + { + if (targetData.Type != 0 && Collision.CanHit(NPC, targetData)) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2) + NPC.velocity.X), (int)(NPC.position.Y + (float)(NPC.height / 2) + NPC.velocity.Y), NPCID.VileSpitEaterOfWorlds); + + NPC.localAI[0] = 0f; + } + } + } + + if (NPC.type == NPCID.Corruptor) + { + if (NPC.justHit || !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.localAI[0] = 0f; + + NPC.localAI[0] += 1f; + if (NPC.localAI[0] == CorruptorVileSpitGateValue) + { + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2) + NPC.velocity.X), (int)(NPC.position.Y + (float)(NPC.height / 2) + NPC.velocity.Y), NPCID.VileSpit); + + NPC.localAI[0] = 0f; + } + + if (NPC.localAI[0] > CorruptorVileSpitGateValue - CorruptorVileSpitTelegraphTime) + { + Vector2 dustCenter = NPC.Center + NPC.SafeDirectionTo(Main.player[NPC.target].Center, -Vector2.UnitY) * 25f + Main.rand.NextVector2CircularEdge(3f, 3f); + Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, DustID.CorruptGibs, NPC.velocity.X * 0.1f, NPC.velocity.Y * 0.1f, 80, default, 1.3f); + dust.noGravity = true; + dust.velocity *= 0.3f; + } + } + + if (NPC.type == NPCID.BloodSquid) + { + if (NPC.justHit || targetData.Type == 0 || !Collision.CanHit(NPC, targetData)) + NPC.localAI[0] = 0f; + + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= BloodSquidBloodShotGateValue) + { + if (targetData.Type != 0 && Collision.CanHit(NPC, targetData)) + { + if ((NPC.Center - targetData.Center).Length() < 400f) + { + Vector2 bloodShotPosition = NPC.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); + NPC.velocity = -bloodShotPosition * 5f; + NPC.netUpdate = true; + NPC.localAI[0] = 0f; + bloodShotPosition = NPC.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bloodShotPosition * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer); + if (CalamityWorld.death) + { + Main.projectile[proj].extraUpdates += 1; + Main.projectile[proj].timeLeft = 1200; + } + } + else + NPC.localAI[0] = 0f; + } + else + NPC.localAI[0] = 0f; + } + + if (NPC.localAI[0] > BloodSquidBloodShotGateValue - BloodSquidBloodShotTelegraphTime) + { + Vector2 dustCenter = NPC.Center + NPC.SafeDirectionTo(Main.player[NPC.target].Center, -Vector2.UnitY) * 25f + Main.rand.NextVector2CircularEdge(5f, 5f); + Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, DustID.Blood, 0f, 0f, 100, default, 3f); + dust.fadeIn = 1.7f; + dust.noGravity = true; + dust.velocity *= 0f; + } + } + } + + if (!queenBeeHornet) + { + if ((Main.dayTime && NPC.type != NPCID.Crimera && NPC.type != NPCID.EaterofSouls && NPC.type != NPCID.MeteorHead && NPC.type != NPCID.Bee && NPC.type != NPCID.BeeSmall && NPC.type != NPCID.Corruptor && NPC.type != NPCID.Moth && NPC.type != NPCID.Parrot && NPC.type != NPCID.BloodSquid) || Main.player[NPC.target].dead) + { + NPC.velocity.Y -= acceleration * 2f; + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; + } + } + + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + NPC.netUpdate = true; + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingFishAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingFishAI.cs new file mode 100644 index 0000000000..a3fbed6183 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingFishAI.cs @@ -0,0 +1,261 @@ +using System; +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class FlyingFishAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.noGravity = true; + if (NPC.collideX) + { + if (NPC.oldVelocity.X > 0f) + { + NPC.direction = -1; + } + else + { + NPC.direction = 1; + } + NPC.velocity.X = (float)NPC.direction; + } + if (NPC.collideY) + { + if (NPC.oldVelocity.Y > 0f) + { + NPC.directionY = -1; + } + else + { + NPC.directionY = 1; + } + NPC.velocity.Y = (float)NPC.directionY; + } + if (NPC.type == NPCID.EyeballFlyingFish) + { + NPC.position += NPC.netOffset; + if (NPC.alpha == 255) + { + NPC.velocity.Y = -6f; + NPC.netUpdate = true; + for (int i = 0; i < 15; i++) + { + Dust eyeFishDust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Blood); + Dust dust = eyeFishDust; + dust.velocity *= 0.5f; + eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishDust; + dust.velocity += NPC.velocity * 0.5f; + } + } + + NPC.alpha -= 15; + if (NPC.alpha < 0) + NPC.alpha = 0; + + if (NPC.alpha != 0) + { + for (int j = 0; j < 2; j++) + { + Dust eyeFishDust2 = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Blood); + Dust dust = eyeFishDust2; + dust.velocity *= 1f; + eyeFishDust2.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishDust2; + dust.velocity += NPC.velocity * 0.3f; + } + } + + if (Main.rand.NextBool(3)) + { + Dust eyeFishIdleDust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Blood); + Dust dust = eyeFishIdleDust; + dust.velocity *= 0f; + eyeFishIdleDust.alpha = 120; + eyeFishIdleDust.scale = 0.7f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishIdleDust; + dust.velocity += NPC.velocity * 0.3f; + } + + NPC.position -= NPC.netOffset; + } + int fishTarget = NPC.target; + int fishDirection = NPC.direction; + if (NPC.target == Main.maxPlayers || (Main.player[NPC.target].wet && NPC.type != NPCID.EyeballFlyingFish) || Main.player[NPC.target].dead || Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[0] = 90f; + NPC.TargetClosest(true); + } + else if (NPC.ai[0] > 0f) + { + NPC.ai[0] -= 1f; + NPC.TargetClosest(true); + } + if (NPC.netUpdate && fishTarget == NPC.target && fishDirection == NPC.direction) + { + NPC.netUpdate = false; + } + float acceleration = 0.05f; + float verticalAcceleration = 0.01f; + float maxVelocity = 6f; + float maxYSpeed = 3f; + float turnAroundXDist = 30f; + float turnAroundYDist = 100f; + float targetXDist = Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))); + float targetYDist = Main.player[NPC.target].position.Y - (float)(NPC.height / 2); + if (NPC.type == NPCID.FlyingAntlion || NPC.type == NPCID.GiantFlyingAntlion) + { + acceleration = 0.09f; + verticalAcceleration = 0.03f; + maxVelocity = 9f; + maxYSpeed = 6f; + turnAroundXDist = 40f; + turnAroundYDist = 150f; + targetYDist = Main.player[NPC.target].Center.Y - (float)(NPC.height / 2); + NPC.rotation = NPC.velocity.X * 0.1f; + int playerInc; + for (int p = 0; p < Main.maxNPCs; p = playerInc + 1) + { + if (p != NPC.whoAmI && Main.npc[p].active && Main.npc[p].type == NPC.type && Math.Abs(NPC.position.X - Main.npc[p].position.X) + Math.Abs(NPC.position.Y - Main.npc[p].position.Y) < (float)NPC.width) + { + if (NPC.position.X < Main.npc[p].position.X) + { + NPC.velocity.X = NPC.velocity.X - 0.05f; + } + else + { + NPC.velocity.X = NPC.velocity.X + 0.05f; + } + if (NPC.position.Y < Main.npc[p].position.Y) + { + NPC.velocity.Y = NPC.velocity.Y - 0.05f; + } + else + { + NPC.velocity.Y = NPC.velocity.Y + 0.05f; + } + } + playerInc = p; + } + } + else if (NPC.type == NPCID.EyeballFlyingFish) + { + acceleration = 0.16f; + verticalAcceleration = 0.12f; + maxVelocity = 9f; + maxYSpeed = 5f; + turnAroundXDist = 0f; + turnAroundYDist = 250f; + targetYDist = Main.player[NPC.target].position.Y; + if (Main.dayTime) + { + targetYDist = 0f; + NPC.direction *= -1; + } + } + if (CalamityWorld.death) + { + maxVelocity *= 1.25f; + acceleration *= 1.25f; + } + if (NPC.ai[0] <= 0f) + { + maxVelocity *= 0.8f; + acceleration *= 0.7f; + targetYDist = NPC.Center.Y + (float)(NPC.directionY * 1000); + if (NPC.velocity.X < 0f) + { + NPC.direction = -1; + } + else if (NPC.velocity.X > 0f || NPC.direction == 0) + { + NPC.direction = 1; + } + } + if (targetXDist > turnAroundXDist) + { + if (NPC.direction == -1 && NPC.velocity.X > -maxVelocity) + { + NPC.velocity.X = NPC.velocity.X - acceleration; + if (NPC.velocity.X > maxVelocity) + { + NPC.velocity.X = NPC.velocity.X - acceleration; + } + else if (NPC.velocity.X > 0f) + { + NPC.velocity.X = NPC.velocity.X - acceleration / 2f; + } + if (NPC.velocity.X < -maxVelocity) + { + NPC.velocity.X = -maxVelocity; + } + } + else if (NPC.direction == 1 && NPC.velocity.X < maxVelocity) + { + NPC.velocity.X = NPC.velocity.X + acceleration; + if (NPC.velocity.X < -maxVelocity) + { + NPC.velocity.X = NPC.velocity.X + acceleration; + } + else if (NPC.velocity.X < 0f) + { + NPC.velocity.X = NPC.velocity.X + acceleration / 2f; + } + if (NPC.velocity.X > maxVelocity) + { + NPC.velocity.X = maxVelocity; + } + } + } + if (targetXDist > turnAroundYDist) + { + targetYDist -= turnAroundYDist / 2f; + } + if (NPC.position.Y < targetYDist) + { + NPC.velocity.Y = NPC.velocity.Y + verticalAcceleration; + if (NPC.velocity.Y < 0f) + { + NPC.velocity.Y = NPC.velocity.Y + verticalAcceleration; + } + } + else + { + NPC.velocity.Y = NPC.velocity.Y - verticalAcceleration; + if (NPC.velocity.Y > 0f) + { + NPC.velocity.Y = NPC.velocity.Y - verticalAcceleration; + } + } + if (NPC.velocity.Y < -maxYSpeed) + { + NPC.velocity.Y = -maxYSpeed; + } + if (NPC.velocity.Y > maxYSpeed) + { + NPC.velocity.Y = maxYSpeed; + } + if (NPC.wet && NPC.type != NPCID.EyeballFlyingFish) + { + if (NPC.velocity.Y > 0f) + { + NPC.velocity.Y = NPC.velocity.Y * 0.95f; + } + NPC.velocity.Y = NPC.velocity.Y - 0.7f; + if (NPC.velocity.Y < -6f) + { + NPC.velocity.Y = -6f; + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingWeaponAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingWeaponAI.cs new file mode 100644 index 0000000000..14d0b79418 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingWeaponAI.cs @@ -0,0 +1,83 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class FlyingWeaponAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.knockBackResist = 0f; + NPC.noGravity = true; + NPC.noTileCollide = true; + if (NPC.type == NPCID.EnchantedSword) + { + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0.2f, 0.05f, 0.3f); + } + else if (NPC.type == NPCID.CrimsonAxe) + { + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0.3f, 0.15f, 0.05f); + } + else + { + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0.05f, 0.2f, 0.3f); + } + // Adjust target if we don't have one. + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) + { + NPC.TargetClosest(true); + } + // Charge + if (NPC.ai[0] == 0f) + { + float chargeSpeed = CalamityWorld.death ? 16f : 12f; + NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center, -Vector2.UnitY) * chargeSpeed; + NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver4; + + // Slow down + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + return false; + } + // Slow down + if (NPC.ai[0] == 1f) + { + NPC.velocity *= CalamityWorld.death ? 0.98f : 0.99f; + NPC.ai[1] += 1f; + // Get ready to spin and then charge again. + if (NPC.ai[1] >= (CalamityWorld.death ? 50f : 100f)) + { + NPC.netUpdate = true; + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + NPC.velocity = Vector2.Zero; + } + } + // Spin + else + { + NPC.velocity *= CalamityWorld.death ? 0.94f : 0.96f; + NPC.ai[1] += 1f; + + float anglularSpeed = NPC.ai[1] / (CalamityWorld.death ? 90f : 150f); + anglularSpeed = 0.1f + anglularSpeed * 0.4f; + NPC.rotation += anglularSpeed * NPC.direction; + + // Charge + if (NPC.ai[1] >= (CalamityWorld.death ? 90f : 150f)) + { + NPC.netUpdate = true; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/GraniteElementalAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/GraniteElementalAI.cs new file mode 100644 index 0000000000..cb06fc8865 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/GraniteElementalAI.cs @@ -0,0 +1,208 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class GraniteElementalAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.noGravity = true; + NPC.noTileCollide = false; + + // Set damage + NPC.damage = NPC.defDamage; + + NPC.defense = NPC.defDefense; + + if (NPC.justHit && Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(10)) + { + NPC.netUpdate = true; + NPC.ai[0] = -1f; + NPC.ai[1] = 0f; + } + if (NPC.ai[0] == -1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.defense = NPC.defDefense + 10; + + NPC.noGravity = false; + NPC.velocity.X *= 0.98f; + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 120f) + { + NPC.ai[0] = (NPC.ai[1] = (NPC.ai[2] = (NPC.ai[3] = 0f))); + } + } + else if (NPC.ai[0] == 0f) + { + NPC.TargetClosest(true); + if (Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[0] = 1f; + return false; + } + Vector2 targetDirection = Main.player[NPC.target].Center - NPC.Center; + targetDirection.Y -= (float)(Main.player[NPC.target].height / 4); + float attackTimeMax1 = targetDirection.Length(); + if (attackTimeMax1 > (CalamityWorld.death ? 400f : 800f)) + { + NPC.ai[0] = 2f; + return false; + } + Vector2 elementalCenter = NPC.Center; + elementalCenter.X = Main.player[NPC.target].Center.X; + Vector2 targetDistance = elementalCenter - NPC.Center; + if (targetDistance.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, elementalCenter, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = elementalCenter.X; + NPC.ai[2] = elementalCenter.Y; + Vector2 elementalCenter2 = NPC.Center; + elementalCenter2.Y = Main.player[NPC.target].Center.Y; + if (targetDistance.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, elementalCenter2, 1, 1) && Collision.CanHit(elementalCenter2, 1, 1, Main.player[NPC.target].position, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = elementalCenter2.X; + NPC.ai[2] = elementalCenter2.Y; + } + } + else + { + elementalCenter = NPC.Center; + elementalCenter.Y = Main.player[NPC.target].Center.Y; + if ((elementalCenter - NPC.Center).Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, elementalCenter, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = elementalCenter.X; + NPC.ai[2] = elementalCenter.Y; + } + } + if (NPC.ai[0] == 0f) + { + NPC.localAI[0] = 0f; + targetDirection.Normalize(); + targetDirection *= 0.5f; + NPC.velocity += targetDirection; + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + } + } + else if (NPC.ai[0] == 1f) + { + Vector2 targetDirectionAgain = Main.player[NPC.target].Center - NPC.Center; + float attackTimeMax2 = targetDirectionAgain.Length(); + float attackTimeMax3 = 2f; + attackTimeMax3 += attackTimeMax2 / (CalamityWorld.death ? 160f : 180f); + int attackTimeMax4 = 50; + targetDirectionAgain.Normalize(); + targetDirectionAgain *= attackTimeMax3; + NPC.velocity = (NPC.velocity * (float)(attackTimeMax4 - 1) + targetDirectionAgain) / (float)attackTimeMax4; + if (!Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + } + } + else if (NPC.ai[0] == 2f) + { + NPC.noTileCollide = true; + Vector2 targetDirection3 = Main.player[NPC.target].Center - NPC.Center; + float attackTimeMax5 = targetDirection3.Length(); + float scaleFactor23 = CalamityWorld.death ? 3f : 2.5f; + int attackTimeMax6 = 4; + targetDirection3.Normalize(); + targetDirection3 *= scaleFactor23; + NPC.velocity = (NPC.velocity * (float)(attackTimeMax6 - 1) + targetDirection3) / (float)attackTimeMax6; + if (attackTimeMax5 < 600f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + { + NPC.ai[0] = 0f; + } + } + else if (NPC.ai[0] == 3f) + { + Vector2 elementalCenter3 = new Vector2(NPC.ai[1], NPC.ai[2]); + Vector2 elementalDirection = elementalCenter3 - NPC.Center; + float attackTimeMax7 = elementalDirection.Length(); + float attackTimeMax8 = 2f; + float attackTimeMax9 = 3f; + elementalDirection.Normalize(); + elementalDirection *= attackTimeMax8; + NPC.velocity = (NPC.velocity * (attackTimeMax9 - 1f) + elementalDirection) / attackTimeMax9; + if (NPC.collideX || NPC.collideY) + { + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + } + if (attackTimeMax7 < attackTimeMax8 || attackTimeMax7 > 800f || Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[0] = 0f; + } + } + else if (NPC.ai[0] == 4f) + { + if (NPC.collideX) + { + NPC.velocity.X = NPC.velocity.X * -0.8f; + } + if (NPC.collideY) + { + NPC.velocity.Y = NPC.velocity.Y * -0.8f; + } + Vector2 stationaryTargetDist; + if (NPC.velocity.X == 0f && NPC.velocity.Y == 0f) + { + stationaryTargetDist = Main.player[NPC.target].Center - NPC.Center; + stationaryTargetDist.Y -= (float)(Main.player[NPC.target].height / 4); + stationaryTargetDist.Normalize(); + NPC.velocity = stationaryTargetDist * 0.1f; + } + float scaleFactor24 = CalamityWorld.death ? 2.5f : 2f; + stationaryTargetDist = NPC.velocity; + stationaryTargetDist.Normalize(); + stationaryTargetDist *= scaleFactor24; + NPC.velocity = (NPC.velocity * 19f + stationaryTargetDist) / 20f; + NPC.ai[1] += 1f; + if (NPC.ai[1] > 180f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + } + if (Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[0] = 0f; + } + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 5f && !Collision.SolidCollision(NPC.position - new Vector2(10f, 10f), NPC.width + 20, NPC.height + 20)) + { + NPC.localAI[0] = 0f; + Vector2 elementalCenter4 = NPC.Center; + elementalCenter4.X = Main.player[NPC.target].Center.X; + if (Collision.CanHit(NPC.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(NPC.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, elementalCenter4, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = elementalCenter4.X; + NPC.ai[2] = elementalCenter4.Y; + return false; + } + elementalCenter4 = NPC.Center; + elementalCenter4.Y = Main.player[NPC.target].Center.Y; + if (Collision.CanHit(NPC.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, elementalCenter4, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = elementalCenter4.X; + NPC.ai[2] = elementalCenter4.Y; + } + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HerplingAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HerplingAI.cs new file mode 100644 index 0000000000..b670f9f69a --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HerplingAI.cs @@ -0,0 +1,310 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class HerplingAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.ai[2] > 1f) + { + NPC.ai[2] -= 1f; + } + + if (NPC.ai[2] == 0f) + { + NPC.ai[0] = -100f; + NPC.ai[2] = 1f; + NPC.TargetClosest(true); + NPC.spriteDirection = NPC.direction; + } + + if (NPC.type == NPCID.ChatteringTeethBomb) + { + Vector2 dustOffset = new Vector2(-6f, -10f); + dustOffset.X *= NPC.spriteDirection; + if (NPC.ai[1] != 5f && Main.rand.NextBool(3)) + { + NPC.position += NPC.netOffset; + int dustID = Dust.NewDust(NPC.Center + dustOffset - Vector2.One * 5f, 4, 4, DustID.Torch); + Dust dust = Main.dust[dustID]; + dust.scale = 1.5f; + dust.noGravity = true; + dust.velocity = dust.velocity * 0.25f + Vector2.Normalize(dustOffset) * 1f; + dust.velocity = dust.velocity.RotatedBy(-(float)Math.PI / 2f * (float)NPC.direction); + NPC.position -= NPC.netOffset; + } + if (NPC.ai[1] == 5f) + { + NPC.velocity = Vector2.Zero; + NPC.position.X += NPC.width / 2; + NPC.position.Y += NPC.height / 2; + NPC.width = 160; + NPC.height = 160; + NPC.position.X -= NPC.width / 2; + NPC.position.Y -= NPC.height / 2; + NPC.dontTakeDamage = true; + NPC.position += NPC.netOffset; + if (NPC.ai[2] > 7f) + { + for (int i = 0; i < 8; i++) + { + Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); + } + for (int i = 0; i < 32; i++) + { + int dustID = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[dustID]; + dust.velocity *= 3f; + dust.noGravity = true; + dustID = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f); + dust = Main.dust[dustID]; + dust.velocity *= 2f; + dust.noGravity = true; + } + for (int i = 0; i < 2; i++) + { + int goreID = Gore.NewGore(NPC.GetSource_FromThis(), NPC.position + new Vector2((float)(NPC.width * Main.rand.Next(100)) / 100f, (float)(NPC.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(GoreID.Smoke1, GoreID.Smoke3 + 1)); + Gore gore = Main.gore[goreID]; + gore.velocity *= 0.3f; + gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; + gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; + } + if (NPC.ai[2] == 9f) + { + SoundEngine.PlaySound(SoundID.Item14, NPC.position); + } + } + if (NPC.ai[2] == 1f) + { + NPC.life = -1; + NPC.HitEffect(); + NPC.active = false; + } + NPC.position -= NPC.netOffset; + return false; + } + } + + if (NPC.type == NPCID.ChatteringTeethBomb && NPC.ai[1] != 5f) + { + if (NPC.wet || Vector2.Distance(NPC.Center, Main.player[NPC.target].Center) < 64f) + { + NPC.ai[1] = 5f; + NPC.ai[2] = 10f; + NPC.netUpdate = true; + return false; + } + } + else if (NPC.wet && NPC.type != NPCID.Derpling) + { + if (NPC.collideX) + { + NPC.direction *= -1; // Fixed bug where herplings didn't change direction from left to right + NPC.spriteDirection = NPC.direction; + } + + if (NPC.collideY) + { + NPC.TargetClosest(true); + + if (NPC.oldVelocity.Y < 0f) + { + NPC.velocity.Y = 5f; + } + else + { + NPC.velocity.Y = NPC.velocity.Y - 2f; + } + + NPC.spriteDirection = NPC.direction; + } + + if (NPC.velocity.Y > 4f) + { + NPC.velocity.Y = NPC.velocity.Y * 0.9f; + } + + NPC.velocity.Y = NPC.velocity.Y - 0.45f; + + if (NPC.velocity.Y < -6f) + { + NPC.velocity.Y = -6f; + } + } + + // Avoid cheap bullshit + NPC.damage = (NPC.velocity.Y == 0f || NPC.velocity.Length() < 3f) ? 0 : NPC.defDamage; + + if (NPC.velocity.Y == 0f) + { + if (NPC.ai[3] == NPC.position.X) + { + NPC.direction *= -1; + NPC.ai[2] = 300f; + } + + NPC.ai[3] = 0f; + + NPC.velocity.X = NPC.velocity.X * 0.8f; + if ((double)NPC.velocity.X > -0.1 && (double)NPC.velocity.X < 0.1) + { + NPC.velocity.X = 0f; + } + + if (NPC.type == NPCID.Derpling) + { + NPC.ai[0] += 3f; + } + else + { + NPC.ai[0] += 10f; + } + + Vector2 herplingPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float herplingTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - herplingPosition.X; + float herplingTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - herplingPosition.Y; + float herplingTargetDist = (float)Math.Sqrt((double)(herplingTargetX * herplingTargetX + herplingTargetY * herplingTargetY)); + float herplingJumpHeight = 400f / herplingTargetDist; + + if (NPC.type == NPCID.Derpling) + { + herplingJumpHeight *= 5f; + } + else + { + herplingJumpHeight *= 10f; + } + + if (herplingJumpHeight > 30f) + { + herplingJumpHeight = 30f; + } + + NPC.ai[0] += (float)((int)herplingJumpHeight); + + if (NPC.ai[0] >= 0f) + { + NPC.netUpdate = true; + + if (NPC.ai[2] == 1f) + { + NPC.TargetClosest(true); + } + + if (NPC.type == NPCID.Derpling) + { + if (NPC.ai[1] == 2f) + { + NPC.velocity.Y = -14f; + NPC.velocity.X = NPC.velocity.X + 3f * (float)NPC.direction; + if (herplingTargetDist < 350f && herplingTargetDist > 200f) + { + NPC.velocity.X = NPC.velocity.X + (float)NPC.direction; + } + NPC.ai[0] = CalamityWorld.death ? -100f : -200f; + NPC.ai[1] = 0f; + NPC.ai[3] = NPC.position.X; + } + else + { + NPC.velocity.Y = -10f; + NPC.velocity.X = NPC.velocity.X + (float)(5 * NPC.direction); + if (herplingTargetDist < 350f && herplingTargetDist > 200f) + { + NPC.velocity.X = NPC.velocity.X + (float)NPC.direction; + } + NPC.ai[0] = CalamityWorld.death ? -60f : -120f; + NPC.ai[1] += 1f; + } + } + else + { + if (NPC.type == NPCID.ChatteringTeethBomb) + { + SoundEngine.PlaySound(SoundID.Zombie124, NPC.position); + } + if (NPC.ai[1] == 3f) + { + NPC.velocity.Y = -9f; + NPC.velocity.X = NPC.velocity.X + (float)(2 * NPC.direction); + if (herplingTargetDist < 350f && herplingTargetDist > 200f) + { + NPC.velocity.X = NPC.velocity.X + (float)NPC.direction; + } + NPC.ai[0] = CalamityWorld.death ? -100f : -200f; + NPC.ai[1] = 0f; + NPC.ai[3] = NPC.position.X; + } + else + { + NPC.velocity.Y = -5f; + NPC.velocity.X = NPC.velocity.X + (float)(4 * NPC.direction); + if (herplingTargetDist < 350f && herplingTargetDist > 200f) + { + NPC.velocity.X = NPC.velocity.X + (float)NPC.direction; + } + NPC.ai[0] = CalamityWorld.death ? -60f : -120f; + NPC.ai[1] += 1f; + } + } + } + else if (NPC.ai[0] >= -30f) + { + NPC.aiAction = 1; + } + + NPC.spriteDirection = NPC.direction; + + return false; + } + + if (NPC.target < Main.maxPlayers) + { + if (NPC.type == NPCID.Derpling) + { + bool derplingDropOnTarget = false; + if (NPC.position.Y + (float)NPC.height < Main.player[NPC.target].position.Y && NPC.position.X + (float)NPC.width > Main.player[NPC.target].position.X && NPC.position.X < Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width) + { + derplingDropOnTarget = true; + NPC.velocity.X = NPC.velocity.X * 0.9f; + if (NPC.velocity.Y < 0f) + { + NPC.velocity.Y = NPC.velocity.Y * 0.9f; + NPC.velocity.Y = NPC.velocity.Y + 0.15f; + } + } + + if (!derplingDropOnTarget && ((NPC.direction == 1 && NPC.velocity.X < 4f) || (NPC.direction == -1 && NPC.velocity.X > -4f))) + { + if ((NPC.direction == -1 && (double)NPC.velocity.X < 0.1) || (NPC.direction == 1 && (double)NPC.velocity.X > -0.1)) + { + NPC.velocity.X = NPC.velocity.X + 0.3f * (float)NPC.direction; + return false; + } + NPC.velocity.X = NPC.velocity.X * 0.9f; + } + } + else if ((NPC.direction == 1 && NPC.velocity.X < 3f) || (NPC.direction == -1 && NPC.velocity.X > -3f)) + { + if ((NPC.direction == -1 && (double)NPC.velocity.X < 0.1) || (NPC.direction == 1 && (double)NPC.velocity.X > -0.1)) + { + NPC.velocity.X = NPC.velocity.X + 0.3f * (float)NPC.direction; + return false; + } + NPC.velocity.X = NPC.velocity.X * 0.9f; + } + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HoveringAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HoveringAI.cs new file mode 100644 index 0000000000..f2fec81647 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/HoveringAI.cs @@ -0,0 +1,503 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class HoveringAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + bool hoverDownDistCheck = false; + bool runAway = NPC.type == NPCID.Poltergeist && !Main.pumpkinMoon; + + if (NPC.type == NPCID.Reaper && !Main.eclipse) + { + runAway = true; + } + if (NPC.type == NPCID.Drippler && Main.dayTime) + { + runAway = true; + } + + if (!runAway) + { + if (NPC.ai[2] >= 0f) + { + int hoverDistance = 16; + bool changeDirectionX = false; + bool changeDirectionY = false; + if (NPC.position.X > NPC.ai[0] - (float)hoverDistance && NPC.position.X < NPC.ai[0] + (float)hoverDistance) + { + changeDirectionX = true; + } + else if ((NPC.velocity.X < 0f && NPC.direction > 0) || (NPC.velocity.X > 0f && NPC.direction < 0)) + { + changeDirectionX = true; + } + hoverDistance += 24; + if (NPC.position.Y > NPC.ai[1] - (float)hoverDistance && NPC.position.Y < NPC.ai[1] + (float)hoverDistance) + { + changeDirectionY = true; + } + if (changeDirectionX & changeDirectionY) + { + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 40f) + { + NPC.ai[2] = -200f; + NPC.direction *= -1; + NPC.velocity.X = NPC.velocity.X * -1f; + NPC.collideX = false; + } + } + else + { + NPC.ai[0] = NPC.position.X; + NPC.ai[1] = NPC.position.Y; + NPC.ai[2] = 0f; + } + NPC.TargetClosest(true); + } + else if (NPC.type == NPCID.Reaper) + { + NPC.TargetClosest(true); + NPC.ai[2] += 30f; + } + else + { + if (NPC.type == NPCID.Poltergeist) + { + NPC.ai[2] += 5f; + } + else + { + NPC.ai[2] += 15f; + } + if (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) > NPC.position.X + (float)(NPC.width / 2)) + { + NPC.direction = -1; + } + else + { + NPC.direction = 1; + } + } + } + + int npcTileX = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; + int npcTileY = (int)((NPC.position.Y + (float)NPC.height) / 16f); + bool hoverDownwards = true; + bool canOpenDoor = false; + int tileCheckLoopAmt = 6; + + if (NPC.type == NPCID.Gastropod) + { + float gastropodProjSpeed = 6f; + Vector2 gastropodPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float gastropodTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - gastropodPosition.X; + float gastropodTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - gastropodPosition.Y; + float gastropodTargetDist = (float)Math.Sqrt((double)(gastropodTargetX * gastropodTargetX + gastropodTargetY * gastropodTargetY)); + + gastropodTargetDist = gastropodProjSpeed / gastropodTargetDist; + gastropodTargetX *= gastropodTargetDist; + gastropodTargetY *= gastropodTargetDist; + + if (NPC.justHit) + { + NPC.localAI[1] = 0f; + NPC.ai[3] = 0f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[3] == 32f && !Main.player[NPC.target].npcTypeNoAggro[NPC.type]) + { + int damage = 25; + int projType = ProjectileID.PinkLaser; + Projectile.NewProjectile(NPC.GetSource_FromAI(), gastropodPosition.X, gastropodPosition.Y, gastropodTargetX, gastropodTargetY, projType, damage, 0f, Main.myPlayer, 0f, 0f); + } + + tileCheckLoopAmt = 12; + + if (NPC.ai[3] > 0f) + { + NPC.ai[3] += 1f; + if (NPC.ai[3] >= 64f) + { + NPC.ai[3] = 0f; + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[3] == 0f) + { + NPC.localAI[1] += 1f; + if (NPC.localAI[1] > (CalamityWorld.death ? 60f : 120f) && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && !Main.player[NPC.target].npcTypeNoAggro[NPC.type]) + { + NPC.localAI[1] = 0f; + NPC.ai[3] = 1f; + NPC.netUpdate = true; + } + } + } + else if (NPC.type == NPCID.Pixie) + { + tileCheckLoopAmt = 8; + + if (Main.rand.NextBool(6)) + { + int pixieDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Pixie, 0f, 0f, 200, NPC.color, 1f); + Dust dust = Main.dust[pixieDust]; + dust.velocity *= 0.3f; + } + + if (Main.rand.NextBool(40)) + { + SoundEngine.PlaySound(SoundID.Pixie, NPC.Center); + } + } + else if (NPC.type == NPCID.IceElemental) + { + Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0f, 0.6f, 0.75f); + + NPC.alpha = 30; + + if (Main.rand.NextBool(3)) + { + int iceEleDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Frost, 0f, 0f, 200, default, 1f); + Dust dust = Main.dust[iceEleDust]; + dust.velocity *= 0.3f; + Main.dust[iceEleDust].noGravity = true; + } + + float iceElementalProjSpeed = 6f; + Vector2 iceElementalPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float iceElementalTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - iceElementalPosition.X; + float iceElementalTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - iceElementalPosition.Y; + float iceElementalTargetDist = (float)Math.Sqrt((double)(iceElementalTargetX * iceElementalTargetX + iceElementalTargetY * iceElementalTargetY)); + + iceElementalTargetDist = iceElementalProjSpeed / iceElementalTargetDist; + iceElementalTargetX *= iceElementalTargetDist; + iceElementalTargetY *= iceElementalTargetDist; + + if (iceElementalTargetX > 0f) + NPC.direction = 1; + else + NPC.direction = -1; + + NPC.spriteDirection = NPC.direction; + + if (NPC.direction < 0) + NPC.rotation = (float)Math.Atan2((double)(-(double)iceElementalTargetY), (double)(-(double)iceElementalTargetX)); + else + NPC.rotation = (float)Math.Atan2((double)iceElementalTargetY, (double)iceElementalTargetX); + + if (NPC.justHit || !Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + NPC.localAI[1] = 0f; + + tileCheckLoopAmt = 15; + + // Emit frost dust when about to fire + if (NPC.localAI[1] > (CalamityWorld.death ? IceElementalFrostBlastGateValue_Death : IceElementalFrostBlastGateValue) - IceElementalFrostBlastTelegraphTime) + { + Dust dust = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Frost, 0f, 0f, 200, default, 2f); + dust.noGravity = true; + dust.velocity *= 0f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[1] += 1f; + if (NPC.localAI[1] > (CalamityWorld.death ? IceElementalFrostBlastGateValue_Death : IceElementalFrostBlastGateValue) && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.localAI[1] = 0f; + + int dmg = 45; + int projType = ProjectileID.FrostBlastHostile; + Projectile.NewProjectile(NPC.GetSource_FromAI(), iceElementalPosition.X, iceElementalPosition.Y, iceElementalTargetX, iceElementalTargetY, projType, dmg, 0f, Main.myPlayer); + + NPC.netUpdate = true; + } + } + } + else if (NPC.type == NPCID.IchorSticker) + { + NPC.rotation = NPC.velocity.X * 0.1f; + + if (Main.player[NPC.target].Center.Y < NPC.Center.Y) + tileCheckLoopAmt = 18; + else + tileCheckLoopAmt = 9; + + if (NPC.justHit) + NPC.ai[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient && !NPC.confused) + { + NPC.ai[3] += 1f; + if (NPC.ai[3] >= (CalamityWorld.death ? IchorStickerShootGateValue_Death : CalamityWorld.revenge ? IchorStickerShootGateValue_Rev : IchorStickerShootGateValue)) + { + NPC.ai[3] = 0f; + Vector2 ichorStickerPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f - 4f, NPC.position.Y + (float)NPC.height * 0.7f); + if (Collision.CanHit(ichorStickerPosition, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + float ichorStickerProjSpeed = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; + float ichorStickerTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - ichorStickerPosition.X; + float ichorStickerAbsTargetX = Math.Abs(ichorStickerTargetX) * 0.1f; + float ichorStickerTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - ichorStickerPosition.Y - ichorStickerAbsTargetX; + float ichorStickerTargetDist = (float)Math.Sqrt((double)(ichorStickerTargetX * ichorStickerTargetX + ichorStickerTargetY * ichorStickerTargetY)); + ichorStickerTargetDist = ichorStickerProjSpeed / ichorStickerTargetDist; + ichorStickerTargetX *= ichorStickerTargetDist; + ichorStickerTargetY *= ichorStickerTargetDist; + int dmg = 40; + int projType = ProjectileID.GoldenShowerHostile; + Projectile.NewProjectile(NPC.GetSource_FromAI(), ichorStickerPosition.X, ichorStickerPosition.Y, ichorStickerTargetX, ichorStickerTargetY, projType, dmg, 0f, Main.myPlayer); + } + } + } + } + + if (NPC.type == NPCID.Drippler) + { + tileCheckLoopAmt = 8; + + if (NPC.target >= 0) + { + float dripperTargetDist = (Main.player[NPC.target].Center - NPC.Center).Length(); + dripperTargetDist /= 70f; + if (dripperTargetDist > 8f) + { + dripperTargetDist = 8f; + } + tileCheckLoopAmt += (int)dripperTargetDist; + } + } + + for (int y = npcTileY; y < npcTileY + tileCheckLoopAmt; y++) + { + if ((Main.tile[npcTileX, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, y].TileType]) || Main.tile[npcTileX, y].LiquidAmount > 0) + { + if (y <= npcTileY + 1) + { + canOpenDoor = true; + } + hoverDownwards = false; + break; + } + } + + if (Main.player[NPC.target].npcTypeNoAggro[NPC.type]) + { + bool canOpenTallGate = false; + for (int yInc = npcTileY; yInc < npcTileY + tileCheckLoopAmt - 2; yInc++) + { + if ((Main.tile[npcTileX, yInc].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, yInc].TileType]) || Main.tile[npcTileX, yInc].LiquidAmount > 0) + { + canOpenTallGate = true; + break; + } + } + NPC.directionY = (!canOpenTallGate).ToDirectionInt(); + } + + if (NPC.type == NPCID.IceElemental || NPC.type == NPCID.IchorSticker) + { + for (int iceIchorY = npcTileY - 3; iceIchorY < npcTileY; iceIchorY++) + { + if ((Main.tile[npcTileX, iceIchorY].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, iceIchorY].TileType]) || Main.tile[npcTileX, iceIchorY].LiquidAmount > 0) + { + canOpenDoor = false; + hoverDownDistCheck = true; + break; + } + } + } + + if (hoverDownDistCheck) + { + hoverDownwards = true; + if (NPC.type == NPCID.IchorSticker) + NPC.velocity.Y += (CalamityWorld.revenge ? 3f : 2f); + } + + if (hoverDownwards) + { + if (NPC.type == NPCID.Pixie || NPC.type == NPCID.IceElemental) + { + NPC.velocity.Y += CalamityWorld.revenge ? 0.3f : 0.2f; + if (NPC.velocity.Y > (CalamityWorld.revenge ? 3f : 2f)) + NPC.velocity.Y = CalamityWorld.revenge ? 3f : 2f; + } + else if (NPC.type == NPCID.Drippler) + { + NPC.velocity.Y += 0.05f; + if (NPC.velocity.Y > 1f) + NPC.velocity.Y = 1f; + } + else + { + NPC.velocity.Y += 0.15f; + if (NPC.velocity.Y > 4f) + NPC.velocity.Y = 4f; + } + } + else + { + if (NPC.type == NPCID.Pixie || NPC.type == NPCID.IceElemental) + { + if ((NPC.directionY < 0 && NPC.velocity.Y > 0f) | canOpenDoor) + NPC.velocity.Y -= CalamityWorld.revenge ? 0.3f : 0.2f; + } + else if (NPC.type == NPCID.Drippler) + { + if ((NPC.directionY < 0 && NPC.velocity.Y > 0f) | canOpenDoor) + NPC.velocity.Y -= 0.1f; + if (NPC.velocity.Y < -1f) + NPC.velocity.Y = -1f; + } + else if (NPC.directionY < 0 && NPC.velocity.Y > 0f) + NPC.velocity.Y -= 0.15f; + + if (NPC.velocity.Y < -(CalamityWorld.revenge ? 5.5f : 4f)) + NPC.velocity.Y = -(CalamityWorld.revenge ? 5.5f : 4f); + } + + if (NPC.type == NPCID.Pixie && NPC.wet) + { + NPC.velocity.Y = NPC.velocity.Y - 0.3f; + if (NPC.velocity.Y < -3f) + { + NPC.velocity.Y = -3f; + } + } + + if (NPC.collideX) + { + NPC.velocity.X = NPC.oldVelocity.X * -0.4f; + if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 1f) + { + NPC.velocity.X = 1f; + } + if (NPC.direction == 1 && NPC.velocity.X < 0f && NPC.velocity.X > -1f) + { + NPC.velocity.X = -1f; + } + } + if (NPC.collideY) + { + NPC.velocity.Y = NPC.oldVelocity.Y * -0.25f; + if (NPC.velocity.Y > 0f && NPC.velocity.Y < 1f) + { + NPC.velocity.Y = 1f; + } + if (NPC.velocity.Y < 0f && NPC.velocity.Y > -1f) + { + NPC.velocity.Y = -1f; + } + } + + float maxHoverVel = 2f; + if (NPC.type == NPCID.Pixie) + { + maxHoverVel = 3f; + } + if (NPC.type == NPCID.Reaper) + { + maxHoverVel = 4f; + } + if (NPC.type == NPCID.Drippler) + { + maxHoverVel = 1.5f; + } + if (CalamityWorld.death) + { + maxHoverVel *= 1.25f; + } + + if (NPC.type == NPCID.Poltergeist) + { + NPC.alpha = 0; + maxHoverVel = 6f; + if (!runAway) + { + NPC.TargetClosest(); + } + else if (NPC.timeLeft > 10) + { + NPC.timeLeft = 10; + } + if (NPC.direction < 0 && NPC.velocity.X > 0f) + { + NPC.velocity.X = NPC.velocity.X * 0.8f; + } + if (NPC.direction > 0 && NPC.velocity.X < 0f) + { + NPC.velocity.X = NPC.velocity.X * 0.8f; + } + } + + if (NPC.direction == -1 && NPC.velocity.X > -maxHoverVel) + { + NPC.velocity.X -= CalamityWorld.revenge ? 0.15f : 0.1f; + if (NPC.velocity.X > maxHoverVel) + NPC.velocity.X -= CalamityWorld.revenge ? 0.15f : 0.1f; + else if (NPC.velocity.X > 0f) + NPC.velocity.X += CalamityWorld.revenge ? 0.1f : 0.05f; + + if (NPC.velocity.X < -maxHoverVel) + NPC.velocity.X = -maxHoverVel; + } + else if (NPC.direction == 1 && NPC.velocity.X < maxHoverVel) + { + NPC.velocity.X += CalamityWorld.revenge ? 0.15f : 0.1f; + if (NPC.velocity.X < -maxHoverVel) + NPC.velocity.X += CalamityWorld.revenge ? 0.15f : 0.1f; + else if (NPC.velocity.X < 0f) + NPC.velocity.X -= CalamityWorld.revenge ? 0.1f : 0.05f; + + if (NPC.velocity.X > maxHoverVel) + NPC.velocity.X = maxHoverVel; + } + + if (NPC.type == NPCID.Drippler) + maxHoverVel = 1.5f; + else + maxHoverVel = CalamityWorld.revenge ? 2.5f : 1.5f; + + if (CalamityWorld.death) + maxHoverVel *= 1.25f; + + if (NPC.directionY == -1 && NPC.velocity.Y > -maxHoverVel) + { + NPC.velocity.Y -= CalamityWorld.revenge ? 0.06f : 0.04f; + if (NPC.velocity.Y > maxHoverVel) + NPC.velocity.Y -= CalamityWorld.revenge ? 0.1f : 0.05f; + else if (NPC.velocity.Y > 0f) + NPC.velocity.Y += CalamityWorld.revenge ? 0.05f : 0.03f; + + if (NPC.velocity.Y < -maxHoverVel) + NPC.velocity.Y = -maxHoverVel; + } + else if (NPC.directionY == 1 && NPC.velocity.Y < maxHoverVel) + { + NPC.velocity.Y += CalamityWorld.revenge ? 0.06f : 0.04f; + if (NPC.velocity.Y < -maxHoverVel) + NPC.velocity.Y += CalamityWorld.revenge ? 0.1f : 0.05f; + else if (NPC.velocity.Y < 0f) + NPC.velocity.Y -= CalamityWorld.revenge ? 0.05f : 0.03f; + + if (NPC.velocity.Y > maxHoverVel) + NPC.velocity.Y = maxHoverVel; + } + + if (NPC.type == NPCID.Gastropod) + Lighting.AddLight((int)NPC.position.X / 16, (int)NPC.position.Y / 16, 0.4f, 0f, 0.25f); + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/JellyfishAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/JellyfishAI.cs new file mode 100644 index 0000000000..4b5cfb1855 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/JellyfishAI.cs @@ -0,0 +1,232 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class JellyfishAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + // Avoid cheap bullshit + float damagingVelocity = NPC.type == NPCID.GreenJellyfish ? 7.2f : 5.6f; + NPC.damage = (NPC.dontTakeDamage || NPC.velocity.Length() > damagingVelocity) ? NPC.defDamage : 0; + + // Stop moving because we're emitting electricity and don't take damage + bool endEarly = false; + if (NPC.wet && NPC.ai[1] == 1f) + { + endEarly = true; + } + else + { + NPC.dontTakeDamage = false; + } + if (NPC.type == NPCID.BlueJellyfish || NPC.type == NPCID.PinkJellyfish || NPC.type == NPCID.GreenJellyfish || NPC.type == NPCID.BloodJelly) + { + if (NPC.wet) + { + if (NPC.target >= 0 && Main.player[NPC.target].wet && !Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < 200f) + { + if (NPC.ai[1] == 0f) + { + NPC.ai[2] += 2f; + } + else + { + NPC.ai[2] -= 0.25f; + } + } + if (endEarly) + { + NPC.dontTakeDamage = true; + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 90f) + { + NPC.ai[1] = 0f; + } + } + else + { + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 300f) + { + NPC.ai[1] = 1f; + NPC.ai[2] = 0f; + } + } + } + else + { + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + } + } + float lightIntensity = 1f; + if (endEarly) + { + lightIntensity += 0.5f; + } + if (NPC.type == NPCID.BlueJellyfish) + { + Lighting.AddLight((int)(NPC.Center.X) / 16, (int)(NPC.Center.Y) / 16, 0.05f * lightIntensity, 0.15f * lightIntensity, 0.4f * lightIntensity); + } + else if (NPC.type == NPCID.GreenJellyfish) + { + Lighting.AddLight((int)(NPC.Center.X) / 16, (int)(NPC.Center.Y) / 16, 0.05f * lightIntensity, 0.45f * lightIntensity, 0.1f * lightIntensity); + } + else if (NPC.type != NPCID.Squid && NPC.type != NPCID.BloodJelly) + { + Lighting.AddLight((int)(NPC.Center.X) / 16, (int)(NPC.Center.Y) / 16, 0.35f * lightIntensity, 0.05f * lightIntensity, 0.2f * lightIntensity); + } + if (NPC.direction == 0) + { + NPC.TargetClosest(true); + } + if (endEarly) + { + return false; + } + if (!NPC.wet) + { + NPC.rotation += NPC.velocity.X * 0.1f; + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X *= 0.98f; + if (Math.Abs(NPC.velocity.X) < 0.01f) + { + NPC.velocity.X = 0f; + } + } + NPC.velocity.Y += 0.2f; + if (NPC.velocity.Y > 10f) + { + NPC.velocity.Y = 10f; + } + NPC.ai[0] = 1f; + return false; + } + // Collision + // Turn around on X collision + if (NPC.collideX) + { + NPC.velocity.X *= 1f; + NPC.direction *= -1; + } + // Manipulate the sign of the Y velocity + if (NPC.collideY) + { + if (NPC.velocity.Y > 0f) + { + NPC.velocity.Y = Math.Abs(NPC.velocity.Y) * -1f; + NPC.directionY = -1; + NPC.ai[0] = -1f; + } + else if (NPC.velocity.Y < 0f) + { + NPC.velocity.Y = Math.Abs(NPC.velocity.Y); + NPC.directionY = 1; + NPC.ai[0] = 1f; + } + } + bool targetInWater = false; + if (!NPC.friendly) + { + NPC.TargetClosest(false); + if ((Main.player[NPC.target].wet || (CalamityWorld.death && NPC.Distance(Main.player[NPC.target].Center) < 400f)) && !Main.player[NPC.target].dead) + { + targetInWater = true; + } + } + // Slow down. When slow enough, charge again. + if (targetInWater) + { + NPC.localAI[2] = 1f; + NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; + NPC.velocity *= 0.96f; + float minimumSpeed = 0.2f; + if (NPC.type == NPCID.GreenJellyfish) + { + NPC.velocity *= 0.98f; + minimumSpeed = 0.6f; + } + if (NPC.type == NPCID.Squid) + { + NPC.velocity *= 0.99f; + minimumSpeed = 1f; + } + if (NPC.type == NPCID.BloodJelly) + { + NPC.velocity *= 0.995f; + minimumSpeed = 3f; + } + minimumSpeed *= 0.8f; + if (NPC.velocity.Length() < minimumSpeed) + { + if (NPC.type == NPCID.Squid) + { + NPC.localAI[0] = 1f; + } + NPC.TargetClosest(true); + + float lungeSpeed = NPC.type == NPCID.GreenJellyfish ? 18f : 14f; + NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center, -Vector2.UnitY) * lungeSpeed; + } + } + // General floating around. + else + { + NPC.localAI[2] = 0f; + NPC.velocity.X += NPC.direction * 0.02f; + NPC.rotation = NPC.velocity.X * 0.4f; + if (NPC.velocity.X < -1f || NPC.velocity.X > 1f) + { + NPC.velocity.X *= 0.95f; + } + if (NPC.ai[0] == -1f) + { + NPC.velocity.Y -= 0.01f; + if (NPC.velocity.Y < -1f) + { + NPC.ai[0] = 1f; + } + } + else + { + NPC.velocity.Y += 0.01f; + if (NPC.velocity.Y > 1f) + { + NPC.ai[0] = -1f; + } + } + int x = (int)NPC.Center.X / 16; + int y = (int)NPC.Center.Y / 16; + if (Main.tile[x, y - 1].LiquidAmount > 128) + { + if (Main.tile[x, y + 1].HasTile) + { + NPC.ai[0] = -1f; + } + else if (Main.tile[x, y + 2].HasTile) + { + NPC.ai[0] = -1f; + } + } + else + { + NPC.ai[0] = 1f; + } + if (Math.Abs(NPC.velocity.Y) > 1.2) + { + NPC.velocity.Y *= 0.99f; + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MartianProbeAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MartianProbeAI.cs new file mode 100644 index 0000000000..41c068723c --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MartianProbeAI.cs @@ -0,0 +1,124 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class MartianProbeAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + // Float around + if (NPC.ai[0] == 0f) + { + if (NPC.direction == 0) + { + NPC.TargetClosest(true); + NPC.netUpdate = true; + } + + if (NPC.collideX) + { + NPC.direction = -NPC.direction; + NPC.netUpdate = true; + } + + NPC.velocity.X = 6f * (float)NPC.direction; + Point centerTileCoords = NPC.Center.ToTileCoordinates(); + int distanceFromGround = 30; + + if (WorldGen.InWorld(centerTileCoords.X, centerTileCoords.Y, 30)) + { + for (int y = 0; y < 30; y++) + { + if (WorldGen.SolidTile(centerTileCoords.X, centerTileCoords.Y + y)) + { + distanceFromGround = y; + break; + } + } + } + + if (distanceFromGround < 15) + { + NPC.velocity.Y = Math.Max(NPC.velocity.Y - 0.05f, -3.5f); + } + else if (distanceFromGround < 20) + { + NPC.velocity.Y *= 0.95f; + } + else + { + NPC.velocity.Y = Math.Min(NPC.velocity.Y + 0.05f, 1.5f); + } + + int playerIndex = NPC.FindClosestPlayer(out float distanceFromPlayer); + if (playerIndex == -1 || Main.player[playerIndex].dead) + { + return false; + } + + // If a player is below and nearby the probe, become active + if (distanceFromPlayer < 440f && Main.player[playerIndex].Center.Y > NPC.Center.Y) + { + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + } + // Wait + else if (NPC.ai[0] == 1f) + { + NPC.ai[1] += 1f; + + NPC.velocity *= 0.93f; + + if (NPC.ai[1] >= (CalamityWorld.death ? 5f : 45f)) + { + NPC.ai[1] = 0f; + NPC.ai[0] = 2f; + + int closetPlayer = NPC.FindClosestPlayer(); + // Update the X acceleration + NPC.ai[3] = closetPlayer != -1 ? (Main.player[closetPlayer].Center.X < NPC.Center.X).ToDirectionInt() : 1f; + + NPC.netUpdate = true; + } + } + // And fly away + else if (NPC.ai[0] == 2f) + { + NPC.noTileCollide = true; + + NPC.ai[1] += 1f; + + NPC.velocity.Y = Math.Max(NPC.velocity.Y - 0.2f, -12f); + NPC.velocity.X = Math.Min(NPC.velocity.X + NPC.ai[3] * 0.1f, 6f); + + // If above the world or enough time has passed, summon the naked grey gods. + if ((NPC.position.Y < -NPC.height || NPC.ai[1] >= 135f) && Main.netMode != NetmodeID.MultiplayerClient) + { + Main.StartInvasion(InvasionID.MartianMadness); + NPC.active = false; + NPC.netUpdate = true; + } + } + + Vector3 lightColor = Color.SkyBlue.ToVector3(); + if (NPC.ai[0] == 2f) + { + lightColor = Color.Red.ToVector3(); + } + lightColor *= 0.65f; + + Lighting.AddLight(NPC.Center, lightColor); + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MimicAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MimicAI.cs new file mode 100644 index 0000000000..f069862f89 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MimicAI.cs @@ -0,0 +1,137 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class MimicAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + bool isLostHoppingPresent = NPC.type == NPCID.PresentMimic && !Main.snowMoon; + + if (NPC.ai[3] == 0f) + { + NPC.position.X += 8f; + if (NPC.position.Y / 16f > Main.UnderworldLayer) + { + NPC.ai[3] = 3f; + } + else if (NPC.position.Y / 16f > Main.worldSurface) + { + NPC.TargetClosest(true); + NPC.ai[3] = 2f; + } + else + { + NPC.ai[3] = 1f; + } + } + + // Never wait. Go straight for the player. + if (NPC.type == NPCID.PresentMimic || NPC.type == NPCID.IceMimic) + { + NPC.ai[3] = 1f; + } + + NPC.dontTakeDamage = NPC.ai[0] == 0f; + + // Sitting around, waiting for a potential player + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (!isLostHoppingPresent) + { + NPC.TargetClosest(true); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.velocity.X != 0f || NPC.velocity.Y < 0f || NPC.velocity.Y > 0.3f) + { + NPC.ai[0] = 1f; + NPC.netUpdate = true; + return false; + } + + Rectangle detectionZone = new Rectangle((int)NPC.position.X - 80, (int)NPC.position.Y - 80, NPC.width + 160, NPC.height + 160); + // If a player is nearby, become active. + if (detectionZone.Intersects(Main.player[NPC.target].Hitbox) || NPC.life < NPC.lifeMax) + { + NPC.ai[0] = 1f; + NPC.netUpdate = true; + } + } + } + else if (NPC.velocity.Y == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[2] += 1f; + + int timeSpentStopping = 20; + if (NPC.ai[1] == 0f) + { + timeSpentStopping = 12; + } + if (NPC.ai[2] < timeSpentStopping) + { + NPC.velocity.X *= 0.9f; + return false; + } + + NPC.ai[2] = 0f; + + if (!isLostHoppingPresent) + { + NPC.TargetClosest(true); + } + if (NPC.direction == 0) + { + NPC.direction = -1; + } + + NPC.spriteDirection = NPC.direction; + + NPC.ai[1] += 1f; + // Hop + if (NPC.ai[1] == 2f) + { + NPC.velocity.X = NPC.direction * 4f; + NPC.velocity.Y = -8f; + NPC.ai[1] = 0f; + } + else + { + NPC.velocity.X = NPC.direction * 5.5f; + NPC.velocity.Y = -4f; + } + + NPC.netUpdate = true; + } + else + { + // Set damage + NPC.damage = NPC.defDamage; + + if (NPC.direction == 1 && NPC.velocity.X < 1f) + { + NPC.velocity.X += 0.1f; + return false; + } + + if (NPC.direction == -1 && NPC.velocity.X > -1f) + { + NPC.velocity.X -= 0.1f; + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MothronEggAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MothronEggAI.cs new file mode 100644 index 0000000000..f2a3216af9 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/MothronEggAI.cs @@ -0,0 +1,70 @@ +using System; +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class MothronEggAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + // Define what exactly is going to be shit out of this egg when it's ready. + if (NPC.ai[1] == 0f) + { + NPC.ai[1] = (Main.rand.NextBool(10) && NPC.CountNPCS(NPCID.Mothron) < 2) ? NPCID.Mothron : NPCID.MothronSpawn; + + if ((int)NPC.ai[1] == NPCID.Mothron) + { + NPC.defense = (int)Math.Round(NPC.defDefense * 1.5); + NPC.scale *= 2f; + NPC.width = NPC.height = (int)(34f * NPC.scale); + NPC.netUpdate = true; + } + } + + // Fall to the side like a sack of potatoes + if (NPC.velocity.Y == 0f) + { + NPC.velocity.X *= 0.9f; + NPC.rotation += NPC.velocity.X * 0.02f; + } + else + { + NPC.velocity.X *= 0.99f; + NPC.rotation += NPC.velocity.X * 0.04f; + } + + // How much time is needed before the egg hatches + float hatchTimer = ((int)NPC.ai[1] == NPCID.Mothron ? 480f : 240f); + if (CalamityWorld.death) + hatchTimer *= 0.5f; + + NPC.ai[0] += 1f; + if (NPC.ai[0] >= hatchTimer) + { + int hatchType = NPC.CountNPCS(NPCID.Mothron) < 2 ? (int)NPC.ai[1] : NPCID.MothronSpawn; + NPC.Transform(hatchType); + } + + // Jump around sometimes + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.velocity.Y == 0f && Math.Abs(NPC.velocity.X) < 0.2f && NPC.ai[0] >= hatchTimer * 0.75f) + { + float hatchCompleteness = NPC.ai[0] - hatchTimer * 0.75f; + hatchCompleteness /= hatchTimer * 0.25f; + if (Main.rand.Next(-10, 120) < hatchCompleteness * 100f) + { + NPC.velocity.Y -= Main.rand.Next(20, 40) * 0.025f; + NPC.velocity.X += Main.rand.Next(-20, 20) * 0.025f; + NPC.velocity *= 1f + hatchCompleteness * 2f; + NPC.netUpdate = true; + } + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/PlantAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/PlantAI.cs new file mode 100644 index 0000000000..b2e0a13494 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/PlantAI.cs @@ -0,0 +1,213 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class PlantAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.ai[0] < 0f || NPC.ai[0] >= (float)Main.maxTilesX || NPC.ai[1] < 0f || NPC.ai[1] >= (float)Main.maxTilesX) + return false; + + if (!Main.tile[(int)NPC.ai[0], (int)NPC.ai[1]].HasTile) + { + NPC.life = -1; + NPC.HitEffect(0, 10.0); + NPC.active = false; + return false; + } + + FixExploitManEaters.ProtectSpot((int)NPC.ai[0], (int)NPC.ai[1]); + + NPC.TargetClosest(); + + float acceleration = 0.035f; + float minDistance = 250f; + switch (NPC.type) + { + case NPCID.ManEater: + minDistance = 350f; + break; + case NPCID.Clinger: + minDistance = 225f; + break; + case NPCID.FungiBulb: + minDistance = !CalamityWorld.revenge ? 100f : 200f; + break; + case NPCID.AngryTrapper: + acceleration = 0.05f; + minDistance = 500f; + break; + case NPCID.GiantFungiBulb: + acceleration = 0.15f; + minDistance = CalamityWorld.revenge ? 450f : 350f; + break; + } + + if (CalamityWorld.death) + { + acceleration *= 1.25f; + minDistance *= 1.25f; + } + + float maxVelocity = 2f + + (NPC.type == NPCID.ManEater ? 1f : 0f) + + (NPC.type == NPCID.AngryTrapper ? 2f : 0f); + + NPC.ai[2] += 1f; + if (NPC.ai[2] > 300f) + { + minDistance *= 1.3f; + + if (CalamityWorld.revenge) + maxVelocity += 2f; + + if (NPC.ai[2] > 450f) + NPC.ai[2] = 0f; + } + + Vector2 anchorPosition = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); + Vector2 distanceVector = Main.player[NPC.target].Center - anchorPosition; + float distanceMagnitude = distanceVector.Length(); + if (distanceMagnitude > minDistance) + { + float normalizedMagnitude = minDistance / distanceMagnitude; + distanceVector *= normalizedMagnitude; + } + + if (NPC.position.X < NPC.ai[0] * 16f + 8f + distanceVector.X) + { + NPC.velocity.X += acceleration; + if (NPC.velocity.X < 0f && distanceVector.X > 0f) + NPC.velocity.X += acceleration * 1.5f; + } + else if (NPC.position.X > NPC.ai[0] * 16f + 8f + distanceVector.X) + { + NPC.velocity.X -= acceleration; + if (NPC.velocity.X > 0f && distanceVector.X < 0f) + NPC.velocity.X -= acceleration * 1.5f; + } + if (NPC.position.Y < NPC.ai[1] * 16f + 8f + distanceVector.Y) + { + NPC.velocity.Y += acceleration; + if (NPC.velocity.Y < 0f && distanceVector.Y > 0f) + NPC.velocity.Y += acceleration * 1.5f; + } + else if (NPC.position.Y > NPC.ai[1] * 16f + 8f + distanceVector.Y) + { + NPC.velocity.Y -= acceleration; + if (NPC.velocity.Y > 0f && distanceVector.Y < 0f) + NPC.velocity.Y -= acceleration * 1.5f; + } + + NPC.velocity = Vector2.Clamp(NPC.velocity, new Vector2(-maxVelocity), new Vector2(maxVelocity)); + + if (NPC.type == NPCID.FungiBulb || NPC.type == NPCID.GiantFungiBulb) + { + NPC.rotation = NPC.AngleTo(Main.player[NPC.target].Center) + MathHelper.PiOver2; + } + else + { + NPC.spriteDirection = (distanceVector.X > 0f).ToDirectionInt(); + NPC.rotation = NPC.AngleTo(Main.player[NPC.target].Center) + (distanceVector.X < 0f).ToInt() * MathHelper.Pi; + } + + if (NPC.collideX) + { + NPC.netUpdate = true; + NPC.velocity.X = NPC.oldVelocity.X * -0.7f; + if (NPC.velocity.X > 0f && NPC.velocity.X < 2f) + NPC.velocity.X = 2f; + if (NPC.velocity.X < 0f && NPC.velocity.X > -2f) + NPC.velocity.X = -2f; + } + if (NPC.collideY) + { + NPC.netUpdate = true; + NPC.velocity.Y = NPC.oldVelocity.Y * -0.7f; + if (NPC.velocity.Y > 0f && NPC.velocity.Y < 2f) + NPC.velocity.Y = 2f; + if (NPC.velocity.Y < 0f && NPC.velocity.Y > -2f) + NPC.velocity.Y = -2f; + } + + if ((NPC.type == NPCID.GiantFungiBulb || NPC.type == NPCID.FungiBulb) && !Main.player[NPC.target].DeadOrGhost) + { + if (NPC.localAI[0] > ((NPC.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? GiantFungiBulbSporeShootGateValue_Rev : GiantFungiBulbSporeShootGateValue) : FungiBulbSporeShootGateValue) - FungiBulbSporeTelegraphTime)) + { + Vector2 dustCenter = NPC.Center + NPC.SafeDirectionTo(Main.player[NPC.target].Center, -Vector2.UnitY) * (NPC.type == NPCID.GiantFungiBulb ? 20f : 12f) + Main.rand.NextVector2CircularEdge(5f, 5f); + Dust dust = Dust.NewDustDirect(dustCenter, 1, 1, DustID.BlueTorch, 0f, 0f, 100, default, 3f); + dust.noGravity = true; + dust.velocity *= 0f; + } + + if (NPC.localAI[0] == (NPC.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? GiantFungiBulbSporeShootGateValue_Rev : GiantFungiBulbSporeShootGateValue) : FungiBulbSporeShootGateValue) - 1) + SoundEngine.PlaySound(SoundID.Item17, NPC.Center); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.type == NPCID.Clinger && !Main.player[NPC.target].DeadOrGhost) + { + if (NPC.justHit) + NPC.localAI[0] = 0f; + + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= ClingerShootGateValue_Rev) + { + if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + int damage = 17; + int type = ProjectileID.CursedFlameHostile; + Vector2 flameVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center, -Vector2.UnitY) * 12f; + + int flame = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, flameVelocity, type, damage, 0f, Main.myPlayer); + Main.projectile[flame].timeLeft = 180; + NPC.localAI[0] = 0f; + } + else + NPC.localAI[0] = ClingerShootGateValue_Rev - 15f; + } + } + + if ((NPC.type == NPCID.GiantFungiBulb || NPC.type == NPCID.FungiBulb) && !Main.player[NPC.target].DeadOrGhost) + { + if (NPC.justHit || Collision.SolidCollision(NPC.position, NPC.width, NPC.height) || !Collision.CanHit(NPC, Main.player[NPC.target])) + NPC.localAI[0] = 0f; + + NPC.localAI[0] += 1f; + float sporeSpawnGateValue = NPC.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? GiantFungiBulbSporeShootGateValue_Rev : GiantFungiBulbSporeShootGateValue) : FungiBulbSporeShootGateValue; + if (NPC.localAI[0] >= sporeSpawnGateValue) + { + if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && Collision.CanHit(NPC, Main.player[NPC.target])) + { + float speed = NPC.type == NPCID.GiantFungiBulb ? (CalamityWorld.revenge ? 16f : 14f) : 8f; + distanceVector.X = Main.player[NPC.target].Center.X - NPC.Center.X; + float absoluteYDistance = Math.Abs(distanceVector.X * 0.1f); + if (Main.player[NPC.target].Center.Y - NPC.Center.Y > 0f) + absoluteYDistance = 0f; + + Vector2 velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center - NPC.Center - Vector2.UnitY * absoluteYDistance, -Vector2.UnitY) * speed; + + int idx = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.FungiSpore); + Main.npc[idx].velocity = velocity; + Main.npc[idx].netUpdate = true; + } + + NPC.localAI[0] = 0f; + } + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/RevengeanceAndDeathAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/RevengeanceAndDeathAI.cs new file mode 100644 index 0000000000..944ddda508 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/RevengeanceAndDeathAI.cs @@ -0,0 +1,63 @@ +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + #region Constants + + public const float ClingerShootGateValue = 120f; + public const float ClingerShootGateValue_Rev = 90f; + public const float ClingerTelegraphTime = 30f; + + public const float IchorStickerShootGateValue = 120f; + public const float IchorStickerShootGateValue_Rev = 90f; + public const float IchorStickerShootGateValue_Death = 60f; + public const float IchorStickerTelegraphTime = 30f; + + public const float SpiderWebSpitGateValue = 420f; + public const float SpiderWebSpitGateValue_Rev = 300f; + public const float SpiderWebSpitGateValue_Death = 180f; + public const float SpiderWebSpitTelegraphTime = 30f; + + public const float AntlionSandSpitGateValue = 200f; + public const float AntlionSandSpitTelegraphTime = 30f; + + public const float BlazingWheelFlameGateValue = 120f; + public const float BlazingWheelFlameGateValue_Death = 90f; + public const float BlazingWheelTelegraphTime = 30f; + + public const float HarpyFeatherGateValue = 600f; + public const float HarpyFeatherTelegraphTime = 30f; + + public const float DemonScytheGateValue = 450f; + public const float DemonScytheTelegraphTime = 30f; + + public const float RedDevilTridentGateValue = 375f; + public const float RedDevilTridentTelegraphTime = 30f; + + public const float IceElementalFrostBlastGateValue = 180f; + public const float IceElementalFrostBlastGateValue_Death = 120f; + public const float IceElementalFrostBlastTelegraphTime = 30f; + + public const float FungiBulbSporeShootGateValue = 240f; + public const float GiantFungiBulbSporeShootGateValue = 150f; + public const float GiantFungiBulbSporeShootGateValue_Rev = 120f; + public const float FungiBulbSporeTelegraphTime = 30f; + + public const float CorruptorVileSpitGateValue = 180f; + public const float CorruptorVileSpitTelegraphTime = 30f; + + public const float BloodSquidBloodShotGateValue = 120f; + public const float BloodSquidBloodShotTelegraphTime = 30f; + + public const float IceGolemFrostBeamGateValue = 120f; + public const float IceGolemFrostBeamGateValue_Rev = 90f; + public const float IceGolemFrostBeamGateValue_Death = 60f; + public const float IceGolemFrostBeamTelegraphTime = 30f; + + public const float EyezorLaserGateValue = 120f; + public const float EyezorLaserGateValue_Rev = 90f; + public const float EyezorLaserGateValue_Death = 60f; + public const float EyezorLaserTelegraphTime = 30f; + + #endregion +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SmallStarCellAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SmallStarCellAI.cs new file mode 100644 index 0000000000..e5b19e4a9b --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SmallStarCellAI.cs @@ -0,0 +1,65 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class SmallStarCellAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + float turnBigDelay = CalamityWorld.death ? 100f : 200f; + if (NPC.velocity.Length() > 4f) + NPC.velocity *= 0.95f; + + NPC.velocity *= 0.99f; + NPC.ai[0]++; + float cellScale = MathHelper.Clamp(NPC.ai[0] / turnBigDelay, 0f, 1f); + NPC.scale = 1f + 0.3f * cellScale; + if (NPC.ai[0] >= turnBigDelay) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.Transform(NPCID.StardustCellBig); + NPC.netUpdate = true; + } + + return false; + } + + NPC.rotation += NPC.velocity.X * 0.1f; + if (!(NPC.ai[0] > 20f)) + return false; + + Vector2 cellCenter = NPC.Center; + int dustAmt = (int)(NPC.ai[0] / (turnBigDelay / 2f)); + for (int i = 0; i < dustAmt + 1; i++) + { + if (Main.rand.NextBool()) + { + float dustScale = 0.4f; + if (i % 2 == 1) + { + dustScale = 0.65f; + } + + Vector2 dustRotation = cellCenter + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - dustAmt * 2); + int cellDust = Dust.NewDust(dustRotation - Vector2.One * 12f, 24, 24, DustID.Electric, NPC.velocity.X / 2f, NPC.velocity.Y / 2f); + Dust dust = Main.dust[cellDust]; + dust.position -= new Vector2(2f); + Main.dust[cellDust].velocity = Vector2.Normalize(cellCenter - dustRotation) * 1.5f * (10f - dustAmt * 2f) / 10f; + Main.dust[cellDust].noGravity = true; + Main.dust[cellDust].scale = dustScale; + Main.dust[cellDust].customData = NPC; + } + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpiderAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpiderAI.cs new file mode 100644 index 0000000000..8e506b1d93 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpiderAI.cs @@ -0,0 +1,266 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class SpiderAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + //Find a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) + { + NPC.TargetClosest(true); + } + + float speed = 2.5f; + float mvtAdjust = 0.1f; + if (NPC.type == NPCID.DesertScorpionWall) + { + speed = 5f; + mvtAdjust = 0.2f; + } + if (CalamityWorld.death) + { + speed *= 1.25f; + mvtAdjust *= 1.25f; + } + + //Calculate how to reach the target + Vector2 npcPos = NPC.Center; + Vector2 targetPos = Main.player[NPC.target].Center; + targetPos.X = (float)((int)(targetPos.X / 8f) * 8); + targetPos.Y = (float)((int)(targetPos.Y / 8f) * 8); + npcPos.X = (float)((int)(npcPos.X / 8f) * 8); + npcPos.Y = (float)((int)(npcPos.Y / 8f) * 8); + targetPos.X -= npcPos.X; + targetPos.Y -= npcPos.Y; + float targetDist = targetPos.Length(); + if (targetDist == 0f) + { + targetPos.X = NPC.velocity.X; + targetPos.Y = NPC.velocity.Y; + } + else + { + targetDist = speed / targetDist; + targetPos.X *= targetDist; + targetPos.Y *= targetDist; + } + + //If the target is dead, nobody cares + if (Main.player[NPC.target].dead) + { + targetPos.X = (float)NPC.direction * speed / 2f; + targetPos.Y = -speed / 2f; + } + + //Sprite direction + NPC.spriteDirection = -1; + + //If you can't see the target, wander around + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + { + NPC.ai[0] += 1f; + if (NPC.ai[0] > 0f) + { + NPC.velocity.Y += 0.023f; + } + else + { + NPC.velocity.Y -= 0.023f; + } + if (NPC.ai[0] < -100f || NPC.ai[0] > 100f) + { + NPC.velocity.X += 0.023f; + } + else + { + NPC.velocity.X -= 0.023f; + } + if (NPC.ai[0] > 200f) + { + NPC.ai[0] = -200f; + } + NPC.velocity.X += targetPos.X * 0.009f; + NPC.velocity.Y += targetPos.Y * 0.009f; + NPC.rotation = NPC.velocity.ToRotation(); + if (NPC.velocity.X > 2.5f) + { + NPC.velocity.X *= 0.9f; + } + if (NPC.velocity.X < -2.5f) + { + NPC.velocity.X *= 0.9f; + } + if (NPC.velocity.Y > 2.5f) + { + NPC.velocity.Y *= 0.9f; + } + if (NPC.velocity.Y < -2.5f) + { + NPC.velocity.Y *= 0.9f; + } + NPC.velocity.X = MathHelper.Clamp(NPC.velocity.X, -4f, 4f); + NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y, -4f, 4f); + } + //If target is in sight, move toward target + else + { + if (NPC.velocity.X < targetPos.X) + { + NPC.velocity.X += mvtAdjust; + if (NPC.velocity.X < 0f && targetPos.X > 0f) + { + NPC.velocity.X += mvtAdjust; + } + } + else if (NPC.velocity.X > targetPos.X) + { + NPC.velocity.X -= mvtAdjust; + if (NPC.velocity.X > 0f && targetPos.X < 0f) + { + NPC.velocity.X -= mvtAdjust; + } + } + if (NPC.velocity.Y < targetPos.Y) + { + NPC.velocity.Y += mvtAdjust; + if (NPC.velocity.Y < 0f && targetPos.Y > 0f) + { + NPC.velocity.Y += mvtAdjust; + } + } + else if (NPC.velocity.Y > targetPos.Y) + { + NPC.velocity.Y -= mvtAdjust; + if (NPC.velocity.Y > 0f && targetPos.Y < 0f) + { + NPC.velocity.Y -= mvtAdjust; + } + } + NPC.rotation = targetPos.ToRotation(); + } + + //Desert Scorpion has a different sprite orientation + if (NPC.type == NPCID.DesertScorpionWall) + { + NPC.rotation += MathHelper.PiOver2; + } + + //Wall collision behavior? + float half = 0.5f; + if (NPC.collideX) + { + NPC.netUpdate = true; + NPC.velocity.X = NPC.oldVelocity.X * -half; + if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) + { + NPC.velocity.X = 2f; + } + if (NPC.direction == 1 && NPC.velocity.X < 0f && NPC.velocity.X > -2f) + { + NPC.velocity.X = -2f; + } + } + if (NPC.collideY) + { + NPC.netUpdate = true; + NPC.velocity.Y = NPC.oldVelocity.Y * -half; + if (NPC.velocity.Y > 0f && NPC.velocity.Y < 1.5f) + { + NPC.velocity.Y = 2f; + } + if (NPC.velocity.Y < 0f && NPC.velocity.Y > -1.5f) + { + NPC.velocity.Y = -2f; + } + } + + // Net update for changing directions + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + { + NPC.netUpdate = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + bool prehardmodeSpiders = (NPC.type == NPCID.WallCreeper || NPC.type == NPCID.WallCreeperWall || NPC.type == NPCID.BloodCrawler || NPC.type == NPCID.BloodCrawlerWall) && CalamityWorld.revenge; + if (NPC.target >= 0 && Main.expertMode && (NPC.type == NPCID.BlackRecluse || NPC.type == NPCID.BlackRecluseWall || NPC.type == NPCID.JungleCreeper || NPC.type == NPCID.JungleCreeperWall || prehardmodeSpiders) && + Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.localAI[0] += 1f; + if (NPC.justHit) + NPC.localAI[0] = 0f; + + float webSpitGateValue = CalamityWorld.death ? SpiderWebSpitGateValue_Death : CalamityWorld.revenge ? SpiderWebSpitGateValue_Rev : SpiderWebSpitGateValue; + + // Emit web dust from mouth when about to fire + if (NPC.localAI[0] > webSpitGateValue - SpiderWebSpitTelegraphTime) + { + Dust dust = Dust.NewDustDirect(NPC.Center, 1, 1, DustID.Web, 0f, 0f, 100, default, 1.5f); + dust.noGravity = true; + dust.velocity *= 0f; + } + + if (NPC.localAI[0] >= webSpitGateValue) + { + NPC.localAI[0] = 0f; + Vector2 velocity = Main.player[NPC.target].Center - NPC.Center; + velocity.Normalize(); + velocity *= prehardmodeSpiders ? 5f : 8f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, ProjectileID.WebSpit, 18, 0f, Main.myPlayer); + } + } + else + NPC.localAI[0] = 0f; + + // Check for walls + int npcX = (int)NPC.Center.X / 16; + int npcY = (int)NPC.Center.Y / 16; + bool climbingWall = false; + for (int i = npcX - 1; i <= npcX + 1; i++) + { + for (int j = npcY - 1; j <= npcY + 1; j++) + { + if (Main.tile[i, j].WallType > WallID.None) + { + climbingWall = true; + } + } + } + //If not on a wall, transform to fighter form + if (!climbingWall) + { + if (NPC.type == NPCID.JungleCreeperWall) + { + NPC.Transform(NPCID.JungleCreeper); + return false; + } + if (NPC.type == NPCID.BlackRecluseWall) + { + NPC.Transform(NPCID.BlackRecluse); + return false; + } + if (NPC.type == NPCID.BloodCrawlerWall) + { + NPC.Transform(NPCID.BloodCrawler); + return false; + } + if (NPC.type == NPCID.DesertScorpionWall) + { + NPC.Transform(NPCID.DesertScorpionWalk); + return false; + } + NPC.Transform(NPCID.WallCreeper); + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpikeBallAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpikeBallAI.cs new file mode 100644 index 0000000000..f97de716dc --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SpikeBallAI.cs @@ -0,0 +1,92 @@ +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class SpikeBallAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.ai[0] == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.TargetClosest(true); + NPC.direction *= -1; + NPC.directionY *= -1; + NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2 + 8); + NPC.ai[1] = NPC.position.X + (float)(NPC.width / 2); + NPC.ai[2] = NPC.position.Y + (float)(NPC.height / 2); + if (NPC.direction == 0) + { + NPC.direction = 1; + } + if (NPC.directionY == 0) + { + NPC.directionY = 1; + } + NPC.ai[3] = 1f + (float)Main.rand.Next(15) * 0.1f; + NPC.velocity.Y = (float)(NPC.directionY * 6) * NPC.ai[3]; + NPC.ai[0] += 1f; + NPC.netUpdate = true; + return false; + } + NPC.ai[1] = NPC.position.X + (float)(NPC.width / 2); + NPC.ai[2] = NPC.position.Y + (float)(NPC.height / 2); + } + else + { + float maxSpinSpeed = (CalamityWorld.death ? 12f : 9f) * NPC.ai[3]; + float spinAcceleration = (CalamityWorld.death ? 0.4f : 0.3f) * NPC.ai[3]; + float timeToReachMaxSpeed = maxSpinSpeed / spinAcceleration / 2f; + if (NPC.ai[0] >= 1f && NPC.ai[0] < (float)((int)timeToReachMaxSpeed)) + { + NPC.velocity.Y = (float)NPC.directionY * maxSpinSpeed; + NPC.ai[0] += 1f; + return false; + } + if (NPC.ai[0] >= (float)((int)timeToReachMaxSpeed)) + { + NPC.velocity.Y = 0f; + NPC.directionY *= -1; + NPC.velocity.X = maxSpinSpeed * (float)NPC.direction; + NPC.ai[0] = -1f; + return false; + } + if (NPC.directionY > 0) + { + if (NPC.velocity.Y >= maxSpinSpeed) + { + NPC.directionY *= -1; + NPC.velocity.Y = maxSpinSpeed; + } + } + else if (NPC.directionY < 0 && NPC.velocity.Y <= -maxSpinSpeed) + { + NPC.directionY *= -1; + NPC.velocity.Y = -maxSpinSpeed; + } + if (NPC.direction > 0) + { + if (NPC.velocity.X >= maxSpinSpeed) + { + NPC.direction *= -1; + NPC.velocity.X = maxSpinSpeed; + } + } + else if (NPC.direction < 0 && NPC.velocity.X <= -maxSpinSpeed) + { + NPC.direction *= -1; + NPC.velocity.X = -maxSpinSpeed; + } + NPC.velocity.X = NPC.velocity.X + spinAcceleration * (float)NPC.direction; + NPC.velocity.Y = NPC.velocity.Y + spinAcceleration * (float)NPC.directionY; + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SporeAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SporeAI.cs new file mode 100644 index 0000000000..1fd9b30a1c --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SporeAI.cs @@ -0,0 +1,67 @@ +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class SporeAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.type == NPCID.Spore) + Lighting.AddLight(NPC.Center, 0.5f, 0.2f, 0.5f); + + if (NPC.timeLeft > 5) + NPC.timeLeft = 5; + + NPC.noTileCollide = true; + NPC.velocity.Y += 0.02f; + + // Ensure slow fall + if (NPC.velocity.Y > 1f) + NPC.velocity.Y = 1f; + + // Use regular AI if not spawned by a Giant Plantera Bulb + if (NPC.ai[0] != -1f) + { + NPC.TargetClosest(true); + float acceleration = CalamityWorld.death ? 0.25f : Main.expertMode ? 0.2f : 0.1f; + float velocity = CalamityWorld.death ? 6.25f : Main.expertMode ? 5f : 3f; + + // Simple movement AI. You shouldn't need any help from comments to parse this. + if (NPC.Center.X < Main.player[NPC.target].position.X) + { + if (NPC.velocity.X < 0f) + { + NPC.velocity.X *= 0.96f; + } + NPC.velocity.X += acceleration; + } + else if (NPC.position.X > Main.player[NPC.target].Center.X) + { + if (NPC.velocity.X > 0f) + { + NPC.velocity.X *= 0.96f; + } + NPC.velocity.X -= acceleration; + } + if (NPC.velocity.X > velocity || NPC.velocity.X < -velocity) + { + NPC.velocity.X *= 0.97f; + } + } + else + { + NPC.velocity.X *= 0.98f; + NPC.damage = NPC.defDamage = 0; + } + + NPC.rotation = NPC.velocity.X * 0.2f; + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/StarCellAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/StarCellAI.cs new file mode 100644 index 0000000000..81e57f4d08 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/StarCellAI.cs @@ -0,0 +1,306 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class StarCellAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.noTileCollide = false; + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + if (NPC.type == NPCID.DeadlySphere || NPC.type == NPCID.NebulaHeadcrab) + NPC.damage = 0; + + NPC.TargetClosest(); + if (Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[0] = 1f; + } + else + { + Vector2 cellTargetDirection = Main.player[NPC.target].Center - NPC.Center; + cellTargetDirection.Y -= Main.player[NPC.target].height / 4; + float cellTargetDist = cellTargetDirection.Length(); + if (cellTargetDist > 800f) + { + NPC.ai[0] = 2f; + } + else + { + Vector2 cellCenter = NPC.Center; + cellCenter.X = Main.player[NPC.target].Center.X; + Vector2 cellFaceDirection = cellCenter - NPC.Center; + if (cellFaceDirection.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, cellCenter, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = cellCenter.X; + NPC.ai[2] = cellCenter.Y; + Vector2 cellCenter2 = NPC.Center; + cellCenter2.Y = Main.player[NPC.target].Center.Y; + if (cellFaceDirection.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, cellCenter2, 1, 1) && Collision.CanHit(cellCenter2, 1, 1, Main.player[NPC.target].position, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = cellCenter2.X; + NPC.ai[2] = cellCenter2.Y; + } + } + else + { + cellCenter = NPC.Center; + cellCenter.Y = Main.player[NPC.target].Center.Y; + if ((cellCenter - NPC.Center).Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, cellCenter, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = cellCenter.X; + NPC.ai[2] = cellCenter.Y; + } + } + + if (NPC.ai[0] == 0f) + { + NPC.localAI[0] = 0f; + cellTargetDirection.Normalize(); + cellTargetDirection *= 0.5f; + NPC.velocity += cellTargetDirection; + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + } + } + } + } + else if (NPC.ai[0] == 1f) + { + // Set damage or avoid cheap bullshit + if (NPC.type == NPCID.DeadlySphere) + NPC.damage = NPC.defDamage; + else if (NPC.type == NPCID.NebulaHeadcrab) + NPC.damage = 0; + + NPC.rotation += NPC.direction * 0.3f; + Vector2 attacktargetDirection = Main.player[NPC.target].Center - NPC.Center; + if (NPC.type == NPCID.NebulaHeadcrab) + attacktargetDirection = Main.player[NPC.target].Top - NPC.Center; + + float attackTargetDist = attacktargetDirection.Length(); + float attackVelocity = CalamityWorld.death ? 9f : 7.5f; + attackVelocity += attackTargetDist / 100f; + int attackVelocityMult = CalamityWorld.death ? 40 : 45; + attacktargetDirection.Normalize(); + attacktargetDirection *= attackVelocity; + NPC.velocity = (NPC.velocity * (attackVelocityMult - 1) + attacktargetDirection) / attackVelocityMult; + if (!Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + } + + if (NPC.type == NPCID.NebulaHeadcrab && attackTargetDist < 40f && Main.player[NPC.target].active && !Main.player[NPC.target].dead) + { + bool headcrabAttach = true; + for (int p = 0; p < Main.maxNPCs; p++) + { + NPC nPC7 = Main.npc[p]; + if (nPC7.active && nPC7.type == NPC.type && nPC7.ai[0] == 5f && nPC7.target == NPC.target) + { + headcrabAttach = false; + break; + } + } + + if (headcrabAttach) + { + NPC.Center = Main.player[NPC.target].Top; + NPC.velocity = Vector2.Zero; + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + } + } + else if (NPC.ai[0] == 2f) + { + // Avoid cheap bullshit + if (NPC.type == NPCID.DeadlySphere || NPC.type == NPCID.NebulaHeadcrab) + NPC.damage = 0; + + NPC.rotation = NPC.velocity.X * 0.1f; + NPC.noTileCollide = true; + Vector2 idleTargetDirection = Main.player[NPC.target].Center - NPC.Center; + float idleTargetDist = idleTargetDirection.Length(); + float idleVelocity = CalamityWorld.death ? 6f : 4.5f; + int idleVelocityMult = 2; + idleTargetDirection.Normalize(); + idleTargetDirection *= idleVelocity; + NPC.velocity = (NPC.velocity * (idleVelocityMult - 1) + idleTargetDirection) / idleVelocityMult; + if (idleTargetDist < 600f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.ai[0] = 0f; + } + else if (NPC.ai[0] == 3f) + { + // Avoid cheap bullshit + if (NPC.type == NPCID.DeadlySphere || NPC.type == NPCID.NebulaHeadcrab) + NPC.damage = 0; + + NPC.rotation = NPC.velocity.X * 0.1f; + Vector2 blockedCellCenter = new Vector2(NPC.ai[1], NPC.ai[2]); + Vector2 blockedCellDirection = blockedCellCenter - NPC.Center; + float blockedTargetDist = blockedCellDirection.Length(); + float blockedVelocity = CalamityWorld.death ? 4f : 3f; + float blockedVelocityMult = 2f; + blockedCellDirection.Normalize(); + blockedCellDirection *= blockedVelocity; + NPC.velocity = (NPC.velocity * (blockedVelocityMult - 1f) + blockedCellDirection) / blockedVelocityMult; + if (NPC.collideX || NPC.collideY) + { + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + } + + if (blockedTargetDist < blockedVelocity || blockedTargetDist > 800f || Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + NPC.ai[0] = 0f; + } + else if (NPC.ai[0] == 4f) + { + // Avoid cheap bullshit + if (NPC.type == NPCID.DeadlySphere || NPC.type == NPCID.NebulaHeadcrab) + NPC.damage = 0; + + NPC.rotation = NPC.velocity.X * 0.1f; + if (NPC.collideX) + NPC.velocity.X *= -0.8f; + + if (NPC.collideY) + NPC.velocity.Y *= -0.8f; + + Vector2 smolCellDirection; + if (NPC.velocity.X == 0f && NPC.velocity.Y == 0f) + { + smolCellDirection = Main.player[NPC.target].Center - NPC.Center; + smolCellDirection.Y -= Main.player[NPC.target].height / 4; + smolCellDirection.Normalize(); + NPC.velocity = smolCellDirection * 0.1f; + } + + float smolCellVelocity = CalamityWorld.death ? 4f : 3f; + float smolCellVelocityMult = CalamityWorld.death ? 16f : 18f; + smolCellDirection = NPC.velocity; + smolCellDirection.Normalize(); + smolCellDirection *= smolCellVelocity; + NPC.velocity = (NPC.velocity * (smolCellVelocityMult - 1f) + smolCellDirection) / smolCellVelocityMult; + NPC.ai[1] += 1f; + if (NPC.ai[1] > 180f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + } + + if (Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + NPC.ai[0] = 0f; + + NPC.localAI[0] += 1f; + if (NPC.localAI[0] >= 5f && !Collision.SolidCollision(NPC.position - new Vector2(10f, 10f), NPC.width + 20, NPC.height + 20)) + { + NPC.localAI[0] = 0f; + Vector2 cellCentered = NPC.Center; + cellCentered.X = Main.player[NPC.target].Center.X; + if (Collision.CanHit(NPC.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(NPC.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, cellCentered, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = cellCentered.X; + NPC.ai[2] = cellCentered.Y; + } + else + { + cellCentered = NPC.Center; + cellCentered.Y = Main.player[NPC.target].Center.Y; + if (Collision.CanHit(NPC.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, cellCentered, 1, 1)) + { + NPC.ai[0] = 3f; + NPC.ai[1] = cellCentered.X; + NPC.ai[2] = cellCentered.Y; + } + } + } + } + else if (NPC.ai[0] == 5f) + { + Player player8 = Main.player[NPC.target]; + if (!player8.active || player8.dead) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + else + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.Center = ((player8.gravDir == 1f) ? player8.Top : player8.Bottom) + new Vector2(player8.direction * 4, 0f); + NPC.gfxOffY = player8.gfxOffY; + NPC.velocity = Vector2.Zero; + if (!player8.creativeGodMode) + player8.AddBuff(BuffID.Obstructed, 59); + } + } + + if (NPC.type == NPCID.StardustCellBig) + { + NPC.rotation = 0f; + for (int r = 0; r < Main.maxNPCs; r++) + { + if (r != NPC.whoAmI && Main.npc[r].active && Main.npc[r].type == NPC.type && Math.Abs(NPC.position.X - Main.npc[r].position.X) + Math.Abs(NPC.position.Y - Main.npc[r].position.Y) < NPC.width) + { + if (NPC.position.X < Main.npc[r].position.X) + NPC.velocity.X -= 0.05f; + else + NPC.velocity.X += 0.05f; + + if (NPC.position.Y < Main.npc[r].position.Y) + NPC.velocity.Y -= 0.05f; + else + NPC.velocity.Y += 0.05f; + } + } + } + else + { + if (NPC.type != NPCID.NebulaHeadcrab) + return false; + + NPC.hide = NPC.ai[0] == 5f; + NPC.rotation = NPC.velocity.X * 0.1f; + for (int s = 0; s < Main.maxNPCs; s++) + { + if (s != NPC.whoAmI && Main.npc[s].active && Main.npc[s].type == NPC.type && Math.Abs(NPC.position.X - Main.npc[s].position.X) + Math.Abs(NPC.position.Y - Main.npc[s].position.Y) < NPC.width) + { + if (NPC.position.X < Main.npc[s].position.X) + NPC.velocity.X -= 0.05f; + else + NPC.velocity.X += 0.05f; + + if (NPC.position.Y < Main.npc[s].position.Y) + NPC.velocity.Y -= 0.05f; + else + NPC.velocity.Y += 0.05f; + } + } + } + + return false; + } + } +} + diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SwimmingAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SwimmingAI.cs new file mode 100644 index 0000000000..266246b6fc --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/SwimmingAI.cs @@ -0,0 +1,239 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class SwimmingAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.direction == 0) + { + NPC.TargetClosest(true); + } + if (NPC.wet) + { + bool noWetTargets = false; + NPC.TargetClosest(false); + if ((Main.player[NPC.target].wet || (CalamityWorld.death && NPC.Distance(Main.player[NPC.target].Center) < 400f)) && !Main.player[NPC.target].dead) + { + noWetTargets = true; + } + if (!noWetTargets) + { + if (NPC.collideX) + { + NPC.velocity.X *= -1f; + NPC.direction *= -1; + NPC.netUpdate = true; + } + if (NPC.collideY) + { + NPC.netUpdate = true; + if (NPC.velocity.Y > 0f) + { + NPC.velocity.Y = Math.Abs(NPC.velocity.Y) * -1f; + NPC.directionY = -1; + NPC.ai[0] = -1f; + } + else if (NPC.velocity.Y < 0f) + { + NPC.velocity.Y = Math.Abs(NPC.velocity.Y); + NPC.directionY = 1; + NPC.ai[0] = 1f; + } + } + } + if (NPC.type == NPCID.AnglerFish) + { + Lighting.AddLight((int)(NPC.position.X + (float)(NPC.width / 2) + (float)(NPC.direction * (NPC.width + 8))) / 16, (int)(NPC.position.Y + 2f) / 16, 0.07f, 0.04f, 0.025f); + } + if (noWetTargets) + { + NPC.TargetClosest(true); + if (NPC.type == NPCID.Arapaima) + { + // Check if the direction value signs match + if ((NPC.velocity.X > 0).ToDirectionInt() != (NPC.velocity.X > 0).ToDirectionInt()) + { + NPC.velocity.X *= 0.95f; + } + NPC.velocity.X += NPC.direction * 0.5f; + NPC.velocity.Y += NPC.directionY * 0.4f; + + // I don't really understand why a boundary break penalty of 2 is used here, but just to be safe, I'll leave it alone. + if (NPC.velocity.X > 16f) + { + NPC.velocity.X = 14f; + } + if (NPC.velocity.X < -16f) + { + NPC.velocity.X = -14f; + } + if (NPC.velocity.Y > 10f) + { + NPC.velocity.Y = 8f; + } + if (NPC.velocity.Y < -10f) + { + NPC.velocity.Y = -8f; + } + } + else if (NPC.type == NPCID.Shark || NPC.type == NPCID.AnglerFish) + { + NPC.velocity.X += NPC.direction * 0.3f; + NPC.velocity.Y += NPC.directionY * 0.3f; + if (NPC.velocity.X > 10f) + { + NPC.velocity.X = 10f; + } + if (NPC.velocity.X < -10f) + { + NPC.velocity.X = -10f; + } + if (NPC.velocity.Y > 6f) + { + NPC.velocity.Y = 6f; + } + if (NPC.velocity.Y < -6f) + { + NPC.velocity.Y = -6f; + } + NPC.velocity = Vector2.Clamp(NPC.velocity, new Vector2(-10f, -6f), new Vector2(10f, 6f)); + } + else + { + NPC.velocity.X += NPC.direction * 0.2f; + NPC.velocity.Y += NPC.directionY * 0.2f; + NPC.velocity = Vector2.Clamp(NPC.velocity, new Vector2(-6f, -4f), new Vector2(6f, 4f)); + } + } + else + { + if (NPC.type == NPCID.Arapaima) + { + NPC.directionY = (Main.player[NPC.target].position.Y > NPC.position.Y).ToDirectionInt(); + NPC.velocity.X += NPC.direction * 0.2f; + if (NPC.velocity.X < -2f || NPC.velocity.X > 2f) + { + NPC.velocity.X *= 0.95f; + } + // Bob up and down in the water + if (NPC.ai[0] == -1f) + { + float yVelocityMin = -0.6f; + if (NPC.directionY < 0) + { + yVelocityMin = -1f; + } + if (NPC.directionY > 0) + { + yVelocityMin = -0.2f; + } + NPC.velocity.Y -= 0.02f; + if (NPC.velocity.Y < yVelocityMin) + { + NPC.ai[0] = 1f; + } + } + else + { + float yVelocityMin = 0.6f; + if (NPC.directionY < 0) + { + yVelocityMin = 0.2f; + } + if (NPC.directionY > 0) + { + yVelocityMin = 1f; + } + NPC.velocity.Y += 0.02f; + if (NPC.velocity.Y > yVelocityMin) + { + NPC.ai[0] = -1f; + } + } + } + else + { + NPC.velocity.X += NPC.direction * 0.1f; + if (NPC.velocity.X < -1f || NPC.velocity.X > 1f) + { + NPC.velocity.X *= 0.95f; + } + if (NPC.ai[0] == -1f) + { + NPC.velocity.Y -= 0.01f; + if (NPC.velocity.Y < -0.3f) + { + NPC.ai[0] = 1f; + } + } + else + { + NPC.velocity.Y += 0.01f; + if (NPC.velocity.Y > 0.3) + { + NPC.ai[0] = -1f; + } + } + } + int x = (int)NPC.Center.X / 16; + int y = (int)NPC.Center.Y / 16; + if (Main.tile[x, y - 1].LiquidAmount > 128) + { + if (Main.tile[x, y + 1].HasTile) + { + NPC.ai[0] = -1f; + } + else if (Main.tile[x, y + 2].HasTile) + { + NPC.ai[0] = -1f; + } + } + if (NPC.type != NPCID.Arapaima && Math.Abs(NPC.velocity.Y) < 0.4f) + { + NPC.velocity.Y *= 0.95f; + } + } + } + else + { + if (NPC.velocity.Y == 0f) + { + // Sit helplessly on land and do absolutely nothing. + if (NPC.type == NPCID.Shark) + { + NPC.velocity.X *= 0.94f; + if (Math.Abs(NPC.velocity.X) < 0.2) + { + NPC.velocity.X = 0f; + } + } + // Flop around + else if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.velocity.Y = Main.rand.NextFloat(-5f, -2f); + NPC.velocity.X = Main.rand.NextFloat(-2f, -2f); + NPC.netUpdate = true; + } + } + NPC.velocity.Y += 0.3f; + if (NPC.velocity.Y > 10f) + { + NPC.velocity.Y = 10f; + } + NPC.ai[0] = 1f; + } + NPC.rotation = NPC.velocity.Y * NPC.direction * 0.1f; + NPC.rotation = MathHelper.Clamp(NPC.rotation, -0.2f, 0.2f); + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TeslaTurretAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TeslaTurretAI.cs new file mode 100644 index 0000000000..f903733120 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TeslaTurretAI.cs @@ -0,0 +1,127 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class TeslaTurretAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + NPC.TargetClosest(false); + + NPC.spriteDirection = NPC.direction; + + NPC.velocity.X *= 0.93f; + if (Math.Abs(NPC.velocity.X) < 0.1f) + { + NPC.velocity.X = 0f; + } + + float appearTime = 120f; + float alphaFadeinTime = 60f; + + // Spend the first "appearTime" frames sitting around and spawning. + if (NPC.ai[1] < appearTime) + { + NPC.ai[1] += 1f; + if (NPC.ai[1] > appearTime - alphaFadeinTime) + { + float alphaRatio = (NPC.ai[1] - alphaFadeinTime) / (appearTime - alphaFadeinTime); + NPC.alpha = (int)((1f - alphaRatio) * 255f); + } + else + { + NPC.alpha = 255; + } + + NPC.dontTakeDamage = true; + + NPC.frameCounter = 0.0; + NPC.frame.Y = 0; + + // Circular dust + float angularRatio = NPC.ai[1] / alphaFadeinTime; + Vector2 spinningpoint = new Vector2(0f, -30f).RotatedBy(angularRatio * 1.5f * MathHelper.TwoPi) * new Vector2(1f, 0.4f); + + for (int i = 0; i < 4; i++) + { + Vector2 dustSpawnDelta = Vector2.Zero; + float scaleFactor2 = 1f; + switch (i) + { + case 0: + dustSpawnDelta = Vector2.UnitY * -15f; + scaleFactor2 = 0.15f; + break; + case 1: + dustSpawnDelta = Vector2.UnitY * -5f; + scaleFactor2 = 0.3f; + break; + case 2: + dustSpawnDelta = Vector2.UnitY * 5f; + scaleFactor2 = 0.6f; + break; + case 3: + dustSpawnDelta = Vector2.UnitY * 20f; + scaleFactor2 = 0.45f; + break; + } + + int idx = Dust.NewDust(NPC.Center, 0, 0, DustID.Electric, 0f, 0f, 100, default, 0.5f); + Main.dust[idx].noGravity = true; + Main.dust[idx].position = NPC.Center + spinningpoint * scaleFactor2 + dustSpawnDelta; + Main.dust[idx].velocity = Vector2.Zero; + spinningpoint *= -1f; + + idx = Dust.NewDust(NPC.Center, 0, 0, DustID.Electric, 0f, 0f, 100, default, 0.5f); + Main.dust[idx].noGravity = true; + Main.dust[idx].position = NPC.Center + spinningpoint * scaleFactor2 + dustSpawnDelta; + Main.dust[idx].velocity = Vector2.Zero; + } + + Lighting.AddLight((int)NPC.Center.X / 16, (int)(NPC.Center.Y - 10f) / 16, 0.1f * angularRatio, 0.5f * angularRatio, 0.7f * angularRatio); + + return false; + } + + Lighting.AddLight((int)NPC.Center.X / 16, (int)(NPC.Center.Y - 10f) / 16, 0.1f, 0.5f, 0.7f); + NPC.dontTakeDamage = false; + + if (NPC.ai[0] < 60f) + { + NPC.ai[0] += 1f; + } + + // Reset laser shoot counter + if (NPC.justHit) + { + NPC.ai[0] = 0f; + } + + // Shoot laser + if (NPC.ai[0] == 60f) + { + NPC.ai[0] = CalamityWorld.death ? -60f : -120f; + + // The "+ Main.player[npc.target].velocity * 20f" part ensures the turret will aim ahead of the player + Vector2 distanceVector = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f - (NPC.Center - Vector2.UnitY * 10f); + + if (distanceVector.HasNaNs()) + { + distanceVector = -Vector2.UnitY; + } + Vector2 velocity = Vector2.Normalize(distanceVector) * 14f; + + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center - Vector2.UnitY * 10f, velocity, ProjectileID.MartianTurretBolt, 28, 0f, Main.myPlayer, 0f, 0f); + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TortoiseAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TortoiseAI.cs new file mode 100644 index 0000000000..cc1b0c8fe2 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/TortoiseAI.cs @@ -0,0 +1,591 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class TortoiseAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.target < 0 || Main.player[NPC.target].dead || NPC.direction == 0) + { + NPC.TargetClosest(true); + } + + int turtleFaceDirection = 0; + if (NPC.velocity.X < 0f) + { + turtleFaceDirection = -1; + } + if (NPC.velocity.X > 0f) + { + turtleFaceDirection = 1; + } + + Vector2 position = NPC.position; + position.X += NPC.velocity.X; + int turtleTileX = (int)((position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * turtleFaceDirection)) / 16f); + int turtleTileY = (int)((position.Y + (float)NPC.height - 1f) / 16f); + + if ((float)(turtleTileX * 16) < position.X + (float)NPC.width && (float)(turtleTileX * 16 + 16) > position.X && ((Main.tile[turtleTileX, turtleTileY].HasUnactuatedTile && !Main.tile[turtleTileX, turtleTileY].TopSlope && !Main.tile[turtleTileX, turtleTileY - 1].TopSlope && ((Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY].TileType] && !Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType]) || (Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType] && (!Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || !Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile) && Main.tile[turtleTileX, turtleTileY].TileType != TileID.Anvils && Main.tile[turtleTileX, turtleTileY].TileType != TileID.WorkBenches && Main.tile[turtleTileX, turtleTileY].TileType != TileID.MythrilAnvil))) || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile)) && (!Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && (!Main.tile[turtleTileX, turtleTileY - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType]))) && (!Main.tile[turtleTileX, turtleTileY - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType]) && (!Main.tile[turtleTileX, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType]) && (!Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType])) + { + float tilePixelPosition = (float)(turtleTileY * 16); + if (Main.tile[turtleTileX, turtleTileY].IsHalfBlock) + { + tilePixelPosition += 8f; + } + if (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock) + { + tilePixelPosition -= 8f; + } + + if (tilePixelPosition < position.Y + (float)NPC.height) + { + float percentageTileRisen = position.Y + (float)NPC.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) + { + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - tilePixelPosition; + NPC.position.Y = tilePixelPosition - (float)NPC.height; + if (percentageTileRisen < 9f) + { + NPC.stepSpeed = 0.75f; + } + else + { + NPC.stepSpeed = 1.5f; + } + } + } + } + + if (NPC.type == NPCID.IceTortoise && Main.rand.NextBool(10)) + { + int iceTortoiseDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.IceRod, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceTortoiseDust].noGravity = true; + Dust dust = Main.dust[iceTortoiseDust]; + dust.velocity *= 0.2f; + } + + if (NPC.ai[0] == 0f) + { + if (NPC.velocity.X < 0f) + { + NPC.direction = -1; + } + else if (NPC.velocity.X > 0f) + { + NPC.direction = 1; + } + + NPC.spriteDirection = NPC.direction; + + Vector2 tortoisePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float tortoiseTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - tortoisePosition.X; + float tortoiseTargetY = Main.player[NPC.target].position.Y - tortoisePosition.Y; + float tortoiseTargetDist = (float)Math.Sqrt((double)(tortoiseTargetX * tortoiseTargetX + tortoiseTargetY * tortoiseTargetY)); + + bool canHitPlayer = Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + if (NPC.type == NPCID.GiantShelly || NPC.type == NPCID.GiantShelly2) + { + if (tortoiseTargetDist > 200f & canHitPlayer) + { + NPC.ai[1] += 3f; + } + if (tortoiseTargetDist > 600f && (canHitPlayer || NPC.position.Y + (float)NPC.height > Main.player[NPC.target].position.Y - 200f)) + { + NPC.ai[1] += 6f; + } + } + else + { + if (tortoiseTargetDist > 200f & canHitPlayer) + { + NPC.ai[1] += 6f; + } + if (tortoiseTargetDist > 600f && (canHitPlayer || NPC.position.Y + (float)NPC.height > Main.player[NPC.target].position.Y - 200f)) + { + NPC.ai[1] += 15f; + } + } + + if (NPC.wet) + { + NPC.ai[1] = 1000f; + } + + NPC.defense = NPC.defDefense; + + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.type == NPCID.GiantShelly || NPC.type == NPCID.GiantShelly2) + { + NPC.knockBackResist = 0.5f; + } + else + { + NPC.knockBackResist = 0.15f; + } + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (CalamityWorld.death ? 400f : 500f)) + { + NPC.ai[1] = 0f; + NPC.ai[0] = 1f; + } + + if (!NPC.justHit && NPC.velocity.X != NPC.oldVelocity.X) + { + NPC.direction *= -1; + } + + if (NPC.velocity.Y == 0f && Main.player[NPC.target].position.Y < NPC.position.Y + (float)NPC.height) + { + int tortoiseLeftTileX; + int tortoiseRightTileX; + if (NPC.direction > 0) + { + tortoiseLeftTileX = (int)(((double)NPC.position.X + (double)NPC.width * 0.5) / 16.0); + tortoiseRightTileX = tortoiseLeftTileX + 3; + } + else + { + tortoiseRightTileX = (int)(((double)NPC.position.X + (double)NPC.width * 0.5) / 16.0); + tortoiseLeftTileX = tortoiseRightTileX - 3; + } + + int tortoiseBotTileY = (int)((NPC.position.Y + (float)NPC.height + 2f) / 16f) - 1; + int tortoiseTopTileY = tortoiseBotTileY + 4; + bool onSolidTile = false; + for (int x = tortoiseLeftTileX; x <= tortoiseRightTileX; x++) + { + for (int y = tortoiseBotTileY; y <= tortoiseTopTileY; y++) + { + if (Main.tile[x, y] != null && Main.tile[x, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y].TileType]) + { + onSolidTile = true; + } + } + } + + if (!onSolidTile) + { + NPC.direction *= -1; + NPC.velocity.X = 0.1f * (float)NPC.direction; + } + } + + if (NPC.type == NPCID.GiantShelly || NPC.type == NPCID.GiantShelly2) + { + float giantShellyMaxVel = 1f; + if (NPC.velocity.X < -giantShellyMaxVel || NPC.velocity.X > giantShellyMaxVel) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity *= 0.8f; + } + } + else if (NPC.velocity.X < giantShellyMaxVel && NPC.direction == 1) + { + NPC.velocity.X = NPC.velocity.X + 0.1f; + if (NPC.velocity.X > giantShellyMaxVel) + { + NPC.velocity.X = giantShellyMaxVel; + } + } + else if (NPC.velocity.X > -giantShellyMaxVel && NPC.direction == -1) + { + NPC.velocity.X = NPC.velocity.X - 0.1f; + if (NPC.velocity.X < -giantShellyMaxVel) + { + NPC.velocity.X = -giantShellyMaxVel; + } + } + } + else + { + float tortoiseMaxVel = 2f; + if (tortoiseTargetDist < 400f) + { + if (NPC.velocity.X < -tortoiseMaxVel || NPC.velocity.X > tortoiseMaxVel) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity *= 0.8f; + } + } + else if (NPC.velocity.X < tortoiseMaxVel && NPC.direction == 1) + { + NPC.velocity.X = NPC.velocity.X + 0.1f; + if (NPC.velocity.X > tortoiseMaxVel) + { + NPC.velocity.X = tortoiseMaxVel; + } + } + else if (NPC.velocity.X > -tortoiseMaxVel && NPC.direction == -1) + { + NPC.velocity.X = NPC.velocity.X - 0.1f; + if (NPC.velocity.X < -tortoiseMaxVel) + { + NPC.velocity.X = -tortoiseMaxVel; + } + } + } + else if (NPC.velocity.X < -3f || NPC.velocity.X > 3f) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity *= 0.8f; + } + } + else if (NPC.velocity.X < 3f && NPC.direction == 1) + { + NPC.velocity.X = NPC.velocity.X + 0.1f; + if (NPC.velocity.X > 3f) + { + NPC.velocity.X = 3f; + } + } + else if (NPC.velocity.X > -3f && NPC.direction == -1) + { + NPC.velocity.X = NPC.velocity.X - 0.1f; + if (NPC.velocity.X < -3f) + { + NPC.velocity.X = -3f; + } + } + } + } + else if (NPC.ai[0] == 1f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.velocity.X = NPC.velocity.X * 0.5f; + + if (NPC.type == NPCID.GiantShelly || NPC.type == NPCID.GiantShelly2) + { + NPC.ai[1] += 1f; + } + else + { + NPC.ai[1] += 2f; + } + + if (NPC.ai[1] >= 30f) + { + NPC.netUpdate = true; + NPC.TargetClosest(true); + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[0] = 3f; + + if (NPC.type == NPCID.SolarSroller) + { + NPC.ai[0] = 6f; + NPC.ai[2] = (float)Main.rand.Next(2, 5); + } + } + } + else + { + if (NPC.ai[0] == 3f) + { + if (NPC.type == NPCID.IceTortoise && Main.rand.Next(3) < 2) + { + int iceTortoiseSpinDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.IceRod, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceTortoiseSpinDust].noGravity = true; + Dust dust = Main.dust[iceTortoiseSpinDust]; + dust.velocity *= 0.2f; + } + + if (NPC.type == NPCID.GiantShelly || NPC.type == NPCID.GiantShelly2) + { + NPC.damage = (int)Math.Round(NPC.defDamage * 1.2); + } + else + { + NPC.damage = (int)Math.Round(NPC.defDamage * 1.4); + } + + NPC.defense = NPC.defDefense * 2; + + NPC.ai[1] += 1f; + if (NPC.ai[1] == 1f) + { + NPC.netUpdate = true; + NPC.TargetClosest(true); + + NPC.ai[2] += 0.3f; + NPC.rotation += NPC.ai[2] * (float)NPC.direction; + NPC.ai[1] += 1f; + + bool spinAttackCanHit = Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + float spinAttackSpeed = 15f; + if (!spinAttackCanHit) + { + spinAttackSpeed = 6f; + } + if (NPC.type == NPCID.GiantShelly || NPC.type == NPCID.GiantShelly2) + { + spinAttackSpeed *= 0.75f; + } + + Vector2 spinAttackPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float spinAttackTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - spinAttackPosition.X; + float absoluteSpinTargetX = Math.Abs(spinAttackTargetX) * 0.2f; + if (NPC.directionY > 0) + { + absoluteSpinTargetX = 0f; + } + float spinAttackTargetY = Main.player[NPC.target].position.Y - spinAttackPosition.Y - absoluteSpinTargetX; + float spinAttackTargetDist = (float)Math.Sqrt((double)(spinAttackTargetX * spinAttackTargetX + spinAttackTargetY * spinAttackTargetY)); + NPC.netUpdate = true; + + spinAttackTargetDist = spinAttackSpeed / spinAttackTargetDist; + spinAttackTargetX *= spinAttackTargetDist; + spinAttackTargetY *= spinAttackTargetDist; + + if (!spinAttackCanHit) + { + spinAttackTargetY = -10f; + } + + NPC.velocity.X = spinAttackTargetX; + NPC.velocity.Y = spinAttackTargetY; + NPC.ai[3] = NPC.velocity.X; + } + else + { + if (NPC.position.X + (float)NPC.width > Main.player[NPC.target].position.X && NPC.position.X < Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width && NPC.position.Y < Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height) + { + NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.ai[3] = 0f; + if (NPC.velocity.Y < 0f) + { + NPC.velocity.Y = NPC.velocity.Y + 0.3f; + } + } + + if (NPC.ai[3] != 0f) + { + NPC.velocity.X = NPC.ai[3]; + NPC.velocity.Y = NPC.velocity.Y - 0.33f; + } + + if (NPC.ai[1] >= 90f) + { + NPC.noGravity = false; + NPC.ai[1] = 0f; + NPC.ai[0] = 4f; + } + } + + if (NPC.wet && NPC.directionY < 0) + { + NPC.velocity.Y = NPC.velocity.Y - 0.45f; + } + + NPC.rotation += NPC.ai[2] * (float)NPC.direction; + + return false; + } + + if (NPC.ai[0] == 4f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + if (NPC.wet && NPC.directionY < 0) + { + NPC.velocity.Y = NPC.velocity.Y - 0.45f; + } + + NPC.velocity.X = NPC.velocity.X * 0.95f; + + if (NPC.ai[2] > 0f) + { + NPC.ai[2] -= 0.01f; + NPC.rotation += NPC.ai[2] * (float)NPC.direction; + } + else if (NPC.velocity.Y >= 0f) + { + NPC.rotation = 0f; + } + + if (NPC.ai[2] <= 0f && (NPC.velocity.Y == 0f || NPC.wet)) + { + NPC.netUpdate = true; + NPC.rotation = 0f; + NPC.ai[2] = 0f; + NPC.ai[1] = 0f; + NPC.ai[0] = 5f; + } + } + else + { + if (NPC.ai[0] == 6f) + { + NPC.damage = (int)Math.Round(NPC.defDamage * 1.2); + NPC.defense = NPC.defDefense * 2; + NPC.knockBackResist = 0f; + + if (Main.rand.Next(3) < 2) + { + int spinAttackDust = Dust.NewDust(NPC.Center - new Vector2(30f), 60, 60, DustID.Torch, NPC.velocity.X * 0.5f, NPC.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Dust dust = Main.dust[spinAttackDust]; + dust.noGravity = true; + dust.velocity *= 0.2f; + dust.fadeIn = 1f; + } + + NPC.ai[1] += 1f; + if (NPC.ai[3] > 0f) + { + if (NPC.ai[3] == 1f) + { + Vector2 vector68 = NPC.Center - new Vector2(50f); + for (int i = 0; i < 32; i++) + { + int spinEndDust = Dust.NewDust(vector68, 100, 100, DustID.Torch, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[spinEndDust]; + dust.noGravity = true; + dust.velocity *= 3f; + spinEndDust = Dust.NewDust(vector68, 100, 100, DustID.Torch, 0f, 0f, 100, default(Color), 1.5f); + dust.velocity *= 2f; + dust.noGravity = true; + } + + if (!Main.dedServ) + { + for (int j = 0; j < 4; j++) + { + int spinEndGore = Gore.NewGore(NPC.GetSource_FromAI(), vector68 + new Vector2((float)(50 * Main.rand.Next(100)) / 100f, (float)(50 * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[spinEndGore]; + gore.velocity *= 0.3f; + gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; + gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; + } + } + } + + for (int k = 0; k < 5; k++) + { + int moreSpinEndDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); + Main.dust[moreSpinEndDust].velocity *= Main.rand.NextFloat(); + } + + NPC.ai[3] += 1f; + if (NPC.ai[3] >= 10f) + { + NPC.ai[3] = 0f; + } + } + + if (NPC.ai[1] == 1f) + { + NPC.netUpdate = true; + NPC.TargetClosest(true); + + bool spinAboveCanHit = Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + float spinAboveSpeed = 24f; + if (!spinAboveCanHit) + { + spinAboveSpeed = 10f; + } + + Vector2 vector69 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float spinAboveTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector69.X; + float absoluteSpinAboveTargetX = Math.Abs(spinAboveTargetX) * 0.2f; + if (NPC.directionY > 0) + { + absoluteSpinAboveTargetX = 0f; + } + float spinAboveTargetY = Main.player[NPC.target].position.Y - vector69.Y - absoluteSpinAboveTargetX; + float spinAboveTargetDist = (float)Math.Sqrt((double)(spinAboveTargetX * spinAboveTargetX + spinAboveTargetY * spinAboveTargetY)); + NPC.netUpdate = true; + + spinAboveTargetDist = spinAboveSpeed / spinAboveTargetDist; + spinAboveTargetX *= spinAboveTargetDist; + spinAboveTargetY *= spinAboveTargetDist; + + if (!spinAboveCanHit) + { + spinAboveTargetY = -12f; + } + + NPC.velocity.X = spinAboveTargetX; + NPC.velocity.Y = spinAboveTargetY; + } + else + { + if (NPC.position.X + (float)NPC.width > Main.player[NPC.target].position.X && NPC.position.X < Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width && NPC.position.Y < Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height) + { + NPC.velocity.X = NPC.velocity.X * 0.9f; + if (NPC.velocity.Y < 0f) + { + NPC.velocity.Y = NPC.velocity.Y + 0.3f; + } + } + + if (NPC.ai[2] == 0f || NPC.ai[1] >= 1200f) + { + NPC.ai[1] = 0f; + NPC.ai[0] = 5f; + } + } + + if (NPC.wet && NPC.directionY < 0) + { + NPC.velocity.Y = NPC.velocity.Y - 0.45f; + } + + NPC.rotation += MathHelper.Clamp(NPC.velocity.X / 10f * (float)NPC.direction, -0.314159274f, 0.314159274f); + + return false; + } + + if (NPC.ai[0] == 5f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.rotation = 0f; + NPC.velocity.X = 0f; + + if (NPC.type == NPCID.GiantShelly || NPC.type == NPCID.GiantShelly2) + { + NPC.ai[1] += 1f; + } + else + { + NPC.ai[1] += 2f; + } + + if (NPC.ai[1] >= 30f) + { + NPC.TargetClosest(true); + NPC.netUpdate = true; + NPC.ai[1] = 0f; + NPC.ai[0] = 0f; + } + + if (NPC.wet) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + } + } + } + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/UnicornAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/UnicornAI.cs new file mode 100644 index 0000000000..64ebe35feb --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/UnicornAI.cs @@ -0,0 +1,502 @@ +using System; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class UnicornAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + int turnAroundDelay = 30; + int turnAroundDelayMult = 8; + + bool flag = false; + bool isRunning = false; + bool shouldTurnAround = false; + + if (NPC.velocity.Y == 0f && ((NPC.velocity.X > 0f && NPC.direction < 0) || (NPC.velocity.X < 0f && NPC.direction > 0))) + { + isRunning = true; + NPC.ai[3] += 1f; + } + + if (NPC.type == NPCID.Tumbleweed) + { + turnAroundDelayMult = 3; + bool noYVelocity = NPC.velocity.Y == 0f; + foreach (NPC n in Main.ActiveNPCs) + { + 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 < n.position.X) + { + NPC.velocity.X -= 0.05f; + } + else + { + NPC.velocity.X += 0.05f; + } + if (NPC.position.Y < n.position.Y) + { + NPC.velocity.Y -= 0.05f; + } + else + { + NPC.velocity.Y += 0.05f; + } + } + } + if (noYVelocity) + { + NPC.velocity.Y = 0f; + } + } + + if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)turnAroundDelay) | isRunning) + { + NPC.ai[3] += 1f; + shouldTurnAround = true; + } + else if (NPC.ai[3] > 0f) + { + NPC.ai[3] -= 1f; + } + + if (NPC.ai[3] > (float)(turnAroundDelay * turnAroundDelayMult)) + { + NPC.ai[3] = 0f; + } + + if (NPC.justHit) + { + NPC.ai[3] = 0f; + } + + if (NPC.ai[3] == (float)turnAroundDelay) + { + NPC.netUpdate = true; + } + + Vector2 npcPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + + if (targetDistance < 200f && !shouldTurnAround) + { + NPC.ai[3] = 0f; + } + + if (NPC.type == NPCID.StardustSpiderSmall) + { + NPC.ai[1] += 1f; + bool spawnTwinkle = NPC.ai[1] >= (CalamityWorld.death ? 60f : 120f); + if (!spawnTwinkle && NPC.velocity.Y == 0f) + { + foreach (Player plr in Main.ActivePlayers) + { + 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; + } + } + } + + if (spawnTwinkle && Main.netMode != NetmodeID.MultiplayerClient) + { + for (int k = 0; k < 3; k++) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, (Main.rand.NextFloat() - 0.5f) * 2f, -4f - 10f * Main.rand.NextFloat(), ProjectileID.Twinkle, 50, 0f, Main.myPlayer, 0f, 0f); + } + NPC.HitEffect(9999, 10.0); + NPC.active = false; + return false; + } + } + else if (NPC.type == NPCID.NebulaBeast) + { + if (NPC.ai[2] == 1f) + { + NPC.ai[1] += 1f; + NPC.velocity.X = NPC.velocity.X * 0.7f; + if (NPC.ai[1] < 30f) + { + Vector2 nebulaBeastDustRotation = NPC.Center + Vector2.UnitX * (float)NPC.spriteDirection * -20f; + Dust nebulaBeastDust = Main.dust[Dust.NewDust(nebulaBeastDustRotation, 0, 0, DustID.PinkTorch, 0f, 0f, 0, default(Color), 1f)]; + Vector2 nebulaBeastDustVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + nebulaBeastDust.position = nebulaBeastDustRotation + nebulaBeastDustVelocity * 20f; + nebulaBeastDust.velocity = -nebulaBeastDustVelocity * 2f; + nebulaBeastDust.scale = 0.5f + nebulaBeastDustVelocity.X * (float)(-(float)NPC.spriteDirection); + nebulaBeastDust.fadeIn = 1f; + nebulaBeastDust.noGravity = true; + } + else if (NPC.ai[1] == 30f) + { + for (int l = 0; l < 20; l++) + { + Vector2 nebulaBeastDustRotation2 = NPC.Center + Vector2.UnitX * (float)NPC.spriteDirection * -20f; + Dust nebulaBeastDust2 = Main.dust[Dust.NewDust(nebulaBeastDustRotation2, 0, 0, DustID.PinkTorch, 0f, 0f, 0, default(Color), 1f)]; + Vector2 nebulaBeastDustVelocity2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + nebulaBeastDust2.position = nebulaBeastDustRotation2 + nebulaBeastDustVelocity2 * 4f; + nebulaBeastDust2.velocity = nebulaBeastDustVelocity2 * 4f + Vector2.UnitX * Main.rand.NextFloat() * (float)NPC.spriteDirection * -5f; + nebulaBeastDust2.scale = 0.5f + nebulaBeastDustVelocity2.X * (float)(-(float)NPC.spriteDirection); + nebulaBeastDust2.fadeIn = 1f; + nebulaBeastDust2.noGravity = true; + } + } + + if (NPC.velocity.X > -0.5f && NPC.velocity.X < 0.5f) + { + NPC.velocity.X = 0f; + } + + if (NPC.ai[1] == 30f && Main.netMode != NetmodeID.MultiplayerClient) + { + int nebulaBeastProjDamage = Main.expertMode ? 35 : 50; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X + (float)(NPC.spriteDirection * -20), NPC.Center.Y, (float)(NPC.spriteDirection * -7), 0f, ProjectileID.NebulaSphere, nebulaBeastProjDamage, 0f, Main.myPlayer, (float)NPC.target, 0f); + } + + if (NPC.ai[1] >= 60f) + { + NPC.ai[1] = (float)(-(float)Main.rand.Next(320, CalamityWorld.death ? 361 : 601)); + NPC.ai[2] = 0f; + } + } + else + { + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 180f && targetDistance < 500f && NPC.velocity.Y == 0f) + { + flag = true; + NPC.ai[1] = 0f; + NPC.ai[2] = 1f; + NPC.netUpdate = true; + } + else if (NPC.velocity.Y == 0f && targetDistance < 100f && Math.Abs(NPC.velocity.X) > 3f && ((NPC.Center.X < Main.player[NPC.target].Center.X && NPC.velocity.X > 0f) || (NPC.Center.X > Main.player[NPC.target].Center.X && NPC.velocity.X < 0f))) + { + NPC.velocity.Y = NPC.velocity.Y - 6f; + } + } + } + else if (NPC.type == NPCID.Wolf || NPC.type == NPCID.Hellhound || NPC.type == ModContent.NPCType()) + { + if (NPC.velocity.Y == 0f && targetDistance < 100f && Math.Abs(NPC.velocity.X) > 3f && ((NPC.position.X + (float)(NPC.width / 2) < Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) && NPC.velocity.X > 0f) || (NPC.position.X + (float)(NPC.width / 2) > Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) && NPC.velocity.X < 0f))) + { + NPC.velocity.Y -= 6f; + } + } + + else if (NPC.type == NPCID.Tumbleweed && NPC.velocity.Y == 0f && Math.Abs(NPC.velocity.X) > 3f && ((NPC.Center.X < Main.player[NPC.target].Center.X && NPC.velocity.X > 0f) || (NPC.Center.X > Main.player[NPC.target].Center.X && NPC.velocity.X < 0f))) + { + NPC.velocity.Y -= 6f; + SoundEngine.PlaySound(SoundID.NPCHit11, NPC.Center); + } + + if (NPC.ai[3] < (float)turnAroundDelay) + { + if ((NPC.type == NPCID.Hellhound || NPC.type == NPCID.HeadlessHorseman) && !Main.pumpkinMoon) + { + if (NPC.timeLeft > 10) + { + NPC.timeLeft = 10; + } + } + else + { + NPC.TargetClosest(true); + } + } + else + { + if (NPC.velocity.X == 0f) + { + if (NPC.velocity.Y == 0f) + { + NPC.ai[0] += 1f; + if (NPC.ai[0] >= 2f) + { + NPC.direction *= -1; + NPC.spriteDirection = NPC.direction; + NPC.ai[0] = 0f; + } + } + } + else + { + NPC.ai[0] = 0f; + } + NPC.directionY = -1; + if (NPC.direction == 0) + { + NPC.direction = 1; + } + } + + float maxVelocity = 9f; + float acceleration = 0.1f; + if (CalamityWorld.death) + { + maxVelocity *= 1.25f; + acceleration *= 1.25f; + } + + if (!flag && (NPC.velocity.Y == 0f || NPC.wet || (NPC.velocity.X <= 0f && NPC.direction < 0) || (NPC.velocity.X >= 0f && NPC.direction > 0))) + { + if (NPC.type == ModContent.NPCType()) + { + NPC.velocity.X *= 0.99f; + } + if (NPC.type == NPCID.Wolf) + { + if (NPC.velocity.X > 0f && NPC.direction < 0) + { + NPC.velocity.X *= 0.9f; + } + if (NPC.velocity.X < 0f && NPC.direction > 0) + { + NPC.velocity.X *= 0.9f; + } + } + else if (NPC.type == NPCID.Hellhound) + { + if (NPC.velocity.X > 0f && NPC.direction < 0) + { + NPC.velocity.X *= 0.2f; + } + if (NPC.velocity.X < 0f && NPC.direction > 0) + { + NPC.velocity.X *= 0.2f; + } + if (NPC.direction > 0 && NPC.velocity.X < 3f) + { + NPC.velocity.X += 0.15f; + } + if (NPC.direction < 0 && NPC.velocity.X > -3f) + { + NPC.velocity.X -= 0.15f; + } + } + else if (NPC.type == NPCID.HeadlessHorseman) + { + if (NPC.velocity.X > 0f && NPC.direction < 0) + { + NPC.velocity.X *= 0.9f; + } + if (NPC.velocity.X < 0f && NPC.direction > 0) + { + NPC.velocity.X *= 0.9f; + } + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity *= 0.8f; + } + } + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) + { + NPC.velocity.X += 0.1f; + if (NPC.velocity.X > maxVelocity) + { + NPC.velocity.X = maxVelocity; + } + } + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) + { + NPC.velocity.X -= 0.1f; + if (NPC.velocity.X < -maxVelocity) + { + NPC.velocity.X = -maxVelocity; + } + } + } + else if (NPC.type == NPCID.StardustSpiderSmall) + { + if (Math.Sign(NPC.velocity.X) != NPC.direction) + { + NPC.velocity.X *= 0.8f; + } + acceleration = 0.2f; + } + else if (NPC.type == NPCID.NebulaBeast) + { + if (Math.Sign(NPC.velocity.X) != NPC.direction) + { + NPC.velocity.X *= 0.8f; + } + maxVelocity = 12f; + acceleration = 0.2f; + } + else if (NPC.type == NPCID.Tumbleweed) + { + if (Math.Sign(NPC.velocity.X) != NPC.direction) + { + NPC.velocity.X *= 0.9f; + } + float sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); + if (!Main.player[NPC.target].ZoneSandstorm) + { + sandstormPush = 0f; + } + maxVelocity = 6f + sandstormPush * (float)NPC.direction * 4f; + acceleration = 0.2f; + } + if (CalamityWorld.death) + { + maxVelocity *= 1.25f; + acceleration *= 1.25f; + } + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) + { + if (NPC.velocity.Y == 0f) + { + NPC.velocity *= 0.8f; + } + } + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) + { + NPC.velocity.X = NPC.velocity.X + acceleration; + if (NPC.velocity.X > maxVelocity) + { + NPC.velocity.X = maxVelocity; + } + } + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) + { + NPC.velocity.X = NPC.velocity.X - acceleration; + if (NPC.velocity.X < -maxVelocity) + { + NPC.velocity.X = -maxVelocity; + } + } + } + + if (NPC.velocity.Y >= 0f) + { + int faceDirection = 0; + if (NPC.velocity.X < 0f) + { + faceDirection = -1; + } + if (NPC.velocity.X > 0f) + { + faceDirection = 1; + } + + Vector2 position = NPC.position; + position.X += NPC.velocity.X; + int x = (int)((position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * faceDirection)) / 16f); + int y = (int)((position.Y + (float)NPC.height - 1f) / 16f); + + if ((float)(x * 16) < position.X + (float)NPC.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - faceDirection, y - 3].TileType])) + { + float tilePixelPosition = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) + { + tilePixelPosition += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + tilePixelPosition -= 8f; + } + if (tilePixelPosition < position.Y + (float)NPC.height) + { + float percentageTileRisen = position.Y + (float)NPC.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) + { + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - tilePixelPosition; + NPC.position.Y = tilePixelPosition - (float)NPC.height; + if (percentageTileRisen < 9f) + { + NPC.stepSpeed = 1f; + } + else + { + NPC.stepSpeed = 2f; + } + } + } + } + } + + if (NPC.velocity.Y == 0f) + { + int npcTileX = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 2) * NPC.direction) + NPC.velocity.X * 5f) / 16f); + int npcTileY = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); + + int spriteDirection = NPC.spriteDirection; + if (NPC.type == NPCID.NebulaBeast || NPC.type == NPCID.StardustSpiderSmall || NPC.type == NPCID.Tumbleweed) + { + spriteDirection *= -1; + } + + if ((NPC.velocity.X < 0f && spriteDirection == -1) || (NPC.velocity.X > 0f && spriteDirection == 1)) + { + bool pillarEnemy = NPC.type == NPCID.StardustSpiderSmall || NPC.type == NPCID.NebulaBeast; + + if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 2].TileType]) + { + if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 3].TileType]) + { + NPC.velocity.Y = -10.5f; + NPC.netUpdate = true; + } + else + { + NPC.velocity.Y = -9.5f; + NPC.netUpdate = true; + } + } + else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 1].TileType]) + { + NPC.velocity.Y = -9f; + NPC.netUpdate = true; + } + else if (NPC.position.Y + (float)NPC.height - (float)(npcTileY * 16) > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType]) + { + NPC.velocity.Y = -7f; + NPC.netUpdate = true; + } + else if ((NPC.directionY < 0 || Math.Abs(NPC.velocity.X) > 3f) && (!pillarEnemy || !Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + NPC.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX + NPC.direction, npcTileY + 3].TileType])) + { + NPC.velocity.Y = -10f; + NPC.netUpdate = true; + } + } + } + + if (NPC.type == NPCID.NebulaBeast && Math.Abs(NPC.velocity.X) >= maxVelocity * 0.95f) + { + Rectangle hitbox = NPC.Hitbox; + for (int m = 0; m < 2; m++) + { + if (Main.rand.NextBool(3)) + { + Dust nebulaBeastIdleDust = Main.dust[Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, DustID.PinkTorch, 0f, 0f, 0, default(Color), 1f)]; + nebulaBeastIdleDust.velocity = Vector2.Zero; + nebulaBeastIdleDust.noGravity = true; + nebulaBeastIdleDust.fadeIn = 1f; + nebulaBeastIdleDust.scale = 0.5f + Main.rand.NextFloat(); + } + } + } + + if (NPC.type == NPCID.Tumbleweed) + { + NPC.rotation += NPC.velocity.X * 0.05f; + NPC.spriteDirection = -NPC.direction; + } + + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/WormAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/WormAI.cs new file mode 100644 index 0000000000..09e1d56d07 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/WormAI.cs @@ -0,0 +1,897 @@ +using System; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; + +public static partial class RevengeanceAndDeathAI +{ + public class WormAI : VanillaAIOverride + { + public override bool AI(Mod mod) + { + if (NPC.type == NPCID.LeechHead && NPC.localAI[1] == 0f) + { + NPC.localAI[1] = 1f; + SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); + int dustVelocity = 1; + if (NPC.velocity.X < 0f) + { + dustVelocity = -1; + } + for (int i = 0; i < 20; i++) + { + Dust.NewDust(new Vector2(NPC.position.X - 20f, NPC.position.Y - 20f), NPC.width + 40, NPC.height + 40, DustID.Blood, (float)(dustVelocity * 8), -1f, 0, default(Color), 1f); + } + } + + if (NPC.type >= NPCID.BloodEelHead && NPC.type <= NPCID.BloodEelTail) + { + NPC.position += NPC.netOffset; + NPC.dontTakeDamage = (NPC.alpha > 0); + if (NPC.type == NPCID.BloodEelHead || (NPC.type != NPCID.BloodEelHead && Main.npc[(int)NPC.ai[1]].alpha < 85)) + { + if (NPC.dontTakeDamage) + { + for (int k = 0; k < 2; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100); + } + } + + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } + + if (NPC.alpha == 0 && Main.rand.NextBool(5)) + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100); + + NPC.position -= NPC.netOffset; + } + else if (NPC.type == NPCID.StardustWormHead && NPC.ai[1] == 0f) + { + NPC.ai[1] = Main.rand.Next(-2, 0); + NPC.netUpdate = true; + } + + bool wormHead = NPC.type == NPCID.GiantWormHead || NPC.type == NPCID.BoneSerpentHead || NPC.type == NPCID.DiggerHead || NPC.type == NPCID.LeechHead || NPC.type == NPCID.DuneSplicerHead || (!Main.player[NPC.target].ZoneUndergroundDesert && NPC.type == NPCID.TombCrawlerHead); + float acceleration = NPC.type == NPCID.TombCrawlerHead ? 0.1f : 0.2f; + + NPC.defense = (int)Math.Round(NPC.defDefense * 1.3); + if (NPC.ai[3] > 0f) + NPC.realLife = (int)NPC.ai[3]; + + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || (wormHead && (double)Main.player[NPC.target].position.Y < Main.worldSurface * 16.0)) + { + NPC.TargetClosest(true); + } + + if (Main.player[NPC.target].dead || (wormHead && (double)Main.player[NPC.target].position.Y < Main.worldSurface * 16.0)) + { + if (NPC.timeLeft > 300) + { + NPC.timeLeft = 300; + } + if (wormHead) + { + NPC.velocity.Y = NPC.velocity.Y + acceleration; + } + } + + if (NPC.type == NPCID.BloodEelHead && Main.dayTime) + { + NPC.EncourageDespawn(60); + NPC.velocity.Y += 1f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (NPC.type == NPCID.WyvernHead && NPC.ai[0] == 0f) + { + int maxParts = CalamityWorld.death ? 30 : 21; + NPC.ai[3] = (float)NPC.whoAmI; + NPC.realLife = NPC.whoAmI; + int currentNPC = NPC.whoAmI; + for (int k = 0; k < maxParts; k++) + { + int wyvernSegmentType = NPCID.WyvernBody; + if (k == 1 || k == 12) + { + wyvernSegmentType = NPCID.WyvernLegs; + } + else if (k == maxParts - 3) + { + wyvernSegmentType = NPCID.WyvernBody2; + } + else if (k == maxParts - 2) + { + wyvernSegmentType = NPCID.WyvernBody3; + } + else if (k == maxParts - 1) + { + wyvernSegmentType = NPCID.WyvernTail; + } + int wyvernSegment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), wyvernSegmentType, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[wyvernSegment].ai[3] = (float)NPC.whoAmI; + Main.npc[wyvernSegment].realLife = NPC.whoAmI; + Main.npc[wyvernSegment].ai[1] = (float)currentNPC; + Main.npc[currentNPC].ai[0] = (float)wyvernSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, wyvernSegment, 0f, 0f, 0f, 0, 0, 0); + currentNPC = wyvernSegment; + } + } + + if (NPC.type == NPCID.TombCrawlerHead && NPC.ai[0] == 0f) + { + NPC.ai[3] = (float)NPC.whoAmI; + NPC.realLife = NPC.whoAmI; + int currentTombCrawler = NPC.whoAmI; + int tombCrawlerSegments = Main.rand.Next(11, CalamityWorld.death ? 25 : 15); + for (int m = 0; m < tombCrawlerSegments; m++) + { + int tombCrawlerSegmentType = NPCID.TombCrawlerBody; + if (m == tombCrawlerSegments - 1) + { + tombCrawlerSegmentType = NPCID.TombCrawlerTail; + } + int tombCrawlerSegment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), tombCrawlerSegmentType, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[tombCrawlerSegment].ai[3] = (float)NPC.whoAmI; + Main.npc[tombCrawlerSegment].realLife = NPC.whoAmI; + Main.npc[tombCrawlerSegment].ai[1] = (float)currentTombCrawler; + Main.npc[currentTombCrawler].ai[0] = (float)tombCrawlerSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, tombCrawlerSegment, 0f, 0f, 0f, 0, 0, 0); + currentTombCrawler = tombCrawlerSegment; + } + } + + if (NPC.type == NPCID.SolarCrawltipedeHead && NPC.ai[0] == 0f) + { + NPC.ai[3] = (float)NPC.whoAmI; + NPC.realLife = NPC.whoAmI; + int projTargetDistance = NPC.whoAmI; + int crawltipedeSegments = CalamityWorld.death ? 70 : 50; + for (int n = 0; n < crawltipedeSegments; n++) + { + int crawltipedeSegmentType = NPCID.SolarCrawltipedeBody; + if (n == crawltipedeSegments - 1) + { + crawltipedeSegmentType = NPCID.SolarCrawltipedeTail; + } + int crawltipedeSegment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), crawltipedeSegmentType, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[crawltipedeSegment].ai[3] = (float)NPC.whoAmI; + Main.npc[crawltipedeSegment].realLife = NPC.whoAmI; + Main.npc[crawltipedeSegment].ai[1] = (float)projTargetDistance; + Main.npc[projTargetDistance].ai[0] = (float)crawltipedeSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, crawltipedeSegment, 0f, 0f, 0f, 0, 0, 0); + projTargetDistance = crawltipedeSegment; + } + } + + if (NPC.type == NPCID.BloodEelHead && NPC.ai[0] == 0f) + { + NPC.ai[3] = NPC.whoAmI; + NPC.realLife = NPC.whoAmI; + int bloodEelSegment = 0; + int currentBloodEel = NPC.whoAmI; + int bloodEelSegments = CalamityWorld.death ? 44 : 34; + for (int p = 0; p < bloodEelSegments; p++) + { + int bloodEelSegmentType = NPCID.BloodEelBody; + if (p == bloodEelSegments - 1) + bloodEelSegmentType = NPCID.BloodEelTail; + + bloodEelSegment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), bloodEelSegmentType, NPC.whoAmI); + Main.npc[bloodEelSegment].ai[3] = NPC.whoAmI; + Main.npc[bloodEelSegment].realLife = NPC.whoAmI; + Main.npc[bloodEelSegment].ai[1] = currentBloodEel; + Main.npc[bloodEelSegment].CopyInteractions(NPC); + Main.npc[currentBloodEel].ai[0] = bloodEelSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, bloodEelSegment); + currentBloodEel = bloodEelSegment; + } + } + else if ((NPC.type == NPCID.GiantWormHead || NPC.type == NPCID.GiantWormBody || NPC.type == NPCID.DevourerHead || NPC.type == NPCID.DevourerBody || NPC.type == NPCID.BoneSerpentHead || NPC.type == NPCID.BoneSerpentBody || NPC.type == NPCID.LeechHead || NPC.type == NPCID.LeechBody) && NPC.ai[0] == 0f) + { + if (NPC.type == NPCID.GiantWormHead || NPC.type == NPCID.DevourerHead || NPC.type == NPCID.BoneSerpentHead || NPC.type == NPCID.LeechHead) + { + NPC.ai[3] = (float)NPC.whoAmI; + NPC.realLife = NPC.whoAmI; + + switch (NPC.type) + { + case NPCID.DevourerHead: + NPC.ai[2] = (float)Main.rand.Next(13, CalamityWorld.death ? 30 : 19); + break; + case NPCID.GiantWormHead: + NPC.ai[2] = (float)Main.rand.Next(25, CalamityWorld.death ? 50 : 31); + break; + case NPCID.BoneSerpentHead: + NPC.ai[2] = (float)Main.rand.Next(16, CalamityWorld.death ? 33 : 23); + break; + case NPCID.DiggerHead: + NPC.ai[2] = (float)Main.rand.Next(12, CalamityWorld.death ? 27 : 18); + break; + case NPCID.SeekerHead: + NPC.ai[2] = (float)Main.rand.Next(27, CalamityWorld.death ? 45 : 33); + break; + case NPCID.LeechHead: + NPC.ai[2] = (float)Main.rand.Next(CalamityWorld.death ? 3 : 5, CalamityWorld.death ? 5 : 8); + break; + case NPCID.DuneSplicerHead: + NPC.ai[2] = (float)Main.rand.Next(15, CalamityWorld.death ? 35 : 24); + break; + } + + NPC.ai[0] = (float)NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), NPC.type + 1, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + } + else if ((NPC.type == NPCID.GiantWormBody || NPC.type == NPCID.DevourerBody || NPC.type == NPCID.BoneSerpentBody || NPC.type == NPCID.LeechBody) && NPC.ai[2] > 0f) + { + NPC.ai[0] = (float)NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), NPC.type, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + } + else + { + NPC.ai[0] = (float)NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), NPC.type + 1, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + } + + Main.npc[(int)NPC.ai[0]].ai[3] = NPC.ai[3]; + Main.npc[(int)NPC.ai[0]].realLife = NPC.realLife; + Main.npc[(int)NPC.ai[0]].ai[1] = (float)NPC.whoAmI; + Main.npc[(int)NPC.ai[0]].ai[2] = NPC.ai[2] - 1f; + NPC.netUpdate = true; + } + + if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) + { + if (!Main.npc[(int)NPC.ai[1]].active || Main.npc[(int)NPC.ai[1]].aiStyle != NPC.aiStyle) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } + } + if (NPC.ai[0] > 0f && NPC.ai[0] < (float)Main.npc.Length) + { + if (!Main.npc[(int)NPC.ai[0]].active || Main.npc[(int)NPC.ai[0]].aiStyle != NPC.aiStyle) + { + NPC.life = 0; + NPC.HitEffect(0, 10.0); + NPC.active = false; + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } + } + + if (!NPC.active && Main.dedServ) + { + NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0); + } + } + + int tilePositionX = (int)(NPC.position.X / 16f) - 1; + int tileWidthPosX = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; + int tilePositionY = (int)(NPC.position.Y / 16f) - 1; + int tileWidthPosY = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; + if (tilePositionX < 0) + { + tilePositionX = 0; + } + if (tileWidthPosX > Main.maxTilesX) + { + tileWidthPosX = Main.maxTilesX; + } + if (tilePositionY < 0) + { + tilePositionY = 0; + } + if (tileWidthPosY > Main.maxTilesY) + { + tileWidthPosY = Main.maxTilesY; + } + + bool flying = false; + if (NPC.type >= NPCID.WyvernHead && NPC.type <= NPCID.WyvernTail) + { + flying = true; + } + if (NPC.type == NPCID.StardustWormHead && NPC.ai[1] == -1f) + { + flying = true; + } + if (NPC.type >= NPCID.SolarCrawltipedeHead && NPC.type <= NPCID.SolarCrawltipedeTail) + { + flying = true; + } + if (NPC.type >= NPCID.BloodEelHead && NPC.type <= NPCID.BloodEelTail) + { + flying = true; + } + if (!flying) + { + for (int x = tilePositionX; x < tileWidthPosX; x++) + { + for (int y = tilePositionY; y < tileWidthPosY; y++) + { + if (Main.tile[x, y] != null && ((Main.tile[x, y].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[x, y].TileType] || (Main.tileSolidTop[(int)Main.tile[x, y].TileType] && Main.tile[x, y].TileFrameY == 0))) || Main.tile[x, y].LiquidAmount > 64)) + { + Vector2 flyingPos; + flyingPos.X = (float)(x * 16); + flyingPos.Y = (float)(y * 16); + if (NPC.position.X + (float)NPC.width > flyingPos.X && NPC.position.X < flyingPos.X + 16f && NPC.position.Y + (float)NPC.height > flyingPos.Y && NPC.position.Y < flyingPos.Y + 16f) + { + flying = true; + if (Main.rand.NextBool(100) && NPC.type != NPCID.LeechHead && Main.tile[x, y].HasUnactuatedTile) + { + WorldGen.KillTile(x, y, true, true, false); + } + } + } + } + } + } + + if (!flying && (NPC.type == NPCID.GiantWormHead || NPC.type == NPCID.DevourerHead || NPC.type == NPCID.BoneSerpentHead || NPC.type == NPCID.LeechHead || NPC.type == NPCID.TombCrawlerHead)) + { + Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); + int noFlyZone = 1000; + bool outsideNoFlyZone = true; + for (int f = 0; f < Main.maxPlayers; f++) + { + if (Main.player[f].active) + { + Rectangle rectangle2 = new Rectangle((int)Main.player[f].position.X - noFlyZone, (int)Main.player[f].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); + if (rectangle.Intersects(rectangle2)) + { + outsideNoFlyZone = false; + break; + } + } + } + if (outsideNoFlyZone) + { + flying = true; + } + } + + if ((NPC.type >= NPCID.WyvernHead && NPC.type <= NPCID.WyvernTail) || (NPC.type >= NPCID.BloodEelHead && NPC.type <= NPCID.BloodEelTail)) + { + if (NPC.velocity.X < 0f) + { + NPC.spriteDirection = 1; + } + else if (NPC.velocity.X > 0f) + { + NPC.spriteDirection = -1; + } + } + + if (NPC.type == NPCID.SolarCrawltipedeTail) + { + if (NPC.justHit) + { + NPC.localAI[3] = 3f; + } + if (NPC.localAI[2] > 0f) + { + NPC.localAI[2] -= 16f; + if (NPC.localAI[2] == 0f) + { + NPC.localAI[2] = -128f; + } + } + else if (NPC.localAI[2] < 0f) + { + NPC.localAI[2] += 16f; + } + else if (NPC.localAI[3] > 0f) + { + NPC.localAI[2] = 128f; + NPC.localAI[3] -= 1f; + } + } + + if (NPC.type == NPCID.SolarCrawltipedeHead) + { + Vector2 crawltipedeDustPos = NPC.Center + (NPC.rotation - MathHelper.PiOver2).ToRotationVector2() * 8f; + Vector2 crawltipedeDustRotation = NPC.rotation.ToRotationVector2() * 16f; + Dust crawltipedeDust = Main.dust[Dust.NewDust(crawltipedeDustPos + crawltipedeDustRotation, 0, 0, DustID.Torch, NPC.velocity.X, NPC.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; + crawltipedeDust.noGravity = true; + crawltipedeDust.noLight = true; + crawltipedeDust.position -= new Vector2(4f); + crawltipedeDust.fadeIn = 1f; + crawltipedeDust.velocity = Vector2.Zero; + Dust crawltipedeDust2 = Main.dust[Dust.NewDust(crawltipedeDustPos - crawltipedeDustRotation, 0, 0, DustID.Torch, NPC.velocity.X, NPC.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; + crawltipedeDust2.noGravity = true; + crawltipedeDust2.noLight = true; + crawltipedeDust2.position -= new Vector2(4f); + crawltipedeDust2.fadeIn = 1f; + crawltipedeDust2.velocity = Vector2.Zero; + } + + float wormSpeed = 10f; + float wormAccel = 0.09f; + if (NPC.type == NPCID.DiggerHead) + { + wormSpeed = 6.5f; + wormAccel = 0.05f; + } + if (NPC.type == NPCID.GiantWormHead) + { + wormSpeed = 7.5f; + wormAccel = 0.06f; + } + if (NPC.type == NPCID.TombCrawlerHead) + { + wormSpeed = 8f; + wormAccel = 0.13f; + } + if (NPC.type == NPCID.DuneSplicerHead) + { + if (!Main.player[NPC.target].dead && Main.player[NPC.target].ZoneSandstorm) + { + wormSpeed = 16f; + wormAccel = 0.35f; + } + else + { + wormAccel = 0.25f; + } + } + if (NPC.type == NPCID.WyvernHead) + { + wormSpeed = 11f; + wormAccel = 0.3f; + } + if (NPC.type == NPCID.StardustWormHead) + { + wormSpeed = 9f; + wormAccel = 0.25f; + } + if (NPC.type == NPCID.LeechHead && Main.wofNPCIndex >= 0) + { + float lifeRatio = (float)Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; + if (lifeRatio < 0.75f) + { + wormSpeed += 1f; + wormAccel += 0.1f; + } + if (lifeRatio < 0.5f) + { + wormSpeed += 1f; + wormAccel += 0.1f; + } + if (lifeRatio < 0.25f) + { + wormSpeed += 2f; + wormAccel += 0.1f; + } + } + if (NPC.type == NPCID.BloodEelHead) + { + wormSpeed = 18f; + wormAccel = 0.6f; + } + + if (CalamityWorld.death) + { + wormSpeed *= 1.25f; + wormAccel *= 1.25f; + } + + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float wormTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float wormTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + + if (NPC.type == NPCID.SolarCrawltipedeHead) + { + wormSpeed = 12f; + wormAccel = 0.32f; + int crawltipedeTargetY = -1; + int targetTileX = (int)(Main.player[NPC.target].Center.X / 16f); + int targetTileY = (int)(Main.player[NPC.target].Center.Y / 16f); + for (int i = targetTileX - 2; i <= targetTileX + 2; i++) + { + for (int j = targetTileY; j <= targetTileY + 15; j++) + { + if (WorldGen.SolidTile2(i, j)) + { + crawltipedeTargetY = j; + break; + } + } + if (crawltipedeTargetY > 0) + { + break; + } + } + if (crawltipedeTargetY > 0) + { + crawltipedeTargetY *= 16; + float crawltipedeYTarget = (float)(crawltipedeTargetY - 800); + if (Main.player[NPC.target].position.Y > crawltipedeYTarget) + { + wormTargetY = crawltipedeYTarget; + if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 500f) + { + if (NPC.velocity.X > 0f) + { + wormTargetX = Main.player[NPC.target].Center.X + 600f; + } + else + { + wormTargetX = Main.player[NPC.target].Center.X - 600f; + } + } + } + } + else + { + wormSpeed = 28f; + wormAccel = 0.8f; + } + float maxWormSpeed = wormSpeed * 1.3f; + float minWormSpeed = wormSpeed * 0.7f; + float velocityCheck = NPC.velocity.Length(); + if (velocityCheck > 0f) + { + if (velocityCheck > maxWormSpeed) + { + NPC.velocity.Normalize(); + NPC.velocity *= maxWormSpeed; + } + else if (velocityCheck < minWormSpeed) + { + NPC.velocity.Normalize(); + NPC.velocity *= minWormSpeed; + } + } + if (crawltipedeTargetY > 0) + { + for (int k = 0; k < Main.maxNPCs; k++) + { + if (Main.npc[k].active && Main.npc[k].type == NPC.type && k != NPC.whoAmI) + { + Vector2 targetDirection = Main.npc[k].Center - NPC.Center; + if (targetDirection.Length() < 400f) + { + targetDirection.Normalize(); + targetDirection *= 1000f; + wormTargetX -= targetDirection.X; + wormTargetY -= targetDirection.Y; + } + } + } + } + else + { + for (int l = 0; l < Main.maxNPCs; l++) + { + if (Main.npc[l].active && Main.npc[l].type == NPC.type && l != NPC.whoAmI) + { + Vector2 idleDirection = Main.npc[l].Center - NPC.Center; + if (idleDirection.Length() < 60f) + { + idleDirection.Normalize(); + idleDirection *= 200f; + wormTargetX -= idleDirection.X; + wormTargetY -= idleDirection.Y; + } + } + } + } + } + + wormTargetX = (float)((int)(wormTargetX / 16f) * 16); + wormTargetY = (float)((int)(wormTargetY / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + wormTargetX -= segmentPosition.X; + wormTargetY -= segmentPosition.Y; + float wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); + + if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) + { + try + { + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + wormTargetX = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + wormTargetY = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; + } + catch + { + } + NPC.rotation = (float)Math.Atan2((double)wormTargetY, (double)wormTargetX) + MathHelper.PiOver2; + wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); + int segmentWidth = NPC.width; + if (NPC.type >= NPCID.WyvernHead && NPC.type <= NPCID.WyvernTail) + { + segmentWidth = 42; + } + if (NPC.type >= NPCID.SolarCrawltipedeHead && NPC.type <= NPCID.SolarCrawltipedeTail) + { + segmentWidth += 6; + } + if (NPC.type >= NPCID.BloodEelHead && NPC.type <= NPCID.BloodEelTail) + { + segmentWidth = 24; + } + wormTargetDist = (wormTargetDist - (float)segmentWidth) / wormTargetDist; + wormTargetX *= wormTargetDist; + wormTargetY *= wormTargetDist; + NPC.velocity = Vector2.Zero; + NPC.position.X = NPC.position.X + wormTargetX; + NPC.position.Y = NPC.position.Y + wormTargetY; + if ((NPC.type >= NPCID.WyvernHead && NPC.type <= NPCID.WyvernTail) || (NPC.type >= NPCID.BloodEelHead && NPC.type <= NPCID.BloodEelTail)) + { + if (wormTargetX < 0f) + { + NPC.spriteDirection = 1; + } + else if (wormTargetX > 0f) + { + NPC.spriteDirection = -1; + } + } + } + else + { + if (!flying) + { + NPC.TargetClosest(true); + NPC.velocity.Y = NPC.velocity.Y + 0.11f; + if (NPC.velocity.Y > wormSpeed) + { + NPC.velocity.Y = wormSpeed; + } + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)wormSpeed * 0.4) + { + if (NPC.velocity.X < 0f) + { + NPC.velocity.X = NPC.velocity.X - wormAccel * 1.1f; + } + else + { + NPC.velocity.X = NPC.velocity.X + wormAccel * 1.1f; + } + } + else if (NPC.velocity.Y == wormSpeed) + { + if (NPC.velocity.X < wormTargetX) + { + NPC.velocity.X = NPC.velocity.X + wormAccel; + } + else if (NPC.velocity.X > wormTargetX) + { + NPC.velocity.X = NPC.velocity.X - wormAccel; + } + } + else if (NPC.velocity.Y > 4f) + { + if (NPC.velocity.X < 0f) + { + NPC.velocity.X = NPC.velocity.X + wormAccel * 0.9f; + } + else + { + NPC.velocity.X = NPC.velocity.X - wormAccel * 0.9f; + } + } + } + else + { + if (NPC.type != NPCID.WyvernHead && NPC.type != NPCID.LeechHead && NPC.type != NPCID.SolarCrawltipedeHead && NPC.type != NPCID.BloodEelHead && NPC.soundDelay == 0) + { + float soundDelay = wormTargetDist / 40f; + if (soundDelay < 10f) + { + soundDelay = 10f; + } + if (soundDelay > 20f) + { + soundDelay = 20f; + } + NPC.soundDelay = (int)soundDelay; + SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); + } + + wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); + float absoluteTargetX = Math.Abs(wormTargetX); + float absoluteTargetY = Math.Abs(wormTargetY); + float timeToReachTarget = wormSpeed / wormTargetDist; + wormTargetX *= timeToReachTarget; + wormTargetY *= timeToReachTarget; + + bool wormShouldFlee = false; + if (NPC.type == NPCID.DevourerHead && ((!Main.player[NPC.target].ZoneCorrupt && !Main.player[NPC.target].ZoneCrimson) || Main.player[NPC.target].dead)) + { + wormShouldFlee = true; + } + if ((NPC.type == NPCID.TombCrawlerHead && (double)Main.player[NPC.target].position.Y < Main.worldSurface * 16.0 && !Main.player[NPC.target].ZoneSandstorm && !Main.player[NPC.target].ZoneUndergroundDesert) || Main.player[NPC.target].dead) + { + wormShouldFlee = true; + } + if ((NPC.type == NPCID.DuneSplicerHead && (double)Main.player[NPC.target].position.Y < Main.worldSurface * 16.0 && !Main.player[NPC.target].ZoneSandstorm && !Main.player[NPC.target].ZoneUndergroundDesert) || Main.player[NPC.target].dead) + { + wormShouldFlee = true; + } + if (wormShouldFlee) + { + bool definitelyFlee = true; + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead && Main.player[p].ZoneCorrupt) + { + definitelyFlee = false; + } + } + if (definitelyFlee) + { + if (Main.netMode != NetmodeID.MultiplayerClient && (double)(NPC.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0) + { + NPC.active = false; + int q = (int)NPC.ai[0]; + while (q > 0 && q < Main.maxNPCs && Main.npc[q].active && Main.npc[q].aiStyle == NPC.aiStyle) + { + int differentSegment = (int)Main.npc[q].ai[0]; + Main.npc[q].active = false; + NPC.life = 0; + if (Main.dedServ) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, q, 0f, 0f, 0f, 0, 0, 0); + } + q = differentSegment; + } + if (Main.dedServ) + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI, 0f, 0f, 0f, 0, 0, 0); + } + } + wormTargetX = 0f; + wormTargetY = wormSpeed; + } + } + + bool shouldSwoopDown = false; + if (NPC.type == NPCID.WyvernHead) + { + if (((NPC.velocity.X > 0f && wormTargetX < 0f) || (NPC.velocity.X < 0f && wormTargetX > 0f) || (NPC.velocity.Y > 0f && wormTargetY < 0f) || (NPC.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) > wormAccel / 2f && wormTargetDist < 300f) + { + shouldSwoopDown = true; + + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < wormSpeed) + NPC.velocity *= 1.1f; + } + if (NPC.position.Y > Main.player[NPC.target].position.Y || (double)(Main.player[NPC.target].position.Y / 16f) > Main.worldSurface || Main.player[NPC.target].dead) + { + shouldSwoopDown = true; + + if (Math.Abs(NPC.velocity.X) < wormSpeed / 2f) + { + if (NPC.velocity.X == 0f) + NPC.velocity.X = NPC.velocity.X - NPC.direction; + + NPC.velocity.X = NPC.velocity.X * 1.1f; + } + else if (NPC.velocity.Y > -wormSpeed) + NPC.velocity.Y = NPC.velocity.Y - wormAccel; + } + } + + if (NPC.type == NPCID.BloodEelHead) + { + if (((NPC.velocity.X > 0f && wormTargetX < 0f) || (NPC.velocity.X < 0f && wormTargetX > 0f) || (NPC.velocity.Y > 0f && wormTargetY < 0f) || (NPC.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) > wormAccel / 2f && wormTargetDist < 120f) + { + shouldSwoopDown = true; + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < wormSpeed) + NPC.velocity *= 1.1f; + } + if (NPC.position.Y > Main.player[NPC.target].position.Y || Main.player[NPC.target].dead) + { + shouldSwoopDown = true; + if (Math.Abs(NPC.velocity.X) < wormSpeed / 2f) + { + if (NPC.velocity.X == 0f) + NPC.velocity.X -= NPC.direction; + + NPC.velocity.X *= 1.1f; + } + else if (NPC.velocity.Y > 0f - wormSpeed) + NPC.velocity.Y -= wormAccel; + } + } + + if (!shouldSwoopDown) + { + if ((NPC.velocity.X > 0f && wormTargetX > 0f) || (NPC.velocity.X < 0f && wormTargetX < 0f) || (NPC.velocity.Y > 0f && wormTargetY > 0f) || (NPC.velocity.Y < 0f && wormTargetY < 0f)) + { + if (NPC.velocity.X < wormTargetX) + NPC.velocity.X = NPC.velocity.X + wormAccel; + else if (NPC.velocity.X > wormTargetX) + NPC.velocity.X = NPC.velocity.X - wormAccel; + + if (NPC.velocity.Y < wormTargetY) + NPC.velocity.Y = NPC.velocity.Y + wormAccel; + else if (NPC.velocity.Y > wormTargetY) + NPC.velocity.Y = NPC.velocity.Y - wormAccel; + + if ((double)Math.Abs(wormTargetY) < (double)wormSpeed * 0.2 && ((NPC.velocity.X > 0f && wormTargetX < 0f) || (NPC.velocity.X < 0f && wormTargetX > 0f))) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y = NPC.velocity.Y + wormAccel * 2f; + else + NPC.velocity.Y = NPC.velocity.Y - wormAccel * 2f; + } + + if ((double)Math.Abs(wormTargetX) < (double)wormSpeed * 0.2 && ((NPC.velocity.Y > 0f && wormTargetY < 0f) || (NPC.velocity.Y < 0f && wormTargetY > 0f))) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X = NPC.velocity.X + wormAccel * 2f; + else + NPC.velocity.X = NPC.velocity.X - wormAccel * 2f; + } + } + else if (absoluteTargetX > absoluteTargetY) + { + if (NPC.velocity.X < wormTargetX) + NPC.velocity.X = NPC.velocity.X + wormAccel * 1.1f; + else if (NPC.velocity.X > wormTargetX) + NPC.velocity.X = NPC.velocity.X - wormAccel * 1.1f; + + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)wormSpeed * 0.5) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y = NPC.velocity.Y + wormAccel; + else + NPC.velocity.Y = NPC.velocity.Y - wormAccel; + } + } + else + { + if (NPC.velocity.Y < wormTargetY) + NPC.velocity.Y = NPC.velocity.Y + wormAccel * 1.1f; + else if (NPC.velocity.Y > wormTargetY) + NPC.velocity.Y = NPC.velocity.Y - wormAccel * 1.1f; + + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)wormSpeed * 0.5) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X = NPC.velocity.X + wormAccel; + else + NPC.velocity.X = NPC.velocity.X - wormAccel; + } + } + } + } + + NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + MathHelper.PiOver2; + if (NPC.type == NPCID.DevourerHead || NPC.type == NPCID.GiantWormHead || NPC.type == NPCID.BoneSerpentHead || NPC.type == NPCID.DiggerHead || NPC.type == NPCID.SeekerHead || NPC.type == NPCID.LeechHead || NPC.type == NPCID.DuneSplicerHead || NPC.type == NPCID.TombCrawlerHead) + { + if (flying) + { + if (NPC.localAI[0] != 1f) + NPC.netUpdate = true; + + NPC.localAI[0] = 1f; + } + else + { + if (NPC.localAI[0] != 0f) + NPC.netUpdate = true; + + NPC.localAI[0] = 0f; + } + + if (((NPC.velocity.X > 0f && NPC.oldVelocity.X < 0f) || (NPC.velocity.X < 0f && NPC.oldVelocity.X > 0f) || (NPC.velocity.Y > 0f && NPC.oldVelocity.Y < 0f) || (NPC.velocity.Y < 0f && NPC.oldVelocity.Y > 0f)) && !NPC.justHit) + { + NPC.netUpdate = true; + } + } + } + return false; + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs index 2573731e44..76ff14d407 100644 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs @@ -10,12 +10,8 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies { - public static class SlimeAI + public class SlimeAI : VanillaAIOverride { - public const float SpikedSlimeSpikeBarrageGateValue = 30f; - public const float SpikedSlimeSpikeGateValue = 50f; - public const float SpikedSlimeSpikeTelegraphTime = 30f; - public static void ChooseRandomItem(out int dropItem) { // Use a fallback of -1. @@ -90,34 +86,34 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies } } - public static bool BuffedSlimeAI(NPC npc, Mod mod) + public override bool AI(Mod mod) { - bool isSpikedSlime = npc.type == NPCID.SlimeSpiked || npc.type == NPCID.SpikedIceSlime || npc.type == NPCID.SpikedJungleSlime || npc.type == ModContent.NPCType(); - bool isLavaSlime = npc.type == NPCID.LavaSlime || npc.type == ModContent.NPCType(); - bool canShootProjectile = npc.type == NPCID.SpikedIceSlime || npc.type == NPCID.SlimeSpiked || npc.type == NPCID.SpikedJungleSlime; + bool isSpikedSlime = NPC.type == NPCID.SlimeSpiked || NPC.type == NPCID.SpikedIceSlime || NPC.type == NPCID.SpikedJungleSlime || NPC.type == ModContent.NPCType(); + bool isLavaSlime = NPC.type == NPCID.LavaSlime || NPC.type == ModContent.NPCType(); + bool canShootProjectile = NPC.type == NPCID.SpikedIceSlime || NPC.type == NPCID.SlimeSpiked || NPC.type == NPCID.SpikedJungleSlime; int projectileShootType = -1; float projectileShootSpeedFactor = 1f; - if (npc.type == NPCID.SpikedIceSlime) + if (NPC.type == NPCID.SpikedIceSlime) projectileShootType = ProjectileID.IceSpike; - if (npc.type == NPCID.SlimeSpiked) + if (NPC.type == NPCID.SlimeSpiked) projectileShootType = ProjectileID.SpikedSlimeSpike; - if (npc.type == NPCID.SpikedJungleSlime) + if (NPC.type == NPCID.SpikedJungleSlime) { projectileShootType = ProjectileID.JungleSpike; - projectileShootSpeedFactor *= 1.5f; + projectileShootSpeedFactor *= 0.6f; } - ref float jumpDelay = ref npc.ai[0]; - ref float dropItemID = ref npc.ai[1]; - ref float targetResetCountdown = ref npc.ai[2]; - ref float projectileShootCountdown = ref npc.localAI[0]; + ref float jumpDelay = ref NPC.ai[0]; + ref float dropItemID = ref NPC.ai[1]; + ref float targetResetCountdown = ref NPC.ai[2]; + ref float projectileShootCountdown = ref NPC.localAI[0]; - if (npc.type == NPCID.BlueSlime && (dropItemID == 1f || dropItemID == 2f || dropItemID == 3f)) + if (NPC.type == NPCID.BlueSlime && (dropItemID == 1f || dropItemID == 2f || dropItemID == 3f)) dropItemID = -1f; // Determine what the slime holds, if anything. This does not apply to slimes that are have no money tp drop. - if (npc.type == NPCID.BlueSlime && dropItemID == 0f && Main.netMode != NetmodeID.MultiplayerClient && npc.value > 0f) + if (NPC.type == NPCID.BlueSlime && dropItemID == 0f && Main.netMode != NetmodeID.MultiplayerClient && NPC.value > 0f) { dropItemID = -1f; @@ -125,32 +121,32 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies { ChooseRandomItem(out int dropItem); dropItemID = dropItem; - npc.netUpdate = true; + NPC.netUpdate = true; } } // Decide colors for rainbow slimes. - if (npc.type == NPCID.RainbowSlime) + if (NPC.type == NPCID.RainbowSlime) { - Lighting.AddLight(npc.Center / 16, Main.DiscoColor.ToVector3() * -1f); - npc.color.R = (byte)Main.DiscoR; - npc.color.G = (byte)Main.DiscoG; - npc.color.B = (byte)Main.DiscoB; - npc.color.A = 100; - npc.alpha = 175; + Lighting.AddLight(NPC.Center / 16, Main.DiscoColor.ToVector3() * -1f); + NPC.color.R = (byte)Main.DiscoR; + NPC.color.G = (byte)Main.DiscoG; + NPC.color.B = (byte)Main.DiscoB; + NPC.color.A = 100; + NPC.alpha = 175; } // Have corrupt slimes emit demonite dust. - if (npc.type == NPCID.CorruptSlime && Main.rand.NextBool(30)) + if (NPC.type == NPCID.CorruptSlime && Main.rand.NextBool(30)) { - Dust demonite = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Demonite, 0f, 0f, npc.alpha, npc.color, 1f); + Dust demonite = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, NPC.alpha, NPC.color, 1f); demonite.velocity *= 0.3f; } // Have ice slimes emit snow dust. - if ((npc.type == NPCID.IceSlime || npc.type == NPCID.SpikedIceSlime) && Main.rand.NextBool(10)) + if ((NPC.type == NPCID.IceSlime || NPC.type == NPCID.SpikedIceSlime) && Main.rand.NextBool(10)) { - Dust snow = Dust.NewDustDirect(npc.position, npc.width, npc.height, DustID.Snow, 0f, 0f, 0, default, 1f); + Dust snow = Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, DustID.Snow, 0f, 0f, 0, default, 1f); snow.noGravity = true; snow.velocity *= 0.1f; } @@ -158,10 +154,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies if (isLavaSlime) { // Emit orange light. - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 1f, 0.3f, 0.1f); + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 1f, 0.3f, 0.1f); // And fire. dust. - int idx = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Torch, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default, 1.7f); + int idx = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Torch, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default, 1.7f); Main.dust[idx].noGravity = true; } @@ -172,19 +168,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies if (projectileShootCountdown > 0f) projectileShootCountdown--; - float distanceFromTarget = npc.Distance(Main.player[npc.target].Center); - bool noTilesInWayOfTarget = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + float distanceFromTarget = NPC.Distance(Main.player[NPC.target].Center); + bool noTilesInWayOfTarget = Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); // If not in water, the target can be hit by this NPC, and they're close and in a line of sight, release projectiles. - if (!npc.wet && !Main.player[npc.target].npcTypeNoAggro[npc.type] && noTilesInWayOfTarget && distanceFromTarget < 200f && npc.velocity.Y == 0f) + if (!NPC.wet && !Main.player[NPC.target].npcTypeNoAggro[NPC.type] && noTilesInWayOfTarget && distanceFromTarget < 200f && NPC.velocity.Y == 0f) { jumpDelay = -40f; - npc.velocity.X *= 0.9f; + NPC.velocity.X *= 0.9f; if (Main.netMode != NetmodeID.MultiplayerClient && projectileShootCountdown <= 0f) { - var source = npc.GetSource_FromAI(); - if (Main.expertMode && distanceFromTarget < 120f) + var source = NPC.GetSource_FromAI(); + if (distanceFromTarget < 120f) { for (int i = 0; i < 5; i++) { @@ -192,60 +188,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies spikeShootVelocity *= Main.rand.NextVector2Square(0.75f, 1.25f); spikeShootVelocity.Normalize(); spikeShootVelocity *= Main.rand.NextFloat(3.5f, 4.5f) * projectileShootSpeedFactor; - int proj = Projectile.NewProjectile(source, npc.Center, spikeShootVelocity, projectileShootType, 9, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(source, NPC.Center, spikeShootVelocity, projectileShootType, 9, 0f, Main.myPlayer); if (CalamityWorld.death) Main.projectile[proj].extraUpdates += 1; - projectileShootCountdown = SpikedSlimeSpikeBarrageGateValue; + projectileShootCountdown = 30f; } } else { - Vector2 velocity = npc.SafeDirectionTo(Main.player[npc.target].Center - Vector2.UnitY * (npc.type == NPCID.SpikedJungleSlime ? 10f : 100f)) * projectileShootSpeedFactor * (CalamityWorld.death ? 3.25f : CalamityWorld.revenge ? 5.5f : 4.5f); - int proj = Projectile.NewProjectile(source, npc.Center, velocity, projectileShootType, 9, 0f, Main.myPlayer); + Vector2 velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center - Vector2.UnitY * 100f) * projectileShootSpeedFactor * (CalamityWorld.death ? 3.25f : CalamityWorld.revenge ? 5.5f : 4.5f); + int proj = Projectile.NewProjectile(source, NPC.Center, velocity, projectileShootType, 9, 0f, Main.myPlayer); if (CalamityWorld.death) { Main.projectile[proj].extraUpdates += 1; Main.projectile[proj].timeLeft = 1200; } - projectileShootCountdown = SpikedSlimeSpikeGateValue; + projectileShootCountdown = 50f; } } } else - projectileShootCountdown = SpikedSlimeSpikeGateValue; - - if (npc.type == NPCID.SpikedIceSlime) - { - // Emit dust from center when about to shoot - if (projectileShootCountdown <= SpikedSlimeSpikeTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 135, 0f, 0f, 100, default, 3f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } - else if (npc.type == NPCID.SpikedJungleSlime) - { - // Emit dust from center when about to shoot - if (projectileShootCountdown <= SpikedSlimeSpikeTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 61, 0f, 0f, 0, default, 3f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } - else if (npc.type == NPCID.SlimeSpiked) - { - // Emit dust from center when about to shoot - if (projectileShootCountdown <= SpikedSlimeSpikeTelegraphTime) - { - Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 4, 0f, 0f, 0, new Color(78, 136, 255, 150), 1.5f); - dust.noGravity = true; - dust.velocity *= 0f; - } - } + projectileShootCountdown = 50f; } // Decrement the target reset counter. @@ -253,69 +218,69 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies targetResetCountdown--; // Rise to the top of water. - if (npc.wet) - DoWaterHoverBehavior(npc, isLavaSlime, ref targetResetCountdown); + if (NPC.wet) + DoWaterHoverBehavior(NPC, isLavaSlime, ref targetResetCountdown); - npc.aiAction = 0; + NPC.aiAction = 0; // Initialize with short jumps. if (targetResetCountdown == 0f) { jumpDelay = -100f; targetResetCountdown = 1f; - npc.TargetClosest(); + NPC.TargetClosest(); } // Avoid cheap bullshit if (!isSpikedSlime) - npc.damage = (npc.velocity.Y == 0f || npc.velocity.Length() < 3f) ? 0 : npc.defDamage; + NPC.damage = (NPC.velocity.Y == 0f || NPC.velocity.Length() < 3f) ? 0 : NPC.defDamage; - if (npc.velocity.Y == 0f) + if (NPC.velocity.Y == 0f) { // Slide out of blocks if stuck. - if (npc.collideY && npc.oldVelocity.Y != 0f && Collision.SolidCollision(npc.position, npc.width, npc.height)) - npc.position.X -= npc.velocity.X + npc.direction; + if (NPC.collideY && NPC.oldVelocity.Y != 0f && Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.position.X -= NPC.velocity.X + NPC.direction; - if (npc.ai[3] == npc.position.X) + if (NPC.ai[3] == NPC.position.X) { - npc.direction *= -1; + NPC.direction *= -1; targetResetCountdown = 200f; } - npc.ai[3] = 0f; + NPC.ai[3] = 0f; // Slow down horizontally until stopping. - npc.velocity.X *= 0.8f; - if (Math.Abs(npc.velocity.X) < 0.1f) - npc.velocity.X = 0f; + NPC.velocity.X *= 0.8f; + if (Math.Abs(NPC.velocity.X) < 0.1f) + NPC.velocity.X = 0f; // Slimes jump more quickly overall when the slime rain event is ongoing. jumpDelay += (Main.slimeRain ? 4f : 3f) * (CalamityWorld.death ? 2f : 1f); - if (npc.type == NPCID.HoppinJack || npc.type == NPCID.GoldenSlime) + if (NPC.type == NPCID.HoppinJack || NPC.type == NPCID.GoldenSlime) jumpDelay += 10f; if (isLavaSlime) jumpDelay += 2f; - if (npc.type == NPCID.DungeonSlime || npc.type == ModContent.NPCType() || npc.type == ModContent.NPCType() || - npc.type == ModContent.NPCType()) + if (NPC.type == NPCID.DungeonSlime || NPC.type == ModContent.NPCType() || NPC.type == ModContent.NPCType() || + NPC.type == ModContent.NPCType()) { jumpDelay += 3f; } - if (npc.type == NPCID.RainbowSlime) + if (NPC.type == NPCID.RainbowSlime) jumpDelay += 2f; - if (npc.type == NPCID.IlluminantSlime) + if (NPC.type == NPCID.IlluminantSlime) jumpDelay += 2f; - if (npc.type == NPCID.Crimslime) + if (NPC.type == NPCID.Crimslime) jumpDelay += 1f; // The fuck? This is from vanilla, presumably. I'll leave it alone in the event that it's some dumb spaghetti. - if (npc.type == NPCID.CorruptSlime) - jumpDelay += npc.scale >= 0f ? 4f : 1f; + if (NPC.type == NPCID.CorruptSlime) + jumpDelay += NPC.scale >= 0f ? 4f : 1f; int jumpType = 0; if (jumpDelay >= 0f) @@ -328,30 +293,30 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies jumpType = 3; if (jumpType > 0) - DoJump(npc, jumpType, isLavaSlime, ref targetResetCountdown, out jumpDelay); + DoJump(NPC, jumpType, isLavaSlime, ref targetResetCountdown, out jumpDelay); else if (jumpDelay >= -30f) { - npc.aiAction = 1; + NPC.aiAction = 1; return false; } } - else if (npc.target < Main.maxPlayers && ((npc.direction == 1 && npc.velocity.X < 3f) || (npc.direction == -1 && npc.velocity.X > -3f))) + else if (NPC.target < Main.maxPlayers && ((NPC.direction == 1 && NPC.velocity.X < 3f) || (NPC.direction == -1 && NPC.velocity.X > -3f))) { - if (npc.collideX && Math.Abs(npc.velocity.X) == 0.2f) + if (NPC.collideX && Math.Abs(NPC.velocity.X) == 0.2f) { - npc.position.X -= 1.4f * npc.direction; + NPC.position.X -= 1.4f * NPC.direction; } - if (npc.collideY && npc.oldVelocity.Y != 0f && Collision.SolidCollision(npc.position, npc.width, npc.height)) + if (NPC.collideY && NPC.oldVelocity.Y != 0f && Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { - npc.position.X -= npc.velocity.X + npc.direction; + NPC.position.X -= NPC.velocity.X + NPC.direction; } - if ((npc.direction == -1 && npc.velocity.X < 0.01) || (npc.direction == 1 && npc.velocity.X > -0.01)) + if ((NPC.direction == -1 && NPC.velocity.X < 0.01) || (NPC.direction == 1 && NPC.velocity.X > -0.01)) { - npc.velocity.X += 0.2f * (float)npc.direction; + NPC.velocity.X += 0.2f * (float)NPC.direction; return false; } - npc.velocity.X *= 0.93f; + NPC.velocity.X *= 0.93f; } return false; } @@ -407,7 +372,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies { // Move up if tiles are hit on the Y axis. if (npc.collideY) - npc.velocity.Y = -(CalamityWorld.death ? 4f : CalamityWorld.revenge ? 3f : 2f); + npc.velocity.Y = -(CalamityWorld.death ? 4f : 3f); if (npc.velocity.Y < 0f && npc.ai[3] == npc.position.X) { @@ -418,8 +383,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies if (npc.velocity.Y > 0f) npc.ai[3] = npc.position.X; - float riseSpeed = CalamityWorld.death ? 0.6f : CalamityWorld.revenge ? 0.55f : 0.5f; - float maxRiseSpeed = CalamityWorld.death ? 6f : CalamityWorld.revenge ? 5f : 4f; + float riseSpeed = CalamityWorld.death ? 0.6f : 0.55f; + float maxRiseSpeed = CalamityWorld.death ? 6f : 5f; if (isLavaSlime) { riseSpeed += 0.2f; diff --git a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs new file mode 100644 index 0000000000..13fb90fdc4 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs @@ -0,0 +1,81 @@ +using System.IO; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides +{ + public abstract class VanillaAIOverride : ILoadable + { + public NPC NPC { get; set; } + public bool DisableMultiplayerSmoothing { get; set; } + public virtual bool EnableMultiplayerSmoothingAheadOfAI => false; + + void ILoadable.Load(Mod mod) + { + CalamityVanillaAIOverrideNPC.RegisterNetID(this); + Load(); + } + + void ILoadable.Unload() + { + Unload(); + } + + public virtual void Load() { } + + public virtual void Unload() { } + + public abstract bool AI(Mod mod); + + public virtual void SetDefaults(Mod mod) { } + + public virtual void OnSpawn(Mod mod) { } + + public virtual void PostAI(Mod mod) + { + + } + + public virtual void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter) + { + + } + + public virtual void ReceiveExtraAI(BitReader bitReader, BinaryReader binaryReader) + { + + } + + public virtual bool? CanBeHitByProjectile(Mod mod, Projectile projectile) => null; + + public virtual void ModifyHitByItem(Mod mod, Player player, Item item, ref NPC.HitModifiers modifiers) { } + + public virtual void ModifyHitByProjectile(Mod mod, Projectile projectile, ref NPC.HitModifiers modifiers) { } + + public virtual void OnHitByItem(Mod mod, Player player, Item item, NPC.HitInfo hit, int damageDone) { } + + public virtual void OnHitByProjectile(Mod mod, Projectile projectile, NPC.HitInfo hit, int damageDone) { } + + public virtual void HitEffect(Mod mod, NPC.HitInfo hit) { } + + public virtual bool PreKill(Mod mod) => true; + + public virtual void FindFrame(Mod mod, int frameHeight) { } + + public virtual bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) => true; + + public virtual void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { } + + /// + /// This Method should be Implemented If we added our custom field to AI Overrides + /// + /// + public virtual VanillaAIOverride Clone() + { + return (VanillaAIOverride)this.MemberwiseClone(); + } + } +} diff --git a/NPCs/VanillaNPCAIOverrides/VanillaAIOverrideContext.cs b/NPCs/VanillaNPCAIOverrides/VanillaAIOverrideContext.cs new file mode 100644 index 0000000000..24e5af1645 --- /dev/null +++ b/NPCs/VanillaNPCAIOverrides/VanillaAIOverrideContext.cs @@ -0,0 +1,13 @@ +using Terraria; + +namespace CalamityMod.NPCs.VanillaNPCAIOverrides; + +public class VanillaAIOverrideContext +{ + public NPC NPC { get; init; } + public int NPCType { get; init; } + public bool InRevengeanceWorld { get; init; } + public bool InDeathWorld { get; init; } + public bool InBossRush { get; init; } + public VanillaAIOverride OverrideToApply { get; set; } +} diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index e67348f628..c554318e43 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -1,15 +1,13 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.BossRelics; -using CalamityMod.Items.Placeables.Furniture.DevPaintings; +using CalamityMod.Items.Placeables.Furniture.Paintings; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.SummonItems; @@ -19,11 +17,9 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.NPCs.Bumblebirb; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Rogue; using CalamityMod.Tiles.Ores; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -56,11 +52,9 @@ namespace CalamityMod.NPCs.Yharon private int invincibilityCounter = 0; private int fastChargeTelegraphTime = 120; - private const float ai2GateValue = 0.55f; - public const int Phase2InvincibilityTime = 300; - - public static float normalDR = 0.22f; - public static float EnragedDR = 0.9f; + private const float AI2GateValue = 0.55f; + private const int Phase2InvincibilityTime = 300; + private const float EnragedDR = 0.9f; public static readonly SoundStyle RoarSound = new("CalamityMod/Sounds/Custom/Yharon/YharonRoar"); public static readonly SoundStyle ShortRoarSound = new("CalamityMod/Sounds/Custom/Yharon/YharonRoarShort"); @@ -99,21 +93,28 @@ namespace CalamityMod.NPCs.Yharon } } + public static int FlareDamage = 66; // 264; FlareBomb, FlareDust, FlareDust2 + public static int FireballDamage = 66; // 264 + public static int TornadoDamage = 85; // 340; Flarenado, Infernado, Infernado2 + public static int BordernadoDamage = 125; // 500; SkyFlareRevenge + + // GFB exclusive + public static int VortexDamage = 85; // 340 + public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; + NPC.damage = 210; // 420 NPC.npcSlots = 50f; - NPC.GetNPCDamage(); NPC.width = 200; NPC.height = 200; NPC.defense = 90; - NPC.LifeMaxNERB(1300000, 1560000, 740000); + NPC.LifeMaxNERB(1000000, 1560000, 740000); NPC.knockBackResist = 0f; NPC.aiStyle = -1; AIType = -1; - NPC.value = Item.buyPrice(2, 50, 0, 0); + NPC.value = Item.buyPrice(platinum: 2, gold: 50); NPC.boss = true; - NPC.DR_NERD(normalDR); NPC.noGravity = true; NPC.noTileCollide = true; @@ -123,9 +124,6 @@ namespace CalamityMod.NPCs.Yharon NPC.Calamity().VulnerableToHeat = false; NPC.Calamity().VulnerableToCold = true; NPC.Calamity().VulnerableToSickness = true; - - // Scale HP in Master - CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC, true); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -201,13 +199,9 @@ namespace CalamityMod.NPCs.Yharon CalamityWorld.StopRain(); // Variables - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool masterMode = Main.masterMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; - - float pie = (float)Math.PI; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; CalamityGlobalNPC.yharon = NPC.whoAmI; CalamityGlobalNPC.yharonP2 = -1; @@ -217,15 +211,15 @@ namespace CalamityMod.NPCs.Yharon // Start phase 2 or not if (startSecondAI) { - Yharon_AI2(expertMode, masterMode, revenge, death, bossRush, pie, lifeRatio, calamityGlobalNPC, setDamage); + Yharon_AI2(expertMode, revenge, death, lifeRatio, calamityGlobalNPC, setDamage); return; } // Phase booleans - float phase2GateValue = revenge ? 0.9f : expertMode ? 0.85f : 0.75f; + float phase2GateValue = revenge ? 0.9f : expertMode ? 0.85f : 0.8f; bool phase2Check = death || lifeRatio <= phase2GateValue; - bool phase3Check = lifeRatio <= (death ? 0.8f : revenge ? 0.75f : expertMode ? 0.7f : 0.625f); - bool phase4Check = lifeRatio <= ai2GateValue; + bool phase3Check = lifeRatio <= (death ? 0.8f : revenge ? 0.75f : expertMode ? 0.7f : 0.65f); + bool phase4Check = lifeRatio <= AI2GateValue; bool phase1Change = NPC.ai[0] > -1f; bool phase2Change = NPC.ai[0] > 5f; bool phase3Change = NPC.ai[0] > 12f; @@ -256,7 +250,7 @@ namespace CalamityMod.NPCs.Yharon float reduceSpeedChargeDistance = 540f; int chargeTime = expertMode ? 40 : 45; float chargeSpeed = expertMode ? 28f : 26f; - float fastChargeVelocityMultiplier = bossRush ? 2f : 1.5f; + float fastChargeVelocityMultiplier = 1.5f; bool playFastChargeRoarSound = NPC.localAI[1] == fastChargeTelegraphTime * 0.5f; bool doFastCharge = NPC.localAI[1] > fastChargeTelegraphTime; @@ -275,8 +269,8 @@ namespace CalamityMod.NPCs.Yharon if (revenge) { - int chargeTimeDecrease = bossRush ? 6 : death ? 4 : 2; - float velocityMult = bossRush ? 1.15f : death ? 1.1f : 1.05f; + int chargeTimeDecrease = death ? 4 : 2; + float velocityMult = death ? 1.1f : 1.05f; phaseSwitchTimer -= chargeTimeDecrease; acceleration *= velocityMult; velocity *= velocityMult; @@ -285,17 +279,17 @@ namespace CalamityMod.NPCs.Yharon } float reduceSpeedFlareBombDistance = 570f; - int flareBombPhaseTimer = bossRush ? 30 : death ? 40 : 60; + int flareBombPhaseTimer = death ? 40 : 60; int flareBombSpawnDivisor = flareBombPhaseTimer / 20; - float flareBombPhaseAcceleration = bossRush ? 1f : death ? 0.92f : 0.8f; - float flareBombPhaseVelocity = bossRush ? 16f : death ? 14f : 12f; + float flareBombPhaseAcceleration = death ? 0.92f : 0.8f; + float flareBombPhaseVelocity = death ? 14f : 12f; int fireTornadoPhaseTimer = 90; int newPhaseTimer = 180; - int flareDustPhaseTimer = bossRush ? 160 : death ? 200 : 240; - int flareDustPhaseTimer2 = bossRush ? 80 : death ? 100 : 120; + int flareDustPhaseTimer = death ? 200 : 240; + int flareDustPhaseTimer2 = death ? 100 : 120; float spinTime = flareDustPhaseTimer / 2; @@ -306,12 +300,12 @@ namespace CalamityMod.NPCs.Yharon float spinPhaseVelocity = 25f; float spinPhaseRotation = MathHelper.TwoPi * 3 / spinTime; - float increasedIdleTimeAfterBulletHell = (masterMode ? 120f : 180f) + phaseSwitchTimer; + float increasedIdleTimeAfterBulletHell = (death ? 120f : 180f) + phaseSwitchTimer; bool moveSlowerAfterBulletHell = NPC.ai[2] < 0f; bool slowChargeAfterBulletHell = NPC.ai[2] == -1f; if (moveSlowerAfterBulletHell) { - float reducedMovementMultiplier = MathHelper.Lerp(0.1f, masterMode ? 1f : 0.75f, (NPC.ai[2] + increasedIdleTimeAfterBulletHell) / increasedIdleTimeAfterBulletHell); + float reducedMovementMultiplier = MathHelper.Lerp(0.1f, death ? 1f : 0.75f, (NPC.ai[2] + increasedIdleTimeAfterBulletHell) / increasedIdleTimeAfterBulletHell); acceleration *= reducedMovementMultiplier; velocity *= reducedMovementMultiplier; chargeSpeed *= reducedMovementMultiplier; @@ -370,12 +364,12 @@ namespace CalamityMod.NPCs.Yharon enraged = false; if (Main.netMode != NetmodeID.MultiplayerClient) { - safeBox.X = (int)(player.Center.X - (Main.zenithWorld ? 1500f : Main.getGoodWorld ? 1000f : bossRush ? 2000f : revenge ? 3000f : 3500f)); + safeBox.X = (int)(player.Center.X - (Main.zenithWorld ? 1500f : Main.getGoodWorld ? 1000f : revenge ? 3000f : 3500f)); safeBox.Y = (int)Main.topWorld; - safeBox.Width = Main.zenithWorld ? 3000 : Main.getGoodWorld ? 2000 : bossRush ? 4000 : revenge ? 6000 : 7000; + safeBox.Width = Main.zenithWorld ? 3000 : Main.getGoodWorld ? 2000 : revenge ? 6000 : 7000; safeBox.Height = Main.maxTilesY * 16; - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + (Main.zenithWorld ? 1500f : Main.getGoodWorld ? 1000f : bossRush ? 2000f : revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X - (Main.zenithWorld ? 1500f : Main.getGoodWorld ? 1000f : bossRush ? 2000f : revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X + (Main.zenithWorld ? 1500f : Main.getGoodWorld ? 1000f : revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X - (Main.zenithWorld ? 1500f : Main.getGoodWorld ? 1000f : revenge ? 3000f : 3500f), player.Center.Y + 100f, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); } // Force Yharon to send a sync packet so that the arena gets sent immediately @@ -403,7 +397,7 @@ namespace CalamityMod.NPCs.Yharon // Set DR based on protection boost (aka enrage) bool chargeTelegraph = (NPC.ai[0] == 0f || NPC.ai[0] == 6f || NPC.ai[0] == 13f) && NPC.localAI[1] > 0f; bool bulletHell = NPC.ai[0] == 8f || NPC.ai[0] == 15f; - calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; + calamityGlobalNPC.DR = protectionBoost ? EnragedDR : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = protectionBoost; // Increased DR during phase transitions @@ -411,17 +405,17 @@ namespace CalamityMod.NPCs.Yharon { if (phase3Change) { - calamityGlobalNPC.DR = phase4Check ? (bossRush ? 0.99f : 0.7f) : normalDR; + calamityGlobalNPC.DR = phase4Check ? 0.7f : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase4Check; } else if (phase2Change) { - calamityGlobalNPC.DR = phase3Check ? (bossRush ? 0.99f : 0.7f) : normalDR; + calamityGlobalNPC.DR = phase3Check ? 0.7f : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase3Check; } else if (phase1Change) { - calamityGlobalNPC.DR = phase2Check ? (bossRush ? 0.99f : 0.7f) : normalDR; + calamityGlobalNPC.DR = phase2Check ? 0.7f : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase2Check; } } @@ -444,7 +438,7 @@ namespace CalamityMod.NPCs.Yharon // Rotation float npcRotation = (float)Math.Atan2(player.Center.Y - NPC.Center.Y, player.Center.X - NPC.Center.X); if (NPC.spriteDirection == 1) - npcRotation += pie; + npcRotation += MathHelper.Pi; if (npcRotation < 0f) npcRotation += MathHelper.TwoPi; if (npcRotation > MathHelper.TwoPi) @@ -552,7 +546,7 @@ namespace CalamityMod.NPCs.Yharon Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; - if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance && NPC.localAI[1] <= fastChargeTelegraphTime * 0.5f) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; @@ -561,12 +555,12 @@ namespace CalamityMod.NPCs.Yharon if (phaseSwitchFaceDirection != 0) { if (NPC.ai[2] == 0f && phaseSwitchFaceDirection != NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.direction = phaseSwitchFaceDirection; if (NPC.spriteDirection != -NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -613,7 +607,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = phaseSwitchFaceDirection; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -660,7 +654,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = phaseSwitchFaceDirection; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -677,7 +671,7 @@ namespace CalamityMod.NPCs.Yharon // Set damage NPC.damage = setDamage; - ChargeDust(7, pie); + ChargeDust(7); NPC.ai[2] += 1f; if (NPC.ai[2] >= chargeTime) @@ -717,8 +711,7 @@ namespace CalamityMod.NPCs.Yharon if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, Vector2.Zero, type, damage, 0f, Main.myPlayer, NPC.target, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, Vector2.Zero, type, FlareDamage, 0f, Main.myPlayer, NPC.target, 1f); } } @@ -728,7 +721,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirection; if (NPC.spriteDirection != -NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -804,7 +797,7 @@ namespace CalamityMod.NPCs.Yharon // Set damage NPC.damage = setDamage; - ChargeDust(14, pie); + ChargeDust(14); NPC.ai[2] += 1f; if (NPC.ai[2] >= chargeTime) @@ -833,7 +826,7 @@ namespace CalamityMod.NPCs.Yharon Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; - if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance && NPC.localAI[1] <= fastChargeTelegraphTime * 0.5f) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; @@ -842,12 +835,12 @@ namespace CalamityMod.NPCs.Yharon if (playerFaceDirectionFurtherPhases != 0) { if (NPC.ai[2] == 0f && playerFaceDirectionFurtherPhases != NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection != -NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -897,7 +890,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -924,7 +917,7 @@ namespace CalamityMod.NPCs.Yharon NPC.Center = center; int type = ModContent.ProjectileType(); - int damage = Main.zenithWorld ? NPC.GetProjectileDamage(type) : 0; + int damage = Main.zenithWorld ? VortexDamage : 0; float bulletHellVortexDuration = flareDustPhaseTimer + teleportPhaseTimer - 15f; int extraTime = Main.zenithWorld ? 300 : 0; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, bulletHellVortexDuration + extraTime, NPC.whoAmI); @@ -990,7 +983,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -1008,7 +1001,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -1027,7 +1020,7 @@ namespace CalamityMod.NPCs.Yharon // Set damage NPC.damage = setDamage; - ChargeDust(7, pie); + ChargeDust(7); NPC.ai[2] += 1f; if (NPC.ai[2] >= chargeTime) @@ -1061,7 +1054,7 @@ namespace CalamityMod.NPCs.Yharon { int ringReduction = (int)MathHelper.Lerp(0f, 14f, NPC.ai[2] / flareDustPhaseTimer); int totalProjectiles = 38 - ringReduction; // 36 for first ring, 22 for last ring - DoFlareDustBulletHell(0, flareDustSpawnDivisor, NPC.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, false); + DoFlareDustBulletHell(0, flareDustSpawnDivisor, FlareDamage, totalProjectiles, 0f, 0f, false); } } @@ -1132,7 +1125,7 @@ namespace CalamityMod.NPCs.Yharon // Set damage NPC.damage = setDamage; - ChargeDust(14, pie); + ChargeDust(14); NPC.ai[2] += 1f; if (NPC.ai[2] >= chargeTime) @@ -1164,10 +1157,9 @@ namespace CalamityMod.NPCs.Yharon Vector2 projectileVelocity = NPC.velocity; projectileVelocity.Normalize(); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); float finalVelocity = 12f; float projectileAcceleration = 1.1f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, projectileVelocity, type, damage, 0f, Main.myPlayer, finalVelocity, projectileAcceleration); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, projectileVelocity, type, FlareDamage, 0f, Main.myPlayer, finalVelocity, projectileAcceleration); } } @@ -1200,7 +1192,7 @@ namespace CalamityMod.NPCs.Yharon Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; - if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance && NPC.localAI[1] <= fastChargeTelegraphTime * 0.5f) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; @@ -1209,12 +1201,12 @@ namespace CalamityMod.NPCs.Yharon if (playerFaceDirectionFurtherPhases != 0) { if (NPC.ai[2] == 0f && playerFaceDirectionFurtherPhases != NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection != -NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -1267,7 +1259,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -1294,7 +1286,7 @@ namespace CalamityMod.NPCs.Yharon NPC.Center = center; int type = ModContent.ProjectileType(); - int damage = Main.zenithWorld ? NPC.GetProjectileDamage(type) : 0; + int damage = Main.zenithWorld ? VortexDamage : 0; float bulletHellVortexDuration = flareDustPhaseTimer + teleportPhaseTimer - 15f; int extraTime = Main.zenithWorld ? 300 : 0; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, bulletHellVortexDuration + extraTime, NPC.whoAmI); @@ -1360,7 +1352,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -1378,7 +1370,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirectionFurtherPhases; if (NPC.spriteDirection == 1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -1404,7 +1396,7 @@ namespace CalamityMod.NPCs.Yharon // Set damage NPC.damage = setDamage; - ChargeDust(7, pie); + ChargeDust(7); NPC.ai[2] += 1f; if (NPC.ai[2] >= chargeTime) @@ -1437,7 +1429,7 @@ namespace CalamityMod.NPCs.Yharon if (Main.netMode != NetmodeID.MultiplayerClient) { - DoFlareDustBulletHell(1, flareDustPhaseTimer, NPC.GetProjectileDamage(ModContent.ProjectileType()), 8, 12f, 3.6f, false); + DoFlareDustBulletHell(1, flareDustPhaseTimer, FlareDamage, 8, 13f, 3.6f, false); } } @@ -1511,7 +1503,7 @@ namespace CalamityMod.NPCs.Yharon // Set damage NPC.damage = setDamage; - ChargeDust(14, pie); + ChargeDust(14); NPC.ai[2] += 1f; if (NPC.ai[2] >= chargeTime) @@ -1543,10 +1535,9 @@ namespace CalamityMod.NPCs.Yharon Vector2 projectileVelocity = NPC.velocity; projectileVelocity.Normalize(); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); float finalVelocity = 15f; float projectileAcceleration = 1.11f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, projectileVelocity, type, damage, 0f, Main.myPlayer, finalVelocity, projectileAcceleration); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, projectileVelocity, type, FlareDamage, 0f, Main.myPlayer, finalVelocity, projectileAcceleration); } } @@ -1590,8 +1581,7 @@ namespace CalamityMod.NPCs.Yharon if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, Vector2.Zero, type, damage, 0f, Main.myPlayer, NPC.target, 1f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), fromMouth, Vector2.Zero, type, FlareDamage, 0f, Main.myPlayer, NPC.target, 1f); } } @@ -1601,7 +1591,7 @@ namespace CalamityMod.NPCs.Yharon NPC.direction = playerFaceDirection; if (NPC.spriteDirection != -NPC.direction) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.spriteDirection = -NPC.direction; } @@ -1620,16 +1610,14 @@ namespace CalamityMod.NPCs.Yharon } #region AI2 - public void Yharon_AI2(bool expertMode, bool masterMode, bool revenge, bool death, bool bossRush, float pie, float lifeRatio, CalamityGlobalNPC calamityGlobalNPC, int contactDamage) + public void Yharon_AI2(bool expertMode, bool revenge, bool death, float lifeRatio, CalamityGlobalNPC calamityGlobalNPC, int contactDamage) { CalamityGlobalNPC.yharonP2 = NPC.whoAmI; - float phase2GateValue = revenge ? 0.44f : expertMode ? 0.385f : 0.275f; + float phase2GateValue = revenge ? 0.45f : expertMode ? 0.35f : 0.3f; bool phase2 = death || lifeRatio <= phase2GateValue; - float phase3GateValue = death ? 0.358f : revenge ? 0.275f : expertMode ? 0.22f : 0.138f; - bool phase3 = lifeRatio <= phase3GateValue; - float phase4GateValue = death ? 0.165f : 0.11f; - bool phase4 = lifeRatio <= phase4GateValue && revenge; + bool phase3 = lifeRatio <= (death ? 0.35f : revenge ? 0.3f : expertMode ? 0.2f : 0.15f); + bool phase4 = lifeRatio <= (death ? 0.2f : 0.15f) && revenge; if (NPC.ai[0] != 5f && NPC.ai[0] != 8f) { @@ -1645,7 +1633,7 @@ namespace CalamityMod.NPCs.Yharon string key = "Mods.CalamityMod.Status.Boss.FlameText"; Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } int setDamage = contactDamage; @@ -1723,7 +1711,7 @@ namespace CalamityMod.NPCs.Yharon // Set DR based on protection boost (aka enrage) bool bulletHell = NPC.ai[0] == 5f; NPC.dontTakeDamage = bulletHell; - calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; + calamityGlobalNPC.DR = protectionBoost ? EnragedDR : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = protectionBoost; // Increased DR during phase transitions @@ -1733,21 +1721,21 @@ namespace CalamityMod.NPCs.Yharon { case 1: - calamityGlobalNPC.DR = phase2 ? (bossRush ? 0.99f : 0.7f) : normalDR; + calamityGlobalNPC.DR = phase2 ? 0.7f : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase2; break; case 2: - calamityGlobalNPC.DR = phase3 ? (bossRush ? 0.99f : 0.7f) : normalDR; + calamityGlobalNPC.DR = phase3 ? 0.7f : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase3; break; case 3: - calamityGlobalNPC.DR = phase4 ? (bossRush ? 0.99f : 0.7f) : normalDR; + calamityGlobalNPC.DR = phase4 ? 0.7f : 0f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phase4; break; @@ -1755,27 +1743,27 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[0] == 9f) { - calamityGlobalNPC.DR = bossRush ? 0.99f : 0.7f; + calamityGlobalNPC.DR = 0.7f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = true; } } float reduceSpeedChargeDistance = 500f; float reduceSpeedFireballSpitChargeDistance = 800f; - float phaseSwitchTimer = bossRush ? 28f : expertMode ? 30f : 32f; + float phaseSwitchTimer = expertMode ? 30f : 32f; float acceleration = expertMode ? 0.92f : 0.9f; float velocity = expertMode ? 14.5f : 14f; float chargeTime = expertMode ? 32f : 35f; float chargeSpeed = expertMode ? 32f : 30f; - float fastChargeVelocityMultiplier = bossRush ? 2f : 1.5f; + float fastChargeVelocityMultiplier = 1.5f; fastChargeTelegraphTime = protectionBoost ? 60 : (100 - secondPhasePhase * 10); bool playFastChargeRoarSound = NPC.localAI[1] == fastChargeTelegraphTime * 0.5f; bool doFastChargeTelegraph = NPC.localAI[1] <= fastChargeTelegraphTime; float fireballBreathTimer = 60f; float fireballBreathPhaseTimer = fireballBreathTimer + 80f; - float fireballBreathPhaseVelocity = expertMode ? 32f : 30f; + float fireballBreathPhaseVelocity = expertMode ? 28f : 25f; float splittingFireballBreathTimer = 40f; float splittingFireballBreathPhaseVelocity = 22f; @@ -1785,31 +1773,31 @@ namespace CalamityMod.NPCs.Yharon float splittingFireballBreathYVelocityTimer = 40f; float splittingFireballBreathPhaseTimer = splittingFireballBreathTimer + splittingFireballBreathTimer2 + splittingFireballBreathYVelocityTimer; - int spinPhaseTimer = secondPhasePhase == 4 ? (bossRush ? 80 : death ? 100 : 120) : (bossRush ? 120 : death ? 150 : 180); + int spinPhaseTimer = secondPhasePhase == 4 ? (death ? 100 : 120) : (death ? 150 : 180); int flareDustSpawnDivisor = spinPhaseTimer / 10; - int flareDustSpawnDivisor2 = spinPhaseTimer / 20 + (secondPhasePhase == 4 ? spinPhaseTimer / 60 : 0); + int flareDustSpawnDivisor2 = spinPhaseTimer / 15 + (secondPhasePhase == 4 ? spinPhaseTimer / 60 : 0); - float increasedIdleTimeAfterBulletHell = (masterMode ? 120f : 180f) + phaseSwitchTimer; + float increasedIdleTimeAfterBulletHell = (death ? 120f : 180f) + phaseSwitchTimer; bool moveSlowerAfterBulletHell = NPC.ai[1] < 0f; bool slowChargeAfterBulletHell = NPC.ai[1] == -1f; if (moveSlowerAfterBulletHell) { - float reducedMovementMultiplier = MathHelper.Lerp(0.1f, masterMode ? 1f : 0.75f, (NPC.ai[1] + increasedIdleTimeAfterBulletHell) / increasedIdleTimeAfterBulletHell); + float reducedMovementMultiplier = MathHelper.Lerp(0.1f, death ? 1f : 0.75f, (NPC.ai[1] + increasedIdleTimeAfterBulletHell) / increasedIdleTimeAfterBulletHell); acceleration *= reducedMovementMultiplier; velocity *= reducedMovementMultiplier; chargeSpeed *= reducedMovementMultiplier; } - float flareSpawnDecelerationTimer = bossRush ? 60f : death ? 75f : 90f; - int flareSpawnPhaseTimerReduction = revenge ? (int)(flareSpawnDecelerationTimer * (ai2GateValue - lifeRatio)) : 0; - float flareSpawnPhaseTimer = (bossRush ? 120f : death ? 150f : 180f) - flareSpawnPhaseTimerReduction; + float flareSpawnDecelerationTimer = death ? 75f : 90f; + int flareSpawnPhaseTimerReduction = revenge ? (int)(flareSpawnDecelerationTimer * (AI2GateValue - lifeRatio)) : 0; + float flareSpawnPhaseTimer = (death ? 150f : 180f) - flareSpawnPhaseTimerReduction; float teleportPhaseTimer = 45f; if (revenge) { - float chargeTimeDecrease = bossRush ? 6f : death ? 4f : 2f; - float velocityMult = bossRush ? 1.15f : death ? 1.1f : 1.05f; + float chargeTimeDecrease = death ? 4f : 2f; + float velocityMult = death ? 1.1f : 1.05f; acceleration *= velocityMult; velocity *= velocityMult; chargeTime -= chargeTimeDecrease; @@ -1846,7 +1834,7 @@ namespace CalamityMod.NPCs.Yharon if (!targetDead) { - if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance && NPC.localAI[1] <= fastChargeTelegraphTime * 0.5f) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; @@ -2005,7 +1993,7 @@ namespace CalamityMod.NPCs.Yharon float amount = 0.04f; if (NPC.spriteDirection == -1) - newRotation += pie; + newRotation += MathHelper.Pi; if (amount != 0f) NPC.rotation = NPC.rotation.AngleTowards(newRotation, amount); @@ -2025,19 +2013,13 @@ namespace CalamityMod.NPCs.Yharon if (Main.netMode != NetmodeID.MultiplayerClient) { - if (CalamityWorld.LegendaryMode && revenge) - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); - } - float bulletHellTeleportLocationDistance = 540f; Vector2 teleportLocation = -Vector2.UnitY * bulletHellTeleportLocationDistance * (targetData.velocity.Y >= 0f).ToDirectionInt(); Vector2 center = targetData.Center + teleportLocation; NPC.Center = center; int type = ModContent.ProjectileType(); - int damage = Main.zenithWorld ? NPC.GetProjectileDamage(type) : 0; + int damage = Main.zenithWorld ? VortexDamage : 0; float bulletHellVortexDuration = spinPhaseTimer + 15f; int extraTime = Main.zenithWorld ? 300 : 0; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, bulletHellVortexDuration + extraTime, NPC.whoAmI); @@ -2068,7 +2050,7 @@ namespace CalamityMod.NPCs.Yharon float amount = 0.04f; if (NPC.spriteDirection == -1) - newRotation += pie; + newRotation += MathHelper.Pi; if (amount != 0f) NPC.rotation = NPC.rotation.AngleTowards(newRotation, amount); @@ -2145,7 +2127,7 @@ namespace CalamityMod.NPCs.Yharon NPC.rotation = vector.ToRotation(); if (NPC.spriteDirection == -1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.velocity = vector * chargeSpeed; @@ -2177,7 +2159,7 @@ namespace CalamityMod.NPCs.Yharon NPC.rotation = vector.ToRotation(); if (NPC.spriteDirection == -1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.velocity = vector * chargeSpeed * fastChargeVelocityMultiplier; @@ -2196,7 +2178,7 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[1] == 1f) SoundEngine.PlaySound(ShortRoarSound, NPC.Center); - ChargeDust(7, pie); + ChargeDust(7); NPC.ai[1] += 1f; if (NPC.ai[1] >= chargeTime) @@ -2244,7 +2226,7 @@ namespace CalamityMod.NPCs.Yharon NPC.rotation = vector.ToRotation(); if (NPC.spriteDirection == -1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.velocity = vector * fireballBreathPhaseVelocity; @@ -2253,6 +2235,9 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[1] >= fireballBreathTimer) { + // Set damage once charge starts + NPC.damage = setDamage; + if (NPC.ai[1] % (expertMode ? 6f : 8f) == 0f && Main.netMode != NetmodeID.MultiplayerClient) { float xOffset = 30f; @@ -2260,12 +2245,8 @@ namespace CalamityMod.NPCs.Yharon Vector2 projectileVelocity = NPC.velocity; projectileVelocity.Normalize(); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), position, projectileVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), position, projectileVelocity, type, FlareDamage, 0f, Main.myPlayer); } - - if (Math.Abs(targetData.Center.X - NPC.Center.X) > 700f && Math.Abs(NPC.velocity.X) < chargeSpeed) - NPC.velocity.X += Math.Sign(NPC.velocity.X) * 0.5f; } if (NPC.ai[1] >= fireballBreathPhaseTimer) @@ -2308,7 +2289,7 @@ namespace CalamityMod.NPCs.Yharon NPC.rotation = yharonFireballMoveDirection.ToRotation(); if (NPC.spriteDirection == -1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; NPC.velocity = yharonFireballMoveDirection * splittingFireballBreathPhaseVelocity; SoundEngine.PlaySound(FireSound, NPC.Center); @@ -2323,9 +2304,8 @@ namespace CalamityMod.NPCs.Yharon int yharonFireballTimer = (int)(NPC.ai[1] - splittingFireballBreathTimer + 1f); int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); if (yharonFireballTimer <= splittingFireballBreathTimer2 && yharonFireballTimer % splittingFireballBreathDivisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), position, NPC.velocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), position, NPC.velocity, type, FireballDamage, 0f, Main.myPlayer, 0f, 0f); } if (NPC.ai[1] > splittingFireballBreathPhaseTimer - splittingFireballBreathYVelocityTimer) @@ -2365,17 +2345,17 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[1] % flareDustSpawnDivisor2 == 0f) { int totalProjectiles = secondPhasePhase == 4 ? 12 : 10; - float projectileVelocity = secondPhasePhase == 4 ? 16f : 12f; + float projectileVelocity = secondPhasePhase == 4 ? 17f : 13f; float radialOffset = secondPhasePhase == 4 ? 2.8f : 3.2f; if (NPC.localAI[3] == 0f) { - DoFlareDustBulletHell(1, spinPhaseTimer, NPC.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, projectileVelocity, radialOffset, true); + DoFlareDustBulletHell(1, spinPhaseTimer, FlareDamage, totalProjectiles, projectileVelocity, radialOffset, true); } else { int ringReduction = (int)MathHelper.Lerp(0f, 12f, NPC.ai[1] / spinPhaseTimer); int totalProjectiles2 = 38 - ringReduction; // 36 for first ring, 24 for last ring - DoFlareDustBulletHell(0, flareDustSpawnDivisor2, NPC.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles2, 0f, 0f, true); + DoFlareDustBulletHell(0, flareDustSpawnDivisor2, FlareDamage, totalProjectiles2, 0f, 0f, true); } } } @@ -2385,7 +2365,7 @@ namespace CalamityMod.NPCs.Yharon { int ringReduction = (int)MathHelper.Lerp(0f, 12f, NPC.ai[1] / spinPhaseTimer); int totalProjectiles = 38 - ringReduction; // 36 for first ring, 24 for last ring - DoFlareDustBulletHell(0, flareDustSpawnDivisor, NPC.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, true); + DoFlareDustBulletHell(0, flareDustSpawnDivisor, FlareDamage, totalProjectiles, 0f, 0f, true); } } @@ -2450,7 +2430,7 @@ namespace CalamityMod.NPCs.Yharon { SoundEngine.PlaySound(ShortRoarSound, NPC.Center); - DoFireRing(expertMode ? 300 : 180, NPC.GetProjectileDamage(ModContent.ProjectileType()), NPC.target, 1f); + DoFireRing(expertMode ? 300 : 180, FlareDamage, NPC.target, 1f); } } @@ -2480,7 +2460,7 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[1] == 1f) SoundEngine.PlaySound(ShortRoarSound, NPC.Center); - ChargeDust(14, pie); + ChargeDust(14); NPC.ai[1] += 1f; if (NPC.ai[1] >= chargeTime) @@ -2545,7 +2525,7 @@ namespace CalamityMod.NPCs.Yharon NPC.rotation = vector.ToRotation(); if (NPC.spriteDirection == -1) - NPC.rotation += pie; + NPC.rotation += MathHelper.Pi; if (NPC.ai[2] == 120f) { @@ -2604,10 +2584,10 @@ namespace CalamityMod.NPCs.Yharon case 4: rotationSpeed = 0.01f; - facingAngle = pie; + facingAngle = MathHelper.Pi; if (NPC.spriteDirection == 1) - facingAngle += pie; + facingAngle += MathHelper.Pi; break; case 6: @@ -2615,13 +2595,13 @@ namespace CalamityMod.NPCs.Yharon facingAngle = 0f; if (NPC.spriteDirection == -1) - facingAngle -= pie; + facingAngle -= MathHelper.Pi; break; } if (NPC.spriteDirection == -1) - facingAngle += pie; + facingAngle += MathHelper.Pi; if (rotationSpeed != 0f) NPC.rotation = NPC.rotation.AngleTowards(facingAngle, rotationSpeed); @@ -2629,13 +2609,13 @@ namespace CalamityMod.NPCs.Yharon #endregion #region Charge Dust - private void ChargeDust(int dustAmt, float pie) + private void ChargeDust(int dustAmt) { for (int i = 0; i < dustAmt; i++) { Vector2 dustRotate = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; - dustRotate = dustRotate.RotatedBy((i - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + NPC.Center; - Vector2 dustVel = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + dustRotate = dustRotate.RotatedBy((i - (dustAmt / 2 - 1)) * MathHelper.Pi / (float)dustAmt) + NPC.Center; + Vector2 dustVel = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); int chargeDust = Dust.NewDust(dustRotate + dustVel, 0, 0, DustID.CopperCoin, dustVel.X * 2f, dustVel.Y * 2f, 100, default, 1.4f); Main.dust[chargeDust].noGravity = true; Main.dust[chargeDust].noLight = true; @@ -3000,11 +2980,12 @@ namespace CalamityMod.NPCs.Yharon normalOnly.Add(ModContent.ItemType(), ThankYouPainting.DropInt); // Materials - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 25, 30)); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType(), 1, 35, 40)); // Equipment - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); - normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + // 16NOV2025: Ozzatron: item has been chosen as the "Expert gatekept" item for this Calamity boss + // normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); + normalOnly.Add(DropHelper.PerPlayer(ModContent.ItemType())); } // Trophy (always directly from boss, never in bag) @@ -3017,14 +2998,14 @@ namespace CalamityMod.NPCs.Yharon // He is the dragon of rebirth afterall var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { - GFBOnly.Add(ModContent.ItemType(), hideLootReport: true); + GFBOnly.Add(DropHelper.PerPlayer(ModContent.ItemType()), hideLootReport: true); } // Lore npcLoot.AddConditionalPerPlayer(() => !DownedBossSystem.downedYharon, ModContent.ItemType(), desc: DropHelper.FirstKillText); } - public override void BossLoot(ref string name, ref int potionType) + public override void BossLoot(ref int potionType) { potionType = ModContent.ItemType(); } @@ -3037,7 +3018,7 @@ namespace CalamityMod.NPCs.Yharon if (BossRushEvent.BossRushActive) return; - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedYharon); + CalamityGlobalTownNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, DownedBossSystem.downedYharon); CalamityGlobalNPC.SetNewBossJustDowned(NPC); // If Yharon has not been killed yet, notify players of Auric Ore @@ -3047,7 +3028,7 @@ namespace CalamityMod.NPCs.Yharon string key = "Mods.CalamityMod.Status.Progression.AuricOreText"; Color messageColor = Color.Gold; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Mark Yharon as dead @@ -3059,21 +3040,12 @@ namespace CalamityMod.NPCs.Yharon for (int i = 0; i < 4; i++) { int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.Zero, type, damage, 0f, Main.myPlayer, 360, NPC.whoAmI); + Projectile.NewProjectile(NPC.GetSource_Death(), NPC.Center, Vector2.Zero, type, VortexDamage, 0f, Main.myPlayer, 360, NPC.whoAmI); } } } #endregion - #region On Hit Player - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120, true); - } - #endregion - #region HP Bar Cooldown Slot and Stats public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { @@ -3090,7 +3062,6 @@ namespace CalamityMod.NPCs.Yharon public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); - NPC.damage = (int)(NPC.damage * NPC.GetExpertDamageMultiplier()); } #endregion @@ -3119,7 +3090,7 @@ namespace CalamityMod.NPCs.Yharon bool doTelegraphFlightAnimation = NPC.localAI[1] < fastChargeTelegraphTime * 0.5f || NPC.localAI[1] > fastChargeTelegraphTime - (fastChargeTelegraphTime / 6f); bool doTelegraphRoarAnimation = NPC.localAI[1] > fastChargeTelegraphTime - fastChargeTelegraphTime * 0.4f && NPC.localAI[1] < fastChargeTelegraphTime - fastChargeTelegraphTime * 0.2f; - bool phase4 = startSecondAI && lifeRatio <= ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.165f : 0.11f) && (CalamityWorld.revenge || BossRushEvent.BossRushActive); + bool phase4 = startSecondAI && lifeRatio <= ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 0.2f : 0.15f) && (CalamityWorld.revenge || BossRushEvent.BossRushActive); if (doTelegraphFlightAnimation) { NPC.frameCounter += phase4 ? 2D : 1D; diff --git a/Packets/CalamityPacket.cs b/Packets/CalamityPacket.cs index b21d3795b1..74e667b086 100644 --- a/Packets/CalamityPacket.cs +++ b/Packets/CalamityPacket.cs @@ -1,27 +1,42 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Packets { - public abstract class CalamityPacket + internal abstract class CalamityPacket : ILoadable { - public abstract byte MessageType { get; } - public abstract void HandlePacket(in BinaryReader packet, int sender); + public abstract void HandlePacket(BinaryReader packet, int sender); - public virtual void OnLoaded() { } - public virtual void OnUnloaded() { } + private ushort _NetID; + private PropertyInfo _Prop_Static_Instance; - internal PropertyInfo _Prop_Static_Instance; + public void Load(Mod mod) + { + _NetID = CalamityNetcode.RegisterHandler(this); - public void CloneAndBroadcast(in BinaryReader packet, long startIndex, int length, int ignoreClient = -1) + var type = GetType(); + var instanceProperty = type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic); + + if (instanceProperty == null) + return; + + if (!instanceProperty.PropertyType.IsAssignableFrom(type)) + CalamityMod.Log.Error($"Packet instance's 'Instance' property is not asssignable with given type! [Failed On: '{type.FullName}']"); + + instanceProperty.SetValue(null, this); + _Prop_Static_Instance = instanceProperty; // We saving this for Unload Steps + } + + public virtual void Unload() + { + _Prop_Static_Instance?.SetValue(null, null); + _Prop_Static_Instance = null; + } + + public void CloneAndBroadcast(BinaryReader packet, long startIndex, int length, int ignoreClient = -1) { if (!Main.dedServ) return; @@ -43,7 +58,7 @@ namespace CalamityMod.Packets public ModPacket CreateBasePacket() { var packet = CalamityMod.Instance.GetPacket(); - packet.Write(MessageType); + CalamityNetcode.WriteHandlerNetID(packet, _NetID); return packet; } } diff --git a/Packets/Draedon/CodebreakerSummonStuffPacket.cs b/Packets/Draedon/CodebreakerSummonStuffPacket.cs index 652eca0e97..a8898cbabf 100644 --- a/Packets/Draedon/CodebreakerSummonStuffPacket.cs +++ b/Packets/Draedon/CodebreakerSummonStuffPacket.cs @@ -1,20 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.World; using Terraria; namespace CalamityMod.Packets { - public sealed class CodebreakerSummonStuffPacket : CalamityPacket + internal sealed class CodebreakerSummonStuffPacket : CalamityPacket { public static CodebreakerSummonStuffPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.CodebreakerSummonStuff; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -24,7 +17,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { CalamityWorld.DraedonSummonCountdown = packet.ReadInt32(); CalamityWorld.DraedonSummonPosition = packet.ReadVector2(); diff --git a/Packets/Draedon/ExoMechSelectionPacket.cs b/Packets/Draedon/ExoMechSelectionPacket.cs index c49253b0b4..6d33146509 100644 --- a/Packets/Draedon/ExoMechSelectionPacket.cs +++ b/Packets/Draedon/ExoMechSelectionPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.World; namespace CalamityMod.Packets { - public sealed class ExoMechSelectionPacket : CalamityPacket + internal sealed class ExoMechSelectionPacket : CalamityPacket { public static ExoMechSelectionPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.ExoMechSelection; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -21,7 +14,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { CalamityWorld.DraedonMechToSummon = (ExoMech)packet.ReadInt32(); } diff --git a/Packets/Entities/Androomba/SyncAndroombaAIPacket.cs b/Packets/Entities/Androomba/SyncAndroombaAIPacket.cs index 96ccf4b5be..ce17888ca5 100644 --- a/Packets/Entities/Androomba/SyncAndroombaAIPacket.cs +++ b/Packets/Entities/Androomba/SyncAndroombaAIPacket.cs @@ -1,23 +1,13 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.NPCs.DraedonLabThings; +using System.IO; using CalamityMod.NPCs.TownNPCs; -using Microsoft.Build.Execution; using Terraria; namespace CalamityMod.Packets { - public sealed class SyncAndroombaAIPacket : CalamityPacket + internal sealed class SyncAndroombaAIPacket : CalamityPacket { public static SyncAndroombaAIPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncAndroombaAI; - public static void Send(AndroombaFriendly roomba, int phase = -1, int toClient = -1, int ignoreClient = -1) { if (roomba is null) @@ -29,7 +19,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var roomba = packet.ReadModNPC(); var phase = packet.ReadInt32(); diff --git a/Packets/Entities/Androomba/SyncAndroombaSolutionPacket.cs b/Packets/Entities/Androomba/SyncAndroombaSolutionPacket.cs index e6ac9e69f8..a0d5e925eb 100644 --- a/Packets/Entities/Androomba/SyncAndroombaSolutionPacket.cs +++ b/Packets/Entities/Androomba/SyncAndroombaSolutionPacket.cs @@ -1,20 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.NPCs.TownNPCs; using Terraria; namespace CalamityMod.Packets { - public sealed class SyncAndroombaSolutionPacket : CalamityPacket + internal sealed class SyncAndroombaSolutionPacket : CalamityPacket { public static SyncAndroombaSolutionPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncAndroombaSolution; - public static void Send(AndroombaFriendly roomba, int solType = -1, int toClient = -1, int ignoreClient = -1) { if (roomba is null) @@ -26,7 +19,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var roomba = packet.ReadModNPC(); var solution = packet.ReadInt32(); diff --git a/Packets/Entities/DemonSwordImpalesSyncPacket.cs b/Packets/Entities/DemonSwordImpalesSyncPacket.cs index 78d578c7bc..6353513f79 100644 --- a/Packets/Entities/DemonSwordImpalesSyncPacket.cs +++ b/Packets/Entities/DemonSwordImpalesSyncPacket.cs @@ -3,10 +3,9 @@ using Terraria; namespace CalamityMod.Packets.Entities { - public sealed class DemonSwordImpalesSyncPacket : CalamityPacket + internal sealed class DemonSwordImpalesSyncPacket : CalamityPacket { public static DemonSwordImpalesSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncNPCDemonSwordImpales; public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) { @@ -19,7 +18,7 @@ namespace CalamityMod.Packets.Entities packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var npc = packet.ReadNPC(); var impales = packet.ReadInt32(); diff --git a/Packets/Entities/DemonicFlamesSyncPacket.cs b/Packets/Entities/DemonicFlamesSyncPacket.cs index 95eeef8c51..a254962e80 100644 --- a/Packets/Entities/DemonicFlamesSyncPacket.cs +++ b/Packets/Entities/DemonicFlamesSyncPacket.cs @@ -3,10 +3,9 @@ using Terraria; namespace CalamityMod.Packets.Entities { - public sealed class DemonicFlamesSyncPacket : CalamityPacket + internal sealed class DemonicFlamesSyncPacket : CalamityPacket { public static DemonicFlamesSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncNPCDemonicFlamesDamage; public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) { @@ -19,7 +18,7 @@ namespace CalamityMod.Packets.Entities packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var npc = packet.ReadNPC(); var damage = packet.ReadInt32(); diff --git a/Packets/Entities/GlaiveShredSyncPacket.cs b/Packets/Entities/GlaiveShredSyncPacket.cs new file mode 100644 index 0000000000..bea868c6ea --- /dev/null +++ b/Packets/Entities/GlaiveShredSyncPacket.cs @@ -0,0 +1,35 @@ +using System.IO; +using Terraria; + +namespace CalamityMod.Packets.Entities +{ + internal sealed class GlaiveShredPacket : CalamityPacket + { + public static GlaiveShredPacket Instance { get; private set; } + + public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) + { + if (npc is null) + return; + + var packet = Instance.CreateBasePacket(); + packet.WriteWhoAmI(npc); + packet.Write(npc.Calamity().glaiveShredTimer); + packet.Write(npc.Calamity().blazingStarShredTimer); + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var npc = packet.ReadNPC(); + var glaive = packet.ReadInt32(); + var blazingstar = packet.ReadInt32(); + + if (npc is null) + return; + + npc.Calamity().glaiveShredTimer = glaive; + npc.Calamity().blazingStarShredTimer = blazingstar; + } + } +} diff --git a/Packets/Entities/PlaceAltCritterPacket.cs b/Packets/Entities/PlaceAltCritterPacket.cs index fe85f6574e..c0b91a8fd0 100644 --- a/Packets/Entities/PlaceAltCritterPacket.cs +++ b/Packets/Entities/PlaceAltCritterPacket.cs @@ -1,20 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria.ID; +using System.IO; using Terraria; namespace CalamityMod.Packets { - public sealed class PlaceAltCritterPacket : CalamityPacket + internal sealed class PlaceAltCritterPacket : CalamityPacket { public static PlaceAltCritterPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.PlaceAltCritter; - /// /// Same Method, but uses critterItem.makeNPC and critterItem.type for shorthanded call /// @@ -41,7 +33,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var placerplayer = packet.ReadPlayer(); int posX = packet.ReadInt32(); diff --git a/Packets/Entities/Providence/PSCChallengeSyncPacket.cs b/Packets/Entities/Providence/PSCChallengeSyncPacket.cs index 4aa85f4e3d..a5ee628386 100644 --- a/Packets/Entities/Providence/PSCChallengeSyncPacket.cs +++ b/Packets/Entities/Providence/PSCChallengeSyncPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.NPCs.Providence; namespace CalamityMod.Packets { - public sealed class PSCChallengeSyncPacket : CalamityPacket + internal sealed class PSCChallengeSyncPacket : CalamityPacket { public static PSCChallengeSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.PSCChallengeSync; - public static void Send(Providence providence, int toClient = -1, int ignoreClient = -1) { if (providence is null) @@ -25,7 +18,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var providence = packet.ReadModNPC(); var challenge = packet.ReadBoolean(); diff --git a/Packets/Entities/Providence/ProvidenceDyeConditionSyncPacket.cs b/Packets/Entities/Providence/ProvidenceDyeConditionSyncPacket.cs index 42134ed1c2..fb0a58fce8 100644 --- a/Packets/Entities/Providence/ProvidenceDyeConditionSyncPacket.cs +++ b/Packets/Entities/Providence/ProvidenceDyeConditionSyncPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.NPCs.Providence; namespace CalamityMod.Packets { - public sealed class ProvidenceDyeConditionSyncPacket : CalamityPacket + internal sealed class ProvidenceDyeConditionSyncPacket : CalamityPacket { public static ProvidenceDyeConditionSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.ProvidenceDyeConditionSync; - public static void Send(Providence providence, int toClient = -1, int ignoreClient = -1) { if (providence is null) @@ -25,7 +18,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var providence = packet.ReadModNPC(); var hasBeenEnraged = packet.ReadBoolean(); diff --git a/Packets/Entities/SlabCrab/SyncSlabCrabAIPacket.cs b/Packets/Entities/SlabCrab/SyncSlabCrabAIPacket.cs index 1c7b9f77d2..a146e50b6a 100644 --- a/Packets/Entities/SlabCrab/SyncSlabCrabAIPacket.cs +++ b/Packets/Entities/SlabCrab/SyncSlabCrabAIPacket.cs @@ -1,21 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.TownNPCs; using Terraria; namespace CalamityMod.Packets { - public sealed class SyncSlabCrabAIPacket : CalamityPacket + internal sealed class SyncSlabCrabAIPacket : CalamityPacket { public static SyncSlabCrabAIPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncSlabCrabAI; - public static void Send(SlabCrab crab, int phase = -1, int toClient = -1, int ignoreClient = -1) { if (crab is null) @@ -27,7 +19,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var crab = packet.ReadModNPC(); var phase = packet.ReadInt32(); diff --git a/Packets/Entities/SpawnBossOnPositionPacket.cs b/Packets/Entities/SpawnBossOnPositionPacket.cs index 33c4ef8f2e..f23f347c6b 100644 --- a/Packets/Entities/SpawnBossOnPositionPacket.cs +++ b/Packets/Entities/SpawnBossOnPositionPacket.cs @@ -1,21 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using Terraria; -using Terraria.DataStructures; -using Terraria.ID; namespace CalamityMod.Packets { - public sealed class SpawnBossOnPositionPacket : CalamityPacket + internal sealed class SpawnBossOnPositionPacket : CalamityPacket { public static SpawnBossOnPositionPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SpawnBossOnPosition; - public static void Send(int x, int y, int npcType, Player target = null, int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -26,7 +17,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var x = packet.ReadInt32(); var y = packet.ReadInt32(); @@ -37,10 +28,15 @@ namespace CalamityMod.Packets if (!Main.dedServ) return; + if (npcType == Terraria.ID.NPCID.WallofFlesh) // Divert to using SpawnWOF instead. Used by Slagfire Douser. + { + NPC.SpawnWOF(new (x, y)); + return; + } int spawnedNPCIdx = NPC.NewNPC(NPC.GetBossSpawnSource(targetIndex), x, y, npcType, Start: 1); if (spawnedNPCIdx >= Main.maxNPCs) return; - + NPC npc = Main.npc[spawnedNPCIdx]; npc.timeLeft *= 20; npc.target = targetIndex; diff --git a/Packets/Entities/SpawnNPCOnPlayerPacket.cs b/Packets/Entities/SpawnNPCOnPlayerPacket.cs index a256aa4c57..d58c0698b1 100644 --- a/Packets/Entities/SpawnNPCOnPlayerPacket.cs +++ b/Packets/Entities/SpawnNPCOnPlayerPacket.cs @@ -1,21 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria.DataStructures; -using Terraria.ID; +using System.IO; using Terraria; +using Terraria.DataStructures; namespace CalamityMod.Packets { - public sealed class SpawnNPCOnPlayerPacket : CalamityPacket + internal sealed class SpawnNPCOnPlayerPacket : CalamityPacket { public static SpawnNPCOnPlayerPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SpawnNPCOnPlayer; - public static void Send(Player player, int x, int y, int npcType, int toClient = -1, int ignoreClient = -1) { if (player is null) @@ -29,7 +21,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadPlayer(); var x = packet.ReadInt32(); diff --git a/Packets/Entities/SuperDummy/DeleteAllSuperDummiesPacket.cs b/Packets/Entities/SuperDummy/DeleteAllSuperDummiesPacket.cs index 3ea889f024..6d242152b2 100644 --- a/Packets/Entities/SuperDummy/DeleteAllSuperDummiesPacket.cs +++ b/Packets/Entities/SuperDummy/DeleteAllSuperDummiesPacket.cs @@ -1,27 +1,20 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Items; +using System.IO; +using CalamityMod.Items.Tools; using Terraria; namespace CalamityMod.Packets { - public sealed class DeleteAllSuperDummiesPacket : CalamityPacket + internal sealed class DeleteAllSuperDummiesPacket : CalamityPacket { public static DeleteAllSuperDummiesPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.DeleteAllSuperDummies; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { // There is nothing in the packet! We only need to call delete method on Server if (Main.dedServ) diff --git a/Packets/Entities/SuperDummy/SpawnSuperDummyPacket.cs b/Packets/Entities/SuperDummy/SpawnSuperDummyPacket.cs index 9eac863d7e..5e907a2792 100644 --- a/Packets/Entities/SuperDummy/SpawnSuperDummyPacket.cs +++ b/Packets/Entities/SuperDummy/SpawnSuperDummyPacket.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.NPCs.NormalNPCs; using Terraria; using Terraria.DataStructures; @@ -11,12 +6,10 @@ using Terraria.ModLoader; namespace CalamityMod.Packets { - public sealed class SpawnSuperDummyPacket : CalamityPacket + internal sealed class SpawnSuperDummyPacket : CalamityPacket { public static SpawnSuperDummyPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SpawnSuperDummy; - public static void Send(int x, int y, int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -25,7 +18,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var x = packet.ReadInt32(); var y = packet.ReadInt32(); diff --git a/Packets/Entities/SyncCalamityNPCAIArrayPacket.cs b/Packets/Entities/SyncCalamityNPCAIArrayPacket.cs index 8603df26ac..2e3848c1b7 100644 --- a/Packets/Entities/SyncCalamityNPCAIArrayPacket.cs +++ b/Packets/Entities/SyncCalamityNPCAIArrayPacket.cs @@ -1,22 +1,15 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using Terraria; namespace CalamityMod.Packets { - public sealed class SyncCalamityNPCAIArrayPacket : CalamityPacket + internal sealed class SyncCalamityNPCAIArrayPacket : CalamityPacket { // MIGRATED COMMENTS FROM: 'CalamityNetcode.cs' // - This code has been edited to fail gracefully when trying to provide data for an invalid NPC. public static SyncCalamityNPCAIArrayPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncCalamityNPCAIArray; - public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) { if (npc is null) @@ -33,7 +26,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var npc = packet.ReadNPC(); var ai0 = packet.ReadSingle(); diff --git a/Packets/Entities/SyncNPCMotionDataToServerPacket.cs b/Packets/Entities/SyncNPCMotionDataToServerPacket.cs index 0b86cd640e..9dce22fa4b 100644 --- a/Packets/Entities/SyncNPCMotionDataToServerPacket.cs +++ b/Packets/Entities/SyncNPCMotionDataToServerPacket.cs @@ -1,20 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using Terraria; using Terraria.ID; namespace CalamityMod.Packets { - public sealed class SyncNPCMotionDataToServerPacket : CalamityPacket + internal sealed class SyncNPCMotionDataToServerPacket : CalamityPacket { public static SyncNPCMotionDataToServerPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncNPCMotionDataToServer; - public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) { if (npc is null) @@ -27,7 +20,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var npc = packet.ReadNPC(); var center = packet.ReadVector2(); diff --git a/Packets/Entities/SyncNPCPosAndRotOnlyPacket.cs b/Packets/Entities/SyncNPCPosAndRotOnlyPacket.cs index 403ccef71c..a4f125e596 100644 --- a/Packets/Entities/SyncNPCPosAndRotOnlyPacket.cs +++ b/Packets/Entities/SyncNPCPosAndRotOnlyPacket.cs @@ -1,20 +1,13 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Packets { - public sealed class SyncNPCPosAndRotOnlyPacket : CalamityPacket + internal sealed class SyncNPCPosAndRotOnlyPacket : CalamityPacket { public static SyncNPCPosAndRotOnlyPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncNPCPosAndRotOnly; - public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) { if (npc is null) @@ -27,11 +20,11 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var npc = packet.ReadNPC(); var position = packet.ReadVector2(); - var rotation = (float)packet.ReadHalf(); + var rotation = (float)packet.ReadHalf(); if (npc is null) return; diff --git a/Packets/Entities/SyncVanillaNPCLocalAIArrayPacket.cs b/Packets/Entities/SyncVanillaNPCLocalAIArrayPacket.cs index 25f5ba8f6a..da5936aa15 100644 --- a/Packets/Entities/SyncVanillaNPCLocalAIArrayPacket.cs +++ b/Packets/Entities/SyncVanillaNPCLocalAIArrayPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using Terraria; namespace CalamityMod.Packets { - public sealed class SyncVanillaNPCLocalAIArrayPacket : CalamityPacket + internal sealed class SyncVanillaNPCLocalAIArrayPacket : CalamityPacket { public static SyncVanillaNPCLocalAIArrayPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncVanillaNPCLocalAIArray; - public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) { if (npc is null) @@ -28,7 +21,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var npc = packet.ReadNPC(); var ai0 = packet.ReadSingle(); diff --git a/Packets/Entities/VanillaChanges/SyncDestroyerLaserColorPacket.cs b/Packets/Entities/VanillaChanges/SyncDestroyerLaserColorPacket.cs deleted file mode 100644 index 1758573093..0000000000 --- a/Packets/Entities/VanillaChanges/SyncDestroyerLaserColorPacket.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.NPCs; -using Terraria; - -namespace CalamityMod.Packets -{ - public sealed class SyncDestroyerLaserColorPacket : CalamityPacket - { - public static SyncDestroyerLaserColorPacket Instance { get; private set; } - - public override byte MessageType => (byte)CalamityModMessageType.SyncDestroyerLaserColor; - - public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1) - { - if (npc is null) - return; - - var packet = Instance.CreateBasePacket(); - packet.WriteWhoAmI(npc); - packet.Write(npc.Calamity().destroyerLaserColor); - packet.Send(toClient, ignoreClient); - } - - public override void HandlePacket(in BinaryReader packet, int sender) - { - var npc = packet.ReadNPC(); - var laserColor = packet.ReadInt32(); - - if (npc is null) - return; - - npc.Calamity().destroyerLaserColor = laserColor; - } - } -} diff --git a/Packets/Events/AcidRain/AcidRainOldDukeSummonSyncPacket.cs b/Packets/Events/AcidRain/AcidRainOldDukeSummonSyncPacket.cs index e143687386..8eec0880c4 100644 --- a/Packets/Events/AcidRain/AcidRainOldDukeSummonSyncPacket.cs +++ b/Packets/Events/AcidRain/AcidRainOldDukeSummonSyncPacket.cs @@ -1,20 +1,12 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class AcidRainOldDukeSummonSyncPacket : CalamityPacket + internal sealed class AcidRainOldDukeSummonSyncPacket : CalamityPacket { public static AcidRainOldDukeSummonSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.AcidRainOldDukeSummonSync; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -22,7 +14,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { AcidRainEvent.HasTriedToSummonOldDuke = packet.ReadBoolean(); } diff --git a/Packets/Events/AcidRain/AcidRainSyncPacket.cs b/Packets/Events/AcidRain/AcidRainSyncPacket.cs index c45dbf3546..e216f62ebc 100644 --- a/Packets/Events/AcidRain/AcidRainSyncPacket.cs +++ b/Packets/Events/AcidRain/AcidRainSyncPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class AcidRainSyncPacket : CalamityPacket + internal sealed class AcidRainSyncPacket : CalamityPacket { public static AcidRainSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.AcidRainSync; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -23,7 +16,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { AcidRainEvent.AcidRainEventIsOngoing = packet.ReadBoolean(); AcidRainEvent.AccumulatedKillPoints = packet.ReadInt32(); diff --git a/Packets/Events/AcidRain/EncounteredOldDukeSyncPacket.cs b/Packets/Events/AcidRain/EncounteredOldDukeSyncPacket.cs index 3062cf61ef..2c9384d41e 100644 --- a/Packets/Events/AcidRain/EncounteredOldDukeSyncPacket.cs +++ b/Packets/Events/AcidRain/EncounteredOldDukeSyncPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class EncounteredOldDukeSyncPacket : CalamityPacket + internal sealed class EncounteredOldDukeSyncPacket : CalamityPacket { public static EncounteredOldDukeSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.EncounteredOldDukeSync; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -21,7 +14,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { AcidRainEvent.OldDukeHasBeenEncountered = packet.ReadBoolean(); } diff --git a/Packets/Events/BossRush/BRHostileProjKillSyncPacket.cs b/Packets/Events/BossRush/BRHostileProjKillSyncPacket.cs index d06602c73d..b54dfb388e 100644 --- a/Packets/Events/BossRush/BRHostileProjKillSyncPacket.cs +++ b/Packets/Events/BossRush/BRHostileProjKillSyncPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class BRHostileProjKillSyncPacket : CalamityPacket + internal sealed class BRHostileProjKillSyncPacket : CalamityPacket { public static BRHostileProjKillSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.BRHostileProjKillSync; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -21,7 +14,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { BossRushEvent.HostileProjectileKillCounter = packet.ReadInt32(); } diff --git a/Packets/Events/BossRush/BossRushEndTimerPacket.cs b/Packets/Events/BossRush/BossRushEndTimerPacket.cs index c39bdff49c..3b7f33314f 100644 --- a/Packets/Events/BossRush/BossRushEndTimerPacket.cs +++ b/Packets/Events/BossRush/BossRushEndTimerPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class BossRushEndTimerPacket : CalamityPacket + internal sealed class BossRushEndTimerPacket : CalamityPacket { public static BossRushEndTimerPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.BossRushEndTimer; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -21,7 +14,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { BossRushEvent.EndTimer = packet.ReadInt32(); } diff --git a/Packets/Events/BossRush/BossRushStagePacket.cs b/Packets/Events/BossRush/BossRushStagePacket.cs index ab0ef459bb..675fc6b164 100644 --- a/Packets/Events/BossRush/BossRushStagePacket.cs +++ b/Packets/Events/BossRush/BossRushStagePacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class BossRushStagePacket : CalamityPacket + internal sealed class BossRushStagePacket : CalamityPacket { public static BossRushStagePacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.BossRushStage; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -21,7 +14,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { BossRushEvent.BossRushStage = packet.ReadInt32(); } diff --git a/Packets/Events/BossRush/BossRushStartTimerPacket.cs b/Packets/Events/BossRush/BossRushStartTimerPacket.cs index 22c1ba7a1f..6abe50c28a 100644 --- a/Packets/Events/BossRush/BossRushStartTimerPacket.cs +++ b/Packets/Events/BossRush/BossRushStartTimerPacket.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class BossRushStartTimerPacket : CalamityPacket + internal sealed class BossRushStartTimerPacket : CalamityPacket { public static BossRushStartTimerPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.BossRushStartTimer; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -21,7 +14,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { BossRushEvent.StartTimer = packet.ReadInt32(); } diff --git a/Packets/Events/BossRush/EndBossRushPacket.cs b/Packets/Events/BossRush/EndBossRushPacket.cs index 52e5e9deea..1ae42822fa 100644 --- a/Packets/Events/BossRush/EndBossRushPacket.cs +++ b/Packets/Events/BossRush/EndBossRushPacket.cs @@ -1,26 +1,19 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Events; namespace CalamityMod.Packets { - public sealed class EndBossRushPacket : CalamityPacket + internal sealed class EndBossRushPacket : CalamityPacket { public static EndBossRushPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.EndBossRush; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { BossRushEvent.EndEffects(); } diff --git a/Packets/MusicSystems/MusicEventSyncRequestPacket.cs b/Packets/MusicSystems/MusicEventSyncRequestPacket.cs index 44b5425f09..ef2e6dc1fa 100644 --- a/Packets/MusicSystems/MusicEventSyncRequestPacket.cs +++ b/Packets/MusicSystems/MusicEventSyncRequestPacket.cs @@ -1,22 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; -using Terraria.ModLoader; +using System.IO; using Terraria; using Terraria.ID; namespace CalamityMod.Packets { - public sealed class MusicEventSyncRequestPacket : CalamityPacket + internal sealed class MusicEventSyncRequestPacket : CalamityPacket { public static MusicEventSyncRequestPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.MusicEventSyncRequest; - public static void Send(int toClient = -1, int ignoreClient = -1) { // Only MP Client should send request! @@ -27,7 +18,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { // Only fulfill requests as the server host if (!Main.dedServ) diff --git a/Packets/MusicSystems/MusicEventSyncResponsePacket.cs b/Packets/MusicSystems/MusicEventSyncResponsePacket.cs index adf9a3751e..703760e453 100644 --- a/Packets/MusicSystems/MusicEventSyncResponsePacket.cs +++ b/Packets/MusicSystems/MusicEventSyncResponsePacket.cs @@ -1,22 +1,14 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Systems; using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Packets { - public sealed class MusicEventSyncResponsePacket : CalamityPacket + internal sealed class MusicEventSyncResponsePacket : CalamityPacket { public static MusicEventSyncResponsePacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.MusicEventSyncResponse; - public static void Send(int toClient = -1, int ignoreClient = -1) { // Only Server should send Reponse to Clients @@ -27,13 +19,13 @@ namespace CalamityMod.Packets int trackCount = MusicEventSystem.PlayedEvents.Count; packet.Write(trackCount); - for (int i = 0; i < trackCount; i++) - packet.Write(MusicEventSystem.PlayedEvents[i]); + foreach (string playedEvent in MusicEventSystem.PlayedEvents) + packet.Write(playedEvent); packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { // Only receive info as clients if (Main.netMode != NetmodeID.MultiplayerClient) diff --git a/Packets/Players/AdrenalineSyncPacket.cs b/Packets/Players/AdrenalineSyncPacket.cs index 9071e81810..d623f8bf26 100644 --- a/Packets/Players/AdrenalineSyncPacket.cs +++ b/Packets/Players/AdrenalineSyncPacket.cs @@ -1,20 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.CalPlayer; using Terraria; namespace CalamityMod.Packets { - public sealed class AdrenalineSyncPacket : CalamityPacket + internal sealed class AdrenalineSyncPacket : CalamityPacket { public static AdrenalineSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.AdrenalineSync; - public static void Send(CalamityPlayer playerToSync, int toClient = -1, int ignoreClient = -1) { if (playerToSync is null) @@ -26,7 +19,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); var adrenaline = packet.ReadSingle(); diff --git a/Packets/Players/CooldownAdditionPacket.cs b/Packets/Players/CooldownAdditionPacket.cs index a5906855a9..67b9119c26 100644 --- a/Packets/Players/CooldownAdditionPacket.cs +++ b/Packets/Players/CooldownAdditionPacket.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; using Terraria; @@ -11,12 +6,10 @@ using Terraria.ID; namespace CalamityMod.Packets { - public sealed class CooldownAdditionPacket : CalamityPacket + internal sealed class CooldownAdditionPacket : CalamityPacket { public static CooldownAdditionPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.CooldownAddition; - public static void Send(CalamityPlayer player, CooldownInstance cd, int toClient = -1, int ignoreClient = -1) { Send(player, cd.netID, cd.duration, cd.timeLeft, toClient, ignoreClient); @@ -35,7 +28,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); var netID = packet.ReadUInt16(); diff --git a/Packets/Players/CooldownRemovalPacket.cs b/Packets/Players/CooldownRemovalPacket.cs index 1bcd2235f6..63a63781e8 100644 --- a/Packets/Players/CooldownRemovalPacket.cs +++ b/Packets/Players/CooldownRemovalPacket.cs @@ -1,22 +1,15 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; -using Terraria.ID; using Terraria; +using Terraria.ID; namespace CalamityMod.Packets { - public sealed class CooldownRemovalPacket : CalamityPacket + internal sealed class CooldownRemovalPacket : CalamityPacket { public static CooldownRemovalPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.CooldownRemoval; - public static void Send(CalamityPlayer player, ushort[] netIDsToRemove, int toClient = -1, int ignoreClient = -1) { if (player is null) @@ -32,7 +25,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); var count = packet.ReadInt32(); diff --git a/Packets/Players/DefenseDamageSyncPacket.cs b/Packets/Players/DefenseDamageSyncPacket.cs index 8dfc63ca20..ed7e964951 100644 --- a/Packets/Players/DefenseDamageSyncPacket.cs +++ b/Packets/Players/DefenseDamageSyncPacket.cs @@ -1,22 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.CalPlayer; using Terraria; -using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Packets { - public sealed class DefenseDamageSyncPacket : CalamityPacket + internal sealed class DefenseDamageSyncPacket : CalamityPacket { public static DefenseDamageSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.DefenseDamageSync; - public static void Send(CalamityPlayer playerToSync, int toClient = -1, int ignoreClient = -1) { if (playerToSync is null) @@ -31,7 +22,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); var totalDefDamage = packet.ReadInt32(); diff --git a/Packets/Players/ExaltationDirectionSyncPacket.cs b/Packets/Players/ExaltationDirectionSyncPacket.cs new file mode 100644 index 0000000000..8419069413 --- /dev/null +++ b/Packets/Players/ExaltationDirectionSyncPacket.cs @@ -0,0 +1,36 @@ +using System.IO; +using CalamityMod.CalPlayer; +using Terraria; + +namespace CalamityMod.Packets +{ + internal sealed class ExaltationDirectionSyncPacket : CalamityPacket + { + public static ExaltationDirectionSyncPacket Instance { get; private set; } + + public static void Send(CalamityPlayer playerToSync, int toClient = -1, int ignoreClient = -1) + { + if (playerToSync is null) + return; + + var packet = Instance.CreateBasePacket(); + packet.WriteWhoAmI(playerToSync); + packet.Write(playerToSync.InvertExaltationLineRotationDirections); + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var player = packet.ReadCalamityPlayer(); + var invertDir = packet.ReadBoolean(); + + if (player is null) + return; + + player.InvertExaltationLineRotationDirections = invertDir; + + if (Main.dedServ) + Send(player, ignoreClient: sender); + } + } +} diff --git a/Packets/Players/MousePositionSyncPacket.cs b/Packets/Players/MousePositionSyncPacket.cs index 3f853c19c2..7970227c00 100644 --- a/Packets/Players/MousePositionSyncPacket.cs +++ b/Packets/Players/MousePositionSyncPacket.cs @@ -1,20 +1,14 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; using Terraria; namespace CalamityMod.Packets { - public sealed class MousePositionSyncPacket : CalamityPacket + internal sealed class MousePositionSyncPacket : CalamityPacket { public static MousePositionSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.MousePositionSync; - public static void Send(CalamityPlayer player, int toClient = -1, int ignoreClient = -1) { if (player is null) @@ -22,19 +16,23 @@ namespace CalamityMod.Packets var packet = Instance.CreateBasePacket(); packet.WriteWhoAmI(player); - packet.WriteVector2(player.mouseWorld); + packet.Write((short)player.mouseWorldDeltaFromPlayer.X); + packet.Write((short)player.mouseWorldDeltaFromPlayer.Y); packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); - var mouseWorldPos = packet.ReadVector2(); + var deltaX = packet.ReadInt16(); + var deltaY = packet.ReadInt16(); if (player is null) return; - player.mouseWorld = mouseWorldPos; + var delta = new Vector2(deltaX, deltaY); + player.mouseWorldDeltaFromPlayer = delta; + player.mouseRotationFromPlayer = delta.ToRotation(); if (Main.dedServ) Send(player, ignoreClient: sender); diff --git a/Packets/Players/MouseRotationSyncPacket.cs b/Packets/Players/MouseRotationSyncPacket.cs new file mode 100644 index 0000000000..213649d15b --- /dev/null +++ b/Packets/Players/MouseRotationSyncPacket.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using CalamityMod.CalPlayer; +using Terraria; + +namespace CalamityMod.Packets +{ + internal sealed class MouseRotationSyncPacket : CalamityPacket + { + public static MouseRotationSyncPacket Instance { get; private set; } + + public static void Send(CalamityPlayer player, int toClient = -1, int ignoreClient = -1) + { + if (player is null) + return; + + var packet = Instance.CreateBasePacket(); + packet.WriteWhoAmI(player); + packet.Write((Half)player.mouseRotationFromPlayer); + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var player = packet.ReadCalamityPlayer(); + var rotation = (float)packet.ReadHalf(); + + if (player is null) + return; + + player.mouseRotationFromPlayer = rotation; + player.mouseWorldDeltaFromPlayer = rotation.ToRotationVector2(); + + if (Main.dedServ) + Send(player, ignoreClient: sender); + } + } +} diff --git a/Packets/Players/RageSyncPacket.cs b/Packets/Players/RageSyncPacket.cs index 37e3cd3dd3..7143bf1699 100644 --- a/Packets/Players/RageSyncPacket.cs +++ b/Packets/Players/RageSyncPacket.cs @@ -1,20 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.CalPlayer; using Terraria; namespace CalamityMod.Packets { - public sealed class RageSyncPacket : CalamityPacket + internal sealed class RageSyncPacket : CalamityPacket { public static RageSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.RageSync; - public static void Send(CalamityPlayer playerToSync, int toClient = -1, int ignoreClient = -1) { if (playerToSync is null) @@ -27,7 +20,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); var rage = packet.ReadSingle(); diff --git a/Packets/Players/RightClickSyncPacket.cs b/Packets/Players/RightClickSyncPacket.cs index a6c206d2a5..9d03d404e2 100644 --- a/Packets/Players/RightClickSyncPacket.cs +++ b/Packets/Players/RightClickSyncPacket.cs @@ -1,21 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.CalPlayer; -using CalamityMod.Events; using Terraria; namespace CalamityMod.Packets { - public sealed class RightClickSyncPacket : CalamityPacket + internal sealed class RightClickSyncPacket : CalamityPacket { public static RightClickSyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.RightClickSync; - public static void Send(CalamityPlayer player, int toClient = -1, int ignoreClient = -1) { if (player is null) @@ -27,7 +19,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); var rightClick = packet.ReadBoolean(); diff --git a/Packets/Players/SyncCooldownDictionaryPacket.cs b/Packets/Players/SyncCooldownDictionaryPacket.cs index ba8cf8b74b..cd70d6d41d 100644 --- a/Packets/Players/SyncCooldownDictionaryPacket.cs +++ b/Packets/Players/SyncCooldownDictionaryPacket.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; using Terraria; @@ -13,12 +10,10 @@ using CooldownInfoTuple = (ushort netID, int duration, int timeLeft); namespace CalamityMod.Packets { - public sealed class SyncCooldownDictionaryPacket : CalamityPacket + internal sealed class SyncCooldownDictionaryPacket : CalamityPacket { public static SyncCooldownDictionaryPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncCooldownDictionary; - public static void Send(CalamityPlayer player, int toClient = -1, int ignoreClient = -1) { if (player is null) @@ -48,7 +43,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); int count = packet.ReadInt32(); diff --git a/Packets/Players/SyncPlayerDrawParameterPacket.cs b/Packets/Players/SyncPlayerDrawParameterPacket.cs index 1f71ec7a78..8b2324af6d 100644 --- a/Packets/Players/SyncPlayerDrawParameterPacket.cs +++ b/Packets/Players/SyncPlayerDrawParameterPacket.cs @@ -1,20 +1,14 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using CalamityMod.CalPlayer; using Terraria; namespace CalamityMod.Packets { - public sealed class SyncPlayerDrawParameterPacket : CalamityPacket + internal sealed class SyncPlayerDrawParameterPacket : CalamityPacket { public static SyncPlayerDrawParameterPacket Instance { get; set; } - public override byte MessageType => (byte)CalamityModMessageType.SyncPlayerDrawParameter; - public static void Send(CalamityPlayer player, int toClient = -1, int ignoreClient = -1) { if (player is null) @@ -30,7 +24,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var player = packet.ReadCalamityPlayer(); var roverCharge = (float)packet.ReadHalf(); diff --git a/Packets/StartDialogueDisplayPacket.cs b/Packets/StartDialogueDisplayPacket.cs new file mode 100644 index 0000000000..fbf821b80a --- /dev/null +++ b/Packets/StartDialogueDisplayPacket.cs @@ -0,0 +1,108 @@ +using System.IO; +using System.Linq; +using CalamityMod.UI.DialogueDisplay.DisplayEffects; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader.IO; +using static CalamityMod.UI.DialogueDisplay.DialogueDisplaySystem; + +namespace CalamityMod.Packets +{ + internal sealed class StartDialogueDisplayPacket : CalamityPacket + { + public static StartDialogueDisplayPacket Instance { get; private set; } + + public static void Send(string name, bool progressDialogue, Vector2 position, int index, int uptime, DisplayEffectID effect, float wrapWidth, int toClient = -1, int ignoreClient = -1) + { + // Only Server should send Reponse to Clients + if (!Main.dedServ) + return; + + var packet = Instance.CreateBasePacket(); + + packet.Write(name); + packet.WriteFlags(progressDialogue, false); + packet.WritePackedVector2(position); + packet.Write(index); + packet.Write(uptime); + packet.Write((byte)effect); + packet.Write(wrapWidth); + + packet.Send(toClient, ignoreClient); + } + + public enum EntityType : byte + { + NPC, + Player, + Projectile + } + + public static void Send(string name, bool progressDialogue, EntityType type, int entity, int index, int uptime, DisplayEffectID effect, float wrapWidth, int toClient = -1, int ignoreClient = -1) + { + // Only Server should send Reponse to Clients + if (!Main.dedServ) + return; + + var packet = Instance.CreateBasePacket(); + + packet.Write(name); + packet.WriteFlags(progressDialogue, true); + packet.Write((byte)type); + packet.Write(entity); + packet.Write(index); + packet.Write(uptime); + packet.Write((byte)effect); + packet.Write(wrapWidth); + + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + // Only receive info as clients + + string name = packet.ReadString(); + packet.ReadFlags(out bool progressDialogue, out bool hasEntity); + + int entity = -1; + Vector2 pos = Vector2.zeroVector; + EntityType type = EntityType.NPC; + if (hasEntity) + { + type = (EntityType)packet.ReadByte(); + entity = packet.ReadInt32(); + } + else + pos = packet.ReadPackedVector2(); + + int index = packet.ReadInt32(); + int uptime = packet.ReadInt32(); + byte effect = packet.ReadByte(); + float wrapWidth = packet.ReadSingle(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + return; + + DisplayEffect de = GetEffect((DisplayEffectID)effect); + + if (hasEntity) + { + Entity e = type switch + { + EntityType.NPC => Main.npc[entity], + EntityType.Player => Main.player[entity], + EntityType.Projectile => Main.projectile.FirstOrDefault(p => p.identity == entity), + _ => null + }; + + StartDialogueOnClient(name, e, index, uptime, progressDialogue, de, wrapWidth); + } + else + StartDialogueOnClient(name, pos, index, uptime, progressDialogue, de, wrapWidth); + + } + } + +} diff --git a/Packets/TileEntities/TECanvasPaintingPacket.cs b/Packets/TileEntities/TECanvasPaintingPacket.cs index a7d0b36bbf..99cc38a513 100644 --- a/Packets/TileEntities/TECanvasPaintingPacket.cs +++ b/Packets/TileEntities/TECanvasPaintingPacket.cs @@ -1,22 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; -using Terraria.DataStructures; -using Terraria.ID; using Terraria; namespace CalamityMod.Packets { - public sealed class TECanvasPaintingPacket : CalamityPacket + internal sealed class TECanvasPaintingPacket : CalamityPacket { public static TECanvasPaintingPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.UpdateCanvasPainting; - public static void Send(TECanvasPainting painting, float posX, float posY, float scale, int toClient = -1, int ignoreClient = -1) { if (painting is null) @@ -30,7 +21,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var painting = packet.ReadTileEntity(); float posX = packet.ReadSingle(); diff --git a/Packets/TileEntities/TEChargingStationItemChangePacket.cs b/Packets/TileEntities/TEChargingStationItemChangePacket.cs index 4aef46d3f6..c25886c3a6 100644 --- a/Packets/TileEntities/TEChargingStationItemChangePacket.cs +++ b/Packets/TileEntities/TEChargingStationItemChangePacket.cs @@ -1,23 +1,14 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; using Terraria; -using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader.IO; namespace CalamityMod.Packets { - public sealed class TEChargingStationItemChangePacket : CalamityPacket + internal sealed class TEChargingStationItemChangePacket : CalamityPacket { public static TEChargingStationItemChangePacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.ChargingStationItemChange; - public static void Send(TEChargingStation chargingStn, Item pluggedItem, int toClient = -1, int ignoreClient = -1) { if (chargingStn is null) @@ -29,7 +20,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var chargingStn = packet.ReadTileEntity(); Item thePlug = ItemIO.Receive(packet, readStack: true, readFavorite: true); diff --git a/Packets/TileEntities/TEChargingStationStandardPacket.cs b/Packets/TileEntities/TEChargingStationStandardPacket.cs index 02307d9840..8e7b5962ea 100644 --- a/Packets/TileEntities/TEChargingStationStandardPacket.cs +++ b/Packets/TileEntities/TEChargingStationStandardPacket.cs @@ -1,24 +1,15 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.Items; using CalamityMod.TileEntities; -using Terraria.DataStructures; -using Terraria.ID; using Terraria; -using System.Runtime.InteropServices; +using Terraria.ID; namespace CalamityMod.Packets { - public sealed class TEChargingStationStandardPacket : CalamityPacket + internal sealed class TEChargingStationStandardPacket : CalamityPacket { public static TEChargingStationStandardPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.ChargingStationStandard; - public static void Send(TEChargingStation chargingStn, short timer, short cellStack, float chargeOrNaN, int toClient = -1, int ignoreClient = -1) { if (chargingStn is null) @@ -32,7 +23,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var chargingStn = packet.ReadTileEntity(); short timer = packet.ReadInt16(); diff --git a/Packets/TileEntities/TELabHologramProjectorPacket.cs b/Packets/TileEntities/TELabHologramProjectorPacket.cs index d43785f1ba..7e8e03f5a6 100644 --- a/Packets/TileEntities/TELabHologramProjectorPacket.cs +++ b/Packets/TileEntities/TELabHologramProjectorPacket.cs @@ -1,20 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; -using Terraria.DataStructures; namespace CalamityMod.Packets { - public sealed class TELabHologramProjectorPacket : CalamityPacket + internal sealed class TELabHologramProjectorPacket : CalamityPacket { public static TELabHologramProjectorPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.LabHologramProjector; - public static void Send(TELabHologramProjector projector, bool poppingUp, int toClient = -1, int ignoreClient = -1) { if (projector is null) @@ -26,7 +18,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var projector = packet.ReadTileEntity(); bool pop = packet.ReadBoolean(); diff --git a/Packets/TileEntities/TEPowerCellFactoryPacket.cs b/Packets/TileEntities/TEPowerCellFactoryPacket.cs index 6b99b14023..0c5b92eca6 100644 --- a/Packets/TileEntities/TEPowerCellFactoryPacket.cs +++ b/Packets/TileEntities/TEPowerCellFactoryPacket.cs @@ -1,22 +1,14 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; -using Terraria.DataStructures; -using Terraria.ID; using Terraria; +using Terraria.ID; namespace CalamityMod.Packets { - public sealed class TEPowerCellFactoryPacket : CalamityPacket + internal sealed class TEPowerCellFactoryPacket : CalamityPacket { public static TEPowerCellFactoryPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.PowerCellFactory; - public static void Send(TEPowerCellFactory cellFactory, long time, int stack, int toClient = -1, int ignoreClient = -1) { if (cellFactory is null) @@ -29,7 +21,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var cellFactory = packet.ReadTileEntity(); long time = packet.ReadInt64(); diff --git a/Packets/TileEntities/TETurretPacket.cs b/Packets/TileEntities/TETurretPacket.cs index 342d303c6b..1d61b09962 100644 --- a/Packets/TileEntities/TETurretPacket.cs +++ b/Packets/TileEntities/TETurretPacket.cs @@ -1,25 +1,14 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection.Metadata; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; -using CalamityMod.Tiles.FurnitureStatigel; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; namespace CalamityMod.Packets { - public sealed class TETurretPacket : CalamityPacket + internal sealed class TETurretPacket : CalamityPacket { public static TETurretPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.Turret; - public static void Send(TEBaseTurret turret, int toClient = -1, int ignoreClient = -1) { if (turret is null) @@ -34,7 +23,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var turret = packet.ReadTileEntity(); int firingTime = packet.ReadInt32(); diff --git a/Packets/TileEntities/TEUpdateCodebreakerConstituentsPacket.cs b/Packets/TileEntities/TEUpdateCodebreakerConstituentsPacket.cs index 8746aa37c9..c61a1e012d 100644 --- a/Packets/TileEntities/TEUpdateCodebreakerConstituentsPacket.cs +++ b/Packets/TileEntities/TEUpdateCodebreakerConstituentsPacket.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; using Terraria; -using Terraria.DataStructures; -using Terraria.ID; namespace CalamityMod.Packets { @@ -15,8 +8,6 @@ namespace CalamityMod.Packets { public static TEUpdateCodebreakerConstituentsPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.UpdateCodebreakerConstituents; - public static void Send(TECodebreaker codeBreaker, int toClient = -1, int ignoreClient = -1) { if (codeBreaker is null) @@ -35,7 +26,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var codeBreaker = packet.ReadTileEntity(); BitsByte containmentFlagWrapper = packet.ReadByte(); diff --git a/Packets/TileEntities/TEUpdateCodebreakerContainedStuffPacket.cs b/Packets/TileEntities/TEUpdateCodebreakerContainedStuffPacket.cs index 3ba126974b..8385b9ecb3 100644 --- a/Packets/TileEntities/TEUpdateCodebreakerContainedStuffPacket.cs +++ b/Packets/TileEntities/TEUpdateCodebreakerContainedStuffPacket.cs @@ -1,20 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; -using Terraria.DataStructures; namespace CalamityMod.Packets { - public sealed class TEUpdateCodebreakerContainedStuffPacket : CalamityPacket + internal sealed class TEUpdateCodebreakerContainedStuffPacket : CalamityPacket { public static TEUpdateCodebreakerContainedStuffPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.UpdateCodebreakerContainedStuff; - public static void Send(TECodebreaker codeBreaker, int toClient = -1, int ignoreClient = -1) { if (codeBreaker is null) @@ -25,17 +17,17 @@ namespace CalamityMod.Packets packet.Write(codeBreaker.InputtedCellCount); packet.Write(codeBreaker.InitialCellCountBeforeDecrypting); packet.Write(codeBreaker.HeldSchematicID); - packet.Write(codeBreaker.ContainsBloodSample); + packet.Write(codeBreaker.ContainsBloodyVein); packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var codeBreaker = packet.ReadTileEntity(); int cellCount = packet.ReadInt32(); int cellCountBeforeDecrypting = packet.ReadInt32(); int schematicID = packet.ReadInt32(); - bool containsBloodSample = packet.ReadBoolean(); + bool containsBloodyVein = packet.ReadBoolean(); // Verify to ensure that the tile entity is a valid one. if (codeBreaker is null) @@ -44,7 +36,7 @@ namespace CalamityMod.Packets codeBreaker.InputtedCellCount = cellCount; codeBreaker.InitialCellCountBeforeDecrypting = cellCountBeforeDecrypting; codeBreaker.HeldSchematicID = schematicID; - codeBreaker.ContainsBloodSample = containsBloodSample; + codeBreaker.ContainsBloodyVein = containsBloodyVein; } } } diff --git a/Packets/TileEntities/TEUpdateCodebreakerDecryptCountdownPacket.cs b/Packets/TileEntities/TEUpdateCodebreakerDecryptCountdownPacket.cs index 933c017352..6fc2b6499d 100644 --- a/Packets/TileEntities/TEUpdateCodebreakerDecryptCountdownPacket.cs +++ b/Packets/TileEntities/TEUpdateCodebreakerDecryptCountdownPacket.cs @@ -1,20 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.TileEntities; -using Terraria.DataStructures; namespace CalamityMod.Packets { - public sealed class TEUpdateCodebreakerDecryptCountdownPacket : CalamityPacket + internal sealed class TEUpdateCodebreakerDecryptCountdownPacket : CalamityPacket { public static TEUpdateCodebreakerDecryptCountdownPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.UpdateCodebreakerDecryptCountdown; - public static void Send(TECodebreaker codeBreaker, int toClient = -1, int ignoreClient = -1) { if (codeBreaker is null) @@ -26,7 +18,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var codeBreaker = packet.ReadTileEntity(); int countdown = packet.ReadInt32(); diff --git a/Packets/Worlds/BanditStolenMoneySyncPacket.cs b/Packets/Worlds/BanditStolenMoneySyncPacket.cs index 576f419be8..0a04fcf7c6 100644 --- a/Packets/Worlds/BanditStolenMoneySyncPacket.cs +++ b/Packets/Worlds/BanditStolenMoneySyncPacket.cs @@ -1,20 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.World; using Terraria; namespace CalamityMod.Packets { - public sealed class BanditStolenMoneySyncPacket : CalamityPacket + internal sealed class BanditStolenMoneySyncPacket : CalamityPacket { public static BanditStolenMoneySyncPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.BanditStolenMoneySync; - public static void Send(int amountStolenByBandit, int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); @@ -22,7 +15,7 @@ namespace CalamityMod.Packets packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { var amountStolenByBandit = packet.Read7BitEncodedInt(); diff --git a/Packets/Worlds/SwitchToDifficultyPacket.cs b/Packets/Worlds/SwitchToDifficultyPacket.cs new file mode 100644 index 0000000000..0ea247d70d --- /dev/null +++ b/Packets/Worlds/SwitchToDifficultyPacket.cs @@ -0,0 +1,40 @@ +using System.IO; +using System.Linq; +using CalamityMod.Systems; +using CalamityMod.UI.ModeIndicator; +using Terraria; + +namespace CalamityMod.Packets +{ + internal sealed class SwitchToDifficultyPacket : CalamityPacket + { + public static SwitchToDifficultyPacket Instance { get; private set; } + + public static void Send(DifficultyMode modeToSwitch, int toClient = -1, int ignoreClient = -1) + { + var packet = Instance.CreateBasePacket(); + // Simple Solution: Just write FullName of the DifficultyMode type to avoid any desync + // This is tolerable as this packet is designed to be not be called frequently + packet.Write(modeToSwitch.FullName); + packet.Send(toClient, ignoreClient); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var modeName = packet.ReadString(); + var difficulty = DifficultyModeSystem.Difficulties.SingleOrDefault(diff => diff.FullName.Equals(modeName)); + + if (difficulty != null) + { + ModeIndicatorUI.SwitchToDifficulty(difficulty, broadcast: false); + + if (Main.dedServ) + Send(difficulty, ignoreClient: sender); + } + else + { + CalamityMod.Log.Error($"Packet: [{nameof(SwitchToDifficultyPacket)}] has failed! Name: [{modeName}] is not a valid {nameof(DifficultyMode)} name!"); + } + } + } +} diff --git a/Packets/Worlds/SyncDifficultiesPacket.cs b/Packets/Worlds/SyncDifficultiesPacket.cs deleted file mode 100644 index d205f57d8a..0000000000 --- a/Packets/Worlds/SyncDifficultiesPacket.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.World; -using Terraria; - -namespace CalamityMod.Packets -{ - public sealed class SyncDifficultiesPacket : CalamityPacket - { - // MIGRATED COMMENTS FROM: 'CalamityNetcode.cs' - //TODO - Something so that other mods that hijack the difficulty ui can also use the remainder of the reader to have their own shit - - public static SyncDifficultiesPacket Instance { get; private set; } - - public override byte MessageType => (byte)CalamityModMessageType.SyncDifficulties; - - public static void Send(int toClient = -1, int ignoreClient = -1) - { - var packet = Instance.CreateBasePacket(); - var difficultyFlags = new BitsByte(); - difficultyFlags[0] = CalamityWorld.revenge; - difficultyFlags[1] = CalamityWorld.death; - packet.Write((byte)difficultyFlags); - packet.Send(toClient, ignoreClient); - } - - public override void HandlePacket(in BinaryReader packet, int sender) - { - var difficultyFlags = (BitsByte)packet.ReadByte(); - CalamityWorld.revenge = difficultyFlags[0]; - CalamityWorld.death = difficultyFlags[1]; - - if (Main.dedServ) - Send(ignoreClient: sender); - } - } -} diff --git a/Packets/Worlds/UnlockAbyssChestsPacket.cs b/Packets/Worlds/UnlockAbyssChestsPacket.cs index f134a64e06..88d7705d2d 100644 --- a/Packets/Worlds/UnlockAbyssChestsPacket.cs +++ b/Packets/Worlds/UnlockAbyssChestsPacket.cs @@ -1,28 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.Contracts; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.World; -using Terraria; namespace CalamityMod.Packets { - public sealed class UnlockAbyssChestsPacket : CalamityPacket + internal sealed class UnlockAbyssChestsPacket : CalamityPacket { public static UnlockAbyssChestsPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.UnlockAbyssChests; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { Abyss.DoUnlockAllAbyssChests(); } diff --git a/Packets/Worlds/WantToRefundReforgesPacket.cs b/Packets/Worlds/WantToRefundReforgesPacket.cs index 440cd6791b..980805ffb2 100644 --- a/Packets/Worlds/WantToRefundReforgesPacket.cs +++ b/Packets/Worlds/WantToRefundReforgesPacket.cs @@ -1,29 +1,21 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; using CalamityMod.NPCs.TownNPCs; -using CalamityMod.World; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Packets { - public sealed class WantToRefundReforgesPacket : CalamityPacket + internal sealed class WantToRefundReforgesPacket : CalamityPacket { public static WantToRefundReforgesPacket Instance { get; private set; } - public override byte MessageType => (byte)CalamityModMessageType.WantToRefundReforges; - public static void Send(int toClient = -1, int ignoreClient = -1) { var packet = Instance.CreateBasePacket(); packet.Send(toClient, ignoreClient); } - public override void HandlePacket(in BinaryReader packet, int sender) + public override void HandlePacket(BinaryReader packet, int sender) { // Only Server should handle this action! if (!Main.dedServ) diff --git a/Particles/AresCannonChargeParticleSet.cs b/Particles/AresCannonChargeParticleSet.cs index 057d126e6d..aeb6353468 100644 --- a/Particles/AresCannonChargeParticleSet.cs +++ b/Particles/AresCannonChargeParticleSet.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using static CalamityMod.CalamityUtils; namespace CalamityMod.Particles diff --git a/Particles/BaseParticleSet.cs b/Particles/BaseParticleSet.cs index 29e4ad197e..a5da5de1e5 100644 --- a/Particles/BaseParticleSet.cs +++ b/Particles/BaseParticleSet.cs @@ -4,7 +4,6 @@ using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Particles diff --git a/Particles/BossRoar.cs b/Particles/BossRoar.cs new file mode 100644 index 0000000000..2ce1b63234 --- /dev/null +++ b/Particles/BossRoar.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles; + +public class BossRoar : Particle +{ + public override string Texture => "CalamityMod/Particles/RoarPulse"; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + private float OriginalScale; + private float FinalScale; + private float BaseOpacity; + private float opacity; + private Color BaseColor; + + public BossRoar(Vector2 position, Color color, float rotation, float originalScale, float finalScale, int lifeTime, float baseOpacity = 1f) + { + Position = position; + BaseColor = color; + OriginalScale = originalScale; + FinalScale = finalScale; + Scale = originalScale; + Lifetime = lifeTime; + BaseOpacity = baseOpacity; + Rotation = rotation; + } + + public override void Update() + { + Scale = MathHelper.Lerp(OriginalScale, FinalScale, LifetimeCompletion); + + opacity = 1f; + if (LifetimeCompletion < 0.1f) + opacity = MathHelper.Lerp(0f, 1f, LifetimeCompletion * 10); + + Color = BaseColor * opacity; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * BaseOpacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0); + } +} diff --git a/Particles/BrainOfCthulhuAfterImage.cs b/Particles/BrainOfCthulhuAfterImage.cs new file mode 100644 index 0000000000..f1b18b1eaf --- /dev/null +++ b/Particles/BrainOfCthulhuAfterImage.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; + +namespace CalamityMod.Particles; + +public class BrainOfCthulhuAfterImage : Particle +{ + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool UseCustomDraw => false; + + public override bool SetLifetime => true; + + public override bool Important => true; + + private float StartFade; + private float Opacity = 1f; + List Path; + private Vector2 MyScale = Vector2.One; + private Rectangle Frame; + + public BrainOfCthulhuAfterImage(BezierCurve path, float rotation, Vector2 scale, int lifeTime, Rectangle frame, float startFadeRatio = 0f) + { + Path = path.GetPoints(lifeTime); + Position = Path[0]; + Rotation = rotation; + StartFade = startFadeRatio; + MyScale = scale; + Frame = frame; + Lifetime = lifeTime + 1; + } + + public override void Update() + { + float timeRatio = Time / (float)Lifetime; + Opacity = timeRatio; + if (StartFade != 0f) + Opacity = Utils.GetLerpValue(StartFade, 1f, timeRatio, true); + + Opacity = 1 - CalamityUtils.SineInEasing(Opacity, 1); + + List pathPosition = Path; + + if (Time >= pathPosition.Count) + { + Kill(); + return; + } + + Position = pathPosition[Time]; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + float timeRatio = Time / (float)Lifetime; + spriteBatch.Draw(TextureAssets.Npc[NPCID.BrainofCthulhu].Value, Position - Main.screenPosition, Frame, Lighting.GetColor(Position.ToTileCoordinates()) * Opacity * 0.5f, Rotation, Frame.Size() * 0.5f, MyScale, 0, 0); + } +} + diff --git a/Particles/BrokenTendril.cs b/Particles/BrokenTendril.cs new file mode 100644 index 0000000000..6a91a187a7 --- /dev/null +++ b/Particles/BrokenTendril.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Particles; + +public class BrokenTendril : Particle +{ + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool UseCustomDraw => true; + + private int TimeLeft; + private float Opacity = 1f; + private Vector2 InitalScale = Vector2.One; + + public BrokenTendril(Vector2 position, Vector2 velocity, float rotation, Vector2 scale, int lifeTime) + { + Position = position; + Velocity = velocity; + Scale = 1f; + Rotation = rotation; + TimeLeft = lifeTime; + InitalScale = scale - Vector2.One; + } + + public override void Update() + { + if (InitalScale != Vector2.Zero) + { + InitalScale *= 0.98f; + if (InitalScale.X < 0.05f) + InitalScale.X = 0; + if (InitalScale.Y < 0.05f) + InitalScale.Y = 0; + } + + Point tilePos = Position.ToTileCoordinates(); + if (!WorldGen.InWorld(tilePos.X, tilePos.Y)) + { + Kill(); + return; + } + + if (Main.tile[tilePos].IsTileSolid() || TileID.Sets.Platforms[Main.tile[tilePos].TileType]) + { + Velocity.Y = 0; + if (Velocity.X > 0.05f) + Velocity.X *= 0.9f; + else + Velocity.X = 0; + } + else + { + Velocity.Y += 0.25f; + Velocity.X *= 0.975f; + } + + Rotation += Velocity.X * 0.025f; + + if (Velocity == Vector2.Zero) + { + if (TimeLeft < 30) + { + Opacity = TimeLeft / 30f; + if (TimeLeft <= 0) + Kill(); + } + TimeLeft--; + } + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = BrainOfCthulhuSystem.tendril.Value; + float rot = Rotation - MathHelper.PiOver2; + Vector2 center = Position + rot.ToRotationVector2() * tex.Size().Y * InitalScale.Y * 0.5f; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Lighting.GetColor(center.ToTileCoordinates()) * Opacity, rot, tex.Size() * Vector2.UnitX * 0.5f, Vector2.One + InitalScale, SpriteEffects.None, 0f); + } +} + diff --git a/Particles/ChumBone.cs b/Particles/ChumBone.cs index 88838070b4..07fdf73bf7 100644 --- a/Particles/ChumBone.cs +++ b/Particles/ChumBone.cs @@ -1,7 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -14,11 +13,10 @@ namespace CalamityMod.Particles public override bool UseCustomDraw => true; public override bool SetLifetime => true; - private bool direction; - private bool variant; + private bool TexVariant; public static string Texture2 => "CalamityMod/Particles/ChumBone2"; - public ChumBone(Vector2 position, Vector2 velocity, Color color, float rotation, float scale, int lifeTime, bool variant, bool direction) + public ChumBone(Vector2 position, Vector2 velocity, Color color, float rotation, float scale, int lifeTime, bool variant) { Position = position; Velocity = velocity; @@ -26,6 +24,7 @@ namespace CalamityMod.Particles Lifetime = lifeTime; Rotation = rotation; Color = color; + TexVariant = variant; } public override void Update() @@ -54,8 +53,8 @@ namespace CalamityMod.Particles public override void CustomDraw(SpriteBatch spriteBatch) { - Texture2D tex = variant ? ModContent.Request(Texture2).Value : ModContent.Request(Texture).Value; - SpriteEffects spriteDir = direction ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Texture2D tex = TexVariant ? ModContent.Request(Texture2).Value : ModContent.Request(Texture).Value; + SpriteEffects spriteDir = SpriteEffects.FlipHorizontally; spriteBatch.Draw(tex, Position - Main.screenPosition, null, Lighting.GetColor(Position.ToTileCoordinates()), Rotation, new Vector2(tex.Width / 2, tex.Height), Scale, spriteDir, 0); } } diff --git a/Particles/CustomPulse.cs b/Particles/CustomPulse.cs index ee6649cf23..e46c173c95 100644 --- a/Particles/CustomPulse.cs +++ b/Particles/CustomPulse.cs @@ -23,8 +23,10 @@ namespace CalamityMod.Particles private bool FadeOut; private Vector2 Squish; private Color BaseColor; + private float MakeLight; + SpriteEffects Effects = SpriteEffects.None; - public CustomPulse(Vector2 position, Vector2 velocity, Color color, string texture, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime, bool UseAdditiveBlend = true, float baseOpacity = 1f, bool fade = true) + public CustomPulse(Vector2 position, Vector2 velocity, Color color, string texture, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime, bool UseAdditiveBlend = true, float baseOpacity = 1f, bool fade = true, float makeLight = 1, SpriteEffects effects = SpriteEffects.None) { Position = position; Velocity = velocity; @@ -37,8 +39,10 @@ namespace CalamityMod.Particles BaseOpacity = baseOpacity; FadeOut = fade; Squish = squish; + Effects = effects; Rotation = rotation; UseAltVisual = UseAdditiveBlend; + MakeLight = makeLight; } public override void Update() @@ -49,15 +53,27 @@ namespace CalamityMod.Particles opacity = (FadeOut ? (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2) : 1f) * BaseOpacity; Color = BaseColor * opacity; - Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + if (MakeLight > 0) + Lighting.AddLight(Position, (Color.R / 255f) * MakeLight, (Color.G / 255f) * MakeLight, (Color.B / 255f) * MakeLight); Velocity *= 0.95f; } public override void CustomDraw(SpriteBatch spriteBatch) { Texture2D tex = ModContent.Request(NewTexture).Value; - spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale * Squish, SpriteEffects.None, 0); + float scaleMult = 1; + if (Main.zenithWorld) + { + DateTime day = DateTime.Now; + if (day.DayOfWeek == DayOfWeek.Tuesday) + { + Texture2D joke = ModContent.Request("CalamityMod/Particles/MammothParticle").Value; + scaleMult = (MathHelper.Lerp(tex.Size().X / joke.Size().X, tex.Size().Y / joke.Size().Y, 0.5f)); + tex = joke; + UseAltVisual = true; + } + } + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale * Squish * scaleMult, Effects, 0); } - } } diff --git a/Particles/CustomSpark.cs b/Particles/CustomSpark.cs index eec7780240..72087bb46b 100644 --- a/Particles/CustomSpark.cs +++ b/Particles/CustomSpark.cs @@ -21,13 +21,14 @@ namespace CalamityMod.Particles public float ShrinkSpeed = 0; public bool FlipHorizontal = false; public bool NoShrink = false; + public float Spin = 0; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public bool AltVisual = true; public override bool UseAdditiveBlend => AltVisual; public override bool SetLifetime => true; public override bool UseCustomDraw => true; - public CustomSpark(Vector2 relativePosition, Vector2 velocity, string texture, bool affectedByGravity, int lifetime, float scale, Color color, Vector2 stretch, bool useAddativeBlend = true, bool glowCenter = false, float extraRotation = 0, bool fadeIn = false, bool affectedByLight = false, float shrinkSpeed = 0, float glowCenterScale = 1, float glowOpacity = 1, bool flipHorizontal = false, bool noShrink = false) + public CustomSpark(Vector2 relativePosition, Vector2 velocity, string texture, bool affectedByGravity, int lifetime, float scale, Color color, Vector2 stretch, bool useAddativeBlend = true, bool glowCenter = false, float extraRotation = 0, bool fadeIn = false, bool affectedByLight = false, float shrinkSpeed = 0, float glowCenterScale = 1, float glowOpacity = 1, bool flipHorizontal = false, bool noShrink = false, float spin = 0) { Position = relativePosition; Velocity = velocity; @@ -53,6 +54,7 @@ namespace CalamityMod.Particles if (FadeIn) Scale = 0f; + Spin = spin; } public override void Update() @@ -80,6 +82,7 @@ namespace CalamityMod.Particles Velocity.X *= 0.94f; Velocity.Y += 0.25f; } + ExtraRotation += Spin; Rotation = Velocity.ToRotation() + MathHelper.PiOver2 + ExtraRotation; Stretch.X *= (1 - 0.2f * ShrinkSpeed); @@ -91,6 +94,19 @@ namespace CalamityMod.Particles Vector2 scale = Stretch * Scale; Texture2D texture = ModContent.Request(NewTexture).Value; + float scaleMult = 1; + if (Main.zenithWorld) + { + DateTime day = DateTime.Now; + if (day.DayOfWeek == DayOfWeek.Tuesday) + { + Texture2D joke = ModContent.Request("CalamityMod/Particles/MammothParticle").Value; + scaleMult = (MathHelper.Lerp(texture.Size().X / joke.Size().X, texture.Size().Y / joke.Size().Y, 0.5f)); + texture = joke; + AltVisual = true; + } + } + Color col = Color; if (AffectedByLight) @@ -98,9 +114,9 @@ namespace CalamityMod.Particles col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGB(Color); } - spriteBatch.Draw(texture, Position - Main.screenPosition, null, col, Rotation, texture.Size() * 0.5f, scale, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(col, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); if (GlowCenter) - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(col, Color.White, 0.8f) * GlowOpacity, Rotation, texture.Size() * 0.5f, scale * 0.8f * GlowCenterScale, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.Lerp(col, Color.White, 0.8f), Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)) * GlowOpacity, Rotation, texture.Size() * 0.5f, scale * 0.8f * GlowCenterScale * scaleMult, FlipHorizontal ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); } } } diff --git a/Particles/CustomSprite.cs b/Particles/CustomSprite.cs index 2fee8656b7..14ae848f27 100644 --- a/Particles/CustomSprite.cs +++ b/Particles/CustomSprite.cs @@ -1,8 +1,5 @@ -using System; -using System.Threading; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.ModLoader; diff --git a/Particles/CuteManaStarParticle.cs b/Particles/CuteManaStarParticle.cs index 63461f1970..7d7627425c 100644 --- a/Particles/CuteManaStarParticle.cs +++ b/Particles/CuteManaStarParticle.cs @@ -1,8 +1,5 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Particles { diff --git a/Particles/DeathAshParticle.cs b/Particles/DeathAshParticle.cs index 9d7c9e5da7..98d0553b5d 100644 --- a/Particles/DeathAshParticle.cs +++ b/Particles/DeathAshParticle.cs @@ -2,16 +2,16 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Graphics; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; namespace CalamityMod.Particles { public class DeathAshParticle { - internal static Dictionary PendingNPCsToDraw = new(); + internal static Dictionary PendingNPCsToDraw = new(); internal static BasicEffect basicShader = null; internal static VertexPositionColorTexture[] VertexCache = new VertexPositionColorTexture[PrimitiveBatchSize * 4]; internal static short[] IndexCache = new short[PrimitiveBatchSize * 6]; @@ -66,23 +66,22 @@ namespace CalamityMod.Particles Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); // Draw the NPC to the temporary render target so that all of its drawcode is localized, and then get the colors from the results. - Main.instance.GraphicsDevice.SetRenderTarget(PendingNPCsToDraw[npc]); - Main.instance.GraphicsDevice.Clear(Color.Transparent); - - Vector2 oldPosition = npc.position; - npc.oldPos = new Vector2[npc.oldPos.Length]; - npc.position = Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; - try + using (PendingNPCsToDraw[npc].Scope(clearColor: Color.Transparent)) { - Main.instance.DrawNPC(npc.whoAmI, true); - } - catch { } - npc.position = oldPosition; - npc.Opacity = 0f; + Vector2 oldPosition = npc.position; + npc.oldPos = new Vector2[npc.oldPos.Length]; + npc.position = Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; + try + { + Main.instance.DrawNPC(npc.whoAmI, true); + } + catch { } + npc.position = oldPosition; + npc.Opacity = 0f; - Main.spriteBatch.End(); + Main.spriteBatch.End(); + } } - Main.instance.GraphicsDevice.SetRenderTarget(null); } public static void CreateAshesFromNPC(NPC npc, Vector2 velocityOverride) @@ -92,7 +91,7 @@ namespace CalamityMod.Particles return; VelOverride = velocityOverride; - PendingNPCsToDraw[npc] = new(true, ManagedRenderTarget.CreateScreenSizedTarget); + PendingNPCsToDraw[npc] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); } public static Dictionary GetColorCacheFromTexture(Texture2D texture, Rectangle? frame = null, bool pruneForEfficency = false) diff --git a/Particles/DualTrail.png b/Particles/DualTrail.png new file mode 100644 index 0000000000..ba91236d23 Binary files /dev/null and b/Particles/DualTrail.png differ diff --git a/Particles/FlameExplosion.cs b/Particles/FlameExplosion.cs index 6403703253..cb484bc753 100644 --- a/Particles/FlameExplosion.cs +++ b/Particles/FlameExplosion.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Particles private float OriginalScale; private float FinalScale; + private float baseOpacity; private float opacity; private Vector2 Squish; private Color BaseColor; @@ -31,6 +32,7 @@ namespace CalamityMod.Particles Lifetime = lifeTime; Squish = squish; Rotation = rotation; + baseOpacity = opacity; } public override void Update() @@ -38,7 +40,7 @@ namespace CalamityMod.Particles float pulseProgress = PiecewiseAnimation(LifetimeCompletion, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); - opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2); + opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2) * baseOpacity; Color = BaseColor * opacity; Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); diff --git a/Particles/ForwardSmear.png b/Particles/ForwardSmear.png new file mode 100644 index 0000000000..b577cc9891 Binary files /dev/null and b/Particles/ForwardSmear.png differ diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 5edab9f428..1a10ce3df1 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -1,239 +1,228 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Serialization; +using System.Runtime.CompilerServices; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.Core; -using Terraria.ModLoader.IO; namespace CalamityMod.Particles { + // Important credits for Spirit and Luminance: + #region CREDITS + + // 06JAN2022: Iban + // This particle system was inspired by spirit mod's own particle system, with permission granted by Yuyutsu. Love you spirit mod! -Iban + + // 05NOV2025: fryzahh + // Particle drawing implementation was inspired by Luminance's ParticleManager.cs. See licensing information below: + // https://github.com/LucilleKarma/Luminance/blob/main/LICENSE + // + // MIT License + // + // Copyright(c) 2024 Dominic + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + // + // The above copyright notice and this permission notice shall be included in all + // copies or substantial portions of the Software. + #endregion + [Autoload(Side = ModSide.Client)] public sealed class GeneralParticleHandler : ModSystem { - private static List particles; - private static Queue particlesToSpawnNextFrame; - //List containing the particles to delete - private static List particlesToKill; - //Static list for details concerning every particle type - internal static Dictionary particleTypes; - internal static Dictionary particleTextures; - //Lists used when drawing particles batched - private static List batchedAlphaBlendParticles; - private static List batchedNonPremultipliedParticles; - private static List batchedAdditiveBlendParticles; + #region Fields + /// + /// The integer ID of each particle type defined across all mods, identified by the internal type of the respective particle. + /// + internal static Dictionary particleIDsByTypes; + /// + /// The individual, autoloaded textures of each particle type defined across all mods, identified by the ID of the respective particle. + /// + internal static Dictionary> particleTexturesByIDs; + + // Collections for tracking particles active in the world. + private static List activeParticles; + private static List particlesToKill; + private static Dictionary> particlesToSpawnNextFrame; + private static Dictionary> particlesToSpawnNextFrame_Pixelated; + + // Collections for correctly organizing active prticles for drawing. + private static Dictionary> particlesToDraw; + private static Dictionary> particlesToDraw_Pixelated; + private static Dictionary>> particlesToDraw_CustomShader; + #endregion + + #region Loading and Unloading public override void PostSetupContent() { Type baseParticleType = typeof(Particle); +#pragma warning disable CS0618 // Type or member is obsolete ReflectionHelper.IterateEveryModsTypes(action: type => { - int ID = particleTypes.Count; //Get the ID of the particle - particleTypes[type] = ID; + int ID = particleIDsByTypes.Count; //Get the ID of the particle + particleIDsByTypes[type] = ID; // Flow: 2024/09/17 // 'UnintializedObject' is allowed to use here as it's only read for Texture string Property // But do NOT EVER use it's instance as they are literally Uninitialized. // It might cause unintended behaviour if we do that. -#pragma warning disable SYSLIB0050 - Particle instance = (Particle)FormatterServices.GetUninitializedObject(type); -#pragma warning restore SYSLIB0050 + Particle instance = (Particle)RuntimeHelpers.GetUninitializedObject(type); string texturePath = type.Namespace.Replace('.', '/') + "/" + type.Name; if (instance.Texture != "") texturePath = instance.Texture; - particleTextures[ID] = ModContent.Request(texturePath, AssetRequestMode.ImmediateLoad).Value; + particleTexturesByIDs[ID] = ModContent.Request(texturePath, instance.TextureRequestMode); }); +#pragma warning restore CS0618 // Type or member is obsolete } public override void Load() { - particles = []; - particlesToSpawnNextFrame = []; - particlesToKill = []; - particleTypes = []; - particleTextures = []; + particleIDsByTypes = []; + particleTexturesByIDs = []; - batchedAlphaBlendParticles = []; - batchedNonPremultipliedParticles = []; - batchedAdditiveBlendParticles = []; + activeParticles = []; + particlesToKill = []; + particlesToSpawnNextFrame = []; + particlesToSpawnNextFrame_Pixelated = []; + + particlesToDraw = []; + particlesToDraw_Pixelated = []; + particlesToDraw_CustomShader = []; + + GeneralDrawLayerSystem.OnDrawLayer += DrawParticleCollectionsAtSpecificLayer; } public override void Unload() { - particles = null; - particlesToSpawnNextFrame = null; - particlesToKill = null; - particleTypes = null; - particleTextures = null; + particleIDsByTypes = null; + particleTexturesByIDs = null; - batchedAlphaBlendParticles = null; - batchedNonPremultipliedParticles = null; - batchedAdditiveBlendParticles = null; + activeParticles = null; + particlesToKill = null; + particlesToSpawnNextFrame = null; + particlesToSpawnNextFrame_Pixelated = null; + + particlesToDraw = null; + particlesToDraw_Pixelated = null; + particlesToDraw_CustomShader = null; } + public override void OnWorldUnload() + { + activeParticles.Clear(); + particlesToKill.Clear(); + particlesToSpawnNextFrame.Clear(); + particlesToSpawnNextFrame_Pixelated.Clear(); + + particlesToDraw.Clear(); + particlesToDraw_Pixelated.Clear(); + particlesToDraw_CustomShader.Clear(); + } + #endregion + /// /// Spawns the particle instance provided into the world. If the particle limit is reached but the particle is marked as important, it will try to replace a non important particle. /// - public static void SpawnParticle(Particle particle) + /// Set to true to force the particle being spawned to be drawn pixelated. + /// Only set this to a non-null value if you'd like to manually override the draw layer of the particle instance you are spawning. + public static void SpawnParticle(Particle particle, bool pixelate = false, GeneralDrawLayer? manualDrawLayerOverride = null) { // Don't queue particles if the game is paused. // This precedent is established with how Dust instances are created. // Don't spawn particles if on the server either, or if the particles dictionary is somehow null. - if (Main.gamePaused || Main.dedServ || particles == null) + if (Main.gamePaused || Main.dedServ || activeParticles == null) return; - if (particles.Count >= CalamityClientConfig.Instance.ParticleLimit && !particle.Important) + if (activeParticles.Count >= CalamityClientConfig.Instance.ParticleLimit && !particle.Important) return; - particles.Add(particle); - particle.Type = particleTypes[particle.GetType()]; + particle.Pixelate = pixelate; + if (manualDrawLayerOverride.HasValue) + particle.DrawLayer = manualDrawLayerOverride.Value; + + activeParticles.Add(particle); + ReturnAssociatedDrawCollection(particle).Add(particle); + particle.Type = particleIDsByTypes[particle.GetType()]; } - public static void QueueParticleForNextFrame(Particle particle) + /// + /// Queues a particle instance to be spawned from within a single frame after this is called. + ///
Should be used in cases where you need to spawn a particle type from inside the overall particle update loop, such as inside the Update method of + /// another particle type.
+ ///
The single frame buffer ensures the overall particle update loop isn't altered prematurely from within the loop itself.
+ ///
+ /// Set to true to force the particle being spawned to be drawn pixelated. + /// Only set this to a non-null value if you'd like to manually override the draw layer of the particle instance you are spawning. + public static void QueueParticleForNextFrame(Particle particle, bool pixelate = false, GeneralDrawLayer? manualDrawLayerOverride = null) { // Don't queue particles if the game is paused. // This precedent is established with how Dust instances are created. // Don't spawn particles if on the server side, or if the particles dictionary is somehow null. - if (Main.gamePaused || Main.dedServ || particles == null) + if (Main.gamePaused || Main.dedServ || activeParticles == null) return; - particlesToSpawnNextFrame.Enqueue(particle); - } - - public static void Update() - { - if (Main.dedServ) - return; - - while (particlesToSpawnNextFrame.Count > 0) - SpawnParticle(particlesToSpawnNextFrame.Dequeue()); - - foreach (Particle particle in particles) + GeneralDrawLayer actualDrawLayer = manualDrawLayerOverride ?? particle.DrawLayer; + if (pixelate) { - if (particle == null) - continue; - particle.Position += particle.Velocity; - particle.Time++; - particle.Update(); + if (!particlesToSpawnNextFrame_Pixelated.ContainsKey(actualDrawLayer)) + particlesToSpawnNextFrame_Pixelated[actualDrawLayer] = []; + particlesToSpawnNextFrame_Pixelated[actualDrawLayer].Enqueue(particle); + } + else + { + if (!particlesToSpawnNextFrame.ContainsKey(actualDrawLayer)) + particlesToSpawnNextFrame[actualDrawLayer] = []; + particlesToSpawnNextFrame[actualDrawLayer].Enqueue(particle); } - //Clear out particles whose time is up - particles.RemoveAll(particle => (particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle)); - particlesToKill.Clear(); } + /// + /// Removes an active particle instance from the world entirely. + /// public static void RemoveParticle(Particle particle) { - if (Main.dedServ) - return; - - particlesToKill.Add(particle); + if (!Main.dedServ) + particlesToKill.Add(particle); } - public static void DrawAllParticles(SpriteBatch sb) + /// + /// Removes all active particle instances in the world of a specified type. + /// + public static void RemoveParticlesOfType() where T : Particle { - if (Main.dedServ) + if (Main.dedServ || activeParticles is null || activeParticles.Count == 0) return; - if (particles.Count == 0) + foreach (Particle particle in activeParticles) + { + if (particle.GetType() == typeof(T)) + particlesToKill.Add(particle); + } + } + + /// + /// Removes ALL active particle instances in the world. + /// + public static void RemoveAllParticles() + { + if (Main.dedServ || activeParticles is null || activeParticles.Count == 0) return; - sb.End(); - var rasterizer = Main.Rasterizer; - rasterizer.ScissorTestEnable = true; - Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true; - Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight); - - //Batch the particles to avoid constant restarting of the spritebatch - foreach (Particle particle in particles) - { - if (particle == null) - continue; - - if (particle.UseAdditiveBlend) - batchedAdditiveBlendParticles.Add(particle); - else if (particle.UseHalfTransparency) - batchedNonPremultipliedParticles.Add(particle); - else - batchedAlphaBlendParticles.Add(particle); - } - if (batchedAlphaBlendParticles.Count > 0) - { - sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - foreach (Particle particle in batchedAlphaBlendParticles) - { - if (particle.UseCustomDraw) - particle.CustomDraw(sb); - else - { - Color lightColor = particle.Color; - if (particle.AffectedByLight) - { - lightColor = particle.Color.MultiplyRGB(Lighting.GetColor((particle.Position / 16).ToPoint())); - } - - Rectangle frame = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); - sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, - particle.Scale, SpriteEffects.None, 0f); - } - } - sb.End(); - } - - - if (batchedNonPremultipliedParticles.Count > 0) - { - rasterizer = Main.Rasterizer; - rasterizer.ScissorTestEnable = true; - Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true; - Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight); - sb.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - foreach (Particle particle in batchedNonPremultipliedParticles) - { - if (particle.UseCustomDraw) - particle.CustomDraw(sb); - else - { - Rectangle frame = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); - sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, particle.Color, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); - } - } - sb.End(); - } - - if (batchedAdditiveBlendParticles.Count > 0) - { - rasterizer = RasterizerState.CullNone; - rasterizer.ScissorTestEnable = true; - Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true; - Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight); - sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - foreach (Particle particle in batchedAdditiveBlendParticles) - { - if (particle.UseCustomDraw) - particle.CustomDraw(sb); - else - { - Rectangle frame = particleTextures[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); - sb.Draw(particleTextures[particle.Type], particle.Position - Main.screenPosition, frame, particle.Color, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); - } - } - sb.End(); - } - - batchedAlphaBlendParticles.Clear(); - batchedNonPremultipliedParticles.Clear(); - batchedAdditiveBlendParticles.Clear(); - - sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.Transform); + foreach (Particle particle in activeParticles) + particlesToKill.Add(particle); } /// @@ -243,10 +232,10 @@ namespace CalamityMod.Particles public static int FreeSpacesAvailable() { //Safety check - if (Main.dedServ || particles == null) + if (Main.dedServ || activeParticles == null) return 0; - return CalamityClientConfig.Instance.ParticleLimit - particles.Count(); + return CalamityClientConfig.Instance.ParticleLimit - activeParticles.Count(); } /// @@ -257,11 +246,240 @@ namespace CalamityMod.Particles if (Main.dedServ) return null; - return particleTextures[type]; + return particleTexturesByIDs[type].Value; } -#pragma warning disable CS0414 - private static string noteToEveryone = "This particle system was inspired by spirit mod's own particle system, with permission granted by Yuyutsu. Love you spirit mod! -Iban"; -#pragma warning restore CS0414 + public static void Update() + { + if (Main.dedServ) + return; + + // Spawn queued particles. + foreach (var collectionsByDrawLayer in particlesToSpawnNextFrame) + { + while (collectionsByDrawLayer.Value.Count > 0) + SpawnParticle(collectionsByDrawLayer.Value.Dequeue(), false, collectionsByDrawLayer.Key); + } + + foreach (var collectionsByDrawLayer in particlesToSpawnNextFrame_Pixelated) + { + while (collectionsByDrawLayer.Value.Count > 0) + SpawnParticle(collectionsByDrawLayer.Value.Dequeue(), true, collectionsByDrawLayer.Key); + } + + // Update all particle instances in the world. + foreach (Particle particle in activeParticles) + { + if (particle == null) + continue; + + particle.Position += particle.Velocity; + particle.Time++; + particle.Update(); + } + + //Clear out particles whose time is up + activeParticles.RemoveAll(particle => + { + if ((particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle)) + { + ReturnAssociatedDrawCollection(particle).Remove(particle); + return true; + } + return false; + }); + + particlesToKill.Clear(); + } + + private static void DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer drawLayer) + { + if (Main.dedServ) + return; + + DrawParticleCollection(particlesToDraw, drawLayer); + DrawParticleCollection(particlesToDraw_Pixelated, drawLayer, true); + DrawParticlesWithShaders(drawLayer); + } + + private static void DrawParticleInstance(Particle particle) + { + int drawIterations = Main.LocalPlayer.Calamity().trippy ? 4 : 1; + for (int i = 0; i < drawIterations; i++) + { + // If you have shrooms, manually spoof the position of the particle for each clone location + Vector2 positionSpoof = particle.Position; + Vector2 positionDiff = positionSpoof - Main.LocalPlayer.Center; + switch (i) + { + case 0: + break; + case 1: + particle.Position = Main.LocalPlayer.Center - positionDiff; + break; + case 2: + particle.Position = Main.LocalPlayer.Center - Vector2.UnitY * positionDiff.Y + Vector2.UnitX * positionDiff.X; + break; + case 3: + particle.Position = Main.LocalPlayer.Center - Vector2.UnitX * positionDiff.X + Vector2.UnitY * positionDiff.Y; + break; + } + + if (Main.LocalPlayer.Calamity().trippy) + particle.Color = Main.DiscoColor; + + // The actual drawing step + if (particle.UseCustomDraw) + { + particle.CustomDraw(Main.spriteBatch); + } + else + { + Color lightColor = particle.Color; + if (particle.AffectedByLight) + lightColor = particle.Color.MultiplyRGB(Lighting.GetColor((particle.Position / 16).ToPoint())); + + Rectangle frame = particleTexturesByIDs[particle.Type].Frame(1, particle.FrameVariants, 0, particle.Variant); + Main.spriteBatch.Draw(particleTexturesByIDs[particle.Type].Value, particle.Position - Main.screenPosition, frame, lightColor, particle.Rotation, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); + } + + // Since the switch case directly modifies the particle position, this resets it to the proper location + particle.Position = positionSpoof; + } + } + + private static void DrawParticleCollection(Dictionary> drawCollection, GeneralDrawLayer drawLayer, bool pixelated = false) + { + var scissorRectRasterizer = Main.Rasterizer; + scissorRectRasterizer.ScissorTestEnable = true; + Main.graphics.GraphicsDevice.RasterizerState.ScissorTestEnable = true; + Main.graphics.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight); + + foreach (var keyValuePair in drawCollection) + { + if (pixelated) + { + PixelationManager.AddPixelatedDrawer((pixelationMatrix) => + { + var particlesAtSpecifiedLayer = keyValuePair.Value.Where(p => p.DrawLayer == drawLayer); + if (particlesAtSpecifiedLayer.Any()) + { + foreach (Particle particle in particlesAtSpecifiedLayer) + DrawParticleInstance(particle); + } + + }, drawLayer, keyValuePair.Key); + } + else + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, keyValuePair.Key, SamplerState.LinearClamp, DepthStencilState.None, scissorRectRasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + var particlesAtSpecifiedLayer = keyValuePair.Value.Where(p => p.DrawLayer == drawLayer); + if (particlesAtSpecifiedLayer.Any()) + { + foreach (Particle particle in particlesAtSpecifiedLayer) + DrawParticleInstance(particle); + } + + Main.spriteBatch.End(); + } + } + } + + private static void DrawParticlesWithShaders(GeneralDrawLayer drawLayer) + { + foreach (var shaderDrawCollectionPair in particlesToDraw_CustomShader) + { + foreach (var blendStateParticleListPair in shaderDrawCollectionPair.Value) + { + if (blendStateParticleListPair.Value.Count == 0) + return; + + Main.spriteBatch.Begin(SpriteSortMode.Immediate, blendStateParticleListPair.Key, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, shaderDrawCollectionPair.Key, Main.GameViewMatrix.TransformationMatrix); + + var particlesAtDrawLayer = blendStateParticleListPair.Value.Where(p => p.DrawLayer == drawLayer); + foreach (Particle particle in particlesAtDrawLayer) + { + particle.PrepareCustomShader(shaderDrawCollectionPair.Key); + DrawParticleInstance(particle); + } + + Main.spriteBatch.End(); + } + } + } + + private static List ReturnAssociatedDrawCollection(Particle particle) + { + // Particles with custom shaders. + if (particle.CustomShader != null) + { + if (!particlesToDraw_CustomShader.ContainsKey(particle.CustomShader)) + particlesToDraw_CustomShader[particle.CustomShader] = []; + + if (particle.UseAdditiveBlend) + { + if (!particlesToDraw_CustomShader[particle.CustomShader].ContainsKey(BlendState.Additive)) + particlesToDraw_CustomShader[particle.CustomShader][BlendState.Additive] = []; + return particlesToDraw_CustomShader[particle.CustomShader][BlendState.Additive]; + } + else if (particle.UseHalfTransparency) + { + if (!particlesToDraw_CustomShader[particle.CustomShader].ContainsKey(BlendState.NonPremultiplied)) + particlesToDraw_CustomShader[particle.CustomShader][BlendState.NonPremultiplied] = []; + return particlesToDraw_CustomShader[particle.CustomShader][BlendState.NonPremultiplied]; + } + else + { + if (!particlesToDraw_CustomShader[particle.CustomShader].ContainsKey(BlendState.AlphaBlend)) + particlesToDraw_CustomShader[particle.CustomShader][BlendState.AlphaBlend] = []; + return particlesToDraw_CustomShader[particle.CustomShader][BlendState.AlphaBlend]; + } + } + // Pixelated particles. + else if (particle.Pixelate) + { + if (particle.UseAdditiveBlend) + { + if (!particlesToDraw_Pixelated.ContainsKey(BlendState.Additive)) + particlesToDraw_Pixelated[BlendState.Additive] = []; + return particlesToDraw_Pixelated[BlendState.Additive]; + } + else if (particle.UseHalfTransparency) + { + if (!particlesToDraw_Pixelated.ContainsKey(BlendState.NonPremultiplied)) + particlesToDraw_Pixelated[BlendState.NonPremultiplied] = []; + return particlesToDraw_Pixelated[BlendState.NonPremultiplied]; + } + else + { + if (!particlesToDraw_Pixelated.ContainsKey(BlendState.AlphaBlend)) + particlesToDraw_Pixelated[BlendState.AlphaBlend] = []; + return particlesToDraw_Pixelated[BlendState.AlphaBlend]; + } + } + // Non-pixelated particles (regular). + else + { + if (particle.UseAdditiveBlend) + { + if (!particlesToDraw.ContainsKey(BlendState.Additive)) + particlesToDraw[BlendState.Additive] = []; + return particlesToDraw[BlendState.Additive]; + } + else if (particle.UseHalfTransparency) + { + if (!particlesToDraw.ContainsKey(BlendState.NonPremultiplied)) + particlesToDraw[BlendState.NonPremultiplied] = []; + return particlesToDraw[BlendState.NonPremultiplied]; + } + else + { + if (!particlesToDraw.ContainsKey(BlendState.AlphaBlend)) + particlesToDraw[BlendState.AlphaBlend] = []; + return particlesToDraw[BlendState.AlphaBlend]; + } + } + } } } diff --git a/Particles/GenericBubbleParticle.cs b/Particles/GenericBubbleParticle.cs index b20f7cafa4..8da6b2e912 100644 --- a/Particles/GenericBubbleParticle.cs +++ b/Particles/GenericBubbleParticle.cs @@ -1,6 +1,4 @@ using Microsoft.Xna.Framework; -using Terraria; - namespace CalamityMod.Particles { diff --git a/Particles/GlowBladeNoBloom.png b/Particles/GlowBladeNoBloom.png new file mode 100644 index 0000000000..43dd8daebe Binary files /dev/null and b/Particles/GlowBladeNoBloom.png differ diff --git a/Particles/GlowSparkParticle.cs b/Particles/GlowSparkParticle.cs index 7e81b9a9c4..c2f7729ba3 100644 --- a/Particles/GlowSparkParticle.cs +++ b/Particles/GlowSparkParticle.cs @@ -66,9 +66,21 @@ namespace CalamityMod.Particles Vector2 scale = Squash * Scale; Texture2D texture = ModContent.Request(Texture).Value; - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + float scaleMult = 1; + if (Main.zenithWorld) + { + DateTime day = DateTime.Now; + if (day.DayOfWeek == DayOfWeek.Tuesday) + { + Texture2D joke = ModContent.Request("CalamityMod/Particles/MammothParticle").Value; + scaleMult = (MathHelper.Lerp(texture.Size().X / joke.Size().X, texture.Size().Y / joke.Size().Y, 0.5f)); + texture = joke; + } + } + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * scaleMult, 0, 0f); if (Glowing) - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.White, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.White, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f) * scaleMult, 0, 0f); } } } diff --git a/Particles/GlowSquareFading.png b/Particles/GlowSquareFading.png new file mode 100644 index 0000000000..d14e66bf43 Binary files /dev/null and b/Particles/GlowSquareFading.png differ diff --git a/Particles/GlowSquareParticleThick.png b/Particles/GlowSquareParticleThick.png new file mode 100644 index 0000000000..09dd34cbde Binary files /dev/null and b/Particles/GlowSquareParticleThick.png differ diff --git a/Particles/GlowTriangle.png b/Particles/GlowTriangle.png new file mode 100644 index 0000000000..cdc9e2e98e Binary files /dev/null and b/Particles/GlowTriangle.png differ diff --git a/Particles/HealingPlus.cs b/Particles/HealingPlus.cs index b13f069536..4a4de6232b 100644 --- a/Particles/HealingPlus.cs +++ b/Particles/HealingPlus.cs @@ -1,9 +1,7 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; -using static Terraria.ModLoader.PlayerDrawLayer; namespace CalamityMod.Particles { diff --git a/Particles/HigResThinCircle.png b/Particles/HigResThinCircle.png new file mode 100644 index 0000000000..919f3fed32 Binary files /dev/null and b/Particles/HigResThinCircle.png differ diff --git a/Particles/LineThick.png b/Particles/LineThick.png new file mode 100644 index 0000000000..16eea2a19c Binary files /dev/null and b/Particles/LineThick.png differ diff --git a/Particles/MammothParticle.png b/Particles/MammothParticle.png new file mode 100644 index 0000000000..7d4f3fbb7f Binary files /dev/null and b/Particles/MammothParticle.png differ diff --git a/Particles/ManaDrainBlobs.cs b/Particles/ManaDrainBlobs.cs index 21b23b13b8..eee451d5c4 100644 --- a/Particles/ManaDrainBlobs.cs +++ b/Particles/ManaDrainBlobs.cs @@ -1,7 +1,7 @@ using System; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ModLoader; +using Terraria.ID; namespace CalamityMod.Particles { @@ -56,7 +56,7 @@ namespace CalamityMod.Particles if (Main.rand.NextBool(7)) { float velocityMultiplier = MathHelper.Lerp(0.05f, 1f, MathHelper.Clamp((distanceToOwner - 10f) / 40f, 0f, 1f)); - Dust chust = Dust.NewDustPerfect(Position, 15, Velocity * Main.rand.NextFloat(0.7f, 1.2f) * velocityMultiplier, Alpha: 100, Scale: Main.rand.NextFloat(1.2f, 1.8f)); + Dust chust = Dust.NewDustPerfect(Position, DustID.MagicMirror, Velocity * Main.rand.NextFloat(0.7f, 1.2f) * velocityMultiplier, Alpha: 100, Scale: Main.rand.NextFloat(1.2f, 1.8f)); chust.noGravity = true; chust.noLight = true; } diff --git a/Particles/MantisPunch.cs b/Particles/MantisPunch.cs index 4f948f02e3..b176751e71 100644 --- a/Particles/MantisPunch.cs +++ b/Particles/MantisPunch.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using ReLogic.Content; diff --git a/Particles/MiniFlower.png b/Particles/MiniFlower.png new file mode 100644 index 0000000000..793d007ecd Binary files /dev/null and b/Particles/MiniFlower.png differ diff --git a/Particles/Particle.cs b/Particles/Particle.cs index 41665cfd2d..2a901575ca 100644 --- a/Particles/Particle.cs +++ b/Particles/Particle.cs @@ -1,23 +1,94 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; namespace CalamityMod.Particles { - public class Particle + public abstract class Particle { /// - /// The ID of the particle inside of the general particle handler's array. This is set automatically when the particle is created - /// - public int ID; - /// - /// The ID of the particle type as registered by the general particle handler. This is set automatically when the particle handler loads + /// The ID of the particle type as registered by when the mod loads. + ///
This field is set automatically when a particle instance is spawned in the world. This should NOT be set outside of that context.
///
public int Type; + /// /// The amount of frames this particle has existed for. You shouldn't have to touch this manually. /// public int Time; + /// + /// The maximum amount of frames a particle may stay alive if Particle.SetLifeTime is set to true + /// + public int Lifetime = 0; + + /// + /// The offset of the particle in relation to the origin of the set it belongs to. This is only used in the context of a . + /// + public Vector2 RelativeOffset; + + /// + /// The inworld position of a particle. Keep in mind this isn't used in the context of a , since all the particles work off their relative position to the set's origin + /// + public Vector2 Position; + + public Vector2 Velocity; + + public Vector2 Origin; + + public Color Color; + + public float Rotation; + + public float Scale; + + /// + /// The current Y-frame of this particle's spritesheet. + /// + public int Variant = 0; + + /// + /// Whether your particle is affected by light levels. + /// + public bool AffectedByLight = false; + + /// + /// Whether or not your particle should be drawn with a pixelated effect to match Terraria's pixel size. + ///
Defaults to false.
+ ///
+ public bool Pixelate = false; + + /// + /// The "layer" or point at which you'd like your particle to draw in Terraria's internal draw order. + ///
Defaults to .
+ ///
+ public GeneralDrawLayer DrawLayer = GeneralDrawLayer.AfterDusts; + + /// + /// An 0-1 interpolant representing how close this particle is from its . + /// + public float LifetimeCompletion => Lifetime != 0 ? Time / (float)Lifetime : 0; + + /// + /// The path to this particle's autoloaded texture. + /// + /// + /// Can be accessed via . + /// + public virtual string Texture => ""; + + /// + /// for how should be autoloaded.
+ /// Defaults to + ///
+ public virtual AssetRequestMode TextureRequestMode => AssetRequestMode.AsyncLoad; + + /// + /// The maximum amount of frames this particle's spritesheet has vertically. + /// + public virtual int FrameVariants => 1; + /// /// Set this to true if you NEED the particle to render even if the particle cap is reached. /// @@ -27,51 +98,6 @@ namespace CalamityMod.Particles /// Set this to true if you want your particle to automatically get removed when its time reaches its maximum lifetime ///
public virtual bool SetLifetime => false; - /// - /// The maximum amount of frames a particle may stay alive if Particle.SetLifeTime is set to true - /// - public int Lifetime = 0; - - public float LifetimeCompletion => Lifetime != 0 ? Time / (float)Lifetime : 0; - - /// - /// The offset of the particle in relation to the origin of the set it belongs to. This is only used in the context of a Particle Set - /// - public Vector2 RelativeOffset; - /// - /// The inworld position of a particle. Keep in mind this isn't used in the context of a Particle Set, since all the particles work off their relative position to the set's origin - /// - public Vector2 Position; - public Vector2 Velocity; - - public Vector2 Origin; - public Color Color; - public float Rotation; - public float Scale; - - /// - /// Whether your particle is affected by light levels. - /// - public bool AffectedByLight = false; - - public virtual int FrameVariants => 1; - public int Variant = 0; - public virtual string Texture => ""; - /// - /// Set this to true to disable default particle drawing, thus calling Particle.CustomDraw() instead. - /// - public virtual bool UseCustomDraw => false; - /// - /// Use this method if you want to handle the particle drawing yourself. Only called if Particle.UseCustomDraw is set to true. - /// - public virtual void CustomDraw(SpriteBatch spriteBatch) { } - - public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 basePosition) { } - /// - /// Called for every update of the particle handler. - /// The particle's velocity gets automatically added to its position, and its time automatically increases. - /// - public virtual void Update() { } /// /// Set this to true to make your particle use additive blending instead of alphablend. @@ -83,11 +109,42 @@ namespace CalamityMod.Particles /// public virtual bool UseHalfTransparency => false; + /// + /// Set this to true to disable default particle drawing, thus calling Particle.CustomDraw() instead. + /// + public virtual bool UseCustomDraw => false; + + /// + /// An optional shader parameter for this paricle to be drawn with. + /// Use to set shader parameters accordingly. + /// + public virtual Effect CustomShader => null; + + /// + /// Use this method if you want to handle the particle drawing yourself. Only called if is set to true. + /// + public virtual void CustomDraw(SpriteBatch spriteBatch) { } + + /// + /// Use this method if you want to handle particle drawing yourself in the context of a . + /// + /// The base position of the particle set. + public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 basePosition) { } + + /// + /// Use this method if you're using a custom shader effect with this particle type to set shader parameters accordingly. + /// + public virtual void PrepareCustomShader(Effect shader) { } + + /// + /// Called every frame in . + /// The particle's velocity gets automatically added to its position, and its time automatically increases. + /// + public virtual void Update() { } /// /// Removes the particle from the handler /// public void Kill() => GeneralParticleHandler.RemoveParticle(this); - } } diff --git a/Particles/PlagueHumidifierMist.cs b/Particles/PlagueHumidifierMist.cs index 73c5b92342..8e85f576d9 100644 --- a/Particles/PlagueHumidifierMist.cs +++ b/Particles/PlagueHumidifierMist.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; namespace CalamityMod.Particles diff --git a/Particles/PulseStar.png b/Particles/PulseStar.png new file mode 100644 index 0000000000..4505d12981 Binary files /dev/null and b/Particles/PulseStar.png differ diff --git a/Particles/RainbowSparkParticle.cs b/Particles/RainbowSparkParticle.cs new file mode 100644 index 0000000000..5ba07c9e63 --- /dev/null +++ b/Particles/RainbowSparkParticle.cs @@ -0,0 +1,90 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class RainbowGlowSparkParticle : Particle + { + public Color InitialColor; + public bool AffectedByGravity; + public bool QuickShrink; + public bool Glowing; + public float ShrinkSpeed = 1; + public Vector2 Squash = new Vector2(0.5f, 1.6f); + public float HueShift; + + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => true; + + + public override string Texture => "CalamityMod/Particles/GlowSpark"; + + public RainbowGlowSparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color initialColor, Vector2 squash, bool quickShrink = false, bool glow = true, float shrinkSpeed = 1, float hueShift = 0) + { + Position = relativePosition; + Velocity = velocity; + AffectedByGravity = affectedByGravity; + Scale = scale; + Lifetime = lifetime; + Color = InitialColor = initialColor; + Squash = squash; + QuickShrink = quickShrink; + Glowing = glow; + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + ShrinkSpeed = shrinkSpeed; + HueShift = hueShift; + } + + public override void Update() + { + Scale *= 0.95f; + Velocity *= 0.95f; + if (QuickShrink) + { + if (ShrinkSpeed == 1) + { + Squash.X *= 0.8f; + Squash.Y *= 1.2f; + } + else + { + Squash.X *= (1 - 0.2f * ShrinkSpeed); + Squash.Y *= (1 + 0.2f * ShrinkSpeed); + } + } + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + + Color = Main.hslToRgb(Main.rgbToHsl(Color).X + HueShift, Main.rgbToHsl(Color).Y, Main.rgbToHsl(Color).Z); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Vector2 scale = Squash * Scale; + Texture2D texture = ModContent.Request(Texture).Value; + + float scaleMult = 1; + if (Main.zenithWorld) + { + DateTime day = DateTime.Now; + if (day.DayOfWeek == DayOfWeek.Tuesday) + { + Texture2D joke = ModContent.Request("CalamityMod/Particles/MammothParticle").Value; + scaleMult = (MathHelper.Lerp(texture.Size().X / joke.Size().X, texture.Size().Y / joke.Size().Y, 0.5f)); + texture = joke; + } + } + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * scaleMult, 0, 0f); + if (Glowing) + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.White, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f) * scaleMult, 0, 0f); + } + } +} diff --git a/Particles/RoarPulse.png b/Particles/RoarPulse.png new file mode 100644 index 0000000000..38c740dfea Binary files /dev/null and b/Particles/RoarPulse.png differ diff --git a/Particles/RoundedStar.png b/Particles/RoundedStar.png new file mode 100644 index 0000000000..f88faa5601 Binary files /dev/null and b/Particles/RoundedStar.png differ diff --git a/Particles/RoundedStarParticle.cs b/Particles/RoundedStarParticle.cs new file mode 100644 index 0000000000..0d77d3a243 --- /dev/null +++ b/Particles/RoundedStarParticle.cs @@ -0,0 +1,80 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class RoundedStarParticle : Particle + { + public override string Texture => "CalamityMod/Particles/RoundedStar"; + + public float RotationSpeed; + public float Deceleration; + + public bool UseSpiralAI; + private int OwnerIndex; + private float InitialRadius; + private float OrbitalAngle; + + public override bool UseCustomDraw => true; + public RoundedStarParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifetime, float rotationSpeed, float deceleration, bool useSpiralAI, Vector2 spiralTarget, int ownerIndex) + { + Position = position; + Velocity = velocity; + Color = color; + Scale = scale; + Lifetime = lifetime; + RotationSpeed = rotationSpeed; + Deceleration = deceleration; + UseSpiralAI = useSpiralAI; + OwnerIndex = ownerIndex; + + if (UseSpiralAI) + { + // Store the initial radius and angle relative to the player + Vector2 directionToPlayer = Position - Main.player[OwnerIndex].Center; + InitialRadius = directionToPlayer.Length(); + OrbitalAngle = directionToPlayer.ToRotation(); + } + } + + public override void Update() + { + if (UseSpiralAI) + { + OrbitalAngle += RotationSpeed; + + float fadeScale = 1f - (Time / (float)Lifetime); + float currentRadius = InitialRadius * fadeScale; + + Vector2 playerCenter = Main.player[OwnerIndex].Center; + + Vector2 newRelativePosition = OrbitalAngle.ToRotationVector2() * currentRadius; + + // Update the particle's position. + Position = playerCenter + newRelativePosition; + } + else + { + // If not using the spiral AI, apply deceleration + Velocity *= Deceleration; + Position += Velocity; + } + + Rotation += RotationSpeed; + Time++; + if (Time >= Lifetime) + Kill(); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + float fade = 1f - (Time / (float)Lifetime); + float scaleFade = Scale * fade; + + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * fade, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0f); + } + } +} diff --git a/Particles/SandyDustParticle.cs b/Particles/SandyDustParticle.cs index 8e66785c0d..17b5308195 100644 --- a/Particles/SandyDustParticle.cs +++ b/Particles/SandyDustParticle.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Particles { diff --git a/Particles/SeaPrismParticle.cs b/Particles/SeaPrismParticle.cs index 9c33915342..6493c127cc 100644 --- a/Particles/SeaPrismParticle.cs +++ b/Particles/SeaPrismParticle.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Particles { diff --git a/Particles/SemiCircularSmearFade.cs b/Particles/SemiCircularSmearFade.cs index f01f292b6e..09d245448c 100644 --- a/Particles/SemiCircularSmearFade.cs +++ b/Particles/SemiCircularSmearFade.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; -using static CalamityMod.CalamityUtils; namespace CalamityMod.Particles { diff --git a/Particles/SemiCircularSmearVFX.cs b/Particles/SemiCircularSmearVFX.cs index ff073899fc..acc00a6dbd 100644 --- a/Particles/SemiCircularSmearVFX.cs +++ b/Particles/SemiCircularSmearVFX.cs @@ -1,9 +1,7 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; -using static CalamityMod.CalamityUtils; namespace CalamityMod.Particles { diff --git a/Particles/ShineExplosion1.png b/Particles/ShineExplosion1.png new file mode 100644 index 0000000000..0c288e7f05 Binary files /dev/null and b/Particles/ShineExplosion1.png differ diff --git a/Particles/ShineExplosion2.png b/Particles/ShineExplosion2.png new file mode 100644 index 0000000000..44fb3e36a6 Binary files /dev/null and b/Particles/ShineExplosion2.png differ diff --git a/Particles/SmokeExplosion.png b/Particles/SmokeExplosion.png new file mode 100644 index 0000000000..e5fc5b2953 Binary files /dev/null and b/Particles/SmokeExplosion.png differ diff --git a/Particles/SquareParticle.cs b/Particles/SquareParticle.cs index b3fe433662..bfb860c310 100644 --- a/Particles/SquareParticle.cs +++ b/Particles/SquareParticle.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,13 +10,14 @@ namespace CalamityMod.Particles { public Color InitialColor; public bool AffectedByGravity; + public float ExtraRotation; public override bool SetLifetime => true; public override bool UseCustomDraw => true; public override bool UseAdditiveBlend => true; public override string Texture => "CalamityMod/Particles/Square"; - public SquareParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color) + public SquareParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, float extraRotation = 0f) { Position = relativePosition; Velocity = velocity; @@ -25,6 +25,7 @@ namespace CalamityMod.Particles Scale = scale; Lifetime = lifetime; Color = InitialColor = color; + ExtraRotation = extraRotation; } public override void Update() @@ -37,7 +38,7 @@ namespace CalamityMod.Particles Velocity.X *= 0.94f; Velocity.Y += 0.25f; } - Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + Rotation = Velocity.ToRotation() + MathHelper.PiOver2 + ExtraRotation; } public override void CustomDraw(SpriteBatch spriteBatch) diff --git a/Particles/SquareRotated.png b/Particles/SquareRotated.png new file mode 100644 index 0000000000..259d177399 Binary files /dev/null and b/Particles/SquareRotated.png differ diff --git a/Particles/SquishyLightParticle.cs b/Particles/SquishyLightParticle.cs index ab80277fa6..39b1e87178 100644 --- a/Particles/SquishyLightParticle.cs +++ b/Particles/SquishyLightParticle.cs @@ -13,7 +13,6 @@ namespace CalamityMod.Particles public override bool UseCustomDraw => true; public override bool SetLifetime => true; - public float Opacity; public float SquishStrenght; public float MaxSquish; diff --git a/Particles/StatChangeArrow.cs b/Particles/StatChangeArrow.cs new file mode 100644 index 0000000000..2658562659 --- /dev/null +++ b/Particles/StatChangeArrow.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class StatChangeArrow : Particle + { + public override string Texture => "CalamityMod/Particles/StatChangeArrow"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + + public bool AffectedByGravity = false; + + public Color StartColor; + public Color EndColor; + + public StatChangeArrow(Vector2 position, Vector2 velocity, float rotation, Color startColor, Color endColor, float scale, int lifetime) + { + Position = position; + Velocity = velocity; + Color = startColor; + StartColor = startColor; + EndColor = endColor; + Scale = scale; + Lifetime = lifetime; + Rotation = rotation; + } + + public override void Update() + { + Color = Color.Lerp(StartColor, EndColor, LifetimeCompletion); + Lighting.AddLight(Position, Color.ToVector3() * 0.2f); + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 DrawSize = new Vector2(Scale); + Vector2 Origin = new Vector2(texture.Width, texture.Height) /2f; + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, Origin, DrawSize, SpriteEffects.None, 0); + } + } +} diff --git a/Particles/StatChangeArrow.png b/Particles/StatChangeArrow.png new file mode 100644 index 0000000000..58af425b64 Binary files /dev/null and b/Particles/StatChangeArrow.png differ diff --git a/Particles/StatDownArrow.cs b/Particles/StatDownArrow.cs deleted file mode 100644 index 29624d1cd8..0000000000 --- a/Particles/StatDownArrow.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Particles -{ - public class StatDownArrow : Particle - { - public override string Texture => "CalamityMod/Particles/StatDownArrow"; - public override bool UseAdditiveBlend => true; - public override bool UseCustomDraw => true; - public override bool SetLifetime => true; - - public Color StartColor; - public Color EndColor; - - public StatDownArrow(Vector2 position, Vector2 velocity, Color startColor, Color endColor, float scale, int lifetime) - { - Position = position; - Velocity = velocity; - Color = startColor; - StartColor = startColor; - EndColor = endColor; - Scale = scale; - Lifetime = lifetime; - Rotation = 0; - } - - public override void Update() - { - Color = Color.Lerp(StartColor, EndColor, LifetimeCompletion); - Lighting.AddLight(Position, Color.ToVector3() * 0.2f); - } - - public override void CustomDraw(SpriteBatch spriteBatch) - { - Texture2D texture = ModContent.Request(Texture).Value; - Vector2 DrawSize = new Vector2(Scale); - Vector2 Origin = new Vector2(texture.Width, texture.Height); - - Vector2 PositionAdjust = new Vector2(-5, -11); - - spriteBatch.Draw(texture, Position - Main.screenPosition - PositionAdjust, null, Color, Rotation, Origin, DrawSize, SpriteEffects.None, 0); - } - } -} diff --git a/Particles/StatDownArrow.png b/Particles/StatDownArrow.png deleted file mode 100644 index 1119f1534b..0000000000 Binary files a/Particles/StatDownArrow.png and /dev/null differ diff --git a/Particles/StaticPulseRing.cs b/Particles/StaticPulseRing.cs index 9121efcec4..75a2566d88 100644 --- a/Particles/StaticPulseRing.cs +++ b/Particles/StaticPulseRing.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; diff --git a/Particles/TechyHolosquareParticle.cs b/Particles/TechyHolosquareParticle.cs index c1c010b38d..169cb14a19 100644 --- a/Particles/TechyHolosquareParticle.cs +++ b/Particles/TechyHolosquareParticle.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Particles { diff --git a/Particles/TitaniumRailgunShell.cs b/Particles/TitaniumRailgunShell.cs index 6838e42651..fc15a00138 100644 --- a/Particles/TitaniumRailgunShell.cs +++ b/Particles/TitaniumRailgunShell.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Particles @@ -73,7 +74,7 @@ namespace CalamityMod.Particles { Vector2 dustPosition = Position + Main.rand.NextVector2Circular(8f, 8f); - Dust dust = Dust.NewDustPerfect(dustPosition, 6, Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(-1f, -5f), 0, Color.White, 1.2f); + Dust dust = Dust.NewDustPerfect(dustPosition, DustID.Torch, Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(-1f, -5f), 0, Color.White, 1.2f); dust.noGravity = true; } } diff --git a/Particles/UrchinSpikeParticle.cs b/Particles/UrchinSpikeParticle.cs index 5c4848fdb4..5ba5f20bb2 100644 --- a/Particles/UrchinSpikeParticle.cs +++ b/Particles/UrchinSpikeParticle.cs @@ -1,8 +1,6 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Particles { diff --git a/Particles/VelChangingSpark .cs b/Particles/VelChangingSpark .cs index f917530522..6329ef2c06 100644 --- a/Particles/VelChangingSpark .cs +++ b/Particles/VelChangingSpark .cs @@ -96,9 +96,22 @@ namespace CalamityMod.Particles col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGB(Color); } - spriteBatch.Draw(texture, Position - Main.screenPosition, null, col, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + float scaleMult = 1; + if (Main.zenithWorld) + { + DateTime day = DateTime.Now; + if (day.DayOfWeek == DayOfWeek.Tuesday) + { + Texture2D joke = ModContent.Request("CalamityMod/Particles/MammothParticle").Value; + scaleMult = (MathHelper.Lerp(texture.Size().X / joke.Size().X, texture.Size().Y / joke.Size().Y, 0.5f)); + texture = joke; + AltVisual = true; + } + } + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, col, Rotation, texture.Size() * 0.5f, scale * scaleMult, 0, 0f); if (GlowCenter) - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(col, Color.White, 0.8f), Rotation, texture.Size() * 0.5f, scale * 0.8f, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.Lerp(col, Color.White, 0.8f), Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * 0.8f * scaleMult, 0, 0f); } } } diff --git a/Particles/WaterFlavoredParticle.cs b/Particles/WaterFlavoredParticle.cs index edd3458e2a..4688d497a0 100644 --- a/Particles/WaterFlavoredParticle.cs +++ b/Particles/WaterFlavoredParticle.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Graphics.Renderers; using Terraria.ModLoader; namespace CalamityMod.Particles diff --git a/Particles/WulfrumBastionPartsParticle.cs b/Particles/WulfrumBastionPartsParticle.cs index ea6a9d0ac6..613cd88180 100644 --- a/Particles/WulfrumBastionPartsParticle.cs +++ b/Particles/WulfrumBastionPartsParticle.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ModLoader; namespace CalamityMod.Particles { diff --git a/Particles/XykWing1.png b/Particles/XykWing1.png new file mode 100644 index 0000000000..6779fd4ee6 Binary files /dev/null and b/Particles/XykWing1.png differ diff --git a/Particles/XykWing2.png b/Particles/XykWing2.png new file mode 100644 index 0000000000..8ace823d53 Binary files /dev/null and b/Particles/XykWing2.png differ diff --git a/Particles/XykWing3.png b/Particles/XykWing3.png new file mode 100644 index 0000000000..5db97a482d Binary files /dev/null and b/Particles/XykWing3.png differ diff --git a/Pathfinding/IPathfinder.cs b/Pathfinding/IPathfinder.cs new file mode 100644 index 0000000000..441440d0ce --- /dev/null +++ b/Pathfinding/IPathfinder.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using CalamityMod.Pathfinding.Movements; + +namespace CalamityMod.Pathfinding +{ + /// + /// Defines an interface for an object that can use pathfinding. + /// + public interface IPathfinder + { + /// + /// A enumerable collection of s this pathfinder can use while pathfinding. + /// + IEnumerable Movements { get; } + + /// + /// A method that defines behavior when the pathfinding is still being calculated. + /// + void AwaitingPathBehavior(); + } +} diff --git a/Pathfinding/Movements/IMovement.cs b/Pathfinding/Movements/IMovement.cs new file mode 100644 index 0000000000..680ded0d7b --- /dev/null +++ b/Pathfinding/Movements/IMovement.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Pathfinding.Movements +{ + /// + /// Defines an interface for different types of movement in the context of pathfinding. + /// + public interface IMovement + { + /// + /// The internal name given to this movement.
+ /// Needed to differentiate between movements. + ///
+ string RegistrationName { get; } + + /// + /// The cost of enacting this movement.
+ /// Takes in two positions and returns the cost of the movement.
+ /// Cost can be negative if you want to reward that type of movement, but can lead to unintended behavior. + ///
+ Func Cost { get; } + + /// + /// Defines a method that is run whenever this movement starts execution.
+ /// Useful to get any variables set up for this movement's action. + ///
+ void Start(); + + /// + /// A method that defines the way to follow from one position to another. + /// + /// The destination of this movement. + /// if this movement has finished; otherwise . + bool FollowPath(Vector2 nextPoint); + + /// + /// A method to retrieve the possible destinations that this movement can achieve. + /// + /// The starting position where this movement takes place. + /// An enumerable collection of s with all the possible destinations. + IEnumerable GetDestinations(Point current); + } +} diff --git a/Pathfinding/Movements/SunkenSeaSwinMovement.cs b/Pathfinding/Movements/SunkenSeaSwinMovement.cs new file mode 100644 index 0000000000..bea2a10629 --- /dev/null +++ b/Pathfinding/Movements/SunkenSeaSwinMovement.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using CalamityMod.NPCs.SunkenSea; +using Microsoft.Xna.Framework; +using Terraria; + +namespace CalamityMod.Pathfinding.Movements +{ + public class SunkenSeaSwimMovement(NPC creature) : IMovement + { + public NPC Creature = creature; + private SunkenSeaNPC ssn => Creature.ModNPC(); + + public Func Cost => (_, _) => 0; + + public string RegistrationName => "Swim"; + + public bool FollowPath(Vector2 nextPoint) + { + // Accelerate to the target point. + Creature.velocity += (nextPoint - Creature.Center).SafeNormalize(Vector2.Zero) * ssn.Acceleration; + + // Cap the speed if MaxSpeed has been surpassed. + if (Creature.velocity.LengthSquared() > ssn.MaxSpeed * ssn.MaxSpeed) + Creature.velocity = Creature.velocity.SafeNormalize(Vector2.UnitY) * ssn.MaxSpeed; + + // If the NPC is within 48 pixels of its target point, consider the point reached. + if (Vector2.DistanceSquared(Creature.Center, nextPoint) < ssn.MinimumPointDistance * ssn.MinimumPointDistance) + return true; + + // Otherwise, continue following. + return false; + } + + public IEnumerable GetDestinations(Point current) + { + int nodeX = current.X; + int nodeY = current.Y; + foreach (var direction in CalamityUtils.Directions) + yield return new Point(nodeX + (int)direction.X, nodeY + (int)direction.Y); + } + + public void Start() { } + } +} diff --git a/Pathfinding/PathfindingManager.cs b/Pathfinding/PathfindingManager.cs new file mode 100644 index 0000000000..774937bc52 --- /dev/null +++ b/Pathfinding/PathfindingManager.cs @@ -0,0 +1,381 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using CalamityMod.DataStructures; +using CalamityMod.Pathfinding.Movements; +using Microsoft.Xna.Framework; +using Terraria; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Pathfinding +{ + #region Pathfinding Parameters + public readonly struct PathfindingParameters + { + internal static readonly Func DefaultTileValidity = point => true; + internal static readonly Func DefaultDistanceFunction = OctileDistance; + internal static readonly Func DefaultHeuristic = OctileDistance; + + internal readonly IPathfinder Pathfinder; + internal readonly Vector2 Start; + internal readonly Vector2 End; + internal readonly Func TileValidity; + internal readonly Func DistanceFunction; + internal readonly Func Heuristic; + + public PathfindingParameters( + IPathfinder pathfinder, + Vector2 start, + Vector2 end, + Func tileValidity = null, + Func distanceFunction = null, + Func heuristic = null) + { + Pathfinder = pathfinder; + Start = start; + End = end; + TileValidity = tileValidity; + DistanceFunction = distanceFunction; + Heuristic = heuristic; + } + } + #endregion + + #region Pathfinding Manager + /// + /// Creates a new PathfindingManager for the selected entity.
+ /// Entities should only ever need one PathfindingManager for their lifetime, but more can be created. + ///
+ /// The entity to pathfind for. + public class PathfindingManager(IPathfinder p) + { + public List Path + { + get + { + if (lastSuccessfulTask == null) + return []; + else if (lastSuccessfulTask.Result == null) + return []; + else + { + var path = new List(); + foreach (var node in lastSuccessfulTask.Result) + path.Add(node.Position.ToWorldCoordinates()); + return path; + } + } + } + + /// + /// The entity which this PathfindingManager manages. This cannot be changed after creation. + /// + internal readonly IPathfinder pathfinder = p; + + /// + /// The last completed pathfinding task that this manager has performed.
+ /// This is kept in place so that the entity may continue to follow its last successful path while calculating a new one.
+ ///
+ /// This task will always be in a Completed state with a valid Result. + ///
+ private PathfindingTask lastSuccessfulTask; + + /// + /// Represents the working task for calculating this entity's complex path.
+ ///
+ /// Accessing before execution has completed will result in the calling thread being blocked until execution is complete. + ///
+ private PathfindingTask currentTask; + + /// + /// Finds a path based on the specified parameters and assigns it to this manager's entity.
+ /// This method does not force the entity to begin following the path - it only locates a new path. + ///
+ public void FindPath(PathfindingParameters parameters, bool forceNewTask = true) + { + var potentialNewTask = new PathfindingTask(parameters); + + // Case 1: No current pathfinding task. + // Set the current task to be the potential new task. + if (currentTask is null) + { + currentTask = potentialNewTask; + currentTask.Run(); + } + + // Case 2: Current task exists and is currently running. + // Make the Entity idle and continue to await results. + if (currentTask.Running) + { + // Case 2A: We don't care about the previous pathfinding task. We have changed our goals. + // In order to trigger this behavior, you must set forceNewTask to true, and provide a different end goal position. + bool sameEndPosition = parameters.End.ToTileCoordinates() == currentTask.work.End; + bool forceNewPathAttempt = forceNewTask && !sameEndPosition; + + if (forceNewPathAttempt) + { + currentTask = potentialNewTask; + currentTask.Run(); + } + + // Regardles of whether a new pathing execution is forced, the entity will continue to behave based on any previous successful pathing. + // Its calculations have not finished. + return; + } + + // Case 3: Current task exists, but is not currently running. + // There are two reasons why this can be the case. + bool previousTaskHadNoResult = currentTask.Result is null; + bool previousTaskPathFollowed = (currentTask.Result?.Count ?? -1) == 0; + // The third case is that you are forcing it to start a new task, either to the same or a new destination. + + // Regardless of which reason the pathfinding has ended, start the new task. + if (previousTaskHadNoResult || previousTaskPathFollowed || forceNewTask) + { + currentTask = potentialNewTask; + currentTask.Run(); + return; + } + + // Case 4: "Your paths found." + // The pathfinding task has completed its execution and a valid path has been found. + // Lock in that successful pathfinding task so the entity may consume its results. + lastSuccessfulTask = currentTask; + } + + /// + /// Glue code to cause the Entity to either follow its last successful path, or idle. + /// + public void PathfindingBehavior() + { + if (lastSuccessfulTask is null) + { + pathfinder.AwaitingPathBehavior(); + return; + } + + PathfindingNode nextPoint = lastSuccessfulTask.Result[0]; + + // If that point is reached, it is removed from the list of points to follow. + bool nextPointReached = nextPoint.Move.FollowPath(nextPoint.Position.ToWorldCoordinates()); + if (nextPointReached) + lastSuccessfulTask.Result.RemoveAt(0); + + // If the previous successful found path has been followed to its endpoint, delete the task. + if (lastSuccessfulTask.Result.Count == 0) + lastSuccessfulTask = null; + } + + /// + /// Performs appropriate "path-finding behavior" for the Entity this PathfindingManager is attached to.
+ /// This method is intended to be called every frame that you want the Entity to obey its pathfinding logic. + ///
+ public void DoPathfinding(PathfindingParameters parameters, bool forceNewTask = false) + { + FindPath(parameters, forceNewTask); + PathfindingBehavior(); + } + + public void ClearResults() + { + currentTask = null; + lastSuccessfulTask = null; + } + + #region Pathfinding Task + /// + /// Represents a task for calculating a complex path.
+ /// Allows for synchronous access to an asynchronous execution state, while still providing blocking access where needed. + ///
+ private class PathfindingTask(PathfindingParameters parameters) + { + /// + /// The result of this pathfinding task. + /// + internal List Result { get => _task.Task.Result; } + + /// + /// Whether this pathfinding task has completed running. + /// + internal bool Ready { get; private set; } = false; + + /// + /// Whether this pathfinding task is still currently running. + /// + internal bool Running { get; private set; } = false; + + // Interal task representation of the work. + internal readonly TaskCompletionSource> _task = new(); + + // Internal containing object for the actual work. + internal readonly PathfindingWork work = new(parameters); + + /// + /// Begins execution of this pathfinding task on a background thread. + /// + internal void Run() + { + Running = true; + + ThreadPool.QueueUserWorkItem((pathfindingTask) => + { + var task = pathfindingTask as PathfindingTask; + task._task.TrySetResult(task.work.CalculatePath()); + + task.Ready = true; + task.Running = false; + }, + this); + } + } + #endregion + + #region Pathfinding Work Record + + /// + /// Represents the working computation for a . + /// + /// + /// + /// Has 2 constructors. One option provides the start and end positions as , and the other one as . + /// + /// + /// This record contains the start and end nodes, along with functions for tile validity, distance calculation, and heuristic estimation. + /// + /// + /// - : A function that checks if a tile at a given point is valid for traversal. If not provided, all non-solid tiles are considered valid.
+ /// - : A function that calculates the distance between two points. Defaults to .
+ /// - : A function that estimates the cost from a given point to the end point. Defaults to .
+ ///
+ ///
+ private record PathfindingWork(IPathfinder Pathfinder, Point Start, Point End, Func TileValidity, Func DistanceFunction, Func Heuristic) + { + public PathfindingWork( + PathfindingParameters p) : this( + p.Pathfinder, + p.Start.ToTileCoordinates(), + p.End.ToTileCoordinates(), + p.TileValidity ?? PathfindingParameters.DefaultTileValidity, + p.DistanceFunction ?? PathfindingParameters.DefaultDistanceFunction, + p.Heuristic ?? PathfindingParameters.DefaultHeuristic + ) + { + } + + /// + /// Calculates a path from the start to the end position using the A* pathfinding algorithm. + /// + /// + /// + /// A list of positions representing the path from start to end, or if no path is found. + /// + internal List CalculatePath() + { + // Trying to pathfind to a solid tile would be a waste of resources, we don't even consider pathfinding to it. + Tile endTile = ParanoidTileRetrieval(End.X, End.Y); + if (endTile.IsTileSolid()) + return null; + + var candidates = new HeapDict(); + var explored = new HashSet(); + + // At first, we only know the starting node. + foreach (var movement in Pathfinder.Movements) + { + var start = new PathfindingNode(Start, movement); + (start.Distance, start.Total) = (0f, Heuristic.Invoke(start.Position, End)); + candidates.Add(start, start.Total); + } + + while (candidates.Count > 0) + { + // Get the node with the lowest cost. + var current = candidates.PeekMin().Item1; + + // Check if we've reached the goal. + if (current.Position == End) + return current.ReconstructPath(); + + // Add the current node to the set of explored nodes so we don't have to check it again, + // and also delete it from the candidates. + candidates.PopMin(); + explored.Add(current); + + foreach (var neighbor in current.GetNeighborSteps(Pathfinder)) + { + // If the node has already been explored or is not a valid neighbor, we can skip it. + if (explored.Contains(neighbor) || Main.tile[neighbor.Position].IsTileSolid() || !TileValidity.Invoke(neighbor.Position)) + continue; + + // If going to the neighbor node through the current node is cheaper, we record that node to our candidates. + // Since nodes have, by default, a cost of infinity, first meeting them will always record them. + float newDistance = current.Distance + DistanceFunction.Invoke(current.Position, neighbor.Position); + if (newDistance >= neighbor.Distance) + continue; + + neighbor.Parent = current; + neighbor.Distance = newDistance; + neighbor.Total = newDistance + Heuristic.Invoke(neighbor.Position, End) + neighbor.Move.Cost.Invoke(current.Position, neighbor.Position); + + // We put it on our heap of candidates. + // If the node was already on our heap of candidates, it updates its priority. + candidates.Add(neighbor, neighbor.Total); + } + } + + // If we ran out of candidates and no path was found, we return null. + return null; + } + } + #endregion + + #region Pathfinding Node + /// + /// Represents a node in a pathfinding algorithm, containing position, cost, and parent information. + /// + public class PathfindingNode(Point position, IMovement move) + { + internal Point Position { get; set; } = position; + internal float Distance { get; set; } = float.MaxValue; // Cost from start to this node. + internal float Total { get; set; } = float.MaxValue; // Total cost. + internal IMovement Move { get; set; } = move; + internal PathfindingNode Parent { get; set; } + + public override bool Equals(object obj) + { + if (obj is PathfindingNode other) + return Position == other.Position && Move.RegistrationName.Equals(other.Move.RegistrationName); + return false; + } + + public override int GetHashCode() => Position.GetHashCode() ^ Move.RegistrationName.GetHashCode(); + + internal IEnumerable GetNeighborSteps(IPathfinder pathfinder) + { + foreach (var movement in pathfinder.Movements) + { + foreach (var neighbor in movement.GetDestinations(Position)) + { + yield return new PathfindingNode(neighbor, movement); + } + } + } + + internal List ReconstructPath() + { + var path = new List(); + var current = this; + while (current != null) + { + path.Add(current); + current = current.Parent; + } + path.Reverse(); + return path; + } + } + #endregion + } + #endregion +} diff --git a/Physics/Rope.cs b/Physics/Rope.cs new file mode 100644 index 0000000000..746495c53a --- /dev/null +++ b/Physics/Rope.cs @@ -0,0 +1,229 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; + +namespace CalamityMod.Physics; + +internal class Rope +{ + /// + /// A 0-1 interpolant which dictates a dampning factor for velocity integration increments. + /// + private float MovementSpeedDampingCoefficient + { + get; + set; + } + + /// + /// A timer that increments in respond to wind, assuming wind response is enabled in the . + /// + private float WindTime + { + get; + set; + } + + /// + /// The set of segments that compose this rope. + /// + public RopeSegment[] Segments + { + get; + set; + } + + /// + /// The set of positions that compose this rope. + /// + public Vector2[] SegmentPositions + { + get; + private set; + } + + /// + /// The desired distance between each segment on the rope. + /// + public float DistancePerSegment + { + get; + set; + } + + /// + /// The gravity force to exert on the rope when updating. + /// + public Vector2 Gravity + { + get; + set; + } + + /// + /// The amount of steps to perform when constraining tiles to their desired lengths. Higher values equate to greater accuracy, but reduced performance. + /// + public int ConstraintSteps + { + get; + private set; + } + + /// + /// Sets of settings that dictate how this rope should behave. + /// + public RopeSettings Settings + { + get; + set; + } + + /// + /// Whether this rope should collide with tiles or not. + /// + public bool InteractWithTiles => Settings.TileColliderArea is not null; + + public Rope(Vector2 start, Vector2 end, int segmentCount, float distancePerSegment, Vector2 gravity, RopeSettings settings, int constraintSteps = 10) + { + Segments = new RopeSegment[segmentCount]; + SegmentPositions = new Vector2[segmentCount]; + for (var i = 0; i < segmentCount; i++) + { + var segmentPos = Vector2.Lerp(start, end, i / (segmentCount - 1f)); + Segments[i] = new RopeSegment(segmentPos); + } + + Segments[0].FixedInPlace = settings.StartIsFixed; + Segments[^1].FixedInPlace = settings.EndIsFixed; + RecalculateSegmentPositions(); + + DistancePerSegment = distancePerSegment; + Gravity = gravity; + ConstraintSteps = constraintSteps; + + Settings = settings; + } + + /// + /// Recalculates the cache based on positions. + /// + private void RecalculateSegmentPositions() + { + for (var i = 0; i < Segments.Length; i++) + SegmentPositions[i] = Segments[i].Position; + } + + /// + /// Moves a given position around, obeying tile interaction rules if this rope requires them. + /// + /// The position vector to move. + /// The base velocity to consider. + private void Move(ref Vector2 position, Vector2 baseVelocity) + { + // Apply standard Eulerian integration if tile interactions are not required. + if (!InteractWithTiles || Settings.TileColliderArea is null) + { + position += baseVelocity; + return; + } + + // If tile interactions *are* required, handle them before moving forward. + var width = (int)Settings.TileColliderArea.Value.X; + var height = (int)Settings.TileColliderArea.Value.Y; + var newVelocity = Collision.noSlopeCollision(position, baseVelocity, width, height + 2, true, true); + newVelocity = Collision.noSlopeCollision(position, newVelocity, width, height, true, true); + var finalVelocity = baseVelocity; + if (Math.Abs(baseVelocity.X) > Math.Abs(newVelocity.X)) + finalVelocity.X = 0f; + if (Math.Abs(baseVelocity.Y) > Math.Abs(newVelocity.Y)) + finalVelocity.Y = 0f; + + position += finalVelocity; + } + + /// + /// Updates this rope, making it move around. + /// + public void Update() + { + for (var i = 0; i < Segments.Length; i++) + { + var movementStep = (Segments[i].Position - Segments[i].OldPosition) * (1f - MovementSpeedDampingCoefficient); + if (movementStep.Length() < 0.02f) + movementStep = Vector2.Zero; + + Segments[i].OldPosition = Segments[i].Position; + + if (!Segments[i].FixedInPlace) + Move(ref Segments[i].Position, movementStep + Gravity); + } + + for (var i = 0; i < ConstraintSteps; i++) + Constrain(); + + RecalculateSegmentPositions(); + + if (Settings.RespondToEntityMovement) + HandleEntityMovementResponse(); + if (Settings.RespondToWind) + HandleWindResponse(); + } + + /// + /// Makes this rope respond to the movement of entities. + /// + private void HandleEntityMovementResponse() + { + for (var i = 0; i < Segments.Length; i++) + { + ref RopeSegment ropeSegment = ref Segments[i]; + if (ropeSegment.FixedInPlace) + continue; + + foreach (var player in Main.ActivePlayers) + { + float playerProximityInterpolant = Utils.GetLerpValue(37f, 10f, player.Distance(ropeSegment.Position), true); + ropeSegment.Position += player.velocity * playerProximityInterpolant / Settings.Mass * 0.08f; + } + } + } + + /// + /// Makes this entity respond to wind. + /// + private void HandleWindResponse() + { + WindTime += Main.windSpeedCurrent / 60f; + if (MathF.Abs(WindTime) >= 4000f) + WindTime = 0f; + + var windSpeed = Math.Clamp(Main.WindForVisuals * 2f, -1.3f, 1.3f); + var windWave = MathF.Cos(WindTime * 3.42f + Segments[0].Position.Length() * 0.06f); + var wind = Vector2.UnitX * (windWave + Main.windSpeedCurrent) * -0.2f; + + Segments[^1].Position += wind * Utils.GetLerpValue(0.3f, 0.75f, windSpeed, true) / Settings.Mass; + } + + /// + /// Constrains segments on this rope, conserving their overall length. + /// + public void Constrain() + { + for (var i = 0; i < Segments.Length - 1; i++) + { + // Determine how much each segment has to move in order to return to its desired resting distance. + var segmentLength = Segments[i].Position.Distance(Segments[i + 1].Position); + var distanceFromIdealLength = segmentLength - DistancePerSegment; + Vector2 correctiveForce = (Segments[i].Position - Segments[i + 1].Position).SafeNormalize(Vector2.Zero) * distanceFromIdealLength; + + var pinned = Segments[i].FixedInPlace; + var nextPinned = Segments[i + 1].FixedInPlace; + correctiveForce *= pinned || nextPinned ? 1f : 0.5f; + + if (!pinned) + Move(ref Segments[i].Position, -correctiveForce); + if (!nextPinned) + Move(ref Segments[i + 1].Position, correctiveForce); + } + } +} diff --git a/Physics/RopeHandle.cs b/Physics/RopeHandle.cs new file mode 100644 index 0000000000..4b5c03570f --- /dev/null +++ b/Physics/RopeHandle.cs @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Terraria.ModLoader; + +namespace CalamityMod.Physics; + +// Yes, I was silently reading over the Nightshade dev channels when learning about this. +// So, thanks Tomat and 1-3 for the idea! -Lucille +/// +/// A handle that contains a reference to a given globally managed rope instance. +/// +public readonly struct RopeHandle +{ + /// + /// The value used to identify this handle's associated rope managed by the central system. + /// + private readonly int Identifier; + + /// + /// The rope associated with this handle. + /// + private readonly Rope Rope => ModContent.GetInstance().Ropes[Identifier]!; + + /// + /// The set of all positions maintained by the underlying rope. + /// + public readonly IEnumerable Positions => Rope.SegmentPositions; + + /// + /// The amount of segments this rope has. + /// + public int SegmentCount => Rope.Segments.Length; + + /// + /// The starting position of the underlying rope. + /// + public ref Vector2 Start => ref Rope.Segments[0].Position; + + /// + /// The ending position of the underlying rope. + /// + public ref Vector2 End => ref Rope.Segments[^1].Position; + + /// + /// The gravity associated with the rope. + /// + public Vector2 Gravity + { + get => Rope.Gravity; + set => Rope.Gravity = value; + } + + internal RopeHandle(int identifier) => Identifier = identifier; + + /// + /// Forces this rope to settle by performing a series of constrained updates. + /// + public void Settle() + { + for (var i = 0; i < 20; i++) + Rope.Update(); + } + + /// + /// Indicates that the rope associated with this handle should be returned back to the pool. + /// + public void Dispose() + { + var chunkIndex = Identifier / RopeManagerSystem.BitsPerChunk; + var bitIndex = Identifier % RopeManagerSystem.BitsPerChunk; + ModContent.GetInstance().ToggleActivityIndex(chunkIndex, bitIndex); + } +} diff --git a/Physics/RopeManagerSystem.cs b/Physics/RopeManagerSystem.cs new file mode 100644 index 0000000000..0192cd3c48 --- /dev/null +++ b/Physics/RopeManagerSystem.cs @@ -0,0 +1,132 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria.ModLoader; +using BitOperations = System.Numerics.BitOperations; + +namespace CalamityMod.Physics; + +public sealed class RopeManagerSystem : ModSystem +{ + /// + /// The set of all maintained ropes in the world. + /// + internal readonly Rope[] Ropes = new Rope[MaxRopeCount]; + + /// + /// The internal binary mappings that determine whether ropes are active or not. + /// + internal readonly ulong[] ActivityBitChunks = new ulong[(int)Math.Ceiling((double)MaxRopeCount / BitsPerChunk)]; + + /// + /// The maximum amount of ropes to maintain across the world. + /// + public const int MaxRopeCount = 2048; + + /// + /// The amount of bits contained within each chunk in the array. + /// + public const int BitsPerChunk = sizeof(ulong) * 8; + + public override void ClearWorld() + { + for (var i = 0; i < ActivityBitChunks.Length; i++) + ActivityBitChunks[i] = 0uL; + } + + public override void PostUpdateWorld() + { + for (var i = 0; i < Ropes.Length; i++) + { + var bitIndex = i % BitsPerChunk; + var active = (ActivityBitChunks[i / BitsPerChunk] >> bitIndex & 1) == 1; + if (active) + Ropes[i].Update(); + } + } + + /// + /// Toggles a given activity index. + /// + /// The index of the to toggle. + /// The bit index in the chunk to toggle. + internal void ToggleActivityIndex(int chunkIndex, int bitIndex) => ActivityBitChunks[chunkIndex] ^= 1uL << bitIndex; + + /// + /// Attempts to find and return the first available index for a new rope. + /// + private int? SelectFirstAvailableIndex() + { + for (var i = 0; i < ActivityBitChunks.Length; i++) + { + // This comment can be deleted later if it's deemed a bit too verbose. I'm half doing it for myself to test my understanding, half doing it for any future readers who might + // not immediately understand what the bit operations do here. -Lucille + + // As a simplified example, assume the following for the activity bits, where zero means inactive and one means active: + // 0110 1111 + + // This means the first four indices are occupied, but the fifth index is free. Note that in this case bits are counted from right to left. + // In order to find the first new index, we simply need to count the amount of ones until the first zero. + // Conveniently, BitOperations.TrailingZeroCount exists for this purpose. We just need to invert the binary in order to convert the ones into zeroes. + var offset = BitOperations.TrailingZeroCount(~ActivityBitChunks[i]); + + // Check if the index offset is equal to the amount of bits in the chunk. + // If so, that means that every single bit is a one, and that there's no available index in the chunk to use. + var allBitsAreOccupied = offset == BitsPerChunk; + if (allBitsAreOccupied) + continue; + + return offset + i * BitsPerChunk; + } + + // No valid index found across the activity bit chunks. Return null. + return null; + } + + /// + /// Requests a new rope, returning a handle to it, or null if for some reason the rope couldn't be created. + /// + public RopeHandle? RequestNew(Vector2 start, Vector2 end, int segmentCount, float distancePerSegment, Vector2 gravity, RopeSettings settings, int constraintSteps = 10) + { + var index = SelectFirstAvailableIndex(); + if (index is null) + return null; + + // Mark the newly selected index as active by toggling its activity state on. + ToggleActivityIndex(index.Value / BitsPerChunk, index.Value % BitsPerChunk); + + Ropes[index.Value] = new Rope(start, end, segmentCount, distancePerSegment, gravity, settings, constraintSteps); + + return new RopeHandle(index.Value); + } + + /// + /// Calculates the overall segment length of a rope based on the horizontal span between its two end points and a desired sag distance. + /// + public static float CalculateSegmentLength(float ropeSpan, float sag, int iterations = 12) + { + // A rope at rest is defined via a catenary curve, which exists in the following mathematical form: + // y(x) = a * cosh(x / a) + + // Furthermore, the length of a rope, given the horizontal width w for a rope, is defined as follows: + // L = 2a * sinh(w / 2a) + + // In order to use the above equation, the value of a must be determined for the catenary that this rope will form. + // To do so, a numerical solution will need to be found based on the known width and sag values. + + // Suppose the two supports are at equal height at distances -w/2 and w/2. + // From this, sag (which will be denoted with h) can be defined in the following way: h = y(w/2) - y(0) + // Reducing this results in the following equation: + + // h = a(cosh(w / 2a) - 1) + // a(cosh(w / 2a) - 1) - h = 0 + // This can be used to numerically find a. + var initialGuessA = sag; + var a = (float)CalamityUtils.IterativelySearchForRoot(x => + { + return x * (Math.Cosh(ropeSpan / (x * 2D)) - 1D) - sag; + }, initialGuessA, iterations); + + // Now that a is known, it's just a matter of plugging it back into the original equation to find L. + return MathF.Sinh(ropeSpan / a * 0.5f) * a * 2f; + } +} diff --git a/Physics/RopeSegment.cs b/Physics/RopeSegment.cs new file mode 100644 index 0000000000..81cb8708de --- /dev/null +++ b/Physics/RopeSegment.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; + +namespace CalamityMod.Physics; + +/// +/// A representation of a rope segment, containing physical data such as position, velocity, etc., as well as a value which determines whether the rope is fixed in place and not subject to standard physics. +/// +public struct RopeSegment +{ + /// + /// The current position of this segment. + /// + public Vector2 Position; + + /// + /// The previous position of this segment. + /// + public Vector2 OldPosition; + + /// + /// Whether this segment is fixed in place and not subject to standard physics, such as gravity. + /// + public bool FixedInPlace; + + public RopeSegment(Vector2 position) + { + Position = position; + OldPosition = position; + } +} diff --git a/Physics/RopeSettings.cs b/Physics/RopeSettings.cs new file mode 100644 index 0000000000..133e1bc4f0 --- /dev/null +++ b/Physics/RopeSettings.cs @@ -0,0 +1,11 @@ +using Microsoft.Xna.Framework; + +namespace CalamityMod.Physics; + +public readonly record struct RopeSettings(bool StartIsFixed, bool EndIsFixed, bool RespondToEntityMovement, bool RespondToWind, Vector2? TileColliderArea, float Mass = 1f) +{ + public RopeSettings() : this(false, false, false, false, null, 1f) + { + + } +} diff --git a/Prefixes/AccessoryPrefix.cs b/Prefixes/AccessoryPrefix.cs new file mode 100644 index 0000000000..389f304da9 --- /dev/null +++ b/Prefixes/AccessoryPrefix.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes +{ + public class Invigorating : ModPrefix, ILocalizedModType + { + public new string LocalizationCategory => "Prefixes.Accessory"; + public override PrefixCategory Category => PrefixCategory.Accessory; + + public override void ApplyAccessoryEffects(Player player) + { + player.lifeRegen += GetLifeRegenAmount(); + } + + public override void ModifyValue(ref float valueMult) + { + valueMult = VanillaPrefixChange.RarityPlusOneButClosestToTierTwo; + } + + public LocalizedText LifeRegenTooltip => CalamityUtils.GetText($"{LocalizationCategory}.LifeRegenTooltip"); + public override IEnumerable GetTooltipLines(Item item) + { + var perSecHP = (GetLifeRegenAmount() / 2.0f).ToString("0.#"); + yield return new TooltipLine(Mod, "CalamityMod:PrefixLifeRegenBoost", LifeRegenTooltip.Format(perSecHP)) + { + IsModifier = true + }; + } + + public static int GetLifeRegenAmount() + { + return 1; + } + } + + public class Dauntless : ModPrefix, ILocalizedModType + { + public new string LocalizationCategory => "Prefixes.Accessory"; + public override PrefixCategory Category => PrefixCategory.Accessory; + + public override void ApplyAccessoryEffects(Player player) + { + player.statLifeMax2 += GetHealthBoostAmount(); + } + + public override void ModifyValue(ref float valueMult) + { + valueMult = VanillaPrefixChange.RarityPlusOneButClosestToTierTwo; + } + + public LocalizedText LifeBoostTooltip => CalamityUtils.GetText($"{LocalizationCategory}.MaxLifeBoostTooltip"); + public override IEnumerable GetTooltipLines(Item item) + { + yield return new TooltipLine(Mod, "CalamityMod:PrefixMaxLifeBoost", LifeBoostTooltip.Format(GetHealthBoostAmount())) + { + IsModifier = true + }; + } + + public static int GetHealthBoostAmount() + { + return 15; + } + } +} diff --git a/Prefixes/ReforgeChange.cs b/Prefixes/ReforgeChange.cs new file mode 100644 index 0000000000..f76274b5e9 --- /dev/null +++ b/Prefixes/ReforgeChange.cs @@ -0,0 +1,302 @@ +using System.Linq; +using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Packets; +using CalamityMod.World; +using Terraria; +using Terraria.GameContent.Prefixes; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; + +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Prefixes +{ + public sealed class ReforgeChange : GlobalItem + { + public override bool InstancePerEntity => false; + + // Ozzatron 31AUG2022: total rework to the reforge rework for mod compatibility + // you can now disable the rework with config in case it isn't enough to solve your conflicts + // removed data saved on items; reforging is now a coalescing flowchart that has no RNG + private static int storedPrefix = -1; + public override void PreReforge(Item item) + { + storedPrefix = item.prefix; + } + + public override int ChoosePrefix(Item item, UnifiedRandom rand) + { + if (storedPrefix == -1 && item.CountsAsClass() && (item.maxStack == 1 || item.AllowReforgeForStackableItem)) + { + // Crafting (or first reforge of) a rogue weapon has a 75% chance for a random modifier, this check is done by vanilla + // Negative modifiers have a 66.66% chance of being voided, Annoying modifier is intentionally ignored by vanilla + int prefix = CalamityUtils.RandomRoguePrefix(); + bool keepPrefix = !CalamityUtils.NegativeRoguePrefix(prefix) || Main.rand.NextBool(3); + return keepPrefix ? prefix : 0; + } + + if (Main.gameMenu) + return -1; + + if (item.accessory && CalamityServerConfig.Instance.SimplifyAccessoryReforge) + { + return GetSimplifiedAccessoryReforge(item, rand, storedPrefix); + } + else if (storedPrefix != -1 && CalamityServerConfig.Instance.RemoveReforgeRNG) + { + return GetReworkedReforge(item, rand, storedPrefix); + } + + return -1; + } + + public override void PostReforge(Item item) + { + storedPrefix = -1; + + // Bandit steals 20% of the total price of the reforge if she's around. + if (NPC.AnyNPCs(NPCType())) + { + // Calculate the item's reforge cost. + int value = item.value; + Player p = Main.LocalPlayer; + ItemLoader.ReforgePrice(item, ref value, ref p.discountAvailable); + + // Steal 20% of that money. + int stolen = value / 5; + CalamityWorld.MoneyStolenByBandit += stolen; + + // Increment the reforge counter to allow the Bandit to refund + // Also triggers Tinkerer dialogue that hints to the player that money is being stolen + CalamityWorld.Reforges++; + + if (Main.netMode == NetmodeID.MultiplayerClient) + { + BanditStolenMoneySyncPacket.Send(stolen); + } + } + } + + #region Prefix Definition + public static int[] SimplifiedAccessoryPrefixes = + [ + PrefixID.Warding, + PrefixID.Menacing, + PrefixID.Lucky, + PrefixID.Quick2, + PrefixID.Violent, + PrefixID.Arcane, + PrefixType(), + PrefixType(), + PrefixType() + ]; + + public static int[][] AccessoryPrefixTiers = + [ + /* 0 */ [PrefixID.Hard, PrefixID.Jagged, PrefixID.Brisk, PrefixID.Wild], + /* 1 */ [PrefixID.Guarding, PrefixID.Spiked, PrefixID.Precise, PrefixID.Fleeting, PrefixID.Rash], + /* 2 */ [PrefixID.Armored, PrefixID.Angry, PrefixID.Hasty2, PrefixID.Intrepid, PrefixID.Arcane], + /* 3 */ [PrefixID.Warding, PrefixID.Menacing, PrefixID.Lucky, PrefixID.Quick2, PrefixID.Violent, PrefixType(), PrefixType(), PrefixType()], + ]; + + public static int[][] TerrarianPrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous], + /* 2 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Godly], + /* 3 */ [PrefixID.Legendary2], + ]; + + public static int[][] MeleePrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Light, PrefixID.Heavy, PrefixID.Light, PrefixID.Forceful, PrefixID.Strong], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky], + /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp], + /* 3 */ [PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior], + /* 4 */ [PrefixID.Demonic, PrefixID.Deadly2, PrefixID.Godly], + /* 5 */ [PrefixID.Legendary] // for non-tools, Light is a mediocre low-tier reforge + ]; + + public static int[][] MeleeNoSpeedPrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous], + /* 2 */ [PrefixID.Superior, PrefixID.Demonic], + /* 3 */ [PrefixID.Godly] + ]; + + // 14MAR2025: Ozzatron: Add support for allowing Ruthless over Godly if the player has more than 100% crit chance of the appropriate class + public static int[][] MeleeNoSpeedAlwaysCritPrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous], + /* 2 */ [PrefixID.Superior, PrefixID.Demonic], + /* 3 */ [PrefixID.Godly, PrefixID.Ruthless] + ]; + + public static int[][] ToolPrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Heavy, PrefixID.Forceful, PrefixID.Strong], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky], + /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp], + /* 3 */ [PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior], + /* 4 */ [PrefixID.Demonic, PrefixID.Deadly2, PrefixID.Godly], + /* 5 */ [PrefixID.Legendary, PrefixID.Light] // for some tools, light is better than legendary. for others, it's equal + ]; + + public static int[][] RangedPrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Powerful, PrefixID.Forceful, PrefixID.Strong], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Intimidating], + /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Hasty, PrefixID.Staunch, PrefixID.Unpleasant], + /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Sighted], + /* 4 */ [PrefixID.Godly, PrefixID.Rapid, /* ranged Deadly */ PrefixID.Deadly, /* universal Deadly */ PrefixID.Deadly2], + /* 5 */ [PrefixID.Unreal] + ]; + + public static int[][] MagicPrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Furious, PrefixID.Forceful, PrefixID.Strong], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Taboo, PrefixID.Manic], + /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Adept, PrefixID.Celestial, PrefixID.Unpleasant], + /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Mystic], + /* 4 */ [PrefixID.Godly, PrefixID.Masterful, PrefixID.Deadly2], + /* 5 */ [PrefixID.Mythical] + ]; + + public static int[][] SummonPrefixTiers = + [ + /* 0 */ [PrefixID.Nimble, PrefixID.Furious], + /* 1 */ [PrefixID.Forceful, PrefixID.Strong, PrefixID.Quick, PrefixID.Taboo, PrefixID.Manic], + /* 2 */ [PrefixID.Hurtful, PrefixID.Adept, PrefixID.Celestial], + /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Mystic, PrefixID.Deadly2], + /* 4 */ [PrefixID.Masterful, PrefixID.Godly], + /* 5 */ [PrefixID.Mythical, PrefixID.Ruthless] // you may want mythical early game for the knockback. + ]; + + // Added appropriate universal reforges to rogue, so they don't ONLY get modded prefixes. + public static int[][] RoguePrefixTiers = + [ + /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Forceful, PrefixID.Strong, PrefixType(), PrefixType()], + /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixType(), PrefixType()], + /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Unpleasant, PrefixType(), PrefixType(), PrefixType()], + /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixType(), PrefixType()], + /* 4 */ [PrefixID.Godly, PrefixID.Deadly2, PrefixType(), PrefixType()], + /* 5 */ [PrefixType()] + ]; + #endregion + + #region Reworked Reforge + internal static int GetReworkedReforge(Item item, UnifiedRandom rand, int currentPrefix) + { + // This is the hardcoded value to "do nothing", and is thus the default choice. + int prefix = -1; + bool supportsLegendary = PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] || (item.ModItem != null && item.ModItem.MeleePrefix()); + + // ACCESSORIES + if (item.accessory) + { + int accRerolls = 0; + // Try to prevent the player from rolling the same modifier twice + do + { + int newPrefix = IteratePrefix(rand, AccessoryPrefixTiers, currentPrefix); + if (newPrefix != currentPrefix) + { + prefix = newPrefix; + break; + } + accRerolls++; + } while (accRerolls < 20); + } + + // MELEE (includes tools and whips) + // Melee-ranged hybrid weapons prioritize Legendary if available, otherwise go for Unreal + else if ((item.CountsAsClass() || item.CountsAsClass()) && !(item.CountsAsClass() && !supportsLegendary)) + { + // Terrarian (has its own special "Legendary" for marketing reasons) + // Other items that want to use Legendary2 are also compatible + if (PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2[item.type]) + { + prefix = IteratePrefix(rand, TerrarianPrefixTiers, currentPrefix); + } + + // Swords, Whips, Tools, other items that support the Legendary modifier + else if (supportsLegendary) + { + var tierListToUse = (item.pick > 0 || item.axe > 0 || item.hammer > 0) ? ToolPrefixTiers : MeleePrefixTiers; + prefix = IteratePrefix(rand, tierListToUse, currentPrefix); + } + + // Yoyos, Flails, Spears, etc. + // Spears actually work fine with Legendary, but vanilla doesn't give it to them, so we won't either. + else + { + bool has100Crit = Main.LocalPlayer.GetTotalCritChance(item.DamageType) >= 100; + prefix = IteratePrefix(rand, has100Crit ? MeleeNoSpeedAlwaysCritPrefixTiers : MeleeNoSpeedPrefixTiers, currentPrefix); + } + } + + // RANGED + else if (item.CountsAsClass()) + { + prefix = IteratePrefix(rand, RangedPrefixTiers, currentPrefix); + } + + // MAGIC + else if (item.CountsAsClass() || item.CountsAsClass()) + { + prefix = IteratePrefix(rand, MagicPrefixTiers, currentPrefix); + } + + // SUMMON (not whips) + else if (item.CountsAsClass()) + { + prefix = IteratePrefix(rand, SummonPrefixTiers, currentPrefix); + } + + // ROGUE (Calamity adds these reforges to all 1.4 TML throwing items) + else if (item.CountsAsClass()) + { + prefix = IteratePrefix(rand, RoguePrefixTiers, currentPrefix); + } + + return prefix; + } + + private static int GetPrefixTier(int[][] tiers, int currentPrefix) + { + for (int checkingTier = 0; checkingTier < tiers.Length; ++checkingTier) + { + int[] tierList = tiers[checkingTier]; + for (int i = 0; i < tierList.Length; ++i) + if (tierList[i] == currentPrefix) + return checkingTier; + } + + // If an invalid or modded prefix is detected, return -1. + // This will give a random tier 0 prefix (the "next tier"), starting fresh with a low-tier vanilla or Calamity prefix. + return -1; + } + + private static int IteratePrefix(UnifiedRandom rand, int[][] reforgeTiers, int currentPrefix) + { + int currentTier = GetPrefixTier(reforgeTiers, currentPrefix); + + // If max tier: give max tier reforges forever + // Otherwise: go up by 1 tier with every reforge, guaranteed + int newTier = currentTier == reforgeTiers.Length - 1 ? currentTier : currentTier + 1; + return rand.Next(reforgeTiers[newTier]); + } + #endregion + + #region Simplified Accessory Reforge + internal static int GetSimplifiedAccessoryReforge(Item item, UnifiedRandom rand, int currentPrefix) + { + var pool = SimplifiedAccessoryPrefixes.Where(id => id != currentPrefix); + return pool.ElementAt(rand.Next(0, pool.Count())); + } + #endregion + } +} diff --git a/Prefixes/RogueAccessoryPrefix.cs b/Prefixes/RogueAccessoryPrefix.cs index 1c0ceb2a34..c47a79cd3b 100644 --- a/Prefixes/RogueAccessoryPrefix.cs +++ b/Prefixes/RogueAccessoryPrefix.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges; using Terraria; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Prefixes { - [LegacyName("CloakedPrefix", "QuietPrefix")] - public class Cloaked : RogueAccessoryPrefix - { - public override float stealthGenBonus => 0.04f; - } - - [LegacyName("SilentPrefix", "CamouflagedPrefix")] + [LegacyName("Cloaked", "CloakedPrefix", "QuietPrefix", "SilentPrefix", "CamouflagedPrefix")] public class Silent : RogueAccessoryPrefix { public override float stealthGenBonus => 0.08f; @@ -36,11 +29,11 @@ namespace CalamityMod.Prefixes player.Calamity().accStealthGenBoost += stealthGenBonus; } - // Changing value based on prefix tier (rarity is set automatically around value multiplier) public override void ModifyValue(ref float valueMult) { - float extraValue = 1f + (2.5f * stealthGenBonus); - valueMult *= extraValue; + //float extraValue = 1f + (2.5f * stealthGenBonus); + //valueMult *= extraValue; + valueMult = VanillaPrefixChange.RarityPlusOneButClosestToTierTwo; } // Extra tooltip for new modifier stats diff --git a/Prefixes/RogueWeaponPrefix.cs b/Prefixes/RogueWeaponPrefix.cs index ed81c1cf8d..0298790b1d 100644 --- a/Prefixes/RogueWeaponPrefix.cs +++ b/Prefixes/RogueWeaponPrefix.cs @@ -1,5 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using CalamityMod.Items; using Terraria; using Terraria.Localization; using Terraria.ModLoader; @@ -154,8 +154,8 @@ namespace CalamityMod.Prefixes // Applying stealth strike damage public override void Apply(Item item) { - if (item.CountsAsClass()) - item.Calamity().StealthStrikePrefixBonus = stealthDmgMult; + if (item.CountsAsClass() && item.TryGetGlobalItem(out var rogueItem)) + rogueItem.StealthStrikePrefixBonus = stealthDmgMult; } // Changing value based on prefix tier (rarity is set automatically around value multiplier) diff --git a/Prefixes/VanillaPrefixChanges/CritChancePrefixChanges.cs b/Prefixes/VanillaPrefixChanges/CritChancePrefixChanges.cs new file mode 100644 index 0000000000..8b5f352f2a --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/CritChancePrefixChanges.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges.Stats; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public class PrecisePrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Precise; + public override string TargetTooltipName => "PrefixAccCritChance"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixCritChanceStat(2); + + if (NPC.downedMoonlord) + { + yield return new PrefixArmorPenStat(3); + } + else if (Main.hardMode) + { + yield return new PrefixArmorPenStat(2); + } + else + { + yield return new PrefixArmorPenStat(1); + } + } + } + + public class LuckyPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Lucky; + public override string TargetTooltipName => "PrefixAccCritChance"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixCritChanceStat(4); + yield return new PrefixLuckStat(0.05f); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/DamagePrefixChanges.cs b/Prefixes/VanillaPrefixChanges/DamagePrefixChanges.cs new file mode 100644 index 0000000000..f868c628e0 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/DamagePrefixChanges.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges.Stats; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public class JaggedPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Jagged; + public override string TargetTooltipName => "PrefixAccDamage"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDamageStat(0.02f); + + if (NPC.downedMoonlord) yield return new PrefixArmorPenStat(3); + else if (Main.hardMode) yield return new PrefixArmorPenStat(2); + else yield return new PrefixArmorPenStat(1); + } + } + + public class SpikedPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Spiked; + public override string TargetTooltipName => "PrefixAccDamage"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDamageStat(0.02f); + yield return new PrefixDefenseStat(2); + } + } + + public class AngryPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Angry; + public override string TargetTooltipName => "PrefixAccDamage"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDamageStat(0.02f); + yield return new PrefixCritChanceStat(2); + } + } + + public class MenacingPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Menacing; + public override string TargetTooltipName => "PrefixAccDamage"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDamageStat(0.04f); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/DefensePrefixChanges.cs b/Prefixes/VanillaPrefixChanges/DefensePrefixChanges.cs new file mode 100644 index 0000000000..8d7d538926 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/DefensePrefixChanges.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges.Stats; +using Terraria.ID; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public class HardPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Hard; + public override string TargetTooltipName => "PrefixAccDefense"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDefenseStat(5); + } + } + + public class GuardingsPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Guarding; + public override string TargetTooltipName => "PrefixAccDefense"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDefenseStat(2); + yield return new PrefixMovementSpeedStat(0.02f); + } + } + + public class ArmoredPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Armored; + public override string TargetTooltipName => "PrefixAccDefense"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDefenseStat(2); + yield return new PrefixDRStat(0.015f); + } + } + + public class WardingPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Warding; + public override string TargetTooltipName => "PrefixAccDefense"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixDefenseStat(4); + yield return new PrefixDRStat(0.01f); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/MaxManaPrefixChanges.cs b/Prefixes/VanillaPrefixChanges/MaxManaPrefixChanges.cs new file mode 100644 index 0000000000..13a64028d9 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/MaxManaPrefixChanges.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges.Stats; +using Terraria.ID; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public class ArcanePrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Arcane; + public override string TargetTooltipName => "PrefixAccMaxMana"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixArcaneStat(maxManaBonus: 20, magicDamageBonus: 0.02f, manaCostReductionBonus: 0.02f); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/MeleeSpeedPrefixChanges.cs b/Prefixes/VanillaPrefixChanges/MeleeSpeedPrefixChanges.cs new file mode 100644 index 0000000000..889bf5ae1b --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/MeleeSpeedPrefixChanges.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges.Stats; +using Terraria.ID; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public class WildPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Wild; + public override string TargetTooltipName => "PrefixAccMeleeSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMeleeSpeedStat(0.02f); + yield return new PrefixDamageStat(0.02f); + } + } + + public class RashPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Rash; + public override string TargetTooltipName => "PrefixAccMeleeSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMeleeSpeedStat(0.02f); + yield return new PrefixCritChanceStat(2); + } + } + + public class IntrepidPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Intrepid; + public override string TargetTooltipName => "PrefixAccMeleeSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMeleeSpeedStat(0.02f); + yield return new PrefixMovementSpeedStat(0.02f); + } + } + + public class ViolentPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Violent; + public override string TargetTooltipName => "PrefixAccMeleeSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMeleeSpeedStat(0.04f); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/SpeedPrefixChanges.cs b/Prefixes/VanillaPrefixChanges/SpeedPrefixChanges.cs new file mode 100644 index 0000000000..6d0a25d74d --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/SpeedPrefixChanges.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges.Stats; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public class BriskPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Brisk; + public override string TargetTooltipName => "PrefixAccMoveSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMovementSpeedStat(0.02f); + + if (NPC.downedMoonlord) yield return new PrefixArmorPenStat(3); + else if (Main.hardMode) yield return new PrefixArmorPenStat(2); + else yield return new PrefixArmorPenStat(1); + } + } + + public class FleetingPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Fleeting; + public override string TargetTooltipName => "PrefixAccMoveSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMovementSpeedStat(0.02f); + yield return new PrefixDamageStat(0.02f); + } + } + + public class HastyPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Hasty2; + public override string TargetTooltipName => "PrefixAccMoveSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMovementSpeedStat(0.02f); + yield return new PrefixCritChanceStat(2); + } + } + + public class QuickPrefixChange : VanillaPrefixChange + { + public override int TargetPrefix => PrefixID.Quick2; + public override string TargetTooltipName => "PrefixAccMoveSpeed"; + + public override IEnumerator PopulateStats() + { + yield return new PrefixMovementSpeedStat(0.04f); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/IVanillaPrefixStat.cs b/Prefixes/VanillaPrefixChanges/Stats/IVanillaPrefixStat.cs new file mode 100644 index 0000000000..40d9a57fa4 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/IVanillaPrefixStat.cs @@ -0,0 +1,11 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public interface IVanillaPrefixStat + { + public abstract void ApplyEffects(Player player); + public abstract void ModifyTooltip(TooltipLine line); + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixArcaneStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixArcaneStat.cs new file mode 100644 index 0000000000..55645f86b5 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixArcaneStat.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixArcaneStat(int maxManaBonus, float magicDamageBonus, float manaCostReductionBonus) : IVanillaPrefixStat + { + public int MaxManaBonus = maxManaBonus; + public float MagicDamageBonus = magicDamageBonus; + public float ManaCostReductionBonus = manaCostReductionBonus; + + public readonly void ApplyEffects(Player player) + { + player.statManaMax2 += MaxManaBonus; + player.GetDamage() += MagicDamageBonus; + player.manaCost -= ManaCostReductionBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetArcaneBuffString(MaxManaBonus, MagicDamageBonus, ManaCostReductionBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixArmorPenStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixArmorPenStat.cs new file mode 100644 index 0000000000..2789aab144 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixArmorPenStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixArmorPenStat(int armorPenBonus) : IVanillaPrefixStat + { + public int ArmorPenBonus = armorPenBonus; + + public readonly void ApplyEffects(Player player) + { + player.GetArmorPenetration() += ArmorPenBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetArmorPenString(ArmorPenBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixCritChanceStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixCritChanceStat.cs new file mode 100644 index 0000000000..1d7e11d7d3 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixCritChanceStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixCritChanceStat(int critChanceBonus) : IVanillaPrefixStat + { + public int CritChanceBonus = critChanceBonus; + + public readonly void ApplyEffects(Player player) + { + player.GetCritChance() += CritChanceBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetCritChanceString(CritChanceBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixDRStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixDRStat.cs new file mode 100644 index 0000000000..37945c35d4 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixDRStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixDRStat(float DRbonus) : IVanillaPrefixStat + { + public float DRBouns = DRbonus; + + public readonly void ApplyEffects(Player player) + { + player.endurance += DRBouns; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetDamageReductionString(DRBouns); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixDamageStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixDamageStat.cs new file mode 100644 index 0000000000..620a02807d --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixDamageStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixDamageStat(float damageBonus) : IVanillaPrefixStat + { + public float DamageBonus = damageBonus; + + public readonly void ApplyEffects(Player player) + { + player.GetDamage() += DamageBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetDamageString(DamageBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixDefenseStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixDefenseStat.cs new file mode 100644 index 0000000000..ef40fb7d6f --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixDefenseStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixDefenseStat(int defenseBonus) : IVanillaPrefixStat + { + public int DefenseBonus = defenseBonus; + + public readonly void ApplyEffects(Player player) + { + player.statDefense += DefenseBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetDefenseString(DefenseBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixLuckStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixLuckStat.cs new file mode 100644 index 0000000000..fd2ffc3cc6 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixLuckStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixLuckStat(float luckBonus) : IVanillaPrefixStat + { + public float LuckBonus = luckBonus; + + public readonly void ApplyEffects(Player player) + { + player.Calamity().calamityBonusLuck += LuckBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetLuckString(LuckBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixMeleeSpeedStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixMeleeSpeedStat.cs new file mode 100644 index 0000000000..6ba52cb541 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixMeleeSpeedStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixMeleeSpeedStat(float meleeSpeedBonus) : IVanillaPrefixStat + { + public float MeleeSpeedBonus = meleeSpeedBonus; + + public readonly void ApplyEffects(Player player) + { + player.GetAttackSpeed() += MeleeSpeedBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetMeleeSpeedString(MeleeSpeedBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/Stats/PrefixMovementSpeedStat.cs b/Prefixes/VanillaPrefixChanges/Stats/PrefixMovementSpeedStat.cs new file mode 100644 index 0000000000..511469fcfd --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/Stats/PrefixMovementSpeedStat.cs @@ -0,0 +1,20 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges.Stats +{ + public struct PrefixMovementSpeedStat(float movementSpeedBonus) : IVanillaPrefixStat + { + public float MovementSpeedBonus = movementSpeedBonus; + + public readonly void ApplyEffects(Player player) + { + player.moveSpeed += MovementSpeedBonus; + } + + public readonly void ModifyTooltip(TooltipLine line) + { + line.Text += "\n" + VanillaPrefixChange.GetMoveSpeedString(MovementSpeedBonus); + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/VanillaPrefixChange.cs b/Prefixes/VanillaPrefixChanges/VanillaPrefixChange.cs new file mode 100644 index 0000000000..dee623e42d --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/VanillaPrefixChange.cs @@ -0,0 +1,90 @@ + +using System.Collections.Generic; +using CalamityMod.Prefixes.VanillaPrefixChanges.Stats; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public abstract class VanillaPrefixChange : ILoadable + { + public abstract int TargetPrefix { get; } + public abstract string TargetTooltipName { get; } + + public const float RarityPlusTwo = 1.2f + 0.001f; // Precision Errors... + public const float RarityPlusOne = 1.05f + 0.001f; + public const float RarityKeep = 1.0f; + public const float RarityMinusOne = 0.95f - 0.001f; + public const float RarityMinusTwo = 0.8f - 0.001f; + public const float RarityPlusOneButClosestToTierTwo = 1.199f; + + public abstract IEnumerator PopulateStats(); + + public virtual void ModifyValue(ref float valueMult) + { + valueMult = RarityPlusOneButClosestToTierTwo; + } + + public virtual void PostApplyEffects(Player player) { } + public virtual void PostModifyTooltip(TooltipLine line) { } + + public static LocalizedText GetStatTooltip(string key) => CalamityUtils.GetText($"Vanilla.PrefixTooltip.{key}"); + public static LocalizedText GetLuckyPrefixAddedTooltip() => CalamityUtils.GetText($"Vanilla.AddedTooltip.LuckyPrefix"); + + public static string GetArcaneBuffString(int maxManaBonus, float magicDamageBonus, float manaCostReductionBonus) + { + return GetStatTooltip("ArcaneBuffStat").Format(maxManaBonus, magicDamageBonus.ToPercent(), manaCostReductionBonus.ToPercent()); + } + + public static string GetArmorPenString(int armorPen) + { + return GetStatTooltip("ArmorPenStat").Format(armorPen); + } + + public static string GetCritChanceString(int critChance) + { + return GetStatTooltip("CritStat").Format(critChance); + } + + public static string GetDamageString(float damageP) + { + return GetStatTooltip("DamageStat").Format(damageP.ToPercent()); + } + + public static string GetDefenseString(int defense) + { + return GetStatTooltip("DefenseStat").Format(defense); + } + + public static string GetDamageReductionString(float DR) + { + return GetStatTooltip("DRStat").Format(DR.ToPercent()); + } + + public static string GetLuckString(float luckBonus) + { + return GetStatTooltip("LuckStat").Format(luckBonus); + } + + public static string GetMeleeSpeedString(float meleeSpeedP) + { + return GetStatTooltip("MeleeSpeedStat").Format(meleeSpeedP.ToPercent()); + } + + public static string GetMoveSpeedString(float speedP) + { + return GetStatTooltip("SpeedStat").Format(speedP.ToPercent()); + } + + public void Load(Mod mod) + { + VanillaPrefixChangeSystem.PrefixChanges[TargetPrefix] = this; + } + + public void Unload() + { + // Nothing to do here + } + } +} diff --git a/Prefixes/VanillaPrefixChanges/VanillaPrefixChangeSystem.cs b/Prefixes/VanillaPrefixChanges/VanillaPrefixChangeSystem.cs new file mode 100644 index 0000000000..9f87e0f1e2 --- /dev/null +++ b/Prefixes/VanillaPrefixChanges/VanillaPrefixChangeSystem.cs @@ -0,0 +1,120 @@ +using System.Collections.Generic; +using System.Linq; +using MonoMod.Cil; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Prefixes.VanillaPrefixChanges +{ + public sealed class VanillaPrefixChangeSystem : ModSystem + { + public static bool PrefixReworkEnabled = true; + + public static readonly Dictionary PrefixChanges = []; + + public override void Load() + { + On_Player.GrantPrefixBenefits += OnGrantBenefits; + IL_Item.Prefix += VanillaPrefixValueOverride; + } + + public override void Unload() + { + PrefixChanges.Clear(); + } + + private void VanillaPrefixValueOverride(ILContext il) + { + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(x => x.MatchCallOrCallvirt(nameof(ModPrefix.ModifyValue)))) + { + CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate callvirt (ModPrefix.ModifyValue)"); + return; + } + + if (!cursor.Prev.MatchLdloca(out var multLocaIdx)) + { + CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate Ldloca (mult)"); + return; + } + + if (!cursor.TryGotoPrev(x => x.MatchLdsfld(nameof(PrefixID.Count)))) + { + CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate Ldsfld (PrefixID.Count)"); + return; + } + + if (!cursor.Prev.MatchLdloc(out var prefixLocaIdx)) + { + CalamityMod.Log.ILFailure("Vanilla Prefix Override", "Unable to locate Ldloc (prefix)"); + return; + } + + cursor.GotoPrev(MoveType.AfterLabel); // Emit next to label + cursor.EmitLdloc(prefixLocaIdx); // push prefixID + cursor.EmitLdloca(multLocaIdx); // push &valueMult + cursor.EmitDelegate((int prefixID, ref float value) => + { + if (!PrefixReworkEnabled) + return; + + if (PrefixChanges.TryGetValue(prefixID, out var prefixChange)) + { + prefixChange.ModifyValue(ref value); + } + }); + } + + private void OnGrantBenefits(On_Player.orig_GrantPrefixBenefits orig, Player self, Item item) + { + if (!PrefixReworkEnabled) + { + orig(self, item); + } + else if (PrefixChanges.TryGetValue(item.prefix, out var prefixChange)) + { + var stats = prefixChange.PopulateStats(); + while (stats.MoveNext()) + { + var stat = stats.Current; + stat.ApplyEffects(self); + } + prefixChange.PostApplyEffects(self); + } + else + { + orig(self, item); + } + } + + public sealed class VanillaPrefixChangeTooltipModify : GlobalItem + { + public override bool InstancePerEntity => false; + + public override void ModifyTooltips(Item item, List tooltips) + { + if (!PrefixReworkEnabled) + return; + + if (!PrefixChanges.TryGetValue(item.prefix, out var change)) + return; + + var tooltip = tooltips.FirstOrDefault(x => x.Name.Equals(change.TargetTooltipName)); + if (tooltip == null) + return; + + tooltip.Text = string.Empty; + + var stats = change.PopulateStats(); + while (stats.MoveNext()) + { + var stat = stats.Current; + stat.ModifyTooltip(tooltip); + } + change.PostModifyTooltip(tooltip); + tooltip.Text = tooltip.Text.Trim(); + } + } + } +} diff --git a/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs b/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs index 6e413c3fd5..aea1ac75f1 100644 --- a/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseCustomUseStyleProjectile.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -265,20 +264,17 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void ModifyDamageHitbox(ref Rectangle hitbox) { Vector2 cen = Projectile.Center + new Vector2(HitboxOutset, 0).RotatedBy(FinalRotation + HitboxRotationOffset); - hitbox = new Rectangle((int)cen.X - (int)(HitboxSize.X / 2), (int)cen.Y - (int)(HitboxSize.Y / 2), (int)HitboxSize.X, (int)HitboxSize.Y); - if (false) // Turn this on to show the hitbox, useful for testing if it's working how you want - { - Particle blastRing = new CustomPulse(hitbox.TopLeft(), Vector2.Zero, Color.Red, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); - GeneralParticleHandler.SpawnParticle(blastRing); - Particle blastRing2 = new CustomPulse(hitbox.TopRight(), Vector2.Zero, Color.Gold, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); - GeneralParticleHandler.SpawnParticle(blastRing2); - Particle blastRing3 = new CustomPulse(hitbox.BottomLeft(), Vector2.Zero, Color.Green, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); - GeneralParticleHandler.SpawnParticle(blastRing3); - Particle blastRing4 = new CustomPulse(hitbox.BottomRight(), Vector2.Zero, Color.Cyan, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); - GeneralParticleHandler.SpawnParticle(blastRing4); - } + // Turn this on to show the hitbox, useful for testing if it's working how you want + /*Particle blastRing = new CustomPulse(hitbox.TopLeft(), Vector2.Zero, Color.Red, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(hitbox.TopRight(), Vector2.Zero, Color.Gold, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing3 = new CustomPulse(hitbox.BottomLeft(), Vector2.Zero, Color.Green, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); + GeneralParticleHandler.SpawnParticle(blastRing3); + Particle blastRing4 = new CustomPulse(hitbox.BottomRight(), Vector2.Zero, Color.Cyan, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f, 0.2f, 4); + GeneralParticleHandler.SpawnParticle(blastRing4);*/ base.ModifyDamageHitbox(ref hitbox); } diff --git a/Projectiles/BaseProjectiles/BaseFlailProjectile.cs b/Projectiles/BaseProjectiles/BaseFlailProjectile.cs new file mode 100644 index 0000000000..82541f3ab7 --- /dev/null +++ b/Projectiles/BaseProjectiles/BaseFlailProjectile.cs @@ -0,0 +1,316 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Enums; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.BaseProjectiles +{ + public abstract class BaseFlailProjectile : ModProjectile + { + // This class by default uses the values in the Mourningstar projectile + // Note: the original solar eruption code uses hide and player.heldProj. + // These two combined will prevent the second version of the whip from being drawn. + + public virtual void Behavior() + { + Player player = Main.player[Projectile.owner]; + if (Projectile.localAI[1] > 0f) + { + Projectile.localAI[1] -= 1f; + } + // Rapidly appear + Projectile.alpha -= 42; + if (Projectile.alpha < 0) + { + Projectile.alpha = 0; + } + // Determine the starting velocity direction + if (Projectile.localAI[0] == 0f) + { + Projectile.localAI[0] = Projectile.velocity.ToRotation(); + } + float direction = (Projectile.localAI[0].ToRotationVector2().X >= 0f).ToDirectionInt(); + if (Projectile.ai[1] <= 0f) + { + direction *= -1f; + } + // As ai[0], the timer, goes up, + Vector2 velocityAdditive = (direction * (Projectile.ai[0] / 30f * MathHelper.TwoPi - MathHelper.PiOver2)).ToRotationVector2(); + + // ai[1] = A starting rotation value. With a min of 0 and a max of pi/4 + // The larger it is, the larger the outward distance we travel. + // It will always be compressed a bit relative to the X travel movement, however, + // because sin(pi/4) = 1/sqrt(2), which is less than the default multiplier the X distance + // receives: 1. + velocityAdditive.Y *= (float)Math.Sin(Projectile.ai[1]); + if (Projectile.ai[1] <= 0f) + { + velocityAdditive.Y *= -1f; + } + // Rotate by the starting velocity angle, to maintain the original rotation instead of + // Constantly rotating upward or sideways + velocityAdditive = velocityAdditive.RotatedBy(Projectile.localAI[0]); + Projectile.ai[0] += 1f; + if (Projectile.ai[0] < 30f) + { + Projectile.velocity += 48f * velocityAdditive; + } + else + { + Projectile.Kill(); + } + // Adjust position so that we're always sticking to the player. + Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Projectile.spriteDirection = Projectile.direction; + Projectile.timeLeft = 2; + player.ChangeDir(Projectile.direction); + player.itemTime = 2; + player.itemAnimation = 2; + player.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + + // Adjust the center based on player attributes. + Vector2 centerDelta = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f; + if (player.direction != 1) + { + centerDelta.X = player.bodyFrame.Width - centerDelta.X; + } + if (player.gravDir != 1f) + { + centerDelta.Y = player.bodyFrame.Height - centerDelta.Y; + } + if (player.heldProj == -1) + player.heldProj = Projectile.whoAmI; + centerDelta -= new Vector2(player.bodyFrame.Width - player.width, player.bodyFrame.Height - 42) / 2f; + Projectile.Center = player.RotatedRelativePoint(player.position + centerDelta, true) - Projectile.velocity; + + // Cool dust + if (Projectile.alpha == 0) + { + GenerateDust(); + } + } + public virtual void ExtraBehavior() + { + + } + public override void AI() + { + Behavior(); + ExtraBehavior(); + } + public Texture2D FlailTexture => Terraria.GameContent.TextureAssets.Projectile[Type].Value; + + #region Virtual Values + public virtual Color SpecialDrawColor => new Color(255, 200, 0); + public virtual int ExudeDustType => 244; + public virtual int WhipDustType => 246; + public virtual int HandleHeight => 54; + public virtual int BodyType1SectionHeight => 18; + public virtual int BodyType2SectionHeight => 18; + public virtual int BodyType1StartY => 36; + public virtual int BodyType2StartY => 58; + public virtual int TailStartY => 90; + public virtual int TailHeight => 52; + #endregion + + #region Dust Effects + /// + /// Spawns dust that is emitted outward as well as dust that goes along where the whip is. + /// + public virtual void GenerateDust() + { + // Dust moving along the whip + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity * 2f, Projectile.width, Projectile.height, ExudeDustType, 0f, 0f, 100, SpecialDrawColor, 2f); + dust.noGravity = true; + dust.velocity *= 2f; + dust.velocity += Projectile.localAI[0].ToRotationVector2(); + dust.fadeIn = 1.5f; + } + float counterMax = 18f; + int counter = 0; + while (counter < counterMax) + { + if (Main.rand.NextBool(4)) + { + Vector2 spawnPosition = Projectile.position + Projectile.velocity + Projectile.velocity * (counter / counterMax); + Dust dust = Dust.NewDustDirect(spawnPosition, Projectile.width, Projectile.height, WhipDustType, 0f, 0f, 100, SpecialDrawColor, 1f); + dust.noGravity = true; + dust.fadeIn = 0.5f; + dust.velocity += Projectile.localAI[0].ToRotationVector2(); + dust.noLight = true; + } + counter++; + } + } + #endregion + + #region Draw Helpers + public override bool PreDraw(ref Color lightColor) + { + // If the velocity is zero, don't draw anything. + // Doing so would lead to various divison by 0 errors during the normalization process. + if (Projectile.velocity == Vector2.Zero) + { + return false; + } + + DrawHandleSprite(in lightColor); + + Vector2 normalizedVelocity = Vector2.Normalize(Projectile.velocity); + + float speed = Projectile.velocity.Length() + 16f - 40f * Projectile.scale; + + Vector2 bodyDrawPosition = Projectile.Center.Floor() + normalizedVelocity * Projectile.scale * 20f; + DrawType2BodySprite(in speed, in normalizedVelocity, in lightColor, ref bodyDrawPosition); + + bodyDrawPosition = Projectile.Center.Floor() + normalizedVelocity * Projectile.scale * 20f; + DrawType1BodySprite(in speed, in normalizedVelocity, in lightColor, ref bodyDrawPosition); + + Vector2 whipEndPosition = bodyDrawPosition; + DrawWhipTail(in whipEndPosition, in lightColor); + return false; + } + + /// + /// Draws the handle of the whip. + /// + /// The color to use when drawing. + public void DrawHandleSprite(in Color lightColor) + { + Rectangle handleFrame = new Rectangle(0, 0, FlailTexture.Width, HandleHeight); + Main.EntitySpriteDraw(FlailTexture, + Projectile.Center.Floor() - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, + new Rectangle?(handleFrame), + lightColor, + Projectile.rotation + MathHelper.Pi, + handleFrame.Size() / 2f - Vector2.UnitY * 4f, + Projectile.scale, + SpriteEffects.None, + 0); + } + + /// + /// Draws the first body frame of the whip. + /// + /// The partially modified speed of the projectile. The exact value is determined as + /// projectile.velocity.Length() + 16f - 40f * projectile.scale; + /// + /// The normalized velocity vector of the whip. + /// The color to use when drawing. + /// The drawing position of the body segments. Modified in this method. + public void DrawType1BodySprite(in float speed, in Vector2 normalizedVelocity, in Color lightColor, ref Vector2 bodyDrawPosition) + { + Rectangle type1BodyFrame = new Rectangle(0, BodyType1StartY, FlailTexture.Width, BodyType1SectionHeight); + bool reducedType1BodyCount = speed < 100f; + int type1BodyDrawCount = reducedType1BodyCount ? 22 : 9; + if (speed > 0f) + { + float speedRatio = speed / type1BodyDrawCount; + bodyDrawPosition += normalizedVelocity * speedRatio * 0.25f; + for (int i = 0; i < type1BodyDrawCount; i++) + { + float drawPositionDeltaMult = speedRatio; + if (i == 0) + { + drawPositionDeltaMult *= 0.75f; + } + Main.EntitySpriteDraw(FlailTexture, + bodyDrawPosition - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, + new Rectangle?(type1BodyFrame), + lightColor, + Projectile.rotation + MathHelper.Pi, + new Vector2(type1BodyFrame.Width / 2, 0f), + Projectile.scale, + SpriteEffects.None, + 0); + bodyDrawPosition += normalizedVelocity * drawPositionDeltaMult; + } + } + } + + /// + /// Draws the second body frame of the whip. + /// + /// The partially modified speed of the projectile. The exact value is determined as + /// projectile.velocity.Length() + 16f - 40f * projectile.scale; + /// + /// The normalized velocity vector of the whip. + /// The color to use when drawing. + /// The drawing position of the body segments. Modified in this method. + public void DrawType2BodySprite(in float speed, in Vector2 normalizedVelocity, in Color lightColor, ref Vector2 bodyDrawPosition) + { + // Draw body segment without the molten rock part sticking to it. + // From a drawing standpoint, this is the second chain type of the flail + Rectangle type2BodyFrame = new Rectangle(0, BodyType2StartY, FlailTexture.Width, BodyType2SectionHeight); + if (speed > 0f) + { + float counter = 0f; + while (counter + 1f < speed) + { + if (speed - counter < type2BodyFrame.Height) + { + type2BodyFrame.Height = (int)(speed - counter); + } + Main.EntitySpriteDraw(FlailTexture, + bodyDrawPosition - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, + new Rectangle?(type2BodyFrame), + lightColor, + Projectile.rotation + MathHelper.Pi, + new Vector2(type2BodyFrame.Width / 2, 0f), + Projectile.scale, + SpriteEffects.None, + 0); + counter += type2BodyFrame.Height * Projectile.scale; + bodyDrawPosition += normalizedVelocity * type2BodyFrame.Height * Projectile.scale; + } + } + } + + /// + /// Draws the tail of the whip. + /// + /// The position to draw the tail. + /// The color to use when drawing. + public void DrawWhipTail(in Vector2 whipEndPosition, in Color lightColor) + { + Rectangle tailFrame = new Rectangle(0, TailStartY, FlailTexture.Width, TailHeight); + Main.EntitySpriteDraw(FlailTexture, + whipEndPosition - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, + new Rectangle?(tailFrame), + lightColor, + Projectile.rotation + MathHelper.Pi, + FlailTexture.Frame(1, 1, 0, 0).Top(), + Projectile.scale, + SpriteEffects.None, + 0); + } + #endregion + + #region Collision and Grass Cut Logic + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = Projectile.velocity; + Utils.PlotTileLine(Projectile.Center, Projectile.Center + unit, Projectile.width * Projectile.scale, DelegateMethods.CutTiles); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float _ = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity, 16f * Projectile.scale, ref _)) + { + return true; + } + return false; + } + #endregion + } +} diff --git a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs index 7f3e4dea90..84fc068a5f 100644 --- a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs @@ -100,6 +100,10 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// Defaults to . ///
public bool KeepRefreshingLifetime { get; set; } = true; + /// + /// If the holdout should constantly set Owner.itemTime and Owner.itemAnimation as 2. + /// + public bool SetUsage { get; set; } = true; /// /// The current offset length from the arm of the holdout.
@@ -168,7 +172,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles { // Multiplayer null-checking. Owner ??= Main.player[Projectile.owner]; - HeldItem ??= Owner.ActiveItem(); + HeldItem ??= Owner.HeldItem; KillHoldoutLogic(); ManageHoldout(); @@ -216,7 +220,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles Owner.ChangeDir(direction); Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = Owner.itemAnimation = 2; + if (SetUsage) + Owner.itemTime = Owner.itemAnimation = 2; Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); // -Pi/2 because the arms rotation starts with arms pointing down. diff --git a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs index a8658220ca..a7a7ac75bf 100644 --- a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod.Projectiles.BaseProjectiles { @@ -33,7 +31,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles { foreach (int itemID in ItemProjectileRelationship.Keys) { - Item heldItem = player.ActiveItem(); + Item heldItem = player.HeldItem; if (heldItem.type != itemID) continue; @@ -60,7 +58,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles public sealed override void AI() { CheckForEveryHoldout(Owner); - if (Owner.ActiveItem().type != AssociatedItemID || Owner.CCed || !Owner.active || Owner.dead || Owner.Calamity().profanedCrystalBuffs) + if (Owner.HeldItem.type != AssociatedItemID || Owner.CCed || !Owner.active || Owner.dead || Owner.Calamity().profanedCrystalBuffs) { Projectile.Kill(); return; diff --git a/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs b/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs index d9834046f1..928365b05a 100644 --- a/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -110,12 +109,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// /// Calculates the laser length while taking tiles into account. /// - /// The amount of samples the ray uses. The higher this is, the more precision, but also more calculations done. - public float DetermineLaserLength_CollideWithTiles(int samplePointCount) + public float DetermineLaserLength_CollideWithTiles() { - float[] laserLengthSamplePoints = new float[samplePointCount]; - Collision.LaserScan(Projectile.Center, Projectile.velocity, Projectile.scale, MaxLaserLength, laserLengthSamplePoints); - return laserLengthSamplePoints.Average(); + return CalamityUtils.PreciseDistanceToTileCollisionHit(Projectile.Center, Projectile.velocity.ToRotation(), MaxLaserLength); } protected internal void DrawBeamWithColor(Color beamColor, float scale, int startFrame = 0, int middleFrame = 0, int endFrame = 0) diff --git a/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs b/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs index e6fa7a953e..7f2a948b01 100644 --- a/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseMassiveExplosionProjectile.cs @@ -26,8 +26,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles if (UsesScreenshake) { float screenShakePower = GetScreenshakePower(Projectile.timeLeft / (float)Lifetime) * Utils.GetLerpValue(1300f, 0f, Projectile.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; + Main.LocalPlayer.SetScreenshake(screenShakePower); } // Expand outward. diff --git a/Projectiles/BaseProjectiles/BaseMinionProjectile.cs b/Projectiles/BaseProjectiles/BaseMinionProjectile.cs index 5d6e660d58..cf7e6014d3 100644 --- a/Projectiles/BaseProjectiles/BaseMinionProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseMinionProjectile.cs @@ -140,6 +140,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void SetStaticDefaults() { Main.projFrames[Type] = AnimationFrames; + // IMPORTANT: Setting Main.projPet disables projectile damage! If you are making a charging minion, be sure to override the MinionContactDamage hook Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; diff --git a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs index 99815b550c..2a02d5f774 100644 --- a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.BaseProjectiles @@ -20,6 +21,31 @@ namespace CalamityMod.Projectiles.BaseProjectiles // Also, be careful with the move and reelback speed. If they're bad values, // the spear might end up detaching from or impaling the player. + private float GetSyncedItemAnimation(Player player) + { + float itemAnimation = player.itemAnimation; + + if (Main.netMode != NetmodeID.SinglePlayer && Main.myPlayer == Projectile.owner) + { + if (Projectile.ai[1] != itemAnimation) + { + Projectile.ai[1] = itemAnimation; + Projectile.netUpdate = true; + } + } + + if (Main.netMode == NetmodeID.SinglePlayer || Main.myPlayer == Projectile.owner) + return itemAnimation; + + if (Projectile.ai[1] > 0f) + Projectile.localAI[1] = 1f; + + if (Projectile.localAI[1] == 1f) + return Projectile.ai[1]; + + return Math.Max(1f, player.itemAnimationMax); + } + public virtual void Behavior() { if (SpearAiType == SpearType.TypicalSpear) @@ -29,6 +55,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles Player player = Main.player[Projectile.owner]; + float itemAnimationMax = Math.Max(1f, player.itemAnimationMax); + float syncedItemAnimation = GetSyncedItemAnimation(player); + // Adjust owner stats based on this projectile player.ChangeDir(Projectile.direction); player.heldProj = Projectile.whoAmI; @@ -47,7 +76,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles Projectile.netUpdate = true; } // Reel back - if (player.itemAnimation < player.itemAnimationMax / 3) + if (syncedItemAnimation < itemAnimationMax / 3f) { Projectile.ai[0] -= ReelbackSpeed; @@ -67,7 +96,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles // If at the end of the animation, kill the projectile. //Checking if == 0 is too late, lets the projectile linger into chained item uses. - if (player.itemAnimation <= 1) + if (syncedItemAnimation <= 1f) Projectile.Kill(); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 + MathHelper.PiOver4; @@ -78,6 +107,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles { Player player = Main.player[Projectile.owner]; + float itemAnimationMax = Math.Max(1f, player.itemAnimationMax); + float syncedItemAnimation = GetSyncedItemAnimation(player); + Vector2 playerRelativePoint = player.RotatedRelativePoint(player.MountedCenter, true); Projectile.direction = player.direction; @@ -92,7 +124,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles if (!player.frozen) { // Pretty much the same as regular spears. - if (Main.player[Projectile.owner].itemAnimation < Main.player[Projectile.owner].itemAnimationMax / 3) + if (syncedItemAnimation < itemAnimationMax / 3f) { if (Projectile.localAI[0] == 0f && EffectBeforeReelback != null && Main.myPlayer == Projectile.owner) { @@ -113,7 +145,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles { Projectile.localAI[0] -= 1f; } - float inverseAnimationCompletion = 1f - (player.itemAnimation / (float)player.itemAnimationMax); + float inverseAnimationCompletion = 1f - (syncedItemAnimation / itemAnimationMax); float originalVelocityDirection = Projectile.velocity.ToRotation(); float originalVelocitySpeed = Projectile.velocity.Length(); diff --git a/Projectiles/BaseProjectiles/BaseSwordHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseSwordHoldoutProjectile.cs new file mode 100644 index 0000000000..13125da4a5 --- /dev/null +++ b/Projectiles/BaseProjectiles/BaseSwordHoldoutProjectile.cs @@ -0,0 +1,575 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent.Prefixes; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.BaseProjectiles +{ + + public class BaseSwordHoldoutPlayer : ModPlayer + { + /// + /// Used to detect what swing a weapon is doing. + /// + public int swingNum = 0; + + } + /// + /// Manages all the required settings for custom sword holdouts done using BaseSwordHoldoutProjectile + /// + public abstract class BaseSwordHoldoutItem : ModItem + { + public virtual int ProjectileType { get; set; } + public virtual bool SizeModifiers { get; set; } = true; + + public virtual bool RClickAutoswing { get; set; } = false; + + public override void SetStaticDefaults() + { + if (RClickAutoswing) ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + } + + public override bool MeleePrefix() + { + return SizeModifiers; + } + public override void SetDefaults() + { + Item.noMelee = true; + Item.noUseGraphic = true; + Item.shoot = ProjectileType; + Item.autoReuse = true; + Item.useTurn = false; + Item.useStyle = ItemUseStyleID.Shoot; + if (SizeModifiers) PrefixLegacy.ItemSets.SwordsHammersAxesPicks[Item.type] = true; + } + public override bool CanUseItem(Player player) + { + if (player.itemTime > 0) + { + return false; + } + for (int i = 0; i < 1000; i++) + { + var proj = Main.projectile[i]; + if (proj.type == ProjectileType && proj.owner == player.whoAmI && proj.active) + { + return false; + } + + } + return base.CanUseItem(player); + } + } + + [PierceResistException] + //Doze 24apr2025 - Not a child of BaseCustomUseStyleProjectile because this doesn't use any of it's functionality. Comes from my melee rework mod. + public abstract class BaseSwordHoldoutProjectile : ModProjectile + { + #region Overrideable Fields + /// + /// The width, in degrees, of the sword swing. + /// Defaults to 180 + /// + public virtual int swingWidth { get; set; } = 180; + /// + /// How many frames the sword swing should take. + /// Defaults to 20 + /// + public virtual int swingTime { get; set; } = 20; + /// + /// If the swing should alternate directions each use. + /// Defaults to true + /// + public virtual bool AlternateSwings { get; set; } = true; + /// + /// How far the held sword should be offset from the player + /// Defaults to 0 + /// + public virtual int OffsetDistance { get; set; } = 0; + /// + /// What item this projectile uses as a base. + /// + public virtual Item BaseItem { get; set; } + /// + /// Whether or not this projectile uses a base item at all. + /// Defaults to true. + /// + public virtual bool UsesBaseItem { get; set; } = true; + + /// + /// Length of after-image trail left by the projectile. + /// Defaults to 0 + /// + public virtual int AfterImageLength { get; set; } = 0; + + /// + /// Whether or not this should get melee speed bonuses + /// Defaults to TRUE + /// + public virtual bool useMeleeSpeed { get; set; } = true; + + /// + /// Whether or not this should get melee size bonuses (Titan Glove) + /// Defaults to TRUE + /// + public virtual bool useMeleeSize { get; set; } = true; + /// + /// Array of three colors used for the built-in trail drawing code. + /// Defaults to White, Black, Green. + /// + public virtual Color[] trailColors { get; set; } = [Color.White, Color.Black, Color.Green]; + + /// + /// Whether or not to draw a trail when swung. + /// + public virtual bool drawSwordTrail { get; set; } = false; + /// + /// How far the trail should be offset from the center of the projectile. Use to draw trail at sword tip + /// Defaults to 25 + /// + public virtual float trailOffset { get; set; } = 25; + /// + /// Length of the trail in frames + /// Defaults to 25 + /// + public virtual int trailLength { get; set; } = 25; + + /// + /// How long before the weapon should begin it's actual swing once used + /// + public virtual int StartupTime { get; set; } = 0; + /// + /// How long the weapon should "cool down" after swinging before ending the item use + /// + public virtual int CooldownTime { get; set; } = 0; + /// + /// Speed at which the projectile should rotate to match the mouse angle during StartupTime. + /// Set to 0 to disable. + /// Defaults to 0.5f + /// + public virtual float RotateInStartup { get; set; } = 0.5f; + + /// + /// Speed at which the projectile should rotate to match the mouse angle during Cooldown. + /// Set to 0 to disable. + /// Defaults to 0.5f + /// + public virtual float RotateInCooldown { get; set; } = 0.5f; + + /// + /// What sound to use when the sword begins the actual swing (after startup frames) + /// + public virtual SoundStyle? UseSound { get; set; } = null; + /// + /// The length (from the player) of the projectile's line collision. + /// This helps to prevent blindspots. + /// Defaults to 0 + /// + public virtual float lineCollisionLength { get; set; } = 0; + + public virtual Color AfterImageColor { get; set; } = Color.White; + + #endregion + + #region Fields + + /// + /// Angle of the swing. By default, gets set to mouse angle. Can be set in Spawn(IEntitySource) for fixed angles. + /// + public Vector2 angle { get; set; } = Vector2.Zero; + /// + /// The projectile's center based on offset to the player the previous update + /// Can be used for effects that stay consistent in motion + /// + public Vector2 oldPlayerOffset { get; set; } + /// + /// Internal timer for the projectile's entire lifespan + /// + public int timer { get; set; } = 0; + + /// + /// Internal timer for the projectile's swing animation + /// + internal int swingTimer = 0; + + public static Asset TrailTexture; + + public float baseScale; + /// + /// Old weapon scales used to track for trail drawing + /// + public List oldScale = new List(); + List oldProjectileRot = new List { }; + List oldProjectilePos = new List { }; + + internal int ExistsTime = 20; + public bool inStartup => timer < StartupTime; + + public bool inCooldown => timer > CooldownStartFrame; + + public bool inSwing => !(inStartup || inCooldown); + + public int CooldownStartFrame => swingTime + StartupTime; + + public int CooldownTimer => timer - CooldownStartFrame; + + public float StartupCompletion => timer / (float)StartupTime; + public float SwingCompletion => swingTimer / (float)swingTime; + public float CooldownCompletion => CooldownTimer / (float)CooldownTime; + + private bool hasFakedOnSpawn = false; + + #endregion + + #region Overridable Methods + /// + /// Happens after movement but before timer increases. Use as to not cancel the default AI behavior. + /// + public virtual void AdditionalAI() { } + /// + /// happens at the beginning of AI the first frame. + /// + /// + public virtual void Spawn() { } + /// + /// happens after SetDefaults. Use as not to cancel default SetDefaults behavior. + /// + public virtual void Defaults() { } + /// + /// Returns the swing offset from the center angle in radians. Automatically will be inverted if AlternateSwings is enabled. + /// + /// + public virtual float SwingFunction() + { + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth / 2, swingWidth / 2, swingTimer / (float)swingTime)); + } + + /// + /// The function for the width of the trail + /// + /// + /// + public virtual float trailWidth(float completion, Vector2 vertexPos) + { + return MathHelper.Lerp(30, 0, completion); + } + + /// + /// The function for the color of the trail + /// + /// + /// + public virtual Color trailColor(float completion, Vector2 vertexPos) + { + return Color.Black; + } + #endregion + + #region Overrides + /// + /// DO NOT OVERRIDE IN MOST SITUATIONS + /// use Defaults() instead. + /// That will set defaults after everything is set in the base projectile. + /// + public override void SetDefaults() + { + Projectile.timeLeft = swingTime * 2; + if (UsesBaseItem) + { + Projectile.width = Projectile.height = Math.Max(BaseItem.height, BaseItem.width); + } + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.localNPCHitCooldown = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.extraUpdates = 0; + Projectile.aiStyle = -2; + Projectile.DamageType = ModLoader.GetMod("CalamityMod").Find("TrueMeleeDamageClass"); + Projectile.tileCollide = false; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 100; + Defaults(); + } + /// + /// This hook runs at the beginning of AI the first time through. + /// + private void FakeOnSpawn() + { + var player = Main.player[Projectile.owner]; + angle = (player.MountedCenter - player.Calamity().mouseWorld).SafeNormalize(Vector2.One); + Projectile.velocity = Vector2.Zero; + if (angle.X < 0) + { + player.direction = 1; + Projectile.spriteDirection = 1 * (int)player.gravDir; + } + else + { + player.direction = -1; + Projectile.spriteDirection = -1 * (int)player.gravDir; + } + if (AlternateSwings && player.GetModPlayer().swingNum % 2 == 1) + { + Projectile.spriteDirection *= -1; + } + if (AlternateSwings) + { + player.GetModPlayer().swingNum++; + } + swingTime = Main.player[Projectile.owner].HeldItem.useTime; + Spawn(); + StartupTime *= Projectile.MaxUpdates; + CooldownTime *= Projectile.MaxUpdates; + swingTime *= Projectile.MaxUpdates; + if (useMeleeSpeed) + { + var speed = Main.player[Projectile.owner].GetAttackSpeed(); + if (speed > 3f) + speed = 3f; + + if (speed != 0f) + speed = 1f / speed; + + swingTime = (int)(swingTime * speed); + if (swingTime < 1) + { + swingTime = 1; + } + StartupTime = (int)(StartupTime * speed); + CooldownTime = (int)(CooldownTime * speed); + } + if (useMeleeSize) + { + if (player.meleeScaleGlove) Projectile.scale *= 1.1f; + Projectile.scale *= player.HeldItem.scale; + } + baseScale = Projectile.scale; + ExistsTime = swingTime + StartupTime + CooldownTime; + Projectile.timeLeft = ExistsTime * 2; + Projectile.netUpdate = true; + } + + /// + /// DO NOT OVERRIDE IN MOST SITUATIONS + /// use AdditionalAI() instead + /// That will run AI code at the right time. + /// + public override void AI() + { + if (!hasFakedOnSpawn) + { + FakeOnSpawn(); + hasFakedOnSpawn = true; + } + var player = Main.player[Projectile.owner]; + Projectile.gfxOffY = player.gfxOffY; + player.Calamity().mouseWorldListener = true; + var modplayer = player.GetModPlayer(); + float adust = MathHelper.ToRadians(225); + if (timer < StartupTime || timer > StartupTime + swingTime) + { + if (inStartup) + angle = Vector2.Lerp(angle, (player.MountedCenter - player.Calamity().mouseWorld).SafeNormalize(Vector2.One), RotateInStartup); + if (inCooldown) + angle = Vector2.Lerp(angle, (player.MountedCenter - player.Calamity().mouseWorld).SafeNormalize(Vector2.One), RotateInCooldown); + if (angle.X < 0) + { + player.direction = 1; + Projectile.spriteDirection = 1 * (int)player.gravDir; + } + else + { + player.direction = -1; + Projectile.spriteDirection = -1 * (int)player.gravDir; + } + if (AlternateSwings && player.GetModPlayer().swingNum % 2 == 1) + { + Projectile.spriteDirection *= -1; + } + } + if (Projectile.spriteDirection == -1) + { + adust = MathHelper.ToRadians(-45); + } + var armCenter = player.MountedCenter - new Vector2(5 * player.direction, 2); + if (AfterImageLength > 0) + { + oldProjectileRot.Add(Projectile.rotation); + oldProjectilePos.Add(Projectile.Center + new Vector2(0, Projectile.gfxOffY)); + if (oldProjectileRot.Count > AfterImageLength) + { + oldProjectileRot.RemoveAt(0); + oldProjectilePos.RemoveAt(0); + } + } + if (inSwing && swingTimer == 1 && UseSound != null) + { + SoundEngine.PlaySound((SoundStyle)UseSound, player.Center); + } + var angle2 = (AlternateSwings && modplayer.swingNum % 2 == 1 ? SwingFunction() : SwingFunction()); + Projectile.Center = armCenter - (angle * OffsetDistance * (1 + (Projectile.scale - 1) * 0.75f)).RotatedBy(Projectile.spriteDirection * angle2); + Projectile.rotation = angle.RotatedBy(Projectile.spriteDirection * angle2).ToRotation() + adust; + AdditionalAI(); + if (!Projectile.active) + return; + oldPlayerOffset = Projectile.Center - player.MountedCenter; + player.itemTime = ExistsTime + 2 - timer; + player.itemAnimation = ExistsTime + 2 - timer; + if (timer > ExistsTime) + { + player.itemTime = 0; + player.itemAnimation = 0; + Projectile.Kill(); + } + timer++; + if (timer >= StartupTime && timer < StartupTime + swingTime) + { + swingTimer++; + } + var armDir = armCenter - Projectile.Center; + armDir.Y *= player.gravDir; + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armDir.ToRotation() + MathHelper.ToRadians(90)); + oldScale.Insert(0, Projectile.scale); + } + public override bool PreDraw(ref Color lightColor) + { + + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + if (AfterImageLength > 0) + { + Texture2D texture = ModContent.Request(Texture).Value; + for (int i = 0; i < oldProjectileRot.Count; i++) + { + var col = Projectile.Opacity * (i / (float)AfterImageLength) * 0.1f; + if (Projectile.spriteDirection == 1) + { + Main.EntitySpriteDraw(texture, oldProjectilePos[i] - Main.screenPosition, null, AfterImageColor * col, oldProjectileRot[i], texture.Size() / 2, oldScale[i], SpriteEffects.None, 0); + } + else + { + Main.EntitySpriteDraw(texture, oldProjectilePos[i] - Main.screenPosition, null, AfterImageColor * col, oldProjectileRot[i], texture.Size() / 2, oldScale[i], SpriteEffects.FlipHorizontally, 0); + } + } + } + if (drawSwordTrail && timer >= StartupTime && timer <= StartupTime + swingTime) + { + Main.spriteBatch.EnterShaderRegion(); + if (TrailTexture == null) + { + TrailTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes", (AssetRequestMode)2); + } + Vector2 trailOffset = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() + Projectile.Size * 0.5f; + GameShaders.Misc["CalamityMod:ExobladeSlash"].SetShaderTexture(TrailTexture); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].UseColor(trailColors[0]); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].UseSecondaryColor(trailColors[1]); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["fireColor"].SetValue(trailColors[2].ToVector3()); + + GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue(Projectile.spriteDirection == -1 ? false : true); + GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply(); + + var positionsToUse = Projectile.oldPos.Take((int)MathHelper.Min(trailLength, swingTimer)).ToArray(); + for (var i = 0; i < positionsToUse.Length; i++) + { + if (i >= timer) break; + positionsToUse[i] += (Projectile.oldRot[i] - MathHelper.PiOver4 * (Projectile.spriteDirection == -1 ? 3 : 1)).ToRotationVector2() * this.trailOffset * oldScale[i]; + } + PrimitiveRenderer.RenderTrail(positionsToUse, new(trailWidth, trailColor, (_, _) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 25); + Main.spriteBatch.ExitShaderRegion(); + + Main.player[Projectile.owner].heldProj = Projectile.whoAmI; + } + Main.player[Projectile.owner].heldProj = Projectile.whoAmI; + return true; + } + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + var center = hitbox.Center.ToVector2(); + hitbox.Height = (int)(Projectile.height * Projectile.scale); + hitbox.Width = (int)(Projectile.width * Projectile.scale); + hitbox.Location = (center - new Vector2(hitbox.Width / 2, hitbox.Height / 2)).ToPoint(); + + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (lineCollisionLength > 0) + { + var player = Main.player[Projectile.owner]; + var armcenter = player.MountedCenter - new Vector2(5 * player.direction, 2); + var swordDir = armcenter.DirectionTo(Projectile.Center); + var collisionline = new Vector2(lineCollisionLength / 2f, 0).RotatedBy(swordDir.ToRotation()) * Projectile.scale; + bool c = Collision.CheckAABBvLineCollision(targetHitbox.Location.ToVector2(), targetHitbox.Size(), Projectile.Center, Projectile.Center + collisionline); + if (c && !float.IsNaN(collisionline.X) && !float.IsNaN(collisionline.Y)) + return true; + } + return base.Colliding(projHitbox, targetHitbox); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.HitDirectionOverride = ((Main.player[Projectile.owner].DirectionTo(target.Center)).X >= 0 ? 1 : -1); + } + + public override bool? CanDamage() + { + return inSwing; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(angle); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + angle = reader.ReadVector2(); + } + #endregion + + #region Helper Methods + /// + /// Spawns projectiles from the sword swing, automatically spacing them out on the if an amount is set. + /// + /// + /// Velocity of the projectile. Automatically converted into a Vector2 in the direction of swing. + /// The modifier from the source projectile's damage for this projectile + /// The amount of projectiles for the sword to shoot. If set, it will space out those projectiles evenly. If unset, will force a shot. + /// + /// + public void shootCheck(int type = 0, float velocity = 1, float damagemod = 1, int amount = 0, int negate = 0, int ai0 = 0) + { + if (negate == 0) + { + negate = Projectile.spriteDirection; + } + if (amount == 0) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.rotation + negate * MathHelper.ToRadians(45 - negate * 90)).ToRotationVector2() * velocity, type, (int)(Projectile.damage * damagemod), Projectile.knockBack, Projectile.owner, ai0); + return; + } + amount += 1; + if (swingTimer % (swingTime / amount) == 0 && swingTimer > 0 && swingTimer < swingTime - swingTime / amount / 2) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.rotation + negate * MathHelper.ToRadians(45 - negate * 90)).ToRotationVector2() * velocity, type, (int)(Projectile.damage * damagemod), Projectile.knockBack, Projectile.owner, ai0); + } + } + + #endregion + } + +} diff --git a/Projectiles/BaseProjectiles/BaseWhipProjectile.cs b/Projectiles/BaseProjectiles/BaseWhipProjectile.cs index d237f39f70..de6a3b0cd9 100644 --- a/Projectiles/BaseProjectiles/BaseWhipProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseWhipProjectile.cs @@ -1,316 +1,399 @@ -using System; +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Enums; +using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.BaseProjectiles { + /// + /// Base class for a whip that handles drawing, AI, and onHit. To make a simple whip, you only need to specify stats in setWhipStats + /// This was originally based off the ExampleMod implementation, but with several changes for ease of subclassing + /// public abstract class BaseWhipProjectile : ModProjectile { - // This class by default uses the values in the Mourningstar projectile - // Note: the original solar eruption code uses hide and player.heldProj. - // These two combined will prevent the second version of the whip from being drawn. - public virtual void Behavior() + #region Overridable Properties + + + //Visual and SFX related variables + + /// + /// Color of the line connecting whip segments + /// + public virtual Color FishingLineColor => Color.White; + + /// + /// Overrides the color the whips is drawn as. If null, use surrounding tile lighting + /// + public virtual Color? DrawColor => null; + + /// + /// Color of light the whip emits + /// + public virtual Color LightingColor => Color.Transparent; + + /// + /// Type of dust (ID) the whip emits, emits no dust if it is null + /// + public virtual int? SwingDust => null; + + /// + /// How many times the dust spawning loop iterates + /// + public virtual int DustAmount => 1; + /// + /// If true, the tip of the whip kind of fades away when completing it's arc + /// + public virtual bool ShrinkTip => true; + public virtual bool UseTimeDetermineLifetime => true; + public virtual SoundStyle? WhipCrackSound => SoundID.Item153; + + + + //Textures are set to InvisibleProj by default, but this should be changed if you want it to be visible. + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public abstract string WhipTipTexture { get;} + /// + /// The order of textures in this list is the order which they will appear when drawn in game. + /// + public abstract List WhipSegmentTexture { get;} + + /// + /// UNIMPLEMENTED + /// The Y offset of each whip segment texture, in order of appearance. + /// Length should match WhipSegmentTexture, or be left null. + /// When null, all offsets are set to 0. + /// Defaults to null. + /// + public virtual List WhipSegmentYOffset => null; + public abstract string WhipHandleTexture { get; } + public virtual string WhipTipGlowTexture => null; + public virtual List WhipSegmentGlowTexture => null; + public virtual string WhipHandleGlowTexture => null; + + + //Tag related variables + public virtual int? TagBuffID => null; + public virtual int TagDuration => 240; + + + //Gameplay variables + /// + /// Multiply the whip damage by this amount on hitting an enemy + /// + public virtual float? MultihitModifier => .8f; + + #endregion + + internal List whipPoints = new List(); + internal float Timer { - Player player = Main.player[Projectile.owner]; - if (Projectile.localAI[1] > 0f) - { - Projectile.localAI[1] -= 1f; - } - // Rapidly appear - Projectile.alpha -= 42; - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } - // Determine the starting velocity direction - if (Projectile.localAI[0] == 0f) - { - Projectile.localAI[0] = Projectile.velocity.ToRotation(); - } - float direction = (Projectile.localAI[0].ToRotationVector2().X >= 0f).ToDirectionInt(); - if (Projectile.ai[1] <= 0f) - { - direction *= -1f; - } - // As ai[0], the timer, goes up, - Vector2 velocityAdditive = (direction * (Projectile.ai[0] / 30f * MathHelper.TwoPi - MathHelper.PiOver2)).ToRotationVector2(); - - // ai[1] = A starting rotation value. With a min of 0 and a max of pi/4 - // The larger it is, the larger the outward distance we travel. - // It will always be compressed a bit relative to the X travel movement, however, - // because sin(pi/4) = 1/sqrt(2), which is less than the default multiplier the X distance - // receives: 1. - velocityAdditive.Y *= (float)Math.Sin(Projectile.ai[1]); - if (Projectile.ai[1] <= 0f) - { - velocityAdditive.Y *= -1f; - } - // Rotate by the starting velocity angle, to maintain the original rotation instead of - // Constantly rotating upward or sideways - velocityAdditive = velocityAdditive.RotatedBy(Projectile.localAI[0]); - Projectile.ai[0] += 1f; - if (Projectile.ai[0] < 30f) - { - Projectile.velocity += 48f * velocityAdditive; - } - else - { - Projectile.Kill(); - } - // Adjust position so that we're always sticking to the player. - Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - player.ChangeDir(Projectile.direction); - player.itemTime = 2; - player.itemAnimation = 2; - player.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - - // Adjust the center based on player attributes. - Vector2 centerDelta = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f; - if (player.direction != 1) - { - centerDelta.X = player.bodyFrame.Width - centerDelta.X; - } - if (player.gravDir != 1f) - { - centerDelta.Y = player.bodyFrame.Height - centerDelta.Y; - } - if (player.heldProj == -1) - player.heldProj = Projectile.whoAmI; - centerDelta -= new Vector2(player.bodyFrame.Width - player.width, player.bodyFrame.Height - 42) / 2f; - Projectile.Center = player.RotatedRelativePoint(player.position + centerDelta, true) - Projectile.velocity; - - // Cool dust - if (Projectile.alpha == 0) - { - GenerateDust(); - } + get => Projectile.ai[0]; + set => Projectile.ai[0] = value; } - public virtual void ExtraBehavior() + public int PointDrawTimer = 0; + public float lineScale = 1; + public int lineCount = 1; + + internal Vector2? GetTipPosition() { - + + if (whipPoints != null && whipPoints.Count > 2) + return whipPoints[whipPoints.Count - 1]; + return null; } + + + + #region ModProjectile Functions + + public override void SetStaticDefaults() + { + // This makes the projectile use whip collision detection and allows flasks to be applied to it.> + ProjectileID.Sets.IsAWhip[Type] = true; + } + + + public override void SetDefaults() + { + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ownerHitCheck = true; // This prevents the projectile from hitting through solid tiles. + Projectile.extraUpdates = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = DamageClass.SummonMeleeSpeed; + + + SetWhipStats(); + } + + + public override bool PreAI() + { + if (PointDrawTimer % 2 < .001) + { + whipPoints.Clear(); + Projectile.FillWhipControlPoints(Projectile, whipPoints); + } + return true; + } + public override void AI() { - Behavior(); - ExtraBehavior(); + WhipAIMotion(); + WhipSFX(LightingColor, SwingDust, DustAmount, WhipCrackSound); } - public Texture2D FlailTexture => Terraria.GameContent.TextureAssets.Projectile[Type].Value; - #region Virtual Values - public virtual Color SpecialDrawColor => new Color(255, 200, 0); - public virtual int ExudeDustType => 244; - public virtual int WhipDustType => 246; - public virtual int HandleHeight => 54; - public virtual int BodyType1SectionHeight => 18; - public virtual int BodyType2SectionHeight => 18; - public virtual int BodyType1StartY => 36; - public virtual int BodyType2StartY => 58; - public virtual int TailStartY => 90; - public virtual int TailHeight => 52; #endregion - #region Dust Effects - /// - /// Spawns dust that is emitted outward as well as dust that goes along where the whip is. + + #region Virtual Functions + + /// + /// Function is use to control custom whip stats, called in the parent class's set defaults /// - public virtual void GenerateDust() + public virtual void SetWhipStats() { - // Dust moving along the whip - for (int i = 0; i < 2; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity * 2f, Projectile.width, Projectile.height, ExudeDustType, 0f, 0f, 100, SpecialDrawColor, 2f); - dust.noGravity = true; - dust.velocity *= 2f; - dust.velocity += Projectile.localAI[0].ToRotationVector2(); - dust.fadeIn = 1.5f; - } - float counterMax = 18f; - int counter = 0; - while (counter < counterMax) - { - if (Main.rand.NextBool(4)) - { - Vector2 spawnPosition = Projectile.position + Projectile.velocity + Projectile.velocity * (counter / counterMax); - Dust dust = Dust.NewDustDirect(spawnPosition, Projectile.width, Projectile.height, WhipDustType, 0f, 0f, 100, SpecialDrawColor, 1f); - dust.noGravity = true; - dust.fadeIn = 0.5f; - dust.velocity += Projectile.localAI[0].ToRotationVector2(); - dust.noLight = true; - } - counter++; - } + Projectile.width = 20; + Projectile.height = 20; + Projectile.WhipSettings.Segments = 30; + Projectile.WhipSettings.RangeMultiplier = 1f; } - #endregion + + + // This method draws a line between all points of the whip, in case there's empty space between the sprites. - #region Draw Helpers public override bool PreDraw(ref Color lightColor) { - // If the velocity is zero, don't draw anything. - // Doing so would lead to various divison by 0 errors during the normalization process. - if (Projectile.velocity == Vector2.Zero) + return DrawWhip(FishingLineColor); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + WhipOnHit(target); + } + + /// + /// Applies tag buff if there is one, applies multihit penalty, and focuses minions on target. + /// Called in OnHitNPC + /// + /// + public virtual void WhipOnHit(NPC target) + { + if (TagBuffID != null) { + target.AddBuff((int)TagBuffID, TagDuration); + } + Projectile.damage = (int)(Projectile.damage * MultihitModifier); + if (Projectile.damage < 1) + { + Projectile.damage = 1; + } + Main.player[Projectile.owner].MinionAttackTargetNPC = target.whoAmI; + } + + /// + /// Draws whip based on example mod, override if you want custom. + /// Called in PreDraw + /// + /// What color the fishing line is + /// + public virtual bool DrawWhip(Color lineColor) + { + //Gets every segment of the whip + if (whipPoints == null || whipPoints.Count < 1) return false; + + for (int i = 0; i < lineCount; i++) + CalamityUtils.DrawLineBetweenPoints(whipPoints, lineColor, scaleMod: lineScale - (lineScale / lineCount) * i); + + SpriteEffects flip = Projectile.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically; + + Main.instance.LoadProjectile(Type); + + //Load projectiles using file paths + Texture2D texture = ModContent.Request(WhipHandleTexture).Value; ; + Texture2D glowtexture = texture; + bool drawGlow = false; + if (WhipHandleGlowTexture != null) + { + glowtexture = ModContent.Request(WhipHandleGlowTexture).Value; + drawGlow = true; } - DrawHandleSprite(in lightColor); + //Sets the frame which will be displayed + Rectangle sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height); + Vector2 origin = sourceRectangle.Size() / 2f; - Vector2 normalizedVelocity = Vector2.Normalize(Projectile.velocity); + - float speed = Projectile.velocity.Length() + 16f - 40f * Projectile.scale; - Vector2 bodyDrawPosition = Projectile.Center.Floor() + normalizedVelocity * Projectile.scale * 20f; - DrawType2BodySprite(in speed, in normalizedVelocity, in lightColor, ref bodyDrawPosition); + Vector2 pos = whipPoints[0]; - bodyDrawPosition = Projectile.Center.Floor() + normalizedVelocity * Projectile.scale * 20f; - DrawType1BodySprite(in speed, in normalizedVelocity, in lightColor, ref bodyDrawPosition); + //Repeats for each whip point + for (int i = 0; i < whipPoints.Count; i++) + { + float scale = 1; - Vector2 whipEndPosition = bodyDrawPosition; - DrawWhipTail(in whipEndPosition, in lightColor); + //Tip of the whip + if (i == whipPoints.Count - 1) + { + //Sets image to tip texture + texture = ModContent.Request(WhipTipTexture).Value; + + //Moves the frame with the animation + sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height); + origin = sourceRectangle.Size() / 2f; + origin.Y += DrawOriginOffsetY * Projectile.spriteDirection; + origin.X += DrawOriginOffsetX; + + drawGlow = false; + if (WhipTipGlowTexture != null) + { + glowtexture = ModContent.Request(WhipTipGlowTexture).Value; + drawGlow = true; + } + + // For a more impactful look, this scales the tip of the whip up when fully extended, and down when curled up. + + if (ShrinkTip) + { + Projectile.GetWhipSettings(Projectile, out float timeToFlyOut, out int _, out float _); + float t = Timer / timeToFlyOut; + scale = MathHelper.Lerp(0.5f, 1.5f, + Utils.GetLerpValue(0.1f, 0.7f, t, true) * Utils.GetLerpValue(0.9f, 0.7f, t, true)) * Projectile.scale; + } + } + else if (i > 0) + { + + //Sets image to segment texture + texture = ModContent.Request(WhipSegmentTexture[i%WhipSegmentTexture.Count]).Value; + //sets the frame accordingly + sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height); + origin = sourceRectangle.Size() / 2f; + drawGlow = false; + if (WhipSegmentGlowTexture != null) + { + glowtexture = ModContent.Request(WhipSegmentGlowTexture[i % WhipSegmentTexture.Count]).Value; + drawGlow = true; + } + + } + Vector2 element = whipPoints[i]; + Vector2 diff = (i == whipPoints.Count - 1 ? element- whipPoints[i-1] : whipPoints[i + 1] - element); + + float rotation = diff.ToRotation(); + //Rotate the handle + if (i == 0) + { + //diff.toRotation makes it follow the rotation of the whip anim + //MathHelper.Pi can be subtracted / added to adjust where the handle is + //Use multiplication as needed to tweak that + rotation = diff.ToRotation(); + } + + Color color = Lighting.GetColor(element.ToTileCoordinates()); + if (DrawColor != null) { + + color = (Color)DrawColor; + } + + Main.EntitySpriteDraw(texture, pos - Main.screenPosition, sourceRectangle, color, rotation, origin, scale, flip, 0); + if (drawGlow) + { + Main.EntitySpriteDraw(glowtexture, pos - Main.screenPosition, sourceRectangle, Color.White, rotation, origin, scale, flip, 0); + } + pos += diff; + } return false; } + bool runOnce = true; + /// - /// Draws the handle of the whip. + /// Runs whip AI similar to example mod, but the center is now on the whip tip. Called in AI /// - /// The color to use when drawing. - public void DrawHandleSprite(in Color lightColor) + public virtual void WhipAIMotion() { - Rectangle handleFrame = new Rectangle(0, 0, FlailTexture.Width, HandleHeight); - Main.EntitySpriteDraw(FlailTexture, - Projectile.Center.Floor() - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, - new Rectangle?(handleFrame), - lightColor, - Projectile.rotation + MathHelper.Pi, - handleFrame.Size() / 2f - Vector2.UnitY * 4f, - Projectile.scale, - SpriteEffects.None, - 0); + Player owner = Main.player[Projectile.owner]; + float swingTime = owner.itemAnimationMax * Projectile.MaxUpdates; + if (runOnce) + { + Projectile.WhipSettings.Segments = (int)((owner.whipRangeMultiplier + 1) * Projectile.WhipSettings.Segments); + runOnce = false; + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; // Without PiOver2, the rotation would be off by 90 degrees counterclockwise. + + Projectile.Center = Vector2.Lerp(Projectile.Center, whipPoints[whipPoints.Count - 1], 1); + + // Vanilla uses Vector2.Dot(Projectile.velocity, Vector2.UnitX) here. Dot Product returns the difference between two vectors, 0 meaning they are perpendicular. + // However, the use of UnitX basically turns it into a more complicated way of checking if the projectile's velocity is above or equal to zero on the X axis. + Projectile.spriteDirection = Projectile.velocity.X >= 0f ? 1 : -1; + Timer++; + PointDrawTimer++; + + if (Timer >= swingTime || (UseTimeDetermineLifetime && owner.itemAnimation <= 0)) + { + + Projectile.Kill(); + return; + } } /// - /// Draws the first body frame of the whip. + /// Plays sound and runs dust, all the parameters should be set in whip stats, though you can override them. + /// Called in AI /// - /// The partially modified speed of the projectile. The exact value is determined as - /// projectile.velocity.Length() + 16f - 40f * projectile.scale; - /// - /// The normalized velocity vector of the whip. - /// The color to use when drawing. - /// The drawing position of the body segments. Modified in this method. - public void DrawType1BodySprite(in float speed, in Vector2 normalizedVelocity, in Color lightColor, ref Vector2 bodyDrawPosition) + /// + /// + /// + /// + public virtual void WhipSFX(Color lightingCol, int? dustID, int dustNum, SoundStyle? sound) { - Rectangle type1BodyFrame = new Rectangle(0, BodyType1StartY, FlailTexture.Width, BodyType1SectionHeight); - bool reducedType1BodyCount = speed < 100f; - int type1BodyDrawCount = reducedType1BodyCount ? 22 : 9; - if (speed > 0f) + Player owner = Main.player[Projectile.owner]; + float swingTime = owner.itemAnimationMax * Projectile.MaxUpdates; + //Main.NewText(lightingCol); + + + + owner.heldProj = Projectile.whoAmI; + Vector2? tip = GetTipPosition(); + + if(tip is null) + return; + if (Timer == swingTime / 2 && sound != null) { - float speedRatio = speed / type1BodyDrawCount; - bodyDrawPosition += normalizedVelocity * speedRatio * 0.25f; - for (int i = 0; i < type1BodyDrawCount; i++) + // Plays a whipcrack sound at the tip of the whip. + SoundEngine.PlaySound(sound, tip); + + } + if ((Timer >= swingTime * .45f) && Timer <= swingTime * 0.85f) + { + if (dustID != null) { - float drawPositionDeltaMult = speedRatio; - if (i == 0) + for (int i = 0; i < dustNum; i++) { - drawPositionDeltaMult *= 0.75f; + Dust.NewDust((Vector2)tip, 2, 2, (int)dustID, 0, 0, Scale: .5f); } - Main.EntitySpriteDraw(FlailTexture, - bodyDrawPosition - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, - new Rectangle?(type1BodyFrame), - lightColor, - Projectile.rotation + MathHelper.Pi, - new Vector2(type1BodyFrame.Width / 2, 0f), - Projectile.scale, - SpriteEffects.None, - 0); - bodyDrawPosition += normalizedVelocity * drawPositionDeltaMult; } - } - } - - /// - /// Draws the second body frame of the whip. - /// - /// The partially modified speed of the projectile. The exact value is determined as - /// projectile.velocity.Length() + 16f - 40f * projectile.scale; - /// - /// The normalized velocity vector of the whip. - /// The color to use when drawing. - /// The drawing position of the body segments. Modified in this method. - public void DrawType2BodySprite(in float speed, in Vector2 normalizedVelocity, in Color lightColor, ref Vector2 bodyDrawPosition) - { - // Draw body segment without the molten rock part sticking to it. - // From a drawing standpoint, this is the second chain type of the flail - Rectangle type2BodyFrame = new Rectangle(0, BodyType2StartY, FlailTexture.Width, BodyType2SectionHeight); - if (speed > 0f) - { - float counter = 0f; - while (counter + 1f < speed) + if (lightingCol != Color.Transparent) { - if (speed - counter < type2BodyFrame.Height) - { - type2BodyFrame.Height = (int)(speed - counter); - } - Main.EntitySpriteDraw(FlailTexture, - bodyDrawPosition - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, - new Rectangle?(type2BodyFrame), - lightColor, - Projectile.rotation + MathHelper.Pi, - new Vector2(type2BodyFrame.Width / 2, 0f), - Projectile.scale, - SpriteEffects.None, - 0); - counter += type2BodyFrame.Height * Projectile.scale; - bodyDrawPosition += normalizedVelocity * type2BodyFrame.Height * Projectile.scale; + Lighting.AddLight((Vector2)tip, lightingCol.R / 255f, lightingCol.G / 255f, lightingCol.B / 255f); } + } } - /// - /// Draws the tail of the whip. - /// - /// The position to draw the tail. - /// The color to use when drawing. - public void DrawWhipTail(in Vector2 whipEndPosition, in Color lightColor) - { - Rectangle tailFrame = new Rectangle(0, TailStartY, FlailTexture.Width, TailHeight); - Main.EntitySpriteDraw(FlailTexture, - whipEndPosition - Main.screenPosition + Vector2.UnitY * Main.player[Projectile.owner].gfxOffY, - new Rectangle?(tailFrame), - lightColor, - Projectile.rotation + MathHelper.Pi, - FlailTexture.Frame(1, 1, 0, 0).Top(), - Projectile.scale, - SpriteEffects.None, - 0); - } #endregion + + - #region Collision and Grass Cut Logic - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 unit = Projectile.velocity; - Utils.PlotTileLine(Projectile.Center, Projectile.Center + unit, Projectile.width * Projectile.scale, DelegateMethods.CutTiles); - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (projHitbox.Intersects(targetHitbox)) - { - return true; - } - float _ = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity, 16f * Projectile.scale, ref _)) - { - return true; - } - return false; - } - #endregion + } } diff --git a/Projectiles/BaseProjectiles/BaseWormProjectile.cs b/Projectiles/BaseProjectiles/BaseWormProjectile.cs new file mode 100644 index 0000000000..b7c1765bb6 --- /dev/null +++ b/Projectiles/BaseProjectiles/BaseWormProjectile.cs @@ -0,0 +1,336 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CalamityMod.NPCs; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.BaseProjectiles +{ + /// + /// Implementation to make ModProjectile worms much easier to make. + /// Modified version of BaseWormNPC to function on a ModProjectile instead of ModNPC + /// + public abstract class BaseWormProjectile : ModProjectile + { + #region Abstracts / Commonly Overridden Fields + /// + /// The amount of segments of this worm. This does not include the head + /// + public abstract int SegmentCount { get; } + /// + /// A list of the offsets to the next segment in the worm from this segment + /// DOES include the head + /// + public abstract List SegmentTypePositionOffsets { get; } + /// + /// A list of all textures for the segments to draw with + /// does NOT include the head + /// + public abstract List SegmentTextures { get; } + /// + /// Offsets for drawing each segment + /// + public List SegmentTypeDrawOffsets = new List(); + + /// + /// A list of all glow textures for the segments to draw with + /// DOES include the head + /// + public virtual List GlowTextures { get; } + + /// + /// How far through the current animation this worm is + /// + public float AnimationFrame = 0; + /// + /// The active animation for the worm + /// + public WormAnimation ActiveAnimation = null; + #endregion + #region Segments + /// + /// The textures for each segment type of this worm. Works like getting a texture from TextureAssets + /// + public List> SegmentTextureAssets + { + get + { + if (internalTexAssets.Count == 0) + for (var i = 0; i < SegmentTextures.Count; i++) + { + internalTexAssets.Add(ModContent.Request(SegmentTextures[i])); + if (SegmentTypeDrawOffsets.Count <= i) + { + SegmentTypeDrawOffsets.Add(Vector2.Zero); + } + } + return internalTexAssets; + } + } + + /// + /// Internal list that stores the textureassets. + /// Use SegmentTextureAssets to get the data stored here. + /// + private List> internalTexAssets = new List>(); + /// + /// The textures for each glow type of this worm. Works like getting a texture from TextureAssets + /// + public List> GlowTextureAssets + { + get + { + if (internalGlowAssets.Count == 0) + for (var i = 0; i < GlowTextures.Count; i++) + { + if (GlowTextures[i] is not null) + internalGlowAssets.Add(ModContent.Request(GlowTextures[i])); + else internalGlowAssets.Add(ModContent.Request("CalamityMod/Projectiles/InvisibleProj")); + } + return internalGlowAssets; + } + } + + /// + /// Internal list that stores the glow textureassets. + /// Use SegmentTextureAssets to get the data stored here. + /// + private List> internalGlowAssets = new List>(); + + public List Segments = new(); + + public enum SegmentFollowLogic + { + Regular = 0, //Traditional worm segment logic + Exact = 1, //Follows the path the head took exactly + // In the future, add a segment logic that supports solid tile collisions and forces applied to *any* segment + } + + /// + /// Which type of segment following logic this worm should currently use + /// + public SegmentFollowLogic SegmentFollowType; + + /// + /// How rigid the segment should be when using default segment logic + /// + public float SegmentRigidity = 0.2f; + + /// + /// The max rotational offset from the direction of the previous segment + /// + public float SegmentMaxRotation = MathHelper.TwoPi; + + /// + /// The points used by ExactSegmentLogic to exactly follow the head + /// + private List segmentPoints = new List(); + + /// + /// Updates the positions of the segments based on the value set in SegmentFollowType + /// + public void UpdateSegments() + { + Projectile.position += Projectile.velocity; //Update this segment's movement so that all other segments use this as the base. This is undone at the end of the method. + if (ActiveAnimation is not null) + { + ActiveAnimation.ApplyAnimationFrame(Projectile, AnimationFrame); + AnimationFrame++; + if (AnimationFrame > ActiveAnimation.AnimationKeyframes.Keys.Max()) + { + AnimationFrame = 0; + ActiveAnimation = null; + } + } + else + { + if (segmentPoints.Count < 1 || segmentPoints[0].Distance(Projectile.Center) > 8) + { + segmentPoints.Insert(0, Projectile.Center); + } + while (segmentPoints.Count > 300) + { + segmentPoints.RemoveAt(segmentPoints.Count - 1); + } + switch (SegmentFollowType) + { + case (SegmentFollowLogic.Regular): + RegularSegmentLogic(); + break; + case (SegmentFollowLogic.Exact): + ExactSegmentLogic(); + break; + } + } + Projectile.position -= Projectile.velocity; + + } + + private void RegularSegmentLogic() + { + for (int i = 0; i < Segments.Count; i++) + { + float segmentDistance = SegmentTypePositionOffsets[0]; + var thisSeg = Segments[i]; + var aheadSeg = new BaseWormSegment(this); + if (i != 0) + { + aheadSeg = Segments[i - 1]; + segmentDistance = SegmentTypePositionOffsets[Segments[i - 1].segmentType + 1]; + } + segmentDistance *= Projectile.scale; + Vector2 nexSegDir = aheadSeg.Center - thisSeg.Center; + if (aheadSeg.rotation != thisSeg.rotation) + { + nexSegDir = nexSegDir.RotatedBy(MathHelper.WrapAngle(aheadSeg.rotation - thisSeg.rotation) * SegmentRigidity); + nexSegDir = nexSegDir.MoveTowards((aheadSeg.rotation - thisSeg.rotation).ToRotationVector2(), 1f); + } + thisSeg.rotation = nexSegDir.ToRotation() + MathHelper.PiOver2; + float angledif = MathHelper.WrapAngle(thisSeg.rotation - aheadSeg.rotation); + thisSeg.rotation = thisSeg.rotation.AngleLerp(aheadSeg.rotation + MathHelper.Clamp(angledif, -SegmentMaxRotation * 0.5f, SegmentMaxRotation * 0.5f), 0.25f); + thisSeg.Center = aheadSeg.Center - (thisSeg.rotation - MathHelper.PiOver2).ToRotationVector2() * segmentDistance; + + } + } + + private void ExactSegmentLogic() + { + float dist = 40f; + int segmentPointInUse = 0; + for (int i = 0; i < Segments.Count; i++) + { + var thisSeg = Segments[i]; + var aheadSeg = new BaseWormSegment(this); + if (i != 0) + aheadSeg = Segments[i - 1]; + bool hasMoved = false; + while (segmentPointInUse < segmentPoints.Count) + { + if (segmentPointInUse == 0) + { + if (aheadSeg.Center.Distance(segmentPoints[0]) >= dist) + { + thisSeg.Center = aheadSeg.Center + aheadSeg.Center.DirectionTo(segmentPoints[0]) * dist; + Segments[i].velocity = Segments[i].Center.DirectionTo(aheadSeg.Center); + Segments[i].rotation = Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + hasMoved = true; + break; + } + else + { + segmentPointInUse++; + } + } + else + { + if (aheadSeg.Center.Distance(segmentPoints[segmentPointInUse]) >= dist) + { + thisSeg.Center = aheadSeg.Center + aheadSeg.Center.DirectionTo(segmentPoints[segmentPointInUse]) * dist; + Segments[i].velocity = Segments[i].Center.DirectionTo(aheadSeg.Center); + Segments[i].rotation = Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + hasMoved = true; + break; + } + else + { + segmentPointInUse++; + } + } + } + if (!hasMoved && segmentPointInUse >= segmentPoints.Count) + { + thisSeg.Center = segmentPoints[segmentPoints.Count - 1]; + Segments[i].velocity = Segments[i].Center.DirectionTo(aheadSeg.Center); + Segments[i].rotation = Segments[i].velocity.ToRotation() + MathHelper.PiOver2; + hasMoved = true; + break; + } + } + } + #endregion + + #region Defaults + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 1600; //100 tiles offscreen + } + public override void SetDefaults() + { + for (var i = 0; i < SegmentCount - 1; i++) + { + Segments.Add(new BaseWormSegment(this, 0)); + } + Segments.Add(new BaseWormSegment(this, 1)); + } + #endregion + + #region Draw + public override bool PreDraw(ref Color lightColor) + { + + for (int i = Segments.Count - 1; i >= 0; i--) + { + DrawSegment(ref lightColor, Segments[i]); + } + Main.spriteBatch.Draw(TextureAssets.Projectile[Type].Value, Projectile.Center - Main.screenPosition, null, lightColor * Projectile.Opacity, Projectile.rotation, TextureAssets.Projectile[Type].Value.Size() / 2, Projectile.scale, SpriteEffects.None, 1); + + if (GlowTextures.Count > 0 && GlowTextures[0] is not null) + Main.spriteBatch.Draw(GlowTextureAssets[0].Value, Projectile.Center - Main.screenPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, GlowTextureAssets[0].Size() / 2, Projectile.scale, SpriteEffects.None, 1); + return false; + } + + public virtual void DrawSegment(ref Color lightColor, BaseWormSegment segment) + { + var color = Lighting.GetColor(segment.Center.ToTileCoordinates()); + if (!SegmentTextureAssets.IndexInRange(segment.segmentType)) + { + return; + } + var tex = SegmentTextureAssets[segment.segmentType].Value; + Main.spriteBatch.Draw(tex, segment.Center - Main.screenPosition, null, color *segment.Opacity, segment.rotation, tex.Size() / 2 + (SegmentTypeDrawOffsets[segment.segmentType]), Projectile.scale, SpriteEffects.None, 1); + if (GlowTextures is null || !GlowTextures.IndexInRange(segment.segmentType + 1) || GlowTextures[segment.segmentType + 1] is null) + { + return; + } + tex = GlowTextureAssets[segment.segmentType + 1].Value; + Main.spriteBatch.Draw(tex, segment.Center - Main.screenPosition, null, Color.White * segment.Opacity, segment.rotation, tex.Size() / 2 + (SegmentTypeDrawOffsets[segment.segmentType]), Projectile.scale, SpriteEffects.None, 1); + } + #endregion + + #region Netcode + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(AnimationFrame); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + AnimationFrame = reader.ReadSingle(); + } + #endregion + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + for (var i = 0; i < Segments.Count; i++) + { + var prevSeg = new BaseWormSegment(this); + if (i != 0) + { + prevSeg = Segments[i - 1]; + } + float cpoint = 0; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), prevSeg.Center, Segments[i].Center, 16, ref cpoint)) + { + return true; + } + } + return base.Colliding(projHitbox, targetHitbox); + } + } +} diff --git a/Projectiles/Boss/ApolloChargeTelegraph.cs b/Projectiles/Boss/ApolloChargeTelegraph.cs index b038018e4c..c745682939 100644 --- a/Projectiles/Boss/ApolloChargeTelegraph.cs +++ b/Projectiles/Boss/ApolloChargeTelegraph.cs @@ -37,12 +37,11 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - Projectile.timeLeft = bossRush ? 45 : death ? 60 : revenge ? 68 : expertMode ? 75 : 90; + Projectile.timeLeft = death ? 60 : revenge ? 68 : expertMode ? 75 : 90; if (Main.getGoodWorld) Projectile.timeLeft /= 2; } @@ -78,13 +77,12 @@ namespace CalamityMod.Projectiles.Boss } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Determine opacity - float telegraphTotalTime = bossRush ? 45f : death ? 60f : revenge ? 68f : expertMode ? 75f : 90f; + float telegraphTotalTime = death ? 60f : revenge ? 68f : expertMode ? 75f : 90f; if (Main.getGoodWorld) telegraphTotalTime *= 0.5f; @@ -96,7 +94,7 @@ namespace CalamityMod.Projectiles.Boss return new Color(255, 255, 255, Projectile.alpha); } - public Color TelegraphPrimitiveColor(float completionRatio) + public Color TelegraphPrimitiveColor(float completionRatio, Vector2 vertexPos) { float opacity = MathHelper.Lerp(0.38f, 1.2f, Projectile.Opacity); opacity *= CalamityUtils.Convert01To010(completionRatio); @@ -106,7 +104,7 @@ namespace CalamityMod.Projectiles.Boss return Color.Green * opacity; } - public float TelegraphPrimitiveWidth(float completionRatio) + public float TelegraphPrimitiveWidth(float completionRatio, Vector2 vertexPos) { return Projectile.Opacity * 15f; } @@ -127,7 +125,7 @@ namespace CalamityMod.Projectiles.Boss // It is not used anywhere else. Projectile.ai[0] = i; - PrimitiveRenderer.RenderTrail(positions, new(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, (_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:Flame"]), 55); + PrimitiveRenderer.RenderTrail(positions, new(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, (_,_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:Flame"]), 55); } return false; } diff --git a/Projectiles/Boss/ApolloFireball.cs b/Projectiles/Boss/ApolloFireball.cs index f89f8ea341..dd2889b4c0 100644 --- a/Projectiles/Boss/ApolloFireball.cs +++ b/Projectiles/Boss/ApolloFireball.cs @@ -1,9 +1,8 @@ using System; using System.IO; -using CalamityMod.Events; using CalamityMod.NPCs; +using CalamityMod.NPCs.ExoMechs.Apollo; using CalamityMod.Sounds; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -35,7 +34,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; Projectile.Opacity = 0f; CooldownSlot = ImmunityCooldownID.Bosses; - Projectile.timeLeft = BossRushEvent.BossRushActive ? 48 : timeLeft; + Projectile.timeLeft = timeLeft; } public override void SendExtraAI(BinaryWriter writer) @@ -55,7 +54,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.tileCollide = true; int fadeInTime = 3; - Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - ((BossRushEvent.BossRushActive ? 48 : timeLeft) - fadeInTime)) / (float)fadeInTime), 0f, 1f); + Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); Lighting.AddLight(Projectile.Center, 0f, 0.6f * Projectile.Opacity, 0f); @@ -127,15 +126,6 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.OnFire, 360); - target.AddBuff(BuffID.CursedInferno, 180); - } - public override bool PreDraw(ref Color lightColor) { lightColor.R = (byte)(255 * Projectile.Opacity); @@ -165,7 +155,7 @@ namespace CalamityMod.Projectiles.Boss } // Plasma bolts - int totalProjectiles = BossRushEvent.BossRushActive ? 6 : 4; + int totalProjectiles = 4; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); float velocity = 0.5f; @@ -176,7 +166,7 @@ namespace CalamityMod.Projectiles.Boss for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, (int)Math.Round(Projectile.damage * 0.8), 0f, Main.myPlayer); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, Apollo.BoltDamage, 0f, Main.myPlayer); } } diff --git a/Projectiles/Boss/ApolloRocket.cs b/Projectiles/Boss/ApolloRocket.cs index 7328a7f6e0..65c5918527 100644 --- a/Projectiles/Boss/ApolloRocket.cs +++ b/Projectiles/Boss/ApolloRocket.cs @@ -118,10 +118,9 @@ namespace CalamityMod.Projectiles.Boss } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Light Lighting.AddLight(Projectile.Center, 0.2f, 1f, 0f); @@ -131,7 +130,7 @@ namespace CalamityMod.Projectiles.Boss Vector2 distanceFromTarget = Main.player[target].Center - Projectile.Center; // Set AI to stop homing, start accelerating - float stopHomingDistance = bossRush ? 120f : death ? 160f : revenge ? 180f : expertMode ? 200f : 240f; + float stopHomingDistance = death ? 160f : revenge ? 180f : expertMode ? 200f : 240f; if (distanceFromTarget.Length() < stopHomingDistance || Projectile.ai[0] == 1f || Projectile.timeLeft < 480) { Projectile.ai[0] = 1f; @@ -144,7 +143,7 @@ namespace CalamityMod.Projectiles.Boss // Home in on target float scaleFactor = Projectile.velocity.Length(); - float inertia = bossRush ? 6f : death ? 8f : revenge ? 9f : expertMode ? 10f : 12f; + float inertia = death ? 8f : revenge ? 9f : expertMode ? 10f : 12f; distanceFromTarget.Normalize(); distanceFromTarget *= scaleFactor; Projectile.velocity = (Projectile.velocity * inertia + distanceFromTarget) / (inertia + 1f); @@ -152,8 +151,8 @@ namespace CalamityMod.Projectiles.Boss Projectile.velocity *= scaleFactor; // Fly away from other rockets - float pushForce = bossRush ? 0.07f : death ? 0.06f : revenge ? 0.055f : expertMode ? 0.05f : 0.04f; - float pushDistance = bossRush ? 120f : death ? 100f : revenge ? 90f : expertMode ? 80f : 60f; + float pushForce = death ? 0.06f : revenge ? 0.055f : expertMode ? 0.05f : 0.04f; + float pushDistance = death ? 100f : revenge ? 90f : expertMode ? 80f : 60f; for (int k = 0; k < Main.maxProjectiles; k++) { Projectile otherProj = Main.projectile[k]; @@ -179,15 +178,6 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(BuffID.OnFire, 360); - target.AddBuff(BuffID.CursedInferno, 180); - } - public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); diff --git a/Projectiles/Boss/AresDeathBeamStart.cs b/Projectiles/Boss/AresDeathBeamStart.cs index 76c213e5bf..a42cd03c9b 100644 --- a/Projectiles/Boss/AresDeathBeamStart.cs +++ b/Projectiles/Boss/AresDeathBeamStart.cs @@ -91,14 +91,13 @@ namespace CalamityMod.Projectiles.Boss } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Telegraph duration for deathray spiral - float deathrayTelegraphDuration = bossRush ? AresBody.deathrayTelegraphDuration_BossRush : death ? AresBody.deathrayTelegraphDuration_Death : - revenge ? AresBody.deathrayTelegraphDuration_Rev : expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; + float deathrayTelegraphDuration = death ? AresBody.deathrayTelegraphDuration_Death : revenge ? AresBody.deathrayTelegraphDuration_Rev : + expertMode ? AresBody.deathrayTelegraphDuration_Expert : AresBody.deathrayTelegraphDuration_Normal; Time = Main.npc[OwnerIndex].Calamity().newAI[2] - deathrayTelegraphDuration; } @@ -106,12 +105,11 @@ namespace CalamityMod.Projectiles.Boss public override void UpdateLaserMotion() { // Declare difficulty modes. - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - float angularSlowdownDivisor = bossRush ? 300f : death ? 320f : revenge ? 330f : expertMode ? 340f : 360f; + float angularSlowdownDivisor = death ? 320f : revenge ? 330f : expertMode ? 340f : 360f; float angularVelocity = MathHelper.TwoPi * Time / Lifetime / angularSlowdownDivisor; if (Main.npc[OwnerIndex].ai[3] % 2f == 0f) angularVelocity *= -1f; diff --git a/Projectiles/Boss/AresDeathBeamTelegraph.cs b/Projectiles/Boss/AresDeathBeamTelegraph.cs index 52458b6833..77e04e94a5 100644 --- a/Projectiles/Boss/AresDeathBeamTelegraph.cs +++ b/Projectiles/Boss/AresDeathBeamTelegraph.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Boss public const float deathrayTelegraphDuration_Expert = 120f; public const float deathrayTelegraphDuration_Rev = 105f; public const float deathrayTelegraphDuration_Death = 90f; - public const float deathrayTelegraphDuration_BossRush = 60f; public const float TelegraphFadeTime = 15f; public const float TelegraphWidth = 2400f; @@ -48,13 +47,12 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - Projectile.timeLeft = (int)(bossRush ? deathrayTelegraphDuration_BossRush : death ? deathrayTelegraphDuration_Death : - revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal); + Projectile.timeLeft = (int)(death ? deathrayTelegraphDuration_Death : revenge ? deathrayTelegraphDuration_Rev : + expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal); } public override void SendExtraAI(BinaryWriter writer) @@ -106,13 +104,12 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - float TelegraphTotalTime = bossRush ? deathrayTelegraphDuration_BossRush : death ? deathrayTelegraphDuration_Death : - revenge ? deathrayTelegraphDuration_Rev : expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; + float TelegraphTotalTime = death ? deathrayTelegraphDuration_Death : revenge ? deathrayTelegraphDuration_Rev : + expertMode ? deathrayTelegraphDuration_Expert : deathrayTelegraphDuration_Normal; if (TelegraphDelay >= TelegraphTotalTime) return true; diff --git a/Projectiles/Boss/AresGaussNukeProjectile.cs b/Projectiles/Boss/AresGaussNukeProjectile.cs index 116e59a084..4cc0ef0ef0 100644 --- a/Projectiles/Boss/AresGaussNukeProjectile.cs +++ b/Projectiles/Boss/AresGaussNukeProjectile.cs @@ -1,7 +1,6 @@ using System; using System.IO; using CalamityMod.Events; -using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.Skies; using CalamityMod.World; @@ -39,7 +38,7 @@ namespace CalamityMod.Projectiles.Boss CooldownSlot = ImmunityCooldownID.Bosses; Projectile.timeLeft = timeLeft; - if (Main.getGoodWorld) + if (Main.zenithWorld) Projectile.extraUpdates = 1; } @@ -72,10 +71,9 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) - MathHelper.PiOver2; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Spawn effects if (Projectile.localAI[0] == 0f) @@ -94,14 +92,14 @@ namespace CalamityMod.Projectiles.Boss float scale = Main.rand.NextFloat(0.5f, 1.6f); // Spawn dust - Dust dust = Dust.NewDustPerfect(Projectile.Center, 107, -dustVel, 0, default, scale); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Terra, -dustVel, 0, default, scale); dust.noGravity = true; } // Gauss sparks if (Main.myPlayer == Projectile.owner) { - int totalProjectiles = bossRush ? 18 : 12; + int totalProjectiles = 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); float velocity = Projectile.velocity.Length(); @@ -112,7 +110,7 @@ namespace CalamityMod.Projectiles.Boss for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2 + Vector2.Normalize(Projectile.velocity) * -6f, type, (int)Math.Round(Projectile.damage * 0.5), 0f, Main.myPlayer); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2 + Vector2.Normalize(Projectile.velocity) * -6f, type, AresGaussNuke.SparkDamage, 0f, Main.myPlayer); } } } @@ -124,8 +122,15 @@ namespace CalamityMod.Projectiles.Boss int target = Player.FindClosest(Projectile.Center, 1, 1); Vector2 distanceFromTarget = Main.player[target].Center - Projectile.Center; + // Instant explode upon collision with the target + if (CalamityUtils.CircularHitboxCollision(Projectile.Center, 45f, Main.player[target].Hitbox)) + { + Projectile.Kill(); + return; + } + // Set AI to stop homing, start accelerating - float stopHomingDistance = bossRush ? 260f : death ? 280f : revenge ? 290f : expertMode ? 300f : 320f; + float stopHomingDistance = death ? 280f : revenge ? 290f : expertMode ? 300f : 320f; if ((distanceFromTarget.Length() < stopHomingDistance && Projectile.ai[0] != -1f) || Projectile.ai[0] == 1f) { Projectile.ai[0] = 1f; @@ -138,7 +143,7 @@ namespace CalamityMod.Projectiles.Boss // Home in on target float scaleFactor = Projectile.velocity.Length(); - float inertia = bossRush ? 6f : death ? 8f : revenge ? 9f : expertMode ? 10f : 12f; + float inertia = death ? 8f : revenge ? 9f : expertMode ? 10f : 12f; distanceFromTarget.Normalize(); distanceFromTarget *= scaleFactor; Projectile.velocity = (Projectile.velocity * inertia + distanceFromTarget) / (inertia + 1f); @@ -176,7 +181,8 @@ namespace CalamityMod.Projectiles.Boss Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Boss/AresGaussNukeProjectileGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 45f, targetHitbox); + // Does not do damage by itself, only through the explosion + public override bool? CanDamage() => false; public override void OnKill(int timeLeft) { @@ -198,7 +204,7 @@ namespace CalamityMod.Projectiles.Boss // Explosion waves for (int i = 0; i < 3; i++) { - Projectile explosion = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer); + Projectile explosion = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), i == 2 ? Projectile.damage : 0, 0f, Main.myPlayer); if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) { // Make the max explosion radius decrease over time, creating a ring effect. diff --git a/Projectiles/Boss/AresGaussNukeProjectileBoom.cs b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs index fabc0a19b7..1d60927f9f 100644 --- a/Projectiles/Boss/AresGaussNukeProjectileBoom.cs +++ b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; @@ -29,6 +30,8 @@ namespace CalamityMod.Projectiles.Boss } public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + private List PlayersHit = new List() { -1 }; + public override void SetStaticDefaults() { ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; @@ -48,14 +51,8 @@ namespace CalamityMod.Projectiles.Boss public override void PostAI() => Lighting.AddLight(Projectile.Center, 0.2f, 0.1f, 0f); - public override bool CanHitPlayer(Player target) => CalamityUtils.CircularHitboxCollision(Projectile.Center, CurrentRadius * Projectile.scale * 0.4f, target.Hitbox) && Projectile.timeLeft > 6; + public override bool CanHitPlayer(Player target) => CalamityUtils.CircularHitboxCollision(Projectile.Center, CurrentRadius * Projectile.scale * 0.4f, target.Hitbox) && Projectile.timeLeft > 6 && !PlayersHit.Contains(target.whoAmI); - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(BuffID.OnFire, 480); - } + public override void OnHitPlayer(Player target, Player.HurtInfo info) => PlayersHit.Add(target.whoAmI); } } diff --git a/Projectiles/Boss/AresGaussNukeProjectileSpark.cs b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs index dc29973504..c3bd6ab250 100644 --- a/Projectiles/Boss/AresGaussNukeProjectileSpark.cs +++ b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs @@ -77,14 +77,6 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.OnFire, 180); - } - public override bool PreDraw(ref Color lightColor) { lightColor.R = (byte)(255 * Projectile.Opacity); diff --git a/Projectiles/Boss/AresLaserBeamStart.cs b/Projectiles/Boss/AresLaserBeamStart.cs index fd96c14180..f3d9f29a6d 100644 --- a/Projectiles/Boss/AresLaserBeamStart.cs +++ b/Projectiles/Boss/AresLaserBeamStart.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.NPCs; using CalamityMod.NPCs.ExoMechs.Ares; @@ -228,14 +227,6 @@ namespace CalamityMod.Projectiles.Boss return false; } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 150); - } - public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f; } } diff --git a/Projectiles/Boss/AresPlasmaBolt.cs b/Projectiles/Boss/AresPlasmaBolt.cs index adba705b56..923848fd8f 100644 --- a/Projectiles/Boss/AresPlasmaBolt.cs +++ b/Projectiles/Boss/AresPlasmaBolt.cs @@ -22,7 +22,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 18; Projectile.height = 18; Projectile.hostile = true; @@ -70,15 +69,6 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.OnFire, 180); - target.AddBuff(BuffID.CursedInferno, 90); - } - public override bool PreDraw(ref Color lightColor) { lightColor.R = (byte)(255 * Projectile.Opacity); diff --git a/Projectiles/Boss/AresPlasmaFireball.cs b/Projectiles/Boss/AresPlasmaFireball.cs index c214b13881..52afa6e287 100644 --- a/Projectiles/Boss/AresPlasmaFireball.cs +++ b/Projectiles/Boss/AresPlasmaFireball.cs @@ -1,9 +1,8 @@ using System; using System.IO; -using CalamityMod.Events; using CalamityMod.NPCs; +using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.Sounds; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -26,7 +25,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 36; Projectile.height = 36; Projectile.hostile = true; @@ -35,7 +33,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; Projectile.Opacity = 0f; CooldownSlot = ImmunityCooldownID.Bosses; - Projectile.timeLeft = BossRushEvent.BossRushActive ? 96 : timeLeft; + Projectile.timeLeft = timeLeft; } public override void SendExtraAI(BinaryWriter writer) @@ -58,7 +56,7 @@ namespace CalamityMod.Projectiles.Boss } int fadeInTime = 3; - Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - ((BossRushEvent.BossRushActive ? 96 : timeLeft) - fadeInTime)) / (float)fadeInTime), 0f, 1f); + Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); Lighting.AddLight(Projectile.Center, 0f, 0.6f * Projectile.Opacity, 0f); @@ -126,15 +124,6 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.OnFire, 360); - target.AddBuff(BuffID.CursedInferno, 180); - } - public override bool PreDraw(ref Color lightColor) { lightColor.R = (byte)(255 * Projectile.Opacity); @@ -164,7 +153,7 @@ namespace CalamityMod.Projectiles.Boss } // Plasma bolts - int totalProjectiles = BossRushEvent.BossRushActive ? 12 : 8; + int totalProjectiles = 8; // Reduce the total amount of projectiles by half if Ares Plasma Arm is shooting them and in deathray phase and not the last mech if (Projectile.ai[0] == -1f) @@ -180,7 +169,7 @@ namespace CalamityMod.Projectiles.Boss for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, (int)Math.Round(Projectile.damage * 0.8), 0f, Main.myPlayer); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, AresPlasmaFlamethrower.BoltDamage, 0f, Main.myPlayer); } } diff --git a/Projectiles/Boss/AresTeslaOrb.cs b/Projectiles/Boss/AresTeslaOrb.cs index 4878f29a10..07957ea876 100644 --- a/Projectiles/Boss/AresTeslaOrb.cs +++ b/Projectiles/Boss/AresTeslaOrb.cs @@ -149,12 +149,11 @@ namespace CalamityMod.Projectiles.Boss return null; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - float detachDistance = bossRush ? 1600f : death ? 1360f : revenge ? 1280f : expertMode ? 1200f : 960f; + float detachDistance = death ? 1360f : revenge ? 1280f : expertMode ? 1200f : 960f; foreach (Projectile p in Main.ActiveProjectiles) { if (p.type != Projectile.type || p.ai[0] != Identity + 1f || Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays) @@ -203,21 +202,21 @@ namespace CalamityMod.Projectiles.Boss return points; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return MathHelper.Lerp(0.75f, 1.85f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * Projectile.scale; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeToWhite = MathHelper.Lerp(0f, 0.65f, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); Color baseColor = Color.Lerp(Color.Cyan, Color.White, fadeToWhite); return Color.Lerp(baseColor, Color.LightBlue, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f) * 0.8f) * Projectile.Opacity; } - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; + internal float BackgroundWidthFunction(float completionRatio, Vector2 vertexPos) => WidthFunction(completionRatio, vertexPos) * 4f; - internal Color BackgroundColorFunction(float completionRatio) + internal Color BackgroundColorFunction(float completionRatio, Vector2 vertexPos) { Color color = Color.CornflowerBlue * Projectile.Opacity * 0.4f; return color; diff --git a/Projectiles/Boss/ArtemisChargeTelegraph.cs b/Projectiles/Boss/ArtemisChargeTelegraph.cs index 0ec7ee0a8d..758b06b91a 100644 --- a/Projectiles/Boss/ArtemisChargeTelegraph.cs +++ b/Projectiles/Boss/ArtemisChargeTelegraph.cs @@ -73,14 +73,14 @@ namespace CalamityMod.Projectiles.Boss return new Color(255, 255, 255, Projectile.alpha); } - public Color TelegraphPrimitiveColor(float completionRatio) + public Color TelegraphPrimitiveColor(float completionRatio, Vector2 vertexPos) { float colorInterpolant = (completionRatio * 1.2f + Main.GlobalTimeWrappedHourly * 0.26f) % 1f; float opacity = MathHelper.Lerp(0.2f, 0.425f, Projectile.Opacity) * Utils.GetLerpValue(30f, 24f, Projectile.timeLeft, true); return CalamityUtils.MulticolorLerp(colorInterpolant, Color.Orange, Color.Red, Color.Crimson, Color.Red) * opacity; } - public float TelegraphPrimitiveWidth(float completionRatio) + public float TelegraphPrimitiveWidth(float completionRatio, Vector2 vertexPos) { // Used to determine the degree to which the ends of the telegraph should smoothen away. float endSmoothenFactor = Utils.GetLerpValue(1f, 0.995f, completionRatio, true); @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Boss for (int i = 0; i < drawPositions.Length; i++) drawPositions[i] = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * TelegraphWidth * i / (drawPositions.Length - 1f); - PrimitiveRenderer.RenderTrail(drawPositions, new(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:Flame"]), 87); + PrimitiveRenderer.RenderTrail(drawPositions, new(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:Flame"]), 87); return false; } } diff --git a/Projectiles/Boss/ArtemisLaser.cs b/Projectiles/Boss/ArtemisLaser.cs index 454670d01a..a05cd14b51 100644 --- a/Projectiles/Boss/ArtemisLaser.cs +++ b/Projectiles/Boss/ArtemisLaser.cs @@ -1,8 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -107,7 +104,7 @@ namespace CalamityMod.Projectiles.Boss if (Velocity != Vector2.Zero) { Projectile.extraUpdates = Main.getGoodWorld ? 4 : 3; - Projectile.velocity = Velocity * (BossRushEvent.BossRushActive ? 1.25f : 1f); + Projectile.velocity = Velocity; Velocity = Vector2.Zero; Projectile.netUpdate = true; } @@ -195,14 +192,6 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || TelegraphDelay <= TelegraphTotalTime) - return; - - target.AddBuff(ModContent.BuffType(), 90); - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { return CalamityUtils.CircularHitboxCollision(projHitbox.Center(), Projectile.Size.Length() * 0.5f, targetHitbox); diff --git a/Projectiles/Boss/ArtemisSpinLaserbeam.cs b/Projectiles/Boss/ArtemisSpinLaserbeam.cs index 08b27e1575..e6e3ece013 100644 --- a/Projectiles/Boss/ArtemisSpinLaserbeam.cs +++ b/Projectiles/Boss/ArtemisSpinLaserbeam.cs @@ -119,9 +119,9 @@ namespace CalamityMod.Projectiles.Boss Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; } - public float LaserWidthFunction(float _) => Projectile.scale * Projectile.width; + public float LaserWidthFunction(float _, Vector2 vertexPos) => Projectile.scale * Projectile.width; - public static Color LaserColorFunction(float completionRatio) + public static Color LaserColorFunction(float completionRatio, Vector2 vertexPos) { float colorInterpolant = (float)Math.Sin(Main.GlobalTimeWrappedHourly * -3.2f + completionRatio * 23f) * 0.5f + 0.5f; return Color.Lerp(Color.Orange, Color.Red, colorInterpolant * 0.67f); @@ -151,7 +151,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(ModContent.BuffType(), 300); } public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f; diff --git a/Projectiles/Boss/AstralFlame.cs b/Projectiles/Boss/AstralFlame.cs index 99629bc81a..b3c3cdd0de 100644 --- a/Projectiles/Boss/AstralFlame.cs +++ b/Projectiles/Boss/AstralFlame.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 50; Projectile.height = 50; Projectile.hostile = true; @@ -33,17 +32,16 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = 1; Projectile.timeLeft = 600; - if (Main.getGoodWorld) + if (Main.zenithWorld) Projectile.extraUpdates = 1; } public override void AI() { // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; Projectile.frameCounter++; if (Projectile.frameCounter > 4) @@ -104,8 +102,8 @@ namespace CalamityMod.Projectiles.Boss // Move away from other flames if (Projectile.ai[0] >= 60f) { - float pushForce = bossRush ? 0.07f : death ? 0.06f : revenge ? 0.055f : expertMode ? 0.05f : 0.04f; - float pushDistance = bossRush ? 180f : death ? 150f : revenge ? 135f : expertMode ? 120f : 90f; + float pushForce = death ? 0.06f : revenge ? 0.055f : expertMode ? 0.05f : 0.04f; + float pushDistance = death ? 150f : revenge ? 135f : expertMode ? 120f : 90f; for (int k = 0; k < Main.maxProjectiles; k++) { Projectile otherProj = Main.projectile[k]; @@ -150,7 +148,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 75); + target.AddBuff(ModContent.BuffType(), 120); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Boss/AstralGodRay.cs b/Projectiles/Boss/AstralGodRay.cs index bca3fb8b44..1dabcb8439 100644 --- a/Projectiles/Boss/AstralGodRay.cs +++ b/Projectiles/Boss/AstralGodRay.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 75); + target.AddBuff(ModContent.BuffType(), 120); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Boss/AstralLaser.cs b/Projectiles/Boss/AstralLaser.cs index f81ffeeeac..af2e96b9ad 100644 --- a/Projectiles/Boss/AstralLaser.cs +++ b/Projectiles/Boss/AstralLaser.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Boss return; if (Projectile.timeLeft >= 85) - target.AddBuff(ModContent.BuffType(), 45); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Boss/AstralShot2.cs b/Projectiles/Boss/AstralShot2.cs index 82f15bd2a2..8b979fdd2e 100644 --- a/Projectiles/Boss/AstralShot2.cs +++ b/Projectiles/Boss/AstralShot2.cs @@ -1,7 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -37,11 +35,10 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[0] == 1f) { Projectile.extraUpdates = 2; - bool bossRush = BossRushEvent.BossRushActive; - float maxVelocity = bossRush ? 3.75f : 3f; + float maxVelocity = 3f; if (Projectile.velocity.Length() < maxVelocity) { - Projectile.velocity *= bossRush ? 1.02f : 1.015f; + Projectile.velocity *= 1.015f; if (Projectile.velocity.Length() > maxVelocity) { Projectile.velocity.Normalize(); @@ -78,7 +75,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 45); + target.AddBuff(ModContent.BuffType(), 60); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Boss/BirbAura.cs b/Projectiles/Boss/BirbAura.cs index bf325251d8..d3e0fc4f53 100644 --- a/Projectiles/Boss/BirbAura.cs +++ b/Projectiles/Boss/BirbAura.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; Projectile.tileCollide = false; Projectile.timeLeft = 1200; + Projectile.Calamity().DealsDefenseDamage = true; } public override void SendExtraAI(BinaryWriter writer) diff --git a/Projectiles/Boss/BirbAuraFlare.cs b/Projectiles/Boss/BirbAuraFlare.cs index cb17ddd3fd..7b77bda05b 100644 --- a/Projectiles/Boss/BirbAuraFlare.cs +++ b/Projectiles/Boss/BirbAuraFlare.cs @@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Boss float y = projTileX * 16 + 900; Vector2 laserVelocity = new Vector2(x, 160f) - new Vector2(x, y); int type = ModContent.ProjectileType(); - int damage = Projectile.GetProjectileDamage(ModContent.NPCType()); + int damage = Dragonfolly.LightningDamage; if (Projectile.ai[0] >= 2f) { x += 1000f; diff --git a/Projectiles/Boss/BrainOfCthulhu/BloodScythe.cs b/Projectiles/Boss/BrainOfCthulhu/BloodScythe.cs new file mode 100644 index 0000000000..2a05b796be --- /dev/null +++ b/Projectiles/Boss/BrainOfCthulhu/BloodScythe.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu; + +public class BloodScythe : ModProjectile, ILocalizedModType +{ + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Particles/VerticalSmearRagged"; + + private Vector2 InitialVelocity = Vector2.Zero; + private Vector2 AcceleratingVelocity = Vector2.Zero; + private static float RotationSpeed => MathHelper.Pi / 8f; + private static float Acceleration => 0.175f; + private static int Lifetime => 240; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 16; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 300; + Projectile.height = 300; + Projectile.penetrate = -1; + Projectile.Opacity = 1f; + Projectile.tileCollide = false; + Projectile.timeLeft = Lifetime; + Projectile.damage = 10; + Projectile.scale = 0.1f; + Projectile.hostile = true; + } + + public override void OnSpawn(IEntitySource source) + { + InitialVelocity = Projectile.velocity; + Projectile.rotation = Projectile.velocity.ToRotation(); + for (int i = 0; i < 3; i++) + { + BloodParticle p = new(Projectile.Center, Projectile.velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.5f, 1f), 32, 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + BloodParticle2 p2 = new(Projectile.Center, Projectile.velocity * 0.75f, 16, 0.5f, Color.Red); + GeneralParticleHandler.SpawnParticle(p2); + } + + public override void AI() + { + int UpTime = Lifetime - Projectile.timeLeft; + InitialVelocity *= 0.925f; + if (UpTime > 15) + { + AcceleratingVelocity += Projectile.velocity.SafeNormalize(InitialVelocity.SafeNormalize(Vector2.UnitX)) * Acceleration; + if (Main.rand.NextBool(1 + Projectile.timeLeft / 32)) + { + BloodParticle p = new(Projectile.Center + Main.rand.NextVector2CircularEdge(32, 32), (-Projectile.velocity).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.25f, 0.75f), Main.rand.Next(10, 17), 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + } + Projectile.velocity = InitialVelocity + AcceleratingVelocity; + Projectile.rotation += RotationSpeed; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WritePackedVector2(InitialVelocity); + writer.WritePackedVector2(AcceleratingVelocity); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + InitialVelocity = reader.ReadPackedVector2(); + AcceleratingVelocity = reader.ReadPackedVector2(); + } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + Texture2D tex = TextureAssets.Projectile[Type].Value; + Vector2 drawPos = Projectile.Center - Main.screenPosition; + Color drawColor = Color.Red; + if (!ChildSafety.Disabled) + drawColor = Main.DiscoColor; + + if (CalamityClientConfig.Instance.Afterimages) + { + for (int i = 0; i < Projectile.oldPos.Length; ++i) + { + float afterimageRot = Projectile.oldRot[i]; + drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + if (i != 0) + drawColor *= 0.9f; + + // DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES. + float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); + Main.spriteBatch.Draw(tex, drawPos, null, drawColor, afterimageRot, tex.Size() * 0.5f, Projectile.scale * interpolant, SpriteEffects.None, 0f); + } + } + //else + // Main.EntitySpriteDraw(tex, drawPos, tex.Frame(), drawColor, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + + return false; + } +} + +public class CirclingBloodScythe : ModProjectile, ILocalizedModType +{ + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Particles/VerticalSmearRagged"; + + private static float RotationSpeed => MathHelper.Pi / 8f; + private static int Lifetime => BrainOfCthulhuAI.CrimsonEyeAttackDuration; + private static float MaxCircleSpeed => MathHelper.Pi / 30f; //1 rev per second + + ref float CircleAngle => ref Projectile.ai[0]; + ref float CircleRadius => ref Projectile.ai[1]; + ref float CircleRadiusVelocity => ref Projectile.ai[2]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 16; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 300; + Projectile.height = 300; + Projectile.penetrate = -1; + Projectile.Opacity = 1f; + Projectile.tileCollide = false; + Projectile.timeLeft = Lifetime; + Projectile.damage = 10; + Projectile.scale = 0.1f; + Projectile.hostile = true; + } + + public override void OnSpawn(IEntitySource source) + { + Projectile.rotation = CircleAngle; + for (int i = 0; i < 3; i++) + { + BloodParticle p = new(Projectile.Center, Projectile.velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.5f, 1f), 32, 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + BloodParticle2 p2 = new(Projectile.Center, Projectile.velocity * 0.75f, 16, 0.5f, Color.Red); + GeneralParticleHandler.SpawnParticle(p2); + } + + public override void AI() + { + if (NPC.crimsonBoss == -1) + { + Projectile.active = false; + return; + } + int UpTime = Lifetime - Projectile.timeLeft; + + if (UpTime < 30f) + CircleRadius = MathHelper.Lerp(0f, 128f, CalamityUtils.CircOutEasing(UpTime / 30f, 1)); + else if (UpTime < Lifetime - 180) + CircleRadius = 128f; + else + { + if (UpTime == Lifetime - 180) + CircleRadiusVelocity = -3f; + CircleRadius += CircleRadiusVelocity; + CircleRadiusVelocity += 0.1f; + } + + if (UpTime >= 15f) + { + if (UpTime < 30f) + CircleAngle += MathHelper.Lerp(0f, MaxCircleSpeed, CalamityUtils.SineInEasing((UpTime - 15) / 15f, 1)); + else if (UpTime < 870) + CircleAngle += MaxCircleSpeed; + else if (UpTime < 900) + CircleAngle += MathHelper.Lerp(MaxCircleSpeed, MaxCircleSpeed / 3f, CalamityUtils.SineOutEasing((UpTime - 870) / 30f, 1)); + else + CircleAngle += MaxCircleSpeed / 3f; + + if (Main.rand.NextBool(6)) + { + BloodParticle p = new(Projectile.Center + Main.rand.NextVector2CircularEdge(32, 32), (Projectile.DirectionTo(Main.npc[NPC.crimsonBoss].Center).RotatedBy(MathHelper.PiOver2) * 16f).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.25f, 0.75f), Main.rand.Next(10, 17), 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + } + + NPC boss = Main.npc[NPC.crimsonBoss]; + + Projectile.Center = boss.Center + (CircleAngle.ToRotationVector2() * CircleRadius); + Projectile.rotation += RotationSpeed; + } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + Texture2D tex = TextureAssets.Projectile[Type].Value; + Vector2 drawPos = Projectile.Center - Main.screenPosition; + Color drawColor = Color.Red; + if (!ChildSafety.Disabled) + drawColor = Main.DiscoColor; + + if (CalamityClientConfig.Instance.Afterimages) + { + for (int i = 0; i < Projectile.oldPos.Length; ++i) + { + float afterimageRot = Projectile.oldRot[i]; + drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + if (i != 0) + drawColor *= 0.9f; + // DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES. + float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); + Main.spriteBatch.Draw(tex, drawPos, null, drawColor, afterimageRot, tex.Size() * 0.5f, Projectile.scale * interpolant, SpriteEffects.None, 0f); + } + } + else + Main.EntitySpriteDraw(tex, drawPos, tex.Frame(), drawColor, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + + return false; + } +} + diff --git a/Projectiles/Boss/BrainOfCthulhu/CrimsonEye.cs b/Projectiles/Boss/BrainOfCthulhu/CrimsonEye.cs new file mode 100644 index 0000000000..59747e4788 --- /dev/null +++ b/Projectiles/Boss/BrainOfCthulhu/CrimsonEye.cs @@ -0,0 +1,200 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu; + +public class CrimsonEye : ModProjectile, ILocalizedModType +{ + public new string LocalizationCategory => "Projectiles.Boss"; + + private ref float Time => ref Projectile.ai[0]; + private ref float DistanceRatio => ref Projectile.ai[1]; + private ref float ExplosionTime => ref Projectile.ai[2]; + + private static float TimeToExplode => 30f; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.DontAttachHideToAlpha[Type] = true; + Main.projFrames[Type] = 5; + } + + public override void SetDefaults() + { + Projectile.width = 100; + Projectile.height = 36; + Projectile.penetrate = -1; + Projectile.Opacity = 1f; + Projectile.tileCollide = false; + Projectile.timeLeft = 300; + Projectile.scale = 1; + Projectile.hostile = false; + Projectile.hide = true; + } + + public override void OnSpawn(IEntitySource source) + { + for (int i = 0; i < 32; i++) + Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Crimstone); + } + + public override void AI() + { + if (Time > 45) + { + Player closest = Main.player[Player.FindClosest(Projectile.position, Projectile.width, Projectile.height)]; + DistanceRatio = 1 - MathHelper.Clamp((Projectile.Center.Distance(closest.Center) - 128) / 120f, 0f, 1f); + + if (DistanceRatio >= 1 && Projectile.frame == 4) + { + if (Projectile.timeLeft < 120) + Projectile.timeLeft = 120; + + if (ExplosionTime == TimeToExplode) + { + Projectile.hostile = true; + DetailedExplosion explosion = new(Projectile.Center, Vector2.Zero, Color.Orange, Vector2.One, Main.rand.NextFloatDirection(), 0.3f, 0.9f, 24); + GeneralParticleHandler.SpawnParticle(explosion); + + Projectile.Resize(256, 256); + } + else if (Projectile.width == 256) + Projectile.active = false; + + ExplosionTime++; + } + else + { + if (ExplosionTime > 0) + ExplosionTime--; + + if (Projectile.width == 256) + Projectile.active = false; + } + + if (Time > 65) + { + if (Projectile.timeLeft <= 20) + Projectile.frame = (Projectile.timeLeft - 5) / 5; + else + Projectile.frame = 4; + } + else if (Time % 5 == 0) + Projectile.frame++; + } + Time++; + } + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + behindNPCsAndTiles.Add(index); + } + + public override bool PreDraw(ref Color lightColor) + { + if (ExplosionTime >= TimeToExplode) + return false; + + if (ExplosionTime > 0) + { + float ratio = ExplosionTime / TimeToExplode; + + Vector3 lightLevels = lightColor.ToVector3(); + float lightLevel = (lightLevels.X + lightLevels.Y + lightLevels.Z) / 3f; + lightColor = Color.Lerp(lightColor, Color.Lerp(Color.Red, Color.Gold, (float)Math.Sin(ExplosionTime / 4f) / 2f + 0.5f) * lightLevel, ratio); + lightColor.A = 255; + } + + return true; + } + + public override void PostDraw(Color lightColor) + { + if (ExplosionTime >= TimeToExplode) + return; + + float ratio = CalamityUtils.SineOutEasing(ExplosionTime / TimeToExplode, 1); + + if (Projectile.frame == 4) + { + Texture2D tex = ModContent.Request(Texture + "Pupil").Value; + Vector2 rangeScale = new Vector2(2.25f, 0.75f); + Vector2 dir = Projectile.DirectionTo(Main.LocalPlayer.Center); + if (ExplosionTime > 0) + { + if (ratio < 0.25f) + dir = Vector2.Lerp(dir, Vector2.Zero, ratio * 4f); + else + dir = Main.rand.NextVector2CircularEdge(1, 1); + } + + if (Projectile.timeLeft <= 50) + dir *= (Projectile.timeLeft - 20) / 30f; + + float range = 6f; + if (ratio > 0.25f) + { + range = MathHelper.Lerp(0f, 6f, (ratio - 0.25f) * 0.75f); + } + else if (Time < 85) + { + float lerp = CalamityUtils.SineOutEasing((Time - 65) / 20f, 1); + range = MathHelper.Lerp(0f, range, lerp); + } + + Main.EntitySpriteDraw(tex, Projectile.Center + (dir * rangeScale * range) - Main.screenPosition, null, lightColor, 0, tex.Size() * 0.5f, 1f, 0); + } + + if (DistanceRatio > 0) + { + /* + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D tex = ModContent.Request("CalamityMod/Particles/HollowCircleHardEdge").Value; + Color color = Color.Red * DistanceRatio; + if (Time <= 65) + color *= (Time - 45) / 20f; + + if (Projectile.timeLeft <= 20) + color *= Projectile.timeLeft / 20f; + + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, color, 0f, tex.Size() * 0.5f, 1.75f, 0); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + */ + + float opacity = DistanceRatio; + if (Time <= 65) + opacity *= (Time - 45) / 20f; + + if (Projectile.timeLeft <= 20) + opacity *= Projectile.timeLeft / 20f; + + Main.spriteBatch.EnterShaderRegion(); + Texture2D telegraphBase = ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseColor(Color.Lerp(Color.Red, Color.OrangeRed, 0.7f * (float)Math.Pow(0.5 + 0.5 * Math.Sin(Main.GlobalTimeWrappedHourly), 3))); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSecondaryColor(Color.Lerp(Color.Yellow, Color.White, 0.5f)); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSaturation(ratio * 0.5f + 0.5f); + + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].Apply(); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, lightColor, 0, telegraphBase.Size() / 2f, 248f, 0, 0); + Main.spriteBatch.ExitShaderRegion(); + } + } +} + diff --git a/Projectiles/Boss/BrainOfCthulhu/CrimsonEye.png b/Projectiles/Boss/BrainOfCthulhu/CrimsonEye.png new file mode 100644 index 0000000000..f1c6c86e31 Binary files /dev/null and b/Projectiles/Boss/BrainOfCthulhu/CrimsonEye.png differ diff --git a/Projectiles/Boss/BrainOfCthulhu/CrimsonEyePupil.png b/Projectiles/Boss/BrainOfCthulhu/CrimsonEyePupil.png new file mode 100644 index 0000000000..1b54109f29 Binary files /dev/null and b/Projectiles/Boss/BrainOfCthulhu/CrimsonEyePupil.png differ diff --git a/Projectiles/Boss/BrainOfCthulhu/IchorShower.cs b/Projectiles/Boss/BrainOfCthulhu/IchorShower.cs new file mode 100644 index 0000000000..0af2bbb0ae --- /dev/null +++ b/Projectiles/Boss/BrainOfCthulhu/IchorShower.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu; + +public class IchorShower : ModProjectile, ILocalizedModType +{ + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 8; + Projectile.height = 8; + Projectile.penetrate = -1; + Projectile.Opacity = 1f; + Projectile.tileCollide = false; + Projectile.timeLeft = 480; + Projectile.damage = 10; + Projectile.scale = 1; + Projectile.hostile = true; + Projectile.extraUpdates = 1; + } + + public override void AI() + { + for (int i = 0; i < 3; i++) + Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), DustID.Ichor, Vector2.Zero).noGravity = true; + if (Main.rand.NextBool(8)) + Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), DustID.GoldFlame, Vector2.UnitX * Projectile.velocity / 10f, Scale: 0.75f); + Projectile.velocity.Y += 0.075f; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(BuffID.Ichor, 600); + } +} + diff --git a/Projectiles/Boss/BrainOfCthulhu/TelekineticBlast.cs b/Projectiles/Boss/BrainOfCthulhu/TelekineticBlast.cs new file mode 100644 index 0000000000..9289e9b070 --- /dev/null +++ b/Projectiles/Boss/BrainOfCthulhu/TelekineticBlast.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu; + +public class TelekineticBlast : ModProjectile, ILocalizedModType +{ + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.penetrate = -1; + Projectile.Opacity = 1f; + Projectile.tileCollide = false; + Projectile.timeLeft = 1; + Projectile.damage = 0; + Projectile.scale = 1; + Projectile.hostile = true; + } + + Player target => Main.player[(int)Projectile.ai[0]]; + float debuffMultiplier => Projectile.ai[1]; + + public override void AI() + { + for (int i = 0; i < 6; i++) + { + Vector2 dir = target.Center - Projectile.Center; + int lifeTime = 24; + dir /= lifeTime / 2f * 5f; + dir *= i; + DirectionalPulseRing pulse = new(Projectile.Center, dir, i % 2 == 0 ? Color.Red : Color.Orange, new Vector2(0.5f, 1), dir.ToRotation(), 0f, i / 5f, lifeTime + 8); + GeneralParticleHandler.SpawnParticle(pulse); + } + + SoundEngine.PlaySound(BrainOfCthulhuAI.Laugh, Projectile.Center); + target.AddBuff(BuffID.Darkness, (int)Math.Round(900 * debuffMultiplier)); + target.AddBuff(BuffID.Bleeding, (int)Math.Round(900 * debuffMultiplier)); + target.AddBuff(BuffID.Confused, (int)Math.Round(60 * debuffMultiplier)); + int timeToAdd = (int)Math.Round(600 * debuffMultiplier); + int bbIndex = target.buffType.ToList().IndexOf(ModContent.BuffType()); + if (bbIndex != -1) + timeToAdd += target.buffTime[bbIndex]; + target.AddBuff(ModContent.BuffType(), timeToAdd); + + target.Calamity().adrenaline = 0; + Projectile.active = false; + } +} diff --git a/Projectiles/Boss/BrainOfCthulhu/TelekineticEnemyGrab.cs b/Projectiles/Boss/BrainOfCthulhu/TelekineticEnemyGrab.cs new file mode 100644 index 0000000000..6f4a311073 --- /dev/null +++ b/Projectiles/Boss/BrainOfCthulhu/TelekineticEnemyGrab.cs @@ -0,0 +1,393 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.DataStructures; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu; + +public class TelekineticEnemyGrab : ModProjectile, ILocalizedModType +{ + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Particles/BloomRing"; + + BezierCurve curve; + int throwSign = 0; + Vector2 throwPos = Vector2.Zero; + Vector2 holdPos; + int MyTarget = -1; + + ref float Time => ref Projectile.ai[0]; + ref float StunTime => ref Projectile.ai[1]; + + private static Dictionary EnemyGlowTextures = []; + int enemyID { get => (int)Projectile.ai[2]; set => Projectile.ai[2] = (float)value; } + + public override void SetDefaults() + { + Projectile.width = 48; + Projectile.height = 48; + Projectile.penetrate = -1; + Projectile.Opacity = 1f; + Projectile.tileCollide = false; + Projectile.timeLeft = 1200; + Projectile.damage = 10; + Projectile.hostile = true; + if(NPC.crimsonBoss != -1) + MyTarget = Main.npc[NPC.crimsonBoss].target; + } + + public override void OnSpawn(IEntitySource source) + { + holdPos = new Vector2(Projectile.Center.X, Main.npc[NPC.crimsonBoss].Center.Y - 128) - Main.npc[NPC.crimsonBoss].Center; + + Projectile.rotation = Main.rand.NextFloat(0, MathHelper.TwoPi); + + StunTime = -1; + + enemyID = Main.rand.Next(0, 3); + int[] enemyIDs = [NPCID.FaceMonster, NPCID.Crimera, NPCID.BloodCrawler]; + enemyID = enemyIDs[enemyID]; + + MyTarget = Main.npc[NPC.crimsonBoss].target; + + Projectile.netUpdate = true; + } + + public override void AI() + { + if (NPC.crimsonBoss == -1) + { + Projectile.active = false; + return; + } + + if (Time <= 90) + Projectile.hostile = false; + else + Projectile.hostile = true; + + bool throwing = Time > 180; + float throwTime = Time - 180; + if (throwing) + { + if (throwSign == 0) + throwSign = Math.Sign(Projectile.Center.X - Main.npc[NPC.crimsonBoss].Center.X) * -Math.Sign(Main.player[MyTarget].Center.Y - Main.npc[NPC.crimsonBoss].Center.Y); + } + bool thrown = throwTime > 90; + + if (!thrown) + { + Vector2 startPoint = Main.npc[NPC.crimsonBoss].Center;// Main.npc[NPC.crimsonBoss].Center; + Vector2 endPoint = Projectile.Center; + + if (StunTime == -1) + { + if (!throwing) + { + if (Time >= 150) + Projectile.velocity = ((holdPos + Main.npc[NPC.crimsonBoss].Center) - Projectile.Center) / 30f; + else if (Time != 0) + { + + if (Time <= 90) + { + if (Time == 90) + Projectile.velocity = Vector2.UnitY * -24f; + if (Time % 30 == 0) + Projectile.velocity = Vector2.UnitY * -16f; + else + Projectile.velocity *= 0.33f; + } + else + Projectile.velocity *= 0.966f; + } + } + else + { + if (throwTime <= 30) + throwPos = (Projectile.Center + Projectile.velocity) - (Main.npc[NPC.crimsonBoss].Center + Main.npc[NPC.crimsonBoss].velocity); + Vector2 target = Main.player[MyTarget].Center; + Vector2 throwDir = (target - (throwPos + (Main.npc[NPC.crimsonBoss].Center + Main.npc[NPC.crimsonBoss].velocity))).SafeNormalize(Vector2.UnitY); + + if (throwTime >= 30 && throwTime <= 90) + { + if (throwTime <= 60f) + { + Projectile.Center = Vector2.Lerp(throwPos, throwPos - throwDir * 56f, CalamityUtils.SineInOutEasing((throwTime - 30) / 30f, 1)) + (Main.npc[NPC.crimsonBoss].Center + Main.npc[NPC.crimsonBoss].velocity); + Projectile.velocity = Vector2.Zero; + } + else + { + Projectile.velocity += throwDir * 0.9f; + if (throwTime == 90) + { + float dist = Projectile.Center.Distance(target) / 2f; + dist /= Projectile.velocity.Length(); + Projectile.velocity.Y -= dist * 0.6f; + Projectile.tileCollide = true; + } + } + } + } + } + + Vector2 direction = endPoint - startPoint; + float distance = Vector2.Distance(startPoint, endPoint); + + float lerp = CalamityUtils.SineInOutEasing(MathHelper.Clamp((throwTime) / 60f, 0f, 1f), 1); + float xMult = MathHelper.Lerp(-Math.Clamp(direction.X / 256f, -1, 1), throwSign, lerp); + float yMult = Math.Clamp(direction.Y / 256f, -1, 1); + float curveIntensity = Math.Clamp(distance / 420f, 0f, 0.66f) * xMult * yMult; + //Main.NewText("Completion: " + lerp + ", Intensity: " + curveIntensity); + Vector2 perpindicular = direction.RotatedBy(MathHelper.PiOver2); + + Vector2 controlPoint1 = startPoint + (direction * 0.25f) + (perpindicular * curveIntensity); + Vector2 controlPoint2 = startPoint + (direction * 0.75f) + (perpindicular * curveIntensity); + + curve = new BezierCurve(startPoint, controlPoint1, controlPoint2, endPoint); + } + else + { + Projectile.velocity.Y += 0.6f; + } + + if (StunTime >= 0) + { + if (StunTime < 30f) + StunTime++; + else + { + Projectile.velocity.Y += 0.6f; + Projectile.tileCollide = true; + } + } + else + { + if (Time > 90) + Projectile.rotation += (Projectile.velocity.X / 100f) - (Math.Sign(Main.npc[NPC.crimsonBoss].Center.X - Projectile.Center.X) * 0.025f); + Time++; + } + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(throwSign); + + writer.WriteVector2(throwPos); + + writer.WriteVector2(holdPos); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + throwSign = reader.ReadInt32(); + + throwPos = reader.ReadVector2(); + + holdPos = reader.ReadVector2(); + } + + public override bool OnTileCollide(Vector2 oldVelocity) => true; + + public override void OnKill(int timeLeft) + { + Vector2 velocity = Projectile.velocity.RotatedBy(MathHelper.Pi) / 8f; + Vector2 pos = Projectile.Center + Projectile.velocity; + + switch (enemyID) + { + case NPCID.FaceMonster: + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 237); + + for (int i = 0; i < 24; i++) + Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(16, 32), DustID.Blood, Scale: Main.rand.NextFloat(1, 2)); + + SoundEngine.PlaySound(SoundID.NPCDeath1 with { Volume = 0.25f }, pos); + break; + case NPCID.Crimera: + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 223); + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 224); + + for (int i = 0; i < 24; i++) + Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(16, 32), DustID.Blood, Scale: Main.rand.NextFloat(1, 2)); + + SoundEngine.PlaySound(SoundID.NPCDeath1 with { Volume = 0.25f }, pos); + break; + case NPCID.BloodCrawler: + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 351); + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 352); + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 353); + + for (int i = 0; i < 24; i++) + Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(16, 32), DustID.Blood, Scale: Main.rand.NextFloat(1, 2)); + + SoundEngine.PlaySound(SoundID.NPCDeath1 with { Volume = 0.25f }, pos); + break; + default: + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), 42); + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 43); + Gore.NewGore(Projectile.GetSource_Death(), pos - (Projectile.velocity / 2f), velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)), 44); + + SoundEngine.PlaySound(SoundID.NPCDeath2 with { Volume = 0.175f }, pos); + break; + } + } + + bool evenRed = false; + public override bool PreDraw(ref Color lightColor) + { + //Handles getting the glow textures + if (EnemyGlowTextures.Count == 0 || !EnemyGlowTextures.ContainsKey(enemyID)) + { + EnemyGlowTextures.Clear(); + int[] enemyIDs = [NPCID.FaceMonster, NPCID.Crimera, NPCID.BloodCrawler]; + foreach (int id in enemyIDs) + { + Main.instance.LoadNPC(id); + var baseTex = TextureAssets.Npc[id]; + var glow = new Texture2D(Main.graphics.GraphicsDevice, baseTex.Value.Width, baseTex.Value.Height); + + var BaseArray = new Color[glow.Width * glow.Height]; + var ColorArray = new Color[glow.Width * glow.Height]; + baseTex.Value.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + if (BaseArray[i].A != 0) + ColorArray[i] = new Color(255, 255, 255); + } + glow.SetData(ColorArray); + + EnemyGlowTextures.Add(id, glow); + } + } + + int type = enemyID; + int frameCount; + int wrapFrame = -1; + int startFrame = 0; + float mult = 0.75f; + + switch (type) + { + case NPCID.FaceMonster: + frameCount = 16; + startFrame = 2; + wrapFrame = 16; + break; + case NPCID.Crimera: + frameCount = 2; + mult = 0.25f; + break; + case NPCID.BloodCrawler: + frameCount = 5; + mult = 0.25f; + break; + default: + frameCount = 15; + type = NPCID.Skeleton; + startFrame = 1; + break; + } + + if (wrapFrame == -1) + wrapFrame = frameCount; + + Texture2D tex = TextureAssets.Npc[type].Value; + + int currentFrame = ((int)((1200 - Projectile.timeLeft) * mult)) % (wrapFrame - startFrame); + + Rectangle frame = tex.Frame(1, frameCount, 0, startFrame + currentFrame); + + float throwTime = Time - 180; + + float opacity = 1f; + if (Time < 10) + opacity = Time / 10f; + + if (throwTime <= 90) + { + int pCount = 12; + + float wrapTime = 60; + float wrappedTime = MathHelper.Clamp((Time % (wrapTime + 1)) / wrapTime, 0f, 1f); + if (wrappedTime == 0) + evenRed = !evenRed; + + float glowOpacity = MathHelper.Clamp(1 - ((throwTime - 75) / 15f), 0f, 1f); + if (StunTime >= 0) + glowOpacity = 1 - (StunTime / 30f); + if (Time < 15) + glowOpacity = Time / 15f; + + Main.spriteBatch.End(out var snapshot); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Main.GameViewMatrix.TransformationMatrix); + + Texture2D ring = TextureAssets.Projectile[Type].Value; + + List points = curve.GetPoints(pCount); + for (int i = 1; i < pCount; i++) + { + float scale1 = MathHelper.Lerp(0.1f, 1f, i / (float)(pCount - 1)); + float scale2 = MathHelper.Lerp(0.1f, 1f, (i + 1) / (float)(pCount - 1)); + float scale = MathHelper.Lerp(scale1, scale2, wrappedTime); + + float rot1 = (points[i] - points[i - 1]).ToRotation(); + + float rot2; + if (i == pCount - 1) + rot2 = points[i].ToRotation(); + else + rot2 = (points[i + 1] - points[i]).ToRotation(); + + float rot; + if (i == pCount - 1) + rot = rot1; + else + rot = rot1.AngleLerp(rot2, wrappedTime); + + Vector2 pos; + if (i == pCount - 1) + pos = Vector2.Lerp(points[i], points[i] + rot.ToRotationVector2() * Vector2.Distance(points[^1], points[^2]), wrappedTime); + else + pos = Vector2.Lerp(points[i], points[i + 1], wrappedTime); + + Color color; + if (evenRed) + color = (i % 2 == 0 ? Color.Red : Color.Magenta) * 0.666f; + else + color = (i % 2 == 0 ? Color.Magenta : Color.Red) * 0.666f; + + if (i == pCount - 1) + color *= 1 - wrappedTime; + else if (i == 1) + color *= wrappedTime; + + Main.spriteBatch.Draw(ring, pos + Projectile.velocity - Main.screenPosition, null, color * glowOpacity, rot, ring.Size() * 0.5f, new Vector2(0.5f, 1f) * scale, 0, 0); + } + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(snapshot); + + Vector2[] offsets = [Vector2.UnitX * 2, Vector2.UnitX * -2, Vector2.UnitY * 2, Vector2.UnitY * -2]; + for (int i = 0; i < 4; i++) + Main.EntitySpriteDraw(EnemyGlowTextures[enemyID], Projectile.Center - Main.screenPosition + offsets[i].RotatedBy(Projectile.rotation), frame, Color.Lerp(Color.Red, Color.Magenta, ((float)Math.Sin((Main.GlobalTimeWrappedHourly * 5f)) / 2f + 0.5f)) * glowOpacity, Projectile.rotation, frame.Size() * 0.5f, 1f, 0); + } + + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, lightColor * opacity, Projectile.rotation, frame.Size() * 0.5f, 1f, 0); + + return false; + } +} + diff --git a/Projectiles/Boss/BrimstoneBall.cs b/Projectiles/Boss/BrimstoneBall.cs deleted file mode 100644 index 8009e83729..0000000000 --- a/Projectiles/Boss/BrimstoneBall.cs +++ /dev/null @@ -1,45 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Boss -{ - public class BrimstoneBall : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.hostile = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; - CooldownSlot = ImmunityCooldownID.Bosses; - } - - public override void AI() - { - Projectile.rotation += 0.12f * Projectile.direction; - - Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0f); - - for (int i = 0; i < 2; i++) - { - Vector2 dspeed = -Projectile.velocity * 0.7f; - int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 150, default, 1.1f); - Main.dust[brimDust].noGravity = true; - Main.dust[brimDust].velocity = dspeed; - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 90); - } - } -} diff --git a/Projectiles/Boss/BrimstoneBarrage.cs b/Projectiles/Boss/BrimstoneBarrage.cs index b69a56ddd3..2ebd4d4fcf 100644 --- a/Projectiles/Boss/BrimstoneBarrage.cs +++ b/Projectiles/Boss/BrimstoneBarrage.cs @@ -1,12 +1,7 @@ -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Events; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.NPCs; -using CalamityMod.NPCs.CalClone; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -36,20 +31,8 @@ namespace CalamityMod.Projectiles.Boss CooldownSlot = ImmunityCooldownID.Bosses; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Projectile.localAI[0]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - Projectile.localAI[0] = reader.ReadSingle(); - } - public override void AI() { - bool bossRush = BossRushEvent.BossRushActive; - int target = Player.FindClosest(Projectile.Center, 1, 1); float targetDist; @@ -60,7 +43,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.velocity.Length() < Projectile.ai[2]) { - Projectile.velocity *= bossRush ? 1.0125f : 1.01f; + Projectile.velocity *= 1.01f; if (Projectile.velocity.Length() > Projectile.ai[2]) { Projectile.velocity.Normalize(); @@ -114,20 +97,12 @@ namespace CalamityMod.Projectiles.Boss Projectile.scale = 0.85f; - Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), 182); + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), DustID.TheDestroyer); trailDust.noGravity = true; trailDust.velocity = (-Projectile.velocity * 0.5f) * Main.rand.NextFloat(0.1f, 0.9f); trailDust.scale = Main.rand.NextFloat(0.2f, 0.6f); } - if (Projectile.localAI[0] == 0f) - { - Projectile.localAI[0] = 1f; - - if (Projectile.ai[0] == 0f) - Projectile.damage = NPC.AnyNPCs(ModContent.NPCType()) ? Projectile.GetProjectileDamage(ModContent.NPCType()) : Projectile.GetProjectileDamage(ModContent.NPCType()); - } - Lighting.AddLight(Projectile.Center, 0.75f * Projectile.Opacity, 0f, 0f); time++; } @@ -142,7 +117,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[0] == 0f || Main.zenithWorld) target.AddBuff(ModContent.BuffType(), 180); else - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } public override bool PreDraw(ref Color lightColor) @@ -153,8 +128,12 @@ namespace CalamityMod.Projectiles.Boss { if (Main.npc[CalamityGlobalNPC.SCal].active) { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost) + { + lightColor.G = (byte)(255 * Projectile.Opacity); lightColor.B = (byte)(255 * Projectile.Opacity); + lightColor.R = 0; + } } } diff --git a/Projectiles/Boss/BrimstoneFire.cs b/Projectiles/Boss/BrimstoneFire.cs deleted file mode 100644 index 2fb7384d2e..0000000000 --- a/Projectiles/Boss/BrimstoneFire.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class BrimstoneFire : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/FireProj"; - - public static int Lifetime => 90; - public static int Fadetime => 80; - public ref float Time => ref Projectile.ai[0]; - public int MistType = -1; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 10; - Projectile.hostile = true; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.MaxUpdates = 3; - Projectile.timeLeft = Lifetime; - CooldownSlot = ImmunityCooldownID.Bosses; - } - - public override void AI() - { - Time++; - if (Time < Fadetime && Main.rand.NextBool(6)) - { - Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); - float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); - Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, ModContent.DustType(), Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); - if (Main.rand.NextBool(3)) - { - cinder.scale *= 2f; - cinder.velocity *= 2f; - } - cinder.noGravity = true; - cinder.scale *= cinderSize * 1.2f; - cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); - } - - if (MistType == -1) - MistType = Main.rand.Next(3); - - Lighting.AddLight(Projectile.Center, 0.75f, 0.15f, 0.15f); - } - - // Keeping the flames in place when hitting a block - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.velocity = oldVelocity * 0.95f; - Projectile.position -= Projectile.velocity; - Time++; - Projectile.timeLeft--; - return false; - } - - // Expanding hitbox - // A bit more generous than Havoc's Breath fire because enemy projectiles - public override void ModifyDamageHitbox(ref Rectangle hitbox) - { - int size = (int)Utils.Remap(Time, 0f, Fadetime, 8f, 32f); - - // Shrinks again after fading - if (Time > Fadetime) - size = (int)Utils.Remap(Time, Fadetime, Lifetime, 32f, 0f); - hitbox.Inflate(size, size); - } - - // Anti-wall hacking checks - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projHitbox.Intersects(targetHitbox) && Collision.CanHit(Projectile.Center, 0, 0, targetHitbox.Center.ToVector2(), 0, 0) ? null : false; - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 150); - - // Cook you up (still scales with player size in case it's manipulated) - int smokeCount = 4 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); - for (int i = 0; i < smokeCount; i++) - { - Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f); - Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-2.4f, -0.8f) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f); - Particle smoke = new MediumMistParticle(smokePos, smokeVel, new Color(255, 50, 50), Color.DimGray, Main.rand.NextFloat(1f, 2f), 245 - Main.rand.Next(50), 0.1f); - GeneralParticleHandler.SpawnParticle(smoke); - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D fire = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; - - // The conga line of colors to sift through - Color color1 = new Color(255, 110, 100, 200); - Color color2 = new Color(255, 50, 50, 70); - Color color3 = new Color(255, 100, 100, 100); - Color color4 = new Color(200, 35, 30, 100); - float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); - float vOffset = Math.Min(Time, 20f); - float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); - float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); - - if (timeRatio >= 1f) - return false; - - for (float j = 1f; j >= 0f; j -= length) - { - // Color - Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : - ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : - ((timeRatio < 0.35f) ? color2 : - ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : - ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : - Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); - fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); - Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f); - - // Positions and rotations - Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; - float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length; - float trailRot = MathHelper.PiOver4 - mainRot; - - // Draw one backtrail - Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; - Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); - - // Draw the main fire - Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); - - // Draw the masking smoke - Main.spriteBatch.SetBlendState(BlendState.Additive); - Rectangle frame = mist.Frame(1, 3, 0, MistType); - Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); - Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); - } - return false; - } - } -} diff --git a/Projectiles/Boss/BrimstoneHellblast.cs b/Projectiles/Boss/BrimstoneHellblast.cs index a0abed02ee..78e36d7d8c 100644 --- a/Projectiles/Boss/BrimstoneHellblast.cs +++ b/Projectiles/Boss/BrimstoneHellblast.cs @@ -3,7 +3,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.NPCs; using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -103,8 +102,12 @@ namespace CalamityMod.Projectiles.Boss { if (Main.npc[CalamityGlobalNPC.SCal].active) { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost) + { + lightColor.G = (byte)(255 * Projectile.Opacity); lightColor.B = (byte)(255 * Projectile.Opacity); + lightColor.R = 0; + } } } @@ -122,7 +125,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[0] == 0f || Main.zenithWorld) target.AddBuff(ModContent.BuffType(), 180); else - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Boss/BrimstoneHellblast2.cs b/Projectiles/Boss/BrimstoneHellblast2.cs index 81d2d736db..79009684a7 100644 --- a/Projectiles/Boss/BrimstoneHellblast2.cs +++ b/Projectiles/Boss/BrimstoneHellblast2.cs @@ -3,7 +3,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -40,8 +39,8 @@ namespace CalamityMod.Projectiles.Boss // Cal Clone bullet hell projectiles accelerate after a certain time has passed if (Projectile.ai[0] == 2f && (Main.expertMode || BossRushEvent.BossRushActive) && Projectile.timeLeft < 1260) { - if (Projectile.velocity.Length() < (BossRushEvent.BossRushActive ? 12.5f : 10f)) - Projectile.velocity *= 1.005f; + if (Projectile.velocity.Length() < 10f) + Projectile.velocity *= 1.002f; } Projectile.frameCounter++; @@ -84,8 +83,12 @@ namespace CalamityMod.Projectiles.Boss { if (Main.npc[CalamityGlobalNPC.SCal].active) { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost) + { + lightColor.G = (byte)(255 * Projectile.Opacity); lightColor.B = (byte)(255 * Projectile.Opacity); + lightColor.R = 0; + } } } @@ -103,7 +106,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.ai[0] == 0f || Main.zenithWorld) target.AddBuff(ModContent.BuffType(), 180); else - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Boss/BrimstoneHellfireball.cs b/Projectiles/Boss/BrimstoneHellfireball.cs index c35f3e1f66..e013a9c560 100644 --- a/Projectiles/Boss/BrimstoneHellfireball.cs +++ b/Projectiles/Boss/BrimstoneHellfireball.cs @@ -2,7 +2,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss @@ -19,7 +18,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 34; Projectile.height = 34; Projectile.hostile = true; @@ -83,12 +81,12 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(ModContent.BuffType(), 240); } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor * 0.5f, 1); return false; } } diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index 143bd0df9f..94fdc5611a 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Boss internal static readonly float CircularHitboxRadius = 170f; public static int MinimumDamagePerFrame = 4; - public static int MaximumDamagePerFrame = 16; + public static int MaximumDamagePerFrame = 14; public static float AdrenalineLossPerFrame = 0.04f; public static float SpeedToForceMaxDamage = 25f; @@ -284,7 +284,7 @@ namespace CalamityMod.Projectiles.Boss if (Colliding(Projectile.Hitbox, player.Hitbox) == false) return false; - // Applies Vulnerability Hex and/or the effects of Supreme Cirrus' HAGE faces. + // Applies Vulnerability Hex and/or the effects of Supreme Permafrost's HAGE faces. OnHitPlayer_Internal(player); // Check the player's speed. If they are moving fast enough, damage them more severely; this prevents trying to rush straight through the vortex. @@ -323,7 +323,7 @@ namespace CalamityMod.Projectiles.Boss string path = Main.zenithWorld ? "GFB" : ""; path += Main.rand.Next(1, 4).ToString(); if (Main.myPlayer == player.whoAmI && player.statLife <= 0) - player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.WhisperingMaelstrom" + path).Format(player.name)), 1000, -1); + player.KillMe(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.WhisperingMaelstrom" + path).ToNetworkText(player.name)), 1000, -1); // Still do not allow a standard hit, but the player should surely be feeling the pain soon... return false; @@ -341,17 +341,17 @@ namespace CalamityMod.Projectiles.Boss { target.AddBuff(ModContent.BuffType(), 360, true); - // Remove all positive buffs from the player if they're hit by HAGE while Cirrus is alive. + // Remove all positive buffs from the player if they're hit by HAGE while Permafrost is alive. if (CalamityGlobalNPC.SCal != -1) { if (Main.npc[CalamityGlobalNPC.SCal].active) { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost) { for (int l = 0; l < Player.MaxBuffs; l++) { int buffType = target.buffType[l]; - if (target.buffTime[l] > 0 && AmalgamBuffList.Includes(buffType)) + if (target.buffTime[l] > 0 && CalamityBuffSets.BuffedByAmalgam[buffType]) { target.DelBuff(l); l--; @@ -407,8 +407,8 @@ namespace CalamityMod.Projectiles.Boss Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - bool isCirrus = CalamityGlobalNPC.SCal != -1 && Main.npc[CalamityGlobalNPC.SCal].active && Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus; - if (isCirrus) + bool isPermafrost = CalamityGlobalNPC.SCal != -1 && Main.npc[CalamityGlobalNPC.SCal].active && Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost; + if (isPermafrost) { Texture2D hageTex = ModContent.Request("CalamityMod/Projectiles/Boss/BrimstoneMonsterII").Value; lightColor.B = (byte)(255 * Projectile.Opacity); diff --git a/Projectiles/Boss/BrimstoneRay.cs b/Projectiles/Boss/BrimstoneRay.cs index 860895fc39..2bf79eff7a 100644 --- a/Projectiles/Boss/BrimstoneRay.cs +++ b/Projectiles/Boss/BrimstoneRay.cs @@ -114,17 +114,15 @@ namespace CalamityMod.Projectiles.Boss Vector2 dustSpawnPos = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f); // Fire brimstone darts along the laser - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (Main.npc[(int)Projectile.ai[1]].ai[1] == 210f && Projectile.owner == Main.myPlayer && Main.npc[(int)Projectile.ai[1]].ai[0] == 5) { Vector2 velocity = Projectile.velocity; velocity.Normalize(); - float distanceBetweenProjectiles = Main.zenithWorld ? 360 : bossRush ? 72f : 144f; + float distanceBetweenProjectiles = Main.zenithWorld ? 360 : 144f; Vector2 fireFrom = new Vector2(Main.npc[(int)Projectile.ai[1]].Center.X + (Main.npc[(int)Projectile.ai[1]].spriteDirection > 0 ? 34f : -34f), Main.npc[(int)Projectile.ai[1]].Center.Y - 74f) + velocity * distanceBetweenProjectiles; int projectileAmt = (int)(Projectile.localAI[1] / distanceBetweenProjectiles); int type = ModContent.ProjectileType(); - int damage = (int)Math.Round(Projectile.damage * 0.6); float projectileVelocityToPass = 12f; for (int i = 0; i < projectileAmt; i++) @@ -134,10 +132,8 @@ namespace CalamityMod.Projectiles.Boss for (int j = 0; j < totalProjectiles; j++) { Vector2 projVelocity = Projectile.velocity.RotatedBy(radians * j + MathHelper.PiOver2); - int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), fireFrom, projVelocity, type, damage, 0f, Main.myPlayer, death ? 2f : 1f, 0f, projectileVelocityToPass); + int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), fireFrom, projVelocity, type, BrimstoneElemental.DartDamage, 0f, Main.myPlayer, death ? 2f : 1f, 0f, projectileVelocityToPass); Main.projectile[proj].tileCollide = true; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Main.projectile[proj].extraUpdates += 1; } fireFrom += velocity * distanceBetweenProjectiles; } @@ -235,7 +231,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(ModContent.BuffType(), 240); } public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f; diff --git a/Projectiles/Boss/BrimstoneWave.cs b/Projectiles/Boss/BrimstoneWave.cs index a524d96893..2e5f49310d 100644 --- a/Projectiles/Boss/BrimstoneWave.cs +++ b/Projectiles/Boss/BrimstoneWave.cs @@ -87,8 +87,12 @@ namespace CalamityMod.Projectiles.Boss { if (Main.npc[CalamityGlobalNPC.SCal].active) { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost) + { + lightColor.G = (byte)(255 * Projectile.Opacity); lightColor.B = (byte)(255 * Projectile.Opacity); + lightColor.R = 0; + } } } diff --git a/Projectiles/Boss/BurningBolt.cs b/Projectiles/Boss/BurningBolt.cs new file mode 100644 index 0000000000..65c33dbd53 --- /dev/null +++ b/Projectiles/Boss/BurningBolt.cs @@ -0,0 +1,107 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Boss +{ + public class BurningBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public int time = 0; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 4; + ProjectileID.Sets.TrailCacheLength[Type] = 2; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 18; + Projectile.height = 44; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 690; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void AI() + { + int target = Player.FindClosest(Projectile.Center, 1, 1); + + float targetDist; + if (target != -1 && !Main.player[target].dead && Main.player[target].active && Main.player[target] != null) + targetDist = Vector2.Distance(Main.player[target].Center, Projectile.Center); + else + targetDist = 1000; + + if (Projectile.velocity.Length() < Projectile.ai[2]) + { + Projectile.velocity *= 1.01f; + if (Projectile.velocity.Length() > Projectile.ai[2]) + { + Projectile.velocity.Normalize(); + Projectile.velocity *= Projectile.ai[2]; + } + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 3) + Projectile.frame = 0; + + if (Projectile.timeLeft < 60) + Projectile.Opacity = MathHelper.Clamp(Projectile.timeLeft / 60f, 0f, 1f); + + if (Projectile.ai[0] == 2f) + { + if (Projectile.timeLeft > 570) + { + int player = Player.FindClosest(Projectile.Center, 1, 1); + Vector2 vector = Main.player[player].Center - Projectile.Center; + float scaleFactor = Projectile.velocity.Length(); + vector.Normalize(); + vector *= scaleFactor; + Projectile.velocity = (Projectile.velocity * 15f + vector) / 16f; + Projectile.velocity.Normalize(); + Projectile.velocity *= scaleFactor; + } + } + + Lighting.AddLight(Projectile.Center, 0.75f * Projectile.Opacity, 0f, 0f); + time++; + + var p = SeekersMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * Projectile.MaxUpdates, Vector2.Zero, Terraria.GameContent.TextureAssets.Projectile[Type].Width() * Projectile.scale); + p.rotation = Projectile.rotation; + p.CurrentFrame = Projectile.frame; + p.MaxFrames = Main.projFrames[Type]; + p.TextureToUse = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + p.SizeScaling = 0f; + } + + public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0 || Projectile.Opacity != 1f) + return; + target.AddBuff(ModContent.BuffType(), 120); + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 10 * Projectile.scale, targetHitbox); + } +} diff --git a/Projectiles/Boss/BurningBolt.png b/Projectiles/Boss/BurningBolt.png new file mode 100644 index 0000000000..7664f14d4e Binary files /dev/null and b/Projectiles/Boss/BurningBolt.png differ diff --git a/Projectiles/Boss/BurningFireblast.cs b/Projectiles/Boss/BurningFireblast.cs new file mode 100644 index 0000000000..d4bad3fdcb --- /dev/null +++ b/Projectiles/Boss/BurningFireblast.cs @@ -0,0 +1,221 @@ +using CalamityMod.Events; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.NPCs.CalClone; +using CalamityMod.Particles; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class BurningFireblast + : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static readonly SoundStyle ImpactSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneFireblastImpact"); + public int DartDamage = 0; + public bool withinRange = false; + public bool setLifetime = false; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 5; + } + + public override void SetDefaults() + { + Projectile.Calamity().DealsDefenseDamage = true; + Projectile.width = 36; + Projectile.height = 36; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.Opacity = 0f; + Projectile.timeLeft = 150; + Projectile.tileCollide = false; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void OnSpawn(IEntitySource source) + { + DartDamage = CalamitasClone.DartDamage; + } + + public override void AI() + { + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame >= 5) + Projectile.frame = 0; + + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + + Lighting.AddLight(Projectile.Center, 0.9f * Projectile.Opacity, 0f, 0f); + + if (!withinRange) + { + if (Projectile.ai[2] == 1f) + Projectile.Opacity = MathHelper.Clamp(Projectile.timeLeft / 60f, 0f, 1f); + else + Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - 130) / 20f), 0f, 1f); + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.localAI[0] == 0f) + { + Projectile.localAI[0] = 1f; + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + } + + int target = (int)Projectile.ai[0]; + + if (!withinRange) + { + float inertia = revenge ? 80f : 100f; + float homeSpeed = revenge ? 13f : 9f; + float minDist = 40f; + if (target >= 0 && Main.player[target].active && !Main.player[target].dead) + { + if (Projectile.Distance(Main.player[target].Center) > minDist) + { + Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[target].Center, Vector2.UnitY); + Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * homeSpeed) / inertia; + } + } + else + { + if (Projectile.ai[0] != -1f) + { + Projectile.ai[0] = -1f; + Projectile.netUpdate = true; + } + } + } + + float targetDist; + if (target != -1 && !Main.player[target].dead && Main.player[target].active && Main.player[target] != null) + targetDist = Vector2.Distance(Main.player[target].Center, Projectile.Center); + else + targetDist = 1000; + + if (Projectile.ai[1] == 2f && !withinRange && Main.rand.NextBool()) + { + SparkParticle orb = new SparkParticle(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(20, 20), -Projectile.velocity * Main.rand.NextFloat(0.1f, 1f), false, 14, Main.rand.NextFloat(0.35f, 0.6f), (Main.rand.NextBool() ? Color.Lerp(Color.Red, Color.Magenta, 0.5f) : Color.Red) * Projectile.Opacity); + GeneralParticleHandler.SpawnParticle(orb); + } + if ((Projectile.timeLeft == 1 && !withinRange) || (targetDist < 224 && Projectile.Opacity == 1f)) // When within 14 blocks of player or when it runs out of time + { + if (!setLifetime) + { + Projectile.timeLeft = 60; + setLifetime = true; + } + withinRange = true; + } + if (withinRange && Projectile.ai[2] == 0f) + { + Projectile.velocity *= 0.9f; + for (int i = 0; i < 2; i++) + { + Dust failShotDust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 60 : 114); + failShotDust.noGravity = true; + failShotDust.velocity = new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.3f); + failShotDust.scale = Main.rand.NextFloat(0.7f, 1.8f); + } + if (Projectile.timeLeft <= 40) + { + if (Projectile.Opacity > 0) + Projectile.Opacity -= 0.05f; + } + if (Projectile.timeLeft == 30) + { + Projectile.Opacity = 0; + Projectile.velocity *= 0; + for (int i = 0; i < 2; i++) + { + Particle bloom = new BloomParticle(Projectile.Center, Vector2.Zero, new Color(121, 56, 0), 0.1f, 0.7f, 30, false); + GeneralParticleHandler.SpawnParticle(bloom); + if (Projectile.ai[2] == 1f) + bloom.Lifetime = 0; + } + } + if (Projectile.timeLeft == 15) + { + Particle bloom = new BloomParticle(Projectile.Center, Vector2.Zero, new Color(255, 106, 0), 0.1f, 0.65f, 15, false); + GeneralParticleHandler.SpawnParticle(bloom); + } + if (Projectile.timeLeft == 8) + { + Particle bloom = new BloomParticle(Projectile.Center, Vector2.Zero, Color.White, 0.1f, 0.5f, 8, false); + GeneralParticleHandler.SpawnParticle(bloom); + } + } + + var p = SeekersMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * Projectile.MaxUpdates, Vector2.Zero, Terraria.GameContent.TextureAssets.Projectile[ModContent.ProjectileType()].Width()); + p.rotation = Projectile.rotation; + p.CurrentFrame = Projectile.frame; + p.MaxFrames = Main.projFrames[Type]; + p.TextureToUse = Terraria.GameContent.TextureAssets.Projectile[ModContent.ProjectileType()].Value; + p.SizeScaling = 0f; + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(ImpactSound, Projectile.Center); + + // Difficulty modes + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + if (Projectile.ai[2] == 0f) + { + if (Projectile.owner == Main.myPlayer) + { + int totalProjectiles = death ? 16 : revenge ? 14 : expertMode ? 12 : 8; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 8f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, DartDamage, 0f, Projectile.owner, 0f, Projectile.ai[1], velocity * 1.5f); + } + } + + if (Projectile.ai[1] == 2f) + { + for (int i = 0; i < 18; i++) + { + Vector2 velocity = new Vector2(12, 12).RotatedByRandom(100); + PointParticle spark2 = new PointParticle(Projectile.Center + velocity, velocity * Main.rand.NextFloat(0.3f, 1f), false, 15, 1.1f, (Main.rand.NextBool() ? Color.Lerp(Color.Red, Color.Magenta, 0.5f) : Color.Red) * 0.6f); + GeneralParticleHandler.SpawnParticle(spark2); + } + for (int i = 0; i < 18; i++) + { + Dust failShotDust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 60 : 114); + failShotDust.noGravity = true; + failShotDust.velocity = new Vector2(16, 16).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.3f); + failShotDust.scale = Main.rand.NextFloat(0.75f, 1.3f); + } + } + } + } + } +} diff --git a/Projectiles/Boss/BurningFireblast.png b/Projectiles/Boss/BurningFireblast.png new file mode 100644 index 0000000000..eacc109586 Binary files /dev/null and b/Projectiles/Boss/BurningFireblast.png differ diff --git a/Projectiles/Boss/BurningGigablast.cs b/Projectiles/Boss/BurningGigablast.cs new file mode 100644 index 0000000000..714eca7f76 --- /dev/null +++ b/Projectiles/Boss/BurningGigablast.cs @@ -0,0 +1,214 @@ +using CalamityMod.Events; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.NPCs.CalClone; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Particles; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class BurningGigablast : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static readonly SoundStyle ImpactSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneGigablastImpact"); + public int DartDamage = 0; + public bool withinRange = false; + public bool setLifetime = false; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 6; + } + + public override void SetDefaults() + { + Projectile.Calamity().DealsDefenseDamage = true; + Projectile.width = 50; + Projectile.height = 50; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 120; + Projectile.Opacity = 0f; + Projectile.tileCollide = false; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void OnSpawn(IEntitySource source) + { + DartDamage = SupremeCalamitas.DartDamage; + + if (source is EntitySource_Parent { Entity: NPC parent }) + { + if (parent.type == ModContent.NPCType()) + DartDamage = CalamitasClone.DartDamage; + } + } + + public override void AI() + { + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 5) + Projectile.frame = 0; + + if (!withinRange) + { + if (Projectile.ai[2] == 1f) + Projectile.Opacity = MathHelper.Clamp(Projectile.timeLeft / 60f, 0f, 1f); + else + Projectile.Opacity = MathHelper.Clamp(1f - ((Projectile.timeLeft - 130) / 20f), 0f, 1f); + } + + Lighting.AddLight(Projectile.Center, 0.9f * Projectile.Opacity, 0f, 0f); + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.localAI[0] == 0f) + { + Projectile.localAI[0] = 1f; + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + } + + int target = Player.FindClosest(Projectile.Center, 1, 1); + + if (!withinRange) + { + float projSpeed = Projectile.velocity.Length(); + Vector2 playerVec = Main.player[target].Center - Projectile.Center; + playerVec.Normalize(); + playerVec *= projSpeed; + Projectile.velocity = (Projectile.velocity * 24f + playerVec) / 25f; + Projectile.velocity.Normalize(); + Projectile.velocity *= projSpeed; + } + + float targetDist; + if (target != -1 && !Main.player[target].dead && Main.player[target].active && Main.player[target] != null) + targetDist = Vector2.Distance(Main.player[target].Center, Projectile.Center); + else + targetDist = 1000; + + if (Projectile.ai[1] == 2f && !withinRange && Main.rand.NextBool()) + { + SparkParticle orb = new SparkParticle(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(30, 30), -Projectile.velocity * Main.rand.NextFloat(0.1f, 1f), false, 14, Main.rand.NextFloat(0.5f, 0.75f), (Main.rand.NextBool() ? Color.Lerp(Color.Red, Color.Magenta, 0.5f) : Color.Red) * Projectile.Opacity); + GeneralParticleHandler.SpawnParticle(orb); + } + if ((Projectile.timeLeft == 1 && !withinRange) || (targetDist < 224 && Projectile.Opacity == 1f)) // When within 14 blocks of player or when it runs out of time + { + if (!setLifetime) + { + Projectile.timeLeft = 60; + setLifetime = true; + } + withinRange = true; + } + if (withinRange && Projectile.ai[2] == 0f) + { + Projectile.velocity *= 0.9f; + for (int i = 0; i < 2; i++) + { + Dust failShotDust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 60 : 114); + failShotDust.noGravity = true; + failShotDust.velocity = new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.3f); + failShotDust.scale = Main.rand.NextFloat(0.7f, 1.8f); + } + if (Projectile.timeLeft <= 40) + { + if (Projectile.Opacity > 0) + Projectile.Opacity -= 0.05f; + } + if (Projectile.timeLeft == 30) + { + Projectile.Opacity = 0; + Projectile.velocity *= 0; + for (int i = 0; i < 2; i++) + { + Particle bloom = new BloomParticle(Projectile.Center, Vector2.Zero, new Color(121, 21, 77), 0.1f, 0.85f, 30, false); + GeneralParticleHandler.SpawnParticle(bloom); + if (Projectile.ai[2] == 1f) + bloom.Lifetime = 0; + } + } + if (Projectile.timeLeft == 15) + { + Particle bloom = new BloomParticle(Projectile.Center, Vector2.Zero, Color.Red, 0.1f, 0.8f, 15, false); + GeneralParticleHandler.SpawnParticle(bloom); + } + if (Projectile.timeLeft == 8) + { + Particle bloom = new BloomParticle(Projectile.Center, Vector2.Zero, Color.White, 0.1f, 0.7f, 8, false); + GeneralParticleHandler.SpawnParticle(bloom); + } + } + + var p = SeekersMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * Projectile.MaxUpdates, Vector2.Zero, Terraria.GameContent.TextureAssets.Projectile[ModContent.ProjectileType()].Width()); + p.rotation = Projectile.rotation; + p.CurrentFrame = Projectile.frame; + p.MaxFrames = Main.projFrames[Type]; + p.TextureToUse = Terraria.GameContent.TextureAssets.Projectile[ModContent.ProjectileType()].Value; + p.SizeScaling = 0f; + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(ImpactSound, Projectile.Center); + + // Difficulty modes + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + + if (Projectile.ai[2] == 0f) + { + if (Projectile.owner == Main.myPlayer) + { + int totalProjectiles = death ? 36 : revenge ? 32 : expertMode ? 28 : 20; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 6.5f; + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, DartDamage, 0f, Projectile.owner, 0f, Projectile.ai[1], velocity * 1.5f); + } + } + + if (Projectile.ai[1] == 2f) + { + for (int i = 0; i < 25; i++) + { + Vector2 velocity = new Vector2(15, 15).RotatedByRandom(100); + PointParticle spark2 = new PointParticle(Projectile.Center + velocity, velocity * Main.rand.NextFloat(0.3f, 1f), false, 15, 1.25f, (Main.rand.NextBool() ? Color.Lerp(Color.Red, Color.Magenta, 0.5f) : Color.Red) * 0.6f); + GeneralParticleHandler.SpawnParticle(spark2); + } + for (int i = 0; i < 25; i++) + { + Dust failShotDust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 60 : 114); + failShotDust.noGravity = true; + failShotDust.velocity = new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.3f); + failShotDust.scale = Main.rand.NextFloat(0.9f, 1.8f); + } + } + } + } + } +} diff --git a/Projectiles/Boss/BurningGigablast.png b/Projectiles/Boss/BurningGigablast.png new file mode 100644 index 0000000000..c1867a5f81 Binary files /dev/null and b/Projectiles/Boss/BurningGigablast.png differ diff --git a/Projectiles/Boss/CalamitousDart.cs b/Projectiles/Boss/CalamitousDart.cs new file mode 100644 index 0000000000..871be393a4 --- /dev/null +++ b/Projectiles/Boss/CalamitousDart.cs @@ -0,0 +1,139 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class CalamitousDart : ModProjectile, ILocalizedModType + { + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Boss"; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 4; + ProjectileID.Sets.TrailCacheLength[Type] = 2; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.Calamity().DealsDefenseDamage = true; + Projectile.width = 40; + Projectile.height = 40; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 400; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void AI() + { + if (Projectile.extraUpdates == 0) + { + Projectile.extraUpdates = 1; + Projectile.velocity *= 0.5f; + } + Projectile.frameCounter++; + if (Projectile.frameCounter >= 10) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 3) + Projectile.frame = 0; + + int target = Player.FindClosest(Projectile.Center, 1, 1); + + float targetDist; + if (target != -1 && !Main.player[target].dead && Main.player[target].active && Main.player[target] != null) + targetDist = Vector2.Distance(Main.player[target].Center, Projectile.Center); + else + targetDist = 1000; + + Lighting.AddLight(Projectile.Center, 0.9f * Projectile.Opacity, 0f, 0f); + + if (targetDist < 1400f && Projectile.ai[1] == 2f) + { + // Spawn in a helix-style pattern + float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi); + + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; + + SparkParticle orb = new(Projectile.Center + offset, -Projectile.velocity * 0.05f, false, 8, 0.8f, Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.5f)); + GeneralParticleHandler.SpawnParticle(orb); + + SparkParticle orb2 = new(Projectile.Center - offset, -Projectile.velocity * 0.05f, false, 8, 0.8f, Main.rand.NextBool() ? Color.Red : Color.Lerp(Color.Red, Color.Magenta, 0.5f)); + GeneralParticleHandler.SpawnParticle(orb2); + } + + if (Projectile.timeLeft < 51) + Projectile.Opacity -= 0.02f; + + + if (Projectile.velocity.Length() < (Projectile.ai[2] == 2f ? 9.5f : 5.3f)) // Hellblasts in phase 4 have faster accel and higher max velocity + Projectile.velocity *= Projectile.ai[2] == 2f ? 1.033f : 1.0125f; + + if (Projectile.velocity.X < 0f) + { + Projectile.spriteDirection = -1; + Projectile.rotation = (float)Math.Atan2(-Projectile.velocity.Y, -Projectile.velocity.X); + } + else + { + Projectile.spriteDirection = 1; + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X); + } + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.spriteDirection = 1; + var dir = Projectile.rotation.ToRotationVector2(); + if (Projectile.spriteDirection == -1) + dir = dir.RotatedBy(MathHelper.Pi); + var spot = Vector2.Lerp(Projectile.Center + dir.RotatedBy(MathHelper.PiOver2) * 26, Projectile.Center + dir.RotatedBy(-MathHelper.PiOver2) * 26, Main.rand.NextFloat()); + for (var i = 0; i < 1; i++) + { + var p = CalamitasMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * 2, Vector2.Zero, 40); + p.rotation = Projectile.rotation + MathHelper.PiOver2; + p.TextureToUse = ModContent.Request("CalamityMod/Particles/PointParticle").Value; + p.SizeScaling = 0.65f; + p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2Circular(3, 3), 24f); + p.SizeScaling = 0.8f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override bool CanHitPlayer(Player target) => Projectile.timeLeft >= 51; + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0 || Projectile.timeLeft < 51) + return; + + if (Main.zenithWorld) + target.AddBuff(ModContent.BuffType(), 180); + else + target.AddBuff(ModContent.BuffType(), 120); + } + + public override void OnKill(int timeLeft) + { + for (int dust = 0; dust <= 5; dust++) + { + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f); + } + } + } +} diff --git a/Projectiles/Boss/CalamitousExplosion.cs b/Projectiles/Boss/CalamitousExplosion.cs new file mode 100644 index 0000000000..140999cc63 --- /dev/null +++ b/Projectiles/Boss/CalamitousExplosion.cs @@ -0,0 +1,95 @@ +using System.IO; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.NPCs.CalClone; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Boss +{ + public class CalamitousExplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 130; + Projectile.height = 130; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 180; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.localAI[0]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.localAI[0] = reader.ReadSingle(); + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, 0.75f, 0f, 0f); + if (Projectile.localAI[0] == 0f) + { + SoundEngine.PlaySound(CalamitasClone.CalamitousExplosionSound, Projectile.Center); + Projectile.localAI[0] += 1f; + } + bool xflag = false; + bool yflag = false; + if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) + { + xflag = true; + } + if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) + { + xflag = true; + } + if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) + { + yflag = true; + } + if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) + { + yflag = true; + } + if (xflag && yflag) + { + Projectile.Kill(); + } + float projTimer = 25f; + if (Projectile.ai[0] > 180f) + { + projTimer -= (Projectile.ai[0] - 180f) / 2f; + } + if (projTimer <= 0f) + { + projTimer = 0f; + Projectile.Kill(); + } + projTimer *= 0.7f; + Projectile.ai[0] += 4f; + var p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2CircularEdge(4, 4), 32f); + p.SizeScaling = 0.96f; + + p = CalamitasMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2CircularEdge(3, 3), 40f); + p.SizeScaling = 0.96f; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 150); + } + } +} diff --git a/Projectiles/Boss/CalamitousFireball.cs b/Projectiles/Boss/CalamitousFireball.cs new file mode 100644 index 0000000000..03c0f5dcb0 --- /dev/null +++ b/Projectiles/Boss/CalamitousFireball.cs @@ -0,0 +1,104 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Metaballs; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Boss +{ + public class CalamitousFireball : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 6; + ProjectileID.Sets.TrailCacheLength[Type] = 3; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 34; + Projectile.height = 34; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 300; + Projectile.alpha = 255; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void AI() + { + if (Projectile.Hitbox.Intersects(new Rectangle((int)Projectile.ai[0], (int)Projectile.ai[1], Player.defaultWidth, Player.defaultHeight))) + Projectile.tileCollide = true; + + // Animation + Projectile.frameCounter++; + if (Projectile.frameCounter > 9) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame >= 6) + Projectile.frame = 0; + + // Fade in + if (Projectile.alpha > 5) + Projectile.alpha -= 15; + if (Projectile.alpha < 5) + Projectile.alpha = 5; + + // Rotation + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90f) * Projectile.direction; + + if (Projectile.velocity.Length() < 16f) + Projectile.velocity *= 1.01f; + + Lighting.AddLight(Projectile.Center, 0.5f, 0f, 0f); + + var brimDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(32, 32), (int)CalamityDusts.Brimstone, null, 170, default, 1.1f); + brimDust.noGravity = true; + brimDust.velocity *= 0.5f; + brimDust.velocity += Projectile.velocity * 0.1f; + for (var i = 0; i < 1; i++) + { + CalamitasMetaball.SpawnParticle(Projectile.Center + Projectile.velocity, Main.rand.NextVector2Circular(2, 2), 64f); + } + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(250, 50, 50, Projectile.alpha); + } + + public override void OnKill(int timeLeft) + { + if (Projectile.owner == Main.myPlayer) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 240); + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + + /* + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + return false; + */ + } + } +} diff --git a/Projectiles/Boss/CataclysmicFlame.cs b/Projectiles/Boss/CataclysmicFlame.cs new file mode 100644 index 0000000000..60179713e4 --- /dev/null +++ b/Projectiles/Boss/CataclysmicFlame.cs @@ -0,0 +1,165 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class CataclysmicFlame : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/FireProj"; + + public static int Lifetime => 90; + public static int Fadetime => 80; + public ref float Time => ref Projectile.ai[0]; + public int MistType = -1; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.tileCollide = false; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void AI() + { + Time++; + if (Time < Fadetime && Main.rand.NextBool(6)) + { + Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); + float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); + Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, ModContent.DustType(), Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); + if (Main.rand.NextBool(3)) + { + cinder.scale *= 2f; + cinder.velocity *= 2f; + } + cinder.noGravity = true; + cinder.scale *= cinderSize * 1.2f; + cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); + } + + if (MistType == -1) + MistType = Main.rand.Next(3); + + Lighting.AddLight(Projectile.Center, 0.75f, 0.15f, 0.15f); + if (Projectile.timeLeft > Lifetime - 10) + return; + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + var p = CataclysmMetaball.SpawnParticle(Projectile.Center, Vector2.Zero, Terraria.GameContent.TextureAssets.Projectile[Type].Width() * fireSize); + p.rotation = Main.rand.NextFloat(MathHelper.TwoPi); + p.TextureToUse = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + p.SizeScaling = 0.5f; + } + + // Keeping the flames in place when hitting a block + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + Time++; + Projectile.timeLeft--; + return false; + } + + // Expanding hitbox + // A bit more generous than Havoc's Breath fire because enemy projectiles + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + int size = (int)Utils.Remap(Time, 0f, Fadetime, 8f, 32f); + + // Shrinks again after fading + if (Time > Fadetime) + size = (int)Utils.Remap(Time, Fadetime, Lifetime, 32f, 0f); + hitbox.Inflate(size, size); + } + + // Anti-wall hacking checks + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projHitbox.Intersects(targetHitbox) && Collision.CanHit(Projectile.Center, 0, 0, targetHitbox.Center.ToVector2(), 0, 0) ? null : false; + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 240); + + // Cook you up (still scales with player size in case it's manipulated) + int smokeCount = 4 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); + for (int i = 0; i < smokeCount; i++) + { + Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f); + Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-2.4f, -0.8f) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f); + Particle smoke = new MediumMistParticle(smokePos, smokeVel, new Color(255, 50, 50), Color.DimGray, Main.rand.NextFloat(1f, 2f), 245 - Main.rand.Next(50), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + + /* + Texture2D fire = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; + + // The conga line of colors to sift through + Color color1 = new Color(255, 110, 100, 200); + Color color2 = new Color(255, 50, 50, 70); + Color color3 = new Color(255, 100, 100, 100); + Color color4 = new Color(200, 35, 30, 100); + float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); + float vOffset = Math.Min(Time, 20f); + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + + if (timeRatio >= 1f) + return false; + + for (float j = 1f; j >= 0f; j -= length) + { + // Color + Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : + ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : + ((timeRatio < 0.35f) ? color2 : + ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : + ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : + Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); + fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); + Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f); + + // Positions and rotations + Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; + float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length; + float trailRot = MathHelper.PiOver4 - mainRot; + + // Draw one backtrail + Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; + Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the main fire + Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the masking smoke + Main.spriteBatch.SetBlendState(BlendState.Additive); + Rectangle frame = mist.Frame(1, 3, 0, MistType); + Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); + Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; + */ + } + } +} diff --git a/Projectiles/Boss/CatastrophicCinder.cs b/Projectiles/Boss/CatastrophicCinder.cs new file mode 100644 index 0000000000..6e281aa52e --- /dev/null +++ b/Projectiles/Boss/CatastrophicCinder.cs @@ -0,0 +1,58 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Boss +{ + public class CatastrophicCinder : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 16; + Projectile.hostile = true; + Projectile.penetrate = CalamityWorld.death ? 4 : 3; + Projectile.timeLeft = 300; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void AI() + { + Projectile.rotation += 0.2f * Projectile.direction; + + Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0f); + + var p = CatastropheMetaball.SpawnParticle(Projectile.Center + Projectile.velocity, -Projectile.velocity, Terraria.GameContent.TextureAssets.Projectile[Type].Width() * 2); + p.rotation = Projectile.rotation; + p.TextureToUse = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + p.SizeScaling = 0.5f; + + Projectile.Opacity = 0; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + for (var i = 0; i < 10; i++) + { + var p = CatastropheMetaball.SpawnParticle(Projectile.Center + Projectile.velocity, Main.rand.NextVector2Circular(4, 4), 16); + p.SizeScaling = 0.9f; + } + if (Projectile.velocity.Y != oldVelocity.Y) + Projectile.velocity.Y = -oldVelocity.Y; + if (Projectile.velocity.X != oldVelocity.X) + Projectile.velocity.X = -oldVelocity.X; + return Projectile.penetrate-- == 0; + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 120); + } + } +} diff --git a/Projectiles/Boss/BrimstoneBall.png b/Projectiles/Boss/CatastrophicCinder.png similarity index 100% rename from Projectiles/Boss/BrimstoneBall.png rename to Projectiles/Boss/CatastrophicCinder.png diff --git a/Projectiles/Boss/CirrusBlast.cs b/Projectiles/Boss/CirrusBlast.cs deleted file mode 100644 index 37c926aaa8..0000000000 --- a/Projectiles/Boss/CirrusBlast.cs +++ /dev/null @@ -1,162 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class CirrusBlast : BaseLaserbeamProjectile, ILocalizedModType - { - // Modified clone of Seraphim's Laser - public new string LocalizationCategory => "Projectiles.Boss"; - - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public int OwnerIndex - { - get => (int)Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - - public override float MaxScale => Projectile.ai[0]; - - public override float MaxLaserLength => 2400f; - - public override float Lifetime => 50; - - public override Color LaserOverlayColor - { - get - { - return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - } - } - - public override Color LightCastColor => Color.Transparent; - - public override Texture2D LaserBeginTexture => ModContent.Request("CalamityMod/Projectiles/Rogue/SeraphimBeamLarge", AssetRequestMode.ImmediateLoad).Value; - - public override Texture2D LaserMiddleTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeMiddle", AssetRequestMode.ImmediateLoad).Value; - - public override Texture2D LaserEndTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeEnd", AssetRequestMode.ImmediateLoad).Value; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 10; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 30; - Projectile.hostile = true; - Projectile.alpha = 255; - Projectile.penetrate = -1; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.timeLeft = 200; - Projectile.Calamity().DealsDefenseDamage = true; - CooldownSlot = ImmunityCooldownID.Bosses; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Projectile.localAI[0]); - writer.Write(Projectile.localAI[1]); - writer.Write(Projectile.scale); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - Projectile.localAI[0] = reader.ReadSingle(); - Projectile.localAI[1] = reader.ReadSingle(); - Projectile.scale = reader.ReadSingle(); - } - - public override void UpdateLaserMotion() - { - // Update the direction and rotation of the laser. - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - } - - public override float DetermineLaserLength() => MaxLaserLength; - - public override void PostAI() - { - // Determine frames. - Projectile.frameCounter++; - if (Projectile.frameCounter % 5f == 4f) - Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; - } - - public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f; - - public override bool PreDraw(ref Color lightColor) - { - // This should never happen, but just in case. - if (Projectile.velocity == Vector2.Zero) - return false; - - Color beamColor = LaserOverlayColor; - Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - - // Start texture drawing. - Vector2 centerOnLaser = Projectile.Center + Projectile.velocity * Projectile.scale * 116f; - Main.EntitySpriteDraw(LaserBeginTexture, - centerOnLaser - Main.screenPosition, - startFrameArea, - beamColor, - Projectile.rotation, - LaserBeginTexture.Size() / 2f, - Projectile.scale, - SpriteEffects.None, - 0); - - // Prepare things for body drawing. - float laserBodyLength = LaserLength + middleFrameArea.Height; - - // Body drawing. - if (laserBodyLength > 0f) - { - float laserOffset = middleFrameArea.Height * Projectile.scale; - float incrementalBodyLength = 0f; - while (incrementalBodyLength + 1f < laserBodyLength) - { - centerOnLaser += Projectile.velocity * laserOffset; - incrementalBodyLength += laserOffset; - Main.EntitySpriteDraw(LaserMiddleTexture, - centerOnLaser - Main.screenPosition, - middleFrameArea, - beamColor, - Projectile.rotation, - LaserMiddleTexture.Size() * 0.5f, - Projectile.scale, - SpriteEffects.None, - 0); - } - } - - Vector2 laserEndCenter = centerOnLaser + Projectile.velocity * endFrameArea.Height * Projectile.scale - Main.screenPosition; - Main.EntitySpriteDraw(LaserEndTexture, - laserEndCenter, - endFrameArea, - beamColor, - Projectile.rotation, - LaserEndTexture.Size() * 0.5f, - Projectile.scale, - SpriteEffects.None, - 0); - - return false; - } - } -} diff --git a/Projectiles/Boss/CirrusBlaster.cs b/Projectiles/Boss/CirrusBlaster.cs deleted file mode 100644 index ab60a0adc6..0000000000 --- a/Projectiles/Boss/CirrusBlaster.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class CirrusBlaster : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - - public override string Texture => "CalamityMod/Items/Potions/Alcohol/OddMushroom"; - public static readonly SoundStyle SANSCharge = new("CalamityMod/Sounds/Custom/Ravager/GasterBlasterCharge"); - public static readonly SoundStyle SANSFire = new("CalamityMod/Sounds/Custom/Ravager/GasterBlasterFire"); - public Vector2 storedVelocity; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 42; - Projectile.hostile = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.timeLeft = 180; - CooldownSlot = ImmunityCooldownID.Bosses; - } - - public override void AI() - { - // ai0 = timer, ai1 = laser size - if (Projectile.ai[0] < 90f) // Before the laser - { - Projectile.ai[0]++; - if (storedVelocity == Vector2.Zero) - { - storedVelocity = Projectile.SafeDirectionTo(Projectile.velocity); - Projectile.velocity = Vector2.Zero; - Projectile.netUpdate = true; - Projectile.rotation = (float)Math.Atan2(storedVelocity.Y, storedVelocity.X) + MathHelper.PiOver2; - - SoundEngine.PlaySound(SANSCharge, Projectile.Center); // Funny Gaster Blaster sounds - } - else if (Projectile.ai[0] >= 55f) - { - Projectile.ai[0] = 90f; - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, storedVelocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, Projectile.ai[1], Projectile.whoAmI); - - SoundEngine.PlaySound(SANSFire, Projectile.Center); // Funny Gaster Blaster sounds #2 - } - } - else // Move out and despawn - { - // Start moving - if (Projectile.velocity == Vector2.Zero) - Projectile.velocity = storedVelocity * -1f; - else - Projectile.velocity *= 1.01f; - - // Fade out and die - Projectile.alpha += 3; - if (Projectile.alpha >= 255) - Projectile.Kill(); - } - } - - // Does no contact damage - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Boss/CirrusPhotonRipperPrismTooth.cs b/Projectiles/Boss/CirrusPhotonRipperPrismTooth.cs deleted file mode 100644 index 9a06af2a88..0000000000 --- a/Projectiles/Boss/CirrusPhotonRipperPrismTooth.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Primitives; -using CalamityMod.NPCs.SupremeCalamitas; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent.Achievements; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class CirrusPhotonRipperPrismTooth : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - - public override string Texture => "CalamityMod/Projectiles/Melee/PrismTooth"; - - public const int Lifetime = 80; - - public NPC Cirrus => Main.npc.IndexInRange((int)Projectile.ai[2]) ? Main.npc[(int)Projectile.ai[2]] : null; - - public ref float ShootReach => ref Projectile.ai[0]; - - public ref float Time => ref Projectile.ai[1]; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 36; - } - - public override void SetDefaults() - { - Projectile.Calamity().DealsDefenseDamage = true; - Projectile.width = 30; - Projectile.height = 52; - Projectile.hostile = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.extraUpdates = 5; - Projectile.timeLeft = Lifetime; - CooldownSlot = ImmunityCooldownID.Bosses; - } - - public override void AI() - { - // Die if Cirrus disappears. - if (Cirrus is null || !Cirrus.active) - { - Projectile.Kill(); - return; - } - - // Die if Cirrus shouldn't be using it. - int cirrusBulletHellCounter = Cirrus.ModNPC().bulletHellCounter2; - if (!(cirrusBulletHellCounter > SupremeCalamitas.SecondBulletHellEndValue && cirrusBulletHellCounter < SupremeCalamitas.ThirdBulletHellEndValue) && - !(cirrusBulletHellCounter > SupremeCalamitas.FourthBulletHellEndValue && cirrusBulletHellCounter < SupremeCalamitas.FifthBulletHellEndValue)) - { - Projectile.Kill(); - return; - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.Pi * Time / Lifetime; - - Vector2 baseDirection = (MathHelper.TwoPi * Time / Lifetime - MathHelper.PiOver2).ToRotationVector2(); - baseDirection.X *= 0.25f; - - // Constrain the Y offset into the bounds of 0-1 instead of -1-1. - // This prevents the crystal from flying behind the owner. In this context, the Y offset becomes how far away the crystal is from its own in terms of reach. - baseDirection.Y = baseDirection.Y * 0.5f + 0.5f; - Vector2 positionOffset = baseDirection * ShootReach; - - // Don't allow the X offset to go too far. - // This hard limit turns the squashed circle into bending, semi-rectangular shape. - if (Math.Abs(positionOffset.X) > 45f) - positionOffset.X = Math.Sign(baseDirection.X) * 45f; - - // In this context, the velocity is simply the initial direction as a unit vector- it does not actually influence movement in any way. - positionOffset = positionOffset.RotatedBy(Projectile.velocity.ToRotation() - MathHelper.PiOver2); - - Vector2 cirrusRotatedPosition = Cirrus.Center; - float rotation = Cirrus.rotation; - Vector2 vector = Cirrus.Bottom + new Vector2(0f, Cirrus.gfxOffY); - Vector2 vector2 = new Vector2(0f, -4f) + new Vector2(0f, 4f).RotatedBy(rotation); - cirrusRotatedPosition.Y += Cirrus.gfxOffY; - cirrusRotatedPosition = vector + (cirrusRotatedPosition - vector).RotatedBy(rotation) + vector2; - Projectile.Center = cirrusRotatedPosition + Projectile.velocity * 42f + positionOffset; - Projectile.Opacity = Utils.GetLerpValue(0f, 12f, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - 12f, Lifetime - Projectile.timeLeft, true); - - // Destroy trees within the range of the past 20 oldPos positions. - for (int i = 0; i < 20; i++) - { - Point pointToCheck = (Projectile.oldPos[i] + Projectile.Size * 0.5f).ToTileCoordinates(); - AbsolutelyFuckingAnnihilateTrees(pointToCheck.X, pointToCheck.Y); - } - - // Emit light. - Lighting.AddLight(Projectile.Center, Vector3.One * 0.7f); - - Time++; - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox); - - public void AbsolutelyFuckingAnnihilateTrees(int x, int y) - { - Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); - - // Ignore tiles that are not active and are not breakable by axes. - if (!tileAtPosition.HasTile || !Main.tileAxe[tileAtPosition.TileType]) - return; - - // Don't attempt to mine the tile if for whatever reason it's not supposed to be broken. - if (!WorldGen.CanKillTile(x, y)) - return; - - AchievementsHelper.CurrentlyMining = true; - - WorldGen.KillTile(x, y); - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y); - - AchievementsHelper.CurrentlyMining = false; - } - - public override Color? GetAlpha(Color lightColor) => Color.HotPink; - - internal float WidthFunction(float completionRatio) => Projectile.scale * 24f * (1f - Utils.GetLerpValue(0.7f, 1f, completionRatio, true)) + 1f; - - internal Color ColorFunction(float completionRatio) => Color.HotPink * Projectile.Opacity; - - public override bool PreDraw(ref Color lightColor) - { - if (Time <= 5f) - return true; - - // Variable adjustment vector used to prevent the trail for starting somewhat that isn't behind - // the crystal. This may appear in small amounts, with offsets of a few pixels, but at the speed - // these crystals go, it's probably not something to worry too much about. - Vector2 generalOffset = Projectile.rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2) * 15f; - generalOffset += Projectile.rotation.ToRotationVector2() * -5f * (float)Math.Sin(Projectile.rotation); - - // Mess with the oldPos array so that the trail always points towards the crystal. - Vector2 oldPosition = Projectile.oldPos[1]; - Projectile.oldPos[1] = Projectile.oldPos[0] - Projectile.rotation.ToRotationVector2() * Vector2.Distance(Projectile.oldPos[0], Projectile.oldPos[1]); - - // Revert back if the above calculations caused any NaNs. - if (Projectile.oldPos[1].HasNaNs()) - Projectile.oldPos[1] = oldPosition; - - Main.spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"]), 65); - Main.spriteBatch.ExitShaderRegion(); - return true; - } - - // Prevent the crystals from utilizing velocity. Their movement is entirely dependant on Center setting. - public override bool ShouldUpdatePosition() => false; - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 300); - } -} diff --git a/Projectiles/Boss/CirrusPhotonRipperProjectile.cs b/Projectiles/Boss/CirrusPhotonRipperProjectile.cs deleted file mode 100644 index c7363796be..0000000000 --- a/Projectiles/Boss/CirrusPhotonRipperProjectile.cs +++ /dev/null @@ -1,243 +0,0 @@ -using System; -using CalamityMod.NPCs.SupremeCalamitas; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class CirrusPhotonRipperProjectile : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - - public override string Texture => "CalamityMod/Projectiles/Melee/PhotonRipperProjectile"; - - public NPC Cirrus => Main.npc.IndexInRange((int)Projectile.ai[2]) ? Main.npc[(int)Projectile.ai[2]] : null; - public const float ZeroChargeDamageRatio = 0.36f; - public const float ToothDamageRatio = 0.1666667f; - public const int ToothShootRate = 5; // One chainsaw tooth is emitted every this many frames. - public const int ChargeUpTime = 150; - - public ref float Time => ref Projectile.ai[0]; - - // This is the damage dealt by the chainsaw teeth. It is recalculated every frame in two steps: - // 1) The chainsaw's damage itself is calculated as a long-lasting holdout (like Last Prism -- in case buffs wear off or similar) - // 2) The chainsaw teeth damage scales with charging up. The chainsaw's own damage does not. - public ref float ToothDamage => ref Projectile.ai[1]; - public float ChargeUpPower => MathHelper.Clamp((float)Math.Pow(Time / ChargeUpTime, 1.6D), 0f, 1f); - - public override void SetDefaults() - { - Projectile.Calamity().DealsDefenseDamage = true; - Projectile.width = 132; - Projectile.height = 56; - Projectile.hostile = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - CooldownSlot = ImmunityCooldownID.Bosses; - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Texture2D glowmaskTexture = ModContent.Request("CalamityMod/Projectiles/Melee/PhotonRipperGlowmask").Value; - Rectangle glowmaskRectangle = glowmaskTexture.Frame(1, 6, 0, Projectile.frame); - Vector2 origin = texture.Size() * 0.5f; - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - - Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0); - Main.EntitySpriteDraw(glowmaskTexture, drawPosition, glowmaskRectangle, Color.HotPink, Projectile.rotation, origin, Projectile.scale, direction, 0); - return false; - } - - public override void AI() - { - // Die if Cirrus disappears. - if (Cirrus is null || !Cirrus.active) - { - Projectile.Kill(); - return; - } - - // Die if Cirrus shouldn't be using it. - int cirrusBulletHellCounter = Cirrus.ModNPC().bulletHellCounter2; - if (!(cirrusBulletHellCounter > SupremeCalamitas.SecondBulletHellEndValue && cirrusBulletHellCounter < SupremeCalamitas.ThirdBulletHellEndValue) && - !(cirrusBulletHellCounter > SupremeCalamitas.FourthBulletHellEndValue && cirrusBulletHellCounter < SupremeCalamitas.FifthBulletHellEndValue)) - { - Projectile.Kill(); - return; - } - - Projectile.damage = SupremeCalamitas.CirrusPhotonRipperDamage; - DetermineDamage(); - - PlayChainsawSounds(); - - // Determines the owner's position whilst incorporating their fullRotation field. - // It uses vector transformation on a Z rotation matrix based on said rotation under the hood. - // This is essentially just the pure mathematical definition of the RotatedBy method. - Vector2 cirrusRotatedPosition = Cirrus.Center; - float rotation = Cirrus.rotation; - Vector2 vector = Cirrus.Bottom + new Vector2(0f, Cirrus.gfxOffY); - Vector2 vector2 = new Vector2(0f, -4f) + new Vector2(0f, 4f).RotatedBy(rotation); - cirrusRotatedPosition.Y += Cirrus.gfxOffY; - cirrusRotatedPosition = vector + (cirrusRotatedPosition - vector).RotatedBy(rotation) + vector2; - HandleMovement(cirrusRotatedPosition); - DetermineVisuals(cirrusRotatedPosition); - EmitPrettyDust(); - - if (Time % ToothShootRate == ToothShootRate - 1f) - ReleasePrismTeeth(); - - // Prevent the projectile from dying normally. - // However, if anything for whatever reason goes wrong it will immediately be destroyed on the next frame. - Projectile.timeLeft = 2; - - Time++; - } - - public void PlayChainsawSounds() - { - if (Projectile.soundDelay <= 0) - { - SoundEngine.PlaySound(SoundID.Item22, Projectile.Center); - Projectile.soundDelay = (int)MathHelper.Lerp(30f, 12f, ChargeUpPower); - } - } - - public void DetermineDamage() - { - // Set the initial tooth damage the instant the projectile is created. - if (ToothDamage == 0f) - { - ToothDamage = ToothDamageRatio * Projectile.damage; - Projectile.netUpdate = true; - } - - // And then do time based damage calculations. This does not execute if the original damage is 0. - // This line covers adjusting tooth damage if the projectile's own damage changes. - if (ToothDamage != 0f) - { - float fullMult = ToothDamageRatio; - float zeroMult = ZeroChargeDamageRatio * ToothDamageRatio; - ToothDamage = (int)MathHelper.SmoothStep(Projectile.damage * zeroMult, Projectile.damage * fullMult, ChargeUpPower); - } - } - - public void DetermineVisuals(Vector2 cirrusRotatedPosition) - { - float directionAngle = Projectile.velocity.ToRotation(); - Projectile.rotation = directionAngle; - - int oldDirection = Projectile.spriteDirection; - if (oldDirection == -1) - Projectile.rotation += MathHelper.Pi; - - Projectile.direction = Projectile.spriteDirection = (Math.Cos(directionAngle) > 0).ToDirectionInt(); - - // If the direction differs from what it originaly was, undo the previous 180 degree turn. - // If this is not done, the chainsaw will have 1 frame of rotational "jitter" when the direction changes based on the original angle. - // This effect looks very strange in-game. - if (Projectile.spriteDirection != oldDirection) - Projectile.rotation -= MathHelper.Pi; - - // Positioning close to the Cirrus' arm. - Projectile.position = cirrusRotatedPosition - Projectile.Size * 0.5f + directionAngle.ToRotationVector2() * 30f; - - // Update the position a tiny bit every frame at random to make it look like the saw is vibrating. - // It is reset on the next frame. - Projectile.position += Main.rand.NextVector2Circular(1.4f, 1.4f); - - // Update glowmask frames. - // Smoothstep is essentially like a linear interpolation but instead of being a straight line its - // curve is pseudo-logistic, with low increases at the ends of the curve. - Projectile.frameCounter += (int)MathHelper.SmoothStep(12f, 33f, ChargeUpPower); - if (Projectile.frameCounter >= 32) - { - Projectile.frame = (Projectile.frame + 1) % 6; - Projectile.frameCounter = 0; - } - } - - public void HandleMovement(Vector2 cirrusRotatedPosition) - { - Vector2 idealAimDirection = (Main.player[Cirrus.target].Center - cirrusRotatedPosition).SafeNormalize(Vector2.UnitX * Cirrus.direction); - - float angularAimVelocity = 0.03f; - float directionAngularDisparity = Projectile.velocity.AngleBetween(idealAimDirection) / MathHelper.Pi; - - // Increase the turn speed if close to the ideal direction, since successive linear interpolations are asymptotic. - angularAimVelocity += MathHelper.Lerp(0f, 0.05f, Utils.GetLerpValue(0.28f, 0.08f, directionAngularDisparity, true)); - - if (directionAngularDisparity > 0.02f) - Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealAimDirection, angularAimVelocity); - else - Projectile.velocity = idealAimDirection; - - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX * Cirrus.direction); - } - - public void EmitPrettyDust() - { - if (Main.dedServ) - return; - - for (int i = 0; i < 2; i++) - { - Vector2 spawnPosition = Projectile.Center + Projectile.velocity * 35f; - - // Spawn the dust a little bit on the chainsaw. X variance is less than Y variance to ensure that dust does not - // spawn too far from the blade. - spawnPosition += Main.rand.NextVector2CircularEdge(9f, 35f).RotatedBy(Projectile.velocity.ToRotation() + MathHelper.PiOver2); - - Dust rainbowSpark = Dust.NewDustPerfect(spawnPosition, 261); - rainbowSpark.velocity = Projectile.velocity * 3f + Main.rand.NextVector2CircularEdge(1.5f, 1.5f); - rainbowSpark.noGravity = true; - rainbowSpark.color = Color.HotPink; - rainbowSpark.scale = Main.rand.NextFloat(0.9f, 1.25f); - } - } - - public void ReleasePrismTeeth() - { - // Play the sound that the crystal vile shard uses. - // Hopefully this isn't too cancerous to listen to, given the shoot rate of the crystals. - SoundEngine.PlaySound(SoundID.Item101, Projectile.Center); - - if (Main.myPlayer != Projectile.owner) - return; - - float shootReach = MathHelper.SmoothStep(Projectile.width * 1.8f, Projectile.width * 5.3f + 16f, ChargeUpPower); - float distanceFromTarget = Cirrus.Distance(Main.player[Cirrus.target].Center); - - // If the distance to the mouse is less than the base reach, reach only to mouse. - // This way the player can more directly control the crystals if they want. - // This comes with a small constant offset to cancel out other factors. - // If the mouse is very close to the player, set the shoot reach to its minimum. - if (distanceFromTarget < shootReach) - { - if (distanceFromTarget > 40f) - shootReach = distanceFromTarget + 32f; - else - shootReach = 72f; - } - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Cirrus.Center, Projectile.velocity, ModContent.ProjectileType(), (int)ToothDamage, 0f, Projectile.owner, shootReach, Projectile.whoAmI, Projectile.ai[2]); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - // Collision is done as a line to bypass the fact that hitboxes cannot rotate and that this projectile is notably flat in terms of sprite shape. - float _ = 0f; - float width = Projectile.scale * 36f; - Vector2 start = Projectile.Center; - Vector2 end = Projectile.Center + Projectile.velocity * 70f; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, width, ref _); - } - } -} diff --git a/Projectiles/Boss/CirrusVolatileVodkaBottle.cs b/Projectiles/Boss/CirrusVolatileVodkaBottle.cs deleted file mode 100644 index 753d43bf97..0000000000 --- a/Projectiles/Boss/CirrusVolatileVodkaBottle.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using CalamityMod.Buffs.Alcohol; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.Projectiles.Magic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class CirrusVolatileVodkaBottle : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - - public override string Texture => "CalamityMod/Items/Potions/Alcohol/CirrusVodka"; - - public override void SetDefaults() - { - Projectile.width = 30; - Projectile.height = 30; - Projectile.hostile = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 120; - Projectile.aiStyle = ProjAIStyleID.ThrownProjectile; - AIType = ProjectileID.ThrowingKnife; - } - - public override void AI() - { - if (Projectile.ai[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item106, Projectile.Center); - Projectile.ai[0] = 1f; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - 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.Shatter, Projectile.Center); - - for (int i = 0; i < 10; i++) - { - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 0, default, 1.2f); - Main.dust[dust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[dust].scale = 0.5f; - Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - - for (int i = 0; i < 20; i++) - { - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.BlueCosmilite, 0f, 0f, 0, default, 1.7f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 5f; - dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 0, default, 1f); - Main.dust[dust].velocity *= 2f; - } - - if (Projectile.owner == Main.myPlayer) - { - int totalProjectiles = 3; - float radians = MathHelper.TwoPi / totalProjectiles; - int type = ModContent.ProjectileType(); - float velocity = 8f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Vector2.Normalize(velocity2) * 10f, velocity2, type, (int)Math.Round(Projectile.damage * 0.8), 0f, Main.myPlayer); - if (proj.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[proj].DamageType = DamageClass.Default; - Main.projectile[proj].friendly = false; - Main.projectile[proj].hostile = true; - } - } - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - Projectile.Kill(); - target.AddBuff(ModContent.BuffType(), 54000); - } - } -} diff --git a/Projectiles/Boss/CrimulanSpike.cs b/Projectiles/Boss/CrimulanSpike.cs index 17e7b62fd7..4daf6e82f2 100644 --- a/Projectiles/Boss/CrimulanSpike.cs +++ b/Projectiles/Boss/CrimulanSpike.cs @@ -1,13 +1,6 @@ -using System; -using System.IO; -using CalamityMod.Events; -using CalamityMod.NPCs; -using CalamityMod.Sounds; -using CalamityMod.World; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -25,7 +18,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 20; Projectile.height = 20; Projectile.hostile = true; @@ -52,29 +44,20 @@ namespace CalamityMod.Projectiles.Boss { Color dustColor = Color.Crimson; dustColor.A = 150; - int redSpiky = Dust.NewDust(Projectile.position - Projectile.velocity * 3f, Projectile.width, Projectile.height, DustID.SparksMech, 0f, 0f, 50, dustColor, 1.2f); + int redSpiky = Dust.NewDust(Projectile.position - Projectile.velocity * 3f, Projectile.width, Projectile.height, DustID.TintableDust); Main.dust[redSpiky].velocity *= 0.3f; Main.dust[redSpiky].velocity += Projectile.velocity * 0.3f; + Main.dust[redSpiky].color = dustColor; + Main.dust[redSpiky].scale = 1.4f; Main.dust[redSpiky].noGravity = true; } } public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.Darkness, 180); - } - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Projectile.ai[2] > 0f ? ModContent.Request("CalamityMod/Projectiles/Boss/CrimulanSpike" + ((int)Projectile.ai[2] + 1)).Value : TextureAssets.Projectile[Projectile.type].Value; - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1, texture); return false; } diff --git a/Projectiles/Boss/CursedFire.cs b/Projectiles/Boss/CursedFire.cs index cf1555fc68..7958501fdf 100644 --- a/Projectiles/Boss/CursedFire.cs +++ b/Projectiles/Boss/CursedFire.cs @@ -1,6 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -38,7 +36,7 @@ namespace CalamityMod.Projectiles.Boss { Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); - Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, 75, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); + Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, DustID.CursedTorch, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); if (Main.rand.NextBool(3)) { cinder.scale *= 2f; diff --git a/Projectiles/Boss/DarkEnergyBall.cs b/Projectiles/Boss/DarkEnergyBall.cs index ad7fa65911..b25def68c5 100644 --- a/Projectiles/Boss/DarkEnergyBall.cs +++ b/Projectiles/Boss/DarkEnergyBall.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.NPCs; using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -32,7 +31,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; Projectile.Opacity = 0f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.zenithWorld) Projectile.extraUpdates = 1; } diff --git a/Projectiles/Boss/DarkEnergyBall2.cs b/Projectiles/Boss/DarkEnergyBall2.cs index 17076168fc..ce12a35a0e 100644 --- a/Projectiles/Boss/DarkEnergyBall2.cs +++ b/Projectiles/Boss/DarkEnergyBall2.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.NPCs; using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -32,7 +31,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; Projectile.Opacity = 0f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.zenithWorld) Projectile.extraUpdates = 1; } diff --git a/Projectiles/Boss/DesertScourgeDiveSplash.cs b/Projectiles/Boss/DesertScourgeDiveSplash.cs index 42f310eac0..e988fd9b65 100644 --- a/Projectiles/Boss/DesertScourgeDiveSplash.cs +++ b/Projectiles/Boss/DesertScourgeDiveSplash.cs @@ -1,10 +1,5 @@ -using System; -using System.IO; -using CalamityMod.Dusts; -using CalamityMod.World; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Boss/DesertScourgeSpit.cs b/Projectiles/Boss/DesertScourgeSpit.cs index a7e4915e0e..02de3a207c 100644 --- a/Projectiles/Boss/DesertScourgeSpit.cs +++ b/Projectiles/Boss/DesertScourgeSpit.cs @@ -1,7 +1,5 @@ -using System; -using System.IO; +using System.IO; using CalamityMod.Dusts; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -25,12 +23,10 @@ namespace CalamityMod.Projectiles.Boss { Projectile.width = 16; Projectile.height = 16; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Projectile.scale = 2f; Projectile.hostile = true; Projectile.tileCollide = false; Projectile.penetrate = 1; - Projectile.timeLeft = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 900 : 600; + Projectile.timeLeft = 600; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.alpha = 255; } @@ -65,7 +61,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.alpha < 0) Projectile.alpha = 0; - int sandyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulphurousSeaAcid, 0f, 0f, 100, default, 1f); + int sandyDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.YellowTorch, 0f, 0f, 100, default, 1f); Main.dust[sandyDust].noGravity = true; Main.dust[sandyDust].velocity *= 0f; } diff --git a/Projectiles/Boss/DestroyerElectricLaser.cs b/Projectiles/Boss/DestroyerElectricLaser.cs index 5a30ce18b1..0b9e4572dd 100644 --- a/Projectiles/Boss/DestroyerElectricLaser.cs +++ b/Projectiles/Boss/DestroyerElectricLaser.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Boss/DeusMine.cs b/Projectiles/Boss/DeusMine.cs index 83a4612665..d440cb096b 100644 --- a/Projectiles/Boss/DeusMine.cs +++ b/Projectiles/Boss/DeusMine.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Boss for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, (int)Math.Round(Projectile.damage * 0.75), 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, AstrumDeusBody.LaserDamage, 0f, Main.myPlayer, 1f, 0f); } } } @@ -146,7 +146,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || Projectile.timeLeft > MaxTimeLeft - FadeTime || (Projectile.timeLeft < FadeTime && Projectile.ai[0] == 0f)) return; - target.AddBuff(ModContent.BuffType(), 75); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Boss/DeusRitualDrama.cs b/Projectiles/Boss/DeusRitualDrama.cs index 8ff63ebb1e..95812d46ba 100644 --- a/Projectiles/Boss/DeusRitualDrama.cs +++ b/Projectiles/Boss/DeusRitualDrama.cs @@ -42,18 +42,11 @@ namespace CalamityMod.Projectiles.Boss Time++; if (Time == TotalRitualTime - PulseTime) { - int idx = NPC.NewNPC(Projectile.GetSource_FromThis(), (int)Projectile.Center.X, (int)Projectile.Center.Y - (int)MaxUpwardRise, ModContent.NPCType(), 1); - if (idx != -1) + if (Main.netMode != NetmodeID.MultiplayerClient) { - SoundEngine.PlaySound(AstrumDeusHead.SpawnSound, Projectile.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { + int idx = NPC.NewNPC(Projectile.GetSource_FromThis(), (int)Projectile.Center.X, (int)Projectile.Center.Y - (int)MaxUpwardRise, ModContent.NPCType(), 1); + if (idx != -1) CalamityUtils.BossAwakenMessage(idx); - } - else - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, idx); - } } } } @@ -95,14 +88,14 @@ namespace CalamityMod.Projectiles.Boss { for (int i = 0; i < 20; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY * offset.Y, 261); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY * offset.Y, DustID.AncientLight); dust.color = Utils.SelectRandom(Main.rand, Color.Cyan, Color.OrangeRed); dust.scale = 1.15f; dust.velocity = Main.rand.NextVector2CircularEdge(3f, 3f) * Main.rand.NextFloat(0.7f, 1.4f); dust.noGravity = true; float angle = MathHelper.TwoPi * i / 20f; - dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY * offset.Y, 261); + dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY * offset.Y, DustID.AncientLight); dust.color = Utils.SelectRandom(Main.rand, Color.Cyan, Color.OrangeRed); dust.scale = 1.15f; dust.velocity = angle.ToRotationVector2() * 7f; @@ -164,13 +157,13 @@ namespace CalamityMod.Projectiles.Boss // Generate dust at the star position. This gives them a trail effect. if (!Main.dedServ) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset, 261); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset, DustID.AncientLight); dust2.color = Color.Cyan; dust2.scale = 1.15f; dust2.velocity = Vector2.Zero; dust2.noGravity = true; - dust2 = Dust.NewDustPerfect(Projectile.Center + offset * new Vector2(-1f, 1f), 261); + dust2 = Dust.NewDustPerfect(Projectile.Center + offset * new Vector2(-1f, 1f), DustID.AncientLight); dust2.color = Color.OrangeRed; dust2.scale = 1.15f; dust2.velocity = Vector2.Zero; diff --git a/Projectiles/Boss/DoGBeam.cs b/Projectiles/Boss/DoGBeam.cs index 6be31c977f..aedd5782d1 100644 --- a/Projectiles/Boss/DoGBeam.cs +++ b/Projectiles/Boss/DoGBeam.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.World; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -25,7 +23,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = 1; Projectile.timeLeft = 960; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.zenithWorld) Projectile.extraUpdates = 1; } diff --git a/Projectiles/Boss/DoGBeamPortal.cs b/Projectiles/Boss/DoGBeamPortal.cs index dca2e08b29..3bcb6147b6 100644 --- a/Projectiles/Boss/DoGBeamPortal.cs +++ b/Projectiles/Boss/DoGBeamPortal.cs @@ -84,10 +84,9 @@ namespace CalamityMod.Projectiles.Boss } // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool death = CalamityWorld.death || bossRush; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; Lighting.AddLight(Projectile.Center, 0f, 0.95f, 1.15f); @@ -102,7 +101,7 @@ namespace CalamityMod.Projectiles.Boss double deg = Projectile.ai[1]; double rad = deg * (Math.PI / 180); - double dist = bossRush ? 360D : death ? 400D : revenge ? 420D : expertMode ? 440D : 480D; + double dist = death ? 400D : revenge ? 420D : expertMode ? 440D : 480D; Projectile.position.X = player.Center.X - (int)(Math.Cos(rad) * dist) - Projectile.width / 2; Projectile.position.Y = player.Center.Y - (int)(Math.Sin(rad) * dist) - Projectile.height / 2; Projectile.ai[1] += 1f; @@ -118,7 +117,6 @@ namespace CalamityMod.Projectiles.Boss { SoundEngine.PlaySound(SoundID.Item33, Projectile.Center); float speed = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3f; - speed *= Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; int totalProjectiles = 3; float radians = MathHelper.TwoPi / totalProjectiles; for (int i = 0; i < totalProjectiles; i++) diff --git a/Projectiles/Boss/DoGDeath.cs b/Projectiles/Boss/DoGDeath.cs index b1ff1dcefa..685c26d719 100644 --- a/Projectiles/Boss/DoGDeath.cs +++ b/Projectiles/Boss/DoGDeath.cs @@ -1,7 +1,5 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -41,7 +39,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.tileCollide = false; Projectile.Opacity = 0f; Projectile.penetrate = -1; - Projectile.timeLeft = 480; + Projectile.timeLeft = 300; CooldownSlot = ImmunityCooldownID.Bosses; } @@ -83,7 +81,7 @@ namespace CalamityMod.Projectiles.Boss // If an old velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> if (OldVelocity != Vector2.Zero) { - Projectile.velocity = OldVelocity * (BossRushEvent.BossRushActive ? 1.25f : 1f); + Projectile.velocity = OldVelocity; OldVelocity = Vector2.Zero; Projectile.netUpdate = true; } diff --git a/Projectiles/Boss/DoGFire.cs b/Projectiles/Boss/DoGFire.cs index 315a98ac61..c3f0496bcf 100644 --- a/Projectiles/Boss/DoGFire.cs +++ b/Projectiles/Boss/DoGFire.cs @@ -1,25 +1,39 @@ using System; +using System.Linq; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using CalamityMod.Enums; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.DataStructures; using Terraria; using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { - public class DoGFire : ModProjectile, ILocalizedModType + public class DoGFire : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { - public new string LocalizationCategory => "Projectiles.Boss"; - public override void SetStaticDefaults() + public bool IsAPassiveFireball { - Main.projFrames[Type] = 6; - ProjectileID.Sets.TrailCacheLength[Type] = 3; - ProjectileID.Sets.TrailingMode[Type] = 0; + get => Projectile.ai[0] == 2f; + set => Projectile.ai[0] = value.ToInt(); } + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/DoGFireball"); + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 10; + ProjectileID.Sets.TrailingMode[Type] = 2; + } public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 34; Projectile.height = 34; Projectile.hostile = true; @@ -27,129 +41,136 @@ namespace CalamityMod.Projectiles.Boss Projectile.tileCollide = false; Projectile.extraUpdates = 1; Projectile.penetrate = -1; - Projectile.timeLeft = 480; + Projectile.timeLeft = 300; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 15; CooldownSlot = ImmunityCooldownID.Bosses; } + public override void OnSpawn(IEntitySource source) + { + if (IsAPassiveFireball) + SoundEngine.PlaySound(SpawnSound, Projectile.Center); + } + public override void AI() { - if (Projectile.localAI[0] == 0f && Projectile.ai[1] == 0f) + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Main.rand.NextBool(12)) { - Projectile.localAI[0] = 1f; - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + for (int i = 0; i < 2; i++) + { + Vector2 dustSpawnPosition = Projectile.Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 dustVelocity = Projectile.velocity * -1.2f; + float dustScale = Main.rand.NextFloat(0.6f, 0.8f) * Projectile.scale; + Color dustColor = Color.Lerp(Color.White, IsAPassiveFireball ? Color.SkyBlue : Color.Purple, Main.rand.NextFloat(0.5f, 1f)); + + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } } - Projectile.frameCounter++; - if (Projectile.frameCounter > 4) + if (Main.rand.NextBool(2)) { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 5) - Projectile.frame = 0; + for (int i = 0; i < 3; i++) + { + Vector2 smokeVelocity = -Projectile.velocity * 0.7f + Main.rand.NextVector2Circular(1f, 1f) * 0.65f; + int smokeLifetime = Main.rand.Next(10, 15) * (Projectile.friendly ? 1 : 2); + float smokeScale = Main.rand.NextFloat(0.25f, 0.45f) * Projectile.scale; + float smokeOpacity = Main.rand.NextFloat(0.7f, 0.9f); + Color flameColor = Color.Lerp(Color.White, IsAPassiveFireball ? Color.SkyBlue : Color.Purple, Main.rand.NextFloat(0.5f, 1f)); - int dust = Dust.NewDust(new Vector2(Projectile.position.X + Projectile.velocity.X, Projectile.position.Y + Projectile.velocity.Y), Projectile.width, Projectile.height, DustID.ShadowbeamStaff, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.8f); - Main.dust[dust].noGravity = true; - - Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - - if (Projectile.ai[1] > 0f) - { - if (Projectile.velocity.Length() < Projectile.ai[1]) - Projectile.velocity *= Projectile.ai[0]; + HeavySmokeParticle ghastlySmoke = new(Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), smokeVelocity, flameColor, smokeLifetime, smokeScale, smokeOpacity, 0.02f, true); + GeneralParticleHandler.SpawnParticle(ghastlySmoke); + } } } - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 0); - public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 160); + target.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(5)); } public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 64; - Projectile.position.X = Projectile.position.X - Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; - for (int i = 0; i < 5; i++) + // Spawn a burst of dust at the center. + for (int i = 0; i < 12; i++) { - int godSlay = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 2f); - Main.dust[godSlay].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[godSlay].scale = 0.5f; - Main.dust[godSlay].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 10; j++) - { - int godSlay2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 3f); - Main.dust[godSlay2].noGravity = true; - Main.dust[godSlay2].velocity *= 5f; - godSlay2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 2f); - Main.dust[godSlay2].velocity *= 2f; - } - for (int k = 0; k < 200; k++) - { - float dustScale = 12f; - if (k < 150) - dustScale = 9f; - if (k < 100) - dustScale = 6f; - if (k < 50) - dustScale = 3f; + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(3f, 5f); + Color dustColor = Color.Lerp(Color.White, IsAPassiveFireball ? Color.SkyBlue : Color.Purple, Main.rand.NextFloat(0.5f, 1f)); - int scalingDust = Dust.NewDust(Projectile.Center, 6, 6, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 1f); - float scalingDustVelX = Main.dust[scalingDust].velocity.X; - float scalingDustVelY = Main.dust[scalingDust].velocity.Y; - - if (scalingDustVelX == 0f && scalingDustVelY == 0f) - scalingDustVelX = 1f; - - float scalingDustVelocity = (float)Math.Sqrt(scalingDustVelX * scalingDustVelX + scalingDustVelY * scalingDustVelY); - scalingDustVelocity = dustScale / scalingDustVelocity; - scalingDustVelX *= scalingDustVelocity; - scalingDustVelY *= scalingDustVelocity; - - float scale = 1f; - switch ((int)dustScale) - { - case 4: - scale = 1.2f; - break; - case 8: - scale = 1.1f; - break; - case 12: - scale = 1f; - break; - case 16: - scale = 0.9f; - break; - default: - break; - } - - Dust dust = Main.dust[scalingDust]; - dust.velocity *= 0.5f; - dust.velocity.X += scalingDustVelX; - dust.velocity.Y += scalingDustVelY; - dust.scale = scale; + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; } Projectile.Damage(); } + + public override bool PreDraw(ref Color lightColor) => false; + + public float FireWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = 72f * Projectile.scale; + float curveRatio = 0.2f; + + // Crop the tip of the trail into a conic shape. + if (completion < curveRatio) + width = MathF.Pow(completion/curveRatio,0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return width + additionalPulseWidth; + } + + public Color FireColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = IsAPassiveFireball ? Color.Cyan : Color.Purple * 1.3f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion); + } + + public float FireCoreWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = Projectile.scale * (IsAPassiveFireball ? 24f : 64f); + float curveRatio = 0.25f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width; + } + + public Color FireCoreColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = IsAPassiveFireball ? Color.SkyBlue : Color.Fuchsia; + Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); + return Color.Lerp(fullBodyColor, Color.White, 0.175f); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + // Render the main trail for the body for the flame. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_,_) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero)*24f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 12); + + // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. + int coreLength = IsAPassiveFireball ? 6 : 7; + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos[..coreLength], new(FireCoreWidthFunction, FireCoreColorFunction, (_,_) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * 24f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), coreLength + 8); + } } } diff --git a/Projectiles/Boss/DoGFire.png b/Projectiles/Boss/DoGFire.png deleted file mode 100644 index a97abf9659..0000000000 Binary files a/Projectiles/Boss/DoGFire.png and /dev/null differ diff --git a/Projectiles/Boss/DoGLaserWalls.cs b/Projectiles/Boss/DoGLaserWalls.cs new file mode 100644 index 0000000000..6dc45dc94d --- /dev/null +++ b/Projectiles/Boss/DoGLaserWalls.cs @@ -0,0 +1,199 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DoGLaserWalls : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Boss"; + public float time = 0; + public ref float attackSpeed => ref Projectile.ai[0]; // How fast the attack goes, higher is faster + public ref float laserDist => ref Projectile.ai[1]; // The spacing between lasers + public ref float laserType => ref Projectile.ai[2]; // The style of laser wall, ranging from 0 - 5 (6 for GFB circular variant) + public bool canDamage => doneAttack && laserFX >= 1f; + public bool doneAttack = false; + public int attackTime = 30; + public int laserCount => (int)(6000 / Math.Max(laserDist, 1)); + public float laserLength => laserDist * laserCount / 2; + public float laserFX = 0; + public float storedTime = 0; + public Color drawColor = Color.Cyan; + public float sine = 0; + public Vector2 storedTargetPos; + public Player targeted; + public Vector2 targetPos => (targeted == null ? Projectile.Center : targeted.Center); + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + } + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 6000; + } + public override void AI() + { + if (laserFX > 0) + laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.12f : 0.01f); + sine = (float)Math.Sin(time * 4f / MathHelper.Pi); + + if (time == 0) + { + targeted = Main.player[Player.FindClosest(Projectile.Center, 1, 1)]; + // Some default values for if the projectile spawns without them set + if (attackSpeed == 0) + attackSpeed = 0.5f; + if (laserDist == 0) + laserDist = 250; + Projectile.velocity = Vector2.Zero; + laserFX = 1f; + + SoundStyle appear = new("CalamityMod/Sounds/Custom/DoGLaserWallSpawn"); + SoundEngine.PlaySound(appear with { Volume = 1f, Pitch = 0f, MaxInstances = -1 }, targetPos); + storedTargetPos = targetPos; + Projectile.ForceNetUpdate(); + } + if (time >= attackTime && !doneAttack) + { + SoundStyle attack = new("CalamityMod/Sounds/Custom/DoGLaserWallLightAttack"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(attack with { Volume = 0.9f, Pitch = 0, MaxInstances = -1 }, targetPos); + laserFX = 3; + doneAttack = true; + storedTime = time; + Projectile.ForceNetUpdate(); + } + float endTime = storedTime + 10; + if (time >= endTime && doneAttack) + { + Projectile.Kill(); + return; + } + else if (doneAttack) + { + drawColor = Color.Lerp(Color.Cyan, Color.Magenta, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2)); + } + time += attackSpeed; + } + public override bool CanHitPlayer(Player target) + { + if (canDamage) + { + if (laserType == 6) + { + float distance = Vector2.Distance(Projectile.Center, target.Center); + float expand = MathF.Min(target.width, target.height); + if (distance < laserDist * 1.5f || distance > laserDist * 10f + 40f) + return false; + + if (distance % laserDist > (laserDist - Utils.Remap(distance, 240f, 1440f, 8f, 56f) - expand) || distance % laserDist < expand) + return true; + } + else + return true; + } + return false; + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(ModContent.BuffType(), 60); + base.OnHitPlayer(target, info); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canDamage) + return false; + else if (laserType == 6) // Custom hit check through CanHitPlayer + return true; + else + { + float _ = float.NaN; + bool hit = false; + Vector2 X = Vector2.UnitX.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + Vector2 Y = Vector2.UnitY.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + for (int l = 0; l < 2; l++) + { + bool horizontal = (l != 0); + bool crossLasers = ((laserType == 2 && !horizontal) || (laserType == 3 && !horizontal) || (laserType == 4 && horizontal) || (laserType == 5 && horizontal)); + float length = laserLength * (horizontal ? 1f : 1f); + for (int i = 0; i < laserCount; i += (crossLasers ? 2 : 1)) + { + Vector2 startPoint = Projectile.Center - (horizontal ? Y : X) * (length); + Vector2 laserPoint = startPoint + (horizontal ? X : Y) * (laserDist * i) - (horizontal ? X : Y) * (laserDist * laserCount / 2); + Vector2 rot = laserPoint.DirectionTo(storedTargetPos); + + Vector2 start = laserPoint; + Vector2 end = laserPoint + (crossLasers ? rot : (horizontal ? Y : X)) * laserLength * 2; + + bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 10, ref _); + if (hitCheck) + { + hit = true; + i = laserCount; + } + } + } + return hit; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (laserFX == 0) + return false; + Texture2D beam = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D bBeam = ModContent.Request("CalamityMod/Particles/LineThick").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float opacity = (doneAttack ? 0.65f : 0.3f) * (float)Math.Pow(Math.Min(laserFX, 1), 2); + if (CalamityClientConfig.Instance.Photosensitivity) + opacity = 0.2f; + + Color beamColor = drawColor with { A = 0 }; + if (laserType == 6) + { + Texture2D ring = ModContent.Request("CalamityMod/Particles/BloomRingThinLarge").Value; + for (float scale = 0.25f * laserDist / 120f; scale < 1.25f; scale += 0.125f * laserDist / 120f) + Main.EntitySpriteDraw(ring, Projectile.Center - Main.screenPosition, null, beamColor * opacity, 0f, ring.Size() * 0.5f, scale, SpriteEffects.None); + return false; + } + + Vector2 X = Vector2.UnitX.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + Vector2 Y = Vector2.UnitY.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + for (int l = 0; l < 2; l++) + { + bool horizontal = (l != 0); + float length = laserLength; + bool crossLasers = ((laserType == 2 && !horizontal) || (laserType == 3 && !horizontal) || (laserType == 4 && horizontal) || (laserType == 5 && horizontal)); + for (int i = 0; i < laserCount; i += (crossLasers ? 2 : 1)) + { + Vector2 startPoint = Projectile.Center - (horizontal ? Y : X) * (length); + Vector2 laserPoint = startPoint + (horizontal ? X : Y) * (laserDist * i) - (horizontal ? X : Y) * (laserDist * laserCount / 2); + + for (int t = 0; t < (!doneAttack ? 1 : 5); t++) + { + bool black = (t > 0); + Texture2D usedTex = (black ? bBeam : beam); + + float beamThickness = 0.03f * (black ? (0.8f - 0.15f * t) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f); + float rot = (horizontal ? MathHelper.Pi : MathHelper.PiOver2) + ((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + if (crossLasers) + rot = laserPoint.DirectionTo(storedTargetPos).ToRotation() + (MathHelper.PiOver2); + Main.EntitySpriteDraw(usedTex, laserPoint - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * opacity) * (black ? (0.2f + 0.15f * t) : 1), rot, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness, length / 975) * Projectile.scale, SpriteEffects.None); + } + } + } + return false; + } + } +} diff --git a/Projectiles/Boss/DoGLaserWallsBigBeam.cs b/Projectiles/Boss/DoGLaserWallsBigBeam.cs new file mode 100644 index 0000000000..68b6529f61 --- /dev/null +++ b/Projectiles/Boss/DoGLaserWallsBigBeam.cs @@ -0,0 +1,144 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DoGLaserWallsBigBeam : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Boss"; + public float time = 0; + public ref float attackSpeed => ref Projectile.ai[0]; + public ref float laserType => ref Projectile.ai[2]; + public bool canDamage => doneAttack && laserFX >= 1f; + public bool doneAttack = false; + public int attackTime = 30; + public float laserLength => 3000; + public float laserFX = 0; + public float storedTime = 0; + public Color drawColor = Color.Magenta; + public float sine = 0; + public float laserRot = 0; + Vector2 beamStart = Vector2.Zero; + Vector2 directionToTarget = Vector2.Zero; + public Player targeted; + public Vector2 targetPos => (targeted == null ? Projectile.Center : targeted.Center); + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + } + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 6000; + Projectile.scale = 2; + } + public override void AI() + { + if (laserFX > 0) + laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.07f : 0.01f); + sine = (float)Math.Sin(time * 4f / MathHelper.Pi); + if (time == 0) + { + targeted = Main.player[Player.FindClosest(Projectile.Center, 1, 1)]; + if (CalamityWorld.LegendaryMode) + Projectile.scale = 6; + laserRot = Main.rand.NextFloat(-0.4f, 0.4f); + + beamStart = targetPos + ((laserType == 0 || laserType == 4 || laserType == 5) ? Vector2.UnitX : Vector2.UnitY).RotatedBy(laserRot) * laserLength; + directionToTarget = beamStart.DirectionTo(targetPos); + + Projectile.Center += Main.rand.NextVector2CircularEdge(400, 400); + // Some default values for if the projectile spawns without them set + if (attackSpeed == 0) + attackSpeed = 0.5f; + Projectile.velocity = Vector2.Zero; + laserFX = 1f; + Projectile.ForceNetUpdate(); + } + if (time >= attackTime && !doneAttack) + { + Main.LocalPlayer.SetScreenshake(7f); + SoundStyle attack = new("CalamityMod/Sounds/Custom/DoGLaserWallBigAttack2"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(attack with { Volume = 0.8f, Pitch = 0, MaxInstances = -1 }, targetPos); + laserFX = 2.5f; + doneAttack = true; + storedTime = time; + Projectile.ForceNetUpdate(); + } + float endTime = storedTime + 10; + if (time >= endTime && doneAttack) + { + Projectile.Kill(); + return; + } + else if (doneAttack) + { + drawColor = Color.Lerp(Color.Magenta, Color.Cyan, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2)); + } + time += attackSpeed; + } + public override bool CanHitPlayer(Player target) + { + if (canDamage) + return true; + return false; + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(ModContent.BuffType(), 60); + base.OnHitPlayer(target, info); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canDamage) + return false; + else + { + float _ = float.NaN; + Vector2 start = beamStart; + Vector2 end = beamStart + directionToTarget * laserLength * 2; + bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 30 * Projectile.scale, ref _); + + return hitCheck; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (laserFX == 0) + return false; + Texture2D beam = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D bBeam = ModContent.Request("CalamityMod/Particles/LineThick").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float opacity = (doneAttack ? 0.65f : 0.35f) * (float)Math.Pow(Math.Min(laserFX, 1), 2); + Color beamColor = drawColor with { A = 0 }; + + if (CalamityClientConfig.Instance.Photosensitivity) + opacity = 0.2f; + for (int t = 0; t < (!doneAttack ? 1 : 4 * Projectile.scale); t ++) + { + bool black = (t > 0 + (Projectile.scale - 1)); + if (black) + beam = bBeam; + + float beamThickness = 0.09f * (black ? (0.8f - 0.15f * t / Projectile.scale) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f); + Main.EntitySpriteDraw(beam, beamStart - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * (1 - t * 0.3f) * opacity) * (black ? (0.2f + 0.15f * t / Projectile.scale) : 1), directionToTarget.ToRotation() + MathHelper.PiOver2, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness, laserLength / 975) * Projectile.scale, SpriteEffects.None); + } + //Main.EntitySpriteDraw(bloom, Projectile.Center - Main.screenPosition, null, Color.Red with { A = 0 }, 0, bloom.Size() / 2, 0.3f, SpriteEffects.None); + return false; + } + } +} diff --git a/Projectiles/Boss/DoGRiftCrack.cs b/Projectiles/Boss/DoGRiftCrack.cs new file mode 100644 index 0000000000..4062829c4a --- /dev/null +++ b/Projectiles/Boss/DoGRiftCrack.cs @@ -0,0 +1,85 @@ +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DoGRiftCrack : ModProjectile, ILocalizedModType + { + public Vector2[] CrackPoints; + + public ref float Timer => ref Projectile.ai[0]; + + public ref float MaxWidth => ref Projectile.ai[1]; + + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 30; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 30; + } + + public override void AI() + { + float minDistanceBetweenPoints = 25f; + float maxDistanceBetweenPoints = 50f; + if (CrackPoints is null) + { + CrackPoints = new Vector2[25]; + + Vector2 startingPosition = Projectile.Center; + for (int i = 0; i < CrackPoints.Length; i++) + { + // First point should always be the starting position. + if (i == 0) + { + CrackPoints[i] = startingPosition; + } + // Next point pivots away from the starting position in the direction of the velocity. + else if (i == 1) + { + Vector2 nextPointPosition = startingPosition + Projectile.velocity * Main.rand.NextFloat(0.8f, 1.2f) + Main.rand.NextVector2Circular(30f, 30f); + CrackPoints[i] = nextPointPosition; + } + // All other points follow after the last one with the same slight offset to resemble cracks. + else + { + Vector2 previousPoint = CrackPoints[i - 2]; + float distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints); + if (i == CrackPoints.Length - 1) + distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints) * 0.5f; + + Vector2 newPoint = CrackPoints[i - 1] + (previousPoint.DirectionTo(CrackPoints[i - 1]) * distanceFromLastPoint).RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(-5f, 5f) * i * 0.25f)); + CrackPoints[i] = newPoint; + } + + if (Main.rand.NextBool(9)) + CrackPoints[i] += Main.rand.NextVector2Circular(10f, 10f); + } + } + + Projectile.scale = MathHelper.Lerp(1f, 0f, Timer / 30f); + Timer++; + } + + public float CrackWidthFunction(float completion, Vector2 vertexPos) => Projectile.scale * MathHelper.Lerp(MaxWidth, 0f, completion); + + public Color CrackColorFunction(float completion, Vector2 vertexPos) => Projectile.GetAlpha(Color.White); + + public override bool PreDraw(ref Color lightColor) + { + if (CrackPoints is not null) + { + PrimitiveRenderer.RenderTrail(CrackPoints, new(CrackWidthFunction, CrackColorFunction, null, false)); + } + return false; + } + } +} diff --git a/Projectiles/Boss/DoGTeleportRift.cs b/Projectiles/Boss/DoGTeleportRift.cs index bf28c53f02..9c758d1a81 100644 --- a/Projectiles/Boss/DoGTeleportRift.cs +++ b/Projectiles/Boss/DoGTeleportRift.cs @@ -1,133 +1,289 @@ -using System; -using CalamityMod.Dusts; +using System.IO; +using CalamityMod.Effects; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Particles; +using CalamityMod.Skies; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { public class DoGTeleportRift : ModProjectile, ILocalizedModType { + public static readonly SoundStyle CrackSound = new("CalamityMod/Sounds/NPCHit/CryogenHit", 3); + + public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/NPCHit/CryogenPhaseTransitionCrack"); + + // GFB exclusive; DoG can spawn fake rifts on that seed to confuse the player. + public bool FakeRift; + + public int RiftLifetime; + + public NPC DoGHead => Main.npc[(int)Projectile.ai[0]]; + + public ref float Timer => ref Projectile.ai[1]; + + public ref float CrackScale => ref Projectile.ai[2]; + + public ref float AIState => ref Projectile.localAI[0]; + + public ref float CrackExposure => ref Projectile.localAI[1]; + + public ref float MaxExposure => ref Projectile.localAI[2]; + public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/StarProj"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() { Projectile.width = Projectile.height = 30; - Projectile.scale = 2.5f; - Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.Opacity = 0f; + Projectile.scale = 0f; Projectile.penetrate = -1; - Projectile.timeLeft = 200; + Projectile.timeLeft = RiftLifetime; + } + + public override bool? CanDamage() => false; + + public override bool ShouldUpdatePosition() => false; + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(FakeRift); + writer.Write(RiftLifetime); + for (int i = 0; i < Projectile.localAI.Length; i++) + writer.Write(Projectile.localAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + FakeRift = reader.ReadBoolean(); + RiftLifetime = reader.ReadInt32(); + for (int i = 0; i < Projectile.localAI.Length; i++) + Projectile.localAI[i] = reader.ReadSingle(); } public override void AI() { - if (Projectile.ai[0] == -1f) - return; - - if (Projectile.timeLeft < 160) - Projectile.timeLeft = 160; - - if (!Main.npc[(int)Projectile.ai[0]].active) - Projectile.Kill(); - - Projectile.ai[1] += MathHelper.Pi / 30f; - Projectile.Opacity = MathHelper.Clamp(Projectile.ai[1], 0f, 1f); - - if (Projectile.Opacity == 1f && Main.rand.NextBool(15)) + if (DoGHead is null || !DoGHead.active) { - Dust dust = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, DustID.RainbowMk2, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f)]; - dust.velocity.X = 0f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * (4f * Main.rand.NextFloat() + 26f); - dust.scale = 0.5f; + Projectile.Kill(); + return; + } + + // Pre-explosion, charge-up. + if (AIState == 0f) + { + int riftCrackInterval = (int)(RiftLifetime / 3f); + if (Timer % riftCrackInterval == 0f) + { + // Increase the intensity of certain effects as the crack gets bigger. + float effectsLifetimeInterpolant = MathHelper.Lerp(1f, 2f, Timer / RiftLifetime); + + // Only let the real rift on GFB perform these additional effects. + if (!FakeRift) + { + float crackPitch = MathHelper.Lerp(-0.75f, 0f, Timer / RiftLifetime); + SoundEngine.PlaySound(CrackSound with { Pitch = crackPitch }, Projectile.Center); + + for (int i = 0; i < 12; i++) + { + Vector2 sparkVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(8f, 12f) * effectsLifetimeInterpolant * 0.7f; + float sparkScale = Main.rand.NextFloat(1.2f, 1.6f) * effectsLifetimeInterpolant * 0.62f; + Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(crackSpark); + } + + for (int i = 0; i < 8; i++) + { + Vector2 lightVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 14f) * effectsLifetimeInterpolant * 0.5f; + float lightScale = Main.rand.NextFloat(1.2f, 1.6f) * effectsLifetimeInterpolant * 0.62f; + Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SquishyLightParticle crackLight = new(Projectile.Center, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45)); + GeneralParticleHandler.SpawnParticle(crackLight); + } + + CalamityUtils.AddScreenshakeAt(Projectile.Center, 6f * effectsLifetimeInterpolant * 0.8f); + } + + float brightnessMultiplier = FakeRift ? 0.75f : 1f; + CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion2", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f * effectsLifetimeInterpolant, 45); + GeneralParticleHandler.SpawnParticle(shineExplosion2); + + // Increase the scale and exposure of the actual crack at each interval. + CrackScale += 0.525f * effectsLifetimeInterpolant * 0.75f; + MaxExposure = MathHelper.Clamp(MaxExposure + 0.25f * effectsLifetimeInterpolant, 0f, 0.95f); + } + + // Perform the explosion right at the point where DoG emerges. + if (Timer >= RiftLifetime) + SwitchAIStates(); + + if (Projectile.timeLeft < 45) + Projectile.timeLeft = 45; + + CrackExposure = MathHelper.Lerp(CrackExposure, MaxExposure, 0.075f); + Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.05f, 0f, 1f); + Projectile.scale = MathHelper.Clamp(Projectile.scale + 0.02f, 0f, 1f); + Projectile.ForceNetUpdate(); + } + + // Post-explosion, slowly fade out. + if (AIState == 1f) + { + Projectile.Opacity = MathHelper.Lerp(1f, 0f, Timer / 45f); + CrackExposure = MathHelper.Lerp(MaxExposure, 0f, Timer / 45f); + } + + Timer++; + } + + public void SwitchAIStates() + { + AIState = 1f; + Timer = 0f; + CrackScale += 3f; + Projectile.timeLeft = 30; + SpawnExplosionVisuals(); + Projectile.netUpdate = true; + } + + public void SpawnExplosionVisuals() + { + float brightnessMultiplier = CalamityClientConfig.Instance.Photosensitivity ? 0.6f : 1f; + if (!FakeRift) + { + // Spawn the rift cracks. + for (int i = 0; i < 25; i++) + { + Vector2 crackOffset = Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / 25) * Main.rand.NextFloat(20f, 80f); + Vector2 crackDestination = Projectile.Center + crackOffset; + Vector2 crackLength = crackDestination - Projectile.Center; + float riftWidth = Main.rand.NextFloat(20f, 30f); + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, crackLength, ModContent.ProjectileType(), 0, 0f, ai1: riftWidth); + } + + // Spawn a bunch of square-shaped metaballs at the impact zone as well. + for (int i = 0; i < 35; i++) + DoGDistortionMetaball.SpawnParticle(Projectile.Center + Main.rand.NextVector2Circular(25f, 25f), Vector2.Zero, 500f, true, Main.rand.NextFloat(MathHelper.TwoPi)); + + // More metaballs flying away from the impact zone for extra flavor. + int metaballAmount = Main.rand.Next(15, 21); + for (int i = 0; i < metaballAmount; i++) + DoGDistortionMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2Unit() * Main.rand.NextFloat(25f, 35f), Main.rand.NextFloat(30f, 50f)); + + // Addtional particles and effects. + for (int i = 0; i < 25; i++) + { + Vector2 sparkVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 16f); + float sparkScale = Main.rand.NextFloat(1.8f, 2f); + Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(crackSpark); + } + + for (int i = 0; i < 20; i++) + { + Vector2 lightVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(16f, 20f); + float lightScale = Main.rand.NextFloat(1.8f, 2f); + Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SquishyLightParticle crackLight = new(Projectile.Center, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45)); + GeneralParticleHandler.SpawnParticle(crackLight); + } + + // Explosion visuals. + for (int i = 0; i < 3; i++) + { + CustomPulse plasmaExplosion = new(Projectile.Center, Vector2.Zero, DoGSky.DoGTwlight * 0.8f * brightnessMultiplier, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 1.25f + i * 0.05f, 45); + GeneralParticleHandler.SpawnParticle(plasmaExplosion); + } + + CustomPulse shineExplosion = new(Projectile.Center, Vector2.Zero, DoGSky.DoGTwlight * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion1", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.75f, 45); + GeneralParticleHandler.SpawnParticle(shineExplosion); + CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White * 0.6f * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion2", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f, 45); + GeneralParticleHandler.SpawnParticle(shineExplosion2); + StrongBloom bloom = new(Projectile.Center, Vector2.Zero, Color.White * 0.8f * brightnessMultiplier, 8f, 30); + GeneralParticleHandler.SpawnParticle(bloom); + + SoundEngine.PlaySound(BreakSound, Projectile.Center); + CalamityUtils.AddScreenshakeAt(Projectile.Center, 14f); + } + else + { + for (int i = 0; i < 3; i++) + { + PulseRing fakerDeathRing = new(Projectile.Center, Vector2.Zero, Color.White * 0.45f * brightnessMultiplier, 0f, 3f + i * 0.1f, 30 + i * 15); + GeneralParticleHandler.SpawnParticle(fakerDeathRing); + } } } public override bool PreDraw(ref Color lightColor) { - float lerpMult = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; + Texture2D crackTexture = ModContent.Request("CalamityMod/ExtraTextures/CrackedGlass_Glowing").Value; + Texture2D starTexture = ModContent.Request("CalamityMod/Projectiles/StarProj").Value; + Texture2D bloomRingTexture = ModContent.Request("CalamityMod/Particles/BloomRing").Value; - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color baseColor = new Color(150, 100, 255, 255) * Projectile.Opacity; - baseColor *= 0.5f; - baseColor.A = 0; - Color colorA = baseColor; - Color colorB = baseColor * 0.5f; - colorA *= lerpMult; - colorB *= lerpMult; - Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(3f, 9f) * Projectile.Opacity * lerpMult; + float chargeInterpolant = CalamityUtils.SineInOutEasing(Timer / RiftLifetime, 1); + float brightnessMultiplier = FakeRift ? 0.6f : 1f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 verticalStarPartScale = new Vector2(1f, 8f) * chargeInterpolant * Projectile.scale * 3.25f; + Vector2 horizontalStarPartScale = new Vector2(1f, 5f) * chargeInterpolant * Projectile.scale * 3.25f; - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); + Main.spriteBatch.SetBlendState(BlendState.Additive); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2 + Projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, Projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2 + Projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, Projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + // Draw the glowing star. + Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White * 0.7f * brightnessMultiplier * chargeInterpolant, 0f, starTexture.Size() * 0.5f, verticalStarPartScale, 0); + Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White * 0.7f * brightnessMultiplier * chargeInterpolant, MathHelper.PiOver2, starTexture.Size() * 0.5f, horizontalStarPartScale, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); - - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 + Projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + Projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 + Projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + Projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); - - return false; - } - - public override void OnKill(int timeLeft) - { - if (Projectile.ai[0] == -1f || Projectile.ai[2] == 1f) - return; - - int dustAmt = 50; - int random = 5; - - for (int j = 0; j < 10; j++) + // Draw a smaller, twlight colored star at the center if this isn't a fake rift. + if (!FakeRift) { - random += j * 2; - int dustAmtSpawned = 0; - int scale = random * 13; - float dustPositionX = Projectile.Center.X - (scale / 2); - float dustPositionY = Projectile.Center.Y - (scale / 2); - while (dustAmtSpawned < dustAmt) - { - float dustVelocityX = Main.rand.Next(-random, random); - float dustVelocityY = Main.rand.Next(-random, random); - float dustVelocityScalar = random * 2f; - float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - dustVelocity = dustVelocityScalar / dustVelocity; - dustVelocityX *= dustVelocity; - dustVelocityY *= dustVelocity; - int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position.X = Projectile.Center.X; - Main.dust[dust].position.Y = Projectile.Center.Y; - Main.dust[dust].position.X += Main.rand.Next(-10, 11); - Main.dust[dust].position.Y += Main.rand.Next(-10, 11); - Main.dust[dust].velocity.X = dustVelocityX; - Main.dust[dust].velocity.Y = dustVelocityY; - dustAmtSpawned++; - } + Main.EntitySpriteDraw(starTexture, drawPosition, null, DoGSky.DoGTwlight * 0.9f * brightnessMultiplier * chargeInterpolant, 0f, starTexture.Size() * 0.5f, verticalStarPartScale * 0.8f, 0); + Main.EntitySpriteDraw(starTexture, drawPosition, null, DoGSky.DoGTwlight * 0.9f * brightnessMultiplier * chargeInterpolant, MathHelper.PiOver2, starTexture.Size() * 0.5f, horizontalStarPartScale * 0.8f, 0); } + + // Draw the crack. + Effect crackShader = CalamityShaders.DoGRealityCrackShader.Value; + float crackOpcity = (AIState == 1f) ? Projectile.Opacity * 0.1f : 0.1f; + Color darkerPixelColor = FakeRift ? Color.White : DoGSky.DoGTwlight; + + crackShader.Parameters["opacityCutoffValue"].SetValue(CrackExposure); + crackShader.Parameters["fadeoutPower"].SetValue(1f); + crackShader.Parameters["overallOpacity"].SetValue(crackOpcity * brightnessMultiplier); + crackShader.Parameters["minBrightnessValue"].SetValue(0.75f); + crackShader.Parameters["darkerPixelColor"].SetValue(darkerPixelColor.ToVector3()); + crackShader.Parameters["brighterPixelColor"].SetValue(Color.White.ToVector3()); + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, crackShader, Main.GameViewMatrix.TransformationMatrix); + int crackCount = FakeRift ? 1 : 3; + for (int i = 0; i < crackCount; i++) + { + float crackRotation = i * MathHelper.TwoPi / crackCount; + Main.EntitySpriteDraw(crackTexture, drawPosition + Vector2.UnitY * 8f, null, Color.White * Projectile.Opacity, crackRotation, crackTexture.Size() * 0.5f, CrackScale, 0); + } + Main.spriteBatch.End(); + } + + if (AIState != 1f) + { + // Draw the bloom ring which closes inwards. + float ringScale = MathHelper.Lerp(8f, 0f, chargeInterpolant); + Color ringColor = FakeRift ? Color.White : Color.Lerp(Color.White, DoGSky.DoGTwlight, chargeInterpolant); + Main.EntitySpriteDraw(bloomRingTexture, drawPosition, null, ringColor * brightnessMultiplier * chargeInterpolant * 0.6f, 0f, bloomRingTexture.Size() * 0.5f, ringScale, 0); + } + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/Boss/DoGWingdings.cs b/Projectiles/Boss/DoGWingdings.cs deleted file mode 100644 index c30a8365fb..0000000000 --- a/Projectiles/Boss/DoGWingdings.cs +++ /dev/null @@ -1,159 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using ReLogic.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class DoGWingdings : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public static DynamicSpriteFont Wingdings = null; - - public string dialogue; - - public override void SetStaticDefaults() - { - if (System.Environment.OSVersion.Platform == PlatformID.Win32NT) - { - Wingdings = CalamityMod.Instance.Assets.Request("Fonts/Wingdings", AssetRequestMode.ImmediateLoad).Value; - } - } - - public override void SetDefaults() - { - Projectile.width = 28; - Projectile.height = 28; - Projectile.penetrate = -1; - Projectile.hostile = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.timeLeft = 180; - Projectile.scale = 0; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(dialogue); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - dialogue = reader.ReadString(); - } - - public override void AI() - { - // Replicae CombatText behaviour - float targetScale = 1f; - Projectile.Opacity += (float)Projectile.ai[0] * 0.05f; - if ((double)Projectile.Opacity <= 0.6) - { - Projectile.ai[0] = 1; - } - if (Projectile.Opacity >= 1f) - { - Projectile.Opacity = 1f; - Projectile.ai[0] = -1; - } - Projectile.velocity.Y *= 0.8464f; - - Projectile.velocity.X *= 0.93f; - - if (Projectile.timeLeft <= 60) - { - Projectile.scale -= 0.1f * targetScale; - if ((double)Projectile.scale < 0.1) - { - Projectile.active = false; - } - Projectile.timeLeft = 60; - Projectile.ai[0] = -1; - Projectile.scale += 0.07f * targetScale; - return; - } - if (Projectile.velocity.X < 0f) - { - Projectile.rotation += 0.001f; - } - else - { - Projectile.rotation -= 0.001f; - } - if (Projectile.scale < targetScale) - { - Projectile.scale += 0.1f * targetScale; - } - if (Projectile.scale > targetScale) - { - Projectile.scale = targetScale; - } - } - - public override bool PreDraw(ref Color lightColor) - { - // Do not draw if the font isn't loaded or text is Cyrillic or Chinese - if (Wingdings == null || System.Environment.OSVersion.Platform != PlatformID.Win32NT || GameCulture.FromCultureName(GameCulture.CultureName.Chinese).IsActive || GameCulture.FromCultureName(GameCulture.CultureName.Russian).IsActive) - return false; - // Otherwise identical drawcode to CombatText - Vector2 stringSize = Wingdings.MeasureString(dialogue); - Vector2 origin = new Vector2(stringSize.X * 0.5f, stringSize.Y * 0.5f); - Color cyan = Color.Cyan; - float scale = Projectile.scale; - float red = (int)cyan.R; - float green = (int)cyan.G; - float blue = (int)cyan.B; - float alpha = (int)cyan.A; - red *= scale * Projectile.Opacity * 0.3f; - blue *= scale * Projectile.Opacity * 0.3f; - green *= scale * Projectile.Opacity * 0.3f; - alpha *= scale * Projectile.Opacity; - Color color = new Color((int)red, (int)green, (int)blue, (int)alpha); - for (int l = 0; l < 5; l++) - { - float xOffset = 0f; - float yOffset = 0f; - switch (l) - { - case 0: - xOffset -= 1f; - break; - case 1: - xOffset += 1f; - break; - case 2: - yOffset -= 1f; - break; - case 3: - yOffset += 1f; - break; - default: - red = (float)(int)cyan.R * scale * Projectile.Opacity; - blue = (float)(int)cyan.B * scale * Projectile.Opacity; - green = (float)(int)cyan.G * scale * Projectile.Opacity; - alpha = (float)(int)cyan.A * scale * Projectile.Opacity; - color = new Color((int)red, (int)green, (int)blue, (int)alpha); - break; - } - if (Main.LocalPlayer.gravDir != 1f) - { - float finalYPos = Projectile.position.Y - Main.screenPosition.Y; - finalYPos = (float)Main.screenHeight - finalYPos; - Main.spriteBatch.DrawString(Wingdings, dialogue.ToUpper(), new Vector2(Projectile.position.X - Main.screenPosition.X + xOffset + origin.X, finalYPos + yOffset + origin.Y), color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0f); - } - else - { - Main.spriteBatch.DrawString(Wingdings, dialogue.ToUpper(), new Vector2(Projectile.position.X - Main.screenPosition.X + xOffset + origin.X, Projectile.position.Y - Main.screenPosition.Y + yOffset + origin.Y), color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0f); - } - } - return false; - } - } -} diff --git a/Projectiles/Boss/DraedonSummonLaser.cs b/Projectiles/Boss/DraedonSummonLaser.cs index 2326b291de..17c0110705 100644 --- a/Projectiles/Boss/DraedonSummonLaser.cs +++ b/Projectiles/Boss/DraedonSummonLaser.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(TeslaCannon.FireSound, Projectile.Center); for (int i = 0; i < 36; i++) { - Dust exoDust = Dust.NewDustPerfect(Projectile.BottomRight, 267); + Dust exoDust = Dust.NewDustPerfect(Projectile.BottomRight, DustID.RainbowMk2); exoDust.color = CalamityUtils.MulticolorLerp(i / 36f, CalamityUtils.ExoPalette); exoDust.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * new Vector2(3f, 1.45f) - Vector2.UnitY * 2f; exoDust.scale = 2.8f; @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Boss for (int i = 0; i < 10; i++) { - Dust exoDust = Dust.NewDustPerfect(Projectile.BottomRight, 267); + Dust exoDust = Dust.NewDustPerfect(Projectile.BottomRight, DustID.RainbowMk2); exoDust.color = CalamityUtils.MulticolorLerp(Main.rand.NextFloat(), CalamityUtils.ExoPalette); exoDust.velocity = Main.rand.NextVector2Circular(2f, 2f); exoDust.scale = 4f; @@ -68,12 +68,12 @@ namespace CalamityMod.Projectiles.Boss Projectile.scale = Utils.GetLerpValue(-1f, 15f, Projectile.timeLeft, true) * Utils.GetLerpValue(Lifetime + 1f, Lifetime - 15f, Projectile.timeLeft, true); } - private float PrimitiveWidthFunction(float completionRatio) + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { return Utils.GetLerpValue(1f, 0.96f, completionRatio, true) * Utils.GetLerpValue(0f, 0.016f, completionRatio, true) * Projectile.scale * 20f; } - private Color PrimitiveColorFunction(float completionRatio) + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { return CalamityUtils.MulticolorLerp((Main.GlobalTimeWrappedHourly * 0.67f - completionRatio * 3f) % 1f, CalamityUtils.ExoPalette) * 1.2f; } @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Boss basePoints[i] = Projectile.Center - Vector2.UnitY * i / basePoints.Length * LaserLength; Vector2 overallOffset = Projectile.Size * 0.5f; - PrimitiveRenderer.RenderTrail(basePoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => overallOffset, shader: GameShaders.Misc["CalamityMod:Flame"]), 92); + PrimitiveRenderer.RenderTrail(basePoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => overallOffset, shader: GameShaders.Misc["CalamityMod:Flame"]), 92); return false; } diff --git a/Projectiles/Boss/DyingSun.cs b/Projectiles/Boss/DyingSun.cs index ebd8996414..90435e7abf 100644 --- a/Projectiles/Boss/DyingSun.cs +++ b/Projectiles/Boss/DyingSun.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using CalamityMod.Graphics.Primitives; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Graphics.Shaders; @@ -41,9 +40,9 @@ namespace CalamityMod.Projectiles.Boss Time++; } - public float SunWidthFunction(float completionRatio) => Radius * Projectile.scale * (float)Math.Sin(MathHelper.Pi * completionRatio); + public float SunWidthFunction(float completionRatio, Vector2 vertexPos) => Radius * Projectile.scale * (float)Math.Sin(MathHelper.Pi * completionRatio); - public Color SunColorFunction(float completionRatio) + public Color SunColorFunction(float completionRatio, Vector2 vertexPos) { Color sunColor = Main.zenithWorld ? (new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB) * 0.8f) : (Main.IsItDay() ? Color.Yellow : Color.Cyan); return Color.Lerp(sunColor, Color.White, (float)Math.Sin(MathHelper.Pi * completionRatio) * 0.5f + 0.3f) * Projectile.Opacity; diff --git a/Projectiles/Boss/EssenceDust.cs b/Projectiles/Boss/EssenceDust.cs index bb0f635a76..9a648b90fb 100644 --- a/Projectiles/Boss/EssenceDust.cs +++ b/Projectiles/Boss/EssenceDust.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Boss/FlareBomb.cs b/Projectiles/Boss/FlareBomb.cs index 0d9d4a4d21..515af26689 100644 --- a/Projectiles/Boss/FlareBomb.cs +++ b/Projectiles/Boss/FlareBomb.cs @@ -19,7 +19,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 64; Projectile.height = 66; Projectile.hostile = true; diff --git a/Projectiles/Boss/FlareDust.cs b/Projectiles/Boss/FlareDust.cs index 24a4917bfb..665620b277 100644 --- a/Projectiles/Boss/FlareDust.cs +++ b/Projectiles/Boss/FlareDust.cs @@ -26,7 +26,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 64; Projectile.height = 66; Projectile.scale = 1.5f; @@ -82,14 +81,14 @@ namespace CalamityMod.Projectiles.Boss float earlyTimeProjSpeed = Projectile.localAI[0] / 120f; if (earlyTimeProjSpeed > 1f) earlyTimeProjSpeed = 1f; - distance += MathHelper.Lerp(1f, 9f, earlyTimeProjSpeed); + distance += MathHelper.Lerp(1f, 11f, earlyTimeProjSpeed); if (Projectile.timeLeft < 380) { float longTimeProjSpeed = (Projectile.localAI[0] - 300f) / 240f; if (longTimeProjSpeed > 1f) longTimeProjSpeed = 1f; - distance += MathHelper.Lerp(1f, 9f, longTimeProjSpeed); + distance += MathHelper.Lerp(1f, 11f, longTimeProjSpeed); } double rad = MathHelper.ToRadians(Projectile.ai[1]); @@ -216,10 +215,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - if (Projectile.ai[0] == 3f) - target.AddBuff(ModContent.BuffType(), 160); - else - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Boss/FlareDust2.cs b/Projectiles/Boss/FlareDust2.cs index a2252c2bca..c6e34661ec 100644 --- a/Projectiles/Boss/FlareDust2.cs +++ b/Projectiles/Boss/FlareDust2.cs @@ -19,7 +19,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 64; Projectile.height = 66; Projectile.scale = 1.5f; diff --git a/Projectiles/Boss/Flarenado.cs b/Projectiles/Boss/Flarenado.cs index e8e1ce6b58..36c60ca07c 100644 --- a/Projectiles/Boss/Flarenado.cs +++ b/Projectiles/Boss/Flarenado.cs @@ -2,7 +2,6 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.NPCs.Yharon; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -110,7 +109,7 @@ namespace CalamityMod.Projectiles.Boss center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 11f, Projectile.ai[1] - 1f); } - int tornadoSpeed = 10; + int tornadoSpeed = 15; int breakThreshold = 300; Projectile.localAI[1] += 1f; bool breakapart = Main.zenithWorld && Projectile.localAI[1] >= breakThreshold; @@ -128,13 +127,10 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.localAI[1] == breakThreshold && Main.zenithWorld) { Projectile.velocity.X = Main.rand.NextBool() ? -tornadoSpeed : tornadoSpeed; - - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Projectile.velocity.X *= 1.5f; } if (Projectile.timeLeft == 480) - Projectile.damage = Projectile.GetProjectileDamage(ModContent.NPCType()); + Projectile.damage = Yharon.TornadoDamage; } public override bool CanHitPlayer(Player target) => Projectile.timeLeft <= 480; @@ -159,7 +155,7 @@ namespace CalamityMod.Projectiles.Boss return; if (Projectile.timeLeft <= 480) - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Boss/FoveanatorEnergyBomb.cs b/Projectiles/Boss/FoveanatorEnergyBomb.cs deleted file mode 100644 index 246e80bfb4..0000000000 --- a/Projectiles/Boss/FoveanatorEnergyBomb.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.NPCs; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class FoveanatorEnergyBomb : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - - private const int TotalXFrames = 2; - private const int TotalYFrames = 8; - private const int ExplodeFrames = 6; - private const int ExplodeDamageStartFrame = 3; - private const int FrameTimer = 6; - - public int frameX = 0; - public int frameY = 0; - - public int CurrentFrame - { - get => frameX * TotalYFrames + frameY; - set - { - frameX = value / TotalYFrames; - frameY = value % TotalYFrames; - } - } - - private const int TimeLeft = 300; - private const int SlowDownTime = TimeLeft / 2; - private const int ExplosionDuration = FrameTimer * ExplodeFrames; - - private const float ExplodeDistance = 50f; - - public override void SetDefaults() - { - Projectile.width = 133; - Projectile.height = 142; - Projectile.hostile = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.penetrate = -1; - Projectile.timeLeft = TimeLeft; - } - - public override void AI() - { - // If moving, decelerate. - if (Projectile.velocity.Length() > 0f && Projectile.timeLeft <= SlowDownTime) - Projectile.velocity *= 0.95f; - - // Get a target and calculate distance from it. - int target = Player.FindClosest(Projectile.Center, 1, 1); - float distanceFromTarget = Projectile.Distance(Main.player[target].Center); - - // Explode when within a certain distance of the target. - if (distanceFromTarget <= ExplodeDistance && Projectile.timeLeft > ExplosionDuration) - Projectile.timeLeft = ExplosionDuration; - - bool explode = Projectile.timeLeft <= ExplosionDuration; - - // Stop immediately if explosion is triggered. - if (explode && Projectile.velocity.Length() > 0f) - Projectile.velocity = Vector2.Zero; - - // Reset the frame counter and frameY when explosion is triggered. - if (Projectile.timeLeft == ExplosionDuration) - { - Projectile.frameCounter = 0; - frameY = 0; - } - - // Explosion noise when actually exploding. - if (frameY == ExplodeDamageStartFrame && explode && Projectile.localAI[0] == 0f) - { - Projectile.localAI[0] = 1f; - SoundEngine.PlaySound(DeusMine.ExplodeSound, Projectile.Center); - } - - Projectile.frameCounter++; - if (Projectile.frameCounter % FrameTimer == 0) - { - CurrentFrame++; - - // Non-explosion uses the left side of the sheet, explosion uses the right side of the sheet. - frameX = explode ? 1 : 0; - - // Kill the projectile when the explosion animation is done. - if (explode && frameY >= ExplodeFrames) - { - if (Projectile.ai[0] > 0f) - { - if (Projectile.owner == Main.myPlayer) - { - float laserSpeed = 2f; - int type = ModContent.ProjectileType(); - int damage = (int)Math.Round(Projectile.damage * 0.85); - Vector2 laserVelocity = (Main.player[target].Center - Projectile.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 16f, laserVelocity, type, damage, 0f, Main.myPlayer); - - if (Projectile.ai[0] == 2f) - { - Vector2 projectileVelocity = (Main.player[target].Center - Projectile.Center).SafeNormalize(Vector2.UnitY) * laserSpeed * 0.75f; - int numProj = 2; - int spread = 30; - float rotation = MathHelper.ToRadians(spread); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 16f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } - } - } - } - - Projectile.Kill(); - - return; - } - } - - // Explosion has brighter light. - Color lightColor = Color.Lerp(new Color(25, 25, 128), new Color(100, 25, 128), Main.DiscoR / 255f); - float divisor = explode ? 128f : 255f; - Lighting.AddLight(Projectile.Center, lightColor.R / divisor, lightColor.G / divisor, lightColor.B / divisor); - } - - public override bool PreDraw(ref Color lightColor) => false; - - public override void PostDraw(Color lightColor) - { - if (Projectile.frameCounter < 5) - return; - - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); - - Texture2D texture = TextureAssets.Projectile[Type].Value; - Vector2 position = Projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() / new Vector2(TotalXFrames, TotalYFrames) * 0.5f; - Rectangle frame = texture.Frame(TotalXFrames, TotalYFrames, frameX, frameY); - Main.EntitySpriteDraw(texture, position, frame, Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None); - } - - public override bool CanHitPlayer(Player target) => Projectile.timeLeft <= ExplosionDuration && frameY >= ExplodeDamageStartFrame; - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplodeDistance, targetHitbox); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (Projectile.timeLeft <= ExplosionDuration) - target.AddBuff(BuffID.Frostburn, 180); - } - } -} diff --git a/Projectiles/Boss/FoveanatorEnergyBomb.png b/Projectiles/Boss/FoveanatorEnergyBomb.png deleted file mode 100644 index 4e2a8120cb..0000000000 Binary files a/Projectiles/Boss/FoveanatorEnergyBomb.png and /dev/null differ diff --git a/Projectiles/Boss/FoveanatorFlamethrower.cs b/Projectiles/Boss/FoveanatorFlamethrower.cs deleted file mode 100644 index 6583bef428..0000000000 --- a/Projectiles/Boss/FoveanatorFlamethrower.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class FoveanatorFlamethrower : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/FireProj"; - - public static int Lifetime => 180; - public static int Fadetime => 160; - public ref float Time => ref Projectile.ai[0]; - public int MistType = -1; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 10; - Projectile.hostile = true; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.MaxUpdates = 3; - Projectile.timeLeft = Lifetime; - CooldownSlot = ImmunityCooldownID.Bosses; - } - - public override void AI() - { - Time++; - if (Time < Fadetime && Main.rand.NextBool(6)) - { - Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); - float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); - Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, Main.rand.NextBool() ? (int)CalamityDusts.BlueCosmilite : (int)CalamityDusts.PurpleCosmilite, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); - if (Main.rand.NextBool(3)) - { - cinder.scale *= 2f; - cinder.velocity *= 2f; - } - cinder.noGravity = true; - cinder.scale *= cinderSize * 1.2f; - cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); - } - - if (MistType == -1) - MistType = Main.rand.Next(3); - - Color lightColor = Color.Lerp(new Color(50, 50, 255), new Color(200, 50, 255), Main.DiscoR / 255f); - Lighting.AddLight(Projectile.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); - } - - // Keeping the flames in place when hitting a block - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.velocity = oldVelocity * 0.95f; - Projectile.position -= Projectile.velocity; - Time++; - Projectile.timeLeft--; - return false; - } - - // Cannot hit the player if fading out - public override bool CanHitPlayer(Player target) => Time <= Fadetime; - - // Expanding hitbox - public override void ModifyDamageHitbox(ref Rectangle hitbox) - { - int size = (int)Utils.Remap(Time, 0f, Fadetime, 8f, 32f); - - // Shrinks again after fading - if (Time > Fadetime) - size = (int)Utils.Remap(Time, Fadetime, Lifetime, 32f, 0f); - - hitbox.Inflate(size, size); - } - - // Anti-wall hacking checks - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projHitbox.Intersects(targetHitbox) && Collision.CanHit(Projectile.Center, 0, 0, targetHitbox.Center.ToVector2(), 0, 0) ? null : false; - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(BuffID.Frostburn, 300); - - // Cook you up (still scales with player size in case it's manipulated) - int smokeCount = 4 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); - for (int i = 0; i < smokeCount; i++) - { - Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f); - Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-2.4f, -0.8f) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f); - Particle smoke = new MediumMistParticle(smokePos, smokeVel, Color.Lerp(new Color(50, 50, 255), new Color(200, 50, 255), Main.DiscoR / 255f), Color.DarkMagenta, Main.rand.NextFloat(1f, 2f), 245 - Main.rand.Next(50), 0.1f); - GeneralParticleHandler.SpawnParticle(smoke); - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D fire = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; - - // The conga line of colors to sift through - Color color1 = new Color(50, 50, 255, 200); - Color color2 = new Color(50, 0, 225, 70); - Color color3 = new Color(200, 50, 255, 100); - Color color4 = new Color(150, 15, 85, 100); - float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); - float vOffset = Math.Min(Time, 20f); - float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); - float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); - - if (timeRatio >= 1f) - return false; - - for (float j = 1f; j >= 0f; j -= length) - { - // Color - Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : - ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : - ((timeRatio < 0.35f) ? color2 : - ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : - ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : - Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); - fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); - Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f); - - // Positions and rotations - Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; - float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length; - float trailRot = MathHelper.PiOver4 - mainRot; - - // Draw one backtrail - Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; - Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); - - // Draw the main fire - Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); - - // Draw the masking smoke - Main.spriteBatch.SetBlendState(BlendState.Additive); - Rectangle frame = mist.Frame(1, 3, 0, MistType); - Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); - Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); - } - - return false; - } - } -} diff --git a/Projectiles/Boss/FoveanatorLaser.cs b/Projectiles/Boss/FoveanatorLaser.cs deleted file mode 100644 index fc73073e84..0000000000 --- a/Projectiles/Boss/FoveanatorLaser.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs.TownNPCs; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class FoveanatorLaser : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - - private const int FadeOutTime = 30; - - private const float Acceleration = 1.05f; - private const float MaxVelocity = 24f; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 4; - ProjectileID.Sets.TrailCacheLength[Type] = 2; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.hostile = true; - Projectile.ignoreWater = true; - Projectile.Opacity = 0f; - Projectile.penetrate = -1; - Projectile.timeLeft = 300; - } - - public override void AI() - { - Projectile.frameCounter++; - if (Projectile.frameCounter > 4) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 3) - Projectile.frame = 0; - - if (Projectile.velocity.Length() < MaxVelocity) - { - Projectile.velocity *= Acceleration; - if (Projectile.velocity.Length() > MaxVelocity) - { - Projectile.velocity.Normalize(); - Projectile.velocity *= MaxVelocity; - } - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - - Color lightColor = Color.Lerp(new Color(25, 25, 128), new Color(100, 25, 128), Main.DiscoR / 255f); - Lighting.AddLight(Projectile.Center, lightColor.R / 255f, lightColor.G / 255f, lightColor.B / 255f); - - if (Projectile.timeLeft < FadeOutTime) - { - Projectile.Opacity -= 1f / FadeOutTime; - } - else if (Projectile.Opacity < 1f) - { - Projectile.Opacity += 0.25f; - if (Projectile.Opacity > 1f) - Projectile.Opacity = 1f; - } - } - - public override bool PreDraw(ref Color lightColor) - { - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override bool CanHitPlayer(Player target) => Projectile.timeLeft >= FadeOutTime; - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (Projectile.timeLeft >= FadeOutTime) - target.AddBuff(BuffID.Frostburn, 90); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.Center, Projectile.velocity, Projectile.width, Projectile.height); - SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - return true; - } - } -} diff --git a/Projectiles/Boss/FoveanatorLaser.png b/Projectiles/Boss/FoveanatorLaser.png deleted file mode 100644 index 543c692773..0000000000 Binary files a/Projectiles/Boss/FoveanatorLaser.png and /dev/null differ diff --git a/Projectiles/Boss/FrostMist.cs b/Projectiles/Boss/FrostMist.cs index dc8229123f..21e7016604 100644 --- a/Projectiles/Boss/FrostMist.cs +++ b/Projectiles/Boss/FrostMist.cs @@ -121,14 +121,5 @@ namespace CalamityMod.Projectiles.Boss } public override bool CanHitPlayer(Player target) => Projectile.Opacity == 1f; - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.Frostburn, 180, true); - target.AddBuff(BuffID.Chilled, 90, true); - } } } diff --git a/Projectiles/Boss/GolemInfernoBlast.cs b/Projectiles/Boss/GolemInfernoBlast.cs new file mode 100644 index 0000000000..cdced38b80 --- /dev/null +++ b/Projectiles/Boss/GolemInfernoBlast.cs @@ -0,0 +1,56 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class GolemInfernoBlast : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + private const int Lifetime = 900; + private const float Radius = 200f; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 170; // Doesn't matter because circular hitbox + Projectile.hostile = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = Lifetime; + Projectile.Calamity().DealsDefenseDamage = true; + } + + public override void AI() + { + // Visual effects + for (int i = 0; i < 4; i++) + { + Vector2 spawn = Projectile.Center + Main.rand.NextVector2Circular(Radius, Radius); + HealingPlus test = new HealingPlus(spawn, 1f, Vector2.Zero, Color.Orange, Color.OrangeRed, 2) { Rotation = Main.rand.NextFloat(MathHelper.TwoPi) }; + GeneralParticleHandler.SpawnParticle(test); + } + + if (Projectile.timeLeft % 3 == 0) + { + FlameExplosion blast = new(Projectile.Center, Vector2.Zero, Color.Orange, Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.1f, 0.25f, 15, 0.7f); + GeneralParticleHandler.SpawnParticle(blast); + } + + for (int i = 0; i < 3; i++) + { + float randomMult = Main.rand.NextFloat(0.35f, 0.9f); + Vector2 dustSpawn = Projectile.Center + Main.rand.NextVector2CircularEdge(Radius, Radius) * randomMult; + Vector2 dustVel = Utils.DirectionTo(Projectile.Center, dustSpawn) * Utils.Remap(randomMult, 0.35f, 0.9f, 6f, 1f); + Dust fire = Dust.NewDustPerfect(dustSpawn, DustID.InfernoFork, dustVel, Scale: 1.25f); + fire.noGravity = true; + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Radius, targetHitbox); + public override bool CanHitPlayer(Player target) => Projectile.timeLeft < Lifetime - 30; + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire, 360); + } +} diff --git a/Projectiles/Boss/GolemInfernoBolt.cs b/Projectiles/Boss/GolemInfernoBolt.cs new file mode 100644 index 0000000000..0b61d5b2b6 --- /dev/null +++ b/Projectiles/Boss/GolemInfernoBolt.cs @@ -0,0 +1,50 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class GolemInfernoBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 12; + Projectile.hostile = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (Projectile.ai[2] == 0f) + { + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + Projectile.ai[2] = 1f; + } + + bool hasReachedX = (Projectile.velocity.X < 0f && Projectile.Center.X < Projectile.ai[0]) || (Projectile.velocity.X > 0f && Projectile.Center.X > Projectile.ai[0]); + bool hasReachedY = (Projectile.velocity.Y < 0f && Projectile.Center.Y < Projectile.ai[1]) || (Projectile.velocity.Y > 0f && Projectile.Center.Y > Projectile.ai[1]); + + if (hasReachedX && hasReachedY) + Projectile.Kill(); + + // Add visual effects + MediumMistParticle mist = new(Projectile.Center, Main.rand.NextVector2Circular(3f, 3f), Color.Gray, Color.DarkGray, 0.5f, 192f); + GeneralParticleHandler.SpawnParticle(mist); + Dust.NewDustPerfect(Projectile.Center, DustID.InfernoFork, Main.rand.NextVector2Circular(2f, 2f), Scale: 1.75f); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire, 360); + public override void OnKill(int timeLeft) + { + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner); + } + } +} diff --git a/Projectiles/Boss/GreatSandBlast.cs b/Projectiles/Boss/GreatSandBlast.cs index b7fa0c573f..2cd1b7e987 100644 --- a/Projectiles/Boss/GreatSandBlast.cs +++ b/Projectiles/Boss/GreatSandBlast.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using CalamityMod.World; +using System.IO; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -22,12 +20,12 @@ namespace CalamityMod.Projectiles.Boss { Projectile.width = 10; Projectile.height = 10; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) Projectile.scale = 2f; Projectile.hostile = true; Projectile.tileCollide = false; Projectile.penetrate = 1; - Projectile.timeLeft = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 900 : 600; + Projectile.timeLeft = Main.getGoodWorld ? 900 : 600; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.alpha = 255; } diff --git a/Projectiles/Boss/HiveBombGoliath.cs b/Projectiles/Boss/HiveBombGoliath.cs index 0f763d7085..1872277d3c 100644 --- a/Projectiles/Boss/HiveBombGoliath.cs +++ b/Projectiles/Boss/HiveBombGoliath.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.NPCs.PlaguebringerGoliath; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Boss/HolyAura.cs b/Projectiles/Boss/HolyAura.cs index 3ceab6d0b0..aa0e2e6f81 100644 --- a/Projectiles/Boss/HolyAura.cs +++ b/Projectiles/Boss/HolyAura.cs @@ -31,7 +31,14 @@ namespace CalamityMod.Projectiles.Boss Projectile.timeLeft = 210; } - public override void AI() => Projectile.Center = Main.npc[CalamityGlobalNPC.holyBoss].Center; + public override void AI() + { + int provIndex = CalamityGlobalNPC.holyBoss; + if (provIndex < 0 || provIndex >= Main.maxNPCs || !Main.npc[provIndex].active) + return; + + Projectile.Center = Main.npc[provIndex].Center; + } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Boss/HolyBlast.cs b/Projectiles/Boss/HolyBlast.cs index 4b2b1d3666..e1190825cb 100644 --- a/Projectiles/Boss/HolyBlast.cs +++ b/Projectiles/Boss/HolyBlast.cs @@ -1,19 +1,13 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using CalamityMod.Graphics.Primitives; -using CalamityMod.NPCs; +using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; -using CalamityMod.NPCs.TownNPCs; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -22,6 +16,7 @@ namespace CalamityMod.Projectiles.Boss public class HolyBlast : ModProjectile, ILocalizedModType { public bool started = false; + public int FireDamage = 0; private const int TimeLeft = 120; private const int AccelerationTime = 60; @@ -36,10 +31,6 @@ namespace CalamityMod.Projectiles.Boss Main.projFrames[Type] = 4; } - public override void OnSpawn(IEntitySource source) - { - } - public override void SetDefaults() { Projectile.Calamity().DealsDefenseDamage = true; @@ -52,6 +43,17 @@ namespace CalamityMod.Projectiles.Boss CooldownSlot = ImmunityCooldownID.Bosses; } + public override void OnSpawn(IEntitySource source) + { + FireDamage = Providence.FireDamage.CalculateProvidenceDamage(); + + if (source is EntitySource_Parent { Entity: NPC parent }) + { + if (parent.type == ModContent.NPCType()) + FireDamage = ProfanedGuardianCommander.FireDamage; + } + } + public override void SendExtraAI(BinaryWriter writer) { writer.Write(Projectile.localAI[0]); @@ -64,7 +66,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 320, 20); + ProvUtils.ApplyGFBDamage(Projectile, 180, 20); Lighting.AddLight(Projectile.Center, 0.9f, 0.7f, 0f); @@ -111,8 +113,7 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(ShootSound, Projectile.Center); } - if (Math.Abs(Projectile.velocity.X) > 0.2) - Projectile.spriteDirection = -Projectile.direction; + Projectile.direction = Projectile.spriteDirection = (Math.Abs(Projectile.velocity.X) > 0.2).ToDirectionInt(); GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Projectile.Center + new Vector2(Main.rand.NextFloat(50), 0).RotatedByRandom(MathHelper.TwoPi), Projectile.velocity.RotatedBy(Math.PI) * 0.6f, false, 20, Main.rand.NextFloat(1f, 2f), ProvUtils.GetProjectileColor(255))); GeneralParticleHandler.SpawnParticle(new MediumMistParticle(Projectile.Center + new Vector2(40, 0).RotatedBy(Vector2.Zero.AngleTo(-Projectile.velocity)) + new Vector2(Main.rand.NextFloat(20), 0).RotatedByRandom(MathHelper.TwoPi), Projectile.velocity.RotatedBy(Math.PI) * 0.6f, Color.LightSlateGray, Color.DarkSlateGray, Main.rand.NextFloat(1f, 3f), 150f)); @@ -128,12 +129,11 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = ProvUtils.StandardAI() ? Terraria.GameContent.TextureAssets.Projectile[Type].Value : ModContent.Request("CalamityMod/Projectiles/Boss/HolyBlastNight").Value; - int framing = texture.Height / Main.projFrames[Type]; - int y6 = framing * Projectile.frame; - Vector2 sc = Vector2.One; - Projectile.DrawBackglow(ProvUtils.GetProjectileColor(lightColor, true), 4f, sc, texture); + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + SpriteEffects sp = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Projectile.DrawBackglow(ProvUtils.GetProjectileColor(lightColor, true), 4f, texture, effects: sp); - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, framing / 2f), sc, SpriteEffects.None, 0); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } @@ -158,7 +158,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.owner == Main.myPlayer) { int totalProjectiles = !ProvUtils.StandardAI() ? 8 : 6; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) totalProjectiles *= 2; float radians = MathHelper.TwoPi / totalProjectiles; @@ -169,7 +169,7 @@ namespace CalamityMod.Projectiles.Boss for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2 + additionalVelocity, type, (int)Math.Round(Projectile.damage * 0.75), 0f, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2 + additionalVelocity, type, FireDamage, 0f, Projectile.owner); } } @@ -200,7 +200,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || target.creativeGodMode) return; - ProvUtils.ApplyDebuffs(target, 320); + ProvUtils.ApplyDebuffs(target, 180); } } } diff --git a/Projectiles/Boss/HolyBomb.cs b/Projectiles/Boss/HolyBomb.cs index cb0933c919..33bbb2ddf3 100644 --- a/Projectiles/Boss/HolyBomb.cs +++ b/Projectiles/Boss/HolyBomb.cs @@ -1,13 +1,11 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs; +using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -16,6 +14,7 @@ namespace CalamityMod.Projectiles.Boss public class HolyBomb : ModProjectile, ILocalizedModType { float SquishAnimation = 1f; + public int FireDamage = 0; public new string LocalizationCategory => "Projectiles.Boss"; public override void SetStaticDefaults() @@ -35,9 +34,19 @@ namespace CalamityMod.Projectiles.Boss CooldownSlot = ImmunityCooldownID.Bosses; } + public override void OnSpawn(IEntitySource source) + { + FireDamage = Providence.FireDamage.CalculateProvidenceDamage(); + + if (source is EntitySource_Parent { Entity: NPC parent }) + { + if (parent.type == ModContent.NPCType()) + FireDamage = ProfanedGuardianDefender.FireDamage; + } + } public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 160, 20); + ProvUtils.ApplyGFBDamage(Projectile, 120, 20); Lighting.AddLight(Projectile.Center, 0.45f, 0.35f, 0f); @@ -62,7 +71,7 @@ namespace CalamityMod.Projectiles.Boss SquishAnimation = 0f; if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, velocityY, ModContent.ProjectileType(), (int)Math.Round(Projectile.damage * 0.75), Projectile.knockBack, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, velocityY, ModContent.ProjectileType(), FireDamage, Projectile.knockBack, Projectile.owner, 0f, 0f); } if (Projectile.ai[1] == 0f) @@ -129,7 +138,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || target.creativeGodMode) return; - ProvUtils.ApplyDebuffs(target, 160); + ProvUtils.ApplyDebuffs(target, 120); } } } diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index 64c20b7f63..cddfda4371 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -1,16 +1,11 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -42,9 +37,6 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(Projectile.Center, 0.45f, 0.35f, 0f); - if (Projectile.ai[0] == 0f && BossRushEvent.BossRushActive) - Projectile.velocity *= 1.25f; - if (!started) { Color cl = ProvUtils.GetProjectileColor(255); @@ -60,7 +52,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.timeLeft = 160; } - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) { if (Projectile.velocity.Length() < 12f && Projectile.ai[1] == 0f) { @@ -81,6 +73,8 @@ namespace CalamityMod.Projectiles.Boss float vel = MathHelper.Clamp(Projectile.velocity.Length() / 5, 0, 1.5f); GlowOrbParticle p = new GlowOrbParticle(Projectile.Center, Projectile.velocity + new Vector2(Main.rand.NextFloat(vel * 2), 0).RotatedByRandom(MathHelper.TwoPi), false, 4, 1f, col); GeneralParticleHandler.SpawnParticle(p); + //Trail for visibilty + GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center + Projectile.velocity, Vector2.Zero, col, "CalamityMod/Particles/BlastCone", new Vector2(3f, 2f), Vector2.Zero.AngleFrom(Projectile.velocity), 1f, 0f, 3)); } public override bool PreDraw(ref Color lightColor) @@ -95,7 +89,7 @@ namespace CalamityMod.Projectiles.Boss baseColor *= lerpMult; baseColor2 *= lerpMult; Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(0.5f, 1.5f) * lerpMult; + Vector2 scale = new Vector2(0.5f, 1f) * ((lerpMult-1)*0.5f + 1f); SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) diff --git a/Projectiles/Boss/HolyExplosionBoom.cs b/Projectiles/Boss/HolyExplosionBoom.cs index 0a1fde0f20..7f11d6df29 100644 --- a/Projectiles/Boss/HolyExplosionBoom.cs +++ b/Projectiles/Boss/HolyExplosionBoom.cs @@ -1,5 +1,4 @@ using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Boss/HolyFire.cs b/Projectiles/Boss/HolyFire.cs index 3385962d35..a25b4d1497 100644 --- a/Projectiles/Boss/HolyFire.cs +++ b/Projectiles/Boss/HolyFire.cs @@ -1,8 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs; -using CalamityMod.NPCs.Providence; +using CalamityMod.NPCs.Providence; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -36,7 +33,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 80, 20); + ProvUtils.ApplyGFBDamage(Projectile, 120, 10); Lighting.AddLight(Projectile.Center, 0.3f, 0.225f, 0f); @@ -93,12 +90,12 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.owner == Main.myPlayer) { Vector2 velocity = new Vector2(0.01f, 0f); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) velocity *= Main.rand.NextFloat(1f, 2f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) velocity *= Main.rand.NextFloat(1f, 2f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f); @@ -109,12 +106,12 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.owner == Main.myPlayer) { Vector2 velocity = new Vector2(0.05f, 0f); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) velocity *= Main.rand.NextFloat(1f, 2f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f); - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) velocity *= Main.rand.NextFloat(1f, 2f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 1f); @@ -131,7 +128,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || target.creativeGodMode) return; - ProvUtils.ApplyDebuffs(target, 80); + ProvUtils.ApplyDebuffs(target, 120); } } } diff --git a/Projectiles/Boss/HolyFire2.cs b/Projectiles/Boss/HolyFire2.cs index 3c191e8a20..8cfcd2206d 100644 --- a/Projectiles/Boss/HolyFire2.cs +++ b/Projectiles/Boss/HolyFire2.cs @@ -1,7 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.NPCs; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; using CalamityMod.World; @@ -37,7 +34,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 80, 10); + ProvUtils.ApplyGFBDamage(Projectile, 120, 10); Lighting.AddLight(Projectile.Center, 0.3f, 0.225f, 0f); @@ -50,16 +47,12 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.frame > 3) Projectile.frame = 0; - float maxVelocity = Projectile.ai[0] == 0f ? 7f : (Main.masterMode || BossRushEvent.BossRushActive) ? 13f : CalamityWorld.death ? 11f : CalamityWorld.revenge ? 10f : Main.expertMode ? 9f : 7f; + float maxVelocity = Projectile.ai[0] == 0f ? 7f : CalamityWorld.death ? 11f : CalamityWorld.revenge ? 10f : Main.expertMode ? 9f : 7f; if (Math.Abs(Projectile.velocity.X) < maxVelocity) Projectile.velocity.X *= 1.05f; int playerTracker = Player.FindClosest(Projectile.Center, 1, 1); - // Natural damage is removed from GFB - if (Projectile.ai[1] == 0f && !Main.zenithWorld) - Projectile.damage = Projectile.GetProjectileDamage(ModContent.NPCType()); - Projectile.ai[1] += 1f; if (Projectile.ai[1] < 180f && Projectile.ai[1] > 60f) { @@ -130,7 +123,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || target.creativeGodMode) return; - ProvUtils.ApplyDebuffs(target, 80); + ProvUtils.ApplyDebuffs(target, 120); } } } diff --git a/Projectiles/Boss/HolyFlare.cs b/Projectiles/Boss/HolyFlare.cs index d07046f83a..e14c7bc5cd 100644 --- a/Projectiles/Boss/HolyFlare.cs +++ b/Projectiles/Boss/HolyFlare.cs @@ -1,9 +1,6 @@ using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -36,7 +33,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 120, 20); + ProvUtils.ApplyGFBDamage(Projectile, 120, 10); Lighting.AddLight(Projectile.Center, 0.35f, 0.275f, 0f); diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 0d986b7f27..d59abcff35 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Dusts; using CalamityMod.Enums; -using CalamityMod.NPCs.Providence; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Boss/HolyProfanedCore.cs b/Projectiles/Boss/HolyProfanedCore.cs index db3c46a704..455c072009 100644 --- a/Projectiles/Boss/HolyProfanedCore.cs +++ b/Projectiles/Boss/HolyProfanedCore.cs @@ -2,9 +2,7 @@ using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Projectiles/Boss/HolySpear.cs b/Projectiles/Boss/HolySpear.cs index 00a92cabf5..3e91f57fe2 100644 --- a/Projectiles/Boss/HolySpear.cs +++ b/Projectiles/Boss/HolySpear.cs @@ -1,11 +1,7 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.NPCs; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -55,7 +51,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 120, 20); + ProvUtils.ApplyGFBDamage(Projectile, 120, 10); Lighting.AddLight(Projectile.Center, 0.45f * Projectile.Opacity, 0.35f * Projectile.Opacity, 0f); diff --git a/Projectiles/Boss/HomingGasBulb.cs b/Projectiles/Boss/HomingGasBulb.cs index 2c080802a1..caf3b07e9a 100644 --- a/Projectiles/Boss/HomingGasBulb.cs +++ b/Projectiles/Boss/HomingGasBulb.cs @@ -1,10 +1,8 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; -using CalamityMod.NPCs.TownNPCs; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; using CalamityMod.World; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -34,7 +32,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (Projectile.localAI[0] == 0f) { @@ -49,14 +47,14 @@ namespace CalamityMod.Projectiles.Boss int closestPlayer = (int)Player.FindClosest(Projectile.Center, 1, 1); Vector2 velocity = Main.player[closestPlayer].Center - Projectile.Center; Projectile.ai[0] += 1f; - if (Projectile.ai[0] >= (masterMode ? 0f : 30f)) + if (Projectile.ai[0] >= (death ? 0f : 30f)) { - if (Projectile.ai[0] < (masterMode ? 210f : 150f)) + if (Projectile.ai[0] < (death ? 210f : 150f)) { float scaleFactor2 = Projectile.velocity.Length(); velocity.Normalize(); velocity *= scaleFactor2; - Projectile.velocity = (Projectile.velocity * 24f + velocity) / 25f; + Projectile.velocity = (Projectile.velocity * 22f + velocity) / (death ? 12f : 15f); // Tracking strength Projectile.velocity.Normalize(); Projectile.velocity *= scaleFactor2; } @@ -67,7 +65,7 @@ namespace CalamityMod.Projectiles.Boss } } - if (Projectile.ai[0] % (masterMode ? 10f : 20f) == 0f) + if (Projectile.ai[0] % (death ? 10f : 20f) == 0f) { int dustType = 73; int totalDust = 12; @@ -89,7 +87,8 @@ namespace CalamityMod.Projectiles.Boss { int type = ModContent.ProjectileType(); float ai0 = Main.rand.Next(3); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Normalize(Projectile.velocity) * 0.2f, type, (int)Math.Round(Projectile.damage * 0.8), 0f, Main.myPlayer, ai0); + int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Normalize(Projectile.velocity) * 0.2f, type, PlanteraAI.PinkCloudDamage, 0f, Main.myPlayer, ai0); + Main.projectile[proj].timeLeft = 180; } } } diff --git a/Projectiles/Boss/HomingGasBulbSporeGas.cs b/Projectiles/Boss/HomingGasBulbSporeGas.cs index d467e3eeb4..6a1e342c5e 100644 --- a/Projectiles/Boss/HomingGasBulbSporeGas.cs +++ b/Projectiles/Boss/HomingGasBulbSporeGas.cs @@ -1,5 +1,4 @@ using System.IO; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -40,10 +39,9 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { Projectile.ai[1] += 1f; - if (Projectile.ai[1] > (CalamityWorld.LegendaryMode ? 600f : 900f)) + if (Projectile.ai[1] > (Main.getGoodWorld ? 600f : 900f)) { Projectile.localAI[0] += 10f; - Projectile.damage = 0; } if (Projectile.localAI[0] > 255f) @@ -55,25 +53,23 @@ namespace CalamityMod.Projectiles.Boss float lightValues = (255 - Projectile.alpha) * 0.6f / 255f; Lighting.AddLight(Projectile.Center, lightValues, 0f, lightValues); - Projectile.alpha = (int)(100.0 + Projectile.localAI[0] * 0.7); Projectile.rotation += Projectile.velocity.X * 0.02f; Projectile.rotation += Projectile.direction * 0.002f; - if (Projectile.velocity.Length() > (CalamityWorld.LegendaryMode ? 2f : 0.5f)) + if (Projectile.velocity.Length() > (Main.getGoodWorld ? 2f : 0.5f)) Projectile.velocity *= 0.985f; + + if (Projectile.timeLeft <= 40) + { + Projectile.Opacity = Utils.GetLerpValue(0, 40, Projectile.timeLeft); + } } - public override bool CanHitPlayer(Player target) => Projectile.ai[1] <= (CalamityWorld.LegendaryMode ? 600f : 900f) && Projectile.ai[1] > 120f; + public override bool CanHitPlayer(Player target) => Projectile.Opacity > 0.8f; public override Color? GetAlpha(Color lightColor) { - if (Projectile.ai[1] > (CalamityWorld.LegendaryMode ? 600f : 900f)) - { - byte b2 = (byte)((26f - (Projectile.ai[1] - (CalamityWorld.LegendaryMode ? 600f : 900f))) * 10f); - byte a2 = (byte)(Projectile.alpha * (b2 / 255f)); - return new Color(b2, b2, b2, a2); - } - return new Color(255, 255, 255, Projectile.alpha); + return lightColor; } public override bool PreDraw(ref Color lightColor) @@ -93,7 +89,7 @@ namespace CalamityMod.Projectiles.Boss default: break; } - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1, texture); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor * Projectile.Opacity, 1, texture); return false; } @@ -102,7 +98,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - if (Projectile.ai[1] <= (CalamityWorld.LegendaryMode ? 600f : 900f) && Projectile.ai[1] > 120f) + if (Projectile.ai[1] <= (Main.getGoodWorld ? 600f : 900f) && Projectile.ai[1] > 120f) target.AddBuff(BuffID.Poisoned, 240); } } diff --git a/Projectiles/Boss/HomingLaserDart.cs b/Projectiles/Boss/HomingLaserDart.cs index dc93ed2c2b..fd55783718 100644 --- a/Projectiles/Boss/HomingLaserDart.cs +++ b/Projectiles/Boss/HomingLaserDart.cs @@ -193,14 +193,6 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(BuffID.OnFire, 180); - } - public override Color? GetAlpha(Color lightColor) => new Color(255, 50, 50, Projectile.alpha); public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Boss/IceBlast.cs b/Projectiles/Boss/IceBlast.cs index 5d27626298..ea36c594e5 100644 --- a/Projectiles/Boss/IceBlast.cs +++ b/Projectiles/Boss/IceBlast.cs @@ -1,9 +1,7 @@ using System; using CalamityMod.NPCs.Cryogen; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -92,7 +90,6 @@ namespace CalamityMod.Projectiles.Boss return; target.AddBuff(BuffID.Frostburn, 120, true); - target.AddBuff(BuffID.Chilled, 60, true); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Boss/IceBomb.cs b/Projectiles/Boss/IceBomb.cs index ce60e05cb7..137c10a16c 100644 --- a/Projectiles/Boss/IceBomb.cs +++ b/Projectiles/Boss/IceBomb.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.NPCs.Cryogen; +using CalamityMod.NPCs.Cryogen; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -78,13 +76,12 @@ namespace CalamityMod.Projectiles.Boss int totalProjectiles = 8; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - int damage = (int)Math.Round(Projectile.damage * 0.75); float velocity = 1f; Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vector255, type, damage, 0f, Projectile.owner, 1f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vector255, type, Cryogen.IceRainDamage, 0f, Projectile.owner, 1f, 0f); } } @@ -97,14 +94,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - if (Projectile.ai[0] >= 120f) - { - target.AddBuff(BuffID.Frostburn, 180, true); - target.AddBuff(BuffID.Chilled, 90, true); - - if (!target.Calamity().gState) - target.AddBuff(ModContent.BuffType(), 60); - } + target.AddBuff(BuffID.Frostburn, 180, true); } } } diff --git a/Projectiles/Boss/IceRain.cs b/Projectiles/Boss/IceRain.cs index 53674d6619..d655a370c1 100644 --- a/Projectiles/Boss/IceRain.cs +++ b/Projectiles/Boss/IceRain.cs @@ -5,7 +5,6 @@ using CalamityMod.NPCs.Cryogen; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -106,7 +105,6 @@ namespace CalamityMod.Projectiles.Boss return; target.AddBuff(BuffID.Frostburn, 120, true); - target.AddBuff(BuffID.Chilled, 60, true); } } } diff --git a/Projectiles/Boss/IchorBlob.cs b/Projectiles/Boss/IchorBlob.cs index 479fb920eb..6b5694d4f9 100644 --- a/Projectiles/Boss/IchorBlob.cs +++ b/Projectiles/Boss/IchorBlob.cs @@ -168,7 +168,11 @@ namespace CalamityMod.Projectiles.Boss public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 16f, targetHitbox); + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + Vector2 centerPos = Projectile.frame >= 2 ? Projectile.Bottom - Vector2.UnitY * 16f : Projectile.Center; + return CalamityUtils.CircularHitboxCollision(centerPos, 16f, targetHitbox); + } public override bool CanHitPlayer(Player target) => Projectile.localAI[1] <= 900f && Projectile.localAI[1] > 120f; @@ -195,7 +199,7 @@ namespace CalamityMod.Projectiles.Boss return; if (Projectile.localAI[1] <= 900f && Projectile.localAI[1] > 120f) - target.AddBuff(BuffID.Ichor, 240); + target.AddBuff(BuffID.Ichor, 360); } } } diff --git a/Projectiles/Boss/IchorShot.cs b/Projectiles/Boss/IchorShot.cs index f1e2338a03..5933ef2afd 100644 --- a/Projectiles/Boss/IchorShot.cs +++ b/Projectiles/Boss/IchorShot.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(BuffID.Ichor, 180); + target.AddBuff(BuffID.Ichor, 240); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Boss/Infernado.cs b/Projectiles/Boss/Infernado.cs index 691c909e79..b9ca10a9ab 100644 --- a/Projectiles/Boss/Infernado.cs +++ b/Projectiles/Boss/Infernado.cs @@ -2,7 +2,6 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.NPCs.Yharon; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -112,7 +111,7 @@ namespace CalamityMod.Projectiles.Boss center.Y += 2f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), center, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 11f, Projectile.ai[1] - 1f); } - int tornadoSpeed = 10; + int tornadoSpeed = 15; int breakThreshold = 300; Projectile.localAI[1] += 1f; bool breakapart = Main.zenithWorld && Projectile.localAI[1] >= breakThreshold; @@ -130,13 +129,10 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.localAI[1] == breakThreshold && Main.zenithWorld) { Projectile.velocity.X = Main.rand.NextBool() ? -tornadoSpeed : tornadoSpeed; - - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - Projectile.velocity.X *= 1.5f; } if (Projectile.timeLeft == 600) - Projectile.damage = Projectile.GetProjectileDamage(ModContent.NPCType()); + Projectile.damage = Yharon.TornadoDamage; } public override bool CanHitPlayer(Player target) => Projectile.timeLeft <= 600; @@ -161,7 +157,7 @@ namespace CalamityMod.Projectiles.Boss return; if (Projectile.timeLeft <= 600) - target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/Projectiles/Boss/Infernado2.cs b/Projectiles/Boss/Infernado2.cs index c73d5dc424..4804538ccf 100644 --- a/Projectiles/Boss/Infernado2.cs +++ b/Projectiles/Boss/Infernado2.cs @@ -2,7 +2,6 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.NPCs.Yharon; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -130,7 +129,7 @@ namespace CalamityMod.Projectiles.Boss } if (Projectile.timeLeft == 720) - Projectile.damage = Projectile.GetProjectileDamage(ModContent.NPCType()); + Projectile.damage = Yharon.TornadoDamage; } public override bool CanHitPlayer(Player target) => Projectile.timeLeft <= 720; @@ -155,7 +154,7 @@ namespace CalamityMod.Projectiles.Boss return; if (Projectile.timeLeft <= 720) - target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/Projectiles/Boss/InfernadoRevenge.cs b/Projectiles/Boss/InfernadoRevenge.cs index d193737273..ad78d44e2f 100644 --- a/Projectiles/Boss/InfernadoRevenge.cs +++ b/Projectiles/Boss/InfernadoRevenge.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Boss } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { return Color.Lerp(Color.Yellow, Color.Yellow, completionRatio); } @@ -75,6 +75,7 @@ namespace CalamityMod.Projectiles.Boss Main.spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:Bordernado"].UseSaturation(-0.2f); + GameShaders.Misc["CalamityMod:Bordernado"].UseOpacity(1f); GameShaders.Misc["CalamityMod:Bordernado"].SetShaderTexture(ModContent.Request("Terraria/Images/Misc/Perlin")); Vector2[] drawPoints = new Vector2[5]; Vector2 upwardAscent = Vector2.UnitY * TornadoHeight; @@ -86,7 +87,7 @@ namespace CalamityMod.Projectiles.Boss drawPoints[i] = Vector2.Lerp(top, bottom, i / (float)(drawPoints.Length - 1)); drawPoints[drawPoints.Length - 1] = bottom; - PrimitiveRenderer.RenderTrail(drawPoints, new((_) => Projectile.width * 0.5f + 16f, ColorFunction, shader: GameShaders.Misc["CalamityMod:Bordernado"]), 85); + PrimitiveRenderer.RenderTrail(drawPoints, new((_,_) => Projectile.width * 0.5f + 16f, ColorFunction, shader: GameShaders.Misc["CalamityMod:Bordernado"]), 85); Main.spriteBatch.ExitShaderRegion(); Main.spriteBatch.EnterShaderRegion(); @@ -112,7 +113,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 150); + target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/Projectiles/Boss/LeviathanBomb.cs b/Projectiles/Boss/LeviathanBomb.cs index f995b4634f..f7209115fc 100644 --- a/Projectiles/Boss/LeviathanBomb.cs +++ b/Projectiles/Boss/LeviathanBomb.cs @@ -1,5 +1,4 @@ using System.IO; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -60,14 +59,6 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 80f, targetHitbox); - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 300); - } - public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); diff --git a/Projectiles/Boss/LeviathanSpawner.cs b/Projectiles/Boss/LeviathanSpawner.cs index 1826c1ba3e..a791fdefbc 100644 --- a/Projectiles/Boss/LeviathanSpawner.cs +++ b/Projectiles/Boss/LeviathanSpawner.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Boss float xArea = MathHelper.Lerp(400f, 1150f, Time / 300f); Vector2 dustSpawnPosition = waterTop.ToWorldCoordinates() + Vector2.UnitY * 25f; dustSpawnPosition.X += Main.rand.NextFloatDirection() * xArea * 0.35f; - Dust bubble = Dust.NewDustPerfect(dustSpawnPosition, 267, Vector2.UnitY * -12f); + Dust bubble = Dust.NewDustPerfect(dustSpawnPosition, DustID.RainbowMk2, Vector2.UnitY * -12f); bubble.noGravity = true; bubble.scale = 1.9f; bubble.color = Color.CornflowerBlue; diff --git a/Projectiles/Boss/MoltenBlast.cs b/Projectiles/Boss/MoltenBlast.cs index 457affed38..3ba0c09874 100644 --- a/Projectiles/Boss/MoltenBlast.cs +++ b/Projectiles/Boss/MoltenBlast.cs @@ -1,14 +1,13 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs; +using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -16,6 +15,8 @@ namespace CalamityMod.Projectiles.Boss { public class MoltenBlast : ModProjectile, ILocalizedModType { + public int BlobDamage = 0; + private const int TimeLeft = 90; private const int AccelerationTime = 60; private const float Acceleration = 1.05f; @@ -39,6 +40,17 @@ namespace CalamityMod.Projectiles.Boss CooldownSlot = ImmunityCooldownID.Bosses; } + public override void OnSpawn(IEntitySource source) + { + BlobDamage = Providence.BlobDamage.CalculateProvidenceDamage(); + + if (source is EntitySource_Parent { Entity: NPC parent }) + { + if (parent.type == ModContent.NPCType()) + BlobDamage = ProfanedGuardianDefender.BlobDamage; + } + } + public override void SendExtraAI(BinaryWriter writer) { writer.Write(Projectile.localAI[0]); @@ -53,7 +65,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 160, 20); + ProvUtils.ApplyGFBDamage(Projectile, 120, 20); Lighting.AddLight(Projectile.Center, 0.45f, 0.35f, 0f); @@ -153,10 +165,10 @@ namespace CalamityMod.Projectiles.Boss for (int b = 0; b < blobAmt; b++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f) + additionalBlobVelocity; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) velocity *= 2f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)Math.Round(Projectile.damage * 0.75), 0f, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), BlobDamage, 0f, Projectile.owner); } } @@ -171,7 +183,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || target.creativeGodMode) return; - ProvUtils.ApplyDebuffs(target, 160); + ProvUtils.ApplyDebuffs(target, 120); } } } diff --git a/Projectiles/Boss/MoltenBlob.cs b/Projectiles/Boss/MoltenBlob.cs index 9c3698fe8f..e74a89430b 100644 --- a/Projectiles/Boss/MoltenBlob.cs +++ b/Projectiles/Boss/MoltenBlob.cs @@ -1,11 +1,8 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs; -using CalamityMod.NPCs.Providence; +using CalamityMod.NPCs.Providence; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss @@ -25,7 +22,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 12; Projectile.height = 12; Projectile.hostile = true; @@ -37,7 +33,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - ProvUtils.ApplyGFBDamage(Projectile, 80, 10); + ProvUtils.ApplyGFBDamage(Projectile, 120, 10); Lighting.AddLight(Projectile.Center, 0.3f, 0.225f, 0f); @@ -143,7 +139,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || target.creativeGodMode) return; - ProvUtils.ApplyDebuffs(target, 80); + ProvUtils.ApplyDebuffs(target, 120); } } } diff --git a/Projectiles/Boss/MushBomb.cs b/Projectiles/Boss/MushBomb.cs index 3b31f317a9..fb7b61c8e4 100644 --- a/Projectiles/Boss/MushBomb.cs +++ b/Projectiles/Boss/MushBomb.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -55,7 +56,7 @@ namespace CalamityMod.Projectiles.Boss } } } - else + else if (Main.rand.NextBool()) { int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 0.8f); Main.dust[dust].noGravity = true; @@ -86,17 +87,17 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D texture = TextureAssets.Projectile[Type].Value; int height = texture.Height / Main.projFrames[Type]; int drawStart = height * Projectile.frame; Vector2 origin = Projectile.Size / 2; - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, new Rectangle(0, drawStart, texture.Width, height), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); return false; } public override void PostDraw(Color lightColor) { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D texture = TextureAssets.Projectile[Type].Value; int height = texture.Height / Main.projFrames[Type]; int drawStart = height * Projectile.frame; Vector2 origin = Projectile.Size / 2; @@ -104,21 +105,16 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Boss/MushBombGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Boss/MushBombGlow").Value, Projectile.Center - Main.screenPosition, new Rectangle(0, drawStart, texture.Width, height), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.Center); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 20; - Projectile.height = 20; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 4; i++) + + for (int i = 0; i < 3; i++) { - int shroomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); + int shroomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1f); Main.dust[shroomDust].velocity *= 1.5f; if (Main.rand.NextBool()) { @@ -126,9 +122,10 @@ namespace CalamityMod.Projectiles.Boss Main.dust[shroomDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int j = 0; j < 12; j++) + + for (int j = 0; j < 9; j++) { - int shroomDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 2f); + int shroomDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); Main.dust[shroomDust2].noGravity = true; Main.dust[shroomDust2].velocity *= 2f; Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); diff --git a/Projectiles/Boss/MushBombFall.cs b/Projectiles/Boss/MushBombFall.cs index 5645ec3df9..8855db1768 100644 --- a/Projectiles/Boss/MushBombFall.cs +++ b/Projectiles/Boss/MushBombFall.cs @@ -1,10 +1,10 @@ using System; -using CalamityMod.Events; 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; @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Boss } } } - else + else if (Main.rand.NextBool()) { int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 0.8f); Main.dust[dust].noGravity = true; @@ -75,12 +75,12 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(Projectile.Center, 0f, 0.15f, 0.3f); - float velocityYLimit = BossRushEvent.BossRushActive ? 12f : CalamityWorld.death ? 6f : 5f; - float velocityYIncrement = BossRushEvent.BossRushActive ? 0.24f : CalamityWorld.death ? 0.12f : 0.1f; + float velocityYLimit = Projectile.ai[0] == 1f ? 1f : CalamityWorld.death ? 6f : 5f; + float velocityYIncrement = Projectile.ai[0] == 1f ? 0.1f : CalamityWorld.death ? 0.12f : 0.1f; if (Projectile.velocity.Y < velocityYLimit) Projectile.velocity.Y += velocityYIncrement; - if (Math.Abs(Projectile.velocity.X) > 2f) + if (Math.Abs(Projectile.velocity.X) > (Projectile.ai[0] == 1f ? 0f : 2f)) Projectile.velocity.X *= 0.995f; } @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D texture = TextureAssets.Projectile[Type].Value; int height = texture.Height / Main.projFrames[Type]; int drawStart = height * Projectile.frame; Vector2 origin = Projectile.Size / 2; @@ -98,31 +98,26 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, new Rectangle(0, drawStart, texture.Width, height), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); return false; } public override void PostDraw(Color lightColor) { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D texture = TextureAssets.Projectile[Type].Value; int height = texture.Height / Main.projFrames[Type]; int drawStart = height * Projectile.frame; Vector2 origin = Projectile.Size / 2; - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Boss/MushBombGlow").Value, Projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, drawStart, texture.Width, height)), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Boss/MushBombGlow").Value, Projectile.Center - Main.screenPosition, new Rectangle(0, drawStart, texture.Width, height), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.Center); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 20; - Projectile.height = 20; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 4; i++) + + for (int i = 0; i < 3; i++) { - int shroomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); + int shroomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1f); Main.dust[shroomDust].velocity *= 1.5f; if (Main.rand.NextBool()) { @@ -130,9 +125,10 @@ namespace CalamityMod.Projectiles.Boss Main.dust[shroomDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int j = 0; j < 12; j++) + + for (int j = 0; j < 9; j++) { - int shroomDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 2f); + int shroomDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); Main.dust[shroomDust2].noGravity = true; Main.dust[shroomDust2].velocity *= 2f; Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); @@ -142,9 +138,7 @@ namespace CalamityMod.Projectiles.Boss { int crab = NPC.NewNPC(Projectile.GetSource_FromAI(), (int)Projectile.Center.X, (int)Projectile.Center.Y, NPCID.Crab); if (crab.WithinBounds(Main.maxNPCs)) - { Main.projectile[crab].timeLeft = 1200; - } } } } diff --git a/Projectiles/Boss/MushBombGround.cs b/Projectiles/Boss/MushBombGround.cs new file mode 100644 index 0000000000..ca844bdb13 --- /dev/null +++ b/Projectiles/Boss/MushBombGround.cs @@ -0,0 +1,111 @@ +using CalamityMod.Events; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class MushBombGround : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/Boss/MushBomb"; + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 4; + } + + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 14; + Projectile.hostile = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 300; + } + + public override void AI() + { + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + if (Main.rand.NextBool()) + { + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 0.8f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; + } + + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 3) + Projectile.frame = 0; + + Lighting.AddLight(Projectile.Center, 0f, 0.15f, 0.3f); + + float xVelocityMultiplier = 1.025f; + float xVelocityLimit = 12f; + if (Math.Abs(Projectile.velocity.X) < xVelocityLimit) + Projectile.velocity.X *= xVelocityMultiplier; + } + + public override Color? GetAlpha(Color drawColor) => Main.zenithWorld ? new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Projectile.alpha) : new Color(255, 255, 255, Projectile.alpha); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + int height = texture.Height / Main.projFrames[Type]; + int drawStart = height * Projectile.frame; + Vector2 origin = Projectile.Size / 2; + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, new Rectangle(0, drawStart, texture.Width, height), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + return false; + } + + public override void PostDraw(Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + int height = texture.Height / Main.projFrames[Type]; + int drawStart = height * Projectile.frame; + Vector2 origin = Projectile.Size / 2; + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Boss/MushBombGlow").Value, Projectile.Center - Main.screenPosition, new Rectangle(0, drawStart, texture.Width, height), Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.NPCDeath1, Projectile.Center); + + for (int i = 0; i < 3; i++) + { + int shroomDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1f); + Main.dust[shroomDust].velocity *= 1.5f; + if (Main.rand.NextBool()) + { + Main.dust[shroomDust].scale = 0.5f; + Main.dust[shroomDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 9; j++) + { + int shroomDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); + Main.dust[shroomDust2].noGravity = true; + Main.dust[shroomDust2].velocity *= 2f; + Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1.5f); + } + } + } +} diff --git a/Projectiles/Boss/OldDukeGore.cs b/Projectiles/Boss/OldDukeGore.cs index 382dc902b0..d2828f0aeb 100644 --- a/Projectiles/Boss/OldDukeGore.cs +++ b/Projectiles/Boss/OldDukeGore.cs @@ -1,8 +1,9 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; +using CalamityMod.NPCs.OldDuke; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -48,48 +49,33 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation += Projectile.velocity.X * 0.1f; + MediumMistParticle mist2 = new MediumMistParticle(Projectile.Center, Projectile.velocity, OldDuke.GlowColor, Color.DarkSlateBlue, Main.rand.NextFloat(1f), 200f); + mist2.AffectedByLight = true; + + GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Projectile.Center, (Projectile.velocity / 2) + new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)), Color.DarkRed, 20, Main.rand.NextFloat(0.2f, 1f), 0.2f, MathHelper.ToRadians(Main.rand.NextFloat(-2f, 2f)), affectedByLight: true)); + GeneralParticleHandler.SpawnParticle(mist2); + int blood = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Blood, 0f, 0f, 100, default, 1f); Main.dust[blood].noGravity = true; Main.dust[blood].velocity *= 0f; + } - int acid = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulphurousSeaAcid, 0f, 0f, 100, default, 1f); - Main.dust[acid].noGravity = true; - Main.dust[acid].velocity *= 0f; + public override void OnSpawn(IEntitySource source) + { + for (int i = 0; i < 3; i++) + { + GeneralParticleHandler.SpawnParticle(new PointParticle(Projectile.Center + (Projectile.velocity * 2f), Projectile.velocity.RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))) * Main.rand.NextFloat(3f), true, 8, Main.rand.NextFloat(1f, 2f), Color.DarkRed.MultiplyRGBA(new Color(0.3f, 0.3f, 0.3f, 0.3f)), false, true)); + } } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath12, Projectile.Center); - int dustAmt = 8; - for (int i = 0; i < dustAmt; i++) + for (int i = 0; i < 15; i++) { - Vector2 dustRotation = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - dustRotation = dustRotation.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; - Vector2 dustVel = dustRotation - Projectile.Center; - int blood = Dust.NewDust(dustRotation + dustVel, 0, 0, DustID.Blood, dustVel.X, dustVel.Y, 100, default, 1.2f); - Main.dust[blood].noGravity = true; - Main.dust[blood].noLight = true; - Main.dust[blood].velocity = dustVel; + GeneralParticleHandler.SpawnParticle(new PointParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(10), 0).RotatedByRandom(MathHelper.TwoPi), true, 10, Main.rand.NextFloat(0.5f, 1.5f), Color.DarkRed, false, true)); } - - for (int d = 0; d < 6; d++) - { - int acid = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulphurousSeaAcid, 0f, 0f, 100, default(Color), 3f); - Main.dust[acid].noGravity = true; - Main.dust[acid].velocity *= 5f; - acid = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulphurousSeaAcid, 0f, 0f, 100, default(Color), 2f); - Main.dust[acid].velocity *= 2f; - Main.dust[acid].noGravity = true; - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 180); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Boss/OldDukeSummonDrop.cs b/Projectiles/Boss/OldDukeSummonDrop.cs index abb9efda0c..7962f218e6 100644 --- a/Projectiles/Boss/OldDukeSummonDrop.cs +++ b/Projectiles/Boss/OldDukeSummonDrop.cs @@ -1,6 +1,10 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.NPCs.OldDuke; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,6 +38,9 @@ namespace CalamityMod.Projectiles.Boss { Projectile.velocity.Y += 0.15f; } + + if (Main.rand.NextBool(3)) + GeneralParticleHandler.SpawnParticle(new MediumMistParticle(Projectile.Center, -(Projectile.velocity / 4f).RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)), OldDuke.GlowColor, Color.DarkSlateGray, Main.rand.NextFloat(0.5f, 1.5f), 150f)); } public override bool OnTileCollide(Vector2 oldVelocity) { @@ -75,7 +82,9 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], new Color(255, 255, 255, 127), 2); + Asset tex = ModContent.Request(Texture); + + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, tex.Frame(), Color.White, Projectile.rotation, tex.Frame().Bottom(), new Vector2(1f, 1f / tex.Height() * (Projectile.velocity.Length() * 3 + 6)), SpriteEffects.None); return false; } } diff --git a/Projectiles/Boss/OldDukeToothBallSpike.cs b/Projectiles/Boss/OldDukeToothBallSpike.cs index c165b6e4c4..16bfa07763 100644 --- a/Projectiles/Boss/OldDukeToothBallSpike.cs +++ b/Projectiles/Boss/OldDukeToothBallSpike.cs @@ -1,6 +1,9 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.NPCs.OldDuke; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -38,12 +41,29 @@ namespace CalamityMod.Projectiles.Boss } } + public override bool PreDraw(ref Color lightColor) + { + // There are two of each draw call because it makes the additive glow a bit brighter + Asset tex = ModContent.Request(Texture); + for (int i = 0; i < 5; i++) + { + Main.EntitySpriteDraw(tex.Value, Projectile.Center - (Projectile.velocity * i) - Main.screenPosition, tex.Frame(), OldDuke.GlowColor, Projectile.rotation, tex.Frame().Center(), MathHelper.Lerp(1.5f, 0.2f, (float)i / 5f), SpriteEffects.None); + Main.EntitySpriteDraw(tex.Value, Projectile.Center - (Projectile.velocity * i) - Main.screenPosition, tex.Frame(), OldDuke.GlowColor, Projectile.rotation, tex.Frame().Center(), MathHelper.Lerp(1.5f, 0.2f, (float)i / 5f), SpriteEffects.None); + } + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, tex.Frame(), OldDuke.GlowColor, Projectile.rotation, tex.Frame().Center(), 1.5f, SpriteEffects.None); + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, tex.Frame(), OldDuke.GlowColor, Projectile.rotation, tex.Frame().Center(), 1.5f, SpriteEffects.None); + + Projectile.DrawBackglow(OldDuke.GlowColor, 4f); + + return base.PreDraw(ref lightColor); + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 360); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Boss/OldDukeVortex.cs b/Projectiles/Boss/OldDukeVortex.cs index 264a595984..50daffc173 100644 --- a/Projectiles/Boss/OldDukeVortex.cs +++ b/Projectiles/Boss/OldDukeVortex.cs @@ -1,8 +1,10 @@ using System; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using CalamityMod.World; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -12,23 +14,29 @@ namespace CalamityMod.Projectiles.Boss { public class OldDukeVortex : ModProjectile, ILocalizedModType { + Vector2 cen = Vector2.Zero; + public new string LocalizationCategory => "Projectiles.Boss"; - public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/OldDukeVortex"); + public static SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/OldDukeVortex"); + public SlotId SoundId; public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Type] = 6; - ProjectileID.Sets.TrailingMode[Type] = 0; + SpawnSound.MaxInstances = 50; + + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; } public override void SetDefaults() { + SoundId = SoundEngine.PlaySound(SpawnSound with { IsLooped = true, MaxInstances = 20 }, Projectile.Center, _ => new ProjectileAudioTracker(Projectile).IsActiveAndInGame()); Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 408; Projectile.height = 408; Projectile.scale = 0.004f; Projectile.hostile = true; - Projectile.alpha = 255; + Projectile.alpha = 0; Projectile.penetrate = -1; Projectile.tileCollide = false; Projectile.ignoreWater = true; @@ -38,6 +46,13 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + if (Projectile.localAI[1] == 0) + { + cen = Projectile.Center; + Projectile.localAI[1] = 1; + } + Projectile.position = cen - (new Vector2(Projectile.width / 2) * Projectile.scale); + if (Main.zenithWorld) { if (Projectile.scale < 2f) @@ -56,7 +71,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.alpha < 255) Projectile.alpha += 3; - Projectile.scale += 0.012f; + Projectile.scale -= 0.012f; } } } @@ -80,7 +95,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.alpha < 255) Projectile.alpha += 3; - Projectile.scale += 0.012f; + Projectile.scale -= 0.012f; Projectile.width = Projectile.height = (int)(408f * Projectile.scale); } else @@ -88,69 +103,81 @@ namespace CalamityMod.Projectiles.Boss } } - Projectile.velocity = Vector2.Normalize(new Vector2(Projectile.ai[0], Projectile.ai[1]) - Projectile.Center) * 1.5f; + float distanceRequired = 800f * Projectile.scale; + float succPower = Main.zenithWorld ? 1f : 0.5f; + foreach (Player player in Main.ActivePlayers) + { + float distance = Vector2.Distance(player.Center, cen); + if (distance < distanceRequired && player.grappling[0] == -1) + { + if (Collision.CanHit(cen, 1, 1, player.Center, 1, 1)) + { + float distanceRatio = distance / distanceRequired; + + float wingTimeSet = (float)Math.Ceiling((float)player.wingTimeMax * 0.5f * distanceRatio); + if (player.wingTime > wingTimeSet) + player.wingTime = wingTimeSet; + + float multiplier = 1f - distanceRatio; + if (player.Center.X < cen.X) + player.velocity.X += succPower * multiplier; + else + player.velocity.X -= succPower * multiplier; + } + } + } + + Projectile.ai[0]++; + + if (Projectile.ai[0] % 10 == 1) + { + GeneralParticleHandler.SpawnParticle(new CustomPulse(cen, Vector2.Zero, new Color(55, 195, 0, 20), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), Projectile.scale * 0.9f, Projectile.scale * 0.4f, 40)); + } + + if (Projectile.timeLeft <= 85) + { + Projectile.localAI[2] += 1f / 85f; + } + Projectile.velocity = Vector2.Zero; Projectile.rotation -= 0.1f * (float)(1D - (Projectile.alpha / 255D)); float lightAmt = 2f * Projectile.scale; - Lighting.AddLight(Projectile.Center, lightAmt, lightAmt * 2f, lightAmt); + Lighting.AddLight(cen, lightAmt, lightAmt * 2f, lightAmt); - if (Projectile.soundDelay == 0) + float maxdist = 1200; + + if (SoundEngine.TryGetActiveSound(SoundId, out var Sound) && Sound.IsPlaying) { - Projectile.soundDelay = 174; - SoundEngine.PlaySound(SpawnSound, Projectile.Center); + Sound.Position = cen; + Sound.Volume = Projectile.scale; + Sound.Pitch = MathHelper.Lerp(0f, -1f, (MathHelper.Clamp((Projectile.Distance(Main.LocalPlayer.Center) - 800) / maxdist, 0f, 1f) + (-Projectile.scale + 1))); } if (Projectile.timeLeft > 85) { - int numDust = (int)(0.2f * MathHelper.TwoPi * 408f * Projectile.scale); - float angleIncrement = MathHelper.TwoPi / (float)numDust; - Vector2 dustOffset = new Vector2(408f * Projectile.scale, 0f); - dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); + Vector2 vec2 = cen + new Vector2(Main.rand.NextFloat(320, 540) * Projectile.scale, 0).RotatedByRandom(MathHelper.TwoPi); - int var = (int)(408f * Projectile.scale); - for (int i = 0; i < numDust; i++) - { - if (Main.rand.NextBool(var)) - { - dustOffset = dustOffset.RotatedBy(angleIncrement); - int dust = Dust.NewDust(Projectile.Center, 1, 1, (int)CalamityDusts.SulphurousSeaAcid); - Main.dust[dust].position = Projectile.Center + dustOffset; - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity = Vector2.Normalize(Projectile.Center - Main.dust[dust].position) * 24f; - Main.dust[dust].scale = Projectile.scale * 3f; - } - } - - float distanceRequired = 800f * Projectile.scale; - float succPower = Main.zenithWorld ? 1f : 0.5f; - foreach (Player player in Main.ActivePlayers) - { - float distance = Vector2.Distance(player.Center, Projectile.Center); - if (distance < distanceRequired && player.grappling[0] == -1) - { - if (Collision.CanHit(Projectile.Center, 1, 1, player.Center, 1, 1)) - { - float distanceRatio = distance / distanceRequired; - - float wingTimeSet = (float)Math.Ceiling((float)player.wingTimeMax * 0.5f * distanceRatio); - if (player.wingTime > wingTimeSet) - player.wingTime = wingTimeSet; - - float multiplier = 1f - distanceRatio; - if (player.Center.X < Projectile.Center.X) - player.velocity.X += succPower * multiplier; - else - player.velocity.X -= succPower * multiplier; - } - } - } + GeneralParticleHandler.SpawnParticle(new SparkParticle(vec2, (cen - vec2) / 20, false, 10, Main.rand.NextFloat(0.5f, 1f), Color.LimeGreen, true)); } } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + Asset Tex = ModContent.Request(Texture); + + float sc = MathHelper.Lerp(1, 0, Projectile.localAI[2]); + + float alphaLerp = MathHelper.Lerp(1f, 0f, (float)Projectile.alpha / 255f); + + Main.EntitySpriteDraw(Tex.Value, cen - Main.screenPosition, Tex.Frame(), new Color(0f, 0f, 0f, 0.4f).MultiplyRGBA(new Color(alphaLerp, alphaLerp, alphaLerp, alphaLerp)), -Projectile.rotation / 2 * (4 + 1), Tex.Frame().Center(), 1.61f * Projectile.scale * sc, SpriteEffects.None); + + for (int i = 2; i >= 0; i--) + { + float lerp = (float)i / 3f; + + Main.EntitySpriteDraw(Tex.Value, cen - Main.screenPosition, Tex.Frame(), Color.Lerp(new Color(5, 155, 95, 100), new Color(255, 255, 255, 55), lerp).MultiplyRGBA(new Color(alphaLerp, alphaLerp, alphaLerp, alphaLerp)), -Projectile.rotation / 2 * (i + 1), Tex.Frame().Center(), MathHelper.Lerp(1f, 1.7f, lerp) * Projectile.scale * sc, SpriteEffects.None); + } return false; } diff --git a/Projectiles/Boss/OverlyDramaticDukeSummoner.cs b/Projectiles/Boss/OverlyDramaticDukeSummoner.cs index 57c685ea48..d058986e33 100644 --- a/Projectiles/Boss/OverlyDramaticDukeSummoner.cs +++ b/Projectiles/Boss/OverlyDramaticDukeSummoner.cs @@ -1,10 +1,13 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; +using System; using CalamityMod.Events; using CalamityMod.NPCs.OldDuke; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; using Terraria; +using Terraria.Audio; using Terraria.Chat; using Terraria.ID; using Terraria.Localization; @@ -14,6 +17,10 @@ namespace CalamityMod.Projectiles.Boss { public class OverlyDramaticDukeSummoner : ModProjectile, ILocalizedModType { + Vector2 cen; + + public SlotId? SoundId; + public new string LocalizationCategory => "Projectiles.Boss"; public override string Texture => "CalamityMod/Projectiles/Boss/OldDukeVortex"; @@ -26,7 +33,7 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.width = Projectile.height = 1; + Projectile.width = Projectile.height = 408; Projectile.scale = 0.004f; Projectile.hostile = true; Projectile.alpha = 255; @@ -35,6 +42,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.ignoreWater = true; Projectile.timeLeft = 1800; } + private static void ExpandVertically(int startX, int startY, out int topY, out int bottomY, int maxExpandUp = 100, int maxExpandDown = 100) { topY = startY; @@ -63,49 +71,73 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - Projectile.rotation -= 0.15f * (float)(1D - (Projectile.alpha / 255D)); + if (Main.netMode != NetmodeID.Server && !SoundId.HasValue) + { + SoundId = SoundEngine.PlaySound(OldDukeVortex.SpawnSound with { IsLooped = true, MaxInstances = 20 }, Projectile.Center, _ => new ProjectileAudioTracker(Projectile).IsActiveAndInGame()); + } + + if (Projectile.ai[0] == 0) + cen = Projectile.Center; + + Projectile.rotation -= 0.15f * (float)(1D - (Projectile.alpha / 255D)) * (Projectile.ai[0] / 660f); Projectile.ai[0]++; + Projectile.ai[1]++; + + Vector2 vec = new Vector2(408, 408) * Projectile.scale; + + Projectile.position = cen - new Vector2((float)Math.Sqrt(vec.X), (float)Math.Sqrt(vec.Y)); + float totalTilesToExpand = 1600f * Projectile.scale / 16; Point centerAsTileCoords = Projectile.Center.ToTileCoordinates(); - ExpandVertically(centerAsTileCoords.X, centerAsTileCoords.Y, out int topY, out int bottomY, (int)(totalTilesToExpand / 2), (int)(totalTilesToExpand / 2)); - topY++; - bottomY--; - Vector2 topVector = new Vector2(centerAsTileCoords.X, topY) * 16f + new Vector2(8f); - Vector2 bottomVector = new Vector2(centerAsTileCoords.X, bottomY) * 16f + new Vector2(8f); + Vector2 topVector = Projectile.Top; + Vector2 bottomVector = Projectile.Bottom; Vector2 centerVector = Vector2.Lerp(topVector, bottomVector, 0.5f); Projectile.width = (int)(208 * Projectile.scale); - Projectile.height = (int)(bottomVector.Y - topVector.Y); - Projectile.Center = centerVector; + + Vector2 ProjectileSpawnPosition = cen; if (Projectile.ai[0] < 90f) { Projectile.alpha = (int)MathHelper.Lerp(255f, 0f, Projectile.ai[0] / 90f); - Projectile.scale = MathHelper.Lerp(0.004f, 1f, Projectile.ai[0] / 90f); } + if (Projectile.ai[0] < 600f) + { + Projectile.scale = MathHelper.Lerp(0.004f, 1.6f, Projectile.ai[0] / 660f); + + Vector2 vec2 = Projectile.Center + new Vector2(Main.rand.NextFloat(320, 540) * Projectile.scale, 0).RotatedByRandom(MathHelper.TwoPi); + + GeneralParticleHandler.SpawnParticle(new SparkParticle(vec2, (Projectile.Center - vec2) / 20, false, 10, Main.rand.NextFloat(0.5f, 1f), Color.LimeGreen, true)); + } + + if (Projectile.ai[0] % 10 == 1 && Projectile.ai[0] < 600f) + { + GeneralParticleHandler.SpawnParticle(new CustomPulse(cen, Vector2.Zero, new Color(55, 195, 0, 20), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), Projectile.scale * 0.9f, Projectile.scale * 0.4f, 40)); + } + + float maxdist = 1200; + // Spray gore and acid everywhere - else if (Projectile.ai[0] < 480f) + if (Projectile.ai[0] < 480f && Projectile.ai[0] > 90f) { if (Projectile.ai[0] % 10f == 9f) { Vector2 velocity = new Vector2(0f, -18f).RotatedByRandom(0.7f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Top + new Vector2(Main.rand.NextFloat(-80f, 80f), 100f), velocity, - ModContent.ProjectileType(), 0, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), ProjectileSpawnPosition, velocity, + ModContent.ProjectileType(), 65, 2f); } if (Projectile.ai[0] % 35f == 34f) { Vector2 velocity = new Vector2(Main.rand.NextFloat(-3f, 3f), -7f - Main.rand.NextFloat(4f, 12f)).RotatedByRandom(0.5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Top + new Vector2(Main.rand.NextFloat(-30f, 30f), 100f), velocity, - ModContent.ProjectileType(), 0, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), ProjectileSpawnPosition, velocity, + ModContent.ProjectileType(), 65, 2f); } } // Fade out and die if (Projectile.ai[0] >= 600f) { - Projectile.alpha = (int)MathHelper.Lerp(0f, 255f, (Projectile.ai[0] - 600f) / 120f); - bool canSpawnBoomer = false; foreach (Player player in Main.ActivePlayers) { @@ -117,20 +149,26 @@ namespace CalamityMod.Projectiles.Boss } // Summon the boomer duke - if (Projectile.ai[0] == 660f) + if (Projectile.ai[0] == 600f) { if (canSpawnBoomer) { - for (int i = 0; i < 160; i++) + SoundEngine.PlaySound(SoundID.DD2_BetsyFlameBreath.WithPitchOffset(0.5f), cen); + SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact.WithPitchOffset(-0.5f), cen); + + for (float i = 0; i <= 5; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Top + Vector2.UnitY * 100f, (int)CalamityDusts.SulphurousSeaAcid); - dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5f, 23f); - dust.noGravity = true; - dust.scale = 3f; + if (i == 5) + { + GeneralParticleHandler.SpawnParticle(new CustomPulse(cen, Vector2.Zero, new Color(55, 255, 0), "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.05f, i * 0.1f, 40)); + } + + GeneralParticleHandler.SpawnParticle(new CustomPulse(cen, Vector2.Zero, new Color(55, 255, 0), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.05f, i * 0.1f, 40)); } + if (Main.netMode != NetmodeID.MultiplayerClient) { - int boomer = NPC.NewNPC(Projectile.GetSource_FromThis(), (int)Projectile.Top.X, (int)Projectile.Top.Y + 100, ModContent.NPCType()); + int boomer = NPC.NewNPC(Projectile.GetSource_FromThis(), (int)ProjectileSpawnPosition.X, (int)ProjectileSpawnPosition.Y, ModContent.NPCType()); string boomerName = Main.npc[boomer].TypeName; if (Main.netMode == NetmodeID.SinglePlayer) @@ -166,37 +204,41 @@ namespace CalamityMod.Projectiles.Boss AcidRainEvent.UpdateInvasion(false); } } + + if (Projectile.ai[0] >= 600f) + { + Projectile.alpha = (int)MathHelper.Lerp(0f, 255f, MathHelper.Clamp((Projectile.ai[0] - 600f) / 30, 0f, 1f)); + Projectile.scale = MathHelper.Lerp(Projectile.scale, 0f, MathHelper.Clamp((Projectile.ai[0] - 600f) / 30, 0f, 1f)); + } } if (Projectile.ai[0] >= 720f) { Projectile.Kill(); } + + if (SoundId.HasValue && SoundEngine.TryGetActiveSound(SoundId.Value, out var Sound) && Sound.IsPlaying) + { + Sound.Position = Projectile.Center; + Sound.Volume = Projectile.scale * 2f; + Sound.Pitch = MathHelper.Lerp(0f, -1f, (MathHelper.Clamp((Projectile.Distance(Main.LocalPlayer.Center) - 800) / maxdist, 0f, 1f) + (-Projectile.scale + 1))); + } } public override bool PreDraw(ref Color lightColor) { - float totalTilesToExpand = 1600f * Projectile.scale / 16; - Point centerAsTileCoords = Projectile.Center.ToTileCoordinates(); - ExpandVertically(centerAsTileCoords.X, centerAsTileCoords.Y, out _, out int bottomY, (int)(totalTilesToExpand / 2), (int)(totalTilesToExpand / 2)); - bottomY--; - Vector2 bottomVector = new Vector2(centerAsTileCoords.X, bottomY) * 16f + new Vector2(8f); + Asset Tex = ModContent.Request(Texture); - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - float yMax = 1600f * Projectile.scale; - for (int y = 0; y < yMax; y += 30) + float sc = MathHelper.Lerp(1, 0, Projectile.localAI[2]); + + float alphaLerp = MathHelper.Lerp(1f, 0f, (float)Projectile.alpha / 255f); + + Main.EntitySpriteDraw(Tex.Value, cen - Main.screenPosition, Tex.Frame(), new Color(0f, 0f, 0f, 0.4f).MultiplyRGBA(new Color(alphaLerp, alphaLerp, alphaLerp, alphaLerp)), -Projectile.rotation / 2 * (4 + 1), Tex.Frame().Center(), 1.61f * Projectile.scale * sc, SpriteEffects.None); + + for (int i = 2; i >= 0; i--) { - float thetaDelta = MathHelper.Pi * y / yMax; - float scale = Projectile.scale * MathHelper.Lerp(0.3f, 1.4f, y / yMax); - float alphaMultiplier = MathHelper.Lerp(1f, 0.6f, y / yMax); - Main.EntitySpriteDraw(texture, - bottomVector - Main.screenPosition - Vector2.UnitY * y, - null, - Color.White * Projectile.Opacity * 0.3f * alphaMultiplier, - Projectile.rotation + thetaDelta, - texture.Size() * 0.5f, - scale, - SpriteEffects.None, - 0); + float lerp = (float)i / 3f; + + Main.EntitySpriteDraw(Tex.Value, cen - Main.screenPosition, Tex.Frame(), Color.Lerp(new Color(5, 155, 95, 100), new Color(255, 255, 255, 55), lerp).MultiplyRGBA(new Color(alphaLerp, alphaLerp, alphaLerp, alphaLerp)), -Projectile.rotation / 2 * (i + 1), Tex.Frame().Center(), MathHelper.Lerp(1f, 1.7f, lerp) * Projectile.scale * sc, SpriteEffects.None); } return false; } diff --git a/Projectiles/Boss/PeanutRocket.cs b/Projectiles/Boss/PeanutRocket.cs index e0e203d817..a90b447645 100644 --- a/Projectiles/Boss/PeanutRocket.cs +++ b/Projectiles/Boss/PeanutRocket.cs @@ -9,7 +9,6 @@ namespace CalamityMod.Projectiles.Boss public class PeanutRocket : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/Ranged/HighExplosivePeanutShell"; public override void SetStaticDefaults() { diff --git a/Projectiles/Ranged/HighExplosivePeanutShell.png b/Projectiles/Boss/PeanutRocket.png similarity index 100% rename from Projectiles/Ranged/HighExplosivePeanutShell.png rename to Projectiles/Boss/PeanutRocket.png diff --git a/Projectiles/Boss/PermafrostAbsoluteZeroProjectile.cs b/Projectiles/Boss/PermafrostAbsoluteZeroProjectile.cs new file mode 100644 index 0000000000..9e455e24e3 --- /dev/null +++ b/Projectiles/Boss/PermafrostAbsoluteZeroProjectile.cs @@ -0,0 +1,240 @@ +using System; +using CalamityMod.NPCs.SupremeCalamitas; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class PermafrostAbsoluteZeroProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => "CalamityMod/Items/Weapons/Melee/AbsoluteZero"; + + public NPC Permafrost => Main.npc.IndexInRange((int)Projectile.ai[2]) ? Main.npc[(int)Projectile.ai[2]] : null; + public const float ZeroChargeDamageRatio = 0.36f; + public const float ToothDamageRatio = 0.1666667f; + public const int ToothShootRate = 5; // One chainsaw tooth is emitted every this many frames. + public const int ChargeUpTime = 150; + + public ref float Time => ref Projectile.ai[0]; + + // This is the damage dealt by the chainsaw teeth. It is recalculated every frame in two steps: + // 1) The chainsaw's damage itself is calculated as a long-lasting holdout (like Last Prism -- in case buffs wear off or similar) + // 2) The chainsaw teeth damage scales with charging up. The chainsaw's own damage does not. + public ref float ToothDamage => ref Projectile.ai[1]; + public float ChargeUpPower => MathHelper.Clamp((float)Math.Pow(Time / ChargeUpTime, 1.6D), 0f, 1f); + + public override void SetDefaults() + { + Projectile.Calamity().DealsDefenseDamage = true; + Projectile.width = 132; + Projectile.height = 56; + Projectile.hostile = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Vector2 origin = texture.Size() * 0.5f; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0); + return false; + } + + public override void AI() + { + // Die if Permafrost disappears. + if (Permafrost is null || !Permafrost.active) + { + Projectile.Kill(); + return; + } + + // Die if Permafrost shouldn't be using it. + int permafrostBulletHellCounter = Permafrost.ModNPC().bulletHellCounter2; + if (!(permafrostBulletHellCounter > SupremeCalamitas.SecondBulletHellEndValue && permafrostBulletHellCounter < SupremeCalamitas.ThirdBulletHellEndValue) && + !(permafrostBulletHellCounter > SupremeCalamitas.FourthBulletHellEndValue && permafrostBulletHellCounter < SupremeCalamitas.FifthBulletHellEndValue)) + { + Projectile.Kill(); + return; + } + + Projectile.damage = SupremeCalamitas.PermafrostAbsoluteZeroDamage; + DetermineDamage(); + + PlayChainsawSounds(); + + // Determines the owner's position whilst incorporating their fullRotation field. + // It uses vector transformation on a Z rotation matrix based on said rotation under the hood. + // This is essentially just the pure mathematical definition of the RotatedBy method. + Vector2 permafrostRotatedPosition = Permafrost.Center; + float rotation = Permafrost.rotation; + Vector2 vector = Permafrost.Bottom + new Vector2(0f, Permafrost.gfxOffY); + Vector2 vector2 = new Vector2(0f, -4f) + new Vector2(0f, 4f).RotatedBy(rotation); + permafrostRotatedPosition.Y += Permafrost.gfxOffY; + permafrostRotatedPosition = vector + (permafrostRotatedPosition - vector).RotatedBy(rotation) + vector2; + HandleMovement(permafrostRotatedPosition); + DetermineVisuals(permafrostRotatedPosition); + EmitPrettyDust(); + + if (Time % ToothShootRate == ToothShootRate - 1f) + ReleasePrismTeeth(); + + // Prevent the projectile from dying normally. + // However, if anything for whatever reason goes wrong it will immediately be destroyed on the next frame. + Projectile.timeLeft = 2; + + Time++; + } + + public void PlayChainsawSounds() + { + if (Projectile.soundDelay <= 0) + { + SoundEngine.PlaySound(SoundID.Item22, Projectile.Center); + Projectile.soundDelay = (int)MathHelper.Lerp(30f, 12f, ChargeUpPower); + } + } + + public void DetermineDamage() + { + // Set the initial tooth damage the instant the projectile is created. + if (ToothDamage == 0f) + { + ToothDamage = ToothDamageRatio * Projectile.damage; + Projectile.netUpdate = true; + } + + // And then do time based damage calculations. This does not execute if the original damage is 0. + // This line covers adjusting tooth damage if the projectile's own damage changes. + if (ToothDamage != 0f) + { + float fullMult = ToothDamageRatio; + float zeroMult = ZeroChargeDamageRatio * ToothDamageRatio; + ToothDamage = (int)MathHelper.SmoothStep(Projectile.damage * zeroMult, Projectile.damage * fullMult, ChargeUpPower); + } + } + + public void DetermineVisuals(Vector2 permafrostRotatedPosition) + { + float directionAngle = Projectile.velocity.ToRotation(); + Projectile.rotation = directionAngle; + + int oldDirection = Projectile.spriteDirection; + if (oldDirection == -1) + Projectile.rotation += MathHelper.Pi; + + Projectile.direction = Projectile.spriteDirection = (Math.Cos(directionAngle) > 0).ToDirectionInt(); + + // If the direction differs from what it originaly was, undo the previous 180 degree turn. + // If this is not done, the chainsaw will have 1 frame of rotational "jitter" when the direction changes based on the original angle. + // This effect looks very strange in-game. + if (Projectile.spriteDirection != oldDirection) + Projectile.rotation -= MathHelper.Pi; + + // Positioning close to the Permafrost's arm. + Projectile.position = permafrostRotatedPosition - Projectile.Size * 0.5f + directionAngle.ToRotationVector2() * 30f; + + // Update the position a tiny bit every frame at random to make it look like the saw is vibrating. + // It is reset on the next frame. + Projectile.position += Main.rand.NextVector2Circular(1.4f, 1.4f); + + // Update glowmask frames. + // Smoothstep is essentially like a linear interpolation but instead of being a straight line its + // curve is pseudo-logistic, with low increases at the ends of the curve. + Projectile.frameCounter += (int)MathHelper.SmoothStep(12f, 33f, ChargeUpPower); + if (Projectile.frameCounter >= 32) + { + Projectile.frame = (Projectile.frame + 1) % 6; + Projectile.frameCounter = 0; + } + } + + public void HandleMovement(Vector2 permafrostRotatedPosition) + { + Vector2 idealAimDirection = (Main.player[Permafrost.target].Center - permafrostRotatedPosition).SafeNormalize(Vector2.UnitX * Permafrost.direction); + + float angularAimVelocity = 0.03f; + float directionAngularDisparity = Projectile.velocity.AngleBetween(idealAimDirection) / MathHelper.Pi; + + // Increase the turn speed if close to the ideal direction, since successive linear interpolations are asymptotic. + angularAimVelocity += MathHelper.Lerp(0f, 0.05f, Utils.GetLerpValue(0.28f, 0.08f, directionAngularDisparity, true)); + + if (directionAngularDisparity > 0.02f) + Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealAimDirection, angularAimVelocity); + else + Projectile.velocity = idealAimDirection; + + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX * Permafrost.direction); + } + + public void EmitPrettyDust() + { + if (Main.dedServ) + return; + + for (int i = 0; i < 2; i++) + { + Vector2 spawnPosition = Projectile.Center + Projectile.velocity * 35f; + + // Spawn the dust a little bit on the chainsaw. X variance is less than Y variance to ensure that dust does not + // spawn too far from the blade. + spawnPosition += Main.rand.NextVector2CircularEdge(9f, 35f).RotatedBy(Projectile.velocity.ToRotation() + MathHelper.PiOver2); + + Dust rainbowSpark = Dust.NewDustPerfect(spawnPosition, DustID.AncientLight); + rainbowSpark.velocity = Projectile.velocity * 3f + Main.rand.NextVector2CircularEdge(1.5f, 1.5f); + rainbowSpark.noGravity = true; + rainbowSpark.color = Color.HotPink; + rainbowSpark.scale = Main.rand.NextFloat(0.9f, 1.25f); + } + } + + public void ReleasePrismTeeth() + { + // Play the sound that the crystal vile shard uses. + // Hopefully this isn't too cancerous to listen to, given the shoot rate of the crystals. + SoundEngine.PlaySound(SoundID.Item101, Projectile.Center); + + if (Main.myPlayer != Projectile.owner) + return; + + float shootReach = MathHelper.SmoothStep(Projectile.width * 1.8f, Projectile.width * 5.3f + 16f, ChargeUpPower); + float distanceFromTarget = Permafrost.Distance(Main.player[Permafrost.target].Center); + + // If the distance to the mouse is less than the base reach, reach only to mouse. + // This way the player can more directly control the crystals if they want. + // This comes with a small constant offset to cancel out other factors. + // If the mouse is very close to the player, set the shoot reach to its minimum. + if (distanceFromTarget < shootReach) + { + if (distanceFromTarget > 40f) + shootReach = distanceFromTarget + 32f; + else + shootReach = 72f; + } + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Permafrost.Center, Projectile.velocity, ModContent.ProjectileType(), (int)ToothDamage, 0f, Projectile.owner, shootReach, Projectile.whoAmI, Projectile.ai[2]); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // Collision is done as a line to bypass the fact that hitboxes cannot rotate and that this projectile is notably flat in terms of sprite shape. + float _ = 0f; + float width = Projectile.scale * 36f; + Vector2 start = Projectile.Center; + Vector2 end = Projectile.Center + Projectile.velocity * 70f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, width, ref _); + } + } +} diff --git a/Projectiles/Boss/PermafrostBlast.cs b/Projectiles/Boss/PermafrostBlast.cs new file mode 100644 index 0000000000..203633e721 --- /dev/null +++ b/Projectiles/Boss/PermafrostBlast.cs @@ -0,0 +1,159 @@ +using System.IO; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class PermafrostBlast : BaseLaserbeamProjectile, ILocalizedModType + { + // Modified clone of Seraphim's Laser + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public int OwnerIndex + { + get => (int)Projectile.ai[1]; + set => Projectile.ai[1] = value; + } + + public override float MaxScale => Projectile.ai[0]; + + public override float MaxLaserLength => 2400f; + + public override float Lifetime => 50; + + public override Color LaserOverlayColor + { + get + { + return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + } + } + + public override Color LightCastColor => Color.Transparent; + + public override Texture2D LaserBeginTexture => ModContent.Request("CalamityMod/Projectiles/Rogue/SeraphimBeamLarge", AssetRequestMode.ImmediateLoad).Value; + + public override Texture2D LaserMiddleTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeMiddle", AssetRequestMode.ImmediateLoad).Value; + + public override Texture2D LaserEndTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/SeraphimBeamLargeEnd", AssetRequestMode.ImmediateLoad).Value; + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 10; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 30; + Projectile.hostile = true; + Projectile.alpha = 255; + Projectile.penetrate = -1; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.timeLeft = 200; + Projectile.Calamity().DealsDefenseDamage = true; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.localAI[0]); + writer.Write(Projectile.localAI[1]); + writer.Write(Projectile.scale); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.localAI[0] = reader.ReadSingle(); + Projectile.localAI[1] = reader.ReadSingle(); + Projectile.scale = reader.ReadSingle(); + } + + public override void UpdateLaserMotion() + { + // Update the direction and rotation of the laser. + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + } + + public override float DetermineLaserLength() => MaxLaserLength; + + public override void PostAI() + { + // Determine frames. + Projectile.frameCounter++; + if (Projectile.frameCounter % 5f == 4f) + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; + } + + public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f; + + public override bool PreDraw(ref Color lightColor) + { + // This should never happen, but just in case. + if (Projectile.velocity == Vector2.Zero) + return false; + + Color beamColor = LaserOverlayColor; + Rectangle startFrameArea = LaserBeginTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Rectangle middleFrameArea = LaserMiddleTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Rectangle endFrameArea = LaserEndTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + + // Start texture drawing. + Vector2 centerOnLaser = Projectile.Center + Projectile.velocity * Projectile.scale * 116f; + Main.EntitySpriteDraw(LaserBeginTexture, + centerOnLaser - Main.screenPosition, + startFrameArea, + beamColor, + Projectile.rotation, + LaserBeginTexture.Size() / 2f, + Projectile.scale, + SpriteEffects.None, + 0); + + // Prepare things for body drawing. + float laserBodyLength = LaserLength + middleFrameArea.Height; + + // Body drawing. + if (laserBodyLength > 0f) + { + float laserOffset = middleFrameArea.Height * Projectile.scale; + float incrementalBodyLength = 0f; + while (incrementalBodyLength + 1f < laserBodyLength) + { + centerOnLaser += Projectile.velocity * laserOffset; + incrementalBodyLength += laserOffset; + Main.EntitySpriteDraw(LaserMiddleTexture, + centerOnLaser - Main.screenPosition, + middleFrameArea, + beamColor, + Projectile.rotation, + LaserMiddleTexture.Size() * 0.5f, + Projectile.scale, + SpriteEffects.None, + 0); + } + } + + Vector2 laserEndCenter = centerOnLaser + Projectile.velocity * endFrameArea.Height * Projectile.scale - Main.screenPosition; + Main.EntitySpriteDraw(LaserEndTexture, + laserEndCenter, + endFrameArea, + beamColor, + Projectile.rotation, + LaserEndTexture.Size() * 0.5f, + Projectile.scale, + SpriteEffects.None, + 0); + + return false; + } + } +} diff --git a/Projectiles/Boss/PermafrostBlaster.cs b/Projectiles/Boss/PermafrostBlaster.cs new file mode 100644 index 0000000000..553ba53539 --- /dev/null +++ b/Projectiles/Boss/PermafrostBlaster.cs @@ -0,0 +1,71 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class PermafrostBlaster : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => "CalamityMod/Items/Accessories/PermafrostsConcoction"; + public static readonly SoundStyle SANSCharge = new("CalamityMod/Sounds/Custom/Ravager/GasterBlasterCharge"); + public static readonly SoundStyle SANSFire = new("CalamityMod/Sounds/Custom/Ravager/GasterBlasterFire"); + public Vector2 storedVelocity; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 42; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.timeLeft = 180; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void AI() + { + // ai0 = timer, ai1 = laser size + if (Projectile.ai[0] < 90f) // Before the laser + { + Projectile.ai[0]++; + if (storedVelocity == Vector2.Zero) + { + storedVelocity = Projectile.SafeDirectionTo(Projectile.velocity); + Projectile.velocity = Vector2.Zero; + Projectile.netUpdate = true; + Projectile.rotation = (float)Math.Atan2(storedVelocity.Y, storedVelocity.X) + MathHelper.PiOver2; + + SoundEngine.PlaySound(SANSCharge, Projectile.Center); // Funny Gaster Blaster sounds + } + else if (Projectile.ai[0] >= 55f) + { + Projectile.ai[0] = 90f; + if (Projectile.owner == Main.myPlayer) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, storedVelocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, Projectile.ai[1], Projectile.whoAmI); + + SoundEngine.PlaySound(SANSFire, Projectile.Center); // Funny Gaster Blaster sounds #2 + } + } + else // Move out and despawn + { + // Start moving + if (Projectile.velocity == Vector2.Zero) + Projectile.velocity = storedVelocity * -1f; + else + Projectile.velocity *= 1.01f; + + // Fade out and die + Projectile.alpha += 3; + if (Projectile.alpha >= 255) + Projectile.Kill(); + } + } + + // Does no contact damage + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Boss/PermafrostColdheartIcicle.cs b/Projectiles/Boss/PermafrostColdheartIcicle.cs new file mode 100644 index 0000000000..5c6c4eb6c8 --- /dev/null +++ b/Projectiles/Boss/PermafrostColdheartIcicle.cs @@ -0,0 +1,168 @@ +using System; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Typeless; +using CalamityMod.NPCs.SupremeCalamitas; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent.Achievements; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class PermafrostColdheartIcicle : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => ModContent.GetInstance().Texture; + + public const int Lifetime = 80; + + public NPC Permafrost => Main.npc.IndexInRange((int)Projectile.ai[2]) ? Main.npc[(int)Projectile.ai[2]] : null; + + public ref float ShootReach => ref Projectile.ai[0]; + + public ref float Time => ref Projectile.ai[1]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 36; + } + + public override void SetDefaults() + { + Projectile.Calamity().DealsDefenseDamage = true; + Projectile.width = 30; + Projectile.height = 52; + Projectile.hostile = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 5; + Projectile.timeLeft = Lifetime; + CooldownSlot = ImmunityCooldownID.Bosses; + } + + public override void AI() + { + // Die if Permafrost disappears. + if (Permafrost is null || !Permafrost.active) + { + Projectile.Kill(); + return; + } + + // Die if Permafrost shouldn't be using it. + int permafrostBulletHellCounter = Permafrost.ModNPC().bulletHellCounter2; + if (!(permafrostBulletHellCounter > SupremeCalamitas.SecondBulletHellEndValue && permafrostBulletHellCounter < SupremeCalamitas.ThirdBulletHellEndValue) && + !(permafrostBulletHellCounter > SupremeCalamitas.FourthBulletHellEndValue && permafrostBulletHellCounter < SupremeCalamitas.FifthBulletHellEndValue)) + { + Projectile.Kill(); + return; + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.Pi * Time / Lifetime; + + Vector2 baseDirection = (MathHelper.TwoPi * Time / Lifetime - MathHelper.PiOver2).ToRotationVector2(); + baseDirection.X *= 0.25f; + + // Constrain the Y offset into the bounds of 0-1 instead of -1-1. + // This prevents the crystal from flying behind the owner. In this context, the Y offset becomes how far away the crystal is from its own in terms of reach. + baseDirection.Y = baseDirection.Y * 0.5f + 0.5f; + Vector2 positionOffset = baseDirection * ShootReach; + + // Don't allow the X offset to go too far. + // This hard limit turns the squashed circle into bending, semi-rectangular shape. + if (Math.Abs(positionOffset.X) > 45f) + positionOffset.X = Math.Sign(baseDirection.X) * 45f; + + // In this context, the velocity is simply the initial direction as a unit vector- it does not actually influence movement in any way. + positionOffset = positionOffset.RotatedBy(Projectile.velocity.ToRotation() - MathHelper.PiOver2); + + Vector2 permafrostRotatedPosition = Permafrost.Center; + float rotation = Permafrost.rotation; + Vector2 vector = Permafrost.Bottom + new Vector2(0f, Permafrost.gfxOffY); + Vector2 vector2 = new Vector2(0f, -4f) + new Vector2(0f, 4f).RotatedBy(rotation); + permafrostRotatedPosition.Y += Permafrost.gfxOffY; + permafrostRotatedPosition = vector + (permafrostRotatedPosition - vector).RotatedBy(rotation) + vector2; + Projectile.Center = permafrostRotatedPosition + Projectile.velocity * 42f + positionOffset; + Projectile.Opacity = Utils.GetLerpValue(0f, 12f, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - 12f, Lifetime - Projectile.timeLeft, true); + + // Destroy trees within the range of the past 20 oldPos positions. + for (int i = 0; i < 20; i++) + { + Point pointToCheck = (Projectile.oldPos[i] + Projectile.Size * 0.5f).ToTileCoordinates(); + AbsolutelyFuckingAnnihilateTrees(pointToCheck.X, pointToCheck.Y); + } + + // Emit light. + Lighting.AddLight(Projectile.Center, Vector3.One * 0.7f); + + Time++; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox); + + public void AbsolutelyFuckingAnnihilateTrees(int x, int y) + { + Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); + + // Ignore tiles that are not active and are not breakable by axes. + if (!tileAtPosition.HasTile || !Main.tileAxe[tileAtPosition.TileType]) + return; + + // Don't attempt to mine the tile if for whatever reason it's not supposed to be broken. + if (!WorldGen.CanKillTile(x, y)) + return; + + AchievementsHelper.CurrentlyMining = true; + + WorldGen.KillTile(x, y); + if (Main.netMode == NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y); + + AchievementsHelper.CurrentlyMining = false; + } + + public override Color? GetAlpha(Color lightColor) => Color.Cyan; + + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 24f * (1f - Utils.GetLerpValue(0.7f, 1f, completionRatio, true)) + 1f; + + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) => Color.Cyan * Projectile.Opacity; + + public override bool PreDraw(ref Color lightColor) + { + if (Time <= 5f) + return true; + + // Variable adjustment vector used to prevent the trail for starting somewhat that isn't behind + // the crystal. This may appear in small amounts, with offsets of a few pixels, but at the speed + // these crystals go, it's probably not something to worry too much about. + Vector2 generalOffset = Projectile.rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2) * 15f; + generalOffset += Projectile.rotation.ToRotationVector2() * -5f * (float)Math.Sin(Projectile.rotation); + + // Mess with the oldPos array so that the trail always points towards the crystal. + Vector2 oldPosition = Projectile.oldPos[1]; + Projectile.oldPos[1] = Projectile.oldPos[0] - Projectile.rotation.ToRotationVector2() * Vector2.Distance(Projectile.oldPos[0], Projectile.oldPos[1]); + + // Revert back if the above calculations caused any NaNs. + if (Projectile.oldPos[1].HasNaNs()) + Projectile.oldPos[1] = oldPosition; + + Main.spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_, _) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"]), 65); + Main.spriteBatch.ExitShaderRegion(); + return true; + } + + // Prevent the crystals from utilizing velocity. Their movement is entirely dependant on Center setting. + public override bool ShouldUpdatePosition() => false; + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Frozen, 300); + } +} diff --git a/Projectiles/Boss/PermafrostMeat.cs b/Projectiles/Boss/PermafrostMeat.cs new file mode 100644 index 0000000000..69adc783c8 --- /dev/null +++ b/Projectiles/Boss/PermafrostMeat.cs @@ -0,0 +1,104 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class PermafrostMeat : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => "CalamityMod/Items/Potions/Food/DeliciousMeat"; + + public override void SetDefaults() + { + Projectile.width = 30; + Projectile.height = 30; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 120; + Projectile.aiStyle = ProjAIStyleID.ThrownProjectile; + AIType = ProjectileID.ThrowingKnife; + } + + public override void AI() + { + if (Projectile.ai[0] == 0f) + { + SoundEngine.PlaySound(SoundID.NPCDeath43 with { Volume = SoundID.NPCDeath43.Volume * 0.35f, Pitch = 0.3f }, Projectile.position); + Projectile.ai[0] = 1f; + } + if (Projectile.ai[1] == 0) + { + Projectile.aiStyle = -1; + Projectile.tileCollide = false; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + 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.NPCDeath43 with { Volume = SoundID.NPCDeath43.Volume * 0.35f }, Projectile.position); + + for (int i = 0; i < 10; i++) + { + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceGolem, 0f, 0f, 0, default, 1.2f); + Main.dust[dust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + + for (int i = 0; i < 20; i++) + { + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceGolem, 0f, 0f, 0, default, 1.7f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 5f; + dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceGolem, 0f, 0f, 0, default, 1f); + Main.dust[dust].velocity *= 2f; + } + + if (Projectile.ai[2] == 0) + { + if (Projectile.owner == Main.myPlayer) + { + int totalProjectiles = 3; + float radians = MathHelper.TwoPi / totalProjectiles; + float velocity = 8f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Vector2.Normalize(velocity2) * 10f, velocity2, Type, (int)Math.Round(Projectile.damage * 0.8), 0f, Main.myPlayer, ai2: 1); + if (proj.WithinBounds(Main.maxProjectiles)) + { + Main.projectile[proj].tileCollide = false; + Main.projectile[proj].aiStyle = -1; + } + } + } + } + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + Projectile.Kill(); + } + } +} diff --git a/Projectiles/Boss/PhantomBlast.cs b/Projectiles/Boss/PhantomBlast.cs index 8069efd309..a95da5cdde 100644 --- a/Projectiles/Boss/PhantomBlast.cs +++ b/Projectiles/Boss/PhantomBlast.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -14,7 +13,6 @@ namespace CalamityMod.Projectiles.Boss public new string LocalizationCategory => "Projectiles.Boss"; public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 18; Projectile.height = 18; Projectile.hostile = true; @@ -111,13 +109,5 @@ namespace CalamityMod.Projectiles.Boss Main.dust[killGhostDust2].velocity *= 2f; } } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 120); - } } } diff --git a/Projectiles/Boss/PhantomBlast2.cs b/Projectiles/Boss/PhantomBlast2.cs index f581c4a065..64cb82cdb4 100644 --- a/Projectiles/Boss/PhantomBlast2.cs +++ b/Projectiles/Boss/PhantomBlast2.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -14,7 +13,6 @@ namespace CalamityMod.Projectiles.Boss public new string LocalizationCategory => "Projectiles.Boss"; public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 18; Projectile.height = 18; Projectile.hostile = true; @@ -111,13 +109,5 @@ namespace CalamityMod.Projectiles.Boss Main.dust[killGhostDust2].velocity *= 2f; } } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 180); - } } } diff --git a/Projectiles/Boss/PhantomGhostShot.cs b/Projectiles/Boss/PhantomGhostShot.cs index 61f6e7a116..708a7dc273 100644 --- a/Projectiles/Boss/PhantomGhostShot.cs +++ b/Projectiles/Boss/PhantomGhostShot.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -66,14 +65,6 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 120); - } - public override Color? GetAlpha(Color lightColor) { return new Color(100, 250, 250, Projectile.alpha); diff --git a/Projectiles/Boss/PhantomHookShot.cs b/Projectiles/Boss/PhantomHookShot.cs index 32d119dd72..9a04d114d7 100644 --- a/Projectiles/Boss/PhantomHookShot.cs +++ b/Projectiles/Boss/PhantomHookShot.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -66,14 +65,6 @@ namespace CalamityMod.Projectiles.Boss } } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 80); - } - public override Color? GetAlpha(Color lightColor) { return new Color(100, 250, 250, Projectile.alpha); diff --git a/Projectiles/Boss/PhantomMine.cs b/Projectiles/Boss/PhantomMine.cs index fcadc0e03b..9f46be6e57 100644 --- a/Projectiles/Boss/PhantomMine.cs +++ b/Projectiles/Boss/PhantomMine.cs @@ -1,7 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.World; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -14,7 +11,6 @@ namespace CalamityMod.Projectiles.Boss public new string LocalizationCategory => "Projectiles.Boss"; public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 30; Projectile.height = 30; Projectile.hostile = true; @@ -39,7 +35,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.velocity *= Projectile.ai[0]; } - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + if (Main.getGoodWorld) { if (Projectile.velocity.Length() >= Projectile.ai[0]) { @@ -98,17 +94,5 @@ namespace CalamityMod.Projectiles.Boss Main.dust[phantomDust2].velocity *= 2f; } } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - if (Projectile.velocity.Length() >= Projectile.ai[0]) - { - target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 180); - } - } } } diff --git a/Projectiles/Boss/PhantomShot.cs b/Projectiles/Boss/PhantomShot.cs index 0cc7f9eed7..d866f1ce87 100644 --- a/Projectiles/Boss/PhantomShot.cs +++ b/Projectiles/Boss/PhantomShot.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -67,13 +66,5 @@ namespace CalamityMod.Projectiles.Boss { return new Color(100, 250, 250, Projectile.alpha); } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 80); - } } } diff --git a/Projectiles/Boss/PhantomShot2.cs b/Projectiles/Boss/PhantomShot2.cs index fc48efce2d..24e1aff8a1 100644 --- a/Projectiles/Boss/PhantomShot2.cs +++ b/Projectiles/Boss/PhantomShot2.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -67,13 +66,5 @@ namespace CalamityMod.Projectiles.Boss { return new Color(250, 100, 100, Projectile.alpha); } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(ModContent.BuffType(), 120); - } } } diff --git a/Projectiles/Boss/PlagueStingerGoliath.cs b/Projectiles/Boss/PlagueStingerGoliath.cs index 0f064415ea..6316740702 100644 --- a/Projectiles/Boss/PlagueStingerGoliath.cs +++ b/Projectiles/Boss/PlagueStingerGoliath.cs @@ -4,7 +4,6 @@ using CalamityMod.NPCs.PlaguebringerGoliath; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -53,7 +52,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Boss/PlagueStingerGoliathV2.cs b/Projectiles/Boss/PlagueStingerGoliathV2.cs index cba5fae545..70a5a75a2c 100644 --- a/Projectiles/Boss/PlagueStingerGoliathV2.cs +++ b/Projectiles/Boss/PlagueStingerGoliathV2.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Boss/ProfanedSpear.cs b/Projectiles/Boss/ProfanedSpear.cs index 174bca5a2c..b6e931a260 100644 --- a/Projectiles/Boss/ProfanedSpear.cs +++ b/Projectiles/Boss/ProfanedSpear.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; using Microsoft.Xna.Framework; diff --git a/Projectiles/Boss/ProvidenceCrystal.cs b/Projectiles/Boss/ProvidenceCrystal.cs index b77439580e..35f7a60377 100644 --- a/Projectiles/Boss/ProvidenceCrystal.cs +++ b/Projectiles/Boss/ProvidenceCrystal.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; @@ -25,7 +24,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = 160; Projectile.height = 160; Projectile.ignoreWater = true; - Projectile.timeLeft = BossRushEvent.BossRushActive ? 1500 : CalamityWorld.death ? 2100 : 3600; + Projectile.timeLeft = CalamityWorld.death ? 2100 : 3600; Projectile.alpha = 255; Projectile.tileCollide = false; Projectile.penetrate = -1; diff --git a/Projectiles/Boss/ProvidenceCrystalShard.cs b/Projectiles/Boss/ProvidenceCrystalShard.cs index a745f81594..4f99f0d4d1 100644 --- a/Projectiles/Boss/ProvidenceCrystalShard.cs +++ b/Projectiles/Boss/ProvidenceCrystalShard.cs @@ -25,7 +25,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 34; Projectile.height = 34; Projectile.hostile = true; diff --git a/Projectiles/Boss/ProvidenceHolyRay.cs b/Projectiles/Boss/ProvidenceHolyRay.cs index 7ca90e54b2..a59e3cc8b9 100644 --- a/Projectiles/Boss/ProvidenceHolyRay.cs +++ b/Projectiles/Boss/ProvidenceHolyRay.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.NPCs; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.Particles; @@ -9,7 +8,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; @@ -85,7 +83,7 @@ namespace CalamityMod.Projectiles.Boss } if (projScale == 1f) - ProvUtils.ApplyGFBDamage(Projectile, 400, 20); + ProvUtils.ApplyGFBDamage(Projectile, 240, 20); Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * MathHelper.Pi / (scissorLasers ? 100f : 180f)) * 10f * projScale; if (Projectile.scale > projScale) @@ -240,7 +238,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || target.creativeGodMode) return; - ProvUtils.ApplyDebuffs(target, 400); + ProvUtils.ApplyDebuffs(target, 240); } public override bool CanHitPlayer(Player target) => Projectile.scale >= 0.5f; diff --git a/Projectiles/Boss/RavagerBlast.cs b/Projectiles/Boss/RavagerBlast.cs index 81d5963dae..4773a475d8 100644 --- a/Projectiles/Boss/RavagerBlast.cs +++ b/Projectiles/Boss/RavagerBlast.cs @@ -1,13 +1,9 @@ -using System; -using System.IO; -using System.Linq; +using System.IO; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss diff --git a/Projectiles/Boss/RavagerBlaster.cs b/Projectiles/Boss/RavagerBlaster.cs index 1c56038a6d..a6cd8cb18c 100644 --- a/Projectiles/Boss/RavagerBlaster.cs +++ b/Projectiles/Boss/RavagerBlaster.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss diff --git a/Projectiles/Boss/RavagerFlame.cs b/Projectiles/Boss/RavagerFlame.cs index 69f81fa5da..53bc023b24 100644 --- a/Projectiles/Boss/RavagerFlame.cs +++ b/Projectiles/Boss/RavagerFlame.cs @@ -1,5 +1,7 @@ using CalamityMod.Events; +using CalamityMod.Particles; using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -24,14 +26,16 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.extraUpdates = BossRushEvent.BossRushActive ? 2 : 1; + Projectile.extraUpdates = 1; } public override void AI() { + Particle beam3 = new CustomSpark(Projectile.Center, new Vector2(1).RotatedByRandom(6.3f), "CalamityMod/Particles/BloomCircle", false, 10, 0.25f, Color.SkyBlue, new Vector2(1), true, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam3); for (int i = 0; i < 2; i++) { - int icyFlame = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceTorch, 0f, 0f, 100, default, 3f); + int icyFlame = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceTorch, 0f, 0f, 100, default, 1.5f); Main.dust[icyFlame].noGravity = true; Main.dust[icyFlame].velocity *= 0f; } diff --git a/Projectiles/Boss/RavagerNuke.cs b/Projectiles/Boss/RavagerNuke.cs new file mode 100644 index 0000000000..09a008f4ff --- /dev/null +++ b/Projectiles/Boss/RavagerNuke.cs @@ -0,0 +1,178 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Events; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Boss +{ + public class RavagerNuke : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + public static readonly SoundStyle ExplosionSound = new("CalamityMod/Sounds/Custom/Ravager/RavagerMissileExplosion"); + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 5; + } + + public override void SetDefaults() + { + Projectile.width = 44; + Projectile.height = 44; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = 1; + Projectile.alpha = 255; + Projectile.timeLeft = 600; + } + + public override void AI() + { + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + + if (Projectile.timeLeft < 180) + Projectile.tileCollide = true; + + Projectile.frameCounter++; + if (Projectile.frameCounter > 18) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 4) + Projectile.frame = 0; + + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; + + float inertia = revenge ? 90f : 110f; + float scaleFactor12 = revenge ? 16f : 12f; + + if (Projectile.alpha > 0) + Projectile.alpha -= 10; + if (Projectile.alpha < 0) + Projectile.alpha = 0; + + Lighting.AddLight(Projectile.Center, 1f, 0.7f, 0f); + + int playerTracker = (int)Projectile.ai[0]; + if (playerTracker >= 0 && Main.player[playerTracker].active && !Main.player[playerTracker].dead) + { + if (Projectile.Distance(Main.player[playerTracker].Center) > 320f) + { + Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[playerTracker].Center, Vector2.UnitY); + Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * scaleFactor12) / inertia; + } + } + else + { + if (Projectile.timeLeft > 30) + Projectile.timeLeft = 30; + + if (Projectile.ai[0] != -1f) + { + Projectile.ai[0] = -1f; + Projectile.netUpdate = true; + } + } + } + + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage > 0) + { + if (DownedBossSystem.downedProvidence) + { + target.AddBuff(ModContent.BuffType(), 180, true); + } + else + { + target.AddBuff(ModContent.BuffType(), 180, true); + } + } + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(ExplosionSound, Projectile.Center); + Projectile.position = Projectile.Center; + Projectile.width = Projectile.height = 160; + Projectile.position.X = Projectile.position.X - (Projectile.width / 2); + Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); + Projectile.Damage(); + for (int i = 0; i < 30; i++) + { + int nukeDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f); + Main.dust[nukeDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[nukeDust].scale = 0.5f; + Main.dust[nukeDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int j = 0; j < 40; j++) + { + int nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 3f); + Main.dust[nukeDust2].noGravity = true; + Main.dust[nukeDust2].velocity *= 5f; + nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f); + Main.dust[nukeDust2].velocity *= 2f; + } + + if (!Main.dedServ) + { + Vector2 source = new Vector2(Projectile.Center.X - 24f, Projectile.Center.Y - 24f); + for (int g = 1; g <= 3; g++) + { + float velocityMult = g * 0.33f; + for (int spawn = 0; spawn < 4; spawn++) + { + int type = Main.rand.Next(61, 64); + int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); + Gore gore = Main.gore[smoke]; + gore.velocity *= velocityMult; + gore.velocity.X += 1f; + gore.velocity.Y += 1f; + } + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + int timeToStartWarning = 180; + + Color initialColor = lightColor; + Color finalColor = Color.Lerp(Color.White, Color.Red, (float)Math.Abs(Math.Sin((timeToStartWarning - Projectile.timeLeft) * (MathHelper.Pi * 7f / 180f)))); + Color warningColor; + finalColor.A = (byte)(255 - Projectile.alpha); + float colorTransitionRatio = MathHelper.Clamp((timeToStartWarning - Projectile.timeLeft) / (float)timeToStartWarning, 0f, 1f); + + if (Projectile.timeLeft <= timeToStartWarning) + warningColor = Color.Lerp(initialColor, finalColor, colorTransitionRatio); + else + warningColor = initialColor; + + float strength = Utils.GetLerpValue(0, timeToStartWarning / 1.5f, timeToStartWarning - Projectile.timeLeft, true); + Texture2D tex = TextureAssets.Projectile[Type].Value; + Rectangle frame = tex.Frame(1, 5, 0, Projectile.frame); + SpriteEffects sp = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Projectile.DrawBackglow(new Color(64, 255, 255) * strength, 4.5f, null, frame, sp); + + Main.spriteBatch.EnterShaderRegion(BlendState.AlphaBlend); + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(colorTransitionRatio * 0.45f); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(warningColor); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() * 0.5f, Projectile.scale, sp); + Main.spriteBatch.ExitShaderRegion(); + return false; + } + } +} diff --git a/Projectiles/Boss/ScavengerNuke.png b/Projectiles/Boss/RavagerNuke.png similarity index 100% rename from Projectiles/Boss/ScavengerNuke.png rename to Projectiles/Boss/RavagerNuke.png diff --git a/Projectiles/Boss/RedLightning.cs b/Projectiles/Boss/RedLightning.cs index 7f2f6405fa..8a241ad463 100644 --- a/Projectiles/Boss/RedLightning.cs +++ b/Projectiles/Boss/RedLightning.cs @@ -175,7 +175,7 @@ IL_25092: if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Boss/RedLightningFeather.cs b/Projectiles/Boss/RedLightningFeather.cs index 4941a9ffe3..bb604e5da0 100644 --- a/Projectiles/Boss/RedLightningFeather.cs +++ b/Projectiles/Boss/RedLightningFeather.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -129,7 +128,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0 || Projectile.Opacity != 1f) return; - target.AddBuff(ModContent.BuffType(), 40); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Boss/SCalBrimstoneFireblast.cs b/Projectiles/Boss/SCalBrimstoneFireblast.cs index 17595f148b..17473da1fb 100644 --- a/Projectiles/Boss/SCalBrimstoneFireblast.cs +++ b/Projectiles/Boss/SCalBrimstoneFireblast.cs @@ -1,17 +1,17 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.NPCs; +using CalamityMod.NPCs.CalClone; +using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; using CalamityMod.Particles; namespace CalamityMod.Projectiles.Boss @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Boss { public new string LocalizationCategory => "Projectiles.Boss"; public static readonly SoundStyle ImpactSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneFireblastImpact"); + public int DartDamage = 0; public bool withinRange = false; public bool setLifetime = false; public override void SetStaticDefaults() @@ -41,6 +42,19 @@ namespace CalamityMod.Projectiles.Boss CooldownSlot = ImmunityCooldownID.Bosses; } + public override void OnSpawn(IEntitySource source) + { + DartDamage = SupremeCalamitas.DartDamage; + + if (source is EntitySource_Parent { Entity: NPC parent }) + { + if (parent.type == ModContent.NPCType()) + DartDamage = Cryogen.IceRainDamage; + else if (parent.type == ModContent.NPCType()) + DartDamage = CalamitasClone.DartDamage; + } + } + public override void AI() { Projectile.frameCounter++; @@ -168,8 +182,13 @@ namespace CalamityMod.Projectiles.Boss { if (Main.npc[CalamityGlobalNPC.SCal].active) { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost) + { + lightColor.G = (byte)(255 * Projectile.Opacity); lightColor.B = (byte)(255 * Projectile.Opacity); + lightColor.R = 0; + } } } @@ -192,16 +211,15 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(ImpactSound, Projectile.Center); // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; if (Projectile.ai[2] == 0f) { if (Projectile.owner == Main.myPlayer) { - int totalProjectiles = bossRush ? 20 : death ? 16 : revenge ? 14 : expertMode ? 12 : 8; + int totalProjectiles = death ? 16 : revenge ? 14 : expertMode ? 12 : 8; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); float velocity = 8f; @@ -209,7 +227,7 @@ namespace CalamityMod.Projectiles.Boss for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, (int)Math.Round(Projectile.damage * 0.75), 0f, Projectile.owner, 0f, Projectile.ai[1], velocity * 1.5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, DartDamage, 0f, Projectile.owner, 0f, Projectile.ai[1], velocity * 1.5f); } } diff --git a/Projectiles/Boss/SCalBrimstoneGigablast.cs b/Projectiles/Boss/SCalBrimstoneGigablast.cs index 4ac7522311..9cd222a48d 100644 --- a/Projectiles/Boss/SCalBrimstoneGigablast.cs +++ b/Projectiles/Boss/SCalBrimstoneGigablast.cs @@ -1,14 +1,14 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.NPCs; +using CalamityMod.NPCs.CalClone; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Particles; @@ -19,6 +19,7 @@ namespace CalamityMod.Projectiles.Boss { public new string LocalizationCategory => "Projectiles.Boss"; public static readonly SoundStyle ImpactSound = new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneGigablastImpact"); + public int DartDamage = 0; public bool withinRange = false; public bool setLifetime = false; public override void SetStaticDefaults() @@ -40,6 +41,17 @@ namespace CalamityMod.Projectiles.Boss CooldownSlot = ImmunityCooldownID.Bosses; } + public override void OnSpawn(IEntitySource source) + { + DartDamage = SupremeCalamitas.DartDamage; + + if (source is EntitySource_Parent { Entity: NPC parent }) + { + if (parent.type == ModContent.NPCType()) + DartDamage = CalamitasClone.DartDamage; + } + } + public override void AI() { Projectile.frameCounter++; @@ -153,8 +165,12 @@ namespace CalamityMod.Projectiles.Boss { if (Main.npc[CalamityGlobalNPC.SCal].active) { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) + if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().permafrost) + { + lightColor.G = (byte)(255 * Projectile.Opacity); lightColor.B = (byte)(255 * Projectile.Opacity); + lightColor.R = 0; + } } } @@ -177,16 +193,15 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(ImpactSound, Projectile.Center); // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; if (Projectile.ai[2] == 0f) { if (Projectile.owner == Main.myPlayer) { - int totalProjectiles = bossRush ? 44 : death ? 36 : revenge ? 32 : expertMode ? 28 : 20; + int totalProjectiles = death ? 36 : revenge ? 32 : expertMode ? 28 : 20; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); float velocity = 6.5f; @@ -194,7 +209,7 @@ namespace CalamityMod.Projectiles.Boss for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, (int)Math.Round(Projectile.damage * 0.75), 0f, Projectile.owner, 0f, Projectile.ai[1], velocity * 1.5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity2, type, DartDamage, 0f, Projectile.owner, 0f, Projectile.ai[1], velocity * 1.5f); } } diff --git a/Projectiles/Boss/SCalRitualDrama.cs b/Projectiles/Boss/SCalRitualDrama.cs index 22850fc1e5..96069dfb7b 100644 --- a/Projectiles/Boss/SCalRitualDrama.cs +++ b/Projectiles/Boss/SCalRitualDrama.cs @@ -1,5 +1,5 @@ using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Particles; using CalamityMod.Skies; @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Boss if (Main.rand.NextBool()) { float variance = Main.rand.NextFloat(-25f, 25f); - Dust brimstone = Dust.NewDustPerfect(Projectile.Center + new Vector2(variance, 20), 267); + Dust brimstone = Dust.NewDustPerfect(Projectile.Center + new Vector2(variance, 20), DustID.RainbowMk2); brimstone.scale = Main.rand.NextFloat(0.35f, 1.2f); brimstone.color = Main.rand.NextBool() ? Color.Red : new Color(121, 21, 77); brimstone.fadeIn = 0.7f; @@ -98,33 +98,33 @@ namespace CalamityMod.Projectiles.Boss NPC scal = CalamityUtils.SpawnBossBetter(spawnPosition, ModContent.NPCType()); if (Projectile.ai[1] == 1) { - scal.ModNPC().cirrus = true; + scal.ModNPC().permafrost = true; } } // Make a laugh sound and create a burst of brimstone dust. - SoundStyle SpawnSound = Projectile.ai[1] == 1 ? SoundID.Item107 : SupremeCalamitas.SpawnSound; + SoundStyle SpawnSound = Projectile.ai[1] == 1 ? Cryogen.DeathSound : SupremeCalamitas.SpawnSound; SoundEngine.PlaySound(SpawnSound, Projectile.Center); // Make a sudden screen shake. - Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.GetLerpValue(3400f, 1560f, Main.LocalPlayer.Distance(Projectile.Center), true) * 16f; + Main.LocalPlayer.SetScreenshake(Utils.GetLerpValue(3400f, 1560f, Main.LocalPlayer.Distance(Projectile.Center), true) * 16f); // Generate a dust explosion at the ritual's position. for (int i = 0; i < 90; i++) { - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 1 ? (int)CalamityDusts.PurpleCosmilite : (int)CalamityDusts.Brimstone, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 1.2f)); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 1 ? DustID.IceGolem : (int)CalamityDusts.Brimstone, new Vector2(30, 30).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 1.2f)); spawnDust.noGravity = true; spawnDust.scale = Main.rand.NextFloat(1.2f, 2.3f); } for (int i = 0; i < 40; i++) { Vector2 sparkVel = new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.1f); - GlowOrbParticle orb = new GlowOrbParticle(Projectile.Center + sparkVel * 2, sparkVel, false, 120, Main.rand.NextFloat(1.55f, 2.75f), Projectile.ai[1] == 1 ? Color.Magenta : Color.Red, true, true); + GlowOrbParticle orb = new GlowOrbParticle(Projectile.Center + sparkVel * 2, sparkVel, false, 120, Main.rand.NextFloat(1.55f, 2.75f), Projectile.ai[1] == 1 ? Color.Cyan : Color.Red, true, true); GeneralParticleHandler.SpawnParticle(orb); } - Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Projectile.ai[1] == 1 ? Color.Magenta : Color.Red, new Vector2(2f, 2f), 0, 0f, 2.7f, 60); + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Projectile.ai[1] == 1 ? Color.Cyan : Color.Red, new Vector2(2f, 2f), 0, 0f, 2.7f, 60); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Projectile.ai[1] == 1 ? Color.Magenta : new Color(121, 21, 77), new Vector2(2f, 2f), 0, 0f, 2.1f, 60); + Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Projectile.ai[1] == 1 ? Color.Cyan : new Color(121, 21, 77), new Vector2(2f, 2f), 0, 0f, 2.1f, 60); GeneralParticleHandler.SpawnParticle(pulse2); } } diff --git a/Projectiles/Boss/SandPoisonCloud.cs b/Projectiles/Boss/SandPoisonCloud.cs index 6db2345c81..3e3905fa49 100644 --- a/Projectiles/Boss/SandPoisonCloud.cs +++ b/Projectiles/Boss/SandPoisonCloud.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -84,7 +83,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(BuffID.Venom, 180); } } } diff --git a/Projectiles/Boss/SandPoisonCloudOldDuke.cs b/Projectiles/Boss/SandPoisonCloudOldDuke.cs index 30db17a25a..1862f49051 100644 --- a/Projectiles/Boss/SandPoisonCloudOldDuke.cs +++ b/Projectiles/Boss/SandPoisonCloudOldDuke.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -32,6 +33,9 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + Projectile.spriteDirection = 1; + if (Projectile.Center.X < Main.LocalPlayer.Center.X) Projectile.spriteDirection = -1; + Lighting.AddLight(Projectile.Center, 0.1f, 0.7f, 0f); Projectile.ai[0] += 1f; @@ -43,6 +47,8 @@ namespace CalamityMod.Projectiles.Boss } if (Projectile.ai[0] < 1620f) { + GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Projectile.Top + new Vector2(Main.rand.NextFloat(-12, 12), 6f), new Vector2(0, -Main.rand.NextFloat(2)), false, 20, Main.rand.NextFloat(0.5f, 1.2f), new Color(100, 255, 0))); + if (Projectile.frame >= 4) { Projectile.frame = 0; @@ -67,11 +73,12 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); - CalamityUtils.DrawProjectileWithBackglow(Projectile, new Color(66, 236, 113), lightColor, 3.75f); - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + lightColor.R = (byte)(100 * Projectile.Opacity); + lightColor.G = (byte)(155 * Projectile.Opacity); + lightColor.B = (byte)(55 * Projectile.Opacity); + lightColor.A = 0; + CalamityUtils.DrawProjectileWithBackglow(Projectile, new Color(20, 60, 26, 0), Color.White, 2f); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } @@ -84,7 +91,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 240, true); + target.AddBuff(ModContent.BuffType(), 480, true); } } } diff --git a/Projectiles/Boss/ScavengerNuke.cs b/Projectiles/Boss/ScavengerNuke.cs deleted file mode 100644 index 6406bf212b..0000000000 --- a/Projectiles/Boss/ScavengerNuke.cs +++ /dev/null @@ -1,173 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -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; -namespace CalamityMod.Projectiles.Boss -{ - public class ScavengerNuke : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Boss"; - public static readonly SoundStyle ExplosionSound = new("CalamityMod/Sounds/Custom/Ravager/RavagerMissileExplosion"); - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 5; - } - - public override void SetDefaults() - { - Projectile.Calamity().DealsDefenseDamage = true; - Projectile.width = 44; - Projectile.height = 44; - Projectile.hostile = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.penetrate = 1; - Projectile.alpha = 255; - Projectile.timeLeft = 600; - } - - public override void AI() - { - bool bossRush = BossRushEvent.BossRushActive; - bool revenge = CalamityWorld.revenge || bossRush; - - if (Projectile.timeLeft < 180) - Projectile.tileCollide = true; - - Projectile.frameCounter++; - if (Projectile.frameCounter > 18) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 4) - Projectile.frame = 0; - - Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - - float inertia = bossRush ? 70f : revenge ? 90f : 110f; - float scaleFactor12 = bossRush ? 20f : revenge ? 16f : 12f; - - if (Projectile.alpha > 0) - Projectile.alpha -= 10; - if (Projectile.alpha < 0) - Projectile.alpha = 0; - - Lighting.AddLight(Projectile.Center, 1f, 0.7f, 0f); - - int playerTracker = (int)Projectile.ai[0]; - if (playerTracker >= 0 && Main.player[playerTracker].active && !Main.player[playerTracker].dead) - { - if (Projectile.Distance(Main.player[playerTracker].Center) > 320f) - { - Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[playerTracker].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * scaleFactor12) / inertia; - } - } - else - { - if (Projectile.timeLeft > 30) - Projectile.timeLeft = 30; - - if (Projectile.ai[0] != -1f) - { - Projectile.ai[0] = -1f; - Projectile.netUpdate = true; - } - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - { - if (DownedBossSystem.downedProvidence) - { - target.AddBuff(ModContent.BuffType(), 180, true); - } - else - { - target.AddBuff(ModContent.BuffType(), 180, true); - } - } - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(ExplosionSound, Projectile.Center); - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 160; - Projectile.position.X = Projectile.position.X - (Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); - Projectile.Damage(); - for (int i = 0; i < 30; i++) - { - int nukeDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f); - Main.dust[nukeDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[nukeDust].scale = 0.5f; - Main.dust[nukeDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 40; j++) - { - int nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 3f); - Main.dust[nukeDust2].noGravity = true; - Main.dust[nukeDust2].velocity *= 5f; - nukeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f); - Main.dust[nukeDust2].velocity *= 2f; - } - - if (!Main.dedServ) - { - Vector2 source = new Vector2(Projectile.Center.X - 24f, Projectile.Center.Y - 24f); - for (int g = 1; g <= 3; g++) - { - float velocityMult = g * 0.33f; - for (int spawn = 0; spawn < 4; spawn++) - { - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - } - } - } - } - - public override bool PreDraw(ref Color lightColor) - { - int timeToStartWarning = 180; - - Color initialColor = lightColor; - Color finalColor = Color.Lerp(Color.White, Color.Red, (float)Math.Abs(Math.Sin((timeToStartWarning - Projectile.timeLeft) * (MathHelper.Pi * 7f / 180f)))); - Color warningColor; - finalColor.A = (byte)(255 - Projectile.alpha); - - if (Projectile.timeLeft <= timeToStartWarning) - { - float colorTransitionRatio = (timeToStartWarning - Projectile.timeLeft) / (float)timeToStartWarning; - warningColor = Color.Lerp(initialColor, finalColor, colorTransitionRatio); - } - else - warningColor = initialColor; - - float strength = Utils.GetLerpValue(0, timeToStartWarning / 1.5f, timeToStartWarning - Projectile.timeLeft, true); - Rectangle frame = TextureAssets.Projectile[Type].Value.Frame(1, 5, 0, Projectile.frame); - SpriteEffects sp = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Projectile.DrawProjectileWithBackglow(new Color(64, 255, 255) * strength, Projectile.GetAlpha(warningColor), 4.5f, null, frame, sp); - return false; - } - } -} diff --git a/Projectiles/Boss/ShadeNimbusHostile.cs b/Projectiles/Boss/ShadeNimbusHostile.cs index 60a4894904..a4e68db418 100644 --- a/Projectiles/Boss/ShadeNimbusHostile.cs +++ b/Projectiles/Boss/ShadeNimbusHostile.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Events; +using CalamityMod.World; using Terraria; using Terraria.ModLoader; @@ -7,6 +9,7 @@ namespace CalamityMod.Projectiles.Boss public class ShadeNimbusHostile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; + public override void SetStaticDefaults() { Main.projFrames[Type] = 6; @@ -19,7 +22,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.hostile = true; - Projectile.timeLeft = 360; + Projectile.timeLeft = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 480 : 360; Projectile.penetrate = -1; } @@ -31,12 +34,11 @@ namespace CalamityMod.Projectiles.Boss Projectile.frameCounter = 0; Projectile.frame++; if (Projectile.frame > 5) - { Projectile.frame = 0; - } } + Projectile.ai[1] += 1f; - if (Projectile.ai[1] >= 300f) + if (Projectile.ai[1] >= ((CalamityWorld.death || BossRushEvent.BossRushActive) ? 420f : 300f)) { Projectile.alpha += 5; if (Projectile.alpha > 255) diff --git a/Projectiles/Boss/SignusScythe.cs b/Projectiles/Boss/SignusScythe.cs index 7693532568..8858590c10 100644 --- a/Projectiles/Boss/SignusScythe.cs +++ b/Projectiles/Boss/SignusScythe.cs @@ -1,6 +1,5 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Boss/SirenSong.cs b/Projectiles/Boss/SirenSong.cs index 8a343083b5..bf58180b67 100644 --- a/Projectiles/Boss/SirenSong.cs +++ b/Projectiles/Boss/SirenSong.cs @@ -78,13 +78,5 @@ namespace CalamityMod.Projectiles.Boss CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(BuffID.Dazed, 120); - } } } diff --git a/Projectiles/Boss/SkyFlareRevenge.cs b/Projectiles/Boss/SkyFlareRevenge.cs index 7cb58e9c83..0856f46a52 100644 --- a/Projectiles/Boss/SkyFlareRevenge.cs +++ b/Projectiles/Boss/SkyFlareRevenge.cs @@ -75,8 +75,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.owner == Main.myPlayer) { int type = ModContent.ProjectileType(); - int damage = Projectile.GetProjectileDamage(ModContent.NPCType()); - int nado = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, type, damage, 4f, Main.myPlayer, 16f, 50f); + int nado = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, type, Yharon.BordernadoDamage, 4f, Main.myPlayer, 16f, 50f); Main.projectile[nado].Bottom = Projectile.Center; Main.projectile[nado].netUpdate = true; } diff --git a/Projectiles/Boss/SporeGasPlantera.cs b/Projectiles/Boss/SporeGasPlantera.cs index f1527b37fd..7fa2a06228 100644 --- a/Projectiles/Boss/SporeGasPlantera.cs +++ b/Projectiles/Boss/SporeGasPlantera.cs @@ -1,5 +1,4 @@ using System.IO; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -18,17 +17,10 @@ namespace CalamityMod.Projectiles.Boss { ProjectileID.Sets.TrailCacheLength[Type] = 2; ProjectileID.Sets.TrailingMode[Type] = 0; - - if (!Main.dedServ) - { - Main.instance.LoadProjectile(ProjectileID.SporeGas2); - Main.instance.LoadProjectile(ProjectileID.SporeGas3); - } } public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 32; Projectile.height = 32; Projectile.hostile = true; @@ -50,7 +42,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { Projectile.ai[1] += 1f; - if (Projectile.ai[1] > (CalamityWorld.LegendaryMode ? 600f : 900f)) + if (Projectile.ai[1] > (Main.getGoodWorld ? 600f : 900f)) { Projectile.localAI[0] += 10f; Projectile.damage = 0; @@ -69,17 +61,17 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation += Projectile.velocity.X * 0.02f; Projectile.rotation += Projectile.direction * 0.002f; - if (Projectile.velocity.Length() > (CalamityWorld.LegendaryMode ? 4f : 2f)) + if (Projectile.velocity.Length() > (Main.getGoodWorld ? 4f : 2f)) Projectile.velocity *= 0.985f; } - public override bool CanHitPlayer(Player target) => Projectile.ai[1] <= (CalamityWorld.LegendaryMode ? 600f : 900f) && Projectile.ai[1] > 120f; + public override bool CanHitPlayer(Player target) => Projectile.ai[1] <= (Main.getGoodWorld ? 600f : 900f) && Projectile.ai[1] > 120f; public override Color? GetAlpha(Color lightColor) { - if (Projectile.ai[1] > (CalamityWorld.LegendaryMode ? 600f : 900f)) + if (Projectile.ai[1] > (Main.getGoodWorld ? 600f : 900f)) { - byte b2 = (byte)((26f - (Projectile.ai[1] - (CalamityWorld.LegendaryMode ? 600f : 900f))) * 10f); + byte b2 = (byte)((26f - (Projectile.ai[1] - (Main.getGoodWorld ? 600f : 900f))) * 10f); byte a2 = (byte)(Projectile.alpha * (b2 / 255f)); return new Color(b2, b2, b2, a2); } @@ -95,9 +87,11 @@ namespace CalamityMod.Projectiles.Boss case 0: break; case 1: + Main.instance.LoadProjectile(ProjectileID.SporeGas2); texture = TextureAssets.Projectile[ProjectileID.SporeGas2].Value; break; case 2: + Main.instance.LoadProjectile(ProjectileID.SporeGas3); texture = TextureAssets.Projectile[ProjectileID.SporeGas3].Value; break; default: @@ -112,7 +106,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - if (Projectile.ai[1] <= (CalamityWorld.LegendaryMode ? 600f : 900f) && Projectile.ai[1] > 120f) + if (Projectile.ai[1] <= (Main.getGoodWorld ? 600f : 900f) && Projectile.ai[1] > 120f) target.AddBuff(BuffID.Poisoned, 480); } } diff --git a/Projectiles/Boss/SupremeCataclysmFist.cs b/Projectiles/Boss/SupremeCataclysmFist.cs index edb9e872bf..df2444c9b7 100644 --- a/Projectiles/Boss/SupremeCataclysmFist.cs +++ b/Projectiles/Boss/SupremeCataclysmFist.cs @@ -1,6 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Accessories; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Particles; using CalamityMod.Events; @@ -43,10 +41,9 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // The Orb if (Projectile.ai[2] >= 3) @@ -82,7 +79,7 @@ namespace CalamityMod.Projectiles.Boss { 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)); + Dust cataclysmdust = Dust.NewDustPerfect(Projectile.Center + velocity * (b == 0 ? 7 : 5), DustID.SilverFlame, velocity * (b == 0 ? 9 : 7)); cataclysmdust.noGravity = true; cataclysmdust.scale = Main.rand.NextFloat(1.3f, 1.9f); cataclysmdust.color = Color.Red; @@ -92,7 +89,7 @@ namespace CalamityMod.Projectiles.Boss } 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); + Dust cataclysmdust2 = Dust.NewDustPerfect(Projectile.Center + vel * 2, DustID.SilverFlame, vel); cataclysmdust2.noGravity = true; cataclysmdust2.scale = Main.rand.NextFloat(0.9f, 1.2f); cataclysmdust2.color = Color.Red; @@ -177,7 +174,7 @@ namespace CalamityMod.Projectiles.Boss { 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)); + Dust cataclysmdust = Dust.NewDustPerfect(Projectile.Center + velocity * (b == 0 ? 7 : 5), DustID.SilverFlame, velocity * (b == 0 ? 9 : 7)); cataclysmdust.noGravity = true; cataclysmdust.scale = Main.rand.NextFloat(1.3f, 1.9f); cataclysmdust.color = Color.Red; @@ -187,7 +184,7 @@ namespace CalamityMod.Projectiles.Boss } 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); + Dust cataclysmdust2 = Dust.NewDustPerfect(Projectile.Center + vel * 2, DustID.SilverFlame, vel); cataclysmdust2.noGravity = true; cataclysmdust2.scale = Main.rand.NextFloat(0.9f, 1.2f); cataclysmdust2.color = Color.Red; @@ -246,7 +243,7 @@ namespace CalamityMod.Projectiles.Boss { Vector2 velocity = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.2f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity, 66, velocity * Main.rand.NextFloat(0.2f, 1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity, DustID.RainbowTorch, velocity * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.3f, 1.9f); dust.color = Color.Lerp(Color.Red, Color.Magenta, 0.5f); @@ -281,13 +278,6 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => (Projectile.Opacity >= 1f || Projectile.ai[2] >= 3); - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.Opacity != 1f) - return; - - target.AddBuff(ModContent.BuffType(), 240, true); - } public override bool OnTileCollide(Vector2 oldVelocity) { SoundStyle b = new("CalamityMod/Sounds/Custom/Kickball"); diff --git a/Projectiles/Boss/SupremeCatastropheSlash.cs b/Projectiles/Boss/SupremeCatastropheSlash.cs index afa91f3d53..6f9a5db93a 100644 --- a/Projectiles/Boss/SupremeCatastropheSlash.cs +++ b/Projectiles/Boss/SupremeCatastropheSlash.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -26,8 +25,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; - // These never naturally use rotations, so this shouldn't be an issue. Projectile.width = 100; Projectile.height = 60; @@ -46,10 +43,9 @@ namespace CalamityMod.Projectiles.Boss Time++; // Difficulty modes - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Decide frames. Projectile.frameCounter++; @@ -78,7 +74,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.Opacity = 0f; if (Main.rand.NextBool()) { - Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center, 66, -Projectile.velocity * Main.rand.NextFloat(0.1f, 1.5f)); + Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowTorch, -Projectile.velocity * Main.rand.NextFloat(0.1f, 1.5f)); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(0.5f, 0.7f); catastrophedust.color = Color.DeepSkyBlue; @@ -103,7 +99,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.velocity *= 1.015f; if (Main.rand.NextBool(3)) { - Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50, 50) - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 8.5f, 66, -Projectile.velocity * Main.rand.NextFloat(0.2f, 1.2f)); + Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50, 50) - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 8.5f, DustID.RainbowTorch, -Projectile.velocity * Main.rand.NextFloat(0.2f, 1.2f)); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(0.5f, 0.7f); catastrophedust.color = Color.DeepSkyBlue; @@ -134,7 +130,7 @@ namespace CalamityMod.Projectiles.Boss for (int i = 0; i < 3; i++) { Vector2 vel = new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); - Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center + vel * 2, 279, vel); + Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center + vel * 2, DustID.SilverFlame, vel); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); catastrophedust.color = Color.DeepSkyBlue; @@ -166,7 +162,7 @@ namespace CalamityMod.Projectiles.Boss for (int i = 0; i < 3; i++) { Vector2 vel = new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 2.5f); - Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center + vel * 2, 279, vel); + Dust catastrophedust = Dust.NewDustPerfect(Projectile.Center + vel * 2, DustID.SilverFlame, vel); catastrophedust.noGravity = true; catastrophedust.scale = Main.rand.NextFloat(1.2f, 1.8f); catastrophedust.color = Color.DeepSkyBlue; @@ -182,7 +178,7 @@ namespace CalamityMod.Projectiles.Boss { Vector2 velocity = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.2f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity, 66, velocity * Main.rand.NextFloat(0.2f, 1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity, DustID.RainbowTorch, velocity * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.3f, 1.9f); dust.color = Color.Cyan; diff --git a/Projectiles/Boss/SwirlingFire.cs b/Projectiles/Boss/SwirlingFire.cs index f5554e4fb8..cbb479b398 100644 --- a/Projectiles/Boss/SwirlingFire.cs +++ b/Projectiles/Boss/SwirlingFire.cs @@ -1,7 +1,5 @@ -using CalamityMod.NPCs; -using CalamityMod.NPCs.Providence; +using CalamityMod.NPCs.Providence; using CalamityMod.Particles; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Boss/THanosSideLaser.cs b/Projectiles/Boss/THanosSideLaser.cs index 89b47ae15d..45912e2444 100644 --- a/Projectiles/Boss/THanosSideLaser.cs +++ b/Projectiles/Boss/THanosSideLaser.cs @@ -1,9 +1,6 @@ using System; using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; -using CalamityMod.NPCs.ExoMechs.Ares; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -95,7 +92,7 @@ namespace CalamityMod.Projectiles.Boss if (Velocity != Vector2.Zero) { Projectile.extraUpdates = Main.getGoodWorld ? 4 : 3; - Projectile.velocity = Velocity * (BossRushEvent.BossRushActive ? 1.25f : 1f); + Projectile.velocity = Velocity; Velocity = Vector2.Zero; Projectile.netUpdate = true; } diff --git a/Projectiles/Boss/ThanatosBeamStart.cs b/Projectiles/Boss/ThanatosBeamStart.cs index 1169549444..f2c2441310 100644 --- a/Projectiles/Boss/ThanatosBeamStart.cs +++ b/Projectiles/Boss/ThanatosBeamStart.cs @@ -107,10 +107,9 @@ namespace CalamityMod.Projectiles.Boss return; // Difficulty modes. Used during the firing of the perpendicular lasers. - bool bossRush = BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || bossRush; - bool revenge = CalamityWorld.revenge || bossRush; - bool expertMode = Main.expertMode || bossRush; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; // Spawn dust at the end of the beam. int dustType = (int)CalamityDusts.Brimstone; @@ -137,7 +136,7 @@ namespace CalamityMod.Projectiles.Boss } // Periodically fire beams along the laser perpendicular to its direction. - float laserFireRate = (CalamityWorld.LegendaryMode && revenge) ? 60f : expertMode ? 80f : 160f; + float laserFireRate = Main.getGoodWorld ? 60f : expertMode ? 80f : 160f; if (Main.npc[OwnerIndex].Calamity().newAI[2] % laserFireRate == 0f) { // Play a laser sound to go with the beams. @@ -146,19 +145,18 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.owner == Main.myPlayer) { Vector2 beamDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY); - float distanceBetweenProjectiles = bossRush ? 160f : death ? 256f : revenge ? 288f : 320f; + float distanceBetweenProjectiles = death ? 256f : revenge ? 288f : 320f; Vector2 laserFirePosition = Main.npc[OwnerIndex].Center + beamDirection * distanceBetweenProjectiles; int laserCount = (int)(LaserLength / distanceBetweenProjectiles); int type = ModContent.ProjectileType(); - int damage = Projectile.GetProjectileDamage(Main.npc[OwnerIndex].type); for (int i = 0; i < laserCount; i++) { int totalProjectiles = 2; float radians = MathHelper.TwoPi / totalProjectiles; for (int j = 0; j < totalProjectiles; j++) { - Vector2 projVelocity = (CalamityWorld.LegendaryMode && revenge) ? new Vector2(Main.rand.Next(-12, 12), Main.rand.Next(-12, 12)) : Projectile.velocity.RotatedBy(radians * j + MathHelper.PiOver2) * 12f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), laserFirePosition, projVelocity, type, damage, 0f, Main.myPlayer, 0f, -1f); + Vector2 projVelocity = Main.getGoodWorld ? new Vector2(Main.rand.Next(-12, 12), Main.rand.Next(-12, 12)) : Projectile.velocity.RotatedBy(radians * j + MathHelper.PiOver2) * 12f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), laserFirePosition, projVelocity, type, ThanatosHead.LaserDamage, 0f, Main.myPlayer, 0f, -1f); } laserFirePosition += beamDirection * distanceBetweenProjectiles; } @@ -242,7 +240,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 300); } public override bool CanHitPlayer(Player target) => OwnerIsValid && Projectile.scale >= 0.5f; diff --git a/Projectiles/Boss/ThanatosLaser.cs b/Projectiles/Boss/ThanatosLaser.cs index 75739ff077..455992fbfd 100644 --- a/Projectiles/Boss/ThanatosLaser.cs +++ b/Projectiles/Boss/ThanatosLaser.cs @@ -1,9 +1,6 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Events; using CalamityMod.NPCs.ExoMechs.Ares; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -38,7 +35,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 22; Projectile.height = 22; Projectile.hostile = true; @@ -99,7 +95,7 @@ namespace CalamityMod.Projectiles.Boss if (Velocity != Vector2.Zero) { Projectile.extraUpdates = Main.getGoodWorld ? 4 : 3; - Projectile.velocity = Velocity * (BossRushEvent.BossRushActive ? 1.25f : 1f); + Projectile.velocity = Velocity; Velocity = Vector2.Zero; Projectile.netUpdate = true; } @@ -162,7 +158,7 @@ namespace CalamityMod.Projectiles.Boss if (Velocity != Vector2.Zero) { Projectile.extraUpdates = Main.getGoodWorld ? 4 : 3; - Projectile.velocity = Velocity * (BossRushEvent.BossRushActive ? 1.25f : 1f); + Projectile.velocity = Velocity; Velocity = Vector2.Zero; Projectile.netUpdate = true; } @@ -240,14 +236,6 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || TelegraphDelay <= TelegraphTotalTime) - return; - - target.AddBuff(ModContent.BuffType(), 90); - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { return CalamityUtils.CircularHitboxCollision(projHitbox.Center(), Projectile.Size.Length() * 0.5f, targetHitbox); diff --git a/Projectiles/Boss/ThornBallSpike.cs b/Projectiles/Boss/ThornBallSpike.cs index 790a4288bb..5f1411db59 100644 --- a/Projectiles/Boss/ThornBallSpike.cs +++ b/Projectiles/Boss/ThornBallSpike.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -56,7 +55,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; } - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Venom, 90); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Venom, 120); public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha); diff --git a/Projectiles/Boss/ToxicCloud.cs b/Projectiles/Boss/ToxicCloud.cs index c1c879d50c..8e9cda4d69 100644 --- a/Projectiles/Boss/ToxicCloud.cs +++ b/Projectiles/Boss/ToxicCloud.cs @@ -1,7 +1,5 @@ using System; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Events; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -36,8 +34,7 @@ namespace CalamityMod.Projectiles.Boss { Lighting.AddLight(Projectile.Center, 0.1f, 0.7f, 0f); - bool bossRush = BossRushEvent.BossRushActive; - if (Projectile.velocity.Length() < (bossRush ? 6.25f : 5f)) + if (Projectile.velocity.Length() < 5f) Projectile.velocity *= 1.01f; Projectile.ai[0] += 1f; @@ -88,9 +85,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(BuffID.Poisoned, 240); - target.AddBuff(BuffID.Venom, 240); - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 480); } } } diff --git a/Projectiles/Boss/UnstableCrimulanGlob.cs b/Projectiles/Boss/UnstableCrimulanGlob.cs index 5c2a01564d..e40f6f9e35 100644 --- a/Projectiles/Boss/UnstableCrimulanGlob.cs +++ b/Projectiles/Boss/UnstableCrimulanGlob.cs @@ -11,23 +11,26 @@ namespace CalamityMod.Projectiles.Boss public class UnstableCrimulanGlob : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; + public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 30; Projectile.height = 30; Projectile.hostile = true; Projectile.penetrate = 1; Projectile.Opacity = 0.8f; Projectile.tileCollide = false; - Projectile.timeLeft = BossRushEvent.BossRushActive ? 640 : CalamityWorld.death ? 490 : CalamityWorld.revenge ? 440 : Main.expertMode ? 390 : 240; + Projectile.timeLeft = CalamityWorld.death ? 490 : CalamityWorld.revenge ? 440 : Main.expertMode ? 390 : 240; - if (Main.getGoodWorld) + if (Main.zenithWorld) Projectile.extraUpdates = 1; } public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.1f) * Projectile.Opacity; + Lighting.AddLight(Projectile.Center, light.X, light.Y, light.Z); + // Fly up and then fall down if (Projectile.ai[0] == 1f) { @@ -47,7 +50,7 @@ namespace CalamityMod.Projectiles.Boss { if (Projectile.velocity.Length() < 15f && (Main.expertMode || BossRushEvent.BossRushActive)) { - float velocityMult = BossRushEvent.BossRushActive ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; + float velocityMult = CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; Projectile.velocity *= velocityMult; } } @@ -59,7 +62,7 @@ namespace CalamityMod.Projectiles.Boss { Color dustColor = Color.Crimson; dustColor.A = 150; - int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, Projectile.alpha, dustColor); + int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, 0, dustColor); Main.dust[dust].noGravity = true; } @@ -70,19 +73,8 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => Projectile.timeLeft >= 60; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.timeLeft < 60) - return; - - target.AddBuff(BuffID.Darkness, 180); - } - public override bool PreDraw(ref Color lightColor) { - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } diff --git a/Projectiles/Boss/UnstableEbonianGlob.cs b/Projectiles/Boss/UnstableEbonianGlob.cs index 2860149285..17ab17c58b 100644 --- a/Projectiles/Boss/UnstableEbonianGlob.cs +++ b/Projectiles/Boss/UnstableEbonianGlob.cs @@ -14,24 +14,26 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 30; Projectile.height = 30; Projectile.hostile = true; Projectile.penetrate = 1; Projectile.Opacity = 0.8f; Projectile.tileCollide = false; - Projectile.timeLeft = BossRushEvent.BossRushActive ? 780 : CalamityWorld.death ? 600 : CalamityWorld.revenge ? 540 : Main.expertMode ? 480 : 300; + Projectile.timeLeft = CalamityWorld.death ? 600 : CalamityWorld.revenge ? 540 : Main.expertMode ? 480 : 300; - if (Main.getGoodWorld) + if (Main.zenithWorld) Projectile.extraUpdates = 1; } public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.5f) * Projectile.Opacity; + Lighting.AddLight(Projectile.Center, light.X, light.Y, light.Z); + if (Projectile.velocity.Length() < 12f && (Main.expertMode || BossRushEvent.BossRushActive || Projectile.ai[0] == 1f)) { - float velocityMult = BossRushEvent.BossRushActive ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; + float velocityMult = CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; if (Projectile.ai[0] == 1f) velocityMult += 0.02f; @@ -46,7 +48,7 @@ namespace CalamityMod.Projectiles.Boss { Color dustColor = Color.Lavender; dustColor.A = 150; - int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, Projectile.alpha, dustColor); + int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, 0, dustColor); Main.dust[dust].noGravity = true; } @@ -57,19 +59,8 @@ namespace CalamityMod.Projectiles.Boss public override bool CanHitPlayer(Player target) => Projectile.timeLeft >= 60; - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0 || Projectile.timeLeft < 60) - return; - - target.AddBuff(BuffID.Weak, 180); - } - public override bool PreDraw(ref Color lightColor) { - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } diff --git a/Projectiles/Boss/VileClot.cs b/Projectiles/Boss/VileClot.cs index b793e0bd72..8a0946cd80 100644 --- a/Projectiles/Boss/VileClot.cs +++ b/Projectiles/Boss/VileClot.cs @@ -1,5 +1,4 @@ using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Boss/YharonBulletHellVortex.cs b/Projectiles/Boss/YharonBulletHellVortex.cs index 4fde90ccdf..1187ff9969 100644 --- a/Projectiles/Boss/YharonBulletHellVortex.cs +++ b/Projectiles/Boss/YharonBulletHellVortex.cs @@ -1,6 +1,5 @@ using System.IO; using CalamityMod.NPCs.Yharon; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -31,6 +30,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.penetrate = -1; Projectile.alpha = 255; Projectile.timeLeft = 60000; + Projectile.Calamity().DealsDefenseDamage = true; } public override void SendExtraAI(BinaryWriter writer) @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.hostile = true; Projectile.width = Projectile.height = (int)(408f * Projectile.scale); float inertia = 5f; - float speed = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10.7f : 5.35f; + float speed = 5.35f; float minDist = 160f; if (victim >= 0 && Main.player[victim].active && !Main.player[victim].dead) { @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Boss } // Fly away from other vortices - float pushForce = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.1f : 0.05f; + float pushForce = 0.05f; for (int k = 0; k < Main.maxProjectiles; k++) { Projectile otherProj = Main.projectile[k]; diff --git a/Projectiles/Boss/YharonFireball.cs b/Projectiles/Boss/YharonFireball.cs index 2f8648e584..b7b87e1de4 100644 --- a/Projectiles/Boss/YharonFireball.cs +++ b/Projectiles/Boss/YharonFireball.cs @@ -11,8 +11,8 @@ namespace CalamityMod.Projectiles.Boss public class YharonFireball : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; - private float speedX = -1f; - private float speedX2 = -2f; + private float speedX = -3f; + private float speedX2 = -5f; public override void SetStaticDefaults() { @@ -23,7 +23,6 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 34; Projectile.height = 34; Projectile.hostile = true; @@ -95,13 +94,13 @@ namespace CalamityMod.Projectiles.Boss { for (int x = 0; x < 3; x++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, speedX, -6f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer); - speedX += 1f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, speedX, -50f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer); + speedX += 3f; } for (int x = 0; x < 2; x++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, speedX2, -6f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer); - speedX2 += 4f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, speedX2, -75f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer); + speedX2 += 10f; } } Projectile.ExpandHitboxBy(144); diff --git a/Projectiles/Boss/YharonFireball2.cs b/Projectiles/Boss/YharonFireball2.cs index df9e249e70..96b9044f0d 100644 --- a/Projectiles/Boss/YharonFireball2.cs +++ b/Projectiles/Boss/YharonFireball2.cs @@ -29,10 +29,10 @@ namespace CalamityMod.Projectiles.Boss public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 34; Projectile.height = 34; Projectile.hostile = true; + Projectile.Opacity = 0.25f; Projectile.alpha = 255; Projectile.penetrate = -1; Projectile.timeLeft = 3600; @@ -60,21 +60,43 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.frame >= Main.projFrames[Type]) Projectile.frame = 0; - if (Projectile.ai[0] < TimeBeforeFalling) + if (Projectile.velocity.Y >= -16f) { - Projectile.ai[0] += 1f; - Projectile.velocity.Y -= 0.1f; - if (Projectile.velocity.Y < MaxUpwardVelocity) - Projectile.velocity.Y = MaxUpwardVelocity; + if (Projectile.Opacity < 1f) + { + Projectile.Opacity = 1f; + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + int dustAmount = 36; + + for (int i = 0; i < dustAmount; i++) + { + Vector2 dustSpawnPosition = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.5f; + dustSpawnPosition = dustSpawnPosition.RotatedBy((double)((float)(i - (dustAmount / 2 - 1)) * MathHelper.TwoPi / (float)dustAmount), default) + Projectile.Center; + Vector2 dustVelocity = dustSpawnPosition - Projectile.Center; + + int dust = Dust.NewDust(dustSpawnPosition + dustVelocity, 0, 0, DustID.Pixie, dustVelocity.X, dustVelocity.Y); + Main.dust[dust].noGravity = true; + Main.dust[dust].noLight = true; + Main.dust[dust].velocity = dustVelocity; + } + } + } + + if (Projectile.velocity.Y < -1f) + { + // 129 frames to get from -50 to -1 + Projectile.velocity.Y *= 0.97f; } else { - Projectile.velocity.X *= 0.8f; + // 85 frames to get from -1 to 16 Projectile.velocity.Y += 0.2f; - if (Projectile.velocity.Y > MaxDownwardVelocity) - Projectile.velocity.Y = MaxDownwardVelocity; + if (Projectile.velocity.Y > 16f) + Projectile.velocity.Y = 16f; } + Projectile.velocity.X *= 0.995f; + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; if (Projectile.localAI[0] == 0f) @@ -83,6 +105,13 @@ namespace CalamityMod.Projectiles.Boss SoundEngine.PlaySound(FireballSound, Projectile.Center); } + if (Projectile.ai[0] >= 2f) + { + Projectile.alpha -= 25; + if (Projectile.alpha < 0) + Projectile.alpha = 0; + } + if (Main.rand.NextBool(16)) { Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Pixie, 0f, 0f, 200, default, 1f); @@ -91,6 +120,7 @@ namespace CalamityMod.Projectiles.Boss } } + public override bool CanHitPlayer(Player target) => Projectile.velocity.Y >= -16f; public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha); public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 00aefb65a5..2425fef8d8 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -12,12 +12,19 @@ using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.ExtraTextures; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Ammo; +using CalamityMod.Items.Fishing.FishingRods; +using CalamityMod.Items.Armor.Daedalus; +using CalamityMod.Items.Armor.Reaver; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.NPCs; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PlagueEnemies; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; @@ -25,6 +32,7 @@ using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Projectiles.VanillaProjectileOverrides; using CalamityMod.Systems.Collections; +using CalamityMod.Systems.Mechanic; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; @@ -46,6 +54,7 @@ using Terraria.Utilities; using Terraria.WorldBuilding; using static Terraria.ModLoader.ModContent; using NanotechProjectile = CalamityMod.Projectiles.Typeless.Nanotech; +using CalamityMod.Graphics; namespace CalamityMod.Projectiles { @@ -73,11 +82,6 @@ namespace CalamityMod.Projectiles /// Constant variable used as a speed cap for boss laser projectiles with 2 extra updates. public const float AcceleratingBossLaserVelocityCap = 8f; - /// Constant variable used to determine the percentage a projectile's damage is reduced by pierce resist on each hit. - public const float PierceResistHarshness = 0.12f; - /// Constant variable used to determine the maximum percentage a projectile's damage can be reduced by pierce resist. - public const float PierceResistCap = 0.8f; - /// /// Used for executing frame one hacks. Things set during this include: ///
* Reducing projectile damage for Hardmode enemies and in Master Mode. @@ -118,10 +122,17 @@ namespace CalamityMod.Projectiles /// If true, this projectile is able to spawn lightning while using Arc Flash Ring.
/// This is set to false when lightning is procced, and is reset to true when the cooldown ends. ///
- public bool spawnArcFlash = true; + public bool showArcFlash = true; /// Cooldown variable for Arc Flash Ring's lightning. Primarily used for lingering projectiles and minions. public int arcFlashCooldown = 0; - + /// + /// The location of this projectile in an arena box, used for maintaining this when the arena box moves. + /// + public Vector2 arenaBoxPosition = Vector2.Zero; + /// + /// Which Box this projectile is attached to + /// + public ArenaWallSystem.Box arenaBox = null; /// /// If true, adds a brimstone trail to the projectile, and makes it inflict Brimstone Flames.
/// Used by Animosity. @@ -176,10 +187,16 @@ namespace CalamityMod.Projectiles public bool betterLifeBullet2 = false; /// /// If set to a value greater than 0, causes this projectile to gain homing with a range equal to the value in pixels.
- /// Used by Arterial Assault. + /// Used by Arterial Assault, Deific Amulet's stars, and certain sand projectiles from the Sand Gun. ///
public float conditionalHomingRange = 0f; + /// + /// Whether or not this proj was spawned with grape beer on + /// this does NOT mean it has grape beer homing! + /// + public bool grapeBeer = false; + /// /// Variable used for storing the actual amount of extra updates a projectile has.
/// This is NOT set automatically, and must be set whenever it is needed. @@ -192,21 +209,6 @@ namespace CalamityMod.Projectiles ///
public int timesPierced = 0; - /// - /// If this projectile uses point-blank damage, this gets set to , then is decremented every frame.
- /// If it reaches 0, this projectile can no longer deal point-blank damage. - ///
- public int pointBlankShotDuration = 0; - /// - /// If this projectile uses point-blank damage, this value is incremented on every update by the distance the projectile traveled on that update.
- /// If it exceeds , this projectile can no longer deal point-blank damage. - ///
- public float pointBlankShotDistanceTravelled = 0f; - /// Constant variable which stores how many frames a projectile is allowed to deal point-blank damage. - public const int DefaultPointBlankDuration = 18; // 18 frames - /// Constant variable which stores the maximum distance a projectile can travel to deal point-blank damage, in pixels. - public const float PointBlankShotDistanceLimit = 240f; // 15 tiles - // Empress of Light variables private const float EmpressRainbowStreakSpreadOutCutoff = 140f; private const int EmpressLastingRainbowTotalDuration = 660; @@ -222,6 +224,14 @@ namespace CalamityMod.Projectiles /// A temporary flat amount subtracted from the projectile's damage when hitting the player. Resets to 0 if drops to 0. public int flatDR = 0; + /// Timer for how long a projectile's damage is reduced by the value in . + public int multiplicativeDRTimer = 0; + /// A temporary multiplicative amount of damage reduction when hitting the player. Resets to 0 if drops to 0. + public float multiplicativeDR = 0; + + /// If true, this projectile is a hook which has spawned a flower on it from Bloom Stone. Used to prevent spawning multiple flowers. + public bool hookCanSpawnFlower = false; + /// If true, allows hostile projectiles to deal defense damage to the player. Used mostly for hard-hitting bosses. public bool DealsDefenseDamage = false; @@ -259,10 +269,6 @@ namespace CalamityMod.Projectiles /// Cooldown variable used to prevent projectiles from spawning orbs while in The Transformer's aura. public int TransformerTimer = 0; - // Note: Although this was intended for fishing line colors, I use this as an AI variable a lot because vanilla only has 4 that sometimes are already in use. ~Ben - // TODO -- uses of this variable are undocumented and unstable. Remove it from the API surface. - public int lineColor = 0; - /// /// There are several NPCs in Calamity which do not take damage from minions in certain circumstances.
/// If true, this variable allows a projectile that deals summon damage to bypass this mechanic. @@ -282,12 +288,20 @@ namespace CalamityMod.Projectiles /// /// Custom update priority.
/// Calamity sorts projectiles by their update priority to fix otherwise absurdly difficult to resolve visual bugs on certain weapons.
- /// Examples include Mechworm segments detaching or Rancor's laser beam being offset from the magic circle. + /// Examples include Void Eater Marionette segments detaching or Rancor's laser beam being offset from the magic circle. ///
public float UpdatePriority = 0f; - #region On Spawn + public int BloodstoneOrbValue = 0; + public int HomingTarget = -1; + + /// + /// Flag used during Rev+ Brain of Cthulhu to denote projectiles that were spawned prior to its Illusion Trick attack starting. + /// + public bool IgnoreBoCIllusions = false; + + #region On Spawn public override void OnSpawn(Projectile projectile, IEntitySource source) { // TODO -- it would be nice to move frame one hacks here, but this runs in the middle of NewProjectile @@ -299,18 +313,83 @@ namespace CalamityMod.Projectiles if (sourceItem != null) extorterBoost = true; - if (source is EntitySource_Parent { Entity: NPC npc }) - { - if (!npc.friendly) - ParentNPCIndex = npc.whoAmI; - } - // Whenever the player has Daawnlight Spirit Origin, any ranged projectile will have the capacity to infintely supercrit. if (Main.player[projectile.owner].Calamity().spiritOrigin && projectile.CountsAsClass()) { projectile.CritChance += Main.player[projectile.owner].Calamity().spiritOriginCritBoost; projectile.Calamity().supercritHits = -1; } + + void ApplyGrapeBeer() + { + conditionalHomingRange = 600; + if (projectile.timeLeft > 300 * projectile.MaxUpdates) + projectile.timeLeft = 300 * projectile.MaxUpdates; + //Calamity adds a hybrid iframe system when both local and static are set to true, so this works fine for both global and static projectiles. + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + } + if (source is EntitySource_ItemUse_WithAmmo {Item: Item item}) + { + if (source is EntitySource_Parent { Entity: Player player }) + { + if (player.Calamity().grapeBeer && (item.useAmmo == AmmoID.Bullet || item.useAmmo == AmmoID.Arrow || item.useAmmo == AmmoID.Dart || item.useAmmo == AmmoID.Rocket)) + { + if (player.heldProj != projectile.whoAmI && projectile.aiStyle != ProjAIStyleID.HeldProjectile && projectile.damage > 0 && player.Calamity().grapeBeerTimer < 5) + ApplyGrapeBeer(); + else + grapeBeer = true; + } + } + } + + if (source is EntitySource_Parent { Entity: NPC npc }) + { + if (!npc.friendly) + ParentNPCIndex = npc.whoAmI; + } + // + // SPECIFIC PROJECTILE BALANCE CHANGES (and Grape Beer homing) + // + else if (source is EntitySource_Parent { Entity: Projectile parent }) + { + //Grape Beer homing + if (parent.Calamity().grapeBeer) + { + if (Main.player[projectile.owner].heldProj != projectile.whoAmI && projectile.aiStyle != ProjAIStyleID.HeldProjectile && projectile.damage > 0 && Main.player[projectile.owner].Calamity().grapeBeerTimer < 5) + ApplyGrapeBeer(); + else + grapeBeer = true; + } + + // Nerf Crystal bullet shard damage by 45% + // Vanilla crystal shards deal 50% of the bullet's damage which is absurd, this nerfs them to 27.5% + if (parent.type == ProjectileID.CrystalBullet && projectile.type == ProjectileID.CrystalShard) + projectile.damage = (int)(projectile.damage * 0.55f); + + // Nerf Mushroom Spear mushroom damage by 50% + if (parent.type == ProjectileID.MushroomSpear && projectile.type == ProjectileID.Mushroom) + projectile.damage /= 2; + + // Nerf Luminite Arrow trail damage by 50% + if (parent.type == ProjectileID.MoonlordArrow && projectile.type == ProjectileID.MoonlordArrowTrail) + projectile.damage /= 2; + + // Nerf Cursed Dart flame damage by 50% + if (parent.type == ProjectileID.CursedDart && projectile.type == ProjectileID.CursedDartFlame) + projectile.damage /= 2; + + // Nerf Chlorophyte armor's set bonus crystal damage by 30% + if (parent.type == ProjectileID.CrystalLeaf && projectile.type == ProjectileID.CrystalLeafShot) + projectile.damage = (int)(projectile.damage * 0.7f); + } + + if (source is EntitySource_OnHit e) + { + // Nerf Spectre armor's set bonus soul damage by 50% + if (e.Context == "SetBonus_GhostHurt") + projectile.damage /= 2; + } } public override void SendExtraAI(Projectile projectile, BitWriter bitWriter, BinaryWriter binaryWriter) => binaryWriter.Write(ParentNPCIndex); public override void ReceiveExtraAI(Projectile projectile, BitReader bitReader, BinaryReader binaryReader) => ParentNPCIndex = binaryReader.ReadInt32(); @@ -341,13 +420,22 @@ namespace CalamityMod.Projectiles #region Pre AI public override bool PreAI(Projectile projectile) { + //Light Pets will add light to the abyss darkness. + //This uses local player on purpose, as the abyss darkness system is entirely client side. + if (ProjectileID.Sets.LightPet[projectile.type] && Main.LocalPlayer.Calamity().ZoneAbyss) + EnhancedDarknessSystem.lights.Add(new() { center = projectile.Center, scale = 1 }); + + if (projectile.bobber && projectile.type != ProjectileType() && RunFishingMinigames(projectile)) + return false; + //Reset the Homing Target immediately before AI can re-set it on applicable projectiles + HomingTarget = -1; #region Vanilla Summons AI Changes - // - // MINION AI CHANGES: - // + // + // MINION AI CHANGES: + // - // Hornet Staff's minion changes. + // Hornet Staff's minion changes. if (projectile.type == ProjectileID.Hornet) return HornetMinionAI.DoHornetMinionAI(projectile); @@ -369,12 +457,6 @@ namespace CalamityMod.Projectiles #endregion - if (!Main.player[projectile.owner].ActiveItem().IsAir && !Main.player[projectile.owner].ActiveItem().Calamity().canFirePointBlankShots) - pointBlankShotDuration = 0; - - if (pointBlankShotDuration > 0) - pointBlankShotDuration--; - // Reduce secondary yoyo damage if the player has Yoyo Glove // Brief behavior documentation of yoyo AI: ai[0, 1] are the x, y co-ords and localAI[0] is the airtime in frames // All secondary yoyos are spawned with ai[0] of 1 which tells then tell its AI to do secondary yoyo AI @@ -414,10 +496,6 @@ namespace CalamityMod.Projectiles projectile.Kill(); } - // Chlorophyte Crystal AI rework. - if (projectile.type == ProjectileID.CrystalLeaf) - return ChlorophyteCrystalAI.DoChlorophyteCrystalAI(projectile); - if (projectile.minion && ExplosiveEnchantCountdown > 0) { ExplosiveEnchantCountdown--; @@ -428,7 +506,7 @@ namespace CalamityMod.Projectiles if (Main.rand.NextBool(24)) SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, projectile.Center); - Dust fire = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(projectile.width, projectile.height) * 0.42f, 267); + Dust fire = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(projectile.width, projectile.height) * 0.42f, DustID.RainbowMk2); fire.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0.45f, 1f)); fire.scale = Main.rand.NextFloat(1.4f, 1.65f); fire.fadeIn = 0.5f; @@ -479,10 +557,10 @@ namespace CalamityMod.Projectiles // Accelerate if fired in a spread from Skeletron in Rev+ if (revSkeletronAcceleratingSkull) { - float maxVelocity = (Main.masterMode || BossRushEvent.BossRushActive) ? 20f : CalamityWorld.death ? 18f : 15f; + float maxVelocity = CalamityWorld.death ? 18f : 15f; if (projectile.velocity.Length() < maxVelocity) { - float acceleration = (Main.masterMode || BossRushEvent.BossRushActive) ? 1.02f : 1.015f; + float acceleration = 1.015f; projectile.velocity *= acceleration; if (projectile.velocity.Length() > maxVelocity) { @@ -521,7 +599,7 @@ namespace CalamityMod.Projectiles num133 = Player.FindClosest(projectile.Center, 1, 1); projectile.ai[1] += 1f; float homingStartTime = revSkeletronPrimeHomingSkull ? 10f : 30f; - float homingEndTime = (Main.masterMode || BossRushEvent.BossRushActive) ? 120f : CalamityWorld.death ? 105f : 90f; + float homingEndTime = CalamityWorld.death ? 105f : 90f; if (revSkeletronPrimeHomingSkull) homingEndTime += 60f; @@ -542,7 +620,7 @@ namespace CalamityMod.Projectiles } float maxVelocity = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 18f : 15f; - float acceleration = (Main.masterMode || BossRushEvent.BossRushActive) ? 1.02f : 1.015f; + float acceleration = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 1.02f : 1.015f; if (projectile.velocity.Length() < maxVelocity) projectile.velocity *= acceleration; @@ -695,11 +773,6 @@ namespace CalamityMod.Projectiles { if (projectile.localAI[0] == 0f) { - if (Main.masterMode && !CalamityPlayer.areThereAnyDamnBosses) - projectile.damage = (int)Math.Round(projectile.damage * CalamityGlobalNPC.MasterModeEnemyDamageMultiplier); - if (!CalamityPlayer.areThereAnyDamnBosses) - projectile.damage = (int)Math.Round(projectile.damage * 0.65); - SoundEngine.PlaySound(SoundID.Item17, projectile.Center); projectile.localAI[0] = 1f; for (int i = 0; i < 8; i++) @@ -728,11 +801,6 @@ namespace CalamityMod.Projectiles { if (projectile.localAI[0] == 0f) { - if (Main.masterMode && !CalamityPlayer.areThereAnyDamnBosses) - projectile.damage = (int)Math.Round(projectile.damage * CalamityGlobalNPC.MasterModeEnemyDamageMultiplier); - if (!CalamityPlayer.areThereAnyDamnBosses) - projectile.damage = (int)Math.Round(projectile.damage * 0.65); - SoundEngine.PlaySound(SoundID.Item171, projectile.Center); projectile.localAI[0] = 1f; for (int i = 0; i < 8; i++) @@ -1012,119 +1080,16 @@ namespace CalamityMod.Projectiles } } - else if (projectile.type == ProjectileID.Sharknado) - { - projectile.damage = projectile.GetProjectileDamage(NPCID.DukeFishron); - - int num535 = 10; - int num536 = 15; - float num537 = 1f; - int num538 = 150; - int num539 = 42; - - if (projectile.velocity.X != 0f) - projectile.direction = (projectile.spriteDirection = -Math.Sign(projectile.velocity.X)); - - projectile.frameCounter++; - if (projectile.frameCounter > 2) - { - projectile.frame++; - projectile.frameCounter = 0; - } - - if (projectile.frame >= 6) - projectile.frame = 0; - - if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner) - { - projectile.localAI[0] = 1f; - projectile.position.X += projectile.width / 2; - projectile.position.Y += projectile.height / 2; - projectile.scale = ((float)(num535 + num536) - projectile.ai[1]) * num537 / (float)(num536 + num535); - projectile.width = (int)((float)num538 * projectile.scale); - projectile.height = (int)((float)num539 * projectile.scale); - projectile.position.X -= projectile.width / 2; - projectile.position.Y -= projectile.height / 2; - projectile.netUpdate = true; - } - - if (projectile.ai[1] != -1f) - { - projectile.scale = ((float)(num535 + num536) - projectile.ai[1]) * num537 / (float)(num536 + num535); - projectile.width = (int)((float)num538 * projectile.scale); - projectile.height = (int)((float)num539 * projectile.scale); - } - - int maxAlpha = 150; - int minAlpha = 60; - if (projectile.timeLeft > FishronSharknadoTotalDuration - FishronTornadoTimeBeforeDealingDamage) - { - maxAlpha = 220; - minAlpha = 180; - } - - if (!Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.alpha -= 30; - if (projectile.alpha < minAlpha) - projectile.alpha = minAlpha; - } - else - { - projectile.alpha += 30; - if (projectile.alpha > maxAlpha) - projectile.alpha = maxAlpha; - } - - if (projectile.ai[0] > 0f) - projectile.ai[0]--; - - if (projectile.ai[0] == 1f && projectile.ai[1] > 0f && projectile.owner == Main.myPlayer) - { - projectile.netUpdate = true; - Vector2 center4 = projectile.Center; - center4.Y -= (float)num539 * projectile.scale / 2f; - float num540 = ((float)(num535 + num536) - projectile.ai[1] + 1f) * num537 / (float)(num536 + num535); - center4.Y -= (float)num539 * num540 / 2f; - center4.Y += 2f; - Projectile.NewProjectile(projectile.GetSource_FromAI(), center4, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); - int num541 = 4; - - if ((int)projectile.ai[1] % num541 == 0 && projectile.ai[1] != 0f) - { - int num542 = NPCID.Sharkron; - int num543 = NPC.NewNPC(projectile.GetSource_FromAI(), (int)center4.X, (int)center4.Y, num542); - Main.npc[num543].velocity = projectile.velocity; - Main.npc[num543].netUpdate = true; - } - } - - if (projectile.ai[0] <= 0f) - { - float num544 = MathHelper.Pi / 30f; - float num545 = (float)projectile.width / 5f; - float num546 = (float)(Math.Cos(num544 * (0f - projectile.ai[0])) - 0.5) * num545; - projectile.position.X -= num546 * (float)(-projectile.direction); - projectile.ai[0]--; - num546 = (float)(Math.Cos(num544 * (0f - projectile.ai[0])) - 0.5) * num545; - projectile.position.X += num546 * (float)(-projectile.direction); - } - - return false; - } - // Larger cthulhunadoes else if (projectile.type == ProjectileID.Cthulunado) { - projectile.damage = projectile.GetProjectileDamage(NPCID.DukeFishron); - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; int num606 = 16; int num607 = 16; - float segmentScale = masterMode ? 2.5f : 2f; + float segmentScale = death ? 2.5f : 2f; int segmentWidth = 150; int segmentHeight = 42; @@ -1200,12 +1165,12 @@ namespace CalamityMod.Projectiles float segmentSpawnDelay = 10f; Projectile.NewProjectile(projectile.GetSource_FromThis(), center, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, segmentSpawnDelay, projectile.ai[1] - 1f); - int sharkronSpawnGateValue = masterMode ? 2 : 3; + int sharkronSpawnGateValue = death ? 2 : 3; if ((int)projectile.ai[1] % sharkronSpawnGateValue == 0 && projectile.ai[1] != 0f) { int sharkron = NPC.NewNPC(projectile.GetSource_FromAI(), (int)center.X, (int)center.Y, NPCID.Sharkron2); Main.npc[sharkron].velocity = projectile.velocity; - Main.npc[sharkron].scale = masterMode ? 2f : 1.5f; + Main.npc[sharkron].scale = 1.5f; Main.npc[sharkron].netUpdate = true; Main.npc[sharkron].ai[2] = projectile.width; Main.npc[sharkron].ai[3] = -1.5f; @@ -1537,7 +1502,7 @@ namespace CalamityMod.Projectiles { float x2 = projectile.position.X - projectile.velocity.X / (float)totalDust * (float)i; float y2 = projectile.position.Y - projectile.velocity.Y / (float)totalDust * (float)i; - int dust = Dust.NewDust(new Vector2(x2, y2), 1, 1, 75); + int dust = Dust.NewDust(new Vector2(x2, y2), 1, 1, DustID.CursedTorch); Main.dust[dust].alpha = projectile.alpha; Main.dust[dust].position.X = x2; Main.dust[dust].position.Y = y2; @@ -1763,7 +1728,7 @@ namespace CalamityMod.Projectiles int maxHealAmount = 20; // If the target has more than 250 max life, incorporate their total life into the max amount to heal. - // This is done so that more powerful NPCs, such as Cirrus, do not take an eternity to receive meaningful healing benefits + // This is done so that more powerful NPCs do not take an eternity to receive meaningful healing benefits // from the Nurse. if (npcToHeal.lifeMax > 250) maxHealAmount = (int)Math.Max(maxHealAmount, npcToHeal.lifeMax * 0.05f); @@ -2081,7 +2046,6 @@ namespace CalamityMod.Projectiles if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; if (projectile.type == ProjectileID.DeerclopsIceSpike) @@ -2090,9 +2054,9 @@ namespace CalamityMod.Projectiles float dustVelocityMultiplier = 0.75f; int numDust = 5; int numDust2 = 5; - int fadeInTime = 10; - int fadeOutGateValue = masterMode ? 80 : death ? 50 : 25; - float killGateValue = masterMode ? 90f : death ? 60f : 35f; + int fadeInTime = 25; + int fadeOutGateValue = death ? 90 : 65; + float killGateValue = death ? 100f : 75f; int maxFrames = 5; bool fadeIn = projectile.ai[0] < (float)fadeInTime; @@ -2125,7 +2089,7 @@ namespace CalamityMod.Projectiles if (fadeIn) { - projectile.Opacity += 0.1f; + projectile.Opacity += 0.04f; if (projectile.Opacity > 1f) projectile.Opacity = 1f; @@ -2155,14 +2119,14 @@ namespace CalamityMod.Projectiles projectile.rotation = projectile.velocity.ToRotation(); for (int dustIndex = 0; dustIndex < 5; dustIndex++) { - Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), 16, projectile.velocity * MathHelper.Lerp(0.2f, 0.7f, Main.rand.NextFloat())); + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), DustID.Cloud, projectile.velocity * MathHelper.Lerp(0.2f, 0.7f, Main.rand.NextFloat())); dust.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f); dust.scale = 0.8f + Main.rand.NextFloat() * 0.5f; } for (int dustIndex = 0; dustIndex < 5; dustIndex++) { - Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), 16, Main.rand.NextVector2Circular(2f, 2f) + projectile.velocity * MathHelper.Lerp(0.2f, 0.5f, Main.rand.NextFloat())); + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(24f, 24f), DustID.Cloud, Main.rand.NextVector2Circular(2f, 2f) + projectile.velocity * MathHelper.Lerp(0.2f, 0.5f, Main.rand.NextFloat())); dust.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f); dust.scale = 0.8f + Main.rand.NextFloat() * 0.5f; dust.fadeIn = 1f; @@ -2184,7 +2148,7 @@ namespace CalamityMod.Projectiles if (projectile.ai[0] == projectile.ai[2]) { projectile.velocity *= 100f; - projectile.velocity *= (masterMode ? 20f : death ? 16f : 12f) + Main.rand.NextFloat() * 2f; + projectile.velocity *= (death ? 16f : 12f) + Main.rand.NextFloat() * 2f; } } else @@ -2263,7 +2227,7 @@ namespace CalamityMod.Projectiles if (projectile.velocity.Y > 16f) projectile.velocity.Y = 16f; - if (CalamityWorld.LegendaryMode && projectile.velocity.Length() > 4f) + if (Main.getGoodWorld && projectile.velocity.Length() > 4f) projectile.velocity *= 0.985f; return false; @@ -2311,126 +2275,17 @@ namespace CalamityMod.Projectiles } } - else if (projectile.type == ProjectileID.BombSkeletronPrime && projectile.ai[0] < 0f && masterMode) - { - int num = (int)(projectile.Center.X / 16f); - int num2 = (int)(projectile.Center.Y / 16f); - if (WorldGen.InWorld(num, num2) && projectile.tileCollide) - { - Tile tile = Main.tile[num, num2]; - if (tile != null && tile.HasTile && (TileID.Sets.Platforms[tile.TileType] || tile.TileType == TileID.PlanterBox)) - { - projectile.Kill(); - return false; - } - } - - bool masterModeSkeletronPrimeHomingBomb = projectile.ai[0] == -1f; - bool masterModeSkeletronPrimeFallingBomb = projectile.ai[0] == -2f; - - int target = 0; - target = Player.FindClosest(projectile.Center, 1, 1); - - if (projectile.Hitbox.Intersects(Main.player[target].Hitbox)) - { - projectile.Kill(); - return false; - } - - if (projectile.timeLeft < SkeletronPrime2.BombTimeLeft / 2 && projectile.timeLeft > 3) - projectile.tileCollide = true; - - if (masterModeSkeletronPrimeHomingBomb) - { - projectile.ai[1] += 1f; - float homingStartTime = 20f; - float homingEndTime = death ? 140f : 110f; - - if (Vector2.Distance(projectile.Center, Main.player[target].Center) < 192f && projectile.ai[1] < homingEndTime) - projectile.ai[1] = homingEndTime; - - if (projectile.ai[1] < homingEndTime && projectile.ai[1] > homingStartTime) - { - float num134 = projectile.velocity.Length(); - Vector2 vector24 = Main.player[target].Center - projectile.Center; - vector24.Normalize(); - vector24 *= num134; - float inertia = death ? 25f : 30f; - projectile.velocity = (projectile.velocity * (inertia - 1f) + vector24) / inertia; - projectile.velocity.Normalize(); - projectile.velocity *= num134; - } - - float maxVelocity = death ? 18f : 15f; - float acceleration = 1.02f; - if (projectile.velocity.Length() < maxVelocity) - projectile.velocity *= acceleration; - } - else - { - if (projectile.velocity.Y > 10f) - projectile.velocity.Y = 10f; - } - - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - SoundEngine.PlaySound(SoundID.Item10, projectile.Center); - } - - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - - if (projectile.frame > 1) - projectile.frame = 0; - - if (projectile.owner == Main.myPlayer && projectile.timeLeft <= 3) - { - projectile.tileCollide = false; - projectile.ai[2] = 0f; - projectile.alpha = 255; - } - else if (Main.rand.NextBool()) - { - int num28 = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100); - Main.dust[num28].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num28].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num28].noGravity = true; - Main.dust[num28].position = projectile.Center + new Vector2(0f, -projectile.height / 2).RotatedBy(projectile.rotation) * 1.1f; - int num29 = 6; - Dust dust8 = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, num29, 0f, 0f, 100); - dust8.scale = 1f + (float)Main.rand.Next(5) * 0.1f; - dust8.noGravity = true; - dust8.position = projectile.Center + new Vector2(0f, -projectile.height / 2 - 6).RotatedBy(projectile.rotation) * 1.1f; - } - - if (masterModeSkeletronPrimeFallingBomb) - { - projectile.ai[2] += 1f; - if (projectile.ai[2] > 60f) - projectile.velocity.Y += 0.2f; - } - - projectile.rotation += projectile.velocity.X * 0.1f; - - return false; - } - else if (projectile.type == ProjectileID.RocketSkeleton && projectile.ai[1] >= 1f) { bool primeCannonProjectile = projectile.ai[1] == 2f; bool homeIn = false; - float homingTime = masterMode ? 80f : 140f; + float homingTime = 140f; float spreadOutCutoffTime = 510f; float homeInCutoffTime = spreadOutCutoffTime - homingTime; - float minAcceleration = masterMode ? 0.072f : 0.08f; - float maxAcceleration = masterMode ? 0.108f : 0.12f; - float homingVelocity = masterMode ? 22.5f : 25f; - float maxVelocity = masterMode ? 13.5f : 15f; + float minAcceleration = 0.08f; + float maxAcceleration = 0.12f; + float homingVelocity = 25f; + float maxVelocity = 15f; if (!primeCannonProjectile) { @@ -2459,7 +2314,7 @@ namespace CalamityMod.Projectiles projectile.velocity = Vector2.SmoothStep(projectile.velocity, velocity, amount); // Stop homing when within a certain distance of the target - if (Vector2.Distance(projectile.Center, Main.player[playerIndex].Center) < (masterMode ? 192f : 96f) && projectile.timeLeft > homeInCutoffTime) + if (Vector2.Distance(projectile.Center, Main.player[playerIndex].Center) < 96f && projectile.timeLeft > homeInCutoffTime) projectile.timeLeft = (int)homeInCutoffTime; } @@ -2537,7 +2392,7 @@ namespace CalamityMod.Projectiles projectile.alpha = 0; projectile.ai[0] += 1f; - if (projectile.ai[0] >= (masterMode ? 60f : 120f)) + if (projectile.ai[0] >= 120f) { if (projectile.velocity.Length() < 18f) projectile.velocity *= 1.01f; @@ -2575,7 +2430,7 @@ namespace CalamityMod.Projectiles { if (projectile.owner == Main.myPlayer) { - int totalProjectiles = masterMode ? 12 : 8; + int totalProjectiles = death ? 12 : 8; float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileType(); float velocity = 1f; @@ -2583,7 +2438,7 @@ namespace CalamityMod.Projectiles for (int k = 0; k < totalProjectiles; k++) { Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center + Vector2.Normalize(velocity2) * 16f, velocity2, type, (int)Math.Round(projectile.damage * 0.8), 0f, Main.myPlayer); + Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center + Vector2.Normalize(velocity2) * 16f, velocity2, type, PlanteraAI.ThornBallSpikeDamage, 0f, Main.myPlayer); } } @@ -2616,9 +2471,9 @@ namespace CalamityMod.Projectiles else { int closestPlayer = Player.FindClosest(projectile.Center, 1, 1); - float homingSpeed = (masterMode ? 9f : 7.5f) + Vector2.Distance(Main.player[closestPlayer].Center, projectile.Center) * 0.01f; + float homingSpeed = 7.5f + Vector2.Distance(Main.player[closestPlayer].Center, projectile.Center) * 0.01f; Vector2 homingVelocity = Vector2.Normalize(Main.player[closestPlayer].Center - projectile.Center) * homingSpeed; - int inertia = masterMode ? 150 : 200; + int inertia = 200; projectile.velocity.X = (projectile.velocity.X * (inertia - 1) + homingVelocity.X) / inertia; if (projectile.velocity.Length() > 16f) @@ -2640,110 +2495,6 @@ namespace CalamityMod.Projectiles return false; } - else if (projectile.type == ProjectileID.InfernoHostileBolt && projectile.ai[2] > 0f) - { - if (projectile.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item20, projectile.position); - projectile.localAI[0] += 1f; - } - - bool killX = false; - bool killY = false; - if (projectile.velocity.X < 0f && projectile.position.X < projectile.ai[0]) - killX = true; - - if (projectile.velocity.X > 0f && projectile.position.X > projectile.ai[0]) - killX = true; - - if (projectile.velocity.Y < 0f && projectile.position.Y < projectile.ai[1]) - killY = true; - - if (projectile.velocity.Y > 0f && projectile.position.Y > projectile.ai[1]) - killY = true; - - if (killX && killY) - projectile.Kill(); - - for (int i = 0; i < 10; i++) - { - int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.IchorTorch, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1.6f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.3f; - Main.dust[dust].velocity += projectile.velocity * 0.1f; - if (Main.getGoodWorld) - Main.dust[dust].noLight = true; - } - - Particle theSpark = new AltSparkParticle(projectile.Center, projectile.velocity * 0.06f + projectile.velocity * 0.1f, false, 40, 1f, new Color(255, 255, 100)); - GeneralParticleHandler.SpawnParticle(theSpark); - - return false; - } - - else if (projectile.type == ProjectileID.InfernoHostileBlast && projectile.ai[2] > 0f) - { - if (projectile.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item74, projectile.position); - projectile.localAI[0] += 1f; - } - - projectile.ai[0] += 1f; - - float totalDust = 20f; - if (projectile.ai[0] > 540f) - totalDust -= (projectile.ai[0] - 180f) / 2f; - - if (totalDust <= 0f) - { - totalDust = 0f; - projectile.Kill(); - } - - float maxDustVelocityX = 10f; - float maxDustVelocityY = 10f; - float minDustSpeed = 3f; - float maxDustSpeed = 8f; - - for (int i = 0; i < (int)totalDust; i++) - { - float dustVelocityX = Main.rand.NextFloat(-maxDustVelocityX, maxDustVelocityX); - float dustVelocityY = Main.rand.NextFloat(-maxDustVelocityY, maxDustVelocityY); - float randomDustSpeed = Main.rand.NextFloat(minDustSpeed, maxDustSpeed); - float velocityLength = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - velocityLength = randomDustSpeed / velocityLength; - dustVelocityX *= velocityLength; - dustVelocityY *= velocityLength; - Vector2 dustVelocity = new Vector2(dustVelocityX, dustVelocityY); - Vector2 dustPosition = projectile.Center + new Vector2(Main.rand.NextFloat(-10f, 10f), Main.rand.NextFloat(-10f, 10f)); - int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.IchorTorch, 0f, 0f, 100, default, 1.8f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position = dustPosition; - Main.dust[dust].velocity = dustVelocity; - if (Main.getGoodWorld) - Main.dust[dust].noLight = true; - } - - float maxSparkVelocityX = 10f; - float maxSparkVelocityY = 10f; - float minSparkSpeed = 3f; - float maxSparkSpeed = 7f; - - float sparkVelocityX = Main.rand.NextFloat(-maxSparkVelocityX, maxSparkVelocityX); - float sparkVelocityY = Main.rand.NextFloat(-maxSparkVelocityY, maxSparkVelocityY); - float randSparkSpeed = Main.rand.NextFloat(minSparkSpeed, maxSparkSpeed); - float sparkLength = (float)Math.Sqrt(sparkVelocityX * sparkVelocityX + sparkVelocityY * sparkVelocityY); - sparkLength = randSparkSpeed / sparkLength; - sparkVelocityX *= sparkLength; - sparkVelocityY *= sparkLength; - - Particle theSpark = new AltSparkParticle(projectile.Center, new Vector2(sparkVelocityX, sparkVelocityY), false, 40, 1f, new Color(255, 255, 100)); - GeneralParticleHandler.SpawnParticle(theSpark); - - return false; - } - else if (projectile.type == ProjectileID.AncientDoomProjectile) { if (projectile.velocity.Length() < 6f) @@ -2784,42 +2535,16 @@ namespace CalamityMod.Projectiles Vector2 vector11 = Main.player[num103].Center - projectile.Center; float scaleFactor2 = projectile.velocity.Length(); vector11.Normalize(); + if (vector11.HasNaNs()) + vector11 = Vector2.Zero; vector11 *= scaleFactor2; projectile.velocity = (projectile.velocity * 20f + vector11) / 21f; projectile.velocity.Normalize(); projectile.velocity *= scaleFactor2; + projectile.velocity *= 0.99f; - // Fly away from other Ice Mists in Master - if (masterMode) - { - float pushForce = 0.06f; - float pushDistance = 120f; - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || k == projectile.whoAmI) - continue; - - // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away - bool sameProjType = otherProj.type == projectile.type; - float taxicabDist = Vector2.Distance(projectile.Center, otherProj.Center); - if (sameProjType && taxicabDist < pushDistance) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X -= pushForce; - else - projectile.velocity.X += pushForce; - - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y -= pushForce; - else - projectile.velocity.Y += pushForce; - } - } - } - - if (projectile.ai[0] % (masterMode ? 30f : 60f) == 0f && Main.netMode != NetmodeID.MultiplayerClient) + + if (projectile.ai[0] % (death ? 20f : 30f) == 0f && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector50 = projectile.rotation.ToRotationVector2(); Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, vector50, projectile.type, projectile.damage, projectile.knockBack, projectile.owner); @@ -2971,7 +2696,7 @@ namespace CalamityMod.Projectiles return false; } - float velocityLimit = (death ? 28f : 24f) / MathHelper.Clamp(lineColor * 0.75f, 1f, 3f); + float velocityLimit = (death ? 28f : 24f) / MathHelper.Clamp(projectile.ai[2] * 0.75f, 1f, 3f); if (projectile.velocity.Length() < velocityLimit) projectile.velocity *= 1.01f; } @@ -3163,6 +2888,779 @@ namespace CalamityMod.Projectiles } #endregion + #region Fishing Minigames + // All these fields are exclusively used for fishing minigames, so I declared them in this region for organization + /// + /// Reel state of bobber.
+ /// ai[0] in bobber AI. + ///
+ private float isReelingIn = 0; + /// + /// How long you have to catch a fish when bitten.
+ /// ai[1] in bobber AI. + ///
+ private float CatchTime = 0; + /// + /// How long until a fish bites.
+ /// LocalAI[1] in bobber AI. + ///
+ private float TimerToCatch = 0; + /// Item ID of hooked item for fishing minigames. + public int CaughtItemID = -1; + /// What this does depends on the fishing minigame. Used to store data between updates. + public float PersistentFishingData = -1; + /// + public Vector2 PersistentFishingDataVector2 = Vector2.Zero; + public bool RunFishingMinigames(Projectile projectile) + { + var owner = Main.player[projectile.owner]; + var cplayer = owner.Calamity(); + + //Make sure Victide Snail actually fishes when using a minigame rod + foreach (var item in Main.ActiveProjectiles) + { + if (item.type == ProjectileType() && item.owner == projectile.owner) + item.ModProjectile().PlayerFishingTimer = 600; + } + #region Utilities + void SmallSplashAtOffset(Vector2 offset) + { + int num = Dust.NewDust(new Vector2(projectile.position.X - 6f, projectile.position.Y - 10f) + offset, projectile.width + 12, 24, Dust.dustWater()); + Main.dust[num].velocity.Y -= 4f; + Main.dust[num].velocity.X *= 2.5f; + Main.dust[num].scale = 0.8f; + Main.dust[num].alpha = 100; + Main.dust[num].noGravity = true; + } + void SmallDustAtOffset(Vector2 offset, int dustID) + { + int num = Dust.NewDust(new Vector2(projectile.position.X - 6f, projectile.position.Y - 10f) + offset, projectile.width + 12, 24, dustID); + Main.dust[num].velocity.Y -= 4f; + Main.dust[num].velocity.X *= 2.5f; + Main.dust[num].scale = 0.8f; + Main.dust[num].alpha = 100; + Main.dust[num].noGravity = true; + } + void Splash() + { + for (int i = 0; i < 100; i++) + { + int num = Dust.NewDust(new Vector2(projectile.position.X - 6f, projectile.position.Y - 10f), projectile.width + 12, 24, Dust.dustWater()); + Main.dust[num].velocity.Y -= 4f; + Main.dust[num].velocity.X *= 2.5f; + Main.dust[num].scale = 0.8f; + Main.dust[num].alpha = 100; + Main.dust[num].noGravity = true; + } + + SoundEngine.PlaySound(SoundID.SplashWeak, projectile.Center); + } + void ReelTheBobberChecks() + { + if (projectile.localAI[1] == 1) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.SpawnOnPlayer(owner.whoAmI, 370); + } + projectile.ai[0] = 2f; + } + else if (projectile.localAI[1] < 1) + { + Point point = default(Point); + point = new Point((int)projectile.position.X, (int)projectile.position.Y); + int num = (int)(0f - projectile.localAI[1]); + if (num == 618) + { + point.Y += 64; + } + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.FishOutNPC, -1, -1, null, point.X / 16, point.Y / 16, num); + } + else + { + if (num == 682) + { + NPC.unlockedSlimeRedSpawn = true; + } + NPC.NewNPC(new EntitySource_FishedOut(owner), point.X, point.Y, num); + projectile.ai[0] = 2f; + WorldGen.CheckAchievement_RealEstateAndTownSlimes(); + } + } + else if (Main.rand.NextBool(7) && !owner.accFishingLine) + { + projectile.ai[0] = 2f; + projectile.ai[1] = 0; + projectile.localAI[1] = 0; + } + else + { + projectile.ai[1] = projectile.localAI[1]; + } + projectile.netUpdate = true; + } + + Vector2 GetWaterLine() + { + Vector2 FoundWaterline = projectile.Center; + var tilePos = projectile.Center.ToTileCoordinates(); + if (Main.tile[tilePos.X, tilePos.Y].LiquidAmount > 0) + { + for (var i = 0; i < 1000; i++) + { + if (i <= 0 || i >= Main.maxTilesY || Main.tile[tilePos.X, tilePos.Y - i].LiquidAmount > 0) + continue; + FoundWaterline.Y = (tilePos.Y - i + 1) * 16f; + FoundWaterline.Y += (1 - Main.tile[tilePos.X, tilePos.Y - i + 1].LiquidAmount / 255f) * 16f; + break; + } + } + else + { + for (var i = 0; i < 1000; i++) + { + if (i <= 0 || i >= Main.maxTilesY || Main.tile[tilePos.X, tilePos.Y + i].LiquidAmount == 0) + continue; + FoundWaterline.Y = (tilePos.Y + i) * 16f; + FoundWaterline.Y += (1 - Main.tile[tilePos.X, tilePos.Y + i].LiquidAmount / 255f) * 16f; + break; + } + } + return FoundWaterline; + } + #endregion + //Doze's notes on bobber AI + + //ai[0] - Bobber state. 0: thrown/idle/bitten, 1: reeling in, 2: snapped + //ai[1] - Amount of time to reel in the bobber once a bite happens. Is negative and counts up + //When reeled in, this becomes the value of localAI[1] (ID of item/NPC) + //At 0, the bobber is just floating waiting for a bite + //localAI[1] - The timer for fish to try and bite the hook. When it exceeds 660, it resets to 0. + //If ai[1] is not 0, this is set to the item ID of the hooked item/NPC + //If hooking an NPC, this is set to the NPC ID but negative. Still need to find how this gets treated upon reeling in. + switch (owner.Calamity().SelectedFishingMinigame) + { + case CalamityPlayer.FishingMinigames.ScrapBobber: + { + if (CatchTime < 0 || (isReelingIn == 1 && CaughtItemID > 0)) + { + owner.Calamity().ShouldHideControls = true; + } + if (isReelingIn != projectile.ai[0]) + return false; + + if (CatchTime < 0) + CatchTime++; + if (projectile.wet || (projectile.lavaWet && owner.accLavaFishing) || projectile.honeyWet) + TimerToCatch++; + var speedup = Math.Min(owner.Calamity().consecutiveCaughtFish * 5, 25); + var totalTime = 60 - speedup; + if (TimerToCatch + 90 >= 160 - owner.HeldItem.fishingPole && CatchTime >= 0) + { + // TODO: Implications of rand here? + if (PersistentFishingData == 0) + PersistentFishingData = Main.rand.NextBool() ? 1 : -1; + var timer = TimerToCatch - 160 - owner.HeldItem.fishingPole; + + // TODO: Fine for others to see? + SmallSplashAtOffset(new Vector2(200 * PersistentFishingData * (timer / 90f), 0)); + } + if (TimerToCatch >= 160 - owner.HeldItem.fishingPole && CatchTime >= 0) + { + PersistentFishingData = 0; + projectile.FishingCheck(); + if (projectile.ai[1] < 0) + { + CatchTime = -totalTime * 4; + CaughtItemID = (int)projectile.localAI[1]; + } + TimerToCatch = 0; + } + if (CatchTime < 0 && CatchTime % totalTime == 0) + { + // TODO: Fine for others to see? + Splash(); + // TODO: Implications of rand here? + PersistentFishingData = Main.rand.Next(0, 4); + + if (owner.whoAmI == Main.myPlayer) + { + var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(PersistentFishingData * MathHelper.PiOver2) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 45 - speedup, 0.04f, Color.Blue, new(1, 2), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(particle); + } + } + if (CatchTime < 0 && CatchTime % totalTime == -15) + { + var playerDir = -1; + if (owner.Calamity().pressedUp) + { + playerDir = 3; + } + if (owner.Calamity().pressedLeft) + { + playerDir = 2; + } + if (owner.Calamity().pressedDown) + { + playerDir = 1; + } + if (owner.Calamity().pressedRight) + { + playerDir = 0; + } + if (playerDir == PersistentFishingData) + { + + } + else + { + if (owner.whoAmI == Main.myPlayer) + { + if (playerDir >= 0) + { + var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(playerDir * MathHelper.PiOver2) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 15, 0.04f, Color.Red, new(1, 2), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(particle); + } + else + { + var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 15, 0.06f, Color.Red, Vector2.One); + GeneralParticleHandler.SpawnParticle(particle); + } + } + TimerToCatch = 0; + CatchTime = 0; + CaughtItemID = -1; + PersistentFishingData = 0; + owner.Calamity().consecutiveCaughtFish = 0; + } + } + if (CatchTime == -1) + { + projectile.localAI[1] = CaughtItemID; + ReelTheBobberChecks(); + owner.Calamity().consecutiveCaughtFish++; + if (projectile.ai[0] == 2) + return false; + isReelingIn = 1; + CatchTime = (float)CaughtItemID; + TimerToCatch = 0; + } + if (projectile.ai[0] == 0) + { + projectile.ai[1] = CatchTime; + projectile.localAI[1] = TimerToCatch; + if (CaughtItemID != -1 && isReelingIn == 0) + { + projectile.localAI[1] = 0; + projectile.ai[1] = 0; + } + projectile.ai[0] = isReelingIn; + } + return false; + } + + + case CalamityPlayer.FishingMinigames.ScoriaBobber: + { + if (PersistentFishingData == -1) + { + PersistentFishingData = 1; + TimerToCatch = 300; + } + var Waterline = GetWaterLine(); + if (Waterline.Y >= projectile.Center.Y) + { + TimerToCatch = 300; + projectile.velocity.Y += 0.4f; + } + else if (projectile.ai[0] == 0) + { + owner.Calamity().ShouldHideControls = true; + if (owner.Calamity().pressedUp) + { + projectile.velocity.Y -= 0.125f; + projectile.netUpdate = true; + } + + if (owner.Calamity().pressedDown) + { + projectile.velocity.Y += 0.125f; + projectile.netUpdate = true; + } + + if (owner.Calamity().pressedLeft) + { + projectile.velocity.X -= 0.125f; + projectile.netUpdate = true; + } + + if (owner.Calamity().pressedRight) + { + projectile.velocity.X += 0.125f; + projectile.netUpdate = true; + } + } + projectile.velocity *= 0.975f; + + if (Waterline.Y <= projectile.Center.Y && projectile.ai[0] == 0 && !(projectile.lavaWet && !owner.accLavaFishing)) + { + TimerToCatch -= Main.rand.Next(1, 5); + if (TimerToCatch <= 0) + { + projectile.FishingCheck(); + if (projectile.ai[1] < 0) + { + CaughtItemID = (int)projectile.localAI[1]; + projectile.ai[1] = 0; + projectile.localAI[1] = 0; + + if (owner.whoAmI == Main.myPlayer) + { + for (var i = 0; i < 1000; i++) + { + var vectorToCheck = projectile.Center + new Vector2(Main.rand.Next(-200, 201), Main.rand.Next(-200, 201)); + var tileCoordsToCheck = vectorToCheck.ToSafeTileCoordinates(); + if (new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight).Contains((int)vectorToCheck.X, (int)vectorToCheck.Y) && !Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].IsTileSolid() && Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].LiquidAmount > 0) + { + if (projectile.localAI[2] >= 1) + { + int customSonarText = (int)(projectile.localAI[2] - 1); + if (Main.popupText[customSonarText].sonar) + { + Main.popupText[customSonarText].position = vectorToCheck - FontAssets.MouseText.Value.MeasureString(Main.popupText[customSonarText].name) / 2f; + } + } + PersistentFishingDataVector2 = vectorToCheck; + TimerToCatch = 600; + break; + } + } + } + } + } + if (PersistentFishingDataVector2 != Vector2.Zero && owner.whoAmI == Main.myPlayer) + { + Dust.NewDustPerfect(PersistentFishingDataVector2, DustID.Smoke); + if (Main.rand.NextBool(3)) + { + Dust.NewDustPerfect(PersistentFishingDataVector2, DustID.Torch); + } + var particle = new HeavySmokeParticle(PersistentFishingDataVector2, Vector2.One.RotatedByRandom(6.28) * Main.rand.NextFloat(1f, 4f), Color.Lerp(Color.DarkOrange, Color.DarkGray, Main.rand.NextFloat()), 15, 0.2f, 1); + GeneralParticleHandler.SpawnParticle(particle); + } + + //When in lava, give the bobber a particle over it to show its location + if (projectile.lavaWet && owner.whoAmI == Main.myPlayer) + { + var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 2, 0.01f, Color.DarkGray, Vector2.One); + GeneralParticleHandler.SpawnParticle(particle); + } + List<(Vector2, int)> validRifts = new(); + + foreach (var item in Main.ActiveProjectiles) + { + if (item.bobber && projectile.type != ModContent.ProjectileType() && item.owner == projectile.owner && item.ai[0] == 0 && item.Calamity().PersistentFishingDataVector2 != Vector2.Zero) + { + validRifts.Add((item.Calamity().PersistentFishingDataVector2, item.whoAmI)); + } + } + foreach (var item in validRifts) + { + if (projectile.Distance(item.Item1) < 16) + { + projectile.localAI[1] = Main.projectile[item.Item2].Calamity().CaughtItemID; + ReelTheBobberChecks(); + if (projectile.ai[0] < 2) + projectile.ai[0] = 1; + Main.projectile[item.Item2].Calamity().PersistentFishingDataVector2 = PersistentFishingDataVector2; + Main.projectile[item.Item2].Calamity().CaughtItemID = CaughtItemID; + break; + } + + } + } + if (projectile.ai[0] == 0) + return true; + break; + } + + + case CalamityPlayer.FishingMinigames.PerennialBobber: + if (projectile.ai[0] == 0) + { + if (projectile.wet) //Fishing in water + { + + projectile.extraUpdates = 0; + if (cplayer.mouseRight && projectile.ai[1] == 0) + { + projectile.localAI[1] += 2; + owner.lifeRegenCount -= 60; // -0.5 health per tick + } + } + else //Attached to an enemy + { + if (PersistentFishingData >= 0 && Main.npc[(int)PersistentFishingData].active && projectile.Distance(Main.npc[(int)PersistentFishingData].Center + PersistentFishingDataVector2) < 128) + { + projectile.Center = Main.npc[(int)PersistentFishingData].Center + PersistentFishingDataVector2; + projectile.velocity = Vector2.Zero; + if (cplayer.mouseRight && projectile.ai[1] == 0 && owner.miscCounter % 10 == 0) + { + owner.lifeRegenCount -= 600; // -5 health per 10 ticks + var projID = Projectile.NewProjectile(projectile.GetSource_FromThis(), Main.npc[(int)PersistentFishingData].Center, Vector2.Zero, ModContent.ProjectileType(), (int)owner.GetBestClassDamage().ApplyTo(owner.HeldItem.fishingPole + owner.fishingSkill + owner.ChooseAmmo(owner.HeldItem).bait), 0f, owner.whoAmI, Main.npc[(int)PersistentFishingData].whoAmI); + if (Main.projectile.IndexInRange(projID)) + { + Main.projectile[projID].ArmorPenetration = 100; //This should ignore almost all armor + } + } + projectile.timeLeft++; + + projectile.extraUpdates = 0; + return true; + } + else if (PersistentFishingData >= 0) + { + PersistentFishingData = -1; + projectile.velocity.Y -= 3; + } + foreach (var item in Main.ActiveNPCs) + { + if (item.friendly || item.dontTakeDamage) + continue; + if (projectile.Colliding(projectile.Hitbox, item.Hitbox)) + { + PersistentFishingDataVector2 = projectile.Center - item.Center; + PersistentFishingData = item.whoAmI; + break; + } + } + if (PersistentFishingData == -1) + projectile.extraUpdates = 1; + else + projectile.extraUpdates = 0; + + } + } + else if (projectile.ai[0] == 1) + projectile.extraUpdates = 3; + break; + + + case CalamityPlayer.FishingMinigames.NavystoneBobber: + { + if (CatchTime < 0 || (isReelingIn == 1 && CaughtItemID > 0)) + { + owner.Calamity().ShouldHideControls = true; + } + if (isReelingIn != projectile.ai[0]) + return false; + var waterline = GetWaterLine(); + var AdjustedOwnerWaterline = waterline; + if (AdjustedOwnerWaterline.Y < owner.Center.Y) + AdjustedOwnerWaterline.Y = owner.Center.Y; + if (AdjustedOwnerWaterline.Y >= projectile.Center.Y) + { + projectile.velocity.Y += 0.4f; + } + else + { + projectile.velocity.Y -= 0.1f; + } + projectile.velocity *= 0.975f; + if (CatchTime < 0) + CatchTime++; + if (projectile.wet || (projectile.lavaWet && owner.accLavaFishing) || projectile.honeyWet) + TimerToCatch++; + var speedup = 15; + var totalTime = 60 - speedup; + if (TimerToCatch + 90 >= 300 && CatchTime >= 0) + { + if (PersistentFishingData == 0) + PersistentFishingData = Main.rand.NextBool() ? 1 : -1; + + if (owner.whoAmI == Main.myPlayer) + { + var timer = TimerToCatch - 300; + SmallSplashAtOffset(new Vector2(200 * PersistentFishingData * (timer / 90f), 0)); + SmallDustAtOffset(new Vector2(200 * PersistentFishingData * (timer / 90f), 0), DustID.BlueCrystalShard); + } + } + if (TimerToCatch >= 300 && CatchTime >= 0) + { + PersistentFishingData = 0; + projectile.FishingCheck(); + if (projectile.ai[1] < 0) + { + CatchTime = -totalTime * 4; + CaughtItemID = (int)projectile.localAI[1]; + } + TimerToCatch = 0; + } + if (CatchTime < 0 && CatchTime % totalTime == 0 && owner.whoAmI == Main.myPlayer) + { + Splash(); + PersistentFishingData = Main.rand.Next(0, 2); + var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(PersistentFishingData * MathHelper.Pi) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 45 - speedup, 0.04f, Color.Blue, new(1, 2), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(particle); + } + if (CatchTime < 0 && CatchTime % totalTime == -15) + { + var playerDir = -1; + if (owner.Calamity().pressedLeft) + { + playerDir = 1; + } + if (owner.Calamity().pressedRight) + { + playerDir = 0; + } + if (playerDir == PersistentFishingData) + { + + } + else + { + if (owner.whoAmI == Main.myPlayer) + { + if (playerDir >= 0) + { + var particle = new CustomSpark(projectile.Center, Vector2.UnitX.RotatedBy(playerDir * MathHelper.Pi) * 10, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 15, 0.04f, Color.Red, new(1, 2), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(particle); + } + else + { + var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 15, 0.06f, Color.Red, Vector2.One); + GeneralParticleHandler.SpawnParticle(particle); + } + } + TimerToCatch = 0; + CatchTime = 0; + CaughtItemID = -1; + PersistentFishingData = 0; + owner.Calamity().consecutiveCaughtFish = 0; + } + } + if (CatchTime == -1) + { + projectile.localAI[1] = CaughtItemID; + ReelTheBobberChecks(); + owner.Calamity().consecutiveCaughtFish++; + if (projectile.ai[0] == 2) + return false; + isReelingIn = 1; + CatchTime = (float)CaughtItemID; + TimerToCatch = 0; + } + if (projectile.ai[0] == 0) + { + + + projectile.ai[1] = CatchTime; + projectile.localAI[1] = TimerToCatch; + if (CaughtItemID != -1 && isReelingIn == 0) + { + projectile.localAI[1] = 0; + projectile.ai[1] = 0; + } + projectile.ai[0] = isReelingIn; + } + if (projectile.ai[0] == 0) + return true; + break; + } + + + case CalamityPlayer.FishingMinigames.DevourerofCods: //Technically not a fishing minigame, but the code is already all here + var fishToEat = TheDevourerofCods.FishToEat; + if (projectile.ai[1] < -1) + { + //Coonsuming a fish provides/increases the player's food buffs. + if (fishToEat.Contains((int)projectile.localAI[1])) + { + projectile.ai[1] = 0; + projectile.localAI[1] = 0; + SoundEngine.PlaySound(SoundID.Item2, projectile.Center); + //If the player doesn't have Ex. Stuffed, either give them Plenty Satisfied or inrease existing Plenty Satisfied duration + if (!owner.HasBuff(BuffID.WellFed3)) + { + + if (owner.HasBuff(BuffID.WellFed2)) + { + var bIndex = owner.FindBuffIndex(BuffID.WellFed2); + if (owner.buffTime[bIndex] < CalamityUtils.MinutesToFrames(24)) + { + owner.buffTime[bIndex] += 300; + } + } + else + { + + owner.AddBuff(BuffID.WellFed2, 300); + } + } + else //If the player DOES have Ex. Stuffed, increase the duration of it + { + var bIndex = owner.FindBuffIndex(BuffID.WellFed3); + if (owner.buffTime[bIndex] < CalamityUtils.MinutesToFrames(24)) //Requires fishing once per day if you'd like to keep free ExStuffed forever + { + owner.buffTime[bIndex] += 300; + } + } + } + else //If the hooked item isn't consumable, make it stay hooked forever. + { + projectile.ai[1] = -30; + } + } + + return false; + + + case CalamityPlayer.FishingMinigames.SkylineBobber: + { + if (CatchTime < 0 || (isReelingIn == 1 && CaughtItemID > 0)) + { + owner.Calamity().ShouldHideControls = true; + } + if (PersistentFishingData == -1) + { + PersistentFishingData = 1; + TimerToCatch = 300; + } + var Waterline = GetWaterLine(); + if (Waterline.Y >= projectile.Center.Y) + { + projectile.velocity.Y += 0.4f; + } + else if (projectile.ai[0] <= 0) + { + projectile.velocity.Y -= 0.1f; + } + if (projectile.ai[0] <= 1) + { + owner.Calamity().ShouldHideControls = true; + } + projectile.velocity *= 0.975f; + if (projectile.wet) + projectile.velocity *= 0.99f; + + //When in lava, give the bobber a particle over it to show its location + if (projectile.lavaWet && owner.whoAmI == Main.myPlayer) + { + var particle = new CustomSpark(projectile.Center, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 2, 0.01f, Color.DarkGray, Vector2.One); + GeneralParticleHandler.SpawnParticle(particle); + } + if (projectile.ai[0] == 0) + { + + if (owner.Calamity().pressedUp && projectile.velocity.Y < 0) + { + projectile.velocity.Y -= 0.3f; + projectile.netUpdate = true; + } + + if (owner.Calamity().pressedUp && Waterline.Y < projectile.Center.Y) + { + projectile.velocity.Y -= 0.3f; + projectile.netUpdate = true; + } + + if (owner.Calamity().pressedDown) + { + projectile.velocity.Y += 0.25f; + projectile.netUpdate = true; + } + + if (owner.Calamity().pressedLeft) + { + projectile.velocity.X -= 0.25f; + projectile.netUpdate = true; + } + + if (owner.Calamity().pressedRight) + { + projectile.velocity.X += 0.25f; + projectile.netUpdate = true; + } + + if (Waterline.Y <= projectile.Center.Y - 8) + TimerToCatch -= Main.rand.Next(1, 5); + if (TimerToCatch <= 0) + { + projectile.FishingCheck(); + if (projectile.ai[1] < 0 && !(projectile.lavaWet && !owner.accLavaFishing)) + { + + CaughtItemID = (int)projectile.localAI[1]; + projectile.ai[1] = 0; + projectile.localAI[1] = 0; + for (var i = 0; i < 1000; i++) + { + var vectorToCheck = Waterline + new Vector2(Main.rand.Next(-200, 201), Main.rand.Next(-200, 32)); + var tileCoordsToCheck = vectorToCheck.ToSafeTileCoordinates(); + if (new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight).Contains((int)vectorToCheck.X, (int)vectorToCheck.Y) && !Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].IsTileSolid() && Main.tile[tileCoordsToCheck.X, tileCoordsToCheck.Y].LiquidAmount == 0) + { + if (projectile.localAI[2] >= 1) + { + int customSonarText = (int)(projectile.localAI[2] - 1); + if (Main.popupText[customSonarText].sonar) + { + Main.popupText[customSonarText].position = vectorToCheck - FontAssets.MouseText.Value.MeasureString(Main.popupText[customSonarText].name) / 2f; + } + } + PersistentFishingDataVector2 = vectorToCheck; + TimerToCatch = 600; + break; + } + } + } + } + if (PersistentFishingDataVector2 != Vector2.Zero && owner.miscCounter % 15 == 0 && owner.whoAmI == Main.myPlayer) + { + + var particle = new CustomSpark(PersistentFishingDataVector2, Vector2.Zero, "CalamityMod/Particles/HighResHollowCircleHardEdge", false, 25, 0.02f, Color.Green, Vector2.One); + GeneralParticleHandler.SpawnParticle(particle); + } + List<(Vector2, int)> validRifts = new(); + + foreach (var item in Main.ActiveProjectiles) + { + if (item.bobber && projectile.type != ModContent.ProjectileType() && item.owner == projectile.owner && item.ai[0] == 0 && item.Calamity().PersistentFishingDataVector2 != Vector2.Zero) + { + validRifts.Add((item.Calamity().PersistentFishingDataVector2, item.whoAmI)); + } + } + foreach (var item in validRifts) + { + if (projectile.Distance(item.Item1) < 16) + { + projectile.localAI[1] = Main.projectile[item.Item2].Calamity().CaughtItemID; + projectile.ai[0] = -1; + Main.projectile[item.Item2].Calamity().PersistentFishingDataVector2 = PersistentFishingDataVector2; + Main.projectile[item.Item2].Calamity().CaughtItemID = CaughtItemID; + break; + } + + } + } + if (projectile.ai[0] == -1 && (Waterline.Y <= projectile.Center.Y || projectile.velocity.Length() < 0.5f)) + { + ReelTheBobberChecks(); + if (projectile.ai[0] < 2) + projectile.ai[0] = 1; + } + if (projectile.ai[0] == 0) + return true; + break; + } + + } + return false; + } + #endregion + #region AI public override void AI(Projectile projectile) { @@ -3177,97 +3675,6 @@ namespace CalamityMod.Projectiles if (projectile.type == ProjectileID.Nail && Main.expertMode) projectile.damage /= 2; - // Nerf all these Master Mode enemy projectiles - if (Main.masterMode && !CalamityPlayer.areThereAnyDamnBosses) - { - switch (projectile.type) - { - case ProjectileID.DemonSickle: - case ProjectileID.HarpyFeather: - case ProjectileID.JavelinHostile: - case ProjectileID.SalamanderSpit: - case ProjectileID.SkeletonBone: - case ProjectileID.IceSpike: - case ProjectileID.JungleSpike: - case ProjectileID.PinkLaser: - case ProjectileID.FrostBlastHostile: - case ProjectileID.GoldenShowerHostile: - case ProjectileID.RainNimbus: - case ProjectileID.FlamingArrow: - case ProjectileID.BulletDeadeye: - case ProjectileID.CannonballHostile: - case ProjectileID.UnholyTridentHostile: - case ProjectileID.FrostBeam: - case ProjectileID.CursedFlameHostile: - case ProjectileID.Stinger: - case ProjectileID.BloodNautilusTears: - case ProjectileID.RockGolemRock: - case ProjectileID.IcewaterSpit: - case ProjectileID.RocketSkeleton: - case ProjectileID.SniperBullet: - case ProjectileID.DrManFlyFlask: - case ProjectileID.DesertDjinnCurse: - case ProjectileID.InfernoHostileBlast: - case ProjectileID.InfernoHostileBolt: - case ProjectileID.Shadowflames: - case ProjectileID.ShadowBeamHostile: - case ProjectileID.PaladinsHammerHostile: - case ProjectileID.LostSoulHostile: - case ProjectileID.RuneBlast: - case ProjectileID.DandelionSeed: - case ProjectileID.SandnadoHostile: - case ProjectileID.SandnadoHostileMark: - case ProjectileID.SnowBallHostile: - case ProjectileID.EyeLaser: - case ProjectileID.Nail: - case ProjectileID.BrainScramblerBolt: - case ProjectileID.GigaZapperSpear: - case ProjectileID.MartianWalkerLaser: - case ProjectileID.RayGunnerLaser: - case ProjectileID.MartianTurretBolt: - case ProjectileID.NebulaSphere: - case ProjectileID.NebulaLaser: - case ProjectileID.NebulaBolt: - case ProjectileID.StardustJellyfishSmall: - case ProjectileID.StardustSoldierLaser: - case ProjectileID.Twinkle: - case ProjectileID.VortexAcid: - case ProjectileID.VortexLaser: - case ProjectileID.VortexLightning: - case ProjectileID.VortexVortexLightning: - case ProjectileID.FlamingWood: - case ProjectileID.GreekFire1: - case ProjectileID.GreekFire2: - case ProjectileID.GreekFire3: - case ProjectileID.FlamingScythe: - case ProjectileID.OrnamentHostile: - case ProjectileID.OrnamentHostileShrapnel: - case ProjectileID.PineNeedleHostile: - case ProjectileID.FrostShard: - case ProjectileID.FrostWave: - case ProjectileID.Missile: - case ProjectileID.Present: - case ProjectileID.Spike: - case ProjectileID.SaucerDeathray: - case ProjectileID.SaucerLaser: - case ProjectileID.SaucerMissile: - case ProjectileID.SaucerScrap: - case ProjectileID.DD2GoblinBomb: - case ProjectileID.DD2JavelinHostile: - case ProjectileID.DD2JavelinHostileT3: - case ProjectileID.DD2DarkMageBolt: - case ProjectileID.DD2DrakinShot: - case ProjectileID.DD2OgreSmash: - case ProjectileID.DD2OgreSpit: - case ProjectileID.DD2OgreStomp: - case ProjectileID.DD2LightningBugZap: - case ProjectileID.DD2BetsyFireball: - case ProjectileID.DD2BetsyFlameBreath: - projectile.damage = (int)Math.Round(projectile.damage * CalamityGlobalNPC.MasterModeEnemyDamageMultiplier); - break; - } - } - // Nerf several Hardmode enemy projectiles because they deal way too much damage if (!CalamityPlayer.areThereAnyDamnBosses) { @@ -3285,6 +3692,8 @@ namespace CalamityMod.Projectiles case ProjectileID.FrostBeam: case ProjectileID.CursedFlameHostile: case ProjectileID.Stinger: + case ProjectileID.BloodShot: + case ProjectileID.BloodNautilusShot: case ProjectileID.BloodNautilusTears: case ProjectileID.RockGolemRock: case ProjectileID.IcewaterSpit: @@ -3317,22 +3726,19 @@ namespace CalamityMod.Projectiles if (NPC.downedMoonlord) { - if (BuffedDungeonProjectilesList.Includes(projectile.type)) + if (CalamityProjectileSets.IsBuffedDungeonProjectile[projectile.type]) { // ai[1] being set to 1 is done only by the Calamity usages of these projectiles in Skeletron and Skeletron Prime boss fights bool isSkeletronBossProjectile = (projectile.type == ProjectileID.RocketSkeleton || projectile.type == ProjectileID.Shadowflames) && projectile.ai[1] > 0f; - // These projectiles will not be buffed if Golem fires them - bool isGolemBossProjectile = (projectile.type == ProjectileID.InfernoHostileBolt || projectile.type == ProjectileID.InfernoHostileBlast) && projectile.ai[2] > 0f; - - if (!isSkeletronBossProjectile && !isGolemBossProjectile) + if (!isSkeletronBossProjectile) projectile.damage += 30; } } if (DownedBossSystem.downedDoG && (Main.pumpkinMoon || Main.snowMoon || Main.eclipse)) { - if (EventProjectileBuffList.Includes(projectile.type)) + if (CalamityProjectileSets.IsBuffedEventProjectile[projectile.type]) projectile.damage += 15; } @@ -3340,7 +3746,7 @@ namespace CalamityMod.Projectiles { if (projectile.timeLeft > 570) //all of these have a time left of 600 or 660 { - if (player.ActiveItem().type == ItemID.BeesKnees) + if (player.HeldItem.type == ItemID.BeesKnees) projectile.DamageType = DamageClass.Ranged; } } @@ -3396,6 +3802,18 @@ namespace CalamityMod.Projectiles break; } + // Makes flares from Firestorm Cannon ignore gravity + // Spectralstorm Cannon uses a custom flare projectile + if (projectile.aiStyle == ProjAIStyleID.Flare && projectile.ai[2] == 1f && projectile.localAI[0] == 0f) + projectile.localAI[1]--; + + // Hack to allow Desert Tiger minion to fall through platforms while attacking + if (projectile.type >= ProjectileID.StormTigerTier1 && projectile.type <= ProjectileID.StormTigerTier3) + { + if (projectile.ai[0] == 5f) + projectile.tileCollide = false; + } + // Jack O Lantern Launcher projectile tweak if (projectile.type == ProjectileID.JackOLantern) { @@ -3408,6 +3826,7 @@ namespace CalamityMod.Projectiles } } + #region Flail Extendo Hacks // Very hacky solution for making Dao of Pow's flail throw travel farther and faster if (projectile.type == ProjectileID.TheDaoofPow) { @@ -3438,6 +3857,22 @@ namespace CalamityMod.Projectiles } } } + // And Flower Pow! + if (projectile.type == ProjectileID.FlowerPow) + { + if (projectile.ai[0] == 1f) + { + if (projectile.ai[1] > 0f) + { + projectile.ai[2]++; + if (projectile.ai[2] <= 5f) // When ai[1] reaches 12, it starts returning, so this makes it take an extra 5 frames to return + projectile.ai[1]--; + } + else + projectile.velocity *= 1.33f; + } + } + #endregion // Starfury stars never collide with tiles if (projectile.type == ProjectileID.Starfury) @@ -3463,18 +3898,30 @@ namespace CalamityMod.Projectiles projectile.ai[0]--; // Acceleration for certain lasers - if ((projectile.type == ProjectileID.EyeLaser || projectile.type == ProjectileID.DeathLaser || projectile.type == ProjectileID.FrostBeam) && projectile.ai[0] == 1f) + if ((projectile.type == ProjectileID.EyeLaser || projectile.type == ProjectileID.DeathLaser) && projectile.ai[0] == 1f) { if (projectile.velocity.Length() < AcceleratingBossLaserVelocityCap) projectile.velocity *= 1.0025f; } + // Sharknado is more translucent before dealing damage + if (projectile.type == ProjectileID.Sharknado) + { + if (projectile.timeLeft > FishronCthulhunadoTotalDuration - FishronTornadoTimeBeforeDealingDamage) + { + if (projectile.alpha < 200) + projectile.alpha = 200; + if (projectile.alpha > 220) + projectile.alpha = 220; + } + } + // Accelerate for 1.5 seconds to full velocity if (projectile.type == ProjectileID.HallowBossLastingRainbow && (CalamityWorld.revenge || BossRushEvent.BossRushActive)) { int spreadOutTime = 90; if (projectile.timeLeft > EmpressLastingRainbowTotalDuration - spreadOutTime) - projectile.velocity *= ((Main.masterMode || BossRushEvent.BossRushActive) ? 1.017078f : 1.015525f); + projectile.velocity *= 1.015525f; } // Zapinator lasers cannot trigger their damage multiplier more than once @@ -3559,36 +4006,6 @@ namespace CalamityMod.Projectiles } } - if (projectile.type == ProjectileID.OrnamentFriendly && lineColor == 1) //spawned by Festive Wings - { - Vector2 center = projectile.Center; - float maxDistance = 460f; - bool homeIn = false; - - foreach (NPC n in Main.ActiveNPCs) - { - if (n.CanBeChasedBy(projectile, false)) - { - float extraDistance = (float)(n.width / 2) + (n.height / 2); - - bool canHit = Collision.CanHit(projectile.Center, 1, 1, n.Center, 1, 1); - - if (Vector2.Distance(n.Center, projectile.Center) < (maxDistance + extraDistance) && canHit) - { - center = n.Center; - homeIn = true; - break; - } - } - } - - if (homeIn) - { - Vector2 moveDirection = projectile.SafeDirectionTo(center, Vector2.UnitY); - projectile.velocity = (projectile.velocity * 20f + moveDirection * 15f) / 21f; - } - } - if (!projectile.npcProj && !projectile.trap && projectile.friendly && projectile.damage > 0) { if (modPlayer.fungalSymbiote && player.HasBuff(BuffType())) @@ -3674,18 +4091,14 @@ namespace CalamityMod.Projectiles { if (Main.player[projectile.owner].miscCounter % 30 == 0 && projectile.FinalExtraUpdate()) { - if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileID.CrystalShard] < 15) + if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileID.CrystalShard] < DaedalusHeadRogue.ShardCountLimit) { - // Daedalus Rogue Crystals: 2 x 25%, soft cap starts at 120 base damage - int crystalDamage = CalamityUtils.DamageSoftCap(projectile.damage * 0.25, 30); + int crystalDamage = CalamityUtils.DamageSoftCap(projectile.damage * DaedalusHeadRogue.ShardDamageRatio, DaedalusHeadRogue.ShardDamageSoftcap); - for (int i = 0; i < 2; i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, velocity, ProjectileID.CrystalShard, crystalDamage, 0f, projectile.owner); - if (shard.WithinBounds(Main.maxProjectiles)) - Main.projectile[shard].DamageType = DamageClass.Generic; - } + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int shard = Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, velocity, ProjectileID.CrystalShard, crystalDamage, 0f, projectile.owner); + if (shard.WithinBounds(Main.maxProjectiles)) + Main.projectile[shard].DamageType = DamageClass.Generic; } } } @@ -3835,17 +4248,17 @@ namespace CalamityMod.Projectiles confetti.velocity.Y += Main.rand.Next(-50, 51) * 0.05f; } } - // Support to help things like holdout swords work with Arc Flash Ring - if (!spawnArcFlash && projectile.numHits == 0) - spawnArcFlash = true; + // Support to help things like holdout swords look better with Arc Flash Ring + if (!showArcFlash && projectile.numHits == 0) + showArcFlash = true; // Cooldown for the arc flash so that long lasting projectiles (like dashing summons) can spawn multiple bolts if (arcFlashCooldown >= 0) arcFlashCooldown--; if (arcFlashCooldown == 0) - spawnArcFlash = true; + showArcFlash = true; if (conditionalHomingRange > 0f) { - CalamityUtils.HomeInOnNPC(projectile, !projectile.tileCollide, conditionalHomingRange, 12f, 20f); + CalamityUtils.HomeInOnNPC(projectile, !projectile.tileCollide, conditionalHomingRange, 12f, 20f,true); } if (brimstoneBullets) { @@ -3925,7 +4338,7 @@ namespace CalamityMod.Projectiles for (int i = 0; i < 2; ++i) { - Dust dust = Dust.NewDustPerfect(projectile.Center + projectile.velocity, 261, -projectile.velocity * Main.rand.NextFloat(0.1f, 0.9f)); + Dust dust = Dust.NewDustPerfect(projectile.Center + projectile.velocity, DustID.AncientLight, -projectile.velocity * Main.rand.NextFloat(0.1f, 0.9f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.65f, 0.9f); dust.alpha = 100; @@ -3948,7 +4361,7 @@ namespace CalamityMod.Projectiles for (int i = 0; i < 3; ++i) { - Dust dust = Dust.NewDustPerfect(projectile.Center + spawnOffset, 278, projectile.velocity * Main.rand.NextFloat(0.05f, 0.2f)); + Dust dust = Dust.NewDustPerfect(projectile.Center + spawnOffset, DustID.FireworksRGB, projectile.velocity * Main.rand.NextFloat(0.05f, 0.2f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.35f, 0.45f); dust.color = color; @@ -3977,7 +4390,7 @@ namespace CalamityMod.Projectiles for (int i = 0; i < 3; ++i) { - Dust dust = Dust.NewDustPerfect(projectile.Center + spawnOffset, 278, projectile.velocity * Main.rand.NextFloat(0.05f, 0.2f)); + Dust dust = Dust.NewDustPerfect(projectile.Center + spawnOffset, DustID.FireworksRGB, projectile.velocity * Main.rand.NextFloat(0.05f, 0.2f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.35f, 0.45f); dust.color = color; @@ -4007,36 +4420,33 @@ namespace CalamityMod.Projectiles if (flatDRTimer <= 0) flatDR = 0; } + if (projectile.FinalExtraUpdate() && multiplicativeDRTimer > 0) + { + multiplicativeDRTimer--; + if (multiplicativeDRTimer <= 0) + multiplicativeDR = 0; + } if (projectile.FinalExtraUpdate() && TransformerTimer > 0) { TransformerTimer--; } - // CIT 29JUN2024: Moved from PreAI to PostAI so that it is called every update instead of every frame. - // This makes the distance traveled increment more accurately for projectiles with extra updates, as previously projectiles with extra updates - // would add the distance traveled for the whole frame on the first update, making the distance checking much choppier. - if (pointBlankShotDistanceTravelled < PointBlankShotDistanceLimit) - pointBlankShotDistanceTravelled += projectile.velocity.Length(); + // Spawn Bloom Stone flower on landed hooks + // Should only spawn if: Projectile is a hook, hook is grappled to a tile, the player is wearing Bloom Stone, no flower has been spawned from this hook + if (projectile.aiStyle == ProjAIStyleID.Hook && projectile.ai[0] == 2f && + Main.player[projectile.owner].Calamity().bloomStone && !hookCanSpawnFlower) + { + hookCanSpawnFlower = true; + if (Main.myPlayer == projectile.owner) + Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, projectile.whoAmI); + } - // optimization to remove conversion X/Y loop for irrelevant projectiles - bool isConversionProjectile = projectile.type == ProjectileID.PurificationPowder - || projectile.type == ProjectileID.VilePowder - || projectile.type == ProjectileID.ViciousPowder - || projectile.type == ProjectileID.PureSpray - || projectile.type == ProjectileID.CorruptSpray - || projectile.type == ProjectileID.CrimsonSpray - || projectile.type == ProjectileID.HallowSpray - || projectile.type == ProjectileID.Fertilizer; - if (!isConversionProjectile) - return; - - if (projectile.owner == Main.myPlayer/* && Main.netMode != NetmodeID.MultiplayerClient*/) + // Fertilizer + if (projectile.type == ProjectileID.Fertilizer && projectile.owner == Main.myPlayer/* && Main.netMode != NetmodeID.MultiplayerClient*/) { int x = (int)(projectile.Center.X / 16f); int y = (int)(projectile.Center.Y / 16f); - bool isPowder = projectile.type == ProjectileID.PurificationPowder || projectile.type == ProjectileID.VilePowder || projectile.type == ProjectileID.ViciousPowder; - if (!WorldGen.InWorld(x, y, 3)) return; @@ -4044,47 +4454,27 @@ namespace CalamityMod.Projectiles { for (int j = y - 1; j <= y + 1; j++) { - if (projectile.type == ProjectileID.Fertilizer) - { - Tile tile = Main.tile[i, j]; + Tile tile = Main.tile[i, j]; - if (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) - { - bool isPlayerNear = WorldGen.PlayerLOS(i, j); - bool success = WorldGen.GrowTree(i, j); - if (success && isPlayerNear) - WorldGen.TreeGrowFXCheck(i, j); - } - else if (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) - { - bool isPlayerNear = WorldGen.PlayerLOS(i, j); - bool success = WorldGen.GrowPalmTree(i, j); - if (success && isPlayerNear) - WorldGen.TreeGrowFXCheck(i, j); - } - else if (tile.TileType == ModContent.TileType()) - { - bool isPlayerNear = WorldGen.PlayerLOS(i, j); - if (isPlayerNear && Main.tile[i, j + 1].TileType != ModContent.TileType()) - SpineTree.Spawn(i, j, 22, 28, true); - } - } - - if (projectile.type == ProjectileID.PureSpray || projectile.type == ProjectileID.PurificationPowder) + if (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Pure, !isPowder); + bool isPlayerNear = WorldGen.PlayerLOS(i, j); + bool success = WorldGen.GrowTree(i, j); + if (success && isPlayerNear) + WorldGen.TreeGrowFXCheck(i, j); } - if (projectile.type == ProjectileID.CorruptSpray || projectile.type == ProjectileID.VilePowder) + else if (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Corrupt, !isPowder); + bool isPlayerNear = WorldGen.PlayerLOS(i, j); + bool success = WorldGen.GrowPalmTree(i, j); + if (success && isPlayerNear) + WorldGen.TreeGrowFXCheck(i, j); } - if (projectile.type == ProjectileID.CrimsonSpray || projectile.type == ProjectileID.ViciousPowder) + else if (tile.TileType == ModContent.TileType()) { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Crimson, !isPowder); - } - if (projectile.type == ProjectileID.HallowSpray) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Hallow); + bool isPlayerNear = WorldGen.PlayerLOS(i, j); + if (isPlayerNear && Main.tile[i, j + 1].TileType != ModContent.TileType()) + SpineTree.Spawn(i, j, 22, 28, true); } NetMessage.SendTileSquare(-1, i, j, 1, 1); } @@ -4094,16 +4484,53 @@ namespace CalamityMod.Projectiles #endregion #region Grappling Hooks + public override void UseGrapple(Player player, ref int type) + { + if (player.Calamity().bloomStoneHookVisuals) + { + for (int i = 0; i < 8; i++) + { + Particle floweyFromHitGameUndertale = new CustomSpark(player.Center, Utils.DirectionTo(player.Center, player.Calamity().mouseWorld).RotatedByRandom(0.6f) * Main.rand.NextFloat(4f, 11f), + "CalamityMod/Particles/MiniFlower", false, Main.rand.Next(65, 78 + 1), Main.rand.NextFloat(1.8f, 2.8f), + Color.Lerp(Color.HotPink, Color.Plum, Main.rand.NextFloat(0, 0.65f)), new Vector2(1f, 1f), true, extraRotation: Main.rand.NextFloat(0, MathHelper.TwoPi)); + GeneralParticleHandler.SpawnParticle(floweyFromHitGameUndertale); + + Dust pollenDust = Dust.NewDustPerfect(player.Center, DustType()); + pollenDust.noLightEmittence = true; + pollenDust.noGravity = true; + pollenDust.scale = Main.rand.NextFloat(0.9f, 1.4f); + pollenDust.color = Main.rand.NextBool() ? Color.Gold : Color.HotPink; + pollenDust.velocity = Utils.DirectionTo(player.Center, player.Calamity().mouseWorld).RotatedByRandom(0.6f) * Main.rand.NextFloat(4f, 11f); + pollenDust.fadeIn = -0.5f; + } + } + } public override void GrapplePullSpeed(Projectile projectile, Player player, ref float speed) { + float mult = 1f; if (player.Calamity().reaverSpeed) - speed *= 1.1f; - } + mult += ReaverHeadMobility.SetBonusHookBoost; + if (player.Calamity().tungstenArmorHookBoost) + mult += TungstenArmorSetChange.HookBoost; + if (player.Calamity().bloomStone) + mult += 0.5f; + speed *= mult; + if (player.velocity.Length() > 2f) + { + player.Calamity().hookPullVisuals = 60; + } + } public override void GrappleRetreatSpeed(Projectile projectile, Player player, ref float speed) { + float mult = 1f; if (player.Calamity().reaverSpeed) - speed *= 1.1f; + mult += ReaverHeadMobility.SetBonusHookBoost; + if (player.Calamity().tungstenArmorHookBoost) + mult += TungstenArmorSetChange.HookBoost; + if (player.Calamity().bloomStone) + mult += 0.5f; + speed *= mult; } #endregion @@ -4114,19 +4541,38 @@ namespace CalamityMod.Projectiles CalamityPlayer modPlayer = player.Calamity(); // Old Fashioned buffs (or debuffs) apply if the player has Old Fashioned + // IV Drip on the Rocks inherits the same logic as Old Fashioned if (modPlayer.oldFashioned && buffedByOldFashioned.HasValue) modifiers.SourceDamage *= buffedByOldFashioned.Value ? OldFashioned.DamageBoostMultiplier : OldFashioned.DamageReductionMultiplier; + if (modPlayer.ivDrip && buffedByOldFashioned.HasValue) + modifiers.SourceDamage *= buffedByOldFashioned.Value ? IVDripOnTheRocks.DamageBoostMultiplier : IVDripOnTheRocks.DamageReductionMultiplier; + if (modPlayer.rum && projectile.DamageType.CountsAsClass(DamageClass.Summon)) + { + if (projectile.minion || ProjectileID.Sets.MinionShot[projectile.type]) + { + modifiers.SourceDamage *= Rum.MinionBoost; + } + else + modifiers.SourceDamage *= Rum.NonMinionBoost; + } + if (modPlayer.moscowMule || modPlayer.bloodyMary) + { + if (projectile.DamageType == DamageClass.Summon || (PierceResistNPC.exemptProjectiles.Contains(projectile.type) || (PierceResistNPC.singleHitboxExemptProjectiles.ContainsKey(projectile.type) && PierceResistNPC.singleHitboxExemptProjectiles[projectile.type]))) + { + modifiers.SourceDamage *= ((modPlayer.moscowMule ? 0.7f : 1f) * (modPlayer.bloodyMary ? 0.33f : 1f)); + } + } if (projectile.type == ProjectileID.JoustingLance || projectile.type == ProjectileID.HallowJoustingLance || projectile.type == ProjectileID.ShadowJoustingLance) { - // The vanilla damage Jousting Lance multiplier is as follows. Calamity overrides this with a new formula. + // The vanilla damage Jousting Lance multiplier is as follows. Calamity overrides this with a new formula float vanillaVelocityDamageMultiplier = 0.1f + player.velocity.Length() / 7f * 0.9f; float baseVelocityDamageMultiplier = 0.01f + player.velocity.Length() * 0.002f; float calamityVelocityDamageMultiplier = 100f * (1f - (1f / (1f + baseVelocityDamageMultiplier))); modifiers.SourceDamage *= calamityVelocityDamageMultiplier / vanillaVelocityDamageMultiplier; } - // Adamantite Throwing Axe's lightning has damage falloff. + // Adamantite Throwing Axe's lightning has damage falloff if (projectile.type == ProjectileID.CultistBossLightningOrbArc && projectile.ai[2] == 1f) { if (projectile.numHits > 0) @@ -4135,20 +4581,36 @@ namespace CalamityMod.Projectiles projectile.damage = 1; } - // Stardust Wings buff the Stardust Guardian's damage. - if (player.wingsLogic == (int)VanillaWingID.WingsStardust && projectile.type == ProjectileID.StardustGuardian) - modifiers.SourceDamage *= 2f; + // Super Star Shooter has damage falloff + if (projectile.type == ProjectileID.SuperStar) + { + if (projectile.numHits > 0) + projectile.damage = (int)(projectile.damage * 0.95f); + if (projectile.damage < 1) + projectile.damage = 1; + } - // If applicable, use ricoshot bonus damage. + // Stardust Wings buff the Stardust Guardian's damage + if (player.wingsLogic == (int)VanillaWingID.WingsStardust && player.wingTime > 0f && projectile.type == ProjectileID.StardustGuardian) + modifiers.SourceDamage *= MathF.Max(1f, MathHelper.Lerp(4f, 1f, player.wingTime / (float)player.wingTimeMax)); + + // If applicable, use ricoshot bonus damage if (totalRicoshotDamageBonus > 0f) modifiers.ScalingBonusDamage += totalRicoshotDamageBonus; - // If this projectile is forced to crit, simply set the crit bool. + // If this projectile is forced to crit, simply set the crit bool if (forcedCrit) modifiers.SetCrit(); - if (modPlayer.rottenDogTooth && projectile.Calamity().stealthStrike) + if (modPlayer.rottenDogTooth && projectile.Calamity().stealthStrike && !modPlayer.vampiricTalisman) target.AddBuff(BuffType(), RottenDogtooth.ArmorCrunchDebuffTime); + else if (modPlayer.vampiricTalisman && projectile.Calamity().stealthStrike) + { + target.AddBuff(BuffType(), VampiricTalisman.ArmorCrunchDebuffTime); + + if (!modPlayer.nanotech) + target.AddBuff(BuffType(), VampiricTalisman.HeavyBleedingDebuffTime); + } if (modPlayer.flamingItemEnchant && !projectile.minion && !projectile.npcProj && !projectile.Calamity().CreatedByPlayerDash) target.AddBuff(BuffType(), VulnerabilityHex.AflameDuration); @@ -4215,6 +4677,67 @@ namespace CalamityMod.Projectiles public override void ModifyHitPlayer(Projectile projectile, Player target, ref Player.HurtModifiers modifiers) { modifiers.FinalDamage.Flat -= flatDR; + modifiers.FinalDamage *= 1f - multiplicativeDR; + } + #endregion + + #region On Hit NPC + public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone) + { + //Manage Hybrid iframes + if ((projectile.usesLocalNPCImmunity && projectile.usesIDStaticNPCImmunity) && (projectile.penetrate != 1 || projectile.appliesImmunityTimeOnSingleHits)) + { + projectile.localNPCImmunity[target.whoAmI] = projectile.localNPCHitCooldown; + Projectile.perIDStaticNPCImmunity[projectile.type][target.whoAmI] = Main.GameUpdateCount + (uint)projectile.idStaticNPCHitCooldown; + } + if (BloodstoneOrbValue > 0) + Projectile.NewProjectile(projectile.GetSource_OnHit(target), projectile.Center, projectile.velocity.SafeNormalize(Vector2.Zero) * Math.Min(((projectile.velocity.Length() * projectile.MaxUpdates) / 4f), 4f) * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), BloodstoneOrbValue, 0f, Main.player[projectile.owner].whoAmI); + //Mana Burn + if (Main.player[projectile.owner].statMana < 0) + { + float burnRatio = (-Main.player[projectile.owner].statMana / 100) * ChaosStone.DamageMultPer100Mana; + target.Calamity().manaBurn += damageDone * burnRatio; + target.Calamity().playerManaBurnIntensity = -Main.player[projectile.owner].statMana / (float)Main.player[projectile.owner].statManaMax2; + } + // Hyperius Overflow + if (projectile.type != ProjectileType() && projectile.type != ProjectileType() && projectile.type != ProjectileType() && projectile.type != ProjectileType() && target.Calamity().hyperiusMarked) + { + int damage = 0; + if (target.Calamity().hyperiusDamage < damageDone) + damage = damageDone - target.Calamity().hyperiusDamage; + else + damage = damageDone; + + target.Calamity().hyperiusDamage -= damage; + + // Spawn overflow hit + Projectile overflow = Projectile.NewProjectileDirect(target.GetSource_FromThis(), target.Center, Vector2.Zero, ProjectileType(), (int)(damage * HyperiusBullet.overflowEfficency), 0, projectile.owner, target.whoAmI); + overflow.DamageType = projectile.DamageType; + overflow.ArmorPenetration = projectile.ArmorPenetration; // Takes the armor pen from what did the hit + + if (target.Calamity().hyperiusDamage <= 0) + { + target.Calamity().hyperiusDamage = 0; + target.Calamity().hyperiusMarked = false; + } + } + // Crystal Darts reset iframes on bouncing off an enemy + if (projectile.type == ProjectileID.CrystalDart) + { + projectile.ResetLocalNPCHitImmunity(); + projectile.localNPCImmunity[target.whoAmI] = -1; + } + // Implementation of shared static iframes. + // If this projectile does not use static iframes, or is not registered to share them, then do nothing. + if (!projectile.usesIDStaticNPCImmunity || CalamityProjectileSets.SharedIDStaticIFrames[projectile.type] == -1) + return; + + // Apply the appropriate shared static iframes to all projectile types with which it is shared. + for (int proj = 0; proj < CalamityProjectileSets.SharedIDStaticIFrames.Length; proj++) + { + if (CalamityProjectileSets.SharedIDStaticIFrames[proj] == CalamityProjectileSets.SharedIDStaticIFrames[projectile.type]) + Projectile.perIDStaticNPCImmunity[proj][target.whoAmI] = Main.GameUpdateCount + (uint)projectile.idStaticNPCHitCooldown; + } } #endregion @@ -4224,7 +4747,6 @@ namespace CalamityMod.Projectiles if (projectile.hostile && (projectile.damage - flatDR <= 0)) return false; - bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; switch (projectile.type) @@ -4233,8 +4755,8 @@ namespace CalamityMod.Projectiles case ProjectileID.DeerclopsIceSpike: if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { - float fadeInTime = 10f; - float fadeOutGateValue = masterMode ? 80f : death ? 50f : 25f; + float fadeInTime = 25f; + float fadeOutGateValue = death ? 90f : 65f; return (projectile.ai[0] >= fadeInTime && projectile.ai[0] < fadeOutGateValue); } break; @@ -4245,9 +4767,9 @@ namespace CalamityMod.Projectiles return projectile.ai[0] > projectile.ai[2]; break; - // Additional slams in the Master Mode shockwave have a delay before expanding and dealing damage + // Additional slams in the Death Mode shockwave have a delay before expanding and dealing damage case ProjectileID.QueenSlimeSmash: - if (masterMode) + if (death) return projectile.ai[0] > 0f; break; @@ -4295,6 +4817,28 @@ namespace CalamityMod.Projectiles } return true; } + + public override bool? CanHitNPC(Projectile projectile, NPC target) + { + + if ((projectile.usesLocalNPCImmunity && projectile.usesIDStaticNPCImmunity) && (projectile.localNPCImmunity[target.whoAmI] != 0 || Projectile.perIDStaticNPCImmunity[projectile.type][target.whoAmI] > Main.GameUpdateCount)) + return false; + if (target.Calamity().IsArmored() && HomingTarget > -1 && HomingTarget != target.whoAmI) + return false; + return null; + } + #endregion + + #region TileCollide + public override bool OnTileCollide(Projectile projectile, Vector2 oldVelocity) + { + //Crystal Darts use -1 local that needs to reset whenever they bounce + if (projectile.type == ProjectileID.CrystalDart) + { + projectile.ResetLocalNPCHitImmunity(); + } + return base.OnTileCollide(projectile, oldVelocity); + } #endregion #region Drawing @@ -4307,17 +4851,19 @@ namespace CalamityMod.Projectiles { if (projectile.ModProjectile is null || (projectile.ModProjectile != null && projectile.ModProjectile.CanHitPlayer(Main.LocalPlayer) && (projectile.ModProjectile.CanDamage() ?? true))) { - Color mainColor = Color.Lerp(Color.Crimson with { A = 0 }, Color.OrangeRed with { A = 0 }, ((Main.GlobalTimeWrappedHourly * 2) % 1f)); - return mainColor; + Color mainColor = Color.Lerp(Color.Crimson with { A = 0 }, Color.OrangeRed with { A = 0 }, (Main.GlobalTimeWrappedHourly * 2) % 1f); + Color actualDisplayColor = new Color(Math.Max(mainColor.R, lightColor.R), Math.Max(mainColor.G, lightColor.G), Math.Max(mainColor.B, lightColor.B)); + return actualDisplayColor; } } if (projectile.type == ProjectileID.Skull && (projectile.ai[0] == -1f || projectile.ai[0] == -3f)) { - float homingTime = ((Main.masterMode || BossRushEvent.BossRushActive) ? 120f : CalamityWorld.death ? 105f : 90f); + float homingTime = CalamityWorld.death ? 105f : 90f; if (projectile.ai[0] == -3f) homingTime += 60f; - return projectile.ai[1] >= homingTime ? new Color(184, 140, 255, projectile.alpha) : lightColor; + + return projectile.ai[1] >= homingTime ? new Color(184, 140, 255, projectile.alpha) : new Color(255, 255, 255, (int)Utils.WrappedLerp(0f, 255f, (float)(projectile.timeLeft % 40) / 40f)); } if (projectile.type == ProjectileID.BloodNautilusShot) @@ -4388,8 +4934,6 @@ namespace CalamityMod.Projectiles public override bool PreDraw(Projectile projectile, ref Color lightColor) { - // This is used so that projectiles with specific PreDraws can still have Odd Mushroom clone drawing. - // If Odd Mushroom clone drawing is done manually due to using a different texture, just return false instead of setting this. bool shouldDrawBool = true; #region Vanilla Summons Drawing Changes @@ -4407,7 +4951,6 @@ namespace CalamityMod.Projectiles 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; @@ -4415,9 +4958,9 @@ namespace CalamityMod.Projectiles 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 : 25f; - float killGateValue = masterMode ? 90f : death ? 60f : 35f; - float lerpValue5 = Utils.GetLerpValue(killGateValue, killGateValue - 10f, projectile.ai[0], clamped: true); + float fadeOutGateValue = death ? 90f : 65f; + float killGateValue = death ? 100f : 75f; + float lerpValue5 = Utils.GetLerpValue(killGateValue, killGateValue - 50f, projectile.ai[0], clamped: true); vector39.Y *= lerpValue5; Vector4 vector40 = lightColor.ToVector4(); Vector4 vector41 = new Color(67, 17, 17).ToVector4(); @@ -4427,7 +4970,7 @@ namespace CalamityMod.Projectiles 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); + Main.EntitySpriteDraw(TextureAssets.Extra[ExtrasID.SharpTears].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[ExtrasID.SharpTears].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; @@ -4445,8 +4988,6 @@ namespace CalamityMod.Projectiles Texture2D crossbone = TextureAssets.Projectile[ProjectileID.BoneGloveProj].Value; Main.spriteBatch.Draw(crossbone, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, crossbone.Size() / 2f, projectile.scale, projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); - if (Main.LocalPlayer.Calamity().trippy) - OddMushroomProjectileDrawing(projectile, crossbone); return false; } @@ -4465,8 +5006,6 @@ namespace CalamityMod.Projectiles spriteEffects = SpriteEffects.FlipHorizontally; Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), rectangle, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, spriteEffects, 0f); - if (Main.LocalPlayer.Calamity().trippy) - OddMushroomProjectileDrawing(projectile, texture); return false; } } @@ -4483,16 +5022,6 @@ namespace CalamityMod.Projectiles shouldDrawBool = false; } - // Chlorophyte Crystal AI rework. - if (projectile.type == ProjectileID.CrystalLeaf) - { - ChlorophyteCrystalAI.DoChlorophyteCrystalDrawing(projectile); - shouldDrawBool = false; - } - - if (Main.LocalPlayer.Calamity().trippy) - OddMushroomProjectileDrawing(projectile); - if (Main.zenithWorld) { if (NPC.AnyNPCs(NPCType())) @@ -4506,142 +5035,12 @@ namespace CalamityMod.Projectiles return shouldDrawBool; } - - private static void OddMushroomProjectileDrawing(Projectile projectile, Texture2D? tex = null) - { - Texture2D texture = tex ?? TextureAssets.Projectile[projectile.type].Value; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Color rainbow = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); - Color alphaColor = projectile.GetAlpha(rainbow); - float RGBMult = 0.99f; - alphaColor.R = (byte)(alphaColor.R * RGBMult); - alphaColor.G = (byte)(alphaColor.G * RGBMult); - alphaColor.B = (byte)(alphaColor.B * RGBMult); - alphaColor.A = (byte)(alphaColor.A * RGBMult); - int totalAfterimages = Main.LocalPlayer.Calamity().trippyLevel == 3 ? 16 : (Main.LocalPlayer.Calamity().trippyLevel == 2 ? 12 : 4); - for (int i = 0; i < totalAfterimages; i++) - { - Vector2 position = projectile.position; - float distanceFromTargetX = Math.Abs(projectile.Center.X - Main.LocalPlayer.Center.X); - float distanceFromTargetY = Math.Abs(projectile.Center.Y - Main.LocalPlayer.Center.Y); - - float smallDistanceMult = 0.48f; - float largeDistanceMult = 1.33f; - bool whatTheFuck = Main.LocalPlayer.Calamity().trippyLevel == 3; - - switch (i) - { - case 0: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; - - case 1: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY; - break; - - case 2: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - case 3: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY; - break; - - case 4: // 1 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 1f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 0f : largeDistanceMult)); - break; - - case 5: // 4 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 0f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 1f : smallDistanceMult)); - break; - - case 6: // 7 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 1f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 0f : largeDistanceMult)); - break; - - case 7: // 10 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 0f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 1f : smallDistanceMult)); - break; - - case 8: // 11 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 0f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 0.5f : largeDistanceMult)); - break; - - case 9: // 2 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 0.5f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y - (distanceFromTargetY * (whatTheFuck ? 0f : smallDistanceMult)); - break; - - case 10: // 5 o'clock position - position.X = Main.LocalPlayer.Center.X + (distanceFromTargetX * (whatTheFuck ? 0f : smallDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 0.5f : largeDistanceMult)); - break; - - case 11: // 8 o'clock position - position.X = Main.LocalPlayer.Center.X - (distanceFromTargetX * (whatTheFuck ? 0.5f : largeDistanceMult)); - position.Y = Main.LocalPlayer.Center.Y + (distanceFromTargetY * (whatTheFuck ? 0f : smallDistanceMult)); - break; - - case 12: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY * 0.5f; - break; - - case 13: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y - distanceFromTargetY * 0.5f; - break; - - case 14: - position.X = Main.LocalPlayer.Center.X + distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY * 0.5f; - break; - - case 15: - position.X = Main.LocalPlayer.Center.X - distanceFromTargetX * 0.5f; - position.Y = Main.LocalPlayer.Center.Y + distanceFromTargetY * 0.5f; - break; - - default: - break; - } - - position.X -= projectile.width / 2; - position.Y -= projectile.height / 2; - - int frameHeight = texture.Height / Main.projFrames[projectile.type]; - int currentframeHeight = frameHeight * projectile.frame; - Rectangle frame = new Rectangle(0, currentframeHeight, texture.Width, frameHeight); - - Vector2 halfSize = frame.Size() / 2; - - Main.spriteBatch.Draw(texture, - new Vector2(position.X - Main.screenPosition.X + (float)(projectile.width / 2) - (float)TextureAssets.Projectile[projectile.type].Width() * projectile.scale / 2f + halfSize.X * projectile.scale, - position.Y - Main.screenPosition.Y + (float)projectile.height - (float)TextureAssets.Projectile[projectile.type].Height() * projectile.scale / (float)Main.projFrames[projectile.type] + 4f + halfSize.Y * projectile.scale + projectile.gfxOffY), - frame, alphaColor, projectile.rotation, halfSize, projectile.scale, spriteEffects, 0f); - } - } #endregion #region Pre Kill public override bool PreKill(Projectile projectile, int timeLeft) { - bool masterRevSkeletronPrimeBomb = projectile.type == ProjectileID.BombSkeletronPrime && projectile.ai[0] < 0f && (Main.masterMode || BossRushEvent.BossRushActive); bool revQueenBeeBeeHive = projectile.type == ProjectileID.BeeHive && (CalamityWorld.revenge || BossRushEvent.BossRushActive) && (projectile.ai[2] == 1f || CalamityWorld.death); - bool revGolemInferno = projectile.type == ProjectileID.InfernoHostileBolt && projectile.ai[2] > 0f; if (revQueenBeeBeeHive) { @@ -4661,102 +5060,13 @@ namespace CalamityMod.Projectiles if (projectile.owner == Main.myPlayer) { - if (masterRevSkeletronPrimeBomb) - { - SoundEngine.PlaySound(SoundID.Item14, projectile.Center); - projectile.position.X += projectile.width / 2; - projectile.position.Y += projectile.height / 2; - projectile.width = projectile.height = 22; - projectile.position.X -= projectile.width / 2; - projectile.position.Y -= projectile.height / 2; - - for (int num951 = 0; num951 < 20; num951++) - { - int num952 = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default(Color), 1.5f); - Dust dust2 = Main.dust[num952]; - dust2.velocity *= 1.4f; - } - - int num950 = 6; - for (int num953 = 0; num953 < 10; num953++) - { - int num954 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num950, 0f, 0f, 100, default(Color), 2.5f); - Main.dust[num954].noGravity = true; - Dust dust2 = Main.dust[num954]; - dust2.velocity *= 5f; - num954 = Dust.NewDust(projectile.position, projectile.width, projectile.height, num950, 0f, 0f, 100, default(Color), 1.5f); - dust2 = Main.dust[num954]; - dust2.velocity *= 3f; - } - - int num955 = Gore.NewGore(projectile.GetSource_FromAI(), projectile.position, default(Vector2), Main.rand.Next(61, 64)); - Gore gore2 = Main.gore[num955]; - gore2.velocity *= 0.4f; - Main.gore[num955].velocity.X += 1f; - Main.gore[num955].velocity.Y += 1f; - num955 = Gore.NewGore(projectile.GetSource_FromAI(), projectile.position, default(Vector2), Main.rand.Next(61, 64)); - gore2 = Main.gore[num955]; - gore2.velocity *= 0.4f; - Main.gore[num955].velocity.X -= 1f; - Main.gore[num955].velocity.Y += 1f; - num955 = Gore.NewGore(projectile.GetSource_FromAI(), projectile.position, default(Vector2), Main.rand.Next(61, 64)); - gore2 = Main.gore[num955]; - gore2.velocity *= 0.4f; - Main.gore[num955].velocity.X += 1f; - Main.gore[num955].velocity.Y -= 1f; - num955 = Gore.NewGore(projectile.GetSource_FromAI(), projectile.position, default(Vector2), Main.rand.Next(61, 64)); - gore2 = Main.gore[num955]; - gore2.velocity *= 0.4f; - Main.gore[num955].velocity.X -= 1f; - Main.gore[num955].velocity.Y -= 1f; - - Vector2 vector76 = projectile.position; - projectile.position.X += projectile.width / 2; - projectile.position.Y += projectile.height / 2; - projectile.width = projectile.height = 128; - projectile.position.X -= projectile.width / 2; - projectile.position.Y -= projectile.height / 2; - projectile.Damage(); - projectile.position = vector76; - projectile.width = projectile.height = 22; - - if (Main.getGoodWorld && !Main.remixWorld) - { - int num1011 = 4; - Vector2 center3 = projectile.position; - int num1012 = num1011; - int num1013 = num1011; - int num1014 = (int)(center3.X / 16f - (float)num1012); - int num1015 = (int)(center3.X / 16f + (float)num1012); - int num1016 = (int)(center3.Y / 16f - (float)num1013); - int num1017 = (int)(center3.Y / 16f + (float)num1013); - if (num1014 < 0) - num1014 = 0; - - if (num1015 > Main.maxTilesX) - num1015 = Main.maxTilesX; - - if (num1016 < 0) - num1016 = 0; - - if (num1017 > Main.maxTilesY) - num1017 = Main.maxTilesY; - - bool wallSplode2 = projectile.ShouldWallExplode(center3, num1011, num1014, num1015, num1016, num1017); - projectile.ExplodeTiles(center3, num1011, num1014, num1015, num1016, num1017, wallSplode2); - } - - if (Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.KillProjectile, -1, -1, null, projectile.identity, projectile.owner); - } - - else if (revQueenBeeBeeHive) + if (revQueenBeeBeeHive) { if (Main.netMode != NetmodeID.MultiplayerClient) { int beeAmt = Main.rand.Next(2, 5 + 1); int totalBeesAlive = NPC.CountNPCS(NPCID.Bee) + NPC.CountNPCS(NPCID.BeeSmall); - int finalBeeAmtToSpawn = NPC.AnyNPCs(NPCID.QueenBee) ? Math.Min(beeAmt, (Main.masterMode ? 9 : 15) - totalBeesAlive) : NPC.GetAvailableAmountOfNPCsToSpawnUpToSlot(beeAmt); + int finalBeeAmtToSpawn = NPC.AnyNPCs(NPCID.QueenBee) ? Math.Min(beeAmt, (CalamityWorld.death ? 9 : 15) - totalBeesAlive) : NPC.GetAvailableAmountOfNPCsToSpawnUpToSlot(beeAmt); for (int i = 0; i < finalBeeAmtToSpawn; i++) { int beeType = Main.rand.NextBool() ? NPCID.Bee : NPCID.BeeSmall; @@ -4764,7 +5074,7 @@ namespace CalamityMod.Projectiles { beeType = Main.rand.NextBool(3) ? NPCType() : NPCType(); } - else if (Main.masterMode || BossRushEvent.BossRushActive) + else if (CalamityWorld.death || BossRushEvent.BossRushActive) { switch (Main.rand.Next(12)) { @@ -4806,17 +5116,9 @@ namespace CalamityMod.Projectiles if (Main.netMode != NetmodeID.SinglePlayer) NetMessage.SendData(MessageID.KillProjectile, -1, -1, null, projectile.identity, projectile.owner); } - - else if (revGolemInferno) - { - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileID.InfernoHostileBlast, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f, projectile.ai[2]); - - if (Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.KillProjectile, -1, -1, null, projectile.identity, projectile.owner); - } } - if (masterRevSkeletronPrimeBomb || revQueenBeeBeeHive || revGolemInferno) + if (revQueenBeeBeeHive) { projectile.active = false; return false; @@ -4864,47 +5166,9 @@ namespace CalamityMod.Projectiles modPlayer.scuttlerCooldown = 30; } } - - if (projectile.type == ProjectileID.UnholyWater) - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, 1f); - - if (projectile.type == ProjectileID.BloodWater) - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, 2f); - - if (projectile.type == ProjectileID.HolyWater) - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, 3f); } } } #endregion - - #region Life Steal - public static bool CanSpawnLifeStealProjectile(double healMultiplier, float healAmount) => healMultiplier > 0D && (int)healAmount > 0; - - public static void SpawnLifeStealProjectile(Projectile projectile, Player player, float healAmount, int healProjectileType, float distanceRequired, float cooldownMultiplier = 1f) - { - if (Main.LocalPlayer.moonLeech) - return; - - Main.LocalPlayer.lifeSteal -= healAmount * cooldownMultiplier; - - float lowestHealthCheck = 0f; - int healTarget = projectile.owner; - foreach (Player otherPlayer in Main.ActivePlayers) - { - 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 = otherPlayer.whoAmI; - } - } - } - - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, healProjectileType, 0, 0f, projectile.owner, healTarget, healAmount); - } - #endregion } } diff --git a/Projectiles/CalamityGlobalProjectileTweaks.cs b/Projectiles/CalamityGlobalProjectileTweaks.cs index 3f29fce51a..9d21db0c48 100644 --- a/Projectiles/CalamityGlobalProjectileTweaks.cs +++ b/Projectiles/CalamityGlobalProjectileTweaks.cs @@ -16,13 +16,13 @@ namespace CalamityMod.Projectiles { // Various shorthands for projectiles which receive very simple changes, such as setting one flag. IProjectileTweak[] defenseDamage = Do(DefenseDamage); - IProjectileTweak[] trueMelee = Do(TrueMelee); - IProjectileTweak[] trueMeleeNoSpeed = Do(TrueMeleeNoSpeed); - IProjectileTweak[] pointBlank = Do(PointBlank); - IProjectileTweak[] standardBulletTweaks = Do(PointBlank, ExtraUpdatesDelta(+2)); + IProjectileTweak[] trueMelee = Do(TrueMelee, DefaultIDStaticIFrames); // All the tweaked true melee projectiles need to be changed from global to static as well + IProjectileTweak[] trueMeleeNoSpeed = Do(TrueMeleeNoSpeed, DefaultIDStaticIFrames); + IProjectileTweak[] defaultIFrames = Do(DefaultIDStaticIFrames); + IProjectileTweak[] standardBulletTweaks = Do(ExtraUpdatesDelta(+2)); IProjectileTweak[] standardChainsawTweaks = Do(TrueMeleeNoSpeed, ArmorPenetrationDelta(+15), LocalIFrames(5)); IProjectileTweak[] standardDrillTweaks = Do(TrueMeleeNoSpeed, ArmorPenetrationDelta(+25), LocalIFrames(5)); - IProjectileTweak[] counterweightTweaks = Do(MaxUpdatesExact(2), IDStaticIFrames(10)); + IProjectileTweak[] counterweightTweaks = Do(MaxUpdatesExact(2), DefaultIDStaticIFrames); // Shorthand for changing all the stats of a yoyo at once. This handles extra update related math for you. // For topSpeed, put in how fast you want the yoyo to be EXACTLY: it will be divided out in extra updates for you. @@ -35,8 +35,6 @@ namespace CalamityMod.Projectiles YoyoTopSpeed(topSpeed / (extraUpdates + 1)), }; - // TODO -- Very few vanilla yoyos have range and speed tweaks. Looks like an unfinished job. - // SORTING NOTES: // 1. Sort tweaks by categories first, then sort by the internal name in alphabetical order. Navigate through categories and names using the search function. // 2. Higher categories hold priority over lower ones (ie. Balancing with PB tweaks belong in balancing, rather than PB) @@ -97,7 +95,7 @@ namespace CalamityMod.Projectiles { ProjectileID.TerrarianBeam, Do(LocalIFrames(-1)) }, // Terrarian yoyo orbs // original: INF lifetime | 360px range | 16.5px/f top speed | 0 extra updates - { ProjectileID.TheEyeOfCthulhu, RebalanceYoyo(-1f, 480f, 36f, 1) }, // the yoyo, of course + { ProjectileID.TheEyeOfCthulhu, RebalanceYoyo(-1f, 480f, 36f, 1, 12) }, // the yoyo, of course // original: INF lifetime | 370px range | 16px/f top speed | 0 extra updates { ProjectileID.ValkyrieYoyo, RebalanceYoyo(-1f, 480f, 42f, 2, 12) }, @@ -116,61 +114,60 @@ namespace CalamityMod.Projectiles { ProjectileID.AdamantiteChainsaw, standardChainsawTweaks }, { ProjectileID.AdamantiteDrill, standardDrillTweaks }, { ProjectileID.AdamantiteGlaive, Do(TrueMelee, LocalIFrames(7)) }, - { ProjectileID.Anchor, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.Arkhalis, Do(TrueMeleeNoSpeed, ScaleExact(1.25f)) }, - { ProjectileID.Bee, Do(PiercingExact(2)) }, - { ProjectileID.BeeArrow, Do(PointBlank, ExtraUpdatesExact(1)) }, + { ProjectileID.Anchor, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.Arkhalis, Do(TrueMeleeNoSpeed, ScaleExact(1.25f), IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.Bee, Do(PiercingExact(2), DefaultIDStaticIFrames) }, + { ProjectileID.BeeArrow, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.BlackCounterweight, counterweightTweaks }, { ProjectileID.BlueCounterweight, counterweightTweaks }, { ProjectileID.BlueMoon, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.Bullet, standardBulletTweaks }, - { ProjectileID.BulletHighVelocity, Do(PointBlank, LocalIFrames(-1)) }, - { ProjectileID.ButchersChainsaw, Do(TrueMeleeNoSpeed, ArmorPenetrationDelta(+15), LocalIFrames(5), ScaleExact(1.5f)) }, + { ProjectileID.Bullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, + { ProjectileID.BulletHighVelocity, Do(ExtraUpdatesDelta(+2), LocalIFrames(-1)) }, + { ProjectileID.ButchersChainsaw, Do(TrueMeleeNoSpeed, ArmorPenetrationDelta(+15), LocalIFrames(7), ScaleExact(1.5f)) }, { ProjectileID.ChlorophyteChainsaw, standardChainsawTweaks }, { ProjectileID.ChlorophyteDrill, standardDrillTweaks }, { ProjectileID.ChlorophyteOrb, Do(NoPiercing) }, { ProjectileID.CobaltChainsaw, standardChainsawTweaks }, { ProjectileID.CobaltDrill, standardDrillTweaks }, { ProjectileID.CobaltNaginata, Do(TrueMelee, LocalIFrames(9)) }, - { ProjectileID.CrystalBullet, standardBulletTweaks }, - { ProjectileID.CrystalVileShardHead, Do(LocalIFrames(23)) }, - { ProjectileID.CrystalVileShardShaft, Do(LocalIFrames(23)) }, - { ProjectileID.CursedBullet, standardBulletTweaks }, + { ProjectileID.CrystalBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, + { ProjectileID.CursedBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, { ProjectileID.ClusterRocketI, Do(LocalIFrames(15)) }, { ProjectileID.ClusterFragmentsI, Do(IDStaticIFrames(15)) }, { ProjectileID.ClusterRocketII, Do(LocalIFrames(15)) }, { ProjectileID.ClusterFragmentsII, Do(IDStaticIFrames(15)) }, - { ProjectileID.ClusterSnowmanRocketI, Do(LocalIFrames(15)) }, + { ProjectileID.ClusterSnowmanRocketI, Do(LocalIFrames(15)) }, { ProjectileID.ClusterSnowmanRocketII, Do(LocalIFrames(15)) }, - { ProjectileID.DD2SquireSonicBoom, Do(PiercingExact(3)) }, // Flying Dragon + { ProjectileID.DangerousSpider, Do( ExtraUpdatesExact(2), LocalIFrames(45)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. + { ProjectileID.DD2SquireSonicBoom, Do(PiercingExact(3), DefaultIDStaticIFrames) }, // Flying Dragon + { ProjectileID.DeadlySphere, Do(LocalIFrames(30)) }, { ProjectileID.EmeraldBolt, Do(NoPiercing) }, - { ProjectileID.EmpressBlade, Do(LocalIFrames(30)) }, // Terraprisma - { ProjectileID.EnchantedBoomerang, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.ExplosiveBullet, standardBulletTweaks }, + { ProjectileID.EnchantedBoomerang, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.ExplosiveBullet, Do(ExtraUpdatesDelta(+2), IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes { ProjectileID.FairyQueenRangedItemShot, Do(PiercingExact(7), ExtraUpdatesExact(1)) }, // Eventide Convert - { ProjectileID.FlaironBubble, Do(ExtraUpdatesExact(1), TimeLeftExact(150)) }, - { ProjectileID.Flamarang, Do(ExtraUpdatesExact(2)) }, - { ProjectileID.Flames, Do(IDStaticIFrames(5)) }, // Flamethrower AND Elf Melter flames - { ProjectileID.FlamingJack, Do(ExtraUpdatesExact(1)) }, + { ProjectileID.FlaironBubble, Do(ExtraUpdatesExact(1), TimeLeftExact(150), DefaultIDStaticIFrames) }, + { ProjectileID.Flamarang, Do(ExtraUpdatesExact(2), DefaultIDStaticIFrames) }, + { ProjectileID.FlamingJack, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.FlowerPetal, Do(MaxUpdatesExact(4), LocalIFrames(10)) }, // Orichalcum armor - { ProjectileID.FlowerPow, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.FlyingKnife, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.FrostBoltStaff, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.FruitcakeChakram, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.GiantBee, Do(PiercingExact(2)) }, + { ProjectileID.FlyingKnife, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.FrostBoltStaff, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.FruitcakeChakram, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.GiantBee, Do(PiercingExact(2), DefaultIDStaticIFrames) }, { ProjectileID.GladiusStab, Do(TrueMelee, LocalIFrames(-1)) }, - { ProjectileID.GoldenBullet, standardBulletTweaks }, - { ProjectileID.GoldenShowerFriendly, Do(PiercingExact(2)) }, + { ProjectileID.GoldenBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, + { ProjectileID.GoldenShowerFriendly, Do(PiercingExact(2), DefaultIDStaticIFrames) }, { ProjectileID.GreenCounterweight, counterweightTweaks }, { ProjectileID.Hamdrax, standardDrillTweaks }, // Drax (never internally renamed since 1.1) - { ProjectileID.IceBoomerang, Do(ExtraUpdatesExact(1)) }, + { ProjectileID.HellfireArrow, Do(ExtraUpdatesDelta(+2)) }, + { ProjectileID.IceBoomerang, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.IceSickle, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.IchorBullet, standardBulletTweaks }, + { ProjectileID.IchorBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, { ProjectileID.InfluxWaver, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.InfernoFriendlyBolt, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.InfernoFriendlyBlast, Do(ExtraUpdatesExact(2)) }, + { ProjectileID.InfernoFriendlyBolt, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.InfernoFriendlyBlast, Do(ExtraUpdatesExact(2), DefaultIDStaticIFrames) }, + { ProjectileID.JumperSpider, Do( ExtraUpdatesExact(2), LocalIFrames(45)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. { ProjectileID.LaserDrill, Do(ArmorPenetrationDelta(+25), LocalIFrames(5)) }, - { ProjectileID.LightDisc, Do(MaxUpdatesExact(3)) }, + { ProjectileID.LightDisc, Do(MaxUpdatesExact(3), DefaultIDStaticIFrames) }, { ProjectileID.LostSoulHostile, Do(TileCollide) }, // Ragged Caster { ProjectileID.MeteorShot, standardBulletTweaks }, { ProjectileID.Meowmere, Do(PiercingExact(3), LocalIFrames(-1)) }, @@ -181,15 +178,14 @@ namespace CalamityMod.Projectiles { ProjectileID.MythrilChainsaw, standardChainsawTweaks }, { ProjectileID.MythrilDrill, standardDrillTweaks }, { ProjectileID.MythrilHalberd, Do(TrueMelee, LocalIFrames(8)) }, - { ProjectileID.NanoBullet, standardBulletTweaks }, + { ProjectileID.NanoBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, { ProjectileID.NebulaDrill, standardDrillTweaks }, { ProjectileID.NebulaLaser, Do(ExtraUpdatesDelta(-1)) }, { ProjectileID.OrichalcumChainsaw, standardChainsawTweaks }, { ProjectileID.OrichalcumDrill, standardDrillTweaks }, { ProjectileID.PalladiumChainsaw, standardChainsawTweaks }, { ProjectileID.PalladiumDrill, standardDrillTweaks }, - { ProjectileID.PartyBullet, standardBulletTweaks }, - { ProjectileID.PoisonFang, Do(LocalIFrames(10)) }, + { ProjectileID.PartyBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, { ProjectileID.PurpleCounterweight, counterweightTweaks }, { ProjectileID.QueenSlimeGelAttack, Do(NoPiercing) }, { ProjectileID.QueenSlimeMinionPinkBall, Do(NoPiercing) }, @@ -199,22 +195,21 @@ namespace CalamityMod.Projectiles { ProjectileID.RocketFireworkRed, Do(TimeLeftDelta(+45)) }, { ProjectileID.RocketFireworkYellow, Do(TimeLeftDelta(+45)) }, { ProjectileID.SawtoothShark, Do(TrueMeleeNoSpeed, ArmorPenetrationDelta(+15), LocalIFrames(6)) }, - { ProjectileID.ShadowBeamHostile, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.Shroomerang, Do(ExtraUpdatesExact(1)) }, + { ProjectileID.Shroomerang, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.SolarFlareDrill, standardDrillTweaks }, { ProjectileID.StardustDrill, standardDrillTweaks }, - { ProjectileID.Starfury, Do(TimeLeftExact(75)) }, + { ProjectileID.Starfury, Do(TimeLeftExact(75), DefaultIDStaticIFrames) }, { ProjectileID.StarWrath, Do(NoPiercing) }, { ProjectileID.Sunfury, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.SwordBeam, Do(ExtraUpdatesExact(2)) }, // Beam Sword projectile - { ProjectileID.Terragrim, Do(TrueMeleeNoSpeed, ScaleExact(1.25f)) }, - { ProjectileID.ThunderStaffShot, Do(PiercingExact(3)) }, //Thunder Zapper projectile + { ProjectileID.SwordBeam, Do(ExtraUpdatesExact(2), DefaultIDStaticIFrames) }, // Beam Sword projectile + { ProjectileID.Terragrim, Do(TrueMeleeNoSpeed, ScaleExact(1.25f), IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.ThunderStaffShot, Do(PiercingExact(3), DefaultIDStaticIFrames) }, //Thunder Zapper projectile { ProjectileID.TitaniumChainsaw, standardChainsawTweaks }, { ProjectileID.TitaniumDrill, standardDrillTweaks }, - { ProjectileID.Trimarang, Do(ExtraUpdatesExact(1)) }, + { ProjectileID.Trimarang, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.TrueNightsEdge, Do(PiercingExact(4)) }, - { ProjectileID.VenomBullet, standardBulletTweaks }, - { ProjectileID.VenomFang, Do(LocalIFrames(10)) }, + { ProjectileID.VenomBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, + { ProjectileID.VenomSpider, Do( ExtraUpdatesExact(2), LocalIFrames(45)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. { ProjectileID.VortexDrill, standardDrillTweaks }, { ProjectileID.Wasp, Do(PiercingExact(2)) }, { ProjectileID.WeatherPainShot, Do(ExtraUpdatesExact(3), TimeLeftExact(1920)) }, @@ -236,7 +231,7 @@ namespace CalamityMod.Projectiles { ProjectileID.ObsidianSwordfish, trueMelee }, { ProjectileID.OrichalcumHalberd, trueMelee }, { ProjectileID.PalladiumPike, trueMelee }, - { ProjectileID.PiercingStarlight, trueMelee }, + { ProjectileID.PiercingStarlight, Do(TrueMelee, IDStaticIFrames(4)) }, // Has an exception in Vanilla iframe code, uses 4 iframes { ProjectileID.PlatinumShortswordStab, trueMelee }, { ProjectileID.RulerStab, trueMelee }, { ProjectileID.ShadowJoustingLance, trueMelee }, @@ -253,80 +248,361 @@ namespace CalamityMod.Projectiles { ProjectileID.VortexChainsaw, trueMeleeNoSpeed }, #endregion - #region CATEGORY 4: Point Blank support - { ProjectileID.Blizzard, pointBlank }, // Blizzard Staff projectiles, re-used in Frostbite Blaster. - { ProjectileID.BlueFlare, pointBlank }, - { ProjectileID.BoneArrow, pointBlank }, - { ProjectileID.CandyCorn, pointBlank }, - { ProjectileID.ChlorophyteArrow, pointBlank }, - { ProjectileID.ChlorophyteBullet, pointBlank }, - { ProjectileID.CrimsandBallGun, pointBlank }, - { ProjectileID.CrystalDart, pointBlank }, - { ProjectileID.CursedArrow, pointBlank }, - { ProjectileID.CursedDart, pointBlank }, - { ProjectileID.DD2PhoenixBowShot, pointBlank }, // Phantom Phoenix - { ProjectileID.EbonsandBallGun, pointBlank }, - { ProjectileID.FireArrow, pointBlank }, - { ProjectileID.Flare, pointBlank }, - { ProjectileID.FrostburnArrow, pointBlank }, - { ProjectileID.Harpoon, pointBlank }, - { ProjectileID.Hellwing, pointBlank }, - { ProjectileID.HellfireArrow, pointBlank }, - { ProjectileID.HolyArrow, pointBlank }, - { ProjectileID.IchorArrow, pointBlank }, - { ProjectileID.JestersArrow, pointBlank }, - { ProjectileID.MoonlordArrow, pointBlank }, // Luminite Arrow - { ProjectileID.PainterPaintball, pointBlank }, - { ProjectileID.PearlSandBallGun, pointBlank }, - { ProjectileID.PhantasmArrow, pointBlank }, - { ProjectileID.PoisonDartBlowgun, pointBlank }, - { ProjectileID.PulseBolt, pointBlank }, - { ProjectileID.SandBallGun, pointBlank }, - { ProjectileID.Seed, pointBlank }, - { ProjectileID.ShadowFlameArrow, pointBlank }, - { ProjectileID.SnowBallFriendly, pointBlank }, - { ProjectileID.Stake, pointBlank }, - { ProjectileID.UnholyArrow, pointBlank }, - { ProjectileID.VenomArrow, pointBlank }, - { ProjectileID.WoodenArrowFriendly, pointBlank }, - #endregion - - #region CATEGORY 5: Defense Damage support - { ProjectileID.BombSkeletronPrime, defenseDamage }, - { ProjectileID.CannonballHostile, defenseDamage }, + #region CATEGORY 4: Defense Damage support { ProjectileID.Cthulunado, defenseDamage }, // Duke Fishron's larger Sharknados - { ProjectileID.CultistBossFireBall, defenseDamage }, - { ProjectileID.CultistBossFireBallClone, defenseDamage }, - { ProjectileID.CultistBossIceMist, defenseDamage }, - { ProjectileID.CultistBossLightningOrbArc, defenseDamage }, - { ProjectileID.DD2BetsyFireball, defenseDamage }, { ProjectileID.DD2BetsyFlameBreath, defenseDamage }, { ProjectileID.DeerclopsIceSpike, defenseDamage }, - { ProjectileID.DeerclopsRangedProjectile, defenseDamage }, // Deerclops shadow hands - { ProjectileID.DemonSickle, defenseDamage }, - { ProjectileID.FairyQueenLance, defenseDamage }, // Empress of Light's lance walls { ProjectileID.FairyQueenSunDance, defenseDamage }, // Empress of Light's Sun Dance { ProjectileID.FlamingScythe, defenseDamage }, // Pumpking orange spinning scythes - { ProjectileID.FrostWave, defenseDamage }, // Ice Queen frost waves - { ProjectileID.HallowBossLastingRainbow, defenseDamage }, // Empress of Light's lingering rainbow trail hitboxes { ProjectileID.InfernoHostileBlast, defenseDamage }, // Diabolist inferno fork explosions - { ProjectileID.JavelinHostile, defenseDamage }, { ProjectileID.PaladinsHammerHostile, defenseDamage }, { ProjectileID.PhantasmalDeathray, defenseDamage }, { ProjectileID.PhantasmalSphere, defenseDamage }, - { ProjectileID.Present, defenseDamage }, // Falling present bombs in Frost Moon - { ProjectileID.RocketSkeleton, defenseDamage }, // Skeleton Commando rockets - { ProjectileID.RockGolemRock, defenseDamage }, - { ProjectileID.RuneBlast, defenseDamage }, // Rune Wizard shots { ProjectileID.SaucerDeathray, defenseDamage }, - { ProjectileID.SaucerMissile, defenseDamage }, { ProjectileID.Sharknado, defenseDamage }, - { ProjectileID.Skull, defenseDamage }, // Skeletron Expert+ skulls - { ProjectileID.SniperBullet, defenseDamage }, // Skeleton Sniper bullets - { ProjectileID.Spike, defenseDamage }, // Santank spike balls { ProjectileID.ThornBall, Do(Main.zenithWorld ? IgnoreWater : DontIgnoreWater, DefenseDamage) }, // Plantera bouncing thorn balls - { ProjectileID.UnholyTridentHostile, defenseDamage }, #endregion + + #region CATEGORY 5: ID-Static Immunity Frame changes + { ProjectileID.AbigailCounter, defaultIFrames }, + { ProjectileID.Ale, defaultIFrames }, + { ProjectileID.AmberBolt, defaultIFrames }, + { ProjectileID.AmethystBolt, defaultIFrames }, + { ProjectileID.AshBallFalling, defaultIFrames }, + { ProjectileID.BallofFire, defaultIFrames }, + { ProjectileID.BallofFrost, defaultIFrames }, + { ProjectileID.Bananarang, defaultIFrames }, + { ProjectileID.Bat, defaultIFrames }, + { ProjectileID.BeeHive, defaultIFrames }, + { ProjectileID.Beenade, defaultIFrames }, + { ProjectileID.BlackCat, defaultIFrames }, + { ProjectileID.Blizzard, defaultIFrames }, // Blizzard Staff projectiles, re-used in Frostbite Blaster. + { ProjectileID.BloodArrow, defaultIFrames }, + { ProjectileID.BloodButcherer, defaultIFrames }, + { ProjectileID.BloodNautilusTears, defaultIFrames }, + { ProjectileID.BloodWater, defaultIFrames }, + { ProjectileID.BloodyMachete, defaultIFrames }, + { ProjectileID.BlueFlare, defaultIFrames }, + { ProjectileID.Bomb, defaultIFrames }, + { ProjectileID.BombFish, defaultIFrames }, + { ProjectileID.Bone, defaultIFrames }, + { ProjectileID.BoneArrow, defaultIFrames }, + { ProjectileID.BoneArrowFromMerchant, defaultIFrames }, + { ProjectileID.BoneDagger, defaultIFrames }, + { ProjectileID.BookOfSkullsSkull, defaultIFrames }, + { ProjectileID.BookStaffShot, defaultIFrames }, + { ProjectileID.Boulder, defaultIFrames }, + { ProjectileID.BoulderStaffOfEarth, defaultIFrames }, + { ProjectileID.BouncyBomb, defaultIFrames }, + { ProjectileID.BouncyBoulder, defaultIFrames }, + { ProjectileID.BouncyDynamite, defaultIFrames }, + { ProjectileID.BouncyGrenade, defaultIFrames }, + { ProjectileID.BoxingGlove, defaultIFrames }, + { ProjectileID.Bubble, defaultIFrames }, + { ProjectileID.Bunny, defaultIFrames }, + { ProjectileID.CandyCorn, Do(IDStaticIFrames(7)) }, // Has an exception in Vanilla iframe code, uses 7 iframes + { ProjectileID.CannonballFriendly, defaultIFrames }, + { ProjectileID.CavelingGardener, defaultIFrames }, + { ProjectileID.Celeb2Rocket, defaultIFrames }, + { ProjectileID.Celeb2RocketExplosive, defaultIFrames }, + { ProjectileID.Celeb2RocketExplosiveLarge, defaultIFrames }, + { ProjectileID.Celeb2RocketLarge, defaultIFrames }, + { ProjectileID.Celeb2Weapon, defaultIFrames }, + { ProjectileID.ChainGuillotine, defaultIFrames }, + { ProjectileID.ChainKnife, defaultIFrames }, + { ProjectileID.ChargedBlasterCannon, defaultIFrames }, + { ProjectileID.ChargedBlasterLaser, defaultIFrames }, + { ProjectileID.ChargedBlasterOrb, defaultIFrames }, + { ProjectileID.ChlorophyteArrow, defaultIFrames }, + { ProjectileID.ChlorophyteBullet, defaultIFrames }, + { ProjectileID.ChlorophytePartisan, defaultIFrames }, + { ProjectileID.ClothiersCurse, defaultIFrames }, + { ProjectileID.ClusterMineI, defaultIFrames }, + { ProjectileID.ClusterMineII, defaultIFrames }, + { ProjectileID.ClusterSnowmanFragmentsI, defaultIFrames }, + { ProjectileID.ClusterSnowmanFragmentsII, defaultIFrames }, + { ProjectileID.CoinPortal, defaultIFrames }, + { ProjectileID.CopperCoin, defaultIFrames }, + { ProjectileID.CorruptSpray, defaultIFrames }, + { ProjectileID.CrimsandBallFalling, defaultIFrames }, + { ProjectileID.CrimsandBallGun, defaultIFrames }, + { ProjectileID.CrimsonHeart, defaultIFrames }, + { ProjectileID.CrimsonSpray, defaultIFrames }, + { ProjectileID.CrystalDart, Do( ExtraUpdatesExact(2), LocalIFrames(-1)) }, + { ProjectileID.CrystalLeaf, defaultIFrames }, + { ProjectileID.CrystalLeafShot, defaultIFrames }, + { ProjectileID.CrystalPulse, defaultIFrames }, + { ProjectileID.CrystalPulse2, defaultIFrames }, + { ProjectileID.CrystalShard, defaultIFrames }, + { ProjectileID.CrystalStorm, defaultIFrames }, + { ProjectileID.CrystalVileShardHead, defaultIFrames }, + { ProjectileID.CrystalVileShardShaft, defaultIFrames }, + { ProjectileID.CursedArrow, defaultIFrames }, + { ProjectileID.CursedDart, Do( ExtraUpdatesExact(1), LocalIFrames(20)) }, + { ProjectileID.CursedDartFlame, defaultIFrames }, + { ProjectileID.CursedFlameFriendly, defaultIFrames }, + { ProjectileID.CursedFlare, defaultIFrames }, + { ProjectileID.DD2PhoenixBow, defaultIFrames }, + { ProjectileID.DemonScythe, defaultIFrames }, + { ProjectileID.DiamondBolt, defaultIFrames }, + { ProjectileID.DirtBall, defaultIFrames }, + { ProjectileID.DirtBomb, defaultIFrames }, + { ProjectileID.DirtSpray, defaultIFrames }, + { ProjectileID.DirtStickyBomb, defaultIFrames }, + { ProjectileID.DripplerFlailExtraBall, defaultIFrames }, + { ProjectileID.DryadsWardCircle, defaultIFrames }, + { ProjectileID.DryBomb, defaultIFrames }, + { ProjectileID.DryMine, defaultIFrames }, + { ProjectileID.DryRocket, defaultIFrames }, + { ProjectileID.DrySnowmanRocket, defaultIFrames }, + { ProjectileID.Dynamite, defaultIFrames }, + { ProjectileID.EatersBite, defaultIFrames }, + { ProjectileID.EbonsandBallFalling, defaultIFrames }, + { ProjectileID.EbonsandBallGun, defaultIFrames }, + { ProjectileID.EighthNote, defaultIFrames }, + { ProjectileID.Electrosphere, Do(IDStaticIFrames(8)) }, // Has an exception in Vanilla iframe code, uses 8 iframes + { ProjectileID.ElectrosphereMissile, defaultIFrames }, + { ProjectileID.EnchantedBeam, defaultIFrames }, + { ProjectileID.Explosives, defaultIFrames }, + { ProjectileID.FallingStar, defaultIFrames }, + { ProjectileID.FireArrow, defaultIFrames }, + { ProjectileID.Flairon, defaultIFrames }, + { ProjectileID.FlamesTrap, defaultIFrames }, + { ProjectileID.Flare, defaultIFrames }, + { ProjectileID.FlowerPowPetal, defaultIFrames }, + { ProjectileID.FrostArrow, defaultIFrames }, + { ProjectileID.FrostburnArrow, defaultIFrames }, + { ProjectileID.FrostDaggerfish, defaultIFrames }, + { ProjectileID.GasTrap, defaultIFrames }, + { ProjectileID.GelBalloon, defaultIFrames }, + { ProjectileID.Geode, defaultIFrames }, + { ProjectileID.GeyserTrap, defaultIFrames }, + { ProjectileID.GoldCoin, defaultIFrames }, + { ProjectileID.GolemFist, defaultIFrames }, + { ProjectileID.GreenLaser, defaultIFrames }, + { ProjectileID.Grenade, defaultIFrames }, + { ProjectileID.HallowSpray, defaultIFrames }, + { ProjectileID.HallowStar, defaultIFrames }, + { ProjectileID.Hellwing, defaultIFrames }, + { ProjectileID.HolyArrow, defaultIFrames }, + { ProjectileID.HeatRay, Do(DefaultIDStaticIFrames) }, + { ProjectileID.HolyWater, defaultIFrames }, + { ProjectileID.HoneyBomb, defaultIFrames }, + { ProjectileID.HoneyGrenade, defaultIFrames }, + { ProjectileID.HoneyMine, defaultIFrames }, + { ProjectileID.HoneyRocket, defaultIFrames }, + { ProjectileID.HoneySnowmanRocket, defaultIFrames }, + { ProjectileID.HornetStinger, defaultIFrames }, + { ProjectileID.HoundiusShootiusFireball, defaultIFrames }, + { ProjectileID.IceBlock, defaultIFrames }, + { ProjectileID.IceBolt, defaultIFrames }, + { ProjectileID.IchorArrow, defaultIFrames }, + { ProjectileID.IchorDart, Do( ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.JackOLantern, defaultIFrames }, + { ProjectileID.JavelinFriendly, defaultIFrames }, + { ProjectileID.JestersArrow, defaultIFrames }, + { ProjectileID.Landmine, defaultIFrames }, + { ProjectileID.LaserMachinegun, defaultIFrames }, + { ProjectileID.LaserMachinegunLaser, defaultIFrames }, + { ProjectileID.LastPrism, defaultIFrames }, + { ProjectileID.LastPrismLaser, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.LavaBomb, defaultIFrames }, + { ProjectileID.LavaMine, defaultIFrames }, + { ProjectileID.LavaRocket, defaultIFrames }, + { ProjectileID.LavaSnowmanRocket, defaultIFrames }, + { ProjectileID.Leaf, defaultIFrames }, + { ProjectileID.LifeCrystalBoulder, defaultIFrames }, + { ProjectileID.MagicMissile, Do(IDStaticIFrames(8)) }, // Has an exception in Vanilla iframe code, uses 8 iframes + { ProjectileID.MagnetSphereBolt, defaultIFrames }, + { ProjectileID.MedusaHead, defaultIFrames }, + { ProjectileID.MedusaHeadRay, defaultIFrames }, + { ProjectileID.Meteor1, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.Meteor2, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.Meteor3, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.MinecartMechLaser, defaultIFrames }, + { ProjectileID.MiniBoulder, defaultIFrames }, + { ProjectileID.MiniMinotaur, defaultIFrames }, + { ProjectileID.MiniNukeMineI, defaultIFrames }, + { ProjectileID.MiniNukeMineII, defaultIFrames }, + { ProjectileID.MiniNukeRocketI, defaultIFrames }, + { ProjectileID.MiniNukeRocketII, defaultIFrames }, + { ProjectileID.MiniNukeSnowmanRocketI, defaultIFrames }, + { ProjectileID.MiniNukeSnowmanRocketII, defaultIFrames }, + { ProjectileID.MiniRetinaLaser, defaultIFrames }, + { ProjectileID.MiniSharkron, defaultIFrames }, + { ProjectileID.MolotovCocktail, defaultIFrames }, + { ProjectileID.MolotovFire, defaultIFrames }, + { ProjectileID.MolotovFire2, defaultIFrames }, + { ProjectileID.MolotovFire3, defaultIFrames }, + { ProjectileID.MonkStaffT3_AltShot, defaultIFrames }, + { ProjectileID.MudBall, defaultIFrames }, + { ProjectileID.Mushroom, defaultIFrames }, + { ProjectileID.MushroomSpray, defaultIFrames }, + { ProjectileID.NailFriendly, Do(IDStaticIFrames(1)) }, // Has an exception in Vanilla iframe code, uses 1 iframe + { ProjectileID.NebulaArcanumExplosionShot, defaultIFrames }, + { ProjectileID.NebulaArcanumExplosionShotShard, defaultIFrames }, + { ProjectileID.NebulaBlaze1, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.NebulaBlaze2, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.NettleBurstEnd, defaultIFrames }, + { ProjectileID.NettleBurstLeft, defaultIFrames }, + { ProjectileID.NettleBurstRight, defaultIFrames }, + { ProjectileID.NightBeam, defaultIFrames }, + { ProjectileID.NorthPoleSnowflake, defaultIFrames }, + { ProjectileID.NorthPoleSpear, defaultIFrames }, + { ProjectileID.NorthPoleWeapon, defaultIFrames }, + { ProjectileID.NurseSyringeHeal, defaultIFrames }, + { ProjectileID.NurseSyringeHurt, defaultIFrames }, + { ProjectileID.OrnamentFriendly, defaultIFrames }, + { ProjectileID.OrnamentStar, defaultIFrames }, + { ProjectileID.PainterPaintball, defaultIFrames }, + { ProjectileID.PaladinsHammerFriendly, defaultIFrames }, + { ProjectileID.PaperAirplaneA, defaultIFrames }, + { ProjectileID.PaperAirplaneB, defaultIFrames }, + { ProjectileID.PartyGirlGrenade, defaultIFrames }, + { ProjectileID.PearlSandBallFalling, defaultIFrames }, + { ProjectileID.PearlSandBallGun, defaultIFrames }, + { ProjectileID.PewMaticHornShot, defaultIFrames }, + { ProjectileID.Phantasm, defaultIFrames }, + { ProjectileID.PhantasmArrow, defaultIFrames }, + { ProjectileID.PineNeedleFriendly, defaultIFrames }, + { ProjectileID.PlatinumCoin, defaultIFrames }, + { ProjectileID.PoisonDart, Do( ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.PoisonDartBlowgun, defaultIFrames }, + { ProjectileID.PoisonDartTrap, defaultIFrames }, + { ProjectileID.PoisonedKnife, defaultIFrames }, + { ProjectileID.PossessedHatchet, defaultIFrames }, + { ProjectileID.PrincessWeapon, defaultIFrames }, + { ProjectileID.ProximityMineI, defaultIFrames }, + { ProjectileID.ProximityMineII, defaultIFrames }, + { ProjectileID.ProximityMineIII, defaultIFrames }, + { ProjectileID.ProximityMineIV, defaultIFrames }, + { ProjectileID.PulseBolt, defaultIFrames }, + { ProjectileID.PureSpray, defaultIFrames }, + { ProjectileID.PurificationPowder, defaultIFrames }, + { ProjectileID.PurpleLaser, defaultIFrames }, + { ProjectileID.PygmySpear, defaultIFrames }, + { ProjectileID.QuarterNote, defaultIFrames }, + { ProjectileID.RainbowFlare, defaultIFrames }, + { ProjectileID.RocketFireworksBoxBlue, defaultIFrames }, + { ProjectileID.RocketFireworksBoxGreen, defaultIFrames }, + { ProjectileID.RocketFireworksBoxRed, defaultIFrames }, + { ProjectileID.RocketFireworksBoxYellow, defaultIFrames }, + { ProjectileID.RocketI, defaultIFrames }, + { ProjectileID.RocketII, defaultIFrames }, + { ProjectileID.RocketIII, defaultIFrames }, + { ProjectileID.RocketIV, defaultIFrames }, + { ProjectileID.RocketSnowmanI, defaultIFrames }, + { ProjectileID.RocketSnowmanII, defaultIFrames }, + { ProjectileID.RocketSnowmanIII, defaultIFrames }, + { ProjectileID.RocketSnowmanIV, defaultIFrames }, + { ProjectileID.RollingCactus, defaultIFrames }, + { ProjectileID.RollingCactusSpike, defaultIFrames }, + { ProjectileID.RottenEgg, defaultIFrames }, + { ProjectileID.RubyBolt, defaultIFrames }, + { ProjectileID.SandBallFalling, defaultIFrames }, + { ProjectileID.SandBallGun, defaultIFrames }, + { ProjectileID.SandSpray, defaultIFrames }, + { ProjectileID.SantaBombs, defaultIFrames }, + { ProjectileID.SantankMountRocket, defaultIFrames }, + { ProjectileID.SapphireBolt, defaultIFrames }, + { ProjectileID.ScarabBomb, defaultIFrames }, + { ProjectileID.ScutlixLaser, defaultIFrames }, + { ProjectileID.ScutlixLaserFriendly, defaultIFrames }, + { ProjectileID.Seed, defaultIFrames }, + { ProjectileID.SeedlerNut, defaultIFrames }, + { ProjectileID.SeedlerThorn, defaultIFrames }, + { ProjectileID.ShadowBeamFriendly, defaultIFrames }, + { ProjectileID.ShadowFlameArrow, defaultIFrames }, + { ProjectileID.ShadowFlameKnife, defaultIFrames }, + { ProjectileID.ShellPileFalling, defaultIFrames }, + { ProjectileID.ShimmerArrow, defaultIFrames }, + { ProjectileID.ShimmerFlare, defaultIFrames }, + { ProjectileID.Shuriken, defaultIFrames }, + { ProjectileID.SiltBall, defaultIFrames }, + { ProjectileID.SilverBullet, defaultIFrames }, + { ProjectileID.SilverCoin, defaultIFrames }, + { ProjectileID.SkyFracture, defaultIFrames }, + { ProjectileID.SlushBall, defaultIFrames }, + { ProjectileID.SnowBallFriendly, defaultIFrames }, + { ProjectileID.SnowSpray, defaultIFrames }, + { ProjectileID.SolarCounter, defaultIFrames }, + { ProjectileID.SolarFlareRay, defaultIFrames }, + { ProjectileID.SoulDrain, defaultIFrames }, + { ProjectileID.SpearTrap, defaultIFrames }, + { ProjectileID.SpelunkerFlare, defaultIFrames }, + { ProjectileID.Spider, defaultIFrames }, + { ProjectileID.SpiderEgg, defaultIFrames }, + { ProjectileID.SpikyBall, defaultIFrames }, + { ProjectileID.SpikyBallTrap, defaultIFrames }, + { ProjectileID.SpiritFlame, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.SporeGas, defaultIFrames }, + { ProjectileID.SporeGas2, defaultIFrames }, + { ProjectileID.SporeGas3, defaultIFrames }, + { ProjectileID.SporeTrap, defaultIFrames }, + { ProjectileID.SporeTrap2, defaultIFrames }, + { ProjectileID.Stake, defaultIFrames }, + { ProjectileID.StarAnise, defaultIFrames }, + { ProjectileID.StarCannonStar, defaultIFrames }, + { ProjectileID.StardustCellMinion, defaultIFrames }, + { ProjectileID.StardustGuardianExplosion, defaultIFrames }, + { ProjectileID.StickyBomb, defaultIFrames }, + { ProjectileID.StickyDynamite, defaultIFrames }, + { ProjectileID.StickyGrenade, defaultIFrames }, + { ProjectileID.StormTigerGem, defaultIFrames }, + { ProjectileID.Stynger, Do(IDStaticIFrames(7)) }, // Has an exception in Vanilla iframe code, uses 7 iframes + { ProjectileID.StyngerShrapnel, defaultIFrames }, + { ProjectileID.TentacleSpike, defaultIFrames }, + { ProjectileID.ThornChakram, defaultIFrames }, + { ProjectileID.ThrowingKnife, defaultIFrames }, + { ProjectileID.ThunderSpear, defaultIFrames }, + { ProjectileID.ThunderSpearShot, defaultIFrames }, + { ProjectileID.TiedEighthNote, defaultIFrames }, + { ProjectileID.TitaniumStormShard, defaultIFrames }, + { ProjectileID.TopazBolt, defaultIFrames }, + { ProjectileID.ToxicBubble, defaultIFrames }, + { ProjectileID.ToxicCloud, defaultIFrames }, + { ProjectileID.ToxicCloud2, defaultIFrames }, + { ProjectileID.ToxicCloud3, defaultIFrames }, + { ProjectileID.ToxicFlask, defaultIFrames }, + { ProjectileID.Truffle, defaultIFrames }, + { ProjectileID.TruffleSpore, defaultIFrames }, + { ProjectileID.Typhoon, Do(IDStaticIFrames(6)) }, // Has an exception in Vanilla iframe code, uses 6 iframes + { ProjectileID.UFOLaser, defaultIFrames }, + { ProjectileID.UFOMinion, defaultIFrames }, + { ProjectileID.UnholyArrow, defaultIFrames }, + { ProjectileID.UnholyTridentFriendly, defaultIFrames }, + { ProjectileID.UnholyWater, defaultIFrames }, + { ProjectileID.VampireKnife, defaultIFrames }, + { ProjectileID.VenomArrow, defaultIFrames }, + { ProjectileID.VenomDartTrap, defaultIFrames }, + { ProjectileID.ViciousPowder, defaultIFrames }, + { ProjectileID.VilePowder, defaultIFrames }, + { ProjectileID.VilethornBase, defaultIFrames }, + { ProjectileID.VilethornTip, defaultIFrames }, + { ProjectileID.VortexBeater, defaultIFrames }, + { ProjectileID.VortexBeaterRocket, defaultIFrames }, + { ProjectileID.VortexVortexLightning, defaultIFrames }, + { ProjectileID.VortexVortexPortal, defaultIFrames }, + { ProjectileID.Waffle, defaultIFrames }, + { ProjectileID.WandOfFrostingFrost, defaultIFrames }, + { ProjectileID.WandOfSparkingSpark, defaultIFrames }, + { ProjectileID.WaterBolt, defaultIFrames }, + { ProjectileID.WaterStream, defaultIFrames }, + { ProjectileID.Web, defaultIFrames }, + { ProjectileID.WetBomb, defaultIFrames }, + { ProjectileID.WetMine, defaultIFrames }, + { ProjectileID.WetRocket, defaultIFrames }, + { ProjectileID.WetSnowmanRocket, defaultIFrames }, + { ProjectileID.Wisp, defaultIFrames }, + { ProjectileID.WoodenArrowFriendly, defaultIFrames }, + { ProjectileID.WoodenBoomerang, defaultIFrames }, + { ProjectileID.Xenopopper, defaultIFrames }, + { ProjectileID.ZapinatorLaser, defaultIFrames }, + { ProjectileID.ZoologistStrikeGreen, defaultIFrames }, + { ProjectileID.ZoologistStrikeRed, defaultIFrames }, + + #endregion + }; } @@ -472,6 +748,7 @@ namespace CalamityMod.Projectiles } } internal static IProjectileTweak IDStaticIFrames(int f) => new IDStaticIFrameRule(f); + internal static IProjectileTweak DefaultIDStaticIFrames => new IDStaticIFrameRule(10); #endregion #region Ignore Water @@ -532,7 +809,7 @@ namespace CalamityMod.Projectiles public void ApplyTweak(Projectile proj) { proj.penetrate = newPenetrate; - if (proj.penetrate < 1) + if (proj.penetrate == 0) proj.penetrate = 1; proj.maxPenetrate = proj.penetrate; } @@ -542,16 +819,6 @@ namespace CalamityMod.Projectiles internal static IProjectileTweak InfinitePiercing = new PiercingExactRule(-1); #endregion - #region Point Blank - internal class PointBlankRule : IProjectileTweak - { - public bool AppliesTo(Projectile proj) => true; - public void ApplyTweak(Projectile proj) - => proj.Calamity().pointBlankShotDuration = DefaultPointBlankDuration; - } - internal static IProjectileTweak PointBlank => new PointBlankRule(); - #endregion - #region Scale internal class ScaleDeltaRule : IProjectileTweak { diff --git a/Projectiles/CommonProjectileAI.cs b/Projectiles/CommonProjectileAI.cs new file mode 100644 index 0000000000..03e846d237 --- /dev/null +++ b/Projectiles/CommonProjectileAI.cs @@ -0,0 +1,623 @@ +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Enums; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles; + +internal static class CommonProjectileAI +{ + public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, Vector2 returnOffset, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging, int updateDifference = 1) + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + projectile.MinionAntiClump(); + + //Breather time between charges as like a reset + bool chargeDelay = false; + if (projectile.ai[0] == 2f) + { + projectile.ai[1] += 1f; + projectile.extraUpdates = initialUpdates + updateDifference; + if (projectile.ai[1] > chargeDelayTime) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.extraUpdates = initialUpdates; + // CIT 2OCT2024: This line was breaking how the game counted minions, + // which resulted in minions being counted extra times and despawning other minions, most notoriously with Resurrection Butterfly. + // As such, I have commented it out. + // projectile.numUpdates = 0; + projectile.netUpdate = true; + } + else + { + chargeDelay = true; + } + } + if (chargeDelay) + { + return; + } + + //Find a target + float maxDist = range; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + bool isButterfly = projectile.type == ProjectileType(); + //Prioritize the targeted enemy if possible + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; + if (npc.CanBeChasedBy(projectile, false) || fishronCheck) + { + //Check the size of the target to make it easier to hit fat targets like Levi + float extraDist = (npc.width / 2) + (npc.height / 2); + + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not + bool canHit = true; + if (extraDist < maxDist && !tileVision) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) + { + maxDist = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + //If no npc is specifically targetted or the selected enemy can't be found, check through the entire array + if (!foundTarget) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; + if (npc.CanBeChasedBy(projectile, false) || fishronCheck) + { + float extraDist = (npc.width / 2) + (npc.height / 2); + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (extraDist < maxDist && !tileVision) + canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); + if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) + { + maxDist = targetDist; + targetVec = npc.Center; + foundTarget = true; + } + } + } + } + + //If the player is too far, return to the player. Range is increased while attacking something. + float distBeforeForcedReturn = maxPlayerDist; + if (foundTarget) + { + distBeforeForcedReturn = extraMaxPlayerDist; + } + if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + + //Go to the target if you found one + if (foundTarget && projectile.ai[0] == 0f) + { + //Some minions don't ignore tiles while charging like brittle stars + projectile.tileCollide = !ignoreTilesWhenCharging; + Vector2 targetSpot = targetVec - projectile.Center; + float targetDist = targetSpot.Length(); + targetSpot.Normalize(); + //Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does + if (targetDist > 200f) + { + float speed = goToSpeed; //8 + targetSpot *= speed; + projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; + } + else + { + float speed = -goBackSpeed; //-4 + targetSpot *= speed; + projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41 + } + } + + //Movement for idle or returning to the player + else + { + //Ignore tiles so they don't get stuck everywhere like Optic Staff + projectile.tileCollide = false; + + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } + + //Player distance calculations + Vector2 playerVec = player.Center - projectile.Center + returnOffset; + float playerDist = playerVec.Length(); + + //If the minion is actively returning, move faster + float playerHomeSpeed = 6f; + if (returningToPlayer) + { + playerHomeSpeed = 15f; + } + //Move somewhat faster if the player is kinda far~ish + if (playerDist > 200f && playerHomeSpeed < 8f) + { + playerHomeSpeed = 8f; + } + //Return to normal if close enough to the player + if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //Teleport to the player if abnormally far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + //If more than 70 pixels away, move toward the player + if (playerDist > 70f) + { + playerVec.Normalize(); + playerVec *= playerHomeSpeed; + projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; + } + //Minions never stay still + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } + + //Increment attack counter randomly + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += (float)Main.rand.Next(1, 4); + } + //If high enough, prepare to attack + if (projectile.ai[1] > chargeCounterMax) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + + //Charge at an enemy if not on cooldown + if (projectile.ai[0] == 0f) + { + if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f) + { + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + projectile.ai[0] = 2f; + Vector2 targetPos = targetVec - projectile.Center; + targetPos.Normalize(); + projectile.velocity = targetPos * chargeSpeed; //8 + projectile.netUpdate = true; + } + } + } + } + + public static void FloatingPetAI(this Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false) + { + Player player = Main.player[projectile.owner]; + + //anti sticking movement as a failsafe + float SAImovement = 0.05f; + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.owner != projectile.owner || !Main.projPet[otherProj.type] || k == projectile.whoAmI) + continue; + + // If the other projectile is indeed another pet owned by the same player and they're too close, nudge them away. + bool isPet = Main.projPet[otherProj.type]; + float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); + if (isPet && taxicabDist < projectile.width) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= SAImovement; + else + projectile.velocity.X += SAImovement; + + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= SAImovement; + else + projectile.velocity.Y += SAImovement; + } + } + + float passiveMvtFloat = 0.5f; + projectile.tileCollide = false; + float range = 100f; + Vector2 projPos = projectile.Center; + float xDist = player.Center.X - projPos.X; + float yDist = player.Center.Y - projPos.Y; + yDist += Main.rand.NextFloat(-10, 20); + xDist += Main.rand.NextFloat(-10, 20); + //Light pets lead the player, normal pets trail the player + xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction); + yDist -= 60f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + float returnSpeed = 18f; + + //If player is close enough, resume normal + if (playerDist < range && player.velocity.Y == 0f && + projectile.Bottom.Y <= player.Bottom.Y && + !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } + + //Teleport to player if too far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.height / 2; + projectile.netUpdate = true; + } + + if (playerDist < 50f) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + passiveMvtFloat = 0.01f; + } + else + { + if (playerDist < 100f) + { + passiveMvtFloat = 0.1f; + } + if (playerDist > 300f) + { + passiveMvtFloat = 1f; + } + playerDist = returnSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + } + if (projectile.velocity.X < playerVector.X) + { + projectile.velocity.X += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X += passiveMvtFloat; + } + } + if (projectile.velocity.X > playerVector.X) + { + projectile.velocity.X -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X -= passiveMvtFloat; + } + } + if (projectile.velocity.Y < playerVector.Y) + { + projectile.velocity.Y += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y += passiveMvtFloat * 2f; + } + } + if (projectile.velocity.Y > playerVector.Y) + { + projectile.velocity.Y -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y -= passiveMvtFloat * 2f; + } + } + if (projectile.velocity.X >= 0.25f) + { + projectile.direction = faceRight ? 1 : -1; + } + else if (projectile.velocity.X < -0.25f) + { + projectile.direction = faceRight ? -1 : 1; + } + //Tilting and change directions + projectile.spriteDirection = projectile.direction; + projectile.rotation = projectile.velocity.X * tiltFloat; + } + + public static void HealingProjectile(this Projectile projectile, int healing, int playerToHeal, float homingVelocity, float inertia, bool autoHomes = true, int timeCheck = 120) + { + int target = playerToHeal; + Player player = Main.player[target]; + float homingSpeed = homingVelocity; + if (player.lifeMagnet) + homingSpeed *= 1.5f; + + Vector2 playerVector = player.Center - projectile.Center; + float playerDist = playerVector.Length(); + if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y) + { + if (projectile.owner == Main.myPlayer && !Main.LocalPlayer.moonLeech) + { + int healAmt = healing; + player.HealPlayer(healAmt, HealTextType.Local); + NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0); + } + projectile.Kill(); + } + if (autoHomes) + { + playerDist = homingSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + projectile.velocity.X = (projectile.velocity.X * inertia + playerVector.X) / (inertia + 1f); + projectile.velocity.Y = (projectile.velocity.Y * inertia + playerVector.Y) / (inertia + 1f); + } + else if (player.lifeMagnet && projectile.timeLeft < timeCheck) + { + playerDist = homingVelocity / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + projectile.velocity.X = (projectile.velocity.X * inertia + playerVector.X) / (inertia + 1f); + projectile.velocity.Y = (projectile.velocity.Y * inertia + playerVector.Y) / (inertia + 1f); + } + } + + public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f) + { + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI) + continue; + + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherProj.type == projectile.type; + float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); + if (sameProjType && taxicabDist < projectile.width) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= pushForce; + else + projectile.velocity.X += pushForce; + + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= pushForce; + else + projectile.velocity.Y += pushForce; + } + } + } + + /// + /// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile + /// + /// The projectile you're giving sticky behaviour to + /// How many projectiles of this type can stick to one enemy + public static void ModifyHitNPCSticky(this Projectile projectile, int maxStick) + { + Player player = Main.player[projectile.owner]; + Rectangle myRect = projectile.Hitbox; + + if (projectile.owner == Main.myPlayer) + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + //covers most edge cases like voodoo dolls + if (npc.active && !npc.dontTakeDamage && + ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) || + (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) + { + if (npc.noTileCollide || !projectile.ownerHitCheck) + { + bool stickingToNPC; + //Solar Crawltipede tail has special collision + if (npc.type == NPCID.SolarCrawltipedeTail) + { + Rectangle rect = npc.Hitbox; + int crawltipedeHitboxMod = 8; + rect.X -= crawltipedeHitboxMod; + rect.Y -= crawltipedeHitboxMod; + rect.Width += crawltipedeHitboxMod * 2; + rect.Height += crawltipedeHitboxMod * 2; + stickingToNPC = projectile.Colliding(myRect, rect); + } + else + { + stickingToNPC = projectile.Colliding(myRect, npc.Hitbox); + } + if (stickingToNPC) + { + //reflect projectile if the npc can reflect it (like Selenians) + if (npc.reflectsProjectiles && projectile.CanBeReflected()) + { + npc.ReflectProjectile(projectile); + return; + } + + //let the projectile know it is sticking and the npc it is sticking too + projectile.ai[0] = 1f; + projectile.ai[1] = (float)npcIndex; + + //follow the NPC + projectile.velocity = (npc.Center - projectile.Center); + + projectile.netUpdate = true; + + //Count how many projectiles are attached, delete as necessary + Point[] array2 = new Point[maxStick]; + int projCount = 0; + for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) + { + Projectile proj = Main.projectile[projIndex]; + if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 1f && proj.ai[1] == (float)npcIndex) + { + array2[projCount++] = new Point(projIndex, proj.timeLeft); + if (projCount >= array2.Length) + { + break; + } + } + } + if (projCount >= array2.Length) + { + int stuckProjAmt = 0; + for (int m = 1; m < array2.Length; m++) + { + if (array2[m].Y < array2[stuckProjAmt].Y) + { + stuckProjAmt = m; + } + } + Main.projectile[array2[stuckProjAmt].X].Kill(); + } + } + } + } + } + } + } + + public static void StickToTiles(this Projectile projectile, bool ignorePlatforms, bool stickToEverything) + { + try + { + int xLeft = (int)(projectile.position.X / 16f) - 1; + int xRight = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; + int yBottom = (int)(projectile.position.Y / 16f) - 1; + int yTop = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; + if (xLeft < 0) + { + xLeft = 0; + } + if (xRight > Main.maxTilesX) + { + xRight = Main.maxTilesX; + } + if (yBottom < 0) + { + yBottom = 0; + } + if (yTop > Main.maxTilesY) + { + yTop = Main.maxTilesY; + } + for (int x = xLeft; x < xRight; x++) + { + for (int y = yBottom; y < yTop; y++) + { + Tile tile = Main.tile[x, y]; + bool platformCheck = true; + if (ignorePlatforms) + platformCheck = !TileID.Sets.Platforms[tile.TileType] && tile.TileType != TileID.PlanterBox; + bool tableCheck = false; + if (stickToEverything) + tableCheck = Main.tileSolidTop[tile.TileType] && tile.TileFrameY == 0; + if (tile != null && tile.HasUnactuatedTile && platformCheck && (Main.tileSolid[tile.TileType] || tableCheck)) + { + Vector2 tileSize; + tileSize.X = (float)(x * 16); + tileSize.Y = (float)(y * 16); + if (projectile.position.X + (float)projectile.width - 4f > tileSize.X && projectile.position.X + 4f < tileSize.X + 16f && projectile.position.Y + (float)projectile.height - 4f > tileSize.Y && projectile.position.Y + 4f < tileSize.Y + 16f) + { + projectile.velocity.X = 0f; + projectile.velocity.Y = -0.2f; + } + } + } + } + } + catch + { + } + } + + /// + /// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC + /// + /// The projectile you're adding sticky behaviour to + /// Number of seconds you want a projectile to cling to an NPC + public static void StickyProjAI(this Projectile projectile, int timeLeft, bool findNewNPC = false) + { + if (projectile.ai[0] == 1f) + { + int seconds = timeLeft; + bool killProj = false; + bool spawnDust = false; + + //the projectile follows the NPC, even if it goes into blocks + projectile.tileCollide = false; + + //timer for triggering hit effects + projectile.localAI[0]++; + if (projectile.localAI[0] % 30f == 0f) + { + spawnDust = true; + } + + //So AI knows what NPC it is sticking to + int npcIndex = (int)projectile.ai[1]; + NPC npc = Main.npc[npcIndex]; + + //Kill projectile after so many seconds or if the NPC it is stuck to no longer exists + if (projectile.localAI[0] >= (float)(60 * seconds)) + { + killProj = true; + } + else if (!npcIndex.WithinBounds(Main.maxNPCs)) + { + killProj = true; + } + + else if (npc.active && !npc.dontTakeDamage) + { + //follow the NPC + projectile.Center = npc.Center - projectile.velocity * 2f; + projectile.gfxOffY = npc.gfxOffY; + + //if attached to npc, trigger npc hit effects every half a second + if (spawnDust) + { + npc.HitEffect(0, 1.0); + } + } + else + { + killProj = true; + } + + //Kill the projectile or reset stats if needed + if (killProj) + { + if (findNewNPC) + projectile.ai[0] = 0f; + else + projectile.Kill(); + } + } + } +} diff --git a/Projectiles/Damageable/DamageableProjectile.cs b/Projectiles/Damageable/DamageableProjectile.cs index 123e64c7a8..78b8dfc344 100644 --- a/Projectiles/Damageable/DamageableProjectile.cs +++ b/Projectiles/Damageable/DamageableProjectile.cs @@ -151,17 +151,11 @@ namespace CalamityMod.Projectiles.Damageable } if (wasHit && Life > 0) { - if (HitSound != null) - { - SoundEngine.PlaySound(HitSound, Projectile.Center); - } + SoundEngine.PlaySound(HitSound, Projectile.Center); } else if (Life <= 0) { - if (DeathSound != null) - { - SoundEngine.PlaySound(DeathSound, Projectile.Center); - } + SoundEngine.PlaySound(DeathSound, Projectile.Center); DamageKillEffect(); Projectile.Kill(); } diff --git a/Projectiles/DraedonsArsenal/AerialTrackerLaser.cs b/Projectiles/DraedonsArsenal/AerialTrackerLaser.cs new file mode 100644 index 0000000000..22e3b48d87 --- /dev/null +++ b/Projectiles/DraedonsArsenal/AerialTrackerLaser.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using CalamityMod.NPCs; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AerialTrackerLaser : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public float Time + { + get => Projectile.localAI[0]; + set => Projectile.localAI[0] = value; + } + public Projectile disk; + public Vector2 laserStart; + public Vector2 laserEnd; + public int lifetime = 15; + public NPC targeted; + public float fade => (float)Math.Pow(Utils.GetLerpValue(0, lifetime, Projectile.timeLeft), 3); + public override void SetDefaults() + { + Projectile.width = 2; + Projectile.height = 2; + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = lifetime; + Projectile.ArmorPenetration = 10; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (Time == 0) + { + disk = Main.projectile[(int)Projectile.ai[1]]; + targeted = Main.npc[(int)Projectile.ai[2]]; + if (disk != null) + laserStart = disk.Center; + else + laserStart = Projectile.Center; + if (targeted != null) + laserEnd = targeted.Center; + else + laserEnd = Projectile.Center; + } + if (targeted.active && targeted.life > 0) + { + laserEnd = targeted.Center; + Projectile.Center = targeted.Center; + } + + Time++; + } + public override bool? CanHitNPC(NPC target) + { + return (Projectile.numHits > 0 ? false : null); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // Handles giving the NPC the laser burn effect + CalamityGlobalNPC modNPC = target.Calamity(); + if (!modNPC.laserBurnMarked) + { + modNPC.laserBurnMarked = true; + modNPC.laserBurnType = 1; + modNPC.laserBurnTimer = CalamityGlobalNPC.laserBurnTime; + } + + modNPC.laserBurnTimer -= modNPC.laserBurnStacks * 2; + modNPC.laserBurnDamage += (int)(Projectile.damage * 0.2f); + + modNPC.laserBurnStacks++; + + modifiers.SourceDamage *= 0; + modifiers.FinalDamage.Flat = 0.1f; + modifiers.HideCombatText(); + + } + public override void OnKill(int timeLeft) + { + /* + for (int i = 0; i < 7; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 267); + dust.velocity = (Projectile.velocity * 3 * Projectile.scale).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 1f); + dust.scale = Main.rand.NextFloat(0.4f, 0.7f) * Projectile.scale; + dust.noGravity = true; + dust.color = Color.Red; + } + */ + } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overPlayers.Add(index); + } + public override bool PreDraw(ref Color lightColor) + { + // So unless placed here the position of projectile updates is inconsistent and will cause offsets + if (disk != null && disk.active && disk.type == ModContent.ProjectileType()) + { + laserStart = disk.Center; + } + else + { + disk = null; + } + + if (laserStart == Vector2.Zero || laserEnd == Vector2.Zero) + return false; + + Player player = Main.player[Projectile.owner]; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Texture2D lineTex = ModContent.Request("CalamityMod/Particles/BloomLineSoftEdge").Value; + float distance = Utils.Distance(laserStart, laserEnd); + int drawSeperation = 10; + int startSeperation = drawSeperation; + Vector2 toPoint = Utils.DirectionTo(laserStart, laserEnd); + for (int i = startSeperation; i < distance - drawSeperation; i += drawSeperation) + { + float completion = MathHelper.Lerp(0.8f, 3f, 1 - (i / distance)); + for (int y = 0; y < 2; y++) + Main.EntitySpriteDraw(lineTex, laserStart - Main.screenPosition + toPoint * i, null, (y == 1 ? Color.White : Effects.ArsenalEffects.ArsenalLaserColor) with { A = 0 } * fade, toPoint.ToRotation() + MathHelper.PiOver2, lineTex.Size() * 0.5f, new Vector2((y == 1 ? 0.3f : 1) * MathHelper.Max(fade, 0.3f) * completion, 1.3f) * Projectile.scale * 0.01f, SpriteEffects.None); + } + Texture2D glowTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + Main.EntitySpriteDraw(glowTex, laserStart - Main.screenPosition, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 }, Projectile.rotation, glowTex.Size() * 0.5f, 0.3f * fade, SpriteEffects.None, 0); + Main.EntitySpriteDraw(glowTex, laserStart - Main.screenPosition, null, Color.White with { A = 0 } * 0.65f, Projectile.rotation, glowTex.Size() * 0.5f, 0.15f * fade, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/AerialTrackerProjectile.cs b/Projectiles/DraedonsArsenal/AerialTrackerProjectile.cs new file mode 100644 index 0000000000..a5c01d981e --- /dev/null +++ b/Projectiles/DraedonsArsenal/AerialTrackerProjectile.cs @@ -0,0 +1,189 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AerialTrackerProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/AerialTracker"; + public NPC extraShotTarget; + + public bool ReturningToPlayer + { + get => Projectile.ai[0] == 1f; + set => Projectile.ai[0] = value.ToInt(); + } + + public float Time + { + get => Projectile.ai[1]; + set => Projectile.ai[1] = value; + } + + public const int LaserFireRate = 19; + public const int LaserFireRateStealth = 25; + public const int MaxLaserCountPerShot = 2; // This only applies to stealth strikes. + public const float MaxTargetSearchDistance = 600f; + public const float MaxTargetSearchStealth = 800f; + public const float ReturnAccelerationFactor = 0.0012f; + public const float ReturnMaxSpeed = 6f; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 7; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 52; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 2; + Projectile.tileCollide = false; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, 0.5f).ToVector3() * 0.5f); + + Player player = Main.player[Projectile.owner]; + + Time++; + + if (Time == 5 && !Projectile.Calamity().stealthStrike) + Projectile.tileCollide = true; + if (Time < 100 && Time > 10 && Projectile.Calamity().stealthStrike) + Projectile.velocity = Projectile.velocity.RotatedBy(-0.029f * Projectile.ai[2]); + + if (!ReturningToPlayer) + { + if (Time >= 55f) + { + ReturningToPlayer = true; + Projectile.tileCollide = false; + Projectile.netUpdate = true; + } + } + else + { + float distanceFromPlayer = Projectile.Distance(player.Center); + if (distanceFromPlayer > 3000f) + Projectile.Kill(); + + // 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 * ReturnMaxSpeed * (Projectile.Calamity().stealthStrike ? Utils.GetLerpValue(90, 300, Time, true) * 1.5f : Utils.GetLerpValue(60, 300, Time, true)); + + Projectile.velocity.X += Math.Sign(idealVelocity.X - Projectile.velocity.X) * (ReturnAccelerationFactor * Time); + Projectile.velocity.Y += Math.Sign(idealVelocity.Y - Projectile.velocity.Y) * (ReturnAccelerationFactor * Time); + + if (Time % (Projectile.Calamity().stealthStrike ? LaserFireRateStealth : LaserFireRate) == 0f) + AttemptToFireLasers(Projectile.damage); + + if (Main.myPlayer == Projectile.owner) + { + if (Projectile.Hitbox.Intersects(player.Hitbox)) + Projectile.Kill(); + } + } + + if (ReturningToPlayer) + { + Projectile.rotation += 0.28f * Utils.GetLerpValue(30, 300, Time, true); + } + else + Projectile.rotation += 0.15f; + } + + public void AttemptToFireLasers(int damage) + { + if (Main.myPlayer != Projectile.owner) + return; + if (Projectile.Calamity().stealthStrike) + { + int targetCount = 0; + List targets = Main.npc.Where(npc => + { + return npc.active && Projectile.Distance(npc.Center) < MaxTargetSearchStealth && npc.CanBeChasedBy(); + }).ToList(); + foreach (var target in targets) + { + if (targetCount >= MaxLaserCountPerShot) + break; + Vector2 spawnLocation = Projectile.Center + new Vector2(25, 0).RotatedBy(Projectile.rotation * Utils.GetLerpValue(300, 30, Time, true)); + Projectile laser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, + Vector2.Zero, + ModContent.ProjectileType(), + (int)(damage), + Projectile.knockBack, + Projectile.owner, + 1f, Projectile.whoAmI, target.whoAmI); + laser.scale *= 1.4f; + laser.netUpdate = true; + targetCount++; + extraShotTarget = target; + } + if (targetCount == 1) + { + Vector2 spawnLocation = Projectile.Center + new Vector2(25, 0).RotatedBy(-Projectile.rotation * Utils.GetLerpValue(300, 30, Time, true)); + Projectile laser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, + Vector2.Zero, + ModContent.ProjectileType(), + (int)(damage), + Projectile.knockBack, + Projectile.owner, + -1f, Projectile.whoAmI, extraShotTarget.whoAmI); + } + } + else + { + NPC potentialTarget = Projectile.Center.ClosestNPCAt(MaxTargetSearchDistance); + if (potentialTarget != null) + { + Vector2 spawnLocation = Projectile.Center + new Vector2(25, 0).RotatedBy(Projectile.rotation * 0.4f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), damage, Projectile.knockBack, Projectile.owner, 0, Projectile.whoAmI, potentialTarget.whoAmI); + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + ReturningToPlayer = true; + Projectile.tileCollide = false; + Projectile.netUpdate = true; + 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 PreDraw(ref Color lightColor) + { + Asset texture = ModContent.Request(Texture); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 origin = texture.Size() * 0.5f; + + Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, ProjectileID.Sets.TrailCacheLength[Projectile.type], null, true, false); + + Main.EntitySpriteDraw(texture.Value, drawPosition, null, lightColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/AnomalysNanogunHoldout.cs b/Projectiles/DraedonsArsenal/AnomalysNanogunHoldout.cs index 25ce8ce434..65c00ee576 100644 --- a/Projectiles/DraedonsArsenal/AnomalysNanogunHoldout.cs +++ b/Projectiles/DraedonsArsenal/AnomalysNanogunHoldout.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Particles; -using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -104,7 +103,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } // Make it POWERFUL - Owner.Calamity().GeneralScreenShakePower = MPFBScreenShakePower; + Owner.SetScreenshake(MPFBScreenShakePower); float playerSpeed = Owner.velocity.Length(); Vector2 pushback = Projectile.velocity.SafeNormalize(Vector2.UnitX) * -MPFBPushback; Vector2 newPlayerVelocity = Owner.velocity + pushback; diff --git a/Projectiles/DraedonsArsenal/AnomalysNanogunMPFBDevastator.cs b/Projectiles/DraedonsArsenal/AnomalysNanogunMPFBDevastator.cs index c143c8b02b..9cb7553956 100644 --- a/Projectiles/DraedonsArsenal/AnomalysNanogunMPFBDevastator.cs +++ b/Projectiles/DraedonsArsenal/AnomalysNanogunMPFBDevastator.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Weapons.DraedonsArsenal; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -39,11 +38,11 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float sine = (float)Math.Sin(Projectile.timeLeft * 0.375f / MathHelper.Pi); Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 267, Vector2.Zero); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.RainbowMk2, Vector2.Zero); dust.color = Color.Cyan; dust.noGravity = true; - dust = Dust.NewDustPerfect(Projectile.Center - offset, 267, Vector2.Zero); + dust = Dust.NewDustPerfect(Projectile.Center - offset, DustID.RainbowMk2, Vector2.Zero); dust.color = Color.Cyan; dust.noGravity = true; @@ -77,7 +76,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < 18; i++) { Vector2 vel = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.2f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 1.5f, 226, vel * Main.rand.NextFloat(0.1f, 1.2f) + new Vector2(0, -2)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 1.5f, DustID.Electric, vel * Main.rand.NextFloat(0.1f, 1.2f) + new Vector2(0, -2)); dust.noGravity = false; dust.scale = Main.rand.NextFloat(0.65f, 1.2f); } diff --git a/Projectiles/DraedonsArsenal/AnomalysNanogunPlasmaBeam.cs b/Projectiles/DraedonsArsenal/AnomalysNanogunPlasmaBeam.cs index a1b875a79d..f2bd85a342 100644 --- a/Projectiles/DraedonsArsenal/AnomalysNanogunPlasmaBeam.cs +++ b/Projectiles/DraedonsArsenal/AnomalysNanogunPlasmaBeam.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal @@ -52,7 +53,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Projectile.timeLeft == 12) { Vector2 beamVector = Projectile.velocity; - float beamLength = DetermineLaserLength_CollideWithTiles(12); + float beamLength = DetermineLaserLength_CollideWithTiles(); //Rapid dust int dustCount = Main.rand.Next(10, 30); @@ -61,7 +62,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float dustProgressAlongBeam = beamLength * Main.rand.NextFloat(0f, 0.8f); Vector2 dustPosition = Projectile.Center + dustProgressAlongBeam * beamVector + beamVector.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-6f, 6f) * Projectile.scale; - Dust dust = Dust.NewDustPerfect(dustPosition, 187, beamVector * Main.rand.NextFloat(5f, 26f), 0, Color.OrangeRed, 2.2f); + Dust dust = Dust.NewDustPerfect(dustPosition, DustID.BlueFlare, beamVector * Main.rand.NextFloat(5f, 26f), 0, Color.OrangeRed, 2.2f); dust.noGravity = true; } @@ -89,7 +90,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { for (int i = 0; i <= 8; i++) { - Dust dust = Dust.NewDustPerfect(target.Center, 218, (Projectile.velocity * 30).RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); + Dust dust = Dust.NewDustPerfect(target.Center, DustID.Rain_BloodMoon, (Projectile.velocity * 30).RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); dust.noGravity = true; } @@ -101,7 +102,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void DetermineScale() => Projectile.scale = 1f; - public override float DetermineLaserLength() => DetermineLaserLength_CollideWithTiles(5); + public override float DetermineLaserLength() => DetermineLaserLength_CollideWithTiles(); public override bool ShouldUpdatePosition() => false; diff --git a/Projectiles/DraedonsArsenal/AqueousHunterDroneSummon.cs b/Projectiles/DraedonsArsenal/AqueousHunterDroneSummon.cs new file mode 100644 index 0000000000..49af06b549 --- /dev/null +++ b/Projectiles/DraedonsArsenal/AqueousHunterDroneSummon.cs @@ -0,0 +1,428 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.Cooldowns; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AqueousHunterDroneSummon : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public int time = 0; + public ref float attackTimer => ref Projectile.ai[0]; + public ref float interactionTimer => ref Projectile.ai[1]; + public int interactionPoint = 600; // The time needed before shimps do their idle animation + public int cooldownGiven = 450; + public bool pressedRight => Projectile.ai[2] == 5; + public bool doingSpecialAttack = false; + public float moveSpeed = 30; // Lower is actually faster + public NPC targetedNPC; // The NPC being targeted + public float tailRot = 0; // Extra rotation on the tail + public float tailRecoil = 0; // Recoil for the tail after firing + public int facingDir = 0; + public Vector2 headPlace; + public Vector2 tailPlace; + public float lastFirePositionX; // Used for some of the movement + public Vector2 chillSpot; // Stored position for intro animation and some movement + public Vector2 spawnAnimStart; // Second stored position for the spawn animation + public Vector2 lastTargetCenter; + public int attackDowntime = 0; // Timer used for post attack effects + public int surpriseTimer = 0; // Used for the jump animation when surprized + public float slidingDirection = 0; // Value that lerps from left to right + public int animationClickTime = 70; // Time before body and tail click together in spawn anim + public bool doSpin = false; // If the shrimp will spin for it's attack + public float specialAttackfx = 0; // spinnning effect opacity mult + public override void SetStaticDefaults() + { + Main.projPet[Type] = true; + ProjectileID.Sets.MinionSacrificable[Type] = true; + ProjectileID.Sets.SummonTagDamageMultiplier[Type] = 0f; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.minionSlots = 4f; + Projectile.timeLeft = 18000; + Projectile.penetrate = -1; + Projectile.minion = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 5; + Projectile.DamageType = DamageClass.Summon; + } + + public override void AI() + { + int shrimpNum = Owner.ownedProjectileCounts[Projectile.type]; + facingDir = Math.Sign(Projectile.velocity.X); + GrantBuffs(Owner); + if ((targetedNPC == null || targetedNPC.life <= 0 || !targetedNPC.CanBeChasedBy() || attackDowntime == 20) && attackDowntime < 30) + targetedNPC = Projectile.Center.MinionHoming(2000f, Owner); + + // All the stuff for the spawn animation + if (time < animationClickTime + 20) + { + if (time == 0) + { + chillSpot = Projectile.Center; + spawnAnimStart = Projectile.Center; + int chosenDir = Math.Sign(Projectile.Center.DirectionTo(Owner.Center).X); + Projectile.velocity.X = (chosenDir * 16); + tailRot = -2f * chosenDir; + attackTimer += 8 * Projectile.localAI[2]; + } + SpawnAnim(); + facingDir = Math.Sign(Projectile.velocity.X); + time++; + return; + } + + slidingDirection = MathHelper.Lerp(slidingDirection, Owner.direction, 0.03f); + + bool isSummonWeapon = Owner.HeldItem.DamageType.CountsAsClass(DamageClass.Summon); + if (Owner.Calamity().mouseRight && Owner.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && Owner.Calamity().arsenalCooldown <= 0 && isSummonWeapon) + { + Projectile.ai[2] = 5; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == Projectile.type && p.owner == Projectile.owner) + { + p.ai[2] = 5; + } + } + } + + if (doingSpecialAttack) + { + SpecialAttack(); + } + else + { + specialAttackfx = MathHelper.Lerp(specialAttackfx, 0, 0.15f); + if (targetedNPC != null || attackDowntime > 0) + { + lastTargetCenter = (targetedNPC == null ? Owner.Center : targetedNPC.Center); + Attacking(); + } + else + { + Passive(); + CheckForSpecialAttack(); + } + } + + if (tailRecoil > 0) + tailRecoil = MathHelper.Lerp(tailRecoil, 0, 0.2f); + if (attackDowntime > 0) + attackDowntime--; + time++; + SetVisualPlacement(); + } + public void CheckForSpecialAttack() + { + if (pressedRight) + { + Projectile.ai[2] = 0; + doingSpecialAttack = true; + attackTimer = 0; + if (Projectile.velocity.Length() < 5) + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 12; + else + Projectile.velocity *= 1.3f; + Owner.Calamity().arsenalCooldown = cooldownGiven; + Owner.AddCooldown(ArsenalPower.ID, cooldownGiven); + } + } + public void SpecialAttack() + { + interactionTimer = 0; + int length = 33; + specialAttackfx = MathHelper.Lerp(specialAttackfx, 1, 0.2f); + + facingDir = Math.Sign(Projectile.Center.DirectionTo(Owner.Center).X); + Projectile.velocity *= 0.98f; + Projectile.rotation += ((MathHelper.TwoPi * 3) / length) * facingDir; + + tailRot = MathHelper.Lerp(tailRot, 0.75f * -facingDir, 0.2f); + for (int i = -1; i <= 1; i += 2) + { + bool noFall = !Main.rand.NextBool(5); + Vector2 vel = Vector2.UnitY.RotatedBy(Projectile.rotation * -5) * i; + int dustStyle = noFall ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalPlasmaDust; + Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 43 * specialAttackfx, dustStyle); + dust.scale = Main.rand.NextFloat(0.8f, 1.1f) + (noFall ? 0 : 0.5f); + dust.velocity = vel.RotatedBy(Main.rand.NextFloat(-0.2f, 0.2f) - MathHelper.PiOver4 * facingDir) * Main.rand.NextFloat(4, 5.5f); + dust.noGravity = noFall; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = noFall ? 0 : 0.7f; + } + + if (attackTimer % 3 == 0) + { + int usedTimer = (int)(facingDir == -1 ? (length - attackTimer) : attackTimer); + SoundEngine.PlaySound(AqueousHunterDrone.Fire with { Volume = 0.7f, Pitch = 0.0f, PitchVariance = 0.3f, MaxInstances = 10 }, Projectile.Center); + Vector2 shootVel = (MathHelper.PiOver2 / 10 * (int)(usedTimer / 3 - 1)).ToRotationVector2().RotatedBy(-MathHelper.PiOver2 - MathHelper.PiOver4); + Vector2 shootPlace = Projectile.Center + shootVel * 10; + + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), shootPlace, shootVel * 8, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner, 0, 0, attackTimer + 1); + } + attackTimer++; + if (attackTimer > length) + { + attackTimer = 8 * Projectile.localAI[2]; + doingSpecialAttack = false; + } + } + public void SpawnAnim() + { + Vector2 tailDist = new Vector2((30 - Math.Abs(tailRot) * 15) * (-facingDir), 7 - Math.Abs(tailRot) * 3).RotatedBy(Projectile.rotation); + Vector2 headDist = new Vector2(0, 0); + headPlace = Projectile.Center + headDist; + if (time < animationClickTime) + { + tailRot += 0.05f * Projectile.direction; + Projectile.velocity *= 0.98f; + Projectile.Center -= Projectile.velocity; + spawnAnimStart = new Vector2(spawnAnimStart.X, Owner.Center.Y - 700); + + tailPlace = chillSpot + tailDist + (Vector2.UnitY * ((float)Math.Pow(time, 2.05f) * 0.085f) + Vector2.UnitX * (16 - Math.Abs(Projectile.velocity.X)) * 10 * Projectile.direction); + } + else + tailPlace = Projectile.Center + tailDist; + + if (time > animationClickTime - 40) + { + if (time == animationClickTime - 1) + { + Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.PiOver4 * Projectile.direction) * 3; + SoundStyle click = new("CalamityMod/Sounds/Item/DudFire"); + SoundEngine.PlaySound(click with { Pitch = 0.4f }, Projectile.Center); + SoundEngine.PlaySound((Main.rand.NextBool() ? AqueousHunterDrone.Sound1 : AqueousHunterDrone.Sound2) with { Volume = 0.6f, Pitch = 0.3f, MaxInstances = 10 }, Projectile.Center); + + for (int i = -9; i <= 9; i++) + { + int dustStyle = Effects.ArsenalEffects.ArsenalPlasmaDust; + Dust dust = Dust.NewDustPerfect(tailPlace + Main.rand.NextVector2Circular(5, 5), dustStyle); + dust.scale = Main.rand.NextFloat(0.7f, 1.3f); + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.Pi * (Math.Sign(i) == 1 ? 0 : 1)) * Main.rand.NextFloat(1, 5); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = 0.1f; + if (i == -1) + i++; + } + for (int i = 0; i < 2; i++) + { + Particle spark = new CustomSpark(tailPlace, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 15, 0.4f, Effects.ArsenalEffects.ArsenalPlasmaColor, new Vector2(1, 1), true, true, 0, false, false); + GeneralParticleHandler.SpawnParticle(spark); + } + } + if (time > animationClickTime - 1) + { + Projectile.velocity *= 0.97f; + tailRot = MathHelper.Lerp(tailRot, 0, 0.1f); + } + else + { + Projectile.Center = Vector2.Lerp(spawnAnimStart, tailPlace, Utils.GetLerpValue(animationClickTime - 40, animationClickTime, time, true)); + } + } + } + public void Passive() + { + float sine = (float)Math.Sin((time + Projectile.localAI[2] * 3) * 0.075f / MathHelper.Pi); + float sine2 = (float)Math.Sin(((time + Projectile.localAI[2] * 3) * 0.075f / MathHelper.Pi) * 2); + + TailRotationBasedOnMovement(); + + attackTimer = 8 * Projectile.localAI[2]; + + if (interactionTimer == interactionPoint) + { + chillSpot = Owner.Center + Main.rand.NextVector2CircularEdge(190, 190); + } + Projectile.rotation = Projectile.rotation.AngleLerp(0, 0.04f); + Vector2 destination = interactionTimer > interactionPoint ? (chillSpot + new Vector2(220 * sine, -90 + 130 * sine2)) : Owner.Center + new Vector2((-50 + -85 * Projectile.localAI[2]) * slidingDirection, -80 + 30 * sine); + + if (surpriseTimer == 0) + Projectile.velocity = (destination - Projectile.Center) / (moveSpeed + (interactionTimer > interactionPoint ? 20 : 0) - 9 + 9 * sine2); + else + surpriseTimer--; + if (interactionTimer > interactionPoint) + { + if (time % 25 == 0) + { + Particle spark2 = new CustomSpark(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Vector2.UnitY * 20, -Vector2.UnitY.RotatedByRandom(0.1f) * Main.rand.NextFloat(3.3f, 5.5f), "CalamityMod/Projectiles/Magic/MelterNote1", false, 32, Main.rand.NextFloat(1.2f, 1.3f), Color.Lerp(Color.Green, Color.Chartreuse, Main.rand.NextFloat(0, 0.7f)), new Vector2(1, 1), true, false, 0, false, false); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (time % (480 + Projectile.localAI[2] * 120) == 0 && Owner.miscCounter != 0) + { + SoundEngine.PlaySound((Main.rand.NextBool() ? AqueousHunterDrone.Sound1 : AqueousHunterDrone.Sound2) with { Volume = 0.3f, Pitch = 0f + Projectile.localAI[2] * 0.1f * (Projectile.localAI[2] % 2 == 0 ? -1 : 1), MaxInstances = 10 }, Projectile.Center); + } + } + if (Owner.Center.Distance(Projectile.Center) > 450 && interactionTimer > interactionPoint && Owner.velocity.Length() > 5) + { + CombatText.NewText(Projectile.Hitbox, Effects.ArsenalEffects.ArsenalPlasmaColor, "!", true); + SoundEngine.PlaySound(AqueousHunterDrone.Surprise with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); + Projectile.velocity = Projectile.Center.DirectionTo(Owner.Center); + surpriseTimer = 25; + interactionTimer = 0; + } + if (Projectile.velocity.Length() < 5) + interactionTimer++; + else if (interactionTimer > 0 && interactionTimer < interactionPoint) + interactionTimer -= 2; + } + public void Attacking() + { + interactionTimer = 0; + facingDir = Math.Sign(Projectile.Center.DirectionTo(lastTargetCenter).X); + if (tailRecoil > 1 && doSpin) // Little spin + { + Projectile.rotation += 0.35f * facingDir; + } + else + Projectile.rotation = (Projectile.rotation).AngleLerp(tailPlace.DirectionTo(lastTargetCenter).ToRotation() + (facingDir == -1 ? MathHelper.Pi : 0) + (MathHelper.PiOver4 * -facingDir), 0.18f); + if (Utils.Distance(Projectile.Center, lastTargetCenter) > 250 && Projectile.velocity.Length() < 15) + Projectile.velocity += tailPlace.DirectionTo(lastTargetCenter) * 0.3f; + else + Projectile.velocity *= 0.96f; + if (lastTargetCenter.Y - 80 < tailPlace.Y) + Projectile.velocity.Y -= 0.7f; + + Projectile.velocity *= 0.99f; + if (attackDowntime > 35) // Reposition to somewhere on the other side of the target + { + Projectile.velocity.X += 0.8f * Math.Sign(lastTargetCenter.X - lastFirePositionX); + TailRotationBasedOnMovement(); + } + else + { + CheckForSpecialAttack(); + tailRot = MathHelper.Lerp(tailRot, 0, 0.1f); + } + if (attackTimer > 60) // Fire the missiles + { + Vector2 shootVel = tailPlace.DirectionTo(lastTargetCenter); + Vector2 shootPlace = tailPlace + shootVel * 10; + + lastFirePositionX = Projectile.Center.X; + SoundEngine.PlaySound(AqueousHunterDrone.Fire with { Volume = 0.7f, Pitch = 0.0f, PitchVariance = 0.3f, MaxInstances = 10 }, Projectile.Center); + + for (int i = 0; i < 13; i++) + { + bool noFall = !Main.rand.NextBool(5); + float variance = Main.rand.NextFloat(-0.7f, 0.7f); + int dustStyle = noFall ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalPlasmaDust; + Dust dust = Dust.NewDustPerfect(tailPlace, dustStyle); + dust.scale = Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance); + dust.velocity = shootVel.RotatedBy(variance) * Main.rand.NextFloat(9, 9.5f) * (1 - Math.Abs(variance)); + dust.noGravity = noFall; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = noFall ? 0 : 1.1f; + } + + Particle bolt2 = new CustomPulse(shootPlace, shootVel * 0.2f, Effects.ArsenalEffects.ArsenalPlasmaColor, "CalamityMod/Particles/BloomRing", new Vector2(0.5f, 1f), shootVel.ToRotation(), 0f, 0.6f, 23); + GeneralParticleHandler.SpawnParticle(bolt2); + for (int i = 0; i < 2; i++) + { + Particle spark = new CustomSpark(shootPlace, shootVel * 0.2f, "CalamityMod/Particles/BloomCircle", false, 28, 0.6f, Effects.ArsenalEffects.ArsenalPlasmaColor, new Vector2(1f, 0.5f), true, true, 0, false, false); + GeneralParticleHandler.SpawnParticle(spark); + } + + for (int i = -1; i <= 1; i++) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), shootPlace, shootVel.RotatedBy(0.5f * i) * 8, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner, 0, 0, 0); + + doSpin = Main.rand.NextBool(5); + if (doSpin) + SoundEngine.PlaySound((Main.rand.NextBool() ? AqueousHunterDrone.Sound1 : AqueousHunterDrone.Sound2) with { Volume = 0.4f, Pitch = 0.2f, MaxInstances = 10 }, Projectile.Center); + tailRecoil = 25f; + Projectile.velocity += shootVel * (doSpin ? -18 : -9); + attackTimer = 0; + attackDowntime = 60; + } + attackTimer++; + } + public void TailRotationBasedOnMovement() + { + float sine = (float)Math.Sin(time * 0.1f / MathHelper.Pi); + tailRot = (sine * 0.2f) + 1.2f * (float)Math.Pow(Utils.GetLerpValue(0, 12 * facingDir, Projectile.velocity.X, true), 1.5f) * facingDir; + } + public void SetVisualPlacement() + { + float sine = (float)Math.Sin(time * 0.35f / MathHelper.Pi); + float sine2 = (float)Math.Sin(time * 0.05f / MathHelper.Pi); + Vector2 shake = new Vector2(3 * sine * (facingDir), 7 * sine2); + Vector2 visualPlace = Projectile.Center + shake + Vector2.UnitY * (surpriseTimer > 20 ? Utils.GetLerpValue(25, 20, surpriseTimer) : 1 - (float)Math.Pow(Utils.GetLerpValue(20, 15, surpriseTimer, true), 2)) * -25; + Vector2 tailDist = new Vector2((30 - Math.Abs(tailRot) * 15) * (-facingDir), 7 - Math.Abs(tailRot) * 3).RotatedBy(Projectile.rotation); + Vector2 headDist = new Vector2(0, 0); + Vector2 recoilPlace = ((Projectile.rotation - (facingDir == -1 ? MathHelper.Pi : 0) - (MathHelper.PiOver4 * -facingDir)).ToRotationVector2() * -tailRecoil); + headPlace = visualPlace + headDist; + tailPlace = visualPlace + tailDist + recoilPlace; + } + public void GrantBuffs(Player player) + { + bool isCorrectProjectile = Projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (isCorrectProjectile) + { + if (player.dead) + { + player.Calamity().aqueousHunterDrone = false; + } + if (player.Calamity().aqueousHunterDrone) + { + Projectile.timeLeft = 2; + } + } + } + public override bool MinionContactDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + Texture2D head = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/ShrimpBody").Value; + Texture2D glow = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/ShrimpBodyGlow").Value; + Texture2D tail = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/ShrimpTail").Value; + Texture2D glow2 = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/ShrimpTailGlow").Value; + Texture2D spin = ModContent.Request("CalamityMod/Particles/CircularSmearSmokey").Value; + Color drawColor = Projectile.GetAlpha(lightColor); + bool left = facingDir == -1; + float rotation = Projectile.rotation; + + // Tail + Main.EntitySpriteDraw(tail, tailPlace - Main.screenPosition, null, drawColor, rotation + tailRot, new Vector2(left ? tail.Height : 0, 0), Projectile.scale, left ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + Main.EntitySpriteDraw(glow2, tailPlace - Main.screenPosition, null, Color.White, rotation + tailRot, new Vector2(left ? glow2.Height : 0, 0), Projectile.scale, left ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + float sine = (float)Math.Sin(time * 0.35f / MathHelper.Pi); + float headFadeIn = (float)Math.Pow(Utils.GetLerpValue(0, animationClickTime - 25, time, true), 8); + // Head + Main.EntitySpriteDraw(head, headPlace - Main.screenPosition, null, drawColor * headFadeIn, rotation + sine * 0.1f, head.Size() * 0.5f, Projectile.scale, left ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + Main.EntitySpriteDraw(glow, headPlace - Main.screenPosition, null, Color.White * headFadeIn, rotation + sine * 0.1f, glow.Size() * 0.5f, Projectile.scale, left ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + // Spin effect + Main.EntitySpriteDraw(spin, Vector2.Lerp(headPlace, tailPlace, 0f) - Main.screenPosition, null, Effects.ArsenalEffects.ArsenalPlasmaColor with { A = 0 } * specialAttackfx, rotation * 1.8f, spin.Size() * 0.5f, Projectile.scale * 0.53f * specialAttackfx, left ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + + if (tailRecoil > 0) // Glowing on the gun after firing + { + float fade = Utils.GetLerpValue(0, 15, tailRecoil, true); + for (int i = 0; i < 12; i++) + { + Vector2 vel = (MathHelper.TwoPi * i / 12f).ToRotationVector2() * (2 + 2 * fade); + Main.EntitySpriteDraw(glow2, tailPlace - Main.screenPosition + vel, null, Color.White with { A = 0 } * fade, rotation + tailRot, new Vector2(left ? glow2.Height : 0, 0), Projectile.scale, left ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + } + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/AugerHoldout.cs b/Projectiles/DraedonsArsenal/AugerHoldout.cs new file mode 100644 index 0000000000..55dc54e885 --- /dev/null +++ b/Projectiles/DraedonsArsenal/AugerHoldout.cs @@ -0,0 +1,274 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Cooldowns; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static Terraria.Player; + + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AugerHoldout : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public ref float attackTimer => ref Projectile.ai[0]; + public Player Owner => Main.player[Projectile.owner]; + public float scaleFx = 1; + public int fireRate => Owner.itemAnimationMax; + public int time = 0; + public bool longSwing => swingCount >= 2; + public int cooldown => -Owner.itemAnimationMax * (Owner.Calamity().buffedAuger ? 2 : longSwing ? 3 : 1); + public float bladeRot = 0; // Rotation of the blade + public int swingCount = 0; // Increases at the start of a swing + public float bladefx = 0; // Scaling on the effects of the blade + // Both checks to make sure sounds/hitboxes only happen once per swing + public bool makeSound = true; + public bool makeHitbox = true; + public int cooldownGiven => (int)(800 / Owner.GetAttackSpeed()); // Cooldown is effected by melee speed, lines up perfectly so you do 22 swings and end in time for a big swing + public float pullFx = 1; // Scaling on the effects of the blade when it's buffed + public bool pressedRight = false; + // Spawns a hitbox to do damage, rather than dealing damage itself + // Theres many reasons this is better, but at the very least it prevents bloating this single projectile's code + public override bool? CanDamage() => false; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 100; + Projectile.friendly = true; + Projectile.DamageType = TrueMeleeDamageClass.Instance; + Projectile.timeLeft = 5; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public void Positioning(Vector2 toMouse) // Hand and holdout positioning + { + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Owner.direction).ToRotation(); + + Owner.ChangeDir(Math.Sign(toMouse.X)); + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, (toMouse.ToRotation() + bladeRot * Owner.direction + MathHelper.PiOver2 * -Owner.direction) + (Owner.direction == -1 ? MathHelper.Pi : 0)); + Vector2 handPos = Owner.GetFrontHandPosition(CompositeArmStretchAmount.None, Owner.compositeFrontArm.rotation) + (Owner.compositeFrontArm.rotation + MathHelper.PiOver2).ToRotationVector2() * 9; + float armRotation = (Utils.DirectionTo(Owner.Center, handPos).ToRotation() - MathHelper.PiOver2) * Owner.gravDir + (Owner.gravDir == -1 ? MathHelper.Pi : 0f); + Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, armRotation); + Projectile.velocity = toMouse.RotatedBy(bladeRot * Owner.direction); + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.Center = handPos; + } + public void OnSpawn() + { + if (time == 0) + { + scaleFx = Owner.Calamity().buffedAuger ? 1.5f : 1; + attackTimer = cooldown; + if (Owner.Calamity().buffedAuger) + { + swingCount = 1; + } + } + } + public override void AI() + { + if (!Owner.CantUseHoldout(false)) + Projectile.timeLeft = 5; + + Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld()); + + Positioning(toMouse); + + if (Owner.Calamity().mouseRight) + pressedRight = true; + + #region Right Click + if (Projectile.ai[2] > 0) // Right click "gravity well" and buff + { + if (Projectile.ai[2] == 5) + { + time = 0; + attackTimer = 0; + swingCount = -1; + makeHitbox = true; + Projectile.ai[2]--; + pullFx = 5; + } + if (bladefx > 0) + bladefx = 0; + bladeRot = 0; + pullFx = MathHelper.Lerp(pullFx, 1, 0.12f); + + if (attackTimer > fireRate && makeHitbox) + { + Projectile magnetZone = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.ClampedMouseWorld(), Vector2.Zero, ModContent.ProjectileType(), 0, 0, Projectile.owner, 0, 0, 0); + + SoundStyle pull = new("CalamityMod/Sounds/Item/AugerPull"); + SoundEngine.PlaySound(pull with { Volume = 0.9f, Pitch = 0 }, Owner.ClampedMouseWorld()); + Owner.Calamity().buffedAuger = true; + Owner.Calamity().arsenalCooldown = cooldownGiven; + Owner.AddCooldown(ArsenalPower.ID, cooldownGiven); + makeHitbox = false; + } + if (attackTimer >= fireRate * 2) + { + Projectile.Kill(); + return; + } + time++; + attackTimer++; + return; + } + #endregion + + OnSpawn(); + + if (scaleFx > 1 && !Owner.Calamity().buffedAuger) // Fade out the extra size from the big blade + scaleFx = MathHelper.Lerp(scaleFx, 1, 0.15f * Owner.GetAttackSpeed()); + + #region Not Swinging + if (attackTimer < 0) // When the sword isn't swinging + { + if ((pressedRight || Owner.Calamity().mouseRight) && !Owner.Calamity().buffedAuger && Owner.Calamity().arsenalCooldown <= 0) + Projectile.ai[2] = 5; + else + pressedRight = false; + if (longSwing && attackTimer == -1) + { + swingCount = 0; + } + attackTimer++; + time++; + + if (longSwing && attackTimer <= cooldown * 0.35f) + { + float lerp = Utils.GetLerpValue(cooldown, -1, attackTimer, true); + bladefx = MathHelper.Lerp(bladefx, 0, lerp); + } + else + { + if (!Main.mouseLeft && longSwing && !Owner.Calamity().buffedAuger) + { + Projectile.Kill(); + return; + } + + float lerp = Utils.GetLerpValue((longSwing ? cooldown * 0.35f : cooldown), -1, attackTimer, true); + bladefx = MathHelper.Lerp(bladefx, 1.5f, lerp); + } + if (attackTimer >= cooldown * 0.3f) + { + if (makeSound && Owner.Calamity().buffedAuger) // Windup Sound + { + SoundStyle windup = new("CalamityMod/Sounds/Item/AugerWindup"); + SoundEngine.PlaySound(windup with { Volume = 0.9f, Pitch = 0 }, Projectile.Center); + makeSound = false; + } + } + if (attackTimer == 0) // Reset a few things in prep for the next swing + { + pressedRight = false; + swingCount++; + makeSound = true; + makeHitbox = true; + } + else // Wind up animation in prep for the next swing + { + int swingDir = (swingCount % 2 != 0 ? 1 : -1); + float lerp = Utils.GetLerpValue(cooldown, -1, attackTimer, true); + bladeRot = MathHelper.Lerp(-MathHelper.Pi * swingDir, -MathHelper.PiOver4 * 3 * swingDir, CalamityUtils.EaseInOutExp(lerp, 2f, 2f)); + } + return; + } + #endregion + + if (attackTimer >= fireRate) // Once the swing is done, put it on cooldown + { + attackTimer = cooldown * (Owner.Calamity().buffedAuger ? 3 : 1); + if (Owner.Calamity().buffedAuger) + { + Owner.Calamity().buffedAuger = false; + } + } + else // Do the swing + { + #region Swinging + int swingDir = (swingCount % 2 != 0 ? -1 : 1); + float lerp = Utils.GetLerpValue(0, fireRate - 1, attackTimer, true); + bladeRot = MathHelper.Lerp(-MathHelper.PiOver4 * 3 * swingDir, MathHelper.Pi * swingDir, CalamityUtils.EaseInOutExp(lerp, 5f, 3f)); + + if (lerp > 0.5f) // Halfway through make the hitbox and sound + { + if (makeHitbox) + { + SoundStyle swing = Owner.Calamity().buffedAuger ? new("CalamityMod/Sounds/Item/AugerBigSlash") : swingCount % 2 != 0 ? new("CalamityMod/Sounds/Item/AugerSlash1") : new("CalamityMod/Sounds/Item/AugerSlash2"); + SoundEngine.PlaySound(swing with { Volume = Owner.Calamity().buffedAuger ? 1f : 0.7f, Pitch = -0.1f, MaxInstances = 2 }, Projectile.Center); + + int damage = Projectile.damage; + if (Owner.Calamity().buffedAuger) + { + Owner.SetScreenshake(5f); + damage = (int)(damage * 2.5f); + } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center + toMouse * 20 * (float)Math.Pow(scaleFx, 4), toMouse * 25, ModContent.ProjectileType(), damage, 0, Projectile.owner, 0, swingCount, Owner.Calamity().buffedAuger ? 5 : 0); + makeHitbox = false; + } + } + #endregion + } + time++; + attackTimer++; + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 3) + return false; + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/AugerHoldout").Value; + Texture2D glow = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/AugerHoldoutGlow").Value; + Texture2D blade = ModContent.Request("CalamityMod/Particles/GlowBlade").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 vel = Projectile.rotation.ToRotationVector2(); + float randSize = Main.rand.NextFloat(0.8f, 1f); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Owner.direction == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = Owner.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float lerp = Utils.GetLerpValue(0, fireRate - 1, attackTimer, true); + float length = MathHelper.Lerp(0f, 0.1f, CalamityUtils.EaseInOutExp(lerp, 1f, 1f)); + float bladeRotation = drawRotation + MathHelper.PiOver2 * Owner.direction; + Vector2 bladePlaceAdjust = (bladeRotation - MathHelper.PiOver2).ToRotationVector2(); + for (int i = 0; i < 2; i++) // The actual energy blade + Main.EntitySpriteDraw(blade, drawPosition + bladePlaceAdjust * 20, null, (i == 0 ? Effects.ArsenalEffects.ArsenalGaussColor : Color.White) with { A = 0 }, bladeRotation, new Vector2(blade.Width / 2, blade.Height), new Vector2((i == 0 ? 0.2f : 0.1f) * randSize, 0.2f * bladefx) * Projectile.scale * 0.07f * bladefx * scaleFx, SpriteEffects.None); + for (int i = 0; i < 2; i++) // The glow at the "hilt" + Main.EntitySpriteDraw(bloom, drawPosition + bladePlaceAdjust * 20, null, (i == 0 ? Effects.ArsenalEffects.ArsenalGaussColor : Color.White) with { A = 0 }, bladeRotation, bloom.Size() / 2, (Projectile.ai[2] > 0 ? new Vector2(randSize, randSize * (i == 0 ? 1f : 0.9f)) * 0.1f : new Vector2(0.15f * bladefx * randSize, (i == 0 ? 0.1f : 0.05f))) * Projectile.scale * 0.9f * (Projectile.ai[2] > 0 ? pullFx : bladefx) * scaleFx, SpriteEffects.None); + + if (scaleFx > 1) // Extra blade tips for the improved slash + { + for (int b = -2; b <= 2; b++) + { + if (b == 0) b++; + for (int i = 0; i < 2; i++) + { + Main.EntitySpriteDraw(blade, drawPosition + bladePlaceAdjust * 20, null, (i == 0 ? Effects.ArsenalEffects.ArsenalGaussColor : Color.White) with { A = 0 }, bladeRotation + (MathHelper.PiOver4 * 0.55f * b), new Vector2(blade.Width / 2, blade.Height), new Vector2(0.65f * (i == 0 ? 0.1f : 0.05f), 0.09f * (i == 0 ? 1f : 0.9f) * (2 - Math.Abs(b * 0.5f))) * randSize * Projectile.scale * 0.2f * bladefx * (scaleFx - 1), SpriteEffects.None); + } + } + } + Vector2 placeAdjust = (drawRotation + MathHelper.PiOver2).ToRotationVector2() * 2.5f; + Main.EntitySpriteDraw(texture, drawPosition + placeAdjust, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); // The holdout + + Main.EntitySpriteDraw(glow, drawPosition + placeAdjust, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); // The glow + + return false; + } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overPlayers.Add(index); + } + } +} diff --git a/Projectiles/DraedonsArsenal/AugerHoldout.png b/Projectiles/DraedonsArsenal/AugerHoldout.png new file mode 100644 index 0000000000..ec5c4b477a Binary files /dev/null and b/Projectiles/DraedonsArsenal/AugerHoldout.png differ diff --git a/Projectiles/DraedonsArsenal/AugerHoldoutGlow.png b/Projectiles/DraedonsArsenal/AugerHoldoutGlow.png new file mode 100644 index 0000000000..63a21f6979 Binary files /dev/null and b/Projectiles/DraedonsArsenal/AugerHoldoutGlow.png differ diff --git a/Projectiles/DraedonsArsenal/AugerPull.cs b/Projectiles/DraedonsArsenal/AugerPull.cs new file mode 100644 index 0000000000..ce365ce951 --- /dev/null +++ b/Projectiles/DraedonsArsenal/AugerPull.cs @@ -0,0 +1,109 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AugerPull : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public float sine = 0; + public float shrink = 1; + public int strongTimer = 0; + public bool strong => strongTimer < 10; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 250; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.tileCollide = false; + Projectile.timeLeft = 90; + Projectile.penetrate = -1; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15; + } + + public override void AI() + { + if (strongTimer == 0) + { + Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalGaussColor, "CalamityMod/Particles/GlowSquareParticleBig", Vector2.One, 0, 1.1f, 0.7f, 30); + GeneralParticleHandler.SpawnParticle(bolt2); + for (int i = 0; i < 20; i++) + { + Vector2 dustVel2 = (Vector2.UnitX).RotatedByRandom(100) * Main.rand.NextFloat(10f, 15.5f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel2.SafeNormalize(Vector2.UnitX) * 360, ModContent.DustType(), -dustVel2 * 1.5f, 0, default, Main.rand.NextFloat(1.2f, 1.8f)); + dust2.noGravity = true; + dust2.fadeIn = 0.3f; + dust2.color = Effects.ArsenalEffects.ArsenalGaussColor; + } + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + if (target != null && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < 650) + { + Vector2 moveDir = target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX); + target.velocity = moveDir; + target.Center += moveDir * 3f; + } + } + } + + Vector2 dustVel = (Vector2.UnitX).RotatedByRandom(100) * Main.rand.NextFloat(3f, 8.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel.SafeNormalize(Vector2.UnitX) * 120, Effects.ArsenalEffects.ArsenalGaussDust, -dustVel, 0, default, Main.rand.NextFloat(0.5f, 1f)); + dust.noGravity = true; + dust.fadeIn = 0.05f; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + + if (Projectile.timeLeft > 2) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + if (target != null && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1)) + { + if (Vector2.Distance(target.Center, Projectile.Center) > 15 && Vector2.Distance(target.Center, Projectile.Center) < 300) + { + Vector2 moveDir = target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX); + target.velocity = Vector2.Lerp(target.velocity, moveDir * 5, 0.12f); + target.Center += moveDir * 2f; + } + } + } + } + + Projectile.rotation += 0.05f; + if (shrink > 0) + shrink -= 0.05f; + else + shrink = 1; + + if (!strong) + time++; + strongTimer++; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => false; + public override bool PreDraw(ref Color lightColor) + { + float shrinkFade = Math.Min(Utils.GetLerpValue(1, 0.7f, shrink, true), Utils.GetLerpValue(0f, 0.3f, shrink, true)); + float sine = Math.Abs(MathHelper.Lerp((float)Math.Sin(time * 0.1f / MathHelper.Pi), 0.4f, 0.8f)); + float sine2 = Math.Abs(MathHelper.Lerp((float)Math.Sin(time * 0.3f / MathHelper.Pi), 0.4f, 0.8f)); + float fade = (float)Math.Pow(Utils.GetLerpValue(0, 10, Projectile.timeLeft, true), 3); + float areaScale = (strong ? 1f : 1) * fade; + Texture2D tex2 = ModContent.Request("CalamityMod/Particles/GlowSquareParticleBig").Value; + Color drawColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * (strong ? 0.5f : 0.3f) * shrinkFade; + + Main.EntitySpriteDraw(tex2, Projectile.Center - Main.screenPosition, null, drawColor, MathHelper.PiOver4 - MathHelper.PiOver2 * sine * 3, tex2.Size() / 2f, (areaScale + sine * 0.5f) * shrink, SpriteEffects.None, 0); + Main.EntitySpriteDraw(tex2, Projectile.Center - Main.screenPosition, null, drawColor, MathHelper.PiOver2 * sine2 * 3, tex2.Size() / 2f, (areaScale - sine2 * 0.5f) * (float)Math.Pow(shrink, 2), SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/AugerSlash.cs b/Projectiles/DraedonsArsenal/AugerSlash.cs new file mode 100644 index 0000000000..ac72757579 --- /dev/null +++ b/Projectiles/DraedonsArsenal/AugerSlash.cs @@ -0,0 +1,166 @@ +using System; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AugerSlash : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public ref float time => ref Projectile.ai[0]; + public float fade = 1; + public int lifetime = 25; + public Player Owner => Main.player[Projectile.owner]; + public float scaleFx => Projectile.ai[2] == 5 ? 2 : 1; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 120; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Melee; + Projectile.timeLeft = lifetime; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + fade = (float)Math.Pow(Utils.GetLerpValue(lifetime * 0.1f, lifetime * 0.5f, Projectile.timeLeft, true), 4); + if (Projectile.velocity.Length() > 0.1f) + Projectile.velocity *= 0.45f; + int dusts = (int)(30 * scaleFx); + if (time == 1) + { + for (int i = 0; i < dusts; i++) + { + float variance = Utils.GetLerpValue(0, dusts, i, true) * Main.rand.NextFloat(0.9f, 1f); + float rot = MathHelper.Lerp(-0.7f * scaleFx, 0.7f * scaleFx, variance) * Projectile.direction; + float swingDirScale = Projectile.ai[1] == 1 ? (1 - variance) : variance; + float scale = 0.4f + swingDirScale * 2f; + float rotScaling = 1 - Math.Abs(rot); + Vector2 vel = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(rot) * (70 / scaleFx + 80 * (float)Math.Pow(rotScaling, 1.5f) * Main.rand.NextFloat(0.85f, 1f)) * scaleFx; + Vector2 finalDustVel = (vel * (float)Math.Pow(rotScaling, 1.5f) + (vel.RotatedBy(-MathHelper.PiOver2 * rot) * 1.5f)) * 0.03f; + Dust s = Dust.NewDustPerfect(Projectile.Center + vel - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 45 * scaleFx, ModContent.DustType(), finalDustVel / scaleFx); + s.scale = scale * scaleFx; + s.noGravity = true; + s.color = Color.Lerp(Effects.ArsenalEffects.ArsenalGaussColor, Color.White, Math.Max(0, swingDirScale - 0.35f)); + s.fadeIn = 0.1f + swingDirScale; + } + } + + Lighting.AddLight(Projectile.Center, Color.Lerp(Effects.ArsenalEffects.ArsenalGaussColor, Color.White, 0.3f).ToVector3() * 0.7f); + time++; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) + { + Projectile.numHits -= 1; + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.ai[2] == 5) + { + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && p.owner == Projectile.owner) + { + if (p.timeLeft > 2) + p.timeLeft = 2; + } + } + } + + Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float launchPower = (Projectile.ai[2] == 5 ? 35 : 14); + target.MoveNPC(launchVel, launchPower, true); + + if (Projectile.ai[2] == 5) + modifiers.SetCrit(); + + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); + float minMult = 0.3f; + int hitsToMinMult = 7; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= (Projectile.ai[2] == 5 ? (1f + critDamage) : 1) * damageMult; + + if (Projectile.numHits == 0) + { + SoundStyle hit = new("CalamityMod/Sounds/Item/AugerHit"); + SoundEngine.PlaySound(hit with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f), MaxInstances = 2 }, target.Center); + } + if (Projectile.numHits < 4) + { + for (int i = 0; i < (14 - Projectile.numHits * 2); i++) + { + float rot = Main.rand.NextFloat(-0.3f, 0.3f); + Dust s = Dust.NewDustPerfect(target.Center, ModContent.DustType(), Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(rot) * (float)Math.Pow(scaleFx, 1.5f) * Main.rand.NextFloat(8, 12) * (1 - Math.Abs(rot))); + s.scale = Main.rand.NextFloat(1.6f, 1.9f) * (1 - Math.Abs(rot)); + s.noGravity = true; + s.color = Color.Lerp(Effects.ArsenalEffects.ArsenalGaussColor, Color.White, Main.rand.NextFloat(0, 0.4f)); + s.fadeIn = -0.5f; + if (i % 3 != 0) + { + Dust s2 = Dust.NewDustPerfect(target.Center, Effects.ArsenalEffects.ArsenalGaussDust, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.6f) * (float)Math.Pow(scaleFx, 1.5f) * Main.rand.NextFloat(5, 10)); + s2.scale = Main.rand.NextFloat(0.9f, 1.4f); + s2.noGravity = true; + s2.color = Effects.ArsenalEffects.ArsenalGaussColor; + } + } + } + } + + public override bool? CanHitNPC(NPC target) + { + Player owner = Main.player[Projectile.owner]; + + if (!Collision.CanHitLine( + owner.Center, 1, 1, + target.Center, 1, 1)) + return false; + return base.CanHitNPC(target); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (Projectile.timeLeft <= 10) + return false; + Player Owner = Main.player[Projectile.owner]; + Vector2 start = (time < 2 ? Owner.Center : Projectile.Center); + float scale = (scaleFx > 1 ? 1.5f : 1); + float length = 135 * scale; + float size = 135 * scale; + float _ = float.NaN; + bool hit = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, start + Projectile.velocity.SafeNormalize(Vector2.UnitX) * length, size, ref _); + return (hit); + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D proj = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/AugerSlash").Value; + + Vector2 vel = Projectile.rotation.ToRotationVector2(); + + Color drawColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 }; + float drawRotation = Projectile.velocity.ToRotation(); + + float lerp = 1 - (float)Math.Pow((Utils.GetLerpValue(lifetime, 0, time, true)), 2f); + float sizeLerp = (float)Math.Pow((Utils.GetLerpValue(lifetime, lifetime * 0.2f, time, true)), 5f); + Vector2 squash = new Vector2(1 + lerp * 0.5f, 1.25f - lerp * 1.1f) * 0.08f * sizeLerp; + Vector2 rotationPoint = new Vector2(proj.Width * 0.85f, proj.Height / 2); + Vector2 drawPosition = Projectile.Center - Main.screenPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 105; + + SpriteEffects spfx = (Projectile.ai[1] != 1 ? SpriteEffects.None : SpriteEffects.FlipVertically); + if (Projectile.direction == -1) + spfx = (Projectile.ai[1] == 1 ? SpriteEffects.None : SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(proj, drawPosition, null, Color.White with { A = 0 } * sizeLerp, drawRotation, rotationPoint, squash * Projectile.scale * scaleFx, spfx); + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/AugerSlash.png b/Projectiles/DraedonsArsenal/AugerSlash.png new file mode 100644 index 0000000000..c2643dcb63 Binary files /dev/null and b/Projectiles/DraedonsArsenal/AugerSlash.png differ diff --git a/Projectiles/DraedonsArsenal/AugerSlashAlt.png b/Projectiles/DraedonsArsenal/AugerSlashAlt.png new file mode 100644 index 0000000000..38d9b158cb Binary files /dev/null and b/Projectiles/DraedonsArsenal/AugerSlashAlt.png differ diff --git a/Projectiles/DraedonsArsenal/CountermeasureMittFinger.png b/Projectiles/DraedonsArsenal/CountermeasureMittFinger.png new file mode 100644 index 0000000000..4872bab1bc Binary files /dev/null and b/Projectiles/DraedonsArsenal/CountermeasureMittFinger.png differ diff --git a/Projectiles/DraedonsArsenal/CountermeasureMittFinger2.png b/Projectiles/DraedonsArsenal/CountermeasureMittFinger2.png new file mode 100644 index 0000000000..c5619e167a Binary files /dev/null and b/Projectiles/DraedonsArsenal/CountermeasureMittFinger2.png differ diff --git a/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs new file mode 100644 index 0000000000..6ab5de6adc --- /dev/null +++ b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs @@ -0,0 +1,578 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Cooldowns; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.Player; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + [PierceResistException] + public class CountermeasureMittHoldout : BaseGunHoldoutProjectile + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override int AssociatedItemID => ModContent.ItemType(); + + public float offsetBase = 0; + public override float MaxOffsetLengthFromArm => offsetBase; + public override float RecoilResolveSpeed => 0.4f; + public override float OffsetXUpwards => 0f; + public override float BaseOffsetY => 0f; + public override float OffsetYDownwards => 0f; + public override float WeaponTurnSpeed => 0.5f; + public bool forcePalm => Projectile.ai[2] != 0; // If you're performing a palm blast or not + public ref float shootingTimer => ref Projectile.ai[0]; + public ref float fireRate => ref Projectile.ai[1]; + public int time = 0; + + // Finger lerps and rotations + #region Fingers + public float rotSpeed = 0; + public float f1l => 0.02f * rotSpeed; // Finger Lerp Speed + public float f1r = 0; // Finger Rotation + public float f1x = 0; // Finger Effects Multiplier + public float f1d = -0.95f; // Finger Aim Direction + public SlotId AudSlot1; // Finger Laser Audio Slot + public float f2l => 0.016f * rotSpeed; + public float f2r = 0; + public float f2x = 0; + public float f2d = -0.95f; + public SlotId AudSlot2; + public float f3l => 0.012f * rotSpeed; + public float f3r = 0; + public float f3x = 0; + public float f3d = -0.95f; + public SlotId AudSlot3; + public float f4l => 0.008f * rotSpeed; + public float f4r = 0; + public float f4x = 0; + public float f4d = -0.95f; + public SlotId AudSlot4; + public float f5l => 0.004f * rotSpeed; + public float f5r = 0; + public float f5x = 0; + public float f5d = -0.95f; + public SlotId AudSlot5; + #endregion + + public int palmAnimTime = 20; // Animation length for the palm attack + public int cooldownGiven = 400; // Arsenal Cooldown from the palm attack + public int attackTime = 100; // Attack cycle length + public int attackCycles = 0; + public bool failedManaCheck = false; + public bool canHit = false; + public float alteredRotationRot = 0.7f; // Alteration to the holdout rotation so it's not directly to the mouse, changes with the attack cycle + public float alteredRotation => Projectile.rotation + (f2r * alteredRotationRot * -Projectile.direction); + public Vector2 palmBlastPos => Owner.Center + alteredRotation.ToRotationVector2() * 55 * Projectile.scale; + public int palmManaCost => HeldItem.mana * 30; + public int hitTimer = 0; + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.tileCollide = false; + Projectile.ArmorPenetration = 55; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 5; + } + public override void KillHoldoutLogic() + { + + } + public override bool? CanDamage() => null; + public override bool? CanHitNPC(NPC target) + { + return (canHit ? null : false); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canHit) return false; + float realRot = alteredRotation; + Vector2 handPos = Owner.GetBackHandPosition(CompositeArmStretchAmount.None, Owner.compositeBackArm.rotation) + (Owner.compositeBackArm.rotation + MathHelper.PiOver2).ToRotationVector2() * 9; + + // Every laser has collision for the single hitbox, so it works more like a large wide piercing single beam + float beamLength = 1500 * Projectile.scale; + float beamThickness = 20 * Projectile.scale; + float fingerLength = 6 * Projectile.scale; + float _ = float.NaN; + + bool colCheck = false; + + #region 5 Collision Line Checks + for (int t = 0; t < 5; t++) + { + float rot = t switch + { + 1 => f4r * Projectile.direction, + 2 => f3r * Projectile.direction, + 3 => f2r * Projectile.direction, + 4 => f1r * Projectile.direction, + _ => -f5r * 0.3f * Projectile.direction, + }; + float fx = t switch + { + 1 => f4x, 2 => f3x, 3 => f2x, 4 => f1x, _ => f5x, + }; + + Vector2 basePosition = handPos + alteredRotation.ToRotationVector2() * (t == 0 ? 2.5f : 3.3f) * Projectile.scale + (alteredRotation + rot).ToRotationVector2() * fingerLength + (alteredRotation + MathHelper.PiOver2 * -Projectile.direction).ToRotationVector2() * (t == 0 ? -3 : 3) * Projectile.scale; + if (fx > 0.2f) + colCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), basePosition, basePosition + (realRot + rot).ToRotationVector2() * (fingerLength + beamLength), beamThickness, ref _); + if (colCheck) + t = 5; + } + #endregion + + return (colCheck); + } + public void EndSounds() + { + if (SoundEngine.TryGetActiveSound(AudSlot1, out var s1)) + s1?.Stop(); + if (SoundEngine.TryGetActiveSound(AudSlot2, out var s2)) + s2?.Stop(); + if (SoundEngine.TryGetActiveSound(AudSlot3, out var s3)) + s3?.Stop(); + if (SoundEngine.TryGetActiveSound(AudSlot4, out var s4)) + s4?.Stop(); + if (SoundEngine.TryGetActiveSound(AudSlot5, out var s5)) + s5?.Stop(); + } + public override void HoldoutAI() + { + if (hitTimer > 0) + hitTimer--; + + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, (alteredRotation + MathHelper.PiOver2 * -Projectile.direction) + (Owner.direction == -1 ? MathHelper.Pi : 0)); + + Vector2 handPos = Owner.GetBackHandPosition(CompositeArmStretchAmount.None, Owner.compositeBackArm.rotation) + (Owner.compositeBackArm.rotation + MathHelper.PiOver2).ToRotationVector2() * 4; + float armRotation = (Utils.DirectionTo(Owner.Center, handPos).ToRotation() - MathHelper.PiOver2) * Owner.gravDir + (Owner.gravDir == -1 ? MathHelper.Pi : 0f); + Owner.SetCompositeArmFront(true, FrontArmStretch, armRotation + ExtraFrontArmRotation * Projectile.direction); + + // Below you see the sacrifice of coding 5 individual fingers + if (time == 0 && forcePalm) + { + rotSpeed = 7f; + alteredRotationRot = 0; + } + if (time == 1) + rotSpeed = 0; + + if (forcePalm) alteredRotationRot = MathHelper.Lerp(alteredRotationRot, 0, 0.1f); + else if (shootingTimer > -10) alteredRotationRot = MathHelper.Lerp(alteredRotationRot, 0.7f, 0.1f); + + #region The Price of 5 Fingers + float fxPower = 5; + if (!forcePalm) + { + if (shootingTimer == 10) f1d *= -1; + if (shootingTimer == 20) f2d *= -1; + if (shootingTimer == 30) f3d *= -1; + if (shootingTimer == 40) f4d *= -1; + if (shootingTimer == 50) f5d *= -1; + if (attackCycles == 0) + { + if (shootingTimer == 10) f1x = fxPower; + if (shootingTimer == 20) f2x = fxPower; + if (shootingTimer == 30) f3x = fxPower; + if (shootingTimer == 40) f4x = fxPower; + if (shootingTimer == 50) f5x = fxPower; + } + } + + f1r = MathHelper.Lerp(f1r, f1d, f1l * rotSpeed); + f2r = MathHelper.Lerp(f2r, f2d * 0.775f, f2l * rotSpeed); + f3r = MathHelper.Lerp(f3r, f3d * 0.55f, f3l * rotSpeed); + f4r = MathHelper.Lerp(f4r, f4d * 0.325f, f4l * rotSpeed); + f5r = MathHelper.Lerp(f5r, f5d * 2.3f - 2, f5l * 4 * rotSpeed); + + float goalValue = (canHit ? 1 : 0); + float lerpPower = (forcePalm ? 0.35f : canHit ? 0.2f : 0.25f); + f1x = MathHelper.Lerp(f1x, (f1x > 0.05f ? goalValue : 0), lerpPower); + f2x = MathHelper.Lerp(f2x, (f2x > 0.05f ? goalValue : 0), lerpPower); + f3x = MathHelper.Lerp(f3x, (f3x > 0.05f ? goalValue : 0), lerpPower); + f4x = MathHelper.Lerp(f4x, (f4x > 0.05f ? goalValue : 0), lerpPower); + f5x = MathHelper.Lerp(f5x, (f5x > 0.05f ? goalValue : 0), lerpPower); + + float sine = (float)Math.Sin(time * 0.2f / MathHelper.Pi) * 0.1f; + float maxVol = 0.4f; + float minPitch = -0.8f; + if (SoundEngine.TryGetActiveSound(AudSlot1, out var f1s) && f1s.IsPlaying) + { + f1s.Position = Projectile.Center; + f1s.Pitch = Utils.Remap(f1x, 0.7f, 1, 0f + minPitch, 0f) + sine; + f1s.Volume = Utils.Remap(f1x, 0, 1, 0f, maxVol) * 100; + } + else if (f1x > 1) + { + SoundStyle beam = new("CalamityMod/Sounds/Item/MittWelding/Weld1"); + AudSlot1 = SoundEngine.PlaySound(beam with { Volume = 0.01f, Pitch = 0, IsLooped = true }, Projectile.Center); + } + if (SoundEngine.TryGetActiveSound(AudSlot2, out var f2s) && f2s.IsPlaying) + { + f2s.Position = Projectile.Center; + f2s.Pitch = Utils.Remap(f2x, 0.7f, 1, 0.2f + minPitch, 0.2f) + sine; + f2s.Volume = Utils.Remap(f2x, 0, 1, 0f, maxVol) * 100; + } + else if (f2x > 1) + { + SoundStyle beam = new("CalamityMod/Sounds/Item/MittWelding/Weld2"); + AudSlot2 = SoundEngine.PlaySound(beam with { Volume = 0.01f, Pitch = 0, IsLooped = true }, Projectile.Center); + } + if (SoundEngine.TryGetActiveSound(AudSlot3, out var f3s) && f3s.IsPlaying) + { + f3s.Position = Projectile.Center; + f3s.Pitch = Utils.Remap(f3x, 0.7f, 1, 0.4f + minPitch, 0.4f) + sine; + f3s.Volume = Utils.Remap(f3x, 0, 1, 0f, maxVol) * 100; + } + else if (f3x > 1) + { + SoundStyle beam = new("CalamityMod/Sounds/Item/MittWelding/Weld3"); + AudSlot3 = SoundEngine.PlaySound(beam with { Volume = 0.01f, Pitch = 0, IsLooped = true }, Projectile.Center); + } + if (SoundEngine.TryGetActiveSound(AudSlot4, out var f4s) && f4s.IsPlaying) + { + f4s.Position = Projectile.Center; + f4s.Pitch = Utils.Remap(f4x, 0.7f, 1, 0.6f + minPitch, 0.6f) + sine; + f4s.Volume = Utils.Remap(f4x, 0, 1, 0f, maxVol) * 100; + } + else if (f4x > 1) + { + SoundStyle beam = new("CalamityMod/Sounds/Item/MittWelding/Weld4"); + AudSlot4 = SoundEngine.PlaySound(beam with { Volume = 0.01f, Pitch = 0, IsLooped = true }, Projectile.Center); + } + if (SoundEngine.TryGetActiveSound(AudSlot5, out var f5s) && f5s.IsPlaying) + { + f5s.Position = Projectile.Center; + f5s.Pitch = Utils.Remap(f5x, 0.7f, 1, 0.8f + minPitch, 0.8f) + sine; + f5s.Volume = Utils.Remap(f5x, 0, 1, 0f, maxVol) * 100; + } + else if (f5x > 1) + { + SoundStyle beam = new("CalamityMod/Sounds/Item/MittWelding/Weld5"); + AudSlot5 = SoundEngine.PlaySound(beam with { Volume = 0.01f, Pitch = 0, IsLooped = true }, Projectile.Center); + } + #endregion + + Lighting.AddLight(Projectile.Center, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, 0.3f).ToVector3() * MathHelper.Clamp((f1x + f2x + f3x + f4x + f5x - 4f) * 2f, 0f, 0.7f)); + Projectile.scale = MathHelper.Lerp(Projectile.scale, 1, 0.1f); + + if (time == 0) + { + if (!forcePalm) + shootingTimer = -40; + if (Projectile.ai[2] != 0) + Projectile.ai[2] = palmAnimTime; + fireRate = attackTime; + OffsetLengthFromArm = offsetBase; + } + if (shootingTimer < 0) + { + canHit = false; + // Light cooldown before firing + if (rotSpeed > 0) + rotSpeed -= 0.05f; + + if (shootingTimer == -1 || forcePalm) + { + if ((!Main.mouseLeft && !forcePalm) || failedManaCheck) + { + EndSounds(); + Projectile.Kill(); + return; + } + + attackCycles = 0; + fireRate = attackTime; + } + + } + if (Owner.Calamity().mouseRight && Owner.Calamity().arsenalCooldown <= 0 && !forcePalm && !failedManaCheck) + { + Projectile.ai[2] = 5; + shootingTimer = 0; + } + if (forcePalm) + { + if (!Owner.CheckMana(HeldItem, palmManaCost, false, false)) + { + failedManaCheck = true; + SoundEngine.PlaySound(SoundID.MaxMana with { Pitch = -0.5f }, Projectile.Center); + Projectile.ai[2] = 0; + return; + } + rotSpeed = 5; + + f1d = -Math.Abs(f1d); f2d = -Math.Abs(f2d); f3d = -Math.Abs(f3d); f4d = -Math.Abs(f4d); f5d = -Math.Abs(f5d); + + if (shootingTimer <= palmAnimTime) + { + if (shootingTimer == 1) + { + SoundStyle aud = new("CalamityMod/Sounds/Item/MittReadyPalm"); + SoundEngine.PlaySound(aud with { Volume = 1f, Pitch = 0 }, Projectile.Center); + } + if (shootingTimer == (int)(palmAnimTime * 0.8f)) + { + SoundStyle aud = new("CalamityMod/Sounds/Item/MittThrust"); + SoundEngine.PlaySound(aud with { Volume = 1f, Pitch = 0 }, Projectile.Center); + } + if (shootingTimer == palmAnimTime) + { + Shoot(); + Projectile.ai[2] = 0; + shootingTimer = -30; + rotSpeed = 0; + } + Lighting.AddLight(palmBlastPos, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, 0.3f).ToVector3() * (float)Math.Pow(Utils.GetLerpValue(0, palmAnimTime, shootingTimer), 2)); + } + if (shootingTimer > palmAnimTime * 0.8f) + Projectile.scale *= 1.25f; + canHit = false; + } + else if (shootingTimer >= 0) + { + if (!Main.mouseLeft) + shootingTimer = fireRate; + + if (shootingTimer < fireRate && !failedManaCheck) + { + canHit = true; + if (time % 3 == 0) + { + if (Owner.CheckMana(HeldItem, -1, true, false)) + { + if (rotSpeed < 1.1f) + rotSpeed += 0.1f; + } + else + { + SoundEngine.PlaySound(SoundID.MaxMana with { Pitch = -0.5f }, Projectile.Center); + failedManaCheck = true; + } + } + } + else + { + if (attackCycles < 1 && !failedManaCheck) + { + attackCycles++; + shootingTimer = 0; + } + else + shootingTimer = -30; + } + } + + time++; + shootingTimer++; + } + public void Shoot() + { + bool hitAnything = false; + bool oneFx = true; + float damageMult = 25; + foreach (NPC npc in Main.ActiveNPCs) + { + if (!npc.dontTakeDamage && Utils.Distance(npc.Center, palmBlastPos) <= (80 + Math.Max(npc.width / 2, npc.height / 2))) + { + hitAnything = true; + Vector2 pos = Vector2.Lerp(npc.Center, Projectile.Center, 0.35f); + Vector2 vel = Vector2.Lerp(Projectile.Center.DirectionTo(npc.Center), alteredRotation.ToRotationVector2(), 0.5f); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel, ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), 0, Projectile.owner, 0, npc.whoAmI); + if (oneFx) + { + for (int i = 0; i < 25; i++) + { + float size = Main.rand.NextFloat(0.4f, 1f); + Dust dust = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Circular(10, 10), ModContent.DustType(), -vel.SafeNormalize(Vector2.UnitX).RotatedBy(0.95f * (Main.rand.NextBool() ? 1 : -1)) * Main.rand.NextFloat(4f, 18f) * size, 0, default, Main.rand.NextFloat(1.1f, 1.9f) + (1 - size)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.fadeIn = 0.7f; + } + for (int i = 0; i < 25; i++) + { + Dust dust = Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(20, 20), Effects.ArsenalEffects.ArsenalLaserDust, vel.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(10f, 45f), 0, default, Main.rand.NextFloat(1f, 1.8f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + dust.fadeIn = 20; + if (i % 2 == 0) + { + Dust dust2 = Dust.NewDustPerfect(pos + Main.rand.NextVector2Circular(20, 20), Effects.ArsenalEffects.ArsenalLaserDust, vel.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(40f, 65f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); + dust2.noGravity = true; + dust2.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust2.alpha = 100; + dust2.fadeIn = 10; + } + } + for (int i = 0; i < 2; i++) + { + Particle pulse = new CustomSpark(pos, vel.SafeNormalize(Vector2.UnitX) * 2, "CalamityMod/Particles/BloomRing", false, 20, 1f, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(2f, 0.7f), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse1 = new CustomSpark(pos, vel.SafeNormalize(Vector2.UnitX) * 18, "CalamityMod/Particles/BloomRing", false, 18, 0.8f, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(2f, 0.7f), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(pulse1); + Particle pulse2 = new CustomSpark(pos, vel.SafeNormalize(Vector2.UnitX) * 34, "CalamityMod/Particles/BloomRing", false, 16, 0.6f, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(2f, 0.7f), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(pulse2); + } + Particle bloom = new CustomSpark(pos, vel.SafeNormalize(Vector2.UnitX) * 8, "CalamityMod/Particles/BloomCircle", false, 22, 0.7f, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(1f, 8f), true, true, shrinkSpeed: -0.5f, extraRotation: MathHelper.PiOver2); + GeneralParticleHandler.SpawnParticle(bloom); + oneFx = false; + } + damageMult -= 6; + if (damageMult < 1) + damageMult = 1; + } + } + if (hitAnything && Owner.CheckMana(HeldItem, palmManaCost, true, false)) + { + Owner.Calamity().arsenalCooldown = cooldownGiven; + Owner.AddCooldown(ArsenalPower.ID, cooldownGiven); + + SoundStyle aud = new("CalamityMod/Sounds/Item/MittHit"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(aud with { Volume = 0.8f, Pitch = 0, MaxInstances = 2 }, Projectile.Center); + Owner.SetScreenshake(8f); + } + else + { + Owner.Calamity().arsenalCooldown = (int)(cooldownGiven / 10); + Owner.AddCooldown(ArsenalPower.ID, (int)(cooldownGiven / 10)); + + for (int i = 0; i < 15; i++) + { + Dust dust = Dust.NewDustPerfect(palmBlastPos, ModContent.DustType(), Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(4f, 7f), 0, default, Main.rand.NextFloat(0.7f, 0.85f)); + dust.noGravity = false; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + } + for (int i = 0; i < 2; i++) + { + Particle bloom = new CustomSpark(palmBlastPos, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 15, 0.5f, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(1f, 1f), true, true); + GeneralParticleHandler.SpawnParticle(bloom); + } + SoundStyle aud = new("CalamityMod/Sounds/Item/MittFail"); + SoundEngine.PlaySound(aud with { Volume = 1f, Pitch = 0 }, Projectile.Center); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (hitTimer == 0) + { + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(target.Center, Effects.ArsenalEffects.ArsenalLaserDust, Owner.Center.DirectionTo(target.Center).RotatedByRandom(0.3f) * Main.rand.NextFloat(9f, 13f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + dust.fadeIn = 10; + } + hitTimer = Projectile.localNPCHitCooldown; + } + else + { + Dust dust = Dust.NewDustPerfect(target.Center, Effects.ArsenalEffects.ArsenalLaserDust, Owner.Center.DirectionTo(target.Center).RotatedByRandom(0.2f) * Main.rand.NextFloat(6f, 9f), 0, default, Main.rand.NextFloat(0.3f, 0.7f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + dust.fadeIn = 10; + modifiers.SourceDamage *= 0.2f; + } + } + public override bool PreDraw(ref Color lightColor) + { + Vector2 handPos = Owner.GetBackHandPosition(CompositeArmStretchAmount.None, Owner.compositeBackArm.rotation) + (Owner.compositeBackArm.rotation + MathHelper.PiOver2).ToRotationVector2() * 9 * Projectile.scale; + Projectile.Center = handPos; + + if (time < 2) + return false; + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/CountermeasureMittHoldout").Value; + + Texture2D finger = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/CountermeasureMittFinger2").Value; + Texture2D laser = ModContent.Request("CalamityMod/Particles/BloomLineFade").Value; + Texture2D laser2 = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D diamond = ModContent.Request("CalamityMod/Particles/SquareRotated").Value; + + Vector2 drawPosition = handPos - Main.screenPosition; + Vector2 vel = alteredRotation.ToRotationVector2(); + + float randSize = Main.rand.NextFloat(0.8f, 1.3f); + float fadeIn = (float)Math.Pow(Utils.GetLerpValue(0, palmAnimTime, shootingTimer), 2); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = alteredRotation + (Projectile.direction == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + float exRot = (Projectile.direction == -1 ? MathHelper.PiOver2 : 0); + SpriteEffects flipSprite = Projectile.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float thrustCuttoff = palmAnimTime * 0.8f; + float pullBack = MathHelper.Lerp(0.2f, 1f, (float)Math.Pow(Utils.GetLerpValue(thrustCuttoff, 0, shootingTimer, true), 4)); + float pushOut = MathHelper.Lerp(0.2f, 1.5f, (float)Math.Pow(Utils.GetLerpValue(thrustCuttoff, palmAnimTime, shootingTimer, true), 5)); + float thrustMult = (float)(forcePalm ? (shootingTimer <= thrustCuttoff ? pullBack : pushOut) : 1); + Vector2 thrustAddition = vel * 10 * thrustMult - vel * 10; + + Main.EntitySpriteDraw(texture, drawPosition + thrustAddition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + for (int i = 0; i < 5; i++) + { + float fingerLength = 3f * Projectile.scale; + Vector2 fingerScale = new Vector2(1f, 1f) * Projectile.scale; + Vector2 fingerOrgin = new Vector2(0, finger.Height / 2); + + float rot = i switch + { + 1 => f4r * Projectile.direction, + 2 => f3r * Projectile.direction, + 3 => f2r * Projectile.direction, + 4 => f1r * Projectile.direction, + _ => -f5r * 0.3f * Projectile.direction, + }; + float fx = i switch + { + 1 => f4x, 2 => f3x, 3 => f2x, 4 => f1x, _ => f5x, + }; + Color fingerColor = Color.Lerp(drawColor, Color.Black, (4 - i) * 0.2f); + if (i == 0) + { + fingerScale = new Vector2(0.9f, 1f) * Projectile.scale; + fingerLength = 1f * Projectile.scale; + fingerColor = drawColor; + } + + Vector2 basePosition = handPos + vel * (i == 0 ? 2.5f : 3.3f) * Projectile.scale + thrustAddition + (alteredRotation + rot).ToRotationVector2() * fingerLength + (alteredRotation + MathHelper.PiOver2 * -Projectile.direction).ToRotationVector2() * (i == 0 ? -3 : 3) * Projectile.scale; + Main.EntitySpriteDraw(finger, basePosition - Main.screenPosition, null, fingerColor, alteredRotation + rot, fingerOrgin, fingerScale, SpriteEffects.None); + + Vector2 velocity = (alteredRotation + rot).ToRotationVector2(); + Main.EntitySpriteDraw(laser, basePosition - Main.screenPosition + velocity * 545 * Projectile.scale, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * fx, velocity.ToRotation() + MathHelper.PiOver2, laser.Size() / 2, new Vector2(2.5f * randSize * fx, 55f) * Projectile.scale * 0.01f, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(laser2, basePosition - Main.screenPosition + velocity * 545 * Projectile.scale, null, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, 0.3f) with { A = 0 } * fx, velocity.ToRotation() + MathHelper.PiOver2, laser2.Size() / 2, new Vector2(0.4f * Math.Min(fx, 1), 55f) * Projectile.scale * 0.01f, SpriteEffects.FlipVertically); + + for (int y = 0; y < 2; y++) + Main.EntitySpriteDraw(bloom, basePosition - Main.screenPosition + velocity * 7 * Projectile.scale, null, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, y) with { A = 0 } * (fx - 1), velocity.ToRotation() + MathHelper.PiOver2, bloom.Size() / 2, new Vector2(2 + 0.05f * (fx + 25), 1) * Projectile.scale * MathHelper.Lerp(fx, 1, 0.7f) * (0.03f - 0.01f * y), SpriteEffects.FlipVertically); + } + if (forcePalm) + { + for (int y = 0; y < 8; y++) + Main.EntitySpriteDraw(bloom, palmBlastPos - Main.screenPosition + thrustAddition, null, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, y * 0.1f) with { A = 0 } * fadeIn * 0.25f, alteredRotation + Main.rand.NextFloat(-4, 4), bloom.Size() / 2, new Vector2(0.4f, 1.8f) * Projectile.scale * (0.3f - 0.02f * y) * randSize, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(diamond, palmBlastPos - Main.screenPosition + thrustAddition, null, Color.White with { A = 0 } * fadeIn, 0, diamond.Size() / 2, new Vector2(1.7f * Main.rand.NextFloat(1, 1.6f) * (float)Math.Pow(fadeIn, 3), 0.06f) * Projectile.scale * 0.3f, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(bloom, palmBlastPos - Main.screenPosition + thrustAddition, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * fadeIn * 0.35f, 0, bloom.Size() / 2, new Vector2(1.8f, 0.5f) * Projectile.scale * 0.4f * randSize, SpriteEffects.FlipVertically); + } + return false; + } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + behindNPCsAndTiles.Add(index); + } + } +} diff --git a/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.png b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.png new file mode 100644 index 0000000000..389b6646b7 Binary files /dev/null and b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.png differ diff --git a/Projectiles/DraedonsArsenal/CountermeasurePalmBlast.cs b/Projectiles/DraedonsArsenal/CountermeasurePalmBlast.cs new file mode 100644 index 0000000000..295d12422c --- /dev/null +++ b/Projectiles/DraedonsArsenal/CountermeasurePalmBlast.cs @@ -0,0 +1,87 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class CountermeasurePalmBlast : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float time => ref Projectile.ai[0]; + public float fade => (float)Math.Pow(Utils.GetLerpValue(0, 13, Projectile.timeLeft, true), 4); + public bool onSpawn = true; + private NPC targeted = null; + public int lifetime = 18; + public override void SetDefaults() + { + Projectile.width = 150; + Projectile.height = 150; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.timeLeft = lifetime; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalLaserColor.ToVector3() * 0.5f); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (Projectile.ai[1] != -5) + targeted = Main.npc[(int)Projectile.ai[1]]; + if (targeted == null || !targeted.active) + { + targeted = Projectile.Center.ClosestNPCAt(150); + Projectile.ai[1] = -5; + } + if (time == 0) + { + Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float launchPower = 25; + targeted.MoveNPC(launchVel, launchPower, true); + } + time++; + } + + public override bool? CanHitNPC(NPC target) => (target == targeted) ? null : false; + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + Player Owner = Main.player[Projectile.owner]; + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); + float minMult = 0.25f; + int hitsToMinMult = 7; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult + critDamage; + + Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float launchPower = 40; + target.MoveNPC(launchVel, launchPower, true); + } + public override bool PreDraw(ref Color lightColor) + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Texture2D beam = ModContent.Request("CalamityMod/Particles/BloomLineFade").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float completion = Utils.GetLerpValue(lifetime, 0, time); + for (int i = 0; i < 6; i++) + { + Color orbColor = Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, i * 0.04f) with { A = 0 } * 0.8f; + float scale = Projectile.scale * (0.05f + i * 0.01f) * 3; + + Main.EntitySpriteDraw(beam, Projectile.Center - Main.screenPosition, null, orbColor, Projectile.rotation, new Vector2(beam.Width / 2, beam.Height), new Vector2(0.3f * fade, 2) * scale, SpriteEffects.None); + Main.EntitySpriteDraw(bloom, Projectile.Center - Main.screenPosition, null, orbColor, Projectile.rotation + MathHelper.PiOver2, bloom.Size() * 0.5f, new Vector2(0.5f, 1 + 2 * completion) * scale * 3 * fade, SpriteEffects.None); + } + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs deleted file mode 100644 index 4bd40a578c..0000000000 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class FrequencyManipulatorEnergy : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public float Time - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public const int Lifetime = 240; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 12; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 8; - Projectile.height = 8; - Projectile.friendly = true; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.timeLeft = Lifetime; - Projectile.extraUpdates = 1; - } - - public override void AI() - { - Time++; - GenerateIdleDust(); - - NPC potentialTarget = Projectile.Center.ClosestNPCAt(920f); - if (potentialTarget != null) - { - float oldSpeed = Projectile.velocity.Length(); - float inertia = MathHelper.Lerp(15f, 4f, Utils.GetLerpValue(Lifetime, Lifetime - 60f, Projectile.timeLeft, true)); - Projectile.velocity = (Projectile.velocity * inertia + Projectile.SafeDirectionTo(potentialTarget.Center, -Vector2.UnitY) * oldSpeed) / (inertia + 1f); - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * oldSpeed; - } - } - - public void GenerateIdleDust() - { - if (!Main.dedServ) - { - // Generate a helical group of dust particles that pulsate with time. - for (int i = 0; i < 3; i++) - { - float angle = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - float pulse = (float)Math.Sin(Time / 110f + MathHelper.TwoPi / 3f * i); - Vector2 offset = angle.ToRotationVector2().RotatedBy(MathHelper.TwoPi / 3f * i) * pulse * 6f; - - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 234); - dust.velocity = Vector2.Zero; - dust.noGravity = true; - - dust = Dust.NewDustPerfect(Projectile.Center + offset, 234); - dust.velocity = Vector2.Zero; - dust.noGravity = true; - } - } - } - } -} diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs deleted file mode 100644 index fae768a21d..0000000000 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs +++ /dev/null @@ -1,120 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class FrequencyManipulatorProjectile : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/FrequencyManipulator"; - - public float Time - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public const int TotalSpins = 2; - public const float SpinTime = 30f; - public override void SetDefaults() - { - Projectile.width = 34; - Projectile.height = 34; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.timeLeft = 180; - Projectile.penetrate = 2; - Projectile.extraUpdates = 1; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.tileCollide = false; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 45; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, Color.Purple.ToVector3()); - - Time++; - Player player = Main.player[Projectile.owner]; - if (Time <= SpinTime) - { - Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.TwoPi * TotalSpins / SpinTime); - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; - Projectile.Center = player.itemLocation + Projectile.velocity; - ManipulatePlayerItemValues(player); - } - else if (Time == SpinTime + 1f) - { - Projectile.tileCollide = true; - RingDustEffect(player.itemLocation, 1f, 1f, 5f, 2f); - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX * player.direction) * player.ActiveItem().shootSpeed; - } - } - - public void ManipulatePlayerItemValues(Player player) - { - player.ChangeDir(Projectile.direction); - player.heldProj = Projectile.whoAmI; - player.itemRotation = Projectile.rotation; - player.itemTime = player.itemAnimation; - } - - public void RingDustEffect(Vector2 spawnPosition, float scale, float fadeIn, float ringSpeed, float secondaryRingSpeedMultiplier) - { - if (Main.dedServ) - return; - for (int i = 0; i < 36; i++) - { - float angle = MathHelper.TwoPi * i / 36f; - Dust dust = Dust.NewDustPerfect(spawnPosition, 234); - dust.scale = scale; - dust.fadeIn = scale; - dust.velocity = angle.ToRotationVector2() * ringSpeed; - - dust = Dust.NewDustPerfect(spawnPosition, 173); - dust.scale = scale; - dust.fadeIn = scale; - dust.velocity = angle.ToRotationVector2() * ringSpeed * secondaryRingSpeedMultiplier; - } - } - - public void OnHitEffects() - { - if (Main.myPlayer != Projectile.owner) - return; - // Explode if the projectile is a stealth strike projectile. - int totalEnergyParticlesToSpawn = 3; - if (Projectile.Calamity().stealthStrike) - { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - totalEnergyParticlesToSpawn = 4; - RingDustEffect(Projectile.Center, 1.6f, 1.4f, 7f, 2.6f); - Projectile.ExpandHitboxBy(160); - Projectile.damage /= 2; - Projectile.Damage(); - Projectile.damage *= 2; - Projectile.ExpandHitboxBy(34); - } - - for (int i = 0; i < totalEnergyParticlesToSpawn; i++) - { - float offsetAngle = MathHelper.Lerp(-0.35f, 0.35f, i / (float)totalEnergyParticlesToSpawn); - Vector2 velocity = -Projectile.oldVelocity.RotatedBy(offsetAngle) * 0.66f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + velocity * 1.8f, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 0.4f, Projectile.owner); - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - OnHitEffects(); - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - OnHitEffects(); - return true; - } - } -} diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs deleted file mode 100644 index afe5e4399e..0000000000 --- a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using CalamityMod.Items; -using CalamityMod.Items.Weapons.DraedonsArsenal; -using Microsoft.Xna.Framework; -using ReLogic.Utilities; -using Terraria; -using Terraria.Audio; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class GatlingLaserProj : ModProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - private SlotId gatlingLaserLoopID; - private bool fireLasers = false; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 4; - } - - public override void SetDefaults() - { - Projectile.width = 24; - Projectile.height = 58; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Magic; - } - - public override void AI() - { - Projectile.frameCounter++; - if (Projectile.frameCounter >= 13) - { - Projectile.frameCounter = 10; - Projectile.frame++; - if (Projectile.frame >= Main.projFrames[Type]) - Projectile.frame = 0; - } - - if (SoundEngine.TryGetActiveSound(gatlingLaserLoopID, out var ShootingSound) && ShootingSound.IsPlaying) - ShootingSound.Position = Projectile.Center; - Player player = Main.player[Projectile.owner]; - Vector2 playerRotation = player.RotatedRelativePoint(player.MountedCenter, true); - if (Projectile.type == ModContent.ProjectileType()) - { - if (Projectile.ai[0] < 5f) - Projectile.ai[0] += 1f; - - if (Projectile.ai[0] > 4f) - Projectile.ai[0] = 2f; - - // The Gatling Laser shoots every other frame (effective use time of 2). - int fireRate = 2; - Projectile.ai[1] += 1f; - bool shootThisFrame = false; - if (Projectile.ai[1] >= fireRate) - { - Projectile.ai[1] = 0f; - shootThisFrame = true; - } - - if (Projectile.soundDelay <= 0) - { - Projectile.soundDelay = fireRate * 6; - if (Projectile.ai[0] != 1f) - { - fireLasers = true; - Projectile.soundDelay *= 6; - gatlingLaserLoopID = SoundEngine.PlaySound(GatlingLaser.FireLoopSound, Projectile.Center); - } - } - if (shootThisFrame && Main.myPlayer == Projectile.owner && fireLasers) - { - Item gatling = player.ActiveItem(); - - // This grabs the weapon's current damage, taking current charge level into account. - int currentDamage = player.GetWeaponDamage(gatling); - - bool stillInUse = !player.CantUseHoldout(); - - // This both checks if the player has sufficient mana and consumes it if they do. - // If this is false, the Gatling Laser stops functioning. - bool hasMana = player.CheckMana(gatling, -1, true, false); - - // Checks if the Gatling Laser has sufficient charge to fire. If this is false, it stops functioning. - CalamityGlobalItem modItem = gatling.Calamity(); - bool hasCharge = modItem.Charge >= GatlingLaser.HoldoutChargeUse; - - if (stillInUse && hasMana && hasCharge) - { - float scaleFactor = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 laserDirection = playerRotation; - Vector2 aimDirection = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - laserDirection; - if (player.gravDir == -1f) - { - aimDirection.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - laserDirection.Y; - } - Vector2 projVelocity = Vector2.Normalize(aimDirection); - if (float.IsNaN(projVelocity.X) || float.IsNaN(projVelocity.Y)) - { - projVelocity = -Vector2.UnitY; - } - projVelocity *= scaleFactor; - if (projVelocity.X != Projectile.velocity.X || projVelocity.Y != Projectile.velocity.Y) - { - Projectile.netUpdate = true; - } - Projectile.velocity = projVelocity; - int type = ModContent.ProjectileType(); - float velocity = 3f; - laserDirection = Projectile.Center; - Vector2 spinningpoint = Vector2.Normalize(Projectile.velocity) * velocity; - - double spread = Math.PI / 32D; - spinningpoint = spinningpoint.RotatedBy(Main.rand.NextDouble() * 2D * spread - spread); - - if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y)) - { - spinningpoint = -Vector2.UnitY; - } - Vector2 projVelocitySpread = new Vector2(spinningpoint.X, spinningpoint.Y); - if (projVelocitySpread.Length() > 5f) - { - projVelocitySpread.Normalize(); - projVelocitySpread *= 5f; - } - float SpeedX = projVelocitySpread.X + Main.rand.Next(-1, 2) * 0.005f; - float SpeedY = projVelocitySpread.Y + Main.rand.Next(-1, 2) * 0.005f; - float ai0 = Projectile.ai[0] - 2f; // 0, 1, or 2 - - // Use charge when firing a laser. - modItem.Charge -= GatlingLaser.HoldoutChargeUse; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), laserDirection.X, laserDirection.Y, SpeedX, SpeedY, type, currentDamage, Projectile.knockBack, Projectile.owner, ai0, 0f); - } - else - { - ActiveSound result; - if (SoundEngine.TryGetActiveSound(gatlingLaserLoopID, out result)) - result.Stop(); - - SoundEngine.PlaySound(GatlingLaser.FireEndSound, Projectile.Center); - Projectile.Kill(); - } - } - } - Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - player.ChangeDir(Projectile.direction); - player.heldProj = Projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - player.itemRotation = (float)Math.Atan2(Projectile.velocity.Y * Projectile.direction, Projectile.velocity.X * Projectile.direction); - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.png b/Projectiles/DraedonsArsenal/GatlingLaserProj.png deleted file mode 100644 index c4b477bdc8..0000000000 Binary files a/Projectiles/DraedonsArsenal/GatlingLaserProj.png and /dev/null differ diff --git a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs b/Projectiles/DraedonsArsenal/GatlingLaserShot.cs deleted file mode 100644 index f1292b9b35..0000000000 --- a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using ReLogic.Utilities; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class GatlingLaserShot : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - private int dust = 182; - private Player Owner => Main.player[Projectile.owner]; - - private int Time = 0; - - public override void SetDefaults() - { - Projectile.width = 2; - Projectile.height = 2; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Magic; - Projectile.penetrate = 1; - Projectile.extraUpdates = 100; - Projectile.timeLeft = 600; - } - - public override void AI() - { - Time++; - Lighting.AddLight(Projectile.Center, 0.2f, 0f, 0f); - if (Projectile.timeLeft % 11 == 0 && Time > 15 && Time < 460) - { - SparkParticle spark = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 6, 1.7f, Color.Red); - GeneralParticleHandler.SpawnParticle(spark); - } - if (Projectile.timeLeft % 4 == 0 && Time > 15 && Time < 460) - { - SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 6, 0.4f, Color.White); - GeneralParticleHandler.SpawnParticle(spark2); - } - } - - public override void OnKill(int timeLeft) - { - int height = 20; - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = height; - Projectile.Center = Projectile.position; - Projectile.damage = 0; - - LaserBurst(2.4f, 4.2f); // 60 dusts - - int inc; - for (int i = 0; i < 100; i = inc + 1) - { - int gatlingDust = Dust.NewDust(Projectile.Center, 6, 6, dust, 0f, 0f, 100, default, 1f); - float dustVelX = Main.dust[gatlingDust].velocity.X; - float dustVelY = Main.dust[gatlingDust].velocity.Y; - - if (dustVelX == 0f && dustVelY == 0f) - dustVelX = 1f; - - float dustVelocity = (float)Math.Sqrt(dustVelX * dustVelX + dustVelY * dustVelY); - dustVelocity = 4f / dustVelocity; - dustVelX *= dustVelocity; - dustVelY *= dustVelocity; - - Dust dust2 = Main.dust[gatlingDust]; - dust2.velocity *= 0.5f; - dust2.velocity.X = dust2.velocity.X + dustVelX; - dust2.velocity.Y = dust2.velocity.Y + dustVelY; - dust2.scale = 0.66f; - dust2.noGravity = true; - - inc = i; - } - } - - private void LaserBurst(float speed1, float speed2) - { - float angleRandom = 0.05f; - - int inc; - for (int j = 0; j < 4; j = inc + 1) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - - int burstDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 200, default, 0.9f); - Main.dust[burstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - Main.dust[burstDust].noGravity = true; - - Dust dust2 = Main.dust[burstDust]; - dust2.velocity *= 3f; - dust2 = Main.dust[burstDust]; - - burstDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 100, default, 0.66f); - Main.dust[burstDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * Projectile.width / 2f; - - dust2 = Main.dust[burstDust]; - dust2.velocity *= 2f; - - Main.dust[burstDust].noGravity = true; - Main.dust[burstDust].fadeIn = 1f; - Main.dust[burstDust].color = Color.Crimson * 0.5f; - - dust2 = Main.dust[burstDust]; - - inc = j; - } - for (int k = 0; k < 2; k = inc + 1) - { - float dustSpeed = Main.rand.NextFloat(speed1, speed2); - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); - - int moreBurstDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dust, dustVel.X, dustVel.Y, 0, default, 1.2f); - Main.dust[moreBurstDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(Projectile.velocity.ToRotation()) * Projectile.width / 3f; - Main.dust[moreBurstDust].noGravity = true; - - Dust dust2 = Main.dust[moreBurstDust]; - dust2.velocity *= 0.5f; - dust2 = Main.dust[moreBurstDust]; - - inc = k; - } - } - } -} diff --git a/Projectiles/DraedonsArsenal/GaussEnergy.cs b/Projectiles/DraedonsArsenal/GaussEnergy.cs index 443a2a0cc7..8fe6a4b1af 100644 --- a/Projectiles/DraedonsArsenal/GaussEnergy.cs +++ b/Projectiles/DraedonsArsenal/GaussEnergy.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal @@ -21,7 +22,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { for (int i = 0; i < 2; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4f, 4f), 107); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4f, 4f), DustID.Terra); dust.scale = Main.rand.NextFloat(1.1f, 1.3f); dust.noGravity = true; } diff --git a/Projectiles/DraedonsArsenal/GaussFlux.cs b/Projectiles/DraedonsArsenal/GaussFlux.cs index 62f23c5416..aca0413667 100644 --- a/Projectiles/DraedonsArsenal/GaussFlux.cs +++ b/Projectiles/DraedonsArsenal/GaussFlux.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal @@ -47,7 +48,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { for (int i = 0; i < 60; i++) { - Dust dust = Dust.NewDustPerfect(Target.Center, 261); + Dust dust = Dust.NewDustPerfect(Target.Center, DustID.AncientLight); dust.color = Utils.SelectRandom(Main.rand, Color.Yellow, Color.YellowGreen); dust.velocity = Main.rand.NextVector2Circular(20f, 20f); dust.scale = 2f; @@ -65,7 +66,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 offset = Target.Size.RotatedBy(offsetAngle) * 0.5f; offset += (arcIndex * MathHelper.TwoPi / 6f + Time / 20f).ToRotationVector2() * 6f * arcIndex; - Dust dust = Dust.NewDustPerfect(Target.Center + offset, 261); + Dust dust = Dust.NewDustPerfect(Target.Center + offset, DustID.AncientLight); dust.color = Utils.SelectRandom(Main.rand, Color.Yellow, Color.YellowGreen); dust.velocity = Vector2.Zero; dust.scale = scale; diff --git a/Projectiles/DraedonsArsenal/GaussPistolShot.cs b/Projectiles/DraedonsArsenal/GaussPistolShot.cs deleted file mode 100644 index 8b69e78d76..0000000000 --- a/Projectiles/DraedonsArsenal/GaussPistolShot.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.IO; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class GaussPistolShot : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public float Time - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public Vector2 OldVelocity; - public const float MaxChargeRadius = 7f; - public const float MinEnergyParticleSpeed = 0.25f; - public const float MaxEnergyParticleSpeed = 4f; - public const float EnergyChargeRadiusRatio = 1.45f; - public const float ChargeTime = 30f; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 12; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Magic; - Projectile.penetrate = 1; - Projectile.timeLeft = 240; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.WriteVector2(OldVelocity); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - OldVelocity = reader.ReadVector2(); - } - - public override void AI() - { - Time++; - - if (Time < ChargeTime && OldVelocity == Vector2.Zero) - { - OldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Zero; - Projectile.netUpdate = true; - } - if (Time >= ChargeTime && OldVelocity != Vector2.Zero) - { - Projectile.velocity = OldVelocity; - OldVelocity = Vector2.Zero; - Projectile.netUpdate = true; - } - - float energyRadius = MathHelper.Lerp(MaxChargeRadius * 0.333f, MaxChargeRadius, Utils.GetLerpValue(0f, ChargeTime, Time, true)); - float energySphereSpeedMax = MathHelper.Lerp(MaxEnergyParticleSpeed, MinEnergyParticleSpeed, Utils.GetLerpValue(0f, ChargeTime, Time, true)); - - // Charge up dust. - if (Projectile.velocity.Length() == 0f && !Main.dedServ) - { - for (int i = 0; i < 2; i++) - { - Vector2 offset = Main.rand.NextVector2CircularEdge(energyRadius, energyRadius) * 3f; - - float dustHue = Main.rand.NextFloat(0.15f, 0.3f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 261); - dust.velocity = Projectile.DirectionFrom(dust.position) * energyRadius / 3f; - dust.color = Main.hslToRgb(dustHue, Main.rand.NextFloat(0.9f, 1f), Main.rand.NextFloat(0.5f, 0.66f)); - dust.noGravity = true; - } - } - - if (!Main.dedServ) - { - // To give a bubble effect. - float xOffsetFactor = MathHelper.Lerp(0.7f, 1.3f, (float)Math.Cos(Time / 15f) * 0.5f + 0.5f); - float yOffsetFactor = MathHelper.Lerp(0.7f, 1.3f, (float)Math.Sin(Time / 15f) * 0.5f + 0.5f); - - // Idle energy pulse dust. - for (int i = 0; i < 10; i++) - { - Vector2 offset = Main.rand.NextVector2Circular(energyRadius, energyRadius); - offset.X *= xOffsetFactor; - offset.Y *= yOffsetFactor; - - float dustHue = Main.rand.NextFloat(0.15f, 0.3f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 261); - dust.velocity = Main.rand.NextVector2Circular(energySphereSpeedMax, energySphereSpeedMax); - dust.velocity += Projectile.velocity; - dust.color = Main.hslToRgb(dustHue, Main.rand.NextFloat(0.9f, 1f), Main.rand.NextFloat(0.5f, 0.66f)); - dust.scale = 0.8f; - dust.noGravity = true; - } - - // Ring of dust. - for (int i = 0; i < 25; i++) - { - float angle = i / 25f * MathHelper.TwoPi; - - Vector2 offset = angle.ToRotationVector2().RotatedBy(Projectile.velocity.ToRotation()) * energyRadius * 1.5f; - offset.X *= -xOffsetFactor; - offset.Y *= yOffsetFactor; - - float dustHue = Main.rand.NextFloat(0.15f, 0.3f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 261); - dust.velocity = Vector2.Zero; - dust.color = Main.hslToRgb(dustHue, Main.rand.NextFloat(0.9f, 1f), Main.rand.NextFloat(0.5f, 0.66f)); - dust.scale = 0.5f; - dust.noGravity = true; - } - } - } - } -} diff --git a/Projectiles/DraedonsArsenal/GaussRifleBlast.cs b/Projectiles/DraedonsArsenal/GaussRifleBlast.cs deleted file mode 100644 index cc03f8632e..0000000000 --- a/Projectiles/DraedonsArsenal/GaussRifleBlast.cs +++ /dev/null @@ -1,106 +0,0 @@ -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class GaussRifleBlast : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetDefaults() - { - Projectile.width = Projectile.height = 20; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.timeLeft = 600; - Projectile.extraUpdates = 0; - Projectile.penetrate = -1; - Projectile.tileCollide = true; - Projectile.ignoreWater = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - public override void AI() - { - if (Projectile.timeLeft == 600) - { - for (int i = 0; i < 3; i++) - { - Particle Square = new GlowSquareParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(1f, 3f), false, 15, Main.rand.NextFloat(0.5f, 1.2f), Color.Goldenrod, false, Main.rand.NextFloat(-3, 3)); - GeneralParticleHandler.SpawnParticle(Square); - } - } - if (Projectile.extraUpdates < 30 && Projectile.timeLeft % 3 == 0) - Projectile.extraUpdates++; - Player Owner = Main.player[Projectile.owner]; - float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - if (Projectile.timeLeft % 2 == 0 && targetDist < 1400 && Projectile.timeLeft <= 585) - { - float cLerp = Utils.GetLerpValue(500, 600, Projectile.timeLeft); - Particle spark = new GlowSparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 7, 0.08f, Color.Lerp(Color.Gold, Color.Goldenrod, cLerp), new Vector2(0.3f, 1), true, true); - GeneralParticleHandler.SpawnParticle(spark); - } - if (Main.rand.NextBool(7)) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), 267); - dust.scale = Main.rand.NextFloat(0.5f, 1.1f); - dust.velocity = Projectile.velocity * Main.rand.NextFloat(-3, 3); - dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; - } - if (Projectile.timeLeft == 600) - { - Particle pulse = new GlowSparkParticle(Projectile.Center, Projectile.velocity * 3, false, 8, 0.042f, Color.Goldenrod, new Vector2(1.5f, 0.9f), true); - GeneralParticleHandler.SpawnParticle(pulse); - } - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity, false, 8, MathHelper.Clamp(0.06f - Projectile.numHits * 0.01f, 0f, 0.06f), Color.Goldenrod * 0.9f, new Vector2(1, 0.5f), true); - GeneralParticleHandler.SpawnParticle(spark); - - if (Projectile.numHits == 0) - { - Particle bolt2 = new CustomPulse(target.Center, Vector2.Zero, Color.Gold * 0.55f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 1.4f, 0, 23); - GeneralParticleHandler.SpawnParticle(bolt2); - Particle bolt3 = new CustomPulse(target.Center, Vector2.Zero, Color.Gold * 0.35f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 1.6f, 0, 18); - GeneralParticleHandler.SpawnParticle(bolt3); - - for (int i = 0; i < 8; i++) - { - Vector2 dustVel = Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(3f, 7f); - Dust dust = Dust.NewDustPerfect(target.Center + dustVel * 5, 267, -dustVel * 0.5f, 0, default, Main.rand.NextFloat(0.5f, 1f)); - dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; - } - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 3, 0, Projectile.owner); - } - for (int i = 0; i < MathHelper.Clamp(5 - Projectile.numHits, 1, 5); i++) - { - Particle Square = new GlowSquareParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(1f, 3f), false, 18, Main.rand.NextFloat(0.8f, 1.8f), Color.Goldenrod, false, Main.rand.NextFloat(-3, 3)); - GeneralParticleHandler.SpawnParticle(Square); - } - - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.84f); - if (Projectile.damage < 1) - Projectile.damage = 1; - } - - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 5; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), 66); - dust.scale = Main.rand.NextFloat(0.5f, 1.1f); - dust.velocity = Projectile.velocity.RotateRandom(0.3f) * Main.rand.NextFloat(1, 3); - dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.LightYellow : Color.Gold; - dust.noLight = true; - } - } - } -} diff --git a/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs b/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs deleted file mode 100644 index 86d085f658..0000000000 --- a/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs +++ /dev/null @@ -1,46 +0,0 @@ -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class GaussRifleExplosion : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 200; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.tileCollide = false; - Projectile.timeLeft = 12; - Projectile.penetrate = -1; - Projectile.ignoreWater = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - for (int i = 0; i < Main.maxNPCs; i++) - { - NPC target = Main.npc[i]; - if (target.CanBeMoved(true) && target.CanBeChasedBy(Projectile, false)) - { - if (target != null && !CalamityPlayer.areThereAnyDamnBosses) - { - if (Vector2.Distance(target.Center, Projectile.Center) > 5 && Vector2.Distance(target.Center, Projectile.Center) < 500) - { - target.velocity += target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.4f; - target.Center += target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.8f; - } - } - } - } - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f * Projectile.scale, targetHitbox); - } -} diff --git a/Projectiles/DraedonsArsenal/HolofiberImmolatorHoldout.cs b/Projectiles/DraedonsArsenal/HolofiberImmolatorHoldout.cs deleted file mode 100644 index 93e6c4f824..0000000000 --- a/Projectiles/DraedonsArsenal/HolofiberImmolatorHoldout.cs +++ /dev/null @@ -1,204 +0,0 @@ -using CalamityMod.Items; -using CalamityMod.Items.Weapons.DraedonsArsenal; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class HolofiberImmolatorHoldout : BaseGunHoldoutProjectile - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override int AssociatedItemID => ModContent.ItemType(); - public override float MaxOffsetLengthFromArm => 15f; - public override float OffsetXUpwards => -0f; - public override float BaseOffsetY => -0f; - public override float OffsetYDownwards => 0f; - - public static int FramesPerLoad = 13; - public static int MaxLoadableShots = 15; - public static float BulletSpeed = 12f; - public SlotId ChargeSlot; - public Color mainColor = Color.Lerp(Color.Chartreuse, Color.White, 0.35f); - public int time = 0; - - public ref float CurrentChargingFrames => ref Projectile.ai[0]; - public ref float ShotsLoaded => ref Projectile.ai[1]; - public int chargeMax = 0; - public int downtime = 0; - public bool ChargeLV1 => CurrentChargingFrames >= chargeMax; - - public override void KillHoldoutLogic() - { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) - Projectile.Kill(); - } - public override void OnSpawn(IEntitySource source) - { - OffsetLengthFromArm = 15; - Player Owner = Main.player[Projectile.owner]; - chargeMax = (int)(Owner.itemAnimationMax * 1.5f); - - SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorCharge"); - ChargeSlot = SoundEngine.PlaySound(sound with { Volume = 0.7f, IsLooped = true }, Projectile.Center); - } - - public override void HoldoutAI() - { - CalamityGlobalItem modItem = Owner.ActiveItem().Calamity(); - Vector2 mountedCenter = Owner.MountedCenter; - Vector2 ownerToMouse = Owner.Calamity().mouseWorld - mountedCenter; - if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) - ChargeSound.Position = Projectile.Center; - - // Fire if the owner stops channeling or otherwise cannot use the weapon. - if ((Owner.CantUseHoldout() || Owner.Calamity().mouseRight) && downtime == 0 && time >= 1) - { - KeepRefreshingLifetime = false; - - Projectile.timeLeft = Owner.Calamity().mouseRight ? Owner.itemAnimationMax * 2 : Owner.itemAnimationMax; - downtime = Owner.itemAnimationMax; - if (Owner.Calamity().mouseRight) - CurrentChargingFrames = 0; - - // Big Shot mode - if (ChargeLV1) - { - ChargeSound?.Stop(); - SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorFire"); - SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = 0.3f }, Projectile.Center); - - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - int charge2Damage = (int)(Projectile.damage * 2.5f); - float charge2KB = Projectile.knockBack * 3f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 2, ModContent.ProjectileType(), charge2Damage, charge2KB, Projectile.owner); - - for (int i = 0; i <= 25; i++) - { - Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, 267, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(0.5f, 1.3f)); - dust.noGravity = true; - dust.color = mainColor; - } - CurrentChargingFrames = 0; - if (modItem.Charge > 0) - modItem.Charge -= 0.06f; - else - Projectile.Kill(); - } - // Spread Fire mode - else - { - ChargeSound?.Stop(); - SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorFire"); - SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); - - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - for (int i = 0; i < 3; i++) - { - Vector2 fireVec = shootVelocity.RotatedBy((i == 0 ? 0.4f : i == 2 ? -0.4f : 0) * Utils.GetLerpValue(chargeMax * 1.1f, 0, CurrentChargingFrames, true)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec * MathHelper.Clamp((2 * (Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true))), 0.5f, 2), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } - for (int i = 0; i <= 4; i++) - { - Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, 267, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(0.4f, 1.1f)); - dust.noGravity = true; - dust.color = mainColor; - } - CurrentChargingFrames = 0; - if (modItem.Charge > 0) - modItem.Charge -= 0.025f; - else - Projectile.Kill(); - } - } - else if (downtime == 0) - { - CurrentChargingFrames++; - // Charge-up visuals - if (CurrentChargingFrames >= 10) - { - float particleScale = Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true); - float strength = particleScale; - Vector3 DustLight = mainColor.ToVector3(); - Lighting.AddLight(GunTipPosition, DustLight * strength); - } - - // Full charge dusts - if (CurrentChargingFrames == chargeMax) - { - ChargeSound?.Stop(); - for (int i = 0; i < 20; i++) - { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 278); - chargefull.velocity = (MathHelper.TwoPi * i / 20f).ToRotationVector2() * 4f + Owner.velocity * 0.5f; - chargefull.scale = Main.rand.NextFloat(0.6f, 0.8f); - chargefull.noGravity = false; - chargefull.color = mainColor; - } - SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorChargeLoop"); - ChargeSlot = SoundEngine.PlaySound(sound with { Volume = 0.7f, IsLooped = true }, Projectile.Center); - } - - if (CurrentChargingFrames > chargeMax && Main.rand.NextBool()) - { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 278); - chargefull.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(5, 9); - chargefull.scale = Main.rand.NextFloat(0.2f, 0.4f); - chargefull.noGravity = true; - chargefull.color = mainColor; - } - } - - if (downtime == 1 && !Owner.Calamity().mouseRight) - Projectile.Kill(); - - if (downtime > 0) - downtime--; - - time++; - } - public override void OnKill(int timeLeft) - { - if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound)) - ChargeSound?.Stop(); - } - public override bool PreDraw(ref Color lightColor) - { - if (time < 2) - return false; - - Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 10f; - - float fade = Utils.GetLerpValue(chargeMax / 3, chargeMax, CurrentChargingFrames, true); - - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/HolofiberImmolator").Value; - Texture2D glowTexture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/HolofiberImmolatorGlow").Value; - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Color drawColor = Projectile.GetAlpha(lightColor); - float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); - Vector2 rotationPoint = texture.Size() * 0.5f; - SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; - - Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); - Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); - - if (CurrentChargingFrames > 0 && downtime == 0) - { - float randSize = Main.rand.NextFloat(0.8f, 1.2f); - Main.EntitySpriteDraw(rechargeTexture, tipPosition - Main.screenPosition, null, mainColor with { A = 0 }, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.25f * Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); - Main.EntitySpriteDraw(rechargeTexture, tipPosition - Main.screenPosition, null, Color.White with { A = 0 }, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.15f * Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); - - Main.EntitySpriteDraw(pointTexture, tipPosition - Main.screenPosition + (Projectile.velocity * 15 * fade), null, mainColor with { A = 0 } * fade, Projectile.velocity.RotatedBy(MathHelper.ToRadians(90f)).ToRotation(), pointTexture.Size() * 0.5f, new Vector2(0.5f, 0.9f) * 0.035f * fade * randSize * (CurrentChargingFrames == chargeMax ? 1.5f : 1), flipSprite); - } - return false; - } - } -} diff --git a/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs b/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs new file mode 100644 index 0000000000..a8a735cb03 --- /dev/null +++ b/Projectiles/DraedonsArsenal/HolofibreImmolatorHoldout.cs @@ -0,0 +1,216 @@ +using CalamityMod.Dusts; +using CalamityMod.Items; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class HolofibreImmolatorHoldout : BaseGunHoldoutProjectile + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 15f; + public override float OffsetXUpwards => -0f; + public override float BaseOffsetY => -0f; + public override float OffsetYDownwards => 0f; + public override float WeaponTurnSpeed => 0.45f; + + public static float BulletSpeed = 12f; + public SlotId ChargeSlot; + public int time = 0; + + public ref float CurrentChargingFrames => ref Projectile.ai[0]; + public ref float ShotsLoaded => ref Projectile.ai[1]; + public int chargeMax = 0; + public int downtime = 0; + public static int spamDelayMax = 8; + public int spamDelay = spamDelayMax; + public bool ChargeLV1 => CurrentChargingFrames >= chargeMax; + + public override void KillHoldoutLogic() + { + if (HeldItem.type != Owner.HeldItem.type) + Projectile.Kill(); + } + public override void OnSpawn(IEntitySource source) + { + OffsetLengthFromArm = 15; + Player Owner = Main.player[Projectile.owner]; + chargeMax = (int)(Owner.itemAnimationMax * 1.5f); + } + + public override void HoldoutAI() + { + if (CurrentChargingFrames == 0) + { + SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorCharge"); + ChargeSlot = SoundEngine.PlaySound(sound with { Volume = 0.7f, IsLooped = true }, Projectile.Center); + } + CalamityGlobalItem modItem = Owner.HeldItem.Calamity(); + Vector2 mountedCenter = Owner.MountedCenter; + Vector2 ownerToMouse = Owner.Calamity().mouseWorld - mountedCenter; + if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) + ChargeSound.Position = Projectile.Center; + if (ChargeLV1 && spamDelay > 0) + spamDelay--; + // Fire if the owner stops channeling or otherwise cannot use the weapon. + bool autoSpam = (Owner.Calamity().mouseRight && !Main.mouseLeft); + bool chargeSpam = (Owner.Calamity().mouseRight && Main.mouseLeft && ChargeLV1 && spamDelay == 0); + if ((!Main.mouseLeft || autoSpam || chargeSpam) && downtime == 0 && time >= 1) + { + KeepRefreshingLifetime = false; + + Projectile.timeLeft = Owner.Calamity().mouseRight ? Owner.itemAnimationMax * 2 : Owner.itemAnimationMax; + downtime = Owner.itemAnimationMax; + if (Owner.Calamity().mouseRight && !Main.mouseLeft) + CurrentChargingFrames = 0; + spamDelay = spamDelayMax; + // Big Shot mode + if (ChargeLV1) + { + ChargeSound?.Stop(); + SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorFire"); + SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = 0.3f }, Projectile.Center); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; + if (Main.myPlayer == Projectile.owner) + { + int charge2Damage = (int)(Projectile.damage * 4.5f); + float charge2KB = Projectile.knockBack * 3f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 2, ModContent.ProjectileType(), charge2Damage, charge2KB, Projectile.owner); + } + + for (int i = 0; i <= 25; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, Effects.ArsenalEffects.ArsenalPlasmaDust, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(0.5f, 1.3f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + } + CurrentChargingFrames = 0; + } + // Spread Fire mode + else + { + ChargeSound?.Stop(); + SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorFire"); + SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; + if (Main.myPlayer == Projectile.owner) + { + for (int i = 0; i < 3; i++) + { + Vector2 fireVec = shootVelocity.RotatedBy((i == 0 ? 0.4f : i == 2 ? -0.4f : 0) * Utils.GetLerpValue(chargeMax * 1.1f, 0, CurrentChargingFrames, true)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec * MathHelper.Clamp((2 * (Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true))), 0.5f, 2), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + } + for (int i = 0; i <= 4; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, Effects.ArsenalEffects.ArsenalPlasmaDust, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(0.8f, 1.3f)); + dust.noGravity = false; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = 2; + } + CurrentChargingFrames = 0; + } + } + else if (downtime == 0) + { + CurrentChargingFrames++; + Projectile.timeLeft = Owner.itemAnimationMax; + + // Charge-up visuals + if (CurrentChargingFrames >= 10) + { + float particleScale = Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true); + float strength = particleScale; + Vector3 DustLight = Effects.ArsenalEffects.ArsenalPlasmaColor.ToVector3(); + Lighting.AddLight(GunTipPosition, DustLight * strength); + } + + // Full charge dusts + if (CurrentChargingFrames == chargeMax) + { + ChargeSound?.Stop(); + for (int i = 0; i < 20; i++) + { + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = (MathHelper.TwoPi * i / 20f).ToRotationVector2() * 4f + Owner.velocity * 0.5f; + chargefull.scale = Main.rand.NextFloat(0.6f, 0.8f); + chargefull.noGravity = false; + chargefull.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + } + SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorChargeLoop"); + ChargeSlot = SoundEngine.PlaySound(sound with { Volume = 0.7f, IsLooped = true }, Projectile.Center); + } + + if (CurrentChargingFrames > chargeMax && Main.rand.NextBool()) + { + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(5, 9); + chargefull.scale = Main.rand.NextFloat(0.7f, 0.85f); + chargefull.noGravity = true; + chargefull.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + chargefull.fadeIn = 0.5f; + } + } + + if ((downtime == 1 && !Owner.Calamity().mouseRight) || Owner.dead) + { + ChargeSound?.Stop(); + Projectile.Kill(); + } + + if (downtime > 0) + downtime--; + + time++; + } + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound)) + ChargeSound?.Stop(); + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + + Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 10f; + + float fade = Utils.GetLerpValue(chargeMax / 3, chargeMax, CurrentChargingFrames, true); + + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/HolofibreImmolator").Value; + Texture2D glowTexture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/HolofibreImmolatorGlow").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + if (CurrentChargingFrames > 0 && downtime == 0) + { + float randSize = Main.rand.NextFloat(0.8f, 1.2f); + Main.EntitySpriteDraw(rechargeTexture, tipPosition - Main.screenPosition, null, Effects.ArsenalEffects.ArsenalPlasmaColor with { A = 0 }, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.25f * Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); + Main.EntitySpriteDraw(rechargeTexture, tipPosition - Main.screenPosition, null, Color.White with { A = 0 }, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.15f * Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); + + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(pointTexture, tipPosition - Main.screenPosition + (Projectile.velocity * 15 * fade), null, Color.Lerp(Color.White, Effects.ArsenalEffects.ArsenalPlasmaColor, i * 0.5f) with { A = 0 } * fade * 0.7f, Projectile.velocity.RotatedBy(MathHelper.ToRadians(90f)).ToRotation(), pointTexture.Size() * 0.5f, new Vector2(0.7f - 0.2f * i, 0.7f + 0.3f * i) * 0.035f * fade * randSize * (CurrentChargingFrames == chargeMax ? 1.5f : 1) * (0.6f + 0.2f * i), flipSprite); + } + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs index 6ef1364726..36a3eebbcb 100644 --- a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs +++ b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Main.myPlayer == Owner.whoAmI) { // Get the projectile owner's held item. If it's not a modded item, stop now to prevent weird errors. - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; if (heldItem.type < ItemID.Count) { Projectile.Kill(); @@ -72,11 +72,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // Update the damage of the holdout projectile constantly so that it decreases as charge decreases, even while in use. Projectile.damage = Owner.GetWeaponDamage(heldItem); - // Check if the player's held item still has sufficient charge. If so, and they're still using it, take a tiny bit of charge from it. CalamityGlobalItem modItem = heldItem.Calamity(); - if ((Owner.channel || Owner.Calamity().mouseRight) && modItem.Charge >= HydraulicVoltCrasher.HoldoutChargeUse) + if ((Owner.channel || Owner.Calamity().mouseRight)) { - modItem.Charge -= HydraulicVoltCrasher.HoldoutChargeUse; float speed = Owner.inventory[Owner.selectedItem].shootSpeed * Projectile.scale; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction @@ -113,7 +111,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal spawnPosition.Normalize(); spawnPosition *= Projectile.Size; spawnPosition += Projectile.Center; - Dust dust = Dust.NewDustPerfect(spawnPosition, 226); + Dust dust = Dust.NewDustPerfect(spawnPosition, DustID.Electric); dust.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(2f, 3.6f); dust.velocity += Owner.velocity * 0.4f; } @@ -143,7 +141,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (float increment = 0f; increment <= 1f; increment += 0.05f) { Vector2 spawnPosition = Vector2.Lerp(target.Center, n.Center, increment); - Dust dust = Dust.NewDustPerfect(spawnPosition, 226); + Dust dust = Dust.NewDustPerfect(spawnPosition, DustID.Electric); dust.velocity = Vector2.Zero; dust.scale = 1.6f; dust.noGravity = true; diff --git a/Projectiles/DraedonsArsenal/ImmolationArrow.cs b/Projectiles/DraedonsArsenal/ImmolationArrow.cs index 1ce4b8c049..a08dcb5229 100644 --- a/Projectiles/DraedonsArsenal/ImmolationArrow.cs +++ b/Projectiles/DraedonsArsenal/ImmolationArrow.cs @@ -1,4 +1,6 @@ -using CalamityMod.Items.Weapons.DraedonsArsenal; +using System; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -15,7 +17,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public new string LocalizationCategory => "Projectiles.Misc"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public ref float time => ref Projectile.ai[0]; - public Color mainColor = Color.Lerp(Color.Chartreuse, Color.White, 0.35f); public NPC chosenTarget; public bool stuckInTarget = false; @@ -43,7 +44,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.timeLeft = 180; - Projectile.extraUpdates = 2; + Projectile.extraUpdates = 4; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; @@ -70,6 +71,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (stuckInGround) { + Projectile.extraUpdates = 2; Projectile.rotation = storedVelocity.ToRotation() + MathHelper.PiOver2; stuckTimer--; @@ -86,38 +88,31 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { if (Main.rand.NextBool(3) && canStick) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity); - dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.3f, 0.6f) : Main.rand.NextFloat(0.6f, 1.4f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPlasmaDust, -Projectile.velocity); + dust.scale = Main.rand.NextFloat(0.6f, 1.4f); dust.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.7f); dust.noGravity = true; - dust.color = mainColor; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; } if (targetDist < 1400f) { - Particle spark = new SparkParticle(Projectile.Center, -Projectile.velocity, false, 6, 1.3f, mainColor * 0.7f); + Particle spark = new SparkParticle(Projectile.Center, -Projectile.velocity, false, 13, 1.3f, Effects.ArsenalEffects.ArsenalPlasmaColor * 0.7f); GeneralParticleHandler.SpawnParticle(spark); if (Main.rand.NextBool(6)) { Vector2 placement = Projectile.Center + Main.rand.NextVector2Circular(12, 12); float speed = Main.rand.NextFloat(0.2f, 0.7f); - Particle spark2 = new GlowOrbParticle(placement, -Projectile.velocity * speed, false, 7, Main.rand.NextFloat(0.4f, 0.7f), mainColor); + Particle spark2 = new GlowOrbParticle(placement, -Projectile.velocity * speed, false, 7, Main.rand.NextFloat(0.4f, 0.7f), Effects.ArsenalEffects.ArsenalPlasmaColor); GeneralParticleHandler.SpawnParticle(spark2); } } - if (closestTarget != null && Projectile.numHits < 1 && closestTarget.CanBeChasedBy(Projectile)) - { - Vector2 moveTotarget = (closestTarget.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); - if (Projectile.velocity.Length() < 20) - Projectile.velocity = Projectile.velocity * 0.95f + moveTotarget * 0.28f; - else - Projectile.velocity *= 0.8f; - } } } else if (stuckInTarget) { + Projectile.extraUpdates = 2; Projectile.rotation = (storedVelocity).SafeNormalize(Vector2.UnitX).ToRotation() + MathHelper.PiOver2; placementCenter = chosenTarget.Center + placementVelocity * placementDistance; @@ -139,16 +134,16 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Main.rand.NextBool(8)) { float speed = Main.rand.NextFloat(0.2f, 1.5f); - Particle spark = new SparkParticle(Projectile.Center, -storedVelocity * speed, false, 23, 0.7f * speed, mainColor * 0.7f); + Particle spark = new SparkParticle(Projectile.Center, -storedVelocity * speed, false, 23, 0.7f * speed, Effects.ArsenalEffects.ArsenalPlasmaColor * 0.7f); GeneralParticleHandler.SpawnParticle(spark); } if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity); - dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.3f, 0.6f) : Main.rand.NextFloat(0.6f, 1.4f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), -Projectile.velocity); + dust.scale = Main.rand.NextFloat(0.6f, 1.4f); dust.velocity = (new Vector2(35, 35).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.7f)) * Utils.GetLerpValue(90, 0, stuckTimer); dust.noGravity = true; - dust.color = mainColor; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; } } time++; @@ -166,7 +161,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal collideWithTiles = false; SoundStyle sound2 = new("CalamityMod/Sounds/Item/ImmolatorPreExplode"); SoundEngine.PlaySound(sound2 with { Volume = 0.3f, Pitch = 0.5f }, Projectile.Center); - SoundEngine.PlaySound(HolofiberImmolator.PlasmaSound with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.3f, -0.4f) }, Projectile.Center); + SoundEngine.PlaySound(HolofibreImmolator.PlasmaSound with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.3f, -0.4f) }, Projectile.Center); } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) @@ -189,31 +184,44 @@ namespace CalamityMod.Projectiles.DraedonsArsenal stuckInTarget = true; storedVelocity = Projectile.velocity; Projectile.velocity = Vector2.Zero; - for (int i = 0; i <= 11; i++) + for (int i = 0; i < 12; i++) { - int dustStyle = Main.rand.NextBool() ? 66 : 263; + int dustStyle = Effects.ArsenalEffects.ArsenalPlasmaDust; Dust dust = Dust.NewDustPerfect(Projectile.Center + storedVelocity.SafeNormalize(Vector2.UnitX) * 38 + Main.rand.NextVector2Circular(12, 12), dustStyle, Projectile.velocity); - dust.scale = Main.rand.NextFloat(0.7f, 1.1f); - dust.velocity = storedVelocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.8f, 2.1f); - dust.noGravity = true; - dust.color = mainColor; + dust.scale = Main.rand.NextFloat(0.7f, 1.3f); + dust.velocity = storedVelocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.4f, 1.5f); + dust.noGravity = false; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = 1.5f; } SoundStyle sound = new("CalamityMod/Sounds/Item/ImmolatorPreExplode"); SoundEngine.PlaySound(sound with { Volume = 0.3f, Pitch = 0.5f }, Projectile.Center); - SoundEngine.PlaySound(HolofiberImmolator.PlasmaSound with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.3f, -0.4f) }, Projectile.Center); + SoundEngine.PlaySound(HolofibreImmolator.PlasmaSound with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.3f, -0.4f) }, Projectile.Center); } } public override void OnKill(int timeLeft) { - float bonus = (stuckInGround ? 2f : 1); + float bonus = (stuckInGround ? 3f : 1.5f); float explosionDamage = (stuckInGround ? 2.3f : 0.5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * explosionDamage), Projectile.knockBack * 2, Projectile.owner, 0, bonus != 1 ? 1 : 0); - Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor * 0.75f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 1.2f * bonus, 26); + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * explosionDamage), Projectile.knockBack * 2, Projectile.owner, 0, stuckInGround ? 1 : 0); + blast.scale = (stuckInGround ? 2 : 1); + Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalPlasmaColor * 0.75f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 1.2f * bonus, 26); GeneralParticleHandler.SpawnParticle(bolt2); - Particle bolt3 = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor * 0.75f, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.07f * bonus, 14); + Particle bolt3 = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalPlasmaColor * 0.75f, "CalamityMod/Particles/WaterFoam", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.77f * bonus, 16); GeneralParticleHandler.SpawnParticle(bolt3); + for (int i = 0; i < (int)(15 * bonus); i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, stuckInGround ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalPlasmaDust, -Projectile.velocity); + dust.scale = Main.rand.NextFloat(0.9f, 1.8f); + dust.velocity = (new Vector2(35, 35).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.7f)) * Utils.GetLerpValue(90, 0, stuckTimer); + dust.noGravity = false; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + if (dust.type == Effects.ArsenalEffects.ArsenalPlasmaDust) + dust.fadeIn = 2f; + } + SoundStyle sound = new("CalamityMod/Sounds/Item/PlasmaBig"); SoundEngine.PlaySound(sound with { Volume = 1f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); } @@ -224,21 +232,17 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return false; Asset tex = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/ImmolationArrow"); + Asset bloom = ModContent.Request("CalamityMod/Particles/BloomCircle"); - if (!stuckInGround && !stuckInTarget && false) - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], mainColor with { A = 0 }, 1, tex.Value); + float randSize = Main.rand.NextFloat(0.9f, 1f); + float fadeIn = (float)Math.Pow(Utils.GetLerpValue(90, 5, stuckTimer, true), 3); + for (int i = 0; i < 6; i++) + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition - (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * 6 * i, null, Color.Lerp(Color.White, Effects.ArsenalEffects.ArsenalPlasmaColor, i * 0.35f) with { A = 0 } * 0.5f, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.7f - 0.15f * i, 0.7f + 0.15f * i) * randSize * (0.6f + 0.25f * i) * 2, SpriteEffects.None); - float randSize = Main.rand.NextFloat(0.7f, 1.2f); for (int i = 0; i < 3; i++) - { - Vector2 scale = Projectile.scale * new Vector2(0.5f * (1 - i * 0.25f), 1) * 1.5f * (1 - i * 0.3f) * randSize; - Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, mainColor with { A = 0 } * 0.5f, Projectile.rotation, tex.Size() * 0.5f, scale, SpriteEffects.None); - } - if (stuckInTarget || stuckInGround) - { - Vector2 scale = 1.1f * new Vector2(0.5f, 1) * 1.5f * randSize; - Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * Utils.GetLerpValue(90, 30, stuckTimer, true), Projectile.rotation, tex.Size() * 0.5f, scale, SpriteEffects.None); - } + Main.EntitySpriteDraw(bloom.Value, Projectile.Center - Main.screenPosition + (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * 3, null, Color.Lerp(Color.White, Effects.ArsenalEffects.ArsenalPlasmaColor, 0.5f * i) with { A = 0 } * fadeIn * 0.3f, Projectile.rotation, bloom.Size() * 0.5f, new Vector2(1f - 0.2f * i, 1f + 0.35f * i) * randSize * (0.5f + 0.15f * i), SpriteEffects.None); + + Vector2 scale2 = 1.1f * new Vector2(0.5f, 1) * 1.5f * randSize; return false; } } diff --git a/Projectiles/DraedonsArsenal/ImmolationBurst.cs b/Projectiles/DraedonsArsenal/ImmolationBurst.cs index f73a3757d3..21557b8120 100644 --- a/Projectiles/DraedonsArsenal/ImmolationBurst.cs +++ b/Projectiles/DraedonsArsenal/ImmolationBurst.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() { - Projectile.width = Projectile.height = 150; + Projectile.width = Projectile.height = 235; Projectile.friendly = true; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; @@ -26,10 +26,10 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.88f); - if (Projectile.damage < 1) - Projectile.damage = 1; + float minMult = 0.25f; + int hitsToMinMult = (int)(5 * Projectile.scale); + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f * Projectile.scale, targetHitbox); } diff --git a/Projectiles/DraedonsArsenal/ImmolationSpray.cs b/Projectiles/DraedonsArsenal/ImmolationSpray.cs index 8cde23aa2c..56aa2e95fe 100644 --- a/Projectiles/DraedonsArsenal/ImmolationSpray.cs +++ b/Projectiles/DraedonsArsenal/ImmolationSpray.cs @@ -15,7 +15,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public new string LocalizationCategory => "Projectiles.Misc"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public ref float time => ref Projectile.ai[0]; - public Color mainColor = Color.Lerp(Color.Chartreuse, Color.White, 0.35f); public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; @@ -29,7 +28,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.DamageType = DamageClass.Ranged; Projectile.timeLeft = 300; Projectile.extraUpdates = 3; - Projectile.penetrate = -1; + Projectile.penetrate = 4; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } @@ -47,21 +46,21 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Vector2 placement = Projectile.Center + Main.rand.NextVector2Circular(8, 8); float speed = Main.rand.NextFloat(0.2f, 0.7f); - Particle spark = new GlowOrbParticle(placement, -Projectile.velocity * speed, false, 7, Main.rand.NextFloat(0.4f, 0.7f), mainColor); + Particle spark = new GlowOrbParticle(placement, -Projectile.velocity * speed, false, 7, Main.rand.NextFloat(0.4f, 0.7f), Effects.ArsenalEffects.ArsenalPlasmaColor); GeneralParticleHandler.SpawnParticle(spark); - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity); - dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.2f, 0.5f) : Main.rand.NextFloat(0.4f, 1.1f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPlasmaDust, -Projectile.velocity); + dust.scale = Main.rand.NextFloat(0.4f, 1.1f); dust.velocity = (new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.7f)); dust.noGravity = true; - dust.color = mainColor; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; } } time++; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - SoundEngine.PlaySound(HolofiberImmolator.PlasmaSound with { Volume = 0.5f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); + SoundEngine.PlaySound(HolofibreImmolator.PlasmaSound with { Volume = 0.5f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.8f); @@ -74,8 +73,16 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); if (targetDist < 1400) { - Particle spark = new GlowOrbParticle(Projectile.Center + oldVelocity.SafeNormalize(Vector2.UnitX) * 11, Projectile.velocity * 0.001f, false, 60, 1.6f, mainColor); - GeneralParticleHandler.SpawnParticle(spark); + Vector2 vel = oldVelocity.SafeNormalize(Vector2.UnitX); + int dustStyle = Effects.ArsenalEffects.ArsenalPlasmaDust; + for (int i = 0; i < 6; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 5, dustStyle, (-vel * Main.rand.NextFloat(5, 8)).RotatedByRandom(0.7f)); + dust.scale = Main.rand.NextFloat(0.7f, 1.3f); + dust.noGravity = false; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = 1.2f; + } } return true; } @@ -86,10 +93,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Asset tex = ModContent.Request("CalamityMod/Particles/GlowSpark"); - //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], mainColor with { A = 0 } * 0.3f, 1, tex.Value); float squash = Utils.GetLerpValue(-3, 10, Projectile.velocity.Length(), true); for (int i = 0; i < 2; i++) - Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, mainColor with { A = 0 } * 0.6f, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, squash) * 0.045f * (i == 0 ? 0.6f : 1), SpriteEffects.None); + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Effects.ArsenalEffects.ArsenalPlasmaColor with { A = 0 } * 0.6f, Projectile.rotation, tex.Size() * 0.5f, new Vector2(0.4f, squash) * 0.045f * (i == 0 ? 0.6f : 1), SpriteEffects.None); return false; } } diff --git a/Projectiles/DraedonsArsenal/MountedScannerLaser.cs b/Projectiles/DraedonsArsenal/MountedScannerLaser.cs index e51fce714d..f3bc047dc8 100644 --- a/Projectiles/DraedonsArsenal/MountedScannerLaser.cs +++ b/Projectiles/DraedonsArsenal/MountedScannerLaser.cs @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 laserSpawnPosition = Projectile.Center + Projectile.velocity * (LaserLength - 14f); for (int i = 0; i < 3; i++) { - Dust dust = Dust.NewDustPerfect(laserSpawnPosition + Main.rand.NextVector2Circular(8f, 8f), 261); + Dust dust = Dust.NewDustPerfect(laserSpawnPosition + Main.rand.NextVector2Circular(8f, 8f), DustID.AncientLight); dust.velocity = Main.rand.NextVector2CircularEdge(9f, 9f) * Main.rand.NextFloat(0.3f, 1f); dust.color = Color.Lerp(Color.Crimson, Color.Red, Main.rand.NextFloat()); dust.noGravity = true; diff --git a/Projectiles/DraedonsArsenal/MountedScannerSummon.cs b/Projectiles/DraedonsArsenal/MountedScannerSummon.cs index e925397619..3ccb38ab25 100644 --- a/Projectiles/DraedonsArsenal/MountedScannerSummon.cs +++ b/Projectiles/DraedonsArsenal/MountedScannerSummon.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; ProjectileID.Sets.NeedsUUID[Type] = true; @@ -114,6 +115,5 @@ namespace CalamityMod.Projectiles.DraedonsArsenal SoundEngine.PlaySound(CommonCalamitySounds.LaserCannonSound, Projectile.Center); } } - public override bool? CanDamage() => false; } } diff --git a/Projectiles/DraedonsArsenal/NidhoggBottom.png b/Projectiles/DraedonsArsenal/NidhoggBottom.png new file mode 100644 index 0000000000..c082408c47 Binary files /dev/null and b/Projectiles/DraedonsArsenal/NidhoggBottom.png differ diff --git a/Projectiles/DraedonsArsenal/NidhoggExplosion.cs b/Projectiles/DraedonsArsenal/NidhoggExplosion.cs new file mode 100644 index 0000000000..428ab220d0 --- /dev/null +++ b/Projectiles/DraedonsArsenal/NidhoggExplosion.cs @@ -0,0 +1,85 @@ +using System; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class NidhoggExplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public float sine = 0; + public float shrink = 1; + public int strongTimer = 0; + public bool strong => strongTimer < 10; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 250; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; + Projectile.timeLeft = 420; + Projectile.penetrate = -1; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15; + } + + public override void AI() + { + Vector2 dustVel = (Vector2.UnitX).RotatedByRandom(100) * Main.rand.NextFloat(3f, 8.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel.SafeNormalize(Vector2.UnitX) * 120, ModContent.DustType(), -dustVel, 0, default, Main.rand.NextFloat(0.5f, 1f)); + dust.noGravity = true; + dust.fadeIn = 0.05f; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + if (target != null && target.CanBeMoved(true)) + { + if (Vector2.Distance(target.Center, Projectile.Center) > 15 && Vector2.Distance(target.Center, Projectile.Center) < 500) + { + Vector2 moveDir = target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX); + target.velocity = Vector2.Lerp(target.velocity, moveDir * 8, 0.12f); + target.Center += moveDir * 1.5f; + } + } + } + Projectile.rotation += 0.07f; + if (shrink > 0) + shrink -= strong ? 0.03f : 0.03f; + else + shrink = 1; + + if (!strong) + time++; + strongTimer++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (!strong) + modifiers.SourceDamage *= 0.1f; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f * Projectile.scale, targetHitbox); + public override bool PreDraw(ref Color lightColor) + { + float shrinkFade = Math.Min(Utils.GetLerpValue(1, 0.7f, shrink, true), Utils.GetLerpValue(0f, 0.3f, shrink, true)); + float sine = Math.Abs(MathHelper.Lerp((float)Math.Sin(time * 0.5f / MathHelper.Pi), 0.4f, 0.8f)); + float sine2 = Math.Abs(MathHelper.Lerp((float)Math.Sin(time * 0.7f / MathHelper.Pi), 0.4f, 0.8f)); + float fade = (float)Math.Pow(Utils.GetLerpValue(0, 10, Projectile.timeLeft, true), 3); + float areaScale = (strong ? 1f : 1) * fade; + Texture2D tex2 = ModContent.Request("CalamityMod/Particles/GlowSquareParticleBig").Value; + Color drawColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * (strong ? 0.5f : 0.3f) * shrinkFade; + + Main.EntitySpriteDraw(tex2, Projectile.Center - Main.screenPosition, null, drawColor, MathHelper.PiOver4 - MathHelper.PiOver2 * sine * 3, tex2.Size() / 2f, (areaScale + sine * 0.5f) * shrink, SpriteEffects.None, 0); + Main.EntitySpriteDraw(tex2, Projectile.Center - Main.screenPosition, null, drawColor, MathHelper.PiOver2 * sine2 * 3, tex2.Size() / 2f, (areaScale - sine2 * 0.5f) * (float)Math.Pow(shrink, 2), SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/NidhoggHoldout.cs b/Projectiles/DraedonsArsenal/NidhoggHoldout.cs new file mode 100644 index 0000000000..0d7f3975c8 --- /dev/null +++ b/Projectiles/DraedonsArsenal/NidhoggHoldout.cs @@ -0,0 +1,267 @@ +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class NidhoggHoldout : BaseGunHoldoutProjectile + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override int AssociatedItemID => ModContent.ItemType(); + + public float offsetBase = 30; + public override float MaxOffsetLengthFromArm => offsetBase; + public override float RecoilResolveSpeed => (shootingTimer < 0) ? 0.02f : 0.1f; + public override float OffsetXUpwards => 0f; + public override float BaseOffsetY => 0f; + public override float OffsetYDownwards => 0f; + public override float WeaponTurnSpeed => charging ? 0.75f : 0.4f; + public SlotId SoundSlot; + public bool charging => Projectile.ai[2] == 5; + public ref float shootingTimer => ref Projectile.ai[0]; + public ref float chargeTimer => ref Projectile.ai[1]; + public int fireRate => Owner.HeldItem.useAnimation; + public int chargeRate => 222; // It's spesifically this to line up with the charge sound + public int time = 0; + public float lightSine = 0; + float charge = 0; // multiplier for vfx based on charge of the weapon + + public override void KillHoldoutLogic() + { + if (Owner.dead) + { + StopSounds(); + Projectile.Kill(); + } + } + public void StopSounds() + { + if (SoundEngine.TryGetActiveSound(SoundSlot, out var audio2) && audio2.IsPlaying) + { + audio2?.Stop(); + } + } + public override void HoldoutAI() + { + if (time == 0) + { + OffsetLengthFromArm = offsetBase; + if (!charging) + shootingTimer = fireRate; + } + + if (shootingTimer < 0) + { + if (charge > 0) + charge = 1 - (float)Math.Pow(Utils.GetLerpValue(-50, -20, shootingTimer, true), 8); + shootingTimer++; + if (charge == 0) // Make a sound when the jaws close + { + SoundStyle close = new("CalamityMod/Sounds/NPCHit/ExoHit2"); + SoundEngine.PlaySound(close with { Volume = 0.5f, Pitch = Main.rand.NextFloat(0.3f, 0.4f) }, Projectile.Center); + charge -= 0.001f; + } + if (shootingTimer == 0) + { + shootingTimer = fireRate; + } + + return; + } + + if (HeldItem.type != Owner.HeldItem.type) + { + StopSounds(); + Projectile.Kill(); + return; + } + if (!charging) + { + StopSounds(); + } + if (shootingTimer == 0) + { + if (!charging || Owner.Calamity().arsenalCooldown > 0) + { + if (Owner.Calamity().mouseRight) + { + Projectile.ai[2] = 5; + shootingTimer = 1; // This is just so you dont fire when you stop using it + return; + } + Shoot(false); + } + else // Charging mode + { + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalGaussColor.ToVector3() * 2f * MathHelper.Lerp(Math.Abs(lightSine), 0.5f, 0.3f)); + + if (chargeTimer == 0) + { + SoundStyle sound = new("CalamityMod/Sounds/Item/NidhoggCharge"); + SoundSlot = SoundEngine.PlaySound(sound with { Volume = 0.9f }, Projectile.Center); + } + if (chargeTimer == chargeRate) // Reached max charge + { + Shoot(true); + } + else + chargeTimer++; + } + } + else + { + if (!Owner.Calamity().mouseRight && !Main.mouseLeft && shootingTimer > 0) + { + StopSounds(); + Projectile.Kill(); + } + } + + if (shootingTimer > 0) + shootingTimer--; + + time++; + + if (SoundEngine.TryGetActiveSound(SoundSlot, out var ChargeSound) && ChargeSound.IsPlaying) + ChargeSound.Position = Projectile.Center; + if (shootingTimer >= 0) + charge = (float)(Math.Pow(chargeTimer / chargeRate, 3)); + } + public void Shoot(bool isBig) + { + if (isBig) + { + Owner.velocity += -Projectile.velocity * 12; + OffsetLengthFromArm -= 15; + StopSounds(); + Owner.Calamity().arsenalCooldown = 540; + Owner.AddCooldown(ArsenalPower.ID, 540); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); + if (Main.myPlayer == Projectile.owner) + { + int chargeDamage = Projectile.damage * 33; + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 6, ModContent.ProjectileType(), chargeDamage, 0, Projectile.owner); + } + + SoundStyle sound = new("CalamityMod/Sounds/Item/NidhoggBigShot"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(sound with { Volume = 0.9f, MaxInstances = 2, Pitch = i == 0 ? -0.4f : 0 }, Projectile.Center); + Owner.SetScreenshake(8f); + + for (int i = 0; i < 40; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, Main.rand.NextBool(3) ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalGaussDust, (shootVelocity * 25).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(1.2f, 1.9f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + } + for (float i = 0.6f; i <= 1; i += 0.4f) + { + Particle pulse3 = new CustomSpark(Projectile.Center, Projectile.velocity * (20 - 10 * i), "CalamityMod/Particles/GlowSquareFading", false, 19, 0.9f * i, Effects.ArsenalEffects.ArsenalGaussColor, new Vector2(1.2f, 0.7f), shrinkSpeed: -0.1f, extraRotation: MathHelper.Pi); + GeneralParticleHandler.SpawnParticle(pulse3); + } + + shootingTimer = (-50); + chargeTimer = 0; + Projectile.ai[2] = 0; + } + else + { + OffsetLengthFromArm -= 5; + SoundStyle sound = new("CalamityMod/Sounds/Item/NidhoggFire"); + SoundEngine.PlaySound(sound with { Volume = 0.6f, Pitch = Main.rand.NextFloat(0.5f, 0.65f) }, Projectile.Center); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6f; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shootVelocity, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + + for (int i = 0; i < 9; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, Main.rand.NextBool(3) ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalGaussDust, (shootVelocity * 4).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.7f, 1.1f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + } + + shootingTimer = fireRate; + } + } + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(SoundSlot, out var ChargeSound)) + ChargeSound?.Stop(); + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + + Texture2D topJaw = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/NidhoggTop").Value; + Texture2D bottomJaw = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/NidhoggBottom").Value; + Texture2D glowTexture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/NidhoggGlow").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 jawVec = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2 * Projectile.direction); + + float randSize = Main.rand.NextFloat(0.9f, 1f); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.direction == -1 ? MathHelper.Pi : 0f); + SpriteEffects flipSprite = Projectile.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Texture2D aimTex = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D ringTex = ModContent.Request("CalamityMod/Particles/GlowSquareFading").Value; + Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; + Texture2D centerTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + if (charging) + { + drawPosition += Projectile.velocity * Main.rand.NextFloat(-6 * charge, 6 * charge); + + for (int i = 1; i <= 5; i++) // Sightlines + { + float sine = (float)Math.Sin(((charge * 60f + time * 0.15f) + MathHelper.ToRadians(216) * i) / MathHelper.Pi); + float angle = MathHelper.ToRadians(36) * sine * Math.Max(1 - charge * 1.06f, 0); + Color lineColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * Math.Abs(sine) * Math.Min(chargeTimer / (chargeRate * 0.3f), 1) * 0.2f; + Main.EntitySpriteDraw(aimTex, Projectile.Center - Main.screenPosition + Projectile.velocity * 10, null, lineColor, Projectile.rotation + angle - MathHelper.PiOver2, new Vector2(aimTex.Size().X * 0.5f, 0), new Vector2(0.2f - Math.Abs(sine) * 0.12f, 8) * 0.07f, SpriteEffects.FlipVertically, 0); + } + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(centerTex, Projectile.Center - Main.screenPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10, null, Color.Lerp(Effects.ArsenalEffects.ArsenalGaussColor, Color.White, i * 0.3f) with { A = 0 }, drawRotation, centerTex.Size() * 0.5f, new Vector2(2.1f, 0.9f) * ((0.04f + 0.1f * (float)Math.Pow(charge, 3)) - 0.02f * i), flipSprite); + } + // Oh boy I love perfectly placing multiple textures together!!! + Vector2 topJawPlace = drawPosition - jawVec * (5 + 10 * (float)Math.Pow(charge, 3)); + Vector2 bottomJawPlace = drawPosition + jawVec * (4 + 10 * (float)Math.Pow(charge, 3)) + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6; + Vector2 glowPlace = topJawPlace + jawVec; + for (int i = 0; i < 14; i++) + { + Color auraColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * 0.25f * charge; + Vector2 drawOffset = (MathHelper.TwoPi * i / 14f).ToRotationVector2() * 3 * charge; + Main.EntitySpriteDraw(bottomJaw, bottomJawPlace + drawOffset, null, auraColor, drawRotation, bottomJaw.Size() * 0.5f, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(topJaw, topJawPlace + drawOffset, null, auraColor, drawRotation, topJaw.Size() * 0.5f, Projectile.scale, flipSprite); + } + + Main.EntitySpriteDraw(bottomJaw, bottomJawPlace, null, drawColor, drawRotation, bottomJaw.Size() * 0.5f, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(topJaw, topJawPlace, null, drawColor, drawRotation, topJaw.Size() * 0.5f, Projectile.scale, flipSprite); + + Main.EntitySpriteDraw(glowTexture, glowPlace, null, Color.White, drawRotation, glowTexture.Size() * 0.5f, Projectile.scale, flipSprite); + if (charging) + { + for (int i = 1; i <= 3; i++) // "Rings" + { + lightSine = (float)Math.Sin(((charge * 100f + time * 0.15f) + MathHelper.ToRadians(360) * i) / MathHelper.Pi); + float angle = MathHelper.ToRadians(36) * lightSine * (1 - charge); + Vector2 posOffset = Projectile.velocity * 20 * lightSine; + Color lineColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * Math.Min(chargeTimer / (chargeRate * 0.3f), 1) * 0.7f; + Main.EntitySpriteDraw(ringTex, Projectile.Center - Main.screenPosition + posOffset, null, lineColor, Projectile.rotation + MathHelper.PiOver2, ringTex.Size() * 0.5f, new Vector2(1 + 0.5f * (float)Math.Pow(charge, 3), 1) * (0.12f + i * 0.025f), SpriteEffects.FlipVertically, 0); + } + } + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/NidhoggRailgunBigShot.cs b/Projectiles/DraedonsArsenal/NidhoggRailgunBigShot.cs new file mode 100644 index 0000000000..a05b781b79 --- /dev/null +++ b/Projectiles/DraedonsArsenal/NidhoggRailgunBigShot.cs @@ -0,0 +1,115 @@ +using CalamityMod.Dusts; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class NidhoggRailgunBigShot : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 60; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 900; + Projectile.extraUpdates = 80; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + if (targetDist < 1400 && time > 7) + { + if (time % 2 == 0) + { + Particle trail = new CustomSpark(Projectile.Center, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 48, 0.375f, Effects.ArsenalEffects.ArsenalGaussColor, new Vector2(1f, 2f), true, true, glowCenterScale: 0.7f, shrinkSpeed: 0.05f); + GeneralParticleHandler.SpawnParticle(trail); + } + if (time % 3 == 0) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), ModContent.DustType()); + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.1f) * Main.rand.NextFloat(10f, 30f); + dust.scale = Main.rand.NextFloat(1.3f, 1.7f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + dust.noLightEmittence = time % 6 != 0; + dust.fadeIn = -0.6f; + } + + if (time % 12 == 0) + { + Particle trail2 = new VelChangingSpark(Projectile.Center, -Projectile.velocity * 0.1f, -Projectile.velocity * 0.1f, "CalamityMod/Particles/GlowSquareFading", 35, 0.33f, Effects.ArsenalEffects.ArsenalGaussColor, new Vector2(1f, 0.8f), shrinkSpeed: 0f, lerpRate: 0.1f); + GeneralParticleHandler.SpawnParticle(trail2); + } + } + + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (Vector2.Distance(Projectile.Center, projectile.Center) <= 20 && projectile.active && projectile.type == ModContent.ProjectileType()) + { + projectile.Kill(); + Projectile.velocity = Projectile.Center.DirectionTo(Owner.Center) * 6; + Projectile.hostile = true; + Projectile.friendly = false; + } + } + + time++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + impactDust(); + + bool onKill = (target.life <= 0 && target.realLife == -1); + if (onKill && Projectile.numHits > 0) + Projectile.numHits--; + + modifiers.SetCrit(); + Player Owner = Main.player[Projectile.owner]; + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); + float minMult = 0.25f; + int hitsToMinMult = 7; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult + critDamage; + + Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float launchPower = 20; + target.MoveNPC(launchVel, launchPower, true); + } + + public override void OnKill(int timeLeft) + { + impactDust(); + } + public void impactDust() + { + for (int i = 0; i < MathHelper.Clamp(12 - Projectile.numHits * 2, 1, 12); i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalGaussDust); + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.3f) * Main.rand.NextFloat(14f, 37f); + dust.scale = Main.rand.NextFloat(0.8f, 1.5f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + dust.noLightEmittence = true; + } + } + public override bool PreDraw(ref Color lightColor) + { + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/NidhoggRailgunBlast.cs b/Projectiles/DraedonsArsenal/NidhoggRailgunBlast.cs new file mode 100644 index 0000000000..ba71ef2c53 --- /dev/null +++ b/Projectiles/DraedonsArsenal/NidhoggRailgunBlast.cs @@ -0,0 +1,101 @@ +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class NidhoggRailgunBlast : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 600; + Projectile.extraUpdates = 80; + Projectile.penetrate = 1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + if (targetDist < 1400 && time > 7) + { + if (time % 3 == 0) + { + Particle trail = new CustomSpark(Projectile.Center, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 8, 0.15f, Effects.ArsenalEffects.ArsenalGaussColor, new Vector2(1f, 2.5f), true, true, glowCenterScale: 0.7f, shrinkSpeed: 0.4f); + GeneralParticleHandler.SpawnParticle(trail); + } + if (time % 3 == 0) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), Effects.ArsenalEffects.ArsenalGaussDust); + dust.velocity = Vector2.One.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(0.1f, 0.2f); + dust.scale = Main.rand.NextFloat(0.7f, 0.85f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + dust.noLightEmittence = time % 9 != 0; + dust.fadeIn = 0.3f; + } + } + + time++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity, false, 8, MathHelper.Clamp(0.06f - Projectile.numHits * 0.01f, 0f, 0.06f), Effects.ArsenalEffects.ArsenalGaussColor * 0.9f, new Vector2(1f, 0.5f), true, true, 0.9f); + GeneralParticleHandler.SpawnParticle(spark); + + if (Projectile.numHits == 0) + { + Particle bolt2 = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/GlowSquareParticleThick", false, 8, 1f, Effects.ArsenalEffects.ArsenalGaussColor * 0.6f, Vector2.One, true, true, glowOpacity: 0.5f, glowCenterScale: 1.15f, extraRotation: MathHelper.PiOver4); + GeneralParticleHandler.SpawnParticle(bolt2); + + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && p.owner == Projectile.owner) + { + if (p.timeLeft > 10) + p.timeLeft = 10; + } + } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0, Projectile.owner, 0f, 0f); + } + impactDust(); + + Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float launchPower = 6; + target.MoveNPC(launchVel, launchPower, true); + } + + public override void OnKill(int timeLeft) + { + impactDust(); + } + public void impactDust() + { + for (int i = 0; i < MathHelper.Clamp(5 - Projectile.numHits, 1, 5); i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.3f) * Main.rand.NextFloat(8f, 13f); + dust.scale = Main.rand.NextFloat(0.8f, 1.35f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + dust.noLightEmittence = true; + } + } + public override bool PreDraw(ref Color lightColor) + { + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/NidhoggTop.png b/Projectiles/DraedonsArsenal/NidhoggTop.png new file mode 100644 index 0000000000..cd159f151e Binary files /dev/null and b/Projectiles/DraedonsArsenal/NidhoggTop.png differ diff --git a/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs b/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs new file mode 100644 index 0000000000..1449a379e7 --- /dev/null +++ b/Projectiles/DraedonsArsenal/PhalanxSurgeHoldout.cs @@ -0,0 +1,372 @@ +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class PhalanxSurgeHoldout : BaseGunHoldoutProjectile + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override int AssociatedItemID => ModContent.ItemType(); + + public float offsetBase = 30; + public override float MaxOffsetLengthFromArm => doingChargeAttack ? 100f : offsetBase; + public override float RecoilResolveSpeed => doingChargeAttack ? 2f : (shootingTimer < 0) ? 0.2f : 0.1f; + public override float OffsetXUpwards => 0f; + public override float BaseOffsetY => 0f; + public override float OffsetYDownwards => 0f; + public override float WeaponTurnSpeed => (shootingTimer < 0 ? 0 : 0.35f); + public SlotId ChargeSlot; + public SlotId StartSlot; + public bool charging => Projectile.ai[2] == 5; + public ref float shootingTimer => ref Projectile.ai[0]; + public ref float chargeTimer => ref Projectile.ai[1]; + public int fireRate => Owner.HeldItem.useAnimation; + public int chargeRate => 65; + public bool fullyCharged = false; + public bool doingChargeAttack = false; + public bool startChargeLoop = true; + public int time = 0; + float charge = 0; // multiplier for vfx based on charge of the weapon + public bool didDash = false; + + public override void KillHoldoutLogic() + { + if (Owner.dead) + { + StopSounds(); + Projectile.Kill(); + } + } + public void StopSounds() + { + if (SoundEngine.TryGetActiveSound(StartSlot, out var audio) && audio.IsPlaying) + { + audio?.Stop(); + } + if (SoundEngine.TryGetActiveSound(ChargeSlot, out var audio2) && audio2.IsPlaying) + { + audio2?.Stop(); + } + } + public override void HoldoutAI() + { + if (time == 0) + { + OffsetLengthFromArm = offsetBase; + if (!charging) + shootingTimer = fireRate; + } + + if (shootingTimer < 0) + { + if (Projectile.localAI[0] > 0) + { + Owner.velocity = -Projectile.velocity * (didDash ? 25 : (5 + 10 * Projectile.localAI[0])); + didDash = false; + Projectile.localAI[0] = 0; + } + if (didDash) + { + Owner.velocity = Projectile.velocity * 25; + if (!Collision.SolidCollision(GunTipPosition, 10, 10)) + { + Owner.Center += Projectile.velocity * 40; + Projectile.Center += Projectile.velocity * 40; + } + float fxScale = Utils.GetLerpValue(10, 25, Owner.velocity.Length(), true); + for (int i = 0; i < 3; i++) + { + Particle spark2 = new CustomSpark(Owner.Center + Main.rand.NextVector2Circular(20, 20), -Owner.velocity * Main.rand.NextFloat(0.4f, 1.2f), "CalamityMod/Particles/BloomLineSoftEdge", false, 12, Main.rand.NextFloat(0.02f, 0.03f) * fxScale, Effects.ArsenalEffects.ArsenalLaserColor * 0.8f, new Vector2(1, 1), true, false, 0, false, false, 1f * fxScale); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + Owner.direction = Projectile.direction; + shootingTimer++; + if (shootingTimer == 0) + { + didDash = false; + shootingTimer = fireRate; + } + return; + } + + if (HeldItem.type != Owner.HeldItem.type) + { + StopSounds(); + Projectile.Kill(); + return; + } + if (!charging) + { + StopSounds(); + } + if (shootingTimer == 0) + { + if (!charging || Owner.Calamity().arsenalCooldown > 0) + { + if (Owner.Calamity().mouseRight) + { + Projectile.ai[2] = 5; + shootingTimer = 1; // This is just so you dont fire when you stop using it + return; + } + Shoot(false); + } + else // Charging mode + { + if (Owner.Calamity().mouseRight && !doingChargeAttack) // Charge up the skewer + { + for (int i = 0; i < 4; i++) + { + Vector2 place = GunTipPosition + Main.rand.NextVector2Circular(5, 5) + Projectile.velocity * 12; + int dir = Main.rand.NextBool() ? 1 : -1; + Particle chargeParticles = new CustomSpark(place, -Projectile.velocity.RotatedBy(0.42f * dir).RotatedByRandom(0.1f) * Main.rand.NextFloat(8, 30), "CalamityMod/Particles/BloomLineSoftEdge", false, 6, 0.015f * charge, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(1f, 0.7f), shrinkSpeed: 1.4f); + GeneralParticleHandler.SpawnParticle(chargeParticles); + + if (i % 2 == 0) + { + Dust dust = Dust.NewDustPerfect(place, Effects.ArsenalEffects.ArsenalLaserDust, -Projectile.velocity.RotatedBy(0.42f * dir).RotatedByRandom(0.1f) * Main.rand.NextFloat(4, 20), 0, default, Main.rand.NextFloat(0.4f, 0.9f) * charge); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + } + } + + bool soundPlaying = (SoundEngine.TryGetActiveSound(StartSlot, out var audio) && audio != null); + if (chargeTimer == chargeRate && (!SoundEngine.TryGetActiveSound(ChargeSlot, out var audio3) || !audio3.IsPlaying)) + { + SoundStyle sound = new("CalamityMod/Sounds/Item/PhalanxSurgeChargeLoop"); + ChargeSlot = SoundEngine.PlaySound(sound with { Volume = 0.7f, IsLooped = true }, Projectile.Center); + } + if ((!soundPlaying || !audio.IsPlaying) && startChargeLoop) + { + SoundStyle sound = new("CalamityMod/Sounds/Item/PhalanxSurgeCharge"); + StartSlot = SoundEngine.PlaySound(sound with { Volume = 0.9f }, Projectile.Center); + startChargeLoop = false; + } + if (chargeTimer == chargeRate) // Reached max charge + { + SoundStyle sound = new("CalamityMod/Sounds/Item/PhalanxSurgeChargeMax"); + StartSlot = SoundEngine.PlaySound(sound with { Volume = 0.8f }, Projectile.Center); + + fullyCharged = true; + chargeTimer = 0; + OffsetLengthFromArm -= 7f; + } + if (!fullyCharged) + chargeTimer++; + } + else + { + if (fullyCharged) + { + doingChargeAttack = true; + int chargeAnimMax = (int)(chargeRate * 0.2f); + float completion = (chargeTimer / chargeAnimMax); + + if (chargeTimer <= chargeAnimMax) // Do the pullback pre fire animation here + { + float inMin = 10; + float outMax = 60; + float inOutPoint = 0.5f; + if (completion >= inOutPoint) + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(inOutPoint, 1f, completion, true), 5); + OffsetLengthFromArm = MathHelper.Lerp(inMin, outMax, completionLerp); + } + else + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, inOutPoint, completion, true), 3); + OffsetLengthFromArm = MathHelper.Lerp(offsetBase, inMin, completionLerp); + } + } + if (chargeTimer == chargeAnimMax) + { + Shoot(true); + fullyCharged = false; + startChargeLoop = true; + doingChargeAttack = false; + chargeTimer = 0; + Projectile.ai[2] = 0; // Return to regular firing mode + } + chargeTimer++; + } + else // Failure to full charge + { + shootingTimer = (int)(-fireRate * 0.5f); + chargeTimer = 0; + startChargeLoop = true; + Projectile.ai[2] = 0; // Return to regular firing mode + } + } + } + } + else + { + if (!Owner.Calamity().mouseRight && !Main.mouseLeft && shootingTimer > 0) + { + StopSounds(); + Projectile.Kill(); + } + } + + if (shootingTimer > 0) + shootingTimer--; + + time++; + + if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) + ChargeSound.Position = Projectile.Center; + if (SoundEngine.TryGetActiveSound(StartSlot, out var StartSound) && StartSound.IsPlaying) + { + StartSound.Position = Projectile.Center; + } + charge = (float)(fullyCharged ? 1 : Math.Pow(chargeTimer / chargeRate, 4)); + } + public void Shoot(bool isSkewer) + { + if (isSkewer) + { + if (Main.mouseLeft) + { + SoundStyle sound2 = new("CalamityMod/Sounds/Item/LauncherHeavyShot"); + SoundEngine.PlaySound(sound2 with { Volume = 0.9f, Pitch = 0.4f }, Projectile.Center); + Particle pulse3 = new CustomSpark(Owner.Center, Projectile.velocity * 7, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 26, 0.09f, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(2f, 0.7f), shrinkSpeed: 0.1f); + GeneralParticleHandler.SpawnParticle(pulse3); + didDash = true; + } + + StopSounds(); + Owner.Calamity().arsenalCooldown = 300; + Owner.AddCooldown(ArsenalPower.ID, 300); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); + if (Main.myPlayer == Projectile.owner) + { + int chargeDamage = (int)(Projectile.damage * (35 + (didDash ? 10 : 0))); // Used to be 50x - 60x, skewed the damage way too much to the lance even with it being the special + float chargeKB = Projectile.knockBack * 3f; + Projectile skewer = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 2, ModContent.ProjectileType(), chargeDamage, chargeKB, Projectile.owner, 0, 0, (didDash ? 5 : 0)); + skewer.timeLeft = didDash ? 25 : 10; + } + SoundStyle sound = new("CalamityMod/Sounds/Item/PhalanxSurgeChargeShoot"); + SoundEngine.PlaySound(sound with { Volume = 0.9f }, Projectile.Center); + Owner.SetScreenshake(6f); + + float mult = didDash ? 2 : 1; + for (int i = 0; i < 20 * mult; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, Effects.ArsenalEffects.ArsenalLaserDust, (shootVelocity * 20).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.2f) * mult, 0, default, Main.rand.NextFloat(0.5f, 1.3f) * mult); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + } + + shootingTimer = didDash ? -25 : -10; + } + else + { + OffsetLengthFromArm -= 10; + SoundStyle sound = new("CalamityMod/Sounds/Item/PhalanxSurgeShoot"); + SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 6f; + if (Main.myPlayer == Projectile.owner) + { + float angle1 = MathHelper.ToRadians(2f); + int projType = ModContent.ProjectileType(); + for (int i = 0; i < 2; i++) + { + Vector2 corVel1 = shootVelocity.RotatedBy(angle1 * 1.25f) * 0.8f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - shootVelocity * 2, corVel1, projType, Projectile.damage, Projectile.knockBack, Projectile.owner, 1); + Vector2 corVel2 = shootVelocity.RotatedBy(angle1 * 0.75f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - shootVelocity * 10, corVel2, projType, Projectile.damage, Projectile.knockBack, Projectile.owner, 0.65f); + angle1 *= -1; + } + float angle2 = MathHelper.ToRadians(5f); + for (int i = 0; i < 2; i++) + { + Vector2 corVel3 = shootVelocity.RotatedBy(angle2) * 0.9f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - shootVelocity * 4, corVel3, projType, Projectile.damage, Projectile.knockBack, Projectile.owner, 0.8f); + angle2 *= -1; + } + } + + for (int i = 0; i < 9; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, Effects.ArsenalEffects.ArsenalLaserDust, (shootVelocity * 5).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.5f, 0.8f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + } + + shootingTimer = fireRate; + } + } + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound)) + ChargeSound?.Stop(); + if (SoundEngine.TryGetActiveSound(StartSlot, out var StartSound)) + StartSound?.Stop(); + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/PhalanxSurge").Value; + Texture2D glowTexture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/PhalanxSurgeGlow").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition + new Vector2(0, -3); + + + float randSize = Main.rand.NextFloat(0.9f, 1f); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.direction == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/ArchSmear").Value; + Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; + + if (charging) + { + float rumble = (fullyCharged ? 0 : charge); + drawPosition += Main.rand.NextVector2Circular(5 * rumble, 5 * rumble); + + for (int i = 0; i < 8; i++) + { + float thin = (1 - i * 0.15f); + float fat = (1 + i * 0.3f) * charge; + Main.EntitySpriteDraw(rechargeTexture, Projectile.Center - Main.screenPosition + Projectile.velocity * 10, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * 0.35f * charge, Projectile.rotation + MathHelper.PiOver2, rechargeTexture.Size() * 0.5f, new Vector2(thin, fat) * 0.3f * randSize, SpriteEffects.None, 0); + Main.EntitySpriteDraw(rechargeTexture, Projectile.Center - Main.screenPosition + Projectile.velocity * 10, null, Color.White with { A = 0 } * 0.25f * charge, Projectile.rotation + MathHelper.PiOver2, rechargeTexture.Size() * 0.5f, new Vector2(thin, fat) * 0.2f * randSize, SpriteEffects.None, 0); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + if (charging) + { + for (int i = 0; i < 4; i++) + { + Color auraColor = Color.White with { A = 0 } * 0.6f * charge; + Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTimeWrappedHourly * 48f).ToRotationVector2() * charge; + rotationalDrawOffset *= 3; + Main.EntitySpriteDraw(glowTexture, drawPosition + rotationalDrawOffset, null, auraColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + } + } + + + Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/PhalanxSurgeLance.cs b/Projectiles/DraedonsArsenal/PhalanxSurgeLance.cs new file mode 100644 index 0000000000..8fcacbe4d0 --- /dev/null +++ b/Projectiles/DraedonsArsenal/PhalanxSurgeLance.cs @@ -0,0 +1,170 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class PhalanxSurgeLance : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public Vector2 startVel = Vector2.Zero; + public int time = 0; + public bool didDash => Projectile.ai[2] == 5; + public override void SetDefaults() + { + Projectile.width = 35; + Projectile.height = 35; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.timeLeft = 10; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalLaserColor.ToVector3()); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + if (time == 0) + { + startVel = Projectile.velocity; + for (int i = 0; i <= 15; i++) + { + Dust chargefull = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(40, 40), Effects.ArsenalEffects.ArsenalLaserDust); + chargefull.velocity = (Projectile.velocity * 10).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.2f, 2f); + chargefull.scale = Main.rand.NextFloat(0.4f, 0.8f); + chargefull.noGravity = true; + chargefull.color = Effects.ArsenalEffects.ArsenalLaserColor; + } + for (int i = 0; i < 20; i++) + { + Vector2 place = Projectile.Center + startVel * 20 + Main.rand.NextVector2Circular(5, 5); + int dir = Main.rand.NextBool() ? 1 : -1; + Particle chargeParticles = new CustomSpark(place, -Projectile.velocity.RotatedBy(0.42f * dir).RotatedByRandom(0.1f) * Main.rand.NextFloat(12, 35), "CalamityMod/Particles/BloomLineSoftEdge", false, 7, 0.025f, Effects.ArsenalEffects.ArsenalLaserColor, new Vector2(1f, 0.7f), shrinkSpeed: 1.3f); + GeneralParticleHandler.SpawnParticle(chargeParticles); + + if (i % 2 == 0) + { + Dust dust = Dust.NewDustPerfect(place, Effects.ArsenalEffects.ArsenalLaserDust, -Projectile.velocity.RotatedBy(0.42f * dir).RotatedByRandom(0.1f) * Main.rand.NextFloat(4, 20), 0, default, Main.rand.NextFloat(0.7f, 1.2f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + } + } + } + Projectile.rotation = startVel.ToRotation() + MathHelper.PiOver2; + Projectile.velocity = Vector2.Zero; + Projectile.Center = Owner.Center + startVel * 30; + time++; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + bool onKill = (target.life <= 0 && target.realLife == -1); + Player Owner = Main.player[Projectile.owner]; + float distMult = Utils.GetLerpValue(400, 10, Utils.Distance(target.Center, Projectile.Center), true); + Vector2 launchVel = startVel; + target.MoveNPC(launchVel, 10 + 35 * distMult, true); + + if (Projectile.numHits == 0) + { + if (!onKill || !didDash) + { + for (int i = -5; i <= 5; i++) + { + if (i == 0) + i++; + Particle spark2 = new CustomSpark(target.Center, startVel * i * 2, "CalamityMod/Particles/BloomLineSoftEdge", false, 12, 0.085f - Math.Abs(i) * 0.012f, Effects.ArsenalEffects.ArsenalLaserColor * 1f, new Vector2((6 - Math.Abs(i)) * 0.4f, 1), true, true, 0, false, false, 1.2f, glowOpacity: 0.6f); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (Projectile.timeLeft > 10) + Projectile.timeLeft = 10; + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner) + { + projectile.localAI[0] = distMult; // Tell the holdout that you hit a target and how much recoil + } + } + } + else if (didDash) + { + int extention = 25; + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.owner == Projectile.owner && projectile.ai[0] > -extention) + { + projectile.ai[0] -= extention; + } + } + if (Projectile.timeLeft < extention) + Projectile.timeLeft = extention; + } + + SoundStyle sound = new("CalamityMod/Sounds/Item/MeldShoot"); + SoundEngine.PlaySound(sound with { Volume = 1f }, Projectile.Center); + } + for (int i = 0; i < MathHelper.Clamp(25 - Projectile.numHits * 3, 1, 10); i++) + { + Vector2 velocity = startVel.RotatedByRandom(0.2f) * Main.rand.NextFloat(8f, 20f); + + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalLaserDust, velocity, 0, default, Main.rand.NextFloat(0.9f, 1.8f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + dust.fadeIn = -3; + } + if (onKill) + Projectile.numHits--; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.4f; + int hitsToMinMult = 10; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + Player Owner = Main.player[Projectile.owner]; + if (startVel == Vector2.Zero) + return false; + // If the target is touching the beam's hitbox (which is a small rectangle vaguely overlapping the host crystal), that's good enough. + if (projHitbox.Intersects(targetHitbox)) + return true; + // Otherwise, perform an AABB line collision check to check the whole beam. + float _ = float.NaN; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center, Projectile.Center + startVel * 145, Projectile.width * Projectile.scale, ref _); + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 1) + return false; + Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/BloomLineFade").Value; + Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float fade = Utils.GetLerpValue(0, 5, Projectile.timeLeft, true); + Vector2 distVel = startVel * 10; + for (int i = 0; i < 6; i++) + Main.EntitySpriteDraw(pointTexture, Projectile.Center - Main.screenPosition + (distVel * (3 + i)), null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * fade, Projectile.rotation, pointTexture.Size() * 0.5f, new Vector2(0.5f * (1 - i * 0.08f) * fade, 0.8f * (1 + i * 0.07f)) * 0.11f, SpriteEffects.None); + for (int i = 0; i < 6; i++) + Main.EntitySpriteDraw(pointTexture, Projectile.Center - Main.screenPosition + (distVel * (3 + i)), null, Color.White with { A = 0 } * 0.8f * fade, Projectile.rotation, pointTexture.Size() * 0.5f, new Vector2(0.5f * (1 - i * 0.08f) * fade, 0.8f * (1 + i * 0.07f)) * 0.07f, SpriteEffects.None); + + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(bloomTexture, Projectile.Center - Main.screenPosition, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * fade, Projectile.rotation, bloomTexture.Size() * 0.5f, new Vector2(0.6f, 1) * 0.8f, SpriteEffects.None); + Main.EntitySpriteDraw(bloomTexture, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * fade, Projectile.rotation, bloomTexture.Size() * 0.5f, new Vector2(0.5f, 1) * 0.65f, SpriteEffects.None); + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/PhalanxSurgeLaser.cs b/Projectiles/DraedonsArsenal/PhalanxSurgeLaser.cs new file mode 100644 index 0000000000..a2537d86b8 --- /dev/null +++ b/Projectiles/DraedonsArsenal/PhalanxSurgeLaser.cs @@ -0,0 +1,77 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class PhalanxSurgeLaser : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public int time = 0; + public override void SetDefaults() + { + Projectile.width = 7; + Projectile.height = 7; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.extraUpdates = 7; + Projectile.timeLeft = 600; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalLaserColor.ToVector3() * 0.4f); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + if (time > 15 && targetDist < 1400) + { + if (Projectile.timeLeft % 3 == 0) + { + Particle spark = new LineParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 8, 1.7f * Projectile.ai[0], Effects.ArsenalEffects.ArsenalLaserColor); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Projectile.timeLeft % 2 == 0) + { + SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 3, 0.7f * Projectile.ai[0], Color.White); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + time++; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalLaserDust, (Projectile.velocity * 4).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.3f, 0.8f), 0, default, Main.rand.NextFloat(0.7f, 1.3f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalLaserColor; + dust.alpha = 100; + dust.fadeIn = -3; + } + } + public override bool PreDraw(ref Color lightColor) + { + + if (time < 1) + return false; + Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/GlowBlade").Value; + float fade = Utils.GetLerpValue(0, 15, Projectile.timeLeft, true); + + for (int i = 0; i < 4; i++) + { + Main.EntitySpriteDraw(pointTexture, Projectile.Center - Main.screenPosition, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * fade * 0.4f, Projectile.rotation, pointTexture.Size() * 0.5f, new Vector2(0.7f - i * 0.1f, 1 + i * 0.15f) * 0.018f * Projectile.ai[0], SpriteEffects.None); + Main.EntitySpriteDraw(pointTexture, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * fade * 0.2f, Projectile.rotation, pointTexture.Size() * 0.5f, new Vector2(0.7f - i * 0.1f, 1 + i * 0.15f) * 0.013f * Projectile.ai[0], SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs b/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs index 1299ef33d0..45f31fc87c 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerBeam.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Rectangle frame = bladeTexture.Frame(1, 5, 0, Projectile.frameCounter / 4 % 5); var drawData2 = new DrawData(bladeTexture, Projectile.Center - Main.screenPosition, frame, Color.White, Projectile.rotation, bladeTexture.Size() / new Vector2(1f, 5f) * 0.5f, Projectile.scale * 1.2f, SpriteEffects.None, 0); - CalamityShaders.LightDistortionShader.CurrentTechnique.Passes[0].Apply(); + CalamityShaders.LightDistortionShader.Value.CurrentTechnique.Passes[0].Apply(); drawData2.Draw(Main.spriteBatch); return false; diff --git a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs index 4594581636..beec781400 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs @@ -6,6 +6,7 @@ using CalamityMod.Graphics.Primitives; using CalamityMod.Items; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs; using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -18,31 +19,25 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal { + [PierceResistException] public class PhaseslayerProjectile : ModProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/Phaseslayer"; // The "average" or "expected" swing speed which the sword's damage balance is based off of. - // This is rotation EVERY FRAME. The "average" swing speed is 360 degrees in one second, aka pi/30 radians per frame. - public const float StandardSwingSpeed = MathHelper.Pi / 30f; + // This is rotation EVERY FRAME. The "average" swing speed is 180 degrees in one second, aka pi/60 radians per frame. + public const float StandardSwingSpeed = MathHelper.Pi / 60f; // How quickly the sword's damage updates to reflect its current speed. Higher values make it change damage more quickly. public const float DamageUpdateResponsiveness = 0.08f; public const int SwordBeamCooldown = 15; - public const float SwordBeamDamageMultiplier = 0.15f; + public const float SwordBeamDamageMultiplier = 0.2f; private const float MaximumMouseRange = 360f; private const float ProjCenterOffset = 36f; - public bool IsSmall - { - get - { - CalamityGlobalItem swordItem = Main.player[Projectile.owner].ActiveItem().Calamity(); - return swordItem.ChargeRatio < Phaseslayer.SizeChargeThreshold; - } - } + public bool IsSmall => false; //Phaseslayer no longer uses charge so no longer gets small. I don't care to redo the code to remove this entirely so it's just being set to false. // ai[0] wrapper. Stores a rolling lerped average of angular momentum which is used as the swing speed damage multiplier. public float AngularDamageFactor @@ -78,7 +73,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 13; + Projectile.localNPCHitCooldown = 10; } // Vanilla Terraria doesn't sync projectile rotation, but it does sync velocity. @@ -90,7 +85,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { Player player = Main.player[Projectile.owner]; - CalamityGlobalItem modItem = player.ActiveItem().Calamity(); + CalamityGlobalItem modItem = player.HeldItem.Calamity(); // Angles are wrapped to be 0 to 2pi instead of -pi to pi for convenience with absolute values. float rotationAdjusted = MathHelper.WrapAngle(Projectile.rotation) + MathHelper.Pi; @@ -114,12 +109,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal AdjustCurrentDamage(player, deltaAngle); ManipulateFrames(); HandleSwordBeams(player, modItem, deltaAngle); - - // Because sword beams (or just holding the sword while it's fizzling) can take energy even when the sword's at zero energy, - // this is here to ensure the sword item's charge never goes below zero. - if (modItem.Charge < 0f) - modItem.Charge = 0f; - HandleFadeout(); } @@ -128,8 +117,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (Main.myPlayer == player.whoAmI) { // In addition to typical channel cancellation criteria, the sword fizzles out if it runs out of charge. - Item playerItem = player.ActiveItem(); - bool hasCharge = modItem.Charge > 0f; + Item playerItem = player.HeldItem; + bool hasCharge = true; // Phaseslayer no longer uses charge so always true. if (!player.CantUseHoldout() && playerItem.type == ModContent.ItemType() && hasCharge) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, the effect is capped separately @@ -139,7 +128,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // This formula ensures that the sword has a sudden and extremely harsh responsiveness penalty when the mouse is close to the player. // Otherwise it controls perfectly fine. - float aimResponsiveness = 0.035f + 0.3f * (float)Math.Pow(distRatio, 1D/3); + float aimResponsiveness = 0.035f + 0.3f * MathF.Pow(distRatio, 1 / 3f); // Update the sword's angle with the responsiveness determined by mouse position. // Also flag for netcode sync if applicable (this is the only way the sword can rotate in multiplayer). @@ -193,17 +182,17 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // Update the rolling "blade angular momentum" average by gently lerping in the newest data point. AngularDamageFactor = MathHelper.Lerp(AngularDamageFactor, deltaAngle, DamageUpdateResponsiveness); - // 0x expected speed gives you 53.5% damage. - // 1x expected speed gives you 100.0% damage. - // 1.5x expected speed gives you 116.6% damage. - // 2x expected speed gives you 130.6% damage. - // 3x expected speed gives you 153.5% damage. - // 4x expected speed gives you 171.7% damage. - // 5x expected speed gives you 187.0% damage. - float speedDamageScalar = 0.166f + (float)Math.Log(AngularDamageFactor / StandardSwingSpeed + 1.5f, 3f); + // 0x expected speed gives you 100.0% damage. + // 1x expected speed gives you 126.2% damage. + // 1.5x expected speed gives you 136.9% damage. + // 2x expected speed gives you 146.5% damage. + // 3x expected speed gives you 163.1% damage. + // 4x expected speed gives you 177.1% damage. + // 5x expected speed gives you 189.3% damage. + float speedDamageScalar = MathF.Log(AngularDamageFactor / StandardSwingSpeed + 3f, 3f); // Get the underlying sword item's current damage. This takes into account the player's stats and the sword's current charge. - int damageWithChargeAndStats = player.GetWeaponDamage(player.ActiveItem()); + int damageWithChargeAndStats = player.GetWeaponDamage(player.HeldItem); float sizeDamageScalar = IsSmall ? Phaseslayer.SmallDamageMultiplier : 1f; Projectile.damage = (int)(damageWithChargeAndStats * speedDamageScalar * sizeDamageScalar); } @@ -249,9 +238,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Vector2 velocity = Projectile.rotation.ToRotationVector2() * 20f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * SwordBeamDamageMultiplier), 0f, player.whoAmI); - - // Actually consume energy to fire the sword beam. - modItem.Charge -= Phaseslayer.SwordBeamChargeUse; } // The sound delay doubles as the sword beam's cooldown. @@ -270,14 +256,14 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float averageRotation = Projectile.oldRot.Take(20).Average(angle => MathHelper.WrapAngle(angle) + MathHelper.Pi); float deltaAngle = Math.Abs(averageRotation - (MathHelper.WrapAngle(Projectile.rotation) + MathHelper.Pi)); float opacity = Projectile.Opacity; opacity *= Utils.GetLerpValue(StandardSwingSpeed * 0.7f, StandardSwingSpeed, AngularDamageFactor, true); - opacity *= (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D); - opacity *= (float)Math.Pow(Utils.GetLerpValue(0.9f, 1.1f, deltaAngle, true), 2D); + opacity *= MathF.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4f); + opacity *= MathF.Pow(Utils.GetLerpValue(0.9f, 1.1f, deltaAngle, true), 2f); float rotationAdjusted = MathHelper.WrapAngle(Projectile.rotation) + MathHelper.Pi; float oldRotationAdjusted = MathHelper.WrapAngle(Projectile.oldRot[1]) + MathHelper.Pi; @@ -289,7 +275,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return Color.Lerp(Color.Red, Color.PaleVioletRed * completionRatio, MathHelper.Clamp(completionRatio * 0.8f, 0f, 1f)) * opacity; } - internal float WidthFunction(float completionRatio) => (IsSmall ? 101f : 127f) * (1f - completionRatio) * 0.8f; + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (IsSmall ? 101f : 127f) * (1f - completionRatio) * 0.8f; public override bool PreDraw(ref Color lightColor) { @@ -322,7 +308,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float angularTurn = i * swingAngularDirection * -0.09f; drawPoints[i] = Projectile.position + perpendicularDirection.RotatedBy(angularTurn) * offsetFactor; } - PrimitiveRenderer.RenderTrail(drawPoints, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + bladeOffset, shader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]), 50); + PrimitiveRenderer.RenderTrail(drawPoints, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + bladeOffset, shader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]), 50); Main.EntitySpriteDraw(bladeTexture, Projectile.Center + bladeOffset - Main.screenPosition, frame, Color.White, Projectile.rotation + MathHelper.PiOver2, origin, Projectile.scale, SpriteEffects.None, 0); Main.EntitySpriteDraw(hiltTexture, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation + MathHelper.PiOver2, hiltTexture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); diff --git a/Projectiles/DraedonsArsenal/PoleWarperSummon.cs b/Projectiles/DraedonsArsenal/PoleWarperSummon.cs index 9501d9e619..ad6d661b18 100644 --- a/Projectiles/DraedonsArsenal/PoleWarperSummon.cs +++ b/Projectiles/DraedonsArsenal/PoleWarperSummon.cs @@ -12,7 +12,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { public new string LocalizationCategory => "Projectiles.Misc"; public float AngularOffset = 0f; - public const float MaximumRepulsionSpeed = 13f; + public const float MaximumRepulsionSpeed = 11f; + public const float ChargeTime = 45f; public float Time { get => Projectile.ai[0]; @@ -25,6 +26,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; ProjectileID.Sets.TrailingMode[Type] = 0; @@ -43,7 +45,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.minion = true; Projectile.tileCollide = false; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 12; + Projectile.localNPCHitCooldown = 20; Projectile.DamageType = DamageClass.Summon; } @@ -56,7 +58,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.localAI[0] = 1f; } GrantBuffs(player); - NPC potentialTarget = Projectile.Center.MinionHoming(1400f, player); + NPC potentialTarget = Projectile.Center.MinionHoming(2000f, player); // Teleport near the target if very far away from them. if (!Projectile.WithinRange(player.Center, 4200f)) @@ -72,7 +74,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal else { NPCMovement(potentialTarget); - if (Time % 60f < 35f) + if (Time % ChargeTime < 35f) { RepelMovement(); } @@ -86,7 +88,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angle = MathHelper.TwoPi / 45f * i; Vector2 velocity = angle.ToRotationVector2() * 4f; - Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity * 2.75f, 261, velocity); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity * 2.75f, DustID.AncientLight, velocity); dust.noGravity = true; } } @@ -130,22 +132,22 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } } } - if (Time % 60f < 20f) + if (Time % ChargeTime < 20f) { float offsetAngle = AngularOffset * 0.5f + (!North).ToInt() * MathHelper.Pi; Vector2 destination = npc.Center + Vector2.UnitY.RotatedBy(offsetAngle) * 180f; Projectile.velocity = (Projectile.velocity * 4f + Projectile.SafeDirectionTo(destination) * 10f) / 5f; - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 25f; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 30f; Projectile.rotation = Projectile.AngleTo(npc.Center) + MathHelper.PiOver2; } - else if (Time % 60f < 35f) + else if (Time % ChargeTime < 35f) { Projectile.velocity *= 0.96f; Projectile.rotation += 0.05f; } - else if (Time % 60f == 35f) + else if (Time % ChargeTime == 35f) { - Projectile.velocity = Projectile.SafeDirectionTo(npc.Center, -Vector2.UnitY) * 29f; + Projectile.velocity = Projectile.SafeDirectionTo(npc.Center, -Vector2.UnitY) * 20f; Projectile.rotation = Projectile.AngleTo(npc.Center) + MathHelper.PiOver2; } } @@ -155,8 +157,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // This does not incorporate attraction on purpose. Doing so causes the minions to very easily become distracted. foreach (Projectile p in Main.ActiveProjectiles) { - if (p.type == Projectile.type && - Projectile.Distance(p.Center) < 40f) + if (p.type == Projectile.type && Projectile.Distance(p.Center) < 40f) { PoleWarperSummon otherPole = (PoleWarperSummon)p.ModProjectile; if (otherPole.North != North) @@ -173,6 +174,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } } + public override bool MinionContactDamage() => true; + public override bool PreDraw(ref Color lightColor) { Texture2D tex = TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs index 5f91f4bfe4..f8b2db1ce6 100644 --- a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs +++ b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return; for (int i = 0; i < 4; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(52f, 52f), 261); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(52f, 52f), DustID.AncientLight); dust.velocity = Vector2.Zero; dust.noGravity = true; } @@ -125,6 +125,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (field.whoAmI.WithinBounds(Main.maxProjectiles)) { field.DamageType = DamageClass.MeleeNoSpeed; + field.usesIDStaticNPCImmunity = false; field.usesLocalNPCImmunity = true; field.localNPCHitCooldown = 3; field.timeLeft = 12; diff --git a/Projectiles/DraedonsArsenal/PulseGrenadeNoPin.png b/Projectiles/DraedonsArsenal/PulseGrenadeNoPin.png new file mode 100644 index 0000000000..f1ae57288f Binary files /dev/null and b/Projectiles/DraedonsArsenal/PulseGrenadeNoPin.png differ diff --git a/Projectiles/DraedonsArsenal/PulseGrenadeOrb.cs b/Projectiles/DraedonsArsenal/PulseGrenadeOrb.cs new file mode 100644 index 0000000000..2bebbdd2fb --- /dev/null +++ b/Projectiles/DraedonsArsenal/PulseGrenadeOrb.cs @@ -0,0 +1,146 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static Terraria.Player; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class PulseGrenadeOrb : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public ref float time => ref Projectile.ai[0]; + public bool onSpawn = true; + public Vector2 lastPos; + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 16; + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.penetrate = -1; + Projectile.extraUpdates = 5; + Projectile.timeLeft = 600; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.ArmorPenetration = 15; + } + public override bool ShouldUpdatePosition() => (time < 120); + public override void AI() + { + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseColor.ToVector3() * 0.5f); + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + if (onSpawn) + { + lastPos = Projectile.Center; + Projectile.scale = (Projectile.Calamity().stealthStrike ? 1 : 0.7f); + for (int i = 0; i <= 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseDust); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.5f) * Main.rand.NextFloat(5f, 7f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 1; + } + for (int i = 0; i <= 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.3f) * Main.rand.NextFloat(7f, 9f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 0.3f; + } + + onSpawn = false; + } + + if (time < 120) + Projectile.velocity = Projectile.velocity.RotatedBy(0.023f * Projectile.ai[1] * (time > 25 ? 1 : 0)) * 0.997f * (time > 25 ? 1 : 0.98f); + else + { + Vector2 goal = Vector2.Lerp(Owner.GetFrontHandPosition(CompositeArmStretchAmount.None, Owner.compositeFrontArm.rotation), Projectile.Center, 0.5f); + Projectile.Center = Vector2.Lerp(Projectile.Center, goal, (float)Math.Pow(Utils.GetLerpValue(120, 250, time, true), 5)); + + Vector2 direction = Utils.DirectionTo(Projectile.Center, Owner.Center); + float power = Utils.Distance(Projectile.Center, lastPos); + Projectile.velocity = direction * power; + + if (time == 250 || Utils.Distance(Projectile.Center, Owner.Center) < 10) + { + if (Projectile.ai[2] == 0 && Owner.HeldItem.type == ModContent.ItemType()) + { + Projectile reformGrenade = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), goal, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 0f, Owner.whoAmI, 0); + reformGrenade.ai[1] = 5; + reformGrenade.ai[0] = Owner.HeldItem.useTime * 0.7f; + reformGrenade.Opacity = 0; + + SoundStyle grab = new("CalamityMod/Sounds/Item/LightCatch"); + SoundEngine.PlaySound(grab with { Volume = 1f, Pitch = 0 }, Projectile.Center); + SoundStyle pulse = new("CalamityMod/Sounds/Item/PulseSound"); + SoundEngine.PlaySound(pulse with { Volume = 0.1f, Pitch = 0.4f }, Projectile.Center); + + Particle restock = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalPulseColor, "CalamityMod/Items/Weapons/DraedonsArsenal/PulseGrenade", Vector2.One, Main.rand.NextFloat(-0.2f, 0.2f), 1.5f, 0.9f, 45, true); + GeneralParticleHandler.SpawnParticle(restock); + Particle restock2 = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalPulseColor, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-0.2f, 0.2f), 0.55f, 0.05f, 30, true); + GeneralParticleHandler.SpawnParticle(restock2); + + Projectile.Kill(); + return; + } + else + { + Projectile.Kill(); + return; + } + } + } + + float squash = Utils.GetLerpValue(1, 3, Projectile.velocity.Length(), true); + if (targetDist < 1400f && squash > 0.2f && time > 5) // The trail + { + Particle trail = new CustomSpark(Projectile.Center, Projectile.velocity * 0.01f, "CalamityMod/Particles/DualTrail", false, 13, 0.075f * Projectile.scale, Effects.ArsenalEffects.ArsenalPulseColor * 0.6f * squash, new Vector2(1 - 0.15f * squash, 1.3f + Utils.GetLerpValue(11, 15, Projectile.velocity.Length(), true) * 1.5f), true, false, shrinkSpeed: 0.2f * squash); + GeneralParticleHandler.SpawnParticle(trail); + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + time++; + lastPos = Projectile.Center; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.23f; + int hitsToMinMult = 5; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= (Projectile.Calamity().stealthStrike ? 0.57f : 0.33f) * damageMult; + } + public override bool? CanHitNPC(NPC target) => null; + public override bool PreDraw(ref Color lightColor) + { + Asset orb = ModContent.Request("CalamityMod/Particles/BloomCircle"); + Vector2 squash = new Vector2(Utils.Remap(Projectile.velocity.Length(), 5, 10, 1, 0.6f), Utils.Remap(Projectile.velocity.Length(), 5, 10, 1, 2f)); + float timeleftFade = (float)Math.Pow(Utils.GetLerpValue(0, 40 * Projectile.extraUpdates, Projectile.timeLeft, true), 5); + + for (int i = 0; i < 6; i++) + { + Color orbColor = Color.Lerp(Effects.ArsenalEffects.ArsenalPulseColor, Color.White, i * 0.07f) with { A = 0 } * 0.5f; + Vector2 scale = Projectile.scale * timeleftFade * squash * (0.05f + i * 0.01f) * 3; + Main.EntitySpriteDraw(orb.Value, Projectile.Center - Main.screenPosition, null, orbColor, Projectile.rotation, orb.Size() * 0.5f, scale, SpriteEffects.None); + } + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/PulseGrenadePin.png b/Projectiles/DraedonsArsenal/PulseGrenadePin.png new file mode 100644 index 0000000000..9b251b5081 Binary files /dev/null and b/Projectiles/DraedonsArsenal/PulseGrenadePin.png differ diff --git a/Projectiles/DraedonsArsenal/PulseGrenadeProjectile.cs b/Projectiles/DraedonsArsenal/PulseGrenadeProjectile.cs new file mode 100644 index 0000000000..c5979fa23a --- /dev/null +++ b/Projectiles/DraedonsArsenal/PulseGrenadeProjectile.cs @@ -0,0 +1,352 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Particles; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static Terraria.Player; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class PulseGrenadeProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/PulseGrenade"; + + public ref float time => ref Projectile.ai[0]; + public bool catching => Projectile.ai[1] == 5; + public bool caught = false; + public Player Owner => Main.player[Projectile.owner]; + public int tileHits = 0; // Keeps track of how many times the projectile has hit a tile. + public bool flung = false; // If the projectile has entered the thrown state. + public float UseTimer => Owner.HeldItem.useTime; + public float fxScale = 0; // A scaling value for the effects + public NPC targeted; + + public bool hasStoppedHolding = false; // If the player has let go of m1, thereby throwing the projectile. + + public Color col = Effects.ArsenalEffects.ArsenalPulseColor; + public bool pullPin = true; + public bool onSpawn = true; + public int beepTimer = 0; + public int beepRate = 1; + + public NPC lastHitTarget; + public override void SetDefaults() + { + Projectile.width = 5; + Projectile.height = 5; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.extraUpdates = 0; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + + Projectile.timeLeft = 180; + Projectile.DamageType = RogueDamageClass.Instance; + } + public override bool ShouldUpdatePosition() => flung; + public override bool? CanDamage() => (flung ? null : false); + public override void AI() + { + if (Owner.HeldItem.type != ModContent.ItemType()) + { + Projectile.Kill(); + return; + } + if (onSpawn) + { + if (catching) + caught = true; + if (Owner.Calamity().StealthStrikeAvailable()) + { + Projectile.Calamity().stealthStrike = true; + time = 0; + } + Owner.Calamity().ConsumeStealthByAttacking(); + onSpawn = false; + } + + if (flung) + FlungState(); + else + HeldState(); + + if (catching) + time--; + else + time++; + + if (Projectile.Opacity < 1) + Projectile.Opacity += 0.03f; + + Lighting.AddLight(Projectile.Center, col.ToVector3() * 0.3f); + } + public void HeldState() + { + if (Projectile.Calamity().stealthStrike) + { + if (beepTimer < 40) + { + if (Projectile.Opacity < 1) + Projectile.Opacity += 0.2f; + beepTimer += beepRate; + } + else + { + SoundStyle pulse = new("CalamityMod/Sounds/Item/PulseSound"); + SoundEngine.PlaySound(pulse with { Volume = 0.3f, Pitch = 0.1f + beepRate * 0.04f }, Projectile.Center); + Projectile.Opacity = 0; + beepTimer = 0; + beepRate += 2; + } + + } + + Projectile.velocity = Owner.velocity; + float completion = time / (UseTimer * 0.7f * (Projectile.Calamity().stealthStrike ? 2 : 1)); // The completion of the throw animation. + if (completion >= 1 && !catching) // The moment of being thrown. + { + time = -1; + Projectile.Center = Owner.Center; + Projectile.extraUpdates = (Projectile.Calamity().stealthStrike ? 22 : 5); + Projectile.rotation += Main.rand.NextFloat(-4, 4); + Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * 9; + Projectile.velocity = velocity; + + if (Projectile.Calamity().stealthStrike) + { + SoundStyle hardThrow = new("CalamityMod/Sounds/Item/SwooshMid"); + SoundEngine.PlaySound(hardThrow with { Volume = 0.9f, Pitch = 0.5f }, Projectile.Center); + + Projectile.timeLeft = 240; + Particle pulse3 = new CustomSpark(Projectile.Center, Projectile.velocity * 1.5f, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 13, 0.08f, Effects.ArsenalEffects.ArsenalPulseColor, new Vector2(1.2f, 0.7f), shrinkSpeed: 0.1f); + GeneralParticleHandler.SpawnParticle(pulse3); + + for (int i = 0; i <= 12; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseDust); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f); + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.5f) * Main.rand.NextFloat(7f, 13f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 1; + } + for (int i = 0; i <= 7; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f); + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.3f) * Main.rand.NextFloat(9f, 18f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 0.3f; + } + } + + SoundStyle toss = new("CalamityMod/Sounds/Item/LightThrow"); + SoundEngine.PlaySound(toss with { Volume = 1f, Pitch = 0 }, Projectile.Center); + + Projectile.tileCollide = true; + flung = true; + } + else + { + fxScale = (float)Math.Pow(completion, 2); + + Owner.direction = Math.Sign(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).X); + float grenadeRot = 0; + float pinTime = 0.75f; + Vector2 aimDirection = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + float dir = (Owner.direction == -1 ? MathHelper.ToRadians(180) : 0); + // All the annoying to make rotation and placement code for the throw animation. + if (completion >= 0.7f) + { + if (pullPin && completion >= pinTime && !catching) + { + Vector2 vel = aimDirection * -6 - Vector2.UnitY * 3 + Owner.velocity; + Particle thePin = new CustomSpark(Projectile.Center, vel, "CalamityMod/Projectiles/DraedonsArsenal/PulseGrenadePin", true, 43, 1f, Color.White, Vector2.One, false, false, 0, false, true, noShrink: true, spin: 0.1f * Math.Sign(vel.X)); + GeneralParticleHandler.SpawnParticle(thePin); + SoundStyle pin = new("CalamityMod/Sounds/Item/LightMetal"); + SoundEngine.PlaySound(pin with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); + pullPin = false; + } + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), catching ? 2 : 7); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); + } + else + { + if (catching && !Main.mouseLeft) + { + Projectile.Kill(); + return; + } + Projectile.ai[1] = 0; + + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + } + grenadeRot += aimDirection.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(CompositeArmStretchAmount.None, Owner.compositeFrontArm.rotation) + new Vector2(0, -18 * Owner.direction).RotatedBy(grenadeRot); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * dir); + + Projectile.Center = grenadePos; + Projectile.rotation = (-aimDirection).ToRotation() + MathHelper.PiOver2 * Owner.direction + dir; + + float frontArmRot = aimDirection.ToRotation() - MathHelper.ToRadians(90); + float backArmRot = grenadeRot - (Owner.direction == 1 ? MathHelper.ToRadians(180) : MathHelper.ToRadians(0)); + if (completion >= 0.4f && completion <= pinTime && !catching) + { + float goalRot = MathHelper.Lerp(frontArmRot, backArmRot, (float)Math.Pow(Utils.GetLerpValue(caught ? 0.6f : 0.4f, pinTime, completion, true), (Projectile.Calamity().stealthStrike ? 2 : 1) * (caught ? 5 : 3))); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, goalRot); + } + else + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, (completion > pinTime && !catching) ? MathHelper.Lerp(Owner.compositeFrontArm.rotation, frontArmRot, 0.07f) : frontArmRot); + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, backArmRot); + } + } + public void FlungState() + { + if ((time / Projectile.extraUpdates) > Owner.HeldItem.useAnimation * 0.45f) + Projectile.localAI[1] = 5; // Make sure you can throw another grenade, if any genade has this value at zero you cant throw another one. + + + if (Projectile.Calamity().stealthStrike) + { + Particle fadeInfx = new CustomSpark(Projectile.Center, Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomCircle", false, 23, 0.4f, col * 0.6f, new Vector2(0.8f, 1f), true, true, shrinkSpeed: 0.3f, glowOpacity: 0.35f); + GeneralParticleHandler.SpawnParticle(fadeInfx); + } + else + { + if (targeted != null && time >= 30) + { + Projectile.timeLeft++; + float homeSpeed = Utils.GetLerpValue(30, 180, time, true); + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.8f * homeSpeed, 8, 1f - 0.15f * homeSpeed, 0.99f, true); + if (targeted.life <= 0) + targeted = null; + } + else + { + targeted = (Projectile.Center).ClosestNPCAt(500, false, true); + } + } + + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + + bool squash = Main.rand.NextBool(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, squash ? ModContent.DustType() : ModContent.DustType(), -Projectile.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(0.1f, 1f), 0, default, Main.rand.NextFloat(0.6f, 1.05f)); + dust.noGravity = true; + dust.color = col; + dust.noLightEmittence = true; + if (squash) + { + dust.fadeIn = 1f; + dust.scale *= 2; + } + else + dust.velocity = dust.velocity.RotatedByRandom(0.2f); + if (Projectile.Calamity().stealthStrike) + dust.velocity = dust.velocity.RotatedByRandom(0.7f) * 12.5f; + if (Projectile.timeLeft == 1) + Explode(); + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + SoundStyle sound = CommonCalamitySounds.VoidstoneMine with { Volume = 1 }; + SoundEngine.PlaySound(sound with { Volume = 0.3f, Pitch = -0.25f - 0.1f * tileHits, MaxInstances = 6 }, Projectile.Center); + + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + + tileHits++; + if (tileHits > 2) + Explode(); + return false; + } + public void Explode() + { + Owner.SetScreenshake(3.5f * (Projectile.Calamity().stealthStrike ? 2 : 1)); + + int spin = Main.rand.NextBool() ? -1 : 1; + for (int i = 0; i < 8; i++) + { + Vector2 vel = (MathHelper.TwoPi * i / 8f).ToRotationVector2(); + Dust c = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + c.velocity = vel * 15f * (i % 2 == 0 ? 0.6f : 1f); + c.scale = (i % 2 == 0 ? 2.2f : 1.9f); + c.noGravity = true; + c.color = col; + c.noLightEmittence = true; + c.fadeIn = 0.3f; + + + // Do NOT change the damage of these here, do it on the on hit + Projectile orb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (vel * 7f).RotatedBy(MathHelper.PiOver4 / 2), ModContent.ProjectileType(), Projectile.damage, 0f, Owner.whoAmI, 0, spin, i); + orb.Calamity().stealthStrike = Projectile.Calamity().stealthStrike; + if (Projectile.Calamity().stealthStrike) + { + Projectile orb2 = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (vel * 10f), ModContent.ProjectileType(), Projectile.damage, 0f, Owner.whoAmI, 0, -spin, i + 1); + orb2.Calamity().stealthStrike = Projectile.Calamity().stealthStrike; + } + } + + if (Projectile.Calamity().stealthStrike) + { + SoundStyle pulseHard = new("CalamityMod/Sounds/Item/PulseSoundHeavy"); + SoundEngine.PlaySound(pulseHard with { Volume = 0.8f, Pitch = -0.6f, MaxInstances = 2 }, Projectile.Center); + } + SoundStyle pulse = new("CalamityMod/Sounds/Item/PulseSoundHeavy"); + SoundEngine.PlaySound(pulse with { Volume = 0.9f, Pitch = 0, MaxInstances = 2 }, Projectile.Center); + + + Projectile.Kill(); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.2f; + int hitsToMinMult = 5; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + Explode(); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 15, targetHitbox); + public override bool PreDraw(ref Color lightColor) + { + float fade = 1; + float reformMult = Utils.GetLerpValue(1, 0, Projectile.Opacity) * 3.5f; + Texture2D tex = pullPin ? ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/PulseGrenade").Value : ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseGrenadeNoPin").Value; + for (int i = 0; i < 15; i++) + { + Color auraColor = col with { A = 0 } * 0.25f * fade * fxScale; + Vector2 drawOffset = (MathHelper.TwoPi * i / 15f).ToRotationVector2() * 2 * Math.Max(fxScale, reformMult); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + drawOffset, null, auraColor, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, (!flung ? Owner.direction : Projectile.direction) != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, lightColor * fade * Projectile.Opacity, Projectile.rotation, tex.Size() / 2f, Projectile.scale, (!flung ? Owner.direction : Projectile.direction) != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/PulseGrenadeGlow").Value, Projectile.Center - Main.screenPosition, null, Color.White * fade * Projectile.Opacity, Projectile.rotation, tex.Size() * 0.5f, 1f, (!flung ? Owner.direction : Projectile.direction) != 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + return false; + } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + behindNPCs.Add(index); + } + } +} diff --git a/Projectiles/DraedonsArsenal/PulsePistolShot.cs b/Projectiles/DraedonsArsenal/PulsePistolShot.cs index 8e9409845e..cb2d3a8c00 100644 --- a/Projectiles/DraedonsArsenal/PulsePistolShot.cs +++ b/Projectiles/DraedonsArsenal/PulsePistolShot.cs @@ -1,7 +1,9 @@ using System; -using System.Collections.Generic; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,13 +15,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { public new string LocalizationCategory => "Projectiles.Misc"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - private Color mainColor = Color.Orchid; - private bool doDamage = false; - private NPC closestTarget = null; - private NPC lastTarget = null; - private float distance; + public ref float time => ref Projectile.ai[0]; + public bool onSpawn = true; + private NPC targeted = null; + private NPC lastHitTarget = null; private int timesItCanHit = 1; + public bool startAttackEffects = true; + public int attackTime = 160; // The amount of time an orb spends slowing before it attacks public override void SetDefaults() { Projectile.width = 16; @@ -27,8 +29,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.extraUpdates = 1; - Projectile.timeLeft = 1240; + Projectile.extraUpdates = 5; + Projectile.timeLeft = 600; Projectile.tileCollide = false; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 20; @@ -36,186 +38,179 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - // If it's hit targeted enemies enough, kill it - if (timesItCanHit <= 0) - { - if (Projectile.ai[1] < 5) - { - Projectile uwa = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5).RotatedBy(0.3f) * 0.5f, Projectile.type, Projectile.damage / 4, Projectile.knockBack / 2, Projectile.owner, 0, 5); - Projectile uwaAgain = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5).RotatedBy(-0.3f) * 0.5f, Projectile.type, Projectile.damage / 4, Projectile.knockBack / 2, Projectile.owner, 0, 5); - uwa.penetrate = 1; - uwaAgain.penetrate = 1; - } - Projectile.Kill(); - return; - } - - Lighting.AddLight(Projectile.Center, 0.3f, 0f, 0.5f); + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseColor.ToVector3() * 0.5f); Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - Projectile.rotation = Projectile.velocity.ToRotation(); - float createDustVar = 10f; - - if (Projectile.localAI[0] == 0) + if (onSpawn) { - if (Projectile.ai[1] == 1) + if (Projectile.ai[1] == 0) SoundEngine.PlaySound(SoundID.DD2_DarkMageCastHeal with { Volume = 1.7f, Pitch = 0.3f }, Projectile.Center); - } - if (targetDist < 1400f) - { - GlowOrbParticle spark = new GlowOrbParticle(Projectile.Center, -Projectile.velocity * Main.rand.NextFloat(-0.01f, 0.01f), false, 5, 1.7f - Projectile.ai[1] * 0.18f, Main.rand.NextBool(3) ? Color.DarkViolet : mainColor); - GeneralParticleHandler.SpawnParticle(spark); - } - if (targetDist < 1400f && Main.rand.NextBool()) - { - GlowOrbParticle spark = new GlowOrbParticle(Projectile.Center + Projectile.velocity * Main.rand.NextFloat(-2f, 2f), -Projectile.velocity * Main.rand.NextFloat(-0.01f, 0.01f), false, 5, 1.7f - Projectile.ai[1] * 0.18f, Main.rand.NextBool(3) ? Color.DarkViolet : mainColor); - GeneralParticleHandler.SpawnParticle(spark); - } - - if (Projectile.localAI[0] > 90) - { - // Velocity must look like it has stoped, but can't actually be zero otherwise homing code doesn't work - if (Projectile.localAI[0] == 91) - Projectile.velocity *= 0.001f; - - // When they begin the homing after a hit of spawning, do a few visuals - if (Projectile.localAI[0] == 120) + for (int i = 0; i <= 8; i++) { - distance = 3000; - - 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); - GeneralParticleHandler.SpawnParticle(pulse); - - for (int k = 0; k < 6; k++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 66); - dust.scale = Main.rand.NextFloat(0.6f, 1.1f); - dust.velocity = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f); - dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; - } + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseDust); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.5f) * Main.rand.NextFloat(5f, 7f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 1; } - // Homing code - if (Projectile.localAI[0] > 120) + for (int i = 0; i <= 6; i++) { - // Do damage if it's near its target otherwise don't, this is to prevent excessive hits as orbs rail through worm bosses and such - if (closestTarget is not null) - doDamage = Vector2.Distance(Projectile.Center, closestTarget.Center) < 10; - else - doDamage = false; + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.3f) * Main.rand.NextFloat(7f, 9f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 0.3f; + } - // Tracking code, originally was going to try only tracking the closest target not including the last target you hit, but I couldn't make it work - // Eventually I settled on how it works now and it seems to home consistently so I'm happy enough there - float projectileSpeed = 9.5f; - if (closestTarget is not null && closestTarget.active) - { - float targetDirectionRotation = Projectile.SafeDirectionTo(closestTarget.Center).ToRotation(); - float turningRate = 10f + Projectile.localAI[0] * 0.00008f; - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(targetDirectionRotation, turningRate).ToRotationVector2() * projectileSpeed; - } - else - { - Projectile.velocity = Projectile.rotation.ToRotationVector2() * projectileSpeed; - Projectile.velocity *= 0.999f; - } - if (closestTarget is not null && Vector2.Distance(Projectile.Center, closestTarget.Center) < 10) - { - closestTarget = null; - distance = 3000; - } + onSpawn = false; + } - // Add extra updates as it hits more times, this smoothy increases the speed without destroying velocity based visual effects - Projectile.extraUpdates = 5 + (int)(Projectile.numHits * 0.3f); + if (time >= attackTime) // home in on enemy + { + // Find a target + if (targeted == null) + { + Projectile.velocity *= 0.9f; + + startAttackEffects = true; + NPC chosenTarget = null; + float distance = 2500; + for (int index = 0; index < Main.npc.Length; index++) // look for a target that isnt one it has already hit in the last two hits. { - // Actual homing movement + NPC searchedTarget = Main.npc[index]; + if (searchedTarget.CanBeChasedBy(null, false)) + { + if (Vector2.Distance(Projectile.Center, searchedTarget.Center) < distance && (lastHitTarget != null ? searchedTarget != lastHitTarget : true) && searchedTarget.active && searchedTarget.life > 0) + { + distance = Vector2.Distance(Projectile.Center, searchedTarget.Center); + chosenTarget = searchedTarget; + } + } + } + if (chosenTarget == null) // If no target was found, check again but accept last hit targets as viable. + { + if (lastHitTarget != null) + Projectile.localNPCImmunity[lastHitTarget.whoAmI] = 0; + for (int index = 0; index < Main.npc.Length; index++) { - if (Main.npc[index].CanBeChasedBy(null, false) || Main.npc[index] == lastTarget) + NPC searchedTarget = Main.npc[index]; + if (searchedTarget.CanBeChasedBy(null, false)) { - float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); - - if (Vector2.Distance(Projectile.Center, Main.npc[index].Center) < (distance + extraDistance)) + if (Vector2.Distance(Projectile.Center, searchedTarget.Center) < distance && searchedTarget.active && searchedTarget.life > 0) { - closestTarget = Main.npc[index]; - distance = Vector2.Distance(Projectile.Center, Main.npc[index].Center); + distance = Vector2.Distance(Projectile.Center, searchedTarget.Center); + chosenTarget = searchedTarget; } } } } + + targeted = chosenTarget; + } + else // Home in on selected target + { + // Add extra updates as it hits more times, this smoothy increases the speed without destroying velocity based visual effects + Projectile.extraUpdates = 5 + (int)(Projectile.numHits * 0.6f); + + if (Projectile.timeLeft < 110 * Projectile.extraUpdates) + Projectile.timeLeft = 110 * Projectile.extraUpdates; + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.5f, 15, 0.97f); + if (startAttackEffects) + { + Projectile.velocity = Utils.DirectionTo(Projectile.Center, targeted.Center) * 10; + SoundStyle pulse = new("CalamityMod/Sounds/Item/PulseSound"); + SoundEngine.PlaySound(pulse with { Volume = 0.25f, Pitch = Math.Max(0.6f, Main.rand.NextFloat(0.3f, 0.4f) + Projectile.numHits * 0.1f), MaxInstances = 5 }, Projectile.Center); + for (int k = 0; k < 6; k++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseDust); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = Utils.DirectionTo(Projectile.Center, targeted.Center).RotatedByRandom(0.5f) * Main.rand.NextFloat(5f, 9f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 1; + } + startAttackEffects = false; + } + if (targeted.life <= 0 || !targeted.active || !targeted.CanBeChasedBy()) + targeted = null; } } else { - // Minor dust trail for when they first spawn - if (Main.rand.NextBool(5)) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), 66); - dust.scale = Main.rand.NextFloat(0.8f, 1.4f); - dust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f); - dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; - } - Projectile.velocity *= 0.98f; + Projectile.velocity *= Projectile.numHits > 0 ? 0.955f : 0.97f; } - // Visuals for the shot as it exits the tip of the rifle - if (Projectile.localAI[0] == createDustVar) - PulseBurst(4f, 5f); + float squash = Utils.GetLerpValue(1, 3, Projectile.velocity.Length(), true); + if (targetDist < 1400f && squash > 0.2f && (Projectile.ai[1] == 0 || time > 5)) // The trail + { + Particle trail = new CustomSpark(Projectile.Center, Projectile.velocity * 0.01f, "CalamityMod/Particles/DualTrail", false, 13, 0.075f * Projectile.scale, Effects.ArsenalEffects.ArsenalPulseColor * 0.6f * squash, new Vector2(1 - 0.15f * squash, 1.5f), true, false, shrinkSpeed: 0.2f * squash); + GeneralParticleHandler.SpawnParticle(trail); + } - Projectile.localAI[0]++; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + time++; } - public override bool? CanHitNPC(NPC target) => doDamage ? null : false; + public override bool? CanHitNPC(NPC target) => (target == targeted) ? null : false; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - bool onKill = target.life <= 0; + bool onKill = (target.life <= 0 && target.realLife == -1); // Set some values to get ready for it to home again for its next hit - lastTarget = target; - distance = 3000; - Projectile.localAI[0] = 60; - Projectile.velocity *= MathHelper.Clamp(1.5f - Projectile.numHits * 0.5f, 1f, 1.5f); + lastHitTarget = target; + targeted = null; + time = 0; + timesItCanHit--; + Projectile.velocity *= 0.8f; - for (int i = 0; i <= 2; i++) + for (int i = 0; i <= 5; i++) { - SquishyLightParticle energy = new SquishyLightParticle(Projectile.Center, (Projectile.velocity * 2).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.1f, 0.4f), Main.rand.NextFloat(0.1f, 0.25f), Main.rand.NextBool(3) ? Color.DarkViolet : mainColor, Main.rand.Next(20, 30 + 1), 0.25f, 2f); - GeneralParticleHandler.SpawnParticle(energy); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.scale = Main.rand.NextFloat(1.7f, 2.4f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.3f) * Main.rand.NextFloat(4f, 9f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 0.3f; } - if (target == closestTarget) - timesItCanHit--; - if (onKill) + timesItCanHit += 1; + + // If it's hit targeted enemies enough, kill it + if (timesItCanHit <= 0) { - timesItCanHit += 2; - Projectile.timeLeft += 90; + if (Projectile.ai[1] == 0 && Main.myPlayer == Projectile.owner) + { + Projectile pulseOrb1 = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10).RotatedBy(0.3f) * 0.5f, Projectile.type, Projectile.damage / 4, Projectile.knockBack / 2, Projectile.owner, 0, 1); + Projectile pulseOrb2 = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10).RotatedBy(-0.3f) * 0.5f, Projectile.type, Projectile.damage / 4, Projectile.knockBack / 2, Projectile.owner, 0, -1); + pulseOrb1.penetrate = 1; + pulseOrb1.scale = 0.7f; + pulseOrb2.penetrate = 1; + pulseOrb2.scale = 0.7f; + } + Projectile.Kill(); } } - private void PulseBurst(float speed1, float speed2) + public override bool PreDraw(ref Color lightColor) { - for (int i = 0; i <= 8; i++) + Asset orb = ModContent.Request("CalamityMod/Particles/BloomCircle"); + Vector2 squash = new Vector2(Utils.Remap(Projectile.velocity.Length(), 5, 10, 1, 0.6f), Utils.Remap(Projectile.velocity.Length(), 5, 10, 1, 2f)); + float timeleftFade = (float)Math.Pow(Utils.GetLerpValue(0, 40 * Projectile.extraUpdates, Projectile.timeLeft, true), 5); + + for (int i = 0; i < 6; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 66); - dust.scale = Main.rand.NextFloat(0.4f, 1.4f); - dust.velocity = (Projectile.velocity * 4).RotateRandom(0.6f) * Main.rand.NextFloat(0.2f, 0.9f); - dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; - } - for (int i = 0; i <= 8; i++) - { - SquishyLightParticle energy = new SquishyLightParticle(Projectile.Center, (Projectile.velocity * 4).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.1f, 0.4f), Main.rand.NextFloat(0.2f, 0.6f), Main.rand.NextBool(3) ? Color.DarkViolet : mainColor, Main.rand.Next(30, 40 + 1), 0.25f, 2f); - GeneralParticleHandler.SpawnParticle(energy); + Color orbColor = Color.Lerp(Effects.ArsenalEffects.ArsenalPulseColor, Color.White, i * 0.07f) with { A = 0 } * 0.5f; + Vector2 scale = Projectile.scale * timeleftFade * squash * (0.05f + i * 0.01f) * 3; + Main.EntitySpriteDraw(orb.Value, Projectile.Center - Main.screenPosition, null, orbColor, Projectile.rotation, orb.Size() * 0.5f, scale, SpriteEffects.None); } + + return false; } } } diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index bf23501b3b..c6653e218c 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -1,7 +1,9 @@ -using CalamityMod.Particles; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Typeless; +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -15,13 +17,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public new string LocalizationCategory => "Projectiles.Misc"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - private Color mainColor = Color.Orchid; - private bool notSplit; - private bool doDamage = false; - private NPC closestTarget = null; - private NPC lastTarget = null; - private float distance; + public ref float time => ref Projectile.ai[0]; + public bool isBeam => Projectile.ai[1] == 0; + public bool onSpawn = true; + private NPC targeted = null; + private NPC lastHitTarget = null; private int timesItCanHit = 3; + public bool startAttackEffects = true; + public bool dead = false; + public int attackTime => (int)(180 + Projectile.ai[1]); // The amount of time an orb spends slowing before it attacks public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; public override void SetDefaults() @@ -31,6 +35,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; + Projectile.extraUpdates = 7; Projectile.timeLeft = 900; Projectile.tileCollide = false; Projectile.usesLocalNPCImmunity = true; @@ -39,252 +44,228 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { - // If it's hit targeted enemies enough, kill it - if (timesItCanHit <= 0) - Projectile.Kill(); - - notSplit = Projectile.ai[1] == 0f; - - Lighting.AddLight(Projectile.Center, 0.3f, 0f, 0.5f); Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - Projectile.rotation = Projectile.velocity.ToRotation(); - float createDustVar = 10f; + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseColor.ToVector3() * 0.5f); - // Set split projectile stats - if (Projectile.localAI[0] == 0 && !notSplit) + if (onSpawn) { - Projectile.extraUpdates = 1; - Projectile.timeLeft = 1240; - if (Projectile.ai[1] == 1) - SoundEngine.PlaySound(SoundID.DD2_DarkMageCastHeal with { Volume = 1.7f, Pitch = 0.3f }, Projectile.Center); - } - if (notSplit) - { - doDamage = true; - Projectile.extraUpdates = 100; - } - - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > createDustVar && notSplit) - { - // Main projectile visual - float sizeBonus = MathHelper.Clamp(Projectile.localAI[0] * 0.009f, 0, 3.5f); - if (targetDist < 1400f) + float fxPower = isBeam ? 2 : 0.5f; + if (isBeam) { - GlowOrbParticle spark = new GlowOrbParticle(Projectile.Center, -Projectile.velocity * Main.rand.NextFloat(-0.01f, 0.01f), false, 30, 1.1f - Projectile.ai[1] + sizeBonus, Main.rand.NextBool(3) ? Color.DarkViolet : mainColor); - GeneralParticleHandler.SpawnParticle(spark); + Projectile.Center += Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(-0.05f * Math.Sign(Projectile.velocity.X)) * 60; + Projectile.extraUpdates = 100; + timesItCanHit = 1; + Owner.SetScreenshake(4f); } - if (targetDist < 1400f && Main.rand.NextBool()) + for (int i = 0; i <= 8 * fxPower; i++) { - GlowOrbParticle spark = new GlowOrbParticle(Projectile.Center + Projectile.velocity * Main.rand.NextFloat(-2f, 2f), -Projectile.velocity * Main.rand.NextFloat(-0.01f, 0.01f), false, 30, 1.1f - Projectile.ai[1] + sizeBonus, Main.rand.NextBool(3) ? Color.DarkViolet : mainColor); - GeneralParticleHandler.SpawnParticle(spark); - } - - // A lingering trail of dust you can see after the particle trail disipates - if (Projectile.localAI[0] > 20 && Main.rand.NextBool()) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), 66); - dust.scale = Main.rand.NextFloat(0.7f, 1.5f); - dust.velocity = Projectile.velocity * Main.rand.NextFloat(-3, 3); + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseDust); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.5f) * Main.rand.NextFloat(2f, 9f) * fxPower; dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 1; + } + for (int i = 0; i <= 6 * fxPower; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.3f) * Main.rand.NextFloat(4f, 15f) * fxPower; + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 0.3f; + } + + onSpawn = false; + } + if (isBeam) + { + if (targetDist < 1400f && time > 0) // The main beam + { + Particle mainBeam = new CustomSpark(Projectile.Center, Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomCircle", false, 35, 0.55f * Projectile.scale, Effects.ArsenalEffects.ArsenalPulseColor * 0.5f, new Vector2(0.6f, 1f), true, true, shrinkSpeed: 0.2f, glowCenterScale: 0.7f, glowOpacity: 0.4f); + GeneralParticleHandler.SpawnParticle(mainBeam); + Projectile.scale += 0.007f; + + if (time % 3 == 0) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(3 * Projectile.scale, 3 * Projectile.scale), Effects.ArsenalEffects.ArsenalPulseDust); + dust.scale = Main.rand.NextFloat(0.7f, 1.2f) * Projectile.scale; + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(7f, 25f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 0.6f; + } } } - - #region Split Projectile AI - if (!notSplit) + else { - // Split projectile visuals - if (targetDist < 1400f) + if (time >= attackTime) // home in on enemy { - GlowOrbParticle spark = new GlowOrbParticle(Projectile.Center, -Projectile.velocity * Main.rand.NextFloat(-0.01f, 0.01f), false, 5, 1.7f - Projectile.ai[1] * 0.18f, Main.rand.NextBool(3) ? Color.DarkViolet : mainColor); - GeneralParticleHandler.SpawnParticle(spark); - } - if (targetDist < 1400f && Main.rand.NextBool()) - { - GlowOrbParticle spark = new GlowOrbParticle(Projectile.Center + Projectile.velocity * Main.rand.NextFloat(-2f, 2f), -Projectile.velocity * Main.rand.NextFloat(-0.01f, 0.01f), false, 5, 1.7f - Projectile.ai[1] * 0.18f, Main.rand.NextBool(3) ? Color.DarkViolet : mainColor); - GeneralParticleHandler.SpawnParticle(spark); - } - - if (Projectile.localAI[0] > 90) - { - // Velocity must look like it has stoped, but can't actually be zero otherwise homing code doesn't work - if (Projectile.localAI[0] == 91) - Projectile.velocity *= 0.001f; - - // When they begin the homing after a hit of spawning, do a few visuals - if (Projectile.localAI[0] == 120) + // Find a target + if (targeted == null) { - distance = 3000; + Projectile.velocity *= 0.9f; - 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); - GeneralParticleHandler.SpawnParticle(pulse); - - for (int k = 0; k < 6; k++) + startAttackEffects = true; + NPC chosenTarget = null; + float distance = 2500; + for (int index = 0; index < Main.npc.Length; index++) // look for a target that isnt one it has already hit in the last two hits. { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 66); - dust.scale = Main.rand.NextFloat(0.6f, 1.1f); - dust.velocity = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f); - dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; + NPC searchedTarget = Main.npc[index]; + if (searchedTarget.CanBeChasedBy(null, false)) + { + if (Vector2.Distance(Projectile.Center, searchedTarget.Center) < distance && (lastHitTarget != null ? searchedTarget != lastHitTarget : true) && searchedTarget.active && searchedTarget.life > 0) + { + distance = Vector2.Distance(Projectile.Center, searchedTarget.Center); + chosenTarget = searchedTarget; + } + } } - } - // Homing code - if (Projectile.localAI[0] > 120) - { - // Do damage if it's near its target otherwise don't, this is to prevent excessive hits as orbs rail through worm bosses and such - if (closestTarget is not null) - doDamage = Vector2.Distance(Projectile.Center, closestTarget.Center) < 10; - else - doDamage = false; + if (chosenTarget == null) // If no target was found, check again but accept last hit targets as viable. + { + if (lastHitTarget != null) + Projectile.localNPCImmunity[lastHitTarget.whoAmI] = 0; - // Tracking code, originally was going to try only tracking the closest target not including the last target you hit, but I couldn't make it work - // Eventually I settled on how it works now and it seems to home consistently so I'm happy enough there - float projectileSpeed = 9.5f; - if (closestTarget is not null && closestTarget.active) - { - float targetDirectionRotation = Projectile.SafeDirectionTo(closestTarget.Center).ToRotation(); - float turningRate = 10f + Projectile.localAI[0] * 0.00008f; - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(targetDirectionRotation, turningRate).ToRotationVector2() * projectileSpeed; - } - else - { - Projectile.velocity = Projectile.rotation.ToRotationVector2() * projectileSpeed; - Projectile.velocity *= 0.999f; - } - if (closestTarget is not null && Vector2.Distance(Projectile.Center, closestTarget.Center) < 10) - { - closestTarget = null; - distance = 3000; - } - - // Add extra updates as it hits more times, this smoothy increases the speed without destroying velocity based visual effects - Projectile.extraUpdates = 5 + (int)(Projectile.numHits * 0.3f); - { - // Actual homing movement for (int index = 0; index < Main.npc.Length; index++) { - if (Main.npc[index].CanBeChasedBy(null, false) || Main.npc[index] == lastTarget) + NPC searchedTarget = Main.npc[index]; + if (searchedTarget.CanBeChasedBy(null, false)) { - float extraDistance = (Main.npc[index].width / 2) + (Main.npc[index].height / 2); - - if (Vector2.Distance(Projectile.Center, Main.npc[index].Center) < (distance + extraDistance)) + if (Vector2.Distance(Projectile.Center, searchedTarget.Center) < distance && searchedTarget.active && searchedTarget.life > 0) { - closestTarget = Main.npc[index]; - distance = Vector2.Distance(Projectile.Center, Main.npc[index].Center); + distance = Vector2.Distance(Projectile.Center, searchedTarget.Center); + chosenTarget = searchedTarget; } } } } + + targeted = chosenTarget; + } + else // Home in on selected target + { + // Add extra updates as it hits more times, this smoothy increases the speed without destroying velocity based visual effects + Projectile.extraUpdates = 7 + (int)(Projectile.numHits * 0.6f); + + if (Projectile.timeLeft < 110 * Projectile.extraUpdates) + Projectile.timeLeft = 110 * Projectile.extraUpdates; + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.4f, 15, 0.97f); + if (startAttackEffects) + { + Projectile.velocity = Utils.DirectionTo(Projectile.Center, targeted.Center) * 10; + SoundStyle pulse = new("CalamityMod/Sounds/Item/PulseSound"); + SoundEngine.PlaySound(pulse with { Volume = 0.35f, Pitch = Math.Max(0.5f, Main.rand.NextFloat(0.1f, 0.3f) + Projectile.numHits * 0.2f), MaxInstances = 5 }, Projectile.Center); + + Particle pulse3 = new CustomSpark(Projectile.Center, Projectile.velocity * 0.5f, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 13, 0.05f * Projectile.scale, Effects.ArsenalEffects.ArsenalPulseColor, new Vector2(1.2f, 0.7f), shrinkSpeed: 0.4f); + GeneralParticleHandler.SpawnParticle(pulse3); + + for (int k = 0; k < 6; k++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPulseDust); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * Projectile.scale; + dust.velocity = Utils.DirectionTo(Projectile.Center, targeted.Center).RotatedByRandom(0.5f) * Main.rand.NextFloat(5f, 9f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 1; + } + startAttackEffects = false; + } + if (targeted.life <= 0 || !targeted.active || !targeted.CanBeChasedBy()) + targeted = null; } } else { - // Minor dust trail for when they first spawn - if (Main.rand.NextBool(5)) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), 66); - dust.scale = Main.rand.NextFloat(0.8f, 1.4f); - dust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f); - dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; - } - Projectile.velocity *= 0.98f; + Projectile.velocity *= 0.985f; + } + + float squash = Utils.GetLerpValue(1, 3, Projectile.velocity.Length(), true); + if (targetDist < 1400f && squash > 0.1f && time > 5) // The trail + { + Particle trail = new CustomSpark(Projectile.Center, Projectile.velocity * 0.01f, "CalamityMod/Particles/DualTrail", false, 13, 0.075f, Effects.ArsenalEffects.ArsenalPulseColor * 0.6f * squash, new Vector2(1 - 0.15f * squash, 1.5f), true, false, shrinkSpeed: 0.2f * squash); + GeneralParticleHandler.SpawnParticle(trail); } } - #endregion - // Visuals for the shot as it exits the tip of the rifle - if (Projectile.localAI[0] == createDustVar && notSplit) - PulseBurst(4f, 5f); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + time++; } - public override bool? CanDamage() => (doDamage ? null : false); + public override bool? CanHitNPC(NPC target) => ((target == targeted) || isBeam) ? null : false; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { bool onKill = (target.life <= 0 && target.realLife == -1); - if (notSplit) + + timesItCanHit--; + + float fxVel = isBeam ? 3f : 1f; + for (int i = 0; i <= 5 * fxVel; i++) { - for (int i = 0; i <= 9; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 66); - dust.scale = Main.rand.NextFloat(0.4f, 1.1f); - dust.velocity = (Projectile.velocity * 4).RotateRandom(0.6f) * Main.rand.NextFloat(0.2f, 0.9f); - dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; - } - - // Since the beam looks wider as it travels, these hit particles scale a bit to fit that - float sizeBonus = MathHelper.Clamp(Projectile.localAI[0] * 0.01f, 0, 3.5f); - for (int k = 0; k < 9; k++) - { - SparkParticle spark = new SparkParticle(Projectile.Center + Main.rand.NextVector2Circular(8, 8) - Projectile.velocity * 7, Projectile.velocity * Main.rand.NextFloat(0.7f, 3.1f), false, 30, 0.9f * Main.rand.NextFloat(0.9f, 1.1f) + sizeBonus, mainColor); - GeneralParticleHandler.SpawnParticle(spark); - } - - // Spawn the 4 energy orbs - // 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.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.Zero) * (14f - i * 0.7f)) * ((i + 1) * 0.25f), Projectile.type, projectileDamage, Projectile.knockBack, Projectile.owner, 0f, 1f + i); - } - Projectile.Kill(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.scale = Main.rand.NextFloat(1.7f, 2.4f) * Projectile.scale; + dust.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotateRandom(0.3f) * Main.rand.NextFloat(4f, 9f) * fxVel; + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalPulseColor; + dust.fadeIn = 0.3f * fxVel; } - // Split projectile on hit effects - else + + // Set some values to get ready for it to home again for its next hit + if (!isBeam) { - // Set some values to get ready for it to home again for its next hit - lastTarget = target; - distance = 3000; - Projectile.localAI[0] = 60; - Projectile.velocity *= MathHelper.Clamp(1.5f - Projectile.numHits * 0.5f, 1f, 1.5f); - - for (int i = 0; i <= 2; i++) - { - SquishyLightParticle energy = new SquishyLightParticle(Projectile.Center, (Projectile.velocity * 2).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.1f, 0.4f), Main.rand.NextFloat(0.1f, 0.25f), Main.rand.NextBool(3) ? Color.DarkViolet : mainColor, Main.rand.Next(20, 30 + 1), 0.25f, 2f); - GeneralParticleHandler.SpawnParticle(energy); - } - - if (hit.Damage > 2 && target == closestTarget) - timesItCanHit--; + Projectile.ai[1] = -50; + lastHitTarget = target; + targeted = null; + time = 0; + Projectile.velocity *= 0.9f; if (onKill) + timesItCanHit += 3; + } + else + { + if (Main.myPlayer == Projectile.owner) { - timesItCanHit += 2; - Projectile.timeLeft += 90; + // Spawn the 4 energy orbs + // 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 = 1; i < numProj + 1; i++) + { + Projectile orb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.Zero) * (10 / numProj * i), Projectile.type, projectileDamage, Projectile.knockBack, Projectile.owner, 0f, 28 * i); + orb.scale = 1.4f - i * 0.2f; + } } + Vector2 vel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + Particle pulse3 = new CustomSpark(Projectile.Center, vel * 7, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 16, 0.065f, Effects.ArsenalEffects.ArsenalPulseColor, new Vector2(2f, 0.7f), shrinkSpeed: 0.2f); + GeneralParticleHandler.SpawnParticle(pulse3); + Particle pulse4 = new CustomSpark(Projectile.Center, vel * 13, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 12, 0.04f, Effects.ArsenalEffects.ArsenalPulseColor, new Vector2(2f, 0.7f), shrinkSpeed: 0.2f); + GeneralParticleHandler.SpawnParticle(pulse4); } + // If it's hit targeted enemies enough, kill it + if (timesItCanHit <= 0) + Projectile.Kill(); + } - private void PulseBurst(float speed1, float speed2) + public override bool PreDraw(ref Color lightColor) { - for (int i = 0; i <= 15; i++) + if (isBeam) + return false; + Asset orb = ModContent.Request("CalamityMod/Particles/BloomCircle"); + Vector2 squash = new Vector2(Utils.Remap(Projectile.velocity.Length(), 5, 10, 1, 0.6f), Utils.Remap(Projectile.velocity.Length(), 5, 10, 1, 2f)); + float timeleftFade = (float)Math.Pow(Utils.GetLerpValue(0, 40 * Projectile.extraUpdates, Projectile.timeLeft, true), 5); + + for (int i = 0; i < 7; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 66); - dust.scale = Main.rand.NextFloat(0.4f, 1.4f); - dust.velocity = (Projectile.velocity * 4).RotateRandom(0.6f) * Main.rand.NextFloat(0.2f, 0.9f); - dust.noGravity = true; - dust.color = Main.rand.NextBool(3) ? Color.DarkViolet : mainColor; - dust.noLight = true; - } - for (int i = 0; i <= 15; i++) - { - SquishyLightParticle energy = new SquishyLightParticle(Projectile.Center, (Projectile.velocity * 4).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.1f, 0.4f), Main.rand.NextFloat(0.2f, 0.6f), Main.rand.NextBool(3) ? Color.DarkViolet : mainColor, Main.rand.Next(30, 40 + 1), 0.25f, 2f); - GeneralParticleHandler.SpawnParticle(energy); + Color orbColor = Color.Lerp(Effects.ArsenalEffects.ArsenalPulseColor, Color.White, i * 0.07f) with { A = 0 } * 0.5f; + Vector2 scale = Projectile.scale * timeleftFade * squash * (0.05f + i * 0.01f) * 3; + Main.EntitySpriteDraw(orb.Value, Projectile.Center - Main.screenPosition, null, orbColor, Projectile.rotation, orb.Size() * 0.5f, scale, SpriteEffects.None); } + + return false; } } } diff --git a/Projectiles/DraedonsArsenal/PulseTurret.cs b/Projectiles/DraedonsArsenal/PulseTurret.cs index e820312872..3d2cfc01bb 100644 --- a/Projectiles/DraedonsArsenal/PulseTurret.cs +++ b/Projectiles/DraedonsArsenal/PulseTurret.cs @@ -94,7 +94,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (!Main.dedServ) { for (int i = 0; i < 12; i++) - Dust.NewDustPerfect(shootPosition, 173).scale = Main.rand.NextFloat(1.4f, 1.8f); + Dust.NewDustPerfect(shootPosition, DustID.ShadowbeamStaff).scale = Main.rand.NextFloat(1.4f, 1.8f); } Projectile.ai[1] = 15f; diff --git a/Projectiles/DraedonsArsenal/PulseTurretShot.cs b/Projectiles/DraedonsArsenal/PulseTurretShot.cs index 7bd968780f..347799d8d3 100644 --- a/Projectiles/DraedonsArsenal/PulseTurretShot.cs +++ b/Projectiles/DraedonsArsenal/PulseTurretShot.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float angle = Projectile.velocity.ToRotation() + MathHelper.PiOver2; float pulse = (float)Math.Sin(Projectile.ai[0] + MathHelper.TwoPi / 3f * i); Vector2 offset = angle.ToRotationVector2().RotatedBy(MathHelper.TwoPi / 3f * i) * pulse * 7f; - Dust.NewDustPerfect(Projectile.Center + offset, 234, Vector2.Zero).noGravity = true; - Dust.NewDustPerfect(Projectile.Center - offset, 234, Vector2.Zero).noGravity = true; + Dust.NewDustPerfect(Projectile.Center + offset, DustID.BoneTorch, Vector2.Zero).noGravity = true; + Dust.NewDustPerfect(Projectile.Center - offset, DustID.BoneTorch, Vector2.Zero).noGravity = true; } } if (Projectile.ai[1] == 1f) @@ -67,14 +67,14 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Dust dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY.RotatedBy(j / (float)SpiralRings * MathHelper.TwoPi * direction).RotatedBy(i / (float)SpiralPrecision * MathHelper.TwoPi / SpiralRings * direction) * - 36f * i / SpiralPrecision, 173); + 36f * i / SpiralPrecision, DustID.ShadowbeamStaff); dust.velocity = Projectile.SafeDirectionTo(dust.position) * 2.4f; dust.scale = 1.6f; dust.noGravity = true; dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY.RotatedBy(j / (float)SpiralRings * MathHelper.TwoPi * direction).RotatedBy(i / (float)SpiralPrecision * MathHelper.TwoPi / SpiralRings * direction) * - 36f * i / SpiralPrecision, 173); + 36f * i / SpiralPrecision, DustID.ShadowbeamStaff); dust.velocity = Projectile.DirectionFrom(dust.position) * 4f; dust.scale = 1.6f; dust.noGravity = true; diff --git a/Projectiles/DraedonsArsenal/ScattershotLance.cs b/Projectiles/DraedonsArsenal/ScattershotLance.cs deleted file mode 100644 index 032a7b12ac..0000000000 --- a/Projectiles/DraedonsArsenal/ScattershotLance.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class ScattershotLance : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public Vector2 startVel = Vector2.Zero; - public int time = 0; - public override void SetDefaults() - { - Projectile.width = 35; - Projectile.height = 35; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.timeLeft = 11; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, Color.Red.ToVector3()); - Player Owner = Main.player[Projectile.owner]; - float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - - if (time == 0) - { - startVel = Projectile.velocity; - for (int i = 0; i <= 9; i++) - { - Particle spark = new SparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(0.2f, 1f), false, 55, Main.rand.NextFloat(0.2f, 1.8f), Color.Red); - GeneralParticleHandler.SpawnParticle(spark); - - SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(0.2f, 1f), false, 25, Main.rand.NextFloat(0.1f, 0.8f), Color.White); - GeneralParticleHandler.SpawnParticle(spark2); - } - for (int i = 0; i <= 15; i++) - { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(40, 40), 278); - chargefull.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.2f, 2f); - chargefull.scale = Main.rand.NextFloat(0.4f, 0.8f); - chargefull.noGravity = true; - chargefull.color = Color.Red; - } - } - Projectile.rotation = startVel.ToRotation() + MathHelper.PiOver2; - Projectile.velocity = Vector2.Zero; - time++; - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - if (Projectile.numHits == 0) - { - SoundStyle sound = new("CalamityMod/Sounds/Item/MeldShoot"); - SoundEngine.PlaySound(sound with { Volume = 1f }, Projectile.Center); - //Particle spark = new GlowSparkParticle(target.Center, startVel.SafeNormalize(Vector2.UnitY) * 20, false, 9, 0.1f, Color.Red, new Vector2(1f, 1.1f), true, true, 0.8f); - //GeneralParticleHandler.SpawnParticle(spark); - } - for (int i = 0; i < MathHelper.Clamp(25 - Projectile.numHits * 4, 1, 10); i++) - { - Vector2 velocity = startVel.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 1.4f); - Particle nanoDust = new NanoParticle(target.Center, velocity, Main.rand.NextBool(3) ? Color.Crimson : Color.Red, Main.rand.NextFloat(0.4f, 1f), 35, Main.rand.NextBool(), true); - GeneralParticleHandler.SpawnParticle(nanoDust); - } - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.88f); - if (Projectile.damage < 1) - Projectile.damage = 1; - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (startVel == Vector2.Zero) - return false; - // If the target is touching the beam's hitbox (which is a small rectangle vaguely overlapping the host crystal), that's good enough. - if (projHitbox.Intersects(targetHitbox)) - return true; - // Otherwise, perform an AABB line collision check to check the whole beam. - float _ = float.NaN; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + startVel * 12, Projectile.width * Projectile.scale, ref _); - } - public override bool PreDraw(ref Color lightColor) - { - if (time < 1) - return false; - Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; - float fade = Utils.GetLerpValue(0, 5, Projectile.timeLeft, true); - for (int i = 0; i < 5; i++) - Main.EntitySpriteDraw(pointTexture, Projectile.Center - Main.screenPosition + (startVel * (2 + (i * 2)) * fade), null, Color.Red with { A = 0 } * fade, Projectile.rotation, pointTexture.Size() * 0.5f, new Vector2(0.4f, 0.9f) * (0.12f - (i * 0.0165f)), SpriteEffects.None); - for (int i = 0; i < 5; i++) - Main.EntitySpriteDraw(pointTexture, Projectile.Center - Main.screenPosition + (startVel * (2 + (i * 2)) * fade), null, Color.White with { A = 0 } * 0.8f * fade, Projectile.rotation, pointTexture.Size() * 0.5f, new Vector2(0.4f, 0.9f) * (0.12f - (i * 0.0165f)) * 0.7f, SpriteEffects.None); - return false; - } - } -} diff --git a/Projectiles/DraedonsArsenal/ScattershotLaser.cs b/Projectiles/DraedonsArsenal/ScattershotLaser.cs deleted file mode 100644 index 80246df64a..0000000000 --- a/Projectiles/DraedonsArsenal/ScattershotLaser.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class ScattershotLaser : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - private int dust = 127; - public int time = 0; - public override void SetDefaults() - { - Projectile.width = 7; - Projectile.height = 7; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.extraUpdates = 9; - Projectile.timeLeft = 600; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.4f); - Player Owner = Main.player[Projectile.owner]; - float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - - if (time > 15 && targetDist < 1400) - { - if (Projectile.timeLeft % 6 == 0) - { - Particle spark = new LineParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 8, 1.7f, Color.Red); - GeneralParticleHandler.SpawnParticle(spark); - } - if (Projectile.timeLeft % 5 == 0) - { - SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 3, 0.7f, Color.White); - GeneralParticleHandler.SpawnParticle(spark2); - } - } - - time++; - } - - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 4; i++) - { - Vector2 velocity = (Projectile.velocity * 5).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 0.8f); - Particle nanoDust = new NanoParticle(Projectile.Center, velocity, Main.rand.NextBool(3) ? Color.Crimson : Color.Red, Main.rand.NextFloat(0.4f, 1f), 20, Main.rand.NextBool(), true); - GeneralParticleHandler.SpawnParticle(nanoDust); - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, (Projectile.velocity * 5).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.3f, 0.5f)); - dust.noGravity = true; - dust.color = Color.Red; - } - } - } -} diff --git a/Projectiles/DraedonsArsenal/ScattershotSkewerHoldout.cs b/Projectiles/DraedonsArsenal/ScattershotSkewerHoldout.cs deleted file mode 100644 index 2f0e377c20..0000000000 --- a/Projectiles/DraedonsArsenal/ScattershotSkewerHoldout.cs +++ /dev/null @@ -1,273 +0,0 @@ -using System; -using CalamityMod.Cooldowns; -using CalamityMod.Items; -using CalamityMod.Items.Weapons.DraedonsArsenal; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Particles; -using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class ScattershotSkewerHoldout : BaseGunHoldoutProjectile - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override int AssociatedItemID => ModContent.ItemType(); - public override float MaxOffsetLengthFromArm => 30f; - public override float RecoilResolveSpeed => 0.1f; - public override float OffsetXUpwards => -0f; - public override float BaseOffsetY => -0f; - public override float OffsetYDownwards => 0f; - - public static float BulletSpeed = 12f; - public SlotId ChargeSlot; - public SlotId StartSlot; - public Color mainColor = Color.Lerp(Color.Red, Color.White, 0f); - public int time = 0; - public int chargeAttackTimer = 10; - public bool doingChargeAttack = false; - - public ref float CurrentChargingFrames => ref Projectile.ai[0]; - public int chargeMax = 0; - public int downtime = 0; - public bool ChargeLV1 => CurrentChargingFrames >= chargeMax; - - public override void KillHoldoutLogic() - { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) - Projectile.Kill(); - } - public override void OnSpawn(IEntitySource source) - { - OffsetLengthFromArm = 30; - Player Owner = Main.player[Projectile.owner]; - chargeMax = (int)(Owner.itemAnimationMax * 2.1f); - - if (Owner.Calamity().arsenalCooldown <= 0) - { - SoundStyle sound = new("CalamityMod/Sounds/Item/ScattershotCharge"); - StartSlot = SoundEngine.PlaySound(sound with { Volume = 0.9f }, Projectile.Center); - } - } - - public override void HoldoutAI() - { - CalamityGlobalItem modItem = Owner.ActiveItem().Calamity(); - Vector2 mountedCenter = Owner.MountedCenter; - Vector2 ownerToMouse = Owner.Calamity().mouseWorld - mountedCenter; - if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) - ChargeSound.Position = Projectile.Center; - if (SoundEngine.TryGetActiveSound(StartSlot, out var StartSound) && StartSound.IsPlaying) - StartSound.Position = Projectile.Center; - - // Fire if the owner stops channeling or otherwise cannot use the weapon. - if (((Owner.CantUseHoldout() || (Owner.Calamity().mouseRight || Owner.Calamity().arsenalCooldown > 0)) && downtime == 0 && time >= 1) || doingChargeAttack) - { - KeepRefreshingLifetime = false; - - Projectile.timeLeft = Owner.Calamity().mouseRight ? Owner.itemAnimationMax * 2 : Owner.itemAnimationMax; - downtime = Owner.itemAnimationMax; - - // Big Shot mode - if ((ChargeLV1 && Owner.Calamity().arsenalCooldown <= 0) || doingChargeAttack) - { - if (chargeAttackTimer == 10) - { - doingChargeAttack = true; - Projectile.timeLeft += chargeAttackTimer; - OffsetLengthFromArm -= 20; - } - else - { - if (chargeAttackTimer == 3) - { - OffsetLengthFromArm += 35; - ChargeSound?.Stop(); - SoundStyle sound = new("CalamityMod/Sounds/Item/ScattershotChargeShoot"); - SoundEngine.PlaySound(sound with { Volume = 0.9f }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 6f; - } - if (chargeAttackTimer <= 0) - { - Owner.Calamity().arsenalCooldown = 500; - Owner.AddCooldown(ArsenalPower.ID, 500); - - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - int charge2Damage = (int)(Projectile.damage * 60); // Seems high but its on a cooldown and is a melee attack so might be okay - float charge2KB = Projectile.knockBack * 3f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 2, ModContent.ProjectileType(), charge2Damage, charge2KB, Projectile.owner); - - for (int i = 0; i <= 25; i++) - { - Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, 267, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(0.5f, 1.3f)); - dust.noGravity = true; - dust.color = mainColor; - } - CurrentChargingFrames = 0; - if (modItem.Charge > 0) - modItem.Charge -= 0.25f; - else - Projectile.Kill(); - - chargeAttackTimer = 10; - doingChargeAttack = false; - } - } - if (doingChargeAttack) - chargeAttackTimer--; - } - // Spread Fire mode - else - { - StartSound?.Stop(); - OffsetLengthFromArm -= 10; - ChargeSound?.Stop(); - SoundStyle sound = new("CalamityMod/Sounds/Item/ScattershotShoot"); - SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); - - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed * 0.3f; - - float angle1 = MathHelper.ToRadians(3f); - for (int i = 0; i < 2; i++) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - shootVelocity * 8, shootVelocity.RotatedBy(angle1), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - shootVelocity * 4, shootVelocity.RotatedBy(angle1 * 0.7f) * 0.9f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - angle1 *= -1; - } - - float angle2 = MathHelper.ToRadians(5f); - for (int i = 0; i < 2; i++) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - shootVelocity * 8, shootVelocity.RotatedBy(angle2) * 0.95f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - angle2 *= -1; - } - CurrentChargingFrames = 0; - if (modItem.Charge > 0) - modItem.Charge -= 0.1f; - else - Projectile.Kill(); - } - } - else if (downtime == 0) - { - CurrentChargingFrames++; - // Charge-up visuals - if (CurrentChargingFrames >= 10) - { - float particleScale = Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true); - float strength = particleScale; - Vector3 DustLight = mainColor.ToVector3(); - Lighting.AddLight(GunTipPosition, DustLight * strength); - } - - // Full charge dusts - if (CurrentChargingFrames == chargeMax) - { - OffsetLengthFromArm += 10; - ChargeSound?.Stop(); - for (int i = 0; i < 20; i++) - { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 66); - chargefull.velocity = (MathHelper.TwoPi * i / 20f).ToRotationVector2() * 4f + Owner.velocity * 0.5f; - chargefull.scale = Main.rand.NextFloat(0.6f, 0.8f); - chargefull.noGravity = true; - chargefull.color = mainColor; - } - SoundStyle sound = new("CalamityMod/Sounds/Item/ScattershotChargeLoop"); - ChargeSlot = SoundEngine.PlaySound(sound with { Volume = 0.7f, IsLooped = true }, Projectile.Center); - } - - if (CurrentChargingFrames > 10) - { - for (int i = 0; i < 2; i++) - { - Vector2 spawnPos = Projectile.Center + Main.rand.NextVector2Circular(25, 25); - - Particle spark = new LineParticle(spawnPos, (GunTipPosition - spawnPos).SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(1, 4), false, 4, Main.rand.NextFloat(0.3f, 0.45f), Color.Red); - GeneralParticleHandler.SpawnParticle(spark); - } - } - } - - if (!doingChargeAttack) - { - if (downtime == 1 && !Owner.Calamity().mouseRight) - Projectile.Kill(); - - if (downtime > 0) - downtime--; - - if ((Owner.Calamity().mouseRight || Owner.Calamity().arsenalCooldown > 0)) - CurrentChargingFrames = 0; - - if (Owner.Calamity().mouseRight) - { - StartSound?.Stop(); - } - } - - time++; - } - public override void OnKill(int timeLeft) - { - if (SoundEngine.TryGetActiveSound(ChargeSlot, out var ChargeSound)) - ChargeSound?.Stop(); - if (SoundEngine.TryGetActiveSound(StartSlot, out var StartSound)) - StartSound?.Stop(); - } - public override bool PreDraw(ref Color lightColor) - { - if (time < 2) - return false; - - float fade = Utils.GetLerpValue(chargeMax / 3, chargeMax, CurrentChargingFrames, true); - - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/ScattershotSkewer").Value; - Texture2D glowTexture = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/ScattershotSkewerGlow").Value; - Vector2 drawPosition = Projectile.Center - Main.screenPosition + new Vector2(0, -3); - - if (CurrentChargingFrames > 10 && !Owner.CantUseHoldout() && !Owner.Calamity().mouseRight && CurrentChargingFrames < chargeMax) - { - float rumble = Utils.GetLerpValue(10, chargeMax, CurrentChargingFrames, true); - drawPosition += Main.rand.NextVector2Circular(5 * rumble, 5 * rumble); - } - - Color drawColor = Projectile.GetAlpha(lightColor); - float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); - Vector2 rotationPoint = texture.Size() * 0.5f; - SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - Texture2D pointTexture = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; - - Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); - - if (CurrentChargingFrames > 10 && downtime == 0) - { - for (int i = 0; i < 3; i++) - { - Color auraColor = Color.White with { A = 0 } * Utils.GetLerpValue(10, chargeMax, CurrentChargingFrames, true) * 0.6f; - Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTimeWrappedHourly * 40f).ToRotationVector2(); - rotationalDrawOffset *= 3; - Main.EntitySpriteDraw(glowTexture, drawPosition + rotationalDrawOffset, null, auraColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); - } - - float randSize = Main.rand.NextFloat(0.4f, 0.9f); - Main.EntitySpriteDraw(rechargeTexture, GunTipPosition - Main.screenPosition + Projectile.velocity * 5, null, mainColor with { A = 0 }, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.25f * Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); - Main.EntitySpriteDraw(rechargeTexture, GunTipPosition - Main.screenPosition + Projectile.velocity * 5, null, Color.White with { A = 0 }, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.15f * Utils.GetLerpValue(0, chargeMax, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); - - //Main.EntitySpriteDraw(pointTexture, tipPosition - Main.screenPosition + (Projectile.velocity * 15 * fade), null, mainColor with { A = 0 } * fade, Projectile.velocity.RotatedBy(MathHelper.ToRadians(90f)).ToRotation(), pointTexture.Size() * 0.5f, new Vector2(0.5f, 0.9f) * 0.035f * fade * randSize * (CurrentChargingFrames == chargeMax ? 1.5f : 1), flipSprite); - } - - Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); - return false; - } - } -} diff --git a/Projectiles/DraedonsArsenal/ShortCircuitExplosion.cs b/Projectiles/DraedonsArsenal/ShortCircuitExplosion.cs new file mode 100644 index 0000000000..e931f7966f --- /dev/null +++ b/Projectiles/DraedonsArsenal/ShortCircuitExplosion.cs @@ -0,0 +1,51 @@ +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Ranged +{ + public class ShortCircuitExplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public float radius = 200; + public override void SetDefaults() + { + Projectile.width = 200; + Projectile.height = 200; + Projectile.friendly = true; + Projectile.ignoreWater = false; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 10; + Projectile.DamageType = DamageClass.Ranged; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + target.AddBuff(ModContent.BuffType(), 300); + + float minMult = 0.2f; + int hitsToMinMult = 7; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + Player Owner = Main.player[Projectile.owner]; + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center); + target.MoveNPC(launchVel, 12, true); + } + + public override void AI() + { + + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, radius, targetHitbox); + } +} diff --git a/Projectiles/DraedonsArsenal/ShortCircuitHook.cs b/Projectiles/DraedonsArsenal/ShortCircuitHook.cs new file mode 100644 index 0000000000..deb10e2df6 --- /dev/null +++ b/Projectiles/DraedonsArsenal/ShortCircuitHook.cs @@ -0,0 +1,248 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Cooldowns; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + [PierceResistException] + public class ShortCircuitHook : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public static readonly SoundStyle Explode = new("CalamityMod/Sounds/Item/ElectricBurst") { Volume = 0.8f }; + public bool giveCooldown = false; + public bool onSpawn = true; + public enum TaserAIState + { + Firing, + Electrocuting, + ReelingBack + } + + public TaserAIState AIState + { + get => (TaserAIState)(int)Projectile.ai[0]; + set => Projectile.ai[0] = (int)value; + } + + public float Time + { + get => Projectile.ai[1]; + set => Projectile.ai[1] = value; + } + + public int ElectrocutionTarget + { + get => (int)Projectile.localAI[0]; + set => Projectile.localAI[0] = value; + } + + public const float ReelbackSpeed = 40f; + public Color hookColor = Color.SlateGray; + public SlotId Hum { get; set; } + + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.penetrate = 2; + Projectile.extraUpdates = 8; + Projectile.tileCollide = false; + Projectile.ownerHitCheck = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15; + Projectile.ArmorPenetration = 10; + } + + public override void AI() + { + if (onSpawn) + { + for (int i = 0; i < 15; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 30, Effects.ArsenalEffects.ArsenalElectricDust); + dust.scale = Main.rand.NextBool(7) ? 1.5f : 0.9f; + dust.noGravity = true; + dust.fadeIn = 2; + dust.color = Effects.ArsenalEffects.ArsenalElectricColor; + dust.velocity = Projectile.velocity.RotatedByRandom(0.7f) * Main.rand.NextFloat(0.9f, 2.8f); + } + onSpawn = false; + } + if (AIState != TaserAIState.Firing) + Time++; + Player player = Main.player[Projectile.owner]; + hookColor = Color.Lerp(hookColor, Color.SlateGray, 0.25f); + + float distanceFromPlayer = Projectile.Distance(player.Center); + switch (AIState) + { + case TaserAIState.Firing: + if (distanceFromPlayer > 800f || Time >= 90f) + GoToAIState(TaserAIState.ReelingBack); + break; + case TaserAIState.Electrocuting: + if (distanceFromPlayer > 2000f) + GoToAIState(TaserAIState.ReelingBack); + + if (SoundEngine.TryGetActiveSound(Hum, out var hum) && hum.IsPlaying) + { + hum.Position = player.Center; + hum.Pitch = MathHelper.Lerp(0f, 1f, Utils.GetLerpValue(0f, 150, Time, true)); + } + // electric explosion; + if (Time == 150 || !Main.npc[ElectrocutionTarget].active) + { + if (!Main.npc[ElectrocutionTarget].active) + giveCooldown = false; + SoundEngine.PlaySound(Explode, Projectile.Center); + Projectile.localNPCHitCooldown = 15; + + for (int i = 0; i < 25; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalElectricDust, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f)); + dust.scale = Main.rand.NextFloat(0.9f, 1.4f); + dust.noGravity = false; + dust.color = Effects.ArsenalEffects.ArsenalElectricColor; + + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalElectricDust, new Vector2(15, 15).RotatedByRandom(100) * Main.rand.NextFloat(0.75f, 1f)); + dust2.scale = Main.rand.NextFloat(1.7f, 2.1f); + dust2.noGravity = true; + dust2.color = Effects.ArsenalEffects.ArsenalElectricColor; + } + + DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalElectricColor * 0.5f, new Vector2(1f, 1), 0, 0.5f, 3f, 18); + GeneralParticleHandler.SpawnParticle(pulse); + Particle bloom = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 10, 1.3f, Effects.ArsenalEffects.ArsenalElectricColor, Vector2.One, true, true); + GeneralParticleHandler.SpawnParticle(bloom); + + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 8, 0, Projectile.owner, 0); + Time = 0; + Projectile.velocity = Projectile.SafeDirectionTo(player.Center); + + GoToAIState(TaserAIState.ReelingBack); + return; + } + if (Main.npc[ElectrocutionTarget].active) + Projectile.Center = Main.npc[ElectrocutionTarget].Center; + break; + case TaserAIState.ReelingBack: + // Kill the gun and the hook if the hook has returned to the gun. + if (SoundEngine.TryGetActiveSound(Hum, out var hum2) && hum2.IsPlaying) + { + hum2?.Stop(); + } + if (Projectile.Hitbox.Intersects(player.Hitbox)) + { + if (giveCooldown) + { + player.Calamity().arsenalCooldown = 300; + player.AddCooldown(ArsenalPower.ID, 300); + } + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = 0.5f, Pitch = 0.3f }, Projectile.Center); + Projectile.Kill(); + return; + } + Projectile.tileCollide = false; + Projectile.extraUpdates = 8; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(player.Center) * (ReelbackSpeed / Projectile.extraUpdates), 0.02f); + break; + } + + Projectile.rotation = Projectile.AngleFrom(player.Center); + + ManipulatePlayerItemValues(player); + } + + + public void ManipulatePlayerItemValues(Player player) + { + player.ChangeDir((player.Center.X - Projectile.Center.X < 0).ToDirectionInt()); + player.itemRotation = CalamityUtils.WrapAngle90Degrees(Projectile.rotation); + player.itemTime = 4; + player.itemAnimation = 4; + } + + public void GoToAIState(TaserAIState newAIState) + { + // Don't waste the resources changing the AI state if the projectile is already in said state. + if (AIState == newAIState) + return; + + Projectile.penetrate = -1; + AIState = newAIState; + Projectile.netUpdate = true; + } + + public override bool PreDraw(ref Color lightColor) + { + Player player = Main.player[Projectile.owner]; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Texture2D lineTex = ModContent.Request("CalamityMod/Particles/BloomLineSoftEdge").Value; + Vector2 altPos = player.Center - Vector2.UnitY * 3; + float distance = Utils.Distance(altPos, Projectile.Center); + int drawSeperation = 10; + int startSeperation = drawSeperation; + Vector2 toPoint = Utils.DirectionTo(altPos, Projectile.Center); + for (int i = startSeperation; i < distance; i += drawSeperation) + { + Main.EntitySpriteDraw(lineTex, Projectile.Center - Main.screenPosition - toPoint * i, null, hookColor with { A = 0 }, toPoint.ToRotation() + MathHelper.PiOver2, lineTex.Size() * 0.5f, new Vector2(1, 1.3f) * Projectile.scale * 0.01f, SpriteEffects.None); + } + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Projectile.tileCollide = false; + if (Projectile.localNPCHitCooldown > 7 && target == Main.npc[ElectrocutionTarget]) + Projectile.localNPCHitCooldown -= 1; + hookColor = Color.Cyan; + target.AddBuff(ModContent.BuffType(), 120); + + if (AIState == TaserAIState.Firing) + { + giveCooldown = true; + Projectile.Center = target.Center; + Projectile.extraUpdates = 1; + if (!Main.dedServ) + { + for (int i = 0; i < 30; i++) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalElectricDust, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.85f, 0.9f)); + dust2.scale = Main.rand.NextFloat(0.9f, 1.2f); + dust2.noGravity = true; + dust2.color = Effects.ArsenalEffects.ArsenalElectricColor; + } + } + ElectrocutionTarget = target.whoAmI; + Time = 0f; + + SoundStyle charge = new("CalamityMod/Sounds/Item/LowHum"); + Hum = SoundEngine.PlaySound(charge with { Volume = 1.6f, IsLooped = true }, Projectile.Center); + + GoToAIState(TaserAIState.Electrocuting); + } + + // If it kills an enemy, don't give cooldown + if (giveCooldown && (target.life <= 0 && target.realLife == -1)) + giveCooldown = false; + } + public override bool? CanHitNPC(NPC target) => (Projectile.numHits == 0 || target == Main.npc[ElectrocutionTarget]) ? null : false; + public override bool OnTileCollide(Vector2 oldVelocity) + { + GoToAIState(TaserAIState.ReelingBack); + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/TaserHook.png b/Projectiles/DraedonsArsenal/ShortCircuitHook.png similarity index 100% rename from Projectiles/DraedonsArsenal/TaserHook.png rename to Projectiles/DraedonsArsenal/ShortCircuitHook.png diff --git a/Projectiles/DraedonsArsenal/ShortCircuitShot.cs b/Projectiles/DraedonsArsenal/ShortCircuitShot.cs new file mode 100644 index 0000000000..95c1b5dc0d --- /dev/null +++ b/Projectiles/DraedonsArsenal/ShortCircuitShot.cs @@ -0,0 +1,89 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class ShortCircuitShot : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public Vector2 position; + public Vector2 oldPos; + public override void SetDefaults() + { + Projectile.width = 12; + Projectile.height = 12; + Projectile.timeLeft = 180; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 2; + Projectile.extraUpdates = 5; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.ArmorPenetration = 10; + } + public override void AI() + { + if (time == 0) + { + for (int i = 0; i < 7; i++) + { + bool is278 = Main.rand.NextBool(4); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 30, is278 ? Effects.ArsenalEffects.ArsenalDust : Effects.ArsenalEffects.ArsenalElectricDust); + dust.scale = is278 ? 0.7f : Main.rand.NextBool(7) ? 1.2f : 0.8f; + dust.noGravity = true; + if (!is278) + dust.fadeIn = 2; + dust.color = Effects.ArsenalEffects.ArsenalElectricColor; + dust.velocity = Projectile.velocity.RotatedByRandom(0.7f) * Main.rand.NextFloat(0.6f, 2.3f) * (is278 ? 0.3f : 1); + } + } + if (time > 4) + { + if (Projectile.timeLeft % 2 == 0) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalElectricDust); + dust.scale = Main.rand.NextBool(7) ? 1f : 0.55f; + dust.noGravity = true; + dust.fadeIn = 2; + dust.color = Effects.ArsenalEffects.ArsenalElectricColor; + dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.2f, 1.5f); + } + + if (Projectile.timeLeft % 2 == 0) + { + SparkParticle tip = new SparkParticle(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5, Projectile.velocity, false, (Projectile.timeLeft < 50 ? 20 : 6), 0.6f, Effects.ArsenalEffects.ArsenalElectricColor); + GeneralParticleHandler.SpawnParticle(tip); + } + if (Projectile.timeLeft % 3 == 0) + { + float squash = Utils.GetLerpValue(1, 3, Projectile.velocity.Length(), true); + Particle trail = new BoltParticle(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10, Projectile.velocity * 0.01f, false, 7, 0.2f, Effects.ArsenalEffects.ArsenalElectricColor * 0.8f * squash, new Vector2(1 - 0.15f * squash, 1f), true, false, shrinkSpeed: 0.5f * squash); + GeneralParticleHandler.SpawnParticle(trail); + } + } + + Projectile.velocity *= 0.987f; + time++; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Player Owner = Main.player[Projectile.owner]; + target.AddBuff(ModContent.BuffType(), 40); + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center); + target.MoveNPC(launchVel, 8, false); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.7f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + } +} diff --git a/Projectiles/DraedonsArsenal/ShrimpBody.png b/Projectiles/DraedonsArsenal/ShrimpBody.png new file mode 100644 index 0000000000..6a9768e1f1 Binary files /dev/null and b/Projectiles/DraedonsArsenal/ShrimpBody.png differ diff --git a/Projectiles/DraedonsArsenal/ShrimpBodyGlow.png b/Projectiles/DraedonsArsenal/ShrimpBodyGlow.png new file mode 100644 index 0000000000..5ddf245160 Binary files /dev/null and b/Projectiles/DraedonsArsenal/ShrimpBodyGlow.png differ diff --git a/Projectiles/DraedonsArsenal/ShrimpPlasmaMissile.cs b/Projectiles/DraedonsArsenal/ShrimpPlasmaMissile.cs new file mode 100644 index 0000000000..ff1bf55236 --- /dev/null +++ b/Projectiles/DraedonsArsenal/ShrimpPlasmaMissile.cs @@ -0,0 +1,181 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class ShrimpPlasmaMissile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float time => ref Projectile.ai[0]; + public NPC closestNPC; + public Vector2 offset = Vector2.Zero; + public bool hitTile = false; + public float randomRate = 0; + public float randomSize = 0; + public override void SetStaticDefaults() + { + //ProjectileID.Sets.SummonTagDamageMultiplier[Type] = 0f; // The balance people will say if this is needed + } + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Summon; + Projectile.timeLeft = 300; + Projectile.extraUpdates = 3; + Projectile.penetrate = -1; + Projectile.ArmorPenetration = 15; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + if (time == 0) + { + randomRate = Main.rand.NextFloat(1, 3); + randomSize = Main.rand.NextFloat(1, 5); + } + float sine = (float)Math.Sin(time * 0.075f / MathHelper.Pi * randomRate); + + if (time > 0 && Projectile.numHits == 0) + { + if (Utils.Distance(Owner.Center, Projectile.Center) < 1400) + { + Particle spark = new CustomSpark(Projectile.Center, Projectile.velocity * -0.01f, "CalamityMod/Particles/BloomCircle", false, 12, 0.18f, Effects.ArsenalEffects.ArsenalPlasmaColor, new Vector2(0.3f, 1), true, true, 0, false, false, 0.3f, glowCenterScale: 0.5f); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Projectile.ai[2] == 0) + { + if (time > 10) + { + if (closestNPC == null || closestNPC.life <= 0 || !closestNPC.CanBeChasedBy()) + closestNPC = Projectile.Center.ClosestNPCAt(900); + if (closestNPC != null) + { + Projectile.timeLeft++; + float distMult = ((float)Math.Pow(Utils.GetLerpValue(140, 80, Projectile.Center.Distance(closestNPC.Center), true), 3)); + CalamityUtils.HomeInOnSelectedNPC(Projectile, closestNPC, true, 0.2f + 0.3f * distMult, 8, 0.99f - 0.1f * distMult, accelerate: true); + } + } + } + else + { + Vector2 goalPosition = Owner.Calamity().mouseWorld + offset; + int fallTime = 300 - (int)Projectile.ai[2] * Projectile.extraUpdates; + offset = Vector2.UnitX * sine * 15 * randomSize; + if (time == fallTime) + { + Projectile.timeLeft = 600; + Projectile.extraUpdates = 6; + Projectile.scale = 1.5f; + } + if (time > fallTime) + { + float distMult = (float)Math.Pow(Utils.GetLerpValue(480, 340, time, true), 3); + + Vector2 moveTo = (goalPosition - Projectile.Center).SafeNormalize(Vector2.UnitX); + + if (Projectile.velocity.Y < 8) + Projectile.velocity.Y += 0.1f; + Projectile.velocity.X += moveTo.X * 0.5f; + Projectile.velocity.X *= 0.975f; + } + else + Projectile.timeLeft++; + } + + if (Main.rand.NextBool(5)) + { + int dustStyle = Effects.ArsenalEffects.ArsenalPlasmaDust; + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust.scale = Main.rand.NextFloat(0.5f, 0.7f); + dust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.3f); + dust.noGravity = false; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = -0.2f; + } + } + if (Collision.SolidCollision(Projectile.Center, 8, 8) && Projectile.numHits == 0 && Projectile.ai[2] > 0 && Projectile.Center.Y > Owner.Calamity().mouseWorld.Y && Projectile.scale > 1) + { + hitTile = true; + Projectile.numHits = 1; + Explode(); + } + time++; + } + public void Explode() + { + float lifetimeMult = (hitTile ? 5 : 1); + if (hitTile) + Projectile.localNPCHitCooldown = 8; + Projectile.extraUpdates = 0; + Projectile.timeLeft = (int)(12 * lifetimeMult); + Projectile.velocity = Vector2.Zero; + for (int i = 0; i < (int)(12 * Projectile.scale); i++) + { + bool noFall = !Main.rand.NextBool(5); + int dustStyle = noFall ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalPlasmaDust; + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust.scale = Main.rand.NextFloat(0.9f, 1.7f) * (noFall ? 2 : 0.75f) * Projectile.scale; + dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(6.4f, 7.5f) * (noFall ? 0.7f : 1.2f) * Projectile.scale; + dust.noGravity = noFall; + dust.color = Effects.ArsenalEffects.ArsenalPlasmaColor; + dust.fadeIn = (noFall ? 4.5f * Projectile.scale : 1f); + } + SoundEngine.PlaySound(AqueousHunterDrone.Hit with { Volume = 0.4f * Projectile.scale, Pitch = Main.rand.NextFloat(-0.1f, 0.1f), MaxInstances = 30 }, Projectile.Center); + Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalPlasmaColor * 0.95f, "CalamityMod/Particles/SmokeExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.1f * Projectile.scale, 14); + GeneralParticleHandler.SpawnParticle(bolt2); + + Particle bolt3 = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalPlasmaColor * 0.75f, "CalamityMod/Particles/WaterFoam", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.77f * Projectile.scale, (int)(10 * lifetimeMult)); + GeneralParticleHandler.SpawnParticle(bolt3); + + Particle spark = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, (int)(17 * lifetimeMult), 0.6f * Projectile.scale, Effects.ArsenalEffects.ArsenalPlasmaColor, new Vector2(1, 1), true, true, 0, false, false); + GeneralParticleHandler.SpawnParticle(spark); + if (hitTile) + { + Particle spark2 = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, (int)(20 * lifetimeMult), 0.6f * Projectile.scale * lifetimeMult, Effects.ArsenalEffects.ArsenalPlasmaColor * 0.35f, new Vector2(1, 1), true, true, 0, false, false, glowOpacity: 0.35f); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (Projectile.scale > 1) + { + Player Owner = Main.player[Projectile.owner]; + Owner.SetScreenshake(2.5f); + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.numHits == 0) + { + Explode(); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + { + float minMult = 0.5f; + int hitsToMinMult = 8; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult * 0.5f; + } + } + public override bool? CanDamage() => ((time > 5 && Projectile.ai[2] == 0) || (Projectile.scale > 1)) ? null : false; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * (Projectile.numHits > 0 ? 10 : 1) * Projectile.scale, targetHitbox); + } + public override bool PreDraw(ref Color lightColor) + { + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/ShrimpTail.png b/Projectiles/DraedonsArsenal/ShrimpTail.png new file mode 100644 index 0000000000..ea5481c028 Binary files /dev/null and b/Projectiles/DraedonsArsenal/ShrimpTail.png differ diff --git a/Projectiles/DraedonsArsenal/ShrimpTailGlow.png b/Projectiles/DraedonsArsenal/ShrimpTailGlow.png new file mode 100644 index 0000000000..0d7d5e8d71 Binary files /dev/null and b/Projectiles/DraedonsArsenal/ShrimpTailGlow.png differ diff --git a/Projectiles/DraedonsArsenal/SnakeEyesProjectile.cs b/Projectiles/DraedonsArsenal/SnakeEyesProjectile.cs index 45174b4fd5..c46623b587 100644 --- a/Projectiles/DraedonsArsenal/SnakeEyesProjectile.cs +++ b/Projectiles/DraedonsArsenal/SnakeEyesProjectile.cs @@ -148,7 +148,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal #region Shader Trail Methods - private float PrimitiveWidthFunction(float completionRatio) + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float arrowheadCutoff = 0.36f; float width = 39f; @@ -159,7 +159,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal return width; } - private Color PrimitiveColorFunction(float completionRatio) + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float endFadeRatio = 0.41f; @@ -186,8 +186,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 origin = frame.Size() * 0.5f; Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 92); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 92); return false; } } diff --git a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs index fc95a46d89..e9a7232cdd 100644 --- a/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs +++ b/Projectiles/DraedonsArsenal/SnakeEyesSummon.cs @@ -42,6 +42,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -237,8 +238,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void OnSpawn(IEntitySource source) => DoVFXPulse(); - public override bool? CanDamage() => false; - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/DraedonsArsenal/StarSwallowerAcid.cs b/Projectiles/DraedonsArsenal/StarSwallowerAcid.cs deleted file mode 100644 index 5d981f5dc8..0000000000 --- a/Projectiles/DraedonsArsenal/StarSwallowerAcid.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class StarSwallowerAcid : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/Environment/AcidDrop"; - - public const float Gravity = 0.25f; - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionShot[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 5; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.tileCollide = true; - Projectile.ignoreWater = false; - Projectile.timeLeft = 300; - Projectile.alpha = 255; - Projectile.DamageType = DamageClass.Summon; - } - public override void AI() - { - if (Projectile.velocity.Y <= 10f) - { - Projectile.velocity.Y += Gravity; - } - Projectile.ai[0]++; - if (Projectile.ai[0] < 10) - { - Projectile.alpha = (int)MathHelper.Lerp(255, 0, Projectile.ai[0] / 10f); - } - Projectile.tileCollide = Projectile.timeLeft <= 260; - Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - // Water drip - for (int i = 0; i < 4; i++) - { - int idx = Dust.NewDust(Projectile.position - Projectile.velocity, 2, 2, DustID.Rain, 0f, 0f, 0, new Color(112, 150, 42, 127), 1f); - Dust dust = Main.dust[idx]; - dust.position.X -= 2f; - Main.dust[idx].alpha = 38; - Main.dust[idx].velocity *= 0.1f; - Main.dust[idx].velocity -= Projectile.velocity * 0.025f; - Main.dust[idx].scale = 2f; - } - return true; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], new Color(255, 255, 255, 127) * Projectile.Opacity, 2); - return false; - } - } -} diff --git a/Projectiles/DraedonsArsenal/StarSwallowerAcid.png b/Projectiles/DraedonsArsenal/StarSwallowerAcid.png deleted file mode 100644 index f5e4db998f..0000000000 Binary files a/Projectiles/DraedonsArsenal/StarSwallowerAcid.png and /dev/null differ diff --git a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs deleted file mode 100644 index 526dcb0227..0000000000 --- a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs +++ /dev/null @@ -1,298 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.Summon; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.WorldBuilding; -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class StarSwallowerSummon : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public bool FlyUntilNearPlayer; - public float HopCooldown = 0f; - public float AcidShootTimer = 0f; - public float AcidShootCooldown = 0f; - public float FallThroughYPoint = 0f; - - public bool ReleasingAcid - { - get => Projectile.ai[0] != 0f; - set => Projectile.ai[0] = value.ToInt(); - } - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 12; - ProjectileID.Sets.MinionSacrificable[Type] = true; - ProjectileID.Sets.MinionTargettingFeature[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 38; - Projectile.height = 30; - Projectile.minionSlots = 1f; - Projectile.timeLeft = 18000; - Projectile.ignoreWater = true; - Projectile.tileCollide = true; - Projectile.minion = true; - Projectile.timeLeft *= 5; - Projectile.penetrate = -1; - Projectile.DamageType = DamageClass.Summon; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(HopCooldown); - writer.Write(FlyUntilNearPlayer); - writer.Write(AcidShootTimer); - writer.Write(AcidShootCooldown); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - HopCooldown = reader.ReadSingle(); - FlyUntilNearPlayer = reader.ReadBoolean(); - AcidShootTimer = reader.ReadSingle(); - AcidShootCooldown = reader.ReadSingle(); - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - - bool isCorrectProjectile = Projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (isCorrectProjectile) - { - if (player.dead) - { - player.Calamity().starSwallowerPetFroge = false; - } - if (player.Calamity().starSwallowerPetFroge) - { - Projectile.timeLeft = 2; - } - } - - int minimumFrame = 0; - int maximumFrame = 11; - - if (Projectile.velocity == Vector2.Zero) - { - minimumFrame = maximumFrame = 0; - } - - if (HopCooldown > 0) - { - if (Projectile.velocity.Length() > 8f) - { - minimumFrame = maximumFrame = 1; - if (Math.Abs(Projectile.oldPosition.Y - Projectile.position.Y) < 5.5f) - minimumFrame = maximumFrame = 0; - } - else if (HopCooldown < 6) - { - minimumFrame = maximumFrame = 2; - } - else if (HopCooldown < 12) - { - minimumFrame = maximumFrame = 3; - } - else if (HopCooldown < 21) - { - minimumFrame = maximumFrame = 4; - } - else - { - minimumFrame = maximumFrame = 5; - } - } - - // Gravity effect. - Projectile.velocity.Y = MathHelper.Clamp(Projectile.velocity.Y + 0.4f, -11f, 11f); - - Projectile.tileCollide = !FlyUntilNearPlayer; - - ReleasingAcid = false; - - // Remember, && doesn't evaluate future statements if the statement it just evaluated is true. - // This means that null problems should never happen, since it wouldn't pass the potentialTarget != null check. - NPC potentialTarget = Projectile.Center.MinionHoming(800f, player); - if (potentialTarget != null && - Math.Abs(potentialTarget.Center.X - Projectile.Center.X) < 320f && - Math.Sign(potentialTarget.Center.Y - Projectile.Center.Y) == -1 && - Math.Abs(potentialTarget.Center.Y - Projectile.Center.Y) < 160f && - Math.Sign(potentialTarget.Center.Y - Projectile.Center.Y) == -1 && - !FlyUntilNearPlayer) - { - FallThroughYPoint = potentialTarget.Top.Y; - NPCTargetingAI(potentialTarget); - } - else - { - PlayerSeparationAnxietyAI(player, ref minimumFrame, ref maximumFrame); - FallThroughYPoint = player.Top.Y; - } - - Projectile.MinionAntiClump(); - ManipulateFrames(minimumFrame, maximumFrame); - } - - public void HandleHop(Vector2 targetPosition) - { - if (HopCooldown <= 0f && Projectile.oldPosition.Y == Projectile.position.Y) - { - float hopXMult = Utils.GetLerpValue(50f, 500f, targetPosition.X - Projectile.Center.X, true); - float hopYMult = Utils.GetLerpValue(40f, 300f, targetPosition.Y - Projectile.Center.Y, true); - float hopSpeedX = MathHelper.Lerp(4f, 17f, hopXMult) * Math.Sign(targetPosition.X - Projectile.Center.X); - float hopSpeedY = -1 * MathHelper.Lerp(8f, 23f, hopYMult); - - Vector2 velocity = new Vector2(hopSpeedX, hopSpeedY); - - Projectile.velocity = velocity; - Projectile.spriteDirection = (Projectile.velocity.X > 0).ToDirectionInt(); - HopCooldown = 25f; - } - else - { - Projectile.velocity.X *= 0.935f; - HopCooldown--; - } - } - - public void PlayerSeparationAnxietyAI(Player player, ref int minimumFrame, ref int maximumFrame) - { - // If the player is extremely far away, don't bother homing. Just go to the player's location. - if (Projectile.Distance(player.Center) > 1900f) - { - Projectile.Center = player.Center; - Projectile.netUpdate = true; - return; - } - Vector2 returnPosition = Projectile.Center; - returnPosition.Y -= 200 * 16; - returnPosition.Y = MathHelper.Clamp(returnPosition.Y, 50, Main.maxTilesX * 16 - 50); - - bool noGround = !WorldUtils.Find(returnPosition.ToTileCoordinates(), Searches.Chain(new Searches.Down(400), new GenCondition[] - { - new Conditions.IsSolid() - }), out _); - - if (Projectile.Distance(player.Center) > 1200f) - { - FlyUntilNearPlayer = true; - Projectile.netUpdate = true; - } - if (Projectile.Distance(player.Center) < 120f && - FlyUntilNearPlayer && - !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) - { - FlyUntilNearPlayer = false; - Projectile.netUpdate = true; - } - - bool flying = noGround || FlyUntilNearPlayer; - - // Fly to player. - if (flying) - { - minimumFrame = 7; - maximumFrame = 11; - float inertia = 30f; - Projectile.velocity = (Projectile.velocity * (inertia - 1) + Projectile.SafeDirectionTo(player.Center) * 18f) / inertia; - } - // Otherwise hop around when on the ground. - else if (Projectile.oldPosition.Y == Projectile.position.Y) - { - HandleHop(player.Center); - } - } - - public void NPCTargetingAI(NPC potentialTarget) - { - HandleHop(potentialTarget.Center); - if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, potentialTarget.position, potentialTarget.width, Projectile.height) && AcidShootCooldown <= 0f) - { - AcidShootTimer++; - ReleasingAcid = AcidShootTimer >= 16 && AcidShootTimer <= 44; - - if (AcidShootTimer >= 20 && - AcidShootTimer <= 44 && - AcidShootTimer % 6 == 0 && - Main.myPlayer == Projectile.owner) - { - Vector2 spawnPosition = Projectile.Center + Vector2.UnitX * 8f * Projectile.spriteDirection; - Projectile.spriteDirection = (potentialTarget.Center.X - Projectile.Center.X > 0).ToDirectionInt(); - Vector2 fireVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(spawnPosition, potentialTarget.Center, StarSwallowerAcid.Gravity, 14f); - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPosition, - fireVelocity, - ModContent.ProjectileType(), - Projectile.damage, - Projectile.knockBack, - Projectile.owner); - SoundEngine.PlaySound(SoundID.Item13, spawnPosition); - } - if (AcidShootTimer > 48) - { - AcidShootTimer = 0; - AcidShootCooldown = 10f; - Projectile.netUpdate = true; - } - } - else if (AcidShootCooldown > 0f) - AcidShootCooldown--; - Projectile.velocity.X *= 0.8f; - } - - public void ManipulateFrames(int minimumFrame, int maximumFrame) - { - if (Projectile.frame < minimumFrame) - { - Projectile.frame = minimumFrame; - } - Projectile.frameCounter++; - if (Projectile.frameCounter >= maximumFrame) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > maximumFrame) - { - Projectile.frame = minimumFrame; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle frame = texture.Frame(2, Main.projFrames[Type], ReleasingAcid.ToInt(), Projectile.frame); - Main.EntitySpriteDraw(texture, - Projectile.Center - Main.screenPosition, - frame, - lightColor, - Projectile.rotation, - Projectile.Size * 0.5f, - Projectile.scale, - Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, - 0); - return false; - } - - public override bool OnTileCollide(Vector2 oldVelocity) => false; - - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) - { - fallThrough = Projectile.Bottom.Y < FallThroughYPoint - 120f; - return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/DraedonsArsenal/StarSwallowerSummon.png b/Projectiles/DraedonsArsenal/StarSwallowerSummon.png deleted file mode 100644 index f8c6822514..0000000000 Binary files a/Projectiles/DraedonsArsenal/StarSwallowerSummon.png and /dev/null differ diff --git a/Projectiles/DraedonsArsenal/SystemBaneLightning.cs b/Projectiles/DraedonsArsenal/SystemBaneLightning.cs index cc55d1bebf..85178fd56f 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneLightning.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneLightning.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs index ffccae3cda..6a3bb349fb 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal @@ -43,7 +44,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // Generate idle sparks. if (Time % 15f == 0f) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 229); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Vortex); dust.velocity = Main.rand.NextVector2Circular(10f, 10f); dust.fadeIn = 1.05f; dust.noGravity = true; diff --git a/Projectiles/DraedonsArsenal/TaserExplosion.cs b/Projectiles/DraedonsArsenal/TaserExplosion.cs deleted file mode 100644 index 8cc00129fa..0000000000 --- a/Projectiles/DraedonsArsenal/TaserExplosion.cs +++ /dev/null @@ -1,47 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class TaserExplosion : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public float radius = 100; - public override void SetDefaults() - { - Projectile.width = 200; - Projectile.height = 200; - Projectile.friendly = true; - Projectile.ignoreWater = false; - Projectile.tileCollide = false; - Projectile.penetrate = -1; - Projectile.timeLeft = 2; - Projectile.DamageType = DamageClass.Ranged; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - target.AddBuff(ModContent.BuffType(), 300); - - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.8f); - if (Projectile.damage < 1) - Projectile.damage = 1; - } - - public override void AI() - { - if (Projectile.ai[0] == 0) - radius = 200; - } - - public override bool PreDraw(ref Color lightColor) - { - return false; - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, radius, targetHitbox); - } -} diff --git a/Projectiles/DraedonsArsenal/TaserHook.cs b/Projectiles/DraedonsArsenal/TaserHook.cs deleted file mode 100644 index b20aca6b8d..0000000000 --- a/Projectiles/DraedonsArsenal/TaserHook.cs +++ /dev/null @@ -1,202 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; -using Terraria; -using Terraria.Audio; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class TaserHook : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public static readonly SoundStyle Explode = new("CalamityMod/Sounds/Item/ElectricBurst") { Volume = 0.8f }; - public enum TaserAIState - { - Firing, - Electrocuting, - ReelingBack - } - - public TaserAIState AIState - { - get => (TaserAIState)(int)Projectile.ai[0]; - set => Projectile.ai[0] = (int)value; - } - - public float Time - { - get => Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - - public int ElectrocutionTarget - { - get => (int)Projectile.localAI[0]; - set => Projectile.localAI[0] = value; - } - - public const float ReelbackSpeed = 40f; - public Color hookColor = Color.SlateGray; - public SlotId Hum { get; set; } - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 10; - Projectile.friendly = true; - Projectile.penetrate = 2; - Projectile.extraUpdates = 3; - Projectile.tileCollide = true; - Projectile.ownerHitCheck = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 15; - } - - public override void AI() - { - if (AIState != TaserAIState.Firing) - Time++; - Player player = Main.player[Projectile.owner]; - hookColor = Color.Lerp(hookColor, Color.SlateGray, 0.25f); - - float distanceFromPlayer = Projectile.Distance(player.Center); - switch (AIState) - { - case TaserAIState.Firing: - if (distanceFromPlayer > 800f || Time >= 90f) - GoToAIState(TaserAIState.ReelingBack); - break; - case TaserAIState.Electrocuting: - if (distanceFromPlayer > 800f) - GoToAIState(TaserAIState.ReelingBack); - - if (SoundEngine.TryGetActiveSound(Hum, out var hum) && hum.IsPlaying) - { - hum.Position = player.Center; - hum.Pitch = MathHelper.Lerp(0f, 1f, Utils.GetLerpValue(0f, 150, Time, true)); - } - // electric explosion; - if (Time == 150 || !Main.npc[ElectrocutionTarget].active) - { - SoundEngine.PlaySound(Explode, Projectile.Center); - Projectile.localNPCHitCooldown = 15; - - for (int i = 0; i < 30; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 226, new Vector2(15, 15).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f)); - dust.scale = Main.rand.NextFloat(0.6f, 0.9f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 66, new Vector2(13, 13).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f)); - dust2.scale = Main.rand.NextFloat(0.9f, 1.4f); - dust2.noGravity = true; - dust2.color = Color.Cyan; - } - DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Cyan * 0.5f, new Vector2(1, 1), 0, 0, 3.5f, 13); - GeneralParticleHandler.SpawnParticle(pulse); - - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 5, Projectile.owner, 0); - Time = 0; - GoToAIState(TaserAIState.ReelingBack); - return; - } - if (Main.npc[ElectrocutionTarget].active) - Projectile.Center = Main.npc[ElectrocutionTarget].Center; - break; - case TaserAIState.ReelingBack: - // Kill the gun and the hook if the hook has returned to the gun. - if (SoundEngine.TryGetActiveSound(Hum, out var hum2) && hum2.IsPlaying) - { - hum2?.Stop(); - } - if (Projectile.Hitbox.Intersects(player.Hitbox)) - { - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = 0.5f, Pitch = 0.3f }, Projectile.Center); - Projectile.Kill(); - return; - } - Projectile.tileCollide = false; - Projectile.extraUpdates = 5; - Projectile.velocity = Projectile.SafeDirectionTo(player.Center) * (ReelbackSpeed / Projectile.extraUpdates); - break; - } - - Projectile.rotation = Projectile.AngleFrom(player.Center); - - ManipulatePlayerItemValues(player); - } - - - public void ManipulatePlayerItemValues(Player player) - { - player.ChangeDir((player.Center.X - Projectile.Center.X < 0).ToDirectionInt()); - player.itemRotation = CalamityUtils.WrapAngle90Degrees(Projectile.rotation); - player.itemTime = 4; - player.itemAnimation = 4; - } - - public void GoToAIState(TaserAIState newAIState) - { - // Don't waste the resources changing the AI state if the projectile is already in said state. - if (AIState == newAIState) - return; - - Projectile.penetrate = -1; - AIState = newAIState; - Projectile.netUpdate = true; - } - - public override bool PreDraw(ref Color lightColor) - { - Player player = Main.player[Projectile.owner]; - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Utils.DrawLine(Main.spriteBatch, player.MountedCenter, Projectile.Center, hookColor, hookColor, 3); - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - Projectile.tileCollide = false; - if (Projectile.localNPCHitCooldown > 7 && target == Main.npc[ElectrocutionTarget]) - Projectile.localNPCHitCooldown -= 1; - hookColor = Color.Cyan; - target.AddBuff(ModContent.BuffType(), 120); - - if (AIState == TaserAIState.Firing) - { - Projectile.Center = target.Center; - Projectile.extraUpdates = 0; - if (!Main.dedServ) - { - for (int i = 0; i < 50; i++) - { - float angle = MathHelper.TwoPi / 50f * i + Utils.GetLerpValue(90f, 150f, Time, true) * MathHelper.ToRadians(1080f); - Dust dust = Dust.NewDustPerfect(target.Center + angle.ToRotationVector2() * 10f, 226); - dust.velocity = Vector2.Zero; - if (Main.rand.NextBool(6)) - dust.velocity = target.SafeDirectionTo(dust.position) * 4.5f; - - dust.noGravity = true; - } - } - ElectrocutionTarget = target.whoAmI; - Time = 0f; - - SoundStyle charge = new("CalamityMod/Sounds/Item/LowHum"); - Hum = SoundEngine.PlaySound(charge with { Volume = 1.6f, IsLooped = true }, Projectile.Center); - - GoToAIState(TaserAIState.Electrocuting); - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - GoToAIState(TaserAIState.ReelingBack); - return false; - } - } -} diff --git a/Projectiles/DraedonsArsenal/TrackingDiskLaser.cs b/Projectiles/DraedonsArsenal/TrackingDiskLaser.cs deleted file mode 100644 index 09f57b62a9..0000000000 --- a/Projectiles/DraedonsArsenal/TrackingDiskLaser.cs +++ /dev/null @@ -1,98 +0,0 @@ -using CalamityMod.Particles; -using Terraria; -using Terraria.ModLoader; -using Microsoft.Xna.Framework; -using CalamityMod.NPCs; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class TrackingDiskLaser : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public float Time - { - get => Projectile.localAI[0]; - set => Projectile.localAI[0] = value; - } - public override void SetDefaults() - { - Projectile.width = 2; - Projectile.height = 2; - Projectile.friendly = true; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.tileCollide = false; - Projectile.penetrate = 1; - Projectile.extraUpdates = 100; - Projectile.timeLeft = 600; - Projectile.ArmorPenetration = 10; - } - - public override void AI() - { - Player Owner = Main.player[Projectile.owner]; - float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - Time++; - if (Time == 1) - { - for (int i = 0; i < 7; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 267); - dust.velocity = (Projectile.velocity * 3).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.3f, 1f); - dust.scale = Main.rand.NextFloat(0.6f, 0.8f); - dust.noGravity = true; - dust.color = Color.Red; - } - } - if (Time >= 15f) - { - if (Projectile.timeLeft % 11 == 0 && targetDist < 1400) - { - Particle spark = new LineParticle(Projectile.Center - Projectile.velocity * 10, -Projectile.velocity * 0.01f, false, 4, 1.5f * Projectile.scale, Color.Red); - GeneralParticleHandler.SpawnParticle(spark); - } - if (Projectile.timeLeft % 2 == 0 && targetDist < 1400) - { - Particle spark2 = new LineParticle(Projectile.Center - Projectile.velocity * 10, -Projectile.velocity * 0.01f, false, 4, 0.35f * Projectile.scale, Color.White); - GeneralParticleHandler.SpawnParticle(spark2); - } - } - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - // Handles giving the NPC the laser burn effect - CalamityGlobalNPC modNPC = target.Calamity(); - if (!modNPC.laserBurnMarked) - { - modNPC.laserBurnMarked = true; - modNPC.laserBurnType = 1; - modNPC.laserBurnTimer = CalamityGlobalNPC.laserBurnTime; - } - - modNPC.laserBurnTimer -= modNPC.laserBurnStacks * 2; - modNPC.laserBurnDamage += (int)(Projectile.damage * 0.2f); - - modNPC.laserBurnStacks++; - - if (Projectile.scale == 1) - { - Projectile.damage = 1; - modifiers.HideCombatText(); - } - else - modifiers.SourceDamage *= 0.15f; - } - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 7; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 267); - dust.velocity = (Projectile.velocity * 3 * Projectile.scale).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 1f); - dust.scale = Main.rand.NextFloat(0.4f, 0.7f) * Projectile.scale; - dust.noGravity = true; - dust.color = Color.Red; - } - } - } -} diff --git a/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs b/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs deleted file mode 100644 index 75c41be684..0000000000 --- a/Projectiles/DraedonsArsenal/TrackingDiskProjectile.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.DraedonsArsenal -{ - public class TrackingDiskProjectile : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Items/Weapons/DraedonsArsenal/TrackingDisk"; - public NPC extraShotTarget; - - public bool ReturningToPlayer - { - get => Projectile.ai[0] == 1f; - set => Projectile.ai[0] = value.ToInt(); - } - - public float Time - { - get => Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - - public const int LaserFireRate = 19; - public const int LaserFireRateStealth = 15; - public const int MaxLaserCountPerShot = 2; // This only applies to stealth strikes. - public const float MaxTargetSearchDistance = 600f; - public const float MaxTargetSearchStealth = 800f; - public const float ReturnAccelerationFactor = 0.0012f; - public const float ReturnMaxSpeed = 6f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 7; - ProjectileID.Sets.TrailingMode[Type] = 2; - } - - public override void SetDefaults() - { - Projectile.width = 58; - Projectile.height = 48; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.extraUpdates = 2; - Projectile.tileCollide = false; - Projectile.DamageType = RogueDamageClass.Instance; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.4f); - - Player player = Main.player[Projectile.owner]; - - Time++; - - if (Time == 5) - Projectile.tileCollide = true; - - if (!ReturningToPlayer) - { - if (Time >= 55f) - { - ReturningToPlayer = true; - Projectile.tileCollide = false; - Projectile.netUpdate = true; - } - } - else - { - float distanceFromPlayer = Projectile.Distance(player.Center); - if (distanceFromPlayer > 3000f) - Projectile.Kill(); - - // 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 * ReturnMaxSpeed * (Projectile.Calamity().stealthStrike ? Utils.GetLerpValue(90, 300, Time, true) * 1.5f : Utils.GetLerpValue(60, 300, Time, true)); - - Projectile.velocity.X += Math.Sign(idealVelocity.X - Projectile.velocity.X) * (ReturnAccelerationFactor * Time); - Projectile.velocity.Y += Math.Sign(idealVelocity.Y - Projectile.velocity.Y) * (ReturnAccelerationFactor * Time); - - if (Time % (Projectile.Calamity().stealthStrike ? LaserFireRateStealth : LaserFireRate) == 0f) - AttemptToFireLasers(Projectile.damage); - - if (Main.myPlayer == Projectile.owner) - { - if (Projectile.Hitbox.Intersects(player.Hitbox)) - Projectile.Kill(); - } - } - - if (ReturningToPlayer) - { - Projectile.rotation += 0.28f * Utils.GetLerpValue(30, 300, Time, true); - } - else - Projectile.rotation += 0.15f; - } - - public void AttemptToFireLasers(int damage) - { - if (Main.myPlayer != Projectile.owner) - return; - if (Projectile.Calamity().stealthStrike) - { - int targetCount = 0; - List targets = Main.npc.Where(npc => - { - return npc.active && Projectile.Distance(npc.Center) < MaxTargetSearchStealth && npc.CanBeChasedBy(); - }).ToList(); - foreach (var target in targets) - { - if (targetCount >= MaxLaserCountPerShot) - break; - Vector2 spawnLocation = Projectile.Center + new Vector2(25, 0).RotatedBy(Projectile.rotation * Utils.GetLerpValue(300, 30, Time, true)); - Projectile laser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), spawnLocation, - (spawnLocation - target.Center).SafeNormalize(Vector2.UnitX) * -3f, - ModContent.ProjectileType(), - (int)(damage), - Projectile.knockBack, - Projectile.owner, - 1f); - laser.scale *= 1.6f; - laser.netUpdate = true; - targetCount++; - extraShotTarget = target; - } - if (targetCount == 1) - { - Vector2 spawnLocation = Projectile.Center + new Vector2(25, 0).RotatedBy(-Projectile.rotation * Utils.GetLerpValue(300, 30, Time, true)); - Projectile laser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), spawnLocation, - (spawnLocation - extraShotTarget.Center).SafeNormalize(Vector2.UnitX) * -3f, - ModContent.ProjectileType(), - (int)(damage), - Projectile.knockBack, - Projectile.owner, - 1f); - } - } - else - { - NPC potentialTarget = Projectile.Center.ClosestNPCAt(MaxTargetSearchDistance); - if (potentialTarget != null) - { - Vector2 spawnLocation = Projectile.Center + new Vector2(25, 0).RotatedBy(Projectile.rotation * 0.4f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnLocation, (spawnLocation - potentialTarget.Center).SafeNormalize(Vector2.UnitX) * -3f, ModContent.ProjectileType(), damage, Projectile.knockBack, Projectile.owner); - } - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - ReturningToPlayer = true; - Projectile.tileCollide = false; - Projectile.netUpdate = true; - 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 PreDraw(ref Color lightColor) - { - Asset texture = ModContent.Request(Texture); - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Vector2 rotationPoint = texture.Size() * 0.5f; - Vector2 origin = texture.Size() * 0.5f; - - Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, ProjectileID.Sets.TrailCacheLength[Projectile.type], null, true, false); - // Glow Orb - Main.EntitySpriteDraw(rechargeTexture, drawPosition, null, Color.Red with { A = 0 } * 0.65f, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.4f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(rechargeTexture, drawPosition, null, Color.White with { A = 0 } * 0.35f, Projectile.rotation, rechargeTexture.Size() * 0.5f, 0.2f, SpriteEffects.None, 0); - - Main.EntitySpriteDraw(texture.Value, drawPosition, null, lightColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); - - return false; - } - } -} diff --git a/Projectiles/DraedonsArsenal/VoltageStream.cs b/Projectiles/DraedonsArsenal/VoltageStream.cs index 486c6edd18..cfee657f48 100644 --- a/Projectiles/DraedonsArsenal/VoltageStream.cs +++ b/Projectiles/DraedonsArsenal/VoltageStream.cs @@ -56,13 +56,13 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 dustSpawnPosition = dustInitialPosition + angularOffset.ToRotationVector2() * 4f; dustSpawnPosition.X += 10f * (float)Math.Sin(completionRatio * MathHelper.ToRadians(360f)); - Dust dust = Dust.NewDustPerfect(dustSpawnPosition, 261); + Dust dust = Dust.NewDustPerfect(dustSpawnPosition, DustID.AncientLight); dust.velocity = Vector2.Zero; dust.noGravity = true; dustSpawnPosition = dustInitialPosition + angularOffset.ToRotationVector2() * 4f; dustSpawnPosition.X -= 10f * (float)Math.Sin(completionRatio * MathHelper.ToRadians(360f)); - dust = Dust.NewDustPerfect(dustSpawnPosition, 261); + dust = Dust.NewDustPerfect(dustSpawnPosition, DustID.AncientLight); dust.velocity = Vector2.Zero; dust.noGravity = true; } @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { float angle = MathHelper.TwoPi / 50f * i + Utils.GetLerpValue(90f, 150f, Time, true) * MathHelper.ToRadians(1080f); float radius = MathHelper.Lerp(0f, 25f, Utils.GetLerpValue(90f, 150f, Time, true)); - Dust dust = Dust.NewDustPerfect(Target.Center + angle.ToRotationVector2() * radius, 226); + Dust dust = Dust.NewDustPerfect(Target.Center + angle.ToRotationVector2() * radius, DustID.Electric); dust.velocity = Vector2.Zero; if (Main.rand.NextBool(6)) dust.velocity = Target.SafeDirectionTo(dust.position) * 4.5f; @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal for (int i = 0; i < 120; i++) { float angle = MathHelper.TwoPi / 120f * i; - Dust dust = Dust.NewDustPerfect(Target.Center + angle.ToRotationVector2() * 25f, 226); + Dust dust = Dust.NewDustPerfect(Target.Center + angle.ToRotationVector2() * 25f, DustID.Electric); dust.velocity = angle.ToRotationVector2() * Main.rand.NextFloat(2f, 9f) * Main.rand.NextBool().ToDirectionInt(); dust.velocity = dust.velocity.RotatedBy(dust.velocity.ToRotation() * -0.02f); dust.velocity *= 2.1f; diff --git a/Projectiles/DraedonsArsenal/VulcanFlash.png b/Projectiles/DraedonsArsenal/VulcanFlash.png new file mode 100644 index 0000000000..3fc2d1e1d9 Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanFlash.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanHoldout.cs b/Projectiles/DraedonsArsenal/VulcanHoldout.cs new file mode 100644 index 0000000000..25b30502fa --- /dev/null +++ b/Projectiles/DraedonsArsenal/VulcanHoldout.cs @@ -0,0 +1,270 @@ +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class VulcanHoldout : BaseGunHoldoutProjectile + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override int AssociatedItemID => ModContent.ItemType(); + + public float offsetBase = 35; + public override float MaxOffsetLengthFromArm => offsetBase; + public override float RecoilResolveSpeed => 0.2f; + public override float OffsetXUpwards => 0f; + public override float BaseOffsetY => 0f; + public override float OffsetYDownwards => 0f; + public override float WeaponTurnSpeed => (shootingTimer < 0 ? 0 : 0.35f); + public bool firingSpear => Projectile.ai[2] == 5; + public ref float shootingTimer => ref Projectile.ai[0]; + public ref float fireRate => ref Projectile.ai[1]; + public int time = 0; + public int maxShots = 25; + public int shotsToFire = 0; + public bool playRampDown = false; + public int shotsFired = 0; + public float heatVis = 0; + public float flashVis1 = 0; + public float flashVis2 = 0; + public float spearVis = 1; + public int cooldownGiven = 180; + public bool failedManaCheck = false; + public int spearFakeCooldown = 0; + + + public override void KillHoldoutLogic() + { + + } + public override void HoldoutAI() + { + if (flashVis1 > 0) flashVis1 -= 0.2f; if (flashVis1 < 0) flashVis1 = 0; + if (flashVis2 > 0) flashVis2 -= 0.2f; if (flashVis2 < 0) flashVis2 = 0; + + if (time == 0) + { + if (Owner.Calamity().arsenalCooldown > 0) + spearVis = 0; + shootingTimer = -20; + fireRate = Owner.HeldItem.useAnimation; + shotsToFire = maxShots; + OffsetLengthFromArm = offsetBase; + } + if (shootingTimer < 0) + { + // Light cooldown after firing + if (shootingTimer == -20 || shootingTimer == -1) + { + if ((!Main.mouseLeft && !firingSpear) || failedManaCheck) + { + Projectile.Kill(); + return; + } + } + if (playRampDown) + { + SoundStyle sound = new("CalamityMod/Sounds/Item/VulcanRampDown"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(sound with { Volume = 0.9f, MaxInstances = -1 }, Projectile.Center); + playRampDown = false; + } + if (shootingTimer == -20) + { + SoundStyle sound2 = new("CalamityMod/Sounds/Item/VulcanRampUp"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(sound2 with { Volume = 0.9f, MaxInstances = -1 }, Projectile.Center); + } + if (shootingTimer == -1) + { + if (!firingSpear) + shootingTimer = fireRate; + else + shootingTimer = 0; + shotsToFire = maxShots; + fireRate = Owner.HeldItem.useAnimation; + shotsFired = 0; + playRampDown = true; + } + Projectile.velocity = Owner.Center.DirectionTo(Owner.Calamity().mouseWorld); + } + if (Owner.Calamity().mouseRight && Owner.Calamity().arsenalCooldown <= 0) + { + Projectile.ai[2] = 5; + } + if (firingSpear && time > 20 && spearFakeCooldown <= 0) + { + Shoot(true); + spearFakeCooldown = 5; + shotsToFire = maxShots; + Projectile.ai[2] = 0; + Owner.Calamity().arsenalCooldown = cooldownGiven; + Owner.AddCooldown(ArsenalPower.ID, cooldownGiven); + } + if (shootingTimer >= 0) + { + if (!Main.mouseLeft && !firingSpear) + shotsToFire = 0; + + if (!firingSpear) + { + if (shotsToFire <= 0) + shootingTimer = -50; + else if (shootingTimer >= fireRate) + { + if (Owner.CheckMana(HeldItem, -1, true, false)) + { + Shoot(false); + + if (shotsFired % 2 == 0) flashVis1 = 1; + else flashVis2 = 1; + + shootingTimer = -1; + if (shotsToFire > maxShots * 0.2f) + { + fireRate -= 1; + if (fireRate < 3) + fireRate = 3; + } + else if (fireRate < Owner.HeldItem.useAnimation) + fireRate += 1; + if (fireRate > Owner.HeldItem.useAnimation) + fireRate = Owner.HeldItem.useAnimation; + + } + else + { + failedManaCheck = true; + shotsToFire = 0; + } + + shotsToFire--; + shotsFired++; + if (shotsToFire <= 0) + { + shootingTimer = -50; + } + } + } + } + if (shotsFired > 0 && shotsToFire > 0) + { + heatVis = MathHelper.Lerp(heatVis, 1, 0.007f); + } + else + heatVis = MathHelper.Lerp(heatVis, 0, 0.085f); + + spearVis = Utils.GetLerpValue(cooldownGiven / 2, 0, Owner.Calamity().arsenalCooldown, true); + spearFakeCooldown--; + + time++; + shootingTimer++; + } + public void Shoot(bool isSpear) + { + if (isSpear) + { + Owner.SetScreenshake(3.5f); + OffsetLengthFromArm -= 16; + SoundStyle sound = new("CalamityMod/Sounds/Item/GunShotHeavy"); + SoundEngine.PlaySound(sound with { Volume = 0.8f, Pitch = 0.8f }, Projectile.Center); + if (Main.myPlayer == Projectile.owner) + { + Vector2 spearPos = GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * 12 - Projectile.velocity * 8; + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0f) * 6f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spearPos, shootVelocity, ModContent.ProjectileType(), Projectile.damage * 5, 0, Projectile.owner); + } + } + else + { + Owner.SetScreenshake(1f); + OffsetLengthFromArm -= 7; + SoundStyle sound = new("CalamityMod/Sounds/Item/VulcanShot"); + SoundEngine.PlaySound(sound with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.1f, 0), MaxInstances = 1 }, Projectile.Center); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0f) * 6f; + Vector2 position = GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * (shotsFired % 2 == 0 ? -1 : 1)) * 4; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, shootVelocity, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(position, Main.rand.NextBool(3) ? ModContent.DustType() : Effects.ArsenalEffects.ArsenalGaussDust, (shootVelocity * 4).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.7f, 1.1f)); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + } + } + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanHoldout").Value; + Texture2D glow = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanHoldoutGlow").Value; + Texture2D flash = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanFlash").Value; + Texture2D spear = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanSpear").Value; + Texture2D spearGlow = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanSpearGlow").Value; + Texture2D heat = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanHoldoutHeatedTip").Value; + if (Owner.Calamity().arsenalCooldown <= 0 && false) + { + texture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanHoldoutSpear").Value; + glow = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanHoldoutSpearGlow").Value; + } + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 vel = Projectile.rotation.ToRotationVector2(); + + float randSize = Main.rand.NextFloat(0.9f, 1f); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.direction == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + int draws = 8; + + Vector2 spearPos = GunTipPosition + vel.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * 12 - vel * 27 - Main.screenPosition; + for (int i = 0; i < draws; i++) + { + float fadeIn = Math.Min(Utils.GetLerpValue(0, 0.8f, spearVis), (float)Math.Pow(Utils.GetLerpValue(1, 0.8f, spearVis), 2)); + Vector2 offset = (MathHelper.TwoPi / draws * i).ToRotationVector2() * 6 * (1 - spearVis); + Main.EntitySpriteDraw(spear, spearPos + offset, null, Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * fadeIn * 0.5f, drawRotation, spear.Size() * 0.5f, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(spear, spearPos, null, Color.Lerp(Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 }, drawColor, spearVis) * spearVis, drawRotation, spear.Size() * 0.5f, Projectile.scale, flipSprite); + } + Main.EntitySpriteDraw(spearGlow, spearPos, null, Color.White * spearVis, drawRotation, spearGlow.Size() * 0.5f, Projectile.scale, flipSprite); + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + Main.EntitySpriteDraw(glow, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + for (int i = 0; i < draws; i++) + { + Vector2 offset = (MathHelper.TwoPi / draws * i).ToRotationVector2() * 4 * heatVis; + Main.EntitySpriteDraw(heat, drawPosition + offset, null, Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * heatVis * 0.35f, drawRotation, heat.Size() * 0.5f, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(heat, drawPosition, null, Color.White with { A = 0 } * heatVis * 0.3f, drawRotation, heat.Size() * 0.5f, Projectile.scale, flipSprite); + } + + float tipSeperation = 4; + // Tip flash 1 + if (flashVis1 > 0) + { + Vector2 position = GunTipPosition + vel * (12 + 30 * (1 - flashVis1)) + vel.RotatedBy(MathHelper.PiOver2) * tipSeperation - Main.screenPosition; + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(flash, position, null, Color.White with { A = 0 } * flashVis1, drawRotation, flash.Size() * 0.5f, new Vector2(0.5f + 2f * (1 - flashVis1), 1 - 0.8f * flashVis1) * Projectile.scale, flipSprite); + } + // Tip flash 1 + if (flashVis2 > 0) + { + Vector2 position = GunTipPosition + vel * (12 + 30 * (1 - flashVis2)) + vel.RotatedBy(-MathHelper.PiOver2) * tipSeperation - Main.screenPosition; + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(flash, position, null, Color.White with { A = 0 } * flashVis2, drawRotation, flash.Size() * 0.5f, new Vector2(0.5f + 2f * (1 - flashVis2), 1 - 0.8f * flashVis2) * Projectile.scale, flipSprite); + } + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/VulcanHoldout.png b/Projectiles/DraedonsArsenal/VulcanHoldout.png new file mode 100644 index 0000000000..3df7e215ab Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanHoldout.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanHoldoutGlow.png b/Projectiles/DraedonsArsenal/VulcanHoldoutGlow.png new file mode 100644 index 0000000000..5a1c73ba6c Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanHoldoutGlow.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanHoldoutHeatedTip.png b/Projectiles/DraedonsArsenal/VulcanHoldoutHeatedTip.png new file mode 100644 index 0000000000..a6efb3b878 Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanHoldoutHeatedTip.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanHoldoutSpear.png b/Projectiles/DraedonsArsenal/VulcanHoldoutSpear.png new file mode 100644 index 0000000000..5a4cb9de3d Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanHoldoutSpear.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanHoldoutSpearGlow.png b/Projectiles/DraedonsArsenal/VulcanHoldoutSpearGlow.png new file mode 100644 index 0000000000..3eaba56e73 Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanHoldoutSpearGlow.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanProjectile.cs b/Projectiles/DraedonsArsenal/VulcanProjectile.cs new file mode 100644 index 0000000000..8f805e1a94 --- /dev/null +++ b/Projectiles/DraedonsArsenal/VulcanProjectile.cs @@ -0,0 +1,116 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class VulcanProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public ref float time => ref Projectile.ai[0]; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.timeLeft = 720; + Projectile.extraUpdates = 8; + Projectile.penetrate = 1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 20 * Projectile.MaxUpdates; + } + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (time > 120 && Projectile.penetrate > 1) + Projectile.penetrate = 1; + + if (time > 60 && Projectile.extraUpdates > 2 && time % 4 == 0) + Projectile.extraUpdates--; + + if (Projectile.velocity.Length() < 5) + Projectile.velocity *= 1.01f; + if (targetDist < 1400) + { + if (true) + { + Particle trail = new CustomSpark(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 6, 0.15f, Effects.ArsenalEffects.ArsenalGaussColor * 0.9f, new Vector2(1f, 1f), true, true, glowCenterScale: 0.6f, glowOpacity: 0.8f, shrinkSpeed: 0.9f); + GeneralParticleHandler.SpawnParticle(trail); + } + if (time % 17 == 0) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), Effects.ArsenalEffects.ArsenalGaussDust); + dust.velocity = Vector2.One.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(0.1f, 0.2f); + dust.scale = Main.rand.NextFloat(0.7f, 0.85f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + dust.noLightEmittence = time % 9 != 0; + dust.fadeIn = 0.3f; + } + } + + time++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + impactDust(); + + Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float launchPower = 4; + target.MoveNPC(launchVel, launchPower, true); + } + + public override void OnKill(int timeLeft) + { + impactDust(); + } + public void impactDust() + { + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.1f) * Main.rand.NextFloat(9f, 19f); + dust.scale = Main.rand.NextFloat(0.6f, 0.85f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + dust.noLightEmittence = true; + } + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D proj = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanProjectile").Value; + proj = ModContent.Request("CalamityMod/Particles/SquareRotated").Value; + + Texture2D square = ModContent.Request("CalamityMod/Particles/GlowSquareParticleThick").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 vel = Projectile.rotation.ToRotationVector2(); + + Color drawColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 }; + float drawRotation = Projectile.velocity.ToRotation(); + Vector2 rotationPoint = proj.Size() * 0.5f; + + int rate = 50; + + float shrink = Utils.GetLerpValue(rate - 1, 0, time % rate); + float fade = Math.Min((float)Math.Pow(Utils.GetLerpValue(0, rate * 0.8f, time % rate, true), 3), (float)Math.Pow(Utils.GetLerpValue(rate - 1, rate * 0.8f, time % 30, true), 3)); + float speed = Utils.GetLerpValue(2, 10, Projectile.extraUpdates); + Vector2 squash = new Vector2(1 + 2 * speed, 1 - 0.3f * speed); + + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(square, drawPosition, null, drawColor * fade * (1 - speed), drawRotation + MathHelper.PiOver4, square.Size() * 0.5f, Projectile.scale * (0.05f + 0.2f * shrink), SpriteEffects.None); + + + Main.EntitySpriteDraw(proj, drawPosition, null, drawColor, drawRotation, rotationPoint, squash * Projectile.scale * 0.1f, SpriteEffects.None); + Main.EntitySpriteDraw(proj, drawPosition, null, Color.White with { A = 0 }, drawRotation, rotationPoint, squash * Projectile.scale * 0.06f, SpriteEffects.None); + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/VulcanProjectile.png b/Projectiles/DraedonsArsenal/VulcanProjectile.png new file mode 100644 index 0000000000..f5adc1fd7f Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanProjectile.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanSpear.cs b/Projectiles/DraedonsArsenal/VulcanSpear.cs new file mode 100644 index 0000000000..55707121f9 --- /dev/null +++ b/Projectiles/DraedonsArsenal/VulcanSpear.cs @@ -0,0 +1,199 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class VulcanSpear : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public ref float time => ref Projectile.ai[0]; + + public NPC targeted; + public bool stuckInGround = false; + public bool canDamage => (targeted == null && !stuckInGround); + public bool canStick = true; + public int stuckTimer = 420; + public Vector2 placementCenter; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 35; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.timeLeft = 1200; + Projectile.extraUpdates = 30; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + + Lighting.AddLight(Projectile.Center, Effects.ArsenalEffects.ArsenalGaussColor.ToVector3() * 0.5f); + if (targetDist < 1400 && canDamage) + { + if (time % 2 == 0) + { + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 14, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 12, 0.065f, Effects.ArsenalEffects.ArsenalGaussColor, new Vector2(1f, 2.5f), true, true, glowCenterScale: 0.7f, shrinkSpeed: 0.4f); + GeneralParticleHandler.SpawnParticle(trail); + } + } + + if (!stuckInGround && targeted == null && Collision.SolidCollision(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15, 6, 6)) + { + Projectile.extraUpdates = 0; + stuckInGround = true; + SoundStyle hitTile = new("CalamityMod/Sounds/NPCHit/ExoHit3"); + SoundEngine.PlaySound(hitTile with { Volume = 0.8f, Pitch = Main.rand.NextFloat(0.1f, 0.2f) }, Projectile.Center); + //Get stuck in the ground and fade + } + if (targeted != null && (!targeted.active || targeted.life <= 0)) + targeted = null; + if (targeted != null) + { + Projectile.Center = targeted.Center - placementCenter; + } + else if (Projectile.numHits > 0) + { + Projectile.timeLeft = 1; + } + if (stuckInGround || targeted != null) + { + foreach (Projectile p in Main.ActiveProjectiles) + { + float dist = Utils.Distance(Projectile.Center, p.Center); + if (p.type == ModContent.ProjectileType() && dist <= 900 && p.ai[0] > 120) + { + if (p.velocity.Length() < 6) + p.velocity += p.Center.DirectionTo(Projectile.Center) * Utils.GetLerpValue(1500, 50, dist) * 0.9f; + else + p.velocity *= 0.9f; + if (p.ai[0] % 2 == 0) + p.timeLeft += p.MaxUpdates; + } + } + } + if (!canDamage && Projectile.timeLeft > 300) + Projectile.timeLeft = 300; + time++; + if (Projectile.timeLeft == 35) + { + SoundStyle sound2 = new("CalamityMod/Sounds/Item/VulcanRampUp"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(sound2 with { Volume = 0.9f, MaxInstances = 5, Pitch = -0.4f }, Projectile.Center); + } + } + public override void OnKill(int timeLeft) + { + SoundStyle die = new("CalamityMod/Sounds/NPCHit/ExoHit2"); + SoundEngine.PlaySound(die with { Volume = 0.8f, Pitch = Main.rand.NextFloat(0.4f, 0.5f), MaxInstances = 5 }, Projectile.Center); + SoundStyle sound2 = new("CalamityMod/Sounds/Item/NidhoggFire"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(sound2 with { Volume = 0.8f, MaxInstances = 5, Pitch = -0.1f }, Projectile.Center); + foreach (Projectile p in Main.ActiveProjectiles) + { + float dist = Utils.Distance(Projectile.Center, p.Center); + if (p.type == ModContent.ProjectileType() && dist <= 500) + { + NPC closeTarget = p.Center.ClosestNPCAt(800); + if (closeTarget != null) + p.velocity = p.Center.DirectionTo(closeTarget.Center) * 7; + else + p.velocity = Projectile.Center.DirectionTo(p.Center) * 7; + p.extraUpdates = 8; + p.ai[0] = 0; + p.penetrate = 5; + if (p.ai[1] < 4) // Pretty much just so gfb can't oneshot everything + { + p.damage = (int)(p.damage * 2f); + p.ai[1]++; + } + p.timeLeft = Main.rand.Next(100, 120 + 1); + } + } + Particle bolt = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalGaussColor, "CalamityMod/Particles/GlowSquareParticleThick", Vector2.One, MathHelper.PiOver4, 0.1f, 0.7f, 15); + GeneralParticleHandler.SpawnParticle(bolt); + Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Effects.ArsenalEffects.ArsenalGaussColor, "CalamityMod/Particles/GlowSquareParticleBig", Vector2.One, 0, 0.3f, 1.15f, 10); + GeneralParticleHandler.SpawnParticle(bolt2); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + impactDust(); + + Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + float launchPower = 12; + target.MoveNPC(launchVel, launchPower, true); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (target.life <= 0 && target.realLife == -1) + { + // Don't stick into dead enemies + Projectile.numHits--; + } + else if (targeted == null && !stuckInGround) + { + //Stick + Projectile.extraUpdates = 0; + SoundStyle hitTile = new("CalamityMod/Sounds/NPCHit/ExoHit1"); + SoundEngine.PlaySound(hitTile with { Volume = 0.8f, Pitch = Main.rand.NextFloat(0.1f, 0.2f) }, Projectile.Center); + targeted = target; + placementCenter = targeted.Center - Projectile.Center; + } + } + public override bool? CanDamage() => canDamage ? null : false; + public override bool ShouldUpdatePosition() + { + return canDamage; + } + public void impactDust() + { + for (int i = 0; i < 7; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.15f) * Main.rand.NextFloat(12f, 19f); + dust.scale = Main.rand.NextFloat(0.8f, 1.35f); + dust.noGravity = true; + dust.color = Effects.ArsenalEffects.ArsenalGaussColor; + dust.noLightEmittence = true; + } + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D proj = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanSpear").Value; + Texture2D glow = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/VulcanSpearGlow").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 vel = Projectile.rotation.ToRotationVector2(); + + Color drawColor = Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 }; + float drawRotation = Projectile.velocity.ToRotation() + (Projectile.direction == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = proj.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(proj, drawPosition, null, lightColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(glow, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + int draws = 16; + for (int i = 0; i < draws; i++) + { + float fadeIn = (float)Math.Pow(Utils.GetLerpValue(300, 1, Projectile.timeLeft, true), 3); + Vector2 offset = (MathHelper.TwoPi / draws * i).ToRotationVector2() * 3 * fadeIn; + Main.EntitySpriteDraw(proj, Projectile.Center - Main.screenPosition + offset + Main.rand.NextVector2Circular(3, 3) * fadeIn, null, Effects.ArsenalEffects.ArsenalGaussColor with { A = 0 } * fadeIn * 0.5f, drawRotation, proj.Size() * 0.5f, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(proj, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * fadeIn, drawRotation, proj.Size() * 0.5f, Projectile.scale, flipSprite); + } + + return false; + } + } +} diff --git a/Projectiles/DraedonsArsenal/VulcanSpear.png b/Projectiles/DraedonsArsenal/VulcanSpear.png new file mode 100644 index 0000000000..cfcab36090 Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanSpear.png differ diff --git a/Projectiles/DraedonsArsenal/VulcanSpearGlow.png b/Projectiles/DraedonsArsenal/VulcanSpearGlow.png new file mode 100644 index 0000000000..c010c5ec95 Binary files /dev/null and b/Projectiles/DraedonsArsenal/VulcanSpearGlow.png differ diff --git a/Projectiles/DraedonsArsenal/WavePounderProjectile.cs b/Projectiles/DraedonsArsenal/WavePounderProjectile.cs index 9a8ecefceb..c058dcf34e 100644 --- a/Projectiles/DraedonsArsenal/WavePounderProjectile.cs +++ b/Projectiles/DraedonsArsenal/WavePounderProjectile.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal @@ -39,7 +40,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal float offset = Main.rand.NextFloat(38f, 42f); if (Projectile.Calamity().stealthStrike) offset *= 1.66f; - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(offset, offset), 107); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(offset, offset), DustID.Terra); dust.velocity = Projectile.DirectionFrom(dust.position) * offset / 12f + Projectile.velocity; dust.noGravity = true; } diff --git a/Projectiles/Enemy/AnglerFlash.cs b/Projectiles/Enemy/AnglerFlash.cs new file mode 100644 index 0000000000..47879ee90d --- /dev/null +++ b/Projectiles/Enemy/AnglerFlash.cs @@ -0,0 +1,61 @@ +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Enemy +{ + public class AnglerFlash : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 100; + Projectile.height = 100; + Projectile.hostile = true; + Projectile.alpha = 255; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.timeLeft = 30; + Projectile.localNPCHitCooldown = -1; + Projectile.usesLocalNPCImmunity = true; + } + + public override void AI() + { + if (Projectile.ai[0] == 0) + { + GeneralParticleHandler.SpawnParticle(new BloomParticle(Projectile.Center, Vector2.Zero, Color.LightCyan, 1, 3, 30, true)); + Projectile.ai[0] = 1; + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 100, targetHitbox); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 120); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 120); + } + + public override bool? CanHitNPC(NPC target) + { + if (LazarusLampfish.PredatorList.Contains(target.type)) + { + return true; + } + return null; + } + } +} diff --git a/Projectiles/Enemy/CarrionPus.cs b/Projectiles/Enemy/CarrionPus.cs new file mode 100644 index 0000000000..c71e1ed9b6 --- /dev/null +++ b/Projectiles/Enemy/CarrionPus.cs @@ -0,0 +1,43 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Enemy +{ + public class CarrionPus : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 12; + Projectile.penetrate = -1; + Projectile.timeLeft = 240; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, 0.5f, 0.5f, 0f); + + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Main.rand.NextVector2Circular(4f, 4f), 0, Main.rand.NextBool(3) ? Color.Red : Color.Yellow); + dust.noLightEmittence = true; + } + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 60); + } + } +} diff --git a/Projectiles/Enemy/ClamBubbleBlast.cs b/Projectiles/Enemy/ClamBubbleBlast.cs new file mode 100644 index 0000000000..e6b3598e1c --- /dev/null +++ b/Projectiles/Enemy/ClamBubbleBlast.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Enemy +{ + public class ClamBubbleBlast : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + Projectile.timeLeft = 20; + Projectile.extraUpdates = 3; + } + + public override void AI() + { + // Bubbles + if (Main.rand.NextBool()) + { + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), Projectile.position, Projectile.velocity * 0.2f + Main.rand.NextVector2Circular(1f, 1f), 411); + bubble.timeLeft = 9 + Main.rand.Next(7); + bubble.scale = Main.rand.NextFloat(0.6f, 1f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + } + + public override void OnKill(int timeLeft) + { + // Bubbles + for (int i = 0; i < 10; i++) + { + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), Projectile.position, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(60f)) * 0.3f, 411); + bubble.timeLeft = 9 + Main.rand.Next(7); + bubble.scale = Main.rand.NextFloat(0.6f, 1f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + } + } +} diff --git a/Projectiles/Enemy/CragmawVibeCheckChain.cs b/Projectiles/Enemy/CragmawVibeCheckChain.cs index 8bcb308698..829d85fc55 100644 --- a/Projectiles/Enemy/CragmawVibeCheckChain.cs +++ b/Projectiles/Enemy/CragmawVibeCheckChain.cs @@ -1,5 +1,4 @@ using System.IO; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Enemy/CrimsonSpike.cs b/Projectiles/Enemy/CrimsonSpike.cs index 02fc31ab07..f46a0d9f6c 100644 --- a/Projectiles/Enemy/CrimsonSpike.cs +++ b/Projectiles/Enemy/CrimsonSpike.cs @@ -50,14 +50,6 @@ namespace CalamityMod.Projectiles.Enemy } } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (info.Damage <= 0) - return; - - target.AddBuff(BuffID.Darkness, 90); - } - public override void OnKill(int timeLeft) { Color dustColor = Color.Crimson; diff --git a/Projectiles/Enemy/EarthRockBig.cs b/Projectiles/Enemy/EarthRockBig.cs index 6d24b0c175..53a8b9b58c 100644 --- a/Projectiles/Enemy/EarthRockBig.cs +++ b/Projectiles/Enemy/EarthRockBig.cs @@ -12,7 +12,6 @@ namespace CalamityMod.Projectiles.Enemy public new string LocalizationCategory => "Projectiles.Enemy"; public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 32; Projectile.height = 32; Projectile.hostile = true; diff --git a/Projectiles/Enemy/GammRayBurst.cs b/Projectiles/Enemy/GammRayBurst.cs index 54f9905839..3700f52029 100644 --- a/Projectiles/Enemy/GammRayBurst.cs +++ b/Projectiles/Enemy/GammRayBurst.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; using CalamityMod.NPCs.AcidRain; @@ -95,9 +94,9 @@ namespace CalamityMod.Projectiles.Enemy Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; } - public float LaserWidthFunction(float _) => Projectile.scale * Projectile.width + 180; + public float LaserWidthFunction(float _, Vector2 vertexPos) => Projectile.scale * Projectile.width + 180; - public static Color LaserColorFunction(float completionRatio) + public static Color LaserColorFunction(float completionRatio, Vector2 vertexPos) { float colorInterpolant = (float)Math.Sin(Main.GlobalTimeWrappedHourly * -3.2f + completionRatio * 23f) * 0.5f + 0.5f; return Color.Lerp(Color.LightGreen, Color.Lime, colorInterpolant * 0.67f); diff --git a/Projectiles/Enemy/GhostBellShock.cs b/Projectiles/Enemy/GhostBellShock.cs new file mode 100644 index 0000000000..56159811df --- /dev/null +++ b/Projectiles/Enemy/GhostBellShock.cs @@ -0,0 +1,262 @@ +using System.Collections.Generic; +using System.IO; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Enemy +{ + public class GhostBellShock : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + // Max aura size not accounting for babies + public static int MaxDefaultRadius => 160; + + // How much does each baby boost the size of the aura + public static int RadiusBoostPerBaby => 10; + + // Stores the ring points + public List points = []; + + // Stores the bolts which connect from the center to the ring + public List> bolts = []; + + // Stores the bolts which connect to babies + public List> jellyBolts = []; + + // Generic timer + public ref float Timer => ref Projectile.ai[0]; + // The jelly + public ref float Parent => ref Projectile.ai[1]; + // Size of the aura + public ref float CurrentRadius => ref Projectile.ai[2]; + // How many valid babies exist + public ref float CurrentBabies => ref Projectile.localAI[0]; + + public override void SetDefaults() + { + Projectile.width = MaxDefaultRadius * 2; + Projectile.height = MaxDefaultRadius * 2; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.alpha = 255; + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + CurrentBabies = reader.ReadSingle(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(CurrentBabies); + } + + public override void OnSpawn(IEntitySource source) + { + RecalculateLists(); + } + + public override void AI() + { + bool validOwner = true; + int impactMoment = GhostBell.ElectrifyingPhaseDischarge; + + NPC n = Main.npc[(int)Parent - 1]; + if (n == null || !n.active || n.life < 0) + { + validOwner = false; + } + else + { + Projectile.Center = n.Center; + } + // Recalculate the prims to animate the lightning + if (Projectile.ai[0] % 5 == 0) + { + RecalculateLists(); + } + // Scale the aura size. More babies increases the size of the aura + CurrentRadius = MathHelper.Lerp(0, MaxDefaultRadius + (CurrentBabies * RadiusBoostPerBaby), Utils.GetLerpValue(impactMoment, impactMoment + 10, Timer, true)); + if (Timer == 0 && CurrentBabies > 0) + { + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound with { Pitch = 1f }, Projectile.Center); + } + Timer++; + float pitch = (CurrentBabies > 0 && Timer < impactMoment) ? 1f : 0.4f; + if (Timer % 10 == 0 && (Timer >= impactMoment || CurrentBabies > 0)) + { + SoundEngine.PlaySound(SoundID.DD2_LightningBugZap with { Pitch = pitch }, Projectile.Center); + } + if (Timer == impactMoment) + { + SoundEngine.PlaySound(CommonCalamitySounds.LightningSound, Projectile.Center); + } + if (CurrentBabies > 0 || Timer >= impactMoment) + Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(CurrentRadius, CurrentRadius), DustID.Electric); + // Become opaque + if (Timer < (40 + impactMoment) && validOwner) + { + if (Projectile.alpha > 0) + Projectile.alpha -= 20; + if (Projectile.alpha < 0) + Projectile.alpha = 0; + } + // become transparent and die + else + { + Projectile.alpha += 20; + if (Projectile.alpha >= 255) + { + Projectile.Kill(); + } + } + } + + public void RecalculateLists() + { + int ringPoints = 60; // How many times can the ring bend + int boltPoints = 12; // How many times can a bolt bend + int minimumBolts = 6; // Minimum number of bolts + int maximumBolts = 12; // Maximum number of bolts + //int minimumSplits = 0; // Minimum number of split bolts + //int maximumSplits = 2; // Maximum number of split bolts + points.Clear(); + bolts.Clear(); + jellyBolts.Clear(); + for (int i = 0; i < ringPoints; i++) + { + // The radius of the aura. Randomized to be electricky + float rad = CurrentRadius + Main.rand.Next(-20, 20); + // Determinte the end point + // This creates a circle with the given radius + Vector2 end = Vector2.UnitY.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi + MathHelper.ToRadians(15), (i + 1) / (float)ringPoints)) * rad; + points.Add(Projectile.Center + end); + + // Randomly create more electric bolts that connect from the center to the ring + if (Main.rand.NextBool(ringPoints / Main.rand.Next(minimumBolts, maximumBolts))) + { + List bolt = []; + Vector2 start = Projectile.Center; + Vector2 boltEnd = Projectile.Center + end.RotatedByRandom(MathHelper.PiOver4); + + bolt.Add(start); + for (int j = 0; j < boltPoints; j++) + { + Vector2 dest = Vector2.Lerp(start, boltEnd, (j + 1) / (float)boltPoints); + Vector2 dif = dest - start; + Vector2 newPoint = start + dif.RotatedByRandom(MathHelper.ToRadians(10)); + bolt.Add(newPoint); + + // UNUSED code that occasionally gives bolts their own smaller bolts + /*if (Main.rand.NextBool(boltPoints / Main.rand.Next(minimumSplits + 1, maximumSplits + 1)) && j > boltPoints / 2) + { + Main.NewText("Made a bolt"); + List boltSplit = []; + boltSplit.Add(newPoint); + for (int k = 0; k < boltPoints; k++) + { + Vector2 destSplit = Vector2.Lerp(newPoint, Projectile.Center + end.RotatedBy(MathHelper.PiOver4), (k + 1) / (float)boltPoints); + Vector2 difSplit = destSplit - newPoint; + Vector2 newPointSplit = newPoint + difSplit.RotatedByRandom(MathHelper.ToRadians(10)); + boltSplit.Add(newPointSplit); + } + boltSplit.Add(Projectile.Center + end.RotatedBy(MathHelper.PiOver4)); + bolts.Add(boltSplit); + }*/ + } + bolt.Add(boltEnd); + bolts.Add(bolt); + } + + // Re-add the first point so that the trail can form a full circle + if (i == ringPoints - 1) + { + points.Add(points[0]); + } + } + + // Count how many baby jellies exist and tie lightning to them + CurrentBabies = 0; + foreach (NPC n in Main.ActiveNPCs) + { + if (n.type != ModContent.NPCType()) + continue; + if (n.Distance(Projectile.Center) > 400) + continue; + + CurrentBabies++; + + List bolt = []; + Vector2 start = Projectile.Center; + Vector2 boltEnd = n.Center; + + bolt.Add(start); + for (int i = 0; i < boltPoints; i++) + { + Vector2 dest = Vector2.Lerp(start, boltEnd, (i + 1) / (float)boltPoints); + Vector2 dif = dest - start; + Vector2 newPoint = start + dif.RotatedByRandom(MathHelper.ToRadians(4)); + bolt.Add(newPoint); + } + bolt.Add(boltEnd); + jellyBolts.Add(bolt); + } + + Projectile.netUpdate = true; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 60); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.alpha <= 0 && CalamityUtils.CircularHitboxCollision(Projectile.Center, CurrentRadius, targetHitbox); + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:TeslaTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ZapTrail")); + float opacity = 0.6f; + float jellyOpacity = 0.2f; + if (Timer >= GhostBell.ElectrifyingPhaseDischarge) + { + // The aura + PrimitiveRenderer.RenderTrail(points, new((float completion, Vector2 vertexPos) => 4, (float completion, Vector2 vertexPos) => Color.Cyan * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"])); + PrimitiveRenderer.RenderTrail(points, new((float completion, Vector2 vertexPos) => 1, (float completion, Vector2 vertexPos) => Color.White * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"])); + // Bolts inside of the aura + for (int i = 0; i < bolts.Count; i++) + { + List boltPoints = bolts[i]; + PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 3, (float completion, Vector2 vertexPos) => Color.Cyan * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"])); + PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 1, (float completion, Vector2 vertexPos) => Color.White * Projectile.Opacity * opacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"])); + } + } + // Harmless bolts connecting to babies + for (int i = 0; i < jellyBolts.Count; i++) + { + List boltPoints = jellyBolts[i]; + PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 2, (float completion, Vector2 vertexPos) => Color.Cyan * jellyOpacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"])); + PrimitiveRenderer.RenderTrail(boltPoints, new((float completion, Vector2 vertexPos) => 1, (float completion, Vector2 vertexPos) => Color.White * jellyOpacity, smoothen: true, shader: GameShaders.Misc["CalamityMod:TeslaTrail"])); + } + Main.spriteBatch.ExitShaderRegion(); + return false; + } + } +} diff --git a/Projectiles/Enemy/HorsWaterBlast.cs b/Projectiles/Enemy/HorsWaterBlast.cs index ea5ecff51a..33ffa642e9 100644 --- a/Projectiles/Enemy/HorsWaterBlast.cs +++ b/Projectiles/Enemy/HorsWaterBlast.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Enemy/InkPoisonCloud.cs b/Projectiles/Enemy/InkPoisonCloud.cs index 7fd5c520a6..120eb9ae34 100644 --- a/Projectiles/Enemy/InkPoisonCloud.cs +++ b/Projectiles/Enemy/InkPoisonCloud.cs @@ -10,6 +10,7 @@ namespace CalamityMod.Projectiles.Enemy public class InkPoisonCloud : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Enemy"; + public override void SetStaticDefaults() { Main.projFrames[Type] = 10; @@ -35,6 +36,7 @@ namespace CalamityMod.Projectiles.Enemy Projectile.frame++; Projectile.frameCounter = 0; } + if (Projectile.ai[0] < 180f) { if (Projectile.frame >= 4) @@ -42,11 +44,13 @@ namespace CalamityMod.Projectiles.Enemy Projectile.frame = 0; } } - if (Projectile.ai[0] > 180f) + else { Projectile.damage = 0; } - else if (Projectile.frame >= Main.projFrames[Type]) + + // Kill the Projectile if reached end of frame + if (Projectile.frame >= Main.projFrames[Type]) { Projectile.Kill(); } diff --git a/Projectiles/Enemy/JellyghoulBolt.cs b/Projectiles/Enemy/JellyghoulBolt.cs index bf9edbf051..d023799517 100644 --- a/Projectiles/Enemy/JellyghoulBolt.cs +++ b/Projectiles/Enemy/JellyghoulBolt.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; @@ -63,7 +61,7 @@ namespace CalamityMod.Projectiles.Enemy if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override void OnKill(int timeLeft) @@ -86,7 +84,7 @@ namespace CalamityMod.Projectiles.Enemy GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(Color.Red); GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Color.OrangeRed); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; int projFrame = Terraria.GameContent.TextureAssets.Projectile[Type].Value.Height / Main.projFrames[Type]; @@ -104,8 +102,8 @@ namespace CalamityMod.Projectiles.Enemy Main.spriteBatch.ExitShaderRegion();*/ return false; } - public float SlashWidthFunction(float _) => 16 * Utils.GetLerpValue(0f, 0.1f, _, true); + public float SlashWidthFunction(float _, Vector2 vertexPos) => 16 * Utils.GetLerpValue(0f, 0.1f, _, true); - public Color SlashColorFunction(float _) => Color.IndianRed * Projectile.Opacity; + public Color SlashColorFunction(float _, Vector2 vertexPos) => Color.IndianRed * Projectile.Opacity; } } diff --git a/Projectiles/Enemy/MantisRing.cs b/Projectiles/Enemy/MantisRing.cs index 002314546d..b2096ae397 100644 --- a/Projectiles/Enemy/MantisRing.cs +++ b/Projectiles/Enemy/MantisRing.cs @@ -20,7 +20,6 @@ namespace CalamityMod.Projectiles.Enemy public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.knockBack = 3f; Projectile.width = 72; Projectile.height = 30; diff --git a/Projectiles/Enemy/PearlBurst.cs b/Projectiles/Enemy/PearlBurst.cs index 3bc8a1c361..c7bc3fa6a0 100644 --- a/Projectiles/Enemy/PearlBurst.cs +++ b/Projectiles/Enemy/PearlBurst.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Enemy/PearlRain.cs b/Projectiles/Enemy/PearlRain.cs index 29fde3728f..9e3b6b19e3 100644 --- a/Projectiles/Enemy/PearlRain.cs +++ b/Projectiles/Enemy/PearlRain.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Enemy/PodobooSpit.cs b/Projectiles/Enemy/PodobooSpit.cs new file mode 100644 index 0000000000..534740364c --- /dev/null +++ b/Projectiles/Enemy/PodobooSpit.cs @@ -0,0 +1,69 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.GameContent; + +namespace CalamityMod.Projectiles.Enemy +{ + public class PodobooSpit : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Projectiles/Ranged/DrizzlefishFire"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + Projectile.timeLeft = 180; + } + + public override void AI() + { + Projectile.rotation += Projectile.velocity.X * 0.01f; + Lighting.AddLight(Projectile.Center, 0.3f, 0, 0f); + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 30; i++) + { + float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + Vector2 angleVec = angle.ToRotationVector2(); + float distance = Main.rand.NextFloat(4f, 8f); + Vector2 off = angleVec * distance; + off.Y *= (float)Projectile.height / Projectile.width; + Vector2 pos = Projectile.Center + off; + Dust d = Dust.NewDustPerfect(pos, DustID.InfernoFork, angleVec * Main.rand.NextFloat(1f, 2f)); + d.customData = true; + } + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.Orange, 1, TextureAssets.Projectile[Type].Value); + int animSped = 10; + Vector2 scale = Vector2.One + new Vector2(MathF.Cos(Main.GlobalTimeWrappedHourly * animSped), MathF.Sin(Main.GlobalTimeWrappedHourly * animSped)) * 0.25f; + Main.EntitySpriteDraw(TextureAssets.Projectile[Type].Value, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, TextureAssets.Projectile[Type].Size() / 2, scale, 0); + return false; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(BuffID.OnFire, 60); + } + } +} diff --git a/Projectiles/Enemy/PodobooSpitHoming.cs b/Projectiles/Enemy/PodobooSpitHoming.cs new file mode 100644 index 0000000000..8ef5b1a60d --- /dev/null +++ b/Projectiles/Enemy/PodobooSpitHoming.cs @@ -0,0 +1,78 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.GameContent; + +namespace CalamityMod.Projectiles.Enemy +{ + public class PodobooSpitHoming : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + Projectile.timeLeft = 180; + } + + public override void AI() + { + Projectile.rotation += Projectile.velocity.X * 0.01f; + Player p = Main.player[(int)Projectile.ai[0]]; + if (p != null && p.active && !p.dead) + { + Projectile.velocity += Projectile.DirectionTo(p.Center) * 0.25f; + Projectile.velocity = Vector2.Clamp(Projectile.velocity, Vector2.One * -8, Vector2.One * 8); + } + Lighting.AddLight(Projectile.Center, 0.3f, 0, 0.3f); + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 30; i++) + { + float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + Vector2 angleVec = angle.ToRotationVector2(); + float distance = Main.rand.NextFloat(4f, 8f); + Vector2 off = angleVec * distance; + off.Y *= (float)Projectile.height / Projectile.width; + Vector2 pos = Projectile.Center + off; + Dust d = Dust.NewDustPerfect(pos, DustID.InfernoFork, angleVec * Main.rand.NextFloat(1f, 2f)); + d.customData = true; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Main.spriteBatch.Draw(bloom, Projectile.Center - Main.screenPosition, null, Color.Magenta with { A = 0 } * 0.45f, 0f, bloom.Size() / 2f, 0.3f, SpriteEffects.None, 0); + + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.Cyan, 1, TextureAssets.Projectile[Type].Value); + int animSped = 10; + Vector2 scale = Vector2.One + new Vector2(MathF.Cos(Main.GlobalTimeWrappedHourly * animSped), MathF.Sin(Main.GlobalTimeWrappedHourly * animSped)) * 0.25f; + Main.EntitySpriteDraw(TextureAssets.Projectile[Type].Value, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, TextureAssets.Projectile[Type].Size() / 2, scale, 0); + return false; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(BuffID.OnFire, 60); + } + } +} diff --git a/Projectiles/Enemy/PodobooSpitHoming.png b/Projectiles/Enemy/PodobooSpitHoming.png new file mode 100644 index 0000000000..26bc4a232e Binary files /dev/null and b/Projectiles/Enemy/PodobooSpitHoming.png differ diff --git a/Projectiles/Enemy/PodobooSpitSplitting.cs b/Projectiles/Enemy/PodobooSpitSplitting.cs new file mode 100644 index 0000000000..98f520d05e --- /dev/null +++ b/Projectiles/Enemy/PodobooSpitSplitting.cs @@ -0,0 +1,104 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.GameContent; + +namespace CalamityMod.Projectiles.Enemy +{ + public class PodobooSpitSplitting : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Projectiles/Ranged/DrizzlefishFire2"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 3; + Projectile.tileCollide = true; + Projectile.timeLeft = 180; + } + + public override void AI() + { + Projectile.rotation += Projectile.velocity.X * 0.01f; + Lighting.AddLight(Projectile.Center, 0.4f, 0, 0.2f); + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 30; i++) + { + float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + Vector2 angleVec = angle.ToRotationVector2(); + float distance = Main.rand.NextFloat(4f, 8f); + Vector2 off = angleVec * distance; + off.Y *= (float)Projectile.height / Projectile.width; + Vector2 pos = Projectile.Center + off; + Dust d = Dust.NewDustPerfect(pos, DustID.InfernoFork, angleVec * Main.rand.NextFloat(1f, 2f)); + d.customData = true; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (Projectile.ai[0] == 1) + { + if (Projectile.penetrate > 1) + { + if (Projectile.velocity.X != oldVelocity.X) + Projectile.velocity.X = -oldVelocity.X; + if (Projectile.velocity.Y != oldVelocity.Y) + Projectile.velocity.Y = -oldVelocity.Y; + Projectile.penetrate--; + return false; + } + } + else if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.PiOver2), Type, (int)(Projectile.damage * 0.5f), Projectile.knockBack, ai0: 1); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(-MathHelper.PiOver2), Type, (int)(Projectile.damage * 0.5f), Projectile.knockBack, ai0: 1); + } + return true; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (Projectile.ai[0] == 1) + { + if (Projectile.penetrate > 1) + { + Projectile.velocity *= -1; + } + } + else if(Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.PiOver2), Type, (int)(Projectile.damage * 0.5f), Projectile.knockBack, ai0: 1); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(-MathHelper.PiOver2), Type, (int)(Projectile.damage * 0.5f), Projectile.knockBack, ai0: 1); + } + + if (info.Damage <= 0) + return; + + target.AddBuff(BuffID.OnFire, 60); + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.Magenta, 1, TextureAssets.Projectile[Type].Value); + int animSped = 10; + Vector2 scale = Vector2.One + new Vector2(MathF.Cos(Main.GlobalTimeWrappedHourly * animSped), MathF.Sin(Main.GlobalTimeWrappedHourly * animSped)) * 0.25f; + Main.EntitySpriteDraw(TextureAssets.Projectile[Type].Value, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, TextureAssets.Projectile[Type].Size() / 2, scale, 0); + return false; + } + } +} diff --git a/Projectiles/Enemy/PodobooSpitUltima.cs b/Projectiles/Enemy/PodobooSpitUltima.cs new file mode 100644 index 0000000000..c5acee939b --- /dev/null +++ b/Projectiles/Enemy/PodobooSpitUltima.cs @@ -0,0 +1,90 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using CalamityMod.Graphics.Primitives; +using Terraria.Audio; +using CalamityMod.Buffs.DamageOverTime; + +namespace CalamityMod.Projectiles.Enemy +{ + public class PodobooSpitUltima : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + Projectile.timeLeft = 180; + } + + public override void AI() + { + Projectile.rotation += Projectile.velocity.X * 0.01f; + Lighting.AddLight(Projectile.Center, 0.4f, 0.2f, 0f); + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); + + for (int i = 0; i < 30; i++) + { + float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + Vector2 angleVec = angle.ToRotationVector2(); + float distance = Main.rand.NextFloat(7f, 18f); + Vector2 off = angleVec * distance; + off.Y *= (float)Projectile.height / Projectile.width; + Vector2 pos = Projectile.Center + off; + Dust d = Dust.NewDustPerfect(pos, DustID.InfernoFork, angleVec * Main.rand.NextFloat(2f, 4f)); + d.customData = true; + } + } + + + + public override bool PreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + Vector2 overallOffset = Projectile.Size / 2; + int numPoints = 92; + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => overallOffset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), numPoints); + + int animSped = 10; + Vector2 scale = Vector2.One + new Vector2(MathF.Cos(Main.GlobalTimeWrappedHourly * animSped), MathF.Sin(Main.GlobalTimeWrappedHourly * animSped)) * 0.25f; + Main.EntitySpriteDraw(TextureAssets.Projectile[Type].Value, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, TextureAssets.Projectile[Type].Size() / 2, scale, 0); + return false; + } + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) + { + return MathHelper.Lerp(12, 1, completionRatio); + } + + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) + { + return Color.Lerp(Color.Orange, Color.DarkOrange, completionRatio); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 60); + } + } +} diff --git a/Projectiles/Enemy/PodobooSpitUltima.png b/Projectiles/Enemy/PodobooSpitUltima.png new file mode 100644 index 0000000000..2d0b8b00dd Binary files /dev/null and b/Projectiles/Enemy/PodobooSpitUltima.png differ diff --git a/Projectiles/Enemy/PrismBackCrystal.cs b/Projectiles/Enemy/PrismBackCrystal.cs new file mode 100644 index 0000000000..0816057675 --- /dev/null +++ b/Projectiles/Enemy/PrismBackCrystal.cs @@ -0,0 +1,54 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Enemy +{ + public class PrismBackCrystal : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Particles/SeaPrisms"; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 16; + Projectile.friendly = true; + Projectile.hostile = true; + Projectile.timeLeft = 240; + Projectile.ignoreWater = true; + Projectile.scale = 0.85f; + } + + public override void AI() + { + Projectile.velocity.X *= 0.995f; + Projectile.velocity.Y += 0.03f; + if (Projectile.velocity.Y > 5f) + Projectile.velocity.Y = 5f; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + + public override bool? CanHitNPC(NPC target) => target.whoAmI == (int)Projectile.ai[1] ? false : null; + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Item27 with { Volume = 0.5f }, Projectile.Center); + for (int i = 0; i < 3; i++) + { + Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IcyMerman); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = TextureAssets.Projectile[Type].Value; + Rectangle frame = new Rectangle(18 * (int)Projectile.ai[0], 0, 16, 32); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, lightColor, Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None); + return false; + } + } +} diff --git a/Projectiles/Enemy/PufferExplosion.cs b/Projectiles/Enemy/PufferExplosion.cs index dc22fa1f93..8b0daae483 100644 --- a/Projectiles/Enemy/PufferExplosion.cs +++ b/Projectiles/Enemy/PufferExplosion.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Enemy/ShoreskipperTackle.cs b/Projectiles/Enemy/ShoreskipperTackle.cs new file mode 100644 index 0000000000..242025c4b1 --- /dev/null +++ b/Projectiles/Enemy/ShoreskipperTackle.cs @@ -0,0 +1,64 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Enemy +{ + public class ShoreskipperTackle : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + private NPC OwnerNPC => Main.npc[(int)Projectile.ai[0]]; + + public override void SetDefaults() + { + Projectile.width = 64; + Projectile.height = 32; + Projectile.hostile = true; + Projectile.friendly = false; + Projectile.ignoreWater = false; + Projectile.tileCollide = false; + Projectile.timeLeft = 120; + Projectile.penetrate = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + if (!OwnerNPC.active || OwnerNPC.type != NPCType()) + { + Projectile.Kill(); + return; + } + + Projectile.Center = OwnerNPC.Center; + + if (OwnerNPC.velocity.Y == 0f) + { + Projectile.Kill(); + } + } + + public override bool? CanHitNPC(NPC target) + { + // Can only damage other Shoreskippers + if (target.type == NPCType()) + { + // Never kill yourself + if (target.whoAmI == OwnerNPC.whoAmI) + return false; + + return true; + } + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Dust.NewDust(target.position, target.width, target.height, DustID.Water, 0f, -2f, 0, default, 1f); + } + } +} diff --git a/Projectiles/Enemy/StormlionSentryBullet.cs b/Projectiles/Enemy/StormlionSentryBullet.cs new file mode 100644 index 0000000000..5802fe3a03 --- /dev/null +++ b/Projectiles/Enemy/StormlionSentryBullet.cs @@ -0,0 +1,64 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Enemy +{ + public class StormlionSentryBullet : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Enemy"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetDefaults() + { + Projectile.width = 8; + Projectile.height = 8; + Projectile.hostile = true; + Projectile.timeLeft = 160; + Projectile.extraUpdates = 6; + Projectile.tileCollide = true; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Lighting.AddLight(Projectile.Center, Effects.StormlionEffects.EnergyColor.ToVector3() * 0.3f); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (Main.rand.NextBool()) + { + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust2.scale = Main.rand.NextFloat(0.4f, 0.7f); + dust2.velocity = Projectile.velocity * Main.rand.NextFloat(0.6f, 1f); + dust2.noGravity = true; + dust2.color = Effects.StormlionEffects.EnergyColor; + } + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (info.Damage <= 0) + return; + + target.AddBuff(ModContent.BuffType(), 60); + } + public override void OnKill(int timeLeft) + { + + } + public override bool PreDraw(ref Color lightColor) + { + Asset orb = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + for (int i = 0; i < 4; i++) + { + Vector2 scale = Projectile.scale * new Vector2(0.2f, 1.4f) * (0.05f + i * 0.02f) * 4; + Main.EntitySpriteDraw(orb.Value, Projectile.Center - Main.screenPosition, null, Effects.StormlionEffects.EnergyColor with { A = 0 }, Projectile.rotation, orb.Size() * 0.5f, scale, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Enemy/SulphuricAcidMist.cs b/Projectiles/Enemy/SulphuricAcidMist.cs index f1f5d6b825..2ad2cea566 100644 --- a/Projectiles/Enemy/SulphuricAcidMist.cs +++ b/Projectiles/Enemy/SulphuricAcidMist.cs @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Enemy return; if (Projectile.Opacity >= 0.9f) - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 300); } } } diff --git a/Projectiles/Enemy/TornadoHostile.cs b/Projectiles/Enemy/TornadoHostile.cs index ed74fd0215..002c255f37 100644 --- a/Projectiles/Enemy/TornadoHostile.cs +++ b/Projectiles/Enemy/TornadoHostile.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Enemy public override void SetDefaults() { + Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 10; Projectile.height = 10; Projectile.hostile = true; diff --git a/Projectiles/Enemy/ToxicMinnowCloud.cs b/Projectiles/Enemy/ToxicMinnowCloud.cs index fa67dcad89..f5ba29a1d1 100644 --- a/Projectiles/Enemy/ToxicMinnowCloud.cs +++ b/Projectiles/Enemy/ToxicMinnowCloud.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Enemy Projectile.ignoreWater = true; Projectile.timeLeft = 600; Projectile.alpha = 120; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Environment/BarrelCactusProjectile.cs b/Projectiles/Environment/BarrelCactusProjectile.cs new file mode 100644 index 0000000000..813fa91228 --- /dev/null +++ b/Projectiles/Environment/BarrelCactusProjectile.cs @@ -0,0 +1,50 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Environment +{ + public class BarrelCactusProjectile : ModProjectile, ILocalizedModType + { //I tried, someone else figure it out I bet YuH could do it + public new string LocalizationCategory => "Projectiles.Misc"; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 1; + } + + public override void SetDefaults() + { + Projectile.CloneDefaults(ProjectileID.RollingCactus); + + Projectile.width = 32; + Projectile.height = 32; + + Projectile.damage = 70; + Projectile.knockBack = 6f; + + Projectile.friendly = false; + Projectile.hostile = true; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle frame = tex.Bounds; + Vector2 origin = frame.Size() * 0.5f; + + Main.EntitySpriteDraw( + tex, + Projectile.Center - Main.screenPosition, + frame, + lightColor, + Projectile.rotation, + origin, + Projectile.scale, + SpriteEffects.None, + 0); + + return false; + } + } +} diff --git a/Projectiles/Environment/BarrelCactusProjectile.png b/Projectiles/Environment/BarrelCactusProjectile.png new file mode 100644 index 0000000000..1530195e19 Binary files /dev/null and b/Projectiles/Environment/BarrelCactusProjectile.png differ diff --git a/Projectiles/Environment/HotSteam.cs b/Projectiles/Environment/HotSteam.cs index 7a9029974e..9c51cc8e26 100644 --- a/Projectiles/Environment/HotSteam.cs +++ b/Projectiles/Environment/HotSteam.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Environment/LargeBarrelCactusProjectile.png b/Projectiles/Environment/LargeBarrelCactusProjectile.png new file mode 100644 index 0000000000..0848fd8154 Binary files /dev/null and b/Projectiles/Environment/LargeBarrelCactusProjectile.png differ diff --git a/Projectiles/Environment/Lilyglow.cs b/Projectiles/Environment/Lilyglow.cs index b984a03d89..a56a6dde4d 100644 --- a/Projectiles/Environment/Lilyglow.cs +++ b/Projectiles/Environment/Lilyglow.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Projectiles.Environment public class Lilyglow : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Misc"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/ExtraTextures/TinyGreyscaleCircle"; public ref float Direction => ref Projectile.ai[0]; @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Environment Projectile.tileCollide = false; Projectile.timeLeft = 600; Projectile.penetrate = 1; - Projectile.scale = Main.rand?.NextFloat(0.02f, 0.035f) ?? 0.03f; + Projectile.scale = Main.rand?.NextFloat(0.03f, 0.055f) ?? 0.04f; Projectile.Size /= Projectile.scale; } diff --git a/Projectiles/Environment/MurkySteam.cs b/Projectiles/Environment/MurkySteam.cs index 74523462b0..7a08be9d5c 100644 --- a/Projectiles/Environment/MurkySteam.cs +++ b/Projectiles/Environment/MurkySteam.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Environment/ThermalSteam.cs b/Projectiles/Environment/ThermalSteam.cs index 2b4061379c..4539d420a9 100644 --- a/Projectiles/Environment/ThermalSteam.cs +++ b/Projectiles/Environment/ThermalSteam.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Healing/AbsorberAura.cs b/Projectiles/Healing/AbsorberAura.cs index 91fb6286d8..771a198030 100644 --- a/Projectiles/Healing/AbsorberAura.cs +++ b/Projectiles/Healing/AbsorberAura.cs @@ -1,17 +1,13 @@ using System; using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Accessories; -using CalamityMod.Particles; using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing @@ -61,7 +57,7 @@ namespace CalamityMod.Projectiles.Healing for (int l = 0; l < Player.MaxBuffs; l++) { int buffID = player.buffType[l]; - if (player.buffTime[l] > 2 && DebuffsList.Includes(buffID)) + if (player.buffTime[l] > 2 && CalamityBuffSets.IsDebuff[buffID]) { player.buffTime[l] *= 0; } diff --git a/Projectiles/Healing/AltTransfusionTrail.cs b/Projectiles/Healing/AltTransfusionTrail.cs index cb362dbc53..b70a5cb7c5 100644 --- a/Projectiles/Healing/AltTransfusionTrail.cs +++ b/Projectiles/Healing/AltTransfusionTrail.cs @@ -1,7 +1,5 @@ -using Microsoft.CodeAnalysis; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Particles; @@ -17,13 +15,11 @@ namespace CalamityMod.Projectiles.Healing public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; - Projectile.penetrate = 1; - Projectile.timeLeft = 600; + Projectile.width = Projectile.height = 4; Projectile.friendly = true; Projectile.tileCollide = false; - Projectile.extraUpdates = 5; + Projectile.MaxUpdates = 5; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; } public override void AI() diff --git a/Projectiles/Healing/BloodstoneHealOrb.cs b/Projectiles/Healing/BloodstoneHealOrb.cs new file mode 100644 index 0000000000..c0073ab719 --- /dev/null +++ b/Projectiles/Healing/BloodstoneHealOrb.cs @@ -0,0 +1,118 @@ +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Healing +{ + public class BloodstoneHealOrb : ModProjectile, ILocalizedModType //Modified copy from SanguineHealOrb + { + public new string LocalizationCategory => "Projectiles.Healing"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public int target = -1; + public ref int heal => ref Projectile.damage; + + public int spawnCooldown = 60; //how many frames must pass before it can be picked up + + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 16; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.penetrate = 1; + Projectile.tileCollide = false; + Projectile.extraUpdates = 3; + Projectile.timeLeft = 60 * 5 * Projectile.MaxUpdates; + spawnCooldown *= Projectile.MaxUpdates; + } + public override void AI() + { + bool finalUpdate = Projectile.FinalExtraUpdate(); + + var p = BloodMetaball.SpawnParticle(Projectile.Center + Projectile.velocity, Main.rand.NextVector2Circular(-0.5f, -0.5f), Projectile.width); + p.SizeScaling = 0.75f; + p.ShrinkDelay = 1; + + float maxDistanceSq = 200f * 200f; + if (spawnCooldown > 0) + { + PassiveBehavior(); + spawnCooldown--; + return; + } + if (target < 0) + { + PassiveBehavior(); + if (finalUpdate) for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + Player player = Main.player[playerIndex]; + float perPlayerMaxDistanceSq = player.lifeMagnet ? maxDistanceSq * 2.25f : maxDistanceSq; //Heartreach gives 50% more range + float targetDistSq = Vector2.DistanceSquared(player.Center, Projectile.Center); + if (targetDistSq < perPlayerMaxDistanceSq) + { + maxDistanceSq = targetDistSq; + target = playerIndex; + } + } + } + else HealHome(); + } + + public void PassiveBehavior() + { + Projectile.velocity *= 0.99f; + } + + public void HealHome() + { + Player player = Main.player[target]; + Vector2 playerVector = player.Center - Projectile.Center; + float playerDist = playerVector.Length(); + if (playerDist < 50f && Projectile.position.X < player.position.X + player.width && Projectile.position.X + Projectile.width > player.position.X && Projectile.position.Y < player.position.Y + player.height && Projectile.position.Y + Projectile.height > player.position.Y) + { + Heal(player, heal); + Projectile.Kill(); + } + + Projectile.velocity = (Projectile.velocity * 5 + (playerVector.SafeNormalize(Vector2.Zero) * 5)) / 6f; //Move towards player. Range is determined in the AI(); + } + + public static void Heal(Player player, int PotionTime) + { + var cplayer = player.Calamity(); + if (player.potionDelay > 0) + { + player.potionDelay -= PotionTime; + if (player.potionDelay < 0) + player.potionDelay = 0; + if (player.HasBuff(BuffID.PotionSickness)) + { + for (var i = 0; i < player.buffType.Length; i++) + { + if (player.buffType[i] == BuffID.PotionSickness) + { + player.buffTime[i] = player.potionDelay; + } + } + } + } + else + { + player.lifeRegenTime += 3*PotionTime; //if Potion Sickness is full, each orb speeds up natural regen + } + + Particle ring = new CustomPulse(player.Center, Vector2.Zero, new Color(255, 32, 32)*0.75f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, 0, 0.01f, 0.05f, 20); + GeneralParticleHandler.SpawnParticle(ring); + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + } +} diff --git a/Projectiles/Healing/BlueJellyAura.cs b/Projectiles/Healing/BlueJellyAura.cs index 1282ea8349..dd490b0074 100644 --- a/Projectiles/Healing/BlueJellyAura.cs +++ b/Projectiles/Healing/BlueJellyAura.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; +using System.Collections.Generic; using CalamityMod.Items.Accessories; using CalamityMod.Particles; using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -58,7 +52,7 @@ namespace CalamityMod.Projectiles.Healing for (int l = 0; l < Player.MaxBuffs; l++) { int buffID = player.buffType[l]; - if (player.buffTime[l] > 2 && DebuffsList.Includes(buffID)) + if (player.buffTime[l] > 2 && CalamityBuffSets.IsDebuff[buffID]) { player.buffTime[l] *= 0; } @@ -100,14 +94,14 @@ namespace CalamityMod.Projectiles.Healing for (int i = 0; i < 1; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(155f, 155f), 187); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(155f, 155f), DustID.BlueFlare); dust.scale = Main.rand.NextFloat(2.2f, 3.3f); dust.noGravity = true; } for (int i = 0; i < 1; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(150f, 150f), 187); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(150f, 150f), DustID.BlueFlare); dust.scale = Main.rand.NextFloat(0.8f, 1.3f); dust.noGravity = true; } diff --git a/Projectiles/Healing/BurntSiennaProj.cs b/Projectiles/Healing/BurntSiennaProj.cs index 76a4347133..52efdc55f8 100644 --- a/Projectiles/Healing/BurntSiennaProj.cs +++ b/Projectiles/Healing/BurntSiennaProj.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Healing/DemonHeal.cs b/Projectiles/Healing/DemonHeal.cs index 550e365b49..7e4d4e30fd 100644 --- a/Projectiles/Healing/DemonHeal.cs +++ b/Projectiles/Healing/DemonHeal.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Healing @@ -23,7 +24,7 @@ namespace CalamityMod.Projectiles.Healing { Projectile.HealingProjectile(10, Projectile.owner, 20f, 20f, true, 640); - Dust fire = Dust.NewDustPerfect(Projectile.Center, 130); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.Firework_Red); fire.velocity = Microsoft.Xna.Framework.Vector2.Zero; fire.scale = Main.rand.NextFloat(1f, 1.15f); fire.fadeIn = 0.45f; diff --git a/Projectiles/Healing/EmpyreanHealOrb.cs b/Projectiles/Healing/EmpyreanHealOrb.cs index f876e0cf8a..4ea21d084d 100644 --- a/Projectiles/Healing/EmpyreanHealOrb.cs +++ b/Projectiles/Healing/EmpyreanHealOrb.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Healing/EssenceFlame.cs b/Projectiles/Healing/EssenceFlame.cs index ad272fe761..d06bdfd4c6 100644 --- a/Projectiles/Healing/EssenceFlame.cs +++ b/Projectiles/Healing/EssenceFlame.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Healing/FungalHeal.cs b/Projectiles/Healing/FungalHeal.cs index 1dcb6e2a4f..bcf3dcdf59 100644 --- a/Projectiles/Healing/FungalHeal.cs +++ b/Projectiles/Healing/FungalHeal.cs @@ -12,18 +12,16 @@ namespace CalamityMod.Projectiles.Healing public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; - Projectile.penetrate = 1; + Projectile.width = Projectile.height = 4; Projectile.friendly = true; Projectile.tileCollide = false; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 300; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; } public override void AI() { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 3f, 15f); + Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 4f, 15f); int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0f; diff --git a/Projectiles/Healing/GladiatorHealOrb.cs b/Projectiles/Healing/GladiatorHealOrb.cs index 3659aadfad..bbebf4fcd9 100644 --- a/Projectiles/Healing/GladiatorHealOrb.cs +++ b/Projectiles/Healing/GladiatorHealOrb.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Balancing; using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -63,7 +62,7 @@ namespace CalamityMod.Projectiles.Healing public void PassiveBehavior() { float maxYVelocity = 2f; - CalamityUtils.StickToTiles(Projectile, false, false); + CommonProjectileAI.StickToTiles(Projectile, false, false); Projectile.velocity.X *= 0.99f; if (Projectile.velocity.Y < maxYVelocity) Projectile.velocity.Y += 0.02f; diff --git a/Projectiles/Healing/GreenJellyAura.cs b/Projectiles/Healing/GreenJellyAura.cs index 3b41df93d3..44751aed01 100644 --- a/Projectiles/Healing/GreenJellyAura.cs +++ b/Projectiles/Healing/GreenJellyAura.cs @@ -1,14 +1,9 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; +using System.Collections.Generic; using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; using CalamityMod.Items.Accessories; using CalamityMod.Particles; using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -60,7 +55,7 @@ namespace CalamityMod.Projectiles.Healing for (int l = 0; l < Player.MaxBuffs; l++) { int buffID = player.buffType[l]; - if (player.buffTime[l] > 2 && DebuffsList.Includes(buffID)) + if (player.buffTime[l] > 2 && CalamityBuffSets.IsDebuff[buffID]) { player.buffTime[l] *= 0; } @@ -102,14 +97,14 @@ namespace CalamityMod.Projectiles.Healing for (int i = 0; i < 2; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(232f, 232f), 298); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(232f, 232f), DustID.JungleTorch); dust.scale = Main.rand.NextFloat(2.2f, 3.3f); dust.noGravity = true; } for (int i = 0; i < 1; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(225f, 225f), 298); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(225f, 225f), DustID.JungleTorch); dust.scale = Main.rand.NextFloat(0.8f, 1.3f); dust.noGravity = true; } diff --git a/Projectiles/Healing/HydrothermicHealOrb.cs b/Projectiles/Healing/HydrothermicHealOrb.cs index e1df042f9f..fd789bee4a 100644 --- a/Projectiles/Healing/HydrothermicHealOrb.cs +++ b/Projectiles/Healing/HydrothermicHealOrb.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,18 +12,16 @@ namespace CalamityMod.Projectiles.Healing public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; + Projectile.width = Projectile.height = 4; Projectile.friendly = true; - Projectile.penetrate = 1; Projectile.tileCollide = false; - Projectile.timeLeft = 300; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; } public override void AI() { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 5f, 15f); + Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 8f, 15f); int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Flare, 0f, 0f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0f; diff --git a/Projectiles/Healing/IridescentExcaliburHeal.cs b/Projectiles/Healing/IridescentExcaliburHeal.cs deleted file mode 100644 index c71e6050d7..0000000000 --- a/Projectiles/Healing/IridescentExcaliburHeal.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Healing -{ - public class IridescentExcaliburHeal : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Healing"; - - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; - Projectile.tileCollide = false; - Projectile.extraUpdates = 3; - } - - public override void AI() - { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 10f, 15f); - - Color dustColor = Color.White; - switch (Main.rand.Next(3)) - { - default: - case 0: - dustColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - break; - - case 1: - dustColor = new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB); - break; - - case 2: - dustColor = new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1); - break; - } - - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 278, 0f, 0f, 100); - Main.dust[dust].color = dustColor; - Main.dust[dust].fadeIn = 0.4f + Main.rand.NextFloat() * 0.15f; - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0f; - Main.dust[dust].position.X -= Projectile.velocity.X * 0.2f; - Main.dust[dust].position.Y += Projectile.velocity.Y * 0.2f; - } - } -} diff --git a/Projectiles/Healing/ManaPolarizerHealOrb.cs b/Projectiles/Healing/ManaPolarizerHealOrb.cs index c2dbdacf55..c7f4fbb298 100644 --- a/Projectiles/Healing/ManaPolarizerHealOrb.cs +++ b/Projectiles/Healing/ManaPolarizerHealOrb.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,18 +12,16 @@ namespace CalamityMod.Projectiles.Healing public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; + Projectile.width = Projectile.height = 4; Projectile.friendly = true; - Projectile.penetrate = 1; Projectile.tileCollide = false; - Projectile.timeLeft = 300; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; } public override void AI() { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 4f, 15f); + Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 6f, 15f); int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SpectreStaff, 0f, 0f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0f; diff --git a/Projectiles/Healing/PhantomicHeart.cs b/Projectiles/Healing/PhantomicHeart.cs index ea6c6c6de7..6a5c000682 100644 --- a/Projectiles/Healing/PhantomicHeart.cs +++ b/Projectiles/Healing/PhantomicHeart.cs @@ -25,6 +25,7 @@ namespace CalamityMod.Projectiles.Healing Projectile.width = 28; Projectile.height = 42; Projectile.friendly = true; + Projectile.tileCollide = false; Projectile.alpha = 20; Projectile.penetrate = -1; Projectile.timeLeft = 600; @@ -68,7 +69,7 @@ namespace CalamityMod.Projectiles.Healing if (player.whoAmI == Main.myPlayer) { CalamityPlayer calPlayer = player.Calamity(); - calPlayer.phantomicHeartRegen = 720; + calPlayer.phantomicHeartRegen = 600; Projectile.Kill(); } } diff --git a/Projectiles/Healing/PinkJellyAura.cs b/Projectiles/Healing/PinkJellyAura.cs index e369e66a30..bade738b9c 100644 --- a/Projectiles/Healing/PinkJellyAura.cs +++ b/Projectiles/Healing/PinkJellyAura.cs @@ -1,11 +1,7 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Dusts; +using CalamityMod.Buffs.StatBuffs; using CalamityMod.Items.Accessories; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -74,14 +70,14 @@ namespace CalamityMod.Projectiles.Healing for (int i = 0; i < 1; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(155f, 155f), 242); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(155f, 155f), DustID.PinkTorch); dust.scale = Main.rand.NextFloat(2.2f, 3.3f); dust.noGravity = true; } for (int i = 0; i < 1; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(150f, 150f), 242); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(150f, 150f), DustID.PinkTorch); dust.scale = Main.rand.NextFloat(0.8f, 1.3f); dust.noGravity = true; } diff --git a/Projectiles/Healing/ReaverHealOrb.cs b/Projectiles/Healing/ReaverHealOrb.cs deleted file mode 100644 index 23d5fb22c0..0000000000 --- a/Projectiles/Healing/ReaverHealOrb.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Healing -{ - public class ReaverHealOrb : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Healing"; - - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.tileCollide = false; - Projectile.timeLeft = 300; - Projectile.extraUpdates = 3; - } - - public override void AI() - { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 5f, 15f); - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GreenFairy, 0f, 0f, 100); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0f; - Main.dust[dust].position.X -= Projectile.velocity.X * 0.2f; - Main.dust[dust].position.Y += Projectile.velocity.Y * 0.2f; - } - } -} diff --git a/Projectiles/Healing/RoyalHeal.cs b/Projectiles/Healing/RoyalHeal.cs index 145c21fc49..c16117c171 100644 --- a/Projectiles/Healing/RoyalHeal.cs +++ b/Projectiles/Healing/RoyalHeal.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,18 +12,16 @@ namespace CalamityMod.Projectiles.Healing public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; + Projectile.width = Projectile.height = 4; Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; Projectile.tileCollide = false; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 5; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; } public override void AI() { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 18f, 10f); + Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 12f, 10f); int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.PurificationPowder, 0f, 0f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0f; diff --git a/Projectiles/Healing/ShinobiHealOrb.cs b/Projectiles/Healing/ShinobiHealOrb.cs index 7a507a57a0..e809f38c1d 100644 --- a/Projectiles/Healing/ShinobiHealOrb.cs +++ b/Projectiles/Healing/ShinobiHealOrb.cs @@ -26,19 +26,18 @@ namespace CalamityMod.Projectiles.Healing Projectile.width = Projectile.height = 20; Projectile.friendly = true; Projectile.tileCollide = false; - Projectile.penetrate = -1; Projectile.MaxUpdates = 5; Projectile.timeLeft = 120 * Projectile.MaxUpdates; } public override void AI() => Projectile.HealingProjectile((int)Projectile.ai[1], Projectile.owner, 6f, 15f); - internal Color ColorFunction(float completionRatio) => Color.Lerp(Color.Blue, Color.CornflowerBlue, completionRatio); - internal float WidthFunction(float completionRatio) => 10f * (completionRatio < 0.2f ? MathHelper.Clamp(1f - MathF.Pow(5f * completionRatio - 1f, 2f), 0f, 1f) : Utils.GetLerpValue(1f, 0.2f, completionRatio, true)); + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.Blue, Color.CornflowerBlue, completionRatio); + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => 10f * (completionRatio < 0.2f ? MathHelper.Clamp(1f - MathF.Pow(5f * completionRatio - 1f, 2f), 0f, 1f) : Utils.GetLerpValue(1f, 0.2f, completionRatio, true)); public override bool PreDraw(ref Color lightColor) { GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/BasicTrail")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); return false; } diff --git a/Projectiles/Healing/SilvaOrb.cs b/Projectiles/Healing/SilvaOrb.cs deleted file mode 100644 index 1d12d7230d..0000000000 --- a/Projectiles/Healing/SilvaOrb.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Healing -{ - public class SilvaOrb : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Healing"; - - public override void SetDefaults() - { - Projectile.width = 22; - Projectile.height = 22; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; - Projectile.extraUpdates = 3; - Projectile.tileCollide = false; - } - - public override void AI() - { - Projectile.alpha -= 2; - if (Projectile.localAI[0] == 0f) - { - Projectile.scale += 0.05f; - if (Projectile.scale > 1.2f) - Projectile.localAI[0] = 1f; - } - else - { - Projectile.scale -= 0.05f; - if (Projectile.scale < 0.8f) - Projectile.localAI[0] = 0f; - } - - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 6f, 15f); - return; - } - - public override Color? GetAlpha(Color lightColor) => new Color(Main.DiscoR, 203, 103, Projectile.alpha); - - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 5; i++) - { - int silvaHeal = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ChlorophyteWeapon, 0f, 0f, 0, new Color(Main.DiscoR, 203, 103), 1.5f); - Main.dust[silvaHeal].noGravity = true; - Main.dust[silvaHeal].velocity *= 0f; - } - } - } -} diff --git a/Projectiles/Healing/SilvaOrb.png b/Projectiles/Healing/SilvaOrb.png deleted file mode 100644 index 37597f4cad..0000000000 Binary files a/Projectiles/Healing/SilvaOrb.png and /dev/null differ diff --git a/Projectiles/Healing/TransfusionTrail.cs b/Projectiles/Healing/TransfusionTrail.cs index 55d1326d47..29a46da0a4 100644 --- a/Projectiles/Healing/TransfusionTrail.cs +++ b/Projectiles/Healing/TransfusionTrail.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,13 +12,11 @@ namespace CalamityMod.Projectiles.Healing public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.width = Projectile.height = 4; Projectile.friendly = true; Projectile.tileCollide = false; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; } public override void AI() diff --git a/Projectiles/Magic/AbyssBall.cs b/Projectiles/Magic/AbyssBall.cs index 7b1c806410..d29cc98319 100644 --- a/Projectiles/Magic/AbyssBall.cs +++ b/Projectiles/Magic/AbyssBall.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -21,6 +20,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Magic; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/AcidicSaxBubble.cs b/Projectiles/Magic/AcidicSaxBubble.cs index 740ff708e4..ffb9068575 100644 --- a/Projectiles/Magic/AcidicSaxBubble.cs +++ b/Projectiles/Magic/AcidicSaxBubble.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Magic; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -10,6 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class AcidicSaxBubble : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -31,6 +33,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; Projectile.alpha = 255; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/AerSigil.cs b/Projectiles/Magic/AerSigil.cs new file mode 100644 index 0000000000..5af08db9b2 --- /dev/null +++ b/Projectiles/Magic/AerSigil.cs @@ -0,0 +1,114 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Magic +{ + public class AerSigil : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private bool spawnedProjectile = false; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 74; + Projectile.friendly = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)Projectile.ai[0]]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive && Projectile.ai[2] == 0) + { + Projectile.Kill(); + return; + } + + int i = (int)Projectile.ai[1]; + float dist = i % 3 == 0 ? 270f : 280f; + float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f); + + Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot); + Projectile.Center = sigilPos; + + if (Projectile.ai[2] > 0) + { + Projectile.localAI[0]++; + + if (Projectile.localAI[0] == 35 && !spawnedProjectile) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/VividClarityBeamAppear") { Volume = 0.5f, PitchVariance = 0.1f }, Projectile.Center); + + Player owner = Main.player[Projectile.owner]; + Vector2 targetDirection = Projectile.Center.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX); + + spawnedProjectile = true; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, targetDirection * 48f, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); + } + + if (Projectile.localAI[0] >= 50) + { + Projectile.Kill(); + } + } + + else + { + Projectile.scale = parent.scale; + Projectile.rotation = 0; + Projectile.alpha = parent.alpha; + } + + if (parentActive) + { + Projectile.timeLeft = parent.timeLeft; + } + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D blankTexture = ModContent.Request("CalamityMod/Projectiles/Magic/BlankSigil").Value; + + float finalScale = Projectile.scale; + float alphaOpacity = 1f - (Projectile.alpha / 255f); + float maskOpacity = 0f; + + // Apply animation effects if fading + if (Projectile.ai[2] > 0) + { + float animationTime = Projectile.localAI[0]; + + if (animationTime <= 24) + { + maskOpacity = Utils.GetLerpValue(0f, 24f, animationTime, clamped: true); + } + else + { + maskOpacity = 1f; + } + + if (animationTime >= 35) + { + float scaleFactor = Utils.GetLerpValue(35f, 50f, animationTime, clamped: true); + finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor); + alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor); + } + } + + Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + + if (Projectile.ai[2] > 0) + { + Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/AerSigil.png b/Projectiles/Magic/AerSigil.png new file mode 100644 index 0000000000..2e4c57cf21 Binary files /dev/null and b/Projectiles/Magic/AerSigil.png differ diff --git a/Projectiles/Magic/AerSigilBlast.cs b/Projectiles/Magic/AerSigilBlast.cs new file mode 100644 index 0000000000..6a67675d83 --- /dev/null +++ b/Projectiles/Magic/AerSigilBlast.cs @@ -0,0 +1,33 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AerSigilBlast : BaseMassiveExplosionProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override int Lifetime => 28; + public override bool UsesScreenshake => true; + public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 5.5f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.LightGoldenrodYellow, Color.Yellow, MathHelper.Clamp(pulseCompletionRatio * 2f, 0f, 1f)); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 2; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.timeLeft = Lifetime; + Projectile.DamageType = DamageClass.Magic; + } + + public override void PostAI() + { + Lighting.AddLight(Projectile.Center, 0, Projectile.Opacity * 0.8f / 255f, Projectile.Opacity); + } + } +} diff --git a/Projectiles/Magic/AerSigilFeather.cs b/Projectiles/Magic/AerSigilFeather.cs new file mode 100644 index 0000000000..073ec1f09d --- /dev/null +++ b/Projectiles/Magic/AerSigilFeather.cs @@ -0,0 +1,73 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using System; + +namespace CalamityMod.Projectiles.Magic +{ + // This projectile is intended to be a simple VFX projectile. + public class AerSigilFeather : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private float extraRotation = 0; + private float intervalModifier = 1f; + private bool randomized = false; + + public override void SetDefaults() + { + Projectile.width = 151; + Projectile.height = 205; + Projectile.scale = 0.15f; + + Projectile.friendly = false; + Projectile.tileCollide = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 170; + } + public override void AI() + { + // Fade out + if (Projectile.timeLeft < 50) + { + Projectile.alpha = (int)(255 - (255f / 50f) * Projectile.timeLeft); + } + + + // Attempts to replicate the motion of a feather swaying in wind + float blendProgress = (170f - Projectile.timeLeft) / (170f - 100f); + blendProgress = Math.Min(blendProgress, 1f); + + if (!randomized) + { + extraRotation = Main.rand.NextFloat(0, MathHelper.TwoPi); + intervalModifier = Main.rand.NextFloat(0.815f, 1.225f); + randomized = true; + } + + Vector2 newFeatherVelocity = Vector2.Zero; + newFeatherVelocity.Y = Projectile.velocity.Y * 0.96f + 0.04f; + newFeatherVelocity.X = 1.4f * (float)Math.Cos(Projectile.timeLeft * 0.035f * intervalModifier); // The first float is effectively magnitude + + + float newFeatherRotation = extraRotation + (float)Math.Sin(Projectile.timeLeft * 0.035f); + + + Projectile.velocity = Vector2.Lerp(Projectile.velocity, newFeatherVelocity, blendProgress); + Projectile.rotation = MathHelper.Lerp(Projectile.rotation, newFeatherRotation, blendProgress); + + + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity = Vector2.Zero; + return false; + } + public override bool PreDraw(ref Color lightColor) + { + lightColor = Color.LightGoldenrodYellow * 0.5f; + return true; + } + } +} diff --git a/Projectiles/Magic/AerSigilFeather.png b/Projectiles/Magic/AerSigilFeather.png new file mode 100644 index 0000000000..c3ad5b66c5 Binary files /dev/null and b/Projectiles/Magic/AerSigilFeather.png differ diff --git a/Projectiles/Magic/AerSigilMissile.cs b/Projectiles/Magic/AerSigilMissile.cs new file mode 100644 index 0000000000..a97417bf7b --- /dev/null +++ b/Projectiles/Magic/AerSigilMissile.cs @@ -0,0 +1,236 @@ +using System; +using System.Linq; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Magic +{ + public class AerSigilMissile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static float MaxWidth = 32; + public ref float Time => ref Projectile.ai[0]; + + private int wingAnimationTimer = 0; + private const int wingAnimationDuration = 80; + + public static Asset BloomTex; + public static Asset SlashTex; + public static Asset TrailTex; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 12; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 40; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.ignoreWater = true; + Projectile.tileCollide = true; + Projectile.penetrate = 1; + Projectile.alpha = 255; + Projectile.timeLeft = 420; + Projectile.usesLocalNPCImmunity = true; + + // Makes trail draw right away + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Projectile.oldPos[i] = Projectile.position; + } + } + + public override void AI() + { + // Little bit of ambient lighting as it travels + Lighting.AddLight(Projectile.Center, Color.LightGoldenrodYellow.ToVector3() * 0.4f); + + Projectile.rotation = Projectile.velocity.ToRotation(); + + if (Projectile.FinalExtraUpdate()) + Time++; + + // Required in addition to the SetDefaults loop because otherwise the funny drawing from (0,0) error happens + if (Projectile.localAI[0] == 0f) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Projectile.oldPos[i] = Projectile.position; + } + Projectile.localAI[0] = 1f; + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + for (int i = 0; i < 8; i++) + { + float variance = Main.rand.NextFloat(-0.6f, 0.6f); + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(target.Center, dustStyle); + dust2.scale = Main.rand.NextFloat(1.2f, 1.9f) - Math.Abs(variance); + dust2.velocity = (Projectile.velocity * 1.5f).RotatedBy(variance) * Main.rand.NextFloat(1f, 1.6f) * (1 - Math.Abs(variance)); + dust2.noGravity = true; + dust2.color = Color.Lerp(Color.LightGoldenrodYellow, Color.Orange, Main.rand.NextFloat(0f, 1f)); + } + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/AerSigilGust") { Volume = 0.6f, PitchVariance = 0.1f }, Projectile.Center); + + Vector2 adjustedCenter = Projectile.Center - Main.screenPosition + new Vector2(0, -16).RotatedBy(Projectile.rotation - MathHelper.PiOver2); + + for (int i = 0; i < 11; i++) + { + float randomAngle = Main.rand.NextFloat(MathHelper.TwoPi); + float randomSpeed = Main.rand.NextFloat(6, 10); + Vector2 vel = new Vector2((float)Math.Cos(randomAngle) * randomSpeed, (float)Math.Sin(randomAngle) * randomSpeed); + vel.X *= 3f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + + + if (Projectile.owner == Main.myPlayer) + { + Projectile explosion = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 4.25f), Projectile.knockBack * 6, Projectile.owner); + explosion.ai[1] = 600f; + explosion.localAI[1] = Main.rand.NextFloat(0.1f, 0.2f); // Interpolate + explosion.netUpdate = true; + } + + Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Goldenrod * 0.75f, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.1f, 0.6f * 2.5f, 15); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White * 0.75f, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.1f, 0.5f * 2.5f, 15); + GeneralParticleHandler.SpawnParticle(orb2); + + } + + public override Color? GetAlpha(Color lightColor) => Color.Lerp(Color.LightGoldenrodYellow, Color.Orange, 0.5f) with { A = 0 } * Projectile.Opacity; + + public float TrailWidth(float completionRatio, Vector2 vertexPos) + { + float width = Utils.GetLerpValue(1f, 0.4f, completionRatio, true) * (float)Math.Sin(Math.Acos(1 - Utils.GetLerpValue(0f, 0.08f, completionRatio, true))); + width *= Utils.GetLerpValue(0f, 0.1f, Projectile.timeLeft / 600f, true); + return width * (MaxWidth * .265f); + } + public Color TrailColor(float completionRatio, Vector2 vertexPos) + { + Color baseColor = Color.Lerp(Color.LightGoldenrodYellow, Color.Orange, completionRatio); + return baseColor * 0.2f; + } + + public float MiniTrailWidth(float completionRatio, Vector2 vertexPos) => TrailWidth(completionRatio, vertexPos) * 5.5f; + public Color MiniTrailColor(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.LightGoldenrodYellow, Color.Orange, completionRatio); + public override bool PreDraw(ref Color lightColor) + { + Color mainColor = Color.Lerp(Color.LightGoldenrodYellow, Color.Orange, ((float)Main.timeForVisualEffects * 0.5f + Projectile.whoAmI * 0.12f) % 1); + Color secondaryColor = Color.Lerp(Color.LightGoldenrodYellow, Color.Orange, ((float)Main.timeForVisualEffects * 0.5f + Projectile.whoAmI * 0.12f + 0.2f) % 1); + + Vector2 adjustedCenter = Projectile.Center - Main.screenPosition + new Vector2(0, -16).RotatedBy(Projectile.rotation - MathHelper.PiOver2); + + wingAnimationTimer++; + Texture2D wingTexture = Request("CalamityMod/ExtraTextures/SimpleWings").Value; + Vector2 origin = wingTexture.Size() * 0.5f; + + float stretchFactorY = 0f; + + // Only run the animation logic if the timer is within the duration + if (wingAnimationTimer <= wingAnimationDuration) + { + float progress = (float)wingAnimationTimer / wingAnimationDuration; + + if (progress < 0.25f) // Stretch Up + { + float stretchProgress = progress / 0.25f; + stretchFactorY = MathHelper.Lerp(-1.4f, 0.5f, (float)Math.Sin(stretchProgress * MathHelper.PiOver2)); + } + else if (progress < 0.5f) // Squash Down and overadjust + { + float squashProgress = (progress - 0.25f) / 0.3f; + stretchFactorY = MathHelper.Lerp(0.5f, -0.25f, squashProgress * squashProgress); + } + else if (progress < 0.8f) // Stretch up again at a slower pace to a bit above the normal scale + { + float stretchProgress = (progress - 0.6f) / 0.2f; + stretchFactorY = MathHelper.Lerp(-0.25f, 0f, stretchProgress * stretchProgress); + } + else // Return to normal + { + stretchFactorY = 0f; + } + } + + // Calculate scale to display with all factors combined + float baseScale = 1f; + float stretchScaleY = 1f + stretchFactorY; + float stretchScaleX = 1f - (stretchFactorY * 0.5f); + Vector2 finalScale = new Vector2(baseScale * stretchScaleX, baseScale * stretchScaleY) * 0.6f; + + // Draw backglow of wings + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive); + Color glowColor = Color.LightGoldenrodYellow with { A = 0 } * 0.8f; + Main.EntitySpriteDraw(wingTexture, adjustedCenter, null, glowColor, (Projectile.rotation + MathHelper.PiOver2), origin, finalScale * 1.5f, SpriteEffects.None, 0); + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); + + + // Render the trail + Main.spriteBatch.EnterShaderRegion(); + + if (TrailTex == null) + TrailTex = Request("CalamityMod/ExtraTextures/Trails/BasicTrail"); + + GameShaders.Misc["CalamityMod:ExobladePierce"].SetShaderTexture(TrailTex); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseImage2("Images/Extra_189"); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].Apply(); + + Vector2 offset = Projectile.Size * 0.5f; + Vector2[] oldPosWithOffset = Projectile.oldPos.Select(p => p - offset).ToArray(); + + PrimitiveRenderer.RenderTrail(oldPosWithOffset, new(TrailWidth, TrailColor, (_,_) => Projectile.Size * 1f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + + GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); + + PrimitiveRenderer.RenderTrail(oldPosWithOffset, new(MiniTrailWidth, MiniTrailColor, (_,_) => Projectile.Size * 1f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + + Main.spriteBatch.ExitShaderRegion(); + + + // Draw the main texture + Color drawColor = Color.LightGoldenrodYellow * 0.5f; + Main.EntitySpriteDraw(wingTexture, adjustedCenter, null, drawColor, (Projectile.rotation + MathHelper.PiOver2), origin, finalScale, SpriteEffects.None, 0); + + + // Draw bloom circle at the tip + if (BloomTex == null) + BloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle"); + Texture2D bloomTex = BloomTex.Value; + Main.EntitySpriteDraw(bloomTex, adjustedCenter, null, (Color.White * 4f) with { A = 0 }, 0, bloomTex.Size() / 2f, 0.45f * Projectile.scale, 0, 0); + + return false; + } + } +} diff --git a/Projectiles/Magic/AetherBeam.cs b/Projectiles/Magic/AetherBeam.cs index 838d3a474e..a5f0fb487d 100644 --- a/Projectiles/Magic/AetherBeam.cs +++ b/Projectiles/Magic/AetherBeam.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/AetherfluxCannonHoldout.cs b/Projectiles/Magic/AetherfluxCannonHoldout.cs index ae0e2654ae..22726a859c 100644 --- a/Projectiles/Magic/AetherfluxCannonHoldout.cs +++ b/Projectiles/Magic/AetherfluxCannonHoldout.cs @@ -8,7 +8,6 @@ using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; -using static CalamityMod.Systems.LavaRenderingSystem; namespace CalamityMod.Projectiles.Magic { @@ -36,7 +35,7 @@ namespace CalamityMod.Projectiles.Magic { base.KillHoldoutLogic(); bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? AetherfluxCannon.UseTime); - bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem()); + bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.HeldItem); if (!manaOK) Projectile.Kill(); } @@ -74,7 +73,7 @@ namespace CalamityMod.Projectiles.Magic { LastShootAttemptTime = DeployedFrames; bool actuallyShoot = DeployedFrames >= itemUseTime; - bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.HeldItem, -1, true, false); if (manaOK) { if (actuallyShoot) @@ -83,7 +82,7 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire = new("CalamityMod/Sounds/Item/MagnaCannonShot"); SoundEngine.PlaySound(fire with { Volume = 0.4f, Pitch = Main.rand.NextFloat(0.1f, 0.3f) }, Projectile.Center); } - + int projID = ModContent.ProjectileType(); float shootSpeed = HeldItem.shootSpeed; diff --git a/Projectiles/Magic/AlphaDraconisStar.cs b/Projectiles/Magic/AlphaDraconisStar.cs new file mode 100644 index 0000000000..2499326beb --- /dev/null +++ b/Projectiles/Magic/AlphaDraconisStar.cs @@ -0,0 +1,285 @@ +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class AlphaDraconisStar : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 16; + ProjectileID.Sets.TrailingMode[Type] = 1; + } + + public override void SetDefaults() + { + Projectile.width = 22; + Projectile.height = 24; + Projectile.friendly = true; + Projectile.penetrate = 5; + Projectile.DamageType = DamageClass.Magic; + Projectile.extraUpdates = 4; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; + Projectile.scale = 0.5f; + Projectile.tileCollide = false; + Projectile.timeLeft = Projectile.MaxUpdates * 300; + Projectile.stopsDealingDamageAfterPenetrateHits = true; + } + + public override void OnSpawn(IEntitySource source) + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + } + + NPC target = null; + Player closestPlayer = null; + public override void AI() + { + Vector2 goalPos = new Vector2(Projectile.ai[0], Projectile.ai[1]); + float velLength = Projectile.velocity.Length(); + if (Projectile.ai[2] == 0) + { + float maxDist = 57600; //240^2 + if (Projectile.FinalExtraUpdate()) + { + target = null; + foreach (var item in Main.ActiveNPCs) + { + if (item.CanBeChasedBy(item) && item.DistanceSQ(goalPos) < maxDist) + { + maxDist = item.DistanceSQ(goalPos); + target = item; + } + } + } + if (target != null) + { + if (target.active) + { + goalPos = target.Center; + Projectile.ai[0] = goalPos.X; + Projectile.ai[1] = goalPos.Y; + Projectile.Calamity().HomingTarget = target.whoAmI; + } + else + { + target = null; + } + } else + { + Projectile.Calamity().HomingTarget = -1; + } + + Projectile.velocity += Projectile.DirectionTo(goalPos); + Projectile.velocity.Normalize(); + if (Projectile.velocity.HasNaNs()) + Projectile.velocity = Vector2.UnitY; + Projectile.velocity *= velLength; + + if (Projectile.Center.Y > goalPos.Y + 100) + Projectile.ai[2] = 1; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + else + { + Projectile.Calamity().HomingTarget = -1; + Projectile.velocity *= 0.98f; + if (Projectile.velocity.Length() < 1 && Projectile.ai[2] == 1) + Projectile.Kill(); + if (Projectile.ai[2] == 2) + { + Projectile.rotation += 0.05f; + Projectile.scale = MathHelper.Min(Projectile.scale + 0.02f, 1); + if (Projectile.FinalExtraUpdate()) + { + closestPlayer = null; + float closestDis = 320*320; + foreach (var player in Main.ActivePlayers) + { + var dis = Projectile.DistanceSQ(player.Center); + if (dis < closestDis) + { + closestDis = dis; + closestPlayer = player; + } + } + } + if (closestPlayer != null) + { + Projectile.velocity += Projectile.DirectionTo(closestPlayer.Center); + if (Projectile.Distance(closestPlayer.Center) < 32) + { + closestPlayer.Calamity().StratusStarburst++; + Projectile.Kill(); + } + } + } + } + + // Emit a small amount of dust while traveling + if (Main.rand.NextBool(10)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Effects.ArsenalEffects.ArsenalPlasmaDust, -Projectile.velocity); + dust.scale = Main.rand.NextFloat(0.4f, 1f); + dust.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.7f); + dust.noGravity = true; + dust.color = Color.CadetBlue; + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[2] == 0) + { + if (Main.rand.NextFloat() <= 0.33f) //33% chance to become pick-up-able stars + { + Projectile.ai[2] = 2; + Projectile.timeLeft = 600 * Projectile.MaxUpdates; + } + else + Projectile.ai[2] = 1; + Projectile.velocity *= Main.rand.NextFloat(0.9f, 1.1f); + Projectile.netUpdate = true; + } + } + + public override void OnKill(int timeLeft) + { + if (Projectile.ai[2] == 2) + return; + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), -Projectile.velocity); + dust.scale = Main.rand.NextFloat(0.4f, 0.6f); + dust.velocity = (new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f)); + dust.color = Color.CadetBlue; + } + } + + + + + public override bool PreDraw(ref Color lightColor) + { + // Glow FX + Texture2D mainTexture = ModContent.Request(Texture).Value; + SpriteEffects spriteEffects = SpriteEffects.None; + + Vector2 drawOrigin = mainTexture.Size() / 2f; + float drawScale = Projectile.scale; + float drawRotation = Projectile.rotation; + Vector2 drawPosition; + + float glowSine = ((float)Math.Sin(Main.GlobalTimeWrappedHourly * 14f) + 1f) / 2f; + float pulse = MathHelper.Lerp(0.25f, 0.8f, glowSine); // Least protruding to most protruding + drawPosition = Projectile.Center - Main.screenPosition; + + for (int i = 0; i < 12; i++) + { + Vector2 unitVector = (MathHelper.TwoPi * i / 12f).ToRotationVector2(); + + Vector2 innerOffset = unitVector * (1.4f * pulse); + Main.spriteBatch.Draw(mainTexture, drawPosition + innerOffset, null, Color.SkyBlue with { A = 0 } * 0.225f, drawRotation, drawOrigin, drawScale, spriteEffects, 0f); + + Vector2 outerOffset = unitVector * (1.75f * pulse); + Main.spriteBatch.Draw(mainTexture, drawPosition + outerOffset, null, Color.DeepSkyBlue with { A = 0 } * 0.1f, drawRotation, drawOrigin, drawScale, spriteEffects, 0f); + } + + // Trail rendering + Main.spriteBatch.End(out var ss); + + var device = Main.instance.GraphicsDevice; + using var lease = RenderTargetPool.Shared.Rent( + device, + Main.screenWidth / 2, + Main.screenHeight / 2, + RenderTargetDescriptor.Default + ); + + using (lease.Scope(clearColor: Color.Transparent)) + { + if (Projectile.velocity.Length() > 1) // Will otherwise cause noticeable frame drops + { + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), Projectile.oldPos.Length + 32); + + Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), fireCoreLength.Length + 24); + } + } + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); + Main.spriteBatch.End(); + + Main.spriteBatch.Begin(ss); + return false; + } + + public float FireWidthFunction(float completion, Vector2 pos) + { + float width; + float maxBodyWidth = 32f * Projectile.scale; + float curveRatio = 0.05f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + // Crop the tip of the trail into a conic shape. + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireColorFunction(float completion, Vector2 pos) + { + Color mainColor = Color.CadetBlue * 1.1f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; + } + + public float FireCoreWidthFunction(float completion, Vector2 pos) + { + float width; + float maxBodyWidth = Projectile.scale * 8; + float curveRatio = 0.1f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireCoreColorFunction(float completion, Vector2 pos) + { + Color mainColor = Color.CadetBlue; + Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.2f, 1f, completion, true)); + Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); + return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity; + } + } +} diff --git a/Projectiles/Magic/ClamorNoctusStar.png b/Projectiles/Magic/AlphaDraconisStar.png similarity index 100% rename from Projectiles/Magic/ClamorNoctusStar.png rename to Projectiles/Magic/AlphaDraconisStar.png diff --git a/Projectiles/Magic/AnahitasArpeggioNote.cs b/Projectiles/Magic/AnahitasArpeggioNote.cs index 3aa60a7fb8..7f1ce0a0c8 100644 --- a/Projectiles/Magic/AnahitasArpeggioNote.cs +++ b/Projectiles/Magic/AnahitasArpeggioNote.cs @@ -1,6 +1,8 @@ using CalamityMod.Items.Weapons.Magic; +using CalamityMod.NPCs; using CalamityMod.Systems; using Microsoft.Xna.Framework; +using ReLogic.Utilities; using System; using System.IO; using Terraria; @@ -10,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException(onlyForSingleHitbox: true)] public class AnahitasArpeggioNote : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -20,7 +23,9 @@ namespace CalamityMod.Projectiles.Magic public int LingeringTime = 300; public int FadeOutTime = 20; public bool HasSetFadeOutVelocity = false; + public Vector2 ReleaseCenterPoint = Vector2.Zero; public float _randomReleaseRotationOffset; + public SlotId StupidEasterEggSlot; public Player Owner => Main.player[Projectile.owner]; @@ -61,8 +66,23 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] = 0f; } + // Sound business if (Timer == 1f) - SoundEngine.PlaySound(new("CalamityMod/Sounds/Item/HarpLV" + Math.Clamp((int)NoteSequence + 1, 1, 6)), Owner.Center); + { + if (Main.zenithWorld) + { + if (NoteSequence == 0f) + StupidEasterEggSlot = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/GFB/SevenTrebleClefSouls"), Owner.Center); + } + else + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/HarpLV" + Math.Clamp((int)NoteSequence + 1, 1, 6)) with { Volume = 0.8f }, Owner.Center); + } + // They did not obey me + // Big shoutouts to NotRyo for making this Finale remix out of harp notes + if (Main.zenithWorld && NoteSequence == 0f && Timer % 2428f == 0f && AIState == 0f) + StupidEasterEggSlot = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/GFB/SevenTrebleClefSouls"), Owner.Center); + if (SoundEngine.TryGetActiveSound(StupidEasterEggSlot, out var TrebleSoul) && TrebleSoul.IsPlaying) + TrebleSoul.Position = Owner.Center; if (Main.zenithWorld) Lighting.AddLight(Projectile.Center, 1.25f, 1.25f, 1.25f); @@ -76,7 +96,7 @@ namespace CalamityMod.Projectiles.Magic // Makes the music notes appear to orbit around the player float baseRotationSpeed = Main.zenithWorld ? 0.857142f : 1f; - float rotationSpeed = baseRotationSpeed * (60f / Owner.ActiveItem().useTime); + float rotationSpeed = baseRotationSpeed * (60f / Owner.HeldItem.useTime); Projectile.Center = Owner.Center + new Vector2(80, 0).RotatedBy(MathHelper.ToRadians(Timer * rotationSpeed)); // If the player stops using the weapon or does not have enough mana, switch to fade away mode @@ -112,12 +132,19 @@ namespace CalamityMod.Projectiles.Magic Vector2 mouse = Owner.ClampedMouseWorld(); Projectile.Center = mouse + musicNoteRotationOffset * 220f; + ReleaseCenterPoint = mouse; playerDirection = Projectile.Center - mouse; playerDirection.Normalize(); - playerDirection *= -9.2f; + playerDirection *= -13f; Projectile.velocity = playerDirection; - SoundEngine.PlaySound(AnahitasArpeggio.EndSound, Projectile.Center); + if (Main.zenithWorld) + { + if (SoundEngine.TryGetActiveSound(StupidEasterEggSlot, out var Flowey)) + Flowey?.Stop(); + } + else + SoundEngine.PlaySound(AnahitasArpeggio.EndSound with { Volume = 0.8f }, Projectile.Center); AIState = 2f; } } @@ -140,9 +167,18 @@ namespace CalamityMod.Projectiles.Magic // Slow down quickly if (Projectile.velocity.Length() > 0.5f) - Projectile.velocity *= 0.95f; + Projectile.velocity *= 0.925f; else + { Projectile.velocity = Vector2.Zero; + + // Makes the notes slowly follow the mouse and rotate + Vector2 centerPointDirection = (Owner.Calamity().mouseWorld - ReleaseCenterPoint).SafeNormalize(Vector2.Zero); + float distToMove = MathF.Min(5.75f, Vector2.Distance(Owner.Calamity().mouseWorld, ReleaseCenterPoint)); // The constant value is the maximum chase speed + ReleaseCenterPoint += centerPointDirection * distToMove; + Projectile.Center += centerPointDirection * distToMove; + Projectile.Center = ReleaseCenterPoint + Utils.DirectionTo(ReleaseCenterPoint, Projectile.Center).RotatedBy(MathHelper.Pi * 0.01f) * Vector2.Distance(ReleaseCenterPoint, Projectile.Center); + } } } @@ -200,7 +236,6 @@ namespace CalamityMod.Projectiles.Magic } public override void SendExtraAI(BinaryWriter writer) => writer.Write(_randomReleaseRotationOffset); - public override void ReceiveExtraAI(BinaryReader reader) => _randomReleaseRotationOffset = reader.ReadSingle(); } } diff --git a/Projectiles/Magic/ApoctosisArrayHoldout.cs b/Projectiles/Magic/ApoctosisArrayHoldout.cs index 6e4ab6c4d4..61c854a9f0 100644 --- a/Projectiles/Magic/ApoctosisArrayHoldout.cs +++ b/Projectiles/Magic/ApoctosisArrayHoldout.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic return; } - if (HeldItem.type != Owner.ActiveItem().type) + if (HeldItem.type != Owner.HeldItem.type) { if (manaPower > 0) shootingTimer = -75; @@ -216,7 +216,7 @@ namespace CalamityMod.Projectiles.Magic float manaPercent = ((float)Owner.statMana / (float)Owner.statManaMax2); Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); Vector2 firingVelocity = (shootDirection * 4); - float damageBoost = Math.Max((manaPower * 55) * (manaPower >= 1 ? 1.3f : 1f), 1); + float damageBoost = Math.Max((manaPower * 60) * (manaPower >= 1 ? 1.5f : 1f), 1); if (big) { @@ -232,7 +232,7 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire2 = new("CalamityMod/Sounds/Item/PulseRifleFire"); SoundEngine.PlaySound(fire2 with { Volume = 0.75f, Pitch = (manaPower >= 1 ? 0.7f : 0.5f) }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 12f * manaPower; + Owner.SetScreenshake(12f * manaPower); float projSpeedMult = (manaPower + 0.4f) * (manaPower >= 1 ? 3f : 2f); float variance = Main.rand.NextFloat(-0.8f, 0.8f); diff --git a/Projectiles/Magic/ApoctosisBlast.cs b/Projectiles/Magic/ApoctosisBlast.cs index 55327155f1..89781e04db 100644 --- a/Projectiles/Magic/ApoctosisBlast.cs +++ b/Projectiles/Magic/ApoctosisBlast.cs @@ -60,8 +60,8 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - float minMult = 0.2f; - int hitsToMinMult = 15; + float minMult = 0.35f; + int hitsToMinMult = 10; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; @@ -70,10 +70,6 @@ namespace CalamityMod.Projectiles.Magic Particle sparks = new SparkParticle(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.7f) * Main.rand.NextFloat(7, 25), false, 35, Main.rand.NextFloat(0.5f, 0.9f), Main.rand.NextBool() ? Color.Lerp(Color.Crimson, Color.White, 0.5f) : Color.Crimson); GeneralParticleHandler.SpawnParticle(sparks); } - } - public override void OnKill(int timeLeft) - { - } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { diff --git a/Projectiles/Magic/ApotheosisEnergy.cs b/Projectiles/Magic/ApotheosisEnergy.cs index 7aa7bea46c..7b9c610e55 100644 --- a/Projectiles/Magic/ApotheosisEnergy.cs +++ b/Projectiles/Magic/ApotheosisEnergy.cs @@ -1,11 +1,13 @@ using System; using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class ApotheosisEnergy : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -50,7 +52,7 @@ namespace CalamityMod.Projectiles.Magic } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { Color baseColor = Color.Cyan; if (completionRatio > 0.66f) @@ -67,7 +69,7 @@ namespace CalamityMod.Projectiles.Magic return colorToUse * Projectile.Opacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float width; float maxWidthOutwardness = 6f; @@ -90,7 +92,7 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f), 85); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f), 85); return false; } } diff --git a/Projectiles/Magic/ApotheosisWorm.cs b/Projectiles/Magic/ApotheosisWorm.cs index 43f9c166df..2d2b200bac 100644 --- a/Projectiles/Magic/ApotheosisWorm.cs +++ b/Projectiles/Magic/ApotheosisWorm.cs @@ -2,7 +2,7 @@ using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -12,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class ApotheosisWorm : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -177,7 +178,7 @@ namespace CalamityMod.Projectiles.Magic // This variant of segment attachment incorporates rotation. // Given the fact that all segments will execute this code is succession, the // result across the entire worm will exponentially decay over each segment, - // allowing for smooth rotations. This code is what the stardust dragon and mechworm use for their segmenting. + // allowing for smooth rotations. This code is what the stardust dragon and Void Eater Marionette use for their segmenting. if (aheadSegmentRotation != Segments[segmentIndex].Rotation) { float offsetAngle = MathHelper.WrapAngle(aheadSegmentRotation - Segments[segmentIndex].Rotation); @@ -200,7 +201,7 @@ namespace CalamityMod.Projectiles.Magic } if (Main.rand.NextBool(10)) - SoundEngine.PlaySound(GaussRifle.FireSound, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MechGaussRifle"), Projectile.Center); } float idealFlyAcceleration = 0.18f; @@ -272,8 +273,8 @@ namespace CalamityMod.Projectiles.Magic Vector2 jawOrigin = jawTexture.Size() * 0.5f; // Segment drawing. - Texture2D bodyTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS").Value; - Texture2D tailTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS").Value; + Texture2D bodyTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBody_P2").Value; + Texture2D tailTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_P2").Value; // Not white to differentiate itself slightly from regular DoG when fighting Boss Rush. Color baseColor = Color.Lerp(Color.White, Color.Fuchsia, 0.15f); diff --git a/Projectiles/Magic/AquaSigil.cs b/Projectiles/Magic/AquaSigil.cs new file mode 100644 index 0000000000..45a03ce786 --- /dev/null +++ b/Projectiles/Magic/AquaSigil.cs @@ -0,0 +1,113 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Magic +{ + public class AquaSigil : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private bool spawnedProjectile = false; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 74; + Projectile.friendly = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)Projectile.ai[0]]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive && Projectile.ai[2] == 0) + { + Projectile.Kill(); + return; + } + + int i = (int)Projectile.ai[1]; + float dist = i % 3 == 0 ? 270f : 280f; + float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f); + + Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot); + Projectile.Center = sigilPos; + + if (Projectile.ai[2] > 0) + { + Projectile.localAI[0]++; + + if (Projectile.localAI[0] == 35 && !spawnedProjectile) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/AquaSigilShot") { Volume = 1.5f, PitchVariance = 0.1f }, Projectile.Center); + + Player owner = Main.player[Projectile.owner]; + Vector2 targetDirection = Projectile.Center.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX); + + spawnedProjectile = true; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, targetDirection * 29f, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); + } + + if (Projectile.localAI[0] >= 50) + { + Projectile.Kill(); + } + } + else + { + Projectile.scale = parent.scale; + Projectile.rotation = 0; + Projectile.alpha = parent.alpha; + } + + if (parentActive) + { + Projectile.timeLeft = parent.timeLeft; + } + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D blankTexture = ModContent.Request("CalamityMod/Projectiles/Magic/BlankSigil").Value; + + float finalScale = Projectile.scale; + float alphaOpacity = 1f - (Projectile.alpha / 255f); + float maskOpacity = 0f; + + // Apply animation effects if fading + if (Projectile.ai[2] > 0) + { + float animationTime = Projectile.localAI[0]; + + if (animationTime <= 24) + { + maskOpacity = Utils.GetLerpValue(0f, 24f, animationTime, clamped: true); + } + else + { + maskOpacity = 1f; + } + + if (animationTime >= 35) + { + float scaleFactor = Utils.GetLerpValue(35f, 50f, animationTime, clamped: true); + finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor); + alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor); + } + } + + Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + + if (Projectile.ai[2] > 0) + { + Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/AquaSigil.png b/Projectiles/Magic/AquaSigil.png new file mode 100644 index 0000000000..41022e4db5 Binary files /dev/null and b/Projectiles/Magic/AquaSigil.png differ diff --git a/Projectiles/Magic/AquaSigilWaterball.cs b/Projectiles/Magic/AquaSigilWaterball.cs new file mode 100644 index 0000000000..3b37d92670 --- /dev/null +++ b/Projectiles/Magic/AquaSigilWaterball.cs @@ -0,0 +1,131 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class AquaSigilWaterball : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public ref float Time => ref Projectile.ai[0]; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 6; + } + + public override void SetDefaults() + { + Projectile.width = 108; + Projectile.height = 94; + Projectile.friendly = true; + Projectile.penetrate = -1; // Explodes on a delay after hitting +            Projectile.DamageType = DamageClass.Magic; + Projectile.timeLeft = 300; + Projectile.alpha = 255; + Projectile.tileCollide = false; + } + + public override void AI() + { + Time++; + Projectile.Opacity = Utils.GetLerpValue(0f, 10f, Time, true); + +            // Hasnt hit anything +            if (Projectile.ai[1] == 0) + { +                // Set rotation to face forward +                Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + + Projectile.frameCounter++; + if (Projectile.frameCounter % 4 == 3) + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; + } + else // After hit +            { +                Projectile.velocity = Vector2.Zero; + +                // Scale up and die +                Projectile.scale += 0.05f; + if (Projectile.scale >= 1.25f) + { + Projectile.Kill(); + } +                // Failsafe +                if (Projectile.timeLeft > 5) + { + Projectile.timeLeft = 5; + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + // Normal sprite + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + + // All-white variant + Asset ghostTexture = ModContent.Request("CalamityMod/Projectiles/Magic/AquaSigilWaterballGhost"); + + Color drawColor = Projectile.GetAlpha(lightColor); + + // NORMAL draw logic + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame), drawColor, Projectile.rotation, new Vector2(49, 160), Projectile.scale, SpriteEffects.None, 0); + + // After hitting a target, draw the white variant + if (Projectile.ai[1] > 0) + { + // Fade from normal to fully white + float fadeFactor = Utils.GetLerpValue(5f, 0f, Projectile.timeLeft, true); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive); + + Main.EntitySpriteDraw(ghostTexture.Value, Projectile.Center - Main.screenPosition, texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame), Color.White * fadeFactor, Projectile.rotation, new Vector2(49, 160), Projectile.scale * (1f + fadeFactor * 0.2f), SpriteEffects.None, 0); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); + } + + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 240); + Projectile.ai[1] = 1; // Has hit an enemy +            Projectile.penetrate = -1; + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/AquaSigilExplosion") { Volume = 1f, PitchVariance = 0.1f }, Projectile.Center); + + for (int i = 0; i < 40; i++) + { + Vector2 vel = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.85f, 1.2f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + (new Vector2(Main.rand.NextFloat(-22, -30), Main.rand.NextFloat(-4, 4)).RotatedBy(Projectile.rotation - MathHelper.PiOver2)), Main.rand.NextBool(5) ? 187 : 180, vel * Main.rand.NextFloat(0.1f, 0.9f) + new Vector2(0, -2)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(1.1f, 1.7f); + } + + for (int i = 0; i < 8; i++) + { + Vector2 vel = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.85f, 1.2f); + Projectile droplets = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center + (new Vector2(Main.rand.NextFloat(-22, -30), Main.rand.NextFloat(-4, 4)).RotatedBy(Projectile.rotation - MathHelper.PiOver2)), vel * 0.8f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + + if (Projectile.owner == Main.myPlayer) + { + Projectile explosion = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center + (new Vector2(-26, 0).RotatedBy(Projectile.rotation - MathHelper.PiOver2)), Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 3.85f), Projectile.knockBack, Projectile.owner); + explosion.ai[1] = 260f; +                explosion.localAI[1] = Main.rand.NextFloat(0.1f, 0.2f); // Interpolate +                explosion.netUpdate = true; + } + } + } +} diff --git a/Projectiles/Magic/AquaSigilWaterball.png b/Projectiles/Magic/AquaSigilWaterball.png new file mode 100644 index 0000000000..68ebd28acc Binary files /dev/null and b/Projectiles/Magic/AquaSigilWaterball.png differ diff --git a/Projectiles/Magic/AquaSigilWaterballExplosion.cs b/Projectiles/Magic/AquaSigilWaterballExplosion.cs new file mode 100644 index 0000000000..0151b4add1 --- /dev/null +++ b/Projectiles/Magic/AquaSigilWaterballExplosion.cs @@ -0,0 +1,33 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class AquaSigilWaterballExplosion : BaseMassiveExplosionProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override int Lifetime => 26; + public override bool UsesScreenshake => true; + public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 3f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.DarkTurquoise, Color.MediumTurquoise, MathHelper.Clamp(pulseCompletionRatio * 2f, 0f, 1f)); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 2; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.timeLeft = Lifetime; + Projectile.DamageType = DamageClass.Magic; + } + + public override void PostAI() + { + Lighting.AddLight(Projectile.Center, 0, Projectile.Opacity * 0.3f / 255f, Projectile.Opacity); + } + } +} diff --git a/Projectiles/Magic/AquaSigilWaterballGhost.png b/Projectiles/Magic/AquaSigilWaterballGhost.png new file mode 100644 index 0000000000..35c6fcbe39 Binary files /dev/null and b/Projectiles/Magic/AquaSigilWaterballGhost.png differ diff --git a/Projectiles/Magic/AquaSigilWaterdroplet.cs b/Projectiles/Magic/AquaSigilWaterdroplet.cs new file mode 100644 index 0000000000..041b600a89 --- /dev/null +++ b/Projectiles/Magic/AquaSigilWaterdroplet.cs @@ -0,0 +1,83 @@ +using System; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class AquaSigilWaterdroplet : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 9; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 32; + Projectile.friendly = false; // This is VFX + Projectile.ignoreWater = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.damage = 0; // This is VFX + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); + Projectile.scale -= 0.01f; + + if (Projectile.scale <= 0f) + { + Projectile.Kill(); + } + + if (Projectile.ai[0] <= 3f) + { + Projectile.ai[0] += 1f; + return; + } + + // Gravity! + Projectile.velocity.Y = Projectile.velocity.Y + 0.35f; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + int frameHeight = texture.Height / Main.projFrames[Type]; + Rectangle sourceRect = new Rectangle(0, frameHeight * Projectile.frame, texture.Width, frameHeight); + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, sourceRect, Color.White, Projectile.rotation, sourceRect.Size() * 0.5f, 1f, 0); + return false; + } + + // Handle the projectile's trail from here + private float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Lerp(0f, MathHelper.Lerp(Projectile.scale * 48f, 0f, completionRatio), MathF.Pow(completionRatio, 1f / 2.5f)); + private Color ColorFunction(float completionRatio, Vector2 vertexPos) + { + float offsetTime = Main.GlobalTimeWrappedHourly; + float fadeOpacity = Utils.GetLerpValue(0.5f, 0f, completionRatio, true) * Projectile.Opacity; + Color endColor = Color.LightSkyBlue; + return Color.Lerp(endColor, Color.White, completionRatio) * fadeOpacity; + } + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32); + GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Projectile.Center, Projectile.velocity, false, 2, Projectile.scale * 1.525f, Color.LightSkyBlue), pixelate: true); + } + } +} diff --git a/Projectiles/Magic/AquamarineBolt.cs b/Projectiles/Magic/AquamarineBolt.cs index 2a0aedf884..26286550e9 100644 --- a/Projectiles/Magic/AquamarineBolt.cs +++ b/Projectiles/Magic/AquamarineBolt.cs @@ -108,12 +108,12 @@ namespace CalamityMod.Projectiles.Magic } public override Color? GetAlpha(Color lightColor) => Color.White; - public float PrimitiveWidthFunction(float completionRatio) + public float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { return (1 - completionRatio) * 20 * Projectile.scale; } - public Color PrimitiveColorFunction(float completionRatio) + public Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { return Color.Lerp(new Color(86, 176, 240), Color.Azure, (float)Math.Pow(completionRatio, 1.5D)) * 0.6f * Projectile.Opacity; } @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Magic Main.spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Vector2.Zero, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 66); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Vector2.Zero, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 66); Main.spriteBatch.ExitShaderRegion(); Main.EntitySpriteDraw(TextureAssets.Projectile[Type].Value, Projectile.position - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * Projectile.Opacity, Projectile.rotation, Projectile.getRect().Size() * 0.5f, Projectile.scale, 0, 0); diff --git a/Projectiles/Magic/ArtAttackHoldout.cs b/Projectiles/Magic/ArtAttackHoldout.cs index f6011b65a7..3593087353 100644 --- a/Projectiles/Magic/ArtAttackHoldout.cs +++ b/Projectiles/Magic/ArtAttackHoldout.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Magic int attackType = ModContent.ProjectileType(); if (Owner.ownedProjectileCounts[attackType] == 0) { - if (Projectile.ai[0] >= 0f && Owner.CheckMana(Owner.ActiveItem(), -1, true, false)) + if (Projectile.ai[0] >= 0f && Owner.CheckMana(Owner.HeldItem, -1, true, false)) { SoundEngine.PlaySound(ArtAttack.UseSound, Owner.Center); Vector2 initialStarVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15f; diff --git a/Projectiles/Magic/ArtAttackStar.cs b/Projectiles/Magic/ArtAttackStar.cs index e1da468182..a69ca4e9c8 100644 --- a/Projectiles/Magic/ArtAttackStar.cs +++ b/Projectiles/Magic/ArtAttackStar.cs @@ -123,7 +123,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < 3; i++) { - Dust rainbowMagic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), 261); + Dust rainbowMagic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), DustID.AncientLight); rainbowMagic.velocity = Main.rand.NextVector2Circular(6f, 6f) - ((Projectile.position - Projectile.oldPos[1]) / 3f).RotatedByRandom(0.51f); rainbowMagic.color = Main.hslToRgb(Main.rand.NextFloat(), 1f, Main.rand.NextFloat(0.5f, 0.9f)); rainbowMagic.color.A = 128; @@ -191,7 +191,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < 60; i++) { - Dust rainbowMagic = Dust.NewDustPerfect(dustSpawnPosition + Main.rand.NextVector2Circular(12f, 12f), 267); + Dust rainbowMagic = Dust.NewDustPerfect(dustSpawnPosition + Main.rand.NextVector2Circular(12f, 12f), DustID.RainbowMk2); rainbowMagic.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 9.5f); rainbowMagic.color = Main.hslToRgb(Main.rand.NextFloat(), 1f, Main.rand.NextFloat(0.5f, 0.9f)); rainbowMagic.color.A = 100; @@ -203,7 +203,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) => CreateDustExplosionEffect(Projectile.Center); - public Color TrailColor(float completionRatio) + public Color TrailColor(float completionRatio, Vector2 vertexPos) { float hue = (Main.GlobalTimeWrappedHourly * -0.62f + completionRatio * 1.5f) % 1f; float brightness = MathHelper.SmoothStep(0.5f, 1f, Utils.GetLerpValue(0.3f, 0f, completionRatio, true)); @@ -213,7 +213,7 @@ namespace CalamityMod.Projectiles.Magic return color; } - public float TrailWidth(float completionRatio) + public float TrailWidth(float completionRatio, Vector2 vertexPos) { float widthInterpolant = Utils.GetLerpValue(0f, 0.25f, completionRatio, true) * Utils.GetLerpValue(1.1f, 0.7f, completionRatio, true); return MathHelper.SmoothStep(8f, 20f, widthInterpolant); @@ -226,10 +226,10 @@ namespace CalamityMod.Projectiles.Magic Vector2 origin = texture.Size() * 0.5f; Main.spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:ArtAttack"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + GameShaders.Misc["CalamityMod:ArtAttack"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); GameShaders.Misc["CalamityMod:ArtAttack"].Apply(); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ArtAttack"]), 180); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ArtAttack"]), 180); Main.spriteBatch.ExitShaderRegion(); Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(Color.White), Projectile.rotation, origin, Projectile.scale, 0, 0); diff --git a/Projectiles/Magic/Asteroid.cs b/Projectiles/Magic/Asteroid.cs deleted file mode 100644 index f481a41547..0000000000 --- a/Projectiles/Magic/Asteroid.cs +++ /dev/null @@ -1,126 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Magic -{ - public class Asteroid : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 8; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 24; - Projectile.height = 24; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Magic; - Projectile.extraUpdates = 2; - } - - public override void AI() - { - if (Projectile.position.Y > Main.player[Projectile.owner].position.Y - 300f) - { - Projectile.tileCollide = true; - } - if ((double)Projectile.position.Y < Main.worldSurface * 16.0) - { - Projectile.tileCollide = true; - } - Projectile.scale = Projectile.ai[1]; - Projectile.rotation += Projectile.velocity.X * 2f; - Vector2 position = Projectile.Center + Vector2.Normalize(Projectile.velocity) * 10f; - Dust greenDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, 0f, 0f, 0, default, 1f)]; - greenDust.position = position; - greenDust.velocity = Projectile.velocity.RotatedBy(1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; - greenDust.position += Projectile.velocity.RotatedBy(1.5707963705062866, default); - greenDust.fadeIn = 0.5f; - greenDust.noGravity = true; - greenDust = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, 0f, 0f, 0, default, 1f)]; - greenDust.position = position; - greenDust.velocity = Projectile.velocity.RotatedBy(-1.5707963705062866, default) * 0.33f + Projectile.velocity / 4f; - greenDust.position += Projectile.velocity.RotatedBy(-1.5707963705062866, default); - greenDust.fadeIn = 0.5f; - greenDust.noGravity = true; - - int moreGreen = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, 0f, 0f, 0, default, 1f); - Main.dust[moreGreen].velocity *= 0.5f; - Main.dust[moreGreen].scale *= 1.3f; - Main.dust[moreGreen].fadeIn = 1f; - Main.dust[moreGreen].noGravity = true; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item89, Projectile.Center); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = (int)(128f * Projectile.scale); - Projectile.height = (int)(128f * Projectile.scale); - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 4; i++) - { - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.5f); - } - for (int j = 0; j < 16; j++) - { - int killDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, 0f, 0f, 100, default, 2.5f); - Main.dust[killDust].noGravity = true; - Main.dust[killDust].velocity *= 3f; - killDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, 0f, 0f, 100, default, 1.5f); - Main.dust[killDust].velocity *= 2f; - Main.dust[killDust].noGravity = true; - } - if (!Main.dedServ) - { - for (int k = 0; k < 2; k++) - { - int gored = Gore.NewGore(Projectile.GetSource_Death(), Projectile.position + new Vector2((float)(Projectile.width * Main.rand.Next(100)) / 100f, (float)(Projectile.height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default, Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[gored]; - gore.velocity *= 0.3f; - gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; - gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; - } - } - if (Projectile.owner == Main.myPlayer) - { - Projectile.localAI[1] = -1f; - Projectile.maxPenetrate = 0; - Projectile.Damage(); - } - for (int l = 0; l < 5; l++) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 107, - 259, - 158 - }); - int exploding = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 2.5f * (float)Projectile.direction, -2.5f, 0, default, 1f); - Main.dust[exploding].alpha = 200; - Main.dust[exploding].velocity *= 2.4f; - Main.dust[exploding].scale += Main.rand.NextFloat(); - } - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Magic/Asteroid.png b/Projectiles/Magic/Asteroid.png deleted file mode 100644 index 85ede611fc..0000000000 Binary files a/Projectiles/Magic/Asteroid.png and /dev/null differ diff --git a/Projectiles/Magic/AsteroidMolten.cs b/Projectiles/Magic/AsteroidMolten.cs index 593186be24..102095506d 100644 --- a/Projectiles/Magic/AsteroidMolten.cs +++ b/Projectiles/Magic/AsteroidMolten.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatBuffs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Magic/AstralCrystal.cs b/Projectiles/Magic/AstralCrystal.cs index 296fb9b03d..188e0b38ce 100644 --- a/Projectiles/Magic/AstralCrystal.cs +++ b/Projectiles/Magic/AstralCrystal.cs @@ -30,6 +30,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.extraUpdates = 2; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Magic/AstralCrystalInvisibleExplosion.cs b/Projectiles/Magic/AstralCrystalInvisibleExplosion.cs index a958dd9dc9..3fbe159a25 100644 --- a/Projectiles/Magic/AstralCrystalInvisibleExplosion.cs +++ b/Projectiles/Magic/AstralCrystalInvisibleExplosion.cs @@ -17,6 +17,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = -1; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Magic/AstralStarMagic.cs b/Projectiles/Magic/AstralStarMagic.cs index 075eb98bf5..ed9be83c10 100644 --- a/Projectiles/Magic/AstralStarMagic.cs +++ b/Projectiles/Magic/AstralStarMagic.cs @@ -2,7 +2,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Magic/AstralachneaFang.cs b/Projectiles/Magic/AstralachneaFang.cs index cf5ed838f9..5619a355ec 100644 --- a/Projectiles/Magic/AstralachneaFang.cs +++ b/Projectiles/Magic/AstralachneaFang.cs @@ -49,7 +49,10 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); + //Doze - I gave this long debuff infliction times due to the lack of weapons that inflict debuffs for a decent time + //Most common vanilla debuffs have a way to inflict them for 15, 20, or even 30 seconds + //Poison and Venom staff in vanilla do 30 seconds, so this should too as it's a spiritual successor to them. + target.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(30)); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Magic/AtlantisSpear.cs b/Projectiles/Magic/AtlantisSpear.cs index 6c8a87d6fe..bb43dee78e 100644 --- a/Projectiles/Magic/AtlantisSpear.cs +++ b/Projectiles/Magic/AtlantisSpear.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.NPCs; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,10 +9,10 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException(onlyForSingleHitbox: true)] public class AtlantisSpear : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; - public bool devourer = DownedBossSystem.downedDoG; private static int TotalSegments = 16; private float damageMultiplier = 1f; private int time = 0; @@ -26,9 +27,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = 4; - Projectile.extraUpdates = (Main.zenithWorld && devourer) ? 1 : 0; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = (Main.zenithWorld && devourer) ? 2 : 8; + Projectile.idStaticNPCHitCooldown = 8; Projectile.appliesImmunityTimeOnSingleHits = true; } @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Magic } if (Main.rand.NextBool(7)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 0.5f, 278, Projectile.velocity.RotatedByRandom(0.8) * Main.rand.NextFloat(0.03f, 0.18f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 0.5f, DustID.FireworksRGB, Projectile.velocity.RotatedByRandom(0.8) * Main.rand.NextFloat(0.03f, 0.18f)); dust.scale = Main.rand.NextFloat(0.3f, 0.5f); dust.color = Main.rand.NextBool() ? Color.CornflowerBlue : Color.LightBlue; dust.noGravity = true; diff --git a/Projectiles/Magic/AuroraAustralis.cs b/Projectiles/Magic/AuroraAustralis.cs index ae1b9ec827..9381f68bf7 100644 --- a/Projectiles/Magic/AuroraAustralis.cs +++ b/Projectiles/Magic/AuroraAustralis.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = 1; Projectile.tileCollide = false; Projectile.ignoreWater = true; - Projectile.timeLeft = 300; + Projectile.timeLeft = 180; Projectile.DamageType = DamageClass.Magic; Projectile.alpha = 255; diff --git a/Projectiles/Magic/BeastScythe.cs b/Projectiles/Magic/BeastScythe.cs index 0c309d3205..0e044bd0fe 100644 --- a/Projectiles/Magic/BeastScythe.cs +++ b/Projectiles/Magic/BeastScythe.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Magic/BlankSigil.png b/Projectiles/Magic/BlankSigil.png new file mode 100644 index 0000000000..28f585c0f5 Binary files /dev/null and b/Projectiles/Magic/BlankSigil.png differ diff --git a/Projectiles/Magic/BlindingLight.cs b/Projectiles/Magic/BlindingLight.cs index 6728104eec..e26ce7b91d 100644 --- a/Projectiles/Magic/BlindingLight.cs +++ b/Projectiles/Magic/BlindingLight.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Graphics.Effects; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { diff --git a/Projectiles/Magic/BloodBeam.cs b/Projectiles/Magic/BloodBeam.cs index 19dd655fa2..80d7385459 100644 --- a/Projectiles/Magic/BloodBeam.cs +++ b/Projectiles/Magic/BloodBeam.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Magic/BloodRay.cs b/Projectiles/Magic/BloodRay.cs index 04b524b607..76cc9a31f0 100644 --- a/Projectiles/Magic/BloodRay.cs +++ b/Projectiles/Magic/BloodRay.cs @@ -24,6 +24,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = 10; Projectile.extraUpdates = 100; Projectile.timeLeft = Lifetime; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/BlueBubble.cs b/Projectiles/Magic/BlueBubble.cs index e54b7b72f7..d420068129 100644 --- a/Projectiles/Magic/BlueBubble.cs +++ b/Projectiles/Magic/BlueBubble.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -60,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 400f, 8f, 20f); if (Main.rand.NextBool(10)) { - Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Projectile.velocity, 66); + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Projectile.velocity, DustID.RainbowTorch); trailDust.scale = Main.rand.NextFloat(0.7f, 0.85f); trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.5f); trailDust.color = Main.rand.NextBool() ? Color.AliceBlue : Color.SkyBlue; @@ -83,7 +84,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item54, Projectile.Center); + SoundEngine.PlaySound(Effervescence.PopSound, Projectile.Center); Particle Star = new CritSpark(Projectile.Center, Vector2.Zero, Color.SkyBlue, Color.DeepSkyBlue, Main.rand.NextFloat(1f, 1.1f), 30, 0.1f, 3f); GeneralParticleHandler.SpawnParticle(Star); int num190 = Main.rand.Next(5, 9); diff --git a/Projectiles/Magic/BlushieStaffProj.cs b/Projectiles/Magic/BlushieStaffProj.cs index 98e2af8c09..9fd2bb2ae1 100644 --- a/Projectiles/Magic/BlushieStaffProj.cs +++ b/Projectiles/Magic/BlushieStaffProj.cs @@ -1,12 +1,13 @@ -using Microsoft.Xna.Framework; +using CalamityMod.NPCs; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using rail; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class BlushieStaffProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; diff --git a/Projectiles/Magic/CauldronHoldout.cs b/Projectiles/Magic/CauldronHoldout.cs index 80d327c3ef..3039f77888 100644 --- a/Projectiles/Magic/CauldronHoldout.cs +++ b/Projectiles/Magic/CauldronHoldout.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic float rotoffset = MathHelper.PiOver4; Vector2 playerpos = player.RotatedRelativePoint(player.MountedCenter, true); bool shouldBeHeld = !player.CantUseHoldout(); - Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem()); + Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem); if (Projectile.ai[0] > 0f) { Projectile.ai[0] -= 1f; @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Magic { if (shouldBeHeld) { - float holdscale = player.ActiveItem().shootSpeed * Projectile.scale; + float holdscale = player.HeldItem.shootSpeed * Projectile.scale; Vector2 playerpos2 = playerpos; Vector2 going = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - Projectile.Center; if (player.gravDir == -1f) @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[0] <= 0) { - bool manaCostPaid = player.CheckMana(player.ActiveItem(), -1, true, false); + bool manaCostPaid = player.CheckMana(player.HeldItem, -1, true, false); if (manaCostPaid) { SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, Projectile.Center); @@ -75,11 +75,7 @@ namespace CalamityMod.Projectiles.Magic int projType = ModContent.ProjectileType(); int projDamage = Projectile.damage; float speedscale = 18f; - Vector2 shotSpeed = Vector2.Normalize(Projectile.velocity) * speedscale; - if (float.IsNaN(shotSpeed.X) || float.IsNaN(shotSpeed.Y)) - { - shotSpeed = -Vector2.UnitY; - } + Vector2 shotSpeed = Projectile.velocity.SafeNormalize(-Vector2.UnitY) * speedscale; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shotSpeed, projType, projDamage, Projectile.knockBack, player.whoAmI); for (int i = 0; i < 6; i++) diff --git a/Projectiles/Magic/CauldronProj.cs b/Projectiles/Magic/CauldronProj.cs index 21c716e995..a414b19b1c 100644 --- a/Projectiles/Magic/CauldronProj.cs +++ b/Projectiles/Magic/CauldronProj.cs @@ -98,8 +98,8 @@ namespace CalamityMod.Projectiles.Magic Main.EntitySpriteDraw(Glow.Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); return false; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire3, 90); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire, 90); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire3, 90); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire, 90); } } diff --git a/Projectiles/Magic/CauldronProjSmall.cs b/Projectiles/Magic/CauldronProjSmall.cs index 1ae7f52f9a..20ae6b8292 100644 --- a/Projectiles/Magic/CauldronProjSmall.cs +++ b/Projectiles/Magic/CauldronProjSmall.cs @@ -58,13 +58,6 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Pitch = 0.8f, Volume = 0.6f }, Projectile.Center); - Projectile.ExpandHitboxBy(46); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.damage /= 2; - Projectile.Damage(); for (int i = 0; i < 10; i++) { int size = 10; @@ -86,8 +79,8 @@ namespace CalamityMod.Projectiles.Magic public override bool? CanDamage() => Projectile.velocity.Y < 0f ? false : null; - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire3, 90); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire, 90); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire3, 90); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire, 90); } } diff --git a/Projectiles/Magic/ChronoIcicleLarge.cs b/Projectiles/Magic/ChronoIcicleLarge.cs index 72f369e809..4ae6e976d7 100644 --- a/Projectiles/Magic/ChronoIcicleLarge.cs +++ b/Projectiles/Magic/ChronoIcicleLarge.cs @@ -31,6 +31,10 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { + Player player = Main.player[Projectile.owner]; + if (player is null || player.dead) + Projectile.Kill(); + Projectile.ai[1]++; switch (Projectile.ai[0]) { diff --git a/Projectiles/Magic/ChronoIcicleSmall.cs b/Projectiles/Magic/ChronoIcicleSmall.cs index e3c8e83f67..29dddd6b34 100644 --- a/Projectiles/Magic/ChronoIcicleSmall.cs +++ b/Projectiles/Magic/ChronoIcicleSmall.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Magic/ChronomancersScytheHoldout.cs b/Projectiles/Magic/ChronomancersScytheHoldout.cs index ed6c379bfd..f594450c37 100644 --- a/Projectiles/Magic/ChronomancersScytheHoldout.cs +++ b/Projectiles/Magic/ChronomancersScytheHoldout.cs @@ -1,12 +1,8 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Particles; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -44,6 +40,10 @@ namespace CalamityMod.Projectiles.Magic { Owner.ChangeDir((int)Projectile.ai[2]); + Player player = Main.player[Projectile.owner]; + if (player is null || player.dead) + Projectile.Kill(); + Projectile.velocity = Vector2.Zero; Projectile.rotation += (2 * MathHelper.Pi / 60) * Projectile.ai[2]; diff --git a/Projectiles/Magic/ChronomancersScytheSwing.cs b/Projectiles/Magic/ChronomancersScytheSwing.cs index 0aed3a8905..07c79e9f38 100644 --- a/Projectiles/Magic/ChronomancersScytheSwing.cs +++ b/Projectiles/Magic/ChronomancersScytheSwing.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -62,7 +60,7 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[2] >= 32) { - bool manaCostPaid = Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + bool manaCostPaid = Owner.CheckMana(Owner.HeldItem, -1, true, false); if (!manaCostPaid) { Projectile.Kill(); @@ -78,8 +76,8 @@ namespace CalamityMod.Projectiles.Magic { float scaleFactor6 = 1f; - if (Owner.ActiveItem().shoot == Projectile.type) - scaleFactor6 = Owner.ActiveItem().shootSpeed * Projectile.scale; + if (Owner.HeldItem.shoot == Projectile.type) + scaleFactor6 = Owner.HeldItem.shootSpeed * Projectile.scale; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Vector2 slashDirection = Main.MouseWorld - Owner.RotatedRelativePoint(Owner.MountedCenter, true); diff --git a/Projectiles/Magic/ClamorNoctusStar.cs b/Projectiles/Magic/ClamorNoctusStar.cs deleted file mode 100644 index ed88380a08..0000000000 --- a/Projectiles/Magic/ClamorNoctusStar.cs +++ /dev/null @@ -1,99 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Magic -{ - public class ClamorNoctusStar : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 8; - ProjectileID.Sets.TrailingMode[Type] = 1; - } - - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 10; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.alpha = 255; - Projectile.DamageType = DamageClass.Magic; - Projectile.aiStyle = ProjAIStyleID.Nail; - AIType = ProjectileID.NailFriendly; - Projectile.extraUpdates = 1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - if (Projectile.soundDelay == 0) - { - Projectile.soundDelay = 20 + Main.rand.Next(40); - if (Main.rand.NextBool(5)) - { - SoundEngine.PlaySound(SoundID.Item9, Projectile.Center); - } - } - if (Main.rand.NextBool(3)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.PurificationPowder, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 120); - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 50; - Projectile.height = 50; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - for (int i = 0; i < 15; i++) - { - int brightDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.PurificationPowder, 0f, 0f, 100, default, 1.2f); - Main.dust[brightDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[brightDust].scale = 0.5f; - Main.dust[brightDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 30; j++) - { - int brightDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.PurificationPowder, 0f, 0f, 100, default, 1.7f); - Main.dust[brightDust2].noGravity = true; - Main.dust[brightDust2].velocity *= 5f; - brightDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.PurificationPowder, 0f, 0f, 100, default, 1f); - Main.dust[brightDust2].velocity *= 2f; - } - if (!Main.dedServ) - { - for (int k = 0; k < 3; k++) - { - Gore.NewGore(Projectile.GetSource_Death(), Projectile.position, new Vector2(Projectile.velocity.X * 0.05f, Projectile.velocity.Y * 0.05f), Main.rand.Next(16, 18), 1f); - } - } - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); - return false; - } - } -} diff --git a/Projectiles/Magic/ClamorNoctusWyvern.cs b/Projectiles/Magic/ClamorNoctusWyvern.cs deleted file mode 100644 index 8196533cc1..0000000000 --- a/Projectiles/Magic/ClamorNoctusWyvern.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Magic -{ - public class ClamorNoctusWyvern : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 10; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.alpha = 255; - Projectile.DamageType = DamageClass.Magic; - Projectile.aiStyle = ProjAIStyleID.Nail; - Projectile.extraUpdates = 1; - } - - public override void AI() - { - if (Main.rand.NextBool(5)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Shadewood, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (Projectile.owner == Main.myPlayer) - { - Projectile.timeLeft = 0; - } - return false; - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.NPCHit7, Projectile.Center); - for (int i = 0; i <= 10; i++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Shadewood, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } - if (!Main.dedServ) - { - int head = Gore.NewGore(Projectile.GetSource_Death(), Projectile.Center, Projectile.velocity * 0.8f, Mod.Find("ClamorNoctusHead").Type); - Main.gore[head].timeLeft /= 10; - int body = Gore.NewGore(Projectile.GetSource_Death(), Projectile.Center, Projectile.velocity * 0.8f, Mod.Find("ClamorNoctusBody").Type); - Main.gore[body].timeLeft /= 10; - int tail = Gore.NewGore(Projectile.GetSource_Death(), Projectile.Center, Projectile.velocity * 0.8f, Mod.Find("ClamorNoctusTail").Type); - Main.gore[tail].timeLeft /= 10; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - return false; - } - } -} diff --git a/Projectiles/Magic/ClamorNoctusWyvern.png b/Projectiles/Magic/ClamorNoctusWyvern.png deleted file mode 100644 index 514dbd4679..0000000000 Binary files a/Projectiles/Magic/ClamorNoctusWyvern.png and /dev/null differ diff --git a/Projectiles/Magic/ClimaxBeam.cs b/Projectiles/Magic/ClimaxBeam.cs index 0acd9b663f..aec84744d8 100644 --- a/Projectiles/Magic/ClimaxBeam.cs +++ b/Projectiles/Magic/ClimaxBeam.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i <= 4; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), 226, (Projectile.velocity * 2) * Main.rand.NextFloat(0.1f, 0.9f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), DustID.Electric, (Projectile.velocity * 2) * Main.rand.NextFloat(0.1f, 0.9f)); dust.scale = Main.rand.NextFloat(0.3f, 0.5f); dust.noGravity = true; } diff --git a/Projectiles/Magic/ClimaxProj.cs b/Projectiles/Magic/ClimaxProj.cs index 2b7085481d..fd43a5ea28 100644 --- a/Projectiles/Magic/ClimaxProj.cs +++ b/Projectiles/Magic/ClimaxProj.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Magic/CoralSpoutHoldout.cs b/Projectiles/Magic/CoralSpoutHoldout.cs index ac08faddd8..3312bcb246 100644 --- a/Projectiles/Magic/CoralSpoutHoldout.cs +++ b/Projectiles/Magic/CoralSpoutHoldout.cs @@ -6,7 +6,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.Graphics.Effects; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Projectiles/Magic/CosmicRainbowFront.cs b/Projectiles/Magic/CosmicRainbowFront.cs index 3f6a2c3f1a..86677839cd 100644 --- a/Projectiles/Magic/CosmicRainbowFront.cs +++ b/Projectiles/Magic/CosmicRainbowFront.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Magic/CosmicRainbowTrail.cs b/Projectiles/Magic/CosmicRainbowTrail.cs index ceedd2c90b..bfc412d878 100644 --- a/Projectiles/Magic/CosmicRainbowTrail.cs +++ b/Projectiles/Magic/CosmicRainbowTrail.cs @@ -1,12 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics.PackedVector; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic diff --git a/Projectiles/Magic/CosmicTentacle.cs b/Projectiles/Magic/CosmicTentacle.cs index feb3ae822f..82d268e778 100644 --- a/Projectiles/Magic/CosmicTentacle.cs +++ b/Projectiles/Magic/CosmicTentacle.cs @@ -4,7 +4,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -84,11 +83,11 @@ namespace CalamityMod.Projectiles.Magic scaling = Utils.GetLerpValue(0, scalingTimerMax, scalingTimer, true); float sharpScaling = Utils.GetLerpValue(scalingTimerMax * 0.7f, scalingTimerMax, scalingTimer, true); - if (targetDist < 1400f) + if (targetDist < 1400f && Projectile.timeLeft % 2 == 0) { Particle spark = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.05f, "CalamityMod/Particles/GlowSpark2", false, 12, 0.07f * scaling, Color.Black * 0.85f, new Vector2(1.7f - (1 - sharpScaling), 0.9f + (1 - sharpScaling) * 2), false); GeneralParticleHandler.SpawnParticle(spark); - Particle spark2 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.05f, "CalamityMod/Particles/GlowSpark", false, 12, 0.035f * scaling, Color.LightGreen * 0.55f, new Vector2(1.7f - (1 - sharpScaling), 0.9f + (1 - sharpScaling) * 2)); + Particle spark2 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.05f, "CalamityMod/Particles/GlowSpark", false, 12, 0.035f * scaling, Color.LightGreen * 0.75f, new Vector2(1.7f - (1 - sharpScaling), 0.9f + (1 - sharpScaling) * 2)); GeneralParticleHandler.SpawnParticle(spark2); } if (Main.rand.NextBool(6)) @@ -186,8 +185,9 @@ namespace CalamityMod.Projectiles.Magic public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { // it was GOING to have this but deus made it real bad - //damageMult = MathHelper.Clamp(Utils.GetLerpValue(5, 1, Projectile.numHits), 0.7f, 1); - //modifiers.SourceDamage *= damageMult; + // renabled and tested on deus, no noticable effect + damageMult = MathHelper.Clamp(Utils.GetLerpValue(5, 1, Projectile.numHits), 0.7f, 1); + modifiers.SourceDamage *= damageMult; } public override void OnKill(int timeLeft) { diff --git a/Projectiles/Magic/DarkSparkBeam.cs b/Projectiles/Magic/DarkSparkBeam.cs index 242551db4a..fe351407b1 100644 --- a/Projectiles/Magic/DarkSparkBeam.cs +++ b/Projectiles/Magic/DarkSparkBeam.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class DarkSparkBeam : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; diff --git a/Projectiles/Magic/DarkSparkPrism.cs b/Projectiles/Magic/DarkSparkPrism.cs index a512651328..310cec8de3 100644 --- a/Projectiles/Magic/DarkSparkPrism.cs +++ b/Projectiles/Magic/DarkSparkPrism.cs @@ -29,6 +29,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.ignoreWater = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void SendExtraAI(BinaryWriter writer) @@ -59,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[0] > 480f) hitCooldown = 5f; - Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem()); + Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem); Projectile.ai[0] += 1f; Projectile.ai[1] += 1f; @@ -88,7 +90,7 @@ namespace CalamityMod.Projectiles.Magic if (Main.myPlayer == Projectile.owner) { - float scaleFactor5 = player.ActiveItem().shootSpeed * Projectile.scale; + float scaleFactor5 = player.HeldItem.shootSpeed * Projectile.scale; Vector2 projRotation = playerRotation; Vector2 gravityAdjustedRotation = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - projRotation; if (player.gravDir == -1f) @@ -125,7 +127,7 @@ namespace CalamityMod.Projectiles.Magic if (shouldHitChargedUp && Main.myPlayer == Projectile.owner) { - bool hasMana = !shouldHitNotCharged || player.CheckMana(player.ActiveItem(), -1, true, false); + bool hasMana = !shouldHitNotCharged || player.CheckMana(player.HeldItem, -1, true, false); if (!player.CantUseHoldout() && hasMana) { if (Projectile.ai[0] == 1f) diff --git a/Projectiles/Magic/DeathValleyDusterProjectile.cs b/Projectiles/Magic/DeathValleyDusterProjectile.cs index d7602bf560..eec7dfda4e 100644 --- a/Projectiles/Magic/DeathValleyDusterProjectile.cs +++ b/Projectiles/Magic/DeathValleyDusterProjectile.cs @@ -1,15 +1,13 @@ using System; using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.DataStructures; using CalamityMod.Particles; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Terraria.Audio; using Terraria; using Terraria.ID; using Terraria.ModLoader; using System.Collections.Generic; + namespace CalamityMod.Projectiles.Magic { public class DeathValleyDusterProjectile : ModProjectile, ILocalizedModType @@ -34,7 +32,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.extraUpdates = 4; + Projectile.extraUpdates = 7; Projectile.timeLeft = 400; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; @@ -60,7 +58,7 @@ namespace CalamityMod.Projectiles.Magic if (buffList[playerIndex] == false) { buffList[playerIndex] = true; - player.AddBuff(ModContent.BuffType(), 240); + player.AddBuff(ModContent.BuffType(), 720); int Dusts = 12; float radians = MathHelper.TwoPi / Dusts; @@ -68,10 +66,10 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < Dusts; i++) { Vector2 dustVelocity = spinningPoint.RotatedBy(radians * i) * 12.5f; - Dust dust = Dust.NewDustPerfect(player.Center, 262, dustVelocity, 0, default, 0.9f); + Dust dust = Dust.NewDustPerfect(player.Center, DustID.AmberBolt, dustVelocity, 0, default, 0.9f); dust.noGravity = true; - Dust dust2 = Dust.NewDustPerfect(player.Center, 262, dustVelocity * 0.6f, 0, default, 1.2f); + Dust dust2 = Dust.NewDustPerfect(player.Center, DustID.AmberBolt, dustVelocity * 0.6f, 0, default, 1.2f); dust2.noGravity = true; } @@ -141,7 +139,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.rotation += Main.rand.NextFloat(0.01f, 0.18f) * (float)Projectile.direction * Projectile.Opacity * rotDirection; - if (Projectile.timeLeft <= 45) { Projectile.extraUpdates = 1; @@ -152,15 +149,37 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.95f); - if (Projectile.damage < 1) - Projectile.damage = 1; + float minMult = 0.25f; + int hitsToMinMult = 6; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + if (Projectile.numHits == 0) + { + Player Owner = Main.player[Projectile.owner]; + Owner.SetScreenshake(3.5f); + damageMult += 0.5f; + for (int i = 0; i < 3; i++) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact with { Volume = 0.9f, Pitch = -0.4f + i * 0.25f, MaxInstances = 3 }, Projectile.Center); + for (int i = 0; i < 14; i++) + { + float range = Main.rand.NextFloat(-0.5f, 0.5f); + float power = 1 - Math.Abs(range); + Vector2 vel = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(range) * Main.rand.NextFloat(45, 50) * power; + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center, vel, Color.Peru, Color.PeachPuff, Main.rand.NextFloat(1.7f, 2.3f), 120f, Main.rand.NextFloat(0.03f, -0.03f)); + GeneralParticleHandler.SpawnParticle(SandCloud); + for (int b = 0; b < 5; b++) + { + Color clr = Color.Lerp((Main.rand.NextBool() ? Color.Peru : Color.PeachPuff), Color.Black, Main.rand.NextFloat(0.25f, 0.45f)); + Particle sand = new CustomSpark(Projectile.Center, vel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.4f, 0.9f) * power, "CalamityMod/Particles/SmallSmoke", false, Main.rand.Next(15, 25 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 7, clr, new Vector2(1, Main.rand.NextFloat(0.2f, 2f)), false, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.8f, 0.8f), affectedByLight: true); + GeneralParticleHandler.SpawnParticle(sand); + } + } + } + modifiers.SourceDamage *= damageMult; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (Projectile.numHits >= 3 && Projectile.timeLeft > 45) + if (Projectile.numHits >= 5 && Projectile.timeLeft > 45) { Projectile.timeLeft = 45; Projectile.velocity *= 0.4f; diff --git a/Projectiles/Magic/DeathhailBeam.cs b/Projectiles/Magic/DeathhailBeam.cs index 077c9eeec0..94904b9b1c 100644 --- a/Projectiles/Magic/DeathhailBeam.cs +++ b/Projectiles/Magic/DeathhailBeam.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic diff --git a/Projectiles/Magic/DivineRetributionSpear.cs b/Projectiles/Magic/DivineRetributionSpear.cs deleted file mode 100644 index f1b2dc7525..0000000000 --- a/Projectiles/Magic/DivineRetributionSpear.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Magic -{ - public class DivineRetributionSpear : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public Player Owner => Main.player[Projectile.owner]; - public ref float VelocityScale => ref Projectile.ai[0]; - public ref float Time => ref Projectile.ai[1]; - - public static float HomingSpeed => 20f; - public static float HomingTime => 15f; - public static float ReturnTime => 75f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 15; - ProjectileID.Sets.TrailingMode[Type] = 2; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 30; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Magic; - Projectile.penetrate = 1; - Projectile.timeLeft = 210; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation(); - - Time++; - Projectile.Opacity = Utils.GetLerpValue(0f, 18f, Projectile.timeLeft, true); - Lighting.AddLight(Projectile.Center, Color.Gold.ToVector3() * 0.7f * Projectile.Opacity); - - if (Time % 2f == 1f) - { - Vector2 dustOffset = (Vector2.UnitY * MathF.Sin(Projectile.timeLeft * MathHelper.Pi * 0.05f) * 16f).RotatedBy(Projectile.velocity.ToRotation()); - Dust dust = Dust.NewDustPerfect(Projectile.Center + dustOffset, ModContent.DustType()); - dust.noGravity = true; - dust.noLightEmittence = true; - dust.color = Main.rand.NextBool() ? Color.Orange : Color.Goldenrod; - dust.scale = Main.rand.NextFloat(0.4f, 0.6f); - } - - NPC potentialTarget = Projectile.Center.ClosestNPCAt(Time >= ReturnTime ? 480f : 320f); - if (potentialTarget != null && Time >= HomingTime) - { - Vector2 idealVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * HomingSpeed * VelocityScale; - Projectile.velocity = (Projectile.velocity * 29f + idealVelocity) / 30f; - Projectile.velocity = Projectile.velocity.MoveTowards(idealVelocity, 3f); - return; - } - else if (Owner.active && !Owner.dead && Time >= ReturnTime) - { - Vector2 idealVelocity = Projectile.SafeDirectionTo(Owner.MountedCenter) * HomingSpeed * VelocityScale * (1.2f - Utils.GetLerpValue(800f, 160f, Vector2.Distance(Projectile.Center, Owner.MountedCenter), true)); - Projectile.velocity = (Projectile.velocity * 29f + idealVelocity) / 30f; - Projectile.velocity = Projectile.velocity.MoveTowards(idealVelocity, 3f); - } - if (!Owner.active || Owner.dead || (Vector2.Distance(Projectile.Center, Owner.MountedCenter) <= 240f && Time >= ReturnTime)) - { - Projectile.timeLeft--; - if (!Owner.active || Owner.dead || Vector2.Distance(Projectile.Center, Owner.MountedCenter) <= 80f) - { - if (Projectile.timeLeft > 30) - Projectile.timeLeft = 30; - } - } - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D spear = TextureAssets.Projectile[Type].Value; - Vector2 drawPos = Projectile.Center - Main.screenPosition; - - float cLerp = Utils.GetLerpValue(210, 160, Projectile.timeLeft, true); - Color baseColor = Color.Lerp(Color.Goldenrod, new Color(255, 255, 150), cLerp) * Projectile.Opacity; - Color glowColor = Color.Lerp(Color.OrangeRed, Color.Orange, cLerp) * Projectile.Opacity; - - float squish = MathHelper.Clamp(Projectile.velocity.Length() * 0.04f, 0, 0.2f); - Vector2 scale = new Vector2(1f + squish, 1f - squish); - - Main.spriteBatch.EnterShaderRegion(BlendState.Additive); - if (CalamityClientConfig.Instance.Afterimages) - { - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - float completionRatio = i / (float)Projectile.oldPos.Length; - Vector2 trailPos = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; - - Color trailColor = Color.Lerp(glowColor, Color.Black, completionRatio) * 0.35f; - Vector2 trailScale = scale * MathHelper.Lerp(1f, 0.15f, completionRatio); - - Main.EntitySpriteDraw(spear, trailPos, null, trailColor, Projectile.oldRot[i], spear.Size() * 0.5f, trailScale, SpriteEffects.None); - } - } - - for (int i = 0; i < 8; i++) - { - Vector2 offset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 4f; - Main.EntitySpriteDraw(spear, drawPos + offset, null, Color.Lerp(baseColor, glowColor, 0.8f) * 0.5f, Projectile.rotation, spear.Size() * 0.5f, scale, SpriteEffects.None); - } - Main.spriteBatch.ExitShaderRegion(); - - Main.EntitySpriteDraw(spear, drawPos, null, baseColor, Projectile.rotation, spear.Size() * 0.5f, scale, SpriteEffects.None); - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - - public override void OnKill(int timeLeft) - { - Projectile.ExpandHitboxBy(96); - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); - SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - for (int i = 0; i < 9; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Main.rand.NextVector2CircularEdge(5f, 5f)); - dust.noGravity = true; - dust.noLightEmittence = true; - dust.color = Main.rand.NextBool() ? Color.Orange : Color.Goldenrod; - dust.scale = Main.rand.NextFloat(0.8f, 1.4f); - } - } - } -} diff --git a/Projectiles/Magic/DivineRetributionSpear.png b/Projectiles/Magic/DivineRetributionSpear.png deleted file mode 100644 index c8b7e089ab..0000000000 Binary files a/Projectiles/Magic/DivineRetributionSpear.png and /dev/null differ diff --git a/Projectiles/Magic/DracoConstellation.cs b/Projectiles/Magic/DracoConstellation.cs new file mode 100644 index 0000000000..90e20daa46 --- /dev/null +++ b/Projectiles/Magic/DracoConstellation.cs @@ -0,0 +1,258 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class DracoConstellation : ModProjectile, ILocalizedModType + { + + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Particles/Sparkle"; + public float TailLength => 600; + public List Segments = new(); + /// + /// Do not reference this field directly. Use GetGlowTex() instead. + /// + private static Asset GlowTex = null; + public static Texture2D GetGlowTex() + { + if (GlowTex == null) + { + GlowTex = ModContent.Request("CalamityMod/Particles/BloomCircle"); + } + return GlowTex.Value; + } + public class DracoSegment + { + public Vector2 Center = Vector2.Zero; + public float rotation = 0; + public Vector2 velocity = Vector2.Zero; + public Vector2 size = Vector2.One; + public float followDistance = 50; + public float PoseRotation = 0; + public DracoSegment(Projectile Head, float followingDistance = 50) + { + Center = Head.Center; + rotation = Head.rotation; + velocity = Head.velocity; + followDistance = followingDistance; + } + + public DracoSegment(DracoConstellation Head, float followingDistance, float rotation) + { + var prior = Head.Segments.LastOrDefault(new DracoSegment(Head.Projectile)); + Center = prior.Center + rotation.ToRotationVector2() * (followingDistance * 600f); + this.rotation = prior.rotation; + velocity = prior.velocity; + followDistance = followingDistance; + PoseRotation = rotation; + } + } + + public override void SetDefaults() + { + Projectile.width = 64; + Projectile.height = 64; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Magic; + Projectile.extraUpdates = 1; + Projectile.tileCollide = false; + Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; + Projectile.usesLocalNPCImmunity = true; + Projectile.timeLeft = 300; + } + + public override void AI() + { + if (Main.player[Projectile.owner].Calamity().StratusStarburst < 1 && Projectile.timeLeft > 60) + { + Projectile.timeLeft = 60; + return; + } + if (Projectile.FinalExtraUpdate() && Main.player[Projectile.owner].miscCounter % 15 == 0 && + Projectile.timeLeft > 60) + { + Main.player[Projectile.owner].Calamity().StratusStarburst--; + Main.player[Projectile.owner].Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(Main.player[Projectile.owner].Calamity().StratusStarburstResetTimer, 240); + } + if (Segments.Count <= 0) + { + //These segment lengths were gotten by getting the length between each star from Draco's Wikipedia diagam in pixels, then converting to a percentage of the total length. + //This ignores the "head" of draco in those calculations. The values here are multiplied by TailLength to get the full length of Draco in game. + Segments = new List(); + Segments.Add(new(this, 0.1985f, MathHelper.TwoPi * 0.74f)); + Segments.Add(new(this, 0.0835f, MathHelper.TwoPi * 0.01f)); + Segments.Add(new(this, 0.1209f, MathHelper.TwoPi * 0.2f)); + Segments.Add(new(this, 0.0938f, MathHelper.TwoPi * 0.15f)); + Segments.Add(new(this, 0.0571f, MathHelper.TwoPi * 0.15f)); + Segments.Add(new(this, 0.0711f, MathHelper.TwoPi * 0.99f)); + Segments.Add(new(this, 0.1560f, MathHelper.TwoPi * 0.9f)); + Segments.Add(new(this, 0.1458f, MathHelper.TwoPi * 0.85f)); + Segments.Add(new(this, 0.0733f, MathHelper.TwoPi * 0.9f)); + } + ; + if (Projectile.timeLeft <= 240 && Projectile.timeLeft > 60) + { + Projectile.timeLeft++; + NPC target = null; + if (Projectile.ai[2] > 0) + { + target = Main.npc[(int)Projectile.ai[2]]; + } + else if (Main.player[Projectile.owner].HasMinionAttackTargetNPC) + { + target = Main.npc[Main.player[Projectile.owner].MinionAttackTargetNPC]; + } + float targetDistance = 1600; + if (target == null || !target.CanBeChasedBy(Projectile)) + target = null; + if (target == null) + foreach (var item in Main.ActiveNPCs) + { + if (!item.CanBeChasedBy(Projectile) || Projectile.localNPCImmunity[item.whoAmI] > 0 || item.Distance(Main.player[Projectile.owner].Center) > 1200) + continue; + var dis = Projectile.Distance(item.Center); + if (dis < targetDistance) + { + targetDistance = dis; + target = item; + } + } + if (target != null) + { + float velLength = Projectile.velocity.Length(); + Projectile.velocity += Projectile.DirectionTo(target.Center) * 0.5f; + Projectile.ai[2] = target.whoAmI + 1; + } + else + { + Projectile.ai[2] = 0; + if (Projectile.Distance(Main.player[Projectile.owner].Center) > 300) + { + float velLength = Projectile.velocity.Length(); + Projectile.velocity += Projectile.DirectionTo(Main.player[Projectile.owner].Center) * 0.5f; + } + } + if (Projectile.velocity.Length() > 5) + Projectile.velocity *= 0.98f; + + if (Projectile.velocity != Vector2.Zero) + Projectile.rotation = Projectile.velocity.ToRotation(); + } + else if (Projectile.timeLeft > 60) + { + + Projectile.rotation = MathHelper.PiOver2; + Projectile.scale = MathHelper.Lerp(1, 0, (Projectile.timeLeft - 240) / 60f); + } + else + { + Projectile.scale = MathHelper.Lerp(0, 1, (Projectile.timeLeft) / 60f); + Projectile.velocity *= 0.95f; + } + Projectile.position += Projectile.velocity; + if (Projectile.timeLeft <= 241 && Projectile.velocity != Vector2.Zero) + for (int i = 0; i < Segments.Count; i++) + { + float segmentDistance = Segments[i].followDistance * TailLength; + var thisSeg = Segments[i]; + var aheadSeg = new DracoSegment(Projectile); + if (i != 0) + { + aheadSeg = Segments[i - 1]; + } + float intensity = 0.05f; + + + Vector2 nexSegDir = aheadSeg.Center - thisSeg.Center; + if (aheadSeg.rotation != thisSeg.rotation) + { + nexSegDir = nexSegDir.RotatedBy(MathHelper.WrapAngle(aheadSeg.rotation - thisSeg.rotation) * intensity); + nexSegDir = nexSegDir.MoveTowards((aheadSeg.rotation - thisSeg.rotation).ToRotationVector2(), 1f); + } + thisSeg.rotation = nexSegDir.ToRotation(); + + thisSeg.Center = aheadSeg.Center - nexSegDir.SafeNormalize(Vector2.Zero) * segmentDistance; + + } + Projectile.position -= Projectile.velocity; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + for (var i = 0; i < Segments.Count; i++) + { + var prevSeg = new DracoSegment(Projectile); + if (i != 0) + { + prevSeg = Segments[i - 1]; + } + float cpoint = 0; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), prevSeg.Center, Segments[i].Center, 4, ref cpoint)) + { + return true; + } + } + return base.Colliding(projHitbox, targetHitbox); + } + public override bool PreDraw(ref Color lightColor) + { + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive,SamplerState.PointClamp,DepthStencilState.None,Main.Rasterizer,null,Main.Transform); + var tex = TextureAssets.Projectile[Type].Value; + var connectioncolor = Color.SkyBlue * ((MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.125f + 0.75f); + for (var i = 0; i < Segments.Count; i++) + { + if (i == 0) + { + CalamityUtils.DrawLineBetter(Main.spriteBatch, Projectile.Center, Segments[i].Center, connectioncolor, 2 * Projectile.scale); + } + if (Segments.IndexInRange(i + 1)) + { + var nextSegment = Segments[i + 1]; + CalamityUtils.DrawLineBetter(Main.spriteBatch, Segments[i].Center, nextSegment.Center, connectioncolor, 2 * Projectile.scale); + } + Main.spriteBatch.Draw(GetGlowTex(), Segments[i].Center - Main.screenPosition, null, Color.SkyBlue, 0, GetGlowTex().Size() * 0.5f, 0.2f * Projectile.scale, SpriteEffects.None, 0); + + Main.spriteBatch.Draw(tex, Segments[i].Center - Main.screenPosition, null, Color.White, 0 * Segments[i].followDistance * 5f * Main.GlobalTimeWrappedHourly, tex.Size() * 0.5f, 0.75f * Projectile.scale, SpriteEffects.None, 0); + } + void DrawHeadStar(Vector2 offsetPercentage) + { + Main.spriteBatch.Draw(GetGlowTex(), Projectile.Center + offsetPercentage.RotatedBy(Projectile.rotation - MathHelper.PiOver2) * TailLength - Main.screenPosition, null, Color.SkyBlue, 0, GetGlowTex().Size() * 0.5f, 0.2f * Projectile.scale, SpriteEffects.None, 0); + Main.spriteBatch.Draw(tex, Projectile.Center + offsetPercentage.RotatedBy(Projectile.rotation - MathHelper.PiOver2) * TailLength - Main.screenPosition, null, Color.White, 0 * Math.Abs(offsetPercentage.X) * 5f * Main.GlobalTimeWrappedHourly, tex.Size() * 0.5f, 0.75f * Projectile.scale, SpriteEffects.None, 0); + } + void connectOffsets(Vector2 offset1, Vector2 offset2) + { + CalamityUtils.DrawLineBetter(Main.spriteBatch, Projectile.Center + offset1.RotatedBy(Projectile.rotation - MathHelper.PiOver2) * TailLength, Projectile.Center + offset2.RotatedBy(Projectile.rotation - MathHelper.PiOver2) * TailLength, connectioncolor, 2 * Projectile.scale); + + } + connectOffsets(new(), new(-0.0425f, 0.0637f)); + connectOffsets(new(), new(0.0307f, 0.0418f)); + connectOffsets(new(-0.0425f, 0.0637f), new(0.0168f, 0.0791f)); + connectOffsets(new(0.0307f, 0.0418f), new(0.0168f, 0.0791f)); + DrawHeadStar(new()); + DrawHeadStar(new(-0.0425f, 0.0637f)); + DrawHeadStar(new(0.0307f, 0.0418f)); + DrawHeadStar(new(0.0168f, 0.0791f)); + Main.spriteBatch.End(); + } + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } + } +} diff --git a/Projectiles/Magic/EidolicWailSoundwave.cs b/Projectiles/Magic/EidolicWailSoundwave.cs index 23316f5c74..e44aa47ee0 100644 --- a/Projectiles/Magic/EidolicWailSoundwave.cs +++ b/Projectiles/Magic/EidolicWailSoundwave.cs @@ -1,11 +1,12 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class EidolicWailSoundwave : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; diff --git a/Projectiles/Magic/EnormousConsumingVortex.cs b/Projectiles/Magic/EnormousConsumingVortex.cs index d41eb0e8df..9b3b3877a3 100644 --- a/Projectiles/Magic/EnormousConsumingVortex.cs +++ b/Projectiles/Magic/EnormousConsumingVortex.cs @@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Magic if (potentialTarget != null && Time % SubsumingVortex.VortexReleaseRate == SubsumingVortex.VortexReleaseRate - 1 && Time < SubsumingVortex.LargeVortexChargeupTime && !HasBeenReleased) { // CheckMana returns true if the mana cost can be paid.. - bool allowContinuedUse = Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + bool allowContinuedUse = Owner.CheckMana(Owner.HeldItem, -1, true, false); bool vortexStillInUse = Owner.Calamity().mouseRight && allowContinuedUse && !Owner.noItems && !Owner.CCed; if (vortexStillInUse) { diff --git a/Projectiles/Magic/EternityCircle.cs b/Projectiles/Magic/EternityCircle.cs index d12cc1eddb..6e7225660a 100644 --- a/Projectiles/Magic/EternityCircle.cs +++ b/Projectiles/Magic/EternityCircle.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -83,10 +84,10 @@ namespace CalamityMod.Projectiles.Magic float radius = 8f; Vector2 offset = Vector2.UnitY * pulse * radius; - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 132, Vector2.Zero); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.Firework_Blue, Vector2.Zero); dust.noGravity = true; - dust = Dust.NewDustPerfect(Projectile.Center - offset, 133, Vector2.Zero); + dust = Dust.NewDustPerfect(Projectile.Center - offset, DustID.Firework_Yellow, Vector2.Zero); dust.noGravity = true; } } diff --git a/Projectiles/Magic/EternityHex.cs b/Projectiles/Magic/EternityHex.cs index ce073f8144..419902fa4c 100644 --- a/Projectiles/Magic/EternityHex.cs +++ b/Projectiles/Magic/EternityHex.cs @@ -5,7 +5,6 @@ using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent.Drawing; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -139,7 +138,7 @@ namespace CalamityMod.Projectiles.Magic // Release bursts of homing dark magic bolts periodically. The amount of bolts that can be summoned has a hard limit. // This is where most of the damage comes from. Be careful when messing with this. - if ((int)Time % 30 == 0 && CalamityUtils.CountOwnedProjectiles(ModContent.ProjectileType(), Projectile.owner) < Eternity.MaxHomers) + if ((int)Time % 30 == 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] < Eternity.MaxHomers) { int homerCount = 6; int damage = (int)player.GetTotalDamage().ApplyTo(0.8f * Eternity.BaseDamage); @@ -198,14 +197,14 @@ namespace CalamityMod.Projectiles.Magic float outwardnessFactor = Main.rand.NextFloat(); Vector2 spawnPosition = target.Center + randomAngle.ToRotationVector2() * MathHelper.Lerp(70f, EternityCircle.TargetOffsetRadius - 60f, outwardnessFactor); Vector2 velocity = (randomAngle - 3f * MathHelper.Pi / 8f).ToRotationVector2() * (10f + 9f * Main.rand.NextFloat() + 4f * outwardnessFactor); - Dust swirlingDust = Dust.NewDustPerfect(spawnPosition, 267, new Vector2?(velocity), 0, Main.rand.NextBool(3) ? Eternity.BlueColor : Eternity.PinkColor, 1.4f); + Dust swirlingDust = Dust.NewDustPerfect(spawnPosition, DustID.RainbowMk2, new Vector2?(velocity), 0, Main.rand.NextBool(3) ? Eternity.BlueColor : Eternity.PinkColor, 1.4f); swirlingDust.scale = 1.2f; swirlingDust.fadeIn = 0.25f + outwardnessFactor * 0.1f; swirlingDust.noGravity = true; } } - public Color PrimitiveColorFunction(float completionRatio) + public Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float leftoverTimeScale = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f; leftoverTimeScale *= 0.5f; @@ -218,7 +217,7 @@ namespace CalamityMod.Projectiles.Magic return Color.Lerp(headColor, tailColor, fadeToMagenta) * opacity; } - public static float PrimitiveWidthFunction(float completionRatio) + public static float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float widthInterpolant = Utils.GetLerpValue(0f, 0.12f, completionRatio, true); return MathHelper.SmoothStep(1f, 10f, widthInterpolant); @@ -227,7 +226,7 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 84); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 84); return false; } } diff --git a/Projectiles/Magic/EternityHoming.cs b/Projectiles/Magic/EternityHoming.cs index 1911bad441..98aeb4ae5f 100644 --- a/Projectiles/Magic/EternityHoming.cs +++ b/Projectiles/Magic/EternityHoming.cs @@ -37,13 +37,13 @@ namespace CalamityMod.Projectiles.Magic float radius = 4f; Vector2 offset = angle.ToRotationVector2() * pulse * radius; - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 264, Vector2.Zero); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.PortalBoltTrail, Vector2.Zero); dust.color = Eternity.BlueColor; dust.scale = 1.4f; dust.noLight = true; dust.noGravity = true; - dust = Dust.NewDustPerfect(Projectile.Center - offset, 264, Vector2.Zero); + dust = Dust.NewDustPerfect(Projectile.Center - offset, DustID.PortalBoltTrail, Vector2.Zero); dust.color = Eternity.PinkColor; dust.scale = 1.4f; dust.noLight = true; diff --git a/Projectiles/Magic/EvergladeSprayProjectile.cs b/Projectiles/Magic/EvergladeSprayProjectile.cs index dbd85e0838..0cf2d5e24f 100644 --- a/Projectiles/Magic/EvergladeSprayProjectile.cs +++ b/Projectiles/Magic/EvergladeSprayProjectile.cs @@ -17,11 +17,11 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 4; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.penetrate = 6; + Projectile.penetrate = 3; Projectile.MaxUpdates = 3; Projectile.DamageType = DamageClass.Magic; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6 * Projectile.MaxUpdates; // 6 effective, 18 total + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/ExoVortex.cs b/Projectiles/Magic/ExoVortex.cs index ba25da0d47..1e80d0a34c 100644 --- a/Projectiles/Magic/ExoVortex.cs +++ b/Projectiles/Magic/ExoVortex.cs @@ -88,14 +88,14 @@ namespace CalamityMod.Projectiles.Magic behindProjectiles.Add(index); } - public float PrimitiveWidthFunction(float completionRatio) + public float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float width = Projectile.width * 0.6f; width *= MathHelper.SmoothStep(0.6f, 1f, Utils.GetLerpValue(0f, 0.3f, completionRatio, true)); return width; } - public Color PrimitiveTrailColor(float completionRatio) + public Color PrimitiveTrailColor(float completionRatio, Vector2 vertexPos) { float hue = Hue % 1f + HueShiftAcrossAfterimages; if (hue >= 0.99f) @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Magic return c * Utils.GetLerpValue(0.04f, 0.2f, completionRatio, true) * velocityOpacityFadeout; } - public Vector2 PrimitiveOffsetFunction(float completionRatio) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f; + public Vector2 PrimitiveOffsetFunction(float completionRatio, Vector2 _) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Magic/ExoVortex2.cs b/Projectiles/Magic/ExoVortex2.cs index e8e1c97ce0..bae8a19a18 100644 --- a/Projectiles/Magic/ExoVortex2.cs +++ b/Projectiles/Magic/ExoVortex2.cs @@ -92,14 +92,14 @@ namespace CalamityMod.Projectiles.Magic behindProjectiles.Add(index); } - public float PrimitiveWidthFunction(float completionRatio) + public float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float width = Projectile.width * 0.6f; width *= MathHelper.SmoothStep(0.6f, 1f, Utils.GetLerpValue(0f, 0.3f, completionRatio, true)); return width; } - public Color PrimitiveTrailColor(float completionRatio) + public Color PrimitiveTrailColor(float completionRatio, Vector2 vertexPos) { float hue = Hue % 1f + HueShiftAcrossAfterimages; if (hue >= 0.99f) @@ -110,7 +110,7 @@ namespace CalamityMod.Projectiles.Magic return c * Utils.GetLerpValue(0.04f, 0.2f, completionRatio, true) * velocityOpacityFadeout; } - public Vector2 PrimitiveOffsetFunction(float completionRatio) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f; + public Vector2 PrimitiveOffsetFunction(float completionRatio, Vector2 _) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Magic/FabBolt.cs b/Projectiles/Magic/FabBolt.cs deleted file mode 100644 index 75521fc686..0000000000 --- a/Projectiles/Magic/FabBolt.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using CalamityMod.Graphics.Primitives; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class FabBolt : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public bool FadingOut - { - get => Projectile.ai[0] == 1f; - set => Projectile.ai[0] = value.ToInt(); - } - - public override void SetStaticDefaults() - { - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 23; - } - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.extraUpdates = 2; - Projectile.penetrate = 12; - Projectile.timeLeft = 90 * Projectile.extraUpdates; - Projectile.DamageType = DamageClass.Magic; - Projectile.ignoreWater = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 0; - } - - public override void AI() - { - if (FadingOut) - { - Projectile.Opacity = MathHelper.Lerp(Projectile.Opacity, 0f, 0.27f); - if (Projectile.Opacity <= 0.05f) - Projectile.Kill(); - } - else - Projectile.velocity *= 1.004f; - Projectile.rotation = Projectile.velocity.ToRotation(); - - // Emit light. - Lighting.AddLight(Projectile.Center, Vector3.One * Projectile.Opacity * 0.45f); - } - - internal Color ColorFunction(float completionRatio) - { - float fadeToEnd = MathHelper.Lerp(0.25f, 0.5f, (float)Math.Cos(-Main.GlobalTimeWrappedHourly * 3f) * 0.5f + 0.5f); - fadeToEnd *= 1f - Utils.GetLerpValue(0.35f, 0f, completionRatio, true); - Color endColor = Color.Lerp(Color.Cyan, Color.HotPink, Projectile.identity % 2); - return Color.Lerp(Color.White, endColor, fadeToEnd) * Projectile.Opacity * 0.7f; - } - - internal float WidthFunction(float completionRatio) - { - float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.GetLerpValue(0f, 0.2f, completionRatio, true), 2D); - return MathHelper.Lerp(0f, 22f, expansionCompletion) * Projectile.Opacity; - } - - public override bool PreDraw(ref Color lightColor) - { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 80); - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (!FadingOut && Projectile.penetrate < 2) - { - FadingOut = true; - Projectile.velocity *= 0.1f; - Projectile.extraUpdates = 0; - Projectile.netUpdate = true; - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (!FadingOut) - { - FadingOut = true; - Projectile.velocity *= 0.1f; - Projectile.extraUpdates = 0; - Projectile.netUpdate = true; - } - return false; - } - - public override bool? CanDamage() - { - if (FadingOut) - return false; - return null; - } - } -} diff --git a/Projectiles/Magic/FabRay.cs b/Projectiles/Magic/FabRay.cs deleted file mode 100644 index 6afbdea101..0000000000 --- a/Projectiles/Magic/FabRay.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using CalamityMod.Buffs.Alcohol; -using CalamityMod.Graphics.Primitives; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Magic -{ - public class FabRay : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 54; - ProjectileID.Sets.TrailingMode[Type] = 2; - } - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Magic; - Projectile.ignoreWater = true; - Projectile.penetrate = 70; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 60 * Projectile.extraUpdates; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, 0.2f, 0.01f, 0.1f); - Projectile.ai[0] += 1f; - Projectile.Opacity = Utils.GetLerpValue(0f, 10f * Projectile.MaxUpdates, Projectile.timeLeft, true); - - int shootRate = Projectile.npcProj ? 40 : 12; - if (Projectile.owner == Main.myPlayer && Projectile.ai[0] % shootRate == 0f) - { - NPC potentialTarget = Projectile.Center.ClosestNPCAt(180f, false); - if (potentialTarget != null) - { - Vector2 shootVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * 13f; - int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - shootVelocity * 2.5f, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - if (p.WithinBounds(Main.maxProjectiles)) - { - if (Projectile.hostile) - { - Main.projectile[p].hostile = true; - Main.projectile[p].friendly = false; - Main.projectile[p].DamageType = DamageClass.Default; - } - } - } - - for (int i = 0; i < Projectile.oldPos.Length / 4; i += 3) - { - potentialTarget = Projectile.oldPos[i].ClosestNPCAt(280f, false); - if (potentialTarget != null) - { - Vector2 shootVelocity = (potentialTarget.Center - Projectile.oldPos[i]).SafeNormalize(Vector2.UnitY) * 13f; - int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.oldPos[i] - shootVelocity * 2.5f, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - if (p.WithinBounds(Main.maxProjectiles)) - { - if (Projectile.hostile) - { - Main.projectile[p].hostile = true; - Main.projectile[p].friendly = false; - Main.projectile[p].DamageType = DamageClass.Default; - } - } - break; - } - } - } - - // Emit light. - if (!Projectile.hostile) - Lighting.AddLight(Projectile.Center, Vector3.One * Projectile.Opacity * 0.7f); - } - - internal Color ColorFunction(float completionRatio) - { - float fadeToEnd = MathHelper.Lerp(0.65f, 1f, (float)Math.Cos(-Main.GlobalTimeWrappedHourly * 3f) * 0.5f + 0.5f); - float fadeOpacity = Utils.GetLerpValue(1f, 0.64f, completionRatio, true) * Projectile.Opacity; - Color endColor = Color.Lerp(Color.Cyan, Color.HotPink, (float)Math.Sin(completionRatio * MathHelper.Pi * 1.6f - Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); - return Color.Lerp(Color.White, endColor, fadeToEnd) * fadeOpacity; - } - - internal float WidthFunction(float completionRatio) - { - float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.GetLerpValue(0f, 0.3f, completionRatio, true), 2D); - return MathHelper.Lerp(0f, 32f * Projectile.Opacity, expansionCompletion); - } - - internal Vector2 OffsetFunction(float completionRatio) => Projectile.Size * 0.5f; - - public override bool PreDraw(ref Color lightColor) - { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, OffsetFunction, pixelate: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32); - return false; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.penetrate--; - if (Projectile.penetrate <= 0) - { - Projectile.Kill(); - } - else - { - 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 OnHitPlayer(Player target, Player.HurtInfo info) - { - if (Projectile.hostile) - target.AddBuff(ModContent.BuffType(), 54000); - } - } -} diff --git a/Projectiles/Magic/FireImplosion.cs b/Projectiles/Magic/FireImplosion.cs index 83de69cf6c..b053d51ba6 100644 --- a/Projectiles/Magic/FireImplosion.cs +++ b/Projectiles/Magic/FireImplosion.cs @@ -1,9 +1,7 @@ using System; -using System.IO; using CalamityMod.Dusts; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; -using Microsoft.Build.Construction; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Magic/FlareBoltProjectile.cs b/Projectiles/Magic/FlareBoltProjectile.cs index e4f2bb2345..3bf2727b31 100644 --- a/Projectiles/Magic/FlareBoltProjectile.cs +++ b/Projectiles/Magic/FlareBoltProjectile.cs @@ -1,8 +1,6 @@ using System; using CalamityMod.Dusts; using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Build.Construction; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -18,6 +16,8 @@ namespace CalamityMod.Projectiles.Magic public float fadeIn = 0; public bool launch = true; public Color bColor = Color.OrangeRed; + public int launchTime = 0; + public Vector2 endPoint; public new string LocalizationCategory => "Projectiles.Magic"; public override void SetDefaults() { @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 16; Projectile.friendly = true; Projectile.penetrate = -1; - Projectile.timeLeft = 240; + Projectile.timeLeft = 500; Projectile.extraUpdates = 2; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 mouse = Owner.Calamity().mouseWorld; fadeIn = Utils.GetLerpValue(0, Owner.itemAnimationMax * 0.5f * Projectile.MaxUpdates, time, true); float velFade = Utils.GetLerpValue(1.5f, 6.5f, Projectile.velocity.Length(), true); - Vector2 velocity = Utils.DirectionTo(Owner.Center, mouse) * Owner.HeldItem.shootSpeed; + Vector2 velocity = Utils.DirectionTo(Owner.Center, mouse) * 8f; Projectile.scale = fadeIn * 1.5f; if (fadeIn < 1) // Hold the projectile in front of the player while they case the spell { @@ -51,8 +51,9 @@ namespace CalamityMod.Projectiles.Magic { Projectile.tileCollide = true; - Vector2 staticSpeed = Utils.DirectionTo(Owner.Center, mouse) * Utils.Distance(Owner.Center, Owner.ClampedMouseWorld()) * 0.0165f; + Vector2 staticSpeed = Utils.DirectionTo(Owner.Center, mouse) * Utils.Distance(Projectile.Center, Owner.ClampedMouseWorld()) * 0.0165f; Projectile.velocity = staticSpeed; + endPoint = Owner.ClampedMouseWorld(); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/HalleysInfernoShoot") with { Volume = 0.45f, Pitch = 0.3f }, Projectile.Center); for (int i = 0; i < 20; i++) @@ -75,7 +76,7 @@ namespace CalamityMod.Projectiles.Magic launch = false; } - if (Main.rand.NextBool(10) && velFade > 0.1f) + if (Main.rand.NextBool(8) && launchTime < 56) { Particle fx = new CustomSpark(Projectile.Center + Main.rand.NextVector2Circular(8, 8), -Projectile.velocity * 0.9f, "CalamityMod/Particles/FireTypeParticle", false, 32, 1.15f, Color.Lerp(bColor, Color.Red, 0.5f), new Vector2(0.8f, 1f), true, false); GeneralParticleHandler.SpawnParticle(fx); @@ -93,13 +94,16 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(trail); } - if (Projectile.timeLeft < 120) - { - Projectile.velocity *= 0.98f; - } - Projectile.rotation += 0.3f * Projectile.direction; time++; + if (!launch) + { + Projectile.Center = Vector2.Lerp(Projectile.Center, endPoint, 0.035f); + Projectile.velocity *= 0.9f; + launchTime++; + if (launchTime >= (Owner.itemAnimationMax + 28)) + Projectile.Kill(); + } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { diff --git a/Projectiles/Magic/FrigidflashBoltProjectile.cs b/Projectiles/Magic/FrigidflashBoltProjectile.cs index 119fbf7c03..19899c4f4f 100644 --- a/Projectiles/Magic/FrigidflashBoltProjectile.cs +++ b/Projectiles/Magic/FrigidflashBoltProjectile.cs @@ -1,9 +1,9 @@ using System; +using System.Net; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; -using Microsoft.Build.Construction; using Microsoft.Xna.Framework; using ReLogic.Utilities; using Terraria; @@ -24,6 +24,8 @@ namespace CalamityMod.Projectiles.Magic public Color fireColor = Color.OrangeRed; public Color iceColor = Color.DeepSkyBlue; public SlotId chargeSound; + public int launchTime = 0; + public Vector2 endPoint; public override void SetDefaults() { Projectile.width = 20; @@ -44,7 +46,7 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, lightColor.ToVector3()); Vector2 mouse = Owner.Calamity().mouseWorld; fadeIn = launch ? Utils.GetLerpValue(0, Owner.itemAnimationMax * 0.5f * Projectile.MaxUpdates, time, true) : 1; - Vector2 velocity = Utils.DirectionTo(Owner.Center, mouse) * Owner.HeldItem.shootSpeed; + Vector2 velocity = Utils.DirectionTo(Owner.Center, mouse) * 10; Projectile.scale = fadeIn * (bigMagic ? 1.3f : 1); if (fadeIn < 1) // Hold the projectile in front of the player while they case the spell { @@ -72,6 +74,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = true; Vector2 staticSpeed = Utils.DirectionTo(Owner.Center, mouse) * Utils.Distance(Owner.Center, Owner.ClampedMouseWorld()) * 0.01f; Projectile.velocity = (bigMagic ? staticSpeed : velocity); + endPoint = Owner.ClampedMouseWorld(); SoundEngine.PlaySound(FrigidflashBolt.UseSound with { Volume = 1f, Pitch = (bigMagic ? -0.15f : 0.15f) }, Projectile.Center); if (bigMagic) @@ -98,7 +101,7 @@ namespace CalamityMod.Projectiles.Magic launch = false; } - if (Main.rand.NextBool(8)) + if (Main.rand.NextBool(bigMagic ? 3 : 8) && launchTime < 56) { bool type = Main.rand.NextBool(); Particle fx = new CustomSpark(Projectile.Center + Main.rand.NextVector2Circular(12, 12), -Projectile.velocity * 0.3f, type ? "CalamityMod/Particles/FireTypeParticle" : "CalamityMod/Particles/IceTypeParticle", false, 32, 0.9f, type ? fireColor : iceColor, new Vector2(0.8f, 1f), true, false, shrinkSpeed: type ? 0.2f : 0); @@ -113,9 +116,13 @@ namespace CalamityMod.Projectiles.Magic } if (bigMagic) { - if (Projectile.timeLeft < 145) + if (!launch) { - Projectile.velocity *= 0.98f; + Projectile.Center = Vector2.Lerp(Projectile.Center, endPoint, 0.035f); + Projectile.velocity *= 0.9f; + launchTime++; + if (launchTime >= (Owner.itemAnimationMax * 2.5f + 28)) + Projectile.Kill(); } } else diff --git a/Projectiles/Magic/FrostBoltProjectile.cs b/Projectiles/Magic/FrostBoltProjectile.cs index dae2d9f8c1..6bd7c8c9e5 100644 --- a/Projectiles/Magic/FrostBoltProjectile.cs +++ b/Projectiles/Magic/FrostBoltProjectile.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; diff --git a/Projectiles/Magic/GammaLaser.cs b/Projectiles/Magic/GammaLaser.cs index 0030bf2cdc..be1f3e3d1a 100644 --- a/Projectiles/Magic/GammaLaser.cs +++ b/Projectiles/Magic/GammaLaser.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/GenesisBeam.cs b/Projectiles/Magic/GenesisBeam.cs index f93e9798bc..2a2c098807 100644 --- a/Projectiles/Magic/GenesisBeam.cs +++ b/Projectiles/Magic/GenesisBeam.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ModLoader; -using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Magic { diff --git a/Projectiles/Magic/GenesisHoldout.cs b/Projectiles/Magic/GenesisHoldout.cs index a5dc0753e8..1cae76f266 100644 --- a/Projectiles/Magic/GenesisHoldout.cs +++ b/Projectiles/Magic/GenesisHoldout.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Magic public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner.CantUseHoldout()) + if (HeldItem.type != Owner.HeldItem.type || Owner.CantUseHoldout()) Projectile.Kill(); } diff --git a/Projectiles/Magic/GhastlyExplosionShard.cs b/Projectiles/Magic/GhastlyExplosionShard.cs index 36b23f3e45..b9c28a1a4a 100644 --- a/Projectiles/Magic/GhastlyExplosionShard.cs +++ b/Projectiles/Magic/GhastlyExplosionShard.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic diff --git a/Projectiles/Magic/GhastlyVisageProj.cs b/Projectiles/Magic/GhastlyVisageProj.cs index 42cd6b630f..5e69e5ea73 100644 --- a/Projectiles/Magic/GhastlyVisageProj.cs +++ b/Projectiles/Magic/GhastlyVisageProj.cs @@ -154,12 +154,12 @@ namespace CalamityMod.Projectiles.Magic if (isActive && Main.myPlayer == Projectile.owner) { float coreVelocity = 11.5f; - int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); - float weaponKnockback2 = player.ActiveItem().knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.HeldItem); + float weaponKnockback2 = player.HeldItem.knockBack; if (canUseItem) { - weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); - float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; + weaponKnockback2 = player.GetWeaponKnockback(player.HeldItem, weaponKnockback2); + float scaleFactor12 = player.HeldItem.shootSpeed * Projectile.scale; Vector2 playerRotateCopy = playerRotate; Vector2 projSpawnDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotateCopy; if (player.gravDir == -1f) diff --git a/Projectiles/Magic/GleamingBolt.cs b/Projectiles/Magic/GleamingBolt.cs index 8fdd57539f..caa9485d19 100644 --- a/Projectiles/Magic/GleamingBolt.cs +++ b/Projectiles/Magic/GleamingBolt.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 6; i++) { Vector2 velocity = ((MathHelper.TwoPi * i / 6f) - (MathHelper.Pi / 3f - Projectile.velocity.ToRotation())).ToRotationVector2() * 3.5f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75), Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); } } SoundEngine.PlaySound(SoundID.Item105, Projectile.Center); diff --git a/Projectiles/Magic/GruesomeEminenceHoldout.cs b/Projectiles/Magic/GruesomeEminenceHoldout.cs index 4ea05ca7e9..90eef47f00 100644 --- a/Projectiles/Magic/GruesomeEminenceHoldout.cs +++ b/Projectiles/Magic/GruesomeEminenceHoldout.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Magic Lighting.AddLight(Projectile.Center, 0.13f, 0f, 0.05f); // Also emit dust. - Dust ghostlyMagic = Dust.NewDustPerfect(Projectile.Top + Main.rand.NextVector2Circular(5f, 5f) + Vector2.UnitX * Projectile.direction * 7f, 267); + Dust ghostlyMagic = Dust.NewDustPerfect(Projectile.Top + Main.rand.NextVector2Circular(5f, 5f) + Vector2.UnitX * Projectile.direction * 7f, DustID.RainbowMk2); ghostlyMagic.color = Color.Lerp(Color.DarkRed, Color.Fuchsia, Main.rand.NextFloat(0.7f)); ghostlyMagic.color = Color.Lerp(ghostlyMagic.color, Color.Black, 0.5f); ghostlyMagic.velocity = -Vector2.UnitY.RotatedBy(0.44f) * Main.rand.NextFloat(0.8f, 2f); diff --git a/Projectiles/Magic/HadalUrnHoldout.cs b/Projectiles/Magic/HadalUrnHoldout.cs index 1a806f98cf..c5d7c6e301 100644 --- a/Projectiles/Magic/HadalUrnHoldout.cs +++ b/Projectiles/Magic/HadalUrnHoldout.cs @@ -33,16 +33,16 @@ namespace CalamityMod.Projectiles.Magic float rotoffset = MathHelper.PiOver2; Vector2 playerpos = player.RotatedRelativePoint(player.MountedCenter, true); bool shouldBeHeld = !player.CantUseHoldout(); - Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem()); + Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem); if (Projectile.ai[0] > 0f) { - Projectile.ai[0] -= 1f; + Projectile.ai[0]--; } if (Main.myPlayer == Projectile.owner) { if (shouldBeHeld) { - float holdscale = player.ActiveItem().shootSpeed * Projectile.scale; + float holdscale = player.HeldItem.shootSpeed * Projectile.scale; Vector2 playerpos2 = playerpos; Vector2 going = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerpos2; if (player.gravDir == -1f) @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[0] <= 0) { - bool manaCostPaid = player.CheckMana(player.ActiveItem(), -1, true, false); + bool manaCostPaid = player.CheckMana(player.HeldItem, -1, true, false); if (manaCostPaid) { SoundEngine.PlaySound(SoundID.Item111, Projectile.Center); @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Magic } Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shotSpeed, projType, projDamage, Projectile.knockBack, player.whoAmI, ai); } - Projectile.ai[0] = 16; + Projectile.ai[0] = player.HeldItem.useTime; } else { diff --git a/Projectiles/Magic/HadalUrnJellyfish.cs b/Projectiles/Magic/HadalUrnJellyfish.cs index e85edb4ef0..f36c9a7ff2 100644 --- a/Projectiles/Magic/HadalUrnJellyfish.cs +++ b/Projectiles/Magic/HadalUrnJellyfish.cs @@ -3,7 +3,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/HeliumFlashBlast.cs b/Projectiles/Magic/HeliumFlashBlast.cs index 67b98a66f5..d0d7bb0ca4 100644 --- a/Projectiles/Magic/HeliumFlashBlast.cs +++ b/Projectiles/Magic/HeliumFlashBlast.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Magic starAngle = Main.rand.NextFloat(-0.9f, 0.9f); for (int i = 0; i < 4; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); Vector2 vel = (MathHelper.TwoPi * i / 4f).ToRotationVector2().RotatedBy(starAngle) * 8f; Particle pulse = new GlowSparkParticle(Projectile.Center, vel, false, 6, 0.12f, Color.Orange, new Vector2(1.5f, 0.9f), true, true, 2); @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Magic } if (currentFrame == 19) { - Owner.Calamity().GeneralScreenShakePower = 8f; + Owner.SetScreenshake(8f); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/HeliumFlashExplodeNoMetal") { Volume = 1f }, Projectile.Center); for (int i = 0; i < 12; i++) { @@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Magic } for (int i = 0; i < 4; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); Vector2 vel = (MathHelper.TwoPi * i / 4f).ToRotationVector2().RotatedBy(starAngle) * 8f; Particle pulse = new GlowSparkParticle(Projectile.Center, vel, false, 10, 0.22f, Color.Orange, new Vector2(1.5f, 0.9f), true, true, 1); @@ -114,7 +114,7 @@ namespace CalamityMod.Projectiles.Magic } for (int i = 0; i < 60; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); chargefull.velocity = new Vector2(25, 25).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 2f); chargefull.scale = Main.rand.NextFloat(0.65f, 1.25f); chargefull.noGravity = true; diff --git a/Projectiles/Magic/HeliumFlashHoldout.cs b/Projectiles/Magic/HeliumFlashHoldout.cs index c26c976f60..338c58f4f1 100644 --- a/Projectiles/Magic/HeliumFlashHoldout.cs +++ b/Projectiles/Magic/HeliumFlashHoldout.cs @@ -7,6 +7,7 @@ using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -30,7 +31,7 @@ namespace CalamityMod.Projectiles.Magic public override void KillHoldoutLogic() { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type) Projectile.Kill(); } @@ -56,7 +57,7 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[1] != 1f) { - Projectile.timeLeft = (FullyCharged ? HeliumFlash.AftershotCooldownFrames * 3 : (int)(HeliumFlash.AftershotCooldownFrames * 1.5f)); + Projectile.timeLeft = FullyCharged ? HeliumFlash.AftershotCooldownFrames * 3 : (int)(HeliumFlash.AftershotCooldownFrames * 1.5f); ChargeSound?.Stop(); @@ -67,7 +68,8 @@ namespace CalamityMod.Projectiles.Magic OffsetLengthFromArm -= 25; SoundEngine.PlaySound(HeliumFlash.ChargeFire, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0); Particle pulse = new CustomPulse(GunTipPosition, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.05f, 14); GeneralParticleHandler.SpawnParticle(pulse); @@ -76,7 +78,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 17; i++) { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 278); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB); chargefull.velocity = Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(5, 25); chargefull.scale = Main.rand.NextFloat(0.65f, 0.95f); chargefull.noGravity = true; @@ -107,7 +109,7 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(fire with { Volume = 0.4f, Pitch = 0.3f }, Projectile.Center); for (int i = 0; i < 12; i++) { - Dust dust2 = Dust.NewDustPerfect(GunTipPosition, 278, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1f, 3.5f)); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1f, 3.5f)); dust2.scale = Main.rand.NextFloat(0.55f, 0.9f); dust2.noGravity = false; dust2.color = Color.Lerp(Color.White, Main.rand.NextBool(4) ? Color.Orange : Color.OrangeRed, 0.7f); @@ -130,7 +132,7 @@ namespace CalamityMod.Projectiles.Magic if (Main.rand.NextBool()) { Vector2 dustVel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(3, 5); - Dust dust2 = Dust.NewDustPerfect(GunTipPosition + dustVel, 278, dustVel * 0.15f); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition + dustVel, DustID.FireworksRGB, dustVel * 0.15f); dust2.scale = Main.rand.NextFloat(0.35f, 0.7f); dust2.noGravity = true; dust2.color = Color.Lerp(Color.White, Main.rand.NextBool(4) ? Color.Orange : Color.OrangeRed, 0.7f); @@ -152,12 +154,12 @@ namespace CalamityMod.Projectiles.Magic // Full charge effects if (CurrentChargingFrames == HeliumFlash.FullChargeFrames) { - SoundStyle fire = new("CalamityMod/Sounds/Item/HeliumFlashReadyAlt"); + SoundStyle fire = new("CalamityMod/Sounds/Item/HeliumFlashReady"); SoundEngine.PlaySound(fire with { Volume = 1f, Pitch = 0f }, Projectile.Center); for (int i = 0; i < 18; i++) { Vector2 dustVel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1, 5); - Dust dust2 = Dust.NewDustPerfect(GunTipPosition + dustVel, 278, dustVel * 0.7f); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition + dustVel, DustID.FireworksRGB, dustVel * 0.7f); dust2.scale = Main.rand.NextFloat(0.45f, 0.9f); dust2.noGravity = true; dust2.color = Color.Lerp(Color.White, Main.rand.NextBool(4) ? Color.Orange : Color.OrangeRed, 0.7f); @@ -188,13 +190,13 @@ namespace CalamityMod.Projectiles.Magic Particle smoke3 = new HeavySmokeParticle(GunTipPosition + smokeVel3 * 2, smokeVel3 * Main.rand.NextFloat(0.2f, 0.7f), Color.Lerp(Color.SlateGray, Color.Orange, Main.rand.NextFloat(0, 0.4f)), Main.rand.Next(15, 35 + 1), Main.rand.NextFloat(0.08f, 0.45f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); GeneralParticleHandler.SpawnParticle(smoke3); - Dust dust1 = Dust.NewDustPerfect(GunTipPosition + smokeVel1 * 2, 303, smokeVel1.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.03f, 0.3f), 180, default, Main.rand.NextFloat(0.3f, 1.1f)); + Dust dust1 = Dust.NewDustPerfect(GunTipPosition + smokeVel1 * 2, DustID.SteampunkSteam, smokeVel1.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.03f, 0.3f), 180, default, Main.rand.NextFloat(0.3f, 1.1f)); dust1.noGravity = false; dust1.color = Color.Lerp(Color.SlateGray, Color.Orange, Main.rand.NextFloat(0, 0.4f)); - Dust dust2 = Dust.NewDustPerfect(GunTipPosition + smokeVel2 * 2, 303, smokeVel2.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.03f, 0.3f), 180, default, Main.rand.NextFloat(0.3f, 1.1f)); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition + smokeVel2 * 2, DustID.SteampunkSteam, smokeVel2.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.03f, 0.3f), 180, default, Main.rand.NextFloat(0.3f, 1.1f)); dust2.noGravity = false; dust2.color = Color.Lerp(Color.SlateGray, Color.Orange, Main.rand.NextFloat(0, 0.4f)); - Dust dust3 = Dust.NewDustPerfect(GunTipPosition + smokeVel3 * 2, 303, smokeVel3.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.03f, 0.3f), 180, default, Main.rand.NextFloat(0.3f, 1.1f)); + Dust dust3 = Dust.NewDustPerfect(GunTipPosition + smokeVel3 * 2, DustID.SteampunkSteam, smokeVel3.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.03f, 0.3f), 180, default, Main.rand.NextFloat(0.3f, 1.1f)); dust3.noGravity = false; dust3.color = Color.Lerp(Color.SlateGray, Color.Orange, Main.rand.NextFloat(0, 0.4f)); diff --git a/Projectiles/Magic/HellfireExplosionFriendly.cs b/Projectiles/Magic/HellfireExplosionFriendly.cs index 866f9658e6..7b73558e5a 100644 --- a/Projectiles/Magic/HellfireExplosionFriendly.cs +++ b/Projectiles/Magic/HellfireExplosionFriendly.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Magic/HellwingBat.cs b/Projectiles/Magic/HellwingBat.cs index f07139620d..c639ccada8 100644 --- a/Projectiles/Magic/HellwingBat.cs +++ b/Projectiles/Magic/HellwingBat.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/HeresyProj.cs b/Projectiles/Magic/HeresyProj.cs index d3da71c8c8..e14d893f13 100644 --- a/Projectiles/Magic/HeresyProj.cs +++ b/Projectiles/Magic/HeresyProj.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Magic // If the owner has sufficient mana, consume it. // Otherwise, delete the book and don't bother summoning anything. - if (!Owner.CheckMana(Owner.ActiveItem().mana, true, false)) + if (!Owner.CheckMana(Owner.HeldItem.mana, true, false)) { Projectile.Kill(); return; diff --git a/Projectiles/Magic/HolyFlame.cs b/Projectiles/Magic/HolyFlame.cs index caea82db64..bd5c3b75c8 100644 --- a/Projectiles/Magic/HolyFlame.cs +++ b/Projectiles/Magic/HolyFlame.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Magic/HolyLaser.cs b/Projectiles/Magic/HolyLaser.cs index bb111a2960..6b59f559a9 100644 --- a/Projectiles/Magic/HolyLaser.cs +++ b/Projectiles/Magic/HolyLaser.cs @@ -4,8 +4,8 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; @@ -38,7 +38,6 @@ namespace CalamityMod.Projectiles.Magic private Player Owner { get; set; } - private SlotId BigBeamSoundSlot; public int time = 0; public override void SetDefaults() { @@ -47,6 +46,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.friendly = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = DamageClass.Magic; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -104,7 +104,7 @@ namespace CalamityMod.Projectiles.Magic if (Main.rand.NextBool() || isBigLaser) { - Dust laserDust = Dust.NewDustPerfect(randomLineEffectPosition, 278, Projectile.velocity * Main.rand.NextFloat(5f, 40f), Scale: Main.rand.NextFloat(0.8f, 1.1f)); + Dust laserDust = Dust.NewDustPerfect(randomLineEffectPosition, DustID.FireworksRGB, Projectile.velocity * Main.rand.NextFloat(5f, 40f), Scale: Main.rand.NextFloat(0.8f, 1.1f)); laserDust.noGravity = true; laserDust.color = Main.rand.NextBool(3) ? color2 : color1; } diff --git a/Projectiles/Magic/HyperdeathRiftScepterBeam.cs b/Projectiles/Magic/HyperdeathRiftScepterBeam.cs new file mode 100644 index 0000000000..284db13562 --- /dev/null +++ b/Projectiles/Magic/HyperdeathRiftScepterBeam.cs @@ -0,0 +1,157 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class HyperdeathRiftScepterBeam : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Magic"; + public float time = 0; + public ref float attackSpeed => ref Projectile.ai[0]; + public ref float laserType => ref Projectile.ai[2]; + public bool canDamage => doneAttack && laserFX >= 1f; + public bool doneAttack = false; + public int attackTime = 10; + public float laserLength => 3000; + public float laserFX = 0; + public float storedTime = 0; + public Color drawColor = Color.Magenta; + public float sine = 0; + public float laserRot = 0; + Vector2 beamStart = Vector2.Zero; + Vector2 directionToTarget = Vector2.Zero; + public Vector2 targetPos => Projectile.Center; + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + } + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 6000; + Projectile.scale = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + if (laserFX > 0) + laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.07f : 0.01f); + sine = (float)Math.Sin(time * 4f / MathHelper.Pi); + if (time == 0) + { + laserType = 1; + if (CalamityWorld.LegendaryMode) + Projectile.scale = 6; + laserRot = Main.rand.NextFloat(-0.4f, 0.4f); + + beamStart = targetPos + ((laserType == 0 || laserType == 4 || laserType == 5) ? Vector2.UnitX : Vector2.UnitY).RotatedBy(laserRot) * laserLength; + directionToTarget = beamStart.DirectionTo(targetPos); + + Projectile.Center += Main.rand.NextVector2CircularEdge(400, 400); + // Some default values for if the projectile spawns without them set + if (attackSpeed == 0) + attackSpeed = 0.5f; + Projectile.velocity = Vector2.Zero; + laserFX = 1f; + Projectile.ForceNetUpdate(); + } + if (time >= attackTime && !doneAttack) + { + SoundStyle attack = new("CalamityMod/Sounds/Custom/DoGLaserWallBigAttack"); + SoundEngine.PlaySound(attack with { Volume = 0.6f, Pitch = 0, MaxInstances = -1 }, targetPos); + laserFX = 2.5f; + doneAttack = true; + storedTime = time; + Projectile.ForceNetUpdate(); + + if (Main.LocalPlayer.Distance(Projectile.Center) < 1600) + Main.LocalPlayer.SetScreenshake(3f); + } + float endTime = storedTime + 10; + if (time >= endTime && doneAttack) + { + Projectile.Kill(); + return; + } + else if (doneAttack) + { + drawColor = Color.Lerp(Color.Magenta, Color.Cyan, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2)); + } + time += attackSpeed; + } + + public override bool? CanHitNPC(NPC target) + { + if (canDamage) + return null; + return false; + } + public override bool CanHitPlayer(Player target) + { + if (canDamage) + return true; + return false; + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + base.OnHitPlayer(target, info); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + base.OnHitNPC(target, hit, damageDone); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canDamage) + return false; + else + { + float _ = float.NaN; + Vector2 start = beamStart; + Vector2 end = beamStart + directionToTarget * laserLength * 2; + bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 70 * Projectile.scale, ref _); + + return hitCheck; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (laserFX == 0) + return false; + Texture2D beam = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D bBeam = ModContent.Request("CalamityMod/Particles/LineThick").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float opacity = (doneAttack ? 0.65f : 0.35f) * (float)Math.Pow(Math.Min(laserFX, 1), 2); + Color beamColor = drawColor with { A = 0 }; + + if (CalamityClientConfig.Instance.Photosensitivity) + opacity = 0.2f; + for (int t = 0; t < (!doneAttack ? 1 : 4 * Projectile.scale); t++) + { + bool black = (t > 0 + (Projectile.scale - 1)); + if (black) + beam = bBeam; + + float beamThickness = 0.09f * (black ? (0.8f - 0.15f * t / Projectile.scale) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f); + Main.EntitySpriteDraw(beam, beamStart - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * (1 - t * 0.3f) * opacity) * (black ? (0.2f + 0.15f * t / Projectile.scale) : 1), directionToTarget.ToRotation() + MathHelper.PiOver2, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness, laserLength / 975) * Projectile.scale, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Magic/IceBarrageMain.cs b/Projectiles/Magic/IceBarrageMain.cs index 7abf042476..b0bdd946ac 100644 --- a/Projectiles/Magic/IceBarrageMain.cs +++ b/Projectiles/Magic/IceBarrageMain.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/IceCluster.cs b/Projectiles/Magic/IceCluster.cs index 40d362af69..4ce8847842 100644 --- a/Projectiles/Magic/IceCluster.cs +++ b/Projectiles/Magic/IceCluster.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.coldDamage = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/IcicleStaffProj.cs b/Projectiles/Magic/IcicleStaffProj.cs index d5790eb209..3e0d5ccdc5 100644 --- a/Projectiles/Magic/IcicleStaffProj.cs +++ b/Projectiles/Magic/IcicleStaffProj.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Magic/IgnisSigil.cs b/Projectiles/Magic/IgnisSigil.cs new file mode 100644 index 0000000000..c3d022a7f5 --- /dev/null +++ b/Projectiles/Magic/IgnisSigil.cs @@ -0,0 +1,115 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; +using Terraria.ID; + +namespace CalamityMod.Projectiles.Magic +{ + public class IgnisSigil : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private bool spawnedProjectile = false; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 74; + Projectile.friendly = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)Projectile.ai[0]]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive && Projectile.ai[2] == 0) + { + Projectile.Kill(); + return; + } + + int i = (int)Projectile.ai[1]; + float dist = i % 3 == 0 ? 270f : 280f; + float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f); + + Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot); + Projectile.Center = sigilPos; + + if (Projectile.ai[2] > 0) + { + Projectile.localAI[0]++; + + if (Projectile.localAI[0] == 35 && !spawnedProjectile) + { + SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, Projectile.Center); + + Player owner = Main.player[Projectile.owner]; + Vector2 targetDirection = Projectile.Center.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX); + + spawnedProjectile = true; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, targetDirection * 34f, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); + } + + if (Projectile.localAI[0] >= 50) + { + Projectile.Kill(); + } + } + else + { + Projectile.scale = parent.scale; + Projectile.rotation = 0; + Projectile.alpha = parent.alpha; + } + + if (parentActive) + { + Projectile.timeLeft = parent.timeLeft; + } + } + public override bool PreDraw(ref Color lightColor) + { + // Get textures + Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D blankTexture = ModContent.Request("CalamityMod/Projectiles/Magic/BlankSigil").Value; + + float finalScale = Projectile.scale; + float alphaOpacity = 1f - (Projectile.alpha / 255f); + float maskOpacity = 0f; + + // Apply animation effects if fading + if (Projectile.ai[2] > 0) + { + float animationTime = Projectile.localAI[0]; + + if (animationTime <= 24) + { + maskOpacity = Utils.GetLerpValue(0f, 24f, animationTime, clamped: true); + } + else + { + maskOpacity = 1f; + } + + if (animationTime >= 35) + { + float scaleFactor = Utils.GetLerpValue(35f, 50f, animationTime, clamped: true); + finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor); + alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor); + } + } + + Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + + if (Projectile.ai[2] > 0) + { + Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/IgnisSigil.png b/Projectiles/Magic/IgnisSigil.png new file mode 100644 index 0000000000..cc092cc9a9 Binary files /dev/null and b/Projectiles/Magic/IgnisSigil.png differ diff --git a/Projectiles/Magic/IgnisSigilEmbers.cs b/Projectiles/Magic/IgnisSigilEmbers.cs new file mode 100644 index 0000000000..48bc309196 --- /dev/null +++ b/Projectiles/Magic/IgnisSigilEmbers.cs @@ -0,0 +1,83 @@ +using System; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class IgnisSigilEmbers : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 9; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 32; + Projectile.friendly = false; // This is VFX + Projectile.ignoreWater = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.damage = 0; // This is VFX + } + + public override void AI() + { + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.22f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); + Projectile.scale -= 0.01f; + + if (Projectile.scale <= 0f) + { + Projectile.Kill(); + } + + if (Projectile.ai[0] <= 3f) + { + Projectile.ai[0] += 1f; + return; + } + + // Gravity! + Projectile.velocity.Y = Projectile.velocity.Y + 0.35f; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + int frameHeight = texture.Height / Main.projFrames[Type]; + Rectangle sourceRect = new Rectangle(0, frameHeight * Projectile.frame, texture.Width, frameHeight); + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, sourceRect, Color.White, Projectile.rotation, sourceRect.Size() * 0.5f, 1f, 0); + return false; + } + + // Handle the projectile's trail from here + private float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Lerp(0f, MathHelper.Lerp(Projectile.scale * 48f, 0f, completionRatio), MathF.Pow(completionRatio, 1f / 2.5f)); + private Color ColorFunction(float completionRatio, Vector2 vertexPos) + { + float offsetTime = Main.GlobalTimeWrappedHourly; + float fadeOpacity = Utils.GetLerpValue(0.5f, 0f, completionRatio, true) * Projectile.Opacity; + Color endColor = Color.DarkOrange; + return Color.Lerp(endColor, Color.DarkSalmon, completionRatio) * fadeOpacity; + } + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_, _) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32); + GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Projectile.Center, Projectile.velocity, false, 2, Projectile.scale * 1.45f, Color.Salmon), pixelate: true); + } + } +} diff --git a/Projectiles/Magic/IgnisSigilFireball.cs b/Projectiles/Magic/IgnisSigilFireball.cs new file mode 100644 index 0000000000..c3187cd90c --- /dev/null +++ b/Projectiles/Magic/IgnisSigilFireball.cs @@ -0,0 +1,157 @@ +using System; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Particles; +using CalamityMod.Graphics.Primitives; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; + +namespace CalamityMod.Projectiles.Magic +{ + public class IgnisSigilFireball : ModProjectile, ILocalizedModType + { + public ref float Time => ref Projectile.ai[0]; + + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 9; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 92; + Projectile.height = 92; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; // Explodes on a delay after hitting + Projectile.timeLeft = 300; + Projectile.alpha = 255; + Projectile.DamageType = DamageClass.Magic; + } + + public override void AI() + { + Time++; + + Projectile.Opacity = Utils.GetLerpValue(0f, 10f, Time, true); + +            // Hasnt hit anything +            if (Projectile.ai[1] == 0) + { +                // Set rotation to face forward +                Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + + Projectile.frameCounter++; + if (Projectile.frameCounter % 4 == 3) + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; + } + else // After hit +            { + Projectile.velocity = Vector2.Zero; + +                // Scale up and die +                Projectile.scale += 0.2f; + if (Projectile.scale >= 1.75f) + { + Projectile.Kill(); + } +                // Failsafe +                if (Projectile.timeLeft > 5) + { + Projectile.timeLeft = 5; + } + } + + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.22f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); + Projectile.scale -= 0.01f; + + if (Projectile.scale <= 0f) + { + Projectile.Kill(); + } + + if (Projectile.ai[0] <= 3f) + { + Projectile.ai[0] += 1f; + return; + } + + GeneralParticleHandler.SpawnParticle(new SquishyLightParticle(Projectile.Center, Projectile.velocity, Projectile.scale * 1.5f, Color.OrangeRed, 3, 1f, 0f, 1f)); + + // Gravity! + Projectile.velocity.Y = Projectile.velocity.Y + 0.125f; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.Daybreak, 180); + Projectile.ai[1] = 1; // Has hit an enemy +            Projectile.penetrate = -1; + } + + // Standard trail drawing logic + private float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Lerp(0f, MathHelper.Lerp(Projectile.scale * 132f, 0f, completionRatio), MathF.Pow(completionRatio, 1f / 2.5f)); + private Color ColorFunction(float completionRatio, Vector2 vertexPos) + { + float offsetTime = Main.GlobalTimeWrappedHourly; + float fadeOpacity = Utils.GetLerpValue(0.5f, 0f, completionRatio, true) * Projectile.Opacity; + Color endColor = Color.IndianRed; + return Color.Lerp(endColor, Color.Orange, completionRatio) * fadeOpacity; + } + public override bool PreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, pixelate: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 340); + + + Texture2D texture = TextureAssets.Projectile[Type].Value; + int frameHeight = texture.Height / Main.projFrames[Type]; + Rectangle sourceRect = new Rectangle(0, frameHeight * Projectile.frame, texture.Width, frameHeight); + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, sourceRect, Color.White, Projectile.rotation, sourceRect.Size() * 0.5f, 1f, 0); + + return false; + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/IgnisSigilHit") { Volume = 0.7f, PitchVariance = 0.1f }, Projectile.Center); + + for (int i = 0; i < 40; i++) + { + Vector2 vel = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.85f, 1.2f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + (new Vector2(Main.rand.NextFloat(-22, -30), Main.rand.NextFloat(-4, 4)).RotatedBy(Projectile.rotation - MathHelper.PiOver2)), Main.rand.NextBool(5) ? 174 : 35, vel * Main.rand.NextFloat(0.1f, 0.9f) + new Vector2(0, -2)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(1.1f, 1.7f); + } + + for (int i = 0; i < 8; i++) + { + Vector2 vel = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.85f, 1.2f); + Projectile embers = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center + (new Vector2(Main.rand.NextFloat(-22, -30), Main.rand.NextFloat(-4, 4)).RotatedBy(Projectile.rotation - MathHelper.PiOver2)), vel * 0.8f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + + GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center + (new Vector2(-26, 0).RotatedBy(Projectile.rotation - MathHelper.PiOver2)), Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.265f, 21, true, 1f)); + + if (Projectile.owner == Main.myPlayer) + { + Projectile explosion = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center + (new Vector2(-26, 0).RotatedBy(Projectile.rotation - MathHelper.PiOver2)), Vector2.Zero, ModContent.ProjectileType(), (int) (Projectile.damage * 3.35f), Projectile.knockBack, Projectile.owner); + explosion.ai[1] = 145f; + explosion.localAI[1] = Main.rand.NextFloat(0.1f, 0.2f); // Interpolate +                explosion.netUpdate = true; + } + } + + public override Color? GetAlpha(Color lightColor) => Color.Lerp(Color.LightGoldenrodYellow, Color.Orange, 0.5f) with { A = 0 } * Projectile.Opacity; + } +} diff --git a/Projectiles/Magic/IgnisSigilFireballExplosion.cs b/Projectiles/Magic/IgnisSigilFireballExplosion.cs new file mode 100644 index 0000000000..dc9bcedbba --- /dev/null +++ b/Projectiles/Magic/IgnisSigilFireballExplosion.cs @@ -0,0 +1,33 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.DraedonsArsenal +{ + public class IgnisSigilFireballExplosion : BaseMassiveExplosionProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override int Lifetime => 16; + public override bool UsesScreenshake => true; + public override float GetScreenshakePower(float pulseCompletionRatio) => CalamityUtils.Convert01To010(pulseCompletionRatio) * 3f; + public override Color GetCurrentExplosionColor(float pulseCompletionRatio) => Color.Lerp(Color.Firebrick, Color.LightSalmon, MathHelper.Clamp(pulseCompletionRatio * 2f, 3f, 6f)); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 2; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.timeLeft = Lifetime; + Projectile.DamageType = DamageClass.Magic; + } + + public override void PostAI() + { + Lighting.AddLight(Projectile.Center, 0, Projectile.Opacity * 0.5f / 255f, Projectile.Opacity); + } + } +} diff --git a/Projectiles/Magic/IncineratingFireball.cs b/Projectiles/Magic/IncineratingFireball.cs index 46cac4412a..77ef628275 100644 --- a/Projectiles/Magic/IncineratingFireball.cs +++ b/Projectiles/Magic/IncineratingFireball.cs @@ -56,9 +56,9 @@ namespace CalamityMod.Projectiles.Magic if (TriggeredBurnOut) Owner.Calamity().burningSeaBurnOut = BurningSea.BurnOutReuseDelay; - bool canUseMana = Owner.CheckMana(Owner.ActiveItem()); + bool canUseMana = Owner.CheckMana(Owner.HeldItem); // Use different behavior depending on if the player is channeling or not. - if (Owner.CantUseHoldout() || !canUseMana || Projectile.timeLeft <= 40) + if (Owner.CantUseHoldout() || !canUseMana || Projectile.timeLeft <= (int)BurningSea.FizzleOutTime) { Released = true; @@ -101,19 +101,28 @@ namespace CalamityMod.Projectiles.Magic // Consume mana periodically. if (Timer % 15 == 0f) - Owner.CheckMana(Owner.ActiveItem(), -1, true); + Owner.CheckMana(Owner.HeldItem, -1, true); - // If channeled for a while, turns red (handled in PreDraw) and starts emitting smoke as a warning. - // The smoke only starts once the fireball is completely red. - if (Timer > BurningSea.BurnOutTime - 60f) + // Spawn little spark effects around the fireball when fully charged. + if (Timer > BurningSea.ChargeTime && Timer < BurningSea.BurnOutTime) { - for (int s = 0; s < 2; s++) + for (int s = 0; s < 6; s++) { - Vector2 smokeLocation = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * 237f; - Vector2 smokeVel = smokeLocation - Projectile.Center; - smokeVel.Normalize(); - smokeVel *= 5f; - HeavySmokeParticle burningUp = new(smokeLocation, smokeVel, new Color(192, 192, 192), 10, 1f, 0.6f); + float sparkRotation = Main.GlobalTimeWrappedHourly * -5.75f + (MathHelper.TwoPi / 6f * s); + Vector2 sparkLocation = Projectile.Center + Vector2.UnitX.RotatedBy(sparkRotation) * 220f; + Vector2 sparkVelocity = Vector2.Normalize(sparkLocation - Projectile.Center).RotatedBy(MathHelper.ToRadians(70)) * 2f; + AltLineParticle spark = new(sparkLocation, sparkVelocity, false, 8, 0.8f, Color.Lerp(Color.Red, Color.Orange, Main.rand.NextFloat(0.3f))); + GeneralParticleHandler.SpawnParticle(spark); + } + } + // If channeled for a while, turns red (handled in PreDraw) and starts emitting smoke as a warning. + if (Timer > BurningSea.BurnOutTime - 90f) + { + for (int s = 0; s < 3; s++) + { + Vector2 smokeLocation = Projectile.Center + Main.rand.NextVector2Circular(220f, 220f); + Vector2 smokeVel = -Vector2.UnitY * Main.rand.NextFloat(7f, 13f); + HeavySmokeParticle burningUp = new(smokeLocation, smokeVel, new Color(192, 192, 192), 10, 0.7f, 0.6f); GeneralParticleHandler.SpawnParticle(burningUp); } } @@ -122,10 +131,10 @@ namespace CalamityMod.Projectiles.Magic if (Timer > BurningSea.BurnOutTime) { Projectile.timeLeft = (int)BurningSea.FizzleOutTime; - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/WeaponEnchant"), Owner.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/WeaponEnchant"), Owner.Center); CombatText.NewText(Owner.Hitbox, new Color(192, 0, 0), CalamityUtils.GetTextValue("Misc.BurningSeaBurn"), true); - Owner.AddBuff(ModContent.BuffType(), (int)BurningSea.FizzleOutTime); + Owner.AddBuff(ModContent.BuffType(), 120); TriggeredBurnOut = true; } } @@ -178,12 +187,16 @@ namespace CalamityMod.Projectiles.Magic // Big fucking fireball for (int i = 0; i < 6; i++) { - float direction = (i % 2f == 0f).ToDirectionInt(); + float direction = (i % 2 == 0).ToDirectionInt(); + float offsetDist = 0f; Color fireballColor = Color.Lerp(new Color(255, 200, 200), new Color(255, 30, 30), MathHelper.Clamp(Timer / BurningSea.ChargeTime, 0f, 1f)); if (Timer > BurningSea.BurnOutTime - 120f) + { fireballColor = Color.Lerp(new Color(255, 30, 30), Color.Red, MathHelper.Clamp((Timer - BurningSea.BurnOutTime + 120f) / 60f, 0f, 1f)); + offsetDist = MathHelper.Lerp(5f, 40f, (Timer - BurningSea.BurnOutTime + 120f) / 120f); + } - Main.spriteBatch.Draw(TheodoreJNoise, Projectile.Center - Main.screenPosition, null, fireballColor, direction * rotation, TheodoreJNoise.Size() / 2f, drawScale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(TheodoreJNoise, Projectile.Center - Main.screenPosition + Main.rand.NextVector2Circular(offsetDist, offsetDist), null, fireballColor, direction * rotation, TheodoreJNoise.Size() / 2f, drawScale, SpriteEffects.None, 0f); } Main.spriteBatch.ExitShaderRegion(); diff --git a/Projectiles/Magic/InfernadoFriendly.cs b/Projectiles/Magic/InfernadoFriendly.cs index 2dd9e9497f..e55502e726 100644 --- a/Projectiles/Magic/InfernadoFriendly.cs +++ b/Projectiles/Magic/InfernadoFriendly.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Magic/InfernalBlade.cs b/Projectiles/Magic/InfernalBlade.cs index 98a4418dea..13748da418 100644 --- a/Projectiles/Magic/InfernalBlade.cs +++ b/Projectiles/Magic/InfernalBlade.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Magic/InfernalBlade2.cs b/Projectiles/Magic/InfernalBlade2.cs index 8a2bc0d826..6d3dd6b05f 100644 --- a/Projectiles/Magic/InfernalBlade2.cs +++ b/Projectiles/Magic/InfernalBlade2.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Magic/IonBlast.cs b/Projectiles/Magic/IonBlast.cs index 9155789df3..9352beef41 100644 --- a/Projectiles/Magic/IonBlast.cs +++ b/Projectiles/Magic/IonBlast.cs @@ -4,7 +4,6 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using rail; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -75,8 +74,8 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - float minMult = 0.2f; - int hitsToMinMult = 5; + float minMult = 0.25f; + int hitsToMinMult = 8; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; } @@ -101,12 +100,12 @@ namespace CalamityMod.Projectiles.Magic // Create Blast float blastSize = 60; - float minMultiplier = 0.25f; - int hitsToMinMult = 6; - Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.3f), 0, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + float minMultiplier = 0.3f; + int hitsToMinMult = 7; + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); blast.timeLeft = 10; blast.DamageType = DamageClass.Magic; - blast.ArmorPenetration = 25; + blast.ArmorPenetration = 40; } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Magic/IonBlasterHoldout.cs b/Projectiles/Magic/IonBlasterHoldout.cs index a49602f0fe..550d6ae5c8 100644 --- a/Projectiles/Magic/IonBlasterHoldout.cs +++ b/Projectiles/Magic/IonBlasterHoldout.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Magic return; } - if (HeldItem.type != Owner.ActiveItem().type) + if (HeldItem.type != Owner.HeldItem.type) { if (manaPower > 0) shootingTimer = -75; @@ -216,7 +216,7 @@ namespace CalamityMod.Projectiles.Magic float manaPercent = ((float)Owner.statMana / (float)Owner.statManaMax2); Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); Vector2 firingVelocity = (shootDirection * 4); - float damageBoost = (manaPower >= 1 ? 1.7f : 1.5f); + float damageBoost = (manaPower >= 1 ? 1.9f : 1.6f); if (big) { @@ -232,7 +232,7 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire2 = new("CalamityMod/Sounds/Item/LanceofDestinyStrong"); SoundEngine.PlaySound(fire2 with { Volume = 0.4f, Pitch = (manaPower >= 1 ? 0.8f : 0.6f) }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 6f * manaPower; + Owner.SetScreenshake(6f * manaPower); int maxProj = (int)(manaPower * 24 * (manaPower >= 1 ? 1 : 0.5f)); for (int i = 0; i < maxProj; i++) { diff --git a/Projectiles/Magic/KeelhaulBubble.cs b/Projectiles/Magic/KeelhaulBubble.cs index a01363c641..53f62bc727 100644 --- a/Projectiles/Magic/KeelhaulBubble.cs +++ b/Projectiles/Magic/KeelhaulBubble.cs @@ -16,6 +16,12 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() || p.type == ModContent.ProjectileType()) + p.Kill(); + } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 80f, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 80f, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); } diff --git a/Projectiles/Magic/KeelhaulGeyserBottom.cs b/Projectiles/Magic/KeelhaulGeyserBottom.cs index 632c9c9e08..dbe61a5152 100644 --- a/Projectiles/Magic/KeelhaulGeyserBottom.cs +++ b/Projectiles/Magic/KeelhaulGeyserBottom.cs @@ -1,7 +1,10 @@ -using Terraria; +using CalamityMod.NPCs; +using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Magic { + [PierceResistExceptionAttribute(true)] public class KeelhaulGeyserBottom : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -19,14 +22,21 @@ namespace CalamityMod.Projectiles.Magic Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.timeLeft = 180; - Projectile.alpha = 90; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.timeLeft = 900; + Projectile.alpha = 255; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() { + if (Projectile.alpha > 90) + { + Projectile.alpha -= 10; + if (Projectile.alpha < 90) + Projectile.alpha = 90; + } + Projectile.frameCounter++; if (Projectile.frameCounter > 6) { diff --git a/Projectiles/Magic/KeelhaulGeyserTop.cs b/Projectiles/Magic/KeelhaulGeyserTop.cs index 69aeb8f78b..db17a5ca70 100644 --- a/Projectiles/Magic/KeelhaulGeyserTop.cs +++ b/Projectiles/Magic/KeelhaulGeyserTop.cs @@ -1,7 +1,10 @@ -using Terraria; +using CalamityMod.NPCs; +using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Magic { + [PierceResistExceptionAttribute(true)] public class KeelhaulGeyserTop : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -19,14 +22,21 @@ namespace CalamityMod.Projectiles.Magic Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.timeLeft = 180; - Projectile.alpha = 90; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.timeLeft = 900; + Projectile.alpha = 255; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() { + if (Projectile.alpha > 90) + { + Projectile.alpha -= 10; + if (Projectile.alpha < 90) + Projectile.alpha = 90; + } + Projectile.frameCounter++; if (Projectile.frameCounter > 6) { diff --git a/Projectiles/Magic/LightningArc.cs b/Projectiles/Magic/LightningArc.cs index 441739fc9c..8f43f46666 100644 --- a/Projectiles/Magic/LightningArc.cs +++ b/Projectiles/Magic/LightningArc.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft = 20; Projectile.penetrate = 5; Projectile.tileCollide = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } diff --git a/Projectiles/Magic/LiquidBlade2.cs b/Projectiles/Magic/LiquidBlade2.cs index 94ab1d3557..3703b43b20 100644 --- a/Projectiles/Magic/LiquidBlade2.cs +++ b/Projectiles/Magic/LiquidBlade2.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Magic/LuxorsGiftMagic.cs b/Projectiles/Magic/LuxorsGiftMagic.cs index ada0659e91..53d96f1139 100644 --- a/Projectiles/Magic/LuxorsGiftMagic.cs +++ b/Projectiles/Magic/LuxorsGiftMagic.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Magic { Vector2 offset = (MathHelper.TwoPi * i / 2f).ToRotationVector2().RotatedBy(Projectile.timeLeft * 0.1f) * 35 * velLerp; Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.1f) * Main.rand.NextFloat(5.5f, 6.5f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 278, dustVel); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.FireworksRGB, dustVel); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.4f, 0.5f); dust.color = Color.Gold; diff --git a/Projectiles/Magic/MadAlchemistsCocktailAlt.cs b/Projectiles/Magic/MadAlchemistsCocktailAlt.cs index 4bc6077cae..8a56db4b2a 100644 --- a/Projectiles/Magic/MadAlchemistsCocktailAlt.cs +++ b/Projectiles/Magic/MadAlchemistsCocktailAlt.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 360); + target.AddBuff(ModContent.BuffType(), 900); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Magic/MagneticBeam.cs b/Projectiles/Magic/MagneticBeam.cs index 9662ab8b21..a59e52fe9a 100644 --- a/Projectiles/Magic/MagneticBeam.cs +++ b/Projectiles/Magic/MagneticBeam.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i <= 4; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), 272, (Projectile.velocity * 3) * Main.rand.NextFloat(0.1f, 0.9f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), DustID.WitherLightning, (Projectile.velocity * 3) * Main.rand.NextFloat(0.1f, 0.9f)); dust.scale = Main.rand.NextFloat(0.3f, 0.5f); dust.noGravity = true; } diff --git a/Projectiles/Magic/ManaBoltSmall2.cs b/Projectiles/Magic/ManaBoltSmall2.cs index 2278759d9f..c95e13a87a 100644 --- a/Projectiles/Magic/ManaBoltSmall2.cs +++ b/Projectiles/Magic/ManaBoltSmall2.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Magic/ManaChargedCoral.cs b/Projectiles/Magic/ManaChargedCoral.cs index 2a0c915a13..4c1c8b0d32 100644 --- a/Projectiles/Magic/ManaChargedCoral.cs +++ b/Projectiles/Magic/ManaChargedCoral.cs @@ -116,7 +116,7 @@ namespace CalamityMod.Projectiles.Magic if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), 45, Vector2.UnitY * -7f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), DustID.ManaRegeneration, Vector2.UnitY * -7f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); dust.noGravity = true; } @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Magic //Sharticles if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), 15, Projectile.velocity * 0.3f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), DustID.MagicMirror, Projectile.velocity * 0.3f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); dust.noGravity = true; } @@ -228,7 +228,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 14; i++) { Vector2 direction = Main.rand.NextVector2Circular(10f, 10f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + direction, 45, direction + Vector2.UnitY * -7f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + direction, DustID.ManaRegeneration, direction + Vector2.UnitY * -7f, Alpha: Main.rand.Next(100) + 120, Scale: Main.rand.NextFloat(1f, 2f)); dust.noGravity = true; } diff --git a/Projectiles/Magic/MelterAmp.cs b/Projectiles/Magic/MelterAmp.cs index 3d959df991..c3969c8959 100644 --- a/Projectiles/Magic/MelterAmp.cs +++ b/Projectiles/Magic/MelterAmp.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.active = false; return; } - if (!player.ActiveItem().CountsAsClass() || player.ActiveItem().shoot != ModContent.ProjectileType()) + if (!player.HeldItem.CountsAsClass() || player.HeldItem.shoot != ModContent.ProjectileType()) { Projectile.active = false; return; diff --git a/Projectiles/Magic/NanoPurgeHoldout.cs b/Projectiles/Magic/NanoPurgeHoldout.cs index 6e580453fd..54bed4ff59 100644 --- a/Projectiles/Magic/NanoPurgeHoldout.cs +++ b/Projectiles/Magic/NanoPurgeHoldout.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -38,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic { base.KillHoldoutLogic(); bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? NanoPurge.UseTime); - bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem()); + bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.HeldItem); if (!manaOK) Projectile.Kill(); } @@ -68,26 +67,29 @@ namespace CalamityMod.Projectiles.Magic // Update the animation. Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; - bool manaCostPaid = Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + bool manaCostPaid = Owner.CheckMana(Owner.HeldItem, -1, true, false); if (manaCostPaid) { postShotFade = 1; SoundEngine.PlaySound(SoundID.Item91, Projectile.Center); - int projID = ModContent.ProjectileType(); - float shootSpeed = HeldItem.shootSpeed; - float inaccuracyRatio = 0.045f; - Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY); - Vector2 perp = shootDirection.RotatedBy(MathHelper.PiOver2); - - // Fire a pair of lasers, one with a negative offset, one with a positive offset. - for (int i = -1; i <= 1; i += 2) + if (Main.myPlayer == Projectile.owner) { - Vector2 spread = Main.rand.NextVector2CircularEdge(shootSpeed, shootSpeed); - Vector2 shootVelocity = shootDirection * shootSpeed + inaccuracyRatio * spread; - Vector2 splitBarrelPos = GunTipPosition + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner); - SpawnFiringDust(splitBarrelPos, shootVelocity); + int projID = ModContent.ProjectileType(); + float shootSpeed = HeldItem.shootSpeed; + float inaccuracyRatio = 0.045f; + Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY); + Vector2 perp = shootDirection.RotatedBy(MathHelper.PiOver2); + + // Fire a pair of lasers, one with a negative offset, one with a positive offset. + for (int i = -1; i <= 1; i += 2) + { + Vector2 spread = Main.rand.NextVector2CircularEdge(shootSpeed, shootSpeed); + Vector2 shootVelocity = shootDirection * shootSpeed + inaccuracyRatio * spread; + Vector2 splitBarrelPos = GunTipPosition + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner); + SpawnFiringDust(splitBarrelPos, shootVelocity); + } } } } diff --git a/Projectiles/Magic/NanoPurgeLaser.cs b/Projectiles/Magic/NanoPurgeLaser.cs index 9f074f7308..c0972778f5 100644 --- a/Projectiles/Magic/NanoPurgeLaser.cs +++ b/Projectiles/Magic/NanoPurgeLaser.cs @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Magic // If the index is not default, smart bounce in the direction of that enemy. if (index != -1) { - Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.ActiveItem().shootSpeed, 3); + Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.HeldItem.shootSpeed, 3); } else // Otherwise, use standard bouncing behavior. { diff --git a/Projectiles/Magic/NebulaCloudCore.cs b/Projectiles/Magic/NebulaCloudCore.cs index d48efbeab7..531bbd6f31 100644 --- a/Projectiles/Magic/NebulaCloudCore.cs +++ b/Projectiles/Magic/NebulaCloudCore.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Magic public class NebulaCloudCore : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; - private const float IntendedVelocity = 4f; + private const float IntendedVelocity = 6f; public override void SetStaticDefaults() { @@ -28,12 +28,12 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 32; Projectile.friendly = true; Projectile.alpha = 255; - Projectile.penetrate = 4; + Projectile.penetrate = 3; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Magic; Projectile.MaxUpdates = 3; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8 * Projectile.MaxUpdates; // 8 effective, 24 total + Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; // 10 effective, 30 total } public override void AI() @@ -351,12 +351,10 @@ namespace CalamityMod.Projectiles.Magic int totalProjectiles = Main.rand.Next(6, 9); float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); - float velocity = Main.rand.Next(70, 101) * 0.1f; - Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Utils.RandomVector2(Main.rand, -30f, 30f), velocity2, type, (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.8f, Projectile.owner); + Vector2 velocity = -Vector2.UnitY.RotatedBy(radians * k) * Main.rand.NextFloat(7f, 10f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Main.rand.NextVector2Circular(30f, 30f), velocity, type, (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.8f, Projectile.owner); } } } diff --git a/Projectiles/Magic/NebulaElementalBeam.cs b/Projectiles/Magic/NebulaElementalBeam.cs index 0bcde074e7..4d45d789dd 100644 --- a/Projectiles/Magic/NebulaElementalBeam.cs +++ b/Projectiles/Magic/NebulaElementalBeam.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -42,7 +43,7 @@ namespace CalamityMod.Projectiles.Magic int totalBubbles = 24; for (int i = 0; i < totalBubbles; i++) { - Dust nebulaBubble = Dust.NewDustPerfect(Projectile.Center, 242); + Dust nebulaBubble = Dust.NewDustPerfect(Projectile.Center, DustID.PinkTorch); nebulaBubble.velocity = Main.rand.NextVector2Circular(6f, 6f); nebulaBubble.scale = Main.rand.NextFloat(2f, 3f); nebulaBubble.noGravity = true; diff --git a/Projectiles/Magic/NebulaNova.cs b/Projectiles/Magic/NebulaNova.cs index 84830b3f48..db975c183e 100644 --- a/Projectiles/Magic/NebulaNova.cs +++ b/Projectiles/Magic/NebulaNova.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.timeLeft = TotalXFrames * TotalYFrames * FrameTimer; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = 30; } public override void AI() diff --git a/Projectiles/Magic/NebulousCataclysm_Held.cs b/Projectiles/Magic/NebulousCataclysm_Held.cs index d29dbbe09e..016f2c14e1 100644 --- a/Projectiles/Magic/NebulousCataclysm_Held.cs +++ b/Projectiles/Magic/NebulousCataclysm_Held.cs @@ -60,9 +60,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.ai[0] = 0f; bool shoot = CurrentFrame == ShootFrame && Projectile.ai[0] == 0f; - bool ableToShoot = true; + bool ableToShoot = false; bool weaponInUse = !Owner.CantUseHoldout(); - int manaCost = (int)(30f * Owner.manaCost); Vector2 halvedSize = Projectile.Size / 2f; Vector2 staffOffset = halvedSize + new Vector2(24f, 24f); @@ -72,51 +71,29 @@ namespace CalamityMod.Projectiles.Magic if (weaponInUse) { - if (Owner.statMana < manaCost) - { - if (Owner.manaFlower) - { - Owner.QuickMana(); - if (Owner.statMana >= manaCost) - { - Owner.manaRegenDelay = (int)Owner.maxRegenDelay; - Owner.statMana -= manaCost; - } - else - { - Projectile.Kill(); - ableToShoot = false; - } - } - else - { - Projectile.Kill(); - ableToShoot = false; - } - } + if (Owner.CheckMana(Owner.HeldItem.mana)) + ableToShoot = true; else - { - if (Owner.statMana >= manaCost) - { - Owner.statMana -= manaCost; - Owner.manaRegenDelay = (int)Owner.maxRegenDelay; - } - } + Projectile.Kill(); if (ableToShoot) SoundEngine.PlaySound(SoundID.Item117, Projectile.Center); } + else + Projectile.Kill(); if (Main.myPlayer == Projectile.owner && ableToShoot) { + Owner.CheckMana(Owner.HeldItem.mana, true); + int projectileType = ModContent.ProjectileType(); float coreVelocity = 8f; - int weaponDamage = Owner.GetWeaponDamage(Owner.ActiveItem()); - float weaponKnockback = Owner.ActiveItem().knockBack; + int weaponDamage = Owner.GetWeaponDamage(Owner.HeldItem); + float weaponKnockback = Owner.HeldItem.knockBack; if (weaponInUse) { - weaponKnockback = Owner.GetWeaponKnockback(Owner.ActiveItem(), weaponKnockback); - float scaleFactor = Owner.ActiveItem().shootSpeed * Projectile.scale; + weaponKnockback = Owner.GetWeaponKnockback(Owner.HeldItem, weaponKnockback); + float scaleFactor = Owner.HeldItem.shootSpeed * Projectile.scale; Vector2 projectileSpawnPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); Vector2 projectileDestination = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - projectileSpawnPosition; diff --git a/Projectiles/Magic/NightOrb.cs b/Projectiles/Magic/NightOrb.cs index c5373229e3..0bfd8ae7cc 100644 --- a/Projectiles/Magic/NightOrb.cs +++ b/Projectiles/Magic/NightOrb.cs @@ -16,6 +16,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft = 30; Projectile.DamageType = DamageClass.Magic; Projectile.ignoreWater = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/NightsRayBeam.cs b/Projectiles/Magic/NightsRayBeam.cs index 0e38e73656..b04f36ae02 100644 --- a/Projectiles/Magic/NightsRayBeam.cs +++ b/Projectiles/Magic/NightsRayBeam.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -23,6 +24,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = 10; Projectile.extraUpdates = 100; Projectile.timeLeft = 150; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -33,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 2; i++) { Vector2 dustSpawnPos = Projectile.position - Projectile.velocity * i / 2f; - Dust corruptMagic = Dust.NewDustPerfect(dustSpawnPos, 27); + Dust corruptMagic = Dust.NewDustPerfect(dustSpawnPos, DustID.Shadowflame); corruptMagic.color = Color.Lerp(Color.Fuchsia, Color.Magenta, Main.rand.NextFloat(0.6f)); corruptMagic.scale = Main.rand.NextFloat(0.96f, 1.04f); corruptMagic.noGravity = true; diff --git a/Projectiles/Magic/OmicronHoldout.cs b/Projectiles/Magic/OmicronHoldout.cs index a476798def..4d83523c81 100644 --- a/Projectiles/Magic/OmicronHoldout.cs +++ b/Projectiles/Magic/OmicronHoldout.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Magic if (Owner.Calamity().mouseRight && PostFireCooldown <= 0) { - if (Owner.CheckMana(Owner.ActiveItem(), (int)(HeldItem.mana * Owner.manaCost) * 16, true, false)) + if (Owner.CheckMana(Owner.HeldItem, (int)(HeldItem.mana * Owner.manaCost) * 13, true)) { PostFireCooldown = 100; Shoot(true); @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Magic } else if (ShootingTimer >= FireRate) { - if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false) && PostFireCooldown <= 0) + if (Owner.CheckMana(Owner.HeldItem, -1, true) && PostFireCooldown <= 0) { MaxFireRateShots++; @@ -106,8 +106,9 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(pulse2); } - Owner.Calamity().GeneralScreenShakePower = 6.5f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 32, Projectile.knockBack, Projectile.owner, 0, 0); + Owner.SetScreenshake(6.5f); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 32, Projectile.knockBack, Projectile.owner, 0, 0); for (int i = 0; i < 8; i++) { @@ -120,15 +121,18 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire = new("CalamityMod/Sounds/Item/ArcNovaDiffuserBigShot"); SoundEngine.PlaySound(fire with { Volume = 0.2f, Pitch = 0.9f }, Projectile.Center); - for (int i = 0; i < 5; i++) + if (Main.myPlayer == Projectile.owner) { - firingVelocity3 = (shootDirection * 10).RotatedBy((0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); - Projectile.NewProjectile(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.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); - Projectile.NewProjectile(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.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); + Projectile.NewProjectile(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.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); + } } Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); @@ -166,7 +170,7 @@ namespace CalamityMod.Projectiles.Magic Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel, EffectsColor, Main.rand.Next(30, 50 + 1), Main.rand.NextFloat(0.1f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); GeneralParticleHandler.SpawnParticle(smoke); - Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.2f, 0.8f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.2f, 0.8f)); dust.noGravity = false; dust.color = EffectsColor; } diff --git a/Projectiles/Magic/OmicronWingman.cs b/Projectiles/Magic/OmicronWingman.cs index 6fd83a0954..6e2173aa5c 100644 --- a/Projectiles/Magic/OmicronWingman.cs +++ b/Projectiles/Magic/OmicronWingman.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Magic MovingUp = Projectile.ai[2] == 1; firingDelay--; - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; // Update damage based on curent magic damage stat (so Mana Sickness affects it) Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Magic if (launchDelay < 50) launchDelay++; - if (launchDelay >= 50 && (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 2, true, false))) + if (launchDelay >= 50 && (Owner.CheckMana(Owner.HeldItem, (int)(heldItem.mana * Owner.manaCost) * 2, true, false))) { Shoot(true); PostFireCooldown = 50; @@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.Magic } else if (ShootingTimer >= FiringTime) { - if (Owner.CheckMana(Owner.ActiveItem(), -1, false, false)) + if (Owner.CheckMana(Owner.HeldItem, -1, false, false)) { Shoot(false); ShootingTimer = 0; @@ -221,7 +221,7 @@ namespace CalamityMod.Projectiles.Magic Particle smoke = new HeavySmokeParticle(tipPosition, smokeVel, StaticEffectsColor, Main.rand.Next(30, 50 + 1), Main.rand.NextFloat(0.1f, 0.4f), 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.2f, 0.8f)); + Dust dust = Dust.NewDustPerfect(tipPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.2f, 0.8f)); dust.noGravity = false; dust.color = StaticEffectsColor; } diff --git a/Projectiles/Magic/OrdoSigil.cs b/Projectiles/Magic/OrdoSigil.cs new file mode 100644 index 0000000000..27717cd24b --- /dev/null +++ b/Projectiles/Magic/OrdoSigil.cs @@ -0,0 +1,117 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Projectiles.Ranged; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Magic +{ + public class OrdoSigil : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private bool spawnedProjectile = false; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 74; + Projectile.friendly = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)Projectile.ai[0]]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive && Projectile.ai[2] == 0) + { + Projectile.Kill(); + return; + } + + int i = (int)Projectile.ai[1]; + float dist = i % 3 == 0 ? 270f : 280f; + float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f); + + Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot); + Projectile.Center = sigilPos; + + if (Projectile.ai[2] > 0) + { + Projectile.localAI[0]++; + + if (Projectile.localAI[0] == 35 && !spawnedProjectile) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/OntologicalDespoilerLargeShot") { Volume = 0.5f, PitchVariance = 0.1f }, Projectile.Center); + + Player owner = Main.player[Projectile.owner]; + + owner.SetScreenshake(3f); + Vector2 targetDirection = Projectile.Center.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX); + + spawnedProjectile = true; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, targetDirection * 18f, ModContent.ProjectileType(), (int) (Projectile.damage * 4.5f), Projectile.knockBack, Projectile.owner); + } + + if (Projectile.localAI[0] >= 50) + { + Projectile.Kill(); + } + } + else + { + Projectile.scale = parent.scale; + Projectile.rotation = 0; + Projectile.alpha = parent.alpha; + } + + if (parentActive) + { + Projectile.timeLeft = parent.timeLeft; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D blankTexture = ModContent.Request("CalamityMod/Projectiles/Magic/BlankSigil").Value; + + float finalScale = Projectile.scale; + float alphaOpacity = 1f - (Projectile.alpha / 255f); + float maskOpacity = 0f; + + // Apply animation effects if fading + if (Projectile.ai[2] > 0) + { + float animationTime = Projectile.localAI[0]; + + if (animationTime <= 24) + { + maskOpacity = Utils.GetLerpValue(0f, 24f, animationTime, clamped: true); + } + else + { + maskOpacity = 1f; + } + + if (animationTime >= 35) + { + float scaleFactor = Utils.GetLerpValue(35f, 50f, animationTime, clamped: true); + finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor); + alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor); + } + } + + Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + + if (Projectile.ai[2] > 0) + { + Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/OrdoSigil.png b/Projectiles/Magic/OrdoSigil.png new file mode 100644 index 0000000000..a6229c8efe Binary files /dev/null and b/Projectiles/Magic/OrdoSigil.png differ diff --git a/Projectiles/Magic/OrdoSigilBeam.cs b/Projectiles/Magic/OrdoSigilBeam.cs new file mode 100644 index 0000000000..4624f0c9f5 --- /dev/null +++ b/Projectiles/Magic/OrdoSigilBeam.cs @@ -0,0 +1,61 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class OrdoSigilBeam : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public ref float Time => ref Projectile.ai[0]; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 32; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = 5; + Projectile.MaxUpdates = 15; + Projectile.timeLeft = 20 * Projectile.MaxUpdates; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + Time++; + + // Render the needle beam as a pair of severely stretched spark particles. + // This has to be done only on specific extra updates or it'll instantly overload the particle limit. + bool isDrawingUpdate = Projectile.numUpdates % 3 == 0; + if (Time > 6f && isDrawingUpdate) + { + Color outerSparkColor = new Color(255, 255, 255); + float scaleBoost = MathHelper.Clamp(Time * 0.03f, 0f, 2f); + float outerSparkScale = 3.2f + scaleBoost; + SparkParticle spark = new SparkParticle(Projectile.Center, Projectile.velocity, false, 7, outerSparkScale, outerSparkColor); + GeneralParticleHandler.SpawnParticle(spark); + + Color innerSparkColor = new Color(181, 181, 181); + float innerSparkScale = 1.6f + scaleBoost; + SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity, false, 7, innerSparkScale, innerSparkColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + + if (Projectile.FinalExtraUpdate()) + Lighting.AddLight(Projectile.Center, Color.MediumBlue.ToVector3() * 0.4f); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + } + + } +} diff --git a/Projectiles/Magic/PerditoSigil.cs b/Projectiles/Magic/PerditoSigil.cs new file mode 100644 index 0000000000..366876353f --- /dev/null +++ b/Projectiles/Magic/PerditoSigil.cs @@ -0,0 +1,108 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Projectiles.Magic +{ + public class PerditoSigil : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private bool spawnedProjectile = false; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 74; + Projectile.friendly = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)Projectile.ai[0]]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive && Projectile.ai[2] == 0) + { + Projectile.Kill(); + return; + } + + int i = (int)Projectile.ai[1]; + float dist = i % 3 == 0 ? 270f : 280f; + float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f); + + Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot); + Projectile.Center = sigilPos; + + + if (Projectile.ai[2] > 0) + { + Projectile.localAI[0]++; + + if (Projectile.localAI[0] == 35 && !spawnedProjectile) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Main.MouseWorld, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + spawnedProjectile = true; + } + + if (Projectile.localAI[0] >= 50) + { + Projectile.Kill(); + } + } + else + { + Projectile.scale = parent.scale; + Projectile.rotation = 0; + Projectile.alpha = parent.alpha; + } + + if (parentActive) + { + Projectile.timeLeft = parent.timeLeft; + } + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D blankTexture = ModContent.Request("CalamityMod/Projectiles/Magic/BlankSigil").Value; + + float finalScale = Projectile.scale; + float alphaOpacity = 1f - (Projectile.alpha / 255f); + float maskOpacity = 0f; + + // Apply animation effects if fading + if (Projectile.ai[2] > 0) + { + float animationTime = Projectile.localAI[0]; + + if (animationTime <= 24) + { + maskOpacity = Utils.GetLerpValue(0f, 24f, animationTime, clamped: true); + } + else + { + maskOpacity = 1f; + } + + if (animationTime >= 35) + { + float scaleFactor = Utils.GetLerpValue(35f, 50f, animationTime, clamped: true); + finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor); + alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor); + } + } + + Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + + if (Projectile.ai[2] > 0) + { + Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/PerditoSigil.png b/Projectiles/Magic/PerditoSigil.png new file mode 100644 index 0000000000..75de686aaa Binary files /dev/null and b/Projectiles/Magic/PerditoSigil.png differ diff --git a/Projectiles/Magic/PerditoSigilShot.cs b/Projectiles/Magic/PerditoSigilShot.cs new file mode 100644 index 0000000000..e96d170b15 --- /dev/null +++ b/Projectiles/Magic/PerditoSigilShot.cs @@ -0,0 +1,131 @@ +using System; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class PerditoSigilShot : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float time => ref Projectile.ai[0]; + public Color baseColor = Color.White; + public int sineDir = 1; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 22; + Projectile.DamageType = DamageClass.Magic; + Projectile.extraUpdates = 3; + Projectile.tileCollide = false; + Projectile.ArmorPenetration = 25; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + float lifeProgress = 1f - (Projectile.timeLeft / 22f); + + float fadeIn = Utils.GetLerpValue(0f, 0.25f, lifeProgress, true); + float fadeOut = Utils.GetLerpValue(1f, 0.66f, lifeProgress, true); + float fadeMult = fadeIn * fadeOut; + + // Store fade multiplier in ai[3] + Projectile.localAI[0] = fadeMult; + + if (time == 0) + { + sineDir = Main.rand.NextBool() ? 1 : -1; + Projectile.ai[1] = Main.rand.NextFloat(-0.06f, 0.06f); // curvature + } + + float curvature = Projectile.ai[1]; + if (curvature != 0f) + Projectile.velocity = Projectile.velocity.RotatedBy(curvature); + + Projectile.scale = MathHelper.Lerp(0.4f, 2.4f, fadeMult); + baseColor = Color.LightGray * fadeMult; + + if (time > 13) + { + float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi); + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; + float scale = Main.rand.NextFloat(0.8f, 1.1f); + if (Main.rand.NextBool(3)) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset * sineDir, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust2.noGravity = true; + dust2.scale = scale; + dust2.color = baseColor; + } + if (Main.rand.NextBool(3)) + { + Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset * sineDir, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust3.noGravity = true; + dust3.scale = scale; + dust3.color = baseColor; + } + } + + if (time > 13 && time < 34 && Projectile.ai[2] > 0) + { + Projectile.Center += Projectile.velocity.RotatedBy((Projectile.ai[2] == 1 ? MathHelper.PiOver2 : -MathHelper.PiOver2)) * 0.2f; + } + + time++; + } + + public override bool PreDraw(ref Color lightColor) + { + float fadeMult = Projectile.localAI[0]; + + Asset tex = ModContent.Request("CalamityMod/Particles/DrainLineBloom"); + Asset tex2 = ModContent.Request("CalamityMod/Particles/DrainLine"); + + // Colors dynamically fade out + Color trailColor1 = (baseColor with { A = 0 }) * (0.35f * fadeMult); + Color trailColor2 = Color.Black * fadeMult; + + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], trailColor1, 1, tex.Value); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], trailColor2, 1, tex2.Value, true, true); + + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, (Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()), (Projectile.velocity * 3).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.2f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.15f, 1.45f); + dust.color = baseColor; + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.97f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + } +} diff --git a/Projectiles/Magic/PerditoSigilShotCreator.cs b/Projectiles/Magic/PerditoSigilShotCreator.cs new file mode 100644 index 0000000000..e04665bd0c --- /dev/null +++ b/Projectiles/Magic/PerditoSigilShotCreator.cs @@ -0,0 +1,65 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class PerditoSigilShotCreator : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public ref float FiringTimer => ref Projectile.ai[0]; + public ref float ShotsFiredCount => ref Projectile.ai[1]; + + private const int TotalShots = 13; + private const int DelayBetweenShots = 4; + private const float ShotSpeed = 17f; + private const float SpawnRadius = 150f; // Radius around the cursor where shots spawn + + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = DelayBetweenShots * TotalShots + 10; + } + + public override void AI() + { + Projectile.Center = Main.MouseWorld; + Vector2 targetCenter = Projectile.Center; + + FiringTimer++; + + if (FiringTimer % DelayBetweenShots == 0 && ShotsFiredCount < TotalShots) + { + ShotsFiredCount++; + if (ShotsFiredCount == TotalShots) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit2") { Volume = 0.9f, PitchVariance = 0.1f }, Projectile.Center); + } + else + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit1") { Volume = 0.8f, PitchVariance = 0.1f }, Projectile.Center); + + float startAngle = Main.rand.NextFloat(MathHelper.TwoPi); + Vector2 spawnOffset = startAngle.ToRotationVector2() * SpawnRadius; + Vector2 spawnPosition = targetCenter + spawnOffset; + + Vector2 velocity = (targetCenter - spawnPosition).SafeNormalize(Vector2.UnitX) * ShotSpeed; + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPosition, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + + if (ShotsFiredCount >= TotalShots) + { + Projectile.Kill(); + } + } + } +} diff --git a/Projectiles/Magic/PhantasmalFuryProj.cs b/Projectiles/Magic/PhantasmalFuryProj.cs index 8eb1c426c2..ac35739eca 100644 --- a/Projectiles/Magic/PhantasmalFuryProj.cs +++ b/Projectiles/Magic/PhantasmalFuryProj.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Projectiles.Magic public int time = 0; public float dustRotation = 0; public bool launched = false; + public NPC targeted; public override void SetStaticDefaults() { Main.projFrames[Type] = 4; @@ -63,11 +64,11 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = 1; launched = true; } + if (targeted == null || targeted.life <= 0) + targeted = Projectile.Center.ClosestNPCAt(950); + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.15f, 6, 0.98f, accelerate: true); - NPC target = Projectile.Center.ClosestNPCAt(700); - CalamityUtils.HomeInOnSelectedNPC(Projectile, target, true, 0.15f, 6, 0.98f, accelerate: true); - - if (time < 550 && target == null) + if (time < 550 && targeted == null) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction if (Projectile.velocity.Length() < 6) @@ -89,7 +90,7 @@ namespace CalamityMod.Projectiles.Magic if (time > 5) { Vector2 dustPos = Projectile.Center + (MathHelper.Pi + dustRotation + MathHelper.PiOver2).ToRotationVector2() * 10f * Projectile.scale; - Dust dust = Dust.NewDustPerfect(dustPos, 175, (MathHelper.Pi + dustRotation * Math.Sign(Projectile.velocity.Length())).ToRotationVector2() * 2); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.SpectreStaff, (MathHelper.Pi + dustRotation * Math.Sign(Projectile.velocity.Length())).ToRotationVector2() * 2); dust.noGravity = false; dust.scale = Main.rand.NextFloat(0.75f, 1.2f); dust.alpha = Main.rand.Next(100, 170 + 1); @@ -99,19 +100,25 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - modifiers.SourceDamage *= (launched ? 1f : 0.4f); + modifiers.SourceDamage *= (launched ? 1f : 0.3f); Player Owner = Main.player[Projectile.owner]; Vector2 launchVel = (Owner.Center - target.Center).SafeNormalize(Vector2.UnitY) * -10 * (launched ? 0.5f : 1); target.MoveNPC(launchVel, 10 * (launched ? 0.5f : 1), true); } - + public override bool? CanHitNPC(NPC target) + { + if (targeted != null) + return (target == targeted ? null : false); + else + return null; + } public override void OnKill(int timeLeft) { for (int i = 0; i <= 3; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 175, (Projectile.velocity * 6).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(1.2f, 1.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.SpectreStaff, (Projectile.velocity * 6).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(1.2f, 1.8f)); dust.noGravity = true; Dust chargefull = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 278 : 267); chargefull.velocity = Projectile.velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(1f, 4); diff --git a/Projectiles/Magic/Phantom.cs b/Projectiles/Magic/Phantom.cs index 34b9525e3e..eb3af39916 100644 --- a/Projectiles/Magic/Phantom.cs +++ b/Projectiles/Magic/Phantom.cs @@ -14,6 +14,7 @@ namespace CalamityMod.Projectiles.Magic public int spinDir = 100; public int waveOften = 40; public float scaleVariance = 1; + public NPC targeted; public bool launched = false; public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; @@ -70,11 +71,11 @@ namespace CalamityMod.Projectiles.Magic { time = 600; } + if (targeted == null || targeted.life <= 0) + targeted = Projectile.Center.ClosestNPCAt(950); + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.15f, 6, 0.98f, accelerate: true); - NPC target = Projectile.Center.ClosestNPCAt(550); - CalamityUtils.HomeInOnSelectedNPC(Projectile, target, true, 0.15f, 6, 0.98f, accelerate: true); - - if (time < 550 && target == null) + if (time < 550 && targeted == null) { if (Projectile.velocity.Length() < 6) Projectile.velocity += (mouse - Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.35f; @@ -101,7 +102,7 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - modifiers.SourceDamage *= (launched ? 1f : 0.4f); + modifiers.SourceDamage *= (launched ? 1f : 0.3f); Player Owner = Main.player[Projectile.owner]; @@ -109,11 +110,18 @@ namespace CalamityMod.Projectiles.Magic target.MoveNPC(launchVel, 10 * (launched ? 0.5f : 1), true); } + public override bool? CanHitNPC(NPC target) + { + if (targeted != null) + return (target == targeted ? null : false); + else + return null; + } public override void OnKill(int timeLeft) { for (int i = 0; i <= 2; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 175, (Projectile.velocity * 3).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.SpectreStaff, (Projectile.velocity * 3).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.3f)); dust.noGravity = true; } } diff --git a/Projectiles/Magic/PhotosyntheticSolarBeam.cs b/Projectiles/Magic/PhotosyntheticSolarBeam.cs index fb6fd037ed..b6a874652d 100644 --- a/Projectiles/Magic/PhotosyntheticSolarBeam.cs +++ b/Projectiles/Magic/PhotosyntheticSolarBeam.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -18,7 +19,6 @@ namespace CalamityMod.Projectiles.Magic public override Texture2D LaserMiddleTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/UltimaRayMid", AssetRequestMode.ImmediateLoad).Value; public override Texture2D LaserEndTexture => ModContent.Request("CalamityMod/ExtraTextures/Lasers/UltimaRayEnd", AssetRequestMode.ImmediateLoad).Value; - public ref float ShardCooldown => ref Projectile.ai[1]; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() { @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.ignoreWater = true; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 12; + Projectile.localNPCHitCooldown = -1; Projectile.tileCollide = false; Projectile.timeLeft = (int)Lifetime; } @@ -42,13 +42,13 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < starPoints; i++) { float angle = MathHelper.TwoPi * i / starPoints; - for (int j = 0; j < 12; j++) + for (int j = 0; j < 6; j++) { - float starSpeed = MathHelper.Lerp(1f, 7f, j / 12f); - Color dustColor = Color.Lerp(Color.White, Color.YellowGreen, j / 12f); - float dustScale = MathHelper.Lerp(1.6f, 0.85f, j / 12f); + float starSpeed = MathHelper.Lerp(1f, 7f, j / 6f); + Color dustColor = Color.Lerp(Color.White, Color.YellowGreen, j / 6f); + float dustScale = MathHelper.Lerp(1.6f, 0.85f, j / 6f); - Dust terraMagic = Dust.NewDustPerfect(Projectile.Center, 107); + Dust terraMagic = Dust.NewDustPerfect(Projectile.Center, DustID.Terra); terraMagic.velocity = angle.ToRotationVector2() * starSpeed; terraMagic.color = dustColor; terraMagic.scale = dustScale; @@ -56,19 +56,16 @@ namespace CalamityMod.Projectiles.Magic } } - int ovalPoints = 42; + int ovalPoints = 30; for (int i = 0; i < ovalPoints; i++) { float angle = MathHelper.TwoPi * i / ovalPoints; - Dust terraMagic = Dust.NewDustPerfect(Projectile.Center, 107); + Dust terraMagic = Dust.NewDustPerfect(Projectile.Center, DustID.Terra); terraMagic.velocity = angle.ToRotationVector2() * 6f; terraMagic.scale = 1.1f; terraMagic.noGravity = true; } } - - if (ShardCooldown > 0f) - ShardCooldown--; } public override void DetermineScale() => Projectile.scale = Projectile.timeLeft / Lifetime * MaxScale; @@ -89,18 +86,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (ShardCooldown > 0f) - return; - - // The "Center" of the laser is actually the start of it in this context. - // Collision is done separately. This might have a slight offset due to collision - // boxes, but that should be negligible. - float lengthFromStart = Projectile.Distance(target.Center); - - int totalShards = (int)MathHelper.Lerp(1, 3, MathHelper.Clamp(lengthFromStart / MaxLaserLength * 1.5f, 0f, 1f)); - int shardType = ModContent.ProjectileType(); - int shardDamage = (int)(Projectile.damage * 0.5); - for (int i = 0; i < totalShards; i++) + for (int i = 0; i < 2; i++) { int tries = 0; Vector2 spawnOffset; @@ -111,11 +97,8 @@ namespace CalamityMod.Projectiles.Magic } while (Collision.SolidCollision((target.Center + spawnOffset).ToTileCoordinates().ToVector2(), 4, 4) && tries < 10); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center + spawnOffset, Main.rand.NextVector2CircularEdge(6f, 6f), shardType, shardDamage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center + spawnOffset, Main.rand.NextVector2CircularEdge(6f, 6f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); } - - ShardCooldown = 3f; - Projectile.netUpdate = true; } } } diff --git a/Projectiles/Magic/PlagueFang.cs b/Projectiles/Magic/PlagueFang.cs index 443df05763..6451fbf2f3 100644 --- a/Projectiles/Magic/PlagueFang.cs +++ b/Projectiles/Magic/PlagueFang.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -78,7 +77,10 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); + //Doze - I gave this long debuff infliction times due to the lack of weapons that inflict debuffs for a decent time + //Most common vanilla debuffs have a way to inflict them for 15, 20, or even 30 seconds + //Poison and Venom staff in vanilla do 30 seconds, so this should too as it's a spiritual successor to them. + target.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(30)); } } } diff --git a/Projectiles/Magic/PlasmaRay.cs b/Projectiles/Magic/PlasmaRay.cs index 76a251b329..42cad39feb 100644 --- a/Projectiles/Magic/PlasmaRay.cs +++ b/Projectiles/Magic/PlasmaRay.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/PlasmaRay2.cs b/Projectiles/Magic/PlasmaRay2.cs index cb246a839a..2078a2e6a4 100644 --- a/Projectiles/Magic/PlasmaRay2.cs +++ b/Projectiles/Magic/PlasmaRay2.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Magic { for (int k = 0; k < 3; k++) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 65, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.DemonTorch, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); } } } diff --git a/Projectiles/Magic/PlasmaRifleExplosion.cs b/Projectiles/Magic/PlasmaRifleExplosion.cs index 358b53ed41..1c8ae3d674 100644 --- a/Projectiles/Magic/PlasmaRifleExplosion.cs +++ b/Projectiles/Magic/PlasmaRifleExplosion.cs @@ -1,7 +1,6 @@ using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -27,13 +26,5 @@ namespace CalamityMod.Projectiles.Magic } public override void PostAI() => Lighting.AddLight(Projectile.Center, Color.Chartreuse.ToVector3() * Projectile.Opacity * 0.7f); - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.9f); - if (Projectile.damage < 1) - Projectile.damage = 1; - } } } diff --git a/Projectiles/Magic/PlasmaRifleShot.cs b/Projectiles/Magic/PlasmaRifleShot.cs index e3f148857f..2be09d6972 100644 --- a/Projectiles/Magic/PlasmaRifleShot.cs +++ b/Projectiles/Magic/PlasmaRifleShot.cs @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(AnomalysNanogunMPFBBoom.MPFBExplosion, Projectile.Center); if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, ai1: 160f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.7f), Projectile.knockBack, Projectile.owner, ai1: 160f); for (int k = 0; k < 30; k++) { @@ -98,10 +98,10 @@ namespace CalamityMod.Projectiles.Magic } } - internal float HeadWidthFunction(float completionRatio) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f) * Utils.GetLerpValue(0.5f, 0.25f, MathF.Abs(0.5f - completionRatio), true); - internal Color HeadColorFunction(float completionRatio) => Color.LightSlateGray * Projectile.Opacity; - internal float TrailWidthFunction(float completionRatio) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f); - internal Color TrailColorFunction(float completionRatio) => Color.Lerp(Color.Chartreuse, Color.SlateGray, Utils.Remap(Projectile.Opacity, 0.5f, 1f, 0f, 0.8f)) * Projectile.Opacity * 0.3f; + internal float HeadWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f) * Utils.GetLerpValue(0.5f, 0.25f, MathF.Abs(0.5f - completionRatio), true); + internal Color HeadColorFunction(float completionRatio, Vector2 vertexPos) => Color.LightSlateGray * Projectile.Opacity; + internal float TrailWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * (Projectile.ai[0] > 0f ? 2f : 4f); + internal Color TrailColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.Chartreuse, Color.SlateGray, Utils.Remap(Projectile.Opacity, 0.5f, 1f, 0f, 0.8f)) * Projectile.Opacity * 0.3f; public override bool PreDraw(ref Color lightColor) { @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Magic return false; PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction), 30); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(HeadWidthFunction, HeadColorFunction, (_) => Projectile.Size * 0.5f), 12); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(HeadWidthFunction, HeadColorFunction, (_,_) => Projectile.Size * 0.5f), 12); return false; } } diff --git a/Projectiles/Magic/PoseidonTyphoon.cs b/Projectiles/Magic/PoseidonTyphoon.cs index e9b2f197a4..fe22cf764e 100644 --- a/Projectiles/Magic/PoseidonTyphoon.cs +++ b/Projectiles/Magic/PoseidonTyphoon.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Magic/PrimordialAncientExplosion.cs b/Projectiles/Magic/PrimordialAncientExplosion.cs index 8b4f5a9c1a..f5783774a8 100644 --- a/Projectiles/Magic/PrimordialAncientExplosion.cs +++ b/Projectiles/Magic/PrimordialAncientExplosion.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -28,6 +27,9 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); + target.MoveNPC(launchVel, 40, true); + if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.95f); if (Projectile.damage < 1) diff --git a/Projectiles/Magic/PrimordialAncientProjectile.cs b/Projectiles/Magic/PrimordialAncientProjectile.cs index 42821ea279..5e3154a432 100644 --- a/Projectiles/Magic/PrimordialAncientProjectile.cs +++ b/Projectiles/Magic/PrimordialAncientProjectile.cs @@ -37,10 +37,10 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.tileCollide = false; Projectile.penetrate = -1; - Projectile.extraUpdates = 6; + Projectile.extraUpdates = 8; Projectile.timeLeft = 430; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 40 * Projectile.extraUpdates; + Projectile.localNPCHitCooldown = -1; } public override void AI() { @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Magic if (buffList[playerIndex] == false) { buffList[playerIndex] = true; - player.AddBuff(ModContent.BuffType(), 540); + player.AddBuff(ModContent.BuffType(), 1080); int Dusts = 8; float radians = MathHelper.TwoPi / Dusts; @@ -82,9 +82,9 @@ namespace CalamityMod.Projectiles.Magic GlowSparkParticle spark = new GlowSparkParticle(Projectile.Center, dustVelocity * 0.7f, false, 12, 0.009f, Color.Purple, new Vector2(3.5f, 1.3f), true); GeneralParticleHandler.SpawnParticle(spark); - Dust dust = Dust.NewDustPerfect(player.Center, 86, dustVelocity.RotatedBy(MathHelper.ToRadians(22.5f)), 0, default, 0.9f); + Dust dust = Dust.NewDustPerfect(player.Center, DustID.GemAmethyst, dustVelocity.RotatedBy(MathHelper.ToRadians(22.5f)), 0, default, 0.9f); dust.noGravity = true; - Dust dust2 = Dust.NewDustPerfect(player.Center, 86, dustVelocity.RotatedBy(MathHelper.ToRadians(22.5f)) * 0.4f, 0, default, 1.2f); + Dust dust2 = Dust.NewDustPerfect(player.Center, DustID.GemAmethyst, dustVelocity.RotatedBy(MathHelper.ToRadians(22.5f)) * 0.4f, 0, default, 1.2f); dust2.noGravity = true; } @@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 2; i++) { Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 60f * Projectile.scale * Utils.GetLerpValue(350, 250, time, true); - Dust dust = Dust.NewDustPerfect(dustPos, 272, (i * MathHelper.Pi + Projectile.rotation * Math.Sign(Projectile.velocity.Length())).ToRotationVector2()); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.WitherLightning, (i * MathHelper.Pi + Projectile.rotation * Math.Sign(Projectile.velocity.Length())).ToRotationVector2()); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.4f, 0.6f); } @@ -176,7 +176,7 @@ namespace CalamityMod.Projectiles.Magic float size = Projectile.width * 0.03f * Projectile.scale; Vector2 dustPos = Projectile.Center + Main.rand.NextVector2Circular(size, size); Vector2 trailVel = (new Vector2(CenterX, CenterY) - Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.5f; - Dust dust = Dust.NewDustPerfect(dustPos, 272, trailVel); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.WitherLightning, trailVel); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.4f, 0.6f); } @@ -190,7 +190,6 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(SandCloud); } - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + new Vector2(25, 25).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.3f) * Projectile.scale, Main.rand.NextBool(5) ? 86 : 287, -Projectile.velocity * Main.rand.NextFloat(0.1f, 1.3f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.4f, 0.7f); @@ -203,48 +202,81 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - modifiers.SourceDamage *= 0.05f; + float minMult = 0.25f; + int hitsToMinMult = 6; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + if (Projectile.numHits == 0) + { + damageMult += 0.5f; + for (int i = 0; i < 3; i++) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact with { Volume = 0.9f, Pitch = -0.4f + i * 0.25f, MaxInstances = 9 }, Projectile.Center); + for (int i = 0; i < 6; i++) + { + float range = Main.rand.NextFloat(-0.3f, 0.3f); + float power = 1 - Math.Abs(range); + Vector2 vel = Projectile.Center.DirectionTo(target.Center).RotatedBy(range) * Main.rand.NextFloat(35, 40) * power; + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center, vel, Color.Peru, Color.PeachPuff, Main.rand.NextFloat(1.7f, 2.3f), 120f, Main.rand.NextFloat(0.03f, -0.03f)); + GeneralParticleHandler.SpawnParticle(SandCloud); + for (int b = 0; b < 5; b++) + { + Color clr = Color.Lerp((Main.rand.NextBool() ? Color.Peru : Color.PeachPuff), Color.Black, Main.rand.NextFloat(0.25f, 0.45f)); + Particle sand = new CustomSpark(Projectile.Center, vel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.4f, 0.9f) * power, "CalamityMod/Particles/SmallSmoke", false, Main.rand.Next(25, 35 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 7, clr, new Vector2(1, Main.rand.NextFloat(0.2f, 2f)), false, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.8f, 0.8f), affectedByLight: true); + GeneralParticleHandler.SpawnParticle(sand); + } + } + } - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.95f); - if (Projectile.damage < 1) - Projectile.damage = 1; + modifiers.SourceDamage *= damageMult * 0.03f; } public override void OnKill(int timeLeft) { Lighting.AddLight(Projectile.Center, Color.Purple.ToVector3() * 2); if (Projectile.ai[1] == 1) { - Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Purple, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0f, 0.82f, 11); + Player Owner = Main.player[Projectile.owner]; + Owner.SetScreenshake(8f); + + Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Purple, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.2f * 2f, 0.6f * 2.5f, 17); GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0f, 0.74f, 11); + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.1f * 2f, 0.5f * 2.5f, 17); GeneralParticleHandler.SpawnParticle(orb2); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 1.5f, Projectile.owner); SoundStyle explo = new("CalamityMod/Sounds/Item/MineralMortarExplode"); SoundEngine.PlaySound(explo with { Volume = 0.9f }, Projectile.Center); + SoundStyle explo2 = new("CalamityMod/Sounds/Item/EarthMeteor"); + SoundEngine.PlaySound(explo2 with { Volume = 0.9f, Pitch = -0.3f }, Projectile.Center); Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lerp(Color.Purple, Color.White, 0.5f) * 0.55f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 2.56f * 2.3f, 18); GeneralParticleHandler.SpawnParticle(bolt2); - Particle bolt3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Peru * 0.55f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.3f, 30); + Particle bolt3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Peru * 0.55f, "CalamityMod/Particles/SmokeExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.4f, 23); GeneralParticleHandler.SpawnParticle(bolt3); - Particle bolt4 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.PeachPuff * 0.55f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.3f * 1.35f, 30); + Particle bolt4 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.PeachPuff * 0.55f, "CalamityMod/Particles/SmokeExplosion", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.4f * 1.35f, 18); GeneralParticleHandler.SpawnParticle(bolt4); for (int i = 0; i < 140; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 86 : 287, new Vector2(21, 21).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.3f)); - dust.noGravity = false; - dust.scale = Main.rand.NextFloat(0.8f, 1.3f); - if (dust.type == 86) + if (Main.rand.NextBool(5)) { - dust.noGravity = true; - dust.fadeIn = 0.5f; - dust.velocity *= 2; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 86 : 287, new Vector2(21, 21).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.3f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.8f, 1.3f); + if (dust.type == 86) + { + dust.noGravity = true; + dust.fadeIn = 0.5f; + dust.velocity *= 2; + } + dust.alpha = 100; + } + else + { + Color clr = Color.Lerp((Main.rand.NextBool() ? Color.Peru : Color.PeachPuff), Color.Black, Main.rand.NextFloat(0.25f, 0.45f)); + Particle sand = new CustomSpark(Projectile.Center, (Vector2.One * Main.rand.NextFloat(9, 33)).RotatedByRandom(MathHelper.TwoPi), "CalamityMod/Particles/SmallSmoke", true, Main.rand.Next(25, 55 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 23, clr, new Vector2(1, Main.rand.NextFloat(0.2f, 2f)), false, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.8f, 0.8f), affectedByLight: true); + GeneralParticleHandler.SpawnParticle(sand); } - dust.alpha = 100; } for (int i = 0; i < 30; i++) { diff --git a/Projectiles/Magic/PrimordialEarthExplosion.cs b/Projectiles/Magic/PrimordialEarthExplosion.cs index 7a2fc6d42f..d35a7323a5 100644 --- a/Projectiles/Magic/PrimordialEarthExplosion.cs +++ b/Projectiles/Magic/PrimordialEarthExplosion.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -28,6 +27,9 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); + target.MoveNPC(launchVel, 20, true); + if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.9f); if (Projectile.damage < 1) diff --git a/Projectiles/Magic/PrimordialEarthProjectile.cs b/Projectiles/Magic/PrimordialEarthProjectile.cs index e7d99309b2..cfaa1e0416 100644 --- a/Projectiles/Magic/PrimordialEarthProjectile.cs +++ b/Projectiles/Magic/PrimordialEarthProjectile.cs @@ -1,9 +1,6 @@ using System; using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.DataStructures; using CalamityMod.Particles; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Terraria.Audio; using Terraria; @@ -35,7 +32,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.extraUpdates = 6; + Projectile.extraUpdates = 9; Projectile.timeLeft = 132; // NOTE: Do not change this. Specific timing is needed for the weapon to function properly. Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; @@ -71,7 +68,7 @@ namespace CalamityMod.Projectiles.Magic if (buffList[playerIndex] == false) { buffList[playerIndex] = true; - player.AddBuff(ModContent.BuffType(), 360); + player.AddBuff(ModContent.BuffType(), 840); int Dusts = 12; float radians = MathHelper.TwoPi / Dusts; @@ -79,10 +76,10 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < Dusts; i++) { Vector2 dustVelocity = spinningPoint.RotatedBy(radians * i) * 12.5f; - Dust dust = Dust.NewDustPerfect(player.Center, 262, dustVelocity, 0, default, 0.9f); + Dust dust = Dust.NewDustPerfect(player.Center, DustID.AmberBolt, dustVelocity, 0, default, 0.9f); dust.noGravity = true; - Dust dust2 = Dust.NewDustPerfect(player.Center, 262, dustVelocity * 0.6f, 0, default, 1.2f); + Dust dust2 = Dust.NewDustPerfect(player.Center, DustID.AmberBolt, dustVelocity * 0.6f, 0, default, 1.2f); dust2.noGravity = true; } SoundStyle buff = new("CalamityMod/Sounds/Custom/Ravager/RavagerPillarSummon"); @@ -135,7 +132,6 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(SandCloud); } - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + new Vector2(25, 25).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.3f) * Projectile.scale, Main.rand.NextBool(8) ? 262 : 287, -Projectile.velocity * Main.rand.NextFloat(0.1f, 1.3f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.4f, 0.7f); @@ -148,36 +144,71 @@ namespace CalamityMod.Projectiles.Magic } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.95f); - if (Projectile.damage < 1) - Projectile.damage = 1; + float minMult = 0.25f; + int hitsToMinMult = 6; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + if (Projectile.numHits == 0) + { + damageMult += 0.5f; + for (int i = 0; i < 3; i++) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact with { Volume = 0.9f, Pitch = -0.4f + i * 0.25f, MaxInstances = 6 }, Projectile.Center); + for (int i = 0; i < 9; i++) + { + float range = Main.rand.NextFloat(-0.3f, 0.3f); + float power = 1 - Math.Abs(range); + Vector2 vel = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(range) * Main.rand.NextFloat(35, 40) * power; + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center, vel, Color.Peru, Color.PeachPuff, Main.rand.NextFloat(1.7f, 2.3f), 120f, Main.rand.NextFloat(0.03f, -0.03f)); + GeneralParticleHandler.SpawnParticle(SandCloud); + for (int b = 0; b < 6; b++) + { + Color clr = Color.Lerp((Main.rand.NextBool() ? Color.Peru : Color.PeachPuff), Color.Black, Main.rand.NextFloat(0.25f, 0.45f)); + Particle sand = new CustomSpark(Projectile.Center, vel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.4f, 0.9f) * power, "CalamityMod/Particles/SmallSmoke", false, Main.rand.Next(25, 35 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 7, clr, new Vector2(1, Main.rand.NextFloat(0.2f, 2f)), false, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.8f, 0.8f), affectedByLight: true); + GeneralParticleHandler.SpawnParticle(sand); + } + } + } + modifiers.SourceDamage *= damageMult; } public override void OnKill(int timeLeft) { if (Projectile.ai[1] == 1) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 1.5f, Projectile.owner); + Player Owner = Main.player[Projectile.owner]; + Owner.SetScreenshake(5f); + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 2.5f), 0, Projectile.owner); SoundStyle explo = new("CalamityMod/Sounds/Item/MagicRockImpact"); SoundEngine.PlaySound(explo with { Volume = 0.75f }, Projectile.Center); - //Particle bolt = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Gold * 0.3f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 1.86f, 15); - //GeneralParticleHandler.SpawnParticle(bolt); Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Gold * 0.55f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 2.56f, 15); GeneralParticleHandler.SpawnParticle(bolt2); + + Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Gold, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.1f, 0.4f * 1.5f, 17); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.05f, 0.3f * 1.5f, 17); + GeneralParticleHandler.SpawnParticle(orb2); } for (int i = 0; i < 65; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 262 : 287, new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.3f)); - dust.noGravity = false; - dust.scale = Main.rand.NextFloat(0.8f, 1.3f); - if (dust.type == 262) + if (Main.rand.NextBool(4)) { - dust.noGravity = true; - dust.fadeIn = 0.5f; - dust.velocity *= 2; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 262 : 287, new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.3f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.8f, 1.3f); + if (dust.type == 262) + { + dust.noGravity = true; + dust.fadeIn = 0.5f; + dust.velocity *= 2; + } + dust.alpha = 100; + } + else + { + Color clr = Color.Lerp((Main.rand.NextBool() ? Color.Peru : Color.PeachPuff), Color.Black, Main.rand.NextFloat(0.25f, 0.45f)); + Particle sand = new CustomSpark(Projectile.Center, (Vector2.One * Main.rand.NextFloat(6, 15)).RotatedByRandom(MathHelper.TwoPi), "CalamityMod/Particles/SmallSmoke", true, Main.rand.Next(20, 45 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 8, clr, new Vector2(1, Main.rand.NextFloat(0.2f, 2f)), false, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.8f, 0.8f), affectedByLight: true); + GeneralParticleHandler.SpawnParticle(sand); } - dust.alpha = 100; } for (int i = 0; i < 9; i++) { diff --git a/Projectiles/Magic/PurgeGuzzlerHoldout.cs b/Projectiles/Magic/PurgeGuzzlerHoldout.cs index 45f863f630..5041446fb2 100644 --- a/Projectiles/Magic/PurgeGuzzlerHoldout.cs +++ b/Projectiles/Magic/PurgeGuzzlerHoldout.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -36,13 +37,13 @@ namespace CalamityMod.Projectiles.Magic public Color color2 = Color.Orange; public override void KillHoldoutLogic() { - if (!isOnCooldown && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)) + if (!isOnCooldown && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)) Projectile.Kill(); } public override void HoldoutAI() { - if (!isOnCooldown && (Owner.CantUseHoldout() || HeldItem.type != Owner.ActiveItem().type)) + if (!isOnCooldown && (Owner.CantUseHoldout() || HeldItem.type != Owner.HeldItem.type)) cooldownTimer = (int)(Utils.Remap(revFrames, 0, 350, 40, 120, true)); if (isOnCooldown) { @@ -56,10 +57,12 @@ namespace CalamityMod.Projectiles.Magic SoundStyle shot = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianShieldDeactivate"); SoundEngine.PlaySound(shot with { Pitch = Utils.Remap(revFrames, 0, 150, 0.2f, 0.8f, true), Volume = 0.2f, MaxInstances = -1 }, Projectile.Center); - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - float spread = 0.045f * Utils.GetLerpValue(0, 300, revFrames, true); - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(spread), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, revSpeed * (shotsFired % 2 == 0 ? -1f : 1f) * Utils.Remap(revFrames, 120, 150, 0.1f, 0.45f, true), Projectile.whoAmI); + if (Main.myPlayer == Projectile.owner) + { + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); + float spread = 0.045f * Utils.GetLerpValue(0, 300, revFrames, true); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(spread), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, revSpeed * (shotsFired % 2 == 0 ? -1f : 1f) * Utils.Remap(revFrames, 120, 150, 0.1f, 0.45f, true), Projectile.whoAmI); + } for (int i = 0; i <= 2; i++) { @@ -79,7 +82,7 @@ namespace CalamityMod.Projectiles.Magic if (revFrames >= 150 && !isOnCooldown) { revSpeed = 4; - Owner.Calamity().GeneralScreenShakePower = 3.5f; + Owner.SetScreenshake(3.5f); OffsetLengthFromArm -= 35f; cooldownTimer = 60; SoundStyle bigShot = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianRay"); @@ -87,15 +90,18 @@ namespace CalamityMod.Projectiles.Magic SoundStyle bigShot2 = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyRay"); SoundEngine.PlaySound(bigShot2 with { Pitch = 0.4f, Volume = 0.8f }, Projectile.Center); - int bigBeamDamage = (int)(Projectile.damage * 6.5f); + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), bigBeamDamage, Projectile.knockBack * 3, Projectile.owner, 1, Projectile.whoAmI, 1); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), bigBeamDamage, Projectile.knockBack * 3, Projectile.owner, -1, Projectile.whoAmI, 1); + if (Main.myPlayer == Projectile.owner) + { + int bigBeamDamage = (int)(Projectile.damage * 6.5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), bigBeamDamage, Projectile.knockBack * 3, Projectile.owner, 1, Projectile.whoAmI, 1); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), bigBeamDamage, Projectile.knockBack * 3, Projectile.owner, -1, Projectile.whoAmI, 1); + } for (int i = 0; i <= 25; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition, 278, shootVelocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(5f, 30f), 0, default, Main.rand.NextFloat(0.6f, 1.4f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB, shootVelocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(5f, 30f), 0, default, Main.rand.NextFloat(0.6f, 1.4f)); dust.noGravity = true; dust.color = Color.Lerp(Color.Orchid, Color.White, Main.rand.NextFloat(0, 0.7f)); } diff --git a/Projectiles/Magic/RainbowComet.cs b/Projectiles/Magic/RainbowComet.cs index 3bd0b240f3..3a833d9801 100644 --- a/Projectiles/Magic/RainbowComet.cs +++ b/Projectiles/Magic/RainbowComet.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < 80; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 263); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBolt); dust.color = CalamityUtils.MulticolorLerp((Main.rand.NextFloat(0.4f) + Main.GlobalTimeWrappedHourly * 0.4f) % 0.999f, RainbowPartyCannon.ColorSet); dust.scale = Main.rand.NextFloat(0.6f, 0.9f); dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 16f); diff --git a/Projectiles/Magic/RainbowPartyCannonProjectile.cs b/Projectiles/Magic/RainbowPartyCannonProjectile.cs index a5a9de1063..e891606c3b 100644 --- a/Projectiles/Magic/RainbowPartyCannonProjectile.cs +++ b/Projectiles/Magic/RainbowPartyCannonProjectile.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); UpdatePlayerVisuals(Owner.Center); diff --git a/Projectiles/Magic/RainbowRocket.cs b/Projectiles/Magic/RainbowRocket.cs index 8d93e5a912..14c9e803b6 100644 --- a/Projectiles/Magic/RainbowRocket.cs +++ b/Projectiles/Magic/RainbowRocket.cs @@ -117,13 +117,13 @@ namespace CalamityMod.Projectiles.Magic return Color.White; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { Color baseColor = Main.hslToRgb((Projectile.identity * 0.33f + completionRatio + Main.GlobalTimeWrappedHourly * 2f) % 1f, 1f, 0.54f); return Color.Lerp(GetRocketColor(), baseColor, MathHelper.Clamp(completionRatio * 0.8f, 0f, 1f)) * Projectile.Opacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float width; float maxWidthOutwardness = 8f; @@ -137,7 +137,7 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { Projectile.oldPos[0] = Projectile.position + Projectile.velocity.SafeNormalize(Vector2.Zero) * 50f; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + Projectile.velocity), 80); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + Projectile.velocity), 80); Texture2D rocketTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; Main.EntitySpriteDraw(rocketTexture, @@ -240,7 +240,7 @@ namespace CalamityMod.Projectiles.Magic velocity = velocity.RotatedBy(MathHelper.PiOver2); // Flip the petal velocity. It's tilted to the side normally. velocity = velocity.RotatedBy(explosionOffsetAngle); // Account for the explosion offset angle that was determined at the start. - Dust dust = Dust.NewDustPerfect(center, 261); + Dust dust = Dust.NewDustPerfect(center, DustID.AncientLight); dust.velocity = velocity * petalBurstSpeed; dust.noGravity = true; dust.color = balloonColor; @@ -267,7 +267,7 @@ namespace CalamityMod.Projectiles.Magic BezierCurve bezierCurve = new BezierCurve(bezierControlPoints); for (int i = 0; i < evaluationPoints; i++) { - Dust dust = Dust.NewDustPerfect(center, 261); + Dust dust = Dust.NewDustPerfect(center, DustID.AncientLight); dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints).RotatedBy(offsetAngle) + Vector2.UnitY * petalBurstSpeed * 2f; dust.velocity = Vector2.Zero; dust.noGravity = true; @@ -320,7 +320,7 @@ namespace CalamityMod.Projectiles.Magic velocity = velocity.RotatedBy(offsetAngle); // Account for the explosion offset angle that was determined at the start. - Dust dust = Dust.NewDustPerfect(center, 261); + Dust dust = Dust.NewDustPerfect(center, DustID.AncientLight); dust.velocity = velocity * appleBurstSpeed; dust.noGravity = true; dust.color = Color.Orange; @@ -346,7 +346,7 @@ namespace CalamityMod.Projectiles.Magic BezierCurve bezierCurve = new BezierCurve(bezierControlPoints); for (int i = 0; i < evaluationPoints; i++) { - Dust dust = Dust.NewDustPerfect(center, 261); + Dust dust = Dust.NewDustPerfect(center, DustID.AncientLight); dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints).RotatedBy(offsetAngle); dust.velocity = Vector2.Zero; dust.noGravity = true; @@ -383,7 +383,7 @@ namespace CalamityMod.Projectiles.Magic velocity = velocity.RotatedBy(offsetAngle); velocity *= 0.25f; // Normalization removes the spaces that make the vector petal-like and not circular, so multiplication must be utilized instead. - Dust dust = Dust.NewDustPerfect(center, 262); + Dust dust = Dust.NewDustPerfect(center, DustID.AmberBolt); dust.velocity = velocity * butterflyBurstSpeed; dust.noGravity = true; dust.color = Color.Pink; @@ -410,7 +410,7 @@ namespace CalamityMod.Projectiles.Magic BezierCurve bezierCurve = new BezierCurve(bezierControlPoints); for (int i = 0; i < evaluationPoints; i++) { - Dust dust = Dust.NewDustPerfect(center, 263); + Dust dust = Dust.NewDustPerfect(center, DustID.PortalBolt); dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints).RotatedBy(offsetAngle); dust.velocity = Vector2.Zero; dust.noGravity = true; @@ -471,7 +471,7 @@ namespace CalamityMod.Projectiles.Magic velocity *= diamondBurstSpeed; velocity.X *= 0.667f; - Dust dust = Dust.NewDustPerfect(center, 263); + Dust dust = Dust.NewDustPerfect(center, DustID.PortalBolt); dust.position = center; dust.velocity = velocity; dust.noGravity = true; @@ -508,7 +508,7 @@ namespace CalamityMod.Projectiles.Magic spawnOffset -= Vector2.UnitY.RotatedBy(offsetAngle) * 90f; - Dust dust = Dust.NewDustPerfect(center + spawnOffset, 263); + Dust dust = Dust.NewDustPerfect(center + spawnOffset, DustID.PortalBolt); dust.velocity = Vector2.Zero; dust.noGravity = true; dust.scale = 2.7f; @@ -545,7 +545,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 currentPosition = controlPoints[currentIndex]; Vector2 nextPosition = controlPoints[(currentIndex + 1) % controlPoints.Length]; - Dust dust = Dust.NewDustPerfect(center, 263); + Dust dust = Dust.NewDustPerfect(center, DustID.PortalBolt); dust.position = center + Vector2.Lerp(currentPosition, nextPosition, i / (float)evaluationPoints * controlPoints.Length % 0.999f).RotatedBy(offsetAngle) * 2f; dust.position += Vector2.UnitY.RotatedBy(offsetAngle) * 138f; dust.velocity = Vector2.Zero; @@ -566,7 +566,7 @@ namespace CalamityMod.Projectiles.Magic spawnOffset += Vector2.UnitY.RotatedBy(offsetAngle) * 30f; - Dust dust = Dust.NewDustPerfect(center + spawnOffset, 263); + Dust dust = Dust.NewDustPerfect(center + spawnOffset, DustID.PortalBolt); dust.velocity = Vector2.Zero; dust.noGravity = true; dust.scale = 4f; @@ -598,7 +598,7 @@ namespace CalamityMod.Projectiles.Magic int pointsOnStarSegment = 35; for (int j = 0; j < pointsOnStarSegment; j++) { - Dust dust = Dust.NewDustPerfect(center, 263); + Dust dust = Dust.NewDustPerfect(center, DustID.PortalBolt); dust.scale = 1.8f; dust.velocity = Vector2.Lerp(start, end, j / (float)pointsOnStarSegment) * petalBurstSpeed; dust.velocity.X *= 0.7f; @@ -641,7 +641,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < evaluationPoints; i++) { - Dust dust = Dust.NewDustPerfect(center, 263); + Dust dust = Dust.NewDustPerfect(center, DustID.PortalBolt); dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints) * new Vector2(3f, 1.7f); dust.velocity = Vector2.Zero; dust.color = i >= evaluationPoints / 2 ? Color.Cyan : Color.SkyBlue; @@ -684,7 +684,7 @@ namespace CalamityMod.Projectiles.Magic velocity *= starBurstSpeed; velocity.X *= 0.75f; - Dust dust = Dust.NewDustPerfect(center, 263); + Dust dust = Dust.NewDustPerfect(center, DustID.PortalBolt); dust.position = center; dust.velocity = velocity; dust.noGravity = true; diff --git a/Projectiles/Magic/RancorArm.cs b/Projectiles/Magic/RancorArm.cs index e2ad741f5e..94aa1068c6 100644 --- a/Projectiles/Magic/RancorArm.cs +++ b/Projectiles/Magic/RancorArm.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.World; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; diff --git a/Projectiles/Magic/RancorFog.cs b/Projectiles/Magic/RancorFog.cs index af5e72d30e..bc4ee599e4 100644 --- a/Projectiles/Magic/RancorFog.cs +++ b/Projectiles/Magic/RancorFog.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic diff --git a/Projectiles/Magic/RancorHoldout.cs b/Projectiles/Magic/RancorHoldout.cs index e845a63e6c..0a72c89b15 100644 --- a/Projectiles/Magic/RancorHoldout.cs +++ b/Projectiles/Magic/RancorHoldout.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.Center = Owner.Center + Vector2.UnitX * Owner.direction * 8f; // CheckMana returns true if the mana cost can be paid. If mana isn't consumed this frame, the CheckMana short-circuits out of being evaluated. - bool allowContinuedUse = Time % ManaConsumeRate != ManaConsumeRate - 1f || Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + bool allowContinuedUse = Time % ManaConsumeRate != ManaConsumeRate - 1f || Owner.CheckMana(Owner.HeldItem, -1, true, false); bool bookStillInUse = Owner.channel && allowContinuedUse && !Owner.noItems && !Owner.CCed; // If the owner is no longer able to hold the book, kill it. diff --git a/Projectiles/Magic/RancorLargeCinder.cs b/Projectiles/Magic/RancorLargeCinder.cs index a27ef75db1..ac874b32c1 100644 --- a/Projectiles/Magic/RancorLargeCinder.cs +++ b/Projectiles/Magic/RancorLargeCinder.cs @@ -21,6 +21,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.friendly = true; Projectile.timeLeft = 300; Projectile.ignoreWater = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/RancorLaserbeam.cs b/Projectiles/Magic/RancorLaserbeam.cs index b857ad36cf..05e4966f84 100644 --- a/Projectiles/Magic/RancorLaserbeam.cs +++ b/Projectiles/Magic/RancorLaserbeam.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Metaballs; using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -13,6 +13,7 @@ using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class RancorLaserbeam : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -146,9 +147,9 @@ namespace CalamityMod.Projectiles.Magic RancorLavaMetaball.SpawnParticle(endOfLaser + Main.rand.NextVector2Circular(10f, 10f) + Projectile.velocity * 40f, 135f); } - private float PrimitiveWidthFunction(float completionRatio) => Projectile.scale * 20f; + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 20f; - private Color PrimitiveColorFunction(float completionRatio) + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { Color vibrantColor = Color.Lerp(Color.Blue, Color.Red, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.67f - completionRatio / LaserLength * 29f) * 0.5f + 0.5f); float opacity = Projectile.Opacity * Utils.GetLerpValue(0.97f, 0.9f, completionRatio, true) * diff --git a/Projectiles/Magic/RancorMagicCircle.cs b/Projectiles/Magic/RancorMagicCircle.cs index 0552119b08..02d318930e 100644 --- a/Projectiles/Magic/RancorMagicCircle.cs +++ b/Projectiles/Magic/RancorMagicCircle.cs @@ -132,7 +132,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 dustVelocity = (-dustSpawnOffset.SafeNormalize(Vector2.UnitY)).RotatedBy(MathHelper.PiOver2 * Main.rand.NextFloatDirection()); dustVelocity *= Main.rand.NextFloat(2f, 6f); - Dust magic = Dust.NewDustPerfect(Projectile.Center + dustSpawnOffset, 264); + Dust magic = Dust.NewDustPerfect(Projectile.Center + dustSpawnOffset, DustID.PortalBoltTrail); magic.color = Color.Lerp(Color.Red, Color.Blue, Main.rand.NextFloat()); magic.velocity = dustVelocity; magic.scale *= Main.rand.NextFloat(1f, 1.4f); @@ -168,7 +168,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 dustSpawnOffsetDirection = Main.rand.NextVector2CircularEdge(0.5f, 1f).RotatedBy(Projectile.velocity.ToRotation()); Vector2 dustSpawnOffset = dustSpawnOffsetDirection * dustSpawnOffsetFactor; - Dust magic = Dust.NewDustPerfect(Projectile.Center + dustSpawnOffset, 264); + Dust magic = Dust.NewDustPerfect(Projectile.Center + dustSpawnOffset, DustID.PortalBoltTrail); magic.color = Color.Lerp(Color.Red, Color.Blue, Main.rand.NextFloat()); magic.velocity = dustVelocity; magic.scale *= Main.rand.NextFloat(1f, 1.05f + ChargeupCompletion * 0.55f); diff --git a/Projectiles/Magic/RedirectingFire.cs b/Projectiles/Magic/RedirectingFire.cs index 65892c59e0..76b877126d 100644 --- a/Projectiles/Magic/RedirectingFire.cs +++ b/Projectiles/Magic/RedirectingFire.cs @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 15; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(30f, 30f) * BurstIntensity, 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(30f, 30f) * BurstIntensity, DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); ectoplasm.color = Color.Lerp(Color.Orange, Color.Yellow, Main.rand.NextFloat(0.67f)); ectoplasm.scale = MathHelper.Lerp(1f, 1.6f, BurstIntensity); diff --git a/Projectiles/Magic/RedirectingGildedSoul.cs b/Projectiles/Magic/RedirectingGildedSoul.cs index f49200a9d7..a70ce403f9 100644 --- a/Projectiles/Magic/RedirectingGildedSoul.cs +++ b/Projectiles/Magic/RedirectingGildedSoul.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 45; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(80f, 80f) * (float)Math.Pow(BurstIntensity, 2D), 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(80f, 80f) * (float)Math.Pow(BurstIntensity, 2D), DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = MathHelper.Lerp(1f, 1.6f, BurstIntensity); diff --git a/Projectiles/Magic/RedirectingLostSoul.cs b/Projectiles/Magic/RedirectingLostSoul.cs index c4bae2a019..f197995890 100644 --- a/Projectiles/Magic/RedirectingLostSoul.cs +++ b/Projectiles/Magic/RedirectingLostSoul.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 45; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50f, 50f) * BurstIntensity, 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50f, 50f) * BurstIntensity, DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = MathHelper.Lerp(1f, 1.6f, BurstIntensity); diff --git a/Projectiles/Magic/RedirectingVengefulSoul.cs b/Projectiles/Magic/RedirectingVengefulSoul.cs index 550b223e20..66ed0ac74b 100644 --- a/Projectiles/Magic/RedirectingVengefulSoul.cs +++ b/Projectiles/Magic/RedirectingVengefulSoul.cs @@ -109,14 +109,14 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 45; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(100f, 100f) * (float)Math.Pow(BurstIntensity, 2D), 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(100f, 100f) * (float)Math.Pow(BurstIntensity, 2D), DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = MathHelper.Lerp(1.2f, 1.9f, BurstIntensity); ectoplasm.noGravity = true; ectoplasm.noLight = true; - ectoplasm = Dust.NewDustPerfect(Projectile.Center, 264); + ectoplasm = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail); ectoplasm.velocity = (MathHelper.TwoPi * i / 45f).ToRotationVector2() * 6f; ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = MathHelper.Lerp(1.2f, 1.9f, BurstIntensity); diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 5713663db6..0183bcdc66 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -1,21 +1,36 @@ using System; +using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SHPB : ModProjectile, ILocalizedModType + public class SHPB : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { + public GeneralDrawLayer LayerToRenderTo => GeneralDrawLayer.BeforeProjectiles; + + public ref float ExplodeTimer => ref Projectile.ai[2]; + + public bool CanExplodeFromProximity + { + get => Projectile.ai[1] == 1f; + set => Projectile.ai[1] = value.ToInt(); + } + public new string LocalizationCategory => "Projectiles.Magic"; - public int explosionTimer = 120; public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + ProjectileID.Sets.TrailCacheLength[Type] = 12; + ProjectileID.Sets.TrailingMode[Type] = 2; } public override void SetDefaults() @@ -23,8 +38,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 24; Projectile.height = 24; Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.scale = 0.4f; + Projectile.alpha = 0; + Projectile.scale = 0f; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Magic; } @@ -78,7 +93,7 @@ namespace CalamityMod.Projectiles.Magic case 4: return new(79, 255, 124); case 5: - return new(255, 128, 20); + return new(255, 96, 20); default: return new(0, 0, 0); @@ -92,7 +107,6 @@ namespace CalamityMod.Projectiles.Magic float lights = (float)Main.rand.Next(90, 111) * 0.01f; lights *= Main.essScale; Lighting.AddLight(Projectile.Center, 1f * lights, 0.2f * lights, 0.75f * lights); - Projectile.alpha -= 2; // Animation Projectile.frameCounter++; @@ -104,22 +118,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.frame = 0; } - // Size pulsing - bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; - - if (Projectile.localAI[0] == 0f) - { - Projectile.scale += 0.05f; - if (Projectile.scale > 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) - Projectile.localAI[0] = 1f; - } - else - { - Projectile.scale -= 0.05f; - if (Projectile.scale < 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) - Projectile.localAI[0] = 0f; - } - // Sight has weak homing if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Sight) { @@ -139,18 +137,15 @@ namespace CalamityMod.Projectiles.Magic } if (index != -1) - { - float speed = Projectile.velocity.Length(); - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Main.npc[index].Center).ToRotation(), 0.1f).ToRotationVector2() * speed; - } - else // Slow down over time if not homing - Projectile.velocity *= 0.9875f; + Projectile.velocity = (Projectile.velocity * 17f + Utils.DirectionTo(Projectile.Center, Main.npc[index].Center) * 20f) / 18f; + else + Projectile.velocity *= 0.9875f; // Slow down over time if not homing } - else if (!(GetSoulEffects((int)Projectile.ai[0]) == SoulType.Flight))// Always slow down if not Flight + else if (GetSoulEffects((int)Projectile.ai[0]) != SoulType.Flight) // Always slow down if not Flight Projectile.velocity *= 0.9875f; + // As soon as a plasma orb is in range of an enemy, it will explode in 1 second. float explodeRange = 250f; - bool canExplode = false; foreach (NPC n in Main.ActiveNPCs) { if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) @@ -161,15 +156,99 @@ namespace CalamityMod.Projectiles.Magic if (npcDist < explodeRange) { explodeRange = npcDist; - canExplode = true; + CanExplodeFromProximity = true; } } } - if (canExplode) + + if (CanExplodeFromProximity) { - explosionTimer--; - if (explosionTimer <= 0) + ExplodeTimer++; + if (ExplodeTimer >= 60f) Projectile.Kill(); + + // Quickly scale down before exploding. + bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; + float minScale = 0.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + float maxScale = 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + Projectile.scale = MathHelper.Clamp(Projectile.scale - 0.075f, minScale, maxScale); + } + else + { + // Size control. + // Scale up to the minimum scale at the start. + if (Projectile.timeLeft >= 285) + { + bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; + float minScale = 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + Projectile.scale += 0.125f; + if (Projectile.scale > minScale) + Projectile.scale = minScale; + } + // Pulse occasionally afterwards. + else if (Projectile.timeLeft <= 285 && Projectile.timeLeft >= 45) + { + bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; + float minScale = 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + float maxScale = 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + + Projectile.localAI[0]++; + Projectile.scale = MathHelper.Lerp(minScale, maxScale, CalamityUtils.SineBumpEasing(Projectile.localAI[0] / 75f, 1)); + } + // Scale down once the projectile is about to die. + else + { + // Save the last scale value of the projectile so that we can seamlessly shrink the projectile. + if (Projectile.localAI[1] == 0f) + Projectile.localAI[1] = Projectile.scale; + + Projectile.scale = Utils.Remap(Projectile.timeLeft, 45, 0, Projectile.localAI[1], 0.35f, true); + } + } + + Projectile.ExpandHitboxBy((int)(24 * Projectile.scale)); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // Miscellaneous visual additions. + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + if (Main.rand.NextBool(3) && deathInterpolant <= 0f) + { + for (int i = 0; i < 4; i++) + { + Vector2 dustSpawnPosition = Projectile.Center + Main.rand.NextVector2Circular(Projectile.width * 0.75f, Projectile.height * 0.75f); + Vector2 dustVelocity = Projectile.velocity * -1.2f; + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y); + dust.scale = Main.rand.NextFloat(0.8f, 1.2f); + dust.noGravity = true; + dust.noLight = false; + dust.color = FindColorForSoul((int)Projectile.ai[0]); + dust.velocity *= 0.9f; + } + } + + // Start emitting particles on death. + if (deathInterpolant > 0f) + { + float speedMultiplier = MathHelper.Lerp(1f, 3f, deathInterpolant); + float scaleMultiplier = MathHelper.Lerp(1f, 1.65f, deathInterpolant); + for (int i = 0; i < 3; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 2.5f * speedMultiplier; + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y); + dust.scale = Main.rand.NextFloat(1.4f, 1.8f) * scaleMultiplier; + dust.color = FindColorForSoul((int)Projectile.ai[0]); + dust.noGravity = true; + dust.noLight = false; + } + + Vector2 plasmaVelocity = Main.rand.NextVector2Circular(1f, 1f) * 1.35f * speedMultiplier; + Color plasmaColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, deathInterpolant); + + float plasmaScale = Main.rand.NextFloat(0.2f, 0.4f) * scaleMultiplier; + int plasmaLifetime = Main.rand.Next(30, 45); + + SquishyLightParticle plasma = new(Projectile.Center, plasmaVelocity, plasmaScale, plasmaColor, plasmaLifetime); + GeneralParticleHandler.SpawnParticle(plasma); } } @@ -190,7 +269,7 @@ namespace CalamityMod.Projectiles.Magic if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Might && target.CanBeMoved(false)) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength - new Vector2(0, 3); + Vector2 launchVel = Utils.DirectionTo(owner.Center, owner.Calamity().mouseWorld) - Vector2.UnitY * 5f; target.MoveNPC(launchVel, SHPC.MightKnockbackStrength, false); } } @@ -206,29 +285,103 @@ namespace CalamityMod.Projectiles.Magic { SoundEngine.PlaySound(SoundID.Item105, Projectile.Center); float screenshake = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light ? 5f : 3.5f; - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenshake) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenshake; + Main.LocalPlayer.SetScreenshake(screenshake); if (Projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner, Projectile.ai[0], 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, Projectile.ai[0], 0f); - for (int i = 0; i < 5; i++) + for (int i = 0; i < 8; i++) { - Vector2 soulVelocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(6f, 9f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, soulVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.33f), 0f, Projectile.owner, Main.rand.Next(6)); + bool pickup = i >= 5; + Vector2 soulVelocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (pickup ? 2.75f : Main.rand.NextFloat(6f, 9f)); + int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, soulVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.33f), 0f, Projectile.owner, Main.rand.Next(6), 0f, pickup ? 1f : 0f); + if (pickup) + Main.projectile[p].timeLeft *= 3; } } + + // Explosion visuals. + for (int i = 0; i < 25; i++) + { + Vector2 plasmaVelocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(6f, 11f); + Color plasmaColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, Main.rand.NextFloat()); + + float plasmaScale = Main.rand.NextFloat(0.8f, 1.4f); + int plasmaLifetime = Main.rand.Next(30, 45); + + SquishyLightParticle plasma = new(Projectile.Center, plasmaVelocity, plasmaScale, plasmaColor, plasmaLifetime); + GeneralParticleHandler.SpawnParticle(plasma); + } + + for (int i = 0; i < 15; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(1.8f, 2.4f); + Color dustColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, Main.rand.NextFloat()); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } } - public override Color? GetAlpha(Color lightColor) => FindColorForSoul((int)Projectile.ai[0]); - public override bool PreDraw(ref Color lightColor) { - Texture2D tex = ModContent.Request(Texture).Value; - Rectangle frame = tex.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None); + Texture2D mainTexture = ModContent.Request(Texture).Value; + Texture2D bloomCircleTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Rectangle frame = mainTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + + // Start to shake before exploding. + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + float shakeStrength = MathHelper.Lerp(0f, 6f, deathInterpolant); + Vector2 drawPosition = Projectile.Center + Main.rand.NextVector2Circular(shakeStrength, shakeStrength) - Main.screenPosition; + + // Turn the entire projectile white while exploding. + Color drawColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, deathInterpolant); + Color bloomColor = Color.Lerp(drawColor, Color.White, 0.25f); + + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Main.EntitySpriteDraw(bloomCircleTexture, drawPosition, null, Projectile.GetAlpha(bloomColor) * 0.85f, Projectile.rotation, bloomCircleTexture.Size() / 2f, Projectile.scale * 0.65f, SpriteEffects.None); + Main.EntitySpriteDraw(mainTexture, drawPosition, frame, Projectile.GetAlpha(drawColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None); + Main.EntitySpriteDraw(mainTexture, drawPosition, frame, Projectile.GetAlpha(Color.White), Projectile.rotation, frame.Size() / 2f, Projectile.scale * 0.8f, SpriteEffects.None); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } + + public float PlasmaBallWidthFunction(float completion, Vector2 vertexPos) + { + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + + float width; + float maxBodyWidth = Projectile.scale * 58f; + float curveRatio = 0.15f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + return width * MathHelper.Lerp(1f, 0f, deathInterpolant); + } + + public Color PlasmaBallColorFunction(float completion, Vector2 vertexPos) + { + Color bodyColor = Color.Lerp(Color.Transparent, FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0f, 0.35f, completion)); + Color endColor = Color.Lerp(bodyColor, FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0.35f, 1f, completion)); + + // Change to white when the ball is about to explode. + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + return Color.Lerp(endColor, Color.White, deathInterpolant); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PlasmaBallWidthFunction, PlasmaBallColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + } } } diff --git a/Projectiles/Magic/SHPExplosion.cs b/Projectiles/Magic/SHPExplosion.cs index 7b64dbe4e0..4b0bda748a 100644 --- a/Projectiles/Magic/SHPExplosion.cs +++ b/Projectiles/Magic/SHPExplosion.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Magic { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Player owner = Main.player[Projectile.owner]; - Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength - new Vector2(0, 3); + Vector2 launchVel = Utils.DirectionTo(owner.Center, owner.Calamity().mouseWorld) - Vector2.UnitY * 5f; target.MoveNPC(launchVel, SHPC.MightKnockbackStrength, false); } diff --git a/Projectiles/Magic/SHPL.cs b/Projectiles/Magic/SHPL.cs index fcc39b155d..5581d24080 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -1,27 +1,84 @@ -using CalamityMod.Particles; +using System.Linq; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using CalamityMod.Enums; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SHPL : ModProjectile, ILocalizedModType + public class SHPL : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { public new string LocalizationCategory => "Projectiles.Magic"; - public override string Texture => "CalamityMod/Projectiles/LaserProj"; + + public bool ShouldStopAndDie + { + get => Projectile.ai[1] == 1f; + set => Projectile.ai[1] = value.ToInt(); + } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public GeneralDrawLayer LayerToRenderTo => GeneralDrawLayer.BeforeProjectiles; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; + } public override void SetDefaults() { Projectile.width = 5; Projectile.height = 5; + Projectile.scale = 1.85f; Projectile.friendly = true; Projectile.extraUpdates = 3; Projectile.timeLeft = 600; + Projectile.penetrate = -1; Projectile.DamageType = DamageClass.Magic; } + public override bool? CanDamage() => !ShouldStopAndDie; + public override void AI() { + // 12MAY2025: fryzahh: + // This is made so that when hitting targets or tiles, the oldPos array can properly update so the laser appears to + // naturally dissipate entirely before despawning. Of course, it's also coded so that the laser stops dealing damage + // entirely once this is done to avoid hitting targets multiple times, so functionally the projectile remains the same + // and this change should have little to no effect on gameplay. If it does, ping me about it. + if (ShouldStopAndDie) + { + Projectile.velocity *= 0f; + if (Projectile.oldPos.Last() == Projectile.position) + { + Projectile.scale -= 0.15f; + if (Projectile.scale <= 0f) + { + Projectile.Kill(); + return; + } + } + + // Spawn a bunch of dusts at the dissipation point. + for (int i = 0; i < 2; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(1.8f, 2.4f); + Color dustColor = Color.Lerp(SHPB.FindColorForSoul((int)Projectile.ai[0]), Color.White, Main.rand.NextFloat()); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + } + + Projectile.rotation += MathHelper.TwoPi / 60f; Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 0.5f, 0.2f, 0.5f); float timerIncr = 3f; Projectile.localAI[0] += timerIncr; @@ -29,14 +86,65 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] = 100f; } - public override Color? GetAlpha(Color lightColor) => SHPB.FindColorForSoul((int)Projectile.ai[0]); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => ShouldStopAndDie = true; - public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); + public override bool OnTileCollide(Vector2 oldVelocity) + { + ShouldStopAndDie = true; + return false; + } public override void OnKill(int timeLeft) { AltLineParticle line = new(Projectile.Center, -Projectile.velocity.RotatedByRandom(MathHelper.Pi / 6f), false, 20, 1f, SHPB.FindColorForSoul((int)Projectile.ai[0])); GeneralParticleHandler.SpawnParticle(line); } + + public override bool PreDraw(ref Color lightColor) => false; + + public override void PostDraw(Color lightColor) + { + if (!ShouldStopAndDie) + return; + + // Draw a star over the collision point while dissipting. + Texture2D starTexture = ModContent.Request("CalamityMod/Particles/FullStar").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White, Projectile.rotation, starTexture.Size() * 0.5f, Projectile.scale, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + + public float LaserWidthFunction(float completion, Vector2 vertexPos) + { + float maxBodyWidth = Projectile.scale * Projectile.width; + float scaleInterpolant = Utils.GetLerpValue(0.05f, 0.2f, completion, true) * Utils.GetLerpValue(0.95f, 0.8f, completion, true); + return maxBodyWidth * scaleInterpolant * Projectile.scale; + } + + public float LaserCoreEnergyFunction(float completion, Vector2 vertexPos) + { + float maxBodyWidth = (Projectile.scale * Projectile.width) * 0.25f; + float scaleInterpolant = Utils.GetLerpValue(0.05f, 0.2f, completion, true) * Utils.GetLerpValue(0.95f, 0.8f, completion, true); + return maxBodyWidth * scaleInterpolant * Projectile.scale; + } + + public Color LaserColorFunction(float completion, Vector2 vertexPos) + { + Color startColor = Color.Lerp(Color.White, SHPB.FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0f, 0.125f, completion, true)); + Color bodyColor = Color.Lerp(startColor, SHPB.FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0.125f, 1f, completion, true)); + return Color.Lerp(startColor, bodyColor, completion); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + // Render the main trail for the body for the laser. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(LaserWidthFunction, LaserColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + + // Render a smaller, pure white trail in the same position to represent condensed energy in the core of the laser. + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(LaserCoreEnergyFunction, (_,_) => Color.White, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + } } } diff --git a/Projectiles/Magic/SHPS.cs b/Projectiles/Magic/SHPS.cs index 13fbc454d3..f58c8ea181 100644 --- a/Projectiles/Magic/SHPS.cs +++ b/Projectiles/Magic/SHPS.cs @@ -1,27 +1,49 @@ -using CalamityMod.Particles; +using System; +using System.Linq; +using CalamityMod.DataStructures; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using CalamityMod.Enums; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SHPS : ModProjectile, ILocalizedModType + public class SHPS : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public ref float Timer => ref Projectile.ai[1]; - public ref float State => ref Projectile.ai[2]; // 0 = Idle; 1 = Homing to enemy - public const float HomingRange = 560f; - public NPC Target; + // Whether or not this soul can be collected by the SHPC or not. + public bool IsAPickupSoul + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value.ToInt(); + } + + private float AIState = 0f; // 0 = Idle, 1 = Homing to enemy, 2 = Getting sucked to player + private const float HomingRange = 560f; + + private NPC Target; + private Projectile ToSuckTowards; public float RandomAnglingStrength = 0f; - public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + public override void SetDefaults() { - Projectile.width = Projectile.height = 10; + Projectile.width = Projectile.height = 24; Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.tileCollide = false; @@ -30,66 +52,199 @@ namespace CalamityMod.Projectiles.Magic } // Can only deal damage after it starts homing - public override bool? CanDamage() => Timer >= 25f; + public override bool? CanDamage() => Timer >= 25f && !IsAPickupSoul; public override void AI() { Timer++; - // Randomly changes the strength of idle turning - if (Timer % 30 == 1f) - RandomAnglingStrength = Main.rand.NextFloat(-0.16f, 0.16f); - // Determine behavior - if (Timer < 25) // Don't try to home at the start - State = 0f; - else + if (Timer >= 25) // Always remains idle for a short delay { - float npcDistCheck = HomingRange; - int index = -1; - foreach (NPC n in Main.ActiveNPCs) + if (!IsAPickupSoul) // Only run homing code if not a pickup { - if (!n.CanBeChasedBy(Projectile)) - continue; - - float currentNPCDist = Vector2.Distance(n.Center, Projectile.Center); - if (currentNPCDist < npcDistCheck) + float npcDistCheck = HomingRange; + int index = -1; + foreach (NPC n in Main.ActiveNPCs) { - npcDistCheck = currentNPCDist; - index = n.whoAmI; + if (!n.CanBeChasedBy(Projectile)) + continue; + + float currentNPCDist = Vector2.Distance(n.Center, Projectile.Center); + if (currentNPCDist < npcDistCheck) + { + npcDistCheck = currentNPCDist; + index = n.whoAmI; + } + } + + if (index == -1) + AIState = 0f; + else + { + Target = Main.npc[index]; + AIState = 1f; } } - - if (index == -1) - State = 0f; - else + else // Only run suction code if a pickup { - Target = Main.npc[index]; - State = 1f; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && p.Colliding(p.Hitbox, Projectile.Hitbox)) + { + if (AIState != 2f) + { + AIState = 2f; + Projectile.ExpandHitboxBy(70); + } + ToSuckTowards = p; + break; + } + else + AIState = 0f; + } } } // Actual behavior - if (State == 0f) + switch (AIState) { - Projectile.extraUpdates = 0; - Projectile.velocity = Projectile.velocity.RotatedBy(RandomAnglingStrength); - } - else if (State == 1f) - { - Projectile.extraUpdates = 1; - float speed = Projectile.velocity.Length(); - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Target.Center).ToRotation(), 0.15f).ToRotationVector2() * speed; + case 0f: + Projectile.extraUpdates = 0; + // Randomly changes the strength of idle turning + if (Timer % 30 == 1f) + RandomAnglingStrength = Main.rand.NextFloat(-0.16f, 0.16f); + Projectile.velocity = Projectile.velocity.RotatedBy(RandomAnglingStrength); + if (Projectile.velocity.Length() > 2.75f && IsAPickupSoul) + Projectile.velocity *= 0.96f; + break; + + case 1f: + Projectile.extraUpdates = 1; + float speed = Projectile.velocity.Length(); + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Target.Center).ToRotation(), 0.15f).ToRotationVector2() * speed; + break; + + case 2f: + // Attempt to smoothly fly towards SHPC's barrel. + Vector2 idealVelocity = Projectile.SafeDirectionTo(ToSuckTowards.ModProjectile().TipPosition + Main.player[Projectile.owner].velocity) * 30f; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.1f); + + if (Vector2.Distance(Projectile.Center, ToSuckTowards.ModProjectile().TipPosition) < 70f) + { + ToSuckTowards.ModProjectile().SoulColors.Add(Projectile.ai[0]); + Projectile.Kill(); + } + break; } - // Appearance - if (Timer % 1 == 0f) + if (Main.rand.NextBool(12)) { - SquareParticle trail = new(Projectile.Center, Vector2.Zero, false, 25, 3f, SHPB.FindColorForSoul((int)Projectile.ai[0])); - GeneralParticleHandler.SpawnParticle(trail); + for (int i = 0; i < 2; i++) + { + Vector2 dustSpawnPosition = Projectile.Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 dustVelocity = Projectile.velocity * -1.2f; + float dustScale = Main.rand.NextFloat(0.6f, 0.8f); + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, SHPB.FindColorForSoul((int)Projectile.ai[0]), dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } } - SquareParticle mainSpot = new(Projectile.Center, Vector2.Zero, false, 2, 1.4f, Color.White); - GeneralParticleHandler.SpawnParticle(mainSpot); + + // Pickup souls give off separate particles to differentiate them from Attack souls. + if (Main.rand.NextBool(6) && IsAPickupSoul) + { + for (int i = 0; i < 3; i++) + { + Vector2 smokeVelocity = Main.rand.NextVector2Circular(1f, 1f) * 0.65f; + int smokeLifetime = Main.rand.Next(30, 45); + float smokeScale = Main.rand.NextFloat(0.15f, 0.3f); + float smokeOpacity = Main.rand.NextFloat(0.75f, 0.9f); + + HeavySmokeParticle ghastlySmoke = new(Projectile.Center, smokeVelocity, SHPB.FindColorForSoul((int)Projectile.ai[0]), smokeLifetime, smokeScale, smokeOpacity, 0.02f, true); + GeneralParticleHandler.SpawnParticle(ghastlySmoke); + } + } + } + + public override void OnKill(int timeLeft) + { + // Spawn a bunch of dust along the length of the trail a soul is killed. + BezierCurve curve = new(Projectile.oldPos); + for (int i = 0; i < 35; i++) + { + Vector2 dustSpawnPosition = curve.Evaluate(Main.rand.NextFloat()); + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 3f; + float dustScale = Main.rand.NextFloat(1.2f, 1.8f); + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, SHPB.FindColorForSoul((int)Projectile.ai[0]), dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + + // Spawn a burst of dust at the center. + for (int i = 0; i < 12; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(1.8f, 2.4f); + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, SHPB.FindColorForSoul((int)Projectile.ai[0]), dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + } + + public override bool PreDraw(ref Color lightColor) => false; + + public float SoulWidthFunction(float completion, Vector2 _) + { + float width; + float maxBodyWidth = Projectile.scale * 24f; + float curveRatio = 0.15f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width; + } + + public Color SoulColorFunction(float completion, Vector2 _) + { + Color tipColor = Color.Lerp(SHPB.FindColorForSoul((int)Projectile.ai[0]), Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(SHPB.FindColorForSoul((int)Projectile.ai[0]), tipColor, completion); + } + + public float SoulCoreWidthFunction(float completion, Vector2 _) + { + float width; + float maxBodyWidth = Projectile.scale * 14f; + float curveRatio = 0.15f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width; + } + + public Color SoulCoreColorFunction(float completion, Vector2 _) + { + Color tipColor = Color.Lerp(Color.White, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(Color.White, tipColor, completion); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + // Render the main trail for the body for the soul. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SoulWidthFunction, SoulColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + + // Render a smaller, pure white trail in the same position to represent the glowing white core of the soul. + Vector2[] soulCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(soulCoreLength, new(SoulCoreWidthFunction, SoulCoreColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), soulCoreLength.Length * 2); } } } diff --git a/Projectiles/Magic/SHPV.cs b/Projectiles/Magic/SHPV.cs new file mode 100644 index 0000000000..a169b698cc --- /dev/null +++ b/Projectiles/Magic/SHPV.cs @@ -0,0 +1,228 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SHPV : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + private static Asset Smoke = ModContent.Request("CalamityMod/Particles/MediumMist"); + private static Asset SoulSquare = ModContent.Request("CalamityMod/Particles/Square"); + + private Player Owner => Main.player[Projectile.owner]; + private SlotId VacuumSound; + private const int VacuumStartFrames = 78; + private const int VacuumLoopFrames = 132; + private bool PlayedEndSound = false; + public ref float Timer => ref Projectile.ai[0]; + + // The maximum distance in pixels out from the tip of the gun in which souls can be sucked in. + private const float Size = 576f; + // The spread of the suction on each side. 27 degrees on each side, 54 degrees total. + private const float Spread = MathHelper.Pi / 6.66f; + // Maximum number of souls per visual ring drawn on the gun. Additional souls get moved into additional rings. + private const int MaxSoulsRing = 10; + // Manual offset used for drawing the gun. + private static Vector2 Offset => new Vector2(27f, -10f); + // The position of the tip of the gun. Used for most projectile logic. + public Vector2 TipPosition => Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * 62f + Vector2.UnitY * Offset.Y; + // A list containing the ai[0] values of each soul that is sucked in, used for determining the color to draw the soul as. + public List SoulColors = []; + // Tracks whether or not the gun should be doing the laser attack. + private bool FiringLasers = false; + // Allows for current soul color to be "consumed" every other laser shot. + private bool ConsumeSoul = false; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 70; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + public override void AI() + { + // Stop using the holdout if you cannot + if (Owner.CantUseHoldout(false)) + { + Projectile.Kill(); + return; + } + // Start sound + if (Timer == 0f) + VacuumSound = SoundEngine.PlaySound(SHPC.VacuumStart, Owner.Center); + // Move the vacuum sound on top of the player constantly + if (SoundEngine.TryGetActiveSound(VacuumSound, out var ChargeSound) && ChargeSound.IsPlaying) + ChargeSound.Position = Owner.Center; + Timer++; + + // If you release right click, use the laser attack + if (!Owner.Calamity().mouseRight) + FiringLasers = true; + if (FiringLasers) + { + // Vacuum end sound + if (!PlayedEndSound) + { + if (SoundEngine.TryGetActiveSound(VacuumSound, out var Vacuum)) + Vacuum?.Stop(); + VacuumSound = SoundEngine.PlaySound(SHPC.VacuumEnd, Owner.Center); + PlayedEndSound = true; + } + + if (SoulColors.Count > 0) + { + if (Timer % 5 == 0f) + { + if (Owner.HeldItem.ModItem is SHPC shpc) + { + SoundEngine.PlaySound(CommonCalamitySounds.ELRFireSound, Owner.Center); + Vector2 laserPos = TipPosition + Vector2.UnitY.RotatedBy(Projectile.rotation) * Main.rand.NextFloat(-7f, 7f); + Vector2 laserVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * 20f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), laserPos, laserVel, ModContent.ProjectileType(), (int)(Projectile.damage * 1.35f), 3f, Projectile.owner, SoulColors[0]); + + if (ConsumeSoul) + { + SoulColors.RemoveAt(0); + if (shpc.storedSoulpower > 0) + shpc.storedSoulpower--; + else if (SHPC.FindSoulForAmmo(Owner) != -1) + { + int soulType = SHPC.FindSoulForAmmo(Owner); + Owner.ConsumeItem(soulType); + shpc.storedSoulType = soulType; + shpc.storedSoulpower = SHPC.ShotsPerSoul; + } + else + { + SoulColors.Clear(); + } + } + ConsumeSoul = !ConsumeSoul; + } + else + SoulColors.Clear(); + } + } + } + else + { + // Debug code used for assessing the visual and functional area of the vacuum + /*BloomLineVFX l = new(TipPosition, Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).RotatedBy(Spread) * Size, 0.4f, Color.Gray, 2, true); + BloomLineVFX l2 = new(TipPosition, Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).RotatedBy(-Spread) * Size, 0.4f, Color.Gray, 2, true); + GeneralParticleHandler.SpawnParticle(l); + GeneralParticleHandler.SpawnParticle(l2);*/ + + // Spawn faded smoke particles idly + if (Timer % 2 == 0f) + { + Vector2 spawn = Owner.Center + Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).RotatedByRandom(Spread) * Size * Main.rand.NextFloat(0.4f, 1f); + MediumMistParticle smoky = new(spawn, Utils.DirectionTo(spawn, TipPosition) * 4.5f, Color.Gray, Color.DarkGray, 1.25f, 96f); + GeneralParticleHandler.SpawnParticle(smoky); + } + + // Vacuum loop sound + if ((Timer - VacuumStartFrames) % VacuumLoopFrames == 0) + VacuumSound = SoundEngine.PlaySound(SHPC.VacuumLoop, Owner.Center); + } + + // Typical held projectile shit + Owner.heldProj = Projectile.whoAmI; + Owner.ChangeDir(Math.Sign((Owner.Calamity().mouseWorld - Owner.Center).X)); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, (Owner.Center - Owner.Calamity().mouseWorld).ToRotation() * Owner.gravDir + MathHelper.PiOver2); + Owner.SetDummyItemTime(2); + Projectile.rotation = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).ToRotation(); + Projectile.velocity = Vector2.Zero; + Projectile.Center = Owner.Center; + // This is used to make the projectile naturally despawn with a delay after running out of souls or if you stop firing with no souls + if (!FiringLasers || SoulColors.Count > 0) + Projectile.timeLeft = 48; + } + + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(VacuumSound, out var ChargeSound)) + ChargeSound?.Stop(); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // You shouldn't be sucking in souls while firing + if (FiringLasers) + return false; + + bool withinAngle = Math.Abs(Utils.DirectionTo(TipPosition, Owner.Calamity().mouseWorld).ToRotation() - Utils.DirectionTo(TipPosition, targetHitbox.Center.ToVector2()).ToRotation()) <= Spread; + // This extra safety hitbox is a square around the gun tip used so that the soul doesn't need to perfectly travel down the narrow end of the vacuum to get sucked in + Rectangle extraSafetyHitbox = new Rectangle((int)TipPosition.X - (Projectile.width / 2), (int)TipPosition.Y - (Projectile.height / 2), Projectile.width, Projectile.height); + return (CalamityUtils.CircularHitboxCollision(TipPosition, Size, targetHitbox) && withinAngle) || targetHitbox.Intersects(extraSafetyHitbox); + } + public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + // Draw spiraling smoke particles representing the suction radius + Vector2 farthestPos = Owner.Center + Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * Size; + float rotation = Utils.DirectionTo(TipPosition, farthestPos).ToRotation(); + if (!FiringLasers) + { + Texture2D tex = Smoke.Value; + Rectangle frame = tex.Frame(1, 3, 0, Main.rand.Next(3)); + + Main.spriteBatch.SetBlendState(BlendState.Additive); + for (int i = 0; i < 6; i++) + { + // There are 3 separate streams offset from one another + for (int j = 0; j < 3; j++) + { + float distRatio = 1f - (Main.GameUpdateCount + j * 10) % 30 / 30f; + Vector2 posOffset = new Vector2(MathF.Sin(MathHelper.TwoPi / 6f * i) * 25f * distRatio, MathF.Cos(Main.GameUpdateCount * MathHelper.Pi / 30f + MathHelper.TwoPi / 6f * i) * 240f * distRatio).RotatedBy(rotation); + float colorMult = 0.5f * Utils.GetLerpValue(1f, 0.8f, distRatio, true); + Main.EntitySpriteDraw(tex, Vector2.Lerp(TipPosition, farthestPos, distRatio) + posOffset - Main.screenPosition, frame, Color.Gray * colorMult, rotation + MathHelper.Pi, frame.Size() / 2f, 1.5f * distRatio, SpriteEffects.None); + } + } + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + + // Manually draw the gun itself + Texture2D shpc = TextureAssets.Item[ModContent.ItemType()].Value; + Vector2 position = Owner.Center - Main.screenPosition + Vector2.UnitX.RotatedBy(rotation) * Offset.X + Vector2.UnitY * Offset.Y; + SpriteEffects sp = Owner.Calamity().mouseWorld.X < Owner.Center.X ? SpriteEffects.FlipVertically : SpriteEffects.None; + Main.EntitySpriteDraw(shpc, position, null, lightColor, rotation, shpc.Size() / 2f, 1f, sp); + + // Draw souls around the gun as a sort of indicator of how many you have sucked in + if (SoulColors.Count > 0) + { + Texture2D orbitingSoulTexture = SoulSquare.Value; + for (int i = 0; i < SoulColors.Count; i++) + { + int soulsInRing = SoulColors.Count > MaxSoulsRing ? (SoulColors.Count - i > SoulColors.Count % MaxSoulsRing ? MaxSoulsRing : SoulColors.Count % MaxSoulsRing) : SoulColors.Count; + // Souls past 10 get moved into additional rings + int ringsBack = i / MaxSoulsRing; + Vector2 soulPosition = Projectile.Center + Vector2.UnitX.RotatedBy(rotation) * (68f - (ringsBack * 9f)) + Vector2.UnitY * -12.5f; + Vector2 posOffset = new Vector2(MathF.Sin(Main.GameUpdateCount * MathHelper.Pi / 30f + MathHelper.TwoPi / soulsInRing * (i % MaxSoulsRing)) * 3f, MathF.Cos(Main.GameUpdateCount * MathHelper.Pi / 30f + MathHelper.TwoPi / soulsInRing * (i % MaxSoulsRing)) * 25f).RotatedBy(rotation); + + // Makes the souls disappear when they go "behind" the gun + bool shouldDraw = posOffset.RotatedBy(-rotation).X <= 2.7f; + if (shouldDraw) + { + Main.EntitySpriteDraw(orbitingSoulTexture, soulPosition + posOffset - Main.screenPosition, null, SHPB.FindColorForSoul((int)SoulColors[i]), 0f, orbitingSoulTexture.Size() * 0.5f, 1f, SpriteEffects.None); + Main.EntitySpriteDraw(orbitingSoulTexture, soulPosition + posOffset - Main.screenPosition, null, Color.White, 0f, orbitingSoulTexture.Size() * 0.5f, 0.5f, SpriteEffects.None); + } + } + } + return false; + } + } +} diff --git a/Projectiles/Magic/Sandstream.cs b/Projectiles/Magic/Sandstream.cs index 2b79fe2656..da69d2f40d 100644 --- a/Projectiles/Magic/Sandstream.cs +++ b/Projectiles/Magic/Sandstream.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i <= 10; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 313, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(1.3f, 1.7f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.DirtSpray, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(1.3f, 1.7f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.7f, 2.3f); } @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Magic dust.velocity = new Vector2(0.5f, 0.5f).RotatedByRandom(100); dust.scale = Main.rand.NextFloat(0.3f, 1.3f); } - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 313); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.DirtSpray); dust2.noGravity = true; dust2.velocity = -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f); dust2.scale = Main.rand.NextFloat(0.3f, 1.3f); @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Magic float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 1.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 1.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); - Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool(3) ? 288 : 121, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool(3) ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = false; dust.velocity = velOffset; dust.scale = Main.rand.NextFloat(0.5f, 0.8f); @@ -125,7 +125,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 velOffset = new Vector2(Main.rand.NextFloat(1.5f, 5.5f), 0).RotatedBy(rot * Main.rand.NextFloat(3.1f, 9.1f)); MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center + offset, velOffset * Main.rand.NextFloat(1.5f, 3f), Color.Peru, Color.PeachPuff, Main.rand.NextFloat(0.9f, 1.2f), 160f, Main.rand.NextFloat(0.03f, -0.03f)); GeneralParticleHandler.SpawnParticle(SandCloud); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool() ? 288 : 121, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool() ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = false; dust.velocity = velOffset; dust.scale = Main.rand.NextFloat(1.2f, 1.6f); diff --git a/Projectiles/Magic/SanguineFlareProj.cs b/Projectiles/Magic/SanguineFlareProj.cs index 4926c62ddd..10dd0573ca 100644 --- a/Projectiles/Magic/SanguineFlareProj.cs +++ b/Projectiles/Magic/SanguineFlareProj.cs @@ -1,8 +1,10 @@ using System; -using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,10 +15,8 @@ namespace CalamityMod.Projectiles.Magic public class SanguineFlareProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; - private int x; - private double speed = 10; - private float startSpeedY = 0f; - + public bool beingChanneled = true; + public float dmgMult = 1; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 4; @@ -25,48 +25,74 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = 30; + Projectile.height = 30; Projectile.friendly = true; Projectile.penetrate = 1; Projectile.tileCollide = false; Projectile.timeLeft = 600; Projectile.alpha = 255; Projectile.DamageType = DamageClass.Magic; + Projectile.extraUpdates = 19; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Lighting.AddLight(Projectile.Center, 1f, 0f, 0f); - if (Projectile.localAI[0] == 0f) + var player = Main.player[Projectile.owner]; + if (beingChanneled && player.channel) { - Projectile.velocity.X = Projectile.velocity.X + (Main.player[Projectile.owner].velocity.X * 0.5f); - startSpeedY = Projectile.velocity.Y + (Main.player[Projectile.owner].velocity.Y * 0.5f); - Projectile.velocity.Y = startSpeedY; - } - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] >= 180f) + Projectile.velocity = Vector2.Zero; + Projectile.timeLeft = 300 * Projectile.MaxUpdates; + if (Projectile.FinalExtraUpdate()) + { + player.itemTime = 15; + player.SetItemAnimation(15); + var dir = player.Center.DirectionTo(player.ClampedMouseWorld()) * 64; + player.direction = dir.X >= 0 ? 1 : -1; + Projectile.direction = player.direction; + player.itemRotation = (dir * player.direction).ToRotation(); + Projectile.Center = player.Center + player.Center.DirectionTo(player.ClampedMouseWorld()) * 64; + dmgMult *= 1.009f; + if (dmgMult >= 5f) + { + dmgMult = 5f; + player.channel = false; + } + + } + + } else { - x++; - speed += 0.1; - Projectile.velocity.Y = startSpeedY + (float)(speed * Math.Sin(x / 4)); - } - Projectile.rotation += Projectile.velocity.Y * 0.02f; - Projectile.alpha -= 5; - if (Projectile.alpha < 30) - { - Projectile.alpha = 30; + if (beingChanneled) + { + Projectile.damage = (int)(Projectile.damage * dmgMult); + Projectile.velocity = player.MountedCenter.DirectionTo(player.ClampedMouseWorld())*4; + Projectile.extraUpdates = 19; + beingChanneled = false; + } + + float particleSize = (dmgMult * 5 + 5)/2f; + Particle beam3 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam3); + + if (Main.rand.NextBool(8)) + { + Particle beam4 = new CustomSpark(Projectile.Center, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, Color.Red, new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam4); + } } } - public override Color? GetAlpha(Color lightColor) + public override bool? CanDamage() { - return new Color(200, 60, 60, Projectile.alpha); + return !beingChanneled; } - public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + SoundStyle hitSound = new("CalamityMod/Sounds/NPCKilled/PerfLargeDeath"); + SoundEngine.PlaySound(hitSound with { Volume = 0.5f }, Projectile.Center); Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); Projectile.width = 10; @@ -95,23 +121,63 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 60); - - int heal = (int)Math.Round(hit.Damage * 0.025); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) + target.AddBuff(ModContent.BuffType(), 360); + if (beingChanneled || Projectile.penetrate == -1) return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + var player = Main.player[Projectile.owner]; + float orbCount = MathHelper.Lerp(0, 20, (dmgMult-1) / 4f); + for (var i = 0; i < orbCount; i++) + { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), Projectile.Center, Projectile.velocity.RotatedByRandom(1) * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 18, 0f, player.whoAmI); + } + if (dmgMult > 1) + { + Projectile.position = Projectile.Center; + Projectile.Size *= dmgMult * 1.5f; + Projectile.Center = Projectile.position; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.timeLeft = 2; + Projectile.velocity *= 0; + Projectile.damage /= 2; + Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed*0.75f, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f*dmgMult/5f, 0.87f * dmgMult / 5f, (int)(40 * 0.38f), false); + GeneralParticleHandler.SpawnParticle(bloodsplosion); + Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(255, 32, 32)*0.5f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f * dmgMult / 5f, 0.155f * dmgMult / 5f, 40); + GeneralParticleHandler.SpawnParticle(bloodsplosion2); + } } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 60); public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + if (beingChanneled) + { + + Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + for (int i = 0; i < 1; i++) + { + //Photoviscerator drawcode, edited slightly + Color color = Color.DarkRed * (dmgMult/5f); + color.A = 0; + Vector2 drawPosition = Projectile.oldPos[i]+Projectile.Size /2f + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-32.5f, -32.5f); //Last vector is to offset the circle so that it is displayed where the hitbox actually is, instead of a bit down and to the right. + Color outerColor = color; + Color innerColor = color * 0.5f; + float intensity = 0.9f + 0.15f * (float)Math.Cos(dmgMult * MathHelper.TwoPi); + intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); + if (Projectile.timeLeft <= 60) //Shrinks to nothing when projectile is nearing death + { + intensity *= Projectile.timeLeft / 60f; + } + // Become smaller the futher along the old positions we are. + Vector2 outerScale = new Vector2(1f) * Projectile.scale * intensity; + Vector2 innerScale = new Vector2(1f) * Projectile.scale * intensity * 0.7f; + outerColor *= intensity; + innerColor *= intensity; + Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 1.25f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 1.25f, SpriteEffects.None, 0); + } + } return false; } } diff --git a/Projectiles/Magic/Shadowbolt.cs b/Projectiles/Magic/Shadowbolt.cs index adb118628d..2cdc0e9dd2 100644 --- a/Projectiles/Magic/Shadowbolt.cs +++ b/Projectiles/Magic/Shadowbolt.cs @@ -1,7 +1,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using rail; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -75,10 +74,10 @@ namespace CalamityMod.Projectiles.Magic if (reflectionTimer <= 0) { SoundStyle bounce = new("CalamityMod/Sounds/Item/ShadowboltReflect"); - SoundEngine.PlaySound(bounce with { Volume = 0.6f, Pitch = 0f }, platPosWall); + SoundEngine.PlaySound(bounce with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f), MaxInstances = -1 }, platPosWall); for (int i = 0; i < Main.maxNPCs; i++) Projectile.localNPCImmunity[i] = 0; - Projectile.velocity = (targetCenter - platPosCenter).SafeNormalize(Vector2.UnitX) * 5; + Projectile.velocity = (targetCenter - platPosCenter).SafeNormalize(Vector2.UnitX) * 12; reflecting = false; hasReboundOffPlat = true; time = 10; @@ -121,13 +120,13 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(blastRing); SoundStyle wall = new("CalamityMod/Sounds/Item/ShadowboltWallHit"); - SoundEngine.PlaySound(wall with { Volume = 0.5f, Pitch = 0f }, platPosWall); + SoundEngine.PlaySound(wall with { Volume = 0.5f, Pitch = 0f, MaxInstances = -1 }, platPosWall); reflecting = true; Projectile.extraUpdates = 0; } } - if (!hasReboundOffPlat && Projectile.numHits == 0 && !hasSetPlatSpawn && (Collision.SolidCollision(Projectile.Center, 20, 20) || time > 90)) + if (!hasReboundOffPlat && Projectile.numHits == 0 && !hasSetPlatSpawn && time > 70) { hasSetPlatSpawn = true; spawnPlat = true; @@ -140,7 +139,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < 2; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 267); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); chargefull.velocity = new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 0.8f); chargefull.scale = Main.rand.NextFloat(0.35f, 0.8f); chargefull.noGravity = true; @@ -151,6 +150,8 @@ namespace CalamityMod.Projectiles.Magic { if (time == 14) { + SoundEngine.PlaySound(SoundID.Item72 with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f), MaxInstances = -1 }, Projectile.Center); + Projectile.velocity = Projectile.velocity.RotatedByRandom(0.15f); for (int i = 0; i < 2; i++) { Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Indigo, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.3f, 0.75f, 12, true); @@ -160,7 +161,7 @@ namespace CalamityMod.Projectiles.Magic } for (int i = 0; i < 6; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); chargefull.velocity = Projectile.velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(0.6f, 2f); chargefull.scale = Main.rand.NextFloat(0.65f, 0.9f); chargefull.noGravity = true; @@ -176,12 +177,12 @@ namespace CalamityMod.Projectiles.Magic } if (time > 22 && time % 3 == 0) { - Particle spark = new GlowSparkParticle(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10, -Projectile.velocity * 0.1f, false, 18, 0.05f * (hasReboundOffPlat ? 1.1f : 0.5f), Color.Lerp(Color.Indigo, Color.Orchid, 0.25f), new Vector2(0.7f, 1f), true, false, 0.3f); + Particle spark = new GlowSparkParticle(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10, -Projectile.velocity * 0.1f, false, 18, 0.05f * (hasReboundOffPlat ? 1.1f : 0.5f), Color.Lerp(Color.Indigo, Color.Orchid, 0.25f), new Vector2(0.7f, 2f), true, false, 0.3f); GeneralParticleHandler.SpawnParticle(spark); } if (time > 30 && Main.rand.NextBool(12)) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 267); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); chargefull.velocity = Projectile.velocity * Main.rand.NextFloat(-2, 2); chargefull.scale = Main.rand.NextFloat(0.95f, 1.4f); chargefull.noGravity = true; @@ -195,15 +196,13 @@ namespace CalamityMod.Projectiles.Magic float minMult = 0.25f; int hitsToMinMult = 7; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= (hasReboundOffPlat ? 2.5f : 1) * damageMult; + modifiers.SourceDamage *= (hasReboundOffPlat ? 2.5f : 0.8f) * damageMult; if (!hasReboundOffPlat && Projectile.numHits == 0 && !hasSetPlatSpawn) { spawnPlat = true; hasSetPlatSpawn = true; } - //if (!hasReboundOffPlat) - //Projectile.extraUpdates = 10; } public override bool? CanDamage() => reflecting ? false : null; public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Magic/ShiftingSandsProj.cs b/Projectiles/Magic/ShiftingSandsProj.cs index f231dfd265..f5ca2df035 100644 --- a/Projectiles/Magic/ShiftingSandsProj.cs +++ b/Projectiles/Magic/ShiftingSandsProj.cs @@ -21,120 +21,170 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 18; Projectile.height = 18; Projectile.friendly = true; - Projectile.penetrate = 5; + Projectile.penetrate = 3; Projectile.DamageType = DamageClass.Magic; - Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = 12; } public override void AI() { - if (Projectile.soundDelay == 0 && Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) > 2f) - { - Projectile.soundDelay = 10; - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); - } - int sand = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.UnusedBrown, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[sand]; - dust.velocity *= 0.3f; - dust.position.X = Projectile.Center.X + 4f + (float)Main.rand.Next(-4, 5); - dust.position.Y = Projectile.Center.Y + (float)Main.rand.Next(-4, 5); - dust.noGravity = true; + int maxVelocity = 32; + Player player = Main.player[Projectile.owner]; + int height = Main.maxTilesY * 16; + int heightRatio = 0; - if (Main.myPlayer == Projectile.owner && Projectile.ai[0] <= 0f) + if (Projectile.ai[0] >= 0f) + heightRatio = (int)(Projectile.ai[1] / (float)height); + + bool notBeingChanneled = Projectile.ai[0] == -1f || Projectile.ai[0] == -2f; + if (Projectile.penetrate == 1 && Projectile.ai[0] >= 0f && heightRatio == 0) { - Player player = Main.player[Projectile.owner]; - if (player.channel) + Projectile.ai[1] += height; + heightRatio = 1; + Projectile.netUpdate = true; + } + if (Projectile.penetrate == 1 && Projectile.ai[0] == -1f) + { + Projectile.ai[0] = -2f; + Projectile.netUpdate = true; + } + if (heightRatio > 0 || Projectile.ai[0] == -2f) + Projectile.localAI[0] += 1f; + + if (Main.myPlayer == Projectile.owner) + { + if (Projectile.ai[0] >= 0f) { - float speed = 18f; - float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - Projectile.Center.X; - float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - Projectile.Center.Y; - if (player.gravDir == -1f) + if (player.channel && player.HeldItem.shoot == Projectile.type) { - mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - Projectile.Center.Y; - } - Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); - float mouseDist = mouseVec.Length(); - if (Projectile.ai[0] < 0f) - { - Projectile.ai[0] += 1f; - } - if (mouseDist > speed) - { - mouseDist = speed / mouseDist; - mouseVec.X *= mouseDist; - mouseVec.Y *= mouseDist; - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(Projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(Projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + Vector2 channelPos = Main.MouseWorld; + player.LimitPointToPlayerReachableArea(ref channelPos); + if (Projectile.ai[0] != channelPos.X || Projectile.ai[1] != channelPos.Y) { Projectile.netUpdate = true; + Projectile.ai[0] = channelPos.X; + Projectile.ai[1] = channelPos.Y + (float)(height * heightRatio); } - Projectile.velocity.X = mouseVec.X; - Projectile.velocity.Y = mouseVec.Y; } else { - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(Projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(Projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) + Projectile.netUpdate = true; + Projectile.ai[0] = -1f; + Projectile.ai[1] = -1f; + NPC homeTarget = ClosestNPCAtMagicMissileStyle(Projectile.Center, 800f); + if (homeTarget != null) { + int targetIndex = homeTarget.whoAmI; + if (targetIndex != -1) + Projectile.ai[1] = targetIndex; + } + else if (Projectile.velocity.Length() < 2f) + Projectile.velocity = Projectile.DirectionFrom(player.Center) * maxVelocity; + else + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * maxVelocity; + } + } + + if (notBeingChanneled && Projectile.ai[1] == -1f) + { + NPC homeTarget = ClosestNPCAtMagicMissileStyle(Projectile.Center, 800f); + if (homeTarget != null) + { + int targetIndex = homeTarget.whoAmI; + if (targetIndex != -1) + { + Projectile.ai[1] = targetIndex; Projectile.netUpdate = true; } - Projectile.velocity.X = mouseVec.X; - Projectile.velocity.Y = mouseVec.Y; } } - else if (Projectile.ai[0] <= 0f) - { - Projectile.netUpdate = true; - float speed = 12f; - Vector2 projCenter = Projectile.Center; - float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - projCenter.X; - float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - projCenter.Y; - if (player.gravDir == -1f) - { - mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - projCenter.Y; - } - Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); - float mouseDist = mouseVec.Length(); - if (mouseDist == 0f || Projectile.ai[0] < 0f) - { - projCenter = player.Center; - mouseVec = Projectile.Center - projCenter; - mouseDist = mouseVec.Length(); - } - mouseDist = speed / mouseDist; - mouseVec.X *= mouseDist; - mouseVec.Y *= mouseDist; - Projectile.velocity.X = mouseVec.X; - Projectile.velocity.Y = mouseVec.Y; - if (Projectile.velocity.X == 0f && Projectile.velocity.Y == 0f) - { - Projectile.Kill(); - } - Projectile.ai[0] = 1f; - } } - if (Projectile.velocity.X != 0f || Projectile.velocity.Y != 0f) - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - } - if (Projectile.velocity.Y > 16f) - { - Projectile.velocity.Y = 16f; - } - } - public override bool PreDraw(ref Color lightColor) + Vector2 targetVector = Vector2.Zero; + float chaseLerp = 1f; + if (Projectile.ai[0] > 0f && Projectile.ai[1] > 0f) + targetVector = new Vector2(Projectile.ai[0], Projectile.ai[1] % height); + + if (notBeingChanneled && Projectile.ai[1] >= 0f) + { + Projectile.tileCollide = false; + NPC target = Main.npc[(int)Projectile.ai[1]]; + if (target.CanBeChasedBy()) + { + targetVector = target.Center; + float invFineL = Utils.GetLerpValue(0f, 100f, Projectile.Distance(targetVector), true) * Utils.GetLerpValue(600f, 400f, Projectile.Distance(targetVector), true); + chaseLerp = MathHelper.Lerp(0f, 0.2f, Utils.GetLerpValue(200f, 20f, 1f - invFineL, true)); + } + else + { + Projectile.ai[1] = -1f; + Projectile.netUpdate = true; + } + } + + if (targetVector != Vector2.Zero) + { + if (Projectile.Distance(targetVector) >= 64f) + { + Vector2 distanceVector = targetVector - Projectile.Center; + Vector2 moveVelocity = distanceVector.SafeNormalize(Vector2.Zero); + float velocityMult = Math.Min(maxVelocity, distanceVector.Length()); + moveVelocity *= velocityMult; + if (Projectile.velocity.Length() < 4f) + Projectile.velocity += Projectile.velocity.RotatedBy(MathHelper.PiOver4).SafeNormalize(Vector2.Zero) * 4f; + + Projectile.velocity = Vector2.Lerp(Projectile.velocity, moveVelocity, chaseLerp); + } + else + { + Projectile.velocity *= 0.3f; + Projectile.velocity += (targetVector - Projectile.Center) * 0.3f; + } + + if (Projectile.timeLeft < 60) + Projectile.timeLeft = 60; + } + + if (notBeingChanneled && Projectile.ai[1] < 0f) + { + if (Projectile.velocity.Length() != maxVelocity) + Projectile.velocity = Projectile.velocity.MoveTowards(Projectile.velocity.SafeNormalize(Vector2.UnitY) * maxVelocity, 4f); + + if (Projectile.timeLeft > 300) + Projectile.timeLeft = 300; + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + private NPC ClosestNPCAtMagicMissileStyle(Vector2 origin, float maxDistanceToCheck = 800f) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; + NPC closestTarget = null; + float distance = maxDistanceToCheck; + + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].CanBeChasedBy() && Projectile.localNPCImmunity[i] == 0) + { + float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + if (Vector2.Distance(origin, Main.npc[i].Center) < distance) + { + distance = Vector2.Distance(origin, Main.npc[i].Center); + closestTarget = Main.npc[i]; + } + } + } + return closestTarget; + } + public override bool OnTileCollide(Vector2 oldVelocity) => Projectile.ai[0] < 0f; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[0] == -1f) + { + Projectile.ai[1] = -1f; + Projectile.netUpdate = true; + } } public override void OnKill(int timeLeft) @@ -149,10 +199,10 @@ namespace CalamityMod.Projectiles.Magic Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); int dustAmt = 36; - for (int index = 0; index < dustAmt; index++) + for (int i = 0; i < dustAmt; i++) { Vector2 dustPos = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - dustPos = dustPos.RotatedBy((double)((float)(index - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; + dustPos = dustPos.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; Vector2 dustVel = dustPos - Projectile.Center; int sand = Dust.NewDust(dustPos + dustVel, 0, 0, DustID.UnusedBrown, dustVel.X * 1.5f, dustVel.Y * 1.5f, 100, default, 1.2f); Main.dust[sand].noGravity = true; @@ -160,5 +210,11 @@ namespace CalamityMod.Projectiles.Magic Main.dust[sand].velocity = dustVel; } } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + return false; + } } } diff --git a/Projectiles/Magic/SigilSet.cs b/Projectiles/Magic/SigilSet.cs new file mode 100644 index 0000000000..ee111eaa8b --- /dev/null +++ b/Projectiles/Magic/SigilSet.cs @@ -0,0 +1,224 @@ +using System; +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ModLoader; +using ReLogic.Content; + +namespace CalamityMod.Projectiles.Magic +{ + public class SigilSet : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public ref float FadeoutFlag => ref Projectile.ai[2]; + private const float RuneLerpTime = 22f; + private const float RuneDelayTime = 3f; + private const float StartRadius = 240f; + private const float BaseRadius = 150f; + private const float GhostFlashDuration = 22f; + public ref float RuneTimer => ref Projectile.localAI[2]; + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 4; + } + + public override void SetDefaults() + { + Projectile.width = 550; + Projectile.height = 550; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.alpha = 255; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { +            // Culling Logic +            Player p = Main.player[Projectile.owner]; + if (p == null || !p.active || p.dead || p.HeldItem.type != ModContent.ItemType()) + { + Projectile.Kill(); + return; + } + +            // Visuals +            Projectile.Center = p.MountedCenter + Vector2.UnitY * p.gfxOffY; + Projectile.rotation += 0.01f; + Lighting.AddLight(Projectile.Center, 1f, 1f, 1f); + + if (Projectile.frameCounter++ > 3) + { + Projectile.frameCounter = 0; + if (Projectile.frame++ > 2) + { + Projectile.frame = 0; + } + } + +            // Fading logic +            if (FadeoutFlag == 1f) + { + Projectile.alpha += 13; + if (Projectile.alpha >= 255) + { + Projectile.Kill(); + } + } + else + { + Projectile.alpha = Utils.Clamp(Projectile.alpha - 25, 0, 255); + } + + RuneTimer++; + + + if (Projectile.ai[1] == 0) // spawn flag +            { + int[] sigilTypes = new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }; + + for (int i = 0; i < 6; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, sigilTypes[i], Projectile.damage, Projectile.knockBack, Projectile.owner, Projectile.identity, i); + } + + // Make it not happen again + Projectile.ai[1] = 1; + } + else // Sigils exist +            { + int activeSigilCount = 0; + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.ai[0] == Projectile.identity && proj.owner == Projectile.owner) + { + int projType = proj.type; + + // Check if it's any sigil that occupies a slot + if (projType == ModContent.ProjectileType() || + projType == ModContent.ProjectileType() || + projType == ModContent.ProjectileType() || + projType == ModContent.ProjectileType() || + projType == ModContent.ProjectileType() || + projType == ModContent.ProjectileType() || + projType == ModContent.ProjectileType()) + { + + if (proj.ai[2] <= 0) + { + activeSigilCount++; + } + } + } + } + + // If no non-fading sigils remain, start timer + if (activeSigilCount == 0) + { + Projectile.localAI[0]++; + if (Projectile.localAI[0] >= 50) + { + FadeoutFlag = 1f; + } + } + else + { + Projectile.localAI[0] = 0; + } + } + Projectile.timeLeft = 4; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D main = TextureAssets.Projectile[Type].Value; + Texture2D smol = ModContent.Request("CalamityMod/Projectiles/Magic/ThaumRingSmall").Value; + Texture2D rune = ModContent.Request("CalamityMod/Projectiles/Magic/ThaumRune").Value; + Asset ghostTextureAsset = ModContent.Request("CalamityMod/Projectiles/Magic/ThaumRuneGhost"); + + // Modify opacity again so it doesn't override changes to alpha in AI + float drawOpacity = 1f - Projectile.alpha / 255f; + Main.EntitySpriteDraw(smol, Projectile.Center - Main.screenPosition, null, Color.White * 0.5f * drawOpacity, Projectile.rotation, smol.Size() / 2, Projectile.scale + MathF.Cos(2 * Main.GlobalTimeWrappedHourly + 5) * 0.0027f, SpriteEffects.None); + Main.EntitySpriteDraw(main, Projectile.Center - Main.screenPosition, main.Frame(1, 4, 0, Projectile.frame), Color.White * 0.5f * drawOpacity, Projectile.rotation, new Vector2(main.Width / 2, main.Height / 8), Projectile.scale, SpriteEffects.None); + + // -- Normal Runes -- +            for (int i = 0; i < 14; i++) + { + float runeStartTick = i * RuneDelayTime; + + float t = MathHelper.Clamp((RuneTimer - runeStartTick) / RuneLerpTime, 0f, 1f); + float ease = MathHelper.SmoothStep(0f, 1f, t); + + float baseDist = BaseRadius + MathF.Sin(Main.GlobalTimeWrappedHourly * 2) * 10; + float lerpedRadius = MathHelper.Lerp(StartRadius, baseDist, ease); + + float angle = MathHelper.TwoPi * i / 14f; + Vector2 circleOffset = Vector2.UnitX.RotatedBy(angle) * lerpedRadius; + circleOffset = circleOffset.RotatedBy(-Projectile.rotation * 0.6f); + Vector2 animatedPos = Projectile.Center + circleOffset; + float runeAlpha = ease; + + Main.EntitySpriteDraw(rune, animatedPos - Main.screenPosition, rune.Frame(1, 7, 0, i % 6), Color.White * 0.5f * drawOpacity * runeAlpha, (animatedPos - Projectile.Center).ToRotation() + MathHelper.PiOver2, new Vector2(rune.Width / 2, rune.Height / 14), Projectile.scale, SpriteEffects.None); + } + + +            // --- White/Flash layer -- +            // Used in spawn anim for the runes +            Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix); + + Texture2D ghostTexture = ghostTextureAsset.Value; + + for (int i = 0; i < 14; i++) + { + float runeStartTick = i * RuneDelayTime; + float t = MathHelper.Clamp((RuneTimer - runeStartTick) / RuneLerpTime, 0f, 1f); + float ease = MathHelper.SmoothStep(0f, 1f, t); + + float peakTime = 0.25f; + float endTime = 1f; + + float rampUp = Utils.GetLerpValue(0f, peakTime, t, clamped: true); + float rampDown = Utils.GetLerpValue(endTime, peakTime, t, clamped: true); + + float ghostOpacity = Math.Min(rampUp, rampDown); + + if (ghostOpacity > 0f) + { +                    // Recalculate position (same as solid rune) +                    float baseDist = BaseRadius + MathF.Sin(Main.GlobalTimeWrappedHourly * 2) * 10; + float lerpedRadius = MathHelper.Lerp(StartRadius, baseDist, ease); + + float angle = MathHelper.TwoPi * i / 14f; + Vector2 circleOffset = Vector2.UnitX.RotatedBy(angle) * lerpedRadius; + circleOffset = circleOffset.RotatedBy(-Projectile.rotation * 0.6f); + Vector2 animatedPos = Projectile.Center + circleOffset; + + Rectangle runeFrame = ghostTexture.Frame(1, 7, 0, i % 6); + Vector2 runeOrigin = new Vector2(runeFrame.Width / 2, runeFrame.Height / 2); + + Main.EntitySpriteDraw(ghostTexture, animatedPos - Main.screenPosition, runeFrame, Color.White * drawOpacity * ghostOpacity * 0.6f, (animatedPos - Projectile.Center).ToRotation() + MathHelper.PiOver2, runeOrigin, Projectile.scale * (1f + ghostOpacity * 0.3f), SpriteEffects.None); + } + } + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.ZoomMatrix); + + return false; + } + + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Magic/SigilSet.png b/Projectiles/Magic/SigilSet.png new file mode 100644 index 0000000000..ef228236d4 Binary files /dev/null and b/Projectiles/Magic/SigilSet.png differ diff --git a/Projectiles/Magic/SmallSpirit.cs b/Projectiles/Magic/SmallSpirit.cs index d220c36ccd..646359d0df 100644 --- a/Projectiles/Magic/SmallSpirit.cs +++ b/Projectiles/Magic/SmallSpirit.cs @@ -2,6 +2,7 @@ using CalamityMod.Graphics.Metaballs; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -113,7 +114,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < 6; i++) { - Dust necroplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12f, 12f), 261); + Dust necroplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12f, 12f), DustID.AncientLight); necroplasm.color = Color.Lerp(Color.LightPink, Color.Red, Main.rand.NextFloat(0.67f)); necroplasm.scale = 1.2f; necroplasm.fadeIn = 0.55f; diff --git a/Projectiles/Magic/Snowball.cs b/Projectiles/Magic/Snowball.cs index 451b62000a..e62ac2ff5b 100644 --- a/Projectiles/Magic/Snowball.cs +++ b/Projectiles/Magic/Snowball.cs @@ -19,7 +19,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.coldDamage = true; Projectile.penetrate = 1; - Projectile.extraUpdates = 1; Projectile.coldDamage = true; } diff --git a/Projectiles/Magic/Snowflake.cs b/Projectiles/Magic/Snowflake.cs index f024feb401..edcd3fe031 100644 --- a/Projectiles/Magic/Snowflake.cs +++ b/Projectiles/Magic/Snowflake.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Items.Weapons.Magic; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -8,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class Snowflake : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; diff --git a/Projectiles/Magic/SolarElementalBeam.cs b/Projectiles/Magic/SolarElementalBeam.cs index ecde7f4ccb..b067427386 100644 --- a/Projectiles/Magic/SolarElementalBeam.cs +++ b/Projectiles/Magic/SolarElementalBeam.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -47,7 +48,7 @@ namespace CalamityMod.Projectiles.Magic Color dustColor = Color.Lerp(Color.White, Color.Yellow, j / 12f); float dustScale = MathHelper.Lerp(1.6f, 0.85f, j / 12f); - Dust fire = Dust.NewDustPerfect(Projectile.Center, 6); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.Torch); fire.velocity = angle.ToRotationVector2() * starSpeed; fire.color = dustColor; fire.scale = dustScale; diff --git a/Projectiles/Magic/SparklingEmpressHoldout.cs b/Projectiles/Magic/SparklingEmpressHoldout.cs index 8e544c347a..92726655cf 100644 --- a/Projectiles/Magic/SparklingEmpressHoldout.cs +++ b/Projectiles/Magic/SparklingEmpressHoldout.cs @@ -32,14 +32,15 @@ namespace CalamityMod.Projectiles.Magic public bool deservesMana = false; public float GfbMult = 1; - public int cooldownTime => 20 * (deservesMana ? 2 : 1); + public int CooldownTime => 20 * (deservesMana ? 2 : 1); + private const int FishShineTime = 150; public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner.dead) + if (HeldItem.type != Owner.HeldItem.type || Owner.dead) Projectile.Kill(); if (Owner.CantUseHoldout() && !hasLetGo) - postFireTimer = cooldownTime; + postFireTimer = CooldownTime; } public override void HoldoutAI() @@ -48,7 +49,8 @@ namespace CalamityMod.Projectiles.Magic GfbMult = MathHelper.Clamp((int)(time / 60), 1, 7); if (!hasLetGo) { - if (shootingTimer >= (deservesMana && !Main.zenithWorld ? 6 : 3)) + int shootInterval = deservesMana && !Main.zenithWorld ? Owner.HeldItem.useTime * 2 : Owner.HeldItem.useTime; + if (shootingTimer >= shootInterval) { if (Owner.CheckMana(HeldItem, (int)(HeldItem.mana * GfbMult), true, false)) { @@ -58,15 +60,15 @@ namespace CalamityMod.Projectiles.Magic else { SoundEngine.PlaySound(SoundID.MaxMana with { Pitch = -0.5f }, Projectile.Center); - postFireTimer = cooldownTime; + postFireTimer = CooldownTime; } } shootingTimer++; - if (time >= 120) + if (time >= FishShineTime) deservesMana = true; - if (time == 120) + if (time == FishShineTime) { SoundStyle f = new("CalamityMod/Sounds/Item/MeldShoot"); SoundEngine.PlaySound(f with { Volume = 0.5f, Pitch = 0.95f }, Projectile.Center); @@ -129,7 +131,7 @@ namespace CalamityMod.Projectiles.Magic CombatText.NewText(Projectile.Hitbox, Color.Cyan, CalamityUtils.GetTextValue("Misc.Empress4")); } if (postFireTimer == 0) - postFireTimer = (cooldownTime * 5); + postFireTimer = (CooldownTime * 5); deservesMana = false; } } @@ -143,7 +145,7 @@ namespace CalamityMod.Projectiles.Magic if (deservesMana && postFireTimer % 8 == 0) { - int manaGained = 24; + int manaGained = 10; Owner.statMana += manaGained; if (Main.myPlayer == Owner.whoAmI) Owner.ManaEffect(manaGained); @@ -161,10 +163,6 @@ namespace CalamityMod.Projectiles.Magic SoundStyle s = new("CalamityMod/Sounds/Custom/PistolShrimpBubbleBurst"); SoundEngine.PlaySound(s with { Volume = 0.35f, Pitch = -postFireTimer * 0.01f, MaxInstances = -1 }, Projectile.Center); } - if (deservesMana && (postFireTimer + 2) % 8 == 0) - { - Owner.HealPlayer(1); - } if (postFireTimer == 1) Projectile.Kill(); postFireTimer--; @@ -172,9 +170,12 @@ namespace CalamityMod.Projectiles.Magic public void Shoot() { Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); - Vector2 firingVelocity = (shootDirection * 4); - for (int k = 0; k < (int)(GfbMult); k++) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition + firingVelocity * 5, firingVelocity.RotatedByRandom(Main.zenithWorld ? GfbMult * 0.08f : 0), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 0); + if (Main.myPlayer == Projectile.owner) + { + Vector2 firingVelocity = (shootDirection * 4); + for (int k = 0; k < (int)(GfbMult); k++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition + firingVelocity * 5, firingVelocity.RotatedByRandom(Main.zenithWorld ? GfbMult * 0.08f : 0), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 0); + } for (int k = 0; k < 4; k++) { diff --git a/Projectiles/Magic/SparklingLaser.cs b/Projectiles/Magic/SparklingLaser.cs index 4a6cbb038c..54a4b578af 100644 --- a/Projectiles/Magic/SparklingLaser.cs +++ b/Projectiles/Magic/SparklingLaser.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -7,6 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class SparklingLaser : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; diff --git a/Projectiles/Magic/SpiritCongregation.cs b/Projectiles/Magic/SpiritCongregation.cs index ba7385356e..2858155357 100644 --- a/Projectiles/Magic/SpiritCongregation.cs +++ b/Projectiles/Magic/SpiritCongregation.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Graphics.Metaballs; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class SpiritCongregation : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -149,7 +151,7 @@ namespace CalamityMod.Projectiles.Magic burstDirectionVariance += j * 2; for (int k = 0; k < 40; k++) { - Dust burstDust = Dust.NewDustPerfect(Projectile.Center, 267); + Dust burstDust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); burstDust.scale = Main.rand.NextFloat(1.74f, 2.5f); burstDust.position += Main.rand.NextVector2Circular(10f, 10f); burstDust.velocity = Main.rand.NextVector2Square(-burstDirectionVariance, burstDirectionVariance).SafeNormalize(Vector2.UnitY) * burstSpeed; diff --git a/Projectiles/Magic/StardustElementalBeam.cs b/Projectiles/Magic/StardustElementalBeam.cs index 4ff5c27167..f785b1b2ef 100644 --- a/Projectiles/Magic/StardustElementalBeam.cs +++ b/Projectiles/Magic/StardustElementalBeam.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic diff --git a/Projectiles/Magic/StickyFeather.cs b/Projectiles/Magic/StickyFeather.cs index 96822f36ce..d33a69bb29 100644 --- a/Projectiles/Magic/StickyFeather.cs +++ b/Projectiles/Magic/StickyFeather.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.aiStyle = ProjAIStyleID.Nail; AIType = ProjectileID.NailFriendly; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 1; } public override void AI() @@ -35,10 +37,6 @@ namespace CalamityMod.Projectiles.Magic } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.immune[Projectile.owner] = 1; - } public override void OnKill(int timeLeft) { diff --git a/Projectiles/Magic/SylvBolt.cs b/Projectiles/Magic/SylvBolt.cs new file mode 100644 index 0000000000..ec2f293dbe --- /dev/null +++ b/Projectiles/Magic/SylvBolt.cs @@ -0,0 +1,155 @@ +using System; +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Magic +{ + public class SylvBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + /// + /// The color hue interpolant for this bolt. + /// + public ref float HueInterpolant => ref Projectile.ai[0]; + + /// + /// How many natural frames have elapsed so far throughout the duration of this bolt's life. Extra updates do not affect this timer. + /// + public int Time + { + get => (int)Projectile.ai[1]; + set => Projectile.ai[1] = value; + } + + /// + /// Whether this bolt is vanishing due to the a collision. + /// + public bool Vanishing + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value.ToInt(); + } + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 23; + } + + public override void SetDefaults() + { + Projectile.width = 4; + Projectile.height = 4; + Projectile.friendly = true; + Projectile.extraUpdates = 2; + Projectile.penetrate = 12; + Projectile.timeLeft = Projectile.extraUpdates * 90; + Projectile.DamageType = DamageClass.Magic; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 0; + } + + public override void AI() + { + Projectile.velocity *= 1.004f; + if (Vanishing) + Vanish(); + + if (Projectile.FinalExtraUpdate()) + Time++; + + Projectile.scale = Utils.GetLerpValue(0f, 7f, Time, true); + + CreateMagicDust(); + + // Emit light. + Lighting.AddLight(Projectile.Center, Vector3.One * Projectile.Opacity * 0.45f); + } + + /// + /// Makes this bolt vanish. + /// + private void Vanish() + { + Projectile.Opacity = MathHelper.Lerp(Projectile.Opacity, 0f, 0.24f); + Projectile.velocity = Vector2.Zero; + Projectile.tileCollide = false; + if (Projectile.Opacity <= 0.1f) + Projectile.Kill(); + } + + /// + /// Idly emits magic dust off this bolt. + /// + private void CreateMagicDust() + { + if (Main.rand.NextBool(4)) + { + Dust magic = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail); + magic.color = ColorFunction(0f, Vector2.Zero); + magic.scale *= 0.56f; + magic.noGravity = true; + } + } + + /// + /// The function responsible for dictating the color of this bolt. + /// + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) + { + float opacity = (1f - completionRatio) * Projectile.Opacity; + return CalamityUtils.MulticolorLerp(HueInterpolant, new Color(255, 193, 255), Color.White, new Color(127, 242, 255)) * opacity; + } + + /// + /// The function responsible for dictating the width of this bolt. + /// + internal float WidthFunction(float completionRatio, Vector2 vertexPos) + { + float tip = 1f - MathF.Pow(1f - Utils.GetLerpValue(0.05f, 0.2f, completionRatio * Projectile.Opacity, true), 2f); + return tip * Projectile.Opacity * Projectile.scale * 22f; + } + + public override bool PreDraw(ref Color lightColor) + { + MiscShaderData boltShader = GameShaders.Misc["CalamityMod:SylvestaffProjectile"]; + + boltShader.SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, smoothen: false, shader: boltShader), 80); + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (!Vanishing && Projectile.penetrate < 2) + { + Vanishing = true; + Projectile.velocity *= 0.02f; + Projectile.extraUpdates = 0; + Projectile.netUpdate = true; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (!Vanishing) + { + Vanishing = true; + Projectile.velocity = Vector2.Zero; + Projectile.extraUpdates = 0; + Projectile.netUpdate = true; + } + return false; + } + + public override bool? CanDamage() => !Vanishing; + } +} diff --git a/Projectiles/Magic/SylvRay.cs b/Projectiles/Magic/SylvRay.cs new file mode 100644 index 0000000000..6876622c59 --- /dev/null +++ b/Projectiles/Magic/SylvRay.cs @@ -0,0 +1,217 @@ +using System; +using System.IO; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SylvRay : ModProjectile, ILocalizedModType + { + /// + /// The position from which this ray's glow effect appears. + /// + public Vector2 GlowCenter + { + get; + set; + } + + /// + /// How many natural frames have elapsed so far throughout the duration of this ray's life. Extra updates do not affect this timer. + /// + public int Time + { + get => (int)Projectile.ai[0]; + set => Projectile.ai[0] = value; + } + + public new string LocalizationCategory => "Projectiles.Magic"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 54; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 4; + Projectile.height = 4; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.ignoreWater = true; + Projectile.penetrate = 70; + Projectile.extraUpdates = 3; + Projectile.timeLeft = 60 * Projectile.extraUpdates; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.WriteVector2(GlowCenter); + + public override void ReceiveExtraAI(BinaryReader reader) => GlowCenter = reader.ReadVector2(); + + public override void AI() + { + if (Projectile.FinalExtraUpdate()) + Time++; + + Projectile.Opacity = Utils.GetLerpValue(0f, Projectile.MaxUpdates * 10f, Projectile.timeLeft, true); + Projectile.scale = Utils.GetLerpValue(1f, 9.5f, Time, true) * Projectile.Opacity; + + if (GlowCenter == Vector2.Zero) + GlowCenter = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero) * 74f; + + HandleBoltFiring(); + CreateGlowyDust(); + + Lighting.AddLight(Projectile.Center, Vector3.One * Projectile.Opacity * 0.7f); + } + + /// + /// Handles the firing of bolts across this ray. + /// + private void HandleBoltFiring() + { + int shootRate = Sylvestaff.RayBoltShootRate; + if (Time % shootRate == 0 && Projectile.FinalExtraUpdate()) + { + int trailSearchPositions = 13; + for (int i = 0; i < trailSearchPositions; i += 3) + TryToFireBolt(Projectile.oldPos[i] + Projectile.Size * 0.5f, i / (float)trailSearchPositions); + } + } + + /// + /// Attempts to fire a given bolt projectile from a given position at the closest enemy to said position, assuming one exists. + /// + private void TryToFireBolt(Vector2 searchPosition, float hue) + { + NPC potentialTarget = searchPosition.ClosestNPCAt(Sylvestaff.RayBoltTargetingRange, false); + if (potentialTarget is null) + return; + + SoundEngine.PlaySound(Sylvestaff.BounceSound with { MaxInstances = 12, Volume = 0.4f, Pitch = 0.4f }, Projectile.Center); + + float shootSpeed = Projectile.velocity.Length(); + Vector2 shootVelocity = (potentialTarget.Center - searchPosition).SafeNormalize(Vector2.UnitY) * shootSpeed; + if (Projectile.owner == Main.myPlayer) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), searchPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, hue); + + float burstSpeed = Main.rand.NextFloat(1f, 3f); + for (int i = 0; i < 4; i++) + { + Dust magicBurst = Dust.NewDustPerfect(searchPosition, DustID.PortalBoltTrail); + magicBurst.velocity = Projectile.velocity.RotatedBy(MathHelper.TwoPi * i / 4f + MathHelper.PiOver4).SafeNormalize(Vector2.Zero) * burstSpeed; + magicBurst.color = Color.White; + magicBurst.noLight = true; + magicBurst.noGravity = true; + } + } + + /// + /// Emits dust particles at the glow center of this ray, to help sell the notion that it's appearing from a concentrated ball of queer magic energy. + /// + private void CreateGlowyDust() + { + if (Time <= 9 && Main.rand.NextBool()) + { + Color colorAccent = Main.rand.NextBool() ? Color.HotPink : Color.Aqua; + + Dust transMagic = Dust.NewDustPerfect(GlowCenter, DustID.PortalBoltTrail); + transMagic.velocity = Main.rand.NextVector2Circular(4.6f, 4.6f) + Projectile.velocity * 0.25f; + transMagic.color = Color.Lerp(Color.White, colorAccent, Main.rand.NextFloat(0.23f)); + transMagic.scale *= 1.1f; + transMagic.fadeIn = 0.75f; + transMagic.noGravity = true; + } + } + + /// + /// The function responsible for dictating the color of this ray. + /// + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) + { + float opacity = MathF.Pow(Utils.GetLerpValue(1f, 0.64f, completionRatio, true), 3f) * Projectile.Opacity; + float colorInterpolant = MathF.Cos(MathHelper.Pi * completionRatio - Main.GlobalTimeWrappedHourly * 7.2f) * 0.5f + 0.5f; + + Color pink = new Color(255, 147, 255); + Color blue = new Color(109, 224, 255); + Color baseColor = CalamityUtils.MulticolorLerp(colorInterpolant, pink, Color.White, blue, Color.White); + + return baseColor * opacity; + } + + /// + /// The function responsible for dictating the width of this ray. + /// + internal float WidthFunction(float completionRatio, Vector2 vertexPos) + { + float expansionCompletion = 1f - MathF.Pow(1f - Utils.GetLerpValue(0f, 0.3f, completionRatio, true), 2f); + float undulation = MathF.Cos(MathHelper.Pi * completionRatio * 5f - Main.GlobalTimeWrappedHourly * 23f) * 2.4f; + float maxWidth = undulation + 32f; + + return MathHelper.Lerp(0f, Projectile.scale * maxWidth, expansionCompletion); + } + + /// + /// The function responsible for dictating the render offset of this ray. + /// + internal Vector2 OffsetFunction(float completionRatio, Vector2 vertexPos) => Projectile.Size * 0.5f; + + /// + /// Renders the front-glow for this ray, to help make it look like it has a defined origin of concentrated magic. + /// + private void RenderFrontGlow() + { + float glowAnimationProgress = Utils.GetLerpValue(0f, 9.5f, Time, true); + float glowBump = CalamityUtils.Convert01To010(glowAnimationProgress); + float glowRotation = Projectile.velocity.ToRotation(); + Vector2 glowScale = new Vector2(1f + glowBump * 0.8f, 1f) * glowBump; + + Vector2 startingPosition = GlowCenter - Main.screenPosition; + Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/BloomCirclePinpoint").Value; + Main.spriteBatch.Draw(lightTexture, startingPosition, null, ColorFunction(0f,Vector2.Zero) with { A = 0 }, glowRotation, lightTexture.Size() * 0.5f, glowScale, 0, 0f); + Main.spriteBatch.Draw(lightTexture, startingPosition, null, ColorFunction(0f, Vector2.Zero) with { A = 0 }, glowRotation, lightTexture.Size() * 0.5f, glowScale * 0.4f, 0, 0f); + } + + public override bool PreDraw(ref Color lightColor) + { + RenderFrontGlow(); + + MiscShaderData rayShader = GameShaders.Misc["CalamityMod:SylvestaffProjectile"]; + rayShader.SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, OffsetFunction, pixelate: false, shader: rayShader), 32); + return false; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.penetrate--; + if (Projectile.penetrate <= 0) + { + Projectile.Kill(); + } + else + { + SoundEngine.PlaySound(Sylvestaff.BounceSound, 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; + } + } +} diff --git a/Projectiles/Magic/SylvestaffHoldout.cs b/Projectiles/Magic/SylvestaffHoldout.cs new file mode 100644 index 0000000000..eb344012ef --- /dev/null +++ b/Projectiles/Magic/SylvestaffHoldout.cs @@ -0,0 +1,263 @@ +using System; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Physics; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SylvestaffHoldout : ModProjectile, IPixelatedPrimitiveRenderer + { + public GeneralDrawLayer LayerToRenderTo => GeneralDrawLayer.BeforeProjectiles | GeneralDrawLayer.AfterPlayers; + + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + + /// + /// The left ribbon on this holdout. + /// + public RopeHandle? LeftRibbon; + + /// + /// The right ribbon on this holdout. + /// + public RopeHandle? RightRibbon; + + /// + /// The player owner of this holdout staff. + /// + public Player Owner => Main.player[Projectile.owner]; + + /// + /// A general purpose, ever-increment timer used by this holdout staff. + /// + public ref float Time => ref Projectile.ai[0]; + + /// + /// The point of attachment for ribbons on this staff. + /// + public Vector2 RibbonAttachPoint => Projectile.Center + Projectile.velocity * Projectile.scale * Projectile.width * 0.34f; + + /// + /// The length of ribbons attached to this staff. + /// + private static float RibbonLength => 70f; + + public override string Texture => ModContent.GetInstance().Texture; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 94; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Magic; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.timeLeft = 72000; + } + + public override void AI() + { + if (!Owner.channel) + Projectile.Kill(); + + if (LeftRibbon is null && RightRibbon is null) + InitializeRibbons(); + + AimTowardsMouse(); + HandleHoldoutLogic(); + OrientOwnerArms(); + FireAwesomeMagicRays(); + UpdateRibbon(LeftRibbon, Projectile.velocity.RotatedBy(-MathHelper.PiOver2)); + UpdateRibbon(RightRibbon, Projectile.velocity.RotatedBy(MathHelper.PiOver2)); + + Time++; + } + + /// + /// Initializes the ribbons attached to this staff. + /// + private void InitializeRibbons() + { + int ribbonSegmentCount = 12; + float distancePerSegment = RibbonLength / ribbonSegmentCount; + RopeSettings ribbonSettings = new RopeSettings() + { + StartIsFixed = true, + Mass = 0.72f, + RespondToEntityMovement = true, + RespondToWind = true + }; + LeftRibbon = ModContent.GetInstance().RequestNew(RibbonAttachPoint, Projectile.Center, ribbonSegmentCount, distancePerSegment, Vector2.Zero, ribbonSettings, 25); + RightRibbon = ModContent.GetInstance().RequestNew(RibbonAttachPoint, Projectile.Center, ribbonSegmentCount, distancePerSegment, Vector2.Zero, ribbonSettings, 25); + } + + /// + /// Handles all logic pertaining to making this staff act as a holdout projectile. + /// + private void HandleHoldoutLogic() + { + Vector2 center = Owner.MountedCenter + Vector2.UnitY * 7f + Projectile.velocity * Projectile.width * 0.31f; + + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.Center = Owner.RotatedRelativePoint(center) - Vector2.UnitY * Owner.gfxOffY; + Projectile.spriteDirection = (Math.Cos(Projectile.rotation) > 0).ToDirectionInt(); + + // The staff is a holdout projectile; change the player's variables to reflect this. + Owner.ChangeDir(Projectile.spriteDirection); + Owner.SetDummyItemTime(2); + Owner.heldProj = Projectile.whoAmI; + + Projectile.rotation += MathHelper.PiOver4; + if (Projectile.spriteDirection == -1) + Projectile.rotation += MathHelper.PiOver2; + } + + /// + /// Orients the owner player's arm rotation to help make it look like they're actually holding the staff. + /// + private void OrientOwnerArms() + { + float baseRotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + float directionVerticality = MathF.Abs(Projectile.velocity.X); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, baseRotation + Owner.direction * directionVerticality * MathHelper.PiOver4); + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, baseRotation + Owner.direction * directionVerticality * 0.33f); + } + + /// + /// Makes this staff aim towards the owner's mouse. + /// + private void AimTowardsMouse() + { + if (Main.myPlayer != Projectile.owner) + return; + + Vector2 idealDirection = Projectile.SafeDirectionTo(Main.MouseWorld); + Vector2 newDirection = Vector2.Lerp(Projectile.velocity, idealDirection, Sylvestaff.TurnSpeedInterpolant).SafeNormalize(Vector2.UnitX * Owner.direction); + if (Projectile.velocity != newDirection) + { + Projectile.velocity = newDirection; + Projectile.netUpdate = true; + Projectile.netSpam = 0; + } + } + + /// + /// Updates a given ribbon. + /// + private void UpdateRibbon(RopeHandle? ribbon, Vector2 gravityDirection) + { + // Ensure that the handle is properly initialized before proceeding any further. + if (ribbon is not RopeHandle rope) + return; + + rope.Start = RibbonAttachPoint; + rope.Gravity = gravityDirection * 0.15f - Projectile.velocity * 0.4f; + } + + /// + /// Handles the firing of magic ray projectiles for this staff. + /// + private void FireAwesomeMagicRays() + { + Item heldItem = Owner.HeldItem; + if (heldItem is null) + return; + + if (Time % heldItem.useAnimation == heldItem.useAnimation - 1 && Owner.CheckMana(heldItem.mana, true)) + { + SoundEngine.PlaySound(Sylvestaff.FireSound, Projectile.Center); + if (Main.myPlayer == Projectile.owner) + { + int damage = Owner.GetWeaponDamage(heldItem); + Vector2 shootVelocity = Projectile.velocity * heldItem.shootSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shootVelocity, ModContent.ProjectileType(), damage, heldItem.knockBack, Projectile.owner); + + // Apply a minor amount of recoil. + Projectile.velocity -= Projectile.velocity.RotatedBy(Projectile.spriteDirection * MathHelper.PiOver2) * Sylvestaff.StaffRecoilForce; + } + } + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + bool backLayer = layer == GeneralDrawLayer.BeforeProjectiles; + RenderRibbon(LeftRibbon, -1, backLayer); + RenderRibbon(RightRibbon, 1, backLayer); + } + + /// + /// The function responsible for dictating the width of this staff's ribbons. + /// + private float RibbonWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * Utils.GetLerpValue(0f, 0.2f, completionRatio, true) * 3.6f; + + /// + /// The function responsible for dictating the color of this staff's ribbons. + /// + private Color RibbonColorFunction(float completionRatio, Vector2 vertexPos) + { + Color light = Lighting.GetColor(RibbonAttachPoint.ToTileCoordinates()); + return Projectile.GetAlpha(light); + } + + /// + /// Renders one of this staff's ribbons. + /// + private void RenderRibbon(RopeHandle? ribbon, int direction, bool backLayer) + { + // Ensure that the handle is properly initialized before proceeding any further. + if (ribbon is not RopeHandle rope) + return; + + Vector2 forwardDirection = Projectile.velocity; + Vector2 sideDirection = forwardDirection.RotatedBy(MathHelper.PiOver2 * direction); + Vector2 attachmentPoint = RibbonAttachPoint; + Vector2[] ribbonPositions = [.. rope.Positions]; + int positionCount = ribbonPositions.Length; + for (int i = 0; i < ribbonPositions.Length; i++) + { + float completionRatio = i / (float)positionCount; + float wave = MathF.Cos(MathHelper.Pi * completionRatio * 1.5f - MathHelper.TwoPi * Time / 97f) * completionRatio; + + Vector2 backwardsOffset = forwardDirection * i * -RibbonLength / positionCount; + Vector2 sideWavyOffset = sideDirection * wave * RibbonLength * 0.5f; + Vector2 rigidPosition = attachmentPoint + backwardsOffset + sideWavyOffset; + + ribbonPositions[i] = Vector2.Lerp(ribbonPositions[i], rigidPosition, 0.76f); + } + + Vector2 intersectionPosition = Vector2.Transform((Projectile.Center - Main.screenPosition) * 0.5f, Main.GameViewMatrix.TransformationMatrix); + MiscShaderData ribbonShader = GameShaders.Misc["CalamityMod:SylvestaffRibbon"]; + ribbonShader.UseShaderSpecificData(new Vector4(intersectionPosition.X, intersectionPosition.Y, sideDirection.X, sideDirection.Y)); + ribbonShader.UseSaturation(backLayer ? -1f : 1f); + + PrimitiveSettings primitiveSettings = new PrimitiveSettings(RibbonWidthFunction, RibbonColorFunction, pixelate: true, shader: ribbonShader); + PrimitiveRenderer.RenderTrail(ribbonPositions, primitiveSettings, 33); + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, direction, 0f); + return false; + } + + public override void OnKill(int timeLeft) + { + LeftRibbon?.Dispose(); + RightRibbon?.Dispose(); + } + + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Magic/TearsofHeavenProjectile.cs b/Projectiles/Magic/TearsofHeavenProjectile.cs index c3c2809d12..93bd301892 100644 --- a/Projectiles/Magic/TearsofHeavenProjectile.cs +++ b/Projectiles/Magic/TearsofHeavenProjectile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -62,7 +61,8 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(BuffID.OnFire3, 180); + target.AddBuff(BuffID.Frostburn2, 180); } } } diff --git a/Projectiles/Magic/TerraSigil.cs b/Projectiles/Magic/TerraSigil.cs new file mode 100644 index 0000000000..578d0d49f9 --- /dev/null +++ b/Projectiles/Magic/TerraSigil.cs @@ -0,0 +1,116 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Magic +{ + public class TerraSigil : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private bool spawnedProjectile = false; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 74; + Projectile.friendly = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)Projectile.ai[0]]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive && Projectile.ai[2] == 0) + { + Projectile.Kill(); + return; + } + + int i = (int)Projectile.ai[1]; + float dist = i % 3 == 0 ? 270f : 280f; + float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f); + + Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot); + Projectile.Center = sigilPos; + + if (Projectile.ai[2] > 0) + { + Projectile.localAI[0]++; + + if (Projectile.localAI[0] >= 35 && !spawnedProjectile) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastShoot") { Volume = 0.45f, PitchVariance = 0.1f }, Projectile.Center); + + Player owner = Main.player[Projectile.owner]; + Vector2 targetDirection = Projectile.Center.DirectionTo(Main.MouseWorld).SafeNormalize(Vector2.UnitX); + + spawnedProjectile = true; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, targetDirection * 32f, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); + } + + if (Projectile.localAI[0] >= 50) + { + Projectile.Kill(); + } + } + + else + { + Projectile.scale = parent.scale; + Projectile.rotation = 0; + Projectile.alpha = parent.alpha; + } + + if (parentActive) + { + Projectile.timeLeft = parent.timeLeft; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D blankTexture = ModContent.Request("CalamityMod/Projectiles/Magic/BlankSigil").Value; + + float finalScale = Projectile.scale; + float alphaOpacity = 1f - (Projectile.alpha / 255f); + float maskOpacity = 0f; + + // Apply animation effects if the fade-out is active + if (Projectile.ai[2] > 0) + { + float animationTime = Projectile.localAI[0]; + + if (animationTime <= 24) + { + maskOpacity = Utils.GetLerpValue(0f, 24f, animationTime, clamped: true); + } + else + { + maskOpacity = 1f; + } + + if (animationTime >= 35) + { + float scaleFactor = Utils.GetLerpValue(35f, 50f, animationTime, clamped: true); + finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor); + alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor); + } + } + + Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + + if (Projectile.ai[2] > 0) + { + Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/TerraSigil.png b/Projectiles/Magic/TerraSigil.png new file mode 100644 index 0000000000..ee77b62527 Binary files /dev/null and b/Projectiles/Magic/TerraSigil.png differ diff --git a/Projectiles/Magic/TerraSigilLargeRock.cs b/Projectiles/Magic/TerraSigilLargeRock.cs new file mode 100644 index 0000000000..63560b9844 --- /dev/null +++ b/Projectiles/Magic/TerraSigilLargeRock.cs @@ -0,0 +1,112 @@ +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class TerraSigilLargeRock : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public ref float Time => ref Projectile.ai[0]; + + public override void SetDefaults() + { + Projectile.width = 66; + Projectile.height = 64; + Projectile.friendly = true; + Projectile.penetrate = 1; +            Projectile.DamageType = DamageClass.Magic; + Projectile.timeLeft = 255; + Projectile.tileCollide = false; + } + + public override void AI() + { + Time++; + Projectile.rotation += 0.05f; + + if (Projectile.timeLeft > 247) + Projectile.scale *= 1.05f; + } + + public override bool PreDraw(ref Color lightColor) + { + // Normal sprite + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + + // All-white variant + Asset ghostTexture = ModContent.Request("CalamityMod/Projectiles/Magic/TerraSigilLargeRockGhost"); + + Color drawColor = Projectile.GetAlpha(lightColor); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame), drawColor, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + + // Only apply the glow effect during the first 8 frames + if (Time < 8) + { + // Fade from fully white to fully transparent + float fadeFactor = Utils.GetLerpValue(0, 8, Time, true); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive); + + Main.EntitySpriteDraw(ghostTexture.Value, Projectile.Center - Main.screenPosition, texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame), Color.White * (1 - fadeFactor), Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); + } + + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact with { Volume = 0.8f, Pitch = -0.4f + i * 0.25f, MaxInstances = 2 }, Projectile.Center); + + if (Projectile.owner == Main.myPlayer && Projectile.numHits > 0) + { + // Spawns 5 medium rock projectiles outward and evenly spaced + int numRocks = 5; + float spreadAngle = MathHelper.TwoPi / numRocks; + + for (int i = 0; i < numRocks; i++) + { + // Calc angle for each rock + float rotation = spreadAngle * i; + Vector2 launchVelocity = new Vector2(1f, 0f).RotatedBy(rotation) * 20f; + + // Spawn them. + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, launchVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + } + + + // Dust and smoke particles + for (int i = 0; i < 28; i++) + { + if (Main.rand.NextBool()) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? ModContent.DustType() : 262, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.85f, 1.25f); + dust.noGravity = true; + dust.fadeIn = 0.3f; + dust.velocity *= 2.2f; + dust.alpha = 100; + } + else + { + Color clr = Color.Lerp((Main.rand.NextBool() ? Color.Peru : Color.PeachPuff), Color.Black, Main.rand.NextFloat(0.25f, 0.45f)); + Particle sand = new CustomSpark(Projectile.Center, (Vector2.One * Main.rand.NextFloat(3, 8)).RotatedByRandom(MathHelper.TwoPi), "CalamityMod/Particles/SmallSmoke", true, Main.rand.Next(15, 30 + 1), Projectile.scale * Main.rand.NextFloat(0.05f, 0.1f) * 4, clr, new Vector2(1, Main.rand.NextFloat(0.2f, 1f)), false, extraRotation: Main.rand.NextFloat(-2, 2), spin: Main.rand.NextFloat(-0.5f, 0.5f), affectedByLight: true); + GeneralParticleHandler.SpawnParticle(sand); + } + } + } + } +} diff --git a/Projectiles/Magic/TerraSigilLargeRock.png b/Projectiles/Magic/TerraSigilLargeRock.png new file mode 100644 index 0000000000..899422376e Binary files /dev/null and b/Projectiles/Magic/TerraSigilLargeRock.png differ diff --git a/Projectiles/Magic/TerraSigilLargeRockGhost.png b/Projectiles/Magic/TerraSigilLargeRockGhost.png new file mode 100644 index 0000000000..804d9cca51 Binary files /dev/null and b/Projectiles/Magic/TerraSigilLargeRockGhost.png differ diff --git a/Projectiles/Magic/TerraSigilMediumRock.cs b/Projectiles/Magic/TerraSigilMediumRock.cs new file mode 100644 index 0000000000..0d32e3110c --- /dev/null +++ b/Projectiles/Magic/TerraSigilMediumRock.cs @@ -0,0 +1,123 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using CalamityMod.Particles; +using Terraria.Audio; +using CalamityMod.Dusts; + +namespace CalamityMod.Projectiles.Magic +{ + public class TerraSigilMediumRock : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public ref float Time => ref Projectile.ai[0]; + public bool goToCursor = false; + public Vector2 mousePos; + public float CenterX; + public float CenterY; + + public override void SetDefaults() + { + Projectile.width = 40; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.tileCollide = false; + Projectile.penetrate = 1; + Projectile.timeLeft = 75; + Projectile.extraUpdates = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + if (Time < 69) + Projectile.friendly = false; + else + Projectile.friendly = true; + + if (Time == 0) + { + Projectile.scale = 0.5f; + } + + // If not moving to cursor, slow down + if (!goToCursor) + { + Projectile.velocity *= 0.96f; + } + + if (Time < 11) + Projectile.scale *= 1.08f; + + // After 1 second, rapidly move to cursor + if (Time == 60) + { + Projectile.velocity = Vector2.Zero; + mousePos = Main.player[Projectile.owner].ClampedMouseWorld(); + goToCursor = true; + } + + if (goToCursor) + { + if (Time == 60) + { + CenterX = Projectile.Center.X; + CenterY = Projectile.Center.Y; + } + if (Time > 60) + Projectile.Center = new Vector2(MathHelper.Lerp(CenterX, mousePos.X, Utils.GetLerpValue(60, 73, Time, true)), MathHelper.Lerp(CenterY, mousePos.Y, Utils.GetLerpValue(60, 73, Time, true))); + } + + Projectile.rotation += 0.05f; + Time++; + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/Ravager/RavagerJump2") { Volume = 0.7f, PitchVariance = 0.1f }, Projectile.Center); + + int rockCount = Main.rand.Next(1, 3); + for (int i = 0; i < rockCount; i++) + { + Vector2 randomVelocity = new Vector2(Main.rand.NextFloat(-10f, 10f), Main.rand.NextFloat(-3f, -10f)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randomVelocity, ModContent.ProjectileType(), 0, 0, Projectile.owner); + } + + // Dust and smoke particles + for (int i = 0; i < 14; i++) + { + if (Main.rand.NextBool(3)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? ModContent.DustType() : 262, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f)); // Reduced velocity + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.6f, 1f); + if (dust.type == 262) + { + dust.noGravity = true; + dust.fadeIn = 0.3f; + dust.velocity *= 1.5f; + } + dust.alpha = 100; + } + else + { + Color clr = Color.Lerp((Main.rand.NextBool() ? Color.Peru : Color.PeachPuff), Color.Black, Main.rand.NextFloat(0.25f, 0.45f)); + Particle sand = new CustomSpark(Projectile.Center, (Vector2.One * Main.rand.NextFloat(3, 8)).RotatedByRandom(MathHelper.TwoPi), "CalamityMod/Particles/SmallSmoke", true, Main.rand.Next(15, 30 + 1), Projectile.scale * Main.rand.NextFloat(0.05f, 0.1f) * 4, clr, new Vector2(1, Main.rand.NextFloat(0.2f, 1f)), false, extraRotation: Main.rand.NextFloat(-2, 2), spin: Main.rand.NextFloat(-0.5f, 0.5f), affectedByLight: true); + GeneralParticleHandler.SpawnParticle(sand); + } + } + + for (int i = 0; i < 3; i++) + { + Vector2 randVel = new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 1f); // Reduced velocity + Particle smoke = new HeavySmokeParticle(Projectile.Center + randVel, randVel, Color.Peru, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(0.6f, 1.5f), 0.3f); // Reduced duration and scale + GeneralParticleHandler.SpawnParticle(smoke); + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center, randVel * 0.5f, Color.SandyBrown, Color.Beige, Main.rand.NextFloat(0.2f, 0.8f), 80f, Main.rand.NextFloat(0.02f, -0.02f)); // Reduced duration and scale + GeneralParticleHandler.SpawnParticle(SandCloud); + } + } + } +} diff --git a/Projectiles/Magic/TerraSigilMediumRock.png b/Projectiles/Magic/TerraSigilMediumRock.png new file mode 100644 index 0000000000..375d568a98 Binary files /dev/null and b/Projectiles/Magic/TerraSigilMediumRock.png differ diff --git a/Projectiles/Magic/TerraSigilSmallRock.cs b/Projectiles/Magic/TerraSigilSmallRock.cs new file mode 100644 index 0000000000..73393766fb --- /dev/null +++ b/Projectiles/Magic/TerraSigilSmallRock.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class TerraSigilSmallRock : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 26; + Projectile.height = 32; + Projectile.friendly = false; // VFX + Projectile.damage = 0; // This is VFX + Projectile.hostile = false; + Projectile.tileCollide = true; + Projectile.timeLeft = 100; + Projectile.scale *= 0.6f; + } + + public override void AI() + { + // Set the frame to be randomly chosen on spawn + if (Projectile.ai[0] == 0) + { + Projectile.frame = Main.rand.Next(Main.projFrames[Type]); + Projectile.ai[0] = 1; + } + + // Gravity! + Projectile.velocity.Y = Projectile.velocity.Y + 0.45f; + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + } +} diff --git a/Projectiles/Magic/TerraSigilSmallRock.png b/Projectiles/Magic/TerraSigilSmallRock.png new file mode 100644 index 0000000000..0f13993661 Binary files /dev/null and b/Projectiles/Magic/TerraSigilSmallRock.png differ diff --git a/Projectiles/Magic/Teslabeam.cs b/Projectiles/Magic/Teslabeam.cs index c01869a4b3..406697d659 100644 --- a/Projectiles/Magic/Teslabeam.cs +++ b/Projectiles/Magic/Teslabeam.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -15,6 +16,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class Teslabeam : BaseLaserbeamProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -99,7 +101,7 @@ namespace CalamityMod.Projectiles.Magic return false; } // Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore - if (Owner.miscCounter % 10 == 0 && !Owner.CheckMana(Owner.ActiveItem(), -1, true)) + if (Owner.miscCounter % 10 == 0 && !Owner.CheckMana(Owner.HeldItem, -1, true)) { Projectile.Kill(); return false; @@ -131,19 +133,19 @@ namespace CalamityMod.Projectiles.Magic return true; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return MathHelper.Clamp(completionRatio * 15, 1, 1.5f); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { return new Color(174, 227, 244); // directly color picked from the source material } - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; + internal float BackgroundWidthFunction(float completionRatio, Vector2 vertexPos) => WidthFunction(completionRatio, vertexPos) * 4f; - internal Color BackgroundColorFunction(float completionRatio) + internal Color BackgroundColorFunction(float completionRatio, Vector2 vertexPos) { return new Color(92, 144, 245) * 0.6f; // directly color picked from the source material } diff --git a/Projectiles/Magic/ThaumRingSmall.png b/Projectiles/Magic/ThaumRingSmall.png new file mode 100644 index 0000000000..2af46bf05c Binary files /dev/null and b/Projectiles/Magic/ThaumRingSmall.png differ diff --git a/Projectiles/Magic/ThaumRune.png b/Projectiles/Magic/ThaumRune.png new file mode 100644 index 0000000000..ae351cbc86 Binary files /dev/null and b/Projectiles/Magic/ThaumRune.png differ diff --git a/Projectiles/Magic/ThaumRuneGhost.png b/Projectiles/Magic/ThaumRuneGhost.png new file mode 100644 index 0000000000..73cc8078af Binary files /dev/null and b/Projectiles/Magic/ThaumRuneGhost.png differ diff --git a/Projectiles/Magic/ThunderboltOrb.cs b/Projectiles/Magic/ThunderboltOrb.cs deleted file mode 100644 index d87f7d9bca..0000000000 --- a/Projectiles/Magic/ThunderboltOrb.cs +++ /dev/null @@ -1,158 +0,0 @@ -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using System; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; -using static CalamityMod.CalamityUtils; - -namespace CalamityMod.Projectiles.Magic -{ - public class VolterionOrb : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - - public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/VolterionOrbShot") { Volume = 0.6f }; - public static readonly SoundStyle ExplosionSound = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact") { Volume = 0.5f }; - - // Explosion - public static float ExplosionTime = 150f; // Time taken to explode - public static float ExplosionLifetime = 18f; - public static float MaxScale = 7.5f; - - // Lightning - public static float AttackRate = 60f; - public static float AttackRange = 800f; - public static float LightningDamageMult = 0.25f; - - public ref float OrbType => ref Projectile.ai[0]; - public ref float AttackTimer => ref Projectile.ai[1]; - public ref float ExplosionTimer => ref Projectile.ai[2]; - - public Player Owner => Main.player[Projectile.owner]; - - public static Asset Bloom; - public static Asset Explosion; - public override void Load() - { - Bloom = ModContent.Request("CalamityMod/Particles/BloomCircle"); - Explosion = ModContent.Request("CalamityMod/Particles/PlasmaExplosion"); - } - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 5; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 38; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Magic; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - Projectile.frameCounter++; - Projectile.frame = Projectile.frameCounter / 4 % Main.projFrames[Type]; - - Projectile.velocity *= 0.8f; - Projectile.rotation += 0.01f; - Lighting.AddLight(Projectile.Center, GetColor(OrbType).ToVector3()); - - // Each orb fires at a slightly different timing from the previous - AttackTimer++; - float offset = 9f * OrbType; - if (AttackTimer > AttackRate * 2f) - { - // Explode - if (AttackTimer > ExplosionTime) - { - if (ExplosionTimer == 0f) - SoundEngine.PlaySound(ExplosionSound, Projectile.Center); - - float scaleLevel = PiecewiseAnimation(ExplosionTimer / ExplosionLifetime, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); - Projectile.scale = MathHelper.Lerp(1f, MaxScale, scaleLevel); - Projectile.Opacity = MathF.Sin(MathHelper.PiOver2 + MathHelper.PiOver2 * ExplosionTimer / ExplosionLifetime); - - if (ExplosionTimer++ > ExplosionLifetime) - Projectile.Kill(); - } - // Builds up dust readying up to explode - else if (AttackTimer > MathHelper.Lerp(AttackRate * 2f, ExplosionTime, 0.8f) || AttackTimer % 3 == 2) - { - Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f)); - Dust spark = Dust.NewDustPerfect(Projectile.Center, 278, velocity); - spark.noLight = true; - spark.noGravity = Main.rand.NextBool(); - spark.color = GetColor(OrbType); - } - } - else if (AttackTimer % AttackRate == (AttackRate - offset - 1f)) - { - // Orbs should be extremely slow by the time they fire already but make sure it's not moving to keep the visuals right - Projectile.velocity *= 0f; - - NPC target = Projectile.Center.ClosestNPCAt(AttackRange); - if (target != null) - { - SoundEngine.PlaySound(FireSound, Projectile.Center); - - Vector2 velocity = Projectile.SafeDirectionTo(target.Center) * 16f; - Projectile shot = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * LightningDamageMult), Projectile.knockBack * LightningDamageMult, Projectile.owner, OrbType + 1f); - shot.tileCollide = false; - - // Create a lightning bolt-like particle in the direction of the shot and 3 random hue-shifted ones by the side - Particle bolt = new CrackParticle(Projectile.Center, velocity * 0.5f, GetColor(OrbType), Vector2.One, 0, 0, Main.rand.NextFloat(0.8f, 1f), 12); - GeneralParticleHandler.SpawnParticle(bolt); - - for (int i = 1; i < 4; i++) - { - Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, GetColor(4f - OrbType) * 0.6f, Vector2.One, 0, 0, Main.rand.NextFloat(0.5f, 0.6f), 12); - GeneralParticleHandler.SpawnParticle(bolt2); - } - } - } - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Electrified, 120); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Electrified, 120); - - public static Color GetColor(float type) => Color.Lerp(new Color(51, 197, 255), new Color(143, 51, 255), 0.2f + 0.15f * type + 0.2f * MathF.Sin(Main.GlobalTimeWrappedHourly * 10f)); - - public override Color? GetAlpha(Color lightColor) => GetColor(OrbType); - - public override bool PreDraw(ref Color lightColor) - { - Vector2 drawPos = Projectile.Center - Main.screenPosition; - Color color = Projectile.GetAlpha(lightColor); - - if (ExplosionTimer > 0f) - { - Main.spriteBatch.EnterShaderRegion(BlendState.Additive); - Texture2D explosionTex = Explosion.Value; - Main.EntitySpriteDraw(explosionTex, drawPos, null, color * Projectile.Opacity, Projectile.rotation, explosionTex.Size() * 0.5f, 0.02f * Projectile.scale, SpriteEffects.None); - Main.spriteBatch.ExitShaderRegion(); - return false; - } - - Main.spriteBatch.EnterShaderRegion(BlendState.Additive); - Texture2D bloomTex = Bloom.Value; - Main.EntitySpriteDraw(bloomTex, drawPos, null, color * 0.5f, 0, bloomTex.Size() * 0.5f, 0.42f, SpriteEffects.None); - Main.spriteBatch.ExitShaderRegion(); - return true; - } - - public override bool? CanDamage() => ExplosionTimer > 0f ? base.CanDamage() : false; - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CircularHitboxCollision(Projectile.Center, 20 * Projectile.scale, targetHitbox); - } -} diff --git a/Projectiles/Magic/ThunderboltShot.cs b/Projectiles/Magic/ThunderboltShot.cs deleted file mode 100644 index 986c67b904..0000000000 --- a/Projectiles/Magic/ThunderboltShot.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Graphics.Primitives; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Magic -{ - public class VolterionShot : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Magic"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - // Due to how far/fast this thing moves, it'd require way too many points for a smooth long trail using oldPos - public List TrailPos = new List(); - public const int TrailLength = 50; - - public ref float OrbType => ref Projectile.ai[0]; - - public override void SetStaticDefaults() => ProjectileID.Sets.DrawScreenCheckFluff[Type] = 5000; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 20; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Magic; - Projectile.MaxUpdates = 15; - Projectile.timeLeft = 24 * Projectile.MaxUpdates; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation(); - - if (Projectile.numHits > 0) - { - Projectile.scale -= 0.005f; - Projectile.Opacity -= 0.005f; - if (Projectile.Opacity <= 0f) - Projectile.Kill(); - } - else - { - // Update a bit more frequently than the update count for better point distribution - if (Projectile.FinalExtraUpdate() || Projectile.numUpdates % 3 == 2 || TrailPos == null) - { - // Initialize 15 points immediately - if (TrailPos == null) - { - TrailPos = new List(15); - for (int i = 0; i < 15; ++i) - TrailPos.Add(Projectile.Center); - } - - // Add some random value for the natural lightning look - Vector2 randOffset = (Vector2.UnitY * Main.rand.NextFloat(-24f, 24f)).RotatedBy(Projectile.rotation); - TrailPos.Insert(0, Projectile.Center + randOffset); - - while (TrailPos.Count > TrailLength) - TrailPos.RemoveAt(TrailPos.Count - 1); - } - - // Randomly spawn glowing bolts outwards - if (Main.rand.NextBool(6)) - { - BoltParticle bolt = new BoltParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(36f)), false, 10, 0.3f, TrailColorFunction(0f), Vector2.One, true); - GeneralParticleHandler.SpawnParticle(bolt); - } - - if (Projectile.timeLeft < 50) // Starts exploding and fading by itself if it never hits anything - Decay(); - } - } - - public override bool? CanDamage() => Projectile.numHits == 0 ? null : false; - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.Electrified, 60); - if (Projectile.numHits == 0) - Decay(); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (Projectile.numHits == 0) - Decay(); - return false; - } - - public void Decay() - { - Projectile.numHits++; // Ensure this can only happen once - Projectile.timeLeft = 200; - Projectile.velocity = Vector2.Zero; - Projectile.netUpdate = true; - - // Final position update - TrailPos.Insert(0, Projectile.Center); - - while (TrailPos.Count > TrailLength) - TrailPos.RemoveAt(TrailPos.Count - 1); - - bool secondary = OrbType > 0f; - if (Projectile.owner == Main.myPlayer && !secondary) - { - float rotOffset = Main.rand.NextFloat(0f, MathHelper.TwoPi); - for (int i = 0; i < 5; i++) - { - Vector2 velocity = Vector2.UnitX.RotatedBy(rotOffset + MathHelper.TwoPi * 0.2f * (i + Main.rand.NextFloat(-0.4f, 0.4f))) * (Main.rand.NextFloat(40f, 45f)); - Projectile orb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, i); - orb.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); - } - } - - int boltCount = secondary ? 6 : 10; - for (int i = 0; i < boltCount; i++) - { - Color color = OrbType > 0f ? VolterionOrb.GetColor(OrbType - 1f) : (Main.rand.NextBool() ? Color.Cyan : Color.Orchid); - Vector2 velocity = Vector2.UnitX.RotatedBy(MathHelper.TwoPi * 0.2f * (i + Main.rand.NextFloat(-0.4f, 0.4f))) * (Main.rand.NextFloat(12f, 15f)); - BoltParticle bolt = new BoltParticle(Projectile.Center, velocity, false, 18, Main.rand.NextFloat(0.4f, 0.6f), color, new Vector2(0.6f, 1f), true); - GeneralParticleHandler.SpawnParticle(bolt); - } - for (int k = 0; k < 7; k++) - { - Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 14f)); - Dust spark = Dust.NewDustPerfect(Projectile.Center, 278, velocity); - spark.noLight = true; - spark.color = Main.rand.NextBool() ? Color.Cyan : Color.Orchid; - } - } - - internal float TrailWidthFunction(float completionRatio) => Projectile.scale * 15f * Utils.GetLerpValue(0.5f, 0.4f, MathF.Abs(0.5f - completionRatio), true); - internal Color TrailColorFunction(float completionRatio) => OrbType > 0f ? VolterionOrb.GetColor(OrbType - 1f) : Color.Lerp(new Color(51, 197, 255), new Color(143, 51, 255), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 20f)) * Projectile.Opacity; - - public override bool PreDraw(ref Color lightColor) - { - if (TrailPos == null) - return false; - - GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply(); - PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction, smoothen: false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), TrailLength); - return false; - } - } -} diff --git a/Projectiles/Magic/TradewindsProjectile.cs b/Projectiles/Magic/TradewindsProjectile.cs index ba0a63c9e0..5d30d7731f 100644 --- a/Projectiles/Magic/TradewindsProjectile.cs +++ b/Projectiles/Magic/TradewindsProjectile.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/TridentIcicle.cs b/Projectiles/Magic/TridentIcicle.cs index 4fc8c59b59..383b158822 100644 --- a/Projectiles/Magic/TridentIcicle.cs +++ b/Projectiles/Magic/TridentIcicle.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Magic/UberBubble.cs b/Projectiles/Magic/UberBubble.cs index 3bd8f7fb9c..157be894aa 100644 --- a/Projectiles/Magic/UberBubble.cs +++ b/Projectiles/Magic/UberBubble.cs @@ -1,10 +1,11 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Particles; -using CalamityMod.Dusts; + namespace CalamityMod.Projectiles.Magic { public class UberBubble : ModProjectile, ILocalizedModType @@ -22,6 +23,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Magic; Projectile.timeLeft = 30; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -61,7 +64,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item96, Projectile.Center); + SoundEngine.PlaySound(Effervescence.BurstSound, Projectile.Center); Particle Star = new GenericSparkle(Projectile.Center, Vector2.Zero, Color.Purple, Color.PeachPuff, Main.rand.NextFloat(0.5f, 0.6f), 30, 0.1f, 3f); GeneralParticleHandler.SpawnParticle(Star); Star = new GenericSparkle(Projectile.Center + Projectile.velocity, Vector2.Zero, Color.MediumPurple, Color.LightPink, Main.rand.NextFloat(0.5f, 0.6f), 20, 0.1f, 3f); @@ -78,7 +81,7 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.owner == Main.myPlayer) { for (int numBubbles = 0; numBubbles < 3; numBubbles++) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Projectile.velocity.X * (Main.rand.NextFloat() * 2f), Projectile.velocity.Y * (Main.rand.NextFloat() * 2f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.5f, 2f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } } } diff --git a/Projectiles/Magic/UnstableCastersGauntletHoldout.cs b/Projectiles/Magic/UnstableCastersGauntletHoldout.cs new file mode 100644 index 0000000000..5c2a940d07 --- /dev/null +++ b/Projectiles/Magic/UnstableCastersGauntletHoldout.cs @@ -0,0 +1,296 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class UnstableCastersGauntletHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float shootingTimer => ref Projectile.ai[0]; + + private float currentRecoilRotation; + private float RecoilRotationAmount = 0.24f; + private float RotationResolveSpeed = 0.24f; + + // Normal weapon usetime is 20. This is used throughout the AI to make the holdout's components scale with attack speed. + public float speedModifier => HeldItem.useTime / 20f; + + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.friendly = true; + Projectile.hostile = false; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Magic; + Projectile.ownerHitCheck = true; + } + + public override void HoldoutAI() + { + CalamityPlayer calPlayer = Owner.Calamity(); + + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.None, 0f); + + // -- SIGIL M1 ATTACKS -- + if (Owner.ownedProjectileCounts[ModContent.ProjectileType()] == 1 && Owner.altFunctionUse == 0) + { + float sigilFireRate = HeldItem.useTime * 4f; + + if (shootingTimer >= sigilFireRate) + { + // Find all active sigils + var activeSigils = new List(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.active && proj.owner == Projectile.owner) + { + if (proj.type == ModContent.ProjectileType() || + proj.type == ModContent.ProjectileType() || + proj.type == ModContent.ProjectileType() || + proj.type == ModContent.ProjectileType() || + proj.type == ModContent.ProjectileType() || + proj.type == ModContent.ProjectileType() || + proj.type == ModContent.ProjectileType()) + { + // Make sure sigil isn't already consumed + if (proj.ai[2] <= 0) + { + activeSigils.Add(proj); + } + } + } + } + + // If there are active sigils, select a random one and start the consuming anim + if (activeSigils.Count > 0) + { + int randomIndex = Main.rand.Next(activeSigils.Count); + Projectile chosenSigil = activeSigils[randomIndex]; + + // Start fadeout + chosenSigil.ai[2] = 1.0f; + + // Less delay than normal + if (chosenSigil.type == ModContent.ProjectileType()) + shootingTimer = (HeldItem.useTime * 1.65f); + else + shootingTimer = 0f; + + } + } + + // Particle/dust channeling VFX + if (Owner.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + Projectile sigilParent = null; + int sigilType = ModContent.ProjectileType(); + + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == sigilType && p.owner == Projectile.owner) + { + sigilParent = p; + break; + } + } + + if (sigilParent != null) + { + Vector2 randomSpawnOffset = Main.rand.NextVector2Circular(90f, 90f); + Vector2 dustSpawnPosition = GunTipPosition + randomSpawnOffset; + + Vector2 inwardVelocity = (GunTipPosition - dustSpawnPosition).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(7f, 10f); + Dust dust = Dust.NewDustPerfect(dustSpawnPosition, ModContent.DustType(), inwardVelocity, 0, Color.DarkMagenta, 1.2f); + dust.noGravity = true; + dust.velocity *= 0.5f; + dust.fadeIn = 0.5f; + dust.scale *= 0.4f; + + Lighting.AddLight(GunTipPosition, 0.4f * Color.DarkMagenta.ToVector3()); + } + } + } + + + // -- NEEDLES -- + else if (Owner.altFunctionUse == 0) + { + int needleFireRate = (int)(12 * speedModifier); + if (shootingTimer >= needleFireRate) + { + if (calPlayer.unstableCastersGauntletVis >= 0.6f) + { + // Consume vis + calPlayer.unstableCastersGauntletVis -= 0.6f; + + Projectile.velocity *= Main.rand.NextFloat(0.97f, 1.04f); + + currentRecoilRotation -= RecoilRotationAmount; + + // SFX + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/VisNeedleFire") { Volume = 0.4f, PitchVariance = 0.15f }, Projectile.Center); + + // Pulse VFX + Particle shootPulse = new DirectionalPulseRing(GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5f, Color.DarkMagenta * 4f, new Vector2(0.4f, 0.8f), Projectile.velocity.ToRotation(), 0.07f, 0.3f, 16); + GeneralParticleHandler.SpawnParticle(shootPulse); + + // Spawn needle + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity * 35f).RotatedBy(Main.rand.NextFloat(-0.07f, 0.07f)), ModContent.ProjectileType(), (int) (Projectile.damage * 0.8f), Projectile.knockBack, Projectile.owner); + shootingTimer = 0f; + } + else + { + // Cull if there isnt enough vis + Projectile.Kill(); + } + } + } + + + // -- SIGIL SPAWNING -- + if (Owner.altFunctionUse == 2 && calPlayer.unstableCastersGauntletVis >= 12f && Owner.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + { + float sigilFireRate = HeldItem.useTime * 4f; + + if (Owner.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 || shootingTimer >= sigilFireRate) + { + calPlayer.unstableCastersGauntletVis -= 12f; + + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MagicRockSound") { Volume = 0.4f, PitchVariance = 0.05f }, Projectile.Center); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + shootingTimer = 0f; + } + } + + // Warp Sigil Spawning + else if (Owner.altFunctionUse == 2 && Owner.ownedProjectileCounts[ModContent.ProjectileType()] == 1) + { + int parentType = ModContent.ProjectileType(); + Projectile thisParent = null; + + // Find parent + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == parentType && p.owner == Projectile.owner) + { + thisParent = p; + break; + } + } + + if (thisParent != null) + { + + int maxSigils = 6; + bool[] slotIsOccupied = new bool[maxSigils]; + int nonConsumedSigils = 0; + + int[] sigilVariants = new int[] + { + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() + }; + + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + // Check if projectile is active, belongs to this player, and is a child of this SigilSet + if (proj.active && proj.owner == Projectile.owner && proj.ai[0] == thisParent.identity) + { + // Check if it's a type of sigil + bool isASigil = false; + foreach (int sigilType in sigilVariants) + { + if (proj.type == sigilType) + { + isASigil = true; + break; + } + } + + if (isASigil) + { + // Use the sigil's index to mark as occupied + int sigilIndex = (int)proj.ai[1]; + if (sigilIndex >= 0 && sigilIndex < maxSigils) + { + slotIsOccupied[sigilIndex] = true; + } + + if (proj.ai[2] <= 0) + { + nonConsumedSigils++; + } + } + } + } + + List availableIndices = new List(); + + for (int i = 0; i < maxSigils; i++) + { + if (!slotIsOccupied[i]) + { + availableIndices.Add(i); + } + } + + int emptySlots = availableIndices.Count; + + if (emptySlots > 0 && nonConsumedSigils > 0) + { + // Check if the player has enough vis + if (calPlayer.unstableCastersGauntletVis >= 12f) + { + calPlayer.unstableCastersGauntletVis -= 12f; + + SoundEngine.PlaySound(SoundID.DD2_EtherianPortalOpen with { Volume = 0.6f }, Projectile.Center); + + // Spawn Warp Sigils for each empty slot + if (Main.myPlayer == Projectile.owner) + { + foreach (int sigilIndex in availableIndices) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), thisParent.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, thisParent.identity, sigilIndex); + } + } + + shootingTimer = 0f; + } + } + } + } + + // -- RECOIL -- + ExtraFrontArmRotation = currentRecoilRotation; + + // Resolve + if (currentRecoilRotation != 0f) + currentRecoilRotation = MathHelper.Lerp(currentRecoilRotation, 0f, RotationResolveSpeed); + + + shootingTimer++; + } + } +} diff --git a/Projectiles/Magic/ValkyrieRayBeam.cs b/Projectiles/Magic/ValkyrieRayBeam.cs index d1f2164ad8..f028615069 100644 --- a/Projectiles/Magic/ValkyrieRayBeam.cs +++ b/Projectiles/Magic/ValkyrieRayBeam.cs @@ -6,7 +6,6 @@ using Terraria; using Terraria.Enums; using Terraria.GameContent.Shaders; using Terraria.Graphics.Effects; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -47,7 +46,7 @@ namespace CalamityMod.Projectiles.Magic // The beam itself still stops on tiles, but its invisible "source" projectile ignores them. Projectile.tileCollide = false; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 4; + Projectile.localNPCHitCooldown = -1; // The beam lasts for only some frames and fades out over that time. Projectile.timeLeft = Lifetime; diff --git a/Projectiles/Magic/ValkyrieRayStaff.cs b/Projectiles/Magic/ValkyrieRayStaff.cs index 0fa15fb048..64143f3e25 100644 --- a/Projectiles/Magic/ValkyrieRayStaff.cs +++ b/Projectiles/Magic/ValkyrieRayStaff.cs @@ -35,9 +35,9 @@ namespace CalamityMod.Projectiles.Magic // Calculate how quickly the staff should charge. Charge increases by some number close to 1 every frame. // Speed increasing reforges make this number greater than 1. Slowing reforges make it smaller than 1. if (Projectile.localAI[0] == 0f) - Projectile.localAI[0] = 47f / player.ActiveItem().useTime; + Projectile.localAI[0] = (ValkyrieRay.ChargeFrames + ValkyrieRay.CooldownFrames) / player.HeldItem.useTime; - // Increment the timer for the staff. If the timer has passed 47, destroy it. + // Increment the timer for the staff. If the timer has passed the total time, destroy it. Projectile.ai[0] += Projectile.localAI[0]; int maxTime = ValkyrieRay.ChargeFrames + ValkyrieRay.CooldownFrames; if (Projectile.ai[0] > maxTime) @@ -127,8 +127,8 @@ namespace CalamityMod.Projectiles.Magic private void FiringEffects(Vector2 center) { - SoundEngine.PlaySound(SoundID.Item28, center); - SoundEngine.PlaySound(SoundID.Item60, center); + SoundEngine.PlaySound(SoundID.Item28 with { Volume = 0.7f }, center); + SoundEngine.PlaySound(SoundID.Item60 with { Volume = 0.7f }, center); int numDust = 36; int dustID = 73; for (int i = 0; i < numDust; ++i) diff --git a/Projectiles/Magic/VeeringWindAirWave.cs b/Projectiles/Magic/VeeringWindAirWave.cs index 654b6a8349..f314d7a737 100644 --- a/Projectiles/Magic/VeeringWindAirWave.cs +++ b/Projectiles/Magic/VeeringWindAirWave.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Magic/VeeringWindFrostWave.cs b/Projectiles/Magic/VeeringWindFrostWave.cs index 4716b8c50c..5a0b2b5596 100644 --- a/Projectiles/Magic/VeeringWindFrostWave.cs +++ b/Projectiles/Magic/VeeringWindFrostWave.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Magic/VehemenceBolt.cs b/Projectiles/Magic/VehemenceBolt.cs index ea3f439cc1..88c5d24e18 100644 --- a/Projectiles/Magic/VehemenceBolt.cs +++ b/Projectiles/Magic/VehemenceBolt.cs @@ -1,10 +1,9 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -32,9 +31,12 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; } - public override void AI() + public override void OnSpawn(IEntitySource source) { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + public override void AI() + { Lighting.AddLight(Projectile.Center, Color.DarkRed.ToVector3()); if (Time == 0f) @@ -53,7 +55,7 @@ namespace CalamityMod.Projectiles.Magic { float angle = MathHelper.TwoPi * i / 40f; - Dust brimstoneMagic = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 7f, 27); + Dust brimstoneMagic = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 7f, DustID.Shadowflame); brimstoneMagic.velocity = angle.ToRotationVector2() * 15f; brimstoneMagic.color = Color.Lerp(Color.Red, Color.MediumPurple, (float)Math.Sin(angle) * 0.5f + 0.5f); brimstoneMagic.scale = 1.6f; diff --git a/Projectiles/Magic/VehemenceHoldout.cs b/Projectiles/Magic/VehemenceHoldout.cs index 6fc8bd8129..d37556252e 100644 --- a/Projectiles/Magic/VehemenceHoldout.cs +++ b/Projectiles/Magic/VehemenceHoldout.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.friendly = false; Projectile.tileCollide = false; Projectile.ignoreWater = true; - Projectile.timeLeft = 91; + Projectile.timeLeft = 300; } public override void AI() @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Magic if (Main.myPlayer != Projectile.owner) return; - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; Vector2 shootVelocity = Projectile.velocity * heldItem.shootSpeed; int damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shootVelocity, ModContent.ProjectileType(), damage, heldItem.knockBack, Projectile.owner); diff --git a/Projectiles/Magic/VehemenceSkull.cs b/Projectiles/Magic/VehemenceSkull.cs index 2a4cf2e042..9ad1126416 100644 --- a/Projectiles/Magic/VehemenceSkull.cs +++ b/Projectiles/Magic/VehemenceSkull.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Magic/VenusianBolt.cs b/Projectiles/Magic/VenusianBolt.cs index 4c5d14a937..7e270ed227 100644 --- a/Projectiles/Magic/VenusianBolt.cs +++ b/Projectiles/Magic/VenusianBolt.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -48,7 +47,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i < 12; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); chargefull.velocity = Projectile.velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(0.1f, 1); chargefull.scale = Main.rand.NextFloat(0.45f, 0.8f); chargefull.noGravity = true; @@ -81,10 +80,9 @@ namespace CalamityMod.Projectiles.Magic public override void OnKill(int timeLeft) { - Player Owner = Main.player[Projectile.owner]; - if (Projectile.owner == Main.myPlayer && explode) + if (explode) { - Owner.Calamity().GeneralScreenShakePower = 3.5f; + Main.player[Projectile.owner].SetScreenshake(3.5f); SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Volume = 1f, Pitch = -0.5f }, Projectile.Center); SoundEngine.PlaySound(SoundID.Item74 with { Volume = 0.7f, Pitch = 1f }, Projectile.Center); for (int i = 0; i < 6; i++) @@ -99,35 +97,37 @@ namespace CalamityMod.Projectiles.Magic Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 1.5f, 25, true); GeneralParticleHandler.SpawnParticle(blastRing2); } - - int explosionDamage = Projectile.damage / 4; - float explosionKB = 6f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), explosionDamage, explosionKB, Projectile.owner); - - int cinderDamage = (int)(Projectile.damage * 0.02); - float cinderKB = 0f; - Vector2 cinderPos = Projectile.Center; - int numCinders = 10; - for (int i = 0; i < numCinders; i++) - { - Vector2 cinderVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - while (cinderVel.X == 0f && cinderVel.Y == 0f) - { - cinderVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - } - cinderVel.Normalize(); - cinderVel *= Main.rand.Next(70, 101) * 0.1f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), cinderPos, cinderVel + new Vector2(0, -3), ModContent.ProjectileType(), cinderDamage, cinderKB, Projectile.owner); - } - for (int i = 0; i < 20; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); chargefull.velocity = new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 2f); chargefull.scale = Main.rand.NextFloat(0.65f, 1.25f); chargefull.noGravity = true; chargefull.color = Color.Lerp(Color.White, Main.rand.NextBool(4) ? Color.Orange : Color.Coral, 0.7f); } + + if (Main.myPlayer == Projectile.owner) + { + int explosionDamage = Projectile.damage / 4; + float explosionKB = 6f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), explosionDamage, explosionKB, Projectile.owner); + + int cinderDamage = (int)(Projectile.damage * 0.02); + float cinderKB = 0f; + Vector2 cinderPos = Projectile.Center; + int numCinders = 10; + for (int i = 0; i < numCinders; i++) + { + Vector2 cinderVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + while (cinderVel.X == 0f && cinderVel.Y == 0f) + { + cinderVel = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + } + cinderVel.Normalize(); + cinderVel *= Main.rand.Next(70, 101) * 0.1f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), cinderPos, cinderVel + new Vector2(0, -3), ModContent.ProjectileType(), cinderDamage, cinderKB, Projectile.owner); + } + } } } diff --git a/Projectiles/Magic/VenusianExplosion.cs b/Projectiles/Magic/VenusianExplosion.cs index 6fdb7c87b8..131d9f4eb6 100644 --- a/Projectiles/Magic/VenusianExplosion.cs +++ b/Projectiles/Magic/VenusianExplosion.cs @@ -1,7 +1,5 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Magic/VenusianFlame.cs b/Projectiles/Magic/VenusianFlame.cs index 6d87b5c89c..aa35c8b73d 100644 --- a/Projectiles/Magic/VenusianFlame.cs +++ b/Projectiles/Magic/VenusianFlame.cs @@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Magic } if (Main.rand.NextBool(14)) { - int venusDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 278, 0f, 0f, 0, default, Main.rand.NextFloat(0.3f, 0.5f)); + int venusDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.FireworksRGB, 0f, 0f, 0, default, Main.rand.NextFloat(0.3f, 0.5f)); Dust dust2 = Main.dust[venusDust2]; dust2.position.X -= 2f; dust2.position.Y += 2f; diff --git a/Projectiles/Magic/VisNeedle.cs b/Projectiles/Magic/VisNeedle.cs new file mode 100644 index 0000000000..452592e9f1 --- /dev/null +++ b/Projectiles/Magic/VisNeedle.cs @@ -0,0 +1,77 @@ +using System; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class VisNeedle : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 10; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 34; + Projectile.height = 6; + Projectile.friendly = true; + Projectile.tileCollide = true; + Projectile.ignoreWater = true; + Projectile.timeLeft = 120; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = 3; + } + + public override void AI() + { + // Face the right direction + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // Leak a particle + if (Main.rand.NextBool(6)) + { + Vector2 velocity = Vector2.Normalize(Projectile.velocity).RotatedBy(Main.rand.NextFloat(-0.07f, 0.07f)) * 0.8f; + float scale = Projectile.scale * 0.33f; + + GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Projectile.Center, velocity, false, 20, scale, Color.Magenta)); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + int frameHeight = texture.Height / Main.projFrames[Type]; + Rectangle sourceRect = new Rectangle(0, frameHeight * Projectile.frame, texture.Width, frameHeight); + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, sourceRect, Color.White, Projectile.rotation, sourceRect.Size() * 0.5f, 1f, 0); + + return false; + } + + // Handle the projectile's trail from here + private float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Lerp(0f, MathHelper.Lerp(10f, 0f, completionRatio), MathF.Pow(completionRatio, 1f / 2.5f)); + private Color ColorFunction(float completionRatio, Vector2 vertexPos) + { + float offsetTime = Main.GlobalTimeWrappedHourly; + float fadeOpacity = Utils.GetLerpValue(0.5f, 0f, completionRatio, true) * (Projectile.Opacity * 0.75f); + Color endColor = Color.Lerp(Color.Magenta, Color.Violet, (float)Math.Sin(completionRatio * MathHelper.Pi * 2f - offsetTime * 4f) * 0.5f + 0.5f); + return Color.Lerp(endColor, Color.White, completionRatio) * fadeOpacity; + } + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_, _) => Projectile.Size* 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + } + } +} diff --git a/Projectiles/Magic/VisNeedle.png b/Projectiles/Magic/VisNeedle.png new file mode 100644 index 0000000000..e6c5f7796b Binary files /dev/null and b/Projectiles/Magic/VisNeedle.png differ diff --git a/Projectiles/Magic/VisceraBeam.cs b/Projectiles/Magic/VisceraBeam.cs index b0194dba22..b68e52be1a 100644 --- a/Projectiles/Magic/VisceraBeam.cs +++ b/Projectiles/Magic/VisceraBeam.cs @@ -1,15 +1,12 @@ -using CalamityMod.Graphics.Metaballs; -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; -using CalamityMod.Balancing; -using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.Healing; namespace CalamityMod.Projectiles.Magic { @@ -93,15 +90,13 @@ namespace CalamityMod.Projectiles.Magic dust.noGravity = true; } } + if (Projectile.ai[2] < 1){ + for (int i = 0; i < 2; i++) { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(0.5f) * Main.rand.NextFloat(3, 5), ModContent.ProjectileType(), 5, 0f, Projectile.owner); + } + Projectile.ai[2]++; + } - int heal = (int)Math.Round(hit.Damage * 0.05); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); } public override void AI() diff --git a/Projectiles/Magic/VitriolicViperHoldout.cs b/Projectiles/Magic/VitriolicViperHoldout.cs index e969041603..dd52647e69 100644 --- a/Projectiles/Magic/VitriolicViperHoldout.cs +++ b/Projectiles/Magic/VitriolicViperHoldout.cs @@ -9,6 +9,7 @@ using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -39,7 +40,7 @@ namespace CalamityMod.Projectiles.Magic public override void KillHoldoutLogic() { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type) Projectile.Kill(); } @@ -77,10 +78,11 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(fire2 with { Pitch = -0.3f, Volume = 0.5f }, Projectile.Center); // Vipers can apparently have 33 teeth or something like that - Owner.Calamity().GeneralScreenShakePower = 4f; - for (int i = 0; i < 33; i++) + Owner.SetScreenshake(4f); + if (Main.myPlayer == Projectile.owner) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity * 2).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.2f), ModContent.ProjectileType(), Projectile.damage / 10, Projectile.knockBack, Projectile.owner, 0); + for (int i = 0; i < 33; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity * 2).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.2f), ModContent.ProjectileType(), Projectile.damage / 10, Projectile.knockBack, Projectile.owner, 0); } Particle pulse = new CustomPulse(GunTipPosition, Vector2.Zero, bColor, "CalamityMod/Particles/HighResFoggyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 0.05f, 14); @@ -88,7 +90,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 17; i++) { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 278); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB); chargefull.velocity = Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(5, 25); chargefull.scale = Main.rand.NextFloat(0.45f, 0.75f); chargefull.noGravity = true; @@ -117,11 +119,14 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire = new("CalamityMod/Sounds/Item/ViperSpit"); SoundEngine.PlaySound(fire with { Pitch = (chargePower * 0.3f) + Main.rand.NextFloat(-0.1f, 0.1f), Volume = 0.5f }, Projectile.Center); - Projectile hiss = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * MathHelper.Clamp(chargePower, 0.3f, 1), ModContent.ProjectileType(), (int)(Projectile.damage * MathHelper.Clamp(chargePower, 0.3f, 1)), Projectile.knockBack, Projectile.owner, 0, 0, chargePower); - hiss.extraUpdates = (int)(Utils.Remap(chargePower, 0, 1, 2, 13, true)); + if (Main.myPlayer == Projectile.owner) + { + Projectile hiss = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * MathHelper.Clamp(chargePower, 0.3f, 1), ModContent.ProjectileType(), (int)(Projectile.damage * MathHelper.Clamp(chargePower, 0.3f, 1)), Projectile.knockBack, Projectile.owner, 0, 0, chargePower); + hiss.extraUpdates = (int)(Utils.Remap(chargePower, 0, 1, 2, 13, true)); + } for (int i = 0; i < 17; i++) { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 278); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB); chargefull.velocity = Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(5, 25); chargefull.scale = Main.rand.NextFloat(0.55f, 0.75f) * chargePower + 0.1f; chargefull.noGravity = true; @@ -174,7 +179,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 18; i++) { Vector2 dustVel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1, 5); - Dust dust2 = Dust.NewDustPerfect(GunTipPosition + dustVel, 278, dustVel * 0.7f); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition + dustVel, DustID.FireworksRGB, dustVel * 0.7f); dust2.scale = Main.rand.NextFloat(0.45f, 0.9f); dust2.noGravity = true; dust2.color = Color.Lerp(Color.White, Main.rand.NextBool(4) ? bColor : Color.Green, 0.7f); @@ -186,7 +191,7 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(fire with { Volume = 1f, Pitch = 0.2f }, Projectile.Center); for (int i = 0; i < 12; i++) { - Dust dust2 = Dust.NewDustPerfect(GunTipPosition, 278, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(2f, 5.5f)); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(2f, 5.5f)); dust2.scale = Main.rand.NextFloat(0.75f, 1.1f); dust2.noGravity = false; dust2.color = Color.Lerp(Color.White, Main.rand.NextBool(4) ? Color.Green : bColor, 0.7f); diff --git a/Projectiles/Magic/VitriolicViperSpit.cs b/Projectiles/Magic/VitriolicViperSpit.cs index c1f057a06d..ebf8e8c2fc 100644 --- a/Projectiles/Magic/VitriolicViperSpit.cs +++ b/Projectiles/Magic/VitriolicViperSpit.cs @@ -1,12 +1,10 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -17,6 +15,7 @@ namespace CalamityMod.Projectiles.Magic public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public int time = 0; public int direction = 0; + public Vector2 lastPos; public override void SetDefaults() { Projectile.width = 16; @@ -44,14 +43,15 @@ namespace CalamityMod.Projectiles.Magic if (time == 0) { direction = Main.rand.NextBool() ? 1 : -1; + lastPos = Projectile.Center; } if (time > 3) - Projectile.Center += offset * direction; + Projectile.Center += offset * direction * Utils.GetLerpValue(3, 10, time, true); if (time > 3 && targetDist < 1400) { - Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.3f, false, (int)(15 * MathHelper.Clamp(Projectile.ai[2], 0.5f, 1f)), 0.07f * MathHelper.Clamp(Projectile.ai[2], 0.25f, 1f), Color.Chartreuse, new Vector2(1, 0.7f), false, true); + Particle spark = new GlowSparkParticle(Projectile.Center, Utils.DirectionTo(Projectile.Center, lastPos), false, (int)(15 * MathHelper.Clamp(Projectile.ai[2], 0.5f, 1f)), 0.07f * MathHelper.Clamp(Projectile.ai[2], 0.25f, 1f), Color.Chartreuse, new Vector2(1, 1.4f), false, true); GeneralParticleHandler.SpawnParticle(spark); if (Main.rand.NextBool((int)(MathHelper.Clamp((1 - Projectile.ai[2]) * 5, 1, 15)))) @@ -64,6 +64,7 @@ namespace CalamityMod.Projectiles.Magic } } time++; + lastPos = Projectile.Center; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { diff --git a/Projectiles/Magic/VividBeam.cs b/Projectiles/Magic/VividBeam.cs index 79df19ea9c..54455c7078 100644 --- a/Projectiles/Magic/VividBeam.cs +++ b/Projectiles/Magic/VividBeam.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Terraria; @@ -75,7 +74,7 @@ namespace CalamityMod.Projectiles.Magic { Vector2 source = Projectile.position; source -= Projectile.velocity * ((float)d * 0.25f); - int i = Dust.NewDust(source, 1, 1, 66, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); + int i = Dust.NewDust(source, 1, 1, DustID.RainbowTorch, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); Main.dust[i].noGravity = true; Main.dust[i].position = source; Main.dust[i].scale = Main.rand.NextFloat(0.91f, 1.417f); diff --git a/Projectiles/Magic/VoidVortexProj.cs b/Projectiles/Magic/VoidVortexProj.cs index c0a5cfbf3f..d3f4629ddf 100644 --- a/Projectiles/Magic/VoidVortexProj.cs +++ b/Projectiles/Magic/VoidVortexProj.cs @@ -1,11 +1,7 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; -using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Mono.Cecil; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -66,7 +62,7 @@ namespace CalamityMod.Projectiles.Magic CalamityUtils.HomeInOnNPC(Projectile, true, 1000f, 15, MathHelper.Clamp(100f - time * 0.3f, 40, 100)); if (Main.rand.NextBool()) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 226, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.3f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.Electric, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.3f)); dust2.scale = Main.rand.NextFloat(0.35f, 0.75f); dust2.noGravity = true; } @@ -98,7 +94,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 0; for (int k = 0; k < 25; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 226, new Vector2(15, 15).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.Electric, new Vector2(15, 15).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); dust2.scale = Main.rand.NextFloat(0.45f, 0.95f); dust2.noGravity = true; } @@ -145,13 +141,16 @@ namespace CalamityMod.Projectiles.Magic Projectile.ExpandHitboxBy(400); Projectile.Damage(); - for (int k = 0; k < 12; k++) + if (Main.myPlayer == Projectile.owner) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 0.55f), ModContent.ProjectileType(), Projectile.damage / 6, 0f, Main.myPlayer, 0f, 0f, 3f); + for (int k = 0; k < 12; k++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 0.55f), ModContent.ProjectileType(), Projectile.damage / 6, 0f, Main.myPlayer, 0f, 0f, 3f); + } } for (int k = 0; k < 40; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 226, new Vector2(25, 25).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.Electric, new Vector2(25, 25).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); dust2.scale = Main.rand.NextFloat(0.65f, 1.15f); dust2.noGravity = true; } @@ -164,7 +163,7 @@ namespace CalamityMod.Projectiles.Magic { for (int k = 0; k < 7; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 226, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.Electric, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); dust2.scale = Main.rand.NextFloat(0.45f, 0.75f); dust2.noGravity = true; } diff --git a/Projectiles/Magic/VolterionHoldout.cs b/Projectiles/Magic/VolterionHoldout.cs index 9fae60413e..609001b1e4 100644 --- a/Projectiles/Magic/VolterionHoldout.cs +++ b/Projectiles/Magic/VolterionHoldout.cs @@ -4,10 +4,10 @@ using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; +using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.Magic public override string Texture => "CalamityMod/Projectiles/Magic/VolterionHoldout"; public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/VolterionFire") { Volume = 0.35f }; + public SlotId FireSoundSlot; public ref float FlashTimer => ref Projectile.ai[0]; @@ -46,9 +47,8 @@ namespace CalamityMod.Projectiles.Magic public override void KillHoldoutLogic() { - // Only times out if at the final frame (post-firing resting time) - bool noMana = !Owner.CheckMana(Owner.ActiveItem()) && Projectile.frame == 14; - if (HeldItem.type != Owner.ActiveItem().type || noMana) + // Override typical CantUseHoldout such that the weapon typically runs through the use animation while not channeled + if (HeldItem.type != Owner.HeldItem.type || Owner.dead || !Owner.active) { Projectile.Kill(); Projectile.netUpdate = true; @@ -72,9 +72,9 @@ namespace CalamityMod.Projectiles.Magic Projectile.frameCounter++; // Subtract a flat 42 from the use time because the firing animation consists of 14 frames at 20 FPS - if (Projectile.frameCounter >= MathHelper.Clamp(Owner.ActiveItem().useAnimation - 42, 0f, Owner.ActiveItem().useAnimation)) + if (Projectile.frameCounter >= MathHelper.Clamp(Owner.HeldItem.useAnimation - 42, 0f, Owner.HeldItem.useAnimation)) { - if (Owner.CantUseHoldout()) + if (Owner.CantUseHoldout() || !Owner.CheckMana(Owner.HeldItem)) Projectile.Kill(); Projectile.frame = 0; @@ -97,10 +97,11 @@ namespace CalamityMod.Projectiles.Magic } Projectile.frameCounter++; - if (Owner.CheckMana(Owner.ActiveItem(), -1, true)) + if (Owner.CheckMana(Owner.HeldItem, -1, true)) { FlashTimer = 4f; - SoundEngine.PlaySound(FireSound, GunTipPosition); + FireSoundSlot = SoundEngine.PlaySound(FireSound, GunTipPosition); + Owner.SetScreenshake(3f); // Start from slightly behind the tip Vector2 offsetPos = GunTipPosition - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 18f; @@ -126,6 +127,9 @@ namespace CalamityMod.Projectiles.Magic Projectile.frameCounter = 0; } } + + if (SoundEngine.TryGetActiveSound(FireSoundSlot, out var currentSound) && currentSound.IsPlaying) + currentSound.Position = GunTipPosition; } // Muzzle flash can deal damage diff --git a/Projectiles/Magic/VolterionOrb.cs b/Projectiles/Magic/VolterionOrb.cs new file mode 100644 index 0000000000..7a3de4be3d --- /dev/null +++ b/Projectiles/Magic/VolterionOrb.cs @@ -0,0 +1,157 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Projectiles.Magic +{ + public class VolterionOrb : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + + public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/VolterionOrbShot") { Volume = 0.6f }; + public static readonly SoundStyle ExplosionSound = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact") { Volume = 0.5f }; + + // Explosion + public static float ExplosionTime = 150f; // Time taken to explode + public static float ExplosionLifetime = 18f; + public static float MaxScale = 7.5f; + + // Lightning + public static float AttackRate = 60f; + public static float AttackRange = 800f; + public static float LightningDamageMult = 0.25f; + + public ref float OrbType => ref Projectile.ai[0]; + public ref float AttackTimer => ref Projectile.ai[1]; + public ref float ExplosionTimer => ref Projectile.ai[2]; + + public Player Owner => Main.player[Projectile.owner]; + + public static Asset Bloom; + public static Asset Explosion; + public override void Load() + { + Bloom = ModContent.Request("CalamityMod/Particles/BloomCircle"); + Explosion = ModContent.Request("CalamityMod/Particles/PlasmaExplosion"); + } + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 5; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 38; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / 4 % Main.projFrames[Type]; + + Projectile.velocity *= 0.8f; + Projectile.rotation += 0.01f; + Lighting.AddLight(Projectile.Center, GetColor(OrbType).ToVector3()); + + // Each orb fires at a slightly different timing from the previous + AttackTimer++; + float offset = 9f * OrbType; + if (AttackTimer > AttackRate * 2f) + { + // Explode + if (AttackTimer > ExplosionTime) + { + if (ExplosionTimer == 0f) + SoundEngine.PlaySound(ExplosionSound, Projectile.Center); + + float scaleLevel = PiecewiseAnimation(ExplosionTimer / ExplosionLifetime, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Projectile.scale = MathHelper.Lerp(1f, MaxScale, scaleLevel); + Projectile.Opacity = MathF.Sin(MathHelper.PiOver2 + MathHelper.PiOver2 * ExplosionTimer / ExplosionLifetime); + + if (ExplosionTimer++ > ExplosionLifetime) + Projectile.Kill(); + } + // Builds up dust readying up to explode + else if (AttackTimer > MathHelper.Lerp(AttackRate * 2f, ExplosionTime, 0.8f) || AttackTimer % 3 == 2) + { + Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f)); + Dust spark = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, velocity); + spark.noLight = true; + spark.noGravity = Main.rand.NextBool(); + spark.color = GetColor(OrbType); + } + } + else if (AttackTimer % AttackRate == (AttackRate - offset - 1f)) + { + // Orbs should be extremely slow by the time they fire already but make sure it's not moving to keep the visuals right + Projectile.velocity *= 0f; + + NPC target = Projectile.Center.ClosestNPCAt(AttackRange); + if (target != null) + { + SoundEngine.PlaySound(FireSound, Projectile.Center); + + Vector2 velocity = Projectile.SafeDirectionTo(target.Center) * 16f; + Projectile shot = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * LightningDamageMult), Projectile.knockBack * LightningDamageMult, Projectile.owner, OrbType + 1f); + shot.tileCollide = false; + + // Create a lightning bolt-like particle in the direction of the shot and 3 random hue-shifted ones by the side + Particle bolt = new CrackParticle(Projectile.Center, velocity * 0.5f, GetColor(OrbType), Vector2.One, 0, 0, Main.rand.NextFloat(0.8f, 1f), 12); + GeneralParticleHandler.SpawnParticle(bolt); + + for (int i = 1; i < 4; i++) + { + Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, GetColor(4f - OrbType) * 0.6f, Vector2.One, 0, 0, Main.rand.NextFloat(0.5f, 0.6f), 12); + GeneralParticleHandler.SpawnParticle(bolt2); + } + } + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Electrified, 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Electrified, 120); + + public static Color GetColor(float type) => Color.Lerp(new Color(51, 197, 255), new Color(143, 51, 255), 0.2f + 0.15f * type + 0.2f * MathF.Sin(Main.GlobalTimeWrappedHourly * 10f)); + + public override Color? GetAlpha(Color lightColor) => GetColor(OrbType); + + public override bool PreDraw(ref Color lightColor) + { + Vector2 drawPos = Projectile.Center - Main.screenPosition; + Color color = Projectile.GetAlpha(lightColor); + + if (ExplosionTimer > 0f) + { + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + Texture2D explosionTex = Explosion.Value; + Main.EntitySpriteDraw(explosionTex, drawPos, null, color * Projectile.Opacity, Projectile.rotation, explosionTex.Size() * 0.5f, 0.02f * Projectile.scale, SpriteEffects.None); + Main.spriteBatch.ExitShaderRegion(); + return false; + } + + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + Texture2D bloomTex = Bloom.Value; + Main.EntitySpriteDraw(bloomTex, drawPos, null, color * 0.5f, 0, bloomTex.Size() * 0.5f, 0.42f, SpriteEffects.None); + Main.spriteBatch.ExitShaderRegion(); + return true; + } + + public override bool? CanDamage() => ExplosionTimer > 0f ? base.CanDamage() : false; + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CircularHitboxCollision(Projectile.Center, 20 * Projectile.scale, targetHitbox); + } +} diff --git a/Projectiles/Magic/VolterionShot.cs b/Projectiles/Magic/VolterionShot.cs new file mode 100644 index 0000000000..7ec4b6b137 --- /dev/null +++ b/Projectiles/Magic/VolterionShot.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class VolterionShot : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + // Due to how far/fast this thing moves, it'd require way too many points for a smooth long trail using oldPos + public List TrailPos = new List(); + public const int TrailLength = 50; + + public ref float OrbType => ref Projectile.ai[0]; + + public override void SetStaticDefaults() => ProjectileID.Sets.DrawScreenCheckFluff[Type] = 5000; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 20; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.MaxUpdates = 15; + Projectile.timeLeft = 24 * Projectile.MaxUpdates; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + + if (Projectile.numHits > 0) + { + Projectile.scale -= 0.005f; + Projectile.Opacity -= 0.005f; + if (Projectile.Opacity <= 0f) + Projectile.Kill(); + } + else + { + // Update a bit more frequently than the update count for better point distribution + if (Projectile.FinalExtraUpdate() || Projectile.numUpdates % 3 == 2 || TrailPos == null) + { + // Initialize 15 points immediately + if (TrailPos == null) + { + TrailPos = new List(15); + for (int i = 0; i < 15; ++i) + TrailPos.Add(Projectile.Center); + } + + // Add some random value for the natural lightning look + Vector2 randOffset = (Vector2.UnitY * Main.rand.NextFloat(-24f, 24f)).RotatedBy(Projectile.rotation); + TrailPos.Insert(0, Projectile.Center + randOffset); + + while (TrailPos.Count > TrailLength) + TrailPos.RemoveAt(TrailPos.Count - 1); + } + + // Randomly spawn glowing bolts outwards + if (Main.rand.NextBool(6)) + { + BoltParticle bolt = new BoltParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(36f)), false, 10, 0.3f, TrailColorFunction(0f, Vector2.Zero), Vector2.One, true); + GeneralParticleHandler.SpawnParticle(bolt); + } + + if (Projectile.timeLeft < 50) // Starts exploding and fading by itself if it never hits anything + Decay(); + } + } + + public override bool? CanDamage() => Projectile.numHits == 0 ? null : false; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.Electrified, 60); + if (Projectile.numHits == 0) + Decay(); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (Projectile.numHits == 0) + Decay(); + return false; + } + + public void Decay() + { + Projectile.numHits++; // Ensure this can only happen once + Projectile.timeLeft = 200; + Projectile.velocity = Vector2.Zero; + Projectile.netUpdate = true; + + // Final position update + TrailPos.Insert(0, Projectile.Center); + + while (TrailPos.Count > TrailLength) + TrailPos.RemoveAt(TrailPos.Count - 1); + + bool secondary = OrbType > 0f; + if (Projectile.owner == Main.myPlayer && !secondary) + { + float rotOffset = Main.rand.NextFloat(0f, MathHelper.TwoPi); + for (int i = 0; i < 5; i++) + { + Vector2 velocity = Vector2.UnitX.RotatedBy(rotOffset + MathHelper.TwoPi * 0.2f * (i + Main.rand.NextFloat(-0.4f, 0.4f))) * (Main.rand.NextFloat(40f, 45f)); + Projectile orb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, i); + orb.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); + } + } + + int boltCount = secondary ? 6 : 10; + for (int i = 0; i < boltCount; i++) + { + Color color = OrbType > 0f ? VolterionOrb.GetColor(OrbType - 1f) : (Main.rand.NextBool() ? Color.Cyan : Color.Orchid); + Vector2 velocity = Vector2.UnitX.RotatedBy(MathHelper.TwoPi * 0.2f * (i + Main.rand.NextFloat(-0.4f, 0.4f))) * (Main.rand.NextFloat(12f, 15f)); + BoltParticle bolt = new BoltParticle(Projectile.Center, velocity, false, 18, Main.rand.NextFloat(0.4f, 0.6f), color, new Vector2(0.6f, 1f), true); + GeneralParticleHandler.SpawnParticle(bolt); + } + for (int k = 0; k < 7; k++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 14f)); + Dust spark = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, velocity); + spark.noLight = true; + spark.color = Main.rand.NextBool() ? Color.Cyan : Color.Orchid; + } + } + + internal float TrailWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 15f * Utils.GetLerpValue(0.5f, 0.4f, MathF.Abs(0.5f - completionRatio), true); + internal Color TrailColorFunction(float completionRatio, Vector2 vertexPos) => OrbType > 0f ? VolterionOrb.GetColor(OrbType - 1f) : Color.Lerp(new Color(51, 197, 255), new Color(143, 51, 255), 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 20f)) * Projectile.Opacity; + + public override bool PreDraw(ref Color lightColor) + { + if (TrailPos == null) + return false; + + GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin"); + GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply(); + PrimitiveRenderer.RenderTrail(TrailPos, new(TrailWidthFunction, TrailColorFunction, smoothen: false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), TrailLength); + return false; + } + } +} diff --git a/Projectiles/Magic/WarpSigil.cs b/Projectiles/Magic/WarpSigil.cs new file mode 100644 index 0000000000..191ff61d2e --- /dev/null +++ b/Projectiles/Magic/WarpSigil.cs @@ -0,0 +1,118 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Particles; + +namespace CalamityMod.Projectiles.Magic +{ + public class WarpSigil : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + private bool spawnedProjectile = false; + private bool spawnedIntroParticle = false; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 74; + Projectile.friendly = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)Projectile.ai[0]]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive && Projectile.ai[2] == 0) + { + Projectile.Kill(); + return; + } + + int i = (int)Projectile.ai[1]; + float dist = i % 3 == 0 ? 270f : 280f; + float extraRot = i % 3 == 0 ? 0 : i % 3 == 1 ? MathHelper.ToRadians(-3.33f) : MathHelper.ToRadians(3.33f); + + Vector2 sigilPos = parent.Center + (Vector2.UnitX.RotatedBy(MathHelper.Lerp(0, MathHelper.TwoPi, i / 6f)) * dist).RotatedBy(parent.rotation + extraRot); + Projectile.Center = sigilPos; + + if (Projectile.ai[2] > 0) + { + Projectile.localAI[0]++; + + if (Projectile.localAI[0] >= 25 && !spawnedProjectile) + { + // ai[1] and ai[2] will inherit this sigil's position and timeLeft as its own + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Main.MouseWorld, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Projectile.whoAmI, Projectile.timeLeft); + spawnedProjectile = true; + } + + if (Projectile.localAI[0] >= 70) + { + Projectile.Kill(); + } + } + + else + { + Projectile.rotation = 0; + Projectile.alpha = parent.alpha; + } + + if (parentActive) + { + Projectile.timeLeft = parent.timeLeft; + } + + if (!spawnedIntroParticle) + for (int j = 0; j < 13; j++) + { + spawnedIntroParticle = true; + GeneralParticleHandler.SpawnParticle(new SquishyLightParticle(Projectile.Center, new Vector2(Main.rand.NextFloat(3f, 7f), 0f).RotatedByRandom(MathHelper.TwoPi), Projectile.scale * Main.rand.NextFloat(0.2f, 0.475f), Main.rand.NextBool() ? Color.Magenta : Color.White, Main.rand.Next(12, 24), 1f, 0f, 1f)); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D mainTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D blankTexture = ModContent.Request("CalamityMod/Projectiles/Magic/BlankSigil").Value; + + float finalScale = Projectile.scale; + float alphaOpacity = 1f - (Projectile.alpha / 255f); + float maskOpacity = 0f; + + // Apply animation effects if the fade-out is active + if (Projectile.ai[2] > 0) + { + float animationTime = Projectile.localAI[0]; + + if (animationTime <= 18) + { + maskOpacity = Utils.GetLerpValue(0f, 18f, animationTime, clamped: true); + } + else + { + maskOpacity = 1f; + } + + if (animationTime >= 55) + { + float scaleFactor = Utils.GetLerpValue(55f, 70f, animationTime, clamped: true); + finalScale = MathHelper.Lerp(Projectile.scale, 0f, scaleFactor); + alphaOpacity = MathHelper.Lerp(alphaOpacity, 0f, scaleFactor); + } + } + + Main.EntitySpriteDraw(mainTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor) * alphaOpacity, Projectile.rotation, mainTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + + if (Projectile.ai[2] > 0) + { + Main.EntitySpriteDraw(blankTexture, Projectile.Center - Main.screenPosition, null, Color.White * maskOpacity, Projectile.rotation, blankTexture.Size() / 2, finalScale, SpriteEffects.None, 0); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/WarpSigil.png b/Projectiles/Magic/WarpSigil.png new file mode 100644 index 0000000000..ec2978c54f Binary files /dev/null and b/Projectiles/Magic/WarpSigil.png differ diff --git a/Projectiles/Magic/WarpSigilShot.cs b/Projectiles/Magic/WarpSigilShot.cs new file mode 100644 index 0000000000..88b1a56aac --- /dev/null +++ b/Projectiles/Magic/WarpSigilShot.cs @@ -0,0 +1,137 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class WarpSigilShot : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float FixedOffsetX => ref Projectile.ai[0]; + public ref float FixedOffsetY => ref Projectile.ai[1]; + public ref float DamageStatus => ref Projectile.ai[2]; + + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 36; + Projectile.height = 36; + Projectile.friendly = false; // Only deals damage after it has passed over its targeted point + Projectile.hostile = false; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 28; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = 1; + } + + public override void AI() + { + // Called here so that the projectile dissapears instantly after the frame it is able to damage something + if (DamageStatus == 1 && Projectile.timeLeft <= 6) + Projectile.Kill(); + + Vector2 fixedOffset = new Vector2(FixedOffsetX, FixedOffsetY); + Vector2 targetPosition = Main.MouseWorld + fixedOffset; + + Vector2 direction = targetPosition - Projectile.Center; + float distanceToTarget = direction.Length(); + direction.Normalize(); + + float homingStrength = 0f; + if (Projectile.timeLeft <= 22) + homingStrength = 0.475f; + + float maxSpeed = 60f; + + Projectile.velocity = Vector2.Lerp(Projectile.velocity, direction * maxSpeed, homingStrength * 0.4f); + + Projectile.velocity *= 1.05f; + + if (Projectile.velocity.Length() > maxSpeed) + { + Projectile.velocity = Vector2.Normalize(Projectile.velocity) * maxSpeed; + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Vector2 vectorToTarget = targetPosition - Projectile.Center; + + // Checking for if the projectile is over it's targeted point + if (Vector2.Dot(Projectile.velocity, vectorToTarget) < 0f) + { + DamageStatus = 1; + } + Projectile.friendly = DamageStatus == 1 ? true : false; + + float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi); + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; + if (Main.rand.NextBool(5)) + { + Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust3.noGravity = true; + dust3.scale = Main.rand.NextFloat(0.4f, 0.85f); + dust3.color = Color.Violet; + } + + } + public override void OnKill(int timeLeft) + { + SoundStyle w = new("CalamityMod/Sounds/Custom/PlagueSounds/PlagueBoom4"); + SoundEngine.PlaySound(w with { Volume = 0.25f, Pitch = 0f, MaxInstances = 4 }, Projectile.Center); + + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkMagenta * 2f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.04f, 14, true, 1f); + GeneralParticleHandler.SpawnParticle(blastRing); + + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.ShadowbeamStaff, Main.rand.NextVector2Circular(2f, 2f)); + dust.noGravity = true; + dust.scale = 0.5f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + int frameHeight = texture.Height / Main.projFrames[Type]; + Rectangle sourceRect = new Rectangle(0, frameHeight * Projectile.frame, texture.Width, frameHeight); + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, sourceRect, Color.White, Projectile.rotation, sourceRect.Size() * 0.5f, 1f, SpriteEffects.None, 0); + return false; + } + + // Handle the projectile's trail from here + private float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Lerp(0f, MathHelper.Lerp(32f, 0f, completionRatio), MathF.Pow(completionRatio, 1f / 2.5f)); + private Color ColorFunction(float completionRatio, Vector2 vertexPos) + { + float offsetTime = Main.GlobalTimeWrappedHourly; + float fadeOpacity = Utils.GetLerpValue(0.5f, 0f, completionRatio, true) * Projectile.Opacity; + Color endColor = Color.Lerp(Color.Magenta, Color.DarkMagenta, (float)Math.Sin(completionRatio * MathHelper.Pi * 1.6f - offsetTime * 4f) * 0.5f + 0.5f); + return Color.Lerp(endColor, Color.White, completionRatio) * fadeOpacity; + } + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32); + + GeneralParticleHandler.SpawnParticle(new SquishyLightParticle(Projectile.Center, Projectile.velocity, Projectile.scale * 0.4f, Color.Magenta, 2, 1f, 0.5f, 1f), pixelate: true); + } + } +} diff --git a/Projectiles/Magic/WarpSigilShotCreator.cs b/Projectiles/Magic/WarpSigilShotCreator.cs new file mode 100644 index 0000000000..912e0cdf4d --- /dev/null +++ b/Projectiles/Magic/WarpSigilShotCreator.cs @@ -0,0 +1,65 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class WarpSigilShotCreator : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public ref float FiringTimer => ref Projectile.ai[0]; + public ref float ParentIndex => ref Projectile.ai[1]; + + private const int DelayBetweenShots = 5; + private const float ShotSpeed = 20f; + private const float SpawnDistance = 250f; + + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + } + + public override void AI() + { + Projectile parent = Main.projectile[(int)ParentIndex]; + bool parentActive = parent != null && parent.active && parent.type == ModContent.ProjectileType(); + + if (!parentActive) + { + Projectile.Kill(); + return; + } + + Projectile.Center = parent.Center; + Projectile.timeLeft = parent.timeLeft; + Vector2 targetCenter = Main.MouseWorld; + + FiringTimer++; + if (FiringTimer % DelayBetweenShots == 0) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/UnstableCastersGauntlet/VisNeedleFire") { Volume = 0.35f, Pitch = -0.3f, PitchVariance = 0.1f }, Projectile.Center); + + // Shoot blasts from random angles, then pass a given point to target + Vector2 fixedTargetOffset = Main.rand.NextVector2Circular(36f, 36f); + float startAngle = Main.rand.NextFloat(MathHelper.TwoPi); + Vector2 spawnOffset = startAngle.ToRotationVector2() * SpawnDistance; + Vector2 spawnPosition = targetCenter + spawnOffset; + + Vector2 initialTargetLocation = targetCenter + fixedTargetOffset; + Vector2 velocity = (initialTargetLocation - spawnPosition).SafeNormalize(Vector2.UnitX) * ShotSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, ai0: fixedTargetOffset.X, ai1: fixedTargetOffset.Y); + } + + } + public override bool PreDraw(ref Color lightColor) => false; + } +} diff --git a/Projectiles/Magic/WaterLeechProj.cs b/Projectiles/Magic/WaterLeechProj.cs index cc1d8ddeb6..a85083f258 100644 --- a/Projectiles/Magic/WaterLeechProj.cs +++ b/Projectiles/Magic/WaterLeechProj.cs @@ -1,6 +1,6 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -10,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class WaterLeechProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -25,6 +26,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = -1; Projectile.timeLeft = 540; Projectile.DamageType = DamageClass.Magic; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/WingmanGrenade.cs b/Projectiles/Magic/WingmanGrenade.cs index ed92403696..16e2a6667b 100644 --- a/Projectiles/Magic/WingmanGrenade.cs +++ b/Projectiles/Magic/WingmanGrenade.cs @@ -48,8 +48,10 @@ namespace CalamityMod.Projectiles.Magic if (mainColor == Color.White) { Projectile.scale = 0.4f; + if (Projectile.ai[1] == -1) + mainColor = Color.Turquoise; if (Projectile.ai[1] == 0) - mainColor = Color.HotPink; + mainColor = Color.Orchid; if (Projectile.ai[1] == 2) { diff --git a/Projectiles/Magic/WingmanHoldout.cs b/Projectiles/Magic/WingmanHoldout.cs index 76512e79f1..9b83bbff90 100644 --- a/Projectiles/Magic/WingmanHoldout.cs +++ b/Projectiles/Magic/WingmanHoldout.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Magic public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public override string Texture => "CalamityMod/Items/Weapons/Magic/Wingman"; - public Color StaticEffectsColor = Color.HotPink; + public Color StaticEffectsColor = Color.Orchid; private ref float ShootingTimer => ref Projectile.ai[0]; private ref float PostFireCooldown => ref Projectile.ai[1]; public float yOffset; @@ -50,6 +50,8 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Owner ??= Main.player[Projectile.owner]; + if (Projectile.ai[2] == 1) + StaticEffectsColor = Color.Turquoise; Lighting.AddLight(Projectile.Center, StaticEffectsColor.ToVector3() * 0.2f); @@ -59,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic } firingDelay--; - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; // Update damage based on curent magic damage stat (so Mana Sickness affects it) Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); @@ -81,7 +83,7 @@ namespace CalamityMod.Projectiles.Magic // If the player's pressing RMB, it'll shoot the grenade. if (Owner.Calamity().mouseRight) { - if ((Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 5, true, false))) + if ((Owner.CheckMana(Owner.HeldItem, (int)(heldItem.mana * Owner.manaCost) * 5, true, false))) { Shoot(true); PostFireCooldown = 35 + 55 * Utils.GetLerpValue(10, 40, FiringTime, true); @@ -100,7 +102,7 @@ namespace CalamityMod.Projectiles.Magic } else if (ShootingTimer >= FiringTime) { - if (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost), true, false)) + if (Owner.CheckMana(Owner.HeldItem, (int)(heldItem.mana * Owner.manaCost), true, false)) { Shoot(false); ShootingTimer = 0; @@ -192,13 +194,13 @@ 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.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (firingVelocity * 1.3f) * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 6), Projectile.knockBack * 5, Projectile.owner, 0); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (firingVelocity * 1.3f) * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 6), Projectile.knockBack * 5, Projectile.owner, 0, (Projectile.ai[2] == 1 ? -1 : 0)); } else { SoundStyle fire = new("CalamityMod/Sounds/Item/MagnaCannonShot"); SoundEngine.PlaySound(fire with { Volume = 0.25f, Pitch = 1f, PitchVariance = 0.35f }, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * Utils.GetLerpValue(80, 10, FiringTime, true), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * Utils.GetLerpValue(80, 10, FiringTime, true), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, (Projectile.ai[2] == 1 ? -1 : 0)); } // Inside here go all the things that dedicated servers shouldn't spend resources on. @@ -236,7 +238,7 @@ namespace CalamityMod.Projectiles.Magic Particle smoke = new HeavySmokeParticle(tipPosition, smokeVel, StaticEffectsColor, Main.rand.Next(30, 50 + 1), Main.rand.NextFloat(0.1f, 0.4f), 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.2f, 0.8f)); + Dust dust = Dust.NewDustPerfect(tipPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.2f, 0.8f)); dust.noGravity = false; dust.color = StaticEffectsColor; } diff --git a/Projectiles/Magic/WingmanShot.cs b/Projectiles/Magic/WingmanShot.cs index 4a291ae93a..b33efa4379 100644 --- a/Projectiles/Magic/WingmanShot.cs +++ b/Projectiles/Magic/WingmanShot.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -37,8 +36,10 @@ namespace CalamityMod.Projectiles.Magic { if (mainColor == Color.White) { + if (Projectile.ai[1] == -1) + mainColor = Color.Turquoise; if (Projectile.ai[1] == 0) - mainColor = Color.HotPink; + mainColor = Color.Orchid; if (Projectile.ai[1] == 1) mainColor = Color.MediumSlateBlue; if (Projectile.ai[1] == 2) diff --git a/Projectiles/Magic/WulfrumBolt.cs b/Projectiles/Magic/WulfrumBolt.cs index 591346ae76..96fef2ab3b 100644 --- a/Projectiles/Magic/WulfrumBolt.cs +++ b/Projectiles/Magic/WulfrumBolt.cs @@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 5; i++) { - Dust chust = Dust.NewDustPerfect(dustCenter, 15, Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); chust.noGravity = true; } } @@ -149,7 +149,7 @@ namespace CalamityMod.Projectiles.Magic { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust chust = Dust.NewDustPerfect(dustCenter, 15, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); chust.noGravity = true; } @@ -157,7 +157,7 @@ namespace CalamityMod.Projectiles.Magic { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust largeDust = Dust.NewDustPerfect(dustCenter, 257, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f), Scale: Main.rand.NextFloat(0.4f, 1f)); + Dust largeDust = Dust.NewDustPerfect(dustCenter, DustID.BubbleBlock, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f), Scale: Main.rand.NextFloat(0.4f, 1f)); largeDust.noGravity = true; largeDust.noLight = true; } @@ -173,13 +173,13 @@ namespace CalamityMod.Projectiles.Magic } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = (float)Math.Sqrt(1 - completionRatio); return Color.DeepSkyBlue.MultiplyRGB(PrimColorMult) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return 9.4f; } @@ -195,7 +195,7 @@ namespace CalamityMod.Projectiles.Magic { PrimColorMult = colorMod; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); }); Main.spriteBatch.End(); diff --git a/Projectiles/Magic/WyvernFeatherGreen.cs b/Projectiles/Magic/WyvernFeatherGreen.cs index 74c6d6ee5f..809db702cf 100644 --- a/Projectiles/Magic/WyvernFeatherGreen.cs +++ b/Projectiles/Magic/WyvernFeatherGreen.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.aiStyle = ProjAIStyleID.Nail; AIType = ProjectileID.NailFriendly; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/WyvernFeatherPink.cs b/Projectiles/Magic/WyvernFeatherPink.cs index c336051740..c4ae4715b3 100644 --- a/Projectiles/Magic/WyvernFeatherPink.cs +++ b/Projectiles/Magic/WyvernFeatherPink.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.aiStyle = ProjAIStyleID.Nail; AIType = ProjectileID.NailFriendly; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/WyvernFeatherPurple.cs b/Projectiles/Magic/WyvernFeatherPurple.cs index fbc4db8a6d..c80d9b0306 100644 --- a/Projectiles/Magic/WyvernFeatherPurple.cs +++ b/Projectiles/Magic/WyvernFeatherPurple.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; Projectile.aiStyle = ProjAIStyleID.Nail; AIType = ProjectileID.NailFriendly; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Magic/YharimsCrystalBeam.cs b/Projectiles/Magic/YharimsCrystalBeam.cs index 105a0a852e..2f72ac129f 100644 --- a/Projectiles/Magic/YharimsCrystalBeam.cs +++ b/Projectiles/Magic/YharimsCrystalBeam.cs @@ -1,6 +1,7 @@ using System; using System.IO; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -12,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { + [PierceResistException] public class YharimsCrystalBeam : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; @@ -310,7 +312,6 @@ namespace CalamityMod.Projectiles.Magic { switch (name) { - case "Fabsol": case "Ziggums": return 2f; case "Poly": diff --git a/Projectiles/Magic/YharimsCrystalPrism.cs b/Projectiles/Magic/YharimsCrystalPrism.cs index e6138298dc..5bb0d22176 100644 --- a/Projectiles/Magic/YharimsCrystalPrism.cs +++ b/Projectiles/Magic/YharimsCrystalPrism.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true); // Update damage based on curent magic damage stat (so Mana Sickness affects it) - Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem()); + Projectile.damage = player.HeldItem is null ? 0 : player.GetWeaponDamage(player.HeldItem); FrameCounter += 1f; float chargeRatio = MathHelper.Clamp(FrameCounter / MaxCharge, 0f, 1f); @@ -79,11 +79,11 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.owner == Main.myPlayer) { // Scale seemingly never changes, so this just scales with shoot speed (Yharim's Crystal is 30 by default) - float speedTimesScale = player.ActiveItem().shootSpeed * Projectile.scale; + float speedTimesScale = player.HeldItem.shootSpeed * Projectile.scale; UpdateAim(rrp, speedTimesScale); // CheckMana returns true if the mana cost can be paid. If mana isn't consumed this frame, the CheckMana short-circuits out of being evaluated. - bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.ActiveItem(), -1, true, false); + bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.HeldItem, -1, true, false); bool crystalStillInUse = !player.CantUseHoldout() && allowContinuedUse; // The beams are only projected once (on frame 1). diff --git a/Projectiles/Melee/AbyssBladeProjectile.cs b/Projectiles/Melee/AbyssBladeProjectile.cs index 1ea0f6191b..6221665ecc 100644 --- a/Projectiles/Melee/AbyssBladeProjectile.cs +++ b/Projectiles/Melee/AbyssBladeProjectile.cs @@ -2,9 +2,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; -using CalamityMod.Projectiles.Ranged; -using Humanizer; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -153,12 +150,13 @@ namespace CalamityMod.Projectiles.Melee Projectile.extraUpdates = 2; Projectile.rotation = 0; spinMode = false; - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.65f, PitchVariance = 0.3f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.65f, PitchVariance = 0.3f }, Projectile.Center); for (int i = 0; i < 3; i++) { GenericSparkle sparker = new GenericSparkle(Projectile.Center, Vector2.Zero, Color.DodgerBlue, Color.MediumBlue, Main.rand.NextFloat(2.5f, 2.9f) - i * 0.55f, 14, Main.rand.NextFloat(-0.01f, 0.01f), 2.5f); GeneralParticleHandler.SpawnParticle(sparker); } + Projectile.ResetLocalNPCHitImmunity(); Projectile.penetrate = 1; Projectile.damage = (int)(startDamage * 2); // Launched blade deals 200% damage Time = 0; diff --git a/Projectiles/Melee/AbyssBladeSplitProjectile.cs b/Projectiles/Melee/AbyssBladeSplitProjectile.cs index 664e1c1d3c..6587d48b9d 100644 --- a/Projectiles/Melee/AbyssBladeSplitProjectile.cs +++ b/Projectiles/Melee/AbyssBladeSplitProjectile.cs @@ -1,10 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Particles; -using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Melee/AftershockRock.cs b/Projectiles/Melee/AftershockRock.cs deleted file mode 100644 index 8686851e54..0000000000 --- a/Projectiles/Melee/AftershockRock.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class AftershockRock : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - - public override void SetDefaults() - { - Projectile.width = 38; - Projectile.height = 38; - Projectile.aiStyle = ProjAIStyleID.GroundProjectile; - Projectile.friendly = true; - Projectile.penetrate = 3; - Projectile.MaxUpdates = 3; - Projectile.DamageType = DamageClass.Melee; - Projectile.timeLeft = 300 * Projectile.MaxUpdates; - Projectile.ignoreWater = true; - AIType = ProjectileID.BoulderStaffOfEarth; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; - Projectile.tileCollide = false; - } - - public override void AI() - { - if (Projectile.Center.Y > Projectile.ai[2]) - Projectile.tileCollide = true; - else - Projectile.tileCollide = false; - } - } -} diff --git a/Projectiles/Melee/AmidiasTridentBoltProj.cs b/Projectiles/Melee/AmidiasTridentBoltProj.cs new file mode 100644 index 0000000000..ae6f70f440 --- /dev/null +++ b/Projectiles/Melee/AmidiasTridentBoltProj.cs @@ -0,0 +1,100 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + class AmidiasTridentBoltProj : ModProjectile, ILocalizedModType + { + public override string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Particles/VerticalSmear"; + public override void SetDefaults() + { + base.SetDefaults(); + + Projectile.width = Projectile.height = 50; + Projectile.DamageType = DamageClass.Melee; + Projectile.timeLeft = 100; + Projectile.friendly = true; + Projectile.hostile = false; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.aiStyle = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.extraUpdates = 1; + } + bool start = false; + public override bool PreKill(int timeLeft) + { + + return base.PreKill(timeLeft); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + SeaKingsAssurance.Apply(target, Vector2.Zero); + base.OnHitNPC(target, hit, damageDone); + } + public override void AI() + { + float sc = MathHelper.Clamp(Projectile.velocity.Length() / 8f, 0f, 0.8f); + + Lighting.AddLight(Projectile.Center, new Vector3(0f, 0.2f, 0.5f)); + Projectile.ai[1]++; + if (!start) + { + Projectile.velocity *= 2f; + Projectile.ai[0] = MathHelper.ToRadians(Main.rand.NextFloat(-1.6f, 1.6f)); + Projectile.velocity = Projectile.velocity.RotatedBy(-Projectile.ai[0] * 10f); + start = true; + } + else + { + NPC npc = CalamityUtils.ClosestNPCAt(Projectile.Center, 150); + + if (npc != null) + { + float rot = Projectile.velocity.ToRotation(); + float rot2 = rot.AngleLerp(Projectile.AngleTo(npc.Center), 0.1f); + + Projectile.velocity = Projectile.velocity.RotatedBy(rot2 - rot); + } + else + { + Projectile.velocity = Projectile.velocity.RotatedBy(Projectile.ai[0] / 1.5f); + } + } + + GeneralParticleHandler.SpawnParticle( + new AltSparkParticle(Projectile.Center, Projectile.velocity * 0.1f, false, 8, sc, SeaKingsAssurance.BaseColor.MultiplyRGBA(new(1f, 1f, 1f, 0f))) + ); + + Projectile.velocity *= 0.89f; + if (Projectile.velocity.Length() < 1f) Projectile.Kill(); + } + public override bool PreDraw(ref Color lightColor) + { + Asset MainTexture = ModContent.Request("CalamityMod/Particles/VerticalSmear"); + + float vel = Projectile.velocity.Length() / 50f; + + Main.EntitySpriteDraw(MainTexture.Value, Projectile.Center - Main.screenPosition, MainTexture.Frame(), + SeaKingsAssurance.BaseColor.MultiplyRGBA(new(1f, 1f, 1f, 0f)), Projectile.velocity.ToRotation() + MathHelper.PiOver2, MainTexture.Size() * new Vector2(0.5f, 0f), new Vector2( + vel, vel * 4f + ) * 0.7f, SpriteEffects.None); + for (int i = 0; i < 5; i++) + { + Main.EntitySpriteDraw(MainTexture.Value, Projectile.Center - Main.screenPosition, MainTexture.Frame(), + SeaKingsAssurance.LightColor.MultiplyRGBA(new(1f, 1f, 1f, 0f)), Projectile.velocity.ToRotation() + MathHelper.PiOver2, MainTexture.Size() * new Vector2(0.5f, 0f), new Vector2( + vel, vel * 4f + ) * 0.4f, SpriteEffects.None); + } + + return false; + } + } +} diff --git a/Projectiles/Melee/AncientStar.cs b/Projectiles/Melee/AncientStar.cs index d798f5435c..bc1885c66b 100644 --- a/Projectiles/Melee/AncientStar.cs +++ b/Projectiles/Melee/AncientStar.cs @@ -50,11 +50,6 @@ namespace CalamityMod.Projectiles.Melee } } - if (Projectile.timeLeft < MaxTime - 5) - { - Projectile.tileCollide = true; - } - if (Timer / MaxTime > 0.25f) { Projectile.velocity *= 0.95f; diff --git a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs index cb5eb85d89..7f071091f0 100644 --- a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs @@ -35,6 +35,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.noEnchantmentVisuals = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? CanDamage() => Timer <= ParryTime && AlreadyParried == 0f; diff --git a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs index d043ba2deb..961520ed25 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using CalamityMod.Sounds; @@ -7,6 +8,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; @@ -17,7 +19,6 @@ namespace CalamityMod.Projectiles.Melee public class ArkoftheCosmosBlast : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; //Yes this is AotE sprite, but it gets changed in predraw anyways private bool initialized = false; public ref float Charge => ref Projectile.ai[0]; @@ -101,13 +102,30 @@ namespace CalamityMod.Projectiles.Melee HandleParticles(); + if (StitchProgress == 0) + { + + var p = BigRipMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * MathHelper.Lerp(0f, ThrustDisplaceRatio() * 242f, 0.5f), Vector2.Zero, 242f); + p.SizeScaling = 0f; + p.TextureToUse = TextureAssets.Projectile[Type].Value; + p.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + p.Scale = new Vector2(0.25f * ThrustDisplaceRatio(), 1f * ThrustDisplaceRatio()); + } + if (SnapTimer == 5) + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = -0.5f, Volume = 0.5f, MaxInstances = 2}, Projectile.Center); //Spawn particles when the line appears if (HoldTimer == 1) { + + var p = BigRipMetaball.SpawnParticle(Projectile.Center + Projectile.velocity * MathHelper.Lerp(0f, ThrustDisplaceRatio() * 242f, 0.5f), Vector2.Zero, 242f); + p.SizeScaling = 0.925f; + p.TextureToUse = TextureAssets.Projectile[Type].Value; + p.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + p.Scale = new Vector2(0.25f * ThrustDisplaceRatio(), 1f * ThrustDisplaceRatio()); + // Feel the power - SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound, Projectile.Center); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 7.5f) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 7.5f; + SoundEngine.PlaySound(CommonCalamitySounds.SwiftSliceSound with {Pitch = 0f, MaxInstances = 2}, Projectile.Center); + Main.LocalPlayer.SetScreenshake(7.5f); // Feel the particles for (int i = 0; i < 20; i++) @@ -163,7 +181,7 @@ namespace CalamityMod.Projectiles.Melee else if (HoldProgress <= 0.4f) { PolarStar.Time = 0; - PolarStar.Position = scissorPosition; + PolarStar.Position = scissorPosition + Projectile.velocity * SnapProgress * 150; PolarStar.Scale = Projectile.scale * 2f; } @@ -229,12 +247,6 @@ namespace CalamityMod.Projectiles.Melee Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - Texture2D sliceTex = Request("CalamityMod/Particles/BloomLine").Value; - Color sliceColor = Color.Lerp(Color.OrangeRed, Color.White, SnapProgress); - float rot = Projectile.rotation + MathHelper.PiOver2; - Vector2 sliceScale = new Vector2(0.2f * (1 - SnapProgress), ThrustDisplaceRatio() * 242f); - Main.EntitySpriteDraw(sliceTex, Projectile.Center - Main.screenPosition, null, sliceColor, rot, new Vector2(sliceTex.Width / 2f, sliceTex.Height), sliceScale, 0f, 0); - //Draw the scissors if (HoldProgress <= 0.4f) { @@ -257,48 +269,6 @@ namespace CalamityMod.Projectiles.Melee Main.EntitySpriteDraw(frontBlade, drawPosition, null, drawColor * opacity, drawRotation, drawOrigin, Projectile.scale, 0f, 0); } - //Draw the rip - if (HoldProgress > 0) - { - Texture2D lineTex = Request("CalamityMod/Particles/ThinEndedLine").Value; - - Vector2 Shake = HoldProgress > 0.2f ? Vector2.Zero : Vector2.One.RotatedByRandom(MathHelper.TwoPi) * (1 - HoldProgress * 5f) * 0.5f; - float raise = (float)Math.Sin(HoldProgress * MathHelper.PiOver2); - - Vector2 origin = new Vector2(lineTex.Width / 2f, lineTex.Height); - float ripWidth = StitchProgress < 0.75f ? 0.4f : (1 - (StitchProgress - 0.75f) * 4f) * 0.2f; - Vector2 scale = new Vector2(ripWidth, (ThrustDisplaceRatio() * 242f) / lineTex.Height); - float lineOpacity = StitchProgress < 0.75f ? 1f : 1 - (StitchProgress - 0.75f) * 4f; - - Main.EntitySpriteDraw(lineTex, Projectile.Center - Main.screenPosition + Shake, null, Color.Lerp(Color.White, Color.OrangeRed * 0.7f, raise) * lineOpacity, rot, origin, scale, SpriteEffects.None, 0); - - //Draw the stitches - if (StitchProgress > 0) - { - for (int i = 0; i < CurrentStitches; i++) - { - - float positionAlongLine = (ThrustDisplaceRatio() * 242f / (float)maxStitches * 0.5f) + MathHelper.Lerp(0f, ThrustDisplaceRatio() * 242f, i / (float)maxStitches); - Vector2 stitchCenter = Projectile.Center + Projectile.velocity * positionAlongLine; - - rot = Projectile.rotation + MathHelper.PiOver2 + StitchRotations[i]; - origin = new Vector2(lineTex.Width / 2f, lineTex.Height / 2f); - - float stitchLength = (float)Math.Sin(i / (float)(maxStitches - 1) * MathHelper.Pi) * 0.5f + 0.5f; - float stitchScale = (1f + (float)Math.Sin(MathHelper.Clamp(StitchLifetimes[i] / 7f, 0f, 1f) * MathHelper.Pi) * 0.3f) * 0.85f; - if (CurrentStitches == maxStitches) - { - stitchScale *= 1 - ((StitchTimer - (MaxTime - SnapTime - HoldTime * 0.5f) * 0.3f) / (MaxTime - SnapTime - HoldTime * 0.5f) * 0.7f) * 0.8f; - } - scale = new Vector2(0.2f, stitchLength) * stitchScale; - - Color stitchColor = Color.Lerp(Color.White, Color.CornflowerBlue * 0.7f, (float)Math.Sin(MathHelper.Clamp(StitchLifetimes[i] / 7f, 0f, 1f) * MathHelper.PiOver2)); - - Main.EntitySpriteDraw(lineTex, stitchCenter - Main.screenPosition + Shake, null, stitchColor, rot, origin, scale, SpriteEffects.None, 0); - } - } - } - Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); return false; diff --git a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs index c9e6cc4e7a..ed61618cec 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs @@ -39,6 +39,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.noEnchantmentVisuals = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.timeLeft = (int)MaxTime; } public override bool? CanDamage() => Timer <= ParryTime && AlreadyParried == 0f; @@ -106,7 +109,7 @@ namespace CalamityMod.Projectiles.Melee { if (!initialized) //Initialization { - Projectile.timeLeft = (int)MaxTime; + //Projectile.timeLeft = (int)MaxTime; SoundEngine.PlaySound(SoundID.Item84 with { Volume = SoundID.Item84.Volume * 0.3f }, Projectile.Center); // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction diff --git a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs index 65c5cce750..85f208c7fb 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using CalamityMod.Sounds; @@ -230,9 +231,7 @@ namespace CalamityMod.Projectiles.Melee { Particle snapSpark = new GenericSparkle(Projectile.Center, Owner.velocity - Utils.SafeNormalize(Projectile.velocity, Vector2.Zero), Color.White, Color.OrangeRed, Main.rand.NextFloat(1f, 2f), 10 + Main.rand.Next(10), 0.1f, 3f); GeneralParticleHandler.SpawnParticle(snapSpark); - - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; + Main.LocalPlayer.SetScreenshake(3f); if (Owner.whoAmI == Main.myPlayer) { @@ -273,6 +272,15 @@ namespace CalamityMod.Projectiles.Melee float extraRotations = (direction.ToRotation() + MathHelper.PiOver4 > Projectile.velocity.ToRotation()) ? -MathHelper.TwoPi : 0f; Projectile.rotation = MathHelper.Lerp(Projectile.velocity.ToRotation(), direction.ToRotation() + extraRotations, orientateProperly); + if (ChanceMissed == 0f && Owner.controlUseTile && ThrowCompletion > 0.99f) + { + ArkoftheCosmos sword = (Owner.HeldItem.ModItem as ArkoftheCosmos); + Projectile parrier = Main.projectile.FirstOrDefault(p => p.active && p.owner == Owner.whoAmI && p.type == ProjectileType(), null); + if (sword is not null && parrier is null) + { + int parryID = Projectile.NewProjectile(Owner.GetSource_ItemUse(sword.Item), Owner.Center, Owner.DirectionTo(Projectile.Center), ModContent.ProjectileType(), 0, 0, Owner.whoAmI); + } + } } //Sharticles @@ -435,9 +443,7 @@ namespace CalamityMod.Projectiles.Melee { if (Combo == 3f) { - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; - + Main.LocalPlayer.SetScreenshake(3f); SoundEngine.PlaySound(SoundID.Item84, Projectile.Center); Vector2 sliceDirection = Utils.SafeNormalize(direction, Vector2.One) * 40; diff --git a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs index 6c3de2de20..65c40923ae 100644 --- a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs @@ -39,6 +39,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.noEnchantmentVisuals = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? CanDamage() => Timer <= ParryTime && AlreadyParried == 0f; diff --git a/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs b/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs index 244c91ea80..5a8bc31f62 100644 --- a/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheElements_SwungBlade.cs @@ -186,9 +186,7 @@ namespace CalamityMod.Projectiles.Melee { Particle snapSpark = new GenericSparkle(Projectile.Center, Owner.velocity - Utils.SafeNormalize(Projectile.velocity, Vector2.Zero), Color.White, Color.OrangeRed, Main.rand.NextFloat(1f, 2f), 10 + Main.rand.Next(10), 0.1f, 3f); GeneralParticleHandler.SpawnParticle(snapSpark); - - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; + Main.LocalPlayer.SetScreenshake(3f); if (Owner.whoAmI == Main.myPlayer) { @@ -258,9 +256,7 @@ namespace CalamityMod.Projectiles.Melee { if (Combo == 3f) { - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; - + Main.LocalPlayer.SetScreenshake(3f); SoundEngine.PlaySound(SoundID.Item84, Projectile.Center); Vector2 sliceDirection = direction * 40; diff --git a/Projectiles/Melee/ArkoftheCosmosBlast.png b/Projectiles/Melee/ArkoftheCosmosBlast.png new file mode 100644 index 0000000000..eec8d7bf76 Binary files /dev/null and b/Projectiles/Melee/ArkoftheCosmosBlast.png differ diff --git a/Projectiles/Melee/ArkoftheCosmos_Constellation.cs b/Projectiles/Melee/ArkoftheCosmos_Constellation.cs index 796b9d43b2..b4cdf66a10 100644 --- a/Projectiles/Melee/ArkoftheCosmos_Constellation.cs +++ b/Projectiles/Melee/ArkoftheCosmos_Constellation.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee if (!Main.dedServ) { Particles.Add(particle); - particle.Type = GeneralParticleHandler.particleTypes[particle.GetType()]; + particle.Type = GeneralParticleHandler.particleIDsByTypes[particle.GetType()]; } } diff --git a/Projectiles/Melee/AtaraxiaBoom.cs b/Projectiles/Melee/AtaraxiaBoom.cs index e3aed7c831..e8a9209d6c 100644 --- a/Projectiles/Melee/AtaraxiaBoom.cs +++ b/Projectiles/Melee/AtaraxiaBoom.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Melee // instead of weaving backwards. (float)(Math.Sin(thetaDelta + theta * flowerPetalCount) + 0.5f + weaveDistanceInner) * weaveDistanceOutwardMax); - Dust dust = Dust.NewDustPerfect(Projectile.Center, 267, velocity); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2, velocity); dust.noGravity = true; dust.scale = 1.15f; dust.color = Color.Lerp(Color.DarkOrchid, Color.IndianRed, colorRando); diff --git a/Projectiles/Melee/AtaraxiaMain.cs b/Projectiles/Melee/AtaraxiaMain.cs index ca674586b8..1ed4264a41 100644 --- a/Projectiles/Melee/AtaraxiaMain.cs +++ b/Projectiles/Melee/AtaraxiaMain.cs @@ -1,8 +1,5 @@ -using CalamityMod.Items.Ammo; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Mono.Cecil; -using SteelSeries.GameSense; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -64,7 +61,7 @@ namespace CalamityMod.Projectiles.Melee if (time > 8 && Main.rand.NextBool()) { Vector2 dustvel = -Projectile.velocity; - Dust dust = Dust.NewDustPerfect(Projectile.Center, 267, dustvel * Main.rand.NextFloat(0.1f, 1.2f), 0, default, Main.rand.NextFloat(0.7f, 0.9f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2, dustvel * Main.rand.NextFloat(0.1f, 1.2f), 0, default, Main.rand.NextFloat(0.7f, 0.9f)); dust.noGravity = true; dust.color = Color.Lerp(Color.DarkOrchid, Color.IndianRed, Main.rand.NextFloat(0, 1)); } @@ -100,7 +97,7 @@ namespace CalamityMod.Projectiles.Melee { Vector2 velocity = new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.2f); float colorRando = Main.rand.NextFloat(0, 1); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity, 278, velocity * Main.rand.NextFloat(0.2f, 1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity, DustID.FireworksRGB, velocity * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.3f, 0.65f); dust.color = Color.Lerp(Color.DarkOrchid, Color.IndianRed, colorRando); diff --git a/Projectiles/Melee/AtaraxiaSide.cs b/Projectiles/Melee/AtaraxiaSide.cs index 9b4779611c..800130f55c 100644 --- a/Projectiles/Melee/AtaraxiaSide.cs +++ b/Projectiles/Melee/AtaraxiaSide.cs @@ -1,5 +1,4 @@ -using CalamityMod.Particles; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -56,7 +55,7 @@ namespace CalamityMod.Projectiles.Melee { float colorRando = Main.rand.NextFloat(0, 1); Vector2 dustvel = Projectile.ai[1] == 2 ? Projectile.velocity.RotatedBy(0.2f) : Projectile.velocity.RotatedBy(-0.2f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity, 261, -dustvel * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity, DustID.AncientLight, -dustvel * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(0.4f, 0.6f)); dust.noGravity = true; dust.color = Color.Lerp(Color.DarkOrchid, Color.IndianRed, colorRando); } diff --git a/Projectiles/Melee/BalefulHarvesterHoldout.cs b/Projectiles/Melee/BalefulHarvesterHoldout.cs index 3363445afd..19382f94d0 100644 --- a/Projectiles/Melee/BalefulHarvesterHoldout.cs +++ b/Projectiles/Melee/BalefulHarvesterHoldout.cs @@ -7,7 +7,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; @@ -46,7 +45,6 @@ namespace CalamityMod.Projectiles.Melee { Projectile.knockBack = 0; Projectile.scale = 1; - Projectile.ai[1] = -1; mousePos = Owner.Calamity().mouseWorld; aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; @@ -76,9 +74,7 @@ namespace CalamityMod.Projectiles.Melee if (!doSwing) { - for (int i = 0; i < Main.maxNPCs; i++) - Projectile.localNPCImmunity[i] = 0; - + Projectile.ResetLocalNPCHitImmunity(); Projectile.numHits = 0; mousePos = Owner.Calamity().mouseWorld; aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65f; @@ -116,7 +112,7 @@ namespace CalamityMod.Projectiles.Melee { doSwing = false; } - RotationOffset = RotationOffset.AngleLerp(MathHelper.ToRadians(45f * Projectile.ai[1] * Owner.direction), 0.2f); + RotationOffset = RotationOffset.AngleLerp(MathHelper.ToRadians(-30f * Owner.direction), 0.12f); } else { @@ -137,27 +133,24 @@ namespace CalamityMod.Projectiles.Melee if (time > (int)(timeMax * 0.66f)) { - RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(-45f * Projectile.ai[1] * Owner.direction, 1125f * -Projectile.ai[1] * Owner.direction, CalamityUtils.ExpInOutEasing(time * 3f / timeMax, 1))), 0.125f); + RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(765f * Owner.direction, 1125f * Owner.direction, CalamityUtils.ExpInOutEasing(time * 3f / timeMax, 1))), 0.1f * Owner.GetAttackSpeed()); if (!SecondIFrameReset) { SecondIFrameReset = true; - for (int i = 0; i < Main.maxNPCs; i++) - Projectile.localNPCImmunity[i] = 0; + Projectile.ResetLocalNPCHitImmunity(); } } else if (time > (int)(timeMax * 0.33f)) { - RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(-45f * Projectile.ai[1] * Owner.direction, 765f * -Projectile.ai[1] * Owner.direction, CalamityUtils.ExpInOutEasing(time * 3f / timeMax, 1))), 0.125f); + RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(405f * Owner.direction, 765f * Owner.direction, CalamityUtils.ExpInOutEasing(time * 3f / timeMax, 1))), 0.1f * Owner.GetAttackSpeed()); if (!FirstIFrameReset) { FirstIFrameReset = true; - for (int i = 0; i < Main.maxNPCs; i++) - Projectile.localNPCImmunity[i] = 0; + Projectile.ResetLocalNPCHitImmunity(); } } else - RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(-45f * Projectile.ai[1] * Owner.direction, 405f * -Projectile.ai[1] * Owner.direction, CalamityUtils.ExpInOutEasing(time * 3f / timeMax, 1))), 0.125f); - + RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(45f * Owner.direction, 405f * Owner.direction, CalamityUtils.ExpInOutEasing(time * 3f / timeMax, 1))), 0.1f * Owner.GetAttackSpeed()); if (time >= (int)(timeMax * 0.98f)) doSwing = false; diff --git a/Projectiles/Melee/BansheeHookBoom.cs b/Projectiles/Melee/BansheeHookBoom.cs index 033293a215..4339b376d0 100644 --- a/Projectiles/Melee/BansheeHookBoom.cs +++ b/Projectiles/Melee/BansheeHookBoom.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; Main.dust[bansheeDust2].noGravity = true; Main.dust[bansheeDust2].velocity *= 3f; - bansheeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); + bansheeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RedTorch, 0f, 0f, 100, default, 1.5f); Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; Main.dust[bansheeDust2].velocity *= 2f; Main.dust[bansheeDust2].noGravity = true; @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Melee for (int k = 0; k < 2; k++) { - int bansheeDust3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.7f); + int bansheeDust3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RedTorch, 0f, 0f, 0, default, 2.7f); Main.dust[bansheeDust3].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; Main.dust[bansheeDust3].noGravity = true; Main.dust[bansheeDust3].velocity *= 3f; @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Melee for (int l = 0; l < 5; l++) { - int spiritDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 180, 0f, 0f, 0, default, 1.5f); + int spiritDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonSpirit, 0f, 0f, 0, default, 1.5f); Main.dust[spiritDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; Main.dust[spiritDust].noGravity = true; Main.dust[spiritDust].velocity *= 3f; diff --git a/Projectiles/Melee/BasherHoldout.cs b/Projectiles/Melee/BasherHoldout.cs index defc0b40a2..af058d0bcc 100644 --- a/Projectiles/Melee/BasherHoldout.cs +++ b/Projectiles/Melee/BasherHoldout.cs @@ -1,20 +1,19 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Particles; +using CalamityMod.NPCs; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class BasherHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -143,7 +142,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 particleVel = new Vector2(0, 7 * -Projectile.ai[1] * Owner.direction).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)); Vector2 particlePos = Owner.Center + (new Vector2(Main.rand.Next(10, 90), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))); - Dust dust = Dust.NewDustPerfect(particlePos, 79); + Dust dust = Dust.NewDustPerfect(particlePos, DustID.Pearlwood); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.85f, 1.3f); dust.velocity = -particleVel.RotatedByRandom(0.2f); @@ -193,9 +192,9 @@ namespace CalamityMod.Projectiles.Melee if (Owner.Calamity().mouseRight) { - Owner.Calamity().GeneralScreenShakePower = 1.2f; + Owner.SetScreenshake(1.2f); - SoundStyle fire3 = new("CalamityMod/Sounds/Item/HolyFireBulletExplosion"); + SoundStyle fire3 = new("CalamityMod/Sounds/Item/DampExplosion"); SoundEngine.PlaySound(fire3 with { Volume = 0.35f, Pitch = 0.7f }, Projectile.Center); for (int i = 0; i < MathHelper.Clamp(15 - Projectile.numHits * 3, 2, 15); i++) { diff --git a/Projectiles/Melee/BladecrestOathswordThrownBlade.cs b/Projectiles/Melee/BladecrestOathswordThrownBlade.cs index 377e46ab08..500a311afe 100644 --- a/Projectiles/Melee/BladecrestOathswordThrownBlade.cs +++ b/Projectiles/Melee/BladecrestOathswordThrownBlade.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; @@ -48,6 +49,23 @@ namespace CalamityMod.Projectiles.Melee public int bounces = 0; public bool fadingOut => Projectile.timeLeft <= (Lifetime - fadeOutTime); + private Vector2 GetAimDirection() + { + if (Main.myPlayer == Projectile.owner) + { + Vector2 toMouse = (Owner.Calamity().mouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + float aimAngle = toMouse.ToRotation(); + if (Math.Abs(MathHelper.WrapAngle(aimAngle - Projectile.localAI[1])) > 0.02f) + { + Projectile.localAI[1] = aimAngle; + if (Projectile.timeLeft % 6 == 0) + Projectile.netUpdate = true; + } + return toMouse; + } + return Projectile.localAI[1].ToRotationVector2(); + } + public override void SetDefaults() { Projectile.width = 12; @@ -103,11 +121,13 @@ namespace CalamityMod.Projectiles.Melee ejectedBlade = projectile; } } - ejectedBlade.localAI[0] = 5; - ejectedBlade.ai[1] += 1000; - ejectedBlade.velocity = Projectile.velocity.RotatedByRandom(0.2f); - ejectedBlade.netUpdate = true; - ejectedBlade.netSpam = 0; + if (ejectedBlade != null) + { + ejectedBlade.localAI[0] = 5; + ejectedBlade.ai[1] += 1000; + ejectedBlade.velocity = Projectile.velocity.RotatedByRandom(0.2f); + ejectedBlade.ForceNetUpdate(); + } for (int i = 0; i < 8; i++) { @@ -132,16 +152,19 @@ namespace CalamityMod.Projectiles.Melee CurrentState &= ~State.HitTarget; } + if ((CurrentState & State.Thrown) != 0 && (CurrentState & (State.StuckInGround | State.StuckInTarget)) == 0) + Projectile.extraUpdates = 1; + float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); Projectile.spriteDirection = Projectile.direction; Vector3 Light = Color.Firebrick.ToVector3(); Lighting.AddLight(Projectile.Center, Light * 0.5f); - if (Projectile.timeLeft == Lifetime) + if (Projectile.timeLeft == Lifetime && Main.myPlayer == Projectile.owner) { // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 toMouse = (Owner.Calamity().mouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + Vector2 toMouse = GetAimDirection(); Projectile.velocity = toMouse * 14; Projectile.Center = Owner.MountedCenter + toMouse * 12f; Projectile.spriteDirection = Projectile.direction; @@ -149,6 +172,7 @@ namespace CalamityMod.Projectiles.Melee time = 0; Projectile.extraUpdates = 1; Projectile.tileCollide = true; + Projectile.netUpdate = true; } if (Projectile.velocity.X > 0) @@ -285,7 +309,8 @@ namespace CalamityMod.Projectiles.Melee public void throwAnimation() { - Owner.ChangeDir(MathF.Sign(Owner.Calamity().mouseWorld.X - Owner.Center.X)); + Vector2 aimDirection = GetAimDirection(); + Owner.ChangeDir(MathF.Sign(aimDirection.X)); float armRotation = ArmAnticipationMovement() * Owner.direction; @@ -335,7 +360,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.velocity.Length() < 8) Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 8; Projectile.velocity.Y *= 0.85f; - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center); bounces++; Projectile.timeLeft = Lifetime; } @@ -356,6 +381,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; SoundStyle stuck = new("CalamityMod/Sounds/Item/DemonSwordImpact", 2); SoundEngine.PlaySound(stuck with { Volume = 0.75f, Pitch = Main.rand.NextFloat(0.2f, 0.3f), MaxInstances = 3 }, Projectile.Center); + Projectile.netUpdate = true; } public override bool? CanDamage() @@ -405,11 +431,22 @@ namespace CalamityMod.Projectiles.Melee public override void SendExtraAI(BinaryWriter writer) { writer.Write((byte)CurrentState); + writer.Write(Projectile.rotation); + writer.Write(Projectile.localAI[1]); + writer.Write(impalePos.X); + writer.Write(impalePos.Y); + writer.Write(stuckTimer); + writer.Write((short)bounces); } public override void ReceiveExtraAI(BinaryReader reader) { CurrentState = (State)reader.ReadByte(); + Projectile.rotation = reader.ReadSingle(); + Projectile.localAI[1] = reader.ReadSingle(); + impalePos = new Vector2(reader.ReadSingle(), reader.ReadSingle()); + stuckTimer = reader.ReadInt32(); + bounces = reader.ReadInt16(); } } } diff --git a/Projectiles/Melee/BlazingPhantomBlade.cs b/Projectiles/Melee/BlazingPhantomBlade.cs index a4cc2fb971..3c316d190c 100644 --- a/Projectiles/Melee/BlazingPhantomBlade.cs +++ b/Projectiles/Melee/BlazingPhantomBlade.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.DataStructures; using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -244,7 +243,7 @@ namespace CalamityMod.Projectiles.Melee float num13 = MathHelper.Min(num3, MathHelper.Lerp(1f, fromValue, Utils.Remap(Projectile.localAI[0], 0f, 80f, 0f, 1f))); - Texture2D value = TextureAssets.Extra[98].Value; + Texture2D value = TextureAssets.Extra[ExtrasID.SharpTears].Value; SpriteEffects dir = SpriteEffects.None; Vector2 drawpos = Projectile.Center - Main.screenPosition + (Projectile.rotation + (MathHelper.Pi / (20f / 3f)) * Projectile.ai[0]).ToRotationVector2() * ((float)asset.Width * 0.5f - 4f) * num * num12; Color drawColor = new Color(255, 255, 255, 0) * Projectile.Opacity * 0.5f * num13; diff --git a/Projectiles/Melee/Blood.cs b/Projectiles/Melee/Blood.cs index d87e1880b7..d59bf6b966 100644 --- a/Projectiles/Melee/Blood.cs +++ b/Projectiles/Melee/Blood.cs @@ -1,6 +1,4 @@ -using CalamityMod.Balancing; -using System; -using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -42,16 +40,6 @@ namespace CalamityMod.Projectiles.Melee CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 600f, 6f, 20f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - int heal = (int)Math.Round(hit.Damage * 0.075); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, (int)Math.Round(hit.Damage * 0.075)); } } diff --git a/Projectiles/Melee/Blood2.cs b/Projectiles/Melee/Blood2.cs index d7a37f148f..9818a156a0 100644 --- a/Projectiles/Melee/Blood2.cs +++ b/Projectiles/Melee/Blood2.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/BloodBall.cs b/Projectiles/Melee/BloodBall.cs index f9ad15cf39..6cce44387c 100644 --- a/Projectiles/Melee/BloodBall.cs +++ b/Projectiles/Melee/BloodBall.cs @@ -19,6 +19,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.timeLeft = 200; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/BonebreakerProjectile.cs b/Projectiles/Melee/BonebreakerProjectile.cs index 765c4831b3..41c5b560a3 100644 --- a/Projectiles/Melee/BonebreakerProjectile.cs +++ b/Projectiles/Melee/BonebreakerProjectile.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class BonebreakerProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; diff --git a/Projectiles/Melee/BotanicSpear.cs b/Projectiles/Melee/BotanicSpear.cs index f42ce6103b..fb447ceb6d 100644 --- a/Projectiles/Melee/BotanicSpear.cs +++ b/Projectiles/Melee/BotanicSpear.cs @@ -1,6 +1,4 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -26,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 16; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = -1; + Projectile.penetrate = 2; Projectile.tileCollide = false; Projectile.timeLeft = TimeLeft; Projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Melee/BrimlanceHellfireExplosion.cs b/Projectiles/Melee/BrimlanceHellfireExplosion.cs index 49d5d4b713..be9e32e7ff 100644 --- a/Projectiles/Melee/BrimlanceHellfireExplosion.cs +++ b/Projectiles/Melee/BrimlanceHellfireExplosion.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Melee/BrimlanceStandingFire.cs b/Projectiles/Melee/BrimlanceStandingFire.cs index a61c779db2..b35bf7e40b 100644 --- a/Projectiles/Melee/BrimlanceStandingFire.cs +++ b/Projectiles/Melee/BrimlanceStandingFire.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - if (Projectile.ai[1] == 0f && Projectile.type >= 326 && Projectile.type <= 328) + if (Projectile.ai[1] == 0f && Projectile.type >= ProjectileID.GreekFire1 && Projectile.type <= ProjectileID.GreekFire3) { Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item13, Projectile.position); diff --git a/Projectiles/Melee/BrimlashProj.cs b/Projectiles/Melee/BrimlashProj.cs index 52d339417e..413bdb5310 100644 --- a/Projectiles/Melee/BrimlashProj.cs +++ b/Projectiles/Melee/BrimlashProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Melee/BrimstoneBoom.cs b/Projectiles/Melee/BrimstoneBoom.cs index eadf3c961e..9c3045c256 100644 --- a/Projectiles/Melee/BrimstoneBoom.cs +++ b/Projectiles/Melee/BrimstoneBoom.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/BrimstoneSwordExplosion.cs b/Projectiles/Melee/BrimstoneSwordExplosion.cs index 582e18faaf..fb469fb57b 100644 --- a/Projectiles/Melee/BrimstoneSwordExplosion.cs +++ b/Projectiles/Melee/BrimstoneSwordExplosion.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Melee/BrimstoneSwordProj.cs b/Projectiles/Melee/BrimstoneSwordProj.cs index c1b453c184..3dad5ae9a7 100644 --- a/Projectiles/Melee/BrimstoneSwordProj.cs +++ b/Projectiles/Melee/BrimstoneSwordProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Melee/BrinyTyphoonBubble.cs b/Projectiles/Melee/BrinyTyphoonBubble.cs index 3fbd52fcf1..0957b0a141 100644 --- a/Projectiles/Melee/BrinyTyphoonBubble.cs +++ b/Projectiles/Melee/BrinyTyphoonBubble.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.alpha = 255; Projectile.penetrate = -1; Projectile.timeLeft = 5; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs index e36d1e29dd..f8d4d6935c 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs @@ -70,6 +70,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.extraUpdates = 1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs index 0022918305..4f6706afe6 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs @@ -25,9 +25,6 @@ namespace CalamityMod.Projectiles.Melee public const float LungeSpeed = 16; public ref float CanBounce => ref Projectile.localAI[0]; - public override void SetStaticDefaults() - { - } public override void SetDefaults() { Projectile.DamageType = DamageClass.Melee; @@ -37,6 +34,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.extraUpdates = 1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -89,20 +88,14 @@ namespace CalamityMod.Projectiles.Melee Owner.velocity = direction.SafeNormalize(Vector2.UnitX * Owner.direction) * LungeSpeed; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(Main.player[Projectile.owner].moonLeech); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(Main.player[Projectile.owner].moonLeech); - - private void OnHitEffects(bool cannotLifesteal) + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Projectile.ForceNetUpdate(); if (Main.myPlayer != Owner.whoAmI || CanBounce == 0f) return; - if (!cannotLifesteal) //trolled - { - Owner.HealPlayer(BrokenBiomeBlade.EvilAttunement_Lifesteal); //Idk if its too much or what but at the same time its close range as fuck - } + Owner.DoLifestealDirect(target, BrokenBiomeBlade.EvilAttunement_Lifesteal, 1.25f); //Idk if its too much or what but at the same time its close range as fuck // Bounce off float bounceStrength = LungeSpeed / 2f; diff --git a/Projectiles/Melee/BrokenBiomeBlade_PureClarity.cs b/Projectiles/Melee/BrokenBiomeBlade_PureClarity.cs index 2f5da2023e..31e478ef7c 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_PureClarity.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_PureClarity.cs @@ -2,10 +2,8 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs b/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs index 5c924c1b88..02c71828d9 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_PurityProjection.cs @@ -1,7 +1,6 @@ using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; diff --git a/Projectiles/Melee/ClamCrusherFlail.cs b/Projectiles/Melee/ClamCrusherFlail.cs index 3ce47bbf54..6d1015e6c7 100644 --- a/Projectiles/Melee/ClamCrusherFlail.cs +++ b/Projectiles/Melee/ClamCrusherFlail.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.alpha = 255; Projectile.tileCollide = false; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/CometQuasherHoldout.cs b/Projectiles/Melee/CometQuasherHoldout.cs index ab6c6ec2b2..fb612dd221 100644 --- a/Projectiles/Melee/CometQuasherHoldout.cs +++ b/Projectiles/Melee/CometQuasherHoldout.cs @@ -1,5 +1,5 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -7,12 +7,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class CometQuasherHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -171,7 +172,7 @@ namespace CalamityMod.Projectiles.Melee } } - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(120, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1)); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(120, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.AliceBlue : Color.DodgerBlue; @@ -183,7 +184,7 @@ namespace CalamityMod.Projectiles.Melee Particle orb = new CustomPulse(particlePos, particleVel * Main.rand.NextFloat(0.8f, 1.2f), Main.rand.NextBool(4) ? Color.AliceBlue : Color.DodgerBlue, "CalamityMod/Particles/HealingPlus", new Vector2(1f, 1f), Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(0.8f, 1.2f), 0.2f, 23); GeneralParticleHandler.SpawnParticle(orb); - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(75, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1)); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(75, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.AliceBlue : Color.DodgerBlue; @@ -220,7 +221,7 @@ namespace CalamityMod.Projectiles.Melee if (spawnBoom) { Vector2 spawnSpot = target.Center + new Vector2(Main.rand.NextFloat(-550, 550), Main.rand.NextFloat(-750, -950)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnSpot, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 0, Projectile.owner, 0, 0, 4); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnSpot, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 0, Projectile.owner, 0, Main.rand.Next(3), 4); spawnBoom = false; } } diff --git a/Projectiles/Melee/CometQuasherMeteor.cs b/Projectiles/Melee/CometQuasherMeteor.cs index f9ab862f37..6627821de0 100644 --- a/Projectiles/Melee/CometQuasherMeteor.cs +++ b/Projectiles/Melee/CometQuasherMeteor.cs @@ -1,11 +1,8 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Renderers; using Terraria.ID; using Terraria.ModLoader; @@ -75,7 +72,7 @@ namespace CalamityMod.Projectiles.Melee } if (Main.rand.NextBool(13)) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), 278, -Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 3)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), DustID.FireworksRGB, -Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 3)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.AliceBlue : Color.DodgerBlue; @@ -87,11 +84,20 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - if (Projectile.Calamity().lineColor == 1) - tex = ModContent.Request("CalamityMod/Projectiles/Melee/CometQuasherMeteor2").Value; - if (Projectile.Calamity().lineColor == 2) - tex = ModContent.Request("CalamityMod/Projectiles/Melee/CometQuasherMeteor3").Value; + Texture2D tex; + switch (Projectile.ai[1]) + { + case 0: + default: + tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + break; + case 1: + tex = ModContent.Request("CalamityMod/Projectiles/Melee/CometQuasherMeteor2").Value; + break; + case 2: + tex = ModContent.Request("CalamityMod/Projectiles/Melee/CometQuasherMeteor3").Value; + break; + } CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.White, 1, tex); return false; diff --git a/Projectiles/Melee/CosmicDischargeFlail.cs b/Projectiles/Melee/CosmicDischargeFlail.cs index df46b60a8a..5eaf0a592f 100644 --- a/Projectiles/Melee/CosmicDischargeFlail.cs +++ b/Projectiles/Melee/CosmicDischargeFlail.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class CosmicDischargeFlail : BaseWhipProjectile, ILocalizedModType + public class CosmicDischargeFlail : BaseFlailProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public override void SetDefaults() @@ -23,10 +23,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.ignoreWater = true; + Projectile.MaxUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; + Projectile.localNPCHitCooldown = 6 * Projectile.MaxUpdates; Projectile.coldDamage = true; - Projectile.extraUpdates = 1; } public override Color SpecialDrawColor => new Color(150, 255, 255); @@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Player player = Main.player[Projectile.owner]; - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); target.AddBuff(ModContent.BuffType(), 60); if (Projectile.localAI[1] <= 0f && Projectile.owner == Main.myPlayer) { diff --git a/Projectiles/Melee/CosmicIceBurst.cs b/Projectiles/Melee/CosmicIceBurst.cs index 997501b309..379f8d6c13 100644 --- a/Projectiles/Melee/CosmicIceBurst.cs +++ b/Projectiles/Melee/CosmicIceBurst.cs @@ -115,18 +115,18 @@ namespace CalamityMod.Projectiles.Melee return new Color(150, Main.DiscoG, 255, 127); }*/ - // Only inflict Voidfrost if not spawned from Icebreaker + // Only inflict Nightwither if not spawned from Icebreaker public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.ai[2] != 1f) - target.AddBuff(ModContent.BuffType(), 420); + target.AddBuff(ModContent.BuffType(), 420); Projectile.direction = Main.player[Projectile.owner].direction; } public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (Projectile.ai[2] != 1f) - target.AddBuff(ModContent.BuffType(), 420); + target.AddBuff(ModContent.BuffType(), 420); Projectile.direction = Main.player[Projectile.owner].direction; } } diff --git a/Projectiles/Melee/CosmicShivAura.cs b/Projectiles/Melee/CosmicShivAura.cs index 43e42687bb..390c13d3d1 100644 --- a/Projectiles/Melee/CosmicShivAura.cs +++ b/Projectiles/Melee/CosmicShivAura.cs @@ -1,11 +1,3 @@ -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; diff --git a/Projectiles/Melee/CosmicShivBlade.cs b/Projectiles/Melee/CosmicShivBlade.cs index 074d2769c8..1e2714859a 100644 --- a/Projectiles/Melee/CosmicShivBlade.cs +++ b/Projectiles/Melee/CosmicShivBlade.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D texture = TextureAssets.Projectile[Type].Value; Rectangle sourceRectangle = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); Vector2 origin = sourceRectangle.Size() / 2f; float rotation = Projectile.rotation; diff --git a/Projectiles/Melee/CrescentMoonFlail.cs b/Projectiles/Melee/CrescentMoonFlail.cs index 842105dfaf..df9de73172 100644 --- a/Projectiles/Melee/CrescentMoonFlail.cs +++ b/Projectiles/Melee/CrescentMoonFlail.cs @@ -1,20 +1,31 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.DataStructures; +using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Systems.Mechanic; +using Microsoft.Build.Evaluation; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class CrescentMoonFlail : BaseWhipProjectile, ILocalizedModType + public class CrescentMoonFlail : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public int moonCounter = 6; - + public int burstStage = -1; public override void SetDefaults() { - Projectile.width = 16; - Projectile.height = 16; + Projectile.width = 50; + Projectile.height = 50; Projectile.friendly = true; Projectile.alpha = 255; Projectile.penetrate = -1; @@ -23,47 +34,183 @@ namespace CalamityMod.Projectiles.Melee Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 8; + Projectile.timeLeft = 6000; + Projectile.MaxUpdates = 2; } - public override Color SpecialDrawColor => default; - public override int ExudeDustType => 176; - public override int WhipDustType => 176; - public override int HandleHeight => 56; - public override int BodyType1StartY => 60; - public override int BodyType1SectionHeight => 22; - public override int BodyType2StartY => 86; - public override int BodyType2SectionHeight => 18; - public override int TailStartY => 108; - public override int TailHeight => 50; - public override void ExtraBehavior() + bool hasFired = false; + bool hasStarbits = false; + StarburstEntity starburst1 = null; + StarburstEntity starburst2 = null; + public override void AI() { Player player = Main.player[Projectile.owner]; - if (moonCounter > 0) - moonCounter--; - if (moonCounter <= 0 && Projectile.owner == Main.myPlayer) + player.heldProj = Projectile.whoAmI; + player.itemAnimation = 5; + player.itemTime = 5; + if (!player.channel && !hasFired) { - Vector2 vectorBruh = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f; - if (player.direction != 1) + Projectile.velocity = player.DirectionTo(player.Calamity().mouseWorld) * 25; + Projectile.Center = player.Center + Projectile.velocity * 5; + hasFired = true; + Projectile.ai[0] = 0; + hasStarbits = player.Calamity().AvaliableStarburst >= 20; + if (hasStarbits) { - vectorBruh.X = (float)player.bodyFrame.Width - vectorBruh.X; + var star1 = player.Calamity().StarburstEntities.FirstOrDefault(x => x.AICooldown <= 0 && x.value == 10,null); + if (star1 != null) + { + star1.AICooldown = 1; + var star2 = player.Calamity().StarburstEntities.FirstOrDefault(x => x.AICooldown <= 0 && x.value == 10, null); + if (star2 != null) + { + star2.AICooldown = 1; + starburst1 = star1; + starburst2 = star2; + } + } } - if (player.gravDir != 1f) - { - vectorBruh.Y = (float)player.bodyFrame.Height - vectorBruh.Y; - } - vectorBruh -= new Vector2((float)(player.bodyFrame.Width - player.width), (float)(player.bodyFrame.Height - 42)) / 2f; - Vector2 newCenter = player.RotatedRelativePoint(Main.player[Projectile.owner].position + vectorBruh, true) + Projectile.velocity; - int moonDamage = (int)(Projectile.damage * 0.18f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), newCenter.X, newCenter.Y, 0f, 0f, ModContent.ProjectileType(), moonDamage, 0f, Projectile.owner, 0f, 0f); - moonCounter = 6; } + if (Projectile.velocity == Vector2.Zero) + Projectile.velocity = player.DirectionTo(player.Calamity().mouseWorld); + if (!hasFired) + { + Projectile.velocity = Projectile.velocity.RotatedBy(0.3f * player.direction).SafeNormalize(Vector2.One) * 50f; + Projectile.Center = player.Center; + Projectile.ai[0]++; + + if (player.miscCounter % 13 == 0 && Projectile.FinalExtraUpdate()) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.Zero) * 5f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1f), 0f, Projectile.owner, 0f, 0f); + if (player.miscCounter % 20 == 0 && Projectile.FinalExtraUpdate()) + { + player.Calamity().StratusStarburst++; + } + } else + { + Projectile.ai[0]++; + if (Projectile.ai[0] == 30 && burstStage == -1 && hasStarbits && player.Calamity().StratusStarburst >= 20 && player.controlUseItem) + { + burstStage = 10; + } + if (Projectile.ai[0] == 40) + { + if (burstStage == -1) + { + for (var i = 0; i < 6; i++) + { + int moonDamage = (int)(Projectile.damage * 0.1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.TwoPi * (i / 6f + 0.5f)) * 10f, ModContent.ProjectileType(), moonDamage, 0f, Projectile.owner, 0f, 0f); + } + } else + { + burstStage = 0; + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath); + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 3), 0f, Projectile.owner, 0f, 0f); + Projectile.position = Projectile.Center; + Projectile.Size *= 7; + Projectile.Center = Projectile.position; + Projectile.damage *= 3; + Projectile.Damage(); + Projectile.damage = 0; + Projectile.position = Projectile.Center; + Projectile.Size *= 0.2f; + Projectile.Center = Projectile.position; + GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, Color.SkyBlue, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0f, 0.25f, 12)); + GeneralParticleHandler.SpawnParticle(new CustomPulse(Projectile.Center, Vector2.Zero, Color.DeepSkyBlue, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0f, 0.2f, 12)); + for (int i = 0; i < 30; i++) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); + + int dust = Dust.NewDust(Projectile.Center, 0, 0, dustType); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 7; + } + player.Calamity().StratusStarburst -= 20; + if (starburst1 != null) + player.Calamity().StarburstEntities.Remove(starburst1); + + if (starburst2 != null) + player.Calamity().StarburstEntities.Remove(starburst2); + } + } + if (burstStage > 0) + burstStage--; + if (Projectile.ai[0] > 20 && Projectile.Distance(player.Center) < 100) + Projectile.ai[0] = 501; + + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(player.Center) * 35, Projectile.ai[0] * 0.00075f); + if (Projectile.Distance(player.Center) < 32 && Projectile.ai[0] > 20) + { + Projectile.Kill(); + } + if (hasStarbits) + { + var rotation = Projectile.DirectionFrom(player.Center).ToRotation() - MathHelper.PiOver2; + float distanceMod = MathHelper.SmoothStep(0,1,MathHelper.Min(Projectile.ai[0] / 30f, 1)); + if (burstStage > 0) + distanceMod = (burstStage * 0.1f); + float playerLerpMod = MathHelper.Min(Projectile.ai[0] / 40f, 1); + if (Projectile.ai[0] <= 40) + { + if (starburst1 != null) + { + var goal = Vector2.Lerp(Main.player[Projectile.owner].Center, Projectile.Center, playerLerpMod) + new Vector2(200, 0).RotatedBy(rotation) * distanceMod; + starburst1.Velocity = starburst1.Center.DirectionTo(goal) * MathHelper.Min(goal.Distance(starburst1.Center), 64f); + starburst1.AICooldown = 2; + starburst1.Velocity *= 0.95f; + } + if (starburst2 != null) + { + var goal = Vector2.Lerp(Main.player[Projectile.owner].Center, Projectile.Center, playerLerpMod) - new Vector2(200, 0).RotatedBy(rotation) * distanceMod; + starburst2.Velocity = starburst2.Center.DirectionTo(goal) * MathHelper.Min(goal.Distance(starburst2.Center), 64f); + starburst2.AICooldown = 2; + starburst2.Velocity *= 0.95f; + } + } else if (Projectile.ai[0] <= 45) + { + if (starburst2 != null) + starburst2.Velocity *= 0.8f; + if (starburst1 != null) + starburst1.Velocity *= 0.8f; + } + } + player.direction = player.DirectionTo(Projectile.Center + Projectile.velocity).X.DirectionalSign(); + } + if (Projectile.FinalExtraUpdate() && burstStage != 0 && (Projectile.ai[0] <= 40 || !hasFired)) + { + GeneralParticleHandler.SpawnParticle(new BloomParticle(Projectile.Center + Projectile.velocity, Vector2.Zero, Color.SkyBlue, 0.45f, 0.45f, 2, false)); + } + player.SetCompositeArmFront(true,Player.CompositeArmStretchAmount.Full,player.DirectionTo(Projectile.Center + Projectile.velocity).ToRotation() - MathHelper.PiOver2); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 240); Projectile.localAI[1] = 4f; } + + public override bool PreDraw(ref Color lightColor) + { + var startPos = Main.player[Projectile.owner].Center + Main.player[Projectile.owner].DirectionTo(Projectile.Center) * 20f; + var endPos = Projectile.Center; + var rotation = Projectile.DirectionFrom(startPos).ToRotation() - MathHelper.PiOver2; + var tex = TextureAssets.Projectile[Type].Value; + + for (var i = 1; i < 50; i++) + { + + Main.EntitySpriteDraw(tex, Vector2.Lerp(startPos,endPos,i/50f) - Main.screenPosition, i % 5 == 2 ? new Rectangle(0, 60, 54, 20) : new Rectangle(0, 86, 54, 18), Color.White, rotation, ( i % 5 == 2 ? new Vector2(54, 20) : new Vector2(54, 18)) * 0.5f, Projectile.scale, SpriteEffects.None); + } + Main.EntitySpriteDraw(tex, startPos - Main.screenPosition, new Rectangle(0, 0, 54, 56), Color.White, rotation, new Vector2(54, 56) * 0.5f, Projectile.scale, SpriteEffects.None); + if (burstStage != 0) + Main.EntitySpriteDraw(tex,Projectile.Center-Main.screenPosition,new Rectangle(0,108,54,50),Color.White, rotation, new Vector2(54,50) * 0.5f,Projectile.scale,SpriteEffects.None); + return false; + } } } diff --git a/Projectiles/Melee/CrescentMoonProj.cs b/Projectiles/Melee/CrescentMoonProj.cs index 1d705276ba..8b2486a67f 100644 --- a/Projectiles/Melee/CrescentMoonProj.cs +++ b/Projectiles/Melee/CrescentMoonProj.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -25,40 +26,65 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.tileCollide = false; - Projectile.penetrate = -1; - Projectile.timeLeft = 140; + Projectile.penetrate = 2; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.localNPCHitCooldown = 60; Projectile.extraUpdates = 2; - Projectile.aiStyle = ProjAIStyleID.Sickle; - AIType = ProjectileID.DeathSickle; + Projectile.aiStyle = -1; + AIType = -1; + Projectile.timeLeft = 240 * Projectile.MaxUpdates; } public override void AI() { Lighting.AddLight(Projectile.Center, 0f, 0f, 0.6f); - if (Projectile.soundDelay == 0) + if (Projectile.soundDelay == 0 && Projectile.velocity.Length() > 0.1f) { - Projectile.soundDelay = 30 + Main.rand.Next(50); - if (Main.rand.NextBool(10)) - { - SoundEngine.PlaySound(SoundID.Item9, Projectile.position); - } + Projectile.soundDelay = 60; + SoundEngine.PlaySound(SoundID.Item9 with { Volume = 0.5f }, Projectile.position); } - CalamityUtils.HomeInOnNPC(Projectile, true, 375f, 12f, 20f); + Projectile.rotation += Projectile.direction * 0.15f; + + if (Projectile.FinalExtraUpdate()) + { + GeneralParticleHandler.SpawnParticle(new BloomParticle(Projectile.Center, Vector2.Zero, Color.SkyBlue, 0.65f, 0.65f, 2, false),true,Enums.GeneralDrawLayer.AfterProjectiles); + GeneralParticleHandler.SpawnParticle(new CustomSpark(Projectile.Center, Vector2.UnitX.RotatedBy(Projectile.rotation) * 0.1f, "CalamityMod/Projectiles/Melee/CrescentMoonProj", false, 2, 1f, Color.White, Vector2.One, false), false, Enums.GeneralDrawLayer.AfterProjectiles); + } + + Projectile.velocity *= 0.965f; + if (Projectile.timeLeft < 225 * Projectile.MaxUpdates) + CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 12f, 20f, true); + } + + public override bool? CanHitNPC(NPC target) + { + if (target.CanBeChasedBy(Projectile, false) && target.Calamity().IsArmored()) + return false; + return base.CanHitNPC(target); + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); + + int dust = Dust.NewDust(Projectile.Center, 0, 0, dustType); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 2; + } } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } } } diff --git a/Projectiles/Melee/CrystylCrusherRay.cs b/Projectiles/Melee/CrystylCrusherRay.cs index fd9454da63..9e308d1d6f 100644 --- a/Projectiles/Melee/CrystylCrusherRay.cs +++ b/Projectiles/Melee/CrystylCrusherRay.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Melee { Projectile.width = 10; Projectile.height = 10; - Projectile.scale = 1.5f; + Projectile.scale = 7f; Projectile.friendly = true; Projectile.penetrate = -1; Projectile.tileCollide = false; @@ -67,33 +67,32 @@ namespace CalamityMod.Projectiles.Melee Vector2 maxLength = owner.ClampedMouseWorld() - owner.Center; DrawLaser(Terraria.GameContent.TextureAssets.Projectile[Type].Value, owner.Center, - Projectile.velocity, 15f, Projectile.damage, -MathHelper.PiOver2, Projectile.scale, maxLength.Length(), new Color(Main.DiscoR, 0, 255), (int)MOVE_DISTANCE); + Projectile.velocity, 15f, -MathHelper.PiOver2, Projectile.scale, maxLength.Length(), new Color(Main.DiscoR, 0, 255), (int)MOVE_DISTANCE); } return false; } // The core function of drawing a laser - public void DrawLaser(Texture2D texture, Vector2 start, Vector2 unit, float step, int damage, float rotation = 0f, float scale = 1f, float maxDist = 2000f, Color color = default(Color), int transDist = 50) + public void DrawLaser(Texture2D texture, Vector2 start, Vector2 unit, float step, float rotation = 0f, float scale = 1f, float maxDist = 2000f, Color color = default, int transDist = 50) { float r = unit.ToRotation() + rotation; // Draws the laser 'body' for (float i = transDist; i <= Distance; i += step) { - Color c = new Color(Main.DiscoR, 0, 255); var origin = start + i * unit; Main.EntitySpriteDraw(texture, origin - Main.screenPosition, - new Rectangle(0, 26, 28, 26), i < transDist ? Color.Transparent : c, r, - new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + new Rectangle(0, 26, 28, 26), i < transDist ? Color.Transparent : color, r, + new Vector2(28 * .5f, 26 * .5f), MathHelper.Lerp(1f, scale, i / Distance), 0, 0); } // Draws the laser 'tail' Main.EntitySpriteDraw(texture, start + unit * (transDist - step) - Main.screenPosition, - new Rectangle(0, 0, 28, 26), new Color(Main.DiscoR, 0, 255), r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + new Rectangle(0, 0, 28, 26), color, r, new Vector2(28 * .5f, 26 * .5f), 1f, 0, 0); // Draws the laser 'head' Main.EntitySpriteDraw(texture, start + (Distance + step) * unit - Main.screenPosition, - new Rectangle(0, 52, 28, 26), new Color(Main.DiscoR, 0, 255), r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); + new Rectangle(0, 52, 28, 26), color, r, new Vector2(28 * .5f, 26 * .5f), scale, 0, 0); } // Change the way of collision check of the projectile @@ -119,7 +118,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.timeLeft == 300) SoundEngine.PlaySound(CrystylCrusher.ChargeSound, player.Center); - Projectile.position = player.Center + Projectile.velocity * MOVE_DISTANCE; + Projectile.Center = player.Center + Projectile.velocity * MOVE_DISTANCE; Projectile.timeLeft = 2; // By separating large AI into methods it becomes very easy to see the flow of the AI in a broader sense @@ -232,6 +231,7 @@ namespace CalamityMod.Projectiles.Melee /* * Update CutTiles so the laser will cut tiles (like grass) */ + public override bool? CanCutTiles() => IsAtMaxCharge ? null : false; public override void CutTiles() { DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; @@ -244,11 +244,11 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.owner == Main.myPlayer) { Vector2 destroyVector = Projectile.Center + Projectile.velocity * (Distance - MOVE_DISTANCE); - int threeMod = 3; - int mineXLeft = (int)(destroyVector.X / 16f - threeMod); - int mineXRight = (int)(destroyVector.X / 16f + threeMod); - int mineXUp = (int)(destroyVector.Y / 16f - threeMod); - int mineXDown = (int)(destroyVector.Y / 16f + threeMod); + int radius = 7; + int mineXLeft = (int)(destroyVector.X / 16f - radius); + int mineXRight = (int)(destroyVector.X / 16f + radius); + int mineXUp = (int)(destroyVector.Y / 16f - radius); + int mineXDown = (int)(destroyVector.Y / 16f + radius); if (mineXLeft < 0) { mineXLeft = 0; @@ -273,7 +273,7 @@ namespace CalamityMod.Projectiles.Melee float destroyTileX = Math.Abs(i - destroyVector.X / 16f); float destroyTileY = Math.Abs(j - destroyVector.Y / 16f); double destroyTileArea = Math.Sqrt(destroyTileX * destroyTileX + destroyTileY * destroyTileY); - if (destroyTileArea < threeMod) + if (destroyTileArea < radius) { if (Main.tile[i, j] != null && Main.tile[i, j].HasTile) { diff --git a/Projectiles/Melee/Cyclone.cs b/Projectiles/Melee/Cyclone.cs index 449613f3d8..44797b6574 100644 --- a/Projectiles/Melee/Cyclone.cs +++ b/Projectiles/Melee/Cyclone.cs @@ -11,7 +11,8 @@ namespace CalamityMod.Projectiles.Melee public class Cyclone : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - public int dustvortex = 0; + public int dustVortex = 0; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 6; @@ -36,33 +37,31 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Projectile.ai[0]++; - Projectile.ai[1]++; - - //Code so it doesnt collide on tiles instantly - if (Projectile.ai[0] >= 12) - Projectile.tileCollide = true; + // Only begin colliding with tiles when the projectile is not inside tiles + CalamityUtils.PreventTileCollisionUntilHitboxIsOutsideOfTiles(Projectile); Projectile.rotation += 2.5f; + Projectile.alpha -= 5; + Projectile.ai[1] += 1f; if (Projectile.alpha < 50) { Projectile.alpha = 50; - if (Projectile.ai[1] >= 15) + if (Projectile.ai[1] >= 15f) { - for (int i = 1; i <= 6; i++) { - Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(dustvortex)); - int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f); + Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(dustVortex)); + int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f); Main.dust[d].noGravity = true; Main.dust[d].velocity = dustspeed; - dustvortex += 60; + dustVortex += 60; } - dustvortex -= 355; - Projectile.ai[1] = 0; + dustVortex -= 355; + Projectile.ai[1] = 0f; } } + float num472 = Projectile.Center.X; float num473 = Projectile.Center.Y; float num474 = 600f; @@ -77,30 +76,20 @@ namespace CalamityMod.Projectiles.Melee if (num478 < num474) { if (npc.position.X < num472) - { npc.velocity.X += 0.05f; - } else - { npc.velocity.X -= 0.05f; - } + if (npc.position.Y < num473) - { npc.velocity.Y += 0.05f; - } else - { npc.velocity.Y -= 0.05f; - } } } } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(204, 255, 255, Projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(204, 255, 255, Projectile.alpha); public override bool PreDraw(ref Color lightColor) { @@ -115,7 +104,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i <= 360; i += 3) { Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(i)); - int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f); + int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f); Main.dust[d].noGravity = true; Main.dust[d].position = Projectile.Center; Main.dust[d].velocity = dustspeed; diff --git a/Projectiles/Melee/DNA.cs b/Projectiles/Melee/DNA.cs deleted file mode 100644 index 671209f27b..0000000000 --- a/Projectiles/Melee/DNA.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class DNA : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - - public static int TotalSegments = 10; - - public override void SetDefaults() - { - Projectile.width = 22; - Projectile.height = 72; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = -1; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 6; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.ai[1] == 0f) - { - Projectile.alpha -= 100; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.ai[1] = 1f; - - // This projectile normally does not move by itself, so this will manually move it one time only - // This is only for the first segment - if (Projectile.ai[0] == 0f) - { - Projectile.ai[0]++; - Projectile.position += Projectile.velocity; - } - - // Spawn the next segment - if (Main.myPlayer == Projectile.owner && Projectile.ai[0] < TotalSegments) - { - int nextSegment = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Projectile.velocity, Projectile.velocity, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, Projectile.ai[0] + 1f); - NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, nextSegment); - } - } - } - else // Begin fading out - { - int AlphaPerFrame = 15; - Projectile.alpha += AlphaPerFrame; - if (Projectile.alpha == AlphaPerFrame * 14) - { - for (int i = 0; i < 3; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.BoneTorch, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f, 200, default, 1f); - dust.noGravity = true; - dust.velocity *= 0.5f; - } - } - - if (Projectile.alpha >= 255) - Projectile.Kill(); - } - if (Main.rand.NextBool(10)) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BoneTorch, Projectile.velocity.X * 0.005f, Projectile.velocity.Y * 0.005f); - } - - // This is essential for Vilethorn-type projectiles, as velocity is a stored parameter and isn't supposed to actually move the projectile - public override bool ShouldUpdatePosition() => false; - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox); - - public override void OnKill(int timeLeft) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BoneTorch, Projectile.oldVelocity.X * 0.005f, Projectile.oldVelocity.Y * 0.005f); - } - } -} diff --git a/Projectiles/Melee/DNA.png b/Projectiles/Melee/DNA.png deleted file mode 100644 index 67167a046b..0000000000 Binary files a/Projectiles/Melee/DNA.png and /dev/null differ diff --git a/Projectiles/Melee/DarkBall.cs b/Projectiles/Melee/DarkBall.cs index 93c4930826..e0c9b5272e 100644 --- a/Projectiles/Melee/DarkBall.cs +++ b/Projectiles/Melee/DarkBall.cs @@ -20,6 +20,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.timeLeft = 200; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/DarkBeam.cs b/Projectiles/Melee/DarkBeam.cs index b4e4995aaa..8f22487732 100644 --- a/Projectiles/Melee/DarkBeam.cs +++ b/Projectiles/Melee/DarkBeam.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/DarkIceZero.cs b/Projectiles/Melee/DarkIceZero.cs index ea6cc9d671..4c06f168f6 100644 --- a/Projectiles/Melee/DarkIceZero.cs +++ b/Projectiles/Melee/DarkIceZero.cs @@ -5,7 +5,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Melee { diff --git a/Projectiles/Melee/DarklightGreatswordSlash.cs b/Projectiles/Melee/DarklightGreatswordSlash.cs index c3fb36562c..f77714369d 100644 --- a/Projectiles/Melee/DarklightGreatswordSlash.cs +++ b/Projectiles/Melee/DarklightGreatswordSlash.cs @@ -1,8 +1,5 @@ -using System; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Melee/DeathsAscensionSwing.cs b/Projectiles/Melee/DeathsAscensionSwing.cs index 2a229ebcaf..36f9c36aee 100644 --- a/Projectiles/Melee/DeathsAscensionSwing.cs +++ b/Projectiles/Melee/DeathsAscensionSwing.cs @@ -176,8 +176,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item165 with { Pitch = -1 }, Projectile.Center); Projectile.ai[2] = 40; float screenShakePower = 3 * Utils.GetLerpValue(1300f, 0f, target.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; + Main.LocalPlayer.SetScreenshake(screenShakePower); } } } diff --git a/Projectiles/Melee/DepthCrusherProjectile.cs b/Projectiles/Melee/DepthCrusherProjectile.cs index 7ef793f9d0..b51c8ece9d 100644 --- a/Projectiles/Melee/DepthCrusherProjectile.cs +++ b/Projectiles/Melee/DepthCrusherProjectile.cs @@ -1,9 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Ranged; -using Humanizer; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Melee/DepthCrusherSplitProjectile.cs b/Projectiles/Melee/DepthCrusherSplitProjectile.cs index 4cbdba0560..0ad06a907d 100644 --- a/Projectiles/Melee/DepthCrusherSplitProjectile.cs +++ b/Projectiles/Melee/DepthCrusherSplitProjectile.cs @@ -1,10 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Particles; -using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Melee/DevilsDevastationHoldout.cs b/Projectiles/Melee/DevilsDevastationHoldout.cs index 6f506700ea..3f526d4002 100644 --- a/Projectiles/Melee/DevilsDevastationHoldout.cs +++ b/Projectiles/Melee/DevilsDevastationHoldout.cs @@ -1,14 +1,13 @@ using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Cooldowns; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Packets.Entities; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -23,6 +22,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class DevilsDevastationHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -52,8 +52,10 @@ namespace CalamityMod.Projectiles.Melee public bool willDie = false; public bool hasLaunchedBlades = false; public bool swooshFade = false; + private int lastSwingId; public NPC lastHitTarget = null; + private int lastHitTargetIndex = -1; public int postSwingCooldownMax => (int)(useAnim * 0.65f); public override void SetDefaults() { @@ -62,6 +64,14 @@ namespace CalamityMod.Projectiles.Melee Projectile.localNPCHitCooldown = -1; Projectile.DamageType = TrueMeleeDamageClass.Instance; } + public override void OnSpawn(IEntitySource source) + { + base.OnSpawn(source); + // This is needed because EntitySource_ItemUse always sets Projectile.originalDamage to the item's damage, + // regardless of the value passed into the damage argument of NewProjectile. + // This results in continuous updating damage resetting the damage. + Projectile.originalDamage *= 15; + } public override void WhenSpawned() { IgnoreActiveAnimation = true; @@ -70,11 +80,26 @@ namespace CalamityMod.Projectiles.Melee Projectile.knockBack = 0; Projectile.scale = 1.15f; Projectile.ai[1] = -1; + bool isOwner = Main.myPlayer == Projectile.owner; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - mousePos = Owner.Calamity().mouseWorld; - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + if (isOwner) + { + mousePos = Owner.Calamity().mouseWorld; + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + Projectile.netUpdate = true; + } + else + { + Vector2 syncedDelta = Owner.Calamity().mouseWorldDeltaFromPlayer; + if (syncedDelta.LengthSquared() > 0.001f) + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65f; + else + aimVel = Vector2.UnitX * Owner.direction * 65f; + mousePos = Owner.Center - aimVel; + } useAnim = (int)(Owner.HeldItem.useAnimation / Owner.GetTotalAttackSpeed()); postSwingCooldown = postSwingCooldownMax / 2; + lastSwingId = (int)Projectile.ai[0]; if (mousePos.X < Owner.Center.X) Owner.direction = -1; else Owner.direction = 1; @@ -86,7 +111,7 @@ namespace CalamityMod.Projectiles.Melee Owner.Calamity().demonSwordKillMode = false; if (lastHitTarget != null && lastHitTarget.life > 0 && lastHitTarget.active && Owner.HeldItem.type == AssignedItemID && Main.myPlayer == Projectile.owner) { - Owner.Calamity().GeneralScreenShakePower = 12.5f; + Owner.SetScreenshake(12.5f); Particle blastRing = new CustomPulse(lastHitTarget.Center, Vector2.Zero, clr, "CalamityMod/Particles/HighResHollowCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10, 10), 0.05f, 0.6f, 20, true); GeneralParticleHandler.SpawnParticle(blastRing); for (int i = 0; i < 4; i++) @@ -94,11 +119,12 @@ namespace CalamityMod.Projectiles.Melee Vector2 vel = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 2; Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), lastHitTarget.Center, vel.RotatedBy(MathHelper.ToRadians(45)), ModContent.ProjectileType(), 0, 0f, Owner.whoAmI, 1, 0); } - Projectile strike = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), lastHitTarget.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 2.5f), 0f, Owner.whoAmI, lastHitTarget.whoAmI, 0); + Projectile strike = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), lastHitTarget.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 0f, Owner.whoAmI, lastHitTarget.whoAmI, 0); + strike.DamageType = DamageClass.Melee; SoundStyle dieSound = new("CalamityMod/Sounds/Item/LanceofDestinyStrong"); SoundEngine.PlaySound(dieSound with { Volume = 0.9f, Pitch = 0.3f }, lastHitTarget.Center); - int bonusDamage = 4500; + int bonusDamage = 4000; if (lastHitTarget.Calamity().demonicFlamesBonusDamage <= bonusDamage) { lastHitTarget.Calamity().demonicFlamesBonusDamage = bonusDamage; @@ -109,32 +135,66 @@ namespace CalamityMod.Projectiles.Melee } public override void UseStyle() { + bool isOwner = Main.myPlayer == Projectile.owner; bool hasKillMode = Owner.Calamity().cooldowns.TryGetValue(KillMode.ID, out CooldownInstance killModeCD); - if (SoundEngine.TryGetActiveSound(SoundSlot, out var Sound) && Sound.IsPlaying && lastHitTarget != null) - Sound.Position = lastHitTarget.Center; + if (!isOwner) + { + Vector2 syncedDelta = Owner.Calamity().mouseWorldDeltaFromPlayer; + if (syncedDelta.LengthSquared() > 0.001f) + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65f; + } - if ((Main.mouseLeft || (hasKillMode && killModeCD.timeLeft == KillMode.cooldownMax + 1)) && holding && postSwingCooldown == 0) + if (lastHitTargetIndex >= 0) + { + NPC syncedTarget = Main.npc[lastHitTargetIndex]; + if (syncedTarget != null && syncedTarget.active && syncedTarget.life > 0) + lastHitTarget = syncedTarget; + } + + if (isOwner) + { + bool shouldStartSwing = (Main.mouseLeft || (hasKillMode && killModeCD.timeLeft == KillMode.cooldownMax + 1)) && holding && postSwingCooldown == 0; + if (shouldStartSwing) + { + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + Projectile.ai[0] += 1f; + Projectile.netUpdate = true; + } + } + + int swingId = (int)Projectile.ai[0]; + if (swingId != lastSwingId && holding && postSwingCooldown == 0) { Animation = (int)(useAnim * 0.7f); holding = false; - killModeCD.timeLeft = KillMode.cooldownMax; - Owner.Calamity().killModeCooldown = KillMode.cooldownMax - 1; + if (isOwner) + { + killModeCD.timeLeft = KillMode.cooldownMax; + Owner.Calamity().killModeCooldown = KillMode.cooldownMax - 1; + } swingCount++; + lastSwingId = swingId; } + + if (SoundEngine.TryGetActiveSound(SoundSlot, out var Sound) && Sound.IsPlaying && lastHitTarget != null) + Sound.Position = lastHitTarget.Center; if (postSwingCooldown > 0) postSwingCooldown--; else if (willDie) { - if (hasKillMode) - killModeCD.timeLeft = KillMode.cooldownMax; - Owner.Calamity().killModeCooldown = KillMode.cooldownMax; + if (isOwner) + { + if (hasKillMode) + killModeCD.timeLeft = KillMode.cooldownMax; + Owner.Calamity().killModeCooldown = KillMode.cooldownMax; + Owner.Calamity().demonSwordKillMode = false; + } DrawUnconditionally = false; Projectile.Kill(); - Owner.Calamity().demonSwordKillMode = false; return; } - if (killModeCD.timeLeft < KillMode.cooldownMax) + if (isOwner && killModeCD.timeLeft < KillMode.cooldownMax) { killModeCD.timeLeft = KillMode.cooldownMax; Owner.Calamity().killModeCooldown = KillMode.cooldownMax; @@ -147,11 +207,14 @@ namespace CalamityMod.Projectiles.Melee AnimationProgress = Animation % useAnim; + if (isOwner && !holding && Main.netMode != NetmodeID.SinglePlayer && (int)Animation % 3 == 0) + Projectile.netUpdate = true; + if (CanHit || postSwing) mousePos = Owner.Center - aimVel; else { - mousePos = Owner.Calamity().mouseWorld; + mousePos = isOwner ? Owner.Calamity().mouseWorld : (Owner.Center - aimVel); } if (CanHit && !swooshFade) @@ -169,8 +232,15 @@ namespace CalamityMod.Projectiles.Melee Projectile.numHits = 0; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - mousePos = Owner.Calamity().mouseWorld; - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + if (isOwner) + { + mousePos = Owner.Calamity().mouseWorld; + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + } + else + { + mousePos = Owner.Center - aimVel; + } CanHit = false; if (mousePos.X < Owner.Center.X) Owner.direction = -1; else Owner.direction = 1; @@ -179,8 +249,10 @@ namespace CalamityMod.Projectiles.Melee finalFlip = false; playSwingSound = true; hasLaunchedBlades = false; - if (!Owner.Calamity().demonSwordKillMode && postSwingCooldown == 0) + if (isOwner && !Owner.Calamity().demonSwordKillMode && postSwingCooldown == 0) { + if (!willDie) + Projectile.netUpdate = true; willDie = true; if (lastHitTarget != null) { @@ -226,7 +298,8 @@ namespace CalamityMod.Projectiles.Melee if (holding) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + if (isOwner) + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; CanHit = false; postSwing = false; RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(120f * Projectile.ai[1] * Owner.direction * (1 + (Utils.GetLerpValue(useAnim * 0.7f, useAnim, Animation, true)) * 0.35f)), 0.2f); @@ -248,7 +321,8 @@ namespace CalamityMod.Projectiles.Melee SoundStyle swing2 = new("CalamityMod/Sounds/Item/HeavySwing"); SoundEngine.PlaySound(swing2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(0.2f, 0.3f) }, Projectile.Center); playSwingSound = false; - Owner.Calamity().demonSwordKillMode = false; + if (isOwner) + Owner.Calamity().demonSwordKillMode = false; } if (time > (int)(timeMax * 0.2f) && time < (int)(timeMax * 0.9f)) CanHit = true; @@ -298,11 +372,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.numHits -= 1; if (target != null && target.life > 0 && target.active) + { lastHitTarget = target; + lastHitTargetIndex = target.whoAmI; + if (Main.myPlayer == Projectile.owner) + Projectile.netUpdate = true; + } bool hasKillMode = Owner.Calamity().cooldowns.TryGetValue(KillMode.ID, out CooldownInstance killModeCD); - int bonusDamage = 4500; + int bonusDamage = 4000; if (target.Calamity().demonicFlamesBonusDamage <= bonusDamage) { target.Calamity().demonicFlamesBonusDamage = bonusDamage; @@ -363,7 +442,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits == 0) { - Owner.Calamity().GeneralScreenShakePower = 12f; + Owner.SetScreenshake(12f); for (int i = 0; i < 5; i++) GeneralParticleHandler.SpawnParticle(new CustomSpark(target.Center + launchVel * 15, launchVel.RotatedBy((0.15f - 0.05f * i) * (i % 2 == 0 ? -1 : 1)) * (10 + 10 * i), "CalamityMod/Particles/DemonSigilParticle", false, 11, 0.7f - 0.15f * i, Main.rand.NextBool() ? clr : Color.MediumOrchid, new Vector2(1.5f, 1), extraRotation: MathHelper.ToRadians(i % 2 == 0 ? 90 : 0), shrinkSpeed: (i % 2 == 0 ? -0.8f : 0.8f))); @@ -387,7 +466,7 @@ namespace CalamityMod.Projectiles.Melee float minMult = 0.35f; int hitsToMinMult = 8; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= damageMult * (Owner.Calamity().mouseRight ? 2.5f : 1); + modifiers.SourceDamage *= damageMult; } public override bool PreDraw(ref Color lightColor) { @@ -430,5 +509,26 @@ namespace CalamityMod.Projectiles.Melee public override void ResetStyle() { } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(willDie); + writer.Write7BitEncodedInt(useAnim); + writer.Write7BitEncodedInt(lastHitTargetIndex); + writer.Write7BitEncodedInt(postSwingCooldown); + writer.WriteVector2(aimVel); + writer.Write(Animation); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + willDie = reader.ReadBoolean(); + useAnim = reader.Read7BitEncodedInt(); + lastHitTargetIndex = reader.Read7BitEncodedInt(); + postSwingCooldown = reader.Read7BitEncodedInt(); + aimVel = reader.ReadVector2(); + Animation = reader.ReadSingle(); + mousePos = Owner.Center - aimVel; + } } } diff --git a/Projectiles/Melee/DevilsDevastationThrownBlade.cs b/Projectiles/Melee/DevilsDevastationThrownBlade.cs index 4fc376974d..2daec84626 100644 --- a/Projectiles/Melee/DevilsDevastationThrownBlade.cs +++ b/Projectiles/Melee/DevilsDevastationThrownBlade.cs @@ -1,6 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; +using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Packets.Entities; @@ -12,7 +12,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.IO; using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee @@ -23,7 +22,7 @@ namespace CalamityMod.Projectiles.Melee public override string Texture => "CalamityMod/Items/Weapons/Melee/DevilsDevastation"; public int ChargeupTime => (int)Projectile.localAI[2]; - public int Lifetime = 180; + public int Lifetime = 300; public float OverallProgress => 1 - Projectile.timeLeft / (float)Lifetime; public float ThrowProgress => 1 - Projectile.timeLeft / (float)(Lifetime); public float ChargeProgress => 1 - (Projectile.timeLeft - Lifetime) / (float)(ChargeupTime); @@ -37,7 +36,7 @@ namespace CalamityMod.Projectiles.Melee public Color clr = Color.Lerp(Color.DeepPink, Color.Orange, 0.5f); public Color usedColor = Color.White; public bool thrown = false; - public int fadeOutTime = 120; + public int fadeOutTime = 240; public bool stuckInTarget = false; public int stuckTimer = 0; public bool exitedTarget = false; @@ -46,6 +45,26 @@ namespace CalamityMod.Projectiles.Melee public int bounces = 0; public Vector2 tipPosition = Vector2.Zero; public bool fadingOut => Projectile.timeLeft <= (Lifetime - fadeOutTime); + private bool visualChargeInitialized = false; + private int visualChargeTimer = 0; + private int visualChargeTime = 0; + + private Vector2 GetAimDirection() + { + if (Main.myPlayer == Projectile.owner) + { + Vector2 toMouse = (Main.MouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + float aimAngle = toMouse.ToRotation(); + if (Math.Abs(MathHelper.WrapAngle(aimAngle - Projectile.localAI[1])) > 0.02f) + { + Projectile.localAI[1] = aimAngle; + if (Projectile.timeLeft % 6 == 0) + Projectile.netUpdate = true; + } + return toMouse; + } + return Projectile.localAI[1].ToRotationVector2(); + } public override void SetDefaults() { Projectile.width = 35; @@ -60,6 +79,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.noEnchantmentVisuals = true; } + public override void OnSpawn(Terraria.DataStructures.IEntitySource source) + { + if (Main.myPlayer == Projectile.owner) + { + Vector2 toMouse = (Owner.Calamity().mouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + Projectile.localAI[1] = toMouse.ToRotation(); + Projectile.netUpdate = true; + } + } + public override bool ShouldUpdatePosition() { return (ChargeProgress >= 1 && !stuckInGround && !stuckInTarget); @@ -68,10 +97,25 @@ namespace CalamityMod.Projectiles.Melee //Swing animation keys public CurveSegment pullback = new CurveSegment(EasingType.PolyOut, 0f, 0f, MathHelper.PiOver4 * -1.2f, 2); public CurveSegment throwout = new CurveSegment(EasingType.PolyOut, 0.7f, MathHelper.PiOver4 * -1.2f, MathHelper.PiOver4 * 1.2f + MathHelper.PiOver2, 3); - internal float ArmAnticipationMovement() => PiecewiseAnimation(ChargeProgress, new CurveSegment[] { pullback, throwout }); + internal float ArmAnticipationMovement(float progress) => PiecewiseAnimation(progress, new CurveSegment[] { pullback, throwout }); public override void AI() { + bool isOwner = Main.myPlayer == Projectile.owner; + if (!visualChargeInitialized && !isOwner) + { + int fallbackCharge = (int)MathHelper.Clamp((Owner.HeldItem.useTime / 2.8f), 1, 100); + visualChargeTime = (int)(Projectile.localAI[2] > 0f ? Projectile.localAI[2] : fallbackCharge); + visualChargeTimer = visualChargeTime; + visualChargeInitialized = true; + } + + if (!thrown && ChargeProgress >= 1f) + thrown = true; + + if (thrown && !stuckInGround && !stuckInTarget && !exitedTarget) + Projectile.extraUpdates = 3; + float rate = (Main.GlobalTimeWrappedHourly + time * 3) * 2; List eColors = new List() { @@ -89,10 +133,10 @@ namespace CalamityMod.Projectiles.Melee Vector3 Light = Color.MediumOrchid.ToVector3(); Lighting.AddLight(Projectile.Center, Light * 0.85f); - if (Projectile.timeLeft == Lifetime) + if (Projectile.timeLeft == Lifetime && Main.myPlayer == Projectile.owner) { // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 toMouse = (Main.MouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + Vector2 toMouse = GetAimDirection(); Projectile.velocity = toMouse * 14; Projectile.Center = Owner.MountedCenter + toMouse * 30f; Projectile.spriteDirection = Projectile.direction; @@ -131,7 +175,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity *= 0.01f; stabbedTarget.Calamity().demonSwordImpales--; stuckInTarget = false; - fadeOutEffect(); + FadeOutEffect(); } Projectile.Center = stabbedTarget.Center + impalePos; @@ -157,7 +201,7 @@ namespace CalamityMod.Projectiles.Melee } if (fadingOut) - fadeOutEffect(); + FadeOutEffect(); } if (!fadingOut && !stuckInTarget && !stuckInGround && ChargeProgress >= 1) { @@ -198,9 +242,16 @@ namespace CalamityMod.Projectiles.Melee } //Anticipation animation. Make the player look like they're holding the item - if (ChargeProgress < 1) + float chargeProgress = ChargeProgress; + bool canVisualCharge = !isOwner && Projectile.velocity.LengthSquared() < 0.01f && visualChargeTimer > 0; + if (canVisualCharge) { - throwAnimation(); + chargeProgress = 1f - (visualChargeTimer / (float)visualChargeTime); + visualChargeTimer--; + } + if (chargeProgress < 1f) + { + ThrowAnimation(chargeProgress); if (ChargeProgress >= 0.6f && time == 0) { SoundStyle swing = new("CalamityMod/Sounds/Item/DemonSwordSwing", 2); @@ -212,7 +263,8 @@ namespace CalamityMod.Projectiles.Melee else time++; } - public void fadeOutEffect() + + public void FadeOutEffect() { Projectile.tileCollide = false; if (Projectile.timeLeft > Lifetime - fadeOutTime) @@ -231,11 +283,12 @@ namespace CalamityMod.Projectiles.Melee dust.velocity += Projectile.velocity; } } - public void throwAnimation() + public void ThrowAnimation(float chargeProgress) { - Owner.ChangeDir(MathF.Sign(Main.MouseWorld.X - Owner.Center.X)); + Vector2 aimDirection = GetAimDirection(); + Owner.ChangeDir(MathF.Sign(aimDirection.X)); - float armRotation = ArmAnticipationMovement() * Owner.direction; + float armRotation = ArmAnticipationMovement(chargeProgress) * Owner.direction; Owner.heldProj = Projectile.whoAmI; Projectile.spriteDirection = Owner.direction; @@ -364,25 +417,43 @@ namespace CalamityMod.Projectiles.Melee return false; } - /* public override void SendExtraAI(BinaryWriter writer) { - writer.Write(Projectile.timeLeft); - writer.Write(Projectile.rotation); - writer.Write(Projectile.localAI[2]); - writer.Write(Projectile.localAI[0]); + byte state = 0; + if (thrown) + state |= 1; + if (stuckInTarget) + state |= 2; + if (exitedTarget) + state |= 4; + if (stuckInGround) + state |= 8; - writer.WriteFlags(stuckInTarget, thrown); + writer.Write(state); + writer.Write(Projectile.rotation); + writer.Write(Projectile.localAI[0]); + writer.Write(Projectile.localAI[1]); + writer.Write(Projectile.localAI[2]); + writer.Write(impalePos.X); + writer.Write(impalePos.Y); + writer.Write(stuckTimer); + writer.Write((short)bounces); } public override void ReceiveExtraAI(BinaryReader reader) { - Projectile.timeLeft = reader.Read(); - Projectile.rotation = reader.ReadSingle(); - Projectile.localAI[2] = reader.ReadSingle(); - Projectile.localAI[0] = reader.ReadSingle(); + byte state = reader.ReadByte(); + thrown = (state & 1) != 0; + stuckInTarget = (state & 2) != 0; + exitedTarget = (state & 4) != 0; + stuckInGround = (state & 8) != 0; - reader.ReadFlags(out stuckInTarget, out thrown); + Projectile.rotation = reader.ReadSingle(); + Projectile.localAI[0] = reader.ReadSingle(); + Projectile.localAI[1] = reader.ReadSingle(); + Projectile.localAI[2] = reader.ReadSingle(); + impalePos = new Vector2(reader.ReadSingle(), reader.ReadSingle()); + stuckTimer = reader.ReadInt32(); + bounces = reader.ReadInt16(); } - */ } } diff --git a/Projectiles/Melee/DevilsStrike.cs b/Projectiles/Melee/DevilsStrike.cs index 47d45183f0..edd2632ef4 100644 --- a/Projectiles/Melee/DevilsStrike.cs +++ b/Projectiles/Melee/DevilsStrike.cs @@ -1,15 +1,7 @@ -using System; -using System.Runtime.ConstrainedExecution; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Projectiles/Melee/DevilsSunriseCyclone.cs b/Projectiles/Melee/DevilsSunriseCyclone.cs index 959f4b8f4d..4e5e3888ab 100644 --- a/Projectiles/Melee/DevilsSunriseCyclone.cs +++ b/Projectiles/Melee/DevilsSunriseCyclone.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -9,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class DevilsSunriseCyclone : ModProjectile, ILocalizedModType { public static readonly SoundStyle HitSound = new SoundStyle("CalamityMod/Sounds/Item/MantisSwipe", 2) with { Pitch = 1.25f, PitchVariance = 0.15f }; @@ -139,9 +141,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(HitSound, target.Center); target.AddBuff(ModContent.BuffType(), 180); // Heals on each hit - Player own = Main.player[Projectile.owner]; - if (!own.moonLeech) - own.HealPlayer(1); + Main.player[Projectile.owner].DoLifestealDirect(target, 1, 0.75f); // Start slicing the hit enemy if not doing so already if (State != 2f) diff --git a/Projectiles/Melee/DevilsSunriseProj.cs b/Projectiles/Melee/DevilsSunriseProj.cs index 5a440b6883..56e91d066e 100644 --- a/Projectiles/Melee/DevilsSunriseProj.cs +++ b/Projectiles/Melee/DevilsSunriseProj.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class DevilsSunriseProj : ModProjectile { public static readonly SoundStyle HitSound = new SoundStyle("CalamityMod/Sounds/Item/MantisSwipe", 2) with { Pitch = 0.8f }; @@ -88,8 +90,8 @@ namespace CalamityMod.Projectiles.Melee else { float velocityScale = 1f; - if (Owner.ActiveItem().shoot == Projectile.type) - velocityScale = Owner.ActiveItem().shootSpeed * Projectile.scale; + if (Owner.HeldItem.shoot == Projectile.type) + velocityScale = Owner.HeldItem.shootSpeed * Projectile.scale; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Vector2 slashDirection = Main.MouseWorld - Owner.RotatedRelativePoint(Owner.MountedCenter, true); diff --git a/Projectiles/Melee/DracoBeam.cs b/Projectiles/Melee/DracoBeam.cs index 414c822892..13c9210230 100644 --- a/Projectiles/Melee/DracoBeam.cs +++ b/Projectiles/Melee/DracoBeam.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index 01ec734e1f..5286f392d9 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class DragonRageStaff : ModProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); @@ -159,7 +161,7 @@ namespace CalamityMod.Projectiles.Melee { CalamityPlayer modPlayer = Main.player[Projectile.owner].Calamity(); modPlayer.dragonRageHits++; - if (modPlayer.dragonRageHits > 10 && modPlayer.dragonRageCooldown <= 0) + if (modPlayer.dragonRageHits >= 10 && modPlayer.dragonRageCooldown <= 0) { SpawnFireballs(); modPlayer.dragonRageHits = 0; diff --git a/Projectiles/Melee/DragoonBigBolt.cs b/Projectiles/Melee/DragoonBigBolt.cs index 5ed32691a3..828cbe7972 100644 --- a/Projectiles/Melee/DragoonBigBolt.cs +++ b/Projectiles/Melee/DragoonBigBolt.cs @@ -2,7 +2,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -72,7 +71,7 @@ namespace CalamityMod.Projectiles.Melee } if (time % 5 == 0) { - Dust dust = Dust.NewDustPerfect(pos, 278, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); + Dust dust = Dust.NewDustPerfect(pos, DustID.FireworksRGB, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); dust.noGravity = true; dust.color = usedColor; } @@ -131,7 +130,18 @@ namespace CalamityMod.Projectiles.Melee target.MoveNPC(launchVel, 20, true); } } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 45 * sizeMult * (Projectile.numHits > 0 ? 6 : 1), targetHitbox); + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float size = 45 * sizeMult * (Projectile.numHits > 0 ? 6 : 1); + Player Owner = Main.player[Projectile.owner]; + if (time <= 1 && Projectile.ai[1] != 0.5f) + { + float _ = float.NaN; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Owner.Center, size, ref _); + } + else + return CalamityUtils.CircularHitboxCollision(Projectile.Center, size, targetHitbox); + } public override bool? CanCutTiles() => false; } } diff --git a/Projectiles/Melee/DragoonSmallBolt.cs b/Projectiles/Melee/DragoonSmallBolt.cs index 50f9cd897e..d230a95b11 100644 --- a/Projectiles/Melee/DragoonSmallBolt.cs +++ b/Projectiles/Melee/DragoonSmallBolt.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Melee } if (time % 5 == 0) { - Dust dust = Dust.NewDustPerfect(pos, 278, new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); + Dust dust = Dust.NewDustPerfect(pos, DustID.FireworksRGB, new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); dust.noGravity = true; dust.color = usedColor; } @@ -75,9 +75,19 @@ namespace CalamityMod.Projectiles.Melee Particle spark2 = new BoltParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.9f), false, 13, Main.rand.NextFloat(0.3f, 0.35f), Main.rand.NextBool() ? Color.Orchid : Color.Cyan, new Vector2(1.8f, 0.8f), true, true, false, 0.9f); GeneralParticleHandler.SpawnParticle(spark2); } - + + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + Player Owner = Main.player[Projectile.owner]; + if (time <= 1) + { + float _ = float.NaN; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Owner.Center, 25, ref _); + } + else + return CalamityUtils.CircularHitboxCollision(Projectile.Center, 25, targetHitbox); } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 25, targetHitbox); public override bool? CanCutTiles() => false; } } diff --git a/Projectiles/Melee/EarthBoom.cs b/Projectiles/Melee/EarthBoom.cs index 58fc294fb1..b71021e706 100644 --- a/Projectiles/Melee/EarthBoom.cs +++ b/Projectiles/Melee/EarthBoom.cs @@ -1,8 +1,4 @@ -using System; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; +using Microsoft.Xna.Framework; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/EarthHoldout.cs b/Projectiles/Melee/EarthHoldout.cs index 32426601ca..2a230edb90 100644 --- a/Projectiles/Melee/EarthHoldout.cs +++ b/Projectiles/Melee/EarthHoldout.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Runtime.ConstrainedExecution; +using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -10,12 +9,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class EarthHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -41,6 +41,7 @@ namespace CalamityMod.Projectiles.Melee public bool playSwingSound = true; public bool allowSecondHit = true; public float bladeFade = 0; + public int armoredHits = 0; public override void SetDefaults() { base.SetDefaults(); @@ -133,6 +134,7 @@ namespace CalamityMod.Projectiles.Melee doSwing = true; finalFlip = false; + armoredHits = 0; } else { @@ -238,7 +240,7 @@ namespace CalamityMod.Projectiles.Melee GenericSparkle sparker = new GenericSparkle(Owner.Center + (new Vector2(270 * (1 + bladeFade * 0.6f), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), Vector2.Zero, Color.White, mainColor, Main.rand.NextFloat(0.5f, 0.7f), 11, Main.rand.NextFloat(-0.1f, 0.1f), 2.68f); GeneralParticleHandler.SpawnParticle(sparker); - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(270 * (1 + bladeFade * 0.6f), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, dustVel); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(270 * (1 + bladeFade * 0.6f), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, dustVel); dust2.scale = Main.rand.NextFloat(0.65f, 1.05f); dust2.noGravity = true; dust2.color = Color.Lerp(Color.White, mainColor, 0.5f); @@ -253,8 +255,10 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 600); - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) + if ((target.life <= 0 && target.realLife == -1) && Projectile.numHits > 0) Projectile.numHits -= 1; + if (damageDone <= 2) + armoredHits++; Vector2 launchVel = (Projectile.ai[1] != 1 ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Utils.DirectionTo(Owner.Center, target.Center)); target.MoveNPC(launchVel, 37, true); @@ -296,11 +300,11 @@ namespace CalamityMod.Projectiles.Melee spawnBoom = false; } - int healPower = (Projectile.ai[1] == -1 ? 100 : 85); - int heal = (int)(MathHelper.Clamp(healPower - Projectile.numHits * 75, 1, healPower)); + int healPower = Projectile.ai[1] == -1 ? 60 : 50; + int heal = (int)(MathHelper.Clamp(healPower - Projectile.numHits * 35, 1, healPower)); if (Projectile.numHits < 10) { - Owner.HealPlayer(heal); + Owner.DoLifestealDirect(target, heal, 0.2f); } if (Projectile.numHits <= 2) @@ -328,7 +332,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++) { float power = Main.rand.NextFloat(0.2f, 0.8f); - Dust dust2 = Dust.NewDustPerfect(target.Center, 278, (Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld)).RotatedByRandom(power) * (Main.rand.NextFloat(10f, 35f) * ( 1 - power))); + Dust dust2 = Dust.NewDustPerfect(target.Center, DustID.FireworksRGB, (Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld)).RotatedByRandom(power) * (Main.rand.NextFloat(10f, 35f) * ( 1 - power))); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * scaleFactor; dust2.noGravity = true; dust2.color = Color.Lerp(Color.White, mainColor, 0.5f); @@ -339,7 +343,7 @@ namespace CalamityMod.Projectiles.Melee { float minMult = 1f; int hitsToMinMult = 1; - float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + float damageMult = Utils.Remap(Projectile.numHits - armoredHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Melee/EarthMeteor.cs b/Projectiles/Melee/EarthMeteor.cs index aa2b3f192d..8acfbb5dd5 100644 --- a/Projectiles/Melee/EarthMeteor.cs +++ b/Projectiles/Melee/EarthMeteor.cs @@ -6,12 +6,8 @@ using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using ReLogic.Utilities; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework.Graphics; using CalamityMod.Particles; -using Terraria.Graphics.Renderers; -using CalamityMod.Dusts; using ReLogic.Content; namespace CalamityMod.Projectiles.Melee @@ -172,7 +168,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits <= 0) { Player Owner = Main.player[Projectile.owner]; - Owner.Calamity().GeneralScreenShakePower = 4.5f; + Owner.SetScreenshake(4.5f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack, Projectile.owner); for (int i = 0; i < 15; i++) { @@ -182,7 +178,7 @@ namespace CalamityMod.Projectiles.Melee 1 => Color.MediumTurquoise, _ => Color.LawnGreen, }; - Dust dust2 = Dust.NewDustPerfect(target.Center, 278, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(5.5f, 20)); + Dust dust2 = Dust.NewDustPerfect(target.Center, DustID.FireworksRGB, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(5.5f, 20)); dust2.scale = Main.rand.NextFloat(0.85f, 1.15f); dust2.noGravity = false; dust2.color = Color.Lerp(Color.White, randomColor, 0.5f); diff --git a/Projectiles/Melee/EmpyreanKnife.cs b/Projectiles/Melee/EmpyreanKnife.cs index 26ee16b06f..2f788e4530 100644 --- a/Projectiles/Melee/EmpyreanKnife.cs +++ b/Projectiles/Melee/EmpyreanKnife.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Balancing; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -78,29 +77,7 @@ namespace CalamityMod.Projectiles.Melee } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - int heal = (int)Math.Round(hit.Damage * 0.015); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - int heal = (int)Math.Round(info.Damage * 0.015); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, (int)Math.Round(hit.Damage * 0.015), 0.75f); public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/EonBolt.cs b/Projectiles/Melee/EonBolt.cs index e6988ef0c0..ca8503c7b9 100644 --- a/Projectiles/Melee/EonBolt.cs +++ b/Projectiles/Melee/EonBolt.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Melee } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeToEnd = MathHelper.Lerp(0.65f, 1f, (float)Math.Cos(-Main.GlobalTimeWrappedHourly * 3f) * 0.5f + 0.5f); float fadeOpacity = Utils.GetLerpValue(1f, 0.64f, completionRatio, true) * Projectile.Opacity; @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Melee return Color.Lerp(Color.White, endColor, fadeToEnd) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float expansionCompletion = (float)Math.Pow(1 - completionRatio, 3); return MathHelper.Lerp(0f, 22 * Projectile.scale * Projectile.Opacity, expansionCompletion); @@ -104,7 +104,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); Texture2D texture = Request("CalamityMod/Projectiles/Melee/GalaxiaBolt").Value; Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.Lerp(lightColor, Color.White, 0.5f), Projectile.rotation, texture.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); diff --git a/Projectiles/Melee/EssenceFlame2.cs b/Projectiles/Melee/EssenceFlame2.cs deleted file mode 100644 index e48ffa2e5b..0000000000 --- a/Projectiles/Melee/EssenceFlame2.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee -{ - public class EssenceFlame2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/Healing/EssenceFlame"; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 4; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 20; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Melee; - Projectile.timeLeft = 180; - Projectile.alpha = 255; - Projectile.extraUpdates = 3; - } - - public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 150 && target.CanBeChasedBy(Projectile); - - public override void AI() - { - Projectile.alpha -= 5; - - Projectile.frameCounter++; - if (Projectile.frameCounter > 16) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 3) - Projectile.frame = 0; - - if (Projectile.timeLeft < 150) - CalamityUtils.HomeInOnNPC(Projectile, true, 760f, 10f, 20f); - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 50; - Projectile.height = 50; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 5; i++) - { - int essenceDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 2f); - Main.dust[essenceDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[essenceDust].scale = 0.5f; - Main.dust[essenceDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 8; j++) - { - int essenceDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 3f); - Main.dust[essenceDust2].noGravity = true; - Main.dust[essenceDust2].velocity *= 5f; - essenceDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 2f); - Main.dust[essenceDust2].velocity *= 2f; - } - } - } -} diff --git a/Projectiles/Melee/EssenceScythe.cs b/Projectiles/Melee/EssenceScythe.cs index f487a0cd93..7e33e40e0a 100644 --- a/Projectiles/Melee/EssenceScythe.cs +++ b/Projectiles/Melee/EssenceScythe.cs @@ -1,5 +1,4 @@ -using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -23,16 +22,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = 100; Projectile.height = 78; Projectile.aiStyle = ProjAIStyleID.Sickle; + AIType = ProjectileID.DeathSickle; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; - Projectile.alpha = 55; - Projectile.penetrate = 10; - Projectile.timeLeft = 300; Projectile.ignoreWater = true; - AIType = ProjectileID.DeathSickle; + Projectile.alpha = 55; + Projectile.penetrate = 5; + Projectile.timeLeft = 300; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 2; + Projectile.idStaticNPCHitCooldown = 3; } public override void AI() @@ -44,7 +43,7 @@ namespace CalamityMod.Projectiles.Melee Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); } - CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 512f, 12f, 20f); } public override bool PreDraw(ref Color lightColor) @@ -78,11 +77,8 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); - if (target.life <= 0 && target.lifeMax > 5) - { - if (Projectile.owner == Main.myPlayer) - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], 8, ModContent.ProjectileType(), BalancingConstants.LifeStealRange, 0f); - } + if (target.life <= 0) + Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ModContent.ProjectileType(), 8, 0f); } } } diff --git a/Projectiles/Melee/ExaltedOathbladeHoldout.cs b/Projectiles/Melee/ExaltedOathbladeHoldout.cs index 3512cfa0cd..c4db13d8e4 100644 --- a/Projectiles/Melee/ExaltedOathbladeHoldout.cs +++ b/Projectiles/Melee/ExaltedOathbladeHoldout.cs @@ -1,9 +1,9 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Cooldowns; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Packets.Entities; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; @@ -12,13 +12,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class ExaltedOathbladeHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -294,7 +294,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits == 0) { - Owner.Calamity().GeneralScreenShakePower = 7f; + Owner.SetScreenshake(7f); for (int i = 0; i < 4; i++) GeneralParticleHandler.SpawnParticle(new CustomSpark(target.Center + launchVel * 15, launchVel.RotatedBy((0.15f - 0.05f * i) * (i % 2 == 0 ? -1 : 1)) * (10 + 10 * i), "CalamityMod/Particles/DemonSigilParticle", false, 11, 0.7f - 0.15f * i, Color.MediumOrchid, new Vector2(1.5f, 1), extraRotation: MathHelper.ToRadians(i % 2 == 0 ? 90 : 0), shrinkSpeed: (i % 2 == 0 ? -0.8f : 0.8f))); @@ -316,7 +316,7 @@ namespace CalamityMod.Projectiles.Melee float minMult = 0.35f; int hitsToMinMult = 8; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= damageMult * (Owner.Calamity().mouseRight ? 2.5f : 1); + modifiers.SourceDamage *= damageMult; } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/ExaltedOathbladeThrownBlade.cs b/Projectiles/Melee/ExaltedOathbladeThrownBlade.cs index 17b17ede5c..2e35aee3ab 100644 --- a/Projectiles/Melee/ExaltedOathbladeThrownBlade.cs +++ b/Projectiles/Melee/ExaltedOathbladeThrownBlade.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Packets.Entities; @@ -11,7 +10,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.IO; using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee @@ -226,7 +224,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - int bonusDamage = 120; + int bonusDamage = 100; if (target.Calamity().demonicFlamesBonusDamage <= bonusDamage) { target.Calamity().demonicFlamesBonusDamage = bonusDamage; @@ -312,7 +310,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 8; Projectile.velocity.Y *= 0.85f; Projectile.velocity = Projectile.velocity.RotatedByRandom(0.2f); - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center); bounces++; Projectile.timeLeft = Lifetime; } diff --git a/Projectiles/Melee/ExcelsusBlue.cs b/Projectiles/Melee/ExcelsusBlue.cs deleted file mode 100644 index 2ae98ca2fc..0000000000 --- a/Projectiles/Melee/ExcelsusBlue.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class ExcelsusBlue : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetDefaults() - { - Projectile.width = 34; - Projectile.height = 34; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.ignoreWater = true; - Projectile.penetrate = 3; - Projectile.timeLeft = 300; - Projectile.alpha = 100; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) < 16f && Projectile.timeLeft > 85) - { - Projectile.velocity *= 1.05f; - } - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) > 0f && Projectile.timeLeft <= 85) - { - Projectile.velocity *= 0.98f; - } - Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.02f; - if (Main.rand.NextBool(8)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BlueFairy, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.tileCollide = false; - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - return false; - } - - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return default(Color); - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - 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 PostDraw(Color lightColor) - { - Color color; - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - color = new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - else - { - color = new Color(255, 255, 255, 100); - } - Vector2 origin = new Vector2(39f, 46f); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Melee/ExcelsusBlueGlow").Value, Projectile.Center - Main.screenPosition, null, color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - target.AddBuff(ModContent.BuffType(), 180); - } - } -} diff --git a/Projectiles/Melee/ExcelsusBlue.png b/Projectiles/Melee/ExcelsusBlue.png deleted file mode 100644 index 1bb0363ed5..0000000000 Binary files a/Projectiles/Melee/ExcelsusBlue.png and /dev/null differ diff --git a/Projectiles/Melee/ExcelsusBlueGlow.png b/Projectiles/Melee/ExcelsusBlueGlow.png deleted file mode 100644 index e7669091fd..0000000000 Binary files a/Projectiles/Melee/ExcelsusBlueGlow.png and /dev/null differ diff --git a/Projectiles/Melee/ExcelsusMain.cs b/Projectiles/Melee/ExcelsusMain.cs deleted file mode 100644 index 4b86ba15d7..0000000000 --- a/Projectiles/Melee/ExcelsusMain.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class ExcelsusMain : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetDefaults() - { - Projectile.width = 34; - Projectile.height = 34; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.ignoreWater = true; - Projectile.penetrate = 3; - Projectile.timeLeft = 300; - Projectile.alpha = 100; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) < 20f && Projectile.timeLeft > 85) - { - Projectile.velocity *= 1.05f; - } - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) > 0f && Projectile.timeLeft <= 85) - { - Projectile.velocity *= 0.98f; - } - Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.02f; - if (Main.rand.NextBool(8)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 56 : 242, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.tileCollide = false; - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - return false; - } - - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return default(Color); - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - 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 PostDraw(Color lightColor) - { - Color color; - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - color = new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - else - { - color = new Color(255, 255, 255, 100); - } - Vector2 origin = new Vector2(39f, 46f); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Melee/ExcelsusMainGlow").Value, Projectile.Center - Main.screenPosition, null, color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - target.AddBuff(ModContent.BuffType(), 180); - } - } -} diff --git a/Projectiles/Melee/ExcelsusMain.png b/Projectiles/Melee/ExcelsusMain.png deleted file mode 100644 index 15e7b947e2..0000000000 Binary files a/Projectiles/Melee/ExcelsusMain.png and /dev/null differ diff --git a/Projectiles/Melee/ExcelsusMainGlow.png b/Projectiles/Melee/ExcelsusMainGlow.png deleted file mode 100644 index c8b3d4cc56..0000000000 Binary files a/Projectiles/Melee/ExcelsusMainGlow.png and /dev/null differ diff --git a/Projectiles/Melee/ExcelsusPink.cs b/Projectiles/Melee/ExcelsusPink.cs deleted file mode 100644 index 5bf63ee24e..0000000000 --- a/Projectiles/Melee/ExcelsusPink.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class ExcelsusPink : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetDefaults() - { - Projectile.width = 34; - Projectile.height = 34; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.ignoreWater = true; - Projectile.penetrate = 3; - Projectile.timeLeft = 300; - Projectile.alpha = 100; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) < 24f && Projectile.timeLeft > 85) - { - Projectile.velocity *= 1.05f; - } - if (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y) > 0f && Projectile.timeLeft <= 85) - { - Projectile.velocity *= 0.98f; - } - Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.02f; - if (Main.rand.NextBool(8)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.PinkTorch, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.tileCollide = false; - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - return false; - } - - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return default(Color); - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - 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 PostDraw(Color lightColor) - { - Color color; - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - color = new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - else - { - color = new Color(255, 255, 255, 100); - } - Vector2 origin = new Vector2(39f, 46f); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Melee/ExcelsusPinkGlow").Value, Projectile.Center - Main.screenPosition, null, color, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (Projectile.timeLeft > 85) - { - Projectile.timeLeft = 85; - } - target.AddBuff(ModContent.BuffType(), 180); - } - } -} diff --git a/Projectiles/Melee/ExcelsusPink.png b/Projectiles/Melee/ExcelsusPink.png deleted file mode 100644 index 997a611ea0..0000000000 Binary files a/Projectiles/Melee/ExcelsusPink.png and /dev/null differ diff --git a/Projectiles/Melee/ExcelsusPinkGlow.png b/Projectiles/Melee/ExcelsusPinkGlow.png deleted file mode 100644 index 07f364ec1a..0000000000 Binary files a/Projectiles/Melee/ExcelsusPinkGlow.png and /dev/null differ diff --git a/Projectiles/Melee/Exobeam.cs b/Projectiles/Melee/Exobeam.cs index 553cb5793c..1532037dd0 100644 --- a/Projectiles/Melee/Exobeam.cs +++ b/Projectiles/Melee/Exobeam.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool()) { Color dustColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.9f); - Dust must = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20f, 20f) + Projectile.velocity, 267, Projectile.velocity * -2.6f, 0, dustColor); + Dust must = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20f, 20f) + Projectile.velocity, DustID.RainbowMk2, Projectile.velocity * -2.6f, 0, dustColor); must.scale = 0.3f; must.fadeIn = Main.rand.NextFloat() * 1.2f; must.noGravity = true; @@ -118,7 +118,7 @@ namespace CalamityMod.Projectiles.Melee public override Color? GetAlpha(Color lightColor) => Color.White with { A = 0 } * Projectile.Opacity; - public float TrailWidth(float completionRatio) + public float TrailWidth(float completionRatio, Vector2 vertexPos) { float width = Utils.GetLerpValue(1f, 0.4f, completionRatio, true) * (float)Math.Sin(Math.Acos(1 - Utils.GetLerpValue(0f, 0.15f, completionRatio, true))); @@ -126,15 +126,15 @@ namespace CalamityMod.Projectiles.Melee return width * MaxWidth; } - public Color TrailColor(float completionRatio) + public Color TrailColor(float completionRatio, Vector2 vertexPos) { Color baseColor = Color.Lerp(Color.Cyan, new Color(0, 0, 255), completionRatio); return baseColor; } - public float MiniTrailWidth(float completionRatio) => TrailWidth(completionRatio) * 0.8f; - public Color MiniTrailColor(float completionRatio) => Color.White; + public float MiniTrailWidth(float completionRatio, Vector2 vertexPos) => TrailWidth(completionRatio, vertexPos) * 0.8f; + public Color MiniTrailColor(float completionRatio, Vector2 vertexPos) => Color.White; public override bool PreDraw(ref Color lightColor) @@ -172,12 +172,12 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExobladePierce"].Apply(); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(Color.White); GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Color.White); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(MiniTrailWidth, MiniTrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(MiniTrailWidth, MiniTrailColor, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); Main.spriteBatch.ExitShaderRegion(); diff --git a/Projectiles/Melee/ExobeamSlash.cs b/Projectiles/Melee/ExobeamSlash.cs index 731a9e3e59..be763198b1 100644 --- a/Projectiles/Melee/ExobeamSlash.cs +++ b/Projectiles/Melee/ExobeamSlash.cs @@ -1,9 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Melee/ExobeamSlashCreator.cs b/Projectiles/Melee/ExobeamSlashCreator.cs index 4ad18c1c87..834b6a37e6 100644 --- a/Projectiles/Melee/ExobeamSlashCreator.cs +++ b/Projectiles/Melee/ExobeamSlashCreator.cs @@ -1,7 +1,5 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 884824bdbe..0c11323fc6 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -2,13 +2,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using CalamityMod.Balancing; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; -using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -223,8 +221,8 @@ namespace CalamityMod.Projectiles.Melee { float _ = 0f; Vector2 start = Projectile.Center; - Vector2 end = start + SwordDirection * BladeLength * Projectile.scale; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, Projectile.scale * 30f, ref _); + Vector2 end = start + SwordDirection * (BladeLength + 50) * Projectile.scale; // Has an additional offset so that the hitbox to match the vfx + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, State == SwingState.BonkDash ? Projectile.scale * 45 : Projectile.scale * 30f, ref _); } public void InitializationEffects(bool startInitialization) @@ -326,7 +324,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextFloat() < RiskOfDust) { Color dustColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.9f); - Dust must = Dust.NewDustPerfect(Owner.MountedCenter + SwordDirection * BladeLength * Projectile.scale * (float)Math.Pow(Main.rand.NextFloat(0.2f, 1f), 0.5f), 267, SwordDirection.RotatedBy(MathHelper.PiOver2 * Direction) * 2.6f, 0, dustColor); + Dust must = Dust.NewDustPerfect(Owner.MountedCenter + SwordDirection * BladeLength * Projectile.scale * (float)Math.Pow(Main.rand.NextFloat(0.2f, 1f), 0.5f), DustID.RainbowMk2, SwordDirection.RotatedBy(MathHelper.PiOver2 * Direction) * 2.6f, 0, dustColor); must.scale = 0.3f; must.fadeIn = Main.rand.NextFloat() * 1.2f; @@ -344,7 +342,7 @@ namespace CalamityMod.Projectiles.Melee float rotationAngle = MathHelper.PiOver4 * 0.3f * ((Timer - beamShootStart) / beamShootPeriod); int boltDamage = (int)(Projectile.damage * Exoblade.NotTrueMeleeDamagePenalty); Vector2 boltVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.3); - boltVelocity *= Owner.ActiveItem().shootSpeed; + boltVelocity *= Owner.HeldItem.shootSpeed; Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + boltVelocity * 5f, boltVelocity, ModContent.ProjectileType(), boltDamage, Projectile.knockBack / 3f, Projectile.owner); } @@ -373,13 +371,13 @@ namespace CalamityMod.Projectiles.Melee // Do the dash. else { - float rotationStrenght = MathHelper.PiOver4 * 0.05f * (float)Math.Pow(LungeProgression, 3); + float rotationStrength = MathHelper.PiOver4 * 0.05f * (float)Math.Pow(LungeProgression, 3); float currentRotation = Projectile.velocity.ToRotation(); // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction float idealRotation = Owner.MountedCenter.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(); - Projectile.velocity = currentRotation.AngleTowards(idealRotation, rotationStrenght).ToRotationVector2(); + Projectile.velocity = currentRotation.AngleTowards(idealRotation, rotationStrength).ToRotationVector2(); Owner.fallStart = (int)(Owner.position.Y / 16f); @@ -393,7 +391,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool()) { Color dustColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.9f); - Dust must = Dust.NewDustPerfect(Owner.MountedCenter + Main.rand.NextVector2Circular(20f, 20f), 267, SwordDirection * -2.6f, 0, dustColor); + Dust must = Dust.NewDustPerfect(Owner.MountedCenter + Main.rand.NextVector2Circular(20f, 20f), DustID.RainbowMk2, SwordDirection * -2.6f, 0, dustColor); must.scale = 0.3f; must.fadeIn = Main.rand.NextFloat() * 1.2f; must.noGravity = true; @@ -425,11 +423,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4 * Direction; } - public float SlashWidthFunction(float completionRatio) => SquishAtProgress(RealProgressionAtTrailCompletion(completionRatio)) * Projectile.scale * 60.5f; + public float SlashWidthFunction(float completionRatio, Vector2 vertexPos) => SquishAtProgress(RealProgressionAtTrailCompletion(completionRatio)) * Projectile.scale * 60.5f; - public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity; + public Color SlashColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity; - public float PierceWidthFunction(float completionRatio) + public float PierceWidthFunction(float completionRatio, Vector2 vertexPos) { float width = Utils.GetLerpValue(0f, 0.2f, completionRatio, true) * Projectile.scale * 50f; //Fade it out starkly near the end of the lunge @@ -437,7 +435,7 @@ namespace CalamityMod.Projectiles.Melee return width; } - public Color PierceColorFunction(float completionRatio) => Color.Lime * Projectile.Opacity; //The trail color doesnt matter here + public Color PierceColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lime * Projectile.Opacity; //The trail color doesnt matter here public List GenerateSlashPoints() { @@ -447,7 +445,7 @@ namespace CalamityMod.Projectiles.Melee { float progress = MathHelper.Lerp(Progression, TrailEndProgression, i / 40f); - result.Add(DirectionAtProgressScuffed(progress) * (BladeLength - 20f) * Projectile.scale); + result.Add(DirectionAtProgressScuffed(progress) * (BladeLength - 6f) * Projectile.scale); } return result; @@ -480,7 +478,7 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue(Direction == 1); GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply(); - PrimitiveRenderer.RenderTrail(GenerateSlashPoints(), new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 95); + PrimitiveRenderer.RenderTrail(GenerateSlashPoints(), new(SlashWidthFunction, SlashColorFunction, (_,_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 95); Main.spriteBatch.ExitShaderRegion(); } @@ -510,7 +508,7 @@ namespace CalamityMod.Projectiles.Melee int numPointsRendered = 30; int numPointsProvided = 60; var positionsToUse = Projectile.oldPos.Take(numPointsProvided).ToArray(); - PrimitiveRenderer.RenderTrail(positionsToUse, new(PierceWidthFunction, PierceColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), numPointsRendered); + PrimitiveRenderer.RenderTrail(positionsToUse, new(PierceWidthFunction, PierceColorFunction, (_,_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), numPointsRendered); Main.spriteBatch.ExitShaderRegion(); } @@ -576,6 +574,8 @@ namespace CalamityMod.Projectiles.Melee origin.X = texture.Width; } + Projectile.scale = MathHelper.Lerp(1f, 0.22f, MathF.Pow(LungeProgression, 7)); + Main.EntitySpriteDraw(texture, drawPosition, null, Color.White, rotation, origin, Projectile.scale, direction, 0); float energyPower = Utils.GetLerpValue(0f, 0.32f, Progression, true) * Utils.GetLerpValue(1f, 0.85f, Progression, true); @@ -589,8 +589,8 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, hit, damageDone); - NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), hit, damageDone); + ItemLoader.OnHitNPC(Owner.HeldItem, Owner, target, hit, damageDone); + NPCLoader.OnHitByItem(target, Owner, Owner.HeldItem, hit, damageDone); PlayerLoader.OnHitNPC(Owner, target, hit, damageDone); if (State == SwingState.BonkDash) @@ -628,17 +628,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.NewProjectile(Projectile.GetSource_FromAI(), target.Center, Vector2.Zero, ModContent.ProjectileType(), explosionDamage, 0f, Projectile.owner); } - if (target.lifeMax <= 5 || Owner.lifeSteal <= 0) - return; - - int healAmt = (int)Math.Round(hit.Damage * 0.04); - if (healAmt > BalancingConstants.LifeStealCap) - healAmt = BalancingConstants.LifeStealCap; - - if (healAmt <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Owner, healAmt, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); + Owner.DoLifestealDirect(target, (int)Math.Round(hit.Damage * 0.04), 0.4f); } } diff --git a/Projectiles/Melee/FallenPaladinsHammerEcho.cs b/Projectiles/Melee/FallenPaladinsHammerEcho.cs index 875dca52b7..6e7dc89318 100644 --- a/Projectiles/Melee/FallenPaladinsHammerEcho.cs +++ b/Projectiles/Melee/FallenPaladinsHammerEcho.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Melee { for (int i = 0; i < 20; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, ((targeted.Center - Projectile.Center).SafeNormalize(Vector2.UnitX) * 15).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, ((targeted.Center - Projectile.Center).SafeNormalize(Vector2.UnitX) * 15).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 1.2f); dust.color = Main.rand.NextBool() ? Color.IndianRed : Color.Red; @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Melee { Vector2 offset = new Vector2(7, 0).RotatedByRandom(MathHelper.ToRadians(360f)); Vector2 velOffset = new Vector2(3, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 267, new Vector2(Projectile.velocity.X * 0.2f + velOffset.X, Projectile.velocity.Y * 0.2f + velOffset.Y), 0, new Color(255, 245, 198), 1f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.RainbowMk2, new Vector2(Projectile.velocity.X * 0.2f + velOffset.X, Projectile.velocity.Y * 0.2f + velOffset.Y), 0, new Color(255, 245, 198), 1f); dust.noGravity = true; dust.color = Color.DarkRed; } @@ -112,7 +112,7 @@ namespace CalamityMod.Projectiles.Melee else SoundEngine.PlaySound(SlamHamSound, Projectile.Center); - Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 5; + Main.player[Projectile.owner].SetScreenshake(5f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 0.001f, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f); diff --git a/Projectiles/Melee/FallenPaladinsHammerProj.cs b/Projectiles/Melee/FallenPaladinsHammerProj.cs index fae1893ed4..67390506e9 100644 --- a/Projectiles/Melee/FallenPaladinsHammerProj.cs +++ b/Projectiles/Melee/FallenPaladinsHammerProj.cs @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(RedHamSound, Projectile.Center); for (int i = 0; i < 20; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center, 90); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.GemRuby); fire.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.8f) * new Vector2(4f, 1.25f) * Main.rand.NextFloat(0.9f, 1f); fire.velocity = fire.velocity.RotatedBy(Projectile.rotation - MathHelper.PiOver2); fire.velocity += Projectile.velocity * (EmpoweredHammer * 0.1f); @@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.DD2_BetsysWrathShot with { Volume = 0.4f }, Projectile.Center); for (int i = 0; i < 20; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center, 90); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.GemRuby); fire.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.8f) * new Vector2(4f, 1.25f) * Main.rand.NextFloat(0.9f, 1f); fire.velocity = fire.velocity.RotatedBy(Projectile.rotation - MathHelper.PiOver2); fire.velocity += Projectile.velocity * (EmpoweredHammer * 0.1f); @@ -162,7 +162,7 @@ namespace CalamityMod.Projectiles.Melee { Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f)); Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(new Vector2(Projectile.Center.X, Projectile.Center.Y) + offset, 267, new Vector2(Projectile.velocity.X * 0.2f + velOffset.X, Projectile.velocity.Y * 0.2f + velOffset.Y), 0, default, 0.7f); + Dust dust = Dust.NewDustPerfect(new Vector2(Projectile.Center.X, Projectile.Center.Y) + offset, DustID.RainbowMk2, new Vector2(Projectile.velocity.X * 0.2f + velOffset.X, Projectile.velocity.Y * 0.2f + velOffset.Y), 0, default, 0.7f); dust.noGravity = true; dust.color = Color.DarkRed; } diff --git a/Projectiles/Melee/Feather.cs b/Projectiles/Melee/Feather.cs index 507f59ee20..3b31bef2f9 100644 --- a/Projectiles/Melee/Feather.cs +++ b/Projectiles/Melee/Feather.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/ForbiddenOathbladeHoldout.cs b/Projectiles/Melee/ForbiddenOathbladeHoldout.cs index edbf65fe72..b4088066bc 100644 --- a/Projectiles/Melee/ForbiddenOathbladeHoldout.cs +++ b/Projectiles/Melee/ForbiddenOathbladeHoldout.cs @@ -1,9 +1,10 @@ -using System; +using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Cooldowns; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Packets.Entities; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; @@ -12,13 +13,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class ForbiddenOathbladeHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -46,6 +47,7 @@ namespace CalamityMod.Projectiles.Melee public bool willDie = false; public bool hasLaunchedBlades = false; public bool swooshFade = false; + private int lastSwingId; public int postSwingCooldownMax => (int)(useAnim * 0.65f); public override void SetDefaults() { @@ -62,11 +64,26 @@ namespace CalamityMod.Projectiles.Melee Projectile.knockBack = 0; Projectile.scale = 1.15f; Projectile.ai[1] = -1; + bool isOwner = Main.myPlayer == Projectile.owner; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - mousePos = Owner.Calamity().mouseWorld; - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + if (isOwner) + { + mousePos = Owner.Calamity().mouseWorld; + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + Projectile.netUpdate = true; + } + else + { + Vector2 syncedDelta = Owner.Calamity().mouseWorldDeltaFromPlayer; + if (syncedDelta.LengthSquared() > 0.001f) + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65f; + else + aimVel = Vector2.UnitX * Owner.direction * 65f; + mousePos = Owner.Center - aimVel; + } useAnim = (int)(Owner.HeldItem.useAnimation / Owner.GetTotalAttackSpeed()); postSwingCooldown = postSwingCooldownMax / 2; + lastSwingId = (int)Projectile.ai[0]; if (mousePos.X < Owner.Center.X) Owner.direction = -1; else Owner.direction = 1; @@ -79,29 +96,56 @@ namespace CalamityMod.Projectiles.Melee } public override void UseStyle() { + bool isOwner = Main.myPlayer == Projectile.owner; bool hasKillMode = Owner.Calamity().cooldowns.TryGetValue(KillMode.ID, out CooldownInstance killModeCD); - if ((Main.mouseLeft || (hasKillMode && killModeCD.timeLeft == KillMode.cooldownMax + 1)) && holding && postSwingCooldown == 0) + if (!isOwner) + { + Vector2 syncedDelta = Owner.Calamity().mouseWorldDeltaFromPlayer; + if (syncedDelta.LengthSquared() > 0.001f) + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65f; + } + + if (isOwner) + { + bool shouldStartSwing = (Main.mouseLeft || (hasKillMode && killModeCD.timeLeft == KillMode.cooldownMax + 1)) && holding && postSwingCooldown == 0; + if (shouldStartSwing) + { + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + Projectile.ai[0] += 1f; + Projectile.netUpdate = true; + } + } + + int swingId = (int)Projectile.ai[0]; + if (swingId != lastSwingId && holding && postSwingCooldown == 0) { Animation = (int)(useAnim * 0.7f); holding = false; - killModeCD.timeLeft = KillMode.cooldownMax; - Owner.Calamity().killModeCooldown = KillMode.cooldownMax - 1; + if (isOwner) + { + killModeCD.timeLeft = KillMode.cooldownMax; + Owner.Calamity().killModeCooldown = KillMode.cooldownMax - 1; + } swingCount++; + lastSwingId = swingId; } if (postSwingCooldown > 0) postSwingCooldown--; else if (willDie) { - if (hasKillMode) - killModeCD.timeLeft = KillMode.cooldownMax; - Owner.Calamity().killModeCooldown = KillMode.cooldownMax; + if (isOwner) + { + if (hasKillMode) + killModeCD.timeLeft = KillMode.cooldownMax; + Owner.Calamity().killModeCooldown = KillMode.cooldownMax; + Owner.Calamity().demonSwordKillMode = false; + } DrawUnconditionally = false; Projectile.Kill(); - Owner.Calamity().demonSwordKillMode = false; return; } - if (killModeCD.timeLeft < KillMode.cooldownMax) + if (isOwner && killModeCD.timeLeft < KillMode.cooldownMax) { killModeCD.timeLeft = KillMode.cooldownMax; Owner.Calamity().killModeCooldown = KillMode.cooldownMax; @@ -112,11 +156,14 @@ namespace CalamityMod.Projectiles.Melee AnimationProgress = Animation % useAnim; + if (isOwner && !holding && Main.netMode != NetmodeID.SinglePlayer && (int)Animation % 3 == 0) + Projectile.netUpdate = true; + if (CanHit || postSwing) mousePos = Owner.Center - aimVel; else { - mousePos = Owner.Calamity().mouseWorld; + mousePos = isOwner ? Owner.Calamity().mouseWorld : (Owner.Center - aimVel); } if (CanHit && !swooshFade) @@ -134,8 +181,15 @@ namespace CalamityMod.Projectiles.Melee Projectile.numHits = 0; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - mousePos = Owner.Calamity().mouseWorld; - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + if (isOwner) + { + mousePos = Owner.Calamity().mouseWorld; + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + } + else + { + mousePos = Owner.Center - aimVel; + } CanHit = false; if (mousePos.X < Owner.Center.X) Owner.direction = -1; else Owner.direction = 1; @@ -144,8 +198,10 @@ namespace CalamityMod.Projectiles.Melee finalFlip = false; playSwingSound = true; hasLaunchedBlades = false; - if (!Owner.Calamity().demonSwordKillMode && postSwingCooldown == 0) + if (isOwner && !Owner.Calamity().demonSwordKillMode && postSwingCooldown == 0) { + if (!willDie) + Projectile.netUpdate = true; willDie = true; } @@ -169,7 +225,8 @@ namespace CalamityMod.Projectiles.Melee if (holding) { // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + if (isOwner) + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; CanHit = false; postSwing = false; RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(120f * Projectile.ai[1] * Owner.direction * (1 + (Utils.GetLerpValue(useAnim * 0.7f, useAnim, Animation, true)) * 0.35f)), 0.2f); @@ -191,7 +248,8 @@ namespace CalamityMod.Projectiles.Melee SoundStyle swing2 = new("CalamityMod/Sounds/Item/HeavySwing"); SoundEngine.PlaySound(swing2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(0.4f, 0.5f) }, Projectile.Center); playSwingSound = false; - Owner.Calamity().demonSwordKillMode = false; + if (isOwner) + Owner.Calamity().demonSwordKillMode = false; } if (time > (int)(timeMax * 0.2f) && time < (int)(timeMax * 0.9f)) CanHit = true; @@ -292,7 +350,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits == 0) { - Owner.Calamity().GeneralScreenShakePower = 5.5f; + Owner.SetScreenshake(5.5f); for (int i = 0; i < 4; i++) GeneralParticleHandler.SpawnParticle(new CustomSpark(target.Center + launchVel * 15, launchVel.RotatedBy((0.15f - 0.05f * i) * (i % 2 == 0 ? -1 : 1)) * (10 + 10 * i), "CalamityMod/Particles/DemonSigilParticle", false, 11, 0.7f - 0.15f * i, Color.MediumOrchid, new Vector2(1.5f, 1), extraRotation: MathHelper.ToRadians(i % 2 == 0 ? 90 : 0), shrinkSpeed: (i % 2 == 0 ? -0.8f : 0.8f))); @@ -305,7 +363,7 @@ namespace CalamityMod.Projectiles.Melee float minMult = 0.3f; int hitsToMinMult = 7; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= damageMult * (Owner.Calamity().mouseRight ? 2.5f : 1); + modifiers.SourceDamage *= damageMult; } public override bool PreDraw(ref Color lightColor) { @@ -335,5 +393,24 @@ namespace CalamityMod.Projectiles.Melee public override void ResetStyle() { } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(willDie); + writer.Write7BitEncodedInt(useAnim); + writer.Write7BitEncodedInt(postSwingCooldown); + writer.WriteVector2(aimVel); + writer.Write(Animation); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + willDie = reader.ReadBoolean(); + useAnim = reader.Read7BitEncodedInt(); + postSwingCooldown = reader.Read7BitEncodedInt(); + aimVel = reader.ReadVector2(); + Animation = reader.ReadSingle(); + mousePos = Owner.Center - aimVel; + } } } diff --git a/Projectiles/Melee/ForbiddenOathbladeThrownBlade.cs b/Projectiles/Melee/ForbiddenOathbladeThrownBlade.cs index 979189d83c..3f80950563 100644 --- a/Projectiles/Melee/ForbiddenOathbladeThrownBlade.cs +++ b/Projectiles/Melee/ForbiddenOathbladeThrownBlade.cs @@ -10,7 +10,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.IO; using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee @@ -42,6 +41,26 @@ namespace CalamityMod.Projectiles.Melee public int bounces = 0; public Vector2 tipPosition = Vector2.Zero; public bool fadingOut => Projectile.timeLeft <= (Lifetime - fadeOutTime); + private bool visualChargeInitialized = false; + private int visualChargeTimer = 0; + private int visualChargeTime = 0; + + private Vector2 GetAimDirection() + { + if (Main.myPlayer == Projectile.owner) + { + Vector2 toMouse = (Main.MouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + float aimAngle = toMouse.ToRotation(); + if (Math.Abs(MathHelper.WrapAngle(aimAngle - Projectile.localAI[1])) > 0.02f) + { + Projectile.localAI[1] = aimAngle; + if (Projectile.timeLeft % 6 == 0) + Projectile.netUpdate = true; + } + return toMouse; + } + return Projectile.localAI[1].ToRotationVector2(); + } public override void SetDefaults() { Projectile.width = 12; @@ -56,6 +75,16 @@ namespace CalamityMod.Projectiles.Melee Projectile.noEnchantmentVisuals = true; } + public override void OnSpawn(Terraria.DataStructures.IEntitySource source) + { + if (Main.myPlayer == Projectile.owner) + { + Vector2 toMouse = (Owner.Calamity().mouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + Projectile.localAI[1] = toMouse.ToRotation(); + Projectile.netUpdate = true; + } + } + public override bool ShouldUpdatePosition() { return (ChargeProgress >= 1 && !stuckInGround && !stuckInTarget); @@ -64,20 +93,35 @@ namespace CalamityMod.Projectiles.Melee //Swing animation keys public CurveSegment pullback = new CurveSegment(EasingType.PolyOut, 0f, 0f, MathHelper.PiOver4 * -1.2f, 2); public CurveSegment throwout = new CurveSegment(EasingType.PolyOut, 0.7f, MathHelper.PiOver4 * -1.2f, MathHelper.PiOver4 * 1.2f + MathHelper.PiOver2, 3); - internal float ArmAnticipationMovement() => PiecewiseAnimation(ChargeProgress, new CurveSegment[] { pullback, throwout }); + internal float ArmAnticipationMovement(float progress) => PiecewiseAnimation(progress, new CurveSegment[] { pullback, throwout }); public override void AI() { + bool isOwner = Main.myPlayer == Projectile.owner; + if (!visualChargeInitialized && !isOwner) + { + int fallbackCharge = (int)MathHelper.Clamp((Owner.HeldItem.useTime / 2.8f), 1, 100); + visualChargeTime = (int)(Projectile.localAI[2] > 0f ? Projectile.localAI[2] : fallbackCharge); + visualChargeTimer = visualChargeTime; + visualChargeInitialized = true; + } + + if (!thrown && ChargeProgress >= 1f) + thrown = true; + + if (thrown && !stuckInGround && !stuckInTarget) + Projectile.extraUpdates = 1; + float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); Projectile.spriteDirection = Projectile.direction; Vector3 Light = Color.MediumOrchid.ToVector3(); Lighting.AddLight(Projectile.Center, Light * 0.5f); - if (Projectile.timeLeft == Lifetime) + if (Projectile.timeLeft == Lifetime && Main.myPlayer == Projectile.owner) { // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 toMouse = (Main.MouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + Vector2 toMouse = GetAimDirection(); Projectile.velocity = toMouse * 14; Projectile.Center = Owner.MountedCenter + toMouse * 12f; Projectile.spriteDirection = Projectile.direction; @@ -117,7 +161,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity *= 0.01f; stabbedTarget.Calamity().demonSwordImpales--; stuckInTarget = false; - fadeOutEffect(); + FadeOutEffect(); } Projectile.Center = stabbedTarget.Center + impalePos; @@ -143,7 +187,7 @@ namespace CalamityMod.Projectiles.Melee } if (fadingOut) - fadeOutEffect(); + FadeOutEffect(); } if (!fadingOut && !stuckInTarget && !stuckInGround && ChargeProgress >= 1) { @@ -162,7 +206,7 @@ namespace CalamityMod.Projectiles.Melee } if (exitedTarget && i == 0) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + safeVel.RotatedBy(Projectile.rotation - MathHelper.ToRadians(Projectile.direction * 45)) * 45, 278, dustVel * Main.rand.NextFloat(1, 4), 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + safeVel.RotatedBy(Projectile.rotation - MathHelper.ToRadians(Projectile.direction * 45)) * 45, DustID.FireworksRGB, dustVel * Main.rand.NextFloat(1, 4), 0, default, Main.rand.NextFloat(0.4f, 0.6f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.MediumOrchid : Color.BlueViolet; } @@ -176,9 +220,16 @@ namespace CalamityMod.Projectiles.Melee } //Anticipation animation. Make the player look like they're holding the item - if (ChargeProgress < 1) + float chargeProgress = ChargeProgress; + bool canVisualCharge = !isOwner && Projectile.velocity.LengthSquared() < 0.01f && visualChargeTimer > 0; + if (canVisualCharge) { - throwAnimation(); + chargeProgress = 1f - (visualChargeTimer / (float)visualChargeTime); + visualChargeTimer--; + } + if (chargeProgress < 1f) + { + throwAnimation(chargeProgress); if (ChargeProgress >= 0.6f && time == 0) { SoundStyle swing = new("CalamityMod/Sounds/Item/DemonSwordSwing", 2); @@ -190,7 +241,8 @@ namespace CalamityMod.Projectiles.Melee else time++; } - public void fadeOutEffect() + + public void FadeOutEffect() { Projectile.tileCollide = false; if (Projectile.timeLeft > Lifetime - fadeOutTime) @@ -209,11 +261,12 @@ namespace CalamityMod.Projectiles.Melee dust.velocity += Projectile.velocity; } } - public void throwAnimation() + public void throwAnimation(float chargeProgress) { - Owner.ChangeDir(MathF.Sign(Main.MouseWorld.X - Owner.Center.X)); + Vector2 aimDirection = GetAimDirection(); + Owner.ChangeDir(MathF.Sign(aimDirection.X)); - float armRotation = ArmAnticipationMovement() * Owner.direction; + float armRotation = ArmAnticipationMovement(chargeProgress) * Owner.direction; Owner.heldProj = Projectile.whoAmI; Projectile.spriteDirection = Owner.direction; @@ -298,7 +351,7 @@ namespace CalamityMod.Projectiles.Melee { if (bounces >= 2) { - impaleGround(oldVelocity); + ImpaleGround(oldVelocity); } else { @@ -313,19 +366,19 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.velocity.Length() < 8) Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 8; Projectile.velocity.Y *= 0.85f; - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center); bounces++; Projectile.timeLeft = Lifetime; } } else { - impaleGround(oldVelocity); + ImpaleGround(oldVelocity); } Projectile.netUpdate = true; return false; } - public void impaleGround(Vector2 oldVelocity) + public void ImpaleGround(Vector2 oldVelocity) { Projectile.velocity = oldVelocity; stuckInGround = true; @@ -333,6 +386,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; SoundStyle stuck = new("CalamityMod/Sounds/Item/DemonSwordImpact", 2); SoundEngine.PlaySound(stuck with { Volume = 0.75f, Pitch = Main.rand.NextFloat(0.2f, 0.3f), MaxInstances = 3 }, Projectile.Center); + Projectile.netUpdate = true; } public override bool? CanDamage() { @@ -359,25 +413,43 @@ namespace CalamityMod.Projectiles.Melee return false; } - /* public override void SendExtraAI(BinaryWriter writer) { - writer.Write(Projectile.timeLeft); - writer.Write(Projectile.rotation); - writer.Write(Projectile.localAI[2]); - writer.Write(Projectile.localAI[0]); + byte state = 0; + if (thrown) + state |= 1; + if (stuckInTarget) + state |= 2; + if (exitedTarget) + state |= 4; + if (stuckInGround) + state |= 8; - writer.WriteFlags(stuckInTarget, thrown); + writer.Write(state); + writer.Write(Projectile.rotation); + writer.Write(Projectile.localAI[0]); + writer.Write(Projectile.localAI[1]); + writer.Write(Projectile.localAI[2]); + writer.Write(impalePos.X); + writer.Write(impalePos.Y); + writer.Write(stuckTimer); + writer.Write((short)bounces); } public override void ReceiveExtraAI(BinaryReader reader) { - Projectile.timeLeft = reader.Read(); - Projectile.rotation = reader.ReadSingle(); - Projectile.localAI[2] = reader.ReadSingle(); - Projectile.localAI[0] = reader.ReadSingle(); + byte state = reader.ReadByte(); + thrown = (state & 1) != 0; + stuckInTarget = (state & 2) != 0; + exitedTarget = (state & 4) != 0; + stuckInGround = (state & 8) != 0; - reader.ReadFlags(out stuckInTarget, out thrown); + Projectile.rotation = reader.ReadSingle(); + Projectile.localAI[0] = reader.ReadSingle(); + Projectile.localAI[1] = reader.ReadSingle(); + Projectile.localAI[2] = reader.ReadSingle(); + impalePos = new Vector2(reader.ReadSingle(), reader.ReadSingle()); + stuckTimer = reader.ReadInt32(); + bounces = reader.ReadInt16(); } - */ } } diff --git a/Projectiles/Melee/GaelSkull.cs b/Projectiles/Melee/GaelSkull.cs index 173ff6754d..d50c20fc34 100644 --- a/Projectiles/Melee/GaelSkull.cs +++ b/Projectiles/Melee/GaelSkull.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Melee/GalacticaComet.cs b/Projectiles/Melee/GalacticaComet.cs index 1d273db9e9..7e8549252e 100644 --- a/Projectiles/Melee/GalacticaComet.cs +++ b/Projectiles/Melee/GalacticaComet.cs @@ -1,9 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Steamworks; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -91,7 +89,7 @@ namespace CalamityMod.Projectiles.Melee } else { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, (Vector2.One * 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f), 0, default, Main.rand.NextFloat(0.8f, 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, (Vector2.One * 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f), 0, default, Main.rand.NextFloat(0.8f, 1.3f)); dust.noGravity = false; dust.color = Color.Lerp(useColor, Color.White, 0.5f); } diff --git a/Projectiles/Melee/GalaxiaHoldout.cs b/Projectiles/Melee/GalaxiaHoldout.cs index 03485e975a..5ce21e06c0 100644 --- a/Projectiles/Melee/GalaxiaHoldout.cs +++ b/Projectiles/Melee/GalaxiaHoldout.cs @@ -152,12 +152,12 @@ namespace CalamityMod.Projectiles.Melee break; } - //Only draw the cool effect if you have enough particle slots left. Itd look really ugly to have a half complete constellation + // Only draw the cool effect if you have enough particle slots left. It'd look really ugly to have a half complete constellation if (GeneralParticleHandler.FreeSpacesAvailable() > StarPositions.Length * 2) { for (int i = 0; i < StarPositions.Length; i++) { - //The polar star gets bigger than the others. Also since andromeda has so many stars, make em smaller + // The polar star gets bigger than the others. Also since andromeda has so many stars, make em smaller Star = new GenericSparkle(Owner.Center + StarPositions[i], Vector2.Zero, Color.White, StarColor, (attunement.id == AttunementID.Polaris && i == 0) ? 3f : Main.rand.NextFloat(1f, 1.5f) * (attunement.id == AttunementID.Andromeda ? 0.8f : 1f), 20, 0f, 3f); GeneralParticleHandler.SpawnParticle(Star); @@ -175,10 +175,8 @@ namespace CalamityMod.Projectiles.Melee } } - //Chunger SoundEngine.PlaySound(CommonCalamitySounds.LightningSound with { Volume = CommonCalamitySounds.LightningSound.Volume * 0.4f }, Projectile.Center); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 5) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 5; + Main.LocalPlayer.SetScreenshake(5f); item.mainAttunement = attunement; } } diff --git a/Projectiles/Melee/Galaxia_AndromedasStride.cs b/Projectiles/Melee/Galaxia_AndromedasStride.cs index 0fc0b0e1bc..feb707f2c8 100644 --- a/Projectiles/Melee/Galaxia_AndromedasStride.cs +++ b/Projectiles/Melee/Galaxia_AndromedasStride.cs @@ -86,8 +86,7 @@ namespace CalamityMod.Projectiles.Melee { SoundEngine.PlaySound(SoundID.Item120 with { Volume = SoundID.Item120.Volume * 0.5f }, Projectile.Center); float screenshakeLevel = 4f + CurrentIndicator * 2f; - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenshakeLevel) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenshakeLevel; + Main.LocalPlayer.SetScreenshake(screenshakeLevel); CustomPulse shatter = new(Owner.Center, Vector2.Zero, Color.HotPink, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.0075f * CurrentIndicator, 0.075f * CurrentIndicator, 30); GeneralParticleHandler.SpawnParticle(shatter); diff --git a/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs b/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs index 00b06171b7..80cc94824c 100644 --- a/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs +++ b/Projectiles/Melee/Galaxia_AndromedasStrideBoltSpawner.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Melee/Galaxia_AriesWrath.cs b/Projectiles/Melee/Galaxia_AriesWrath.cs index 71e94c3a56..a1b0c8100a 100644 --- a/Projectiles/Melee/Galaxia_AriesWrath.cs +++ b/Projectiles/Melee/Galaxia_AriesWrath.cs @@ -146,9 +146,7 @@ namespace CalamityMod.Projectiles.Melee { Projectile.Center = Owner.Center; SoundEngine.PlaySound(SoundID.Item120 with { Volume = SoundID.Item120.Volume * 0.5f }, Projectile.Center); - - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; + Main.LocalPlayer.SetScreenshake(3f); } Projectile.scale = 1f + ScaleEquation(); diff --git a/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs b/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs index f28406a3ee..fb8dcc5914 100644 --- a/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs +++ b/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Melee if (!Main.dedServ) { Particles.Add(particle); - particle.Type = GeneralParticleHandler.particleTypes[particle.GetType()]; + particle.Type = GeneralParticleHandler.particleIDsByTypes[particle.GetType()]; } } diff --git a/Projectiles/Melee/Galaxia_PhoenixsPride.cs b/Projectiles/Melee/Galaxia_PhoenixsPride.cs index c473cb8de7..1d5953a2f1 100644 --- a/Projectiles/Melee/Galaxia_PhoenixsPride.cs +++ b/Projectiles/Melee/Galaxia_PhoenixsPride.cs @@ -99,8 +99,7 @@ namespace CalamityMod.Projectiles.Melee else if (CurrentState == 0f) { CurrentState = 1f; - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; + Main.LocalPlayer.SetScreenshake(3f); SoundEngine.PlaySound(SoundID.Item80, Projectile.Center); // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction @@ -263,8 +262,7 @@ namespace CalamityMod.Projectiles.Melee if (CurrentState == 1f && Main.myPlayer == Projectile.owner && !AnyProjectiles(ProjectileType())) { Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ProjectileType(), Projectile.damage, 0f, Projectile.owner, target.whoAmI); - if (proj.ModProjectile is PhoenixsPrideFirewall fire) - fire.Scale = MathHelper.Clamp(target.width / 100f, 0.3f, 1.25f); + (proj.ModProjectile as PhoenixsPrideFirewall).Scale = MathHelper.Clamp(target.width / 100f, 0.3f, 1.25f); } } diff --git a/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs b/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs index 2f4a52d81d..7a75e58733 100644 --- a/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs +++ b/Projectiles/Melee/Galaxia_PhoenixsPrideFirewall.cs @@ -1,9 +1,10 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Graphics.Primitives; +using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System.IO; +using System; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ID; @@ -11,11 +12,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class PhoenixsPrideFirewall : ModProjectile, ILocalizedModType + public class PhoenixsPrideFirewall : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public const int TornadoHeight = 480; + public const int MaxTornadoHeight = 270; public float Scale; // Size of the firewall, scales with NPC width public float fadeOut = 0f; // Used to control the firewall fading in and out at the start and end of its lifespan @@ -32,7 +33,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = -1; Projectile.alpha = 255; Projectile.scale = Scale; - Projectile.timeLeft = 150; + Projectile.timeLeft = 180; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = FourSeasonsGalaxia.PhoenixAttunement_FlamePillarLocalIFrames; } @@ -40,20 +41,30 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { // Constantly follow its target - // Die if the target is no longer active + // Immediately start fading away if the target is no longer active if (!Target.active) { - Projectile.Kill(); - return; + Projectile.velocity *= 0.975f; + if (Projectile.timeLeft > 15) + Projectile.timeLeft = 15; } else - Projectile.Center = Target.Center + Target.velocity; + Projectile.velocity = (Projectile.velocity * 13f + (Target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * 24f) / 14f; // Fade in and out at the start and end of its lifespan - if (Projectile.timeLeft > 145) - fadeOut += 0.15f; + if (Projectile.timeLeft > 170) + fadeOut += 0.1f; if (Projectile.timeLeft < 15) fadeOut -= 0.05f; + + // Some smoke on the base + if (Projectile.timeLeft % 3 == 0) + { + MediumMistParticle smoke = new(Projectile.Center, Main.rand.NextVector2Circular(6f, 6f), Color.Orange, Color.DarkOrange, 1.1f, 170f); + GeneralParticleHandler.SpawnParticle(smoke); + SquareParticle spark = new(Projectile.Center, -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * 8f, true, 20, 0.9f, Color.White); + GeneralParticleHandler.SpawnParticle(spark); + } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -62,46 +73,29 @@ namespace CalamityMod.Projectiles.Melee return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Bottom, - Projectile.Bottom - Vector2.UnitY * TornadoHeight, + Projectile.Bottom - Vector2.UnitY * MaxTornadoHeight, 72, ref _); } - public float WidthFunction(float completionRatio) => 50f * Scale * (completionRatio > 0.4f ? 1f : completionRatio * 2.5f); - - public override bool PreDraw(ref Color lightColor) + public float WidthFunction(float completionRatio, Vector2 vertexPos) => MathF.Max(50f * Scale * (MathF.Pow(1f - completionRatio, 2) * 2.75f), 0.35f); + public Color ColorFunction(float completionRatio, Vector2 vertexPos) => Color.Orange * (completionRatio > 0.1f ? 1f : completionRatio * 10f); + public void RenderPixelatedPrimitives(SpriteBatch spritebatch, GeneralDrawLayer layer) { - Main.spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:Bordernado"].UseSaturation(-0.2f); GameShaders.Misc["CalamityMod:Bordernado"].UseOpacity(fadeOut); GameShaders.Misc["CalamityMod:Bordernado"].SetShaderTexture(ModContent.Request("Terraria/Images/Misc/Perlin")); - Vector2[] drawPoints = new Vector2[5]; - Vector2 upwardAscent = Vector2.UnitY * TornadoHeight; + Vector2[] drawPoints = new Vector2[7]; + Vector2 upwardAscent = Vector2.UnitY * MaxTornadoHeight * fadeOut; Vector2 bottom = Projectile.Center; Vector2 top = bottom - upwardAscent; + // Offset is intentionally applied here instead of with an offset function in PrimitiveSettings to make it a bit choppier for (int i = 0; i < drawPoints.Length - 1; i++) - drawPoints[i] = Vector2.Lerp(top, bottom, i / (float)(drawPoints.Length - 1)); + drawPoints[i] = Vector2.Lerp(top + Vector2.UnitX * (MathF.Sin(Main.GameUpdateCount * 0.15f + i) * i * 6f), bottom, i / (float)(drawPoints.Length - 1)); drawPoints[drawPoints.Length - 1] = bottom; - PrimitiveRenderer.RenderTrail(drawPoints, new(WidthFunction, (_) => Color.Orange, shader: GameShaders.Misc["CalamityMod:Bordernado"]), 80); - - Main.spriteBatch.ExitShaderRegion(); - - Texture2D vortexTexture = ModContent.Request("CalamityMod/Projectiles/Boss/OldDukeVortex").Value; - for (int i = 0; i < 90; i++) - { - float angle = MathHelper.TwoPi * i / (25f * Scale) + Main.GlobalTimeWrappedHourly * MathHelper.TwoPi; - Color drawColor = Color.White * 0.04f; - drawColor.A = 0; - Vector2 drawPosition = bottom + angle.ToRotationVector2() * 4f - Main.screenPosition; - - drawPosition += (angle + Main.GlobalTimeWrappedHourly * i / 16f).ToRotationVector2() * 6f; - Main.EntitySpriteDraw(vortexTexture, drawPosition, null, drawColor * fadeOut, angle + MathHelper.PiOver2, vortexTexture.Size() * 0.5f, 0.2f * Scale, SpriteEffects.None, 0); - } - - return false; + PrimitiveRenderer.RenderTrail(drawPoints, new(WidthFunction, ColorFunction, pixelate: true, shader: GameShaders.Misc["CalamityMod:Bordernado"]), 80); } } } diff --git a/Projectiles/Melee/Galaxia_PolarisGazeDash.cs b/Projectiles/Melee/Galaxia_PolarisGazeDash.cs index 8d25d0320a..dd5c3acc47 100644 --- a/Projectiles/Melee/Galaxia_PolarisGazeDash.cs +++ b/Projectiles/Melee/Galaxia_PolarisGazeDash.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Melee/GalaxySmasherEcho.cs b/Projectiles/Melee/GalaxySmasherEcho.cs index c9eba67b70..614a496c49 100644 --- a/Projectiles/Melee/GalaxySmasherEcho.cs +++ b/Projectiles/Melee/GalaxySmasherEcho.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f)); Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 278, (-Projectile.velocity + velOffset) * Main.rand.NextFloat(0.3f, 1f), 0, default, Main.rand.NextFloat(0.35f, 0.75f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.FireworksRGB, (-Projectile.velocity + velOffset) * Main.rand.NextFloat(0.3f, 1f), 0, default, Main.rand.NextFloat(0.35f, 0.75f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Magenta : Color.Aqua; @@ -97,10 +97,8 @@ namespace CalamityMod.Projectiles.Melee { if (targeted != null && target != targeted) modifiers.SourceDamage *= 0.3f; - } - public override bool? CanHitNPC(NPC target) - { - return null; + else + modifiers.SetCrit(); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -112,8 +110,8 @@ namespace CalamityMod.Projectiles.Melee public override bool PreKill(int timeLeft) { Player player = Main.player[Projectile.owner]; - //This is what we call fucking IMPACT (3). - Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 15; + // This is what we call fucking IMPACT (3). + Main.player[Projectile.owner].SetScreenshake(15f); if (Main.zenithWorld) SoundEngine.PlaySound(Kunk, Projectile.Center); else diff --git a/Projectiles/Melee/GalaxySmasherHammer.cs b/Projectiles/Melee/GalaxySmasherHammer.cs index d36e49c644..5a66ea8800 100644 --- a/Projectiles/Melee/GalaxySmasherHammer.cs +++ b/Projectiles/Melee/GalaxySmasherHammer.cs @@ -158,7 +158,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.DD2_BetsysWrathShot with { Volume = 0.4f }, Projectile.Center); for (int i = 0; i < 30; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center, 181); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.GiantCursedSkullBolt); fire.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.8f) * new Vector2(4f, 1.25f) * Main.rand.NextFloat(0.9f, 1f); fire.velocity = fire.velocity.RotatedBy(Projectile.rotation - MathHelper.PiOver2); fire.velocity += Projectile.velocity * (EmpoweredHammer * 0.04f); @@ -209,7 +209,7 @@ namespace CalamityMod.Projectiles.Melee velOffset *= Main.rand.NextFloat(45, 65) * fade; Particle energy = new SparkParticle(Projectile.Center + velOffset * 2.5f, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, false, 14, Main.rand.NextFloat(1.1f, 1.25f) - 0.5f * fade, usedColor); GeneralParticleHandler.SpawnParticle(energy); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, 278, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, DustID.FireworksRGB, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); dust.noGravity = true; dust.color = usedColor; GalaxyMetaball.SpawnParticle(Projectile.Center + velOffset * 1.5f, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 50f * Main.rand.NextFloat(0.9f, 1.3f) * fade); @@ -217,13 +217,13 @@ namespace CalamityMod.Projectiles.Melee } if (EchoHammerPrep > 40) { - int hammer = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity, ModContent.ProjectileType(), Projectile.damage * 10, Projectile.knockBack * 2.5f, Projectile.owner, 0f, Projectile.ai[1]); + int hammer = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity, ModContent.ProjectileType(), Projectile.damage * 9, Projectile.knockBack * 2.5f, Projectile.owner, 0f, Projectile.ai[1]); Main.projectile[hammer].localAI[0] = Math.Sign(Projectile.velocity.X); Main.projectile[hammer].netUpdate = true; Projectile.Kill(); } else - EchoHammerPrep += 0.2f; + EchoHammerPrep += 0.275f; } if (targetDist < 1400) @@ -232,7 +232,7 @@ namespace CalamityMod.Projectiles.Melee { Vector2 offset = new Vector2(12, 0).RotatedByRandom(MathHelper.ToRadians(360f)); Vector2 velOffset = new Vector2(4, 0).RotatedBy(offset.ToRotation()); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 278, -Projectile.velocity * 0.2f + velOffset, 100, default, 0.7f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.FireworksRGB, -Projectile.velocity * 0.2f + velOffset, 100, default, 0.7f); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Magenta : Color.Aqua; } diff --git a/Projectiles/Melee/GalileoGladiusGlow.png b/Projectiles/Melee/GalileoGladiusGlow.png new file mode 100644 index 0000000000..d12f3ee1f6 Binary files /dev/null and b/Projectiles/Melee/GalileoGladiusGlow.png differ diff --git a/Projectiles/Melee/GalileosMoon.cs b/Projectiles/Melee/GalileosMoon.cs index 6a8bc39a8a..88004c2446 100644 --- a/Projectiles/Melee/GalileosMoon.cs +++ b/Projectiles/Melee/GalileosMoon.cs @@ -27,12 +27,12 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; - Projectile.penetrate = -1; + Projectile.penetrate = 3; Projectile.extraUpdates = 2; - Projectile.timeLeft = 135 * Projectile.MaxUpdates; + Projectile.timeLeft = 240 * Projectile.MaxUpdates; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 13; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 10; } public override void AI() @@ -47,7 +47,8 @@ namespace CalamityMod.Projectiles.Melee } } Projectile.rotation += Projectile.direction * 0.55f; - CalamityUtils.HomeInOnNPC(Projectile, true, 250f, 10f, 25f); + if (Projectile.timeLeft < 230 * Projectile.MaxUpdates) + CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 10f, 25f); } public override bool PreDraw(ref Color lightColor) @@ -55,10 +56,5 @@ namespace CalamityMod.Projectiles.Melee CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } } } diff --git a/Projectiles/Melee/GalileosPlanet.cs b/Projectiles/Melee/GalileosPlanet.cs deleted file mode 100644 index 5a1b7ac0d9..0000000000 --- a/Projectiles/Melee/GalileosPlanet.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class GalileosPlanet : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - private float radius = 84f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 6; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 88; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.extraUpdates = 1; - Projectile.penetrate = 1; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - for (float i = -5; i <= 0; i++) - { - if (Main.rand.NextFloat(1f) < 0.4f) - { - // You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle. - Vector2 pos = Projectile.position + new Vector2((Projectile.width / 2) - 8, Projectile.height + 16); - Dust dust1 = Dust.NewDustPerfect(pos + new Vector2(-20 + i, -2), 180, new Vector2(i * 0.7f, -1.1f)); - dust1.noGravity = true; - } - } - for (float i = 0; i <= 5; i++) - { - if (Main.rand.NextFloat(1f) < 0.4f) - { - // You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle. - Vector2 pos = Projectile.position + new Vector2((Projectile.width / 2) - 8, Projectile.height + 16); - Dust dust1 = Dust.NewDustPerfect(pos + new Vector2(20 + i, -2), 180, new Vector2(i * 0.7f, -1.1f)); - dust1.noGravity = true; - } - } - - Dust dust; - // You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle. - Vector2 pos2 = Projectile.Center - new Vector2(20, 20); - dust = Main.dust[Dust.NewDust(pos2, 40, 40, DustID.DungeonSpirit, 0f, 0f, 0, new Color(255, 255, 255), 1f)]; - - Lighting.AddLight(Projectile.Center, 0.3f, 0.3f, 0.7f); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override void OnKill(int timeLeft) - { - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 32; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - radius = 100; - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.damage /= 2; - Projectile.Damage(); - for (int i = 0; i < 72; i++) - { - Dust dust; - // You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle. - Vector2 position = Projectile.Center - new Vector2(30, 30); - dust = Main.dust[Terraria.Dust.NewDust(position, 60, 60, DustID.Flare_Blue, Main.rand.Next(-5, 5), Main.rand.Next(-5, 5), 0, new Color(0, 167, 255), 5f)]; - dust.noGravity = true; - dust.shader = GameShaders.Armor.GetSecondaryShader(47, Main.LocalPlayer); - } - - SoundEngine.PlaySound(SoundID.NPCDeath43, Projectile.position); - - for (int i = 0; i < 155; i++) - { - Dust dust; - // You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle. - Vector2 position = Projectile.position; - dust = Main.dust[Dust.NewDust(position, 94, 94, DustID.DungeonSpirit, Main.rand.Next(-5, 5), Main.rand.Next(-5, 5), 0, new Color(255, 255, 255), Main.rand.NextFloat(1.2f, 2.2f))]; - dust.noGravity = true; - } - - for (int x = 1; x <= 3; x++) - { - int dustAmt = 36; - for (int i = 0; i < dustAmt; i++) - { - Vector2 spinningpoint = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f * 0.5f; - spinningpoint = spinningpoint.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default(Vector2)) + Projectile.Center; - Vector2 vector = spinningpoint - Projectile.Center; - int stratus = Dust.NewDust(spinningpoint + vector, 0, 0, DustID.DungeonSpirit, vector.X * 2f, vector.Y * 2f, 0, new Color(255, 255, 255), 1f); - Main.dust[stratus].noGravity = true; - Main.dust[stratus].velocity = Vector2.Normalize(vector) * x; - } - } - - for (int x = 1; x <= 3; x++) - { - int dustAmt = 36; - for (int i = 0; i < dustAmt; i++) - { - Vector2 spinningpoint = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f * 0.5f; - spinningpoint = spinningpoint.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default(Vector2)) + Projectile.Center; - Vector2 vector = spinningpoint - Projectile.Center; - int stratus = Dust.NewDust(spinningpoint + vector, 0, 0, DustID.DungeonSpirit, vector.X * 2f, vector.Y * 2f, 0, new Color(255, 255, 255), 1f); - Main.dust[stratus].noGravity = true; - Main.dust[stratus].velocity = Vector2.Normalize(vector) * x; - Main.dust[stratus].velocity *= 2; - } - } - - if (!Main.dedServ) - { - Vector2 goreSource = Projectile.Center; - int goreAmt = 3; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 240); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, radius, targetHitbox); - } -} diff --git a/Projectiles/Melee/GalileosPlanet.png b/Projectiles/Melee/GalileosPlanet.png deleted file mode 100644 index d1eb525387..0000000000 Binary files a/Projectiles/Melee/GalileosPlanet.png and /dev/null differ diff --git a/Projectiles/Melee/GayBeam.cs b/Projectiles/Melee/GayBeam.cs deleted file mode 100644 index 5d016effdc..0000000000 --- a/Projectiles/Melee/GayBeam.cs +++ /dev/null @@ -1,470 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Primitives; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class GayBeam : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - - private const int Alpha = 100; - - private const int TimeLeft = 600; - - private const int TrailLength = 36; - - private const int TotalAfterimages = 12; - - private const int AfterimageOffset = TrailLength / TotalAfterimages; - - private const float MaxVelocity = 24f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = TrailLength; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.timeLeft = TimeLeft; - Projectile.alpha = Alpha; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Projectile.localAI[0]); - writer.Write(Projectile.localAI[1]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - Projectile.localAI[0] = reader.ReadSingle(); - Projectile.localAI[1] = reader.ReadSingle(); - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); - - if (Projectile.ai[2] == 0f) - SoundEngine.PlaySound(SoundID.Item60, Projectile.Center); - - Color color = GetProjectileColor(); - switch ((int)Projectile.ai[0]) - { - case 0: // Red, normal beam - break; - - case 1: // Orange, curve back to player - - int player = (int)Player.FindClosest(Projectile.Center, 1, 1); - Projectile.ai[1] += 1f; - if (Projectile.ai[1] < 360f && Projectile.ai[1] > 60f) - { - float homeSpeed = Projectile.velocity.Length(); - Vector2 vecToPlayer = Main.player[player].Center - Projectile.Center; - vecToPlayer = vecToPlayer.SafeNormalize(Vector2.UnitY); - vecToPlayer *= homeSpeed; - Projectile.velocity = (Projectile.velocity * 29f + vecToPlayer) / 30f; - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - Projectile.velocity *= homeSpeed; - } - - if (Projectile.velocity.Length() < MaxVelocity) - { - Projectile.velocity *= 1.01f; - if (Projectile.velocity.Length() > MaxVelocity) - { - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - Projectile.velocity *= MaxVelocity; - } - } - - break; - - case 2: // Yellow, split after a certain time - - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] >= 45f) - { - int numProj = 2; - float rotation = MathHelper.ToRadians(10); - if (Projectile.owner == Main.myPlayer) - { - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed * MaxVelocity, Projectile.type, (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner); - } - } - - Projectile.Kill(); - } - - break; - - case 3: // Lime, home in on player within certain distance - - float inertia = 30f; - float homingSpeed = MaxVelocity; - float minDist = 300f; - if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead) - { - if (Projectile.Distance(Main.player[Projectile.owner].Center) > minDist) - { - Vector2 moveDirection = Projectile.SafeDirectionTo(Main.player[Projectile.owner].Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * (inertia - 1f) + moveDirection * homingSpeed) / inertia; - } - } - else - { - if (Projectile.timeLeft > 30) - Projectile.timeLeft = 30; - } - - break; - - case 4: // Green, home in on enemies - - CalamityUtils.HomeInOnNPC(Projectile, false, 600f, MaxVelocity, 30f); - - break; - - case 5: // Turquoise, speed up and don't collide with tiles - - Projectile.tileCollide = false; - if (Projectile.velocity.Length() < MaxVelocity) - { - Projectile.velocity *= 1.03f; - if (Projectile.velocity.Length() > MaxVelocity) - { - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - Projectile.velocity *= MaxVelocity; - } - } - - break; - - case 6: // Cyan, upon death create several turquoise swords - case 7: // Light Blue, slow down on hit - case 8: // Blue, bounce off of tiles and enemies - break; - - case 9: // Purple, speed up and slow down over and over - - if (Projectile.localAI[1] < 30f) - Projectile.velocity *= 0.95f; - else if (Projectile.localAI[1] < 60f) - Projectile.velocity *= 1.07f; - else if (Projectile.localAI[1] == 60f) - Projectile.localAI[1] = -1f; - Projectile.localAI[1] += 1f; - - break; - - case 10: // Fuschia, start slow then get faster - - if (Projectile.localAI[1] == 0f) - { - Projectile.velocity *= 0.1f; - Projectile.localAI[1] += 1f; - } - - if (Projectile.velocity.Length() < MaxVelocity) - { - Projectile.velocity *= 1.05f; - if (Projectile.velocity.Length() > MaxVelocity) - { - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY); - Projectile.velocity *= MaxVelocity; - } - } - - break; - - case 11: // Hot Pink, split into fuschia while travelling - - if (Projectile.localAI[1] == 0f) - Projectile.velocity *= 0.333f; - - if (Projectile.localAI[1] >= 45f) - { - Projectile.localAI[1] = 0f; - if (Main.myPlayer == Projectile.owner) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Projectile.oldVelocity, Projectile.velocity, Projectile.type, (int)Math.Round(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner, 10f, 0f); - } - Projectile.localAI[1] += 1f; - - break; - - default: - break; - } - - Projectile.ai[2] += MathHelper.Lerp(1f, 2f, Projectile.ai[0] / 11f); - if (Projectile.ai[2] > 7f) - { - Dust rainbow = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X - Projectile.velocity.X + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y), 8, 8, DustID.RainbowMk2, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, Projectile.alpha, default, 1.25f)]; - rainbow.velocity *= -0.25f; - rainbow.color = color; - rainbow.color.A = 100; - rainbow.scale = Main.rand.NextFloat(1f, 1.25f); - rainbow.fadeIn = Main.rand.NextFloat(0.4f, 1f); - rainbow.noGravity = true; - rainbow.noLightEmittence = true; - - rainbow = Main.dust[Dust.NewDust(new Vector2(Projectile.position.X - Projectile.velocity.X + 2f, Projectile.position.Y + 2f - Projectile.velocity.Y), 8, 8, DustID.RainbowMk2, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, Projectile.alpha, default, 1.25f)]; - rainbow.velocity *= -0.25f; - rainbow.color = color; - rainbow.color.A = 100; - rainbow.scale = Main.rand.NextFloat(1f, 1.25f); - rainbow.fadeIn = Main.rand.NextFloat(0.4f, 1f); - rainbow.noGravity = true; - rainbow.position -= Projectile.velocity * 0.5f; - rainbow.noLightEmittence = true; - - if (Projectile.localAI[0] == 0f) - { - Projectile.scale -= 0.02f; - Projectile.alpha += 5; - if (Projectile.alpha >= Alpha - 5) - { - Projectile.alpha = Alpha; - Projectile.localAI[0] = 1f; - } - } - else if (Projectile.localAI[0] == 1f) - { - Projectile.scale += 0.02f; - Projectile.alpha -= 5; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.localAI[0] = 0f; - } - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 300); - - if (Projectile.ai[0] == 7f) - Projectile.velocity *= 0.5f; - else if (Projectile.ai[0] == 8f) - Projectile.velocity *= -1f; - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 300); - - if (Projectile.ai[0] == 7f) - Projectile.velocity *= 0.5f; - else if (Projectile.ai[0] == 8f) - Projectile.velocity *= -1f; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (Projectile.ai[0] == 8f) - { - if (Projectile.velocity.X != oldVelocity.X) - Projectile.velocity.X = -oldVelocity.X; - if (Projectile.velocity.Y != oldVelocity.Y) - Projectile.velocity.Y = -oldVelocity.Y; - - return false; - } - - return true; - } - - public Color TrailColor(float completionRatio) - { - float hue = (Main.GlobalTimeWrappedHourly * -0.62f + completionRatio * 1.5f) % 1f; - float brightness = MathHelper.SmoothStep(0.5f, 1f, Utils.GetLerpValue(0.3f, 0f, completionRatio, true)); - float opacity = Utils.GetLerpValue(1f, 0.8f, completionRatio, true) * ((255 - Projectile.alpha) / 255f); - Color color = GetProjectileColor() * opacity; - color.A = (byte)(int)(Utils.GetLerpValue(0f, 0.2f, completionRatio) * 128); - return color; - } - - public float TrailWidth(float completionRatio) - { - float widthInterpolant = Utils.GetLerpValue(0f, 0.25f, completionRatio, true) * Utils.GetLerpValue(1.1f, 0.7f, completionRatio, true); - return MathHelper.SmoothStep(0f, 14f, widthInterpolant) * Projectile.scale; - } - - public override Color? GetAlpha(Color lightColor) => GetProjectileColor(); - - public override bool PreDraw(ref Color lightColor) - { - if (Projectile.timeLeft > TimeLeft - 5) - return false; - - Main.spriteBatch.EnterShaderRegion(); - - GameShaders.Misc["CalamityMod:ArtAttack"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - GameShaders.Misc["CalamityMod:ArtAttack"].Apply(); - - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ArtAttack"]), TrailLength); - - Main.spriteBatch.ExitShaderRegion(); - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - int frameHeight = texture.Height / Main.projFrames[Type]; - int frameY = frameHeight * Projectile.frame; - float scale = Projectile.scale; - Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); - Vector2 origin = rectangle.Size() / 2f; - Color alphaColor = Projectile.GetAlpha(lightColor); - - if (CalamityClientConfig.Instance.Afterimages) - { - Vector2 centerOffset = Projectile.Size / 2f; - int totalAfterimages = TotalAfterimages; - for (int i = 0; i < totalAfterimages; i++) - { - int arrayPos = i * AfterimageOffset; - float afterimageRot = Projectile.oldRot[arrayPos]; - SpriteEffects sfxForThisAfterimage = Projectile.oldSpriteDirection[arrayPos] == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Vector2 drawPos = Projectile.oldPos[arrayPos] + centerOffset - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - float colorAndSizeScalar = (float)(totalAfterimages - i) / (float)totalAfterimages; - Color color = alphaColor * colorAndSizeScalar; - float afterimageScale = scale * MathHelper.Lerp(0.5f, 1f, colorAndSizeScalar); - Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(rectangle), color, afterimageRot, origin, afterimageScale, sfxForThisAfterimage, 0f); - } - } - else - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), rectangle, alphaColor, Projectile.rotation, origin, scale, spriteEffects, 0f); - } - - return false; - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - - Color color = GetProjectileColor(); - switch ((int)Projectile.ai[0]) - { - case 0: // Red - case 1: // Orange - case 2: // Yellow - case 3: // Lime - case 4: // Green - case 5: // Turquoise - break; - - case 6: // Cyan - - for (int x = 0; x < 2; x++) - { - if (Projectile.owner == Main.myPlayer) - { - var source = Projectile.GetSource_FromThis(); - CalamityUtils.ProjectileBarrage(source, Projectile.Center, Projectile.Center, x == 1, 500f, 500f, 0f, 500f, MaxVelocity, Projectile.type, (int)Math.Round(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner, false, 0f).ai[0] = 5f; - } - } - - break; - - case 7: // Light Blue - case 8: // Blue - case 9: // Purple - case 10: // Fuschia - case 11: // Hot Pink - default: - break; - } - - int totalDust = 60; - for (int i = 4; i < totalDust + 1; i++) - { - Vector2 oldVel = Projectile.oldVelocity * (totalDust / (float)i); - Dust rainbow = Main.dust[Dust.NewDust(Projectile.oldPosition - oldVel * 0.5f, 8, 8, DustID.RainbowMk2, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, Projectile.alpha)]; - rainbow.color = color; - rainbow.color.A = 100; - rainbow.scale = Main.rand.NextFloat(2.4f, 3.6f); - rainbow.fadeIn = Main.rand.NextFloat(0.4f, 1f); - rainbow.noGravity = true; - rainbow.velocity *= (Main.rand.NextBool() ? 0.05f : 0.5f); - } - } - - private Color GetProjectileColor() - { - Color rainbow = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Alpha); - Color color = Color.White; - switch ((int)Projectile.ai[0]) - { - case 0: // Red - color = new Color(255, 0, 0, Alpha); - break; - case 1: // Orange - color = new Color(255, 128, 0, Alpha); - break; - case 2: // Yellow - color = new Color(255, 255, 0, Alpha); - break; - case 3: // Lime - color = new Color(128, 255, 0, Alpha); - break; - case 4: // Green - color = new Color(0, 255, 0, Alpha); - break; - case 5: // Turquoise - color = new Color(0, 255, 128, Alpha); - break; - case 6: // Cyan - color = new Color(0, 255, 255, Alpha); - break; - case 7: // Light Blue - color = new Color(0, 128, 255, Alpha); - break; - case 8: // Blue - color = new Color(0, 0, 255, Alpha); - break; - case 9: // Purple - color = new Color(128, 0, 255, Alpha); - break; - case 10: // Fuschia - color = new Color(255, 0, 255, Alpha); - break; - case 11: // Hot Pink - color = new Color(255, 0, 128, Alpha); - break; - default: - break; - } - return Color.Lerp(rainbow, color, (float)Math.Sqrt((MathF.Cos(Projectile.ai[2] / 90f) + 1f) * 0.5f)); - } - } -} diff --git a/Projectiles/Melee/GayBeam.png b/Projectiles/Melee/GayBeam.png deleted file mode 100644 index 50aac5b8b2..0000000000 Binary files a/Projectiles/Melee/GayBeam.png and /dev/null differ diff --git a/Projectiles/Melee/GelWave.cs b/Projectiles/Melee/GelWave.cs index de43a94052..e8e142abcb 100644 --- a/Projectiles/Melee/GelWave.cs +++ b/Projectiles/Melee/GelWave.cs @@ -1,7 +1,5 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -10,6 +8,8 @@ namespace CalamityMod.Projectiles.Melee public class GelWave : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 10; @@ -32,11 +32,6 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - if (Projectile.localAI[0] == 0f) - { - SoundEngine.PlaySound(SoundID.Item92, Projectile.position); - Projectile.localAI[0] += 1f; - } Lighting.AddLight(Projectile.Center, Color.Blue.ToVector3()); Projectile.rotation = Projectile.velocity.ToRotation(); if (Main.rand.NextBool(10)) @@ -56,7 +51,7 @@ namespace CalamityMod.Projectiles.Melee } if (Projectile.timeLeft > 60) { - Dust disgustingtrail = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, 119, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f)); + Dust disgustingtrail = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, DustID.Ice_Pink, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f)); disgustingtrail.noGravity = true; disgustingtrail.scale = 1.2f; } diff --git a/Projectiles/Melee/GemTechYellowShard.cs b/Projectiles/Melee/GemTechYellowShard.cs index 07091b3d31..a48970bd9c 100644 --- a/Projectiles/Melee/GemTechYellowShard.cs +++ b/Projectiles/Melee/GemTechYellowShard.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 initialVelocity = (Main.rand.NextFloatDirection() * 0.11f).ToRotationVector2() * Main.rand.NextFloat(2f, 3.3f); for (int i = 0; i < 4; i++) { - Dust crystalShard = Dust.NewDustPerfect(Projectile.Center, 267); + Dust crystalShard = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); crystalShard.velocity = initialVelocity * i / 4f; crystalShard.scale = 1.225f; crystalShard.color = Color.Yellow; diff --git a/Projectiles/Melee/GhastlySoulLarge.cs b/Projectiles/Melee/GhastlySoulLarge.cs index 0aad553929..a8b8e4810c 100644 --- a/Projectiles/Melee/GhastlySoulLarge.cs +++ b/Projectiles/Melee/GhastlySoulLarge.cs @@ -1,9 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -129,7 +126,7 @@ namespace CalamityMod.Projectiles.Melee } for (int k = 0; k < 17; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 66, new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowTorch, new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f)); dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); dust2.noGravity = true; dust2.color = Color.Plum; diff --git a/Projectiles/Melee/GhastlySoulMedium.cs b/Projectiles/Melee/GhastlySoulMedium.cs index c168ae37db..1108dfe9fb 100644 --- a/Projectiles/Melee/GhastlySoulMedium.cs +++ b/Projectiles/Melee/GhastlySoulMedium.cs @@ -1,9 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -129,7 +126,7 @@ namespace CalamityMod.Projectiles.Melee } for (int k = 0; k < 12; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 66, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowTorch, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f)); dust2.scale = Main.rand.NextFloat(0.85f, 1.25f); dust2.noGravity = true; dust2.color = Color.Plum; diff --git a/Projectiles/Melee/GhastlySoulSmall.cs b/Projectiles/Melee/GhastlySoulSmall.cs index 1458537533..d6daec9cdf 100644 --- a/Projectiles/Melee/GhastlySoulSmall.cs +++ b/Projectiles/Melee/GhastlySoulSmall.cs @@ -1,10 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Ammo; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -130,7 +126,7 @@ namespace CalamityMod.Projectiles.Melee } for (int k = 0; k < 7; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 66, new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowTorch, new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.8f)); dust2.scale = Main.rand.NextFloat(0.65f, 0.85f); dust2.noGravity = true; dust2.color = Color.Plum; diff --git a/Projectiles/Melee/GrandDadHoldout.cs b/Projectiles/Melee/GrandDadHoldout.cs index da3aea142e..f1151eec3a 100644 --- a/Projectiles/Melee/GrandDadHoldout.cs +++ b/Projectiles/Melee/GrandDadHoldout.cs @@ -1,8 +1,6 @@ -using System.Data; -using System.IO; -using System.Runtime.CompilerServices; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.NPCs.PrimordialWyrm; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; @@ -11,12 +9,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class GrandDadHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -38,6 +37,7 @@ namespace CalamityMod.Projectiles.Melee public int swingCount; public bool finalFlip = false; public bool swingSound = true; + public int armoredHits = 0; private NPC target => Main.npc[(int)Projectile.ai[0]]; @@ -102,6 +102,7 @@ namespace CalamityMod.Projectiles.Melee swingCount++; finalFlip = false; swingSound = true; + armoredHits = 0; } else { @@ -193,7 +194,7 @@ namespace CalamityMod.Projectiles.Melee { float randRot = Main.rand.NextFloat(-30, -60); Vector2 dustVel = (new Vector2(0, 15 * -Projectile.ai[1] * Owner.direction)).RotatedBy(FinalRotation + MathHelper.ToRadians(randRot)); - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(185, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, dustVel * Main.rand.NextFloat(0.1f, 0.5f)); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(185, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, dustVel * Main.rand.NextFloat(0.1f, 0.5f)); dust2.scale = Main.rand.NextFloat(0.55f, 1.05f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Goldenrod : Color.Gold; @@ -208,13 +209,11 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) + if ((target.life <= 0 && target.realLife == -1) && Projectile.numHits > 0) Projectile.numHits -= 1; + if (damageDone <= 2) + armoredHits++; - SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1"); - SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = -0.1f }, Projectile.Center); - SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash"); - SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center); if (Main.zenithWorld && Projectile.numHits == 0 && target.type != ModContent.NPCType() && Main.rand.NextBool(5)) { SoundStyle fire3 = new("CalamityMod/Sounds/Item/GFBScreams/Scream", 8); @@ -222,13 +221,17 @@ namespace CalamityMod.Projectiles.Melee } if (Projectile.numHits == 0) { - Owner.Calamity().GeneralScreenShakePower = 6.5f; + Owner.SetScreenshake(6.5f); + SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1"); + SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = -0.1f }, Projectile.Center); + SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash"); + SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center); } int heal = (int)(MathHelper.Clamp(20 - Projectile.numHits * 12, 1, 20)); if (Projectile.numHits < 10) { - Owner.HealPlayer(heal); + Owner.DoLifestealDirect(target, heal, 0.5f); } if (target.CanBeMoved(true) || Main.zenithWorld || target.type == ModContent.NPCType() || (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs)) @@ -253,8 +256,10 @@ namespace CalamityMod.Projectiles.Melee // Remove knockback resist, just like it used to target.knockBackResist = 1; - // Apply tile collison damage (is bonus on GFB and even further is both final bosses are gone) - target.FlungNPC().ApplyCollisionDamage(target, Owner, Projectile.damage * (Main.zenithWorld ? (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs ? 1000 : 77) : 3) * (rightClicked ? 3 : 1), launchVel * launchPower, 5f, true); + // Apply tile collison damage (is boosted on GFB and even further if both final bosses are gone) + float damageMults = ((DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs) ? 5 : 1) * (Main.zenithWorld ? 77 : 1) * (rightClicked ? 3 : 1); + int damage = (int)(Projectile.damage * damageMults); + target.GetGlobalNPC().ApplyCollisionDamage(target, Owner, damage, launchVel * launchPower, 5f, true); } if (Projectile.numHits < 3) @@ -276,12 +281,15 @@ namespace CalamityMod.Projectiles.Melee public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (Owner.Calamity().mouseRight) - modifiers.SourceDamage *= 0.0025f; + { + modifiers.SourceDamage *= 0; + modifiers.FinalDamage.Flat = 0.1f; + } else { float minMult = 0.5f; int hitsToMinMult = 15; - float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + float damageMult = Utils.Remap(Projectile.numHits - armoredHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; } } diff --git a/Projectiles/Melee/GrandGuardianBoom.cs b/Projectiles/Melee/GrandGuardianBoom.cs index 875b820907..271653a439 100644 --- a/Projectiles/Melee/GrandGuardianBoom.cs +++ b/Projectiles/Melee/GrandGuardianBoom.cs @@ -1,8 +1,6 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/GrandGuardianHoldout.cs b/Projectiles/Melee/GrandGuardianHoldout.cs index 41156a4121..51978ae71d 100644 --- a/Projectiles/Melee/GrandGuardianHoldout.cs +++ b/Projectiles/Melee/GrandGuardianHoldout.cs @@ -1,22 +1,19 @@ -using System; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.NPCs.PrimordialWyrm; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class GrandGuardianHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -39,6 +36,7 @@ namespace CalamityMod.Projectiles.Melee public bool spawnBoom = true; public bool finalFlip = false; public bool playSwingSound = true; + public int armoredHits = 0; public override void SetDefaults() { base.SetDefaults(); @@ -98,6 +96,7 @@ namespace CalamityMod.Projectiles.Melee doSwing = true; finalFlip = false; + armoredHits = 0; } else { @@ -175,7 +174,7 @@ namespace CalamityMod.Projectiles.Melee GenericSparkle sparker = new GenericSparkle(Owner.Center + (new Vector2(198, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), Vector2.Zero, color ? Color.Cyan : Color.DarkOrchid, color ? Color.DarkOrchid : Color.Cyan, Main.rand.NextFloat(0.4f, 0.6f), 10, Main.rand.NextFloat(-0.1f, 0.1f), 2.68f); GeneralParticleHandler.SpawnParticle(sparker); - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(180, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 2)); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(180, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 2)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool() ? Color.Cyan : Color.DarkOrchid; @@ -189,8 +188,10 @@ namespace CalamityMod.Projectiles.Melee } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) + if ((target.life <= 0 && target.realLife == -1) && Projectile.numHits > 0) Projectile.numHits -= 1; + if (damageDone <= 2) + armoredHits++; Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); target.MoveNPC(launchVel, 8, true); @@ -209,7 +210,7 @@ namespace CalamityMod.Projectiles.Melee int heal = (int)(MathHelper.Clamp(5 - Projectile.numHits * 3, 1, 5)); if (Projectile.numHits < 5) { - Owner.HealPlayer(heal); + Owner.DoLifestealDirect(target, heal, 0.75f); } int points = 4; @@ -225,7 +226,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++) { - Dust dust2 = Dust.NewDustPerfect(target.Center, 278, new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.7f)); + Dust dust2 = Dust.NewDustPerfect(target.Center, DustID.FireworksRGB, new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.7f)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool() ? Color.Cyan : Color.DarkOrchid; @@ -235,7 +236,7 @@ namespace CalamityMod.Projectiles.Melee { float minMult = 0.3f; int hitsToMinMult = 5; - float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + float damageMult = Utils.Remap(Projectile.numHits - armoredHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Melee/GreenWater.cs b/Projectiles/Melee/GreenWater.cs index 831386263b..9d0b61b44e 100644 --- a/Projectiles/Melee/GreenWater.cs +++ b/Projectiles/Melee/GreenWater.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Melee SparkParticle orb2 = new(Projectile.Center - offset, -Projectile.velocity * 0.05f, false, 7, 0.7f, Color.Aqua * 0.6f * fade); GeneralParticleHandler.SpawnParticle(orb2); - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), 102, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 180, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), DustID.Water_Desert, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 180, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; dust.alpha = (int)MathHelper.Clamp(Projectile.alpha, 0, 180); @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), 5, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), DustID.Blood, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; dust.alpha = (int)MathHelper.Clamp(Projectile.alpha, 0, 100); } @@ -123,7 +123,7 @@ namespace CalamityMod.Projectiles.Melee } for (int i = 0; i <= 4; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 5, (Projectile.velocity * 2.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, (Projectile.velocity * 2.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.8f)); dust.noGravity = false; } for (int i = 0; i <= 2; i++) diff --git a/Projectiles/Melee/HellionSpike.cs b/Projectiles/Melee/HellionSpike.cs index 7955c988a0..bae234c799 100644 --- a/Projectiles/Melee/HellionSpike.cs +++ b/Projectiles/Melee/HellionSpike.cs @@ -21,11 +21,12 @@ namespace CalamityMod.Projectiles.Melee Projectile.aiStyle = ProjAIStyleID.Beam; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 3; + Projectile.penetrate = 2; + Projectile.MaxUpdates = 2; Projectile.timeLeft = 600; AIType = ProjectileID.SporeCloud; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; + Projectile.localNPCHitCooldown = 8 * Projectile.MaxUpdates; } public override void AI() @@ -73,7 +74,7 @@ namespace CalamityMod.Projectiles.Melee var source = Projectile.GetSource_FromThis(); if (Projectile.owner == Main.myPlayer) { - Projectile petal = CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 10f, ProjectileID.FlowerPetal, (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner, true); + Projectile petal = CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, Main.rand.NextBool(), 800f, 800f, 0f, 800f, 24f, ProjectileID.FlowerPetal, (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.5f, Projectile.owner, false, 0f); if (petal.whoAmI.WithinBounds(Main.maxProjectiles)) { petal.DamageType = DamageClass.Melee; diff --git a/Projectiles/Melee/HellkiteHoldout.cs b/Projectiles/Melee/HellkiteHoldout.cs index f9fc98014c..a9a8633e1d 100644 --- a/Projectiles/Melee/HellkiteHoldout.cs +++ b/Projectiles/Melee/HellkiteHoldout.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -8,12 +9,13 @@ using ReLogic.Content; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class HellkiteHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -141,7 +143,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 particleVel = (Owner.Center - particlePos).SafeNormalize(Vector2.UnitX) * -15; particlePos += Main.rand.NextVector2Circular(20, 20); - Dust dust2 = Dust.NewDustPerfect(particlePos, 267, particleVel * Main.rand.NextFloat(0.2f, 1)); + Dust dust2 = Dust.NewDustPerfect(particlePos, DustID.RainbowMk2, particleVel * Main.rand.NextFloat(0.2f, 1)); dust2.scale = Main.rand.NextFloat(0.65f, 1.15f) * fadeIn * GFBMulti; dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; @@ -185,7 +187,7 @@ namespace CalamityMod.Projectiles.Melee { Particle spark2 = new LineParticle(particlePos, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), false, 30, Main.rand.NextFloat(0.3f, 0.8f), Main.rand.NextBool(3) ? Color.Red : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark2); - Dust dust2 = Dust.NewDustPerfect(particlePos, 267, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f)); + Dust dust2 = Dust.NewDustPerfect(particlePos, DustID.RainbowMk2, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f)); dust2.scale = Main.rand.NextFloat(0.65f, 1.15f) * fadeIn; dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; @@ -313,7 +315,7 @@ namespace CalamityMod.Projectiles.Melee { float randRot = Main.rand.NextFloat(-30, -60); Vector2 dustVel = (new Vector2(0, 15 * -Projectile.ai[1] * Owner.direction)).RotatedBy(FinalRotation + MathHelper.ToRadians(randRot)); - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(170, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, dustVel * Main.rand.NextFloat(0.3f, 0.9f)); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(170, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, dustVel * Main.rand.NextFloat(0.3f, 0.9f)); dust2.scale = Main.rand.NextFloat(0.65f, 0.95f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; @@ -325,7 +327,7 @@ namespace CalamityMod.Projectiles.Melee { float randRot = Main.rand.NextFloat(-30, -60); Vector2 dustVel = (new Vector2(0, 15 * -Projectile.ai[1] * Owner.direction)).RotatedBy(FinalRotation + MathHelper.ToRadians(randRot)); - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(170, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, dustVel * Main.rand.NextFloat(0.1f, 0.5f)); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(170, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, dustVel * Main.rand.NextFloat(0.1f, 0.5f)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; @@ -356,7 +358,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits == 0) { SoundEngine.PlaySound(Hellkite.HitSoundSmall with { Volume = 0.85f, PitchVariance = 0.25f }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 4.5f; + Owner.SetScreenshake(4.5f); } for (int i = 0; i < MathHelper.Clamp(8 - Projectile.numHits * 2, 2, 8); i++) { @@ -374,7 +376,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits == 0) { SoundEngine.PlaySound(Hellkite.HitSoundBig with { Volume = 1f }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 8.5f * GFBMulti; + Owner.SetScreenshake(8.5f * GFBMulti); bool photos = CalamityClientConfig.Instance.Photosensitivity; if (!photos) @@ -402,7 +404,7 @@ namespace CalamityMod.Projectiles.Melee Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Color.DarkRed); GeneralParticleHandler.SpawnParticle(spark3); } - Dust dust2 = Dust.NewDustPerfect(target.Center, 278, new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1)); + Dust dust2 = Dust.NewDustPerfect(target.Center, DustID.FireworksRGB, new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * GFBMulti; dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; @@ -418,10 +420,11 @@ namespace CalamityMod.Projectiles.Melee if (chargedSwing) modifiers.SetCrit(); + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); float minMult = 0.25f; int hitsToMinMult = 10; float damageMult = Utils.Remap(pierceReduction, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= (chargedSwing ? 3f * (GFBMulti) : 1) * damageMult; + modifiers.SourceDamage *= (chargedSwing ? (2.9f * GFBMulti + critDamage) : 1) * damageMult; } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/HolyColliderHoldout.cs b/Projectiles/Melee/HolyColliderHoldout.cs index d342eee4c5..de8e35f5aa 100644 --- a/Projectiles/Melee/HolyColliderHoldout.cs +++ b/Projectiles/Melee/HolyColliderHoldout.cs @@ -2,20 +2,23 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class HolyColliderHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -331,10 +334,29 @@ namespace CalamityMod.Projectiles.Melee for (int x = 0; x < Main.maxProjectiles; x++) { Projectile projectile = Main.projectile[x]; - if (Vector2.Distance(Owner.Center + (new Vector2(100, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))), projectile.Center) <= 100 && projectile.active && projectile.type == ModContent.ProjectileType()) + bool isProviProj = (projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType()); + bool isAFireball = (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.ai[0] != 10) || isProviProj; + if (Vector2.Distance(Owner.Center + (new Vector2(60, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))), projectile.Center) <= 150 + Math.Max(projectile.width, projectile.height) && projectile.active && isAFireball) { - projectile.ai[2] = 5; - projectile.owner = Owner.whoAmI; + if (isProviProj) + { + Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), projectile.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -2.5f, ModContent.ProjectileType(), (int)((Projectile.damage * 0.1) + projectile.damage), Projectile.knockBack, Projectile.owner, 0, 15, 5); + Particle orb2 = new CustomPulse(projectile.Center, Vector2.Zero, Color.Goldenrod, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.8f, 11); + GeneralParticleHandler.SpawnParticle(orb2); + if (projectile.type == ModContent.ProjectileType()) + projectile.active = false; + else + projectile.Kill(); + } + else + { + projectile.ai[2] = 5; + projectile.owner = Owner.whoAmI; + } } } } @@ -343,7 +365,8 @@ namespace CalamityMod.Projectiles.Melee for (int x = 0; x < Main.maxProjectiles; x++) { Projectile projectile = Main.projectile[x]; - if (Vector2.Distance(Owner.Center + (new Vector2(100, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))), projectile.Center) <= 100 && projectile.active && projectile.type == ModContent.ProjectileType() && projectile.ai[0] != 10) + bool isAFireball = (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.ai[0] != 10); + if (Vector2.Distance(Owner.Center + (new Vector2(60, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))), projectile.Center) <= 150 && isAFireball) { Vector2 launch = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -2.5f; projectile.velocity += launch; @@ -401,7 +424,7 @@ namespace CalamityMod.Projectiles.Melee float starAngle = MathHelper.ToRadians(45f); for (int i = 0; i < 4; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); Vector2 vel = (MathHelper.TwoPi * i / 4f).ToRotationVector2().RotatedBy(starAngle) * 4f; Particle pulse = new CustomSpark(target.Center, vel, "CalamityMod/Particles/BloomCircle", false, 12, 1.2f, Color.Orange, new Vector2(3.2f, 0.9f), true, true, shrinkSpeed: 0.95f); @@ -409,7 +432,7 @@ namespace CalamityMod.Projectiles.Melee } for (int i = 0; i < 4; i++) { - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, (new Vector2(0, -35).RotatedBy(MathHelper.ToRadians(45f))).RotatedBy(MathHelper.ToRadians(90f) * i), ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), Projectile.knockBack, Projectile.owner, 0, target.whoAmI); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, (new Vector2(0, -35).RotatedBy(MathHelper.ToRadians(45f))).RotatedBy(MathHelper.ToRadians(90f) * i), ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), Projectile.knockBack, Projectile.owner, 0); } } } diff --git a/Projectiles/Melee/HolyColliderHolyFire.cs b/Projectiles/Melee/HolyColliderHolyFire.cs index fd51d02d91..0318c62d67 100644 --- a/Projectiles/Melee/HolyColliderHolyFire.cs +++ b/Projectiles/Melee/HolyColliderHolyFire.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Melee public bool setStats = true; public static int statMax = 8; public int setStatTimer = statMax; - public int time = 0; + public ref float time => ref Projectile.ai[1]; public override void SetStaticDefaults() { Main.projFrames[Type] = 4; @@ -44,10 +44,13 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Player Owner = Main.player[Projectile.owner]; - if (Projectile.ai[2] == 5 && time > 10 && Projectile.ai[0] != 10) + int hitTime = 13; // Time to pass before it can be launched + + if (Projectile.ai[2] == 5 && time >= hitTime && Projectile.ai[0] != 10) isLaunched = true; else Projectile.ai[2] = 0; + Projectile.scale = Utils.GetLerpValue(0, 40, Projectile.timeLeft, true); @@ -67,7 +70,7 @@ namespace CalamityMod.Projectiles.Melee float starAngle = Main.rand.NextFloat(-0.9f, 0.9f); for (int i = 0; i < 4; i++) { - Dust chargefull = Dust.NewDustPerfect(Projectile.Center, 278); + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); Vector2 vel = (MathHelper.TwoPi * i / 4f).ToRotationVector2().RotatedBy(starAngle) * 8f; Particle pulse = new GlowSparkParticle(Projectile.Center, vel, false, 10, 0.08f, Color.Orange, new Vector2(3.2f, 0.9f), true, true, 0.9f); @@ -154,7 +157,7 @@ namespace CalamityMod.Projectiles.Melee Player Owner = Main.player[Projectile.owner]; if (isLaunched && Projectile.scale > 0.2f) { - Owner.Calamity().GeneralScreenShakePower = 9f; + Owner.SetScreenshake(9f); SoundStyle sound = new("CalamityMod/Sounds/Item/HolyColliderProjectileHit"); SoundEngine.PlaySound(sound with { Volume = 1f }, Projectile.Center); diff --git a/Projectiles/Melee/IceBombFriendly.cs b/Projectiles/Melee/IceBombFriendly.cs index 5bd09ba952..d858ee8cdb 100644 --- a/Projectiles/Melee/IceBombFriendly.cs +++ b/Projectiles/Melee/IceBombFriendly.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Projectiles.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Melee/IllustriousKnife.cs b/Projectiles/Melee/IllustriousKnife.cs index 9f9b9c19d9..08c78e6cec 100644 --- a/Projectiles/Melee/IllustriousKnife.cs +++ b/Projectiles/Melee/IllustriousKnife.cs @@ -1,6 +1,4 @@ using System; -using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Terraria; @@ -73,31 +71,7 @@ namespace CalamityMod.Projectiles.Melee } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - int heal = (int)Math.Round(hit.Damage * 0.015); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 180); - - int heal = (int)Math.Round(info.Damage * 0.015); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ModContent.ProjectileType(), (int)Math.Round(hit.Damage * 0.015), 0.4f); public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/InsidiousHarpoon.cs b/Projectiles/Melee/InsidiousHarpoon.cs index 19356cd8b4..2fb89841b5 100644 --- a/Projectiles/Melee/InsidiousHarpoon.cs +++ b/Projectiles/Melee/InsidiousHarpoon.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -14,6 +15,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class InsidiousHarpoon : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; diff --git a/Projectiles/Melee/IridescentExcaliburSlash.cs b/Projectiles/Melee/IridescentExcaliburSlash.cs deleted file mode 100644 index a91263e002..0000000000 --- a/Projectiles/Melee/IridescentExcaliburSlash.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Graphics.Primitives; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.GameContent; -using Terraria.GameContent.Drawing; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Balancing; -using CalamityMod.Projectiles.Healing; - -namespace CalamityMod.Projectiles.Melee -{ - public class IridescentExcaliburSlash : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 4; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.ownerHitCheck = true; - Projectile.ownerHitCheckDistance = 300f; - Projectile.usesOwnerMeleeHitCD = true; - Projectile.stopsDealingDamageAfterPenetrateHits = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - Projectile.localAI[0] += 1f; - Player player = Main.player[Projectile.owner]; - float num = Projectile.localAI[0] / Projectile.ai[1]; - float num2 = Projectile.ai[0]; - float num3 = Projectile.velocity.ToRotation(); - float num4 = (float)Math.PI * num2 * num + num3 + num2 * (float)Math.PI + player.fullRotation; - Projectile.rotation = num4; - float num5 = 1f; - float num6 = 1.2f; - - Projectile.Center = player.RotatedRelativePoint(player.MountedCenter) - Projectile.velocity; - Projectile.scale = num6 + num * num5; - - float colorAIScale = Projectile.localAI[0] / Projectile.ai[1]; - float amount = Utils.Remap(colorAIScale, 0f, 0.6f, 0f, 1f) * Utils.Remap(colorAIScale, 0.6f, 1f, 1f, 0f); - Color rainbow = Color.Lerp(new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), amount); - float num8 = Projectile.rotation + Main.rand.NextFloatDirection() * MathHelper.PiOver2 * 0.7f; - Vector2 vector2 = Projectile.Center + num8.ToRotationVector2() * 84f * Projectile.scale; - Vector2 vector3 = (num8 + Projectile.ai[0] * MathHelper.PiOver2).ToRotationVector2(); - if (Main.rand.NextFloat() * 2f < Projectile.Opacity) - { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + num8.ToRotationVector2() * (Main.rand.NextFloat() * 80f * Projectile.scale + 20f * Projectile.scale), 278, vector3 * 1f, 100, rainbow, 0.4f); - dust2.fadeIn = 0.4f + Main.rand.NextFloat() * 0.15f; - dust2.noGravity = true; - } - - if (Main.rand.NextFloat() * 1.5f < Projectile.Opacity) - Dust.NewDustPerfect(vector2, 43, vector3 * 1f, 100, rainbow * Projectile.Opacity, 1.2f * Projectile.Opacity); - - float num10 = Projectile.rotation + Main.rand.NextFloatDirection() * MathHelper.PiOver2 * 0.7f; - Vector2 vector5 = Projectile.Center + num10.ToRotationVector2() * 84f * Projectile.scale; - Vector2 vector6 = (num10 + Projectile.ai[0] * MathHelper.PiOver2).ToRotationVector2(); - if (Main.rand.NextFloat() < Projectile.Opacity) - { - Dust dust4 = Dust.NewDustPerfect(Projectile.Center + num10.ToRotationVector2() * (Main.rand.NextFloat() * 80f * Projectile.scale + 20f * Projectile.scale), 278, vector6 * 1f, 100, rainbow, 0.4f); - dust4.fadeIn = 0.4f + Main.rand.NextFloat() * 0.15f; - dust4.noGravity = true; - } - - if (Main.rand.NextFloat() * 1.5f < Projectile.Opacity) - Dust.NewDustPerfect(vector5, 43, vector6 * 1f, 100, rainbow * Projectile.Opacity, 1.2f * Projectile.Opacity); - - Projectile.scale *= Projectile.ai[2]; - if (Projectile.localAI[0] >= Projectile.ai[1]) - Projectile.Kill(); - - // Enchantment visual bullshit - Vector2 boxPosition = Projectile.position; - int boxWidth = Projectile.width; - int boxHeight = Projectile.height; - for (float i = -MathHelper.PiOver4; i <= MathHelper.PiOver4; i += MathHelper.PiOver2) - { - Rectangle rect = Utils.CenteredRectangle(Projectile.Center + (Projectile.rotation + i).ToRotationVector2() * 70f * Projectile.scale, new Vector2(60f * Projectile.scale, 60f * Projectile.scale)); - Projectile.EmitEnchantmentVisualsAt(rect.TopLeft(), rect.Width, rect.Height); - } - } - - public override bool PreDraw(ref Color lightColor) - { - Vector2 vector = Projectile.Center - Main.screenPosition; - Texture2D asset = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle rectangle = asset.Frame(1, 4); - Vector2 origin = rectangle.Size() / 2f; - float num = Projectile.scale * 1.1f; - SpriteEffects effects = ((!(Projectile.ai[0] >= 0f)) ? SpriteEffects.FlipVertically : SpriteEffects.None); - float num2 = Projectile.localAI[0] / Projectile.ai[1]; - float num3 = Utils.Remap(num2, 0f, 0.6f, 0f, 1f) * Utils.Remap(num2, 0.6f, 1f, 1f, 0f); - float num4 = 0.975f; - float amount = num3; - float fromValue = Lighting.GetColor(Projectile.Center.ToTileCoordinates()).ToVector3().Length() / (float)Math.Sqrt(3D); - fromValue = Utils.Remap(fromValue, 0.2f, 1f, 0f, 1f); - Color color = Color.Lerp(new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), amount); - Main.spriteBatch.Draw(asset, vector, rectangle, color * fromValue * num3, Projectile.rotation + Projectile.ai[0] * MathHelper.PiOver4 * -1f * (1f - num2), origin, num, effects, 0f); - Color color2 = Color.Lerp(new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), amount); - Color color3 = Color.Lerp(new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), amount); - Color color4 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB) * num3 * 0.5f; - Color color5 = color4 * fromValue * 0.5f; - Main.spriteBatch.Draw(asset, vector, rectangle, color5 * 0.15f, Projectile.rotation + Projectile.ai[0] * 0.01f, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, rectangle, color3 * fromValue * num3 * 0.3f, Projectile.rotation, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, rectangle, color2 * fromValue * num3 * 0.5f, Projectile.rotation, origin, num * num4, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB) * 0.6f * num3, Projectile.rotation + Projectile.ai[0] * 0.01f, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB) * 0.5f * num3, Projectile.rotation + Projectile.ai[0] * -0.05f, origin, num * 0.8f, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB) * 0.4f * num3, Projectile.rotation + Projectile.ai[0] * -0.1f, origin, num * 0.6f, effects, 0f); - float num5 = num * 0.75f; - Texture2D value = TextureAssets.Extra[98].Value; - Color shineColor = color3 * Projectile.Opacity * 0.5f; - Vector2 origin2 = value.Size() / 2f; - float num9 = Utils.GetLerpValue(0f, 0.5f, num2, clamped: true) * Utils.GetLerpValue(1f, 0.5f, num2, clamped: true); - Vector2 vector3 = new Vector2((Vector2.One * num5).X * 0.5f, (new Vector2(0f, Utils.Remap(num2, 0f, 1f, 3f, 0f)) * num5).X) * num9; - Vector2 vector2 = new Vector2((Vector2.One * num5).Y * 0.5f, (new Vector2(0f, Utils.Remap(num2, 0f, 1f, 3f, 0f)) * num5).Y) * num9; - shineColor *= num9; - for (float num6 = 0f; num6 < 12f; num6 += 1f) - { - float num7 = Projectile.rotation + Projectile.ai[0] * num6 * -MathHelper.TwoPi * 0.025f + Utils.Remap(num2, 0f, 0.6f, 0f, 0.95504415f) * Projectile.ai[0]; - Vector2 drawpos = vector + num7.ToRotationVector2() * ((float)asset.Width * 0.5f - 6f) * num; - float num8 = num6 / 12f; - - Color color6 = new Color(255, 255, 255, 0) * num3 * num8 * 0.5f; - color6 *= num9; - Main.EntitySpriteDraw(value, drawpos, null, shineColor, MathHelper.PiOver2 + num7, origin2, vector3, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, shineColor, 0f + num7, origin2, vector2, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, color6, MathHelper.PiOver2 + num7, origin2, vector3 * 0.6f, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, color6, 0f + num7, origin2, vector2 * 0.6f, SpriteEffects.None); - } - - Vector2 drawpos2 = vector + (Projectile.rotation + Utils.Remap(num2, 0f, 0.6f, 0f, 0.95504415f) * Projectile.ai[0]).ToRotationVector2() * ((float)asset.Width * 0.5f - 4f) * num; - Color color7 = new Color(255, 255, 255, 0) * num3 * 0.5f; - color7 *= num9; - Main.EntitySpriteDraw(value, drawpos2, null, shineColor, MathHelper.PiOver2 + Projectile.rotation, origin2, vector3, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, shineColor, 0f + Projectile.rotation, origin2, vector2, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, color7, MathHelper.PiOver2 + Projectile.rotation, origin2, vector3 * 0.6f, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, color7, 0f + Projectile.rotation, origin2, vector2 * 0.6f, SpriteEffects.None); - - return false; - } - - public override void CutTiles() - { - Vector2 startPoint = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * 60f * Projectile.scale; - Vector2 endPoint = (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * 60f * Projectile.scale; - float projectileSize = 60f * Projectile.scale; - Utils.PlotTileLine(Projectile.Center + startPoint, Projectile.Center + endPoint, projectileSize, DelegateMethods.CutTiles); - } - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - modifiers.HitDirectionOverride = (Main.player[Projectile.owner].Center.X < target.Center.X) ? 1 : -1; - - Vector2 positionInWorld = Main.rand.NextVector2FromRectangle(target.Hitbox); - ParticleOrchestraSettings particleOrchestraSettings = default(ParticleOrchestraSettings); - particleOrchestraSettings.PositionInWorld = positionInWorld; - ParticleOrchestraSettings settings = particleOrchestraSettings; - switch (Main.rand.Next(5)) - { - default: - case 0: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.NightsEdge, settings, Projectile.owner); - break; - - case 1: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TrueNightsEdge, settings, Projectile.owner); - break; - - case 2: - settings.MovementVector = Projectile.velocity; - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TerraBlade, settings, Projectile.owner); - break; - - case 3: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.Excalibur, settings, Projectile.owner); - break; - - case 4: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TrueExcalibur, settings, Projectile.owner); - break; - } - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - float coneLength = 94f * Projectile.scale; - float scale = MathHelper.TwoPi / 25f * Projectile.ai[0]; - float maximumAngle = MathHelper.PiOver4; - float coneRotation = Projectile.rotation + scale; - if (targetHitbox.IntersectsConeSlowMoreAccurate(Projectile.Center, coneLength, coneRotation, maximumAngle)) - return true; - - float rotation = Utils.Remap(Projectile.localAI[0], Projectile.ai[1] * 0.3f, Projectile.ai[1] * 0.5f, 1f, 0f); - if (rotation > 0f) - { - float coneRotation2 = coneRotation - MathHelper.PiOver4 * Projectile.ai[0] * rotation; - if (targetHitbox.IntersectsConeSlowMoreAccurate(Projectile.Center, coneLength, coneRotation2, maximumAngle)) - return true; - } - - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 600); - target.AddBuff(ModContent.BuffType(), 60); - - int heal = (int)Math.Round(hit.Damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 600); - target.AddBuff(ModContent.BuffType(), 60); - - int heal = (int)Math.Round(info.Damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); - } - } -} diff --git a/Projectiles/Melee/IridescentExcaliburSlash.png b/Projectiles/Melee/IridescentExcaliburSlash.png deleted file mode 100644 index 9a31d6718a..0000000000 Binary files a/Projectiles/Melee/IridescentExcaliburSlash.png and /dev/null differ diff --git a/Projectiles/Melee/IridescentExcaliburSlash2.cs b/Projectiles/Melee/IridescentExcaliburSlash2.cs deleted file mode 100644 index 54728381f9..0000000000 --- a/Projectiles/Melee/IridescentExcaliburSlash2.cs +++ /dev/null @@ -1,231 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Graphics.Primitives; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.GameContent; -using Terraria.GameContent.Drawing; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; - -namespace CalamityMod.Projectiles.Melee -{ - public class IridescentExcaliburSlash2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/Melee/IridescentExcaliburSlash"; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 4; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.ownerHitCheck = true; - Projectile.ownerHitCheckDistance = 300f; - Projectile.usesOwnerMeleeHitCD = true; - Projectile.stopsDealingDamageAfterPenetrateHits = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 3; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - Projectile.localAI[0] += 1f; - Player player = Main.player[Projectile.owner]; - float num = Projectile.localAI[0] / Projectile.ai[1]; - float num2 = Projectile.ai[0]; - float num3 = Projectile.velocity.ToRotation(); - float num4 = (float)Math.PI * num2 * num + num3 + num2 * (float)Math.PI + player.fullRotation; - Projectile.rotation = num4; - float num5 = 0.8f; - float num6 = 1.1f; - - Projectile.Center = player.RotatedRelativePoint(player.MountedCenter) - Projectile.velocity; - Projectile.scale = num6 + num * num5; - - float colorAIScale = Projectile.localAI[0] / Projectile.ai[1]; - float amount = Utils.Remap(colorAIScale, 0f, 0.6f, 0f, 1f) * Utils.Remap(colorAIScale, 0.6f, 1f, 1f, 0f); - Color rainbow = Color.Lerp(new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), amount); - float num8 = Projectile.rotation + Main.rand.NextFloatDirection() * MathHelper.PiOver2 * 0.7f; - Vector2 vector2 = Projectile.Center + num8.ToRotationVector2() * 84f * Projectile.scale; - Vector2 vector3 = (num8 + Projectile.ai[0] * MathHelper.PiOver2).ToRotationVector2(); - if (Main.rand.NextFloat() * 2f < Projectile.Opacity) - { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + num8.ToRotationVector2() * (Main.rand.NextFloat() * 80f * Projectile.scale + 20f * Projectile.scale), 278, vector3 * 1f, 100, rainbow, 0.4f); - dust2.fadeIn = 0.4f + Main.rand.NextFloat() * 0.15f; - dust2.noGravity = true; - } - - if (Main.rand.NextFloat() * 1.5f < Projectile.Opacity) - Dust.NewDustPerfect(vector2, 43, vector3 * 1f, 100, rainbow * Projectile.Opacity, 1.2f * Projectile.Opacity); - - float num10 = Projectile.rotation + Main.rand.NextFloatDirection() * MathHelper.PiOver2 * 0.7f; - Vector2 vector5 = Projectile.Center + num10.ToRotationVector2() * 84f * Projectile.scale; - Vector2 vector6 = (num10 + Projectile.ai[0] * MathHelper.PiOver2).ToRotationVector2(); - if (Main.rand.NextFloat() < Projectile.Opacity) - { - Dust dust4 = Dust.NewDustPerfect(Projectile.Center + num10.ToRotationVector2() * (Main.rand.NextFloat() * 80f * Projectile.scale + 20f * Projectile.scale), 278, vector6 * 1f, 100, rainbow, 0.4f); - dust4.fadeIn = 0.4f + Main.rand.NextFloat() * 0.15f; - dust4.noGravity = true; - } - - if (Main.rand.NextFloat() * 1.5f < Projectile.Opacity) - Dust.NewDustPerfect(vector5, 43, vector6 * 1f, 100, rainbow * Projectile.Opacity, 1.2f * Projectile.Opacity); - - Projectile.scale *= Projectile.ai[2]; - if (Projectile.localAI[0] >= Projectile.ai[1]) - Projectile.Kill(); - - // Enchantment visual bullshit - Vector2 boxPosition = Projectile.position; - int boxWidth = Projectile.width; - int boxHeight = Projectile.height; - for (float i = -MathHelper.PiOver4; i <= MathHelper.PiOver4; i += MathHelper.PiOver2) - { - Rectangle rect = Utils.CenteredRectangle(Projectile.Center + (Projectile.rotation + i).ToRotationVector2() * 70f * Projectile.scale, new Vector2(60f * Projectile.scale, 60f * Projectile.scale)); - Projectile.EmitEnchantmentVisualsAt(rect.TopLeft(), rect.Width, rect.Height); - } - } - - public override bool PreDraw(ref Color lightColor) - { - Vector2 vector = Projectile.Center - Main.screenPosition; - Texture2D asset = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle rectangle = asset.Frame(1, 4); - Vector2 origin = rectangle.Size() / 2f; - float num = Projectile.scale * 1.1f; - SpriteEffects effects = ((!(Projectile.ai[0] >= 0f)) ? SpriteEffects.FlipVertically : SpriteEffects.None); - float num2 = Projectile.localAI[0] / Projectile.ai[1]; - float num3 = Utils.Remap(num2, 0f, 0.6f, 0f, 1f) * Utils.Remap(num2, 0.6f, 1f, 1f, 0f); - float num4 = 0.975f; - float amount = num3; - float fromValue = Lighting.GetColor(Projectile.Center.ToTileCoordinates()).ToVector3().Length() / (float)Math.Sqrt(3D); - fromValue = Utils.Remap(fromValue, 0.2f, 1f, 0f, 1f); - Color color = Color.Lerp(new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), amount); - Main.spriteBatch.Draw(asset, vector, rectangle, color * fromValue * num3, Projectile.rotation + Projectile.ai[0] * MathHelper.PiOver4 * -1f * (1f - num2), origin, num, effects, 0f); - Color color2 = Color.Lerp(new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), amount); - Color color3 = Color.Lerp(new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB), new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), amount); - Color color4 = new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB) * num3 * 0.5f; - color4.A = (byte)(((float)(int)color4.A * (1f - fromValue)) * 0.5f); - Color color5 = color4 * fromValue * 0.5f; - Main.spriteBatch.Draw(asset, vector, rectangle, color5 * 0.15f, Projectile.rotation + Projectile.ai[0] * 0.01f, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, rectangle, color3 * fromValue * num3 * 0.3f, Projectile.rotation, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, rectangle, color2 * fromValue * num3 * 0.5f, Projectile.rotation, origin, num * num4, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB) * 0.6f * num3, Projectile.rotation + Projectile.ai[0] * 0.01f, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB) * 0.5f * num3, Projectile.rotation + Projectile.ai[0] * -0.05f, origin, num * 0.8f, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(255 - Main.DiscoR, 255 - Main.DiscoG, 255 - Main.DiscoB) * 0.4f * num3, Projectile.rotation + Projectile.ai[0] * -0.1f, origin, num * 0.6f, effects, 0f); - float num5 = num * 0.75f; - Texture2D value = TextureAssets.Extra[98].Value; - Color shineColor = color3 * Projectile.Opacity * 0.5f; - shineColor.A /= 2; - Vector2 origin2 = value.Size() / 2f; - float num9 = Utils.GetLerpValue(0f, 0.5f, num2, clamped: true) * Utils.GetLerpValue(1f, 0.5f, num2, clamped: true); - Vector2 vector3 = new Vector2((Vector2.One * num5).X * 0.5f, (new Vector2(0f, Utils.Remap(num2, 0f, 1f, 3f, 0f)) * num5).X) * num9; - Vector2 vector2 = new Vector2((Vector2.One * num5).Y * 0.5f, (new Vector2(0f, Utils.Remap(num2, 0f, 1f, 3f, 0f)) * num5).Y) * num9; - shineColor *= num9; - for (float num6 = 0f; num6 < 12f; num6 += 1f) - { - float num7 = Projectile.rotation + Projectile.ai[0] * num6 * -MathHelper.TwoPi * 0.025f + Utils.Remap(num2, 0f, 0.6f, 0f, 0.95504415f) * Projectile.ai[0]; - Vector2 drawpos = vector + num7.ToRotationVector2() * ((float)asset.Width * 0.5f - 6f) * num; - float num8 = num6 / 12f; - - Color color6 = new Color(255, 255, 255, 0) * num3 * num8 * 0.5f; - color6 *= num9; - Main.EntitySpriteDraw(value, drawpos, null, shineColor, MathHelper.PiOver2 + num7, origin2, vector3, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, shineColor, 0f + num7, origin2, vector2, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, color6, MathHelper.PiOver2 + num7, origin2, vector3 * 0.6f, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, color6, 0f + num7, origin2, vector2 * 0.6f, SpriteEffects.None); - } - - Vector2 drawpos2 = vector + (Projectile.rotation + Utils.Remap(num2, 0f, 0.6f, 0f, 0.95504415f) * Projectile.ai[0]).ToRotationVector2() * ((float)asset.Width * 0.5f - 4f) * num; - Color color7 = new Color(255, 255, 255, 0) * num3 * 0.5f; - color7 *= num9; - Main.EntitySpriteDraw(value, drawpos2, null, shineColor, MathHelper.PiOver2 + Projectile.rotation, origin2, vector3, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, shineColor, 0f + Projectile.rotation, origin2, vector2, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, color7, MathHelper.PiOver2 + Projectile.rotation, origin2, vector3 * 0.6f, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, color7, 0f + Projectile.rotation, origin2, vector2 * 0.6f, SpriteEffects.None); - - return false; - } - - public override void CutTiles() - { - Vector2 startPoint = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * 60f * Projectile.scale; - Vector2 endPoint = (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * 60f * Projectile.scale; - float projectileSize = 60f * Projectile.scale; - Utils.PlotTileLine(Projectile.Center + startPoint, Projectile.Center + endPoint, projectileSize, DelegateMethods.CutTiles); - } - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - modifiers.HitDirectionOverride = (Main.player[Projectile.owner].Center.X < target.Center.X) ? 1 : -1; - - Vector2 positionInWorld = Main.rand.NextVector2FromRectangle(target.Hitbox); - ParticleOrchestraSettings particleOrchestraSettings = default(ParticleOrchestraSettings); - particleOrchestraSettings.PositionInWorld = positionInWorld; - ParticleOrchestraSettings settings = particleOrchestraSettings; - switch (Main.rand.Next(5)) - { - default: - case 0: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.NightsEdge, settings, Projectile.owner); - break; - - case 1: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TrueNightsEdge, settings, Projectile.owner); - break; - - case 2: - settings.MovementVector = Projectile.velocity; - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TerraBlade, settings, Projectile.owner); - break; - - case 3: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.Excalibur, settings, Projectile.owner); - break; - - case 4: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TrueExcalibur, settings, Projectile.owner); - break; - } - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - float coneLength = 94f * Projectile.scale; - float scale = MathHelper.TwoPi / 25f * Projectile.ai[0]; - float maximumAngle = MathHelper.PiOver4; - float coneRotation = Projectile.rotation + scale; - if (targetHitbox.IntersectsConeSlowMoreAccurate(Projectile.Center, coneLength, coneRotation, maximumAngle)) - return true; - - float rotation = Utils.Remap(Projectile.localAI[0], Projectile.ai[1] * 0.3f, Projectile.ai[1] * 0.5f, 1f, 0f); - if (rotation > 0f) - { - float coneRotation2 = coneRotation - MathHelper.PiOver4 * Projectile.ai[0] * rotation; - if (targetHitbox.IntersectsConeSlowMoreAccurate(Projectile.Center, coneLength, coneRotation2, maximumAngle)) - return true; - } - - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 600); - target.AddBuff(ModContent.BuffType(), 60); - } - } -} diff --git a/Projectiles/Melee/IridescentExcaliburSlash3.cs b/Projectiles/Melee/IridescentExcaliburSlash3.cs deleted file mode 100644 index b370bdf8b5..0000000000 --- a/Projectiles/Melee/IridescentExcaliburSlash3.cs +++ /dev/null @@ -1,238 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Graphics.Primitives; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.GameContent; -using Terraria.GameContent.Drawing; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; - -namespace CalamityMod.Projectiles.Melee -{ - public class IridescentExcaliburSlash3 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/Melee/IridescentExcaliburSlash"; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 4; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.ownerHitCheck = true; - Projectile.ownerHitCheckDistance = 300f; - Projectile.usesOwnerMeleeHitCD = true; - Projectile.stopsDealingDamageAfterPenetrateHits = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 3; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - Projectile.localAI[0] += 1f; - Player player = Main.player[Projectile.owner]; - float num = Projectile.localAI[0] / Projectile.ai[1]; - float num2 = Projectile.ai[0]; - float num3 = Projectile.velocity.ToRotation(); - float num4 = (float)Math.PI * num2 * num + num3 + num2 * (float)Math.PI + player.fullRotation; - Projectile.rotation = num4; - float num5 = 0.6f; - float num6 = 1f; - - Projectile.Center = player.RotatedRelativePoint(player.MountedCenter) - Projectile.velocity; - Projectile.scale = num6 + num * num5; - - float colorAIScale = Projectile.localAI[0] / Projectile.ai[1]; - float amount = Utils.Remap(colorAIScale, 0f, 0.6f, 0f, 1f) * Utils.Remap(colorAIScale, 0.6f, 1f, 1f, 0f); - Color rainbow = Color.Lerp(new Color(255 - (Math.Abs(128 - Main.DiscoR) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoG) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoB) * 2 - 1)), - new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1), amount); - - float num8 = Projectile.rotation + Main.rand.NextFloatDirection() * MathHelper.PiOver2 * 0.7f; - Vector2 vector2 = Projectile.Center + num8.ToRotationVector2() * 84f * Projectile.scale; - Vector2 vector3 = (num8 + Projectile.ai[0] * MathHelper.PiOver2).ToRotationVector2(); - if (Main.rand.NextFloat() * 2f < Projectile.Opacity) - { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + num8.ToRotationVector2() * (Main.rand.NextFloat() * 80f * Projectile.scale + 20f * Projectile.scale), 278, vector3 * 1f, 100, rainbow, 0.4f); - dust2.fadeIn = 0.4f + Main.rand.NextFloat() * 0.15f; - dust2.noGravity = true; - } - - if (Main.rand.NextFloat() * 1.5f < Projectile.Opacity) - Dust.NewDustPerfect(vector2, 43, vector3 * 1f, 100, rainbow * Projectile.Opacity, 1.2f * Projectile.Opacity); - - float num10 = Projectile.rotation + Main.rand.NextFloatDirection() * MathHelper.PiOver2 * 0.7f; - Vector2 vector5 = Projectile.Center + num10.ToRotationVector2() * 84f * Projectile.scale; - Vector2 vector6 = (num10 + Projectile.ai[0] * MathHelper.PiOver2).ToRotationVector2(); - if (Main.rand.NextFloat() < Projectile.Opacity) - { - Dust dust4 = Dust.NewDustPerfect(Projectile.Center + num10.ToRotationVector2() * (Main.rand.NextFloat() * 80f * Projectile.scale + 20f * Projectile.scale), 278, vector6 * 1f, 100, rainbow, 0.4f); - dust4.fadeIn = 0.4f + Main.rand.NextFloat() * 0.15f; - dust4.noGravity = true; - } - - if (Main.rand.NextFloat() * 1.5f < Projectile.Opacity) - Dust.NewDustPerfect(vector5, 43, vector6 * 1f, 100, rainbow * Projectile.Opacity, 1.2f * Projectile.Opacity); - - Projectile.scale *= Projectile.ai[2]; - if (Projectile.localAI[0] >= Projectile.ai[1]) - Projectile.Kill(); - - // Enchantment visual bullshit - Vector2 boxPosition = Projectile.position; - int boxWidth = Projectile.width; - int boxHeight = Projectile.height; - for (float i = -MathHelper.PiOver4; i <= MathHelper.PiOver4; i += MathHelper.PiOver2) - { - Rectangle rect = Utils.CenteredRectangle(Projectile.Center + (Projectile.rotation + i).ToRotationVector2() * 70f * Projectile.scale, new Vector2(60f * Projectile.scale, 60f * Projectile.scale)); - Projectile.EmitEnchantmentVisualsAt(rect.TopLeft(), rect.Width, rect.Height); - } - } - - public override bool PreDraw(ref Color lightColor) - { - Vector2 vector = Projectile.Center - Main.screenPosition; - Texture2D asset = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle rectangle = asset.Frame(1, 4); - Vector2 origin = rectangle.Size() / 2f; - float num = Projectile.scale * 1.1f; - SpriteEffects effects = ((!(Projectile.ai[0] >= 0f)) ? SpriteEffects.FlipVertically : SpriteEffects.None); - float num2 = Projectile.localAI[0] / Projectile.ai[1]; - float num3 = Utils.Remap(num2, 0f, 0.6f, 0f, 1f) * Utils.Remap(num2, 0.6f, 1f, 1f, 0f); - float num4 = 0.975f; - float amount = num3; - float fromValue = Lighting.GetColor(Projectile.Center.ToTileCoordinates()).ToVector3().Length() / (float)Math.Sqrt(3D); - fromValue = Utils.Remap(fromValue, 0.2f, 1f, 0f, 1f); - - Color color = Color.Lerp(new Color(255 - (Math.Abs(128 - Main.DiscoR) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoG) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoB) * 2 - 1)), - new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1), amount); - Main.spriteBatch.Draw(asset, vector, rectangle, color * fromValue * num3, Projectile.rotation + Projectile.ai[0] * MathHelper.PiOver4 * -1f * (1f - num2), origin, num, effects, 0f); - Color color2 = Color.Lerp(new Color(255 - (Math.Abs(128 - Main.DiscoR) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoG) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoB) * 2 - 1)), - new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1), amount); - Color color3 = Color.Lerp(new Color(255 - (Math.Abs(128 - Main.DiscoR) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoG) * 2 - 1), 255 - (Math.Abs(128 - Main.DiscoB) * 2 - 1)), - new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1), amount); - - Color color4 = new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1) * num3 * 0.5f; - color4.A = (byte)((float)(int)color4.A * (1f - fromValue)); - Color color5 = color4 * fromValue * 0.5f; - Main.spriteBatch.Draw(asset, vector, rectangle, color5 * 0.15f, Projectile.rotation + Projectile.ai[0] * 0.01f, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, rectangle, color3 * fromValue * num3 * 0.3f, Projectile.rotation, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, rectangle, color2 * fromValue * num3 * 0.5f, Projectile.rotation, origin, num * num4, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1) * 0.6f * num3, Projectile.rotation + Projectile.ai[0] * 0.01f, origin, num, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1) * 0.5f * num3, Projectile.rotation + Projectile.ai[0] * -0.05f, origin, num * 0.8f, effects, 0f); - Main.spriteBatch.Draw(asset, vector, asset.Frame(1, 4, 0, 3), new Color(Math.Abs(128 - Main.DiscoR) * 2 - 1, Math.Abs(128 - Main.DiscoG) * 2 - 1, Math.Abs(128 - Main.DiscoB) * 2 - 1) * 0.4f * num3, Projectile.rotation + Projectile.ai[0] * -0.1f, origin, num * 0.6f, effects, 0f); - float num5 = num * 0.75f; - Texture2D value = TextureAssets.Extra[98].Value; - Color shineColor = color3 * Projectile.Opacity * 0.5f; - shineColor.A = 0; - Vector2 origin2 = value.Size() / 2f; - float num9 = Utils.GetLerpValue(0f, 0.5f, num2, clamped: true) * Utils.GetLerpValue(1f, 0.5f, num2, clamped: true); - Vector2 vector3 = new Vector2((Vector2.One * num5).X * 0.5f, (new Vector2(0f, Utils.Remap(num2, 0f, 1f, 3f, 0f)) * num5).X) * num9; - Vector2 vector2 = new Vector2((Vector2.One * num5).Y * 0.5f, (new Vector2(0f, Utils.Remap(num2, 0f, 1f, 3f, 0f)) * num5).Y) * num9; - shineColor *= num9; - for (float num6 = 0f; num6 < 12f; num6 += 1f) - { - float num7 = Projectile.rotation + Projectile.ai[0] * num6 * -MathHelper.TwoPi * 0.025f + Utils.Remap(num2, 0f, 0.6f, 0f, 0.95504415f) * Projectile.ai[0]; - Vector2 drawpos = vector + num7.ToRotationVector2() * ((float)asset.Width * 0.5f - 6f) * num; - float num8 = num6 / 12f; - - Color color6 = new Color(255, 255, 255, 0) * num3 * num8 * 0.5f; - color6 *= num9; - Main.EntitySpriteDraw(value, drawpos, null, shineColor, MathHelper.PiOver2 + num7, origin2, vector3, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, shineColor, 0f + num7, origin2, vector2, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, color6, MathHelper.PiOver2 + num7, origin2, vector3 * 0.6f, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos, null, color6, 0f + num7, origin2, vector2 * 0.6f, SpriteEffects.None); - } - - Vector2 drawpos2 = vector + (Projectile.rotation + Utils.Remap(num2, 0f, 0.6f, 0f, 0.95504415f) * Projectile.ai[0]).ToRotationVector2() * ((float)asset.Width * 0.5f - 4f) * num; - Color color7 = new Color(255, 255, 255, 0) * num3 * 0.5f; - color7 *= num9; - Main.EntitySpriteDraw(value, drawpos2, null, shineColor, MathHelper.PiOver2 + Projectile.rotation, origin2, vector3, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, shineColor, 0f + Projectile.rotation, origin2, vector2, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, color7, MathHelper.PiOver2 + Projectile.rotation, origin2, vector3 * 0.6f, SpriteEffects.None); - Main.EntitySpriteDraw(value, drawpos2, null, color7, 0f + Projectile.rotation, origin2, vector2 * 0.6f, SpriteEffects.None); - - return false; - } - - public override void CutTiles() - { - Vector2 startPoint = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * 60f * Projectile.scale; - Vector2 endPoint = (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * 60f * Projectile.scale; - float projectileSize = 60f * Projectile.scale; - Utils.PlotTileLine(Projectile.Center + startPoint, Projectile.Center + endPoint, projectileSize, DelegateMethods.CutTiles); - } - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - modifiers.HitDirectionOverride = (Main.player[Projectile.owner].Center.X < target.Center.X) ? 1 : -1; - - Vector2 positionInWorld = Main.rand.NextVector2FromRectangle(target.Hitbox); - ParticleOrchestraSettings particleOrchestraSettings = default(ParticleOrchestraSettings); - particleOrchestraSettings.PositionInWorld = positionInWorld; - ParticleOrchestraSettings settings = particleOrchestraSettings; - switch (Main.rand.Next(5)) - { - default: - case 0: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.NightsEdge, settings, Projectile.owner); - break; - - case 1: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TrueNightsEdge, settings, Projectile.owner); - break; - - case 2: - settings.MovementVector = Projectile.velocity; - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TerraBlade, settings, Projectile.owner); - break; - - case 3: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.Excalibur, settings, Projectile.owner); - break; - - case 4: - ParticleOrchestrator.RequestParticleSpawn(clientOnly: false, ParticleOrchestraType.TrueExcalibur, settings, Projectile.owner); - break; - } - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - float coneLength = 94f * Projectile.scale; - float scale = MathHelper.TwoPi / 25f * Projectile.ai[0]; - float maximumAngle = MathHelper.PiOver4; - float coneRotation = Projectile.rotation + scale; - if (targetHitbox.IntersectsConeSlowMoreAccurate(Projectile.Center, coneLength, coneRotation, maximumAngle)) - return true; - - float rotation = Utils.Remap(Projectile.localAI[0], Projectile.ai[1] * 0.3f, Projectile.ai[1] * 0.5f, 1f, 0f); - if (rotation > 0f) - { - float coneRotation2 = coneRotation - MathHelper.PiOver4 * Projectile.ai[0] * rotation; - if (targetHitbox.IntersectsConeSlowMoreAccurate(Projectile.Center, coneLength, coneRotation2, maximumAngle)) - return true; - } - - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 600); - target.AddBuff(ModContent.BuffType(), 60); - } - } -} diff --git a/Projectiles/Melee/JudgementProj.cs b/Projectiles/Melee/JudgementProj.cs index 583ad48e1e..6f80d0ed85 100644 --- a/Projectiles/Melee/JudgementProj.cs +++ b/Projectiles/Melee/JudgementProj.cs @@ -1,4 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; Projectile.timeLeft = 450; Projectile.DamageType = DamageClass.Melee; - Projectile.extraUpdates = 9; + Projectile.extraUpdates = 14; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } @@ -49,10 +49,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.scale += 0.0026f; hitboxSize += 0.4525f; Projectile.velocity *= 0.995f; - // Spawn 3 - if (time % 50 == 0 && time > 10) + // Spawn 2 + if (time % 85 == 0 && time > 10) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Main.rand.NextVector2Circular(hitboxSize * 0.8f, hitboxSize * 0.8f) - Projectile.velocity * 2, (-Projectile.velocity * 3).RotatedByRandom(0.9f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.2f), 3f, Projectile.owner, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Main.rand.NextVector2Circular(hitboxSize * 0.8f, hitboxSize * 0.8f) - Projectile.velocity * 2, (-Projectile.velocity * 3).RotatedByRandom(0.9f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.35f), 3f, Projectile.owner, 0f); } } else @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool(3)) { - Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(hitboxSize, hitboxSize) - Projectile.velocity * 2, 66); + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(hitboxSize, hitboxSize) - Projectile.velocity * 2, ModContent.DustType()); trailDust.scale = Main.rand.NextFloat(0.7f, 0.85f) - (time < 150 ? 0 : time * 0.001f); trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.85f, 1.5f); trailDust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; @@ -102,11 +102,10 @@ namespace CalamityMod.Projectiles.Melee { Texture2D tex = ModContent.Request(Texture).Value; float waveFade = Utils.GetLerpValue(0, 300, Projectile.timeLeft); - Main.spriteBatch.Draw(tex, Projectile.Center - Main.screenPosition, null, mainColor with { A = 0 } * fadeOut, Projectile.rotation, tex.Size() / 2f, new Vector2(1 - (0.2f * waveFade), 1 + (0.45f * waveFade)) * Projectile.scale, SpriteEffects.None, 0); + for (int i = 0; i < 5; i++) + Main.spriteBatch.Draw(tex, Projectile.Center - Main.screenPosition + (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 9 * i, null, mainColor with { A = 0 } * fadeOut * 0.6f, Projectile.rotation, tex.Size() / 2f, new Vector2(1 - (0.2f * waveFade) + 0.01f * i, 1 + (0.45f * waveFade) - 0.06f * i) * Projectile.scale, SpriteEffects.None, 0); return false; } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (Projectile.numHits > 0) diff --git a/Projectiles/Melee/LaceratorSaw.png b/Projectiles/Melee/LaceratorSaw.png new file mode 100644 index 0000000000..4963c7e8f2 Binary files /dev/null and b/Projectiles/Melee/LaceratorSaw.png differ diff --git a/Projectiles/Melee/LaserFountain.cs b/Projectiles/Melee/LaserFountain.cs deleted file mode 100644 index 2bcf99ec00..0000000000 --- a/Projectiles/Melee/LaserFountain.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee -{ - public class LaserFountain : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft = 60; - Projectile.DamageType = DamageClass.Melee; - } - - public override void AI() - { - Projectile.localAI[0] += 1f; - float SpeedX = (float)Main.rand.Next(-15, 15); - float SpeedY = (float)Main.rand.Next(-20, -10); - if (Projectile.localAI[0] >= 12f) - { - if (Projectile.owner == Main.myPlayer) - { - int damage = (int)Main.player[Projectile.owner].GetTotalDamage().ApplyTo(350f); - int laserShot = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - if (laserShot.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[laserShot].DamageType = DamageClass.Melee; - Main.projectile[laserShot].aiStyle = ProjAIStyleID.Arrow; - } - } - Projectile.localAI[0] = 0f; - } - } - } -} diff --git a/Projectiles/Melee/LightBeam.cs b/Projectiles/Melee/LightBeam.cs index b955bf6f86..68a27275bc 100644 --- a/Projectiles/Melee/LightBeam.cs +++ b/Projectiles/Melee/LightBeam.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/LightspeedDashHitbox.cs b/Projectiles/Melee/LightspeedDashHitbox.cs new file mode 100644 index 0000000000..1f6dfd62a0 --- /dev/null +++ b/Projectiles/Melee/LightspeedDashHitbox.cs @@ -0,0 +1,71 @@ +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Sounds; +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class LightspeedDashHitbox : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + + public override void SetDefaults() + { + Projectile.width = 84; + Projectile.height = 64; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; + Projectile.penetrate = -1; + Projectile.timeLeft = 18; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + // Go where the player is going + Projectile.Center = Main.player[Projectile.owner].Center; + Main.player[Projectile.owner].velocity = Projectile.velocity; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld() + MathHelper.Pi.ToRotationVector2()); + SoundEngine.PlaySound(CommonCalamitySounds.SwiftSliceSound with { Volume = CommonCalamitySounds.SwiftSliceSound.Volume * 0.33f }, Projectile.Center); + + var player = Main.player[Projectile.owner]; + var modPlayer = player.Calamity(); + + // Refund 20 energy if dash hits. Can get energy from multiple enemies. + modPlayer.elementalMastery += 20; + modPlayer.elementalMastery = Math.Min(modPlayer.elementalMastery, Lightspeed.MaxEnergy); + + // On-hit cut FX + int points = 2; + float radians = MathHelper.TwoPi / points; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)).RotatedByRandom(100); + + for (int k = 0; k < points; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f); + + Particle spark = new RainbowGlowSparkParticle((target.Center + velocity * 7.5f), velocity * 0.5f, false, 14, 0.07f, Color.Aqua, new Vector2(0.55f, 0.825f), true, true, hueShift: 0.05f); + GeneralParticleHandler.SpawnParticle(spark); + } + + for (int i = 0; i < 12; i++) + { + Vector2 particleSpeed = Utils.SafeNormalize(target.Center, Vector2.One).RotatedByRandom(MathHelper.TwoPi * 3) * Main.rand.NextFloat(4f, 8f); + Particle energyLeak = new SquishyLightParticle(target.Center, particleSpeed, Main.rand.NextFloat(0.4f, 0.9f), Color.OrangeRed, 50, 2, 2.5f, hueShift: 0.06f); + GeneralParticleHandler.SpawnParticle(energyLeak); + } + } + } +} diff --git a/Projectiles/Melee/LightspeedHoldout.cs b/Projectiles/Melee/LightspeedHoldout.cs new file mode 100644 index 0000000000..e517fe64b4 --- /dev/null +++ b/Projectiles/Melee/LightspeedHoldout.cs @@ -0,0 +1,445 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Particles; +using static Terraria.Player; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Graphics.Primitives; +using System.Linq; +using Terraria.Graphics.Shaders; +using static CalamityMod.CalamityUtils; +using CalamityMod.Sounds; + + +namespace CalamityMod.Projectiles.Melee +{ + public class LightspeedHoldout : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + + public override string Texture => "CalamityMod/Items/Weapons/Melee/Lightspeed"; + public ref float attackTimer => ref Projectile.ai[0]; + public Player Owner => Main.player[Projectile.owner]; + public int time = 0; + + // Sprite visuals + public Vector2 innateOffset = new(23f, -0.1f); + public Vector2 handPos; + public float bladeRot = 0; + + // Primary + public int primaryStabfireRate => 2; + private int stabTimer; + public int stabSoundTimer = 3; + + // Secondary + public bool pressedRight = false; + public bool firstSecondaryIteration = false; + public int initialDirectionForThisAnim = 0; + public ref float DashState => ref Projectile.ai[1]; + public ref float DashTimer => ref Projectile.ai[2]; + private const float DashPrepTime = 40f; + private const float DashSpeed = 46f; + private const float DashDuration = 38f; + private const float DashAcceleration = 0.9865f; + private float AltSpinRotation = 0f; + public bool createdSmear = false; + public float LungeProgression + { + get + { + float duration = DashDuration; + float elapsed = DashDuration - (DashTimer * 2); + return MathHelper.Clamp(elapsed / duration, 0f, 1f); + } + } + + // General + public bool gotEnergyThisSwing = false; + public override bool? CanDamage() => false; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 120; + } + + public override void SetDefaults() + { + Projectile.width = 74; + Projectile.height = 94; + Projectile.friendly = true; + Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 1; + } + + public void Positioning(Vector2 toMouse) // Hand and holdout positioning + { + if (DashState == 2) + { + Vector2 dashDirection = Projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction); + Owner.ChangeDir(Math.Sign(dashDirection.X)); + + float dashArmRotation = dashDirection.ToRotation(); + float dashCompositeArmRotation = dashArmRotation + (MathHelper.TwoPi * 0.75f); + + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, dashCompositeArmRotation); + Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, 0f); + + bladeRot = 0; + + handPos = Owner.GetFrontHandPosition(CompositeArmStretchAmount.Full, dashCompositeArmRotation); + + Projectile.Center = handPos; + + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + + // Visual rotation + Projectile.rotation = dashArmRotation; + Projectile.rotation = Projectile.velocity.ToRotation() + (Owner.direction == 1 ? MathHelper.PiOver4 : MathHelper.Pi * 0.75f); + Projectile.rotation += 0.15f * Owner.direction; // Adjustment to make the tip look like its more directly pointing at cursor + + // Item rotation (for arm positioning) + Owner.itemRotation = dashArmRotation + MathHelper.PiOver4; + + if (Owner.direction != 1) + { + Owner.itemRotation -= MathHelper.TwoPi * 0.75f; + } + + Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation); + } + + else // If not in dash + { + Owner.ChangeDir(Math.Sign(toMouse.X)); + + float baseArmRotation = toMouse.ToRotation(); + float compositeArmRotation = baseArmRotation + bladeRot - MathHelper.PiOver2; + + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, compositeArmRotation); + Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, 0f); + + Vector2 actualInnateOffset = innateOffset; + if (Owner.direction == -1) + { + actualInnateOffset.X += 1f; + actualInnateOffset.Y += 2f; + } + + handPos = Owner.GetFrontHandPosition(CompositeArmStretchAmount.Full, compositeArmRotation) + actualInnateOffset.RotatedBy(baseArmRotation); + + Projectile.velocity = toMouse; + Projectile.rotation = toMouse.ToRotation() + bladeRot; + Projectile.rotation += MathHelper.PiOver2 * 0.5f; // Adjustment made so texture actually faces cursor + Projectile.rotation += 0.15f * Owner.direction; // Another to make the tip look like its more directly pointing at cursor + + if (Owner.direction == -1) + { + Projectile.rotation -= MathHelper.TwoPi * 0.75f; + } + + Projectile.Center = handPos; + + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + + // Item rotation (for arm positioning) + Owner.itemRotation = Projectile.rotation - MathHelper.PiOver4; // Adjustment undone for arm pos + if (Owner.direction == -1) + { + Owner.itemRotation -= MathHelper.Pi; + } + else + { + Owner.itemRotation -= MathHelper.PiOver2; + } + + Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation); + + } + } + + public override void AI() + { + Projectile.scale = 0.6f; + + if (!Owner.channel && DashState == 0) + { + Projectile.Kill(); + return; + } + + Vector2 toMouse = Utils.DirectionTo(Owner.MountedCenter, Owner.ClampedMouseWorld()); + Positioning(toMouse); + + if (DashState == 0) + { + if (Owner.altFunctionUse == 2 && Owner.Calamity().mouseRight) + { + // Check if the player has enough EM + if (Owner.Calamity().elementalMastery < 100) + { + Projectile.Kill(); + return; + } + + DashState = 1; + DashTimer = DashPrepTime; + Projectile.localAI[0] = Owner.direction; + Owner.Calamity().elementalMastery = 0; // Reset EM to zero + } + } + + if (Owner.altFunctionUse == 0 && DashState == 0) + { + Projectile.Center += (Utils.DirectionTo(Owner.MountedCenter, Owner.ClampedMouseWorld()) * Main.rand.NextFloat(-5f, 8f)); + UsePrimary(toMouse); + } + + if (DashState > 0) + { + UseSecondary(); + } + } + + private void UsePrimary(Vector2 toMouse) + { + stabTimer++; + if (stabTimer % primaryStabfireRate != 0) + return; + + float offset = Main.rand.NextFloat(-MathHelper.ToRadians(10f), MathHelper.ToRadians(6f)); + Vector2 stabDir = toMouse.RotatedBy(offset); + + Vector2 stabOrigin = Projectile.Center; + Vector2 stabTip = stabOrigin + stabDir * 62f; + + for (int i = 0; i < 4; i++) + { + Vector2 spawnPos = stabTip + Main.rand.NextVector2Circular(18f, 12f); + Vector2 vel = stabDir * Main.rand.NextFloat(5f, 19f); + + Particle spark = new GlowSparkParticle(spawnPos, vel, false, Main.rand.Next(5, 8), Main.rand.NextFloat(0.02f, 0.07f), Color.Lerp(Color.Aqua, Color.OrangeRed, Main.rand.NextFloat(1f)) * 0.55f, new Vector2(Main.rand.NextFloat(0.475f, 0.535f), Main.rand.NextFloat(1.2f, 1.3f)), true, false); + GeneralParticleHandler.SpawnParticle(spark); + } + + Particle afterImage = new CustomSpark(Projectile.Center + (stabDir * 10f) + Main.rand.NextVector2Circular(4f, 11f), (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(), new("CalamityMod/Items/Weapons/Melee/Lightspeed"), false, Main.rand.Next(5,9), Projectile.scale * Main.rand.NextFloat(0.9f, 1.02f), Color.White * Main.rand.NextFloat(0.66f, 0.825f), new Vector2(1, 1), true, false, flipHorizontal: Owner.direction == -1 ? true : false); + GeneralParticleHandler.SpawnParticle(afterImage); + + // Make blade randomly vibrate + bladeRot = Main.rand.NextFloat(-0.12f, 0.3f) * Owner.direction; + Projectile.scale *= Main.rand.NextFloat(0.75f, 1f); + Projectile.Center += stabDir + Main.rand.NextVector2Circular(7f, 1.5f); + Projectile.Opacity = 0.925f; + + Owner.itemRotation += bladeRot * 0.1f; + // Make arm randomly vibrate + if (Main.rand.NextBool()) + { + Owner.SetCompositeArmFront(true, Main.rand.NextBool() ? CompositeArmStretchAmount.ThreeQuarters : CompositeArmStretchAmount.Quarter, Owner.itemRotation); + } + + stabSoundTimer++; + if (stabSoundTimer % 3 == 0) + { + SoundEngine.PlaySound(SoundID.Item1 with { Volume = 0.65f, MaxInstances = -1 }, Projectile.Center); + stabSoundTimer = 0; + } + + // Spawn the hitbox + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.MountedCenter + toMouse * 20 * (float)Math.Pow(Projectile.scale, 4), toMouse * 25, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + } + + private void UseSecondary() + { + Vector2 stabOrigin = Owner.MountedCenter; + Vector2 stabOffset = stabOrigin + Utils.DirectionTo(Owner.MountedCenter, Owner.ClampedMouseWorld()) * 30f; + Projectile.Center = stabOffset; + + + if (DashState == 1) // Initial delay + { + DashTimer--; + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + + Projectile.scale = 0.6f; + + if (!firstSecondaryIteration) + { + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Volume = 0.4f, Pitch = -0.05f }, Projectile.Center); + initialDirectionForThisAnim = Owner.direction; // Set for rest of the pre-dash anim so weird stuff doesnt happen when changing directions + firstSecondaryIteration = true; + } + + // Spin the blade around + if (DashTimer > 6) + { + float duration = DashPrepTime - 6; + float elapsed = duration - DashTimer; + + float t = MathHelper.Clamp(elapsed / duration, 0f, 1f); + float eased = MathF.Pow(t, 1.2f); + + AltSpinRotation = eased * (4f * MathHelper.Pi * 0.7175f); + float orbitalAngle = AltSpinRotation * initialDirectionForThisAnim + (initialDirectionForThisAnim == -1 ? MathHelper.Pi : 0); + float orbitRadius = 40f; + + Projectile.Center = Owner.MountedCenter + orbitalAngle.ToRotationVector2() * orbitRadius; + float tangentAngle = orbitalAngle + (initialDirectionForThisAnim == 1 ? MathHelper.PiOver4 : -MathHelper.PiOver4 + MathHelper.Pi); + Projectile.rotation = tangentAngle; + + // Proper arm positioning + Vector2 armDirection = Projectile.Center - Owner.MountedCenter; + float baseArmRotation = armDirection.ToRotation(); + + float compositeArmRotation = baseArmRotation + (initialDirectionForThisAnim == 1 ? MathHelper.TwoPi * 0.75f : -MathHelper.PiOver2); + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, compositeArmRotation); + Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, 0f); + + Owner.itemRotation = baseArmRotation; + if (Owner.direction == -1) + Owner.itemRotation += MathHelper.Pi; + + Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation); + } + + // Mid-spin VFX + if (DashTimer < 32 && DashTimer > 8) + { + if (DashTimer % 4 == 0) + { + Vector2 pos = Owner.MountedCenter + Projectile.rotation.ToRotationVector2() * 60f; + Particle sparkle = new CritSpark(pos, new Vector2(7f, 0).RotatedBy(Projectile.rotation), Color.Lerp(Color.Aqua, Color.MediumPurple, Main.rand.NextFloat(1f)), Color.White * 0.33f, 1.2f, 12, 0.3f, 1.2f, hueShift: 0.06f); + GeneralParticleHandler.SpawnParticle(sparkle); + } + + Particle smear = new CircularSmearVFX(Owner.MountedCenter, Color.Aqua * 0.4f, Projectile.rotation, Projectile.scale * 1.66f); + GeneralParticleHandler.SpawnParticle(smear); + } + + // Initiate dash + if (DashTimer <= 0) + { + DashState = 2; + DashTimer = DashDuration; + + Vector2 toMouse = Owner.MountedCenter.DirectionTo(Owner.ClampedMouseWorld()); + Projectile.velocity = toMouse * DashSpeed; + + Owner.mount?.Dismount(Owner); + Owner.RemoveAllGrapplingHooks(); + + SoundEngine.PlaySound(Exoblade.DashSound, Owner.MountedCenter); + + SoundStyle otherSound = new("CalamityMod/Sounds/Item/OmicronBeam"); + SoundEngine.PlaySound(otherSound with { Volume = 0.6f, Pitch = Main.rand.NextFloat(0.2f, 0.25f) }, Projectile.Center); + + Owner.immune = true; + Owner.immuneNoBlink = true; + Owner.immuneTime = (int) DashDuration + 2; + for (int k = 0; k < Owner.hurtCooldowns.Length; k++) + Owner.hurtCooldowns[k] = Owner.immuneTime; + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.MountedCenter, Projectile.velocity, ModContent.ProjectileType(), Projectile.damage * 24, Projectile.knockBack * 4, Projectile.owner); + } + } + + else if (DashState == 2) // Dashing + { + DashTimer--; + + Vector2 dashVelocity = Projectile.velocity; + Owner.velocity = dashVelocity; + Owner.ChangeDir(Math.Sign(dashVelocity.X)); + Owner.Calamity().LungingDown = true; + + Projectile.velocity *= DashAcceleration; + + Projectile.scale = MathHelper.Lerp(1f, 0.4f, MathF.Pow(1f - DashTimer / DashDuration, 5)); + + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + + if (DashTimer <= 0) + { + Owner.velocity *= 0.1f; + Owner.Calamity().LungingDown = false; + Projectile.Kill(); + } + } + } + + // Drawcode below is mostly based on Exoblade's dash. + public float PierceWidthFunction(float completionRatio, Vector2 vertexPos) + { + float width = Utils.GetLerpValue(0f, 0.2f, completionRatio, true) * Projectile.scale * 24f; + //Fade it out starkly near the end of the lunge + width *= (1 - (float)Math.Pow(LungeProgression, 4)); + return width; + } + + public Color PierceColorFunction(float completionRatio, Vector2 vertexPos) => Color.White * Projectile.Opacity; // The trail color doesnt matter here + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + int frameHeight = texture.Height / Main.projFrames[Projectile.type]; + Rectangle frame = new Rectangle(0, Projectile.frame * frameHeight, texture.Width, frameHeight); + Vector2 origin = new Vector2(texture.Width / 2f, frameHeight / 2f); + + SpriteEffects spriteEffects = Owner.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + lightColor = Color.White; // Fullbright + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, frame, lightColor * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); + + DrawPierceTrail(); + + return false; + } + + public void DrawPierceTrail() + { + if (DashState != 2) + return; + + Main.spriteBatch.EnterShaderRegion(); + + Color mainColor = MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f) % 1, Color.Aqua, Color.MediumAquamarine, Color.DarkOrange, Color.OrangeRed); + Color secondaryColor = MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f + 0.2f) % 1, Color.Aqua, Color.MediumAquamarine, Color.DarkOrange, Color.OrangeRed); + + mainColor = Color.Lerp(Color.White, mainColor, 0.4f + 0.6f * (float)Math.Pow(LungeProgression, 0.5f)); + secondaryColor = Color.Lerp(Color.White, secondaryColor, 0.4f + 0.6f * (float)Math.Pow(LungeProgression, 0.5f)); + + Vector2 trailOffset = Projectile.Size * 0.5f; + GameShaders.Misc["CalamityMod:ExobladePierce"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseImage2("Images/Extra_189"); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].Apply(); + + // Lightspeed tracks 120 positions in oldPos. + // Provide 60 points for smoothing, but only render 30 + int numPointsRendered = 30; + int numPointsProvided = 60; + var positionsToUse = Projectile.oldPos.Take(numPointsProvided).ToArray(); + PrimitiveRenderer.RenderTrail(positionsToUse, new(PierceWidthFunction, PierceColorFunction, (_,_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), numPointsRendered); + + Main.spriteBatch.ExitShaderRegion(); + } + public override void OnKill(int timeLeft) + { + DashState = 0; + DashTimer = 0; + Projectile.scale = 0.6f; + } + } +} diff --git a/Projectiles/Melee/LightspeedM1Hitbox.cs b/Projectiles/Melee/LightspeedM1Hitbox.cs new file mode 100644 index 0000000000..1a8c420304 --- /dev/null +++ b/Projectiles/Melee/LightspeedM1Hitbox.cs @@ -0,0 +1,67 @@ +using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + [PierceResistExceptionAttribute(true)] + public class LightspeedM1Hitbox : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + + public bool gotEnergyThisSwing = false; + + public override void SetDefaults() + { + Projectile.width = 84; + Projectile.height = 64; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 6; + Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 4; + } + + public override void AI() + { + Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld() + MathHelper.Pi.ToRotationVector2()); + + float rotation = toMouse.ToRotation(); + + Projectile.rotation = rotation; + Projectile.velocity = toMouse * 34; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Vector2 toMouse = Utils.DirectionTo(Owner.Center, Owner.ClampedMouseWorld() + MathHelper.Pi.ToRotationVector2()); + + if (!gotEnergyThisSwing) + { + gotEnergyThisSwing = true; + var player = Main.player[Projectile.owner]; + var modPlayer = player.Calamity(); + + // +4 energy on hit + modPlayer.elementalMastery += 4; + modPlayer.elementalMastery = Math.Min(modPlayer.elementalMastery, Lightspeed.MaxEnergy); + } + + for (int i = 0; i < 2; i++) + { + Vector2 particleSpeed = Utils.SafeNormalize(target.Center * toMouse, Vector2.One).RotatedByRandom(MathHelper.PiOver4 * 0.8f) * Main.rand.NextFloat(7f, 14f); + Particle energyLeak = new SquishyLightParticle(target.Center, particleSpeed, Main.rand.NextFloat(0.25f, 0.5f), Color.OrangeRed, 22, 2, 2.5f, hueShift: 0.06f); + GeneralParticleHandler.SpawnParticle(energyLeak); + } + } + } +} diff --git a/Projectiles/Melee/LucreciaBolt.cs b/Projectiles/Melee/LucreciaBolt.cs new file mode 100644 index 0000000000..44d4c3f279 --- /dev/null +++ b/Projectiles/Melee/LucreciaBolt.cs @@ -0,0 +1,163 @@ +using System; +using System.Linq; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Melee +{ + public class LucreciaBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static float MaxWidth = 30; + public ref float Time => ref Projectile.ai[0]; + + public static Asset TrailTex; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 13; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 19; + Projectile.height = 22; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.ignoreWater = true; + Projectile.tileCollide = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 1; + Projectile.alpha = 0; + Projectile.timeLeft = 420; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 12; + } + + public override void AI() + { + // Little bit of ambient lighting as it travels + Lighting.AddLight(Projectile.Center, Color.WhiteSmoke.ToVector3() * 0.4f); + + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.velocity *= 1.01f; + Projectile.scale = Utils.GetLerpValue(0f, 0.1f, Projectile.timeLeft / 600f, true); + + if (Projectile.FinalExtraUpdate()) + Time++; + + // CRUCIAL so that oldPos isnt initialized incorrectly when drawing + if (Projectile.localAI[0] == 0f) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Projectile.oldPos[i] = Projectile.position; + } + Projectile.localAI[0] = 1f; + } + + if (Projectile.ai[1] > 0) + { + Projectile.damage = 0; + // Reduce opacity over time + Projectile.Opacity -= 0.04f; + if (Projectile.Opacity <= 0f) + { + Projectile.Kill(); + } + } + } + + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + for (int i = 0; i < 6; i++) + { + float variance = Main.rand.NextFloat(-0.6f, 0.6f); + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(target.Center, dustStyle); + dust2.scale = Main.rand.NextFloat(1.2f, 1.6f) - Math.Abs(variance); + dust2.velocity = (Projectile.velocity * 1.5f).RotatedBy(variance) * Main.rand.NextFloat(1.2f, 1.5f) * (1 - Math.Abs(variance)); + dust2.noGravity = true; + dust2.color = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, Main.rand.NextFloat(0f, 1f)); + } + + // Flag set for fading out + Projectile.ai[1] = 1f; + } + + public override Color? GetAlpha(Color lightColor) => Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, 0.5f) with { A = 0 } * Projectile.Opacity; + + public float TrailWidth(float completionRatio, Vector2 vertexPos) + { + float width = Utils.GetLerpValue(1f, 0.4f, completionRatio, true) * (float)Math.Sin(Math.Acos(1 - Utils.GetLerpValue(0f, 0.08f, completionRatio, true))); + + width *= Utils.GetLerpValue(0f, 0.1f, Projectile.timeLeft / 600f, true); + + return width * (MaxWidth * .265f); + } + public Color TrailColor(float completionRatio, Vector2 vertexPos) + { + Color baseColor = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, completionRatio); + + return baseColor * 0.2f * Projectile.Opacity; + } + + public Color MiniTrailColor(float completionRatio, Vector2 vertexPos) + { + Color baseColor = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, completionRatio); + + return baseColor * Projectile.Opacity; + } + + public float MiniTrailWidth(float completionRatio, Vector2 vertexPos) => TrailWidth(completionRatio, vertexPos) * 5.5f; + + public override bool PreDraw(ref Color lightColor) + { + if (Projectile.timeLeft > 412) + return false; + + Color mainColor = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, ((float)Main.timeForVisualEffects * 0.5f + Projectile.whoAmI * 0.12f) % 1); + Color secondaryColor = Color.Lerp(Color.MediumPurple, Color.CornflowerBlue, ((float)Main.timeForVisualEffects * 0.5f + Projectile.whoAmI * 0.12f + 0.2f) % 1); + + Main.spriteBatch.EnterShaderRegion(); + + if (TrailTex == null) + TrailTex = Request("CalamityMod/ExtraTextures/Trails/BasicTrail"); + + GameShaders.Misc["CalamityMod:ExobladePierce"].SetShaderTexture(TrailTex); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseImage2("Images/Extra_189"); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].Apply(); + + Vector2 offset = Projectile.Size * 0.5f; + + // Apply the offset to the projectile's old position + Vector2[] oldPosWithOffset = Projectile.oldPos.Select(p => p - offset).ToArray(); + + PrimitiveRenderer.RenderTrail(oldPosWithOffset, new(TrailWidth, TrailColor, (_,_) => Projectile.Size * 1f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + + GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); + GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); + + PrimitiveRenderer.RenderTrail(oldPosWithOffset, new(MiniTrailWidth, MiniTrailColor, (_,_) => Projectile.Size * 1f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + + Main.spriteBatch.ExitShaderRegion(); + return false; + } + } +} diff --git a/Projectiles/Melee/LucreciaDNATrailCreator.cs b/Projectiles/Melee/LucreciaDNATrailCreator.cs new file mode 100644 index 0000000000..a8ffa98c27 --- /dev/null +++ b/Projectiles/Melee/LucreciaDNATrailCreator.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class LucreciaDNATrailCreator : ModProjectile, ILocalizedModType + { + private List oldPositionsLeft = new List(); + private List oldPositionsRight = new List(); + private int trailTimer = 0; + // The timer is initialized with a delay. It will reset to 6 after the first shot. + private int middleStreakTimer = 40; + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 200; + Projectile.height = 170; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.hostile = false; + Projectile.friendly = true; + Projectile.extraUpdates = 12; + Projectile.timeLeft = 2400; + Projectile.minion = true; // Scuffed but it prevents the projectile from being culled in a few situations + Projectile.alpha = 255; + } + + public override void AI() + { + Player owner = Main.player[Projectile.owner]; + trailTimer++; + + // Very volatile values... + float amplitude = 86f; + float frequency = 0.039f; + + // Makes a perpendicular/mirrored trail, AKA a double helix + Vector2 perpendicular = Vector2.Normalize(new Vector2(-Projectile.velocity.Y, Projectile.velocity.X)); + + // Calculate the sine wave value. + float sineWave = (float)Math.Cos(trailTimer * frequency); + + // Calculate offset based on the pattern of the sinewave and subtract the proj's dimensions to be accurate + Vector2 offsetLeft = (perpendicular * amplitude * sineWave); + Vector2 offsetRight = (-perpendicular * amplitude * sineWave); + + Vector2 adjustedOffsetLeft = offsetLeft - new Vector2(Projectile.width, Projectile.height); + Vector2 adjustedOffsetRight = offsetRight - new Vector2(Projectile.width, Projectile.height); + + // Store newest trail positions as points to render later + oldPositionsLeft.Add(Projectile.Center + adjustedOffsetLeft); + oldPositionsRight.Add(Projectile.Center + adjustedOffsetRight); + + // The timer will now correctly decrease once per AI update. + middleStreakTimer--; + + if (middleStreakTimer <= 0) + { + // Reset the timer for the next shot. + middleStreakTimer = 6; + + // Spawn the main trail + Particle spark = new CustomSpark(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(-170f)), "CalamityMod/Particles/BloomCircle", false, 18, 0.24f, Color.MediumPurple * 1.3f, new Vector2(1f, 2.5f), true, true, shrinkSpeed: 0.25f, glowOpacity: 0.4f); + GeneralParticleHandler.SpawnParticle(spark); + Particle spark2 = new CustomSpark(Projectile.Center + perpendicular, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(170f)), "CalamityMod/Particles/BloomCircle", false, 18, 0.24f, Color.CornflowerBlue * 1.3f, new Vector2(1f, 2.5f), true, true, shrinkSpeed: 0.25f, glowOpacity: 0.4f); + GeneralParticleHandler.SpawnParticle(spark2); + } + + // Chance to spawn small light particles along the trail + if (trailTimer % 7 == 0 && Main.rand.NextBool()) + { + // Use the unmodified offsets to align particle positions w/ the prim trails + Vector2 purpleTrailOrigin = Projectile.Center + offsetLeft; + Vector2 blueTrailOrigin = Projectile.Center + offsetRight; + + Particle purpleLightEmission = new SquishyLightParticle(purpleTrailOrigin, -Projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.5f) * Main.rand.NextFloat(2f, 4f), Main.rand.NextFloat(0.3f, 0.6f), Color.MediumPurple, Main.rand.Next(18, 46), 1, 1.5f); + Particle blueLightEmission = new SquishyLightParticle(blueTrailOrigin, -Projectile.velocity.RotatedByRandom(MathHelper.PiOver4 * 0.5f) * Main.rand.NextFloat(2f, 4f), Main.rand.NextFloat(0.3f, 0.6f), Color.CornflowerBlue, Main.rand.Next(18, 46), 1, 1.5f); + + GeneralParticleHandler.SpawnParticle(blueLightEmission); + GeneralParticleHandler.SpawnParticle(purpleLightEmission); + } + + // Remove old positions after 150 + int maxTrailLength = 150; + if (oldPositionsLeft.Count > maxTrailLength) + oldPositionsLeft.RemoveAt(0); + if (oldPositionsRight.Count > maxTrailLength) + oldPositionsRight.RemoveAt(0); + } + + private float WidthFunction(float completionRatio, Vector2 vertexPos) + { + return MathHelper.Lerp(12f, 0f, completionRatio); + } + + + private Color LeftColorFunction(float completionRatio, Vector2 vertexPos) + { + Color baseColor = Color.MediumPurple * 1.3f; + + float alphaScaling = -4 * completionRatio * (completionRatio - 1); + return baseColor * alphaScaling; + } + private Color RightColorFunction(float completionRatio, Vector2 vertexPos) + { + Color baseColor = Color.CornflowerBlue * 1.3f; + + float alphaScaling = -4 * completionRatio * (completionRatio - 1); + return baseColor * alphaScaling; + } + + + public override bool PreDraw(ref Color lightColor) + { + MiscShaderData trailShader = GameShaders.Misc["CalamityMod:TrailStreak"]; + trailShader.SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + + // Use the separate color functions for each trail + PrimitiveRenderer.RenderTrail(oldPositionsLeft, new PrimitiveSettings(WidthFunction, LeftColorFunction, (_,_) => Projectile.Size * 1f, pixelate: false, shader: trailShader)); + PrimitiveRenderer.RenderTrail(oldPositionsRight, new PrimitiveSettings(WidthFunction, RightColorFunction, (_,_) => Projectile.Size * 1f, pixelate: false, shader: trailShader)); + return false; + } + } +} diff --git a/Projectiles/Melee/LucreciaHoldout.cs b/Projectiles/Melee/LucreciaHoldout.cs new file mode 100644 index 0000000000..7268276580 --- /dev/null +++ b/Projectiles/Melee/LucreciaHoldout.cs @@ -0,0 +1,356 @@ +using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Sounds; + +namespace CalamityMod.Projectiles.Melee +{ + public class LucreciaHoldout : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override bool useMeleeSpeed => true; + public override bool useMeleeSize => false; + public override int swingWidth => 310; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override string Texture => "CalamityMod/Items/Weapons/Melee/Lucrecia"; + public override SoundStyle? UseSound => SoundID.Item71 with { Volume = 0.85f }; + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + public override int swingTime { get; set; } + public override bool AlternateSwings { get => base.AlternateSwings; set => base.AlternateSwings = value; } + public override float lineCollisionLength => 225; + + public bool helixFired = false; + public bool gotEnergyThisSwing = false; + public bool trailFXTriggered = false; + public bool particlesSpawned = false; + public bool sparkTriggered = false; + + public int standardStartupTime = 8; + public int standardSwingTime = 10; + public int standardCooldownTime = 12; + private bool IsThrusting => Projectile.localAI[0] == 1; + public bool IsAlternateThrust { get; set; } + public int thrustStartupTime = 33; + public int thrustForwardTime = 7; + public int thrustCooldownTime = 17; + public float thrustSpinRotation = 0f; + public bool playedAlternateThrustStartupWhoosh = false; + + public override void Defaults() + { + Projectile.extraUpdates = 3; + Projectile.noEnchantmentVisuals = true; + Projectile.Opacity = 0.2f; // Starting point, fades in quickly upon startup + Projectile.width = Projectile.height = 54; + Projectile.scale = 1.25f; + } + + public override void Spawn() + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + var calamityPlayer = player.Calamity(); + + // Store the base use time from the item + int baseUseTime = BaseItem.useTime; + + if (player.altFunctionUse == 2) + { + // Check for energy before the projectile exists + if (calamityPlayer.darklightEnergy < 100) + { + Projectile.Kill(); + return; + } + + IsAlternateThrust = true; + + // Scale all time vars correctly + StartupTime = (int)(thrustStartupTime * (float)player.itemAnimationMax / baseUseTime); + swingTime = (int)(thrustForwardTime * (float)player.itemAnimationMax / baseUseTime); + CooldownTime = (int)(thrustCooldownTime * (float)player.itemAnimationMax / baseUseTime); + + Projectile.DamageType = DamageClass.Melee; + Projectile.width = Projectile.height = 36; + useMeleeSize = true; + UseSound = SoundID.DD2_JavelinThrowersAttack; + OffsetDistance = -30; + RotateInStartup = 0.8f; + RotateInCooldown = 1f; + Projectile.knockBack = 15f; + + calamityPlayer.darklightEnergy = 0; // Remove energy for startup + } + else + { + IsAlternateThrust = false; + + // Scale all time vars correctly + StartupTime = (int)(standardStartupTime * (float)player.itemAnimationMax / baseUseTime); + CooldownTime = (int)(standardSwingTime * (float)player.itemAnimationMax / baseUseTime); + swingTime = (int)(standardCooldownTime * (float)player.itemAnimationMax / baseUseTime); + + OffsetDistance = 36; + RotateInStartup = 0.8f; + RotateInCooldown = 0; + } + } + + public override void AdditionalAI() + { + Player player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + + if (IsAlternateThrust) + { + if (inStartup) + { + trailFXTriggered = false; // Reset bool just in case + Projectile.Opacity += 0.02f; // Fade in + Projectile.scale = baseScale * MathHelper.Lerp(1f, 0.85f, MathF.Pow(StartupCompletion, 0.3f)); + + if (StartupCompletion >= 0.12f && !playedAlternateThrustStartupWhoosh) + { + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Volume = 0.55f, Pitch = -0.05f }, Projectile.Center); + playedAlternateThrustStartupWhoosh = true; + } + + // Every 8 ticks during this part of startup, release a sparkle and a smear effect. + if (StartupCompletion > 0.12f && StartupCompletion < 0.44f) + { + if (timer % 8 == 0) + { + Vector2 pos = player.MountedCenter + Projectile.rotation.ToRotationVector2() * 60f; + Particle sparkle = new CritSpark(pos, new Vector2(7f, 0).RotatedBy(Projectile.rotation), Color.Lerp(Color.CornflowerBlue, Color.MediumPurple, Main.rand.NextFloat(1f)), Color.White * 0.33f, 1.2f, 12, 0.3f, 1.2f); + GeneralParticleHandler.SpawnParticle(sparkle); + } + Particle smear = new CircularSmearVFX(player.MountedCenter, Color.CornflowerBlue * 0.35f, Projectile.rotation, Projectile.scale * 1.25f); + GeneralParticleHandler.SpawnParticle(smear); + } + + // Easing on spin + float t = MathHelper.Clamp(StartupCompletion * 2f, 0f, 1f); + float eased = 0.5f - 0.5f * MathF.Cos(MathHelper.Pi * t); + thrustSpinRotation = eased * MathHelper.TwoPi; + + // Adjust arm rotation along with the spin + float baseAngle = player.Center.DirectionTo(Main.MouseWorld).ToRotation(); + float totalRotation = baseAngle + (thrustSpinRotation * player.direction); + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, totalRotation - MathHelper.PiOver2); + + // Pull back + if (StartupCompletion >= 0.5f) + { + float easedPullback = MathF.Pow((StartupCompletion - 0.5f) * 2f, 0.3f); + OffsetDistance = (int)MathHelper.Lerp(44, 34, easedPullback); + } + + else + { + OffsetDistance = 50; + } + } + + else if (inCooldown) + { + Projectile.Opacity -= 0.025f; + + // During cooldown, pull back slightly + Projectile.scale = baseScale * MathHelper.Lerp(1.4f, 1.25f, CooldownCompletion); + OffsetDistance = (int)MathHelper.Lerp(78, 38, CooldownCompletion); + } + + else if (inSwing) + { + // Thrust forward + OffsetDistance = (int)MathHelper.Lerp(34, 78, SwingCompletion); + Main.player[Projectile.owner].SetScreenshake(3.5f); + + // Scaling adjustments + var t = MathHelper.Clamp(SwingCompletion, 0f, 1f); + var eased = MathF.Pow(t, 0.125f); + Projectile.scale = baseScale * MathHelper.Lerp(0.9f, 1.4f, eased); + + // VFX vars + Vector2 mousePosition = player.Calamity().mouseWorld; + Vector2 fireDirection = Vector2.Normalize(mousePosition - player.Center); + + if (!trailFXTriggered) + { + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, fireDirection * 5, ModContent.ProjectileType(), Projectile.damage * 7, Projectile.knockBack, Projectile.owner, 0f, 0f); + + SoundStyle swish = new("CalamityMod/Sounds/Custom/MeatySlash"); + SoundEngine.PlaySound(swish with { Volume = 0.3f, Pitch = Main.rand.NextFloat(0.1f, 0.2f) }, Projectile.Center); + + SoundStyle projectile = new("CalamityMod/Sounds/Item/OmicronBeam"); + SoundEngine.PlaySound(projectile with { Volume = 0.85f, Pitch = Main.rand.NextFloat(0.15f, 0.2f) }, Projectile.Center); + } + + trailFXTriggered = true; + + // Some sparks from the blade + if (!particlesSpawned) + { + for (int i = 0; i < 6; i++) + { + Vector2 particleOrigin = Projectile.Center; + Vector2 particleSpeed = fireDirection.RotatedByRandom(MathHelper.ToRadians(46f)) * Main.rand.NextFloat(20f, 37f); + Particle sparks = new CritSpark(particleOrigin, particleSpeed, Color.Lerp(Color.CornflowerBlue, Color.MediumPurple, Main.rand.NextFloat(0f, 1f)), Color.NavajoWhite * 0.7f, Main.rand.NextFloat(0.9f, 2f), Main.rand.Next(38, 50), 0.1f, 1.5f, hueShift: 0.01f); + GeneralParticleHandler.SpawnParticle(sparks); + } + particlesSpawned = true; + } + + } + } + + else // Primary + { + if (inStartup) + { + Projectile.Opacity += 0.02f; // Fade in + gotEnergyThisSwing = false; + helixFired = false; + Projectile.scale = baseScale * MathHelper.Lerp(0.625f, 0.8f, StartupCompletion); + } + + else if (inCooldown) + { + helixFired = false; + Projectile.Opacity -= 0.1f; + Projectile.scale = baseScale * MathHelper.Lerp(0.85f, 0.625f, CooldownCompletion); + } + + else if (inSwing) + { + if (!helixFired) + { + helixFired = true; + var mousePosition = Main.MouseWorld; + + // Smear fx on swing + Vector2 shootDir = player.MountedCenter.DirectionTo(mousePosition) * 10f; + int dir = -Math.Sign(mousePosition.X); + float scale = lineCollisionLength / 550f; + Particle swipe = new CustomSpark(player.MountedCenter - shootDir * 4, shootDir.RotatedBy(0.075f * (dir * (modplayer.swingNum % 2 == 0 ? 1 : -1))) * 1.22f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), scale, modplayer.swingNum % 2 == 0 ? Color.CornflowerBlue * 0.85f : Color.MediumPurple * 0.8f, new Vector2(1.1f, 1.3f), true, false, 0, false, false); + GeneralParticleHandler.SpawnParticle(swipe); + + var fireDirection = Vector2.Normalize(mousePosition - player.MountedCenter); + var helixSpeed = 12f; + var helixVelocity = fireDirection * helixSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.MountedCenter + fireDirection * 3, helixVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + + SoundStyle projectile = new("CalamityMod/Sounds/Item/LucreciaBoltFire"); + SoundEngine.PlaySound(projectile with { Volume = 0.8f, Pitch = Main.rand.NextFloat(-0.06f, 0.1f) }, Projectile.Center); + } + + // Matched easing from SwingFunction + var t = MathHelper.Clamp(SwingCompletion, 0f, 1f); + float easedMovement = MathF.Pow(t, 0.4f); + var parabola = 1f - MathF.Pow(easedMovement - 0.5f, 2f) * 4f; + OffsetDistance = (int)MathHelper.Lerp(36 * 1f, 36 * 1.435f, parabola); + + var upPhase = easedMovement <= 0.5f ? easedMovement * 0.5f : (1f - easedMovement) * 0.5f; + var scaleEase = MathF.Pow(upPhase, 2.6f); + Projectile.scale = baseScale * MathHelper.Lerp(0.8f, 1.4f, scaleEase); + + // Every 5 ticks during swing, release a particle + if (t > 0.05f && t < 0.5f) + { + if (timer % 5 == 0) + { + var fireDirection = Vector2.Normalize(Main.MouseWorld - player.Center); + var helixVelocity = fireDirection * 14f; + + SparkParticle orb3 = new SparkParticle(player.Center + fireDirection * 3, helixVelocity.RotatedByRandom(1f), true, 16, 0.5f, Color.Lerp(Color.CornflowerBlue, Color.MediumPurple, Main.rand.NextFloat()) * 0.66f, true); + GeneralParticleHandler.SpawnParticle(orb3); + } + } + } + } + base.AdditionalAI(); + } + + public override float SwingFunction() + { + var player = Main.player[Projectile.owner]; + + if (IsAlternateThrust) + { + if (inStartup) + return thrustSpinRotation; + else + return 0f; // Just retract and fade out without moving the angle + } + + else // Primary swing + { + var modplayer = player.GetModPlayer(); + float swingDirection = Projectile.spriteDirection; + if (modplayer.swingNum % 2 == 1) + swingDirection *= -1; + + float easedCompletion = MathF.Pow(SwingCompletion, 0.4f); + + var startAnglePrimary = -swingWidth / 2.15f; + var endAnglePrimary = swingWidth / 2.15f; + var trueAnglePrimary = MathHelper.Lerp(startAnglePrimary, endAnglePrimary, easedCompletion); + + // Tie arc's path to easedCompletion + var parabolicFactorPrimary = 1f - MathF.Pow(easedCompletion - 0.5f, 2f) * 4f; + parabolicFactorPrimary = MathHelper.Clamp(parabolicFactorPrimary, 0f, 1f); + Projectile.localAI[0] = parabolicFactorPrimary; + + return MathHelper.ToRadians(trueAnglePrimary * -swingDirection); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Add energy for the primary attack + if (!IsAlternateThrust && !gotEnergyThisSwing) + { + SoundEngine.PlaySound(CommonCalamitySounds.SwiftSliceSound with { Volume = CommonCalamitySounds.SwiftSliceSound.Volume * 0.3f }, Projectile.Center); + + gotEnergyThisSwing = true; + var player = Main.player[Projectile.owner]; + var modPlayer = player.Calamity(); + + // +25 energy on hit + modPlayer.darklightEnergy += 25; + modPlayer.darklightEnergy = Math.Min(modPlayer.darklightEnergy, Lucrecia.MaxEnergy); + + // On-hit cut FX + int points = 2; + float radians = MathHelper.TwoPi / points; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)).RotatedByRandom(100); + + var modplayer = player.GetModPlayer(); + Color useColor = modplayer.swingNum % 2 == 0 ? Color.CornflowerBlue : Color.MediumPurple; // Alternate each swing + + for (int k = 0; k < points; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f); + Particle spark = new GlowSparkParticle((target.Center + velocity * 7.5f), velocity * 0.5f, false, 9, 0.05f, useColor, new Vector2(0.5f, 0.6f), true, false); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + // Draw fullbright + lightColor = Color.White; + return base.PreDraw(ref lightColor); + } + } +} diff --git a/Projectiles/Melee/LuxorsGiftMelee.cs b/Projectiles/Melee/LuxorsGiftMelee.cs index 0535c4ff7f..1d1770c2a9 100644 --- a/Projectiles/Melee/LuxorsGiftMelee.cs +++ b/Projectiles/Melee/LuxorsGiftMelee.cs @@ -5,7 +5,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/MaceFlails/BallOFuguProj.cs b/Projectiles/Melee/MaceFlails/BallOFuguProj.cs index afbe2c194e..75fda7e3a0 100644 --- a/Projectiles/Melee/MaceFlails/BallOFuguProj.cs +++ b/Projectiles/Melee/MaceFlails/BallOFuguProj.cs @@ -1,7 +1,6 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -70,12 +69,18 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails if (SpikeCount > 0) { SoundEngine.PlaySound(BallOFugu.BlowSound, Projectile.Center); - Particle BlowParticle = new CustomPulse(Projectile.Center, Vector2.Zero, SpikeColor, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(0, MathHelper.TwoPi), 0f, 0.05f + 0.005f * SpikeCount, 12); - GeneralParticleHandler.SpawnParticle(BlowParticle); + + for (int i = -4; i < 5; i++) + { + Vector2 maxScale = new Vector2(Main.rand.NextFloat(1f, 1.2f), Main.rand.NextFloat(0.6f, 0.75f)) * (i % 2 == 0 ? 1f : 1.35f); + float rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(30f * i); + CustomPulse spike = new CustomPulse(Projectile.Center, Vector2.One, SpikeColor, "CalamityMod/Particles/BlastCone", maxScale, rotation, 1f, 0.5f, 12); + GeneralParticleHandler.SpawnParticle(spike); + } for (int i = 0; i < SpikeCount; i++) { - Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(6f, 7.2f); + Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(MathHelper.ToRadians(105f)) * Main.rand.NextFloat(6f, 7.2f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * SpikeDamage), Projectile.knockBack * SpikeKnockback, Projectile.owner); } } diff --git a/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs b/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs index 224fd4eb9d..d8424376f5 100644 --- a/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs +++ b/Projectiles/Melee/MaceFlails/RemsRevengeProj.cs @@ -1,10 +1,8 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.MaceFlails diff --git a/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs b/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs index d1da4b4c20..19f619afe6 100644 --- a/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs +++ b/Projectiles/Melee/MaceFlails/TumbleweedFlail.cs @@ -1,9 +1,7 @@ using CalamityMod.DataStructures; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Typeless; -using ReLogic.Content; using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -29,6 +27,8 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails public override float RetractAcceleration => 4f; public static float MaxAuraTime = 60f; + private bool hasDetached = false; + private int detachDelay = 0; public ref float AuraScale => ref Projectile.ai[2]; @@ -54,6 +54,13 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails sand.velocity = CurrentFlailState == FlailState.Spinning ? Main.rand.NextVector2Unit() * 1.5f : Projectile.velocity * 0.25f; } + // Force the flail to stay in launch state for a few frames after detaching to prevent spam-click abuse at point-blank + if (detachDelay > 0) + { + detachDelay--; + CurrentFlailState = detachDelay == 0 ? FlailState.ForcedRetracting : FlailState.LaunchingForward; + } + if (CurrentFlailState == FlailState.Spinning) { Projectile.ownerHitCheck = false; // Dust aura can hit through walls @@ -94,7 +101,21 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails Main.EntitySpriteDraw(Aura, position, null, drawColor, Main.GlobalTimeWrappedHourly * 0.5f + (i * i * 0.03f), Aura.Size() * 0.5f, AuraScale - (i * 0.03f), SpriteEffects.None, 0); } } - return base.PreDraw(ref lightColor); + + if (hasDetached) + { + DrawChain(); + return false; + } + else + return base.PreDraw(ref lightColor); + } + + public override bool? CanDamage() + { + if (hasDetached) + return false; + return base.CanDamage(); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) @@ -123,7 +144,11 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails if (Projectile.owner == Main.myPlayer) Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity, ModContent.ProjectileType(), (int)(Projectile.damage * LaunchDamage), Projectile.knockBack, Projectile.owner, CurrentFlailState == FlailState.LaunchingForward ? 0f : 1f); - Projectile.Kill(); + hasDetached = true; + if ((CurrentFlailState == FlailState.LaunchingForward || CurrentFlailState == FlailState.Ricochet) && StateTimer < 6) + detachDelay = 6; + else + CurrentFlailState = FlailState.ForcedRetracting; } } } diff --git a/Projectiles/Melee/MaceFlails/UrchinMaceProj.cs b/Projectiles/Melee/MaceFlails/UrchinMaceProj.cs index 17eb3bd5ad..477271b0b2 100644 --- a/Projectiles/Melee/MaceFlails/UrchinMaceProj.cs +++ b/Projectiles/Melee/MaceFlails/UrchinMaceProj.cs @@ -1,8 +1,8 @@ using System; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.MaceFlails { + [PierceResistException] public class UrchinMaceProj : BaseMaceFlailProjectile { // The entire chain is on the mace sprite, in which the player swings @@ -22,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails // This flail only runs through one state (spin), thereby making most parameters unnecessary to fill out public override int AssociatedItemID => ModContent.ItemType(); public override int SpinIFrames => 15; - public override float SpinHitboxRadius => 64f; + public override float SpinHitboxRadius => 56f; public override float SpinVerticalFactor => 1f; // This flail moves circular public override float LaunchSpeed => 22f; @@ -59,7 +60,7 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails for (int i = 0; i < 25; i++) { Vector2 dustPos = Owner.position + Main.rand.NextVector2FromRectangle(Owner.Hitbox); - Dust dust = Dust.NewDustPerfect(dustPos, 176, Vector2.UnitY * -5f * Main.rand.NextFloat(1f, 2f) + Owner.velocity, Scale: Main.rand.NextFloat(1f, 2f)); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.BubbleBurst_Blue, Vector2.UnitY * -5f * Main.rand.NextFloat(1f, 2f) + Owner.velocity, Scale: Main.rand.NextFloat(1f, 2f)); dust.noGravity = true; } } @@ -77,7 +78,7 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails { float angle = i / (float)dustCount * MathHelper.TwoPi + offset; Vector2 dustPos = Owner.MountedCenter + angle.ToRotationVector2() * 40f * WindupProgress; - Dust dust = Dust.NewDustPerfect(dustPos, 176, (angle - MathHelper.PiOver2 * Owner.direction).ToRotationVector2() * 5f + Owner.velocity, Scale: Main.rand.NextFloat(1f, 2f)); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.BubbleBurst_Blue, (angle - MathHelper.PiOver2 * Owner.direction).ToRotationVector2() * 5f + Owner.velocity, Scale: Main.rand.NextFloat(1f, 2f)); dust.noGravity = true; } } @@ -132,17 +133,17 @@ namespace CalamityMod.Projectiles.Melee.MaceFlails Texture2D whirlpoolTexture = TextureAssets.Projectile[ModContent.ProjectileType()].Value; float WindupProgress = MathHelper.Clamp(StateTimer, 0, MaxWindup) / MaxWindup; - float whirlpoolScale = MathHelper.Clamp(WindupProgress * 3f - 0.4f, 0f, 1f) * 2f; + float whirlpoolScale = MathHelper.Clamp(WindupProgress * 3f - 0.4f, 0f, 1f) * 1.6f; float whirlpoolOpacity = WindupProgress * 0.2f + MathF.Sin(Main.GlobalTimeWrappedHourly * 3f) * 0.1f; float whirlpoolRotation = StateTimer * 0.34f * Owner.direction; SpriteEffects flip = Owner.direction < 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(whirlpoolTexture, Owner.MountedCenter - Main.screenPosition, null, Lighting.GetColor((int)Owner.MountedCenter.X / 16, (int)Owner.MountedCenter.Y / 16) * whirlpoolOpacity * 0.3f, whirlpoolRotation * 1.2f, whirlpoolTexture.Size() / 2f, whirlpoolScale, flip, 0); - Main.EntitySpriteDraw(whirlpoolTexture, Owner.MountedCenter - Main.screenPosition, null, Lighting.GetColor((int)Owner.MountedCenter.X / 16, (int)Owner.MountedCenter.Y / 16) * whirlpoolOpacity, whirlpoolRotation, whirlpoolTexture.Size() / 2f, whirlpoolScale, flip, 0); + Main.EntitySpriteDraw(whirlpoolTexture, Owner.MountedCenter - Main.screenPosition, null, Lighting.GetColor((int)Owner.MountedCenter.X / 16, (int)Owner.MountedCenter.Y / 16) * whirlpoolOpacity * 0.3f, whirlpoolRotation * 1.2f, whirlpoolTexture.Size() * 0.5f, whirlpoolScale, flip); + Main.EntitySpriteDraw(whirlpoolTexture, Owner.MountedCenter - Main.screenPosition, null, Lighting.GetColor((int)Owner.MountedCenter.X / 16, (int)Owner.MountedCenter.Y / 16) * whirlpoolOpacity, whirlpoolRotation, whirlpoolTexture.Size() * 0.5f, whirlpoolScale, flip); Vector2 handleOrigin = new Vector2(0, maceTexture.Height); float maceRotation = Projectile.rotation + MathHelper.PiOver4; - Main.EntitySpriteDraw(maceTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), maceRotation, handleOrigin, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(maceTexture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), maceRotation, handleOrigin, Projectile.scale, SpriteEffects.None); return false; } } diff --git a/Projectiles/Melee/MaceFlails/YateveoBloomMace.cs b/Projectiles/Melee/MaceFlails/YateveoBloomMace.cs index 1073486d6b..9972b1baee 100644 --- a/Projectiles/Melee/MaceFlails/YateveoBloomMace.cs +++ b/Projectiles/Melee/MaceFlails/YateveoBloomMace.cs @@ -1,4 +1,5 @@ using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Projectiles.BaseProjectiles; using Terraria; using Terraria.ID; @@ -6,6 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.MaceFlails { + [PierceResistException] public class YateveoBloomMace : BaseMaceFlailProjectile { public override int AssociatedItemID => ModContent.ItemType(); diff --git a/Projectiles/Melee/MajesticGuardHoldout.cs b/Projectiles/Melee/MajesticGuardHoldout.cs index 0e1d75a86c..ddb54e5253 100644 --- a/Projectiles/Melee/MajesticGuardHoldout.cs +++ b/Projectiles/Melee/MajesticGuardHoldout.cs @@ -1,5 +1,5 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -7,12 +7,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class MajesticGuardHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -34,6 +35,7 @@ namespace CalamityMod.Projectiles.Melee public int swingCount; public bool finalFlip = false; public bool playSwingSound = true; + public int armoredHits = 0; public override void SetDefaults() { base.SetDefaults(); @@ -92,6 +94,7 @@ namespace CalamityMod.Projectiles.Melee doSwing = true; finalFlip = false; + armoredHits = 0; } else { @@ -163,7 +166,7 @@ namespace CalamityMod.Projectiles.Melee { for (int i = 0; i < 2; i++) { - Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(150, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), 278, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 2)); + Dust dust2 = Dust.NewDustPerfect(Owner.Center + (new Vector2(150, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), DustID.FireworksRGB, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 2)); dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool() ? Color.Silver : Color.Gold; @@ -177,8 +180,10 @@ namespace CalamityMod.Projectiles.Melee } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) + if ((target.life <= 0 && target.realLife == -1) && Projectile.numHits > 0) Projectile.numHits -= 1; + if (damageDone <= 2) + armoredHits++; SoundStyle fire = new("CalamityMod/Sounds/Item/CursedDaggerThrow"); SoundEngine.PlaySound(fire with { Volume = 0.65f, Pitch = 0.8f }, Projectile.Center); @@ -188,7 +193,7 @@ namespace CalamityMod.Projectiles.Melee int heal = (int)(MathHelper.Clamp(7 - Projectile.numHits * 5, 1, 7)); if (Projectile.numHits < 5) { - Owner.HealPlayer(heal); + Owner.DoLifestealDirect(target, heal); } Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); @@ -209,7 +214,7 @@ namespace CalamityMod.Projectiles.Melee { float minMult = 0.3f; int hitsToMinMult = 5; - float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + float damageMult = Utils.Remap(Projectile.numHits - armoredHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Melee/MantisClawHoldout.cs b/Projectiles/Melee/MantisClawHoldout.cs index 190f752a77..72d110327a 100644 --- a/Projectiles/Melee/MantisClawHoldout.cs +++ b/Projectiles/Melee/MantisClawHoldout.cs @@ -1,21 +1,14 @@ -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using CalamityMod.Items.BaseItems; -using Terraria.ModLoader; +using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using CalamityMod.Balancing; +using Terraria; using Terraria.Audio; -using CalamityMod.Items.Weapons.Melee; -using System; -using CalamityMod.Particles; -using Terraria.DataStructures; -using System.Collections.Generic; -using CalamityMod.Graphics.Primitives; -using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -23,7 +16,7 @@ namespace CalamityMod.Projectiles.Melee { bool AnimationCooldown = false; - float JetDamageMultiplier => 7.5f; + float JetDamageMultiplier => 6.5f; int SlashSpeed => 6; int BlastChargeUses => 3; @@ -35,8 +28,15 @@ namespace CalamityMod.Projectiles.Melee public float ClawOpenness = MathHelper.ToRadians(80); public float BubbleSize = 0f; + public int m2KillTimer = 0; public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Items/Weapons/Melee/MantisClaws"; + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.DamageType = DamageClass.Melee; + } public override void ResetStyle() { if (AnimationCooldown) @@ -49,10 +49,15 @@ namespace CalamityMod.Projectiles.Melee if (BubbleSize < 0.05f) { - Projectile.scale -= 0.1f; - - if (Projectile.scale < 0.1f) + if (Projectile.scale > 0 && m2KillTimer <= 10) + Projectile.scale -= 0.1f; + if (Projectile.scale < 0.1f && m2KillTimer <= 0) Projectile.active = false; + else + { + Owner.altFunctionUse = 2; + m2KillTimer--; + } } } else @@ -68,10 +73,11 @@ namespace CalamityMod.Projectiles.Melee if (BubbleSize != 0f) { Owner.Calamity().mouseWorldListener = true; + m2KillTimer = 20; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center + new Vector2(20, 0).RotatedBy(Projectile.rotation), - Owner.DirectionTo(Owner.Calamity().mouseWorld) * 30, ModContent.ProjectileType(), (int)(Projectile.damage * JetDamageMultiplier), 7, Owner.whoAmI); + Owner.DirectionTo(Owner.Calamity().mouseWorld) * 30, ModContent.ProjectileType(), (int)(Projectile.damage * JetDamageMultiplier), 7, Owner.whoAmI, 0f, 40f); for (int i = 0; i < 9; i++) { @@ -83,7 +89,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound((Main.rand.NextBool(2) ? SoundID.Item85 : SoundID.Item86).WithPitchOffset(-0.5f), Owner.Center); SoundEngine.PlaySound(SoundID.NPCDeath14.WithPitchOffset(1f), Owner.Center); - Owner.Calamity().GeneralScreenShakePower = 3f; + Owner.SetScreenshake(3f); GeneralParticleHandler.SpawnParticle(new MantisPunch(Owner.Center + new Vector2(26, 0).RotatedBy(Projectile.rotation), Projectile.rotation)); } @@ -129,7 +135,7 @@ namespace CalamityMod.Projectiles.Melee Owner.Calamity().mouseWorldListener = true; // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Projectile slash = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center, Owner.DirectionTo(Owner.Calamity().mouseWorld) * 6f, ModContent.ProjectileType(), Projectile.damage, 4f, Owner.whoAmI); + Projectile slash = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center, Owner.DirectionTo(Owner.Calamity().mouseWorld) * 6f, ModContent.ProjectileType(), Projectile.damage, 2f, Owner.whoAmI); slash.rotation = Owner.AngleTo(Owner.Calamity().mouseWorld) + MathHelper.ToRadians(Main.rand.NextFloat(-25, 25)); } diff --git a/Projectiles/Melee/MantisClawJet.cs b/Projectiles/Melee/MantisClawJet.cs index 87821016d3..842fb8f964 100644 --- a/Projectiles/Melee/MantisClawJet.cs +++ b/Projectiles/Melee/MantisClawJet.cs @@ -1,16 +1,9 @@ -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using CalamityMod.Items.BaseItems; using Terraria.ModLoader; -using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using CalamityMod.Balancing; -using Terraria.Audio; -using CalamityMod.Items.Weapons.Melee; -using System; using CalamityMod.Particles; using Terraria.DataStructures; using System.Collections.Generic; @@ -39,7 +32,6 @@ namespace CalamityMod.Projectiles.Melee Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 60; Projectile.timeLeft = TimerCap; - Projectile.knockBack = 2; Projectile.tileCollide = false; Projectile.width = 20; Projectile.height = 20; @@ -47,7 +39,6 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = -1; Projectile.extraUpdates = 5; Projectile.DamageType = DamageClass.Melee; - Projectile.ai[1] = 40; } public override void OnSpawn(IEntitySource source) @@ -64,16 +55,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[0]++; } - public override bool? CanDamage() - { - return true; - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { Player owner = Main.player[Projectile.owner]; - if (Main.rand.Next(100) < owner.GetWeaponCrit(owner.ActiveItem()) + 20) - modifiers.SetCrit(); + modifiers.SetCrit(); } public override bool PreDraw(ref Color lightColor) @@ -112,7 +97,7 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request(Texture)); - PrimitiveRenderer.RenderTrail(positions, new PrimitiveSettings(AA => { return Projectile.ai[1]; }, CC => { return Lighting.GetColor(Vector2.Lerp(Projectile.oldPos[Projectile.oldPos.Length - 1], Projectile.position, CC).ToPoint()).MultiplyRGBA(WaterColor); }, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); + PrimitiveRenderer.RenderTrail(positions, new PrimitiveSettings((AA,_) => { return Projectile.ai[1]; }, (CC,_) => { return Lighting.GetColor(Vector2.Lerp(Projectile.oldPos[Projectile.oldPos.Length - 1], Projectile.position, CC).ToPoint()).MultiplyRGBA(WaterColor); }, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); return false; } diff --git a/Projectiles/Melee/MantisClawSlash.cs b/Projectiles/Melee/MantisClawSlash.cs index bdf5b9b823..a0783efbce 100644 --- a/Projectiles/Melee/MantisClawSlash.cs +++ b/Projectiles/Melee/MantisClawSlash.cs @@ -1,51 +1,37 @@ -using CalamityMod.Projectiles.Typeless; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using CalamityMod.Items.BaseItems; -using Terraria.ModLoader; -using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using CalamityMod.Balancing; -using Terraria.Audio; -using CalamityMod.Items.Weapons.Melee; -using System; -using CalamityMod.Particles; +using Terraria; using Terraria.DataStructures; -using System.Collections.Generic; -using CalamityMod.Graphics.Primitives; -using Terraria.Graphics.Shaders; -using CalamityMod.Buffs.DamageOverTime; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { public class MantisClawSlash : ModProjectile, ILocalizedModType { - public int TimerCap => 20; - public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Particles/SlashSmear"; + private const int TimerCap = 20; Color startColor; Color endColor; + int dir = 1; public override void SetDefaults() { Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 60; Projectile.timeLeft = TimerCap; - Projectile.knockBack = 2; Projectile.tileCollide = false; Projectile.width = 256; Projectile.height = 256; Projectile.friendly = true; Projectile.penetrate = -1; - Projectile.DamageType = DamageClass.Melee; + Projectile.DamageType = TrueMeleeDamageClass.Instance; } - int dir = 1; - public override void OnSpawn(IEntitySource source) { Projectile.scale = 0f; @@ -53,7 +39,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.NextBool(2)) dir = -1; - // i cherry picked five specific colors to make a similar but different palette to the claws themselves + // I cherry picked five specific colors to make a similar but different palette to the claws themselves // of those five, the projectile lerps between two, randomly chosen when the projectile is spawned List ColorList = [ @@ -89,23 +75,11 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.ToRadians(3f) * dir); Projectile.ai[1]++; - Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], MathHelper.TwoPi * dir, 0.15f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override bool? CanDamage() - { - return true; - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); public override bool PreDraw(ref Color lightColor) { @@ -116,7 +90,6 @@ namespace CalamityMod.Projectiles.Melee Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, tex.Frame(), Color.Lerp(startColor, endColor, Projectile.ai[1] / TimerCap).MultiplyRGBA(new Color(255, 255, 255, 0f)), Projectile.rotation - (dir == -1 ? MathHelper.ToRadians(-135f) : MathHelper.ToRadians(180f)) + Projectile.ai[0], tex.Size() / 2, MathHelper.Lerp(0.6f, 1f, i) * Projectile.scale, dir == 1 ? SpriteEffects.None : SpriteEffects.FlipVertically); } - return false; } } diff --git a/Projectiles/Melee/MarniteDeconstructorProj.cs b/Projectiles/Melee/MarniteDeconstructorProj.cs index 1d006e1ea9..e2b9b8dc85 100644 --- a/Projectiles/Melee/MarniteDeconstructorProj.cs +++ b/Projectiles/Melee/MarniteDeconstructorProj.cs @@ -5,7 +5,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -34,6 +34,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.hide = true; Projectile.ownerHitCheck = true; Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool ShouldUpdatePosition() => false; @@ -74,7 +76,7 @@ namespace CalamityMod.Projectiles.Melee // 15NOV2024: Ozzatron: clamped mouse position unnecessary, result is clamped later Vector2 newVelocity = Owner.Calamity().mouseWorld - Owner.MountedCenter; - if (Main.tile[Player.tileTargetX, Player.tileTargetY].WallType != 0) + if (Main.tile[Player.tileTargetX, Player.tileTargetY].WallType != WallID.None) { newVelocity = new Vector2(Player.tileTargetX, Player.tileTargetY) * 16f + Vector2.One * 8f - Owner.MountedCenter; MoveInIntervals = 2f; diff --git a/Projectiles/Melee/MarniteObliteratorProj.cs b/Projectiles/Melee/MarniteObliteratorProj.cs index d110a46fa3..d03dee081a 100644 --- a/Projectiles/Melee/MarniteObliteratorProj.cs +++ b/Projectiles/Melee/MarniteObliteratorProj.cs @@ -6,9 +6,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -36,6 +34,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.hide = true; Projectile.ownerHitCheck = true; Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool ShouldUpdatePosition() => false; @@ -115,13 +115,13 @@ namespace CalamityMod.Projectiles.Melee Projectile.Center = Owner.MountedCenter + Projectile.velocity; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = (float)Math.Sqrt(1 - completionRatio); return Color.DeepSkyBlue * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return 29.4f * completionRatio; } diff --git a/Projectiles/Melee/MawOfInfinityHoldout.cs b/Projectiles/Melee/MawOfInfinityHoldout.cs new file mode 100644 index 0000000000..cb0d2546cb --- /dev/null +++ b/Projectiles/Melee/MawOfInfinityHoldout.cs @@ -0,0 +1,163 @@ +using System; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class MawOfInfinityHoldout : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override bool useMeleeSpeed => true; + public override bool useMeleeSize => true; + public override int swingWidth => 270; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 0; + + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + + public override string Texture => ModContent.GetModItem(BaseItem.type).Texture; + + public override float lineCollisionLength => 232; + public override bool AlternateSwings => true; + + public override void Defaults() + { + Projectile.width = 78; + Projectile.height = 94; + Projectile.extraUpdates = 5; //ExtraUpdates help make collision more accurate + Projectile.noEnchantmentVisuals = true; + } + public override void Spawn() + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 10; + CooldownTime = 10; + swingTime -= StartupTime + CooldownTime; + + if (Main.myPlayer == Projectile.owner) + modplayer.swingNum = modplayer.swingNum++ % 3; + OffsetDistance = 70; + RotateInStartup = 0.2f; + RotateInCooldown = 0f; + + UseSound = SoundID.DD2_MonkStaffSwing; + } + + public override void AdditionalAI() + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + switch (modplayer.swingNum) + { + case 1: + if (inSwing) + { + var veloc = oldPlayerOffset - (Projectile.Center - Main.player[Projectile.owner].Center); + veloc.Normalize(); + int sparkLifetime = Main.rand.Next(15, 23); + + Vector2 sparkVel = Vector2.UnitY * -9f; + float maxRotationDeviance = 0.4f; + float rotationAngle = Main.rand.NextFloat(-maxRotationDeviance, maxRotationDeviance); + sparkVel = sparkVel.RotatedBy(rotationAngle) * Main.rand.NextFloat(0.3f, 1.0f); + + float sparkScale = Main.rand.NextFloat(0.007f, 0.015f); + + Vector2 compensatedSparkVel = veloc.RotatedBy(MathHelper.PiOver4 * 0.5f * Projectile.spriteDirection) * Main.rand.NextFloat(2, 5); + Particle spark = new GlowSparkParticle(Projectile.Center + new Vector2(-angle.X.DirectionalSign(), Main.rand.NextFloat(-0.05f, 0.05f)).RotatedBy(Projectile.rotation - 0.7f * Projectile.spriteDirection) * Main.rand.NextFloat(-20, -108) * Projectile.scale, compensatedSparkVel, false, sparkLifetime, sparkScale, Main.rand.NextBool() ? Color.Fuchsia : Color.HotPink, new Vector2(0.5f, 1.3f)); + GeneralParticleHandler.SpawnParticle(spark); + } + break; + case 2: + if (swingTimer == (int)(swingTime*0.5f)) + { + if (Main.myPlayer == Projectile.owner) + { + for (var i = -1; i < 2; i++) + { + var p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, -angle.RotatedBy(0.2f * i) * 16, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, player.whoAmI, 2); + if (Main.projectile.IndexInRange(p)) + { + Main.projectile[p].hostile = false; + Main.projectile[p].friendly = true; + Main.projectile[p].DamageType = DamageClass.Melee; + Main.projectile[p].timeLeft = 120; + Main.projectile[p].netUpdate = true; + } + } + } + } + if (inSwing) + { + var veloc = oldPlayerOffset - (Projectile.Center - Main.player[Projectile.owner].Center); + veloc.Normalize(); + int sparkLifetime = Main.rand.Next(15, 23); + + Vector2 sparkVel = Vector2.UnitY * -9f; + float maxRotationDeviance = 0.4f; + float rotationAngle = Main.rand.NextFloat(-maxRotationDeviance, maxRotationDeviance); + sparkVel = sparkVel.RotatedBy(rotationAngle) * Main.rand.NextFloat(0.3f, 1.0f); + + float sparkScale = Main.rand.NextFloat(0.007f, 0.015f); + + Vector2 compensatedSparkVel = veloc.RotatedBy(MathHelper.PiOver4 * 0.5f * Projectile.spriteDirection) * Main.rand.NextFloat(2, 5); + Particle spark = new GlowSparkParticle(Projectile.Center + new Vector2(-angle.X.DirectionalSign(), Main.rand.NextFloat(-0.05f, 0.05f)).RotatedBy(Projectile.rotation - 0.7f * Projectile.spriteDirection) * Main.rand.NextFloat(20, 108) * Projectile.scale, compensatedSparkVel, false, sparkLifetime, sparkScale, Main.rand.NextBool() ? Color.Cyan : Color.Aqua, new Vector2(0.5f, 1.3f)); + GeneralParticleHandler.SpawnParticle(spark); + } + break; + case 0: + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, -angle * 3, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, player.whoAmI); + player.itemAnimation = BaseItem.useAnimation; + player.itemTime = BaseItem.useTime; + Projectile.Kill(); + return; + } + } + + public override float SwingFunction() + { + if (inStartup) + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.6f, -swingWidth * 0.5f, MathF.Pow(StartupCompletion, 2f))); + if (inCooldown) + return MathHelper.ToRadians(MathHelper.Lerp(swingWidth * 0.5f, swingWidth * 0.6f, 1 - MathF.Pow(1 - CooldownCompletion, 2f))); + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.5f, swingWidth * 0.5f, SwingCompletion)); + } + + public override void PostDraw(Color lightColor) + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + if (modplayer.swingNum == 0) + return; + var tex = ModContent.Request("CalamityMod/Particles/Jaws").Value; + float jawScaleMult = 1f; + if (inStartup) + jawScaleMult = StartupCompletion; + if (inCooldown) + jawScaleMult = 1-CooldownCompletion; + jawScaleMult = MathF.Pow(jawScaleMult, 3); + float rotation = Projectile.rotation - (Projectile.spriteDirection == -1 ? MathHelper.PiOver2: 0); + Vector2 DrawPos = Projectile.Center + Projectile.scale * new Vector2(50,10 * Projectile.spriteDirection).RotatedBy(Projectile.rotation - MathHelper.PiOver2 + (Projectile.spriteDirection == -1 ? -MathHelper.PiOver4 : MathHelper.PiOver4)); + + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.spriteBatch.Draw(tex, DrawPos - Main.screenPosition, tex.Frame(2,1,0,0), modplayer.swingNum == 1 ? Color.Fuchsia : Color.Cyan, rotation + MathHelper.PiOver4, new Vector2(tex.Width * 0.25f,tex.Height * 0.5f), Projectile.scale * jawScaleMult, Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 240); + } + } +} diff --git a/Projectiles/Melee/MawOfInfinityJaws.cs b/Projectiles/Melee/MawOfInfinityJaws.cs new file mode 100644 index 0000000000..683d84967e --- /dev/null +++ b/Projectiles/Melee/MawOfInfinityJaws.cs @@ -0,0 +1,142 @@ +using System; +using System.IO; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class MawOfInfinityJaws : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + + public override string Texture => "CalamityMod/Particles/Jaws"; + public int time = 0; + public override void SetDefaults() + { + Projectile.width = 500; + Projectile.height = 500; + Projectile.DamageType = DamageClass.Melee; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 35; + Projectile.alpha = 100; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.WriteVector2(GoalPos); + writer.WriteVector2(StartPos); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + GoalPos = reader.ReadVector2(); + StartPos = reader.ReadVector2(); + } + + Vector2 GoalPos = Vector2.Zero; + Vector2 StartPos = Vector2.Zero; + float offset = 0; + + public override void AI() + { + var player = Main.player[Projectile.owner]; + if (GoalPos == Vector2.Zero) + { + GoalPos = player.Calamity().mouseWorld; + StartPos = Projectile.Center; + Projectile.netUpdate = true; + } + Projectile.Center = Vector2.Lerp(StartPos, GoalPos, MathHelper.Min(1,MathF.Pow(1 - (Projectile.timeLeft - 5) / 30f,0.5f))); + Projectile.rotation = StartPos.DirectionTo(GoalPos).ToRotation(); + offset = 200*MathHelper.Min(MathF.Pow(1-(Projectile.timeLeft-5)/30f,0.4f), (Projectile.timeLeft - 5) / 5f); + if (offset < 16) + offset = 16; + if (Projectile.timeLeft == 5) + { + Projectile.friendly = true; + + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCKilled/DevourerSegmentBreak1") { Volume = 0.3f, PitchVariance = 0.3f }, Projectile.position); + SoundEngine.PlaySound(SoundID.Item62 with { Volume = 0.5f, PitchVariance = 0.3f }, Projectile.position); + for (int i = 0; i < 35; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.GiantCursedSkullBolt, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.9f), 0, default, Main.rand.NextFloat(1.5f, 2.8f)); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + dust.noGravity = true; + } + for (int j = 0; j < 14; j++) + { + Vector2 dustVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f); + + Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, DustID.WitherLightning, dustVel, 0, default, 1f); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, DustID.Electric, dustVel, 0, default, 1f); + dust.shader = GameShaders.Armor.GetSecondaryShader(player.cShield, player); + } + if (Main.LocalPlayer.Distance(Projectile.Center) < 1600) + Main.LocalPlayer.SetScreenshake(5f); + + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Aqua, new Vector2(2f, 2f), 0, 0.2f, 1.7f, 36); + GeneralParticleHandler.SpawnParticle(pulse); + + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.Magenta, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 1.3f, 26); + GeneralParticleHandler.SpawnParticle(explosion2); + + } + time++; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.tileCollide = false; + if (Projectile.timeLeft > 85) + { + Projectile.timeLeft = 85; + } + return false; + } + + public override Color? GetAlpha(Color lightColor) + { + if (Projectile.timeLeft < 85) + { + byte b2 = (byte)(Projectile.timeLeft * 3); + byte a2 = (byte)(100f * ((float)b2 / 255f)); + return new Color((int)b2, (int)b2, (int)b2, (int)a2); + } + return default(Color); + } + + public override bool PreDraw(ref Color lightColor) + { + var tex = TextureAssets.Projectile[Type].Value; + float jawScaleMult = 1f + (0.007f * time); + jawScaleMult = MathF.Pow(jawScaleMult, 3); + float rotationOff = 0.5f * MathHelper.Min(MathF.Pow(MathHelper.Clamp(1 - (Projectile.timeLeft - 5) / 30f,0,1),0.5f), MathF.Pow(MathHelper.Clamp((Projectile.timeLeft - 5) / 10f,0,1),0.5f)); + if (rotationOff < 0.01f) + rotationOff = 0.01f; + float drawRot = Projectile.rotation; + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.spriteBatch.Draw(tex, Projectile.Center + new Vector2(0, offset).RotatedBy(drawRot) - Main.screenPosition, tex.Frame(2, 1, 0, 0), Color.Fuchsia, Projectile.rotation + rotationOff + MathHelper.PiOver2, new Vector2(tex.Width * 0.25f, tex.Height * 0.5f), jawScaleMult, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + Main.spriteBatch.Draw(tex, Projectile.Center + new Vector2(0, -offset).RotatedBy(drawRot) - Main.screenPosition, tex.Frame(2, 1, 1, 0), Color.Aqua, Projectile.rotation - rotationOff + MathHelper.PiOver2, new Vector2(tex.Width * 0.25f, tex.Height * 0.5f), jawScaleMult, Projectile.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 360); + } + } +} diff --git a/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs b/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs index 56c512c9e4..cc6e39ef9c 100644 --- a/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs +++ b/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { Projectile.DamageType = DamageClass.Melee; - Projectile.width = Projectile.height = 8; + Projectile.width = Projectile.height = 80; Projectile.tileCollide = false; Projectile.friendly = true; Projectile.penetrate = -1; diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs index 7a7fc8cb16..68bc6ca463 100644 --- a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs +++ b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Melee public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { float collisionPoint = 0f; - float bladeLength = 100 * Projectile.scale; + float bladeLength = 105 * Projectile.scale; float bladeWidth = 20 * Projectile.scale; return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + (direction * bladeLength), bladeWidth, ref collisionPoint); } @@ -171,7 +171,7 @@ namespace CalamityMod.Projectiles.Melee //Manage position and rotation - Projectile.scale = 1 + Empowerment / maxEmpowerment * 1.5f; + Projectile.scale = 1 + Empowerment / maxEmpowerment * 1.85f; oldDirection = direction; direction = direction.RotatedBy(MathHelper.Clamp(Empowerment * 1.1f / maxEmpowerment, 0.45f, 1f) * MathHelper.PiOver4 * 0.20f); @@ -222,6 +222,8 @@ namespace CalamityMod.Projectiles.Melee modifiers.SourceDamage *= MathHelper.Lerp(1f, TrueBiomeBlade.HolyAttunement_ThrowDamageBoost, Empowerment / maxEmpowerment); else modifiers.SourceDamage *= MathHelper.Lerp(TrueBiomeBlade.HolyAttunement_BaseSwingDamageMult, TrueBiomeBlade.HolyAttunement_FullSwingDamageMult, Empowerment / maxEmpowerment); + + modifiers.HitDirectionOverride = (Owner.Center.X > target.Center.X).ToDirectionInt(); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMonolith.cs b/Projectiles/Melee/MendedBiomeBlade_HeavensMonolith.cs index d2ada56839..8add1114d7 100644 --- a/Projectiles/Melee/MendedBiomeBlade_HeavensMonolith.cs +++ b/Projectiles/Melee/MendedBiomeBlade_HeavensMonolith.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.IO; -using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -48,7 +46,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.timeLeft = 102; Projectile.scale = Scale; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.idStaticNPCHitCooldown = 20; Projectile.hide = true; } diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs index 5b12d990e1..b05763bebb 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs @@ -70,6 +70,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.extraUpdates = 1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs index 1ae29e68d9..966f0d858e 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs @@ -30,9 +30,6 @@ namespace CalamityMod.Projectiles.Melee private Vector2 PowerLungeStart; - public override void SetStaticDefaults() - { - } public override void SetDefaults() { Projectile.DamageType = DamageClass.Melee; @@ -42,6 +39,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.extraUpdates = 1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -138,10 +137,7 @@ namespace CalamityMod.Projectiles.Melee Owner.GiveUniversalIFrames(TrueBiomeBlade.EvilAttunement_SlashIFrames); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(Main.player[Projectile.owner].moonLeech); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(Main.player[Projectile.owner].moonLeech); - - private void OnHitEffects(bool cannotLifesteal) + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (ChargedUp) return; @@ -151,10 +147,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.myPlayer != Owner.whoAmI || CanBounce == 0f) return; - if (!cannotLifesteal) //trolled - { - Owner.HealPlayer(TrueBiomeBlade.EvilAttunement_Lifesteal); //Idk if its too much or what but at the same time its close range as fuck - } + Owner.DoLifestealDirect(target, TrueBiomeBlade.EvilAttunement_Lifesteal); //Idk if its too much or what but at the same time its close range as fuck // Bounce off float bounceStrength = LungeSpeed / 2f; diff --git a/Projectiles/Melee/MendedBiomeBlade_TruePureClarity.cs b/Projectiles/Melee/MendedBiomeBlade_TruePureClarity.cs index 644d52dd2e..73a23e9dfd 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TruePureClarity.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TruePureClarity.cs @@ -6,7 +6,6 @@ using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs b/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs index 56f513e75c..960e66f1fa 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TruePurityProjection.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; diff --git a/Projectiles/Melee/MirrorBladeProjectile.cs b/Projectiles/Melee/MirrorBladeProjectile.cs new file mode 100644 index 0000000000..56cca4d246 --- /dev/null +++ b/Projectiles/Melee/MirrorBladeProjectile.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + + public class MirrorBladeProjectile : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public Player Owner => Main.player[Projectile.owner]; + public override int swingWidth => 200; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 10; + public override int OffsetDistance => 90; + public override bool drawSwordTrail => false; + public override Color[] trailColors => new Color[] { Color.Red, Color.MediumPurple, Color.Purple }; public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + public override bool AlternateSwings => false; + public bool SpawnShards = true; + + public override bool useMeleeSpeed => true; + + public override int swingTime { get; set; } = 8; + + public override SoundStyle? UseSound => SoundID.Item71 with {Volume = 0.9f}; + + public List reflectedProjectiles = new List() { }; + + public override void Defaults() + { + Projectile.extraUpdates = 3; + } + + public override void Spawn() + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 15; + CooldownTime = 15; + swingTime -= StartupTime + CooldownTime; + modplayer.swingNum = (modplayer.swingNum + 1) % 2; + Projectile.timeLeft = 600; + + } + + public override void AdditionalAI() + { + if (inStartup) + { + Projectile.scale = baseScale * MathHelper.Lerp(0.75f, 1f, StartupCompletion); + } + else if (inCooldown) + { + Projectile.Opacity = 1; + Projectile.scale = baseScale * MathHelper.Lerp(1, 0.75f, CooldownCompletion); + } + else + { + Projectile.Opacity = 1; + } + if (!inStartup && !inCooldown) + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.type == ModContent.ProjectileType() && proj.ModProjectile().canDamage && !reflectedProjectiles.Contains(proj.whoAmI)) + { + reflectedProjectiles.Add(proj.whoAmI); + for (var i = 0; i < 3; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), proj.Center, proj.velocity * -1, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact, Projectile.Center); + } + } + else if (proj.Hitbox.Intersects(Projectile.Hitbox) && proj.hostile && !reflectedProjectiles.Contains(proj.whoAmI)) + { + reflectedProjectiles.Add(proj.whoAmI); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), proj.Center, proj.velocity * -1, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact, Projectile.Center); + } + } + + Lighting.AddLight(Main.player[Projectile.owner].Center, 0.96f, 0.91f, 1f); + } + + public override float SwingFunction() + { + if (inStartup) + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.7f, -swingWidth * 0.4f, 1 - MathF.Pow(StartupCompletion, 0.5f))); + if (inCooldown) + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * 0.5f, (360 - swingWidth * 0.4f), MathF.Pow(CooldownCompletion, 0.5f))); + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * .5f, (swingWidth * 0.5f), SwingCompletion)); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + + //Ensures only two shards spawn on enemy hits. If you're wondering why this is needed, turn this off and fight Storm Weaver + if (SpawnShards) + { + for (var i = 0; i < 2; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + + SpawnShards = false; + } + + int slashCreatorID = ModContent.ProjectileType(); + int damage = (int)(Projectile.damage * MirrorBlade.SlashProjectileDamageMultiplier); + float knockback = Projectile.knockBack * MirrorBlade.SlashProjectileDamageMultiplier; + if (Owner.ownedProjectileCounts[slashCreatorID] < MirrorBlade.SlashProjectileLimit) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, slashCreatorID, damage, knockback, Projectile.owner, target.whoAmI, Projectile.rotation, 1f); + Owner.ownedProjectileCounts[slashCreatorID]++; + } + SoundEngine.PlaySound(CommonCalamitySounds.SwiftSliceSound with { Volume = CommonCalamitySounds.SwiftSliceSound.Volume * 0.3f }, Projectile.Center); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact,Projectile.Center); + } + public override float trailOffset => 28; + public override float trailWidth(float completion, Vector2 vertexPos) + { + return 60; + } + public override int trailLength => 40; + public override bool PreDraw(ref Color lightColor) + { + lightColor = Color.White; + return base.PreDraw(ref lightColor); + } + } +} diff --git a/Projectiles/Melee/MirrorBladeProjectile.png b/Projectiles/Melee/MirrorBladeProjectile.png new file mode 100644 index 0000000000..56f94280f2 Binary files /dev/null and b/Projectiles/Melee/MirrorBladeProjectile.png differ diff --git a/Projectiles/Melee/MirrorBladeSlash.cs b/Projectiles/Melee/MirrorBladeSlash.cs new file mode 100644 index 0000000000..12c3e9402e --- /dev/null +++ b/Projectiles/Melee/MirrorBladeSlash.cs @@ -0,0 +1,88 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class MirrorBladeSlash : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + + public override string Texture => "CalamityMod/Projectiles/Melee/ExobeamSlash"; + + public override void SetDefaults() + { + Projectile.width = 24; + Projectile.height = 512; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = 2; + Projectile.Opacity = 1f; + Projectile.timeLeft = 35; + Projectile.MaxUpdates = 2; + Projectile.scale = 0.75f; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.noEnchantmentVisuals = true; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.Opacity = Projectile.timeLeft / 35f; + if (Projectile.timeLeft == 34) + { + Vector2 vel = new Vector2(0.1f, 0.1f).RotatedByRandom(100); + VoidSparkParticle spark2 = new VoidSparkParticle(Projectile.Center, vel, false, 9, Main.rand.NextFloat(0.25f, 0.35f), Main.rand.NextBool() ? Color.Silver : Color.BlueViolet); + GeneralParticleHandler.SpawnParticle(spark2); + + for (int j = -1; j <= 1; j += 2) + { + for (int i = 0; i < 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), vel.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.1f) * Main.rand.NextFloat(2f, 12.5f) * j); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 1.7f); + dust.color = Main.rand.NextBool() ? Color.SteelBlue : Color.BlueViolet; + dust.noLightEmittence = true; + dust.fadeIn = 1; + } + } + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.67f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 120); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(ModContent.BuffType(), 120); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox); + + public override bool ShouldUpdatePosition() => true; + + public override Color? GetAlpha(Color lightColor) => Color.Lerp(Projectile.ai[2] == 0f ? Color.Blue : Color.White, Projectile.ai[2] == 0f ? Color.DarkBlue : Color.White, Projectile.identity / 7f % 1f) * Projectile.Opacity; + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + } +} diff --git a/Projectiles/Melee/MirrorBladeSlashCreator.cs b/Projectiles/Melee/MirrorBladeSlashCreator.cs new file mode 100644 index 0000000000..2766c33bff --- /dev/null +++ b/Projectiles/Melee/MirrorBladeSlashCreator.cs @@ -0,0 +1,60 @@ +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class MirrorBladeSlashCreator : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + + public NPC Target => Main.npc[(int)Projectile.ai[0]]; + + public float SlashDirection + { + get + { + if (Projectile.ai[1] > MathHelper.Pi) + return Main.rand.NextFloatDirection(); + + return Projectile.ai[1] + Main.rand.NextFloatDirection() * 0.2f; + } + } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 2; + Projectile.height = 2; + Projectile.ignoreWater = false; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 36; + Projectile.MaxUpdates = 2; + Projectile.noEnchantmentVisuals = true; + } + + public override void AI() + { + if (Projectile.timeLeft % MirrorBlade.SlashCreationRate == 0) + { + if (Main.myPlayer == Projectile.owner) + { + float maxOffset = Target.width * 0.4f; + if (maxOffset > 300f) + maxOffset = 300f; + + Vector2 spawnOffset = SlashDirection.ToRotationVector2() * Main.rand.NextFloatDirection() * maxOffset; + Vector2 sliceVelocity = spawnOffset.SafeNormalize(Vector2.UnitY) * 0.1f; + + int damage = Projectile.damage; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Target.Center + spawnOffset, sliceVelocity, ModContent.ProjectileType(), damage, 0f, Projectile.owner, 0f, 0f, Projectile.ai[2]); + } + } + } + + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Melee/MirrorBlast.cs b/Projectiles/Melee/MirrorBlast.cs index bcf7c10932..276bc0972a 100644 --- a/Projectiles/Melee/MirrorBlast.cs +++ b/Projectiles/Melee/MirrorBlast.cs @@ -1,6 +1,11 @@ using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -9,55 +14,240 @@ namespace CalamityMod.Projectiles.Melee public class MirrorBlast : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public bool isShard = true; + + public int shardShield = 0; + + public bool isShield => shardShield > 0; + + private bool hasSpawned = false; + + public int shardNum = -1; + + private Player player => Main.player[Projectile.owner]; public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Type] = 10; - ProjectileID.Sets.TrailingMode[Type] = 1; + Main.projFrames[Type] = 3; } public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = 16; + Projectile.height = 16; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 1800; + Projectile.extraUpdates = 0; + Projectile.noEnchantmentVisuals = true; + Projectile.tileCollide = false; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(isShard); + writer.Write(hasSpawned); + writer.Write(shardNum); + writer.Write(shardShield); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + isShard = reader.ReadBoolean(); + hasSpawned = reader.ReadBoolean(); + shardNum = reader.ReadInt32(); + shardShield = reader.ReadInt32(); + } + public override bool? CanDamage() + { + return !isShard; + } + + public override bool? CanHitNPC(NPC target) + { + if (target.Calamity().DR > 0.9f) { + return false; + } + return base.CanHitNPC(target); + } public override void AI() { - int playerOwner = (int)Player.FindClosest(Projectile.Center, 1, 1); - Projectile.ai[1] += 1f; - if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) + player.Calamity().mouseWorldListener = true; + if (!hasSpawned) { - float scaleFactor = Projectile.velocity.Length(); - Vector2 projDirection = Main.player[playerOwner].Center - Projectile.Center; - projDirection.Normalize(); - projDirection *= scaleFactor; - Projectile.velocity = (Projectile.velocity * 24f + projDirection) / 25f; - Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor; + Projectile.netUpdate = true; + if (Projectile.ai[0] != 0) + { + //This is used when spawned by Evolution. + //Setting AP so high guarantees we get the full dmg of the projectile. + Projectile.ArmorPenetration = 1000; + hasSpawned = true; + shardShield = 0; + isShard = false; + Projectile.timeLeft = 1200; + Projectile.velocity = Projectile.DirectionTo(player.Center) * -20f; + Projectile.DamageType = DamageClass.Generic; + Projectile.CritChance = 0; + return; + } + shardNum = player.ownedProjectileCounts[Projectile.type]; + hasSpawned = true; + shardNum = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == Projectile.owner) + { + (proj.ModProjectile as MirrorBlast).shardNum++; + proj.netUpdate = true; + } + } + } + if (isShield) + { + if (shardNum > 10 || Projectile.timeLeft < 2) + { + shardShield = 0; + isShard = false; + Projectile.timeLeft = 1200; + Projectile.velocity = Projectile.DirectionTo(player.Center) * -20f; + Projectile.netUpdate = true; + return; + } + List positions = new List() //Hardcoded positions for the mirror shield shards so we can make it look nice + { + new(0,75), + new(10,65), + new(-10,65), + new(20,75), + new(-20,75), + new(30,65), + new(-30,65), + new(14,55), + new(-14,55), + new(0,45) + }; + Projectile.velocity = Vector2.Zero; + Projectile.Center = Vector2.Lerp(Projectile.Center, + player.Center + player.DirectionTo(player.Calamity().mouseWorld) + .RotatedBy(MathHelper.ToRadians(positions[shardNum - 1].X)) + * positions[shardNum - 1].Y, + 0.5f); + Projectile.rotation = Projectile.DirectionTo(player.Center).ToRotation() + MathHelper.PiOver2; + shardShield--; + } + else if (isShard) + { + Projectile.velocity = Vector2.Zero; + var shardCount = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == Projectile.owner && (proj.ModProjectile as MirrorBlast).isShard) + { + shardCount++; + } + } + Projectile.Center = Vector2.Lerp(Projectile.Center, player.Center + new Vector2(0, MathHelper.Lerp(-90, -110, MathF.Sin(player.miscCounter / 300f * MathHelper.TwoPi + MathHelper.Pi * (shardNum % 2)))).RotatedBy(MathHelper.ToRadians(player.miscCounter / 300f * 360f + 360f / shardCount * shardNum)), 0.15f); + Projectile.rotation = Projectile.DirectionTo(player.Center).ToRotation() + MathHelper.PiOver2; + if (shardNum > 10 || Projectile.timeLeft < 2) + { + isShard = false; + Projectile.timeLeft = 1200; + Projectile.velocity = Projectile.DirectionTo(player.Center) * -20f; + } + } + else + { + float homingStrength = 0.025f; // Adjust this value for stronger or weaker homing + if (Projectile.timeLeft < 1000) + homingStrength *= 2f; + if (Projectile.timeLeft < 800) + homingStrength *= 2f; + if (Projectile.timeLeft < 600) + homingStrength *= 2f; + NPC target = FindClosestNPC(3200f); + if (target != null) + { + Vector2 direction = target.Center - Projectile.Center; + direction.Normalize(); + direction *= 40f; // Adjust speed as needed + Projectile.velocity = Vector2.Lerp(Projectile.velocity, direction, homingStrength); + + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * Main.rand.NextFloat(-0.2f, -0.6f), Color.Black, 7, Main.rand.NextFloat(0.35f, 0.4f), 1f, Main.rand.NextFloat(-0.2f, 0.2f), false); + GeneralParticleHandler.SpawnParticle(smoke); + if (Main.rand.NextBool(5)) + { + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Projectile.velocity, DustID.RainbowTorch); + trailDust.scale = Main.rand.NextFloat(0.7f, 0.85f); + trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.5f); + trailDust.color = Main.rand.NextBool() ? Color.AliceBlue : Color.SkyBlue; + trailDust.noGravity = true; + } + } + Projectile.rotation = Projectile.velocity.ToRotation(); } - if (Projectile.velocity.Length() < 18f) + Lighting.AddLight(Projectile.Center, 0.96f*0.33f, 0.91f*0.33f, 0.33f); + if (Projectile.FinalExtraUpdate()) + Projectile.frameCounter++; + if (Projectile.frameCounter > 8) { - Projectile.velocity *= 1.02f; + Projectile.frame++; + Projectile.frameCounter = 0; } + if (Projectile.frame >= 3) + Projectile.frame = 0; + } - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + public override void OnKill(int timeLeft) + { + if (!isShard) + { + SoundEngine.PlaySound(SoundID.Item27 with {Volume = 0.5f }, Projectile.position); + Particle Star = new CritSpark(Projectile.Center, Vector2.Zero, Color.WhiteSmoke, Color.BlueViolet, Main.rand.NextFloat(1.5f, 1.6f), 10, 0.1f, 3f); + GeneralParticleHandler.SpawnParticle(Star); - Lighting.AddLight(Projectile.Center, 0f, 0.35f, 0.35f); + for (int i = 0; i < 10; i++) + { + int dust = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, DustID.GemDiamond, 0f, 0f, 100, default, 1f); + Main.dust[dust].velocity *= 2f; + Main.dust[dust].noGravity = true; + } + } } public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 295) - return false; - - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + Texture2D BlastTex = ModContent.Request("CalamityMod/Projectiles/Melee/MirrorBlast").Value; + Texture2D ShardTex = ModContent.Request("CalamityMod/Projectiles/Melee/MirrorShard").Value; + Point BlastTextureDim = new Point(60, 26); + Point ShardTextureDim = new Point(32, 14); + Texture2D UsedTex = isShard ? ShardTex : BlastTex; + Point UsedTextureDim = isShard ? ShardTextureDim : BlastTextureDim; + Vector2 origin = isShard ? ShardTextureDim.ToVector2() / 2f : BlastTextureDim.ToVector2() / 2f + new Vector2(14, 0); + Main.spriteBatch.Draw(UsedTex, Projectile.Center - Main.screenPosition, new Rectangle(0, UsedTextureDim.Y * Projectile.frame, UsedTextureDim.X, UsedTextureDim.Y), Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0f); return false; } + + private NPC FindClosestNPC(float maxRange) + { + NPC closestNPC = null; + float closestDistance = maxRange; + + foreach (NPC npc in Main.npc) + { + if (npc.CanBeChasedBy(this) && !npc.friendly) + { + float distance = Vector2.Distance(Projectile.Center, npc.Center); + if (distance < closestDistance) + { + closestDistance = distance; + closestNPC = npc; + } + } + } + + return closestNPC; + } } } diff --git a/Projectiles/Melee/MirrorBlast.png b/Projectiles/Melee/MirrorBlast.png index ae7a902f9a..07a4720957 100644 Binary files a/Projectiles/Melee/MirrorBlast.png and b/Projectiles/Melee/MirrorBlast.png differ diff --git a/Projectiles/Melee/MirrorShard.png b/Projectiles/Melee/MirrorShard.png new file mode 100644 index 0000000000..926658fff7 Binary files /dev/null and b/Projectiles/Melee/MirrorShard.png differ diff --git a/Projectiles/Melee/MonstrousKnife.cs b/Projectiles/Melee/MonstrousKnife.cs index 41b96a3f76..7cfb2d2d45 100644 --- a/Projectiles/Melee/MonstrousKnife.cs +++ b/Projectiles/Melee/MonstrousKnife.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Balancing; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -47,28 +45,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - int heal = (int)Math.Round(hit.Damage * Main.rand.NextFloat(0.05f, 0.1f)); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - int heal = (int)Math.Round(info.Damage * Main.rand.NextFloat(0.05f, 0.1f)); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, 1, 3f); } } diff --git a/Projectiles/Melee/MourningstarFlail.cs b/Projectiles/Melee/MourningstarFlail.cs index 147a4d209c..37ca8c6209 100644 --- a/Projectiles/Melee/MourningstarFlail.cs +++ b/Projectiles/Melee/MourningstarFlail.cs @@ -6,7 +6,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class MourningstarFlail : BaseWhipProjectile, ILocalizedModType + public class MourningstarFlail : BaseFlailProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public override void SetDefaults() diff --git a/Projectiles/Melee/MurasamaSlash.cs b/Projectiles/Melee/MurasamaSlash.cs index 8cf521594d..fea77fab78 100644 --- a/Projectiles/Melee/MurasamaSlash.cs +++ b/Projectiles/Melee/MurasamaSlash.cs @@ -1,18 +1,17 @@ using System; -using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; -using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class MurasamaSlash : ModProjectile, ILocalizedModType { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); @@ -154,9 +153,9 @@ namespace CalamityMod.Projectiles.Melee public void HandleChannelMovement(Player player, Vector2 playerRotatedPoint) { float speed = 1f; - if (player.ActiveItem().shoot == Projectile.type) + if (player.HeldItem.shoot == Projectile.type) { - speed = player.ActiveItem().shootSpeed * Projectile.scale; + speed = player.HeldItem.shootSpeed * Projectile.scale; } // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed; @@ -171,12 +170,15 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity = newVelocity; } } - public override void ModifyDamageHitbox(ref Rectangle hitbox) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { - int size = 60; - if (Slash3) - hitbox.Inflate(size, size); + Vector2 lineEnd = Main.player[Projectile.owner].Center + Projectile.velocity * (Slash3 ? 11.35f : 8.6f); + // The slash sprite is top-heavy, so make the width lean in a direction + float lineWidth = (Projectile.direction == 1 && projHitbox.Center.X > targetHitbox.Center.X) || (Projectile.direction == -1 && projHitbox.Center.X < targetHitbox.Center.X) ? 320f : 200f; + float _ = 0f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Main.player[Projectile.owner].Center, lineEnd, lineWidth, ref _); } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (target.Organic()) diff --git a/Projectiles/Melee/Nebudust.cs b/Projectiles/Melee/Nebudust.cs index 4d74002b3b..de66badf41 100644 --- a/Projectiles/Melee/Nebudust.cs +++ b/Projectiles/Melee/Nebudust.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Melee/NebulashFlail.cs b/Projectiles/Melee/NebulashFlail.cs index 04c51a2b4f..fd779d8c56 100644 --- a/Projectiles/Melee/NebulashFlail.cs +++ b/Projectiles/Melee/NebulashFlail.cs @@ -7,7 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class NebulashFlail : BaseWhipProjectile, ILocalizedModType + public class NebulashFlail : BaseFlailProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public override void SetDefaults() @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 2; + Projectile.localNPCHitCooldown = 6; } public override Color SpecialDrawColor => new(255, 200, 0); public override int ExudeDustType => ModContent.DustType(); diff --git a/Projectiles/Melee/NeptunesBountyProjectile.cs b/Projectiles/Melee/NeptunesBountyProjectile.cs index 5c9268ace4..3dbec4a60a 100644 --- a/Projectiles/Melee/NeptunesBountyProjectile.cs +++ b/Projectiles/Melee/NeptunesBountyProjectile.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatBuffs; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -11,7 +10,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Melee @@ -133,7 +131,7 @@ namespace CalamityMod.Projectiles.Melee { Projectile.extraUpdates = 3; - SoundEngine.PlaySound(new("CalamityMod/Sounds/Item/VividClarityBeamAppear") { Volume = 0.65f, PitchVariance = 0.3f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/VividClarityBeamAppear") { Volume = 0.65f, PitchVariance = 0.3f }, Projectile.Center); SoundEngine.PlaySound(SoundID.ShimmerWeak1 with { Pitch = 0.15f }, Projectile.Center); Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Aqua, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 0.01f, 0.9f, 22); @@ -275,7 +273,7 @@ namespace CalamityMod.Projectiles.Melee SoundStyle HitSound2 = new("CalamityMod/Sounds/Item/HellkiteSmallHit", 3) { Volume = 0.45f, Pitch = 0.2f }; SoundEngine.PlaySound(HitSound2, Projectile.Center); - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/SwiftSlice") { Volume = 0.65f, Pitch = -0.3f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") { Volume = 0.65f, Pitch = -0.3f }, Projectile.Center); } } diff --git a/Projectiles/Melee/NeptunesBountySplitProjectile.cs b/Projectiles/Melee/NeptunesBountySplitProjectile.cs index 439bf42e1c..3d3d52b371 100644 --- a/Projectiles/Melee/NeptunesBountySplitProjectile.cs +++ b/Projectiles/Melee/NeptunesBountySplitProjectile.cs @@ -1,13 +1,7 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; -using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/OldLordClaymoreHoldout.cs b/Projectiles/Melee/OldLordClaymoreHoldout.cs index d2b6619595..e84665578a 100644 --- a/Projectiles/Melee/OldLordClaymoreHoldout.cs +++ b/Projectiles/Melee/OldLordClaymoreHoldout.cs @@ -1,7 +1,7 @@ using System; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -9,13 +9,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class OldLordClaymoreHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -217,11 +217,9 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits == 0) { - Owner.Calamity().GeneralScreenShakePower = 5f; - + Owner.SetScreenshake(5f); SoundStyle swing = new("CalamityMod/Sounds/Item/DemonSwordStrongImpact"); SoundEngine.PlaySound(swing with { Volume = 0.95f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center); - } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) @@ -237,6 +235,7 @@ namespace CalamityMod.Projectiles.Melee if ((useAnim > 0 || DrawUnconditionally) && Owner.ItemAnimationActive) { Asset tex = ModContent.Request(Texture); + Asset glowTex = ModContent.Request("CalamityMod/Items/Weapons/Melee/OldLordClaymoreGlow"); Asset swoosh = ModContent.Request("CalamityMod/Particles/VerticalSmearLarge"); float r = FlipAsSword ? MathHelper.ToRadians(90) : 0f; @@ -253,6 +252,7 @@ namespace CalamityMod.Projectiles.Melee Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); + Main.EntitySpriteDraw(glowTex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), glowTex.Frame(1, FrameCount, 0, Frame), Color.White, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(glowTex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); } return false; } diff --git a/Projectiles/Melee/OmnibladeSwing.cs b/Projectiles/Melee/OmnibladeSwing.cs index d7bb4b4043..8e9ef1d4ae 100644 --- a/Projectiles/Melee/OmnibladeSwing.cs +++ b/Projectiles/Melee/OmnibladeSwing.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Localization; @@ -7,6 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class OmnibladeSwing : ModProjectile, ILocalizedModType { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); diff --git a/Projectiles/Melee/OrderbringerBeam.cs b/Projectiles/Melee/OrderbringerBeam.cs index ea5a3dc017..2fc3736a21 100644 --- a/Projectiles/Melee/OrderbringerBeam.cs +++ b/Projectiles/Melee/OrderbringerBeam.cs @@ -1,9 +1,7 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -30,7 +28,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.extraUpdates = 6; + Projectile.extraUpdates = 40; Projectile.timeLeft = 180; Projectile.DamageType = DamageClass.Melee; Projectile.usesLocalNPCImmunity = true; @@ -39,17 +37,16 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - if (time == 0) - { - mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; - } + Player player = Main.player[Projectile.owner]; + mainColor = player.Calamity().lightRGB; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - if (Projectile.timeLeft % 3 == 0 && targetDist < 1400f) + if (Projectile.timeLeft % 12 == 0 && targetDist < 1400f) { - Particle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 3, -Projectile.velocity * 0.05f, false, 17, 1.5f, mainColor * 0.7f); + Particle spark = new CustomSpark(Projectile.Center, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 23, 0.25f, mainColor * 0.75f, new Vector2(1f, 7.35f), true, true, shrinkSpeed: 0.2f, glowOpacity: 0.7f); GeneralParticleHandler.SpawnParticle(spark); } time++; @@ -62,7 +59,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); if (Projectile.numHits < 1) { Particle orb = new GlowSparkParticle(target.Center, Projectile.velocity.SafeNormalize(Vector2.UnitY), false, 12, 0.07f, mainColor, new Vector2(1.5f, 0.8f), true); diff --git a/Projectiles/Melee/OrderbringerWaveProj.cs b/Projectiles/Melee/OrderbringerWaveProj.cs index d38407612a..c75a37a4ae 100644 --- a/Projectiles/Melee/OrderbringerWaveProj.cs +++ b/Projectiles/Melee/OrderbringerWaveProj.cs @@ -1,14 +1,11 @@ using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using CalamityMod.Particles; -using Terraria.ModLoader; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework.Graphics; -using System.ComponentModel; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -32,21 +29,23 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; Projectile.timeLeft = 450; Projectile.DamageType = DamageClass.Melee; - Projectile.extraUpdates = 10; + Projectile.extraUpdates = 22; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } public override void AI() { - Vector2 topCorner = Projectile.Center + (Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(100f)) * Projectile.scale) * 157; - Vector2 bottomCorner = Projectile.Center + (Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(-100f)) * Projectile.scale) * 157; + Vector2 topCorner = Projectile.Center + (Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(125f)) * Projectile.scale) * 190; + Vector2 bottomCorner = Projectile.Center + (Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(-125f)) * Projectile.scale) * 190; + + Player player = Main.player[Projectile.owner]; + mainColor = player.Calamity().lightRGB; if (time == 0) { Projectile.scale = 0.0875f; - Projectile.velocity *= 0.9f; - mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; + Projectile.velocity *= 1.25f; } Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; @@ -67,19 +66,20 @@ namespace CalamityMod.Projectiles.Melee { if (Main.rand.NextBool(3)) { - Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(hitboxSize, hitboxSize) - Projectile.velocity * 2, 66); - trailDust.scale = Main.rand.NextFloat(0.7f, 0.85f) - (time < 150 ? 0 : time * 0.001f); + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(hitboxSize * 1.25f, hitboxSize * 1.25f) - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 25, ModContent.DustType()); + trailDust.scale = Main.rand.NextFloat(1.6f, 1.95f) - (time < 150 ? 0 : time * 0.001f); trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.85f, 1.5f); - trailDust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; + trailDust.color = mainColor; trailDust.noGravity = true; + trailDust.fadeIn = 2f; } - if (time % 9 == 0) + if (time % 9 == 0 && time < 200) { - Particle orb = new GlowSparkParticle(topCorner, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(170f)), false, 15, Main.rand.NextFloat(0.03f, 0.055f) * Utils.GetLerpValue(250, 150, time, true), mainColor, new Vector2(1, 0.8f), true, false, 0.3f); - GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GlowSparkParticle(bottomCorner, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(-170f)), false, 15, Main.rand.NextFloat(0.03f, 0.055f) * Utils.GetLerpValue(250, 150, time, true), mainColor, new Vector2(1, 0.8f), true, false, 0.3f); - GeneralParticleHandler.SpawnParticle(orb2); + Particle spark = new CustomSpark(topCorner, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(-170f)), "CalamityMod/Particles/BloomCircle", false, 18, 0.35f, mainColor * 0.75f, new Vector2(1f, 2.5f), true, true, shrinkSpeed: 0.2f, glowOpacity: 0.7f); + GeneralParticleHandler.SpawnParticle(spark); + Particle spark2 = new CustomSpark(bottomCorner, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.ToRadians(170f)), "CalamityMod/Particles/BloomCircle", false, 18, 0.35f, mainColor * 0.75f, new Vector2(1f, 2.5f), true, true, shrinkSpeed: 0.2f, glowOpacity: 0.7f); + GeneralParticleHandler.SpawnParticle(spark2); } if (Main.rand.NextBool(12)) { @@ -90,25 +90,22 @@ namespace CalamityMod.Projectiles.Melee } } - fadeOut = Utils.GetLerpValue(0, 180, Projectile.timeLeft, true); - time++; } public override bool PreDraw(ref Color lightColor) { Texture2D tex = ModContent.Request(Texture).Value; - float waveFade = Utils.GetLerpValue(0, 300, Projectile.timeLeft); - for (int i = 1; i < 6; i++) // Weird for loop because of squash code - Main.spriteBatch.Draw(tex, Projectile.Center - Main.screenPosition, null, mainColor with { A = 0 } * fadeOut, Projectile.rotation, tex.Size() / 2f, new Vector2(1 - (i * 0.2f * waveFade), 1 + (i * 0.35f * waveFade)) * Projectile.scale * 1.1f, SpriteEffects.None, 0); + float waveFade = (float)Math.Pow(Utils.GetLerpValue(0, 250, Projectile.timeLeft, true), 2); + float waveFade2 = (float)Math.Pow(Utils.GetLerpValue(0, 80, Projectile.timeLeft, true), 2); + for (int i = 1; i < 15; i++) // Weird for loop because of squash code + Main.spriteBatch.Draw(tex, Projectile.Center - Main.screenPosition - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6f * i, null, mainColor with { A = 0 } * waveFade * (1 - 0.1f * i), Projectile.rotation, tex.Size() / 2f, new Vector2(1.1f * MathHelper.Lerp(waveFade2, 1, 0.3f), 0.6f + (1 - waveFade) * 0.8f) * Projectile.scale * 1.1f, SpriteEffects.None, 0); return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 300); - if (damageMult < 1.3f && damageDone > 2) - damageMult += 0.325f; + target.AddBuff(ModContent.BuffType(), 300); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) diff --git a/Projectiles/Melee/PhotonRipperProjectile.cs b/Projectiles/Melee/PhotonRipperProjectile.cs index d587a822c6..7df5d407e1 100644 --- a/Projectiles/Melee/PhotonRipperProjectile.cs +++ b/Projectiles/Melee/PhotonRipperProjectile.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,6 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class PhotonRipperProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; @@ -59,7 +61,7 @@ namespace CalamityMod.Projectiles.Melee { // Recalculate damage every frame for balance reasons, as this is a long-lasting holdout. // This is important because you could start using it while benefitting from Auric Tesla standstill bonus, for example. - Projectile.damage = Owner.ActiveItem() is null ? 0 : Owner.GetWeaponDamage(Owner.ActiveItem()); + Projectile.damage = Owner.HeldItem is null ? 0 : Owner.GetWeaponDamage(Owner.HeldItem); DetermineDamage(); PlayChainsawSounds(); @@ -194,7 +196,7 @@ namespace CalamityMod.Projectiles.Melee // spawn too far from the blade. spawnPosition += Main.rand.NextVector2CircularEdge(9f, 35f).RotatedBy(Projectile.velocity.ToRotation() + MathHelper.PiOver2); - Dust rainbowSpark = Dust.NewDustPerfect(spawnPosition, 261); + Dust rainbowSpark = Dust.NewDustPerfect(spawnPosition, DustID.AncientLight); rainbowSpark.velocity = Projectile.velocity * 3f + Main.rand.NextVector2CircularEdge(1.5f, 1.5f); rainbowSpark.noGravity = true; rainbowSpark.color = Main.hslToRgb((Time / 40f + Main.rand.NextFloat(-0.1f, 0.1f)) % 1f, 0.95f, 0.8f); @@ -215,7 +217,7 @@ namespace CalamityMod.Projectiles.Melee // Incorporate item shoot speed into the range of the crystals. // This means that projectile speed boosts will improve the range of the chainsaw. - shootReach *= Owner.ActiveItem().shootSpeed; + shootReach *= Owner.HeldItem.shootSpeed; // 15NOV2024: Ozzatron: clamped mouse position unnecessary, the result is separately capped float distanceFromMouse = Owner.Distance(Main.MouseWorld); diff --git a/Projectiles/Melee/PrismTooth.cs b/Projectiles/Melee/PrismTooth.cs index 6f9361c6a7..acc4f019cc 100644 --- a/Projectiles/Melee/PrismTooth.cs +++ b/Projectiles/Melee/PrismTooth.cs @@ -4,7 +4,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent.Achievements; @@ -122,9 +121,9 @@ namespace CalamityMod.Projectiles.Melee public override Color? GetAlpha(Color lightColor) => Color.White; - internal float WidthFunction(float completionRatio) => (Projectile.scale * 24f * (1f - Utils.GetLerpValue(0.7f, 1f, completionRatio, true)) + 1f); + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (Projectile.scale * 24f * (1f - Utils.GetLerpValue(0.7f, 1f, completionRatio, true)) + 1f); - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float hue = (Projectile.identity % 9f / 9f + completionRatio * 0.7f) % 1f; return Color.Lerp(Color.White, Main.hslToRgb(hue, 0.95f, 0.55f), 0.35f) * Projectile.Opacity; @@ -149,7 +148,7 @@ namespace CalamityMod.Projectiles.Melee int numPointsRendered = 22; int numPointsProvided = 80; var positionsToUse = Projectile.oldPos.Take(numPointsProvided).ToArray(); - PrimitiveRenderer.RenderTrail(positionsToUse, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"], smoothen: false), numPointsRendered); + PrimitiveRenderer.RenderTrail(positionsToUse, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"], smoothen: false), numPointsRendered); Main.spriteBatch.ExitShaderRegion(); return true; } diff --git a/Projectiles/Melee/PrismaticBeam.cs b/Projectiles/Melee/PrismaticBeam.cs index 0917e7db63..a3dcbd83e6 100644 --- a/Projectiles/Melee/PrismaticBeam.cs +++ b/Projectiles/Melee/PrismaticBeam.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Melee public override float DetermineLaserLength() { - return DetermineLaserLength_CollideWithTiles(5); + return DetermineLaserLength_CollideWithTiles(); } public override bool PreAI() diff --git a/Projectiles/Melee/PrismaticBreakerHoldout.cs b/Projectiles/Melee/PrismaticBreakerHoldout.cs index 7b0dc48d71..fb6c9c15e7 100644 --- a/Projectiles/Melee/PrismaticBreakerHoldout.cs +++ b/Projectiles/Melee/PrismaticBreakerHoldout.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Melee { StarTimer = 0f; SoundEngine.PlaySound(SoundID.Item43 with { Volume = 0.6f }, Projectile.Center); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 3; i++) { float clampedChargeTime = MathHelper.Clamp(Timer / LaserChargeTime, 0f, 1f); float starOffset = MathHelper.Lerp(MathHelper.Pi / 6f, 0f, clampedChargeTime); diff --git a/Projectiles/Melee/PrismaticMagicCircle.cs b/Projectiles/Melee/PrismaticMagicCircle.cs index 760f51b0de..108b2e440d 100644 --- a/Projectiles/Melee/PrismaticMagicCircle.cs +++ b/Projectiles/Melee/PrismaticMagicCircle.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; @@ -75,10 +74,8 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExoVortex"].Apply(); for (int i = 0; i < 6; i++) - { - Color portalColor = Color.Lerp(Main.DiscoColor, Color.White, (float)Math.Abs(Math.Sin(Main.GlobalTimeWrappedHourly * 2f))); Main.spriteBatch.Draw(howNoisy, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, howNoisy.Size() / 2f, squishScale, SpriteEffects.None, 0f); - } + Main.spriteBatch.ExitShaderRegion(); return false; } diff --git a/Projectiles/Melee/PrismaticRay.cs b/Projectiles/Melee/PrismaticRay.cs index c10c472e13..9a7efa8c1a 100644 --- a/Projectiles/Melee/PrismaticRay.cs +++ b/Projectiles/Melee/PrismaticRay.cs @@ -1,11 +1,10 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; -using CalamityMod.Particles; +using CalamityMod.NPCs; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using Steamworks; using System.Collections.Generic; using Terraria; using Terraria.Audio; @@ -15,6 +14,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class PrismaticRay : BaseLaserbeamProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; Projectile.timeLeft = 360; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; + Projectile.localNPCHitCooldown = 9; Projectile.hide = true; } @@ -83,9 +83,7 @@ namespace CalamityMod.Projectiles.Melee public override void ExtraBehavior() { Projectile.rotation = Projectile.velocity.ToRotation(); - - if (Owner.Calamity().GeneralScreenShakePower < 3f) - Owner.Calamity().GeneralScreenShakePower = 3f; + Owner.SetScreenshake(3f); if (HitSoundCooldown > 0) HitSoundCooldown--; @@ -98,13 +96,13 @@ namespace CalamityMod.Projectiles.Melee if (HitSoundCooldown == 0) { SoundEngine.PlaySound(HitSound, target.Center); - HitSoundCooldown = 10; + HitSoundCooldown = 9; } } - public float LaserWidthFunction(float _) => Projectile.scale * Projectile.width; - public Color LaserColorFunction(float completionRatio) => Main.DiscoColor; + public float LaserWidthFunction(float _, Vector2 vertexPos) => Projectile.scale * Projectile.width; + public Color LaserColorFunction(float completionRatio, Vector2 vertexPos) => Main.DiscoColor; public override bool PreDraw(ref Color lightColor) { // This should never happen, but just in case... diff --git a/Projectiles/Melee/PrismaticWave.cs b/Projectiles/Melee/PrismaticWave.cs index 98dec241ce..05121e430c 100644 --- a/Projectiles/Melee/PrismaticWave.cs +++ b/Projectiles/Melee/PrismaticWave.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Melee/PwnagehammerExplosionBig.cs b/Projectiles/Melee/PwnagehammerExplosionBig.cs index e31a3d8e10..d7f7c634dc 100644 --- a/Projectiles/Melee/PwnagehammerExplosionBig.cs +++ b/Projectiles/Melee/PwnagehammerExplosionBig.cs @@ -1,10 +1,5 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/PwnagehammerProj.cs b/Projectiles/Melee/PwnagehammerProj.cs index 3f656010c7..20ae6c52e5 100644 --- a/Projectiles/Melee/PwnagehammerProj.cs +++ b/Projectiles/Melee/PwnagehammerProj.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Melee float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(9f, 0).RotatedBy(rot); Vector2 velOffset = new Vector2(6f, 0).RotatedBy(rot); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 269, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.Sandnado, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = true; dust.velocity = velOffset; dust.scale = 2.5f; @@ -92,7 +92,8 @@ namespace CalamityMod.Projectiles.Melee else SoundEngine.PlaySound(UseSound with { Pitch = EmpoweredHammer * 0.1f - 0.2f }, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 0f, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 0f, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f); return false; } diff --git a/Projectiles/Melee/RSSolarFlare.cs b/Projectiles/Melee/RSSolarFlare.cs index e3515eca78..2c7d895665 100644 --- a/Projectiles/Melee/RSSolarFlare.cs +++ b/Projectiles/Melee/RSSolarFlare.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Melee/RedtideWhirlpool.cs b/Projectiles/Melee/RedtideWhirlpool.cs index 0b983a87b8..aca73d5124 100644 --- a/Projectiles/Melee/RedtideWhirlpool.cs +++ b/Projectiles/Melee/RedtideWhirlpool.cs @@ -14,10 +14,15 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; public Player Owner => Main.player[Projectile.owner]; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + public override void SetDefaults() { - Projectile.width = 60; - Projectile.height = 60; + Projectile.width = Projectile.height = 60; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.ignoreWater = true; @@ -39,32 +44,32 @@ namespace CalamityMod.Projectiles.Melee { float angle = i / (float)dustCount * MathHelper.TwoPi + offset; Vector2 dustPos = Projectile.Center + angle.ToRotationVector2() * 46f; - Dust dust = Dust.NewDustPerfect(dustPos, 176, (angle - MathHelper.PiOver2 * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 8f + Projectile.velocity, Scale: Main.rand.NextFloat(1.6f, 3f)); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.BubbleBurst_Blue, (angle - MathHelper.PiOver2 * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 8f + Projectile.velocity, Scale: Main.rand.NextFloat(1.6f, 3f)); dust.noGravity = true; } - - Vector2 trailOffset = Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(40f, 48f); - Dust trail = Dust.NewDustPerfect(Projectile.Center + trailOffset, 176, Main.rand.NextVector2Circular(0.2f, 0.2f)); - trail.noGravity = true; - trail.scale = Main.rand.NextFloat(0.8f, 3f); - trail.alpha = Main.rand.Next(120, 180 + 1); - trail = Dust.NewDustPerfect(Projectile.Center - trailOffset, 176, Main.rand.NextVector2Circular(0.2f, 0.2f)); - trail.noGravity = true; - trail.scale = Main.rand.NextFloat(0.8f, 3f); - trail.alpha = Main.rand.Next(120, 180 + 1); } public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - SpriteEffects flip = Math.Sign(Projectile.velocity.X) < 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor * 0.3f, Projectile.rotation * 1.2f, texture.Size() * 0.5f, 1.2f, flip); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor * 0.4f, Projectile.rotation, texture.Size() * 0.5f, 1.6f, flip); - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor * 0.3f, Projectile.rotation * 1.2f, texture.Size() / 2f, 1.5f, flip, 0); - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor * 0.4f, Projectile.rotation, texture.Size() / 2f, 2f, flip, 0); - + // Custom afterimage + for (int i = 1; i < Projectile.oldPos.Length; i++) + { + float afterimageRot = Projectile.oldRot[i]; + Vector2 drawPos = Projectile.oldPos[i] + texture.Size() * 0.5f - Main.screenPosition; + float intensity = MathHelper.Lerp(0.01f, 0.1f, 1f - i / (float)Projectile.oldPos.Length); + + Main.EntitySpriteDraw(texture, drawPos, null, lightColor * intensity, afterimageRot, texture.Size() * 0.5f, 1.6f, flip); + } return false; } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 56f, targetHitbox); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override void OnKill(int timeLeft) @@ -77,7 +82,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 offset = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; offset = offset.RotatedBy(((i - (dustCount / 2 - 1)) * MathHelper.TwoPi / (float)dustCount), default) + Projectile.Center; Vector2 dustDirection = offset - Projectile.Center; - Dust dust = Dust.NewDustPerfect(offset + dustDirection, 172, Vector2.Zero, 100, default, 1.4f); + Dust dust = Dust.NewDustPerfect(offset + dustDirection, DustID.DungeonWater, Vector2.Zero, 100, default, 1.4f); dust.noGravity = true; dust.noLight = true; dust.velocity = dustDirection; diff --git a/Projectiles/Melee/RemsRevengeExplosion.cs b/Projectiles/Melee/RemsRevengeExplosion.cs index 2a44122aa2..9b13c24d12 100644 --- a/Projectiles/Melee/RemsRevengeExplosion.cs +++ b/Projectiles/Melee/RemsRevengeExplosion.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Melee if (Time == 0f) { // Makeshift metal-blood explosion sound that is good enough ig - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/Ravager/RavagerStomp", 2) { Pitch = -0.75f, PitchVariance = 0.5f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/Ravager/RavagerStomp", 2) { Pitch = -0.75f, PitchVariance = 0.5f }, Projectile.Center); for (int i = 0; i < 5; i++) { diff --git a/Projectiles/Melee/RendingNeedle.cs b/Projectiles/Melee/RendingNeedle.cs index 6c4ad50df0..54a9452577 100644 --- a/Projectiles/Melee/RendingNeedle.cs +++ b/Projectiles/Melee/RendingNeedle.cs @@ -34,6 +34,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.timeLeft = (int)MaxTime; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -70,7 +72,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.Kill(); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeToEnd = MathHelper.Lerp(0.65f, 1f, (float)Math.Cos(-Main.GlobalTimeWrappedHourly * 3f) * 0.5f + 0.5f); float fadeOpacity = Utils.GetLerpValue(1f, 0.64f, completionRatio, true) * Projectile.Opacity; @@ -79,13 +81,13 @@ namespace CalamityMod.Projectiles.Melee return Color.Lerp(Color.White, endColor, fadeToEnd) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float expansionCompletion = (float)Math.Pow(1 - completionRatio, 2); return MathHelper.Lerp(0f, 14f * Projectile.scale, expansionCompletion); } - public Vector2 OffsetFunction(float completionRatio) => Projectile.Size * 0.5f - Utils.SafeNormalize(Projectile.velocity, Vector2.Zero) * 30.5f; + public Vector2 OffsetFunction(float completionRatio, Vector2 vertexPos) => Projectile.Size * 0.5f - Utils.SafeNormalize(Projectile.velocity, Vector2.Zero) * 30.5f; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/RespiteblockBlood.cs b/Projectiles/Melee/RespiteblockBlood.cs index 5cee5c6c73..a180ac1cc7 100644 --- a/Projectiles/Melee/RespiteblockBlood.cs +++ b/Projectiles/Melee/RespiteblockBlood.cs @@ -1,9 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using SteelSeries.GameSense; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { diff --git a/Projectiles/Melee/RespiteblockHoldout.cs b/Projectiles/Melee/RespiteblockHoldout.cs index 5e691dfb7b..47bff0a112 100644 --- a/Projectiles/Melee/RespiteblockHoldout.cs +++ b/Projectiles/Melee/RespiteblockHoldout.cs @@ -1,17 +1,17 @@ using System; -using CalamityMod.Enums; -using CalamityMod.Particles; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.GameContent.Achievements; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class RespiteblockHoldout : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Melee { // Recalculate damage every frame for balance reasons, as this is a long-lasting holdout. // This is important because you could start using it while benefitting from Auric Tesla standstill bonus, for example. - Projectile.damage = Owner.ActiveItem() is null ? 0 : Owner.GetWeaponDamage(Owner.ActiveItem()); + Projectile.damage = Owner.HeldItem is null ? 0 : Owner.GetWeaponDamage(Owner.HeldItem); PlayChainsawSounds(); @@ -104,20 +104,14 @@ namespace CalamityMod.Projectiles.Melee Particle blood = new PointParticle(spawnPos, (Projectile.velocity * 30).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.2f, 0.9f) + new Vector2(0, Main.rand.NextFloat(-7, -2 + 1)), true, 25, Main.rand.NextFloat(0.7f, 1.2f), (Main.rand.NextBool() ? Color.Green : Color.Purple) * 0.5f, false); GeneralParticleHandler.SpawnParticle(blood); - Dust dust = Dust.NewDustPerfect(spawnPos, 263, (Projectile.velocity * 50).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.05f, 0.9f), 0, default, Main.rand.NextFloat(0.6f, 0.95f)); + Dust dust = Dust.NewDustPerfect(spawnPos, DustID.PortalBolt, (Projectile.velocity * 50).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.05f, 0.9f), 0, default, Main.rand.NextFloat(0.6f, 0.95f)); dust.noGravity = true; dust.color = Color.White; } SoundStyle fire = new("CalamityMod/Sounds/Item/WulfrumKnifeTileHit", 2); SoundEngine.PlaySound(fire with { Volume = 0.55f, Pitch = 0.3f }, Projectile.Center); - - if (player.moonLeech || player.lifeSteal <= 0f || target.lifeMax <= 5) - return; - - int heal = Main.rand.NextBool(4) ? 2 : 1; - player.lifeSteal -= heal; - player.HealPlayer(heal); + player.DoLifestealDirect(target, Main.rand.NextBool(4) ? 2 : 1, 0.75f); } public void PlayChainsawSounds() diff --git a/Projectiles/Melee/RiptideWave.cs b/Projectiles/Melee/RiptideWave.cs index 6c7f6f9f13..3e80596056 100644 --- a/Projectiles/Melee/RiptideWave.cs +++ b/Projectiles/Melee/RiptideWave.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; @@ -12,7 +11,8 @@ namespace CalamityMod.Projectiles.Melee public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public const int Lifetime = 30; - public const int MaxSize = 176; + + public float RotationDirection = 1f; public override void SetDefaults() { @@ -25,13 +25,18 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.aiStyle = -1; } public override void AI() { - // Constantly stay on top of the yoyo. + Projectile.rotation += MathHelper.Lerp(0.3f, 0f, Projectile.timeLeft / (float)Lifetime) * RotationDirection; + + float MaxSize = 135f * Projectile.ai[1]; + + // Stay on top of the yoyo. if (Main.projectile[(int)Projectile.ai[0]].active) - Projectile.Center = Main.projectile[(int)Projectile.ai[0]].Center + Main.projectile[(int)Projectile.ai[0]].velocity; + Projectile.Center = Vector2.Lerp(Projectile.Center, Main.projectile[(int)Projectile.ai[0]].Center + Main.projectile[(int)Projectile.ai[0]].velocity, 0.2f); // Expand the hitbox as lifespan goes on. int waveSize = (int)MathHelper.Lerp(MaxSize, 16, Projectile.timeLeft / (float)Lifetime); @@ -39,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee // Fade out. if (Projectile.timeLeft <= 20) - Projectile.alpha += 12; + Projectile.alpha += (int)(12 * Projectile.ai[1]); } // Ensure knockback is always applied away from the player. @@ -47,19 +52,18 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - Main.spriteBatch.SetBlendState(BlendState.Additive); - Texture2D waveTex = ModContent.Request("CalamityMod/Particles/SeaFoam").Value; Rectangle frame = waveTex.Frame(1, 3, 0, (int)Projectile.ai[2]); - Color waveColor = new Color(61, 119, 148) * Projectile.Opacity; + Color Col = Color.Lerp(Color.DarkSlateBlue, Color.DeepSkyBlue, Projectile.ai[1]); + Color waveColor = Lighting.GetColor((Projectile.Center / 16).ToPoint()).MultiplyRGBA(Color.Lerp(Color.Transparent, Col, Projectile.Opacity).MultiplyRGBA(new Color(1f, 1f, 1f, 0f))); float waveScale = Projectile.width / (float)waveTex.Width; - Main.EntitySpriteDraw(waveTex, Projectile.Center - Main.screenPosition, frame, waveColor, Projectile.ai[1], frame.Size() / 2f, waveScale, SpriteEffects.None); + Main.EntitySpriteDraw(waveTex, Projectile.Center - Main.screenPosition, frame, waveColor, Projectile.rotation, frame.Size() / 2f, waveScale, SpriteEffects.None); + Color ringColor = Lighting.GetColor((Projectile.Center / 16).ToPoint()).MultiplyRGBA(Color.Lerp(Color.Transparent, Col.MultiplyRGBA(new Color(0.6f, 0.8f, 1f, 0f)), Projectile.Opacity)); Texture2D ringTex = ModContent.Request("CalamityMod/Particles/HollowCircleSoftEdge").Value; float ringScale = Projectile.width / (float)ringTex.Width; - Main.EntitySpriteDraw(ringTex, Projectile.Center - Main.screenPosition, null, waveColor, 0f, ringTex.Size() / 2f, ringScale, SpriteEffects.None); + Main.EntitySpriteDraw(ringTex, Projectile.Center - Main.screenPosition, null, ringColor, Projectile.rotation, ringTex.Size() / 2f, ringScale, SpriteEffects.None); - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } } diff --git a/Projectiles/Melee/SaharaSlicersBlade.png b/Projectiles/Melee/SaharaSlicersBlade.png index d3667f574b..abf539a5d6 100644 Binary files a/Projectiles/Melee/SaharaSlicersBlade.png and b/Projectiles/Melee/SaharaSlicersBlade.png differ diff --git a/Projectiles/Melee/SaharaSlicersBladeAlt.png b/Projectiles/Melee/SaharaSlicersBladeAlt.png index 69a74d3ac1..989f6b5acf 100644 Binary files a/Projectiles/Melee/SaharaSlicersBladeAlt.png and b/Projectiles/Melee/SaharaSlicersBladeAlt.png differ diff --git a/Projectiles/Melee/SaharaSlicersBolt.cs b/Projectiles/Melee/SaharaSlicersBolt.cs index 3304c67806..2fefaf7b63 100644 --- a/Projectiles/Melee/SaharaSlicersBolt.cs +++ b/Projectiles/Melee/SaharaSlicersBolt.cs @@ -1,8 +1,9 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -35,6 +36,7 @@ namespace CalamityMod.Projectiles.Melee { Player Owner = Main.player[Projectile.owner]; float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); + Projectile.ai[2]++; // Shot Mode if (Projectile.ai[0] == 1) @@ -65,7 +67,7 @@ namespace CalamityMod.Projectiles.Melee // Setting the bolt's position on the player's back Projectile.rotation = (21.8f - (Projectile.ai[1] * 0.1f)) * -Owner.direction; - Vector2 BoltPos = Owner.MountedCenter + new Vector2((10 + Projectile.ai[1] * 2.5f) * -Owner.direction, 3f - Projectile.ai[1]); + Vector2 BoltPos = Owner.MountedCenter + new Vector2((10 + Projectile.ai[1] * 2.5f) * -Owner.direction, 3f - Projectile.ai[1] + Owner.gfxOffY); Projectile.Center = BoltPos; } @@ -77,7 +79,7 @@ namespace CalamityMod.Projectiles.Melee Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 288 : 121, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.3f, 1.9f)); dust.noGravity = false; dust.scale = Main.rand.NextFloat(0.6f, 0.9f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 288 : 121, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.05f, 0.9f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 288 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.05f, 0.9f)); dust2.noGravity = false; dust2.scale = Main.rand.NextFloat(0.6f, 0.9f); } @@ -89,10 +91,10 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(SoundID.Item10, Projectile.position); for (int i = 0; i <= 5; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 216 : 121, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 216 : 207, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.1f, 1.8f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 216 : 121, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.05f, 0.4f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 216 : 207, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.05f, 0.4f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(1.1f, 1.8f); } @@ -102,7 +104,28 @@ namespace CalamityMod.Projectiles.Melee { if (Projectile.ai[0] == 1) CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return true; + Vector2 scale = new Vector2(Projectile.scale); + // Squishy fade in. This does not occur if the slicer is instantly thrown + if (Projectile.ai[0] == 0) + { + int endStretch = 4; + int endSquash = 8; + Vector2 stretch = new Vector2(0.8f, 1.6f); + if (Projectile.ai[2] < endStretch) + { + float completion = Utils.GetLerpValue(0, endStretch, Projectile.ai[2], true); + scale.X = MathHelper.Lerp(1.8f, stretch.X, completion); + scale.Y = MathHelper.Lerp(0.3f, stretch.Y, completion); + } + else + { + float completion = Utils.GetLerpValue(0, endSquash, Projectile.ai[2], true); + scale.X = MathHelper.Lerp(stretch.X, 1f, completion); + scale.Y = MathHelper.Lerp(stretch.Y, 1f, completion); + } + } + Main.EntitySpriteDraw(TextureAssets.Projectile[Type].Value, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, TextureAssets.Projectile[Type].Size() / 2, scale, SpriteEffects.None); + return false; } public override bool? CanDamage() => Projectile.ai[0] == 1 ? true : false; } diff --git a/Projectiles/Melee/SaharaSlicersBolt.png b/Projectiles/Melee/SaharaSlicersBolt.png index 7bcc8d6378..9c954972d8 100644 Binary files a/Projectiles/Melee/SaharaSlicersBolt.png and b/Projectiles/Melee/SaharaSlicersBolt.png differ diff --git a/Projectiles/Melee/SandFire.cs b/Projectiles/Melee/SandFire.cs index 479a3fa16c..b2d352d5a0 100644 --- a/Projectiles/Melee/SandFire.cs +++ b/Projectiles/Melee/SandFire.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/ScorcherExplosion.cs b/Projectiles/Melee/ScorcherExplosion.cs index 025bd83cdc..4d6f899af6 100644 --- a/Projectiles/Melee/ScorcherExplosion.cs +++ b/Projectiles/Melee/ScorcherExplosion.cs @@ -1,8 +1,5 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/ScorpiusConstellation.cs b/Projectiles/Melee/ScorpiusConstellation.cs new file mode 100644 index 0000000000..b7bc4ae366 --- /dev/null +++ b/Projectiles/Melee/ScorpiusConstellation.cs @@ -0,0 +1,136 @@ + +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class ScorpiusConstellation : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int lifetime = 150; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 1; + } + + public override void SetDefaults() + { + + lifetime = 90; + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = lifetime; + Projectile.DamageType = DamageClass.Melee; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.scale = 0; + } + + public override void AI() + { + if (Projectile.velocity.Length() > 0) + Projectile.rotation = Projectile.velocity.ToRotation(); + var Owner = Main.player[Projectile.owner]; + var DrawCenter = Projectile.Center + Projectile.velocity; + var StarScale = 0.2f; + Projectile.scale = 0.75f*MathF.Min(MathF.Pow((lifetime- Projectile.timeLeft)/ 20f,2f), 1f); + Projectile.Opacity = MathF.Min(Projectile.timeLeft / 20f, 1f); + Vector2 ada = default; + void SpawnStar(Vector2 offset, float intensity, int flashOffset = 0, int flashMod = 60) + { + offset += new Vector2(5, 49.25f); //this centers the constellation + offset.X *= Projectile.spriteDirection; + var star = new BloomParticle(DrawCenter + offset.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(offset.Length() * 0.001f, 0, 1)), Vector2.Zero, Color.SkyBlue * Projectile.Opacity * ((Owner.miscCounter + flashOffset) % flashMod < 5 ? 0.75f : 1f), StarScale * intensity, StarScale * intensity, 2, false); + var star2 = new CustomSpark(DrawCenter + offset.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(offset.Length() * 0.001f, 0, 1)), Vector2.UnitX.RotatedBy(MathHelper.Pi * ((Owner.miscCounter + flashOffset) / 300f)) * 0.1f, "CalamityMod/Particles/Sparkle", false, 2, 4 * StarScale * intensity, Color.White * Projectile.Opacity, Vector2.One); + GeneralParticleHandler.SpawnParticle(star); + GeneralParticleHandler.SpawnParticle(star2); + } + if (Projectile.FinalExtraUpdate()) + { + SpawnStar(new Vector2(0f, 0f), 0.75f, 25); //Center + SpawnStar(new Vector2(99,-166), 1.25f, 20); //Antares + SpawnStar(new Vector2(224,-300), 0.75f, 15); //topHead + SpawnStar(new Vector2(243,-237), 0.75f, 10); //midHead + SpawnStar(new Vector2(243,-163), 0.75f, 5); //lowHead + SpawnStar(new Vector2(246,-97), 0.75f, 0); //bottomHead + SpawnStar(new Vector2(-255,77), 0.75f, 55); //tail + SpawnStar(new Vector2(-176,71), 0.75f, 50); //zig + SpawnStar(new Vector2(-236,142), 0.75f, 45); //zag + SpawnStar(new Vector2(-188,197), 0.75f, 40); //tail 4 + SpawnStar(new Vector2(-85,193), 0.75f, 35); //taol 5 + SpawnStar(new Vector2(-19,172), 0.75f, 30); //tail 6 + } + Projectile.position = Projectile.Center; + Projectile.Size = new Vector2(510,510) * Projectile.scale; + Projectile.Center = Projectile.position; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); + + public override bool PreDraw(ref Color lightColor) + { + var SiriusPos = Projectile.Center; + var Owner = Main.player[Projectile.owner]; + void ConnectStars(Vector2 point1, Vector2 point2) + { + point1 += new Vector2(5, 49.25f); //this centers the constellation + point2 += new Vector2(5, 49.25f); + point1.X *= Projectile.spriteDirection; + point2.X *= Projectile.spriteDirection; + var color = Color.SkyBlue * 0.75f * ((MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f + 0.5f); + CalamityUtils.DrawLineBetter(Main.spriteBatch, SiriusPos + point1.RotatedBy(Projectile.rotation) * Projectile.scale, SiriusPos + point2.RotatedBy(Projectile.rotation) * Projectile.scale, color * Projectile.Opacity, 3); + } + //Order is back of tail to front. Last four are the head + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + ConnectStars(new Vector2(-255, 77), new Vector2(-176, 71)); + ConnectStars(new Vector2(-176, 71), new Vector2(-236, 142)); + ConnectStars(new Vector2(-236, 142), new Vector2(-188, 197)); + ConnectStars(new Vector2(-188, 197), new Vector2(-85, 193)); + ConnectStars(new Vector2(-85, 193), new Vector2(-19, 172)); + ConnectStars(new Vector2(-19, 172), new Vector2(0f, 0f)); + ConnectStars(new Vector2(0f, 0f), new Vector2(99, -166)); + ConnectStars(new Vector2(99, -166), new Vector2(224, -300)); + ConnectStars(new Vector2(99, -166), new Vector2(243, -237)); + ConnectStars(new Vector2(99, -166), new Vector2(243, -163)); + ConnectStars(new Vector2(99, -166), new Vector2(246, -97)); + Main.spriteBatch.End(); + } + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); + + int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + } + } + } +} diff --git a/Projectiles/Melee/ScourgeoftheCosmosProj.cs b/Projectiles/Melee/ScourgeoftheCosmosProj.cs index 813b2ed575..277b84805f 100644 --- a/Projectiles/Melee/ScourgeoftheCosmosProj.cs +++ b/Projectiles/Melee/ScourgeoftheCosmosProj.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Melee/SeekingScorcherProj.cs b/Projectiles/Melee/SeekingScorcherProj.cs index 3ade299e4f..759ef84b5e 100644 --- a/Projectiles/Melee/SeekingScorcherProj.cs +++ b/Projectiles/Melee/SeekingScorcherProj.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -28,8 +27,9 @@ namespace CalamityMod.Projectiles.Melee public static float CrystalBounceDamageMult = 2f; // Exponential scaling for multiple bounces but capped at max bounces public static float CrystalBounceSpeedMult = 1.25f; public static int MaxBounces = 3; - public const float MaxNPCHomingRange = 1200f; // 75 tiles - public const float MaxAxeHomingRange = 800f; // 50 tiles + public const float MaxNPCHomingRange = 960f; // 60 tiles + up to 3x empowerment boosts + public const float MaxAxeHomingRange = 640f; // 40 tiles + up to 2x empowerment boosts + public const float BonusRangePerEmpowerment = 80f; // 5 tiles private List PreviousNPCs = new List() { -1 }; public Player Owner => Main.player[Projectile.owner]; @@ -126,6 +126,9 @@ namespace CalamityMod.Projectiles.Melee // Cause the axe that just hit to be empowered and counts as a bounce proj.damage = Math.Clamp((int)(proj.damage * CrystalBounceDamageMult), 0, (int)(proj.originalDamage * MathF.Pow(CrystalBounceDamageMult, MaxBounces))); proj.velocity = proj.velocity.RotatedBy(Main.rand.NextBool() ? MathHelper.ToRadians(Main.rand.NextFloat(108f, 162f)) : MathHelper.ToRadians(Main.rand.NextFloat(-162f, -108f))) * CrystalBounceSpeedMult; + if (proj.MaxUpdates < 5) + proj.MaxUpdates++; + proj.ai[1] -= 30f; proj.ai[2] = -1f; proj.netUpdate = true; @@ -230,6 +233,13 @@ namespace CalamityMod.Projectiles.Melee } } } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.8f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } public override void OnKill(int timeLeft) { @@ -263,7 +273,7 @@ namespace CalamityMod.Projectiles.Melee return; } - float range = MaxNPCHomingRange; + float range = MaxNPCHomingRange + BonusRangePerEmpowerment * (Projectile.MaxUpdates - 2); int targetNPC = -1; foreach (NPC target in Main.ActiveNPCs) { @@ -282,7 +292,7 @@ namespace CalamityMod.Projectiles.Melee { // Will only try to bounce towards nearby axes if there are nearby enemies as to not waste axe hits // The last usable pierce will never be spent on an axe since it would then just return to the player - float range2 = MaxAxeHomingRange; + float range2 = MaxAxeHomingRange + BonusRangePerEmpowerment * (Projectile.MaxUpdates - 2); int targetAxe = -1; foreach (Projectile proj in Main.ActiveProjectiles) { @@ -319,6 +329,7 @@ namespace CalamityMod.Projectiles.Melee { // Swiftly move back towards the player; also make it avoid naturally despawning Projectile.velocity = Projectile.SafeDirectionTo(Owner.Center) * Projectile.velocity.Length(); + Projectile.MaxUpdates = 2; Projectile.timeLeft = 2; // Delete the Projectile if it touches its owner or too far away. diff --git a/Projectiles/Melee/Shortswords/CosmicShivProj.cs b/Projectiles/Melee/Shortswords/CosmicShivProj.cs index 15a8518531..c1483e7ab4 100644 --- a/Projectiles/Melee/Shortswords/CosmicShivProj.cs +++ b/Projectiles/Melee/Shortswords/CosmicShivProj.cs @@ -1,14 +1,9 @@ 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; diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs index 2843ec3b4a..4ef4e0f9b3 100644 --- a/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs +++ b/Projectiles/Melee/Shortswords/GalileoGladiusProj.cs @@ -1,90 +1,121 @@ using System; +using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Sounds; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Shortswords { - public class GalileoGladiusProj : BaseShortswordProjectile + public class GalileoGladiusProj : BaseSwordHoldoutProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Melee/GalileoGladius"; + public Player Owner => Main.player[Projectile.owner]; + public override int swingWidth => 200; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override string Texture => BaseItem.ModItem.Texture; + public override int AfterImageLength => 0; + public override int OffsetDistance { get; set; } = 90; + public override bool drawSwordTrail => false; + public override bool AlternateSwings => false; - public override void SetDefaults() + public override bool useMeleeSpeed => true; + + public override int swingTime { get; set; } = 8; + + public override SoundStyle? UseSound => SoundID.Item71 with { Volume = 0.5f }; + + public override void Defaults() { - Projectile.Size = new Vector2(24); - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.scale = 1f; - Projectile.DamageType = DamageClass.Melee; - Projectile.ownerHitCheck = true; - Projectile.timeLeft = 360; - Projectile.extraUpdates = 1; - Projectile.hide = true; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; + Projectile.extraUpdates = 3; } - public override Action EffectBeforePullback => (proj) => + public override void Spawn() { - int moonDamage = (int)(Projectile.damage * 0.6f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 10f, ModContent.ProjectileType(), moonDamage, Projectile.knockBack, Projectile.owner, 0f, 0f); - }; - - public override void SetVisualOffsets() - { - const int HalfSpriteWidth = 42 / 2; - const int HalfSpriteHeight = 46 / 2; - - int HalfProjWidth = Projectile.width / 2; - int HalfProjHeight = Projectile.height / 2; - - DrawOriginOffsetX = 0; - DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); - DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); + angle = angle.RotatedByRandom(0.25f); } - public override void ExtraBehavior() + public override void AdditionalAI() { - if (Main.rand.NextBool(5)) + OffsetDistance = (int)MathHelper.Lerp(15, 45, SwingCompletion); + //Spawn the large glow V + var sparkAngle = angle.RotatedBy(MathHelper.Pi); + int dir = MathF.Sign(sparkAngle.X); + var color = Color.LightSkyBlue; + if (Projectile.FinalExtraUpdate()) { - int gladiusDust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (Main.rand.NextBool() ? 20 : 176), (float)(Main.player[Projectile.owner].direction * 2), 0f, 150, default, 1.3f); - Main.dust[gladiusDust].velocity *= 0.2f; - Main.dust[gladiusDust].noGravity = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(Main.player[Projectile.owner]); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 300); - SpawnMeteor(Main.player[Projectile.owner]); - } - - private void SpawnMeteor(Player player) - { - if (player.whoAmI == Main.myPlayer) - { - var source = player.GetSource_FromThis(); - if (player.Calamity().galileoCooldown <= 0) + for (float i = -1; i <= 1; i += 2f) { - int damage = player.GetWeaponDamage(player.ActiveItem()) * 2; - CalamityUtils.ProjectileRain(source, player.Center, 400f, 100f, 500f, 800f, 25f, ModContent.ProjectileType(), damage, 15f, player.whoAmI); - player.Calamity().galileoCooldown = 15; + Vector2 velocity = -sparkAngle.RotatedBy(i * -0.3f) * 10f; + Vector2 position = Projectile.Center + new Vector2(MathHelper.Lerp(20, 93 * Projectile.scale, SwingCompletion), i * 15).RotatedBy(sparkAngle.ToRotation()); + Particle spark = new CustomSpark(position, velocity, "CalamityMod/Particles/BloomCircle", false, 3, 0.3f, color, new Vector2(0.3f, 3f),noShrink:true); + GeneralParticleHandler.SpawnParticle(spark); } } + Lighting.AddLight(Main.player[Projectile.owner].Center, 0.96f, 0.91f, 1f); + Main.player[Projectile.owner].heldProj = Projectile.whoAmI; } + + public override float SwingFunction() + { + return 0; //Galileo stabs, not swings. + } + + public override bool PreDraw(ref Color lightColor) + { + var tex = ModContent.Request("CalamityMod/Particles/GlowBlade").Value; + var sparkAngle = angle.RotatedBy(MathHelper.Pi); + + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Draw(tex, Projectile.Center + sparkAngle * -10 - Main.screenPosition, null, Color.SkyBlue * 0.75f, sparkAngle.ToRotation() + MathHelper.PiOver2, new Vector2(tex.Width * 0.5f,tex.Height), new Vector2(0.85f, MathHelper.Lerp(0.1f, 1.55f, SwingCompletion)) * Projectile.scale * 0.04f, SpriteEffects.None, 1); + + Main.spriteBatch.End(); + } + + var tex2 = TextureAssets.Projectile[Type].Value; + Main.spriteBatch.Draw(tex2, Projectile.Center + new Vector2(0, Projectile.gfxOffY) - Main.screenPosition, null, Color.SkyBlue * 1f, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 1); + return false ; + } + + public override void PostDraw(Color lightColor) + { + var tex2 = ModContent.Request("CalamityMod/Projectiles/Melee/GalileoGladiusGlow").Value; + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Draw(tex2, Projectile.Center + new Vector2(0, Projectile.gfxOffY) - Main.screenPosition, null, Color.SkyBlue * 0.75f, Projectile.rotation, tex2.Size() * 0.5f, Projectile.scale, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 1); + Main.spriteBatch.End(); + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Owner.Calamity().StratusStarburst++; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + var lineCollisionLength = 192; + var player = Main.player[Projectile.owner]; + var armcenter = player.Center - new Vector2(5 * player.direction, 2); + var swordDir = armcenter.DirectionTo(Projectile.Center); + var collisionline = new Vector2(lineCollisionLength / 2f, 0).RotatedBy(swordDir.ToRotation()) * Projectile.scale; + bool c = Collision.CheckAABBvLineCollision(targetHitbox.Location.ToVector2(), targetHitbox.Size(), Projectile.Center, Projectile.Center + collisionline); + if (c && !float.IsNaN(collisionline.X) && !float.IsNaN(collisionline.Y)) + return true; + return base.Colliding(projHitbox, targetHitbox); + } + } } diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs new file mode 100644 index 0000000000..90b3e5f30a --- /dev/null +++ b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Pets; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Sounds; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee.Shortswords +{ + public class GalileoGladiusThrown : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public Player Owner => Main.player[Projectile.owner]; + public override string Texture => "CalamityMod/Items/Weapons/Melee/GalileoGladius"; + + public Vector2 NPCOffset = Vector2.Zero; + public NPC stabbedNPC + { + get + { + if (Main.npc.IndexInRange((int)Projectile.ai[0] - 1)) + { + var npc = Main.npc[(int)Projectile.ai[0] - 1]; + if (npc.active) + return npc; + else + Projectile.ai[0] = 0; + } + return null; + } + set + { + if (value is null) + Projectile.ai[0] = 0; + else + Projectile.ai[0] = value.whoAmI + 1; + } + } + + public override void SetDefaults() + { + Projectile.width = 44; + Projectile.height = 46; + Projectile.DamageType = DamageClass.Melee; + Projectile.penetrate = 1; + Projectile.stopsDealingDamageAfterPenetrateHits = true; + Projectile.extraUpdates = 2; + Projectile.timeLeft = 300; + Projectile.friendly = true; + Projectile.tileCollide = false; + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 48000; + } + float intensitymult = 0.2f; + public override void AI() + { + if (Projectile.ai[2] == 0) + Projectile.ai[2] += Main.rand.Next(1, 10000); //random start configuration for the consteallation trail + Projectile.ai[2]++; //timer for visuals + var point1 = Projectile.Center + Projectile.velocity + new Vector2(-17, 18).RotatedBy(Projectile.rotation); + var point2 = Owner.Center; + float intensity = MathHelper.Min(32, point1.Distance(point2) * 0.1f); + float size = intensity / 32f * 0.75f; + if (Projectile.ai[1] > 0 || stabbedNPC is null) + { + intensitymult = MathHelper.Max(0.2f, intensitymult - 0.05f); + } else + { + intensitymult = MathHelper.Min(1f, intensitymult + 0.05f); + } + intensity *= intensitymult; + if (Projectile.FinalExtraUpdate()) + for (var i = 0; i < offsets.Count - 1; i++) + { + var p1 = Vector2.Lerp(point1, point2, i / (float)(offsets.Count - 1)) + new Vector2(0, intensity).RotatedBy(point1.DirectionTo(point2).ToRotation()) * MathF.Sin(Projectile.ai[2] * 0.01f * offsets[i].Item2 + offsets[i].Item1); + var star = new BloomParticle(p1, Vector2.Zero, Color.SkyBlue * 0.75f, (i == 0 || i == offsets.Count - 1 ? 0.1f : 0.2f) * size, (i == 0 || i == offsets.Count - 1 ? 0.1f : 0.2f) * size, 2, false); + var star2 = new CustomSpark(p1, Vector2.UnitX.RotatedBy(MathHelper.Pi * ((Owner.miscCounter) / 300f)) * 0.1f, "CalamityMod/Particles/Sparkle", false, 2, (i == 0 || i == offsets.Count - 1 ? 0.4f : 0.8f) * size, Color.White, Vector2.One); + GeneralParticleHandler.SpawnParticle(star); + GeneralParticleHandler.SpawnParticle(star2); + } + if (stabbedNPC != null) + { + Projectile.Center = stabbedNPC.Center + NPCOffset; + Projectile.timeLeft++; + Projectile.velocity = Vector2.Zero; + } + else + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; + if (Projectile.Distance(Owner.Center) > 1000) + { + Projectile.ai[1] = 1; + } + if (Projectile.ai[1] == 1) + { + Projectile.velocity = Vector2.Lerp(Projectile.velocity,Projectile.DirectionTo(Owner.Center) * 15,0.1f); + Projectile.rotation += MathHelper.Pi; + if (Projectile.Distance(Owner.Center) < 16) + { + Projectile.Kill(); + return; + } + } + } + if (Projectile.ai[1] == 3) + { + + Owner.mount.Dismount(Owner); + Owner.SetImmuneTimeForAllTypes(3); + Owner.velocity = Owner.DirectionTo(Projectile.Center) * 4; + Owner.Center += Owner.DirectionTo(Projectile.Center) * 16; + if (Collision.SolidCollision(Owner.position, Owner.width, Owner.height)) + { + Projectile.ai[1] = 2; + Owner.velocity *= -2; + Owner.Center += Owner.velocity * 2; + } + if (Projectile.Distance(Owner.Center) < 64) + Projectile.ai[1] = 4; + } + if (Projectile.ai[1] == 2) + { + Projectile.ai[1] = 1; + Projectile.penetrate = 1; + Projectile.damage = Projectile.originalDamage; + if (Owner.Calamity().AvaliableStarburst >= 10) + { + for (var i = 0; i < 10; i++) + GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, (Projectile.rotation-MathHelper.PiOver4).ToRotationVector2().RotatedByRandom(0.4f) * -Main.rand.Next(10,20), false, 30, 2, new Color(69, 69, 200))); + Projectile.damage = (int)(Projectile.damage*17.5f); + Projectile.Damage(); + Owner.Calamity().StratusStarburst -= 10; + for (int i = 0; i < 3; i++) + { + float moveDuration = Main.rand.Next(5, 15); + var proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.rotation + MathHelper.PiOver4*3).ToRotationVector2().RotatedByRandom(0.4f) * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner, 0f, moveDuration); + if (Main.projectile.IndexInRange(proj)) + { + Main.projectile[proj].DamageType = DamageClass.Melee; + Main.projectile[proj].usesIDStaticNPCImmunity = false; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 20; + } + } + Projectile.velocity = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * -15; + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, Owner.Center); + + } + stabbedNPC = null; + } + if (Projectile.ai[1] > 3) + { + Projectile.ai[1]++; + Owner.Center = Projectile.Center; + Owner.SetImmuneTimeForAllTypes(3); + Owner.velocity = Owner.velocity.SafeNormalize(Vector2.Zero) * 2; + if (Collision.SolidCollision(Owner.position, Owner.width, Owner.height)) + { + Projectile.ai[1] = 2; + Owner.position = Owner.oldPosition; + Owner.SetImmuneTimeForAllTypes(12); + } + var particlevel = Owner.DirectionFrom(Owner.Calamity().mouseWorld); + GeneralParticleHandler.SpawnParticle(new CustomSpark(Owner.Center + particlevel * 96, particlevel, "CalamityMod/Particles/BloomCircle", false, 2, 0.2f, Color.SkyBlue, new Vector2(0.3f, 3f), shrinkSpeed: 0.2f)); + } + if (Projectile.ai[1] >= 34 && !Owner.controlUseTile || Projectile.ai[1] >= 64) + { + Owner.velocity = Owner.DirectionFrom(Owner.Calamity().mouseWorld) * 15; + Owner.Center = Projectile.Center; + Projectile.penetrate = 1; + Projectile.damage = Projectile.originalDamage; + if (Owner.Calamity().AvaliableStarburst >= 20) + { + Projectile.damage *= 35; + Owner.SetImmuneTimeForAllTypes(Owner.longInvince ? 40 : 20); + Owner.Calamity().StratusStarburst -= 20; + SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, Owner.Center); + SoundEngine.PlaySound(SoundID.DD2_SonicBoomBladeSlash, Owner.Center); + for (var i = 0; i < 10; i++) + GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, Owner.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.75f, 1.25f), false, 30, 2, new Color(69, 69, 200))); + for (int i = 0; i < 3; i++) + { + float moveDuration = Main.rand.Next(5, 15); + var proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Owner.velocity.RotatedByRandom(0.4f) * -Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner, 0f, moveDuration); + if (Main.projectile.IndexInRange(proj)) + { + Main.projectile[proj].DamageType = DamageClass.Melee; + Main.projectile[proj].usesIDStaticNPCImmunity = false; + Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].localNPCHitCooldown = 20; + } + } + } + Projectile.stopsDealingDamageAfterPenetrateHits = false; + Projectile.ai[1] = 1; + Vector2 position = Projectile.Center - Owner.velocity * 5; + Vector2 velocity = Owner.velocity.SafeNormalize(Vector2.One) * -5; + int lifetime = 120; + float scale = 0.1f; + Color color = Color.SkyBlue; + Vector2 stretch = new Vector2(0.5f, 0.5f); + float shrink = -0.3f; + Particle boostRing = new CustomSpark(position, velocity, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, lifetime, scale, color, stretch, shrinkSpeed: shrink); + GeneralParticleHandler.SpawnParticle(boostRing); + + if (stabbedNPC.CanBeMoved(true)) + { + stabbedNPC.velocity = -Owner.velocity; + } + stabbedNPC = null; + return; + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[1] == 0) + { + stabbedNPC = target; + NPCOffset = Projectile.Center - target.Center; + } + target.AddBuff(ModContent.BuffType(), 600); + } + + List<(float, float)> offsets = new() + { + (0,0), + (0,1), + (4,2), + (2,1.2f), + (1,0.2f), + (0.75f,1.1f), + (0,0) + }; + public override bool PreDraw(ref Color lightColor) + { + + var point1 = Projectile.Center + new Vector2(-17, 18).RotatedBy(Projectile.rotation); + var point2 = Owner.Center; + float intensity = MathHelper.Min(32, point1.Distance(point2) * 0.1f); + float size = intensity/32f; + intensity *= intensitymult; + var color = Color.SkyBlue * 0.75f * ((MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f + 0.5f); + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + for (var i = 1; i < offsets.Count; i++) + { + var p1 = Vector2.Lerp(point1, point2, i / (float)(offsets.Count - 1)) + new Vector2(0, intensity).RotatedBy(point1.DirectionTo(point2).ToRotation()) * MathF.Sin(Projectile.ai[2] * 0.01f * offsets[i].Item2 + offsets[i].Item1); + var p2 = Vector2.Lerp(point1, point2, (i - 1) / (float)(offsets.Count - 1)) + new Vector2(0, intensity).RotatedBy(point1.DirectionTo(point2).ToRotation()) * MathF.Sin(Projectile.ai[2] * 0.01f * offsets[i - 1].Item2 + offsets[i - 1].Item1); + CalamityUtils.DrawLineBetter(Main.spriteBatch, p1, p2, color, 2 * size); + } + Main.spriteBatch.End(); + } + return base.PreDraw(ref lightColor); + } + + } +} diff --git a/Projectiles/Melee/Shortswords/LucreciaProj.cs b/Projectiles/Melee/Shortswords/LucreciaProj.cs deleted file mode 100644 index 2517332b34..0000000000 --- a/Projectiles/Melee/Shortswords/LucreciaProj.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee.Shortswords -{ - public class LucreciaProj : BaseShortswordProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Melee/Lucrecia"; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 28; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Melee; - Projectile.ownerHitCheck = true; - Projectile.timeLeft = 360; - Projectile.hide = true; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; - } - - public override Action EffectBeforePullback => (proj) => - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 10f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - }; - - - public override void SetVisualOffsets() - { - const int HalfSpriteWidth = 62 / 2; - const int HalfSpriteHeight = 62 / 2; - - int HalfProjWidth = Projectile.width / 2; - int HalfProjHeight = Projectile.height / 2; - - DrawOriginOffsetX = 0; - DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); - DrawOriginOffsetY = -(HalfSpriteHeight - HalfProjHeight); - } - - public override void ExtraBehavior() - { - if (Main.rand.NextBool(5)) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BoneTorch); - } - } -} diff --git a/Projectiles/Melee/Shortswords/SaharaSlicersBlade.cs b/Projectiles/Melee/Shortswords/SaharaSlicersBlade.cs index 9c6ded3e47..247efad73c 100644 --- a/Projectiles/Melee/Shortswords/SaharaSlicersBlade.cs +++ b/Projectiles/Melee/Shortswords/SaharaSlicersBlade.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; @@ -35,8 +34,8 @@ namespace CalamityMod.Projectiles.Melee.Shortswords public override void SetVisualOffsets() { - const int HalfSpriteWidth = 40 / 2; - const int HalfSpriteHeight = 40 / 2; + const int HalfSpriteWidth = 32 / 2; + const int HalfSpriteHeight = 32 / 2; int HalfProjWidth = Projectile.width / 2; int HalfProjHeight = Projectile.height / 2; @@ -50,7 +49,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords { if (Main.rand.NextBool(2)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12), 288); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12), DustID.DesertWater2); dust.scale = Main.rand.NextFloat(0.15f, 0.6f); dust.noGravity = true; dust.velocity = -Projectile.velocity * 0.5f; @@ -83,7 +82,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); - Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool() ? 288 : 121, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool() ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = false; dust.velocity = velOffset; dust.scale = Main.rand.NextFloat(1.5f, 1.2f); diff --git a/Projectiles/Melee/Shortswords/SaharaSlicersBladeAlt.cs b/Projectiles/Melee/Shortswords/SaharaSlicersBladeAlt.cs index d6fd3f55d1..d24515e39e 100644 --- a/Projectiles/Melee/Shortswords/SaharaSlicersBladeAlt.cs +++ b/Projectiles/Melee/Shortswords/SaharaSlicersBladeAlt.cs @@ -1,13 +1,10 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Projectiles.Melee.Shortswords { @@ -37,8 +34,8 @@ namespace CalamityMod.Projectiles.Melee.Shortswords public override void SetVisualOffsets() { - const int HalfSpriteWidth = 40 / 2; - const int HalfSpriteHeight = 40 / 2; + const int HalfSpriteWidth = 32 / 2; + const int HalfSpriteHeight = 32 / 2; int HalfProjWidth = Projectile.width / 2; int HalfProjHeight = Projectile.height / 2; @@ -52,7 +49,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords { if (Main.rand.NextBool(2)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12), 288); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12), DustID.DesertWater2); dust.scale = Main.rand.NextFloat(0.15f, 0.6f); dust.noGravity = true; dust.velocity = -Projectile.velocity * 0.5f; @@ -86,7 +83,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); - Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool() ? 288 : 121, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(target.Center + offset, Main.rand.NextBool() ? 288 : 207, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = false; dust.velocity = velOffset; dust.scale = Main.rand.NextFloat(1.5f, 1.2f); diff --git a/Projectiles/Melee/Shortswords/StarburstShivProj.cs b/Projectiles/Melee/Shortswords/StarburstShivProj.cs deleted file mode 100644 index 8293e62d06..0000000000 --- a/Projectiles/Melee/Shortswords/StarburstShivProj.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee.Shortswords -{ - public class StarburstShivProj : BaseShortswordProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Melee/StarburstShiv"; - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 44; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.scale = 1f; - Projectile.DamageType = TrueMeleeDamageClass.Instance; - Projectile.ownerHitCheck = true; - Projectile.timeLeft = 360; - Projectile.extraUpdates = 1; - Projectile.hide = true; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override Action EffectBeforePullback => (proj) => - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 14f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 0f); - }; - - public override void SetVisualOffsets() - { - const int HalfSpriteWidth = 37; - const int HalfSpriteHeight = 47; - - int HalfProjWidth = Projectile.width / 2; - int QuarterProjHeight = Projectile.height / 4; - - DrawOriginOffsetX = 0; - DrawOffsetX = -(HalfSpriteWidth - HalfProjWidth); - DrawOriginOffsetY = -(HalfSpriteHeight - QuarterProjHeight); - } - - public override void ExtraBehavior() - { - if (Main.rand.NextBool(5)) - { - int rainbowDust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[rainbowDust].velocity *= 0.2f; - Main.dust[rainbowDust].noGravity = true; - } - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } -} diff --git a/Projectiles/Melee/SkytideDragoonHoldout.cs b/Projectiles/Melee/SkytideDragoonHoldout.cs index bda0458693..d1439e3957 100644 --- a/Projectiles/Melee/SkytideDragoonHoldout.cs +++ b/Projectiles/Melee/SkytideDragoonHoldout.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -8,13 +9,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class SkytideDragoonHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -217,18 +218,18 @@ namespace CalamityMod.Projectiles.Melee { if (fancySwing) // Call down the bolt { - Owner.Calamity().GeneralScreenShakePower = 3f; - SoundStyle sound = new("CalamityMod/Sounds/Item/SkytiedBolt"); + Owner.SetScreenshake(3f); + SoundStyle sound = new("CalamityMod/Sounds/Item/SkytideBolt"); SoundEngine.PlaySound(sound with { Volume = 0.8f }, Projectile.Center); - Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center + new Vector2(0, -600), new Vector2(0, 10), ModContent.ProjectileType(), (int)(Projectile.damage * 5), Projectile.knockBack, Projectile.owner, 0, 0.5f); + Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center + new Vector2(0, -600), new Vector2(0, 10), ModContent.ProjectileType(), (int)(Projectile.damage * 9), Projectile.knockBack, Projectile.owner, 0, 0.5f); proj.timeLeft = 45; swingCount = 0; attackPower = 6; } else if (redirected) // Redirect the bolt { - Owner.Calamity().GeneralScreenShakePower = 4.5f; - SoundStyle fire = new("CalamityMod/Sounds/Item/SkytiedBolt"); + Owner.SetScreenshake(4.5f); + SoundStyle fire = new("CalamityMod/Sounds/Item/SkytideBolt"); SoundEngine.PlaySound(fire with { Volume = 1f, Pitch = -0.2f }, Projectile.Center); SoundStyle fire2 = new("CalamityMod/Sounds/Item/AuricBulletHit"); SoundEngine.PlaySound(fire2 with { Volume = 0.5f, Pitch = 0.2f }, Projectile.Center); diff --git a/Projectiles/Melee/SolsticeBeam.cs b/Projectiles/Melee/SolsticeBeam.cs index c51f791152..145fe5dd34 100644 --- a/Projectiles/Melee/SolsticeBeam.cs +++ b/Projectiles/Melee/SolsticeBeam.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Melee/SoulScytheExplosion.cs b/Projectiles/Melee/SoulScytheExplosion.cs index 4e59925bfe..abed6afa05 100644 --- a/Projectiles/Melee/SoulScytheExplosion.cs +++ b/Projectiles/Melee/SoulScytheExplosion.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/SpatialSpear.cs b/Projectiles/Melee/SpatialSpear.cs index db4bd66be8..f9f4ca25d7 100644 --- a/Projectiles/Melee/SpatialSpear.cs +++ b/Projectiles/Melee/SpatialSpear.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,13 +12,8 @@ namespace CalamityMod.Projectiles.Melee { public new string LocalizationCategory => "Projectiles.Melee"; - private const int TimeLeft = 180; - - private const int TimeToFall = TimeLeft / 2; - - private const int TotalSplits = 6; - - private const int SplitTime = TimeLeft / TotalSplits; + private int TimeLeft = Main.zenithWorld ? 300 : 180; + private int TotalSplits = Main.zenithWorld ? 30: 6; public override void SetStaticDefaults() { @@ -35,6 +29,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = -1; Projectile.timeLeft = TimeLeft; + Projectile.tileCollide = !Main.zenithWorld; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } @@ -45,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver4; - if (Projectile.timeLeft < TimeToFall) + if (Projectile.timeLeft < (TimeLeft / 2)) { Projectile.velocity.Y += 0.16f; if (Projectile.velocity.Y > 16f) @@ -81,18 +76,17 @@ namespace CalamityMod.Projectiles.Melee Main.dust[dust].noLightEmittence = true; Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] >= SplitTime) + if (Projectile.localAI[0] >= TimeLeft / TotalSplits) { Projectile.localAI[0] = 0f; int numProj = 2; float rotation = MathHelper.ToRadians(5); - float velocity = 16f; if (Projectile.owner == Main.myPlayer) { for (int i = 0; i < numProj; i++) { - Vector2 perturbedSpeed = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed * velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.5f, Projectile.owner); + Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.5f, Projectile.owner); } } } diff --git a/Projectiles/Melee/SpatialSpear2.cs b/Projectiles/Melee/SpatialSpear2.cs index fcdd40ad08..09895b3c24 100644 --- a/Projectiles/Melee/SpatialSpear2.cs +++ b/Projectiles/Melee/SpatialSpear2.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -14,12 +13,7 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; private const int TimeLeft = 100; - - private const int TimeToFall = TimeLeft / 2; - - private const int TotalSplits = 3; - - private const int SplitTime = TimeLeft / TotalSplits; + private int TotalSplits = Main.zenithWorld ? 4 : 3; public override void SetStaticDefaults() { @@ -35,6 +29,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 3; Projectile.timeLeft = TimeLeft; + Projectile.tileCollide = !Main.zenithWorld; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } @@ -45,7 +40,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver4; - if (Projectile.timeLeft < TimeToFall) + if (Projectile.timeLeft < (TimeLeft / 2)) { Projectile.velocity.Y += 0.16f; if (Projectile.velocity.Y > 16f) @@ -81,18 +76,17 @@ namespace CalamityMod.Projectiles.Melee Main.dust[dust].noLightEmittence = true; Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] >= SplitTime) + if (Projectile.localAI[0] >= TimeLeft / TotalSplits) { Projectile.localAI[0] = 0f; int numProj = 2; float rotation = MathHelper.ToRadians(10); - float velocity = 16f; if (Projectile.owner == Main.myPlayer) { for (int i = 0; i < numProj; i++) { - Vector2 perturbedSpeed = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed * velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.5f, Projectile.owner); + Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.5f, Projectile.owner); } } } diff --git a/Projectiles/Melee/SpatialSpear3.cs b/Projectiles/Melee/SpatialSpear3.cs index 2b5f59aa0d..fafddb70d7 100644 --- a/Projectiles/Melee/SpatialSpear3.cs +++ b/Projectiles/Melee/SpatialSpear3.cs @@ -1,9 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -35,6 +33,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 2; Projectile.timeLeft = TimeLeft; + Projectile.tileCollide = !Main.zenithWorld; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } @@ -86,13 +85,12 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] = 0f; int numProj = 2; float rotation = MathHelper.ToRadians(20); - float velocity = 16f; if (Projectile.owner == Main.myPlayer) { for (int i = 0; i < numProj; i++) { - Vector2 perturbedSpeed = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed * velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.5f, Projectile.owner); + Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8), Projectile.knockBack * 0.5f, Projectile.owner); } } } diff --git a/Projectiles/Melee/SpatialSpear4.cs b/Projectiles/Melee/SpatialSpear4.cs index f7932ebf8d..b966f0a938 100644 --- a/Projectiles/Melee/SpatialSpear4.cs +++ b/Projectiles/Melee/SpatialSpear4.cs @@ -1,9 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -30,6 +28,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.timeLeft = TimeLeft; + Projectile.tileCollide = !Main.zenithWorld; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } diff --git a/Projectiles/Melee/Spears/AmidiasTridentProj.cs b/Projectiles/Melee/Spears/AmidiasTridentProj.cs index 1581375c55..597a56c049 100644 --- a/Projectiles/Melee/Spears/AmidiasTridentProj.cs +++ b/Projectiles/Melee/Spears/AmidiasTridentProj.cs @@ -1,21 +1,31 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using Terraria; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.NPCs; +using ReLogic.Content; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Particles; +using Terraria.Audio; +using System; +using Terraria.DataStructures; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.Typeless; namespace CalamityMod.Projectiles.Melee.Spears { - public class AmidiasTridentProj : BaseSpearProjectile + [PierceResistException] + public class AmidiasTridentProj : BaseCustomUseStyleProjectile { + public override int AssignedItemID => ModContent.ItemType(); public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public override void SetDefaults() { - Projectile.width = Projectile.height = 28; + Projectile.width = Projectile.height = 50; Projectile.DamageType = DamageClass.Melee; - Projectile.timeLeft = 90; + Projectile.timeLeft = 2; Projectile.friendly = true; Projectile.hostile = false; Projectile.tileCollide = false; @@ -23,14 +33,220 @@ namespace CalamityMod.Projectiles.Melee.Spears Projectile.penetrate = -1; Projectile.ownerHitCheck = true; Projectile.hide = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 7; + } + float rot = 0f; + float glow = 0f; + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + Vector2 cen = Projectile.Center + new Vector2(45, 0).RotatedBy(rot); + hitbox = new Rectangle((int)cen.X - 40, (int)cen.Y - 40, 80, 80); + + if (Owner.altFunctionUse == 2) + { + cen = Owner.Center; + hitbox = new Rectangle((int)cen.X - 80, (int)cen.Y - 80, 160, 160); + } + } + public override void WhenSpawned() + { + Projectile.ai[0] = -20; + rot = Owner.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(); + } + public override void UseStyle() + { + glow = MathHelper.Lerp(glow, 0f, 0.12f); + Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.Center.X); + + switch (Owner.altFunctionUse) + { + case 2: // Alt attack + Projectile.localNPCHitCooldown = 4; + + if (AnimationProgress <= 0) + Projectile.ai[0] = 20; + + if (AnimationProgress < 20) + { + if (AnimationProgress == 1) + { + SoundStyle soundStyle = new SoundStyle("CalamityMod/Sounds/Item/AmidiasTrident_Spin"); + soundStyle.MaxInstances = 5; + SoundEngine.PlaySound(soundStyle, Owner.Center); + } + if (AnimationProgress % 2 == 0) + { + for (int i = 0; i < 3; i++) + GeneralParticleHandler.SpawnParticle(new CustomPulse(Owner.Center, Vector2.Zero, SeaKingsAssurance.BaseColor, + "CalamityMod/Particles/CircularSmearFire3", Vector2.One, Projectile.rotation, 0.8f, 1.2f, 6, effects: Owner.direction > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally)); + } + + glow = MathHelper.Lerp(glow, Projectile.ai[0] * 0.05f / 3f, 0.2f); + rot += MathHelper.ToRadians(Projectile.ai[0] * 0.8f * Owner.direction); + if (AnimationProgress < 5) + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 60, 0.2f); + else if (AnimationProgress >= 10) + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 20, 0.2f); + else + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 40, 0.2f); + } + else + { + if (AnimationProgress == 20) + { + ExpendStacks(); + + SoundStyle soundStyle = new SoundStyle("CalamityMod/Sounds/Item/AmidiasTrident_Raise"); + soundStyle.MaxInstances = 5; + SoundEngine.PlaySound(soundStyle, Owner.Center); + glow = 1.5f; + rot = -MathHelper.PiOver2; + } + + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 60, 0.3f); + } + + Projectile.rotation = rot + MathHelper.ToRadians(135f); + AbsolutePosition = Owner.Center + new Vector2(Projectile.ai[0], 0).RotatedBy(rot); + break; + + + default: // Main attack + if (AnimationProgress < 21) + { + rot = Owner.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(); + if (AnimationProgress % 7 < 2) + { + if (AnimationProgress % 7 == 1) + { + SoundStyle soundStyle = new SoundStyle("CalamityMod/Sounds/Item/AmidiasTrident_Stab" + Main.rand.Next(1, 3).ToString()); + soundStyle.MaxInstances = 5; + soundStyle.PitchVariance = 0.2f; + SoundEngine.PlaySound(soundStyle.WithPitchOffset(0.2f), Owner.Center); + for (int i = 0; i < 6; i++) + { + CustomSpark p = new CustomSpark(Projectile.Center + new Vector2(20, Main.rand.NextFloat(-30, 30)).RotatedBy(rot), Owner.DirectionTo(AbsolutePosition) * 10, "CalamityMod/Particles/ThinEndedLine", false, 5, 1f, Color.CadetBlue.MultiplyRGBA(new(1f, 1f, 1f, 1f)), new Vector2(0.2f, 1.2f)); + GeneralParticleHandler.SpawnParticle(p); + } + if (Main.myPlayer == Projectile.owner) + { + Lighting.AddLight(Projectile.Center, new Vector3(0.2f, 0.45f, 1f)); + Vector2 vel = (Projectile.rotation + MathHelper.ToRadians(-135f)).ToRotationVector2() * 30f; + Projectile.NewProjectile(new EntitySource_Parent(Projectile), Projectile.Center + new Vector2(-30, 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(-135f)), + vel, ModContent.ProjectileType(), (int)(Projectile.damage * AmidiasTrident.BaseAttackProjectileMult), Projectile.knockBack / 2, Projectile.owner); + } + } + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 92, 0.3f); + glow = MathHelper.Lerp(glow, 1f, 0.3f); + } + else + { + if (AnimationProgress % 7 < 4) + { + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 10, 0.3f); + } + else + { + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 10, 0.1f); + } + } + } + else + { + rot = rot.AngleLerp(Owner.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(), 0.3f); + Projectile.ai[0] = MathHelper.Lerp(Projectile.ai[0], 10, 0.1f); + } + + Projectile.rotation = rot + MathHelper.ToRadians(135f); + AbsolutePosition = Owner.Center + new Vector2(Projectile.ai[0], 0).RotatedBy(rot); + break; + } } - public override float InitialSpeed => 3f; - public override float ReelbackSpeed => 1f; - public override float ForwardSpeed => 0.75f; - public override Action EffectBeforeReelback => (proj) => + public override bool? CanDamage() => (Owner.altFunctionUse == 0 && AnimationProgress < 21 && AnimationProgress % 7 < 2) || (Owner.altFunctionUse == 2 && AnimationProgress < 20); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 0.8f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 0.85f, Projectile.owner, 0f, 0f); - }; + if (Owner.altFunctionUse == 2 && AnimationProgress < 20) + modifiers.SourceDamage *= AmidiasTrident.SecondaryAttackMeleeMult; + } + + private void ExpendStacks() + { + foreach (NPC npc2 in Main.npc) + { + if (npc2.active && !npc2.friendly && !npc2.isLikeATownNPC) + { + if (npc2.Distance(Owner.Center) < 200) + { + if (npc2.HasBuff(ModContent.BuffType())) + { + int stacks = (int)Math.Ceiling((double)npc2.buffTime[npc2.FindBuffIndex(ModContent.BuffType())] / SeaKingsAssurance.FramesPerStack); + + DamageEffect(npc2, stacks); + + npc2.DelBuff(npc2.FindBuffIndex(ModContent.BuffType())); + } + } + } + } + + for (int i = 0; i < 5; i++) + { + GeneralParticleHandler.SpawnParticle(new CustomPulse( + Owner.Center, Vector2.Zero, SeaKingsAssurance.LightColor, "CalamityMod/Particles/ShineExplosion2", new Vector2(Main.rand.NextFloat(0.2f, 0.3f), Main.rand.NextFloat(0.1f, 0.15f)), + 0f, 0.6f, 1.2f, 6 + )); + } + } + + private static void DamageEffect(NPC npc, int stacks) + { + Projectile.NewProjectileDirect(new EntitySource_Buff(npc, ModContent.BuffType(), + npc.FindBuffIndex(ModContent.BuffType())), npc.Center, Vector2.Zero, ModContent.ProjectileType(), + AmidiasTrident.SecondaryAttackBlastBaseDamage * stacks, 0f, ai0: npc.whoAmI); + + for (int i = 0; i < 5; i++) + { + GeneralParticleHandler.SpawnParticle(new CustomPulse( + npc.Center, Vector2.Zero, SeaKingsAssurance.LightColor, "CalamityMod/Particles/ShineExplosion2", new Vector2(Main.rand.NextFloat(0.2f, 0.3f), Main.rand.NextFloat(0.1f, 0.15f)), + 0f, 0.2f, 0.8f, 6 + )); + } + + for (int i = 0; i < 5; i++) + { + float rot = Main.rand.NextFloat(MathHelper.TwoPi) + MathHelper.PiOver2; + float sc = 0.3f; + + GeneralParticleHandler.SpawnParticle(new CustomPulse( + npc.Center, (rot - MathHelper.PiOver2).ToRotationVector2() * 6f, Color.Lerp(SeaKingsAssurance.BaseColor, SeaKingsAssurance.LightColor, sc * 3f), "CalamityMod/Particles/ForwardSmear", new Vector2(Main.rand.NextFloat(0.015f, 0.1f), 0.1f), + rot, sc, sc * 2f, 8 + )); + } + + } + + public static readonly Asset StabTexture = ModContent.Request("CalamityMod/Particles/LargeSpark"); + public static readonly Asset SwingTexture = ModContent.Request("CalamityMod/Particles/CircularSmearFire3"); + public override bool PreDraw(ref Color lightColor) + { + Asset tex = ModContent.Request("CalamityMod/Particles/GlowBlade"); + + for (int i = 0; i < 5; i++) + { + int f = (int)(tex.Height() * glow); + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(-60 + (f * 0.03f), 0).RotatedBy(rot) + new Vector2(0f, Owner.gfxOffY), new Rectangle(0, 0, tex.Width(), f), Color.DeepSkyBlue.MultiplyRGBA(new(glow, glow, glow, 0f)), rot + MathHelper.PiOver2, new Vector2(tex.Width() / 2, tex.Height()), new Vector2(0.03f), SpriteEffects.None); + } + + return base.PreDraw(ref lightColor); + } + public override void AI() + { + base.AI(); + + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation + MathHelper.ToRadians(135f)); + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation + MathHelper.ToRadians(135f)); + } } } diff --git a/Projectiles/Melee/Spears/AstralPikeProj.cs b/Projectiles/Melee/Spears/AstralPikeProj.cs index 2c1f92d4d1..18a77736ea 100644 --- a/Projectiles/Melee/Spears/AstralPikeProj.cs +++ b/Projectiles/Melee/Spears/AstralPikeProj.cs @@ -4,7 +4,6 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Typeless; using Terraria; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Projectiles/Melee/Spears/BotanicPiercerProjectile.cs b/Projectiles/Melee/Spears/BotanicPiercerProjectile.cs index 6c829928f4..3960a33083 100644 --- a/Projectiles/Melee/Spears/BotanicPiercerProjectile.cs +++ b/Projectiles/Melee/Spears/BotanicPiercerProjectile.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public override void SetDefaults() { Projectile.width = Projectile.height = 40; - Projectile.DamageType = DamageClass.Melee; //Dictates whether this is a melee-class weapon. + Projectile.DamageType = TrueMeleeDamageClass.Instance; Projectile.timeLeft = 90; Projectile.friendly = true; Projectile.hostile = false; @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee.Spears Projectile.penetrate = -1; Projectile.ownerHitCheck = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; + Projectile.localNPCHitCooldown = 8; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/BrimlanceProj.cs b/Projectiles/Melee/Spears/BrimlanceProj.cs index 0dc86176b8..bb14457788 100644 --- a/Projectiles/Melee/Spears/BrimlanceProj.cs +++ b/Projectiles/Melee/Spears/BrimlanceProj.cs @@ -3,7 +3,6 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Projectiles/Melee/Spears/EarthenPikeSpear.cs b/Projectiles/Melee/Spears/EarthenPikeSpear.cs index 7101466f9a..1a43c3599e 100644 --- a/Projectiles/Melee/Spears/EarthenPikeSpear.cs +++ b/Projectiles/Melee/Spears/EarthenPikeSpear.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Projectiles/Melee/Spears/GildedProboscisProj.cs b/Projectiles/Melee/Spears/GildedProboscisProj.cs index 76bbf419ed..b4c31c6166 100644 --- a/Projectiles/Melee/Spears/GildedProboscisProj.cs +++ b/Projectiles/Melee/Spears/GildedProboscisProj.cs @@ -1,58 +1,275 @@ -using CalamityMod.Balancing; -using System; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.BaseProjectiles; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; +using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Spears { - public class GildedProboscisProj : BaseSpearProjectile + public class GildedProboscisProj : BaseSwordHoldoutProjectile, ILocalizedModType { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override void SetDefaults() + public new string LocalizationCategory => "Projectiles.Melee"; + public override bool useMeleeSpeed => false; + public override bool useMeleeSize => false; + public override int swingWidth => 360; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 0; + + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + + + public override float lineCollisionLength => 196; + + bool isChannelable = false; + + int channelCharge = 0; + + public override void Defaults() { - Projectile.width = Projectile.height = 40; - Projectile.DamageType = TrueMeleeDamageClass.Instance; - Projectile.timeLeft = 90; - Projectile.friendly = true; - Projectile.hostile = false; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 4; + Projectile.width = Projectile.height = 138; + Projectile.extraUpdates = 5; //ExtraUpdates help make the VFX smoother + Projectile.noEnchantmentVisuals = true; + } + public override void Spawn() + { + //This sets variables for the spear in general, as well as the secondary attack + //The secondary attack is the "default" because it was coded first + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 20; + CooldownTime = 41; + swingTime -= StartupTime + CooldownTime; + modplayer.swingNum = 0; + OffsetDistance = 70; + angle = new Vector2(angle.X > 0 ? 1 : -1, 0); + if (player.dashDelay == -1) + { + angle = new Vector2(-MathF.Sign(player.velocity.X), 0 ); + } + RotateInStartup = 0; + RotateInCooldown = 0; + + UseSound = SoundID.DD2_BetsysWrathImpact; + //This adjusts variables for the primary attack + if (player.altFunctionUse == 0) + { + UseSound = SoundID.DD2_JavelinThrowersAttack; + isChannelable = true; + RotateInStartup = 0.5f; + OffsetDistance = 10; + } } - // These numbers sure are common, huh? yeah, they are - public override float InitialSpeed => 3f; - public override float ReelbackSpeed => 2.4f; - public override float ForwardSpeed => 0.8f; - public override void ExtraBehavior() + public override void AdditionalAI() { - if (Main.rand.NextBool(4)) + var player = Main.player[Projectile.owner]; + //Primary attack is a chargable spear stab + //The DPS is worse than the secondary due to being able to charge it while out of range + //The goal gameplay loop is for the primary to be used when getting up close, than the secondary to be used while close + #region Primary Attack + if (isChannelable) { - int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RedTorch, Projectile.direction * 2, 0f, 150, default, 1f); - Main.dust[dust].noGravity = true; + //When channeling, the internal timer will not progress & the charge timer will go up + if (player.channel) + { + if (timer >= StartupTime - 1) + { + timer--; + Projectile.timeLeft++; + } + if (Projectile.FinalExtraUpdate() && channelCharge < CalamityUtils.SecondsToFrames(5)) + channelCharge++; + } + //Once not channeling, set the damage at the end of the startup + else + { + if (timer == StartupTime - 1) + Projectile.damage = (int)(Projectile.damage * 0.75 * (channelCharge / 75f)); //scales from 0x to 3x power + } + //Make the sprite rotation look right in game + Projectile.rotation -= (MathHelper.PiOver2) * (angle.X > 0 ? 1 : -1); + + //Adjust the offset distance (how close/far the weapon is held to the player) depending on charge during startup + //In cooldown or during the swing, these are based on how far completed the corresponding step is + if (inStartup) + { + OffsetDistance = (int)MathHelper.SmoothStep(40, 5, channelCharge / 300f); + } + if (inCooldown) + { + OffsetDistance = (int)MathHelper.SmoothStep(90, 60, MathF.Pow(CooldownCompletion, 1)); + + if (CooldownCompletion > 0.5f && Main.LocalPlayer.whoAmI == Projectile.owner && player.HeldItem.type == ModContent.ItemType() && Main.mouseRight) + { + player.itemAnimation = 1; + player.itemTime = 1; + Projectile.timeLeft = 1; + timer = StartupTime + swingTime + CooldownTime; + return; + } + } + + if (inSwing) + { + OffsetDistance = (int)MathHelper.Lerp(-40, 90, MathF.Pow(SwingCompletion, 1.7f)); + //Spawn the little sparks + var veloc = oldPlayerOffset - (Projectile.Center - Main.player[Projectile.owner].Center); + veloc.Normalize(); + if (swingTimer % 4 == 0) + { + for (int i2 = -1; i2 <= 1; i2 += 2) + { + int sparkLifetime = Main.rand.Next(15, 23); + + Vector2 sparkVel = Vector2.UnitY * -9f; + float maxRotationDeviance = 0.4f; + float rotationAngle = Main.rand.NextFloat(-maxRotationDeviance, maxRotationDeviance); + sparkVel = sparkVel.RotatedBy(rotationAngle) * Main.rand.NextFloat(0.3f, 1.0f); + + float sparkScale = Main.rand.NextFloat(0.007f, 0.015f); + + Vector2 compensatedSparkVel = angle.RotatedBy(i2 * -0.15f) * Main.rand.NextFloat(5, 10); + Vector2 pos = player.Center + angle.RotatedBy(MathHelper.Pi) * (OffsetDistance + Main.rand.NextFloat(30, 100)) * Projectile.scale + new Vector2(0, 10 * i2).RotatedByRandom(MathHelper.Pi - 0.2f); + + Particle spark = new GlowSparkParticle(pos, compensatedSparkVel, false, sparkLifetime, sparkScale, Main.rand.NextBool() ? Color.Red : Color.Gold, new Vector2(0.5f, 1.3f)); + GeneralParticleHandler.SpawnParticle(spark); + } + + } + //Spawn the large glow V + var sparkAngle = angle.RotatedBy(MathHelper.Pi); + int dir = MathF.Sign(sparkAngle.X); + var color = Color.Lerp(Color.Gold, Color.Crimson, SwingCompletion); + if (swingTimer % 2 == 0 || (swingTimer == swingTime - 1)) + for (int i = -1; i <= 1; i += 2) + { + Vector2 velocity = -sparkAngle.RotatedBy(i * -0.3f) * 10f; + Vector2 position = Projectile.Center + new Vector2(75, i * 22).RotatedBy(sparkAngle.ToRotation()); + Particle spark = new CustomSpark(position, velocity, "CalamityMod/Particles/BloomCircle", false, 10, 0.3f, color, new Vector2(0.3f, 3f), shrinkSpeed: 0.2f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + return; } + #endregion + //The secondary attack is based on Byleth's side-special from Smash Ultimate + //It moves the player forward when used, and is meant to be the higher DPS option of the two + #region Secondary Attack + + //Sets the max dash velocity depending on keys + //Base of 12, 4 when holding against the dash & 20 when holding with the dash + var dashStrength = 12; + if ((player.direction == 1 && player.controlLeft) || (player.direction == -1 && player.controlRight)) + dashStrength -= 8; + if ((player.direction == 1 && player.controlRight) || (player.direction == -1 && player.controlLeft)) + dashStrength += 8; + if (inStartup) + { + //Scale % offset distance during startup + Projectile.scale = baseScale * MathHelper.Lerp(0.9f, 0.65f, MathF.Pow(StartupCompletion, 2f)); + OffsetDistance = (int)MathHelper.Lerp(60f, 40f, MathF.Pow(StartupCompletion, 2f)); + ref var vel = ref Main.player[Projectile.owner].velocity; + //accel for player during dash + if (StartupCompletion > 0.5f && -vel.X * angle.X < dashStrength) + vel.X -= angle.X; + } + else if (inCooldown) + { + //Scale & offset distance during cooldown + Projectile.scale = baseScale * MathHelper.Lerp(1, 0.9f, 1 - MathF.Pow(1 - CooldownCompletion, 2)); + OffsetDistance = (int)MathHelper.Lerp(70, 60, 1 - MathF.Pow(1 - CooldownCompletion, 2)); + ref var vel = ref Main.player[Projectile.owner].velocity; + //decel for player after dash + if (CooldownCompletion < 0.25f && -vel.X * angle.X > 5) + vel.X *= 0.9f; + } + else + { + //scale & offset for the damaging swing part of the anim + //This keeps "am" (short for animation) at 0 or 1 most of the time, with a quick but smooth transition + float am = MathHelper.Clamp(MathF.Pow((SwingCompletion - (0.5f - (1 / 3f))) * 3f, 3f), 0, 1); + if (float.IsNaN(am)) + am = 0; + Projectile.scale = baseScale * MathHelper.Lerp(0.65f, 1, am); + am = MathHelper.Clamp(MathF.Pow((SwingCompletion - (0.3f - (1 / 3f))) * 3f, 3f), 0, 1); + if (float.IsNaN(am)) + am = 0; + OffsetDistance = (int)MathHelper.Lerp(40, 70, am); + //accel for player during dash + ref var vel = ref Main.player[Projectile.owner].velocity; + if (-vel.X * angle.X < dashStrength) + vel.X -= angle.X; + + var veloc = oldPlayerOffset - (Projectile.Center - Main.player[Projectile.owner].Center); + veloc.Normalize(); + //Little sparks + for (var i = 0; i < 2; i++) + { + int sparkLifetime = Main.rand.Next(15, 23); + + Vector2 sparkVel = Vector2.UnitY * -9f; + float maxRotationDeviance = 0.4f; + float rotationAngle = Main.rand.NextFloat(-maxRotationDeviance, maxRotationDeviance); + sparkVel = sparkVel.RotatedBy(rotationAngle) * Main.rand.NextFloat(0.3f, 1.0f); + + float sparkScale = Main.rand.NextFloat(0.007f, 0.015f); + + Vector2 compensatedSparkVel = veloc * Main.rand.NextFloat(2, 5); + Particle spark = new GlowSparkParticle(Projectile.Center + new Vector2(-angle.X, Main.rand.NextFloat(-0.05f, 0.05f)).RotatedBy(Projectile.rotation) * Main.rand.NextFloat(50, 120) * Projectile.scale, compensatedSparkVel, false, sparkLifetime, sparkScale, Main.rand.NextBool() ? Color.Red : Color.Gold, new Vector2(0.5f, 1.3f)); + GeneralParticleHandler.SpawnParticle(spark); + + } + // Smoke/fire effect + Color[] smokeColor = { Color.Red, Color.Goldenrod, Color.Crimson }; + Vector2 smokePosition = Projectile.Center + new Vector2(-angle.X, Main.rand.NextFloat(-0.05f, 0.05f)).RotatedBy(Projectile.rotation) * 80 * Projectile.scale; + for (var i = 0; i < 3; i++) + { + Particle beam4 = new CustomSpark(smokePosition, smokePosition.DirectionTo(Main.player[Projectile.owner].Center), "CalamityMod/ExtraTextures/Trails/ScarletDevilStreak", false, 10, 0.6f * Projectile.scale, smokeColor[timer % 3], new Vector2(1f, 1), true, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(beam4); + } + } + Projectile.rotation -= (MathHelper.PiOver2) * angle.X; + #endregion + } + + public override float SwingFunction() + { + if (isChannelable) //Primary attack + { + if (inStartup && channelCharge >= CalamityUtils.SecondsToFrames(5)) + { + //shake when fully charged + return Main.rand.NextFloat(-0.025f, 0.025f); + } + return 0; //Primary attack should face the mouse direction directly + } + //Everything else is secondary attack + if (inStartup) + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * 0.7f, swingWidth * 0.33f, MathF.Pow(StartupCompletion, 4f))); + if (inCooldown) + return MathHelper.ToRadians(MathHelper.Lerp(-swingWidth * 0.2f, -swingWidth * 0.3f, 1 - MathF.Pow(1 - CooldownCompletion, 3f))); + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * 0.33f, -swingWidth * 0.2f, SwingCompletion)); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 900); + Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, (int)Math.Round(hit.Damage * 0.0015)); + if (Projectile.damage > 1) + Projectile.damage = (int)(Projectile.damage * 0.85f); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); - int heal = (int)Math.Round(hit.Damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + float critDamage = Math.Min(Main.player[Projectile.owner].GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); + modifiers.SourceDamage *= 1 + critDamage; } } } diff --git a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs index 88f394f1cc..8d20e38bb7 100644 --- a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs +++ b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public override void SetDefaults() { Projectile.width = Projectile.height = 40; - Projectile.DamageType = DamageClass.Melee; //Dictates whether this is a melee-class weapon. + Projectile.DamageType = TrueMeleeDamageClass.Instance; Projectile.timeLeft = 90; Projectile.friendly = true; Projectile.hostile = false; @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public override float ForwardSpeed => 0.8f; public override Action EffectBeforeReelback => (proj) => { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 2.4f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.65), Projectile.knockBack * 0.85f, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 2f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 0.85f, Projectile.owner); }; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Melee/Spears/NadirSpear.cs b/Projectiles/Melee/Spears/NadirSpear.cs index 672789f03f..1f02d2c570 100644 --- a/Projectiles/Melee/Spears/NadirSpear.cs +++ b/Projectiles/Melee/Spears/NadirSpear.cs @@ -71,6 +71,6 @@ namespace CalamityMod.Projectiles.Melee.Spears Main.dust[idx].velocity = Vector2.Zero; } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/Projectiles/Melee/Spears/SausageMakerSpear.cs b/Projectiles/Melee/Spears/SausageMakerSpear.cs index c46d1c22cd..0bb3d152c0 100644 --- a/Projectiles/Melee/Spears/SausageMakerSpear.cs +++ b/Projectiles/Melee/Spears/SausageMakerSpear.cs @@ -22,6 +22,8 @@ namespace CalamityMod.Projectiles.Melee.Spears Projectile.ignoreWater = true; Projectile.penetrate = -1; Projectile.ownerHitCheck = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/YateveoBloomSpear.cs b/Projectiles/Melee/Spears/YateveoBloomSpear.cs index 5acc6d3ecc..21d14c9015 100644 --- a/Projectiles/Melee/Spears/YateveoBloomSpear.cs +++ b/Projectiles/Melee/Spears/YateveoBloomSpear.cs @@ -3,7 +3,6 @@ using CalamityMod.Projectiles.BaseProjectiles; using Terraria; using Terraria.ID; using Terraria.Localization; -using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee.Spears { @@ -22,6 +21,8 @@ namespace CalamityMod.Projectiles.Melee.Spears Projectile.ignoreWater = true; Projectile.penetrate = -1; Projectile.ownerHitCheck = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/StarburstBeam.cs b/Projectiles/Melee/StarburstBeam.cs deleted file mode 100644 index 788aa3c149..0000000000 --- a/Projectiles/Melee/StarburstBeam.cs +++ /dev/null @@ -1,76 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee -{ - public class StarburstBeam : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; - public override void SetDefaults() - { - Projectile.width = 20; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 2; - Projectile.tileCollide = false; - Projectile.timeLeft = 60; - Projectile.aiStyle = ProjAIStyleID.Beam; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[rainbow].noGravity = true; - Main.dust[rainbow].velocity = Vector2.Zero; - - CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f); - } - - public override bool PreDraw(ref Color lightColor) - { - if (Projectile.timeLeft > 50) - return false; - - return true; - } - - public override void OnKill(int timeLeft) - { - for (int k = 0; k < 2; k++) - { - int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[rainbow].noGravity = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 30); - OnHitEffects(target.Center); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - OnHitEffects(target.Center); - } - - private void OnHitEffects(Vector2 targetPos) - { - var source = Projectile.GetSource_FromThis(); - for (int x = 0; x < 3; x++) - { - if (Projectile.owner == Main.myPlayer) - { - CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, x > 2, 800f, 800f, 0f, 800f, 20f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, false, 50f); - } - } - } - } -} diff --git a/Projectiles/Melee/StarburstBeam.png b/Projectiles/Melee/StarburstBeam.png deleted file mode 100644 index 01a8a875ef..0000000000 Binary files a/Projectiles/Melee/StarburstBeam.png and /dev/null differ diff --git a/Projectiles/Melee/StarburstSHIV.cs b/Projectiles/Melee/StarburstSHIV.cs deleted file mode 100644 index 6bdbcae1a7..0000000000 --- a/Projectiles/Melee/StarburstSHIV.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Melee -{ - public class StarburstSHIV : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Melee"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 15; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 20; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 1; - Projectile.tileCollide = false; - Projectile.timeLeft = 90; - Projectile.aiStyle = ProjAIStyleID.Beam; - Projectile.extraUpdates = 1; - } - - public override void AI() - { - CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f); - - int rainbow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[rainbow].noGravity = true; - Main.dust[rainbow].velocity = Vector2.Zero; - } - - public override void OnKill(int timeLeft) - { - int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.RainbowTorch, (float)(Projectile.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[rainbow].noGravity = true; - } - - public override bool PreDraw(ref Color lightColor) - { - if (Projectile.timeLeft > 85) - return false; - - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Melee/StarburstSHIV.png b/Projectiles/Melee/StarburstSHIV.png deleted file mode 100644 index 01a8a875ef..0000000000 Binary files a/Projectiles/Melee/StarburstSHIV.png and /dev/null differ diff --git a/Projectiles/Melee/StarofJudgement.cs b/Projectiles/Melee/StarofJudgement.cs index 7d8e9fb74c..b370747d9f 100644 --- a/Projectiles/Melee/StarofJudgement.cs +++ b/Projectiles/Melee/StarofJudgement.cs @@ -1,12 +1,11 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using CalamityMod.Particles; using Terraria.ModLoader; using Microsoft.Xna.Framework.Graphics; using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; namespace CalamityMod.Projectiles.Melee { @@ -40,31 +39,37 @@ namespace CalamityMod.Projectiles.Melee { if (time == 0) { - Projectile.scale = (Projectile.ai[2] == 1 ? 0.75f : 0.5f); mainColor = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; + Projectile.scale = (Projectile.ai[2] == 1 ? 0.75f : 0.5f); if (Projectile.ai[2] == 1) { - Projectile.localNPCHitCooldown = 7; - Projectile.penetrate = 4; + Projectile.localNPCHitCooldown = -1; + Projectile.penetrate = 1; + Projectile.extraUpdates = 1; } } Projectile.rotation += (Projectile.velocity.X + MathF.Abs(Projectile.velocity.Y) * Projectile.direction) * 0.01f; if (Projectile.ai[2] == 1) { - CalamityUtils.HomeInOnNPC(Projectile, true, 900f, 25, MathHelper.Clamp(30 - time, 15, 30)); - if (Main.rand.NextBool(4) && Projectile.numHits < 1) + if (time > 18) { - Particle spark = new GlowOrbParticle(Projectile.Center + Main.rand.NextVector2Circular(7, 7) - Projectile.velocity, -Projectile.velocity * Main.rand.NextFloat(0.5f, 0.8f), false, 13, 1f, mainColor * 0.5f); + CalamityUtils.HomeInOnNPC(Projectile, true, 900f, 25, MathHelper.Clamp(30 - time, 15, 30)); + } + else + Projectile.velocity = Projectile.velocity.RotatedBy(0.085f * Projectile.ai[1]); + if (time % 2 == 0) + { + Particle spark = new CustomSpark(Projectile.Center, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 13, 0.35f, mainColor * 0.75f, new Vector2(0.8f, 1.35f), true, false, shrinkSpeed: 0.3f); GeneralParticleHandler.SpawnParticle(spark); } } - else if (time > 15) + if (Projectile.ai[2] != 1 && time > 10) { CalamityUtils.HomeInOnNPC(Projectile, true, 700f * (Projectile.numHits > 1 ? 2 : 1), 20, 20f * (Projectile.numHits > 1 ? 5 : 1)); if (Main.rand.NextBool(3)) { - Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Projectile.velocity, 66); + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Projectile.velocity, ModContent.DustType()); trailDust.scale = Main.rand.NextFloat(0.7f, 0.85f); trailDust.velocity = -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.5f); trailDust.color = Main.rand.NextBool() ? Color.MediumPurple : Color.MediumOrchid; @@ -84,18 +89,19 @@ namespace CalamityMod.Projectiles.Melee Vector2 rotationPoint = texture.Size() * 0.5f; CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], drawColor * 0.5f, 1, texture, true, true); Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + Main.EntitySpriteDraw(texture, drawPosition, null, Color.White with { A = 0 }, drawRotation, rotationPoint, Projectile.scale * 0.8f, SpriteEffects.None); return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - int buffType = Projectile.ai[2] == 1f ? ModContent.BuffType() : ModContent.BuffType(); - target.AddBuff(buffType, 60); + if (!target.CanBeChasedBy()) + Projectile.penetrate++; if (Projectile.ai[2] == 0) { Projectile.timeLeft = 180; time = 0; - Projectile.velocity *= 1.2f; + Projectile.velocity *= 1.1f; } } public override void OnKill(int timeLeft) diff --git a/Projectiles/Melee/StarofOrder.cs b/Projectiles/Melee/StarofOrder.cs new file mode 100644 index 0000000000..958b843c75 --- /dev/null +++ b/Projectiles/Melee/StarofOrder.cs @@ -0,0 +1,117 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class StarofOrder : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float time => ref Projectile.ai[0]; + public Color mainColor; + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 12; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 44; + Projectile.height = 44; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 4; + Projectile.tileCollide = false; + Projectile.timeLeft = 180; + Projectile.DamageType = DamageClass.Melee; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 7; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + mainColor = player.Calamity().lightRGB; + if (time == 0) + { + Projectile.scale = Main.rand.NextFloat(0.65f, 0.8f); + } + float sine = (float)Math.Sin(time * 0.575f * Projectile.scale / MathHelper.Pi); + + Projectile.rotation = 0.25f * sine; + if (time < 20) + { + Projectile.extraUpdates = 1; + Projectile.velocity = Projectile.velocity.RotatedBy(-Projectile.ai[1] * 0.05f); + } + else + { + Projectile.extraUpdates = 0; + CalamityUtils.HomeInOnNPC(Projectile, true, 900f, 25, MathHelper.Clamp(30 - time, 15, 30)); + } + if (time % 2 == 0 && Projectile.numHits < 1) + { + Particle spark = new CustomSpark(Projectile.Center, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 13, 0.35f, mainColor * 0.75f, new Vector2(0.8f, 1.35f), true, false, shrinkSpeed: 0.3f); + GeneralParticleHandler.SpawnParticle(spark); + } + + time++; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Color.Lerp(mainColor, Color.White, 0.2f) with { A = 0 }; + float drawRotation = Projectile.rotation; + Vector2 rotationPoint = texture.Size() * 0.5f; + //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], drawColor * 0.5f, 1, texture, true, true); + bool roted = true; + for (int i = 0; i < 5; i++) + { + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, (roted ? 0 : MathHelper.PiOver2) + Projectile.rotation, rotationPoint, new Vector2(1 - 0.12f * i, 1 + 0.75f * i) * Projectile.scale * 0.2f * Main.rand.NextFloat(0.8f, 1.1f), SpriteEffects.None); + if (roted && i == 4) + { + i = -1; + roted = false; + } + } + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + int buffType = ModContent.BuffType(); + target.AddBuff(buffType, 60); + + if (Projectile.ai[2] == 0) + { + Projectile.timeLeft = 180; + time = 0; + Projectile.velocity *= 1.2f; + } + } + public override void OnKill(int timeLeft) + { + int points = 4; + float radians = MathHelper.TwoPi / points; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f).RotatedBy(Projectile.rotation)); + for (int k = 0; k < points; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velocity * 2, ModContent.DustType(), velocity * 8); + dust.scale = 3.5f; + dust.color = mainColor; + dust.noGravity = true; + dust.fadeIn = 6f; + } + } + } +} diff --git a/Projectiles/Melee/StellarContemptEcho.cs b/Projectiles/Melee/StellarContemptEcho.cs index f13e8eb5ca..505e533945 100644 --- a/Projectiles/Melee/StellarContemptEcho.cs +++ b/Projectiles/Melee/StellarContemptEcho.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Melee { for (int i = 0; i < 20; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, ((targeted.Center - Projectile.Center).SafeNormalize(Vector2.UnitX) * 25).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, ((targeted.Center - Projectile.Center).SafeNormalize(Vector2.UnitX) * 25).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.8f, 1.9f); dust.color = Main.rand.NextBool(3) ? Color.PaleTurquoise : Color.Turquoise; @@ -123,7 +123,7 @@ namespace CalamityMod.Projectiles.Melee Player player = Main.player[Projectile.owner]; // This is what we call fucking IMPACT (2). - Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 7; + Main.player[Projectile.owner].SetScreenshake(7f); if (Main.zenithWorld) SoundEngine.PlaySound(Kunk, Projectile.Center); diff --git a/Projectiles/Melee/StellarContemptHammer.cs b/Projectiles/Melee/StellarContemptHammer.cs index c46e2eb20a..680985e763 100644 --- a/Projectiles/Melee/StellarContemptHammer.cs +++ b/Projectiles/Melee/StellarContemptHammer.cs @@ -171,7 +171,7 @@ namespace CalamityMod.Projectiles.Melee velOffset *= Main.rand.NextFloat(25, 45) * fade; Particle energy = new SparkParticle(Projectile.Center + velOffset * 2.5f, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, false, 14, Main.rand.NextFloat(1.1f, 1.25f) - 0.5f * fade, Color.Turquoise); GeneralParticleHandler.SpawnParticle(energy); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, 278, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, DustID.FireworksRGB, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); dust.noGravity = true; dust.color = Color.Turquoise; dust.velocity += Projectile.velocity; diff --git a/Projectiles/Melee/StellarStrikerHoldout.cs b/Projectiles/Melee/StellarStrikerHoldout.cs index 6b1346c954..5dfff076cc 100644 --- a/Projectiles/Melee/StellarStrikerHoldout.cs +++ b/Projectiles/Melee/StellarStrikerHoldout.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -8,12 +9,13 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class StellarStrikerHoldout : BaseCustomUseStyleProjectile, ILocalizedModType { public override int AssignedItemID => ModContent.ItemType(); @@ -204,7 +206,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++) { - Dust dust2 = Dust.NewDustPerfect(target.Center, 278, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.4) * Main.rand.NextFloat(0.2f, 1f)); + Dust dust2 = Dust.NewDustPerfect(target.Center, DustID.FireworksRGB, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -20).RotatedByRandom(0.4) * Main.rand.NextFloat(0.2f, 1f)); dust2.scale = Main.rand.NextFloat(0.55f, 0.95f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.PaleTurquoise : Color.Turquoise; @@ -218,7 +220,7 @@ namespace CalamityMod.Projectiles.Melee if (spawnBoom) { Vector2 spawnSpot = target.Center + new Vector2(Main.rand.NextFloat(-550, 550), Main.rand.NextFloat(-750, -950)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnSpot, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 2.25f), Projectile.knockBack, Projectile.owner, 0, 0, 7); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnSpot, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner, 0, 0, 7); spawnBoom = false; } @@ -237,9 +239,12 @@ namespace CalamityMod.Projectiles.Melee if ((useAnim > 0 || DrawUnconditionally) && Owner.ItemAnimationActive) { Asset tex = ModContent.Request(Texture); + Asset swoosh = ModContent.Request("CalamityMod/Particles/CircularSmearSmokey"); float r = FlipAsSword ? MathHelper.ToRadians(90) : 0f; + Main.EntitySpriteDraw(swoosh.Value, Owner.Center - Main.screenPosition, null, Color.Turquoise with { A = 0 } * (float)Math.Pow(fadeIn, 3), Projectile.rotation + MathHelper.PiOver4 * Owner.direction + RotationOffset * 1.75f, swoosh.Size() * 0.5f, Projectile.scale * 2f, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); + for (int i = 0; i < 25; i++) { Texture2D centerTexture = ModContent.Request("CalamityMod/Projectiles/Melee/StellarStrikerGhost").Value; diff --git a/Projectiles/Melee/StellarStrikerMeteor.cs b/Projectiles/Melee/StellarStrikerMeteor.cs index 5b47d38907..0cfc50fec9 100644 --- a/Projectiles/Melee/StellarStrikerMeteor.cs +++ b/Projectiles/Melee/StellarStrikerMeteor.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * wavePower; - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset * direction, 267, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset * direction, DustID.RainbowMk2, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.3f)); dust.scale = Main.rand.NextFloat(0.85f, 0.95f); dust.noGravity = true; dust.color = Main.rand.NextBool(3) ? Color.PaleTurquoise : Color.Turquoise; @@ -143,7 +143,7 @@ namespace CalamityMod.Projectiles.Melee } for (int i = 0; i < 18; i++) { - Dust c = Dust.NewDustPerfect(Projectile.Center, 267); + Dust c = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); c.velocity = (MathHelper.TwoPi * i / 18f).ToRotationVector2() * 10f + Owner.velocity * 0.5f; c.scale = Main.rand.NextFloat(0.8f, 0.9f); c.noGravity = true; diff --git a/Projectiles/Melee/StormRulerProj.cs b/Projectiles/Melee/StormRulerProj.cs index 337f994549..53d6b7b334 100644 --- a/Projectiles/Melee/StormRulerProj.cs +++ b/Projectiles/Melee/StormRulerProj.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/StygianShieldAttack.cs b/Projectiles/Melee/StygianShieldAttack.cs index ed2b80decf..738b46d0ca 100644 --- a/Projectiles/Melee/StygianShieldAttack.cs +++ b/Projectiles/Melee/StygianShieldAttack.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Melee } public override void AI() { - if (Owner is null || Owner.dead || Owner.ActiveItem().type != ModContent.ItemType()) + if (Owner is null || Owner.dead || Owner.HeldItem.type != ModContent.ItemType()) Projectile.Kill(); Owner.heldProj = Projectile.whoAmI; @@ -179,13 +179,13 @@ namespace CalamityMod.Projectiles.Melee GeneralParticleHandler.SpawnParticle(redSlash); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = Utils.GetLerpValue(1f, 0.2f, completionRatio, true) * Projectile.Opacity; return Color.Lerp(Color.DarkOrange, Color.Red, completionRatio) * fadeOpacity; } - internal float WidthFunction(float completionRatio) => 12f; + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => 12f; public override bool PreDraw(ref Color lightColor) { @@ -220,7 +220,7 @@ namespace CalamityMod.Projectiles.Melee // Main trail GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + extraOffset + Main.screenPosition - direction * 80f, + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + extraOffset + Main.screenPosition - direction * 80f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 10); ArrowEffect.Parameters["halfSpreadAngle"].SetValue(MathHelper.ToRadians(7.5f)); diff --git a/Projectiles/Melee/StygianShieldThrown.cs b/Projectiles/Melee/StygianShieldThrown.cs index c786c5a669..3d64ac9bb8 100644 --- a/Projectiles/Melee/StygianShieldThrown.cs +++ b/Projectiles/Melee/StygianShieldThrown.cs @@ -1,6 +1,5 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using ReLogic.Utilities; using System.Collections.Generic; diff --git a/Projectiles/Melee/TaintedBladeSlasher.cs b/Projectiles/Melee/TaintedBladeSlasher.cs index c17cd585cf..a2f770befa 100644 --- a/Projectiles/Melee/TaintedBladeSlasher.cs +++ b/Projectiles/Melee/TaintedBladeSlasher.cs @@ -129,15 +129,15 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - CalamityPlayer.EnchantHeldItemEffects(Owner, Owner.Calamity(), Owner.ActiveItem()); - if (!Owner.Calamity().bladeArmEnchant || Owner.ActiveItem().type != SwordItemID || Owner.CCed || !Owner.active || Owner.dead) + CalamityPlayer.EnchantHeldItemEffects(Owner, Owner.Calamity(), Owner.HeldItem); + if (!Owner.Calamity().bladeArmEnchant || Owner.HeldItem.type != SwordItemID || Owner.CCed || !Owner.active || Owner.dead) { Projectile.Kill(); return; } if (Owner.itemAnimationMax == 0) - Owner.itemAnimationMax = (int)(Owner.ActiveItem().useAnimation * Owner.GetAttackSpeed()); + Owner.itemAnimationMax = (int)(Owner.HeldItem.useAnimation * Owner.GetAttackSpeed()); float swingOffsetAngle = MathHelper.SmoothStep(-1.87f, 3.79f, AttackCompletionRatio); @@ -198,9 +198,9 @@ namespace CalamityMod.Projectiles.Melee Time++; } - internal float PrimitiveWidthFunction(float completionRatio) => BladeFrame.Height * 0.47f; + internal float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) => BladeFrame.Height * 0.47f; - internal Color PrimitiveColorFunction(float completionRatio) + internal Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float opacity = Utils.GetLerpValue(0.8f, 0.52f, completionRatio, true) * Utils.GetLerpValue(1f, 0.81f, AttackCompletionRatio, true); Color startingColor = Color.Lerp(Color.Red, Color.DarkRed, 0.4f); @@ -263,7 +263,7 @@ namespace CalamityMod.Projectiles.Melee if (Owner.direction == -1) Utils.Swap(ref leftVertexPosition, ref rightVertexPosition); - PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => BladeCenterPosition - Projectile.position, + PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => BladeCenterPosition - Projectile.position, shader: GameShaders.Misc["CalamityMod:FadingSolidTrail"], initialVertexPositionsOverride: (leftVertexPosition, rightVertexPosition)), 67); } @@ -289,8 +289,8 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, hit, damageDone); - NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), hit, damageDone); + ItemLoader.OnHitNPC(Owner.HeldItem, Owner, target, hit, damageDone); + NPCLoader.OnHitByItem(target, Owner, Owner.HeldItem, hit, damageDone); PlayerLoader.OnHitNPC(Owner, target, hit, damageDone); } } diff --git a/Projectiles/Melee/TenebreusTidesWaterSpear.cs b/Projectiles/Melee/TenebreusTidesWaterSpear.cs index 97a536f5f8..ff6e8d1a3a 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSpear.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSpear.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -183,7 +182,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] += 1f; - int water = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.4f); + int water = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Water, 0f, 0f, 100, default, 0.4f); Main.dust[water].noGravity = true; Main.dust[water].velocity *= 0.5f; Main.dust[water].velocity += Projectile.velocity * 0.1f; diff --git a/Projectiles/Melee/TenebreusTidesWaterSword.cs b/Projectiles/Melee/TenebreusTidesWaterSword.cs index 272ea31e28..d4ab7c49f2 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSword.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSword.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -165,7 +164,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.localAI[0] += 1f; - int water = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.4f); + int water = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Water, 0f, 0f, 100, default, 0.4f); Main.dust[water].noGravity = true; Main.dust[water].velocity *= 0.5f; Main.dust[water].velocity += Projectile.velocity * 0.1f; diff --git a/Projectiles/Melee/TerratomereHoldoutProj.cs b/Projectiles/Melee/TerratomereHoldoutProj.cs index 4be39fcdda..b5ecb88747 100644 --- a/Projectiles/Melee/TerratomereHoldoutProj.cs +++ b/Projectiles/Melee/TerratomereHoldoutProj.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using CalamityMod.Balancing; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -161,7 +159,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.myPlayer == Projectile.owner && Time == (int)(Terratomere.SwingTime * (SwingCompletionRatio + 0.34f))) { // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 bigSlashVelocity = Projectile.SafeDirectionTo(Main.MouseWorld) * Owner.ActiveItem().shootSpeed / 2f; + Vector2 bigSlashVelocity = Projectile.SafeDirectionTo(Main.MouseWorld) * Owner.HeldItem.shootSpeed / 2f; if (bigSlashVelocity.AngleBetween(InitialRotation.ToRotationVector2()) > 1.456f) bigSlashVelocity = InitialRotation.ToRotationVector2() * bigSlashVelocity.Length(); @@ -177,7 +175,7 @@ namespace CalamityMod.Projectiles.Melee // Close range slash effect if (Main.myPlayer == Projectile.owner && Time == (int)(Terratomere.SwingTime * RecoveryCompletionRatio) + 5f) { - Vector2 bigSlashVelocity = InitialRotation.ToRotationVector2() * Owner.ActiveItem().shootSpeed / 6f; + Vector2 bigSlashVelocity = InitialRotation.ToRotationVector2() * Owner.HeldItem.shootSpeed / 6f; Vector2 bigSlashSpawnPosition = Projectile.Center + bigSlashVelocity.SafeNormalize(Vector2.UnitY) * 64f; int slash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), bigSlashSpawnPosition, bigSlashVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); @@ -221,9 +219,9 @@ namespace CalamityMod.Projectiles.Melee return false; } - public float SlashWidthFunction(float completionRatio) => Projectile.scale * 22f; + public float SlashWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 22f; - public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity; + public Color SlashColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity; public IEnumerable GenerateSlashPoints() { @@ -248,7 +246,7 @@ namespace CalamityMod.Projectiles.Melee PrepareSlashShader(Direction == 1); if (SwingCompletionAtStartOfTrail > SwingCompletionRatio) - PrimitiveRenderer.RenderTrail(GenerateSlashPoints().ToArray(), new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 95); + PrimitiveRenderer.RenderTrail(GenerateSlashPoints().ToArray(), new(SlashWidthFunction, SlashColorFunction, (_,_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 95); Main.spriteBatch.ExitShaderRegion(); } @@ -277,19 +275,6 @@ namespace CalamityMod.Projectiles.Melee #endregion Drawing #region Hit Effects and Collision - - public void OnHitHealEffect(int damage) - { - int heal = (int)Math.Round(damage * 0.025); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); - } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { float point = 0f; @@ -300,9 +285,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), Terratomere.TrueMeleeGlacialStateTime); - - if (target.lifeMax > 5) - OnHitHealEffect(hit.Damage); + Owner.DoLifestealDirect(target, (int)Math.Round(hit.Damage * 0.025), 0.75f); // Create a slash creator on top of the hit target. int slashCreatorID = ModContent.ProjectileType(); @@ -312,12 +295,6 @@ namespace CalamityMod.Projectiles.Melee Owner.ownedProjectileCounts[slashCreatorID]++; } } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), Terratomere.TrueMeleeGlacialStateTime); - OnHitHealEffect(info.Damage); - } #endregion Hit Effects and Collision } } diff --git a/Projectiles/Melee/TerratomereMeleeSlash.cs b/Projectiles/Melee/TerratomereMeleeSlash.cs index 3445abe5ee..50dc9223d7 100644 --- a/Projectiles/Melee/TerratomereMeleeSlash.cs +++ b/Projectiles/Melee/TerratomereMeleeSlash.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ModLoader; @@ -40,9 +39,9 @@ namespace CalamityMod.Projectiles.Melee Projectile.scale *= 1.01f; } - public float SlashWidthFunction(float completionRatio) => Projectile.scale * 22f; + public float SlashWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 22f; - public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.04f, 0.27f, completionRatio, true) * Projectile.Opacity; + public Color SlashColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lime * Utils.GetLerpValue(0.04f, 0.27f, completionRatio, true) * Projectile.Opacity; public override bool PreDraw(ref Color lightColor) { @@ -56,7 +55,7 @@ namespace CalamityMod.Projectiles.Melee points.Add(ControlPoints[i] + ControlPoints[i].SafeNormalize(Vector2.Zero) * (Projectile.scale - 1f) * 40f); // 17MAY2024: Ozzatron: remove Terratomere rendering its trails multiple times - PrimitiveRenderer.RenderTrail(points, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65); + PrimitiveRenderer.RenderTrail(points, new(SlashWidthFunction, SlashColorFunction, (_,_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65); Main.spriteBatch.ExitShaderRegion(); return false; diff --git a/Projectiles/Melee/TerratomereSlash.cs b/Projectiles/Melee/TerratomereSlash.cs index fa00458626..4dcd4bc317 100644 --- a/Projectiles/Melee/TerratomereSlash.cs +++ b/Projectiles/Melee/TerratomereSlash.cs @@ -1,8 +1,6 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Melee/TerratomereSwordBeam.cs b/Projectiles/Melee/TerratomereSwordBeam.cs index ae999701c0..c11aa55bc5 100644 --- a/Projectiles/Melee/TerratomereSwordBeam.cs +++ b/Projectiles/Melee/TerratomereSwordBeam.cs @@ -52,9 +52,9 @@ namespace CalamityMod.Projectiles.Melee dust.fadeIn = 0.5f; } - public float SlashWidthFunction(float _) => Projectile.width * Projectile.scale * Utils.GetLerpValue(0f, 0.1f, _, true); + public float SlashWidthFunction(float _, Vector2 vertexPos) => Projectile.width * Projectile.scale * Utils.GetLerpValue(0f, 0.1f, _, true); - public Color SlashColorFunction(float _) => Color.Turquoise; + public Color SlashColorFunction(float _, Vector2 vertexPos) => Color.Turquoise; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Terratomere.TerraColor2); // 17MAY2024: Ozzatron: remove Terratomere rendering its trails multiple times - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); return false; } diff --git a/Projectiles/Melee/TerrorBeam.cs b/Projectiles/Melee/TerrorBeam.cs index 1f00829413..deb709ce2e 100644 --- a/Projectiles/Melee/TerrorBeam.cs +++ b/Projectiles/Melee/TerrorBeam.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Melee/TerrorBlast.cs b/Projectiles/Melee/TerrorBlast.cs index 2352264195..b35662a364 100644 --- a/Projectiles/Melee/TerrorBlast.cs +++ b/Projectiles/Melee/TerrorBlast.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/ThanatosBoom.cs b/Projectiles/Melee/ThanatosBoom.cs index 723013e72c..f3da8385f9 100644 --- a/Projectiles/Melee/ThanatosBoom.cs +++ b/Projectiles/Melee/ThanatosBoom.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -41,7 +42,7 @@ namespace CalamityMod.Projectiles.Melee float lifePersistance = Main.rand.NextFloat(0.8f, 1.7f); for (int i = 0; i < 60; i++) { - Dust energy = Dust.NewDustPerfect(Projectile.Center, 267); + Dust energy = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); energy.velocity = (MathHelper.TwoPi * i / 60f).ToRotationVector2() * speed; energy.noGravity = true; energy.color = Main.hslToRgb(Main.rand.NextFloat(), 0.7f, 0.625f); diff --git a/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs b/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs new file mode 100644 index 0000000000..843103b40d --- /dev/null +++ b/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs @@ -0,0 +1,111 @@ +using System; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Healing; +using Terraria.Audio; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; + +namespace CalamityMod.Projectiles.Melee +{ + public class MutilatorSwordProj : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override int swingWidth => 180; + public override string Texture => ModContent.GetModItem(BaseItem.type).Texture; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 5; + public override int OffsetDistance => 60; + public override bool drawSwordTrail => true; + public override Color[] trailColors => [Color.Red, Color.DarkRed, Color.Gold]; + + public override float trailOffset => 20; + + public override float trailWidth(float completion, Vector2 vertexPos) + { + return base.trailWidth(completion, vertexPos); + } + + public override int trailLength => 5; + + public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + + public override SoundStyle? UseSound => SoundID.Item1; + + + public bool hasGivenBlood = false; + + public override void Spawn() + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 15; + CooldownTime = 5; + swingTime -= StartupTime + CooldownTime; + modplayer.swingNum = 0; + } + + public override void AdditionalAI() + { + if (inStartup) + { + Projectile.scale = baseScale * MathHelper.Lerp(0.5f, 1, 1 - MathF.Pow(1 - StartupCompletion, 2f)); + } else if (inCooldown) + { + Projectile.scale = baseScale * MathHelper.Lerp(1,0.5f,MathF.Pow(CooldownCompletion,2)); + } else + Projectile.scale = baseScale * Math.Min(MathHelper.SmoothStep(1, 2, SwingCompletion), MathHelper.SmoothStep(2, 1, SwingCompletion)); + } + + public override float SwingFunction() + { + if (inStartup) + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.5f, -swingWidth * 0.75f, 1-MathF.Pow(1-StartupCompletion,2f))); + if (inCooldown) + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * 0.25f, swingWidth * 0.33f, CooldownCompletion)); + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth *0.75f, swingWidth *0.25f, SwingCompletion)); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + var player = Main.player[Projectile.owner]; + var item = player.HeldItem; + if (item.type != ModContent.ItemType()) + { + Projectile.Kill(); + return; + } + var modItem = item.ModItem as TheMutilator; + if (!hasGivenBlood) + { + modItem.Charge++; + hasGivenBlood = true; + if (modItem.Charge > TheMutilator.MaximumCharge) + { + modItem.Charge = 0; + int orbAmount = 30; + if (orbAmount > 0) + { + float spreadAmount = MathHelper.ToRadians(360); + for (var i = 0; i < orbAmount; i++) + { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), target.Center, -angle.RotatedByRandom(spreadAmount) * 3.5f * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 20, 0f, player.whoAmI); + + } + Particle bloodsplosion2 = new CustomPulse(target.Center, Vector2.Zero, new Color(255, 32, 32) * 0.75f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f, 0.155f, 40); + GeneralParticleHandler.SpawnParticle(bloodsplosion2); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BloodPactCrit") { Volume = 0.5f }, player.Center); + } + } + modItem.DecayTimer = 180; + } + } + } +} diff --git a/Projectiles/Melee/TinyFlare.cs b/Projectiles/Melee/TinyFlare.cs index 09b459f960..a2718e7105 100644 --- a/Projectiles/Melee/TinyFlare.cs +++ b/Projectiles/Melee/TinyFlare.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/TriactisHammerExplosion.cs b/Projectiles/Melee/TriactisHammerExplosion.cs index af160569b0..5741b0bd64 100644 --- a/Projectiles/Melee/TriactisHammerExplosion.cs +++ b/Projectiles/Melee/TriactisHammerExplosion.cs @@ -4,9 +4,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee @@ -47,7 +45,7 @@ namespace CalamityMod.Projectiles.Melee GeneralParticleHandler.SpawnParticle(blastG); Particle blastB = new CustomPulse(Projectile.Center, Vector2.Zero, TriactisHammerFlare.GetColor(3f) * 0.7f, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, rotation + MathHelper.ToRadians(240f), 0f, 0.4f, 24); GeneralParticleHandler.SpawnParticle(blastB); - Owner.Calamity().GeneralScreenShakePower = 40; + Owner.SetScreenshake(40f); } if (Timer % 4f == 0f) @@ -84,13 +82,17 @@ namespace CalamityMod.Projectiles.Melee public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 640f, targetHitbox); - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.HitDirectionOverride = (Owner.Center.X < target.Center.X).ToDirectionInt(); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.HitDirectionOverride = (Owner.Center.X < target.Center.X).ToDirectionInt(); + modifiers.SourceDamage *= Utils.Remap(Projectile.numHits, 0, 10, 1f, 0.1f, true); + } - internal float WidthFunction(float completionRatio) => MathHelper.Clamp(CalamityUtils.Convert01To010(completionRatio * 2), 0.2f, 1f) * 4f; - internal Color ColorFunction(float completionRatio) => Color.White; + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Clamp(CalamityUtils.Convert01To010(completionRatio * 2), 0.2f, 1f) * 4f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) => Color.White; - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 2f; - internal Color BackgroundColorFunction(float completionRatio) => ColorFunction(completionRatio) * 0.5f; + internal float BackgroundWidthFunction(float completionRatio, Vector2 vertexPos) => WidthFunction(completionRatio, vertexPos) * 2f; + internal Color BackgroundColorFunction(float completionRatio, Vector2 vertexPos) => ColorFunction(completionRatio, vertexPos) * 0.5f; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/TriactisHammerFlare.cs b/Projectiles/Melee/TriactisHammerFlare.cs index e12aebdd45..70af4b6ee0 100644 --- a/Projectiles/Melee/TriactisHammerFlare.cs +++ b/Projectiles/Melee/TriactisHammerFlare.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using System; using Terraria; -using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/TriactisHammerProj.cs b/Projectiles/Melee/TriactisHammerProj.cs index 1c22309d4c..e455e9aff9 100644 --- a/Projectiles/Melee/TriactisHammerProj.cs +++ b/Projectiles/Melee/TriactisHammerProj.cs @@ -1,9 +1,7 @@ -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using System; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs index 172fff2d28..0f208bdc5b 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs @@ -35,6 +35,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.penetrate = -1; Projectile.noEnchantmentVisuals = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool? CanDamage() => Timer <= ParryTime && AlreadyParried == 0f; diff --git a/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs b/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs index 68dda29ff5..50216466a3 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_SwungBlade.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; Projectile.width = Projectile.height = 60; Projectile.width = Projectile.height = 60; Projectile.tileCollide = false; diff --git a/Projectiles/Melee/TrueBiomeBladeHoldout.cs b/Projectiles/Melee/TrueBiomeBladeHoldout.cs index 675b93172a..8fcfde2e17 100644 --- a/Projectiles/Melee/TrueBiomeBladeHoldout.cs +++ b/Projectiles/Melee/TrueBiomeBladeHoldout.cs @@ -141,7 +141,7 @@ namespace CalamityMod.Projectiles.Melee if (whirlAttune) attunement = AttunementSystem.FindOrNull(AttunementID.Whirlwind); //Putting holy check at the end so it may override hallowed variants of biomes - //If the owner already had the attunement, break out of it (And unswap) + // If the owner already had the attunement, break out of it (And unswap) if (item.secondaryAttunement == attunement) { SoundEngine.PlaySound(SoundID.DD2_LightningBugZap, Projectile.Center); @@ -149,7 +149,6 @@ namespace CalamityMod.Projectiles.Melee item.mainAttunement = attunement; return; } - //Chunger var Sound = SoundEngine.PlaySound(CommonCalamitySounds.LightningSound with { Volume = CommonCalamitySounds.LightningSound.Volume * 0.4f }, Projectile.Center); Particle thunder = new ThunderBoltVFX( @@ -161,9 +160,7 @@ namespace CalamityMod.Projectiles.Melee 15f); GeneralParticleHandler.SpawnParticle(thunder); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 5) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 5; - + Main.LocalPlayer.SetScreenshake(5f); item.mainAttunement = attunement; } diff --git a/Projectiles/Melee/TrueBiomeBlade_EarthenTides.cs b/Projectiles/Melee/TrueBiomeBlade_EarthenTides.cs index dc3cb85d90..da7aad8975 100644 --- a/Projectiles/Melee/TrueBiomeBlade_EarthenTides.cs +++ b/Projectiles/Melee/TrueBiomeBlade_EarthenTides.cs @@ -202,8 +202,7 @@ namespace CalamityMod.Projectiles.Melee // Sound and screenshake SoundEngine.PlaySound(GroundImpact, Projectile.Center); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 15) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 15; + Main.LocalPlayer.SetScreenshake(15f); // Dust and particles from the impact for (int d = 0; d < 13; d++) diff --git a/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBeam.cs b/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBeam.cs index 57bdc0163c..86d8b8d514 100644 --- a/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBeam.cs +++ b/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBeam.cs @@ -1,8 +1,5 @@ using System; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.DataStructures; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBlast.cs b/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBlast.cs index 843cd4effd..c5659ce5e6 100644 --- a/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBlast.cs +++ b/Projectiles/Melee/TrueBiomeBlade_EarthenTidesBlast.cs @@ -1,5 +1,4 @@ -using CalamityMod.DataStructures; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Melee/TrueBiomeBlade_EarthenTidesShockwave.cs b/Projectiles/Melee/TrueBiomeBlade_EarthenTidesShockwave.cs index 8731a26b33..30501fc196 100644 --- a/Projectiles/Melee/TrueBiomeBlade_EarthenTidesShockwave.cs +++ b/Projectiles/Melee/TrueBiomeBlade_EarthenTidesShockwave.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.DataStructures; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs index 47863bc102..e208cc34e7 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryDash.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.DataStructures; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -57,10 +56,7 @@ namespace CalamityMod.Projectiles.Melee GeneralParticleHandler.SpawnParticle(Spark); } - if (Owner.moonLeech) - return; - - Owner.HealPlayer(OmegaBiomeBlade.SuperPogoAttunementSliceLifesteal); + Owner.DoLifestealDirect(target, OmegaBiomeBlade.SuperPogoAttunementSliceLifesteal, 0.75f); } public override bool PreDraw(ref Color lightColor) //OMw to reuse way too much code from the entangling vines diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs index 0c02adb129..db8c02523c 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs @@ -1,5 +1,4 @@ -using CalamityMod.DataStructures; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideAstralEnergy.cs b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideAstralEnergy.cs index f2e88c452b..cdc8773374 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideAstralEnergy.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideAstralEnergy.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; diff --git a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideMonolith.cs b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideMonolith.cs index 1c50fbb05c..bdc6d4c53f 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideMonolith.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPrideMonolith.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; -using CalamityMod.DataStructures; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; diff --git a/Projectiles/Melee/TyphonsGreedStaff.cs b/Projectiles/Melee/TyphonsGreedStaff.cs index 851b4a2cd1..17cf90d7a2 100644 --- a/Projectiles/Melee/TyphonsGreedStaff.cs +++ b/Projectiles/Melee/TyphonsGreedStaff.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Enums; @@ -10,6 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class TyphonsGreedStaff : ModProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); diff --git a/Projectiles/Melee/UltimusCleaverDust.cs b/Projectiles/Melee/UltimusCleaverDust.cs index 72e9ceb558..a16e9523c4 100644 --- a/Projectiles/Melee/UltimusCleaverDust.cs +++ b/Projectiles/Melee/UltimusCleaverDust.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Melee/UrchinSpikeFugu.cs b/Projectiles/Melee/UrchinSpikeFugu.cs index 3938a7e9cc..36866784f2 100644 --- a/Projectiles/Melee/UrchinSpikeFugu.cs +++ b/Projectiles/Melee/UrchinSpikeFugu.cs @@ -46,10 +46,13 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity = (Projectile.velocity * 20f + idealVelocity) / 21f; Projectile.velocity = Projectile.velocity.MoveTowards(idealVelocity, 2f); } + else if (Time >= 48f) + Projectile.velocity *= 0.9f; - if (Main.rand.NextBool(8)) + int dustRate = (int)MathF.Max(Utils.Remap(Time, 0f, 12f, 20f, 4f), Utils.Remap(Time, 60f, 90f, 4f, 20f)); + if (Main.rand.NextBool(dustRate)) { - Dust offTrail = Dust.NewDustPerfect(Projectile.Center, 171, Main.rand.NextVector2Circular(0.2f, 0.2f)); + Dust offTrail = Dust.NewDustPerfect(Projectile.Center, DustID.Venom, Main.rand.NextVector2Circular(0.2f, 0.2f)); offTrail.noGravity = true; offTrail.scale = Main.rand.NextFloat(0.6f, 1.2f); } @@ -59,12 +62,12 @@ namespace CalamityMod.Projectiles.Melee public override bool? CanDamage() => Time < 12f ? false : base.CanDamage(); - internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 4f; - internal Color ColorFunction(float completionRatio) => new Color(91, 62, 153) * Projectile.Opacity; + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (1f - completionRatio) * Projectile.scale * 4f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) => new Color(91, 62, 153) * Projectile.Opacity; public override bool PreDraw(ref Color lightColor) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 8); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 8); return true; } } diff --git a/Projectiles/Melee/ViolenceSlashProjectile.cs b/Projectiles/Melee/ViolenceSlashProjectile.cs index c24ce18a99..1e36fe4e58 100644 --- a/Projectiles/Melee/ViolenceSlashProjectile.cs +++ b/Projectiles/Melee/ViolenceSlashProjectile.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Melee Owner.ChangeDir((Math.Cos(Projectile.rotation - MathHelper.PiOver4) > 0f).ToDirectionInt()); } - internal Color PrimitiveColorFunction(float completionRatio) + internal Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float averageRotation = Projectile.oldRot.Average(angle => MathHelper.WrapAngle(angle) + MathHelper.Pi); float opacity = Projectile.Opacity * Utils.GetLerpValue(0.75f, 0.45f, completionRatio, true) * 0.5f; @@ -94,7 +94,7 @@ namespace CalamityMod.Projectiles.Melee return Color.Lerp(Color.Red * 1.1f, Color.DarkRed, Utils.GetLerpValue(0f, 0.5f, completionRatio, true)) * opacity; } - internal float PrimitiveWidthFunction(float completionRatio) => Projectile.height * 0.48f; + internal float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.height * 0.48f; public override bool PreDraw(ref Color lightColor) { @@ -107,13 +107,13 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 16; i++) { - Vector2 position = Projectile.position + (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * (PrimitiveWidthFunction(0f) - 30f) * Projectile.scale * 0.5f; + Vector2 position = Projectile.position + (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * (PrimitiveWidthFunction(0f,Vector2.Zero) - 30f) * Projectile.scale * 0.5f; float angleOffset = MathHelper.Pi * 0.25f * -Math.Sign(SwingSine) * i / 16f; position += (Projectile.rotation - MathHelper.PiOver4 + MathHelper.PiOver2).ToRotationVector2().RotatedBy(angleOffset) * -SwingSine * i * 12f; positions.Add(position); } - PrimitiveRenderer.RenderTrail(positions, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]), 50); + PrimitiveRenderer.RenderTrail(positions, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_, _) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]), 50); return true; } } diff --git a/Projectiles/Melee/ViolenceThrownProjectile.cs b/Projectiles/Melee/ViolenceThrownProjectile.cs index 2da1fa70aa..c37230af4c 100644 --- a/Projectiles/Melee/ViolenceThrownProjectile.cs +++ b/Projectiles/Melee/ViolenceThrownProjectile.cs @@ -1,6 +1,8 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,22 +12,263 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using CalamityMod.NPCs.ExoMechs.Ares; +using System.Linq; +using Terraria.DataStructures; namespace CalamityMod.Projectiles.Melee { + [PierceResistException] public class ViolenceThrownProjectile : ModProjectile { + private int hitstop = 0; public override LocalizedText DisplayName => CalamityUtils.GetItemName(); internal Player Owner => Main.player[Projectile.owner]; internal ref float Time => ref Projectile.ai[0]; public override string Texture => "CalamityMod/Items/Weapons/Melee/Violence"; - public override void SetStaticDefaults() + + public bool isJavelin { - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 36; + get + { + if (Projectile.ai[2] == 0) + return true; + else + return false; + } } + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 60; + } + + private Vector2 NormalVelocity = Vector2.Zero; + private NPC target; + private Vector2 targetoffset = Vector2.Zero; + private int[] offsetadjust = new int[] + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + }; + + public override void OnSpawn(IEntitySource source) + { + if (isJavelin) + JavelinSetDefaults(); + else + YoyoSetDefaults(); + } + + //These methods adjusts to which AI type is in use + #region Variable Methods + public override void SetDefaults() + { + Projectile.timeLeft = 60; + //The rest of this runs in OnSpawn instead due to variable AI stuff + } + public override void AI() + { + if (isJavelin) + JavelinAI(); + else + YoyoAI(); + } + + public override bool PreDraw(ref Color lightColor) + { + if (isJavelin && Projectile.timeLeft > 2) + return JavelinPreDraw(ref lightColor); + else + return YoyoPreDraw(ref lightColor); + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + if (isJavelin) + JavelinModifyDamageHitbox(ref hitbox); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (isJavelin) + JavelinOnHitNPC(target, hit, damageDone); + else + YoyoOnHitNPC(target, hit, damageDone); + } + #endregion + + //Methods for controlling the Javelin throw + #region Javelin Methods + public void JavelinAI() + { + + var player = Main.player[Projectile.owner]; + float adust = MathHelper.ToRadians(45 + 180); + if (hitstop > 0) + { + hitstop--; + Projectile.timeLeft++; + Projectile.velocity = NormalVelocity * 0.01f + (offsetadjust.Contains(target.type) ? target.position - targetoffset : Vector2.Zero); + targetoffset = target.position; + + Vector2 impactPoint = Vector2.Lerp(Projectile.Center, target.Center, 0.5f);//Projectile.Center + new Vector2(0,-100).RotatedBy(Projectile.rotation + MathHelper.Pi/4f); + Vector2 bloodSpawnPosition = impactPoint + Main.rand.NextVector2Circular(target.width, target.height) * 0.04f; + Vector2 splatterDirection = Projectile.velocity.SafeNormalize(Vector2.Zero) * -1; + + // Emit blood if the target is organic. + if (target.Organic()) + { + if (Projectile.FinalExtraUpdate()) + SoundEngine.PlaySound(SoundID.NPCHit18 with { Volume = 0.2f }, Projectile.Center); + for (int i = 0; i < 1; i++) + { + int bloodLifetime = Main.rand.Next(22, 36); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); + bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); + + if (Main.rand.NextBool(20)) + bloodScale *= 2f; + + Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.81f) * Main.rand.NextFloat(11f, 23f); + bloodVelocity.Y -= 12f; + BloodParticle blood = new BloodParticle(bloodSpawnPosition, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + for (int i = 0; i < 1; i++) + { + float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); + Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.9f) * Main.rand.NextFloat(9f, 14.5f); + BloodParticle2 blood = new BloodParticle2(bloodSpawnPosition, bloodVelocity, 20, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + } + + // Emit sparks if the target is not organic. + else + { + + if (Projectile.FinalExtraUpdate()) + { + for (int i = 0; i < 2; i++) + { + int sparkLifetime = Main.rand.Next(22, 36); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) + 1 * 0.85f; + Color sparkColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.Orange, Main.rand.NextFloat()); + + if (Main.rand.NextBool(10)) + sparkScale *= 2f; + + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); + sparkVelocity.Y -= 6f; + SparkParticle spark = new SparkParticle(impactPoint, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + SoundEngine.PlaySound(SoundID.NPCHit18 with { Volume = 0.2f }, Projectile.Center); + } + } + + + } + else + { + Projectile.velocity = NormalVelocity; + } + if (Projectile.timeLeft == 1) + { + Projectile.timeLeft++; + + ReturnToOwner(); + Projectile.rotation += 0.45f; + Projectile.extraUpdates = 3; + Projectile.damage = 0; + Time = 60; + } + Lighting.AddLight(Projectile.Center + (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.45f, Color.Red.ToVector3() * 0.4f); + } + public bool JavelinPreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + + // Not cloning the points causes the below operations to be applied to the original oldPos value by reference + // and thus causes it to be consistently added over and over, which is not intended behavior. + Vector2[] drawPoints = (Vector2[])Projectile.oldPos.Clone(); + Vector2 aimAheadDirection = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + PrimitiveRenderer.RenderTrail(Projectile.oldPos.Take(60).ToArray(), new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), 25); + return true; + } + public void JavelinSetDefaults() + { + Projectile.timeLeft = 60; + Projectile.width = Projectile.height = 142; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.localNPCHitCooldown = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.extraUpdates = 4; + Projectile.aiStyle = -2; + Projectile.DamageType = DamageClass.Melee; + Projectile.tileCollide = false; + Projectile.Center = Main.player[Projectile.owner].Center; + NormalVelocity = Projectile.velocity; + Projectile.rotation = Projectile.velocity.ToRotation() + MathF.PI / 4; + } + public void JavelinModifyDamageHitbox(ref Rectangle hitbox) + { + var center = hitbox.Center.ToVector2(); + hitbox.Height = (int)(45 * Projectile.scale); + hitbox.Width = (int)(45 * Projectile.scale); + hitbox.Location = (center + NormalVelocity.SafeNormalize(Vector2.Zero) * 70 - new Vector2(hitbox.Width / 2, hitbox.Height / 2)).ToPoint(); + + } + public void JavelinOnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + var player = Main.player[Projectile.owner]; + this.target = target; + targetoffset = target.position; + float x = Utils.GetLerpValue(1000f, 6000f, damageDone, true); + int x1 = (int)(20 * (x) * (Projectile.extraUpdates + 1)); + if (damageDone > 5) + { + hitstop = x1; + Projectile.damage = (int)(Projectile.damage * 0.9f); + } + target.AddBuff(ModContent.BuffType(), 240); + + + if (Main.netMode != NetmodeID.Server) + { + // Play a splatter and impact sound. + SoundEngine.PlaySound(SoundID.DD2_CrystalCartImpact, Projectile.Center); + + float damageInterpolant = Utils.GetLerpValue(950f, 2000f, hit.Damage, true); + float impactAngularVelocity = MathHelper.Lerp(0.08f, 0.2f, damageInterpolant); + float impactParticleScale = MathHelper.Lerp(0.6f, 1f, damageInterpolant); + impactAngularVelocity *= Main.rand.NextBool().ToDirectionInt() * Main.rand.NextFloat(0.75f, 1.25f); + + Color impactColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.5f)); + Vector2 impactPoint = Vector2.Lerp(Projectile.Center, target.Center, 0.65f); + + + // And create an impact point particle. + ImpactParticle impactParticle = new ImpactParticle(impactPoint, impactAngularVelocity, 20, impactParticleScale, impactColor); + GeneralParticleHandler.SpawnParticle(impactParticle); + } + + } + #endregion + + //These methods are the original Violence "Yoyo" functionality + #region Yoyo Methods + public void YoyoSetDefaults() { Projectile.width = Projectile.height = 142; Projectile.aiStyle = -1; @@ -40,7 +283,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; } - public override void AI() + public void YoyoAI() { // Fade in. Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Time, true); @@ -53,7 +296,6 @@ namespace CalamityMod.Projectiles.Melee else { ReturnToOwner(); - float idealAngle = Projectile.AngleTo(Owner.Center) - MathHelper.PiOver4; Projectile.rotation = Projectile.rotation.AngleLerp(idealAngle, 0.1f); Projectile.rotation = Projectile.rotation.AngleTowards(idealAngle, 0.25f); @@ -86,7 +328,7 @@ namespace CalamityMod.Projectiles.Melee { for (int i = 0; i < 75; i++) { - Dust fire = Dust.NewDustPerfect(Owner.Center, 6); + Dust fire = Dust.NewDustPerfect(Owner.Center, DustID.Torch); fire.velocity = (MathHelper.TwoPi * i / 75f).ToRotationVector2() * 4f - Vector2.UnitY * 3f; fire.scale = 1.4f; fire.noGravity = true; @@ -101,7 +343,7 @@ namespace CalamityMod.Projectiles.Melee Owner.itemAnimation = 2; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public void YoyoOnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (!Main.dedServ) { @@ -172,32 +414,9 @@ namespace CalamityMod.Projectiles.Melee GeneralParticleHandler.SpawnParticle(impactParticle); } } - - internal float PrimitiveWidthFunction(float completionRatio) + public bool YoyoPreDraw(ref Color lightColor) { - float tipWidthFactor = MathHelper.SmoothStep(0f, 1f, Utils.GetLerpValue(0.01f, 0.04f, completionRatio)); - float bodyWidthFactor = (float)Math.Pow(Utils.GetLerpValue(1f, 0.04f, completionRatio), 0.9D); - return (float)Math.Pow(tipWidthFactor * bodyWidthFactor, 0.1D) * 30f; - } - - internal Color PrimitiveColorFunction(float completionRatio) - { - float fadeInterpolant = (float)Math.Cos(Main.GlobalTimeWrappedHourly * -9f + completionRatio * 6f + Projectile.identity * 2f) * 0.5f + 0.5f; - - // Adjust the fade interpolant to be on a different scale via a linear interpolation. - fadeInterpolant = MathHelper.Lerp(0.15f, 0.75f, fadeInterpolant); - Color frontFade = Color.Lerp(new Color(255, 145, 115), new Color(113, 0, 159), fadeInterpolant); - - // Go halfway to a dark red color. - frontFade = Color.Lerp(frontFade, Color.DarkRed, 0.5f); - Color backFade = new Color(255, 145, 115); - - return Color.Lerp(frontFade, backFade, (float)Math.Pow(completionRatio, 1.2D)) * (float)Math.Pow(1f - completionRatio, 1.1D) * Projectile.Opacity; - } - - public override bool PreDraw(ref Color lightColor) - { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); Texture2D spearProjectile = Terraria.GameContent.TextureAssets.Projectile[Type].Value; @@ -206,7 +425,7 @@ namespace CalamityMod.Projectiles.Melee Vector2[] drawPoints = (Vector2[])Projectile.oldPos.Clone(); Vector2 aimAheadDirection = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); - if (Owner.channel) + if (Owner.channel || isJavelin) { drawPoints[0] += aimAheadDirection * -12f; drawPoints[1] = drawPoints[0] - (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * Vector2.Distance(drawPoints[0], drawPoints[1]); @@ -214,13 +433,8 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < drawPoints.Length; i++) drawPoints[i] -= (Projectile.oldRot[i] + MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.5f; - if (Time > Projectile.oldPos.Length) - { - // Violence trakcs 36 positions in oldPos. - // Provide all 36 points for smoothing, but only render 24. - int numPointsRendered = 24; - PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), numPointsRendered); - } + int numPointsRendered = (int)Math.Min(24, Time); + PrimitiveRenderer.RenderTrail(drawPoints.Take((int)Math.Min(Time, 36)).ToArray(), new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), 24); Vector2 drawPosition = Projectile.Center - Main.screenPosition; for (int i = 0; i < 6; i++) @@ -235,5 +449,31 @@ namespace CalamityMod.Projectiles.Melee return false; } + #endregion + + #region Shared Methods + + internal float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) + { + float tipWidthFactor = MathHelper.SmoothStep(0f, 1f, Utils.GetLerpValue(0.01f, 0.04f, completionRatio)); + float bodyWidthFactor = (float)Math.Pow(Utils.GetLerpValue(1f, 0.04f, completionRatio), 0.9D); + return (float)Math.Pow(tipWidthFactor * bodyWidthFactor, 0.1D) * 30f; + } + + internal Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) + { + float fadeInterpolant = (float)Math.Cos(Main.GlobalTimeWrappedHourly * -9f + completionRatio * 6f + Projectile.identity * 2f) * 0.5f + 0.5f; + + // Adjust the fade interpolant to be on a different scale via a linear interpolation. + fadeInterpolant = MathHelper.Lerp(0.15f, 0.75f, fadeInterpolant); + Color frontFade = Color.Lerp(new Color(255, 145, 115), new Color(113, 0, 159), fadeInterpolant); + + // Go halfway to a dark red color. + frontFade = Color.Lerp(frontFade, Color.DarkRed, 0.5f); + Color backFade = new Color(255, 145, 115); + + return Color.Lerp(frontFade, backFade, (float)Math.Pow(completionRatio, 1.2D)) * (float)Math.Pow(1f - completionRatio, 1.1D) * Projectile.Opacity; + } + #endregion } } diff --git a/Projectiles/Melee/VoidEssence.cs b/Projectiles/Melee/VoidEssence.cs index 047bad504b..52d4a597c0 100644 --- a/Projectiles/Melee/VoidEssence.cs +++ b/Projectiles/Melee/VoidEssence.cs @@ -154,7 +154,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[idx].scale = scale; } - target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 30); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Melee/VolcanicFireballLarge.cs b/Projectiles/Melee/VolcanicFireballLarge.cs index 690b93fada..fad0d22a36 100644 --- a/Projectiles/Melee/VolcanicFireballLarge.cs +++ b/Projectiles/Melee/VolcanicFireballLarge.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Melee/WulfrumScrew.cs b/Projectiles/Melee/WulfrumScrew.cs index 2a245b5267..104bca3d8a 100644 --- a/Projectiles/Melee/WulfrumScrew.cs +++ b/Projectiles/Melee/WulfrumScrew.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust chust = Dust.NewDustPerfect(dustCenter, 15, -Projectile.velocity * Main.rand.NextFloat(0.6f, 1.5f), Scale: Main.rand.NextFloat(1f, 1.4f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, -Projectile.velocity * Main.rand.NextFloat(0.6f, 1.5f), Scale: Main.rand.NextFloat(1f, 1.4f)); chust.noGravity = true; if (!Main.rand.NextBool(5)) @@ -138,13 +138,13 @@ namespace CalamityMod.Projectiles.Melee return base.OnTileCollide(oldVelocity); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = (float)Math.Pow(1 - completionRatio, 2) * (float)Math.Pow(1 - BazingaTimeCompletion, 0.4f); return Color.GreenYellow.MultiplyRGB(PrimColorMult) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return 9.4f; } @@ -206,7 +206,7 @@ namespace CalamityMod.Projectiles.Melee CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1f, delegate (Vector2 offset, Color colorMod) { PrimColorMult = colorMod; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); }); //Draw the screw with chroma abberation diff --git a/Projectiles/Melee/WulfrumScrewdriverProj.cs b/Projectiles/Melee/WulfrumScrewdriverProj.cs index 9c05c2c756..6b82d56b3d 100644 --- a/Projectiles/Melee/WulfrumScrewdriverProj.cs +++ b/Projectiles/Melee/WulfrumScrewdriverProj.cs @@ -1,19 +1,14 @@ using System; -using System.IO; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Effects; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; -using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Melee { @@ -69,7 +64,7 @@ namespace CalamityMod.Projectiles.Melee { if (EndLag == 0) //Initialization { - EndLag = (float)Math.Max(Owner.ActiveItem().useTime - MaxTime, 1); + EndLag = (float)Math.Max(Owner.HeldItem.useTime - MaxTime, 1); // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction TrueDirection = (Owner.Calamity().mouseWorld - Owner.MountedCenter).SafeNormalize(Vector2.Zero).ToRotation(); //Store this for the screw hit Projectile.velocity = (Owner.Calamity().mouseWorld - Owner.MountedCenter).SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4 * 0.15f); @@ -115,11 +110,8 @@ namespace CalamityMod.Projectiles.Melee if (screw.AlreadyBazinged > 2) SoundEngine.PlaySound(WulfrumScrewdriver.FunnyUltrablingSound, Projectile.Center); - if (Main.myPlayer == proj.owner) - { - Owner.Calamity().GeneralScreenShakePower = 6f; - } + Owner.SetScreenshake(6f); return; } @@ -188,7 +180,7 @@ namespace CalamityMod.Projectiles.Melee //Dust for (int k = 0; k < 4; k++) { - Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 70f, 16, Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(6), 0, default, Main.rand.NextFloat(0.7f, 1f)); + Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 70f, DustID.Cloud, Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(6), 0, default, Main.rand.NextFloat(0.7f, 1f)); } diff --git a/Projectiles/Melee/Yoyos/AzathothYoyo.cs b/Projectiles/Melee/Yoyos/AzathothYoyo.cs deleted file mode 100644 index 029bdbc52e..0000000000 --- a/Projectiles/Melee/Yoyos/AzathothYoyo.cs +++ /dev/null @@ -1,64 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Melee; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Melee.Yoyos -{ - public class AzathothYoyo : ModProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public const int MaxUpdates = 3; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.YoyosLifeTimeMultiplier[Type] = -1f; - ProjectileID.Sets.YoyosMaximumRange[Type] = Azathoth.Reach; - ProjectileID.Sets.YoyosTopSpeed[Type] = Azathoth.Speed / MaxUpdates; - - ProjectileID.Sets.TrailCacheLength[Type] = 8; - ProjectileID.Sets.TrailingMode[Type] = 1; - } - - public override void SetDefaults() - { - Projectile.aiStyle = ProjAIStyleID.Yoyo; - Projectile.width = Projectile.height = 24; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.MeleeNoSpeed; - Projectile.penetrate = -1; - Projectile.MaxUpdates = MaxUpdates; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 2 * MaxUpdates; - } - - public override void AI() - { - if (Main.rand.NextBool(MaxUpdates)) - { - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 0.55f), ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f, 0f); - } - if (Main.rand.NextBool((int)(MaxUpdates / 2))) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 1f), 0, default, Main.rand.NextFloat(1.85f, 2.2f)); - dust.color = Main.rand.NextBool() ? Color.Magenta : Color.HotPink; - bool b = !Main.rand.NextBool(3); - dust.scale -= b ? 0.8f : 0; - dust.velocity *= b ? 0.4f : 1; - dust.noGravity = !b; - } - if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks - Projectile.Kill(); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Melee/Yoyos/BurningRevelationYoyo.cs b/Projectiles/Melee/Yoyos/BurningRevelationYoyo.cs index 71c49e4116..c88f451f81 100644 --- a/Projectiles/Melee/Yoyos/BurningRevelationYoyo.cs +++ b/Projectiles/Melee/Yoyos/BurningRevelationYoyo.cs @@ -18,14 +18,14 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public const int MaxUpdates = 3; - public int timer = 0; public bool canDamage = true; public bool firing = false; public NPC targeted; public float fade = 0; public int hitCooldown = 0; - public ref float yoyoPower => ref Projectile.ai[2]; + public int timer = 0; + public int yoyoPower = 0; public int yoyoPowerMax = 1000; public bool cloneYoyo = false; @@ -90,19 +90,19 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (firing) { if (targeted == null || targeted.life <= 0) - targeted = Projectile.Center.ClosestNPCAt(600); + targeted = Projectile.Center.ClosestNPCAt(800f); if (timer % (cloneYoyo ? 20 : 10) == 0) // Fire Holy Stars { - int stardamage = (int)(Projectile.damage * 0.12f); + int stardamage = (int)(Projectile.damage * 0.24f); Vector2 vel = new Vector2(0, 10).RotatedBy(timer * 0.025f * (cloneYoyo ? -1 : 1)); - Projectile damageStar = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType(), stardamage, Projectile.knockBack, Projectile.owner, 0, 5, (targeted == null ? -1 : targeted.whoAmI)); + Projectile damageStar = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType(), stardamage, Projectile.knockBack, Projectile.owner, 0, 5, targeted == null ? -1 : targeted.whoAmI); damageStar.extraUpdates = 1; - damageStar.scale = 0.6f; - Projectile damageStar2 = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, -vel, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, 0, 5, (targeted == null ? -1 : targeted.whoAmI)); + damageStar.scale = 0.5f; + Projectile damageStar2 = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, -vel, ModContent.ProjectileType(), stardamage, Projectile.knockBack, Projectile.owner, 0, 5, targeted == null ? -1 : targeted.whoAmI); damageStar2.extraUpdates = 1; - damageStar2.scale = 0.6f; + damageStar2.scale = 0.5f; SoundStyle fire = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastShoot"); SoundEngine.PlaySound(fire with { Volume = 0.6f, PitchVariance = 0.2f }, Projectile.Center); @@ -120,14 +120,16 @@ namespace CalamityMod.Projectiles.Melee.Yoyos } */ - if (timer <= 0) + if (timer > 0) { - firing = false; - canDamage = true; - yoyoPower = 0; - } - else timer--; + if (timer <= 0) + { + firing = false; + canDamage = true; + yoyoPower = 0; + } + } } else { @@ -204,7 +206,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos SoundStyle explode = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastImpact"); SoundEngine.PlaySound(explode with { Volume = 0.5f, Pitch = 0.3f * power }, Projectile.Center); - SoundStyle explode2 = new("CalamityMod/Sounds/Item/HeliumFlashReadyAlt"); + SoundStyle explode2 = new("CalamityMod/Sounds/Item/HeliumFlashReady"); SoundEngine.PlaySound(explode2 with { Volume = 0.7f, Pitch = 0.6f * power }, Projectile.Center); } } diff --git a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs index 43b61fd17b..fb0fb6b52a 100644 --- a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs @@ -1,18 +1,33 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using CalamityMod.Particles; +using System.IO; namespace CalamityMod.Projectiles.Melee.Yoyos { + // Although normally yoyos are automatically exempted from pierce resist, + // the damage logic for the buzzsaw briefly clobbers aiStyle, necessitating a manual pierce resist exception. + [PierceResistException] public class LaceratorYoyo : ModProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public const int MaxUpdates = 3; + public float chargeProgress = 0; + private bool sawHit = false; + private bool spawnedBlood = false; + private int sawDir = 0; + public override void SetStaticDefaults() { ProjectileID.Sets.YoyosLifeTimeMultiplier[Type] = -1f; @@ -33,29 +48,103 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Projectile.MaxUpdates = MaxUpdates; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 6 * MaxUpdates; + } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(chargeProgress); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + chargeProgress = reader.ReadInt32(); + } public override void AI() { + if (sawDir == 0) + sawDir = Projectile.velocity.X < 0 ? -1 : 1; + if (chargeProgress > 1) + chargeProgress = 1; + if (chargeProgress > 0) + { + // Handles damage logic for the buzzsaw visual + if (Main.player[Projectile.owner].miscCounter % 5 == 0 && Projectile.FinalExtraUpdate() && chargeProgress > 0.05f) + { + spawnedBlood = false; + Projectile.position = Projectile.Center; + Projectile.width = 196; + Projectile.height = 196; + Projectile.Center = Projectile.position; + Projectile.originalDamage = Projectile.damage; + Projectile.damage = (int)(Projectile.damage * MathHelper.Lerp(0, 0.75f, chargeProgress)); + sawHit = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.aiStyle = -1; + Projectile.Damage(); + Projectile.aiStyle = ProjAIStyleID.Yoyo; + Projectile.usesIDStaticNPCImmunity = false; + sawHit = false; + Projectile.damage = Projectile.originalDamage; + Projectile.position = Projectile.Center; + Projectile.width = 16; + Projectile.height = 16; + Projectile.Center = Projectile.position; + + } + if (chargeProgress > 0.05f) + { + float particleSize = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + particleSize *= 0.5f; + var particlePos = Projectile.Center + new Vector2(0, 84).RotatedByRandom(MathHelper.TwoPi); + var particleVel = particlePos.DirectionTo(Projectile.Center).RotatedBy(-sawDir * MathHelper.PiOver2 * 0.9f).RotatedByRandom(0.1f) * Main.rand.NextFloat(15f, 25f); + Particle blood = new CustomSpark(particlePos, particleVel, "CalamityMod/Particles/PearlParticleGlow", false, (int)MathHelper.Lerp(7, 17, chargeProgress), particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(blood); + } + chargeProgress -= 0.003f / Projectile.extraUpdates; + if (chargeProgress < 0) + chargeProgress = 0; + } + if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks Projectile.Kill(); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); - - if (Main.player[Projectile.owner].moonLeech) + if (sawHit) + { + Vector2 bloodpos = Projectile.Center + Projectile.DirectionTo(target.Center) * 84; + if (!spawnedBlood && Main.rand.NextBool() && chargeProgress > 0.2f && target.Hitbox.Contains(bloodpos.ToPoint())) + { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), bloodpos, Projectile.DirectionTo(target.Center).RotatedBy(sawDir * MathHelper.PiOver2 * 0.9f).RotatedByRandom(0.1f) * Main.rand.NextFloat(3f, 5f), ModContent.ProjectileType(), 4, 0f, Projectile.owner); + spawnedBlood = true; + } return; - - Player player = Main.player[Projectile.owner]; - player.lifeRegenTime += 2; + } + var baseYoyo = Main.projectile.First(x => x.active && x.type == ModContent.ProjectileType() && x.owner == Projectile.owner); + baseYoyo.ModProjectile().chargeProgress += (Main.player[Projectile.owner].yoyoGlove ? 0.05f : 0.1f); + Projectile.netUpdate = true; + target.AddBuff(ModContent.BuffType(), 180); } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); public override bool PreDraw(ref Color lightColor) { + if (chargeProgress > 0) + { + var owner = Main.player[Projectile.owner]; + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Melee/LaceratorSaw").Value; + Texture2D WindTexture = ModContent.Request("CalamityMod/Projectiles/Melee/BlazingPhantomBlade").Value; + float rot = MathHelper.TwoPi * 30 * sawDir * (owner.miscCounter / 300f); + var color = new Color(200, 200, 200); + var frame = WindTexture.Frame(1, 4, 0, 0); + Main.EntitySpriteDraw(WindTexture, Projectile.Center - Main.screenPosition + rot.ToRotationVector2() * 30, frame, color * MathF.Pow(chargeProgress, 0.5f) * 0.33f, rot - 0.2f * sawDir, new Vector2(frame.Width, frame.Height) * 0.5f, 1, sawDir == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None, 0); + Main.EntitySpriteDraw(WindTexture, Projectile.Center - Main.screenPosition + (rot + MathHelper.Pi).ToRotationVector2() * 30, frame, color * MathF.Pow(chargeProgress, 0.5f) * 0.33f, (rot + MathHelper.Pi) - 0.2f * sawDir, new Vector2(frame.Width, frame.Height) * 0.5f, 1, sawDir == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None, 0); + color = new Color(255, 10, 10); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, color * MathF.Pow(chargeProgress, 0.5f) * 1f, rot, texture.Size() * 0.5f, 1, sawDir == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + } CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs index 183a1b9d1a..3bddbb1b4d 100644 --- a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs +++ b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs @@ -5,7 +5,6 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Systems; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -19,7 +18,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public const int MaxUpdates = 3; private const float Radius = 100f; - private SlotId mmmmmm; private bool spawnedAura = false; public int soundCooldown = 0; diff --git a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs index 95d5798836..3f2b27e3c6 100644 --- a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs @@ -1,7 +1,11 @@ using System; using System.Collections.Generic; +using System.Linq; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; @@ -16,20 +20,17 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public class ObliteratorYoyo : ModProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - private const int FramesPerShot = 5; + private static int DashStartup => 60; + private static int DashCooldown => 15; public SlotId GFB; public int GFBCounter = 0; public int time = 0; - // Ensures that the main AI only runs once per frame, despite the projectile's multiple updates - private int extraUpdateCounter = 0; - private const int UpdatesPerFrame = 3; - public override void SetStaticDefaults() { ProjectileID.Sets.YoyosLifeTimeMultiplier[Type] = -1f; ProjectileID.Sets.YoyosMaximumRange[Type] = TheObliterator.Reach; - ProjectileID.Sets.YoyosTopSpeed[Type] = TheObliterator.Speed / UpdatesPerFrame; + ProjectileID.Sets.YoyosTopSpeed[Type] = TheObliterator.Speed / 3f; ProjectileID.Sets.TrailCacheLength[Type] = 8; ProjectileID.Sets.TrailingMode[Type] = 1; @@ -42,14 +43,28 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Projectile.friendly = true; Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.penetrate = -1; - Projectile.MaxUpdates = UpdatesPerFrame; + Projectile.MaxUpdates = 3; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6 * UpdatesPerFrame; + Projectile.localNPCHitCooldown = 7 * Projectile.MaxUpdates; + } + + public override bool PreAI() + { + if (Projectile.FinalExtraUpdate()) + { + if (Projectile.localAI[1] != DashStartup) + Projectile.localAI[1]++; + if (Projectile.localAI[1] > DashStartup + DashCooldown) + Projectile.localAI[1] = 0; + } + + if (Projectile.localAI[1] <= DashStartup) + return true; + Projectile.aiStyle = -1; + Projectile.timeLeft++; + return true; } - // localAI[1] is the shot counter. Every 5 frames, The Obliterator tries to fire a laser at a nearby target. - // It has 4 "laser ports" which whirl around in circles with the yoyo. It uses each of these in order. - // localAI[1] counts up to 19 (4 x 5 - 1), then resets back to 0 for a 20-frame cycle. public override void AI() { time++; @@ -76,63 +91,60 @@ namespace CalamityMod.Projectiles.Melee.Yoyos } } - if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks - Projectile.Kill(); - // Only do stuff once per frame, despite the yoyo's extra updates. - extraUpdateCounter = (extraUpdateCounter + 1) % UpdatesPerFrame; - if (extraUpdateCounter != UpdatesPerFrame - 1) - return; - - Lighting.AddLight(Projectile.Center, 0.8f, 0.3f, 1f); - - Projectile.localAI[1]++; - if (Projectile.localAI[1] >= 4 * FramesPerShot) - Projectile.localAI[1] = 0f; - - // Attempt to fire a laser every 5 frames - if (Projectile.localAI[1] % FramesPerShot == 0f) + if (Projectile.FinalExtraUpdate()) { - List targets = new List(); - float laserRange = 300f; - foreach (NPC n in Main.ActiveNPCs) + if (Projectile.localAI[1] == DashStartup) { - if (n.CanBeChasedBy(Projectile, false) && (n.Center - Projectile.Center).Length() <= laserRange && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) + List targets = new List(); + float laserRange = 600f; + foreach (NPC n in Main.ActiveNPCs) { - 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(n.whoAmI); + if (n.CanBeChasedBy(Projectile, false) && (n.Center - Projectile.Center).Length() <= laserRange && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) + { + targets.Add(n); + } } - } - if (targets.Count == 0) - return; + if (targets.Count == 0) + return; + targets = targets.OrderBy(x => x.Distance(Projectile.Center)).ToList(); + Projectile.velocity = Projectile.DirectionTo(targets[0].Center); + Projectile.Center = targets[0].Center - new Vector2(Projectile.velocity.X * targets[0].width*0.5f, Projectile.velocity.Y * targets[0].height*0.5f); + Projectile.velocity *= 15; + for (var i = 0; i < 20; i++) + { + Projectile.Center -= Projectile.velocity; + if (Collision.SolidCollision(Projectile.position,Projectile.width,Projectile.height)) + { + Projectile.Center += Projectile.velocity; + break; + } + } + if (Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Projectile.owner); + } + int laserAmount = 8; + for (int i = 0; i < laserAmount; i++) + { + int sparkLifetime = Main.rand.Next(30, 45); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) + 1f * 0.05f; + Color sparkColor = Color.Lerp(Color.Fuchsia, Color.AliceBlue, Main.rand.NextFloat(0.5f)); + sparkColor = Color.Lerp(sparkColor, Color.Cyan, Main.rand.NextFloat()); - // Pick which of the four corners the laser is spawning in - Vector2 laserSpawnPosition = Projectile.Center; - Vector2 offset; - if (Projectile.localAI[1] < FramesPerShot) - offset = new Vector2(4, 4); - else if (Projectile.localAI[1] < 2 * FramesPerShot) - offset = new Vector2(-4, 4); - else if (Projectile.localAI[1] < 3 * FramesPerShot) - offset = new Vector2(-4, -4); - else - offset = new Vector2(4, -4); - laserSpawnPosition += offset.RotatedBy(Projectile.rotation); + if (Main.rand.NextBool(5)) + sparkScale *= 1.4f; - ref NPC target = ref Main.npc[targets[Main.rand.Next(targets.Count)]]; - const float laserSpeed = 6f; - Vector2 velocity = target.Center - Projectile.Center; - velocity = velocity.SafeNormalize(Vector2.Zero) * laserSpeed; - if (Projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), laserSpawnPosition, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].DamageType = DamageClass.MeleeNoSpeed; + Vector2 sparkVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.TwoPi * (i / (float)laserAmount)) * 4; + SparkParticle spark = new SparkParticle(Projectile.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + Projectile.localAI[1]++; + Projectile.ResetLocalNPCHitImmunity(); } } + + Projectile.aiStyle = ProjAIStyleID.Yoyo; } public override bool PreDraw(ref Color lightColor) @@ -145,6 +157,14 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { Vector2 origin = new Vector2(10f, 10f); Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Melee/Yoyos/ObliteratorYoyoGlow").Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, 2f, SpriteEffects.None, 0); + + if (Projectile.localAI[1] <= DashStartup) + return; + var tex = ModContent.Request("CalamityMod/Particles/Jaws").Value; + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.spriteBatch.Draw(tex,Projectile.Center+ Projectile.velocity.SafeNormalize(Vector2.Zero)*16f- Main.screenPosition,null,Color.Fuchsia,Projectile.velocity.ToRotation() + MathHelper.PiOver2,tex.Size()*0.5f,0.33f,SpriteEffects.None,0); + Main.spriteBatch.Draw(tex, Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero) * 16f - Main.screenPosition, null, Color.Aqua, Projectile.velocity.ToRotation() + MathHelper.PiOver2, tex.Size() * 0.5f, 0.25f, SpriteEffects.None, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); } public override void OnKill(int timeLeft) { @@ -153,10 +173,36 @@ namespace CalamityMod.Projectiles.Melee.Yoyos RumblePlaying?.Stop(); } } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.localAI[1] > DashStartup) + { + modifiers.SourceDamage *= 6; + } + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + + if (Projectile.localAI[1] > DashStartup) + { + Projectile.localAI[1] = 0; + target.AddBuff(ModContent.BuffType(), 180); + for (int i = 0; i < 10; i++) + { + Vector2 sparkVelocity = -Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(26f, 32f); + int sparkLifetime = Main.rand.Next(10, 20); + float sparkScale = Main.rand.NextFloat(1.4f, 1.8f); + Color sparkColor = Color.Lerp(Main.rand.NextBool() ? Color.Cyan : Color.Purple, Color.White, Main.rand.NextFloat(0f, 0.3f)); + + SparkParticle chompSpark = new(Projectile.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(chompSpark); + } + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCHit/OtherworldlyHit") with { Pitch = -0.45f, Volume = 0.33f }, Projectile.Center); + } + else + target.AddBuff(ModContent.BuffType(), 180); GFBCounter = 15; - target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/Projectiles/Melee/Yoyos/OracleYoyo.cs b/Projectiles/Melee/Yoyos/OracleYoyo.cs index f3faadcc66..3d4fce1963 100644 --- a/Projectiles/Melee/Yoyos/OracleYoyo.cs +++ b/Projectiles/Melee/Yoyos/OracleYoyo.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (AuraCharge <= SuperchargeThreshold) { Vector2 vel = new Vector2(45, 45).RotatedByRandom(100); - Dust dust = Dust.NewDustPerfect(Projectile.Center + vel, 213, Vector2.Zero, 0, default, Main.rand.NextFloat(2.2f, 2.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + vel, DustID.MinecartSpark, Vector2.Zero, 0, default, Main.rand.NextFloat(2.2f, 2.4f)); dust.noGravity = true; } diff --git a/Projectiles/Melee/Yoyos/OzzathothYoyo.cs b/Projectiles/Melee/Yoyos/OzzathothYoyo.cs new file mode 100644 index 0000000000..690d67df7f --- /dev/null +++ b/Projectiles/Melee/Yoyos/OzzathothYoyo.cs @@ -0,0 +1,64 @@ +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Melee; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee.Yoyos +{ + public class OzzathothYoyo : ModProjectile + { + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public const int MaxUpdates = 3; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.YoyosLifeTimeMultiplier[Type] = -1f; + ProjectileID.Sets.YoyosMaximumRange[Type] = Ozzathoth.Reach; + ProjectileID.Sets.YoyosTopSpeed[Type] = Ozzathoth.Speed / MaxUpdates; + + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 1; + } + + public override void SetDefaults() + { + Projectile.aiStyle = ProjAIStyleID.Yoyo; + Projectile.width = Projectile.height = 24; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.MeleeNoSpeed; + Projectile.penetrate = -1; + Projectile.MaxUpdates = MaxUpdates; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 2 * MaxUpdates; + } + + public override void AI() + { + if (Main.rand.NextBool(MaxUpdates)) + { + if (Projectile.owner == Main.myPlayer) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 0.55f), ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f, 0f); + } + if (Main.rand.NextBool((int)(MaxUpdates / 2))) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 1f), 0, default, Main.rand.NextFloat(1.85f, 2.2f)); + dust.color = Main.rand.NextBool() ? Color.Magenta : Color.HotPink; + bool b = !Main.rand.NextBool(3); + dust.scale -= b ? 0.8f : 0; + dust.velocity *= b ? 0.4f : 1; + dust.noGravity = !b; + } + if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks + Projectile.Kill(); + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Melee/Yoyos/AzathothYoyo.png b/Projectiles/Melee/Yoyos/OzzathothYoyo.png similarity index 100% rename from Projectiles/Melee/Yoyos/AzathothYoyo.png rename to Projectiles/Melee/Yoyos/OzzathothYoyo.png diff --git a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs index 0f165f509e..b96f270a03 100644 --- a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs +++ b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs @@ -12,6 +12,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public const int MaxUpdates = 2; + public ref float Timer => ref Projectile.localAI[2]; public override void SetStaticDefaults() { @@ -34,18 +35,17 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void AI() { + Timer++; if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks Projectile.Kill(); if (Main.rand.NextBool(5 * MaxUpdates)) Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.JungleSpore, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); if (Projectile.owner == Main.myPlayer) { - if (Main.rand.NextBool(10 * MaxUpdates)) + if (Timer % (10 * MaxUpdates) == 0) { - Projectile spore = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * Main.rand.NextFloat(0.15f, 0.35f) + Vector2.UnitX.RotatedByRandom(MathHelper.Pi), ProjectileID.SporeGas + Main.rand.Next(3), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner); + Projectile spore = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * Main.rand.NextFloat(0.15f, 0.35f) + Vector2.UnitX.RotatedByRandom(MathHelper.Pi), ProjectileID.SporeGas + Main.rand.Next(3), (int)(Projectile.damage * 0.75f), Projectile.knockBack, Projectile.owner); spore.DamageType = DamageClass.MeleeNoSpeed; - spore.usesLocalNPCImmunity = true; - spore.localNPCHitCooldown = 30; } } } diff --git a/Projectiles/Melee/Yoyos/RiptideYoyo.cs b/Projectiles/Melee/Yoyos/RiptideYoyo.cs index 1f151bb14f..2cb9f3738d 100644 --- a/Projectiles/Melee/Yoyos/RiptideYoyo.cs +++ b/Projectiles/Melee/Yoyos/RiptideYoyo.cs @@ -1,8 +1,10 @@ using System.IO; using CalamityMod.Items.Weapons.Melee; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -26,20 +28,21 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Projectile.width = Projectile.height = 22; Projectile.friendly = true; Projectile.DamageType = DamageClass.MeleeNoSpeed; - Projectile.alpha = 150; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.localNPCHitCooldown = 10; } public override void SendExtraAI(BinaryWriter writer) { writer.Write(Projectile.localAI[1]); + writer.Write(Projectile.localAI[2]); } public override void ReceiveExtraAI(BinaryReader reader) { Projectile.localAI[1] = reader.ReadSingle(); + Projectile.localAI[2] = reader.ReadSingle(); } public override void AI() @@ -47,14 +50,34 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) // 200 blocks Projectile.Kill(); - Projectile.localAI[1]++; - if (Projectile.localAI[1] % 32f == 0f) + Projectile.localAI[2]++; + if (Projectile.localAI[2] % 10 == 0) { - SoundEngine.PlaySound(SoundID.Item21, Projectile.position); - - // ai[0] is the yoyo's index, ai[1] is the rotation, ai[2] is the texture - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 10f, Projectile.owner, Projectile.whoAmI, Main.rand.NextFloat(MathHelper.TwoPi), Main.rand.Next(3)); + Projectile proj = Projectile.NewProjectileDirect(new EntitySource_ItemUse(Main.player[Projectile.owner], Main.player[Projectile.owner].HeldItem), + Projectile.Center, + Vector2.Zero, + ModContent.ProjectileType(), + Projectile.damage, + 0f, + Projectile.owner, + Projectile.whoAmI, + Projectile.localAI[1]); + (proj.ModProjectile as RiptideWave).RotationDirection = Projectile.localAI[2] % 20 == 0 ? -1 : 1; } } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], 2f, 0.09f); + } + + public override bool PreDraw(ref Color lightColor) + { + Asset glowTexture = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + Main.EntitySpriteDraw(glowTexture.Value, Projectile.Center - Main.screenPosition, glowTexture.Frame(), new Color(0.05f, 0.1f, 0.25f, 0f), 0f, glowTexture.Frame().Size() / 2, 0.3f * Projectile.localAI[1], SpriteEffects.None); + + return true; + } } } diff --git a/Projectiles/Pets/BabyGhostBell.cs b/Projectiles/Pets/BabyGhostBell.cs index ec696d2407..1b3c1ec0fc 100644 --- a/Projectiles/Pets/BabyGhostBell.cs +++ b/Projectiles/Pets/BabyGhostBell.cs @@ -1,4 +1,6 @@ using CalamityMod.CalPlayer; +using CalamityMod.Graphics; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -46,6 +48,8 @@ namespace CalamityMod.Projectiles.Pets underwater = Collision.DrownCollision(player.position, player.width, player.height, player.gravDir); if (underwater) { + if (Main.LocalPlayer.Calamity().ZoneAbyss) + EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 3, texture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value }); Lighting.AddLight(Projectile.Center, 0.3f, 0.9f, 1.5f); } else diff --git a/Projectiles/Pets/BurrowerPet.cs b/Projectiles/Pets/BurrowerPet.cs new file mode 100644 index 0000000000..6c75a9f13d --- /dev/null +++ b/Projectiles/Pets/BurrowerPet.cs @@ -0,0 +1,324 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Effects; +using CalamityMod.NPCs; +using CalamityMod.NPCs.Deconstructors; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Systems; +using CalamityMod.Systems.Mechanic; +using CalamityMod.Tiles.Ores; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Pets +{ + public class BurrowerPet : BaseWormProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/NPCs/Deconstructors/DeconstructorMK1Head"; + public override List SegmentTextures => new() + { + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1Body", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt1", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt2", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1Tail" + }; + + public override List GlowTextures => new() + { + null, + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyGlow", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt1Glow", + "CalamityMod/NPCs/Deconstructors/DeconstructorMK1BodyAlt2Glow" + }; + public override int SegmentCount => 3; + + public override List SegmentTypePositionOffsets => new() + { + 32, + 32, + 32, + 32, + 32 + }; + public new string LocalizationCategory => "Projectiles.Pets"; + public Player Owner => Main.player[Projectile.owner]; + public override void SetStaticDefaults() + { + Main.projPet[Type] = true; + ProjectileID.Sets.LightPet[Type] = true; + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 1600; //100 tiles offscreen + Projectile.width = 38; + Projectile.height = 38; + Projectile.friendly = true; + Projectile.netImportant = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + for (var i = 0; i < SegmentCount - 1; i++) + { + Segments.Add(new BaseWormSegment(this, i % 3)); + } + Segments.Add(new BaseWormSegment(this, 3)); + } + + public bool VerifyOwnerIsPresent() + { + // No logic should be run if the player is no longer active in the game. + if (!Owner.active) + { + Projectile.Kill(); + return true; + } + + if (Owner.dead) + Owner.Calamity().burrowerPet = false; + if (Owner.Calamity().burrowerPet) + Projectile.timeLeft = 2; + + return false; + } + #region AI Variables + + public enum AttackState + { + Idle, + Mining, + Shocked + } + public AttackState ActiveAttackState + { + get { return (AttackState)Projectile.ai[1]; } + set { Projectile.ai[1] = (float)value; } + } + public float MainTimer + { + get { return Projectile.ai[0]; } + set { Projectile.ai[0] = value; } + } + + public float AttackSubstate + { + get { return Projectile.ai[2]; } + set { Projectile.ai[2] = value; } + } + + public float StateChangeCounter + { + get { return Projectile.ai[3]; } + set { Projectile.ai[3] = value; } + } + public float VelocityRotation + { + + get { return Projectile.velocity.ToRotation(); } + set { Projectile.velocity = value.ToRotationVector2() * Projectile.velocity.Length(); } + } + + public Vector2 TargetVector = Vector2.Zero; + public Vector2 SecondaryVector = Vector2.Zero; + public float StoredValue = 0; + #endregion + + public void SwitchAttackState(AttackState State, float Substate = 0, bool resetVector = true) + { + Projectile.netUpdate = true; + ActiveAttackState = State; + AttackSubstate = Substate; + MainTimer = 0; + if (resetVector) + TargetVector = Vector2.Zero; + } + + public override void AI() + { + if (VerifyOwnerIsPresent()) + return; + + HandleAIStates(); + MainTimer++; + UpdateSegments(); + } + private void LowerTargetToGround() + { + var pointToCheck = TargetVector.ToTileCoordinates(); + for (var i = 0; i < 50; i++) + { + if (pointToCheck.X < 0 || pointToCheck.X >= Main.maxTilesX || pointToCheck.Y < 0 || pointToCheck.Y >= Main.maxTilesY) + return; + var targetTile = Main.tile[pointToCheck]; + if (targetTile == null || !targetTile.HasTile || !targetTile.IsTileSolidGround()) + pointToCheck.Y += 1; + else + { + TargetVector = pointToCheck.ToWorldCoordinates() - new Vector2(0, 16); + return; + } + } + } + + public void HandleAIStates() + { + Player player = Main.player[Projectile.owner]; + SegmentMaxRotation = 0.65f; + SegmentRigidity = 0.2f; + var distanceToPlayer = Projectile.Distance(player.Center); + bool onScreen = true; + if (Main.netMode == NetmodeID.SinglePlayer) //In singleplayer we base the "off screen" check on the actual screen. In multiplayer, we base it off the maximum zoom size. + { + onScreen = Collision.CheckAABBvAABBCollision(Projectile.position, Projectile.Size, Main.screenPosition, Main.ScreenSize.ToVector2()); + } + else + { + //Terraria forces the game view to never go above 1920x1200px, regardless of actual resolution. This code marks the "off screen box" to match that maximum size game viewport. (960x600 is half of 1920x1200) + onScreen = Collision.CheckAABBvAABBCollision(Projectile.position, Projectile.Size, player.Center - new Vector2(960, 600), new Vector2(1920, 1200)); + } + bool noGravity = (!onScreen || Projectile.wet || Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height, true)); + switch (ActiveAttackState) + { + case AttackState.Idle: + { + if (TargetVector == Vector2.Zero || MainTimer > 300 || (MainTimer > 120 && Projectile.Distance(TargetVector) < 64)) + { + if (Main.rand.NextBool()) + { + var veins = Burrower.FindOreVeins(Projectile.Center.ToTileCoordinates()); + while (veins.Count > 0) + { + var targetVein = veins[Main.rand.Next(veins.Count)]; + var foundTarget = Burrower.FindTargetFromVein(targetVein); + if (foundTarget is not null) + { + TargetVector = foundTarget.Value.Item1.ToWorldCoordinates(); + SecondaryVector = foundTarget.Value.Item2.ToWorldCoordinates(); + if (Projectile.Distance(TargetVector) > 160) + GeneralParticleHandler.SpawnParticle(new EmoteExpressionParticle(Projectile.Top, -Vector2.UnitY * 5, 2, ArsenalEffects.ArsenalGaussColor, 60, EmoteExpressionParticle.EmoteType.Exclamation)); + SwitchAttackState(AttackState.Mining, resetVector: false); + return; + } + else + veins.Remove(targetVein); + } + } + TargetVector = player.Center; + LowerTargetToGround(); + MainTimer = 0; + } + + var playerDistance = Projectile.Distance(Owner.Center); + float speed = 0.06f; + if (playerDistance > CalamityUtils.TilesToPixels(150)) + { + Projectile.Center = Owner.Center - Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 200; + Projectile.velocity = Projectile.velocity.ClampMagnitude(1, 8); + } + else + { + if (playerDistance < 600 && !noGravity) + Projectile.velocity.Y += 0.5f; + if (playerDistance > 600) + speed = 0.5f; + if (playerDistance > 200f) + speed = 0.4f; + else if (playerDistance > 140f) + speed = 0.2f; + if (playerDistance > 100) + Projectile.velocity += Projectile.DirectionTo(Owner.Center) * speed; + else if (Projectile.velocity.Length() > 2) + Projectile.velocity *= 0.9f; + + Projectile.velocity = Projectile.velocity.ClampMagnitude(0, 16); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + break; + } + case AttackState.Mining: + { + Projectile.velocity += Projectile.DirectionTo(SecondaryVector).SafeNormalize(Vector2.UnitY); + Projectile.velocity *= 0.9f; + if (MainTimer > 600) + SwitchAttackState(AttackState.Idle); + if (Projectile.Distance(SecondaryVector) < 4) + { + var dir = SecondaryVector.DirectionTo(TargetVector); + + if (Main.tile[TargetVector.ToTileCoordinates()].TileType == ModContent.TileType()) + { + Projectile.velocity = -Projectile.DirectionTo(TargetVector) * 16; + Projectile.Center = SecondaryVector + Projectile.velocity; + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + SwitchAttackState(AttackState.Shocked, 300); //Shock for 5 seconds + AuricOre.Animate = true; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ExoMechs/TeslaShoot1"), Projectile.Center); + return; + } + SegmentRigidity = 0f; + Projectile.velocity = Vector2.Zero; + Projectile.rotation = SecondaryVector.DirectionTo(TargetVector).ToRotation() + MathHelper.PiOver2; + + if (Main.netMode != NetmodeID.Server && !(BurrowerPingTileEffect.Instance.Active)) + TilePingerSystem.AddPing(BurrowerPingTileEffect.Instance, Projectile.Center, player); + for (int i = 0; i < 1; i++) + { + int sparkLifetime = Main.rand.Next(10, 20); + float sparkScale = Main.rand.NextFloat(0.8f, 1f); + Color sparkColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.Orange, Main.rand.NextFloat()); + + if (Main.rand.NextBool(10)) + sparkScale *= 2f; + + Vector2 sparkVelocity = dir.RotatedByRandom(0.6f) * Main.rand.NextFloat(6f, 16f); + SparkParticle spark = new SparkParticle((TargetVector + SecondaryVector) * 0.5f, -sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + + if (MainTimer < 520) + MainTimer = 520; + } + SoundEngine.PlaySound(SoundID.NPCHit18 with { Volume = 0.2f }, Projectile.Center); + } + else + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; + break; + } + case AttackState.Shocked: + { + + if (AttackSubstate > 0) + AttackSubstate--; + else + { + SwitchAttackState(AttackState.Idle); + break; + } + if (noGravity) + { + SegmentRigidity = 0; + if (AttackSubstate < 295) //5 frames to get out of the auric ore that rejected it before it slows down from tiles + Projectile.velocity *= 0.55f; + foreach (var item in Segments) + { + if (!Collision.SolidCollision(item.Center - new Vector2(19, 17), 38, 38, true)) + item.Center.Y += 2f; + } + } + else + { + Projectile.velocity.Y += 0.5f; + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; + } + break; + } + } + } + + } +} diff --git a/Projectiles/Pets/ChibiiDoggo.cs b/Projectiles/Pets/ChibiiDoggo.cs index 4d38d44c8c..9bcfc40ee6 100644 --- a/Projectiles/Pets/ChibiiDoggo.cs +++ b/Projectiles/Pets/ChibiiDoggo.cs @@ -88,7 +88,7 @@ IL_6899: public override bool PreAI() { - Projectile.type = 319; //tricks AI 26 into thinking this is a black cat, makes it act like black cat + Projectile.type = ProjectileID.BlackCat; //tricks AI 26 into thinking this is a black cat, makes it act like black cat Player player = Main.player[Projectile.owner]; player.blackCat = false; //ensure doesnt interact weird with actual black cat return true; @@ -219,7 +219,7 @@ IL_6899: } else { - player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ChibiiDoggo").Format(player.name)), 500, 0); + player.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ChibiiDoggo").ToNetworkText(player.name)), 500, 0); } player.RemoveAllIFrames(); } diff --git a/Projectiles/Pets/FrostyBatPet.cs b/Projectiles/Pets/FrostyBatPet.cs new file mode 100644 index 0000000000..0b4d6c7da9 --- /dev/null +++ b/Projectiles/Pets/FrostyBatPet.cs @@ -0,0 +1,151 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Pets +{ + public class FrostyBatPet : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Pets"; + public Player Owner => Main.player[Projectile.owner]; + public Color effectColor = Color.CornflowerBlue; + public ref float time => ref Projectile.ai[0]; + public float flapMult = 0; + public int flapTime = 0; + public int flapRate = 5; + public Vector2 goalPosition; + public Vector2 dashDirection; + public int dashingTimer = 0; + public int dashLength = 120; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 8; + Main.projPet[Type] = true; + ProjectileID.Sets.LightPet[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 24; + Projectile.friendly = true; + Projectile.netImportant = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (VerifyOwnerIsPresent()) + return; + + HandleFrames(); + + int maxFlapTime = flapRate * Main.projFrames[Type]; + if (Projectile.frame == 4) + { + if (flapTime == 0) + flapTime = maxFlapTime; + float lerp = 1 - (float)Math.Pow(Utils.GetLerpValue(flapRate - 1, 0, Projectile.frameCounter % flapRate), 1.75f); + flapMult = CalamityUtils.EaseInOutExp(lerp, 2.5f, 1f); + } + else + flapMult = 1 - (float)Math.Pow(Utils.GetLerpValue(maxFlapTime, 1, flapTime), 3); + if (flapTime > 0) + flapTime--; + + float sine = (float)Math.Sin(time * 0.05f / MathHelper.Pi); + float sine2 = (float)Math.Sin((time * 0.05f / MathHelper.Pi) * 2); + + if (dashingTimer == 0) + goalPosition = Owner.Center + new Vector2(45 * sine, -60 + 10 * sine2); + + float dashIntensity = 1 - Math.Abs(Utils.GetLerpValue(dashLength / 2, 0, dashingTimer)); + if (Owner.dashDelay == -1 && dashingTimer == 0) + { + dashingTimer = dashLength; + Projectile.extraUpdates = 1; + dashDirection = Owner.Center.DirectionTo(Owner.Calamity().mouseWorld); + } + if (dashingTimer > 0) + { + float velPower = (float)Math.Pow(Owner.velocity.Length(), 0.75f) * 35; + goalPosition = Owner.Center + dashDirection * (250 + velPower) * dashIntensity; + + float opacity = Utils.GetLerpValue(6, 12, Projectile.velocity.Length(), true) * 0.25f + 0.05f; + Particle iceMist = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 14f, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.3f, 1f) + Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f), "CalamityMod/Particles/BloomCircle", false, 22, Main.rand.NextFloat(0.3f, 0.55f), effectColor * opacity, new Vector2(1f, 1.3f), true, true, glowOpacity: opacity, extraRotation: Main.rand.NextFloat(0, MathHelper.TwoPi), spin: Main.rand.NextFloat(-0.1f, 0.1f)); + GeneralParticleHandler.SpawnParticle(iceMist); + } + else if (Projectile.extraUpdates > 0) + Projectile.extraUpdates = 0; + + float followSpeed = 10; + Projectile.velocity = (goalPosition - Projectile.Center) / (followSpeed); + + Projectile.rotation = Projectile.velocity.X * 0.035f; + + // Emit light. + float tileCollideMult = !Collision.SolidCollision(Projectile.Center, 2, 2) ? 1 : (dashingTimer > 0 ? Math.Max(Utils.GetLerpValue(dashLength * 0.8f, dashLength, dashingTimer, true), 0.15f) : 1); + if (tileCollideMult > 0) + Lighting.AddLight(Projectile.Center, effectColor.ToVector3() * (0.65f + 0.5f * dashIntensity) * tileCollideMult); + + if (Main.rand.NextBool(15 / (dashingTimer != 0 ? 3 : 1))) + { + Vector2 vel = Vector2.One.RotatedByRandom(MathHelper.TwoPi); + Particle iceFlake = new CustomSpark(Projectile.Center + vel * 9, vel * Main.rand.NextFloat(0.3f, 1.5f) + Projectile.velocity * Main.rand.NextFloat(0.1f, 0.4f), "CalamityMod/Particles/GlowFlakeParticle", false, Main.rand.Next(25, 35), Main.rand.NextFloat(0.2f, 0.45f) + (dashingTimer > 0 ? 0.2f : 0), effectColor * 0.7f, new Vector2(1f, 1f), true, true, glowOpacity: 0.8f, extraRotation: Main.rand.NextFloat(0, MathHelper.TwoPi), spin: Main.rand.NextFloat(-0.3f, 0.3f)); + GeneralParticleHandler.SpawnParticle(iceFlake); + } + + time++; + if (dashingTimer > 0) + dashingTimer--; + } + + public bool VerifyOwnerIsPresent() + { + // No logic should be run if the player is no longer active in the game. + if (!Owner.active) + { + Projectile.Kill(); + return true; + } + + if (Owner.dead) + Owner.Calamity().frostyBat = false; + if (Owner.Calamity().frostyBat) + Projectile.timeLeft = 2; + + return false; + } + + public void HandleFrames() + { + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / flapRate % Main.projFrames[Type]; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Texture2D glow = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + float sine = (float)Math.Sin((time * 0.05f / MathHelper.Pi) * 3); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition + new Vector2(0, 7) * MathHelper.Lerp(1 , -1, flapMult); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + + Rectangle frame = texture.Frame(1, 8, 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(glow, drawPosition, null, effectColor with { A = 0 } * (0.3f + 0.65f * i), Projectile.rotation, glow.Size() * 0.5f, new Vector2(1.2f, 1f) * Projectile.scale * (0.5f + sine * 0.05f * (1 - i) - 0.3f * i), Owner.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, Owner.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/FrostbatMinion.png b/Projectiles/Pets/FrostyBatPet.png similarity index 100% rename from Projectiles/Summon/FrostbatMinion.png rename to Projectiles/Pets/FrostyBatPet.png diff --git a/Projectiles/Pets/OceanSpirit.cs b/Projectiles/Pets/OceanSpirit.cs index 233fb80d29..393b00f5ce 100644 --- a/Projectiles/Pets/OceanSpirit.cs +++ b/Projectiles/Pets/OceanSpirit.cs @@ -1,5 +1,7 @@ using CalamityMod.CalPlayer; +using CalamityMod.Graphics; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -73,9 +75,11 @@ namespace CalamityMod.Projectiles.Pets Projectile.frame = sleepy ? 16 : 8; } } - underwater = player.IsUnderwater(); + underwater = player.Calamity().countsAsAnyWet; if (underwater) { + if (Main.LocalPlayer.Calamity().ZoneAbyss) + EnhancedDarknessSystem.lights.Add(new() { center = Projectile.Center, rotation = 0, scale = 6, texture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value }); if (Projectile.frame == 16) Projectile.frame = 0; if (sleepyTimer > 0) diff --git a/Projectiles/Pets/PrimroseKeepsakeDisplay.cs b/Projectiles/Pets/PrimroseKeepsakeDisplay.cs index 5f4baf9ecf..90442720aa 100644 --- a/Projectiles/Pets/PrimroseKeepsakeDisplay.cs +++ b/Projectiles/Pets/PrimroseKeepsakeDisplay.cs @@ -1,5 +1,4 @@ -using CalamityMod.CalPlayer; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Pets/SCalPet.cs b/Projectiles/Pets/SCalPet.cs index e36dffffe6..a6e0eae4d3 100644 --- a/Projectiles/Pets/SCalPet.cs +++ b/Projectiles/Pets/SCalPet.cs @@ -1,5 +1,6 @@ using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -45,8 +46,106 @@ namespace CalamityMod.Projectiles.Pets { Projectile.timeLeft = 2; } - Projectile.FloatingPetAI(false, 0.05f); - Projectile.rotation -= Projectile.spriteDirection * MathHelper.PiOver2; + float passiveMvtFloat = 0.5f; + Projectile.tileCollide = false; + int range = 300; + Vector2 center = Projectile.Center; + float distX = player.Center.X - center.X; + float distY = player.Center.Y - center.Y; + float playerDist = player.Distance(center); + float returnSpeed = 18f; + float maxDist = 2000f; + bool tooFar = playerDist > maxDist; + if (playerDist < (float)range && Main.player[Projectile.owner].velocity.Y == 0f && Projectile.position.Y + (float)Projectile.height <= Main.player[Projectile.owner].position.Y + (float)Main.player[Projectile.owner].height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + Projectile.ai[0] = 0f; + if (Projectile.velocity.Y < -6f) + { + Projectile.velocity.Y = -6f; + } + } + if (playerDist < 150f) + { + if (Math.Abs(Projectile.velocity.X) > 2f || Math.Abs(Projectile.velocity.Y) > 2f) + { + Projectile.velocity *= 0.99f; + } + passiveMvtFloat = 0.01f; + if (distX < -2f) + { + distX = -2f; + } + if (distX > 2f) + { + distX = 2f; + } + if (distY < -2f) + { + distY = -2f; + } + if (distY > 2f) + { + distY = 2f; + } + } + else + { + if (playerDist > 300f) + { + passiveMvtFloat = 0.2f; + } + playerDist = returnSpeed / playerDist; + distX *= playerDist; + distY *= playerDist; + } + if (tooFar) + { + Projectile.Center = Main.player[Projectile.owner].Center; + Projectile.velocity = Vector2.Zero; + if (Main.myPlayer == Projectile.owner) + { + Projectile.netUpdate = true; + } + } + if (Math.Abs(distX) > Math.Abs(distY) || passiveMvtFloat == 0.05f) + { + if (Projectile.velocity.X < distX) + { + Projectile.velocity.X += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && Projectile.velocity.X < 0f) + { + Projectile.velocity.X += passiveMvtFloat; + } + } + if (Projectile.velocity.X > distX) + { + Projectile.velocity.X -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && Projectile.velocity.X > 0f) + { + Projectile.velocity.X -= passiveMvtFloat; + } + } + } + if (Math.Abs(distX) <= Math.Abs(distY) || passiveMvtFloat == 0.05f) + { + if (Projectile.velocity.Y < distY) + { + Projectile.velocity.Y += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && Projectile.velocity.Y < 0f) + { + Projectile.velocity.Y += passiveMvtFloat; + } + } + if (Projectile.velocity.Y > distY) + { + Projectile.velocity.Y -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && Projectile.velocity.Y > 0f) + { + Projectile.velocity.Y -= passiveMvtFloat; + } + } + } + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; Projectile.frameCounter++; if (Projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/Sparks.cs b/Projectiles/Pets/Sparks.cs index e7918942b7..f017b35725 100644 --- a/Projectiles/Pets/Sparks.cs +++ b/Projectiles/Pets/Sparks.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Pets { if (new Rectangle((int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height).Intersects(new Rectangle((int)item.position.X, (int)item.position.Y, item.width, item.height))) { - if (Projectile.owner == Main.myPlayer && (player.ActiveItem().type != ItemID.None || player.itemAnimation <= 0)) + if (Projectile.owner == Main.myPlayer && (player.HeldItem.type != ItemID.None || player.itemAnimation <= 0)) { // TODO -- fix this maybe? (what is it?) if (!ItemLoader.OnPickup(item, player)) diff --git a/Projectiles/Pets/ToastyBatPet.cs b/Projectiles/Pets/ToastyBatPet.cs new file mode 100644 index 0000000000..bf1f326f09 --- /dev/null +++ b/Projectiles/Pets/ToastyBatPet.cs @@ -0,0 +1,135 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Pets +{ + public class ToastyBatPet : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Pets"; + public Player Owner => Main.player[Projectile.owner]; + public Color effectColor = Color.OrangeRed; + public float flapMult = 0; + public int flapTime = 0; + public int flapRate = 3; + public Vector2 goalPosition; + public ref float time => ref Projectile.ai[0]; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 8; + Main.projPet[Type] = true; + ProjectileID.Sets.LightPet[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 24; + Projectile.friendly = true; + Projectile.netImportant = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (VerifyOwnerIsPresent()) + return; + + HandleFrames(); + + int maxFlapTime = flapRate * Main.projFrames[Type]; + if (Projectile.frame == 4) + { + if (flapTime == 0) + flapTime = maxFlapTime; + float lerp = 1 - (float)Math.Pow(Utils.GetLerpValue(flapRate - 1, 0, Projectile.frameCounter % flapRate), 1.75f); + flapMult = CalamityUtils.EaseInOutExp(lerp, 2.5f, 1f); + } + else + flapMult = 1 - (float)Math.Pow(Utils.GetLerpValue(maxFlapTime, 1, flapTime), 3); + if (flapTime > 0) + flapTime--; + + float sine = (float)Math.Sin(time * 0.08f / MathHelper.Pi); + float sine2 = (float)Math.Sin((time * 0.08f / MathHelper.Pi) * 2); + + goalPosition = Owner.Center + new Vector2(35 * sine, -50 + 15 * sine2) + Owner.velocity * 8.5f; + + float followSpeed = 5.5f; + Projectile.velocity = (goalPosition - Projectile.Center) / (followSpeed); + + Projectile.rotation = Projectile.velocity.X * 0.035f; + + // Emit light. + Lighting.AddLight(Projectile.Center, Color.Lerp(effectColor, Color.White, 0.6f).ToVector3() * 0.9f); + + float speedMult = Utils.GetLerpValue(4, 8, Owner.velocity.Length(), true); + if (Main.rand.NextBool((int)(20 - 15 * speedMult))) + { + Vector2 vel = Vector2.One.RotatedByRandom(MathHelper.TwoPi); + Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 4, ModContent.DustType(), vel * Main.rand.NextFloat(0.1f, 0.5f) + Projectile.velocity * Main.rand.NextFloat(0.3f, 0.75f), 0, default, Main.rand.NextFloat(0.4f, 0.7f)); + dust.noGravity = true; + dust.color = effectColor; + dust.noLightEmittence = false; + dust.fadeIn = -0.95f; + } + if (Main.rand.NextBool((int)(10 - 7 * speedMult)) || speedMult >= 1) + { + Vector2 vel = Vector2.One.RotatedByRandom(MathHelper.TwoPi); + Particle fireFlake = new CustomSpark(Projectile.Center + vel * 3, vel * Main.rand.NextFloat(0.1f, 0.3f) + Projectile.velocity * Main.rand.NextFloat(0.1f, 0.4f), "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(35, 45), Main.rand.NextFloat(0.3f, 0.45f), effectColor * 0.2f, new Vector2(1f, 1f), true, true, glowOpacity: 0.2f, extraRotation: Main.rand.NextFloat(0, MathHelper.TwoPi), noShrink: true, spin: Main.rand.NextFloat(-0.2f, 0.2f)); + GeneralParticleHandler.SpawnParticle(fireFlake); + } + + time++; + } + + public bool VerifyOwnerIsPresent() + { + // No logic should be run if the player is no longer active in the game. + if (!Owner.active) + { + Projectile.Kill(); + return true; + } + + if (Owner.dead) + Owner.Calamity().toastyBat = false; + if (Owner.Calamity().toastyBat) + Projectile.timeLeft = 2; + + return false; + } + + public void HandleFrames() + { + Projectile.frameCounter++; + Projectile.frame = Projectile.frameCounter / flapRate % Main.projFrames[Type]; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Texture2D glow = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + float sine = (float)Math.Sin((time * 0.08f / MathHelper.Pi) * 3); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition + new Vector2(0, 7) * MathHelper.Lerp(1, -1, flapMult); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + + Rectangle frame = texture.Frame(1, 8, 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(glow, drawPosition, null, effectColor with { A = 0 } * (0.3f + 0.65f * i), Projectile.rotation, glow.Size() * 0.5f, new Vector2(1.2f, 1f) * Projectile.scale * (0.5f + sine * 0.05f * (1 - i) - 0.3f * i), Owner.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, Owner.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/FlarebatMinion.png b/Projectiles/Pets/ToastyBatPet.png similarity index 100% rename from Projectiles/Summon/FlarebatMinion.png rename to Projectiles/Pets/ToastyBatPet.png diff --git a/Projectiles/Ranged/AMR2.cs b/Projectiles/Ranged/AMR2.cs index 0e7a6fd955..bcf73a3b9a 100644 --- a/Projectiles/Ranged/AMR2.cs +++ b/Projectiles/Ranged/AMR2.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 4; Projectile.light = 0.5f; Projectile.alpha = 255; - Projectile.extraUpdates = 5; + Projectile.extraUpdates = 10; Projectile.scale = 1.18f; Projectile.tileCollide = false; Projectile.friendly = true; diff --git a/Projectiles/Ranged/AMRShot.cs b/Projectiles/Ranged/AMRShot.cs index d1c7e80d46..41299f06f5 100644 --- a/Projectiles/Ranged/AMRShot.cs +++ b/Projectiles/Ranged/AMRShot.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -24,18 +23,16 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ignoreWater = true; Projectile.penetrate = 1; Projectile.timeLeft = 600; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { - float num107 = (float)Math.Sqrt(Projectile.velocity.X * Projectile.velocity.X + Projectile.velocity.Y * Projectile.velocity.Y); if (Projectile.alpha > 0) - Projectile.alpha -= (byte)(num107 * 0.9); + Projectile.alpha -= (int)(Projectile.velocity.Length() * 0.9f); if (Projectile.alpha < 0) Projectile.alpha = 0; - Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override Color? GetAlpha(Color lightColor) @@ -76,12 +73,12 @@ namespace CalamityMod.Projectiles.Ranged if (crit) { var source = Projectile.GetSource_FromThis(); - extraProjectileAmt = 5; + extraProjectileAmt = 4; for (int x = 0; x < extraProjectileAmt; x++) { if (Projectile.owner == Main.myPlayer) { - fromRight = x > 3; + fromRight = x >= 2; CalamityUtils.ProjectileBarrage(source, Projectile.Center, targetPos, fromRight, 500f, 500f, 0f, 500f, 10f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15), Projectile.knockBack * 0.1f, Projectile.owner); } } diff --git a/Projectiles/Ranged/AcidRocket.cs b/Projectiles/Ranged/AcidRocket.cs index 982bd2cb2c..6888d2156a 100644 --- a/Projectiles/Ranged/AcidRocket.cs +++ b/Projectiles/Ranged/AcidRocket.cs @@ -1,20 +1,18 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs; using CalamityMod.Particles; -using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { + [PierceResistException] public class AcidRocket : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; @@ -103,7 +101,7 @@ namespace CalamityMod.Projectiles.Ranged if (stuckTimer == 40) { SoundStyle Primed = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGAttackSwitchShort"); - SoundEngine.PlaySound(Primed with { Volume = 0.5f }, Projectile.Center); + SoundEngine.PlaySound(Primed with { Volume = 0.4f , PitchVariance = 0.2f }, Projectile.Center); } } Projectile.Opacity = 1f; @@ -124,6 +122,7 @@ namespace CalamityMod.Projectiles.Ranged stuckInTarget = true; storedVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 8; Projectile.velocity = Vector2.Zero; + Projectile.netUpdate = true; } } diff --git a/Projectiles/Ranged/AdamAcceleratorBeam.cs b/Projectiles/Ranged/AdamAcceleratorBeam.cs index 84159ca526..f8c1737c54 100644 --- a/Projectiles/Ranged/AdamAcceleratorBeam.cs +++ b/Projectiles/Ranged/AdamAcceleratorBeam.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -7,7 +8,6 @@ using Terraria; using Terraria.Enums; using Terraria.GameContent.Shaders; using Terraria.Graphics.Effects; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.PolarityNPC().applyPolarity(polarity, target); //applies a positive or negative polarity on the target for 120 frames + target.GetGlobalNPC().applyPolarity(polarity, target); //applies a positive or negative polarity on the target for 120 frames } @@ -148,7 +148,7 @@ namespace CalamityMod.Projectiles.Ranged { // Ensure that the hit direction is correct when hitting enemies. modifiers.HitDirectionOverride = (Projectile.Center.X < target.Center.X).ToDirectionInt(); - float targetPolarity = target.PolarityNPC().CurPolarity; + float targetPolarity = target.GetGlobalNPC().CurPolarity; //If a polarity beam hits the target with the opposite polarity, the damage dealt increases by 20% if (polarity * targetPolarity < 0) { diff --git a/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs b/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs index 3af7722d96..b9fef80f94 100644 --- a/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs +++ b/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs @@ -118,11 +118,7 @@ namespace CalamityMod.Projectiles.Ranged Particle pulse = new DirectionalPulseRing(GunTipPosition + Projectile.rotation.ToRotationVector2() * 5f, Vector2.Zero, color, new Vector2(0.5f, 1f), Projectile.rotation, 0.05f, 0.34f + Main.rand.NextFloat(0.3f), 30); GeneralParticleHandler.SpawnParticle(pulse); - if (Owner == Main.LocalPlayer && Owner.Calamity().GeneralScreenShakePower < 5) - { - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 1; - } - + Owner.SetScreenshake(1f); BounceBackPower = 1f; } diff --git a/Projectiles/Ranged/AngelicBeam.cs b/Projectiles/Ranged/AngelicBeam.cs index 6748cc971a..2337c68599 100644 --- a/Projectiles/Ranged/AngelicBeam.cs +++ b/Projectiles/Ranged/AngelicBeam.cs @@ -104,8 +104,8 @@ namespace CalamityMod.Projectiles.Ranged } } - public Color LaserColor(float completionRatio) => Main.hslToRgb(0.08f + 0.05f * completionRatio + 0.05f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.7f) * 0.8f * Projectile.Opacity; - public float LaserWidth(float completionRatio) => 30f * Projectile.Opacity * Projectile.scale; + public Color LaserColor(float completionRatio, Vector2 vertexPos) => Main.hslToRgb(0.08f + 0.05f * completionRatio + 0.05f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.7f) * 0.8f * Projectile.Opacity; + public float LaserWidth(float completionRatio, Vector2 vertexPos) => 30f * Projectile.Opacity * Projectile.scale; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Ranged/AnimosityBullet.cs b/Projectiles/Ranged/AnimosityBullet.cs index 546f2b7cf2..a52e6c2f5e 100644 --- a/Projectiles/Ranged/AnimosityBullet.cs +++ b/Projectiles/Ranged/AnimosityBullet.cs @@ -1,9 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; using CalamityMod.Particles; using CalamityMod.Systems; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -32,7 +30,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = Main.zenithWorld ? 3 : 1; Projectile.extraUpdates = 2; Projectile.timeLeft = 300; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { diff --git a/Projectiles/Ranged/AquaBlast.cs b/Projectiles/Ranged/AquaBlast.cs index 4a0a100b61..147e0e0344 100644 --- a/Projectiles/Ranged/AquaBlast.cs +++ b/Projectiles/Ranged/AquaBlast.cs @@ -1,10 +1,6 @@ -using System.Diagnostics.Contracts; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -34,7 +30,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = Lifetime; Projectile.extraUpdates = 2; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/Aquashard.cs b/Projectiles/Ranged/Aquashard.cs index 7aaa3c6e6a..0e33af218e 100644 --- a/Projectiles/Ranged/Aquashard.cs +++ b/Projectiles/Ranged/Aquashard.cs @@ -1,52 +1,140 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using CalamityMod.Tiles.Abyss; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.GameContent.Animations.Actions.Sprites; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using CalamityMod.Projectiles.Summon; namespace CalamityMod.Projectiles.Ranged { public class Aquashard : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public int time = 0; public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = 20; + Projectile.height = 20; Projectile.friendly = true; + Projectile.tileCollide = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; Projectile.timeLeft = 300; - Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { - Projectile.velocity.X *= 0.9995f; - Projectile.velocity.Y += 0.01f; + //Rotation + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (time == 1) + { + Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5; + int smokeAmount = Main.rand.Next(8, 12 + 1); + for (int i = 0; i < smokeAmount; i++) + { + Particle smoke = new HeavySmokeParticle(Projectile.Center, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(1.2f, 2f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + } + for (int i = 0; i < 5; i++) + { + Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(0.2f, 0.4f), false, 12, 0.009f, Color.DarkTurquoise, new Vector2(1.5f, 0.7f), true, false, 1.3f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + if (time >= 2) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 135 : 279, -Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.05f, 0.2f) - new Vector2(0, 1)); + dust.scale = Main.rand.NextFloat(0.6f, 0.8f); + dust.noGravity = false; + } + if (time == 14) + { + Projectile.Kill(); + } + time++; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - int projAmt = Main.rand.Next(1, 3); - if (Projectile.owner == Main.myPlayer) + int projAmt = 3; + for (int i = 0; i < projAmt; i++) { - for (int i = 0; i < projAmt; i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Projectile.owner); - } + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 35f, 50f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.3f), 0f, Projectile.owner); } + float offset = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < 4; i++) + { + Vector2 velocity = (MathHelper.TwoPi * i / 4f + offset).ToRotationVector2() * 0.5f;; + Particle cross = new SparkParticle(Projectile.Center + velocity * 15f, velocity, false, 15, 1.5f, Color.DarkTurquoise, true); + GeneralParticleHandler.SpawnParticle(cross); + } + for (int k = 0; k < 3; k++) + { + Particle outerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkSlateBlue, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.25f, 25); + GeneralParticleHandler.SpawnParticle(outerGlow); + Particle innerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkTurquoise, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.15f, 25); + GeneralParticleHandler.SpawnParticle(innerGlow); + } + Player Owner = Main.player[Projectile.owner]; + if (Owner.Calamity().GeneralScreenShakePower < 1.2f) + Owner.Calamity().GeneralScreenShakePower = 1.2f; + target.AddBuff(ModContent.BuffType(), 30); } public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item27, Projectile.position); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath with { Volume = 0.8f }, Projectile.Center); + int projAmt = 3; + if (Projectile.owner == Main.myPlayer) + { + for (int i = 0; i < projAmt; i++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 35f, 50f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Projectile.owner); + } + } + // Create Blast + float blastSize = 80; + float minMultiplier = 0.25f; + int hitsToMinMult = 8; + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.DamageType = DamageClass.Ranged; + blast.ArmorPenetration = 5; for (int k = 0; k < 5; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Rain, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); } + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkTurquoise, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-12, 12), 0f, 0.08f, 22); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DeepSkyBlue * 0.8f, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.06f, 22, true); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DeepSkyBlue * 0.8f, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.2f, 22, true); + GeneralParticleHandler.SpawnParticle(blastRing3); + for (int i = 0; i < (int)(15); i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(1f, 1.3f)); + dust.noGravity = !Main.rand.NextBool(); + dust.color = Main.rand.NextBool(5) ? Color.DeepSkyBlue : Color.DarkTurquoise; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + { + return false; + } + return base.PreDraw(ref lightColor); } } } diff --git a/Projectiles/Ranged/Aquashard.png b/Projectiles/Ranged/Aquashard.png index 0e32025173..54457ff6b4 100644 Binary files a/Projectiles/Ranged/Aquashard.png and b/Projectiles/Ranged/Aquashard.png differ diff --git a/Projectiles/Ranged/AquashardSplit.cs b/Projectiles/Ranged/AquashardSplit.cs index a9555374d0..82ce78b9f9 100644 --- a/Projectiles/Ranged/AquashardSplit.cs +++ b/Projectiles/Ranged/AquashardSplit.cs @@ -2,13 +2,15 @@ using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Projectiles.Ranged { public class AquashardSplit : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/Ranged/Aquashard"; public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; public override void SetDefaults() @@ -36,10 +38,16 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item27, Projectile.position); - for (int k = 0; k < 5; k++) + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.5f, PitchVariance = 0.3f }, Projectile.Center); + Particle Star = new CritSpark(Projectile.Center, Vector2.Zero, Color.SkyBlue, Color.DarkTurquoise, Main.rand.NextFloat(1f, 1.1f), 30, 0.1f, 3f); + GeneralParticleHandler.SpawnParticle(Star); + int num190 = Main.rand.Next(5, 9); + for (int i = 0; i < num190; i++) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Rain, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); + int bubbly = Dust.NewDust(Projectile.Center, 0, 0, DustID.UnusedWhiteBluePurple, 0f, 0f, 100, default, 1.4f); + Main.dust[bubbly].velocity *= 0.8f; + Main.dust[bubbly].position = Vector2.Lerp(Main.dust[bubbly].position, Projectile.Center, 0.5f); + Main.dust[bubbly].noGravity = true; } } } diff --git a/Projectiles/Ranged/AquashardSplit.png b/Projectiles/Ranged/AquashardSplit.png new file mode 100644 index 0000000000..55f7bbe5a6 Binary files /dev/null and b/Projectiles/Ranged/AquashardSplit.png differ diff --git a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs index bfda144189..7845aed473 100644 --- a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs +++ b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs @@ -1,8 +1,11 @@ -using CalamityMod.Items.Weapons.Ranged; +using System; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using ReLogic.Utilities; using Terraria; using Terraria.Audio; @@ -18,12 +21,21 @@ namespace CalamityMod.Projectiles.Ranged public override float OffsetXUpwards => -5f; public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 5f; + public override float RecoilResolveSpeed => (KeepRefreshingLifetime || CurrentChargingFrames < ArcNovaDiffuser.Charge2Frames) ? 0.4f : 0.04f; public static int FramesPerLoad = 13; public static int MaxLoadableShots = 15; public static float BulletSpeed = 12f; public SlotId NovaChargeSlot; + public Vector2 effectSpot; + public float effectScale = 0; + public Vector2 effectSpot2; + public float effectScale2 = 0; + public Vector2 effectSpot3; + public float effectScale3 = 0; + public int time = 0; + public ref float CurrentChargingFrames => ref Projectile.ai[0]; public ref float ShotsLoaded => ref Projectile.ai[1]; public ref float ShootRecoilTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil @@ -32,7 +44,7 @@ namespace CalamityMod.Projectiles.Ranged public override void KillHoldoutLogic() { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type) Projectile.Kill(); } @@ -55,21 +67,37 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = ArcNovaDiffuser.AftershotCooldownFrames * 2; ChargeSound?.Stop(); - SoundEngine.PlaySound(ArcNovaDiffuser.BigShot, Projectile.position); + SoundEngine.PlaySound(ArcNovaDiffuser.BigShot, Projectile.Center); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - int charge2Damage = Projectile.damage * 20; + int charge2Damage = (int)(Projectile.damage * 9f); float charge2KB = Projectile.knockBack * 3f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), charge2Damage, charge2KB, Projectile.owner); - Owner.Calamity().GeneralScreenShakePower = 6.5f; - for (int i = 0; i <= 25; i++) + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), charge2Damage, charge2KB, Projectile.owner); + Owner.SetScreenshake(6.5f); + for (int i = 0; i <= 45; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, 107, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.2f), 0, default, Main.rand.NextFloat(1f, 2.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, ModContent.DustType(), shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.6f, 1.9f), 0, default, Main.rand.NextFloat(2f, 3.3f)); dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Lime : ArcNovaDiffuser.mainColor; + dust.fadeIn = 2.5f; + if (Main.rand.NextBool(4)) + { + dust.scale = Main.rand.NextFloat(0.8f, 0.95f); + dust.fadeIn = -0.85f; + dust.velocity /= 2; + } } + for (int i = 0; i < 2; i++) + { + Particle spark2 = new CustomSpark(GunTipPosition, Projectile.velocity * 25, "CalamityMod/Particles/BloomCircle", false, 16, 0.95f, ArcNovaDiffuser.mainColor, new Vector2(1.8f, 0.8f), true, true, glowOpacity: 0.9f, shrinkSpeed: 0.8f); + GeneralParticleHandler.SpawnParticle(spark2); + } + Particle spark = new CustomSpark(GunTipPosition, Projectile.velocity * 2, "CalamityMod/Particles/BloomRing", false, 12, 0.7f, ArcNovaDiffuser.mainColor, new Vector2(0.5f, 1.5f), true, false, extraRotation: -MathHelper.PiOver2, noShrink: true); + GeneralParticleHandler.SpawnParticle(spark); ShotsLoaded = 0; - ShootRecoilTimer = 24f; + ShootRecoilTimer = Projectile.timeLeft = 55; OffsetLengthFromArm -= 25f; } // Retracting recoil @@ -88,36 +116,34 @@ namespace CalamityMod.Projectiles.Ranged if (ShootRecoilTimer <= 0f) { ChargeSound?.Stop(); - SoundEngine.PlaySound(ArcNovaDiffuser.SmallShot, Projectile.position); + SoundEngine.PlaySound(ArcNovaDiffuser.SmallShot, Projectile.Center); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; Vector2 fireVec = shootVelocity.RotatedByRandom(MathHelper.ToRadians(2f)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec * (ChargeLV1 ? 1 : 0.7f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); for (int i = 0; i <= 4; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, 107, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(0.8f, 1.8f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, ModContent.DustType(), shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(1.2f, 1.6f), 0, default, Main.rand.NextFloat(0.8f, 1.8f)); dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Lime : ArcNovaDiffuser.mainColor; + dust.fadeIn = 1.5f; + if (Main.rand.NextBool(6)) + { + dust.scale = Main.rand.NextFloat(0.4f, 0.5f); + dust.fadeIn = -0.85f; + dust.velocity /= 2; + } } ShotsLoaded--; - ShootRecoilTimer = 16f; - OffsetLengthFromArm -= 5f; + ShootRecoilTimer = (int)MathHelper.Lerp(33, 13, Math.Min(CurrentChargingFrames / ArcNovaDiffuser.Charge1Frames, 1)); + OffsetLengthFromArm -= 6f; } } // Retracting any remaining recoil else if (ShootRecoilTimer > 0) ShootRecoilTimer -= 2; - - // Fires a burst of sparks on the last shot - if (ShotsLoaded == 0) - { - for (int i = 0; i < 6; i++) - { - SparkParticle spark2 = new SparkParticle((GunTipPosition - Projectile.velocity * 3) + Main.rand.NextVector2Circular(10, 10), -Projectile.velocity * Main.rand.NextFloat(9.1f, 17.8f), false, Main.rand.Next(9, 12), Main.rand.NextFloat(0.2f, 0.3f), Main.rand.NextBool(4) ? Color.Chartreuse : Color.Lime); - GeneralParticleHandler.SpawnParticle(spark2); - } - ShotsLoaded--; - } } else { @@ -152,16 +178,6 @@ namespace CalamityMod.Projectiles.Ranged if (CurrentChargingFrames >= 10) { float particleScale = MathHelper.Clamp(CurrentChargingFrames, 0f, ArcNovaDiffuser.Charge2Frames); - for (int i = 0; i < (ChargeLV2 ? 4 : ChargeLV1 ? 3 : 2); i++) - { - SparkParticle spark2 = new SparkParticle((GunTipPosition - Projectile.velocity * 4) + Main.rand.NextVector2Circular(12, 12), -Projectile.velocity * Main.rand.NextFloat(16.1f, 30.8f), false, Main.rand.Next(2, 7), Main.rand.NextFloat(particleScale / 350f, particleScale / 270f), Main.rand.NextBool(4) ? Color.Chartreuse : Color.Lime); - GeneralParticleHandler.SpawnParticle(spark2); - } - Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Lime, particleScale / 270f, 2, false); - GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.White, particleScale / 400f, 2, false); - GeneralParticleHandler.SpawnParticle(orb2); - float strength = particleScale / 45f; Vector3 DustLight = new Vector3(0.000f, 0.255f, 0.000f); Lighting.AddLight(GunTipPosition, DustLight * strength); @@ -170,25 +186,30 @@ namespace CalamityMod.Projectiles.Ranged // Full charge dusts if (CurrentChargingFrames == ArcNovaDiffuser.Charge1Frames) { - for (int i = 0; i < 36; i++) + for (int i = 0; i < 25; i++) { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 107); - chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 8f + Owner.velocity; - chargefull.scale = Main.rand.NextFloat(1f, 1.3f); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = (MathHelper.TwoPi * i / 25f).ToRotationVector2() * Main.rand.NextFloat(8, 9.5f); + chargefull.scale = Main.rand.NextFloat(1.2f, 1.5f); chargefull.noGravity = true; + chargefull.color = Main.rand.NextBool(3) ? Color.Lime : ArcNovaDiffuser.mainColor; + chargefull.fadeIn = 1; } } if (CurrentChargingFrames == ArcNovaDiffuser.Charge2Frames) { - for (int i = 0; i < 45; i++) + for (int i = 0; i < 35; i++) { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 107); - chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 12f + Owner.velocity; - chargefull.scale = Main.rand.NextFloat(1.2f, 1.4f); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = (MathHelper.TwoPi * i / 35f).ToRotationVector2() * Main.rand.NextFloat(11, 13.5f); + chargefull.scale = Main.rand.NextFloat(1.7f, 1.9f); chargefull.noGravity = true; + chargefull.color = Main.rand.NextBool(3) ? Color.Lime : ArcNovaDiffuser.mainColor; + chargefull.fadeIn = 1; } } } + time++; } public override void OnKill(int timeLeft) @@ -199,20 +220,52 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { + if (time < 2) + return false; Texture2D texture = TextureAssets.Projectile[Type].Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 tipDrawPosition = GunTipPosition - Main.screenPosition; float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); Vector2 rotationPoint = texture.Size() * 0.5f; SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Color color = ArcNovaDiffuser.mainColor; + float chargeScale = KeepRefreshingLifetime ? Math.Min(Utils.GetLerpValue(0, ArcNovaDiffuser.Charge1Frames, CurrentChargingFrames, false), 2) : 0; if (!Owner.CantUseHoldout()) { float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, ArcNovaDiffuser.Charge2Frames); drawPosition += Main.rand.NextVector2Circular(rumble / 70f, rumble / 70f); } + float sine = (float)Math.Sin(time * 0.15f / MathHelper.Pi); + for (int i = 0; i < 10; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * (2f + sine * 0.3f); + Main.EntitySpriteDraw(texture, drawPosition + drawOffset * chargeScale, null, color with { A = 0 } * Math.Min(chargeScale, 1) * 0.3f, drawRotation, rotationPoint, Projectile.scale, flipSprite, 0); + } + Asset tex2 = ModContent.Request("CalamityMod/Particles/BloomCircle"); + Asset tex3 = ModContent.Request("CalamityMod/Particles/ForwardSmear"); + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + for (int i = 0; i < 4; i++) + { + Vector2 place = Vector2.One.RotateRandom(MathHelper.TwoPi) * Main.rand.NextFloat(1, 5.5f) * Math.Min(chargeScale, 1); + Vector2 vel = Projectile.velocity.RotatedByRandom(0.3f); + Main.EntitySpriteDraw(tex3.Value, tipDrawPosition + place - Vector2.Lerp(place, -Projectile.velocity, 0.9f) * Main.rand.NextFloat(15, 35) + Projectile.velocity * -8 * (6 - chargeScale * 2), null, (Main.rand.NextBool(3) ? Color.Lime : color) with { A = 0 } * 0.8f * Math.Min(chargeScale, 1), vel.ToRotation() - MathHelper.PiOver2, new Vector2(tex3.Width() / 2, tex3.Height()), new Vector2(0.25f * chargeScale, (1.7f + (Main.rand.NextBool(4) ? 1.8f : 0))) * Projectile.scale * 0.05f * Math.Min(chargeScale, 1), SpriteEffects.None, 0); + } + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(tex2.Value, tipDrawPosition, null, Color.Lerp(color, Color.White, i * 0.25f) with { A = 0 } * 0.8f, Main.rand.NextFloat(-5, 5), tex2.Size() * 0.5f, new Vector2(1.35f, 1f) * Projectile.scale * chargeScale * (1 - 0.27f * i) * 0.23f, SpriteEffects.None, 0); + if (CurrentChargingFrames >= ArcNovaDiffuser.Charge2Frames) + { + for (int y = 0; y < 3; y++) + { + Vector2 angleVel = (MathHelper.TwoPi * y / 3f).ToRotationVector2().RotatedBy(time * 0.18f); + Vector2 drawOffset = (new Vector2(angleVel.X * 0.7f, angleVel.Y * 1.2f)).RotatedBy(Projectile.rotation) * chargeScale * 12; + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(tex2.Value, tipDrawPosition + drawOffset, null, Color.Lerp(color, Color.White, i) with { A = 0 } * 0.8f, Main.rand.NextFloat(-5, 5), tex2.Size() * 0.5f, new Vector2(1f, 1f) * Projectile.scale * chargeScale * (1 - 0.25f * i) * 0.085f * (CurrentChargingFrames <= ArcNovaDiffuser.Charge2Frames + 3 ? 3 : 1), SpriteEffects.None, 0); + } + } return false; } } diff --git a/Projectiles/Ranged/ArcherfishRing.cs b/Projectiles/Ranged/ArcherfishRing.cs index afbe1a3107..53c71a5842 100644 --- a/Projectiles/Ranged/ArcherfishRing.cs +++ b/Projectiles/Ranged/ArcherfishRing.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 3; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox); @@ -83,7 +82,7 @@ namespace CalamityMod.Projectiles.Ranged for (float i = 0f; i < totalDusts; i++) { Vector2 ringSpeed = new Vector2((float)Math.Cos(i / totalDusts * MathHelper.TwoPi), (float)Math.Sin(i / totalDusts * MathHelper.TwoPi) * 0.5f).RotatedBy(Projectile.rotation) * 4f * Projectile.scale; - Dust droplets = Dust.NewDustPerfect(Projectile.Center, 211, ringSpeed, 100); + Dust droplets = Dust.NewDustPerfect(Projectile.Center, DustID.Wet, ringSpeed, 100); droplets.noGravity = true; } } diff --git a/Projectiles/Ranged/ArcherfishShot.cs b/Projectiles/Ranged/ArcherfishShot.cs index 918ebc8a95..0f128affa3 100644 --- a/Projectiles/Ranged/ArcherfishShot.cs +++ b/Projectiles/Ranged/ArcherfishShot.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -25,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 3; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/AstralRound.cs b/Projectiles/Ranged/AstralRound.cs index 834728bd1c..8f89a2b96b 100644 --- a/Projectiles/Ranged/AstralRound.cs +++ b/Projectiles/Ranged/AstralRound.cs @@ -30,7 +30,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.light = 0.25f; Projectile.extraUpdates = 2; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Ranged/AstralSandgun.cs b/Projectiles/Ranged/AstralSandgun.cs index dd09fb1abf..44efefd7a5 100644 --- a/Projectiles/Ranged/AstralSandgun.cs +++ b/Projectiles/Ranged/AstralSandgun.cs @@ -17,7 +17,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/AstrealArrow.cs b/Projectiles/Ranged/AstrealArrow.cs index 4d72d5c9f0..08761e3027 100644 --- a/Projectiles/Ranged/AstrealArrow.cs +++ b/Projectiles/Ranged/AstrealArrow.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -27,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 1; Projectile.penetrate = 1; Projectile.timeLeft = 600; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/AstrealFlame.cs b/Projectiles/Ranged/AstrealFlame.cs index 06d379b47a..0839e99708 100644 --- a/Projectiles/Ranged/AstrealFlame.cs +++ b/Projectiles/Ranged/AstrealFlame.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/AuralisBullet.cs b/Projectiles/Ranged/AuralisBullet.cs index 9de76738f3..6051520954 100644 --- a/Projectiles/Ranged/AuralisBullet.cs +++ b/Projectiles/Ranged/AuralisBullet.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 10; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/AuricBullet.cs b/Projectiles/Ranged/AuricBullet.cs index 9a2f524c55..e125194e84 100644 --- a/Projectiles/Ranged/AuricBullet.cs +++ b/Projectiles/Ranged/AuricBullet.cs @@ -1,13 +1,10 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Ranged { @@ -32,7 +29,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.extraUpdates = 15; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.tileCollide = false; Projectile.ArmorPenetration = 50; Projectile.alpha = 255; @@ -98,10 +94,11 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i <= 6; i++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 226, new Vector2(2, 2).RotatedByRandom(100f) * Main.rand.NextFloat(0.1f, 2.9f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.Electric, new Vector2(2, 2).RotatedByRandom(100f) * Main.rand.NextFloat(0.1f, 2.9f)); dust2.noGravity = false; dust2.scale = Main.rand.NextFloat(0.3f, 0.9f); } } + public override bool? CanHitNPC(NPC target) => target.CanBeChasedBy() ? null : false; } } diff --git a/Projectiles/Ranged/AuroraFire.cs b/Projectiles/Ranged/AuroraFire.cs index 42d6af0c6d..8ae685bc7a 100644 --- a/Projectiles/Ranged/AuroraFire.cs +++ b/Projectiles/Ranged/AuroraFire.cs @@ -1,14 +1,15 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { + [PierceResistException(onlyForSingleHitbox: true)] public class AuroraFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; diff --git a/Projectiles/Ranged/BallistaGreatArrow.cs b/Projectiles/Ranged/BallistaGreatArrow.cs index d9a48ebcd8..33f3b8a93f 100644 --- a/Projectiles/Ranged/BallistaGreatArrow.cs +++ b/Projectiles/Ranged/BallistaGreatArrow.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -29,7 +27,6 @@ namespace CalamityMod.Projectiles.Ranged AIType = ProjectileID.WoodenArrowFriendly; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool OnTileCollide(Vector2 oldVelocity) @@ -41,23 +38,17 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); target.AddBuff(ModContent.BuffType(), 180); - } - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - if (Projectile.owner == Main.myPlayer) + for (int i = 0; i < 2; i++) // Burst into 2 shards upwards { - for (int i = -1; i < 2; i++) // Burst into 3 shards upwards - { - Vector2 baseVelocity = Vector2.UnitY * -12f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Top, baseVelocity.RotatedBy(MathHelper.ToRadians(10 * i)), ModContent.ProjectileType(), Projectile.damage / 4, Projectile.knockBack * 0.25f, Projectile.owner); - } + Vector2 baseVelocity = Vector2.UnitY * -12f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Top, baseVelocity.RotatedByRandom(MathHelper.Pi * 0.1f), ModContent.ProjectileType(), Projectile.damage / 4, Projectile.knockBack * 0.25f, Projectile.owner); } } + public override void OnKill(int timeLeft) => SoundEngine.PlaySound(SoundID.Item14, Projectile.position); + public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); diff --git a/Projectiles/Ranged/BarinadeArrow.cs b/Projectiles/Ranged/BarinadeArrow.cs index 8e5a2ad405..36075d3f3d 100644 --- a/Projectiles/Ranged/BarinadeArrow.cs +++ b/Projectiles/Ranged/BarinadeArrow.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -26,7 +25,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.extraUpdates = 2; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { @@ -42,7 +40,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 5; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 216 : 121, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.6f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 216 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.6f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); dust.noGravity = true; } } diff --git a/Projectiles/Ranged/BarinadeArrow.png b/Projectiles/Ranged/BarinadeArrow.png index 6e8c0c4a87..d4720a0d0e 100644 Binary files a/Projectiles/Ranged/BarinadeArrow.png and b/Projectiles/Ranged/BarinadeArrow.png differ diff --git a/Projectiles/Ranged/BlightFlames.cs b/Projectiles/Ranged/BlightFlames.cs index a66ebc3f36..78afb7d58f 100644 --- a/Projectiles/Ranged/BlightFlames.cs +++ b/Projectiles/Ranged/BlightFlames.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 91, Projectile.velocity * 0.6f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.GemDiamond, Projectile.velocity * 0.6f); dust.scale = Main.rand.NextFloat(1.1f, 1.9f); dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); dust.noGravity = true; @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 3; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 220, Projectile.velocity * 0.6f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworkFountain_Green, Projectile.velocity * 0.6f); dust.scale = Main.rand.NextFloat(0.4f, 1.2f); dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); dust.noGravity = false; @@ -80,13 +80,13 @@ namespace CalamityMod.Projectiles.Ranged } if (Main.rand.NextBool(4) && Time > 135 && !postTileHit && !postEnemyHit) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), 220, Vector2.Zero); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), DustID.FireworkFountain_Green, Vector2.Zero); dust.scale = Main.rand.NextFloat(0.2f, 0.4f); dust.noGravity = true; } if (Main.rand.NextBool(20) && (postTileHit || postEnemyHit)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), 220, Vector2.Zero); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), DustID.FireworkFountain_Green, Vector2.Zero); dust.scale = Main.rand.NextFloat(0.4f, 1.2f); dust.noGravity = true; } @@ -118,8 +118,11 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { //if (!postTileHit) - //Projectile.Center = Projectile.Center + Main.rand.NextVector2Circular(20, 20); - target.AddBuff(ModContent.BuffType(), 420); + //Projectile.Center = Projectile.Center + Main.rand.NextVector2Circular(20, 20); + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); for (int i = 0; i <= 3; i++) { diff --git a/Projectiles/Ranged/BlissfulBombardierHoldout.cs b/Projectiles/Ranged/BlissfulBombardierHoldout.cs index 8304e5168a..8bd3e4faf7 100644 --- a/Projectiles/Ranged/BlissfulBombardierHoldout.cs +++ b/Projectiles/Ranged/BlissfulBombardierHoldout.cs @@ -87,6 +87,7 @@ namespace CalamityMod.Projectiles.Ranged if (Owner.CantUseHoldout() && PostFireCooldown <= 0 && shootingTimer < (int)(Owner.itemAnimationMax * 0.8f)) { Projectile.Kill(); + return; } if (!hasFired) @@ -107,7 +108,7 @@ namespace CalamityMod.Projectiles.Ranged } else { - Dust dust = Dust.NewDustPerfect(GunTipPosition, 278, (Projectile.velocity * 12).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.4f, 1.7f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB, (Projectile.velocity * 12).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.4f, 1.7f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); dust.noGravity = false; dust.color = Main.rand.NextBool(3) ? Color.Orange : staticEffectsColor; } @@ -152,10 +153,12 @@ namespace CalamityMod.Projectiles.Ranged } // Spawns the projectile. - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootDirection * projSpeed * velocityMultiplier, ProjectileType(), damage, knockback, Projectile.owner, rocketType); - PostFireCooldown = Owner.itemAnimationMax; - Owner.Calamity().GeneralScreenShakePower = 5f; - + if (Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootDirection * projSpeed * velocityMultiplier, ProjectileType(), damage, knockback, Projectile.owner, rocketType); + PostFireCooldown = Owner.itemAnimationMax; + Owner.SetScreenshake(5f); + } // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. @@ -186,7 +189,7 @@ namespace CalamityMod.Projectiles.Ranged Particle smoke = new HeavySmokeParticle(GunTipPosition, 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); GeneralParticleHandler.SpawnParticle(smoke); - Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); dust.noGravity = false; dust.color = staticEffectsColor; } diff --git a/Projectiles/Ranged/BloodBoilerFire.cs b/Projectiles/Ranged/BloodBoilerFire.cs index af3ed087d8..6f66d1d97f 100644 --- a/Projectiles/Ranged/BloodBoilerFire.cs +++ b/Projectiles/Ranged/BloodBoilerFire.cs @@ -1,12 +1,12 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Metaballs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Projectiles.Healing; namespace CalamityMod.Projectiles.Ranged { @@ -195,19 +195,9 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.Hitbox.Intersects(player.Hitbox)) { - if (!Main.player[Projectile.owner].moonLeech) + if (improvedHeal) { - int bonusHeal = Main.rand.NextBool(3) ? 5 : 3; - int heal = improvedHeal ? bonusHeal : 2; - - if (Main.LocalPlayer.lifeSteal <= 0f) - { - Projectile.Kill(); - return; - } - - Main.LocalPlayer.lifeSteal -= heal; - player.HealPlayer(heal); + BloodstoneHealOrb.Heal(player, 6); } Projectile.Kill(); @@ -218,8 +208,11 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 360); - target.AddBuff(ModContent.BuffType(), 360); + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); + target.AddBuff(ModContent.BuffType(), 1200); improvedHeal = true; } diff --git a/Projectiles/Ranged/BloodClotFriendly.cs b/Projectiles/Ranged/BloodClotFriendly.cs index a72db98d46..caf1e8b0b1 100644 --- a/Projectiles/Ranged/BloodClotFriendly.cs +++ b/Projectiles/Ranged/BloodClotFriendly.cs @@ -26,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.extraUpdates = 3; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index 985287bd5b..2ab87f6171 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -1,12 +1,7 @@ -using System; -using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -17,6 +12,9 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; + //Used by Arterial Assault + public bool DisableEffects = false; + public override string Texture => "CalamityMod/Items/Ammo/BloodfireArrow"; public override void SetStaticDefaults() @@ -33,9 +31,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.arrow = true; Projectile.penetrate = 1; - Projectile.extraUpdates = 6; + Projectile.extraUpdates = 9; Projectile.timeLeft = 1200; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -46,13 +43,22 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] == 0) { - player.statLife -= 1; - if (player.statLife <= 0) + if (DisableEffects) { - PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodFireArrow" + Main.rand.Next(1, 2 + 1)).Format(player.name)); - player.KillMe(pdr, 1000.0, 0, false); + + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9; + } else + { + Projectile.damage = (int)(Projectile.damage * 1.3f); // damage boost + player.statLife -= 1; + if (player.statLife <= 0) + { + PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodFireArrow" + Main.rand.Next(1, 2 + 1)).ToNetworkText(player.name)); + player.KillMe(pdr, 1000.0, 0, false); + } + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9; } - Projectile.velocity *= 0.4f; + } Player Owner = Main.player[Projectile.owner]; @@ -73,36 +79,37 @@ namespace CalamityMod.Projectiles.Ranged if (dust.type == 130) dust.scale = Main.rand.NextFloat(0.25f, 0.45f); } - PointParticle spark = new PointParticle(Projectile.Center - Projectile.velocity, -Projectile.velocity * 0.01f, false, 2, 1.2f, Color.Firebrick); - GeneralParticleHandler.SpawnParticle(spark); + if (Projectile.localAI[0] % 2 == 0) + { + Particle spark = new CustomSpark(Projectile.Center - Projectile.velocity * 2, -Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomLineFade", false, 6, 0.025f, Color.Firebrick, new Vector2(1, 1), true, true, shrinkSpeed: 1.4f, glowOpacity: 0.4f); + GeneralParticleHandler.SpawnParticle(spark); + } } } public override void OnKill(int timeLeft) { - for (int b = 0; b < 9; b++) + for (int b = 0; b < 6; b++) { - int dustType = Main.rand.NextBool() ? 303 : 90; + int dustType = ModContent.DustType(); float velMulti = Main.rand.NextFloat(0.1f, 0.75f); - Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, new Vector2(4, 4).RotatedByRandom(100) * velMulti); + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, (Projectile.velocity * 2).RotatedByRandom(0.3) * velMulti); dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.75f, 1.35f); - if (dust.type == 303) - dust.color = Color.Firebrick; + dust.scale = Main.rand.NextFloat(0.75f, 0.95f); + dust.color = Color.Firebrick; + dust.noLightEmittence = true; + dust.noLight = true; + dust.fadeIn = 15; } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + if (DisableEffects) + return; Player player = Main.player[Projectile.owner]; player.lifeRegenTime += 2; - if (player.moonLeech) - return; - - if (target.lifeMax <= 5) - return; - float lifeRatio = (float)player.statLife / player.statLifeMax2; float averageHealAmount = MathHelper.Lerp(4.0f, 0.5f, lifeRatio); // Average heal increases from 1/2 to 4 HP based on missing health int guaranteedHeal = (int)averageHealAmount; @@ -110,16 +117,12 @@ namespace CalamityMod.Projectiles.Ranged float chanceOfOneMoreHP = averageHealAmount - guaranteedHeal; bool bonusHeal = Main.rand.NextFloat() < chanceOfOneMoreHP; int finalHeal = guaranteedHeal + (bonusHeal ? 1 : 0); - if (finalHeal > BalancingConstants.LifeStealCap) - finalHeal = BalancingConstants.LifeStealCap; - - if (finalHeal > 0) - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], finalHeal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + player.SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, finalHeal, 0.5f); } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.White, 2); return false; } } diff --git a/Projectiles/Ranged/BloodfireBulletProj.cs b/Projectiles/Ranged/BloodfireBulletProj.cs index cdf8888264..287413b0ff 100644 --- a/Projectiles/Ranged/BloodfireBulletProj.cs +++ b/Projectiles/Ranged/BloodfireBulletProj.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -25,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.extraUpdates = 12; Projectile.timeLeft = Lifetime; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.tileCollide = false; } @@ -76,36 +76,34 @@ namespace CalamityMod.Projectiles.Ranged return true; } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage.Flat += OnHitEffect(Main.player[Projectile.owner]); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= OnHitEffect(Main.player[Projectile.owner], target); // Returns the amount of bonus damage that should be dealt. Boosts life regeneration appropriately as a side effect. - private int OnHitEffect(Player owner) + private float OnHitEffect(Player owner, NPC target) { - // Adds 3 frames to lifeRegenTime on every hit. This increased value is used for the damage calculation. + // Adds 3 frames to natural life regen on each hit owner.lifeRegenTime += 3; - // Deals (1.00 + (0.1 * current lifeRegen))% of current lifeRegenTime as flat bonus damage on hit. - // For example, at 0 life regen, you get 1% of lifeRegenTime as bonus damage. - // At 10 life regen, you get 2%. At 20 life regen, you get 3%. - // Negative life regen does not decrease damage. - int regenForCalc = owner.lifeRegen > 0 ? owner.lifeRegen : 0; - float regenDamageRatio = (1f + 0.1f * regenForCalc) / 100f; + // Provides up to 10% damage boost based on life regen time, caps at 3600 + float lifeRegenTimeContribution = Utils.GetLerpValue(0, 3600, owner.lifeRegenTime, true) * 0.1f; + float finalDamageBoost = 1 + lifeRegenTimeContribution; - // For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla. 75% of this is taken for computing the final damage. - int regenTimeForCalc = (int)(MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f) * 0.75f); - - int finalDamageBoost = (int)(regenDamageRatio * regenTimeForCalc); - // Damage boost has a cap of 35 to prevent it from getting too crazy. - int damageCap = 35; - if (finalDamageBoost > damageCap) - finalDamageBoost = damageCap; - - if (finalDamageBoost == damageCap) // Special hit visual if the bonus damage is at the cap. + if (lifeRegenTimeContribution == 0.1f) // Special hit visual if the bonus damage is at the cap. { for (int k = 0; k < 3; k++) { BloodParticle blood = new BloodParticle(Projectile.Center, new Vector2(6.5f, 6.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.2f), Main.rand.Next(8, 10 + 1), Main.rand.NextFloat(0.7f, 0.9f), Color.Red); GeneralParticleHandler.SpawnParticle(blood); + + int dustType = ModContent.DustType(); + float velMulti = Main.rand.NextFloat(0.1f, 0.75f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, (-Projectile.velocity * 4).RotatedByRandom(0.4) * velMulti); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.55f, 0.65f); + dust.color = Color.Firebrick; + dust.noLightEmittence = true; + dust.noLight = true; + dust.fadeIn = 15; } } return finalDamageBoost; diff --git a/Projectiles/Ranged/BloodflareSoul.cs b/Projectiles/Ranged/BloodflareSoul.cs index e124ee2a71..437478b6ef 100644 --- a/Projectiles/Ranged/BloodflareSoul.cs +++ b/Projectiles/Ranged/BloodflareSoul.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Ranged/BoltArrow.cs b/Projectiles/Ranged/BoltArrow.cs index 69ea77610f..10475f8682 100644 --- a/Projectiles/Ranged/BoltArrow.cs +++ b/Projectiles/Ranged/BoltArrow.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -19,7 +18,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.arrow = true; Projectile.penetrate = 1; Projectile.timeLeft = 180; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Electrified, 60); diff --git a/Projectiles/Ranged/BouncingShotgunPellet.cs b/Projectiles/Ranged/BouncingShotgunPellet.cs index eb59268856..b756c2149f 100644 --- a/Projectiles/Ranged/BouncingShotgunPellet.cs +++ b/Projectiles/Ranged/BouncingShotgunPellet.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/Ranged/RealmRavagerBullet"; - private int bounce = 2; + private int bounce = 3; public override void SetDefaults() { Projectile.width = 4; @@ -21,7 +21,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.BulletHighVelocity; Projectile.timeLeft = 180; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool OnTileCollide(Vector2 oldVelocity) @@ -29,14 +28,42 @@ namespace CalamityMod.Projectiles.Ranged bounce--; if (bounce <= 0) Projectile.Kill(); - else + + Player owner = Main.player[Projectile.owner]; + + if (bounce == 1) + { + float npcDistCheck = 640f; // 40 tiles + int index = -1; + foreach (NPC n in Main.ActiveNPCs) + { + if (!n.CanBeChasedBy(Projectile)) + continue; + + float currentNPCDist = Vector2.Distance(n.Center, owner.ClampedMouseWorld()); + if (currentNPCDist < npcDistCheck) + { + npcDistCheck = currentNPCDist; + index = n.whoAmI; + } + } + // If the index is not default, smart bounce in the direction of that enemy. + if (index != -1) + { + Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.HeldItem.shootSpeed, 3); + } + return false; + } + else // Otherwise, use standard bouncing behavior. { if (Projectile.velocity.X != oldVelocity.X) + { Projectile.velocity.X = -oldVelocity.X; + } if (Projectile.velocity.Y != oldVelocity.Y) + { Projectile.velocity.Y = -oldVelocity.Y; - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - Projectile.damage /= 2; + } } return false; } diff --git a/Projectiles/Ranged/BrimstoneBolt.cs b/Projectiles/Ranged/BrimstoneBolt.cs index 70666e710f..1ff6ff8ae1 100644 --- a/Projectiles/Ranged/BrimstoneBolt.cs +++ b/Projectiles/Ranged/BrimstoneBolt.cs @@ -24,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 3; Projectile.extraUpdates = 2; Projectile.timeLeft = 300; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } diff --git a/Projectiles/Ranged/BrimstoneFireFriendly.cs b/Projectiles/Ranged/BrimstoneFireFriendly.cs index 75f421c5e6..d10e45801b 100644 --- a/Projectiles/Ranged/BrimstoneFireFriendly.cs +++ b/Projectiles/Ranged/BrimstoneFireFriendly.cs @@ -82,7 +82,9 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 240); + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); // Gas up the enemy int smokeCount = 3 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); diff --git a/Projectiles/Ranged/BubonicRoundProj.cs b/Projectiles/Ranged/BubonicRoundProj.cs index d591810015..362ea3d1b8 100644 --- a/Projectiles/Ranged/BubonicRoundProj.cs +++ b/Projectiles/Ranged/BubonicRoundProj.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 600; Projectile.extraUpdates = 3; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -39,7 +38,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 303, -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.01f, 0.15f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.SteampunkSteam, -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.01f, 0.15f)); dust.scale = Main.rand.NextFloat(0.7f, 0.85f); dust.noGravity = true; if (Main.rand.NextBool(3)) @@ -85,7 +84,7 @@ namespace CalamityMod.Projectiles.Ranged } for (int b = 0; b < 6; b++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 107, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Terra, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 1.1f); dust.alpha = 200; diff --git a/Projectiles/Ranged/BuzzkillHoldout.cs b/Projectiles/Ranged/BuzzkillHoldout.cs index 04c8fdb96e..63e38eac06 100644 --- a/Projectiles/Ranged/BuzzkillHoldout.cs +++ b/Projectiles/Ranged/BuzzkillHoldout.cs @@ -6,11 +6,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using ReLogic.Utilities; -using System; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -55,7 +53,7 @@ namespace CalamityMod.Projectiles.Ranged public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type) + if (HeldItem.type != Owner.HeldItem.type) { Projectile.Kill(); Projectile.netUpdate = true; @@ -78,17 +76,20 @@ namespace CalamityMod.Projectiles.Ranged Idle?.Stop(); Projectile.ai[1] = 1f; - Projectile.timeLeft = Owner.ActiveItem().useAnimation; + Projectile.timeLeft = Owner.HeldItem.useAnimation; SoundStyle ShootSound = new("CalamityMod/Sounds/Item/SawShot", 2) { PitchVariance = 0.1f, Volume = 0.4f + SawPower * 0.5f }; SoundEngine.PlaySound(ShootSound, GunTipPosition); - float sawDamageMult = MathHelper.Lerp(1f, 5f, SawPower) / 1.5f; // The damage must be divided by 1.5 to offset the holdout having 1.5x base damage. - int sawPierce = (int)MathHelper.Lerp(2f, 6f, SawPower); int sawLevel = (SawPower >= 1f).ToInt() + (SawPower >= 0.25f).ToInt(); + if (Main.myPlayer == Projectile.owner) + { + float sawDamageMult = MathHelper.Lerp(1f, 5f, SawPower) / 1.5f; // The damage must be divided by 1.5 to offset the holdout having 1.5x base damage. + int sawPierce = (int)MathHelper.Lerp(2f, 6f, SawPower); - Projectile buzzsaw = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * Owner.ActiveItem().shootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * sawDamageMult), (int)(Projectile.knockBack * (sawDamageMult / 2)), Main.myPlayer, sawLevel); - buzzsaw.penetrate = sawPierce; - buzzsaw.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); + Projectile buzzsaw = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * Owner.HeldItem.shootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * sawDamageMult), (int)(Projectile.knockBack * (sawDamageMult / 2)), Main.myPlayer, sawLevel); + buzzsaw.penetrate = sawPierce; + buzzsaw.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); + } NoSawOnHoldout = true; OffsetLengthFromArm -= 4f + 12f * SawPower; diff --git a/Projectiles/Ranged/BuzzkillSaw.cs b/Projectiles/Ranged/BuzzkillSaw.cs index a9d383fd87..73db387c35 100644 --- a/Projectiles/Ranged/BuzzkillSaw.cs +++ b/Projectiles/Ranged/BuzzkillSaw.cs @@ -39,7 +39,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; // Saw pierce is set when the saw is spawned, due to it being dynamic based on charge. Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -126,7 +125,7 @@ namespace CalamityMod.Projectiles.Ranged dustVel.SafeNormalize(Vector2.Zero); dustVel *= Main.rand.NextFloat(5f, 9f); - Dust collisionDust = Dust.NewDustPerfect(Projectile.Center, 84, dustVel); + Dust collisionDust = Dust.NewDustPerfect(Projectile.Center, DustID.Platinum, dustVel); collisionDust.noGravity = true; } diff --git a/Projectiles/Ranged/CardClub.cs b/Projectiles/Ranged/CardClub.cs index 34900bde02..f3ea0ffbef 100644 --- a/Projectiles/Ranged/CardClub.cs +++ b/Projectiles/Ranged/CardClub.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -24,7 +23,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; + Projectile.extraUpdates = 3; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.Bullet; } diff --git a/Projectiles/Ranged/CardClubSplit.cs b/Projectiles/Ranged/CardClubSplit.cs index 3a5b856b38..f53382575c 100644 --- a/Projectiles/Ranged/CardClubSplit.cs +++ b/Projectiles/Ranged/CardClubSplit.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Ranged/CardDiamond.cs b/Projectiles/Ranged/CardDiamond.cs index e6f934e331..99391ca33e 100644 --- a/Projectiles/Ranged/CardDiamond.cs +++ b/Projectiles/Ranged/CardDiamond.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -24,7 +23,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; + Projectile.extraUpdates = 3; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.Bullet; } diff --git a/Projectiles/Ranged/CardHeart.cs b/Projectiles/Ranged/CardHeart.cs index 2d02ef5959..75fd178ad3 100644 --- a/Projectiles/Ranged/CardHeart.cs +++ b/Projectiles/Ranged/CardHeart.cs @@ -1,6 +1,4 @@ using System; -using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -26,7 +24,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; + Projectile.extraUpdates = 3; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.Bullet; } @@ -59,17 +57,7 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - int heal = (int)Math.Round(hit.Damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, (int)Math.Round(hit.Damage * 0.01), 0.4f); public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Ranged/CardSpade.cs b/Projectiles/Ranged/CardSpade.cs index b0addec51c..af0d2dd9c6 100644 --- a/Projectiles/Ranged/CardSpade.cs +++ b/Projectiles/Ranged/CardSpade.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -24,7 +23,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; + Projectile.extraUpdates = 3; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.Bullet; Projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index 6f0cbfa965..5913c8504c 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -30,7 +29,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.extraUpdates = 6; Projectile.timeLeft = 360; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -57,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged if (Svant) Projectile.ArmorPenetration = 200; if (Infinity) - Projectile.ArmorPenetration = 25; + Projectile.ArmorPenetration = 20; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; if (Projectile.timeLeft == 2) @@ -73,10 +71,9 @@ namespace CalamityMod.Projectiles.Ranged if (!outOfTime) { SoundEngine.PlaySound(SoundID.Item62, Projectile.Center); - int projectiles = 2; if (Projectile.owner == Main.myPlayer) { - for (int k = 0; k < projectiles; k++) + for (int k = 0; k < 2; k++) Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -baseVel.RotatedByRandom(0.9f) * Main.rand.NextFloat(0.6f, 0.7f), ModContent.ProjectileType(), (int)(Projectile.damage * (Projectile.ai[2] > 0 ? 0.3f : 0.5f)), Projectile.knockBack * 0.8f, Main.myPlayer, 0, 0, Projectile.ai[2]); } for (int k = 0; k < 3; k++) diff --git a/Projectiles/Ranged/ChargedBlastSplit.cs b/Projectiles/Ranged/ChargedBlastSplit.cs index 9251ff639d..6aafc4fdff 100644 --- a/Projectiles/Ranged/ChargedBlastSplit.cs +++ b/Projectiles/Ranged/ChargedBlastSplit.cs @@ -3,10 +3,8 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Utilities.Terraria.Utilities; namespace CalamityMod.Projectiles.Ranged { @@ -57,12 +55,12 @@ namespace CalamityMod.Projectiles.Ranged if (Infinity) { Projectile.timeLeft = 340; - Projectile.ArmorPenetration = 25; + Projectile.ArmorPenetration = 20; } if (Svant) { Projectile.timeLeft = 640; - Projectile.ArmorPenetration = 100; + Projectile.ArmorPenetration = 200; } direction = Main.rand.NextBool(); homeSpeed = Main.rand.NextFloat(5, 8); diff --git a/Projectiles/Ranged/ChickenCannonHeld.cs b/Projectiles/Ranged/ChickenCannonHeld.cs index acaafa0d12..a34cdee075 100644 --- a/Projectiles/Ranged/ChickenCannonHeld.cs +++ b/Projectiles/Ranged/ChickenCannonHeld.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged FramesTillNextShot = FireRate; shouldShoot = true; } - bool canShoot = !player.CantUseHoldout() && (player.HasAmmo(player.ActiveItem()) || FreeShotLoaded > 0); + bool canShoot = !player.CantUseHoldout() && (player.HasAmmo(player.HeldItem) || FreeShotLoaded > 0); if (Projectile.soundDelay <= 0 && canShoot) { Projectile.soundDelay = (int)FireRate; @@ -66,8 +66,8 @@ namespace CalamityMod.Projectiles.Ranged { int projType = ModContent.ProjectileType(); // PickAmmo screws up with Rockets as per usual so this variable is reset right afterward float speedMult2 = 14.5f; - int dmg = player.GetWeaponDamage(player.ActiveItem()); - float kBack = player.ActiveItem().knockBack; + int dmg = player.GetWeaponDamage(player.HeldItem); + float kBack = player.HeldItem.knockBack; if (canShoot) { Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged direction.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - source.Y; } Vector2 speedMult = Vector2.Normalize(direction); - float shootSpeed = player.ActiveItem().shootSpeed * Projectile.scale; + float shootSpeed = player.HeldItem.shootSpeed * Projectile.scale; if (float.IsNaN(speedMult.X) || float.IsNaN(speedMult.Y)) { speedMult = -Vector2.UnitY; @@ -94,10 +94,10 @@ namespace CalamityMod.Projectiles.Ranged if (FreeShotLoaded > 0) FreeShotLoaded--; else - player.PickAmmo(player.ActiveItem(), out projType, out speedMult2, out dmg, out kBack, out _); + player.PickAmmo(player.HeldItem, out projType, out speedMult2, out dmg, out kBack, out _); projType = ModContent.ProjectileType(); - kBack = player.GetWeaponKnockback(player.ActiveItem(), kBack); + kBack = player.GetWeaponKnockback(player.HeldItem, kBack); Vector2 velocity = Vector2.Normalize(Projectile.velocity) * speedMult2; if (float.IsNaN(velocity.X) || float.IsNaN(velocity.Y)) diff --git a/Projectiles/Ranged/ChromaticEruptionHoldout.cs b/Projectiles/Ranged/ChromaticEruptionHoldout.cs index 13c0e5205e..a406ae5b0e 100644 --- a/Projectiles/Ranged/ChromaticEruptionHoldout.cs +++ b/Projectiles/Ranged/ChromaticEruptionHoldout.cs @@ -2,9 +2,11 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -13,6 +15,7 @@ namespace CalamityMod.Projectiles.Ranged public class ChromaticEruptionHoldout : BaseGunHoldoutProjectile { public override int AssociatedItemID => ModContent.ItemType(); + public override string Texture => "CalamityMod/Projectiles/Ranged/ChromaticEruptionHoldout"; public override float MaxOffsetLengthFromArm => 40f; public override float OffsetXUpwards => -10f; public override float BaseOffsetY => -12f; @@ -47,14 +50,16 @@ namespace CalamityMod.Projectiles.Ranged if (ShotCooldown == 0) { SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); - Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() < 0.70f); - for (int i = 0; i < 2; i++) + Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); + if (Main.myPlayer == Projectile.owner) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + for (int i = 0; i < 2; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); } + ShotsFired++; ShotCooldown = HeldItem.useTime; - if (FireBlobs == 0) + if (FireBlobs == 0 && Main.myPlayer == Projectile.owner) { Vector2 newVel = (Projectile.velocity * 9); Vector2 newPos = GunTipPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 36f; @@ -94,5 +99,15 @@ namespace CalamityMod.Projectiles.Ranged public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(FireBlobs); public override void ReceiveExtraAIHoldout(BinaryReader reader) => FireBlobs = reader.ReadInt32(); + public override void PostDraw(Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 origin = texture.Size() * 0.5f; + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipVertically; + + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Ranged/ChromaticEruptionHoldoutGlow").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/ChromaticEruptionHoldout.png b/Projectiles/Ranged/ChromaticEruptionHoldout.png new file mode 100644 index 0000000000..e60591d984 Binary files /dev/null and b/Projectiles/Ranged/ChromaticEruptionHoldout.png differ diff --git a/Projectiles/Ranged/ChromaticEruptionHoldoutGlow.png b/Projectiles/Ranged/ChromaticEruptionHoldoutGlow.png new file mode 100644 index 0000000000..5d2180deb4 Binary files /dev/null and b/Projectiles/Ranged/ChromaticEruptionHoldoutGlow.png differ diff --git a/Projectiles/Ranged/ChromaticFire.cs b/Projectiles/Ranged/ChromaticFire.cs index a97a221ad5..bd30a4ba89 100644 --- a/Projectiles/Ranged/ChromaticFire.cs +++ b/Projectiles/Ranged/ChromaticFire.cs @@ -3,7 +3,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -19,7 +18,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - Projectile.width = Projectile.height = 12; + Projectile.width = Projectile.height = 52; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; @@ -97,6 +96,9 @@ namespace CalamityMod.Projectiles.Ranged // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 540); + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 1200); } } diff --git a/Projectiles/Ranged/ChromaticFlare.cs b/Projectiles/Ranged/ChromaticFlare.cs index 4c9cb7dd55..99a1d3fd7b 100644 --- a/Projectiles/Ranged/ChromaticFlare.cs +++ b/Projectiles/Ranged/ChromaticFlare.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -83,7 +82,9 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 540); + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); // Lose a bit of damage from repeated hits if ((StickToEnemies || StickToTiles) && Projectile.damage > 1) diff --git a/Projectiles/Ranged/CinderArrowProj.cs b/Projectiles/Ranged/CinderArrowProj.cs index aa7d906b6b..2dee125be4 100644 --- a/Projectiles/Ranged/CinderArrowProj.cs +++ b/Projectiles/Ranged/CinderArrowProj.cs @@ -34,7 +34,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 2; Projectile.timeLeft = 600; Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } diff --git a/Projectiles/Ranged/ClamorRifleProj.cs b/Projectiles/Ranged/ClamorRifleProj.cs index ce6bb0907b..c0b78ea5f1 100644 --- a/Projectiles/Ranged/ClamorRifleProj.cs +++ b/Projectiles/Ranged/ClamorRifleProj.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -20,7 +19,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ignoreWater = true; Projectile.penetrate = 1; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/ClaretCannonProj.cs b/Projectiles/Ranged/ClaretCannonProj.cs deleted file mode 100644 index d37c4265a0..0000000000 --- a/Projectiles/Ranged/ClaretCannonProj.cs +++ /dev/null @@ -1,77 +0,0 @@ -using CalamityMod.Balancing; -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class ClaretCannonProj : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 10; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = 1; - Projectile.timeLeft = 600; - Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; - Projectile.aiStyle = ProjAIStyleID.Arrow; - AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0f / 255f); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); - SoundEngine.PlaySound(SoundID.Dig, Projectile.position); - return true; - } - - public override void OnKill(int timeLeft) - { - for (int k = 0; k < 2; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X * 0.15f, Projectile.oldVelocity.Y * 0.15f); - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 120); - - int heal = (int)Math.Round(hit.Damage * 0.02); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Ranged/ClockworkBowHoldout.cs b/Projectiles/Ranged/ClockworkBowHoldout.cs index dd09e1efaa..576a35d3b2 100644 --- a/Projectiles/Ranged/ClockworkBowHoldout.cs +++ b/Projectiles/Ranged/ClockworkBowHoldout.cs @@ -62,10 +62,10 @@ namespace CalamityMod.Projectiles.Ranged // Frame 1 effects: Initialize the shoot speed if (FramesToLoadBolt == 0f) { - FramesToLoadBolt = Owner.ActiveItem().useAnimation; + FramesToLoadBolt = Owner.HeldItem.useAnimation; } - if (Owner.HasAmmo(Owner.ActiveItem())) + if (Owner.HasAmmo(Owner.HeldItem)) { ++CurrentChargingFrames; @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Ranged if (CurrentChargingFrames >= FramesToLoadBolt && LoadedBolts < ClockworkBow.MaxBolts) { // Save the stats here for later - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; Owner.PickAmmo(heldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); Projectile.damage = damage; Projectile.knockBack = knockback; @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item38);//play the sound } - FramesToLoadBolt = Owner.ActiveItem().useAnimation; //reset the reload time + FramesToLoadBolt = Owner.HeldItem.useAnimation; //reset the reload time LoadedBolts = 0; //Unload the bow } @@ -216,7 +216,7 @@ namespace CalamityMod.Projectiles.Ranged Shift = 1 - (CurrentChargingFrames / FramesToLoadBolt); // You need to have arrows left for the tint to not remain in stasis - if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.ActiveItem())) //If the arrow we are looking at is the one that just got loaded, OR all arrows got loaded, we apply some flashiness + if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.HeldItem)) //If the arrow we are looking at is the one that just got loaded, OR all arrows got loaded, we apply some flashiness { Main.spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f - MathHelper.Clamp((CurrentChargingFrames * 2 / FramesToLoadBolt), 0f, 1f)); @@ -233,7 +233,7 @@ namespace CalamityMod.Projectiles.Ranged Main.EntitySpriteDraw(BoltTexture, drawPosition, null, Transparency, Projectile.rotation + BoltAngle + MathHelper.PiOver2 + FlipFactor, BoltTexture.Size(), 1f, 0, 0); - if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.ActiveItem())) //Don't forget to exit the shader region + if ((i == LoadedBolts - 1 || LoadedBolts == ClockworkBow.MaxBolts) && Owner.HasAmmo(Owner.HeldItem)) //Don't forget to exit the shader region Main.spriteBatch.ExitShaderRegion(); } return true; diff --git a/Projectiles/Ranged/CondemnationArrow.cs b/Projectiles/Ranged/CondemnationArrow.cs index a3f208088d..519e27b5e3 100644 --- a/Projectiles/Ranged/CondemnationArrow.cs +++ b/Projectiles/Ranged/CondemnationArrow.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.arrow = true; Projectile.extraUpdates = 2; Projectile.timeLeft = 300; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -76,7 +75,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 30; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center, 130); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.Firework_Red); fire.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.8f) * new Vector2(4f, 1.25f) * Main.rand.NextFloat(0.9f, 1f); fire.velocity = fire.velocity.RotatedBy(Projectile.rotation - MathHelper.PiOver2); fire.velocity += Projectile.velocity * 0.7f; diff --git a/Projectiles/Ranged/CondemnationArrowHoming.cs b/Projectiles/Ranged/CondemnationArrowHoming.cs index 23d7c8f793..d21d53f25c 100644 --- a/Projectiles/Ranged/CondemnationArrowHoming.cs +++ b/Projectiles/Ranged/CondemnationArrowHoming.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.height = 90; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.tileCollide = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.arrow = true; Projectile.extraUpdates = 2; @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 10; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center, 267); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); fire.velocity = Main.rand.NextVector2Circular(2f, 2f); fire.color = Color.Lerp(Color.Red, Color.Purple, Main.rand.NextFloat()); fire.scale = Main.rand.NextFloat(1f, 1.1f); diff --git a/Projectiles/Ranged/CondemnationHoldout.cs b/Projectiles/Ranged/CondemnationHoldout.cs index a2756431ff..1ac8222238 100644 --- a/Projectiles/Ranged/CondemnationHoldout.cs +++ b/Projectiles/Ranged/CondemnationHoldout.cs @@ -2,8 +2,10 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -23,6 +25,7 @@ namespace CalamityMod.Projectiles.Ranged private float storedVelocity = 1f; public const float velocityMultiplier = 1.2f; public bool homing = false; + public bool playShootSound = true; public override void KillHoldoutLogic() { @@ -35,6 +38,12 @@ namespace CalamityMod.Projectiles.Ranged Projectile.Kill(); return; } + if (homing && playShootSound) + { + SoundEngine.PlaySound(SoundID.DD2_BallistaTowerShot with { Pitch = 0.2f, MaxInstances = 2 }, Projectile.Center); + SoundEngine.PlaySound(SoundID.DD2_BallistaTowerShot with { Pitch = -0.4f, MaxInstances = 2 }, Projectile.Center); + playShootSound = false; + } // Fire one charged arrow every frame until you're out of arrows. ShootProjectiles(homing); @@ -59,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged // If no arrows are loaded, spawn a bit of dust to indicate it's not ready yet. // Spawn the same dust if the max number of arrows have been loaded or the player ran out of ammos to load. - if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.ActiveItem())) + if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.HeldItem)) SpawnCannotLoadArrowsDust(GunTipPosition); if (Owner.HasAmmo(HeldItem)) @@ -84,11 +93,13 @@ namespace CalamityMod.Projectiles.Ranged FramesToLoadNextArrow = MathHelper.Clamp(FramesToLoadNextArrow--, 1f, HeldItem.useAnimation); // Play a sound for additional notification that an arrow has been loaded. - var loadSound = SoundEngine.PlaySound(SoundID.Item108 with { Volume = SoundID.Item108.Volume * 0.3f }); + var loadSound = SoundEngine.PlaySound(SoundID.Item108 with { Volume = SoundID.Item108.Volume * 0.4f, Pitch = -0.3f + ArrowsLoaded * 0.1f }); if (ArrowsLoaded >= Condemnation.MaxLoadedArrows) { - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/AbilitySounds/BrimflameRecharge")); + SoundStyle fire = new("CalamityMod/Sounds/Custom/AbilitySounds/BrimflameRecharge"); + for (int i = 0; i < 3; i++) + SoundEngine.PlaySound(fire with { Volume = 0.8f, Pitch = i * 0.25f, MaxInstances = 3 }); homing = true; } } @@ -112,7 +123,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 end = nextAngle.ToRotationVector2(); for (int j = 0; j < 40; j++) { - Dust starDust = Dust.NewDustPerfect(GunTipPosition, 267); + Dust starDust = Dust.NewDustPerfect(GunTipPosition, DustID.RainbowMk2); starDust.scale = 2.5f; starDust.velocity = Vector2.Lerp(start, end, j / 40f) * 16f; starDust.color = Color.Crimson; @@ -124,7 +135,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 36; i++) { - Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition, 267); + Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition, DustID.RainbowMk2); chargeMagic.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 5f + Owner.velocity; chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); chargeMagic.color = Color.Violet; @@ -139,7 +150,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 2; i++) { - Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition + Main.rand.NextVector2Circular(20f, 20f), 267); + Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition + Main.rand.NextVector2Circular(20f, 20f), DustID.RainbowMk2); chargeMagic.velocity = (GunTipPosition - chargeMagic.position) * 0.1f + Owner.velocity; chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); chargeMagic.color = Projectile.GetAlpha(Color.White); @@ -154,9 +165,32 @@ namespace CalamityMod.Projectiles.Ranged Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * storedVelocity; int ArrowType = homing ? ModContent.ProjectileType() : ModContent.ProjectileType(); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ArrowType, Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ArrowType, (int)(Projectile.damage * 1.35f), Projectile.knockBack, Projectile.owner); } + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition + new Vector2(0, -3); + float randSize = Main.rand.NextFloat(0.9f, 1f); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.direction == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (homing) + { + for (int i = 0; i < 22; i++) + { + Color auraColor = Color.Lerp(Color.Red, Color.White, i * 0.01f) with { A = 0 } * 0.6f; + Vector2 drawOffset = ((MathHelper.TwoPi * i / 22f).ToRotationVector2() * 5) + Main.rand.NextVector2Circular(7, 7); + Main.EntitySpriteDraw(texture, drawPosition + drawOffset, null, auraColor, drawRotation, rotationPoint, Projectile.scale * Main.rand.NextFloat(0.7f, 1.1f), flipSprite); + } + } + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + return false; + } public override void SendExtraAIHoldout(BinaryWriter writer) { writer.Write(FramesToLoadNextArrow); diff --git a/Projectiles/Ranged/ContagionArrow.cs b/Projectiles/Ranged/ContagionArrow.cs index 067c7820e3..d18396677f 100644 --- a/Projectiles/Ranged/ContagionArrow.cs +++ b/Projectiles/Ranged/ContagionArrow.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -28,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.extraUpdates = 1; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/ContagionBall.cs b/Projectiles/Ranged/ContagionBall.cs index 7b8798c7be..34fa5fc860 100644 --- a/Projectiles/Ranged/ContagionBall.cs +++ b/Projectiles/Ranged/ContagionBall.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/ContagionBow.cs b/Projectiles/Ranged/ContagionBow.cs index ec199c5071..e6261e8090 100644 --- a/Projectiles/Ranged/ContagionBow.cs +++ b/Projectiles/Ranged/ContagionBow.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged { if (!player.CantUseHoldout()) { - float speed = player.ActiveItem().shootSpeed * Projectile.scale; + float speed = player.HeldItem.shootSpeed * Projectile.scale; Vector2 spawnPos = vector; Vector2 direction = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - spawnPos; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/CorrodedShell.cs b/Projectiles/Ranged/CorrodedShell.cs index d70b68fad7..f2097e64ee 100644 --- a/Projectiles/Ranged/CorrodedShell.cs +++ b/Projectiles/Ranged/CorrodedShell.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; @@ -25,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 12; Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/CosmicFire.cs b/Projectiles/Ranged/CosmicFire.cs index c4b5d2e4e5..6a11f73d6f 100644 --- a/Projectiles/Ranged/CosmicFire.cs +++ b/Projectiles/Ranged/CosmicFire.cs @@ -1,9 +1,7 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Ranged/DWArrow.cs b/Projectiles/Ranged/DWArrow.cs deleted file mode 100644 index 74f4fb6f83..0000000000 --- a/Projectiles/Ranged/DWArrow.cs +++ /dev/null @@ -1,75 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class DWArrow : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 10; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.extraUpdates = 5; - Projectile.timeLeft = 600; - Projectile.arrow = true; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - //Rotation - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = (Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi)) + MathHelper.ToRadians(90) * Projectile.direction; - - if (Projectile.ai[1] == 0f) - { - Projectile.ai[1] = 1f; - SoundEngine.PlaySound(SoundID.Item12, Projectile.position); - } - - Lighting.AddLight(Projectile.Center, 0.4f, 0.2f, 0.4f); - for (int i = 0; i < 2; i++) - { - Dust dusty = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool(3) ? 56 : 242, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 1f)]; - dusty.velocity = Vector2.Zero; - dusty.position -= Projectile.velocity / 5f * (float)i; - dusty.noGravity = true; - dusty.scale = 0.8f; - dusty.noLight = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); - - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture; - if (Projectile.localAI[1] == 0f) - Projectile.localAI[1] = Main.rand.Next(1, 3); - switch (Projectile.localAI[1]) - { - - case 2f: - texture = ModContent.Request("CalamityMod/Projectiles/Ranged/DWArrow2").Value; - break; - default: - texture = ModContent.Request("CalamityMod/Projectiles/Ranged/DWArrow").Value; - break; - } - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), Projectile.scale, SpriteEffects.None, 0); - return false; - } - } -} diff --git a/Projectiles/Ranged/DWArrow.png b/Projectiles/Ranged/DWArrow.png deleted file mode 100644 index 187c297c92..0000000000 Binary files a/Projectiles/Ranged/DWArrow.png and /dev/null differ diff --git a/Projectiles/Ranged/DWArrow2.png b/Projectiles/Ranged/DWArrow2.png deleted file mode 100644 index 1e189d0434..0000000000 Binary files a/Projectiles/Ranged/DWArrow2.png and /dev/null differ diff --git a/Projectiles/Ranged/DaemonsFlameBow.cs b/Projectiles/Ranged/DaemonsFlameBow.cs index 6653ea2313..51a138913b 100644 --- a/Projectiles/Ranged/DaemonsFlameBow.cs +++ b/Projectiles/Ranged/DaemonsFlameBow.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged fullSpeed = true; int arg_1EF4_0 = (int)Projectile.ai[0] / (delayCompare - fireSpeedCompare * fireSpeed); } - bool canUseItem = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem()); + bool canUseItem = !player.CantUseHoldout() && player.HasAmmo(player.HeldItem); if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -95,13 +95,13 @@ namespace CalamityMod.Projectiles.Ranged { int ammoType = ProjectileID.WoodenArrowFriendly; float scaleFactor11 = 14f; - int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); - float weaponKnockback2 = player.ActiveItem().knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.HeldItem); + float weaponKnockback2 = player.HeldItem.knockBack; if (canUseItem) { - player.PickAmmo(player.ActiveItem(), out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); - weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); - float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; + player.PickAmmo(player.HeldItem, out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); + weaponKnockback2 = player.GetWeaponKnockback(player.HeldItem, weaponKnockback2); + float scaleFactor12 = player.HeldItem.shootSpeed * Projectile.scale; Vector2 shootDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotate; if (player.gravDir == -1f) { diff --git a/Projectiles/Ranged/DeadSunExplosion.cs b/Projectiles/Ranged/DeadSunExplosion.cs index bd6d20582e..040893cf7e 100644 --- a/Projectiles/Ranged/DeadSunExplosion.cs +++ b/Projectiles/Ranged/DeadSunExplosion.cs @@ -1,11 +1,7 @@ -using System; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged diff --git a/Projectiles/Ranged/DragonsBreathBurst.cs b/Projectiles/Ranged/DragonsBreathBurst.cs index 5370887732..3f3359b603 100644 --- a/Projectiles/Ranged/DragonsBreathBurst.cs +++ b/Projectiles/Ranged/DragonsBreathBurst.cs @@ -1,9 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { diff --git a/Projectiles/Ranged/DragonsBreathFlames.cs b/Projectiles/Ranged/DragonsBreathFlames.cs index d6a65bac8e..643df17066 100644 --- a/Projectiles/Ranged/DragonsBreathFlames.cs +++ b/Projectiles/Ranged/DragonsBreathFlames.cs @@ -1,11 +1,11 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -185,7 +185,7 @@ namespace CalamityMod.Projectiles.Ranged } for (int i = 0; i <= 3; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 0.5f, 278, Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(2.5f, 8.5f), 0, default, Main.rand.NextFloat(0.5f, 1.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 0.5f, DustID.FireworksRGB, Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(2.5f, 8.5f), 0, default, Main.rand.NextFloat(0.5f, 1.1f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Orange : Color.OrangeRed; } @@ -220,16 +220,30 @@ namespace CalamityMod.Projectiles.Ranged } for (int i = 0; i <= 2; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 0.5f, 278, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.5f, 3.5f), 0, default, Main.rand.NextFloat(0.8f, 1.5f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 0.5f, DustID.FireworksRGB, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.5f, 3.5f), 0, default, Main.rand.NextFloat(0.8f, 1.5f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Orange : Color.OrangeRed; } postHit = true; } - target.AddBuff(ModContent.BuffType(), 240); + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + Player Owner = Main.player[Projectile.owner]; + if (Time <= 1) + { + float _ = float.NaN; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Owner.Center, Projectile.width, ref _); + } + else + return CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.ai[1] == 1 ? 4 : Projectile.width + Time * 0.1f, targetHitbox); } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.ai[1] == 1 ? 4 : Projectile.width + Time * 0.1f, targetHitbox); public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (Projectile.numHits > 0) diff --git a/Projectiles/Ranged/DragonsBreathHoldout.cs b/Projectiles/Ranged/DragonsBreathHoldout.cs index 8ebff3977e..8b11715fbe 100644 --- a/Projectiles/Ranged/DragonsBreathHoldout.cs +++ b/Projectiles/Ranged/DragonsBreathHoldout.cs @@ -1,14 +1,10 @@ -using System.Diagnostics.Metrics; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -50,7 +46,7 @@ namespace CalamityMod.Projectiles.Ranged WeldSoundSlot = SoundEngine.PlaySound(DragonsBreath.WeldingShoot, Projectile.Center); } - if (weldingTimer % 2 == 0) + if (weldingTimer % 2 == 0 && Main.myPlayer == Projectile.owner) Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 1, weldingTimer, (Time % 15 < 10 ? 18 : 0)); weldingTimer--; @@ -67,7 +63,8 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle bigShot = new("CalamityMod/Sounds/Item/DudFire"); SoundEngine.PlaySound(bigShot with { PitchVariance = 0.15f, Volume = 0.75f }, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6).RotatedBy(-2.3f * Projectile.direction), ModContent.ProjectileType(), Main.zenithWorld ? 250000 : 1, Projectile.knockBack, Projectile.owner, 1); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6).RotatedBy(-2.3f * Projectile.direction), ModContent.ProjectileType(), Main.zenithWorld ? 250000 : 1, Projectile.knockBack, Projectile.owner, 1); hasLaunchedMag = true; } } @@ -76,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged // If the time reaches Item.useTime, it'll shoot the projectile, fire and reset the timer. if (fireTimer >= Owner.itemTimeMax && Main.myPlayer == Projectile.owner) { - Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, !Main.rand.NextBool(5)); + Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); for (int i = 0; i < 3; i++) Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.15f * i * 0.5f) * shootSpeed * (i == 0 ? 0.5f : i == 1 ? 0.7f : 1) * Main.rand.NextFloat(0.8f, 1f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); diff --git a/Projectiles/Ranged/DragonsBreathMag.cs b/Projectiles/Ranged/DragonsBreathMag.cs index 89bafd2447..c61a87375b 100644 --- a/Projectiles/Ranged/DragonsBreathMag.cs +++ b/Projectiles/Ranged/DragonsBreathMag.cs @@ -1,13 +1,9 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Projectiles.Ranged { diff --git a/Projectiles/Ranged/DrataliornusBow.cs b/Projectiles/Ranged/DrataliornusBow.cs index 04839e8617..57ba9125d9 100644 --- a/Projectiles/Ranged/DrataliornusBow.cs +++ b/Projectiles/Ranged/DrataliornusBow.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged timeToFire = true; } - bool canFire = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem()); + bool canFire = !player.CantUseHoldout() && player.HasAmmo(player.HeldItem); if (Projectile.soundDelay <= 0 && canFire) { @@ -92,13 +92,13 @@ namespace CalamityMod.Projectiles.Ranged { int type = ProjectileID.WoodenArrowFriendly; //Gets changed below anyways float scaleFactor = 18f; - int damage = player.GetWeaponDamage(player.ActiveItem()); - float knockBack = player.ActiveItem().knockBack; + int damage = player.GetWeaponDamage(player.HeldItem); + float knockBack = player.HeldItem.knockBack; - player.PickAmmo(player.ActiveItem(), out type, out scaleFactor, out damage, out knockBack, out _); + player.PickAmmo(player.HeldItem, out type, out scaleFactor, out damage, out knockBack, out _); type = ModContent.ProjectileType(); - knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); + knockBack = player.GetWeaponKnockback(player.HeldItem, knockBack); Vector2 playerPosition = player.RotatedRelativePoint(player.MountedCenter, true); Projectile.velocity = Main.screenPosition - playerPosition; diff --git a/Projectiles/Ranged/DrataliornusExoArrow.cs b/Projectiles/Ranged/DrataliornusExoArrow.cs index 97ec9ede47..f5294bdcfc 100644 --- a/Projectiles/Ranged/DrataliornusExoArrow.cs +++ b/Projectiles/Ranged/DrataliornusExoArrow.cs @@ -1,7 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { @@ -23,6 +22,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.arrow = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 0; } public override void AI() @@ -62,8 +63,6 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.immune[Projectile.owner] = 0; - target.AddBuff(ModContent.BuffType(), 180); } diff --git a/Projectiles/Ranged/DrizzlefishFire.cs b/Projectiles/Ranged/DrizzlefishFire.cs index a1384538d8..9d8f700405 100644 --- a/Projectiles/Ranged/DrizzlefishFire.cs +++ b/Projectiles/Ranged/DrizzlefishFire.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Fishing.BrimstoneCragCatches; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -164,6 +163,10 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + //This is one of the exceptions, as Brimstone Flames is a very strong DoT debuff for this tier. if (Projectile.ai[1] == 1f) { target.AddBuff(BuffID.OnFire3, 120); diff --git a/Projectiles/Ranged/DrizzlefishFireSplit.cs b/Projectiles/Ranged/DrizzlefishFireSplit.cs index 29155befd3..390906dd83 100644 --- a/Projectiles/Ranged/DrizzlefishFireSplit.cs +++ b/Projectiles/Ranged/DrizzlefishFireSplit.cs @@ -1,12 +1,9 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Projectiles.Ranged { @@ -95,6 +92,10 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + //This is one of the exceptions, as Brimstone Flames is a very strong debuff for it's tier if (Projectile.ai[1] == 1f) { target.AddBuff(BuffID.OnFire3, 60); diff --git a/Projectiles/Ranged/DrizzlefishFireball.cs b/Projectiles/Ranged/DrizzlefishFireball.cs index d6de88439b..7d2f18766e 100644 --- a/Projectiles/Ranged/DrizzlefishFireball.cs +++ b/Projectiles/Ranged/DrizzlefishFireball.cs @@ -136,12 +136,17 @@ namespace CalamityMod.Projectiles.Ranged } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + //This is one of the exceptions, as Brimstone Flames is a very strong debuff for it's tier if (Projectile.ai[1] == 1f) { target.AddBuff(BuffID.OnFire3, 40); } else { + target.AddBuff(ModContent.BuffType(), 20); } } diff --git a/Projectiles/Ranged/DryadsTearMain.cs b/Projectiles/Ranged/DryadsTearMain.cs index 81766cb87a..48d0f4c787 100644 --- a/Projectiles/Ranged/DryadsTearMain.cs +++ b/Projectiles/Ranged/DryadsTearMain.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.extraUpdates = 5; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/DryadsTearSplit.cs b/Projectiles/Ranged/DryadsTearSplit.cs index dc63930a32..26ca02be87 100644 --- a/Projectiles/Ranged/DryadsTearSplit.cs +++ b/Projectiles/Ranged/DryadsTearSplit.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -45,7 +44,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[2]++; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Dust dust = Dust.NewDustPerfect(Projectile.Center, 264, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.6f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 0.8f); dust.color = Main.rand.NextBool(3) ? Color.MediumAquamarine : Color.Lime; diff --git a/Projectiles/Ranged/ElysianArrowProj.cs b/Projectiles/Ranged/ElysianArrowProj.cs index 0e457db337..f76f5fdcbd 100644 --- a/Projectiles/Ranged/ElysianArrowProj.cs +++ b/Projectiles/Ranged/ElysianArrowProj.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 1200; Projectile.extraUpdates = 2; Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -73,7 +72,7 @@ namespace CalamityMod.Projectiles.Ranged } } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnSpot, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0f, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnSpot, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15f), 0f, Projectile.owner, 0f, 0f); SoundStyle onKill = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastShoot"); SoundEngine.PlaySound(onKill with { Volume = 0.4f, Pitch = 0.4f }, Projectile.position); @@ -88,7 +87,7 @@ namespace CalamityMod.Projectiles.Ranged dust.alpha = 235; if (Main.rand.NextBool()) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 303, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.SteampunkSteam, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.8f, 1.5f); dust2.alpha = 70; @@ -96,7 +95,7 @@ namespace CalamityMod.Projectiles.Ranged } for (int k = 0; k < 2; k++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, Projectile.velocity.RotatedByRandom(0.4) * Main.rand.NextFloat(0.5f, 1.5f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, Projectile.velocity.RotatedByRandom(0.4) * Main.rand.NextFloat(0.5f, 1.5f)); dust.noGravity = false; dust.scale = Main.rand.NextFloat(0.85f, 1f); dust.color = Main.rand.NextBool() ? Color.Orange : Color.Khaki; diff --git a/Projectiles/Ranged/ElysianArrowRain.cs b/Projectiles/Ranged/ElysianArrowRain.cs index 2963288945..b56748ff08 100644 --- a/Projectiles/Ranged/ElysianArrowRain.cs +++ b/Projectiles/Ranged/ElysianArrowRain.cs @@ -43,6 +43,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.ArmorPenetration = 15; } public override bool? CanDamage() => Projectile.numHits >= 1 ? false : null; @@ -78,7 +79,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 80; } - private float PrimitiveWidthFunction(float completionRatio) + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float arrowheadCutoff = 0.36f; float width = 24f; @@ -89,7 +90,7 @@ namespace CalamityMod.Projectiles.Ranged return width; } - private Color PrimitiveColorFunction(float completionRatio) + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float endFadeRatio = 0.41f; @@ -109,11 +110,11 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); Vector2 overallOffset = Projectile.Size * 0.5f; overallOffset += Projectile.velocity * 1.4f; int numPoints = 46; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => overallOffset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), numPoints); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => overallOffset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), numPoints); return false; } diff --git a/Projectiles/Ranged/EmesisGore.cs b/Projectiles/Ranged/EmesisGore.cs index f66c31aa8f..6157644e6c 100644 --- a/Projectiles/Ranged/EmesisGore.cs +++ b/Projectiles/Ranged/EmesisGore.cs @@ -1,13 +1,10 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged diff --git a/Projectiles/Ranged/EssenceFire.cs b/Projectiles/Ranged/EssenceFire.cs index 18d29ded2c..5807bc11dd 100644 --- a/Projectiles/Ranged/EssenceFire.cs +++ b/Projectiles/Ranged/EssenceFire.cs @@ -58,12 +58,12 @@ namespace CalamityMod.Projectiles.Ranged dust.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); } - if (Main.rand.NextBool(17)) + if (Main.rand.NextBool(19)) { bool LowVel = Main.rand.NextBool() ? false : true; - FlameParticle fire = new FlameParticle(Projectile.Center, 20, MathHelper.Clamp(Time * 0.05f, 0.15f, 1.75f), 0.05f, Color.BlueViolet * (LowVel ? 1.2f : 0.5f), Color.DarkBlue * (LowVel ? 1.2f : 0.5f)); - fire.Velocity = new Vector2(Projectile.velocity.X * 0.8f, -10).RotatedByRandom(0.005f) * (LowVel ? Main.rand.NextFloat(0.4f, 0.65f) : Main.rand.NextFloat(0.8f, 1f)); - GeneralParticleHandler.SpawnParticle(fire); + float size = Utils.Remap(Utils.GetLerpValue(0f, Lifetime, Time), 0.2f, 0.5f, 0.25f, 1f); + Particle trail = new CustomSpark(Projectile.Center, Projectile.velocity + Vector2.UnitY * Main.rand.NextFloat(-10, -24) * size, "CalamityMod/Particles/BloomCircle", false, 14, 0.9f * size, (Main.rand.NextBool() ? Color.DarkBlue : Color.BlueViolet) * 0.5f, new Vector2(Main.rand.NextFloat(2, 3), 1f), true, true, shrinkSpeed: 0.3f, glowOpacity: 0.5f); + GeneralParticleHandler.SpawnParticle(trail); } } else if (Time == 5f) @@ -86,7 +86,9 @@ namespace CalamityMod.Projectiles.Ranged hitbox.Inflate(size, size); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 360); + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 1200); public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (Projectile.numHits > 0) diff --git a/Projectiles/Ranged/ExoCrystalArrow.cs b/Projectiles/Ranged/ExoCrystalArrow.cs index e51f5150fe..6beda615b2 100644 --- a/Projectiles/Ranged/ExoCrystalArrow.cs +++ b/Projectiles/Ranged/ExoCrystalArrow.cs @@ -3,7 +3,6 @@ using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using CalamityMod.Sounds; -using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -40,7 +39,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 1; Projectile.timeLeft = 300; Projectile.arrow = true; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -74,9 +72,9 @@ namespace CalamityMod.Projectiles.Ranged return true; } - public float PrimitiveWidthFunction(float completionRatio) => Projectile.scale * 30f; + public float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 30f; - public Color PrimitiveColorFunction(float _) => Color.Lime * Projectile.Opacity; + public Color PrimitiveColorFunction(float _, Vector2 vertexPos) => Color.Lime * Projectile.Opacity; public override bool PreDraw(ref Color lightColor) { @@ -93,7 +91,7 @@ namespace CalamityMod.Projectiles.Ranged GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].UseColor(mainColor); GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].UseSecondaryColor(secondaryColor); GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].Apply(); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"]), 53); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => trailOffset, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"]), 53); Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; Vector2 origin = tex.Size() * 0.5f; Vector2 drawPosition = Projectile.Center - Main.screenPosition; diff --git a/Projectiles/Ranged/ExoFire.cs b/Projectiles/Ranged/ExoFire.cs index 323da18020..59fe2939aa 100644 --- a/Projectiles/Ranged/ExoFire.cs +++ b/Projectiles/Ranged/ExoFire.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -81,7 +79,7 @@ namespace CalamityMod.Projectiles.Ranged } if (Main.rand.NextBool(35) && targetDist < 1400f && Time > 5) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 263, new Vector2(0, -5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.3f, 1.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBolt, new Vector2(0, -5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.3f, 1.6f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.3f, 1f); dust.color = sparkColor; @@ -89,7 +87,10 @@ namespace CalamityMod.Projectiles.Ranged } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 300); + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); if (audioCooldown == 0) { SoundEngine.PlaySound(Photoviscerator.HitSound, target.Center); @@ -97,7 +98,7 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 300); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 1200); } } diff --git a/Projectiles/Ranged/ExoFlareCluster.cs b/Projectiles/Ranged/ExoFlareCluster.cs index f8fd95b5d8..9d49ba0ef0 100644 --- a/Projectiles/Ranged/ExoFlareCluster.cs +++ b/Projectiles/Ranged/ExoFlareCluster.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -12,6 +12,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { + [PierceResistException] // Photoviscerator right click main projectile (invisible flare cluster bomb) public class ExoFlareCluster : ModProjectile, ILocalizedModType { @@ -74,7 +75,9 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 600); + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); Projectile.tileCollide = false; float numberOflines = 5; @@ -145,7 +148,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitPlayer(Player target, Player.HurtInfo info) { - target.AddBuff(ModContent.BuffType(), 600); + target.AddBuff(ModContent.BuffType(), 1200); } } } diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index 7e169f185c..2d9bca1355 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; diff --git a/Projectiles/Ranged/ExoLightningBolt.cs b/Projectiles/Ranged/ExoLightningBolt.cs index 24b74afde4..9a9605dec0 100644 --- a/Projectiles/Ranged/ExoLightningBolt.cs +++ b/Projectiles/Ranged/ExoLightningBolt.cs @@ -135,9 +135,9 @@ namespace CalamityMod.Projectiles.Ranged } } - public float PrimitiveWidthFunction(float completionRatio) => CalamityUtils.Convert01To010(completionRatio) * Projectile.scale * Projectile.width; + public float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) => CalamityUtils.Convert01To010(completionRatio) * Projectile.scale * Projectile.width; - public Color PrimitiveColorFunction(float completionRatio) + public Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float colorInterpolant = (float)Math.Sin(Projectile.identity / 3f + completionRatio * 20f + Main.GlobalTimeWrappedHourly * 1.1f) * 0.5f + 0.5f; Color color = CalamityUtils.MulticolorLerp(colorInterpolant, Color.GreenYellow, Color.Lime, Color.Cyan); @@ -153,7 +153,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < checkPoints.Count - 1; i++) { float _ = 0f; - float width = PrimitiveWidthFunction(i / (float)checkPoints.Count); + float width = PrimitiveWidthFunction(i / (float)checkPoints.Count, Vector2.Zero); if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), checkPoints[i], checkPoints[i + 1], width * 0.8f, ref _)) return true; } @@ -165,7 +165,7 @@ namespace CalamityMod.Projectiles.Ranged GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin"); GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply(); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), 18); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Projectile.Size * 0.5f, false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), 18); return false; } diff --git a/Projectiles/Ranged/FeatherLarge.cs b/Projectiles/Ranged/FeatherLarge.cs index db3737de73..f247d38ab7 100644 --- a/Projectiles/Ranged/FeatherLarge.cs +++ b/Projectiles/Ranged/FeatherLarge.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -25,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; Projectile.timeLeft = 300; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/FetidEmesisHoldout.cs b/Projectiles/Ranged/FetidEmesisHoldout.cs index 6a4d3e1a42..2a7c4b353e 100644 --- a/Projectiles/Ranged/FetidEmesisHoldout.cs +++ b/Projectiles/Ranged/FetidEmesisHoldout.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -24,20 +25,19 @@ namespace CalamityMod.Projectiles.Ranged public ref float shootingTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil public bool isTired => cooldownTimer > 0; public float revSpeed = 1; - public bool secondShot = true; public int maxFrames = 420; public int initialFireTime = 45; public float shineScale = 0; public override void KillHoldoutLogic() { - if (!isTired && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)) + if (!isTired && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type)) Projectile.Kill(); } public override void HoldoutAI() { - if (!isTired && (Owner.CantUseHoldout() || HeldItem.type != Owner.ActiveItem().type)) + if (!isTired && (Owner.CantUseHoldout() || HeldItem.type != Owner.HeldItem.type)) cooldownTimer = (int)(Utils.Remap(revFrames, 0, 350, 40, 180, true)); if (isTired) { @@ -46,38 +46,30 @@ namespace CalamityMod.Projectiles.Ranged } revSpeed = Utils.Remap(revFrames, 0, maxFrames - 120, 1, 20, true); - if (shootingTimer >= initialFireTime && revFrames < maxFrames && secondShot) + if (shootingTimer >= initialFireTime && revFrames < maxFrames) { - Owner.PickAmmo(Owner.ActiveItem(), out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _, !Main.rand.NextBool(4)); + Owner.PickAmmo(Owner.HeldItem, out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _); SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotSmallAlt"); SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.1f + revSpeed * 0.01f }, Projectile.Center); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 19; - float spread = 0.045f * Utils.GetLerpValue(0, maxFrames, revFrames, true); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity).RotatedByRandom(spread), bulletAMMO, Projectile.damage / 2, Projectile.knockBack, Projectile.owner); + if (Main.myPlayer == Projectile.owner) + { + float spread = 0.045f * Utils.GetLerpValue(0, maxFrames, revFrames, true); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity).RotatedByRandom(spread), bulletAMMO, Projectile.damage, Projectile.knockBack, Projectile.owner); + } for (int i = 0; i <= 3; i++) { Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 5, Main.rand.NextBool(5) ? 28 : 215, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f)); dust.noGravity = true; } - //GenericSparkle sparker = new GenericSparkle(GunTipPosition, Vector2.Zero, Color.DarkGoldenrod, Color.Gold, Main.rand.NextFloat(1.1f, 1.8f), 2, Main.rand.NextFloat(-0.01f, 0.01f), 2.68f); - //GeneralParticleHandler.SpawnParticle(sparker); OffsetLengthFromArm -= 5f; - secondShot = false; shineScale = 1; - } - if (shootingTimer >= 60 && revFrames < maxFrames) - { - Owner.PickAmmo(Owner.ActiveItem(), out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _, !Main.rand.NextBool(4)); - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 19; - float spread = 0.045f * Utils.GetLerpValue(0, maxFrames, revFrames, true); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (shootVelocity).RotatedByRandom(spread).RotatedByRandom(0.04f), bulletAMMO, Projectile.damage / 2, Projectile.knockBack, Projectile.owner); shootingTimer = 0; - secondShot = true; } shootingTimer += revSpeed; @@ -86,7 +78,7 @@ namespace CalamityMod.Projectiles.Ranged if (revFrames >= maxFrames && !isTired || (Owner.Calamity().mouseRight && revFrames > 2 )) { - Owner.Calamity().GeneralScreenShakePower = 6.5f; + Owner.SetScreenshake(6.5f); OffsetLengthFromArm -= 35f; cooldownTimer = (int)MathHelper.Lerp((int)(Utils.Remap(revFrames, 0, 350, 40, 180, true)), 180, 0.7f); SoundStyle bigShot = new("CalamityMod/Sounds/Custom/Perforator/PerfHiveIchorShoot"); @@ -105,20 +97,20 @@ namespace CalamityMod.Projectiles.Ranged Particle pulse = new CustomPulse(GunTipPosition, Projectile.velocity * 9f, Color.Chartreuse * 0.7f, "CalamityMod/Particles/FlameExplosion", new Vector2(0.4f, 1f), Projectile.velocity.ToRotation(), 0.25f, 0, 34); GeneralParticleHandler.SpawnParticle(pulse); - float velBonus = 1.1f; - for (int i = 0; i <= 5; i++) + if (Main.myPlayer == Projectile.owner) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(-0.03f * i * velBonus) * (1 - i * 0.08f) * velBonus, ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, -i, 0, velBonus); + float velBonus = 1.1f; + for (int i = 0; i <= 5; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(-0.03f * i * velBonus) * (1 - i * 0.08f) * velBonus, ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, -i, 0, velBonus); + for (int j = 0; j <= 5; j++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(0.03f * j * velBonus) * (1 - j * 0.08f) * velBonus, ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, j, 0, velBonus); + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * velBonus, ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, 20, 0, velBonus); } - for (int j = 0; j <= 5; j++) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(0.03f * j * velBonus) * (1 - j * 0.08f) * velBonus, ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, j, 0, velBonus); - } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * velBonus, ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, 20, 0, velBonus); for (int i = 0; i <= 18; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition, 66, shootVelocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.RainbowTorch, shootVelocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f)); dust.noGravity = true; dust.color = Color.Chartreuse; } @@ -139,7 +131,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(tired with { Pitch = -0.2f }, Projectile.Center); for (int i = 0; i <= 12; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); dust.noGravity = false; dust.color = Color.White; } diff --git a/Projectiles/Ranged/FirestormCannonHoldout.cs b/Projectiles/Ranged/FirestormCannonHoldout.cs new file mode 100644 index 0000000000..cb539519b4 --- /dev/null +++ b/Projectiles/Ranged/FirestormCannonHoldout.cs @@ -0,0 +1,164 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class FirestormCannonHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 16f; + public override float BaseOffsetY => -5f; + public override float OffsetYDownwards => 5f; + public override Vector2 GunTipPosition => Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.35f; + + public static readonly SoundStyle WarningSound = new SoundStyle("CalamityMod/Sounds/Item/FireImplosion") with { Volume = 0.75f }; + public static readonly SoundStyle OverheatSound = new("CalamityMod/Sounds/Item/HeliumFlashSteamRelease"); + public SlotId WarningSlot; + public ref float Timer => ref Projectile.ai[0]; + private int BuiltHeat => (Owner.HeldItem.ModItem as FirestormCannon).BuiltUpHeat; + private bool displayOverheat = false; + private const int WarningTime = FirestormCannon.OverheatLevel - 100; + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Ranged; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15; + } + public override void KillHoldoutLogic() + { + // What kills the holdout: + // Dead, CCed, Cursed, etc. + // Not holding the item + // Right-clicking (Can kill it early) (Does not work if in overheat state) + // Completely cooling while not firing + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type || + (Owner.Calamity().mouseRight && !displayOverheat) || (BuiltHeat == 0 && !Main.mouseLeft)) + { + if (SoundEngine.TryGetActiveSound(WarningSlot, out var warn)) + warn.Stop(); + + Projectile.Kill(); + } + } + + public override void HoldoutAI() + { + // Timer should only increment while firing and not overheated + if (Main.mouseLeft && Owner.Calamity().flareGunOverheat == 0) + Timer++; + else + Timer = 0; + + // Once holding the fire button down long enough, start actually firing + if (Timer >= 30) + { + // For some reason using HeldItem here breaks its functionality while being held on the cursor + (Owner.HeldItem.ModItem as FirestormCannon).BuiltUpHeat++; + + // Overheat yourself if you fire too long + if (BuiltHeat >= FirestormCannon.OverheatLevel) + { + WarningSlot = SoundEngine.PlaySound(OverheatSound, Owner.Center); + for (int e = 0; e < 7; e++) + { + Vector2 dustVel = -Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.Pi * 0.15f) * Main.rand.NextFloat(3.8f, 5.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Flare, dustVel, Scale: 1.5f); + dust.noGravity = true; + } + + // Overheat damage ignores defense and is undodgeable, also inflicts On Fire + Owner.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.FlareGunOverheat").ToNetworkText(Owner.name)), FirestormCannon.OverheatDamage, 1, dodgeable: false, scalingArmorPenetration: 1f, knockback: 0f); + Owner.AddBuff(BuffID.OnFire, FirestormCannon.OverheatCooldown); + Owner.Calamity().flareGunOverheat = FirestormCannon.OverheatCooldown; + displayOverheat = true; + return; + } + + // Play a warning sound + if (BuiltHeat == WarningTime) + { + WarningSlot = SoundEngine.PlaySound(WarningSound, Owner.Center); + } + + // Controls the escalating firing speed + float firingLerp = Utils.GetLerpValue(0, 90, Timer - 30, true); + int firingFrequency = (int)MathHelper.Lerp(HeldItem.useTime, HeldItem.useTime / 2, firingLerp); + // Actually fire shtuff + if (Timer % firingFrequency == 0) + { + SoundEngine.PlaySound(SoundID.Item11 with { Volume = 0.8f }, Owner.Center); + if (Main.myPlayer == Projectile.owner) + { + Owner.PickAmmo(HeldItem, out int flareType, out _, out _, out _, out _, Main.rand.Next(100) >= 70); + Vector2 velocity = Projectile.velocity.RotatedByRandom(MathHelper.Pi * 0.04f * (1f + firingLerp * 0.5f)) * Owner.HeldItem.shootSpeed; + Projectile flare = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, velocity, flareType, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f, 1f); + flare.penetrate = 3; + flare.MaxUpdates = 2; + flare.timeLeft = 600; + flare.DamageType = DamageClass.Ranged; + flare.usesIDStaticNPCImmunity = false; + flare.usesLocalNPCImmunity = true; + flare.localNPCHitCooldown = 30 * 2; + } + } + } + + // Reset overheat draw color once the heat passes below the warning indicator + if (BuiltHeat < WarningTime) + displayOverheat = false; + // Draw smoke effect while overheated + if (displayOverheat && Main.rand.NextBool(3)) + { + HeavySmokeParticle smoke = new(GunTipPosition, -Vector2.UnitY * 7.5f, Color.DarkGray, 25, 0.4f, 0.75f); + GeneralParticleHandler.SpawnParticle(smoke); + } + // Constantly move the warning sound on top of the player + if (SoundEngine.TryGetActiveSound(WarningSlot, out var warning) && warning.IsPlaying) + warning.Position = Projectile.Center; + } + + // Pan-searing mechanic; reduces heat a bit + public override bool? CanDamage() => BuiltHeat >= 120 && Owner.Calamity().flareGunOverheat == 0; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.OnFire, 300); + (Owner.HeldItem.ModItem as FirestormCannon).BuiltUpHeat -= 6; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Color tintColor = displayOverheat ? Color.Black : + BuiltHeat >= WarningTime ? Color.Lerp(Color.Tomato, Color.White, MathF.Abs(MathF.Sin(Owner.miscCounter * MathHelper.Pi / 30f))) : Color.Tomato; + + CalamityUtils.EnterShaderRegion(Main.spriteBatch); + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(Utils.GetLerpValue(0, WarningTime, BuiltHeat, true) * 0.45f); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(tintColor); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + CalamityUtils.ExitShaderRegion(Main.spriteBatch); + return false; + } + } +} diff --git a/Projectiles/Ranged/FlakKrakenHoldout.cs b/Projectiles/Ranged/FlakKrakenHoldout.cs index 71f1228313..952a65edc8 100644 --- a/Projectiles/Ranged/FlakKrakenHoldout.cs +++ b/Projectiles/Ranged/FlakKrakenHoldout.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Ranged // Every time we shoot we use ammo. // With this method we also use the item's stats, like the shoot speed, or the type of ammo it was used. - Owner.PickAmmo(Owner.ActiveItem(), out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot); + Owner.PickAmmo(Owner.HeldItem, out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot); // Decides the color of the effects depending on the type of rocket used. switch (rocketTypeShot) @@ -80,20 +80,23 @@ namespace CalamityMod.Projectiles.Ranged break; } - // 15NOV2024: Ozzatron: manually clamp flak explosion distance - float flakDist = MathHelper.Clamp(ownerToMouse.Length(), 0f, 960f); + if (Main.myPlayer == Projectile.owner) + { + // 15NOV2024: Ozzatron: manually clamp flak explosion distance + float flakDist = MathHelper.Clamp(ownerToMouse.Length(), 0f, 960f); - // Spawns the projectile. - Projectile.NewProjectile( - Projectile.GetSource_FromThis(), - GunTipPosition, - direction * itemShootSpeed, - ProjectileType(), - itemDamage, - itemKnockback, - Projectile.owner, - rocketTypeShot, - flakDist); + // Spawns the projectile. + Projectile.NewProjectile( + Projectile.GetSource_FromThis(), + GunTipPosition, + direction * itemShootSpeed, + ProjectileType(), + itemDamage, + itemKnockback, + Projectile.owner, + rocketTypeShot, + flakDist); + } // Applies the knockback to the player. Owner.velocity += ownerToMouse.SafeNormalize(Vector2.UnitY) * -OwnerKnockbackStrength; @@ -105,7 +108,7 @@ namespace CalamityMod.Projectiles.Ranged // By decreasing the offset length of the gun from the arms, we give an effect of recoil. OffsetLengthFromArm = 10f; - Owner.Calamity().GeneralScreenShakePower = 3.5f; + Owner.SetScreenshake(3.5f); Particle shootPulse = new DirectionalPulseRing(GunTipPosition, Vector2.Zero, diff --git a/Projectiles/Ranged/FlakToxicannonHoldout.cs b/Projectiles/Ranged/FlakToxicannonHoldout.cs index c257dcc7a0..c2c80b9bc6 100644 --- a/Projectiles/Ranged/FlakToxicannonHoldout.cs +++ b/Projectiles/Ranged/FlakToxicannonHoldout.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Ranged // Every time we shoot we use ammo. // With this method we also use the item's stats, like the shoot speed, or the type of ammo it was used. - Owner.PickAmmo(Owner.ActiveItem(), out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot); + Owner.PickAmmo(Owner.HeldItem, out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot); // Decides the color of the effects depending on the type of rocket used. switch (rocketTypeShot) @@ -77,20 +77,23 @@ namespace CalamityMod.Projectiles.Ranged break; } - // 15NOV2024: Ozzatron: manually clamp flak explosion distance - float flakDist = MathHelper.Clamp(ownerToMouse.Length(), 0f, 960f); + if (Main.myPlayer == Projectile.owner) + { + // 15NOV2024: Ozzatron: manually clamp flak explosion distance + float flakDist = MathHelper.Clamp(ownerToMouse.Length(), 0f, 960f); - // Spawns the projectile. - Projectile.NewProjectile( - Projectile.GetSource_FromThis(), - GunTipPosition, - direction * itemShootSpeed, - ProjectileType(), - itemDamage, - itemKnockback, - Projectile.owner, - rocketTypeShot, - flakDist); + // Spawns the projectile. + Projectile.NewProjectile( + Projectile.GetSource_FromThis(), + GunTipPosition, + direction * itemShootSpeed, + ProjectileType(), + itemDamage, + itemKnockback, + Projectile.owner, + rocketTypeShot, + flakDist); + } // Applies the knockback to the player. Owner.velocity += ownerToMouse.SafeNormalize(Vector2.UnitY) * -OwnerKnockbackStrength; @@ -102,7 +105,7 @@ namespace CalamityMod.Projectiles.Ranged // By decreasing the offset length of the gun from the arms, we give an effect of recoil. OffsetLengthFromArm = 25f; - Owner.Calamity().GeneralScreenShakePower = 2f; + Owner.SetScreenshake(2f); Particle shootPulse = new DirectionalPulseRing(GunTipPosition, Vector2.Zero, diff --git a/Projectiles/Ranged/FlareBat.cs b/Projectiles/Ranged/FlareBat.cs index eec96dfc86..73b4c62e01 100644 --- a/Projectiles/Ranged/FlareBat.cs +++ b/Projectiles/Ranged/FlareBat.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -25,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.light = 0.25f; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/Flash.cs b/Projectiles/Ranged/Flash.cs index 1c2fca754b..93ca565bd1 100644 --- a/Projectiles/Ranged/Flash.cs +++ b/Projectiles/Ranged/Flash.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -22,72 +21,22 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; Projectile.timeLeft = 5; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f); Color dustColor = Projectile.ai[1] == 1f ? CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f) : default; - bool xflag = false; - bool yflag = false; - if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) - { - xflag = true; - } - if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) - { - xflag = true; - } - if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) - { - yflag = true; - } - if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) - { - yflag = true; - } - if (xflag && yflag) - { - Projectile.Kill(); - } - float projTimer = 25f; - if (Projectile.ai[0] > 180f) - { - projTimer -= (Projectile.ai[0] - 180f) / 2f; - } - if (projTimer <= 0f) - { - projTimer = 0f; - Projectile.Kill(); - } - projTimer *= 0.7f; - Projectile.ai[0] += 4f; - int timerCounter = 0; - while ((float)timerCounter < projTimer) - { - float rand1 = (float)Main.rand.Next(-30, 31); - float rand2 = (float)Main.rand.Next(-30, 31); - float rand3 = (float)Main.rand.Next(9, 27); - float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); - randAdjust = rand3 / randAdjust; - rand1 *= randAdjust; - rand2 *= randAdjust; - int flashDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.PortalBoltTrail, 0f, 0f, 100, dustColor, 2f); - Dust dust = Main.dust[flashDust]; - dust.noGravity = true; - dust.position.X = Projectile.Center.X; - dust.position.Y = Projectile.Center.Y; - dust.position.X += (float)Main.rand.Next(-10, 11); - dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = rand1; - dust.velocity.Y = rand2; - timerCounter++; - } - } + float randRot = Main.rand.NextFloat(MathHelper.TwoPi); - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.Confused, 300); + for (int i = 0; i < 4; i++) + { + Vector2 dustVel = Vector2.UnitX.RotatedBy(MathHelper.PiOver2 * i + randRot) * 3f; + Dust flashDust = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail, dustVel, 100, dustColor, 1.5f); + flashDust.noGravity = true; + } } } } diff --git a/Projectiles/Ranged/FlashRoundFlash.cs b/Projectiles/Ranged/FlashRoundFlash.cs new file mode 100644 index 0000000000..292698a737 --- /dev/null +++ b/Projectiles/Ranged/FlashRoundFlash.cs @@ -0,0 +1,48 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class FlashRoundFlash : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Ranged"; + public override void SetDefaults() + { + Projectile.width = 95; + Projectile.height = 95; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.timeLeft = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.5f); + } + public override bool? CanHitNPC(NPC target) + { + if (Utils.Distance(target.Center, Projectile.Center) <= Projectile.width) + { + Player Owner = Main.player[Projectile.owner]; + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Projectile.Center); + target.MoveNPC(launchVel, 5, false); + + Vector2 dustVel = Utils.DirectionTo(Projectile.Center, target.Center); + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(target.Center, ModContent.DustType(), dustVel.RotatedByRandom(0.7f) * Main.rand.NextFloat(9f, 14f)); + dust.scale = Main.rand.NextFloat(0.45f, 0.75f); + dust.noGravity = true; + dust.color = Color.White; + dust.noLightEmittence = true; + } + } + return false; + } + } +} diff --git a/Projectiles/Ranged/FlashRoundProj.cs b/Projectiles/Ranged/FlashRoundProj.cs index 6eb86ba08f..51615c3a6a 100644 --- a/Projectiles/Ranged/FlashRoundProj.cs +++ b/Projectiles/Ranged/FlashRoundProj.cs @@ -1,4 +1,9 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -9,8 +14,10 @@ namespace CalamityMod.Projectiles.Ranged public class FlashRoundProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public bool Exploding = false; - public float ExplosionPower = 1.5f; + public int bounces = 2; + public float shineRot = 0; + public bool onSpawn = true; + public ref float time => ref Projectile.ai[2]; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 15; @@ -19,99 +26,152 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; + Projectile.width = 8; + Projectile.height = 8; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; + Projectile.penetrate = 2; Projectile.timeLeft = 600; - Projectile.extraUpdates = 2; + Projectile.extraUpdates = 3; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.localNPCHitCooldown = -1; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; Projectile.spriteDirection = Projectile.direction; - Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * (Exploding ? 1.5f : 0.2f)); + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.3f); - Projectile.localAI[0] += 1f; - - if (Exploding) + if (bounces < 2 || Projectile.numHits > 0) { - if (Projectile.timeLeft == 59) - { - SoundEngine.PlaySound(SoundID.Item93 with { Pitch = 0.55f, Volume = 0.4f }, Projectile.Center); - } - Projectile.velocity = Vector2.Zero; + int falloffTime = 7; + if (time > falloffTime) + Projectile.velocity.X *= 0.983f; + if (Projectile.velocity.Y < 15 && time > falloffTime) + Projectile.velocity.Y += 0.16f; + if (Projectile.velocity.Y < 5) + Projectile.velocity.Y *= 0.98f; + } + if (onSpawn) + { + Projectile.knockBack = 0; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 10; + shineRot = Main.rand.NextFloat(-5, 5); + onSpawn = false; + } + shineRot += Math.Sign(shineRot) * 0.05f; - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 91 : 264, (new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.9f, 1.2f)) * ExplosionPower); - dust.scale = Main.rand.NextFloat(0.75f, 0.9f) * ExplosionPower; + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (time > 2 && time % 2 == 0 && targetDist < 1400) + { + float trailSize = Utils.GetLerpValue(2, 5, Projectile.velocity.Length(), true); + Particle trail = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 0.5f, "CalamityMod/Particles/BloomCircle", false, 5, 0.13f, Color.White * 0.6f, new Vector2(1f - 0.2f * trailSize, 1 + 2f * trailSize), true, false, shrinkSpeed: 0.8f * trailSize); + GeneralParticleHandler.SpawnParticle(trail); + } + if (Main.rand.NextBool(3)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 91 : 264, -Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.5f, 0.9f)); + dust.scale = Main.rand.NextFloat(0.55f, 0.7f); dust.noGravity = true; - - if (Projectile.timeLeft <= 50 && ExplosionPower > 0.5f) - ExplosionPower -= 0.015f; - } - else - { - if (Projectile.localAI[0] > 4f) - { - if (Main.rand.NextBool()) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 63, -Projectile.velocity * Main.rand.NextFloat(0.9f, 1.1f)); - dust.scale = Main.rand.NextFloat(0.7f, 0.85f); - dust.noGravity = true; - } - } } + time++; } public override bool PreDraw(ref Color lightColor) { - if (Projectile.localAI[0] > 6f && !Exploding) - CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, Color.White); + float sine = (float)Math.Sin(Projectile.timeLeft * 0.175f / MathHelper.Pi); + float trueSine = MathHelper.Lerp(sine, Math.Sign(sine) * 0.5f, 0.6f); + Asset trail = ModContent.Request("CalamityMod/Particles/BloomLineSoftEdge"); + Asset shine = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * 0.6f, Projectile.rotation + shineRot, shine.Size() / 2f, new Vector2(1 + 0.9f * trueSine, 1 + 0.9f * -trueSine) * Projectile.scale * 0.13f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * 0.6f, Projectile.rotation + shineRot, shine.Size() / 2f, new Vector2(1 + 0.9f * -trueSine, 1 + 0.9f * trueSine) * Projectile.scale * 0.13f, SpriteEffects.None, 0); return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (!Exploding) + time = 0; + Projectile.velocity = Vector2.Lerp(Utils.DirectionFrom(Projectile.Center, target.Center) * 12, Vector2.UnitY * -7, 0.75f).RotatedByRandom(0.25f); + makeDust(false); + } + public void makeDust(bool onlyFlash) // This is basically the tile/hit effects + { + if (!onlyFlash) { - Projectile.timeLeft = 60; - Exploding = true; - Projectile.damage = (int)(Projectile.damage * 0.15f); - Projectile.ExpandHitboxBy(100); - Projectile.alpha = 255; + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 91 : 264, Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.6f) * Main.rand.NextFloat(8.5f, 12f)); + dust.scale = Main.rand.NextFloat(0.75f, 1.1f); + dust.noGravity = true; + } + SoundEngine.PlaySound(SoundID.Item50 with { Volume = 0.3f, Pitch = -0.2f + 0.4f * bounces, MaxInstances = 15 }, Projectile.Center); } - target.AddBuff(BuffID.Confused, 300); + for (int i = 0; i < 2; i++) + { + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f * (i), 0.45f * (i), 9, true, makeLight: 0); + GeneralParticleHandler.SpawnParticle(blastRing); + } + float rot = Main.rand.NextFloat(-5, 5); + for (int i = 0; i < 5; i++) + { + Vector2 dustVel = ((MathHelper.TwoPi * i / 5f) + rot).ToRotationVector2() * 5; + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), dustVel); + dust.scale = 1.1f; + dust.fadeIn = 1.5f; + dust.noGravity = true; + dust.color = Color.White; + dust.noLightEmittence = true; + } + // Doesn't actually do damage, just an aoe for knockback + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 5, 0f, Projectile.owner); } public override bool OnTileCollide(Vector2 oldVelocity) { - if (!Exploding) + time = 0; + if (Projectile.velocity.X != oldVelocity.X) { - Projectile.timeLeft = 60; - Exploding = true; - Projectile.damage = (int)(Projectile.damage * 0.15f); - Projectile.ExpandHitboxBy(100); - Projectile.alpha = 255; - Projectile.tileCollide = false; + Projectile.velocity.X = -oldVelocity.X; } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + if (Projectile.velocity.X < 2 && Projectile.velocity.X > 0) + Projectile.velocity.X = 2; + if (Projectile.velocity.X > -2 && Projectile.velocity.X < 0) + Projectile.velocity.X = -2; + if (Projectile.velocity.Y < 2 && Projectile.velocity.Y > 0) + Projectile.velocity.Y = 2; + if (Projectile.velocity.Y > -2 && Projectile.velocity.Y < 0) + Projectile.velocity.Y = -2; + + Projectile.velocity *= 0.97f; + + int expectedDamage = Math.Max((int)(Projectile.damage * 1.13f), Projectile.damage + 2); + Projectile.damage = expectedDamage; + + makeDust(false); + if (bounces <= 0) + { + Projectile.Kill(); + return false; + } + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; + bounces--; return false; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float damageMult = (Projectile.numHits == 0 ? 1 : 0.3f); + modifiers.SourceDamage *= damageMult; + } public override void OnKill(int timeLeft) { - if (!Exploding) - { - for (int k = 0; k < 9; k++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 63, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.9f, 1.1f)); - dust.scale = Main.rand.NextFloat(0.6f, 0.75f); - dust.noGravity = true; - } - } } } } diff --git a/Projectiles/Ranged/FlurrystormCannonShooting.cs b/Projectiles/Ranged/FlurrystormCannonShooting.cs index 52bee35333..99085fbb5a 100644 --- a/Projectiles/Ranged/FlurrystormCannonShooting.cs +++ b/Projectiles/Ranged/FlurrystormCannonShooting.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[1] = (float)(initialRate - fireRateMult * fireRate); shouldShoot = true; } - bool canShoot = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem()); + bool canShoot = !player.CantUseHoldout() && player.HasAmmo(player.HeldItem); if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -95,13 +95,13 @@ namespace CalamityMod.Projectiles.Ranged { int projType = ProjectileID.SnowBallFriendly; float speedMult2 = 14f; - int dmg = player.GetWeaponDamage(player.ActiveItem()); - float kBack = player.ActiveItem().knockBack; + int dmg = player.GetWeaponDamage(player.HeldItem); + float kBack = player.HeldItem.knockBack; if (canShoot) { - player.PickAmmo(player.ActiveItem(), out projType, out speedMult2, out dmg, out kBack, out _); - kBack = player.GetWeaponKnockback(player.ActiveItem(), kBack); - float shootSpeed = player.ActiveItem().shootSpeed * Projectile.scale; + player.PickAmmo(player.HeldItem, out projType, out speedMult2, out dmg, out kBack, out _); + kBack = player.GetWeaponKnockback(player.HeldItem, kBack); + float shootSpeed = player.HeldItem.shootSpeed * Projectile.scale; Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); Vector2 direction = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - source; if (player.gravDir == -1f) diff --git a/Projectiles/Ranged/FlurrystormIceChunk.cs b/Projectiles/Ranged/FlurrystormIceChunk.cs index 33f031585d..39b2db16d6 100644 --- a/Projectiles/Ranged/FlurrystormIceChunk.cs +++ b/Projectiles/Ranged/FlurrystormIceChunk.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.coldDamage = true; Projectile.penetrate = 1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/FossilShard.cs b/Projectiles/Ranged/FossilShard.cs index 04c56abf8c..03a853f3db 100644 --- a/Projectiles/Ranged/FossilShard.cs +++ b/Projectiles/Ranged/FossilShard.cs @@ -23,11 +23,10 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.ai[1] != 1f) { - if (Projectile.velocity.Y <= 0f) - Projectile.velocity.Y = 0.1f; - Projectile.velocity.Y *= 1.05f; + if (Projectile.velocity.Y <= -2f) + Projectile.velocity.Y = -2f; } - + Projectile.velocity.Y += 0.025f; Projectile.rotation += Projectile.velocity.Y; } diff --git a/Projectiles/Ranged/FreedomStarHoldout.cs b/Projectiles/Ranged/FreedomStarHoldout.cs index cc5ea44a41..e1d5479db2 100644 --- a/Projectiles/Ranged/FreedomStarHoldout.cs +++ b/Projectiles/Ranged/FreedomStarHoldout.cs @@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles.Ranged // Projectile shooting. if (shootThisFrame && Main.myPlayer == Projectile.owner) { - Item freedomStar = player.ActiveItem(); + Item freedomStar = player.HeldItem; // This grabs the weapon's current damage, taking current charge level into account. int currentDamage = player.GetWeaponDamage(freedomStar); @@ -147,26 +147,10 @@ namespace CalamityMod.Projectiles.Ranged // Checks if the Freedom Star has sufficient charge to fire. If this is false, it stops functioning. CalamityGlobalItem modItem = freedomStar.Calamity(); - float chargeConsumed = FreedomStar.HoldoutChargeUse_Orb; - switch (chargeAmt) - { - case 1: - chargeConsumed = FreedomStar.HoldoutChargeUse_OrbLarge; - break; - - case 2: - chargeConsumed = MathHelper.Lerp(FreedomStar.HoldoutChargeUse_Laser, FreedomStar.HoldoutChargeUse_LaserLarge, lerpAmtForCharge); - break; - - default: - break; - } - bool hasCharge = modItem.Charge >= chargeConsumed; + bool hasCharge = true; if (stillInUse && hasCharge) { - // Use charge when firing anything. - modItem.Charge -= chargeConsumed; if (Projectile.ai[0] == LaserGateValue) { diff --git a/Projectiles/Ranged/FungiOrb.cs b/Projectiles/Ranged/FungiOrb.cs index b0917fb7a7..08be24b2b6 100644 --- a/Projectiles/Ranged/FungiOrb.cs +++ b/Projectiles/Ranged/FungiOrb.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/GemTechGreenFlechette.cs b/Projectiles/Ranged/GemTechGreenFlechette.cs index 981761315d..b8f64714ac 100644 --- a/Projectiles/Ranged/GemTechGreenFlechette.cs +++ b/Projectiles/Ranged/GemTechGreenFlechette.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Ranged float initialSpeed = Main.rand.NextFloat(2.5f, 4.5f); for (int i = 0; i < 12; i++) { - Dust crystalShard = Dust.NewDustPerfect(Projectile.Center, 267); + Dust crystalShard = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); crystalShard.velocity = (MathHelper.TwoPi * i / 12f).ToRotationVector2() * initialSpeed * Main.rand.NextFloat(0.6f, 1f); crystalShard.velocity = crystalShard.velocity.RotatedByRandom(0.37f); crystalShard.scale = 1.25f; @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged float initialSpeed = Main.rand.NextFloat(2.5f, 4.5f); for (int i = 0; i < 16; i++) { - Dust crystalShard = Dust.NewDustPerfect(Projectile.Center, 267); + Dust crystalShard = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); crystalShard.velocity = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * initialSpeed; crystalShard.scale = 1.25f; crystalShard.color = Color.ForestGreen; diff --git a/Projectiles/Ranged/GodSlayerSlugProj.cs b/Projectiles/Ranged/GodSlayerSlugProj.cs index 45dd067be9..3f492ffb36 100644 --- a/Projectiles/Ranged/GodSlayerSlugProj.cs +++ b/Projectiles/Ranged/GodSlayerSlugProj.cs @@ -1,5 +1,6 @@ using System.IO; using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -50,7 +51,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; Projectile.timeLeft = Lifetime; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void SendExtraAI(BinaryWriter writer) => writer.Write(Projectile.tileCollide); @@ -99,10 +99,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ai[1] = BlueNoCollideFrames; Projectile.tileCollide = false; - // Reduce damage, but remove piercing. Reset local iframes so the bullet, turned blue, may always strike again. Reset the point blank timer. - Projectile.damage = (int)(0.28f * Projectile.damage); + // Reduce damage, but remove piercing. Reset local iframes so the bullet, turned blue, may always strike again. + Projectile.damage = (int)(0.25f * Projectile.damage); Projectile.penetrate = 1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; for (int i = 0; i < Main.maxNPCs; i++) Projectile.localNPCImmunity[i] = 0; @@ -113,7 +112,7 @@ namespace CalamityMod.Projectiles.Ranged return; // The bullet disappears in a puff of dust. - ProduceWarpCrossDust(Projectile.Center, (int)CalamityDusts.PurpleCosmilite); + ProduceWarpCrossDust(Projectile.Center, ModContent.DustType(), 0.5f, Color.Magenta); // The warp must be performed client side because it requires knowledge of the player's mouse position. Projectile.netUpdate = true; @@ -146,7 +145,17 @@ namespace CalamityMod.Projectiles.Ranged // Now that the bullet has warped, produce a tiny puff of dust at its back for effect. Vector2 warpInDustPos = Projectile.Center - bulletToMouseVec * TextureHeight; - ProduceWarpCrossDust(warpInDustPos, (int)CalamityDusts.BlueCosmilite); + ProduceWarpCrossDust(warpInDustPos, ModContent.DustType(), 1f, Color.Cyan); + for (int i = 0; i < 3; i++) + { + Vector2 dustVel = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.05f) * Main.rand.NextFloat(9, 15); + Dust d = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + d.position = warpInDustPos; + d.velocity = dustVel; + d.noGravity = true; + d.scale *= Main.rand.NextFloat(0.6f, 1f); + d.color = Color.Cyan; + } } public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 140); @@ -170,18 +179,21 @@ namespace CalamityMod.Projectiles.Ranged Projectile.Damage(); // Create a fancy triangle of dust. - int dustID = (int)CalamityDusts.BlueCosmilite; + int dustID = ModContent.DustType(); int numDust = 9; float triangleAngle = Main.rand.NextFloat(MathHelper.TwoPi); for (int i = 0; i < numDust; ++i) { - float speed = MathHelper.Lerp(0.2f, 3.6f, i / (float)(numDust - 1)); - Vector2 dustVel = Vector2.UnitX.RotatedBy(triangleAngle) * speed; + float lerp = i / (float)(numDust - 1); + float speed = MathHelper.Lerp(0.2f, 3.6f, lerp); + Vector2 dustVel = Vector2.UnitX.RotatedBy(triangleAngle) * speed * 2; Dust d = Dust.NewDustDirect(Projectile.Center, 0, 0, dustID); d.position = Projectile.Center; d.velocity = dustVel; d.noGravity = true; - d.scale *= Main.rand.NextFloat(1.1f, 1.4f); + d.fadeIn = 1.5f; + d.scale *= Main.rand.NextFloat(1.4f, 1.9f) - lerp * 0.5f; + d.color = Color.Lerp(Color.Cyan, Color.Magenta, lerp); Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi * 2f / 3f); Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi * 4f / 3f); } @@ -201,17 +213,36 @@ namespace CalamityMod.Projectiles.Ranged return true; } - private void ProduceWarpCrossDust(Vector2 dustPos, int dustID) + private void ProduceWarpCrossDust(Vector2 dustPos, int dustID, float speedMultiplier, Color color) { - for (int i = 0; i < 4; ++i) + if (speedMultiplier > 0.8f) //dark { - float speed = Main.rand.NextFloat(2.0f, 4.1f); - Vector2 dustVel = Vector2.UnitX * speed; + for (int i = 0; i < 2; ++i) + { + Particle pulse = new CustomPulse(dustPos, Vector2.Zero, Color.Black, "CalamityMod/ExtraTextures/BasicCircle", Vector2.One, 0, 0.4f * speedMultiplier, 0.05f * speedMultiplier, 12, false); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new CustomPulse(dustPos, Vector2.Zero, color, "CalamityMod/Particles/BloomRing", Vector2.One, 0, 0.15f * (1 + i * 0.2f) * speedMultiplier, 0.025f * (1 + i * 0.2f) * speedMultiplier, 12, true); + GeneralParticleHandler.SpawnParticle(pulse2); + } + } + else //light + { + Particle pulse = new CustomSpark(dustPos, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 10, 0.3f * speedMultiplier, color, new Vector2(1f, 1f), true, true, glowOpacity: 1f); + GeneralParticleHandler.SpawnParticle(pulse); + } + + + for (int i = 0; i < 5; ++i) + { + float speed = Main.rand.NextFloat(3f, 6f); + Vector2 dustVel = Vector2.UnitX * speed * speedMultiplier * 1.5f; Dust d = Dust.NewDustDirect(Projectile.Center, 0, 0, dustID); d.position = dustPos; d.velocity = dustVel; d.noGravity = true; - d.scale *= Main.rand.NextFloat(1.1f, 1.4f); + d.scale *= Main.rand.NextFloat(1.8f, 2.2f) * (1 - speed / 7); + d.color = color; + d.fadeIn = 1; Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.PiOver2); Dust.CloneDust(d).velocity = dustVel.RotatedBy(MathHelper.Pi); Dust.CloneDust(d).velocity = dustVel.RotatedBy(-MathHelper.PiOver2); diff --git a/Projectiles/Ranged/HailstormBulletProj.cs b/Projectiles/Ranged/HailstormBulletProj.cs index 17620c79fa..7b111a00ae 100644 --- a/Projectiles/Ranged/HailstormBulletProj.cs +++ b/Projectiles/Ranged/HailstormBulletProj.cs @@ -1,7 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -37,7 +35,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; Projectile.coldDamage = true; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/HalleysComet.cs b/Projectiles/Ranged/HalleysComet.cs index be4ba1de28..696a290861 100644 --- a/Projectiles/Ranged/HalleysComet.cs +++ b/Projectiles/Ranged/HalleysComet.cs @@ -1,4 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -73,11 +75,17 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.FinalExtraUpdate()) Lighting.AddLight(Projectile.Center, Color.MediumBlue.ToVector3() * 0.4f); + + if (Projectile.timeLeft == 1 && Projectile.ai[1] < 1) + { + Main.player[Projectile.owner].Calamity().HalleyAccuracyCounter -= HalleysInferno.LostAccuracyPerMiss; + } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 450); + //Doze - Originally I gave this long Voidfrost infiction due to flamethrowers in vanilla being long debuff infliction items + //This has been undone as Voidfrost is now inflicted more sparingly but is more powerful. On-tier it's exclusively used by Stratus items consuming Starbursts SoundEngine.PlaySound(HalleysInferno.Hit, Projectile.Center); // Dust emission on hit @@ -88,6 +96,14 @@ namespace CalamityMod.Projectiles.Ranged dust.velocity = Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 2.1f); dust.noGravity = true; } + Projectile.ai[1] = 1; + if (Projectile.penetrate == 5) + { + var cplay = Main.player[Projectile.owner].Calamity(); + cplay.HalleyAccuracyCounter++; + cplay.HalleyAccuracyCounter = MathF.Min(HalleysInferno.MaxAccuracy, cplay.HalleyAccuracyCounter); + Main.player[Projectile.owner].Calamity().StarburstSpawnFrameCounter += cplay.HalleyAccuracyCounter / HalleysInferno.MaxAccuracy * HalleysInferno.MaxStarburstPerComet; + } } public override void OnHitPlayer(Player target, Player.HurtInfo info) diff --git a/Projectiles/Ranged/HalleysInfernoHoldout.cs b/Projectiles/Ranged/HalleysInfernoHoldout.cs new file mode 100644 index 0000000000..166b8d838d --- /dev/null +++ b/Projectiles/Ranged/HalleysInfernoHoldout.cs @@ -0,0 +1,151 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Mono.Cecil; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using static System.Net.Mime.MediaTypeNames; + +namespace CalamityMod.Projectiles.Ranged +{ + public class HalleysInfernoHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 24f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; + public override float OffsetYDownwards => 5f; + public override float WeaponTurnSpeed => 20; + + public ref float ShotTimer => ref Projectile.ai[0]; + public ref float AccuracyCounter => ref Owner.Calamity().HalleyAccuracyCounter; + + public ref float ShotCounter => ref Projectile.ai[2]; + + public ref float RecoilAmount => ref Projectile.localAI[0]; + + public Player Owner => Main.player[Projectile.owner]; + + public Item Halley => Owner.HeldItem; + public override void KillHoldoutLogic() + { + if ((Owner.CantUseHoldout(false) || Halley.type != ModContent.ItemType())) + Projectile.Kill(); + } + + public override void HoldoutAI() + { + SetUsage = false; + if (Halley.type != ModContent.ItemType()) + { + Projectile.Kill(); + return; + } + Projectile.timeLeft = 60; + if (Owner.HasAmmo(Halley) && (Owner.controlUseItem || ShotCounter > 0)) + { + if (ShotTimer <= 0) + { + ShotCounter++; + ShotTimer = 5; + if (ShotCounter >= 5) + { + ShotCounter = 0; + ShotTimer += 35; + } + var spawnpos = Projectile.Center; + Projectile.NewProjectile(Owner.GetSource_ItemUse_WithPotentialAmmo(Halley,AmmoID.Gel),spawnpos,spawnpos.DirectionTo(Main.MouseWorld) * Halley.shootSpeed,ModContent.ProjectileType(), (int)Owner.GetDamage(DamageClass.Ranged).ApplyTo(Halley.damage),Halley.knockBack,Projectile.owner); + RecoilAmount = 8; + SoundEngine.PlaySound(HalleysInferno.ShootSound); + //consume gel + Owner.PickAmmo(Halley, out _, out _, out _, out _, out _); + } + } + else if (Owner.controlUseTile) + { + if (ShotTimer <= 0 && Owner.Calamity().AvaliableStarburst > 0) + { + ShotTimer = 4; + var spawnpos = Projectile.Center; + var dir = spawnpos.DirectionTo(Main.MouseWorld); + var color = Main.rand.Next(1, 7); + Color drawColor = Color.White; + switch (color) + { + case 1: + drawColor = Color.HotPink; + break; + case 2: + drawColor = Color.Yellow; + break; + case 3: + drawColor = Color.LimeGreen; + break; + case 4: + drawColor = Color.SkyBlue; + break; + case 5: + drawColor = Color.Lavender; + break; + } + for (var i = 0; i < 5; i++) + GeneralParticleHandler.SpawnParticle(new GlowSparkParticle(spawnpos + dir * 36, (dir * Halley.shootSpeed).RotatedByRandom(0.75f) * Main.rand.NextFloat(0.5f, 1.5f), false, 7, 0.02f, drawColor, new Vector2(0.5f, 1f))); + if (Projectile.owner == Main.myPlayer) + Projectile.NewProjectile(Owner.GetSource_ItemUse_WithPotentialAmmo(Halley, AmmoID.Gel), spawnpos + dir * 16,dir * Halley.shootSpeed * 0.75f, ModContent.ProjectileType(), (int)Owner.GetDamage(DamageClass.Ranged).ApplyTo(Halley.damage), Halley.knockBack, Projectile.owner, color); + Owner.Calamity().StratusStarburst--; + SoundEngine.PlaySound(HalleysInferno.ShootSound); + RecoilAmount = 4; + } + } + RecoilAmount *= 0.75f; + if (ShotTimer > 0) + ShotTimer--; + } + + public override bool PreDraw(ref Color lightColor) + { + if (Main.myPlayer == Owner.whoAmI) + { + float completion = (AccuracyCounter) / (HalleysInferno.MaxAccuracy); + var barBG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; + var barFG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; + + Vector2 drawPos = Owner.Center - Main.screenPosition + new Vector2(0, -36) - barBG.Size() / 2; + Rectangle frame = new Rectangle(0, 0, (int)(completion * barFG.Width), barFG.Height); + + float opacity = 1f; + Color color = Color.Lerp(Color.DarkSlateBlue,Color.SkyBlue, completion); + if (completion >= 1) + color = Color.DeepSkyBlue; + + Main.spriteBatch.Draw(barBG, drawPos, color * opacity); + Main.spriteBatch.Draw(barFG, drawPos, frame, color * opacity * 0.8f); + } + + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + for (int i = 1; i <= 24; i++) + { + float mult = MathHelper.Max(Utils.GetLerpValue(7, 0, i), Utils.GetLerpValue(17, 24, i)); + Vector2 drawOffset = (((MathHelper.TwoPi * i / 24f).ToRotationVector2().RotatedBy(Projectile.rotation) * RecoilAmount) + Main.rand.NextVector2Circular(2, 2)); + Color auraColor = Color.Chartreuse with { A = 0 } * mult * (0.4f) * Utils.GetLerpValue(90, 135, RecoilAmount, true); + float aimAngle = drawRotation; + Main.EntitySpriteDraw(texture, drawPosition + drawOffset, null, auraColor, aimAngle, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + } + + Main.EntitySpriteDraw(texture, drawPosition + new Vector2(-RecoilAmount,0).RotatedBy(Projectile.rotation), null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } + } +} diff --git a/Projectiles/Ranged/HalleysStarburst.cs b/Projectiles/Ranged/HalleysStarburst.cs new file mode 100644 index 0000000000..41e48151e3 --- /dev/null +++ b/Projectiles/Ranged/HalleysStarburst.cs @@ -0,0 +1,217 @@ +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class HalleysStarburst : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Particles/Sparkle"; + Color drawColor = Color.Black; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 6; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 20; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 24; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 6; + Projectile.timeLeft = 60 * Projectile.MaxUpdates; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.frame = Main.rand.Next(0, 6); + Projectile.scale = 0.75f; + Projectile.rotation += Main.rand.NextFloat(0, 3); + Projectile.stopsDealingDamageAfterPenetrateHits = true; + } + + public override void AI() + { + Projectile.rotation += Projectile.direction * 0.05f; + if (Projectile.FinalExtraUpdate()) + { + var star = new BloomParticle(Projectile.Center, Vector2.Zero, drawColor, 0.2f, 0.25f, 2, false); + var star2 = new CustomSpark(Projectile.Center, Vector2.UnitX.RotatedBy(Projectile.rotation) * 0.1f, Texture, false, 2, 1f, Color.White, Vector2.One); + GeneralParticleHandler.SpawnParticle(star); + GeneralParticleHandler.SpawnParticle(star2); + } + Projectile.frameCounter++; + if (Projectile.frameCounter > 5) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 5) + Projectile.frame = 0; + if (Projectile.timeLeft == 1) + { + + for (var i = 0; i < 5; i++) + GeneralParticleHandler.SpawnParticle(new GlowSparkParticle(Projectile.Center, Main.rand.NextVector2CircularEdge(10,10), false, 10, 0.02f, drawColor, new Vector2(0.5f, 1f))); + if (Projectile.damage != 0) + Main.player[Projectile.owner].Calamity().HalleyAccuracyCounter -= HalleysInferno.LostAccuracyPerMiss; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (drawColor == Color.Black) + { + switch (Projectile.ai[0]) + { + case 1: + drawColor = Color.HotPink; + break; + case 2: + drawColor = Color.Yellow; + break; + case 3: + drawColor = Color.LimeGreen; + break; + case 4: + drawColor = Color.SkyBlue; + break; + case 5: + drawColor = Color.Lavender; + break; + case 6: + drawColor = Color.White; + break; + } + } + + Main.spriteBatch.End(out var ss); + + var device = Main.instance.GraphicsDevice; + using var lease = RenderTargetPool.Shared.Rent( + device, + Main.screenWidth / 2, + Main.screenHeight / 2, + RenderTargetDescriptor.Default + ); + + using (lease.Scope(clearColor: Color.Transparent)) + { + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), Projectile.oldPos.Length + 32); + + Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), fireCoreLength.Length + 24); + } + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); + Main.spriteBatch.End(); + + Main.spriteBatch.Begin(ss); + lightColor = drawColor; + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 75); + SoundEngine.PlaySound(SoundID.DD2_CrystalCartImpact, Projectile.Center); + + // Dust emission on hit + for (int i = 0; i < 14; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 2.1f); + dust.noGravity = true; + } + var cplay = Main.player[Projectile.owner].Calamity(); + cplay.HalleyAccuracyCounter++; + cplay.HalleyAccuracyCounter = MathF.Min(HalleysInferno.MaxAccuracy, cplay.HalleyAccuracyCounter); + Main.player[Projectile.owner].Calamity().StarburstSpawnFrameCounter += cplay.HalleyAccuracyCounter / HalleysInferno.MaxAccuracy * HalleysInferno.MaxStarburstPerStar; + Projectile.velocity *= 0.25f; + Projectile.timeLeft = Projectile.MaxUpdates; + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(ModContent.BuffType(), 450); + SoundEngine.PlaySound(SoundID.DD2_CrystalCartImpact, Projectile.Center); + + // Dust emission on hit + for (int i = 0; i < 14; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 2.1f); + dust.noGravity = true; + } + } + + public float FireWidthFunction(float completion, Vector2 pos) + { + float width; + float maxBodyWidth = 38f * Projectile.scale; + float curveRatio = 0.2f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + // Crop the tip of the trail into a conic shape. + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireColorFunction(float completion, Vector2 pos) + { + Color mainColor = drawColor * 1.3f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; + } + + public float FireCoreWidthFunction(float completion, Vector2 pos) + { + float width; + float maxBodyWidth = Projectile.scale * 16; + float curveRatio = 0.25f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireCoreColorFunction(float completion, Vector2 pos) + { + Color mainColor = drawColor; + Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); + return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity; + } + } +} diff --git a/Projectiles/Ranged/HallowPointRoundProj.cs b/Projectiles/Ranged/HallowPointRoundProj.cs index 8d8ec76fec..02da6911c5 100644 --- a/Projectiles/Ranged/HallowPointRoundProj.cs +++ b/Projectiles/Ranged/HallowPointRoundProj.cs @@ -30,7 +30,6 @@ namespace CalamityMod.Projectiles.Ranged // Invisible for the first few frames Projectile.alpha = 255; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/HeavenlyGaleProj.cs b/Projectiles/Ranged/HeavenlyGaleProj.cs index a3bd608917..a62ef04abb 100644 --- a/Projectiles/Ranged/HeavenlyGaleProj.cs +++ b/Projectiles/Ranged/HeavenlyGaleProj.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -15,13 +14,13 @@ namespace CalamityMod.Projectiles.Ranged public class HeavenlyGaleProj : BaseIdleHoldoutProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public bool OwnerCanShoot => Owner.HasAmmo(Owner.ActiveItem()) && !Owner.noItems && !Owner.CCed; + public bool OwnerCanShoot => Owner.HasAmmo(Owner.HeldItem) && !Owner.noItems && !Owner.CCed; public float StringReelbackInterpolant { get { - int duration = Owner.ActiveItem().useAnimation; + int duration = Owner.HeldItem.useAnimation; float time = duration - ShootDelay; float firstHalf = Utils.GetLerpValue(8f, 0f, time, true); float secondHalf = Utils.GetLerpValue(8f, duration * 0.6f, time, true); @@ -65,12 +64,12 @@ namespace CalamityMod.Projectiles.Ranged if (Main.myPlayer == Projectile.owner && OwnerCanShoot && activatingShoot) { SoundEngine.PlaySound(HeavenlyGale.FireSound, Projectile.Center); - ShootDelay = Owner.ActiveItem().useAnimation; + ShootDelay = Owner.HeldItem.useAnimation; Projectile.netUpdate = true; } // Update damage based on current ranged damage stat, since this projectile exists regardless of if it's being fired. - Projectile.damage = Owner.ActiveItem() is null ? 0 : Owner.GetWeaponDamage(Owner.ActiveItem()); + Projectile.damage = Owner.HeldItem is null ? 0 : Owner.GetWeaponDamage(Owner.HeldItem); UpdateProjectileHeldVariables(armPosition); ManipulatePlayerVariables(); @@ -78,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged // Fire arrows. if (ShootDelay > 0f && Projectile.FinalExtraUpdate()) { - float shootCompletionRatio = 1f - ShootDelay / (Owner.ActiveItem().useAnimation - 1f); + float shootCompletionRatio = 1f - ShootDelay / (Owner.HeldItem.useAnimation - 1f); float bowAngularOffset = (float)Math.Sin(MathHelper.TwoPi * shootCompletionRatio) * 0.4f; float damageFactor = Utils.Remap(ChargeTimer, 0f, HeavenlyGale.MaxChargeTime, 1f, HeavenlyGale.MaxChargeDamageBoost); @@ -96,9 +95,9 @@ namespace CalamityMod.Projectiles.Ranged // Update the tip position for one frame. tipPosition = armPosition + arrowDirection * Projectile.width * 0.45f; - if (Main.myPlayer == Projectile.owner && Owner.HasAmmo(Owner.ActiveItem())) + if (Main.myPlayer == Projectile.owner && Owner.HasAmmo(Owner.HeldItem)) { - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; Owner.PickAmmo(heldItem, out int projectileType, out float shootSpeed, out int damage, out float knockback, out _); damage = (int)(damage * damageFactor); projectileType = ModContent.ProjectileType(); @@ -146,7 +145,7 @@ namespace CalamityMod.Projectiles.Ranged float unitOffsetY = (float)Math.Pow(Math.Sin(offsetAngle), 3D); Vector2 puffDustVelocity = new Vector2(unitOffsetX, unitOffsetY) * 5f; - Dust magic = Dust.NewDustPerfect(tipPosition, 267, puffDustVelocity); + Dust magic = Dust.NewDustPerfect(tipPosition, DustID.RainbowMk2, puffDustVelocity); magic.scale = 1.8f; magic.fadeIn = 0.5f; magic.color = CalamityUtils.MulticolorLerp(i / 75f, CalamityUtils.ExoPalette); diff --git a/Projectiles/Ranged/HellbornHoldout.cs b/Projectiles/Ranged/HellbornHoldout.cs index c37eb1104c..781335298d 100644 --- a/Projectiles/Ranged/HellbornHoldout.cs +++ b/Projectiles/Ranged/HellbornHoldout.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -12,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { + [PierceResistException] public class HellbornHoldout : BaseGunHoldoutProjectile { public override int AssociatedItemID => ModContent.ItemType(); @@ -32,6 +34,7 @@ namespace CalamityMod.Projectiles.Ranged public bool hasPlayedSound = false; public bool hasPlayedReloadSound = false; public float fade = 0; + public int hitTimer = 0; public override void SetStaticDefaults() { @@ -52,6 +55,9 @@ namespace CalamityMod.Projectiles.Ranged } public override void HoldoutAI() { + if (hitTimer > 0) + hitTimer--; + fade = Utils.GetLerpValue(0, 40, time, true); if (SoundEngine.TryGetActiveSound(SoundSlot, out var sSound) && sSound.IsPlaying) { @@ -105,7 +111,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 2; i++) { Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + drawRot * 0.25f + MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * 35f * fade; - Dust dust = Dust.NewDustPerfect(dustPos, 278, (i * MathHelper.Pi + (drawRot * Projectile.direction) * 0.25f * Math.Sign(Projectile.velocity.X)).ToRotationVector2().RotatedBy(MathHelper.ToRadians(180f) * (Projectile.direction == 1 ? 0 : 1)) * -3f * Main.rand.NextFloat(0.5f, 1f) * fade); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.FireworksRGB, (i * MathHelper.Pi + (drawRot * Projectile.direction) * 0.25f * Math.Sign(Projectile.velocity.X)).ToRotationVector2().RotatedBy(MathHelper.ToRadians(180f) * (Projectile.direction == 1 ? 0 : 1)) * -3f * Main.rand.NextFloat(0.5f, 1f) * fade); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.42f, 0.62f); dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); @@ -117,7 +123,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 3; i++) { Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + drawRot * 0.5f + MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * 87f * fade; - Dust dust = Dust.NewDustPerfect(dustPos, 267, (i * MathHelper.Pi + (drawRot * Projectile.direction) * 0.5f * Math.Sign(Projectile.velocity.X)).ToRotationVector2().RotatedBy(MathHelper.ToRadians(180f) * (Projectile.direction == 1 ? 0 : 1)) * -7f * Main.rand.NextFloat(0.5f, 1f) * fade); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.RainbowMk2, (i * MathHelper.Pi + (drawRot * Projectile.direction) * 0.5f * Math.Sign(Projectile.velocity.X)).ToRotationVector2().RotatedBy(MathHelper.ToRadians(180f) * (Projectile.direction == 1 ? 0 : 1)) * -7f * Main.rand.NextFloat(0.5f, 1f) * fade); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.62f, 0.82f); dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); @@ -129,7 +135,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Owner.Calamity().hellbornShots > 0) { - Owner.Calamity().GeneralScreenShakePower = 5f; + Owner.SetScreenshake(5f); OffsetLengthFromArm -= 35f; cooldownTimer = Owner.itemAnimationMax * 2; Owner.Calamity().hellbornShots--; @@ -140,16 +146,19 @@ namespace CalamityMod.Projectiles.Ranged Owner.velocity += shootVelocity * -0.68f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -shootVelocity.RotatedBy(0.75f * Projectile.direction) * 1f, ModContent.ProjectileType(), 0, 0, Projectile.owner); + if (Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -shootVelocity.RotatedBy(0.75f * Projectile.direction) * 1f, ModContent.ProjectileType(), 0, 0, Projectile.owner); + } for (int i = 0; i <= 13; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 1.5f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.SteampunkSteam, shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 1.5f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); dust.noGravity = false; dust.color = Color.White; - Dust dust2 = Dust.NewDustPerfect(GunTipPosition, 278, shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 1f)); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition, DustID.FireworksRGB, shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 1f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.52f, 0.72f); dust2.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); @@ -201,10 +210,18 @@ namespace CalamityMod.Projectiles.Ranged } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - modifiers.SourceDamage *= 0.1f; - if (Owner.Calamity().hellbornShots < 8) + if (hitTimer == 0) { - Owner.Calamity().hellbornShots++; + modifiers.SourceDamage *= 0.08f; + if (Owner.Calamity().hellbornShots < 12) + { + Owner.Calamity().hellbornShots++; + } + hitTimer = Projectile.localNPCHitCooldown; + } + else + { + modifiers.SourceDamage *= 0.02f; } } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/HellbornProj.cs b/Projectiles/Ranged/HellbornProj.cs index 357bbad717..90705bfdf2 100644 --- a/Projectiles/Ranged/HellbornProj.cs +++ b/Projectiles/Ranged/HellbornProj.cs @@ -1,9 +1,12 @@ using System; +using CalamityMod.Dusts; using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -26,7 +29,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Ranged; Projectile.extraUpdates = 2; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; } public override void AI() @@ -64,20 +68,34 @@ namespace CalamityMod.Projectiles.Ranged Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; if (Main.rand.NextBool(2)) { - Particle orb = new GlowOrbParticle(Projectile.Center + offset, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), Main.rand.NextBool() ? Color.Orange : Color.OrangeRed); - GeneralParticleHandler.SpawnParticle(orb); + //Particle orb = new GlowOrbParticle(Projectile.Center + offset, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), Main.rand.NextBool() ? Color.Orange : Color.OrangeRed); + //GeneralParticleHandler.SpawnParticle(orb); + + Dust dust5 = Dust.NewDustPerfect(Projectile.Center + offset, ModContent.DustType(), -Projectile.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(3f, 5f)); + dust5.noGravity = true; + dust5.scale = Main.rand.NextFloat(2.3f, 2.7f); + dust5.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + dust5.fadeIn = 2.5f; } if (Main.rand.NextBool(2)) { - Particle orb2 = new GlowOrbParticle(Projectile.Center - offset, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), Main.rand.NextBool() ? Color.Orange : Color.OrangeRed); - GeneralParticleHandler.SpawnParticle(orb2); + //Particle orb2 = new GlowOrbParticle(Projectile.Center - offset, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), Main.rand.NextBool() ? Color.Orange : Color.OrangeRed); + //GeneralParticleHandler.SpawnParticle(orb2); + + Dust dust5 = Dust.NewDustPerfect(Projectile.Center - offset, ModContent.DustType(), -Projectile.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(3f, 5f)); + dust5.noGravity = true; + dust5.scale = Main.rand.NextFloat(2.3f, 2.7f); + dust5.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + dust5.fadeIn = 2.5f; } } Vector2 dustPos = Projectile.Center + Main.rand.NextVector2Circular(30, 30); - Dust dust = Dust.NewDustPerfect(dustPos, 267, -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.4f)); + Dust dust = Dust.NewDustPerfect(dustPos, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.4f)); dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.72f, 1.12f); + dust.scale = Main.rand.NextFloat(0.62f, 0.82f); dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + dust.fadeIn = 1; + dust.noLight = true; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -86,15 +104,23 @@ namespace CalamityMod.Projectiles.Ranged // Launch Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center); target.MoveNPC(launchVel, 6, true); + + MakeBlast(target.whoAmI, true); } public override void OnKill(int timeLeft) { for (int l = 0; l < 17; l++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f)); dust.noGravity = false; dust.scale = Main.rand.NextFloat(0.62f, 0.82f); dust.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + + Dust dust5 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f)); + dust5.noGravity = true; + dust5.scale = Main.rand.NextFloat(2.1f, 2.4f); + dust5.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 1f)); + dust5.fadeIn = 1.7f; } Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed * 0.7f, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1.2f, 1.7f, 16, true); @@ -104,6 +130,30 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle bigShot = new("CalamityMod/Sounds/Item/HellbornImpact"); SoundEngine.PlaySound(bigShot with { PitchVariance = 0.15f, Volume = 0.8f }, Projectile.Center); + if (Projectile.numHits == 0) + { + MakeBlast(0, false); + } + } + public void MakeBlast(int target, bool hitTarget) + { + float blastSize = 70; + float minMultiplier = 0.25f; + int hitsToMinMult = 5; + int blastDamage = (int)(Projectile.damage * 0.33f); + if (hitTarget) + { + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), blastDamage, Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 2; + blast.DamageType = DamageClass.Ranged; + blast.localAI[0] = target; + } + else + { + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), blastDamage, Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 2; + blast.DamageType = DamageClass.Ranged; + } } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Ranged/HellbornShell.cs b/Projectiles/Ranged/HellbornShell.cs index 7647aaf586..dedb2d2d40 100644 --- a/Projectiles/Ranged/HellbornShell.cs +++ b/Projectiles/Ranged/HellbornShell.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -42,7 +43,7 @@ namespace CalamityMod.Projectiles.Ranged if (Main.rand.NextBool(4)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, 303, -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(0.2f, 1f), 180, default, Main.rand.NextFloat(0.4f, 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, DustID.SteampunkSteam, -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(0.2f, 1f), 180, default, Main.rand.NextFloat(0.4f, 1.3f)); dust.noGravity = false; dust.color = Color.White; } diff --git a/Projectiles/Ranged/HighExplosivePeanutShell.cs b/Projectiles/Ranged/HighExplosivePeanutShell.cs deleted file mode 100644 index cefe2998ce..0000000000 --- a/Projectiles/Ranged/HighExplosivePeanutShell.cs +++ /dev/null @@ -1,93 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class HighExplosivePeanutShell : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - private const int Lifetime = 180; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 9; - ProjectileID.Sets.TrailingMode[Type] = 1; - } - - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 16; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 4; - Projectile.timeLeft = Lifetime; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation(); - Projectile.spriteDirection = 1; - - // Lighting - Lighting.AddLight(Projectile.Center, 0.75f, 0.65f, 0.08f); - - // Dirty dust, done dirt cheap - { - int dustID = 7; // wood flakes - float scale = Main.rand.NextFloat(1f, 1.4f); - Dust d = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustID); - d.noGravity = true; - d.scale = scale; - - // Dust velocity is a complicated flaking function taken from Holy Fire Bullets - d.velocity *= 0.2f; - float angleDeviation = 0.17f; - float angle = Main.rand.NextFloat(-angleDeviation, angleDeviation); - Vector2 sprayVelocity = Projectile.velocity.RotatedBy(angle) * 0.6f; - d.velocity += sprayVelocity; - } - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override void OnKill(int timeLeft) - { - // Grenade Launcher + Lunar Flare sounds for maximum meaty explosion - SoundEngine.PlaySound(SoundID.Item62, Projectile.Center); - SoundEngine.PlaySound(SoundID.Item88, Projectile.Center); - - // Massively inflate the projectile's hitbox - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 140; - Projectile.position.X = Projectile.position.X - Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; - - // Allow infinite piercing and ignoring iframes for this one extra hit - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - - // Rocket III type explosion is now a utility for convenience - Projectile.LargeFieryExplosion(); - - // Deal damage again. The explosion deals half the damage of the direct hit. - Projectile.damage /= 2; - Projectile.Damage(); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); - return true; // the projectile does indeed die on collision - } - } -} diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index a660154ee0..a272cb7945 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -1,7 +1,5 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; -using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -83,7 +81,7 @@ namespace CalamityMod.Projectiles.Ranged if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 2.5f, 303, -Projectile.velocity.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 2.5f, DustID.SteampunkSteam, -Projectile.velocity.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = false; dust.color = Color.Black; dust.alpha = Main.rand.Next(90, 220 + 1); @@ -152,7 +150,7 @@ namespace CalamityMod.Projectiles.Ranged for (int k = 0; k < 15; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 303, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.SteampunkSteam, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); dust2.scale = Main.rand.NextFloat(0.75f, 0.95f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; diff --git a/Projectiles/Ranged/HiveNuke.cs b/Projectiles/Ranged/HiveNuke.cs index cbf2793e2f..4603c31b0b 100644 --- a/Projectiles/Ranged/HiveNuke.cs +++ b/Projectiles/Ranged/HiveNuke.cs @@ -1,8 +1,5 @@ -using System; -using System.Net.Sockets; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; -using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -136,7 +133,7 @@ namespace CalamityMod.Projectiles.Ranged Color smokeColor = Color.Lerp(Color.Black, Color.Lime, 0.25f); Particle smoke = new HeavySmokeParticle(Projectile.Center - Projectile.velocity * 2, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.6f), smokeColor * 0.65f, 9, Main.rand.NextFloat(0.45f, 0.6f), 0.23f, Main.rand.NextFloat(-0.2f, 0.2f), false); GeneralParticleHandler.SpawnParticle(smoke); - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 2.5f, 303, -Projectile.velocity.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.2f, 0.9f), 0, default, Main.rand.NextFloat(0.9f, 1.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10) - Projectile.velocity * 2.5f, DustID.SteampunkSteam, -Projectile.velocity.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.2f, 0.9f), 0, default, Main.rand.NextFloat(0.9f, 1.6f)); dust.noGravity = false; dust.color = Color.Black; dust.alpha = Main.rand.Next(90, 220 + 1); @@ -193,7 +190,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(fire with { Volume = 0.9f }, Projectile.Center); } - Owner.Calamity().GeneralScreenShakePower = 9.5f; + Owner.SetScreenshake(9.5f); var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID) { @@ -235,7 +232,7 @@ namespace CalamityMod.Projectiles.Ranged } else { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 303, new Vector2(35, 35).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.7f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.SteampunkSteam, new Vector2(35, 35).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.7f)); dust.noGravity = false; dust.color = Color.Black; dust.alpha = Main.rand.Next(90, 220 + 1); diff --git a/Projectiles/Ranged/HolyFireBulletProj.cs b/Projectiles/Ranged/HolyFireBulletProj.cs index 1a126bde6b..da00965d94 100644 --- a/Projectiles/Ranged/HolyFireBulletProj.cs +++ b/Projectiles/Ranged/HolyFireBulletProj.cs @@ -1,8 +1,12 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using CalamityMod.Items.Ammo; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,120 +17,163 @@ namespace CalamityMod.Projectiles.Ranged public class HolyFireBulletProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - private const int Lifetime = 600; - private static readonly Color Alpha = new Color(1f, 1f, 1f, 0f); - private bool ColorStyle = false; + public Color col = Color.White; private float SizeVariance; - private float SizeBonus = 2; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 5; - ProjectileID.Sets.TrailingMode[Type] = 2; - } + public ref float time => ref Projectile.ai[2]; + public ref float sizeBonus => ref Projectile.ai[1]; public override void SetDefaults() { - Projectile.width = 4; - Projectile.height = 4; + Projectile.width = 8; + Projectile.height = 8; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.MaxUpdates = 5; - Projectile.timeLeft = Lifetime; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + Projectile.penetrate = 1; + Projectile.extraUpdates = 7; + Projectile.timeLeft = 600; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - if (Projectile.localAI[0] == 0) + if (time == 0) { + Projectile.damage = (int)(Projectile.damage * 1.15f); + col = Main.rand.NextBool() ? Color.Orange : Color.Goldenrod; SizeVariance = Main.rand.NextFloat(0.95f, 1.05f); - ColorStyle = Main.rand.NextBool(); - Projectile.velocity *= 0.7f; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 14; } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(90f); Projectile.spriteDirection = Projectile.direction; - if (Projectile.localAI[0] >= 30 && SizeBonus > 1) - { - SizeBonus -= 0.02f; - } - // Flaking dust - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 4f) + + sizeBonus = MathHelper.Lerp(1, 2, (float)Math.Pow(Utils.GetLerpValue(50, 15, time, true), 2)); + if (time > 4) { + float sine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 15f / MathHelper.Pi); if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), Main.rand.NextBool() ? 262 : 87, -Projectile.velocity.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.01f, 0.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), ModContent.DustType(), -Projectile.velocity.RotatedBy(Main.rand.NextFloat(0.15f, 0.3f) * (Main.rand.NextBool() ? -1 : 1)) * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 0.85f); - dust.alpha = 235; + dust.noLightEmittence = true; + dust.color = col; } - if (Main.rand.NextBool(15)) + + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (time > 2 && targetDist < 1400) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, -Projectile.velocity.RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 0.4f)); - dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.4f, 0.7f); - dust.color = ColorStyle ? Color.Orange : Color.Khaki; + Particle trail = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 0.5f, "CalamityMod/Particles/DualTrail", false, 4, 0.03f, col * 0.9f, new Vector2(1f, 3), true, true, shrinkSpeed: 0.8f, glowOpacity: 0.6f); + GeneralParticleHandler.SpawnParticle(trail); } } + time++; } - - public override Color? GetAlpha(Color lightColor) => Alpha; - public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, ColorStyle ? Color.OrangeRed * 8 : Color.Khaki * 8); - return true; + if (time <= 0) + return false; + Asset tip = ModContent.Request("CalamityMod/Particles/SquareRotated"); + + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(tip.Value, Projectile.Center - Main.screenPosition, null, Color.Lerp(col, Color.White, i) with { A = 0 } * 0.7f, Projectile.rotation, tip.Size() / 2f, new Vector2(0.2f, 1.4f) * Projectile.scale * (0.28f - 0.1f * i), SpriteEffects.None, 0); + return false; } public override void OnKill(int timeLeft) { - // Spawn an on-hit explosion which deals 30% of the projectile's damage. - if (Projectile.owner == Main.myPlayer) + // Spawn an on-hit explosion which deals part of the projectile's damage to enemies around the target + if (Projectile.numHits == 0) { - Projectile.damage = (int)(Projectile.damage * HolyFireBullet.ExplosionMultiplier); - Projectile.penetrate = -1; - Projectile.ExpandHitboxBy((25 * SizeVariance) * SizeBonus); - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); - } - SoundEngine.PlaySound(HolyFireBullet.Explosion with { Pitch = -0.15f, Volume = 0.3f }, Projectile.Center); - - Vector2 Offset = Main.rand.NextVector2Circular(15, 15); - - Particle explosion = new DetailedExplosion(Projectile.Center + Offset, Vector2.Zero, (ColorStyle ? Color.Orange : Color.Khaki) * 0.9f, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, (0.28f * SizeVariance) * SizeBonus, 10); - GeneralParticleHandler.SpawnParticle(explosion); - - SparkleParticle impactParticle = new SparkleParticle(Projectile.Center + Offset, Vector2.Zero, Color.White, ColorStyle ? Color.Orange : Color.OrangeRed, 2.5f * (SizeBonus * 0.3f), 7, 0f, 2f); - GeneralParticleHandler.SpawnParticle(impactParticle); - - for (int k = 0; k < 9; k++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 262 : 87, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f)); - dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.7f, 1.25f); - dust.alpha = 235; - if (Main.rand.NextBool()) - { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 303, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f)); - dust2.noGravity = true; - dust2.scale = Main.rand.NextFloat(0.8f, 1.5f); - dust2.alpha = 70; - } - } - for (int k = 0; k < 3; k++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f) + new Vector2(0, -3)); - dust.noGravity = false; - dust.scale = Main.rand.NextFloat(0.85f, 1f); - dust.color = ColorStyle ? Color.Orange : Color.Khaki; + MakeBlast(0, false); } } + public void MakeBlast(int target, bool hitTarget) + { + float blastSize = 50 * sizeBonus; + float minMultiplier = 0.35f; + int hitsToMinMult = 8; + int blastDamage = (int)(Projectile.damage * 0.33f); + int knockback = -10; + int debuff = ModContent.BuffType(); + int debuffTime = 180; + if (hitTarget) + { + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), blastDamage, knockback, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 3; + blast.DamageType = Projectile.DamageType; + blast.localAI[0] = target; + blast.localAI[1] = debuff; + blast.localAI[2] = debuffTime; + } + else + { + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), blastDamage, knockback, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 3; + blast.DamageType = Projectile.DamageType; + blast.localAI[0] = debuff; + blast.localAI[1] = debuffTime; + } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + SoundEngine.PlaySound(HolyFireBullet.Explosion with { Pitch = -0.2f + 0.3f * sizeBonus, Volume = 0.3f + 0.1f * sizeBonus, MaxInstances = 10 }, Projectile.Center); + + float fxScale = MathHelper.Lerp(sizeBonus, 1, 0.25f); + Vector2 Offset = Main.rand.NextVector2Circular(15, 15); + + Particle blastvfx = new CustomPulse(Projectile.Center + Offset, Vector2.Zero, Color.Lerp(Color.SlateGray, col, 0.8f) * 0.9f, "CalamityMod/Particles/SmokeExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0.05f * fxScale, 0.1f * fxScale, Main.rand.Next(8, 10 + 1), true); + GeneralParticleHandler.SpawnParticle(blastvfx); + + float rot = Main.rand.NextFloat(-5, 5); + for (int i = -1; i <= 1; i += 2) + { + Particle centerShine = new CustomSpark(Projectile.Center + Offset, Vector2.UnitY.RotatedBy(rot + MathHelper.PiOver4 * i) * 0.01f, "CalamityMod/Particles/BloomCircle", false, 5, 0.3f * fxScale, Color.White, new Vector2(1f, 1f), true, false, shrinkSpeed: 2f); + GeneralParticleHandler.SpawnParticle(centerShine); + } + + for (int k = 0; k < 7; k++) + { + if (Main.rand.NextBool()) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Offset, ModContent.DustType(), new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f) * fxScale); + dust2.noGravity = true; + dust2.scale = Main.rand.NextFloat(0.4f, 0.6f) * fxScale; + dust2.alpha = Main.rand.Next(90, 180 + 1); + dust2.color = col; + dust2.fadeIn = 10f; + dust2.noLight = true; + dust2.noLightEmittence = true; + } + else + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Offset, ModContent.DustType(), new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f) * fxScale); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.5f, 1f) * fxScale; + dust.alpha = Main.rand.Next(160, 230 + 1); ; + dust.color = Color.White; + dust.noLight = true; + dust.noLightEmittence = true; + } + } + for (int k = 0; k < 2; k++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Offset, ModContent.DustType(), new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f) * fxScale + new Vector2(0, -5)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.75f, 0.95f) * fxScale; + dust.color = Main.rand.NextBool() ? Color.Orange : Color.Goldenrod; + dust.fadeIn = 1; + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { target.AddBuff(ModContent.BuffType(), 300); + MakeBlast(target.whoAmI, true); + if (sizeBonus == 2) // If you're at max damage get extra damage + { + SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Pitch = 0.3f, Volume = 0.4f, MaxInstances = 10 }, Projectile.Center); + } + // This used to be 25% was I fucking insane??? + modifiers.SourceDamage *= MathHelper.Lerp(1, 1.15f, sizeBonus - 1); // Up to 15% damage bonus } } } diff --git a/Projectiles/Ranged/HydraHead.cs b/Projectiles/Ranged/HydraHead.cs index f6439a1330..ae90151da0 100644 --- a/Projectiles/Ranged/HydraHead.cs +++ b/Projectiles/Ranged/HydraHead.cs @@ -7,6 +7,7 @@ using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -60,7 +61,7 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (Owner.dead || !Owner.active || Owner.ActiveItem().type != ModContent.ItemType()) + if (Owner.dead || !Owner.active || Owner.HeldItem.type != ModContent.ItemType()) Projectile.Kill(); else Projectile.timeLeft = 2; //Infinite lifespan @@ -137,7 +138,7 @@ namespace CalamityMod.Projectiles.Ranged public void PerformAttacks(Vector2 aimDestination) { - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; Vector2 shootDirection = Projectile.SafeDirectionTo(aimDestination); @@ -147,7 +148,7 @@ namespace CalamityMod.Projectiles.Ranged //Calculation for damage and co Owner.PickAmmo(heldItem, out _, out float itemVelocity, out int itemDamage, out float itemKB, out _); int type = ModContent.ProjectileType(); - for (int i = 0; i < 3; i++) + for (int i = 0; i < Hydra.BulletsPerShot - 1; i++) { Vector2 spreadDirection = shootDirection.RotatedByRandom(MathHelper.ToRadians(Hydra.ShotSpread / 2f)); float spreadVelocity = itemVelocity * Main.rand.NextFloat(1f, 1.4f); @@ -183,7 +184,7 @@ namespace CalamityMod.Projectiles.Ranged return; for (int i = 0; i < 10; i++) - Dust.NewDustPerfect(Projectile.Center, 171, Main.rand.NextVector2CircularEdge(4f, 4f)).noGravity = true; + Dust.NewDustPerfect(Projectile.Center, DustID.Venom, Main.rand.NextVector2CircularEdge(4f, 4f)).noGravity = true; } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/HydraHeadLaunch.cs b/Projectiles/Ranged/HydraHeadLaunch.cs index db6d8fc4aa..532d9309cf 100644 --- a/Projectiles/Ranged/HydraHeadLaunch.cs +++ b/Projectiles/Ranged/HydraHeadLaunch.cs @@ -3,6 +3,7 @@ using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -22,7 +23,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 3; Projectile.penetrate = 1; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } //Normal hitbox size for explosion, rotated otherwise @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 end = nextAngle.ToRotationVector2(); for (int j = 0; j < 30; j++) { - Dust starDust = Dust.NewDustPerfect(Projectile.Center, 267); + Dust starDust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); starDust.scale = 1.5f; starDust.velocity = Vector2.Lerp(start, end, j / 30f) * 12f; starDust.color = Color.Orchid; diff --git a/Projectiles/Ranged/HydrasBlood.cs b/Projectiles/Ranged/HydrasBlood.cs index ee78b8b6ae..c768f79f5d 100644 --- a/Projectiles/Ranged/HydrasBlood.cs +++ b/Projectiles/Ranged/HydrasBlood.cs @@ -25,7 +25,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 5; Projectile.penetrate = 1; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox); diff --git a/Projectiles/Ranged/HyperiusBulletProj.cs b/Projectiles/Ranged/HyperiusBulletProj.cs index 5bf58ceb15..89e23accd5 100644 --- a/Projectiles/Ranged/HyperiusBulletProj.cs +++ b/Projectiles/Ranged/HyperiusBulletProj.cs @@ -1,7 +1,10 @@ using System; using CalamityMod.Dusts; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -18,36 +21,37 @@ namespace CalamityMod.Projectiles.Ranged public bool dustWave = false; public float variance = 0.8f; public Vector2 lastPos; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 10; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - + public int slowdownTime = 7; + public bool tileTouched = false; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = 15; + Projectile.height = 15; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; + Projectile.penetrate = -1; Projectile.timeLeft = 1200; - Projectile.extraUpdates = 7; + Projectile.extraUpdates = 25; + Projectile.tileCollide = false; AIType = ProjectileID.Bullet; Projectile.ignoreWater = true; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - + float timeleftFade = (float)Math.Pow(Utils.GetLerpValue(0, slowdownTime * Projectile.extraUpdates, Projectile.timeLeft, true), 1); if (currentColor == Color.Black) { + slowdownTime = Main.rand.Next(6, 9 + 1); + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 20; variance = Main.rand.NextFloat(0.7f, 1f); - dustWave = Main.rand.NextBool(); + dustAngle = Main.rand.NextFloat(-0.43f, 0.43f); + dustWave = Math.Sign(dustAngle) == 1; Projectile.scale = 1.5f; Projectile.velocity *= 0.3f; lastPos = Projectile.velocity; @@ -80,85 +84,87 @@ namespace CalamityMod.Projectiles.Ranged } dustAngle += (growing ? 0.07f * variance : -0.07f * variance); - Projectile.localAI[0] += 1f; - Vector2 orbPos = Projectile.Center + (Projectile.velocity.RotatedBy((dustWave ? 1 : -1) * dustAngle) * 4.5f - Projectile.velocity * 5); - if (Projectile.localAI[0] > 12f && targetDist < 1200f) + if (Collision.SolidCollision(Projectile.Center, 4, 4) && !tileTouched && Projectile.numHits == 0) { - CustomSpark orb = new CustomSpark(orbPos, Utils.DirectionTo(lastPos, orbPos), "CalamityMod/Particles/BloomCircle", false, 5, (0.55f + MathF.Abs(dustAngle * 0.65f)) * 0.2f, currentColor, new Vector2(1 + MathF.Abs(dustAngle * 0.6f), 1), true, true, 0, false, false, 0.8f - MathF.Abs(dustAngle * 0.7f), 0.7f, 0.8f); + tileTouched = true; + OnHitEffects(null); + } + if (Projectile.numHits > 0 || tileTouched) + { + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5 * Math.Max(timeleftFade, 0.01f); + if (Projectile.timeLeft > slowdownTime * Projectile.extraUpdates) + Projectile.timeLeft = slowdownTime * Projectile.extraUpdates; + } + + Projectile.ai[2]++; + Vector2 orbPos = Projectile.Center + (Projectile.velocity.RotatedBy((dustWave ? 1 : -1) * dustAngle) * 4.5f - Projectile.velocity * 5); + if (Projectile.ai[2] > 15 && targetDist < 1200f) + { + CustomSpark orb = new CustomSpark(orbPos - Utils.DirectionTo(lastPos, orbPos) * timeleftFade, Utils.DirectionTo(lastPos, orbPos) * 0.1f, "CalamityMod/Particles/BloomCircle", false, 5, (0.55f + MathF.Abs(dustAngle * 0.65f)) * 0.15f * timeleftFade, currentColor, new Vector2(1 - MathF.Abs(dustAngle * 0.2f), 2 - (1 - MathF.Abs(dustAngle))), true, true, 0, false, false, 0.8f - MathF.Abs(dustAngle * 0.6f), 0.7f, 0.8f); GeneralParticleHandler.SpawnParticle(orb); - if (Main.rand.NextBool(7)) + if (Main.rand.NextBool(8)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.8f, 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), -Projectile.velocity.RotatedByRandom(0.15f) * Main.rand.NextFloat(0.9f, 1.8f)); dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.5f, 0.8f); + dust.scale = Main.rand.NextFloat(1.2f, 1.9f) * timeleftFade; dust.color = currentColor; dust.noLightEmittence = true; + dust.fadeIn = 1.4f; } } lastPos = orbPos; } - - // This projectile is always fullbright. - public override Color? GetAlpha(Color lightColor) + public override bool? CanHitNPC(NPC target) { - return currentColor; + return (Projectile.numHits > 0 ? false : null); } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + CalamityGlobalNPC modNPC = target.Calamity(); + if (!modNPC.hyperiusMarked) + modNPC.hyperiusMarked = true; + + Player Owner = Main.player[Projectile.owner]; + // Hits can crit and the collapse damage will take that into account + bool crit = Main.rand.Next(0, 100 + 1) < Owner.GetTotalCritChance(Projectile.DamageType); + modNPC.hyperiusDamage += Math.Max(Projectile.damage * (crit ? 2 : 1) - 1, 1); + + modifiers.DisableCrit(); + modifiers.SourceDamage *= 0; + modifiers.FinalDamage.Flat = 0.1f; + modifiers.HideCombatText(); + + OnHitEffects(target); + } + private void OnHitEffects(NPC target) + { + if (Projectile.owner == Main.myPlayer) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/ShadowboltWallHit") with { Volume = 0.25f, Pitch = Main.rand.NextFloat(0.6f, 1f), MaxInstances = -1 }, Projectile.Center); + for (int b = 0; b < 2; b++) + { + Vector2 velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7 * (tileTouched ? -1 : 1)).RotatedByRandom(0.5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * 0.7f, ModContent.ProjectileType(), (int)Math.Max(Projectile.originalDamage * 0.05f, 1), 0, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); + } + } + } public override bool PreDraw(ref Color lightColor) { - if (Projectile.localAI[0] > 25f) + Asset orb = ModContent.Request("CalamityMod/Particles/GlowSpark"); + int startTime = 9; + int endTime = 35; + float timeleftFade = (float)Math.Pow(Utils.GetLerpValue(0, slowdownTime * Projectile.extraUpdates, Projectile.timeLeft, true), 1); + + for (int i = 0; i < 4; i++) { - CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor); + Vector2 squash = new Vector2(Utils.Remap(Projectile.ai[2], startTime, endTime, 0.2f, 0.6f + i * 0.2f), Utils.Remap(Projectile.ai[2], startTime, endTime, 1f, 3f - i * 0.4f)); + Color orbColor = Color.Lerp(currentColor, Color.White, i * 0.2f) with { A = 0 } * 0.9f; + Vector2 scale = Projectile.scale * timeleftFade * squash * (0.05f - i * 0.008f) * 0.3f; + Main.EntitySpriteDraw(orb.Value, Projectile.Center - Main.screenPosition + Projectile.velocity * i * 1.3f, null, orbColor, Projectile.rotation, orb.Size() * 0.5f, scale, SpriteEffects.None); } return false; } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (Projectile.owner == Main.myPlayer) - { - for (int b = 0; b < 3; b++) - { - Vector2 vel = (-oldVelocity.SafeNormalize(Vector2.UnitX) * 5); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel.RotatedByRandom(0.5f) * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); - } - } - return true; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - OnHitEffects(target.Center); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - OnHitEffects(target.Center); - } - - private void OnHitEffects(Vector2 targetPos) - { - if (Projectile.owner == Main.myPlayer) - { - for (int b = 0; b < 3; b++) - { - Vector2 velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5).RotatedByRandom(0.5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), Projectile.knockBack * 2f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); - } - } - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/ShadowboltWallHit") with { Volume = 0.25f, Pitch = Main.rand.NextFloat(0.6f, 1f), MaxInstances = -1 }, Projectile.Center); - for (int b = 0; b < 4; b++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f)); - dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.7f, 1.4f); - dust.color = currentColor; - dust.noLightEmittence = true; - } - } } } diff --git a/Projectiles/Ranged/HyperiusSplit.cs b/Projectiles/Ranged/HyperiusSplit.cs index a6605021e9..b1bd44c5b8 100644 --- a/Projectiles/Ranged/HyperiusSplit.cs +++ b/Projectiles/Ranged/HyperiusSplit.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Ammo; +using System; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -16,11 +17,7 @@ namespace CalamityMod.Projectiles.Ranged private int rotDirection = 1; private float rotIntensity; private bool rotPhase2 = false; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 20; - ProjectileID.Sets.TrailingMode[Type] = 2; - } + public bool photosen = CalamityClientConfig.Instance.Photosensitivity; public override void SetDefaults() { Projectile.width = 12; @@ -29,11 +26,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.tileCollide = false; - Projectile.penetrate = 2; + Projectile.penetrate = 4; Projectile.timeLeft = 500; Projectile.extraUpdates = 4; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10 * Projectile.extraUpdates; + Projectile.localNPCHitCooldown = -1; Projectile.alpha = 255; Projectile.ignoreWater = true; AIType = ProjectileID.Bullet; @@ -42,65 +39,83 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { Projectile.localAI[0]++; + int trailLifetime = 8; if (currentColor == Color.Black) { + Player Owner = Main.player[Projectile.owner]; + Projectile.scale = 0.015f; Projectile.alpha = 255; rotDirection = Main.rand.NextBool() ? 1 : -1; - rotIntensity = Main.rand.NextFloat(0.5f, 1.5f); + rotIntensity = Main.rand.NextFloat(0.3f, 1.1f); Projectile.timeLeft = Main.rand.Next(250, 300 + 1); switch (Projectile.ai[2]) { case 4: // Yellow shot - currentColor = Color.Yellow * 0.65f; + currentColor = Color.Yellow; break; case 3: // Magenta shot - currentColor = Color.Magenta * 0.65f; + currentColor = Color.Magenta; break; case 2: // Red shot - currentColor = Color.Red * 0.65f; + currentColor = Color.Red; break; case 1: // Blue shot - currentColor = Color.Cyan * 0.65f; + currentColor = Color.Cyan; break; default: // Green shot - currentColor = Color.Lime * 0.65f; + currentColor = Color.Lime; break; } } + if (Projectile.localAI[0] > 4 && Projectile.localAI[0] % 2 == 0 && !photosen) + { + Particle trail = new CustomSpark(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9, -Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomCircle", false, trailLifetime, 0.15f, currentColor, new Vector2(0.8f, 1.3f), true, true, shrinkSpeed: 0.6f / rotIntensity, glowCenterScale: 0.8f, glowOpacity: 0.7f); + GeneralParticleHandler.SpawnParticle(trail); + } + if (Projectile.timeLeft == 180) rotPhase2 = true; if (rotPhase2) { - rotIntensity *= 1.001f; - Projectile.velocity *= 0.997f; - Projectile.velocity = Projectile.velocity.RotatedBy(-0.025f * rotIntensity * rotDirection); + rotIntensity *= 1.003f; + Projectile.velocity *= 0.995f; + Projectile.velocity = Projectile.velocity.RotatedBy(-0.04f * rotIntensity * rotDirection); } else { - Projectile.velocity = Projectile.velocity.RotatedBy(0.015f * rotIntensity * rotDirection); + Projectile.velocity = Projectile.velocity.RotatedBy(0.02f * rotIntensity * rotDirection); } } public override void OnKill(int timeLeft) { - for (int b = 0; b < 2; b++) - { - GlowOrbParticle orb = new GlowOrbParticle(Projectile.Center, new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f), false, 5, Main.rand.NextFloat(0.35f, 0.45f), currentColor, true, true); - GeneralParticleHandler.SpawnParticle(orb); - } + } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 12, targetHitbox); public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.Lerp(currentColor, Color.White, 0.15f) with { A = 0 }, 1, texture, true, true); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, currentColor with { A = 0 } * (photosen ? 0.4f : 1), Projectile.rotation, texture.Size() * 0.5f, new Vector2(0.9f, 1.5f) * Projectile.scale, SpriteEffects.None); return false; } - public override bool? CanDamage() => Projectile.localAI[0] < 20 ? false : null; + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + CalamityGlobalNPC modNPC = target.Calamity(); - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage.Flat += HyperiusBullet.SplitBulletBonusDamage; + if (!modNPC.hyperiusMarked) + modNPC.hyperiusMarked = true; + + Player Owner = Main.player[Projectile.owner]; + // Hits can crit and the collapse damage will take that into account + bool crit = Main.rand.Next(0, 100 + 1) < Owner.GetTotalCritChance(Projectile.DamageType); + modNPC.hyperiusDamage += Math.Max(Projectile.damage * (crit ? 2 : 1) - 1, 1); + + modifiers.DisableCrit(); + modifiers.SourceDamage *= 0; + modifiers.FinalDamage.Flat = 0.1f; + modifiers.HideCombatText(); + } } } diff --git a/Projectiles/Ranged/IcicleArrowProj.cs b/Projectiles/Ranged/IcicleArrowProj.cs index c67551d894..bb2953d0f9 100644 --- a/Projectiles/Ranged/IcicleArrowProj.cs +++ b/Projectiles/Ranged/IcicleArrowProj.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 1000; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -118,9 +117,6 @@ namespace CalamityMod.Projectiles.Ranged } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (falling) - modifiers.SourceDamage *= 1.1f; - if (Projectile.numHits > 1 && falling) Projectile.damage = (int)(Projectile.damage * 0.5f); if (Projectile.damage < 1) diff --git a/Projectiles/Ranged/ImpactRound.cs b/Projectiles/Ranged/ImpactRound.cs index 9dae2a8086..bd6a72442c 100644 --- a/Projectiles/Ranged/ImpactRound.cs +++ b/Projectiles/Ranged/ImpactRound.cs @@ -32,7 +32,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = Lifetime; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/KarasawaShot.cs b/Projectiles/Ranged/KarasawaShot.cs index 68a689ae84..cc46428e1d 100644 --- a/Projectiles/Ranged/KarasawaShot.cs +++ b/Projectiles/Ranged/KarasawaShot.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Ranged/KingsbaneHoldout.cs b/Projectiles/Ranged/KingsbaneHoldout.cs index 9dd0bb0edc..23ea0c60bb 100644 --- a/Projectiles/Ranged/KingsbaneHoldout.cs +++ b/Projectiles/Ranged/KingsbaneHoldout.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15; int bulletAMMO = ProjectileID.Bullet; - Owner.PickAmmo(Owner.ActiveItem(), out bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out int _); + Owner.PickAmmo(Owner.HeldItem, 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() || discharging) @@ -89,16 +89,16 @@ namespace CalamityMod.Projectiles.Ranged if (fullRev && fullRevShots > 0) { Projectile.timeLeft = 2; - Dust dust2 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 68, 87, Projectile.velocity.RotatedBy((8.6f * Main.rand.NextFloat(0.975f, 1.025f)) * -Projectile.direction) * Main.rand.NextFloat(5.5f, 7f) + Owner.velocity * 0.5f); + Dust dust2 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 68, DustID.GemTopaz, Projectile.velocity.RotatedBy((8.6f * Main.rand.NextFloat(0.975f, 1.025f)) * -Projectile.direction) * Main.rand.NextFloat(5.5f, 7f) + Owner.velocity * 0.5f); dust2.noGravity = false; dust2.scale = Main.rand.NextFloat(0.8f, 0.9f); Dust dust3 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 5, Main.rand.NextBool(4) ? 169 : 162, (Projectile.velocity * Main.rand.NextFloat(4f, 15.5f)).RotatedByRandom(0.3f)); dust3.noGravity = true; dust3.scale = Main.rand.NextFloat(1.3f, 2.2f); - Owner.Calamity().GeneralScreenShakePower = 1.85f; + Owner.SetScreenshake(1.85f); //recoil 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); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition + Projectile.velocity * 5 + Main.rand.NextVector2Circular(7, 7), shootVelocity.RotatedByRandom(MathHelper.ToRadians(4f)), ModContent.ProjectileType(), (int)(Projectile.damage), Projectile.knockBack, Projectile.owner); SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotSmall"); if (fullRevShots % 2 == 0) SoundEngine.PlaySound(fire with { Volume = 0.7f }, Projectile.Center); @@ -122,7 +122,7 @@ namespace CalamityMod.Projectiles.Ranged fullRev = true; if (framesBetweenShots == 0) { - Dust dust2 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 68, 87, Projectile.velocity.RotatedBy((8.6f * Main.rand.NextFloat(0.985f, 1.015f)) * -Projectile.direction) * Main.rand.NextFloat(4, 5) + Owner.velocity * 0.5f); + Dust dust2 = Dust.NewDustPerfect(tipPosition - Projectile.velocity * 68, DustID.GemTopaz, Projectile.velocity.RotatedBy((8.6f * Main.rand.NextFloat(0.985f, 1.015f)) * -Projectile.direction) * Main.rand.NextFloat(4, 5) + Owner.velocity * 0.5f); dust2.noGravity = false; dust2.scale = Main.rand.NextFloat(0.8f, 0.9f); for (int i = 0; i <= 2; i++) @@ -153,7 +153,7 @@ namespace CalamityMod.Projectiles.Ranged 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), 0.185f).SafeNormalize(Vector2.UnitY); + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), (discharging ? 0.2f : 0.45f)).SafeNormalize(Vector2.UnitY); if (Projectile.velocity != oldVelocity) Projectile.ForceNetUpdate(); } diff --git a/Projectiles/Ranged/LeafArrow.cs b/Projectiles/Ranged/LeafArrow.cs index e5fb34f26e..bcdcdf3975 100644 --- a/Projectiles/Ranged/LeafArrow.cs +++ b/Projectiles/Ranged/LeafArrow.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -26,7 +25,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 1; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/LeviatitanAberration.cs b/Projectiles/Ranged/LeviatitanAberration.cs index 2d8f5fdeef..24bfa06ff0 100644 --- a/Projectiles/Ranged/LeviatitanAberration.cs +++ b/Projectiles/Ranged/LeviatitanAberration.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using CalamityMod.Particles; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Ranged/LeviatitanMeteor.cs b/Projectiles/Ranged/LeviatitanMeteor.cs index 76d7062dc8..d9956c8648 100644 --- a/Projectiles/Ranged/LeviatitanMeteor.cs +++ b/Projectiles/Ranged/LeviatitanMeteor.cs @@ -1,19 +1,17 @@ -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Particles; using Terraria.DataStructures; -using System; namespace CalamityMod.Projectiles.Ranged { public class LeviatitanMeteor : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/Melee/AftershockRock"; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 5; diff --git a/Projectiles/Melee/AftershockRock.png b/Projectiles/Ranged/LeviatitanMeteor.png similarity index 100% rename from Projectiles/Melee/AftershockRock.png rename to Projectiles/Ranged/LeviatitanMeteor.png diff --git a/Projectiles/Ranged/LunarBolt.cs b/Projectiles/Ranged/LunarBolt.cs index b7fa456499..b5883c7d61 100644 --- a/Projectiles/Ranged/LunarBolt.cs +++ b/Projectiles/Ranged/LunarBolt.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.extraUpdates = 1; Projectile.timeLeft = 180; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/LuxorsGiftRanged.cs b/Projectiles/Ranged/LuxorsGiftRanged.cs index 7bcf579a96..a19a9fa41c 100644 --- a/Projectiles/Ranged/LuxorsGiftRanged.cs +++ b/Projectiles/Ranged/LuxorsGiftRanged.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/M1GarandBulletCasing.cs b/Projectiles/Ranged/M1GarandBulletCasing.cs new file mode 100644 index 0000000000..0e92f629b2 --- /dev/null +++ b/Projectiles/Ranged/M1GarandBulletCasing.cs @@ -0,0 +1,67 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class M1GarandBulletCasing : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/M1GarandBulletCasing"; + public int Time = 0; + public bool TouchedGrass = false; + + public override void SetDefaults() + { + Projectile.width = 6; + Projectile.height = 12; + Projectile.friendly = true; + Projectile.ignoreWater = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.timeLeft = 300; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Projectile.scale = 1f; + Projectile.extraUpdates = 1; + Time++; + Player Owner = Main.player[Projectile.owner]; + if (!TouchedGrass) + { + if (Projectile.timeLeft <= 240) + Projectile.rotation += 0.04f * Projectile.direction; + else + Projectile.rotation = (new Vector2(0, -5 * Projectile.direction) + Projectile.velocity * -1.2f).ToRotation(); + + Projectile.velocity.Y += 0.087f; + Projectile.velocity.X *= 0.99f; + + if (Main.rand.NextBool(3)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, DustID.SteampunkSteam, -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(0.2f, 1f), 140, default, Main.rand.NextFloat(0.35f, 0.5f)); + dust.noGravity = false; + dust.color = Color.White; + } + } + else + { + Projectile.velocity = Vector2.Zero; + } + Projectile.alpha = (int)(255 * Utils.GetLerpValue(60, 0, Projectile.timeLeft, true)); + if (Collision.SolidCollision(Projectile.Center - Projectile.velocity * 1.5f, 2, 2)) + Projectile.tileCollide = true; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.damage = 0; + TouchedGrass = true; + Projectile.velocity = Vector2.Zero; + return false; + } + } +} diff --git a/Projectiles/Ranged/M1GarandBulletCasing.png b/Projectiles/Ranged/M1GarandBulletCasing.png new file mode 100644 index 0000000000..2e3aeeab4f Binary files /dev/null and b/Projectiles/Ranged/M1GarandBulletCasing.png differ diff --git a/Projectiles/Ranged/M1GarandEmptyClip.cs b/Projectiles/Ranged/M1GarandEmptyClip.cs new file mode 100644 index 0000000000..ea2854972c --- /dev/null +++ b/Projectiles/Ranged/M1GarandEmptyClip.cs @@ -0,0 +1,149 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class M1GarandEmptyClip : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + internal static readonly SoundStyle BlingSound = new("CalamityMod/Sounds/Custom/Ultrabling") { PitchVariance = 0.5f }; + internal static readonly SoundStyle BlingHitSound = new("CalamityMod/Sounds/Custom/UltrablingHit") { PitchVariance = 0.5f }; + private static Asset sheenAsset; + private static Asset bloomAsset; + + public static float UsedCoinGrabRangeMultiplier = 5f; + public static float ClipTossForce = 7.33f; + public float midAirRot = 0f; + + public static float MaxIntraClipRicoshotDistance = 1000f; + + public static readonly float RicoshotSearchDistance = 2000f; + + public static float SuperpredictionRatio = 0.1f; + + public static float ClipBonus = 2.5f; + public static float ClipMulticlipBonus = 0.9f; // lmar + + internal static readonly int UpdateCount = 4; + internal static readonly int ClipLifetime = UpdateCount * CalamityUtils.SecondsToFrames(7); + + // Clips fade out for the last 30 frames of their existence. + private static readonly int FadeoutTime = UpdateCount * 30; + private static readonly float ForceFadeDistance = 2000f; + public static int CritDelayFrames = 22; + internal static int CritDelayTime => UpdateCount * CritDelayFrames; + internal ref float ShotFreezeTimer => ref Projectile.ai[1]; + internal static int RicochetPause = UpdateCount * 22; + public bool HasBeenShot => Projectile.localAI[0] > 0f; + + public Player Owner => Main.player[Projectile.owner]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 60; + ProjectileID.Sets.TrailingMode[Type] = 0; + Main.projFrames[Type] = 1; + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 12; + Projectile.height = 14; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Ranged; + Projectile.MaxUpdates = UpdateCount; + Projectile.timeLeft = ClipLifetime; + // Draws very small otherwise + Projectile.scale = 1.5f; + } + + public override bool? CanDamage() => false; + + public override bool ShouldUpdatePosition() => ShotFreezeTimer <= 0; + + public override void AI() + { + if (ShotFreezeTimer > 0f) + { + --ShotFreezeTimer; + if (ShotFreezeTimer <= 0) + { + Projectile.Kill(); + return; + } + } + + Lighting.AddLight(Projectile.Center, Color.LightGray.ToVector3() * 0.2f); + + if (Main.rand.NextBool(10)) + { + Dust d = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke); + d.noGravity = true; + } + + + midAirRot += 0.05f; + Projectile.rotation = Projectile.velocity.X * 0.5f + midAirRot; + + if (Projectile.FinalExtraUpdate()) + { + float clipGravity = Player.defaultGravity / Projectile.MaxUpdates; + Projectile.velocity.Y += clipGravity / 1.75f; + } + + if (Projectile.timeLeft > FadeoutTime && Projectile.Center.Distance(Owner.MountedCenter) > ForceFadeDistance) + Projectile.timeLeft = FadeoutTime; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); + return base.OnTileCollide(oldVelocity); + } + // Pretty much all from ricoshot coins from here. + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Rectangle frame = tex.Frame(1, 1); + float fadingOpacity = Math.Clamp(Projectile.timeLeft / (float)FadeoutTime, 0f, 1f); + Color alphaColor = Projectile.GetAlpha(lightColor) * fadingOpacity; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, alphaColor, Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + + int numUpdatesPassed = ClipLifetime - Projectile.timeLeft; + float x = Math.Clamp((float)numUpdatesPassed / CritDelayTime, 0f, 2f); + float sheenFunction = Math.Min(MathF.Pow(x + 0.1f, 10f), MathF.Pow(x - 2.1f, 10f)); + float sheenOpacity = Math.Clamp(sheenFunction, 0f, 2f); + + if (sheenOpacity > 0f) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + sheenAsset ??= ModContent.Request("CalamityMod/Particles/HalfStar"); + Texture2D shineTex = sheenAsset.Value; + + bloomAsset ??= ModContent.Request("CalamityMod/Particles/BloomCircle"); + Texture2D bloomTex = bloomAsset.Value; + + Vector2 shineScale = new Vector2(1f, 3f - sheenOpacity * 2f); + Color shineColor = Color.LightGray; + + Main.EntitySpriteDraw(bloomTex, Projectile.Center - Main.screenPosition, null, shineColor * sheenOpacity * 0.3f, MathHelper.PiOver2, bloomTex.Size() / 2f, shineScale * Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(shineTex, Projectile.Center - Main.screenPosition, null, shineColor * sheenOpacity, MathHelper.PiOver2, shineTex.Size() / 2f, shineScale * Projectile.scale, SpriteEffects.None, 0); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/M1GarandEmptyClip.png b/Projectiles/Ranged/M1GarandEmptyClip.png new file mode 100644 index 0000000000..c08f6def56 Binary files /dev/null and b/Projectiles/Ranged/M1GarandEmptyClip.png differ diff --git a/Projectiles/Ranged/M1GarandHoldout.cs b/Projectiles/Ranged/M1GarandHoldout.cs new file mode 100644 index 0000000000..7a606842e0 --- /dev/null +++ b/Projectiles/Ranged/M1GarandHoldout.cs @@ -0,0 +1,415 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ModLoader; +using System; +using ReLogic.Utilities; + +namespace CalamityMod.Projectiles.Ranged +{ + public class M1GarandHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + + public ref float CurrentState => ref Projectile.ai[0]; + public ref float reloadTimeLeft => ref Projectile.ai[1]; + public ref float globalTimer => ref Projectile.ai[2]; + + private float muzzleFlashTimer; + private float flashVariant; + + private int pingAnimationTimer = 0; + private const int PingAnimationDuration = 120; + private bool shouldPing = false; + + public override float RecoilResolveSpeed => 0.13f; + public override float MaxOffsetLengthFromArm => 28f; + public override float BaseOffsetY => -4f; + public override float OffsetXUpwards => -6f; + public override float OffsetXDownwards => 0f; + public override float OffsetYUpwards => 0f; + public override float OffsetYDownwards => 0f; + + public override Vector2 GunTipPosition => (Projectile.Center + new Vector2(1.5f, -2.5f)) + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.425f; + public override string Texture => "CalamityMod/Projectiles/Ranged/M1GarandHoldout"; + + // Muzzle flash textures + public static Asset MuzzleFlash; + public static Asset HoldoutGlow; + + public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/WulfrumBlunderbussFire") { PitchVariance = 0.1f }; + public static readonly SoundStyle PingSound = new("CalamityMod/Sounds/Item/M1GarandPing"); + public static readonly SoundStyle ReloadSound = new("CalamityMod/Sounds/Item/M1GarandReload"); + private SlotId reloadSoundSlot; + + public override void Load() + { + MuzzleFlash = ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandMuzzleFlash", AssetRequestMode.ImmediateLoad); + HoldoutGlow = ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandHoldoutGlow", AssetRequestMode.ImmediateLoad); + } + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 6; + Projectile.frame = Main.projFrames[Type] - 1; + + } + public override void KillHoldoutLogic() + { + // Only allow the projectile to kill if we're not reloading + if (CurrentState == 0 && HeldItem.type != Owner.HeldItem.type) + { + Projectile.Kill(); + Projectile.netUpdate = true; + } + } + + public override void HoldoutAI() + { + globalTimer++; + + // Decrements the timer which controls the duration of the flash + if (muzzleFlashTimer > 0f) + muzzleFlashTimer -= 1f; + + if (shouldPing) + pingAnimationTimer += 3; + + hereInstead: // Code reads from back here after getting the 'goto' set down below + switch (CurrentState) + { + // Normal Firing State + case 0: + // Time between firing (as the player continues to hold) + if (Projectile.frame == 5) + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= MathHelper.Clamp(Owner.HeldItem.useAnimation - 18, 0f, Owner.HeldItem.useAnimation)) + { + if (Owner.CantUseHoldout()) + { + Projectile.Kill(); + return; + } + + if (Owner.Calamity().garandShots != 0) + Projectile.frame = 0; + else + { + CurrentState = 1; // Begin reloading + reloadTimeLeft = 120; + goto hereInstead; + } + + Projectile.frameCounter = 0; + } + } + // Begin firing + else if (Projectile.frame == 0) + { + if (Owner.Calamity().garandShots == 0 && globalTimer < 3) + { + CurrentState = 1; // Begin reloading + reloadTimeLeft = 120; + goto hereInstead; + } + + if (Projectile.frameCounter != 1) + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + return; + } + + Projectile.frameCounter++; + + // Check if the player has any shots left + if (Owner.Calamity().garandShots > 0) + { + // -- Firing Logic & FX -- + muzzleFlashTimer = 2f; + flashVariant = Main.rand.Next(3); + SoundEngine.PlaySound(FireSound, GunTipPosition); + + if (Owner.Calamity().garandShots == 1) + { + SoundEngine.PlaySound(PingSound, GunTipPosition); + shouldPing = true; + } + + OffsetLengthFromArm -= 3.5f; + + // Consume a shot + Owner.Calamity().garandShots--; + + Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * HeldItem.shootSpeed; + + if (Main.myPlayer == Projectile.owner) + { + // Eject bullet casing + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity.RotatedBy(Main.rand.NextFloat(2.5f, 2.65f) * -Projectile.direction) * 0.5f, ModContent.ProjectileType(), 0, 0, Projectile.owner); + + if (Owner.Calamity().garandShots == 0) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity.RotatedBy(Main.rand.NextFloat(1.175f, 1.25f) * -Projectile.direction) * 0.285f, ModContent.ProjectileType(), 0, 0, Projectile.owner); + + GenericSparkle sparker = new GenericSparkle(Projectile.Center, Vector2.Zero, Color.PaleGoldenrod, Color.Gold * 0.25f, 1.25f, 5, Projectile.velocity.ToRotation() + Main.rand.NextFloat(-0.15f, 0.15f), 1f); + GeneralParticleHandler.SpawnParticle(sparker); + } + } + + // Direct smoke + for (int i = 0; i < 8; i++) + { + Particle smoke = new HeavySmokeParticle(GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * 7f * Main.rand.NextFloat(0.4f, 1.5f), Color.Gray, Main.rand.Next(30, 50), Main.rand.NextFloat(0.22f, 0.44f), 0.35f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + } + + // "Smoke" ring + Particle shootPulse = new DirectionalPulseRing(GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * 4f, Color.Gray * 0.5f, new Vector2(0.5f, 1f), Projectile.velocity.ToRotation(), 0.1f, 0.475f, 18); + GeneralParticleHandler.SpawnParticle(shootPulse); + + // Shot starts from slightly behind the tip + if (Main.myPlayer == Projectile.owner) + { + Vector2 offsetPos = GunTipPosition - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 18f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), offsetPos, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + } + } + // The firing animation + else if (Projectile.frame > 0) + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frame++; + Projectile.frameCounter = 0; + + } + } + break; + + // Reloading + case 1: + reloadTimeLeft--; + + // Keep the player from switching weapons + Owner.channel = true; + + // The gun points slightly downwards during the first part + if (reloadTimeLeft <= 120 && reloadTimeLeft > 75) + { + Projectile.rotation += 0.15f * Projectile.spriteDirection; + } + // Lerp back to the normal pos + else if (reloadTimeLeft < 75 && reloadTimeLeft >= 64) + { + float progress = (75f - reloadTimeLeft) / (75f - 64f); + float lerpedOffset = MathHelper.Lerp(0.15f, 0f, progress); + Projectile.rotation += lerpedOffset * Projectile.spriteDirection; + } + else if (reloadTimeLeft == 39) + { + OffsetLengthFromArm -= 2f; + } + + // Hold frame 3 until this point + if (reloadTimeLeft > 40) + { + Projectile.frame = 3; + Projectile.frameCounter = 0; + } + + else if (Projectile.frame < Main.projFrames[Type] - 1) + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + } + + else + { + // Hold + Projectile.frame = Main.projFrames[Type] - 1; + } + + if (reloadTimeLeft == 110) + { + reloadSoundSlot = SoundEngine.PlaySound(ReloadSound, Projectile.Center); + } + + if (SoundEngine.TryGetActiveSound(reloadSoundSlot, out var sound) && sound.IsPlaying) + { + // Update the sound's position to the current projectile center + sound.Position = Projectile.Center; + } + + // Reload and cull the projectile + if (reloadTimeLeft <= 0) + { + // Stop when sound is complete + if (SoundEngine.TryGetActiveSound(reloadSoundSlot, out var soundToStop) && soundToStop.IsPlaying) + { + soundToStop.Stop(); + } + + Owner.Calamity().garandShots += 8; + globalTimer = 0; + Projectile.Kill(); + Projectile.netUpdate = true; + } + + break; + } + } + + // Can damage when firing. + public override bool? CanDamage() => muzzleFlashTimer > 0f; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(GunTipPosition + Vector2.UnitX.RotatedBy(Projectile.rotation) * MuzzleFlash.Width() * 0.5f, 64f, targetHitbox); + + public override bool PreDraw(ref Color lightColor) + { + // This class doesn't draw correctly on the first 2 frames. + if (globalTimer < 3) + return false; + + int chosenFrame = Math.Clamp(Projectile.frame, 0, Main.projFrames[Type] - 1); + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: chosenFrame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + float scale = Projectile.scale * Owner.gravDir; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if ((CurrentState != 1 && Owner.Calamity().garandShots == 0 && Projectile.frame >= 3)) // After firing the last shot, hold frame 3 after it increments to it to match the start of the reload animation + frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: 3); + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, frame.Size() * 0.5f, scale, flipSprite); + + // Flash + if (muzzleFlashTimer > 0f) + { + Texture2D flashTex = MuzzleFlash.Value; + int flashFrameY = (int)flashVariant; + Vector2 flashPos = GunTipPosition + Vector2.UnitX.RotatedBy(Projectile.rotation) * MuzzleFlash.Width() * 0.5f - Main.screenPosition; + Rectangle flashFrame = flashTex.Frame(verticalFrames: 3, frameY: flashFrameY); + Main.EntitySpriteDraw(flashTex, flashPos, flashFrame, Color.White, drawRotation, flashFrame.Size() * 0.5f, scale * 0.8f, flipSprite); + } + + // PING! + if (shouldPing) + { + if (pingAnimationTimer <= PingAnimationDuration) + { + Texture2D pingTexture = Main.zenithWorld ? ModContent.Request("CalamityMod/Particles/MammothParticle").Value : ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandPingText").Value; + Vector2 origin = pingTexture.Size() * 0.5f; + Vector2 pingDrawPosition; + + Vector2 finalPosition = Owner.Center + new Vector2(40f * -Owner.direction, -40f); + float progress = (float)pingAnimationTimer / PingAnimationDuration; + + if (pingAnimationTimer < 15) + { + float popOutProgress = (float)pingAnimationTimer / 15; + pingDrawPosition = Vector2.Lerp(Owner.Center, finalPosition, popOutProgress); + } + else + { + pingDrawPosition = finalPosition; + } + + pingDrawPosition -= Main.screenPosition; + + float stretchFactorY = 0f; + + if (progress < 0.25f) // Stretch Up + { + float stretchProgress = progress / 0.25f; + stretchFactorY = MathHelper.Lerp(-1.4f, 0.5f, (float)Math.Sin(stretchProgress * MathHelper.PiOver2)); + } + else if (progress < 0.5f) // Squash Down and overadjust + { + float squashProgress = (progress - 0.25f) / 0.3f; + stretchFactorY = MathHelper.Lerp(0.5f, -0.25f, squashProgress * squashProgress); + } + else if (progress < 0.8f) // Stretch up again at a slower pace to a bit above the normal scale + { + float stretchProgress = (progress - 0.6f) / 0.2f; + stretchFactorY = MathHelper.Lerp(-0.25f, 0f, stretchProgress * stretchProgress); + } + else // Return to normal + { + stretchFactorY = 0f; + } + + // Draw without any additions + Color drawColor = Color.White; + int fadeDuration = 30; + int fadeStartFrame = PingAnimationDuration - fadeDuration; + + // Fade out over 30 frames + if (pingAnimationTimer >= fadeStartFrame) + { + float fadeProgress = (float)(pingAnimationTimer - fadeStartFrame) / fadeDuration; + drawColor = Color.White * MathHelper.Lerp(1f, 0f, fadeProgress); + } + + float basePingDrawScale = 1f; + float stretchScaleY = 1f + stretchFactorY; + float stretchScaleX = 1f - (stretchFactorY * 0.5f); + + // Calculate scale to display with all factors combined + Vector2 finalPingScale = new Vector2(basePingDrawScale * stretchScaleX, basePingDrawScale * stretchScaleY); + Main.EntitySpriteDraw(pingTexture, pingDrawPosition, null, drawColor, Owner.direction == 1 ? -0.25f : 0.25f, origin, finalPingScale, SpriteEffects.None, 0f); + } + else + { + // Reset the flag and timer once the animation is complete. + shouldPing = false; + pingAnimationTimer = 0; + } + } + + return false; + } + + // Glowmask. + public override void PostDraw(Color lightColor) + { + // This class doesn't draw correctly on the first 2 frames. + if (CurrentState == 1 || globalTimer < 3) + return; + + int chosenFrame = Math.Clamp(Projectile.frame, 0, Main.projFrames[Type] - 1); + + if (globalTimer > 2 && globalTimer < 6) // If the holdout just spawned in and isn't in the reload state, play a belated flash animation. + chosenFrame = 0; + + Texture2D texture = TextureAssets.Projectile[Type].Value; + Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: chosenFrame); + Texture2D glowTexture = HoldoutGlow.Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 origin = frame.Size() * 0.5f; + float scale = Projectile.scale * Owner.gravDir; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(glowTexture, drawPosition, frame, Color.White, drawRotation, origin, scale, flipSprite); + } + } +} diff --git a/Projectiles/Ranged/M1GarandHoldout.png b/Projectiles/Ranged/M1GarandHoldout.png new file mode 100644 index 0000000000..59767b1acd Binary files /dev/null and b/Projectiles/Ranged/M1GarandHoldout.png differ diff --git a/Projectiles/Ranged/M1GarandHoldoutGlow.png b/Projectiles/Ranged/M1GarandHoldoutGlow.png new file mode 100644 index 0000000000..fff673165b Binary files /dev/null and b/Projectiles/Ranged/M1GarandHoldoutGlow.png differ diff --git a/Projectiles/Ranged/M1GarandMuzzleFlash.png b/Projectiles/Ranged/M1GarandMuzzleFlash.png new file mode 100644 index 0000000000..30764d9ece Binary files /dev/null and b/Projectiles/Ranged/M1GarandMuzzleFlash.png differ diff --git a/Projectiles/Ranged/M1GarandPingText.png b/Projectiles/Ranged/M1GarandPingText.png new file mode 100644 index 0000000000..2d49dc5f35 Binary files /dev/null and b/Projectiles/Ranged/M1GarandPingText.png differ diff --git a/Projectiles/Ranged/M1GarandShot.cs b/Projectiles/Ranged/M1GarandShot.cs new file mode 100644 index 0000000000..843d8ecb3b --- /dev/null +++ b/Projectiles/Ranged/M1GarandShot.cs @@ -0,0 +1,81 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using CalamityMod.Particles; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class M1GarandShot : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/AMRShot"; + public override void SetDefaults() + { + Projectile.width = 4; + Projectile.height = 4; + Projectile.light = 0.5f; + Projectile.alpha = 255; + Projectile.extraUpdates = 10; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.penetrate = 2; + Projectile.timeLeft = 600; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + float num107 = (float)Math.Sqrt(Projectile.velocity.X * Projectile.velocity.X + Projectile.velocity.Y * Projectile.velocity.Y); + if (Projectile.alpha > 0) + Projectile.alpha -= (byte)(num107 * 0.9); + if (Projectile.alpha < 0) + Projectile.alpha = 0; + + if (Projectile.timeLeft == 597) + { + for (int i = 0; i <= 15; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.position, DustID.GemTopaz, (Projectile.velocity).RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); + dust.noGravity = true; + } + } + Projectile.scale = 1.38f; + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; + + if (Projectile.timeLeft < 597 && Projectile.timeLeft > 450) + { + SparkParticle spark = new SparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 9, 1f, Color.Coral * 0.3f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + + public override Color? GetAlpha(Color lightColor) + { + if (Projectile.alpha < 140) + return new Color(255, 255, 255, 100); + + return Color.Transparent; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.Center, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.Dig, Projectile.Center); + return true; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + + for (int i = 0; i <= 10; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.position, DustID.GemTopaz, (Projectile.velocity).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); + dust.noGravity = true; + } + } + } +} diff --git a/Projectiles/Ranged/MaelstromHoldout.cs b/Projectiles/Ranged/MaelstromHoldout.cs index 50ef7b39b3..1f85ea4a27 100644 --- a/Projectiles/Ranged/MaelstromHoldout.cs +++ b/Projectiles/Ranged/MaelstromHoldout.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 shootPosition = armPosition + Projectile.velocity * Projectile.width * 0.5f; // Destroy the holdout projectile if the owner is no longer eligible to hold it. - if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.ActiveItem())) + if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.HeldItem)) { Projectile.Kill(); return; @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Ranged if (FramesToLoadNextArrow == 0f) { SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); - FramesToLoadNextArrow = Owner.ActiveItem().useAnimation; + FramesToLoadNextArrow = Owner.HeldItem.useAnimation; } // Actually make progress towards loading more arrows. @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Ranged if (Main.myPlayer != Projectile.owner) return; - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; // Calculate damage at the instant the arrow is fired int arrowDamage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); diff --git a/Projectiles/Ranged/MagnaCannonHoldout.cs b/Projectiles/Ranged/MagnaCannonHoldout.cs index ef4ea8c38e..8440f44443 100644 --- a/Projectiles/Ranged/MagnaCannonHoldout.cs +++ b/Projectiles/Ranged/MagnaCannonHoldout.cs @@ -1,8 +1,9 @@ -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Particles; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using ReLogic.Utilities; using Terraria; using Terraria.Audio; @@ -14,7 +15,7 @@ namespace CalamityMod.Projectiles.Ranged public class MagnaCannonHoldout : BaseGunHoldoutProjectile { public override int AssociatedItemID => ModContent.ItemType(); - public override float MaxOffsetLengthFromArm => 20f; + public override float MaxOffsetLengthFromArm => 28f; public override float OffsetXUpwards => -5f; public override float BaseOffsetY => -5f; @@ -26,10 +27,11 @@ namespace CalamityMod.Projectiles.Ranged public static int FramesPerLoad = 9; public static int MaxLoadableShots = 20; public static float BulletSpeed = 12f; + public int time = 0; public override void KillHoldoutLogic() { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type) Projectile.Kill(); } @@ -56,12 +58,16 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(MagnaCannon.Fire, Projectile.position); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner); for (int i = 0; i <= 3; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition, 187, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); - dust.noGravity = true; + Dust dust = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType(), shootVelocity.RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.2f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.6f)); + dust.noGravity = false; + dust.color = Main.rand.NextBool(3) ? Color.DodgerBlue : Color.RoyalBlue; + dust.fadeIn = 0.3f; } + OffsetLengthFromArm -= 5f; ShotsLoaded--; ShootTimer = FullyCharged ? 4f : 5f; @@ -90,16 +96,8 @@ namespace CalamityMod.Projectiles.Ranged // Charge-up visuals if (CurrentChargingFrames >= 10) { - if (!FullyCharged) - { - Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.White, Color.Aqua, 7, GunTipPosition); - GeneralParticleHandler.SpawnParticle(streak); - } - float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames); - Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Color.DarkBlue, orbScale / 135f, 2); - GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Aqua, orbScale / 200f, 2); - GeneralParticleHandler.SpawnParticle(orb2); + float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames) / 200; + Lighting.AddLight(GunTipPosition, Color.DodgerBlue.ToVector3() * orbScale); } // Full charge dusts @@ -107,13 +105,16 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 36; i++) { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 160); - chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 18f + Owner.velocity; - chargefull.scale = Main.rand.NextFloat(1f, 1.5f); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * Main.rand.NextFloat(6, 7.5f); + chargefull.scale = Main.rand.NextFloat(2f, 2.5f); chargefull.noGravity = true; + chargefull.color = Main.rand.NextBool(3) ? Color.Cyan : Color.RoyalBlue; + chargefull.fadeIn = 1; } } } + time++; } public override void OnKill(int timeLeft) @@ -124,6 +125,8 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { + if (time < 2) + return false; Texture2D texture = TextureAssets.Projectile[Type].Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition; float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); @@ -136,8 +139,14 @@ namespace CalamityMod.Projectiles.Ranged drawPosition += Main.rand.NextVector2Circular(rumble / 43f, rumble / 43f); } + Asset tex2 = ModContent.Request("CalamityMod/Particles/BloomCircle"); + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + float chargeScale = KeepRefreshingLifetime ? Utils.GetLerpValue(0, MagnaCannon.FullChargeFrames, CurrentChargingFrames, true) : 0; + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(tex2.Value, GunTipPosition - Main.screenPosition, null, Color.Lerp(FullyCharged ? Color.DodgerBlue : Color.RoyalBlue, Color.White, i * 0.25f) with { A = 0 } * 0.8f, Main.rand.NextFloat(-5, 5), tex2.Size() * 0.5f, new Vector2(1.35f, 1f) * Projectile.scale * chargeScale * (1 - 0.27f * i) * 0.25f * ((chargeScale >= 1 && CurrentChargingFrames <= MagnaCannon.FullChargeFrames + 3) ? 1.75f : FullyCharged ? 1.4f : 1), SpriteEffects.None, 0); + return false; } } diff --git a/Projectiles/Ranged/MagnaShot.cs b/Projectiles/Ranged/MagnaShot.cs index 874aa255a4..dac9fbc59e 100644 --- a/Projectiles/Ranged/MagnaShot.cs +++ b/Projectiles/Ranged/MagnaShot.cs @@ -1,5 +1,6 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -19,37 +20,41 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.width = Projectile.height = 5; Projectile.friendly = true; - Projectile.alpha = 25; Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 50; + Projectile.localNPCHitCooldown = -1; } public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Dust dust = Dust.NewDustPerfect(Projectile.Center, 187); - dust.noGravity = true; - dust.scale = 0.5f; + + Vector2 trailPos = Projectile.Center + Main.rand.NextVector2Circular(4, 4) - Projectile.velocity; + float trailScale = Main.rand.NextFloat(0.04f, 0.05f); + Color trailColor = Main.rand.NextBool(3) ? Color.DodgerBlue : Color.RoyalBlue; + Particle Trail = new CustomSpark(trailPos, Projectile.velocity.RotatedByRandom(0.03f) * Main.rand.NextFloat(0.1f, 0.4f), "CalamityMod/Particles/SquareRotated", false, Main.rand.NextBool(7) ? 35 : 6, trailScale, trailColor, new Vector2(1f, 1f), true, true, glowOpacity: 0.5f, extraRotation: Main.rand.NextFloat(0, MathHelper.TwoPi)); + GeneralParticleHandler.SpawnParticle(Trail); + } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.DodgerBlue with { A = 0 }, 1); return false; } public override void OnKill(int timeLeft) { - for (int i = 0; i <= 3; i++) + for (int i = 0; i <= 2; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.position, 187, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) / 2, 0, default, Main.rand.NextFloat(1.1f, 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.8f, 1.8f), 0, default, Main.rand.NextFloat(0.9f, 1.3f)); dust.noGravity = false; - SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.8f, PitchVariance = 0.3f }, Projectile.Center); + dust.color = Main.rand.NextBool(3) ? Color.DodgerBlue : Color.RoyalBlue; + dust.fadeIn = -0.15f; } + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.8f, PitchVariance = 0.3f }, Projectile.Center); } public override bool? CanDamage() => base.CanDamage(); } diff --git a/Projectiles/Ranged/MagnomalyRocket.cs b/Projectiles/Ranged/MagnomalyRocket.cs index 7408ace3d2..c318af97b7 100644 --- a/Projectiles/Ranged/MagnomalyRocket.cs +++ b/Projectiles/Ranged/MagnomalyRocket.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Ranged/MarksmanShot.cs b/Projectiles/Ranged/MarksmanShot.cs index f0ed4e0c90..80da0b0d93 100644 --- a/Projectiles/Ranged/MarksmanShot.cs +++ b/Projectiles/Ranged/MarksmanShot.cs @@ -110,18 +110,25 @@ namespace CalamityMod.Projectiles.Ranged { // Assemble an array of the remaining coins. Projectile[] otherCoins = validCoins.Where((proj) => proj.whoAmI != struckCoin.whoAmI).ToArray(); - + RicoshotTarget nextCoin = Projectile.FindRicochetTarget(Projectile.Center, otherCoins, true); + RicochetOffCoin(nextCoin, struckCoin); // Ricochet off of this coin to the next target. // This coin (and potential further coins) may have already been recursively frozen. // As long as those coins have not yet been struck, they are valid targets. - RicoshotTarget nextTarget = Projectile.FindRicochetTarget(Projectile.Center, otherCoins, true); - RicochetOffCoin(nextTarget, struckCoin); - - // If the next target is another coin, freeze it to (almost) guarantee it will be hit. - if (nextTarget.type == RicoshotTargetType.Coin) + // If the next target is another coin/clip, freeze it. + if (nextCoin.type == RicoshotTargetType.Coin) { - Projectile nextCoin = Main.projectile[nextTarget.entityID]; - nextCoin.ai[1] = RicoshotCoin.RicochetPause; + Projectile nextCoinProj = Main.projectile[nextCoin.entityID]; + + // Use the correct RicochetPause value based on the projectile type + if (nextCoinProj.type == ModContent.ProjectileType()) + { + nextCoinProj.ai[1] = M1GarandEmptyClip.RicochetPause; + } + else + { + nextCoinProj.ai[1] = RicoshotCoin.RicochetPause; + } } } } @@ -142,18 +149,42 @@ namespace CalamityMod.Projectiles.Ranged if (NumRicochets == 0 && CalamityUtils.CanRicoshotCoinForceCrit(struckCoin)) cgp.forcedCrit = true; - // Apply bonus damage to the projectile. This is an additive multiplier between multiple coins. - float bonusDamageRatio = struckCoin.ai[0] switch + // Apply bonus damage to the projectile based on the projectile type. This is an additive multiplier between multiple coins/clips. + float bonusDamageRatio = 0f; + if (struckCoin.type == ModContent.ProjectileType()) { - 1f => NumRicochets > 0 ? RicoshotCoin.SilverMulticoinBonus : RicoshotCoin.SilverBonus, - 2f => NumRicochets > 0 ? RicoshotCoin.GoldMulticoinBonus : RicoshotCoin.GoldBonus, - _ => NumRicochets > 0 ? RicoshotCoin.CopperMulticoinBonus : RicoshotCoin.CopperBonus, - }; + bonusDamageRatio = struckCoin.ai[0] switch + { + 1f => NumRicochets > 0 ? RicoshotCoin.SilverMulticoinBonus : RicoshotCoin.SilverBonus, + 2f => NumRicochets > 0 ? RicoshotCoin.GoldMulticoinBonus : RicoshotCoin.GoldBonus, + _ => NumRicochets > 0 ? RicoshotCoin.CopperMulticoinBonus : RicoshotCoin.CopperBonus, + }; + } + else if (struckCoin.type == ModContent.ProjectileType()) + { + bonusDamageRatio = NumRicochets > 0 ? M1GarandEmptyClip.ClipMulticlipBonus : M1GarandEmptyClip.ClipBonus; + } + cgp.totalRicoshotDamageBonus += bonusDamageRatio; // Increment the ricochet count, relegating further coins to only give the multicoin bonus damage. NumRicochets++; + // If the target was valid, freeze the shot in place for a brief moment. + if (target.IsValid) + { + if (struckCoin.type == ModContent.ProjectileType()) + { + RicochetFreezeTimer = M1GarandEmptyClip.RicochetPause; + } + else + { + RicochetFreezeTimer = RicoshotCoin.RicochetPause; + } + } + + SoundEngine.PlaySound(RicoshotCoin.BlingHitSound, struckCoin.Center); + // If the target was valid, freeze the shot in place for a brief moment. if (target.IsValid) RicochetFreezeTimer = RicochetPause; @@ -162,7 +193,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(RicoshotCoin.BlingHitSound, struckCoin.Center); // Apply a little screenshake - Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 5; + Main.player[Projectile.owner].SetScreenshake(5f); // Kill the struck coin immediately after marking it as having been struck. struckCoin.localAI[0] = NumRicochets; @@ -202,13 +233,13 @@ namespace CalamityMod.Projectiles.Ranged } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = Math.Min(Projectile.timeLeft / (float)trailLength, 1f); return Color.PaleGoldenrod * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float width = Math.Min(Projectile.timeLeft / (float)trailLength, 1f); return (1 - completionRatio) * 6.4f * width; @@ -221,7 +252,7 @@ namespace CalamityMod.Projectiles.Ranged return false; GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/BasicTrail")); - PrimitiveRenderer.RenderTrail(trailPositions, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), trailLength); + PrimitiveRenderer.RenderTrail(trailPositions, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), trailLength); return false; } diff --git a/Projectiles/Ranged/MegalodonShot.cs b/Projectiles/Ranged/MegalodonShot.cs index 9ecee22bea..f6589a5697 100644 --- a/Projectiles/Ranged/MegalodonShot.cs +++ b/Projectiles/Ranged/MegalodonShot.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -25,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 3; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/MeowCreature.cs b/Projectiles/Ranged/MeowCreature.cs index 081011d165..802cabe422 100644 --- a/Projectiles/Ranged/MeowCreature.cs +++ b/Projectiles/Ranged/MeowCreature.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -52,8 +51,8 @@ namespace CalamityMod.Projectiles.Ranged } } - internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 9f; - internal Color ColorFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (1f - completionRatio) * Projectile.scale * 9f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float hue = 0.5f + 0.5f * completionRatio * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); Color trailColor = Main.hslToRgb(hue, 1f, 0.8f); @@ -63,7 +62,7 @@ namespace CalamityMod.Projectiles.Ranged // The creature glows public override void PostDraw(Color lightColor) { - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f), 30); Texture2D glow = Terraria.GameContent.TextureAssets.Projectile[Type].Value; Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None); } diff --git a/Projectiles/Ranged/MeowFire.cs b/Projectiles/Ranged/MeowFire.cs index 9fe5429ec1..380a1a7134 100644 --- a/Projectiles/Ranged/MeowFire.cs +++ b/Projectiles/Ranged/MeowFire.cs @@ -2,8 +2,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged diff --git a/Projectiles/Ranged/MineralMortarHoldout.cs b/Projectiles/Ranged/MineralMortarHoldout.cs index 06c9d2f8cb..800f3969e6 100644 --- a/Projectiles/Ranged/MineralMortarHoldout.cs +++ b/Projectiles/Ranged/MineralMortarHoldout.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Ranged // If the time reaches Item.useTime, it'll shoot the projectile, consume ammo and reset the timer. if (Time >= Owner.itemTimeMax && Main.myPlayer == Projectile.owner) { - Owner.PickAmmo(Owner.ActiveItem(), out _, out float speed, out int damage, out float knockback, out int usedItemAmmoId); + Owner.PickAmmo(Owner.HeldItem, out _, out float speed, out int damage, out float knockback, out int usedItemAmmoId); Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX) * speed * 1.5f, ModContent.ProjectileType(), damage, knockback, Projectile.owner, usedItemAmmoId); diff --git a/Projectiles/Ranged/MineralMortarProjectile.cs b/Projectiles/Ranged/MineralMortarProjectile.cs index 50f8a74119..d0efa0f5c6 100644 --- a/Projectiles/Ranged/MineralMortarProjectile.cs +++ b/Projectiles/Ranged/MineralMortarProjectile.cs @@ -162,9 +162,9 @@ namespace CalamityMod.Projectiles.Ranged } } - public static float TrailWidthFunction(float completionRatio) => MathHelper.Lerp(20f, 0f, completionRatio); + public static float TrailWidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Lerp(20f, 0f, completionRatio); - public Color ColorTrailFunction(float completionRatio) => Color.Lerp(BackTrailColor, FrontTrailColor, completionRatio); + public Color ColorTrailFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(BackTrailColor, FrontTrailColor, completionRatio); public override bool PreDraw(ref Color lightColor) { @@ -174,7 +174,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 origin = texture.Size() * 0.5f; GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SwordSlashTexture")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidthFunction, ColorTrailFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 50); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidthFunction, ColorTrailFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 50); if (CalamityClientConfig.Instance.Afterimages) { for (int i = 0; i < 3; i++) diff --git a/Projectiles/Ranged/MiniSharkron.cs b/Projectiles/Ranged/MiniSharkron.cs index 6f357a690c..07831fa91b 100644 --- a/Projectiles/Ranged/MiniSharkron.cs +++ b/Projectiles/Ranged/MiniSharkron.cs @@ -20,9 +20,9 @@ namespace CalamityMod.Projectiles.Ranged AIType = ProjectileID.MiniSharkron; Projectile.friendly = true; Projectile.alpha = 255; + Projectile.arrow = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/MiniatureFolly.cs b/Projectiles/Ranged/MiniatureFolly.cs index d3d590baa2..679a6e8dba 100644 --- a/Projectiles/Ranged/MiniatureFolly.cs +++ b/Projectiles/Ranged/MiniatureFolly.cs @@ -92,8 +92,8 @@ namespace CalamityMod.Projectiles.Ranged CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, SpawnedByFatFuck ? 960f : 300f, 10f, 20f); } - internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 10f; - internal Color ColorFunction(float completionRatio) => Color.Lerp(Color.Red, Color.Magenta, 0.7f * completionRatio + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 20f)) * Projectile.Opacity; + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (1f - completionRatio) * Projectile.scale * 10f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.Red, Color.Magenta, 0.7f * completionRatio + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 20f)) * Projectile.Opacity; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Ranged/MistArrow.cs b/Projectiles/Ranged/MistArrow.cs index 60782c2b63..30bacffc92 100644 --- a/Projectiles/Ranged/MistArrow.cs +++ b/Projectiles/Ranged/MistArrow.cs @@ -26,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged AIType = ProjectileID.WoodenArrowFriendly; Projectile.arrow = true; Projectile.coldDamage = true; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/MistArrowFrostMist.cs b/Projectiles/Ranged/MistArrowFrostMist.cs index 2c38992adf..29d8e23ecb 100644 --- a/Projectiles/Ranged/MistArrowFrostMist.cs +++ b/Projectiles/Ranged/MistArrowFrostMist.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -42,7 +41,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 2; i++) { Vector2 dustPosition = new Vector2(Projectile.position.X + Main.rand.NextFloat(0f, Projectile.width), Projectile.position.Y + Main.rand.NextFloat(0f, Projectile.height)); - Dust frostDust = Dust.NewDustPerfect(dustPosition, 16, Vector2.Zero, 0, default, 0.45f); + Dust frostDust = Dust.NewDustPerfect(dustPosition, DustID.Cloud, Vector2.Zero, 0, default, 0.45f); frostDust.noGravity = true; } Lighting.AddLight(Projectile.Center, 0.4f, 0.4f, 0.4f); diff --git a/Projectiles/Ranged/NeedlerProj.cs b/Projectiles/Ranged/NeedlerProj.cs index 1df82ad3bb..533bba5dd5 100644 --- a/Projectiles/Ranged/NeedlerProj.cs +++ b/Projectiles/Ranged/NeedlerProj.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -64,7 +63,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); for (int j = 0; j < 4; j++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 46, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Poisoned, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.3f)); dust.noGravity = false; dust.scale = Main.rand.NextFloat(0.8f, 1.8f); if (Main.rand.NextBool()) diff --git a/Projectiles/Ranged/NitroShot.cs b/Projectiles/Ranged/NitroShot.cs index 5496c63ec7..70cbb6cd64 100644 --- a/Projectiles/Ranged/NitroShot.cs +++ b/Projectiles/Ranged/NitroShot.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -27,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 600; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -42,7 +40,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 15; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.position, 87, (Projectile.velocity).RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.position, DustID.GemTopaz, (Projectile.velocity).RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); dust.noGravity = true; } } @@ -75,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i <= 10; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.position, 87, (Projectile.velocity).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.position, DustID.GemTopaz, (Projectile.velocity).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.6f, 1.1f)); dust.noGravity = true; } diff --git a/Projectiles/Ranged/NorfleetCannon.cs b/Projectiles/Ranged/NorfleetCannon.cs index caeb01d06d..331e716686 100644 --- a/Projectiles/Ranged/NorfleetCannon.cs +++ b/Projectiles/Ranged/NorfleetCannon.cs @@ -1,9 +1,7 @@ using System; -using System.Runtime.Intrinsics.X86; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; -using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; @@ -28,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged private SlotId NorfleetRecharge; private ref float OffsetLength => ref Projectile.localAI[0]; - private ref float loadedShots => ref Projectile.ai[2]; private Player Owner; @@ -52,7 +49,7 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; if (Owner.dead || Owner is null) Projectile.Kill(); @@ -92,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged { hum?.Stop(); } - if (loadedShots > 1) + if (Owner.Calamity().NorfleetCounter < 2) { ShootRocket(heldItem); PostFireCooldown = PUNISHMENTMODE ? 1000 : 55; @@ -180,7 +177,7 @@ namespace CalamityMod.Projectiles.Ranged private void ShootRocket(Item item) { - if (hasFired == false) + if (!hasFired) { // We use the velocity of this projectile as its direction vector. Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); @@ -191,10 +188,11 @@ namespace CalamityMod.Projectiles.Ranged // Spawns the projectile. SoundStyle fire = new("CalamityMod/Sounds/Item/NorfleetFire"); SoundEngine.PlaySound(fire with { Volume = 0.9f, PitchVariance = 0.25f }, Projectile.Center); + Owner.Calamity().NorfleetCounter++; for (int i = 0; i < 3; i++) { - Vector2 firingVelocity = shootDirection.RotatedByRandom((0.2f * i) + 0.02f) * 5f * Main.rand.NextFloat(0.7f, 1.3f); + Vector2 firingVelocity = shootDirection.RotatedByRandom((0.1f * i) + 0.02f) * 5f * Main.rand.NextFloat(0.8f, 1.2f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage / 3, Projectile.knockBack, Projectile.owner, 0, i, PUNISHMENTMODE ? 1 : 0); } @@ -264,7 +262,7 @@ namespace CalamityMod.Projectiles.Ranged 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 dust = Dust.NewDustPerfect(tipPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); dust.noGravity = false; dust.color = PUNISHMENTMODE ? Color.Red : Color.White; } @@ -306,7 +304,7 @@ namespace CalamityMod.Projectiles.Ranged if (PostFireCooldown > 15) { Vector2 dustVel = Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(5.1f, 25.8f); - Dust dust = Dust.NewDustPerfect(tipPosition + dustVel * 5, 267, -dustVel * 0.5f, 0, default, Main.rand.NextFloat(0.5f, 1f)); + Dust dust = Dust.NewDustPerfect(tipPosition + dustVel * 5, DustID.RainbowMk2, -dustVel * 0.5f, 0, default, Main.rand.NextFloat(0.5f, 1f)); dust.noGravity = true; dust.color = mainColor; } @@ -328,6 +326,12 @@ namespace CalamityMod.Projectiles.Ranged { Owner = Main.player[Projectile.owner]; OffsetLength = MaxOffsetLength; + + if (Main.zenithWorld && Main.rand.NextBool(1000)) + { + PUNISHMENTMODE = true; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/NuhUhUh"), Owner.Center); + } } // Because we use the velocity as a direction, we don't need it to change its position. diff --git a/Projectiles/Ranged/NorfleetComet.cs b/Projectiles/Ranged/NorfleetComet.cs index 6ad655c2d3..3516c60b3d 100644 --- a/Projectiles/Ranged/NorfleetComet.cs +++ b/Projectiles/Ranged/NorfleetComet.cs @@ -6,7 +6,6 @@ using CalamityMod.Particles; using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework.Graphics; -using SteelSeries.GameSense; namespace CalamityMod.Projectiles.Ranged { @@ -81,7 +80,7 @@ namespace CalamityMod.Projectiles.Ranged public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { Player Owner = Main.player[Projectile.owner]; - Owner.Calamity().GeneralScreenShakePower = 7.5f; + Owner.SetScreenshake(7.5f); SoundStyle fire = new("CalamityMod/Sounds/Item/ScorpioNukeHit"); SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = 0.6f, PitchVariance = 0.2f }, Projectile.Center); } @@ -109,7 +108,7 @@ namespace CalamityMod.Projectiles.Ranged for (int k = 0; k < 30; k++) { Vector2 velocity = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.2f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + velocity, 259, velocity); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + velocity, DustID.SolarFlare, velocity); dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); dust2.noGravity = true; } @@ -133,7 +132,7 @@ namespace CalamityMod.Projectiles.Ranged for (int k = 0; k < 30; k++) { Vector2 velocity = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.2f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + velocity, 226, velocity); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + velocity, DustID.Electric, velocity); dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); dust2.noGravity = false; } diff --git a/Projectiles/Ranged/NorfleetExplosion.cs b/Projectiles/Ranged/NorfleetExplosion.cs index 66a58bd95a..d1bb85209d 100644 --- a/Projectiles/Ranged/NorfleetExplosion.cs +++ b/Projectiles/Ranged/NorfleetExplosion.cs @@ -1,8 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged diff --git a/Projectiles/Ranged/NovaChargedShot.cs b/Projectiles/Ranged/NovaChargedShot.cs index 26e5da2318..63bb4b40ca 100644 --- a/Projectiles/Ranged/NovaChargedShot.cs +++ b/Projectiles/Ranged/NovaChargedShot.cs @@ -1,4 +1,7 @@ -using CalamityMod.Particles; +using System; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -26,7 +29,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 1200; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.extraUpdates = 24; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; @@ -36,19 +38,32 @@ namespace CalamityMod.Projectiles.Ranged { Time++; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(-3, 3), 107); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(-3, 3), ModContent.DustType()); dust.noGravity = true; - dust.scale = 1.2f; + dust.scale = Main.rand.NextFloat(0.9f, 1.3f); + dust.color = ArcNovaDiffuser.mainColor; + dust.fadeIn = -0.4f; if (Time < 120) { if (Main.rand.NextBool()) { Vector2 trailPos = Projectile.Center + Main.rand.NextVector2Circular(10, 10); - float trailScale = Main.rand.NextFloat(0.8f, 1.2f); - Color trailColor = Main.rand.NextBool(3) ? Color.Chartreuse : Color.Lime; - Particle Trail = new SparkParticle(trailPos, Projectile.velocity * 0.2f, false, 60, trailScale, trailColor); + float trailScale = Main.rand.NextFloat(0.6f, 0.75f); + Color trailColor = Main.rand.NextBool(3) ? Color.Chartreuse : ArcNovaDiffuser.mainColor; + Particle Trail = new CustomSpark(trailPos, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 50, trailScale, trailColor, new Vector2(0.2f, 1.4f), true, true, shrinkSpeed: 0.1f); GeneralParticleHandler.SpawnParticle(Trail); } + if (Time % 2 == 0) + { + for (int i = -1; i <= 1; i += 2) + { + float sine = (float)Math.Sin(Projectile.timeLeft * 0.45f / MathHelper.Pi); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 28 * i, ModContent.DustType(), Projectile.velocity * Main.rand.NextFloat(0.6f, 0.8f), 0, default, Main.rand.NextFloat(0.8f, 0.85f)); + dust2.noGravity = true; + dust2.color = Main.rand.NextBool(3) ? Color.Lime : ArcNovaDiffuser.mainColor; + dust2.fadeIn = -0.55f; + } + } } @@ -60,45 +75,43 @@ namespace CalamityMod.Projectiles.Ranged } public override Color? GetAlpha(Color lightColor) { - return new Color(50, 255, 50, Projectile.alpha); + return ArcNovaDiffuser.mainColor with { A = 0 }; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.CursedInferno, 900); + } public override void OnKill(int timeLeft) { for (int i = 0; i <= 19; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 107, new Vector2(0, -18).RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.9f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(0, -18).RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.9f)); dust.noGravity = false; - dust.scale = Main.rand.NextFloat(0.8f, 1.5f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 107, new Vector2(0, -7).RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.9f)); + dust.scale = Main.rand.NextFloat(0.8f, 2.3f); + dust.color = ArcNovaDiffuser.mainColor; + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(0, -7).RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.9f)); dust2.noGravity = false; - dust2.scale = Main.rand.NextFloat(0.8f, 1.5f); + dust2.scale = Main.rand.NextFloat(0.8f, 2.3f); + dust2.color = Color.Lime; } - SoundEngine.PlaySound(ChargeImpact, Projectile.position); - Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Lime, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 0.1f, 0.6f, 20); + SoundEngine.PlaySound(ChargeImpact, Projectile.Center); + Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, ArcNovaDiffuser.mainColor, "CalamityMod/Particles/BloomRing", new Vector2(1f, 1f), 0, 0.2f, 1.3f, 16); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.Chartreuse, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 0.1f, 0.5f, 16); + Particle pulse2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lime, "CalamityMod/Particles/BloomCircle", new Vector2(1f, 1f), 0, 0.8f, 0.1f, 20); GeneralParticleHandler.SpawnParticle(pulse2); - - for (int i = 0; i < 25; ++i) + for (int i = 0; i < 2; i++) { - int bloodLifetime = Main.rand.Next(22, 36); - float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); - Color bloodColor = Color.Lerp(Color.Lime, Color.Chartreuse, Main.rand.NextFloat()); - bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); - - if (Main.rand.NextBool(20)) - bloodScale *= 2f; - - float randomSpeedMultiplier = Main.rand.NextFloat(1.25f, 2.25f); - Vector2 bloodVelocity = Main.rand.NextVector2Unit() * 5 * randomSpeedMultiplier; - bloodVelocity.Y -= 5f; - BloodParticle blood = new BloodParticle(Projectile.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); - GeneralParticleHandler.SpawnParticle(blood); + Particle spark2 = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 16, 0.95f, ArcNovaDiffuser.mainColor, new Vector2(1f, 1f), true, true, glowOpacity: 0.9f); + GeneralParticleHandler.SpawnParticle(spark2); } + + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + Player Owner = Main.player[Projectile.owner]; + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); + modifiers.SourceDamage *= 1 + critDamage; } public override bool? CanDamage() => base.CanDamage(); } diff --git a/Projectiles/Ranged/NovaShot.cs b/Projectiles/Ranged/NovaShot.cs index c121177a34..5d7facd89b 100644 --- a/Projectiles/Ranged/NovaShot.cs +++ b/Projectiles/Ranged/NovaShot.cs @@ -1,8 +1,9 @@ -using CalamityMod.Particles; +using System; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -11,6 +12,7 @@ namespace CalamityMod.Projectiles.Ranged { public bool FirstFrameNoDraw = true; public new string LocalizationCategory => "Projectiles.Ranged"; + public int sineDir = 0; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 8; @@ -26,7 +28,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.extraUpdates = 3; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; @@ -34,15 +35,24 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + if (sineDir == 0) + sineDir = Main.rand.NextBool() ? -1 : 1; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; //Dust dust = Dust.NewDustPerfect(Projectile.Center, 107); // + Main.rand.NextVector2Circular(-3, 3) //dust.noGravity = true; //dust.scale = 0.5f; if (Projectile.timeLeft % 2 == 0 && Projectile.timeLeft < 290) { - SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 5, 1f, Color.Lime * 0.6f); - GeneralParticleHandler.SpawnParticle(spark); - + Particle Trail = new CustomSpark(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomCircle", false, 7, 0.33f, ArcNovaDiffuser.mainColor * 0.8f, new Vector2(0.2f, 1.4f), true, true, shrinkSpeed: 0.4f, glowOpacity: 0.8f); + GeneralParticleHandler.SpawnParticle(Trail); + } + if (Main.rand.NextBool(3)) + { + float sine = (float)Math.Sin(Projectile.timeLeft * 0.45f / MathHelper.Pi); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2 * sineDir) * sine * 8, ModContent.DustType(), Projectile.velocity * Main.rand.NextFloat(0.85f, 0.9f), 0, default, Main.rand.NextFloat(0.4f, 0.45f) * 3); + dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Lime : ArcNovaDiffuser.mainColor; + dust.fadeIn = Main.rand.NextBool(8) ? -0.4f : 1.75f; } } public override bool PreDraw(ref Color lightColor) @@ -52,11 +62,26 @@ namespace CalamityMod.Projectiles.Ranged } public override Color? GetAlpha(Color lightColor) { - return new Color(50, 255, 50, Projectile.alpha); + return ArcNovaDiffuser.mainColor with { A = 0 }; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.CursedInferno, 90); + if (Projectile.numHits == 0) + { + for (int i = 0; i <= 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.4f) * Main.rand.NextFloat(7f, 9f), 0, default, Main.rand.NextFloat(0.8f, 1.8f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Lime : ArcNovaDiffuser.mainColor; + dust.fadeIn = 1.5f; + if (Main.rand.NextBool(3)) + { + dust.scale = Main.rand.NextFloat(0.4f, 0.5f); + dust.fadeIn = -0.85f; + dust.velocity /= 2; + } + } + } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { @@ -69,7 +94,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 4; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.position, 107, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.position, DustID.Terra, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); dust.noGravity = false; } } diff --git a/Projectiles/Ranged/NukeOfBliss.cs b/Projectiles/Ranged/NukeOfBliss.cs index a8ff6adc94..169a5e007f 100644 --- a/Projectiles/Ranged/NukeOfBliss.cs +++ b/Projectiles/Ranged/NukeOfBliss.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged if (rainDownTimer >= 80) { bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); - if (rainDownTimer % 15 == 0) + if (rainDownTimer % 15 == 0 && Main.myPlayer == Projectile.owner) { SoundStyle fire = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastShoot"); SoundEngine.PlaySound(fire with { Volume = 0.45f, Pitch = (0 - 0.3f * Utils.GetLerpValue(0, 300, rainDownTimer, true)) }, Projectile.Center); @@ -190,7 +190,7 @@ namespace CalamityMod.Projectiles.Ranged } else { - Dust l = Dust.NewDustPerfect(Projectile.Center, 278); + Dust l = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); l.velocity = new Vector2(5, 5).RotatedByRandom(100) * blastRadiusVisual * Main.rand.NextFloat(0.4f, 1f); l.scale = Main.rand.NextFloat(0.6f, 0.8f) * blastRadiusVisual * 0.2f * (i % 2 == 0 ? 2.2f : 1.8f); l.noGravity = false; diff --git a/Projectiles/Ranged/NullFlash.cs b/Projectiles/Ranged/NullFlash.cs index 1b9bae9402..3654040cf2 100644 --- a/Projectiles/Ranged/NullFlash.cs +++ b/Projectiles/Ranged/NullFlash.cs @@ -1,13 +1,9 @@ using System.Collections.Generic; -using CalamityMod.CalPlayer; -using CalamityMod.NPCs; -using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged diff --git a/Projectiles/Ranged/NullShot.cs b/Projectiles/Ranged/NullShot.cs index bdb58ffa4f..1cb32211fc 100644 --- a/Projectiles/Ranged/NullShot.cs +++ b/Projectiles/Ranged/NullShot.cs @@ -1,8 +1,7 @@ using System; using System.Collections.Generic; -using CalamityMod.CalPlayer; using CalamityMod.Dusts; -using CalamityMod.NPCs; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -167,7 +166,7 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(orb2); } } - SoundStyle fire = new("CalamityMod/Sounds/Item/NullHit"); + SoundStyle fire = NullificationPistol.HitSound; SoundEngine.PlaySound(fire with { Volume = (Projectile.ai[1] == 5 ? 1 : 0.7f), Pitch = Main.rand.NextFloat(0, 0.1f) * (Projectile.ai[1] == 5 ? 3 : 1) }, Projectile.Center); if (Main.zenithWorld) { @@ -178,27 +177,34 @@ namespace CalamityMod.Projectiles.Ranged if (Utils.Distance(Main.player[Projectile.owner].Center, target.Center) > 1000) target.velocity = Utils.DirectionTo(target.Center, Main.player[Projectile.owner].Center); - int nullCorrupt = Main.rand.Next(4); - switch (nullCorrupt) + if (Main.rand.NextBool(4)) { - case 0: - target.ai[0] = Main.rand.Next(0, 100 + 1); - target.localAI[0] = Main.rand.Next(0, 100 + 1); - break; - case 1: - target.ai[1] = Main.rand.Next(0, 100 + 1); - target.localAI[1] = Main.rand.Next(0, 100 + 1); - break; - case 2: - target.ai[2] = Main.rand.Next(0, 100 + 1); - target.localAI[2] = Main.rand.Next(0, 100 + 1); - break; - case 3: - target.ai[3] = Main.rand.Next(0, 100 + 1); - target.localAI[3] = Main.rand.Next(0, 100 + 1); - break; - default: - break; + target.aiStyle = Main.rand.Next(2, 140 + 1); + } + else + { + int nullCorrupt = Main.rand.Next(4); + switch (nullCorrupt) + { + case 0: + target.ai[0] = Main.rand.Next(0, 100 + 1); + target.localAI[0] = Main.rand.Next(0, 100 + 1); + break; + case 1: + target.ai[1] = Main.rand.Next(0, 100 + 1); + target.localAI[1] = Main.rand.Next(0, 100 + 1); + break; + case 2: + target.ai[2] = Main.rand.Next(0, 100 + 1); + target.localAI[2] = Main.rand.Next(0, 100 + 1); + break; + case 3: + target.ai[3] = Main.rand.Next(0, 100 + 1); + target.localAI[3] = Main.rand.Next(0, 100 + 1); + break; + default: + break; + } } } else diff --git a/Projectiles/Ranged/OntoligicalDespoilerBurst.cs b/Projectiles/Ranged/OntoligicalDespoilerBurst.cs index 4de91212fa..8877b11310 100644 --- a/Projectiles/Ranged/OntoligicalDespoilerBurst.cs +++ b/Projectiles/Ranged/OntoligicalDespoilerBurst.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -28,10 +29,17 @@ namespace CalamityMod.Projectiles.Ranged } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + modifiers.SetCrit(); + Player Owner = Main.player[Projectile.owner]; + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); float minMult = 0.45f; int hitsToMinMult = 15; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= damageMult; + modifiers.SourceDamage *= (damageMult + critDamage); + + Vector2 launchVel = Projectile.Center.DirectionTo(target.Center); + float launchPower = 20; + target.MoveNPC(launchVel, launchPower, true); } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 450, targetHitbox); } diff --git a/Projectiles/Ranged/OntologicalDespoilerBeam.cs b/Projectiles/Ranged/OntologicalDespoilerBeam.cs index 5aecd11315..7281333710 100644 --- a/Projectiles/Ranged/OntologicalDespoilerBeam.cs +++ b/Projectiles/Ranged/OntologicalDespoilerBeam.cs @@ -1,14 +1,7 @@ using System; -using System.Collections.Generic; -using CalamityMod.CalPlayer; using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.NPCs; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -23,6 +16,8 @@ namespace CalamityMod.Projectiles.Ranged public ref float time => ref Projectile.ai[0]; public Color baseColor = Color.White; public bool fading = false; + public int sineDir = 0; + public float fadeMultiplier = 1; public override void SetDefaults() { Projectile.width = 45; @@ -33,6 +28,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.extraUpdates = 80; Projectile.tileCollide = false; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -40,7 +37,8 @@ namespace CalamityMod.Projectiles.Ranged Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); bool inRange = targetDist < 1400; - + if (sineDir == 0) + sineDir = Main.rand.NextBool() ? 1 : -1; Projectile.rotation = Projectile.velocity.ToRotation(); if (time <= 5) Projectile.scale = 0.1f; @@ -51,8 +49,21 @@ namespace CalamityMod.Projectiles.Ranged Projectile.velocity *= 0.992f; Projectile.scale *= 0.992f; } - if (time > 11) + if (fading) + fadeMultiplier -= 0.007f; + if (time > 11 && inRange) { + if (fadeMultiplier > 0.01f) + { + for (int i = -1 * sineDir; (sineDir == 1 ? (i <= 1) : (i >= -1)); i += 2 * sineDir) + { + float sine = (float)Math.Sin(Projectile.timeLeft * 0.25f / MathHelper.Pi); + + Particle beam = new CustomSpark(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 35 * i * fadeMultiplier, Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4 * Main.rand.NextFloat(0.6f, 0.8f), "CalamityMod/Particles/Light", false, 45, 0.4f * fadeMultiplier * MathHelper.Lerp(Math.Abs(sine), 0.55f, 0.6f), i == 1 ? Color.White : Color.Black, new Vector2(1f, 1f), i == 1 ? true : false, false, 0, false, false, 0, noShrink: true); + GeneralParticleHandler.SpawnParticle(beam); + } + } + if (Main.rand.NextBool(4) && !fading) { Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), (Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()), Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(2.3f, 5.8f)); @@ -87,7 +98,7 @@ namespace CalamityMod.Projectiles.Ranged dust.noGravity = true; dust.scale = Main.rand.NextFloat(2.15f, 3.45f) * dustPower; dust.color = baseColor; - Dust dust3 = Dust.NewDustPerfect(Projectile.Center, 278, (Projectile.velocity * 25 * (dustPower * dustPower)).RotatedByRandom(1f - dustPower * dustPower) * Main.rand.NextFloat(0.9f, 1f)); + Dust dust3 = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, (Projectile.velocity * 25 * (dustPower * dustPower)).RotatedByRandom(1f - dustPower * dustPower) * Main.rand.NextFloat(0.9f, 1f)); dust3.noGravity = true; dust3.scale = Main.rand.NextFloat(1.35f, 1.75f) * dustPower; dust3.color = baseColor; @@ -109,10 +120,21 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 3; i++) { SoundStyle fire = new("CalamityMod/Sounds/Item/OntologicalDespoilerLargeImpact"); - SoundEngine.PlaySound(fire with { Volume = 0.65f, MaxInstances = 3 }, Projectile.Center); + SoundEngine.PlaySound(fire with { Volume = 0.65f, MaxInstances = -1}, Projectile.Center); } SoundStyle fire2 = new("CalamityMod/Sounds/Item/MeldExplosion"); - SoundEngine.PlaySound(fire2 with { Volume = 1, Pitch = Main.rand.NextFloat(-0.5f, -0.6f) }, Projectile.Center); + SoundEngine.PlaySound(fire2 with { Volume = 1, Pitch = Main.rand.NextFloat(-0.5f, -0.6f), MaxInstances = -1 }, Projectile.Center); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + Player Owner = Main.player[Projectile.owner]; + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); + modifiers.SourceDamage *= 1 + critDamage; + + Vector2 launchVel = Projectile.velocity; + float launchPower = 60; + target.MoveNPC(launchVel, launchPower, true); } public override bool? CanDamage() => Projectile.numHits < 1 ? null : false; public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/OntologicalDespoilerGrenade.cs b/Projectiles/Ranged/OntologicalDespoilerGrenade.cs index ea3b79ba0d..fe4aa1371d 100644 --- a/Projectiles/Ranged/OntologicalDespoilerGrenade.cs +++ b/Projectiles/Ranged/OntologicalDespoilerGrenade.cs @@ -126,7 +126,7 @@ namespace CalamityMod.Projectiles.Ranged if (explode) { - Owner.Calamity().GeneralScreenShakePower = 8.5f; + Owner.SetScreenshake(8.5f); float power = 1.5f; for (int i = 0; i < 55; i++) @@ -172,7 +172,7 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle fire2 = new("CalamityMod/Sounds/Item/ShadowboltReflect"); SoundEngine.PlaySound(fire2 with { Volume = 0.9f, Pitch = -0.4f}, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 12f), Projectile.knockBack * 3, Projectile.owner, 0, 0, 0); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 12f), 0, Projectile.owner, 0, 0, 0); } else { @@ -199,6 +199,13 @@ namespace CalamityMod.Projectiles.Ranged useColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); return useColor; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + Player Owner = Main.player[Projectile.owner]; + float critDamage = Math.Min(Owner.GetTotalCritChance(Projectile.DamageType) * 0.01f, 1f); + modifiers.SourceDamage *= 1 + critDamage; + } public override bool PreDraw(ref Color lightColor) { if (time < 2) diff --git a/Projectiles/Ranged/OntologicalDespoilerHoldout.cs b/Projectiles/Ranged/OntologicalDespoilerHoldout.cs index 05b655bfd8..ca3726c40e 100644 --- a/Projectiles/Ranged/OntologicalDespoilerHoldout.cs +++ b/Projectiles/Ranged/OntologicalDespoilerHoldout.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged } public override void KillHoldoutLogic() { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type) Projectile.Kill(); } @@ -155,7 +155,17 @@ namespace CalamityMod.Projectiles.Ranged inverseTimer--; // Changing Mode - if (Projectile.ai[2] >= 10) + if (Projectile.ai[2] == 20) + { + Projectile.frame = 6; + ShotsLoaded = 0; + if (Time == 0) + { + Projectile.timeLeft = (int)(AftershotCooldownFrames * 1.5f); + OffsetLengthFromArm = 45f; + } + } + else if (Projectile.ai[2] >= 10) { ShotsLoaded = 0; if (Time == 0) @@ -207,20 +217,23 @@ namespace CalamityMod.Projectiles.Ranged ChargeSound?.Stop(); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - int charge2DamagePos = Projectile.damage; // Most of the damage comes from the explosion - int charge2DamageNeg = Projectile.damage * 40; // Big charge time? Check. No pierce? Check. 40x damage? Yes! + int charge2DamagePos = (int)(Projectile.damage * 0.5f); // Most of the damage comes from the explosion + int charge2DamageNeg = Projectile.damage * 20; // Big charge time? Check. No pierce? Check. 20x damage? Yes! - if (Positive) + if (Main.myPlayer == Projectile.owner) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 2.5f, ModContent.ProjectileType(), charge2DamagePos, Projectile.knockBack, Projectile.owner); - SoundEngine.PlaySound(OntologicalDespoiler.BigShot, Projectile.Center); - } - else - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 0.6f, ModContent.ProjectileType(), charge2DamageNeg, Projectile.knockBack * 3, Projectile.owner); - Owner.Calamity().GeneralScreenShakePower = 12f; - SoundEngine.PlaySound(OntologicalDespoiler.BigShot2 with { Pitch = 0.2f }, Projectile.Center); - SoundEngine.PlaySound(OntologicalDespoiler.BigShot with { Pitch = -0.3f }, Projectile.Center); + if (Positive) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 2.5f, ModContent.ProjectileType(), charge2DamagePos, Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(OntologicalDespoiler.BigShot, Projectile.Center); + } + else + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity * 0.6f, ModContent.ProjectileType(), charge2DamageNeg, Projectile.knockBack * 3, Projectile.owner); + Owner.SetScreenshake(12f); + SoundEngine.PlaySound(OntologicalDespoiler.BigShot2 with { Pitch = 0.2f }, Projectile.Center); + SoundEngine.PlaySound(OntologicalDespoiler.BigShot with { Pitch = -0.3f }, Projectile.Center); + } } // Setting stats for the flash visual effect so it doesn't stick to the gun @@ -261,20 +274,23 @@ namespace CalamityMod.Projectiles.Ranged ChargeSound?.Stop(); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - Vector2 fireVec = shootVelocity * Main.rand.NextFloat(0.9f, 1.1f); - if (Positive) + if (Main.myPlayer == Projectile.owner) { - for (int i = 0; i < 3; i++) + Vector2 fireVec = shootVelocity * Main.rand.NextFloat(0.9f, 1.1f); + if (Positive) { - float angle = i == 0 ? -0.25f : i == 2 ? 0.25f : 0; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedBy(angle) * (1 - Math.Abs(angle * 0.25f)), ModContent.ProjectileType(), (int)(Projectile.damage / 1.5f), Projectile.knockBack, Projectile.owner, 0, 0, i); + for (int i = 0; i < 3; i++) + { + float angle = i == 0 ? -0.25f : i == 2 ? 0.25f : 0; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedBy(angle) * (1 - Math.Abs(angle * 0.25f)), ModContent.ProjectileType(), (int)(Projectile.damage), Projectile.knockBack, Projectile.owner, 0, 0, i); + } } - } - else - { - for (int i = 0; i < 2; i++) + else { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedByRandom(0.45f) * Main.rand.NextFloat(0.8f, 1f), ModContent.ProjectileType(), (int)(Projectile.damage / 2.5f), Projectile.knockBack, Projectile.owner, 0, 0, 5); + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedByRandom(0.45f) * Main.rand.NextFloat(0.8f, 1f), ModContent.ProjectileType(), (int)(Projectile.damage / 4f), Projectile.knockBack, Projectile.owner, 0, 0, 5); + } } } @@ -447,7 +463,7 @@ namespace CalamityMod.Projectiles.Ranged SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; if (!Owner.CantUseHoldout()) { - float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, Charge2Frames); + float rumble = (Projectile.ai[2] == 20 ? 200 : MathHelper.Clamp(CurrentChargingFrames, 0f, Charge2Frames)); drawPosition += Main.rand.NextVector2Circular(rumble / 120f, rumble / 120f); } diff --git a/Projectiles/Ranged/OntologicalDespoilerShot.cs b/Projectiles/Ranged/OntologicalDespoilerShot.cs index 0056e5832b..2d0d3f96e2 100644 --- a/Projectiles/Ranged/OntologicalDespoilerShot.cs +++ b/Projectiles/Ranged/OntologicalDespoilerShot.cs @@ -194,7 +194,7 @@ namespace CalamityMod.Projectiles.Ranged } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - float minMult = 0.35f; + float minMult = 0.3f; int hitsToMinMult = 3; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; diff --git a/Projectiles/Ranged/OpalChargedStrike.cs b/Projectiles/Ranged/OpalChargedStrike.cs index 52cf57f8aa..705ff23ddf 100644 --- a/Projectiles/Ranged/OpalChargedStrike.cs +++ b/Projectiles/Ranged/OpalChargedStrike.cs @@ -1,8 +1,7 @@ -using CalamityMod.Particles; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -18,16 +17,15 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - Projectile.width = Projectile.height = 30; + Projectile.width = Projectile.height = 35; Projectile.friendly = true; Projectile.alpha = 55; - Projectile.penetrate = 3; + Projectile.penetrate = 5; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - Projectile.extraUpdates = 3; + Projectile.extraUpdates = 6; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 50; + Projectile.localNPCHitCooldown = -1; Projectile.tileCollide = false; // Custom tile collision since the hitbox is large } @@ -38,43 +36,49 @@ namespace CalamityMod.Projectiles.Ranged if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(7, 7), 162); - dust.scale = 1.3f; - dust.velocity = -Projectile.velocity * 0.4f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 0.4f, 0, default, Main.rand.NextFloat(0.75f, 0.95f)); + dust.noGravity = !Main.rand.NextBool(5); + dust.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + dust.fadeIn = -0.85f; } Player Owner = Main.player[Projectile.owner]; float playerDist = Vector2.Distance(Owner.Center, Projectile.Center); - if (Projectile.timeLeft % 2 == 0 && playerDist < 1400f && Projectile.timeLeft < 290) + if (Main.rand.NextBool(3) && playerDist < 1400f && Projectile.timeLeft < 290) { - SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 3f, -Projectile.velocity * 0.05f, false, 9, 2f, Color.OrangeRed * 0.25f); - GeneralParticleHandler.SpawnParticle(spark); + Vector2 trailPos = Projectile.Center + Main.rand.NextVector2Circular(8, 8); + float trailScale = Main.rand.NextFloat(0.45f, 0.6f); + Color trailColor = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + Particle Trail = new CustomSpark(trailPos, Projectile.velocity * 0.2f, "CalamityMod/Particles/BloomCircle", false, 40, trailScale, trailColor, new Vector2(0.2f, 1.4f), true, true, shrinkSpeed: 0.13f, glowOpacity: 0.6f); + GeneralParticleHandler.SpawnParticle(Trail); } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.OrangeRed with { A = 0 }, 1); return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.OnFire, 300); + target.AddBuff(BuffID.OnFire3, 120); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.80f); + Projectile.damage = (int)(Projectile.damage * 0.75f); if (Projectile.damage < 1) Projectile.damage = 1; } public override void OnKill(int timeLeft) { - for (int i = 0; i <= 8; i++) + for (int i = 0; i <= 12; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.position, 162, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) / 2, 0, default, Main.rand.NextFloat(1.6f, 2.3f)); - dust.noGravity = false; + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.8f, 1.8f), 0, default, Main.rand.NextFloat(1.9f, 2.8f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + dust.fadeIn = 1.85f; } } public override bool? CanDamage() => base.CanDamage(); diff --git a/Projectiles/Ranged/OpalStrike.cs b/Projectiles/Ranged/OpalStrike.cs index c2d0bbc307..c7ec142426 100644 --- a/Projectiles/Ranged/OpalStrike.cs +++ b/Projectiles/Ranged/OpalStrike.cs @@ -1,7 +1,6 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -24,10 +23,9 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 2; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 50; + Projectile.localNPCHitCooldown = -1; Projectile.tileCollide = false; // Custom tile collision since the hitbox is large } @@ -37,12 +35,19 @@ namespace CalamityMod.Projectiles.Ranged Projectile.Kill(); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Dust.NewDustPerfect(Projectile.Center, 162); + if (Main.rand.NextBool()) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 0.4f, 0, default, Main.rand.NextFloat(0.6f, 0.8f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + dust.fadeIn = -0.5f; + } + } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.Orange with { A = 0 }, 1); return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) @@ -53,8 +58,10 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.position, 162, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) / 2, 0, default, Main.rand.NextFloat(1.6f, 2.3f)); - dust.noGravity = false; + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.6f, 1.3f), 0, default, Main.rand.NextFloat(1.6f, 2.3f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + dust.fadeIn = 1.5f; } } public override bool? CanDamage() => base.CanDamage(); diff --git a/Projectiles/Ranged/OpalStrikerHoldout.cs b/Projectiles/Ranged/OpalStrikerHoldout.cs index 7a42eabdbf..54d701d687 100644 --- a/Projectiles/Ranged/OpalStrikerHoldout.cs +++ b/Projectiles/Ranged/OpalStrikerHoldout.cs @@ -1,8 +1,11 @@ -using CalamityMod.Items.Weapons.Ranged; +using System; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using ReLogic.Utilities; using Terraria; using Terraria.Audio; @@ -14,7 +17,7 @@ namespace CalamityMod.Projectiles.Ranged public class OpalStrikerHoldout : BaseGunHoldoutProjectile { public override int AssociatedItemID => ModContent.ItemType(); - public override float MaxOffsetLengthFromArm => 15f; + public override float MaxOffsetLengthFromArm => 25f; public override float OffsetXUpwards => -5f; public override float BaseOffsetY => -5f; @@ -24,10 +27,11 @@ namespace CalamityMod.Projectiles.Ranged public static float ChargedDamageMult = 5f; public static float ChargedKBMult = 3f; public static float BulletSpeed = 12f; + public int time = 0; public override void KillHoldoutLogic() { - if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type) Projectile.Kill(); } @@ -52,15 +56,40 @@ namespace CalamityMod.Projectiles.Ranged if (FullyCharged) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * ChargedDamageMult), Projectile.knockBack * ChargedKBMult, Projectile.owner); - for (int i = 0; i <= 10; i++) + for (int i = 0; i <= 35; i++) { - Dust dust = Dust.NewDustPerfect(GunTipPosition, 162, shootVelocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.8f, 1.4f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType(), shootVelocity.RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(1.6f, 2.9f), 0, default, Main.rand.NextFloat(1.6f, 2.5f)); dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + dust.fadeIn = 2.5f; + if (Main.rand.NextBool(4)) + { + dust.scale = Main.rand.NextFloat(0.8f, 0.95f); + dust.fadeIn = -0.85f; + dust.velocity /= 2; + } + } + OffsetLengthFromArm -= 25f; + Owner.SetScreenshake(5f); + + for (int i = 0; i < 2; i++) + { + Particle spark2 = new CustomSpark(GunTipPosition, Projectile.velocity * 18, "CalamityMod/Particles/BloomCircle", false, 18, 0.65f, Color.OrangeRed, new Vector2(1.2f, 0.8f), true, true, glowOpacity: 0.9f, shrinkSpeed: 0.6f); + GeneralParticleHandler.SpawnParticle(spark2); } } else + { + for (int i = 0; i <= 5; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType(), shootVelocity.RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.6f, 1.9f), 0, default, Main.rand.NextFloat(1.2f, 2f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + dust.fadeIn = 1.5f; + } + OffsetLengthFromArm -= 5f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - + } Projectile.ai[1] = 1f; } } @@ -80,31 +109,27 @@ namespace CalamityMod.Projectiles.Ranged // Charge-up visuals if (CurrentChargingFrames >= 10) { - if (!FullyCharged) - { - Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.Gold, Color.Orange, 7, GunTipPosition); - GeneralParticleHandler.SpawnParticle(streak); - } - - float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames); - Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Color.OrangeRed, orbScale / 135f, 2); - GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Coral, orbScale / 200f, 2); - GeneralParticleHandler.SpawnParticle(orb2); + float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames) / 200; + Lighting.AddLight(GunTipPosition, Color.Orange.ToVector3() * orbScale); } // Full charge dusts if (CurrentChargingFrames == OpalStriker.FullChargeFrames) { + SoundEngine.PlaySound(OpalStriker.Fire with { Pitch = 0.6f, Volume = 0.7f }, Projectile.Center); for (int i = 0; i < 36; i++) { - Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 162); - chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 13f + Owner.velocity; - chargefull.scale = Main.rand.NextFloat(2f, 2.5f); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * Main.rand.NextFloat(7, 8.5f); + chargefull.scale = Main.rand.NextFloat(1f, 1.5f); chargefull.noGravity = true; + chargefull.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; + chargefull.fadeIn = 1; } + } } + time++; } public override void OnKill(int timeLeft) @@ -115,11 +140,14 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { + if (time < 2) + return false; Texture2D texture = TextureAssets.Projectile[Type].Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition; float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); Vector2 rotationPoint = texture.Size() * 0.5f; SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + float chargeScale = KeepRefreshingLifetime ? Utils.GetLerpValue(0, OpalStriker.FullChargeFrames, CurrentChargingFrames, true) : 0; if (!Owner.CantUseHoldout()) { @@ -127,8 +155,22 @@ namespace CalamityMod.Projectiles.Ranged drawPosition += Main.rand.NextVector2Circular(rumble / 30f, rumble / 30f); } + float sine = (float)Math.Sin(time * 0.25f / MathHelper.Pi); + for (int i = 0; i < 10; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * (3f + sine * 0.3f); + Main.EntitySpriteDraw(texture, drawPosition + drawOffset * chargeScale, null, Color.OrangeRed with { A = 0 } * Math.Min(chargeScale, 1) * 0.4f, drawRotation, rotationPoint, Projectile.scale, flipSprite, 0); + } + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + Asset tex2 = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(tex2.Value, GunTipPosition - Main.screenPosition, null, Color.Lerp(FullyCharged ? Color.OrangeRed : Color.Orange, Color.White, i * 0.25f) with { A = 0 } * 0.8f, Main.rand.NextFloat(-5, 5), tex2.Size() * 0.5f, new Vector2(1.35f, 1f) * Projectile.scale * chargeScale * (1 - 0.27f * i) * 0.3f * ((chargeScale >= 1 && CurrentChargingFrames <= OpalStriker.FullChargeFrames + 3) ? 1.75f : FullyCharged ? 1.4f : 1), SpriteEffects.None, 0); + return false; } } diff --git a/Projectiles/Ranged/P90Round.cs b/Projectiles/Ranged/P90Round.cs index 1fb3cf5ea8..ca539abd9d 100644 --- a/Projectiles/Ranged/P90Round.cs +++ b/Projectiles/Ranged/P90Round.cs @@ -1,12 +1,7 @@ -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; -using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Ranged { @@ -23,7 +18,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.extraUpdates = 5; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.tileCollide = false; // Custom tile collision since the hitbox is large Projectile.ArmorPenetration = 30; } diff --git a/Projectiles/Ranged/PhotovisceratorHoldout.cs b/Projectiles/Ranged/PhotovisceratorHoldout.cs index 2fe75164e6..ad1b90aeba 100644 --- a/Projectiles/Ranged/PhotovisceratorHoldout.cs +++ b/Projectiles/Ranged/PhotovisceratorHoldout.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using static CalamityMod.Items.Weapons.Ranged.Photoviscerator; @@ -117,7 +118,7 @@ namespace CalamityMod.Projectiles.Ranged return; // Immediately killed if ammo is out - if (!Owner.HasAmmo(Owner.ActiveItem())) + if (!Owner.HasAmmo(Owner.HeldItem)) { Projectile.Kill(); return; @@ -150,7 +151,7 @@ namespace CalamityMod.Projectiles.Ranged Sound3.Pitch = 0 - (PhotoTimer * 0.002f); // Consume ammo and retrieve projectile stats; has a chance to not consume ammo - Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() <= AmmoNotConsumeChance); + Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.Next(100) < AmmoSavedPercent); var source = Projectile.GetSource_FromThis(); Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f; @@ -173,11 +174,11 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(DeadSunsWind.ShootSound with { Volume = 1.9f }, Owner.MountedCenter); } - Dust dust = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); + Dust dust = Dust.NewDustPerfect(position, DustID.PortalBolt, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.3f, 1.8f) - PhotoTimer * 0.02f; dust.color = sparkColorSmooth; - Dust dust2 = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 15).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.3f, 1.6f)); + Dust dust2 = Dust.NewDustPerfect(position, DustID.PortalBolt, (Projectile.velocity * 15).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.3f, 1.6f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(1.3f, 1.8f) - PhotoTimer * 0.02f; dust2.color = sparkColorSmooth; @@ -193,7 +194,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.NewProjectile(source, position, velocity.RotatedByRandom(0.005f), ProjectileType(), (int)(damage * (1 - PhotoTimer / 59.9f)), knockback, Projectile.owner, Main.rand.NextFloat(0f, 3f)); // Shoots light bombs every once in a while, rate of which equals to the item's use time - if (ShootTimer >= Owner.ActiveItem().useTime * 10 && PhotoTimer == 0) + if (ShootTimer >= Owner.HeldItem.useTime * 10 && PhotoTimer == 0) { ShootTimer = 0f; @@ -212,11 +213,11 @@ namespace CalamityMod.Projectiles.Ranged public void RightClickAttack(Vector2 armPosition, Vector2 verticalOffset) { // Multiplied by the ratio of attack speed gained from modifiers - ShootTimer = (RightClickCooldown * Owner.ActiveItem().useTime / (float)LightBombCooldown) - 1f; + ShootTimer = (RightClickCooldown * Owner.HeldItem.useTime / (float)LightBombCooldown) - 1f; ForcedLifespan = ShootTimer; // Consume ammo and retrieve projectile stats - Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _); + Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); var source = Projectile.GetSource_FromThis(); Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f; @@ -234,7 +235,7 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(pulse); DirectionalPulseRing pulse2 = new DirectionalPulseRing(position, (Projectile.velocity * 10).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.8f, 3.1f), sparkColor, new Vector2(1, 1), 0, Main.rand.NextFloat(0.2f, 0.35f), 0f, 40); GeneralParticleHandler.SpawnParticle(pulse2); - Dust dust = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); + Dust dust = Dust.NewDustPerfect(position, DustID.PortalBolt, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.3f, 1.8f); dust.color = sparkColor; diff --git a/Projectiles/Ranged/PiercingBullet.cs b/Projectiles/Ranged/PiercingBullet.cs index 650721a4f8..d42cf3e313 100644 --- a/Projectiles/Ranged/PiercingBullet.cs +++ b/Projectiles/Ranged/PiercingBullet.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -27,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged AIType = ProjectileID.BulletHighVelocity; Projectile.penetrate = 1; Projectile.timeLeft = 600; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) diff --git a/Projectiles/Ranged/PlagueArrow.cs b/Projectiles/Ranged/PlagueArrow.cs index f6ee408e98..144d8c151b 100644 --- a/Projectiles/Ranged/PlagueArrow.cs +++ b/Projectiles/Ranged/PlagueArrow.cs @@ -26,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.timeLeft = 600; AIType = ProjectileID.WoodenArrowFriendly; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/PlagueExplosionFriendly.cs b/Projectiles/Ranged/PlagueExplosionFriendly.cs index 51358b057d..4763d82e88 100644 --- a/Projectiles/Ranged/PlagueExplosionFriendly.cs +++ b/Projectiles/Ranged/PlagueExplosionFriendly.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -22,6 +21,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; Projectile.timeLeft = 60; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Ranged/PlagueTaintedDrone.cs b/Projectiles/Ranged/PlagueTaintedDrone.cs index c364af3ef6..e0f144dd43 100644 --- a/Projectiles/Ranged/PlagueTaintedDrone.cs +++ b/Projectiles/Ranged/PlagueTaintedDrone.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -121,7 +118,7 @@ namespace CalamityMod.Projectiles.Ranged public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (target.Calamity().pFlames > 0) + if (target.Calamity().plague) { if (Projectile.ai[1] == 1) return; diff --git a/Projectiles/Ranged/PlagueTaintedProjectile.cs b/Projectiles/Ranged/PlagueTaintedProjectile.cs index 1c24282b48..fdc6f744a5 100644 --- a/Projectiles/Ranged/PlagueTaintedProjectile.cs +++ b/Projectiles/Ranged/PlagueTaintedProjectile.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -30,7 +29,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 600; Projectile.extraUpdates = 2; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/PlanarRipperBolt.cs b/Projectiles/Ranged/PlanarRipperBolt.cs index 49223801bc..da0808050a 100644 --- a/Projectiles/Ranged/PlanarRipperBolt.cs +++ b/Projectiles/Ranged/PlanarRipperBolt.cs @@ -32,7 +32,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.aiStyle = ProjAIStyleID.Arrow; AIType = ProjectileID.BulletHighVelocity; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/PlanarRipperExplosion.cs b/Projectiles/Ranged/PlanarRipperExplosion.cs index 683b641017..76fdaf1750 100644 --- a/Projectiles/Ranged/PlanarRipperExplosion.cs +++ b/Projectiles/Ranged/PlanarRipperExplosion.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/PlasmaBlast.cs b/Projectiles/Ranged/PlasmaBlast.cs deleted file mode 100644 index af1049f2ba..0000000000 --- a/Projectiles/Ranged/PlasmaBlast.cs +++ /dev/null @@ -1,114 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class PlasmaBlast : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 10; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 10; - Projectile.alpha = 150; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; - Projectile.penetrate = 1; - Projectile.timeLeft = 600; - Projectile.ignoreWater = true; - } - - public override void AI() - { - if (Projectile.soundDelay == 0) - { - Projectile.soundDelay = 20 + Main.rand.Next(40); - SoundEngine.PlaySound(SoundID.Item9, Projectile.position); - } - - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] == 12f) - { - Projectile.localAI[0] = 0f; - for (int l = 0; l < 12; l++) - { - Vector2 dustVel = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - dustVel += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - dustVel = dustVel.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); - int dust = Dust.NewDust(Projectile.Center, 0, 0, DustID.FireworkFountain_Blue, 0f, 0f, 160, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position = Projectile.Center + dustVel; - Main.dust[dust].velocity = Projectile.velocity * 0.1f; - Main.dust[dust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dust].position) * 1.25f; - } - } - - Projectile.alpha -= 15; - int alphaControl = 150; - if (Projectile.Center.Y >= Projectile.ai[1]) - alphaControl = 0; - if (Projectile.alpha < alphaControl) - Projectile.alpha = alphaControl; - - Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - - if (Main.rand.NextBool(16)) - { - Vector2 extraDustVel = Vector2.UnitX.RotatedByRandom(MathHelper.PiOver2).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int extraDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.FireworkFountain_Blue, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); - Main.dust[extraDust].velocity = extraDustVel * 0.66f; - Main.dust[extraDust].position = Projectile.Center + extraDustVel * 12f; - } - - if (Main.rand.NextBool(48) && !Main.dedServ) - { - int gore = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[gore].velocity *= 0.66f; - Main.gore[gore].velocity += Projectile.velocity * 0.3f; - } - - if (Projectile.ai[1] == 1f) - { - Projectile.light = 0.9f; - if (Main.rand.NextBool(10)) - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.FireworkFountain_Blue, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); - if (Main.rand.NextBool(20) && !Main.dedServ) - Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.position, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); - } - - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.1f / 255f, (255 - Projectile.alpha) * 0.7f / 255f, (255 - Projectile.alpha) * 0.15f / 255f); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override void OnKill(int timeLeft) - { - if (Projectile.ai[0] == 1f) - return; - - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - - SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - } - } -} diff --git a/Projectiles/Ranged/PlasmaBlast.png b/Projectiles/Ranged/PlasmaBlast.png deleted file mode 100644 index cafdce830a..0000000000 Binary files a/Projectiles/Ranged/PlasmaBlast.png and /dev/null differ diff --git a/Projectiles/Ranged/PlasmaExplosion.cs b/Projectiles/Ranged/PlasmaExplosion.cs index 47b172c2d7..5cdb2263cb 100644 --- a/Projectiles/Ranged/PlasmaExplosion.cs +++ b/Projectiles/Ranged/PlasmaExplosion.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -23,7 +22,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; Projectile.timeLeft = 5; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 1; + Projectile.localNPCHitCooldown = -1; } public override void AI() @@ -34,62 +33,14 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item93, Projectile.position); Projectile.localAI[0] += 1f; } - bool xflag = false; - bool yflag = false; - if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) + + for (int i = 0; i < 20; i++) { - xflag = true; + Vector2 randDirection = new Vector2(Main.rand.NextFloat(-40f, 40f), Main.rand.NextFloat(-40f, 40f)); + randDirection = randDirection.SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(12f, 35f); + Dust stardust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 1f ? 173 : 221, randDirection, 100, Scale: 2f); + stardust.noGravity = true; } - if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) - { - xflag = true; - } - if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) - { - yflag = true; - } - if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) - { - yflag = true; - } - if (xflag && yflag) - { - Projectile.Kill(); - } - float projTimer = 25f; - if (Projectile.ai[0] > 180f) - { - projTimer -= (Projectile.ai[0] - 180f) / 2f; - } - if (projTimer <= 0f) - { - projTimer = 0f; - Projectile.Kill(); - } - projTimer *= 0.7f; - Projectile.ai[0] += 4f; - int timerCounter = 0; - while ((float)timerCounter < projTimer) - { - float rand1 = (float)Main.rand.Next(-40, 41); - float rand2 = (float)Main.rand.Next(-40, 41); - float rand3 = (float)Main.rand.Next(12, 36); - float randAdjust = (float)Math.Sqrt((double)(rand1 * rand1 + rand2 * rand2)); - randAdjust = rand3 / randAdjust; - rand1 *= randAdjust; - rand2 *= randAdjust; - int dustID = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Projectile.ai[1] == 1f ? 173 : 221, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[dustID]; - dust.noGravity = true; - dust.position.X = Projectile.Center.X; - dust.position.Y = Projectile.Center.Y; - dust.position.X += (float)Main.rand.Next(-10, 11); - dust.position.Y += (float)Main.rand.Next(-10, 11); - dust.velocity.X = rand1; - dust.velocity.Y = rand2; - timerCounter++; - } - return; } } } diff --git a/Projectiles/Ranged/PrecisionBolt.cs b/Projectiles/Ranged/PrecisionBolt.cs index 4b11483a72..28aa43a090 100644 --- a/Projectiles/Ranged/PrecisionBolt.cs +++ b/Projectiles/Ranged/PrecisionBolt.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Ranged } } - Dust trail = Dust.NewDustPerfect(Projectile.Center, 267); //Dust trail kinda poopy but idk how to make a cool trail :( + Dust trail = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); //Dust trail kinda poopy but idk how to make a cool trail :( trail.velocity = Vector2.Zero; trail.color = Color.Yellow; trail.scale = Main.rand.NextFloat(1f, 1.1f); @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item94, Projectile.Center); for (int i = 0; i < 10; i++) { - Dust zap = Dust.NewDustPerfect(Projectile.Center, 267); + Dust zap = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); zap.velocity = Projectile.velocity; zap.color = Color.Yellow; zap.scale = Main.rand.NextFloat(1f, 1.1f); diff --git a/Projectiles/Ranged/PressurizedBubbleStream.cs b/Projectiles/Ranged/PressurizedBubbleStream.cs index 4b593181e5..e6ab06cd98 100644 --- a/Projectiles/Ranged/PressurizedBubbleStream.cs +++ b/Projectiles/Ranged/PressurizedBubbleStream.cs @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < numDust; i++) { Vector2 ringSpeed = new Vector2((float)Math.Cos(i / (float)numDust * MathHelper.TwoPi), (float)Math.Sin(i / (float)numDust * MathHelper.TwoPi) * 0.5f).RotatedBy(Projectile.velocity.ToRotation() + MathHelper.PiOver2) * (3.5f * (1 - Progress) + 3f); - Dust ringDust = Dust.NewDustPerfect(Projectile.position, 211, ringSpeed, 100, default, 1.25f); + Dust ringDust = Dust.NewDustPerfect(Projectile.position, DustID.Wet, ringSpeed, 100, default, 1.25f); ringDust.noGravity = true; } diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.cs b/Projectiles/Ranged/PrismaticEnergyBlast.cs index e7f29f76f0..a30ef78454 100644 --- a/Projectiles/Ranged/PrismaticEnergyBlast.cs +++ b/Projectiles/Ranged/PrismaticEnergyBlast.cs @@ -40,6 +40,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 100; Projectile.extraUpdates = 1; Projectile.timeLeft = 450; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool PreAI() @@ -71,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged public override float DetermineLaserLength() { if (Projectile.penetrate == 100) - return DetermineLaserLength_CollideWithTiles(8); + return DetermineLaserLength_CollideWithTiles(); return LaserLength; } diff --git a/Projectiles/Ranged/PristineFire.cs b/Projectiles/Ranged/PristineFire.cs index 38a8616c6e..6d321b5b86 100644 --- a/Projectiles/Ranged/PristineFire.cs +++ b/Projectiles/Ranged/PristineFire.cs @@ -1,15 +1,10 @@ using System; -using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -62,7 +57,7 @@ namespace CalamityMod.Projectiles.Ranged for (int x = 0; x < Main.maxProjectiles; x++) { Projectile projectile = Main.projectile[x]; - if (Vector2.Distance(Projectile.Center, projectile.Center) <= 100 && projectile.active && projectile.type == ModContent.ProjectileType() && projectile.Opacity > 0.5f) + if (Vector2.Distance(Projectile.Center, projectile.Center) <= 100 && projectile.active && projectile.type == ModContent.ProjectileType() && projectile.Opacity > 0.7f) { if (projectile.ai[2] == 0) { @@ -81,6 +76,10 @@ namespace CalamityMod.Projectiles.Ranged time--; } + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + //On Pristine Fury, the full 20 seconds is limited to the ignition of the secondary. public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/PristineSecondary.cs b/Projectiles/Ranged/PristineSecondary.cs index da8d891e33..876f0a59a8 100644 --- a/Projectiles/Ranged/PristineSecondary.cs +++ b/Projectiles/Ranged/PristineSecondary.cs @@ -3,12 +3,10 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; -using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -50,7 +48,8 @@ namespace CalamityMod.Projectiles.Ranged { // Xyk: "This is probably too much lol" // Yeah I'd say 7x base damage is a bit much - Projectile.damage *= 4; + // Xyk: Follow up, the inital damage is nerfed AND it has a "cooldown" 7x should now be fine... + Projectile.damage *= (int)7; FogColor = Color.Lerp(Color.OrangeRed, Color.Goldenrod, Main.rand.NextFloat()); SoundStyle ignite = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyBlastImpact"); @@ -125,7 +124,10 @@ namespace CalamityMod.Projectiles.Ranged { if (Ignited) { - target.AddBuff(ModContent.BuffType(), 420); + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + target.AddBuff(ModContent.BuffType(), 1200); } } diff --git a/Projectiles/Ranged/PumplerGrenade.cs b/Projectiles/Ranged/PumplerGrenade.cs index 04ff44cbea..422818de55 100644 --- a/Projectiles/Ranged/PumplerGrenade.cs +++ b/Projectiles/Ranged/PumplerGrenade.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; Projectile.DamageType = DamageClass.Ranged; Projectile.ignoreWater = true; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 20; diff --git a/Projectiles/Ranged/PumplerHoldout.cs b/Projectiles/Ranged/PumplerHoldout.cs index 7333516569..5619c8286d 100644 --- a/Projectiles/Ranged/PumplerHoldout.cs +++ b/Projectiles/Ranged/PumplerHoldout.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -88,7 +87,7 @@ namespace CalamityMod.Projectiles.Ranged // Frame 1 effects: Initialize the shoot speed if (FramesToLoadNextPumpkin == 0f) { - FramesToLoadNextPumpkin = Owner.ActiveItem().useAnimation; + FramesToLoadNextPumpkin = Owner.HeldItem.useAnimation; } // Actually make progress towards loading more arrows. Also, make smoke come out eventually perhaps ++CurrentChargingFrames; @@ -149,7 +148,7 @@ namespace CalamityMod.Projectiles.Ranged } SoundEngine.PlaySound(SoundID.Item96);//play the sound SmokeBurst(tipPosition); - FramesToLoadNextPumpkin = Owner.ActiveItem().useAnimation; //reset the reload time + FramesToLoadNextPumpkin = Owner.HeldItem.useAnimation; //reset the reload time PumpkinsCharge = 0; //Unload the barrel if (!IsOverfilled) Overfilled = 1f; //Make the shoot anim play @@ -161,7 +160,7 @@ namespace CalamityMod.Projectiles.Ranged if (Main.myPlayer != Projectile.owner) return; - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; int projectileType = ModContent.ProjectileType(); int PumpkinDamage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); float shootSpeed = heldItem.shootSpeed * 1.5f; diff --git a/Projectiles/Ranged/RealmRavagerBullet.cs b/Projectiles/Ranged/RealmRavagerBullet.cs index 76570d8ccd..2b74fcb9f6 100644 --- a/Projectiles/Ranged/RealmRavagerBullet.cs +++ b/Projectiles/Ranged/RealmRavagerBullet.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 3; Projectile.penetrate = 1; Projectile.timeLeft = 90; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/RicoshotCoin.cs b/Projectiles/Ranged/RicoshotCoin.cs index b8090108e7..f8f2a35d1e 100644 --- a/Projectiles/Ranged/RicoshotCoin.cs +++ b/Projectiles/Ranged/RicoshotCoin.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Items; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -243,7 +244,8 @@ namespace CalamityMod.Projectiles.Ranged _ => ItemID.CopperCoin, }; int coin = Item.NewItem(Projectile.GetSource_DropAsItem(), Projectile.Center, Vector2.One, itemID, noBroadcast: false); - Main.item[coin].Calamity().grabRangeMultiplier = UsedCoinGrabRangeMultiplier; + if (Main.item[coin].TryGetGlobalItem(out var grabRangeItem)) + grabRangeItem.grabRangeMultiplier = UsedCoinGrabRangeMultiplier; // Sync this dropped coin in multiplayer. if (Main.netMode == NetmodeID.MultiplayerClient) diff --git a/Projectiles/Ranged/RiftburstBow.cs b/Projectiles/Ranged/RiftburstBow.cs index 5c6196bf96..baaa0dc66b 100644 --- a/Projectiles/Ranged/RiftburstBow.cs +++ b/Projectiles/Ranged/RiftburstBow.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged fullSpeed = true; int arg_1EF4_0 = (int)Projectile.ai[0] / (delayCompare - fireSpeedCompare * fireSpeed); } - bool canUseItem = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem()); + bool canUseItem = !player.CantUseHoldout() && player.HasAmmo(player.HeldItem); if (Projectile.localAI[0] > 0f) { Projectile.localAI[0] -= 1f; @@ -79,13 +79,13 @@ namespace CalamityMod.Projectiles.Ranged { int ammoType = ProjectileID.WoodenArrowFriendly; float scaleFactor11 = 14f; - int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); - float weaponKnockback2 = player.ActiveItem().knockBack; + int weaponDamage2 = player.GetWeaponDamage(player.HeldItem); + float weaponKnockback2 = player.HeldItem.knockBack; if (canUseItem) { - player.PickAmmo(player.ActiveItem(), out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); - weaponKnockback2 = player.GetWeaponKnockback(player.ActiveItem(), weaponKnockback2); - float scaleFactor12 = player.ActiveItem().shootSpeed * Projectile.scale; + player.PickAmmo(player.HeldItem, out ammoType, out scaleFactor11, out weaponDamage2, out weaponKnockback2, out _); + weaponKnockback2 = player.GetWeaponKnockback(player.HeldItem, weaponKnockback2); + float scaleFactor12 = player.HeldItem.shootSpeed * Projectile.scale; Vector2 shootDirection = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerRotation; if (player.gravDir == -1f) { diff --git a/Projectiles/Ranged/RocketFire.cs b/Projectiles/Ranged/RocketFire.cs index 899990b1ac..e6b3ee1246 100644 --- a/Projectiles/Ranged/RocketFire.cs +++ b/Projectiles/Ranged/RocketFire.cs @@ -1,4 +1,6 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,11 +13,11 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Projectiles/Rogue/TotalityFire"; private bool initialized = false; + public static Asset Glow; public override void SetStaticDefaults() { Main.projFrames[Type] = 3; ProjectileID.Sets.TrailCacheLength[Type] = 2; - ProjectileID.Sets.TrailingMode[Type] = 0; } public override void SetDefaults() @@ -60,7 +62,6 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.frame = 0; } - //movement if (Projectile.velocity.X != Projectile.velocity.X) { @@ -99,9 +100,9 @@ namespace CalamityMod.Projectiles.Ranged } //dust - if (Main.rand.NextBool(4)) + if (Main.rand.NextBool(3)) { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); + int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool() ? DustID.Torch : Main.rand.NextBool() ? 53 : 54, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[fire]; dust.position.X -= 2f; dust.position.Y += 2f; @@ -109,9 +110,9 @@ namespace CalamityMod.Projectiles.Ranged dust.noGravity = true; dust.velocity.Y -= 2f; } - if (Main.rand.NextBool(10)) + if (Main.rand.NextBool(6)) { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); + int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool() ? DustID.Torch : Main.rand.NextBool() ? 53 : 54, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[fire]; dust.position.X -= 2f; dust.position.Y += 2f; @@ -120,6 +121,17 @@ namespace CalamityMod.Projectiles.Ranged dust.velocity *= 0.1f; } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.Daybreak, 300); + target.AddBuff(BuffID.Oiled, 300); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(BuffID.Daybreak, 300); + target.AddBuff(BuffID.Oiled, 300); + } public override bool OnTileCollide(Vector2 oldVelocity) { diff --git a/Projectiles/Ranged/RubicoPrimeMag.cs b/Projectiles/Ranged/RubicoPrimeMag.cs index 0a4d72860d..6215c09e65 100644 --- a/Projectiles/Ranged/RubicoPrimeMag.cs +++ b/Projectiles/Ranged/RubicoPrimeMag.cs @@ -1,13 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Projectiles.Ranged { diff --git a/Projectiles/Ranged/SandblasterBullet.cs b/Projectiles/Ranged/SandblasterBullet.cs index 7bdf86ebc3..cd1595833a 100644 --- a/Projectiles/Ranged/SandblasterBullet.cs +++ b/Projectiles/Ranged/SandblasterBullet.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -29,7 +28,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 1; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.alpha = 255; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/ScorchedEarthBlast.cs b/Projectiles/Ranged/ScorchedEarthBlast.cs deleted file mode 100644 index 7673ef7306..0000000000 --- a/Projectiles/Ranged/ScorchedEarthBlast.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class ScorchedEarthBlast : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - private static int Lifetime = 20; - private static float ExplosionRadius = 150f; - private static float StartDustQuantity = 36f; - - public override void SetDefaults() - { - // Width and height don't actually do anything because the explosion uses custom collision - Projectile.width = Projectile.height = 300; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.penetrate = -1; - Projectile.timeLeft = Lifetime; - - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - // localAI[0] = frame counter - // localAI[1] = dust quantity - public override void AI() - { - // Play sound on frame 1 and initialize dust quantity - if (Projectile.localAI[0] == 0f) - { - Projectile.localAI[1] = StartDustQuantity; - } - - // Pure dust projectile - DrawProjectile(); - - // Increment frame counter - Projectile.localAI[0] += 1f; - } - - private void DrawProjectile() - { - // Taper down the dust amount for the last bit of the projectile's life - if (Projectile.localAI[0] >= Lifetime - 15) - Projectile.localAI[1] -= 1f; - - int dustCount = (int)Projectile.localAI[1]; - for (int i = 0; i < dustCount; ++i) - { - int dustType = Main.rand.NextBool() ? 6 : 244; - float scale = Main.rand.NextFloat(2.0f, 2.5f); - float randX = Main.rand.NextFloat(-30f, 30f); - float randY = Main.rand.NextFloat(-30f, 30f); - float randVelocity = Main.rand.NextFloat(5f, 19f); - float speed = (float)Math.Sqrt((double)(randX * randX + randY * randY)); - speed = randVelocity / speed; - randX *= speed; - randY *= speed; - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType); - Main.dust[idx].position.X = Projectile.Center.X + Main.rand.NextFloat(-10f, 10f); - Main.dust[idx].position.Y = Projectile.Center.Y + Main.rand.NextFloat(-10f, 10f); - Main.dust[idx].velocity.X = randX; - Main.dust[idx].velocity.Y = randY; - Main.dust[idx].scale = scale; - Main.dust[idx].noGravity = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.Daybreak, 300); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); - } -} diff --git a/Projectiles/Ranged/ScorchedEarthClusterBomb.cs b/Projectiles/Ranged/ScorchedEarthClusterBomb.cs index 2127a50d88..c81b851c14 100644 --- a/Projectiles/Ranged/ScorchedEarthClusterBomb.cs +++ b/Projectiles/Ranged/ScorchedEarthClusterBomb.cs @@ -1,4 +1,6 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -8,6 +10,7 @@ namespace CalamityMod.Projectiles.Ranged public class ScorchedEarthClusterBomb : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public Vector2 vibrate = Vector2.Zero; public override void SetDefaults() { Projectile.width = 14; @@ -27,14 +30,25 @@ namespace CalamityMod.Projectiles.Ranged Projectile.velocity *= 0.95f; if (Projectile.velocity.Length() < 0.5f && Projectile.timeLeft > 10) Projectile.timeLeft = 10; + if (Projectile.timeLeft <= 75) + { + float power = 2.5f; + vibrate = Main.rand.NextVector2Circular(power, power); + } } public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int i = 0; i < 10; i++) + SoundEngine.PlaySound(SoundID.Item62 with { Volume = 0.8f , MaxInstances = 3}, Projectile.position); + for (int i = 0; i < 15; i++) { - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 0, default, 1f); + int size = 16; + Vector2 position = Projectile.Center; + Vector2 velocity = Main.rand.NextVector2Circular(size, size); + SquishyLightParticle energy = new(position, velocity, Main.rand.NextFloat(0.2f, 0.3f), Color.DarkOrange * 0.5f, Main.rand.Next(6, 9), 1, 1.5f); + GeneralParticleHandler.SpawnParticle(energy); + Dust dust = Dust.NewDustPerfect(position, DustID.Torch, velocity, 0, default, Main.rand.NextFloat(1f, 2f)); + dust.noGravity = true; } int projAmt = Main.rand.Next(2, 4); if (Projectile.owner == Main.myPlayer) @@ -46,5 +60,15 @@ namespace CalamityMod.Projectiles.Ranged } } } + public override bool PreDraw(ref Color lightColor) + { + Texture2D Texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle frame = Texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Vector2 drawPosition; + Vector2 origin = frame.Size() * 0.5f; + drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(Texture, drawPosition + vibrate, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + return false; + } } } diff --git a/Projectiles/Ranged/ScorchedEarthHoldout.cs b/Projectiles/Ranged/ScorchedEarthHoldout.cs new file mode 100644 index 0000000000..67fe2cbcfe --- /dev/null +++ b/Projectiles/Ranged/ScorchedEarthHoldout.cs @@ -0,0 +1,110 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Ranged.ScorchedEarth; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ScorchedEarthHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => base.GunTipPosition - Vector2.UnitY.RotatedBy(Projectile.rotation) * 5f * Projectile.spriteDirection * Owner.gravDir; + public override float RecoilResolveSpeed => 0.1f; + public override float MaxOffsetLengthFromArm => 15f; + public override float OffsetXUpwards => -12f; + public override float OffsetXDownwards => 2f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 10f; + + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float TimerBetweenBursts => ref Projectile.ai[1]; + + public override void HoldoutAI() + { + + if (ShootingTimer >= HeldItem.useAnimation) + { + // Shooting the burst of rockets. + // The time is adapted to the speed modifier from the reforge. + int adaptedTimeBetweenBursts = TimeBetweenBursts * HeldItem.useAnimation / OriginalUseTime; + + if (ShootingTimer % adaptedTimeBetweenBursts == 0f) + ShootRocket(HeldItem, false); + + // Resets the timers when everything has been shot. + if (ShootingTimer >= HeldItem.useAnimation + adaptedTimeBetweenBursts * (ProjectilesPerBurst - 1)) + { + ShootingTimer = 0f; + TimerBetweenBursts = 0f; + } + if (Main.dedServ) + return; + Vector2 smokeVel = new Vector2(0, -8) * Main.rand.NextFloat(0.1f, 1.1f); + Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel, Main.rand.NextBool() ? Color.DarkSlateGray : Color.DarkGray, 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); + //Visual request from the donor that I tried and didn't end up liking. This is commented and not deleted in case the donor really wants this effect + //for (int i = 0; i < 2; i++) + { + //Vector2 backsmokeVel = new Vector2(6, -2) * Main.rand.NextFloat(0.1f, 1.1f); + //Particle backsmoke = new HeavySmokeParticle(GunTipPosition + (-Projectile.velocity * 110f), -Projectile.velocity.SafeNormalize(Vector2.UnitY) * backsmokeVel, Main.rand.NextBool() ? Color.DarkSlateGray : Color.Black, Main.rand.Next(20, 30 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + //GeneralParticleHandler.SpawnParticle(backsmoke); + } + } + + ShootingTimer++; + } + + public void ShootRocket(Item item, bool isRMB) + { + // We use the velocity of this projectile as its direction vector. + Vector2 projectileVelocity = Projectile.velocity.SafeNormalize(Vector2.Zero); + + // Every time we shoot we use ammo. + // With this method we also use the item's stats, like the shoot speed, or the type of ammo it was used. + Owner.PickAmmo(item, out _, out float projSpeed, out int damage, out float knockback, out int rocketType); + + // Spawns the projectile. + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 12; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(10f)), ModContent.ProjectileType(), damage, knockback, Projectile.owner, rocketType); + + // Inside here go all the things that dedicated servers shouldn't spend resources on. + // Like visuals and sounds. + if (Main.dedServ) + return; + SoundEngine.PlaySound(RocketShoot with { Pitch = 0.045f }, Projectile.Center); + + // By decreasing the offset length of the gun from the arms, we give an effect of recoil. + OffsetLengthFromArm -= 7f; + + Particle shootPulse = new DirectionalPulseRing(GunTipPosition,Vector2.Zero,Color.Gray * 0.7f,new Vector2(0.5f, 1f),Projectile.rotation, 0.1f, 0.4f, 25); + GeneralParticleHandler.SpawnParticle(shootPulse); + for (int i = 0; i <= 8; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(3) ? 303 : 244, (shootVelocity * Main.rand.NextFloat(0.2f, 1.1f)).RotatedByRandom(0.4f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.8f, 1.4f); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } + } +} diff --git a/Projectiles/Ranged/ScorchedEarthRocket.cs b/Projectiles/Ranged/ScorchedEarthRocket.cs index d806b0180c..4313ba0061 100644 --- a/Projectiles/Ranged/ScorchedEarthRocket.cs +++ b/Projectiles/Ranged/ScorchedEarthRocket.cs @@ -1,4 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -8,123 +11,228 @@ namespace CalamityMod.Projectiles.Ranged public class ScorchedEarthRocket : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public int time = 0; + public bool BonusEffectMode; + public bool HasHit = false; + public bool SetLifetime = false; + public static readonly SoundStyle RocketExplosion = new("CalamityMod/Sounds/Item/AnomalysNanogunMPFBExplosion"); + public ref float RocketID => ref Projectile.ai[0]; + public override void SetStaticDefaults() { Main.projFrames[Type] = 10; ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 3; - ProjectileID.Sets.TrailingMode[Type] = 0; } public override void SetDefaults() { - Projectile.width = 22; - Projectile.height = 22; + Projectile.width = Projectile.height = 34; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; - Projectile.tileCollide = false; - Projectile.extraUpdates = 1; } public override void AI() { - //Lighting - Lighting.AddLight(Projectile.Center, 1f, 0.79f, 0.3f); - - //Animation - Projectile.frameCounter++; - if (Projectile.frameCounter > (Projectile.frame == 1 ? 10 : 7)) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } + //Rotation + Projectile.rotation = Projectile.velocity.ToRotation(); + //If the frame ever goes over 10, return it to 6 if (Projectile.frame >= Main.projFrames[Type]) { Projectile.frame = 6; } + //For the first 20 frames, the rocket constantly loses velocity and stays on frame 0 + if (time <= 20) + { + Projectile.velocity *= 0.9f; + Projectile.frame = 0; + Projectile.frameCounter = 0; + } + //Ensures the prime sound only plays once + if (time == 24) + { + SoundStyle PrimeSound = new("CalamityMod/Sounds/Item/ScorchedEarthShot", 3) { Volume = 0.25f, MaxInstances = 8 }; + SoundEngine.PlaySound(PrimeSound with { Pitch = -0.1f }, Projectile.Center); + } + //Be VERY CAREFUL changing this. The rocket quickly gains speed for a very limited amount of time to make sure it doesn't go too fast + if (time > 24 && time < 34) + { + Projectile.velocity *= 1.5f; + } + //All of these effects only trigger once the rocket is speeding up + if (time >= 24) + { + //Lighting + Lighting.AddLight(Projectile.Center, 1f, 0.79f, 0.3f); + Projectile.frameCounter++; + if (Projectile.frameCounter >= 5) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame >= Main.projFrames[Type]) + { + Projectile.frame = 6; + } + } + } + //After the rocket has reached full speed, give it homing for half a second + if (time >= 37 && time < 67) + { + CalamityUtils.HomeInOnNPC(Projectile, true, 350f, 20f, 6f); + } + //Handling Tile Breaking/Liquid Rockets + BonusEffectMode = Projectile.ai[2] == 2; + if (BonusEffectMode) + { + if (!SetLifetime) + { + Projectile.timeLeft = 60; + Projectile.extraUpdates = 0; + Projectile.damage = 0; + Projectile.alpha = 255; + SetLifetime = true; + } + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII) + { - CalamityUtils.HomeInOnNPC(Projectile, true, 400f, 5f, 30f); + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); + int blastRadius = (int)(Projectile.RocketBehavior(info) * 3f); + if (time % 5 == 0) + { + Projectile.ExplodeTiles((int)(blastRadius * Utils.Remap(time, 60f, 1f, 1f, 0f, true)), info.respectStandardBlastImmunity, info.tilesToCheck, info.wallsToCheck); + } + } + else + { + Point center = Projectile.Center.ToTileCoordinates(); + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); + int blastRadius = Projectile.RocketBehavior(info); + if (RocketID == ItemID.DryRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadDry); + } + } + if (RocketID == ItemID.WetRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadWater); + } + } + if (RocketID == ItemID.LavaRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadLava); + } + } + if (RocketID == ItemID.HoneyRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadHoney); + } + } + } + } + time++; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + HasHit = true; + Projectile.netUpdate = true; + } - //Rotation - Projectile.rotation = Projectile.velocity.ToRotation(); + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + HasHit = true; + Projectile.netUpdate = true; + } - float xVel = Projectile.velocity.X * 0.5f; - float yVel = Projectile.velocity.Y * 0.5f; - int d = Dust.NewDust(new Vector2(Projectile.position.X + 3f + xVel, Projectile.position.Y + 3f + yVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.CopperCoin, 0f, 0f, 100, default, 1f); - Main.dust[d].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[d].velocity *= 0.2f; - Main.dust[d].noGravity = true; - d = Dust.NewDust(new Vector2(Projectile.position.X + 3f + xVel, Projectile.position.Y + 3f + yVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.CopperCoin, 0f, 0f, 100, default, 0.5f); - Main.dust[d].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[d].velocity *= 0.05f; + public override bool OnTileCollide(Vector2 oldVelocity) + { + HasHit = true; + Projectile.netUpdate = true; + return true; } public override void OnKill(int timeLeft) { - if (Projectile.owner == Main.myPlayer) + if (HasHit == true && !BonusEffectMode && Projectile.ai[2] == 0) { - Projectile.ExpandHitboxBy(300); - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - - if (!Main.dedServ) + if (Projectile.owner == Main.myPlayer) { - Vector2 goreSource = Projectile.Center; - int goreAmt = 10; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) + bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); + //If using a rocket with extra effects, spawn an invisible copy that handes the tile breaking/liquid spawning logic + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII || RocketID == ItemID.DryRocket || RocketID == ItemID.WetRocket || RocketID == ItemID.LavaRocket || RocketID == ItemID.HoneyRocket) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, RocketID, 0f, 2f); + // Create Blast + float blastSize = 300; + float minMultiplier = 0.25f; + int hitsToMinMult = 4; + int debuff1 = BuffID.Daybreak; + int debuff2 = BuffID.Oiled; + int debuffTime = 360; + //The explosion has a different damage scaling depending on which rocket type you have. Left is Cluster Rocket, right is Non-Cluster. + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.75f : 1)), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff1; + blast.localAI[2] = debuff2; + blast.localAI[1] = debuffTime; + blast.timeLeft = 15; + blast.DamageType = DamageClass.Ranged; + for (int j = 0; j < (isClusterRocket ? 9 : 5); j++) { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; + Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); } } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 2f, Projectile.owner); - for (int j = 0; j < 5; j++) + // Handle FX for all clients + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + SoundEngine.PlaySound(RocketExplosion with { MaxInstances = 2 }, Projectile.Center); + + for (int i = 0; i < 15; i++) { - Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); + Vector2 randVel = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.6f); + Particle smoke = new HeavySmokeParticle(Projectile.Center + randVel, randVel, Color.Black, Main.rand.Next(20, 25 + 1), Main.rand.NextFloat(0.9f, 2.3f), 0.7f); + GeneralParticleHandler.SpawnParticle(smoke); + } + + for (int i = 0; i < 2; i++) + { + //Explosion effect + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.OrangeRed : Color.DarkGoldenrod * 0.8f, "CalamityMod/Particles/ShineExplosion1", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.2f, 20, true, 1.4f); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.18f, 20, true, 1f); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f, 1.8f, 25, true); + GeneralParticleHandler.SpawnParticle(blastRing3); + Particle blastRing4 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.8f, 25, true); + GeneralParticleHandler.SpawnParticle(blastRing4); + Particle blastRing5 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.13f, 20, true, 1f); + GeneralParticleHandler.SpawnParticle(blastRing5); } } } - public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + if (time < 1) + return false; + Texture2D Texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle frame = Texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Vector2 drawPosition; + Vector2 origin = frame.Size() * 0.5f; + + drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(Texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Ranged/ScorpioHoldout.cs b/Projectiles/Ranged/ScorpioHoldout.cs index ea27ca7445..6564d46342 100644 --- a/Projectiles/Ranged/ScorpioHoldout.cs +++ b/Projectiles/Ranged/ScorpioHoldout.cs @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 2; i++) { - Dust dust = Dust.NewDustPerfect(position, 303, velocity * 0.5f, 200, default, Main.rand.NextFloat(0.9f, 1.3f)); + Dust dust = Dust.NewDustPerfect(position, DustID.SteampunkSteam, velocity * 0.5f, 200, default, Main.rand.NextFloat(0.9f, 1.3f)); dust.noGravity = false; } } @@ -143,16 +143,19 @@ namespace CalamityMod.Projectiles.Ranged } // Spawns the projectile. - Projectile.NewProjectile( - Projectile.GetSource_FromThis(), - GunTipPosition, - projectileVelocity.RotatedByRandom(isRMB ? 0f : MathHelper.PiOver4) * projSpeed * (isRMB ? 1f : Main.rand.NextFloat(0.8f, 1f)), - isRMB ? ProjectileType() : ProjectileType(), - damage, - knockback, - Projectile.owner, - rocketType, - projSpeed); + if (Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectile( + Projectile.GetSource_FromThis(), + GunTipPosition, + projectileVelocity.RotatedByRandom(isRMB ? 0f : MathHelper.PiOver4) * projSpeed * (isRMB ? 1f : Main.rand.NextFloat(0.8f, 1f)), + isRMB ? ProjectileType() : ProjectileType(), + damage, + knockback, + Projectile.owner, + rocketType, + projSpeed); + } // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. diff --git a/Projectiles/Ranged/ScorpioLargeRocket.cs b/Projectiles/Ranged/ScorpioLargeRocket.cs index 0e6e837318..47d5d13f2d 100644 --- a/Projectiles/Ranged/ScorpioLargeRocket.cs +++ b/Projectiles/Ranged/ScorpioLargeRocket.cs @@ -202,11 +202,11 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.numHits < 1) - Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 6f; + Main.player[Projectile.owner].SetScreenshake(6f); } - public float TrailWidthFunction(float completionRatio) => Utils.Remap(completionRatio, 0f, 0.8f, 15f, 0f); - public Color TrailColorFunction(float completionRatio) => Color.Lerp(EffectsColor, EffectsColor * 0.3f, Utils.GetLerpValue(0f, 0.8f, completionRatio)) * Utils.GetLerpValue(255f, 0f, Projectile.alpha); + public float TrailWidthFunction(float completionRatio, Vector2 vertexPos) => Utils.Remap(completionRatio, 0f, 0.8f, 15f, 0f); + public Color TrailColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(EffectsColor, EffectsColor * 0.3f, Utils.GetLerpValue(0f, 0.8f, completionRatio)) * Utils.GetLerpValue(255f, 0f, Projectile.alpha); public override bool PreDraw(ref Color lightColor) { @@ -219,8 +219,8 @@ namespace CalamityMod.Projectiles.Ranged Vector2 rotationPoint = frame.Size() * 0.5f; // 29FEB2024: Ozzatron: hopefully ported this correctly to the new prim system by Toasty - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidthFunction, TrailColorFunction, (_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 25); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidthFunction, TrailColorFunction, (_,_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 25); Main.EntitySpriteDraw(texture, drawPosition, frame, drawColor, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); Main.EntitySpriteDraw(glowTexture, drawPosition, frame, Color.White, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); diff --git a/Projectiles/Ranged/ScorpioRocket.cs b/Projectiles/Ranged/ScorpioRocket.cs index 94e9965fc4..092deedbd3 100644 --- a/Projectiles/Ranged/ScorpioRocket.cs +++ b/Projectiles/Ranged/ScorpioRocket.cs @@ -155,8 +155,8 @@ namespace CalamityMod.Projectiles.Ranged public override bool? CanDamage() => Time >= TimeToLaunch ? null : false; - public float TrailWidthFunction(float completionRatio) => Utils.Remap(completionRatio, 0f, 0.8f, 6f, 0f); - public Color TrailColorFunction(float completionRatio) => Color.Lerp(EffectsColor, StaticEffectsColor * 0.75f, Utils.GetLerpValue(0f, 0.5f, completionRatio)) * Utils.GetLerpValue(255f, 0f, Projectile.alpha); + public float TrailWidthFunction(float completionRatio, Vector2 vertexPos) => Utils.Remap(completionRatio, 0f, 0.8f, 6f, 0f); + public Color TrailColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(EffectsColor, StaticEffectsColor * 0.75f, Utils.GetLerpValue(0f, 0.5f, completionRatio)) * Utils.GetLerpValue(255f, 0f, Projectile.alpha); public override bool PreDraw(ref Color lightColor) { @@ -171,8 +171,8 @@ namespace CalamityMod.Projectiles.Ranged if (Time >= TimeToLaunch) { // 29FEB2024: Ozzatron: hopefully ported this correctly to the new prim system by Toasty - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidthFunction, TrailColorFunction, (_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 25); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidthFunction, TrailColorFunction, (_,_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 25); } Main.EntitySpriteDraw(texture, drawPosition, frame, drawColor, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); diff --git a/Projectiles/Ranged/SeaDragonMuzzleBlast.cs b/Projectiles/Ranged/SeaDragonMuzzleBlast.cs index 245b8e92fe..f8279c2f1d 100644 --- a/Projectiles/Ranged/SeaDragonMuzzleBlast.cs +++ b/Projectiles/Ranged/SeaDragonMuzzleBlast.cs @@ -1,9 +1,5 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -28,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 4; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - // This projectile is already point blank. It cannot be boosted by point blank. } public override void AI() diff --git a/Projectiles/Ranged/SeasSearingSecondary.cs b/Projectiles/Ranged/SeasSearingSecondary.cs index 2ef11249e6..5d1d581f0b 100644 --- a/Projectiles/Ranged/SeasSearingSecondary.cs +++ b/Projectiles/Ranged/SeasSearingSecondary.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/SepticSkewerBacteria.cs b/Projectiles/Ranged/SepticSkewerBacteria.cs index 23e8884714..e5fd0f6d73 100644 --- a/Projectiles/Ranged/SepticSkewerBacteria.cs +++ b/Projectiles/Ranged/SepticSkewerBacteria.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged } if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), 5, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), DustID.Blood, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; dust.alpha = (int)MathHelper.Clamp(Projectile.alpha, 0, 255); } diff --git a/Projectiles/Ranged/SepticSkewerHarpoon.cs b/Projectiles/Ranged/SepticSkewerHarpoon.cs index 10ffcec20c..1306b8f225 100644 --- a/Projectiles/Ranged/SepticSkewerHarpoon.cs +++ b/Projectiles/Ranged/SepticSkewerHarpoon.cs @@ -2,11 +2,11 @@ using System.Linq; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.DataStructures; -using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -73,7 +73,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.localNPCHitCooldown = -1; Projectile.extraUpdates = 1; Projectile.timeLeft = 900; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -173,7 +172,7 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(spark); } - Dust dust = Dust.NewDustPerfect(Projectile.Center, 5, vel * 3, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, vel * 3, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; } @@ -207,7 +206,7 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(orb7); } - Owner.Calamity().GeneralScreenShakePower = 8.5f; + Owner.SetScreenshake(8.5f); } SoundStyle die = new("CalamityMod/Sounds/NPCKilled/PerfLargeDeath"); @@ -230,12 +229,12 @@ namespace CalamityMod.Projectiles.Ranged for (int r = 0; r < 2; r++) { Vector2 vel2 = (Vector2.One * -28).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f) * intensity; - Dust dust = Dust.NewDustPerfect(Projectile.Center, 5, vel2, 100, default, Main.rand.NextFloat(0.9f, 1.7f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, vel2, 100, default, Main.rand.NextFloat(0.9f, 1.7f)); dust.noGravity = false; } if (strongEnemy) { - Dust dust5 = Dust.NewDustPerfect(Projectile.Center, 278, vel * 0.6f, 0, Color.Red, Main.rand.NextFloat(0.7f, 0.9f)); + Dust dust5 = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, vel * 0.6f, 0, Color.Red, Main.rand.NextFloat(0.7f, 0.9f)); dust5.noGravity = false; } } @@ -267,8 +266,11 @@ namespace CalamityMod.Projectiles.Ranged Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, ((closestTarget.Center - Owner.Center + closestTarget.velocity * 1.5f).SafeNormalize(Vector2.UnitX) * 18), Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Projectile.ai[1] + 1); } - int heal = 25; - Owner.HealPlayer(heal); + if (!chosenTarget.SpawnedFromStatue) + { + int heal = Math.Max(25 - (int)Projectile.ai[1], 10); + Owner.HealPlayer(heal); + } spawnPullBlood = false; } @@ -339,7 +341,8 @@ namespace CalamityMod.Projectiles.Ranged public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (!stuckInTarget && canStick) + + if (!stuckInTarget && canStick && !target.Calamity().pacified) { for (int i = 0; i <= 8; i++) { @@ -355,7 +358,7 @@ namespace CalamityMod.Projectiles.Ranged Particle spark2 = new LineParticle(Projectile.Center, sparkvelocity2, false, 40, sparkScale2, Main.rand.NextBool() ? bColor : Color.Green); GeneralParticleHandler.SpawnParticle(spark2); - Dust dust = Dust.NewDustPerfect(Projectile.Center, 5, sparkvelocity2, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, sparkvelocity2, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; } @@ -404,7 +407,6 @@ namespace CalamityMod.Projectiles.Ranged } public override bool? CanDamage() => canDamage ? null : false; public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 25 * (!spawnPullBlood ? 4 : 1), targetHitbox); - public override bool PreDraw(ref Color lightColor) { Player Owner = Main.player[Projectile.owner]; diff --git a/Projectiles/Ranged/SevensStrikerCherrySplit.cs b/Projectiles/Ranged/SevensStrikerCherrySplit.cs index aca24b229d..6f0fbd69cb 100644 --- a/Projectiles/Ranged/SevensStrikerCherrySplit.cs +++ b/Projectiles/Ranged/SevensStrikerCherrySplit.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { diff --git a/Projectiles/Ranged/SevensStrikerGrape.cs b/Projectiles/Ranged/SevensStrikerGrape.cs index 42a3db8d65..af44565c8d 100644 --- a/Projectiles/Ranged/SevensStrikerGrape.cs +++ b/Projectiles/Ranged/SevensStrikerGrape.cs @@ -1,5 +1,4 @@ -using Terraria; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { diff --git a/Projectiles/Ranged/SevensStrikerHoldout.cs b/Projectiles/Ranged/SevensStrikerHoldout.cs index b94d1e005f..deefc94393 100644 --- a/Projectiles/Ranged/SevensStrikerHoldout.cs +++ b/Projectiles/Ranged/SevensStrikerHoldout.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Sounds; +using CalamityMod.Items.Weapons.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; @@ -48,8 +46,8 @@ namespace CalamityMod.Projectiles.Ranged int shot; float scaleFactor = 14f; - int weaponDamage = player.GetWeaponDamage(player.ActiveItem()); - float weaponKnockback = player.ActiveItem().knockBack; + int weaponDamage = player.GetWeaponDamage(player.HeldItem); + float weaponKnockback = player.HeldItem.knockBack; // Consumes a coin, stores it, then calculates what effect will be executed if (Projectile.ai[1] == 0) @@ -57,7 +55,7 @@ namespace CalamityMod.Projectiles.Ranged // These checks are here so that the weapon doesn't consume two coins when first used if (shotonce) { - if (player.PickAmmo(player.ActiveItem(), out shot, out scaleFactor, out weaponDamage, out weaponKnockback, out _)) + if (player.PickAmmo(player.HeldItem, out shot, out scaleFactor, out weaponDamage, out weaponKnockback, out _)) { Projectile.ai[0] = shot; Projectile.ai[1] = CalculateOutcome(); @@ -105,7 +103,7 @@ namespace CalamityMod.Projectiles.Ranged if (shouldBeHeld && Projectile.ai[1] != 0) { // Holdout stuff - float holdscale = player.ActiveItem().shootSpeed * Projectile.scale; + float holdscale = player.HeldItem.shootSpeed * Projectile.scale; Vector2 playerpos2 = playerpos; Vector2 going = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - playerpos2; if (player.gravDir == -1f) @@ -319,7 +317,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 armPosition = player.RotatedRelativePoint(player.MountedCenter, true); armPosition += Projectile.velocity.SafeNormalize(player.direction * Vector2.UnitX) * 32f; armPosition.Y -= 20f; - Vector2 gunTip = armPosition + Projectile.velocity.SafeNormalize(player.direction * Vector2.UnitX) * player.ActiveItem().scale * 70f; + Vector2 gunTip = armPosition + Projectile.velocity.SafeNormalize(player.direction * Vector2.UnitX) * player.HeldItem.scale * 70f; for (int i = 0; i < projcount; ++i) { Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-spreadfactor, spreadfactor, i / 7f)) * scaleFactor; diff --git a/Projectiles/Ranged/ShadeFire.cs b/Projectiles/Ranged/ShadeFire.cs index 2d8fd1e748..cc6a29d94c 100644 --- a/Projectiles/Ranged/ShadeFire.cs +++ b/Projectiles/Ranged/ShadeFire.cs @@ -3,7 +3,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -57,6 +56,9 @@ namespace CalamityMod.Projectiles.Ranged // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 1200); } } diff --git a/Projectiles/Ranged/ShardshockerCrystal.cs b/Projectiles/Ranged/ShardshockerCrystal.cs new file mode 100644 index 0000000000..8dc08c0597 --- /dev/null +++ b/Projectiles/Ranged/ShardshockerCrystal.cs @@ -0,0 +1,259 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using CalamityMod.Tiles.Abyss; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.GameContent.Animations.Actions.Sprites; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework.Graphics; +using Terraria.GameContent; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Melee; +using System; +using System.Data; +using CalamityMod.Items.Ammo; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ShardshockerCrystal : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/Aquashard"; + public static readonly SoundStyle Collision = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact") { Volume = 0.5f }; + public int time = 0; + + public override void SetDefaults() + { + Projectile.width = 33; + Projectile.height = 33; + Projectile.friendly = true; + Projectile.tileCollide = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.timeLeft = 240; + } + + //The crystal can only damage enemies if it's not hanging in the air + public override bool? CanDamage() => time <= 30 ? null : false; + public override void AI() + { + //Set the projectile as traveling and only update rotation while traveling + if (time < 30) + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Projectile.ai[1] = 1f; + } + + // Make it lose velocity as it travels + Projectile.velocity *= 0.9f; + #region Traveling Visuals + //Firing effects on frame one + if (time == 1) + { + Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5; + int smokeAmount = Main.rand.Next(8, 12 + 1); + for (int i = 0; i < smokeAmount; i++) + { + Particle smoke = new HeavySmokeParticle(Projectile.Center, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(1.2f, 2f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + } + for (int i = 0; i < 5; i++) + { + Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(0.2f, 0.4f), false, 12, 0.009f, Color.DarkTurquoise, new Vector2(1.5f, 0.7f), true, false, 1.3f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + //Only spawn dust trails while traveling + if (time >= 2 && time <= 30) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 135 : 279, -Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.05f, 0.2f) - new Vector2(0, 1)); + dust.scale = Main.rand.NextFloat(0.6f, 0.8f); + dust.noGravity = false; + } + #endregion + //After traveling for 30 frames, come to a stop in the air + if (time >= 30) + { + //Set AI as stopped so traveling crystals can collide with it + Projectile.ai[1] = 0f; + Projectile.velocity = Vector2.Zero; + Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f)); + Dust spark = Dust.NewDustPerfect(Projectile.Center, 278, velocity); + spark.noGravity = true; + spark.color = Main.rand.NextBool() ? Color.Aquamarine : Color.LightSkyBlue; + if (Main.rand.NextBool(13)) + { + // Create a lightning bolt-like particle in the direction of the shot and 3 random hue-shifted ones by the side + Particle bolt = new CrackParticle(Projectile.Center, velocity * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.4f, 0.5f), 12); + GeneralParticleHandler.SpawnParticle(bolt); + + for (int i = 1; i < 4; i++) + { + Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.2f, 0.3f), 12); + GeneralParticleHandler.SpawnParticle(bolt2); + } + } + //Create a lightning AoE every second + if (time % 60 == 0) + { + SoundEngine.PlaySound(SoundID.Item93, Projectile.Center); + // Create Blast + float blastSize = 120; + float minMultiplier = 0.25f; + int hitsToMinMult = 8; + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.DamageType = DamageClass.Ranged; + Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.MediumTurquoise : Color.SkyBlue, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.12f, 30); + GeneralParticleHandler.SpawnParticle(blastRing3); + } + //Set up colliding behavior + foreach (Projectile proj in Main.ActiveProjectiles) + { + // Only allow other large crystals to collide + if (proj.type != Type) + continue; + + // Check if the colliding crystal is traveling + if (proj.ai[1] > 0f && Projectile.Hitbox.Intersects(proj.Hitbox)) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LightningAura"), Projectile.Center); + //Set on kill effects and kill the stopped crystal + Projectile.ai[1] = 2f; + Projectile.Kill(); + //Kill the traveling crystal + proj.timeLeft = 0; + } + } + } + time++; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Create a smaller AoE on direct hits + float blastSize = 130; + float minMultiplier = 0.25f; + int hitsToMinMult = 4; + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.DamageType = DamageClass.Ranged; + + target.AddBuff(ModContent.BuffType(), 60); + + #region Visuals and Sound + SoundEngine.PlaySound(Collision, Projectile.Center); + + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.MediumAquamarine : Color.DarkSeaGreen, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.1f, 22, true); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-12, 12), 0f, 0.18f, 22, true); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.12f, 22); + GeneralParticleHandler.SpawnParticle(blastRing3); + + float offset = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < 4; i++) + { + Vector2 velocity = (MathHelper.TwoPi * i / 4f + offset).ToRotationVector2() * 0.5f; ; + Particle cross = new SparkParticle(Projectile.Center + velocity * 15f, velocity, false, 15, 1.5f, Color.MediumAquamarine, true); + GeneralParticleHandler.SpawnParticle(cross); + } + for (int k = 0; k < 3; k++) + { + Particle outerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkSlateBlue, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.25f, 25); + GeneralParticleHandler.SpawnParticle(outerGlow); + Particle innerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.15f, 25); + GeneralParticleHandler.SpawnParticle(innerGlow); + } + + for (int i = 1; i < 8; i++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(9f, 11f)); + Dust spark = Dust.NewDustPerfect(Projectile.Center, 278, velocity); + spark.color = Main.rand.NextBool() ? Color.Aquamarine : Color.SkyBlue; + } + + for (int i = 1; i < 6; i++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f)); + Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.8f, 1.1f), 17); + GeneralParticleHandler.SpawnParticle(bolt2); + } + #endregion + } + + public override void OnKill(int timeLeft) + { + //These effects only occur if another crystal collides with a stopped one + if (Projectile.ai[1] == 2f) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LightningAura"), Projectile.Center); + Player Owner = Main.player[Projectile.owner]; + if (Owner.Calamity().GeneralScreenShakePower < 1.2f) + Owner.Calamity().GeneralScreenShakePower = 1.2f; + int projAmt = 15; + for (int i = 0; i < projAmt; i++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 35f, 50f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.27f), 0f, Projectile.owner); + } + float blastSize = 185; + float minMultiplier = 0.25f; + int hitsToMinMult = 8; + int debuff1 = BuffID.Electrified; + int debuffTime = 240; + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 2f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff1; + blast.localAI[1] = debuffTime; + blast.DamageType = DamageClass.Ranged; + for (int i = 1; i < 9; i++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f)); + Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.9f, 1.5f), 20); + GeneralParticleHandler.SpawnParticle(bolt2); + } + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-12, 12), 0f, 0.25f, 25, true); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.MediumAquamarine : Color.DarkSeaGreen, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.13f, 25, true); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.16f, 25, true); + GeneralParticleHandler.SpawnParticle(blastRing3); + float offset = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < 4; i++) + { + Vector2 velocity = (MathHelper.TwoPi * i / 4f + offset).ToRotationVector2() * 0.5f; ; + Particle cross = new SparkParticle(Projectile.Center + velocity * 15f, velocity, false, 15, 2.5f, Color.MediumAquamarine, true); + GeneralParticleHandler.SpawnParticle(cross); + } + for (int k = 0; k < 3; k++) + { + Particle outerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkSlateBlue, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.25f, 25); + GeneralParticleHandler.SpawnParticle(outerGlow); + Particle innerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.15f, 25); + GeneralParticleHandler.SpawnParticle(innerGlow); + } + } + //These effects always occur + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath with { Volume = 0.8f }, Projectile.Center); + for (int i = 0; i < (int)(15); i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(1f, 1.3f)); + dust.noGravity = !Main.rand.NextBool(); + dust.color = Main.rand.NextBool(5) ? Color.DeepSkyBlue : Color.DarkTurquoise; + } + } + public override bool PreDraw(ref Color lightColor) + { + //Don't draw the projectile for the first two frames, to prevent it from coming out of the player + if (time < 2) + { + return false; + } + return base.PreDraw(ref lightColor); + } + } +} diff --git a/Projectiles/Ranged/Shell.cs b/Projectiles/Ranged/Shell.cs index df5f7620f1..a9f54ada25 100644 --- a/Projectiles/Ranged/Shell.cs +++ b/Projectiles/Ranged/Shell.cs @@ -19,7 +19,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.arrow = true; Projectile.timeLeft = 600; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } diff --git a/Projectiles/Ranged/Shockblast.cs b/Projectiles/Ranged/Shockblast.cs index 4abaaa0f57..c525dcf630 100644 --- a/Projectiles/Ranged/Shockblast.cs +++ b/Projectiles/Ranged/Shockblast.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/ShockblastRound.cs b/Projectiles/Ranged/ShockblastRound.cs index 94df4dbaac..f7e03349b5 100644 --- a/Projectiles/Ranged/ShockblastRound.cs +++ b/Projectiles/Ranged/ShockblastRound.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Balancing; using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Terraria; @@ -29,7 +28,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.light = 0.5f; Projectile.extraUpdates = 3; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool OnTileCollide(Vector2 oldVelocity) @@ -82,14 +80,7 @@ namespace CalamityMod.Projectiles.Ranged Main.projectile[proj].scale = (Projectile.ai[1] * 0.5f) + 1f; } - int heal = (int)Math.Round(hit.Damage * 0.05); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); + Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ModContent.ProjectileType(), (int)Math.Round(hit.Damage * 0.05)); } } } diff --git a/Projectiles/Ranged/Sickness.cs b/Projectiles/Ranged/Sickness.cs index 9507691805..6c20a601a1 100644 --- a/Projectiles/Ranged/Sickness.cs +++ b/Projectiles/Ranged/Sickness.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/SicknessRound.cs b/Projectiles/Ranged/SicknessRound.cs index b67f488a47..1d7e5cb26b 100644 --- a/Projectiles/Ranged/SicknessRound.cs +++ b/Projectiles/Ranged/SicknessRound.cs @@ -26,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.light = 0.25f; Projectile.extraUpdates = 4; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/SlagRound.cs b/Projectiles/Ranged/SlagRound.cs index bc9098440e..3c06527ae4 100644 --- a/Projectiles/Ranged/SlagRound.cs +++ b/Projectiles/Ranged/SlagRound.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -26,7 +25,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.extraUpdates = 3; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/Slagfire.cs b/Projectiles/Ranged/Slagfire.cs new file mode 100644 index 0000000000..481a9d8559 --- /dev/null +++ b/Projectiles/Ranged/Slagfire.cs @@ -0,0 +1,159 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using CalamityMod.Packets; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class Slagfire : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool CanHitPlayer(Player target) => false; + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 32; + Projectile.friendly = true; + Projectile.hostile = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.extraUpdates = 1; + Projectile.tileCollide = true; +            Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + } + + public override void AI() + { + Projectile.localAI[1]++; + if (Projectile.localAI[1] >= 4f) + { + Projectile.tileCollide = true; + } + Projectile.scale -= 0.001f; + if (Projectile.scale <= 0f) + { + Projectile.Kill(); + } + if (Projectile.localAI[0] <= 3f) + { + Projectile.localAI[0] += 1f; + return; + } + + Color color = new(254, 63, 63); + + for (int i = 0; i < 3; i++) + { + Vector2 sparkPosition = Projectile.Center - (Projectile.velocity / 3f * i); + + Vector2 sparkVelocity = -Projectile.velocity * 0.01f * Main.rand.NextFloat(0.5f, 1.5f); + + Particle spark = new CustomSpark(sparkPosition, sparkVelocity, "CalamityMod/Particles/BloomLineFade", false, 6, 0.04f, color * 0.85f, new Vector2(0.45f, 0.9f), shrinkSpeed: 0.4f); + GeneralParticleHandler.SpawnParticle(spark); + } + + if (Main.rand.NextBool(8)) + { + Vector2 sparkPosition = Projectile.Center + Main.rand.NextVector2Circular(15, 15); + Vector2 sparkVelocity = -Projectile.velocity * Main.rand.NextFloat(0.01f, 0.045f); // Backward velocity + +                Particle subtleSpark = new CustomSpark(sparkPosition, sparkVelocity, "CalamityMod/Particles/BloomLineFade", false, 8, 0.02f, color * 0.5f, new Vector2(0.5f, 0.8f), shrinkSpeed: 0.3f); + GeneralParticleHandler.SpawnParticle(subtleSpark); + } + + // Falling particles to appear as lava droplets, similar to speed blaster's falling dust + if (Main.rand.NextBool(50)) + { + Vector2 spawnHere = Projectile.position; + spawnHere.Y = Projectile.Bottom.Y + 3f; // A little down + + Vector2 particleVelocity = new Vector2(Main.rand.Next(-1, 1), 3); + + GeneralParticleHandler.SpawnParticle(new WaterFlavoredParticle(spawnHere, particleVelocity, true, // Affected by gravity + Main.rand.Next(30, 50), Main.rand.NextFloat(0.4f, 0.65f), new(220, 138, 138))); + } + + if (Projectile.localAI[1] >= 10f) + Projectile.velocity.Y += 0.2f; + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (target.type == NPCID.Guide) + modifiers.FinalDamage *= 25f; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Color innerColor = new(230, 198, 198); + Color outterColor = new(248, 63, 63); + + Vector2 baseParticleDirection = new Vector2(Projectile.direction, 0).SafeNormalize(Vector2.UnitX * Projectile.direction); + + for (int i = 0; i < 4; i++) + { + // This rotation makes it look like it's bursting out from a set point + Vector2 particleVelocity = baseParticleDirection.RotatedByRandom(MathHelper.ToRadians(50f)) * Main.rand.NextFloat(10f, 13f); + + bool affectedByGravity = true; + int lifetime = Main.rand.Next(20, 45); + float scale = Main.rand.NextFloat(.3f, .7f); + + GeneralParticleHandler.SpawnParticle(new WaterFlavoredParticle(Projectile.Center, particleVelocity, affectedByGravity, lifetime, scale * 1.15f, outterColor)); + GeneralParticleHandler.SpawnParticle(new WaterFlavoredParticle(Projectile.Center, particleVelocity, affectedByGravity, lifetime, scale * 0.75f, innerColor)); + } + Projectile.Kill(); + return true; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damage) + { + target.AddBuff(ModContent.BuffType(), 600); + Color innerColor = new(230, 198, 198); + Color outterColor = new(248, 63, 63); + + Vector2 baseParticleDirection = new Vector2(Projectile.direction, 0).SafeNormalize(Vector2.UnitX * Projectile.direction); + Vector2 initialSpawnPosition = target.Center + new Vector2(target.width / 2f * Projectile.direction + 4f * Projectile.direction, Main.rand.NextFloat(-target.height / 2f, target.height / 2f)); + + for (int i = 0; i < 4; i++) + { + Vector2 finalSpawnPosition = initialSpawnPosition + Main.rand.NextVector2Circular(1f, 1f); + + // This rotation makes it look like it's bursting out from a set point + Vector2 particleVelocity = baseParticleDirection.RotatedByRandom(MathHelper.ToRadians(50f)) * Main.rand.NextFloat(10f, 13f); + + bool affectedByGravity = true; + int lifetime = Main.rand.Next(20, 45); + float scale = Main.rand.NextFloat(.3f, .7f); + + GeneralParticleHandler.SpawnParticle(new WaterFlavoredParticle(finalSpawnPosition, particleVelocity, affectedByGravity, lifetime, scale * 1.15f, outterColor)); + GeneralParticleHandler.SpawnParticle(new WaterFlavoredParticle(finalSpawnPosition, particleVelocity, affectedByGravity, lifetime, scale * 0.75f, innerColor)); + } + + //WoF Spawning + if (target.type == NPCID.Guide) + { + if (target.life <= 0) + { + if (Projectile.owner == Main.myPlayer) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + SpawnBossOnPositionPacket.Send((int)Main.player[Projectile.owner].Center.X, (int)Main.player[Projectile.owner].Center.Y, NPCID.WallofFlesh, Main.player[Projectile.owner]); + + else + NPC.SpawnWOF(Main.player[Projectile.owner].Center); + } + } + } + } + } +} diff --git a/Projectiles/Ranged/SlagfireDouserHoldout.cs b/Projectiles/Ranged/SlagfireDouserHoldout.cs new file mode 100644 index 0000000000..267b3b2fdf --- /dev/null +++ b/Projectiles/Ranged/SlagfireDouserHoldout.cs @@ -0,0 +1,153 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Dusts.WaterSplash; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SlagfireDouserHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ItemType(); + + private static readonly Vector2 CustomHoldoutOffset = new Vector2(25f, -5f); + + public static Asset pistilTexture; + + public override string Texture => "CalamityMod/Projectiles/Ranged/SlagfireDouserHoldout"; + public static string TexturePathPistil => "CalamityMod/Projectiles/Ranged/SlagfireDouserPistil"; + private float pistilJigglePhysicsTimer = 0; + + // Positioning overrides + public override Vector2 GunTipPosition + { + get + { + Vector2 baseTip = base.GunTipPosition; + + baseTip.X += CustomHoldoutOffset.X * Owner.direction; + baseTip.Y += CustomHoldoutOffset.Y; + + baseTip -= Vector2.UnitX.RotatedBy(Projectile.rotation) * 24f * Owner.gravDir; + + return baseTip; + } + } + public override float MaxOffsetLengthFromArm => 12f; + public override float OffsetXUpwards => -25f; + public override float OffsetXDownwards => -25f; + public override float OffsetYUpwards => -24f; + public override float OffsetYDownwards => 24f; + public override float BaseOffsetY => -2f; + + public override float RecoilResolveSpeed => 0.12f; + private float frontArmRotation = 0.14f; + public ref float ShootingTimer => ref Projectile.ai[0]; + + private const int BurstProjectiles = 4; // 4 Slagfire shots per burst +        private const int DelayBetweenShotsInBurst = 4; + + public static Color EffectsColor { get; set; } = Color.MediumVioletRed * 1.3f; + public static Color StaticEffectsColor { get; set; } = Color.MediumVioletRed * 1.3f; + + public override void HoldoutAI() + { + if (!Owner.channel) + { + Projectile.Kill(); + return; + } + if (ShootingTimer % (HeldItem.useAnimation + BurstProjectiles * DelayBetweenShotsInBurst) == 0 && ShootingTimer > 0) + { + ShootingTimer = 0; + } + +            // Calc current shot index +            int currentShotInBurst = (int)((ShootingTimer % (HeldItem.useAnimation + BurstProjectiles * DelayBetweenShotsInBurst) - HeldItem.useAnimation) / DelayBetweenShotsInBurst); + + if (ShootingTimer >= HeldItem.useAnimation && currentShotInBurst >= 0 && currentShotInBurst < BurstProjectiles) + { + if ((ShootingTimer - HeldItem.useAnimation) % DelayBetweenShotsInBurst == 0) + { + Shoot(HeldItem); + } + } + + ShootingTimer++; // Once per tick + + pistilJigglePhysicsTimer = MathHelper.Clamp(pistilJigglePhysicsTimer - 0.04f, 0, 1); + + // Set front arm to be angled slightly up toward the trigger + ExtraFrontArmRotation = frontArmRotation; + } + + public void Shoot(Item item) + { + // Create random spread + Vector2 projectileDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); +            Vector2 finalProjectileVelocity = projectileDirection.RotatedByRandom(MathHelper.ToRadians(11f)) * item.shootSpeed; + +            // Spawn the main projectile +            Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, finalProjectileVelocity, ModContent.ProjectileType(), Owner.GetWeaponDamage(item), Owner.GetWeaponKnockback(item, item.knockBack), Projectile.owner); + +            if (Main.dedServ) + return; + + SoundEngine.PlaySound(SoundID.Item61 with { Volume = 0.9f, Pitch = 0.125f }, Projectile.Center); + +            // Translates arm back and upward to simulate recoil +            OffsetLengthFromArm -= 1f; + + pistilJigglePhysicsTimer += 1; + + + int dustAmount = Main.rand.Next(3, 6); + for (int i = 0; i < dustAmount; i++) + { + Dust shootDust = Dust.NewDustPerfect( + GunTipPosition, + ModContent.DustType(), + projectileDirection.RotatedByRandom(MathHelper.PiOver4 * 1.2f) * Main.rand.NextFloat(2.5f, 9f), + newColor: Color.Red); + shootDust.noGravity = false; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + pistilTexture ??= Request(TexturePathPistil); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + + float pistilPow = MathF.Pow(pistilJigglePhysicsTimer, 2); + Vector2 pistilJiggleScale = new Vector2(1 - 0.25f * pistilPow, 1 + 0.5f * pistilPow); + + drawPosition.X += 25 * Owner.direction; + drawPosition.Y += -5f; + + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + float pistilJiggleRotOffset = (MathF.Sin(MathF.Pow(pistilJigglePhysicsTimer * 3.4f, 2)) * 0.2f + MathF.Sin(Main.LocalPlayer.miscCounter * MathHelper.Pi) * 0.1f) * Projectile.spriteDirection; + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(pistilTexture.Value, drawPosition, null, drawColor, drawRotation + pistilJiggleRotOffset, pistilTexture.Size() * 0.5f, Projectile.scale * Owner.gravDir * pistilJiggleScale, flipSprite); + + return false; + } + } +} diff --git a/Projectiles/Ranged/SlagfireDouserHoldout.png b/Projectiles/Ranged/SlagfireDouserHoldout.png new file mode 100644 index 0000000000..ebd8568100 Binary files /dev/null and b/Projectiles/Ranged/SlagfireDouserHoldout.png differ diff --git a/Projectiles/Ranged/SlagfireDouserPistil.png b/Projectiles/Ranged/SlagfireDouserPistil.png new file mode 100644 index 0000000000..b760f61be8 Binary files /dev/null and b/Projectiles/Ranged/SlagfireDouserPistil.png differ diff --git a/Projectiles/Ranged/SlimeBolt.cs b/Projectiles/Ranged/SlimeBolt.cs index a89ee193a5..576bcec82f 100644 --- a/Projectiles/Ranged/SlimeBolt.cs +++ b/Projectiles/Ranged/SlimeBolt.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -50,7 +47,7 @@ namespace CalamityMod.Projectiles.Ranged if (Time == EmpowerTime) { Projectile.penetrate = 1; - Projectile.damage = (int)((Projectile.damage / Math.Pow(DamageFalloff, Projectile.numHits)) * 1.6f); // 7/4 + Projectile.damage = (int)(Projectile.originalDamage * 1.6f); Projectile.velocity *= 0f; Projectile.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); diff --git a/Projectiles/Ranged/SmallCoral.cs b/Projectiles/Ranged/SmallCoral.cs deleted file mode 100644 index 40f6c0292c..0000000000 --- a/Projectiles/Ranged/SmallCoral.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class SmallCoral : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 22; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - Projectile.velocity.X *= 0.9995f; - Projectile.velocity.Y = Projectile.velocity.Y + 0.01f; - Projectile.rotation = Projectile.velocity.ToRotation(); - if (Projectile.direction == -1) - Projectile.rotation += MathHelper.Pi; - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 16; - Projectile.height = 16; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 5; i++) - { - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SnowBlock, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 2f; - } - } - } -} diff --git a/Projectiles/Ranged/SmallCoral.png b/Projectiles/Ranged/SmallCoral.png deleted file mode 100644 index 10aba07451..0000000000 Binary files a/Projectiles/Ranged/SmallCoral.png and /dev/null differ diff --git a/Projectiles/Ranged/SparkSpreaderFire.cs b/Projectiles/Ranged/SparkSpreaderFire.cs index fa7385a9ee..8caf844073 100644 --- a/Projectiles/Ranged/SparkSpreaderFire.cs +++ b/Projectiles/Ranged/SparkSpreaderFire.cs @@ -61,15 +61,19 @@ namespace CalamityMod.Projectiles.Ranged return true; } + + //Doze - Flamethrowers in vanilla are long debuff infliction tools (20 seconds of their debuff). + //I am applying this as the base for Cal flamethrowers, with shorter times being the exception instead of the rule + //Due to Spark Spreader's tier, I am making this be random of 5-20 seconds public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(5, 20+1)); SpawnSparks(5); } public override void OnHitPlayer(Player target, Player.HurtInfo info) { - target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(5, 20+1)); SpawnSparks(5); } diff --git a/Projectiles/Ranged/SpectralFlare.cs b/Projectiles/Ranged/SpectralFlare.cs new file mode 100644 index 0000000000..d8e99defad --- /dev/null +++ b/Projectiles/Ranged/SpectralFlare.cs @@ -0,0 +1,88 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; +using Terraria; +using Terraria.ID; +using CalamityMod.Buffs.DamageOverTime; +using System; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SpectralFlare : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 6; + Projectile.scale = 1.15f; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.netImportant = true; + Projectile.aiStyle = ProjAIStyleID.Flare; + Projectile.alpha = 255; + Projectile.penetrate = 3; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 600; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 30 * Projectile.MaxUpdates; + DrawOriginOffsetY = -10; + } + + public override bool PreAI() + { + if (Projectile.alpha > 0) + { + Projectile.alpha -= 80; + if (Projectile.alpha < 0) + Projectile.alpha = 0; + } + + float xVel = Projectile.ai[0]; + float yVel = Projectile.ai[1]; + if (xVel == 0f && yVel == 0f) + xVel = 1f; + float dist = MathF.Sqrt(xVel * xVel + yVel * yVel); + dist = 4f / dist; + xVel *= dist; + yVel *= dist; + + if (Projectile.alpha < 70) + { + Dust dust = Dust.NewDustDirect(Projectile.position - Vector2.UnitY * 2f, 7, 7, DustID.SpectreStaff, Projectile.velocity.X, Projectile.velocity.Y, Scale: 1.15f); + dust.noGravity = true; + dust.velocity *= 0.3f; + dust.position.X -= xVel; + dust.position.Y -= yVel; + dust.velocity.X -= xVel; + dust.velocity.Y -= yVel; + } + + if (Projectile.localAI[0] == 0f) + { + Projectile.ai[0] = Projectile.velocity.X; + Projectile.ai[1] = Projectile.velocity.Y; + + if (Projectile.localAI[1] == 1f) + { + Projectile.velocity.Y += 0.09f; + if (Projectile.velocity.Y > 16f) + Projectile.velocity.Y = 16f; + } + } + else + { + if (!Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + { + Projectile.localAI[0] = 0f; + Projectile.localAI[1] = 1f; + } + + Projectile.damage = 0; + } + Projectile.rotation = MathF.Atan2(Projectile.ai[1], Projectile.ai[0]) + MathHelper.PiOver2; + + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), Main.rand.NextBool(3) ? 600 : 300); + } +} diff --git a/Projectiles/Ranged/SpectralFlare.png b/Projectiles/Ranged/SpectralFlare.png new file mode 100644 index 0000000000..ecba14a897 Binary files /dev/null and b/Projectiles/Ranged/SpectralFlare.png differ diff --git a/Projectiles/Ranged/SpectralstormCannonHoldout.cs b/Projectiles/Ranged/SpectralstormCannonHoldout.cs new file mode 100644 index 0000000000..0c6b0ed23f --- /dev/null +++ b/Projectiles/Ranged/SpectralstormCannonHoldout.cs @@ -0,0 +1,205 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SpectralstormCannonHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 16f; + public override float BaseOffsetY => -5f; + public override float OffsetYDownwards => 5f; + public override Vector2 GunTipPosition => Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.35f; + + public static readonly SoundStyle OverheatSound = new SoundStyle("CalamityMod/Sounds/Custom/AbilitySounds/OmegaBlueAbility") with { Pitch = -0.5f }; + public SlotId WarningSlot; + public ref float Timer => ref Projectile.ai[0]; + public ref float SoulTimer => ref Projectile.ai[1]; + private int BuiltHeat => (Owner.HeldItem.ModItem as SpectralstormCannon).BuiltUpHeat; + private bool displayOverheat = false; + private const int WarningTime = SpectralstormCannon.OverheatLevel - 100; + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Ranged; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15; + } + public override void KillHoldoutLogic() + { + // What kills the holdout: + // Dead, CCed, Cursed, etc. + // Not holding the item + // Right-clicking (Can kill it early) (Does not work if in overheat state) + // Completely cooling while not firing + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.HeldItem.type || + (Owner.Calamity().mouseRight && !displayOverheat) || (BuiltHeat == 0 && !Main.mouseLeft)) + { + if (SoundEngine.TryGetActiveSound(WarningSlot, out var warn)) + warn.Stop(); + + Projectile.Kill(); + } + } + + public override void HoldoutAI() + { + // Timer should only increment while firing and not overheated + if (Owner.Calamity().flareGunOverheat == 0) + { + if (Main.mouseLeft) + { + Timer++; + SoulTimer = 0; + } + else + { + Timer = 0; + SoulTimer++; + } + } + else + { + Timer = 0; + SoulTimer = 0; + } + + // Once holding the fire button down long enough, start actually firing + if (Timer >= 30) + { + // For some reason using HeldItem here breaks its functionality while being held on the cursor + (Owner.HeldItem.ModItem as SpectralstormCannon).BuiltUpHeat++; + + // Overheat yourself if you fire too long + if (BuiltHeat >= SpectralstormCannon.OverheatLevel) + { + WarningSlot = SoundEngine.PlaySound(OverheatSound, Owner.Center); + for (int e = 0; e < 7; e++) + { + Vector2 dustVel = -Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.Pi * 0.15f) * Main.rand.NextFloat(3.8f, 5.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Flare, dustVel, Scale: 1.5f); + dust.noGravity = true; + } + + // Overheat damage ignores defense and is undodgeable, also inflicts Nightwither + Owner.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.FlareGunOverheat").ToNetworkText(Owner.name)), SpectralstormCannon.OverheatDamage, 1, dodgeable: false, scalingArmorPenetration: 1f, knockback: 0f); + Owner.AddBuff(ModContent.BuffType(), SpectralstormCannon.OverheatCooldown); + Owner.Calamity().flareGunOverheat = SpectralstormCannon.OverheatCooldown; + displayOverheat = true; + // Spectralstorm Cannon's overheat immediately resets heat after triggered + (Owner.HeldItem.ModItem as SpectralstormCannon).BuiltUpHeat = 1; + + // Spawn a burst of souls on overheat + if (Main.myPlayer == Projectile.owner) + { + for (int i = 0; i < 25; i++) + { + Vector2 soulVel = Main.rand.NextVector2CircularEdge(1f, 1f) * Main.rand.NextFloat(4f, 7.5f); + Projectile soul = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Owner.Center, soulVel, ModContent.ProjectileType(), (int)(Projectile.damage * 1.15f), 0f, Projectile.owner); + soul.timeLeft = 250; + soul.DamageType = DamageClass.Ranged; + soul.frame = Main.rand.Next(4); + } + } + return; + } + + // Play a warning sound + if (BuiltHeat == WarningTime) + { + WarningSlot = SoundEngine.PlaySound(FirestormCannonHoldout.WarningSound, Owner.Center); + } + + // Controls the escalating firing speed + float firingLerp = Utils.GetLerpValue(0, 90, Timer - 30, true); + int firingFrequency = (int)MathHelper.Lerp(HeldItem.useTime, HeldItem.useTime / 2, firingLerp); + // Actually fire shtuff + if (Timer % firingFrequency == 0) + { + SoundEngine.PlaySound(SoundID.Item11 with { Volume = 0.8f }, Owner.Center); + if (Main.myPlayer == Projectile.owner) + { + Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _); + Vector2 velocity = Projectile.velocity.RotatedByRandom(MathHelper.Pi * 0.015f * (1f + firingLerp * 0.25f)) * Owner.HeldItem.shootSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + } + } + + // Fire souls while dissipating heat + if (SoulTimer % 8 == 4f) + { + if (SoulTimer % 16 == 4f) + SoundEngine.PlaySound(SoundID.Item103 with { Volume = 0.7f }, Owner.Center); + if (Main.myPlayer == Projectile.owner) + { + Vector2 velocity = Projectile.velocity.RotatedByRandom(MathHelper.Pi * 0.03f) * Owner.HeldItem.shootSpeed * 0.8f; + Projectile soul = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, velocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 2f); + soul.DamageType = DamageClass.Ranged; + soul.frame = Main.rand.Next(4); + } + } + + // Reset overheat draw color once the overheat ends + if (Owner.Calamity().flareGunOverheat == 0) + displayOverheat = false; + // Draw smoke effect while overheated + if (displayOverheat && Main.rand.NextBool(3)) + { + HeavySmokeParticle smoke = new(GunTipPosition, -Vector2.UnitY * 7.5f, Color.DarkCyan, 25, 0.4f, 0.75f); + GeneralParticleHandler.SpawnParticle(smoke); + } + // Constantly move the warning sound on top of the player + if (SoundEngine.TryGetActiveSound(WarningSlot, out var warning) && warning.IsPlaying) + warning.Position = Projectile.Center; + } + + // Pan-searing mechanic; reduces heat a bit + public override bool? CanDamage() => BuiltHeat >= 120 && Owner.Calamity().flareGunOverheat == 0; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.OnFire3, 300); + (Owner.HeldItem.ModItem as SpectralstormCannon).BuiltUpHeat -= 6; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Color tintColor = displayOverheat ? Color.Black : + BuiltHeat >= WarningTime ? Color.Lerp(Color.LightSalmon, Color.White, MathF.Abs(MathF.Sin(Owner.miscCounter * MathHelper.Pi / 30f))) : Color.LightSalmon; + float opacity = Utils.GetLerpValue(0, WarningTime, BuiltHeat, true); + + Projectile.DrawBackglow(Color.HotPink * opacity, 4f, null, null, (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipVertically : SpriteEffects.None); + + CalamityUtils.EnterShaderRegion(Main.spriteBatch); + GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity((displayOverheat ? 1f : opacity) * 0.45f); + GameShaders.Misc["CalamityMod:BasicTint"].UseColor(tintColor); + GameShaders.Misc["CalamityMod:BasicTint"].Apply(); + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + CalamityUtils.ExitShaderRegion(Main.spriteBatch); + return false; + } + } +} diff --git a/Projectiles/Ranged/SpeedBlasterShot.cs b/Projectiles/Ranged/SpeedBlasterShot.cs index 25f6e366d2..f569bc4e27 100644 --- a/Projectiles/Ranged/SpeedBlasterShot.cs +++ b/Projectiles/Ranged/SpeedBlasterShot.cs @@ -1,5 +1,4 @@ -using System.Linq; -using CalamityMod.Graphics.Metaballs; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -37,7 +36,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 2; Projectile.timeLeft = 150 * Projectile.MaxUpdates; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } @@ -96,7 +94,7 @@ namespace CalamityMod.Projectiles.Ranged if (Main.rand.NextBool(20) && !DashShot && !PostHit) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 192); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Ghost); dust.noLight = true; dust.noGravity = false; dust.scale = 1.2f; @@ -124,7 +122,7 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(spark2); } - Dust dust = Dust.NewDustPerfect(Projectile.Center, 192); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Ghost); dust.noLight = true; dust.noGravity = false; dust.scale = Main.rand.NextFloat(1.3f, 1.5f); @@ -136,7 +134,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 10; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 192, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.4f, 1.2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Ghost, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.4f, 1.2f)); dust.noGravity = true; dust.color = ColorUsed; dust.alpha = Main.rand.Next(40, 90); @@ -148,7 +146,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 7; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 192, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(PostDashShot ? 13f : 23f)) * Main.rand.NextFloat(0.4f, 1.2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Ghost, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(PostDashShot ? 13f : 23f)) * Main.rand.NextFloat(0.4f, 1.2f)); dust.noGravity = true; dust.color = ColorUsed; dust.alpha = Main.rand.Next(40, 90); @@ -188,7 +186,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(7, 7), 192, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.05f, 0.45f), 0, default, Main.rand.NextFloat(0.6f, 1.2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(7, 7), DustID.Ghost, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.05f, 0.45f), 0, default, Main.rand.NextFloat(0.6f, 1.2f)); dust.noLight = true; dust.noGravity = false; dust.color = GetColor(Projectile.ai[0]); @@ -237,11 +235,11 @@ namespace CalamityMod.Projectiles.Ranged public static Color GetColor(float type) => type == 0 ? Color.Aqua : type == 1 ? Color.Blue : type == 2 ? Color.Fuchsia : type == 3 ? Color.Lime : Color.Yellow; public override Color? GetAlpha(Color drawColor) => GetColor(Projectile.ai[0]) * drawColor.A * Projectile.Opacity; - internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 6f; - internal Color ColorFunction(float completionRatio) => GetColor(Projectile.ai[0]) * Projectile.Opacity; + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (1f - completionRatio) * Projectile.scale * 6f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) => GetColor(Projectile.ai[0]) * Projectile.Opacity; public override bool PreDraw(ref Color lightColor) { - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f), 20); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f), 20); return true; } } diff --git a/Projectiles/Ranged/SporeBomb.cs b/Projectiles/Ranged/SporeBomb.cs index 8dce1067ed..c1b5d6dde9 100644 --- a/Projectiles/Ranged/SporeBomb.cs +++ b/Projectiles/Ranged/SporeBomb.cs @@ -90,6 +90,7 @@ namespace CalamityMod.Projectiles.Ranged { Main.projectile[proj].DamageType = DamageClass.Ranged; Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].usesIDStaticNPCImmunity = false; Main.projectile[proj].localNPCHitCooldown = 30; } } diff --git a/Projectiles/Ranged/SproutingArrowMain.cs b/Projectiles/Ranged/SproutingArrowMain.cs index 4857e9db0d..7aea0dd46f 100644 --- a/Projectiles/Ranged/SproutingArrowMain.cs +++ b/Projectiles/Ranged/SproutingArrowMain.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -8,7 +7,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static Terraria.GameContent.Animations.IL_Actions.Sprites; namespace CalamityMod.Projectiles.Ranged { @@ -30,7 +28,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 80; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.ArmorPenetration = 8; Projectile.tileCollide = false; } @@ -59,7 +56,7 @@ namespace CalamityMod.Projectiles.Ranged float blastSize = 45; float minMultiplier = 0.4f; int hitsToMinMult = 4; - Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.25f), 0, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); blast.DamageType = DamageClass.Ranged; blast.ArmorPenetration = 8; @@ -74,7 +71,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < Dusts; i++) { Vector2 dustVelocity = spinningPoint.RotatedBy(radians * i).RotatedBy(0.5f * rotRando) * 6f; - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 264, dustVelocity); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail, dustVelocity); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.85f, 1.35f); dust2.color = Main.rand.NextBool(3) ? Color.MediumAquamarine : Color.Lime; @@ -97,7 +94,7 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(sparker); Projectile split1 = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel1 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), Projectile.damage * 2, 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); Projectile split2 = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel2 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), Projectile.damage * 2, 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); - if (Projectile.Calamity().conditionalHomingRange > 0f) // Allows the split arrows to home when using Arterial Assault as well + if (Projectile.Calamity().conditionalHomingRange > 0f) // Allows the split arrows to home if the main arrow homes { split1.Calamity().conditionalHomingRange = Projectile.Calamity().conditionalHomingRange; split2.Calamity().conditionalHomingRange = Projectile.Calamity().conditionalHomingRange; diff --git a/Projectiles/Ranged/SproutingArrowSplit.cs b/Projectiles/Ranged/SproutingArrowSplit.cs index 32c8e504c3..0ad7438abb 100644 --- a/Projectiles/Ranged/SproutingArrowSplit.cs +++ b/Projectiles/Ranged/SproutingArrowSplit.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, Color.LimeGreen.ToVector3() * 0.25f); if (Projectile.alpha > 0) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 264, Projectile.velocity.RotatedByRandom(0.6) * Main.rand.NextFloat(0.05f, 1.5f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail, Projectile.velocity.RotatedByRandom(0.6) * Main.rand.NextFloat(0.05f, 1.5f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.8f, 1.3f); dust.color = Main.rand.NextBool(3) ? Color.MediumAquamarine : Color.Lime; @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Ranged } else if (Main.rand.NextBool()) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 264, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.3f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.3f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.35f, 0.65f); dust2.color = Main.rand.NextBool(3) ? Color.MediumAquamarine : Color.Lime; @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < Dusts; i++) { Vector2 dustVelocity = spinningPoint.RotatedBy(radians * i).RotatedBy(0.5f * rotRando) * 3f; - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 264, dustVelocity); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.PortalBoltTrail, dustVelocity); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(0.65f, 0.95f); dust2.color = Main.rand.NextBool(3) ? Color.MediumAquamarine : Color.Lime; diff --git a/Projectiles/Ranged/SputterCometBig.cs b/Projectiles/Ranged/SputterCometBig.cs index 7f227bbb77..85150cc826 100644 --- a/Projectiles/Ranged/SputterCometBig.cs +++ b/Projectiles/Ranged/SputterCometBig.cs @@ -68,9 +68,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item93, Projectile.position); if (Projectile.owner == Main.myPlayer) { - int flash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.5), 0f, Projectile.owner, 0f, 0f); - Main.projectile[flash].usesLocalNPCImmunity = true; - Main.projectile[flash].localNPCHitCooldown = 10; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((double)Projectile.damage * 0.5), 0f, Projectile.owner, 0f, 0f); } for (int k = 0; k < 5; k++) { diff --git a/Projectiles/Ranged/SpykerProj.cs b/Projectiles/Ranged/SpykerProj.cs index 78994fca75..06be4cf7e6 100644 --- a/Projectiles/Ranged/SpykerProj.cs +++ b/Projectiles/Ranged/SpykerProj.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Ranged/StarfleetHoldout.cs b/Projectiles/Ranged/StarfleetHoldout.cs new file mode 100644 index 0000000000..c3b09dc367 --- /dev/null +++ b/Projectiles/Ranged/StarfleetHoldout.cs @@ -0,0 +1,312 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarfleetHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => base.GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -5; + public override float RecoilResolveSpeed => 0.1f; + public override float MaxOffsetLengthFromArm => 25f; + public override float OffsetXUpwards => -12f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 10f; + public override float WeaponTurnSpeed => (0.6f); + + public int time = 0; + public int lastUseTime = 0; + public int perfectLeniancy = 2; + public int goodLeniancy => perfectLeniancy + 6; + public ref float shootingCooldown => ref Projectile.ai[0]; + public ref float starburstTimer => ref Projectile.ai[1]; + public int extendedCooldown => (int)(lastUseTime * 1.2f); + public int naildriverCooldown => (int)(lastUseTime * 1.5f); + public int starburstPerfectTime = 23; + public float recoilIntensity = 0; + public int recoilTimerMax = 62; + public Vector2 recoilDirection; + public bool setVel = true; + public float glowIntensity = 1; + public Color c1 = new Color(146, 255, 211); + public Color c2 = new Color(222, 225, 146); + public Color c3 = new Color(255, 233, 146); + public Color shiftColor; + public ref float starburstCooldown => ref Projectile.ai[2]; + public bool naildriver => ((starburstTimer <= starburstPerfectTime + perfectLeniancy) && (starburstTimer >= starburstPerfectTime - perfectLeniancy)); // if within perfect frame window + public bool scattershot => !naildriver && ((starburstTimer <= starburstPerfectTime + goodLeniancy) && (starburstTimer >= starburstPerfectTime - goodLeniancy)); // If within early or late frame window + public override void KillHoldoutLogic() { } + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; + } + public override void HoldoutAI() + { + float rate = (time * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); + + SetUsage = false; + bool doingNothing = shootingCooldown == 0 && starburstCooldown == 0 && starburstTimer == 0; + if (lastUseTime == 0 || doingNothing) + lastUseTime = Owner.HeldItem.useAnimation; + if (!doingNothing) + Owner.itemTime = Owner.itemAnimation = 5; + + glowIntensity = MathHelper.Lerp(glowIntensity, (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax, 0, shootingCooldown, true), 5), 0.2f); + + if ((Owner.HeldItem.type != ItemType() && doingNothing) || (doingNothing && (Main.mapFullscreen || Owner.mouseInterface)) || Owner.dead) + { + Projectile.Kill(); + return; + } + bool hasAmmo = Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, true); + bool leftShootChecks = (Main.mouseLeft && !Main.mapFullscreen && !Owner.mouseInterface && shootingCooldown == 0) && hasAmmo; + bool rightShootChecks = Owner.Calamity().mouseRight && !Main.mapFullscreen && !Owner.mouseInterface && starburstCooldown == 0 && starburstTimer == 0; + + if (Main.mouseLeft && !hasAmmo && OffsetLengthFromArm >= 24.5f) + { + OffsetLengthFromArm -= 8; + SoundStyle click = new("CalamityMod/Sounds/Item/DudFire"); + SoundEngine.PlaySound(click with { Volume = .6f, Pitch = -.2f }, Projectile.Center); + } + if (leftShootChecks) + FireShotgun(); + if (rightShootChecks) + { + SoundStyle test = new("CalamityMod/Sounds/Item/StarfleetStarburst"); + SoundEngine.PlaySound(test with { Volume = 1f, Pitch = 0f }, Projectile.Center); + starburstTimer++; + } + if (starburstTimer > 0) + { + // Do wind up animation + if (starburstTimer < starburstPerfectTime / 2) + OffsetLengthFromArm = 25 - 12 * (1 - (float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2 - 1, 0, starburstTimer, true), 5)); + else + OffsetLengthFromArm = 13 + 20 * ((float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2, starburstPerfectTime - 1, starburstTimer, true), 8)); + + if (starburstTimer == starburstPerfectTime) + FireStarburst(); + + starburstTimer++; + if (starburstTimer > starburstPerfectTime + goodLeniancy + 1) + starburstTimer = 0; + } + if (shootingCooldown > 0) + shootingCooldown--; + if (starburstCooldown > 0) + starburstCooldown--; + if (recoilIntensity > 0 && (shootingCooldown > 0 || starburstCooldown > 0)) + ManageRecoil(); + time++; + } + public void ManageRecoil() + { + float slowdown = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4); + Vector2 movement = recoilDirection * (recoilIntensity) * slowdown; + bool enableRecoil = false; + if (!enableRecoil || Collision.SolidCollision(Owner.Center + movement, (int)(Owner.width * 1.1f), (int)(Owner.height * 1.1f)) || !Owner.Calamity().mouseRight) + { + recoilIntensity = 0; + return; + } + if (slowdown > 0.1f) + { + if (setVel) + { + Owner.velocity = movement * 0.25f; + setVel = false; + } + Projectile.Center += movement; + Owner.Center += movement; + } + else + setVel = true; + } + public void FireShotgun() + { + // 50% chance to not consume ammo + Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, Main.rand.NextBool()); + + SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarfleetFire"); + for (int i = 0; i < (naildriver ? 2 : 1); i++) + SoundEngine.PlaySound(shotgunFire with { Volume = (naildriver && i == 0 ? 0.3f : 0.6f), Pitch = ((naildriver && i == 0) ? 0f : 0.2f), MaxInstances = 2 }, Projectile.Center); + // Perfects have longer cooldown + int cooldown = (naildriver ? naildriverCooldown : lastUseTime); + recoilTimerMax = cooldown; + shootingCooldown = cooldown; + recoilDirection = -Projectile.velocity; + Owner.SetScreenshake(naildriver ? 9 : scattershot ? 7 : 4); + OffsetLengthFromArm = naildriver ? 0 : scattershot ? 7 : 15; + + if (Main.myPlayer == Projectile.owner) + { + int baseShotCount = 6; + for (int i = 0; i < baseShotCount; i++) + { + float randomVel = Main.rand.NextFloat(0.8f, 1f); + float damageMult = ((naildriver || scattershot) ? 1.75f : 1f) / baseShotCount; + float spread = (naildriver ? 0.06f : scattershot ? 0.9f : 0.25f); + Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(spread) * 8, ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner, 0, 0, Main.rand.Next(0, 300 + 1)); + shotgun.extraUpdates = naildriver ? 9 : scattershot ? 7 : 3; + } + } + + for (int i = 0; i < 25; i++) + { + float variance = Main.rand.NextFloat(-0.7f, 0.7f); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(GunTipPosition, dustStyle); + dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 3f; + dust.velocity = Projectile.velocity.RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 4.75f; + } + + // You can uncomment this to check your timing + /*if (naildriver) + Main.NewText("naildriver: " + (starburstPerfectTime - starburstTimer), Color.DarkOrchid); + if (scattershot) + Main.NewText("scattershot: " + (starburstPerfectTime - starburstTimer), Color.Lime);*/ + + recoilIntensity = (naildriver ? 55f : scattershot ? 20f : 0); + } + public void FireStarburst() + { + Owner.SetScreenshake(7f); + recoilDirection = -Projectile.velocity; + if (recoilIntensity < 15) + recoilIntensity = 15; + if (recoilTimerMax < extendedCooldown) + recoilTimerMax = extendedCooldown; + if (starburstCooldown < extendedCooldown) + starburstCooldown = extendedCooldown; + + if (Main.myPlayer == Projectile.owner) + { + float blastSize = 140; + float minMultiplier = 0.1f; + int hitsToMinMult = 6; + Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 3, -45, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 15; + } + + for (int i = 0; i < 14; i++) + { + float dist = Main.rand.NextFloat(0, 3); + Particle forwardJet = new CustomSpark(GunTipPosition + Main.rand.NextVector2CircularEdge(dist * 5, dist * 5), Projectile.velocity * Main.rand.NextFloat(4, 5) * (6 - dist * 2), "CalamityMod/Particles/ForwardSmear", false, (int)(Main.rand.Next(9, 15 + 1) + (dist * 3)), Main.rand.NextFloat(0.1f, 0.2f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: 0.3f); + GeneralParticleHandler.SpawnParticle(forwardJet); + } + for (int i = 0; i < 34; i++) + { + float rot = Main.rand.NextFloat(0.05f, 0.35f) * (Main.rand.NextBool() ? -1 : 1); + Vector2 startVel = Projectile.velocity.RotatedBy(rot) * Main.rand.NextFloat(8, 18) * (Main.rand.NextBool(4) ? 2f : 1); + Particle stars = new VelChangingSpark(GunTipPosition, startVel, startVel.RotatedBy(rot * 5), "CalamityMod/Particles/PulseStar", Main.rand.Next(25, 45 + 1), Main.rand.NextFloat(0.1f, 0.35f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: Main.rand.NextFloat(0.02f, 0.06f), lerpRate: 0.02f, glowCenter: true); + GeneralParticleHandler.SpawnParticle(stars); + } + int parts = 60; + for (int i = 0; i < parts; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / parts).ToRotationVector2() * 4f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxPlace = GunTipPosition + fxVel.RotatedBy(Projectile.velocity.ToRotation()); + + float size = Utils.GetLerpValue(0, -4, intenededVel.X, true); + float width = Utils.GetLerpValue(0, 4 * Math.Sign(fxVel.X), fxVel.X, true); + Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f)); + + Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(15 + size * 5), 0.35f + size * 0.2f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); + GeneralParticleHandler.SpawnParticle(aura); + + } + } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D glowTexture = Request("CalamityMod/Items/Weapons/Ranged/StarfleetGlow").Value; + Texture2D orb = Request("CalamityMod/Particles/BloomCircle").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float glowMult = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4); + int draws = 18; + float sine = (float)Math.Sin(time * 0.02f); + float attackMult = (float)Math.Pow(Utils.GetLerpValue(0, starburstPerfectTime - 1, starburstTimer, true), 2); + float sine2 = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 55.5f / MathHelper.Pi); + float fastSine = (float)Math.Sin(time * 0.2f); + Color glowColor = shiftColor; + + if (starburstTimer > 0 && starburstCooldown == 0) + { + for (int i = 0; i < draws; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time * 2); + Main.EntitySpriteDraw(texture, drawPosition + drawOffset * 6 * attackMult, null, shiftColor with { A = 0 } * 0.7f * attackMult, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + for (int i = 0; i < draws; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4); + Main.EntitySpriteDraw(glowTexture, drawPosition + drawOffset, null, Color.Lerp(Color.Gray * 0.15f, glowColor with { A = 0 }, glowIntensity) * (0.1f + 0.5f * glowMult), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + } + + if (starburstTimer > 0 && starburstCooldown == 0) + { + for (int i = 0; i < 6; i++) + { + // The shining orb at the tip + Color orbColor = shiftColor with { A = 0 } * 0.5f; + Vector2 scale = new Vector2(Math.Abs(sine2 * 0.5f) + 0.1f, 1) * (0.05f + i * 0.01f) * attackMult * Main.rand.NextFloat(0.9f, 1.1f) * 8.5f; + Main.EntitySpriteDraw(orb, GunTipPosition - Main.screenPosition, null, orbColor, Main.rand.NextFloat(-5, 5), orb.Size() * 0.5f, scale, SpriteEffects.None); + } + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/StarfleetMK2Gun.cs b/Projectiles/Ranged/StarfleetMK2Gun.cs deleted file mode 100644 index 304bdf7b2b..0000000000 --- a/Projectiles/Ranged/StarfleetMK2Gun.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class StarfleetMK2Gun : ModProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/Starmada"; - - public override void SetDefaults() - { - Projectile.width = 122; - Projectile.height = 50; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, 32f / 255f, 208f / 255f, 255f / 255f); - Player player = Main.player[Projectile.owner]; - Projectile.ai[1]--; - if (Projectile.ai[0] >= 0f) - { - Projectile.ai[0] += 1f; - switch ((int)Projectile.ai[0]) - { - case 90: - case 180: - case 270: - case 360: - case 450: - Projectile.localAI[0] += 1f; - break; - case 540: - Projectile.localAI[0] += 1f; - Projectile.ai[0] = -1f; - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - int dustAmt = 36; - for (int d = 0; d < dustAmt; d++) - { - Vector2 source = Vector2.Normalize(Projectile.velocity) * 9f; - source = source.RotatedBy((d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / dustAmt, default) + player.Center; - Vector2 dustVel = source - player.Center; - int index = Dust.NewDust(source + dustVel, 0, 0, DustID.FireworkFountain_Blue, 0f, 0f, 0, default, 4f); - Main.dust[index].noGravity = true; - Main.dust[index].velocity = dustVel; - } - break; - } - } - int baseUseTime = 27; //Ranges from 27 to 15 use time - int modifier = 2; - bool timeToFire = false; - if (Projectile.ai[1] <= 0f) - { - Projectile.ai[1] = baseUseTime - modifier * Projectile.localAI[0]; - timeToFire = true; - } - bool canFire = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem()); - if (Projectile.soundDelay <= 0 && canFire) - { - Projectile.soundDelay = baseUseTime - modifier * (int)Projectile.localAI[0]; - if (Projectile.ai[0] != 1f) - SoundEngine.PlaySound(SoundID.Item92, Projectile.Center); - } - if (timeToFire && Main.myPlayer == Projectile.owner) - { - if (canFire) - { - int type = ProjectileID.StarCannonStar; - float shootSpeed = 16f; - int damage = player.GetWeaponDamage(player.ActiveItem()); - float knockBack = player.ActiveItem().knockBack; - player.PickAmmo(player.ActiveItem(), out type, out shootSpeed, out damage, out knockBack, out _); - for (int i = 0; i < 5; i++) - { - knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); - Vector2 playerPosition = player.RotatedRelativePoint(player.MountedCenter, true); - Projectile.velocity = Main.screenPosition - playerPosition; - Projectile.velocity.X += Main.mouseX; - Projectile.velocity.Y += Main.mouseY; - if (player.gravDir == -1f) - Projectile.velocity.Y = Main.screenHeight - Main.mouseY + Main.screenPosition.Y - playerPosition.Y; - Projectile.velocity.Normalize(); - float variation = (1f + Projectile.localAI[0]) * 3f; - Vector2 position = playerPosition + Utils.RandomVector2(Main.rand, -variation, variation); - Vector2 speed = Projectile.velocity * shootSpeed * Main.rand.NextFloat(0.6f, 1.2f); - type = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ProjectileID.StarCannonStar, - ProjectileID.Starfury - }); - int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, speed, type, damage, knockBack, Projectile.owner); - if (star.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[star].penetrate = 1; - Main.projectile[star].timeLeft = 300; - Main.projectile[star].DamageType = DamageClass.Ranged; - Main.projectile[star].netUpdate = true; - } - Projectile.netUpdate = true; - } - } - else - { - Projectile.Kill(); - } - } - Projectile.rotation = Projectile.velocity.ToRotation(); - Vector2 displayOffset = new Vector2(27f, -10f * Projectile.direction).RotatedBy(Projectile.rotation); - Projectile.Center = player.RotatedRelativePoint(player.MountedCenter, true) + displayOffset; - if (Projectile.spriteDirection == -1) - Projectile.rotation += MathHelper.Pi; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - player.ChangeDir(Projectile.direction); - player.heldProj = Projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - player.itemRotation = (float)Math.Atan2(Projectile.velocity.Y * Projectile.direction, Projectile.velocity.X * Projectile.direction); - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Ranged/StarfleetStar.cs b/Projectiles/Ranged/StarfleetStar.cs new file mode 100644 index 0000000000..13c18cf074 --- /dev/null +++ b/Projectiles/Ranged/StarfleetStar.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarfleetStar : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public Color c1 = new Color(146, 255, 211); + public Color c2 = new Color(222, 225, 146); + public Color c3 = new Color(255, 233, 146); + public Color shiftColor; + public Player Owner => Main.player[Projectile.owner]; + public override void SetDefaults() + { + Projectile.width = 25; + Projectile.height = 25; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 1; + Projectile.penetrate = 3; + Projectile.timeLeft = 600; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + float rate = (Projectile.ai[2] * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); + Projectile.ai[2]++; + + if (time > 5 && time % 2 == 0) + { + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, shiftColor * 0.6f, new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f); + GeneralParticleHandler.SpawnParticle(trail); + + if (time > 18) + { + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f); + dust.velocity = -Projectile.velocity * Main.rand.NextFloat(3f, 5f); + dust.noGravity = true; + dust.color = shiftColor; + dust.fadeIn = 5f; + } + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + time++; + } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D glowTexture = Request("CalamityMod/Projectiles/Rogue/LeonidStar").Value; + Texture2D tex2 = Request("CalamityMod/Particles/FadeStreak").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = glowTexture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + for (int i = 0; i < 5; i++) + { + Vector2 offset = (MathHelper.TwoPi * i / 5).ToRotationVector2().RotatedBy(Projectile.rotation + MathHelper.Pi); + for (int t = 0; t < 2; t++) + Main.EntitySpriteDraw(tex2, drawPosition, null, shiftColor with { A = 0 } * 0.4f, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2((2.3f + t * 0.03f) * (i == 2 ? 1.8f : i == 3 ? 1.8f : 1), (1.1f + t * 0.03f) * (i == 2 ? 0.75f : i == 3 ? 0.75f : 1)) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(tex2, drawPosition, null, Color.White with { A = 0 } * 0.4f, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2(1.5f, 0.7f) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); + } + return false; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.1f; + int hitsToMinMult = 2; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 15; i++) + { + float variance = Main.rand.NextFloat(-0.5f, 0.5f); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 1.5f; + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 2.5f; + } + } + + } +} diff --git a/Projectiles/Ranged/StarmadaBack.png b/Projectiles/Ranged/StarmadaBack.png new file mode 100644 index 0000000000..0ab54481ce Binary files /dev/null and b/Projectiles/Ranged/StarmadaBack.png differ diff --git a/Projectiles/Ranged/StarmadaBackGlow.png b/Projectiles/Ranged/StarmadaBackGlow.png new file mode 100644 index 0000000000..272ee30ca2 Binary files /dev/null and b/Projectiles/Ranged/StarmadaBackGlow.png differ diff --git a/Projectiles/Ranged/StarmadaFront.png b/Projectiles/Ranged/StarmadaFront.png new file mode 100644 index 0000000000..56513025f1 Binary files /dev/null and b/Projectiles/Ranged/StarmadaFront.png differ diff --git a/Projectiles/Ranged/StarmadaFrontGlow.png b/Projectiles/Ranged/StarmadaFrontGlow.png new file mode 100644 index 0000000000..8a230dbe1f Binary files /dev/null and b/Projectiles/Ranged/StarmadaFrontGlow.png differ diff --git a/Projectiles/Ranged/StarmadaHitProj.cs b/Projectiles/Ranged/StarmadaHitProj.cs new file mode 100644 index 0000000000..7349e0875a --- /dev/null +++ b/Projectiles/Ranged/StarmadaHitProj.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarmadaHitProj : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; + public bool move = false; + public NPC targeted; + public Vector2 targetPos; + public Vector2 distFromPos; + public float squash = 1; + public bool launched => Projectile.localAI[2] == 5 && move; + public bool setLaunchStats = true; + public Player Owner => Main.player[Projectile.owner]; + public override void SetDefaults() + { + Projectile.width = 25; + Projectile.height = 25; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 3; + Projectile.penetrate = -1; + Projectile.timeLeft = 800; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + } + public void FindTarget() + { + if (Projectile.ai[0] != -5) + targeted = Main.npc[(int)Projectile.ai[0]]; + if (targeted == null || !targeted.CanBeChasedBy(Projectile, false) || !targeted.active) + { + targeted = Projectile.Center.ClosestNPCAt(800); + Projectile.ai[0] = -5; + } + } + + public override void AI() + { + if (time == 0) + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + targetPos = Projectile.Center; + } + float rate = (Projectile.ai[2] * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); + Projectile.ai[2]++; + + float startTime = 120 + Projectile.ai[1]; + float endTime = startTime + 15 + Projectile.ai[1]; + if (launched) + { + if (setLaunchStats) + { + Projectile.extraUpdates = 12; + Projectile.penetrate = 1; + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; + + setLaunchStats = false; + } + Projectile.rotation += (MathHelper.TwoPi) / (endTime / 3); + if (time % 2 == 0) + { + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/BloomCircle", false, 13, 0.11f, shiftColor * 0.6f, new Vector2(launched ? 5.5f : 0.8f, 3f), shrinkSpeed: launched ? 1f : 0.5f); + GeneralParticleHandler.SpawnParticle(trail); + } + } + else + { + if (move) + { + squash = MathHelper.Lerp(squash, (time < endTime ? 0.15f : 1f), 0.08f); + if (time == endTime) + Projectile.localAI[2] = 1; + if (time >= endTime) + { + if (Main.rand.NextBool(15)) + { + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f); + dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5f, 7f); + dust.noGravity = true; + dust.color = shiftColor; + dust.fadeIn = 2f; + } + + Projectile.Center += Projectile.velocity.SafeNormalize(Vector2.UnitX) * 0.2f; + if (time < endTime * 2f) + Projectile.velocity *= 0.9f + (Projectile.ai[1] * 0.005f); + + Projectile.rotation += (MathHelper.TwoPi) / (endTime / 3); + } + else + { + Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.velocity.ToRotation() + MathHelper.PiOver2, 0.1f); + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/BloomCircle", false, 15, 0.3f, shiftColor, new Vector2(0.8f, 1.3f), shrinkSpeed: 0.5f); + GeneralParticleHandler.SpawnParticle(trail); + } + } + else + { + Projectile.rotation += MathHelper.TwoPi / (startTime / 3); + + FindTarget(); + if (targeted != null) + { + targetPos = targeted.Center; + } + if (distFromPos != Vector2.Zero) + { + Projectile.Center = targetPos + distFromPos; + } + else if (targeted != null) + distFromPos = (Projectile.Center - targeted.Center); + + + distFromPos += -Projectile.velocity * 3.5f; + Projectile.velocity *= 0.97f + (Projectile.ai[1] * 0.0025f); + } + } + if (time == startTime && setLaunchStats) + { + Projectile.timeLeft = (int)(endTime * 3); + move = true; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15; + } + + Projectile.scale = (float)Math.Pow(Math.Min(Utils.GetLerpValue(0, 40, time, true), Utils.GetLerpValue(0, 40, Projectile.timeLeft, true)), 3); + + time++; + } + public override bool ShouldUpdatePosition() => move; + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D star = Request("CalamityMod/ExtraTextures/SimpleStar").Value; + Texture2D tex = Request("CalamityMod/Particles/CircularSmear").Value; + Texture2D tex2 = Request("CalamityMod/Particles/FadeStreak").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = star.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(tex, drawPosition, null, shiftColor with { A = 0 } * Math.Max((float)Math.Pow(squash, 5) - 0.15f, 0), Projectile.rotation * 1.6f, tex.Size() * 0.5f, Projectile.scale * Owner.gravDir * 0.39f, SpriteEffects.None); + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(star, drawPosition, null, i == 0 ? Color.White with { A = 0 } * 0.3f : (shiftColor with { A = 0 } * 0.6f), Projectile.rotation, rotationPoint, new Vector2(1f * squash, 1f + (1 - squash)) * Projectile.scale * Owner.gravDir * (i == 0 ? 0.12f : 0.2f), SpriteEffects.None); + return false; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + + float minMult = 0.1f; + int hitsToMinMult = 2; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult * (launched ? 2 : 1); + } + public override void OnKill(int timeLeft) + { + if (launched) + { + float rot = Main.rand.NextFloat(0, MathHelper.TwoPi); + for (int b = 1; b <= 6; b++) + { + for (int i = 0; i < 5; i++) + { + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust.scale = 8 - b; + dust.velocity = -Vector2.UnitY.RotatedBy((MathHelper.TwoPi / 5 * i) + rot) * (b * 1.75f + 2); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 6.5f - b * 0.5f; + } + } + Particle bloom = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 25, 1.2f, shiftColor, new Vector2(1, 1), true, true, 0, false, false, glowOpacity: 0.85f); + GeneralParticleHandler.SpawnParticle(bloom); + } + } + + } +} diff --git a/Projectiles/Ranged/StarmadaHoldout.cs b/Projectiles/Ranged/StarmadaHoldout.cs new file mode 100644 index 0000000000..41fc43d182 --- /dev/null +++ b/Projectiles/Ranged/StarmadaHoldout.cs @@ -0,0 +1,477 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarmadaHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => base.GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -5; + public override float RecoilResolveSpeed => 0.1f; + public override float MaxOffsetLengthFromArm => 32f; + public override float OffsetXUpwards => -12f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 10f; + public override float WeaponTurnSpeed => (0.6f); + + public int time = 0; + public int lastUseTime = 0; + public int perfectLeniancy = 2; + public float frontRecoil = 0; + public int goodLeniancy => perfectLeniancy + 6; + public ref float shootingCooldown => ref Projectile.ai[0]; + public ref float starburstTimer => ref Projectile.ai[1]; + public int extendedCooldown => (int)(lastUseTime * 1.2f); + public int perfectCooldown => (int)(lastUseTime * 1.5f); + public int starburstPerfectTime = 23; + public float recoilIntensity = 0; + public int recoilTimerMax = 62; + public Vector2 recoilDirection; + public bool setVel = true; + public float glowIntensity = 1; + public float attackVisualMult = 0; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; + public Vector2 gunBackPosition; + public int gunPower = 1; + public int lastGunPower = 1; + public SlotId AudSlot1; + public SlotId AudSlot2; + public bool failedChain = false; + public float shake = 0; + public ref float starburstCooldown => ref Projectile.ai[2]; + public bool naildriver => ((starburstTimer <= starburstPerfectTime + perfectLeniancy) && (starburstTimer >= starburstPerfectTime - perfectLeniancy)); // if within perfect frame window + public bool scattershot => !naildriver && ((starburstTimer <= starburstPerfectTime + goodLeniancy) && (starburstTimer >= starburstPerfectTime - goodLeniancy)); // If within early or late frame window + public override void KillHoldoutLogic() { } + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; + } + public override void HoldoutAI() + { + float rate = (time * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); + + SetUsage = false; + bool doingNothing = shootingCooldown == 0 && starburstCooldown == 0 && starburstTimer == 0; + if (lastUseTime == 0 || doingNothing) + lastUseTime = Owner.HeldItem.useAnimation; + if (!doingNothing) + Owner.itemTime = Owner.itemAnimation = 5; + + glowIntensity = MathHelper.Lerp(glowIntensity, (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax, 0, shootingCooldown, true), 5), 0.2f); + attackVisualMult = MathHelper.Lerp(attackVisualMult, (float)Math.Pow(Math.Min(Utils.GetLerpValue(0, starburstPerfectTime - 1, starburstTimer, true), 2) + (gunPower - 1) * 0.25f, 1) * glowIntensity, 0.2f); + shake = MathHelper.Lerp(shake, 0, 0.05f); + frontRecoil = MathHelper.Lerp(frontRecoil, 0, 0.11f); + + if ((Owner.HeldItem.type != ItemType() && doingNothing) || (doingNothing && (Main.mapFullscreen || Owner.mouseInterface)) || Owner.dead) + { + Projectile.Kill(); + return; + } + bool hasAmmo = Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, true); + bool leftShootChecks = (Main.mouseLeft && !Main.mapFullscreen && !Owner.mouseInterface && shootingCooldown == 0) && hasAmmo; + bool rightShootChecks = Owner.Calamity().mouseRight && !Main.mapFullscreen && !Owner.mouseInterface && starburstCooldown == 0 && starburstTimer == 0; + + if (Main.mouseLeft && !hasAmmo && shake < 0.1f) + { + shake = 0.8f; + SoundStyle click = new("CalamityMod/Sounds/Item/DudFire"); + SoundEngine.PlaySound(click with { Volume = .6f, Pitch = -.2f}, Projectile.Center); + } + + if (leftShootChecks) + FireShotgun(); + if (rightShootChecks) + { + SoundStyle blast1 = new("CalamityMod/Sounds/Item/StarfleetStarburst"); + AudSlot1 = SoundEngine.PlaySound(blast1 with { Volume = 0.7f + gunPower * 0.1f, Pitch = 0f, MaxInstances = 8 }, Projectile.Center); + SoundStyle blast2 = new("CalamityMod/Sounds/Item/StarfleetStarburst"); + AudSlot2 = SoundEngine.PlaySound(blast2 with { Volume = 0.5f + gunPower * 0.1f, Pitch = -0.2f + gunPower * 0.2f, MaxInstances = 8 }, Projectile.Center); + lastGunPower = gunPower; + starburstTimer++; + } + if (starburstTimer > 0) + { + // Do wind up animation + if (starburstTimer < starburstPerfectTime / 2) + { + float up = (1 - (float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2 - 1, 0, starburstTimer, true), 2)); + OffsetLengthFromArm = 32 - 7 * up; + frontRecoil = -25 * up; + } + else + { + float down = ((float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2, starburstPerfectTime - 1, starburstTimer, true), 12)); + OffsetLengthFromArm = 25 + 15 * down; + frontRecoil = -25 + 25 * down; + } + + if (starburstTimer == starburstPerfectTime) + FireStarburst(); + + starburstTimer++; + if (starburstTimer > starburstPerfectTime + goodLeniancy + 1) + starburstTimer = 0; + } + if (shootingCooldown > 0) + { + if (lastGunPower != gunPower) + { + if (SoundEngine.TryGetActiveSound(AudSlot1, out var s1) && s1.IsPlaying && failedChain) + { + s1.Pitch = MathHelper.Lerp(s1.Pitch, -0.7f, 0.07f); + s1.Volume = MathHelper.Lerp(s1.Volume, 0.2f, 0.07f); + } + if (SoundEngine.TryGetActiveSound(AudSlot2, out var s2) && s2.IsPlaying && failedChain) + { + s2.Pitch = MathHelper.Lerp(s2.Pitch, -0.7f, 0.07f); + s2.Volume = MathHelper.Lerp(s2.Volume, 0.2f, 0.07f); + } + } + shootingCooldown--; + } + else + failedChain = false; + if (starburstCooldown > 0) + starburstCooldown--; + if (recoilIntensity > 0 && (shootingCooldown > 0 || starburstCooldown > 0)) + ManageRecoil(); + + time++; + } + public void ManageRecoil() + { + float slowdown = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4); + Vector2 movement = recoilDirection * (recoilIntensity) * slowdown; + bool enableRecoil = false; + if (!enableRecoil || Collision.SolidCollision(Owner.Center + movement, (int)(Owner.width * 1.1f), (int)(Owner.height * 1.1f)) || !Owner.Calamity().mouseRight) + { + recoilIntensity = 0; + return; + } + if (slowdown > 0.1f) + { + if (setVel) + { + Owner.velocity = movement * 0.25f; + setVel = false; + } + Projectile.Center += movement; + Owner.Center += movement; + } + else + setVel = true; + } + public void FireShotgun() + { + // 50% chance to not consume ammo + Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, Main.rand.NextBool()); + + + if (!naildriver && gunPower > 1) + { + shake = 4; + failedChain = true; + SoundStyle oops = new("CalamityMod/Sounds/Item/TaserLaunch"); + SoundStyle oops2 = new("CalamityMod/Sounds/Item/LightMetal"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound((i == 0 ? oops : oops2) with { Volume = 1f, Pitch = (i == 0 ? 0.5f : -0.3f), MaxInstances = 2 }, Projectile.Center); + } + else + { + SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarmadaFire"); + for (int i = 0; i < (naildriver ? 2 : 1); i++) + SoundEngine.PlaySound(shotgunFire with { Volume = (naildriver && i == 0 ? 0.3f : 0.6f), Pitch = ((naildriver && i == 0) ? -0.2f : 0f), MaxInstances = 2 }, Projectile.Center); + + for (int b = 0; b < 24; b++) + { + int parts2 = 4; + for (int i = 0; i < parts2; i++) + { + float power = Main.rand.NextFloat(0.2f, 1f); + Vector2 vel = (MathHelper.TwoPi * i / parts2).ToRotationVector2().RotatedBy(Projectile.rotation) * 12f; + float size = (0.8f + 0.35f * gunPower) * Main.rand.NextFloat(0.9f, 1.1f) * (1.1f - power); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(gunBackPosition, dustStyle); + dust.scale = size; + dust.velocity = vel * power * (0.7f + gunPower * 0.2f); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 0f; + + if (b == 0) + { + Particle aura = new CustomSpark(gunBackPosition, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 20, size * 0.9f, shiftColor, new Vector2(0.65f, 1f), glowCenter: true, glowOpacity: 0.8f, glowCenterScale: 0.85f, extraRotation: Projectile.rotation + (i % 2 == 0 ? MathHelper.PiOver2 : 0), shrinkSpeed: 0.1f); + GeneralParticleHandler.SpawnParticle(aura); + } + } + } + } + + // Perfects have longer cooldown + int cooldown = (naildriver ? perfectCooldown : lastUseTime); + recoilTimerMax = cooldown; + shootingCooldown = cooldown; + recoilDirection = -Projectile.velocity; + Owner.SetScreenshake(naildriver ? 9 + gunPower : scattershot ? 8 : 5); + OffsetLengthFromArm = naildriver ? 0 : scattershot ? 7 : 15; + frontRecoil = naildriver ? -25 : scattershot ? -18 : -10; + + float gunPowerMult = MathHelper.Lerp(gunPower, 1, 0.7f); + + if (Main.myPlayer == Projectile.owner) + { + int baseShotCount = 7; + for (int i = 0; i < baseShotCount + gunPower; i++) + { + float randomVel = Main.rand.NextFloat(0.8f, 1f); + float damageMult = ((naildriver || scattershot) ? 1.75f : 1f) / baseShotCount; + float spread = (i == 0 ? 0f : naildriver ? 0.06f : scattershot ? 0.9f : 0.25f) * MathHelper.Lerp(gunPower, 1, 0.75f); + Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(spread) * 8, ProjectileType(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner, 0, 0, Main.rand.Next(0, 300 + 1)); + shotgun.extraUpdates = naildriver ? 9 : scattershot ? 7 : 3; + } + } + for (int i = 0; i < (int)(25 * gunPowerMult); i++) + { + float variance = Main.rand.NextFloat(-0.7f, 0.7f); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(GunTipPosition, dustStyle); + dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 3f * gunPowerMult; + dust.velocity = Projectile.velocity.RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2) * gunPowerMult; + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 3.75f; + } + + // You can uncomment this to check your timing + /*if (naildriver) + Main.NewText("naildriver: " + (starburstPerfectTime - starburstTimer), Color.DarkOrchid); + if (scattershot) + Main.NewText("scattershot: " + (starburstPerfectTime - starburstTimer), Color.Lime);*/ + + if (naildriver && gunPower < 3) + gunPower++; + if (scattershot || (!naildriver && !scattershot)) + gunPower = 1; + + recoilIntensity = (naildriver ? 70f : scattershot ? 25f : 0); + setVel = true; + } + public void FireStarburst() + { + Owner.SetScreenshake(8f); + recoilDirection = -Projectile.velocity; + if (recoilIntensity < 19) + recoilIntensity = 19; + if (recoilTimerMax < extendedCooldown) + recoilTimerMax = extendedCooldown; + if (starburstCooldown < extendedCooldown) + starburstCooldown = extendedCooldown; + setVel = true; + + if (Main.myPlayer == Projectile.owner) + { + Vector2 blastCenter = GunTipPosition + Projectile.velocity * 10; + float blastSize = 140 + 15 * lastGunPower; + float minMultiplier = 0.1f; + int hitsToMinMult = 8; + int damage = (int)(Projectile.damage * (1 + lastGunPower * 0.5f)); + Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), blastCenter, Vector2.Zero, ProjectileType(), damage, -45, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 15; + } + + float gunPowerMult = MathHelper.Lerp(lastGunPower, 1, 0.7f); + for (int i = 0; i < 20; i++) + { + float dist = Main.rand.NextFloat(1, 4); + Particle forwardJet = new CustomSpark(GunTipPosition + Main.rand.NextVector2CircularEdge(dist * 3.5f, dist * 3.5f), Projectile.velocity * Main.rand.NextFloat(5, 6) * (8 - dist * 2) * gunPowerMult, "CalamityMod/Particles/ForwardSmear", false, (int)(Main.rand.Next(9, 15 + 1) + (dist * 3)), Main.rand.NextFloat(0.15f, 0.25f) * gunPowerMult, GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: 0.3f); + GeneralParticleHandler.SpawnParticle(forwardJet); + } + for (int i = 0; i < 34; i++) + { + float rot = Main.rand.NextFloat(0.05f, 0.35f) * (Main.rand.NextBool() ? -1 : 1); + Vector2 startVel = Projectile.velocity.RotatedBy(rot) * Main.rand.NextFloat(8, 18) * (Main.rand.NextBool(4) ? 2f : 1); + Particle stars = new VelChangingSpark(GunTipPosition, startVel * gunPowerMult, startVel.RotatedBy(rot * 5) * gunPowerMult, "CalamityMod/Particles/PulseStar", Main.rand.Next(25, 45 + 1), Main.rand.NextFloat(0.1f, 0.35f) * gunPowerMult, GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: Main.rand.NextFloat(0.02f, 0.06f), lerpRate: 0.02f, glowCenter: true); + GeneralParticleHandler.SpawnParticle(stars); + } + if (lastGunPower == 3) + { + int parts2 = 45; + for (int i = 0; i < parts2; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / parts2).ToRotationVector2() * 3f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxPlace = GunTipPosition + Projectile.velocity * 45 + fxVel.RotatedBy(Projectile.velocity.ToRotation()); + + float size = Utils.GetLerpValue(0, -3, intenededVel.X, true); + float width = Utils.GetLerpValue(0, 3 * Math.Sign(fxVel.X), fxVel.X, true); + Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f)); + + Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(15 + size * 5), 0.35f + size * 0.2f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); + GeneralParticleHandler.SpawnParticle(aura); + + } + } + if (lastGunPower >= 2) + { + int parts = 85; + for (int i = 0; i < parts; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / parts).ToRotationVector2() * 5f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxPlace = GunTipPosition + fxVel.RotatedBy(Projectile.velocity.ToRotation()); + + float size = Utils.GetLerpValue(0, -5, intenededVel.X, true); + float width = Utils.GetLerpValue(0, 5 * Math.Sign(fxVel.X), fxVel.X, true); + Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f)); + + Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(19 + size * 6), 0.45f + size * 0.23f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); + GeneralParticleHandler.SpawnParticle(aura); + + } + } + else + { + int parts = 70; + for (int i = 0; i < parts; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / parts).ToRotationVector2() * 4f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxPlace = GunTipPosition + fxVel.RotatedBy(Projectile.velocity.ToRotation()); + + float size = Utils.GetLerpValue(0, -4, intenededVel.X, true); + float width = Utils.GetLerpValue(0, 4 * Math.Sign(fxVel.X), fxVel.X, true); + Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f)); + + Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(18 + size * 5), 0.35f + size * 0.23f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); + GeneralParticleHandler.SpawnParticle(aura); + + } + } + } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + + gunBackPosition = Projectile.Center - Projectile.velocity * 38f + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -2; + + Texture2D orb = Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D shine = Request("CalamityMod/Particles/FadeStreak").Value; + + Texture2D front = Request("CalamityMod/Projectiles/Ranged/StarmadaFront").Value; + Texture2D frontGlow = Request("CalamityMod/Projectiles/Ranged/StarmadaFrontGlow").Value; + Texture2D back = Request("CalamityMod/Projectiles/Ranged/StarmadaBack").Value; + Texture2D backGlow = Request("CalamityMod/Projectiles/Ranged/StarmadaBackGlow").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition + Main.rand.NextVector2Circular(8 * shake, 8 * shake); + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float glowMult = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4); + int draws = 14 + 4 * gunPower; + float sine = (float)Math.Sin(time * 0.02f); + float sine2 = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 55.5f / MathHelper.Pi); + float fastSine = (float)Math.Sin(time * 0.2f); + Color glowColor = Color.Lerp(Color.Gray * 0.15f, shiftColor with { A = 0 }, glowIntensity) * (0.1f * gunPower + 0.5f * glowMult); + Vector2 frontRecoilPlace = Projectile.velocity * frontRecoil; + + if ((starburstTimer > 0 && starburstCooldown == 0) || gunPower > 1) + { + for (int i = 0; i < draws; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time * 2); + Main.EntitySpriteDraw(back, drawPosition + drawOffset * (6 + gunPower) * attackVisualMult, null, shiftColor with { A = 0 } * 0.7f * attackVisualMult, drawRotation, back.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(front, drawPosition + drawOffset * (6 + gunPower) * attackVisualMult + frontRecoilPlace, null, shiftColor with { A = 0 } * 0.7f * attackVisualMult, drawRotation, front.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + } + } + + // back + Main.EntitySpriteDraw(back, drawPosition, null, drawColor, drawRotation, back.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + for (int i = 0; i < draws; i++) // back glow + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4) * MathHelper.Lerp(gunPower, 1, 0.75f); + Main.EntitySpriteDraw(backGlow, drawPosition + drawOffset, null, glowColor, drawRotation, backGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(backGlow, drawPosition, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, backGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + } + // front + Main.EntitySpriteDraw(front, drawPosition + frontRecoilPlace, null, drawColor, drawRotation, front.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + for (int i = 0; i < draws; i++) // front glow + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4) * MathHelper.Lerp(gunPower, 1, 0.75f); + Main.EntitySpriteDraw(frontGlow, drawPosition + drawOffset + frontRecoilPlace, null, glowColor, drawRotation, frontGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(frontGlow, drawPosition + frontRecoilPlace, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, frontGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + } + + if (starburstTimer > 0 && starburstCooldown == 0) + { + for (int i = 0; i < 6; i++) + { + // The shining orb at the tip + Color orbColor = shiftColor with { A = 0 } * 0.5f; + Vector2 scale = new Vector2(Math.Abs(sine2 * 0.5f) + 0.1f, 1) * (0.05f + i * 0.01f) * attackVisualMult * Main.rand.NextFloat(0.9f, 1.1f) * 8.5f; + Main.EntitySpriteDraw(orb, GunTipPosition - Main.screenPosition, null, orbColor, Main.rand.NextFloat(-5, 5), orb.Size() * 0.5f, scale, SpriteEffects.None); + } + } + + Color powerColor = Color.Lerp(shiftColor, (gunPower == 1 ? c1 : gunPower == 2 ? c2 : c3), 0.7f); + + float scaleMod = (0.15f + gunPower * 0.1f) * attackVisualMult; + float rand = Main.rand.NextFloat(0.7f, 1f); + for (int i = 0; i < 4; i++) + { + for (int y = 0; y < 2; y++) + Main.EntitySpriteDraw(orb, gunBackPosition - Main.screenPosition, null, powerColor with { A = 0 }, y == 0 ? MathHelper.PiOver2 : 0, orb.Size() * 0.5f, new Vector2(0.5f, 1f) * scaleMod * 0.6f * rand, SpriteEffects.None); + + Vector2 offset = (MathHelper.TwoPi * i / 4).ToRotationVector2().RotatedBy(Projectile.rotation); + for (int t = 0; t < 3; t++) + Main.EntitySpriteDraw(shine, gunBackPosition - Main.screenPosition, null, powerColor with { A = 0 }, offset.ToRotation(), new Vector2(shine.Width * 0.5f, 0), new Vector2((1f - t * 0.1f) * rand + gunPower * 0.05f, 0.5f + t * 0.15f) * Projectile.scale * Owner.gravDir * scaleMod, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(shine, gunBackPosition - Main.screenPosition, null, Color.White with { A = 0 }, offset.ToRotation(), new Vector2(shine.Width * 0.5f, 0), new Vector2(0.5f, 0.75f) * Projectile.scale * Owner.gravDir * scaleMod, SpriteEffects.FlipVertically); + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/StarmadaStar.cs b/Projectiles/Ranged/StarmadaStar.cs new file mode 100644 index 0000000000..6bc3b5b7f9 --- /dev/null +++ b/Projectiles/Ranged/StarmadaStar.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarmadaStar : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; + public Player Owner => Main.player[Projectile.owner]; + public override void SetDefaults() + { + Projectile.width = 25; + Projectile.height = 25; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 1; + Projectile.penetrate = 5; + Projectile.timeLeft = 600; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + float rate = (Projectile.ai[2] * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f >= 1f ? 1f : rate % 1f); + Projectile.ai[2]++; + + if (time > 5 && time % 2 == 0) + { + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, shiftColor, new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f); + GeneralParticleHandler.SpawnParticle(trail); + + if (time > 18) + { + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f); + dust.velocity = -Projectile.velocity * Main.rand.NextFloat(3f, 5f); + dust.noGravity = true; + dust.color = shiftColor; + dust.fadeIn = 5f; + } + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + time++; + } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex2 = Request("CalamityMod/Particles/FadeStreak").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + for (int i = 0; i < 5; i++) + { + Vector2 offset = (MathHelper.TwoPi * i / 5).ToRotationVector2().RotatedBy(Projectile.rotation + MathHelper.Pi); + for (int t = 0; t < 3; t++) + Main.EntitySpriteDraw(tex2, drawPosition, null, shiftColor with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2((2.3f + t * 0.03f) * (i == 2 ? 1.8f : i == 3 ? 1.8f : 1), (1.1f + t * 0.03f) * (i == 2 ? 0.75f : i == 3 ? 0.75f : 1)) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(tex2, drawPosition, null, Color.White with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2(1.5f, 0.7f) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); + } + return false; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.1f; + int hitsToMinMult = 4; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + if (Projectile.numHits == 0 && false) + { + // spawn slice projectiles + Vector2 spawnPos = target.Center + target.Center.DirectionFrom(Owner.Center).RotatedByRandom(0.5f) * (target.height / 2 + 40); + Vector2 vel = spawnPos.DirectionTo(target.Center); + int damage = (int)(Projectile.damage * 0.25f); + Projectile star = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), spawnPos, vel, ModContent.ProjectileType(), damage, 0, Projectile.owner, target.whoAmI, Main.rand.Next(0, 7 + 1), Main.rand.Next(0, 300 + 1)); + } + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 15; i++) + { + float variance = Main.rand.NextFloat(-0.5f, 0.5f); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 1.5f; + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 2.5f; + } + } + + } +} diff --git a/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs b/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs index 30c4c325b1..1d00a3f86e 100644 --- a/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs +++ b/Projectiles/Ranged/StarmageddonBinaryStarCenter.cs @@ -1,8 +1,6 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.NPCs.CalClone; -using CalamityMod.Projectiles.Magic; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -11,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { + [PierceResistException] public class StarmageddonBinaryStarCenter : ModProjectile, ILocalizedModType { private const float TimeBeforeHoming = 30f; diff --git a/Projectiles/Ranged/StarmageddonHeld.cs b/Projectiles/Ranged/StarmageddonHeld.cs index 87f3bc97ff..784cc23c14 100644 --- a/Projectiles/Ranged/StarmageddonHeld.cs +++ b/Projectiles/Ranged/StarmageddonHeld.cs @@ -1,8 +1,6 @@ using System; using System.IO; using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -82,8 +80,8 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item92, Projectile.Center); float shootSpeed = 12f; - int damage = player.GetWeaponDamage(player.ActiveItem()); - float knockBack = player.ActiveItem().knockBack; + int damage = player.GetWeaponDamage(player.HeldItem); + float knockBack = player.HeldItem.knockBack; Projectile.velocity = Main.screenPosition - playerPosition; Projectile.velocity.X += Main.mouseX; diff --git a/Projectiles/Ranged/StarmageddonStar.cs b/Projectiles/Ranged/StarmageddonStar.cs index 1f37ecea6d..df55fd0f34 100644 --- a/Projectiles/Ranged/StarmageddonStar.cs +++ b/Projectiles/Ranged/StarmageddonStar.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using CalamityMod.Dusts; -using CalamityMod.NPCs.TownNPCs; using CalamityMod.Particles; -using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -134,21 +130,31 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[starDust].velocity = Vector2.Normalize(position - speed * 3f - Main.dust[starDust].position) * 1.25f; } - int type = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), + int type = Utils.SelectRandom(Main.rand, + [ + ModContent.ProjectileType(), ModContent.ProjectileType(), ProjectileID.StarCannonStar, ProjectileID.Starfury - }); + ]); - int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, speed, type, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); + Projectile starCenter = Projectile; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && p.owner == Projectile.owner) + { + starCenter = p; + break; + } + } + Vector2 predictSpeed = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(position, Main.npc[(int)starCenter.ai[2]], 12f, 5); + int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, predictSpeed, type, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); if (star.WithinBounds(Main.maxProjectiles)) { - if (type == ModContent.ProjectileType() || type == ModContent.ProjectileType()) + if (type == ModContent.ProjectileType() || type == ModContent.ProjectileType()) Main.projectile[star].ai[0] = 1f; - Main.projectile[star].extraUpdates += 4; + Main.projectile[star].extraUpdates = 4; Main.projectile[star].penetrate = 1; Main.projectile[star].timeLeft = 300; Main.projectile[star].DamageType = DamageClass.Ranged; diff --git a/Projectiles/Ranged/StarmageddonStar2.cs b/Projectiles/Ranged/StarmageddonStar2.cs index 99b8d1a175..c452ad5609 100644 --- a/Projectiles/Ranged/StarmageddonStar2.cs +++ b/Projectiles/Ranged/StarmageddonStar2.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using CalamityMod.Dusts; -using CalamityMod.NPCs.TownNPCs; using CalamityMod.Particles; -using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -134,21 +130,31 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[starDust].velocity = Vector2.Normalize(position - speed * 3f - Main.dust[starDust].position) * 1.25f; } - int type = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), + int type = Utils.SelectRandom(Main.rand, + [ + ModContent.ProjectileType(), ModContent.ProjectileType(), ProjectileID.StarCannonStar, ProjectileID.Starfury - }); + ]); - int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, speed, type, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); + Projectile starCenter = Projectile; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && p.owner == Projectile.owner) + { + starCenter = p; + break; + } + } + Vector2 predictSpeed = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(position, Main.npc[(int)starCenter.ai[2]], 12f, 5); + int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, predictSpeed, type, Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); if (star.WithinBounds(Main.maxProjectiles)) { - if (type == ModContent.ProjectileType() || type == ModContent.ProjectileType()) + if (type == ModContent.ProjectileType() || type == ModContent.ProjectileType()) Main.projectile[star].ai[0] = 1f; - Main.projectile[star].extraUpdates += 4; + Main.projectile[star].extraUpdates = 4; Main.projectile[star].penetrate = 1; Main.projectile[star].timeLeft = 300; Main.projectile[star].DamageType = DamageClass.Ranged; diff --git a/Projectiles/Ranged/SulphuricAcidCannonExplosion.cs b/Projectiles/Ranged/SulphuricAcidCannonExplosion.cs index 7f30d0aa99..670bf26f99 100644 --- a/Projectiles/Ranged/SulphuricAcidCannonExplosion.cs +++ b/Projectiles/Ranged/SulphuricAcidCannonExplosion.cs @@ -1,9 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -40,7 +37,7 @@ namespace CalamityMod.Projectiles.Ranged int dustAmount = Main.rand.Next(14, 20 + 1); for (int i = 0; i <= 28; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.3f), 0, default, Main.rand.NextFloat(0.7f, 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.3f), 0, default, Main.rand.NextFloat(0.7f, 1.3f)); dust.noGravity = false; dust.color = Color.SeaGreen; } diff --git a/Projectiles/Ranged/SulphuricDrop.cs b/Projectiles/Ranged/SulphuricDrop.cs index f987c5725a..ae6b82830a 100644 --- a/Projectiles/Ranged/SulphuricDrop.cs +++ b/Projectiles/Ranged/SulphuricDrop.cs @@ -2,7 +2,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -28,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.ignoreWater = false; Projectile.penetrate = 3; Projectile.timeLeft = 840; - Projectile.extraUpdates = 1; + Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 15; Projectile.DamageType = DamageClass.Ranged; @@ -37,7 +36,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); dust.noGravity = false; dust.scale = Main.rand.NextFloat(0.4f, 0.65f); dust.velocity = -Projectile.velocity * 0.4f; diff --git a/Projectiles/Ranged/SuperradiantBolt.cs b/Projectiles/Ranged/SuperradiantBolt.cs index 2ba1733524..4caa797042 100644 --- a/Projectiles/Ranged/SuperradiantBolt.cs +++ b/Projectiles/Ranged/SuperradiantBolt.cs @@ -65,8 +65,8 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 45); - internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 20f; - internal Color ColorFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (1f - completionRatio) * Projectile.scale * 20f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float hue = 0.4f + 0.2f * completionRatio * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); Color trailColor = Main.hslToRgb(hue, 1f, 0.8f); @@ -75,8 +75,8 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 20); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 20); Texture2D glow = TextureAssets.Projectile[Type].Value; Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None); return false; diff --git a/Projectiles/Ranged/SuperradiantSaw.cs b/Projectiles/Ranged/SuperradiantSaw.cs index b6e808d15f..6099118d71 100644 --- a/Projectiles/Ranged/SuperradiantSaw.cs +++ b/Projectiles/Ranged/SuperradiantSaw.cs @@ -56,7 +56,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; // Saws only pierce a certain number of times before returning, and don't deal direct damage while returning Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -243,7 +242,10 @@ namespace CalamityMod.Projectiles.Ranged PierceBeforeReturn--; Projectile.numHits++; if (PierceBeforeReturn <= 0) + { + Projectile.localNPCHitCooldown = 20; Returning = true; + } } return false; @@ -290,15 +292,18 @@ namespace CalamityMod.Projectiles.Ranged { PierceBeforeReturn--; if (PierceBeforeReturn <= 0) + { + Projectile.localNPCHitCooldown = 20; Returning = true; + } } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { // The saw deals less damage while returning, to prevent its damage being too crazy - if (PierceBeforeReturn <= 0) - modifiers.SourceDamage *= 0.33f; + // The saw also deals less damage while homing + modifiers.SourceDamage *= Returning ? 0.2f : Empowered ? 0.75f : 1f; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/SuperradiantSawLingering.cs b/Projectiles/Ranged/SuperradiantSawLingering.cs index 2397d1ca85..3b2f14b333 100644 --- a/Projectiles/Ranged/SuperradiantSawLingering.cs +++ b/Projectiles/Ranged/SuperradiantSawLingering.cs @@ -40,7 +40,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.tileCollide = false; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs index 24ba2a20b3..4d2b48ff8e 100644 --- a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs +++ b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs @@ -11,7 +11,6 @@ using System; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -59,7 +58,7 @@ namespace CalamityMod.Projectiles.Ranged public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type) + if (HeldItem.type != Owner.HeldItem.type || Owner.dead || !Owner.active) { Projectile.Kill(); Projectile.netUpdate = true; @@ -74,44 +73,45 @@ namespace CalamityMod.Projectiles.Ranged if (SoundEngine.TryGetActiveSound(ChargeIdle, out var Idle) && Idle.IsPlaying) Idle.Position = GunTipPosition; - // Handle the right-click dash (holds priority over left-click) + // Handle the right-click dash (only works when not used from left-click) if (Owner.Calamity().mouseRight && !Owner.HasCooldown(SuperradiantSawBoost.ID)) { - Owner.AddCooldown(SuperradiantSawBoost.ID, SuperradiantSlaughterer.DashCooldown); - Owner.Calamity().sBlasterDashActivated = true; - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/MeatySlash"), GunTipPosition); - - // Throws a lingering saw at the cursor that deals 3x damage (since the holdout already deals 2x) - float clampedMouseDist = MathHelper.Clamp(Vector2.Distance(GunTipPosition, Owner.Calamity().mouseWorld), 0f, 960f); - float adjustedMouseDist = clampedMouseDist / 21f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * adjustedMouseDist, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner); - - // Special case: right-clicking while not holding left-click - // This is to keep it friendly to use both fires at the same time, but end the animation early if not if (Projectile.ai[1] >= 2f) { + Owner.AddCooldown(SuperradiantSawBoost.ID, SuperradiantSlaughterer.DashCooldown); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/MeatySlash"), GunTipPosition); + + // Throws a lingering saw at the cursor that deals 3x damage (since the holdout already deals 2x) + if (Main.myPlayer == Projectile.owner) + { + float clampedMouseDist = MathHelper.Clamp(Vector2.Distance(GunTipPosition, Owner.Calamity().mouseWorld), 0f, 960f); + float adjustedMouseDist = clampedMouseDist / 21f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * adjustedMouseDist, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner); + } + + // End animation early NoSawOnHoldout = true; OffsetLengthFromArm -= 16f; - Projectile.timeLeft = Owner.ActiveItem().useAnimation; + Projectile.timeLeft = Owner.HeldItem.useAnimation; KeepRefreshingLifetime = false; Idle?.Stop(); - } - // If moving, make particle effects when the dash activates - if (Owner.velocity != Vector2.Zero) - { - int particleAmt = 7; - for (int c = 0; c < particleAmt; c++) + // If moving, make particle effects when the dash activates + if (Owner.velocity != Vector2.Zero) { - Color sparkColor = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), c / (particleAmt - 1)); - Particle spark = new CritSpark(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(13f)) * Main.rand.NextFloat(-2.1f, -4.5f), Color.White, sparkColor, 2f, 45, 2.25f, 2f); - GeneralParticleHandler.SpawnParticle(spark); - } - for (int e = 0; e < particleAmt * 2; e++) - { - Color sparkColor2 = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), e / (particleAmt - 1)); - Particle spark2 = new NanoParticle(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(-MathHelper.PiOver4)) * Main.rand.NextFloat(2.5f, 4.5f), sparkColor2, 1f, 45, Main.rand.NextBool(3)); - GeneralParticleHandler.SpawnParticle(spark2); + int particleAmt = 7; + for (int c = 0; c < particleAmt; c++) + { + Color sparkColor = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), c / (particleAmt - 1)); + Particle spark = new CritSpark(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(13f)) * Main.rand.NextFloat(-2.1f, -4.5f), Color.White, sparkColor, 2f, 45, 2.25f, 2f); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int e = 0; e < particleAmt * 2; e++) + { + Color sparkColor2 = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), e / (particleAmt - 1)); + Particle spark2 = new NanoParticle(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(-MathHelper.PiOver4)) * Main.rand.NextFloat(2.5f, 4.5f), sparkColor2, 1f, 45, Main.rand.NextBool(3)); + GeneralParticleHandler.SpawnParticle(spark2); + } } } } @@ -121,7 +121,7 @@ namespace CalamityMod.Projectiles.Ranged Idle?.Stop(); Projectile.ai[1] = 1f; - Projectile.timeLeft = Owner.ActiveItem().useAnimation; + Projectile.timeLeft = Owner.HeldItem.useAnimation; SoundStyle ShootSound = new("CalamityMod/Sounds/Item/SawShot", 2) { PitchVariance = 0.1f, Volume = 0.4f + SawPower * 0.5f }; SoundEngine.PlaySound(ShootSound, GunTipPosition); @@ -130,7 +130,8 @@ namespace CalamityMod.Projectiles.Ranged int sawLevel = (SawPower >= 1f).ToInt() + (SawPower >= 0.25f).ToInt(); // ai[0] determines which slashes are drawn. ai[1] is the saw's timer variable. ai[2] stores the saw's pierce. - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * sawDamageMult), Projectile.knockBack, Projectile.owner, sawLevel, 0f, sawPierce); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * sawDamageMult), Projectile.knockBack, Projectile.owner, sawLevel, 0f, sawPierce); NoSawOnHoldout = true; OffsetLengthFromArm -= 4f + 12f * SawPower; diff --git a/Projectiles/Ranged/SurgeDriverHoldout.cs b/Projectiles/Ranged/SurgeDriverHoldout.cs index dbc776ec05..05cdc389ea 100644 --- a/Projectiles/Ranged/SurgeDriverHoldout.cs +++ b/Projectiles/Ranged/SurgeDriverHoldout.cs @@ -39,12 +39,12 @@ namespace CalamityMod.Projectiles.Ranged Projectile.Kill(); // Can't shoot on frame 1 as it can't use ammo yet - else if (ShootCountdown < 0f && Owner.HasAmmo(Owner.ActiveItem())) + else if (ShootCountdown < 0f && Owner.HasAmmo(Owner.HeldItem)) { if (Main.myPlayer == Projectile.owner) { ShootProjectiles(armPosition); - ShootCountdown = Owner.ActiveItem().useAnimation - 1; + ShootCountdown = Owner.HeldItem.useAnimation - 1; Projectile.netUpdate = true; } @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Ranged if (Main.myPlayer != Projectile.owner) return; - Item heldItem = Owner.ActiveItem(); + Item heldItem = Owner.HeldItem; Owner.PickAmmo(heldItem, out int projectileType, out float shootSpeed, out int damage, out float knockback, out _); damage *= 4; shootSpeed = heldItem.shootSpeed * Projectile.scale * 0.64f; diff --git a/Projectiles/Ranged/TauCannonBeam.cs b/Projectiles/Ranged/TauCannonBeam.cs index d61422d5c2..72ea9e7190 100644 --- a/Projectiles/Ranged/TauCannonBeam.cs +++ b/Projectiles/Ranged/TauCannonBeam.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.Projectiles.Ranged.TauCannonHoldout; using static Terraria.ModLoader.ModContent; @@ -92,7 +93,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 effectsPosition = Vector2.Lerp(Projectile.Center, Projectile.Center + Projectile.velocity * LaserLength, Main.rand.NextFloat()); Vector2 randomLineEffectPosition = effectsPosition + Main.rand.NextVector2Circular(40f * (IsStage3Laser ? 1.2f : 0.8f), 40f * (IsStage3Laser ? 1.2f : 0.8f)); - Dust laserDust = Dust.NewDustPerfect(randomLineEffectPosition, 278, Projectile.velocity * Main.rand.NextFloat(5f, 40f), Scale: Main.rand.NextFloat(0.8f, 1.1f)); + Dust laserDust = Dust.NewDustPerfect(randomLineEffectPosition, DustID.FireworksRGB, Projectile.velocity * Main.rand.NextFloat(5f, 40f), Scale: Main.rand.NextFloat(0.8f, 1.1f)); laserDust.noGravity = true; laserDust.color = Main.rand.NextBool(3) ? color2 : color1; diff --git a/Projectiles/Ranged/TauCannonBolt.cs b/Projectiles/Ranged/TauCannonBolt.cs index 491ebfcdd0..cb427b5c19 100644 --- a/Projectiles/Ranged/TauCannonBolt.cs +++ b/Projectiles/Ranged/TauCannonBolt.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Ranged return; if (Main.rand.NextBool(10)) { - Dust trailDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 278, Scale: Main.rand.NextFloat(0.5f, 0.8f)); + Dust trailDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.FireworksRGB, Scale: Main.rand.NextFloat(0.5f, 0.8f)); trailDust.noGravity = true; trailDust.color = Main.rand.NextBool(3) ? coralColor : turquoiseColor; } @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged int dustAmount = Main.rand.Next(5, 10); for (int i = 0; i < dustAmount; i++) { - Dust boomDust = Dust.NewDustPerfect(Projectile.Center, 278, (MathHelper.TwoPi / dustAmount * i).ToRotationVector2() * Main.rand.NextFloat(5f, 8f), Scale: Main.rand.NextFloat(0.6f, 1f)); + Dust boomDust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, (MathHelper.TwoPi / dustAmount * i).ToRotationVector2() * Main.rand.NextFloat(5f, 8f), Scale: Main.rand.NextFloat(0.6f, 1f)); boomDust.noGravity = true; boomDust.color = Main.rand.NextBool(3) ? coralColor : turquoiseColor; } @@ -69,14 +69,14 @@ namespace CalamityMod.Projectiles.Ranged { target.AddBuff(ModContent.BuffType(), 60); } - private float WidthFunction(float completionRatio) => Projectile.scale * 32f * CalamityUtils.Convert01To010(completionRatio); + private float WidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 32f * CalamityUtils.Convert01To010(completionRatio); - private Color ColorFunction(float completionRatio) => Color.Lerp(turquoiseColor, Color.Transparent, completionRatio) * Utils.GetLerpValue(0f, 30f, Projectile.timeLeft, true); + private Color ColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(turquoiseColor, Color.Transparent, completionRatio) * Utils.GetLerpValue(0f, 30f, Projectile.timeLeft, true); public override bool PreDraw(ref Color lightColor) { GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ZapTrail")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); return false; } } diff --git a/Projectiles/Ranged/TauCannonHoldout.cs b/Projectiles/Ranged/TauCannonHoldout.cs index 216a74c57f..754264c5ea 100644 --- a/Projectiles/Ranged/TauCannonHoldout.cs +++ b/Projectiles/Ranged/TauCannonHoldout.cs @@ -9,6 +9,7 @@ using ReLogic.Content; using ReLogic.Utilities; using Terraria; using Terraria.Audio; +using Terraria.ID; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Ranged @@ -92,7 +93,7 @@ namespace CalamityMod.Projectiles.Ranged public override void HoldoutAI() { - CalamityGlobalItem modItem = Owner.ActiveItem().Calamity(); + CalamityGlobalItem modItem = Owner.HeldItem.Calamity(); if (Owner.CantUseHoldout() && KeepRefreshingLifetime) { @@ -128,7 +129,6 @@ namespace CalamityMod.Projectiles.Ranged if (!HasShotBeam) { - modItem.Charge -= 0.2f; HasShotBeam = true; } @@ -148,7 +148,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.owner, ai1: Projectile.whoAmI); OffsetLengthFromArm -= 25f; - modItem.Charge -= 0.8f; HasShotBeam = true; SoundEngine.PlaySound(SmallBeamSound, GunTipPosition); } @@ -186,7 +185,6 @@ namespace CalamityMod.Projectiles.Ranged } } - modItem.Charge -= 2.5f; HasShotBeam = true; } @@ -255,7 +253,7 @@ namespace CalamityMod.Projectiles.Ranged float randomRadius = Utils.Remap(Timer, 0f, TimePerCharge * 3f, 5f, 15f); Dust orbDust = Dust.NewDustPerfect( GunTipPosition + Main.rand.NextVector2Circular(randomRadius, randomRadius), - 278, + DustID.FireworksRGB, -Vector2.UnitY.RotatedByRandom(100) * Main.rand.NextFloat(2f, 5f) * Utils.Remap(Timer, 0f, TimePerCharge * 3f, 1f, 5f), Scale: Main.rand.NextFloat(0.3f, 0.9f)); orbDust.noGravity = true; @@ -299,13 +297,14 @@ namespace CalamityMod.Projectiles.Ranged AIState.Level3 => 36, AIState.Level2 => 24, AIState.Level1 => 12, + _ => 0 }; for (int i = 0; i < dustAmount; i++) { float angle = MathHelper.TwoPi / dustAmount * i; Vector2 velocity = angle.ToRotationVector2() * 8f; - Dust chargeDust = Dust.NewDustPerfect(GunTipPosition, 267, velocity, Scale: Utils.Remap(dustAmount, 10f, 30f, 1.5f, 2.2f)); + Dust chargeDust = Dust.NewDustPerfect(GunTipPosition, DustID.RainbowMk2, velocity, Scale: Utils.Remap(dustAmount, 10f, 30f, 1.5f, 2.2f)); chargeDust.noGravity = true; chargeDust.noLight = true; chargeDust.noLightEmittence = true; @@ -328,6 +327,7 @@ namespace CalamityMod.Projectiles.Ranged AIState.Level3 => ChargeLV2Sound, AIState.Level2 => ChargeLV1Sound, AIState.Level1 => ChargeLV1Sound, + _ => ChargeLV1Sound }; SoundEngine.PlaySound(chargeSound, GunTipPosition); diff --git a/Projectiles/Ranged/TauCannonPortal.cs b/Projectiles/Ranged/TauCannonPortal.cs index a3b5a0852b..125621a082 100644 --- a/Projectiles/Ranged/TauCannonPortal.cs +++ b/Projectiles/Ranged/TauCannonPortal.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Ranged/TelluricGlareArrow.cs b/Projectiles/Ranged/TelluricGlareArrow.cs index 5e6bb758a4..098bc31f8b 100644 --- a/Projectiles/Ranged/TelluricGlareArrow.cs +++ b/Projectiles/Ranged/TelluricGlareArrow.cs @@ -43,7 +43,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; // Can hit many enemies. Will explode extremely soon after hitting the first, though. Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool? CanDamage() => (Projectile.timeLeft < Lifetime - 4) ? null : false; @@ -137,7 +136,7 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.damage < 1) Projectile.damage = 1; } - private float PrimitiveWidthFunction(float completionRatio) + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float arrowheadCutoff = 0.36f; float width = 29f * Projectile.scale; @@ -148,7 +147,7 @@ namespace CalamityMod.Projectiles.Ranged return width; } - private Color PrimitiveColorFunction(float completionRatio) + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { float endFadeRatio = 0.41f; @@ -167,11 +166,11 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); Vector2 overallOffset = Projectile.Size * 0.5f; overallOffset += Projectile.velocity * 1.4f; int numPoints = 92; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => overallOffset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), numPoints); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => overallOffset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), numPoints); return false; } } diff --git a/Projectiles/Ranged/TheHiveHoldout.cs b/Projectiles/Ranged/TheHiveHoldout.cs index 6be2de4d51..042172d36c 100644 --- a/Projectiles/Ranged/TheHiveHoldout.cs +++ b/Projectiles/Ranged/TheHiveHoldout.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Ranged } for (int e = 0; e < 2; e++) { - Dust dust2 = Dust.NewDustPerfect(GunTipPosition + Projectile.velocity * 1.5f, 90, shootDirection * Main.rand.NextFloat(0.01f, 0.8f)); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition + Projectile.velocity * 1.5f, DustID.GemRuby, shootDirection * Main.rand.NextFloat(0.01f, 0.8f)); dust2.scale = Main.rand.NextFloat(0.45f, 0.75f); dust2.noGravity = true; } @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(fullCharge with { Volume = 0.9f }, Projectile.Center); for (int k = 0; k < 15; k++) { - Dust dust2 = Dust.NewDustPerfect(GunTipPosition, 90, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + Dust dust2 = Dust.NewDustPerfect(GunTipPosition, DustID.GemRuby, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); dust2.scale = Main.rand.NextFloat(0.85f, 1.15f); dust2.noGravity = true; } @@ -140,15 +140,9 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGBarrageLaunch"); SoundEngine.PlaySound(fire with { Volume = 0.5f, Pitch = 0.1f }, Projectile.Center); - Projectile.NewProjectile( - Projectile.GetSource_FromThis(), - GunTipPosition, - shootDirection * projSpeed * 0.3f, - ProjectileType(), - damage * 10, - knockback, - Projectile.owner, - rocketType); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootDirection * projSpeed * 0.3f, ProjectileType(), damage * 10, knockback, Projectile.owner, rocketType); + PostFireCooldown = 75; } else @@ -156,21 +150,25 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGBarrageLaunch"); SoundEngine.PlaySound(fire with { Volume = 0.4f, Pitch = 0.7f }, Projectile.Center); - int numProj = 4; - float rotation = MathHelper.ToRadians(MathHelper.Clamp(35 - VelocityMultiplier * 26, 2, 25)); - for (int i = 0; i < numProj; i++) + if (Main.myPlayer == Projectile.owner) { - Vector2 perturbedSpeed = (shootDirection).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile( - Projectile.GetSource_FromThis(), - GunTipPosition, - perturbedSpeed * projSpeed * VelocityMultiplier, - ProjectileType(), - damage, - knockback, - Projectile.owner, - rocketType); + int numProj = 4; + float rotation = MathHelper.ToRadians(MathHelper.Clamp(35 - VelocityMultiplier * 26, 2, 25)); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = (shootDirection).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile( + Projectile.GetSource_FromThis(), + GunTipPosition, + perturbedSpeed * projSpeed * VelocityMultiplier, + ProjectileType(), + damage, + knockback, + Projectile.owner, + rocketType); + } } + PostFireCooldown = 30; } @@ -219,7 +217,7 @@ namespace CalamityMod.Projectiles.Ranged Particle smoke = new HeavySmokeParticle(GunTipPosition, 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); GeneralParticleHandler.SpawnParticle(smoke); - Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, DustID.SteampunkSteam, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); dust.noGravity = false; dust.color = StaticEffectsColor; } diff --git a/Projectiles/Ranged/TheMaelstromExplosion.cs b/Projectiles/Ranged/TheMaelstromExplosion.cs index e8a8318177..70bac8a4fa 100644 --- a/Projectiles/Ranged/TheMaelstromExplosion.cs +++ b/Projectiles/Ranged/TheMaelstromExplosion.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(spark); Vector2 dustSpawnOffset = Main.rand.NextVector2Circular(Projectile.width, Projectile.height) * Projectile.scale * 0.4f; - Dust electricity = Dust.NewDustPerfect(Projectile.Center + dustSpawnOffset, 267); + Dust electricity = Dust.NewDustPerfect(Projectile.Center + dustSpawnOffset, DustID.RainbowMk2); electricity.color = Color.Cyan; electricity.color.A = 84; electricity.scale *= Main.rand.NextFloat(0.7f, 1.2f); diff --git a/Projectiles/Ranged/TheMaelstromShark.cs b/Projectiles/Ranged/TheMaelstromShark.cs index a9a4037ffe..8d55ed4f71 100644 --- a/Projectiles/Ranged/TheMaelstromShark.cs +++ b/Projectiles/Ranged/TheMaelstromShark.cs @@ -31,7 +31,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 1; Projectile.Opacity = 0f; Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -54,13 +53,13 @@ namespace CalamityMod.Projectiles.Ranged return true; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = Utils.GetLerpValue(0.94f, 0.54f, completionRatio, true) * Projectile.Opacity; return Color.Lerp(Color.Cyan, Color.White, 0.4f) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.GetLerpValue(0f, 0.3f, completionRatio, true), 2D); return MathHelper.Lerp(0f, 12f * Projectile.Opacity, expansionCompletion); @@ -78,7 +77,7 @@ namespace CalamityMod.Projectiles.Ranged } for (int i = 0; i < 12; i++) { - Dust blood = Dust.NewDustPerfect(Projectile.Center, 5); + Dust blood = Dust.NewDustPerfect(Projectile.Center, DustID.Blood); blood.velocity = Main.rand.NextVector2Circular(6f, 6f); blood.scale *= Main.rand.NextFloat(0.7f, 1.3f); blood.noGravity = true; @@ -99,7 +98,7 @@ namespace CalamityMod.Projectiles.Ranged SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 60); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 60); Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0); return false; } diff --git a/Projectiles/Ranged/ThePackMinissile.cs b/Projectiles/Ranged/ThePackMinissile.cs index 7044b1bbb1..5f502e3538 100644 --- a/Projectiles/Ranged/ThePackMinissile.cs +++ b/Projectiles/Ranged/ThePackMinissile.cs @@ -1,6 +1,4 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -31,15 +29,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.rotation = Projectile.velocity.ToRotation(); CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 300f, 12f, 15f); Projectile.frameCounter++; - if (Projectile.frameCounter > 3) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 3) - { - Projectile.frame = 0; - } + Projectile.frame = Projectile.frameCounter / 4 % Main.projFrames[Type]; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/ThePackMinissile.png b/Projectiles/Ranged/ThePackMinissile.png index 343769d211..1323197fa3 100644 Binary files a/Projectiles/Ranged/ThePackMinissile.png and b/Projectiles/Ranged/ThePackMinissile.png differ diff --git a/Projectiles/Ranged/ThePackMissile.cs b/Projectiles/Ranged/ThePackMissile.cs index 6d16b07aaf..56f4cb345b 100644 --- a/Projectiles/Ranged/ThePackMissile.cs +++ b/Projectiles/Ranged/ThePackMissile.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -11,7 +10,7 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override void SetStaticDefaults() { - Main.projFrames[Type] = 4; + Main.projFrames[Type] = 9; ProjectileID.Sets.CultistIsResistantTo[Type] = true; ProjectileID.Sets.TrailCacheLength[Type] = 6; ProjectileID.Sets.TrailingMode[Type] = 0; @@ -71,15 +70,7 @@ namespace CalamityMod.Projectiles.Ranged } Projectile.frameCounter++; - if (Projectile.frameCounter > 3) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 3) - { - Projectile.frame = 0; - } + Projectile.frame = Projectile.frameCounter / 4 % Main.projFrames[Type]; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/ThePackMissile.png b/Projectiles/Ranged/ThePackMissile.png index 76f97a6237..61fbc7519e 100644 Binary files a/Projectiles/Ranged/ThePackMissile.png and b/Projectiles/Ranged/ThePackMissile.png differ diff --git a/Projectiles/Ranged/TheStormLightningShot.cs b/Projectiles/Ranged/TheStormLightningShot.cs index 8dc6f6328c..7c5fa7a94f 100644 --- a/Projectiles/Ranged/TheStormLightningShot.cs +++ b/Projectiles/Ranged/TheStormLightningShot.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Ranged } if (time % 15 == 0) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, (effectVel * 10) * Main.rand.NextFloat(-0.4f, -0.7f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, (effectVel * 10) * Main.rand.NextFloat(-0.4f, -0.7f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); dust.noGravity = true; dust.color = usedColor; effectVel = Projectile.velocity.RotatedBy(0.2f * zagDirection * (hasZaged ? 1 : 0.5f)) * 0.08f; @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i <= 2; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, (Projectile.velocity * 4).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.3f, 1.8f), 0, default, Main.rand.NextFloat(0.6f, 0.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, (Projectile.velocity * 4).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.3f, 1.8f), 0, default, Main.rand.NextFloat(0.6f, 0.8f)); dust.noGravity = true; dust.color = Main.rand.NextBool(5) ? Color.Cyan : Color.Orchid; } diff --git a/Projectiles/Ranged/TitaniumRailgunScope.cs b/Projectiles/Ranged/TitaniumRailgunScope.cs index c9daab4596..60c5ea557c 100644 --- a/Projectiles/Ranged/TitaniumRailgunScope.cs +++ b/Projectiles/Ranged/TitaniumRailgunScope.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Ranged // 15NOV2024: Ozzatron: clamped mouse position unnecessary. All uses are direction only. public Vector2 MousePosition => Owner.Calamity().mouseWorld - Owner.MountedCenter; - public const float WeaponLength = 52f; + public const float WeaponLength = 62f; public const float MaxSightAngle = MathHelper.Pi * (2f / 3f); public Color ScopeColor => Color.White; @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Ranged // Apply some recoil to the player Owner.velocity += direction * (ChargePercent * -5f); - Owner.Calamity().GeneralScreenShakePower = 4f * ChargePercent; + Owner.SetScreenshake(4f * ChargePercent); // Spawn the laser int shotDamage = (int)(Projectile.damage * ChargePercent); diff --git a/Projectiles/Ranged/TitaniumRailgunShot.cs b/Projectiles/Ranged/TitaniumRailgunShot.cs index d36d0017ea..1246361c5c 100644 --- a/Projectiles/Ranged/TitaniumRailgunShot.cs +++ b/Projectiles/Ranged/TitaniumRailgunShot.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -49,7 +50,7 @@ namespace CalamityMod.Projectiles.Ranged { Vector2 beamVector = Projectile.velocity; - float beamLength = DetermineLaserLength_CollideWithTiles(12); + float beamLength = DetermineLaserLength_CollideWithTiles(); //Rapid dust int dustCount = Main.rand.Next(10, 30); @@ -58,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged float dustProgressAlongBeam = beamLength * Main.rand.NextFloat(0f, 0.8f); Vector2 dustPosition = Projectile.Center + dustProgressAlongBeam * beamVector + beamVector.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-6f, 6f) * Projectile.scale; - Dust dust = Dust.NewDustPerfect(dustPosition, 187, beamVector * Main.rand.NextFloat(5f, 26f), 0, Color.White, 2.2f); + Dust dust = Dust.NewDustPerfect(dustPosition, DustID.BlueFlare, beamVector * Main.rand.NextFloat(5f, 26f), 0, Color.White, 2.2f); dust.noGravity = true; } @@ -77,7 +78,7 @@ namespace CalamityMod.Projectiles.Ranged public override void DetermineScale() => Projectile.scale = Projectile.timeLeft / Lifetime * MaxScale; - public override float DetermineLaserLength() => DetermineLaserLength_CollideWithTiles(5); + public override float DetermineLaserLength() => DetermineLaserLength_CollideWithTiles(); public override bool ShouldUpdatePosition() => false; diff --git a/Projectiles/Ranged/TorrentialArrow.cs b/Projectiles/Ranged/TorrentialArrow.cs index 885533921d..648535d215 100644 --- a/Projectiles/Ranged/TorrentialArrow.cs +++ b/Projectiles/Ranged/TorrentialArrow.cs @@ -21,7 +21,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.arrow = true; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/ToxicArrow.cs b/Projectiles/Ranged/ToxicArrow.cs index e010f3eb95..42160ce9af 100644 --- a/Projectiles/Ranged/ToxicArrow.cs +++ b/Projectiles/Ranged/ToxicArrow.cs @@ -19,7 +19,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.arrow = true; Projectile.penetrate = 1; Projectile.timeLeft = 240; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/TyphoonArrow.cs b/Projectiles/Ranged/TyphoonArrow.cs index 0c15bffcfa..03721e4fec 100644 --- a/Projectiles/Ranged/TyphoonArrow.cs +++ b/Projectiles/Ranged/TyphoonArrow.cs @@ -17,7 +17,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.timeLeft = 600; AIType = ProjectileID.WoodenArrowFriendly; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/TyphoonBubble.cs b/Projectiles/Ranged/TyphoonBubble.cs index 08be6cba30..719bedb2bc 100644 --- a/Projectiles/Ranged/TyphoonBubble.cs +++ b/Projectiles/Ranged/TyphoonBubble.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.alpha = 255; Projectile.penetrate = -1; Projectile.timeLeft = 1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Ranged/UltimaBolt.cs b/Projectiles/Ranged/UltimaBolt.cs index 2c321b7ad7..daf3e7c25f 100644 --- a/Projectiles/Ranged/UltimaBolt.cs +++ b/Projectiles/Ranged/UltimaBolt.cs @@ -31,7 +31,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.arrow = true; Projectile.penetrate = 1; Projectile.timeLeft = 300; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -48,7 +47,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < dustCount; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 267); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); dust.color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); dust.scale = Main.rand.NextFloat(1f, 1.25f); dust.velocity = Main.rand.NextVector2Circular(7f, 7f); diff --git a/Projectiles/Ranged/UltimaBowProjectile.cs b/Projectiles/Ranged/UltimaBowProjectile.cs index 6dfb5da650..3e23c36519 100644 --- a/Projectiles/Ranged/UltimaBowProjectile.cs +++ b/Projectiles/Ranged/UltimaBowProjectile.cs @@ -43,22 +43,22 @@ namespace CalamityMod.Projectiles.Ranged public void AttemptToFireProjectiles(Player player) { - if (player.CantUseHoldout() || !player.HasAmmo(player.ActiveItem())) + if (player.CantUseHoldout() || !player.HasAmmo(player.HeldItem)) { Projectile.Kill(); return; } - if (Projectile.owner == Main.myPlayer && Time % player.ActiveItem().useTime == 0) + if (Projectile.owner == Main.myPlayer && Time % player.HeldItem.useTime == 0) { int type = ProjectileID.WoodenArrowFriendly; // This doesn't really matter. It's overwritten anyway. But it is passed into the PickAmmo method. - float shotSpeed = player.ActiveItem().shootSpeed; - int damage = player.GetWeaponDamage(player.ActiveItem()); - float knockBack = player.ActiveItem().knockBack; + float shotSpeed = player.HeldItem.shootSpeed; + int damage = player.GetWeaponDamage(player.HeldItem); + float knockBack = player.HeldItem.knockBack; - player.PickAmmo(player.ActiveItem(), out type, out shotSpeed, out damage, out knockBack, out _); // Pick ammo and consume it (this incorporates the bow's chance to not consume ammo). + player.PickAmmo(player.HeldItem, out type, out shotSpeed, out damage, out knockBack, out _); // Pick ammo and consume it (this incorporates the bow's chance to not consume ammo). - if (player.ActiveItem().UseSound.HasValue) - SoundEngine.PlaySound(player.ActiveItem().UseSound.GetValueOrDefault(), Projectile.Center); + if (player.HeldItem.UseSound.HasValue) + SoundEngine.PlaySound(player.HeldItem.UseSound.GetValueOrDefault(), Projectile.Center); type = ModContent.ProjectileType(); float shootLaserChance = Utils.GetLerpValue(Ultima.FullChargeTime * 0.35f, Ultima.FullChargeTime, Time, true); @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Ranged sparkVelocity = sparkVelocity.RotatedBy(offsetAngle); Projectile.NewProjectile(Projectile.GetSource_FromThis(), shotPosition, sparkVelocity, ModContent.ProjectileType(), damage / 3, knockBack, Projectile.owner); } - knockBack = player.GetWeaponKnockback(player.ActiveItem(), knockBack); + knockBack = player.GetWeaponKnockback(player.HeldItem, knockBack); Projectile.NewProjectile(Projectile.GetSource_FromThis(), shotPosition, shotVelocity, type, damage, knockBack, Projectile.owner); Projectile.netUpdate = true; diff --git a/Projectiles/Ranged/UniversalGenesisStar.cs b/Projectiles/Ranged/UniversalGenesisStar.cs index 9eabd1a422..1d12051662 100644 --- a/Projectiles/Ranged/UniversalGenesisStar.cs +++ b/Projectiles/Ranged/UniversalGenesisStar.cs @@ -1,7 +1,5 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -30,7 +28,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 180; Projectile.extraUpdates = 1; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = -1; } public override void AI() diff --git a/Projectiles/Ranged/UniversalGenesisStarcaller.cs b/Projectiles/Ranged/UniversalGenesisStarcaller.cs index fc22e9fde8..a2f2483888 100644 --- a/Projectiles/Ranged/UniversalGenesisStarcaller.cs +++ b/Projectiles/Ranged/UniversalGenesisStarcaller.cs @@ -26,7 +26,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 600; Projectile.extraUpdates = 1; AIType = ProjectileID.Bullet; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() @@ -77,15 +76,11 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - SpawnStars(); - } - - private void SpawnStars() - { - // The patron said 10 blocks, but 10 blocks is like nothing... I'm sure they won't mind. + // The patron said 10 blocks, but 10 blocks is like nothing... I'm sure they won't mind int maxDistance = 480; // 30 blocks bool bossFound = false; int life = 0; + int index = -1; Vector2 targetVec = Projectile.Center; foreach (NPC npc in Main.ActiveNPCs) { @@ -94,7 +89,7 @@ namespace CalamityMod.Projectiles.Ranged if (npc.CanBeChasedBy(Projectile, false)) { float extraDist = (npc.width / 2) + (npc.height / 2); - //Calculate distance between target and the projectile to know if it's too far or not + // Calculate distance between target and the projectile to know if it's too far or not float targetDist = Vector2.Distance(npc.Center, Projectile.Center); if (targetDist < (maxDistance + extraDist) && (npc.IsABoss() || npc.life > life)) { @@ -102,16 +97,15 @@ namespace CalamityMod.Projectiles.Ranged bossFound = true; life = npc.life; targetVec = npc.Center; + index = npc.whoAmI; } } } - var source = Projectile.GetSource_FromThis(); - for (int n = 0; n < 2; n++) - { - Projectile star = CalamityUtils.ProjectileRain(source, targetVec, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); - star.ai[0] = n; - } + Vector2 spawnPos = targetVec - new Vector2(Main.rand.NextFloat(-300f, 300f), Main.rand.NextFloat(500f, 800f)); + Vector2 velocity = index == -1 ? Utils.DirectionTo(spawnPos, Projectile.Center) * 29f : CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(spawnPos, Main.npc[index], 29f, 2); + velocity.X += Main.rand.NextFloat(-1f, 1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPos, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.65f), Projectile.knockBack, Projectile.owner); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/VanquisherArrowProj.cs b/Projectiles/Ranged/VanquisherArrowProj.cs index b0c39fb9b8..ad4207dc0a 100644 --- a/Projectiles/Ranged/VanquisherArrowProj.cs +++ b/Projectiles/Ranged/VanquisherArrowProj.cs @@ -1,15 +1,15 @@ -using System; +using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Ammo; +using CalamityMod.Dusts; using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; -using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class VanquisherArrowProj : ModProjectile, ILocalizedModType @@ -22,6 +22,8 @@ namespace CalamityMod.Projectiles.Ranged public float HomingTime = 0; public Color MainColor; public NPC targeted; + public int rotDir = 0; + public float rotSpeed = 0; public override void SetStaticDefaults() { ProjectileID.Sets.CultistIsResistantTo[Type] = true; @@ -30,27 +32,43 @@ namespace CalamityMod.Projectiles.Ranged } public override void SetDefaults() { - Projectile.width = 22; - Projectile.height = 22; + Projectile.width = 35; + Projectile.height = 35; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.tileCollide = false; Projectile.arrow = true; Projectile.penetrate = 2; - Projectile.timeLeft = 300; + Projectile.timeLeft = 600; Projectile.extraUpdates = 7; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 15 * Projectile.extraUpdates; } public override void AI() { + //This is so Grape Beer works properly with them + if (targeted != null && Projectile.localNPCImmunity[targeted.whoAmI] == -1) + Projectile.localNPCImmunity[targeted.whoAmI] = 15 * Projectile.extraUpdates; + float rate = Main.GlobalTimeWrappedHourly * 5; + List eColors = new List() + { + Color.Cyan, + Color.Magenta + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + MainColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + if (Time == 0) { - Projectile.velocity *= 0.4f; + rotDir = (Main.rand.NextBool() ? -1 : 1); + rotSpeed = Main.rand.NextFloat(0.8f, 1.1f); + Projectile.scale = 0.014f; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7f; ProjectileSpeed = 30; - MainColor = Main.rand.NextBool() ? Color.Cyan : Color.Magenta; } Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; @@ -62,49 +80,45 @@ namespace CalamityMod.Projectiles.Ranged dust.noLightEmittence = true; } - if (Phase2 == false) - targeted = Projectile.Center.ClosestNPCAt(165); - - if (targeted != null) + if (Time > 45) { - Phase2 = true; - HomingTime = 1; + if (targeted != null) + { + Phase2 = true; + if (HomingTime == 0) + HomingTime = 1; + if (targeted.life <= 0) + targeted = null; + } + else + targeted = Projectile.Center.ClosestNPCAt(450); } - if (HomingTime == 1) + if (HomingTime > 0 && HomingTime < 2 && targeted != null) { Projectile.timeLeft++; - CalamityUtils.HomeInOnNPC(Projectile, true, 2000f, 12, 200f); + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.65f, 7, 0.98f, 0.95f, true); + } + else if (Projectile.velocity.Length() < 7) + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7f, 0.04f); + if (HomingTime > 1) + { + HomingTime--; + Projectile.velocity = Projectile.velocity.RotatedBy(0.2f * rotDir * rotSpeed * Utils.GetLerpValue(15, 5, HomingTime, true)); } Time++; } - - public override void PostDraw(Color lightColor) - { - Color color = Color.White; - Rectangle frame = new Rectangle(0, 0, Terraria.GameContent.TextureAssets.Projectile[Type].Value.Width, Terraria.GameContent.TextureAssets.Projectile[Type].Value.Height); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Items/Ammo/VanquisherArrowGlow").Value, Projectile.Center - Main.screenPosition, frame, color, Projectile.rotation, Projectile.Size / 2, 1f, SpriteEffects.None, 0); - } - - public override Color? GetAlpha(Color lightColor) - { - return lightColor; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + HomingTime = Main.rand.Next(12, 15 + 1) * Projectile.extraUpdates; target.AddBuff(ModContent.BuffType(), 180); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - // First hit is 0.85% damage - if (Projectile.numHits < 1) - Projectile.damage = (int)(Projectile.damage * .85f); + // First hit is 40% damage // Second hit is 100% base damage, it is the "Slash Hit" - else - Projectile.damage = (int)(Projectile.damage * (1f / 0.85f)); - + modifiers.SourceDamage *= (Projectile.numHits == 0 ? 0.4f : 1f); if (Projectile.damage < 1) Projectile.damage = 1; } @@ -112,20 +126,45 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.numHits > 0) { - VoidSparkParticle spark2 = new VoidSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 9, Main.rand.NextFloat(0.15f, 0.25f), Main.rand.NextBool() ? Color.Magenta : Color.Cyan); + Vector2 vel = new Vector2(0.1f, 0.1f).RotatedByRandom(100); + VoidSparkParticle spark2 = new VoidSparkParticle(Projectile.Center, vel, false, 9, Main.rand.NextFloat(0.15f, 0.25f), Main.rand.NextBool() ? Color.Magenta : Color.Cyan); GeneralParticleHandler.SpawnParticle(spark2); + for (int j = -1; j <= 1; j += 2) + { + for (int i = 0; i < 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), vel.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.1f) * Main.rand.NextFloat(2f, 12.5f) * j); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 1.7f); + dust.color = Main.rand.NextBool() ? Color.Magenta : Color.Cyan; + dust.noLightEmittence = true; + dust.fadeIn = 1; + } + } + SoundStyle onKill = new("CalamityMod/Sounds/Item/ScorpioHit"); SoundEngine.PlaySound(onKill with { Volume = 0.25f, Pitch = 0.1f, PitchVariance = 0.3f }, Projectile.Center); - SoundEngine.PlaySound(SoundID.DD2_FlameburstTowerShot with { Volume = 0.8f, Pitch = -0.5f, PitchVariance = 0.3f }, Projectile.Center); + SoundEngine.PlaySound(SoundID.DD2_FlameburstTowerShot with { Volume = 0.4f, Pitch = -0.4f, PitchVariance = 0.3f }, Projectile.Center); } } public override bool PreDraw(ref Color lightColor) { - Texture2D texture = ModContent.Request("CalamityMod/Projectiles/StarProj").Value; - if (Time > 6) - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], MainColor * 0.3f, 1, texture); - return true; + if (Time == 0) + return false; + Asset arrow = ModContent.Request("CalamityMod/Items/Ammo/VanquisherArrow"); + Asset glow = ModContent.Request("CalamityMod/Items/Ammo/VanquisherArrowGlow"); + Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomLineSoftEdge").Value; + + if (Time > 6) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], MainColor with { A = 0 } * 0.6f, 1, texture); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + Main.EntitySpriteDraw(arrow.Value, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, arrow.Size() / 2f, 1, SpriteEffects.None, 0); + Main.EntitySpriteDraw(glow.Value, Projectile.Center - Main.screenPosition, null, Color.Lerp(MainColor, Color.White, 0.6f), Projectile.rotation, glow.Size() / 2f, 1, SpriteEffects.None, 0); + return false; } } } diff --git a/Projectiles/Ranged/VeriumBoltProj.cs b/Projectiles/Ranged/VeriumBoltProj.cs index 3c62464ca2..37bb0ce748 100644 --- a/Projectiles/Ranged/VeriumBoltProj.cs +++ b/Projectiles/Ranged/VeriumBoltProj.cs @@ -1,7 +1,6 @@ using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -29,7 +28,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.extraUpdates = 1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool PreDraw(ref Color lightColor) @@ -71,7 +69,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int k = 0; k < 4; k++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 223, Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(0.1f, 0.9f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworkFountain_Pink, Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(0.1f, 0.9f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 0.7f); } diff --git a/Projectiles/Ranged/VernalBolt.cs b/Projectiles/Ranged/VernalBolt.cs index f548e85826..2cd58bc842 100644 --- a/Projectiles/Ranged/VernalBolt.cs +++ b/Projectiles/Ranged/VernalBolt.cs @@ -20,7 +20,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.extraUpdates = 1; Projectile.timeLeft = 180; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/VoidragonTentacle.cs b/Projectiles/Ranged/VoidragonTentacle.cs index cf7887c1db..d0978a16c4 100644 --- a/Projectiles/Ranged/VoidragonTentacle.cs +++ b/Projectiles/Ranged/VoidragonTentacle.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -24,7 +23,6 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 3; Projectile.DamageType = DamageClass.Ranged; Projectile.extraUpdates = 1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() diff --git a/Projectiles/Ranged/WildfireBloomFire.cs b/Projectiles/Ranged/WildfireBloomFire.cs index 5902dbc88c..207f5fcf19 100644 --- a/Projectiles/Ranged/WildfireBloomFire.cs +++ b/Projectiles/Ranged/WildfireBloomFire.cs @@ -1,8 +1,6 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged diff --git a/Projectiles/Ranged/WildfireBloomFlare.cs b/Projectiles/Ranged/WildfireBloomFlare.cs index f21d9f5d93..f820a97186 100644 --- a/Projectiles/Ranged/WildfireBloomFlare.cs +++ b/Projectiles/Ranged/WildfireBloomFlare.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Ranged/WildfireBloomHoldout.cs b/Projectiles/Ranged/WildfireBloomHoldout.cs index dc4086d841..02dfc11b39 100644 --- a/Projectiles/Ranged/WildfireBloomHoldout.cs +++ b/Projectiles/Ranged/WildfireBloomHoldout.cs @@ -40,11 +40,12 @@ namespace CalamityMod.Projectiles.Ranged if (ShotCooldown == 0) { SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); - Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextBool(2)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + Owner.PickAmmo(Owner.HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); ShotsFired++; ShotCooldown = HeldItem.useTime; - if (FireBlobs == 0) + if (FireBlobs == 0 && Main.myPlayer == Projectile.owner) { float randAngle = Main.rand.NextFloat(8f, 15f); Vector2 newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(randAngle)) * 2f; diff --git a/Projectiles/Ranged/WulfrumScrapBullet.cs b/Projectiles/Ranged/WulfrumScrapBullet.cs index 908adae75c..e175b7280a 100644 --- a/Projectiles/Ranged/WulfrumScrapBullet.cs +++ b/Projectiles/Ranged/WulfrumScrapBullet.cs @@ -47,13 +47,13 @@ namespace CalamityMod.Projectiles.Ranged return base.OnTileCollide(oldVelocity); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = (float)Math.Sqrt(Projectile.timeLeft / 100f); return Color.PaleGoldenrod * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return (1 - completionRatio) * 6.4f; } @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request("CalamityMod/ExtraTextures/Trails/BasicTrail")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); return false; } } diff --git a/Projectiles/Rogue/AcidBarrelDrop.cs b/Projectiles/Rogue/AcidBarrelDrop.cs deleted file mode 100644 index d635b81c3f..0000000000 --- a/Projectiles/Rogue/AcidBarrelDrop.cs +++ /dev/null @@ -1,82 +0,0 @@ -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class AcidBarrelDrop : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Projectiles/Environment/AcidDrop"; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 5; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.tileCollide = true; - Projectile.ignoreWater = false; - Projectile.timeLeft = 840; - Projectile.extraUpdates = 2; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - Projectile.DamageType = RogueDamageClass.Instance; - } - public override void AI() - { - if (Main.rand.NextBool()) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.JungleTorch); - dust.noGravity = true; - dust.scale = Main.rand.NextFloat(0.65f, 0.8f); - dust.velocity = -Projectile.velocity * 0.4f; - } - - if (Projectile.ai[0] < 3) - { - if (Projectile.timeLeft == 839) - Projectile.velocity *= 0.5f; - Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - if (Projectile.velocity.Y <= 12f) - { - Projectile.velocity.Y += 0.15f; - } - Projectile.tileCollide = Projectile.timeLeft <= 300; - } - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - // Water drip - for (int i = 0; i < 4; i++) - { - int idx = Dust.NewDust(Projectile.position - Projectile.velocity, 2, 2, DustID.JungleTorch, 0f, 0f, 0, new Color(112, 150, 42, 127), 1f); - Dust dust = Main.dust[idx]; - dust.position.X -= 2f; - Main.dust[idx].alpha = 38; - Main.dust[idx].velocity *= Projectile.velocity.RotatedByRandom(0.3f) * 0.4f; - Main.dust[idx].velocity -= Projectile.velocity * 0.025f; - Main.dust[idx].scale = 0.85f; - } - return true; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], new Color(255, 255, 255, 127), 2); - return false; - } - } -} diff --git a/Projectiles/Rogue/AcidShrapnel.cs b/Projectiles/Rogue/AcidShrapnel.cs deleted file mode 100644 index 8797e58c73..0000000000 --- a/Projectiles/Rogue/AcidShrapnel.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class AcidShrapnel : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Projectiles/Rogue/BarrelShrapnel"; - - public bool HitTile = false; - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 3; - } - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 160; - Projectile.tileCollide = true; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.ignoreWater = true; - } - public override void AI() - { - Projectile.ai[0] += 1f; - if (HitTile) - { - Projectile.velocity.X = 0f; - Projectile.rotation = MathHelper.Pi; - } - else - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - - Projectile.velocity.Y += 0.2f; - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - HitTile = true; - return false; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - Projectile.Kill(); - } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 180); - Projectile.Kill(); - } - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 15; i++) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulphurousSeaAcid); - dust.velocity = Vector2.UnitY.RotatedBy(i / 15f * MathHelper.TwoPi) * 3f * (float)Math.Cos(i / 15f * MathHelper.TwoPi); - dust.scale = 2.5f; - dust.noGravity = true; - } - } - } -} diff --git a/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs b/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs index 9c28fd938f..2a3431c9fd 100644 --- a/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs +++ b/Projectiles/Rogue/AdamantiteThrowingAxeProjectile.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Rogue/AntlionSkewerProj.cs b/Projectiles/Rogue/AntlionSkewerProj.cs index d5352afbda..82b4faa8b3 100644 --- a/Projectiles/Rogue/AntlionSkewerProj.cs +++ b/Projectiles/Rogue/AntlionSkewerProj.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Rogue/AntlionSkewerSandCloud.cs b/Projectiles/Rogue/AntlionSkewerSandCloud.cs index db9e2423b6..dae0dba88c 100644 --- a/Projectiles/Rogue/AntlionSkewerSandCloud.cs +++ b/Projectiles/Rogue/AntlionSkewerSandCloud.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/AntumbraShardProjectile.cs b/Projectiles/Rogue/AntumbraShardProjectile.cs index c233a5a823..18899e0bdf 100644 --- a/Projectiles/Rogue/AntumbraShardProjectile.cs +++ b/Projectiles/Rogue/AntumbraShardProjectile.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { @@ -110,7 +111,7 @@ namespace CalamityMod.Projectiles.Rogue GeneralParticleHandler.SpawnParticle(spark2); if (Main.rand.NextBool() && !Projectile.Calamity().stealthStrike) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); dust.noGravity = true; dust.velocity = Projectile.velocity * randVel; dust.scale = Main.rand.NextFloat(0.6f, 0.8f); diff --git a/Projectiles/Rogue/ApoctolithExplosion.cs b/Projectiles/Rogue/ApoctolithExplosion.cs index 2016e7b790..89a789a2d4 100644 --- a/Projectiles/Rogue/ApoctolithExplosion.cs +++ b/Projectiles/Rogue/ApoctolithExplosion.cs @@ -28,8 +28,7 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.ai[0] == 0f) { float screenShakePower = 7 * Utils.GetLerpValue(1300f, 0f, Projectile.Distance(Main.LocalPlayer.Center), true); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenShakePower) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenShakePower; + Main.LocalPlayer.SetScreenshake(screenShakePower); CustomPulse blastRing1 = new(Projectile.Center, Vector2.Zero, Color.Blue, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0.05f, 0.35f, 15); GeneralParticleHandler.SpawnParticle(blastRing1); diff --git a/Projectiles/Rogue/ApoctolithProj.cs b/Projectiles/Rogue/ApoctolithProj.cs index 590be93ddb..063b61e44b 100644 --- a/Projectiles/Rogue/ApoctolithProj.cs +++ b/Projectiles/Rogue/ApoctolithProj.cs @@ -1,19 +1,13 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.CalPlayer; -using CalamityMod.MainMenu; using CalamityMod.Particles; -using CalamityMod.Systems; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using rail; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Projectiles.Typeless; using CalamityMod.NPCs.SunkenSea; using CalamityMod.Tiles.Abyss; diff --git a/Projectiles/Rogue/AshenStalactiteDebris.cs b/Projectiles/Rogue/AshenStalactiteDebris.cs index 45e2583878..00bd07fc53 100644 --- a/Projectiles/Rogue/AshenStalactiteDebris.cs +++ b/Projectiles/Rogue/AshenStalactiteDebris.cs @@ -19,6 +19,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = -1; Projectile.timeLeft = 50; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/AshenStalactiteProj.cs b/Projectiles/Rogue/AshenStalactiteProj.cs index f0e3046f7a..9b901030ab 100644 --- a/Projectiles/Rogue/AshenStalactiteProj.cs +++ b/Projectiles/Rogue/AshenStalactiteProj.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/AshenStalagmiteProj.cs b/Projectiles/Rogue/AshenStalagmiteProj.cs index d6df8cb06e..63c8a8d83e 100644 --- a/Projectiles/Rogue/AshenStalagmiteProj.cs +++ b/Projectiles/Rogue/AshenStalagmiteProj.cs @@ -1,6 +1,4 @@ - -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/AuroradicalStar.cs b/Projectiles/Rogue/AuroradicalStar.cs index ce88e9d5ee..1f35bc450e 100644 --- a/Projectiles/Rogue/AuroradicalStar.cs +++ b/Projectiles/Rogue/AuroradicalStar.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -12,11 +11,11 @@ namespace CalamityMod.Projectiles.Rogue public class AuroradicalStar : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; - public int[] dustTypes = new int[] - { + public int[] dustTypes = + [ ModContent.DustType(), ModContent.DustType() - }; + ]; public override void SetStaticDefaults() { @@ -107,39 +106,26 @@ namespace CalamityMod.Projectiles.Rogue } } - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha); - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); - OnHitEffect(target.Center, target.width); + OnHitEffect(target); } - - private void OnHitEffect(Vector2 targetPos, int width) - { - if (Projectile.Calamity().stealthStrike && Main.myPlayer == Projectile.owner) - { - Vector2 pos = new Vector2(targetPos.X + width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - Vector2 velocity = (targetPos - pos) / 40f; - int comet = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 1.25), Projectile.knockBack, Projectile.owner); - if (comet.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[comet].DamageType = RogueDamageClass.Instance; - Main.projectile[comet].Calamity().lineColor = Main.rand.Next(3); - } - } - } - public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(ModContent.BuffType(), 180); - OnHitEffect(target.Center, target.width); + OnHitEffect(target); + } + private void OnHitEffect(Entity target) + { + if (Projectile.Calamity().stealthStrike && Main.myPlayer == Projectile.owner) + { + Vector2 pos = new Vector2(target.Center.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 meteorVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(pos, target, 20f, 3); + int comet = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, meteorVel, ModContent.ProjectileType(), (int)(Projectile.damage * 1.25f), Projectile.knockBack, Projectile.owner); + if (comet.WithinBounds(Main.maxProjectiles)) + Main.projectile[comet].DamageType = RogueDamageClass.Instance; + } } public override void OnKill(int timeLeft) @@ -166,5 +152,12 @@ namespace CalamityMod.Projectiles.Rogue } } } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + return false; + } + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha); } } diff --git a/Projectiles/Rogue/BallisticPoisonBombProj.cs b/Projectiles/Rogue/BallisticPoisonBombProj.cs index 828e638019..7300ceacc7 100644 --- a/Projectiles/Rogue/BallisticPoisonBombProj.cs +++ b/Projectiles/Rogue/BallisticPoisonBombProj.cs @@ -20,6 +20,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.tileCollide = false; Projectile.DamageType = RogueDamageClass.Instance; Projectile.ignoreWater = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -58,10 +60,9 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.ExpandHitboxBy(128); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - int spikeAmt = Main.rand.Next(3, 4+1); if (Projectile.owner == Main.myPlayer) { - for (int s = 0; s < spikeAmt; s++) + for (int s = 0; s < 3; s++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner); @@ -70,7 +71,7 @@ namespace CalamityMod.Projectiles.Rogue for (int c = 0; c < cloudAmt; c++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75), 0f, Projectile.owner, 0f, Projectile.Calamity().stealthStrike ? 1f : 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6f), 0f, Projectile.owner, 0f, Projectile.Calamity().stealthStrike ? 1f : 0f); } } for (int d = 0; d < 5; d++) @@ -97,42 +98,13 @@ namespace CalamityMod.Projectiles.Rogue Vector2 goreSource = Projectile.Center; int goreAmt = 3; Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) + for (int goreIndex = 1; goreIndex <= goreAmt; goreIndex++) { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); + float velocityMult = 0.33f * goreIndex; int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); + int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, Main.rand.NextVector2CircularEdge(2f, 2f), type, 1f); Gore gore = Main.gore[smoke]; gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; } } } @@ -142,7 +114,6 @@ namespace CalamityMod.Projectiles.Rogue target.AddBuff(BuffID.Venom, 180); Projectile.Kill(); } - public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(BuffID.Venom, 180); diff --git a/Projectiles/Rogue/BallisticPoisonCloud.cs b/Projectiles/Rogue/BallisticPoisonCloud.cs index efd74924e6..51cb7e8104 100644 --- a/Projectiles/Rogue/BallisticPoisonCloud.cs +++ b/Projectiles/Rogue/BallisticPoisonCloud.cs @@ -1,10 +1,12 @@ using System; +using CalamityMod.NPCs; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException(onlyForSingleHitbox: true)] public class BallisticPoisonCloud : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/BileExplosion.cs b/Projectiles/Rogue/BileExplosion.cs index e9a21f4ad8..d5dd26b9c3 100644 --- a/Projectiles/Rogue/BileExplosion.cs +++ b/Projectiles/Rogue/BileExplosion.cs @@ -1,10 +1,8 @@ using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -27,6 +25,10 @@ namespace CalamityMod.Projectiles.Rogue Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 25; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.HitDirectionOverride = (Projectile.Center.X < target.Center.X).ToDirectionInt(); + } public override void AI() { diff --git a/Projectiles/Rogue/BlazingStarOrbital.cs b/Projectiles/Rogue/BlazingStarOrbital.cs new file mode 100644 index 0000000000..367cbe811b --- /dev/null +++ b/Projectiles/Rogue/BlazingStarOrbital.cs @@ -0,0 +1,73 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class BlazingStarOrbital : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/BlazingStar"; + + private static int Lifetime = 300; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 3; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 272; + Projectile.height = 272; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 1; + Projectile.timeLeft = Lifetime; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + public override void AI() + { + Projectile.Center = Main.player[Projectile.owner].Center; + Projectile.rotation += 0.2f; Lifetime = 300; + Projectile.ai[0]++; + } + + public override bool PreDraw(ref Color lightColor) + { + float distance = MathHelper.Min(Projectile.ai[0] / 15f, 1f); + if (Projectile.timeLeft < 15) + { + distance = Projectile.timeLeft / 15f; + } + int firstRingGlaives = 3; + int secondRingGlaives = 6; + for (var i2 = 0; i2 < 5; i2++)//Afteriamges + { + for (var i = 0; i < firstRingGlaives; i++) + { + float glaiveRot = MathHelper.TwoPi * ((i / (float)firstRingGlaives)); + float opacity = i2 / 5f; + Main.spriteBatch.Draw(TextureAssets.Projectile[Type].Value, Projectile.Center + new Vector2(distance * 64, 0).RotatedBy(Projectile.rotation + glaiveRot + (1f * i2 / 5f)) - Main.screenPosition, null, lightColor * opacity, Main.GlobalTimeWrappedHourly * -10, TextureAssets.Projectile[Type].Size() * 0.5f, 0.5f * opacity + 0.5f, 0, 1); ; + } + for (var i = 0; i < secondRingGlaives; i++) + { + float glaiveRot = MathHelper.TwoPi * ((i / (float)secondRingGlaives)); + float opacity = 1 - i2 / 5f; + Main.spriteBatch.Draw(TextureAssets.Projectile[Type].Value, Projectile.Center + new Vector2(distance * 128, 0).RotatedBy(-Projectile.rotation * 0.5f + glaiveRot + (0.45f * i2 / 5f)) - Main.screenPosition, null, lightColor * opacity, Main.GlobalTimeWrappedHourly * 10, TextureAssets.Projectile[Type].Size() * 0.5f, 0.5f * opacity + 0.5f, 0, 1); ; + } + } + return false; + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.HitDirectionOverride = -target.DirectionTo(Main.player[Projectile.owner].Center).X.DirectionalSign(); + } + } +} diff --git a/Projectiles/Rogue/BlazingStarProj.cs b/Projectiles/Rogue/BlazingStarProj.cs index 79ce3bb0d0..30035fff76 100644 --- a/Projectiles/Rogue/BlazingStarProj.cs +++ b/Projectiles/Rogue/BlazingStarProj.cs @@ -1,6 +1,5 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Packets.Entities; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -14,9 +13,9 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/BlazingStar"; - public static int Lifetime = 1540; - public static int ReboundTime = 60; - public static float Speed = 13f; + private static int Lifetime = 300; + private int timeAlive => Lifetime - Projectile.timeLeft; + private bool hasHit = false; public override void SetStaticDefaults() { @@ -26,106 +25,87 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - Projectile.width = 34; - Projectile.height = 32; + Lifetime = 300; + Projectile.width = 16; + Projectile.height = 16; Projectile.friendly = true; Projectile.tileCollide = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 5; + Projectile.penetrate = 10; + Projectile.MaxUpdates = 3; Projectile.timeLeft = Lifetime; + DrawOffsetX = -10; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - if (Projectile.Calamity().stealthStrike) - Projectile.penetrate = Projectile.maxPenetrate = -1; + Projectile.rotation += 0.175f * Projectile.direction; - // Boomerang rotation - Projectile.rotation += 0.4f * Projectile.direction; - - // Boomerang sound - if (Projectile.soundDelay == 0) + if (timeAlive == 0) { - Projectile.soundDelay = 8; - SoundEngine.PlaySound(SoundID.Item7, Projectile.position); - } - - // Returns after some number of frames in the air - if (Projectile.timeLeft < Lifetime - ReboundTime) - Projectile.ai[0] = 1f; - - if (Projectile.ai[0] != 0f) - { - Projectile.tileCollide = false; - float returnSpeed = 32.5f; - float acceleration = 2f; - Player owner = Main.player[Projectile.owner]; - - // Delete the projectile if it's excessively far away. - // Relying on the length instead of a second square root call for Normalize is used here for general performance since both the distance - // and normalized vector are used in this code. - float distanceToPlayer = Projectile.Distance(owner.Center); - Vector2 velocity = (owner.Center - Projectile.Center) / distanceToPlayer * returnSpeed; - - // Kill the projectile is if it's super far from the player. - if (distanceToPlayer > 3000f) - Projectile.Kill(); - - // Home back in on the player. - - // No, projectiles do not have a SimpleFlyMovement extension method like NPCs do. - if (Projectile.velocity.X < velocity.X) + Projectile.localNPCHitCooldown = -1; + if (Projectile.Calamity().stealthStrike) { - Projectile.velocity.X = Projectile.velocity.X + acceleration; - if (Projectile.velocity.X < 0f && velocity.X > 0f) - Projectile.velocity.X += acceleration; - } - else if (Projectile.velocity.X > velocity.X) - { - Projectile.velocity.X = Projectile.velocity.X - acceleration; - if (Projectile.velocity.X > 0f && velocity.X < 0f) - Projectile.velocity.X -= acceleration; - } - if (Projectile.velocity.Y < velocity.Y) - { - Projectile.velocity.Y = Projectile.velocity.Y + acceleration; - if (Projectile.velocity.Y < 0f && velocity.Y > 0f) - Projectile.velocity.Y += acceleration; - } - else if (Projectile.velocity.Y > velocity.Y) - { - Projectile.velocity.Y = Projectile.velocity.Y - acceleration; - if (Projectile.velocity.Y > 0f && velocity.Y < 0f) - Projectile.velocity.Y -= acceleration; - } - - // Delete the projectile if it touches its owner. - if (Main.myPlayer == Projectile.owner) - { - if (Projectile.Hitbox.Intersects(owner.Hitbox)) - Projectile.Kill(); + Projectile.penetrate = -1; + Projectile.MaxUpdates++; } } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.OnFire3, 180); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(BuffID.OnFire3, 180); - } - public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } - // Make the star bounce on tiles. + void Ricochet() + { + float maxDistance = 1600f; + float npcDistCompare = 1600f; + int index = -1; + foreach (NPC n in Main.ActiveNPCs) // Find an NPC to ricochet to + { + if (!n.CanBeChasedBy(Projectile) || !Projectile.WithinRange(n.Center, maxDistance) || Projectile.localNPCImmunity[n.whoAmI] != 0) + continue; + + float currentNPCDist = Vector2.Distance(n.Center, Projectile.Center); + if ((currentNPCDist < npcDistCompare) && (Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1))) + { + npcDistCompare = currentNPCDist; + index = n.whoAmI; + } + } + + // If you find an NPC, ricochet in their direction and reset iframes for them + if (index != -1) + { + Projectile.ai[1] = index; + Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], Projectile.velocity.Length(), Projectile.MaxUpdates); + Projectile.netUpdate = true; + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.Calamity().stealthStrike) + { + if (!hasHit) + { + target.Calamity().blazingStarShredTimer += 300; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Projectile.owner, 0f, 0.1f); + + // Shred must be synced, because OnHitNPC is only run for the client that hit the NPC + if (Main.netMode != NetmodeID.SinglePlayer) + GlaiveShredPacket.Send(target); + } + hasHit = true; + } + Ricochet(); + } + + + // Make it bounce on tiles. public override bool OnTileCollide(Vector2 oldVelocity) { // Impacts the terrain even though it bounces off. @@ -140,7 +120,10 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.velocity.Y = -oldVelocity.Y; } - Projectile.ai[0] = 1f; + Projectile.ResetLocalNPCHitImmunity(); + Ricochet(); + if (Projectile.penetrate > 0) + Projectile.penetrate--; return false; } } diff --git a/Projectiles/Rogue/BloodsoakedCrashax.cs b/Projectiles/Rogue/BloodsoakedCrashax.cs index 4884fc3f27..7d4cfc7002 100644 --- a/Projectiles/Rogue/BloodsoakedCrashax.cs +++ b/Projectiles/Rogue/BloodsoakedCrashax.cs @@ -1,11 +1,11 @@ -using CalamityMod.Balancing; -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Projectiles.Healing; + namespace CalamityMod.Projectiles.Rogue { public class BloodsoakedCrashax : ModProjectile, ILocalizedModType @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Rogue else { // Gravity - Projectile.velocity.Y += 0.11f; + Projectile.velocity.Y += 0.07f; // Cap velocity. speed = Projectile.velocity.Length(); @@ -100,16 +100,14 @@ namespace CalamityMod.Projectiles.Rogue private void OnHitEffects(int damage) { - grind += 5; //THE GRIND NEVER STOPS - if (grind > 15) - grind = 15; // except when it's too much + grind += 6; //THE GRIND NEVER STOPS + if (grind > 18) + grind = 18; // except when it's too much if (Projectile.Calamity().stealthStrike && Projectile.owner == Main.myPlayer) //stealth strike attack { int projID = ModContent.ProjectileType(); - int bloodDamage = Projectile.damage; - float bloodKB = 1f; - int stealth = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, projID, bloodDamage, bloodKB, Projectile.owner, 1f, 0.85f + Main.rand.NextFloat() * 1.15f); + int stealth = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * 4f, projID, (int)(Projectile.damage * 0.5f), 1f, Projectile.owner, 1f, 0.85f + Main.rand.NextFloat() * 1.15f); if (stealth.WithinBounds(Main.maxProjectiles)) { Main.projectile[stealth].DamageType = RogueDamageClass.Instance; @@ -117,14 +115,16 @@ namespace CalamityMod.Projectiles.Rogue } } - int heal = (int)Math.Round(damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; + float orbAmount = Projectile.Calamity().stealthStrike ? 3 : Projectile.penetrate % 2; + if (orbAmount > 0) + { + float spreadAmount = MathHelper.ToRadians(360); + for (var i = 0; i < orbAmount; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.One.RotatedByRandom(spreadAmount) * 2f * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 10, 0f, Projectile.owner); - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + } + } } public override bool PreDraw(ref Color lightColor) //afterimages diff --git a/Projectiles/Rogue/BlunderBoosterLightning.cs b/Projectiles/Rogue/BlunderBoosterLightning.cs index 29bd9d4098..bbe5a0d6de 100644 --- a/Projectiles/Rogue/BlunderBoosterLightning.cs +++ b/Projectiles/Rogue/BlunderBoosterLightning.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -14,6 +13,8 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public static int frameWidth = 12; public static int frameHeight = 26; + public int dir = 0; + public float intensity = 0; public override void SetStaticDefaults() { @@ -23,15 +24,17 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = 40; + Projectile.height = 40; Projectile.friendly = true; Projectile.tileCollide = false; Projectile.penetrate = 1; - Projectile.timeLeft = 120; + Projectile.extraUpdates = 2; + Projectile.timeLeft = 290; Projectile.DamageType = RogueDamageClass.Instance; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 15; + Projectile.localNPCHitCooldown = -1; + Projectile.ArmorPenetration = 15; } public override void AI() @@ -49,43 +52,20 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.timeLeft < 55 && Projectile.ai[1] != 1f) - { - Projectile.tileCollide = true; - } - Projectile.ai[1]++; - if (Projectile.ai[1] >= 15f) - { - float minDist = 999f; - int index = -1; - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.CanBeChasedBy(Projectile, false)) - { - float dist = (Projectile.Center - npc.Center).Length(); - if (dist < minDist) - { - minDist = dist; - index = npc.whoAmI; - } - } - } - Vector2 velocityNew; - if (minDist < 999f && index != -1) - { - velocityNew = Main.npc[index].Center - Projectile.Center; - velocityNew.Normalize(); - velocityNew *= 2f; - Projectile.velocity += velocityNew; - if (Projectile.velocity.Length() > 10f) - { - Projectile.velocity.Normalize(); - Projectile.velocity *= 10f; - } - } + if (dir == 0) + { + Projectile.timeLeft -= Main.rand.Next(5, 20 + 1); + dir = Main.rand.NextBool() ? -1 : 1; + intensity = Main.rand.NextFloat(0.2f, 1.2f); } + + + if (Projectile.timeLeft < 190) + CalamityUtils.HomeInOnSelectedNPC(Projectile, Projectile.Center.ClosestNPCAt(1500), true, 0.65f * intensity, 8, 0.98f, 0.99f, true); + else + Projectile.velocity = Projectile.velocity.RotatedBy(0.04f * dir * intensity) * Main.rand.NextFloat(0.985f, 1f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Rogue/Brick.cs b/Projectiles/Rogue/Brick.cs index da1d54c513..b1fe2fe40f 100644 --- a/Projectiles/Rogue/Brick.cs +++ b/Projectiles/Rogue/Brick.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/BrimbladeProj.cs b/Projectiles/Rogue/BrimbladeProj.cs index e12364e225..17c0a27023 100644 --- a/Projectiles/Rogue/BrimbladeProj.cs +++ b/Projectiles/Rogue/BrimbladeProj.cs @@ -22,6 +22,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 180; AIType = ProjectileID.WoodenBoomerang; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Rogue/BurningStrifeProj.cs b/Projectiles/Rogue/BurningStrifeProj.cs index c0cbb74b13..bbaa6d9d0a 100644 --- a/Projectiles/Rogue/BurningStrifeProj.cs +++ b/Projectiles/Rogue/BurningStrifeProj.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/CelestusProj.cs b/Projectiles/Rogue/CelestusProj.cs index d1f724e892..2056e68e0a 100644 --- a/Projectiles/Rogue/CelestusProj.cs +++ b/Projectiles/Rogue/CelestusProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/CircletMark.cs b/Projectiles/Rogue/CircletMark.cs deleted file mode 100644 index 1222796e47..0000000000 --- a/Projectiles/Rogue/CircletMark.cs +++ /dev/null @@ -1,159 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class CircletMark : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.timeLeft = 900; - Projectile.ignoreWater = true; - Projectile.alpha = 255; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - Color newColor3 = new Color(255, 255, 255); - if (Projectile.soundDelay == 0) - { - Projectile.soundDelay = -1; - SoundEngine.PlaySound(SoundID.Item60, Projectile.Center); - } - if (Projectile.localAI[1] < 30f) - { - for (int i = 0; i < 1; i++) - { - float lerpvalue1 = -0.5f; - float lerpvalue2 = 0.9f; - float randomLerp = Main.rand.NextFloat(); - Vector2 dustMovement = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(lerpvalue1, lerpvalue2, randomLerp)); - dustMovement.X *= MathHelper.Lerp(2.2f, 0.6f, randomLerp); - dustMovement.X *= -1f; - Vector2 dustMovement2 = new Vector2(2f, 10f); - Vector2 position4 = Projectile.Center + new Vector2(60f, 200f) * dustMovement * 0.5f + dustMovement2; - Dust dust = Main.dust[Dust.NewDust(position4, 0, 0, DustID.Sandnado, 0f, 0f, 0, default, 0.5f)]; - dust.position = position4; - dust.customData = Projectile.Center + dustMovement2; - dust.fadeIn = 1f; - dust.scale = 0.3f; - if (dustMovement.X > -1.2f) - { - dust.velocity.X = 1f + Main.rand.NextFloat(); - } - dust.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; - } - } - if (Projectile.localAI[0] == 0f) - { - Projectile.localAI[0] = 0.8f; - Projectile.direction = 1; - Point projCenter = Projectile.Center.ToTileCoordinates(); - Projectile.Center = new Vector2((float)(projCenter.X * 16 + 8), (float)(projCenter.Y * 16 + 8)); - } - Projectile.rotation = Projectile.localAI[1] / 40f * 6.28318548f * (float)Projectile.direction; - if (Projectile.localAI[1] < 33f) - { - if (Projectile.alpha > 0) - { - Projectile.alpha -= 8; - } - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } - } - if (Projectile.localAI[1] > 103f) - { - if (Projectile.alpha < 255) - { - Projectile.alpha += 16; - } - if (Projectile.alpha > 255) - { - Projectile.alpha = 255; - } - } - if (Projectile.alpha == 0) - { - Lighting.AddLight(Projectile.Center, newColor3.ToVector3() * 0.5f); - } - for (int j = 0; j < 2; j++) - { - if (Main.rand.NextBool(10)) - { - Vector2 dustVel = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust dusty = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, DustID.Sandnado, 0f, 0f, 225, newColor3, 1f)]; - dusty.noGravity = true; - dusty.noLight = true; - dusty.scale = Projectile.Opacity * Projectile.localAI[0]; - dusty.position = Projectile.Center; - dusty.velocity = dustVel * 2.5f; - } - } - for (int k = 0; k < 2; k++) - { - if (Main.rand.NextBool(10)) - { - Vector2 dustVel2 = Vector2.UnitY.RotatedBy((double)((float)k * 3.14159274f), default); - Dust dustier = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, DustID.Sandnado, 0f, 0f, 225, newColor3, 1.5f)]; - dustier.noGravity = true; - dustier.noLight = true; - dustier.scale = Projectile.Opacity * Projectile.localAI[0]; - dustier.position = Projectile.Center; - dustier.velocity = dustVel2 * 2.5f; - } - } - if (Projectile.localAI[1] < 33f || Projectile.localAI[1] > 87f) - { - Projectile.scale = Projectile.Opacity / 2f * Projectile.localAI[0]; - } - Projectile.velocity = Vector2.Zero; - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] == 60f && Projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 2f, Projectile.owner, 0f, 0f); - } - if (Projectile.localAI[1] >= 120f) - { - Projectile.Kill(); - return; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Color originalColor = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - SpriteEffects spriteEffects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Vector2 drawPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Texture2D texture2D27 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle rectangle = texture2D27.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Color alphaColor = Projectile.GetAlpha(originalColor); - Vector2 origin7 = rectangle.Size() / 2f; - Color sandyColor = Main.hslToRgb(0.25f, 1f, 1f).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), sandyColor, 0f, origin7, new Vector2(1f, 5f) * Projectile.scale * 2f, spriteEffects, 0); - Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, Projectile.rotation, origin7, Projectile.scale, spriteEffects, 0); - Main.spriteBatch.Draw(texture2D27, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaColor, 0f, origin7, new Vector2(1f, 8f) * Projectile.scale, spriteEffects, 0); - return false; - } - } -} diff --git a/Projectiles/Rogue/CircletTornado.cs b/Projectiles/Rogue/CircletTornado.cs index 8ea5f2ff63..4ac2eb94bf 100644 --- a/Projectiles/Rogue/CircletTornado.cs +++ b/Projectiles/Rogue/CircletTornado.cs @@ -12,165 +12,121 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Projectiles/TornadoProj"; + public static float Lifetime = 900f; + public static float Fadetime = 120f; + + public ref float Time => ref Projectile.ai[0]; + public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = Projectile.height = 10; Projectile.friendly = true; Projectile.tileCollide = false; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.minion = true; Projectile.penetrate = -1; - Projectile.timeLeft = 1200; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 30; } public override void AI() { - //only 1 tornado can exist at a time - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] >= 10f) - { - Projectile.localAI[1] = 0f; - int projCount = 0; - int oldestTornado = 0; - float tornadoAge = 0f; - int projType = Projectile.type; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - if (proj.active && proj.owner == Projectile.owner && proj.type == projType && proj.ai[0] < 900f) - { - projCount++; - if (proj.ai[0] > tornadoAge) - { - oldestTornado = projIndex; - tornadoAge = proj.ai[0]; - } - } - } - if (projCount > 1) - { - Main.projectile[oldestTornado].netUpdate = true; - Main.projectile[oldestTornado].ai[0] = 36000f; - return; - } - } - - float lifeSpan = 900f; if (Projectile.soundDelay == 0) { Projectile.soundDelay = -1; - SoundEngine.PlaySound(SoundID.Item122, Projectile.Center); + SoundEngine.PlaySound(SoundID.Item82, Projectile.Center); } - Projectile.ai[0] += 1f; - if (Projectile.ai[0] >= lifeSpan) - { + + Time++; + if (Time >= Lifetime) Projectile.Kill(); - } - if (Projectile.localAI[0] >= 30f) + if (Projectile.numHits >= 30) { Projectile.damage = 0; - if (Projectile.ai[0] < lifeSpan - 120f) + if (Time < Lifetime - Fadetime) { - float aiDecrement = Projectile.ai[0] % 60f; - Projectile.ai[0] = lifeSpan - 120f + aiDecrement; + Time = Lifetime - Fadetime + Time % 60f; Projectile.netUpdate = true; } } - Point point8 = Projectile.Center.ToTileCoordinates(); - int sizeMod; - int sizeMod2; - Collision.ExpandVertically(point8.X, point8.Y, out sizeMod, out sizeMod2, 15, 15); - sizeMod++; - sizeMod2--; - Vector2 sizeModVector = new Vector2((float)point8.X, (float)sizeMod) * 16f + new Vector2(8f); - Vector2 sizeModVector2 = new Vector2((float)point8.X, (float)sizeMod2) * 16f + new Vector2(8f); - Vector2 centering = Vector2.Lerp(sizeModVector, sizeModVector2, 0.5f); - Vector2 sizeModPos = new Vector2(0f, sizeModVector2.Y - sizeModVector.Y); - sizeModPos.X = sizeModPos.Y * 0.2f; - Projectile.width = (int)(sizeModPos.X * 0.65f); - Projectile.height = (int)sizeModPos.Y; - Projectile.Center = centering; + + GetVerticallyExpandedPos(out Vector2 newTop, out Vector2 newBottom, out Vector2 newCenter, out Vector2 newSize); + Projectile.width = (int)(newSize.X * 0.65f); + Projectile.height = (int)newSize.Y; + Projectile.Center = newCenter; if (Projectile.owner == Main.myPlayer) { bool breakFlag = false; Vector2 playerCenter = Main.player[Projectile.owner].Center; - Vector2 top = Main.player[Projectile.owner].Top; + Vector2 playerTop = Main.player[Projectile.owner].Top; for (float i = 0f; i < 1f; i += 0.05f) { - Vector2 position2 = Vector2.Lerp(sizeModVector, sizeModVector2, i); - if (Collision.CanHitLine(position2, 0, 0, playerCenter, 0, 0) || Collision.CanHitLine(position2, 0, 0, top, 0, 0)) + Vector2 collisionPos = Vector2.Lerp(newTop, newBottom, i); + if (Collision.CanHitLine(collisionPos, 0, 0, playerCenter, 0, 0) || Collision.CanHitLine(collisionPos, 0, 0, playerTop, 0, 0)) { breakFlag = true; break; } } - if (!breakFlag && Projectile.ai[0] < lifeSpan - 120f) + if (!breakFlag && Time < Lifetime - Fadetime) { - float aiDecrement2 = Projectile.ai[0] % 60f; - Projectile.ai[0] = lifeSpan - 120f + aiDecrement2; + Time = Lifetime - Fadetime + Time % 60f; Projectile.netUpdate = true; } } - if (Projectile.ai[0] < lifeSpan - 120f) + if (Time < Lifetime - Fadetime) { - return; + float randFactor = Main.rand.NextFloat(); + Vector2 randomOffset = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()) * MathHelper.Lerp(-2.2f, -0.6f, randFactor), MathHelper.Lerp(-0.5f, 0.9f, randFactor)); + Vector2 fixedOffset = new Vector2(6f, 10f); + Vector2 dustPos = newCenter + newSize * randomOffset * 0.5f + fixedOffset; + Dust sand = Dust.NewDustDirect(dustPos, 0, 0, DustID.Sandnado); + sand.position = dustPos; + sand.customData = newCenter + fixedOffset; + sand.fadeIn = 1f; + sand.scale = 0.3f; + if (randomOffset.X > -1.2f) + sand.velocity.X = 1f + Main.rand.NextFloat(); + sand.velocity.Y = Main.rand.NextFloat() * -0.5f - 1f; } } public override bool PreDraw(ref Color lightColor) { - float aiTracker = Projectile.ai[0]; - float trackerClamp = MathHelper.Clamp(aiTracker / 30f, 0f, 1f); - if (aiTracker > 540f) - { - trackerClamp = MathHelper.Lerp(1f, 0f, (aiTracker - 540f) / 60f); - } - Point centerPoint = Projectile.Center.ToTileCoordinates(); - int sizeModding; - int sizeModding2; - Collision.ExpandVertically(centerPoint.X, centerPoint.Y, out sizeModding, out sizeModding2, 15, 15); - sizeModding++; - sizeModding2--; - float vectorMult = 0.2f; - Vector2 sizeModdingVector = new Vector2((float)centerPoint.X, (float)sizeModding) * 16f + new Vector2(8f); - Vector2 sizeModdingVector2 = new Vector2((float)centerPoint.X, (float)sizeModding2) * 16f + new Vector2(8f); - Vector2.Lerp(sizeModdingVector, sizeModdingVector2, 0.5f); - Vector2 sizeModdingPos = new Vector2(0f, sizeModdingVector2.Y - sizeModdingVector.Y); - sizeModdingPos.X = sizeModdingPos.Y * vectorMult; - new Vector2(sizeModdingVector.X - sizeModdingPos.X / 2f, sizeModdingVector.Y); - Texture2D texture2D23 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle drawRectangle = texture2D23.Frame(1, 1, 0, 0); - Vector2 smallRect = drawRectangle.Size() / 2f; - float aiTrackMult = -0.06283186f * aiTracker; - Vector2 spinningpoint = Vector2.UnitY.RotatedBy((double)(aiTracker * 0.1f), default); + Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + GetVerticallyExpandedPos(out Vector2 newTop, out Vector2 newBottom, out Vector2 newCenter, out Vector2 newSize); + + float TextureFadetime = Lifetime - 60f; + Color fullColor = new Color(212, 192, 100); + float colorMult = (Time > TextureFadetime ? MathHelper.Lerp(1f, 0f, (Time - TextureFadetime) / 60f) : MathHelper.Clamp(Time / 30f, 0f, 1f)); + float timedRotation = Time * MathHelper.Pi * -0.02f; + float incrementStorage = 0f; float increment = 5.1f; - Color sandYellow = new Color(225, 225, 100); - for (float k = (float)(int)sizeModdingVector2.Y; k > (float)(int)sizeModdingVector.Y; k -= increment) + for (float k = newBottom.Y; k > newTop.Y; k -= increment) { incrementStorage += increment; - float colorChanger = incrementStorage / sizeModdingPos.Y; - float incStorageMult = incrementStorage * 6.28318548f / -20f; - float lowerColorChanger = colorChanger - 0.15f; - Vector2 spinArea = spinningpoint.RotatedBy((double)incStorageMult, default); - Vector2 colorChangeVector = new Vector2(0f, colorChanger + 1f); - colorChangeVector.X = colorChangeVector.Y * vectorMult; - Color newSandYellow = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, sandYellow, colorChanger * 2f); - if (colorChanger > 0.5f) - { - newSandYellow = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, sandYellow, 2f - colorChanger * 2f); - } - newSandYellow.A = (byte)((float)newSandYellow.A * 0.5f); - newSandYellow *= trackerClamp; - spinArea *= colorChangeVector * 100f; - spinArea.Y = 0f; - spinArea.X = 0f; - spinArea += new Vector2(sizeModdingVector2.X, k) - Main.screenPosition; - Main.spriteBatch.Draw(texture2D23, spinArea, new Microsoft.Xna.Framework.Rectangle?(drawRectangle), newSandYellow, aiTrackMult + incStorageMult, smallRect, 1f + lowerColorChanger, SpriteEffects.None, 0); + float segmentHeight = incrementStorage / newSize.Y; + float addedRotation = incrementStorage * MathHelper.Pi * -0.1f; + float addedScale = segmentHeight - 0.15f; + Color drawColor = Color.Lerp(Color.Transparent, fullColor, (segmentHeight > 0.5f ? 2f - segmentHeight * 2f : segmentHeight * 2f)); + drawColor.A = (byte)((float)drawColor.A * 0.5f); + + Vector2 drawPos = new Vector2(newBottom.X, k) - Main.screenPosition; + Main.spriteBatch.Draw(tex, drawPos, null, drawColor * colorMult, timedRotation + addedRotation, tex.Size() * 0.5f, 1f + addedScale, SpriteEffects.None, 0); } return false; } + + public void GetVerticallyExpandedPos(out Vector2 newTop, out Vector2 newBottom, out Vector2 newCenter, out Vector2 newSize) + { + Point center = Projectile.Center.ToTileCoordinates(); + Collision.ExpandVertically(center.X, center.Y, out int topY, out int bottomY, 15, 15); + newTop = new Vector2(center.X, topY + 1) * 16f + new Vector2(8f); + newBottom = new Vector2(center.X, bottomY - 1) * 16f + new Vector2(8f); + newCenter = Vector2.Lerp(newTop, newBottom, 0.5f); + newSize = new Vector2(0f, newBottom.Y - newTop.Y); + newSize.X = newSize.Y * 0.2f; + } } } diff --git a/Projectiles/Rogue/CobaltKunaiProjectile.cs b/Projectiles/Rogue/CobaltKunaiProjectile.cs index 07c4e8ee65..cbb13afe0c 100644 --- a/Projectiles/Rogue/CobaltKunaiProjectile.cs +++ b/Projectiles/Rogue/CobaltKunaiProjectile.cs @@ -1,9 +1,6 @@ -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { diff --git a/Projectiles/Rogue/CorpusAvertorClone.cs b/Projectiles/Rogue/CorpusAvertorClone.cs index 561260ec7a..4d691b78b9 100644 --- a/Projectiles/Rogue/CorpusAvertorClone.cs +++ b/Projectiles/Rogue/CorpusAvertorClone.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Rogue/CorpusAvertorProj.cs b/Projectiles/Rogue/CorpusAvertorProj.cs index 7c00bf1283..1f35e41c2d 100644 --- a/Projectiles/Rogue/CorpusAvertorProj.cs +++ b/Projectiles/Rogue/CorpusAvertorProj.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; @@ -79,29 +78,9 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); - - int heal = (int)Math.Round(hit.Damage * 0.05); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.player[Projectile.owner].lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, (int)Math.Round(hit.Damage * 0.05)); } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 180); - - int heal = (int)Math.Round(info.Damage * 0.05); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.player[Projectile.owner].lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/Projectiles/Rogue/CorpusAvertorStealth.cs b/Projectiles/Rogue/CorpusAvertorStealth.cs index 99f36ef71e..8a3ee31bc5 100644 --- a/Projectiles/Rogue/CorpusAvertorStealth.cs +++ b/Projectiles/Rogue/CorpusAvertorStealth.cs @@ -1,5 +1,4 @@ -using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Particles; using CalamityMod.Sounds; @@ -37,6 +36,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = -1; Projectile.MaxUpdates = 4; Projectile.timeLeft = 300; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -91,8 +92,13 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); - if (target.lifeMax > 5 && Projectile.numHits == 0 && Slash == 0f) - OnHitEffects(hit.Damage); + if (target.IsAnEnemy(false) && Projectile.numHits == 0 && Slash == 0f) + { + Player player = Main.player[Projectile.owner]; + player.SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, (int)Math.Round(hit.Damage * 0.025)); + if (Main.LocalPlayer.team == player.team && player.team != 0) + Main.LocalPlayer.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(20f), true); + } if (Projectile.numHits > 0 && !(target.life <= 0 && target.realLife == -1)) Projectile.damage = (int)(Projectile.damage * 0.9f); @@ -100,29 +106,6 @@ namespace CalamityMod.Projectiles.Rogue Projectile.damage = 1; } - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), 180); - if (Projectile.numHits == 0 && Slash == 0f) - OnHitEffects(info.Damage); - } - - private void OnHitEffects(int damage) - { - Player player = Main.player[Projectile.owner]; - if (Main.LocalPlayer.team == player.team && player.team != 0) - { - Main.LocalPlayer.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(20f), true); - - int heal = (int)Math.Round(damage * 0.025); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.LocalPlayer, heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); - } - } + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/Projectiles/Rogue/Corrocloud1.cs b/Projectiles/Rogue/Corrocloud1.cs index 1a277ec5db..46a118bfe1 100644 --- a/Projectiles/Rogue/Corrocloud1.cs +++ b/Projectiles/Rogue/Corrocloud1.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/Corrocloud2.cs b/Projectiles/Rogue/Corrocloud2.cs index 32115a9cf5..3417ef3b8a 100644 --- a/Projectiles/Rogue/Corrocloud2.cs +++ b/Projectiles/Rogue/Corrocloud2.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/Corrocloud3.cs b/Projectiles/Rogue/Corrocloud3.cs index 06fa8761d7..25a45d9056 100644 --- a/Projectiles/Rogue/Corrocloud3.cs +++ b/Projectiles/Rogue/Corrocloud3.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/CraniumSmasherExplosive.cs b/Projectiles/Rogue/CraniumSmasherExplosive.cs index 3fcf3036a9..874ca3ca1f 100644 --- a/Projectiles/Rogue/CraniumSmasherExplosive.cs +++ b/Projectiles/Rogue/CraniumSmasherExplosive.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/CraniumSmasherStealth.cs b/Projectiles/Rogue/CraniumSmasherStealth.cs index 5c22c4ad96..beb06ba31a 100644 --- a/Projectiles/Rogue/CraniumSmasherStealth.cs +++ b/Projectiles/Rogue/CraniumSmasherStealth.cs @@ -75,8 +75,7 @@ namespace CalamityMod.Projectiles.Rogue if (Main.myPlayer == Projectile.owner) Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 0f, Projectile.owner, 0f, 1f); SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3.5f) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3.5f; + Main.LocalPlayer.SetScreenshake(3.5f); if (!Main.dedServ) { diff --git a/Projectiles/Rogue/Crushax.cs b/Projectiles/Rogue/Crushax.cs index f8f7e01382..c3b7f5d28c 100644 --- a/Projectiles/Rogue/Crushax.cs +++ b/Projectiles/Rogue/Crushax.cs @@ -32,8 +32,13 @@ namespace CalamityMod.Projectiles.Rogue Projectile.ai[0]++; if (Projectile.ai[0] >= 20f) { - Projectile.velocity.Y += 0.35f; - Projectile.velocity.X *= 0.97f; + if (CalamityUtils.ClosestNPCAt(Projectile.Center, 280f) == null) + { + Projectile.velocity.Y += 0.35f; + Projectile.velocity.X *= 0.97f; + } + else + CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 280f, 14f, 20f); } else { @@ -42,9 +47,6 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.velocity.Y > 15f) Projectile.velocity.Y = 15f; - - if (Projectile.ai[0] >= 20f) - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 280f, 14f, 20f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/CrystalPiercerProjectile.cs b/Projectiles/Rogue/CrystalPiercerProjectile.cs index 61cb9505f0..8001454901 100644 --- a/Projectiles/Rogue/CrystalPiercerProjectile.cs +++ b/Projectiles/Rogue/CrystalPiercerProjectile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Weapons.Rogue; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -26,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 600; AIType = ProjectileID.BoneJavelin; Projectile.DamageType = RogueDamageClass.Instance; - Projectile.localNPCHitCooldown = 10; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/CursedDaggerBlastHitbox.cs b/Projectiles/Rogue/CursedDaggerBlastHitbox.cs index 2c2f129f03..9ebf1727aa 100644 --- a/Projectiles/Rogue/CursedDaggerBlastHitbox.cs +++ b/Projectiles/Rogue/CursedDaggerBlastHitbox.cs @@ -1,15 +1,9 @@ -using System; -using System.Reflection.Metadata; -using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Utilities; -using static Humanizer.In; namespace CalamityMod.Projectiles.Rogue { @@ -37,7 +31,7 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.timeLeft % 30 == 0) SoundEngine.PlaySound(SoundID.DD2_SkyDragonsFurySwing with { Volume = 1.2f }, Projectile.position); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(200f, 200f), 75); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(200f, 200f), DustID.CursedTorch); dust2.scale = Main.rand.NextFloat(0.8f, 1.1f); dust2.noGravity = true; diff --git a/Projectiles/Rogue/CursedDaggerProj.cs b/Projectiles/Rogue/CursedDaggerProj.cs index b7878c41c5..e9ec19acbc 100644 --- a/Projectiles/Rogue/CursedDaggerProj.cs +++ b/Projectiles/Rogue/CursedDaggerProj.cs @@ -1,12 +1,10 @@ using CalamityMod.Dusts; -using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Projectiles.Rogue { diff --git a/Projectiles/Rogue/DeepWounderProjectile.cs b/Projectiles/Rogue/DeepWounderProjectile.cs index 8575ee7ec5..ddbaacfa61 100644 --- a/Projectiles/Rogue/DeepWounderProjectile.cs +++ b/Projectiles/Rogue/DeepWounderProjectile.cs @@ -1,7 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -32,7 +31,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - Projectile.rotation += (StuckTo == null ? 0.2f : 0.35f) * Projectile.direction; + Projectile.rotation += (StuckTo == null ? 0.3f : 0.6f) * Projectile.direction; if (Projectile.Calamity().stealthStrike) { @@ -64,11 +63,10 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); if (Projectile.Calamity().stealthStrike) { - target.AddBuff(ModContent.BuffType(), 120); if (StuckTo == null) { StuckTo = target; diff --git a/Projectiles/Rogue/DestructionBolt.cs b/Projectiles/Rogue/DestructionBolt.cs index b1f39306a7..061624c956 100644 --- a/Projectiles/Rogue/DestructionBolt.cs +++ b/Projectiles/Rogue/DestructionBolt.cs @@ -1,12 +1,8 @@ -using System; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/DestructionExplosion.cs b/Projectiles/Rogue/DestructionExplosion.cs index d20d58abca..aeb01ad6f6 100644 --- a/Projectiles/Rogue/DestructionExplosion.cs +++ b/Projectiles/Rogue/DestructionExplosion.cs @@ -27,8 +27,16 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { + if (Main.zenithWorld) + { + Projectile.hostile = true; + Projectile.friendly = true; + } + if (Projectile.ai[0] == 1) - ExplosionRadius = 800; + { + ExplosionRadius = 800; + } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { diff --git a/Projectiles/Rogue/DestructionStar.cs b/Projectiles/Rogue/DestructionStar.cs index 2f70791b27..cca15c79f5 100644 --- a/Projectiles/Rogue/DestructionStar.cs +++ b/Projectiles/Rogue/DestructionStar.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -44,6 +43,7 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { + if (setRot) { rotDirection = Main.rand.NextBool() ? 1 : -1; @@ -151,24 +151,41 @@ namespace CalamityMod.Projectiles.Rogue internal void Explode(bool big) { - float sizeBonus = big ? 2 : 1; - float bigExplosionDamage = 1f; + + + float sizeBonus = big ? Main.zenithWorld ? 6 : 2 : 1; + float bigExplosionDamage = 3f; Player Owner = Main.player[Projectile.owner]; Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.LightGreen with { A = 0 }, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0f, 0.82f * sizeBonus, 11); GeneralParticleHandler.SpawnParticle(orb); Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0f, 0.74f * sizeBonus, 11); GeneralParticleHandler.SpawnParticle(orb2); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (big ? bigExplosionDamage : Projectile.Calamity().stealthStrike ? 0.25f : 1f)), Projectile.knockBack * 1.5f, Projectile.owner); - SoundStyle explo = new("CalamityMod/Sounds/Item/MeldExplosion"); - SoundEngine.PlaySound(explo with { Volume = 0.9f }, Projectile.Center); + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (big ? Main.zenithWorld ? bigExplosionDamage * 4f : bigExplosionDamage : Projectile.Calamity().stealthStrike ? 0.25f : 1f)), Projectile.knockBack * 1.5f, Projectile.owner); + + if (!Main.zenithWorld || !big) + { + SoundStyle explo = new("CalamityMod/Sounds/Item/MeldExplosion"); + SoundEngine.PlaySound(explo with { Volume = 0.9f }, Projectile.Center); + } + else + { + SoundStyle gfbExplosion = new("CalamityMod/Sounds/Custom/ExoMechs/AresGaussNukeExplosion"); + SoundEngine.PlaySound(gfbExplosion with { Volume = 1f, Pitch = -0.5f }, Projectile.Center); + } + if (big) { - SoundStyle explo2 = new("CalamityMod/Sounds/Item/EarthMeteor"); - SoundEngine.PlaySound(explo2 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); + if (!Main.zenithWorld) + { + SoundStyle explo2 = new("CalamityMod/Sounds/Item/EarthMeteor"); + SoundEngine.PlaySound(explo2 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); + + SoundStyle explo3 = new("CalamityMod/Sounds/Item/ExobladeDashImpact"); + SoundEngine.PlaySound(explo3 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); + } - SoundStyle explo3 = new("CalamityMod/Sounds/Item/ExobladeDashImpact"); - SoundEngine.PlaySound(explo3 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); } Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.LightGreen, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 2.56f * 1.3f * sizeBonus, 18); @@ -196,13 +213,13 @@ namespace CalamityMod.Projectiles.Rogue } for (int i = 0; i < (25 * sizeBonus); i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 278); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB); dust.noGravity = false; dust.velocity = new Vector2(18, 18).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f) * sizeBonus; dust.scale = Main.rand.NextFloat(0.8f, 1.2f); dust.color = Color.LightGreen; } - Owner.Calamity().GeneralScreenShakePower = 6f * (big ? 2.5f : 1f); + Owner.SetScreenshake(6f * (big ? 2.5f : 1f)); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Rogue/DimensionTearingDiskProjectile.cs b/Projectiles/Rogue/DimensionTearingDiskProjectile.cs new file mode 100644 index 0000000000..156084813e --- /dev/null +++ b/Projectiles/Rogue/DimensionTearingDiskProjectile.cs @@ -0,0 +1,229 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + [PierceResistException] + public class DimensionTearingDiskProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/DimensionTearingDisk"; + private static float RotationIncrement = 0.15f; + private static int Lifetime = 350; + public static int StealthExtraLifetime = 240; // 1 extra update means this is double what you'd expect for 2 seconds + private static int ReboundTime = 60; + + private float randomLaserCharge = 0f; + private Vector2 dir = Vector2.Zero; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 6; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 62; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = Lifetime; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = RogueDamageClass.Instance; + } + + public override void AI() + { + if (dir == Vector2.Zero) + dir = Projectile.velocity.SafeNormalize(Vector2.Zero); + + // The disc runs its returning AI if it has existed longer than ReboundTime frames. + if (Projectile.ai[0] != 1f) + { + + // On the frame the disc begins returning, send a net update. + if (Projectile.timeLeft == Lifetime - ReboundTime) + { + Projectile.ResetLocalNPCHitImmunity(); + Projectile.netUpdate = true; + } + Projectile.velocity = Vector2.Lerp(dir, Projectile.DirectionTo(Main.player[Projectile.owner].Center).SafeNormalize(Vector2.Zero), (Lifetime - Projectile.timeLeft) / (ReboundTime * 1.75f)); + Projectile.velocity *= Projectile.Calamity().stealthStrike ? 40f : 25f; + } + if (Projectile.timeLeft < Lifetime - ReboundTime) + { + if (Projectile.Distance(Main.player[Projectile.owner].Center) < 32) + Projectile.Kill(); + } + // Lighting. + Lighting.AddLight(Projectile.Center, 0.35f, 0f, 0.25f); + + // Rotate the disc as it flies. + float spin = Projectile.direction <= 0 ? -1f : 1f; + Projectile.rotation += spin * RotationIncrement; + + // If attached to something (this only occurs for stealth strikes), do the buzzsaw grind and spam lasers everywhere. + if (Projectile.ai[0] == 1f) + StealthStrikeGrind(spin); + else if (Projectile.timeLeft == Lifetime - ReboundTime) + { + NPC npc = null; + float maxDist = 1000; + foreach (var item in Main.ActiveNPCs) + { + if (!item.CanBeChasedBy()) + continue; + var dist = item.Distance(Projectile.Center); + if (dist < maxDist) + { + maxDist = dist; + npc = item; + } + } + if (npc != null) + { + int laserDamage = (int)(Projectile.damage * 0.7f); + Projectile laser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.DirectionTo(npc.Center), ModContent.ProjectileType(), laserDamage, 0f, Projectile.owner, -1.5f); + if (laser.whoAmI.WithinBounds(Main.maxProjectiles)) + { + laser.DamageType = RogueDamageClass.Instance; + laser.scale *= 0.5f; + } + + for (int i = 0; i < 8; i++) + { + int sparkLifetime = Main.rand.Next(14, 21); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) + 1f * 0.05f; + Color sparkColor = Color.Lerp(Color.Fuchsia, Color.AliceBlue, Main.rand.NextFloat(0.5f)); + sparkColor = Color.Lerp(sparkColor, Color.Cyan, Main.rand.NextFloat()); + + if (Main.rand.NextBool(5)) + sparkScale *= 1.4f; + + Vector2 sparkVelocity = Projectile.DirectionTo(npc.Center).RotatedByRandom(MathHelper.TwoPi) * 5; + SparkParticle spark = new SparkParticle(Projectile.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + } + + private void StealthStrikeGrind(float spinDir) + { + // Spin extra fast to visually shred the enemy. + Projectile.rotation += spinDir * RotationIncrement * 0.8f; + + // Randomly fire lasers while grinding. + randomLaserCharge += Main.rand.NextFloat(0.09f, 0.14f); + if (randomLaserCharge >= 1f) + { + randomLaserCharge -= 1f; + Vector2 velocity = Vector2.UnitX.RotatedBy(Projectile.timeLeft / 120f * MathHelper.TwoPi); + + int laserDamage = (int)(Projectile.damage * 0.2f); + Projectile laser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), laserDamage, 0f, Projectile.owner, 1.5f,0,2); + if (laser.whoAmI.WithinBounds(Main.maxProjectiles)) + { + laser.DamageType = RogueDamageClass.Instance; + } + } + + // Stay stuck to the target. + Projectile.StickyProjAI(6, true); + + // If still attached to a target, do nothing. + if (Projectile.ai[0] != 0f) + return; + + // If the target died, look for a new one. + const float turnSpeed = 30f; + const float speedMult = 5f; + const float homingRange = 600f; + NPC uDie = Projectile.Center.ClosestNPCAt(homingRange, true, true); + if (uDie != null) + { + Vector2 distNorm = (uDie.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); + Projectile.velocity = (Projectile.velocity * (turnSpeed - 1f) + distNorm * speedMult) / turnSpeed; + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + + // Spawn sparks; taken from Despair stone then adapted to a projectile + Vector2 particleSpawnDisplacement; + Vector2 splatterDirection; + + particleSpawnDisplacement = new Vector2(2f * -Projectile.ai[2], 2f * -Projectile.ai[2]); + splatterDirection = new Vector2(Projectile.velocity.X, Projectile.velocity.Y); + + Vector2 SparkSpawnPosition = target.Center + particleSpawnDisplacement; + + if (Projectile.ai[1] % 4 == 0) + { + for (int i = 0; i < 2; i++) + { + int sparkLifetime = Main.rand.Next(14, 21); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) + 1f * 0.05f; + Color sparkColor = Color.Lerp(Color.Fuchsia, Color.AliceBlue, Main.rand.NextFloat(0.5f)); + sparkColor = Color.Lerp(sparkColor, Color.Cyan, Main.rand.NextFloat()); + + if (Main.rand.NextBool(5)) + sparkScale *= 1.4f; + + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(MathHelper.TwoPi); + sparkVelocity.Y -= 6f; + SparkParticle spark = new SparkParticle(SparkSpawnPosition, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } + + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // Non-stealth strikes do not stick on hit. + if (!Projectile.Calamity().stealthStrike) + return; + + // On the first frame of impact, slow down massively so it'll effectively stay stuck to an enemy. + if (Projectile.ai[0] == 0f && Projectile.ai[1] == 0f) + { + Projectile.timeLeft = StealthExtraLifetime; + Projectile.velocity *= 0.1f; + + // Provide a fixed amount of grind time so that DPS can't vary wildly. + Projectile.timeLeft = 90; + } + + // Apply sticky AI. + Projectile.ModifyHitNPCSticky(3); + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor); + return false; + } + + public override void PostDraw(Color lightColor) + { + Vector2 origin = new Vector2(31f, 29f); + Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Items/Weapons/Rogue/DimensionTearingDiskGlow").Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, 1f, SpriteEffects.None, 0); + } + } +} diff --git a/Projectiles/Rogue/DoomsdayDeviceProjectile.cs b/Projectiles/Rogue/DoomsdayDeviceProjectile.cs index cd6fc21372..265b3e9638 100644 --- a/Projectiles/Rogue/DoomsdayDeviceProjectile.cs +++ b/Projectiles/Rogue/DoomsdayDeviceProjectile.cs @@ -1,7 +1,10 @@ using System; using System.Collections.Generic; using CalamityMod.Dusts; +using CalamityMod.NPCs; +using CalamityMod.NPCs.Ravager; using CalamityMod.Particles; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -10,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class DoomsdayDeviceProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -29,6 +33,8 @@ namespace CalamityMod.Projectiles.Rogue public int maxStealthHits = 5; // How many bounces the stealth strike has. This does not include the inital and final hit, so be sure to take those into account if you adjust this. public Color mainColor = Color.White; + public Color c1 = Color.Turquoise; + public Color c2 = Color.Orchid; public NPC lastHitTarget; public override void SetDefaults() @@ -53,8 +59,8 @@ namespace CalamityMod.Projectiles.Rogue float rate = (Main.GlobalTimeWrappedHourly * 6); List eColors = new List() { - Color.Turquoise, - Color.Orchid + c1, + c2 }; int colorIndex = (int)(rate / 2 % eColors.Count); Color currentColor = eColors[colorIndex]; @@ -185,7 +191,7 @@ namespace CalamityMod.Projectiles.Rogue c.velocity = (MathHelper.TwoPi * i / 12f).ToRotationVector2().RotatedBy(Projectile.rotation) * 5.5f * (i % 2 == 0 ? 0.8f : 1f); c.scale = 0.7f * (i % 2 == 0 ? 2.2f : 1.8f); c.noGravity = true; - c.color = i % 2 == 0 ? Color.Turquoise : Color.Orchid; + c.color = i % 2 == 0 ? c1 : c2; c.noLightEmittence = true; } @@ -235,7 +241,7 @@ namespace CalamityMod.Projectiles.Rogue { float finalHitMult = 1; // If it is the last hit of a stealth strike, this is increased. - if (Projectile.Calamity().stealthStrike && !doneHitting) // Stealth strike bounce code, TODO: port this over to Pulse Rifle/Pusle Pistol because this is just a more functional version of theirs. + if (Projectile.Calamity().stealthStrike && !doneHitting) // Stealth strike bounce code { NPC chosenTarget = null; float distance = 2500; @@ -300,15 +306,15 @@ namespace CalamityMod.Projectiles.Rogue dust2.scale = Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance); dust2.velocity = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5 * charge).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)) * finalHitMult; dust2.noGravity = true; - dust2.color = Main.rand.NextBool() ? Color.Turquoise : Color.Orchid; + dust2.color = Main.rand.NextBool() ? c1 : c2; } - Particle pulse = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.2f, Color.Turquoise * 0.85f, new Vector2(3f, 1f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); + Particle pulse = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.2f, c1 * 0.85f, new Vector2(3f, 1f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 2.5f, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.175f * finalHitMult, Color.Orchid * 0.7f, new Vector2(2.5f, 2f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); + Particle pulse2 = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 2.5f, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.175f * finalHitMult, c2 * 0.7f, new Vector2(2.5f, 2f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); GeneralParticleHandler.SpawnParticle(pulse2); - Owner.Calamity().GeneralScreenShakePower = 3; + Owner.SetScreenshake(3f); } else // If there's no targets other than the currently hit one or the projectile is out of bounces, deal the final stronger blow. { @@ -343,7 +349,7 @@ namespace CalamityMod.Projectiles.Rogue giveStealth = false; } - Owner.Calamity().GeneralScreenShakePower = charge * (hasReachedFullCharge ? 1.2f : 0.8f) * finalHitMult; + Owner.SetScreenshake(charge * (hasReachedFullCharge ? 1.2f : 0.8f) * finalHitMult); for (int i = 0; i <= 12 * finalHitMult; i++) { @@ -353,7 +359,7 @@ namespace CalamityMod.Projectiles.Rogue dust2.scale = Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance); dust2.velocity = (launchDir * 5 * charge).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)) * finalHitMult; dust2.noGravity = true; - dust2.color = Main.rand.NextBool() ? Color.Turquoise : Color.Orchid; + dust2.color = Main.rand.NextBool() ? c1 : c2; } if (hasReachedFullCharge) @@ -361,9 +367,9 @@ namespace CalamityMod.Projectiles.Rogue SoundStyle soundExtra = new("CalamityMod/Sounds/Item/DoomsdayDeviceImpact"); SoundEngine.PlaySound(soundExtra with { Volume = 1f, Pitch = 0.35f + extraPitch, MaxInstances = 6 }, Projectile.Center); - Particle pulse = new CustomSpark(Projectile.Center, -launchDir * 3, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.4f * finalHitMult, Color.Turquoise * 0.85f, new Vector2(3f, 1f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); + Particle pulse = new CustomSpark(Projectile.Center, -launchDir * 3, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.4f * finalHitMult, c1 * 0.85f, new Vector2(3f, 1f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); GeneralParticleHandler.SpawnParticle(pulse); - Particle pulse2 = new CustomSpark(Projectile.Center, -launchDir * 2.5f, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.35f * finalHitMult, Color.Orchid * 0.7f, new Vector2(2.5f, 2f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); + Particle pulse2 = new CustomSpark(Projectile.Center, -launchDir * 2.5f, "CalamityMod/Particles/HollowCircleSoftEdge", false, 14, 0.35f * finalHitMult, c2 * 0.7f, new Vector2(2.5f, 2f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); GeneralParticleHandler.SpawnParticle(pulse2); } SoundStyle sound = new("CalamityMod/Sounds/Item/DoomsdayDeviceImpact"); @@ -395,9 +401,9 @@ namespace CalamityMod.Projectiles.Rogue hasReachedFullCharge = false; if (tileHits == 0) { - SoundStyle sound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3); + SoundStyle sound = CommonCalamitySounds.VoidstoneMine with { Volume = 1 }; SoundEngine.PlaySound(sound with { Volume = 0.3f, Pitch = -0.55f, MaxInstances = 6 }, Projectile.Center); - SoundStyle sound2 = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit", 3); + SoundStyle sound2 = RockPillar.HitSound; SoundEngine.PlaySound(sound2 with { Volume = 0.4f, Pitch = -0.2f, MaxInstances = 6 }, Projectile.Center); } tileHits++; diff --git a/Projectiles/Rogue/DragonScalesInfernado.cs b/Projectiles/Rogue/DragonScalesInfernado.cs index f30b9462d4..5c4406da9c 100644 --- a/Projectiles/Rogue/DragonScalesInfernado.cs +++ b/Projectiles/Rogue/DragonScalesInfernado.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/DuststormCloud.cs b/Projectiles/Rogue/DuststormCloud.cs index be9d2ec200..40e64aea72 100644 --- a/Projectiles/Rogue/DuststormCloud.cs +++ b/Projectiles/Rogue/DuststormCloud.cs @@ -1,5 +1,6 @@ using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Rogue { public class DuststormCloud : ModProjectile, ILocalizedModType diff --git a/Projectiles/Rogue/DuststormCloudHitbox.cs b/Projectiles/Rogue/DuststormCloudHitbox.cs index 9629e274f1..a8e02d7678 100644 --- a/Projectiles/Rogue/DuststormCloudHitbox.cs +++ b/Projectiles/Rogue/DuststormCloudHitbox.cs @@ -1,14 +1,11 @@ -using System; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; -using Terraria.Utilities; namespace CalamityMod.Projectiles.Rogue { + [PierceResistExceptionAttribute(true)] public class DuststormCloudHitbox : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -25,15 +22,15 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = DuststormInABottle.CloudLifetime; Projectile.DamageType = RogueDamageClass.Instance; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.idStaticNPCHitCooldown = 12; } public override void AI() { if (Projectile.scale < (Projectile.ai[1] == 1 ? DuststormInABottle.MaxSizeStealth : DuststormInABottle.MaxSize)) { - Projectile.scale += (Projectile.ai[1] == 1 ? DuststormInABottle.StealthGrowhRate : DuststormInABottle.GrowthRate); - Projectile.ExpandHitboxBy(1 + (Projectile.ai[1] == 1 ? DuststormInABottle.StealthGrowhRate : DuststormInABottle.GrowthRate)); + Projectile.scale += Projectile.ai[1] == 1 ? DuststormInABottle.StealthGrowthRate : DuststormInABottle.GrowthRate; + Projectile.ExpandHitboxBy(1 + (Projectile.ai[1] == 1 ? DuststormInABottle.StealthGrowthRate : DuststormInABottle.GrowthRate)); } } diff --git a/Projectiles/Rogue/DuststormInABottleProj.cs b/Projectiles/Rogue/DuststormInABottleProj.cs index 7a012612b4..61d51c1462 100644 --- a/Projectiles/Rogue/DuststormInABottleProj.cs +++ b/Projectiles/Rogue/DuststormInABottleProj.cs @@ -68,11 +68,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, stealth ? velocity * 1.2f : velocity, ModContent.ProjectileType(), 0, 0, Projectile.owner, stealth ? 1f : 0f, (float)Main.rand.Next(-45, 1)); } int hitbox = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 0.5f, Projectile.owner); - if (hitbox.WithinBounds(Main.maxProjectiles) && Projectile.Calamity().stealthStrike) //Inherit stealth flag and less iframes - { + if (hitbox.WithinBounds(Main.maxProjectiles) && Projectile.Calamity().stealthStrike) //Inherit stealth flag Main.projectile[hitbox].ai[1] = 1; - Main.projectile[hitbox].idStaticNPCHitCooldown = DuststormInABottle.StealthIframes; - } } } } diff --git a/Projectiles/Rogue/DynamicPursuerElectricity.cs b/Projectiles/Rogue/DynamicPursuerElectricity.cs index 9e44160aad..ef448cef63 100644 --- a/Projectiles/Rogue/DynamicPursuerElectricity.cs +++ b/Projectiles/Rogue/DynamicPursuerElectricity.cs @@ -43,6 +43,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.extraUpdates = 10; Projectile.timeLeft = 60 * Projectile.extraUpdates; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; // Readjust the velocity magnitude the moment this projectile is created // to make velocity setting outside the scope of this projectile less irritating @@ -112,19 +114,19 @@ namespace CalamityMod.Projectiles.Rogue } } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float baseWidth = MathHelper.Lerp(4f, 7f, (float)Math.Sin(MathHelper.Pi * 4f * completionRatio) * 0.5f + 0.5f) * Projectile.scale; return baseWidth * (float)Math.Sin(MathHelper.Pi * completionRatio); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { Color baseColor = Color.Lerp(Color.Blue, Color.LightSteelBlue, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); return Color.Lerp(baseColor, Color.LightBlue, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f) * 0.8f); } public override bool PreDraw(ref Color lightColor) { - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, false), 90); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, false), 90); return false; } } diff --git a/Projectiles/Rogue/DynamicPursuerProjectile.cs b/Projectiles/Rogue/DynamicPursuerProjectile.cs index 132302e852..5875f71472 100644 --- a/Projectiles/Rogue/DynamicPursuerProjectile.cs +++ b/Projectiles/Rogue/DynamicPursuerProjectile.cs @@ -1,7 +1,4 @@ using System; -using System.CodeDom; -using System.Collections.Generic; -using System.Linq; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Sounds; diff --git a/Projectiles/Rogue/EclipsesFallMain.cs b/Projectiles/Rogue/EclipsesFallMain.cs index 3448ed80af..acae2f710c 100644 --- a/Projectiles/Rogue/EclipsesFallMain.cs +++ b/Projectiles/Rogue/EclipsesFallMain.cs @@ -49,18 +49,17 @@ namespace CalamityMod.Projectiles.Rogue } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => SpawnSpears(target.Center); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => SpawnSpears(target); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => SpawnSpears(target); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => SpawnSpears(target.Center); - - private void SpawnSpears(Vector2 targetPos) + private void SpawnSpears(Entity target) { int spearAmt = Main.rand.Next(3, 4 + 1); // 3 or 4 spears - var source = Projectile.GetSource_FromThis(); for (int n = 0; n < spearAmt; n++) { - ; - CalamityUtils.ProjectileRain(source, targetPos, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(Projectile.damage * RainDamageMult), Projectile.knockBack * RainDamageMult, Projectile.owner); + Vector2 spawnPos = target.Center - new Vector2(Main.rand.NextFloat(-100f, 100f), Main.rand.NextFloat(500f, 800f)); + Vector2 spearVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(spawnPos, target, 29f, 2) + Vector2.UnitX * Main.rand.NextFloat(-6f, 6f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPos, spearVel, ModContent.ProjectileType(), (int)(Projectile.damage * RainDamageMult), Projectile.knockBack * RainDamageMult, Projectile.owner); } } diff --git a/Projectiles/Rogue/EclipsesStealth.cs b/Projectiles/Rogue/EclipsesStealth.cs index 2ea50cc720..bdf017b9f2 100644 --- a/Projectiles/Rogue/EclipsesStealth.cs +++ b/Projectiles/Rogue/EclipsesStealth.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.NPCs; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class EclipsesStealth : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -17,8 +19,6 @@ namespace CalamityMod.Projectiles.Rogue public const float RainDamageMult = 0.2f; public const float ExplosionDamageMult = 0.5f; - // For more consistent DPS, always alternates between spawning 1 and 2 spears instead of picking randomly - private bool spawnTwoSpears = true; private bool changedTimeLeft = false; public override void SetStaticDefaults() @@ -75,19 +75,15 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.owner == Main.myPlayer) { Projectile.localAI[1] -= 1f; - - var source = Projectile.GetSource_FromThis(); if (Projectile.localAI[1] <= 0f) { // Set up the spear counter for next time. Used to be every 5 frames there was a 50% chance; now it's more reliable but slower. - Projectile.localAI[1] = Main.rand.Next(10, 13); // 10 to 12 frames between each spearfall + Projectile.localAI[1] = Main.rand.Next(8, 10+1); // 8 to 10 frames between each spearfall int type = ModContent.ProjectileType(); - // Used to be a 50% chance each spearfall for 1 or 2. Now is consistent. - int numSpears = spawnTwoSpears ? 2 : 1; - spawnTwoSpears = !spawnTwoSpears; - for (int i = 0; i < numSpears; ++i) - CalamityUtils.ProjectileRain(source, Projectile.Center, 400f, 100f, 500f, 800f, 29f, type, (int)(Projectile.damage * RainDamageMult), Projectile.knockBack * RainDamageMult, Projectile.owner); + Vector2 spawnPos = Projectile.Center - new Vector2(Main.rand.NextFloat(-100f, 100f), Main.rand.NextFloat(500f, 800f)); + Vector2 spearVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(spawnPos, Main.npc[(int)Projectile.ai[1]], 29f, 2) + Vector2.UnitX * Main.rand.NextFloat(-6f, 6f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPos, spearVel, type, (int)(Projectile.damage * RainDamageMult), Projectile.knockBack * RainDamageMult, Projectile.owner); } } } diff --git a/Projectiles/Rogue/EquanimityLightShard.cs b/Projectiles/Rogue/EquanimityLightShard.cs index 08d2cd1b20..5d5de62d7c 100644 --- a/Projectiles/Rogue/EquanimityLightShard.cs +++ b/Projectiles/Rogue/EquanimityLightShard.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Rogue/EquanimityProj.cs b/Projectiles/Rogue/EquanimityProj.cs index 6ca0713e32..506b636594 100644 --- a/Projectiles/Rogue/EquanimityProj.cs +++ b/Projectiles/Rogue/EquanimityProj.cs @@ -1,12 +1,10 @@ -using CalamityMod.Projectiles.Melee; -using System; +using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; -using System.Collections.Generic; using CalamityMod.Particles; using CalamityMod.Items.Weapons.Typeless; using CalamityMod.Items.Weapons.Ranged; @@ -37,6 +35,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 46; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.penetrate = -1; Projectile.timeLeft = Lifetime + ChargeupTime; Projectile.usesLocalNPCImmunity = true; @@ -91,7 +90,6 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.DD2_GoblinBomberThrow, Projectile.Center); Projectile.Center = Owner.MountedCenter + Projectile.velocity * 12f; Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 17.5f; - Projectile.tileCollide = true; } Projectile.rotation += (MathHelper.PiOver4 / 4f + MathHelper.PiOver4 / 2f * Math.Clamp(ThrowProgress * 2f, 0, 1)) * Math.Sign(Projectile.velocity.X); @@ -128,7 +126,6 @@ namespace CalamityMod.Projectiles.Rogue if (Returning == 1f) { - Projectile.tileCollide = false; //Aim back at the player Projectile.velocity = Projectile.velocity.Length() * (Owner.MountedCenter - Projectile.Center).SafeNormalize(Vector2.One); @@ -287,12 +284,5 @@ namespace CalamityMod.Projectiles.Rogue Bouncing = 2f; } } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.velocity = Projectile.oldVelocity.Length() * 0.3f * (Owner.MountedCenter - Projectile.Center).SafeNormalize(Vector2.One); - Returning = 1f; - return false; - } } } diff --git a/Projectiles/Rogue/EradicatorProjectile.cs b/Projectiles/Rogue/EradicatorProjectile.cs deleted file mode 100644 index 6c32ebf15d..0000000000 --- a/Projectiles/Rogue/EradicatorProjectile.cs +++ /dev/null @@ -1,240 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class EradicatorProjectile : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/Eradicator"; - private static float RotationIncrement = 0.15f; - private static int Lifetime = 350; - public static int StealthExtraLifetime = 240; // 1 extra update means this is double what you'd expect for 2 seconds - private static int ReboundTime = 60; - - private float randomLaserCharge = 0f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 6; - ProjectileID.Sets.TrailingMode[Type] = 2; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 62; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.MaxUpdates = 2; - Projectile.timeLeft = Lifetime; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 18; - Projectile.DamageType = RogueDamageClass.Instance; - } - - public override void AI() - { - // - // Boomerang AI copied from Nanoblack Reaper - // - - // On the frame the disc begins returning, send a net update. - if (Projectile.timeLeft == Lifetime - ReboundTime) - Projectile.netUpdate = true; - - // The disc runs its returning AI if it has existed longer than ReboundTime frames. - if (Projectile.timeLeft <= Lifetime - ReboundTime) - { - float returnSpeed = Eradicator.Speed * 1.3f; - float acceleration = 0.25f; - Player owner = Main.player[Projectile.owner]; - - // Delete the disc if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - Projectile.Center.X; - float yDist = playerCenter.Y - Projectile.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (dist > 3000f) - Projectile.Kill(); - - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; - - // Home back in on the player. - if (Projectile.velocity.X < xDist) - { - Projectile.velocity.X = Projectile.velocity.X + acceleration; - if (Projectile.velocity.X < 0f && xDist > 0f) - Projectile.velocity.X += acceleration; - } - else if (Projectile.velocity.X > xDist) - { - Projectile.velocity.X = Projectile.velocity.X - acceleration; - if (Projectile.velocity.X > 0f && xDist < 0f) - Projectile.velocity.X -= acceleration; - } - if (Projectile.velocity.Y < yDist) - { - Projectile.velocity.Y = Projectile.velocity.Y + acceleration; - if (Projectile.velocity.Y < 0f && yDist > 0f) - Projectile.velocity.Y += acceleration; - } - else if (Projectile.velocity.Y > yDist) - { - Projectile.velocity.Y = Projectile.velocity.Y - acceleration; - if (Projectile.velocity.Y > 0f && yDist < 0f) - Projectile.velocity.Y -= acceleration; - } - - // Delete the projectile if it touches its owner. - if (Main.myPlayer == Projectile.owner) - if (Projectile.Hitbox.Intersects(owner.Hitbox)) - Projectile.Kill(); - } - - // Lighting. - Lighting.AddLight(Projectile.Center, 0.35f, 0f, 0.25f); - - // Rotate the disc as it flies. - float spin = Projectile.direction <= 0 ? -1f : 1f; - Projectile.rotation += spin * RotationIncrement; - - // If attached to something (this only occurs for stealth strikes), do the buzzsaw grind and spam lasers everywhere. - if (Projectile.ai[0] == 1f) - StealthStrikeGrind(spin); - else - { - // Fire lasers at up to 2 nearby targets every 8 frames for 40% damage. - // Stealth strike lasers have an intentionally lower ratio of 12%. - double laserDamageRatio = Projectile.Calamity().stealthStrike ? 0.15D : 0.4D; - float laserFrames = Projectile.MaxUpdates * 8f; - CalamityUtils.MagnetSphereHitscan(Projectile, 300f, 6f, laserFrames, 2, ModContent.ProjectileType(), laserDamageRatio, true, Projectile.DamageType); - } - } - - private void StealthStrikeGrind(float spinDir) - { - // Spin extra fast to visually shred the enemy. - Projectile.rotation += spinDir * RotationIncrement * 0.8f; - - // Randomly fire lasers while grinding. Each laser only does 12% damage. - randomLaserCharge += Main.rand.NextFloat(0.09f, 0.14f); - if (randomLaserCharge >= 1f) - { - randomLaserCharge -= 1f; - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - - int laserDamage = (int)(Projectile.damage * 0.12D); - Projectile laser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), laserDamage, 0f, Projectile.owner); - if (laser.whoAmI.WithinBounds(Main.maxProjectiles)) - { - laser.DamageType = RogueDamageClass.Instance; - laser.aiStyle = Main.rand.NextBool() ? ProjAIStyleID.Arrow : -1; - laser.penetrate = -1; - laser.usesLocalNPCImmunity = true; - - // This projectile has a hefty amount of extra updates, which will influence the hit cooldown. - laser.localNPCHitCooldown = 120; - } - } - - // Stay stuck to the target. - Projectile.StickyProjAI(6, true); - - // If still attached to a target, do nothing. - if (Projectile.ai[0] != 0f) - return; - - // If the target died, look for a new one. - const float turnSpeed = 30f; - const float speedMult = 5f; - const float homingRange = 600f; - NPC uDie = Projectile.Center.ClosestNPCAt(homingRange, true, true); - if (uDie != null) - { - Vector2 distNorm = (uDie.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); - Projectile.velocity = (Projectile.velocity * (turnSpeed - 1f) + distNorm * speedMult) / turnSpeed; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - - // Spawn sparks; taken from Despair stone then adapted to a projectile - Vector2 particleSpawnDisplacement; - Vector2 splatterDirection; - - particleSpawnDisplacement = new Vector2(2f * -Projectile.ai[2], 2f * -Projectile.ai[2]); - splatterDirection = new Vector2(Projectile.velocity.X, Projectile.velocity.Y); - - Vector2 SparkSpawnPosition = target.Center + particleSpawnDisplacement; - - if (Projectile.ai[1] % 4 == 0) - { - for (int i = 0; i < 2; i++) - { - int sparkLifetime = Main.rand.Next(14, 21); - float sparkScale = Main.rand.NextFloat(0.8f, 1f) + 1f * 0.05f; - Color sparkColor = Color.Lerp(Color.Fuchsia, Color.AliceBlue, Main.rand.NextFloat(0.5f)); - sparkColor = Color.Lerp(sparkColor, Color.Cyan, Main.rand.NextFloat()); - - if (Main.rand.NextBool(5)) - sparkScale *= 1.4f; - - Vector2 sparkVelocity = splatterDirection.RotatedByRandom(MathHelper.TwoPi); - sparkVelocity.Y -= 6f; - SparkParticle spark = new SparkParticle(SparkSpawnPosition, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); - GeneralParticleHandler.SpawnParticle(spark); - } - } - - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => OnHit(); - - private void OnHit() - { - // Non-stealth strikes do not stick on hit. - if (!Projectile.Calamity().stealthStrike) - return; - - // On the first frame of impact, slow down massively so it'll effectively stay stuck to an enemy. - if (Projectile.ai[0] == 0f && Projectile.ai[1] == 0f) - { - Projectile.velocity *= 0.1f; - - // Provide a fixed amount of grind time so that DPS can't vary wildly. - Projectile.timeLeft = 90; - } - - // Apply sticky AI. - Projectile.ModifyHitNPCSticky(3); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor); - return false; - } - - public override void PostDraw(Color lightColor) - { - Vector2 origin = new Vector2(31f, 29f); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Items/Weapons/Rogue/EradicatorGlow").Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, 1f, SpriteEffects.None, 0); - } - } -} diff --git a/Projectiles/Rogue/ExecutionersBladeProj.cs b/Projectiles/Rogue/ExecutionersBladeProj.cs index ae1c6226d1..0e373d855c 100644 --- a/Projectiles/Rogue/ExecutionersBladeProj.cs +++ b/Projectiles/Rogue/ExecutionersBladeProj.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.Item73, Projectile.Center); for (int i = 0; i < 20; i++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), new Vector2(position.X + (-600 + i * 60), position.Y - 800), new Vector2(0f, 2.5f), ModContent.ProjectileType(), Projectile.damage * 4, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), new Vector2(position.X + (-600 + i * 60), position.Y - 800), new Vector2(0f, 2.5f), ModContent.ProjectileType(), (int)(Projectile.damage * 2.4f), Projectile.knockBack, Projectile.owner); } } } diff --git a/Projectiles/Rogue/ExorcismProj.cs b/Projectiles/Rogue/ExorcismProj.cs index 86102bdd3f..86e4795ad8 100644 --- a/Projectiles/Rogue/ExorcismProj.cs +++ b/Projectiles/Rogue/ExorcismProj.cs @@ -163,11 +163,12 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.velocity.Length() < storedStealthVel.Length()) Projectile.velocity += Utils.DirectionTo(Projectile.Center, Owner.Center) * 0.1f; Projectile.velocity *= 0.99f; - if (time == 180) // Reset iframes when it starts to come back + // CIT 26JUN2025: Removing its ability to deal damage again because it's overpowered + /*if (time == 180) { for (int i = 0; i < Main.maxNPCs; i++) Projectile.localNPCImmunity[i] = 0; - } + }*/ if (Projectile.timeLeft <= 240) { impaleDist = Vector2.One; // This is so the projectile stops dealing damage @@ -319,7 +320,7 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(sound with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0.15f, 0.25f) }, Projectile.Center); SoundStyle sound2 = new("CalamityMod/Sounds/NPCHit/ExoHit3"); SoundEngine.PlaySound(sound2 with { Volume = 0.5f, Pitch = Main.rand.NextFloat(-0.1f, 0f) }, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = 5.5f; + Owner.SetScreenshake(5.5f); Projectile.timeLeft = 300; targeted = target; impaleDist = (Projectile.Center - targeted.Center); @@ -344,13 +345,13 @@ namespace CalamityMod.Projectiles.Rogue searchedTarget.active = false; } - SoundStyle gfb = new("CalamityMod/Sounds/Item/HolyBurst"); - for (int i = 0; i < 7; i++) - SoundEngine.PlaySound(gfb with { Volume = 1f, Pitch = 0.2f * i, MaxInstances = 7 }, Projectile.Center); + SoundStyle gong = new("CalamityMod/Sounds/Custom/GFB/Jesus"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(gong with { Volume = 1f, MaxInstances = 2 }, Projectile.Center); } else { - Owner.Calamity().GeneralScreenShakePower = 7f; + Owner.SetScreenshake(7f); SoundStyle soundBurst = new("CalamityMod/Sounds/Item/HolyBurst"); for (int i = 0; i < 3; i++) SoundEngine.PlaySound(soundBurst with { Volume = 0.8f, Pitch = 0.2f * i, MaxInstances = 3 }, Projectile.Center); diff --git a/Projectiles/Rogue/ExorcismShockwave.cs b/Projectiles/Rogue/ExorcismShockwave.cs index 40234674e5..25e1abd09a 100644 --- a/Projectiles/Rogue/ExorcismShockwave.cs +++ b/Projectiles/Rogue/ExorcismShockwave.cs @@ -1,13 +1,8 @@ -using CalamityMod.NPCs.Yharon; -using CalamityMod.UI; -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.ModLoader; -using System.Text.RegularExpressions; namespace CalamityMod.Projectiles.Rogue { diff --git a/Projectiles/Rogue/FantasyTalismanProj.cs b/Projectiles/Rogue/FantasyTalismanProj.cs index ccbb12405c..382f3e0603 100644 --- a/Projectiles/Rogue/FantasyTalismanProj.cs +++ b/Projectiles/Rogue/FantasyTalismanProj.cs @@ -1,10 +1,12 @@ -using Microsoft.Xna.Framework; +using CalamityMod.NPCs; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class FantasyTalismanProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -41,16 +43,13 @@ namespace CalamityMod.Projectiles.Rogue Projectile.StickyProjAI(4); if (Projectile.ai[0] == 1f) { - if (Projectile.timeLeft % 10 == 0) + if (Projectile.timeLeft % 40 == 0) { - if (Main.rand.NextBool(8)) + Projectile ghost = CalamityUtils.SpawnOrb(Projectile, (int)(Projectile.damage * 0.3f), ProjectileID.SpectreWrath, 1000f, 4f); + if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) { - Projectile ghost = CalamityUtils.SpawnOrb(Projectile, (int)(Projectile.damage * 0.4f), ProjectileID.SpectreWrath, 1000f, 4f); - if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) - { - ghost.DamageType = RogueDamageClass.Instance; - ghost.penetrate = 1; - } + ghost.DamageType = RogueDamageClass.Instance; + ghost.penetrate = 1; } } } @@ -62,7 +61,7 @@ namespace CalamityMod.Projectiles.Rogue return false; } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(12); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(9); public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { diff --git a/Projectiles/Rogue/FantasyTalismanStealth.cs b/Projectiles/Rogue/FantasyTalismanStealth.cs index c15729eb34..35b90af917 100644 --- a/Projectiles/Rogue/FantasyTalismanStealth.cs +++ b/Projectiles/Rogue/FantasyTalismanStealth.cs @@ -1,10 +1,12 @@ -using Microsoft.Xna.Framework; +using CalamityMod.NPCs; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class FantasyTalismanStealth : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -43,16 +45,13 @@ namespace CalamityMod.Projectiles.Rogue Projectile.StickyProjAI(4); if (Projectile.ai[0] == 1f) { - if (Projectile.timeLeft % 4 == 0) + if (Projectile.timeLeft % 20 == 0) { - if (Main.rand.NextBool(3)) + Projectile ghost = CalamityUtils.SpawnOrb(Projectile, (int)(Projectile.damage * 0.3f), ProjectileID.SpectreWrath, 1000f, 4f); + if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) { - Projectile ghost = CalamityUtils.SpawnOrb(Projectile, (int)(Projectile.damage * 0.2f), ProjectileID.SpectreWrath, 1000f, 4f); - if (ghost.whoAmI.WithinBounds(Main.maxProjectiles)) - { - ghost.DamageType = RogueDamageClass.Instance; - ghost.penetrate = 1; - } + ghost.DamageType = RogueDamageClass.Instance; + ghost.penetrate = 1; } } } @@ -64,7 +63,7 @@ namespace CalamityMod.Projectiles.Rogue return false; } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(9); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(6); public override void OnKill(int timeLeft) { @@ -72,7 +71,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int j = 0; j <= 3; j++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(12f, 12f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(12f, 12f), ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Rogue/FeatherKnifeProjectile.cs b/Projectiles/Rogue/FeatherKnifeProjectile.cs index 1c454320dd..7589b9ce5b 100644 --- a/Projectiles/Rogue/FeatherKnifeProjectile.cs +++ b/Projectiles/Rogue/FeatherKnifeProjectile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Projectiles.Typeless; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/FinalDawnFireSlash.cs b/Projectiles/Rogue/FinalDawnFireSlash.cs index bfd59add8c..00542724da 100644 --- a/Projectiles/Rogue/FinalDawnFireSlash.cs +++ b/Projectiles/Rogue/FinalDawnFireSlash.cs @@ -5,7 +5,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs index 1f03f7c82b..4dc73b70fd 100644 --- a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs +++ b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/FishboneBoomerangProjectile.cs b/Projectiles/Rogue/FishboneBoomerangProjectile.cs index bfe0172d80..a3f8d570f9 100644 --- a/Projectiles/Rogue/FishboneBoomerangProjectile.cs +++ b/Projectiles/Rogue/FishboneBoomerangProjectile.cs @@ -116,7 +116,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 2; i++) { Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 14f; - Dust dust = Dust.NewDustPerfect(dustPos, 176, (i * MathHelper.Pi + Projectile.rotation * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 3f); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.BubbleBurst_Blue, (i * MathHelper.Pi + Projectile.rotation * Math.Sign(Projectile.velocity.X)).ToRotationVector2() * 3f); dust.noGravity = true; } @@ -151,7 +151,7 @@ namespace CalamityMod.Projectiles.Rogue for (int j = 0; j < 4; j++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + streakRotation.ToRotationVector2() * (2f + 0.4f * j), 176, streakRotation.ToRotationVector2() * (0.6f * j + 3f), Scale: 1.4f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + streakRotation.ToRotationVector2() * (2f + 0.4f * j), DustID.BubbleBurst_Blue, streakRotation.ToRotationVector2() * (0.6f * j + 3f), Scale: 1.4f); dust.noGravity = true; } } diff --git a/Projectiles/Rogue/FrostyFlareProj.cs b/Projectiles/Rogue/FrostyFlareProj.cs index f101b2cb23..2f812635cf 100644 --- a/Projectiles/Rogue/FrostyFlareProj.cs +++ b/Projectiles/Rogue/FrostyFlareProj.cs @@ -20,6 +20,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = -1; Projectile.timeLeft = 300; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -42,17 +44,18 @@ namespace CalamityMod.Projectiles.Rogue if (shoot) { - Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); - Vector2 pos = Projectile.Center - vel; - vel.X += Main.rand.Next(-50, 51); - vel.Normalize(); - vel *= 30f; - int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Projectile.velocity / 4f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Vector2 pos = Projectile.Center - new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 751)); + Vector2 vel = Utils.DirectionTo(pos, Projectile.Center) * 30f; + vel.X += Main.rand.NextFloat(-4f, 4f); + int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Projectile.velocity / 4f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack, Projectile.owner); Main.projectile[shard].alpha = Projectile.alpha; } int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonWater); Main.dust[index2].noGravity = true; + + if (Projectile.ai[2] == 1f) + CalamityUtils.HomeInOnSelectedNPC(Projectile, CalamityUtils.ClosestNPCAt(Projectile.Center, 400f, false), false, 5f, 30f, 0.99f); } else { @@ -66,12 +69,10 @@ namespace CalamityMod.Projectiles.Rogue if (shoot) { - Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); - Vector2 pos = Main.npc[id].Center - vel; - vel.X += Main.rand.Next(-50, 51); - vel.Normalize(); - vel *= 30f; - int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Main.npc[id].velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Vector2 pos = Projectile.Center - new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 751)); + Vector2 vel = Utils.DirectionTo(pos, Projectile.Center) * 30f; + vel.X += Main.rand.NextFloat(-4f, 4f); + int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Main.npc[id].velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack, Projectile.owner); Main.projectile[shard].alpha = Projectile.alpha; } } @@ -119,7 +120,6 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(BuffID.Frostburn2, 180); - target.AddBuff(ModContent.BuffType(), 30); } public override bool? CanDamage() => Projectile.ai[0] == 0f ? null : false; diff --git a/Projectiles/Rogue/FrostyFlareStealth.cs b/Projectiles/Rogue/FrostyFlareStealth.cs index e485108463..09d88e9a77 100644 --- a/Projectiles/Rogue/FrostyFlareStealth.cs +++ b/Projectiles/Rogue/FrostyFlareStealth.cs @@ -20,6 +20,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = -1; Projectile.timeLeft = 300; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -42,23 +44,12 @@ namespace CalamityMod.Projectiles.Rogue if (shoot) { - Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); - Vector2 pos = Projectile.Center - vel; - vel.X += Main.rand.Next(-50, 51); - vel.Normalize(); - vel *= 30f; - int flare = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Projectile.velocity / 4f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Vector2 pos = Projectile.Center - new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); + Vector2 vel = Utils.DirectionTo(pos, Projectile.Center) * 30f; + vel.X += Main.rand.NextFloat(-4f, 4f); + int flare = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Projectile.velocity / 4f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6f), Projectile.knockBack, Projectile.owner, ai2: 1f); Main.projectile[flare].alpha = 150; } - if (Projectile.timeLeft % 10 == 0) - { - int snowflake = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Projectile.velocity.X * 0f, Projectile.velocity.Y * 0f, ProjectileID.NorthPoleSnowflake, (int)(Projectile.damage * 0.25), Projectile.knockBack, Projectile.owner, 0f, Main.rand.Next(3)); - if (snowflake.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[snowflake].DamageType = RogueDamageClass.Instance; - Main.projectile[snowflake].timeLeft = 300; - } - } int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.DungeonWater); Main.dust[index2].noGravity = true; @@ -75,12 +66,10 @@ namespace CalamityMod.Projectiles.Rogue if (shoot) { - Vector2 vel = new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 801)); - Vector2 pos = Main.npc[id].Center - vel; - vel.X += Main.rand.Next(-50, 51); - vel.Normalize(); - vel *= 30f; - int flare = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Main.npc[id].velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Vector2 pos = Projectile.Center - new Vector2(Main.rand.Next(-300, 301), Main.rand.Next(500, 751)); + Vector2 vel = CalamityUtils.CalculatePredictiveAimToTarget(pos, Main.npc[id], 30f); + vel.X += Main.rand.NextFloat(-4f, 4f); + int flare = Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, vel + Main.npc[id].velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6f), Projectile.knockBack, Projectile.owner, ai2: 1f); Main.projectile[flare].alpha = 150; } } @@ -128,7 +117,6 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(BuffID.Frostburn2, 180); - target.AddBuff(ModContent.BuffType(), 30); } public override bool? CanDamage() => Projectile.ai[0] == 0f ? null : false; diff --git a/Projectiles/Rogue/GelDartProjectile.cs b/Projectiles/Rogue/GelDartProjectile.cs index 79f2a0b1fb..c4bc7816ad 100644 --- a/Projectiles/Rogue/GelDartProjectile.cs +++ b/Projectiles/Rogue/GelDartProjectile.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Rogue/GildedDaggerProj.cs b/Projectiles/Rogue/GildedDaggerProj.cs index bafb14937a..9a13c9403b 100644 --- a/Projectiles/Rogue/GildedDaggerProj.cs +++ b/Projectiles/Rogue/GildedDaggerProj.cs @@ -23,6 +23,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = 2; Projectile.timeLeft = 600; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/GlaiveOrbital.cs b/Projectiles/Rogue/GlaiveOrbital.cs new file mode 100644 index 0000000000..bbf9278897 --- /dev/null +++ b/Projectiles/Rogue/GlaiveOrbital.cs @@ -0,0 +1,66 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class GlaiveOrbital : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Glaive"; + + private static int Lifetime = 300; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 3; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 136; + Projectile.height = 136; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 1; + Projectile.timeLeft = Lifetime; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + public override void AI() + { + Projectile.Center = Main.player[Projectile.owner].Center; + Projectile.rotation += 0.2f; Projectile.ai[0]++; + } + + public override bool PreDraw(ref Color lightColor) + { + float distance = MathHelper.Min(MathHelper.Lerp(0, 64, Projectile.ai[0] / 15f), 64f); + if (Projectile.timeLeft < 15) + { + distance = MathHelper.Lerp(0, 64, Projectile.timeLeft / 15f); + } + int glaiveCount = 3; + for (var i2 = 0; i2 < 5; i2++)//Afteriamges + { + for (var i = 0; i < glaiveCount; i++) + { + float glaiveRot = MathHelper.TwoPi * ((i / (float)glaiveCount)); + float opacity = i2 / 5f; + Main.spriteBatch.Draw(TextureAssets.Projectile[Type].Value, Projectile.Center + new Vector2(distance, 0).RotatedBy(Projectile.rotation + glaiveRot + (1f * i2 / 5f)) - Main.screenPosition, null, lightColor * opacity, Main.GlobalTimeWrappedHourly * -10, TextureAssets.Projectile[Type].Size() * 0.5f, 0.5f * opacity + 0.5f, 0, 1); ; + } + } + return false; + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.HitDirectionOverride = -target.DirectionTo(Main.player[Projectile.owner].Center).X.DirectionalSign(); + } + } +} diff --git a/Projectiles/Rogue/GlaiveProj.cs b/Projectiles/Rogue/GlaiveProj.cs index 5ba3bdc63f..d7d71f3de2 100644 --- a/Projectiles/Rogue/GlaiveProj.cs +++ b/Projectiles/Rogue/GlaiveProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Packets.Entities; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -14,7 +13,8 @@ namespace CalamityMod.Projectiles.Rogue public override string Texture => "CalamityMod/Items/Weapons/Rogue/Glaive"; private static int Lifetime = 180; - private static int ReboundTime = 45; + private int timeAlive => Lifetime - Projectile.timeLeft; + private bool hasHit = false; public override void SetStaticDefaults() { @@ -28,91 +28,27 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 16; Projectile.friendly = true; Projectile.tileCollide = true; - Projectile.penetrate = 3; + Projectile.penetrate = 4; + Projectile.MaxUpdates = 2; Projectile.timeLeft = Lifetime; DrawOffsetX = -10; Projectile.DamageType = RogueDamageClass.Instance; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - // ai[1] = 1 means that the projectile is a stealth strike, in which case it pierces infinitely. - if (Projectile.ai[1] == 1f) - Projectile.penetrate = Projectile.maxPenetrate = -1; + Projectile.rotation += 0.175f * Projectile.direction; - // Boomerang rotation - Projectile.rotation += 0.4f * (float)Projectile.direction; - - // Boomerang sound - if (Projectile.soundDelay == 0) + if (timeAlive == 0) { - Projectile.soundDelay = 8; - SoundEngine.PlaySound(SoundID.Item7, Projectile.position); - } - - // Returns after some number of frames in the air - if (Projectile.timeLeft < Lifetime - ReboundTime) - Projectile.ai[0] = 1f; - - if (Projectile.ai[0] != 0f) - { - Projectile.tileCollide = false; - - float returnSpeed = Glaive.Speed * 1.6f; - float acceleration = 1.4f; - - if (Projectile.ai[1] == 1f) + Projectile.localNPCHitCooldown = -1; + if (Projectile.Calamity().stealthStrike) { - returnSpeed *= Glaive.StealthSpeedMult; - acceleration *= Glaive.StealthSpeedMult; + Projectile.penetrate = -1; + Projectile.MaxUpdates++; } - - Player owner = Main.player[Projectile.owner]; - - // Delete the projectile if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - Projectile.Center.X; - float yDist = playerCenter.Y - Projectile.Center.Y; - float dist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (dist > 3000f) - Projectile.Kill(); - - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; - - // Home back in on the player. - if (Projectile.velocity.X < xDist) - { - Projectile.velocity.X += acceleration; - if (Projectile.velocity.X < 0f && xDist > 0f) - Projectile.velocity.X += acceleration; - } - else if (Projectile.velocity.X > xDist) - { - Projectile.velocity.X -= acceleration; - if (Projectile.velocity.X > 0f && xDist < 0f) - Projectile.velocity.X -= acceleration; - } - if (Projectile.velocity.Y < yDist) - { - Projectile.velocity.Y += acceleration; - if (Projectile.velocity.Y < 0f && yDist > 0f) - Projectile.velocity.Y += acceleration; - } - else if (Projectile.velocity.Y > yDist) - { - Projectile.velocity.Y -= acceleration; - if (Projectile.velocity.Y > 0f && yDist < 0f) - Projectile.velocity.Y -= acceleration; - } - - // Delete the projectile if it touches its owner. - if (Main.myPlayer == Projectile.owner) - if (Projectile.Hitbox.Intersects(owner.Hitbox)) - Projectile.Kill(); } } @@ -122,15 +58,49 @@ namespace CalamityMod.Projectiles.Rogue return false; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + void Ricochet() { - // After its last hit, starts returning instead of vanishing. Can pierce infinitely on the way back. - if (Projectile.penetrate == 1) + float maxDistance = 1000f; + float npcDistCompare = 1000f; + int index = -1; + foreach (NPC n in Main.ActiveNPCs) // Find an NPC to ricochet to { - Projectile.penetrate = -1; - Projectile.ai[0] = 1f; + if (!n.CanBeChasedBy(Projectile) || !Projectile.WithinRange(n.Center, maxDistance) || Projectile.localNPCImmunity[n.whoAmI] != 0) + continue; + + float currentNPCDist = Vector2.Distance(n.Center, Projectile.Center); + if ((currentNPCDist < npcDistCompare) && (Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1))) + { + npcDistCompare = currentNPCDist; + index = n.whoAmI; + } + } + + // If you find an NPC, ricochet in their direction and reset iframes for them + if (index != -1) + { + Projectile.ai[1] = index; + Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], Projectile.velocity.Length(), Projectile.MaxUpdates); + Projectile.netUpdate = true; } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.Calamity().stealthStrike) + { + if (!hasHit) + { + target.Calamity().glaiveShredTimer += 300; + + // Shred must be synced, because OnHitNPC is only run for the client that hit the NPC + if (Main.netMode != NetmodeID.SinglePlayer) + GlaiveShredPacket.Send(target); + } + hasHit = true; + } + Ricochet(); + } + // Make it bounce on tiles. public override bool OnTileCollide(Vector2 oldVelocity) @@ -147,7 +117,9 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.velocity.Y = -oldVelocity.Y; } - Projectile.ai[0] = 1f; + Ricochet(); + if (Projectile.penetrate > 0) + Projectile.penetrate--; return false; } } diff --git a/Projectiles/Rogue/GleamingDaggerProj.cs b/Projectiles/Rogue/GleamingDaggerProj.cs index 2adb2139bb..1546b0b997 100644 --- a/Projectiles/Rogue/GleamingDaggerProj.cs +++ b/Projectiles/Rogue/GleamingDaggerProj.cs @@ -23,6 +23,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = 2; Projectile.timeLeft = 600; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/GodsParanoiaProj.cs b/Projectiles/Rogue/GodsParanoiaProj.cs index d0834ef778..5c2bc3d735 100644 --- a/Projectiles/Rogue/GodsParanoiaProj.cs +++ b/Projectiles/Rogue/GodsParanoiaProj.cs @@ -1,12 +1,12 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class GodsParanoiaProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/GreenDonkeyKongReference.cs b/Projectiles/Rogue/GreenDonkeyKongReference.cs deleted file mode 100644 index fce9c945f1..0000000000 --- a/Projectiles/Rogue/GreenDonkeyKongReference.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class GreenDonkeyKongReference : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/AcidicRainBarrel"; - - public float cooldown = 0f; - public float oldVelocityX = 0f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 5; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 48; - Projectile.height = 48; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.timeLeft = 480; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - Projectile.DamageType = RogueDamageClass.Instance; - } - - public bool CollideX => Projectile.oldPosition.X == Projectile.position.X; - - public override void AI() - { - bool stealthS = Projectile.Calamity().stealthStrike; - if (Projectile.localAI[0] == 0f) - { - Projectile.ai[1] = stealthS.ToInt() == 0 ? 1 : 3; - Projectile.localAI[0] = 1f; - } - Projectile.rotation += Math.Sign(Projectile.velocity.X) * MathHelper.ToRadians(8f); - if (Projectile.velocity.Y < 15f) - { - Projectile.velocity.Y += 0.3f; - } - if (CollideX && cooldown == 0) - { - BounceEffects(); - Projectile.velocity.X = -oldVelocityX; - } - else if (cooldown > 0) - { - cooldown -= 1f; - } - if (Projectile.velocity.X != 0f) - { - oldVelocityX = Math.Sign(Projectile.velocity.X) * 12f; - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) => false; - - public void BounceEffects() - { - bool stealthS = Projectile.Calamity().stealthStrike; - int projectileCount = 8; - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - if (stealthS) - { - projectileCount += 5; //more shit the closer we are to death - } - for (int i = 0; i < projectileCount; i++) - { - if (Main.rand.NextBool(3)) - { - Vector2 shrapnelVelocity = (Vector2.UnitY * (-16f + Main.rand.NextFloat(-3, 12f))).RotatedByRandom((double)MathHelper.ToRadians(30f)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity + shrapnelVelocity, - ModContent.ProjectileType(), Projectile.damage, 3f, Projectile.owner); - } - else - { - Vector2 acidVelocity = (Vector2.UnitY * (-16f + Main.rand.NextFloat(-3, 12f))).RotatedByRandom((double)MathHelper.ToRadians(40f)); - int acidIndex = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity + acidVelocity, - ModContent.ProjectileType(), - (int)(Projectile.damage * 0.75f), 1f, Projectile.owner); - if (acidIndex.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[acidIndex].DamageType = RogueDamageClass.Instance; - Main.projectile[acidIndex].timeLeft = 300; - Main.projectile[acidIndex].usesLocalNPCImmunity = true; - Main.projectile[acidIndex].localNPCHitCooldown = -1; - } - } - } - - if (stealthS) - { - for (int i = 0; i < 6; i++) - { - Vector2 acidVelocity = (Vector2.UnitY * (-16f + Main.rand.NextFloat(-3, 12f))).RotatedByRandom((double)MathHelper.ToRadians(40f)); - int acidIndex = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity + acidVelocity, - ModContent.ProjectileType(), - (int)(Projectile.damage * 0.667f), 1f, Projectile.owner); - if (acidIndex.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[acidIndex].DamageType = RogueDamageClass.Instance; - Main.projectile[acidIndex].timeLeft = 420; - } - } - } - - Projectile.ai[1]--; - cooldown = 15; - if (Projectile.ai[1] <= 0) - { - Projectile.Kill(); - } - } - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); - return false; - } - } -} diff --git a/Projectiles/Rogue/GrimreaverSkull.cs b/Projectiles/Rogue/GrimreaverSkull.cs index 36f83f8a40..b7c04f8d8e 100644 --- a/Projectiles/Rogue/GrimreaverSkull.cs +++ b/Projectiles/Rogue/GrimreaverSkull.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/HeavenfallenEnergy.cs b/Projectiles/Rogue/HeavenfallenEnergy.cs index 74056c7f34..0570f33e54 100644 --- a/Projectiles/Rogue/HeavenfallenEnergy.cs +++ b/Projectiles/Rogue/HeavenfallenEnergy.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -20,41 +19,31 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 8; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.tileCollide = false; + Projectile.timeLeft = 240; Projectile.DamageType = RogueDamageClass.Instance; } public override void AI() { - int constant = 14; int coolDust; Projectile.ai[0]++; if (Projectile.ai[0] % 2 == 0) { - if (Projectile.ai[0] % 4 == 0) - { - coolDust = Dust.NewDust(Projectile.position, Projectile.width - constant * 2, Projectile.height - constant * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - } - else - { - coolDust = Dust.NewDust(Projectile.position, Projectile.width - constant * 2, Projectile.height - constant * 2, ModContent.DustType(), 0f, 0f, 100, default, 1.5f); - } + int dustType = Projectile.ai[0] % 4 == 0 ? ModContent.DustType() : ModContent.DustType(); + coolDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Alpha: 100, Scale: 1.5f); Main.dust[coolDust].noGravity = true; Main.dust[coolDust].velocity *= 0.1f; Main.dust[coolDust].velocity += Projectile.velocity * 0.5f; } float homingRange = raining ? 480f : 240f; - if (Projectile.ai[0] >= 15f || raining) CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, homingRange, 12f, 20f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - public override bool? CanDamage() => Projectile.ai[0] >= 15f || raining; } } diff --git a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs index aa6704c88a..caa3ce9873 100644 --- a/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs +++ b/Projectiles/Rogue/HeavenfallenStardiskBoomerang.cs @@ -36,8 +36,8 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - 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.Calamity().stealthStrike && Projectile.timeLeft % 20f == 4f) + 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.alpha > 0) { @@ -136,7 +136,6 @@ namespace CalamityMod.Projectiles.Rogue } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 240); public override void OnKill(int timeLeft) diff --git a/Projectiles/Rogue/Honeycomb.cs b/Projectiles/Rogue/Honeycomb.cs index 535e0c6eb7..f12ba890ba 100644 --- a/Projectiles/Rogue/Honeycomb.cs +++ b/Projectiles/Rogue/Honeycomb.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Weapons.Rogue; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/HypothermiaChunk.cs b/Projectiles/Rogue/HypothermiaChunk.cs index bdedfa919b..3ce8253f53 100644 --- a/Projectiles/Rogue/HypothermiaChunk.cs +++ b/Projectiles/Rogue/HypothermiaChunk.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 20; Projectile.friendly = true; Projectile.penetrate = 1; - Projectile.timeLeft = 100; + Projectile.timeLeft = 480; Projectile.extraUpdates = 4; Projectile.ignoreWater = true; Projectile.DamageType = RogueDamageClass.Instance; @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(10)) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 318, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Cryocore, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f); } } @@ -55,20 +55,18 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i <= 3; i++) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 318, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Cryocore, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f); } if (Projectile.owner == Main.myPlayer) { - int numSplits = Main.rand.NextBool() ? 4 : 3; - int type = ModContent.ProjectileType(); int shardDamage = (int)(Projectile.damage * 0.5f); float shardKB = Projectile.knockBack * 0.75f; - for (int i = 0; i < numSplits; ++i) + for (int i = 0; i < 4; ++i) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int texID = Main.rand.Next(4); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, type, shardDamage, shardKB, Main.myPlayer, texID, 1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), shardDamage, shardKB, Main.myPlayer, texID, 1f); } } } @@ -82,7 +80,6 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(ModContent.BuffType(), 150); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Rogue/HypothermiaShard.cs b/Projectiles/Rogue/HypothermiaShard.cs index 054cdff67c..b62faae264 100644 --- a/Projectiles/Rogue/HypothermiaShard.cs +++ b/Projectiles/Rogue/HypothermiaShard.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Rogue public class HypothermiaShard : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; - private float counter = 0f; + private int counter = 0; public override void SetDefaults() { Projectile.width = 6; @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Rogue Projectile.scale = 1f; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.alpha = 50; Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.DamageType = RogueDamageClass.Instance; @@ -29,18 +28,19 @@ namespace CalamityMod.Projectiles.Rogue { Lighting.AddLight(Projectile.Center, 0.1f, 0f, 0.5f); Projectile.rotation += Projectile.velocity.X * 0.2f; - counter += 0.25f; if (Main.rand.NextBool(10)) { - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 318, 0f, 0f, 0, default, 0.8f); + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Cryocore, 0f, 0f, Scale: 0.8f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0.2f; } + Projectile.velocity *= 0.996f; - if (counter > 100f) + counter++; + if (counter > 400) { Projectile.scale -= 0.05f; - if ((double)Projectile.scale <= 0.2) + if (Projectile.scale <= 0.2f) { Projectile.scale = 0.2f; Projectile.Kill(); @@ -53,45 +53,42 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { 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 OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override void OnKill(int timeLeft) { for (int k = 0; k < 3; k++) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 318, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Cryocore, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 0, default, 0.8f); } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); - public override bool PreDraw(ref Color lightColor) { //Changes the texture of the projectile Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - if (Projectile.ai[0] == 1f) + switch (Projectile.ai[0]) { - texture = ModContent.Request("CalamityMod/Projectiles/Rogue/HypothermiaShard2").Value; + case 0: + texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + break; + case 1: + texture = ModContent.Request("CalamityMod/Projectiles/Rogue/HypothermiaShard2").Value; + break; + case 2: + texture = ModContent.Request("CalamityMod/Projectiles/Rogue/HypothermiaShard3").Value; + break; + case 3: + texture = ModContent.Request("CalamityMod/Projectiles/Rogue/HypothermiaShard4").Value; + break; } - if (Projectile.ai[0] == 2f) - { - texture = ModContent.Request("CalamityMod/Projectiles/Rogue/HypothermiaShard3").Value; - } - if (Projectile.ai[0] == 3f) - { - texture = ModContent.Request("CalamityMod/Projectiles/Rogue/HypothermiaShard4").Value; - } - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, texture.Size() / 2f, Projectile.scale, SpriteEffects.None); return false; } } diff --git a/Projectiles/Rogue/IcebreakerHammer.cs b/Projectiles/Rogue/IcebreakerHammer.cs index 3ab30014a9..e079d036ad 100644 --- a/Projectiles/Rogue/IcebreakerHammer.cs +++ b/Projectiles/Rogue/IcebreakerHammer.cs @@ -90,19 +90,6 @@ namespace CalamityMod.Projectiles.Rogue int ice = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5), Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f, 1f); if (ice.WithinBounds(Main.maxProjectiles)) Main.projectile[ice].DamageType = RogueDamageClass.Instance; - - int buffType = ModContent.BuffType(); - float radius = 112f; // 7 blocks - - foreach (Player player in Main.ActivePlayers) - { - Player owner = Main.player[Projectile.owner]; - 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) - player.AddBuff(buffType, 60, false); - } - } } } } diff --git a/Projectiles/Rogue/IchorSpearProj.cs b/Projectiles/Rogue/IchorSpearProj.cs index f6b9d9f36a..e596e7e874 100644 --- a/Projectiles/Rogue/IchorSpearProj.cs +++ b/Projectiles/Rogue/IchorSpearProj.cs @@ -1,10 +1,6 @@ -using System; -using System.Reflection.Metadata; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Pets; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Mono.Cecil; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Rogue/InfernalKrisProjectile.cs b/Projectiles/Rogue/InfernalKrisProjectile.cs index 60d4e259a8..2c4c9f3161 100644 --- a/Projectiles/Rogue/InfernalKrisProjectile.cs +++ b/Projectiles/Rogue/InfernalKrisProjectile.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Rogue; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -12,8 +10,7 @@ namespace CalamityMod.Projectiles.Rogue { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/InfernalKris"; - - public static int spinTime = 280; + private bool hasSpawnedCinders = false; public override void SetStaticDefaults() { @@ -29,11 +26,13 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = 2; Projectile.timeLeft = 300; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() { - if (Projectile.timeLeft < spinTime) + if (Projectile.timeLeft < 280) { Projectile.rotation += 0.4f * Projectile.direction; @@ -54,59 +53,37 @@ namespace CalamityMod.Projectiles.Rogue } } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - if (Projectile.timeLeft < spinTime) - { - modifiers.SourceDamage *= 1.75f; - } - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { int debuffTime = 60 * (Projectile.Calamity().stealthStrike ? Main.rand.Next(4, 8) : Main.rand.Next(3, 6)); target.AddBuff(BuffID.OnFire, debuffTime); if (Projectile.Calamity().stealthStrike) - { - int sparkCount = Main.rand.Next(3, 7); - for (int i = 0; i < sparkCount; i++) - { - int sparkScatter = 1; - Vector2 sparkVelocity = new Vector2(Main.rand.NextFloat(-sparkScatter, sparkScatter), Main.rand.NextFloat(-sparkScatter - 2, sparkScatter + 2)); - - sparkVelocity.Normalize(); - sparkVelocity *= 3; - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, sparkVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0, Projectile.owner, 0, 0); - } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0, Projectile.owner, 0, 0); - SoundEngine.PlaySound(SoundID.Item74, Projectile.position); - } + StealthEffect(); } - public override void OnHitPlayer(Player target, Player.HurtInfo info) { int debuffTime = 60 * (Projectile.Calamity().stealthStrike ? Main.rand.Next(4, 8) : Main.rand.Next(3, 6)); target.AddBuff(BuffID.OnFire, debuffTime); if (Projectile.Calamity().stealthStrike) - { - int sparkCount = Main.rand.Next(3, 7); - for (int i = 0; i < sparkCount; i++) - { - int sparkScatter = 1; - Vector2 sparkVelocity = new Vector2(Main.rand.NextFloat(-sparkScatter, sparkScatter), Main.rand.NextFloat(-sparkScatter - 2, sparkScatter + 2)); - - sparkVelocity.Normalize(); - sparkVelocity *= 3; - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, sparkVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0, Projectile.owner, 0, 0); - } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0, Projectile.owner, 0, 0); - SoundEngine.PlaySound(SoundID.Item74, Projectile.position); - } + StealthEffect(); } + private void StealthEffect() + { + hasSpawnedCinders = true; + int sparkCount = Main.rand.Next(4, 5 + 1); + for (int i = 0; i < sparkCount; i++) + { + Vector2 sparkVelocity = Main.rand.NextVector2Circular(1f, 3f); + sparkVelocity = sparkVelocity.SafeNormalize(Vector2.UnitY) * 3f; + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, sparkVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0, Projectile.owner, 0, 0); + } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0, Projectile.owner, 0, 0); + SoundEngine.PlaySound(SoundID.Item74, Projectile.position); + } + public override bool PreDraw(ref Color lightColor) { @@ -165,13 +142,13 @@ namespace CalamityMod.Projectiles.Rogue public override void OnKill(int timeLeft) { - if (Projectile.Calamity().stealthStrike) + if (Projectile.Calamity().stealthStrike && !hasSpawnedCinders) { - int sparkCount = Main.rand.Next(3, 7); + int sparkCount = Main.rand.Next(4, 5+1); for (int i = 0; i < sparkCount; i++) { - int sparkScatter = 1; - Vector2 sparkVelocity = new Vector2(Main.rand.NextFloat(-sparkScatter, sparkScatter), Main.rand.NextFloat(-sparkScatter, sparkScatter)); + Vector2 sparkVelocity = Main.rand.NextVector2Circular(1f, 3f); + sparkVelocity = sparkVelocity.SafeNormalize(Vector2.UnitY) * 3f; if (Projectile.ai[0] != 0) { @@ -182,14 +159,9 @@ namespace CalamityMod.Projectiles.Rogue sparkVelocity.Y *= -1; } - sparkVelocity.X += Projectile.ai[0]; - sparkVelocity.Y += Projectile.ai[1]; - sparkVelocity.Normalize(); - sparkVelocity *= 3; - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, sparkVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0, Projectile.owner, 0, 0); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, sparkVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0, Projectile.owner, 0, 0); } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0, Projectile.owner, 0, 0); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0, Projectile.owner, 0, 0); SoundEngine.PlaySound(SoundID.Item74, Projectile.position); } } diff --git a/Projectiles/Rogue/InfestedClawmerangProj.cs b/Projectiles/Rogue/InfestedClawmerangProj.cs index ab0c7314d9..e420a236a8 100644 --- a/Projectiles/Rogue/InfestedClawmerangProj.cs +++ b/Projectiles/Rogue/InfestedClawmerangProj.cs @@ -22,6 +22,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 300; AIType = ProjectileID.WoodenBoomerang; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() @@ -35,12 +37,8 @@ namespace CalamityMod.Projectiles.Rogue { if (Projectile.timeLeft % 15 == 0 && Projectile.owner == Main.myPlayer) { - Vector2 vector62 = Main.player[Projectile.owner].Center - Projectile.Center; - Vector2 vector63 = vector62 * -1f; - vector63.Normalize(); - vector63 *= (float)Main.rand.Next(45, 65) * 0.1f; - vector63 = vector63.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, vector63.X, vector63.Y, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), Projectile.knockBack * 0.2f, Projectile.owner, -10f, 0f); + Vector2 sporeVel = Utils.DirectionFrom(Projectile.Center, Main.player[Projectile.owner].Center).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(4.5f, 6.5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, sporeVel, ModContent.ProjectileType(), (int)(Projectile.damage * 0.3f), 1f, Projectile.owner, -10f, 1f); } } } diff --git a/Projectiles/Rogue/InkBombProjectile.cs b/Projectiles/Rogue/InkBombProjectile.cs index 7f9f6b90cc..aa11a82aa0 100644 --- a/Projectiles/Rogue/InkBombProjectile.cs +++ b/Projectiles/Rogue/InkBombProjectile.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Accessories; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -10,6 +10,7 @@ namespace CalamityMod.Projectiles.Rogue public class InkBombProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; + public static readonly SoundStyle Explode = new("CalamityMod/Sounds/Custom/PlantyMushMine", 3); public override void SetDefaults() { Projectile.width = 14; @@ -49,10 +50,10 @@ namespace CalamityMod.Projectiles.Rogue private void CreateInk() { Player player = Main.player[Projectile.owner]; - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int i = 0; i < 20; i++) + SoundEngine.PlaySound(SoundID.NPCHit25, Projectile.Center); + for (int i = 0; i < 4; i++) { - int damage = (int)player.GetTotalDamage().ApplyTo(22); + int damage = (int)player.GetTotalDamage().ApplyTo(InkBomb.InkDamage); int inkID = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(2f, 2f), ModContent.ProjectileType(), damage, 7, Projectile.owner, Main.rand.Next(3) + 1); Main.projectile[inkID].timeLeft += Main.rand.Next(-15, 15 + 1); diff --git a/Projectiles/Rogue/InkCloud.cs b/Projectiles/Rogue/InkCloud.cs index b45ad2b89a..7313d4b6e1 100644 --- a/Projectiles/Rogue/InkCloud.cs +++ b/Projectiles/Rogue/InkCloud.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.tileCollide = true; Projectile.ignoreWater = true; Projectile.timeLeft = 100; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 15; Projectile.DamageType = RogueDamageClass.Instance; } @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Rogue { if (!target.friendly) { - target.AddBuff(BuffID.Confused, 300); + target.AddBuff(BuffID.Confused, 60); } } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Confused, 300); diff --git a/Projectiles/Rogue/IronFranciscaProj.cs b/Projectiles/Rogue/IronFranciscaProj.cs index 6352c68223..5b5f49e5f4 100644 --- a/Projectiles/Rogue/IronFranciscaProj.cs +++ b/Projectiles/Rogue/IronFranciscaProj.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/JawsProjectile.cs b/Projectiles/Rogue/JawsProjectile.cs index 25b55a5c37..cf28eed5b5 100644 --- a/Projectiles/Rogue/JawsProjectile.cs +++ b/Projectiles/Rogue/JawsProjectile.cs @@ -1,6 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -9,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class JawsProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/KelvinCatalystBoomerang.cs b/Projectiles/Rogue/KelvinCatalystBoomerang.cs index db15c7a74b..fbf1f6df10 100644 --- a/Projectiles/Rogue/KelvinCatalystBoomerang.cs +++ b/Projectiles/Rogue/KelvinCatalystBoomerang.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Rogue/LanceofDestiny.cs b/Projectiles/Rogue/LanceofDestiny.cs index 60d06ad8ae..12007830d2 100644 --- a/Projectiles/Rogue/LanceofDestiny.cs +++ b/Projectiles/Rogue/LanceofDestiny.cs @@ -1,13 +1,8 @@ -using System; -using System.Reflection.Metadata; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Pets; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Mono.Cecil; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/LeadTomahawkProj.cs b/Projectiles/Rogue/LeadTomahawkProj.cs index 714492858c..aa8886d999 100644 --- a/Projectiles/Rogue/LeadTomahawkProj.cs +++ b/Projectiles/Rogue/LeadTomahawkProj.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/LeonidCometSmall.cs b/Projectiles/Rogue/LeonidCometSmall.cs index 9bcf7cc54e..6835ca8f01 100644 --- a/Projectiles/Rogue/LeonidCometSmall.cs +++ b/Projectiles/Rogue/LeonidCometSmall.cs @@ -28,19 +28,6 @@ namespace CalamityMod.Projectiles.Rogue Projectile.alpha = 255; } - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), Projectile.rotation, tex.Size() / 2, Projectile.scale, SpriteEffects.None, 0); - return false; - } - - public override void PostDraw(Color lightColor) - { - Texture2D tex = ModContent.Request("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow").Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, tex.Size() / 2, Projectile.scale, SpriteEffects.None, 0); - } - public override void AI() { Projectile.alpha -= 25; @@ -55,15 +42,10 @@ namespace CalamityMod.Projectiles.Rogue }); if (Main.rand.NextBool()) { - int index = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.6f); + int index = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.3f); Main.dust[index].noGravity = true; } - if (Main.rand.NextBool()) - { - int index = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.6f); - Main.dust[index].noGravity = true; - } - int index1 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), 1.2f); + int index1 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f)); Main.dust[index1].noGravity = true; Main.dust[index1].velocity *= 2f; Main.dust[index1].velocity += Projectile.velocity; @@ -84,11 +66,14 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation += Projectile.velocity.X * 0.1f; } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); + public override void OnKill(int timeLeft) { if (Projectile.owner != Main.myPlayer) return; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 3, 0f, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 2, 0f, Projectile.owner); Projectile.ai[1] = -1f; Projectile.position = Projectile.Center; Projectile.width = Projectile.height = 40; @@ -124,8 +109,16 @@ namespace CalamityMod.Projectiles.Rogue } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, CalamityUtils.ColorSwap(LeonidProgenitor.blueColor, LeonidProgenitor.purpleColor, 1f), Projectile.rotation, tex.Size() / 2, Projectile.scale, SpriteEffects.None, 0); + return false; + } + public override void PostDraw(Color lightColor) + { + Texture2D tex = ModContent.Request("CalamityMod/Items/Weapons/Rogue/LeonidProgenitorGlow").Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, tex.Size() / 2, Projectile.scale, SpriteEffects.None, 0); + } } } diff --git a/Projectiles/Rogue/LeonidProgenitorBombshell.cs b/Projectiles/Rogue/LeonidProgenitorBombshell.cs index 8ecefdb0c6..606bf24ff4 100644 --- a/Projectiles/Rogue/LeonidProgenitorBombshell.cs +++ b/Projectiles/Rogue/LeonidProgenitorBombshell.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.netUpdate = true; } } - Projectile.velocity.Y += 0.2f; + Projectile.velocity.Y += 0.2f / (float)Projectile.MaxUpdates; } Projectile.rotation += Projectile.velocity.X * 0.1f; } @@ -76,47 +76,35 @@ namespace CalamityMod.Projectiles.Rogue { int flash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner, 0f, 1f); if (flash.WithinBounds(Main.maxProjectiles)) - { Main.projectile[flash].DamageType = RogueDamageClass.Instance; - Main.projectile[flash].usesLocalNPCImmunity = true; - Main.projectile[flash].localNPCHitCooldown = 10; - } - - Vector2 pos = new Vector2(Projectile.Center.X + Projectile.width * 0.5f + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - Vector2 velocity = (Projectile.Center - pos) / 40f; - int dmg = Projectile.damage / 2; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, velocity, ModContent.ProjectileType(), dmg, Projectile.knockBack, Projectile.owner, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 240); - StealthStrikeEffect(); + SpawnExtraProjectiles(target); } public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(ModContent.BuffType(), 240); - StealthStrikeEffect(); + SpawnExtraProjectiles(target); } - private void StealthStrikeEffect() + private void SpawnExtraProjectiles(Entity target) { - if (!Projectile.Calamity().stealthStrike || Main.myPlayer != Projectile.owner) - return; - - Vector2 spinningpoint = new Vector2(0f, 6f); - float radian45 = MathHelper.ToRadians(45f); - int cometAmt = 5; - float cometSpread = -(radian45 * 2f) / (cometAmt - 1f); - for (int projIndex = 0; projIndex < cometAmt; ++projIndex) + Vector2 pos = new Vector2(target.Center.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 meteorVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(pos, target, 20f, 3); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, meteorVel, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner, 0f, 0.5f + Main.rand.NextFloat() * 0.3f); + + if (Projectile.Calamity().stealthStrike) { - int index2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, spinningpoint.RotatedBy((double)radian45 + (double)cometSpread * (double)projIndex, new Vector2()), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, -1f); - Projectile proj = Main.projectile[index2]; - for (int index3 = 0; index3 < Projectile.localNPCImmunity.Length; ++index3) + for (int i = 0; i < 5; i++) { - proj.localNPCImmunity[index3] = Projectile.localNPCImmunity[index3]; + Vector2 cometPos = new Vector2(target.Center.X + Main.rand.Next(-100, 101), target.Center.Y - 150f - Main.rand.Next(30)); + Vector2 cometVel = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(pos, target, 18f, 2); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), cometPos, cometVel, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, -1f); } } } diff --git a/Projectiles/Rogue/LeviathanTooth.cs b/Projectiles/Rogue/LeviathanTooth.cs index 85a6f13add..86a1595caf 100644 --- a/Projectiles/Rogue/LeviathanTooth.cs +++ b/Projectiles/Rogue/LeviathanTooth.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -9,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class LeviathanTooth : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -21,18 +23,13 @@ namespace CalamityMod.Projectiles.Rogue public bool canDamage = true; public bool canStick = true; public Vector2 vibrate = Vector2.Zero; - public int stuckTimer = 120; + public int stuckTimer = 180; public Vector2 placementCenter; float placementDistance; Vector2 placementVelocity; public Vector2 storedVelocity; public bool collideWithTiles = true; - - public bool jawline = true; // Tooth direction for the stealthstrike - public Vector2 startingVel; public bool toothDirection = false; - public Vector2 chomp = Vector2.Zero; - public bool chomping = true; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 8; @@ -46,39 +43,42 @@ namespace CalamityMod.Projectiles.Rogue Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.extraUpdates = 2; + Projectile.extraUpdates = 3; Projectile.tileCollide = false; Projectile.timeLeft = 600; Projectile.DamageType = RogueDamageClass.Instance; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.noEnchantmentVisuals = true; } public override void AI() { + Lighting.AddLight(Projectile.Center, Color.Lerp(Color.Red, Color.White, 0.85f).ToVector3() * 0.5f * Utils.GetLerpValue(255, 0, Projectile.alpha, true)); if (time == 0) { stuckTimer = Main.rand.Next(100, 120 + 1); - startingVel = Projectile.velocity; if (Projectile.ai[1] < 4) toothDirection = Main.rand.NextBool(); } if (!stuckInTarget && !stuckInGround) { - if (!Projectile.Calamity().stealthStrike) + if (Projectile.velocity.Length() > 5 && time > 30 && Projectile.numHits == 0) + Projectile.velocity *= 0.97f; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if ((time % 2 == 0 || !canStick) && time > 5) { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if ((time % 2 == 0 || !canStick) && time > 15) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), 5, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f)); - dust.noGravity = true; - } - if (time > 90 && canStick) - { - Projectile.velocity.Y += 0.03f; - if (Projectile.velocity.Y > 0) - Projectile.velocity.X *= 0.99f; - } + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), DustID.Blood, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f) * (canStick ? 1 : 1.3f)); + dust.noGravity = true; + Particle blood = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(canStick ? 0.3f : 0.1f) * Main.rand.NextFloat(5f, 8f), "CalamityMod/Particles/LargeBloom", + false, 8, Main.rand.NextFloat(0.055f, 0.07f), Color.Lerp(Color.DarkRed, Color.Black, Main.rand.NextFloat(0, 0.5f)) * 0.7f, new Vector2(0.7f, 1f), false, shrinkSpeed: 0.8f); + GeneralParticleHandler.SpawnParticle(blood); + } + if (time > 90 && canStick) + { + Projectile.velocity.Y += 0.03f; + if (Projectile.velocity.Y > 0) + Projectile.velocity.X *= 0.99f; } } else if (stuckInTarget) @@ -105,12 +105,13 @@ namespace CalamityMod.Projectiles.Rogue vibrate = Vector2.Zero; canStick = false; collideWithTiles = true; - Projectile.velocity = storedVelocity * 1.3f; + Projectile.velocity = storedVelocity; + Projectile.extraUpdates = 4; stuckInTarget = false; for (int i = 0; i <= 7; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 5, (storedVelocity * 2.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, (storedVelocity * 2.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.8f)); dust.noGravity = false; } for (int i = 0; i <= 3; i++) @@ -128,117 +129,33 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation = storedVelocity.ToRotation() + MathHelper.PiOver2; } - if (Projectile.Calamity().stealthStrike) - { - collideWithTiles = false; - if (time > 15 && (Projectile.ai[1] == 4 ? Projectile.timeLeft > 60 : time < 40)) - { - for (int i = 0; i < (Projectile.ai[1] == 4 ? 2 : 1); i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), 5, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.5f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.6f)); - dust.noGravity = true; - } - } - if (Projectile.ai[1] == 4) - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; - int jawDir = jawline ? 1 : -1; - Vector2 spawnPos = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.ToRadians(90f * jawDir)) * 170; - Vector2 jawVel = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.ToRadians(90f * jawDir)) * 17; - if (time > 10 && Projectile.timeLeft >= 60) - { - if (time % 3 == 0) - { - Projectile tooth = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), spawnPos, jawVel, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack / 12, Projectile.owner, 0, 0, Projectile.velocity.X > 0 ? 1 : -1); - tooth.Calamity().stealthStrike = true; - tooth.timeLeft = 120; - tooth.extraUpdates = 0; - tooth.usesIDStaticNPCImmunity = true; - tooth.usesLocalNPCImmunity = false; - tooth.idStaticNPCHitCooldown = 5; - tooth.ai[1] = Main.rand.Next(1, 3 + 1); - jawline = !jawline; - } - if (time % 2 == 0) - { - Particle spark = new AltSparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 15, 1f, Color.DarkRed * 0.4f); - GeneralParticleHandler.SpawnParticle(spark); - } - if (Projectile.timeLeft == 60) - Projectile.velocity *= 0.5f; - } - else if (Projectile.timeLeft <= 60) - { - Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 0, 60, 255, 0)); - Projectile.velocity *= 0.95f; - } - } - else - { - Projectile.rotation = startingVel.ToRotation() + MathHelper.ToRadians(270f); - if (Projectile.timeLeft > 90) - { - Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, -startingVel.X * 1.3f, 0.045f); - Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, -startingVel.Y * 1.3f, 0.045f); - Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 120, 90, 255, 0)); - } - else - { - Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 0, 30, 255, 0)); - Projectile.velocity *= 0.9f; - } - if (time > 40) - { - if (!chomping) - { - chomp.X = MathHelper.Lerp(chomp.X, startingVel.X * 3, 0.2f); - chomp.Y = MathHelper.Lerp(chomp.Y, startingVel.Y * 3, 0.2f); - } - else - { - chomp.X = MathHelper.Lerp(chomp.X, 0, 0.2f); - chomp.Y = MathHelper.Lerp(chomp.Y, 0, 0.2f); - } - if (time % 18 == 0) - chomping = !chomping; - } - - } - } - time++; - if (collideWithTiles && Collision.SolidCollision(Projectile.Center, 4, 4)) // Vanilla tile collision messes with velocity so we use this instead { canDamage = false; - if (Projectile.timeLeft > 180) - Projectile.timeLeft = 180; + Projectile.timeLeft = 180; stuckInGround = true; storedVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitX); Projectile.velocity = Vector2.Zero; SoundStyle sound = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit1"); SoundEngine.PlaySound(sound with { Volume = 0.25f, Pitch = Main.rand.NextFloat(-0.3f, -0.6f) }, Projectile.Center); collideWithTiles = false; - } - if (!Projectile.Calamity().stealthStrike) - Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 0, 60, 255, 0)); + Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 0, 60, 255, 0)); + time++; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.Calamity().stealthStrike) - modifiers.SourceDamage *= Projectile.ai[1] == 4 ? 0.6f : 0.5f; - else - modifiers.SourceDamage *= target == chosenTarget ? 1 : (canStick ? 0.2f : 0.5f); + modifiers.SourceDamage *= target == chosenTarget ? 1 : (canStick ? 0.2f : 0.5f); } public override bool? CanDamage() => canDamage ? null : false; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (target == chosenTarget || Projectile.Calamity().stealthStrike) + if (target == chosenTarget) target.AddBuff(ModContent.BuffType(), 180); - if (!stuckInTarget && canStick && !Projectile.Calamity().stealthStrike) + if (!stuckInTarget && canStick) { if (Projectile.timeLeft < 400) Projectile.timeLeft = 400; @@ -264,10 +181,10 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.ai[1] == 4) tex = ModContent.Request("CalamityMod/Projectiles/Melee/GreenWater").Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + vibrate + chomp, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, toothDirection ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + vibrate, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, toothDirection ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); return false; } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.Calamity().stealthStrike ? 50 : 18, targetHitbox); + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 18, targetHitbox); } } diff --git a/Projectiles/Rogue/LeviathanToothStealth.cs b/Projectiles/Rogue/LeviathanToothStealth.cs new file mode 100644 index 0000000000..34163a3f15 --- /dev/null +++ b/Projectiles/Rogue/LeviathanToothStealth.cs @@ -0,0 +1,199 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.Player; + +namespace CalamityMod.Projectiles.Rogue +{ + [PierceResistException] + public class LeviathanToothStealth : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/Rogue/LeviathanTooth"; + public new string LocalizationCategory => "Projectiles.Rogue"; + public ref float time => ref Projectile.ai[0]; + + public bool canDamage = false; + public bool isTopJaw = false; + public float topJawRot = 0; + public float bottomJawRot = 0; + public int jawSlamTime = 25; + public bool spawnedDust = false; + public int jawLength = 750; + public int hitTimer = 0; + public Player Owner => Main.player[Projectile.owner]; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 2; + Projectile.height = 2; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.timeLeft = 180; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 8; + Projectile.ArmorPenetration = 25; + Projectile.noEnchantmentVisuals = true; + } + + public override void AI() + { + if (hitTimer > 0) + hitTimer--; + if (time == 0) + { + topJawRot = -MathHelper.PiOver4; + bottomJawRot = MathHelper.PiOver4; + } + topJawRot *= 0.95f; + bottomJawRot *= 0.95f; + float openingRot = 0.5f; + if (time <= 10) + { + float lerpValue = 1 - (float)Math.Pow(Utils.GetLerpValue(10, 0, time, true), 2); + topJawRot = MathHelper.Lerp(-MathHelper.PiOver4, -MathHelper.PiOver4 - openingRot, lerpValue); + bottomJawRot = MathHelper.Lerp(MathHelper.PiOver4, MathHelper.PiOver4 + openingRot, lerpValue); + } + else + { + float lerpValue = (float)Math.Pow(Utils.GetLerpValue(11, jawSlamTime, time, true), 4); + topJawRot = MathHelper.Lerp(-MathHelper.PiOver4 - openingRot, 0, lerpValue); + bottomJawRot = MathHelper.Lerp(MathHelper.PiOver4 + openingRot, 0, lerpValue); + } + + if (time < jawSlamTime * 1.5f) + { + Owner.direction = Projectile.direction; + if (time < jawSlamTime) + { + Projectile.Center = Owner.Center; + Projectile.velocity = Owner.Center.DirectionTo(Owner.Calamity().mouseWorld) * 0.01f; + } + Owner.itemTime = Owner.itemAnimation = 2; + Vector2 toMouse = Owner.Center.DirectionTo(Owner.Calamity().mouseWorld); + Owner.SetCompositeArmFront(true, CompositeArmStretchAmount.Full, toMouse.ToRotation() + topJawRot * Owner.direction + MathHelper.PiOver2 * -Owner.direction + (Owner.direction == -1 ? MathHelper.Pi : 0)); + Owner.SetCompositeArmBack(true, CompositeArmStretchAmount.Full, toMouse.ToRotation() + bottomJawRot * Owner.direction + MathHelper.PiOver2 * -Owner.direction + (Owner.direction == -1 ? MathHelper.Pi : 0)); + } + if (time == jawSlamTime) + { + Owner.SetScreenshake(5f); + Owner.Calamity().ConsumeStealthByAttacking(); + SoundStyle crunch = new("CalamityMod/Sounds/NPCKilled/PerfSmallDeath"); + for (int i = 0; i < 3; i++) + SoundEngine.PlaySound(crunch with { Volume = 0.4f, Pitch = -0.1f * i, MaxInstances = 3 }, Projectile.Center); + SoundStyle crunch2 = new("CalamityMod/Sounds/NPCHit/RavagerHurt3"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(crunch2 with { Volume = 0.8f, Pitch = -0.4f * i, MaxInstances = 2 }, Projectile.Center); + canDamage = true; + } + + Projectile.Opacity = (float)Math.Pow(Utils.GetLerpValue(0, 40, Projectile.timeLeft, true), 4); + if (Projectile.Opacity <= 0.4f) + canDamage = false; + time++; + spawnedDust = false; + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float damageMult = 1; + if (hitTimer != 0) + damageMult = 0.2f; + bool jawsJustSlammed = (time >= jawSlamTime && time <= jawSlamTime + 8); + modifiers.SourceDamage *= (jawsJustSlammed ? 12 : 1) * damageMult; + if (hitTimer == 0) + hitTimer = Projectile.localNPCHitCooldown; + + if (target.CanBeMoved(true)) + target.velocity *= 0.05f; + } + public override bool? CanDamage() => canDamage ? null : false; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + } + + public override bool PreDraw(ref Color lightColor) + { + if (time == 0) + return false; + + Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Vector2 startPoint = Projectile.Center; + int distance = jawLength; + int travelLength = 35; + Vector2 endPoint = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * distance; + Vector2 direction = Projectile.velocity.SafeNormalize(Vector2.UnitX); + + for (int t = -1; t <= 1; t += 2) + { + SpriteEffects spriteFx = (!isTopJaw) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Color drawColor = Projectile.GetAlpha(lightColor); + int toothNum = 0; + for (int i = 0; i < distance; i += travelLength) + { + if (((isTopJaw && Projectile.direction == -1) || (!isTopJaw && Projectile.direction == 1)) && i == 0) + i += (int)(travelLength * 0.5f); + + float jawRot = (isTopJaw ? topJawRot : bottomJawRot); + float scale = (Projectile.scale + 0.35f - 0.02f * toothNum); + float slamLerp = (float)Math.Pow(Utils.GetLerpValue(0, jawSlamTime * 1.5f, time, true), 4); + float sine = ((float)Math.Pow((float)Math.Sin((time + toothNum * 3) / 10), 4)) * slamLerp; + Vector2 drawPos = (startPoint + i * direction.RotatedBy(jawRot)) + direction.RotatedBy(MathHelper.PiOver2 * (isTopJaw ? 1 : -1)) * (-25 * scale - 65 * sine * scale); + Vector2 toMouse = Projectile.velocity.SafeNormalize(Vector2.UnitX); + Vector2 finalDrawPos = drawPos + toMouse.RotatedBy(jawRot) * 5 * (1 - slamLerp) + Main.rand.NextVector2Circular(14, 14) * (time >= jawSlamTime ? Utils.GetLerpValue(jawSlamTime + 30, jawSlamTime, time, true) : 0); + float rotation = Projectile.velocity.ToRotation() + (jawRot) + (isTopJaw ? MathHelper.Pi : 0); + float toothOpacity = Math.Min((float)Math.Pow(Utils.GetLerpValue(0, toothNum, time, true), 3), Projectile.Opacity); + Main.EntitySpriteDraw(tex, finalDrawPos - Main.screenPosition, null, Color.Lerp(drawColor, Color.White, toothOpacity) * toothOpacity, rotation, new Vector2(tex.Width / 2, tex.Height), new Vector2(1f, 1) * scale, spriteFx, 0); + toothNum++; + + if (!spawnedDust && toothNum > 1) + { + Dust dust = Dust.NewDustPerfect(finalDrawPos, DustID.Blood, (rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2)).RotatedByRandom(0.5f).RotatedBy(1.2f * (isTopJaw ? -1 : 1)) * Main.rand.NextFloat(5f, 8f), 100, default, Main.rand.NextFloat(1.1f, 1.9f) * scale); + dust.noGravity = true; + dust.alpha = (int)(255 * (1 - toothOpacity)); + Particle blood = new CustomSpark(finalDrawPos, (rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2)).RotatedByRandom(0.4f).RotatedBy(1.2f * (isTopJaw ? -1 : 1)) * Main.rand.NextFloat(5f, 8f), "CalamityMod/Particles/LargeBloom", + false, 8, Main.rand.NextFloat(0.065f, 0.08f) * scale, Color.Lerp(Color.DarkRed, Color.Black, Main.rand.NextFloat(0, 0.5f)) * 0.7f * toothOpacity, new Vector2(1f, 1f), false, shrinkSpeed: 0.9f); + GeneralParticleHandler.SpawnParticle(blood); + + Lighting.AddLight(finalDrawPos, Color.Lerp(Color.Red, Color.White, 0.85f).ToVector3() * 1.2f * toothOpacity); + } + } + isTopJaw = (t == -1); + } + spawnedDust = true; // Make sure effect spawning isn't happening based on frame rate + + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canDamage) + return false; + + Vector2 start = Projectile.Center; + float length = jawLength; + float size = 165; + float _ = float.NaN; + + bool hit = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, start + Projectile.velocity.SafeNormalize(Vector2.UnitX) * length, size, ref _); + return hit; + } + } +} diff --git a/Projectiles/Rogue/LionfishProj.cs b/Projectiles/Rogue/LionfishProj.cs index 6d6bd45d06..7d5cb2ecae 100644 --- a/Projectiles/Rogue/LionfishProj.cs +++ b/Projectiles/Rogue/LionfishProj.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.NPCs; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -9,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class LionfishProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -24,6 +26,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.alpha = 255; Projectile.DamageType = RogueDamageClass.Instance; Projectile.timeLeft = CalamityUtils.SecondsToFrames(20f); + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/LostSoulFriendly.cs b/Projectiles/Rogue/LostSoulFriendly.cs index 1976f6b70e..3ed53a60cd 100644 --- a/Projectiles/Rogue/LostSoulFriendly.cs +++ b/Projectiles/Rogue/LostSoulFriendly.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Rogue Projectile.DamageType = RogueDamageClass.Instance; Projectile.extraUpdates = 1; Projectile.alpha = 150; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override bool? CanHitNPC(NPC target) => (Projectile.timeLeft < 210 || Projectile.ai[0] == 2f) && target.CanBeChasedBy(Projectile); @@ -54,7 +53,7 @@ namespace CalamityMod.Projectiles.Rogue // Reduce damage of projectiles if more than the cap are active public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (!Projectile.CountsAsClass()) + if (Projectile.DamageType == DamageClass.Generic) { int cap = 10; float capDamageFactor = 0.05f; diff --git a/Projectiles/Rogue/LunarKunaiProj.cs b/Projectiles/Rogue/LunarKunaiProj.cs index 0e9238f4ce..974861b4a5 100644 --- a/Projectiles/Rogue/LunarKunaiProj.cs +++ b/Projectiles/Rogue/LunarKunaiProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Rogue/LyraConstellation.cs b/Projectiles/Rogue/LyraConstellation.cs new file mode 100644 index 0000000000..323b89b4f3 --- /dev/null +++ b/Projectiles/Rogue/LyraConstellation.cs @@ -0,0 +1,119 @@ + +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using rail; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class LyraConstellation : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int lifetime = 150; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 1; + } + + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + lifetime = 300; + Projectile.timeLeft = lifetime; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.MaxUpdates = 2; + } + + public override void AI() + { + if (Projectile.velocity.Length() > 0) + Projectile.rotation = Projectile.velocity.ToRotation(); + var Owner = Main.player[Projectile.owner]; + var DrawCenter = Projectile.Center + Projectile.velocity; + var StarScale = 0.2f; + Projectile.scale = MathF.Min(Projectile.timeLeft / 20f, MathF.Min((lifetime - Projectile.timeLeft) / 20f, 1f)); + void SpawnStar(Vector2 offset, float intensity, int flashOffset = 0, int flashMod = 100) + { + offset += new Vector2(35.666f, -53.166f); //this centers the constellation + offset.X *= Projectile.spriteDirection; + var star = new BloomParticle(DrawCenter + offset.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(offset.Length() * 0.001f, 0, 1)), Vector2.Zero, Color.SkyBlue * ((Owner.miscCounter + flashOffset) % flashMod < 5 ? 0.75f : 1f), StarScale * intensity, StarScale * intensity, 2, false); + var star2 = new CustomSpark(DrawCenter + offset.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(offset.Length() * 0.001f, 0, 1)), Vector2.UnitX.RotatedBy(MathHelper.Pi * ((Owner.miscCounter + flashOffset) / 300f)) * 0.1f, "CalamityMod/Particles/Sparkle", false, 2, 4 * StarScale * intensity, Color.White, Vector2.One); + GeneralParticleHandler.SpawnParticle(star); + GeneralParticleHandler.SpawnParticle(star2); + } + if (Projectile.FinalExtraUpdate()) + { + SpawnStar(new Vector2(0f, 0f), 0.75f, 0); //Center + SpawnStar(new Vector2(75, -60), 1.25f, 40); //Vega + SpawnStar(new Vector2(3, -102), 0.75f, 120); //Top + SpawnStar(new Vector2(-52, 207), 0.75f, 5); //Bottom R + SpawnStar(new Vector2(-144, 239), 0.75f, 10); //Bottom L + SpawnStar(new Vector2(-96, 35), 0.75f, 75); //Left + } + Projectile.position = Projectile.Center; + Projectile.Size = new Vector2(225, 375) * Projectile.scale; + Projectile.Center = Projectile.position; + } + + public override bool PreDraw(ref Color lightColor) + { + var SiriusPos = Projectile.Center; + var Owner = Main.player[Projectile.owner]; + void ConnectStars(Vector2 point1, Vector2 point2) + { + point1 += new Vector2(35.666f, -53.166f); //this centers the constellation + point2 += new Vector2(35.666f, -53.166f); + point1.X *= Projectile.spriteDirection; + point2.X *= Projectile.spriteDirection; + var color = Color.SkyBlue * 0.75f * ((MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f + 0.5f); + CalamityUtils.DrawLineBetter(Main.spriteBatch, SiriusPos + point1.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(point1.Length() * 0.001f, 0, 1)), SiriusPos + point2.RotatedBy(Projectile.rotation) * Projectile.scale - (Owner.oldVelocity * Math.Clamp(point2.Length() * 0.001f, 0, 1)), color, 3); + } + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + ConnectStars(new Vector2(0f, 0f), new Vector2(75, -60)); //Center - Vega + ConnectStars(new Vector2(0f, 0f), new Vector2(3, -102)); //Center - Top + ConnectStars(new Vector2(0f, 0f), new Vector2(-96, 35)); //Center - Left + ConnectStars(new Vector2(0f, 0f), new Vector2(-52, 207)); //Center - Bottom R + ConnectStars(new Vector2(75, -60), new Vector2(3, -102)); //Vega - Top + ConnectStars(new Vector2(-144, 239), new Vector2(-96, 35)); //Bottom L - Left + ConnectStars(new Vector2(-144, 239), new Vector2(-52, 207)); //Bottom L - Bottom R + Main.spriteBatch.End(); + } + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); + + int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + } + } + } +} diff --git a/Projectiles/Rogue/MalachiteBolt.cs b/Projectiles/Rogue/MalachiteBolt.cs index 6645114223..8ce8b7166b 100644 --- a/Projectiles/Rogue/MalachiteBolt.cs +++ b/Projectiles/Rogue/MalachiteBolt.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Rogue/MangroveChakramProjectile.cs b/Projectiles/Rogue/MangroveChakramProjectile.cs index 81f4212305..4bed2c6456 100644 --- a/Projectiles/Rogue/MangroveChakramProjectile.cs +++ b/Projectiles/Rogue/MangroveChakramProjectile.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Rogue Lighting.AddLight(Projectile.Center, 0f, 0.25f, 0f); if (Main.rand.NextBool(5)) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.JungleSpore, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.ChlorophyteWeapon, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); if (Projectile.Calamity().stealthStrike) { @@ -39,8 +39,8 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.timeLeft < 240) Projectile.Kill(); - Projectile.localAI[0] += Main.rand.Next(0, 3); - if (Projectile.localAI[0] >= 10f) + Projectile.localAI[0] += Main.rand.Next(1, 3); + if (Projectile.localAI[0] >= 20f) { Projectile.localAI[0] = 0f; Vector2 flowerSpawnPosition = Projectile.Center + Main.rand.NextVector2Square(-10f, 10f); @@ -58,7 +58,6 @@ namespace CalamityMod.Projectiles.Rogue } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Venom, 120); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Venom, 120); } } diff --git a/Projectiles/Rogue/MetalShard.cs b/Projectiles/Rogue/MetalShard.cs index 0310ef4f94..83d25aece6 100644 --- a/Projectiles/Rogue/MetalShard.cs +++ b/Projectiles/Rogue/MetalShard.cs @@ -1,4 +1,4 @@ - +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,6 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class MetalShard : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/MeteorFistMeteorite.cs b/Projectiles/Rogue/MeteorFistMeteorite.cs index 5281f17885..710a94cc2a 100644 --- a/Projectiles/Rogue/MeteorFistMeteorite.cs +++ b/Projectiles/Rogue/MeteorFistMeteorite.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -55,8 +52,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnKill(int timeLeft) { - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3f) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3f; + Main.LocalPlayer.SetScreenshake(3f); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/HellbornImpact"), Projectile.Center); Projectile.ExpandHitboxBy(300); diff --git a/Projectiles/Rogue/MeteorFistProj.cs b/Projectiles/Rogue/MeteorFistProj.cs index cc694bad98..68ff1c2eec 100644 --- a/Projectiles/Rogue/MeteorFistProj.cs +++ b/Projectiles/Rogue/MeteorFistProj.cs @@ -1,9 +1,7 @@ using CalamityMod.DataStructures; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; -using System; using System.Collections.Generic; using Terraria; using Terraria.Audio; @@ -110,9 +108,6 @@ namespace CalamityMod.Projectiles.Rogue return false; } public override bool? CanDamage() => Projectile.numHits == 0 ? null : false; - - // Fuck off stupid Vile Spits - public override bool? CanHitNPC(NPC target) => NPCID.Sets.ProjectileNPC[target.type] ? false : null; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.OnFire, 120); @@ -165,8 +160,8 @@ namespace CalamityMod.Projectiles.Rogue } } - public float WidthFunction(float completionRatio) => 0.4f; - public Color ColorFunction(float completionRatio) + public float WidthFunction(float completionRatio, Vector2 vertexPos) => 0.4f; + public Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeThreshold = 60f; float opacity = Projectile.numHits > 0 && Timer > fadeThreshold ? MathHelper.Lerp(0.75f, 0f, (Timer - fadeThreshold) / 30f) : 0.75f; diff --git a/Projectiles/Rogue/MycorootProj.cs b/Projectiles/Rogue/MycorootProj.cs index 681c6a2201..c826d6adac 100644 --- a/Projectiles/Rogue/MycorootProj.cs +++ b/Projectiles/Rogue/MycorootProj.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/MythrilKnifeProjectile.cs b/Projectiles/Rogue/MythrilKnifeProjectile.cs index 0e041f6aba..fc588544f4 100644 --- a/Projectiles/Rogue/MythrilKnifeProjectile.cs +++ b/Projectiles/Rogue/MythrilKnifeProjectile.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/NastyChollaBol.cs b/Projectiles/Rogue/NastyChollaBol.cs index 492b0a54db..82a59ad5dd 100644 --- a/Projectiles/Rogue/NastyChollaBol.cs +++ b/Projectiles/Rogue/NastyChollaBol.cs @@ -1,5 +1,5 @@ using System; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -7,6 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class NastyChollaBol : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/NiceCock.cs b/Projectiles/Rogue/NiceCock.cs deleted file mode 100644 index 51360e48a2..0000000000 --- a/Projectiles/Rogue/NiceCock.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System.IO; -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Rogue -{ - // The file name is a specific request from the patron - public class NiceCock : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public bool homing = false; - public int Timer = 0; - private bool initialized = false; - private Color[] colors = new Color[] - { - new Color(255, 0, 0, 50), //Red - new Color(255, 128, 0, 50), //Orange - new Color(255, 255, 0, 50), //Yellow - new Color(128, 255, 0, 50), //Lime - new Color(0, 255, 0, 50), //Green - new Color(0, 255, 128, 50), //Turquoise - new Color(0, 255, 255, 50), //Cyan - new Color(0, 128, 255, 50), //Light Blue - new Color(0, 0, 255, 50), //Blue - new Color(128, 0, 255, 50), //Purple - new Color(255, 0, 255, 50), //Fuschia - new Color(255, 0, 128, 50) //Hot Pink - }; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 5; - } - - public override void SetDefaults() - { - Projectile.width = 44; - Projectile.height = 70; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.timeLeft = 180; - Projectile.alpha = 255; - } - - public override void SendExtraAI(BinaryWriter writer) => writer.Write(homing); - - public override void ReceiveExtraAI(BinaryReader reader) => homing = reader.ReadBoolean(); - - public override bool? CanHitNPC(NPC target) - { - // Do not deal damage before fully opaque - if (Projectile.alpha >= 10) - return false; - int index = (int)Projectile.ai[1]; - if (Main.npc[index] is null || !Main.npc[index].active || Main.npc[index].life < 0) - return false; - // Do not deal damage to any NPC that isn't the specified target - if (index != target.whoAmI) - return false; - return null; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - // Fireballs disappear if you can't stealth strike - if (!modPlayer.wearingRogueArmor || modPlayer.rogueStealthMax <= 0) - Projectile.Kill(); - - Projectile.alpha -= 5; - - if (!initialized) - { - // Pick a random frame to start on - Projectile.frame = Main.rand.Next(Main.projFrames[Type]); - initialized = true; - } - - Projectile.frameCounter++; - if (Projectile.frameCounter > 8) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= Main.projFrames[Type]) - Projectile.frame = 0; - - int index = (int)Projectile.ai[1]; - - // If the target doesn't exist or is dead, spontaneously combust - if (Main.npc[index] is null || !Main.npc[index].active || Main.npc[index].life < 0) - Projectile.Kill(); - - // Decrement the timer. This should last a second as stealth strikes will initialize this at 61. - if (Timer > 1) - Timer--; - if (Timer == 1) - homing = true; - - NPC target = Main.npc[index]; - - if (homing) - { - // Home in on the target - Vector2 moveDirection = Projectile.SafeDirectionTo(target.Center, Vector2.UnitY); - Projectile.velocity = (Projectile.velocity * 20f + moveDirection * 15f) / 21f; - } - else - { - // Circle around the target counter-clockwise at 4 radians per frame - float height = target.getRect().Height; - float width = target.getRect().Width; - float circleDist = MathHelper.Min((height > width ? height : width) * 3f, (Main.LogicCheckScreenWidth * Main.LogicCheckScreenHeight) / 2); - if (circleDist > Main.LogicCheckScreenWidth / 3) - circleDist = Main.LogicCheckScreenWidth / 3; - Projectile.Center = target.Center + Projectile.ai[0].ToRotationVector2() * circleDist; - Projectile.ai[0] -= MathHelper.ToRadians(4f); - } - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - Projectile.ExpandHitboxBy(50); - - // Create into some rainbow-colored dust when dead - for (int d = 0; d < 5; d++) - { - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowMk2, 0f, 0f, 150, Main.rand.Next(colors), 2f); - Main.dust[idx].velocity *= 3f; - Main.dust[idx].noGravity = true; - if (Main.rand.NextBool()) - { - Main.dust[idx].scale = 0.5f; - Main.dust[idx].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 8; d++) - { - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowMk2, 0f, 0f, 150, Main.rand.Next(colors), 3f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 5f; - idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowMk2, 0f, 0f, 150, Main.rand.Next(colors), 2f); - Main.dust[idx].velocity *= 2f; - Main.dust[idx].noGravity = true; - } - } - } -} diff --git a/Projectiles/Rogue/NiceCock.png b/Projectiles/Rogue/NiceCock.png deleted file mode 100644 index 8881462c5c..0000000000 Binary files a/Projectiles/Rogue/NiceCock.png and /dev/null differ diff --git a/Projectiles/Rogue/NightsGazeProjectile.cs b/Projectiles/Rogue/NightsGazeProjectile.cs deleted file mode 100644 index 1676e41309..0000000000 --- a/Projectiles/Rogue/NightsGazeProjectile.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class NightsGazeProjectile : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/NightsGaze"; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 8; - ProjectileID.Sets.TrailingMode[Type] = 1; - } - - public override void SetDefaults() - { - Projectile.width = 20; - Projectile.height = 20; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 300; - Projectile.DamageType = RogueDamageClass.Instance; - } - - private int SplitProjDamage => (int)(Projectile.damage * 0.6f); - - public override void AI() - { - if (Projectile.ai[0] == 0f) - Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.ToRadians(45); - - if (Projectile.Calamity().stealthStrike) - { - if (Main.rand.NextBool(8)) - { - int projID = ModContent.ProjectileType(); - int starDamage = SplitProjDamage; - float starKB = 5f; - Vector2 velocity = Projectile.velocity; - - int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, projID, starDamage, starKB, Projectile.owner, 1f, 0f); - Main.projectile[p].penetrate = 1; - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), Projectile.timeLeft); - OnHitEffects(); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(ModContent.BuffType(), Projectile.timeLeft); - OnHitEffects(); - } - - private void OnHitEffects() - { - int onHitCount = 6; - int chanceOfStar = 2; - float spread = 20f; - int projectileDamage = SplitProjDamage; - float kb = 5f; - int sparkID = ModContent.ProjectileType(); - int starID = ModContent.ProjectileType(); - for (int i = 0; i < onHitCount; i++) - { - int projID = Main.rand.NextBool(chanceOfStar) ? starID : sparkID; - Vector2 velocity = Projectile.oldVelocity.RotateRandom(MathHelper.ToRadians(spread)); - float speed = Main.rand.NextFloat(1.5f, 2f); - float moveDuration = Main.rand.Next(5, 15); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * speed, projID, projectileDamage, kb, Projectile.owner, 0f, moveDuration); - } - - SoundEngine.PlaySound(SoundID.Item62 with { Volume = SoundID.Item62.Volume * 0.6f }, Projectile.position); - SoundEngine.PlaySound(SoundID.Item68 with { Volume = SoundID.Item68.Volume * 0.2f }, Projectile.position); - SoundEngine.PlaySound(SoundID.Item122 with { Volume = SoundID.Item122.Volume * 0.4f }, Projectile.position); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - SoundEngine.PlaySound(SoundID.Dig, Projectile.position); - Projectile.Kill(); - return false; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override void PostDraw(Color lightColor) - { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Rogue/NightsGazeGlow").Value; - Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / 2f); - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, 1f, SpriteEffects.None, 0); - } - - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 5; i++) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 109, - 111, - 132 - }); - - int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X / 3f, Projectile.velocity.Y / 3f, 0, default, 1.5f); - Main.dust[dust].noGravity = true; - } - } - } -} diff --git a/Projectiles/Rogue/NightsGazeSpark.cs b/Projectiles/Rogue/NightsGazeSpark.cs deleted file mode 100644 index a33e54ff06..0000000000 --- a/Projectiles/Rogue/NightsGazeSpark.cs +++ /dev/null @@ -1,102 +0,0 @@ - -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class NightsGazeSpark : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public static int lifetime = 150; - - public override void SetDefaults() - { - Projectile.width = 6; - Projectile.height = 6; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 5; - Projectile.timeLeft = lifetime; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.localAI[0] = 10f; - } - - public override void AI() - { - Projectile.rotation += Projectile.direction * Projectile.ai[0]; - - if (Projectile.timeLeft < (lifetime - Projectile.ai[1]) && Projectile.localAI[0] >= 0) - { - Projectile.velocity.Normalize(); - Projectile.velocity *= Projectile.localAI[0]; - Projectile.localAI[0]--; - } - - if (Projectile.localAI[0] == 0) - { - Projectile.Kill(); - } - - for (int i = 0; i < 3; i++) - { - float dustVelocity = Main.rand.NextFloat(0f, 0.5f); - int dustToUse = Main.rand.Next(0, 3); - int dustType = 0; - switch (dustToUse) - { - case 0: - dustType = 109; - break; - case 1: - dustType = 111; - break; - case 2: - dustType = 132; - break; - } - - int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= dustVelocity; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - Projectile.Kill(); - return false; - } - - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 5; i++) - { - int dustToUse = Main.rand.Next(0, 3); - int dustType = 0; - switch (dustToUse) - { - case 0: - dustType = 109; - break; - case 1: - dustType = 111; - break; - case 2: - dustType = 132; - break; - } - - int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 0.75f; - } - } - } -} diff --git a/Projectiles/Rogue/NightsGazeStar.cs b/Projectiles/Rogue/NightsGazeStar.cs deleted file mode 100644 index 69829d8f21..0000000000 --- a/Projectiles/Rogue/NightsGazeStar.cs +++ /dev/null @@ -1,132 +0,0 @@ - -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class NightsGazeStar : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public static int lifetime = 150; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 8; - ProjectileID.Sets.TrailingMode[Type] = 1; - } - - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 10; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 5; - Projectile.timeLeft = lifetime; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.localAI[0] = 10f; - } - - public override void AI() - { - Projectile.rotation += Projectile.direction * 0.05f; - - if (Projectile.ai[0] == 0f) - { - if (Projectile.timeLeft < (lifetime - Projectile.ai[1]) && Projectile.localAI[0] >= 0) - { - Projectile.velocity.Normalize(); - Projectile.velocity *= Projectile.localAI[0]; - Projectile.localAI[0]--; - } - else if (Projectile.timeLeft >= (lifetime - Projectile.ai[1])) - { - for (int i = 0; i < 3; i++) - { - float dustVelocity = Main.rand.NextFloat(0f, 0.5f); - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 109, - 111, - 132 - }); - - int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= dustVelocity; - } - } - } - else if (Projectile.ai[0] == 1f) - { - float minDist = 999f; - int index = 0; - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.CanBeChasedBy(Projectile, false)) - { - float dist = (Projectile.Center - npc.Center).Length(); - if (dist < minDist) - { - minDist = dist; - index = npc.whoAmI; - } - } - } - - if (minDist < 999f) - { - Vector2 velocityNew = Main.npc[index].Center - Projectile.Center; - float speed = 10f; - velocityNew.Normalize(); - Projectile.velocity = velocityNew * speed; - } - } - if (Projectile.soundDelay == 0) - { - Projectile.soundDelay = 20 + Main.rand.Next(40); - if (Main.rand.NextBool(5)) - { - SoundEngine.PlaySound(SoundID.Item9, Projectile.position); - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - Projectile.Kill(); - return false; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.White, 1); - return false; - } - - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 5; i++) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 109, - 111, - 132 - }); - - int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); - Main.dust[dust].noGravity = true; - } - } - } -} diff --git a/Projectiles/Rogue/PalladiumJavelinProjectile.cs b/Projectiles/Rogue/PalladiumJavelinProjectile.cs index 515e6f14b1..ff48cd70d1 100644 --- a/Projectiles/Rogue/PalladiumJavelinProjectile.cs +++ b/Projectiles/Rogue/PalladiumJavelinProjectile.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Items.Weapons.Rogue; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; @@ -32,7 +30,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4; //Stealth strike behavior - if (!Projectile.Calamity().stealthStrike || Projectile.owner != Main.myPlayer || Projectile.Calamity().lineColor >= 2) + if (!Projectile.Calamity().stealthStrike || Projectile.owner != Main.myPlayer || Projectile.ai[2] >= 2) return; Projectile.localAI[0]++; if (Projectile.localAI[0] >= 12f) @@ -49,18 +47,13 @@ namespace CalamityMod.Projectiles.Rogue Dust.NewDust(Projectile.Center - vector2 / 2f, (int)vector2.X, (int)vector2.Y, DustID.Palladium, 0f, 0f, 0, default, 1f); } - int javelin = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.ToRadians(3f)), Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner); - int javelin2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.ToRadians(-3f)), Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner); + int javelin = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.ToRadians(3f)), Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, ai2: Projectile.ai[2] + 1); + int javelin2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedBy(MathHelper.ToRadians(-3f)), Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, ai2: Projectile.ai[2] + 1); if (javelin.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[javelin].Calamity().lineColor = Projectile.Calamity().lineColor + 1; Main.projectile[javelin].Calamity().stealthStrike = true; - } if (javelin2.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[javelin2].Calamity().lineColor = Projectile.Calamity().lineColor + 1; Main.projectile[javelin2].Calamity().stealthStrike = true; - } + Projectile.Kill(); } } diff --git a/Projectiles/Rogue/PanSpark.cs b/Projectiles/Rogue/PanSpark.cs deleted file mode 100644 index 941dae41cc..0000000000 --- a/Projectiles/Rogue/PanSpark.cs +++ /dev/null @@ -1,139 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class PanSpark : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - private bool initialized = false; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 3; - ProjectileID.Sets.TrailCacheLength[Type] = 2; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 14; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.timeLeft = 120; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.ignoreWater = true; - } - - public override void AI() - { - //make it face the way it's going - if (Projectile.ai[1] > 0f) - { - Projectile.rotation = -Projectile.velocity.X * 0.05f + MathHelper.PiOver2; - } - else - { - Projectile.rotation = Projectile.velocity.ToRotation(); - } - Projectile.ai[1]--; - - //frames - if (!initialized) - { - initialized = true; - Projectile.frame = Main.rand.Next(Main.projFrames[Type]); - } - Projectile.frameCounter++; - if (Projectile.frameCounter > 6) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= Main.projFrames[Type]) - { - Projectile.frame = 0; - } - - //movement - if (Projectile.velocity.X != Projectile.velocity.X) - { - Projectile.velocity.X *= -0.1f; - } - if (Projectile.velocity.X != Projectile.velocity.X) - { - Projectile.velocity.X *= -0.5f; - } - if (Projectile.velocity.Y != Projectile.velocity.Y && Projectile.velocity.Y > 1f) - { - Projectile.velocity.Y *= -0.5f; - } - Projectile.ai[0] += 1f; - if (Projectile.ai[0] > 5f) - { - Projectile.ai[0] = 5f; - if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f) - { - Projectile.velocity.X *= 0.97f; - if (Projectile.velocity.X > -0.01f && Projectile.velocity.X < 0.01f) - { - Projectile.velocity.X = 0f; - Projectile.netUpdate = true; - } - } - Projectile.velocity.Y += 0.2f; - } - if (Projectile.velocity.Y < 0.25f && Projectile.velocity.Y > 0.15f) - { - Projectile.velocity.X *= 0.8f; - } - if (Projectile.velocity.Y > 16f) - { - Projectile.velocity.Y = 16f; - } - - //dust - if (Main.rand.NextBool(4)) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[fire]; - dust.position.X -= 2f; - dust.position.Y += 2f; - dust.scale += (float)Main.rand.Next(50) * 0.01f; - dust.noGravity = true; - dust.velocity.Y -= 2f; - } - if (Main.rand.NextBool(10)) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); - Dust dust = Main.dust[fire]; - dust.position.X -= 2f; - dust.position.Y += 2f; - dust.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f; - dust.noGravity = true; - dust.velocity *= 0.1f; - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.ai[1] = 10f; - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Daybreak, 90); - - public override Color? GetAlpha(Color lightColor) => new Color(255, 230, 130); - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Rogue/PanSpark.png b/Projectiles/Rogue/PanSpark.png deleted file mode 100644 index c74b2ed1a7..0000000000 Binary files a/Projectiles/Rogue/PanSpark.png and /dev/null differ diff --git a/Projectiles/Rogue/PenumbraBomb.cs b/Projectiles/Rogue/PenumbraBomb.cs index 3ecbfb63bd..2778a1a68b 100644 --- a/Projectiles/Rogue/PenumbraBomb.cs +++ b/Projectiles/Rogue/PenumbraBomb.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -54,7 +53,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.alpha = 10; //Rotation Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = (Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi)) + (MathHelper.ToRadians(180) * Projectile.direction); + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + (MathHelper.ToRadians(180) * Projectile.direction); //Dust float dfreq = Projectile.Calamity().stealthStrike ? 8f : 4f; @@ -81,27 +80,24 @@ namespace CalamityMod.Projectiles.Rogue } public override void OnKill(int timeLeft) { - //Dark soul projectiles - int ad = Projectile.Calamity().stealthStrike ? 40 : 60; - float dmgMult = Projectile.Calamity().stealthStrike ? 0.08f : 0.15f; - int randrot = Main.rand.Next(-30, 31); - for (int i = 0; i < 360; i += ad) + // Dark soul projectiles + int projAmt = Projectile.Calamity().stealthStrike ? 8 : 6; + for (int i = 0; i < projAmt; i++) { - Vector2 SoulSpeed = new Vector2(13f, 13f).RotatedBy(MathHelper.ToRadians(i + randrot)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, SoulSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * dmgMult), 3f, Projectile.owner, 0f, 0f); + Vector2 SoulSpeed = Vector2.UnitX.RotatedBy(MathHelper.TwoPi * i / projAmt) * 13f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, SoulSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15f), 3f, Projectile.owner, 0f, 0f); } - //Dust + + // Dust int maxDust = Projectile.Calamity().stealthStrike ? 100 : 70; for (int i = 0; i < maxDust; i++) { Vector2 dustspeed = new Vector2(Main.rand.NextFloat(-6f, 6f), Main.rand.NextFloat(-6f, 6f)); - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Wraith, dustspeed.X, dustspeed.Y, 0, new Color(38, 30, 43), 1.6f); + Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Wraith, dustspeed.X, dustspeed.Y, 0, new Color(38, 30, 43), 1.6f); } + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - Projectile.width = 110; - Projectile.height = 110; - Projectile.position.X = Projectile.position.X - (Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (Projectile.height / 2); + Projectile.ExpandHitboxBy(110); Projectile.maxPenetrate = -1; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; @@ -115,7 +111,5 @@ namespace CalamityMod.Projectiles.Rogue CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Blackout, 300); } } diff --git a/Projectiles/Rogue/PenumbraSoul.cs b/Projectiles/Rogue/PenumbraSoul.cs index a942a55356..bb272dbe50 100644 --- a/Projectiles/Rogue/PenumbraSoul.cs +++ b/Projectiles/Rogue/PenumbraSoul.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Weapons.Rogue; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -20,32 +19,26 @@ namespace CalamityMod.Projectiles.Rogue { Projectile.height = 18; Projectile.width = 18; - Projectile.timeLeft = 150; Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; Projectile.tileCollide = false; Projectile.ignoreWater = true; - Projectile.DamageType = RogueDamageClass.Instance; + Projectile.timeLeft = 240; Projectile.alpha = 80; - - Projectile.penetrate = 2; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; Projectile.extraUpdates = 1; + DrawOffsetX = 1; + DrawOriginOffsetY = 4; } public override void AI() { Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - DrawOffsetX = 1; - DrawOriginOffsetY = 4; // Continuously trail dust int trailDust = 1; for (int i = 0; i < trailDust; ++i) { - int dustID = 54; //Used by Wraiths and other shadowy stuff - - int idx = Dust.NewDust(Projectile.position - Projectile.velocity, Projectile.width, Projectile.height, dustID, 0f, 0f, 0, new Color(38, 30, 43)); + int idx = Dust.NewDust(Projectile.position - Projectile.velocity, Projectile.width, Projectile.height, DustID.Wraith, 0f, 0f, 0, new Color(38, 30, 43)); Main.dust[idx].noGravity = true; Main.dust[idx].velocity += Projectile.velocity * 0.8f; } @@ -54,14 +47,20 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.ai[0] > 0f) Projectile.ai[0] -= 1f; - // Home in on nearby enemies if homing is enabled - if (Projectile.ai[1] == 0f) - HomingAI(); + // Home in on nearby enemies + CalamityUtils.HomeInOnNPC(Projectile, true, 400f, 12f, 35f); } - private void HomingAI() + public override void OnKill(int timeLeft) { - CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 12f, 35f); + // Create a burst of dust + int dustAmt = Main.rand.Next(30, 41); + for (int i = 0; i < dustAmt; i++) + { + int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Wraith, 0f, 0f, 0, new Color(38, 30, 43), Main.rand.NextFloat(1f, 1.8f)); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= Main.rand.NextFloat(2f, 3.1f); + } } public override bool PreDraw(ref Color lightColor) @@ -69,48 +68,5 @@ namespace CalamityMod.Projectiles.Rogue CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - // Rapidly screech to a halt upon touching an enemy and disable homing. - Projectile.velocity *= 0.4f; - Projectile.ai[1] = 1f; - - // Fade out a bit with every hit - Projectile.alpha += 20; - if (Projectile.alpha > 255) - Projectile.alpha = 255; - - // Explode into dust (as if being shredded apart on contact) - int onHitDust = Main.rand.Next(6, 11); - for (int i = 0; i < onHitDust; ++i) - { - int dustID = 54; - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustID, 0f, 0f, 0, new Color(38, 30, 43)); - - Main.dust[idx].noGravity = true; - float speed = Main.rand.NextFloat(1.4f, 2.6f); - Main.dust[idx].velocity *= speed; - float scale = Main.rand.NextFloat(1.0f, 1.8f); - Main.dust[idx].scale = scale; - } - } - - public override void OnKill(int timeLeft) - { - // Create a burst of dust - int killDust = Main.rand.Next(30, 41); - for (int i = 0; i < killDust; ++i) - { - int dustID = 54; - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustID, 0f, 0f, 0, new Color(38, 30, 43)); - - Main.dust[idx].noGravity = true; - float speed = Main.rand.NextFloat(2.0f, 3.1f); - Main.dust[idx].velocity *= speed; - float scale = Main.rand.NextFloat(1.0f, 1.8f); - Main.dust[idx].scale = scale; - } - } } } diff --git a/Projectiles/Rogue/PhantasmalRuinProj.cs b/Projectiles/Rogue/PhantasmalRuinProj.cs index e0b8e583db..3adb2f5387 100644 --- a/Projectiles/Rogue/PhantasmalRuinProj.cs +++ b/Projectiles/Rogue/PhantasmalRuinProj.cs @@ -1,6 +1,4 @@ -using CalamityMod.Projectiles.Melee; -using Microsoft.Xna.Framework; -using Mono.Cecil; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -108,8 +106,8 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 8; i += 2) { // d, du, dus, dust :) - Dust du = Dust.NewDustPerfect(Projectile.Center, 180, velocity, 0, default, Main.rand.NextFloat(1.1f, 1.4f)); - Dust dus = Dust.NewDustPerfect(Projectile.Center, 180, -velocity, 0, default, Main.rand.NextFloat(1.1f, 1.4f)); + Dust du = Dust.NewDustPerfect(Projectile.Center, DustID.DungeonSpirit, velocity, 0, default, Main.rand.NextFloat(1.1f, 1.4f)); + Dust dus = Dust.NewDustPerfect(Projectile.Center, DustID.DungeonSpirit, -velocity, 0, default, Main.rand.NextFloat(1.1f, 1.4f)); du.noGravity = true; dus.noGravity = true; // Rotate direction for the next dust. diff --git a/Projectiles/Rogue/PhantasmalSoulBlue.cs b/Projectiles/Rogue/PhantasmalSoulBlue.cs index a8d0612531..19e2cb17d8 100644 --- a/Projectiles/Rogue/PhantasmalSoulBlue.cs +++ b/Projectiles/Rogue/PhantasmalSoulBlue.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Weapons.Melee; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Rogue/PlaguedFuelPackCloud.cs b/Projectiles/Rogue/PlaguedFuelPackCloud.cs index a543c97c8b..802a3a9265 100644 --- a/Projectiles/Rogue/PlaguedFuelPackCloud.cs +++ b/Projectiles/Rogue/PlaguedFuelPackCloud.cs @@ -8,28 +8,39 @@ namespace CalamityMod.Projectiles.Rogue public class PlaguedFuelPackCloud : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; + public int dir = 0; + public float intensity = 0; + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + } public override void SetDefaults() { Projectile.width = 28; Projectile.height = 24; Projectile.friendly = true; Projectile.alpha = 0; - Projectile.penetrate = -1; - Projectile.tileCollide = true; + Projectile.penetrate = 1; + Projectile.tileCollide = false; Projectile.ignoreWater = true; - Projectile.timeLeft = 120; + Projectile.timeLeft = 390; + Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; + Projectile.localNPCHitCooldown = -1; Projectile.DamageType = RogueDamageClass.Instance; - Projectile.ArmorPenetration = 5; + Projectile.ArmorPenetration = 10; } public override void AI() { if (Projectile.timeLeft < 50) Projectile.alpha += 5; - if (Projectile.timeLeft < 75) - Projectile.velocity *= 0.95f; + if (dir == 0) + { + Projectile.timeLeft -= Main.rand.Next(5, 20 + 1); + dir = Main.rand.NextBool() ? -1 : 1; + intensity = Main.rand.NextFloat(0.2f, 1.2f); + } if (Main.rand.NextBool(150)) { @@ -38,6 +49,11 @@ namespace CalamityMod.Projectiles.Rogue Main.dust[dust].velocity *= 1.2f; Main.dust[dust].velocity.Y -= 0.15f; } + + if (Projectile.timeLeft < 290) + CalamityUtils.HomeInOnSelectedNPC(Projectile, Projectile.Center.ClosestNPCAt(1000), true, 0.65f * intensity, 6, 0.98f, 0.995f, true); + else + Projectile.velocity = Projectile.velocity.RotatedBy(0.006f * dir * intensity) * Main.rand.NextFloat(0.985f, 1f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); diff --git a/Projectiles/Rogue/PrismShurikenBlade.cs b/Projectiles/Rogue/PrismShurikenBlade.cs index fe3d80d954..4e57a9d8d1 100644 --- a/Projectiles/Rogue/PrismShurikenBlade.cs +++ b/Projectiles/Rogue/PrismShurikenBlade.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using CalamityMod.Particles; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/PumkaboomBoomBig.cs b/Projectiles/Rogue/PumkaboomBoomBig.cs new file mode 100644 index 0000000000..419c8f5544 --- /dev/null +++ b/Projectiles/Rogue/PumkaboomBoomBig.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Rogue +{ + public class PumpkaboomBoomBig : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 40; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.ignoreWater = false; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 230, targetHitbox); + } +} diff --git a/Projectiles/Rogue/PumkaboomBoomSmall.cs b/Projectiles/Rogue/PumkaboomBoomSmall.cs new file mode 100644 index 0000000000..fee73fab79 --- /dev/null +++ b/Projectiles/Rogue/PumkaboomBoomSmall.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Rogue +{ + public class PumpkaboomBoomSmall : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 40; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.ignoreWater = false; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 170, targetHitbox); + } +} diff --git a/Projectiles/Rogue/PumpkaboomBig.cs b/Projectiles/Rogue/PumpkaboomBig.cs new file mode 100644 index 0000000000..2bfe1f2e96 --- /dev/null +++ b/Projectiles/Rogue/PumpkaboomBig.cs @@ -0,0 +1,418 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Projectiles.Rogue +{ + [PierceResistException] + public class PumpkaboomBig : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/Rogue/PumpkaboomBig"; + + public float time = 0; + public ref float stuckNPC => ref Projectile.ai[2]; + public ref float stuckState => ref Projectile.ai[1]; + public ref float flungState => ref Projectile.ai[0]; + public Player Owner => Main.player[Projectile.owner]; + public int tileHits = 0; + public float charge = 0; + public bool hasReachedFullCharge = false; + public bool hasStoppedHolding = false; + public float midAirRot = 0; + public int initialCastDirection = 0; + + Vector2 placementDistance; + Vector2 placementVelocity; + + private bool beginStretchAnim = false; + private float progress = -1; + + public Color mainColor = Color.White; + public Color c1 = new Color(255, 117, 24); + public Color c2 = new Color(168, 47, 57); + private bool hasDealtDamage = false; + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + + Projectile.timeLeft = 1200; + Projectile.DamageType = RogueDamageClass.Instance; + } + + public override bool ShouldUpdatePosition() => flungState != 0f && stuckState == 0f; + public override bool? CanDamage() => (flungState != 0f && tileHits == 0 ? null : false); + + public override bool? CanHitNPC(NPC target) + { + if (hasDealtDamage) + return false; + + return null; + } + + public override void AI() + { + float rate = (Main.GlobalTimeWrappedHourly * 6); + List eColors = new List() { c1, c2 }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + mainColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + // Progress through squash n stretch anim on hit + if (progress >= 0f && progress < 1f) + { + progress += 0.08f; + } + +            // When an NPC is hit by the bomb, stick to it. + if (stuckState == 1f) + { + if (stuckNPC >= 0 && Main.npc[(int) stuckNPC].active) + Projectile.Center = Main.npc[(int) stuckNPC].Center + placementVelocity * placementDistance; + + else if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.Kill(); + + if (Projectile.timeLeft == 109) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/PumpkaboomStealthTicking") with { Pitch = 0f, Volume = 1f, MaxInstances = 4 }, Projectile.Center); + } + + if (Projectile.timeLeft < 110) + { + // Pull in small NPCs + float pullStrength = 9f; + float centerShift = 1f; + float maxPullDistance = 240f; + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + if (target != null && target.active && target.CanBeMoved(true) && Collision.CanHit(Projectile.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(target.Center, Projectile.Center) < maxPullDistance) + { + if (target.whoAmI == stuckNPC) + continue; + + Vector2 moveDir = target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX); + target.velocity = Vector2.Lerp(target.velocity, moveDir * pullStrength, 0.15f); + target.Center += moveDir * centerShift; + } + } + if (Main.rand.NextBool(3)) + { + Vector2 dustVel2 = (Vector2.UnitX).RotatedByRandom(100) * Main.rand.NextFloat(9.5f, 13f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel2.SafeNormalize(Vector2.UnitX) * 160, ModContent.DustType(), -dustVel2 * 1.2f, 0, default, Main.rand.NextFloat(0.9f, 1.4f)); + dust2.noGravity = true; + dust2.fadeIn = 0.8f; + dust2.color = c1; + } + } + return; + } + + if (flungState != 0f) + { + if (initialCastDirection == 0) + initialCastDirection = Owner.direction; + + // stuckNPC index + Projectile.localAI[0]++; + Projectile.localAI[1] = 5; // The item can be used again once flung. + + Projectile.velocity.Y += 0.22f; + + if (stuckState == 0f) + midAirRot += 0.03f * initialCastDirection; + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 + midAirRot; + } + + // While in hand + else + { + Projectile.velocity = Owner.velocity; + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); + + if (Main.myPlayer == Projectile.owner) + { + if (completion >= 1 || hasReachedFullCharge) + { + time = -1; + Projectile.Center = Owner.Center; + Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + Projectile.velocity = velocity * 16; + Projectile.tileCollide = true; + flungState = 1f; + Projectile.netUpdate = true; + } + else + { + if (Main.mouseLeft && !hasStoppedHolding) + { + if (completion >= 0.7f && completion <= 0.8f) + { + time--; + if (charge < 1) + charge += 0.5f; + + if (charge >= 1 && !hasReachedFullCharge) + { + SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); + hasReachedFullCharge = true; + } + } + } + else + { + if (!hasReachedFullCharge) + { + Projectile.localAI[1] = 5; + flungState = -1f; + Projectile.Kill(); + } + hasStoppedHolding = true; + } + } + + Owner.direction = Math.Sign(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).X); + } + + float grenadeRot = 0; + if (completion >= 0.7f) + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); + } + else + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + } + + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : -3, Owner.direction == 1 ? -24 : -4).RotatedBy(grenadeRot); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + + Projectile.Center = grenadePos; + Projectile.rotation = grenadeRot - MathHelper.ToRadians(25 * grenadeHalfRot) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, mouseDir.ToRotation() - MathHelper.ToRadians(90)); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, grenadeRot - (Owner.direction == 1 ? MathHelper.ToRadians(180) : MathHelper.ToRadians(0))); + } + time++; + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + stuckState = 1f; + stuckNPC = target.whoAmI; + Projectile.localAI[1] = 5; + beginStretchAnim = true; + Projectile.netUpdate = true; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + SoundStyle w = new("CalamityMod/Sounds/Item/WulfrumScrewdriverThud"); + SoundEngine.PlaySound(w with { Volume = 0.7f, Pitch = 0f, MaxInstances = 6 }, Projectile.Center); + + stuckState = 1f; + stuckNPC = target.whoAmI; + + placementDistance = new(-Vector2.Distance(target.Center, Projectile.Center)); + placementVelocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); + + Projectile.velocity = Vector2.Zero; + Projectile.tileCollide = false; + Projectile.rotation = Projectile.oldVelocity.ToRotation() + MathHelper.PiOver2 + midAirRot; + flungState = Projectile.rotation; + + hasDealtDamage = true; + Projectile.localAI[1] = 5; + Projectile.timeLeft = 110; + + for (int i = 0; i < 6; i++) + { + int sparkLifetime = Main.rand.Next(13, 22); + float sparkScale = Main.rand.NextFloat(0.55f, 1.1f); + Color sparkColor = Main.rand.NextBool() ? c1 : c2; + + Vector2 burstDirection = Projectile.oldVelocity + new Vector2(Main.rand.NextFloat(-2.25f, 2.25f), Main.rand.NextFloat(-6.75f, 6.75f)); + Vector2 spawnPos = target.Center + burstDirection * target.width * 0.15f; + Vector2 sparkVelocity = burstDirection * Main.rand.NextFloat(0.7f, 1.3f); + + if (Main.rand.NextBool()) + { + AltSparkParticle spark = new AltSparkParticle(spawnPos, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + + else + { + LineParticle spark = new LineParticle(spawnPos, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } + Projectile.netUpdate = true; + } + + public override void OnKill(int timeLeft) + { + Projectile.localAI[1] = 5; // Reset firing state + if (flungState != -1f) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/PumpkinExplode1") with { Pitch = 0f, Volume = 0.75f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") with { Pitch = 0f, Volume = 0.6f }, Projectile.Center); + + if (Main.myPlayer == Projectile.owner) + { + Owner.SetScreenshake(5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 2, Projectile.owner, 0); + } + + float scale = 0.18f; + Vector2 spawnPos = Projectile.Center; + Particle blastRing = new CustomPulse(spawnPos, Vector2.Zero, c1, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0.07f, scale, 10); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(spawnPos, Vector2.Zero, c1 * 0.33f, "CalamityMod/Particles/HighResHollowCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10, 10), 0.07f, scale * 1.66f, 11); + GeneralParticleHandler.SpawnParticle(blastRing2); + for (int k = 0; k < 16; k++) + { + Vector2 velocity = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.7f, 1.3f); + Particle spark = new SparkParticle(Projectile.Center + velocity, velocity, false, 45, Main.rand.NextFloat(0.95f, 1.35f), c1); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int k = 0; k < 30; k++) + { + Vector2 velocity = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.2f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + velocity, DustID.SolarFlare, velocity); + dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); + dust2.noGravity = true; + } + } + + Projectile.netUpdate = true; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 21, targetHitbox); + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overPlayers.Add(index); + } + + public override bool PreDraw(ref Color lightColor) + { + if (beginStretchAnim) + { + progress = 0f; + beginStretchAnim = false; + } + + if (progress >= 0f) + { + float stretchFactorX, stretchFactorY; + + if (progress < 0.5f) // Stretch + { + float completion = progress / 0.5f; + stretchFactorX = MathHelper.Lerp(1.7f, 0.7f, completion); + stretchFactorY = MathHelper.Lerp(0.7f, 1.7f, completion); + } + else // Squash + { + float completion = (progress - 0.5f) / 0.5f; + stretchFactorX = MathHelper.Lerp(0.7f, 1f, completion); + stretchFactorY = MathHelper.Lerp(1.7f, 1f, completion); + } + + if (progress >= 1f) + { + stretchFactorX = 1f; + stretchFactorY = 1f; + progress = -1f; + } + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 origin = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f); + Vector2 finalSyringeScale = new Vector2(stretchFactorX, stretchFactorY); + Vector2 finalPos = Projectile.Center - Main.screenPosition; + + Main.spriteBatch.Draw(texture, finalPos, null, lightColor, Projectile.rotation, origin, finalSyringeScale, SpriteEffects.None, 0f); + + return false; + } + + + Texture2D mainTexture = ModContent.Request(Texture).Value; + SpriteEffects spriteEffects = SpriteEffects.None; + + Vector2 drawOrigin = mainTexture.Size() / 2f; + float drawScale = Projectile.scale; + float drawRotation = Projectile.rotation; + Vector2 drawPosition; + + if (stuckState == 1f && Projectile.timeLeft <= 110) + { + float glowSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 25f); + float pulse = MathHelper.Lerp(0.7f, 1f, glowSine); + float lifeFadeIn = Utils.GetLerpValue(110, 0, Projectile.timeLeft, true); + float finalGlowIntensity = pulse * lifeFadeIn; + drawPosition = Projectile.Center - Main.screenPosition; + for (int i = 0; i < 20; i++) + { + float rotationOffset = (MathHelper.TwoPi * i / 15); + Vector2 glowOffset = rotationOffset.ToRotationVector2() * (3f + glowSine * 1f) * finalGlowIntensity; + + Main.spriteBatch.Draw(mainTexture, drawPosition + glowOffset, null, mainColor with { A = 0 } * finalGlowIntensity * 0.4f, flungState, drawOrigin, drawScale, spriteEffects, 0f); + } + } + + if (flungState == 0f) + { + spriteEffects = SpriteEffects.FlipVertically; + + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + float grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : 5, Owner.direction == 1 ? -38 : 22).RotatedBy(grenadeRot); + drawPosition = grenadePos - Main.screenPosition; + drawRotation = grenadeRot - MathHelper.ToRadians(25 * completionLerp2) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + } + else + { + if (stuckState == 1f) + drawRotation = flungState; + drawPosition = Projectile.Center - Main.screenPosition; + } + + // Draw it + Main.spriteBatch.Draw(mainTexture, drawPosition, null, lightColor * (1f - Projectile.alpha / 255f), drawRotation, drawOrigin, drawScale, spriteEffects, 0f); + + return false; + } + } +} diff --git a/Projectiles/Rogue/PumpkaboomBig.png b/Projectiles/Rogue/PumpkaboomBig.png new file mode 100644 index 0000000000..70cf124970 Binary files /dev/null and b/Projectiles/Rogue/PumpkaboomBig.png differ diff --git a/Projectiles/Rogue/PumpkaboomSmall.cs b/Projectiles/Rogue/PumpkaboomSmall.cs new file mode 100644 index 0000000000..19708ea60b --- /dev/null +++ b/Projectiles/Rogue/PumpkaboomSmall.cs @@ -0,0 +1,383 @@ +using System; +using System.Collections.Generic; +using CalamityMod.NPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + [PierceResistException] + public class PumpkaboomSmall : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Pumpkaboom"; + + public float time = 0; + public ref float stuckNPC => ref Projectile.ai[2]; + public ref float stuckState => ref Projectile.ai[1]; + public ref float flungState => ref Projectile.ai[0]; + public Player Owner => Main.player[Projectile.owner]; + public int tileHits = 0; + public float charge = 0; + public bool hasReachedFullCharge = false; + public bool hasStoppedHolding = false; + public float midAirRot = 0; + public int initialCastDirection = 0; + + Vector2 placementDistance; + Vector2 placementVelocity; + + private bool beginStretchAnim = false; + private float progress = -1; + + public Color mainColor = Color.White; + public Color c1 = new Color(255, 117, 24); + public Color c2 = new Color(168, 47, 57); + private bool hasDealtDamage = false; + + public override void SetDefaults() + { + Projectile.width = 26; + Projectile.height = 34; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + Projectile.timeLeft = 1200; + Projectile.DamageType = RogueDamageClass.Instance; + } + + public override bool ShouldUpdatePosition() => flungState != 0f && stuckState == 0f; + public override bool? CanDamage() => (flungState != 0f && tileHits == 0 ? null : false); + + public override bool? CanHitNPC(NPC target) + { + if (hasDealtDamage) + return false; + + return null; + } + + public override void AI() + { + float rate = (Main.GlobalTimeWrappedHourly * 6); + List eColors = new List() { c1, c2 }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + mainColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + // Progress through squash n stretch anim on hit + if (progress >= 0f && progress < 1f) + { + progress += 0.08f; + } + + if (stuckState == 1f) + { + if (stuckNPC >= 0 && Main.npc[(int) stuckNPC].active) + { + Projectile.Center = Main.npc[(int) stuckNPC].Center + placementVelocity * placementDistance; + } + + else if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.Kill(); + if (Projectile.timeLeft == 109) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/PumpkaboomNormalTicking") with { Pitch = 0f, Volume = 1f, MaxInstances = 4 }, Projectile.Center); + } + return; + } + + if (flungState != 0f) + { + if (initialCastDirection == 0) + initialCastDirection = Owner.direction; + + // stuckNPC index + Projectile.localAI[0]++; + Projectile.localAI[1] = 5; // The item can be used again once flung. + + Projectile.velocity.Y += 0.22f; + + if (stuckState == 0f) + midAirRot += 0.06f * initialCastDirection; + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 + midAirRot; + } + + // While in hand + else + { + Projectile.velocity = Owner.velocity; + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); + + if (Main.myPlayer == Projectile.owner) + { + if (completion >= 1 || hasReachedFullCharge) + { + time = -1; + Projectile.Center = Owner.Center; + Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + Projectile.velocity = velocity * 16; + Projectile.tileCollide = true; + flungState = 1f; + Projectile.netUpdate = true; + } + else + { + if (Main.mouseLeft && !hasStoppedHolding) + { + if (completion >= 0.7f && completion <= 0.8f) + { + time--; + if (charge < 1) + charge += 0.5f; + + if (charge >= 1 && !hasReachedFullCharge) + { + SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); + hasReachedFullCharge = true; + } + } + } + else + { + if (!hasReachedFullCharge) + { + Projectile.localAI[1] = 5; + flungState = -1f; + Projectile.Kill(); + } + hasStoppedHolding = true; + } + } + Owner.direction = Math.Sign(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).X); + } + + float grenadeRot = 0; + if (completion >= 0.7f) + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); + } + else + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + } + + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : -3, Owner.direction == 1 ? -24 : -4).RotatedBy(grenadeRot); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + + Projectile.Center = grenadePos; + Projectile.rotation = grenadeRot - MathHelper.ToRadians(25 * grenadeHalfRot) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + + Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, mouseDir.ToRotation() - MathHelper.ToRadians(90)); + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, grenadeRot - (Owner.direction == 1 ? MathHelper.ToRadians(180) : MathHelper.ToRadians(0))); + } + time++; + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + stuckState = 1f; + stuckNPC = target.whoAmI; + Projectile.localAI[1] = 5; + beginStretchAnim = true; + Projectile.netUpdate = true; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + SoundStyle w = new("CalamityMod/Sounds/Item/WulfrumScrewdriverThud"); + SoundEngine.PlaySound(w with { Volume = 0.7f, Pitch = 0f, MaxInstances = 6 }, Projectile.Center); + + stuckState = 1f; + stuckNPC = target.whoAmI; + + placementDistance = new(-Vector2.Distance(target.Center, Projectile.Center)); + placementVelocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); + + Projectile.velocity = Vector2.Zero; + Projectile.tileCollide = false; + Projectile.rotation = Projectile.oldVelocity.ToRotation() + MathHelper.PiOver2 + midAirRot; + flungState = Projectile.rotation; + + hasDealtDamage = true; + Projectile.localAI[1] = 5; + Projectile.timeLeft = 110; + Projectile.netUpdate = true; + + for (int i = 0; i < 4; i++) + { + int sparkLifetime = Main.rand.Next(11, 19); + float sparkScale = Main.rand.NextFloat(0.5f, 1f); + Color sparkColor = Main.rand.NextBool() ? c1 : c2; + + Vector2 burstDirection = Projectile.oldVelocity + new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-6f, 6f)); + Vector2 spawnPos = target.Center + burstDirection * target.width * 0.15f; + Vector2 sparkVelocity = burstDirection * Main.rand.NextFloat(0.7f, 1.3f); + + if (Main.rand.NextBool()) + { + AltSparkParticle spark = new AltSparkParticle(spawnPos, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + + else + { + LineParticle spark = new LineParticle(spawnPos, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + + public override void OnKill(int timeLeft) + { + Projectile.localAI[1] = 5; // Reset firing state + + if (flungState != -1f) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/PumpkinExplode1") with { Pitch = 0f, Volume = 0.75f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") with { Pitch = 0f, Volume = 0.4f }, Projectile.Center); + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack * 2, Projectile.owner, 0); + + float scale = 0.1f; + Vector2 spawnPos = Projectile.Center; + Particle blastRing = new CustomPulse(spawnPos, Vector2.Zero, c1, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0.07f, scale, 10); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(spawnPos, Vector2.Zero, c1 * 0.33f, "CalamityMod/Particles/HighResHollowCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10, 10), 0.07f, scale * 1.66f, 11); + GeneralParticleHandler.SpawnParticle(blastRing2); + for (int k = 0; k < 8; k++) + { + Vector2 velocity = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.66f, 1f); + Particle spark = new SparkParticle(Projectile.Center + velocity, velocity, false, 24, Main.rand.NextFloat(0.75f, 1.15f), c1); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int k = 0; k < 20; k++) + { + Vector2 velocity = new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.2f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + velocity, DustID.SolarFlare, velocity); + dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); + dust2.noGravity = true; + } + } + + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 18, targetHitbox); + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overPlayers.Add(index); + } + + public override bool PreDraw(ref Color lightColor) + { + if (beginStretchAnim) + { + progress = 0f; + beginStretchAnim = false; + } + + if (progress >= 0f) + { + float stretchFactorX, stretchFactorY; + + if (progress < 0.5f) // Stretch + { + float completion = progress / 0.5f; + stretchFactorX = MathHelper.Lerp(1.7f, 0.7f, completion); + stretchFactorY = MathHelper.Lerp(0.7f, 1.7f, completion); + } + else // Squash + { + float completion = (progress - 0.5f) / 0.5f; + stretchFactorX = MathHelper.Lerp(0.7f, 1f, completion); + stretchFactorY = MathHelper.Lerp(1.7f, 1f, completion); + } + + if (progress >= 1f) + { + stretchFactorX = 1f; + stretchFactorY = 1f; + progress = -1f; + } + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 origin = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f); + Vector2 finalSyringeScale = new Vector2(stretchFactorX, stretchFactorY); + Vector2 finalPos = Projectile.Center - Main.screenPosition; + + Main.spriteBatch.Draw(texture, finalPos, null, lightColor, Projectile.rotation, origin, finalSyringeScale, SpriteEffects.None, 0f); + + return false; + } + + + Texture2D mainTexture = ModContent.Request(Texture).Value; + SpriteEffects spriteEffects = SpriteEffects.None; + + Vector2 drawOrigin = mainTexture.Size() / 2f; + float drawScale = Projectile.scale; + float drawRotation = Projectile.rotation; + Vector2 drawPosition; + + if (stuckState == 1f && Projectile.timeLeft <= 110) + { + float glowSine = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 20f); + float pulse = MathHelper.Lerp(0.7f, 1f, glowSine); + float lifeFadeIn = Utils.GetLerpValue(110, 0, Projectile.timeLeft, true); + float finalGlowIntensity = pulse * lifeFadeIn; + drawPosition = Projectile.Center - Main.screenPosition; + + // Create 15 copies of the projectile that draw behind with mainColor to create a glowy outline effect + for (int i = 0; i < 15; i++) + { + float rotationOffset = (MathHelper.TwoPi * i / 15); + Vector2 glowOffset = rotationOffset.ToRotationVector2() * (3f + glowSine * 1f) * finalGlowIntensity; + + Main.spriteBatch.Draw(mainTexture, drawPosition + glowOffset, null, mainColor with { A = 0 } * finalGlowIntensity * 0.4f, flungState, drawOrigin, drawScale, spriteEffects, 0f); + } + } + + if (flungState == 0f) + { + spriteEffects = SpriteEffects.FlipVertically; + + int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; + float completion = time / (useAnim * 0.7f); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); + float grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); + grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : 5, Owner.direction == 1 ? -38 : 22).RotatedBy(grenadeRot); + drawPosition = grenadePos - Main.screenPosition; + drawRotation = grenadeRot - MathHelper.ToRadians(25 * completionLerp2) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + } + else + { + if (stuckState == 1f) + drawRotation = flungState; + drawPosition = Projectile.Center - Main.screenPosition; + } + + // Draw it + Main.spriteBatch.Draw(mainTexture, drawPosition, null, lightColor * (1f - Projectile.alpha / 255f), drawRotation, drawOrigin, drawScale, spriteEffects, 0f); + + return false; + } + } +} diff --git a/Projectiles/Rogue/RadiantExplosion.cs b/Projectiles/Rogue/RadiantExplosion.cs index 9c6a87fafe..ff08a98a62 100644 --- a/Projectiles/Rogue/RadiantExplosion.cs +++ b/Projectiles/Rogue/RadiantExplosion.cs @@ -2,7 +2,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Dusts; -using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Rogue/RadiationBurst.cs b/Projectiles/Rogue/RadiationBurst.cs index a3f2054340..885ce066db 100644 --- a/Projectiles/Rogue/RadiationBurst.cs +++ b/Projectiles/Rogue/RadiationBurst.cs @@ -1,10 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Dusts; @@ -51,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue velOffset *= Main.rand.NextFloat(25, 45) * fade; Particle energy = new GlowOrbParticle(Projectile.Center + velOffset * 2.5f, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, false, (int)(14 - (5 * fade)), Main.rand.NextFloat(1.1f, 1.25f) - 0.5f * fade, Color.Chartreuse); GeneralParticleHandler.SpawnParticle(energy); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, 278, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, DustID.FireworksRGB, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); dust.noGravity = true; dust.color = Color.Chartreuse; } @@ -81,7 +77,7 @@ namespace CalamityMod.Projectiles.Rogue Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 1f, 0.2f, 32); GeneralParticleHandler.SpawnParticle(orb2); - Owner.Calamity().GeneralScreenShakePower = 3.5f; + Owner.SetScreenshake(3.5f); } time++; } diff --git a/Projectiles/Rogue/RadiationRain.cs b/Projectiles/Rogue/RadiationRain.cs index b4d1c05c71..72de92480f 100644 --- a/Projectiles/Rogue/RadiationRain.cs +++ b/Projectiles/Rogue/RadiationRain.cs @@ -1,13 +1,8 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Dusts; using CalamityMod.Particles; namespace CalamityMod.Projectiles.Rogue @@ -86,7 +81,7 @@ namespace CalamityMod.Projectiles.Rogue } if (time % 4 == 0) { - Dust c = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(70, 70), 267); + Dust c = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(70, 70), DustID.RainbowMk2); c.velocity = Projectile.velocity * Main.rand.NextFloat(0.5f, 3f); c.scale = Main.rand.NextFloat(0.45f, 0.75f); c.noGravity = true; @@ -97,7 +92,7 @@ namespace CalamityMod.Projectiles.Rogue } if (time % 10 * Projectile.MaxUpdates == 0) { - Owner.Calamity().GeneralScreenShakePower = 1.5f; + Owner.SetScreenshake(1.5f); } if (Projectile.ai[2] > 0 && time == 30) diff --git a/Projectiles/Rogue/RealityRuptureLance.cs b/Projectiles/Rogue/RealityRuptureLance.cs index 1c809342c0..7cb4c0edb7 100644 --- a/Projectiles/Rogue/RealityRuptureLance.cs +++ b/Projectiles/Rogue/RealityRuptureLance.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/RealityRuptureMini.cs b/Projectiles/Rogue/RealityRuptureMini.cs index ce5384bb64..9007df044e 100644 --- a/Projectiles/Rogue/RealityRuptureMini.cs +++ b/Projectiles/Rogue/RealityRuptureMini.cs @@ -1,6 +1,5 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Rogue/RealityRuptureStealth.cs b/Projectiles/Rogue/RealityRuptureStealth.cs index 5842c87c3b..ca9cc42de9 100644 --- a/Projectiles/Rogue/RealityRuptureStealth.cs +++ b/Projectiles/Rogue/RealityRuptureStealth.cs @@ -1,14 +1,9 @@ -using System; -using System.Reflection.Metadata; -using CalamityMod.Particles; +using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Pets; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Mono.Cecil; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -73,7 +68,7 @@ namespace CalamityMod.Projectiles.Rogue CrackParticle crack2 = new CrackParticle(Projectile.Center, vel2, Color.Plum, new Vector2(1f, 1f), 0, Scale2, Scale2 - 0.5f, Main.rand.Next(27, 32)); GeneralParticleHandler.SpawnParticle(crack2); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 0f, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack * 2, Projectile.owner, 0f); - Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 8; + Main.player[Projectile.owner].SetScreenshake(8f); } public override bool PreDraw(ref Color lightColor) { @@ -94,7 +89,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i <= 15; i++) { Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.6f, 1.5f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity, 272, sparkVelocity.RotatedByRandom(0.1f), 0, default, Main.rand.NextFloat(1.2f, 1.5f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity, DustID.WitherLightning, sparkVelocity.RotatedByRandom(0.1f), 0, default, Main.rand.NextFloat(1.2f, 1.5f)); dust.noGravity = true; int sparkLifetime = Main.rand.Next(43, 48); diff --git a/Projectiles/Rogue/ReaperProjectile.cs b/Projectiles/Rogue/ReaperProjectile.cs index 836b7d10e8..98bd094a7b 100644 --- a/Projectiles/Rogue/ReaperProjectile.cs +++ b/Projectiles/Rogue/ReaperProjectile.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -13,6 +14,7 @@ using static CalamityMod.CalamityUtils; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class ReaperProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -154,7 +156,7 @@ namespace CalamityMod.Projectiles.Rogue { float rot2 = (Projectile.rotation * Projectile.direction); Vector2 dustPos = Projectile.Center + (i * MathHelper.Pi + Projectile.rotation * 0.3f + MathHelper.PiOver2).ToRotationVector2() * 70f; - Dust dust = Dust.NewDustPerfect(dustPos, 267); + Dust dust = Dust.NewDustPerfect(dustPos, DustID.RainbowMk2); dust.noGravity = true; dust.scale = 0.8f; dust.color = Color.Chartreuse; @@ -210,7 +212,7 @@ namespace CalamityMod.Projectiles.Rogue velOffset *= Main.rand.NextFloat(25, 45) * fade; Particle energy = new GlowOrbParticle(Projectile.Center + velOffset * 2.5f, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, false, (int)(14 - (5 * fade)), Main.rand.NextFloat(1.1f, 1.25f) - 0.5f * fade, Color.Chartreuse); GeneralParticleHandler.SpawnParticle(energy); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, 278, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, DustID.FireworksRGB, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); dust.noGravity = true; dust.color = Color.Chartreuse; } @@ -235,7 +237,7 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(fire2 with { Volume = 1f, Pitch = -0.3f }, rainSpot); for (int i = 0; i < 37; i++) { - Dust chargefull = Dust.NewDustPerfect(rainSpot, 278); + Dust chargefull = Dust.NewDustPerfect(rainSpot, DustID.FireworksRGB); chargefull.velocity = Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(1, 8); chargefull.scale = Main.rand.NextFloat(0.45f, 0.75f); chargefull.noGravity = true; @@ -243,7 +245,7 @@ namespace CalamityMod.Projectiles.Rogue } Particle Smear = new CustomPulse(rainSpot, Vector2.Zero, Color.Chartreuse * 0.7f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-5, 5), 0, 0.35f, 12); GeneralParticleHandler.SpawnParticle(Smear); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), rainSpot, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0, 0, 100); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), rainSpot, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.13), 0f, Projectile.owner, 0, 0, 100); } else // Radiation Burst { diff --git a/Projectiles/Rogue/ReboundingRainbowProj.cs b/Projectiles/Rogue/ReboundingRainbowProj.cs index 8f847a26a8..b9d387de60 100644 --- a/Projectiles/Rogue/ReboundingRainbowProj.cs +++ b/Projectiles/Rogue/ReboundingRainbowProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Rogue/RefractionRotorProjectile.cs b/Projectiles/Rogue/RefractionRotorProjectile.cs index 202178f0a5..ccfb5a7e3b 100644 --- a/Projectiles/Rogue/RefractionRotorProjectile.cs +++ b/Projectiles/Rogue/RefractionRotorProjectile.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Security.AccessControl; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Particles; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Sounds; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -90,7 +84,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 15; i++) { - Dust rainbowBurst = Dust.NewDustPerfect(Projectile.Center, 267); + Dust rainbowBurst = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); rainbowBurst.color = Main.hslToRgb(i / 80f, 0.9f, 0.6f); rainbowBurst.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(3f, 5.5f); rainbowBurst.scale = Main.rand.NextFloat(1.4f, 2.4f); @@ -108,8 +102,7 @@ namespace CalamityMod.Projectiles.Rogue int shootType = ModContent.ProjectileType(); if (Main.myPlayer != Projectile.owner) return; - - if (CalamityUtils.CountOwnedProjectiles(shootType, Projectile.owner) > 24) + if (Main.LocalPlayer.ownedProjectileCounts[shootType] > 24) return; int energyDamage = (int)(Projectile.damage * 0.5f); diff --git a/Projectiles/Rogue/RefractionRotorSlashCreator.cs b/Projectiles/Rogue/RefractionRotorSlashCreator.cs index 48414382ae..18ff2ac28a 100644 --- a/Projectiles/Rogue/RefractionRotorSlashCreator.cs +++ b/Projectiles/Rogue/RefractionRotorSlashCreator.cs @@ -1,7 +1,5 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/RefractionSlash.cs b/Projectiles/Rogue/RefractionSlash.cs index 69aa4d974d..434377f822 100644 --- a/Projectiles/Rogue/RefractionSlash.cs +++ b/Projectiles/Rogue/RefractionSlash.cs @@ -1,9 +1,5 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/RegulusRiotProj.cs b/Projectiles/Rogue/RegulusRiotProj.cs index 626f47a9ce..4060b86d03 100644 --- a/Projectiles/Rogue/RegulusRiotProj.cs +++ b/Projectiles/Rogue/RegulusRiotProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Rogue/RotBallProjectile.cs b/Projectiles/Rogue/RotBallProjectile.cs index 66ce8495dc..04a6155d74 100644 --- a/Projectiles/Rogue/RotBallProjectile.cs +++ b/Projectiles/Rogue/RotBallProjectile.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/SacrificeProjectile.cs b/Projectiles/Rogue/SacrificeProjectile.cs index 8da92c9fc3..a2c3f3170f 100644 --- a/Projectiles/Rogue/SacrificeProjectile.cs +++ b/Projectiles/Rogue/SacrificeProjectile.cs @@ -1,4 +1,5 @@ using System.IO; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -6,6 +7,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class SacrificeProjectile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; @@ -53,20 +55,8 @@ namespace CalamityMod.Projectiles.Rogue // Heal the player and disappear when touching them. if (Projectile.Hitbox.Intersects(Owner.Hitbox)) { - if (!Owner.moonLeech && AbleToHealOwner) - { - int heal = Projectile.Calamity().stealthStrike ? 40 : 3; - - if (Main.LocalPlayer.lifeSteal <= 0f) - { - Projectile.Kill(); - return; - } - - Main.LocalPlayer.lifeSteal -= heal; - Owner.HealPlayer(heal); - } - + if (AbleToHealOwner) + Owner.DoLifestealDirect(null, Projectile.Calamity().stealthStrike ? 40 : 3, 0.4f); Projectile.Kill(); } } @@ -76,7 +66,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 60; i++) { - Dust blood = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50f, 50f), 267); + Dust blood = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50f, 50f), DustID.RainbowMk2); blood.velocity = Main.rand.NextVector2Circular(3f, 3f); blood.noGravity = true; blood.color = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.25f, 1f)); diff --git a/Projectiles/Rogue/SamsaraSlicerProjectile.cs b/Projectiles/Rogue/SamsaraSlicerProjectile.cs index 1433f615a4..a56c2b4816 100644 --- a/Projectiles/Rogue/SamsaraSlicerProjectile.cs +++ b/Projectiles/Rogue/SamsaraSlicerProjectile.cs @@ -1,8 +1,6 @@ -using System; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MonoMod.Core.Utils; using ReLogic.Content; using Terraria; using Terraria.Audio; @@ -17,18 +15,21 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/SamsaraSlicer"; - public float ReboundVelocity => 20; + //These are the same number, but will be left as two seperate variables for future tuning purposes + public float ReboundVelocity => 30; public float StealthReboundVelocity => 30; public float StealthPauseTime => 55; - public int ReboundTime => 20; + public int ReboundTime => 30; - public int SmallDiskDamage => 8; - public int SmallDiskStealthDamage => 17; + public int SmallDiskDamage => 30; + public int SmallDiskStealthDamage => 19; public bool initialized = false; Vector2 oldVelocity; + int? npcTaggedTo = null; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 10; @@ -54,7 +55,6 @@ namespace CalamityMod.Projectiles.Rogue { width = 20; height = 20; - return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); } @@ -107,6 +107,15 @@ namespace CalamityMod.Projectiles.Rogue } } } + else + { + if (npcTaggedTo != null) + { + NPC npc = Main.npc[npcTaggedTo.GetValueOrDefault(0)]; + if (npc.active) + Projectile.Center += npc.velocity; + } + } // Frame pause @@ -114,6 +123,8 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.ai[0] == 0) { + npcTaggedTo = null; + Projectile.velocity = oldVelocity; SoundEngine.PlaySound(SoundID.DD2_SkyDragonsFuryShot.WithPitchOffset(1f)); @@ -219,8 +230,6 @@ namespace CalamityMod.Projectiles.Rogue } else { - //Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Items/Weapons/Rogue/SamsaraSlicerGlow").Value, Projectile.Center - Main.screenPosition + randVec, tex.Frame(), new Color(0f, 1f, 0f, 0f), Projectile.rotation, tex.Frame().Center(), 1f, SpriteEffects.None); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Items/Weapons/Rogue/SamsaraSlicerGlow").Value, Projectile.Center - Main.screenPosition + randVec, tex.Frame(), new Color(0f, 1f, 0f, 0f), Projectile.rotation, tex.Frame().Center(), 1f, SpriteEffects.None); } return false; @@ -228,6 +237,8 @@ namespace CalamityMod.Projectiles.Rogue public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + npcTaggedTo = target.whoAmI; + if (Projectile.velocity != Vector2.Zero) { if (Projectile.ai[0] <= -200) diff --git a/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs b/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs index dac74b5b0d..94be412dca 100644 --- a/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs +++ b/Projectiles/Rogue/SamsaraSlicerSmallDisk.cs @@ -9,7 +9,6 @@ namespace CalamityMod.Projectiles.Rogue public class SamsaraSlicerSmallDisk : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; - private double rotation = 0; public Projectile Parent = null; public override void SetStaticDefaults() { @@ -28,7 +27,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.aiStyle = -1; Projectile.DamageType = RogueDamageClass.Instance; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 3; + Projectile.localNPCHitCooldown = 5; + Projectile.ArmorPenetration = 20; } public override void AI() @@ -105,11 +105,6 @@ namespace CalamityMod.Projectiles.Rogue Parent = Main.projectile[(int)Projectile.ai[0]]; } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - target.immune[Projectile.owner] = 0; - } - public override bool PreDraw(ref Color lightColor) { for (int i = 1; i < Projectile.oldPos.Length; i++) diff --git a/Projectiles/Rogue/SandDollarFrag.cs b/Projectiles/Rogue/SandDollarFrag.cs new file mode 100644 index 0000000000..97d81c2105 --- /dev/null +++ b/Projectiles/Rogue/SandDollarFrag.cs @@ -0,0 +1,45 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Rogue +{ + public class SandDollarFrag : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; // Gets overridden in PreDraw anyways + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 22; + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + } + + public override void AI() + { + Projectile.velocity.Y += 0.11f; + if (Projectile.velocity.Y > 16f) + Projectile.velocity.Y = 16f; + Projectile.rotation += Projectile.velocity.X * 0.025f; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Sand, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 2f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = ModContent.Request("CalamityMod/Projectiles/Rogue/SandDollarFrag" + Projectile.ai[0].ToString()).Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, tex.Size() / 2f, 1f, SpriteEffects.None); + return false; + } + } +} diff --git a/Projectiles/Rogue/SandDollarFrag1.png b/Projectiles/Rogue/SandDollarFrag1.png new file mode 100644 index 0000000000..caffaafff7 Binary files /dev/null and b/Projectiles/Rogue/SandDollarFrag1.png differ diff --git a/Projectiles/Rogue/SandDollarFrag2.png b/Projectiles/Rogue/SandDollarFrag2.png new file mode 100644 index 0000000000..1e318bc1f0 Binary files /dev/null and b/Projectiles/Rogue/SandDollarFrag2.png differ diff --git a/Projectiles/Rogue/SandDollarFrag3.png b/Projectiles/Rogue/SandDollarFrag3.png new file mode 100644 index 0000000000..33c162ee37 Binary files /dev/null and b/Projectiles/Rogue/SandDollarFrag3.png differ diff --git a/Projectiles/Rogue/SandDollarProj.cs b/Projectiles/Rogue/SandDollarProj.cs index d6a3686639..eb4fbebd69 100644 --- a/Projectiles/Rogue/SandDollarProj.cs +++ b/Projectiles/Rogue/SandDollarProj.cs @@ -1,4 +1,8 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -8,29 +12,98 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/SandDollar"; + public ref float Timer => ref Projectile.ai[0]; + public ref float BounceCheck => ref Projectile.ai[1]; + private const int Pierce = 2; public override void SetDefaults() { Projectile.width = 30; Projectile.height = 28; Projectile.DamageType = RogueDamageClass.Instance; Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.aiStyle = ProjAIStyleID.Boomerang; - Projectile.timeLeft = 300; - AIType = ProjectileID.Bananarang; + Projectile.penetrate = Pierce; + Projectile.timeLeft = 600; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 25; } + public override void AI() + { + Timer++; + Projectile.rotation += BounceCheck > 0f ? 0.35f : 0.2f; + // Bouncing resets the timer for use in fading in its glow + if (Timer >= 30f || BounceCheck > 0f) + { + if (BounceCheck > 0f && Projectile.Calamity().stealthStrike) + Projectile.velocity *= 0.975f; + else + { + Projectile.velocity.X *= BounceCheck > 0f ? 0.985f : 0.998f; + Projectile.velocity.Y += 0.0375f; + } + } + if (Projectile.velocity.Y > 8f) + Projectile.velocity.Y = 8f; + + // Random dust after bouncing + if (BounceCheck > 0f || Projectile.Calamity().stealthStrike) + { + Vector2 dustPos = Projectile.Center + Main.rand.NextVector2CircularEdge(20f, 15f); + Vector2 dustVel = Utils.DirectionTo(Projectile.Center, dustPos).RotatedBy(MathHelper.PiOver2) * 2f; + Dust dust = Dust.NewDustPerfect(dustPos, DustID.Sand, dustVel, Scale: 0.75f); + dust.noGravity = true; + } + } + public override bool? CanDamage() => BounceCheck > 0f && Projectile.Calamity().stealthStrike ? false : null; + public override bool OnTileCollide(Vector2 oldVelocity) { - Projectile.ai[0] += 0.1f; - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) + // Should only bounce if it hasn't bounced before, hasn't pierced an enemy, and is hitting a floor (moving downwards) + if (BounceCheck == 0f && (Projectile.penetrate == Pierce || Projectile.Calamity().stealthStrike) && Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y > 0f) { + BounceCheck = 1f; + Timer = 0f; + Projectile.penetrate = 1; Projectile.velocity.Y = -oldVelocity.Y; + if (Projectile.velocity.Y < -4f) + Projectile.velocity.Y = -4f; + + // Summon a duststorm on stealth strikes + if (Projectile.Calamity().stealthStrike && Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 4, 1f, Projectile.owner, Projectile.whoAmI); + } + return false; } + return true; + } + + public override void OnKill(int timeLeft) + { + for (int s = 0; s < 8; s++) + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Sand, Scale: 0.9f); + dust.noGravity = true; + } + + if (BounceCheck > 0f && Main.myPlayer == Projectile.owner) + { + for (int i = 1; i <= 3; i++) + { + Vector2 velocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(3f, 4.5f); + int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0f, Projectile.owner, i); + Main.projectile[p].rotation = Main.rand.NextFloat(MathHelper.TwoPi); + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = TextureAssets.Projectile[Type].Value; + Vector2 stretch = new Vector2(MathHelper.Lerp(1.2f, 0.8f, (float)Math.Abs(Math.Sin(Projectile.rotation))), MathHelper.Lerp(0.85f, 1.15f, (float)Math.Abs(Math.Sin(Projectile.rotation)))); + Color drawColor = BounceCheck > 0f ? Color.Lerp(lightColor, Color.White, MathHelper.Clamp(Timer / 60f, 0f, 0.5f)) : lightColor; + + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, drawColor, Projectile.rotation, tex.Size() / 2f, stretch, SpriteEffects.None); return false; } } diff --git a/Projectiles/Rogue/SandDollarStealth.cs b/Projectiles/Rogue/SandDollarStealth.cs index 5eed13c7f0..1a7b49c931 100644 --- a/Projectiles/Rogue/SandDollarStealth.cs +++ b/Projectiles/Rogue/SandDollarStealth.cs @@ -1,58 +1,74 @@ -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class SandDollarStealth : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/SandDollar"; + public override string Texture => "CalamityMod/Projectiles/Typeless/SandCloakVeil"; + private const float Radius = 96f; + private const int StartTime = 180; + private bool shouldDie = false; public override void SetDefaults() { Projectile.width = 30; Projectile.height = 28; Projectile.DamageType = RogueDamageClass.Instance; Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.aiStyle = ProjAIStyleID.Boomerang; - Projectile.timeLeft = 300; - AIType = ProjectileID.Bananarang; + Projectile.timeLeft = StartTime; + Projectile.Opacity = 0f; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(); - - private void OnHitEffects() + public override void AI() { - int coralAmt = Main.rand.Next(1, 4); - if (Projectile.owner == Main.myPlayer && Projectile.Calamity().stealthStrike) + Projectile disk = Main.projectile[(int)Projectile.ai[0]]; + Projectile.rotation += 0.025f; + + if (disk.active) { - for (int coralCount = 0; coralCount < coralAmt; coralCount++) + if (!shouldDie) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int coral = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage / 3, 0f, Projectile.owner); - if (coral.WithinBounds(Main.maxProjectiles)) - Main.projectile[coral].DamageType = RogueDamageClass.Instance; + Projectile.Center = disk.Center + disk.velocity; + Projectile.timeLeft = 20; } - } - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.ai[0] += 0.1f; - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; } - if (Projectile.velocity.Y != oldVelocity.Y) + else + shouldDie = true; + + if (Projectile.timeLeft >= 20) + Projectile.Opacity += 0.05f; + else + Projectile.Opacity -= 0.05f; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.HitDirectionOverride = (target.Center.X > Projectile.Center.X).ToDirectionInt(); + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Radius, targetHitbox); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = TextureAssets.Projectile[Type].Value; + float scaleStep = 0.05f; + Color drawCol = Projectile.GetAlpha(Color.Lerp(lightColor, Color.White, 0.5f)); + float drawTransparency = 0.2f; + + if (Projectile.timeLeft > StartTime - 20) + drawTransparency *= Utils.GetLerpValue(StartTime - 20, StartTime, Projectile.timeLeft, true); + else if (Projectile.timeLeft < 20) + drawTransparency *= Utils.GetLerpValue(0, 20, Projectile.timeLeft, true); + + for (int i = 0; i < 20; i++) { - Projectile.velocity.Y = -oldVelocity.Y; + float rotation = (Projectile.rotation + scaleStep * i) * (i % 2 == 0).ToDirectionInt(); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, drawCol * drawTransparency, rotation, tex.Size() / 2f, (Radius * 0.0044f) - (i * scaleStep), SpriteEffects.None); } return false; } diff --git a/Projectiles/Rogue/ScarletBlast.cs b/Projectiles/Rogue/ScarletBlast.cs index 5a8782ef8c..e1bb9b41a4 100644 --- a/Projectiles/Rogue/ScarletBlast.cs +++ b/Projectiles/Rogue/ScarletBlast.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Rogue/ScarletDevilProjectile.cs b/Projectiles/Rogue/ScarletDevilProjectile.cs index fa631e61cb..336cacc18b 100644 --- a/Projectiles/Rogue/ScarletDevilProjectile.cs +++ b/Projectiles/Rogue/ScarletDevilProjectile.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Balancing; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -45,7 +44,7 @@ namespace CalamityMod.Projectiles.Rogue if (!Main.dedServ) { for (int i = 0; i < (Projectile.Calamity().stealthStrike && Main.rand.NextBool() ? 2 : 1); i++) - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 130, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.85f); + Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Firework_Red, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.85f); } ShootTimer++; @@ -131,14 +130,7 @@ namespace CalamityMod.Projectiles.Rogue SpawnOnStealthStrikeBullets(); // Give on-heal effects from stealth strikes. - int heal = (int)Math.Round(hit.Damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); + Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, (int)Math.Round(hit.Damage * 0.005), 0.5f); } public override void OnHitPlayer(Player target, Player.HurtInfo info) @@ -150,26 +142,16 @@ namespace CalamityMod.Projectiles.Rogue // Spawn a bloom of bullets. SpawnOnStealthStrikeBullets(); - - // Give on-heal effects from stealth strikes. - int heal = (int)Math.Round(info.Damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float widthRatio = Utils.GetLerpValue(0f, 0.1f, completionRatio, true); float baseWidth = MathHelper.Lerp(0f, 110f, widthRatio) * MathHelper.Clamp(1f - (float)Math.Pow(completionRatio, 0.4D), 0.37f, 1f); return baseWidth; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float colorIncrement = (float)Math.Pow(completionRatio, 1f / 2f); if (colorIncrement is float.NaN) @@ -189,7 +171,7 @@ namespace CalamityMod.Projectiles.Rogue else { GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * 86f, false, + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * 86f, false, shader: GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"]), 60); Texture2D spearTexture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Rogue/ScourgeoftheDesertProj.cs b/Projectiles/Rogue/ScourgeoftheDesertProj.cs index 3b9e665621..0cffabe8d1 100644 --- a/Projectiles/Rogue/ScourgeoftheDesertProj.cs +++ b/Projectiles/Rogue/ScourgeoftheDesertProj.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(2)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), Main.rand.NextBool() ? 288 : 121); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), Main.rand.NextBool() ? 288 : 207); dust.scale = Main.rand.NextFloat(0.3f, 0.55f); dust.noGravity = true; dust.velocity = -Projectile.velocity * 0.5f; @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(SoundID.NPCHit11 with { Volume = 1.3f, Pitch = 1.1f }, Projectile.Center); for (int i = 0; i <= 25; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 6.5f, Main.rand.NextBool() ? 121 : 216, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 6.5f, Main.rand.NextBool() ? 207 : 216, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); dust.noGravity = true; } PostExitTiles = true; @@ -176,7 +176,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i <= 25; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 3, Main.rand.NextBool() ? 121 : 216, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 3, Main.rand.NextBool() ? 207 : 216, -Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.3f, 0.9f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); dust.noGravity = true; } Projectile.velocity = SavedOldVelocity * 0.7f; @@ -209,7 +209,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i <= 25; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, Main.rand.NextBool(3) ? 216 : 121, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.05f, 2.2f), 0, default, Main.rand.NextFloat(1.5f, 2.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, Main.rand.NextBool(3) ? 216 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.05f, 2.2f), 0, default, Main.rand.NextFloat(1.5f, 2.8f)); dust.noGravity = true; } } diff --git a/Projectiles/Rogue/SearedPanProjectile.cs b/Projectiles/Rogue/SearedPanProjectile.cs deleted file mode 100644 index 11e591ffc0..0000000000 --- a/Projectiles/Rogue/SearedPanProjectile.cs +++ /dev/null @@ -1,206 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.NPCs.NormalNPCs; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class SearedPanProjectile : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - internal enum SearedPanTypes - { - VenLocket = 0, - Normal = 1, - Golden = 2, - StealthStrike = 3 - } - - internal SearedPanTypes PanType - { - get => (SearedPanTypes)(int)Projectile.ai[0]; - set => Projectile.ai[0] = (int)value; - } - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 6; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 20; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.timeLeft = 420; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.extraUpdates = 2; - } - - public override void AI() - { - if (Main.rand.NextBool(5)) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Blood, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); - } - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - // Don't increment the Seared Pan counter when hitting dummies - //&& target.type != ModContent.NPCType() this is here just in case its needed again - bool dummy = target.type != NPCID.TargetDummy; - OnHitEffects(target.whoAmI, target.life, dummy); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - target.AddBuff(BuffID.Bleeding, 300); - OnHitEffects(-1, target.statLife, true); - } - - private void OnHitEffects(int targetIndex, int health, bool specialEffects) - { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - // Don't spawn fireballs or increment the special effects counter if you can't even stealth strike - bool playerCanStealthStrike = modPlayer.wearingRogueArmor && modPlayer.rogueStealthMax > 0; - if (!playerCanStealthStrike) - return; - - // Increment the seared pan counter. Pans summoned via the Venerated Locket shouldn't increment the counter. - // See CalamityPlayerMiscEffects.cs for code that resets the counter after 40 frames - modPlayer.searedPanTimer = 0; - if (specialEffects && PanType != SearedPanTypes.VenLocket) - modPlayer.searedPanCounter++; - - // Pans summoned via the Venerated Locket have zero special effects - if (PanType == SearedPanTypes.StealthStrike) - { - modPlayer.searedPanCounter = 0; - // Stealth strikes spawn four golden sparks on hit - for (int t = 0; t < 4; t++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.2), 0f, Projectile.owner); - } - SoundEngine.PlaySound(SearedPan.SmashSound, Projectile.position); - // Stealth strikes also cause any existing fireballs to home in on their targets - FireballStuff(true); - - if (!specialEffects) - return; - // Stealth strikes then summon five fireballs to circle the hit enemy, they will home in on their own after a second. - for (int t = 0; t < 5; t++) - { - int i = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, targetIndex); - Main.projectile[i].ModProjectile().Timer = 61; - } - FireballPositions(targetIndex); - } - else if (PanType == SearedPanTypes.Golden) - { - modPlayer.searedPanCounter = 0; - SoundEngine.PlaySound(SearedPan.SmashSound, Projectile.position); - // Golden pans simply cause all fireballs to home in on their targets - FireballStuff(true); - } - else if (PanType == SearedPanTypes.Normal && targetIndex != -1 && health > 0 && specialEffects) - { - // Summon three fireballs to circle the hit enemy - for (int t = 0; t < 3; t++) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, targetIndex); - } - FireballPositions(targetIndex); - } - } - - private void FireballStuff(bool activate) - { - if (Projectile.owner == Main.myPlayer) - { - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.owner != Projectile.owner) - continue; - if (p.ModProjectile is NiceCock) - { - if (!activate) - p.Kill(); - else - { - p.ModProjectile().homing = true; - p.extraUpdates += 2; - } - } - } - } - } - - private void FireballPositions(int targetIndex) - { - int fireballCount = 0; - // Count how many fireballs exist already around the given target - foreach (Projectile p in Main.ActiveProjectiles) - { - // Keep the loop as short as possible - if (p.owner != Projectile.owner || !p.CountsAsClass() || targetIndex != (int)p.ai[1]) - continue; - if (p.ModProjectile is NiceCock) - { - if (p.ModProjectile().homing) - continue; - fireballCount++; - } - } - // Adjust the angle of the existing fireballs around a target - float angleVariance = MathHelper.TwoPi / fireballCount; - float angle = 0f; - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.owner != Projectile.owner || !p.CountsAsClass() || targetIndex != (int)p.ai[1]) - continue; - if (p.ModProjectile is NiceCock) - { - if (p.ModProjectile().homing) - continue; - p.ai[0] = angle; - p.netUpdate = true; - angle += angleVariance; - } - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - // Kill all fireballs if you miss a stealth strike or golden pan - if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) - FireballStuff(false); - return true; - } - - public override Color? GetAlpha(Color lightColor) - { - // Stealth strikes and golden pans are golden colored - if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) - return new Color(255, 222, 0); - return null; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Rogue/SearedPanProjectile.png b/Projectiles/Rogue/SearedPanProjectile.png deleted file mode 100644 index 559b586cb8..0000000000 Binary files a/Projectiles/Rogue/SearedPanProjectile.png and /dev/null differ diff --git a/Projectiles/Rogue/SeraphimAngelicLight.cs b/Projectiles/Rogue/SeraphimAngelicLight.cs index e1f1561977..272171c10f 100644 --- a/Projectiles/Rogue/SeraphimAngelicLight.cs +++ b/Projectiles/Rogue/SeraphimAngelicLight.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -40,7 +41,7 @@ namespace CalamityMod.Projectiles.Rogue // Release a puff of golden light dust. for (int i = 0; i < 15; i++) { - Dust light = Dust.NewDustPerfect(Projectile.Center, 267); + Dust light = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); light.color = Color.Lerp(Color.Gold, Color.White, Main.rand.NextFloat(0.5f, 1f)); light.velocity = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * 5f; light.scale = 1.35f; diff --git a/Projectiles/Rogue/SeraphimAngelicLight2.cs b/Projectiles/Rogue/SeraphimAngelicLight2.cs index 3c3d4e443b..e8675d29bf 100644 --- a/Projectiles/Rogue/SeraphimAngelicLight2.cs +++ b/Projectiles/Rogue/SeraphimAngelicLight2.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -43,7 +44,7 @@ namespace CalamityMod.Projectiles.Rogue // Release a puff of golden light dust. for (int i = 0; i < 16; i++) { - Dust light = Dust.NewDustPerfect(Projectile.Center, 267); + Dust light = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); light.color = Color.Lerp(Color.Gold, Color.White, Main.rand.NextFloat(0.5f, 1f)); light.velocity = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * 5f; light.scale = 0.9f; diff --git a/Projectiles/Rogue/SeraphimBeamLarge.cs b/Projectiles/Rogue/SeraphimBeamLarge.cs index ad41f9fa89..74b0e69908 100644 --- a/Projectiles/Rogue/SeraphimBeamLarge.cs +++ b/Projectiles/Rogue/SeraphimBeamLarge.cs @@ -8,7 +8,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/SeraphimProjectile.cs b/Projectiles/Rogue/SeraphimProjectile.cs index e16685c4a0..8790a564c9 100644 --- a/Projectiles/Rogue/SeraphimProjectile.cs +++ b/Projectiles/Rogue/SeraphimProjectile.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -48,7 +49,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < lightDustCount; i++) { Vector2 dustSpawnPosition = Projectile.Center + Main.rand.NextVector2Unit() * (1f - Projectile.Opacity) * 45f; - Dust light = Dust.NewDustPerfect(dustSpawnPosition, 267); + Dust light = Dust.NewDustPerfect(dustSpawnPosition, DustID.RainbowMk2); light.color = Color.Lerp(Color.Gold, Color.White, Main.rand.NextFloat(0.5f, 1f)); light.velocity = Main.rand.NextVector2Circular(10f, 10f); light.scale = MathHelper.Lerp(1.3f, 0.8f, Projectile.Opacity) * Main.rand.NextFloat(0.8f, 1.2f); diff --git a/Projectiles/Rogue/ShatteredExplosion.cs b/Projectiles/Rogue/ShatteredExplosion.cs index f5ffc3e384..42448f2591 100644 --- a/Projectiles/Rogue/ShatteredExplosion.cs +++ b/Projectiles/Rogue/ShatteredExplosion.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/ShinobiBladeProjectile.cs b/Projectiles/Rogue/ShinobiBladeProjectile.cs index 8ce4a2584a..5ef272e6b4 100644 --- a/Projectiles/Rogue/ShinobiBladeProjectile.cs +++ b/Projectiles/Rogue/ShinobiBladeProjectile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Balancing; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Particles; using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; @@ -71,14 +70,8 @@ namespace CalamityMod.Projectiles.Rogue SoundEngine.PlaySound(WulfrumKnife.TileHitSound, Projectile.Center); } - if (target.life <= 0 && target.lifeMax > 5) - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], 10, ModContent.ProjectileType(), BalancingConstants.LifeStealRange, 0f); - } - - public override void OnHitPlayer(Player target, Player.HurtInfo info) - { - if (target.statLife <= 0) - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], 10, ModContent.ProjectileType(), BalancingConstants.LifeStealRange, 0f); + if (target.life <= 0) + Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ModContent.ProjectileType(), 10, 0f); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Rogue/ShockBolt.cs b/Projectiles/Rogue/ShockBolt.cs index 741e2daa70..b8317bac3f 100644 --- a/Projectiles/Rogue/ShockBolt.cs +++ b/Projectiles/Rogue/ShockBolt.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Rogue/ShockTeslaAura.cs b/Projectiles/Rogue/ShockTeslaAura.cs index da9583480a..0f781531c3 100644 --- a/Projectiles/Rogue/ShockTeslaAura.cs +++ b/Projectiles/Rogue/ShockTeslaAura.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.NPCs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -94,19 +92,9 @@ namespace CalamityMod.Projectiles.Rogue { target.AddBuff(BuffID.Electrified, 60); target.AddBuff(ModContent.BuffType(), 60); - - if (target.knockBackResist <= 0f) - return; - - // 12AUG2023: Ozzatron: TML was giving NaN knockback, probably due to 0 base knockback. Do not use hit.Knockback - if (CalamityGlobalNPC.ShouldAffectNPC(target)) - { - float knockbackMultiplier = MathHelper.Clamp(1f - target.knockBackResist, 0f, 1f); - Vector2 trueKnockback = target.Center - Projectile.Center; - trueKnockback.Normalize(); - target.velocity = trueKnockback * knockbackMultiplier; - } } + // CIT 2MAY2025: Replaced old manual knockback code with setting HitDirectionOverride + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.HitDirectionOverride = (target.Center.X > Projectile.Center.X).ToDirectionInt(); public override void OnHitPlayer(Player target, Player.HurtInfo info) { diff --git a/Projectiles/Rogue/SkyStabberProj.cs b/Projectiles/Rogue/SkyStabberProj.cs deleted file mode 100644 index c9cab426cb..0000000000 --- a/Projectiles/Rogue/SkyStabberProj.cs +++ /dev/null @@ -1,84 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class SkyStabberProj : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/SkyStabber"; - - public override void SetDefaults() - { - Projectile.width = 15; - Projectile.height = 15; - Projectile.friendly = true; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.tileCollide = true; - Projectile.penetrate = 10; - Projectile.timeLeft = 1000; - - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; - } - - public override void AI() - { - Projectile.ai[0] += 1f; - - if (Projectile.ai[0] >= 90f) - { - Projectile.velocity.X *= 0.98f; - Projectile.velocity.Y *= 0.98f; - } - else - { - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.killSpikyBalls) - { - Projectile.active = false; - Projectile.netUpdate = true; - } - } - - // Makes the projectile bounce infinitely, as it stops mid-air anyway. - public override bool OnTileCollide(Vector2 oldVelocity) - { - Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X * 0.6f; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y * 0.6f; - } - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(target.Center); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(target.Center); - - private void OnHitEffects(Vector2 targetPos) - { - if (Projectile.Calamity().stealthStrike) - { - var source = Projectile.GetSource_FromThis(); - for (int n = 0; n < 4; n++) - { - Projectile feather = CalamityUtils.ProjectileRain(source, targetPos, 400f, 100f, 500f, 800f, 20f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); - if (feather.whoAmI.WithinBounds(Main.maxProjectiles)) - feather.DamageType = RogueDamageClass.Instance; - } - } - } - } -} diff --git a/Projectiles/Rogue/SlickCaneProjectile.cs b/Projectiles/Rogue/SlickCaneProjectile.cs index ce965f114c..061241ef8a 100644 --- a/Projectiles/Rogue/SlickCaneProjectile.cs +++ b/Projectiles/Rogue/SlickCaneProjectile.cs @@ -80,7 +80,7 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[Projectile.owner]; //Dont drop money from Dummies, WoF eyes and worm segments to make grinding money a bit harder and not give money from Dummies since that was apparently happening - if (Projectile.owner == Main.myPlayer && target.IsAnEnemy(false) && !target.dontCountMe && !NeedsDebuffIconDisplayList.Includes(target.type)) + if (Projectile.owner == Main.myPlayer && target.IsAnEnemy(false) && !target.dontCountMe && !CalamityNPCSets.ForceDrawDebuffDisplay[target.type]) { float moneyValueToDrop = target.value / Main.rand.NextFloat(15f, 35f); // Maximum of 50 silver, not counting steath strikes diff --git a/Projectiles/Rogue/SnapClamProj.cs b/Projectiles/Rogue/SnapClamProj.cs index f84567151f..2aff8e2686 100644 --- a/Projectiles/Rogue/SnapClamProj.cs +++ b/Projectiles/Rogue/SnapClamProj.cs @@ -1,11 +1,14 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class SnapClamProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/SnapClamStealth.cs b/Projectiles/Rogue/SnapClamStealth.cs index a7dd3b8d1c..12ddd3ee4b 100644 --- a/Projectiles/Rogue/SnapClamStealth.cs +++ b/Projectiles/Rogue/SnapClamStealth.cs @@ -1,11 +1,14 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class SnapClamStealth : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/SpearofDestinyStealth.cs b/Projectiles/Rogue/SpearofDestinyStealth.cs index d117d5262e..15bca9c5e9 100644 --- a/Projectiles/Rogue/SpearofDestinyStealth.cs +++ b/Projectiles/Rogue/SpearofDestinyStealth.cs @@ -1,14 +1,10 @@ using System; -using System.Reflection.Metadata; using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Pets; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Mono.Cecil; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Rogue/SpearofDestinyStealthExplosion.cs b/Projectiles/Rogue/SpearofDestinyStealthExplosion.cs index 51f777bac3..5766d48b4e 100644 --- a/Projectiles/Rogue/SpearofDestinyStealthExplosion.cs +++ b/Projectiles/Rogue/SpearofDestinyStealthExplosion.cs @@ -1,9 +1,5 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee diff --git a/Projectiles/Rogue/SphereSpiked.cs b/Projectiles/Rogue/SphereSpiked.cs index 7d2c53512d..cde5d6edc4 100644 --- a/Projectiles/Rogue/SphereSpiked.cs +++ b/Projectiles/Rogue/SphereSpiked.cs @@ -27,6 +27,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 300; AIType = ProjectileID.WoodenBoomerang; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/SphereYellow.cs b/Projectiles/Rogue/SphereYellow.cs index cfa9694d3b..fd4022c0cc 100644 --- a/Projectiles/Rogue/SphereYellow.cs +++ b/Projectiles/Rogue/SphereYellow.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 300; AIType = ProjectileID.WoodenBoomerang; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/SporeKnifeBud.cs b/Projectiles/Rogue/SporeKnifeBud.cs index 19bf3b86cd..fab64ac627 100644 --- a/Projectiles/Rogue/SporeKnifeBud.cs +++ b/Projectiles/Rogue/SporeKnifeBud.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using static Terraria.GameContent.Animations.Actions.Sprites; namespace CalamityMod.Projectiles.Ranged { diff --git a/Projectiles/Rogue/SporeKnifeProj.cs b/Projectiles/Rogue/SporeKnifeProj.cs index 55298d704f..d40c4525c7 100644 --- a/Projectiles/Rogue/SporeKnifeProj.cs +++ b/Projectiles/Rogue/SporeKnifeProj.cs @@ -1,10 +1,5 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Ammo; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Particles; +using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/StealthRain.cs b/Projectiles/Rogue/StealthRain.cs index 1e951130d1..b4db768312 100644 --- a/Projectiles/Rogue/StealthRain.cs +++ b/Projectiles/Rogue/StealthRain.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { diff --git a/Projectiles/Rogue/StormfrontLightning.cs b/Projectiles/Rogue/StormfrontLightning.cs index bab525c68b..9c44e329f9 100644 --- a/Projectiles/Rogue/StormfrontLightning.cs +++ b/Projectiles/Rogue/StormfrontLightning.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Projectiles.Rogue; using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Terraria; @@ -83,7 +79,7 @@ namespace CalamityMod.Projectiles.Rogue //dust sparks are now a feature if (Main.rand.NextBool(10)) { - int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 226, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); + int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, DustID.Electric, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f); Main.dust[d].scale += (float)Main.rand.Next(50) * 0.01f; Main.dust[d].noGravity = true; Main.dust[d].position = Projectile.Center; @@ -153,11 +149,11 @@ namespace CalamityMod.Projectiles.Rogue } } - public float PrimitiveWidthFunction(float completionRatio) => CalamityUtils.Convert01To010(completionRatio) * Projectile.scale * Projectile.width; + public float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) => CalamityUtils.Convert01To010(completionRatio) * Projectile.scale * Projectile.width; - public Color PrimitiveColorFunction(float completionRatio) + public Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) { - //Why did you have to overcomplicate it Dom, I could have just fucking used "lightningColor = new Color(Main.rand.Next(20,100), 204, 250);" and shove it in PreDraw - Shade + //Why did you have to overcomplicate it Lucille, I could have just fucking used "lightningColor = new Color(Main.rand.Next(20,100), 204, 250);" and shove it in PreDraw - Shade float colorInterpolant = (float)Math.Sin(Projectile.identity / 3f + completionRatio * 20f + Main.GlobalTimeWrappedHourly * 1.1f) * 0.5f + 0.5f; Color color = CalamityUtils.MulticolorLerp(colorInterpolant, new Color(Main.rand.Next(20, 100), 204, 250), new Color(Main.rand.Next(20, 100), 204, 250)); return color; @@ -179,11 +175,11 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(ref Color lightColor) { - //Just gonna use Dom's work on Heavenly Gale, tried to do a new one myself but I barely understand the .fx files and how they work, might revist it again eventually - Shade + //Just gonna use Lucille's work on Heavenly Gale, tried to do a new one myself but I barely understand the .fx files and how they work, might revist it again eventually - Shade GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin"); GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply(); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.3f, false, + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Projectile.Size * 0.3f, false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), 10); return false; } diff --git a/Projectiles/Rogue/StormfrontRazorProjectile.cs b/Projectiles/Rogue/StormfrontRazorProjectile.cs index 625317777c..71423075f3 100644 --- a/Projectiles/Rogue/StormfrontRazorProjectile.cs +++ b/Projectiles/Rogue/StormfrontRazorProjectile.cs @@ -5,7 +5,6 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Utilities; namespace CalamityMod.Projectiles.Rogue { diff --git a/Projectiles/Rogue/SubductionSlicerProj.cs b/Projectiles/Rogue/SubductionSlicerProj.cs index 429d657d1b..d44e9ed49b 100644 --- a/Projectiles/Rogue/SubductionSlicerProj.cs +++ b/Projectiles/Rogue/SubductionSlicerProj.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Rogue { diff --git a/Projectiles/Rogue/SupernovaBomb.cs b/Projectiles/Rogue/SupernovaBomb.cs index fdfb0aea35..2de6b55286 100644 --- a/Projectiles/Rogue/SupernovaBomb.cs +++ b/Projectiles/Rogue/SupernovaBomb.cs @@ -1,8 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Summon; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -109,7 +107,7 @@ namespace CalamityMod.Projectiles.Rogue } for (int i = 0; i < 2; i++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12) - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 12, 303, visualDirection * Main.rand.NextFloat(0.05f, 0.7f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(12, 12) - Projectile.velocity.SafeNormalize(Vector2.UnitY) * 12, DustID.SteampunkSteam, visualDirection * Main.rand.NextFloat(0.05f, 0.7f)); dust2.scale = Main.rand.NextFloat(0.75f, 2.25f); dust2.noGravity = true; dust2.color = Main.rand.NextBool() ? Color.White : Color.Lerp(Color.White, randomColor, 0.1f); @@ -270,7 +268,7 @@ namespace CalamityMod.Projectiles.Rogue _ => Color.LawnGreen, }; Vector2 vel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 14 * Main.rand.NextFloat(0.05f, 1.2f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), 278, vel); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), DustID.FireworksRGB, vel); dust2.scale = Main.rand.NextFloat(0.45f, 1.15f); dust2.noGravity = true; dust2.color = Color.Lerp(Color.White, randomColor, 0.3f); diff --git a/Projectiles/Rogue/SupernovaBoom.cs b/Projectiles/Rogue/SupernovaBoom.cs index c2e12a9887..7a48ea630d 100644 --- a/Projectiles/Rogue/SupernovaBoom.cs +++ b/Projectiles/Rogue/SupernovaBoom.cs @@ -1,14 +1,10 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; -using CalamityMod.NPCs.Crags; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; -using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Projectiles.Rogue { @@ -130,7 +126,7 @@ namespace CalamityMod.Projectiles.Rogue } Projectile.velocity = Vector2.Zero; - Owner.Calamity().GeneralScreenShakePower = 5f; + Owner.SetScreenshake(5f); int points = 5; float radians = MathHelper.TwoPi / points; diff --git a/Projectiles/Rogue/SupernovaStealthBoom.cs b/Projectiles/Rogue/SupernovaStealthBoom.cs index d2f46b2302..b78d856f42 100644 --- a/Projectiles/Rogue/SupernovaStealthBoom.cs +++ b/Projectiles/Rogue/SupernovaStealthBoom.cs @@ -1,17 +1,12 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Particles; -using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static Humanizer.In; namespace CalamityMod.Projectiles.Rogue { @@ -150,7 +145,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.numHits = 0; damageFrame = true; doDamage = true; - Owner.Calamity().GeneralScreenShakePower = 14.5f; + Owner.SetScreenshake(14.5f); for (int i = 0; i < 55; i++) { @@ -161,7 +156,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 150; i++) { Vector2 randVel = new Vector2(15, 15).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.6f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + randVel, 303, randVel); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + randVel, DustID.SteampunkSteam, randVel); dust2.scale = Main.rand.NextFloat(1.75f, 2.5f); dust2.noGravity = true; dust2.color = new Color(57, 46, 115); @@ -288,7 +283,7 @@ namespace CalamityMod.Projectiles.Rogue _ => Color.LawnGreen, }; Vector2 vel = target.Center.DirectionFrom(Projectile.Center).SafeNormalize(Vector2.UnitX) * 20 * Main.rand.NextFloat(0.05f, 1.2f); - Dust dust2 = Dust.NewDustPerfect(target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f), 66, vel); + Dust dust2 = Dust.NewDustPerfect(target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f), DustID.RainbowTorch, vel); dust2.scale = Main.rand.NextFloat(1.15f, 2f); dust2.noGravity = true; dust2.color = Color.Lerp(Color.White, randomColor, 0.9f); diff --git a/Projectiles/Rogue/TalonSmallProj.cs b/Projectiles/Rogue/TalonSmallProj.cs index 017bdfe455..1694f4b37d 100644 --- a/Projectiles/Rogue/TalonSmallProj.cs +++ b/Projectiles/Rogue/TalonSmallProj.cs @@ -43,19 +43,18 @@ namespace CalamityMod.Projectiles.Rogue // spawn dust if (Main.rand.NextBool(5)) { - int dustType = Main.rand.NextBool() ? DustID.Chlorophyte : DustID.UnusedBrown; + int dustType = Main.rand.NextBool() ? DustID.Chlorophyte : DustID.Ash; Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, Scale: 0.9f); } - // freely spins instead of facing forwards - Projectile.rotation += 0.26f; + Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); Projectile.ai[0]++; } private void ApplySineVelocity(Vector2 baseVelocity) { - float radians = Projectile.ai[1] * (float)Math.Sin(-MathHelper.PiOver2 + 0.25f * Projectile.ai[0]); + float radians = Projectile.ai[1] * (float)Math.Sin(-MathHelper.PiOver2 + 0.25f * Projectile.ai[0]) * 0.5f; Projectile.velocity = baseVelocity.RotatedBy(radians); } @@ -71,7 +70,9 @@ namespace CalamityMod.Projectiles.Rogue public override bool PreDraw(ref Color lightColor) { Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); + Color draw = Color.Lerp(lightColor, Color.White, 0.5f); + SpriteEffects sp = Projectile.ai[1] == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(draw), Projectile.rotation, tex.Size() / 2f, Projectile.scale, sp, 0); return false; } } diff --git a/Projectiles/Rogue/TarragonThrowingDartProjectile.cs b/Projectiles/Rogue/TarragonThrowingDartProjectile.cs index 9741c76fb2..156db5a62b 100644 --- a/Projectiles/Rogue/TarragonThrowingDartProjectile.cs +++ b/Projectiles/Rogue/TarragonThrowingDartProjectile.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Dusts; -using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/TheAtomSplitterProjectile.cs b/Projectiles/Rogue/TheAtomSplitterProjectile.cs index c2278e7890..3c3c9d3e62 100644 --- a/Projectiles/Rogue/TheAtomSplitterProjectile.cs +++ b/Projectiles/Rogue/TheAtomSplitterProjectile.cs @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Rogue for (float direction = -1f; direction <= 1f; direction += 2f) { - Dust prismaticEnergy = Dust.NewDustPerfect(tipPosition, 267); + Dust prismaticEnergy = Dust.NewDustPerfect(tipPosition, DustID.RainbowMk2); prismaticEnergy.velocity = currentDirection.RotatedBy(direction * dustVelocityArcOffset) * -7f + Projectile.velocity; prismaticEnergy.scale = 1.2f; prismaticEnergy.color = dustColor; diff --git a/Projectiles/Rogue/TheSyringeCinder.cs b/Projectiles/Rogue/TheSyringeCinder.cs index fcd99f75ce..2c21966add 100644 --- a/Projectiles/Rogue/TheSyringeCinder.cs +++ b/Projectiles/Rogue/TheSyringeCinder.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Rogue/TitaniumShurikenProjectile.cs b/Projectiles/Rogue/TitaniumShurikenProjectile.cs index de17c8d7e8..0fa076bd92 100644 --- a/Projectiles/Rogue/TitaniumShurikenProjectile.cs +++ b/Projectiles/Rogue/TitaniumShurikenProjectile.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Rogue/ToothBallProjectile.cs b/Projectiles/Rogue/ToothBallProjectile.cs index dda87de504..8592253161 100644 --- a/Projectiles/Rogue/ToothBallProjectile.cs +++ b/Projectiles/Rogue/ToothBallProjectile.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.Rogue; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -22,6 +21,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 600; AIType = ProjectileID.ThrowingKnife; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 30; } diff --git a/Projectiles/Rogue/TotalMeltdown.cs b/Projectiles/Rogue/TotalMeltdown.cs index 48e2eb7e92..f439d9122b 100644 --- a/Projectiles/Rogue/TotalMeltdown.cs +++ b/Projectiles/Rogue/TotalMeltdown.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = -1; Projectile.timeLeft = Main.projFrames[Type] * 5; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; + Projectile.localNPCHitCooldown = -1; } public override void AI() diff --git a/Projectiles/Rogue/TotalityFlask.cs b/Projectiles/Rogue/TotalityFlask.cs index 545f479c5b..e4ca68525c 100644 --- a/Projectiles/Rogue/TotalityFlask.cs +++ b/Projectiles/Rogue/TotalityFlask.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Rogue Dust dust2 = Main.dust[index3]; dust2.velocity *= 3f; } - int tarAmt = Main.rand.Next(2, 4); + int tarAmt = Projectile.Calamity().stealthStrike ? 5 : Main.rand.Next(2, 3+1); for (int t = 0; t < tarAmt; t++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); diff --git a/Projectiles/Rogue/TotalityTar.cs b/Projectiles/Rogue/TotalityTar.cs index 98d51d5ec5..c9b92c8d76 100644 --- a/Projectiles/Rogue/TotalityTar.cs +++ b/Projectiles/Rogue/TotalityTar.cs @@ -79,23 +79,16 @@ namespace CalamityMod.Projectiles.Rogue { SoundEngine.PlaySound(SoundID.Item74, Projectile.position); Vector2 vector2 = new Vector2(20f, 20f); - for (int index = 0; index < 3; ++index) + for (int i = 0; i < 3; ++i) Dust.NewDust(Projectile.Center - vector2 / 2f, (int)vector2.X, (int)vector2.Y, DustID.SpookyWood, 0.0f, 0.0f, 0, Color.Red, 1f); - for (int index1 = 0; index1 < 5; ++index1) + for (int j = 0; j < 5; ++j) { - int index2 = Dust.NewDust(Projectile.Center - vector2 / 2f, (int)vector2.X, (int)vector2.Y, DustID.Smoke, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust = Main.dust[index2]; - dust.velocity *= 1.4f; - } - for (int index1 = 0; index1 < 10; ++index1) - { - int index2 = Dust.NewDust(Projectile.Center - vector2 / 2f, (int)vector2.X, (int)vector2.Y, DustID.Torch, 0.0f, 0.0f, 100, new Color(), 2.5f); - Dust dust1 = Main.dust[index2]; - dust1.noGravity = true; - dust1.velocity *= 5f; - int index3 = Dust.NewDust(Projectile.Center - vector2 / 2f, (int)vector2.X, (int)vector2.Y, DustID.Torch, 0.0f, 0.0f, 100, new Color(), 1.5f); - Dust dust2 = Main.dust[index3]; - dust2.velocity *= 3f; + Dust smoke = Dust.NewDustDirect(Projectile.Center - vector2 / 2f, (int)vector2.X, (int)vector2.Y, DustID.Smoke, 0.0f, 0.0f, 100, new Color(), 1.5f); + smoke.velocity *= 1.4f; + + Dust fire = Dust.NewDustDirect(Projectile.Center - vector2 / 2f, (int)vector2.X, (int)vector2.Y, DustID.Torch, 0.0f, 0.0f, 100, new Color(), 2.5f); + fire.noGravity = true; + fire.velocity *= 5f; } int fireAmt = Main.rand.Next(2, 4); if (Projectile.owner == Main.myPlayer) diff --git a/Projectiles/Rogue/ToxicantTwisterDust.cs b/Projectiles/Rogue/ToxicantTwisterDust.cs index e45b387d1d..70fc9fcc83 100644 --- a/Projectiles/Rogue/ToxicantTwisterDust.cs +++ b/Projectiles/Rogue/ToxicantTwisterDust.cs @@ -1,10 +1,6 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Dusts; diff --git a/Projectiles/Rogue/ToxicantTwisterProj.cs b/Projectiles/Rogue/ToxicantTwisterProj.cs index 8099348e8e..2a12cd17fd 100644 --- a/Projectiles/Rogue/ToxicantTwisterProj.cs +++ b/Projectiles/Rogue/ToxicantTwisterProj.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Rogue } if (Projectile.timeLeft % 50 == 0) { - Projectile dustProjectile = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.1f) * -0.6f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.33f), 0f, Projectile.owner, 0, 0, Projectile.ai[2]); + Projectile dustProjectile = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.1f) * -0.6f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0f, Projectile.owner, 0, 0, Projectile.ai[2]); dustProjectile.timeLeft = 240; } } @@ -110,7 +110,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 5; i++) { Vector2 dustVel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(4, 8); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel, 278, dustVel * 0.7f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel, DustID.FireworksRGB, dustVel * 0.7f); dust2.scale = Main.rand.NextFloat(0.8f, 0.9f); dust2.noGravity = false; dust2.color = Color.Lerp(Color.White, Main.rand.NextBool(4) ? Color.Chartreuse : Color.Green, 0.7f); diff --git a/Projectiles/Rogue/UmbraphileBoom.cs b/Projectiles/Rogue/UmbraphileBoom.cs index 1437255fe8..add1a4ff4f 100644 --- a/Projectiles/Rogue/UmbraphileBoom.cs +++ b/Projectiles/Rogue/UmbraphileBoom.cs @@ -1,8 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue diff --git a/Projectiles/Rogue/UrchinStingerProj.cs b/Projectiles/Rogue/UrchinStingerProj.cs index d874b1ee34..e2e73954eb 100644 --- a/Projectiles/Rogue/UrchinStingerProj.cs +++ b/Projectiles/Rogue/UrchinStingerProj.cs @@ -1,4 +1,5 @@ using CalamityMod.Dusts; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -9,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { + [PierceResistException] public class UrchinStingerProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; diff --git a/Projectiles/Rogue/ValariBoomerang.cs b/Projectiles/Rogue/ValariBoomerang.cs index 9db3525406..40790b782c 100644 --- a/Projectiles/Rogue/ValariBoomerang.cs +++ b/Projectiles/Rogue/ValariBoomerang.cs @@ -1,9 +1,7 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Particles; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -145,7 +143,6 @@ namespace CalamityMod.Projectiles.Rogue Projectile.velocity.Y -= acceleration; } - // Delete the projectile if it touches its owner. if (Main.myPlayer == Projectile.owner) if (Projectile.Hitbox.Intersects(owner.Hitbox)) @@ -198,8 +195,6 @@ namespace CalamityMod.Projectiles.Rogue { OnHitEffects(target); target.AddBuff(BuffID.Frostburn2, 120); - if (Projectile.Calamity().stealthStrike) - target.AddBuff(ModContent.BuffType(), 45); } public override bool OnTileCollide(Vector2 oldVelocity) @@ -228,8 +223,9 @@ namespace CalamityMod.Projectiles.Rogue { SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); Vector2 splinterVel = Projectile.velocity.RotatedByRandom(MathHelper.Pi / 12f); - Gore.NewGore(Projectile.GetSource_Death(), Projectile.Center, splinterVel, Mod.Find("FrostcrushValariGore1").Type); - Gore.NewGore(Projectile.GetSource_Death(), Projectile.Center, splinterVel, Mod.Find("FrostcrushValariGore2").Type); + + for (int i = 1; i <= 5; i++) + Gore.NewGore(Projectile.GetSource_Death(), Projectile.Center, splinterVel, Mod.Find($"FrostcrushValariGore{i}").Type); } } diff --git a/Projectiles/Rogue/VegaProjectile.cs b/Projectiles/Rogue/VegaProjectile.cs new file mode 100644 index 0000000000..7d0b91d0cc --- /dev/null +++ b/Projectiles/Rogue/VegaProjectile.cs @@ -0,0 +1,144 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.CalPlayer; +using CalamityMod.Systems.Mechanic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class VegaProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Vega"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 1; + } + + public override void SetDefaults() + { + Projectile.width = 20; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 300; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.MaxUpdates = 2; + } + + private int SplitProjDamage => (int)(Projectile.damage * 0.6f); + + public override void AI() + { + if (Projectile.ai[0] == 0f) + Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.ToRadians(45); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + OnHitEffects(); + var owner = Main.player[Projectile.owner]; + if (Projectile.ai[1] > 0) + { + foreach (var item in Main.ActiveProjectiles) + { + if (item.type == ModContent.ProjectileType() && item.owner == Projectile.owner) + { + item.ai[2] = target.whoAmI + 1; + item.timeLeft = Math.Max(300,item.timeLeft); + item.penetrate = 1; + item.usesIDStaticNPCImmunity = false; + item.usesLocalNPCImmunity = true; + item.localNPCHitCooldown = 10; + } + } + } + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + OnHitEffects(); + } + + private void OnHitEffects() + { + int onHitCount = 6; + float spread = 20f; + int projectileDamage = SplitProjDamage; + float kb = 5f; + int sparkID = ModContent.ProjectileType(); + int starID = ModContent.ProjectileType(); + if (Projectile.Calamity().stealthStrike) + for (int i = 0; i < 1; i++) + { + int projID = ModContent.ProjectileType(); + Vector2 velocity = Vector2.Zero; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, projID, projectileDamage, kb, Projectile.owner); + } + for (int i = 0; i < onHitCount; i++) + { + int projID = i % 3 == 0 ? starID : sparkID; + Vector2 velocity = Projectile.oldVelocity.RotateRandom(MathHelper.ToRadians(spread)) * 0.5f; + float speed = Main.rand.NextFloat(1.5f, 2f); + float moveDuration = Main.rand.Next(5, 15); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * speed, projID, projectileDamage, kb, Projectile.owner, 0f, moveDuration); + } + + SoundEngine.PlaySound(SoundID.Item62 with { Volume = SoundID.Item62.Volume * 0.6f }, Projectile.position); + SoundEngine.PlaySound(SoundID.Item68 with { Volume = SoundID.Item68.Volume * 0.2f }, Projectile.position); + SoundEngine.PlaySound(SoundID.Item122 with { Volume = SoundID.Item122.Volume * 0.4f }, Projectile.position); + + for (var i = 0; i < (Projectile.ai[1] == 0 && Projectile.Calamity().stealthStrike ? 3 : 1); i++) + { + Main.player[Projectile.owner].Calamity().StratusStarburst++; + if (Main.player[Projectile.owner].Calamity().StratusStarburst <= CalamityPlayer.MaxStratusStarburst) + Main.player[Projectile.owner].Calamity().StarburstEntities.Add(new StarburstEntity(Projectile.Center)); + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.Dig, Projectile.position); + Projectile.Kill(); + return false; + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + return false; + } + + public override void PostDraw(Color lightColor) + { + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Rogue/VegaGlow").Value; + Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / 2f); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, 1f, SpriteEffects.None, 0); + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); + + int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X / 3f, Projectile.velocity.Y / 3f, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + } + } + } +} diff --git a/Projectiles/Rogue/VegaSpark.cs b/Projectiles/Rogue/VegaSpark.cs new file mode 100644 index 0000000000..60e5d2cd2b --- /dev/null +++ b/Projectiles/Rogue/VegaSpark.cs @@ -0,0 +1,80 @@ + +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class VegaSpark : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public static int lifetime = 150; + + public override void SetDefaults() + { + Projectile.width = 6; + Projectile.height = 6; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 5; + Projectile.timeLeft = lifetime; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.localAI[0] = 20f; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.MaxUpdates = 2; + } + + public override void AI() + { + Projectile.rotation += Projectile.direction * Projectile.ai[0]; + + if (Projectile.timeLeft < (lifetime - Projectile.ai[1]) && Projectile.localAI[0] >= 0) + { + Projectile.velocity.Normalize(); + Projectile.velocity *= Projectile.localAI[0]; + Projectile.localAI[0]--; + } + + if (Projectile.localAI[0] == 0) + { + Projectile.Kill(); + } + GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center,Projectile.velocity* 0.001f,false,10,1,new Color(69,69,200))); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + Projectile.Kill(); + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dustToUse = Main.rand.Next(0, 3); + int dustType = 0; + switch (dustToUse) + { + case 0: + dustType = 109; + break; + case 1: + dustType = 111; + break; + case 2: + dustType = 132; + break; + } + + int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0.75f; + } + } + } +} diff --git a/Projectiles/Rogue/NightsGazeSpark.png b/Projectiles/Rogue/VegaSpark.png similarity index 100% rename from Projectiles/Rogue/NightsGazeSpark.png rename to Projectiles/Rogue/VegaSpark.png diff --git a/Projectiles/Rogue/VegaStar.cs b/Projectiles/Rogue/VegaStar.cs new file mode 100644 index 0000000000..4c2240f9f7 --- /dev/null +++ b/Projectiles/Rogue/VegaStar.cs @@ -0,0 +1,139 @@ + +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using rail; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class VegaStar : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public static int lifetime = 300; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 1; + } + + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 5; + lifetime = 600; + Projectile.timeLeft = lifetime; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.localAI[0] = 20f; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.MaxUpdates = 2; + } + + public override void AI() + { + Projectile.rotation += Projectile.direction * 0.05f; + if (Projectile.FinalExtraUpdate()) + { + var star = new BloomParticle(Projectile.Center, Vector2.Zero, Color.SkyBlue, 0.2f, 0.25f, 2, false); + var star2 = new CustomSpark(Projectile.Center, Vector2.UnitX.RotatedBy(Projectile.rotation) * 0.1f, "CalamityMod/Particles/Sparkle", false, 2, 1f, Color.White, Vector2.One); + GeneralParticleHandler.SpawnParticle(star); + GeneralParticleHandler.SpawnParticle(star2); + } + if (Projectile.ai[0] == 0f) + { + if (Projectile.timeLeft < (lifetime - Projectile.ai[1]) && Projectile.localAI[0] >= 0) + { + Projectile.velocity.Normalize(); + Projectile.velocity *= Projectile.localAI[0]; + Projectile.localAI[0]--; + GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, Projectile.velocity * 0.001f, false, 10, 1, Color.SkyBlue)); + } + else if (Projectile.timeLeft >= (lifetime - Projectile.ai[1])) + { + GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, Projectile.velocity * 0.001f, false, 10, 1, Color.SkyBlue)); + } + } + else if (Projectile.ai[0] == 1f) + { + float minDist = 999f; + int index = 0; + foreach (NPC npc in Main.ActiveNPCs) + { + if (npc.CanBeChasedBy(Projectile, false)) + { + float dist = (Projectile.Center - npc.Center).Length(); + if (dist < minDist) + { + minDist = dist; + index = npc.whoAmI; + } + } + } + + if (minDist < 999f) + { + Vector2 velocityNew = Main.npc[index].Center - Projectile.Center; + float speed = 10f; + velocityNew.Normalize(); + Projectile.velocity = velocityNew * speed; + } + } + if (Projectile.ai[2] > 0 && Projectile.localAI[0] < 0) + { + if (Main.npc.IndexInRange((int)Projectile.ai[2]-1) && Main.npc[(int)Projectile.ai[2]-1].active) + { + Projectile.velocity += Projectile.DirectionTo(Main.npc[(int)Projectile.ai[2] - 1].Center); + Projectile.velocity *= 0.95f; + } + } + if (Projectile.soundDelay == 0 && Projectile.velocity.Length() > 0.1f) + { + Projectile.soundDelay = 60; + SoundEngine.PlaySound(SoundID.Item9 with { Volume = 0.5f}, Projectile.position); + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height); + Projectile.Kill(); + return false; + } + + public override bool PreDraw(ref Color lightColor) + { + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); + + int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[2] == 0) + return; + target.AddBuff(ModContent.BuffType(), 120); + } + } +} diff --git a/Projectiles/Rogue/NightsGazeStar.png b/Projectiles/Rogue/VegaStar.png similarity index 100% rename from Projectiles/Rogue/NightsGazeStar.png rename to Projectiles/Rogue/VegaStar.png diff --git a/Projectiles/Rogue/WebBallBol.cs b/Projectiles/Rogue/WebBallBol.cs index 14840d8a11..278ffb7121 100644 --- a/Projectiles/Rogue/WebBallBol.cs +++ b/Projectiles/Rogue/WebBallBol.cs @@ -18,6 +18,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.timeLeft = 300; Projectile.DamageType = RogueDamageClass.Instance; Projectile.aiStyle = ProjAIStyleID.GroundProjectile; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Rogue/WhitewaterAura.cs b/Projectiles/Rogue/WhitewaterAura.cs index cc86ca7ba0..e47fa8cfe1 100644 --- a/Projectiles/Rogue/WhitewaterAura.cs +++ b/Projectiles/Rogue/WhitewaterAura.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -55,7 +54,7 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 4; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(200f * areaScale, 200f * areaScale), 66); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2CircularEdge(200f * areaScale, 200f * areaScale), DustID.RainbowTorch); dust.scale = Main.rand.NextFloat(0.3f, 0.7f); dust.velocity = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f); dust.color = Color.LightBlue; diff --git a/Projectiles/Rogue/WhitewaterProj.cs b/Projectiles/Rogue/WhitewaterProj.cs index 1bc378ec2d..dcfa2b4da3 100644 --- a/Projectiles/Rogue/WhitewaterProj.cs +++ b/Projectiles/Rogue/WhitewaterProj.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -36,7 +37,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.DamageType = RogueDamageClass.Instance; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; } public override void AI() { @@ -62,7 +63,7 @@ namespace CalamityMod.Projectiles.Rogue Lighting.AddLight(Projectile.Center, Color.LightBlue.ToVector3() * fade); if (Main.rand.NextBool(5)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15, 15), 278); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(15, 15), DustID.FireworksRGB); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.3f, 0.55f); dust.velocity = Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f); @@ -94,7 +95,7 @@ namespace CalamityMod.Projectiles.Rogue if (Main.rand.NextBool(5)) { Vector2 vel = (Vector2.One * 19).RotatedByRandom(100) * Main.rand.NextFloat(0.9f, 1.1f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 3, 66); + Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 3, DustID.RainbowTorch); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 0.85f); dust.velocity = -vel * Main.rand.NextFloat(0.2f, 0.4f); @@ -106,7 +107,7 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 25; i++) { Vector2 vel = (Vector2.One * 24).RotatedByRandom(100) * Main.rand.NextFloat(0.9f, 1.1f); - Dust dust = Dust.NewDustPerfect(Projectile.Center, 66); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowTorch); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 0.85f); dust.velocity = vel * Main.rand.NextFloat(0.2f, 0.4f); @@ -164,29 +165,25 @@ namespace CalamityMod.Projectiles.Rogue { if (Projectile.Hitbox.Intersects(Owner.Hitbox)) { - Projectile.Kill(); if (Projectile.Calamity().stealthStrike) { - for (int x = 0; x < Main.maxProjectiles; x++) + foreach (Projectile p in Main.ActiveProjectiles) { - Projectile projectile = Main.projectile[x]; - if (projectile.active) + if (p.type == ModContent.ProjectileType() && p.owner == Projectile.owner) { - if (projectile.type == ModContent.ProjectileType()) - { - if (projectile.timeLeft > 30) - projectile.timeLeft = 30; - } + if (p.timeLeft > 30) + p.timeLeft = 30; } } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.2f), Projectile.knockBack, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25f), Projectile.knockBack, Projectile.owner, 0f, 0f); } + Projectile.Kill(); } } } time++; } - public override bool? CanDamage() => (shattered && !returning) ? false : null; + public override bool? CanDamage() => (shattered || returning) ? false : null; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (damageModifier > 0.05f) @@ -197,7 +194,7 @@ namespace CalamityMod.Projectiles.Rogue SoundStyle sound = new("CalamityMod/Sounds/Item/BreakAndReform"); SoundEngine.PlaySound(sound with { Volume = 0.4f }, Projectile.Center); - int points = Projectile.Calamity().stealthStrike ? 8 : 4; + int points = Projectile.Calamity().stealthStrike ? 6 : 4; float radians = MathHelper.TwoPi / points; Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)); for (int k = 0; k < points; k++) diff --git a/Projectiles/Rogue/WhitewaterSpear.cs b/Projectiles/Rogue/WhitewaterSpear.cs index dedcc42106..c0967afa4f 100644 --- a/Projectiles/Rogue/WhitewaterSpear.cs +++ b/Projectiles/Rogue/WhitewaterSpear.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.extraUpdates = 5; Projectile.DamageType = RogueDamageClass.Instance; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 25; + Projectile.localNPCHitCooldown = 20 * Projectile.MaxUpdates; } public override void AI() diff --git a/Projectiles/Rogue/WulfrumKnifeProj.cs b/Projectiles/Rogue/WulfrumKnifeProj.cs index 4f6a26f038..1e27343593 100644 --- a/Projectiles/Rogue/WulfrumKnifeProj.cs +++ b/Projectiles/Rogue/WulfrumKnifeProj.cs @@ -25,10 +25,26 @@ namespace CalamityMod.Projectiles.Rogue ProjectileID.Sets.TrailingMode[Type] = 0; } - public static int Lifetime = 950; + public static int Lifetime = 1440; public float LifetimeCompletion => MathHelper.Clamp((Lifetime - Projectile.timeLeft) / (float)Lifetime, 0f, 1f); public float StealthEffectOpacity => MathHelper.Clamp(1 - LifetimeCompletion, 0f, 1f); + public float StuckEnemyID + { + get { return Projectile.ai[0]; } + set { Projectile.ai[0] = value; } + } + public float StuckEnemyDistance + { + get { return Projectile.ai[1]; } + set { Projectile.ai[1] = value; } + } + public float StuckEnemyRotation + { + get { return Projectile.ai[2]; } + set { Projectile.ai[2] = value; } + } + public override void SetDefaults() { Projectile.width = 12; @@ -41,11 +57,48 @@ namespace CalamityMod.Projectiles.Rogue Projectile.extraUpdates = 5; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 1; + Projectile.stopsDealingDamageAfterPenetrateHits = true; } public override void AI() { + if (StuckEnemyID > 0) + { + Projectile.tileCollide = false; + if (!Main.npc[(int)StuckEnemyID-1].active) + { + StuckEnemyID = 0; + Projectile.velocity = -Vector2.UnitY.RotatedByRandom(0.25f) * Main.rand.NextFloat(0, 1f); + Projectile.tileCollide = true; + return; + } + Projectile.Center = Main.npc[(int)StuckEnemyID-1].Center + Vector2.UnitX.RotatedBy(StuckEnemyRotation) * StuckEnemyDistance; + return; + } + if (StuckEnemyID == -1) + { + var player = Main.player[Projectile.owner]; + Projectile.velocity = Projectile.DirectionTo(player.Center) * 10f; + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + if (Main.rand.NextBool(3)) + { + Vector2 dustCenter = Projectile.Center + Main.rand.NextVector2Circular(4f, 4f); + + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.1f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); + chust.noGravity = true; + } + if (Projectile.Distance(player.Center) < 16) + { + //Gives 1 second of armorless stealth usage + player.Calamity().temporaryStealthTimer = 60; + if (player.Calamity().rogueStealthMax < 0.1f) + player.Calamity().rogueStealthMax = 0.1f; + player.Calamity().rogueStealth += player.Calamity().rogueStealthMax * 0.084f; + Projectile.Kill(); + } + return; + } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; Projectile.velocity *= 0.998f; @@ -59,7 +112,7 @@ namespace CalamityMod.Projectiles.Rogue { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust chust = Dust.NewDustPerfect(dustCenter, 15, -Projectile.velocity * Main.rand.NextFloat(0.6f, 1.5f), Scale: Main.rand.NextFloat(1f, 1.4f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, -Projectile.velocity * Main.rand.NextFloat(0.6f, 1.5f), Scale: Main.rand.NextFloat(1f, 1.4f)); chust.noGravity = true; if (!Main.rand.NextBool(5)) @@ -83,7 +136,7 @@ namespace CalamityMod.Projectiles.Rogue { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust chust = Dust.NewDustPerfect(dustCenter, 15, -Projectile.velocity * Main.rand.NextFloat(0.6f, 1.5f), Scale: Main.rand.NextFloat(1f, 1.4f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, -Projectile.velocity * Main.rand.NextFloat(0.6f, 1.5f), Scale: Main.rand.NextFloat(1f, 1.4f)); chust.noGravity = true; chust.noLightEmittence = true; } @@ -92,6 +145,10 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { SoundEngine.PlaySound(WulfrumKnife.TileHitSound, Projectile.Center); + Projectile.timeLeft = Lifetime; + StuckEnemyID = target.whoAmI+1; + StuckEnemyDistance = Projectile.Distance(target.Center); + StuckEnemyRotation = Projectile.DirectionFrom(target.Center).ToRotation(); } public override bool OnTileCollide(Vector2 oldVelocity) @@ -102,13 +159,13 @@ namespace CalamityMod.Projectiles.Rogue return base.OnTileCollide(oldVelocity); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = (float)Math.Pow(1 - completionRatio, 2) * StealthEffectOpacity; return Color.GreenYellow.MultiplyRGB(PrimColorMult) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return 9.4f; } @@ -118,7 +175,7 @@ namespace CalamityMod.Projectiles.Rogue Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; float opacitey = StealthEffectOpacity; - if (Projectile.Calamity().stealthStrike) + if (Projectile.Calamity().stealthStrike && StuckEnemyID == 0) { Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); @@ -128,7 +185,7 @@ namespace CalamityMod.Projectiles.Rogue CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1f, delegate (Vector2 offset, Color colorMod) { PrimColorMult = colorMod; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); }); diff --git a/Projectiles/Summon/AmphibiansGuitarHoldout.cs b/Projectiles/Summon/AmphibiansGuitarHoldout.cs index 966171311f..0b2a688865 100644 --- a/Projectiles/Summon/AmphibiansGuitarHoldout.cs +++ b/Projectiles/Summon/AmphibiansGuitarHoldout.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -23,6 +24,7 @@ namespace CalamityMod.Projectiles.Summon private static readonly int MinionType = ModContent.ProjectileType(); + public override void SetStaticDefaults() => ProjectileID.Sets.MinionTargettingFeature[Type] = true; public override void SetDefaults() { Projectile.width = Projectile.height = 50; diff --git a/Projectiles/Summon/AmphibiansGuitarMinion.cs b/Projectiles/Summon/AmphibiansGuitarMinion.cs index ddfab3cd17..5f026779bb 100644 --- a/Projectiles/Summon/AmphibiansGuitarMinion.cs +++ b/Projectiles/Summon/AmphibiansGuitarMinion.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Summon SoundStyle spawnSound = new("CalamityMod/Sounds/Item/AmphibiansGuitarSummon"); SoundEngine.PlaySound(spawnSound with { Volume = 0.8f, Pitch = (GuitarSprite == 2 || GuitarSprite == 5) ? -0.15f : 0f }, Projectile.Center); - ShootTimer = GuitarSprite * 10f; + ShootTimer = GuitarSprite * 12f; _hasSpawned = true; } @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Summon if (Target != null) { bool bigShot = ShootCount % 3 == 0; - if (ShootTimer > 80f && Main.myPlayer == Projectile.owner) + if (ShootTimer > 96f && Main.myPlayer == Projectile.owner) { for (int i = 0; i < (bigShot ? 3 : 1); i++) { @@ -76,7 +76,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.NewProjectile( Projectile.GetSource_FromThis(), Projectile.Center, - CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, Target, 18f * (1f - Math.Abs(rot))).RotatedBy(rot), + CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, Target, (bigShot ? 36f : 25f) * (1f - Math.Abs(rot))).RotatedBy(rot), ProjectileType(), Projectile.damage, Projectile.knockBack, @@ -140,8 +140,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool? CanDamage() => false; - public override bool PreDraw(ref Color lightColor) { Texture2D texture = TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/AmphibiansGuitarProjectile.cs b/Projectiles/Summon/AmphibiansGuitarProjectile.cs index 5782e66785..bde7e8a8b4 100644 --- a/Projectiles/Summon/AmphibiansGuitarProjectile.cs +++ b/Projectiles/Summon/AmphibiansGuitarProjectile.cs @@ -5,7 +5,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using System; using CalamityMod.Dusts; using Terraria.Audio; @@ -33,21 +32,20 @@ namespace CalamityMod.Projectiles.Summon Projectile.width = 54; Projectile.height = 44; Projectile.timeLeft = 150; - Projectile.localNPCHitCooldown = 20; Projectile.friendly = true; Projectile.tileCollide = false; + Projectile.penetrate = 1; Projectile.usesLocalNPCImmunity = true; - Projectile.penetrate = -1; - Projectile.extraUpdates = 0; + Projectile.localNPCHitCooldown = 20; } public override void AI() { if (time == 0) { - if (IsHatNote) - Projectile.penetrate = 1; if (Projectile.ai[2] == 5) - Projectile.extraUpdates = 1; + { + Projectile.penetrate = 3; + } } Projectile.scale = 1.6f * Utils.GetLerpValue(-5, 20, time, true); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; diff --git a/Projectiles/Summon/AndromedaDeathRay.cs b/Projectiles/Summon/AndromedaDeathRay.cs index 887b45d8a6..e4ac485ec5 100644 --- a/Projectiles/Summon/AndromedaDeathRay.cs +++ b/Projectiles/Summon/AndromedaDeathRay.cs @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 4; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 133); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Firework_Yellow); dust.velocity = Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(2f, 3.5f) + Main.player[Projectile.owner].velocity * 1.5f; dust.fadeIn = Main.rand.NextFloat(0.6f, 0.85f); if (player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot) @@ -136,7 +136,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 3; i++) { - Dust dust = Dust.NewDustPerfect(beamEndPosiiton + angle.ToRotationVector2() * 8f, 133); + Dust dust = Dust.NewDustPerfect(beamEndPosiiton + angle.ToRotationVector2() * 8f, DustID.Firework_Yellow); dust.velocity = velocity.RotatedBy(MathHelper.TwoPi / 3f * i); dust.scale = (float)Math.Cos(angle) + 1.2f; dust.noGravity = true; diff --git a/Projectiles/Summon/AndromedaRegislash.cs b/Projectiles/Summon/AndromedaRegislash.cs index 17bdca96bc..0c9ffa773a 100644 --- a/Projectiles/Summon/AndromedaRegislash.cs +++ b/Projectiles/Summon/AndromedaRegislash.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[Projectile.owner]; if (Projectile.localAI[0] == 0f) { - if (CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner) > 1) + if (player.ownedProjectileCounts[Projectile.type] > 1) { Projectile.Kill(); return; diff --git a/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs index a2094971eb..6ecca6bb93 100644 --- a/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs +++ b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs @@ -1,10 +1,10 @@ using System.IO; -using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon.AndromedaUI @@ -293,7 +293,7 @@ namespace CalamityMod.Projectiles.Summon.AndromedaUI Player player = Main.player[Projectile.owner]; for (int i = 0; i < 45; i++) { - Dust dust = Dust.NewDustPerfect(player.Center + Utils.NextVector2Circular(Main.rand, 60f, 90f), 26); + Dust dust = Dust.NewDustPerfect(player.Center + Utils.NextVector2Circular(Main.rand, 60f, 90f), DustID.Bone); dust.velocity = Utils.NextVector2Circular(Main.rand, 4f, 4f); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.2f, 1.35f); @@ -369,7 +369,7 @@ namespace CalamityMod.Projectiles.Summon.AndromedaUI dust.noGravity = true; } } - SoundEngine.PlaySound(GaussRifle.FireSound, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MechGaussRifle"), Projectile.Center); } } } diff --git a/Projectiles/Summon/ApexShark.cs b/Projectiles/Summon/ApexShark.cs index e0063dc6e0..3bef24a545 100644 --- a/Projectiles/Summon/ApexShark.cs +++ b/Projectiles/Summon/ApexShark.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 8; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -239,6 +240,8 @@ namespace CalamityMod.Projectiles.Summon } + public override bool MinionContactDamage() => HitCooldown == 0; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Main.rand.NextBool(3)) @@ -253,14 +256,5 @@ namespace CalamityMod.Projectiles.Summon Projectile.netUpdate = true; HitCooldown = 20; } - - public override bool? CanHitNPC(NPC target) - { - if (HitCooldown == 0) - { - return null; - } - return false; - } } } diff --git a/Projectiles/Summon/AquasScepterCloud.cs b/Projectiles/Summon/AquasScepterCloud.cs index 37e01d580f..81a98d789a 100644 --- a/Projectiles/Summon/AquasScepterCloud.cs +++ b/Projectiles/Summon/AquasScepterCloud.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.Graphics.Shaders; using Terraria.ModLoader; diff --git a/Projectiles/Summon/AquasScepterTeslaAura.cs b/Projectiles/Summon/AquasScepterTeslaAura.cs index d55ee2ca0d..d82c9ac926 100644 --- a/Projectiles/Summon/AquasScepterTeslaAura.cs +++ b/Projectiles/Summon/AquasScepterTeslaAura.cs @@ -1,7 +1,5 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon diff --git a/Projectiles/Summon/AquaticStarMinion.cs b/Projectiles/Summon/AquaticStarMinion.cs index f060849af8..8267a409ae 100644 --- a/Projectiles/Summon/AquaticStarMinion.cs +++ b/Projectiles/Summon/AquaticStarMinion.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -57,7 +58,7 @@ namespace CalamityMod.Projectiles.Summon float angle = MathHelper.TwoPi / 45f * i; Vector2 direction = angle.ToRotationVector2() * 10f; - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 33, direction); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, DustID.Water, direction); spawnDust.noGravity = true; } CheckForSpawning++; @@ -70,6 +71,14 @@ namespace CalamityMod.Projectiles.Summon Projectile.ChargingMinionAI(1200f, 1500f, 2200f, 150f, 0, 24f, 15f, 4f, new Vector2(0f, -60f), 12f, 12f, false, false, 1); } + public override bool MinionContactDamage() => true; + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = true; // Should always be able to fly through platforms + return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); + } + public override bool OnTileCollide(Vector2 oldVelocity) => false; } } diff --git a/Projectiles/Summon/AstrageldonSummon.cs b/Projectiles/Summon/AstrageldonSummon.cs index 795b62514b..c5a3c69c48 100644 --- a/Projectiles/Summon/AstrageldonSummon.cs +++ b/Projectiles/Summon/AstrageldonSummon.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 6; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -209,6 +210,8 @@ namespace CalamityMod.Projectiles.Summon } } + public override bool MinionContactDamage() => true; + public override bool OnTileCollide(Vector2 oldVelocity) => false; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Summon/AstralProbeSummon.cs b/Projectiles/Summon/AstralProbeSummon.cs index 64de6fe834..3abb483622 100644 --- a/Projectiles/Summon/AstralProbeSummon.cs +++ b/Projectiles/Summon/AstralProbeSummon.cs @@ -40,6 +40,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -116,7 +117,7 @@ namespace CalamityMod.Projectiles.Summon } } - public void LookInCorrectDirection(NPC target) // I feel really fucking proud of how organized I made it. ~Memes + public void LookInCorrectDirection(NPC target) { Vector2 lookHere = (target is not null) ? target.Center : Main.MouseWorld; // Looks at the mouse if there's no enemy, if there is one, it'll look at the enemy. int direction = (lookHere.X - Projectile.Center.X > 0).ToDirectionInt(); // If the target is at it's right, look at the right, if not, at it's left. @@ -150,8 +151,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool? CanDamage() => false; - #endregion } } diff --git a/Projectiles/Summon/AtlasMunitionsAutocannon.cs b/Projectiles/Summon/AtlasMunitionsAutocannon.cs index fd34912391..2237e4ea50 100644 --- a/Projectiles/Summon/AtlasMunitionsAutocannon.cs +++ b/Projectiles/Summon/AtlasMunitionsAutocannon.cs @@ -7,7 +7,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -184,7 +183,7 @@ namespace CalamityMod.Projectiles.Summon // Be picked up by nearby players if they right click and are holding the appropriate item. bool rightClick = Main.mouseRight && Main.mouseRightRelease; - if (Main.LocalPlayer.WithinRange(Projectile.Center, AtlasMunitionsBeacon.PickupRange) && rightClick && Main.LocalPlayer.ActiveItem().type == ModContent.ItemType() && CannonIsMounted) + if (Main.LocalPlayer.WithinRange(Projectile.Center, AtlasMunitionsBeacon.PickupRange) && rightClick && Main.LocalPlayer.HeldItem.type == ModContent.ItemType() && CannonIsMounted) { Projectile heldCannon = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Main.LocalPlayer.Center, Vector2.UnitX, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Main.myPlayer); heldCannon.ModProjectile().HeatInterpolant = HeatInterpolant * 0.65f; diff --git a/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs b/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs index 2fa308dd49..239c5d7201 100644 --- a/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs +++ b/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Summon return false; // Drop the cannon if the player is not holding the appropriate item. - if (Owner.ActiveItem().type != ModContent.ItemType()) + if (Owner.HeldItem.type != ModContent.ItemType()) return false; return true; @@ -185,7 +185,7 @@ namespace CalamityMod.Projectiles.Summon // Be picked up by nearby players if they right click and are holding the appropriate item. bool rightClick = Main.mouseRight && Main.mouseRightRelease; - bool correctItem = Main.LocalPlayer.ActiveItem().type == ModContent.ItemType(); + bool correctItem = Main.LocalPlayer.HeldItem.type == ModContent.ItemType(); if (Main.LocalPlayer.WithinRange(Projectile.Center, AtlasMunitionsBeacon.PickupRange) && rightClick && correctItem && HeatInterpolant < 0.5f) { BeingHeld = true; diff --git a/Projectiles/Summon/AtlasMunitionsDropPod.cs b/Projectiles/Summon/AtlasMunitionsDropPod.cs index a2850a87e0..83f690b80f 100644 --- a/Projectiles/Summon/AtlasMunitionsDropPod.cs +++ b/Projectiles/Summon/AtlasMunitionsDropPod.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; using CalamityMod.NPCs.ExoMechs.Thanatos; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -127,7 +125,7 @@ namespace CalamityMod.Projectiles.Summon } SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode, Projectile.Center); - Owner.Calamity().GeneralScreenShakePower = Utils.Remap(Owner.Distance(Projectile.Center), 1800f, 1000f, 0f, 4.5f); + Owner.SetScreenshake(Utils.Remap(Owner.Distance(Projectile.Center), 1800f, 1000f, 0f, 4.5f)); } // As a means of obscuring contents when they spawn (such as ensuring that the minigun doesn't seem to pop into existence), this projectile draws above most other projectiles. diff --git a/Projectiles/Summon/AtlasMunitionsDropPodUpper.cs b/Projectiles/Summon/AtlasMunitionsDropPodUpper.cs index 823f66367d..6288a49cc9 100644 --- a/Projectiles/Summon/AtlasMunitionsDropPodUpper.cs +++ b/Projectiles/Summon/AtlasMunitionsDropPodUpper.cs @@ -1,7 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon diff --git a/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs b/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs index b178aadb8e..687d7d13ed 100644 --- a/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs +++ b/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Summon else puffDustVelocity = puffDustVelocity.RotatedBy(generalAngularOffset); - Dust magic = Dust.NewDustPerfect(target.Center, 182, puffDustVelocity); + Dust magic = Dust.NewDustPerfect(target.Center, DustID.TheDestroyer, puffDustVelocity); magic.scale = 1.8f; magic.fadeIn = 0.5f; magic.noGravity = true; diff --git a/Projectiles/Summon/AureusBomber.cs b/Projectiles/Summon/AureusBomber.cs index 4dd7f1f898..52d7dd22ef 100644 --- a/Projectiles/Summon/AureusBomber.cs +++ b/Projectiles/Summon/AureusBomber.cs @@ -4,7 +4,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/BabyBloodCrawler.cs b/Projectiles/Summon/BabyBloodCrawler.cs index c3b33c47d2..a206139565 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -9,12 +9,13 @@ namespace CalamityMod.Projectiles.Summon public class BabyBloodCrawler : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; - public static int bloodCooldown = 0; + public int bloodCooldown = 0; public float dust = 0f; public override void SetStaticDefaults() { Main.projFrames[Type] = 11; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -36,7 +37,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.DamageType = DamageClass.Summon; Projectile.MaxUpdates = 2; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 33 * Projectile.MaxUpdates; + Projectile.localNPCHitCooldown = 30 * Projectile.MaxUpdates; } public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) @@ -45,6 +46,20 @@ namespace CalamityMod.Projectiles.Summon return true; } + private bool _hadSpiderMinion = false; + public override bool PreAI() + { + var owner = Main.player[Projectile.owner]; + _hadSpiderMinion = owner.spiderMinion; + owner.spiderMinion = false; + return true; + } + + public override void PostAI() + { + Main.player[Projectile.owner].spiderMinion = _hadSpiderMinion; + } + public override void AI() { if (bloodCooldown > 0) @@ -53,19 +68,6 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - foreach (Projectile proj in Main.ActiveProjectiles) - { - // Short circuits to make the loop as fast as possible - if (proj.owner != Projectile.owner || !proj.minion || proj.Calamity().lineColor != 1) - continue; - if (proj.type == Projectile.type) - { - proj.Calamity().lineColor = 2; - } - } - if (Projectile.Calamity().lineColor == 0) - Projectile.Calamity().lineColor = 1; - if (dust == 0f) { int constant = 16; @@ -96,23 +98,20 @@ namespace CalamityMod.Projectiles.Summon } } + public override bool MinionContactDamage() => true; + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(target.Center); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(target.Center); - - private void OnHitEffects(Vector2 targetPos) + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(target); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(target); + private void OnHitEffects(Entity target) { if (bloodCooldown == 0) { - bloodCooldown = 17; - int projAmt = 2; - var source = Projectile.GetSource_FromThis(); - for (int n = 0; n < projAmt; n++) - { - CalamityUtils.ProjectileRain(source, targetPos, 400f, 100f, 400f, 700f, 29f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * Main.rand.NextFloat(0.7f, 1f), Projectile.owner); - } + bloodCooldown = 15; + Vector2 spawnPos = target.Center + Vector2.UnitX * Main.rand.NextFloat(-100f, 100f) - Vector2.UnitY * Main.rand.NextFloat(400f, 700f); + Vector2 velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(spawnPos, target, 25f, 2); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPos, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); } } } diff --git a/Projectiles/Summon/BelladonnaSpirit.cs b/Projectiles/Summon/BelladonnaSpirit.cs index 5d99e1cd20..34f577a36c 100644 --- a/Projectiles/Summon/BelladonnaSpirit.cs +++ b/Projectiles/Summon/BelladonnaSpirit.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -98,7 +99,7 @@ namespace CalamityMod.Projectiles.Summon { float angle = MathHelper.TwoPi / 45f * dustIndex; Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 4.5f); - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 39, velocity); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, DustID.JungleGrass, velocity); spawnDust.noGravity = true; spawnDust.scale = velocity.Length() * 0.1f; spawnDust.velocity *= 0.3f; @@ -106,8 +107,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool? CanDamage() => false; - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/BlackDragonBody.cs b/Projectiles/Summon/BlackDragonBody.cs index 27168209bd..b6c649c49c 100644 --- a/Projectiles/Summon/BlackDragonBody.cs +++ b/Projectiles/Summon/BlackDragonBody.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.Summon; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; diff --git a/Projectiles/Summon/BlackDragonHead.cs b/Projectiles/Summon/BlackDragonHead.cs index 3bca4cd7c6..e76fe8b28c 100644 --- a/Projectiles/Summon/BlackDragonHead.cs +++ b/Projectiles/Summon/BlackDragonHead.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using CalamityMod.Buffs.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -216,6 +215,8 @@ namespace CalamityMod.Projectiles.Summon } + public override bool MinionContactDamage() => true; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.ShadowFlame, 300); } } diff --git a/Projectiles/Summon/BlackDragonTail.cs b/Projectiles/Summon/BlackDragonTail.cs index 0b9be2eff1..ed0ba244f8 100644 --- a/Projectiles/Summon/BlackDragonTail.cs +++ b/Projectiles/Summon/BlackDragonTail.cs @@ -1,7 +1,5 @@ -using CalamityMod.Buffs.Summon; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon diff --git a/Projectiles/Summon/BlackHawkSummon.cs b/Projectiles/Summon/BlackHawkSummon.cs index a3b25021a1..93d42c501c 100644 --- a/Projectiles/Summon/BlackHawkSummon.cs +++ b/Projectiles/Summon/BlackHawkSummon.cs @@ -18,9 +18,10 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projFrames[Type] = 6; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; - Main.projFrames[Type] = 6; } public override void SetDefaults() @@ -299,9 +300,6 @@ namespace CalamityMod.Projectiles.Summon } } - //Does no contact damage - public override bool? CanDamage() => false; - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/BloodRain.cs b/Projectiles/Summon/BloodRain.cs index 9d79d29582..c03465dcfd 100644 --- a/Projectiles/Summon/BloodRain.cs +++ b/Projectiles/Summon/BloodRain.cs @@ -27,6 +27,8 @@ namespace CalamityMod.Projectiles.Summon AIType = ProjectileID.RainFriendly; Projectile.extraUpdates = 1; Projectile.DamageType = DamageClass.Summon; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Summon/BloodSpit.cs b/Projectiles/Summon/BloodSpit.cs index 1a0908f86e..62dd5683bd 100644 --- a/Projectiles/Summon/BloodSpit.cs +++ b/Projectiles/Summon/BloodSpit.cs @@ -1,6 +1,4 @@ -using CalamityMod.Balancing; -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -28,6 +26,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 6; Projectile.DamageType = DamageClass.Summon; + Projectile.Calamity().BloodstoneOrbValue = 12; //Bloodstone Orb lifesteal. May want to go back to regular lifesteal. } public override void AI() @@ -49,15 +48,6 @@ namespace CalamityMod.Projectiles.Summon blood.velocity = Main.rand.NextVector2Circular(1f, 2f); blood.noGravity = true; } - - int heal = (int)Math.Round(hit.Damage * 0.01); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ProjectileID.VampireHeal, BalancingConstants.LifeStealRange); } } } diff --git a/Projectiles/Summon/BrimstoneDartSummon.cs b/Projectiles/Summon/BrimstoneDartSummon.cs index a422cd416c..ccd8922fd3 100644 --- a/Projectiles/Summon/BrimstoneDartSummon.cs +++ b/Projectiles/Summon/BrimstoneDartSummon.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 15; i++) { - Dust brimstone = Dust.NewDustPerfect(Projectile.Center, 267); + Dust brimstone = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); brimstone.velocity = Projectile.velocity.RotatedByRandom(0.26f) * Main.rand.NextFloat(0.3f, 0.8f); brimstone.scale = Main.rand.NextFloat(1.5f, 1.85f); brimstone.color = Color.DarkRed; diff --git a/Projectiles/Summon/BrimstoneElementalMinion.cs b/Projectiles/Summon/BrimstoneElementalMinion.cs index 9def69225a..81f4e960a3 100644 --- a/Projectiles/Summon/BrimstoneElementalMinion.cs +++ b/Projectiles/Summon/BrimstoneElementalMinion.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Summon bool isActive = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.brimstoneWaifu && !modPlayer.allWaifus && !modPlayer.brimstoneWaifuVanity && !modPlayer.allWaifusVanity) + if (!modPlayer.brimElemental && !modPlayer.allElementals && !modPlayer.brimElementalVanity && !modPlayer.allElementalsVanity) { Projectile.active = false; return; @@ -52,9 +52,9 @@ namespace CalamityMod.Projectiles.Summon { if (player.dead) { - modPlayer.bWaifu = false; + modPlayer.brimEleBuff = false; } - if (modPlayer.bWaifu) + if (modPlayer.brimEleBuff) { Projectile.timeLeft = 2; } @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Summon Main.dust[brimDust].scale *= 1.15f; } } - bool passive = modPlayer.brimstoneWaifuVanity || modPlayer.allWaifusVanity; + bool passive = modPlayer.brimElementalVanity || modPlayer.allElementalsVanity; Projectile.frameCounter++; if (Projectile.frameCounter > 9) { @@ -210,7 +210,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.brimstoneWaifuVanity || modPlayer.allWaifusVanity) + if (modPlayer.brimElementalVanity || modPlayer.allElementalsVanity) { return false; } diff --git a/Projectiles/Summon/BrimstoneExplosionMinion.cs b/Projectiles/Summon/BrimstoneExplosionMinion.cs index 2e2db8edf5..66312416fc 100644 --- a/Projectiles/Summon/BrimstoneExplosionMinion.cs +++ b/Projectiles/Summon/BrimstoneExplosionMinion.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Summon/BrimstoneFireSummon.cs b/Projectiles/Summon/BrimstoneFireSummon.cs index d3399e3df5..c0d8293cd1 100644 --- a/Projectiles/Summon/BrimstoneFireSummon.cs +++ b/Projectiles/Summon/BrimstoneFireSummon.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -25,7 +24,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.extraUpdates = 3; Projectile.timeLeft = 50; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 9; + Projectile.idStaticNPCHitCooldown = 12; Projectile.DamageType = DamageClass.Summon; } diff --git a/Projectiles/Summon/BrimstoneLaserSummon.cs b/Projectiles/Summon/BrimstoneLaserSummon.cs index 4e5fda6383..69c063bd29 100644 --- a/Projectiles/Summon/BrimstoneLaserSummon.cs +++ b/Projectiles/Summon/BrimstoneLaserSummon.cs @@ -16,26 +16,24 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { - Projectile.width = Projectile.height = 2; + Projectile.width = Projectile.height = 10; Projectile.aiStyle = ProjAIStyleID.Arrow; + AIType = ProjectileID.CursedBullet; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.alpha = 120; Projectile.timeLeft = 300; - AIType = ProjectileID.DeathLaser; + Projectile.extraUpdates = 2; Projectile.DamageType = DamageClass.Summon; } public override void AI() { Lighting.AddLight(Projectile.Center, Projectile.Opacity * 0.5f, Projectile.Opacity * 0.05f, Projectile.Opacity * 0.05f); - Projectile.velocity.X *= 1.05f; - Projectile.velocity.Y *= 1.05f; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 120); public override Color? GetAlpha(Color lightColor) => new Color(250, 50, 50, Projectile.alpha); diff --git a/Projectiles/Summon/BrittleStarMinion.cs b/Projectiles/Summon/BrittleStarMinion.cs index c9feccb7dc..31eedec90e 100644 --- a/Projectiles/Summon/BrittleStarMinion.cs +++ b/Projectiles/Summon/BrittleStarMinion.cs @@ -1,6 +1,4 @@ -using System; -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.Summon; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; @@ -31,8 +29,8 @@ namespace CalamityMod.Projectiles.Summon public int Time = 0; public override void SetDefaults() { - Projectile.width = 42; - Projectile.height = 42; + Projectile.width = 30; + Projectile.height = 28; Projectile.localNPCHitCooldown = 15; base.SetDefaults(); } @@ -72,7 +70,7 @@ namespace CalamityMod.Projectiles.Summon float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(Main.rand.NextFloat(1.5f, 4f), 0).RotatedBy(rot * Main.rand.NextFloat(3.1f, 9.1f)); Vector2 velOffset = new Vector2(Main.rand.NextFloat(1.5f, 4f), 0).RotatedBy(rot * Main.rand.NextFloat(3.1f, 9.1f)); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 216 : 121, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 216 : 207, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = true; dust.velocity = velOffset; dust.scale = Main.rand.NextFloat(1.3f, 1.9f); @@ -122,7 +120,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.Center = Vector2.Lerp(Projectile.Center, idleDestination, 0.15f); AITimer++; - Owner.statDefense += 4; Projectile.rotation += MoveWidth * 0.2f; } if (!MinionBuffMode && !Reforming) // Minion when ramming @@ -178,7 +175,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i <= 5; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, Main.rand.NextBool(3) ? 216 : 121, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, Main.rand.NextBool(3) ? 216 : 207, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.05f, 0.4f), 0, default, Main.rand.NextFloat(1.3f, 1.8f)); dust.noGravity = true; } SoundEngine.PlaySound(SoundID.DD2_SkeletonHurt with { Pitch = 0.5f }, Projectile.Center); @@ -196,7 +193,7 @@ namespace CalamityMod.Projectiles.Summon float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); Vector2 velOffset = new Vector2(Main.rand.NextFloat(0.5f, 2.5f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 216 : 121, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 216 : 207, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = true; dust.velocity = velOffset; dust.scale = Main.rand.NextFloat(1.3f, 1.8f); diff --git a/Projectiles/Summon/BrittleStarMinion.png b/Projectiles/Summon/BrittleStarMinion.png index 4497bd57e6..739f28d509 100644 Binary files a/Projectiles/Summon/BrittleStarMinion.png and b/Projectiles/Summon/BrittleStarMinion.png differ diff --git a/Projectiles/Summon/CalamarisLamentMinion.cs b/Projectiles/Summon/CalamarisLamentMinion.cs index dd9d517abe..fbbc308064 100644 --- a/Projectiles/Summon/CalamarisLamentMinion.cs +++ b/Projectiles/Summon/CalamarisLamentMinion.cs @@ -54,13 +54,13 @@ namespace CalamityMod.Projectiles.Summon } else { - if (Main.rand.NextBool(600)) + if (Main.rand.NextBool(800)) { SoundStyle glubNoise = Main.rand.NextBool() ? SoundID.Zombie35 : SoundID.Zombie34; SoundStyle trollBirdChirpingSound = SoundID.Zombie16; - // 1/200th chance to do a bird chirping sound. - SoundEngine.PlaySound(Main.rand.NextBool(200) ? trollBirdChirpingSound : glubNoise, Projectile.Center); + // 1/2000th chance to do a bird chirping sound. + SoundEngine.PlaySound(Main.rand.NextBool(2000) ? trollBirdChirpingSound : glubNoise, Projectile.Center); } } @@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.Summon // Flavor dust effect. for (int i = 0; i < 15; i++) { - Dust shootDust = Dust.NewDustPerfect(Projectile.Center + (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * Projectile.height / 2, 109, toTargetDirection.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 7f), Scale: Main.rand.NextFloat(0.5f, 1.5f), Alpha: 127); + Dust shootDust = Dust.NewDustPerfect(Projectile.Center + (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * Projectile.height / 2, DustID.Asphalt, toTargetDirection.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 7f), Scale: Main.rand.NextFloat(0.5f, 1.5f), Alpha: 127); shootDust.noGravity = true; } @@ -198,7 +198,7 @@ namespace CalamityMod.Projectiles.Summon { float angle = MathHelper.TwoPi / dustAmount * dustIndex; Vector2 velocity = angle.ToRotationVector2() * 8f; - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 109, velocity); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, DustID.Asphalt, velocity); spawnDust.noGravity = true; spawnDust.noLight = true; } diff --git a/Projectiles/Summon/CalamarisLamentProjectile.cs b/Projectiles/Summon/CalamarisLamentProjectile.cs index 56f317b73b..b890b8bc31 100644 --- a/Projectiles/Summon/CalamarisLamentProjectile.cs +++ b/Projectiles/Summon/CalamarisLamentProjectile.cs @@ -38,7 +38,10 @@ namespace CalamityMod.Projectiles.Summon Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; } - + public override bool? CanHitNPC(NPC target) + { + return target.CanBeChasedBy() ? null : false; + } public override void AI() { if (TargetShot is not null && TargetShot.active) @@ -78,7 +81,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 15; i++) { - Dust deathDust = Dust.NewDustPerfect(Projectile.Center, 109, Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 7f), Scale: Main.rand.NextFloat(0.5f, 1.5f), Alpha: 127); + Dust deathDust = Dust.NewDustPerfect(Projectile.Center, DustID.Asphalt, Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 7f), Scale: Main.rand.NextFloat(0.5f, 1.5f), Alpha: 127); deathDust.noGravity = true; deathDust.noLight = true; } diff --git a/Projectiles/Summon/Calamitamini.cs b/Projectiles/Summon/Calamitamini.cs index a7c0bfb1ec..f1c755a738 100644 --- a/Projectiles/Summon/Calamitamini.cs +++ b/Projectiles/Summon/Calamitamini.cs @@ -210,25 +210,23 @@ namespace CalamityMod.Projectiles.Summon if (Projectile.ai[1] > 0f) { - Projectile.ai[1] += (float)Main.rand.Next(1, 4); + Projectile.ai[1] += Main.rand.Next(2, 3+1); } - if (Projectile.ai[1] > 110f) + if (Projectile.ai[1] > 100f) { Projectile.ai[1] = 0f; Projectile.netUpdate = true; } if (Projectile.ai[0] == 0f) { - float projSpeed = 8f; + float projSpeed = 10f; int projType = ModContent.ProjectileType(); if (foundTarget && Projectile.ai[1] == 0f) { Projectile.ai[1] += 1f; if (Main.myPlayer == Projectile.owner && Collision.CanHitLine(Projectile.Center, Projectile.width, Projectile.height, targetVec, 0, 0)) { - Vector2 velocity = targetVec - Projectile.Center; - velocity.Normalize(); - velocity *= projSpeed; + Vector2 velocity = Utils.DirectionTo(Projectile.Center, targetVec) * projSpeed; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, projType, Projectile.damage, Projectile.knockBack, Projectile.owner); Projectile.netUpdate = true; } @@ -245,7 +243,5 @@ namespace CalamityMod.Projectiles.Summon Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, yStart, texture.Width, frameHeight)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/Cataclymini.cs b/Projectiles/Summon/Cataclymini.cs index dabd888069..b67690cdcc 100644 --- a/Projectiles/Summon/Cataclymini.cs +++ b/Projectiles/Summon/Cataclymini.cs @@ -239,7 +239,5 @@ namespace CalamityMod.Projectiles.Summon Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, yStart, texture.Width, frameHeight)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/CataclysmSummon.cs b/Projectiles/Summon/CataclysmSummon.cs index 8c2597e858..d855ac7e65 100644 --- a/Projectiles/Summon/CataclysmSummon.cs +++ b/Projectiles/Summon/CataclysmSummon.cs @@ -90,7 +90,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 40; i++) { - Dust brimstone = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Square(-65f, 65f), 267); + Dust brimstone = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Square(-65f, 65f), DustID.RainbowMk2); brimstone.velocity = -Vector2.UnitY * Main.rand.NextFloat(1.8f, 3.6f); brimstone.scale = Main.rand.NextFloat(1.65f, 1.85f); brimstone.fadeIn = Main.rand.NextFloat(0.7f, 0.9f); diff --git a/Projectiles/Summon/Catastromini.cs b/Projectiles/Summon/Catastromini.cs index 1766bdf8be..956f049214 100644 --- a/Projectiles/Summon/Catastromini.cs +++ b/Projectiles/Summon/Catastromini.cs @@ -35,6 +35,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.idStaticNPCHitCooldown = 8; Projectile.DamageType = DamageClass.Summon; } + public override bool MinionContactDamage() => Projectile.ai[0] == 2f; public override void AI() { diff --git a/Projectiles/Summon/CausticStaffProjectile.cs b/Projectiles/Summon/CausticStaffProjectile.cs index 79ad9f70d0..7e7c5355f6 100644 --- a/Projectiles/Summon/CausticStaffProjectile.cs +++ b/Projectiles/Summon/CausticStaffProjectile.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 5; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 6); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Torch); dust.noGravity = true; dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(2f); } @@ -51,14 +51,14 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Player player = Main.player[Projectile.owner]; - Item heldItem = player.ActiveItem(); + Item heldItem = player.HeldItem; if (!CalamityUtils.ShouldTriggerSummonPenalty(player, heldItem)) { int duration = Main.rand.Next(60, 181); // Anywhere between 1 and 3 seconds switch ((int)Projectile.ai[0]) { case 0: - if (target.Calamity().marked <= 0) + if (target.Calamity().markedForDeath) target.AddBuff(ModContent.BuffType(), duration); break; case 1: diff --git a/Projectiles/Summon/CausticStaffSummon.cs b/Projectiles/Summon/CausticStaffSummon.cs index ca75b21aa9..501472f410 100644 --- a/Projectiles/Summon/CausticStaffSummon.cs +++ b/Projectiles/Summon/CausticStaffSummon.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -285,7 +286,5 @@ namespace CalamityMod.Projectiles.Summon } public override bool OnTileCollide(Vector2 oldVelocity) => false; - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/CelestialAxeMinion.cs b/Projectiles/Summon/CelestialAxeMinion.cs index 888c97d688..932f8ec4fb 100644 --- a/Projectiles/Summon/CelestialAxeMinion.cs +++ b/Projectiles/Summon/CelestialAxeMinion.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Projectiles.Summon public new string LocalizationCategory => "Projectiles.Summon"; public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -75,6 +76,9 @@ namespace CalamityMod.Projectiles.Summon 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 bool MinionContactDamage() => true; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 60); diff --git a/Projectiles/Summon/CinderBlossom.cs b/Projectiles/Summon/CinderBlossom.cs index d594e5ff50..40c1149605 100644 --- a/Projectiles/Summon/CinderBlossom.cs +++ b/Projectiles/Summon/CinderBlossom.cs @@ -1,5 +1,4 @@ -using System.Diagnostics.CodeAnalysis; -using CalamityMod.Buffs.Summon; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Terraria; @@ -20,6 +19,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 36; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 6); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Torch); dust.noGravity = true; dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(2f, 6f); } @@ -89,7 +89,5 @@ namespace CalamityMod.Projectiles.Summon DelayBetweenShooting++; } } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/CloudElementalMinion.cs b/Projectiles/Summon/CloudElementalMinion.cs index 2a8fa900b4..336fbb5feb 100644 --- a/Projectiles/Summon/CloudElementalMinion.cs +++ b/Projectiles/Summon/CloudElementalMinion.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.cloudWaifu && !modPlayer.allWaifus && !modPlayer.cloudWaifuVanity && !modPlayer.allWaifusVanity) + if (!modPlayer.cloudElemental && !modPlayer.allElementals && !modPlayer.cloudElementalVanity && !modPlayer.allElementalsVanity) { Projectile.active = false; return; @@ -51,9 +51,9 @@ namespace CalamityMod.Projectiles.Summon { if (player.dead) { - modPlayer.cWaifu = false; + modPlayer.cloudEleBuff = false; } - if (modPlayer.cWaifu) + if (modPlayer.cloudEleBuff) { Projectile.timeLeft = 2; } @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.frame = 0; } - if (!modPlayer.cloudWaifuVanity && !modPlayer.allWaifusVanity) + if (!modPlayer.cloudElementalVanity && !modPlayer.allElementalsVanity) { float lightScalar = (float)Main.rand.Next(90, 111) * 0.01f; lightScalar *= Main.essScale; @@ -146,7 +146,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.cloudWaifuVanity || modPlayer.allWaifusVanity) + if (modPlayer.cloudElementalVanity || modPlayer.allElementalsVanity) { return false; } diff --git a/Projectiles/Summon/CnidarianJellyfishOnTheString.cs b/Projectiles/Summon/CnidarianJellyfishOnTheString.cs index a26b46828f..14adef8764 100644 --- a/Projectiles/Summon/CnidarianJellyfishOnTheString.cs +++ b/Projectiles/Summon/CnidarianJellyfishOnTheString.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using CalamityMod.Buffs.Summon.Whips; using CalamityMod.DataStructures; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; @@ -211,6 +212,7 @@ namespace CalamityMod.Projectiles.Summon { SoundEngine.PlaySound(SlapSound with { Volume = SlapSound.Volume * centrifugalForce + 0.8f }, target.position); Owner.MinionAttackTargetNPC = target.whoAmI; + target.AddBuff(BuffType(), 240); } } @@ -221,12 +223,12 @@ namespace CalamityMod.Projectiles.Summon public CurveSegment retract = new CurveSegment(EasingType.SineInOut, 0.7f, 0.5f, 0.5f); internal float StretchRatio() => PiecewiseAnimation(MathHelper.Clamp((Timer + 45) % ElectrifyTimer, 0, 80) / 80f, new CurveSegment[] { anticipation, contraction, retract }); - public float PrimWidthFunction(float completionRatio) + public float PrimWidthFunction(float completionRatio, Vector2 vertexPos) { return 1.6f; } - public Color PrimColorFunction(float completionRatio) + public Color PrimColorFunction(float completionRatio, Vector2 vertexPos) { float timeAfterZap = MathHelper.Clamp(20 - (Timer - 5 - completionRatio * 12f) % ElectrifyTimer, 0, 20); float postZapTime = 1 - timeAfterZap / 20f; @@ -289,7 +291,7 @@ namespace CalamityMod.Projectiles.Summon } catch (Exception) { - CalamityMod.Instance.Logger.Warn("IbanPlay Victide Cnidarian Position Netcode failed safely"); + CalamityMod.Log.Warn("IbanPlay Victide Cnidarian Position Netcode failed safely"); } } } diff --git a/Projectiles/Summon/CorroslimeMinion.cs b/Projectiles/Summon/CorroslimeMinion.cs index 06d676e565..9fd7296ef8 100644 --- a/Projectiles/Summon/CorroslimeMinion.cs +++ b/Projectiles/Summon/CorroslimeMinion.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 6; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -80,6 +81,8 @@ namespace CalamityMod.Projectiles.Summon } } + public override bool MinionContactDamage() => true; + public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/CorruptionSlimeGodMinion.cs b/Projectiles/Summon/CorruptionSlimeGodMinion.cs index 3f0975c5ca..e627103010 100644 --- a/Projectiles/Summon/CorruptionSlimeGodMinion.cs +++ b/Projectiles/Summon/CorruptionSlimeGodMinion.cs @@ -1,7 +1,9 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -9,11 +11,12 @@ namespace CalamityMod.Projectiles.Summon public class CorruptionSlimeGodMinion : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/Summon/CorroslimeMinion"; public float dust = 0f; public override void SetStaticDefaults() { - Main.projFrames[Type] = 2; + Main.projFrames[Type] = 6; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -84,5 +87,13 @@ namespace CalamityMod.Projectiles.Summon } public override bool OnTileCollide(Vector2 oldVelocity) => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D slom = TextureAssets.Projectile[Type].Value; + Rectangle frame = slom.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Main.EntitySpriteDraw(slom, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None); + return false; + } } } diff --git a/Projectiles/Summon/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index bc06a90b67..14049b2ad4 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -221,7 +221,5 @@ namespace CalamityMod.Projectiles.Summon { return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 255); } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/CosmicViperSummon.cs b/Projectiles/Summon/CosmicViperSummon.cs index 747eb5e5c6..0dffeca8d7 100644 --- a/Projectiles/Summon/CosmicViperSummon.cs +++ b/Projectiles/Summon/CosmicViperSummon.cs @@ -18,9 +18,10 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projFrames[Type] = 3; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; - Main.projFrames[Type] = 3; } public override void SetDefaults() @@ -69,12 +70,11 @@ namespace CalamityMod.Projectiles.Summon for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { int dustType = Main.rand.NextBool(3) ? 56 : 242; - Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - rotate = rotate.RotatedBy((double)((float)(dustIndex - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Projectile.Center; + Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; + rotate = rotate.RotatedBy(dustIndex * MathHelper.TwoPi / (float)dustAmt) + Projectile.Center; Vector2 faceDirection = rotate - Projectile.Center; - int dusty = Dust.NewDust(rotate + faceDirection, 0, 0, dustType, faceDirection.X * 1.75f, faceDirection.Y * 1.75f, 100, default, 1.1f); - Main.dust[dusty].noGravity = true; - Main.dust[dusty].velocity = faceDirection; + Dust dusty = Dust.NewDustPerfect(Projectile.Center, dustType, faceDirection, 100, default, 1.1f); + dusty.noGravity = true; } // Construct a fake item to use with vanilla code for the sake of firing bullets. @@ -307,8 +307,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool? CanDamage() => false; - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/CosmilampBeam.cs b/Projectiles/Summon/CosmilampBeam.cs index 68d6b66b8f..4c97013286 100644 --- a/Projectiles/Summon/CosmilampBeam.cs +++ b/Projectiles/Summon/CosmilampBeam.cs @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Summon Timer++; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float streakOpacity = Utils.GetLerpValue(0.8f, 0.54f, completionRatio, true) * Projectile.Opacity; Color endColor = Color.Lerp(Color.Fuchsia, Color.DarkViolet, (float)Math.Sin(completionRatio * MathHelper.Pi * 1.6f - Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Summon return Color.Lerp(endColor, Color.Black, 0.3f) * streakOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.GetLerpValue(0f, 0.3f, completionRatio, true), 2D); float maxWidth = Projectile.Opacity * Projectile.width * 1.65f; @@ -105,14 +105,14 @@ namespace CalamityMod.Projectiles.Summon return MathHelper.Lerp(0f, maxWidth, expansionCompletion); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); public override bool PreDraw(ref Color lightColor) { Projectile.localAI[0] = 0f; GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - var settings = new PrimitiveSettings(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]); + var settings = new PrimitiveSettings(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]); PrimitiveRenderer.RenderTrail(Projectile.oldPos, settings, 42); Projectile.localAI[0] = 1f; PrimitiveRenderer.RenderTrail(Projectile.oldPos, settings, 42); diff --git a/Projectiles/Summon/CosmilampMinion.cs b/Projectiles/Summon/CosmilampMinion.cs index a3f6adb628..1d7269474d 100644 --- a/Projectiles/Summon/CosmilampMinion.cs +++ b/Projectiles/Summon/CosmilampMinion.cs @@ -148,8 +148,5 @@ namespace CalamityMod.Projectiles.Summon Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0); return false; } - - // The lamps themselves do not do damage, but they do store damage for the sake of shooting projectiles. - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/CrimslimeMinion.cs b/Projectiles/Summon/CrimslimeMinion.cs index 2ce626218e..934db01829 100644 --- a/Projectiles/Summon/CrimslimeMinion.cs +++ b/Projectiles/Summon/CrimslimeMinion.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 6; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -80,6 +81,8 @@ namespace CalamityMod.Projectiles.Summon } } + public override bool MinionContactDamage() => true; + public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/CrimsonSlimeGodMinion.cs b/Projectiles/Summon/CrimsonSlimeGodMinion.cs index fa6f533cff..3199f82bbc 100644 --- a/Projectiles/Summon/CrimsonSlimeGodMinion.cs +++ b/Projectiles/Summon/CrimsonSlimeGodMinion.cs @@ -1,7 +1,9 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -9,11 +11,12 @@ namespace CalamityMod.Projectiles.Summon public class CrimsonSlimeGodMinion : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/Summon/CrimslimeMinion"; public float dust = 0f; public override void SetStaticDefaults() { - Main.projFrames[Type] = 2; + Main.projFrames[Type] = 6; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -84,5 +87,13 @@ namespace CalamityMod.Projectiles.Summon } public override bool OnTileCollide(Vector2 oldVelocity) => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D slom = TextureAssets.Projectile[Type].Value; + Rectangle frame = slom.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Main.EntitySpriteDraw(slom, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None); + return false; + } } } diff --git a/Projectiles/Summon/DaedalusCrystalShot.cs b/Projectiles/Summon/DaedalusCrystalShot.cs index 8cfb190581..79eda97bd1 100644 --- a/Projectiles/Summon/DaedalusCrystalShot.cs +++ b/Projectiles/Summon/DaedalusCrystalShot.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/DaedalusGolem.cs b/Projectiles/Summon/DaedalusGolem.cs index dfcfa3f201..964467aad5 100644 --- a/Projectiles/Summon/DaedalusGolem.cs +++ b/Projectiles/Summon/DaedalusGolem.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 18; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -131,7 +132,7 @@ namespace CalamityMod.Projectiles.Summon if (AttackTimer >= 45 && AttackTimer < ChargedLaserAttackTime / 2 && !Main.dedServ) { Vector2 drawOffset = Main.rand.NextVector2CircularEdge(12f, 12f); - Dust light = Dust.NewDustPerfect(ArmPosition + drawOffset, 261); + Dust light = Dust.NewDustPerfect(ArmPosition + drawOffset, DustID.AncientLight); light.velocity = drawOffset.SafeNormalize(Vector2.Zero) * -2.5f; light.color = Color.Lerp(Color.HotPink, Color.LightPink, Main.rand.NextFloat()); light.scale = Main.rand.NextFloat(1.2f, 1.45f); @@ -297,7 +298,5 @@ namespace CalamityMod.Projectiles.Summon Projectile.frame = 0; } } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/DaedalusLightning.cs b/Projectiles/Summon/DaedalusLightning.cs index 23d7b00dda..8e6206dd3e 100644 --- a/Projectiles/Summon/DaedalusLightning.cs +++ b/Projectiles/Summon/DaedalusLightning.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; using Terraria; @@ -40,6 +39,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.extraUpdates = 20; Projectile.timeLeft = 45 * Projectile.extraUpdates; Projectile.DamageType = DamageClass.Summon; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; // Readjust the velocity magnitude the moment this projectile is created // to make velocity setting outside the scope of this projectile less irritating @@ -125,19 +126,19 @@ namespace CalamityMod.Projectiles.Summon } #region Drawing - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { float baseWidth = MathHelper.Lerp(2f, 6f, (float)Math.Sin(MathHelper.Pi * 4f * completionRatio) * 0.5f + 0.5f) * Projectile.scale; return baseWidth * (float)Math.Sin(MathHelper.Pi * completionRatio); } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { Color baseColor = Color.Lerp(Color.Pink, Color.HotPink, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); return Color.Lerp(baseColor, Color.Red, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f) * 0.8f); } public override bool PreDraw(ref Color lightColor) { - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, false), 90); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, false), 90); return false; } #endregion diff --git a/Projectiles/Summon/DankCreeperMinion.cs b/Projectiles/Summon/DankCreeperMinion.cs index 98dadc21e2..4aedb83069 100644 --- a/Projectiles/Summon/DankCreeperMinion.cs +++ b/Projectiles/Summon/DankCreeperMinion.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Projectiles.Summon public new string LocalizationCategory => "Projectiles.Summon"; public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -208,6 +209,8 @@ namespace CalamityMod.Projectiles.Summon } } + public override bool MinionContactDamage() => true; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.owner == Main.myPlayer) diff --git a/Projectiles/Summon/DazzlingStabber.cs b/Projectiles/Summon/DazzlingStabber.cs index b965693fe2..4322dbb52a 100644 --- a/Projectiles/Summon/DazzlingStabber.cs +++ b/Projectiles/Summon/DazzlingStabber.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.tileCollide = false; Projectile.minion = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = 28; Projectile.DamageType = DamageClass.Summon; } @@ -303,7 +303,9 @@ namespace CalamityMod.Projectiles.Summon } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - public override bool? CanDamage() => attackCooldown == 0 ? null : false; + + public override bool? CanDamage() => (attackCooldown == 0 ? base.CanDamage() : false); + public override bool PreDraw(ref Color lightColor) { Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/DeathstareBeam.cs b/Projectiles/Summon/DeathstareBeam.cs index 4c8b737425..19279ec247 100644 --- a/Projectiles/Summon/DeathstareBeam.cs +++ b/Projectiles/Summon/DeathstareBeam.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.ignoreWater = true; Projectile.timeLeft = 10; Projectile.DamageType = DamageClass.Summon; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() { diff --git a/Projectiles/Summon/DeathstareEyeball.cs b/Projectiles/Summon/DeathstareEyeball.cs index 6ef2b94958..9cdbf33a3e 100644 --- a/Projectiles/Summon/DeathstareEyeball.cs +++ b/Projectiles/Summon/DeathstareEyeball.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 6; + Main.projPet[Type] = true; ProjectileID.Sets.NeedsUUID[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; @@ -169,7 +170,5 @@ namespace CalamityMod.Projectiles.Summon Main.EntitySpriteDraw(pupilTexture, pupilDrawPosition, null, Projectile.GetAlpha(lightColor), PupilAngle, pupilTexture.Size() * 0.5f, PupilScale, SpriteEffects.None); return false; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/DoGWeaponTeleportRift.cs b/Projectiles/Summon/DoGWeaponTeleportRift.cs new file mode 100644 index 0000000000..2e8bbed414 --- /dev/null +++ b/Projectiles/Summon/DoGWeaponTeleportRift.cs @@ -0,0 +1,101 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class DoGWeaponTeleportRift : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/StarProj"; + + public ref float GeneralRotationalOffset => ref Projectile.ai[0]; + public override void SetStaticDefaults() + { + ProjectileID.Sets.NeedsUUID[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 170; + Projectile.scale = 0.25f; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.Opacity = 0f; + Projectile.penetrate = -1; + Projectile.timeLeft = 45; + Projectile.netImportant = true; + Projectile.DamageType = DamageClass.Summon; + } + + public override void AI() + { + Projectile.scale = Projectile.ai[1]; + if (Projectile.ai[0] == 0f) + Projectile.ai[0] = 45f; + + GeneralRotationalOffset += MathHelper.Pi / 8f; + Projectile.Opacity = MathHelper.Clamp(GeneralRotationalOffset, 0f, 1f); + + if (Projectile.Opacity == 1f && Main.rand.NextBool(15)) + { + Dust dust = Dust.NewDustDirect(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f); + dust.velocity.X = 0f; + dust.noGravity = true; + dust.position = Projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(4f, 20f); + dust.fadeIn = 1f; + dust.scale = 0.5f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + float currentFade = Utils.GetLerpValue(0f, 5f, Projectile.timeLeft, true) * Utils.GetLerpValue(Projectile.ai[0], Projectile.ai[0] - 5f, Projectile.timeLeft, true); + currentFade *= (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f * MathHelper.Pi * 3f)) * 0.8f; + + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + Color baseColor = new Color(150, 100, 255, 255) * Projectile.Opacity; + baseColor *= 0.5f; + baseColor.A = 0; + Color colorA = baseColor; + Color colorB = baseColor * 0.5f; + colorA *= currentFade; + colorB *= currentFade; + Vector2 origin = texture.Size() / 2f; + Vector2 scale = new Vector2(3f, 7f) * Projectile.Opacity * Projectile.scale * currentFade; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); + + Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2 + GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorA, GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2 + GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + + Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); + + Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); + + return false; + } + + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Summon/DormantBrimseekerBab.cs b/Projectiles/Summon/DormantBrimseekerBab.cs index f26f66f14a..183b6108fc 100644 --- a/Projectiles/Summon/DormantBrimseekerBab.cs +++ b/Projectiles/Summon/DormantBrimseekerBab.cs @@ -26,12 +26,10 @@ namespace CalamityMod.Projectiles.Summon } public override void SetStaticDefaults() { - Main.projFrames[Type] = 8; - + Main.projPet[Type] = true; ProjectileID.Sets.TrailCacheLength[Type] = 7; ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.MinionSacrificable[Type] = true; } @@ -153,6 +151,9 @@ namespace CalamityMod.Projectiles.Summon } Lighting.AddLight(Projectile.Center, Color.Red.ToVector3()); } + + public override bool MinionContactDamage() => true; + public override void PostDraw(Color lightColor) { if ((Projectile.ai[0] > 0f && Projectile.ai[0] <= MaxChargeTime && Projectile.velocity.Length() >= 8f) || SeekingTarget) diff --git a/Projectiles/Summon/DreadmineTurret.cs b/Projectiles/Summon/DreadmineTurret.cs index eb8f33d7f9..c0ef740d36 100644 --- a/Projectiles/Summon/DreadmineTurret.cs +++ b/Projectiles/Summon/DreadmineTurret.cs @@ -77,7 +77,7 @@ namespace CalamityMod.Projectiles.Summon int tileX = (int)center.X / 16; int tileY = (int)center.Y / 16; bool canSpawnMine = false; - if (Main.rand.NextBool(3) && Main.tile[tileX, tileY] != null && Main.tile[tileX, tileY].WallType > 0) + if (Main.rand.NextBool(3) && Main.tile[tileX, tileY] != null && Main.tile[tileX, tileY].WallType > WallID.None) { canSpawnMine = true; } diff --git a/Projectiles/Summon/EXPLODINGFROG.cs b/Projectiles/Summon/EXPLODINGFROG.cs index a54e7caea0..34f6f7f1b8 100644 --- a/Projectiles/Summon/EXPLODINGFROG.cs +++ b/Projectiles/Summon/EXPLODINGFROG.cs @@ -1,6 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; +using System; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -11,8 +11,8 @@ namespace CalamityMod.Projectiles.Summon public class EXPLODINGFROG : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; - public const float MinExplodeDistance = 120f; - public const float ExplodeWaitTime = 45f; + public const float MinExplodeDistance = 96f; + public const float ExplodeWaitTime = 120f; public const float ExplosionAngleVariance = 0.8f; public override void SetStaticDefaults() { @@ -35,6 +35,11 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + if (Projectile.ai[1] == 0) + { + Projectile.ai[0] = 75; + Projectile.ai[1] = 1; + } if (Projectile.frameCounter++ > 5) { Projectile.frame++; @@ -46,39 +51,56 @@ namespace CalamityMod.Projectiles.Summon } Player player = Main.player[Projectile.owner]; bool canExplode = Projectile.Center.ClosestNPCAt(MinExplodeDistance) != null; - if (player.HasMinionAttackTargetNPC) + if (player.HasMinionAttackTargetNPC && !canExplode) { canExplode = Main.npc[player.MinionAttackTargetNPC].Distance(Projectile.Center) < MinExplodeDistance; } - if (canExplode) + if (Projectile.ai[0] < ExplodeWaitTime) Projectile.ai[0]++; if (Projectile.ai[0] >= ExplodeWaitTime) { - if (Main.myPlayer == Projectile.owner) + if (canExplode) { - // Goop projectiles - for (int i = 0; i < 3; i++) + if (Main.myPlayer == Projectile.owner) { + Vector2 rotOffset = -Vector2.UnitY; + if (player.HasMinionAttackTargetNPC && Main.npc[player.MinionAttackTargetNPC].Distance(Projectile.Center) < MinExplodeDistance + Math.Max(Main.npc[player.MinionAttackTargetNPC].width * 0.5f, Main.npc[player.MinionAttackTargetNPC].height * 0.5f)) + rotOffset = (Projectile.DirectionTo(Main.npc[player.MinionAttackTargetNPC].Center)); + else + { + var tar = Projectile.Center.ClosestNPCAt(MinExplodeDistance); + if (tar != null) + rotOffset = (Projectile.DirectionTo(tar.Center)); + } + // Goop projectiles + Vector2 direction = Vector2.Lerp(-Vector2.UnitY, rotOffset, 0.25f).SafeNormalize(-Vector2.UnitY); + for (int i = 0; i < 3; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, + (direction * Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), + ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, + (direction * Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), + ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, - new Vector2(0f, -Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), - ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + (direction * Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), + ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, - new Vector2(0f, -Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), - ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + (direction * Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), + ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, + (direction * Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), + ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, - new Vector2(0f, -Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), - ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, - new Vector2(0f, -Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), - ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, - new Vector2(0f, -Main.rand.NextFloat(6f, 10f)).RotatedByRandom(ExplosionAngleVariance), - ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + // WoF vomit sound. + SoundEngine.PlaySound(SoundID.NPCDeath13, Projectile.Center); + Projectile.ai[0] = 0; + + //do a little hop + if (Projectile.velocity.Length() < 0.1f) + Projectile.velocity.Y -= 5; } - // WoF vomit sound. - SoundEngine.PlaySound(SoundID.NPCDeath13, Projectile.Center); - Projectile.Kill(); } Projectile.velocity.Y += 0.5f; @@ -91,12 +113,55 @@ namespace CalamityMod.Projectiles.Summon public override bool? CanDamage() => false; // Don't die on tile collision - public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity *= 0.8f; + return false; + } public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { fallThrough = false; return true; } + private static Texture2D GlowOutline = null; + public static Texture2D GetGlowOutline() + { + if (GlowOutline == null) + { + var texture = ModContent.Request("CalamityMod/Projectiles/Summon/EXPLODINGFROG").Value; + GlowOutline = new Texture2D(Main.graphics.GraphicsDevice, texture.Width, texture.Height); + + var BaseArray = new Color[GlowOutline.Width * GlowOutline.Height]; + var ColorArray = new Color[GlowOutline.Width * GlowOutline.Height]; + texture.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + GlowOutline.SetData(ColorArray); + } + return GlowOutline; + } + + public void ApplyGlowOutline(Texture2D tex, Rectangle? frame = null, float rotationOffset = 0, float borderPixels = 1, float opacity = 1) + { + Color color = Color.GreenYellow; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + new Vector2(2, 0) * borderPixels, frame, color * opacity, Projectile.rotation - rotationOffset, new Vector2(frame.Value.Width,frame.Value.Height) *0.5f, Projectile.scale, (Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None), 0); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + new Vector2(0, 2) * borderPixels, frame, color * opacity, Projectile.rotation - rotationOffset, new Vector2(frame.Value.Width, frame.Value.Height) * 0.5f, Projectile.scale, (Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None), 0); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + new Vector2(-2, 0) * borderPixels, frame, color * opacity, Projectile.rotation - rotationOffset, new Vector2(frame.Value.Width, frame.Value.Height) * 0.5f, Projectile.scale, (Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None), 0); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition + new Vector2(0, -2) * borderPixels, frame, color * opacity, Projectile.rotation - rotationOffset, new Vector2(frame.Value.Width, frame.Value.Height) * 0.5f, Projectile.scale, (Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None), 0); + } + public override bool PreDraw(ref Color lightColor) + { + var tex = GetGlowOutline(); + var frame = tex.Frame(1, 5, 0, Projectile.frame); + ApplyGlowOutline(tex, frame, 0, MathF.Pow(Math.Clamp((Projectile.ai[0]-90)/(ExplodeWaitTime-90), 0, 1), 2),1); + + Lighting.AddLight(Projectile.Center, Color.GreenYellow.ToVector3()*(MathF.Pow(Math.Clamp((Projectile.ai[0] - 90) / (ExplodeWaitTime - 90), 0, 1), 2))); + tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, lightColor * Projectile.Opacity, Projectile.rotation, new Vector2(frame.Width, frame.Height) * 0.5f, Projectile.scale, (Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None), 0); + return false; + } } } diff --git a/Projectiles/Summon/EnchantedKnifeStaffProjectile.cs b/Projectiles/Summon/EnchantedKnifeStaffProjectile.cs new file mode 100644 index 0000000000..121c7de996 --- /dev/null +++ b/Projectiles/Summon/EnchantedKnifeStaffProjectile.cs @@ -0,0 +1,62 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class EnchantedKnifeStaffProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override void SetStaticDefaults() => ProjectileID.Sets.MinionShot[Type] = true; + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 32; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.timeLeft = 300; + } + + public override void OnSpawn(IEntitySource source) + { + Projectile.rotation = Projectile.velocity.ToRotation(); + Projectile.netUpdate = true; + } + + public override void AI() + { + if (!Main.dedServ && Projectile.timeLeft % 2 == 0) + { + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(6, 6), Main.rand.NextBool() ? Main.rand.NextBool() ? 57 : 58 : 15, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.8f)); + trailDust.noGravity = true; + trailDust.scale = Main.rand.NextFloat(0.8f, 1.5f); + + Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3() * 0.2f); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Projectile.timeLeft = 3; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Color.Cyan with { A = 0 } * 1.2f; + float drawRotation = Projectile.rotation + MathHelper.PiOver2; + Vector2 anchorPoint = texture.Size() * 0.5f; + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, anchorPoint, Projectile.scale, SpriteEffects.None); + + return false; + } + } +} diff --git a/Projectiles/Summon/EnchantedKnifeStaffProjectile.png b/Projectiles/Summon/EnchantedKnifeStaffProjectile.png new file mode 100644 index 0000000000..dc3a135310 Binary files /dev/null and b/Projectiles/Summon/EnchantedKnifeStaffProjectile.png differ diff --git a/Projectiles/Summon/EnchantedKnifeSummon.cs b/Projectiles/Summon/EnchantedKnifeSummon.cs new file mode 100644 index 0000000000..3537ae9712 --- /dev/null +++ b/Projectiles/Summon/EnchantedKnifeSummon.cs @@ -0,0 +1,285 @@ +using System; +using System.IO; +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using static CalamityMod.Items.Weapons.Summon.EnchantedKnifeStaff; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Summon +{ + public class EnchantedKnifeSummon : BaseMinionProjectile + { + public override int AssociatedProjectileTypeID => ProjectileType(); + + public override int AssociatedBuffTypeID => BuffType(); + + public override ref bool AssociatedMinionBool => ref ModdedOwner.EnchantedKnifeStaffBool; + + public override bool PreHardmodeMinionTileVision => true; + + private Action CurrentState + { + get => _currentState; + set + { + OnStateChange(value); + _currentState = value; + } + } + private Action _currentState; + + private ref float DashTimer => ref Projectile.ai[0]; + + private ref float SwingTimer => ref Projectile.ai[1]; + + private ref float SwingDirection => ref Projectile.ai[2]; + + private Vector2 IdlePosition => Owner.MountedCenter + + new Vector2(50f * MathF.Ceiling(Projectile.minionPos / 2f) * (Projectile.minionPos % 2 == 0 ? -1 : 1), -60f + MathF.Ceiling(Projectile.minionPos / 2f) * 15f); + + private Vector2 SwingCenter; + + private float RandomRotationOffset; + + private bool HasStartedSwinging; + + private bool HasSpawned; + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.width = Projectile.height = 32; + } + + #region AI + + public override void MinionAI() + { + if (!HasSpawned) + { + TrailCacheLength = 4; + DashTimer = Main.rand.Next(30); + Projectile.velocity = Projectile.DirectionFrom(Owner.Center); + CurrentState = GoToOwnerState; + HasSpawned = true; + NetUpdate(); + } + if (Main.rand.NextBool(6)) + { + Vector2 vel = new Vector2(2, 2).RotatedByRandom(100); + Dust trailDust = Dust.NewDustPerfect(Projectile.Center + vel * Main.rand.NextFloat(0.5f, 3f), Main.rand.NextBool() ? Main.rand.NextBool() ? 57 : 58 : 15, vel * Main.rand.NextFloat(0.5f, 1f)); + trailDust.noGravity = true; + trailDust.scale = Main.rand.NextFloat(0.6f, 1.1f); + } + + CurrentState.Invoke(); + + Projectile.MinionAntiClump(0.25f); + + if (!Main.dedServ) + Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3() * 0.4f); + } + + private void GoToOwnerState() + { + if (Target is not null) + { + CurrentState = AttackState; + return; + } + + if (Projectile.DistanceSQ(IdlePosition) > 3000f * 3000f) + Projectile.Center = Owner.Center; + + if (Projectile.DistanceSQ(IdlePosition) < 80f * 80f) + CurrentState = IdleState; + + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.DirectionTo(IdlePosition).ToRotation(), 0.08f).ToRotationVector2() * 10f; + Projectile.rotation = Projectile.velocity.ToRotation(); + } + + private void IdleState() + { + if (Target is not null) + { + CurrentState = AttackState; + return; + } + + if (Projectile.DistanceSQ(IdlePosition) > 160f * 160f) + CurrentState = GoToOwnerState; + + float speed = Utils.Remap(Projectile.DistanceSQ(IdlePosition), 0f, 160f * 160f, 0.25f, 15f); + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.velocity.ToRotation().AngleTowards(Projectile.DirectionTo(IdlePosition).ToRotation(), 0.4f).ToRotationVector2() * speed, 0.2f); + Projectile.rotation = MathHelper.Lerp(Projectile.rotation, MathHelper.ToRadians(RandomSineFunction(Main.GlobalTimeWrappedHourly + RandomRotationOffset) * 3f) - MathHelper.PiOver2, 0.1f); + } + + private void AttackState() + { + if (Target is null) + { + CurrentState = GoToOwnerState; + return; + } + + if (float.IsNaN(SwingCenter.X) || float.IsNaN(SwingCenter.Y) || float.IsNaN(Projectile.velocity.X) || float.IsNaN(Projectile.velocity.Y)) + { + SwingCenter = Target.Center; + Projectile.velocity = Vector2.Zero; + } + + SwingCenter += Projectile.velocity; + Projectile.velocity *= 0.9f; + + var easing = new CalamityUtils.CurveSegment(CalamityUtils.PolyInOutEasing, 0f, 0f, 1f, 3); + float xDifference = Target.Center.X - SwingCenter.X; + int signDirection = float.IsNaN(xDifference) ? 1 : MathF.Sign(xDifference); + float swingRotation = MathHelper.Lerp(-MathHelper.PiOver2, MathHelper.PiOver2, CalamityUtils.PiecewiseAnimation(Utils.GetLerpValue(SwingWait, SwingWait + SwingTime, SwingTimer, true), easing)) * signDirection; + Vector2 predictiveDirection = CalamityUtils.CalculatePredictiveAimToTarget(SwingCenter, Target, ProjectileSpeed); + + if (float.IsNaN(predictiveDirection.X) || float.IsNaN(predictiveDirection.Y)) + predictiveDirection = Projectile.DirectionTo(Target.Center); + + Projectile.Center = SwingCenter + (predictiveDirection.ToRotation() + swingRotation).ToRotationVector2() * 40f; + Projectile.rotation = Projectile.DirectionFrom(SwingCenter).ToRotation(); + + if (SwingTimer == SwingWait + SwingTime * 0.5f && Main.myPlayer == Projectile.owner) + { + Vector2 spawnPosition = SwingCenter + predictiveDirection.SafeNormalize(-Vector2.UnitY) * 40f; + Projectile.NewProjectileDirect( + Projectile.GetSource_FromThis(), + spawnPosition, + predictiveDirection, + ProjectileType(), + Projectile.damage, + Projectile.knockBack, + Projectile.owner); + } + + if (DashTimer >= DashCooldown) + { + Vector2 dashVelocity = CalamityUtils.CalculatePredictiveAimToTarget(SwingCenter, Target, DashSpeed); + if (!float.IsNaN(dashVelocity.X) && !float.IsNaN(dashVelocity.Y)) + Projectile.velocity = dashVelocity; + DashTimer = 0f; + } + + SwingTimer += 1f * SwingDirection; + if (SwingTimer == 0f || SwingTimer == SwingWait + SwingTime + SwingWait) + { + if (HasStartedSwinging) + SwingDirection *= -1f; + else + HasStartedSwinging = true; + } + + if (Projectile.DistanceSQ(Target.Center) > 320f * 320f) + DashTimer += Main.rand.NextBool((int)DashCooldown) ? 2 : 1; + } + + private void OnStateChange(Action newState) + { + if (newState == IdleState) + { + RandomRotationOffset = Main.rand.NextFloat(MathHelper.TwoPi); + NetUpdate(); + } + + if (newState == AttackState) + { + if (Target is null) + return; + + float targetSize = Target.Size.Length(); + Vector2 previousCenter = Projectile.Center; + Vector2 newCenter = Target.Center + Main.rand.NextVector2CircularEdge(targetSize * 0.5f + 160f, targetSize * 0.5f + 160f); + + int maxAttempts = 10; + int attempts = 0; + while (Main.tile[newCenter.ToSafeTileCoordinates()].IsTileSolid() && attempts < maxAttempts) + { + newCenter = Target.Center + Main.rand.NextVector2CircularEdge(targetSize * 0.5f + 160f, targetSize * 0.5f + 160f); + attempts++; + } + + if (float.IsNaN(newCenter.X) || float.IsNaN(newCenter.Y)) + newCenter = Target.Center; + + Projectile.Center = newCenter; + SwingCenter = Projectile.Center; + + HasStartedSwinging = false; + SwingDirection = Main.rand.NextBool().ToDirectionInt(); + int totalSwingTime = (int)(2f * SwingWait + SwingTime); + SwingTimer = SwingDirection == 1 ? Main.rand.Next(-30, -2) : Main.rand.Next(totalSwingTime + 1, totalSwingTime + 30 + 1); + + NetUpdate(); + + if (!Main.dedServ) + { + int dustAmount = Main.rand.Next(30, 40); + for (int i = 0; i < dustAmount; i++) + { + float angle = MathHelper.TwoPi / dustAmount * i; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f); + Dust tpDustStart = Dust.NewDustPerfect(previousCenter, DustID.ShimmerSpark, velocity); + Dust tpDustEnd = Dust.NewDustPerfect(SwingCenter, DustID.ShimmerSpark, velocity); + tpDustStart.noGravity = true; + tpDustEnd.noGravity = true; + } + } + } + } + + private float RandomSineFunction(float x) => MathF.Sin(3f * x) + MathF.Cos(5f * x) + 2f * MathF.Sin(0.5f * x); + + #endregion + + #region Drawing + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + MathHelper.PiOver2; + Vector2 anchorPoint = texture.Size() * 0.5f; + + if (CurrentState == AttackState) + { + for (int i = 0; i < 4; i++) + { + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Color afterimageDrawColor = Color.Cyan * ((4f - i) / 4f) * 0.8f; + float afterimageDrawRotation = Projectile.oldRot[i] + MathHelper.PiOver2; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, null, afterimageDrawColor, afterimageDrawRotation, anchorPoint, Projectile.scale, SpriteEffects.None); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, anchorPoint, Projectile.scale, SpriteEffects.None); + + return false; + } + + #endregion + + #region Syncing + + private void NetUpdate(int netSpam = 0) + { + Projectile.netUpdate = true; + Projectile.netSpam = netSpam; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.WriteVector2(SwingCenter); + + public override void ReceiveExtraAI(BinaryReader reader) => SwingCenter = reader.ReadVector2(); + + #endregion + } +} diff --git a/Projectiles/Summon/EnchantedKnifeSummon.png b/Projectiles/Summon/EnchantedKnifeSummon.png new file mode 100644 index 0000000000..6536b06034 Binary files /dev/null and b/Projectiles/Summon/EnchantedKnifeSummon.png differ diff --git a/Projectiles/Summon/EndoCooperBody.cs b/Projectiles/Summon/EndoCooperBody.cs index bab1116e24..487ec89ec1 100644 --- a/Projectiles/Summon/EndoCooperBody.cs +++ b/Projectiles/Summon/EndoCooperBody.cs @@ -351,12 +351,12 @@ namespace CalamityMod.Projectiles.Summon Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, frame, Color.LightSkyBlue, Projectile.rotation, Projectile.Size / 2, 1f, SpriteEffects.None, 0); } + public override bool MinionContactDamage() => AttackMode == 2; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(ModContent.BuffType(), 180); } - - public override bool? CanDamage() => AttackMode == 2; } } diff --git a/Projectiles/Summon/EndoFire.cs b/Projectiles/Summon/EndoFire.cs index 697fa142f3..ae049ace55 100644 --- a/Projectiles/Summon/EndoFire.cs +++ b/Projectiles/Summon/EndoFire.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/EndoHydraHead.cs b/Projectiles/Summon/EndoHydraHead.cs index cb231e8ac5..d33f6bbb9f 100644 --- a/Projectiles/Summon/EndoHydraHead.cs +++ b/Projectiles/Summon/EndoHydraHead.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 5; + Main.projPet[Type] = true; ProjectileID.Sets.TrailingMode[Type] = 0; ProjectileID.Sets.TrailCacheLength[Type] = 20; ProjectileID.Sets.MinionSacrificable[Type] = true; @@ -73,7 +74,7 @@ namespace CalamityMod.Projectiles.Summon return; } - int totalHeads = CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner); + int totalHeads = player.ownedProjectileCounts[Projectile.type]; if (Projectile.localAI[0] == 0f) { DeltaPosition = DeltaPositionMoving = new Vector2(Main.rand.NextFloat(-72f - 8f * totalHeads, 72f + 8f * totalHeads), -Main.rand.NextFloat(8f, 84f + 4f * totalHeads)); @@ -83,7 +84,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 18; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 113); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.MushroomSpray); dust.velocity = new Vector2(0f, -5f).RotatedBy(i / 18f * MathHelper.TwoPi); dust.noGravity = true; dust.scale = 1.2f; @@ -241,6 +242,5 @@ namespace CalamityMod.Projectiles.Summon 0); return false; } - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/EyeOfNightSummon.cs b/Projectiles/Summon/EyeOfNightSummon.cs index ffeccfa56a..d5e9b86981 100644 --- a/Projectiles/Summon/EyeOfNightSummon.cs +++ b/Projectiles/Summon/EyeOfNightSummon.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Summon public const int ShootRate = 60; public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -117,7 +118,5 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity = (destination - Projectile.Center).SafeNormalize(Vector2.Zero) * flySpeed; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/FieryDraconid.cs b/Projectiles/Summon/FieryDraconid.cs index f93412f81f..2574c58132 100644 --- a/Projectiles/Summon/FieryDraconid.cs +++ b/Projectiles/Summon/FieryDraconid.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 45; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(55f, 55f), 244); + Dust fire = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(55f, 55f), DustID.CopperCoin); fire.velocity *= 2f; fire.scale *= 1.15f; } @@ -214,12 +214,12 @@ namespace CalamityMod.Projectiles.Summon // Create an explosion of dust. for (int i = 0; i < 150; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center, 244); + Dust fire = Dust.NewDustPerfect(Projectile.Center, DustID.CopperCoin); fire.velocity = Main.rand.NextVector2Circular(20f, 20f); fire.scale *= 3f; fire.noGravity = true; - fire = Dust.NewDustPerfect(Projectile.Center, 244); + fire = Dust.NewDustPerfect(Projectile.Center, DustID.CopperCoin); fire.velocity *= Main.rand.NextVector2Circular(8f, 8f); fire.scale *= 2f; } @@ -235,7 +235,7 @@ namespace CalamityMod.Projectiles.Summon modifiers.FinalDamage *= YharonsKindleStaff.ReboundRamDamageFactor; } - public override bool? CanDamage() => Projectile.localAI[0] > 1f; + public override bool MinionContactDamage() => Projectile.localAI[0] > 1f; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Summon/FlameBlast.cs b/Projectiles/Summon/FlameBlast.cs index 4230820a80..3a3533b16a 100644 --- a/Projectiles/Summon/FlameBlast.cs +++ b/Projectiles/Summon/FlameBlast.cs @@ -3,7 +3,6 @@ using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/FlameBurst.cs b/Projectiles/Summon/FlameBurst.cs index 275894d092..11c2558d96 100644 --- a/Projectiles/Summon/FlameBurst.cs +++ b/Projectiles/Summon/FlameBurst.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Summon/FlarebatMinion.cs b/Projectiles/Summon/FlarebatMinion.cs deleted file mode 100644 index 66e1a5b87b..0000000000 --- a/Projectiles/Summon/FlarebatMinion.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.Summon; -using CalamityMod.Particles; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Projectiles.Summon -{ - public class FlarebatMinion : BaseMinionProjectile - { - public override int AssociatedProjectileTypeID => ProjectileType(); - - public override int AssociatedBuffTypeID => BuffType(); - - public override ref bool AssociatedMinionBool => ref ModdedOwner.FlarebatBool; - - public override bool PreHardmodeMinionTileVision => true; - - public override int AnimationFrames => 8; - - private Vector2 IdlePosition => Owner.MountedCenter + - -Vector2.UnitY.RotatedBy(MathHelper.ToRadians(15f) * (Owner.ownedProjectileCounts[Type] + Owner.ownedProjectileCounts[ProjectileType()] - 1) - MathHelper.ToRadians(30f) * MinionIndex) * 80f; - - private Action CurrentBehavior; - - [Flags] - private enum AttackBehaviorFlags : byte - { - None = 0, - HasDashed = 1, - HasHitTargetOnDash = 2, - IsReturningToOwner = 4, - } - - private AttackBehaviorFlags AttackState; - - public int MinionIndex; - - public override void SetDefaults() - { - base.SetDefaults(); - (Projectile.width, Projectile.height) = (32, 28); - } - - #region AI - - public override void MinionAI() - { - if (Projectile.ai[0] == 0f) - { - CurrentBehavior = IdleBehavior; - FramesUntilNextAnimationFrame = 3; - - int minionIndex = 0; - foreach (var proj in Main.ActiveProjectiles) - { - if ((proj.type != Type && proj.type != ProjectileType()) || proj.owner != Projectile.owner) - continue; - - if (proj.type == Type) - MinionIndex = minionIndex; - else - proj.ModProjectile().MinionIndex = minionIndex; - - minionIndex++; - } - - Projectile.ai[0]++; - } - - CurrentBehavior.Invoke(); - Projectile.rotation = Projectile.rotation.AngleTowards(MathHelper.ToRadians(Projectile.velocity.X * 3f), 0.2f); - Projectile.spriteDirection = MathF.Sign(Projectile.velocity.X); - - if (!Main.dedServ) - { - if (CurrentBehavior == AttackBehavior || (CurrentBehavior == IdleBehavior && Main.rand.NextBool(10))) - { - Dust ambientDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Torch); - ambientDust.noGravity = Main.rand.NextBool(); - ambientDust.noLight = true; - ambientDust.noLightEmittence = true; - } - - Lighting.AddLight(Projectile.Center, Color.OrangeRed.ToVector3() * 0.5f); - } - } - - private void IdleBehavior() - { - if (Target is not null) - { - CurrentBehavior = AttackBehavior; - Projectile.velocity = Projectile.DirectionTo(Target.Center).RotatedByRandom(MathHelper.PiOver2 * 0.7f) * 10f; - return; - } - - Projectile.velocity = Projectile.DirectionTo(IdlePosition) * Utils.Remap(Projectile.DistanceSQ(IdlePosition), 25600f, 0f, 6f, 0f); - Projectile.MinionAntiClump(); - } - - private void AttackBehavior() - { - if (Target is null) - { - CurrentBehavior = IdleBehavior; - return; - } - - // The first stage is redirecting towards the target. - if (!AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && Vector2.Dot(Projectile.DirectionTo(Target.Center), Projectile.velocity.SafeNormalize(-Vector2.UnitY)) < 0.96f) - { - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.DirectionTo(Target.Center).ToRotation(), 0.08f).ToRotationVector2() * - Utils.Remap(Projectile.DistanceSQ(Target.Center), 6400f, 0f, 12f, 0f); - } - - // When it's whithin a distnce and it hasn't dashed yet, it'll dash. - else if (!AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && Projectile.DistanceSQ(Target.Center) < 57600f) - { - Projectile.velocity = Projectile.DirectionTo(Target.Center) * 15f; - AttackState |= AttackBehaviorFlags.HasDashed; - Projectile.netUpdate = true; - - if (!Main.dedServ) - { - Particle dashRing = new DirectionalPulseRing( - Projectile.Center, - Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 5f, - Color.OrangeRed, - new Vector2(0.5f, 1f), - Projectile.velocity.ToRotation(), - 0.04f, - 0.4f, - 30); - GeneralParticleHandler.SpawnParticle(dashRing); - - SoundEngine.PlaySound(SoundID.Item1 with { Pitch = 0.5f, PitchVariance = 0.1f, Volume = 0.6f }, Projectile.Center); - } - } - - // The second stage is after the dash. - // If it has hit the target is was supposed to hit or he missed: - // Return to the owner. - if (AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && !AttackState.HasFlag(AttackBehaviorFlags.IsReturningToOwner)) - { - if (Vector2.Dot(Projectile.DirectionTo(Target.Center), Projectile.velocity.SafeNormalize(-Vector2.UnitY)) < 0f || AttackState.HasFlag(AttackBehaviorFlags.HasHitTargetOnDash)) - { - AttackState |= AttackBehaviorFlags.IsReturningToOwner; - Projectile.netUpdate = true; - } - } - - // The minion will redirect towards its idle position. - // When it has arrived to it at a distance, reset the state and start over. - if (AttackState.HasFlag(AttackBehaviorFlags.IsReturningToOwner)) - { - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.DirectionTo(IdlePosition).ToRotation(), 0.08f).ToRotationVector2() * - Utils.Remap(Projectile.DistanceSQ(IdlePosition), 6400f, 0f, 12f, 0f); - - if (Projectile.DistanceSQ(IdlePosition) < 6400f) - { - AttackState = AttackBehaviorFlags.None; - Projectile.netUpdate = true; - } - } - } - - public override bool MinionContactDamage() => true; - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && !AttackState.HasFlag(AttackBehaviorFlags.HasHitTargetOnDash) && Target == target) - AttackState |= AttackBehaviorFlags.HasHitTargetOnDash; - - target.AddBuff(BuffID.OnFire, 60); - } - - #endregion - - #region Drawing - - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture = TextureAssets.Projectile[Type].Value; - Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); - Main.EntitySpriteDraw( - texture, - Projectile.Center - Main.screenPosition, - frame, - Color.White * 0.6f, - Projectile.rotation, - frame.Size() * 0.5f, - Projectile.scale, - Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); - return false; - } - - #endregion - - #region Syncing - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write7BitEncodedInt(MinionIndex); - writer.Write((byte)AttackState); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - MinionIndex = reader.Read7BitEncodedInt(); - AttackState = (AttackBehaviorFlags)reader.ReadByte(); - } - - #endregion - } -} diff --git a/Projectiles/Summon/FleshBallMinion.cs b/Projectiles/Summon/FleshBallMinion.cs index 3125b8f324..4de9b04216 100644 --- a/Projectiles/Summon/FleshBallMinion.cs +++ b/Projectiles/Summon/FleshBallMinion.cs @@ -125,6 +125,8 @@ namespace CalamityMod.Projectiles.Summon #endregion + public override bool MinionContactDamage() => true; + public override void OnSpawn(IEntitySource source) => IFrames = 30; // Prevent immediate death on tile collision, and slow down on tile collision. diff --git a/Projectiles/Summon/FlowersOfMortalityPetal.cs b/Projectiles/Summon/FlowersOfMortalityPetal.cs index 3ddd3ef53a..1bb7b10527 100644 --- a/Projectiles/Summon/FlowersOfMortalityPetal.cs +++ b/Projectiles/Summon/FlowersOfMortalityPetal.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 36; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 261); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.AncientLight); dust.noGravity = true; dust.color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f); dust.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 7f); diff --git a/Projectiles/Summon/ForbiddenCircletEater.cs b/Projectiles/Summon/ForbiddenCircletEater.cs index 90472d54b1..cc72dd3d22 100644 --- a/Projectiles/Summon/ForbiddenCircletEater.cs +++ b/Projectiles/Summon/ForbiddenCircletEater.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Projectiles.Summon { Main.projFrames[Type] = 4; ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.MinionShot[Type] = true; //This marks it as a minion shot, which allows it to proc summon tag effects. } public override void SetDefaults() @@ -68,8 +69,9 @@ namespace CalamityMod.Projectiles.Summon float projX = Projectile.position.X; float projY = Projectile.position.Y; float attackDistance = 100000f; - bool canAttack = false; Projectile.ai[0] += 1f; + + NPC target = null; if (Projectile.ai[0] > 30f) { if (player.HasMinionAttackTargetNPC) @@ -82,14 +84,11 @@ namespace CalamityMod.Projectiles.Summon float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); if (npcDist < 640f && npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - attackDistance = npcDist; - projX = npcX; - projY = npcY; - canAttack = true; + target = npc; } } } - if (!canAttack) + if (target.IsNullOrInactive()) { foreach (NPC npc in Main.ActiveNPCs) { @@ -100,60 +99,17 @@ namespace CalamityMod.Projectiles.Summon float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); if (npcDist < 640f && npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) { - attackDistance = npcDist; - projX = npcX; - projY = npcY; - canAttack = true; + + target = npc; } } } } } - if (!canAttack) - { - projX = Projectile.position.X + (float)(Projectile.width / 2) + Projectile.velocity.X * 100f; - projY = Projectile.position.Y + (float)(Projectile.height / 2) + Projectile.velocity.Y * 100f; - } - float projVel = 0.16f; - Vector2 playerDirection = Projectile.Center; - float playerX = projX - playerDirection.X; - float playerY = projY - playerDirection.Y; - float playerDist = (float)Math.Sqrt((double)(playerX * playerX + playerY * playerY)); - playerDist = 10f / playerDist; - playerX *= playerDist; - playerY *= playerDist; - if (Projectile.velocity.X < playerX) - { - Projectile.velocity.X = Projectile.velocity.X + projVel; - if (Projectile.velocity.X < 0f && playerX > 0f) - { - Projectile.velocity.X = Projectile.velocity.X + projVel * 2f; - } - } - else if (Projectile.velocity.X > playerX) - { - Projectile.velocity.X = Projectile.velocity.X - projVel; - if (Projectile.velocity.X > 0f && playerX < 0f) - { - Projectile.velocity.X = Projectile.velocity.X - projVel * 2f; - } - } - if (Projectile.velocity.Y < playerY) - { - Projectile.velocity.Y = Projectile.velocity.Y + projVel; - if (Projectile.velocity.Y < 0f && playerY > 0f) - { - Projectile.velocity.Y = Projectile.velocity.Y + projVel * 2f; - } - } - else if (Projectile.velocity.Y > playerY) - { - Projectile.velocity.Y = Projectile.velocity.Y - projVel; - if (Projectile.velocity.Y > 0f && playerY < 0f) - { - Projectile.velocity.Y = Projectile.velocity.Y - projVel * 2f; - } - } + if (!target.IsNullOrInactive()) + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(target.Center) * 15, 0.1f); + else + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.velocity.SafeNormalize(Vector2.Zero) * 15, 0.1f); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Summon/FrostBeam.cs b/Projectiles/Summon/FrostBeam.cs index 387742cada..115b330c06 100644 --- a/Projectiles/Summon/FrostBeam.cs +++ b/Projectiles/Summon/FrostBeam.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Summon // instead of weaving backwards. (float)(Math.Sin(thetaDelta + theta * flowerPetalCount) + 0.5f + weaveDistanceInner) * weaveDistanceOutwardMax); - Dust dust = Dust.NewDustPerfect(Projectile.Center, 113, velocity); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.MushroomSpray, velocity); dust.noGravity = true; dust.scale = 1.35f; } diff --git a/Projectiles/Summon/FrostBlossom.cs b/Projectiles/Summon/FrostBlossom.cs index c430427aad..0c8c0125da 100644 --- a/Projectiles/Summon/FrostBlossom.cs +++ b/Projectiles/Summon/FrostBlossom.cs @@ -17,6 +17,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -71,7 +72,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 36; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 113); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.MushroomSpray); dust.noGravity = true; dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(2f, 7f); } @@ -88,7 +89,5 @@ namespace CalamityMod.Projectiles.Summon } } } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/FrostMistFriendly.cs b/Projectiles/Summon/FrostMistFriendly.cs index b315063341..02afaf3337 100644 --- a/Projectiles/Summon/FrostMistFriendly.cs +++ b/Projectiles/Summon/FrostMistFriendly.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Summon } } Projectile.ai[1] = 1f; - SoundEngine.PlaySound(SoundID.Item30, Projectile.position); + SoundEngine.PlaySound(SoundID.Item30 with { Volume = 0.5f }, Projectile.position); } if (Projectile.localAI[0] == 0f) { diff --git a/Projectiles/Summon/FrostbatMinion.cs b/Projectiles/Summon/FrostbatMinion.cs deleted file mode 100644 index a6de4258f3..0000000000 --- a/Projectiles/Summon/FrostbatMinion.cs +++ /dev/null @@ -1,224 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.Summon; -using CalamityMod.Particles; -using CalamityMod.Projectiles.BaseProjectiles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Projectiles.Summon -{ - public class FrostbatMinion : BaseMinionProjectile - { - public override int AssociatedProjectileTypeID => ProjectileType(); - - public override int AssociatedBuffTypeID => BuffType(); - - public override ref bool AssociatedMinionBool => ref ModdedOwner.FrostbatBool; - - public override bool PreHardmodeMinionTileVision => true; - - public override int AnimationFrames => 8; - - private Vector2 IdlePosition => Owner.MountedCenter + - -Vector2.UnitY.RotatedBy(MathHelper.ToRadians(15f) * (Owner.ownedProjectileCounts[Type] + Owner.ownedProjectileCounts[ProjectileType()] - 1) - MathHelper.ToRadians(30f) * MinionIndex) * 80f; - - private Action CurrentBehavior; - - [Flags] - private enum AttackBehaviorFlags : byte - { - None = 0, - HasDashed = 1, - HasHitTargetOnDash = 2, - IsReturningToOwner = 4, - } - - private AttackBehaviorFlags AttackState; - - public int MinionIndex; - - public override void SetDefaults() - { - base.SetDefaults(); - (Projectile.width, Projectile.height) = (32, 28); - } - - #region AI - - public override void MinionAI() - { - if (Projectile.ai[0] == 0f) - { - CurrentBehavior = IdleBehavior; - FramesUntilNextAnimationFrame = 3; - - int minionIndex = 0; - foreach (var proj in Main.ActiveProjectiles) - { - if ((proj.type != Type && proj.type != ProjectileType()) || proj.owner != Projectile.owner) - continue; - - if (proj.type == Type) - MinionIndex = minionIndex; - else - proj.ModProjectile().MinionIndex = minionIndex; - - minionIndex++; - } - - Projectile.ai[0]++; - } - - CurrentBehavior.Invoke(); - Projectile.rotation = Projectile.rotation.AngleTowards(MathHelper.ToRadians(Projectile.velocity.X * 3f), 0.2f); - Projectile.spriteDirection = MathF.Sign(Projectile.velocity.X); - - if (!Main.dedServ) - { - if (CurrentBehavior == AttackBehavior || (CurrentBehavior == IdleBehavior && Main.rand.NextBool(10))) - { - Dust ambientDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.IceTorch); - ambientDust.noGravity = Main.rand.NextBool(); - ambientDust.noLight = true; - ambientDust.noLightEmittence = true; - } - - Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3() * 0.5f); - } - } - - private void IdleBehavior() - { - if (Target is not null) - { - CurrentBehavior = AttackBehavior; - Projectile.velocity = Projectile.DirectionTo(Target.Center).RotatedByRandom(MathHelper.PiOver2 * 0.7f) * 10f; - return; - } - - Projectile.velocity = Projectile.DirectionTo(IdlePosition) * Utils.Remap(Projectile.DistanceSQ(IdlePosition), 25600f, 0f, 6f, 0f); - Projectile.MinionAntiClump(); - } - - private void AttackBehavior() - { - if (Target is null) - { - CurrentBehavior = IdleBehavior; - return; - } - - // The first stage is redirecting towards the target. - if (!AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && Vector2.Dot(Projectile.DirectionTo(Target.Center), Projectile.velocity.SafeNormalize(-Vector2.UnitY)) < 0.96f) - { - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.DirectionTo(Target.Center).ToRotation(), 0.08f).ToRotationVector2() * - Utils.Remap(Projectile.DistanceSQ(Target.Center), 6400f, 0f, 8f, 0f); - } - - // When it's whithin a distnce and it hasn't dashed yet, it'll dash. - else if (!AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && Projectile.DistanceSQ(Target.Center) < 57600f) - { - Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, Target, 18f); - AttackState |= AttackBehaviorFlags.HasDashed; - Projectile.netUpdate = true; - - if (!Main.dedServ) - { - Particle dashRing = new DirectionalPulseRing( - Projectile.Center, - Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 5f, - Color.Cyan, - new Vector2(0.5f, 1f), - Projectile.velocity.ToRotation(), - 0.04f, - 0.4f, - 30); - GeneralParticleHandler.SpawnParticle(dashRing); - - SoundEngine.PlaySound(SoundID.Item1 with { Pitch = 0.5f, PitchVariance = 0.1f, Volume = 0.6f }, Projectile.Center); - } - } - - // The second stage is after the dash. - // If it has hit the target is was supposed to hit or he missed: - // Return to the owner. - if (AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && !AttackState.HasFlag(AttackBehaviorFlags.IsReturningToOwner)) - { - if (Vector2.Dot(Projectile.DirectionTo(Target.Center), Projectile.velocity.SafeNormalize(-Vector2.UnitY)) < 0f || AttackState.HasFlag(AttackBehaviorFlags.HasHitTargetOnDash)) - { - AttackState |= AttackBehaviorFlags.IsReturningToOwner; - Projectile.netUpdate = true; - } - } - - // The minion will redirect towards its idle position. - // When it has arrived to it at a distance, reset the state and start over. - if (AttackState.HasFlag(AttackBehaviorFlags.IsReturningToOwner)) - { - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.DirectionTo(IdlePosition).ToRotation(), 0.08f).ToRotationVector2() * - Utils.Remap(Projectile.DistanceSQ(IdlePosition), 6400f, 0f, 8f, 0f); - - if (Projectile.DistanceSQ(IdlePosition) < 6400f) - { - AttackState = AttackBehaviorFlags.None; - Projectile.netUpdate = true; - } - } - } - - public override bool MinionContactDamage() => true; - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (AttackState.HasFlag(AttackBehaviorFlags.HasDashed) && !AttackState.HasFlag(AttackBehaviorFlags.HasHitTargetOnDash) && Target == target) - AttackState |= AttackBehaviorFlags.HasHitTargetOnDash; - - target.AddBuff(BuffID.Frostburn, 60); - } - - #endregion - - #region Drawing - - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture = TextureAssets.Projectile[Type].Value; - Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); - Main.EntitySpriteDraw( - texture, - Projectile.Center - Main.screenPosition, - frame, - Color.White * 0.6f, - Projectile.rotation, - frame.Size() * 0.5f, - Projectile.scale, - Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); - return false; - } - - #endregion - - #region Syncing - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write7BitEncodedInt(MinionIndex); - writer.Write((byte)AttackState); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - MinionIndex = reader.Read7BitEncodedInt(); - AttackState = (AttackBehaviorFlags)reader.ReadByte(); - } - - #endregion - } -} diff --git a/Projectiles/Summon/GammaHead.cs b/Projectiles/Summon/GammaHead.cs index c769643882..adad872278 100644 --- a/Projectiles/Summon/GammaHead.cs +++ b/Projectiles/Summon/GammaHead.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -97,7 +98,7 @@ namespace CalamityMod.Projectiles.Summon public void PerformInitializationEffects() { - int totalHeads = CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner); + int totalHeads = Main.player[Projectile.owner].ownedProjectileCounts[Projectile.type]; CurrentPositionOffset = IdealPositionOffset = new Vector2(Main.rand.NextFloat(-72f - 8f * totalHeads, 72f + 8f * totalHeads), -Main.rand.NextFloat(8f, 84f + 4f * totalHeads)); Projectile.netUpdate = true; @@ -169,7 +170,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity = (Projectile.velocity * 9f + Projectile.SafeDirectionTo(returnPosition) * flySpeed) / 10f; } - int totalHeads = CalamityUtils.CountOwnedProjectiles(Projectile.type, Projectile.owner); + int totalHeads = Main.player[Projectile.owner].ownedProjectileCounts[Projectile.type]; int moveRate = 40 + totalHeads * 4; // Reset the ideal offset from time to time. @@ -264,7 +265,5 @@ namespace CalamityMod.Projectiles.Summon return false; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/GastricBelcher.cs b/Projectiles/Summon/GastricBelcher.cs index 12856293d4..c4523cdeee 100644 --- a/Projectiles/Summon/GastricBelcher.cs +++ b/Projectiles/Summon/GastricBelcher.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -162,7 +163,7 @@ namespace CalamityMod.Projectiles.Summon //If farther than 200 pixels, move toward it if (targetDist > 200f) { - float speedMult = (targetDist > 400f) ? 12f : (targetDist > 250) ? 6f : 3f; + float speedMult = (targetDist > 400f) ? 16f : (targetDist > 250) ? 9f : 5f; vecToTarget *= speedMult; Projectile.velocity = (Projectile.velocity * 40f + vecToTarget) / 41f; } @@ -242,7 +243,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.ai[1] += Main.rand.Next(1, 4); } //Set the minion to be ready for attack - if (Projectile.ai[1] > 90f) + if (Projectile.ai[1] > 100f) { Projectile.ai[1] = 0f; Projectile.netUpdate = true; @@ -264,25 +265,23 @@ namespace CalamityMod.Projectiles.Summon //Increment the attack counter Projectile.ai[1]++; - int projType = ModContent.ProjectileType(); - //Calculate the general velocity Vector2 velocity = targetVec - Projectile.Center; velocity.Normalize(); //Add some inaccuracy for the vomit projectiles - float vomitSpeedMult = 16f; + float vomitSpeedMult = 20f; Vector2 vomitVel = velocity * vomitSpeedMult; vomitVel.Y += Main.rand.NextFloat(-30f, 30f) * 0.05f; vomitVel.X += Main.rand.NextFloat(-30f, 30f) * 0.05f; //Fire the vomit projectile - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vomitVel, projType, Projectile.damage, Projectile.knockBack, Projectile.owner, Main.rand.Next(3), 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vomitVel, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, Main.rand.Next(3), 0f); - //Fire 5 bubbles for every three attacks + //Fire 3 bubbles for every three attacks if (bubbleCounter++ % 3 == 2) { - for (int projCount = 0; projCount < 5; projCount++) + for (int projCount = 0; projCount < 3; projCount++) { //Add a shotgun spread to the bubbles float bubbleSpeedMult = 14f; @@ -298,9 +297,6 @@ namespace CalamityMod.Projectiles.Summon } } - //This minion does no contact damage - public override bool? CanDamage() => false; - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; diff --git a/Projectiles/Summon/GastricBelcherVomit.cs b/Projectiles/Summon/GastricBelcherVomit.cs index f5c7e0265a..a64d35a94b 100644 --- a/Projectiles/Summon/GastricBelcherVomit.cs +++ b/Projectiles/Summon/GastricBelcherVomit.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; @@ -21,9 +20,9 @@ namespace CalamityMod.Projectiles.Summon Projectile.friendly = true; Projectile.width = Projectile.height = 18; Projectile.timeLeft = 300; - Projectile.penetrate = 3; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.penetrate = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 30; Projectile.DamageType = DamageClass.Summon; } diff --git a/Projectiles/Summon/GhostFire.cs b/Projectiles/Summon/GhostFire.cs index d4f5d8136a..ffabe84d0f 100644 --- a/Projectiles/Summon/GhostFire.cs +++ b/Projectiles/Summon/GhostFire.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -36,7 +35,10 @@ namespace CalamityMod.Projectiles.Summon Projectile.DamageType = DamageClass.Summon; } public override bool? CanDamage() => ableToHit ? (bool?)null : false; - + public override bool? CanHitNPC(NPC target) + { + return target.CanBeChasedBy() ? null : false; + } public override void AI() { Player player = Main.player[Projectile.owner]; diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs index ccc2102d01..95c43d2771 100644 --- a/Projectiles/Summon/GiantIbanRobotOfDoom.cs +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.Mounts; using CalamityMod.Items; -using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Projectiles.Summon.AndromedaUI; using Microsoft.Xna.Framework; using Terraria; @@ -243,7 +242,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 2; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.position + dustOffset, 263); + Dust dust = Dust.NewDustPerfect(Projectile.position + dustOffset, DustID.PortalBolt); dust.velocity = Vector2.Normalize(dust.position - Projectile.Top).RotatedByRandom(0.4f) * Main.rand.NextFloat(4f, 7f) + Projectile.velocity; dust.color = Color.SkyBlue; dust.scale = Main.rand.NextFloat(0.9f, 1.35f); @@ -330,7 +329,7 @@ namespace CalamityMod.Projectiles.Summon { if (Projectile.owner == Main.myPlayer) { - SoundEngine.PlaySound(GaussRifle.FireSound, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MechGaussRifle"), Projectile.Center); int damage = (int)player.GetTotalDamage().ApplyTo(LaserBaseDamage); // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction @@ -353,7 +352,7 @@ namespace CalamityMod.Projectiles.Summon public void ExitChargeModeEarly(Player player) { RightIconCooldown = RightIconAttackTime; - SoundEngine.PlaySound(GaussRifle.FireSound, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MechGaussRifle"), Projectile.Center); SpecialAttackExplosionDust(player); } public void SpecialAttackExplosionDust(Player player) @@ -368,13 +367,13 @@ namespace CalamityMod.Projectiles.Summon for (int speedSign = -1; speedSign <= 1; speedSign += 2) { float angle = MathHelper.Lerp(0f, MathHelper.TwoPi / 10f, (outwardness - 190f) / 170f); - Dust dust = Dust.NewDustPerfect(Projectile.Center, 221); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworkFountain_Blue); dust.noGravity = true; dust.scale = 1.6f; dust.position = player.Center + outwardness * (MathHelper.TwoPi / 10f * angleInterval).ToRotationVector2().RotatedBy(angle); dust.velocity = player.SafeDirectionTo(dust.position) * 8f * speedSign; - dust = Dust.NewDustPerfect(Projectile.Center, 221); + dust = Dust.NewDustPerfect(Projectile.Center, DustID.FireworkFountain_Blue); dust.noGravity = true; dust.scale = 1.6f; dust.position = player.Center + outwardness * (MathHelper.TwoPi / 10f * angleInterval).ToRotationVector2().RotatedBy(-angle); @@ -397,7 +396,7 @@ namespace CalamityMod.Projectiles.Summon int pointsOnStarSegment = 24; for (int j = 0; j < pointsOnStarSegment; j++) { - Dust dust = Dust.NewDustPerfect(player.Center, 221); + Dust dust = Dust.NewDustPerfect(player.Center, DustID.FireworkFountain_Blue); dust.noGravity = true; dust.scale = 1.9f; dust.velocity = Vector2.Lerp(start, end, j / (float)pointsOnStarSegment) * 13f * new Vector2(1.414f, 1f); diff --git a/Projectiles/Summon/HallowedStarSummon.cs b/Projectiles/Summon/HallowedStarSummon.cs index 4bb33d179c..12f84ae24b 100644 --- a/Projectiles/Summon/HallowedStarSummon.cs +++ b/Projectiles/Summon/HallowedStarSummon.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -30,6 +29,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.penetrate = 1; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Summon; + Projectile.extraUpdates = 4; + Projectile.stopsDealingDamageAfterPenetrateHits = true; } public override void AI() diff --git a/Projectiles/Summon/HarvestStaffMinion.cs b/Projectiles/Summon/HarvestStaffMinion.cs index f81a2ebd01..67d97ddc25 100644 --- a/Projectiles/Summon/HarvestStaffMinion.cs +++ b/Projectiles/Summon/HarvestStaffMinion.cs @@ -405,7 +405,7 @@ namespace CalamityMod.Projectiles.Summon // Pumpkins relase a bit of fire from their heads when running after enemies if (!Main.dedServ) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + new Vector2(0, -Projectile.height * 0.5f), 6, new Vector2(0, -4).RotatedBy(0.7f * -Projectile.direction) * Main.rand.NextFloat(0.1f, 0.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + new Vector2(0, -Projectile.height * 0.5f), DustID.Torch, new Vector2(0, -4).RotatedBy(0.7f * -Projectile.direction) * Main.rand.NextFloat(0.1f, 0.8f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.4f, 0.95f); } diff --git a/Projectiles/Summon/HauntedDishes.cs b/Projectiles/Summon/HauntedDishes.cs index c37e9eca65..05a7c49d14 100644 --- a/Projectiles/Summon/HauntedDishes.cs +++ b/Projectiles/Summon/HauntedDishes.cs @@ -15,9 +15,10 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projFrames[Type] = 19; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; - Main.projFrames[Type] = 19; } public override void SetDefaults() @@ -432,9 +433,9 @@ namespace CalamityMod.Projectiles.Summon { int i1 = (int)((double)Projectile.position.X + (double)(Projectile.width / 2)) / 16; int j = (int)((double)Projectile.position.Y + (double)Projectile.height) / 16 + 1; - if (WorldGen.SolidTile(i1, j) || Main.tile[i1, j].IsHalfBlock || ((int)Main.tile[i1, j].Slope > 0 || Projectile.type == 200)) + if (WorldGen.SolidTile(i1, j) || Main.tile[i1, j].IsHalfBlock || ((int)Main.tile[i1, j].Slope > 0 || Projectile.type == ProjectileID.PetLizard)) { - if (Projectile.type == 200) + if (Projectile.type == ProjectileID.PetLizard) { Projectile.velocity.Y = -3.1f; } @@ -467,7 +468,7 @@ namespace CalamityMod.Projectiles.Summon } } } - else if (Projectile.type == 266 && minionMovingLeft | minionMovingRight) + else if (Projectile.type == ProjectileID.BabySlime && minionMovingLeft | minionMovingRight) Projectile.velocity.Y -= 6f; } if (Projectile.velocity.X > groundMinionMaxVel) @@ -566,8 +567,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool? CanDamage() => false; - public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) { fallThrough = false; diff --git a/Projectiles/Summon/HermitCrabMinion.cs b/Projectiles/Summon/HermitCrabMinion.cs index c40b5a5741..444d3c756a 100644 --- a/Projectiles/Summon/HermitCrabMinion.cs +++ b/Projectiles/Summon/HermitCrabMinion.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 9; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -359,6 +360,8 @@ namespace CalamityMod.Projectiles.Summon return true; } + public override bool MinionContactDamage() => true; + public override bool OnTileCollide(Vector2 oldVelocity) => false; } } diff --git a/Projectiles/Summon/HerringAI.cs b/Projectiles/Summon/HerringAI.cs index 1c5e8e6087..54ae7836db 100644 --- a/Projectiles/Summon/HerringAI.cs +++ b/Projectiles/Summon/HerringAI.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -94,6 +95,8 @@ namespace CalamityMod.Projectiles.Summon } } + public override bool MinionContactDamage() => true; + public override bool OnTileCollide(Vector2 oldVelocity) => false; } } diff --git a/Projectiles/Summon/HerringMinion.cs b/Projectiles/Summon/HerringMinion.cs index 050a280eea..5821c667dc 100644 --- a/Projectiles/Summon/HerringMinion.cs +++ b/Projectiles/Summon/HerringMinion.cs @@ -33,6 +33,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.minion = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Summon/IceClasperMinion.cs b/Projectiles/Summon/IceClasperMinion.cs index a3c210090f..d99434a91f 100644 --- a/Projectiles/Summon/IceClasperMinion.cs +++ b/Projectiles/Summon/IceClasperMinion.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Summon { if (Main.rand.NextBool(10)) { - Dust ghostDust = Dust.NewDustPerfect(Projectile.Center, 56, -Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(2f, 3f)); + Dust ghostDust = Dust.NewDustPerfect(Projectile.Center, DustID.BlueFairy, -Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver2) * Main.rand.NextFloat(2f, 3f)); ghostDust.customData = false; ghostDust.noLight = true; ghostDust.noLightEmittence = true; @@ -170,7 +170,7 @@ namespace CalamityMod.Projectiles.Summon { float angle = MathHelper.TwoPi / dustAmount * dustIndex; Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 7f); - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 56, velocity); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, DustID.BlueFairy, velocity); spawnDust.customData = false; spawnDust.noGravity = true; spawnDust.velocity *= .75f; diff --git a/Projectiles/Summon/IceSentry.cs b/Projectiles/Summon/IceSentry.cs index 204cf095bf..83cce4898f 100644 --- a/Projectiles/Summon/IceSentry.cs +++ b/Projectiles/Summon/IceSentry.cs @@ -93,12 +93,10 @@ namespace CalamityMod.Projectiles.Summon rememberTarget = Collision.CanHit(Projectile.Center, 0, 0, npc.position, npc.width, npc.height); if (rememberTarget && Projectile.owner == Main.myPlayer) { - Vector2 speed = npc.Center - Projectile.Center; - speed.Normalize(); - speed *= 8f; + Vector2 iceSpeed = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, npc, 12f * (Utils.GetLerpValue(0f, 1000f, Vector2.Distance(Projectile.Center, npc.Center)) + 1)); if (Projectile.ai[1] >= 300f) - speed = speed.RotatedBy(MathHelper.ToRadians(Main.rand.Next(-5, 6))) * 1.5f + npc.velocity / 2f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, speed + npc.velocity / 2f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + iceSpeed = iceSpeed.RotatedByRandom(MathHelper.Pi * 0.025f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, iceSpeed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } } } @@ -132,7 +130,6 @@ namespace CalamityMod.Projectiles.Summon if (possibleTarget > 0) { - //Main.NewText("new target acquired"); Projectile.ai[0] = possibleTarget; Projectile.ai[1] = 0f; Projectile.netUpdate = true; diff --git a/Projectiles/Summon/IgneousBlade.cs b/Projectiles/Summon/IgneousBlade.cs index 4bff9cf79d..7fca4f2e51 100644 --- a/Projectiles/Summon/IgneousBlade.cs +++ b/Projectiles/Summon/IgneousBlade.cs @@ -1,156 +1,278 @@ -using System.IO; +using System; +using System.IO; using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Graphics; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { + //Based off Virid Vanguard projectile code for circling and drawing logic public class IgneousBlade : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; - public bool Firing = false; + public enum AIState + { + CircleOwner, + TransitionToLaunch, + LaunchAtPos + } + + public int BladeIndex; + + public VertexStrip TrailDrawer; + + public Vector2 ChargeStartingPosition; + + public float BladeHoverOffsetAngle + { + get + { + float projectileCounts = Owner.ownedProjectileCounts[Type]; + if (projectileCounts <= 1f) + projectileCounts = 1f; + + return MathHelper.WrapAngle(MathHelper.TwoPi * BladeIndex / projectileCounts + MathHelper.TwoPi * (Owner.miscCounter % 60 / 60f)) * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1); + } + } + + public AIState CurrentState + { + get => (AIState)Projectile.ai[0]; + set => Projectile.ai[0] = (int)value; + } + + public Player Owner => Main.player[Projectile.owner]; + + public ref float AITimer => ref Projectile.ai[1]; + + public ref float DistanceTimer => ref Projectile.ai[2]; + + public ref float BladeGleamInterpolant => ref Projectile.localAI[0]; + + public Vector2 ChargeTargetPos = Vector2.Zero; + public Vector2 ChargeStartPos = Vector2.Zero; + public override void SetStaticDefaults() { - ProjectileID.Sets.TrailingMode[Type] = 0; - ProjectileID.Sets.TrailCacheLength[Type] = 7; + ProjectileID.Sets.MinionSacrificable[Type] = true; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 45; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; } public override void SetDefaults() { - Projectile.width = 52; - Projectile.height = 86; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + + Projectile.width = 84; + Projectile.height = 84; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.minionSlots = 1f; - Projectile.timeLeft = 18000; + Projectile.timeLeft = 90000; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 7; Projectile.tileCollide = false; - Projectile.timeLeft *= 5; Projectile.minion = true; + Projectile.minionSlots = 1f; Projectile.DamageType = DamageClass.Summon; + Projectile.stopsDealingDamageAfterPenetrateHits = true; } + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(Firing); + writer.Write(BladeIndex); + writer.WriteVector2(ChargeStartingPosition); } + public override void ReceiveExtraAI(BinaryReader reader) { - Firing = reader.ReadBoolean(); + BladeIndex = reader.ReadInt32(); + ChargeStartingPosition = reader.ReadVector2(); } + + public override void AI() { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - bool isProperProjectile = Projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (isProperProjectile) - { - if (player.dead) - { - modPlayer.igneousExaltation = false; - } - if (modPlayer.igneousExaltation) - { - Projectile.timeLeft = 2; - } - } + // Decide whether the minion should still exist. + HandleMinionBools(); - // Orbiting. 1 = Shooting - if (!Firing) + // Reset extra updates. + Projectile.MaxUpdates = 1; + + // Have the gleam interpolant dissipate. + BladeGleamInterpolant = MathHelper.Lerp(BladeGleamInterpolant, 0f, 0.1f); + if (BladeGleamInterpolant <= 0.02f) + BladeGleamInterpolant = 0f; + + switch (CurrentState) { - const float outwardPosition = 180f; - Projectile.Center = player.Center + Projectile.ai[0].ToRotationVector2() * outwardPosition + Vector2.UnitY * player.gfxOffY; - Projectile.rotation = Projectile.ai[0] + MathHelper.PiOver2 + MathHelper.PiOver4; - Projectile.ai[0] -= MathHelper.ToRadians(4f); + case AIState.CircleOwner: + CircleOwner(); + break; + case AIState.TransitionToLaunch: + ChargeTargetPos = Owner.Calamity().mouseWorld; + ChargeStartPos = Owner.Center; + CurrentState = AIState.LaunchAtPos; + AITimer = 0; + Projectile.penetrate = 50; + LaunchAtTargetPos(); + break; + case AIState.LaunchAtPos: + LaunchAtTargetPos(); + break; + } + if (CurrentState == AIState.CircleOwner) + { + if (Owner.HeldItem.type == ModContent.ItemType()) + AITimer++; + else + AITimer--; + AITimer = MathHelper.Clamp(AITimer, -IgneousExaltation.ChargeCooldown, 0); } else + AITimer++; + DistanceTimer++; + } + + public void CircleOwner() + { + Vector2 hoverDestination = Owner.Center + BladeHoverOffsetAngle.ToRotationVector2() * (DistanceTimer < 0 ? MathHelper.Lerp(200, 100, 1 - (-DistanceTimer) / IgneousExaltation.ChargeCooldown) : 100f); + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, 24f); + Projectile.velocity *= 0.8f; + + // Teleport to the owner if sufficiently far away. + if (!Projectile.WithinRange(Owner.Center, 3200f)) { - if (Projectile.penetrate == -1) //limit penetration for worm memes - Projectile.penetrate = 3; + Projectile.Center = hoverDestination; + Projectile.netUpdate = true; + } - Projectile.ai[0]--; - if (Projectile.ai[0] == 1) - Projectile.Kill(); + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } - if (Projectile.ai[0] % 10f == 9f) - { - for (int i = 0; i < 20; i++) - { - float angle = MathHelper.TwoPi / 20f * i; - Dust dust = Dust.NewDustPerfect(Projectile.position + angle.ToRotationVector2().RotatedBy(Projectile.rotation) * new Vector2(14f, 21f), 6); - dust.velocity = angle.ToRotationVector2().RotatedBy(Projectile.rotation) * 2f; - dust.noGravity = true; - } - } + public void LaunchAtTargetPos() + { + Projectile.damage = Projectile.originalDamage; + if (Projectile.penetrate > 40) //First 10 hits do 2x damage + Projectile.damage *= 2; + int chargeTime = IgneousExaltation.ChargeDuration * 2; + int chargeLength = 2000; + float circleWidth = Math.Min(75, Owner.ownedProjectileCounts[Type] * 4); + var CurrentPlace = Vector2.Lerp(ChargeStartPos, ChargeStartPos + ChargeStartPos.DirectionTo(ChargeTargetPos) * chargeLength, MathF.Pow(AITimer / chargeTime, 3)); + Projectile.Center = CurrentPlace + BladeHoverOffsetAngle.ToRotationVector2() * Math.Max(MathHelper.Lerp(100f, 25f, AITimer / 10f), circleWidth); + Projectile.rotation = Projectile.AngleFrom(CurrentPlace) + MathHelper.PiOver2; + if (AITimer >= chargeTime) + { + Projectile.damage = Projectile.originalDamage; + AITimer = -IgneousExaltation.ChargeCooldown; + DistanceTimer = -IgneousExaltation.ChargeCooldown; + CurrentState = AIState.CircleOwner; + Projectile.penetrate = -1; } } + + public void HandleMinionBools() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type == ModContent.ProjectileType()) + { + if (Owner.dead) + Owner.Calamity().igneousExaltation = false; + + if (Owner.Calamity().igneousExaltation) + Projectile.timeLeft = 2; + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (Firing) - { + if (Projectile.penetrate >= 40 && CurrentState != AIState.CircleOwner) //The first 10 hits per launch can spawn blades if (Main.myPlayer == Projectile.owner) { - Projectile.ai[0] = 50; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 1; i++) { - Vector2 spawnPosition = target.Center - new Vector2(0f, 550f).RotatedByRandom(MathHelper.ToRadians(8f)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * 24f, ModContent.ProjectileType(), + Vector2 spawnPosition = Projectile.Center - new Vector2(0f, 550f).RotatedByRandom(MathHelper.TwoPi); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), spawnPosition, Vector2.Normalize(Projectile.Center - spawnPosition) * 24f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } for (int i = 0; i < Main.rand.Next(28, 41); i++) { Dust.NewDustPerfect( Projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f), - 6, + DustID.Torch, Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f)); } Projectile.netUpdate = true; } - } + base.OnHitNPC(target, hit, damageDone); } - public override void OnKill(int timeLeft) + public Color TrailColorFunction(float completionRatio) { - for (int j = 0; j < 40; j++) - { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Torch); - dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool().ToDirectionInt(); - dust.noGravity = true; - } + float opacity = (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D) * Projectile.Opacity * 0.48f; + var redColor = new Color(166, 46, 61); + return Color.Lerp(redColor, new(64, 51, 66), MathHelper.Clamp(completionRatio * 1.4f, 0f, 1f)) * opacity; } + + public float TrailWidthFunction(float completionRatio) => Projectile.height * (1f - completionRatio) * 0.3f; + public override bool PreDraw(ref Color lightColor) { - if (Firing) + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ^ Owner.Calamity().InvertExaltationLineRotationDirections ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + + // Draw the afterimage trail. + TrailDrawer ??= new(); + GameShaders.Misc["EmpressBlade"].UseImage0("Images/Extra_201"); + GameShaders.Misc["EmpressBlade"].UseImage1("Images/Extra_193"); + GameShaders.Misc["EmpressBlade"].UseShaderSpecificData(new Vector4(1f, 0f, 0f, 0.6f)); + GameShaders.Misc["EmpressBlade"].Apply(null); + TrailDrawer.PrepareStrip(Projectile.oldPos, Projectile.oldRot, TrailColorFunction, TrailWidthFunction, Projectile.Size * 0.5f - Main.screenPosition, Projectile.oldPos.Length, true); + TrailDrawer.DrawTrail(); + Main.pixelShader.CurrentTechnique.Passes[0].Apply(); + + // Draw the blade. + float outlineOpacity = 1; + float outlineWidth = 1; + if ((CurrentState == AIState.CircleOwner && AITimer < 0)) { - Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Summon/IgneousBlade").Value; - - Rectangle rectangle = new Rectangle(0, 0, texture.Width, texture.Height); - - if (Lighting.NotRetro) - { - 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 = Color.Lerp(Color.White, Color.Red, i / (float)Projectile.oldPos.Length) * - ((Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); - float scale = MathHelper.Lerp(Projectile.scale * 1.35f, Projectile.scale * 0.6f, i / (float)Projectile.oldPos.Length); - Main.EntitySpriteDraw(texture, drawPos, new Rectangle?(rectangle), color, - Projectile.rotation, - rectangle.Size() / 2f, scale, SpriteEffects.None, 0); - } - } - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle?(rectangle), Color.White, - Projectile.rotation, - rectangle.Size() / 2f, 1.35f, SpriteEffects.None, 0); - return false; + outlineWidth = Math.Clamp(MathF.Pow(1 - (AITimer) / -IgneousExaltation.ChargeCooldown, 3), 0, 100); + outlineOpacity = 0.75f; } - return true; + var outlineTex = IgneousExaltation.GetBladeOutlineTex(); + float rotation = Projectile.rotation - MathHelper.PiOver4 * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(2, 0) * outlineWidth, frame, new Color(166, 46, 61) * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(0, 2) * outlineWidth, frame, new Color(166, 46, 61) * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(-2, 0) * outlineWidth, frame, new Color(166, 46, 61) * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(0, -2) * outlineWidth, frame, new Color(166, 46, 61) * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, direction, 0); + + // Draw the gleam at the tip of the blade. + Texture2D shineTex = ModContent.Request("CalamityMod/Particles/HalfStar").Value; + Vector2 shineScale = new Vector2(1.67f, 3f) * Projectile.scale; + shineScale *= MathHelper.Lerp(0.9f, 1.1f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 7.4f + Projectile.identity) * 0.5f + 0.5f); + + Vector2 lensFlareWorldPosition = Projectile.Center + (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * Projectile.width * Projectile.scale * 0.88f; + Color lensFlareColor = Color.Lerp(Color.LimeGreen, Color.Yellow, 0.23f) with { A = 0 } * BladeGleamInterpolant; + Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, 0f, shineTex.Size() * 0.5f, shineScale * 0.6f, 0, 0); + Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, MathHelper.PiOver2, shineTex.Size() * 0.5f, shineScale, 0, 0); + + // Reset textures for shaders, since they're only defined once at load-time in vanilla. + GameShaders.Misc["EmpressBlade"].UseImage0("Images/Extra_209"); + GameShaders.Misc["EmpressBlade"].UseImage1("Images/Extra_210"); + return false; } } } diff --git a/Projectiles/Summon/IgneousBladeStrike.cs b/Projectiles/Summon/IgneousBladeStrike.cs index 6762bec590..4a3c172e87 100644 --- a/Projectiles/Summon/IgneousBladeStrike.cs +++ b/Projectiles/Summon/IgneousBladeStrike.cs @@ -1,6 +1,9 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -18,8 +21,8 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { Projectile.friendly = true; - Projectile.width = 86; - Projectile.height = 36; + Projectile.width = 50; + Projectile.height = 50; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.usesLocalNPCImmunity = true; @@ -27,6 +30,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 360; Projectile.alpha = 127; Projectile.DamageType = DamageClass.Summon; + Projectile.penetrate = 1; + Projectile.extraUpdates = 1; } public override void AI() @@ -39,10 +44,23 @@ namespace CalamityMod.Projectiles.Summon { Dust.NewDustPerfect( Projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f), - 6, + DustID.Torch, Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f)); } SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); } + + public override bool PreDraw(ref Color lightColor) + { + + var AllWhiteTexture = IgneousExaltation.GetBladeOutlineTex(); + Main.spriteBatch.Draw(AllWhiteTexture, Projectile.Center + new Vector2(0,2) - Main.screenPosition, null, new Color(166, 46, 61), Projectile.rotation, AllWhiteTexture.Size()*0.5f, Projectile.scale * 1f, SpriteEffects.None, 1f); + Main.spriteBatch.Draw(AllWhiteTexture, Projectile.Center + new Vector2(2, 0) - Main.screenPosition, null, new Color(166, 46, 61), Projectile.rotation, AllWhiteTexture.Size() * 0.5f, Projectile.scale * 1f, SpriteEffects.None, 1f); + Main.spriteBatch.Draw(AllWhiteTexture, Projectile.Center + new Vector2(0, -2) - Main.screenPosition, null, new Color(166, 46, 61), Projectile.rotation, AllWhiteTexture.Size() * 0.5f, Projectile.scale * 1f, SpriteEffects.None, 1f); + Main.spriteBatch.Draw(AllWhiteTexture, Projectile.Center + new Vector2(-2, 0) - Main.screenPosition, null, new Color(166, 46, 61), Projectile.rotation, AllWhiteTexture.Size() * 0.5f, Projectile.scale * 1f, SpriteEffects.None, 1f); + var tex = TextureAssets.Projectile[Type].Value; + Main.spriteBatch.Draw(tex, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale * 1f, SpriteEffects.None, 1f); + return false; + } } } diff --git a/Projectiles/Summon/IrradiatedAura.cs b/Projectiles/Summon/IrradiatedAura.cs index 65ca1a55ed..ddf25218a6 100644 --- a/Projectiles/Summon/IrradiatedAura.cs +++ b/Projectiles/Summon/IrradiatedAura.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; diff --git a/Projectiles/Summon/LanternFlame.cs b/Projectiles/Summon/LanternFlame.cs index 0707bd5bbf..9f56b3f108 100644 --- a/Projectiles/Summon/LanternFlame.cs +++ b/Projectiles/Summon/LanternFlame.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/LiliesOfEternityBullet.cs b/Projectiles/Summon/LiliesOfEternityBullet.cs index 5cbe15d4d7..9d836d0f40 100644 --- a/Projectiles/Summon/LiliesOfEternityBullet.cs +++ b/Projectiles/Summon/LiliesOfEternityBullet.cs @@ -1,4 +1,5 @@ -using CalamityMod.Graphics.Primitives; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -40,7 +41,7 @@ namespace CalamityMod.Projectiles.Summon Dust trailDust = Dust.NewDustPerfect( Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), - 64, + DustID.YellowTorch, Projectile.velocity * Main.rand.NextFloat(0.01f, 0.05f), Scale: Main.rand.NextFloat(1f, 1.2f)); trailDust.noGravity = true; @@ -52,18 +53,18 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 10; } - private float PrimitiveWidthFunction(float completionRatio) + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float trailPoint = 0.1f; return completionRatio > trailPoint ? Utils.Remap(completionRatio, trailPoint, 1f, 12f, 0f) : Utils.Remap(completionRatio, trailPoint, 0f, 12f, 0f); } - private Color PrimitiveColorFunction(float completionRatio) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch) + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_,_) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); } } } diff --git a/Projectiles/Summon/LiliesOfFinalityAriane.cs b/Projectiles/Summon/LiliesOfFinalityAriane.cs index 7139fe46db..18cc36c7d0 100644 --- a/Projectiles/Summon/LiliesOfFinalityAriane.cs +++ b/Projectiles/Summon/LiliesOfFinalityAriane.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; using static System.MathF; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -150,8 +151,6 @@ namespace CalamityMod.Projectiles.Summon return true; } - public override bool? CanDamage() => false; - #endregion #region AI @@ -334,7 +333,7 @@ namespace CalamityMod.Projectiles.Summon GeneralParticleHandler.SpawnParticle(outerRing); GeneralParticleHandler.SpawnParticle(innerRing); - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneHellblastSound") { Pitch = 0.4f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneHellblastSound") { Pitch = 0.4f }, Projectile.Center); } private void FlyTowardsPlace(float speed, Vector2 place, int spriteDirection) @@ -451,7 +450,7 @@ namespace CalamityMod.Projectiles.Summon bool behindBackWall = false; Tile tileSafely = Framing.GetTileSafely(Projectile.Center); if (tileSafely != null) - behindBackWall = tileSafely.WallType > 0; + behindBackWall = tileSafely.WallType > WallID.None; if (behindBackWall) storming = false; diff --git a/Projectiles/Summon/LiliesOfFinalityBolt.cs b/Projectiles/Summon/LiliesOfFinalityBolt.cs index 662b165cf3..9656c511d3 100644 --- a/Projectiles/Summon/LiliesOfFinalityBolt.cs +++ b/Projectiles/Summon/LiliesOfFinalityBolt.cs @@ -114,9 +114,9 @@ namespace CalamityMod.Projectiles.Summon sound.Stop(); } - private float WidthFunction(float completionRatio) => MathHelper.Lerp(0f, 32f, MathF.Pow(completionRatio, 1f / 2.5f)); + private float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Lerp(0f, 32f, MathF.Pow(completionRatio, 1f / 2.5f)); - private Color ColorFunction(float completionRatio) + private Color ColorFunction(float completionRatio, Vector2 vertexPos) { float offsetTime = Main.GlobalTimeWrappedHourly + RandomColorOffset; float fadeToEnd = MathHelper.Lerp(0.65f, 1f, (float)Math.Cos(-offsetTime * 3f) * 0.5f + 0.5f); @@ -128,7 +128,7 @@ namespace CalamityMod.Projectiles.Summon public override bool PreDraw(ref Color lightColor) { GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, pixelate: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, pixelate: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32); return false; } } diff --git a/Projectiles/Summon/LiliesOfFinalityBullet.cs b/Projectiles/Summon/LiliesOfFinalityBullet.cs index 7dd9798613..2ec3764de2 100644 --- a/Projectiles/Summon/LiliesOfFinalityBullet.cs +++ b/Projectiles/Summon/LiliesOfFinalityBullet.cs @@ -1,4 +1,5 @@ -using CalamityMod.Graphics.Primitives; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -43,7 +44,7 @@ namespace CalamityMod.Projectiles.Summon Dust trailDust = Dust.NewDustPerfect( Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), - 64, + DustID.YellowTorch, Projectile.velocity * Main.rand.NextFloat(0.01f, 0.05f), Scale: Main.rand.NextFloat(1f, 1.2f)); trailDust.noGravity = true; @@ -56,18 +57,18 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 10; } - private float PrimitiveWidthFunction(float completionRatio) + private float PrimitiveWidthFunction(float completionRatio, Vector2 vertexPos) { float trailPoint = 0.1f; return completionRatio > trailPoint ? Utils.Remap(completionRatio, trailPoint, 1f, 16f, 0f) : Utils.Remap(completionRatio, trailPoint, 0f, 16f, 0f); } - private Color PrimitiveColorFunction(float completionRatio) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); + private Color PrimitiveColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); - public void RenderPixelatedPrimitives(SpriteBatch spriteBatch) + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_, _) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); } } } diff --git a/Projectiles/Summon/LiliesOfFinalityElster.cs b/Projectiles/Summon/LiliesOfFinalityElster.cs index 3d52276011..2764514390 100644 --- a/Projectiles/Summon/LiliesOfFinalityElster.cs +++ b/Projectiles/Summon/LiliesOfFinalityElster.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; using static System.MathF; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -146,8 +147,6 @@ namespace CalamityMod.Projectiles.Summon return true; } - public override bool? CanDamage() => false; - #endregion #region AI @@ -330,7 +329,7 @@ namespace CalamityMod.Projectiles.Summon 7); GeneralParticleHandler.SpawnParticle(shootRing); - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/ElsterShot", 4) { Volume = 0.3f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ElsterShot", 4) { Volume = 0.3f }, Projectile.Center); } private void ElevationDust(bool shootingState) @@ -474,7 +473,7 @@ namespace CalamityMod.Projectiles.Summon bool behindBackWall = false; Tile tileSafely = Framing.GetTileSafely(Projectile.Center); if (tileSafely != null) - behindBackWall = tileSafely.WallType > 0; + behindBackWall = tileSafely.WallType > WallID.None; if (behindBackWall) storming = false; diff --git a/Projectiles/Summon/LostSoulGiant.cs b/Projectiles/Summon/LostSoulGiant.cs index c50208768b..ebdc36e759 100644 --- a/Projectiles/Summon/LostSoulGiant.cs +++ b/Projectiles/Summon/LostSoulGiant.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 45; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(60f, 60f), 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(60f, 60f), DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = 1.45f; diff --git a/Projectiles/Summon/LostSoulGold.cs b/Projectiles/Summon/LostSoulGold.cs index c9b0b3853d..993b33345b 100644 --- a/Projectiles/Summon/LostSoulGold.cs +++ b/Projectiles/Summon/LostSoulGold.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 45; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(42f, 42f), 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(42f, 42f), DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(1.75f, 1.75f); ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = 1.45f; diff --git a/Projectiles/Summon/LostSoulLarge.cs b/Projectiles/Summon/LostSoulLarge.cs index 819ffc07be..330a5dcc94 100644 --- a/Projectiles/Summon/LostSoulLarge.cs +++ b/Projectiles/Summon/LostSoulLarge.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 45; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(42f, 42f), 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(42f, 42f), DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(1.75f, 1.75f); ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = 1.45f; diff --git a/Projectiles/Summon/LostSoulSmall.cs b/Projectiles/Summon/LostSoulSmall.cs index 6e2bf53586..3266817ab8 100644 --- a/Projectiles/Summon/LostSoulSmall.cs +++ b/Projectiles/Summon/LostSoulSmall.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 45; i++) { - Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(42f, 42f), 264); + Dust ectoplasm = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(42f, 42f), DustID.PortalBoltTrail); ectoplasm.velocity = Main.rand.NextVector2Circular(1.75f, 1.75f); ectoplasm.color = Projectile.GetAlpha(Color.White); ectoplasm.scale = 1.45f; diff --git a/Projectiles/Summon/LuxorsGiftSummon.cs b/Projectiles/Summon/LuxorsGiftSummon.cs index 4e1654aa79..bd47047885 100644 --- a/Projectiles/Summon/LuxorsGiftSummon.cs +++ b/Projectiles/Summon/LuxorsGiftSummon.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -14,7 +13,6 @@ namespace CalamityMod.Projectiles.Summon public class LuxorsGiftSummon : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; - private int dust = 3; public NPC targeted; public int attackTime = 0; public override void SetStaticDefaults() @@ -57,7 +55,7 @@ namespace CalamityMod.Projectiles.Summon { bool sparkly = Main.rand.NextBool(3); Vector2 dustVel = -(Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.3f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), sparkly ? 278 : ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), sparkly ? DustID.FireworksRGB : ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); dust.noGravity = !sparkly; dust.scale = Main.rand.NextFloat(0.45f, 0.6f) * (sparkly ? 1.6f : 1); dust.color = Color.Lime; diff --git a/Projectiles/Summon/MechwormBody.cs b/Projectiles/Summon/MechwormBody.cs deleted file mode 100644 index b628517c67..0000000000 --- a/Projectiles/Summon/MechwormBody.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class MechwormBody : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionSacrificable[Type] = true; - ProjectileID.Sets.NeedsUUID[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 24; - Projectile.height = 24; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.alpha = 255; - Projectile.minionSlots = 0.5f; - Projectile.timeLeft = 90000; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.minion = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; - Projectile.hide = true; - Projectile.DamageType = DamageClass.Summon; - } - - // Arbitrary function used to identify a projectile based owner and identity. - // Used to get the correct projectile to attach to. - // Do not EVER touch this. - internal static bool SameIdentity(Projectile proj, int owner, int identity) - { - return proj.owner == owner && (proj.projUUID == identity || proj.identity == identity); - } - - internal static void SegmentAI(Projectile projectile, int offsetFromNextSegment, ref int playerMinionSlots) - { - // If the mechworm is opaque enough, produce light. - if (projectile.alpha <= 128) - Lighting.AddLight(projectile.Center, Color.DarkMagenta.ToVector3()); - - Player owner = Main.player[projectile.owner]; - CalamityPlayer modPlayer = owner.Calamity(); - - // Track the minion presence boolean. - if (owner.dead) - modPlayer.mWorm = false; - if (modPlayer.mWorm) - projectile.timeLeft = 2; - - int headProjType = ModContent.ProjectileType(); - int bodyProjType = ModContent.ProjectileType(); - int tailProjType = ModContent.ProjectileType(); - - ref float segmentAheadIdentity = ref projectile.ai[0]; - Projectile segmentAhead = Main.projectile.Take(Main.maxProjectiles).FirstOrDefault(proj => SameIdentity(proj, projectile.owner, (int)projectile.ai[0])); - - // Ensure that the segment ahead actually exists. If it doesn't, kill this segment. - if (segmentAhead is null || !Main.projectile.IndexInRange(segmentAhead.whoAmI) || (segmentAhead.type != bodyProjType && segmentAhead.type != headProjType)) - { - projectile.Kill(); - return; - } - - // Delete segments if some are lost for whatever reason (such as a summon potion expiring). - // playerMinionSlots is set to -1 for body segments to avoid type checking. - if (playerMinionSlots != -1 && (owner.maxMinions < playerMinionSlots || !owner.active)) - { - int lostSlots = playerMinionSlots - owner.maxMinions; - while (lostSlots > 0) - { - Projectile ahead = segmentAhead; - // Each body slot is actually 0.5 slots. Kill two segments to lose 1 "true" slot. - for (int i = 0; i < 2; ++i) - { - if (ahead.type != ModContent.ProjectileType()) - projectile.localAI[1] = ahead.localAI[1]; - - // Inherit the ahead segment index of the ahead segment (basically attaching to the segment that's two indices ahead). - segmentAheadIdentity = ahead.ai[0]; - projectile.netUpdate = true; - - ahead.Kill(); - - // And re-decide the ahead segment. - segmentAhead = Main.projectile.Take(Main.maxProjectiles).FirstOrDefault(proj => SameIdentity(proj, projectile.owner, (int)projectile.ai[0])); - - // Ensure that the segment ahead actually exists. If it doesn't, kill this segment. - if (segmentAhead is null || !Main.projectile.IndexInRange(segmentAhead.whoAmI)) - { - projectile.Kill(); - return; - } - ahead = segmentAhead; - } - lostSlots--; - } - playerMinionSlots = owner.maxMinions; - } - - // Accumulate the total segments of the worm. - segmentAhead.localAI[0] = projectile.localAI[0] + 1f; - segmentAhead.Calamity().UpdatePriority = segmentAhead.localAI[0]; - - // Locate the head segment by looping through the projectile array. - // Doing identity checks across every segment would be much more expensive than doing just this one loop. - Projectile head = LocateHead(projectile); - - // If no such head exists, kill this segment. - if (head is null) - { - projectile.Kill(); - return; - } - - // If the head is set to net update every body segment will also update. - // This update cannot be blocked by netSpam. - if (head.netUpdate) - projectile.ForceNetUpdate(false); - - projectile.extraUpdates = head.extraUpdates; - - MechwormHead headModProj = head.ModProjectile(); - if (headModProj.EndRiftGateUUID == -1) - { - // Very rapidly fade-in. - projectile.alpha = Utils.Clamp(projectile.alpha - 16, 0, 255); - } - else if (projectile.Hitbox.Intersects(Main.projectile[headModProj.EndRiftGateUUID].Hitbox)) - { - // Disappear if touching the mechworm portal. - // It will look like it's teleporting, when in reality, it's - // just an invisible, uninteractable projectile for the time being. - projectile.alpha = 255; - } - - projectile.velocity = Vector2.Zero; - Vector2 offsetToDestination = segmentAhead.Center - projectile.Center; - - // This variant of segment attachment incorporates rotation. - // Given the fact that all segments will execute this code is succession, the - // result across the entire worm will exponentially decay over each segment, - // allowing for smooth rotations. This code is what the stardust dragon uses for its segmenting. - if (segmentAhead.rotation != projectile.rotation) - { - float offsetAngle = MathHelper.WrapAngle(segmentAhead.rotation - projectile.rotation); - offsetToDestination = offsetToDestination.RotatedBy(offsetAngle * 0.08f); - } - projectile.rotation = offsetToDestination.ToRotation() + MathHelper.PiOver2; - - // Adjust the width/height of the segment in case the general size of the worm changes. - if (offsetToDestination != Vector2.Zero) - projectile.Center = segmentAhead.Center - offsetToDestination.SafeNormalize(Vector2.Zero) * offsetFromNextSegment; - - projectile.Center = Vector2.Clamp(projectile.Center, new Vector2(160f), new Vector2(Main.maxTilesX - 10, Main.maxTilesY - 10) * 16); - } - - public static Projectile LocateHead(Projectile projectile) - { - int headType = ModContent.ProjectileType(); - foreach (Projectile p in Main.ActiveProjectiles) - { - if (p.type != headType || p.owner != projectile.owner) - continue; - return p; - } - return null; - } - - public override void AI() - { - int _ = -1; - SegmentAI(Projectile, 16, ref _); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Main.EntitySpriteDraw(tex, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - return false; - } - - public override bool? CanDamage() => Projectile.alpha == 0; - - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) - { - behindProjectiles.Add(index); - } - - public override bool ShouldUpdatePosition() => false; - } -} diff --git a/Projectiles/Summon/MechwormBody.png b/Projectiles/Summon/MechwormBody.png deleted file mode 100644 index e27c80c807..0000000000 Binary files a/Projectiles/Summon/MechwormBody.png and /dev/null differ diff --git a/Projectiles/Summon/MechwormHead.cs b/Projectiles/Summon/MechwormHead.cs deleted file mode 100644 index bf954c8832..0000000000 --- a/Projectiles/Summon/MechwormHead.cs +++ /dev/null @@ -1,416 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class MechwormHead : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - internal enum AttackState : byte - { - PortalGateCharge, - LaserCharge - } - internal int AttackStateTimer = 0; - internal int EndRiftGateUUID = -1; - internal Vector2 TeleportStartingPoint; - internal Vector2 TeleportEndingPoint; - internal AttackState CurrentAttackState = AttackState.LaserCharge; - - internal const int MaxSegmentsToCountForScaling = 50; - internal const int AttackStateShiftTime = 320; - internal const int StartupLethargy = 150; - internal const int LaserChargeFrames = 45; - internal const int LaserRedirectFrames = 30; - internal const float MaxAttackFlySpeed = 33f; - - internal ref float Time => ref Projectile.ai[1]; - internal ref float TotalWormSegments => ref Projectile.localAI[0]; - - // Helper functions because Mechworm does a lot of checking for either itself or its target being near the edge of the world. - private static Vector2 WorldTopLeft(int tileDist = 15) => new Vector2(tileDist * 16f); - private static Vector2 WorldBottomRight(int tileDist = 15) => new Vector2(Main.maxTilesX - tileDist, Main.maxTilesY - tileDist) * 16f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionSacrificable[Type] = true; - ProjectileID.Sets.MinionTargettingFeature[Type] = true; - ProjectileID.Sets.NeedsUUID[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 24; - Projectile.height = 24; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.netImportant = true; - Projectile.penetrate = -1; - Projectile.timeLeft = 18000; - Projectile.alpha = 255; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - Projectile.minion = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; - Projectile.hide = true; - Projectile.DamageType = DamageClass.Summon; - } - - #region Syncing - public override void SendExtraAI(BinaryWriter writer) - { - byte enumByte = (byte)CurrentAttackState; - writer.Write(enumByte); - writer.Write(AttackStateTimer); - // localAI and alpha are not normally synced, so sync those - writer.Write(TotalWormSegments); - writer.Write(Projectile.alpha); - writer.Write(EndRiftGateUUID); - writer.WriteVector2(TeleportStartingPoint); - writer.WriteVector2(TeleportEndingPoint); - writer.Write(Projectile.extraUpdates); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - byte enumByte = reader.ReadByte(); - CurrentAttackState = (AttackState)enumByte; - AttackStateTimer = reader.ReadInt32(); - TotalWormSegments = reader.ReadSingle(); - Projectile.alpha = reader.ReadInt32(); - EndRiftGateUUID = reader.ReadInt32(); - TeleportStartingPoint = reader.ReadVector2(); - TeleportEndingPoint = reader.ReadVector2(); - Projectile.extraUpdates = reader.ReadInt32(); - } - #endregion - - #region AI - public override void AI() - { - // If the mechworm is opaque enough, produce light. - if (Projectile.alpha <= 128) - Lighting.AddLight(Projectile.Center, Color.DarkMagenta.ToVector3()); - - // Stops the mechworm from getting too close to the world boundary. Projectiles can instantly cause crashes when they cross the world boundary. - Projectile.Center = Vector2.Clamp(Projectile.Center, WorldTopLeft(10), WorldBottomRight(10)); - - Player owner = Main.player[Projectile.owner]; - - // Produce some dust when the worm is summoned. - if (Time < 3 && !Main.dedServ) - { - for (int i = 0; i < 50; i++) - { - Dust purpleElectricity = Dust.NewDustDirect(Projectile.position + Vector2.UnitY * 16f, Projectile.width, Projectile.height - 16, DustID.BoneTorch, 0f, 0f, 0, default, 1f); - purpleElectricity.velocity *= 2f; - purpleElectricity.scale *= 1.15f; - } - } - CalamityPlayer modPlayer = owner.Calamity(); - - // Maintain or remove the Mechworm buff from the owner. - owner.AddBuff(ModContent.BuffType(), 3600); - if (owner.dead) - modPlayer.mWorm = false; - if (modPlayer.mWorm) - Projectile.timeLeft = 2; - - Time++; - - if (!Main.projectile.IndexInRange(EndRiftGateUUID)) - { - // Very rapidly fade-in. - Projectile.alpha = Utils.Clamp(Projectile.alpha - 42, 0, 255); - } - else if (Projectile.Hitbox.Intersects(Main.projectile[EndRiftGateUUID].Hitbox)) - { - // Disappear if touching the mechworm portal. - // It will look like it's teleporting, when in reality, it's - // just an invisible, uninteractable projectile for the time being. - - if (Projectile.alpha != 255) - { - for (int i = 0; i < 35; i++) - { - Dust burstDust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.PurpleCosmilite); - burstDust.velocity = (MathHelper.TwoPi * i / 35f).ToRotationVector2().RotatedByRandom(0.035f) * 12f; - burstDust.noGravity = true; - - burstDust = Dust.NewDustDirect(Projectile.Center, 70, 70, (int)CalamityDusts.PurpleCosmilite); - burstDust.velocity = Main.rand.NextVector2CircularEdge(6f, 6f); - burstDust.scale = Main.rand.NextFloat(1.3f, 1.75f); - } - - SoundEngine.PlaySound(SoundID.Item8, Projectile.Center); - Projectile.alpha = 255; - } - } - - // Mechworm has an extremely generous default aggro range of 2200, but if it's already attacking, its bloodlust is insatiable. - NPC potentialTarget = Projectile.Center.MinionHoming(AttackStateTimer > 0 ? 999999f : 2800f, owner); - - // Teleport to the player if the worm is very far away from them. - if (Projectile.Distance(owner.Center) > 3850f) - { - Projectile.Center = owner.Center; - // Reset the worm's velocity when it returns to the player so that it doesn't instantly yeet off somewhere. - Projectile.velocity = Main.rand.NextVector2CircularEdge(3f, 3f); - Projectile.netUpdate = true; - } - - // Don't bother attacking if the target is close to the world edge, to prevent issues. - if (potentialTarget != null && Time > StartupLethargy && TargetInSafeBoundaries(potentialTarget)) - { - if (CurrentAttackState == AttackState.LaserCharge) - LaserAttackMovement(potentialTarget); - else - PortalAttackMovement(potentialTarget); - UpdateAttackStates(); - Projectile.extraUpdates = 1; - } - // Attacking movement can be canceled, so if it was, run the passive movement instead. - else - PlayerFollowMovement(owner); - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - - // Update the segment direction based on the velocity. - int previousDirection = Projectile.direction; - Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); - - // If it changed for some reason, fire a net update. This update cannot be blocked by netSpam. - if (previousDirection != Projectile.direction) - Projectile.ForceNetUpdate(false); - } - - private static bool TargetInSafeBoundaries(NPC target) => target?.Center.Between(WorldTopLeft(), WorldBottomRight()) ?? true; - - private void PlayerFollowMovement(Player owner) - { - Projectile.extraUpdates = 0; - - // Reset the gate UUID from any previous teleports. - if (EndRiftGateUUID != -1) - { - EndRiftGateUUID = -1; - Projectile.netUpdate = true; - } - - // If any attack was in use previously, send a net update now that attack mode is off. - if (AttackStateTimer != 0) - { - AttackStateTimer = 0; - Projectile.netUpdate = true; - } - - float hoverAcceleration = 0.2f; - float distanceFromOwner = Projectile.Distance(owner.Center); - if (distanceFromOwner < 200f) - hoverAcceleration = 0.12f; - if (distanceFromOwner < 140f) - hoverAcceleration = 0.06f; - - if (distanceFromOwner > 100f) - { - if (Math.Abs(owner.Center.X - Projectile.Center.X) > 20f) - Projectile.velocity.X += hoverAcceleration * Math.Sign(owner.Center.X - Projectile.Center.X); - if (Math.Abs(owner.Center.Y - Projectile.Center.Y) > 10f) - Projectile.velocity.Y += hoverAcceleration * Math.Sign(owner.Center.Y - Projectile.Center.Y); - } - else if (Projectile.velocity.Length() > 1f) - Projectile.velocity *= 0.96f; - - if (Math.Abs(Projectile.velocity.Y) < 1f) - Projectile.velocity.Y -= 0.1f; - - // The worm's max speed is more strictly capped for the first few seconds. - float maxSpeed = Time < StartupLethargy ? 6.5f : 25f; - if (Projectile.velocity.Length() > maxSpeed) - Projectile.velocity = Vector2.Normalize(Projectile.velocity) * maxSpeed; - } - - private void LaserAttackMovement(NPC target) - { - // Reset the gate UUID from any previous teleports. - if (EndRiftGateUUID != -1) - { - EndRiftGateUUID = -1; - Projectile.netUpdate = true; - } - - // If the timer indicates the worm is in redirect mode, then angle towards the target. - if (AttackStateTimer % (LaserChargeFrames + LaserRedirectFrames) < LaserRedirectFrames) - { - float angularTurnSpeed = MathHelper.ToRadians(18f); - float newSpeed = MathHelper.Lerp(Projectile.velocity.Length(), 24f, 0.35f); - - if (Projectile.Distance(target.Center) > 1100f) - newSpeed = MathHelper.Lerp(Projectile.velocity.Length(), 38f, 0.35f); - - Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.AngleTo(target.Center), angularTurnSpeed).ToRotationVector2() * newSpeed; - - // If the worm is very close to aiming directly at the target, immediately switch from redirecting to charging. - if (Vector2.Dot(Projectile.velocity.SafeNormalize(Vector2.Zero), Projectile.SafeDirectionTo(target.Center)) > 0.86f) - { - AttackStateTimer += LaserRedirectFrames - (AttackStateTimer % LaserChargeFrames); - Projectile.netUpdate = true; - } - } - - // On the exact frame the worm enters charge mode, fire 3 lasers and send a net update. - if (AttackStateTimer % (LaserChargeFrames + LaserRedirectFrames) == LaserChargeFrames) - { - // Charge and fire three lasers. - Projectile.velocity = Projectile.SafeDirectionTo(target.Center) * MaxAttackFlySpeed; - - if (Main.myPlayer == Projectile.owner) - { - for (int i = 0; i < 3; i++) - { - Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-0.15f, 0.15f, i / 3f)) * 0.3f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } - } - - SoundEngine.PlaySound(SoundID.Item12, Projectile.Center); - Projectile.netUpdate = true; - } - - // If neither of the above if-statements trigger, the worm just moves forwards in a straight line and this AI function does nothing. - } - - private void PortalAttackMovement(NPC target) - { - // Instantly abort and switch to laser mode if the target is too close to the edges of the world. - if (!target.Center.Between(WorldTopLeft(37), WorldBottomRight(37))) - { - CurrentAttackState = AttackState.LaserCharge; - EndRiftGateUUID = -1; - Projectile.netUpdate = true; - return; - } - - int chargeTime = (int)MathHelper.Min(36 + TotalWormSegments, 70); - if (AttackStateTimer % chargeTime == 0) - { - Vector2 offsetBounds = Vector2.Max(target.Size, new Vector2(425f + TotalWormSegments * 8f)); - Vector2 offset = Main.rand.NextVector2CircularEdge(offsetBounds.X, offsetBounds.Y) * 0.65f; - - // Dont teleport on the very first portal summon. Fly into a portal and THEN teleport later. - if (AttackStateTimer != 0) - { - TeleportStartingPoint = target.Center + offset; - TeleportEndingPoint = target.Center - offset; - } - else - TeleportEndingPoint = Projectile.Center + Projectile.velocity * chargeTime / 2f; - - // On the starting frame of a teleport, spawn portals. - if (Main.myPlayer == Projectile.owner) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), TeleportStartingPoint, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner); - int endGateIndex = Projectile.NewProjectile(Projectile.GetSource_FromThis(), TeleportEndingPoint, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner); - EndRiftGateUUID = Projectile.GetByUUID(Projectile.owner, endGateIndex); - - Main.projectile[EndRiftGateUUID].ai[0] = chargeTime; - Main.projectile[EndRiftGateUUID].timeLeft = chargeTime; - } - - // Dont teleport on the very first portal summon. - if (AttackStateTimer != 0) - Projectile.Center = TeleportStartingPoint; - - // Reset the alpha and position across the entire worm for the next charge. - foreach (Projectile otherProj in Main.ActiveProjectiles) - { - if (otherProj.owner != Projectile.owner || otherProj.whoAmI == Projectile.whoAmI) - continue; - - if (otherProj.type == ModContent.ProjectileType() || otherProj.type == ModContent.ProjectileType()) - { - otherProj.alpha = 0; - if (AttackStateTimer != 0) - otherProj.Center = Projectile.Center; - // There is no need to set the other projectiles to net update. They will do so when the head does. - } - } - - Projectile.alpha = 0; - Projectile.velocity = Projectile.SafeDirectionTo(TeleportEndingPoint) * (MaxAttackFlySpeed + target.velocity.Length() * 0.45f); - Projectile.netUpdate = true; - } - } - - private void UpdateAttackStates() - { - // If the current attack state is out of time, pick a new one. - if (++AttackStateTimer >= AttackStateShiftTime) - { - // When leaving portal-charge state, delete any remaining portals spawned by this worm. - if (CurrentAttackState == AttackState.PortalGateCharge) - CleanUpMechwormPortals(); - - CurrentAttackState = CurrentAttackState == AttackState.LaserCharge ? AttackState.PortalGateCharge : AttackState.LaserCharge; - AttackStateTimer = 0; - Projectile.netUpdate = true; - } - } - - private void CleanUpMechwormPortals() - { - int portalType = ModContent.ProjectileType(); - foreach (Projectile proj in Main.ActiveProjectiles) - { - if (proj.type != portalType || proj.owner != Projectile.owner) - continue; - - proj.Kill(); - // Spawn a little bit of dust when the portals are destroyed. - if (!Main.dedServ) - for (int j = 0; j < 16; j++) - Dust.NewDustDirect(proj.position, 45, 45, (int)CalamityDusts.PurpleCosmilite); - } - } - #endregion - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - - #region Drawing - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - 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 PostDraw(Color lightColor) - { - if (Projectile.alpha > 200) - return; - - Vector2 origin = new Vector2(21f, 25f); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Summon/MechwormHeadGlow").Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, 1f, SpriteEffects.None, 0); - } - - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) - { - behindProjectiles.Add(index); - } - - #endregion - } -} diff --git a/Projectiles/Summon/MechwormHead.png b/Projectiles/Summon/MechwormHead.png deleted file mode 100644 index 51125cc48c..0000000000 Binary files a/Projectiles/Summon/MechwormHead.png and /dev/null differ diff --git a/Projectiles/Summon/MechwormHeadGlow.png b/Projectiles/Summon/MechwormHeadGlow.png deleted file mode 100644 index 5c3251c4ec..0000000000 Binary files a/Projectiles/Summon/MechwormHeadGlow.png and /dev/null differ diff --git a/Projectiles/Summon/MechwormLaser.cs b/Projectiles/Summon/MechwormLaser.cs deleted file mode 100644 index 8237d39a03..0000000000 --- a/Projectiles/Summon/MechwormLaser.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class MechwormLaser : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override string Texture => "CalamityMod/Projectiles/LaserProj"; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionShot[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 5; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = 4; - Projectile.MaxUpdates = 3; - Projectile.timeLeft = 600; - Projectile.tileCollide = false; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - // Very quickly fade in. - Projectile.alpha = Utils.Clamp(Projectile.alpha - 25, 0, 255); - - Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3()); - if (Projectile.ai[1] == 0f) - { - Projectile.localAI[0] += 6f; - if (Projectile.localAI[0] > 30) - Projectile.localAI[0] = 30; - } - else - { - Projectile.localAI[0] -= 6f; - if (Projectile.localAI[0] <= 0f) - { - Projectile.Kill(); - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 120); - - public override Color? GetAlpha(Color lightColor) => Color.Lerp(Color.Fuchsia, Color.Cyan, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 1.9f + Projectile.identity * 2.4f) * 0.5f + 0.5f); - - public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); - - public override void OnKill(int timeLeft) - { - int dustAmt = Main.rand.Next(3, 7); - for (int d = 0; d < dustAmt; d++) - { - int rainbow = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, DustID.RainbowTorch, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.1f); - Main.dust[rainbow].velocity *= 2f; - Main.dust[rainbow].noGravity = true; - } - } - } -} diff --git a/Projectiles/Summon/MechwormTail.cs b/Projectiles/Summon/MechwormTail.cs deleted file mode 100644 index 3e4257fb5f..0000000000 --- a/Projectiles/Summon/MechwormTail.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class MechwormTail : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - private int playerMinionSlots = 0; - private bool runCheck = true; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionSacrificable[Type] = true; - ProjectileID.Sets.NeedsUUID[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 24; - Projectile.height = 24; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.alpha = 255; - Projectile.netImportant = true; - Projectile.timeLeft = 18000; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - Projectile.minion = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; - Projectile.hide = true; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - Player owner = Main.player[Projectile.owner]; - if (owner.maxMinions > playerMinionSlots) - playerMinionSlots = owner.maxMinions; - - if (runCheck) - { - runCheck = false; - playerMinionSlots = owner.maxMinions; - } - - Projectile.localAI[0] = 0f; - - MechwormBody.SegmentAI(Projectile, 16, ref playerMinionSlots); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 90); - - public override bool PreDraw(ref Color lightColor) - { - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Main.EntitySpriteDraw(tex, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); - return false; - } - - public override bool? CanDamage() => Projectile.alpha == 0; - - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) - { - behindProjectiles.Add(index); - } - - public override bool ShouldUpdatePosition() => false; - } -} diff --git a/Projectiles/Summon/MechwormTail.png b/Projectiles/Summon/MechwormTail.png deleted file mode 100644 index 1b8899fe11..0000000000 Binary files a/Projectiles/Summon/MechwormTail.png and /dev/null differ diff --git a/Projectiles/Summon/MechwormTeleportRift.cs b/Projectiles/Summon/MechwormTeleportRift.cs deleted file mode 100644 index 913d734f22..0000000000 --- a/Projectiles/Summon/MechwormTeleportRift.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class MechwormTeleportRift : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override string Texture => "CalamityMod/Projectiles/StarProj"; - - public ref float GeneralRotationalOffset => ref Projectile.ai[0]; - public override void SetStaticDefaults() - { - ProjectileID.Sets.NeedsUUID[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 170; - Projectile.scale = 0.25f; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.Opacity = 0f; - Projectile.penetrate = -1; - Projectile.timeLeft = 45; - Projectile.netImportant = true; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - if (Projectile.ai[0] == 0f) - Projectile.ai[0] = 45f; - - GeneralRotationalOffset += MathHelper.Pi / 8f; - Projectile.Opacity = MathHelper.Clamp(GeneralRotationalOffset, 0f, 1f); - - if (Projectile.Opacity == 1f && Main.rand.NextBool(15)) - { - Dust dust = Dust.NewDustDirect(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f); - dust.velocity.X = 0f; - dust.noGravity = true; - dust.position = Projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(4f, 20f); - dust.fadeIn = 1f; - dust.scale = 0.5f; - } - } - - public override bool PreDraw(ref Color lightColor) - { - float currentFade = Utils.GetLerpValue(0f, 5f, Projectile.timeLeft, true) * Utils.GetLerpValue(Projectile.ai[0], Projectile.ai[0] - 5f, Projectile.timeLeft, true); - currentFade *= (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f * MathHelper.Pi * 3f)) * 0.8f; - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color baseColor = new Color(150, 100, 255, 255) * Projectile.Opacity; - baseColor *= 0.5f; - baseColor.A = 0; - Color colorA = baseColor; - Color colorB = baseColor * 0.5f; - colorA *= currentFade; - colorB *= currentFade; - Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(3f, 7f) * Projectile.Opacity * Projectile.scale * currentFade; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); - - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2 + GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, GeneralRotationalOffset * 0.25f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2 + GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, GeneralRotationalOffset * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); - - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + GeneralRotationalOffset * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + GeneralRotationalOffset, origin, scale * 0.4f, spriteEffects, 0); - - return false; - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Summon/MidnightSunUFO.cs b/Projectiles/Summon/MidnightSunUFO.cs index c809587298..502494bb28 100644 --- a/Projectiles/Summon/MidnightSunUFO.cs +++ b/Projectiles/Summon/MidnightSunUFO.cs @@ -20,6 +20,8 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; + ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.TrailCacheLength[Type] = 4; ProjectileID.Sets.TrailingMode[Type] = 0; } @@ -39,8 +41,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.DamageType = DamageClass.Summon; } - public override bool? CanDamage() => false; - public override void AI() { Lighting.AddLight(Projectile.Center, Color.SkyBlue.ToVector3()); diff --git a/Projectiles/Summon/MiniGuardianAttack.cs b/Projectiles/Summon/MiniGuardianAttack.cs index 614db32a4d..539d17389d 100644 --- a/Projectiles/Summon/MiniGuardianAttack.cs +++ b/Projectiles/Summon/MiniGuardianAttack.cs @@ -155,7 +155,6 @@ namespace CalamityMod.Projectiles.Summon } // Turning (wtf is this) - // idk ask phup lmao if (Projectile.velocity.X < playerDestination.X) { Projectile.velocity.X += acceleration; diff --git a/Projectiles/Summon/MiniGuardianDefense.cs b/Projectiles/Summon/MiniGuardianDefense.cs index 5ec0668b23..c3ebe6bf20 100644 --- a/Projectiles/Summon/MiniGuardianDefense.cs +++ b/Projectiles/Summon/MiniGuardianDefense.cs @@ -226,7 +226,7 @@ namespace CalamityMod.Projectiles.Summon playerDist = returnSpeed / playerDist; playerDestination *= playerDist; - // Turning (wtf is this) (idk ask phup lmao) + // Turning (wtf is this) if (Projectile.velocity.X < playerDestination.X) { Projectile.velocity.X += acceleration; diff --git a/Projectiles/Summon/MiniGuardianHealer.cs b/Projectiles/Summon/MiniGuardianHealer.cs index 92b2796588..53397e2946 100644 --- a/Projectiles/Summon/MiniGuardianHealer.cs +++ b/Projectiles/Summon/MiniGuardianHealer.cs @@ -231,7 +231,7 @@ namespace CalamityMod.Projectiles.Summon playerDist = returnSpeed / playerDist; playerDestination *= playerDist; - // Turning (wtf is this) (idk ask phup lmao) + // Turning (wtf is this) if (Projectile.velocity.X < playerDestination.X) { Projectile.velocity.X += acceleration; diff --git a/Projectiles/Summon/MiniGuardianRock.cs b/Projectiles/Summon/MiniGuardianRock.cs index 664e157772..0e6437ea00 100644 --- a/Projectiles/Summon/MiniGuardianRock.cs +++ b/Projectiles/Summon/MiniGuardianRock.cs @@ -1,6 +1,7 @@ using System; using CalamityMod.Buffs.Summon.Whips; using CalamityMod.Dusts; +using CalamityMod.NPCs.ProfanedGuardians; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -109,7 +110,7 @@ namespace CalamityMod.Projectiles.Summon var dye = Owner?.cMinion ?? 0; bool psc = Owner.Calamity().profanedCrystalBuffs; int rockType = (int)MathHelper.Clamp(Projectile.ai[2], 1f, 6f); ; - Texture2D texture = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedRocks" + rockType.ToString()).Value; + Texture2D texture = ProfanedRocks.Textures[rockType - 1].Value; Vector2 drawOrigin = new Vector2(texture.Width / 2, texture.Height / 2); Vector2 drawPos = Projectile.Center - Main.screenPosition; diff --git a/Projectiles/Summon/MiniSandShark.cs b/Projectiles/Summon/MiniSandShark.cs index fd1ef345c5..8bf960074c 100644 --- a/Projectiles/Summon/MiniSandShark.cs +++ b/Projectiles/Summon/MiniSandShark.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Summon public override void OnKill(int timeLeft) // When the projectile hits an enemy, it'll make a dust impact effect. { SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int dustIndex = 0; dustIndex < 36; dustIndex++) + for (int dustIndex = 0; dustIndex < 18; dustIndex++) { Dust.NewDust(Projectile.Center, Projectile.width, diff --git a/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.cs b/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.cs index f7199ae813..0211e46030 100644 --- a/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.cs +++ b/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.cs @@ -3,7 +3,6 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Particles; -using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -79,7 +78,8 @@ namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions // Repeating swing sound. if (Projectile.soundDelay <= 0) { - SoundEngine.PlaySound(CommonCalamitySounds.LouderSwingWoosh with { Pitch = -.8f, PitchVariance = 1f, Volume = .6f }, Projectile.Center); + SoundStyle swing = new SoundStyle("CalamityMod/Sounds/Custom/LoudSwingWoosh") with { Pitch = -.8f, PitchVariance = 1f, Volume = .6f }; + SoundEngine.PlaySound(swing, Projectile.Center); Projectile.soundDelay = 15; Projectile.netUpdate = true; } diff --git a/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.cs b/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.cs index 34d42f7ebe..a1c6c3aee3 100644 --- a/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.cs +++ b/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.cs @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions { float angle = MathHelper.TwoPi / dustAmount * dustIndex; Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 15f); - Dust teleportDust = Dust.NewDustPerfect(Projectile.Center, 212, velocity, 0, default, 2f); + Dust teleportDust = Dust.NewDustPerfect(Projectile.Center, DustID.BubbleBurst_White, velocity, 0, default, 2f); teleportDust.noGravity = true; } diff --git a/Projectiles/Summon/MirrorofKalandraMinions/StarforgeBlast.cs b/Projectiles/Summon/MirrorofKalandraMinions/StarforgeBlast.cs index 6488c79e8f..6e71e48748 100644 --- a/Projectiles/Summon/MirrorofKalandraMinions/StarforgeBlast.cs +++ b/Projectiles/Summon/MirrorofKalandraMinions/StarforgeBlast.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions { float angle = MathHelper.TwoPi / dustAmount * dustIndex; Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(2f, 15f); - Dust boomDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(MirrorofKalandra.Purple_BlastSize / 2, MirrorofKalandra.Purple_BlastSize / 2), 272, velocity); + Dust boomDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(MirrorofKalandra.Purple_BlastSize / 2, MirrorofKalandra.Purple_BlastSize / 2), DustID.WitherLightning, velocity); boomDust.noGravity = true; boomDust.velocity *= .8f; boomDust.scale = velocity.Length() * .08f; diff --git a/Projectiles/Summon/MoonFist.cs b/Projectiles/Summon/MoonFist.cs index dec5c356bd..ca9f891814 100644 --- a/Projectiles/Summon/MoonFist.cs +++ b/Projectiles/Summon/MoonFist.cs @@ -94,7 +94,6 @@ namespace CalamityMod.Projectiles.Summon public void ApplyMinionBuffs() { - // Maintain or remove the Mechworm buff from the owner. Owner.AddBuff(ModContent.BuffType(), 3600); if (Owner.dead) Owner.Calamity().MoonFist = false; @@ -181,7 +180,7 @@ namespace CalamityMod.Projectiles.Summon { Vector2 dustDrawPosition = Vector2.Lerp(start, end, i / 74f); - Dust magic = Dust.NewDustPerfect(dustDrawPosition, 267); + Dust magic = Dust.NewDustPerfect(dustDrawPosition, DustID.RainbowMk2); magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(0.2f, 0.235f); magic.color = Color.LightCyan; magic.color.A = 0; diff --git a/Projectiles/Summon/MoonFistTeleportVisual.cs b/Projectiles/Summon/MoonFistTeleportVisual.cs index bea41c2742..f1714e561e 100644 --- a/Projectiles/Summon/MoonFistTeleportVisual.cs +++ b/Projectiles/Summon/MoonFistTeleportVisual.cs @@ -2,7 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 20; i++) { - Dust magic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(30f, 30f), 267); + Dust magic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(30f, 30f), DustID.RainbowMk2); magic.color = Color.SkyBlue; magic.scale = 1.1f; magic.fadeIn = 0.6f; diff --git a/Projectiles/Summon/MortalityBeam.cs b/Projectiles/Summon/MortalityBeam.cs index 49e9e13c28..91f493a79f 100644 --- a/Projectiles/Summon/MortalityBeam.cs +++ b/Projectiles/Summon/MortalityBeam.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Summon float offset = (float)Math.Sin(Time / 45f * MathHelper.TwoPi) * 10f * i; Vector2 rotatedOffset = new Vector2(offset, 2f).RotatedBy(Projectile.velocity.ToRotation() + MathHelper.PiOver2); - Dust rainbowDust = Dust.NewDustPerfect(Projectile.Center + rotatedOffset, 261); + Dust rainbowDust = Dust.NewDustPerfect(Projectile.Center + rotatedOffset, DustID.AncientLight); rainbowDust.color = Main.hslToRgb(Main.rand.NextFloat(), 0.9f, 0.5f); rainbowDust.velocity = Vector2.Zero; rainbowDust.scale = 1.5f; diff --git a/Projectiles/Summon/MortalityBolt.cs b/Projectiles/Summon/MortalityBolt.cs index 040465d30e..e1b9965dc0 100644 --- a/Projectiles/Summon/MortalityBolt.cs +++ b/Projectiles/Summon/MortalityBolt.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 4; i++) { - Dust rainbowDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5f, 5f), 261); + Dust rainbowDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5f, 5f), DustID.AncientLight); rainbowDust.color = ProjectileColor; rainbowDust.velocity += Projectile.velocity; rainbowDust.noGravity = true; diff --git a/Projectiles/Summon/MutatedTruffleMinion.cs b/Projectiles/Summon/MutatedTruffleMinion.cs index 6d9da588ec..5e97d9c72c 100644 --- a/Projectiles/Summon/MutatedTruffleMinion.cs +++ b/Projectiles/Summon/MutatedTruffleMinion.cs @@ -170,7 +170,7 @@ namespace CalamityMod.Projectiles.Summon if (!Main.dedServ) { - Dust.NewDustPerfect(Projectile.Right.RotatedBy(Projectile.rotation), 7, Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver4 / 2) * Main.rand.NextFloat(1f, 3f)); + Dust.NewDustPerfect(Projectile.Right.RotatedBy(Projectile.rotation), DustID.WoodFurniture, Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver4 / 2) * Main.rand.NextFloat(1f, 3f)); SoundEngine.PlaySound(SoundID.NPCDeath13 with { Volume = .5f, PitchVariance = .1f }, Projectile.Center); } diff --git a/Projectiles/Summon/MutatedTruffleToothball.cs b/Projectiles/Summon/MutatedTruffleToothball.cs index a80d5824e1..57bcb789eb 100644 --- a/Projectiles/Summon/MutatedTruffleToothball.cs +++ b/Projectiles/Summon/MutatedTruffleToothball.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Summon { float angle = MathHelper.TwoPi / dustAmount * dustIndex; Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(1f, 3f); - Dust.NewDustPerfect(Projectile.Center, 7, velocity); + Dust.NewDustPerfect(Projectile.Center, DustID.WoodFurniture, velocity); Dust deathDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.WoodFurniture); deathDust.noGravity = true; diff --git a/Projectiles/Summon/OldDukeHeadCorpse.cs b/Projectiles/Summon/OldDukeHeadCorpse.cs index ea34f9e8aa..747d5a4ebe 100644 --- a/Projectiles/Summon/OldDukeHeadCorpse.cs +++ b/Projectiles/Summon/OldDukeHeadCorpse.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using CalamityMod.Skies; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -53,7 +52,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity += (Vector2.One * 0.3f).RotatedByRandom(100); SoundStyle heartbeat = new("CalamityMod/Sounds/Item/Heartbeat"); SoundEngine.PlaySound(heartbeat with { Volume = 0.5f, MaxInstances = -1 }, player.Center); - player.Calamity().GeneralScreenShakePower = 6.5f * Utils.GetLerpValue(600, 0, GFBTimer); + player.SetScreenshake(6.5f * Utils.GetLerpValue(600, 0, GFBTimer)); Projectile.velocity *= 0.99f; } GFBTimer--; @@ -112,7 +111,7 @@ namespace CalamityMod.Projectiles.Summon SoundStyle heartbeat = new("CalamityMod/Sounds/Item/Heartbeat"); SoundEngine.PlaySound(heartbeat with { Volume = 0.8f, MaxInstances = -1 }, player.Center); } - player.Calamity().GeneralScreenShakePower = 4.5f; + player.SetScreenshake(4.5f); } Projectile.Center = player.Center; SoundEngine.PlaySound(SoundID.NPCDeath20 with { Volume = 0.35f, MaxInstances = -1 }, Projectile.Center); diff --git a/Projectiles/Summon/OldDukeSharkVomit.cs b/Projectiles/Summon/OldDukeSharkVomit.cs index fd7b640122..ebf8e9c181 100644 --- a/Projectiles/Summon/OldDukeSharkVomit.cs +++ b/Projectiles/Summon/OldDukeSharkVomit.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Summon/PerditionBeacon.cs b/Projectiles/Summon/PerditionBeacon.cs index 505e9616ee..c8efad089d 100644 --- a/Projectiles/Summon/PerditionBeacon.cs +++ b/Projectiles/Summon/PerditionBeacon.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.ID; using Terraria.ModLoader; using Terraria.Utilities; @@ -15,16 +16,14 @@ namespace CalamityMod.Projectiles.Summon public override int AssociatedProjectileTypeID => ModContent.ProjectileType(); public override int AssociatedBuffTypeID => ModContent.BuffType(); public override ref bool AssociatedMinionBool => ref ModdedOwner.perditionBeacon; - public override float MinionSlots => 5f; - public ref float AttackTime => ref Projectile.ai[0]; public ref float AttackTimer => ref Projectile.ai[1]; public ref float DownwardCrossFade => ref Projectile.localAI[1]; public override void SetStaticDefaults() { - base.SetStaticDefaults(); Main.projFrames[Type] = 16; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; } public override void SetDefaults() @@ -32,6 +31,10 @@ namespace CalamityMod.Projectiles.Summon base.SetDefaults(); Projectile.width = 48; Projectile.height = 90; + Projectile.minion = false; + Projectile.sentry = true; + Projectile.minionSlots = 0; + Projectile.timeLeft = Projectile.SentryLifeTime; } public override void SetOwnerTarget() @@ -77,7 +80,7 @@ namespace CalamityMod.Projectiles.Summon internal void AttackTarget() { // Release cinders around the target. - Dust cinder = Dust.NewDustPerfect(Target.Center + Main.rand.NextVector2Circular(800f, 800f), 6); + Dust cinder = Dust.NewDustPerfect(Target.Center + Main.rand.NextVector2Circular(800f, 800f), DustID.Torch); cinder.velocity = Vector2.UnitY * -Main.rand.NextFloat(3f, 7f); cinder.scale = 1f + cinder.velocity.Length() * 0.17f; cinder.noGravity = true; @@ -111,13 +114,14 @@ namespace CalamityMod.Projectiles.Summon public override void OnSpawn(IEntitySource source) { + Main.player[Projectile.owner].UpdateMaxTurrets(); // Release a burst of fire dust on spawn. if (Main.dedServ) return; for (int i = 0; i < 55; i++) { - Dust fire = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(35f, 35f), 267); + Dust fire = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(35f, 35f), DustID.RainbowMk2); fire.velocity = Vector2.Lerp(fire.velocity, Vector2.UnitY * -Main.rand.NextFloat(3.5f, 6f), 0.5f); fire.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 0.67f)); fire.scale = Main.rand.NextFloat(1.2f, 1.5f); diff --git a/Projectiles/Summon/PhantomGuy.cs b/Projectiles/Summon/PhantomGuy.cs index a86a9b90d6..90f0b0cbae 100644 --- a/Projectiles/Summon/PhantomGuy.cs +++ b/Projectiles/Summon/PhantomGuy.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -229,7 +230,5 @@ namespace CalamityMod.Projectiles.Summon { return new Color(100, 250, 250, Projectile.alpha); } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/PhantomicDagger.cs b/Projectiles/Summon/PhantomicDagger.cs index 114b11ab6c..8831c83389 100644 --- a/Projectiles/Summon/PhantomicDagger.cs +++ b/Projectiles/Summon/PhantomicDagger.cs @@ -57,11 +57,6 @@ namespace CalamityMod.Projectiles.Summon if (target.defense > 999 || target.Calamity().DR >= 0.95f || target.Calamity().unbreakableDR) return; - int cap = 3; - float capDamageFactor = 0.05f; - int excessCount = Main.player[Projectile.owner].ownedProjectileCounts[Type] - cap; - modifiers.SourceDamage *= MathHelper.Clamp(1f - (capDamageFactor * excessCount), 0f, 1f); - // Bypass a portion of the target's DR float maxDRPenetration = 1.05f; // 5% extra damage modifiers.FinalDamage *= MathHelper.Clamp(1f / (1f - target.Calamity().DR), 1f, maxDRPenetration); @@ -111,16 +106,15 @@ namespace CalamityMod.Projectiles.Summon } if (Projectile.alpha != 0) { - Projectile.rotation -= 0.25f; - Projectile.velocity.X *= 0.985f; - Projectile.velocity.Y *= 0.985f; + Projectile.rotation -= 6f * (MathF.Pow(Projectile.Opacity,2f)); + Projectile.velocity *= MathHelper.Lerp(1, 0.9f, Projectile.Opacity); if (Projectile.alpha < 3) { Projectile.alpha = 0; homing = true; } else - Projectile.alpha -= 3; + Projectile.alpha -= 2; } else { @@ -139,8 +133,8 @@ namespace CalamityMod.Projectiles.Summon targetDist = projVel / targetDist; targetXDist *= targetDist; targetYDist *= targetDist; - Projectile.velocity.X = (Projectile.velocity.X * 25f + targetXDist) / 26f; - Projectile.velocity.Y = (Projectile.velocity.Y * 25f + targetYDist) / 26f; + Projectile.velocity.X = (Projectile.velocity.X * 2f + targetXDist) / 3f; + Projectile.velocity.Y = (Projectile.velocity.Y * 2f + targetYDist) / 3f; } else { diff --git a/Projectiles/Summon/PhantomicShield.cs b/Projectiles/Summon/PhantomicShield.cs index e8cde40735..5b833ba421 100644 --- a/Projectiles/Summon/PhantomicShield.cs +++ b/Projectiles/Summon/PhantomicShield.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Summon int shadow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Shadowflame, 0f, 0f, 100, new Color(0, 0, 0), 3f); Main.dust[shadow].noGravity = true; Main.dust[shadow].velocity *= 5f; - shadow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 27, 0f, 0f, 100, new Color(0, 0, 0), 2f); + shadow = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Shadowflame, 0f, 0f, 100, new Color(0, 0, 0), 2f); Main.dust[shadow].velocity *= 2f; } } diff --git a/Projectiles/Summon/PinkButterfly.cs b/Projectiles/Summon/PinkButterfly.cs index 62400663b8..46df273110 100644 --- a/Projectiles/Summon/PinkButterfly.cs +++ b/Projectiles/Summon/PinkButterfly.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -245,7 +246,5 @@ namespace CalamityMod.Projectiles.Summon Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, spriteEffects, 0); return false; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/PlaguePrincess.cs b/Projectiles/Summon/PlaguePrincess.cs index be7f43f5e7..675df857c8 100644 --- a/Projectiles/Summon/PlaguePrincess.cs +++ b/Projectiles/Summon/PlaguePrincess.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.Particles; diff --git a/Projectiles/Summon/PlaguebringerMK2.cs b/Projectiles/Summon/PlaguebringerMK2.cs index 45bb6d1396..01e795d795 100644 --- a/Projectiles/Summon/PlaguebringerMK2.cs +++ b/Projectiles/Summon/PlaguebringerMK2.cs @@ -14,7 +14,8 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 6; - ProjectileID.Sets.MinionTargettingFeature[Type] = true; + Main.projPet[Type] = true; + ProjectileID.Sets.MinionSacrificable[Type] = true; } public override void SetDefaults() @@ -128,7 +129,5 @@ namespace CalamityMod.Projectiles.Summon Projectile.frame = 0; } } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/PlaguebringerSummon.cs b/Projectiles/Summon/PlaguebringerSummon.cs index 93401191a7..ffa626a95c 100644 --- a/Projectiles/Summon/PlaguebringerSummon.cs +++ b/Projectiles/Summon/PlaguebringerSummon.cs @@ -1,8 +1,6 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Projectiles/Summon/PlantationStaffSummon.cs b/Projectiles/Summon/PlantationStaffSummon.cs index 8c63dbcea8..cbda9afefa 100644 --- a/Projectiles/Summon/PlantationStaffSummon.cs +++ b/Projectiles/Summon/PlantationStaffSummon.cs @@ -324,7 +324,7 @@ namespace CalamityMod.Projectiles.Summon private void ShootEffect() { for (int i = 0; i < 5; i++) - Dust.NewDustPerfect(Projectile.Center, 40, Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 5f)); + Dust.NewDustPerfect(Projectile.Center, DustID.JunglePlants, Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(3f, 5f)); } #endregion diff --git a/Projectiles/Summon/PlantationStaffTentacle.cs b/Projectiles/Summon/PlantationStaffTentacle.cs index 788c936649..56d5d904f3 100644 --- a/Projectiles/Summon/PlantationStaffTentacle.cs +++ b/Projectiles/Summon/PlantationStaffTentacle.cs @@ -6,7 +6,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/PowerfulRaven.cs b/Projectiles/Summon/PowerfulRaven.cs index 379971a921..1f407a02b1 100644 --- a/Projectiles/Summon/PowerfulRaven.cs +++ b/Projectiles/Summon/PowerfulRaven.cs @@ -17,6 +17,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 5; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -61,6 +62,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 2; } } + Projectile.MinionAntiClump(); NPC potentialTarget = Projectile.Center.MinionHoming(DistanceToCheck, player); @@ -84,7 +86,7 @@ namespace CalamityMod.Projectiles.Summon { float angle = MathHelper.TwoPi / 40f * i; float lerp = MathHelper.Lerp(0f, 1f, (float)Math.Sin(i / 8f * MathHelper.TwoPi) * 0.5f + 0.5f); - Dust dust = Dust.NewDustPerfect(Projectile.position, 6); + Dust dust = Dust.NewDustPerfect(Projectile.position, DustID.Torch); dust.velocity = Vector2.Lerp(Vector2.Zero, angle.ToRotationVector2() * 6f, lerp); dust.noGravity = true; } @@ -97,7 +99,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 20; i++) { float angle = MathHelper.TwoPi / 20f * i; - Dust dust = Dust.NewDustPerfect(Projectile.position + angle.ToRotationVector2().RotatedBy(Projectile.rotation) * new Vector2(14f, 21f), 6); + Dust dust = Dust.NewDustPerfect(Projectile.position + angle.ToRotationVector2().RotatedBy(Projectile.rotation) * new Vector2(14f, 21f), DustID.Torch); dust.velocity = angle.ToRotationVector2().RotatedBy(Projectile.rotation) * 2f; dust.noGravity = true; } @@ -148,5 +150,7 @@ namespace CalamityMod.Projectiles.Summon } Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0).ToDirectionInt(); } + + public override bool MinionContactDamage() => true; } } diff --git a/Projectiles/Summon/ProfanedEnergy.cs b/Projectiles/Summon/ProfanedEnergy.cs index ae5a03e61c..fadd5344d5 100644 --- a/Projectiles/Summon/ProfanedEnergy.cs +++ b/Projectiles/Summon/ProfanedEnergy.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using CalamityMod.Dusts; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs index 2fe43d71ee..5c3722b6de 100644 --- a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs +++ b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Buffs.Summon.Whips; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Particles; @@ -15,7 +14,6 @@ using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.Items.Accessories.ProfanedSoulCrystal; -using static Humanizer.In; using Vector2 = Microsoft.Xna.Framework.Vector2; namespace CalamityMod.Projectiles.Summon @@ -1521,7 +1519,7 @@ namespace CalamityMod.Projectiles.Summon else { owner.Calamity().profanedCrystalAnim = -1; - owner.Calamity().GeneralScreenShakePower = 5f; + owner.SetScreenshake(5f); DetermineTransformationEligibility(owner); if (!Main.dedServ) { diff --git a/Projectiles/Summon/PuffWarrior.cs b/Projectiles/Summon/PuffWarrior.cs index 91dc1aa0a2..887fc8d6bd 100644 --- a/Projectiles/Summon/PuffWarrior.cs +++ b/Projectiles/Summon/PuffWarrior.cs @@ -30,6 +30,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 10; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -199,6 +200,8 @@ namespace CalamityMod.Projectiles.Summon } } + public override bool MinionContactDamage() => true; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (EnemyFailureCooldown > 0) diff --git a/Projectiles/Summon/PurpleButterfly.cs b/Projectiles/Summon/PurpleButterfly.cs index 790c60d81a..b7a03a55bc 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -87,6 +88,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.ChargingMinionAI(1200f, 1500f, 2400f, 150f, 0, 25f, 20f, 9f, new Vector2(0f, -60f), 30f, 15f, true, true); } + public override bool MinionContactDamage() => true; + public override bool PreDraw(ref Color lightColor) { SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; diff --git a/Projectiles/Summon/RustyBeaconPulse.cs b/Projectiles/Summon/RustyBeaconPulse.cs index db6d3a5737..daf22ad8c5 100644 --- a/Projectiles/Summon/RustyBeaconPulse.cs +++ b/Projectiles/Summon/RustyBeaconPulse.cs @@ -4,7 +4,6 @@ using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon diff --git a/Projectiles/Summon/SageNeedle.cs b/Projectiles/Summon/SageNeedle.cs index 0efecc2a3b..1de448a053 100644 --- a/Projectiles/Summon/SageNeedle.cs +++ b/Projectiles/Summon/SageNeedle.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -36,19 +35,7 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - int totalSageSpirits = Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()]; - - // A slightly-smoothened curve that's a little less potent than a linear curve. - // Has the potential to eventually surpass a linear curve, but this is infeasible, only happening - // at around 344 allocated slots. - float averageDamageMultiplier = (float)(Math.Pow(totalSageSpirits, 0.73D) + Math.Pow(totalSageSpirits, 1.1D)) * 0.5f; - - // 1 slot provides 25 DoT. - // 2 slots provide 48 DoT. - // 3 slots provide 70 DoT. - // 4 slots provide 92 DoT. - // 5 slots provide 114 DoT. - int sagePoisonDamage = (int)(50 * averageDamageMultiplier); + int sagePoisonDamage = (int)(SagePoison.debuffData.EnemyLostRegen * Main.player[Projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()]); target.AddBuff(ModContent.BuffType(), 300); target.Calamity().sagePoisonDamage = sagePoisonDamage; } diff --git a/Projectiles/Summon/SageSpirit.cs b/Projectiles/Summon/SageSpirit.cs index c7925c58ac..c621a77e78 100644 --- a/Projectiles/Summon/SageSpirit.cs +++ b/Projectiles/Summon/SageSpirit.cs @@ -25,6 +25,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -191,8 +192,5 @@ namespace CalamityMod.Projectiles.Summon } } } - - // The spirit itself should not do direct damage. - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/SandElementalHealer.cs b/Projectiles/Summon/SandElementalHealer.cs index 8ec3c83484..408e4982e2 100644 --- a/Projectiles/Summon/SandElementalHealer.cs +++ b/Projectiles/Summon/SandElementalHealer.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Summon Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.sandBoobWaifu && !modPlayer.allWaifus && !modPlayer.sandBoobWaifuVanity && !modPlayer.allWaifusVanity) + if (!modPlayer.rareSandElemental && !modPlayer.allElementals && !modPlayer.rareSandElementalVanity && !modPlayer.allElementalsVanity) { Projectile.active = false; return; @@ -55,9 +55,9 @@ namespace CalamityMod.Projectiles.Summon { if (player.dead) { - modPlayer.dWaifu = false; + modPlayer.rareSandEleBuff = false; } - if (modPlayer.dWaifu) + if (modPlayer.rareSandEleBuff) { Projectile.timeLeft = 2; } @@ -91,7 +91,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.spriteDirection = -Projectile.direction; } - if (!modPlayer.sandBoobWaifuVanity && !modPlayer.allWaifusVanity) + if (!modPlayer.rareSandElementalVanity && !modPlayer.allElementalsVanity) { float lightScalar = (float)Main.rand.Next(90, 111) * 0.01f; lightScalar *= Main.essScale; @@ -160,7 +160,7 @@ namespace CalamityMod.Projectiles.Summon { Projectile.localAI[0] += 1f; } - if (Projectile.ai[0] == 0f && !modPlayer.sandBoobWaifuVanity && !modPlayer.allWaifusVanity) + if (Projectile.ai[0] == 0f && !modPlayer.rareSandElementalVanity && !modPlayer.allElementalsVanity) { int healProj = ModContent.ProjectileType(); if (Projectile.ai[1] == 0f && Projectile.localAI[0] >= 120f) @@ -189,7 +189,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (modPlayer.sandBoobWaifuVanity || modPlayer.allWaifusVanity) + if (modPlayer.rareSandElementalVanity || modPlayer.allElementalsVanity) { return false; } diff --git a/Projectiles/Summon/SandElementalMinion.cs b/Projectiles/Summon/SandElementalMinion.cs index 59c7f9c2bf..397f3481cd 100644 --- a/Projectiles/Summon/SandElementalMinion.cs +++ b/Projectiles/Summon/SandElementalMinion.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.sandWaifu && !modPlayer.allWaifus && !modPlayer.sandWaifuVanity && !modPlayer.allWaifusVanity) + if (!modPlayer.sandElemental && !modPlayer.allElementals && !modPlayer.sandElementalVanity && !modPlayer.allElementalsVanity) { Projectile.active = false; return; @@ -51,9 +51,9 @@ namespace CalamityMod.Projectiles.Summon { if (player.dead) { - modPlayer.sWaifu = false; + modPlayer.sandEleBuff = false; } - if (modPlayer.sWaifu) + if (modPlayer.sandEleBuff) { Projectile.timeLeft = 2; } @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Summon Main.dust[dust].scale *= 1.15f; } } - bool passive = modPlayer.sandWaifuVanity || modPlayer.allWaifusVanity; + bool passive = modPlayer.sandElementalVanity || modPlayer.allElementalsVanity; if (Math.Abs(Projectile.velocity.X) > 0.2f) { Projectile.spriteDirection = -Projectile.direction; diff --git a/Projectiles/Summon/SandnadoMinion.cs b/Projectiles/Summon/SandnadoMinion.cs index 4fcc69068f..d9f2fb1c4b 100644 --- a/Projectiles/Summon/SandnadoMinion.cs +++ b/Projectiles/Summon/SandnadoMinion.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 6; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -81,12 +82,12 @@ namespace CalamityMod.Projectiles.Summon { if (CheckForSpawning == false) { - int dustAmount = 75; - for (int dustIndex = 0; dustIndex < dustAmount; dustIndex++) + int dustAmount = 25; + for (int d = 0; d < dustAmount; d++) { - float angle = MathHelper.TwoPi / dustAmount * dustIndex; + float angle = MathHelper.TwoPi / dustAmount * d; Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 6.5f); - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 85, velocity); + Dust.NewDustPerfect(Projectile.Center, DustID.UnusedBrown, velocity); } CheckForSpawning = true; } @@ -165,8 +166,6 @@ namespace CalamityMod.Projectiles.Summon TimerForShooting++; } - public override bool? CanDamage() => false; - #endregion } } diff --git a/Projectiles/Summon/SarosAura.cs b/Projectiles/Summon/SarosAura.cs index e626a5ea77..2820b3535f 100644 --- a/Projectiles/Summon/SarosAura.cs +++ b/Projectiles/Summon/SarosAura.cs @@ -1,135 +1,205 @@ -using CalamityMod.Buffs.Summon; +using System.IO; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; -using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; - namespace CalamityMod.Projectiles.Summon { public class SarosAura : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; - public Player Owner => Main.player[Projectile.owner]; - - public CalamityPlayer moddedOwner => Owner.Calamity(); - - public ref float GeneralTimer => ref Projectile.ai[0]; - - public bool CheckForSpawning = false; - - public static readonly SoundStyle SarosDiskThrow = new SoundStyle("CalamityMod/Sounds/Item/SarosDiskThrow", 3) { Volume = 0.4f, PitchVariance = 1 }; - public override void SetStaticDefaults() { - Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } public override void SetDefaults() { - Projectile.minionSlots = 8f; - Projectile.penetrate = -1; - - Projectile.width = Projectile.height = 132; - - Projectile.DamageType = DamageClass.Summon; + Projectile.width = 50; + Projectile.height = 50; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.minionSlots = 1f; + Projectile.timeLeft = 18000; + Projectile.penetrate = -1; Projectile.tileCollide = false; + Projectile.timeLeft *= 5; Projectile.minion = true; + Projectile.DamageType = DamageClass.Summon; } + public int MinionSlotsToAdd + { + get { return (int)Projectile.ai[0]; } + set { Projectile.ai[0] = value; } + } public override void AI() { - NPC potentialTarget = Projectile.Center.MinionHoming(5000f, Owner); + Player player = Main.player[Projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + player.AddBuff(ModContent.BuffType(), 3600); - CheckMinionExistince(); // Ensure that the projectile using this AI is the correct projectile and that the owner has the appropriate buffs. - SpawnEffect(); // Makes a dust spawn effect where the minion spawns. - - // Attack nearby targets. - if (potentialTarget != null && Main.myPlayer == Projectile.owner) - AttackTarget(potentialTarget); - - // Stay near the target and spin around. - Projectile.Center = Owner.Center - Vector2.UnitY * (16f - Owner.gfxOffY); - // The projectile spins right at a constant speed. - Projectile.rotation += MathHelper.ToRadians(1.5f); - - // Emit some light. - Lighting.AddLight(Projectile.Center, Vector3.One * 1.2f); - - // A timer for the AI. - GeneralTimer++; - } - - #region Methods - - public void CheckMinionExistince() - { - Owner.AddBuff(ModContent.BuffType(), 3600); - if (Projectile.type == ModContent.ProjectileType()) + #region Add Minion Slots + if (MinionSlotsToAdd > 0) { - if (Owner.dead) - moddedOwner.saros = false; - if (moddedOwner.saros) - Projectile.timeLeft = 2; - } - } - - public void SpawnEffect() - { - if (CheckForSpawning == false) - { - int dustAmount = 360; - for (int d = 0; d < dustAmount; d++) + float minionSlotsAvaliable = player.maxMinions; + foreach (var item in Main.ActiveProjectiles) { - float angle = MathHelper.TwoPi / dustAmount * d; - Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(20f, 30f); - - Dust spawnDust = Dust.NewDustPerfect(Owner.Center - Vector2.UnitY * 60f, (int)CalamityDusts.ProfanedFire, velocity); - spawnDust.noGravity = true; - spawnDust.color = Color.Lerp(Color.White, Color.Yellow, 0.25f); - spawnDust.scale = velocity.Length() * 0.25f; - spawnDust.velocity *= 0.7f; + if (item.owner == Projectile.owner) + minionSlotsAvaliable -= item.minionSlots; } - } - CheckForSpawning = true; - } - - public void AttackTarget(NPC target) - { - if (GeneralTimer % 50f == 49f) - { - for (int i = -1; i < 2; i++) + while (minionSlotsAvaliable >= 1 && MinionSlotsToAdd > 0) { - float angle = (target.Center - Projectile.Center).ToRotation() + (MathHelper.PiOver2 * i) + Main.rand.NextFloat(MathHelper.PiOver4, -MathHelper.PiOver4); - Vector2 velocity = angle.ToRotationVector2() * 30f; - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - + Projectile.minionSlots++; + minionSlotsAvaliable--; + MinionSlotsToAdd--; + player.channel = false; Projectile.netUpdate = true; } + if (MinionSlotsToAdd > 0) + { + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * (int)Projectile.minionSlots, Projectile.knockBack, Projectile.owner); + } + MinionSlotsToAdd = 0; } + #endregion - if (GeneralTimer % 100f == 99f) + #region Checking alive + bool correctMinion = Projectile.type == ModContent.ProjectileType(); + if (correctMinion) { - float angle = (target.Center - Projectile.Center).ToRotation() + Main.rand.NextFloat(MathHelper.PiOver2, -MathHelper.PiOver2); - Vector2 velocity = angle.ToRotationVector2() * 25f; - SoundEngine.PlaySound(SarosDiskThrow, Projectile.Center); + if (player.dead) + { + modPlayer.sunSpirit = false; + } + if (modPlayer.saros) + { + Projectile.timeLeft = 2; + } + } + #endregion - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage * 2, Projectile.knockBack, Projectile.owner); + #region Positioning + Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -24f); + #endregion - Projectile.netUpdate = true; + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f); + + NPC target = GetTargetInRange(1600); + + if (target is null) + return; + + + if (Projectile.owner == Main.myPlayer) + { + + if (Projectile.ai[1] > 0f) + { + Projectile.ai[1] -= 1f; + } + else + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + { + int damage = (int)(Projectile.damage * (0.8f + Projectile.minionSlots * 0.2f)); + float shootSpeed = 15f; + Vector2 source = Projectile.Center; + for (var i = 0; i < 3; i++) + { + SoundEngine.PlaySound(SarosPossession.FiringSound, Projectile.Center); + var velocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * shootSpeed; + Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center - velocity, velocity, ModContent.ProjectileType(), damage, Projectile.knockBack, Projectile.owner, 120, ai1: (Projectile.minionSlots - 1) / 9f); + beam.DamageType = DamageClass.Summon; + } + Projectile.ai[1] += 60f / (0.8f + Projectile.minionSlots * 0.2f); + } + } + + } + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.minionSlots); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.minionSlots = reader.ReadSingle(); + } + NPC GetTargetInRange(float range) + { + var player = Main.player[Projectile.owner]; + if (player.HasMinionAttackTargetNPC && Main.npc[player.MinionAttackTargetNPC].CanBeChasedBy() && Projectile.IsInRangeOfMeOrMyOwner(Main.npc[player.MinionAttackTargetNPC], range, out var _, out var _, out var _)) + { + return Main.npc[player.MinionAttackTargetNPC]; + } + else + { + NPC gotTarget = null; + float currentDistance = range; + foreach (var npc in Main.ActiveNPCs) + { + var myDistance = npc.Distance(Projectile.Center); + if (npc.CanBeChasedBy() && myDistance < currentDistance) + { + currentDistance = myDistance; + gotTarget = npc; + } + } + return gotTarget; } } public override bool? CanDamage() => false; - #endregion + public static Asset circle; + public override bool PreDraw(ref Color lightColor) + { + //Sigil + var spTex = TextureAssets.Projectile[Type].Value; + Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); + + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //Sunlines + int count = (int)((Projectile.minionSlots - 1) / 3) * 2 + 2; + for (var i = 0; i < count; i++) + { + var comp = (i / (float)count); + var offset = ((Main.mouseTextColor - 190) / 64f) * 8; + if (i % 2 == 0) + offset = 8 - offset; + CalamityUtils.DrawLineBetter(Main.spriteBatch, Projectile.Center + new Vector2(20 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), Projectile.Center + new Vector2(34 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), i % 2 == 3 ? Color.OrangeRed : Color.Gold, 2f); + } + + //Circles + var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/Particles/BloomRingThinLarge").Value; + count = (int)MathHelper.Min((1 + (Projectile.minionSlots - 1) % 3), 10); + for (var i = 0; i < count && i < 5; i++) + { + var comp = (i / (count)); + var offset = ((Main.mouseTextColor - 190) / 64f); + if (i % 2 == 0) + offset = 1 - offset; + Main.EntitySpriteDraw(ciTex, Projectile.Center - Main.screenPosition, null, Color.Lerp(Color.Gold, Color.OrangeRed, i / (4f)), Main.GlobalTimeWrappedHourly, ciTex.Size() * 0.5f, 0.0225f + 0.0025f * offset + 0.005f * i, SpriteEffects.None); + } + + Main.spriteBatch.End(); + } + return false; + } } } diff --git a/Projectiles/Summon/SarosAura.png b/Projectiles/Summon/SarosAura.png index 1706469c4f..8b4f1ddd52 100644 Binary files a/Projectiles/Summon/SarosAura.png and b/Projectiles/Summon/SarosAura.png differ diff --git a/Projectiles/Summon/SarosEclipseBeam.cs b/Projectiles/Summon/SarosEclipseBeam.cs new file mode 100644 index 0000000000..430ead2ec3 --- /dev/null +++ b/Projectiles/Summon/SarosEclipseBeam.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class SarosEclipseBeam : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + Player Owner => Main.player[Projectile.owner]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 24; + Projectile.height = 24; + Projectile.friendly = true; + Projectile.timeLeft = 10; + Projectile.DamageType = DamageClass.Summon; + Projectile.MaxUpdates = 1; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.stopsDealingDamageAfterPenetrateHits = true; + } + + Vector2 SarosPos => Owner.Center + Vector2.UnitY * (Owner.gfxOffY + Owner.gravDir * -24f); + public override void OnSpawn(IEntitySource source) + { + SoundEngine.PlaySound(SarosPossession.SpawnSound with {pitch = -0.5f, MaxInstances = 5, SoundLimitBehavior = SoundLimitBehavior.IgnoreNew}, Owner.Center); + Projectile.rotation = SarosPos.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(); + } + public override void AI() + { + if (Owner.miscCounter % 10 == 0) + SoundEngine.PlaySound(SoundID.DD2_BetsyFlameBreath with {Volume = 0.2f }, Owner.Center); + Projectile.rotation = Projectile.rotation.AngleLerp(SarosPos.DirectionTo(Owner.Calamity().mouseWorld).ToRotation(), 0.1f); + Projectile.Center = SarosPos + Projectile.rotation.ToRotationVector2() * Utils.Remap(Projectile.timeLeft,5,10,1600,0); + if (Projectile.timeLeft == 5 && Owner.channel) + Projectile.timeLeft++; + Owner.Calamity().sarosEclipseBeamUsage += 2; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float _ = 0; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), SarosPos, Projectile.Center, 80, ref _); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SourceDamage *= Utils.Remap(Owner.Calamity().sarosEclipseBeamUsage, 0, 300, 2, 1); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + for (int i = 0; i < 12; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(3f, 5f); + Color dustColor = Color.Lerp(Color.OrangeRed, Color.Gold, Main.rand.NextFloat(0.5f, 1f)); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = true; + } + } + + public override bool PreDraw(ref Color lightColor) => false; + + public float FireWidthFunction(float completion, Vector2 vertexPos) + { + return MathHelper.Min(Utils.Remap(completion, 0, 0.1f, 0, 96), Utils.Remap(completion, 0.9f, 1f, 96, 0)) * Utils.Remap(Projectile.timeLeft, 0, 5, 0, 1) * (0.75f+MathF.Pow(1 -(Owner.Calamity().sarosEclipseBeamUsage / 300f), 3)) * (Projectile.timeLeft > 5 ? 1 - (Projectile.timeLeft - 5) / 5f : 1); + } + + public Color FireColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = Color.Lerp(new Color(238, 226, 153), new Color(255, 191, 73), (MathF.Sin(completion*MathHelper.TwoPi + Main.GlobalTimeWrappedHourly*5)+1)*0.5f); + return mainColor * MathF.Pow(1 - completion, 0.5f); + } + + public float FireCoreWidthFunction(float completion, Vector2 vertexPos) + { + return MathHelper.Min(Utils.Remap(completion, 0, 0.1f, 0, 32), Utils.Remap(completion, 0.9f, 1f, 32, 0)) * Utils.Remap(Projectile.timeLeft, 0, 5, 0, 1) * (0.75f+MathF.Pow(1 - (Owner.Calamity().sarosEclipseBeamUsage / 300f), 3)) * (Projectile.timeLeft > 5 ? 1-(Projectile.timeLeft-5)/5f : 1); + } + + public Color FireCoreColorFunction(float completion, Vector2 vertexPos) + { + return Color.Black * MathF.Pow(1 - completion, 0.5f); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + List posList = []; + //For the prim to render properly I need to divide the distance between the positions into a couple points. Just using start and end doesn't render. + for (var i = 0; i <= 10; i++) + { + posList.Add(Vector2.Lerp(SarosPos, Projectile.Center, i / 10f)); + } + var pos = posList.ToArray(); + + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(pos, new(FireWidthFunction, FireColorFunction, null, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), pos.Length+32); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(pos, new(FireCoreWidthFunction, FireCoreColorFunction, null, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), pos.Length+24); + } + } +} diff --git a/Projectiles/Summon/SarosMicrosun.cs b/Projectiles/Summon/SarosMicrosun.cs deleted file mode 100644 index 4e20199930..0000000000 --- a/Projectiles/Summon/SarosMicrosun.cs +++ /dev/null @@ -1,90 +0,0 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class SarosMicrosun : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public Player Owner => Main.player[Projectile.owner]; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 6; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.MinionShot[Type] = true; - } - - public override void SetDefaults() - { - Projectile.timeLeft = 600; - - Projectile.width = Projectile.height = 62; - - Projectile.DamageType = DamageClass.Summon; - Projectile.netImportant = true; - Projectile.tileCollide = false; - Projectile.friendly = true; - Projectile.ignoreWater = true; - } - - public override void AI() - { - // Tries to detect a target on a certain distance. - NPC target = Projectile.Center.MinionHoming(5000f, Owner); - - DoAnimation(); // Does the animation of the minion. - - // Spins as it was thrown really hard and fast. - Projectile.rotation += MathHelper.ToRadians(20f); - - // If there's a target, go towards the target. - if (target != null) - { - Projectile.velocity = Vector2.Lerp(Projectile.velocity, (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * 35f, 0.1f); - Projectile.netUpdate = true; - } - } - - public void DoAnimation() - { - Projectile.frameCounter++; - Projectile.frame = Projectile.frameCounter / 6 % Main.projFrames[Type]; - } - - public override bool PreDraw(ref Color lightColor) // Makes the afterimages of the disk. - { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Vector2 origin = frame.Size() * 0.5f; - SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - Color afterimageDrawColor = Color.DarkOrange with { A = 25 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length); - Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; - Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, Projectile.rotation, origin, Projectile.scale, direction, 0); - } - return true; - } - - public override void OnKill(int timeLeft) - { - int dustAmount = 180; - for (int d = 0; d < dustAmount; d++) - { - float angle = MathHelper.TwoPi / dustAmount * d; - Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(20f, 30f); - - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.ProfanedFire, velocity); - spawnDust.noGravity = true; - spawnDust.color = Color.Lerp(Color.White, Color.Yellow, 0.25f); - spawnDust.scale = velocity.Length() * 0.25f; - spawnDust.velocity *= 0.5f; - } - } - } -} diff --git a/Projectiles/Summon/SarosSunfire.cs b/Projectiles/Summon/SarosSunfire.cs index d454f593ac..6391317e0e 100644 --- a/Projectiles/Summon/SarosSunfire.cs +++ b/Projectiles/Summon/SarosSunfire.cs @@ -1,70 +1,189 @@ -using CalamityMod.Dusts; +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; - namespace CalamityMod.Projectiles.Summon { - public class SarosSunfire : ModProjectile, ILocalizedModType + public class SarosSunfire : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { public new string LocalizationCategory => "Projectiles.Summon"; - public Player Owner => Main.player[Projectile.owner]; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 2; ProjectileID.Sets.MinionShot[Type] = true; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; } public override void SetDefaults() { - Projectile.timeLeft = 600; - Projectile.light = 1f; - - Projectile.width = Projectile.height = 10; - - Projectile.DamageType = DamageClass.Summon; - Projectile.netImportant = true; + Projectile.width = 24; + Projectile.height = 24; Projectile.friendly = true; + Projectile.DamageType = DamageClass.Summon; + Projectile.MaxUpdates = 3; Projectile.tileCollide = false; + Projectile.penetrate = 3; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 24; + Projectile.stopsDealingDamageAfterPenetrateHits = true; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; } + public override void OnSpawn(IEntitySource source) + { + } + + NPC target = null; public override void AI() { - NPC target = Projectile.Center.MinionHoming(5000f, Owner); // Detects a target. - - // Makes dust because the projectile's sprite is invisible. - - for (int moreDust = 0; moreDust < 4; moreDust++) + if (Projectile.ai[0] > 1) { - Dust bootlegSprite = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.ProfanedFire); - bootlegSprite.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi); - bootlegSprite.scale = bootlegSprite.velocity.Length() * 0.25f; - bootlegSprite.color = Color.Lerp(Color.White, Color.DarkOrange, 0.25f); - bootlegSprite.noGravity = true; + Projectile.ai[0]--; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; + + } - // Move towards the target. - if (target != null) + if (target != null && Projectile.localNPCImmunity[target.whoAmI] <= 0 && target.active && !target.dontTakeDamage) { - Projectile.velocity = Vector2.Lerp(Projectile.velocity, (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * 25f, 0.1f); - Projectile.netUpdate = true; + Projectile.Calamity().HomingTarget = target.whoAmI; + Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(Projectile.DirectionTo(target.Center).ToRotation(), 0.5f * (1 - Projectile.ai[0] / 120f)).ToRotationVector2() * Projectile.velocity.Length(); + } + else + { + target = GetTargetInRange(2000); + } + + if (Projectile.damage <= 0) + { + Projectile.ai[0] = 0; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 4; + Projectile.timeLeft = (int)MathHelper.Min(8, Projectile.timeLeft); + } + } + NPC GetTargetInRange(float range) + { + var player = Main.player[Projectile.owner]; + if (player.HasMinionAttackTargetNPC && Main.npc[player.MinionAttackTargetNPC].CanBeChasedBy() && Projectile.localNPCImmunity[player.MinionAttackTargetNPC] <= 0 && Projectile.IsInRangeOfMeOrMyOwner(Main.npc[player.MinionAttackTargetNPC], range, out var _, out var _, out var _)) + { + return Main.npc[player.MinionAttackTargetNPC]; + } + else + { + NPC gotTarget = null; + float currentDistance = range; + foreach (var npc in Main.ActiveNPCs) + { + if (Projectile.localNPCImmunity[npc.whoAmI] > 0) + continue; + var myDistance = npc.Distance(Projectile.Center); + + if (npc.CanBeChasedBy() && myDistance < currentDistance) + { + currentDistance = myDistance; + gotTarget = npc; + } + } + return gotTarget; } } - public override void OnKill(int timeLeft) // Makes a dust explosion effect on death. + public override bool? CanHitNPC(NPC target) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - for (int i = 0; i < 60; i++) + if (target != this.target) + return false; + return null; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Projectile.damage = (int)(Projectile.damage * 0.75f); + for (int i = 0; i < 12; i++) { - Dust dustExplosion = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.ProfanedFire); - dustExplosion.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(2f, 6f); - dustExplosion.noGravity = true; + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(3f, 5f); + Color dustColor = Color.Lerp(Color.OrangeRed, Color.Gold, Main.rand.NextFloat(0.5f, 1f)); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = true; } } + + public override bool? CanDamage() + { + return Projectile.ai[0] <= 90; + } + + public override bool PreDraw(ref Color lightColor) => false; + + //Prim trail based off Fryzahh's work on Faith Incinerator + public float FireWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = 48f * Projectile.scale; + float curveRatio = 0.2f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = new Color(238, 226, 153); + return Color.Lerp(mainColor, Color.Transparent, completion); + } + + public float FireCoreWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = Projectile.scale * 32; + float curveRatio = 0.25f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireCoreColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = new Color(255, 191, 73); + return mainColor; + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + //Flame body + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); + //Flame core + Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), fireCoreLength.Length + 24); + } } } diff --git a/Projectiles/Summon/SeashineSwordProj.cs b/Projectiles/Summon/SeashineSwordProj.cs index a138121bc1..d8e21def52 100644 --- a/Projectiles/Summon/SeashineSwordProj.cs +++ b/Projectiles/Summon/SeashineSwordProj.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Summon public Vector2 tipPosition; public Vector2 savedTipPos = Vector2.Zero; - public bool attackMode => Owner.HeldItem.type == ModContent.ItemType(); // If not holding the weapon, the blades won't charge (no whips for you) + public bool attackMode => Owner.HeldItem.type == ModContent.ItemType(); // If not holding the weapon, the blades won't charge (no whips for you) // Values stored to create blade swing arc public Vector2 startPos; @@ -255,7 +255,7 @@ namespace CalamityMod.Projectiles.Summon } public override bool PreDraw(ref Color lightColor) { - Texture2D tex = ModContent.Request("CalamityMod/Items/Weapons/Summon/SeashineSword").Value; + Texture2D tex = ModContent.Request("CalamityMod/Items/Weapons/Summon/SeashineHilt").Value; Texture2D tex2 = ModContent.Request("CalamityMod/Particles/GlowBlade").Value; Texture2D tex3 = ModContent.Request("CalamityMod/Particles/FullStar").Value; @@ -316,6 +316,6 @@ namespace CalamityMod.Projectiles.Summon float _ = float.NaN; return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, tipPosition, 30 * Projectile.scale, ref _); } - public override bool? CanDamage() => (isAttacking && attackTimer > bladeValue && Projectile.ai[0] != 0) ? null : false; + public override bool? CanDamage() => isAttacking && attackTimer > bladeValue && Projectile.ai[0] != 0; } } diff --git a/Projectiles/Summon/SeekerSummonProj.cs b/Projectiles/Summon/SeekerSummonProj.cs index 19acb71cf0..060a43916a 100644 --- a/Projectiles/Summon/SeekerSummonProj.cs +++ b/Projectiles/Summon/SeekerSummonProj.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 5; + Main.projPet[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; } @@ -65,7 +66,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 40; i++) { - Dust brimstoneFire = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50f, 50f), 219); + Dust brimstoneFire = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(50f, 50f), DustID.Fireworks); brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 5f); brimstoneFire.scale = 1f + brimstoneFire.velocity.Length() * 0.1f; brimstoneFire.color = Color.Lerp(Color.White, Color.OrangeRed, Main.rand.NextFloat()); @@ -159,5 +160,7 @@ namespace CalamityMod.Projectiles.Summon else if (Projectile.velocity.Length() < 28f) Projectile.velocity = Projectile.SafeDirectionTo(target.Center) * 29f; } + + public override bool MinionContactDamage() => true; } } diff --git a/Projectiles/Summon/SepulcherMinion.cs b/Projectiles/Summon/SepulcherMinion.cs index 61ce1510ae..88a2cc9289 100644 --- a/Projectiles/Summon/SepulcherMinion.cs +++ b/Projectiles/Summon/SepulcherMinion.cs @@ -693,6 +693,8 @@ namespace CalamityMod.Projectiles.Summon #endregion + public override bool MinionContactDamage() => true; + public override bool? CanHitNPC(NPC target) { if (target.type == ModContent.NPCType()) diff --git a/Projectiles/Summon/Shellfish.cs b/Projectiles/Summon/Shellfish.cs index c49d18530f..be18d29396 100644 --- a/Projectiles/Summon/Shellfish.cs +++ b/Projectiles/Summon/Shellfish.cs @@ -424,7 +424,7 @@ namespace CalamityMod.Projectiles.Summon return null; } - public override bool? CanDamage() => Projectile.ai[0] == 0f; + public override bool MinionContactDamage() => Projectile.ai[0] == 0f; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Projectiles/Summon/SilvaCrystal.cs b/Projectiles/Summon/SilvaCrystal.cs index 3cbe3f521a..9b76c93281 100644 --- a/Projectiles/Summon/SilvaCrystal.cs +++ b/Projectiles/Summon/SilvaCrystal.cs @@ -3,6 +3,7 @@ using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -38,6 +39,7 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); + bool isMinion = Projectile.type == ModContent.ProjectileType(); if (!modPlayer.silvaSummon) { @@ -47,14 +49,11 @@ namespace CalamityMod.Projectiles.Summon if (isMinion) { if (player.dead) - { modPlayer.sCrystal = false; - } if (modPlayer.sCrystal) - { Projectile.timeLeft = 2; - } } + Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); if (player.gravDir == -1f) { @@ -65,36 +64,27 @@ namespace CalamityMod.Projectiles.Summon { Projectile.rotation = 0f; } - Projectile.position.X = (int)Projectile.position.X; - Projectile.position.Y = (int)Projectile.position.Y; + Projectile.velocity = Vector2.Zero; Projectile.alpha -= 5; if (Projectile.alpha < 0) - { Projectile.alpha = 0; - } if (Projectile.direction == 0) - { Projectile.direction = Main.player[Projectile.owner].direction; - } + if (Projectile.alpha == 0 && Main.rand.NextBool(15)) { - Dust silvaDust = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, DustID.RainbowMk2, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f)]; - silvaDust.velocity.X = 0f; + Vector2 dustSpawn = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(26f, 30f); + Dust silvaDust = Dust.NewDustPerfect(dustSpawn, DustID.RainbowMk2, Vector2.UnitY * Main.rand.NextFloat(-2f, 2f), 100, new Color(Main.DiscoR, 203, 103), 0.5f); silvaDust.noGravity = true; silvaDust.fadeIn = 1f; - silvaDust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (4f * Main.rand.NextFloat() + 26f); - silvaDust.scale = 0.5f; } + Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= 60f) - { Projectile.localAI[0] = 0f; - } if (Projectile.ai[0] < 0f) - { Projectile.ai[0] += 1f; - } if (Projectile.ai[0] == 0f) { int targetID = -1; @@ -116,7 +106,7 @@ namespace CalamityMod.Projectiles.Summon { foreach (NPC target in Main.ActiveNPCs) { - if (target.CanBeChasedBy(Projectile, false)) + if (target.CanBeChasedBy(Projectile)) { float targetDistance = Projectile.Distance(target.Center); if (targetDistance < attackRange && Collision.CanHitLine(Projectile.Center, 0, 0, target.Center, 0, 0)) @@ -130,7 +120,7 @@ namespace CalamityMod.Projectiles.Summon if (targetID != -1) { Projectile.ai[0] = 1f; - Projectile.ai[1] = (float)targetID; + Projectile.ai[1] = targetID; Projectile.netUpdate = true; return; } @@ -138,7 +128,7 @@ namespace CalamityMod.Projectiles.Summon if (Projectile.ai[0] > 0f) { int npcTrack = (int)Projectile.ai[1]; - if (!Main.npc[npcTrack].CanBeChasedBy(Projectile, false)) + if (!Main.npc[npcTrack].CanBeChasedBy(Projectile)) { Projectile.ai[0] = 0f; Projectile.ai[1] = 0f; @@ -154,49 +144,34 @@ namespace CalamityMod.Projectiles.Summon Projectile.netUpdate = true; if (Projectile.owner == Main.myPlayer) { - Vector2 attackPos = Main.npc[npcTrack].position + Main.npc[npcTrack].Size * Utils.RandomVector2(Main.rand, 0f, 1f) - Projectile.Center; - int attackAmt; - for (int j = 0; j < 3; j = attackAmt + 1) + Vector2 attackPos = Main.npc[npcTrack].Center - Projectile.Center; + for (int j = 0; j < 3; j++) { - Vector2 finalAttackPos = Projectile.Center + attackPos; - if (j > 0) - { - finalAttackPos = Projectile.Center + attackPos.RotatedByRandom(0.78539818525314331) * (Main.rand.NextFloat() * 0.5f + 0.75f); - } - float x4 = Main.rgbToHsl(new Color(Main.DiscoR, 203, 103)).X; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), finalAttackPos, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, x4, (float)Projectile.whoAmI); - attackAmt = j; + Vector2 finalAttackPos = Projectile.Center + attackPos.RotatedByRandom(j > 0 ? MathHelper.Pi * 0.125f : 0f) * (j > 0 ? Main.rand.NextFloat(0.9f, 1.1f) : 1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), finalAttackPos, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, Main.rgbToHsl(new Color(Main.DiscoR, 203, 103)).X, Projectile.whoAmI); } return; } } } } + public override bool? CanDamage() => false; - public override Color? GetAlpha(Color lightColor) - { - return new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 127 - Projectile.alpha / 2); - } - + public override Color? GetAlpha(Color lightColor) => new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 127 - Projectile.alpha / 2); public override bool PreDraw(ref Color lightColor) { - Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 projPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Texture2D texture2D34 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle rectangular = texture2D34.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Color colorAlpha = Projectile.GetAlpha(colorArea); - Vector2 halfRectangle = rectangular.Size() / 2f; - float scaleFactor = (float)Math.Cos((double)(6.28318548f * (Projectile.localAI[0] / 60f))) + 3f + 3f; - for (float k = 0f; k < 4f; k += 1f) + Texture2D tex = TextureAssets.Projectile[Type].Value; + Vector2 projPos = Projectile.Center + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color colorArea = Lighting.GetColor((int)(Projectile.position.X + Projectile.width * 0.5) / 16, (int)((Projectile.position.Y + Projectile.height * 0.5) / 16.0)); + Color colorAlpha = Projectile.GetAlpha(colorArea) * 0.2f; + Vector2 origin = tex.Size() / 2f; + float scaleFactor = MathF.Cos(MathHelper.TwoPi * (Projectile.localAI[0] / 60f)) + 6f; + + for (int k = 0; k < 4; k++) { - SpriteBatch spritebatch = Main.spriteBatch; - double arg_F8BE_1 = (double)(k * MathHelper.PiOver2); - Vector2 center = default; - Main.EntitySpriteDraw(texture2D34, projPos + Vector2.UnitY.RotatedBy(arg_F8BE_1, center) * scaleFactor, new Microsoft.Xna.Framework.Rectangle?(rectangular), colorAlpha * 0.2f, Projectile.rotation, halfRectangle, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(tex, projPos + Vector2.UnitY.RotatedBy(k * MathHelper.PiOver2) * scaleFactor, null, colorAlpha, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); } return false; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/SilvaCrystalExplosion.cs b/Projectiles/Summon/SilvaCrystalExplosion.cs index 70fcf7d03b..b118833432 100644 --- a/Projectiles/Summon/SilvaCrystalExplosion.cs +++ b/Projectiles/Summon/SilvaCrystalExplosion.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -11,223 +12,162 @@ namespace CalamityMod.Projectiles.Summon public new string LocalizationCategory => "Projectiles.Summon"; public override string Texture => "CalamityMod/Projectiles/StarProj"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionShot[Type] = true; - } - + public ref float OwnerCheck => ref Projectile.ai[1]; + public override void SetStaticDefaults() => ProjectileID.Sets.MinionShot[Type] = true; public override void SetDefaults() { Projectile.width = Projectile.height = 14; + Projectile.DamageType = DamageClass.Summon; Projectile.alpha = 255; Projectile.tileCollide = false; Projectile.ignoreWater = true; + Projectile.penetrate = -1; Projectile.timeLeft = 900; - Projectile.DamageType = DamageClass.Summon; } public override void AI() { - Color newColor2 = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f); - int activeTimer = (int)Projectile.ai[1]; - if (activeTimer < 0 || activeTimer >= 1000 || (!Main.projectile[activeTimer].active && Main.projectile[activeTimer].type != ModContent.ProjectileType())) + Color colorToUse = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f); + if (OwnerCheck < 0 || OwnerCheck >= 1000 || (!Main.projectile[(int)OwnerCheck].active && Main.projectile[(int)OwnerCheck].type != ModContent.ProjectileType())) { Projectile.ai[1] = -1f; } else { - DelegateMethods.v3_1 = newColor2.ToVector3() * 0.5f; - Utils.PlotTileLine(Projectile.Center, Main.projectile[activeTimer].Center, 8f, DelegateMethods.CastLight); + DelegateMethods.v3_1 = colorToUse.ToVector3() * 0.5f; + Utils.PlotTileLine(Projectile.Center, Main.projectile[(int)OwnerCheck].Center, 8f, DelegateMethods.CastLight); } + if (Projectile.localAI[0] == 0f) { - Projectile.localAI[0] = Main.rand.NextFloat() * 0.8f + 0.8f; - Projectile.direction = (Main.rand.Next(2) > 0) ? 1 : -1; + Projectile.localAI[0] = Main.rand.NextFloat(0.8f) + 0.8f; + Projectile.direction = Main.rand.NextBool() ? 1 : -1; } - Projectile.rotation = Projectile.localAI[1] / 20f * 6.28318548f * (float)Projectile.direction; + Projectile.rotation = Projectile.localAI[1] / 20f * MathHelper.TwoPi * Projectile.direction; if (Projectile.alpha > 0) { - Projectile.alpha -= 8; - } - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; + Projectile.alpha -= 16; + if (Projectile.alpha < 0) + Projectile.alpha = 0; } if (Projectile.alpha == 0) - { - Lighting.AddLight(Projectile.Center, newColor2.ToVector3() * 0.5f); - } - int dustCount; - for (int i = 0; i < 2; i = dustCount + 1) + Lighting.AddLight(Projectile.Center, colorToUse.ToVector3() * 0.5f); + + for (int i = 0; i < 2; i++) { if (Main.rand.NextBool(10)) { - Vector2 silvaDustVel = Vector2.UnitY.RotatedBy((double)((float)i * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust silvaDust = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 225, newColor2, 1.5f)]; + Vector2 silvaDustVel = Vector2.UnitY.RotatedBy(i * MathHelper.Pi + Projectile.rotation) * 2.5f; + Dust silvaDust = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2, silvaDustVel, 225, colorToUse, Projectile.Opacity * Projectile.localAI[0]); silvaDust.noGravity = true; silvaDust.noLight = true; - silvaDust.scale = Projectile.Opacity * Projectile.localAI[0]; - silvaDust.position = Projectile.Center; - silvaDust.velocity = silvaDustVel * 2.5f; } - dustCount = i; - } - for (int j = 0; j < 2; j = dustCount + 1) - { if (Main.rand.NextBool(10)) { - Vector2 silvaDustVel2 = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default); - Dust silvaDust2 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 225, newColor2, 1.5f)]; + Vector2 silvaDustVel2 = Vector2.UnitY.RotatedBy(i * MathHelper.Pi) * 2.5f; + Dust silvaDust2 = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2, silvaDustVel2, 225, colorToUse, Projectile.Opacity * Projectile.localAI[0]); silvaDust2.noGravity = true; silvaDust2.noLight = true; - silvaDust2.scale = Projectile.Opacity * Projectile.localAI[0]; - silvaDust2.position = Projectile.Center; - silvaDust2.velocity = silvaDustVel2 * 2.5f; } - dustCount = j; } if (Main.rand.NextBool(10)) { - float dustVelMod = 1f + Main.rand.NextFloat() * 2f; - float fadeIn = 1f + Main.rand.NextFloat(); - float dustScale = 1f + Main.rand.NextFloat(); - Vector2 randVector = Utils.RandomVector2(Main.rand, -1f, 1f); - if (randVector != Vector2.Zero) - { - randVector.Normalize(); - } - randVector *= 20f + Main.rand.NextFloat() * 100f; + float dustVelMod = Main.rand.NextFloat(1f, 3f); + float fadeIn = Main.rand.NextFloat(1f, 2f); + float dustScale = Main.rand.NextFloat(1f, 2f); + Vector2 randVector = Main.rand.NextVector2Circular(1f, 1f).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(20, 120f); + Vector2 dustPos = Projectile.Center + randVector; Point dustCoords = dustPos.ToTileCoordinates(); - bool shouldSpawnDust = true; - if (!WorldGen.InWorld(dustCoords.X, dustCoords.Y, 0)) + if (WorldGen.InWorld(dustCoords.X, dustCoords.Y) && !WorldGen.SolidTile(dustCoords.X, dustCoords.Y)) { - shouldSpawnDust = false; - } - if (shouldSpawnDust && WorldGen.SolidTile(dustCoords.X, dustCoords.Y)) - { - shouldSpawnDust = false; - } - if (shouldSpawnDust) - { - Dust rainbowDust = Main.dust[Dust.NewDust(dustPos, 0, 0, DustID.RainbowMk2, 0f, 0f, 127, newColor2, 1f)]; + Dust rainbowDust = Dust.NewDustPerfect(dustPos, DustID.RainbowMk2, -Vector2.UnitY * Main.rand.NextFloat(1.6f, 7.5f), 127, colorToUse, dustScale); rainbowDust.noGravity = true; - rainbowDust.position = dustPos; - rainbowDust.velocity = -Vector2.UnitY * dustVelMod * (Main.rand.NextFloat() * 0.9f + 1.6f); rainbowDust.fadeIn = fadeIn; - rainbowDust.scale = dustScale; rainbowDust.noLight = true; + Dust rainbowDust2 = Dust.CloneDust(rainbowDust); - Dust dust = rainbowDust2; - dust.scale *= 0.65f; - dust = rainbowDust2; - dust.fadeIn *= 0.65f; + rainbowDust2.scale *= 0.65f; + rainbowDust2.fadeIn *= 0.65f; rainbowDust2.color = new Color(255, 255, 255, 255); } } Projectile.scale = Projectile.Opacity / 2f * Projectile.localAI[0]; Projectile.velocity = Vector2.Zero; - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] >= 30f) - { - Projectile.Kill(); - } - } - public override bool PreDraw(ref Color lightColor) - { - Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 projPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Texture2D texture2D34 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle rectangular = texture2D34.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Color colorAlpha = Projectile.GetAlpha(colorArea); - Vector2 halfRectangle = rectangular.Size() / 2f; - Color projColor = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, Projectile.rotation, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, 0f, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); - if (Projectile.ai[1] != -1f && Projectile.Opacity > 0.3f) - { - Vector2 projDirection = Main.projectile[(int)Projectile.ai[1]].Center - Projectile.Center; - Vector2 projDistance = new Vector2(1f, projDirection.Length() / (float)texture2D34.Height); - float drawRotation = projDirection.ToRotation() + 1.57079637f; - float colorClamp = MathHelper.Distance(15f, Projectile.localAI[1]) / 20f; - colorClamp = MathHelper.Clamp(colorClamp, 0f, 1f); - if (colorClamp > 0f) - { - Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor * colorClamp, drawRotation, halfRectangle, projDistance, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), colorAlpha * colorClamp, drawRotation, halfRectangle, projDistance / 2f, SpriteEffects.None, 0); - } - } - return false; + Projectile.localAI[1] += 1f; + if (Projectile.localAI[1] >= 15f) + Projectile.Kill(); } public override void OnKill(int timeLeft) { - Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(3.1415927410125732); - float rando = (float)Main.rand.Next(7, 13); - Vector2 dustVel = new Vector2(2.1f, 2f); + Vector2 spinningpoint = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * 3f; + int rando = Main.rand.Next(7, 12+1); + Vector2 dustVel = new Vector2(2.1f, 2f) * Main.rand.NextFloat(0.8f, 1.2f); Color newColor = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f); newColor.A = 255; - float dustCount; - for (float i = 0f; i < rando; i = dustCount + 1f) + + for (int i = 0; i < rando; i++) { - int dustID = Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 0, newColor, 1f); - Main.dust[dustID].position = Projectile.Center; - Main.dust[dustID].velocity = spinningpoint.RotatedBy((double)(6.28318548f * i / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); - Main.dust[dustID].noGravity = true; - Main.dust[dustID].scale = 2f; - Main.dust[dustID].fadeIn = Main.rand.NextFloat() * 2f; + Dust dustID = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2, spinningpoint.RotatedBy(MathHelper.TwoPi * i / rando) * dustVel, 0, newColor, 2f); + dustID.noGravity = true; + dustID.fadeIn = Main.rand.NextFloat() * 2f; + Dust dustCloning = Dust.CloneDust(dustID); - Dust dust = dustCloning; - dust.scale /= 2f; - dust = dustCloning; - dust.fadeIn /= 2f; - dustCloning.color = new Color(255, 255, 255, 255); - dustCount = i; + dustCloning.scale /= 2f; + dustCloning.fadeIn /= 2f; + dustCloning.color = Color.White; } - for (float j = 0f; j < rando; j = dustCount + 1f) + for (int j = 0; j < rando; j++) { - int dustID = Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 0, newColor, 1f); - Main.dust[dustID].position = Projectile.Center; - Main.dust[dustID].velocity = spinningpoint.RotatedBy((double)(6.28318548f * j / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); - Dust dust = Main.dust[dustID]; - dust.velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[dustID].noGravity = true; - Main.dust[dustID].scale = Main.rand.NextFloat() * 1f; - Main.dust[dustID].fadeIn = Main.rand.NextFloat() * 2f; + Dust dustID = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2, spinningpoint.RotatedBy(MathHelper.TwoPi * j / rando) * dustVel * Main.rand.NextFloat(0.8f), 0, newColor, Main.rand.NextFloat()); + dustID.noGravity = true; + dustID.fadeIn = Main.rand.NextFloat() * 2f; + Dust dustCloning2 = Dust.CloneDust(dustID); - dust = dustCloning2; - dust.scale /= 2f; - dust = dustCloning2; - dust.fadeIn /= 2f; - dustCloning2.color = new Color(255, 255, 255, 255); - dustCount = j; + dustCloning2.scale /= 2f; + dustCloning2.fadeIn /= 2f; + dustCloning2.color = Color.White; } if (Main.myPlayer == Projectile.owner) { Projectile.friendly = true; - int width = Projectile.width; - int height2 = Projectile.height; - int penetrateClone = Projectile.penetrate; - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 60; - Projectile.Center = Projectile.position; - Projectile.penetrate = -1; - Projectile.maxPenetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; + Projectile.ExpandHitboxBy(60); Projectile.Damage(); - Projectile.penetrate = penetrateClone; - Projectile.position = Projectile.Center; - Projectile.width = width; - Projectile.height = height2; - Projectile.Center = Projectile.position; } } - public override Color? GetAlpha(Color lightColor) + public override Color? GetAlpha(Color lightColor) => new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 0); + public override bool PreDraw(ref Color lightColor) { - return new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 0); + Texture2D tex = TextureAssets.Projectile[Type].Value; + Vector2 projPos = Projectile.Center + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color projColor = Main.hslToRgb(Projectile.ai[0], 1f, 0.5f).MultiplyRGBA(new Color(255, 255, 255, 0)); + Vector2 origin = tex.Size() / 2f; + SpriteEffects sp = SpriteEffects.None; + + Main.EntitySpriteDraw(tex, projPos, null, projColor, Projectile.rotation, origin, Projectile.scale * 2f, sp); + Main.EntitySpriteDraw(tex, projPos, null, projColor, 0f, origin, Projectile.scale * 2f, sp); + + if (OwnerCheck != -1f && Projectile.Opacity > 0.3f) + { + Color colorArea = Lighting.GetColor((int)(Projectile.position.X + Projectile.width * 0.5) / 16, (int)((Projectile.position.Y + Projectile.height * 0.5) / 16.0)); + Color colorAlpha = Projectile.GetAlpha(colorArea); + + Vector2 projDirection = Main.projectile[(int)OwnerCheck].Center - Projectile.Center; + Vector2 projDistance = new Vector2(1f, projDirection.Length() / (float)tex.Height); + float drawRotation = projDirection.ToRotation() + MathHelper.PiOver2; + float colorClamp = MathHelper.Clamp(MathHelper.Distance(15f, Projectile.localAI[1]) / 20f, 0f, 1f); + if (colorClamp > 0f) + { + Main.EntitySpriteDraw(tex, projPos + projDirection / 2f, null, projColor * colorClamp, drawRotation, origin, projDistance, sp); + Main.EntitySpriteDraw(tex, projPos + projDirection / 2f, null, colorAlpha * colorClamp, drawRotation, origin, projDistance / 2f, sp); + } + } + return false; } } } diff --git a/Projectiles/Summon/SiriusBeam.cs b/Projectiles/Summon/SiriusBeam.cs index 8f4c544141..43f2242b2d 100644 --- a/Projectiles/Summon/SiriusBeam.cs +++ b/Projectiles/Summon/SiriusBeam.cs @@ -1,9 +1,18 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; - namespace CalamityMod.Projectiles.Summon { public class SiriusBeam : ModProjectile, ILocalizedModType @@ -13,45 +22,144 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; ProjectileID.Sets.MinionShot[Type] = true; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; } public override void SetDefaults() { - Projectile.width = Projectile.height = 4; - - Projectile.penetrate = -1; - Projectile.extraUpdates = 220; // Random number to make it go fast. - Projectile.localNPCHitCooldown = 110; // Random number so it doesn't multi-hit. - Projectile.timeLeft = 1000; // Random number so it doesn't die too fast. - + Projectile.width = 24; + Projectile.height = 24; Projectile.friendly = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.tileCollide = false; + Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Summon; + Projectile.MaxUpdates = 3; + Projectile.stopsDealingDamageAfterPenetrateHits = true; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 30; + Projectile.penetrate = 2; + } + + public override void OnSpawn(IEntitySource source) + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; } public override void AI() { - for (int d = 0; d < 4; d++) + NPC target = Projectile.Center.MinionHoming(5000f, Main.player[Projectile.owner]); + // Move towards the target. + if (target != null && Projectile.localNPCImmunity[target.whoAmI] <= 0) { - Vector2 projPos = Projectile.position; - projPos -= Projectile.velocity * (d * 0.25f); - Projectile.alpha = 255; - int trailDust = Dust.NewDust(projPos, 1, 1, DustID.PurificationPowder, 0f, 0f, 0, default, 1f); - Main.dust[trailDust].position = projPos; - Main.dust[trailDust].scale = Main.rand.Next(70, 110) * 0.013f; - Main.dust[trailDust].velocity *= 0.2f; - Main.dust[trailDust].noGravity = true; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * (Projectile.timeLeft < 300 ? 24f : 10f), 0.05f); + Projectile.netUpdate = true; + Projectile.Calamity().HomingTarget = target.whoAmI; } + Projectile.rotation = Projectile.velocity.ToRotation(); + + if (Projectile.damage <= 0) + { + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 4; + Projectile.timeLeft = (int)MathHelper.Min(8,Projectile.timeLeft); + } + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); - float x4 = Main.rgbToHsl(new Color(103, 203, Main.DiscoB)).X; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, x4, Projectile.whoAmI); + for (int i = 0; i < 12; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(3f, 5f); + Color dustColor = Color.Lerp(Color.Yellow, Color.Gold, Main.rand.NextFloat(0.5f, 1f)); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.End(out var ss); + + var device = Main.instance.GraphicsDevice; + using var lease = RenderTargetPool.Shared.Rent( + device, + Main.screenWidth / 2, + Main.screenHeight / 2, + RenderTargetDescriptor.Default + ); + + using (lease.Scope(clearColor: Color.Transparent)) + { + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), Projectile.oldPos.Length + 32); + + Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), fireCoreLength.Length + 24); + } + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); + Main.spriteBatch.End(); + + Main.spriteBatch.Begin(ss); + + return false; + } + + public float FireWidthFunction(float completion, Vector2 pos) + { + float width; + float maxBodyWidth = 38f * Projectile.scale; + float curveRatio = 0.2f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + // Crop the tip of the trail into a conic shape. + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return (width + additionalPulseWidth ) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type] ; + } + + public Color FireColorFunction(float completion, Vector2 pos) + { + Color mainColor = Color.DarkSlateBlue * 1.3f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; + } + + public float FireCoreWidthFunction(float completion, Vector2 pos) + { + float width; + float maxBodyWidth = Projectile.scale * 16; + float curveRatio = 0.25f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireCoreColorFunction(float completion, Vector2 pos) + { + Color mainColor = Color.SkyBlue; + Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); + return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity; } } } diff --git a/Projectiles/Summon/SiriusExplosion.cs b/Projectiles/Summon/SiriusExplosion.cs deleted file mode 100644 index 2dc85a8276..0000000000 --- a/Projectiles/Summon/SiriusExplosion.cs +++ /dev/null @@ -1,236 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class SiriusExplosion : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override string Texture => "CalamityMod/Projectiles/StarProj"; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionShot[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 14; - Projectile.alpha = 255; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.timeLeft = 900; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - Color newColor2 = Main.hslToRgb(0.5f, 1f, Projectile.ai[0]); - int activeTimer = (int)Projectile.ai[1]; - if (activeTimer < 0 || activeTimer >= 1000 || (!Main.projectile[activeTimer].active && Main.projectile[activeTimer].type != ModContent.ProjectileType())) - { - Projectile.ai[1] = -1f; - } - else - { - DelegateMethods.v3_1 = newColor2.ToVector3() * 0.5f; - Utils.PlotTileLine(Projectile.Center, Main.projectile[activeTimer].Center, 8f, DelegateMethods.CastLight); - } - if (Projectile.localAI[0] == 0f) - { - Projectile.localAI[0] = Main.rand.NextFloat() * 0.8f + 0.8f; - Projectile.direction = (Main.rand.Next(2) > 0) ? 1 : -1; - } - Projectile.rotation = Projectile.localAI[1] / 40f * 6.28318548f * (float)Projectile.direction; - if (Projectile.alpha > 0) - { - Projectile.alpha -= 8; - } - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } - if (Projectile.alpha == 0) - { - Lighting.AddLight(Projectile.Center, newColor2.ToVector3() * 0.5f); - } - int dustCount; - for (int i = 0; i < 2; i = dustCount + 1) - { - if (Main.rand.NextBool(10)) - { - Vector2 siriusDustVel = Vector2.UnitY.RotatedBy((double)((float)i * 3.14159274f), default).RotatedBy((double)Projectile.rotation, default); - Dust siriusDust = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 225, newColor2, 1.5f)]; - siriusDust.noGravity = true; - siriusDust.noLight = true; - siriusDust.scale = Projectile.Opacity * Projectile.localAI[0]; - siriusDust.position = Projectile.Center; - siriusDust.velocity = siriusDustVel * 2.5f; - } - dustCount = i; - } - for (int j = 0; j < 2; j = dustCount + 1) - { - if (Main.rand.NextBool(10)) - { - Vector2 siriusDustVel2 = Vector2.UnitY.RotatedBy((double)((float)j * 3.14159274f), default); - Dust siriusDust2 = Main.dust[Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 225, newColor2, 1.5f)]; - siriusDust2.noGravity = true; - siriusDust2.noLight = true; - siriusDust2.scale = Projectile.Opacity * Projectile.localAI[0]; - siriusDust2.position = Projectile.Center; - siriusDust2.velocity = siriusDustVel2 * 2.5f; - } - dustCount = j; - } - if (Main.rand.NextBool(10)) - { - float dustVelMod = 1f + Main.rand.NextFloat() * 2f; - float fadeIn = 1f + Main.rand.NextFloat(); - float dustScale = 1f + Main.rand.NextFloat(); - Vector2 randVector = Utils.RandomVector2(Main.rand, -1f, 1f); - if (randVector != Vector2.Zero) - { - randVector.Normalize(); - } - randVector *= 20f + Main.rand.NextFloat() * 100f; - Vector2 dustPos = Projectile.Center + randVector; - Point dustCoords = dustPos.ToTileCoordinates(); - bool shouldSpawnDust = true; - if (!WorldGen.InWorld(dustCoords.X, dustCoords.Y, 0)) - { - shouldSpawnDust = false; - } - if (shouldSpawnDust && WorldGen.SolidTile(dustCoords.X, dustCoords.Y)) - { - shouldSpawnDust = false; - } - if (shouldSpawnDust) - { - Dust starDust = Main.dust[Dust.NewDust(dustPos, 0, 0, DustID.RainbowMk2, 0f, 0f, 127, newColor2, 1f)]; - starDust.noGravity = true; - starDust.position = dustPos; - starDust.velocity = -Vector2.UnitY * dustVelMod * (Main.rand.NextFloat() * 0.9f + 1.6f); - starDust.fadeIn = fadeIn; - starDust.scale = dustScale; - starDust.noLight = true; - Dust starDust2 = Dust.CloneDust(starDust); - Dust dust = starDust2; - dust.scale *= 0.65f; - dust = starDust2; - dust.fadeIn *= 0.65f; - starDust2.color = new Color(255, 255, 255, 255); - } - } - Projectile.scale = Projectile.Opacity / 2f * Projectile.localAI[0]; - Projectile.velocity = Vector2.Zero; - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] >= 60f) - { - Projectile.Kill(); - return; - } - } - - public override bool PreDraw(ref Color lightColor) - { - Color colorArea = Lighting.GetColor((int)((double)Projectile.position.X + (double)Projectile.width * 0.5) / 16, (int)(((double)Projectile.position.Y + (double)Projectile.height * 0.5) / 16.0)); - Vector2 projPos = Projectile.position + new Vector2((float)Projectile.width, (float)Projectile.height) / 2f + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; - Texture2D texture2D34 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle rectangular = texture2D34.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Color colorAlpha = Projectile.GetAlpha(colorArea); - Vector2 halfRectangle = rectangular.Size() / 2f; - Color projColor = Main.hslToRgb(0.5f, 1f, Projectile.ai[0]).MultiplyRGBA(new Color(255, 255, 255, 0)); - Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, Projectile.rotation, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, projPos, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor, 0f, halfRectangle, Projectile.scale * 2f, SpriteEffects.None, 0); - if (Projectile.ai[1] != -1f && Projectile.Opacity > 0.3f) - { - Vector2 projDirection = Main.projectile[(int)Projectile.ai[1]].Center - Projectile.Center; - Vector2 projDistance = new Vector2(1f, projDirection.Length() / (float)texture2D34.Height); - float drawRotation = projDirection.ToRotation() + 1.57079637f; - float colorClamp = MathHelper.Distance(30f, Projectile.localAI[1]) / 20f; - colorClamp = MathHelper.Clamp(colorClamp, 0f, 1f); - if (colorClamp > 0f) - { - Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), projColor * colorClamp, drawRotation, halfRectangle, projDistance, SpriteEffects.None, 0); - Main.EntitySpriteDraw(texture2D34, projPos + projDirection / 2f, new Microsoft.Xna.Framework.Rectangle?(rectangular), colorAlpha * colorClamp, drawRotation, halfRectangle, projDistance / 2f, SpriteEffects.None, 0); - } - } - return false; - } - - public override void OnKill(int timeLeft) - { - Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(3.1415927410125732); - float rando = (float)Main.rand.Next(7, 13); - Vector2 dustVel = new Vector2(2.1f, 2f); - Color newColor = Main.hslToRgb(0.5f, 1f, Projectile.ai[0]); - newColor.A = 255; - float dustCount; - for (float i = 0f; i < rando; i = dustCount + 1f) - { - int dusty = Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 0, newColor, 1f); - Main.dust[dusty].position = Projectile.Center; - Main.dust[dusty].velocity = spinningpoint.RotatedBy((double)(6.28318548f * i / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); - Main.dust[dusty].noGravity = true; - Main.dust[dusty].scale = 2f; - Main.dust[dusty].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust11 = Dust.CloneDust(dusty); - Dust dust = dust11; - dust.scale /= 2f; - dust = dust11; - dust.fadeIn /= 2f; - dust11.color = new Color(255, 255, 255, 255); - dustCount = i; - } - for (float j = 0f; j < rando; j = dustCount + 1f) - { - int dusty2 = Dust.NewDust(Projectile.Center, 0, 0, DustID.RainbowMk2, 0f, 0f, 0, newColor, 1f); - Main.dust[dusty2].position = Projectile.Center; - Main.dust[dusty2].velocity = spinningpoint.RotatedBy((double)(6.28318548f * j / rando), default) * dustVel * (0.8f + Main.rand.NextFloat() * 0.4f); - Dust dust = Main.dust[dusty2]; - dust.velocity *= Main.rand.NextFloat() * 0.8f; - Main.dust[dusty2].noGravity = true; - Main.dust[dusty2].scale = Main.rand.NextFloat() * 1f; - Main.dust[dusty2].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust12 = Dust.CloneDust(dusty2); - dust = dust12; - dust.scale /= 2f; - dust = dust12; - dust.fadeIn /= 2f; - dust12.color = new Color(255, 255, 255, 255); - dustCount = j; - } - if (Main.myPlayer == Projectile.owner) - { - Projectile.friendly = true; - int width = Projectile.width; - int height2 = Projectile.height; - int penetrateClone = Projectile.penetrate; - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 60; - Projectile.Center = Projectile.position; - Projectile.penetrate = -1; - Projectile.maxPenetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); - Projectile.penetrate = penetrateClone; - Projectile.position = Projectile.Center; - Projectile.width = width; - Projectile.height = height2; - Projectile.Center = Projectile.position; - } - } - - public override Color? GetAlpha(Color lightColor) - { - return new Color(255 - Projectile.alpha, 255 - Projectile.alpha, 255 - Projectile.alpha, 0); - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - } -} diff --git a/Projectiles/Summon/SiriusMinion.cs b/Projectiles/Summon/SiriusMinion.cs index 8078ce92df..e41364e24c 100644 --- a/Projectiles/Summon/SiriusMinion.cs +++ b/Projectiles/Summon/SiriusMinion.cs @@ -1,9 +1,20 @@ using System; +using System.Collections.Generic; +using System.IO; using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; +using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Systems.Mechanic; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using rail; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -12,6 +23,7 @@ namespace CalamityMod.Projectiles.Summon public class SiriusMinion : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[Projectile.owner]; public CalamityPlayer moddedOwner => Owner.Calamity(); @@ -20,9 +32,10 @@ namespace CalamityMod.Projectiles.Summon public bool CheckForSpawning = false; + public List starburstsToFire = new(); + public override void SetStaticDefaults() { - Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -32,7 +45,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.width = 38; Projectile.height = 48; - Projectile.minionSlots = 6f; + Projectile.minionSlots = 1f; Projectile.penetrate = -1; Projectile.netImportant = true; @@ -43,26 +56,99 @@ namespace CalamityMod.Projectiles.Summon Projectile.DamageType = DamageClass.Summon; } + public int MinionSlotsToAdd + { + get { return (int)Projectile.ai[1]; } + set { Projectile.ai[1] = value; } + } + public override void AI() { NPC target = Projectile.Center.MinionHoming(5000f, Owner); // Constantly tries to find a target. + #region Add Minion Slots + if (MinionSlotsToAdd > 0) + { + float minionSlotsAvaliable = Owner.maxMinions; + foreach (var item in Main.ActiveProjectiles) + { + if (item.owner == Projectile.owner) + minionSlotsAvaliable -= item.minionSlots; + } + while (minionSlotsAvaliable >= 1 && MinionSlotsToAdd > 0) + { + Projectile.minionSlots++; + minionSlotsAvaliable--; + MinionSlotsToAdd--; + Projectile.netUpdate = true; + } + MinionSlotsToAdd = 0; + } + #endregion CheckMinionExistince(); // Checks if the minion can still exist. SpawnEffect(); // Does a dust spawn effect. ShootTarget(target); // If there's a target, shoot at the target. - Projectile.Center = Owner.Center - Vector2.UnitY * (60f - Owner.gfxOffY); // Stays above the player. + if (target is not null && Owner.miscCounter % 30 == 0) { + if (moddedOwner.StratusStarburst <= CalamityPlayer.MaxStratusStarburst) + moddedOwner.StarburstEntities.Add(new StarburstEntity(Projectile.Center)); + moddedOwner.StratusStarburst++; + } Lighting.AddLight(Projectile.Center, 0.5f, 0.5f, 1f); // Passively makes blue light. // The timer for the minion shooting. - if (TimerForShooting < 60f) TimerForShooting++; - else - TimerForShooting = 0f; // Makes the star oscillate. - Projectile.scale = 0.8f + MathF.Abs(MathF.Cos(MathHelper.Pi * (TimerForShooting / 50f))) / 5f; + Projectile.scale = MathHelper.Lerp(0.3f,0.33f, (1+MathF.Sin((Projectile.frameCounter* 0.01f))*0.5f)); + Projectile.frameCounter++; + if (Projectile.frameCounter > 31415) + Projectile.frameCounter = 0; + Projectile.spriteDirection = Owner.direction; + + + Projectile.Center = Owner.oldPosition + Owner.Size * 0.5f - new Vector2(64 * Projectile.spriteDirection, 96f - Owner.gfxOffY); // Stays above and behindthe player. + Projectile.velocity = Owner.velocity * 0f; + + var SiriusPos = Projectile.Center + Projectile.velocity; + var value = 0f; + //Count the value of starbursts in Sirius firing animation + if (Projectile.ai[2] > 2) foreach (var item in starburstsToFire) + { + value += item.value; + } + var SiriusScale = 0.055f + (0.001f * (moddedOwner.AvaliableStarburst + value)); + void SpawnStar(float SlotRequirement, Vector2 offset, float intensity, int flashOffset = 0, int flashMod = 100) + { + if (SlotRequirement > 0 && Projectile.minionSlots < SlotRequirement) + return; + offset.X *= Projectile.spriteDirection; + var star = new BloomParticle(SiriusPos + offset * Projectile.scale - (Owner.oldVelocity * Math.Clamp(offset.Length() * 0.001f,0,1) ), Vector2.Zero, Color.SlateBlue * ((Owner.miscCounter + flashOffset) % flashMod < 5 ? 0.75f : 1f), 2*SiriusScale * intensity, 2*SiriusScale * intensity, 2, false); + var star2 = new CustomSpark(SiriusPos + offset * Projectile.scale - (Owner.oldVelocity * Math.Clamp(offset.Length() * 0.001f, 0, 1)), Vector2.UnitX.RotatedBy(MathHelper.Pi * (Owner.miscCounter/300f)) * 0.1f, "CalamityMod/Particles/Sparkle", false, 2, 10*SiriusScale * intensity, Color.SkyBlue, Vector2.One); + GeneralParticleHandler.SpawnParticle(star,false,Enums.GeneralDrawLayer.AfterProjectiles); + GeneralParticleHandler.SpawnParticle(star2, false, Enums.GeneralDrawLayer.AfterProjectiles); + } + SpawnStar(0,new Vector2(0f, 0f), 1.5f, 0,300); //Sirius + SpawnStar(2, new Vector2(-118f, 217f), 0.75f, 40); //bottom + SpawnStar(3, new Vector2(-67f, 272f), 0.75f, 120); //bakc foot + SpawnStar(4,new Vector2(119f,32f),0.75f,5); //Front foot + SpawnStar(5, new Vector2(-192f, 284f), 0.75f, 10); //tail + SpawnStar(6, new Vector2(-62f, 11f), 0.5f, 75); //neck + SpawnStar(7, new Vector2(-50f, -103f), 0.5f, 130); //nose + SpawnStar(8, new Vector2(-101f, -23f), 0.5f, 20); //head + SpawnStar(9,new Vector2(46f, 59f),0.5f,100); // Front Leg + SpawnStar(10,new Vector2(-49f, 166f), 0.5f,60); // belly + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.minionSlots); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.minionSlots = reader.ReadSingle(); } #region Methods @@ -75,7 +161,10 @@ namespace CalamityMod.Projectiles.Summon if (Owner.dead) moddedOwner.sirius = false; if (moddedOwner.sirius) + { Projectile.timeLeft = 2; + moddedOwner.StratusStarburstResetTimer = (int)MathHelper.Max(moddedOwner.StratusStarburstResetTimer, 60); + } } } @@ -88,7 +177,7 @@ namespace CalamityMod.Projectiles.Summon { float angle = MathHelper.TwoPi / dustAmt * d; Vector2 dustVelocity = angle.ToRotationVector2() * 20f; - Dust spawnDust = Dust.NewDustPerfect(Owner.Center - Vector2.UnitY * 60f, 20, dustVelocity); + Dust spawnDust = Dust.NewDustPerfect(Owner.Center - Vector2.UnitY * 60f, DustID.PurificationPowder, dustVelocity); spawnDust.noGravity = true; } CheckForSpawning = true; @@ -99,29 +188,118 @@ namespace CalamityMod.Projectiles.Summon { if (target is not null) { - if (TimerForShooting >= 60f && Projectile.owner == Main.myPlayer) + float timer = 90f * (10f / (10f + Projectile.minionSlots)); + if (TimerForShooting >= timer && Projectile.owner == Main.myPlayer) { + TimerForShooting = 0; // Makes a dust effect on the minion, to make a better effect of it shooting. + SoundEngine.PlaySound(FrigidflashBolt.UseSound with { Volume = 1f, Pitch = -0.15f }, Projectile.Center); int dustAmt = 50; for (int d = 0; d < dustAmt; d++) { float angle = MathHelper.TwoPi / dustAmt * d; Vector2 dustVelocity = angle.ToRotationVector2() * 20f; - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 20, dustVelocity); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, DustID.PurificationPowder, dustVelocity); spawnDust.noGravity = true; } // Shoots the beam. - Vector2 velocity = (target.Center - Projectile.Center).SafeNormalize(Vector2.Zero) * 3f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + for (var i = 0; i < 2; i++) + { + Vector2 velocity = new Vector2(25, 0).RotatedByRandom(MathHelper.Pi); + float damageMod = 1 + MathF.Pow(0.2f * Projectile.minionSlots, 1.5f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + velocity, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * damageMod), Projectile.knockBack, Projectile.owner); + } + } + if (moddedOwner.AvaliableStarburst >= CalamityPlayer.MaxStratusStarburst) + { + Projectile.ai[2]++; + } + if (Projectile.ai[2] > 0) + { + var value = 0f; + //Count the value of starbursts in Sirius firing animation + foreach (var item in starburstsToFire) + { + value += item.value; + } + //Add starbursts to the animation to equal the shot starburst cost + foreach (var star in moddedOwner.StarburstEntities) + { + if (value >= 50) + break; + value += star.value; + starburstsToFire.Add(star); + } + //Animate the starbursts in the animation + foreach (var star in starburstsToFire) + { + star.Center = Vector2.Lerp(star.Center, Projectile.Center + Projectile.velocity, Projectile.ai[2] / 15f); + star.AICooldown = 2; + } + Projectile.ai[2]++; + if (Projectile.ai[2] > 15) { + if (Main.LocalPlayer.whoAmI == Projectile.owner) + for (var i = 0; i < 2; i++) + { + Vector2 velocity = Projectile.Center.DirectionTo(target.Center) * 10; + float damageMod = 40; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + velocity, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * damageMod), Projectile.knockBack, Projectile.owner, 1); + } + SoundEngine.PlaySound(Exoblade.BeamHitSound, Owner.Center); + Particle explosion = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.SkyBlue, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 0.65f + 0.1f, Main.rand.Next(15, 22)); + GeneralParticleHandler.SpawnParticle(explosion); + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.SlateBlue, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 0.45f + 0.1f, Main.rand.Next(10, 19), false); + GeneralParticleHandler.SpawnParticle(explosion2); + Particle explosion3 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.SlateBlue, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 0.30f + 0.1f, Main.rand.Next(10, 19), false); + GeneralParticleHandler.SpawnParticle(explosion3); + + for (int i = 0; i < 4; i++) + { + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.SkyBlue, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0, 0.5f + 0.05f, 25); + GeneralParticleHandler.SpawnParticle(blastRing); + } + moddedOwner.StratusStarburst -= 50; + Projectile.ai[2] = 0; + foreach (var item in starburstsToFire) + { + moddedOwner.StarburstEntities.Remove(item); + } + starburstsToFire = new(); + } } } } public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); - public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + var SiriusPos = Projectile.Center; + void ConnectStars(float SlotRequirement, Vector2 point1, Vector2 point2) + { + if (SlotRequirement > 0 && Projectile.minionSlots < SlotRequirement) + return; + point1.X *= Projectile.spriteDirection; + point2.X *= Projectile.spriteDirection; + var color = Color.SkyBlue * 0.75f * ((MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f + 0.5f); + CalamityUtils.DrawLineBetter(Main.spriteBatch, SiriusPos+point1 * Projectile.scale - (Owner.oldVelocity * Math.Clamp(point1.Length() * 0.001f, 0, 1)), SiriusPos+point2* Projectile.scale - (Owner.oldVelocity * Math.Clamp(point2.Length() * 0.001f, 0, 1)), color, 2f); + } + ConnectStars(4, new Vector2(0f, 0f), new Vector2(119f, 32f)); //Sirius - Front Foot + ConnectStars(2, new Vector2(0f, 0f), new Vector2(-118f, 217f)); //Sirius - Bottom + ConnectStars(6, new Vector2(0f, 0f), new Vector2(-62f, 11f)); //Sirius - neck + + ConnectStars(9, new Vector2(119f, 32f), new Vector2(46f, 59f)); // Front Foot - Front Leg + ConnectStars(10, new Vector2(46f, 59f), new Vector2(-49f, 166f)); // Frong Leg - Belly + ConnectStars(10, new Vector2(-49f, 166f), new Vector2(-67f, 272f)); // Belly - Back Foot + ConnectStars(3, new Vector2(-67f, 272f), new Vector2(-118f, 217f)); // Back Foot - Bottom + ConnectStars(5, new Vector2(-118f, 217f), new Vector2(-192f, 284f)); // Bottom - Tail + ConnectStars(8, new Vector2(-62f, 11f), new Vector2(-101f, -23f)); // Neck - Head + ConnectStars(8, new Vector2(-101f, -23f), new Vector2(-50f, -103f)); // Head - Nose + ConnectStars(7, new Vector2(-50f, -103f), new Vector2(-62f, 11f)); // Nose - Neck + return false; + } #endregion } } diff --git a/Projectiles/Summon/SiriusMinion.png b/Projectiles/Summon/SiriusMinion.png deleted file mode 100644 index a37b045183..0000000000 Binary files a/Projectiles/Summon/SiriusMinion.png and /dev/null differ diff --git a/Projectiles/Summon/SiriusQuasar.cs b/Projectiles/Summon/SiriusQuasar.cs new file mode 100644 index 0000000000..568d8abe34 --- /dev/null +++ b/Projectiles/Summon/SiriusQuasar.cs @@ -0,0 +1,112 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class SiriusQuasar : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 4; + + Projectile.penetrate = -1; + Projectile.extraUpdates = 30; + Projectile.localNPCHitCooldown = -1; + Projectile.timeLeft = 1000; + + Projectile.friendly = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Summon; + } + + public ref float Time => ref Projectile.ai[1]; + + public override void AI() + { + //Sirius Quasar AI + + Projectile.rotation = Projectile.velocity.ToRotation(); + Time++; + bool isDrawingUpdate = Projectile.numUpdates % 6 == 0; + if (Time > 6f && isDrawingUpdate) + { + Color outerSparkColor = new Color(8, 35, 156); + float scaleBoost = MathHelper.Clamp(Time * 0.005f, 0f, 2f); + float outerSparkScale = 3.2f + scaleBoost; + SparkParticle spark = new SparkParticle(Projectile.Center, Projectile.velocity, false, 7, outerSparkScale, outerSparkColor); + GeneralParticleHandler.SpawnParticle(spark); + + Color innerSparkColor = new Color(184, 215, 245); + float innerSparkScale = 1.6f + scaleBoost; + SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity, false, 7, innerSparkScale, innerSparkColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + for (int d = 0; d < 1; d++) + { + Vector2 projPos = Projectile.position; + projPos -= Projectile.velocity * (d * 0.25f); + Projectile.alpha = 255; + int trailDust = Dust.NewDust(projPos, 1, 1, DustID.PurificationPowder, 0f, 0f, 0, default, 1f); + Main.dust[trailDust].position = projPos; + Main.dust[trailDust].scale = Main.rand.Next(70, 110) * 0.013f; + Main.dust[trailDust].velocity *= 0.2f; + Main.dust[trailDust].noGravity = true; + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + //Due to Sirius's high Starburst consumption, it inflicts long amounts of Voidfrost on hit + target.AddBuff(ModContent.BuffType(), 600); + float x4 = Main.rgbToHsl(new Color(103, 203, Main.DiscoB)).X; + if (Projectile.numHits == 0) + { + SoundStyle fire = new("CalamityMod/Sounds/Item/ScorpioNukeHit"); + SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = 0.6f, PitchVariance = 0.2f }, Projectile.Center); + float numberOfDusts = 156f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + float intensity = Main.rand.NextFloat(0.2f, 0.5f); + Vector2 offset = new Vector2(30f, 5.8f).RotatedBy(rot); + Vector2 velOffset = new Vector2(40.8f, 10.5f).RotatedBy(rot); + if (i % 2 == 0) + { + Particle orb = new CustomSpark(Projectile.Center + offset, velOffset * intensity * 0.7f, "CalamityMod/Particles/Sparkle", false, (int)(40 * intensity), intensity, Main.rand.NextBool(3) ? Color.DarkSlateBlue : Color.SlateBlue, new Vector2(1f, 2f), true, true); + GeneralParticleHandler.SpawnParticle(orb); + } + else + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, ModContent.DustType(), velOffset); + dust.noGravity = true; + dust.velocity = velOffset * intensity; + dust.scale = Main.rand.NextFloat(2.5f, 2.8f) * intensity; + dust.color = Main.rand.NextBool(3) ? Color.DarkSlateBlue : Color.SlateBlue; + } + } + + Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkSlateBlue, "CalamityMod/Particles/BloomRing", new Vector2(0.6f, 0.8f), Projectile.velocity.ToRotation(), 0f, 3f, 25); + GeneralParticleHandler.SpawnParticle(bolt2); + Particle bolt3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.SlateBlue, "CalamityMod/Particles/BloomRing", new Vector2(0.3f, 0.7f), Projectile.velocity.ToRotation(), 0f, 4f, 25); + GeneralParticleHandler.SpawnParticle(bolt3); + } + } + } +} diff --git a/Projectiles/Summon/SkeletalDragonMother.cs b/Projectiles/Summon/SkeletalDragonMother.cs index 533f5934b4..1d93cc03e1 100644 --- a/Projectiles/Summon/SkeletalDragonMother.cs +++ b/Projectiles/Summon/SkeletalDragonMother.cs @@ -138,5 +138,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.frame = 0; } } + + public override bool MinionContactDamage() => true; } } diff --git a/Projectiles/Summon/SlimePuppet.cs b/Projectiles/Summon/SlimePuppet.cs index 37f791b7a1..1e12d73113 100644 --- a/Projectiles/Summon/SlimePuppet.cs +++ b/Projectiles/Summon/SlimePuppet.cs @@ -1,13 +1,9 @@ using System; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace CalamityMod.Projectiles.Summon { @@ -93,7 +89,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 20; i++) { Vector2 spawnOffset = Main.rand.NextVector2Unit() * Main.rand.NextFloat(4f, 36f); - Dust slime = Dust.NewDustPerfect(Projectile.Center + spawnOffset, 243); + Dust slime = Dust.NewDustPerfect(Projectile.Center + spawnOffset, DustID.PinkSlime); slime.velocity = spawnOffset.RotatedBy(MathHelper.PiOver2 * Main.rand.NextBool().ToDirectionInt()) * 0.16f; slime.scale = 1.2f; } diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs index ad59ba6a1f..5b9c20254a 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonCannon.cs @@ -69,6 +69,8 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms Projectile.timeLeft = 900000; Projectile.scale = 1f; Projectile.DamageType = DamageClass.Summon; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void SendExtraAI(BinaryWriter writer) diff --git a/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs index 99ee5880ee..436597e274 100644 --- a/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs +++ b/Projectiles/Summon/SmallAresArms/ExoskeletonLaserCannon.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon.SmallAresArms @@ -49,7 +50,7 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms // Create a burst of dust. for (int i = 0; i < 24; i++) { - Dust laserEnergy = Dust.NewDustPerfect(Projectile.Center + shootDirection * Projectile.width * Projectile.scale * 0.45f, 182); + Dust laserEnergy = Dust.NewDustPerfect(Projectile.Center + shootDirection * Projectile.width * Projectile.scale * 0.45f, DustID.TheDestroyer); laserEnergy.velocity = (MathHelper.TwoPi * i / 24f).ToRotationVector2() * 4f; laserEnergy.scale = 1.1f; laserEnergy.fadeIn = 0.4f; @@ -87,7 +88,7 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms return; Vector2 aimDirection = Projectile.rotation.ToRotationVector2(); - Dust laserEnergy = Dust.NewDustPerfect(Projectile.Center + aimDirection * Projectile.width * Projectile.scale * 0.51f, 182); + Dust laserEnergy = Dust.NewDustPerfect(Projectile.Center + aimDirection * Projectile.width * Projectile.scale * 0.51f, DustID.TheDestroyer); laserEnergy.velocity = aimDirection.RotatedByRandom(0.48f) * Main.rand.NextFloat(3f); laserEnergy.scale = 1.1f; laserEnergy.fadeIn = 0.4f; diff --git a/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.cs b/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.cs index 3945b1d12d..9b86d3d3f9 100644 --- a/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.cs +++ b/Projectiles/Summon/SmallAresArms/MinionPlasmaGas.cs @@ -3,7 +3,6 @@ using CalamityMod.DataStructures; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs b/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs index 44f5dd439d..55a19a4dc4 100644 --- a/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs +++ b/Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs @@ -88,21 +88,21 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms return null; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return MathHelper.Lerp(0.75f, 1.85f, (float)Math.Sin(MathHelper.Pi * completionRatio)) * Projectile.scale; } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeToWhite = MathHelper.Lerp(0f, 0.65f, (float)Math.Sin(MathHelper.TwoPi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f); Color baseColor = Color.Lerp(Color.Cyan, Color.White, fadeToWhite); return Color.Lerp(baseColor, Color.LightBlue, ((float)Math.Sin(MathHelper.Pi * completionRatio + Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 0.5f) * 0.8f) * Projectile.Opacity; } - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 4f; + internal float BackgroundWidthFunction(float completionRatio, Vector2 vertexPos) => WidthFunction(completionRatio, vertexPos) * 4f; - internal Color BackgroundColorFunction(float completionRatio) + internal Color BackgroundColorFunction(float completionRatio, Vector2 vertexPos) { Color color = Color.CornflowerBlue * Projectile.Opacity * 0.4f; return color; diff --git a/Projectiles/Summon/SmallSkeletonMinion.cs b/Projectiles/Summon/SmallSkeletonMinion.cs index 2cc5640838..d5be045715 100644 --- a/Projectiles/Summon/SmallSkeletonMinion.cs +++ b/Projectiles/Summon/SmallSkeletonMinion.cs @@ -15,9 +15,10 @@ namespace CalamityMod.Projectiles.Summon public int Variant; public override void SetStaticDefaults() { + Main.projFrames[Type] = 7; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; - Main.projFrames[Type] = 7; } public override void SetDefaults() @@ -171,6 +172,9 @@ namespace CalamityMod.Projectiles.Summon } return true; } + + public override bool MinionContactDamage() => true; + public override bool PreDraw(ref Color lightColor) { Rectangle frame = new Rectangle(Variant * Projectile.width, Projectile.frame * Projectile.height, Projectile.width, Projectile.height); diff --git a/Projectiles/Summon/SolarBeam.cs b/Projectiles/Summon/SolarBeam.cs deleted file mode 100644 index cee2d0e534..0000000000 --- a/Projectiles/Summon/SolarBeam.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class SolarBeam : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionShot[Type] = true; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 4; - Projectile.aiStyle = ProjAIStyleID.Ray; - Projectile.friendly = true; - Projectile.extraUpdates = 220; - Projectile.timeLeft = 200; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 9f) - { - for (int i = 0; i < 4; i++) - { - Vector2 dustPos = Projectile.position; - dustPos -= Projectile.velocity * ((float)i * 0.25f); - Projectile.alpha = 255; - int dust = Dust.NewDust(dustPos, 1, 1, DustID.GoldCoin, 0f, 0f, 0, default, 1f); - Main.dust[dust].position = dustPos; - Main.dust[dust].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[dust].velocity *= 0.2f; - } - } - } - } -} diff --git a/Projectiles/Summon/SolarGod.cs b/Projectiles/Summon/SolarGod.cs deleted file mode 100644 index 890f7bbf8c..0000000000 --- a/Projectiles/Summon/SolarGod.cs +++ /dev/null @@ -1,134 +0,0 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class SolarGod : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionSacrificable[Type] = true; - ProjectileID.Sets.MinionTargettingFeature[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 74; - Projectile.height = 90; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.minionSlots = 1f; - Projectile.timeLeft = 18000; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - Projectile.minion = true; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - player.AddBuff(ModContent.BuffType(), 3600); - bool correctMinion = Projectile.type == ModContent.ProjectileType(); - if (correctMinion) - { - if (player.dead) - { - modPlayer.SPG = false; - } - if (modPlayer.SPG) - { - Projectile.timeLeft = 2; - } - } - Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); - if (player.gravDir == -1f) - { - Projectile.position.Y += 120f; - Projectile.rotation = MathHelper.Pi; - } - else - { - Projectile.rotation = 0f; - } - Projectile.position.X = (int)Projectile.position.X; - Projectile.position.Y = (int)Projectile.position.Y; - float sizeScale = (float)Main.mouseTextColor / 200f - 0.35f; - sizeScale *= 0.2f; - Projectile.scale = sizeScale + 0.95f; - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0f / 255f); - if (Projectile.localAI[0] == 0f) - { - int dustAmt = 50; - for (int d = 0; d < dustAmt; d++) - { - int fire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.CopperCoin, 0f, 0f, 0, default, 1f); - Main.dust[fire].velocity *= 2f; - Main.dust[fire].scale *= 1.15f; - } - Projectile.localAI[0] += 1f; - } - if (Projectile.owner == Main.myPlayer) - { - if (Projectile.ai[0] != 0f) - { - Projectile.ai[0] -= 1f; - return; - } - Vector2 targetPos = Projectile.position; - float maxDistance = 700f; - bool foundTarget = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(Projectile, false)) - { - float npcDist = Vector2.Distance(Projectile.Center, npc.Center); - if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - targetPos = npc.Center; - foundTarget = true; - } - } - } - if (!foundTarget) - { - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.CanBeChasedBy(Projectile, false)) - { - float npcDist = Vector2.Distance(Projectile.Center, npc.Center); - if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - maxDistance = npcDist; - targetPos = npc.Center; - foundTarget = true; - } - } - } - } - if (foundTarget) - { - float shootSpeed = 15f; - Vector2 source = Projectile.Center; - Vector2 velocity = targetPos - source; - velocity.Normalize(); - velocity *= shootSpeed; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - Projectile.ai[0] = 20f; - } - } - } - - public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Summon/SolarPixie.cs b/Projectiles/Summon/SolarPixie.cs deleted file mode 100644 index 3ca4ff1c0f..0000000000 --- a/Projectiles/Summon/SolarPixie.cs +++ /dev/null @@ -1,135 +0,0 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class SolarPixie : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionSacrificable[Type] = true; - ProjectileID.Sets.MinionTargettingFeature[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 50; - Projectile.height = 50; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.minionSlots = 1f; - Projectile.timeLeft = 18000; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - Projectile.minion = true; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - player.AddBuff(ModContent.BuffType(), 3600); - bool correctMinion = Projectile.type == ModContent.ProjectileType(); - if (correctMinion) - { - if (player.dead) - { - modPlayer.SP = false; - } - if (modPlayer.SP) - { - Projectile.timeLeft = 2; - } - } - Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); - if (player.gravDir == -1f) - { - Projectile.position.Y += 120f; - Projectile.rotation = MathHelper.Pi; - } - else - { - Projectile.rotation = 0f; - } - Projectile.position.X = (int)Projectile.position.X; - Projectile.position.Y = (int)Projectile.position.Y; - float sizeScale = (float)Main.mouseTextColor / 200f - 0.35f; - sizeScale *= 0.2f; - Projectile.scale = sizeScale + 0.95f; - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f); - if (Projectile.localAI[0] == 0f) - { - int dustAmt = 25; - for (int d = 0; d < dustAmt; d++) - { - int fire = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.CopperCoin, 0f, 0f, 0, default, 1f); - Main.dust[fire].velocity *= 2f; - Main.dust[fire].scale *= 1.15f; - } - Projectile.localAI[0] += 1f; - } - if (Projectile.owner == Main.myPlayer) - { - if (Projectile.ai[0] != 0f) - { - Projectile.ai[0] -= 1f; - return; - } - Vector2 targetPos = Projectile.position; - float maxDistance = 700f; - bool foundTarget = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(Projectile, false)) - { - float npcDist = Vector2.Distance(Projectile.Center, npc.Center); - if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - targetPos = npc.Center; - foundTarget = true; - } - } - } - if (!foundTarget) - { - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.CanBeChasedBy(Projectile, false)) - { - float npcDist = Vector2.Distance(Projectile.Center, npc.Center); - if (npcDist < maxDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc.position, npc.width, npc.height)) - { - maxDistance = npcDist; - targetPos = npc.Center; - foundTarget = true; - } - } - } - } - if (foundTarget) - { - float shootSpeed = 30f; - Vector2 source = Projectile.Center; - Vector2 velocity = targetPos - source; - velocity.Normalize(); - velocity *= shootSpeed; - Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), source, velocity, ProjectileID.HeatRay, Projectile.damage, Projectile.knockBack, Projectile.owner); - beam.DamageType = DamageClass.Summon; - Projectile.ai[0] = 50f; - } - } - } - - public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Summon/StellarTorusSummon.cs b/Projectiles/Summon/StellarTorusSummon.cs index 0be79f013e..c839add53c 100644 --- a/Projectiles/Summon/StellarTorusSummon.cs +++ b/Projectiles/Summon/StellarTorusSummon.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + Main.projPet[Type] = true; ProjectileID.Sets.DrawScreenCheckFluff[Type] = 12000; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; @@ -106,7 +107,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 chargeDustSpawn = Projectile.Center + Main.rand.NextVector2Circular(scale * 1.2f, scale * 1.2f); Dust chargeDust = Dust.NewDustPerfect(chargeDustSpawn, - 307, + DustID.MushroomTorch, chargeDustSpawn.DirectionTo(Projectile.Center) * Main.rand.NextFloat(5f, 8f)); chargeDust.noGravity = true; chargeDust.scale = chargeDust.velocity.Length() * .15f; @@ -166,7 +167,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.rotation = MathHelper.Lerp(swingRotStart, swingRotStart + (MathHelper.PiOver4 * -LaserSwingDirection), RotationInterpolant); RotationInterpolant += 1f / StellarTorusStaff.TimeShooting; - Dust shootDust = Dust.NewDustPerfect(Projectile.Center, 307, Main.rand.NextVector2Circular(Main.rand.NextFloat(10f, 15f), Main.rand.NextFloat(10f, 15f))); + Dust shootDust = Dust.NewDustPerfect(Projectile.Center, DustID.MushroomTorch, Main.rand.NextVector2Circular(Main.rand.NextFloat(10f, 15f), Main.rand.NextFloat(10f, 15f))); shootDust.noGravity = true; shootDust.scale = shootDust.velocity.Length() * .2f; @@ -272,7 +273,5 @@ namespace CalamityMod.Projectiles.Summon return false; } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/StormjawBaby.cs b/Projectiles/Summon/StormjawBaby.cs index dfa4c71d3b..5c67d408c2 100644 --- a/Projectiles/Summon/StormjawBaby.cs +++ b/Projectiles/Summon/StormjawBaby.cs @@ -18,9 +18,10 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projFrames[Type] = 10; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; - Main.projFrames[Type] = 10; } public override void SetDefaults() @@ -557,7 +558,5 @@ namespace CalamityMod.Projectiles.Summon Main.gore[index].velocity *= 0.1f; } } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/SunSpiritBeam.cs b/Projectiles/Summon/SunSpiritBeam.cs new file mode 100644 index 0000000000..44ef8b803d --- /dev/null +++ b/Projectiles/Summon/SunSpiritBeam.cs @@ -0,0 +1,130 @@ +using System; +using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class SunSpiritBeam : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.MinionShot[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 24; + Projectile.height = 24; + Projectile.friendly = true; + Projectile.timeLeft = 180; + Projectile.DamageType = DamageClass.Summon; + Projectile.MaxUpdates = 2; + Projectile.stopsDealingDamageAfterPenetrateHits = true; + } + + public override void OnSpawn(IEntitySource source) + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + + if (Projectile.damage <= 0) + { + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 4; + Projectile.timeLeft = (int)MathHelper.Min(8,Projectile.timeLeft); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + for (int i = 0; i < 12; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(3f, 5f); + Color dustColor = Color.Lerp(Color.Yellow, Color.Gold, Main.rand.NextFloat(0.5f, 1f)); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = true; + } + } + + public override bool PreDraw(ref Color lightColor) => false; + + //Trail based on Fryzahh's work on Faith Incinerator + public float FireWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = 38f * Projectile.scale; + float curveRatio = 0.2f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return (width + additionalPulseWidth ) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type] ; + } + + public Color FireColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = Color.Gold * 1.3f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; + } + + public float FireCoreWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = Projectile.scale * 16; + float curveRatio = 0.25f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireCoreColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = Color.Gold; + Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); + return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity; + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); + + Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), fireCoreLength.Length + 24); + } + } +} diff --git a/Projectiles/Summon/SunSpiritMinion.cs b/Projectiles/Summon/SunSpiritMinion.cs new file mode 100644 index 0000000000..b00258f2c4 --- /dev/null +++ b/Projectiles/Summon/SunSpiritMinion.cs @@ -0,0 +1,154 @@ +using System.IO; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class SunSpiritMinion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = true; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 50; + Projectile.height = 50; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.minionSlots = 1f; + Projectile.timeLeft = 18000; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.timeLeft *= 5; + Projectile.minion = true; + Projectile.DamageType = DamageClass.Summon; + } + + public int MinionSlotsToAdd + { + get { return (int)Projectile.ai[0]; } + set { Projectile.ai[0] = value; } + } + public override void AI() + { + Player player = Main.player[Projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + player.AddBuff(ModContent.BuffType(), 3600); + + #region Add Minion Slots + if (MinionSlotsToAdd > 0) + { + float minionSlotsAvaliable = player.maxMinions; + foreach (var item in Main.ActiveProjectiles) + { + if (item.owner == Projectile.owner) + minionSlotsAvaliable -= item.minionSlots; + } + while (minionSlotsAvaliable >= 1 && MinionSlotsToAdd > 0) + { + + Projectile.minionSlots++; + minionSlotsAvaliable--; + MinionSlotsToAdd--; + Projectile.netUpdate = true; + } + MinionSlotsToAdd = 0; + } + #endregion + + #region Checking alive + bool correctMinion = Projectile.type == ModContent.ProjectileType(); + if (correctMinion) + { + if (player.dead) + { + modPlayer.sunSpirit = false; + } + if (modPlayer.sunSpirit) + { + Projectile.timeLeft = 2; + } + } + #endregion + + #region Positioning + Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -80f); + #endregion + + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f); + + NPC target = null; + int targetID = -1; + Projectile.Minion_FindTargetInRange(800, ref targetID, false); + if (targetID < 0) + return; + + target = Main.npc[targetID]; + + + if (Projectile.owner == Main.myPlayer) + { + if (Projectile.ai[1] > 0f) + { + Projectile.ai[1] -= 1f; + return; + } + float shootSpeed = 15f; + Vector2 source = Projectile.Center; + var velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, target, shootSpeed, 2); + Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center - velocity, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + beam.DamageType = DamageClass.Summon; + Projectile.ai[1] += 50f / Projectile.minionSlots; + } + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.minionSlots); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.minionSlots = reader.ReadSingle(); + } + + public override bool? CanDamage() => false; + + public static Asset circle; + public override bool PreDraw(ref Color lightColor) + { + var spTex = TextureAssets.Projectile[Type].Value; + var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/ExtraTextures/GreyscaleOpenCircleButBigger").Value; + + Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); + + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + float count = MathHelper.Min(Projectile.minionSlots * 2, 40); + for (var i = 0; i < count; i++) + { + var comp = (i / count); + var offset = ((Main.mouseTextColor - 190) / 64f) * 8; + if (i % 2 == 0) + offset = 8 - offset; + CalamityUtils.DrawLineBetter(Main.spriteBatch, Projectile.Center + new Vector2(20 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), Projectile.Center + new Vector2(34 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), i % 2 == 3 ? Color.OrangeRed : Color.Gold, 2f); + } + Main.spriteBatch.End(); + } + return false; + } + } +} diff --git a/Projectiles/Summon/SolarPixie.png b/Projectiles/Summon/SunSpiritMinion.png similarity index 100% rename from Projectiles/Summon/SolarPixie.png rename to Projectiles/Summon/SunSpiritMinion.png diff --git a/Projectiles/Summon/TacticalPlagueJet.cs b/Projectiles/Summon/TacticalPlagueJet.cs index 0fad924ff2..854d66152b 100644 --- a/Projectiles/Summon/TacticalPlagueJet.cs +++ b/Projectiles/Summon/TacticalPlagueJet.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 3; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -59,8 +60,6 @@ namespace CalamityMod.Projectiles.Summon FalseGun.DamageType = DamageClass.Summon; } - public override bool? CanDamage() => false; - public override void AI() { Player player = Main.player[Projectile.owner]; diff --git a/Projectiles/Summon/TundraFlameBlossom.cs b/Projectiles/Summon/TundraFlameBlossom.cs index 8d7d4333ea..2f3e8932c2 100644 --- a/Projectiles/Summon/TundraFlameBlossom.cs +++ b/Projectiles/Summon/TundraFlameBlossom.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -74,7 +75,7 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 36; i++) { - Dust spawnEffect = Dust.NewDustPerfect(Projectile.Center, 179); + Dust spawnEffect = Dust.NewDustPerfect(Projectile.Center, DustID.BubbleBurst_Purple); spawnEffect.noGravity = true; spawnEffect.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(2f, 7f); } @@ -109,8 +110,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.netUpdate = true; } - public override bool? CanDamage() => false; - #endregion } } diff --git a/Projectiles/Summon/TundraFlameBlossomsOrb.cs b/Projectiles/Summon/TundraFlameBlossomsOrb.cs index f818350390..0468a63a4f 100644 --- a/Projectiles/Summon/TundraFlameBlossomsOrb.cs +++ b/Projectiles/Summon/TundraFlameBlossomsOrb.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/Umbrella/MagicAxe.cs b/Projectiles/Summon/Umbrella/MagicAxe.cs index 8c58102600..52f707b893 100644 --- a/Projectiles/Summon/Umbrella/MagicAxe.cs +++ b/Projectiles/Summon/Umbrella/MagicAxe.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; diff --git a/Projectiles/Summon/Umbrella/MagicBullet.cs b/Projectiles/Summon/Umbrella/MagicBullet.cs index d65f48bb37..64121527b5 100644 --- a/Projectiles/Summon/Umbrella/MagicBullet.cs +++ b/Projectiles/Summon/Umbrella/MagicBullet.cs @@ -1,10 +1,8 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon.Umbrella @@ -49,11 +47,11 @@ namespace CalamityMod.Projectiles.Summon.Umbrella target.AddBuff(BuffID.BetsysCurse, 180); if (!target.ichor) target.AddBuff(BuffID.Ichor, 180); - if (target.Calamity().marked <= 0) + if (target.Calamity().markedForDeath) target.AddBuff(ModContent.BuffType(), 180); - if (target.Calamity().aCrunch <= 0) + if (target.Calamity().armorCrunch) target.AddBuff(ModContent.BuffType(), 180); - if (target.Calamity().wDeath <= 0) + if (target.Calamity().whisperingDeath) target.AddBuff(ModContent.BuffType(), 180); } diff --git a/Projectiles/Summon/Umbrella/MagicBulletBig.cs b/Projectiles/Summon/Umbrella/MagicBulletBig.cs index 4c6080aca4..cf67435646 100644 --- a/Projectiles/Summon/Umbrella/MagicBulletBig.cs +++ b/Projectiles/Summon/Umbrella/MagicBulletBig.cs @@ -1,10 +1,8 @@ -using System; -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon.Umbrella @@ -54,11 +52,11 @@ namespace CalamityMod.Projectiles.Summon.Umbrella target.AddBuff(BuffID.BetsysCurse, 180); if (!target.ichor) target.AddBuff(BuffID.Ichor, 180); - if (target.Calamity().marked <= 0) + if (target.Calamity().markedForDeath) target.AddBuff(ModContent.BuffType(), 180); - if (target.Calamity().aCrunch <= 0) + if (target.Calamity().armorCrunch) target.AddBuff(ModContent.BuffType(), 180); - if (target.Calamity().wDeath <= 0) + if (target.Calamity().whisperingDeath) target.AddBuff(ModContent.BuffType(), 180); } diff --git a/Projectiles/Summon/Umbrella/MagicHat.cs b/Projectiles/Summon/Umbrella/MagicHat.cs index 367a495d61..c75ea5de51 100644 --- a/Projectiles/Summon/Umbrella/MagicHat.cs +++ b/Projectiles/Summon/Umbrella/MagicHat.cs @@ -116,9 +116,6 @@ namespace CalamityMod.Projectiles.Summon.Umbrella // Glowmask effect public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, 200); - // No contact damage - public override bool? CanDamage() => false; - // Draw over players public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) => overPlayers.Add(index); diff --git a/Projectiles/Summon/UniverseSplitterField.cs b/Projectiles/Summon/UniverseSplitterField.cs index f9a4cf3856..36843a7830 100644 --- a/Projectiles/Summon/UniverseSplitterField.cs +++ b/Projectiles/Summon/UniverseSplitterField.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Summon // Generate a dust ring that pulsates for (int i = 0; i < 80; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + (i / 80f * MathHelper.TwoPi).ToRotationVector2() * DustRadius, 247); + Dust dust = Dust.NewDustPerfect(Projectile.Center + (i / 80f * MathHelper.TwoPi).ToRotationVector2() * DustRadius, DustID.PlatinumCoin); dust.velocity = Vector2.Zero; dust.scale = 1.2f; dust.noGravity = true; @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Summon { Dust dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY.RotatedBy(Timer / SpiralPrecision * direction).RotatedBy(j / (float)SpiralRings * MathHelper.TwoPi).RotatedBy(i / (float)SpiralPrecision * MathHelper.TwoPi / SpiralRings * direction) * - DustRadius * i / SpiralPrecision, 261); + DustRadius * i / SpiralPrecision, DustID.AncientLight); dust.velocity = Vector2.Zero; dust.scale = 0.7f; dust.noGravity = true; @@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Summon bool firingGiantLaserBeam = Timer > TimeLeft - UniverseSplitterHugeBeam.TimeLeft; for (int i = 0; i < (firingGiantLaserBeam ? 30 : 16); i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 247); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.PlatinumCoin); dust.velocity = Main.rand.NextVector2Circular(8f, 8f) * (firingGiantLaserBeam ? 1.6f : 1f); dust.noGravity = true; dust.scale = 1.25f; @@ -112,7 +112,7 @@ namespace CalamityMod.Projectiles.Summon float outwardCircleRadius = MathHelper.Lerp(0f, DustRadius * 1.2f, MathHelper.Clamp((Timer - (TimeLeft - UniverseSplitterHugeBeam.TimeLeft - 120f)) / 40f, 0f, 1f)); for (int i = 0; i < 95; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + (i / 95f * MathHelper.TwoPi).ToRotationVector2() * outwardCircleRadius, 247); + Dust dust = Dust.NewDustPerfect(Projectile.Center + (i / 95f * MathHelper.TwoPi).ToRotationVector2() * outwardCircleRadius, DustID.PlatinumCoin); dust.scale = 1.2f; dust.noGravity = true; dust.velocity = Main.rand.NextBool(7) ? Projectile.DirectionFrom(dust.position) * 6f : Vector2.Zero; diff --git a/Projectiles/Summon/UniverseSplitterHugeBeam.cs b/Projectiles/Summon/UniverseSplitterHugeBeam.cs index 0d4b0b518f..10dca0bce0 100644 --- a/Projectiles/Summon/UniverseSplitterHugeBeam.cs +++ b/Projectiles/Summon/UniverseSplitterHugeBeam.cs @@ -1,5 +1,4 @@ using System.IO; -using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.DraedonsArsenal; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -102,13 +101,13 @@ namespace CalamityMod.Projectiles.Summon SoundEngine.PlaySound(TeslaCannon.FireSound, Projectile.Center); for (int i = 0; i < 75; i++) { - Dust dust = Dust.NewDustPerfect(beamEndPosition, 269); + Dust dust = Dust.NewDustPerfect(beamEndPosition, DustID.Sandnado); dust.velocity = Main.rand.NextVector2Circular(16f, 11f); dust.velocity = dust.velocity.SafeNormalize(Vector2.UnitY) * new Vector2(5f, 3.5f); dust.scale = Main.rand.NextFloat(1.2f, 1.5f); dust.noGravity = true; - dust = Dust.NewDustPerfect(beamEndPosition, 269); + dust = Dust.NewDustPerfect(beamEndPosition, DustID.Sandnado); dust.velocity = (i / 75f * MathHelper.TwoPi).ToRotationVector2().RotatedByRandom(0.2f) * new Vector2(16f, 11f) * 1.3f; dust.scale = Main.rand.NextFloat(1.4f, 1.75f); dust.noGravity = true; diff --git a/Projectiles/Summon/Urchin.png b/Projectiles/Summon/Urchin.png deleted file mode 100644 index d9f072c4f9..0000000000 Binary files a/Projectiles/Summon/Urchin.png and /dev/null differ diff --git a/Projectiles/Summon/UrchinSpike.cs b/Projectiles/Summon/UrchinSpike.cs deleted file mode 100644 index bb7dd11f81..0000000000 --- a/Projectiles/Summon/UrchinSpike.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class UrchinSpike : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionShot[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 6; - Projectile.friendly = true; - Projectile.timeLeft = 600; - Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Poisoned, 180); - } -} diff --git a/Projectiles/Summon/UrchinSpike.png b/Projectiles/Summon/UrchinSpike.png deleted file mode 100644 index 0d8e8c9ebf..0000000000 Binary files a/Projectiles/Summon/UrchinSpike.png and /dev/null differ diff --git a/Projectiles/Summon/VengefulSunBeam.cs b/Projectiles/Summon/VengefulSunBeam.cs new file mode 100644 index 0000000000..1bb94fdb23 --- /dev/null +++ b/Projectiles/Summon/VengefulSunBeam.cs @@ -0,0 +1,167 @@ +using System; +using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class VengefulSunBeam : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.MinionShot[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 24; + Projectile.height = 24; + Projectile.friendly = true; + Projectile.timeLeft = 180; + Projectile.DamageType = DamageClass.Summon; + Projectile.MaxUpdates = 2; + Projectile.tileCollide = false; + Projectile.penetrate = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 0; //has a custom iframe counter + Projectile.stopsDealingDamageAfterPenetrateHits = true; + } + + public override void OnSpawn(IEntitySource source) + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + } + + public override void AI() + { + if (Projectile.ai[0] > 1) + { + Projectile.ai[0]--; + Projectile.timeLeft = 120; + } + if (Projectile.ai[0] > 0) + { + var target = Projectile.FindTargetWithinRange(640); + if (target != null) + { + Projectile.Calamity().HomingTarget = target.whoAmI; + Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(Projectile.DirectionTo(target.Center).ToRotation(), 0.5f*(1-Projectile.ai[0]/120f)).ToRotationVector2() * Projectile.velocity.Length(); + } + } + if (Projectile.damage <= 0) + { + Projectile.ai[0] = 0; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 4; + Projectile.timeLeft = (int)MathHelper.Min(8, Projectile.timeLeft); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + for (int i = 0; i < 12; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(3f, 5f); + Color dustColor = Color.Lerp(Color.OrangeRed, Color.Gold, Main.rand.NextFloat(0.5f, 1f)); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = true; + } + if (Projectile.ai[0] > 0) + return; + for (var i = -1; i <= 1; i+=2) + { + var randomVel = Projectile.velocity.RotatedByRandom(MathHelper.TwoPi); + var p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(),Projectile.Center- randomVel * 3, randomVel, Type,Projectile.damage,Projectile.knockBack,Projectile.owner, 120, Projectile.ai[1]); + p.penetrate = 1; + p.scale = 0.75f; + } + Projectile.damage = 0; + Projectile.timeLeft = 10; + Projectile.netUpdate = true; + } + + public override bool? CanDamage() + { + return Projectile.ai[0] <= 90; + } + + public override bool PreDraw(ref Color lightColor) => false; + + //Trail based on Fryzahh's work on Faith Incinerator + public float FireWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = 38f * Projectile.scale; + float curveRatio = 0.2f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = Color.Lerp(Color.Yellow, Color.OrangeRed, Projectile.ai[1]); + if (Projectile.ai[1] >= 1) + mainColor = Color.LightBlue; + mainColor *= 1.3f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion); + } + + public float FireCoreWidthFunction(float completion, Vector2 vertexPos) + { + float width; + float maxBodyWidth = Projectile.scale * 24; + float curveRatio = 0.25f; + var positions = Projectile.oldPos.ToList(); + positions.RemoveAll(x => x == Vector2.Zero); + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; + } + + public Color FireCoreColorFunction(float completion, Vector2 vertexPos) + { + Color mainColor = Color.Black; + mainColor = Color.Lerp(mainColor, Color.Gold, 1 - Projectile.ai[1]); + Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); + return fullBodyColor; + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, GeneralDrawLayer layer) + { + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); + Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_,_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), fireCoreLength.Length + 24); + } + } +} diff --git a/Projectiles/Summon/VengefulSunSpiritMinion.cs b/Projectiles/Summon/VengefulSunSpiritMinion.cs new file mode 100644 index 0000000000..61676b14c0 --- /dev/null +++ b/Projectiles/Summon/VengefulSunSpiritMinion.cs @@ -0,0 +1,188 @@ +using System.IO; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class VengefulSunSpiritMinion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = true; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 50; + Projectile.height = 50; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.minionSlots = 1f; + Projectile.timeLeft = 18000; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.timeLeft *= 5; + Projectile.minion = true; + Projectile.DamageType = DamageClass.Summon; + } + + public int MinionSlotsToAdd + { + get { return (int)Projectile.ai[0]; } + set { Projectile.ai[0] = value; } + } + public override void AI() + { + Player player = Main.player[Projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + player.AddBuff(ModContent.BuffType(), 3600); + + #region Add Minion Slots + if (MinionSlotsToAdd > 0) + { + float minionSlotsAvaliable = player.maxMinions; + foreach (var item in Main.ActiveProjectiles) + { + if (item.owner == Projectile.owner) + minionSlotsAvaliable -= item.minionSlots; + } + while (minionSlotsAvaliable >= 1 && MinionSlotsToAdd > 0) + { + + Projectile.minionSlots++; + minionSlotsAvaliable--; + MinionSlotsToAdd--; + Projectile.netUpdate = true; + } + MinionSlotsToAdd = 0; + } + #endregion + + #region Checking alive + bool correctMinion = Projectile.type == ModContent.ProjectileType(); + if (correctMinion) + { + if (player.dead) + { + modPlayer.vengefulSunMinion = false; + } + if (modPlayer.vengefulSunMinion) + { + Projectile.timeLeft = 2; + } + } + #endregion + + #region Positioning + Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY + player.gravDir * -80f); + #endregion + + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f); + + NPC target = null; + int targetID = -1; + Projectile.Minion_FindTargetInRange(1600, ref targetID, false); + if (targetID < 0) + return; + + target = Main.npc[targetID]; + + + if (Projectile.owner == Main.myPlayer) + { + if (Projectile.ai[1] > 0f) + { + Projectile.ai[1] -= 1f; + return; + } + float shootSpeed = 15f; + Vector2 source = Projectile.Center; + var velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, target, shootSpeed, 2); + Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center - velocity, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * (0.75f + Projectile.minionSlots * 0.25f)), Projectile.knockBack, Projectile.owner, ai1: (Projectile.minionSlots - 1) / 9f); + beam.DamageType = DamageClass.Summon; + Projectile.ai[1] += 60f / (0.75f + Projectile.minionSlots * 0.25f); + } + } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.minionSlots); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.minionSlots = reader.ReadSingle(); + } + + public override bool? CanDamage() => false; + + private static Texture2D AllWhiteVersion = null; + public static Texture2D GetWhiteTex() + { + if (AllWhiteVersion == null) + { + var texture = TextureAssets.Projectile[ModContent.ProjectileType()].Value; + AllWhiteVersion = new Texture2D(Main.graphics.GraphicsDevice, texture.Width, texture.Height); + + var BaseArray = new Color[AllWhiteVersion.Width * AllWhiteVersion.Height]; + var ColorArray = new Color[AllWhiteVersion.Width * AllWhiteVersion.Height]; + texture.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + AllWhiteVersion.SetData(ColorArray); + } + return AllWhiteVersion; + } + public static Asset circle; + public override bool PreDraw(ref Color lightColor) + { + AllWhiteVersion = null; + var spTex = TextureAssets.Projectile[Type].Value; + var whiteTex = GetWhiteTex(); + var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/ExtraTextures/GreyscaleOpenCircleButBigger").Value; + + float completion = (Projectile.minionSlots-1) / 9f; + var color = Color.Lerp(Color.Yellow, Color.DarkOrange, completion); + if (completion >= 1) + color = Color.LightBlue; + + for (float i = 0; i < MathHelper.TwoPi; i += MathHelper.PiOver2) + { + Main.spriteBatch.Draw(whiteTex, Projectile.Center - Main.screenPosition + new Vector2(MathHelper.Min(2, completion * 2.2f), 0).RotatedBy(i), null, color, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); + } + Main.spriteBatch.Draw(spTex, Projectile.Center - Main.screenPosition, null, Color.White, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(whiteTex, Projectile.Center - Main.screenPosition, null, Color.Black * completion, Main.GlobalTimeWrappedHourly, spTex.Size() * 0.5f, 0.75f, SpriteEffects.None, 0); + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + color = Color.Lerp(Color.Yellow, Color.OrangeRed, completion); + if (completion >= 1) + color = Color.LightBlue; + + float count = MathHelper.Min((Projectile.minionSlots) * 2, 40); + for (var i = 0; i < count; i++) + { + var comp = (i / count); + var offset = ((Main.mouseTextColor - 190) / 64f) * 8; + if (i % 2 == 0) + offset = 8 - offset; + CalamityUtils.DrawLineBetter(Main.spriteBatch, Projectile.Center + new Vector2(26 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), Projectile.Center + new Vector2(40 + offset, 0).RotatedBy(MathHelper.TwoPi * comp - Main.GlobalTimeWrappedHourly), color, 1f); + } + Main.spriteBatch.End(); + } + + return false; + } + } +} diff --git a/Projectiles/Summon/SolarGod.png b/Projectiles/Summon/VengefulSunSpiritMinion.png similarity index 100% rename from Projectiles/Summon/SolarGod.png rename to Projectiles/Summon/VengefulSunSpiritMinion.png diff --git a/Projectiles/Summon/VictideSeaSnail.cs b/Projectiles/Summon/VictideSeaSnail.cs deleted file mode 100644 index 64a6a06fbe..0000000000 --- a/Projectiles/Summon/VictideSeaSnail.cs +++ /dev/null @@ -1,231 +0,0 @@ -using System; -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Summon -{ - public class VictideSeaSnail : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Summon"; - public ref float DustTimer => ref Projectile.localAI[0]; - public ref float FireCooldown => ref Projectile.localAI[1]; - public ref float PeekingOut => ref Projectile.ai[0]; - public ref float PlayerStandStillTimer => ref Projectile.ai[1]; - - public const int frameTime = 6; - public const int timeToStandStillBeforePeekOut = 200; - - public bool CanComePeekOut => !Main.player[Projectile.owner].mount.Active && PlayerStandStillTimer >= timeToStandStillBeforePeekOut || Projectile.frame > 0; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionSacrificable[Type] = true; - Main.projFrames[Type] = 7; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 30; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.minion = true; - Projectile.minionSlots = 0f; - Projectile.timeLeft = 18000; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - Projectile.DamageType = DamageClass.Summon; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - if (!modPlayer.victideSummoner) - { - for (int d = 0; d < 45; d++) - { - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.BubbleBurst_Purple, 0f, 0f, 0, default, 1f); - dust.velocity *= 2f; - dust.scale *= 1.15f; - } - Projectile.active = false; - return; - } - - if (player.dead) - modPlayer.victideSnail = false; - - if (modPlayer.victideSnail) - Projectile.timeLeft = 2; - - //Create a burst of dust as it gets created - DustTimer++; - if (DustTimer <= 3) - { - int dustAmount = Main.rand.Next(40, 50); - for (int d = 0; d < dustAmount; d++) - { - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.BubbleBurst_Purple, 0f, 0f, 0, default, 1f); - dust.velocity *= 2f; - dust.scale *= 1.15f; - } - } - - if (player.velocity.Length() == 0) - { - PlayerStandStillTimer++; - //pop out the shell - if (PlayerStandStillTimer == timeToStandStillBeforePeekOut) - { - DustTimer = 0; - float direction = Main.rand.NextBool() ? 1f : -1f; - Projectile.velocity = new Vector2(Main.rand.NextFloat(4f, 10f) * direction, Main.rand.NextFloat(-6f, 0f)); - } - - Projectile.velocity *= 0.98f; - Projectile.velocity.X *= 0.95f; - Projectile.velocity.Y = Math.Min(Projectile.velocity.Y + 0.1f, 14f); - Projectile.tileCollide = true; - - if (CanComePeekOut) - Projectile.rotation = Projectile.rotation.AngleTowards(0, MathHelper.PiOver4 * 0.14f); - - if (PeekingOut > 0) - { - Projectile.frameCounter++; - if (Projectile.frameCounter > frameTime) - { - Projectile.frameCounter = 0; - Projectile.frame = Math.Min(6, Projectile.frame + 1); - } - } - } - - //Go back, in the shell - if (player.velocity.Length() > 0 && CanComePeekOut) - { - Projectile.frameCounter++; - if (Projectile.frameCounter > frameTime) - { - Projectile.frameCounter = 0; - Projectile.frame--; - } - - if (Projectile.frame == 0) - { - PlayerStandStillTimer = 0f; - } - } - - if (!CanComePeekOut) - { - PeekingOut = 0f; - - if (player.velocity.Length() > 0) - PlayerStandStillTimer = 0f; - - Projectile.velocity = Vector2.Zero; - Projectile.tileCollide = false; - Vector2 desiredPosition = player.Center + Vector2.UnitY * (player.gfxOffY - 60f) * player.gravDir; - //Round the result so it doesn't jitter. - desiredPosition = new Vector2((int)desiredPosition.X, (int)desiredPosition.Y); - - Projectile.rotation += MathHelper.PiOver4 * 0.2f; - - Projectile.Center = Projectile.Center.MoveTowards(desiredPosition, 7f + player.velocity.Length()); - } - - //Fire a projectile - if (Projectile.owner == Main.myPlayer) - { - if (FireCooldown > 0f) - { - FireCooldown--; - return; - } - - bool foundTarget = false; - float maxDist = 300f; - foreach (NPC npc in Main.ActiveNPCs) - { - 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)) - { - foundTarget = true; - break; - } - } - } - - if (foundTarget) - { - int projAmt = Main.rand.Next(3, 7); - for (int u = 0; u < projAmt; u++) - { - Vector2 source = new Vector2(Projectile.Center.X - 4f, Projectile.Center.Y); - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, velocity, ModContent.ProjectileType(), Projectile.damage, 1f, Projectile.owner); - } - - SoundEngine.PlaySound(SoundID.Item42, Projectile.position); - FireCooldown = 60f; - } - } - - if ((Projectile.Center - player.Center).Length() > 400) - { - DustTimer = 0; - Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f) * player.gravDir; - PlayerStandStillTimer = 0f; - Projectile.frame = 0; - } - } - - public override bool? CanDamage() => false; - - public override void OnKill(int timeLeft) - { - for (int d = 0; d < 45; d++) - { - Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.BubbleBurst_Purple, 0f, 0f, 0, default, 1f); - dust.velocity *= 2f; - dust.scale *= 1.15f; - } - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - //Touches the ground - if (oldVelocity.Y >= 0) - { - PeekingOut = 1f; - } - return false; - } - - public override bool PreDraw(ref Color lightColor) - { - Player owner = Main.player[Projectile.owner]; - - Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle frame = new Rectangle(0, 36 * Projectile.frame, 38, 34); - Vector2 origin = !CanComePeekOut ? new Vector2(15, 23) : frame.Size() / 2f; - - //Look at the player - SpriteEffects flipperoni = Math.Sign(Projectile.position.X - owner.position.X) > 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, lightColor, Projectile.rotation, origin, Projectile.scale, flipperoni, 0); - - return false; - } - } -} diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index d17ed5e292..13b0cb3416 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -1,5 +1,4 @@ -using System.IO; -using CalamityMod.Buffs.Summon; +using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -18,6 +17,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 3; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -39,16 +39,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.localNPCHitCooldown = 60; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Projectile.Calamity().lineColor); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - Projectile.Calamity().lineColor = reader.ReadInt32(); - } - public override void AI() { Player player = Main.player[Projectile.owner]; @@ -56,7 +46,7 @@ namespace CalamityMod.Projectiles.Summon if (spawnDust) { - Projectile.Calamity().lineColor = -1; + Projectile.ai[1] = -1; int dustAmt = 36; for (int d = 0; d < dustAmt; d++) { @@ -115,7 +105,7 @@ namespace CalamityMod.Projectiles.Summon { spawnDust = true; } - int npcIndex = Projectile.Calamity().lineColor; + int npcIndex = (int)Projectile.ai[1]; if (Projectile.localAI[0] >= 600000f) //tryna make it stay on there "forever" without glitching { breakAway = true; @@ -146,25 +136,19 @@ namespace CalamityMod.Projectiles.Summon if (Projectile.owner == Main.myPlayer) { if (eaterCooldown > 0) - eaterCooldown -= Main.rand.Next(1, 3); + eaterCooldown--; if (eaterCooldown <= 0) { - int projNumber = Main.rand.Next(1, 3); - for (int index2 = 0; index2 < projNumber; index2++) - { - float xVector = (float)Main.rand.Next(-35, 36) * 0.02f; - float yVector = (float)Main.rand.Next(-35, 36) * 0.02f; - xVector *= 10f; - yVector *= 10f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, xVector, yVector, ModContent.ProjectileType(), (int)(Projectile.damage * 1.25f), Projectile.knockBack, Projectile.owner); - } - eaterCooldown = 80; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(7f, 7f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + eaterCooldown = Projectile.localNPCHitCooldown; } } } } + public override bool MinionContactDamage() => true; + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { Player player = Main.player[Projectile.owner]; @@ -209,7 +193,7 @@ namespace CalamityMod.Projectiles.Summon //let the projectile know it is sticking and the npc it is sticking too Projectile.ai[0] = 3f; - Projectile.Calamity().lineColor = npcIndex; + Projectile.ai[1] = npcIndex; //follow the NPC Projectile.velocity = (npc.Center - Projectile.Center) * 0.75f; @@ -222,7 +206,7 @@ namespace CalamityMod.Projectiles.Summon for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { Projectile proj = Main.projectile[projIndex]; - if (projIndex != Projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == Projectile.type && proj.ai[0] == 3f && proj.Calamity().lineColor == npcIndex) + if (projIndex != Projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == Projectile.type && proj.ai[0] == 3f && proj.ai[1] == npcIndex) { array2[projCount++] = new Point(projIndex, proj.timeLeft); if (projCount >= array2.Length) diff --git a/Projectiles/Summon/ViridVanguardBlade.cs b/Projectiles/Summon/ViridVanguardBlade.cs index d8180d7698..12833d3ce9 100644 --- a/Projectiles/Summon/ViridVanguardBlade.cs +++ b/Projectiles/Summon/ViridVanguardBlade.cs @@ -1,7 +1,10 @@ using System; +using System.Collections.Generic; using System.IO; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.Summon; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -23,6 +26,10 @@ namespace CalamityMod.Projectiles.Summon HorizontalSlashes, VerticalPierceTeleport, RegularPierceSlashes, + ChargingCircle, + PhotonRipperZenithSlashes, + PhotonRipperZenithEndlag, + AxeCircle } public int BladeIndex; @@ -31,15 +38,15 @@ namespace CalamityMod.Projectiles.Summon public Vector2 ChargeStartingPosition; + public float BladeAngleForPhripperZenith = 0; + + public int CurrentViridCount => (int)MathHelper.Max(1, Owner.ownedProjectileCounts[Type]); + public float BladeHoverOffsetAngle { get { - float projectileCounts = Owner.ownedProjectileCounts[Type]; - if (projectileCounts <= 1f) - projectileCounts = 1f; - - return MathHelper.TwoPi * BladeIndex / projectileCounts + AITimer / 27f; + return MathHelper.TwoPi * BladeIndex / CurrentViridCount + Owner.Calamity().ViridVanguardRotation * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1); } } @@ -49,14 +56,52 @@ namespace CalamityMod.Projectiles.Summon set => Projectile.ai[0] = (int)value; } + public static List ActiveAttackStateList = new() { ViridVanguardAIState.ChargingCircle, ViridVanguardAIState.PhotonRipperZenithSlashes, ViridVanguardAIState.PhotonRipperZenithEndlag }; + + public Player Owner => Main.player[Projectile.owner]; public ref float AITimer => ref Projectile.ai[1]; + public float ActiveTimer + { + get => Owner.Calamity().ViridVanguardActiveCooldown; + set => Owner.Calamity().ViridVanguardActiveCooldown = value; + } + + public bool IsAxe => BladeIndex % 2 == 0; + + public bool DrawAsAxe => IsInDotRange && CurrentState == ViridVanguardAIState.PhotonRipperZenithSlashes ? !ActiveAttacking : IsAxe; + + bool IsInDotRange = false; + + bool ActiveAttacking = false; + + Vector2 StoredAttackMousePos = Vector2.Zero; + public ref float BladeGleamInterpolant => ref Projectile.localAI[0]; + #region AI consts + public const int HorizontalSlashChargeTime = 14; + + public const float HorizontalSlashSpeed = 44f; + + public const int VerticalSlashChargeTime = 32; + + public const float VerticalSlashSpeed = 45f; + + public const float VerticalTeleportOffset = 850f; + + public const int PierceChargeAttackCycleTime = 44; + + public const float MaxTargetingDistance = 1550f; + + + #endregion + public override void SetStaticDefaults() { + ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; ProjectileID.Sets.TrailingMode[Type] = 2; ProjectileID.Sets.TrailCacheLength[Type] = 45; @@ -64,8 +109,8 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { - Projectile.width = 84; - Projectile.height = 84; + Projectile.width = 120; + Projectile.height = 120; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; @@ -91,6 +136,8 @@ namespace CalamityMod.Projectiles.Summon ChargeStartingPosition = reader.ReadVector2(); } + public override bool MinionContactDamage() => true; + public override void AI() { // Decide whether the minion should still exist. @@ -104,7 +151,7 @@ namespace CalamityMod.Projectiles.Summon if (BladeGleamInterpolant <= 0.02f) BladeGleamInterpolant = 0f; - NPC potentialTarget = Projectile.Center.MinionHoming(ViridVanguard.MaxTargetingDistance, Owner); + NPC potentialTarget = Projectile.Center.MinionHoming(MaxTargetingDistance, Owner); switch (CurrentState) { case ViridVanguardAIState.CircleOwner: @@ -119,24 +166,43 @@ namespace CalamityMod.Projectiles.Summon case ViridVanguardAIState.RegularPierceSlashes: DoBehavior_RegularPierceSlashes(potentialTarget); break; + case ViridVanguardAIState.ChargingCircle: + DoBehavior_PhotonRipperZenithStartup(potentialTarget); + break; + case ViridVanguardAIState.PhotonRipperZenithSlashes: + DoBehavior_PhotonRipperZenithActive(potentialTarget); + break; + case ViridVanguardAIState.PhotonRipperZenithEndlag: + DoBehavior_PhotonRipperZenithEndlag(potentialTarget); + break; + case ViridVanguardAIState.AxeCircle: + DoBehavior_AxeCircle(potentialTarget); + break; } AITimer++; + if (CurrentState == ViridVanguardAIState.PhotonRipperZenithEndlag) + Projectile.MaxUpdates = 1; } public void DoBehavior_CircleOwner(NPC potentialTarget) { + //Reset active cooldown if it's in the negative somehow + if (ActiveTimer < 0) + ActiveTimer = ViridVanguard.ActiveAttackCooldown; + // Begin attacking if an enemy is nearby. + var viridAmount = 300f / CurrentViridCount; if (potentialTarget is not null) { - CurrentState = ViridVanguardAIState.HorizontalSlashes; + CurrentState = IsAxe ? ViridVanguardAIState.AxeCircle : ViridVanguardAIState.HorizontalSlashes; AITimer = 0f; Projectile.netUpdate = true; return; } - - Vector2 hoverDestination = Owner.Center + BladeHoverOffsetAngle.ToRotationVector2() * 200f; - Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, 16f); + float hoverDistMult = MathHelper.Lerp(IsAxe ? 170 : 200, IsAxe ? 200 : 170, (MathF.Sin(AITimer * 0.06f) + 1) * 0.5f); + Vector2 hoverDestination = Owner.Center + BladeHoverOffsetAngle.ToRotationVector2() * hoverDistMult; + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, 20f); Projectile.velocity *= 0.8f; // Teleport to the owner if sufficiently far away. @@ -150,10 +216,35 @@ namespace CalamityMod.Projectiles.Summon Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; } + public void DoBehavior_AxeCircle(NPC potentialTarget) + { + // Begin attacking if an enemy is nearby. + var viridAmount = 300f / CurrentViridCount; + if (potentialTarget is null) + { + ReturnToIdleState(); + return; + } + var offset = MathHelper.TwoPi * MathF.Floor(BladeIndex * 0.5f) / MathF.Ceiling(CurrentViridCount * 0.5f) + Owner.Calamity().ViridVanguardRotation * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1); + Vector2 hoverDestination = Owner.Center + offset.ToRotationVector2() * 200f; + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, 32f); + Projectile.velocity *= 0.8f; + + // Teleport to the owner if sufficiently far away. + if (!Projectile.WithinRange(Owner.Center, 2500f)) + { + Projectile.Center = hoverDestination; + Projectile.netUpdate = true; + } + Owner.Calamity().ViridVanguardRotationToAdd = ViridVanguard.IdleCirclingSpeed * MathHelper.SmoothStep(1f, ViridVanguard.AxeCirclingSpeedMultiplier, AITimer / 150f); + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } + public void DoBehavior_HorizontalSlashes(NPC target) { int hoverTime = 22; - int chargeTime = ViridVanguard.HorizontalSlashChargeTime; + int chargeTime = HorizontalSlashChargeTime; // Exit the attack state if the blade no longer has a valid target. if (target is null) @@ -193,15 +284,15 @@ namespace CalamityMod.Projectiles.Summon { SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.27f }, Projectile.Center); Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; - Projectile.velocity = Vector2.UnitX * (target.Center.X > Projectile.Center.X).ToDirectionInt() * ViridVanguard.HorizontalSlashSpeed; + Projectile.velocity = Vector2.UnitX * (target.Center.X > Projectile.Center.X).ToDirectionInt() * HorizontalSlashSpeed; Projectile.netUpdate = true; } // Switch to the next attack state once enough charges have happened. - if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.ChargesPerAttackCycle) + if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.HorizontalSlashAmount) { AITimer = 0f; - CurrentState = ViridVanguardAIState.VerticalPierceTeleport; + CurrentState = ViridVanguardAIState.RegularPierceSlashes; Projectile.netUpdate = true; } } @@ -209,7 +300,7 @@ namespace CalamityMod.Projectiles.Summon public void DoBehavior_VerticalPierceTeleport(NPC target) { int hoverTime = 26; - int chargeTime = ViridVanguard.VerticalSlashChargeTime; + int chargeTime = VerticalSlashChargeTime; // Exit the attack state if the blade no longer has a valid target. if (target is null) @@ -246,30 +337,30 @@ namespace CalamityMod.Projectiles.Summon { SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.27f }, Projectile.Center); Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; - Projectile.velocity = Vector2.UnitY * ViridVanguard.VerticalSlashSpeed; + Projectile.velocity = Vector2.UnitY * VerticalSlashSpeed; Projectile.netUpdate = true; } // Teleport above the target once sufficiently far below them. - if (wrappedAttackTimer >= hoverTime + 5f && Projectile.Center.Y > target.Center.Y + ViridVanguard.VerticalTeleportOffset) + if (wrappedAttackTimer >= hoverTime + 5f && Projectile.Center.Y > target.Center.Y + VerticalTeleportOffset) { Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; - Projectile.Center = target.Center - Vector2.UnitY * ViridVanguard.VerticalTeleportOffset * 0.7f; + Projectile.Center = target.Center - Vector2.UnitY * VerticalTeleportOffset * 0.7f; Projectile.netUpdate = true; } // Switch to the next attack state once enough charges have happened. - if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.ChargesPerAttackCycle) + if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.VerticalPierceAmount) { AITimer = 0f; - CurrentState = ViridVanguardAIState.RegularPierceSlashes; + CurrentState = ViridVanguardAIState.HorizontalSlashes; Projectile.netUpdate = true; } } public void DoBehavior_RegularPierceSlashes(NPC target) { - int attackCycleTime = ViridVanguard.PierceChargeAttackCycleTime; + int attackCycleTime = PierceChargeAttackCycleTime; float upwardRiseTimeRatio = 0.4f; float pierceTimeRatio = 0.14f; @@ -282,14 +373,13 @@ namespace CalamityMod.Projectiles.Summon } // Initialize the starting position on the first frame. - int localAITimer = (int)AITimer + Projectile.identity; - if (localAITimer % attackCycleTime == 1f) + if (AITimer % attackCycleTime == 1f) { ChargeStartingPosition = Projectile.Center + Main.rand.NextVector2Circular(80f, 80f); Projectile.netUpdate = true; } - float attackCompletion = localAITimer / (float)attackCycleTime % 1f; + float attackCompletion = AITimer / (float)attackCycleTime % 1f; // Reset the trail point array if aiming at the target. if (attackCompletion < upwardRiseTimeRatio) @@ -319,21 +409,137 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity = Vector2.Zero; // Play a slice sound once ready to charge. - if (localAITimer % attackCycleTime == (int)(attackCycleTime * upwardRiseTimeRatio)) + if (AITimer % attackCycleTime == (int)(attackCycleTime * upwardRiseTimeRatio)) SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.27f }, Projectile.Center); // Switch to the next attack state once enough charges have happened. - if (localAITimer >= attackCycleTime * ViridVanguard.ChargesPerAttackCycle) + if (AITimer >= attackCycleTime * ViridVanguard.StabAmount) { AITimer = 0f; - CurrentState = ViridVanguardAIState.HorizontalSlashes; + CurrentState = ViridVanguardAIState.VerticalPierceTeleport; Projectile.netUpdate = true; } } + public void DoBehavior_PhotonRipperZenithStartup(NPC target) + { + Projectile.MaxUpdates = 2; + float completion = AITimer / (ViridVanguard.ActiveAttackStartup * (float)Projectile.MaxUpdates); + Vector2 hoverDestination = Owner.Center + (BladeAngleForPhripperZenith * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1)).ToRotationVector2() * MathHelper.Lerp(200f, 116f, completion); + + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, MathHelper.Lerp(16f, 64f, completion)); + Projectile.velocity *= 0.8f; + Owner.Calamity().ViridVanguardRotationToAdd = MathHelper.Lerp(1, ViridVanguard.ActiveAttackCirclingSpeedMultiplier, completion) * ViridVanguard.IdleCirclingSpeed; + BladeAngleForPhripperZenith += Owner.Calamity().ViridVanguardRotationToAdd / Projectile.MaxUpdates; + ActiveTimer = -1; + IsInDotRange = false; + + if (completion >= 1f) + { + CurrentState = ViridVanguardAIState.PhotonRipperZenithSlashes; + Projectile.netUpdate = true; + } + + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } + public void DoBehavior_PhotonRipperZenithActive(NPC target) + { + Projectile.MaxUpdates = 2; + Vector2 angleToMouse = Owner.DirectionTo(IsInDotRange ? StoredAttackMousePos : Owner.Calamity().mouseWorld); + + float dotResult = Vector2.Dot(angleToMouse, BladeAngleForPhripperZenith.ToRotationVector2()); + + if (dotResult < -0.5f) + { + IsInDotRange = false; + ActiveAttacking = false; + } + else if (!IsInDotRange) + { + IsInDotRange = true; + StoredAttackMousePos = Owner.Calamity().mouseWorld; + ActiveTimer--; + + if (ActiveTimer % 2 == 0) + { + ActiveAttacking = true; + Projectile.ResetLocalNPCHitImmunity(); + } + } + dotResult += 1f; + dotResult /= 2f; + if (!ActiveAttacking) + { + Vector2 hoverDestination = Owner.Center + (BladeAngleForPhripperZenith * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1)).ToRotationVector2() * 116f; + Projectile.Center = hoverDestination; + Projectile.velocity *= 0.8f; + + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + if ((ActiveTimer < -2 * ViridVanguard.ActiveAttackSlashCount * CurrentViridCount || ActiveTimer > 0) && Projectile.FinalExtraUpdate()) + { + CurrentState = ViridVanguardAIState.PhotonRipperZenithEndlag; + ActiveTimer = ViridVanguard.ActiveAttackCooldown; + AITimer = 0; + } + } + else + { + float distance = Owner.Distance(StoredAttackMousePos); + float endSize = MathHelper.Clamp(distance * 0.25f, 164f, 300f); + Vector2 hoverCenter = Vector2.Lerp(Owner.Center, Owner.Center + Owner.Center.DirectionTo(StoredAttackMousePos) * (distance > 164 ? distance - endSize : 0), dotResult); + Vector2 finalHoverDestination = hoverCenter + (BladeAngleForPhripperZenith * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1)).ToRotationVector2() * MathHelper.Lerp(116f, endSize, dotResult); + Projectile.Center = finalHoverDestination; + Projectile.velocity *= 0.8f; + Projectile.rotation = Projectile.AngleFrom(hoverCenter) + MathHelper.PiOver2; + } + + Owner.Calamity().ViridVanguardRotationToAdd = ViridVanguard.ActiveAttackCirclingSpeedMultiplier * ViridVanguard.IdleCirclingSpeed; + BladeAngleForPhripperZenith += Owner.Calamity().ViridVanguardRotationToAdd / Projectile.MaxUpdates; + + } + public void DoBehavior_PhotonRipperZenithEndlag(NPC target) + { + + Projectile.MaxUpdates = 1; + float completion = 1 - AITimer / (ViridVanguard.ActiveAttackEndlag * (float)Projectile.MaxUpdates); + if (Owner.Calamity().ViridVanguardActiveAttackerThisFrame) + { + AITimer = 0; + ActiveTimer = ViridVanguard.ActiveAttackCooldown; + completion = 1; + } + Vector2 hoverDestination = Owner.Center + (BladeAngleForPhripperZenith * (Owner.Calamity().InvertExaltationLineRotationDirections ? -1 : 1)).ToRotationVector2() * MathHelper.Lerp(200f, 116f, completion); + Projectile.Center = hoverDestination; + Projectile.velocity *= 0.8f; + Owner.Calamity().ViridVanguardRotationToAdd = MathHelper.Lerp(1, ViridVanguard.ActiveAttackCirclingSpeedMultiplier, completion) * ViridVanguard.IdleCirclingSpeed; + BladeAngleForPhripperZenith += Owner.Calamity().ViridVanguardRotationToAdd / Projectile.MaxUpdates; + + if (completion <= 0f) + { + ReturnToIdleState(); + Owner.Calamity().ViridVanguardRotation += MathHelper.WrapAngle(BladeAngleForPhripperZenith - BladeHoverOffsetAngle); //This will cause the proper rotation to be kept on completion + Projectile.netUpdate = true; + } + + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } + + public void BeginSuperEpicPhotonRipperZenithKnockoffAttack() + { + + if (CurrentState != ViridVanguardAIState.CircleOwner) + AITimer = 0f; + BladeAngleForPhripperZenith = BladeHoverOffsetAngle; + CurrentState = ViridVanguardAIState.ChargingCircle; + AITimer = 0f; + Projectile.netUpdate = true; + } public void ReturnToIdleState() { AITimer = 0f; + Projectile.extraUpdates = 0; CurrentState = ViridVanguardAIState.CircleOwner; Projectile.netUpdate = true; } @@ -344,28 +550,54 @@ namespace CalamityMod.Projectiles.Summon if (Projectile.type == ModContent.ProjectileType()) { if (Owner.dead) - Owner.Calamity().ViridVanguard = false; + Owner.Calamity().viridVanguard = false; - if (Owner.Calamity().ViridVanguard) + if (Owner.Calamity().viridVanguard) Projectile.timeLeft = 2; } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.Calamity().sagePoisonDamage = (int)(SagePoison.debuffData.EnemyLostRegen * SagePoison.ViridVanguardPoisonMultiplier * CurrentViridCount); + target.AddBuff(ModContent.BuffType(), 60); + if (ActiveAttacking) + { + Vector2 vel = new Vector2(0.1f, 0.1f).RotatedByRandom(100); + VoidSparkParticle spark2 = new VoidSparkParticle(target.Center, vel, false, 9, Main.rand.NextFloat(0.25f, 0.35f), Main.rand.NextBool() ? Color.LimeGreen : Color.Goldenrod); + GeneralParticleHandler.SpawnParticle(spark2); + SoundEngine.PlaySound(CommonCalamitySounds.SwiftSliceSound with { Volume = CommonCalamitySounds.SwiftSliceSound.Volume * 0.3f, MaxInstances = 0 }, Projectile.Center); + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + //Deals massively increased damage during the active attack + if (ActiveAttacking) + modifiers.SourceDamage *= ViridVanguard.ActiveAttackSlashDmgMult; + //when not using the active, deal the right amount of damage for the swords vs axes + else if (!ActiveAttackStateList.Contains(CurrentState)) + if (IsAxe) + modifiers.SourceDamage *= ViridVanguard.AxeDmgMult; + else + modifiers.SourceDamage *= ViridVanguard.SwordDmgMult; + } + public Color TrailColorFunction(float completionRatio) { - float opacity = (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D) * Projectile.Opacity * 0.48f; + float opacity = (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D) * Projectile.Opacity * (CurrentState == ViridVanguardAIState.CircleOwner ? 0.3f : 0.48f); return Color.Lerp(new(115, 196, 127), Color.Yellow, MathHelper.Clamp(completionRatio * 1.4f, 0f, 1f)) * opacity; } - public float TrailWidthFunction(float completionRatio) => Projectile.height * (1f - completionRatio) * 0.8f; + public float TrailWidthFunction(float completionRatio) => Projectile.height * (1f - completionRatio) * (DrawAsAxe ? 0.6f : 0.8f); public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Rectangle frame = texture.Frame(2, 1, DrawAsAxe ? 0 : 1, 0); Vector2 origin = frame.Size() * 0.5f; Vector2 drawPosition = Projectile.Center - Main.screenPosition; - SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + SpriteEffects direction = Projectile.spriteDirection == 1 ^ Owner.Calamity().InvertExaltationLineRotationDirections ? SpriteEffects.FlipHorizontally : SpriteEffects.None; // Draw the afterimage trail. TrailDrawer ??= new(); @@ -378,18 +610,34 @@ namespace CalamityMod.Projectiles.Summon Main.pixelShader.CurrentTechnique.Passes[0].Apply(); // Draw the blade. - Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation + 0.2f, origin, Projectile.scale, direction, 0); + float outlineOpacity = 1; + float outlineWidth = 1; + Color outlineColor = Color.LimeGreen; + if (!(ActiveAttackStateList.Contains(CurrentState) && ActiveTimer > 0)) + { + outlineWidth = Math.Clamp(MathF.Pow(1 - ActiveTimer / ViridVanguard.ActiveAttackCooldown, 3), 0, 1); + outlineOpacity = 0.75f; + } + var outlineTex = ViridVanguard.GetBladeOutlineTex(); + var rotation = Projectile.rotation + (DrawAsAxe ^ Owner.Calamity().InvertExaltationLineRotationDirections ? -0.2f : 0.2f); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(2, 0) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(0, 2) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(-2, 0) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(0, -2) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, direction, 0); // Draw the gleam at the tip of the blade. - Texture2D shineTex = ModContent.Request("CalamityMod/Particles/HalfStar").Value; - Vector2 shineScale = new Vector2(1.67f, 3f) * Projectile.scale; - shineScale *= MathHelper.Lerp(0.9f, 1.1f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 7.4f + Projectile.identity) * 0.5f + 0.5f); - - Vector2 lensFlareWorldPosition = Projectile.Center + (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * Projectile.width * Projectile.scale * 0.88f; - Color lensFlareColor = Color.Lerp(Color.LimeGreen, Color.Yellow, 0.23f) with { A = 0 } * BladeGleamInterpolant; - Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, 0f, shineTex.Size() * 0.5f, shineScale * 0.6f, 0, 0); - Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, MathHelper.PiOver2, shineTex.Size() * 0.5f, shineScale, 0, 0); + if (ActiveTimer <= 0) + { + Texture2D shineTex = ModContent.Request("CalamityMod/Particles/HalfStar").Value; + Vector2 shineScale = new Vector2(1.67f, 3f) * Projectile.scale; + shineScale *= MathHelper.Lerp(0.9f, 1.1f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 7.4f + Projectile.identity) * 0.5f + 0.5f); + Vector2 lensFlareWorldPosition = Projectile.Center + (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * Projectile.width * Projectile.scale * 0.88f; + Color lensFlareColor = Color.Lerp(Color.LimeGreen, Color.Yellow, 0.23f) with { A = 0 } * BladeGleamInterpolant; + Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, 0f, shineTex.Size() * 0.5f, shineScale * 0.6f, 0, 0); + Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, MathHelper.PiOver2, shineTex.Size() * 0.5f, shineScale, 0, 0); + } // Reset textures for shaders, since they're only defined once at load-time in vanilla. GameShaders.Misc["EmpressBlade"].UseImage0("Images/Extra_209"); GameShaders.Misc["EmpressBlade"].UseImage1("Images/Extra_210"); diff --git a/Projectiles/Summon/ViridVanguardBlade.png b/Projectiles/Summon/ViridVanguardBlade.png index e2cbaf2040..6621e5b1c6 100644 Binary files a/Projectiles/Summon/ViridVanguardBlade.png and b/Projectiles/Summon/ViridVanguardBlade.png differ diff --git a/Projectiles/Summon/VoidConcentrationAura.cs b/Projectiles/Summon/VoidConcentrationAura.cs index 37970e73a4..1d9f07ff49 100644 --- a/Projectiles/Summon/VoidConcentrationAura.cs +++ b/Projectiles/Summon/VoidConcentrationAura.cs @@ -29,6 +29,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft *= 5; Projectile.minion = true; Projectile.DamageType = DamageClass.Summon; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void SendExtraAI(BinaryWriter writer) @@ -89,5 +91,7 @@ namespace CalamityMod.Projectiles.Summon return; timer++; } + + public override bool MinionContactDamage() => true; } } diff --git a/Projectiles/Summon/VoidConcentrationBlackhole.cs b/Projectiles/Summon/VoidConcentrationBlackhole.cs index b79ca5a550..efed72d73c 100644 --- a/Projectiles/Summon/VoidConcentrationBlackhole.cs +++ b/Projectiles/Summon/VoidConcentrationBlackhole.cs @@ -45,6 +45,8 @@ namespace CalamityMod.Projectiles.Summon Projectile.tileCollide = false; Projectile.scale = 0.01f; Projectile.DamageType = DamageClass.Summon; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } private void ApplySucc(NPC npc) diff --git a/Projectiles/Summon/VoidEaterMarionetteBody.png b/Projectiles/Summon/VoidEaterMarionetteBody.png new file mode 100644 index 0000000000..0d5aadbd4a Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteBody.png differ diff --git a/Projectiles/Summon/VoidEaterMarionetteBodyGlow.png b/Projectiles/Summon/VoidEaterMarionetteBodyGlow.png new file mode 100644 index 0000000000..61f52b6db2 Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteBodyGlow.png differ diff --git a/Projectiles/Summon/VoidEaterMarionetteHead.png b/Projectiles/Summon/VoidEaterMarionetteHead.png new file mode 100644 index 0000000000..27da9417cc Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteHead.png differ diff --git a/Projectiles/Summon/VoidEaterMarionetteHeadGlow.png b/Projectiles/Summon/VoidEaterMarionetteHeadGlow.png new file mode 100644 index 0000000000..35acff8531 Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteHeadGlow.png differ diff --git a/Projectiles/Summon/VoidEaterMarionetteJaw.png b/Projectiles/Summon/VoidEaterMarionetteJaw.png new file mode 100644 index 0000000000..837dd953f8 Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteJaw.png differ diff --git a/Projectiles/Summon/VoidEaterMarionetteJawGlow.png b/Projectiles/Summon/VoidEaterMarionetteJawGlow.png new file mode 100644 index 0000000000..a1a253ff24 Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteJawGlow.png differ diff --git a/Projectiles/Summon/VoidEaterMarionetteProjectile.cs b/Projectiles/Summon/VoidEaterMarionetteProjectile.cs new file mode 100644 index 0000000000..70bae45554 --- /dev/null +++ b/Projectiles/Summon/VoidEaterMarionetteProjectile.cs @@ -0,0 +1,572 @@ +using System; +using System.Collections.Generic; +using System.IO; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.NPCs; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class VoidEaterMarionetteProjectile : BaseWormProjectile, ILocalizedModType + { + #region Balancing + public float ContactDamageMult => 0.6f + Projectile.minionSlots * 0.4f; + public static int EffectiveContactIframes => 10; + + public float BlueFireballDamageMult => Projectile.minionSlots * 1.1f; + public static int EffectiveBlueFireIframes => 10; + + public float PurpleFireballDamageMult => Projectile.minionSlots * 1.1f; + public static int EffectivePurpleFireIframes => 10; + + #endregion + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/Summon/VoidEaterMarionetteHead"; + + public override string GlowTexture => "CalamityMod/Projectiles/Summon/VoidEaterMarionetteHeadGlow"; + public override List SegmentTextures => new() + { + "CalamityMod/Projectiles/Summon/VoidEaterMarionetteBody", + "CalamityMod/Projectiles/Summon/VoidEaterMarionetteTail" + }; + + public override int SegmentCount => (int)(Projectile.minionSlots); + + public override List SegmentTypePositionOffsets => new() + { + 54, //Head + 38, //Body + 52 //Tail + }; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionSacrificable[Type] = true; + ProjectileID.Sets.MinionTargettingFeature[Type] = true; + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + Projectile.width = 24; + Projectile.height = 24; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.netImportant = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 5; + Projectile.tileCollide = false; + Projectile.minion = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.MaxUpdates = 2; + Projectile.localNPCHitCooldown = EffectiveContactIframes * Projectile.MaxUpdates; + Projectile.DamageType = DamageClass.Summon; + } + + public enum AttackState + { + Idle, + DivinityDevourer, + FaithIncinerator, + UltracosmicMaelstrom, + PlayingFetch + } + /// + /// Used to increase the length of / slots required by the minion + /// + public int MinionSlotsToAdd + { + get { return (int)Projectile.ai[0]; } + set { Projectile.ai[0] = value; } + } + public AttackState CurrentAttack + { + get { return (AttackState)Projectile.ai[1]; } + set { Projectile.ai[1] = (float)value; } + } + + public int AiTimer + { + get { return (int)Projectile.ai[2]; } + set { Projectile.ai[2] = value; } + } + + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer ModOwner => Owner.Calamity(); + + public Vector2 EntrancePortalLocation = Vector2.Zero; + public Vector2 ExitPortalLocation = Vector2.Zero; + bool TightHoming = false; + public bool FocusOnFetching = false; + public float JawOpeningAmount = 0; + + public override void SendExtraAI(BinaryWriter writer) + { + base.SendExtraAI(writer); + writer.Write(FocusOnFetching); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + base.ReceiveExtraAI(reader); + FocusOnFetching = reader.ReadBoolean(); + } + + public override void AI() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Owner.dead) + ModOwner.hasVoidEaterMarionette = false; + if (ModOwner.hasVoidEaterMarionette) + Projectile.timeLeft = 2; + + #region Update Segment Count + if (MinionSlotsToAdd > 0) + { + float minionSlotsAvaliable = Owner.maxMinions; + foreach (var item in Main.ActiveProjectiles) + { + if (item.owner == Projectile.owner) + minionSlotsAvaliable -= item.minionSlots; + } + while (minionSlotsAvaliable >= 1 && MinionSlotsToAdd > 0) + { + + Projectile.minionSlots++; + minionSlotsAvaliable--; + MinionSlotsToAdd--; + } + MinionSlotsToAdd = 0; + } + + bool UpdatedSegmentCount = false; + while (Segments.Count < SegmentCount) + { + UpdatedSegmentCount = true; + Segments.Add(new BaseWormSegment(this, 0)); + } + while (Segments.Count > SegmentCount) + { + UpdatedSegmentCount = true; + Segments.RemoveAt(Segments.Count - 1); + } + if (UpdatedSegmentCount) + { + foreach (var item in Segments) + { + item.segmentType = 0; + } + Segments[Segments.Count - 1].segmentType = 1; + } + #endregion + if (Projectile.minionSlots < 1) + { + Projectile.Kill(); + return; + } + int targetID = -1; + Projectile.Minion_FindTargetInRange(CalamityUtils.TilesToPixels(300), ref targetID, false); + NPC target = Projectile.Center.MinionHoming(CurrentAttack != AttackState.Idle ? 999999f : 2800f, Owner); + SegmentRigidity = 0.1f; + Projectile.extraUpdates = 1; + if (Owner.miscCounter % 10 == 0 && (CurrentAttack == AttackState.Idle || (FocusOnFetching && CurrentAttack != AttackState.UltracosmicMaelstrom))) + { + float SearchDistance = CalamityUtils.TilesToPixels(50); + AiTimer = -1; + foreach (var item in Main.ActiveItems) + { + if (item.noGrabDelay == 0 && !item.beingGrabbed && Owner.CanPullItem(item, Owner.ItemSpace(item)) && !item.IsACoin) + { + var dis = item.Distance(Projectile.Center); + if (dis > SearchDistance) + continue; + AiTimer = item.whoAmI; + SearchDistance = dis; + } + } + if (AiTimer > -1) + { + CurrentAttack = AttackState.PlayingFetch; + } + else if (CurrentAttack == AttackState.PlayingFetch) + CurrentAttack = AttackState.Idle; + } + + switch (CurrentAttack) + { + case AttackState.Idle: + { + var playerDistance = Projectile.Distance(Owner.Center); + float speed = 0.06f; + AiTimer = -1; + if (playerDistance > CalamityUtils.TilesToPixels(150)) + { + Projectile.Center = Owner.Center - Projectile.velocity.SafeNormalize(-Vector2.UnitY) * 200; + SpawnRiftProjectileAt(Projectile.Center); + Projectile.velocity = Projectile.velocity.ClampMagnitude(1, 8); + } + else + { + if (playerDistance > 1000f) + speed = 0.3f; + if (playerDistance > 200f) + speed = 0.2f; + else if (playerDistance > 140f) + speed = 0.12f; + if (playerDistance > 100) + Projectile.velocity += Projectile.DirectionTo(Owner.Center) * speed; + else if (Projectile.velocity.Length() > 1) + Projectile.velocity *= 0.96f; + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + if (target != null) + { + CurrentAttack = AttackState.DivinityDevourer; + AiTimer = 0; + } + JawOpeningAmount = MathHelper.Lerp(JawOpeningAmount,0, 0.1f); + break; + + } + + case AttackState.DivinityDevourer: + { + if (target == null) + { + CurrentAttack = AttackState.Idle; + AiTimer = 0; + TightHoming = false; + break; + } + var targetDistance = Projectile.Distance(target.Center); + float turnspeed = 0.01f; + + if (targetDistance > 500) + TightHoming = true; + if (TightHoming) + { + JawOpeningAmount = MathHelper.Lerp(JawOpeningAmount, 0.75f, 0.1f); + turnspeed = 0.2f; + var dot = Vector2.Dot(Projectile.velocity.SafeNormalize(Vector2.Zero), Projectile.DirectionTo(target.Center)); + if (dot < 0f && targetDistance < 200) + { + TightHoming = false; + turnspeed = 0; + } + } else + JawOpeningAmount = MathHelper.Lerp(JawOpeningAmount, 0f, 0.25f); + if (targetDistance > 0) + + Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(Projectile.DirectionTo(target.Center).ToRotation(), turnspeed).ToRotationVector2() * MathF.Min(Projectile.velocity.Length() + 1, 22f); + + Projectile.velocity *= 0.975f; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + AiTimer++; + if (AiTimer > 300 * Projectile.MaxUpdates) + { + CurrentAttack = AttackState.FaithIncinerator; + AiTimer = 0; + TightHoming = false; + } + break; + } + + case AttackState.FaithIncinerator: + { + if (target == null) + { + CurrentAttack = AttackState.Idle; + AiTimer = 0; + break; + } + + var targetDistance = Projectile.Distance(target.Center); + var targetDir = Projectile.DirectionTo(target.Center); + var targetDirToOwner = Owner.DirectionTo(target.Center); + var playerDistance = Projectile.Distance(Owner.Center); + Vector2 targetedPosition = target.Center; + float turnspeed = 0.05f; + if (TightHoming) + targetedPosition -= targetDir * 960f; + else + turnspeed = 0.15f; + + Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(Projectile.DirectionTo(targetedPosition).ToRotation(), turnspeed).ToRotationVector2() * MathF.Min(Projectile.velocity.Length() + 1, 10f); + if (targetDistance > 800f) + TightHoming = false; + else if (target.Hitbox.Intersects(Projectile.Hitbox)) + TightHoming = true; + + JawOpeningAmount = MathHelper.Lerp(JawOpeningAmount, 0, 0.1f); + if (Vector2.Dot(Projectile.velocity.SafeNormalize(Vector2.Zero), targetDir) > 0.8f && AiTimer % 30 == 0) + { + JawOpeningAmount = 0.75f; + if (Main.myPlayer == Projectile.owner) + { + for (int i = 0; i < 3; i++) + { + Vector2 perturbedSpeed = targetDir.RotatedBy(MathHelper.Lerp(-0.15f, 0.15f, i / 3f)) * 24f; + var p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * BlueFireballDamageMult), Projectile.knockBack, Projectile.owner, 2); + if (Main.projectile.IndexInRange(p)) + { + Main.projectile[p].hostile = false; + Main.projectile[p].friendly = true; + Main.projectile[p].DamageType = DamageClass.Summon; + Main.projectile[p].timeLeft = 120; + Main.projectile[p].scale = 0.5f; + Main.projectile[p].usesIDStaticNPCImmunity = true; + Main.projectile[p].idStaticNPCHitCooldown = EffectiveBlueFireIframes; + } + } + } + } + AiTimer++; + + if (AiTimer > 300 * Projectile.MaxUpdates) + { + CurrentAttack = AttackState.UltracosmicMaelstrom; + AiTimer = 0; + TightHoming = false; + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + break; + } + + case AttackState.UltracosmicMaelstrom: + { + int strikes = 6; + var targetPos = Owner.Center; + if (target != null) + { + targetPos = target.Center; + } + if (AiTimer > 0) + JawOpeningAmount = 0.5f; + float lastSegmentOpacity = Segments[Segments.Count - 1].Opacity; + if (AiTimer == 0 && lastSegmentOpacity > 0 && EntrancePortalLocation == Vector2.Zero) + { + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 16; + EntrancePortalLocation = Projectile.Center + Projectile.velocity * 10; + } + if (Projectile.Distance(EntrancePortalLocation) <= 32 && AiTimer <= strikes && Projectile.Opacity > 0) + { + Projectile.Opacity = 0; + SpawnRiftProjectileAt(EntrancePortalLocation); + } + foreach (var item in Segments) + { + if (item.Center.Distance(EntrancePortalLocation) <= 32) + { + if (AiTimer <= strikes) + item.Opacity = 0; + else if (item.segmentType > 0) + { + CurrentAttack = AttackState.DivinityDevourer; + AiTimer = 0; + EntrancePortalLocation = Vector2.Zero; + ExitPortalLocation = Vector2.Zero; + break; + } + } + + else if (item.Center.Distance(ExitPortalLocation) <= 32) + { + item.Opacity = 1; + } + } + if (lastSegmentOpacity == 0 && Projectile.Opacity == 0) + { + var dir = new Vector2(300).RotatedByRandom(MathHelper.TwoPi); + EntrancePortalLocation = targetPos + dir; + ExitPortalLocation = targetPos - dir; + Projectile.Center = ExitPortalLocation; + Projectile.velocity = dir.SafeNormalize(Vector2.Zero) * 16; + Projectile.Opacity = 1; + foreach (var item in Segments) + { + item.Center = Projectile.Center - dir * 10; + } + Segments[Segments.Count - 1].Opacity = 0.001f; + AiTimer++; + SpawnRiftProjectileAt(ExitPortalLocation); + if (Main.myPlayer == Projectile.owner) + { + for (int i = 0; i < 16; i++) + { + Vector2 perturbedSpeed = Vector2.UnitX.RotatedBy(MathHelper.TwoPi * i / 16f) * (i % 2 == 0 ? 24f : 16f); + var p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * PurpleFireballDamageMult), Projectile.knockBack, Projectile.owner, 0); + if (Main.projectile.IndexInRange(p)) + { + Main.projectile[p].hostile = false; + Main.projectile[p].friendly = true; + Main.projectile[p].DamageType = DamageClass.Summon; + Main.projectile[p].timeLeft = 120; + Main.projectile[p].scale = 0.5f; + Main.projectile[p].usesIDStaticNPCImmunity = true; + Main.projectile[p].idStaticNPCHitCooldown = EffectivePurpleFireIframes; + } + } + } + } + if (AiTimer > 0) + Projectile.extraUpdates = 2; + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + break; + } + + case AttackState.PlayingFetch: + { + var item = Main.item[AiTimer]; + var dir = Projectile.Center.DirectionTo(item.Center); + var holdingSpot = Projectile.Center + (Projectile.rotation-MathHelper.PiOver2).ToRotationVector2() * 35; + if (!item.active || item.beingGrabbed || !Owner.CanPullItem(item, Owner.ItemSpace(item))) + { + AiTimer = 0; + CurrentAttack = AttackState.Idle; + break; + } + float dis = MathHelper.Min(item.Distance(holdingSpot), item.Distance(Projectile.Center)); + if (dis < 36) + { + + Projectile.velocity += Projectile.DirectionTo(Owner.Center) * 0.5f; + Projectile.velocity *= 0.95f; + item.Center = holdingSpot; + item.velocity = Vector2.Zero; + JawOpeningAmount = MathHelper.Lerp(JawOpeningAmount, 0, 0.25f); + } + else + { + Projectile.velocity += Projectile.DirectionTo(item.Center) * 0.5f; + Projectile.velocity *= 0.95f; + JawOpeningAmount = MathF.Max(0,MathHelper.Lerp(1,0,dis / 240f)); + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + break; + } + } + Projectile.position += Projectile.velocity; + Projectile.position.X = MathHelper.Clamp(Projectile.position.X, 5, (Main.maxTilesX-5) * 16); + Projectile.position.Y = MathHelper.Clamp(Projectile.position.Y, 5, (Main.maxTilesY-5) * 16); + Projectile.position -= Projectile.velocity; + UpdateSegments(); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SourceDamage *= ContactDamageMult; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + for (var i = 0; i < Segments.Count; i++) + { + var prevSeg = new BaseWormSegment(this); + if (i != 0) + { + prevSeg = Segments[i - 1]; + } + if (prevSeg.Opacity <= 0.001 || Segments[i].Opacity <= 0.001) + continue; + float cpoint = 0; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), prevSeg.Center, Segments[i].Center, 16, ref cpoint)) + { + return true; + } + } + return base.Colliding(projHitbox, targetHitbox); + } + + public void SpawnRiftProjectileAt(Vector2 position) + { + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), position, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Projectile.owner,0,0.375f); + } + + public override bool PreDraw(ref Color lightColor) + { + for (int i = Segments.Count - 1; i >= 0; i--) + { + DrawSegment(ref lightColor, Segments[i]); + } + var jawTex = CalamityUtils.GetTextureEfficient(ref Jaws, "CalamityMod/Projectiles/Summon/VoidEaterMarionetteJaw").Value; + var jawGlowTex = CalamityUtils.GetTextureEfficient(ref JawGlow, "CalamityMod/Projectiles/Summon/VoidEaterMarionetteJawGlow").Value; + Main.spriteBatch.Draw(TextureAssets.Projectile[Type].Value, Projectile.Center - Main.screenPosition, null, lightColor * Projectile.Opacity, Projectile.rotation, TextureAssets.Projectile[Type].Value.Size() / 2, Projectile.scale, SpriteEffects.None, 1); + + //This draws the jaws at the desired opening amount. The jaw glow doesn't draw during Divinity Devourer as that's the pink attack and this glow is blue + Vector2 jawOffset = new Vector2(10, -18); + Main.spriteBatch.Draw(jawTex, Projectile.Center - jawOffset.RotatedBy(Projectile.rotation) - Main.screenPosition, null, lightColor * Projectile.Opacity, Projectile.rotation - JawOpeningAmount, jawTex.Size() / 2 - jawOffset, Projectile.scale, SpriteEffects.None, 1); + if (CurrentAttack != AttackState.DivinityDevourer) + Main.spriteBatch.Draw(jawGlowTex, Projectile.Center - jawOffset.RotatedBy(Projectile.rotation) - Main.screenPosition, null, Color.White * Projectile.Opacity, Projectile.rotation - JawOpeningAmount, jawTex.Size() / 2 - jawOffset, Projectile.scale, SpriteEffects.None, 1); + jawOffset.X *= -1; + Main.spriteBatch.Draw(jawTex, Projectile.Center - jawOffset.RotatedBy(Projectile.rotation) - Main.screenPosition, null, lightColor * Projectile.Opacity, Projectile.rotation + JawOpeningAmount, jawTex.Size() / 2 - jawOffset, Projectile.scale, SpriteEffects.FlipHorizontally, 1); + if (CurrentAttack != AttackState.DivinityDevourer) + Main.spriteBatch.Draw(jawGlowTex, Projectile.Center - jawOffset.RotatedBy(Projectile.rotation) - Main.screenPosition, null, Color.White * Projectile.Opacity, Projectile.rotation + JawOpeningAmount, jawTex.Size() / 2 - jawOffset, Projectile.scale, SpriteEffects.FlipHorizontally, 1); + + return false; + } + void DrawSegmentGlow(BaseWormSegment segment) + { + var color = Lighting.GetColor(segment.Center.ToTileCoordinates()); + //pink glows don't glow during Faith Incinerator while blue glows don't glow during divinity devourer + if (!SegmentTextureAssetsGlow.IndexInRange(segment.segmentType) || (segment.segmentType == 0 && CurrentAttack == AttackState.FaithIncinerator) || (segment.segmentType == 1 && CurrentAttack == AttackState.DivinityDevourer)) + { + return; + } + var tex = SegmentTextureAssetsGlow[segment.segmentType].Value; + Main.spriteBatch.Draw(tex, segment.Center - Main.screenPosition, null, Color.White * segment.Opacity, segment.rotation, tex.Size() / 2 + (SegmentTypeDrawOffsets[segment.segmentType]), Projectile.scale, SpriteEffects.None, 1); + } + public List> SegmentTextureAssetsGlow + { + get + { + if (internalTexAssetsGlow.Count == 0) + for (var i = 0; i < SegmentTextures.Count; i++) + { + internalTexAssetsGlow.Add(ModContent.Request(SegmentTextures[i] + "Glow")); + if (SegmentTypeDrawOffsets.Count <= i) + { + SegmentTypeDrawOffsets.Add(Vector2.Zero); + } + } + return internalTexAssetsGlow; + } + } + private List> internalTexAssetsGlow = new List>(); + + private Asset GlowTexAsset; + private Asset Jaws; + private Asset JawGlow; + private Asset DoGJaws; + public override void PostDraw(Color lightColor) + { + for (int i = Segments.Count - 1; i >= 0; i--) + { + DrawSegmentGlow(Segments[i]); + } + //Faith Incinerator doesn't use this glow as it's the blue attack and this glow is pink + if (CurrentAttack != AttackState.FaithIncinerator) + Main.EntitySpriteDraw(CalamityUtils.GetTextureEfficient(ref GlowTexAsset, GlowTexture).Value, Projectile.Center - Main.screenPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, CalamityUtils.GetTextureEfficient(ref GlowTexAsset, GlowTexture).Size() *0.5f, Projectile.scale, SpriteEffects.None, 0); + + if (Projectile.Opacity > 0 && CurrentAttack == AttackState.UltracosmicMaelstrom && AiTimer > 0) + { + var tex = CalamityUtils.GetTextureEfficient(ref DoGJaws, "CalamityMod/Particles/Jaws").Value; + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.spriteBatch.Draw(tex, Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero) * 12 - Main.screenPosition, null, Color.Fuchsia, Projectile.velocity.ToRotation() + MathHelper.PiOver2, tex.Size() * 0.5f, 0.7f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(tex, Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero) * 12 - Main.screenPosition, null, Color.Aqua, Projectile.velocity.ToRotation() + MathHelper.PiOver2, tex.Size() * 0.5f, 0.6f, SpriteEffects.None, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + } + } +} diff --git a/Projectiles/Summon/VoidEaterMarionetteTail.png b/Projectiles/Summon/VoidEaterMarionetteTail.png new file mode 100644 index 0000000000..8005a5c636 Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteTail.png differ diff --git a/Projectiles/Summon/VoidEaterMarionetteTailGlow.png b/Projectiles/Summon/VoidEaterMarionetteTailGlow.png new file mode 100644 index 0000000000..0fc144c9bf Binary files /dev/null and b/Projectiles/Summon/VoidEaterMarionetteTailGlow.png differ diff --git a/Projectiles/Summon/WaterElementalMinion.cs b/Projectiles/Summon/WaterElementalMinion.cs index 2e5ea2d82f..e04dd72736 100644 --- a/Projectiles/Summon/WaterElementalMinion.cs +++ b/Projectiles/Summon/WaterElementalMinion.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Summon bool isMinion = Projectile.type == ModContent.ProjectileType(); Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.sirenWaifu && !modPlayer.allWaifus && !modPlayer.sirenWaifuVanity && !modPlayer.allWaifusVanity) + if (!modPlayer.waterElemental && !modPlayer.allElementals && !modPlayer.waterElementalVanity && !modPlayer.allElementalsVanity) { Projectile.active = false; return; @@ -49,9 +49,9 @@ namespace CalamityMod.Projectiles.Summon { if (player.dead) { - modPlayer.slWaifu = false; + modPlayer.waterEleBuff = false; } - if (modPlayer.slWaifu) + if (modPlayer.waterEleBuff) { Projectile.timeLeft = 2; } @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Summon } dust--; } - bool passive = modPlayer.sirenWaifuVanity || modPlayer.allWaifusVanity; + bool passive = modPlayer.waterElementalVanity || modPlayer.allElementalsVanity; if (!passive) Lighting.AddLight(Projectile.Center, 0f, 0.25f, 1.5f); diff --git a/Projectiles/Summon/WhiteDragonBody.cs b/Projectiles/Summon/WhiteDragonBody.cs index 918211fc27..1d0684b528 100644 --- a/Projectiles/Summon/WhiteDragonBody.cs +++ b/Projectiles/Summon/WhiteDragonBody.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.Summon; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; diff --git a/Projectiles/Summon/WhiteDragonHead.cs b/Projectiles/Summon/WhiteDragonHead.cs index 421192a221..634a229076 100644 --- a/Projectiles/Summon/WhiteDragonHead.cs +++ b/Projectiles/Summon/WhiteDragonHead.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using CalamityMod.Buffs.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -214,6 +213,8 @@ namespace CalamityMod.Projectiles.Summon return false; } + public override bool MinionContactDamage() => true; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Frostburn2, 300); } } diff --git a/Projectiles/Summon/WhiteDragonTail.cs b/Projectiles/Summon/WhiteDragonTail.cs index 8a14b34937..2a212aa9ca 100644 --- a/Projectiles/Summon/WhiteDragonTail.cs +++ b/Projectiles/Summon/WhiteDragonTail.cs @@ -1,7 +1,5 @@ -using CalamityMod.Buffs.Summon; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Summon/WitherBlossom.cs b/Projectiles/Summon/WitherBlossom.cs index 833562f02a..1d1cadfd8d 100644 --- a/Projectiles/Summon/WitherBlossom.cs +++ b/Projectiles/Summon/WitherBlossom.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { + Main.projPet[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } @@ -53,13 +54,11 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 36; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 179); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.BubbleBurst_Purple); dust.noGravity = true; dust.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 7f); } } } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Summon/WulfrumDroid.cs b/Projectiles/Summon/WulfrumDroid.cs index cc8d4f7eee..18a1aac1ad 100644 --- a/Projectiles/Summon/WulfrumDroid.cs +++ b/Projectiles/Summon/WulfrumDroid.cs @@ -11,7 +11,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -98,15 +97,16 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { - Main.projFrames[Type] = 12; + Main.projFrames[Type] = 24; + Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; } public override void SetDefaults() { - Projectile.width = 26; - Projectile.height = 32; + Projectile.width = 86; + Projectile.height = 44; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; @@ -118,6 +118,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.minion = true; Projectile.DamageType = DamageClass.Summon; Initialized = 0f; + BuffModeBuffer = 15; } //Returns the npc if targetable, returns null if not @@ -149,7 +150,7 @@ namespace CalamityMod.Projectiles.Summon { Vector2 direction = Main.rand.NextVector2CircularEdge(1f, 1f); - Dust wishyDust = Dust.NewDustPerfect(Projectile.Center + direction * Main.rand.NextFloat(1f, 8f), 229, Alpha : 100, Scale: Main.rand.NextFloat(1f, 1.4f)); + Dust wishyDust = Dust.NewDustPerfect(Projectile.Center + direction * Main.rand.NextFloat(1f, 8f), DustID.Vortex, Alpha : 100, Scale: Main.rand.NextFloat(1f, 1.4f)); wishyDust.noGravity = true; wishyDust.noLight = true; wishyDust.velocity = direction * Main.rand.NextFloat(2f, 4); @@ -164,35 +165,64 @@ namespace CalamityMod.Projectiles.Summon if (Owner.Calamity().mouseRight && Owner.HeldItem.type == ModContent.ItemType()) { - if (BuffModeBuffer > 0) + if (Owner.itemTime == Owner.itemTimeMax) + { + if (BuffModeBuffer == 15) + BuffModeBuffer--; + if (BuffModeBuffer == -15) + BuffModeBuffer++; + } + if (BuffModeBuffer < 15 && BuffModeBuffer >= 0) { BuffModeBuffer--; - Projectile.netUpdate = true; + if (BuffModeBuffer == 0) + BuffModeBuffer = -15; } + if (BuffModeBuffer > -15 && BuffModeBuffer <= 0) + { + BuffModeBuffer++; + if (BuffModeBuffer == 0) + BuffModeBuffer = 15; + } + Projectile.netUpdate = true; + } + + else if (BuffModeBuffer > 0 && BuffModeBuffer < 15) + { + BuffModeBuffer++; + } + else if (BuffModeBuffer < 0 && BuffModeBuffer > -15) + { + BuffModeBuffer--; } - else if (BuffModeBuffer < 15) - BuffModeBuffer = 15; bool buffMode = BuffModeBuffer <= 0; //Do frame stuff i guess - Projectile.frame = Projectile.frame % (Main.projFrames[Type] / 2); - Projectile.frameCounter++; - if (Projectile.frameCounter > 8) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= Main.projFrames[Type] / 2) - { - Projectile.frame = 0; - } - if (buffMode) - Projectile.frame += Main.projFrames[Type] / 2; - + { + Projectile.frame = (int)MathHelper.Clamp(Projectile.frame, 8, 15); + if (Projectile.frameCounter >= 6) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 15) + Projectile.frame = 8; + } + else + { + Projectile.frame = (int)MathHelper.Clamp(Projectile.frame, 0, 7); + if (Projectile.frameCounter >= 6) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 7) + Projectile.frame = 0; + } //Buff stuff player.AddBuff(ModContent.BuffType(), 3600); @@ -332,7 +362,7 @@ namespace CalamityMod.Projectiles.Summon { Vector2 direction = Main.rand.NextVector2CircularEdge(1f, 1f); - Dust wishyDust = Dust.NewDustPerfect(playerToBuff.Center + direction * Main.rand.NextFloat(4f, 9f), 229, Alpha: 100, Scale: Main.rand.NextFloat(1f, 1.4f)); + Dust wishyDust = Dust.NewDustPerfect(playerToBuff.Center + direction * Main.rand.NextFloat(4f, 9f), DustID.Vortex, Alpha: 100, Scale: Main.rand.NextFloat(1f, 1.4f)); wishyDust.noGravity = true; wishyDust.noLight = true; wishyDust.velocity = direction * Main.rand.NextFloat(2f, 4); @@ -368,8 +398,7 @@ namespace CalamityMod.Projectiles.Summon { ShootTimer = ShootDelay; - // 1/3 chance to directly recharge the Rover Drive shield by 1 point - if (Main.rand.NextBool(3) && modPlayer.roverDrive && modPlayer.RoverDriveShieldDurability < RoverDrive.ShieldDurabilityMax) + if (modPlayer.roverDrive && modPlayer.RoverDriveShieldDurability < RoverDrive.ShieldDurabilityMax) { CalamityPlayer buffedCalPlayer = playerToBuff.Calamity(); buffedCalPlayer.RoverDriveShieldDurability++; @@ -401,23 +430,30 @@ namespace CalamityMod.Projectiles.Summon Projectile.rotation = Projectile.velocity.X * 0.05f; Projectile.spriteDirection = Projectile.direction = Math.Sign(Projectile.velocity.X); - if (!buffMode) + if (!buffMode && targetCache != null) ChargeUpAndFire(targetCache); } public void ChargeUpAndFire(NPC targetCache) { - //Decrease the timer by a random number - ShootTimer -= Main.rand.Next(1, 4); - - - if (ShootTimer <= 0) + if (ShootTimer <= 20) { - ShootTimer = ShootDelay; - Projectile.netUpdate = true; + Projectile.frame = (int)Utils.Remap(ShootTimer, 20, 4, 20, 23); + ShootTimer -= 2; - //Don't shoot if no target. - if (targetCache == null) + // If the target is lost or player is switching to defense mode then immediately reset the delay and do not shoot + if (ShootTimer <= 0 || targetCache == null || BuffModeBuffer < 15) + { + ShootTimer = ShootDelay; + Projectile.frame = 0; + Projectile.netUpdate = true; + return; + } + + Projectile.rotation = Utils.Remap(ShootTimer, 18, 4, Projectile.AngleTo(targetCache.Center) + (Projectile.direction == 1 ? 0 : Projectile.Center.Y < targetCache.Center.Y ? -MathHelper.Pi : MathHelper.Pi), Projectile.rotation); + + // Shoot at this exact time (the remaining timer is used to finish the firing animation) + if (ShootTimer != 18) return; NuzzleFlashTime = 20f; @@ -428,7 +464,6 @@ namespace CalamityMod.Projectiles.Summon velocity *= 10f; Projectile.velocity += velocity * -0.3f; - if (Main.myPlayer == Projectile.owner) { int bolt = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); @@ -437,9 +472,37 @@ namespace CalamityMod.Projectiles.Summon Projectile.netUpdate = true; } } + else if (ShootTimer <= 36) + { + // From this point on, decrease the timer by a consistent number for the animation + Projectile.frame = (int)Utils.Remap(ShootTimer, 36, 20, 16, 20); + ShootTimer -= 2; + + // If the target is lost or player is switching to defense mode then de-transition immediately + if (targetCache == null || BuffModeBuffer < 15) + { + ShootTimer = ShootDelay; + Projectile.frame -= 16; + Projectile.netUpdate = true; + return; + } + + Projectile.rotation = Utils.Remap(ShootTimer, 34, 20, Projectile.rotation, Projectile.AngleTo(targetCache.Center) + (Projectile.direction == 1 ? 0 : Projectile.Center.Y < targetCache.Center.Y ? -MathHelper.Pi : MathHelper.Pi)); + + if (ShootTimer < 20) + ShootTimer = 20; + } + else + { + //Decrease the timer by a random number + ShootTimer -= Main.rand.Next(1, 4); + + if (ShootTimer < 36) + ShootTimer = 36; + } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = 0.4f + 0.4f * ((float)Math.Sin(Main.GlobalTimeWrappedHourly * 6f + completionRatio * -12f) * 0.5f + 0.5f); @@ -448,7 +511,7 @@ namespace CalamityMod.Projectiles.Summon return Color.CornflowerBlue.MultiplyRGB(PrimColorMult) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return (3.4f + 4f * ((float)Math.Sin(Main.GlobalTimeWrappedHourly * 6f + completionRatio * -12f) * 0.5f + 0.5f)) * 2f; } @@ -471,7 +534,7 @@ namespace CalamityMod.Projectiles.Summon CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1.8f, delegate (Vector2 offset, Color colorMod) { PrimColorMult = colorMod; - PrimitiveRenderer.RenderTrail(drawPos, new(WidthFunction, ColorFunction, (_) => offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(drawPos, new(WidthFunction, ColorFunction, (_,_) => offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); }); Main.spriteBatch.End(); @@ -508,8 +571,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool? CanDamage() => false; - public override void SendExtraAI(BinaryWriter writer) { writer.Write(BuffModeBuffer); diff --git a/Projectiles/Summon/WulfrumDroid.png b/Projectiles/Summon/WulfrumDroid.png index fec767973b..5f5d822d8a 100644 Binary files a/Projectiles/Summon/WulfrumDroid.png and b/Projectiles/Summon/WulfrumDroid.png differ diff --git a/Projectiles/Summon/WulfrumEnergyBurst.cs b/Projectiles/Summon/WulfrumEnergyBurst.cs index 3aa9aab80d..bf439fe963 100644 --- a/Projectiles/Summon/WulfrumEnergyBurst.cs +++ b/Projectiles/Summon/WulfrumEnergyBurst.cs @@ -1,15 +1,11 @@ using System; using CalamityMod.Graphics.Primitives; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; -using static CalamityMod.CalamityUtils; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Summon @@ -136,7 +132,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 5; i++) { - Dust chust = Dust.NewDustPerfect(dustCenter, 178, Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1f, 1.2f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.BubbleBurst_Green, Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1f, 1.2f)); chust.noGravity = true; } } @@ -147,7 +143,7 @@ namespace CalamityMod.Projectiles.Summon { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust chust = Dust.NewDustPerfect(dustCenter, 178, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(0.6f, 1.15f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.BubbleBurst_Green, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(0.6f, 1.15f)); chust.noGravity = true; } @@ -155,20 +151,20 @@ namespace CalamityMod.Projectiles.Summon { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust largeDust = Dust.NewDustPerfect(dustCenter, 178, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f), Scale: Main.rand.NextFloat(0.4f, 1f)); + Dust largeDust = Dust.NewDustPerfect(dustCenter, DustID.BubbleBurst_Green, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f), Scale: Main.rand.NextFloat(0.4f, 1f)); largeDust.noGravity = true; largeDust.noLight = true; } } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = (float)Math.Sqrt(1 - completionRatio); return Color.Chartreuse.MultiplyRGB(PrimColorMult) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return 9.4f; } @@ -183,7 +179,7 @@ namespace CalamityMod.Projectiles.Summon CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1.5f, delegate (Vector2 offset, Color colorMod) { PrimColorMult = colorMod; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_, _) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); }); Main.spriteBatch.End(); diff --git a/Projectiles/Summon/WulfrumFusionBolt.cs b/Projectiles/Summon/WulfrumFusionBolt.cs index 6b1d5808af..2721af3c07 100644 --- a/Projectiles/Summon/WulfrumFusionBolt.cs +++ b/Projectiles/Summon/WulfrumFusionBolt.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < 5; i++) { - Dust chust = Dust.NewDustPerfect(dustCenter, 15, Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); chust.noGravity = true; } } @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(5)) { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust chust = Dust.NewDustPerfect(dustCenter, 15, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); + Dust chust = Dust.NewDustPerfect(dustCenter, DustID.MagicMirror, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.5f), Scale: Main.rand.NextFloat(1.2f, 1.8f)); chust.noGravity = true; } @@ -153,7 +153,7 @@ namespace CalamityMod.Projectiles.Summon { Vector2 dustCenter = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2).SafeNormalize(Vector2.Zero) * Main.rand.NextFloat(-3f, 3f); - Dust largeDust = Dust.NewDustPerfect(dustCenter, 257, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f), Scale: Main.rand.NextFloat(0.4f, 1f)); + Dust largeDust = Dust.NewDustPerfect(dustCenter, DustID.BubbleBlock, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f), Scale: Main.rand.NextFloat(0.4f, 1f)); largeDust.noGravity = true; largeDust.noLight = true; } @@ -169,13 +169,13 @@ namespace CalamityMod.Projectiles.Summon } } - internal Color ColorFunction(float completionRatio) + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float fadeOpacity = (float)Math.Sqrt(1 - completionRatio); return Color.Lerp(Color.DeepSkyBlue, Color.YellowGreen, Projectile.timeLeft / 140f).MultiplyRGB(PrimColorMult) * fadeOpacity; } - internal float WidthFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) { return 6.4f; } @@ -190,7 +190,7 @@ namespace CalamityMod.Projectiles.Summon { PrimColorMult = colorMod; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30); }); Main.spriteBatch.End(); diff --git a/Projectiles/Turret/DraedonLaser.cs b/Projectiles/Turret/DraedonLaser.cs index 029a148ac1..d692734005 100644 --- a/Projectiles/Turret/DraedonLaser.cs +++ b/Projectiles/Turret/DraedonLaser.cs @@ -1,7 +1,6 @@ using System; using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Terraria; using Terraria.Audio; using Terraria.ModLoader; diff --git a/Projectiles/Turret/IceExplosion.cs b/Projectiles/Turret/IceExplosion.cs index 9b8a1cf7c9..ea15cffab2 100644 --- a/Projectiles/Turret/IceExplosion.cs +++ b/Projectiles/Turret/IceExplosion.cs @@ -3,7 +3,6 @@ using CalamityMod.DataStructures; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Turret/IceShot.cs b/Projectiles/Turret/IceShot.cs index bef1dc5cb2..8f970f9d8e 100644 --- a/Projectiles/Turret/IceShot.cs +++ b/Projectiles/Turret/IceShot.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Turret } public override void OnHitPlayer(Player target, Player.HurtInfo info) { - target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(BuffID.Frozen, 30); target.AddBuff(BuffID.Frostburn, 180); if (Projectile.hostile && Main.netMode == NetmodeID.MultiplayerClient) //hostile version pierces through players in multiplayer return; diff --git a/Projectiles/Turret/LaserShot.cs b/Projectiles/Turret/LaserShot.cs index ae852dfc63..d0aae0660c 100644 --- a/Projectiles/Turret/LaserShot.cs +++ b/Projectiles/Turret/LaserShot.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Turret public override float DetermineLaserLength() { - return DetermineLaserLength_CollideWithTiles(8); + return DetermineLaserLength_CollideWithTiles(); } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Turret/PlagueExplosionGas.cs b/Projectiles/Turret/PlagueExplosionGas.cs index a4102fba0f..a5d41facde 100644 --- a/Projectiles/Turret/PlagueExplosionGas.cs +++ b/Projectiles/Turret/PlagueExplosionGas.cs @@ -3,8 +3,6 @@ using CalamityMod.DataStructures; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Turret diff --git a/Projectiles/Turret/PlagueShot.cs b/Projectiles/Turret/PlagueShot.cs index 2fbf17f8ea..9b3033e391 100644 --- a/Projectiles/Turret/PlagueShot.cs +++ b/Projectiles/Turret/PlagueShot.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -86,7 +85,8 @@ namespace CalamityMod.Projectiles.Turret public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(TeslaCannon.FireSound with { Volume = 0.18f }, Projectile.Center); + SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PlagueBoom", 4); + SoundEngine.PlaySound(fire with { Volume = 0.5f, Pitch = -0.3f }, Projectile.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * 0.4f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25f), Projectile.knockBack * 0.16f, Main.myPlayer); diff --git a/Projectiles/Turret/WaterShotBuffer.cs b/Projectiles/Turret/WaterShotBuffer.cs index 3b41d8810e..1502370a6f 100644 --- a/Projectiles/Turret/WaterShotBuffer.cs +++ b/Projectiles/Turret/WaterShotBuffer.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/AbaddonCrit.cs b/Projectiles/Typeless/AbaddonCrit.cs index 90b917922f..d77d440a3c 100644 --- a/Projectiles/Typeless/AbaddonCrit.cs +++ b/Projectiles/Typeless/AbaddonCrit.cs @@ -1,7 +1,5 @@ -using System; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; diff --git a/Projectiles/Typeless/AmuletEnergy.cs b/Projectiles/Typeless/AmuletEnergy.cs index f6fd3a19e5..e0e37cc736 100644 --- a/Projectiles/Typeless/AmuletEnergy.cs +++ b/Projectiles/Typeless/AmuletEnergy.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -116,11 +114,11 @@ namespace CalamityMod.Projectiles.Typeless float offsetPower = Utils.GetLerpValue(1, 5, Owner.velocity.Length(), true); float sine = (float)Math.Sin((time * 0.1f) / MathHelper.Pi); float sine2 = (float)Math.Sin((time * 0.04f) / MathHelper.Pi); - Vector2 bonusMobility = (offsetPower > 0 ? ((Utils.DirectionTo(Projectile.Center, Owner.Center) * 50) * sine2).RotatedBy(0.8f * sine) * offsetPower : Vector2.Zero); - Vector2 goalPosition = Owner.MountedCenter + bonusMobility + ((MathHelper.TwoPi * energyNumber) / Math.Max(Owner.ownedProjectileCounts[ModContent.ProjectileType()], 1)).ToRotationVector2().RotatedBy(Main.GlobalTimeWrappedHourly * 0.4f) * 80; + Vector2 bonusMobility = (offsetPower > 0 ? ((Utils.DirectionTo(Projectile.Center, Owner.Center) * 90) * sine2).RotatedBy(0.8f * sine) * offsetPower : Vector2.Zero); + Vector2 goalPosition = Owner.MountedCenter + bonusMobility + ((MathHelper.TwoPi * energyNumber) / Math.Max(Owner.ownedProjectileCounts[ModContent.ProjectileType()], 1)).ToRotationVector2().RotatedBy(Main.GlobalTimeWrappedHourly * 0.4f) * 20; - bool outOfRange = Utils.Distance(Projectile.Center, goalPosition) > 100; - if (Projectile.velocity.Length() < 5 && outOfRange) + bool outOfRange = Utils.Distance(Projectile.Center, goalPosition) > 60; + if (Projectile.velocity.Length() < 6 && outOfRange) Projectile.velocity = Projectile.velocity * 0.995f + Utils.DirectionTo(Projectile.Center, goalPosition) * homingSpeed; else if (outOfRange) Projectile.velocity *= 0.985f; @@ -211,7 +209,7 @@ namespace CalamityMod.Projectiles.Typeless GeneralParticleHandler.SpawnParticle(fadeInfx); } - Projectile.scale = MathHelper.Lerp(Projectile.scale, spoke ? 1.4f : 1, 0.1f); + Projectile.scale = MathHelper.Lerp(Projectile.scale, spoke ? 0.9f : 0.5f, 0.1f); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; time++; } @@ -228,7 +226,7 @@ namespace CalamityMod.Projectiles.Typeless { float variance = Main.rand.NextFloat(-0.5f, 0.5f); Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)) * 4; - float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f; + float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f * Projectile.scale; Particle sparks = new CustomSpark(Projectile.Center + vel, vel, "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(13, 16 + 1), scale, bColor * 0.7f, new Vector2(1f, 1), true, false, 0, false, shrinkSpeed: 0.25f); GeneralParticleHandler.SpawnParticle(sparks); diff --git a/Projectiles/Typeless/ArtifactOfResilienceShards.cs b/Projectiles/Typeless/ArtifactOfResilienceShards.cs index 7e75dadd3c..7e07cc5f9a 100644 --- a/Projectiles/Typeless/ArtifactOfResilienceShards.cs +++ b/Projectiles/Typeless/ArtifactOfResilienceShards.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -12,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class ArtifactOfResilienceShards : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; @@ -135,7 +137,7 @@ namespace CalamityMod.Projectiles.Typeless int projNum = Owner.ownedProjectileCounts[ModContent.ProjectileType()] - 4; Projectile.velocity = ((MathHelper.TwoPi * Projectile.ai[2] / projNum).ToRotationVector2()) * 15 * speedMult; - Owner.Calamity().GeneralScreenShakePower = 5f; + Owner.SetScreenshake(5f); if (Projectile.ai[2] == 1) { @@ -174,6 +176,10 @@ namespace CalamityMod.Projectiles.Typeless } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + bool crit = Main.rand.Next(0, 100 + 1) < Owner.GetTotalCritChance(Owner.GetBestClass()); + if (crit) + modifiers.SetCrit(); + modifiers.SourceDamage *= (isAttacking ? 1 : 0.45f); if (isAttacking) target.AddBuff(ModContent.BuffType(), 520); diff --git a/Projectiles/Typeless/AscendantAura.cs b/Projectiles/Typeless/AscendantAura.cs index 311dfd0c3d..36a18030fa 100644 --- a/Projectiles/Typeless/AscendantAura.cs +++ b/Projectiles/Typeless/AscendantAura.cs @@ -1,7 +1,4 @@ -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; -using CalamityMod.Particles; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -57,7 +54,7 @@ namespace CalamityMod.Projectiles.Typeless float angle = MathHelper.TwoPi / dustAmount * d; Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 40f); - Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, 204, velocity); + Dust spawnDust = Dust.NewDustPerfect(Projectile.Center, DustID.TreasureSparkle, velocity); spawnDust.noGravity = true; spawnDust.scale = velocity.Length() * 0.05f; spawnDust.velocity *= 0.4f; @@ -98,7 +95,7 @@ namespace CalamityMod.Projectiles.Typeless float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(8f, 0).RotatedBy(rot); Vector2 velOffset = new Vector2(10.5f, 0).RotatedBy(rot); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 278, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, DustID.FireworksRGB, new Vector2(velOffset.X, velOffset.Y)); dust.noGravity = true; dust.velocity = velOffset * Main.rand.NextFloat(0.2f, 1.1f); dust.scale = Main.rand.NextFloat(0.3f, 0.8f); diff --git a/Projectiles/Typeless/AstralSpray.cs b/Projectiles/Typeless/AstralSpray.cs index d2354f3dd6..f1b18aff04 100644 --- a/Projectiles/Typeless/AstralSpray.cs +++ b/Projectiles/Typeless/AstralSpray.cs @@ -1,4 +1,5 @@ using CalamityMod.World; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,69 +11,50 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float Time => ref Projectile.ai[0]; + public bool ShotFromTerraformer => Projectile.ai[1] == 1f; + + public static int ConversionType; + public override void SetStaticDefaults() => ConversionType = ModContent.GetInstance().Type; + public override void SetDefaults() { - Projectile.width = 16; - Projectile.height = 16; - Projectile.aiStyle = -1; - Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = -1; - Projectile.extraUpdates = 2; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; + Projectile.DefaultToSpray(); + Projectile.aiStyle = 0; } public override bool? CanDamage() => false; - public override bool PreAI() + public override void AI() { + if (Projectile.timeLeft > 133) + Projectile.timeLeft = 133; + if (Main.myPlayer == Projectile.owner) { - int x = (int)(Projectile.Center.X / 16f); - int y = (int)(Projectile.Center.Y / 16f); + int size = ShotFromTerraformer ? 3 : 2; + Point tileCenter = Projectile.Center.ToTileCoordinates(); + WorldGen.Convert(tileCenter.X, tileCenter.Y, ConversionType, size); + } - AstralBiome.ConvertToAstral(x - 1, x + 1, y - 1, y + 1); - } - if (Projectile.timeLeft > 133) + float dustStart = ShotFromTerraformer ? 3f : 7f; + if (Time > dustStart) { - Projectile.timeLeft = 133; - } - if (Projectile.ai[0] > 7f) - { - float scalar = 1f; - if (Projectile.ai[0] == 8f) + float dustScale = Utils.Remap(Time, dustStart + 1f, dustStart + 5f, 0.2f, 1f); + int dustArea = 0; + if (ShotFromTerraformer) { - scalar = 0.2f; + dustScale *= 1.2f; + dustArea = (int)(12f * dustScale); } - else if (Projectile.ai[0] == 9f) - { - scalar = 0.4f; - } - else if (Projectile.ai[0] == 10f) - { - scalar = 0.6f; - } - else if (Projectile.ai[0] == 11f) - { - scalar = 0.8f; - } - Projectile.ai[0]++; - for (int i = 0; i < 1; i++) - { - int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Ice_Purple, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100); - Main.dust[d].noGravity = true; - Main.dust[d].scale *= 1.75f * scalar; - Main.dust[d].velocity.X *= 2f; - Main.dust[d].velocity.Y *= 2f; - } - } - else - { - Projectile.ai[0]++; + + Dust spray = Dust.NewDustDirect(Projectile.position - Vector2.One * dustArea, Projectile.width + dustArea * 2, Projectile.height + dustArea * 2, DustID.Ice_Purple, Projectile.velocity.X * 0.4f, Projectile.velocity.Y * 0.4f, 100); + spray.noGravity = true; + spray.scale *= 1.75f * dustScale; } + + Time++; Projectile.rotation += 0.3f * Projectile.direction; - return false; } } } diff --git a/Projectiles/Typeless/AstralStar.cs b/Projectiles/Typeless/AstralStar.cs index 3958cf21cd..f7bdd0717e 100644 --- a/Projectiles/Typeless/AstralStar.cs +++ b/Projectiles/Typeless/AstralStar.cs @@ -2,7 +2,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Typeless/AuricLandMineExplosion.cs b/Projectiles/Typeless/AuricLandMineExplosion.cs index e5b4d7d935..87aeda8ded 100644 --- a/Projectiles/Typeless/AuricLandMineExplosion.cs +++ b/Projectiles/Typeless/AuricLandMineExplosion.cs @@ -31,12 +31,13 @@ namespace CalamityMod.Projectiles.Typeless Projectile.tileCollide = false; Projectile.hostile = true; Projectile.friendly = true; + Projectile.trap = true; } public override void AI() { if (Projectile.timeLeft == 20) - Owner.Calamity().GeneralScreenShakePower = 200; + Owner.SetScreenshake(200f); if (Projectile.timeLeft <= 20) { if (Projectile.ai[0] % 4 == 0) @@ -95,11 +96,11 @@ namespace CalamityMod.Projectiles.Typeless return false; } - internal float WidthFunction(float completionRatio) => MathHelper.Clamp(CalamityUtils.Convert01To010(completionRatio * 2), 0.2f, 1f) * 4f; - internal Color ColorFunction(float completionRatio) => new Color(123, 205, 237); // Auric blue + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.Clamp(CalamityUtils.Convert01To010(completionRatio * 2), 0.2f, 1f) * 4f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) => new Color(123, 205, 237); // Auric blue - internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 2f; - internal Color BackgroundColorFunction(float completionRatio) => ColorFunction(completionRatio) * 0.5f; + internal float BackgroundWidthFunction(float completionRatio, Vector2 vertexPos) => WidthFunction(completionRatio, vertexPos) * 2f; + internal Color BackgroundColorFunction(float completionRatio, Vector2 vertexPos) => ColorFunction(completionRatio, vertexPos) * 0.5f; public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Typeless/BabyCannonballProjectile.cs b/Projectiles/Typeless/BabyCannonballProjectile.cs index 15f00571b0..2dcca5f59d 100644 --- a/Projectiles/Typeless/BabyCannonballProjectile.cs +++ b/Projectiles/Typeless/BabyCannonballProjectile.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.tileCollide = false; Projectile.alpha = 255; Projectile.MaxUpdates = 3; - Projectile.timeLeft = 600; + Projectile.timeLeft = 150 * Projectile.MaxUpdates;; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 11; } diff --git a/Projectiles/Typeless/BasicBurstExclusive.cs b/Projectiles/Typeless/BasicBurstExclusive.cs new file mode 100644 index 0000000000..b5297f95f8 --- /dev/null +++ b/Projectiles/Typeless/BasicBurstExclusive.cs @@ -0,0 +1,100 @@ +using System; +using System.IO; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class BasicBurstExclusive : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Vector2 pushVelocity; + public float customKnockback = 0; + + public bool hasStongDisplacement = false; // If you set Knockback to anything below zero, the custom knockback will be able to effect enemies that normally ignore knockback. + + // Projectile.ai[0] is the size of the circular hitbox. + // Projectile.ai[1] is the minimum multiplier on pierce damage. + // Projectile.ai[2] is the number of hits to reach minimum pierce damage. + + // local ai 0 is an excluded enemy that can not be hit. This is usually the enemy hit by the projectile that spawned this explosion + + // You can use the local ai variables 1 and 2 to inflict a debuff. If you need more than that, just make your own projectile + // 1 is the debuff being inflicted + // 2 is the debuff duration + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + // Get custom knockback strength. + // Takes the knockback applied to the projectile to determine strength, then sets regular knockback to zero + // Negative knockback is Abs'd and turns on strong knockback that effects more kinds of enemies + if (customKnockback == 0) + { + if (Projectile.knockBack < 0) + hasStongDisplacement = true; + customKnockback = Math.Abs(Projectile.knockBack); + Projectile.knockBack = 0; + } + if (Projectile.ai[0] == 0) + Projectile.ai[0] = 50; // The base size for explosions is 50. + if (Projectile.ai[1] == 0) + Projectile.ai[1] = 0.1f; // The base minimum damage multiplier is 0.1f. + if (Projectile.ai[2] == 0) + Projectile.ai[2] = 5; // The base number of hit to reach minimum damage is 5. + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.localAI[1] != 0) // Debuff 1 + { + target.AddBuff((int)(Projectile.localAI[1]), (int)(Projectile.localAI[2])); + } + pushVelocity = Utils.DirectionTo(Projectile.Center, target.Center) * customKnockback; + float minMult = Projectile.ai[1]; + int hitsToMinMult = (int)Projectile.ai[2]; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + if (customKnockback != 0 && target.CanBeMoved(hasStongDisplacement)) + { + target.velocity = (pushVelocity * (target.knockBackResist == 0 ? 0.5f : 1)); + } + } + public override bool? CanHitNPC(NPC target) + { + if (target.whoAmI == Projectile.localAI[0]) + return false; + else + return null; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.ai[0], targetHitbox); + } + public override void SendExtraAI(BinaryWriter writer) // Sending extra ai for the debuff infliction + { + writer.Write(Projectile.localAI[0]); + writer.Write(Projectile.localAI[1]); + writer.Write(Projectile.localAI[2]); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.localAI[0] = reader.ReadSingle(); + Projectile.localAI[1] = reader.ReadSingle(); + Projectile.localAI[2] = reader.ReadSingle(); + } + } +} diff --git a/Projectiles/Typeless/BasicPlagueBee.cs b/Projectiles/Typeless/BasicPlagueBee.cs index dbdc38363a..22d8033749 100644 --- a/Projectiles/Typeless/BasicPlagueBee.cs +++ b/Projectiles/Typeless/BasicPlagueBee.cs @@ -1,11 +1,8 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -83,7 +80,7 @@ namespace CalamityMod.Projectiles.Typeless if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 89, -Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.2f, 0.6f), 0, default, Main.rand.NextFloat(0.5f, 0.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.GemEmerald, -Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.2f, 0.6f), 0, default, Main.rand.NextFloat(0.5f, 0.8f)); dust.noGravity = true; dust.alpha = Main.rand.Next(90, 220 + 1); } @@ -198,7 +195,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i <= 5; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 89, Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.7f, 0.85f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.GemEmerald, Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.7f, 0.85f)); dust.noGravity = true; } } diff --git a/Projectiles/Typeless/BatholithBangleProjectile.cs b/Projectiles/Typeless/BatholithBangleProjectile.cs new file mode 100644 index 0000000000..efd000c2c1 --- /dev/null +++ b/Projectiles/Typeless/BatholithBangleProjectile.cs @@ -0,0 +1,190 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class BatholithBangleProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public int damageTime = 120; + public int Soundtime1 = 84; + public int Soundtime2 = 90; + public int Soundtime3 = 96; + public int Soundtime4 = 107; + public SlotId SoundSlot; + public Color clr1 = new Color(59, 28, 136); // Light Granite + public Color clr2 = new Color(16, 14, 36); // Dark Granite + public Color clr3 = new Color(23, 186, 218); // Granite energy + public int spinDir = 1; + public bool invalidTarget => (Projectile.ai[0] < 0f || Projectile.ai[0] > 199f || !Main.npc[(int)Projectile.ai[0]].active || Main.npc[(int)Projectile.ai[0]].life <= 0); + public Player Owner => Main.player[Projectile.owner]; + public bool visual => Owner.Calamity().batholithBangleVisual; + public override void SetDefaults() + { + Projectile.width = 120; + Projectile.height = 120; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = damageTime + 2; + Projectile.ArmorPenetration = 35; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.scale = 0.8f; + } + public override void AI() + { + if (time == 0 && visual) + { + spinDir = Main.rand.NextBool() ? 1 : -1; + SoundStyle sound = new("CalamityMod/Sounds/Item/BatholithBangleSound"); + SoundSlot = SoundEngine.PlaySound(sound with { Volume = 1f, MaxInstances = -1 }, Projectile.Center); + } + if (!invalidTarget) + Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; + else if (time < Soundtime2) + { + NPC target = Projectile.Center.ClosestNPCAt(400, true, true); + Projectile.ai[0] = (target == null ? -1 : target.whoAmI); + } + + if (time > Soundtime1) + { + Projectile.rotation += 0.23f * spinDir * (float)Math.Pow(Utils.GetLerpValue(damageTime, Soundtime2, time, true), 1); + } + + float stabLerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime4, damageTime, time, true), 8); + Vector2 triPlace = (Vector2.UnitY * (230 - 150 * stabLerp)) * Projectile.scale; + if (time == Soundtime2) + MakePusle(Projectile.Center + triPlace.RotatedBy(Projectile.rotation)); + if (time == Soundtime3) + MakePusle(Projectile.Center + triPlace.RotatedBy(Projectile.rotation + MathHelper.TwoPi / 3)); + if (time == Soundtime4) + MakePusle(Projectile.Center + triPlace.RotatedBy(Projectile.rotation - MathHelper.TwoPi / 3)); + if (time == damageTime) + { + float visMult = (visual ? 1 : 0.6f); + if (visual) + { + Owner.SetScreenshake(5f); + + Particle spark = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 12, 1.35f, clr3, Projectile.scale * new Vector2(2.5f, 1.3f), true, true, shrinkSpeed: 1.25f, extraRotation: MathHelper.PiOver2); + GeneralParticleHandler.SpawnParticle(spark); + Particle spark2 = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 10, 1.05f, clr3, Projectile.scale * new Vector2(2f, 1.3f), true, true, shrinkSpeed: 0.7f); + GeneralParticleHandler.SpawnParticle(spark2); + + Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, clr1, "CalamityMod/Particles/BloomRing", Projectile.scale * new Vector2(0.6f, 1.4f), 0, 0.3f, 1.35f, 15); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new CustomPulse(Projectile.Center, Vector2.Zero, clr1, "CalamityMod/Particles/BloomRing", Projectile.scale * new Vector2(1.3f, 0.7f), 0, 0.25f, 1f, 15); + GeneralParticleHandler.SpawnParticle(pulse2); + + } + + for (int i = 0; i < 12; i++) + { + Vector2 vel = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5, 10); + Particle granite = new CustomSpark(Projectile.Center, vel, "CalamityMod/Particles/GlowTriangle", true, Main.rand.Next(30, 55 + 1), Projectile.scale * Main.rand.NextFloat(0.12f, 0.18f), (Main.rand.NextBool() ? clr1 : clr3) * visMult, Vector2.One, true, false, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.5f, 0.5f)); + GeneralParticleHandler.SpawnParticle(granite); + } + } + + if (SoundEngine.TryGetActiveSound(SoundSlot, out var Sound) && Sound.IsPlaying) + Sound.Position = Projectile.Center; + time++; + } + public void MakePusle(Vector2 position) + { + if (!visual) + return; + for (int i = 0; i < 8; i++) + { + Vector2 outerVel = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(1, 5); + Particle marble = new CustomSpark(position + outerVel * 5, outerVel, "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(18, 25 + 1), Projectile.scale * Main.rand.NextFloat(0.3f, 0.4f), Main.rand.NextBool() ? clr1 : clr3, Vector2.One, true, true, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.3f, 0.3f), glowOpacity: 0.8f); + GeneralParticleHandler.SpawnParticle(marble); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + float critDamage = Math.Min(Owner.GetTotalCritChance(AverageDamageClass.Instance) * 0.01f, 1f); + modifiers.SourceDamage *= 1 + critDamage; + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center) - Vector2.UnitY; + float launchPower = 9; + target.MoveNPC(launchVel, launchPower, true); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f, targetHitbox); + public override bool? CanDamage() + { + if (time >= damageTime && Projectile.numHits <= 0) + return null; + else + return false; + } + public override bool? CanHitNPC(NPC target) + { + if ((invalidTarget || Projectile.ai[0] == target.whoAmI) && Projectile.numHits <= 0) + return null; + return false; + } + public override bool PreDraw(ref Color lightColor) + { + if (!visual) + return false; + Asset tri = ModContent.Request("CalamityMod/Particles/GlowTriangle"); + Asset shine = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + float stabLerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime4, damageTime, time, true), 8); + Vector2 triPlace = Vector2.UnitY * (230 - 150 * stabLerp) * Projectile.scale; + + for (int i = 0; i < 6; i++) + { + float scale = Projectile.scale * (0.3f - 0.015f * i); + float rotation = Projectile.rotation; + float spawnScaleBonus = 0.3f; + float squashPower = 0.4f; + Color triColor = Color.Lerp(clr1, clr3, i * 0.14f); + if (time >= Soundtime2) + { + float lerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime2 + 13, Soundtime2, time, true), 2); + Main.EntitySpriteDraw(tri.Value, Projectile.Center + triPlace.RotatedBy(rotation) - Main.screenPosition, null, triColor with { A = 0 }, rotation + MathHelper.Pi * lerp, tri.Size() * 0.5f, Projectile.scale * new Vector2(0.05f * i + 1 - squashPower * (1 - lerp), -0.05f * i + 1 + squashPower * (1 - lerp)) * (scale + spawnScaleBonus * lerp), SpriteEffects.None); + } + if (time >= Soundtime3) + { + rotation += MathHelper.TwoPi / 3; + float lerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime3 + 13, Soundtime3, time, true), 2); + Main.EntitySpriteDraw(tri.Value, Projectile.Center + triPlace.RotatedBy(rotation) - Main.screenPosition, null, triColor with { A = 0 }, rotation + MathHelper.Pi * lerp, tri.Size() * 0.5f, Projectile.scale * new Vector2(0.05f * i + 1 - squashPower * (1 - lerp), -0.05f * i + 1 + squashPower * (1 - lerp)) * (scale + spawnScaleBonus * lerp), SpriteEffects.None); + } + if (time >= Soundtime4) + { + rotation += MathHelper.TwoPi / 3; + float lerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime4 + 13, Soundtime4, time, true), 2); + Main.EntitySpriteDraw(tri.Value, Projectile.Center + triPlace.RotatedBy(rotation) - Main.screenPosition, null, triColor with { A = 0 }, rotation + MathHelper.Pi * lerp, tri.Size() * 0.5f, Projectile.scale * new Vector2(0.05f * i + 1 - squashPower * (1 - lerp), -0.05f * i + 1 + squashPower * (1 - lerp)) * (scale + spawnScaleBonus * lerp), SpriteEffects.None); + } + + } + for (int i = 0; i < 4; i++) + { + float shineLerp = (float)Math.Pow(Utils.GetLerpValue(0, Soundtime4, time, true), 3); + Color clrLerp = Color.Lerp(clr1, clr3, i * 0.3f); + Color shineColor = Color.Lerp(clrLerp, Color.White, i * 0.2f) * shineLerp; + float shineScale = Projectile.scale * 0.4f + 0.3f * shineLerp; + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, shineColor with { A = 0 }, MathHelper.PiOver2, shine.Size() * 0.5f, new Vector2(0.5f - i * 0.15f, 1 + i * 0.2f) * (1 - i * 0.2f) * shineScale, SpriteEffects.None); + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, shineColor with { A = 0 }, 0, shine.Size() * 0.5f, new Vector2(0.5f - i * 0.15f, 1 + i * 0.2f) * (1 - i * 0.1f) * shineScale, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Typeless/BlackGlassBandProjectile.cs b/Projectiles/Typeless/BlackGlassBandProjectile.cs index 62e17f4eb4..b48eb8ccb2 100644 --- a/Projectiles/Typeless/BlackGlassBandProjectile.cs +++ b/Projectiles/Typeless/BlackGlassBandProjectile.cs @@ -1,4 +1,6 @@ -using CalamityMod.Items.Accessories; +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Accessories; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -11,6 +13,8 @@ namespace CalamityMod.Projectiles.Typeless { public new string LocalizationCategory => "Projectiles.Typeless"; public int time = 0; + public Player Owner => Main.player[Projectile.owner]; + public bool visual => Owner.Calamity().bGlassBandVisual; public override void SetDefaults() { Projectile.width = 2; @@ -28,27 +32,29 @@ namespace CalamityMod.Projectiles.Typeless { if (time == 0) { - SoundStyle sound = new("CalamityMod/Sounds/Custom/AuricMine", 3); - SoundEngine.PlaySound(sound with { Volume = 0.9f, Pitch = Main.rand.NextFloat(0.15f, 0.25f), MaxInstances = -1 }, Projectile.Center); - SoundStyle sound2 = new("CalamityMod/Sounds/Item/NullHit"); - SoundEngine.PlaySound(sound2 with { Volume = 0.6f, Pitch = Main.rand.NextFloat(0.3f, 0.45f), MaxInstances = -1 }, Projectile.Center); + float visMult = (visual ? 1 : 0.3f); + SoundStyle sound = new("CalamityMod/Sounds/Item/BlackGlassBandSound"); + if (visual) + { + SoundEngine.PlaySound(sound with { Volume = 1f, MaxInstances = -1 }, Projectile.Center); + float randRot = Main.rand.NextFloat(0, MathHelper.Pi); + for (int i = -1; i <= 1; i += 2) + { + Vector2 position = Projectile.Center + (Vector2.UnitX * 20 * i).RotatedBy(randRot); + Particle spark = new CustomSpark(position, Vector2.UnitY.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int i = -1; i <= 1; i += 2) + { + Vector2 position = Projectile.Center + (Vector2.UnitY * 20 * i).RotatedBy(randRot); + Particle spark = new CustomSpark(position, Vector2.UnitX.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); + GeneralParticleHandler.SpawnParticle(spark); + } + } for (int i = 0; i < 18; i++) { - Particle spark = new CustomSpark(Projectile.Center, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f), "CalamityMod/Particles/GlowOrbParticle", true, 35, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.NextBool() ? Color.DarkSlateBlue : Color.MediumPurple, new Vector2(0.8f, 1.2f), false); - GeneralParticleHandler.SpawnParticle(spark); - } - float randRot = Main.rand.NextFloat(0, MathHelper.Pi); - for (int i = -1; i <= 1; i += 2) - { - Vector2 position = Projectile.Center + (Vector2.UnitX * 20 * i).RotatedBy(randRot); - Particle spark = new CustomSpark(position, Vector2.UnitY.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); - GeneralParticleHandler.SpawnParticle(spark); - } - for (int i = -1; i <= 1; i += 2) - { - Vector2 position = Projectile.Center + (Vector2.UnitY * 20 * i).RotatedBy(randRot); - Particle spark = new CustomSpark(position, Vector2.UnitX.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); + Particle spark = new CustomSpark(Projectile.Center, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f), "CalamityMod/Particles/GlowOrbParticle", true, 35, Main.rand.NextFloat(0.6f, 0.8f), (Main.rand.NextBool() ? Color.DarkSlateBlue : Color.MediumPurple) * visMult, new Vector2(0.8f, 1.2f), false); GeneralParticleHandler.SpawnParticle(spark); } } @@ -57,12 +63,23 @@ namespace CalamityMod.Projectiles.Typeless public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { modifiers.SetCrit(); + float critDamage = Math.Min(Owner.GetTotalCritChance(AverageDamageClass.Instance) * 0.01f, 1f); + modifiers.SourceDamage *= (1 + critDamage); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - Player Owner = Main.player[Projectile.owner]; - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Owner.Calamity().bGlassbandCooldown > BlackGlassBand.cooldown / 2) - Owner.Calamity().bGlassbandCooldown = BlackGlassBand.cooldown / 2; + bool hasCD = Owner.Calamity().cooldowns.TryGetValue(GenericBandCooldown.ID, out CooldownInstance bandCD); + + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Owner.Calamity().generalBandCooldown > BlackGlassBand.cooldown / 2) + { + Owner.Calamity().generalBandCooldown -= BlackGlassBand.cooldown / 2; + if (hasCD) + bandCD.timeLeft -= BlackGlassBand.cooldown / 2; + } + } + public override bool? CanDamage() + { + return null; } } } diff --git a/Projectiles/Typeless/BlackPearl.png b/Projectiles/Typeless/BlackPearl.png new file mode 100644 index 0000000000..5c7aaa722a Binary files /dev/null and b/Projectiles/Typeless/BlackPearl.png differ diff --git a/Projectiles/Typeless/BlazingStarHeal.cs b/Projectiles/Typeless/BlazingStarHeal.cs index 813cd82252..d308e03726 100644 --- a/Projectiles/Typeless/BlazingStarHeal.cs +++ b/Projectiles/Typeless/BlazingStarHeal.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using CalamityMod.Enums; @@ -73,8 +72,8 @@ namespace CalamityMod.Projectiles.Typeless } } - internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 16f; - internal Color ColorFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (1f - completionRatio) * Projectile.scale * 16f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float hue = 0.35f + 0.1f * completionRatio * CalamityUtils.Convert01To010((Main.GlobalTimeWrappedHourly * 0.25f) % 1f); Color trailColor = Main.hslToRgb(hue, 0.6f, 0.5f); @@ -83,8 +82,8 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 25); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 25); Main.spriteBatch.EnterShaderRegion(BlendState.Additive); Texture2D sparkleTex = TextureAssets.Projectile[Type].Value; @@ -92,7 +91,7 @@ namespace CalamityMod.Projectiles.Typeless float bloomScale = (sparkleTex.Height / (float)bloomTex.Height) * Projectile.scale; float sparkleScale = (0.5f + CalamityUtils.Convert01To010((Main.GlobalTimeWrappedHourly % 2f) / 2f) * 0.2f) * Projectile.scale; - Color color = ColorFunction(0f); + Color color = ColorFunction(0f, Vector2.Zero); Vector2 drawPos = Projectile.Center - Main.screenPosition; Main.EntitySpriteDraw(bloomTex, drawPos, null, color * 0.5f, 0, bloomTex.Size() * 0.5f, 5f * bloomScale, SpriteEffects.None); @@ -108,9 +107,9 @@ namespace CalamityMod.Projectiles.Typeless SoundStyle fireHeal = new("CalamityMod/Sounds/Custom/PlantyMushMine", 3); SoundEngine.PlaySound(fireHeal with { Volume = 0.5f, Pitch = 0.3f }, Projectile.Center); - Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, ColorFunction(0f), "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.04f, 15); + Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, ColorFunction(0f, Vector2.Zero), "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.04f, 15); GeneralParticleHandler.SpawnParticle(pulse); - Color smokeColor = Color.Lerp(ColorFunction(0f), Color.DarkSlateGray, 0.5f); + Color smokeColor = Color.Lerp(ColorFunction(0f, Vector2.Zero), Color.DarkSlateGray, 0.5f); for (int i = 0; i < 7; i++) { Particle smoke = new HeavySmokeParticle(Projectile.Center, (Vector2.UnitX).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(7f), smokeColor, 30, Main.rand.NextFloat(0.4f, 1f), 0.5f, Main.rand.NextFloat(-0.03f, 0.03f), true); @@ -121,7 +120,7 @@ namespace CalamityMod.Projectiles.Typeless Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), (Vector2.UnitX).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(1.8f, 10f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.8f, 1.5f); - dust.color = ColorFunction(0f); + dust.color = ColorFunction(0f, Vector2.Zero); dust.noLightEmittence = true; } } diff --git a/Projectiles/Typeless/BlazingStarThatDoesNotHeal.cs b/Projectiles/Typeless/BlazingStarThatDoesNotHeal.cs index d782b2b97d..dc4e1c66ef 100644 --- a/Projectiles/Typeless/BlazingStarThatDoesNotHeal.cs +++ b/Projectiles/Typeless/BlazingStarThatDoesNotHeal.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; @@ -50,8 +49,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.velocity *= 1.015f; } - internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 16f; - internal Color ColorFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => (1f - completionRatio) * Projectile.scale * 16f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { float hue = 0.04f * (Projectile.ai[0] % 4f) + 0.1f * completionRatio * CalamityUtils.Convert01To010((Main.GlobalTimeWrappedHourly * 0.25f) % 1f); Color trailColor = Main.hslToRgb(hue, 0.8f, 0.6f); @@ -60,8 +59,8 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 8); + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 8); Main.spriteBatch.EnterShaderRegion(BlendState.Additive); Texture2D sparkleTex = TextureAssets.Projectile[Type].Value; @@ -69,7 +68,7 @@ namespace CalamityMod.Projectiles.Typeless float bloomScale = (float)sparkleTex.Height / (float)bloomTex.Height; float sparkleScale = 0.5f + CalamityUtils.Convert01To010((Main.GlobalTimeWrappedHourly % 2f) / 2f) * 0.2f; - Color color = ColorFunction(0f); + Color color = ColorFunction(0f, Vector2.Zero); float rotation = Projectile.rotation + Main.GlobalTimeWrappedHourly * 8f; Vector2 drawPos = Projectile.Center - Main.screenPosition; @@ -83,9 +82,9 @@ namespace CalamityMod.Projectiles.Typeless public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, ColorFunction(0f), "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.04f, 15); + Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, ColorFunction(0f, Vector2.Zero), "CalamityMod/Particles/SoftRoundExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.04f, 15); GeneralParticleHandler.SpawnParticle(pulse); - Color smokeColor = Color.Lerp(ColorFunction(0f), Color.DarkSlateGray, 0.5f); + Color smokeColor = Color.Lerp(ColorFunction(0f, Vector2.Zero), Color.DarkSlateGray, 0.5f); for (int i = 0; i < 7; i++) { Particle smoke = new HeavySmokeParticle(Projectile.Center, (Vector2.UnitX).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(7f), smokeColor, 30, Main.rand.NextFloat(0.4f, 1f), 0.5f, Main.rand.NextFloat(-0.03f, 0.03f), true); @@ -96,11 +95,13 @@ namespace CalamityMod.Projectiles.Typeless Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), (Vector2.UnitX).RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(1.8f, 10f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.8f, 1.5f); - dust.color = ColorFunction(0f); + dust.color = ColorFunction(0f, Vector2.Zero); dust.noLightEmittence = true; } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 60 * 5); + //Doze - I gave all parry accessories long debuff infliction times due to the lack of weapons that inflict debuffs for a decent time, and the scarcity of using the parry + //Most common vanilla debuffs have a way to inflict them for 15, 20, or even 30 seconds + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(15)); } } diff --git a/Projectiles/Typeless/BloodBomb.cs b/Projectiles/Typeless/BloodBomb.cs index a1b97fc5f4..c0252c1c57 100644 --- a/Projectiles/Typeless/BloodBomb.cs +++ b/Projectiles/Typeless/BloodBomb.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 20; Projectile.friendly = true; Projectile.penetrate = 1; - Projectile.extraUpdates = 1; - Projectile.timeLeft = 600; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 180 * Projectile.MaxUpdates; } public override void AI() diff --git a/Projectiles/Typeless/BloodBombExplosion.cs b/Projectiles/Typeless/BloodBombExplosion.cs index 9a9dcd2707..9568e3ff9d 100644 --- a/Projectiles/Typeless/BloodBombExplosion.cs +++ b/Projectiles/Typeless/BloodBombExplosion.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Typeless/BloomStoneFlower.cs b/Projectiles/Typeless/BloomStoneFlower.cs new file mode 100644 index 0000000000..80e590b0d6 --- /dev/null +++ b/Projectiles/Typeless/BloomStoneFlower.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class BloomStoneFlower : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/Magic/BeamingBolt"; + + public ref float HookIndex => ref Projectile.ai[0]; + public ref float FlowerPart => ref Projectile.ai[1]; + + public ref float timer => ref Projectile.ai[2]; + public float fadeTime = 0; + public bool fadeOut = false; + public int maxTime = 5; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 30; + Projectile.scale = 1f; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 150; + } + + public override void AI() + { + if (timer == 0) + Projectile.rotation = Main.rand.NextFloat(0, MathHelper.TwoPi); + switch (FlowerPart) + { + case 0: + Projectile hook = Main.projectile[(int)HookIndex]; + if (!(hook.active && hook.aiStyle == ProjAIStyleID.Hook && hook.ai[0] == 2f)) + { + fadeOut = true; + } + float sine = (float)Math.Sin(timer * 0.01f); + Projectile.rotation += fadeTime * sine * 0.005f; + if (Projectile.scale > 1) + Projectile.scale = MathHelper.Lerp(Projectile.scale, 1, 0.15f); + + Projectile.timeLeft++; + if (!fadeOut && Vector2.DistanceSquared(Projectile.Center, Main.player[Projectile.owner].Center) < 4096f) + { + SoundEngine.PlaySound(SoundID.Item60, Projectile.Center); + if (Main.myPlayer == Projectile.owner) + { + int dusts = 6; + int dir = Main.rand.NextBool() ? -1 : 1; + for (int i = 0; i < dusts; i++) + { + Projectile pollen = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, (MathHelper.TwoPi / dusts * i).ToRotationVector2() * 3f, Type, 0, 0f, Projectile.owner, 0f, 1f); + pollen.localAI[0] = dir; + } + + } + fadeOut = true; + Projectile.scale = 2.5f; + } + if ((fadeOut && Projectile.scale <= 1.05f) || (!fadeOut && fadeTime < maxTime)) + fadeTime += (fadeOut ? -0.2f : 1); + + if (fadeTime < 0 && fadeOut) + Projectile.Kill(); + break; + case 1: + if (timer == 0) + { + Projectile.scale = 1.8f; + Projectile.extraUpdates = 1; + } + if (Projectile.width < 90) + Projectile.ExpandHitboxBy(90); + Projectile.velocity = Projectile.velocity.RotatedBy(0.04f * Projectile.localAI[0]) * 1.001f; + Color mistColor = Color.Lerp(Color.HotPink, Color.Gold, Utils.GetLerpValue(100, 0, Projectile.timeLeft, true)); + // Visual effect + if (Projectile.timeLeft % 4 == 0) + { + MediumMistParticle pollenCloud = new(Projectile.Center, Main.rand.NextVector2Circular(1f, 1f), mistColor, mistColor, 3f * Projectile.scale, 100f); + GeneralParticleHandler.SpawnParticle(pollenCloud); + } + if (Projectile.timeLeft % 4 == 0) + { + Dust pollenDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), newColor: mistColor, Scale: 0.6f * Projectile.scale); + pollenDust.noLightEmittence = true; + pollenDust.noGravity = true; + } + if (Projectile.scale > 0.7f) + Projectile.scale -= 0.025f; + + // Check for buffing + Player owner = Main.player[Projectile.owner]; + foreach (Player p in Main.ActivePlayers) + { + if (!(p == owner || (p.team == owner.team && owner.team != 0))) + continue; + + if (Projectile.Hitbox.Intersects(p.Hitbox)) + p.Calamity().bloomStoneBuffedHealRateTimer = 360; + } + fadeTime++; + break; + } + timer++; + } + + public override bool PreDraw(ref Color lightColor) + { + if (FlowerPart == 0f) + { + Texture2D tex2 = ModContent.Request("CalamityMod/Particles/BigHeart").Value; + Texture2D tex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + int parts = 5; + float rot = 0; + float scaleFade = (float)Math.Pow(Utils.GetLerpValue(0, maxTime, fadeTime, true), 2); + for (int b = 0; b < 3; b++) + { + Color drawColor = Color.Lerp(Color.HotPink, Color.Plum, b * 0.3f) with { A = 0 }; + float scaleMult = (1 - 0.15f * b) * scaleFade; + for (int i = 0; i < parts; i++) + { + Vector2 vel = (MathHelper.TwoPi * i / parts).ToRotationVector2(); + Main.EntitySpriteDraw(tex2, Projectile.Center - Main.screenPosition + vel.RotatedBy(Projectile.rotation * (float)Math.Pow(1.5f - scaleMult, 2) + rot) * 35 * scaleMult, null, drawColor * 0.3f, Projectile.rotation * (float)Math.Pow(1.5f - scaleMult, 2) + vel.ToRotation() + MathHelper.PiOver2 + rot, tex2.Size() / 2f, new Vector2(0.9f, 1.5f) * Projectile.scale * 0.15f * scaleMult, SpriteEffects.None, 0); + } + rot += MathHelper.PiOver4 * 0.5f; + } + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Color.Gold with { A = 0 }, Projectile.rotation, tex.Size() / 2f, Projectile.scale * 0.45f * scaleFade, SpriteEffects.None, 0); + + return false; + } + else return false; + } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + overPlayers.Add(index); + } + } +} diff --git a/Projectiles/Typeless/BlunderBoosterAura.cs b/Projectiles/Typeless/BlunderBoosterAura.cs index 4a534b93c1..a083ecbb2e 100644 --- a/Projectiles/Typeless/BlunderBoosterAura.cs +++ b/Projectiles/Typeless/BlunderBoosterAura.cs @@ -9,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class BlunderBoosterAura : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; @@ -65,23 +66,9 @@ namespace CalamityMod.Projectiles.Typeless } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 180); - - if (target.knockBackResist <= 0f) - return; - - // 12AUG2023: Ozzatron: TML was giving NaN knockback, probably due to 0 base knockback. Do not use hit.Knockback - if (CalamityGlobalNPC.ShouldAffectNPC(target)) - { - float knockbackMultiplier = MathHelper.Clamp(1f - target.knockBackResist, 0f, 1f); - Vector2 trueKnockback = target.Center - Projectile.Center; - trueKnockback.Normalize(); - target.velocity = trueKnockback * knockbackMultiplier; - } - } - + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); + // CIT 2MAY2025: Replaced old manual knockback code with setting HitDirectionOverride + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.HitDirectionOverride = (target.Center.X > Projectile.Center.X).ToDirectionInt(); public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Typeless/BossRushEffectThing.cs b/Projectiles/Typeless/BossRushEffectThing.cs index 7b91925a73..a03f5c6055 100644 --- a/Projectiles/Typeless/BossRushEffectThing.cs +++ b/Projectiles/Typeless/BossRushEffectThing.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Typeless float currentShakePower = MathHelper.Lerp(8f, 12f, Utils.GetLerpValue(BossRushEvent.StartEffectTotalTime * 0.6f, BossRushEvent.StartEffectTotalTime, Time, true)); currentShakePower *= 1f - Utils.GetLerpValue(1500f, 3700f, Main.LocalPlayer.Distance(Projectile.Center), true); - Main.LocalPlayer.Calamity().GeneralScreenShakePower = currentShakePower; + Main.LocalPlayer.SetScreenshake(currentShakePower); Time++; } diff --git a/Projectiles/Typeless/BossRushEndEffectThing.cs b/Projectiles/Typeless/BossRushEndEffectThing.cs index 67ad0a2a99..769281d1cd 100644 --- a/Projectiles/Typeless/BossRushEndEffectThing.cs +++ b/Projectiles/Typeless/BossRushEndEffectThing.cs @@ -1,5 +1,5 @@ using CalamityMod.Events; -using CalamityMod.Items; +using CalamityMod.Items.Placeables; using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Typeless float currentShakePower = MathHelper.Lerp(1f, 20f, Utils.GetLerpValue(140f, 180f, Time, true) * Utils.GetLerpValue(10f, 40f, Projectile.timeLeft, true)); if (Projectile.timeLeft > 5) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = currentShakePower; + Main.LocalPlayer.SetScreenshake(currentShakePower); MoonlordDeathDrama.RequestLight(Utils.GetLerpValue(220f, 265f, Time, true) * Utils.GetLerpValue(10f, 30f, Projectile.timeLeft, true), Main.LocalPlayer.Center); diff --git a/Projectiles/Typeless/ChlorophyteLifePulse.cs b/Projectiles/Typeless/ChlorophyteLifePulse.cs deleted file mode 100644 index 98e98e702e..0000000000 --- a/Projectiles/Typeless/ChlorophyteLifePulse.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Items.VanillaArmorChanges; -using CalamityMod.Projectiles.VanillaProjectileOverrides; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Typeless -{ - public class ChlorophyteLifePulse : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Typeless"; - - public const int Lifetime = 60; - - public float LifetimeCompletion => 1f - Projectile.timeLeft / (float)Lifetime; - - public override void SetDefaults() - { - Projectile.width = 96; - Projectile.height = 96; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.penetrate = -1; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 30; - Projectile.timeLeft = Lifetime; - } - - public override bool? CanHitNPC(NPC target) => !target.CountsAsACritter && !target.friendly && target.chaseable; - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Projectile.damage = (int)(Projectile.damage * 0.8f); - - public override void AI() - { - Projectile.Opacity = 1f - (float)Math.Pow(LifetimeCompletion, 1.56); - Projectile.scale = MathHelper.Lerp(0.5f, 6f, LifetimeCompletion); - - // Heal all members of the same team. - if (Projectile.timeLeft == (int)(Lifetime * 0.925f)) - { - Player owner = Main.player[Projectile.owner]; - List membersOfSameTeam = new List() - { - owner - }; - if (owner.team != 0) - membersOfSameTeam.AddRange(Main.player.Where(p => p.team == owner.team && p.active && !p.dead)); - - foreach (Player player in membersOfSameTeam) - { - if (player.Calamity().ChlorophyteHealDelay > 0) - continue; - - int healQuantity = (int)owner.GetBestClassDamage().ApplyTo(ChlorophyteArmorSetChange.AmountToHealPerPulse); - player.HealPlayer(healQuantity); - player.Calamity().ChlorophyteHealDelay = ChlorophyteArmorSetChange.DelayBetweenHeals; - } - } - } - - public override Color? GetAlpha(Color lightColor) - { - Color c1 = new Color(142, 255, 155, 0); - Color c2 = new Color(0, 142, 113, 92); - return Color.Lerp(c1, c2, 1f - Projectile.Opacity) * Projectile.Opacity * 0.67f; - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Color drawColor = Projectile.GetAlpha(lightColor) * 0.4f; - for (int i = 0; i < 8; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 4f; - Vector2 drawPosition = Projectile.Center - Main.screenPosition + drawOffset; - Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, 0f, texture.Size() * 0.5f, Projectile.scale, 0, 0); - } - return false; - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.scale * 48f, targetHitbox); - - public override bool OnTileCollide(Vector2 oldVelocity) => false; - } -} diff --git a/Projectiles/Typeless/ChlorophyteLifePulse.png b/Projectiles/Typeless/ChlorophyteLifePulse.png deleted file mode 100644 index f51029ba21..0000000000 Binary files a/Projectiles/Typeless/ChlorophyteLifePulse.png and /dev/null differ diff --git a/Projectiles/Typeless/ChronoClock.cs b/Projectiles/Typeless/ChronoClock.cs index b699426f5d..03055c91ba 100644 --- a/Projectiles/Typeless/ChronoClock.cs +++ b/Projectiles/Typeless/ChronoClock.cs @@ -1,6 +1,4 @@ -using System.IO; -using CalamityMod.Buffs.StatBuffs; -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.StatBuffs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Typeless/ClaretCannonProj.cs b/Projectiles/Typeless/ClaretCannonProj.cs new file mode 100644 index 0000000000..0a67da9052 --- /dev/null +++ b/Projectiles/Typeless/ClaretCannonProj.cs @@ -0,0 +1,78 @@ +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Items.Weapons.Typeless; +using CalamityMod.Projectiles.Healing; +using CalamityMod.Particles; + +namespace CalamityMod.Projectiles.Typeless +{ + public class ClaretCannonProj : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 14; + Projectile.friendly = true; + Projectile.alpha = 0; + Projectile.penetrate = 1; + Projectile.DamageType = AverageDamageClass.Instance; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; + Projectile.aiStyle = 0; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0f / 255f); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.Dig, Projectile.position); + return true; + } + + public override void OnKill(int timeLeft) + { + if (Projectile.penetrate != -1) + return; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCKilled/PerfLargeDeath") { Volume = 0.5f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BloodPactCrit") { Volume = 0.5f }, Projectile.Center); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), ClaretCannon.ClaretCooldownMax / 2); + target.AddBuff(BuffID.BetsysCurse, ClaretCannon.ClaretCooldownMax); + if (Projectile.penetrate == -1) + return; + var player = Main.player[Projectile.owner]; + float orbCount = 20; + for (var i = 0; i < orbCount; i++) + { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(1) * Main.rand.NextFloat(2.75f, 5.25f), ModContent.ProjectileType(), 20, 0f, player.whoAmI); + } + Projectile.position = Projectile.Center; + Projectile.Size = new Vector2(352); + Projectile.Center = Projectile.position; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.timeLeft = 2; + Projectile.velocity *= 0; + Projectile.damage /= 2; + float particleScale = 8f; + Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f*particleScale/5f, 0.87f * particleScale / 5f, (int)(40 * 0.38f), false); + GeneralParticleHandler.SpawnParticle(bloodsplosion); + Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(255, 32, 32), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f * particleScale / 5f, 0.155f * particleScale / 5f, 40); + GeneralParticleHandler.SpawnParticle(bloodsplosion2); + } + } +} \ No newline at end of file diff --git a/Projectiles/Ranged/ClaretCannonProj.png b/Projectiles/Typeless/ClaretCannonProj.png similarity index 100% rename from Projectiles/Ranged/ClaretCannonProj.png rename to Projectiles/Typeless/ClaretCannonProj.png diff --git a/Projectiles/Typeless/CoralBubble.cs b/Projectiles/Typeless/CoralBubble.cs index 9d4cd5e92e..79b2ee73bf 100644 --- a/Projectiles/Typeless/CoralBubble.cs +++ b/Projectiles/Typeless/CoralBubble.cs @@ -1,5 +1,5 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using System; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -63,7 +63,16 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { + Vector3 lightCol = new(85f / 255f, 151f / 255f, 196f / 255f); + float brightness = 0.7f; + float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.01f; + brightness *= (float)MathF.Sin(8f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); + brightness += 0.4f; + brightness = MathHelper.Clamp(brightness, 0.1f, 0.5f); + lightCol *= brightness; + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + Lighting.AddLight(Projectile.position, lightCol); return false; } diff --git a/Projectiles/Typeless/CoralBubbleSmall.cs b/Projectiles/Typeless/CoralBubbleSmall.cs index d6bc051dae..0aabb0c866 100644 --- a/Projectiles/Typeless/CoralBubbleSmall.cs +++ b/Projectiles/Typeless/CoralBubbleSmall.cs @@ -1,5 +1,5 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using System; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -66,7 +66,16 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { + Vector3 lightCol = new(85f / 255f, 151f / 255f, 196f / 255f); + float brightness = 0.7f; + float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.01f; + brightness *= (float)MathF.Sin(8f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); + brightness += 0.4f; + brightness = MathHelper.Clamp(brightness, 0.1f, 0.5f); + lightCol *= brightness; + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + Lighting.AddLight(Projectile.position, lightCol); return false; } diff --git a/Projectiles/Typeless/CosmicDashExplosion.cs b/Projectiles/Typeless/CosmicDashExplosion.cs index d92fe0dfd8..cf2664cf46 100644 --- a/Projectiles/Typeless/CosmicDashExplosion.cs +++ b/Projectiles/Typeless/CosmicDashExplosion.cs @@ -1,5 +1,4 @@ -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; @@ -40,7 +39,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); for (int i = 0; i < 35; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 181, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.9f), 0, default, Main.rand.NextFloat(1.5f, 2.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.GiantCursedSkullBolt, new Vector2(4.5f, 4.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.9f), 0, default, Main.rand.NextFloat(1.5f, 2.8f)); dust.shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); dust.noGravity = true; } @@ -48,10 +47,10 @@ namespace CalamityMod.Projectiles.Typeless { Vector2 dustVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, 272, dustVel, 0, default, 1f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, DustID.WitherLightning, dustVel, 0, default, 1f); dust.shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, 226, dustVel, 0, default, 1f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, DustID.Electric, dustVel, 0, default, 1f); dust.shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); } } diff --git a/Projectiles/Typeless/CryonicShield.cs b/Projectiles/Typeless/CryonicShield.cs index d32a00d7f5..c07289dd98 100644 --- a/Projectiles/Typeless/CryonicShield.cs +++ b/Projectiles/Typeless/CryonicShield.cs @@ -9,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class CryonicShield : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; @@ -56,36 +57,20 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - if (!modPlayer.CryoStoneVanity) + if (!player.Calamity().CryoStoneVanity) { target.AddBuff(BuffID.Frostburn2, 180); target.AddBuff(ModContent.BuffType(), 30); - - if (target.knockBackResist <= 0f) - return; - - // 12AUG2023: Ozzatron: TML was giving NaN knockback, probably due to 0 base knockback. Do not use hit.Knockback - if (CalamityGlobalNPC.ShouldAffectNPC(target)) - { - float knockbackMultiplier = MathHelper.Clamp(1f - target.knockBackResist, 0f, 1f); - Vector2 trueKnockback = target.Center - Projectile.Center; - trueKnockback.Normalize(); - target.velocity = trueKnockback * knockbackMultiplier; - } } } - + // CIT 2MAY2025: Replaced old manual knockback code with setting HitDirectionOverride + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.HitDirectionOverride = (target.Center.X > Projectile.Center.X).ToDirectionInt(); public override void OnHitPlayer(Player target, Player.HurtInfo info) { Player player = Main.player[Projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); if (!modPlayer.CryoStoneVanity) - { target.AddBuff(BuffID.Frostburn2, 180); - target.AddBuff(ModContent.BuffType(), 30); - } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.Size.Length() * 0.5f, targetHitbox); diff --git a/Projectiles/Typeless/CursorProj.cs b/Projectiles/Typeless/CursorProj.cs index 99313d1a2a..7caeee006b 100644 --- a/Projectiles/Typeless/CursorProj.cs +++ b/Projectiles/Typeless/CursorProj.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Typeless/CursorProjSplit.cs b/Projectiles/Typeless/CursorProjSplit.cs index 3c2174243a..4d32133339 100644 --- a/Projectiles/Typeless/CursorProjSplit.cs +++ b/Projectiles/Typeless/CursorProjSplit.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; diff --git a/Projectiles/Typeless/CyanLabSeeker.cs b/Projectiles/Typeless/CyanLabSeeker.cs index 07f7da0ee5..86955b5471 100644 --- a/Projectiles/Typeless/CyanLabSeeker.cs +++ b/Projectiles/Typeless/CyanLabSeeker.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), DustID.RainbowMk2); dust.color = Color.Cyan; dust.scale = Main.rand.NextFloat(0.95f, 1.25f); dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); diff --git a/Projectiles/Typeless/DarkIce.cs b/Projectiles/Typeless/DarkIce.cs index bc65e2df07..b601c92938 100644 --- a/Projectiles/Typeless/DarkIce.cs +++ b/Projectiles/Typeless/DarkIce.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.extraUpdates = 1; Projectile.coldDamage = true; Projectile.npcProj = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Typeless/DeepseaBlaze.cs b/Projectiles/Typeless/DeepseaBlaze.cs index d23c7925f4..b2392cd355 100644 --- a/Projectiles/Typeless/DeepseaBlaze.cs +++ b/Projectiles/Typeless/DeepseaBlaze.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/DemonshadeRedDevil.cs b/Projectiles/Typeless/DemonshadeRedDevil.cs index 6a464560cb..28a575a76d 100644 --- a/Projectiles/Typeless/DemonshadeRedDevil.cs +++ b/Projectiles/Typeless/DemonshadeRedDevil.cs @@ -2,7 +2,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/DiamondOfTheDeepProjectile.cs b/Projectiles/Typeless/DiamondOfTheDeepProjectile.cs new file mode 100644 index 0000000000..c8339673f9 --- /dev/null +++ b/Projectiles/Typeless/DiamondOfTheDeepProjectile.cs @@ -0,0 +1,638 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Sounds; +using CalamityMod.Tiles.Ores; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class DiamondOfTheDeepProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public Color bColor = Color.White; // Shifting color, used for most effects + public Color color1 = Color.White; + public Color color2 = Color.White; + public bool canDamage = false; + public bool visuals => Owner.Calamity().dOfTheDeepVisual; // Enables/disables visuals and sounds based on accessory visibility + public ref float time => ref Projectile.ai[0]; + public ref float energyNumber => ref Projectile.ai[1]; // The number assigned to this energy, ranging from 1 to the max number of projectiles + public bool idle => Projectile.ai[2] == 0; // Floating around the player + public bool healing = false; // If the projectiles should heal the player. If false they will attack + public NPC targeted; // Chosen target to home into + public int hitCooldown = 0; // Only for VOID, time after hit that it turns around before another hit + public ref float projType => ref Projectile.localAI[2]; + public override void SetStaticDefaults() + { + ProjectileID.Sets.NoLiquidDistortion[Type] = true; + } + public override void SetDefaults() + { + Projectile.width = Projectile.height = 30; + Projectile.ignoreWater = true; + Projectile.timeLeft = 600; + Projectile.tileCollide = false; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + // Hello, if you're trying to use code from this thing + // DO NOT + // It's very messy and confusing, because it was coded in pieces over the course of months with various levels of skill + // If I ever make another thing like this it will most certainly be 3 seperate projectiles, or at least use AIState instead + public override void AI() + { + Vector2 velocity = Projectile.velocity; + int startTime = (projType == 0 ? 70 : projType == 1 ? 140 : 210) + 15; // Time after launch when it will begin attacking/healing + int endTime = 320; // Time after launch when it's movement code reaches it's cap on strength + + #region Color Shifting + if (time == 0 && idle) + { + switch (projType) // 0 = gravel/vines, 1 = hadal/hydrothermic, 2 = void/lumenyl + { + case 0: + { + color1 = Color.MediumSeaGreen; + color2 = Color.DarkSlateGray; + break; + } + case 1: + { + color1 = Color.DarkRed; + color2 = Color.OrangeRed; + break; + } + case 2: + { + color1 = Color.MediumBlue; + color2 = Color.DodgerBlue; + break; + } + } + } + + float rate = Main.GlobalTimeWrappedHourly * 5; + List eColors = new List() + { + color1, + color2 + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + bColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + #endregion + + if (idle || time < startTime) // If not attacking/healing keep it alive + Projectile.timeLeft++; + + if (Owner.dead || !Owner.Calamity().dOfTheDeep) + Projectile.Kill(); + + if (Utils.Distance(Owner.Center, Projectile.Center) > 1100) // If it's too far away either teleport to the player if idle (or kill it if needed) + { + if (idle) + Projectile.Center = Owner.Center; + else if (targeted == null && !healing) + Projectile.Kill(); + } + + // Emit some light + Lighting.AddLight(Projectile.Center, bColor.ToVector3() * 1.5f); + + #region Dust Trails + float velLerp = Utils.GetLerpValue(-1.5f, 3f, Projectile.velocity.Length(), true); + if (projType == 0 && visuals) + { + if (Main.rand.NextBool((int)(14 - 5 * velLerp))) + { + Dust c = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(6, 6) * Projectile.scale + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15, ModContent.DustType()); + c.velocity = -Projectile.velocity * Main.rand.NextFloat(0.3f, 1f) * velLerp; + c.scale = Main.rand.NextFloat(1f, 1.3f) * velLerp; + c.noGravity = true; + c.color = Main.rand.NextBool() ? Color.Aquamarine : bColor; + c.noLightEmittence = true; + c.fadeIn = 1; + c.alpha = 100; + } + } + if (projType == 1 && visuals) + { + if (Main.rand.NextBool((int)(10 - 5 * velLerp))) + { + Dust c = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15, ModContent.DustType()); + c.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.6f, 1.3f) * velLerp; + c.scale = Main.rand.NextFloat(1.2f, 1.5f) * velLerp; + c.noGravity = true; + c.color = bColor; + c.noLightEmittence = true; + c.noGravity = !Main.rand.NextBool(3); + } + } + if (projType == 2 && visuals) + { + if (Main.rand.NextBool((int)(3 - velLerp))) + { + Dust c = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(6, 6) * Projectile.scale + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15, ModContent.DustType()); + c.velocity = -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(1.4f, 3.5f) * velLerp; + c.scale = Main.rand.NextFloat(1.8f, 2.3f) * velLerp; + c.noGravity = true; + c.color = bColor; + c.noLightEmittence = true; + c.fadeIn = 2.3f; + } + } + #endregion + + if (idle) // Following Ai + { + if (time == 0 && visuals) // On spawn fx + { + for (int i = 0; i <= 10; i++) + { + float variance = Main.rand.NextFloat(-0.5f, 0.5f); + Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)) * 2; + float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f; + + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), vel); + dust2.scale = scale * 3; + dust2.noGravity = true; + dust2.color = bColor; + dust2.noLightEmittence = true; + } + } + if (time > 80) // Track the player in a natural motion simular to swimming + { + float homingSpeed = Utils.Remap(Utils.Distance(Projectile.Center, Owner.Center), 200, 600, 0.07f, 0.16f) + 0.009f * energyNumber; + float offsetPower = Utils.GetLerpValue(1, 5, Owner.velocity.Length(), true); + float sine = (float)Math.Sin((time * 0.1f) / MathHelper.Pi); + float sine2 = (float)Math.Sin((time * 0.04f) / MathHelper.Pi); + Vector2 bonusMobility = (offsetPower > 0 ? ((Utils.DirectionTo(Projectile.Center, Owner.Center) * 90) * sine2).RotatedBy(0.8f * sine) * offsetPower : Vector2.Zero); + Vector2 goalPosition = Owner.MountedCenter + bonusMobility + ((MathHelper.TwoPi * energyNumber) / Math.Max(Owner.ownedProjectileCounts[ModContent.ProjectileType()], 1)).ToRotationVector2().RotatedBy(Main.GlobalTimeWrappedHourly * 0.4f) * 20; + + bool outOfRange = Utils.Distance(Projectile.Center, goalPosition) > 120; + if (Projectile.velocity.Length() < 6 && outOfRange) + Projectile.velocity = Projectile.velocity * 0.995f + Utils.DirectionTo(Projectile.Center, goalPosition) * homingSpeed; + else if (outOfRange) + Projectile.velocity *= 0.985f; + if (!outOfRange) + Projectile.velocity = Projectile.velocity.RotatedBy(0.0065f * (energyNumber % 2 == 0 ? -1 : 1)) * 1.004f; + + velocity = Projectile.velocity; + } + else + Projectile.velocity *= 0.99f; + } + else // Attack/Healing Ai + { + if (Projectile.ai[2] == 5) // Effects for the moment they stop being idle + { + time = 0; + healing = (Owner.statLife < Owner.statLifeMax2 * 0.5f); + Projectile.ai[2]++; + } + if (healing) + startTime = 100; + if (time <= startTime) // Get into position before the attack/heal + { + float timeLerp = Utils.GetLerpValue(0, startTime * 0.5f, time, true); + int distFromPlayer = (int)(160 + (healing ? 240 * Utils.GetLerpValue(0, startTime * 0.8f, time, true) : 0)); + int moveSpeed = (int)(90 - 85 * timeLerp); + if (projType == 0) + { + Vector2 destination = Owner.Center + Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).RotatedBy(MathHelper.TwoPi / 3) * distFromPlayer; + Projectile.velocity = (destination - Projectile.Center) / moveSpeed; + velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + } + if (projType == 1) + { + Vector2 destination = Owner.Center + Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * distFromPlayer; + Projectile.velocity = (destination - Projectile.Center) / moveSpeed; + velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + } + if (projType == 2) + { + Vector2 destination = Owner.Center + Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).RotatedBy(-(MathHelper.TwoPi / 3)) * distFromPlayer; + Projectile.velocity = (destination - Projectile.Center) / moveSpeed; + velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + } + } + + if (healing) // Heal/Buff player (only occurs below 50% HP) + { + if (time > startTime) + { + float sine = (float)Math.Sin((time * 0.3f) / MathHelper.Pi); + Projectile.extraUpdates = 6; + + if (time > startTime) + { + float homingSpeed = Utils.Remap(time, startTime, endTime, 0.01f, 0.1f); + + Vector2 goalPosition = Owner.Center; + + if (Projectile.velocity.Length() < 5) + Projectile.velocity = Projectile.velocity.RotatedBy(0.02f * sine) * 0.99f + Utils.DirectionTo(Projectile.Center, goalPosition) * homingSpeed; + else + Projectile.velocity *= 0.985f; + + if (Utils.Distance(goalPosition, Projectile.Center) < 50) + { + if (projType == 0) // Heals you for 8 flat + { + Owner.HealPlayer(8); + } + if (projType == 1) // Gives you a temporary defense buff + { + Owner.Calamity().dOfTheDeepDefenseBuffTimer = Owner.Calamity().dOfTheDeepDefenseBuffMax; + } + if (projType == 2) // Heals you for 5% max hp + { + int healValue = (int)((float)(Owner.statLifeMax2) * 0.05f); + Owner.HealPlayer(healValue); + } + + Projectile.Kill(); + } + } + } + } + else // Attacking + { + if (time > startTime) + { + if (canDamage == false) // Effects for the moment they begin attacking + { + if (visuals) + { + SoundStyle fire = AstrumDeusHead.GodRaySound; + SoundEngine.PlaySound(fire with { Volume = 0.3f, Pitch = (Main.rand.NextFloat(-0.6f, -0.5f) + projType * 0.1f) }, Projectile.Center); + SoundStyle fire2 = StatisVoidSash.VoidDash; + SoundEngine.PlaySound(fire2 with { Volume = 0.3f, Pitch = (Main.rand.NextFloat(0.2f, 0.4f) + projType * 0.1f) }, Projectile.Center); + } + + NPC tempTarget = Projectile.Center.ClosestNPCAt(1200); + Vector2 aimTo = (tempTarget == null ? Owner.Calamity().mouseWorld : tempTarget.Center); + if (projType == 0) + { + Projectile.velocity = Utils.DirectionTo(Projectile.Center, aimTo) * 2; + Projectile.extraUpdates = 3; + } + if (projType == 1) + { + Projectile.velocity = Utils.DirectionTo(Projectile.Center, aimTo) * 11; + Projectile.extraUpdates = 18; + + if (visuals) + { + for (float i = 1; i <= 1.4f; i += 0.4f) + { + Particle pulse = new CustomSpark(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7 * i, "CalamityMod/Particles/BloomRing", false, 18, 0.5f / i, bColor, new Vector2(3f, 1f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + } + if (projType == 2) + { + Projectile.velocity = Utils.DirectionTo(Projectile.Center, aimTo) * 7; + Projectile.extraUpdates = 7; + Projectile.localNPCHitCooldown = 5; + Projectile.timeLeft = 600; + + if (visuals) + { + Particle pulse = new CustomSpark(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitX) * 5, "CalamityMod/Particles/BloomRing", false, 14, 0.35f, bColor, new Vector2(3f, 1f), extraRotation: MathHelper.ToRadians(90), shrinkSpeed: 0.9f); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + + if (visuals) + { + for (int i = 0; i <= 12; i++) + { + float variance = Main.rand.NextFloat(-0.7f, 0.7f); + Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 24).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)); + float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f; + + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), vel); + dust2.scale = scale * 4; + dust2.noGravity = true; + dust2.color = bColor; + dust2.noLightEmittence = true; + } + } + } + canDamage = true; + + float homingSpeed = Utils.Remap(time, startTime, endTime, 0.01f, 0.5f); + if (projType == 0) + { + targeted = Owner.Calamity().mouseWorld.ClosestNPCAt(2300); + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, homingSpeed, 25, 0.99f, accelerate: true); + + if (targeted == null) + { + if (Projectile.velocity.Y > 5) + { + Projectile.velocity.Y += 0.8f * homingSpeed; + Projectile.velocity.X *= 0.997f; + } + } + else + Projectile.timeLeft++; + } + if (projType == 2) + { + if (hitCooldown > 0) + hitCooldown--; + float timeLerp = Utils.GetLerpValue(400, 800, Projectile.timeLeft, true); // While a target is active, lifetime goes up, which increases homing power + if (targeted == null && hitCooldown == 0) + { + CalamityUtils.HomeInOnSelectedNPC(Projectile, Owner.Calamity().mouseWorld.ClosestNPCAt(2300), true, 0.5f, 10, 0.99f, accelerate: true); + } + else if (hitCooldown == 0) + { + Projectile.timeLeft += 2; + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.6f * timeLerp, 10, 0.99f, accelerate: true); + } + else + { + if (hitCooldown < 100) + Projectile.velocity = Projectile.velocity.RotatedBy((Projectile.numHits % 2 == 0 ? 1 : -1) * 0.0363f) * 0.99f; + } + if (targeted != null && (targeted.life <= 0 || !targeted.CanBeChasedBy() || !targeted.active)) + targeted = null; + } + } + } + } + + // The main particle trail + float squash = Utils.GetLerpValue(1, 3, Projectile.velocity.Length(), true); + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (squash > 0.15f && visuals && targetDist < 1400) + { + float scale = 0.55f * Projectile.scale * (projType == 1 && canDamage ? 2 : 1); + int lifetime = (int)(18 * (projType == 1 && canDamage ? 2.5f : 1)); + Particle fadeInfx = new CustomSpark(Projectile.Center, Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomCircle", false, lifetime, scale, bColor * 0.4f * squash, new Vector2(1 - 0.15f * squash, 1f), true, true, shrinkSpeed: 0.3f * squash, glowOpacity: 0.5f, glowCenterScale: 0.45f); + GeneralParticleHandler.SpawnParticle(fadeInfx); + } + + Projectile.scale = MathHelper.Lerp(Projectile.scale, 0.7f, 0.1f); + Projectile.rotation = velocity.ToRotation() + MathHelper.PiOver2; + time++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (projType == 0) + { + if (visuals) + { + SoundStyle s = DeusMine.ExplodeSound; + SoundEngine.PlaySound(s with { Volume = 0.7f, Pitch = (Main.rand.NextFloat(0.3f, 0.4f)) }, Projectile.Center); + SoundStyle fire2 = StatisVoidSash.VoidDash; + SoundEngine.PlaySound(fire2 with { Volume = 0.4f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center); + + for (int i = 0; i < 15; i++) + { + Dust c = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + c.velocity = (MathHelper.TwoPi * i / 15f).ToRotationVector2() * 16f * (i % 3 == 0 ? 0.8f : 1f); + c.scale = Main.rand.NextFloat(1.3f, 1.6f) * 0.9f * (i % 3 == 0 ? 2.2f : 1.8f); + c.noGravity = true; + c.color = bColor; + c.noLightEmittence = true; + c.fadeIn = 0.9f; + } + Particle blastRing = new CustomPulse(target.Center, Vector2.Zero, bColor * 0.7f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 1.8f, 13, true); + GeneralParticleHandler.SpawnParticle(blastRing); + } + + float blastSize = 170; + float minMultiplier = 0.35f; + int hitsToMinMult = 8; + int debuff = ModContent.BuffType(); + int debuffTime = 240; + target.AddBuff(debuff, debuffTime); + + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, -11, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 14; + blast.DamageType = Projectile.DamageType; + blast.localAI[0] = target.whoAmI; + blast.localAI[1] = debuff; + blast.localAI[2] = debuffTime; + Projectile.Kill(); + } + else + { + // HADAL and VOID have knockback, GRAVEL has it's knockback on the explosion + Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY; + float launchPower = 7f; + target.MoveNPC(launchVel, launchPower, false); + + if (visuals) + { + for (int i = 0; i <= Math.Max(2, 8 - Projectile.numHits); i++) + { + float variance = Main.rand.NextFloat(-0.3f, 0.3f); + Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 24).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)); + float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f; + + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), vel); + dust2.scale = scale * 5; + dust2.noGravity = true; + dust2.color = bColor; + dust2.noLightEmittence = true; + dust2.fadeIn = 1.5f; + } + } + } + if (projType == 1) + { + if (visuals) + { + SoundStyle s = AuricOre.MineSound; + SoundEngine.PlaySound(s with { Volume = 0.5f, Pitch = (-0.3f + Projectile.numHits * 0.1f), MaxInstances = 6 }, Projectile.Center); + } + + target.AddBuff(BuffID.OnFire3, 300); // Should be replaced with "Steamscorched" or whatever the scoria debuff will be + float minMult = 0.25f; + int hitsToMinMult = 10; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult * 2.5f; // Deals extra damage + } + if (projType == 2) + { + modifiers.SourceDamage *= 0.33f; // Deals less damage but hits multiple times + if (visuals) + { + SoundStyle s = CommonCalamitySounds.VoidstoneMine with { Volume = 1 }; + SoundEngine.PlaySound(s with { Volume = 0.6f, Pitch = (-0.3f + Projectile.numHits * 0.1f) }, Projectile.Center); + } + + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 7; + target.AddBuff(ModContent.BuffType(), 30); // Very stong debuff need very short time + targeted = target; + hitCooldown = 140; + Projectile.timeLeft = 600; + Projectile.extraUpdates += 3; // Get faster on each hit + if (Projectile.numHits >= 5) + Projectile.Kill(); + } + } + public override void OnKill(int timeLeft) + { + if (healing && visuals) + { + for (int i = 0; i <= 4; i++) + { + float variance = Main.rand.NextFloat(-0.5f, 0.5f); + Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedBy(variance) * Main.rand.NextFloat(0.3f, 1f) * (1 - Math.Abs(variance)) * 4; + float scale = (Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance)) * 0.35f; + + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), vel); + dust2.scale = scale * 2; + dust2.noGravity = false; + dust2.color = bColor; + dust2.noLight = true; + dust2.noLightEmittence = true; + } + } + } + public override bool PreDraw(ref Color lightColor) + { + Asset orb = ModContent.Request("CalamityMod/Particles/BloomCircle"); + float sine = (float)Math.Sin((Main.GlobalTimeWrappedHourly * 10) / MathHelper.Pi); + Vector2 squash = new Vector2(Utils.Remap(Projectile.velocity.Length(), 1, 5, 1, 0.6f), Utils.Remap(Projectile.velocity.Length(), 1, 5, 1, 2f)); + + Asset block = TextureAssets.Item[ModContent.ItemType()]; + switch (projType) // 0 = gravel/vines, 1 = hadal/hydrothermic, 2 = void/lumenyl + { + case 0: + { + block = TextureAssets.Item[ModContent.ItemType()]; + break; + } + case 1: + { + block = TextureAssets.Item[ModContent.ItemType()]; + break; + } + case 2: + { + block = TextureAssets.Item[ModContent.ItemType()]; + break; + } + } + + // The main "glowy orb" part of the projectile + for (int i = 0; i < 6; i++) + { + Color orbColor = Color.Lerp(bColor, color2, (i + 1) / 6) with { A = 0 } * 0.4f; + Vector2 scale = Projectile.scale * squash * (0.05f + i * 0.01f) * 4.3f; + Main.EntitySpriteDraw(orb.Value, Projectile.Center - Main.screenPosition, null, Color.Lerp(orbColor, Color.White with { A = 0 }, 1 - i * 0.5f) * (visuals ? 1 : 0.15f), Projectile.rotation, orb.Size() * 0.5f, scale, SpriteEffects.None); + } + + float velLerp = Utils.GetLerpValue(0.5f, 3f, Projectile.velocity.Length(), true); + if (projType == 0 && visuals) // GRAVEL circle + { + Asset ring = ModContent.Request("CalamityMod/Particles/BloomRing"); + int orbs = 9; + for (int i = 1; i < orbs + 1; i++) + { + float sine2 = (float)Math.Sin((time * (i % 3 == 0 ? 0.2f : i % 2 == 0 ? 0.4f : 1f) * 0.2f) / MathHelper.Pi); + + Vector2 placement = Projectile.Center + ((MathHelper.TwoPi * i / orbs) + 7 * sine).ToRotationVector2() * (18 + Math.Abs(sine * (i % 3 == 0 ? 19 : 11))) * velLerp; + Color orbColor = Color.White * (visuals ? 1 : 0.1f) * velLerp; + Vector2 scale = Vector2.One * Projectile.scale; + + for (int y = 0; y < 7; y++) + { + Vector2 drawOffset = (MathHelper.TwoPi * y / 7).ToRotationVector2() * 4.5f; + Main.EntitySpriteDraw(block.Value, placement - Main.screenPosition + drawOffset, null, bColor with { A = 0 } * 0.7f * velLerp, Projectile.rotation + 0.02f * MathHelper.Lerp(i, 1, 0.75f) + 0.4f, block.Size() * 0.5f, scale, i % 2 == 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + Main.EntitySpriteDraw(block.Value, placement - Main.screenPosition, null, orbColor, Projectile.rotation + 0.02f * MathHelper.Lerp(i, 1, 0.75f) + 0.4f, block.Size() * 0.5f, scale, i % 2 == 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + for (int i = 0; i < 3; i++) + Main.EntitySpriteDraw(ring.Value, Projectile.Center - Main.screenPosition, null, bColor with { A = 0 } * 0.9f * velLerp, Projectile.rotation, ring.Size() * 0.5f, 0.2f * velLerp * Projectile.scale + (0.15f * Math.Abs(sine)) + 0.02f * i, SpriteEffects.None); + } + if (projType == 1 && visuals) // HALAD spires + { + int orbs = 9; + for (int i = 0; i < orbs; i++) + { + bool outer = i > (2); + bool outest = i > (5); + float rotation = MathHelper.TwoPi * i / (3) + Main.GlobalTimeWrappedHourly * 6; + Vector2 placement = Projectile.Center + ((rotation).ToRotationVector2() * (outest ? 16 : outer ? 12 : 8) + (Projectile.velocity.SafeNormalize(Vector2.UnitX) * (outest ? -15f : outer ? 0f : 15))) * velLerp; + Color orbColor = Color.White * (visuals ? 1 : 0.1f) * velLerp; + Vector2 scale = new Vector2(0.35f + (outest ? 0.1f : outer ? 0.3f : 0.6f), 2.3f) * Projectile.scale * (outest ? 0.8f : outer ? 0.9f : 1) * 1.5f; + + for (int y = 0; y < 7; y++) + { + Vector2 drawOffset = (MathHelper.TwoPi * y / 7).ToRotationVector2() * 2.5f; + Main.EntitySpriteDraw(block.Value, placement - Main.screenPosition + drawOffset, null, bColor with { A = 0 } * velLerp, Utils.DirectionTo(placement, Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 65f).ToRotation() + MathHelper.PiOver2, block.Size() * 0.5f, scale, outer ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + Main.EntitySpriteDraw(block.Value, placement - Main.screenPosition, null, orbColor, Utils.DirectionTo(placement, Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 65f).ToRotation() + MathHelper.PiOver2, block.Size() * 0.5f, scale, outer ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + } + if (projType == 2 && visuals) // VOID shards + { + float scalingValue = Main.GlobalTimeWrappedHourly * (90 + Projectile.numHits * 55); + int orbs = 8; + for (int i = 1; i < orbs + 1; i++) + { + float sine3 = (float)Math.Sin((scalingValue * (i % 3 == 0 ? 0.2f : i % 2 == 0 ? 0.4f : 1f) * 0.07f) / MathHelper.Pi); + float sine2 = (float)Math.Sin((scalingValue * (i % 3 == 0 ? 0.2f : i % 2 == 0 ? 0.4f : 1f) * 0.2f) / MathHelper.Pi); + + Vector2 velocity = Projectile.Center + ((MathHelper.TwoPi * i / orbs) + scalingValue * 0.04f).ToRotationVector2() * (23f + 8 * sine3) * Math.Abs(sine2) * velLerp; + + Color orbColor = Color.White * (visuals ? 1 : 0.1f) * velLerp; + Vector2 scale = new Vector2(i % 2 == 0 ? 0.4f : 0.6f, i % 2 == 0 ? 1f : 1.3f) * Projectile.scale * 1.3f; + + for (int y = 0; y < 7; y++) + { + Vector2 drawOffset = (MathHelper.TwoPi * y / 7).ToRotationVector2() * 4.5f; + Main.EntitySpriteDraw(block.Value, velocity - Main.screenPosition + drawOffset, null, bColor with { A = 0 } * 0.7f * velLerp, Utils.DirectionTo(velocity, Projectile.Center).ToRotation() + MathHelper.PiOver2 * sine3, block.Size() * 0.5f, scale, i % 2 == 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + Main.EntitySpriteDraw(block.Value, velocity - Main.screenPosition, null, orbColor, Utils.DirectionTo(velocity, Projectile.Center).ToRotation() + MathHelper.PiOver2 * sine3, block.Size() * 0.5f, scale, i % 2 == 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None); + } + } + + return false; + } + public override bool? CanDamage() => canDamage ? null : false; + public override bool? CanHitNPC(NPC target) + { + if (!target.CanBeChasedBy()) + return false; + if (projType == 2) // VOID has multihit, so it needs extra checks. Can't have it inflicting post ML debuffs and piercing + { + if (hitCooldown > 0 || (targeted != null && target != targeted)) + return false; + else + return null; + } + else + return null; + } + } +} diff --git a/Projectiles/Typeless/DirectStrike.cs b/Projectiles/Typeless/DirectStrike.cs index b065165a8f..b29d83d206 100644 --- a/Projectiles/Typeless/DirectStrike.cs +++ b/Projectiles/Typeless/DirectStrike.cs @@ -40,6 +40,7 @@ namespace CalamityMod.Projectiles.Typeless // If the target is moving VERY fast, direct strikes spawned on top of them can actually miss // Setting a target will guarantee hits on said target by teleporting the projectile onto their center every frame + // Setting a target will guarantee hits on said target by teleporting the projectile onto them every frame if (!invalidTarget) Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; } @@ -56,7 +57,7 @@ namespace CalamityMod.Projectiles.Typeless if (projHitbox.Intersects(targetHitbox)) { NPC target = Main.npc[(int)Projectile.ai[0]]; - if (pushVelocity != Vector2.Zero && !invalidTarget && target.CanBeMoved(hasStongDisplacement)) + if (pushVelocity != Vector2.Zero && pushVelocity.X < 255f && !invalidTarget && target.CanBeMoved(hasStongDisplacement)) { target.velocity = (pushVelocity * (target.knockBackResist == 0 ? 0.5f : 1)); } diff --git a/Projectiles/Typeless/DragonDust.cs b/Projectiles/Typeless/DragonDust.cs index 9bb257a7d1..07d2a202c0 100644 --- a/Projectiles/Typeless/DragonDust.cs +++ b/Projectiles/Typeless/DragonDust.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/EmpyreanBlast.cs b/Projectiles/Typeless/EmpyreanBlast.cs index 16329b871a..27643f1b26 100644 --- a/Projectiles/Typeless/EmpyreanBlast.cs +++ b/Projectiles/Typeless/EmpyreanBlast.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/EmpyreanGlob.cs b/Projectiles/Typeless/EmpyreanGlob.cs index ca6b639559..56e03ac2c9 100644 --- a/Projectiles/Typeless/EmpyreanGlob.cs +++ b/Projectiles/Typeless/EmpyreanGlob.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/EmpyreanMarble.cs b/Projectiles/Typeless/EmpyreanMarble.cs index 7345791cff..529cd366c8 100644 --- a/Projectiles/Typeless/EmpyreanMarble.cs +++ b/Projectiles/Typeless/EmpyreanMarble.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/EnergyShell.cs b/Projectiles/Typeless/EnergyShell.cs index 7850d6aadb..b47ee80fd3 100644 --- a/Projectiles/Typeless/EnergyShell.cs +++ b/Projectiles/Typeless/EnergyShell.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Typeless Player player = Main.player[Projectile.owner]; Projectile.Center = player.Center; //if player is dead, null, or stops holding the Lion Heart, kill the projectile - if (player.dead || player is null || player.ActiveItem().type != ModContent.ItemType()) + if (player.dead || player is null || player.HeldItem.type != ModContent.ItemType()) { Projectile.Kill(); } diff --git a/Projectiles/Typeless/ExoTankLaser.cs b/Projectiles/Typeless/ExoTankLaser.cs index 484ff94ef3..d624554ef0 100644 --- a/Projectiles/Typeless/ExoTankLaser.cs +++ b/Projectiles/Typeless/ExoTankLaser.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Typeless else puffDustVelocity = puffDustVelocity.RotatedBy(generalAngularOffset); - Dust magic = Dust.NewDustPerfect(target.Center, 182, puffDustVelocity); + Dust magic = Dust.NewDustPerfect(target.Center, DustID.TheDestroyer, puffDustVelocity); magic.scale = sideways ? 1.8f : 1f; magic.fadeIn = 0.5f; magic.noGravity = true; diff --git a/Projectiles/Typeless/FestiveWingsOrnament.cs b/Projectiles/Typeless/FestiveWingsOrnament.cs new file mode 100644 index 0000000000..9190221ad3 --- /dev/null +++ b/Projectiles/Typeless/FestiveWingsOrnament.cs @@ -0,0 +1,107 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class FestiveWingsOrnament : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "Terraria/Images/Projectile_" + ProjectileID.OrnamentFriendly; + + internal static readonly SoundStyle JingleSound = new("CalamityMod/Sounds/Item/FestiveJingle") { Volume = 0.25f, PitchVariance = 0.5f }; + + public override void SetStaticDefaults() => Main.projFrames[Type] = Main.projFrames[ProjectileID.OrnamentFriendly]; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 22; + Projectile.friendly = true; + Projectile.timeLeft = 420; + } + + public override void OnSpawn(IEntitySource source) + { + Projectile.frame = Main.rand.Next(Main.projFrames[Type]); + + // Vanilla's sprite sheet is slightly messed up so the "center" is the bottom + SoundEngine.PlaySound(JingleSound, Projectile.Bottom); + + Player owner = Main.player[Projectile.owner]; + if (owner == null || !owner.active) + return; + + Vector2 direction = owner.SafeDirectionTo(Projectile.Bottom); + Projectile.rotation = direction.ToRotation() + MathHelper.PiOver2; + + int totalPoints = (int)Utils.Remap(Vector2.Distance(Projectile.Bottom, owner.Center), 320f, 512f, 8f, 13f); + Vector2[] trailPoints = new Vector2[totalPoints + 1]; + trailPoints[0] = owner.Center; + trailPoints[totalPoints] = Projectile.Bottom; + for (int i = 1; i < totalPoints; i++) + { + trailPoints[i] = Vector2.Lerp(owner.Center, Projectile.Bottom, i / (float)totalPoints) + Main.rand.NextVector2Circular(12f, 12f) + direction.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-48f, 48f); + } + + int dustType = DustID.GemRuby - Projectile.frame; + for (int i = 0; i < totalPoints; i++) + { + for (int d = 0; d < 8; d++) + { + Dust trail = Dust.NewDustPerfect(Vector2.Lerp(trailPoints[i], trailPoints[i + 1], d / 8f), dustType); + trail.noGravity = true; + trail.noLight = true; + } + } + } + + public override void AI() + { + Lighting.AddLight(Projectile.Bottom, 0.5f, 0.5f, 0.5f); + + if (Projectile.timeLeft <= 120) + { + Projectile.velocity.Y += 0.75f; + if (Projectile.velocity.Y > 16f) + Projectile.velocity.Y = 16f; + } + + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (Vector2.Distance(player.Center, Projectile.Bottom) < 32f && player.wingTimeMax > 0f) + { + player.wingTime = MathHelper.Clamp(player.wingTime + 75f, 0f, player.wingTimeMax); + SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.25f }, player.Center); + Projectile.Kill(); + + int dustType = DustID.GemRuby - Projectile.frame; + for (int d = 0; d < 36; d++) + { + Dust ring = Dust.NewDustPerfect(Projectile.Bottom, dustType); + ring.velocity = (MathHelper.TwoPi * d / 36f).ToRotationVector2() * 6f; + ring.noGravity = true; + ring.noLight = true; + } + break; + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + SoundEngine.PlaySound(SoundID.Item27, Projectile.Bottom); + int dustType = DustID.GemRuby - Projectile.frame; + for (int i = 0; i < 20; i++) + { + Dust shatter = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustType); + shatter.noLight = true; + shatter.scale = 0.8f; + } + return true; + } + } +} diff --git a/Projectiles/Typeless/FlameLickedBarrage.cs b/Projectiles/Typeless/FlameLickedBarrage.cs index f94d416372..0169f45ec6 100644 --- a/Projectiles/Typeless/FlameLickedBarrage.cs +++ b/Projectiles/Typeless/FlameLickedBarrage.cs @@ -57,7 +57,9 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 90); + //Doze - I gave all parry accessories long debuff infliction times due to the lack of weapons that inflict debuffs for a decent time, and the scarcity of using the parry + //Most common vanilla debuffs have a way to inflict them for 15, 20, or even 30 seconds + target.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(15)); } public override void OnHitPlayer(Player target, Player.HurtInfo info) diff --git a/Projectiles/Typeless/FlameLickedHellblast.cs b/Projectiles/Typeless/FlameLickedHellblast.cs index 944ca206b1..3e2e579ae4 100644 --- a/Projectiles/Typeless/FlameLickedHellblast.cs +++ b/Projectiles/Typeless/FlameLickedHellblast.cs @@ -89,7 +89,9 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 90); + //Doze - I gave all parry accessories long debuff infliction times due to the lack of weapons that inflict debuffs for a decent time, and the scarcity of using the parry + //Most common vanilla debuffs have a way to inflict them for 15, 20, or even 30 seconds + target.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(15)); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Typeless/FlashBolt.cs b/Projectiles/Typeless/FlashBolt.cs index 3f86de4862..2abe28f4d0 100644 --- a/Projectiles/Typeless/FlashBolt.cs +++ b/Projectiles/Typeless/FlashBolt.cs @@ -1,5 +1,8 @@ -using CalamityMod.Particles; +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -12,9 +15,16 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public int time = 0; - public float colorValue = 0; - public float sizeMult = 1; + public int dir = 0; + bool setAltPlace = false; + public Vector2 altPlace; + public Player Owner => Main.player[Projectile.owner]; public bool invalidTarget => (Projectile.ai[0] < 0f || Projectile.ai[0] > 199f); + public bool simplify => Projectile.ai[1] > 0f; + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + } public override void SetDefaults() { Projectile.width = 60; @@ -24,22 +34,20 @@ namespace CalamityMod.Projectiles.Typeless Projectile.ignoreWater = true; Projectile.DamageType = AverageDamageClass.Instance; Projectile.penetrate = 1; // Survives through its first hit by "cheating" and incrementing its own pierce counter - Projectile.extraUpdates = 75; - Projectile.timeLeft = 200; + Projectile.extraUpdates = 0; + Projectile.timeLeft = 2; } - public override void AI() { - Player Owner = Main.player[Projectile.owner]; + // If the target is dead, remove them as a target and hit anything + NPC target = (invalidTarget ? null : Main.npc[(int)Projectile.ai[0]]); + if (target == null || !target.active || target.life <= 0) + Projectile.ai[0] = -1; + // Visibility/Sound toggle on acc visibility bool visible = Owner.Calamity().arcFlashRingVisual; - colorValue = MathHelper.Lerp(colorValue, 50, 0.025f); - Color usedColor = Color.Lerp(Color.Cyan, Color.Orchid, Utils.GetLerpValue(0, 50, colorValue)); - - if (time == 0) + if (time == 0 && Projectile.ai[0] != -1 && !simplify) { - colorValue += Main.rand.Next(0, 20); - sizeMult = 1; if (visible) { SoundStyle fire = new("CalamityMod/Sounds/Item/ArcFlash"); @@ -47,71 +55,91 @@ namespace CalamityMod.Projectiles.Typeless } } - // If the target is dead, remove them as a target and hit anything - NPC target = (invalidTarget ? null : Main.npc[(int)Projectile.ai[0]]); - if (target == null || !target.active || target.life <= 0) - Projectile.ai[0] = -1; - - float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (targetDist < 1400f) - { - Vector2 pos = Projectile.Center - Projectile.velocity * 15; - if (Projectile.timeLeft % 4 == 0) - { - Particle spark2 = new BoltParticle(pos, -Projectile.velocity * 0.05f, false, 30, 0.6f * sizeMult, usedColor * (visible ? 1 : 0.25f), new Vector2(1.8f, 0.8f), true, true, false, 0.3f); - GeneralParticleHandler.SpawnParticle(spark2); - } - if (Main.rand.NextBool(35)) - { - Particle spark2 = new BoltParticle(pos, Projectile.velocity.RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.9f), false, 23, Main.rand.NextFloat(0.2f, 0.25f) * sizeMult, usedColor * (visible ? 1 : 0.3f), new Vector2(1.8f, 0.8f), true, true, false, 0.3f); - GeneralParticleHandler.SpawnParticle(spark2); - } - if (Main.rand.NextBool(10) && visible) - { - Particle spark2 = new CustomSpark(pos, Projectile.velocity * Main.rand.NextFloat(-0.4f, 0.4f), "CalamityMod/Particles/DrainLineBloom", false, 80, Main.rand.NextFloat(1.2f, 1.3f) * sizeMult, usedColor * (visible ? 1 : 0.3f), new Vector2(1, 4), true, true); - GeneralParticleHandler.SpawnParticle(spark2); - } - if (time % 5 == 0 && visible) - { - Dust dust = Dust.NewDustPerfect(pos, 278, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.45f, 0.6f)); - dust.noGravity = true; - dust.color = usedColor; - } - } - if (Projectile.numHits > 0) - { - sizeMult *= 0.97f; - } time++; } + public override bool PreDraw(ref Color lightColor) + { + if (!setAltPlace) + { + NPC target = (invalidTarget ? null : Main.npc[(int)Projectile.ai[0]]); + if (target == null || !target.active || target.life <= 0) + Projectile.ai[0] = -1; + if (target != null && Projectile.ai[0] != -1) + { + float size = (Math.Min(target.width, target.height) * 0.35f) + 10; + altPlace = Projectile.Center + Main.rand.NextVector2Circular(size, size); + } + setAltPlace = true; + } + + if (simplify || !Owner.Calamity().arcFlashRingVisual) + return false; + + Texture2D tex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + if (dir == 0) + dir = Main.rand.NextBool() ? -1 : 1; + + int distance = (int)(600 + (altPlace.Y - Owner.Center.Y)); + int travelAmount = 10; + Vector2 currentPos = altPlace; + Vector2 lastPos = currentPos; + bool zap = false; // Swapping the direction of the bolt + Color drawColor = Color.White; + float lifeLerp = (Projectile.numHits == 0 ? 1 : (float)Math.Pow(Utils.GetLerpValue(-5, 15, Projectile.timeLeft, true), 3)); + int angleSwapTimer = 0; + int angleSwapMax = 7; + for (int i = 0; i < distance; i += travelAmount) + { + float angleLerp = Math.Min(Utils.GetLerpValue(angleSwapMax, 0, angleSwapTimer, true), Utils.GetLerpValue(0, angleSwapMax, angleSwapTimer, true)); + float endLerp = Utils.GetLerpValue(0, distance, i, true); + drawColor = Color.Lerp(Color.Cyan, Color.Orchid, endLerp); + Main.EntitySpriteDraw(tex, currentPos - Main.screenPosition, null, drawColor with { A = 0 }, lastPos.DirectionTo(currentPos).ToRotation() + MathHelper.PiOver2, new Vector2(tex.Width / 2, tex.Height / 2), new Vector2((2.5f - 1.5f * angleLerp) * lifeLerp * Math.Max(endLerp, 0.25f), 1 + 2f * angleLerp) * 0.2f, SpriteEffects.None); + lastPos = currentPos; + currentPos -= new Vector2(travelAmount * 1.5f * endLerp * dir * (zap ? -1 : 1) * lifeLerp, travelAmount); + angleSwapTimer++; + if (angleSwapTimer >= angleSwapMax) { zap = !zap; angleSwapTimer = 0; } + } + return false; + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - // Stops the projectile from deleting itself, while maintaining the masquerade - Projectile.penetrate++; - - //colorValue = Main.rand.Next(0, 10); target.AddBuff(BuffID.Electrified, 180); - Projectile.timeLeft = 25; - Player Owner = Main.player[Projectile.owner]; - if (Owner.Calamity().arcFlashRingVisual && Projectile.numHits == 0) + if (!simplify) { - Vector2 pos = target.Center; - for (int i = 0; i < 10; i++) + // Stops the projectile from deleting itself, while maintaining the masquerade + Projectile.penetrate++; + + Projectile.timeLeft = 15; + if (Projectile.numHits == 0) { - Particle spark2 = new BoltParticle(pos, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1.9f), true, 13, Main.rand.NextFloat(0.2f, 0.3f) * sizeMult, Main.rand.NextBool(5) ? Color.Cyan : Color.Orchid, new Vector2(1.8f, 0.8f), true, true, false, 0.8f); - GeneralParticleHandler.SpawnParticle(spark2); - Dust dust = Dust.NewDustPerfect(pos, 278, new Vector2(14, 14).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(0.8f, 0.9f)); - dust.noGravity = false; - dust.color = Main.rand.NextBool(5) ? Color.Cyan : Color.Orchid; + if (!setAltPlace) + { + if (target != null && Projectile.ai[0] != -1) + { + float size = (Math.Min(target.width, target.height) * 0.35f) + 10; + altPlace = Projectile.Center + Main.rand.NextVector2Circular(size, size); + } + setAltPlace = true; + } + Vector2 pos = altPlace; + if (Owner.Calamity().arcFlashRingVisual) + { + for (int i = 0; i < 10; i++) + { + Dust dust = Dust.NewDustPerfect(pos, ModContent.DustType(), new Vector2(18, 18).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(1.3f, 1.5f) * 3); + dust.noGravity = true; + dust.color = Main.rand.NextBool(3) ? Color.Cyan : Color.Orchid; + dust.fadeIn = 7.5f; + } + Particle orb = new CustomPulse(pos, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.68f, 0.5f, 14); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new CustomPulse(pos, Vector2.Zero, Color.White * 0.8f, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.225f, 0.2f, 14); + GeneralParticleHandler.SpawnParticle(orb2); + } + Particle pulse2 = new CustomPulse(pos, Vector2.Zero, Color.Cyan * (Owner.Calamity().arcFlashRingVisual ? 1 : 0.6f), "CalamityMod/Particles/BloomRing", new Vector2(1, 1), 0, 0.3f, 0.95f, 10); + GeneralParticleHandler.SpawnParticle(pulse2); } - Particle pulse2 = new CustomPulse(pos, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/HighResFoggyCircleHardEdge", new Vector2(1, 1), 0, 0f, 0.0715f, 10); - GeneralParticleHandler.SpawnParticle(pulse2); - Particle orb = new CustomPulse(pos, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.78f, 0.5f, 14); - GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new CustomPulse(pos, Vector2.Zero, Color.White, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.325f, 0.2f, 14); - GeneralParticleHandler.SpawnParticle(orb2); } } public override bool? CanHitNPC(NPC target) @@ -120,7 +148,7 @@ namespace CalamityMod.Projectiles.Typeless return null; return false; } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.numHits > 0 ? false : CalamityUtils.CircularHitboxCollision(Projectile.Center, 60 * sizeMult, targetHitbox); + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.numHits > 0 ? false : base.Colliding(projHitbox, targetHitbox); public override bool? CanCutTiles() => false; } } diff --git a/Projectiles/Typeless/FriendlyLaserWallBeam.cs b/Projectiles/Typeless/FriendlyLaserWallBeam.cs new file mode 100644 index 0000000000..95f8ae5d59 --- /dev/null +++ b/Projectiles/Typeless/FriendlyLaserWallBeam.cs @@ -0,0 +1,173 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class FriendlyLaserWallBeam : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Typeless"; + public float time = 0; + public ref float attackSpeed => ref Projectile.ai[0]; + public ref float laserType => ref Projectile.ai[1]; + public bool canDamage => doneAttack && laserFX >= 1f; + public bool doneAttack = false; + public int attackTime = 30; + public float laserLength => laserType == 0 ? 4000 : 2000; + public float laserFX = 0; + public float storedTime = 0; + public Color drawColor = Color.Magenta; + public float sine = 0; + public float laserRot = 0; + Vector2 beamStart = Vector2.Zero; + Vector2 directionToTarget = Vector2.Zero; + public Vector2 targetPos => Projectile.Center; + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + } + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 6000; + Projectile.scale = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + if (laserFX > 0) + laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.07f : 0.01f); + sine = (float)Math.Sin(time * 4f / MathHelper.Pi); + if (time == 0) + { + laserRot = Projectile.velocity.ToRotation(); + + beamStart = targetPos + Vector2.UnitX.RotatedBy(laserRot) * laserLength; + directionToTarget = beamStart.DirectionTo(targetPos); + + //Projectile.Center += Main.rand.NextVector2CircularEdge(400, 400); + // Some default values for if the projectile spawns without them set + if (attackSpeed == 0) + { + attackSpeed = 3f; + } + //Negative speed causes instant attack with the set speed + if (attackSpeed < 0) + { + attackSpeed = -attackSpeed; + time = attackTime; + } + Projectile.velocity = Vector2.Zero; + laserFX = 1f; + Projectile.ForceNetUpdate(); + } + if (time >= attackTime && !doneAttack) + { + SoundStyle attack = new("CalamityMod/Sounds/Custom/DoGLaserWallLightAttack"); + if (Projectile.scale > 3) { + attack = new("CalamityMod/Sounds/Custom/DoGLaserWallBigAttack"); + } + SoundEngine.PlaySound(attack with { Volume = 0.4f, Pitch = 0, MaxInstances = -1}, Vector2.Lerp(targetPos, Main.player[Projectile.owner].Center, laserType == 0 ? 0 : 0.7f)); + laserFX = 2.5f; + doneAttack = true; + storedTime = time; + Projectile.ForceNetUpdate(); + if (Main.LocalPlayer.Distance(Projectile.Center) < 1600) + Main.LocalPlayer.SetScreenshake(Projectile.ai[2]); + } + float endTime = storedTime + 10; + if (time >= endTime && doneAttack) + { + Projectile.Kill(); + return; + } + else if (doneAttack) + { + drawColor = Color.Lerp(Color.Magenta, Color.Cyan, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2)); + } + time += attackSpeed; + } + + public override bool? CanHitNPC(NPC target) + { + if (canDamage) + return null; + return false; + } + public override bool CanHitPlayer(Player target) + { + if (canDamage) + return true; + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canDamage) + return false; + else + { + float _ = float.NaN; + Vector2 start = beamStart; + Vector2 end = beamStart + directionToTarget * laserLength * 2; + bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 30 * Projectile.scale, ref _); + + return hitCheck; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (laserFX == 0) + return false; + Texture2D beam = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D bBeam = ModContent.Request("CalamityMod/Particles/LineThick").Value; + Texture2D angleBeam = ModContent.Request("CalamityMod/Particles/GlowBlade").Value; + Texture2D angleBeamInside = ModContent.Request("CalamityMod/Particles/GlowBladeNoBloom").Value; + float opacity = (doneAttack ? 0.65f : 0.35f) * (float)Math.Pow(Math.Min(laserFX, 1), 2); + Color beamColor = drawColor with { A = 0 }; + + if (CalamityClientConfig.Instance.Photosensitivity) + opacity = 0.2f; + if (laserType == 0) + { + for (int t = 0; t < (!doneAttack ? 1 : 5); t++) + { + bool black = (t > 0); + Texture2D usedTex = (black ? bBeam : beam); + float beamThickness = 0.03f * (black ? (0.8f - 0.15f * t) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f); + float rot = beamStart.DirectionTo(targetPos).ToRotation() + (MathHelper.PiOver2); + Main.EntitySpriteDraw(usedTex, beamStart - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * opacity) * (black ? (0.2f + 0.15f * t) : 1), rot, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness * Projectile.scale, laserLength / 975 * (usedTex == beam ? 1 : 0.8277f)), SpriteEffects.None); + } + } + else + { + opacity = 1f; + + if (CalamityClientConfig.Instance.Photosensitivity) + opacity = 0.2f; + for (int t = 0; t < (!doneAttack ? 1 : 5); t++) + { + bool notFirstDrawn = (t > (Projectile.scale > 3 ? 1 : 0)); + float beamThickness = 16/1960f * Projectile.scale * (notFirstDrawn ? (1f - 0.8f * (t-1) / 4f) : 1) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f); + Main.EntitySpriteDraw(notFirstDrawn ? angleBeamInside : angleBeam, beamStart - Main.screenPosition, null, (notFirstDrawn ? Color.Black * opacity : beamColor * opacity) * (notFirstDrawn ? (0.2f + 0.8f * (t - 1) / 4f) : 1), directionToTarget.ToRotation() + MathHelper.PiOver2, new Vector2(angleBeam.Width / 2, angleBeam.Height), new Vector2(beamThickness * Projectile.scale, laserLength / 975 * 0.8277f), SpriteEffects.None); + } + } + return false; + } + } +} diff --git a/Projectiles/Typeless/FungalClumpMinion.cs b/Projectiles/Typeless/FungalClumpMinion.cs index 49f7b51a74..782a84cecd 100644 --- a/Projectiles/Typeless/FungalClumpMinion.cs +++ b/Projectiles/Typeless/FungalClumpMinion.cs @@ -1,6 +1,6 @@ using System; -using CalamityMod.Balancing; using CalamityMod.CalPlayer; +using CalamityMod.NPCs; using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Terraria; @@ -9,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class FungalClumpMinion : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; @@ -229,20 +230,7 @@ namespace CalamityMod.Projectiles.Typeless } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (Main.player[Projectile.owner].moonLeech) - return; - - int heal = (int)Math.Round(damageDone * 0.25); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange, BalancingConstants.LifeStealAccessoryCooldownMultiplier); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ModContent.ProjectileType(), 1, 2f); public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Typeless/GemTechArmorGem.cs b/Projectiles/Typeless/GemTechArmorGem.cs index d31ffe8079..b9cfd19417 100644 --- a/Projectiles/Typeless/GemTechArmorGem.cs +++ b/Projectiles/Typeless/GemTechArmorGem.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 7; i++) { - Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, 267); + Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); energyPuff.velocity = -Vector2.UnitY.RotatedByRandom(0.81f) * Main.rand.NextFloat(1.25f, 4.5f); energyPuff.color = Color.Lerp(GemColor, Color.White, Main.rand.NextFloat(0.5f)); energyPuff.scale = 1.1f; @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.Item72, Projectile.Center); for (int i = 0; i < 12; i++) { - Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, 267); + Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); energyPuff.velocity = (MathHelper.TwoPi * i / 12f).ToRotationVector2() * 5f; energyPuff.color = GemColor; energyPuff.scale = 1.125f; @@ -127,7 +127,7 @@ namespace CalamityMod.Projectiles.Typeless public override bool? CanDamage() => Time > UpwardFlyTime + RedirectTime ? null : false; - public Color TrailColor(float completionRatio) + public Color TrailColor(float completionRatio, Vector2 vertexPos) { float trailOpacity = Utils.GetLerpValue(0f, 0.067f, completionRatio, true) * Utils.GetLerpValue(0.7f, 0.58f, completionRatio, true); Color startingColor = Color.Lerp(Color.White, GemColor, 0.47f); @@ -136,7 +136,7 @@ namespace CalamityMod.Projectiles.Typeless return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * trailOpacity; } - public static float TrailWidth(float completionRatio) => MathHelper.SmoothStep(12f, 4.25f, completionRatio); + public static float TrailWidth(float completionRatio, Vector2 vertexPos) => MathHelper.SmoothStep(12f, 4.25f, completionRatio); public override bool PreDraw(ref Color lightColor) { @@ -172,7 +172,7 @@ namespace CalamityMod.Projectiles.Typeless Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(Color.White), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); if (Projectile.ai[0] > UpwardFlyTime + RedirectTime) - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 71); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 71); return false; } diff --git a/Projectiles/Typeless/GhostlyBolt.cs b/Projectiles/Typeless/GhostlyBolt.cs index ceb42cf336..dc550f02e0 100644 --- a/Projectiles/Typeless/GhostlyBolt.cs +++ b/Projectiles/Typeless/GhostlyBolt.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -18,10 +17,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.friendly = true; Projectile.alpha = 255; Projectile.penetrate = 1; - Projectile.extraUpdates = 1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; - Projectile.timeLeft = 900; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 180 * Projectile.MaxUpdates; Projectile.ignoreWater = true; Projectile.tileCollide = false; } diff --git a/Projectiles/Typeless/GodSlayerShrapnel.cs b/Projectiles/Typeless/GodSlayerShrapnel.cs index e539904fcb..34478e42d6 100644 --- a/Projectiles/Typeless/GodSlayerShrapnel.cs +++ b/Projectiles/Typeless/GodSlayerShrapnel.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - if (Projectile.ai[1] == 0f && Projectile.type >= 326 && Projectile.type <= 328) + if (Projectile.ai[1] == 0f && Projectile.type >= ProjectileID.GreekFire1 && Projectile.type <= ProjectileID.GreekFire3) { Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item13, Projectile.position); diff --git a/Projectiles/Typeless/GreenLabSeeker.cs b/Projectiles/Typeless/GreenLabSeeker.cs index 65a48dec84..4f921f5166 100644 --- a/Projectiles/Typeless/GreenLabSeeker.cs +++ b/Projectiles/Typeless/GreenLabSeeker.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), DustID.RainbowMk2); dust.color = Color.Green; dust.scale = Main.rand.NextFloat(0.95f, 1.25f); dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); diff --git a/Projectiles/Typeless/HolyExplosionSupreme.cs b/Projectiles/Typeless/HolyExplosionSupreme.cs index 29bed8cabb..dbdb92c835 100644 --- a/Projectiles/Typeless/HolyExplosionSupreme.cs +++ b/Projectiles/Typeless/HolyExplosionSupreme.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless @@ -47,7 +48,7 @@ namespace CalamityMod.Projectiles.Typeless { Vector2 dustVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f); - Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, 259, dustVel, 0, default, 1f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel * 2, DustID.SolarFlare, dustVel, 0, default, 1f); dust.shader = GameShaders.Armor.GetSecondaryShader(Owner.cShield, Owner); Particle spark = new CustomSpark(Projectile.Center, (new Vector2(15, 15).RotatedByRandom(100)) * Main.rand.NextFloat(0.2f, 1f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 37, Main.rand.NextFloat(1.35f, 1.5f), Main.rand.NextBool(4) ? Color.Khaki : Color.Orange, new Vector2(1.3f, 0.5f), true, false, 0, false, false, Main.rand.NextFloat(0.1f, 0.2f)); diff --git a/Projectiles/Typeless/HolyStarDamage.cs b/Projectiles/Typeless/HolyStarDamage.cs index 455d337210..4be5cc4944 100644 --- a/Projectiles/Typeless/HolyStarDamage.cs +++ b/Projectiles/Typeless/HolyStarDamage.cs @@ -1,18 +1,12 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.NPCs; -using CalamityMod.NPCs.Providence; using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; -using CalamityMod.World; -using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -66,17 +60,17 @@ namespace CalamityMod.Projectiles.Typeless if (Projectile.ai[2] != -1 && time > 20) { NPC targeted = Projectile.ai[2] == -1 ? null : Main.npc[(int)Projectile.ai[2]]; - if (targeted != null && targeted.life <= 0) + if (targeted != null && (targeted.life <= 0 || !targeted.CanBeChasedBy(Projectile))) targeted = null; else Projectile.timeLeft++; - CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.5f, 12, 0.975f); + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted ?? Projectile.Center.ClosestNPCAt(800f), true, 0.5f, 12, 0.975f); } - if (Projectile.scale < 1) - Projectile.scale += 0.0035f; - if (Projectile.scale >= 1 && !reachedMaxDamage) + if (Projectile.scale < 1.15) + Projectile.scale += 0.004f; + if (Projectile.scale >= 1.15 && !reachedMaxDamage) { - Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.5f, 8); + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.3f, 8); GeneralParticleHandler.SpawnParticle(orb2); reachedMaxDamage = true; } @@ -89,8 +83,6 @@ namespace CalamityMod.Projectiles.Typeless Color col = Projectile.ai[1] == 5 ? (Color.Lerp(Color.Goldenrod, Color.Orchid, Utils.GetLerpValue(0.85f, 1f, Projectile.scale))) : Color.Goldenrod; - float vel = MathHelper.Clamp(Projectile.velocity.Length() / 5, 0, 1.5f); - Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.8f, false, 5, 0.06f * Projectile.scale, col * 0.7f, new Vector2(1, 0.3f), true, false, 1.5f); GeneralParticleHandler.SpawnParticle(spark); @@ -111,9 +103,8 @@ namespace CalamityMod.Projectiles.Typeless Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color baseColor = Color.Goldenrod with { A = 0 }; - Color baseColor2 = Color.Khaki with { A = 0 }; - baseColor.A = 0; + Color baseColor = Color.Goldenrod with { A = 150 }; + Color baseColor2 = Color.Khaki with { A = 150 }; baseColor *= lerpMult; baseColor2 *= lerpMult; Vector2 origin = texture.Size() / 2f; @@ -158,8 +149,6 @@ namespace CalamityMod.Projectiles.Typeless Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Goldenrod, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 1.5f, 10); GeneralParticleHandler.SpawnParticle(orb2); - Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Orchid, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 0.65f, 15, true); - GeneralParticleHandler.SpawnParticle(orb3); for (int i = 0; i < 4; i++) { @@ -167,9 +156,12 @@ namespace CalamityMod.Projectiles.Typeless GeneralParticleHandler.SpawnParticle(spark); } - // Sub projectiles spawning sub explosions... yea it needs armor pen - Projectile explo = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.2f), Projectile.knockBack, Projectile.owner, 0.75f); - explo.ArmorPenetration = 30; + if (Main.myPlayer == Projectile.owner) + { + // Sub projectiles spawning sub explosions... yea it needs armor pen + Projectile explo = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.2f), Projectile.knockBack, Projectile.owner, 0.75f); + explo.ArmorPenetration = 30; + } } } public override bool? CanDamage() => time > 15 ? null : false; diff --git a/Projectiles/Typeless/HydrothermalSmoke.cs b/Projectiles/Typeless/HydrothermalSmoke.cs index 7d0236bda1..1fda4b4a77 100644 --- a/Projectiles/Typeless/HydrothermalSmoke.cs +++ b/Projectiles/Typeless/HydrothermalSmoke.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,6 +11,7 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetDefaults() { Projectile.width = 20; @@ -23,21 +25,13 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { + if (Projectile.timeLeft == 6) Projectile.Center = Main.player[Projectile.owner].Center; - int randomDust = Main.rand.Next(4); - if (randomDust == 3) + if (Main.rand.NextBool(6)) { - randomDust = 16; - } - else - { - randomDust = 127; - } - if (Main.rand.NextBool(4)) - { - int fieryDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 1f); + int fieryDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Flare, 0f, 0f, 100, default, 0.7f); if (Main.rand.NextBool(4)) { Main.dust[fieryDust].scale *= 0.35f; @@ -45,11 +39,13 @@ namespace CalamityMod.Projectiles.Typeless Main.dust[fieryDust].velocity *= 0f; } - Vector2 goreVec = Projectile.position; - if (Main.rand.NextBool(8) && !Main.dedServ) + + if (Main.rand.NextBool(9) && !Main.dedServ) { - int smoke = Gore.NewGore(Projectile.GetSource_FromAI(), goreVec, default, Main.rand.Next(375, 378), 0.75f); - Main.gore[smoke].behindTiles = true; + float upwardVariation = Main.rand.NextFloat(-4.5f, -8f); + MediumMistParticle mist = new MediumMistParticle(Projectile.position, -Projectile.velocity + new Vector2(0.5f, upwardVariation), // This velocity makes it slowly float upward + Main.rand.NextBool(3) ? Color.LightSteelBlue : Color.SteelBlue, Color.LightSlateGray, Main.rand.NextFloat(0.4f, 0.65f), 130); + GeneralParticleHandler.SpawnParticle(mist); } } diff --git a/Projectiles/Typeless/HyperiusBleed.cs b/Projectiles/Typeless/HyperiusBleed.cs new file mode 100644 index 0000000000..173f4a5787 --- /dev/null +++ b/Projectiles/Typeless/HyperiusBleed.cs @@ -0,0 +1,20 @@ +using CalamityMod.Items.Ammo; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class HyperiusBleed : DirectStrike, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Player Owner = Main.player[Projectile.owner]; + + modifiers.HideCombatText(); // Has special combat text + + SoundEngine.PlaySound(HyperiusBullet.hit with { Volume = 0.45f, Pitch = Main.rand.NextFloat(-0.15f, 0.15f), MaxInstances = 10 }, Projectile.Center); + } + } +} diff --git a/Projectiles/Typeless/HyperiusDamage.cs b/Projectiles/Typeless/HyperiusDamage.cs new file mode 100644 index 0000000000..bb700a296e --- /dev/null +++ b/Projectiles/Typeless/HyperiusDamage.cs @@ -0,0 +1,22 @@ +using CalamityMod.Items.Ammo; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class HyperiusDamage : DirectStrike, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Player Owner = Main.player[Projectile.owner]; + + modifiers.HideCombatText(); // Has special combat text + modifiers.SourceDamage *= 0; + modifiers.FinalDamage.Flat = Projectile.damage; // Always does the exact damage of the hit so that it doesn't double scale with defense and dr + + SoundEngine.PlaySound(HyperiusBullet.hit with { Volume = 0.45f, Pitch = Main.rand.NextFloat(-0.15f, 0.15f), MaxInstances = 10 }, Projectile.Center); + } + } +} diff --git a/Projectiles/Typeless/JewelSpike.cs b/Projectiles/Typeless/JewelSpike.cs index a2de1dd804..aec3719911 100644 --- a/Projectiles/Typeless/JewelSpike.cs +++ b/Projectiles/Typeless/JewelSpike.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Projectiles.Typeless { if (Projectile.owner == Main.myPlayer) { - for (int index = 0; index < 3; ++index) + for (int index = 0; index < 2; ++index) { float SpeedX = -Projectile.velocity.X * Main.rand.NextFloat(0.4f, 0.7f) + Main.rand.NextFloat(-8f, 8f); float SpeedY = -Projectile.velocity.Y * Main.rand.NextFloat(0.4f, 0.7f) + Main.rand.NextFloat(-8f, 8f); diff --git a/Projectiles/Typeless/LeviAmberDash.cs b/Projectiles/Typeless/LeviAmberDash.cs index ce78561a5f..a77ac9724f 100644 --- a/Projectiles/Typeless/LeviAmberDash.cs +++ b/Projectiles/Typeless/LeviAmberDash.cs @@ -1,5 +1,7 @@ using System; -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,61 +12,153 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class LeviAmberDash : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[Projectile.owner]; + public Color effectsColor = Color.White; + public float fxFade = 0; + public bool isAlive = true; + public bool onSpawn = true; + public Vector2 aimVel; + public bool visuals => Owner.Calamity().lAmbergrisVisual; private static float ExplosionRadius = 85f; public static readonly SoundStyle Slap = new("CalamityMod/Sounds/Custom/WetSlap", 4) { Volume = 0.8f, PitchVariance = 0.3f }; - public override void SetDefaults() { - //These shouldn't matter because its circular - Projectile.width = 85; - Projectile.height = 85; + Projectile.width = (int)ExplosionRadius; + Projectile.height = (int)ExplosionRadius; Projectile.friendly = true; Projectile.DamageType = AverageDamageClass.Instance; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.penetrate = -1; - Projectile.timeLeft = 4; + Projectile.timeLeft = 15; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; + Projectile.localNPCHitCooldown = 18; } + public override void AI() + { + if (onSpawn && visuals) + { + Particle pulse = new CustomSpark(Owner.Center, Owner.velocity.SafeNormalize(Vector2.UnitX) * 9, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 23, 0.095f, Color.MediumTurquoise, new Vector2(1f, 1.7f), shrinkSpeed: -0.2f); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new CustomSpark(Owner.Center, Owner.velocity.SafeNormalize(Vector2.UnitX) * 12, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, 20, 0.065f, Color.DeepSkyBlue, new Vector2(1f, 1.7f), shrinkSpeed: -0.23f); + GeneralParticleHandler.SpawnParticle(pulse2); + onSpawn = false; + } + if (Owner.dashDelay != -1) + isAlive = false; + if (isAlive) + Projectile.timeLeft++; + Projectile.Center = Owner.Center; + + if (effectsColor == Color.White) + aimVel = Owner.velocity; + else + { + aimVel = Vector2.Lerp(aimVel, Owner.velocity, 0.2f); + } + + if (isAlive) + { + float goalSize = Utils.GetLerpValue(5, 15, Math.Abs(aimVel.X), true); + if (goalSize < fxFade) + fxFade = MathHelper.Lerp(fxFade, goalSize, 0.03f); + else + fxFade = goalSize; + } + else + { + fxFade = MathHelper.Lerp(fxFade, 0, 0.13f); + } + + + float rate = Main.GlobalTimeWrappedHourly * 22; + List eColors = new List() + { + Color.DarkTurquoise, + Color.DeepSkyBlue, + Color.MediumTurquoise + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + effectsColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + if (visuals) + { + int dir = MathF.Sign(aimVel.X); + Vector2 safeVel = aimVel.SafeNormalize(Vector2.UnitX); + float sparkscale2 = 0.35f * Math.Max(fxFade, 0.5f); + for (int i = -1; i <= 1; i += 2) + { + Vector2 sparkVelocity = safeVel.RotatedBy(dir * 1.5f * i) - safeVel * 3; + Vector2 sparkPlace = Owner.Center + (((safeVel * 15).RotatedBy(2f * dir * i) * 1.5f) + safeVel.RotatedBy(0.5f * i * dir) * 30) * fxFade; + Particle spark = new CustomSpark(sparkPlace, sparkVelocity.RotatedByRandom(0.1f), "CalamityMod/Particles/BloomCircle", false, 6, sparkscale2, effectsColor * fxFade, new Vector2(0.8f, 2f), shrinkSpeed: 1.1f); + GeneralParticleHandler.SpawnParticle(spark); + + if (isAlive) + { + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(sparkPlace, dustStyle, sparkVelocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(3, 5)); + dust2.scale = Main.rand.NextFloat(0.9f, 1.3f); + dust2.color = effectsColor; + dust2.noGravity = true; + dust2.fadeIn = Main.rand.NextFloat(0f, 0.7f); + } + } + } + + if (Owner.dead || (!isAlive && fxFade < 0.1f) || Owner.velocity == Vector2.Zero) + Projectile.Kill(); + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - target.MoveNPC(launchVel, 16, true); + SoundStyle sound = new("CalamityMod/Sounds/Item/WaterSplash", 2); + SoundEngine.PlaySound(sound with { Volume = 0.2f, Pitch = Main.rand.NextFloat(0.35f, 0.5f), MaxInstances = -1 }, Projectile.Center); target.AddBuff(BuffID.Wet, 300); target.AddBuff(ModContent.BuffType(), 180); - SoundEngine.PlaySound(SoundID.Item85 with { Volume = 0.4f, PitchVariance = 0.4f }, Projectile.Center); - for (int i = 0; i < 3; ++i) + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); + target.MoveNPC(launchVel, 20, true); + + for (int i = 0; i <= 17; i++) { - int bloodLifetime = Main.rand.Next(20, 26); - float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); - Color bloodColor = Color.Lerp(Color.DodgerBlue, Color.DarkTurquoise, Main.rand.NextFloat()); - - if (Main.rand.NextBool(20)) - bloodScale *= 2f; - - float randomSpeedMultiplier = Main.rand.NextFloat(1.25f, 2.25f); - Vector2 bloodVelocity = Main.rand.NextVector2Unit() * 5 * randomSpeedMultiplier; - bloodVelocity.Y -= 5f; - BloodParticle blood = new BloodParticle(Projectile.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); - GeneralParticleHandler.SpawnParticle(blood); + float variance = Main.rand.NextFloat(-0.4f, 0.4f); + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(target.Center, dustStyle); + dust2.scale = (Main.rand.NextFloat(1.2f, 1.4f) - Math.Abs(variance)) * 1.5f; + dust2.velocity = (aimVel.SafeNormalize(Vector2.UnitX).RotatedBy(variance) - Vector2.UnitY * 0.3f) * Main.rand.NextFloat(15, 35f) * (1 - Math.Abs(variance) * 1.3f); + dust2.color = Main.rand.NextBool() ? Color.MediumTurquoise : Color.DeepSkyBlue; + dust2.noGravity = false; + dust2.fadeIn = Main.rand.NextFloat(0f, 1.2f); } + Projectile.damage = (int)(Projectile.damage * 0.67f); } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); - public override bool? CanDamage() => base.CanDamage(); - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + public override bool? CanDamage() => (isAlive ? null : false); + public override bool PreDraw(ref Color lightColor) { - modifiers.HitDirectionOverride = Math.Sign(Owner.direction); - } + if (effectsColor == Color.White || !visuals) + return false; + float sine = MathHelper.Lerp(Math.Abs((float)Math.Sin(Main.GlobalTimeWrappedHourly * 50f / MathHelper.Pi)), 0.8f, 0.7f); + Texture2D bTexture = ModContent.Request("CalamityMod/Particles/VerticalSmearRagged").Value; + + for (int i = 0; i < 10; i++) + { + float bScale2 = 0.75f; + Vector2 scale = new Vector2((1 - i * 0.13f) * sine, (1 + i * 0.012f) + fxFade * 0.2f) * (bScale2 + i * 0.08f) * fxFade * 0.27f; + Main.EntitySpriteDraw(bTexture, Owner.Center - Main.screenPosition + aimVel.SafeNormalize(Vector2.UnitX) * -15, null, Color.Lerp(Color.Aquamarine, effectsColor, i * 0.15f) with { A = 0 } * fxFade * 1f, aimVel.ToRotation() + MathHelper.PiOver2, bTexture.Size() * 0.5f, scale, i % 2 == 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + return false; + } public override bool? CanCutTiles() => false; } } diff --git a/Projectiles/Typeless/Luxor.cs b/Projectiles/Typeless/Luxor.cs index bc170f8aa9..ddafd4ff7b 100644 --- a/Projectiles/Typeless/Luxor.cs +++ b/Projectiles/Typeless/Luxor.cs @@ -1,11 +1,8 @@ using System; using System.Collections.Generic; -using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Particles; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; diff --git a/Projectiles/Typeless/LuxorsGiftClassless.cs b/Projectiles/Typeless/LuxorsGiftClassless.cs index 79ba8f85d7..60a39f400c 100644 --- a/Projectiles/Typeless/LuxorsGiftClassless.cs +++ b/Projectiles/Typeless/LuxorsGiftClassless.cs @@ -1,11 +1,9 @@ using System; -using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/MagnusBeam.cs b/Projectiles/Typeless/MagnusBeam.cs index 3cb564ae69..8df2d4245f 100644 --- a/Projectiles/Typeless/MagnusBeam.cs +++ b/Projectiles/Typeless/MagnusBeam.cs @@ -1,5 +1,4 @@ using System; -using CalamityMod.Balancing; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Graphics.Primitives; @@ -88,14 +87,14 @@ namespace CalamityMod.Projectiles.Typeless trail.color = trailColor; Vector2 sinOffset = (Vector2.UnitY * MathF.Sin(Projectile.timeLeft * MathHelper.Pi * 0.05f) * 24f).RotatedBy(Projectile.rotation); - Dust offTrail = Dust.NewDustPerfect(Projectile.Center + sinOffset, 175, Main.rand.NextVector2Circular(0.2f, 0.2f)); + Dust offTrail = Dust.NewDustPerfect(Projectile.Center + sinOffset, DustID.SpectreStaff, Main.rand.NextVector2Circular(0.2f, 0.2f)); offTrail.noGravity = true; offTrail.scale = Main.rand.NextFloat(1.2f, 1.8f); offTrail.alpha = Main.rand.Next(120, 180 + 1); } - internal float WidthFunction(float completionRatio) => Projectile.scale * 24f; - internal Color ColorFunction(float completionRatio) + internal float WidthFunction(float completionRatio, Vector2 vertexPos) => Projectile.scale * 24f; + internal Color ColorFunction(float completionRatio, Vector2 vertexPos) { Vector3 trailColor = Main.rgbToHsl(Color.Lerp(Color.CornflowerBlue, Color.Magenta, ProximityFactor)); Vector3 endColor = trailColor + new Vector3(0.1f + MathF.Sin(Main.GlobalTimeWrappedHourly * 5f) * 0.05f, 0f, 0.1f); @@ -105,7 +104,7 @@ namespace CalamityMod.Projectiles.Typeless public override void PostDraw(Color lightColor) { GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 30); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 30); Texture2D glow = TextureAssets.Projectile[Type].Value; Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None); } @@ -117,15 +116,7 @@ namespace CalamityMod.Projectiles.Typeless Player player = Main.player[Projectile.owner]; player.statMana += 25; player.ManaEffect(25); - - int heal = (int)Math.Round(hit.Damage * 0.1); - if (heal > BalancingConstants.LifeStealCap) - heal = BalancingConstants.LifeStealCap; - - if (Main.LocalPlayer.lifeSteal <= 0f || heal <= 0 || target.lifeMax <= 5) - return; - - CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], heal, ModContent.ProjectileType(), BalancingConstants.LifeStealRange); + Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ModContent.ProjectileType(), (int)Math.Round(hit.Damage * 0.1), 0.75f); } public override void OnKill(int timeLeft) diff --git a/Projectiles/Typeless/MagnusBoom.cs b/Projectiles/Typeless/MagnusBoom.cs index 95d64842ca..a574bfe58f 100644 --- a/Projectiles/Typeless/MagnusBoom.cs +++ b/Projectiles/Typeless/MagnusBoom.cs @@ -2,7 +2,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; diff --git a/Projectiles/Typeless/MythrilFlare.cs b/Projectiles/Typeless/MythrilFlare.cs index d3c1b2d01d..51985b90a7 100644 --- a/Projectiles/Typeless/MythrilFlare.cs +++ b/Projectiles/Typeless/MythrilFlare.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 15; i++) { - Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, 267); + Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); energyPuff.velocity = -Vector2.UnitY.RotatedByRandom(0.81f) * Main.rand.NextFloat(1.25f, 6f); energyPuff.color = Color.Lerp(new Color(104, 183, 136), Color.White, Main.rand.NextFloat(0.5f)); energyPuff.scale = 1.1f; @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Typeless public override bool? CanDamage() => Time >= AttackDelay ? null : false; - public Color TrailColor(float completionRatio) + public Color TrailColor(float completionRatio, Vector2 vertexPos) { float trailOpacity = Utils.GetLerpValue(0f, 0.13f, completionRatio, true) * Utils.GetLerpValue(0.7f, 0.58f, completionRatio, true); Color startingColor = Color.Lerp(Color.White, Color.LightGreen, 0.47f); @@ -90,13 +90,13 @@ namespace CalamityMod.Projectiles.Typeless return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * trailOpacity; } - public float TrailWidth(float completionRatio) => MathHelper.SmoothStep(Projectile.width, 4.25f, completionRatio); + public float TrailWidth(float completionRatio, Vector2 vertexPos) => MathHelper.SmoothStep(Projectile.width, 4.25f, completionRatio); public override bool PreDraw(ref Color lightColor) { // Prepare the flame trail shader with its map texture. GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 74); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(TrailWidth, TrailColor, (_,_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 74); return false; } @@ -104,7 +104,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 15; i++) { - Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, 267); + Dust energyPuff = Dust.NewDustPerfect(Projectile.Center, DustID.RainbowMk2); energyPuff.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.97f) * Main.rand.NextFloat(1f, 8f); energyPuff.color = Color.Lerp(new Color(104, 183, 136), Color.White, Main.rand.NextFloat(0.5f)); energyPuff.scale = 1.1f; diff --git a/Projectiles/Typeless/NanoFlare.cs b/Projectiles/Typeless/NanoFlare.cs index 7d3096428b..cbe942d302 100644 --- a/Projectiles/Typeless/NanoFlare.cs +++ b/Projectiles/Typeless/NanoFlare.cs @@ -24,14 +24,12 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - //Dust for (int i = 0; i < 3; i++) { - int dint = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, 0f, 0f, 0, default, 0.75f); - Dust dust = Main.dust[dint]; - dust.velocity = Projectile.velocity * Main.rand.NextFloat(-0.3f, 0.3f); - dust.color = Main.hslToRgb((float)(0.40000000596046448 + Main.rand.NextDouble() * 0.20000000298023224), 0.9f, 0.5f); - dust.color = Color.Lerp(dust.color, Color.White, 0.3f); + Dust dint = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.TerraBlade, 0f, 0f, Scale: 0.75f); + dint.velocity = Projectile.velocity * Main.rand.NextFloat(-0.3f, 0.3f); + dint.color = Main.hslToRgb(Main.rand.NextFloat(0.2f, 0.6f), 0.9f, 0.5f); + dint.color = Color.Lerp(dint.color, Color.White, 0.3f); } } @@ -40,25 +38,15 @@ namespace CalamityMod.Projectiles.Typeless for (int i = 0; i < 20; i++) { Vector2 dspeed = new Vector2(Main.rand.NextFloat(-4f, 4f), Main.rand.NextFloat(-6f, 6f)); - int dint = Dust.NewDust(Projectile.Center, 1, 1, DustID.TerraBlade, dspeed.X, dspeed.Y, 0, default, 0.7f); - Dust dust = Main.dust[dint]; - dust.color = Main.hslToRgb((float)(0.40000000596046448 + Main.rand.NextDouble() * 0.20000000298023224), 0.9f, 0.5f); + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TerraBlade, dspeed.X, dspeed.Y, 0, default, 0.7f); + dust.color = Main.hslToRgb(Main.rand.NextFloat(0.2f, 0.6f), 0.9f, 0.5f); dust.color = Color.Lerp(dust.color, Color.White, 0.3f); } SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - Projectile.width = 60; - Projectile.height = 60; - Projectile.maxPenetrate = -1; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); if (!Main.dedServ) { - Vector2 goreVec = new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f); + Vector2 goreVec = new Vector2(Projectile.Center.X - 24f, Projectile.Center.Y - 24f); float smokeScale = 0.66f; for (int i = 0; i < 2; i++) { diff --git a/Projectiles/Typeless/NavyBobber.cs b/Projectiles/Typeless/NavyBobber.cs index 7d45038fbc..cf8952aa1a 100644 --- a/Projectiles/Typeless/NavyBobber.cs +++ b/Projectiles/Typeless/NavyBobber.cs @@ -1,4 +1,6 @@ -using Terraria; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless @@ -14,6 +16,23 @@ namespace CalamityMod.Projectiles.Typeless Projectile.bobber = true; } + public override void PostAI() + { + foreach (var item in Main.ActiveNPCs) + { + if (!item.friendly && item.Distance(Projectile.Center) < 160) + { + item.AddBuff(ModContent.BuffType(), 180); + if (Main.rand.NextBool(10)) + { + Vector2 velocity = CalamityUtils.RandomVelocity(50f, 30f, 60f); + Projectile spark = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), item.Center, velocity, ModContent.ProjectileType(), 0, 0f, Projectile.owner); + spark.localNPCHitCooldown = -2; + spark.timeLeft = 30; + } + } + } + } public override bool PreDrawExtras() { Lighting.AddLight(Projectile.Center, 0f, 0.25f, 0.25f); diff --git a/Projectiles/Typeless/OmegaBlueTentacle.cs b/Projectiles/Typeless/OmegaBlueTentacle.cs index 3bb6f28ae9..2febbae82d 100644 --- a/Projectiles/Typeless/OmegaBlueTentacle.cs +++ b/Projectiles/Typeless/OmegaBlueTentacle.cs @@ -1,4 +1,4 @@ -using CalamityMod.Balancing; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,11 +9,13 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class OmegaBlueTentacle : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; public bool initSegments = false; public Vector2[] segment = new Vector2[6]; + private Player Owner => Main.player[Projectile.owner]; public override void SetDefaults() { @@ -43,18 +45,17 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - Player player = Main.player[Projectile.owner]; - bool hentai = player.Calamity().omegaBlueHentai; - if (player.active && player.Calamity().omegaBlueSet) + bool madness = Owner.Calamity().omegaBlueAbyssalMadness; + if (Owner.active && Owner.Calamity().omegaBlueSet) Projectile.timeLeft = 8; - //tentacle head movement (homing) - Vector2 playerVel = player.position - player.oldPosition; + // Tentacle head movement (homing) + Vector2 playerVel = Owner.position - Owner.oldPosition; Projectile.position += playerVel; Projectile.ai[0]++; if (Projectile.ai[0] >= 0f) { - Vector2 home = player.Center + new Vector2(50, 0).RotatedBy(MathHelper.ToRadians(60) * Projectile.ai[1]); + Vector2 home = Owner.Center + new Vector2(50, 0).RotatedBy(MathHelper.ToRadians(60) * Projectile.ai[1]); Vector2 distance = home - Projectile.Center; float range = distance.Length(); distance.Normalize(); @@ -62,7 +63,7 @@ namespace CalamityMod.Projectiles.Typeless { if (range > 13f) { - Projectile.ai[0] = -1f; //if in fast mode, stay fast until back in range + Projectile.ai[0] = -1f; // If in fast mode, stay fast until back in range if (range > 1300f) { Projectile.Kill(); @@ -71,8 +72,8 @@ namespace CalamityMod.Projectiles.Typeless } else { - if (hentai) - Projectile.ai[0] = 120f;//45f + Main.rand.Next(45); + if (madness) + Projectile.ai[0] = 120f; Projectile.velocity.Normalize(); Projectile.velocity *= 3f + Main.rand.NextFloat(3f); Projectile.netUpdate = true; @@ -82,6 +83,7 @@ namespace CalamityMod.Projectiles.Typeless { distance /= 8f; } + if (range > 120f) //switch to fast return mode { Projectile.ai[0] = -1f; @@ -94,7 +96,7 @@ namespace CalamityMod.Projectiles.Typeless if (Projectile.ai[0] > 120f) //attack nearby enemy { Projectile.ai[0] = 10 + Main.rand.Next(10); - float maxDistance = hentai ? 900f : 600f; + float maxDistance = madness ? 900f : 600f; int target = -1; foreach (NPC npc in Main.ActiveNPCs) { @@ -110,11 +112,7 @@ namespace CalamityMod.Projectiles.Typeless } if (target != -1) { - Projectile.velocity = Main.npc[target].Center - Projectile.Center; - Projectile.velocity.Normalize(); - Projectile.velocity *= 13f; - Projectile.velocity += Main.npc[target].velocity / 2f; - Projectile.velocity -= playerVel / 2f; + Projectile.velocity = Vector2.Normalize(Main.npc[target].Center - Projectile.Center) * 13f + (Main.npc[target].velocity / 2f) - (playerVel / 2f); Projectile.ai[0] *= -1f; } Projectile.netUpdate = true; @@ -122,14 +120,14 @@ namespace CalamityMod.Projectiles.Typeless } //tentacle segment updates - segment[0] = player.Center; + segment[0] = Owner.Center; for (int i = 1; i < 5; i++) { MoveSegment(segment[i - 1], ref segment[i], segment[i + 1]); } MoveSegment(segment[4], ref segment[5], Projectile.Center + Projectile.velocity); - if (hentai) + if (madness) { if (Projectile.ai[0] != -1f) Projectile.ai[0]++; @@ -138,19 +136,15 @@ namespace CalamityMod.Projectiles.Typeless Vector2 dustPos = Projectile.position + Projectile.velocity; Vector2 tickVel = dustPos - Projectile.oldPosition; //playerVel + projectile.velocity * 2f; dustPos += new Vector2(Projectile.width / 2, 0).RotatedBy(Projectile.rotation); - dustPos.X -= 4; - dustPos.X += Projectile.width / 2; - dustPos.Y -= 4; - dustPos.Y += Projectile.height / 2; + dustPos += new Vector2(Projectile.width / 2 - 4, Projectile.height / 2 - 4); const float factor = 3f; int limit = (int)(tickVel.Length() / factor); if (limit == 0) { - int d = Dust.NewDust(dustPos, 0, 0, DustID.PurificationPowder, 0, 0, 100, Color.Transparent, 0.9f); - Main.dust[d].noGravity = true; - Main.dust[d].noLight = true; - Main.dust[d].fadeIn = 1f; - Main.dust[d].velocity = Vector2.Zero; + Dust d = Dust.NewDustPerfect(dustPos, DustID.PurificationPowder, Vector2.Zero, 100, Color.Transparent, 0.9f); + d.noGravity = true; + d.noLight = true; + d.fadeIn = 1f; } else { @@ -158,12 +152,11 @@ namespace CalamityMod.Projectiles.Typeless tickVel *= factor; for (int i = 0; i <= limit; i++) { - int d = Dust.NewDust(dustPos, 0, 0, DustID.PurificationPowder, 0, 0, 100, Color.Transparent, 0.9f); - Main.dust[d].noGravity = true; - Main.dust[d].noLight = true; - Main.dust[d].fadeIn = 1f; - Main.dust[d].position -= tickVel * i; - Main.dust[d].velocity = Vector2.Zero; + Dust d = Dust.NewDustPerfect(dustPos, DustID.PurificationPowder, Vector2.Zero, 100, Color.Transparent, 0.9f); + d.noGravity = true; + d.noLight = true; + d.fadeIn = 1f; + d.position -= tickVel * i; } } } @@ -177,35 +170,18 @@ namespace CalamityMod.Projectiles.Typeless public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Main.player[Projectile.owner].Calamity().omegaBlueHentai) + if (Owner.Calamity().omegaBlueAbyssalMadness) modifiers.SetCrit(); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (Projectile.owner == Main.myPlayer && Main.player[Projectile.owner].lifeSteal > 0f && !Main.player[Projectile.owner].moonLeech && target.lifeMax > 5) - { - int healAmount = 10 * damageDone / Projectile.damage; //should always be around max, less if enemy has defense/DR - if (healAmount > BalancingConstants.LifeStealCap) - healAmount = BalancingConstants.LifeStealCap; - - if (healAmount > 0) - { - Main.player[Projectile.owner].lifeSteal -= healAmount; - if (Main.player[Projectile.owner].Calamity().omegaBlueHentai) //hentai always crits, this makes it have same lifesteal delay - Main.player[Projectile.owner].lifeSteal += healAmount / 2; - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ProjectileID.SpiritHeal, 0, 0f, Projectile.owner, Projectile.owner, healAmount); - } - } - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Owner.DoLifestealDirect(target, 10 * hit.Damage / Projectile.damage, 0.5f); public override bool PreDraw(ref Color lightColor) { Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - GameShaders.Armor.ApplySecondary(Main.player[Projectile.owner].cBody, Main.player[Projectile.owner], new DrawData?()); + GameShaders.Armor.ApplySecondary(Owner.cBody, Owner, new DrawData?()); Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Projectile[Type].Value; Texture2D segmentSprite = ModContent.Request("CalamityMod/Projectiles/Typeless/OmegaBlueTentacleSegment1").Value; for (int i = 0; i < 5; i++) diff --git a/Projectiles/Typeless/OnyxLabSeeker.cs b/Projectiles/Typeless/OnyxLabSeeker.cs index 97a26da02c..d87f60019e 100644 --- a/Projectiles/Typeless/OnyxLabSeeker.cs +++ b/Projectiles/Typeless/OnyxLabSeeker.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), DustID.RainbowMk2); dust.color = Color.Magenta; dust.scale = Main.rand.NextFloat(0.95f, 1.25f); dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); diff --git a/Projectiles/Typeless/PauldronDash.cs b/Projectiles/Typeless/PauldronDash.cs index 31a4099d5a..f3007de542 100644 --- a/Projectiles/Typeless/PauldronDash.cs +++ b/Projectiles/Typeless/PauldronDash.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using CalamityMod.Dusts; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,28 +12,103 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class PauldronDash : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[Projectile.owner]; private static float ExplosionRadius = 75f; + public Color effectsColor = Color.White; + public float fxFade = 0; + public bool isAlive = true; + public bool visuals => Owner.Calamity().sPauldronVisual; + public Vector2 aimVel; + bool hasHit = false; public override void SetDefaults() { - //These shouldn't matter because its circular - Projectile.width = 75; - Projectile.height = 75; + Projectile.width = (int)ExplosionRadius; + Projectile.height = (int)ExplosionRadius; Projectile.friendly = true; Projectile.DamageType = AverageDamageClass.Instance; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.penetrate = 1; - Projectile.timeLeft = 4; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 22; + Projectile.penetrate = -1; + Projectile.timeLeft = 15; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 18; } + public override void AI() + { + if (Owner.dashDelay != -1) + isAlive = false; + if (isAlive) + Projectile.timeLeft++; + Projectile.Center = Owner.Center; + if (effectsColor == Color.White) + aimVel = Owner.velocity; + else + { + aimVel = Vector2.Lerp(aimVel, Owner.velocity, 0.2f); + } + + if (isAlive) + { + float goalSize = Utils.GetLerpValue(5, 15, Math.Abs(aimVel.X), true); + if (goalSize < fxFade) + fxFade = MathHelper.Lerp(fxFade, goalSize, 0.03f); + else + fxFade = goalSize; + } + else + { + fxFade = MathHelper.Lerp(fxFade, 0, 0.08f); + } + + + float rate = Main.GlobalTimeWrappedHourly * 22; + List eColors = new List() + { + Color.OrangeRed, + Color.Orange, + Color.DarkOrange + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + effectsColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + if (visuals) + { + int dir = MathF.Sign(aimVel.X); + if (dir == 0) + dir = Owner.direction; + Vector2 safeVel = aimVel.SafeNormalize(Vector2.UnitX * dir); + float sparkscale2 = 0.35f * Math.Max(fxFade, 0.5f); + for (int i = -1; i <= 1; i += 2) + { + Vector2 sparkVelocity = safeVel.RotatedBy(dir * 4.3f * i) - safeVel * 3; + Vector2 sparkPlace = Owner.Center + (safeVel * 15).RotatedBy(2f * dir * i) * 1.5f; + Particle spark = new VelChangingSpark(sparkPlace, sparkVelocity, -safeVel * 5, "CalamityMod/Particles/BloomCircle", 10, sparkscale2, effectsColor * fxFade, new Vector2(0.8f, 2f), shrinkSpeed: 0.4f, lerpRate: 0.1f); + GeneralParticleHandler.SpawnParticle(spark); + + if (isAlive) + { + int dustStyle = ModContent.DustType(); + Dust dust2 = Dust.NewDustPerfect(sparkPlace + safeVel * 30, dustStyle, sparkVelocity.RotatedBy(-0.6f * i * dir).RotatedByRandom(0.3f) * Main.rand.NextFloat(3, 5)); + dust2.scale = Main.rand.NextFloat(0.9f, 1.3f); + dust2.color = Main.rand.NextBool() ? Color.Orange : Color.OrangeRed; + dust2.noGravity = true; + } + } + } + + if (Owner.dead || (!isAlive && fxFade < 0.1f) || (Owner.velocity == Vector2.Zero && Owner.dashDelay != -1)) + Projectile.Kill(); + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.OnFire3, 240); @@ -45,43 +122,67 @@ namespace CalamityMod.Projectiles.Typeless for (int i = 0; i <= 12; i++) { float variance = Main.rand.NextFloat(-0.7f, 0.7f); - int dustStyle = ModContent.DustType(); + int dustStyle = ModContent.DustType(); Dust dust2 = Dust.NewDustPerfect(target.Center, dustStyle, Projectile.velocity); - dust2.scale = (Main.rand.NextFloat(1.1f, 1.3f) - Math.Abs(variance)) * 2.5f; - dust2.velocity = (Vector2.UnitY * -18).RotatedBy(variance) * Main.rand.NextFloat(0.7f, 1f) * (1 - Math.Abs(variance) * 1.3f); + dust2.scale = (Main.rand.NextFloat(1.2f, 1.4f) - Math.Abs(variance)) * 2.5f; + dust2.velocity = (Vector2.UnitY * -25).RotatedBy(variance) * Main.rand.NextFloat(0.7f, 1f) * (1 - Math.Abs(variance) * 1.3f); dust2.color = Main.rand.NextBool() ? Color.Orange : Color.OrangeRed; dust2.noGravity = false; + dust2.fadeIn = 0.35f; Particle spark = new SparkParticle(Projectile.Center, new Vector2(17, 17).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 1f), true, 55, 0.85f, Main.rand.NextBool() ? Color.Orange : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark); } - float baseRot = Main.rand.NextFloat(-9f, 9f); + if (visuals) + { + float baseRot = Main.rand.NextFloat(-9f, 9f); + for (int i = 0; i < 5; i++) + { + float rot = Main.rand.NextFloat(-0.3f, 0.3f); + for (int b = 0; b < 2; b++) + { + Vector2 pulseVel = new Vector2(0, Main.rand.NextFloat(-7, -9)).RotatedBy(i * (MathHelper.ToRadians(360f) / 5)).RotatedBy(rot + baseRot + 0.9f); + Particle orb = new CustomPulse(target.Center, pulseVel, (Main.rand.NextBool() ? Color.Orange : Color.OrangeRed) * 0.9f, "CalamityMod/Projectiles/Summon/RustyBeaconPulse", Vector2.One, pulseVel.ToRotation(), 0.2f, Main.rand.NextFloat(0.55f, 0.85f) * 3f, Main.rand.Next(14, 19 + 1)); + GeneralParticleHandler.SpawnParticle(orb); + } + Particle orb2 = new CustomSpark(target.Center, new Vector2(0, -7).RotatedBy(i * (MathHelper.ToRadians(360f) / 5)).RotatedBy(rot + baseRot), "CalamityMod/Particles/BloomLineFade", false, 13, 0.095f, Main.rand.NextBool() ? Color.Orange : Color.OrangeRed, new Vector2(2.9f, 0.5f), shrinkSpeed: 0.9f); + GeneralParticleHandler.SpawnParticle(orb2); + } + + for (int i = 0; i < 2; i++) + { + Particle bloom = new CustomSpark(target.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 20, 1.2f, Color.OrangeRed, new Vector2(1, 1), true, true, glowCenterScale: 0.7f, glowOpacity: 0.8f); + GeneralParticleHandler.SpawnParticle(bloom); + } + } + + Owner.SetScreenshake(4f); + + if (!hasHit) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 5, 0, Projectile.owner); + hasHit = true; + } + + Projectile.damage = (int)(Projectile.damage * 0.67f); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); + public override bool? CanDamage() => (isAlive ? null : false); + public override bool PreDraw(ref Color lightColor) + { + if (effectsColor == Color.White || !visuals) + return false; + + float sine = MathHelper.Lerp(Math.Abs((float)Math.Sin(Main.GlobalTimeWrappedHourly * 50f / MathHelper.Pi)), 0.8f, 0.7f); + Texture2D bTexture = ModContent.Request("CalamityMod/Particles/VerticalSmearLarge").Value; + for (int i = 0; i < 5; i++) { - float rot = Main.rand.NextFloat(-0.3f, 0.3f); - for (int b = 0; b < 2; b++) - { - Vector2 pulseVel = new Vector2(0, Main.rand.NextFloat(-7, -9)).RotatedBy(i * (MathHelper.ToRadians(360f) / 5)).RotatedBy(rot + baseRot + 0.9f); - Particle orb = new CustomPulse(target.Center, pulseVel, (Main.rand.NextBool() ? Color.Orange : Color.OrangeRed) * 0.9f, "CalamityMod/Projectiles/Summon/RustyBeaconPulse", Vector2.One, pulseVel.ToRotation(), 0.2f, Main.rand.NextFloat(0.55f, 0.85f) * 3f, Main.rand.Next(14, 19 + 1)); - GeneralParticleHandler.SpawnParticle(orb); - } - Particle orb2 = new CustomSpark(target.Center, new Vector2(0, -7).RotatedBy(i * (MathHelper.ToRadians(360f) / 5)).RotatedBy(rot + baseRot), "CalamityMod/Particles/BloomLineFade", false, 13, 0.095f, Main.rand.NextBool() ? Color.Orange : Color.OrangeRed, new Vector2(2.9f, 0.5f), shrinkSpeed: 0.9f); - GeneralParticleHandler.SpawnParticle(orb2); - } - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 2, 0, Projectile.owner); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); - public override bool? CanDamage() => base.CanDamage(); - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - Owner.Calamity().GeneralScreenShakePower = 4f; - for (int i = 0; i < 2; i++) - { - Particle bloom = new CustomSpark(target.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 20, 1.2f, Color.OrangeRed, new Vector2(1, 1), true, true, glowCenterScale: 0.7f, glowOpacity: 0.8f); - GeneralParticleHandler.SpawnParticle(bloom); + float bScale2 = 0.75f; + Vector2 scale = new Vector2((1 - i * 0.15f) * sine, (1 + i * 0.22f) + fxFade * 0.2f) * (bScale2 - i * 0.08f) * fxFade * 0.23f; + Main.EntitySpriteDraw(bTexture, Owner.Center - Main.screenPosition + aimVel.SafeNormalize(Vector2.UnitX) * -15, null, Color.Lerp(effectsColor, Color.White, i * 0.15f) with { A = 0 } * fxFade, aimVel.ToRotation() + MathHelper.PiOver2, bTexture.Size() * 0.5f, scale, SpriteEffects.None, 0); } + return false; } public override bool? CanCutTiles() => false; } diff --git a/Projectiles/Typeless/PauldronExplosion.cs b/Projectiles/Typeless/PauldronExplosion.cs index ee02ad48c7..eddb8cb142 100644 --- a/Projectiles/Typeless/PauldronExplosion.cs +++ b/Projectiles/Typeless/PauldronExplosion.cs @@ -1,10 +1,5 @@ -using System; -using CalamityMod.Dusts; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -31,21 +26,19 @@ namespace CalamityMod.Projectiles.Typeless Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.OnFire3, 240); - - //Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.OrangeRed, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 0f, Main.rand.NextFloat(0.8f, 1.1f), 20); - //GeneralParticleHandler.SpawnParticle(pulse); - //Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.DarkOrange, new Vector2(2f, 2f), Main.rand.NextFloat(12f, 25f), 0f, Main.rand.NextFloat(0.6f, 0.9f), 20); - //GeneralParticleHandler.SpawnParticle(pulse2); } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); public override bool? CanDamage() => base.CanDamage(); public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + float minMult = 0.3f; + int hitsToMinMult = 8; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); target.MoveNPC(launchVel, 15, true); } diff --git a/Projectiles/Typeless/PearlAuraShard.cs b/Projectiles/Typeless/PearlAuraShard.cs index 6953d1f41b..e6773818c4 100644 --- a/Projectiles/Typeless/PearlAuraShard.cs +++ b/Projectiles/Typeless/PearlAuraShard.cs @@ -1,5 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/PinkPearl.png b/Projectiles/Typeless/PinkPearl.png new file mode 100644 index 0000000000..2689197f96 Binary files /dev/null and b/Projectiles/Typeless/PinkPearl.png differ diff --git a/Projectiles/Typeless/PlaguePulse.cs b/Projectiles/Typeless/PlaguePulse.cs index 64e4a8f6d3..fb430aa6e8 100644 --- a/Projectiles/Typeless/PlaguePulse.cs +++ b/Projectiles/Typeless/PlaguePulse.cs @@ -1,14 +1,9 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using CalamityMod.Particles; -using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework.Graphics; -using SteelSeries.GameSense; using CalamityMod.Buffs.DamageOverTime; -using Mono.Cecil; namespace CalamityMod.Projectiles.Typeless { @@ -79,7 +74,7 @@ namespace CalamityMod.Projectiles.Typeless Player player = Main.player[Projectile.owner]; target.AddBuff(ModContent.BuffType(), 420); - if ((target.life <= 0 && target.realLife == -1)) + if (target.life <= 0 && target.realLife == -1 && target.IsAnEnemy(false)) { player.Heal(10); Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.9f), 0f, Projectile.owner, 0, Projectile.ai[1] + 1, 1); diff --git a/Projectiles/Typeless/PoisonousSeawater.cs b/Projectiles/Typeless/PoisonousSeawater.cs index 62da40e9d6..d69b4e22dc 100644 --- a/Projectiles/Typeless/PoisonousSeawater.cs +++ b/Projectiles/Typeless/PoisonousSeawater.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Projectiles/Typeless/ProtolithBangleProjectile.cs b/Projectiles/Typeless/ProtolithBangleProjectile.cs new file mode 100644 index 0000000000..f50a544547 --- /dev/null +++ b/Projectiles/Typeless/ProtolithBangleProjectile.cs @@ -0,0 +1,125 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class ProtolithBangleProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public int damageTime = 24; + public int Soundtime1 = 2; + public int Soundtime2 = 8; + public int Soundtime3 = 15; + public int explosionSize = 230; + public SlotId SoundSlot; + public Player Owner => Main.player[Projectile.owner]; + public bool visual => Owner.Calamity().protolithBangleVisual; + public override void SetDefaults() + { + Projectile.width = explosionSize; + Projectile.height = explosionSize; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = damageTime + 20; + Projectile.ArmorPenetration = 25; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.scale = 0.8f; + } + public override void AI() + { + if (!(Projectile.ai[0] < 0f || Projectile.ai[0] > 199f) && time <= damageTime && Main.npc[(int)Projectile.ai[0]].active && Main.npc[(int)Projectile.ai[0]].life > 0) + Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; + + Vector2 particlePlace = Vector2.UnitY * 40; + if (time == Soundtime1) + { + MakePusle(Projectile.Center + particlePlace); + } + if (time == Soundtime2) + { + MakePusle(Projectile.Center + particlePlace.RotatedBy(MathHelper.TwoPi / 3)); + } + if (time == Soundtime3) + { + MakePusle(Projectile.Center + particlePlace.RotatedBy(-MathHelper.TwoPi / 3)); + } + if (time == damageTime) + { + float visMult = (visual ? 1 : 0.3f); + Projectile.ai[0] = -1; + + if (visual) + { + Particle spark = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 15, 1.2f, Color.Gold, Projectile.scale * new Vector2(1f, 1.3f), true, true, shrinkSpeed: 0.9f); + GeneralParticleHandler.SpawnParticle(spark); + + Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Projectile.scale * new Vector2(1.4f, 0.6f), 0, 0.3f, 1.35f, 15); + GeneralParticleHandler.SpawnParticle(pulse); + } + + for (int i = 0; i < 28; i++) + { + Particle marble = new CustomSpark(Projectile.Center, (Vector2.One * Main.rand.NextFloat(8, 13)).RotatedByRandom(MathHelper.TwoPi), "CalamityMod/Particles/Square", true, Main.rand.Next(40, 70 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 15, Color.Lerp(Color.White, Color.Khaki, Main.rand.NextFloat()) * visMult, new Vector2(1f, Main.rand.NextFloat(1, 2)), false, false, extraRotation: Main.rand.NextFloat(-4, 4)); + GeneralParticleHandler.SpawnParticle(marble); + } + } + if (time == 0 && visual) + { + SoundStyle sound = new("CalamityMod/Sounds/Item/ProtolithBangleSound"); + SoundSlot = SoundEngine.PlaySound(sound with { Volume = 1f, MaxInstances = -1 }, Projectile.Center); + } + if (SoundEngine.TryGetActiveSound(SoundSlot, out var Sound) && Sound.IsPlaying) + Sound.Position = Projectile.Center; + time++; + } + public void MakePusle(Vector2 position) + { + if (!visual) + return; + + Particle pulse = new CustomPulse(position, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Projectile.scale * Vector2.One, 0, 0.3f, 0.65f, 25); + GeneralParticleHandler.SpawnParticle(pulse); + + for (int i = 0; i < 18; i++) + { + Vector2 outerVel = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5, 7); + Particle marble = new CustomSpark(position + outerVel * 5, -outerVel * 0.6f, "CalamityMod/Particles/Square", false, Main.rand.Next(10, 15 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 10, Color.Lerp(Color.White, Color.Khaki, Main.rand.NextFloat()), new Vector2(1f, Main.rand.NextFloat(1, 2)), false, false, extraRotation: Main.rand.NextFloat(-4, 4)); + GeneralParticleHandler.SpawnParticle(marble); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + float critDamage = Math.Min(Owner.GetTotalCritChance(AverageDamageClass.Instance) * 0.01f, 1f); + + float minMult = 0.1f; + int hitsToMinMult = 5; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult + critDamage; + + Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY; + float launchPower = 6; + target.MoveNPC(launchVel, launchPower, true); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f * Projectile.scale, targetHitbox); + public override bool? CanDamage() + { + if (time >= damageTime) + return null; + else + return false; + } + } +} diff --git a/Projectiles/Typeless/ReaverOrb.cs b/Projectiles/Typeless/ReaverOrb.cs deleted file mode 100644 index e2557bb25b..0000000000 --- a/Projectiles/Typeless/ReaverOrb.cs +++ /dev/null @@ -1,79 +0,0 @@ -using CalamityMod.CalPlayer; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Typeless -{ - public class ReaverOrb : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Typeless"; - public int dust = 3; - - public override void SetDefaults() - { - Projectile.width = 48; - Projectile.height = 50; - Projectile.netImportant = true; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.timeLeft = 18000; - Projectile.alpha = 50; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - } - - public override void AI() - { - bool correctMinion = Projectile.type == ModContent.ProjectileType(); - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (!modPlayer.reaverExplore) - { - Projectile.active = false; - return; - } - if (correctMinion) - { - if (player.dead) - { - modPlayer.rOrb = false; - } - if (modPlayer.rOrb) - { - Projectile.timeLeft = 2; - } - } - dust--; - if (dust >= 0) - { - int dustAmt = 50; - for (int d = 0; d < dustAmt; d++) - { - int idx = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.ChlorophyteWeapon, 0f, 0f, 0, default, 1f); - Main.dust[idx].velocity *= 2f; - Main.dust[idx].scale *= 1.15f; - } - } - - Lighting.AddLight(Projectile.Center, 0.5f, 2f, 0.5f); - - Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 60f); - if (player.gravDir == -1f) - { - Projectile.position.Y += 120f; - Projectile.rotation = MathHelper.Pi; - } - else - { - Projectile.rotation = 0f; - } - Projectile.position.X = (int)Projectile.position.X; - Projectile.position.Y = (int)Projectile.position.Y; - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Typeless/ReaverOrb.png b/Projectiles/Typeless/ReaverOrb.png deleted file mode 100644 index 4832434cb8..0000000000 Binary files a/Projectiles/Typeless/ReaverOrb.png and /dev/null differ diff --git a/Projectiles/Typeless/RedLabSeeker.cs b/Projectiles/Typeless/RedLabSeeker.cs index 7a57f2aada..1028d47434 100644 --- a/Projectiles/Typeless/RedLabSeeker.cs +++ b/Projectiles/Typeless/RedLabSeeker.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Typeless // Release lingering dust. else { - Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(8f, 8f), 267); + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(8f, 8f), DustID.RainbowMk2); dust.velocity = Main.rand.NextVector2Circular(2f, 2f); dust.noGravity = true; dust.color = dustColor; @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), DustID.RainbowMk2); dust.color = Color.Red; dust.scale = Main.rand.NextFloat(0.95f, 1.25f); dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); diff --git a/Projectiles/Typeless/RelicGuard.cs b/Projectiles/Typeless/RelicGuard.cs index 42c242cfe4..f12b5ee889 100644 --- a/Projectiles/Typeless/RelicGuard.cs +++ b/Projectiles/Typeless/RelicGuard.cs @@ -1,15 +1,11 @@ using System; using System.Collections.Generic; -using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Dusts; -using CalamityMod.Items; -using CalamityMod.Particles; +using CalamityMod.Items.Tools; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless @@ -91,7 +87,7 @@ namespace CalamityMod.Projectiles.Typeless } public override bool PreDraw(ref Color lightColor) { - Texture2D rTexture = ModContent.Request("CalamityMod/Items/RelicOfResilience").Value; + Texture2D rTexture = ModContent.Request("CalamityMod/Items/Tools/RelicOfResilience").Value; Texture2D bTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; Color drawColor = bColor; float CDScale = Utils.GetLerpValue(300, 0, Owner.Calamity().rOfResilienceCooldown, true); diff --git a/Projectiles/Typeless/RelicOfConvergenceCrystal.cs b/Projectiles/Typeless/RelicOfConvergenceCrystal.cs index 027e3bebea..b4d444a192 100644 --- a/Projectiles/Typeless/RelicOfConvergenceCrystal.cs +++ b/Projectiles/Typeless/RelicOfConvergenceCrystal.cs @@ -1,9 +1,8 @@ using System; using System.Collections.Generic; -using CalamityMod.Buffs.StatBuffs; using CalamityMod.Dusts; using CalamityMod.Enums; -using CalamityMod.Items; +using CalamityMod.Items.Tools; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -30,6 +29,7 @@ namespace CalamityMod.Projectiles.Typeless public ref float time => ref Projectile.ai[0]; public float completion = 0; public float fade = 0; + public int killTimer = 0; public Vector2 mousePos; public bool playSound = true; public override void SetDefaults() @@ -49,13 +49,16 @@ namespace CalamityMod.Projectiles.Typeless if (Projectile.timeLeft >= 5) mousePos = Owner.ClampedMouseWorld(); - if (!Owner.channel) + if (Owner.channel) + killTimer = 18; + if (killTimer <= 0) { Projectile.Kill(); return; } if (Owner.Calamity().profanedSoulRelicBuff) Projectile.extraUpdates = 1; + killTimer--; UpdatePlayerVisuals(Owner); diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index cc5b122fa2..ed19b92991 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using System.IO; using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Typeless; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -17,6 +17,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class RelicOfDeliveranceSpear : ModProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); @@ -47,7 +48,6 @@ namespace CalamityMod.Projectiles.Typeless public bool inTiles = false; public float respawnMult = 0; - int postHitTimer = 0; public Color bColor = Color.White; public SlotId digSoundSlot; public int digFXCooldown = 0; @@ -115,12 +115,12 @@ namespace CalamityMod.Projectiles.Typeless } // Immediately die if the Owner is not holding the spear - if (Owner.ActiveItem() == null) + if (Owner.HeldItem == null) { KillProj(); return; } - if (Owner.ActiveItem().type != ModContent.ItemType()) + if (Owner.HeldItem.type != ModContent.ItemType()) { KillProj(); return; @@ -249,7 +249,7 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(sound3 with { Volume = 0.7f, Pitch = 0.4f, MaxInstances = 3 }, Projectile.Center); } if (driftPower > 1) - Owner.Calamity().GeneralScreenShakePower = (driftPower == 2 ? 6 : 9); + Owner.SetScreenshake(driftPower == 2 ? 6 : 9); else if (driftBadMult > 0.15f) driftBadMult -= 0.15f; @@ -437,14 +437,29 @@ namespace CalamityMod.Projectiles.Typeless Owner.Center = respawnPoint; } killed = true; - Owner.fullRotationOrigin = Owner.Center - Owner.position; - Owner.fullRotation = 0; Owner.Calamity().rOfDelivarenceRam = false; Projectile.netUpdate = true; Projectile.Kill(); } + + public override void OnKill(int timeLeft) + { + if (Projectile.owner == Main.myPlayer && SoundEngine.TryGetActiveSound(digSoundSlot, out var sound)) + sound.Stop(); + + Owner.fullRotationOrigin = Owner.Center - Owner.position; + Owner.fullRotation = 0f; + + if (Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.SyncPlayer, number: Owner.whoAmI); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + bool crit = Main.rand.Next(0, 100 + 1) < Owner.GetTotalCritChance(Owner.GetBestClass()); + if (crit) + modifiers.SetCrit(); + float minMult = 0.15f; int hitsToMinMult = 15; float damageMult = Utils.Remap(hitCountDamageSource, 0, hitsToMinMult, 1, minMult, true); @@ -476,7 +491,9 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { Vector2 drawPos = Owner.MountedCenter + (drifting ? idealVel : Projectile.velocity).SafeNormalize(Vector2.UnitX) * (55 - 35 * Utils.GetLerpValue(0, 25, driftTimer, true)); - Projectile.DrawProjectileWithBackglow(Color.Goldenrod with { A = 0 }, Color.White, 3f * driftPowerScaling, effects: Math.Sign((drifting ? idealVel.X : Projectile.velocity.X)) == -1 ? Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically : Microsoft.Xna.Framework.Graphics.SpriteEffects.None, xPos: drawPos.X, yPos: drawPos.Y); + Projectile.DrawProjectileWithBackglow(Color.Goldenrod with { A = 0 }, Color.White, 3f * driftPowerScaling, effects: Math.Sign((drifting ? idealVel.X : Projectile.velocity.X)) == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None, xPos: drawPos.X, yPos: drawPos.Y); + //Asset texBase = ModContent.Request(Texture); + //Main.EntitySpriteDraw(texBase.Value, drawPos, null, Color.White, Projectile.rotation, texBase.Size() * 0.5f, Projectile.scale, Math.Sign((drifting ? idealVel.X : Projectile.velocity.X)) == -1 ? Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically : Microsoft.Xna.Framework.Graphics.SpriteEffects.None); Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomRing").Value; Texture2D texture2 = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; diff --git a/Projectiles/Typeless/RetaliationProjectile.cs b/Projectiles/Typeless/RetaliationProjectile.cs index 4e1ff1718d..56a16c3abb 100644 --- a/Projectiles/Typeless/RetaliationProjectile.cs +++ b/Projectiles/Typeless/RetaliationProjectile.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using CalamityMod.CalPlayer; +using System.Collections.Generic; using CalamityMod.Dusts; -using CalamityMod.Graphics.Metaballs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Projectiles/Typeless/RiftReelerBobber.cs b/Projectiles/Typeless/RiftReelerBobber.cs index f5b3defd39..45bd54bfb3 100644 --- a/Projectiles/Typeless/RiftReelerBobber.cs +++ b/Projectiles/Typeless/RiftReelerBobber.cs @@ -13,6 +13,11 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 14; Projectile.aiStyle = ProjAIStyleID.Bobber; Projectile.bobber = true; + Projectile.friendly = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.penetrate = -1; + Projectile.ArmorPenetration = 100; } public override bool PreDrawExtras() diff --git a/Projectiles/Typeless/RustyMedallionDroplet.cs b/Projectiles/Typeless/RustyMedallionDroplet.cs new file mode 100644 index 0000000000..d82bab90f3 --- /dev/null +++ b/Projectiles/Typeless/RustyMedallionDroplet.cs @@ -0,0 +1,73 @@ +using CalamityMod.Buffs.StatDebuffs; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class RustyMedallionDroplet : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/Environment/AcidDrop"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 5; + ProjectileID.Sets.TrailingMode[Type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 20; + Projectile.friendly = true; + Projectile.tileCollide = true; + Projectile.ignoreWater = false; + Projectile.timeLeft = 840; + Projectile.penetrate = 2; + Projectile.extraUpdates = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = DamageClass.Generic; + } + public override void AI() + { + if (Main.rand.NextBool()) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.JungleTorch); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.65f, 0.8f); + dust.velocity = -Projectile.velocity * 0.4f; + } + + Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + // Water drip + for (int i = 0; i < 4; i++) + { + int idx = Dust.NewDust(Projectile.position - Projectile.velocity, 2, 2, DustID.JungleTorch, 0f, 0f, 0, new Color(112, 150, 42, 127), 1f); + Dust dust = Main.dust[idx]; + dust.position.X -= 2f; + Main.dust[idx].alpha = 38; + Main.dust[idx].velocity *= Projectile.velocity.RotatedByRandom(0.3f) * 0.4f; + Main.dust[idx].velocity -= Projectile.velocity * 0.025f; + Main.dust[idx].scale = 0.85f; + } + return true; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], new Color(255, 255, 255, 127), 2); + return false; + } + } +} diff --git a/Projectiles/Typeless/SCalAltarArenaVisual.cs b/Projectiles/Typeless/SCalAltarArenaVisual.cs new file mode 100644 index 0000000000..6ed98e6c53 --- /dev/null +++ b/Projectiles/Typeless/SCalAltarArenaVisual.cs @@ -0,0 +1,64 @@ +using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria; +using CalamityMod.NPCs.SupremeCalamitas; + +namespace CalamityMod.Projectiles.Typeless +{ + public class SCalAltarArenaVisual : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + private const int VisualDuration = 900; + private Particle topLine; + private Particle bottomLine; + private Particle leftLine; + private Particle rightLine; + public override void SetStaticDefaults() => ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 2; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = VisualDuration; + } + + public override void AI() + { + // Spawn in the border lines + if (topLine == null) + { + // Arena is smaller in Death Mode + float arenaHalfLength = Projectile.ai[0] == 1f ? 1000f : 1250f; + Vector2 topLeft = Projectile.Center + new Vector2(-arenaHalfLength, -arenaHalfLength); + Vector2 topRight = Projectile.Center + new Vector2(arenaHalfLength, -arenaHalfLength); + Vector2 bottomLeft = Projectile.Center + new Vector2(-arenaHalfLength, arenaHalfLength); + Vector2 bottomRight = Projectile.Center + new Vector2(arenaHalfLength, arenaHalfLength); + + topLine = new BloomLineVFX(topLeft, topRight - topLeft, 1f, Color.Red, VisualDuration, true, true); + bottomLine = new BloomLineVFX(bottomLeft, bottomRight - bottomLeft, 1f, Color.Red, VisualDuration, true, true); + leftLine = new BloomLineVFX(topLeft, bottomLeft - topLeft, 1f, Color.Red, VisualDuration, true, true); + rightLine = new BloomLineVFX(topRight, bottomRight - topRight, 1f, Color.Red, VisualDuration, true, true); + GeneralParticleHandler.SpawnParticle(topLine); + GeneralParticleHandler.SpawnParticle(bottomLine); + GeneralParticleHandler.SpawnParticle(leftLine); + GeneralParticleHandler.SpawnParticle(rightLine); + } + + if (NPC.AnyNPCs(ModContent.NPCType())) + Projectile.Kill(); + } + + public override void OnKill(int timeLeft) + { + topLine.Time = VisualDuration - 30; + bottomLine.Time = VisualDuration - 30; + leftLine.Time = VisualDuration - 30; + rightLine.Time = VisualDuration - 30; + } + } +} diff --git a/Projectiles/Typeless/SandBall.cs b/Projectiles/Typeless/SandBall.cs index c5f95893e9..218b99706d 100644 --- a/Projectiles/Typeless/SandBall.cs +++ b/Projectiles/Typeless/SandBall.cs @@ -1,10 +1,5 @@ using System; -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Items.Placeables.Astral; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Tiles.Abyss; -using CalamityMod.Tiles.AstralDesert; -using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -21,12 +16,121 @@ namespace CalamityMod.Projectiles.Typeless public override int DustType => 108; } + public class EutrophicSandBallFalling : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallEutrophic"; + public override bool Fired => false; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Titanium; + } + + public class DunesandBallFalling : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallDune"; + public override bool Fired => false; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Hive; + } + + public class PolypSandBallFalling : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallPolyp"; + public override bool Fired => false; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Ice_Red; + } + + public class VolcanicSandBallFalling : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallVolcanic"; + public override bool Fired => false; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.t_PearlWood; + } + + public class WhitePearlFalling : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/WhitePearl"; + public override bool Fired => false; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Slush; + } + + public class PinkPearlFalling : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/PinkPearl"; + public override bool Fired => false; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Ice_Pink; + } + + public class BlackPearlFalling : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/BlackPearl"; + public override bool Fired => false; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Lead; + } + public class AstralSandBallGun : SandBall { public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallAstral"; public override int TileType => ModContent.TileType(); public override int ItemType => ModContent.ItemType(); public override int DustType => 108; + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one hits only one target but splits on impact into seeking mini sands + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 1; + Projectile.localNPCHitCooldown = 10; + Projectile.usesLocalNPCImmunity = true; + Projectile.usesIDStaticNPCImmunity = false; + } + public override bool PreAI() + { + if (Projectile.ai[2] == 1) + { + Projectile.scale = 0.75f; + if (Projectile.ai[1] == 0) + { + Projectile.originalDamage = Projectile.damage; + Projectile.damage = 0; + } + if (Projectile.ai[1] == 30) + { + Projectile.Calamity().conditionalHomingRange = 600; + Projectile.damage = Projectile.originalDamage; + } + } + return base.PreAI(); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[2] != 1) + { + for (var i = 0; i < 4; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.75f) * Main.rand.NextFloat(0.5f,0.75f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, ai2: 1); + } + } + + public override bool PreKill(int timeLeft) + { + if (Projectile.penetrate == 0) + Projectile.active = false; + return Projectile.active; + } + } public class EutrophicSandBallGun : SandBall @@ -34,7 +138,21 @@ namespace CalamityMod.Projectiles.Typeless public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallEutrophic"; public override int TileType => ModContent.TileType(); public override int ItemType => ModContent.ItemType(); + public override bool DropAsItem => true; public override int DustType => 108; // Weirdly same dusts as Astral + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one hits only one target and does 5 less damage, but inflicts a relatively long stun debuff + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 1; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + } } public class SulphurousSandBallGun : SandBall @@ -42,7 +160,131 @@ namespace CalamityMod.Projectiles.Typeless public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallSulphurous"; public override int TileType => ModContent.TileType(); public override int ItemType => ModContent.ItemType(); + public override bool DropAsItem => true; // Uses normal sand dust + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one hits only two targets but inflicts Irradiated + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 2; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 150); + } + } + public class DuneSandBallGun : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallDune"; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Sand; + + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one has much less velocity and no gravity for the first 3 seconds, pierces infinitely, and does 5 extra damage + public override void AI() + { + if (Projectile.ai[1] == 0 ) + { + Projectile.velocity *= 0.5f; + } + if (Main.rand.NextBool()) + { + int i = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustType); + Main.dust[i].velocity.X *= 0.4f; + Main.dust[i].velocity.Y += Fired ? 0f : Projectile.velocity.Y * 0.5f; + } + + Projectile.ai[1]++; + Projectile.rotation += 0.1f; + if (Projectile.ai[1] >= 180f) + { + Projectile.ai[1] = 180f; + Projectile.velocity.Y += 0.2f; + } + if (Projectile.velocity.Y > 10f) + Projectile.velocity.Y = 10f; + + Point p = Projectile.Center.ToTileCoordinates(); + // Don't check out of bounds + if (p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) + return; + Tile placer = Main.tile[p.X, p.Y + 1]; + if (placer.HasTile && TileID.Sets.Platforms[placer.TileType] && Projectile.ai[1] >= 60f) + Projectile.Kill(); + + } + } + public class PolypSandBallGun : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallPolyp"; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => DustID.Sand; + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one has a small homing range and can go through platforms + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = true; + return true; + } + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = 1; + Projectile.Calamity().conditionalHomingRange = 160; + } + } + public class VolcanicSandBallGun : SandBall + { + public override string Texture => "CalamityMod/Projectiles/Typeless/SandBallVolcanic"; + public override int TileType => ModContent.TileType(); + public override int ItemType => ModContent.ItemType(); + public override int DustType => -1; + + //Doze: I'm giving our sandgun sands actual special effects because it's more interesting + //This one fires a shotgun of mini sands, but every sand deals less damage + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.localNPCHitCooldown = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.usesIDStaticNPCImmunity = false; + } + public override bool PreAI() + { + if (Projectile.ai[2] == 1) + { + if (Projectile.ai[1] == 0) + { + Projectile.scale = 0.75f; + Projectile.penetrate = 1; + Projectile.timeLeft = 30; + } + } else + { + if (Projectile.ai[1] == 0) + { + if (Main.myPlayer == Projectile.owner) + for (var i = 0; i < 5; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity.RotatedByRandom(0.5f) * 0.75f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, ai2: 1); + Projectile.damage = (int)(Projectile.damage * 0.5f); + + } + } + return base.PreAI(); + } + public override bool PreKill(int timeLeft) + { + if (Projectile.ai[2] == 1) //Baby sands should always vanish without placing blocks + Projectile.active = false; + return Projectile.active; + } } // All the setups go here to prevent mass blocks of copypasting @@ -59,12 +301,19 @@ namespace CalamityMod.Projectiles.Typeless // Associated dust type public virtual int DustType => DustID.Sand; + /// + /// Whether the sandball should drop as an item on death instead of placing a tile. This is for non-falling sands in sandgun. + /// + public virtual bool DropAsItem => false; + public override void SetDefaults() { Projectile.knockBack = 6f; Projectile.width = Projectile.height = 10; Projectile.friendly = true; Projectile.penetrate = -1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; if (Fired) { @@ -78,7 +327,7 @@ namespace CalamityMod.Projectiles.Typeless // Using clones will not allow for custom dust types sadly public override void AI() { - if (Main.rand.NextBool()) + if (Main.rand.NextBool() && DustType >= 0) { int i = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustType); Main.dust[i].velocity.X *= 0.4f; @@ -94,22 +343,27 @@ namespace CalamityMod.Projectiles.Typeless } if (Projectile.velocity.Y > 10f) Projectile.velocity.Y = 10f; + } - Point p = Projectile.Center.ToTileCoordinates(); - // Don't check out of bounds - if (p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) - return; - Tile placer = Main.tile[p.X, p.Y + 1]; - if (placer.HasTile && TileID.Sets.Platforms[placer.TileType] && Projectile.ai[1] >= 60f) - Projectile.Kill(); + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = false; + return base.TileCollideStyle(ref width, ref height, ref fallThrough, ref hitboxCenterFrac); } public override void OnKill(int timeLeft) { Point p = Projectile.Center.ToTileCoordinates(); - // If the sand is dying outside the world border, cancel placing sand. - if (p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) + // If the sand is dying outside the world border, or having used all of it's pierce, cancel placing sand. + if ( p.X < 0 || p.X >= Main.maxTilesX || p.Y < 0 || p.Y >= Main.maxTilesY) return; + + if (DropAsItem) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + Item.NewItem(Projectile.GetSource_DropAsItem(), Projectile.position, Projectile.width, Projectile.height, ItemType); + return; + } Tile placer = Main.tile[p.X, p.Y]; // If the sand hit a half brick, but was mostly going downwards (at a lower than 45 degree angle), then stack atop the half brick. @@ -152,7 +406,8 @@ namespace CalamityMod.Projectiles.Typeless } // Give the block back if you literally can't place it else - Item.NewItem(Projectile.GetSource_DropAsItem(), Projectile.position, Projectile.width, Projectile.height, ItemType); + if (Main.netMode != NetmodeID.MultiplayerClient) + Item.NewItem(Projectile.GetSource_DropAsItem(), Projectile.position, Projectile.width, Projectile.height, ItemType); } } } diff --git a/Projectiles/Typeless/SandBallDune.png b/Projectiles/Typeless/SandBallDune.png new file mode 100644 index 0000000000..15c62d95a8 Binary files /dev/null and b/Projectiles/Typeless/SandBallDune.png differ diff --git a/Projectiles/Typeless/SandBallPolyp.png b/Projectiles/Typeless/SandBallPolyp.png new file mode 100644 index 0000000000..531e9d5fc8 Binary files /dev/null and b/Projectiles/Typeless/SandBallPolyp.png differ diff --git a/Projectiles/Typeless/SandBallVolcanic.png b/Projectiles/Typeless/SandBallVolcanic.png new file mode 100644 index 0000000000..8b5fa1bb6d Binary files /dev/null and b/Projectiles/Typeless/SandBallVolcanic.png differ diff --git a/Projectiles/Typeless/SandCloakVeil.cs b/Projectiles/Typeless/SandCloakVeil.cs index f31fb59353..83fe0d5eb8 100644 --- a/Projectiles/Typeless/SandCloakVeil.cs +++ b/Projectiles/Typeless/SandCloakVeil.cs @@ -1,6 +1,5 @@ using CalamityMod.DataStructures; using CalamityMod.Items.Accessories; -using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -39,7 +38,7 @@ namespace CalamityMod.Projectiles.Typeless if (posDiff.Length() <= Radius) { BuffedPlayer.Calamity().getSandCloakAccelBoost = true; - BuffedPlayer.statDefense += 10; + BuffedPlayer.statDefense += SandCloak.SandVeilDefenseBoost; } else BuffedPlayer.Calamity().getSandCloakAccelBoost = false; diff --git a/Projectiles/Typeless/ScionsCurioMini.cs b/Projectiles/Typeless/ScionsCurioMini.cs new file mode 100644 index 0000000000..0aaed82961 --- /dev/null +++ b/Projectiles/Typeless/ScionsCurioMini.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; +using CalamityMod.Items.Accessories; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class ScionsCurioMini : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public Player Owner => Main.player[Projectile.owner]; + public Color usedColor = Color.Chartreuse; + public ref float time => ref Projectile.ai[0]; + public ref float attackTimer => ref Projectile.ai[1]; + public ref float idleTimer => ref Projectile.localAI[0]; + + public float fxFade = 0; // The glow visuals multiplier + public float followSpeed = 12; // The speed it follows you, lower is faster + public float lerpDir = 0; + public float facing = 0; + public Vector2 savedPos; + public bool sharingSwineSecrets => idleTimer >= idleMax; + public int swineSecretTimer = 0; + public int swineText = 1; + public float actionSpeed = 1; + public int chosenSecret = 0; + public int idleMax = 10800; // 3 minutes + Vector2 goalPosition; + public List listNumbers = new List(); + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 38; + Projectile.ignoreWater = true; + Projectile.timeLeft = 300; + Projectile.tileCollide = false; + Projectile.friendly = true; + Projectile.penetrate = -1; + } + + public override void AI() + { + if (Main.zenithWorld) idleMax = 301; + float rate = Main.GlobalTimeWrappedHourly * 5; + List eColors = new List() + { + Color.Chartreuse, + Color.LimeGreen + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + usedColor = Color.Lerp(Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f), Color.White, 0.7f); + + float sine = (float)Math.Sin(time * 0.1f * actionSpeed / MathHelper.Pi); + float sine2 = (float)Math.Sin(time * 0.15f * actionSpeed / MathHelper.Pi); + + Vector2 baseDestination = Owner.Center - Vector2.UnitY * (20 + 5 * sine2) - Vector2.UnitX * 30 * lerpDir; + + if (Owner.Calamity().scionsCurioGotHit) + { + if (attackTimer == 0) + savedPos = baseDestination; + if (attackTimer == 30) + { + float blastScale = 1.6f; + for (int g = 0; g < 17; g++) + { + int DustID = ModContent.DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID); + dust.scale = Main.rand.NextFloat(1.1f, 1.35f) * blastScale; + dust.velocity = new Vector2(9, 9).RotatedByRandom(100) * blastScale * Main.rand.NextFloat(0.4f, 0.9f) + Vector2.UnitY * -10; + dust.noGravity = false; + dust.color = Main.rand.NextBool() ? Color.Green : Color.Chartreuse; + dust.fadeIn = Main.rand.NextFloat(0.2f, 2f); + } + Particle blastvfx = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Chartreuse * 0.9f, "CalamityMod/Particles/ShineExplosion1", Vector2.One, Main.rand.NextFloat(-10, 10), 0.05f * blastScale, 0.15f * blastScale, 10, true); + GeneralParticleHandler.SpawnParticle(blastvfx); + SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Volume = 0.5f * blastScale, Pitch = Main.rand.NextFloat(0.5f, 0.7f), MaxInstances = 6 }, Projectile.Center); + + // Create Blast + float blastSize = 115 * blastScale; + float minMultiplier = 0.5f; + int hitsToMinMult = 5; + int debuff = ModContent.BuffType(); + int debuffTime = 300; + Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), ScionsCurio.postHitDamage, 7, (Owner != null ? Owner.whoAmI : -1), blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff; + blast.localAI[1] = debuffTime; + blast.timeLeft = 15; + blast.DamageType = DamageClass.Ranged; + attackTimer = -1; + Owner.Calamity().scionsCurioGotHit = false; + } + baseDestination = savedPos + new Vector2(4, 4).RotatedBy(sine2 * 0.02f); + attackTimer++; + } + + facing = Math.Sign(Projectile.Center.X == Owner.Center.X ? Owner.direction : Projectile.Center.DirectionTo(Owner.Center).X); + + Vector2 speakingDestination = Owner.Center - Vector2.UnitY * (10 + 3 * sine2) + Vector2.UnitX * 45 * lerpDir; + if (time == 0) + goalPosition = baseDestination; + goalPosition = Vector2.Lerp(goalPosition, swineSecretTimer > 0 ? speakingDestination : baseDestination, 0.08f); + lerpDir = MathHelper.Lerp(Owner.direction, facing, 0.04f); + + Projectile.velocity = (goalPosition - Projectile.Center) / (followSpeed * (swineSecretTimer > 0 ? 0.5f : 1)); + + Projectile.rotation = 0.2f * sine; + + if (Owner.Calamity().scionsCurioVisuals) + Lighting.AddLight(Projectile.Center, usedColor.ToVector3() * 0.3f); + + // Swine Secrets + int textSpeed = 4; + if (swineSecretTimer > 0) + { + if (swineSecretTimer % textSpeed == 0 && swineSecretTimer > 30) + { + int originalLength = CalamityUtils.GetTextValue(("Misc.SwineSecret" + chosenSecret.ToString())).Length + 1; + string text = CalamityUtils.GetTextValue(("Misc.SwineSecret" + chosenSecret.ToString())); + int charstoRemove = (text.Length - (int)swineText); + if (charstoRemove > -1) + { + text = text.Remove(swineText, charstoRemove); + if (swineSecretTimer >= 2) + text = text.Remove(0, swineText - 1); + } + if (swineText <= originalLength) + swineText++; + float textSpacing = Utils.Remap(originalLength, 5, 190, 20, 9, true); + Vector2 position = Owner.Center - (Vector2.UnitX * originalLength * (textSpacing / 2)) + (Vector2.UnitX * originalLength * textSpacing / originalLength * swineText); + int letter = CombatText.NewText(new Rectangle((int)position.X, (int)position.Y, 1, 1), usedColor, text, false, false); + Main.combatText[letter].lifeTime = 100; + } + if (swineSecretTimer % 6 == 0 && swineSecretTimer > 30) + { + SoundStyle snort = new("CalamityMod/Sounds/Item/Swine", 2); + SoundEngine.PlaySound(snort with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.35f, 0.55f) }, Projectile.Center); + actionSpeed = Main.rand.NextFloat(0.5f, 1.5f); + } + swineSecretTimer--; + fxFade = MathHelper.Lerp(fxFade, 1, 0.08f); + if (swineSecretTimer == 0) + time = 120; + } + else + { + swineText = 1; + fxFade = MathHelper.Lerp(fxFade, 0, 0.08f); + } + + if (idleTimer % 90 == 0 && swineSecretTimer == 0 && idleTimer > idleMax - 300) + { + CombatText.NewText(Projectile.Hitbox, usedColor, CalamityUtils.GetTextValue("Misc.SwineSecret0"), false, true); + actionSpeed = 1.1f; + SoundStyle snort = new("CalamityMod/Sounds/Item/Swine", 2); + SoundEngine.PlaySound(snort with { Volume = 0.6f, Pitch = Main.rand.NextFloat(0.35f, 0.55f) }, Projectile.Center); + } + + + actionSpeed = MathHelper.Lerp(actionSpeed, 1, 0.08f); + if (Owner.Calamity().scionsCurio) + Projectile.timeLeft++; + else + Projectile.Kill(); + if (Owner.dead) + Projectile.Kill(); + + time++; + if (sharingSwineSecrets && swineSecretTimer == 0) + { + int number = 0; + for (int i = 0; i < 1; i++) + { + int attemptNumber = Main.rand.Next(1, 40 + 1); + if (listNumbers.Contains(attemptNumber)) + { + if (listNumbers.Count >= 40) // Once all options have been exhausted, reset + { + listNumbers.Clear(); + listNumbers.Add(attemptNumber); + number = attemptNumber; + } + else + i--; + } + else + { + listNumbers.Add(attemptNumber); + number = attemptNumber; + } + } + chosenSecret = number; + int originalLength = CalamityUtils.GetTextValue(("Misc.SwineSecret" + chosenSecret.ToString())).Length; + swineSecretTimer = originalLength * textSpeed + 30; + idleTimer = idleMax - 300 - swineSecretTimer; + } + if (Owner.velocity.Length() < 2 && Owner.Calamity().scionsCurioVisuals) + idleTimer++; + else + { + idleTimer = 0; + } + } + public override bool PreDraw(ref Color lightColor) + { + Asset tex = ModContent.Request(Texture); + Texture2D bTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D cTexture = ModContent.Request("CalamityMod/Particles/HalfStar").Value; + Color drawColor = usedColor * Utils.GetLerpValue(0, 100, time, true); + Color bodyColor = lightColor; + float drawMult = 1; + float attackFade = (float)Math.Pow(1 + (float)Math.Pow(Utils.GetLerpValue(0, 30, attackTimer, true), 4), 3); + + Vector2 shake = Main.rand.NextVector2Circular((attackFade - 1) * 5, (attackFade - 1) * 5); + + for (int i = 0; i < 18; i++) // Backglow + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 18f).ToRotationVector2() * 2 * drawMult * attackFade; + if (attackFade > 1 || Owner.Calamity().scionsCurioVisuals) + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset + shake, null, Color.Lerp(drawColor, Color.Chartreuse, attackFade - 1) with { A = 0 } * 0.2f * drawMult, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, facing == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally); + } + + // Main body + if (Owner.Calamity().scionsCurioVisuals) + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + shake, null, Color.Lerp(bodyColor, Color.Chartreuse with { A = 0 }, attackFade - 1), Projectile.rotation, tex.Size() * 0.5f, new Vector2(1f, 1f) * Projectile.scale, facing == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally); + + // Eye Shine + for (int j = -1; j <= 1; j += 2) + { + for (int i = -4; i <= 4; i++) + { + Vector2 pos = (Vector2.UnitX * 3 * facing + Vector2.UnitY * -2).RotatedBy(Projectile.rotation); + float scale = 1; + if (i == 0) i++; + if (i > 0) + { + scale = 0.9f; + pos = (Vector2.UnitX * 10 * facing + Vector2.UnitY * -2).RotatedBy(Projectile.rotation); + } + Main.EntitySpriteDraw(cTexture, Projectile.Center - Main.screenPosition + pos + shake, null, Color.Lerp(Color.Red, Color.White, Math.Abs(i) * 0.05f) with { A = 0 } * 0.7f * fxFade, Projectile.rotation + (j == -1 ? MathHelper.PiOver2 : 0), cTexture.Size() * 0.5f, new Vector2(2f - 0.1f * Math.Abs(i), 1f + 0.4f * Math.Abs(i)) * Projectile.scale * 0.35f * scale * Main.rand.NextFloat(0.65f, 1.25f), SpriteEffects.None); + } + } + return false; + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Typeless/ScionsCurioMini.png b/Projectiles/Typeless/ScionsCurioMini.png new file mode 100644 index 0000000000..cd143eae5a Binary files /dev/null and b/Projectiles/Typeless/ScionsCurioMini.png differ diff --git a/Projectiles/Typeless/ShadeNimbusSpawner.cs b/Projectiles/Typeless/ShadeNimbusSpawner.cs index 2217a60dd5..a1fd3ff705 100644 --- a/Projectiles/Typeless/ShadeNimbusSpawner.cs +++ b/Projectiles/Typeless/ShadeNimbusSpawner.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -47,7 +46,7 @@ namespace CalamityMod.Projectiles.Typeless // Number of clouds and their damage scale based on what accessory in the upgrade path triggered it (damage is set when the spawner is created) if (Main.myPlayer == Projectile.owner) { - int cloudAmt = EffectStrength == 3f ? 11 : EffectStrength == 2f ? 7 : 5; + int cloudAmt = EffectStrength == 3f ? 5 : EffectStrength == 2f ? 3 : 2; for (int c = -(cloudAmt - 1) / 2; c <= (cloudAmt - 1) / 2; c++) { Vector2 cloudVelocity = c == 0 ? Vector2.Zero : Vector2.UnitX.RotatedByRandom(MathHelper.Pi / 72f) * Main.rand.NextFloat(3f, 9.5f); diff --git a/Projectiles/Typeless/SkyFlareFriendly.cs b/Projectiles/Typeless/SkyFlareFriendly.cs index dac01d5b9a..58f6823a88 100644 --- a/Projectiles/Typeless/SkyFlareFriendly.cs +++ b/Projectiles/Typeless/SkyFlareFriendly.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; diff --git a/Projectiles/Typeless/StandingFire.cs b/Projectiles/Typeless/StandingFire.cs index 15aa36b3ff..b692380ee6 100644 --- a/Projectiles/Typeless/StandingFire.cs +++ b/Projectiles/Typeless/StandingFire.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.velocity.Y = Projectile.velocity.Y + 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; - if (Projectile.ai[1] == 0f && Projectile.type >= 326 && Projectile.type <= 328) + if (Projectile.ai[1] == 0f && Projectile.type >= ProjectileID.GreekFire1 && Projectile.type <= ProjectileID.GreekFire3) { Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item13, Projectile.position); diff --git a/Projectiles/Typeless/StarStruckWaterBottle.cs b/Projectiles/Typeless/StarStruckWaterBottle.cs index b201dfc760..808c0307ea 100644 --- a/Projectiles/Typeless/StarStruckWaterBottle.cs +++ b/Projectiles/Typeless/StarStruckWaterBottle.cs @@ -1,4 +1,5 @@ using CalamityMod.Dusts; +using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -12,6 +13,9 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Items/Weapons/Typeless/StarStruckWater"; + public static int ConversionType; + public override void SetStaticDefaults() => ConversionType = ModContent.GetInstance().Type; + public override void SetDefaults() { Projectile.width = 14; @@ -46,7 +50,12 @@ namespace CalamityMod.Projectiles.Typeless dust.velocity.X *= 1.5f; dust.velocity *= 3f; } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, 4f); + + if (Main.myPlayer == Projectile.owner) + { + Point tileCenter = Projectile.Center.ToTileCoordinates(); + WorldGen.Convert(tileCenter.X, tileCenter.Y, ConversionType); + } } } diff --git a/Projectiles/Typeless/StickyFeatherAero.cs b/Projectiles/Typeless/StickyFeatherAero.cs index 6da5082c5c..2bd8aeda1a 100644 --- a/Projectiles/Typeless/StickyFeatherAero.cs +++ b/Projectiles/Typeless/StickyFeatherAero.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Terraria; +using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -22,6 +21,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.alpha = 255; Projectile.aiStyle = ProjAIStyleID.Nail; AIType = ProjectileID.NailFriendly; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Typeless/StomperSlam.cs b/Projectiles/Typeless/StomperSlam.cs index 53cc78a957..7837d4b835 100644 --- a/Projectiles/Typeless/StomperSlam.cs +++ b/Projectiles/Typeless/StomperSlam.cs @@ -1,12 +1,9 @@ -using System; -using CalamityMod.Dusts; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless @@ -45,7 +42,7 @@ namespace CalamityMod.Projectiles.Typeless damageScaleFromFall = Projectile.ai[0] / 40; Projectile.damage = (int)(300f * damageScaleFromFall + 300f); - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/GravistarSlam") { Volume = 0.75f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/GravistarSlam") { Volume = 0.75f }, Projectile.Center); //Spawn particles, but also increase the count to fill more of the circle the bigger it is int particleCount = (int)(10 * scaleFromFall); diff --git a/Projectiles/Typeless/StratusBlackHole.cs b/Projectiles/Typeless/StratusBlackHole.cs new file mode 100644 index 0000000000..9c42012307 --- /dev/null +++ b/Projectiles/Typeless/StratusBlackHole.cs @@ -0,0 +1,194 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Weapons.Typeless; +using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Systems.Mechanic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class StratusBlackHole : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 6; + } + + public override void SetDefaults() + { + Projectile.width = 94; + Projectile.height = 94; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.DamageType = AverageDamageClass.Instance; + Projectile.MaxUpdates = 1; + Projectile.timeLeft = CalamityUtils.MinutesToFrames(10) * Projectile.MaxUpdates; + Projectile.localNPCHitCooldown = 30 * Projectile.MaxUpdates; + Projectile.aiStyle = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.Opacity = 0; + } + + public override void AI() + { + Projectile.velocity *= 0.975f; + Projectile.frameCounter++; + if (Projectile.frameCounter >= 5) + { + Projectile.frame--; + Projectile.frameCounter = 0; + } + if (Projectile.frame < 0) + { + Projectile.frame = Main.projFrames[Type] - 1; + } + if (Projectile.timeLeft < 30) + { + Projectile.Opacity = Projectile.timeLeft / 30f; + } + else if (Projectile.Opacity < 1) + { + Projectile.Opacity += 0.05f; + } + foreach (var player in Main.ActivePlayers) + { + if (player.Distance(Projectile.Center) <= 600 && player.miscCounter % 30 == 15) + { + player.Calamity().StratusStarburst++; + if (player.Calamity().StratusStarburst <= CalamityPlayer.MaxStratusStarburst) + player.Calamity().StarburstEntities.Add(new StarburstEntity(Projectile.Center)); + player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 180); + } + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return targetHitbox.IntersectsConeFastInaccurate(Projectile.Center, 600, 0, MathHelper.TwoPi); + } + static Texture2D _TransparentBloomTex; + + public static Texture2D GetTransparentBloomTex() + { + if (_TransparentBloomTex == null) + { + _TransparentBloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + var BaseArray = new Color[_TransparentBloomTex.Width * _TransparentBloomTex.Height]; + var ColorArray = new Color[_TransparentBloomTex.Width * _TransparentBloomTex.Height]; + _TransparentBloomTex.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color((int)BaseArray[i].R, (int)BaseArray[i].R, (int)BaseArray[i].R, (int)BaseArray[i].R); + } + _TransparentBloomTex.SetData(ColorArray); + } + return _TransparentBloomTex; + } + public override bool PreDraw(ref Color lightColor) + { + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + + PixelationManager.AddPixelatedDrawer((matrix) => DrawAura(this, matrix), Enums.GeneralDrawLayer.BeforeAllTiles); + PixelationManager.AddPixelatedDrawer((matrix) => DrawSingularity(this, matrix), Enums.GeneralDrawLayer.AfterProjectiles); + PixelationManager.AddPixelatedDrawer((matrix) => DrawAuraOutside(this, matrix), Enums.GeneralDrawLayer.AfterEverything); + + + return false; + } + + + private static void DrawAuraOutside(StratusBlackHole mproj, Matrix matrix) + { + + Vector2 drawPosition = mproj.Projectile.Center - Main.screenPosition; + + //Draw the outer particles + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(0.1f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.1f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + Texture2D telegraphBase = ModContent.Request("CalamityMod/Particles/HigResThinCircle").Value; + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.SkyBlue * mproj.Projectile.Opacity * 0.75f, 0, telegraphBase.Size() / 2f, 1200f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + Main.spriteBatch.ExitShaderRegion(matrix: matrix); + } + private static void DrawAura(StratusBlackHole mproj, Matrix matrix) + { + + Vector2 drawPosition = mproj.Projectile.Center - Main.screenPosition; + #region AoE + //Draw the bloom circle + + Texture2D telegraphBase = GetTransparentBloomTex(); + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.DarkSlateBlue * 0.75f * mproj.Projectile.Opacity, 0, telegraphBase.Size() / 2f, 1200f * 1.25f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + + //Draw the inner particles + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(1f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.2f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoiseHighContrast"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + telegraphBase = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.SkyBlue * 0.5f * mproj.Projectile.Opacity, 0, telegraphBase.Size() / 2f, 1200f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + + + //Draw the outer particles + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(0.1f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.1f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + telegraphBase = ModContent.Request("CalamityMod/Particles/HighResFoggyCircleHardEdge").Value; + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.SkyBlue * mproj.Projectile.Opacity * 0.75f, 0, telegraphBase.Size() / 2f, 1200f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + Main.spriteBatch.ExitShaderRegion(matrix: matrix); + #endregion + + + } + + private static void DrawSingularity(StratusBlackHole mproj, Matrix matrix) + { + + Vector2 drawPosition = mproj.Projectile.Center - Main.screenPosition; + + #region Singularity + var telegraphBase = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(0.5f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.2f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/VoidGashes"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.Lerp(Color.DarkSlateBlue, Color.SkyBlue, 0.75f), 0.5f, telegraphBase.Size() / 2f, 84f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(0.5f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.2f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/VoidGashes"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + telegraphBase = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.Lerp(Color.DarkSlateBlue, Color.SkyBlue, 1f), 0, telegraphBase.Size() / 2f, 84f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + Main.spriteBatch.EnterShaderRegion(matrix: matrix); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseOpacity(0.25f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].UseSaturation(0.1f); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/VoidGashes"), 1); + GameShaders.Misc["CalamityMod:OtherworldBarrierDistortion"].Apply(); + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.Black, 1, telegraphBase.Size() / 2f, 72f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + Main.spriteBatch.ExitShaderRegion(matrix: matrix); + + telegraphBase = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + Main.EntitySpriteDraw(telegraphBase, drawPosition, null, Color.Black, 0, telegraphBase.Size() / 2f, 64f * mproj.Projectile.Opacity / telegraphBase.Width, 0, 0); + #endregion + } + } +} diff --git a/Projectiles/Typeless/StratusBlackHole.png b/Projectiles/Typeless/StratusBlackHole.png new file mode 100644 index 0000000000..e2b606b205 Binary files /dev/null and b/Projectiles/Typeless/StratusBlackHole.png differ diff --git a/Projectiles/Typeless/SuicideBomberDemon.cs b/Projectiles/Typeless/SuicideBomberDemon.cs index 06254b320c..5b3f1b9d7e 100644 --- a/Projectiles/Typeless/SuicideBomberDemon.cs +++ b/Projectiles/Typeless/SuicideBomberDemon.cs @@ -187,7 +187,7 @@ namespace CalamityMod.Projectiles.Typeless SoundEngine.PlaySound(SoundID.DD2_KoboldExplosion, Projectile.Center); for (int i = 0; i < 40; i++) { - Dust explosion = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 267); + Dust explosion = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowMk2); explosion.velocity = Main.rand.NextVector2Circular(4f, 4f); explosion.color = Color.Red; explosion.scale = 1.35f; @@ -215,9 +215,9 @@ namespace CalamityMod.Projectiles.Typeless else modifiers.SourceDamage.Flat += 360f; } - public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio); + public float FlameTrailWidthFunction(float completionRatio, Vector2 vertexPos) => MathHelper.SmoothStep(21f, 8f, completionRatio); - public Color FlameTrailColorFunction(float completionRatio) + public Color FlameTrailColorFunction(float completionRatio, Vector2 vertexPos) { float trailOpacity = Utils.GetLerpValue(0.8f, 0.27f, completionRatio, true) * Utils.GetLerpValue(0f, 0.067f, completionRatio, true); Color startingColor = Color.Lerp(Color.Cyan, Color.White, 0.4f); @@ -265,7 +265,7 @@ namespace CalamityMod.Projectiles.Typeless Vector2 trailOffset = Projectile.Size * 0.5f; trailOffset += (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 20f; - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FlameTrailWidthFunction, FlameTrailColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 61); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FlameTrailWidthFunction, FlameTrailColorFunction, (_,_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 61); } Main.spriteBatch.ExitShaderRegion(); diff --git a/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs b/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs index ae998e00f5..cbbd158e99 100644 --- a/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs +++ b/Projectiles/Typeless/SulphuricAcidBubbleFriendly.cs @@ -141,7 +141,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int k = 0; k < 15; k++) { - Dust dust2 = Dust.NewDustPerfect(Projectile.Center, 303, new Vector2(8, 8).RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.05f, 0.8f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, DustID.SteampunkSteam, new Vector2(8, 8).RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(0.05f, 0.8f)); dust2.scale = Main.rand.NextFloat(0.75f, 0.95f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.YellowGreen : Color.OliveDrab; diff --git a/Projectiles/Typeless/TatteredFairyDust.cs b/Projectiles/Typeless/TatteredFairyDust.cs index 9d243ee0e6..054c3c2aa8 100644 --- a/Projectiles/Typeless/TatteredFairyDust.cs +++ b/Projectiles/Typeless/TatteredFairyDust.cs @@ -12,11 +12,9 @@ namespace CalamityMod.Projectiles.Typeless public override void SetDefaults() { - Projectile.width = Projectile.height = 25; + Projectile.width = Projectile.height = 36; Projectile.friendly = true; - Projectile.DamageType = DamageClass.Generic; - Projectile.penetrate = 3; - Projectile.timeLeft = 150; + Projectile.timeLeft = 180; } public override void AI() @@ -29,6 +27,15 @@ namespace CalamityMod.Projectiles.Typeless Dust lightedDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.TintableDustLighted, Main.rand.NextFloat(0.1f), Main.rand.NextFloat(0.1f), 0, new Color(190, 3, 252)); lightedDust.noGravity = true; } + + if (Projectile.timeLeft < 170) + { + foreach (Player player in Main.ActivePlayers) + { + if (Vector2.Distance(player.Center, Projectile.Center) < 24f && player.wingTime > 0f) + player.wingTime -= 4f; + } + } } } } diff --git a/Projectiles/Typeless/TerminusHoldout.cs b/Projectiles/Typeless/TerminusHoldout.cs index 71e8385dd0..c444e4d74e 100644 --- a/Projectiles/Typeless/TerminusHoldout.cs +++ b/Projectiles/Typeless/TerminusHoldout.cs @@ -7,6 +7,7 @@ using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.GameContent.Events; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -94,13 +95,13 @@ namespace CalamityMod.Projectiles.Typeless float currentShakePower = MathHelper.Lerp(0.2f, 8f, Utils.GetLerpValue(Lifetime * 0.725f, Lifetime, Time, true)); currentShakePower *= 1f - Utils.GetLerpValue(1000f, 3100f, Main.LocalPlayer.Distance(Projectile.Center), true); - Main.LocalPlayer.Calamity().GeneralScreenShakePower = currentShakePower; + Main.LocalPlayer.SetScreenshake(currentShakePower); } public void CreateEffectsHandler() { SoundEngine.PlaySound(BossRushEvent.StartBuildupSound, Main.LocalPlayer.Center); - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 16f; + Main.LocalPlayer.SetScreenshake(16f); if (Main.myPlayer == Projectile.owner) Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner); } @@ -112,7 +113,7 @@ namespace CalamityMod.Projectiles.Typeless for (int i = 0; i < 20; i++) { - Dust paleMagic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(22f, 28f), 261); + Dust paleMagic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(22f, 28f), DustID.AncientLight); paleMagic.velocity = -Vector2.UnitY * Main.rand.NextFloat(1.8f, 3.2f); paleMagic.color = Color.White; paleMagic.scale = Main.rand.NextFloat(1.1f, 1.35f); @@ -134,7 +135,7 @@ namespace CalamityMod.Projectiles.Typeless Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Unit() * outwardness * Main.rand.NextFloat(0.75f, 1.1f); Vector2 dustVelocity = (Projectile.Center - spawnPosition) * 0.085f + Owner.velocity; - Dust paleMagic = Dust.NewDustPerfect(spawnPosition, 264); + Dust paleMagic = Dust.NewDustPerfect(spawnPosition, DustID.PortalBoltTrail); paleMagic.velocity = dustVelocity; paleMagic.scale = dustScale * Main.rand.NextFloat(0.75f, 1.15f); paleMagic.color = Color.Lerp(Color.LightCoral, Color.White, Time / Lifetime * Main.rand.NextFloat(0.65f, 1f)); diff --git a/Projectiles/Typeless/TeslaAura.cs b/Projectiles/Typeless/TeslaAura.cs index 26e2976644..0bbfbb4073 100644 --- a/Projectiles/Typeless/TeslaAura.cs +++ b/Projectiles/Typeless/TeslaAura.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.Potions; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.NPCs; using CalamityMod.NPCs.AcidRain; @@ -11,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class TeslaAura : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; @@ -66,19 +66,9 @@ namespace CalamityMod.Projectiles.Typeless { target.AddBuff(ModContent.BuffType(), 90); target.AddBuff(ModContent.BuffType(), 6); - - if (target.knockBackResist <= 0f) - return; - - // 07AUG2023: Ozzatron: TML was giving NaN knockback, probably due to 0 base knockback. Do not use hit.Knockback - if (CalamityGlobalNPC.ShouldAffectNPC(target)) - { - float knockbackMultiplier = MathHelper.Clamp(1f - target.knockBackResist, 0f, 1f); - Vector2 trueKnockback = target.Center - Projectile.Center; - trueKnockback.Normalize(); - target.velocity = trueKnockback * knockbackMultiplier; - } } + // CIT 2MAY2025: Replaced old manual knockback code with setting HitDirectionOverride + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.HitDirectionOverride = (target.Center.X > Projectile.Center.X).ToDirectionInt(); public override void OnHitPlayer(Player target, Player.HurtInfo info) { diff --git a/Projectiles/Typeless/TransformerBlob.cs b/Projectiles/Typeless/TransformerBlob.cs index 3184708412..a3fc1c1c55 100644 --- a/Projectiles/Typeless/TransformerBlob.cs +++ b/Projectiles/Typeless/TransformerBlob.cs @@ -2,6 +2,7 @@ using System.IO; using CalamityMod.CalPlayer; using CalamityMod.Dusts; +using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -9,10 +10,10 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ModLoader.IO; namespace CalamityMod.Projectiles.Typeless { + [PierceResistException] public class TransformerBlob : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; @@ -140,7 +141,7 @@ namespace CalamityMod.Projectiles.Typeless { Projectile.netUpdate = true; if (visuals) - Owner.Calamity().GeneralScreenShakePower = 3.5f; + Owner.SetScreenshake(3.5f); Projectile.numHits = 0; Projectile.velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * 12; Projectile.extraUpdates = 8; @@ -161,7 +162,7 @@ namespace CalamityMod.Projectiles.Typeless if (visuals) { SoundStyle fire = new("CalamityMod/Sounds/Item/OmicronBeam"); - SoundEngine.PlaySound(fire with { Volume = 0.3f, Pitch = Main.rand.NextFloat(0.3f, 0.5f) + Projectile.ai[1] * 0.015f, MaxInstances = -1 }, Projectile.Center); + SoundEngine.PlaySound(fire with { Volume = 0.3f, Pitch = Math.Clamp(Main.rand.NextFloat(0.1f, 0.2f) + Projectile.ai[1] * 0.02f, 0, 1), MaxInstances = 1 }, Projectile.Center); } } else if (poweredTimer == 0) diff --git a/Projectiles/Typeless/UrsaSlash.cs b/Projectiles/Typeless/UrsaSlash.cs index ac9e2c1012..0407ca2cce 100644 --- a/Projectiles/Typeless/UrsaSlash.cs +++ b/Projectiles/Typeless/UrsaSlash.cs @@ -1,12 +1,7 @@ -using System; -using CalamityMod.Dusts; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.Graphics.Shaders; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless diff --git a/Projectiles/Typeless/VictideBarrier.cs b/Projectiles/Typeless/VictideBarrier.cs new file mode 100644 index 0000000000..7ee97c9e22 --- /dev/null +++ b/Projectiles/Typeless/VictideBarrier.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Armor.Victide; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Projectiles.Typeless +{ + public class VictideBarrier : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static readonly SoundStyle ExplosionSound = new("CalamityMod/Sounds/Custom/BubblyBurst"); + + public static float ExplosionLifetime = 24f; + public static float MaxScale = 6f; + + public static float DashSpeed = 24f; // 24 tiles + public static float DashLifetime = 16f; + public static int DashSlamIFrames = 12; + private List NPCsHitBySlam = new List() { -1 }; + + public ref float ExplodeTimer => ref Projectile.ai[0]; + public ref float DashTimer => ref Projectile.ai[1]; + public ref float HealTimer => ref Projectile.ai[2]; + public Player Owner => Main.player[Projectile.owner]; + + public static Asset Shine; + public static Asset Explosion; + public override void Load() + { + Shine = ModContent.Request("CalamityMod/Particles/SemiCircularSmearSwipe"); + Explosion = ModContent.Request("CalamityMod/Particles/SoftRoundExplosion"); + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 20; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = (int)ExplosionLifetime; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Projectile.rotation = MathHelper.ToRadians(Main.GlobalTimeWrappedHourly * 36f); + + if (ExplodeTimer > 0f) + { + float scaleLevel = PiecewiseAnimation(ExplodeTimer / ExplosionLifetime, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Projectile.scale = MathHelper.Lerp(1f, MaxScale, scaleLevel); + Projectile.Opacity = MathF.Sin(MathHelper.PiOver2 + MathHelper.PiOver2 * ExplodeTimer / ExplosionLifetime); + + if (ExplodeTimer == 1f) + { + SoundEngine.PlaySound(ExplosionSound, Projectile.Center); + + for (int i = 0; i < 5; i++) + { + Vector2 velocity = (MathHelper.TwoPi * i / 5f).ToRotationVector2() * Main.rand.NextFloat(10f, 12f) * (i % 2 == 0 ? 0.88f : 1f); + Particle bub = new VelChangingSpark(Projectile.Center, velocity.RotatedByRandom(MathHelper.Pi / 10f), Vector2.UnitY * -6f, "CalamityMod/Particles/BloomRing", Main.rand.Next(36, 42 + 1), Main.rand.NextFloat(0.1f, 0.25f), Main.rand.NextBool(3) ? Color.HotPink : Color.Turquoise, Vector2.One, shrinkSpeed: 0.08f); + GeneralParticleHandler.SpawnParticle(bub); + } + } + + if (ExplodeTimer == 6f) + { + for (int i = 0; i < 8; i++) + { + Vector2 smokeVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(2.5f, 5.5f); + float smokeScale = Main.rand.NextFloat(1.6f, 2f); + Particle smoke = new HeavySmokeParticle(Projectile.Center, smokeVelocity, Color.PaleTurquoise, 18, smokeScale, 0.25f, Main.rand.NextFloat(-0.1f, 0.1f), true); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + ExplodeTimer++; + } + else if (DashTimer > 0f) + { + Owner.mount?.Dismount(Owner); + Owner.RemoveAllGrapplingHooks(); + + Owner.velocity = Projectile.velocity; + Owner.ChangeDir(Math.Sign(Projectile.velocity.X) <= 0 ? -1 : 1); + + // Move the player to the projectile, allowing them to bypass platforms (but not tiles) + Owner.Center = Projectile.Center; + + // Custom ram effect, similar to the one used in CalamityPlayerDashEffects + Rectangle hitArea = new Rectangle((int)(Owner.position.X + Owner.velocity.X * 0.5 - 4f), (int)(Owner.position.Y + Owner.velocity.Y * 0.5 - 4), Owner.width + 8, Owner.height + 8); + foreach (NPC n in Main.ActiveNPCs) + { + // Ignore critters with the Guide to Critter Companionship + if (Owner.dontHurtCritters && NPCID.Sets.CountsAsCritter[n.type]) + continue; + + if (!n.dontTakeDamage && !n.friendly && !NPCsHitBySlam.Contains(n.whoAmI)) + { + if (hitArea.Intersects(n.getRect()) && (n.noTileCollide || Owner.CanHit(n))) + { + Projectile.NewProjectile(Owner.GetSource_FromThis(), n.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, 0f, Owner.whoAmI, n.whoAmI); + Owner.GiveImmuneTimeForCollisionAttack(DashSlamIFrames); + NPCsHitBySlam.Add(n.whoAmI); + } + } + } + + // Dash trail effects + Color trailColor = Color.Lerp(Color.Cyan, Color.RoyalBlue, DashTimer / DashLifetime); + if (DashTimer % 2f == 1f) + { + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity * 2f, Projectile.velocity * 0.5f, "CalamityMod/Particles/ForwardSmear", false, 12, 0.2f, trailColor, new Vector2(1f, Main.rand.NextFloat(1.2f, 1.35f)), fadeIn: true, extraRotation: MathHelper.ToRadians(180f)); + GeneralParticleHandler.SpawnParticle(trail); + } + for (int direction = -1; direction <= 1; direction += 2) + { + Vector2 sidePos = Projectile.Center - Projectile.velocity * 2f + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2 * direction) * Utils.Remap(DashTimer, 1f, DashLifetime, 48f, 24f); + Particle sideTrail = new CustomSpark(sidePos, Projectile.velocity * 0.5f, "CalamityMod/Particles/BloomCircle", false, 18, 0.3f, trailColor * 0.6f, new Vector2(1f, 2.5f), shrinkSpeed: 0.2f); + GeneralParticleHandler.SpawnParticle(sideTrail); + } + + DashTimer++; + } + else + { + // If the barrier set isn't on, unceremoniously disappear + if (!Owner.Calamity().victideBarrierSet || Owner.dead || !Owner.active) + { + Projectile.Kill(); + Owner.Calamity().victideBarrierHeal = 0; + return; + } + // Set to dash if cooldown is detected and also create an explosion in its place + if (Owner.HasCooldown(WardingWave.ID)) + { + DashTimer++; + Projectile.damage = (int)Owner.GetBestClassDamage().ApplyTo(VictideHeadBarrier.BarrierDamage); + Owner.Calamity().victideBarrierHeal = 0; + if (Projectile.owner == Main.myPlayer) + { + // Set dash velocity + Projectile.velocity = Owner.SafeDirectionTo(Main.MouseWorld) * DashSpeed; + Projectile.tileCollide = true; + + // Spawn explosion + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.MountedCenter, Vector2.Zero, Type, Projectile.damage, VictideHeadBarrier.BarrierExplosionKB, Projectile.owner, 1f); + } + } + + if (Owner.Calamity().victideBarrierHeal > 0) + { + HealTimer++; + if (HealTimer % VictideHeadBarrier.BarrierFramesPerHeal == VictideHeadBarrier.BarrierFramesPerHeal - 1) + { + Owner.Calamity().victideBarrierHeal--; + Owner.HealPlayer(1); + } + } + else + HealTimer = 0f; + + Lighting.AddLight(Owner.MountedCenter, Color.White.ToVector3() * 0.5f); + Projectile.Center = Owner.MountedCenter; + Projectile.timeLeft = (int)DashLifetime; + } + } + + public override void OnKill(int timeLeft) + { + if (DashTimer > 0f) + Owner.velocity *= 0.5f; + } + + // Explosion collision only (dash has a custom ram logic check effect) + public override bool? CanDamage() => ExplodeTimer > 0f ? null : false; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20f * Projectile.scale, targetHitbox); + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.HitDirectionOverride = (Owner.Center.X < target.Center.X).ToDirectionInt(); + modifiers.SourceDamage *= Utils.Remap(Projectile.numHits, 0, 10, 1f, 0.1f, true); + } + + public override bool PreDraw(ref Color lightColor) + { + if (DashTimer > 0f) + return false; + + Texture2D explosionTex = Explosion.Value; + Color barrierColor = Main.hslToRgb(0.6f + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 2f), 1f, 0.5f); + + if (ExplodeTimer > 0f) + { + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + Vector2 explosionPos = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(explosionTex, explosionPos, null, barrierColor * Projectile.Opacity, Projectile.rotation, explosionTex.Size() * 0.5f, 0.02f * Projectile.scale, SpriteEffects.None); + Main.spriteBatch.ExitShaderRegion(); + return false; + } + + Vector2 drawPos = Owner.Center + Vector2.UnitY * Owner.gfxOffY - Main.screenPosition; + Texture2D circleBase = TextureAssets.Projectile[Type].Value; + Color contrastingColor = Main.hslToRgb(0.6f + 0.1f * MathF.Cos(Main.GlobalTimeWrappedHourly * 2f), 1f, 0.5f); + + // Silly solution to making a clean circle over the player + Main.spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseOpacity(0.5f); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseColor(barrierColor); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSecondaryColor(Color.Transparent); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].UseSaturation(0f); + GameShaders.Misc["CalamityMod:CircularAoETelegraph"].Apply(); + + Main.EntitySpriteDraw(circleBase, drawPos, null, Color.White, 0f, circleBase.Size() * 0.5f, 80f, SpriteEffects.None); + Main.spriteBatch.ExitShaderRegion(); + + // Give it additional texture + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + Main.EntitySpriteDraw(explosionTex, drawPos, null, contrastingColor * 0.3f, Projectile.rotation, explosionTex.Size() * 0.5f, 0.04f, SpriteEffects.None); + Texture2D shineTex = Shine.Value; + Main.EntitySpriteDraw(shineTex, drawPos, null, Color.HotPink * 0.5f, MathHelper.ToRadians(36f), shineTex.Size() * 0.5f, 0.45f, SpriteEffects.None); + Main.EntitySpriteDraw(shineTex, drawPos, null, Color.Orange * 0.3f, MathHelper.ToRadians(216f), shineTex.Size() * 0.5f, 0.55f, SpriteEffects.None); + Main.spriteBatch.ExitShaderRegion(); + return false; + } + } +} diff --git a/Projectiles/Typeless/VictideBobber.cs b/Projectiles/Typeless/VictideBobber.cs new file mode 100644 index 0000000000..71c2dedb7d --- /dev/null +++ b/Projectiles/Typeless/VictideBobber.cs @@ -0,0 +1,177 @@ +using System; +using CalamityMod.Items.SummonItems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class VictideBobber : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/Summon/CnidarianJellyfishOnTheString"; + + public Player Owner => Main.player[Projectile.owner]; + public ref float ParentProjectile => ref Projectile.ai[2]; + public Projectile Parent => Main.projectile[(int)ParentProjectile]; + + public int stuckTimer; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 20; + Projectile.aiStyle = ProjAIStyleID.Bobber; + Projectile.bobber = true; + } + + public override bool PreAI() + { + // Snap if the snail is shelled, or just nowhere to be found + if (!Parent.active || Owner.HeldItem.fishingPole <= 0 || Parent == null || Parent.frame < 6) + { + Projectile.Kill(); + return false; + } + return true; + } + + public override void AI() + { + // Automatic reeling + if (Projectile.ai[0] == 0f && Projectile.ai[1] < 0f && Main.rand.NextBool(40)) + { + Projectile.ai[0] = 1f; + Projectile.localAI[0] = 1f; + + // Consume bait as needed + int baitType = Owner.GetFishingConditions().BaitItemType; + int baitSlot = GetBaitSlot(Owner, baitType); + if (baitSlot != -1) + { + Item currentBait = Owner.inventory[baitSlot]; + bool consume = false; + + if (baitType == ItemID.TruffleWorm) + consume = true; + else if (baitType == ItemID.GoldWorm) + consume = Main.rand.NextBool(20); + else + { + float chanceMult = MathF.Max(1f, 1f + currentBait.bait / 6f); + if (Owner.accTackleBox) + chanceMult += 1f; + if (Main.rand.NextFloat() * chanceMult < 1f) + consume = true; + + // Junk (or Quest fish) default to no bait consumption + if (Projectile.localAI[1] > 0f) + { + Item dummyCatch = new Item(); + dummyCatch.SetDefaults((int)Projectile.localAI[1]); + if (dummyCatch.rare < ItemRarityID.White) + consume = false; + } + } + if (CombinedHooks.CanConsumeBait(Owner, currentBait).GetValueOrDefault(consume)) + { + if (currentBait.type == ItemID.LadyBug || currentBait.type == ItemID.GoldLadyBug) + NPC.LadyBugKilled(Owner.Center, currentBait.type == ItemID.GoldLadyBug); + + currentBait.stack--; + if (currentBait.stack <= 0) + currentBait.SetDefaults(); + } + } + + // Summon Duke Fishron as this code otherwise only runs on player rod usage + if (baitType == ItemID.TruffleWorm) + { + Projectile.ai[0] = 2f; + CalamityUtils.SpawnBossUsingItem(Owner, NPCID.DukeFishron); + } + // Line snapping behaviour + else if (!Owner.accFishingLine && Main.rand.NextBool(7)) + Projectile.ai[0] = 2f; + // Return back items + else if (Projectile.localAI[1] > 0f) + { + Projectile.ai[1] = Projectile.localAI[1]; + Projectile.localAI[1] = 0f; + } + // Spawn enemies + else if (Projectile.localAI[1] < 0f) + { + int spawnType = (int)(-Projectile.localAI[1]); + Point spawnPos = new Point((int)Projectile.position.X, (int)Projectile.position.Y); + if (spawnType == NPCID.BloodNautilus) + spawnPos.Y += 64; + + if (Main.netMode == NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.FishOutNPC, -1, -1, null, spawnPos.X / 16, spawnPos.Y / 16, spawnType); + else + { + Projectile.ai[0] = 2f; + NPC.NewNPC(new EntitySource_FishedOut(Owner), spawnPos.X, spawnPos.Y, spawnType); + + if (spawnType == NPCID.TownSlimeRed) + NPC.unlockedSlimeRedSpawn = true; + WorldGen.CheckAchievement_RealEstateAndTownSlimes(); + } + } + } + + // Anti-stuck auto reelback + if (Projectile.ai[0] == 0f && Projectile.localAI[1] == 0f && Projectile.velocity.Length() <= 0.2f) + { + stuckTimer++; + if (stuckTimer > 60) + Projectile.ai[0] = 1f; + } + } + + public static int GetBaitSlot(Player owner, int baitType) + { + // Ignore Bloodworm as the Old Duke summon method already manually consumes it + if (baitType == ModContent.ItemType()) + return -1; + + // Check ammo slots first + for (int i = 54; i < Main.InventorySlotsTotal; i++) + { + if (owner.inventory[i].type == baitType) + return i; + } + for (int j = 0; j < 54; j++) + { + if (owner.inventory[j].type == baitType) + return j; + } + return -1; + } + + // Anchor the bobber to the parent projectile, since the default is bound to the player + // Yes. This method is obsolete. No, there is no other way and I won't make another IL edit to remedy this fact. - Iris + public override void ModifyFishingLine(ref Vector2 lineOriginOffset, ref Color lineColor) + { + lineColor = Color.Cyan; + if (Parent.active) + { + Vector2 originalPos = Owner.MountedCenter + Vector2.UnitY * (Owner.gfxOffY - (Owner.gravDir == -1 ? 12f : 0f)); + lineOriginOffset = Parent.Center - originalPos + Vector2.UnitY * 13f; + + // How this is a thing is beyond me + lineOriginOffset.X -= 2f; + if (Owner.direction < 0) + lineOriginOffset.X += (Owner.MountedCenter.X - Parent.Center.X) * 2f; + } + } + + public override bool PreDrawExtras() + { + Lighting.AddLight(Projectile.Center, 0f, 0.2f, 0.2f); + return true; + } + } +} diff --git a/Projectiles/Typeless/VictideSeaSnail.cs b/Projectiles/Typeless/VictideSeaSnail.cs new file mode 100644 index 0000000000..3b8f61194e --- /dev/null +++ b/Projectiles/Typeless/VictideSeaSnail.cs @@ -0,0 +1,264 @@ +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class VictideSeaSnail : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public ref float DustTimer => ref Projectile.localAI[0]; + public ref float CollisionTimer => ref Projectile.ai[0]; + public ref float PlayerStandStillTimer => ref Projectile.ai[1]; + public ref float PlayerFishingTimer => ref Projectile.ai[2]; + + public const int FrameTime = 6; // Switches frame every 6 frames (10 FPS) + public const int PeekCooldown = 150; + + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer ModdedOwner => Owner.Calamity(); + + // Extra requirements so you don't break the bobber, or snail, or how would you fish underwater?? + public bool StandingStill => Owner.velocity.Length() == 0 && !Owner.pulley && !Owner.mount.Active && !Collision.DrownCollision(Owner.position, Owner.width, Owner.height, Owner.gravDir); + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 7; + } + + public override void SetDefaults() + { + Projectile.width = 38; + Projectile.height = 34; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + } + + public override void AI() + { + if (!ModdedOwner.victideSnailSet) + { + for (int d = 0; d < 25; d++) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.BubbleBurst_Purple, 0f, 0f, 0, default, 1f); + dust.velocity *= 2f; + dust.scale *= 1.15f; + } + Projectile.active = false; + return; + } + + if (Owner.dead) + ModdedOwner.victideSnail = false; + + if (ModdedOwner.victideSnail) + Projectile.timeLeft = 2; + + //Create a burst of dust as it gets created, teleported, or popped out + DustTimer++; + if (DustTimer <= 3) + { + for (int d = 0; d < 25; d++) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.BubbleBurst_Purple, 0f, 0f, 0, default, 1f); + dust.velocity *= 2f; + dust.scale *= 1.15f; + } + } + + // Small amount of light + Lighting.AddLight(Projectile.Center, 0.5f, 0.25f, 0.5f); + + if (StandingStill) + { + PlayerStandStillTimer++; + if (PlayerStandStillTimer >= PeekCooldown) + { + // Pop out the shell when ready. This give a slight velocity boost outwards + if (PlayerStandStillTimer == PeekCooldown) + { + DustTimer = 0f; + Projectile.velocity = new Vector2(Main.rand.NextFloat(2f, 3.6f) * Owner.direction, Main.rand.NextFloat(-4f, 0f)); + } + + // Fall down into position + Projectile.velocity *= 0.98f; + Projectile.velocity.X *= 0.9f; + Projectile.velocity.Y = Math.Min(Projectile.velocity.Y + 0.1f, 14f); + Projectile.tileCollide = true; + + bool? collide = CollidingWithLiquidOrPlatform(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); + if (collide.HasValue) + { + CollisionTimer++; + // Bobs up and down if collided with liquids + Projectile.velocity.Y = collide.Value ? MathF.Sin(CollisionTimer * 0.05f) * 0.25f : 0f; + } + + Projectile.rotation = Projectile.rotation.AngleTowards(0, MathHelper.PiOver4 * 0.14f); + + if (CollisionTimer > 0f) + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= FrameTime) + { + Projectile.frameCounter = 0; + Projectile.frame = Math.Min(6, Projectile.frame + 1); + } + } + } + else // keep this guy spinnin' + Projectile.rotation += MathHelper.PiOver4 * 0.2f; + } + else + { + // Slowly puts its head back into shell + if (Projectile.frame > 0) + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= FrameTime) + { + Projectile.frameCounter = 0; + Projectile.frame--; + } + + if (Projectile.frame == 0) + { + CollisionTimer = 0f; + PlayerStandStillTimer = 0f; + PlayerFishingTimer = 0f; + } + } + // Return to resting position once shelled again + else + { + Projectile.velocity = Vector2.Zero; + Projectile.tileCollide = false; + + Vector2 desiredPosition = Owner.Center + Vector2.UnitY * (Owner.gfxOffY - 60f) * Owner.gravDir; + //Round the result so it doesn't jitter. + desiredPosition = new Vector2((int)desiredPosition.X, (int)desiredPosition.Y); + Projectile.Center = Projectile.Center.MoveTowards(desiredPosition, 7f + Owner.velocity.Length()); + Projectile.rotation += MathHelper.PiOver4 * 0.2f; + } + } + + // Teleport and reset everything if too far away (this range is deliberately very short) + if (Vector2.Distance(Projectile.Center, Owner.Center) > 240f) + { + Projectile.Center = Owner.Center + Vector2.UnitY * (Owner.gfxOffY - 60f) * Owner.gravDir; + DustTimer = 0f; + CollisionTimer = 0f; + PlayerStandStillTimer = 0f; + PlayerFishingTimer = 0f; + Projectile.frame = 0; + return; + } + + // Only does fishing stuff when it's fully popped out + if (Projectile.frame == 6) + { + // Give the player a grace period upon any input with the fishing rod + // This means you can't just AFK with the fishing rod held + if (Owner.itemAnimation > 0 && Owner.HeldItem.fishingPole > 0) + PlayerFishingTimer = 600f; + else + PlayerFishingTimer = Math.Max(PlayerFishingTimer -1f, 0f); + + // Automatically casts bobbers one at a time + // This casts the same way the pole does to prevent position variance + int bobberType = ModContent.ProjectileType(); + if (Owner.ownedProjectileCounts[bobberType] < 1 && Owner.HeldItem.fishingPole > 0 && Projectile.owner == Main.myPlayer && PlayerFishingTimer > 0f) + { + SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); + + Vector2 velocity = Owner.SafeDirectionTo(Main.MouseWorld) * Owner.HeldItem.shootSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, bobberType, 0, 0f, Projectile.owner, ai2: Projectile.whoAmI); + } + } + } + + public static bool? CollidingWithLiquidOrPlatform(Vector2 Position, Vector2 Velocity, int Width, int Height) + { + Rectangle Hitbox = new Rectangle((int)Position.X, (int)Position.Y, Width, Height); + Rectangle ProjectedHitbox = new Rectangle((int)(Position.X + Velocity.X), (int)(Position.Y + Velocity.Y), Width, Height); + + int xMin = Utils.Clamp((int)(Position.X / 16f) - 1, 0, Main.maxTilesX - 1); + int xMax = Utils.Clamp((int)((Position.X + (float)Width) / 16f) + 2, 0, Main.maxTilesX - 1); + int yMin = Utils.Clamp((int)(Position.Y / 16f) - 1, 0, Main.maxTilesY - 1); + int yMax = Utils.Clamp((int)((Position.Y + (float)Height) / 16f) + 2, 0, Main.maxTilesY - 1); + for (int i = xMin; i < xMax; i++) + { + for (int j = yMin; j < yMax; j++) + { + Tile tile = Main.tile[i, j]; + if (tile == null) + return null; + + if (tile.HasTile && (Main.tileSolid[tile.TileType] || Main.tileSolidTop[tile.TileType])) + { + Rectangle Target = new Rectangle(i * 16, j * 16 , 16, 16); + if (Hitbox.Intersects(Target) || ProjectedHitbox.Intersects(Target)) + return false; + } + if (tile.LiquidAmount > 0 && !tile.HasTile) + { + float LiquidDepth = (256 - tile.LiquidAmount) / 16f; + Rectangle Target = new Rectangle(i * 16, j * 16 + (int)LiquidDepth, 16, 16 - (int)LiquidDepth); + if (Hitbox.Intersects(Target)) + return true; + } + } + } + return null; + } + + public override bool? CanDamage() => false; + + public override void OnKill(int timeLeft) + { + for (int d = 0; d < 45; d++) + { + Dust dust = Dust.NewDustDirect(new Vector2(Projectile.position.X, Projectile.position.Y + 16f), Projectile.width, Projectile.height - 16, DustID.BubbleBurst_Purple, 0f, 0f, 0, default, 1f); + dust.velocity *= 2f; + dust.scale *= 1.15f; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + // Touches the ground + if (oldVelocity.Y >= 0) + CollisionTimer = 1f; + return false; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Rectangle frame = tex.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + bool CanPeekOut = PlayerStandStillTimer >= PeekCooldown || Projectile.frame > 0; + Vector2 origin = !CanPeekOut ? new Vector2(15, 23) : frame.Size() * 0.5f; + + // Look at the player's direction + SpriteEffects flip = Owner.direction < 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Main.EntitySpriteDraw(tex, Projectile.Center + Vector2.UnitY * 2f - Main.screenPosition, frame, lightColor, Projectile.rotation, origin, Projectile.scale, flip); + + // Fisbing Rod,,. + if (Owner.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + Texture2D rod = Terraria.GameContent.TextureAssets.Item[ModContent.ItemType()].Value; + Main.EntitySpriteDraw(rod, Projectile.Center - Main.screenPosition + Vector2.UnitX * Owner.direction * 30f, null, lightColor, 0f, rod.Size() * 0.5f, Projectile.scale, flip); + } + return false; + } + } +} diff --git a/Projectiles/Summon/VictideSeaSnail.png b/Projectiles/Typeless/VictideSeaSnail.png similarity index 100% rename from Projectiles/Summon/VictideSeaSnail.png rename to Projectiles/Typeless/VictideSeaSnail.png diff --git a/Projectiles/Typeless/VictideSpirit.cs b/Projectiles/Typeless/VictideSpirit.cs new file mode 100644 index 0000000000..6b64564581 --- /dev/null +++ b/Projectiles/Typeless/VictideSpirit.cs @@ -0,0 +1,320 @@ +using CalamityMod.Cooldowns; +using CalamityMod.Dusts; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Armor.Victide; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class VictideSpirit : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + + public static Asset SpiritGlow; + + public ref float SubmergedTimer => ref Projectile.ai[0]; + public ref float DustCounter => ref Projectile.ai[1]; + + public override void Load() => SpiritGlow = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 20; + Projectile.height = 42; + Projectile.friendly = true; + Projectile.tileCollide = false; + } + + public override void OnSpawn(IEntitySource source) + { + Projectile.rotation = MathHelper.PiOver2; + for (int i = 0; i < Projectile.oldPos.Length; i++) + Projectile.oldRot[i] = MathHelper.PiOver2; + + for (int i = 0; i < 3; i++) + { + Color squareColor = Color.Lerp(Color.Cyan, Color.RoyalBlue, i * 0.5f) * 0.6f; + float squareScale = 0.6f + i * 0.2f; + float squareRot = (i % 2 == 0 ? MathHelper.PiOver4 : 0f); + Particle square = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/GlowSquareParticleThick", false, 18, squareScale, squareColor, Vector2.One, true, true, squareRot, true, glowOpacity: 0.5f, glowCenterScale: squareScale * 1.15f); + GeneralParticleHandler.SpawnParticle(square); + } + } + + public override void AI() + { + if (Main.myPlayer == Projectile.owner) + { + // Validate existence + bool hasCD = Owner.Calamity().cooldowns.TryGetValue(BubblyBurrow.ID, out CooldownInstance cd); + if (!hasCD) + { + Owner.AddCooldown(BubblyBurrow.ID, VictideHeadBurrow.BurrowCooldown); + Projectile.Kill(); + return; + } + else if (!Owner.Calamity().victideBurrowSet) + { + cd.timeLeft = VictideHeadBurrow.BurrowCooldown; + Projectile.Kill(); + return; + } + else if (cd.timeLeft <= VictideHeadBurrow.BurrowCooldown) + { + Projectile.Kill(); + return; + } + // Shimmer interaction (Immediately ends if Chromatic Cloak isn't active) + else if (Owner.shimmering) + { + cd.timeLeft = VictideHeadBurrow.BurrowCooldown; + Projectile.Kill(); + return; + } + Projectile.timeLeft = cd.timeLeft - VictideHeadBurrow.BurrowCooldown; + + #region Movement and Controls + float MaxSpeed = Collision.DrownCollision(Projectile.Center - Vector2.One, 2, 2, Owner.gravDir) ? VictideHeadBurrow.SubmergedBurrowSpeed : VictideHeadBurrow.BaseBurrowSpeed; + // Controlling both opposite movement keys brings you to a near immediate stop (faster deceleration than just releasing both buttons) + // Turnaround acceleration is also twice as fast to aid smoothness of movement + if (Owner.controlLeft && Owner.controlRight) + Projectile.velocity.X *= 0.7f; + else if (Owner.controlLeft) + { + if (Projectile.velocity.X < -MaxSpeed) + { + Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, MaxSpeed, 0.05f); + if (Projectile.velocity.X > -MaxSpeed - 0.01f) + Projectile.velocity.X = -MaxSpeed; + } + else if (Projectile.velocity.X > 0f) + Projectile.velocity.X -= VictideHeadBurrow.BaseAcceleration * 2f; + else + Projectile.velocity.X = MathF.Max(Projectile.velocity.X - VictideHeadBurrow.BaseAcceleration, -MaxSpeed); + } + else if (Owner.controlRight) + { + if (Projectile.velocity.X > MaxSpeed) + { + Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, MaxSpeed, 0.05f); + if (Projectile.velocity.X < MaxSpeed + 0.01f) + Projectile.velocity.X = MaxSpeed; + } + else if (Projectile.velocity.X < 0f) + Projectile.velocity.X += VictideHeadBurrow.BaseAcceleration * 2f; + else + Projectile.velocity.X = MathF.Min(Projectile.velocity.X + VictideHeadBurrow.BaseAcceleration, MaxSpeed); + } + else + Projectile.velocity.X *= 0.92f; + + if ((Owner.controlUp || Owner.controlJump) && Owner.controlDown) + Projectile.velocity.Y *= 0.7f; + else if (Owner.controlUp || Owner.controlJump) + { + if (Projectile.velocity.Y < -MaxSpeed) + { + Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, MaxSpeed, 0.05f); + if (Projectile.velocity.Y > -MaxSpeed - 0.01f) + Projectile.velocity.Y = -MaxSpeed; + } + else if (Projectile.velocity.Y > 0f) + Projectile.velocity.Y -= VictideHeadBurrow.BaseAcceleration * 2f; + else + Projectile.velocity.Y = MathF.Max(Projectile.velocity.Y - VictideHeadBurrow.BaseAcceleration, -MaxSpeed); + } + else if (Owner.controlDown) + { + if (Projectile.velocity.Y > MaxSpeed) + { + Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, MaxSpeed, 0.05f); + if (Projectile.velocity.Y < MaxSpeed + 0.01f) + Projectile.velocity.Y = MaxSpeed; + } + else if (Projectile.velocity.Y < 0f) + Projectile.velocity.Y += VictideHeadBurrow.BaseAcceleration * 2f; + else + Projectile.velocity.Y = MathF.Min(Projectile.velocity.Y + VictideHeadBurrow.BaseAcceleration, MaxSpeed); + } + else + Projectile.velocity.Y *= 0.92f; + + // Rotation is less sudden so that the visuals are smoother -- velocity is not affected so that it also plays natural + float idealRotation = (Projectile.velocity.Length() == 0f ? MathHelper.PiOver2 : Projectile.velocity.ToRotation()); + if (MathF.Abs(idealRotation - Projectile.rotation) < MathHelper.ToRadians(1f) || MathF.Abs(idealRotation - Projectile.rotation) > MathHelper.ToRadians(90f)) + Projectile.rotation = idealRotation; + else + Projectile.rotation = MathHelper.Lerp(Projectile.rotation, idealRotation, 0.25f); + #endregion + + #region Player Manipulation + // Actively remove mounts and hooks from the player + Owner.mount?.Dismount(Owner); + Owner.RemoveAllGrapplingHooks(); + + // Give immunity frames and kill suffocation + Owner.suffocateDelay = 0; + Owner.immune = true; + Owner.immuneNoBlink = true; + Owner.immuneTime = 4; + for (int k = 0; k < Owner.hurtCooldowns.Length; k++) + { + // Excluded explicitly-anti cheesed bosses + if (k == ImmunityCooldownID.Bosses) + continue; + + Owner.hurtCooldowns[k] = Owner.immuneTime; + } + + Owner.velocity = Projectile.velocity; + if (Owner.velocity.Y == 0f) + Owner.velocity.Y += 0.00001f; // Prevent sprint particles from appearing + Owner.ChangeDir((Projectile.velocity.X > 0).ToDirectionInt()); + Projectile.direction = Owner.direction; + + // Move the player to the projectile, allowing them to bypass all tiles + Owner.Center = Projectile.Center; + #endregion + } + + #region Visual and Sound Effects + if (Collision.DrownCollision(Projectile.Center - Vector2.One, 2, 2, Owner.gravDir)) + SubmergedTimer++; + else + SubmergedTimer = 0f; + + Color BubblyBlue = new Color(97, 200, 255); + Vector2 headPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * 8f; + Lighting.AddLight(headPosition, BubblyBlue.ToVector3() * Projectile.Opacity * (0.5f + 0.3f * Utils.GetLerpValue(0f, 60f, SubmergedTimer, true))); + + if (SubmergedTimer == 1f) + { + Particle ring = new DirectionalPulseRing(headPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * 0.4f, BubblyBlue, new Vector2(0.5f, 1f), Projectile.rotation, 0.95f, 0f, 30); + GeneralParticleHandler.SpawnParticle(ring); + } + + float lifetimeRatio = Projectile.timeLeft / (float)VictideHeadBurrow.BurrowCooldown; + if (Projectile.soundDelay <= 0) + { + Projectile.soundDelay = Main.rand.Next(20, 36) + (int)(lifetimeRatio * 30); + SoundEngine.PlaySound(Main.rand.NextBool() ? SoundID.ShimmerWeak1 : SoundID.ShimmerWeak2, Projectile.Center); + } + + if ((Main.rand.NextBool(4) || Projectile.velocity.Length() > 0.25f) && SubmergedTimer == 0f) + { + Particle foam = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.7f, "CalamityMod/Particles/WaterFoam", false, 9, 0.25f, Color.DeepSkyBlue, Vector2.One, extraRotation: Main.rand.NextFloat(0, MathHelper.TwoPi), shrinkSpeed: 1f); + GeneralParticleHandler.SpawnParticle(foam); + } + + DustCounter += Utils.Remap(Projectile.velocity.Length(), 0f, VictideHeadBurrow.BaseBurrowSpeed, 1f, 3f, true); + if (DustCounter >= 15f) + { + DustCounter = 0f; + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Projectile.rotation.ToRotationVector2().RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(-4.8f, -6f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.65f, 0.8f); + dust.color = Color.White; + dust.noLightEmittence = true; + } + } + #endregion + } + + public float JetstreamWidthFunction(float completionRatio, Vector2 vertexPos) => Utils.GetLerpValue(1f, 0.8f, completionRatio, true) * 3f; + public float SpiritWidthFunction(float completionRatio, Vector2 vertexPos) => MathF.Min(MathHelper.SmoothStep(64f, 8f, completionRatio), Utils.GetLerpValue(0f, 0.15f, completionRatio, true) * 60f); + + public Color InnerJetstreamColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.CornflowerBlue, new Color(169, 100, 237), MathF.Pow(completionRatio, 2.5f)) * Utils.GetLerpValue(1f, 0.6f, completionRatio, true) * 0.5f; + public Color OuterJetstreamColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.CornflowerBlue, new Color(100, 237, 237), MathF.Pow(completionRatio, 2.5f)) * Utils.GetLerpValue(1f, 0.6f, completionRatio, true) * 0.2f; + public Color SpiritColorFunction(float completionRatio, Vector2 vertexPos) => Color.Lerp(Color.Lerp(Color.White, Color.Cyan, 0.4f + completionRatio), Color.RoyalBlue, completionRatio) * Utils.GetLerpValue(0.8f, 0.54f, completionRatio, true); + + public override bool PreDraw(ref Color lightColor) + { + // Jetstream trails + for (int direction = -1; direction <= 1; direction += 2) + { + List trailPositionsInner = new List(); + List trailPositionsOuter = new List(); + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float mergeFactor = Utils.Remap(i, 0f, 8f, 0f, 1f, true); + + Vector2 trailPosInner = Projectile.Center - Projectile.oldRot[i].ToRotationVector2() * i * 8f; + float spreadLengthInner = 20f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Vector2 sinOffsetInner = (Vector2.UnitY * direction * MathF.Sin(i * MathHelper.Pi * 0.125f) * spreadLengthInner * mergeFactor).RotatedBy(Projectile.oldRot[i]); + trailPositionsInner.Add(trailPosInner + sinOffsetInner); + + Vector2 trailPosOuter = Projectile.Center - Projectile.oldRot[i].ToRotationVector2() * i * 12f; + float spreadLengthOuter = 32f * MathF.Sin(Main.GlobalTimeWrappedHourly * 2f); + Vector2 sinOffsetOuter = (Vector2.UnitY * direction * (6f + MathF.Sin(i * MathHelper.Pi * 0.035f) * spreadLengthOuter * mergeFactor)).RotatedBy(Projectile.oldRot[i]); + trailPositionsOuter.Add(trailPosOuter + sinOffsetOuter); + } + + PrimitiveRenderer.RenderTrail(trailPositionsInner, new(JetstreamWidthFunction, InnerJetstreamColorFunction), 20); + PrimitiveRenderer.RenderTrail(trailPositionsOuter, new(JetstreamWidthFunction, OuterJetstreamColorFunction), 20); + } + + // Oops all trails? + List spiritBodyPositions = new List(); + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + // 3 segments ahead so that it's a little offset forward + Vector2 spiritPos = Projectile.Center - Projectile.oldRot[i].ToRotationVector2() * (i - 3) * 8f; + spiritBodyPositions.Add(spiritPos); + } + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak")); + PrimitiveRenderer.RenderTrail(spiritBodyPositions, new(SpiritWidthFunction, SpiritColorFunction, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 60); + + // Glow pulses when the ability is about to run out + if (Projectile.timeLeft < 180) + { + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + Texture2D glow = SpiritGlow.Value; + Vector2 drawPos = Projectile.Center + Vector2.UnitY * Projectile.gfxOffY - Main.screenPosition; + Color glowColor = new Color(255, 170, 204) * (0.2f * MathF.Sin(Projectile.timeLeft * MathHelper.Pi * 0.25f) + Utils.Remap(Projectile.timeLeft, 180f, 0f, 0.2f, 0.6f, true)); + Main.EntitySpriteDraw(glow, drawPos, null, glowColor, Projectile.rotation, glow.Size() * 0.5f, new Vector2(0.6f, 0.5f), SpriteEffects.None); + Main.spriteBatch.ExitShaderRegion(); + } + return false; + } + + public override bool? CanDamage() => false; + + public override void OnKill(int timeLeft) + { + Owner.velocity *= 0.8f; + Owner.fullRotation = 0f; + Owner.fallStart = (int)(Owner.position.Y / 16f); // Triangle getting hit with the wrath of 2000 fall damage + + SoundEngine.PlaySound(SoundID.Drown, Projectile.Center); + for (int i = 0; i < 3; i++) + { + Color squareColor = Color.Lerp(Color.Cyan, new Color(255, 170, 204), i * 0.5f) * 0.6f; + float squareScale = 0.6f + i * 0.2f; + float squareRot = (i % 2 == 0 ? MathHelper.PiOver4 : 0f); + Particle square = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/GlowSquareParticleThick", false, 18, squareScale, squareColor, Vector2.One, true, true, squareRot, true, glowOpacity: 0.5f, glowCenterScale: squareScale * 1.15f); + GeneralParticleHandler.SpawnParticle(square); + } + } + } +} diff --git a/Projectiles/Typeless/VoidofExtinctionCrit.cs b/Projectiles/Typeless/VoidofExtinctionCrit.cs index 2a2eb12280..9f56c8349e 100644 --- a/Projectiles/Typeless/VoidofExtinctionCrit.cs +++ b/Projectiles/Typeless/VoidofExtinctionCrit.cs @@ -1,7 +1,5 @@ -using System; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.Graphics.Shaders; diff --git a/Projectiles/Typeless/WarbannerDamage.cs b/Projectiles/Typeless/WarbannerDamage.cs index 43622a0356..ca12ba043e 100644 --- a/Projectiles/Typeless/WarbannerDamage.cs +++ b/Projectiles/Typeless/WarbannerDamage.cs @@ -9,11 +9,18 @@ namespace CalamityMod.Projectiles.Typeless public class WarbannerDamage : DirectStrike, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; + public Player Owner => Main.player[Projectile.owner]; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 30); } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + bool crit = Main.rand.Next(0, 100 + 1) < Owner.GetTotalCritChance(Owner.GetBestClass()); + if (crit) + modifiers.SetCrit(); + } } } diff --git a/Projectiles/Typeless/WarbannerLight.cs b/Projectiles/Typeless/WarbannerLight.cs index dfdcde65c0..e2909c78cb 100644 --- a/Projectiles/Typeless/WarbannerLight.cs +++ b/Projectiles/Typeless/WarbannerLight.cs @@ -1,14 +1,10 @@ using System; using System.Collections.Generic; -using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using CalamityMod.Dusts; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Typeless diff --git a/Projectiles/Typeless/WaterConvertor.cs b/Projectiles/Typeless/WaterConvertor.cs deleted file mode 100644 index a45834c1e4..0000000000 --- a/Projectiles/Typeless/WaterConvertor.cs +++ /dev/null @@ -1,71 +0,0 @@ -using CalamityMod.World; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Typeless -{ - public class WaterConvertor : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Typeless"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.penetrate = -1; - Projectile.width = 160; - Projectile.height = 160; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.timeLeft = 10; - } - - public override void AI() - { - ConvertShit(Projectile); - } - - public override void PostAI() - { - ConvertShit(Projectile); - } - - public static void ConvertShit(Projectile projectile) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int x = (int)(projectile.Center.X / 16f); - int y = (int)(projectile.Center.Y / 16f); - for (int i = x - 5; i <= x + 5; i++) - { - for (int j = y - 5; j <= y + 5; j++) - { - if (projectile.ai[0] == 0f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Pure); - } - if (projectile.ai[0] == 1f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Corrupt); - } - if (projectile.ai[0] == 2f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Crimson); - } - if (projectile.ai[0] == 3f) - { - AstralBiome.ConvertFromAstral(i, j, ConvertType.Hallow); - } - if (projectile.ai[0] == 4f) - { - AstralBiome.ConvertToAstral(i, j); - NetMessage.SendTileSquare(-1, i, j, 1, 1); - } - } - } - } - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Typeless/WhiteLabSeeker.cs b/Projectiles/Typeless/WhiteLabSeeker.cs index e524e7f0e8..f5548fee9b 100644 --- a/Projectiles/Typeless/WhiteLabSeeker.cs +++ b/Projectiles/Typeless/WhiteLabSeeker.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), DustID.RainbowMk2); dust.color = Color.White; dust.scale = Main.rand.NextFloat(0.95f, 1.25f); dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); diff --git a/Projectiles/Typeless/WhitePearl.png b/Projectiles/Typeless/WhitePearl.png new file mode 100644 index 0000000000..a6492a5ea8 Binary files /dev/null and b/Projectiles/Typeless/WhitePearl.png differ diff --git a/Projectiles/Typeless/WulfrumDiggingTurtleProjectile.cs b/Projectiles/Typeless/WulfrumDiggingTurtleProjectile.cs index 616ca734da..a4679e0163 100644 --- a/Projectiles/Typeless/WulfrumDiggingTurtleProjectile.cs +++ b/Projectiles/Typeless/WulfrumDiggingTurtleProjectile.cs @@ -6,8 +6,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -49,7 +47,7 @@ namespace CalamityMod.Projectiles.Typeless public static int Lifetime = 400; public static int DigTime = 350; public static float DigSpeed = 1.5f; - public static int MaxPickPower = 160; + public static int MaxPickPower = 1000; public static float ClearSpaceDiagonal = 50; public override void SetDefaults() @@ -80,7 +78,7 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - Lighting.AddLight(Projectile.Center, Color.GreenYellow.ToVector3()); + Lighting.AddLight(Projectile.Center, Color.GreenYellow.ToVector3()*0.75f); //Idle chainsaw sounds if ((!SoundEngine.TryGetActiveSound(IdlingSoundSlot, out var idleSoundOut))) @@ -185,7 +183,7 @@ namespace CalamityMod.Projectiles.Typeless for (int i = 0; i < sparkCount; i++) { - Dust.NewDustPerfect(Projectile.Center, 226, Main.rand.NextVector2Circular(18f, 18f), Scale: Main.rand.NextFloat(0.4f, 1f)); + Dust.NewDustPerfect(Projectile.Center, DustID.Electric, Main.rand.NextVector2Circular(18f, 18f), Scale: Main.rand.NextFloat(0.4f, 1f)); } } diff --git a/Projectiles/Typeless/WulfrumDrillProj.cs b/Projectiles/Typeless/WulfrumDrillProj.cs index 0bc98e5c28..e40f380574 100644 --- a/Projectiles/Typeless/WulfrumDrillProj.cs +++ b/Projectiles/Typeless/WulfrumDrillProj.cs @@ -29,6 +29,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.ownerHitCheck = true; Projectile.DamageType = TrueMeleeNoSpeedDamageClass.Instance; Projectile.scale = 0.93f; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override bool ShouldUpdatePosition() => false; diff --git a/Projectiles/Typeless/WulfrumHook.cs b/Projectiles/Typeless/WulfrumHook.cs index 687ac2c0ca..426e0432ec 100644 --- a/Projectiles/Typeless/WulfrumHook.cs +++ b/Projectiles/Typeless/WulfrumHook.cs @@ -3,15 +3,10 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Materials; -using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -21,6 +16,7 @@ namespace CalamityMod.Projectiles.Typeless { public new string LocalizationCategory => "Projectiles.Typeless"; public Player Owner => Main.player[Projectile.owner]; + public int EquippedHook => Owner.miscEquips[4].type; public HookState State { @@ -37,7 +33,7 @@ namespace CalamityMod.Projectiles.Typeless Grappling = 3 //Making this value "3" is important here, as it makes it so that i can put this projectile in the player grapple list while also never having it considered as "grappling" (aka ai[0] = 2) } - public static float MaxReach = 600; + public float MaxReach => Owner.GetModPlayer().ActualMaxLength; public override void SetStaticDefaults() { @@ -58,6 +54,16 @@ namespace CalamityMod.Projectiles.Typeless Projectile.aiStyle = ProjAIStyleID.Hook; //The projectile uses entirely custom AI, but for some reason terraria's only way to distinguish what is and isnt a hook is its ai style. } + public override bool? CanUseGrapple(Player player) + { + if (player.TryGetModPlayer(out var mPlayer) && mPlayer.hookCooldown > 0) + { + return false; + } + + return base.CanUseGrapple(player); + } + public override bool? CanDamage() => false; public override bool PreAI() => false; @@ -104,7 +110,7 @@ namespace CalamityMod.Projectiles.Typeless else if (State == HookState.Retracting) { - Projectile.velocity = BetweenOwner.SafeNormalize(Vector2.One) * WulfrumPackPlayer.ReturnVelocity; + Projectile.velocity = BetweenOwner.SafeNormalize(Vector2.One) * Owner.GetModPlayer().ActualReturnVelocity; Projectile.Center += Vector2.UnitY * 0.5f; if (BetweenOwner.Length() < 25f) @@ -122,7 +128,7 @@ namespace CalamityMod.Projectiles.Typeless Point tilePos = Projectile.Center.ToTileCoordinates(); Tile tile = Main.tile[tilePos]; - if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo() || Owner.IsBlacklistedForGrappling(tilePos)) + if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo(EquippedHook == ItemID.SquirrelHook) || Owner.IsBlacklistedForGrappling(tilePos)) State = HookState.Retracting; Projectile.velocity = Vector2.Zero; @@ -158,13 +164,16 @@ namespace CalamityMod.Projectiles.Typeless Tile tile = Main.tile[tilePos]; - if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo() || Owner.IsBlacklistedForGrappling(tilePos)) - continue; - if (Main.myPlayer != Owner.whoAmI) + if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo(EquippedHook == ItemID.SquirrelHook && Projectile.Distance(Owner.Center) > 96) || Owner.IsBlacklistedForGrappling(tilePos)) continue; + /* + if (Main.myPlayer != Owner.whoAmI) + continue; + */ + OnGrapple(worldPos, x, y); - + break; } @@ -176,13 +185,20 @@ namespace CalamityMod.Projectiles.Typeless public void OnGrapple(Vector2 grapplePos, int x, int y) { WulfrumPackPlayer mp = Owner.GetModPlayer(); - //Clear previous grapple - if (Main.projectile[mp.Grapple].active && Main.projectile[mp.Grapple].ModProjectile is WulfrumHook hook && hook.State == WulfrumHook.HookState.Grappling) - Main.projectile[mp.Grapple].Kill(); + //Clear all grapples + Owner.ClearGrapplingBlacklist(); + Owner.grappling[0] = -1; + Owner.grapCount = 0; + for (int i = 0; i < 1000; i++) + { + if (Main.projectile[i].active && Main.projectile[i].owner == Owner.whoAmI && Main.projectile[i].aiStyle == ProjAIStyleID.Hook && !(Main.projectile[i].whoAmI == Projectile.whoAmI)) + Main.projectile[i].Kill(); + } //Hook onto the tile Projectile.velocity = Vector2.Zero; State = HookState.Grappling; + Projectile.Center = grapplePos + Vector2.One * 8f; //effects WorldGen.KillTile(x, y, fail: true, effectOnly: true); @@ -193,7 +209,11 @@ namespace CalamityMod.Projectiles.Typeless { Owner.grappling[Owner.grapCount] = Projectile.whoAmI; Owner.grapCount++; - //Owner.velocity = Vector2.Zero; + } + + if (EquippedHook == ItemID.QueenSlimeHook && Owner.whoAmI == Main.myPlayer) + { + Owner.DoQueenSlimeHookTeleport(grapplePos + new Vector2(-(Owner.Center - Projectile.Center).Length() * 0.75f, 0).RotatedBy(Projectile.DirectionTo(Owner.Center).ToRotation())); } mp.SwingLength = (Owner.Center - Projectile.Center).Length(); @@ -205,11 +225,14 @@ namespace CalamityMod.Projectiles.Typeless if (tileVisualHitbox.HasValue) Projectile.Center = tileVisualHitbox.Value.Center.ToVector2(); - Projectile.netUpdate = true; - NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, Owner.whoAmI); + if (Owner.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient) + { + Projectile.netUpdate = true; + NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, Owner.whoAmI); + WulfrumAcrobaticsSync.Send(Owner, mp, Projectile); + } } - public override void OnKill(int timeLeft) { if (Owner.grappling[0] == Projectile.whoAmI) @@ -219,19 +242,39 @@ namespace CalamityMod.Projectiles.Typeless } } - public float PrimWidthFunction(float completionRatio) + public float PrimWidthFunction(float completionRatio, Vector2 vertexPos) { return 1.6f; } - public Color PrimColorFunction(float completionRatio) + public Color PrimColorFunction(float completionRatio, Vector2 vertexPos) { - return Color.Lerp(Color.DeepSkyBlue, Color.GreenYellow, (float)Math.Pow(completionRatio, 1.5D)); + Color EndColor = Color.GreenYellow; + + switch (EquippedHook) + { + case ItemID.AntiGravityHook: + EndColor = Color.Aquamarine; + break; + case ItemID.QueenSlimeHook: + EndColor = Color.HotPink; + break; + case ItemID.SquirrelHook: + EndColor = Color.DarkOrange; + break; + case ItemID.StaticHook: + EndColor = Color.Silver; + break; + default: + break; + } + + return Color.Lerp(Color.DeepSkyBlue, EndColor, (float)Math.Pow(completionRatio, 1.5D)); } public override bool PreDraw(ref Color lightColor) { - Vector2[] segmentPositions = new Vector2[] {Projectile.Center, Owner.Center }; + Vector2[] segmentPositions = new Vector2[] { Projectile.Center, Owner.Center }; if (State == HookState.Grappling) segmentPositions = Owner.GetModPlayer().Segments.Select(x => x.position).ToArray(); diff --git a/Projectiles/Typeless/WulfrumLureSignal.cs b/Projectiles/Typeless/WulfrumLureSignal.cs index 4b103fbb0f..a906024224 100644 --- a/Projectiles/Typeless/WulfrumLureSignal.cs +++ b/Projectiles/Typeless/WulfrumLureSignal.cs @@ -1,14 +1,10 @@ -using System; +using System.Collections.Generic; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Tools; -using CalamityMod.NPCs.AstrumDeus; using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -19,6 +15,14 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static List LureSpawnPool => new List() + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + public ref float Time => ref Projectile.ai[0]; public override void SetDefaults() @@ -77,12 +81,12 @@ namespace CalamityMod.Projectiles.Typeless if (tries < 500) { - int npcToSpawn = Main.rand.NextBool() ? ModContent.NPCType() : Main.rand.NextBool() ? ModContent.NPCType() : ModContent.NPCType(); + int npcToSpawn = LureSpawnPool[Main.rand.Next(LureSpawnPool.Count)]; int index = NPC.NewNPC(Projectile.GetSource_FromAI(), (int)spawnPosition.X, (int)spawnPosition.Y, npcToSpawn, Target: player.whoAmI); for (int iy = 0; iy < 16; iy++) { - Dust zapDust = Dust.NewDustPerfect(spawnPosition + Main.rand.NextVector2Circular(1f, 1f) * 20f, 226, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(1f, 2.3f) - Vector2.UnitY * 6f); + Dust zapDust = Dust.NewDustPerfect(spawnPosition + Main.rand.NextVector2Circular(1f, 1f) * 20f, DustID.Electric, Main.rand.NextVector2Circular(1f, 1f) * Main.rand.NextFloat(1f, 2.3f) - Vector2.UnitY * 6f); zapDust.noGravity = true; } } @@ -95,7 +99,7 @@ namespace CalamityMod.Projectiles.Typeless for (int i = 0; i < dustCount; i++) { float angle = MathHelper.TwoPi * i / dustCount; - Dust dust = Dust.NewDustPerfect(Projectile.Center, 229); + Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Vortex); dust.position = Projectile.Center + angle.ToRotationVector2() * 300; dust.scale = 0.7f; dust.noGravity = true; diff --git a/Projectiles/Typeless/WulfrumScaffoldKitHoldout.cs b/Projectiles/Typeless/WulfrumScaffoldKitHoldout.cs index a4d86d4de0..7d8069dc33 100644 --- a/Projectiles/Typeless/WulfrumScaffoldKitHoldout.cs +++ b/Projectiles/Typeless/WulfrumScaffoldKitHoldout.cs @@ -220,7 +220,7 @@ namespace CalamityMod.Projectiles.Typeless for (int i = 0; i < 3; i++) { Vector2 dustpos = pos.ToWorldCoordinates(); - Dust.NewDustPerfect(dustpos, 83, Main.rand.NextVector2Circular(3f, 3f), Scale: Main.rand.NextFloat(0.4f, 0.7f)); + Dust.NewDustPerfect(dustpos, DustID.Tungsten, Main.rand.NextVector2Circular(3f, 3f), Scale: Main.rand.NextFloat(0.4f, 0.7f)); } TemporaryTile tile = new TemporaryTile(pos, this, WulfrumScaffoldKit.TileTime); @@ -232,7 +232,7 @@ namespace CalamityMod.Projectiles.Typeless if (tile.timeleft < WulfrumScaffoldKit.TileTime * 0.1f && Main.rand.NextBool(10)) { Vector2 dustpos = tile.position.ToWorldCoordinates(); - Dust.NewDustPerfect(dustpos, 226, Main.rand.NextVector2Circular(4f, 4f), Scale: Main.rand.NextFloat(0.4f, 1f)); + Dust.NewDustPerfect(dustpos, DustID.Electric, Main.rand.NextVector2Circular(4f, 4f), Scale: Main.rand.NextFloat(0.4f, 1f)); } } } diff --git a/Projectiles/Typeless/XykDeathAnim.cs b/Projectiles/Typeless/XykDeathAnim.cs index 96b2bb29b9..112b87b4c2 100644 --- a/Projectiles/Typeless/XykDeathAnim.cs +++ b/Projectiles/Typeless/XykDeathAnim.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Graphics.Metaballs; -using CalamityMod.Particles; -using CalamityMod.World; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -17,7 +12,7 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public ref float time => ref Projectile.ai[0]; public int endTime = 25; - public override string Texture => "CalamityMod/Items/LabFinders/RedSeekingMechanism"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { @@ -39,20 +34,7 @@ namespace CalamityMod.Projectiles.Typeless { Player Owner = Main.player[Projectile.owner]; bool Orange = Owner.Calamity().XykVisualsOrange; - Color effectColor = Orange ? Color.Gold : Color.DodgerBlue; - - float rate = Main.GlobalTimeWrappedHourly * 22; - List eColors = new List() - { - Orange ? Color.OrangeRed : Color.DodgerBlue, - Orange ? Color.Gold : Color.Cyan, - Orange ? Color.Orange : Color.RoyalBlue - }; - - int colorIndex = (int)(rate / 2 % eColors.Count); - Color currentColor = eColors[colorIndex]; - Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; - effectColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + Color effectColor = Owner.Calamity().XykFXColor; if (time == 0) { @@ -71,7 +53,7 @@ namespace CalamityMod.Projectiles.Typeless velOffset *= Main.rand.NextFloat(15, 30) * fade; Particle energy = new SparkParticle(Projectile.Center + velOffset * 2.5f, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, false, 14, Main.rand.NextFloat(1.1f, 1.25f) - 0.2f * fade, effectColor); GeneralParticleHandler.SpawnParticle(energy); - Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, 278, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + velOffset * 2.5f, DustID.FireworksRGB, -velOffset * Main.rand.NextFloat(0.08f, 0.12f) * 1.5f, 0, default, Main.rand.NextFloat(0.4f, 0.6f)); dust.noGravity = true; dust.color = effectColor; } diff --git a/Projectiles/Typeless/XykWings.cs b/Projectiles/Typeless/XykWings.cs new file mode 100644 index 0000000000..bdf7d597cd --- /dev/null +++ b/Projectiles/Typeless/XykWings.cs @@ -0,0 +1,330 @@ +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class XykWings : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer moddedOwner => Owner.Calamity(); + public Color drawColor => Owner.Calamity().XykFXColor; + public int time = 0; + public int flightTimer = 0; + public float wingFlapHeight = 0; + public Vector2 expectedWingPosition1; + public Vector2 expectedWingPosition2; + public Vector2 WingVel1; + public Vector2 WingVel2; + public float backWingRot = 0; + public int lastDir = 0; + public float spawnFade = 0; + public float spawnFadePow => (Projectile.ai[1] == 5 ? (float)Math.Pow(spawnFade, 1) : (float)Math.Pow(spawnFade, 4)); + public int deathFadeTimer = 0; + + public bool iAmTopWing = false; + public Vector2 playerCenterPoint; + public int groundTime = 0; + public int dashTimer = 0; + public bool doDashEffect = true; + public float dashfx = 0; + public int timeFalling = 0; + public bool BreakApart = false; + + public ref float wingNum => ref Projectile.ai[0]; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 1; + Projectile.ignoreWater = true; + Projectile.timeLeft = 300; + Projectile.tileCollide = false; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.scale = 0; + } + + public override void AI() + { + float intendedScale = 0.85f; + float spawnAnimTime = 12 + wingNum; + if (time == 0) + { + expectedWingPosition1 = Owner.Center; + expectedWingPosition2 = Owner.Center; + playerCenterPoint = Owner.MountedCenter; + } + if (time <= spawnAnimTime) + { + spawnFade = Utils.GetLerpValue(0, spawnAnimTime, time, true); + Projectile.scale = intendedScale * Math.Min(spawnFade + 0.5f, 1); + if (time == spawnAnimTime) + { + Projectile.scale = 1.6f; + } + } + else if (Projectile.ai[1] == 0) + Projectile.scale = MathHelper.Lerp(Projectile.scale, intendedScale, 0.08f); + + if (moddedOwner.XykVisualsBlue || moddedOwner.XykVisualsOrange) + Projectile.timeLeft++; + else + Projectile.Kill(); + if (Owner.dead) + Projectile.Kill(); + + playerCenterPoint = Owner.MountedCenter; + + if (Owner.wingTime == Owner.wingTimeMax && Owner.velocity.Y == 0 && Owner.dashDelay != -1) + groundTime++; + else + groundTime = 0; + if (((groundTime >= 180 || Owner.wingTime <= 0) && wingNum == checkActiveWings() - 1) || Projectile.ai[1] == 5) + { + if (Projectile.ai[1] == 0) + { + iAmTopWing = true; + foreach (Projectile p in Main.ActiveProjectiles) + if (p.type == ModContent.ProjectileType() && p.owner == Owner.whoAmI && p.ai[1] == 0) + p.ai[1] = 5; + return; + } + if (deathFadeTimer == 0) + BreakApart = Owner.wingTime <= 0; + if (BreakApart) + { + Projectile.extraUpdates = 1; + int startTime = (int)(6 * (wingNum + 1)); + if (deathFadeTimer == startTime) + { + WingVel1 = Vector2.UnitX * -Main.rand.NextFloat(4f, 7f) * lastDir + Vector2.UnitY.RotatedByRandom(0.3f) * -Main.rand.NextFloat(5, 7); + WingVel2 = Vector2.UnitX * Main.rand.NextFloat(4f, 7f) * lastDir + Vector2.UnitY.RotatedByRandom(0.3f) * -Main.rand.NextFloat(5, 7); + } + if (deathFadeTimer > startTime) + { + WingVel1.X *= 0.97f; + if (WingVel1.Y < 15) + WingVel1.Y += 0.2f; + if (WingVel1.Y < 5) + WingVel1.Y *= 0.97f; + WingVel2.X *= 0.97f; + if (WingVel2.Y < 15) + WingVel2.Y += 0.2f; + if (WingVel2.Y < 5) + WingVel2.Y *= 0.97f; + + expectedWingPosition1 += WingVel1; + expectedWingPosition2 += WingVel2; + + Projectile.rotation += 0.01f + wingNum * 0.005f; + backWingRot -= 0.01f + wingNum * 0.005f; + } + else + { + expectedWingPosition1 += Owner.velocity * 0.65f; + expectedWingPosition2 += Owner.velocity * 0.65f; + } + } + else + { + int startTime = (int)(2 * wingNum); + if (deathFadeTimer == startTime) + { + WingVel1 = (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 15; + WingVel2 = (backWingRot + MathHelper.PiOver2).ToRotationVector2() * 7; + } + if (deathFadeTimer > startTime) + { + expectedWingPosition1 += WingVel1; + expectedWingPosition2 += WingVel2; + WingVel1 *= 0.955f; + WingVel2 *= 0.955f; + } + else + { + expectedWingPosition1 += Owner.velocity * 0.85f; + expectedWingPosition2 += Owner.velocity * 0.85f; + } + } + + dashfx = MathHelper.Lerp(dashfx, 0, 0.07f); + deathFadeTimer++; + + int fadeTime = (BreakApart ? 90 : 20); + spawnFade = Utils.GetLerpValue(fadeTime, 0, deathFadeTimer, true); + Projectile.scale = intendedScale * spawnFadePow; + if (deathFadeTimer >= fadeTime) + { + Projectile.Kill(); + return; + } + return; + } + else + { + bool isFlying = Owner.controlJump; + bool isFalling = Owner.controlDown && !isFlying && Owner.velocity.Y > 0; + bool isUpBoosting = Owner.wingTime > 0 && Owner.controlJump && Owner.controlUp; + bool isHovering = Owner.wingTime > 0 && Owner.controlDown && Owner.controlJump && !isUpBoosting; + if (isFalling || timeFalling < 0) + timeFalling++; + else if (timeFalling > 0) + timeFalling -= 3; + float fallingLerp = (float)Math.Pow(Utils.GetLerpValue(0, 40, timeFalling, true), 3); + float topWingNum = (checkActiveWings() - 1); + + float sine = (float)Math.Sin((time * 0.35f * (isFalling ? 3 : (isHovering || isUpBoosting) ? 3.2f : isFlying ? 2f : 1) + wingNum * ((isHovering || isUpBoosting) ? 3f : 2f)) / MathHelper.Pi); + + if (Owner.dashDelay == -1 || isUpBoosting || isHovering || Owner.Calamity().adrenalineModeActive || Owner.Calamity().rageModeActive || isFalling && Owner.velocity.Y > 16) + { + dashfx = MathHelper.Lerp(dashfx, 1, 0.25f); + float bonusScale = 1; + if (Owner.Calamity().rageModeActive) + bonusScale += 0.25f; + if (Owner.Calamity().adrenalineModeActive) + bonusScale += 0.5f; + if (Projectile.scale < bonusScale) + Projectile.scale = bonusScale; + } + else + { + dashfx = MathHelper.Lerp(dashfx, 0, 0.03f); + if (dashfx > 0) + dashfx -= 0.01f; + else + dashfx = 0; + } + + float flapSpeed = MathHelper.Lerp(0.06f * (isHovering ? 2.5f : isFlying ? 2f : 1), 0.55f * (isHovering ? 2.5f : isFlying ? 2f : 1), (float)Math.Pow(Utils.GetLerpValue(-1, 1, sine), 3)); + + wingFlapHeight = MathHelper.Lerp(wingFlapHeight, sine, flapSpeed) * spawnFadePow; + + for (int i = -1; i <= 1; i += 2) + { + float dir = i * lastDir; + Vector2 flightMovement = Vector2.UnitY.RotatedBy(isFalling ? MathHelper.ToRadians(13) * dir * fallingLerp : 0) * (-15 * Projectile.scale + 10 * (isFalling ? 0.35f : isUpBoosting ? 5f : isHovering ? 1.5f : isFlying ? 2.5f : 1) * wingFlapHeight) * ((Owner.velocity.Y == 0) ? 0 : 1); + float wingPartDist = (1.6f / (checkActiveWings() + 1)) * wingNum * (isFalling ? 1 - 0.3f * fallingLerp : isHovering ? 0.5f : 1); + Vector2 destination = (playerCenterPoint - (Vector2.UnitX.RotatedBy(isFalling ? MathHelper.ToRadians(13) * dir * fallingLerp : 0) * (22 + 7 * wingFlapHeight * (i == -1 ? 0.5f : 1)) * Projectile.scale).RotatedBy((-0.8f + (isFalling ? 0.7f * fallingLerp : 0) + wingPartDist + (wingNum == topWingNum ? 0.1f : wingNum == 0 ? -0.1f : 0)) * dir) * dir + (Vector2.One * (isFlying ? 0 : 1)).RotatedBy((time * 0.12f + wingNum * 0.9f) * dir)) + flightMovement; + + float lerpSpeed = (1 + wingNum * (0.1f + 0.15f * fallingLerp) / (Owner.moveSpeed * 0.3f + 1)); + float spawnDistance = 150; + if (i == 1) + expectedWingPosition1 += ((destination + destination.DirectionFrom(playerCenterPoint) * Math.Max(1, spawnDistance * (1 - spawnFadePow))) - expectedWingPosition1) / lerpSpeed; + else + expectedWingPosition2 += ((destination + (Vector2.UnitX * -6f * lastDir) + destination.DirectionFrom(playerCenterPoint) * Math.Max(1, spawnDistance * (1 - spawnFadePow))) - expectedWingPosition2) / lerpSpeed; + } + Projectile.Center = Owner.Center; + + Projectile.rotation = expectedWingPosition1.DirectionFrom(playerCenterPoint).ToRotation() - MathHelper.PiOver2; + backWingRot = expectedWingPosition2.DirectionFrom(playerCenterPoint).ToRotation() - MathHelper.PiOver2; + + if (wingNum == 0) + Lighting.AddLight(Owner.Center, Color.Lerp(drawColor, Color.White, 0.5f).ToVector3() * 1.1f * spawnFadePow); + + if (dashfx > 0.3f && (wingNum == checkActiveWings() - 1 || wingNum == 0)) + { + for (int i = -2; i <= 2; i += 1) + { + if (i == 0) + i++; + + bool front = i > 0; + Vector2 pos1 = expectedWingPosition1 + (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * (45 + 5 * wingNum) * (Projectile.scale + 0.15f); + Vector2 pos2 = expectedWingPosition2 + (backWingRot + MathHelper.PiOver2).ToRotationVector2() * (15 + 3 * wingNum) * (Projectile.scale + 0.15f); + + if (Owner.Calamity().XykVisualsBlue) + { + bool circle = Main.rand.NextBool(3); + Dust dust = Dust.NewDustPerfect(front ? pos1 : pos2, circle ? ModContent.DustType() : ModContent.DustType(), Owner.velocity.RotatedByRandom(circle ? 0.5f : 0) * Main.rand.NextFloat(-0.5f, -0.2f) * dashfx); + dust.scale = Main.rand.NextFloat(1.3f, 1.4f) * (front ? 1 : 0.6f) * dashfx * (circle ? 0.6f : 1f) * (float)Math.Pow(Projectile.scale, 0.4f); + dust.noGravity = true; + dust.color = drawColor; + dust.noLightEmittence = true; + dust.fadeIn = 1.5f * (circle ? 0 : 1f); + } + else + { + bool square = Main.rand.NextBool(3); + Dust dust = Dust.NewDustPerfect(front ? pos1 : pos2, square ? ModContent.DustType() : ModContent.DustType(), Owner.velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(-0.5f, -0.2f) * dashfx); + dust.scale = Main.rand.NextFloat(0.8f, 1f) * (front ? 1 : 0.6f) * dashfx * (square ? 1 : 1.5f) * (float)Math.Pow(Projectile.scale, 0.4f); + dust.noGravity = true; + dust.color = drawColor; + dust.noLightEmittence = true; + dust.fadeIn = 0.1f * (square ? 1 : 3f); + } + } + } + + time++; + } + } + public override void PostDraw(Color lightColor) + { + if (!BreakApart) + lastDir = Owner.direction; + } + public override bool PreDraw(ref Color lightColor) + { + float topWingNum = (checkActiveWings() - 1); + float width = 1; + float height = 1; + Texture2D tex; + if (wingNum == 0) + tex = ModContent.Request("CalamityMod/Particles/XykWing2").Value; + else if (wingNum == topWingNum || iAmTopWing) + { + height = 1.5f; + tex = ModContent.Request("CalamityMod/Particles/XykWing1").Value; + } + else + { + width = 2; + height = 1f + 0.1f * wingNum; + tex = ModContent.Request("CalamityMod/Particles/XykWing3").Value; + } + + Texture2D glow = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + + Vector2 scale = new Vector2(width, height * spawnFadePow) * 0.12f * Projectile.scale; + Vector2 scaleBack = new Vector2(width * 1.5f, height * 0.7f * spawnFadePow) * 0.07f * Projectile.scale; + + if (dashfx > 0) + { + for (int i = 0; i < 4; i++) + { + Main.EntitySpriteDraw(glow, expectedWingPosition1 - Main.screenPosition, null, (i < 2 ? Color.White : drawColor) with { A = 0 } * 0.65f, Projectile.rotation + (i % 2 == 0 ? MathHelper.PiOver2 : 0) + MathHelper.PiOver4, glow.Size() * 0.5f, new Vector2(0.2f, 1.2f) * (i < 2 ? 0.7f : 1) * Projectile.scale * (Main.rand.NextFloat(0.25f, 0.35f) + 0.02f * wingNum) * (float)Math.Pow(dashfx, 7), SpriteEffects.None, 0); + Main.EntitySpriteDraw(glow, expectedWingPosition2 - Main.screenPosition, null, (i < 2 ? Color.White : drawColor) with { A = 0 } * 0.65f, backWingRot + (i % 2 == 0 ? MathHelper.PiOver2 : 0) + MathHelper.PiOver4, glow.Size() * 0.5f, new Vector2(0.2f, 1.2f) * (i < 2 ? 0.3f : 0.6f) * Projectile.scale * (Main.rand.NextFloat(0.25f, 0.35f) + 0.02f * wingNum) * (float)Math.Pow(dashfx, 7), SpriteEffects.None, 0); + } + int draws = 12; + for (int i = 0; i < draws; i++) + { + Vector2 addedPos = ((MathHelper.TwoPi * i / draws).ToRotationVector2() * 2.5f + Main.rand.NextVector2Circular(2, 2)) * dashfx; + Main.EntitySpriteDraw(tex, expectedWingPosition1 - Main.screenPosition + addedPos, null, drawColor with { A = 0 } * spawnFadePow * 0.3f * dashfx, Projectile.rotation, new Vector2(tex.Width * 0.5f, 0), scale, lastDir == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + + Main.EntitySpriteDraw(tex, expectedWingPosition2 - Main.screenPosition + addedPos, null, drawColor with { A = 0 } * spawnFadePow * 0.3f * dashfx, backWingRot, new Vector2(tex.Width * 0.5f, 0), scaleBack, lastDir == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + } + } + + Main.EntitySpriteDraw(tex, expectedWingPosition1 - Main.screenPosition, null, Color.Lerp(drawColor, Color.White, dashfx) with { A = 0 } * spawnFadePow * MathHelper.Lerp(1, 0.6f, dashfx), Projectile.rotation, new Vector2(tex.Width * 0.5f, 0), scale, lastDir == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + + Main.EntitySpriteDraw(tex, expectedWingPosition2 - Main.screenPosition, null, Color.Lerp(drawColor, Color.White, dashfx) with { A = 0 } * spawnFadePow * MathHelper.Lerp(1, 0.6f, dashfx), backWingRot, new Vector2(tex.Width * 0.5f, 0), scaleBack, lastDir == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + return false; + } + public int checkActiveWings() + { + int numOfActiveWings = 0; + foreach (Projectile p in Main.ActiveProjectiles) + if (p.type == ModContent.ProjectileType() && p.owner == Owner.whoAmI && p.ai[1] == 0) + numOfActiveWings++; + if (Projectile.ai[1] == 5) + numOfActiveWings = 7; + return numOfActiveWings; + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Typeless/YanmeisKnifeSlash.cs b/Projectiles/Typeless/YanmeisKnifeSlash.cs deleted file mode 100644 index 8d9ccaaf70..0000000000 --- a/Projectiles/Typeless/YanmeisKnifeSlash.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using CalamityMod.Buffs.StatBuffs; -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Items.Weapons.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Typeless -{ - public class YanmeisKnifeSlash : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Typeless"; - - public override void SetStaticDefaults() - { - Main.projFrames[Type] = 5; - } - - public override void SetDefaults() - { - Projectile.width = 180; - Projectile.height = 96; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.ownerHitCheck = true; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - - // Frames and crap - Projectile.frameCounter++; - if (Projectile.frameCounter % 7 == 0) - { - Projectile.frame++; - if (Projectile.frame >= Main.projFrames[Type]) - Projectile.Kill(); - } - - // Create idle light and dust. - Vector2 origin = Projectile.Center + Projectile.velocity * 3f; - Lighting.AddLight(origin, 0f, 1.5f, 0.1f); - - Vector2 playerRotatedPoint = player.RotatedRelativePoint(player.MountedCenter, true); - - // Rotation and directioning. - float velocityAngle = Projectile.velocity.ToRotation(); - Projectile.rotation = velocityAngle + (Projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; - Projectile.direction = (Math.Cos(velocityAngle) > 0).ToDirectionInt(); - - // Positioning close to the end of the player's arm. - Projectile.position = playerRotatedPoint - Projectile.Size * 0.5f + velocityAngle.ToRotationVector2() * 80f; - - // Sprite and player directioning. - Projectile.spriteDirection = Projectile.direction; - player.ChangeDir(Projectile.direction); - - // Prevents the projectile from dying - Projectile.timeLeft = 2; - - // Player item-based field manipulation. - player.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - player.heldProj = Projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - } - - public void HandleAttachmentMovement(Player player, Vector2 playerRotatedPoint) - { - float speed = 1f; - if (player.ActiveItem().shoot == Projectile.type) - { - speed = player.ActiveItem().shootSpeed * Projectile.scale; - } - - // 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction - Vector2 newVelocity = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * player.direction) * speed; - - // Sync if a velocity component changes. - if (Projectile.velocity.X != newVelocity.X || Projectile.velocity.Y != newVelocity.Y) - { - Projectile.netUpdate = true; - } - Projectile.velocity = newVelocity; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), YanmeisKnife.DebuffDuration); - if (!Main.dedServ) - { - for (int i = 0; i < 60; i++) - { - Dust dust = Dust.NewDustDirect(Main.player[Projectile.owner].position, Main.player[Projectile.owner].width, Main.player[Projectile.owner].height, DustID.RainbowMk2); - dust.position.X += Main.rand.NextFloat(-16f, 16f); - dust.color = Main.hslToRgb(Main.rand.NextFloat(0.26f, 0.37f), 1f, 0.75f); - dust.velocity = Main.rand.NextVector2Circular(24f, 24f); - dust.scale = Main.rand.NextFloat(1.4f, 1.8f); - dust.noGravity = true; - } - } - if (Projectile.ai[0] == 0f) - { - SoundEngine.PlaySound(YanmeisKnife.HitSound, Projectile.position); - Projectile.ai[0] = 1f; - } - Main.player[Projectile.owner].AddBuff(ModContent.BuffType(), YanmeisKnife.BoostDuration); - } - public override Color? GetAlpha(Color lightColor) => new Color(0, 215, 0, 0); - } -} diff --git a/Projectiles/Typeless/YanmeisKnifeSlash.png b/Projectiles/Typeless/YanmeisKnifeSlash.png deleted file mode 100644 index e0b03d728c..0000000000 Binary files a/Projectiles/Typeless/YanmeisKnifeSlash.png and /dev/null differ diff --git a/Projectiles/Typeless/YellowLabSeeker.cs b/Projectiles/Typeless/YellowLabSeeker.cs index b2668fff1a..b0540f1754 100644 --- a/Projectiles/Typeless/YellowLabSeeker.cs +++ b/Projectiles/Typeless/YellowLabSeeker.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Typeless { for (int i = 0; i < 8; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(16f, 16f), DustID.RainbowMk2); dust.color = Color.Yellow; dust.scale = Main.rand.NextFloat(0.95f, 1.25f); dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); diff --git a/Projectiles/VanillaProjectileOverrides/ChlorophyteCrystalAI.cs b/Projectiles/VanillaProjectileOverrides/ChlorophyteCrystalAI.cs deleted file mode 100644 index dcc0ff7262..0000000000 --- a/Projectiles/VanillaProjectileOverrides/ChlorophyteCrystalAI.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using CalamityMod.Items.VanillaArmorChanges; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.VanillaProjectileOverrides -{ - public static class ChlorophyteCrystalAI - { - public static bool DoChlorophyteCrystalAI(Projectile projectile) - { - Player owner = Main.player[projectile.owner]; - ref float timer = ref projectile.ai[1]; - - timer++; - projectile.aiStyle = -1; - if (!owner.crystalLeaf) - { - projectile.Kill(); - return false; - } - - // Stay above the player. - projectile.Center = owner.Center + Vector2.UnitY * (owner.gfxOffY - 60f); - if (Main.player[projectile.owner].gravDir == -1f) - { - projectile.position.Y += 120f; - projectile.rotation = MathHelper.Pi; - } - else - projectile.rotation = 0f; - projectile.Center = projectile.Center.Floor(); - - // Disable hardcoded spaghetti that fires crystal shots in vanilla code. - owner.petalTimer = 2; - - // Have a periodically pulsing scale. - projectile.scale = MathHelper.Lerp(0.9f, 1.15f, (float)Math.Sin(timer / 27f) * 0.5f + 0.5f); - - // Emit life pulses periodically. - NPC potentialTarget = projectile.Center.ClosestNPCAt(560f, true, true); - bool ownerNotFullHealth = owner.statLife < owner.statLifeMax2; - bool willFirePulses = (potentialTarget is not null) || ownerNotFullHealth; - if (timer % ChlorophyteArmorSetChange.PulseReleaseRate == ChlorophyteArmorSetChange.PulseReleaseRate - 1f && willFirePulses) - { - if (Main.myPlayer == projectile.owner) - { - int pulseDamage = (int)owner.GetBestClassDamage().ApplyTo(ChlorophyteArmorSetChange.BaseDamageToEnemies); - - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ModContent.ProjectileType(), pulseDamage, 0f, projectile.owner); - } - } - - return false; - } - - public static void DoChlorophyteCrystalDrawing(Projectile projectile) - { - // Why doesn't this work? How does one access the texture path of a vanilla projectile? Left bugged for someone else to figure out :) - // It's me. I was that someone - Dominic - // TextureAssets is the answer, along with Main.instance.LoadProjectile(projID), to ensure that the texture is loaded into memory. - // In this instance, however, that should happen already on vanilla's end. - Texture2D texture = TextureAssets.Projectile[projectile.type].Value; - Vector2 drawPosition = projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() * 0.5f; - - float backglowColorInterpolant = MathHelper.Lerp(0.44f, 0.88f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 1.1f) * 0.5f + 0.5f); - Color backglowColor = Color.Lerp(Color.Cyan, Color.Lime, backglowColorInterpolant) * 0.37f; - backglowColor.A = 0; - for (int i = 0; i < 8; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 3f; - Main.EntitySpriteDraw(texture, drawPosition + drawOffset, null, projectile.GetAlpha(backglowColor), projectile.rotation, origin, projectile.scale, 0, 0); - } - - Main.EntitySpriteDraw(texture, drawPosition, null, projectile.GetAlpha(Color.White * 0.75f), projectile.rotation, origin, projectile.scale, 0, 0); - } - } -} diff --git a/Projectiles/VanillaProjectileOverrides/HoundiusShootiusFireballAI.cs b/Projectiles/VanillaProjectileOverrides/HoundiusShootiusFireballAI.cs index 9ae33b8dbc..812e6317ef 100644 --- a/Projectiles/VanillaProjectileOverrides/HoundiusShootiusFireballAI.cs +++ b/Projectiles/VanillaProjectileOverrides/HoundiusShootiusFireballAI.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; namespace CalamityMod.Projectiles.VanillaProjectileOverrides { diff --git a/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs b/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs index b79ed81667..16c95c9c77 100644 --- a/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs +++ b/Projectiles/VanillaProjectileOverrides/ImpMinionAI.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.VanillaProjectileOverrides private static float EnemyDistanceDetection { get => Target is null ? MinEnemyDistanceDetection : MaxEnemyDistanceDetection; } - private const int FireRate = 75; + private const int FireRate = 60; private const float ProjectileVelocity = 20f; private static NPC Target { get; set; } @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.VanillaProjectileOverrides shootTimer += Main.rand.NextBool(20) ? 2 : 1; if (shootTimer >= FireRate && proj.owner == Main.myPlayer) { - Vector2 toTargetDirection = CalamityUtils.CalculatePredictiveAimToTarget(proj.Center, Target, ProjectileVelocity); + Vector2 toTargetDirection = Utils.DirectionTo(proj.Center, Target.Center) * ProjectileVelocity; Projectile fireball = Projectile.NewProjectileDirect(proj.GetSource_FromThis(), proj.Center, diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index a505707137..10114472bb 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -1,26 +1,14 @@ { "profiles": { - "Terraria Client (dotnet)": { + "Terraria": { "commandName": "Executable", - "executablePath": "dotnet", + "executablePath": "$(DotNetName)", "commandLineArgs": "$(tMLPath)", "workingDirectory": "$(tMLSteamPath)" }, - "Terraria Server (dotnet)": { + "TerrariaServer": { "commandName": "Executable", - "executablePath": "dotnet", - "commandLineArgs": "$(tMLServerPath)", - "workingDirectory": "$(tMLSteamPath)" - }, - "Terraria Client (dotnet.exe)": { - "commandName": "Executable", - "executablePath": "dotnet.exe", - "commandLineArgs": "$(tMLPath)", - "workingDirectory": "$(tMLSteamPath)" - }, - "Terraria Server (dotnet.exe)": { - "commandName": "Executable", - "executablePath": "dotnet.exe", + "executablePath": "$(DotNetName)", "commandLineArgs": "$(tMLServerPath)", "workingDirectory": "$(tMLSteamPath)" } diff --git a/README.md b/README.md index 9ae12d6b43..fe22891c7f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ - [Steam Workshop](https://calamitymod.com/download/) - [Discord](https://discord.gg/calamity) - [Official Wiki](https://calamitymod.wiki.gg/) -- [Patreon](https://patreon.com/fabsol) +- [Patreon](https://patreon.com/CalamityMod) The Calamity Mod is a vast content mod for Terraria which adds dozens of bosses and thousands of items to create an intense and varied experience. The mod must be installed using [tModLoader](https://github.com/tModLoader/tModLoader). diff --git a/Rarities/BurnishedAuric.cs b/Rarities/BurnishedAuric.cs new file mode 100644 index 0000000000..50f86b9814 --- /dev/null +++ b/Rarities/BurnishedAuric.cs @@ -0,0 +1,132 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Graphics; +using Terraria.GameContent; +using Terraria; +using Terraria.ModLoader; +using Terraria.UI.Chat; +using Terraria.ID; + +namespace CalamityMod.Rarities +{ + public class BurnishedAuric : ModRarity + { + // Burnished Auric is Rarity 15 (Once was known as Violet) + public override Color RarityColor => TextClr * 2f; + + public static float MaxY = 4.5f; + public static Color BloomClr = new Color(48, 33, 4, 0); + public static Color TextClr = new Color(157, 110, 11, 50); + static float lastFlashTime = 0f; + static bool isFlashing = false; + public static void Draw(Item Item, SpriteBatch spriteBatch, string text, int X, int Y, Color textColor, Color lightColor, float rotation, + Vector2 origin, Vector2 baseScale, float time, bool renderTextSparkles, DynamicSpriteFont font) + { + float flashChance = 0.005f; // Low chance per frame + float flashDuration = 0.2f; // Flash lasts ~0.2 seconds + + if (Main.GameUpdateCount - lastFlashTime > flashDuration * 60) + { + if (Main.rand.NextFloat() < flashChance) + { + isFlashing = true; + lastFlashTime = Main.GameUpdateCount; + } + else + { + isFlashing = false; + } + } + var fontSize = font.MeasureString(text); + var center = fontSize / 2.0f; + + if (Item.expert) + textColor = Main.DiscoColor; + + var glowPosition = new Vector2(X + center.X, Y + center.Y / 1.5f); + textColor.A = 0; + + float pulsing = 1.5f + (float)Math.Sin(time * 5f); + for (float f = 0f; f < MathHelper.TwoPi; f += 0.79f) + { + ChatManager.DrawColorCodedString( + spriteBatch, font, text, + new Vector2(X, Y) + new Vector2(pulsing, 0f).RotatedBy(f + time * 2f % MathHelper.TwoPi), + textColor * 0.5f, rotation, origin, baseScale); + if (isFlashing && CalamityClientConfig.Instance.TextEffects) + origin += Main.rand.NextVector2Circular(2f, 1.2f); // Small shake + } + + if (isFlashing) + { + textColor = new Color(0, 183, 241, 50); + lightColor = new Color(14, 255, 255, 50); + } + + textColor.A = 255; + + // Shadow + ChatManager.DrawColorCodedStringShadow(spriteBatch, font, text, new Vector2(X, Y), textColor * 2f, rotation, origin, baseScale); + + // Outline base + ChatManager.DrawColorCodedString(spriteBatch, font, text, new Vector2(X, Y), new Color(77, 0, 33), rotation, origin, baseScale); + + float shineWidth = 40f; //set to charSize + float shineSpeed = 80f; + + float shineDisp = time * shineSpeed; //predicted current location of the shine based on the time and speed + float shinePos = (shineDisp % (fontSize.X + shineWidth)); + + Vector2 basePos = new Vector2(X, Y); + if (isFlashing && CalamityClientConfig.Instance.TextEffects) + basePos += Main.rand.NextVector2Circular(3f, 10f); // Small shake + + float charOffsetX = 0f; + if (!renderTextSparkles) + return; + for (int i = 0; i < text.Length; i++) + { + string c = text[i].ToString(); + Vector2 charSize = font.MeasureString(c); + Vector2 charOrigin = charSize * 0.5f; + + Vector2 charPos = basePos + new Vector2(charOffsetX, 0f); + + float centerX = charPos.X + (charSize.X * baseScale.X) / 2f + 10.5f; + float dist = Math.Abs(centerX - (X + shinePos - shineWidth * 0.15f)); + float intensity = 1f - MathHelper.Clamp(dist / shineWidth, 0f, 1f); + + if (intensity > 0f) + { + Color shineColor = isFlashing ? new Color(90, 207, 255) * intensity * 2f : new Color(254, 231, 117) * intensity * 1f; + ChatManager.DrawColorCodedString( + spriteBatch, font, c, charPos, shineColor, rotation, origin, baseScale); + } + + charOffsetX += charSize.X - text.Length * 0.0085f; + } + } + + public static void Draw(Item Item, string text, int X, int Y, float rotation, Vector2 origin, Vector2 baseScale, Color? textColor = null, Color? lightColor = null, bool? renderTextSparkles = null) + { + Draw(Item, Main.spriteBatch, text, X, Y, Colors.AlphaDarken(textColor ?? TextClr), lightColor ?? BloomClr, rotation, origin, baseScale, Main.GlobalTimeWrappedHourly, + renderTextSparkles ?? CalamityClientConfig.Instance.TextEffects, FontAssets.MouseText.Value); + } + + public static void Draw(Item Item, DrawableTooltipLine line) + { + Draw(Item, line.Text, line.X, line.Y, line.Rotation, line.Origin, line.BaseScale); + } + + // TODO: Add a cooler alternative for reforge rarities + /*public override int GetPrefixedRarity(int offset, float valueMult) => offset switch + { + -2 => ModContent.RarityType(), + -1 => ModContent.RarityType(), + 1 => ModContent.RarityType(), + 2 => ModContent.RarityType(), + _ => Type, + };*/ + } +} diff --git a/Rarities/CalamityRed.cs b/Rarities/CalamityRed.cs index 3b47a6ab63..eb2f0d1920 100644 --- a/Rarities/CalamityRed.cs +++ b/Rarities/CalamityRed.cs @@ -1,5 +1,12 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Graphics; +using Terraria.GameContent; +using Terraria; using Terraria.ModLoader; +using Terraria.UI.Chat; +using Terraria.ID; namespace CalamityMod.Rarities { @@ -8,14 +15,123 @@ namespace CalamityMod.Rarities // Calamity Red is Rarity 17 // This rarity should never be assigned to any items. // It is the equivalent of vanilla's Purple rarity (11): only used for positive reforges on top-rarity items. - public override Color RarityColor => new Color(163, 25, 26); // #A3191A - // (139, 0, 0) is the classic donator item color + //public override Color RarityColor => new Color(163, 25, 26); // #A3191A + // // (139, 0, 0) is the classic donator item color - public override int GetPrefixedRarity(int offset, float valueMult) => offset switch + public override Color RarityColor => TextClr * 2f; + + public static float MaxY = 4.5f; + public static Color BloomClr = new Color(180, 20, 75, 0); + public static Color TextClr = new Color(242, 27, 27, 255); + + public static void Draw(Item Item, SpriteBatch spriteBatch, string text, int X, int Y, Color textColor, Color lightColor, float rotation, + Vector2 origin, Vector2 baseScale, float time, bool renderTextSparkles, DynamicSpriteFont font) { - -2 => ModContent.RarityType(), + var crystalTextGlow = ModContent.Request("CalamityMod/ExtraTextures/UI/CrystalTextGlow").Value; + var sparkle = ModContent.Request("CalamityMod/ExtraTextures/UI/CrystalTextSparkle").Value; + var fontSize = font.MeasureString(text); + var center = fontSize / 2f; + + if (Item.expert) + textColor = Main.DiscoColor; + + var glowPosition = new Vector2(X + center.X, Y + center.Y / 1.5f); + textColor.A = 0; + float pulsing = 10f + (float)Math.Sin(time * 20f); + float baseScalePulse = 1.03f; + float flameHeight = 5f; + float distortionAmount = 2f; + + if (renderTextSparkles) + + for (float f = 0f; f < MathHelper.TwoPi; f += 0.79f) + { + float angle = f + (time * 2f % MathHelper.TwoPi); + + float distortion = (float)Math.Sin((Y + f * 100f + time * 20f) * 0.05f) * distortionAmount; + + Vector2 offset = new Vector2( + (float)Math.Cos(angle) * pulsing * 0.4f + distortion, + -(float)Math.Abs((float)Math.Sin(angle)) * flameHeight + ); + + float scaleVariation = 0.95f + 0.05f * (float)Math.Sin(time * 15f + f * 2f); + Vector2 scale = new Vector2(baseScalePulse * scaleVariation); + + Color flameLayerColor = new Color( + (int)(textColor.R * 0.5f), + (int)(textColor.G * 0.5f), + (int)(textColor.B * 0.5f), + (int)(textColor.A * 0.5f) + ); + + ChatManager.DrawColorCodedString( + spriteBatch, + font, + text, + new Vector2(X, Y) + offset, + flameLayerColor, + rotation, + origin, + scale + ); + } + + // Draw crisp center text + ChatManager.DrawColorCodedString( + spriteBatch, + font, + text, + new Vector2(X, Y), + textColor, + rotation, + origin, + new Vector2(baseScalePulse) + ); + + textColor.A = 255; + + ChatManager.DrawColorCodedStringShadow(spriteBatch, font, text, new Vector2(X, Y), textColor * 2f, rotation, origin, baseScale); + + var bloomColor = ColorTool.Rainbowing(time * 4 - 0.9f); + + spriteBatch.Draw(crystalTextGlow, glowPosition, null, lightColor, rotation + MathHelper.PiOver2, new Vector2(6f, 33f), + new Vector2(1.6f, fontSize.X / crystalTextGlow.Height * 1.2f), SpriteEffects.None, 0f); + + ChatManager.DrawColorCodedString(spriteBatch, font, text, new Vector2(X, Y), Color.Black, rotation, origin, baseScale); + + // Is this a scrapped visual feature of the rarity? + /*int sparkleCount = Main.rand.Next((int)fontSize.X / 7, (int)fontSize.X / 5) + 1; + var color2 = lightColor * 1.00f; + color2.A = 0; + var sparkleOrigin = new Vector2(15f, 15f); + for (int i = 0; i < sparkleCount; i++) + { + var v = new Vector2(Main.rand.NextFloat(fontSize.X), Main.rand.NextFloat(fontSize.Y * 0.6f) + 1f); + float lifeTime = Main.GlobalTimeWrappedHourly * 4f + Main.rand.NextFloat(MathHelper.TwoPi * 7f); + lifeTime %= MathHelper.TwoPi * 1f; + }*/ + + return; + } + + public static void Draw(Item Item, string text, int X, int Y, float rotation, Vector2 origin, Vector2 baseScale, Color? textColor = null, Color? lightColor = null, bool? renderTextSparkles = null) + { + Draw(Item, Main.spriteBatch, text, X, Y, Colors.AlphaDarken(textColor ?? TextClr), lightColor ?? BloomClr, rotation, origin, baseScale, Main.GlobalTimeWrappedHourly, + renderTextSparkles ?? CalamityClientConfig.Instance.TextEffects, FontAssets.MouseText.Value); + } + + public static void Draw(Item Item, DrawableTooltipLine line) + { + Draw(Item, line.Text, line.X, line.Y, line.Rotation, line.Origin, line.BaseScale); + } + + // TODO: Add a cooler alternative for reforge rarities + /*public override int GetPrefixedRarity(int offset, float valueMult) => offset switch + { + -2 => ModContent.RarityType(), -1 => ModContent.RarityType(), _ => Type, - }; + };*/ } } diff --git a/Rarities/ColorTool.cs b/Rarities/ColorTool.cs new file mode 100644 index 0000000000..ca16bd0a20 --- /dev/null +++ b/Rarities/ColorTool.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Rarities +{ + public sealed class ColorTool : GlobalItem + { + public static int RarityCosmicPurple => ModContent.GetInstance().Type; + public static int RarityBurnishedAuric => ModContent.GetInstance().Type; + public static int RarityCalamityRed => ModContent.GetInstance().Type; + + + public override bool PreDrawTooltipLine(Item Item, DrawableTooltipLine line, ref int yOffset) + { + if (line.Mod == "Terraria" && line.Name == "ItemName") + { + if (Item.rare == RarityCosmicPurple) + { + CosmicPurple.Draw(Item, line); + return false; + } + if (Item.rare == RarityBurnishedAuric) + { + BurnishedAuric.Draw(Item, line); + return false; + } + if (Item.rare == RarityCalamityRed) + { + CalamityRed.Draw(Item, line); + return false; + } + } + return true; + } + public static Color colorLerps(Color[] colors, float time) + { + int index = (int)time; + return Color.Lerp(colors[index % colors.Length], colors[(index + 1) % colors.Length], time % 1f); + } + + public static Color Rainbowing(float position) => colorLerps( + [ new Color(255, 50, 50, 255), new Color(255, 128, 50, 255), new Color(230, 255, 50, 255), new Color(80, 255, 60, 255), + new Color(50, 80, 250, 255), new Color(200, 50, 250, 255), new Color(255, 50, 230, 255), ], position); + } +} diff --git a/Rarities/CosmicPurple.cs b/Rarities/CosmicPurple.cs new file mode 100644 index 0000000000..7ede28b514 --- /dev/null +++ b/Rarities/CosmicPurple.cs @@ -0,0 +1,132 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Graphics; +using Terraria.GameContent; +using Terraria; +using Terraria.ModLoader; +using Terraria.UI.Chat; +using Terraria.Utilities; +using Terraria.ID; + +namespace CalamityMod.Rarities +{ + public class CosmicPurple : ModRarity + { + // Cosmic Purple is Rarity 14 (once was known as Dark Blue) + public override Color RarityColor => TextClr * 2f; + + public static float MaxY = 4.5f; + public static Color BloomClr = new Color(65, 38, 87, 0); + public static Color TextClr = new Color(103, 66, 138, 255); + + public static void Draw(Item Item, SpriteBatch spriteBatch, string text, int X, int Y, Color textColor, Color lightColor, float rotation, + Vector2 origin, Vector2 baseScale, float time, bool renderTextSparkles, DynamicSpriteFont font) + { + var crystalTextGlow = ModContent.Request("CalamityMod/ExtraTextures/UI/CrystalTextGlow").Value; + var sparkle = ModContent.Request("CalamityMod/ExtraTextures/UI/CrystalTextSparkle").Value; + var fontSize = font.MeasureString(text); + var center = fontSize / 2f; + + // this was intended behavior. i'm commenting it out for now because it seems like people do not like it. + /* + if (Item.expert) + textColor = Main.DiscoColor; + */ + + var glowPosition = new Vector2(X + center.X, Y + center.Y / 1.5f); + textColor.A = 0; + float pulsing = 2.5f + (float)Math.Sin(time * 5f); + for (float f = 0f; f < MathHelper.TwoPi; f += 0.79f) + { + ChatManager.DrawColorCodedString(spriteBatch, font, text, new Vector2(X, Y) + new Vector2(pulsing, 0f).RotatedBy(f + time * 2f % MathHelper.TwoPi), textColor * 0.5f, rotation, origin, baseScale); + } + + textColor.A = 255; + + ChatManager.DrawColorCodedStringShadow(spriteBatch, font, text, new Vector2(X, Y), textColor * 2f, rotation, origin, baseScale); + + var bloomColor = ColorTool.Rainbowing(time * 4 - 0.9f); + + spriteBatch.Draw(crystalTextGlow, glowPosition, null, lightColor, rotation + MathHelper.PiOver2, new Vector2(6f, 33f), + new Vector2(1.6f, fontSize.X / crystalTextGlow.Height * 1.2f), SpriteEffects.None, 0f); + + ChatManager.DrawColorCodedString(spriteBatch, font, text, new Vector2(X, Y), Color.Black, rotation, origin, baseScale); + + if (!renderTextSparkles) + return; + + static int Hash(int x) + { + x ^= x >> 16; + x *= unchecked((int)0x7feb352d); + x ^= x >> 15; + x *= unchecked((int)0x846ca68b); + x ^= x >> 16; + return x; + } + + // why was this using a string hash previously?????? + var rand = new UnifiedRandom(Hash((int)(center.X + center.Y))); + + int sparkleCount = rand.Next((int)fontSize.X / 7, (int)fontSize.X / 5) + 1; + var color2 = lightColor; + color2.A = 0; + var sparkleOrigin = new Vector2(15f, 15f); + for (int i = 0; i < sparkleCount; i++) + { + var v = new Vector2(rand.NextFloat(fontSize.X), rand.NextFloat(fontSize.Y * 0.6f) + 1f); + float lifeTime = Main.GlobalTimeWrappedHourly * 4f + rand.NextFloat(MathHelper.TwoPi); + lifeTime %= MathHelper.TwoPi; + + if (lifeTime > MathHelper.TwoPi) + continue; + + float sinValue = (float)Math.Sin(lifeTime); + var white = new Color(200 + lightColor.R / 20, 200 + lightColor.G / 20, 200 + lightColor.B / 20, 255) * sinValue; + + float sparkleRotationSpeed = Main.rand.NextFloat(0.8f, 1.5f); // Unique rotation rate per sparkle + float sparkleRotation = time * sparkleRotationSpeed; + + spriteBatch.Draw(sparkle, new Vector2(X, Y - lifeTime * MaxY + 3f) + v, null, white, sparkleRotation, sparkleOrigin, + lifeTime / MathHelper.TwoPi * 0.3f, SpriteEffects.None, 0f); + spriteBatch.Draw(sparkle, new Vector2(X, Y - lifeTime * MaxY + 2f) + v, null, white * 0.5f, sparkleRotation, sparkleOrigin, + lifeTime / MathHelper.TwoPi, SpriteEffects.None, 0f); + + var scale2 = (float)Math.Sin(lifeTime / MathHelper.PiOver2) + 1f; + var scale3 = lifeTime / MathHelper.TwoPi; + + scale2 *= 0.2f; + scale3 *= 0.15f; + + spriteBatch.Draw(sparkle, new Vector2(X, Y - lifeTime * MaxY + 2f) + v, null, color2 * sinValue, sparkleRotation, sparkleOrigin, + new Vector2(scale3, scale3) * 1.5f, SpriteEffects.None, 0f); + spriteBatch.Draw(sparkle, new Vector2(X, Y - lifeTime * MaxY + 2f) + v, null, color2 * sinValue, sparkleRotation, sparkleOrigin, + new Vector2(scale2, scale3), SpriteEffects.None, 0f); + spriteBatch.Draw(sparkle, new Vector2(X, Y - lifeTime * MaxY + 2f) + v, null, color2 * sinValue, sparkleRotation, sparkleOrigin, + new Vector2(scale3, scale2), SpriteEffects.None, 0f); + } + } + + public static void Draw(Item Item, string text, int X, int Y, float rotation, Vector2 origin, Vector2 baseScale, Color? textColor = null, Color? lightColor = null, bool? renderTextSparkles = null) + { + Draw(Item, Main.spriteBatch, text, X, Y, Colors.AlphaDarken(textColor ?? TextClr), lightColor ?? BloomClr, rotation, origin, baseScale, Main.GlobalTimeWrappedHourly, + renderTextSparkles ?? CalamityClientConfig.Instance.TextEffects, FontAssets.MouseText.Value); + } + + public static void Draw(Item Item, DrawableTooltipLine line) + { + Draw(Item, line.Text, line.X, line.Y, line.Rotation, line.Origin, line.BaseScale); + } + + // TODO: Add a cooler alternative for reforge rarities + /*public override int GetPrefixedRarity(int offset, float valueMult) => offset switch + { + -2 => ModContent.RarityType(), + -1 => ModContent.RarityType(), + 1 => ModContent.RarityType(), + 2 => ModContent.RarityType(), + _ => Type, + };*/ + } +} diff --git a/Rarities/DarkBlue.cs b/Rarities/DarkBlue.cs deleted file mode 100644 index 02b431036f..0000000000 --- a/Rarities/DarkBlue.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria.ModLoader; - -namespace CalamityMod.Rarities -{ - public class DarkBlue : ModRarity - { - // Dark Blue is Rarity 14 - public override Color RarityColor => new Color(43, 96, 222); - - public override int GetPrefixedRarity(int offset, float valueMult) => offset switch - { - -2 => ModContent.RarityType(), - -1 => ModContent.RarityType(), - 1 => ModContent.RarityType(), - 2 => ModContent.RarityType(), - _ => Type, - }; - } -} diff --git a/Rarities/HotPink.cs b/Rarities/HotPink.cs index 28258729a5..38dfd4abf9 100644 --- a/Rarities/HotPink.cs +++ b/Rarities/HotPink.cs @@ -8,13 +8,14 @@ namespace CalamityMod.Rarities // Hot Pink is Rarity 16 public override Color RarityColor => new Color(255, 0, 255); - public override int GetPrefixedRarity(int offset, float valueMult) => offset switch + // Hot Pink cannot turn into other rarities via prefix + /*public override int GetPrefixedRarity(int offset, float valueMult) => offset switch { - -2 => ModContent.RarityType(), - -1 => ModContent.RarityType(), + -2 => ModContent.RarityType(), + -1 => ModContent.RarityType(), 1 => ModContent.RarityType(), 2 => ModContent.RarityType(), _ => Type, - }; + };*/ } } diff --git a/Rarities/PureGreen.cs b/Rarities/PureGreen.cs index 5b682682a2..5752ae8335 100644 --- a/Rarities/PureGreen.cs +++ b/Rarities/PureGreen.cs @@ -13,9 +13,7 @@ namespace CalamityMod.Rarities { -2 => ItemRarityID.Purple, -1 => ModContent.RarityType(), - 1 => ModContent.RarityType(), - 2 => ModContent.RarityType(), - _ => Type, + _ => Type, // Cannot reach Cosmic Purple or Burnished Auric }; } } diff --git a/Rarities/Turquoise.cs b/Rarities/Turquoise.cs index 2117b067d9..27428d0c1a 100644 --- a/Rarities/Turquoise.cs +++ b/Rarities/Turquoise.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Rarities -2 => ItemRarityID.Red, -1 => ItemRarityID.Purple, 1 => ModContent.RarityType(), - 2 => ModContent.RarityType(), + 2 => ModContent.RarityType(), // Cannot reach Cosmic Purple _ => Type, }; } diff --git a/Rarities/Violet.cs b/Rarities/Violet.cs deleted file mode 100644 index e5b468f021..0000000000 --- a/Rarities/Violet.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria.ModLoader; - -namespace CalamityMod.Rarities -{ - public class Violet : ModRarity - { - // Violet is Rarity 15 - public override Color RarityColor => new Color(108, 45, 199); - - public override int GetPrefixedRarity(int offset, float valueMult) => offset switch - { - -2 => ModContent.RarityType(), - -1 => ModContent.RarityType(), - 1 => ModContent.RarityType(), - 2 => ModContent.RarityType(), - _ => Type, - }; - } -} diff --git a/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs b/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs index 3530af36a3..ff14df277e 100644 --- a/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs +++ b/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs @@ -1,5 +1,6 @@ using CalamityMod.NPCs.DevourerofGods; using Terraria; +using Terraria.Graphics.Effects; using Terraria.ModLoader; namespace CalamityMod.Systems @@ -8,11 +9,21 @@ namespace CalamityMod.Systems { public override SceneEffectPriority Priority => SceneEffectPriority.BossHigh; - public override bool IsSceneEffectActive(Player player) => NPC.AnyNPCs(ModContent.NPCType()); + public override bool IsSceneEffectActive(Player player) + { + bool monolithIsActive = Main.LocalPlayer.Calamity().monolithDevourerBShader > 0 || Main.LocalPlayer.Calamity().monolithDevourerPShader > 0; + bool dogIsAlive = NPC.AnyNPCs(ModContent.NPCType()); + + return dogIsAlive || monolithIsActive; + } public override void SpecialVisuals(Player player, bool isActive) { player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHead", isActive); + if (isActive) + SkyManager.Instance.Activate("CalamityMod:DevourerofGodsHead"); + else + SkyManager.Instance.Deactivate("CalamityMod:DevourerofGodsHead"); } } } diff --git a/Scenes/BossBackgroundScenes/DrunkCrabBackgroundScene.cs b/Scenes/BossBackgroundScenes/DrunkCrabBackgroundScene.cs index 5b7ee0d578..bc5c78bd20 100644 --- a/Scenes/BossBackgroundScenes/DrunkCrabBackgroundScene.cs +++ b/Scenes/BossBackgroundScenes/DrunkCrabBackgroundScene.cs @@ -1,8 +1,5 @@ -using CalamityMod.NPCs; -using CalamityMod.NPCs.Crabulon; -using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.Crabulon; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Systems @@ -13,31 +10,9 @@ namespace CalamityMod.Systems public override bool IsSceneEffectActive(Player player) { - // Case 1: Zenith Seed Crabulon. if (Main.zenithWorld && NPC.AnyNPCs(ModContent.NPCType())) return true; - - // Case 2: Supreme Cirrus BH5. - bool cirrusSpecialAttack = false; - - // Try to find Supreme Cirrus, if she exists. She might not. - try - { - // Is there an index reference to Supreme Calamitas/Cirrus available? Is it valid? I sure hope so. Thanks TML - if (CalamityGlobalNPC.SCal >= 0 && CalamityGlobalNPC.SCal < Main.maxNPCs && Main.npc[CalamityGlobalNPC.SCal].active) - { - NPC npc = Main.npc[CalamityGlobalNPC.SCal]; - SupremeCalamitas supremeSomeone = npc.ModNPC(); - cirrusSpecialAttack = supremeSomeone is not null && supremeSomeone.cirrus && supremeSomeone.gettingTired5; - } - } - catch - { - if (Main.netMode == NetmodeID.SinglePlayer) - Main.NewText("Supreme Cirrus code attempted to crash the game. Did you do something weird?"); - } - - return cirrusSpecialAttack; + return false; } public override void SpecialVisuals(Player player, bool isActive) diff --git a/Scenes/MiscScenes/BossRushScene.cs b/Scenes/MiscScenes/BossRushScene.cs index e9f9a021b3..7ff89c21f0 100644 --- a/Scenes/MiscScenes/BossRushScene.cs +++ b/Scenes/MiscScenes/BossRushScene.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Reflection; using CalamityMod.Events; using CalamityMod.Skies; using Microsoft.Xna.Framework; @@ -11,8 +10,6 @@ namespace CalamityMod.Systems { public class BossRushScene : ModSceneEffect { - internal static readonly FieldInfo EffectsField = typeof(SkyManager).GetField("_effects", BindingFlags.NonPublic | BindingFlags.Instance); - public override int Music => BossRushEvent.MusicToPlay; public override SceneEffectPriority Priority => SceneEffectPriority.BossHigh; @@ -23,7 +20,7 @@ namespace CalamityMod.Systems // Clear all other skies, including the vanilla ones. if (isActive) { - Dictionary skies = EffectsField.GetValue(SkyManager.Instance) as Dictionary; + Dictionary skies = SkyManager.Instance._effects; bool updateRequired = false; foreach (string skyName in skies.Keys) { diff --git a/Scenes/MiscScenes/MonolithDistortionScene.cs b/Scenes/MiscScenes/MonolithDistortionScene.cs deleted file mode 100644 index 9396487fc8..0000000000 --- a/Scenes/MiscScenes/MonolithDistortionScene.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Systems -{ - public class MonolithDistortionScene : ModSceneEffect - { - public override SceneEffectPriority Priority => SceneEffectPriority.Environment; - - public override bool IsSceneEffectActive(Player player) => Main.LocalPlayer.Calamity().monolithDevourerBShader > 0 || Main.LocalPlayer.Calamity().monolithDevourerPShader > 0; - - public override void SpecialVisuals(Player player, bool isActive) - { - player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHead", isActive); - } - } -} diff --git a/Scenes/MusicScenes/AnahitaMusicScene.cs b/Scenes/MusicScenes/AnahitaMusicScene.cs index cf305a8a7c..0ab3274242 100644 --- a/Scenes/MusicScenes/AnahitaMusicScene.cs +++ b/Scenes/MusicScenes/AnahitaMusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.Leviathan; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/AnahitasLureMusicScene.cs b/Scenes/MusicScenes/AnahitasLureMusicScene.cs index fba7ac4115..33dd111e55 100644 --- a/Scenes/MusicScenes/AnahitasLureMusicScene.cs +++ b/Scenes/MusicScenes/AnahitasLureMusicScene.cs @@ -1,6 +1,4 @@ using CalamityMod.NPCs.Leviathan; -using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Systems diff --git a/Scenes/MusicScenes/AquaticScourgeMusicScene.cs b/Scenes/MusicScenes/AquaticScourgeMusicScene.cs index c9689876c6..193bd6c668 100644 --- a/Scenes/MusicScenes/AquaticScourgeMusicScene.cs +++ b/Scenes/MusicScenes/AquaticScourgeMusicScene.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Systems { if (CalamityGlobalNPC.aquaticScourge == -1) return false; - return Main.npc[CalamityGlobalNPC.aquaticScourge].justHit || Main.npc[CalamityGlobalNPC.aquaticScourge].life <= Main.npc[CalamityGlobalNPC.aquaticScourge].lifeMax * 0.999 || BossRushEvent.BossRushActive || Main.getGoodWorld; + return Main.npc[CalamityGlobalNPC.aquaticScourge].justHit || Main.npc[CalamityGlobalNPC.aquaticScourge].life <= Main.npc[CalamityGlobalNPC.aquaticScourge].lifeMax * 0.999 || BossRushEvent.BossRushActive || Main.zenithWorld; } } } diff --git a/Scenes/MusicScenes/AstrumAureusMusicScene.cs b/Scenes/MusicScenes/AstrumAureusMusicScene.cs index 1ef94a62e8..2dc088d30a 100644 --- a/Scenes/MusicScenes/AstrumAureusMusicScene.cs +++ b/Scenes/MusicScenes/AstrumAureusMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.AstrumAureus; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/AstrumDeusMusicScene.cs b/Scenes/MusicScenes/AstrumDeusMusicScene.cs index 72ca6ea1f5..cabbbb2ba0 100644 --- a/Scenes/MusicScenes/AstrumDeusMusicScene.cs +++ b/Scenes/MusicScenes/AstrumDeusMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.AstrumDeus; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/BioLabMusicScene.cs b/Scenes/MusicScenes/BioLabMusicScene.cs index 59ecadbe6a..d17e718d6f 100644 --- a/Scenes/MusicScenes/BioLabMusicScene.cs +++ b/Scenes/MusicScenes/BioLabMusicScene.cs @@ -31,31 +31,44 @@ namespace CalamityMod.Scenes.MusicScenes // (Tile range * Pixels per tile)^2 double labRadius = Math.Pow(80f * 16f, 2); - + // Checks if the player is behind any wall that naturally generates in Bio Labs bool behindLabWall = - backWall.WallType == WallID.ObsidianBrick || - backWall.WallType == WallID.Glass || - backWall.WallType == WallID.SnowWallUnsafe || - backWall.WallType == WallID.IceUnsafe || - backWall.WallType == WallID.Waterfall || - backWall.WallType == WallID.Lavafall || + backWall.WallType == WallID.AmberGemspark || + backWall.WallType == WallID.AncientSilverBrickWall || + backWall.WallType == WallID.CopperPlating || + backWall.WallType == WallID.EmeraldGemspark || + backWall.WallType == WallID.Granite || + backWall.WallType == WallID.GrayBrick || + backWall.WallType == WallID.IridescentBrick || backWall.WallType == WallID.IronBrick || - backWall.WallType == ModContent.WallType() || - backWall.WallType == ModContent.WallType() || - backWall.WallType == ModContent.WallType() || + backWall.WallType == WallID.Lavafall || + backWall.WallType == WallID.LavaMossBlockWall || + backWall.WallType == WallID.LeadBrick || + backWall.WallType == WallID.ObsidianBrick || + backWall.WallType == WallID.RubyGemspark || + backWall.WallType == WallID.SapphireGemspark || + backWall.WallType == WallID.SilverBrick || + backWall.WallType == WallID.StoneSlab || + backWall.WallType == WallID.TinPlating || + backWall.WallType == WallID.TopazGemspark || + backWall.WallType == WallID.Waterfall || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || + backWall.WallType == ModContent.WallType() || + backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || + backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || backWall.WallType == ModContent.WallType() || - backWall.WallType == ModContent.WallType(); + backWall.WallType == ModContent.WallType() || + backWall.WallType == ModContent.WallType(); // Checks if the player is within a specified range from the center point of any Bio Lab bool nearBioLabPoint = diff --git a/Scenes/MusicScenes/BrimstoneElementalMusicScene.cs b/Scenes/MusicScenes/BrimstoneElementalMusicScene.cs index c310584403..6c8e2a0f2a 100644 --- a/Scenes/MusicScenes/BrimstoneElementalMusicScene.cs +++ b/Scenes/MusicScenes/BrimstoneElementalMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.BrimstoneElemental; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CalamitasCloneMusicScene.cs b/Scenes/MusicScenes/CalamitasCloneMusicScene.cs index ae9a98ad8a..12c6e3a34b 100644 --- a/Scenes/MusicScenes/CalamitasCloneMusicScene.cs +++ b/Scenes/MusicScenes/CalamitasCloneMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.CalClone; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CalamitasDefeatMusicScene.cs b/Scenes/MusicScenes/CalamitasDefeatMusicScene.cs index 8d63f8dbec..4f2c8e3540 100644 --- a/Scenes/MusicScenes/CalamitasDefeatMusicScene.cs +++ b/Scenes/MusicScenes/CalamitasDefeatMusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.SupremeCalamitas; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CalamitasPhase1MusicScene.cs b/Scenes/MusicScenes/CalamitasPhase1MusicScene.cs index 8dc7722607..668568b6bb 100644 --- a/Scenes/MusicScenes/CalamitasPhase1MusicScene.cs +++ b/Scenes/MusicScenes/CalamitasPhase1MusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.SupremeCalamitas; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CalamitasPhase2MusicScene.cs b/Scenes/MusicScenes/CalamitasPhase2MusicScene.cs index 2cbd4eff34..c91eab3621 100644 --- a/Scenes/MusicScenes/CalamitasPhase2MusicScene.cs +++ b/Scenes/MusicScenes/CalamitasPhase2MusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.SupremeCalamitas; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CalamitasPhase3MusicScene.cs b/Scenes/MusicScenes/CalamitasPhase3MusicScene.cs index f92000d1b8..999417908f 100644 --- a/Scenes/MusicScenes/CalamitasPhase3MusicScene.cs +++ b/Scenes/MusicScenes/CalamitasPhase3MusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.SupremeCalamitas; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CeaselessVoidMusicScene.cs b/Scenes/MusicScenes/CeaselessVoidMusicScene.cs index 2b8aa4568a..89623f0b83 100644 --- a/Scenes/MusicScenes/CeaselessVoidMusicScene.cs +++ b/Scenes/MusicScenes/CeaselessVoidMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.CeaselessVoid; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CrabulonMusicScene.cs b/Scenes/MusicScenes/CrabulonMusicScene.cs index dcb377b438..a102816c80 100644 --- a/Scenes/MusicScenes/CrabulonMusicScene.cs +++ b/Scenes/MusicScenes/CrabulonMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.Crabulon; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/CryogenMusicScene.cs b/Scenes/MusicScenes/CryogenMusicScene.cs index 9d4d2dad9e..fa81f18124 100644 --- a/Scenes/MusicScenes/CryogenMusicScene.cs +++ b/Scenes/MusicScenes/CryogenMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.Cryogen; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/DesertScourgeMusicScene.cs b/Scenes/MusicScenes/DesertScourgeMusicScene.cs index 0b123f2be6..7600b28cd5 100644 --- a/Scenes/MusicScenes/DesertScourgeMusicScene.cs +++ b/Scenes/MusicScenes/DesertScourgeMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.DesertScourge; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/DevourerofGodsPhase1MusicScene.cs b/Scenes/MusicScenes/DevourerofGodsPhase1MusicScene.cs index 6e53d9cd4a..64e0284eed 100644 --- a/Scenes/MusicScenes/DevourerofGodsPhase1MusicScene.cs +++ b/Scenes/MusicScenes/DevourerofGodsPhase1MusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.DevourerofGods; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/DevourerofGodsPhase2MusicScene.cs b/Scenes/MusicScenes/DevourerofGodsPhase2MusicScene.cs index 001b5bbeea..81729f4571 100644 --- a/Scenes/MusicScenes/DevourerofGodsPhase2MusicScene.cs +++ b/Scenes/MusicScenes/DevourerofGodsPhase2MusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.DevourerofGods; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/DragonfollyMusicScene.cs b/Scenes/MusicScenes/DragonfollyMusicScene.cs index b005c124a8..0bdc1c12fe 100644 --- a/Scenes/MusicScenes/DragonfollyMusicScene.cs +++ b/Scenes/MusicScenes/DragonfollyMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.Bumblebirb; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,7 +8,7 @@ namespace CalamityMod.Systems { public override SceneEffectPriority Priority => SceneEffectPriority.BossMedium; - public override int NPCType => ModContent.NPCType(); + public override int NPCType => ModContent.NPCType(); public override int? MusicModMusic => CalamityMod.Instance.GetMusicFromMusicMod("Dragonfolly"); public override int VanillaMusic => MusicID.Boss4; public override int OtherworldMusic => MusicID.OtherworldlyBoss2; diff --git a/Scenes/MusicScenes/ExoMechsMusicScene.cs b/Scenes/MusicScenes/ExoMechsMusicScene.cs index 225de8aeef..e8034a5303 100644 --- a/Scenes/MusicScenes/ExoMechsMusicScene.cs +++ b/Scenes/MusicScenes/ExoMechsMusicScene.cs @@ -4,7 +4,6 @@ using CalamityMod.NPCs.ExoMechs.Apollo; using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.ExoMechs.Artemis; using CalamityMod.NPCs.ExoMechs.Thanatos; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/HiveMindMusicScene.cs b/Scenes/MusicScenes/HiveMindMusicScene.cs index 7b8d0b35f0..2830ef418a 100644 --- a/Scenes/MusicScenes/HiveMindMusicScene.cs +++ b/Scenes/MusicScenes/HiveMindMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.HiveMind; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/LeviathanMusicScene.cs b/Scenes/MusicScenes/LeviathanMusicScene.cs index 3bd651a66c..cf703ade8b 100644 --- a/Scenes/MusicScenes/LeviathanMusicScene.cs +++ b/Scenes/MusicScenes/LeviathanMusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.Leviathan; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/OldDukeMusicScene.cs b/Scenes/MusicScenes/OldDukeMusicScene.cs index 83dd915f62..7c15631a54 100644 --- a/Scenes/MusicScenes/OldDukeMusicScene.cs +++ b/Scenes/MusicScenes/OldDukeMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.OldDuke; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/PerforatorsMusicScene.cs b/Scenes/MusicScenes/PerforatorsMusicScene.cs index 0d05ba82e4..35c949925e 100644 --- a/Scenes/MusicScenes/PerforatorsMusicScene.cs +++ b/Scenes/MusicScenes/PerforatorsMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.Perforator; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/PlaguebringerGoliathMusicScene.cs b/Scenes/MusicScenes/PlaguebringerGoliathMusicScene.cs index 31495fc8df..375c691a0e 100644 --- a/Scenes/MusicScenes/PlaguebringerGoliathMusicScene.cs +++ b/Scenes/MusicScenes/PlaguebringerGoliathMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.PlaguebringerGoliath; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/PolterghastSilentMusicScene.cs b/Scenes/MusicScenes/PolterghastSilentMusicScene.cs index b5d8408044..b21be14353 100644 --- a/Scenes/MusicScenes/PolterghastSilentMusicScene.cs +++ b/Scenes/MusicScenes/PolterghastSilentMusicScene.cs @@ -1,7 +1,6 @@ using CalamityMod.NPCs.Polterghast; using CalamityMod.Projectiles.Summon; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Systems diff --git a/Scenes/MusicScenes/ProfanedGuardiansMusicScene.cs b/Scenes/MusicScenes/ProfanedGuardiansMusicScene.cs index 3c6e1cc3f5..7c7bdb1632 100644 --- a/Scenes/MusicScenes/ProfanedGuardiansMusicScene.cs +++ b/Scenes/MusicScenes/ProfanedGuardiansMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.ProfanedGuardians; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/ProvidenceMusicScene.cs b/Scenes/MusicScenes/ProvidenceMusicScene.cs index 7cc9fdd909..33b94b0f75 100644 --- a/Scenes/MusicScenes/ProvidenceMusicScene.cs +++ b/Scenes/MusicScenes/ProvidenceMusicScene.cs @@ -1,5 +1,5 @@ -using CalamityMod.NPCs.Providence; -using CalamityMod.Projectiles.Boss; +using CalamityMod.NPCs; +using CalamityMod.NPCs.Providence; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,33 +11,24 @@ namespace CalamityMod.Systems public override SceneEffectPriority Priority => SceneEffectPriority.BossHigh; public override int NPCType => ModContent.NPCType(); - public override int? MusicModMusic - { - get - { - for (int i = 0; i < Main.projectile.Length; i++) - { - Projectile proj = Main.projectile[i]; - if (proj.type == ModContent.ProjectileType() && proj.timeLeft > 35) - { - return MusicLoader.GetMusicSlot(Mod, "Sounds/Music/Silence"); - } - } - return CalamityMod.Instance.GetMusicFromMusicMod("Providence"); - } - } + public static int ProvidenceTrack => (int)CalamityMod.Instance.GetMusicFromMusicMod("Providence"); + public static int SilenceTrack => MusicLoader.GetMusicSlot(CalamityMod.Instance, "Sounds/Music/Silence"); + public override int? MusicModMusic => ProvidenceSpawnState() < 180f && ProvUtils.StandardAI() ? SilenceTrack : ProvidenceTrack; public override int VanillaMusic => MusicID.LunarBoss; public override int OtherworldMusic => MusicID.OtherworldlyLunarBoss; public override void SpecialVisuals(Player player, bool isActive) { - for (int i = 0; i < Main.projectile.Length; i++) - { - Projectile proj = Main.projectile[i]; - if (isActive && proj.type == ModContent.ProjectileType() && proj.timeLeft <= 35) - { - Main.musicFade[Main.curMusic] = 1f; - } - } + if (ProvidenceSpawnState() == 180f && ProvUtils.StandardAI()) + Main.musicFade[ProvidenceTrack] = 1f; + } + public static float ProvidenceSpawnState() + { + int provIndex = CalamityGlobalNPC.holyBoss; + if (provIndex < 0 || provIndex >= Main.maxNPCs || !Main.npc[provIndex].active) + return -1f; + + var prov = Main.npc[provIndex]; + return prov.Calamity().newAI[3]; } } } diff --git a/Scenes/MusicScenes/RavagerMusicScene.cs b/Scenes/MusicScenes/RavagerMusicScene.cs index 7dbbb50fa2..fac1a9b663 100644 --- a/Scenes/MusicScenes/RavagerMusicScene.cs +++ b/Scenes/MusicScenes/RavagerMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.Ravager; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/RevBoCIntroMusicScene.cs b/Scenes/MusicScenes/RevBoCIntroMusicScene.cs new file mode 100644 index 0000000000..231f894e95 --- /dev/null +++ b/Scenes/MusicScenes/RevBoCIntroMusicScene.cs @@ -0,0 +1,66 @@ +using System; +using CalamityMod.NPCs; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; +using CalamityMod.World; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu.BrainOfCthulhuAI; + +namespace CalamityMod.Scenes.MusicScenes +{ + public class RevBoCIntroMusicScene : ModSceneEffect + { + public override bool IsSceneEffectActive(Player player) + { + if(!CalamityWorld.revenge) + return false; + + if (NPC.crimsonBoss == -1) + return false; + + NPC brain = Main.npc[NPC.crimsonBoss]; + + if ((BrainAIState)brain.ai[0] > BrainAIState.SurfaceSpawnAnimation) //BoC isn't doing its spawn animation + return false; + + if (!brain.TryGetAIOverride(out var revBrain)) + return false; + + // BoC has sent out all its Creepers + // The second part leaves one frame at the end of the animation where the boss music starts playing, so that it can be instantly maxed out + return revBrain.SpawnTime != 0 && (revBrain.Time - Math.Abs(revBrain.SpawnTime) < 420); + } + + public override int Music => MusicLoader.GetMusicSlot(Mod, "Sounds/Music/Silence"); + + public override SceneEffectPriority Priority => SceneEffectPriority.BossMedium; + } + + public class RevBoCPreIntroMusicScene : ModSceneEffect + { + public override bool IsSceneEffectActive(Player player) + { + if (!CalamityWorld.revenge) + return false; + + if (NPC.crimsonBoss == -1) + return false; + + NPC brain = Main.npc[NPC.crimsonBoss]; + + if ((BrainAIState)brain.ai[0] > BrainAIState.SurfaceSpawnAnimation) //BoC isn't doing its spawn animation + return false; + + if (!brain.TryGetAIOverride(out var revBrain)) + return false; + + // BoC hasnt sent out all its Creepers yet + return revBrain.SpawnTime == 0; + } + + public override int Music => BrainOfCthulhuSystem.PreviousMusic >= 0 ? BrainOfCthulhuSystem.PreviousMusic : MusicID.Crimson; //Keeps the music that was playing prior to BoC being spawned + + public override SceneEffectPriority Priority => SceneEffectPriority.BossMedium; + } +} diff --git a/Scenes/MusicScenes/SignusMusicScene.cs b/Scenes/MusicScenes/SignusMusicScene.cs index 5aa9c64edb..6077cc9d32 100644 --- a/Scenes/MusicScenes/SignusMusicScene.cs +++ b/Scenes/MusicScenes/SignusMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.Signus; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/SkeletronPrimeMasterMusicScene.cs b/Scenes/MusicScenes/SkeletronPrimeMasterMusicScene.cs deleted file mode 100644 index e5597c0d2e..0000000000 --- a/Scenes/MusicScenes/SkeletronPrimeMasterMusicScene.cs +++ /dev/null @@ -1,14 +0,0 @@ -using CalamityMod.World; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems -{ - public class SkeletronPrimeMasterMusicScene : ModSceneEffect - { - public override int Music => MusicID.Boss3; // I spent 20 minutes trying to get this music to play while forgetting to actually override this in the first place _ YuH - public override SceneEffectPriority Priority => SceneEffectPriority.BossLow; - public override bool IsSceneEffectActive(Player player) => CalamityWorld.death && NPC.AnyNPCs(NPCID.SkeletronPrime) && Main.npc[NPC.FindFirstNPC(NPCID.SkeletronPrime)].Distance(player.Center) <= 525f * 16f; - } -} diff --git a/Scenes/MusicScenes/SlimeGodMusicScene.cs b/Scenes/MusicScenes/SlimeGodMusicScene.cs index 0572712bcf..05be751f1d 100644 --- a/Scenes/MusicScenes/SlimeGodMusicScene.cs +++ b/Scenes/MusicScenes/SlimeGodMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.SlimeGod; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/StormWeaverMusicScene.cs b/Scenes/MusicScenes/StormWeaverMusicScene.cs index 528cae95a3..2b870d25c9 100644 --- a/Scenes/MusicScenes/StormWeaverMusicScene.cs +++ b/Scenes/MusicScenes/StormWeaverMusicScene.cs @@ -1,5 +1,4 @@ using CalamityMod.NPCs.StormWeaver; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/YharonPhase1MusicScene.cs b/Scenes/MusicScenes/YharonPhase1MusicScene.cs index df9b6bd4d2..9e896c0caf 100644 --- a/Scenes/MusicScenes/YharonPhase1MusicScene.cs +++ b/Scenes/MusicScenes/YharonPhase1MusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.Yharon; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Scenes/MusicScenes/YharonPhase2MusicScene.cs b/Scenes/MusicScenes/YharonPhase2MusicScene.cs index fe4d188f22..e48d7b17af 100644 --- a/Scenes/MusicScenes/YharonPhase2MusicScene.cs +++ b/Scenes/MusicScenes/YharonPhase2MusicScene.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.Yharon; -using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Schematics/Arsenal_Lab_Ice.csch b/Schematics/Arsenal_Lab_Ice.csch new file mode 100644 index 0000000000..21c092cf3c Binary files /dev/null and b/Schematics/Arsenal_Lab_Ice.csch differ diff --git a/Schematics/Arsenal_Lab_Onyx.csch b/Schematics/Arsenal_Lab_Onyx.csch new file mode 100644 index 0000000000..feedc64d68 Binary files /dev/null and b/Schematics/Arsenal_Lab_Onyx.csch differ diff --git a/Schematics/Arsenal_Lab_Plague.csch b/Schematics/Arsenal_Lab_Plague.csch new file mode 100644 index 0000000000..c92d42a573 Binary files /dev/null and b/Schematics/Arsenal_Lab_Plague.csch differ diff --git a/Schematics/Arsenal_Lab_Planetoid.csch b/Schematics/Arsenal_Lab_Planetoid.csch new file mode 100644 index 0000000000..c83879ccaa Binary files /dev/null and b/Schematics/Arsenal_Lab_Planetoid.csch differ diff --git a/Schematics/Arsenal_Lab_Sunken.csch b/Schematics/Arsenal_Lab_Sunken.csch new file mode 100644 index 0000000000..f770b15419 Binary files /dev/null and b/Schematics/Arsenal_Lab_Sunken.csch differ diff --git a/Schematics/Arsenal_Lab_Underworld.csch b/Schematics/Arsenal_Lab_Underworld.csch new file mode 100644 index 0000000000..707fb92e10 Binary files /dev/null and b/Schematics/Arsenal_Lab_Underworld.csch differ diff --git a/Schematics/Barbed_Stockade1.csch b/Schematics/Barbed_Stockade1.csch new file mode 100644 index 0000000000..9d07e3aec6 Binary files /dev/null and b/Schematics/Barbed_Stockade1.csch differ diff --git a/Schematics/Barbed_Stockade2.csch b/Schematics/Barbed_Stockade2.csch new file mode 100644 index 0000000000..c21b797d8a Binary files /dev/null and b/Schematics/Barbed_Stockade2.csch differ diff --git a/Schematics/Barbed_Stockade3.csch b/Schematics/Barbed_Stockade3.csch new file mode 100644 index 0000000000..eae4b2cb42 Binary files /dev/null and b/Schematics/Barbed_Stockade3.csch differ diff --git a/Schematics/Barbed_Stockade4.csch b/Schematics/Barbed_Stockade4.csch new file mode 100644 index 0000000000..a49e0c86d5 Binary files /dev/null and b/Schematics/Barbed_Stockade4.csch differ diff --git a/Schematics/Bonescrapper_Cache1.csch b/Schematics/Bonescrapper_Cache1.csch new file mode 100644 index 0000000000..d5411fa3e7 Binary files /dev/null and b/Schematics/Bonescrapper_Cache1.csch differ diff --git a/Schematics/Bonescrapper_Cache2.csch b/Schematics/Bonescrapper_Cache2.csch new file mode 100644 index 0000000000..1145d46c6e Binary files /dev/null and b/Schematics/Bonescrapper_Cache2.csch differ diff --git a/Schematics/Bonescrapper_Cache3.csch b/Schematics/Bonescrapper_Cache3.csch new file mode 100644 index 0000000000..cb90d99889 Binary files /dev/null and b/Schematics/Bonescrapper_Cache3.csch differ diff --git a/Schematics/Bonescrapper_Cache4.csch b/Schematics/Bonescrapper_Cache4.csch new file mode 100644 index 0000000000..21fa20a226 Binary files /dev/null and b/Schematics/Bonescrapper_Cache4.csch differ diff --git a/Schematics/Bonescrapper_Cache5.csch b/Schematics/Bonescrapper_Cache5.csch new file mode 100644 index 0000000000..09a4f5d4fa Binary files /dev/null and b/Schematics/Bonescrapper_Cache5.csch differ diff --git a/Schematics/Bonescrapper_Cache6.csch b/Schematics/Bonescrapper_Cache6.csch new file mode 100644 index 0000000000..76ecd82c41 Binary files /dev/null and b/Schematics/Bonescrapper_Cache6.csch differ diff --git a/Schematics/Brimstone_Atrium1.csch b/Schematics/Brimstone_Atrium1.csch new file mode 100644 index 0000000000..257b3872c6 Binary files /dev/null and b/Schematics/Brimstone_Atrium1.csch differ diff --git a/Schematics/Brimstone_Atrium2.csch b/Schematics/Brimstone_Atrium2.csch new file mode 100644 index 0000000000..a0b5250357 Binary files /dev/null and b/Schematics/Brimstone_Atrium2.csch differ diff --git a/Schematics/Brimstone_Atrium3.csch b/Schematics/Brimstone_Atrium3.csch new file mode 100644 index 0000000000..258c97d742 Binary files /dev/null and b/Schematics/Brimstone_Atrium3.csch differ diff --git a/Schematics/CalamitySchematicIO.cs b/Schematics/CalamitySchematicIO.cs index 8705364156..a35c7640c8 100644 --- a/Schematics/CalamitySchematicIO.cs +++ b/Schematics/CalamitySchematicIO.cs @@ -277,8 +277,8 @@ namespace CalamityMod.Schematics // In 1.4.4, it's 347, but this can be acquired the normal way. public const ushort TML_14_WallID_Count = 316; - // A generous buffer of 16 megabytes is the default for schematics. If this somehow isn't big enough, they can get bigger. - private const int SchematicBufferStartingSize = 16777216; + // A buffer of 16 kilobytes is the default for schematics. If this isn't big enough, they can get bigger. + private const int SchematicBufferStartingSize = 1024 * 16; // If true, written schematics will have all data GZip compressed except for the magic number header. public static bool UseCompression = true; @@ -772,7 +772,7 @@ PostAreaIteration: // This is an intentional "fail gracefully" case. else if (isTML13Schematic) { - CalamityMod.Instance.Logger.Error(TML13ValidString); + CalamityMod.Log.Error(TML13ValidString); SchematicMetaTile[,] empty = new SchematicMetaTile[0, 0]; return empty; } diff --git a/Schematics/Demonic_Dungeon1.csch b/Schematics/Demonic_Dungeon1.csch new file mode 100644 index 0000000000..7b7595096d Binary files /dev/null and b/Schematics/Demonic_Dungeon1.csch differ diff --git a/Schematics/Demonic_Dungeon2.csch b/Schematics/Demonic_Dungeon2.csch new file mode 100644 index 0000000000..c8116e9d3d Binary files /dev/null and b/Schematics/Demonic_Dungeon2.csch differ diff --git a/Schematics/DraedonsLab_Cavern.csch b/Schematics/DraedonsLab_Cavern.csch deleted file mode 100644 index 189f23904a..0000000000 Binary files a/Schematics/DraedonsLab_Cavern.csch and /dev/null differ diff --git a/Schematics/DraedonsLab_Hell.csch b/Schematics/DraedonsLab_Hell.csch deleted file mode 100644 index 8743c23f3c..0000000000 Binary files a/Schematics/DraedonsLab_Hell.csch and /dev/null differ diff --git a/Schematics/DraedonsLab_Ice.csch b/Schematics/DraedonsLab_Ice.csch deleted file mode 100644 index 7df7875366..0000000000 Binary files a/Schematics/DraedonsLab_Ice.csch and /dev/null differ diff --git a/Schematics/DraedonsLab_Plague.csch b/Schematics/DraedonsLab_Plague.csch deleted file mode 100644 index 4bf586fca1..0000000000 Binary files a/Schematics/DraedonsLab_Plague.csch and /dev/null differ diff --git a/Schematics/DraedonsLab_Planetoid.csch b/Schematics/DraedonsLab_Planetoid.csch deleted file mode 100644 index f6247936d7..0000000000 Binary files a/Schematics/DraedonsLab_Planetoid.csch and /dev/null differ diff --git a/Schematics/DraedonsLab_SunkenSea.csch b/Schematics/DraedonsLab_SunkenSea.csch deleted file mode 100644 index f4a3e047ff..0000000000 Binary files a/Schematics/DraedonsLab_SunkenSea.csch and /dev/null differ diff --git a/Schematics/Hellstone_Stronghold1.csch b/Schematics/Hellstone_Stronghold1.csch new file mode 100644 index 0000000000..f7a79c9c73 Binary files /dev/null and b/Schematics/Hellstone_Stronghold1.csch differ diff --git a/Schematics/Hellstone_Stronghold2.csch b/Schematics/Hellstone_Stronghold2.csch new file mode 100644 index 0000000000..f05f1d9ef6 Binary files /dev/null and b/Schematics/Hellstone_Stronghold2.csch differ diff --git a/Schematics/Sanctum_of_Oblivion1.csch b/Schematics/Sanctum_of_Oblivion1.csch new file mode 100644 index 0000000000..1746bf4e6b Binary files /dev/null and b/Schematics/Sanctum_of_Oblivion1.csch differ diff --git a/Schematics/Sanctum_of_Oblivion2.csch b/Schematics/Sanctum_of_Oblivion2.csch new file mode 100644 index 0000000000..924291f7b7 Binary files /dev/null and b/Schematics/Sanctum_of_Oblivion2.csch differ diff --git a/Schematics/Sanctum_of_Oblivion3.csch b/Schematics/Sanctum_of_Oblivion3.csch new file mode 100644 index 0000000000..13e833b9e2 Binary files /dev/null and b/Schematics/Sanctum_of_Oblivion3.csch differ diff --git a/Schematics/SchematicManager.cs b/Schematics/SchematicManager.cs index 64ef097fca..71c79ad915 100644 --- a/Schematics/SchematicManager.cs +++ b/Schematics/SchematicManager.cs @@ -13,6 +13,69 @@ namespace CalamityMod.Schematics { public sealed class SchematicManager : ModSystem { + internal const string ShimmerShrineKey = "Shimmer Shrine Key"; + internal const string ShimmerShrineFilename = "Schematics/Shimmer_Shrine.csch"; + + internal const string BrimstoneAtriumType1Key = "Brimstone Atrium Type 1 Key"; + internal const string BrimstoneAtriumType1Filename = "Schematics/Brimstone_Atrium1.csch"; + + internal const string BrimstoneAtriumType2Key = "Brimstone Atrium Type 2 Key"; + internal const string BrimstoneAtriumType2Filename = "Schematics/Brimstone_Atrium2.csch"; + + internal const string BrimstoneAtriumType3Key = "Brimstone Atrium Type 3 Key"; + internal const string BrimstoneAtriumType3Filename = "Schematics/Brimstone_Atrium3.csch"; + + internal const string BonescrapperCacheType1Key = "Bonescrapper Cache Type 1 Key"; + internal const string BonescrapperCacheType1Filename = "Schematics/Bonescrapper_Cache1.csch"; + + internal const string BonescrapperCacheType2Key = "Bonescrapper Cache Type 2 Key"; + internal const string BonescrapperCacheType2Filename = "Schematics/Bonescrapper_Cache2.csch"; + + internal const string BonescrapperCacheType3Key = "Bonescrapper Cache Type 3 Key"; + internal const string BonescrapperCacheType3Filename = "Schematics/Bonescrapper_Cache3.csch"; + + internal const string BonescrapperCacheType4Key = "Bonescrapper Cache Type 4 Key"; + internal const string BonescrapperCacheType4Filename = "Schematics/Bonescrapper_Cache4.csch"; + + internal const string BonescrapperCacheType5Key = "Bonescrapper Cache Type 5 Key"; + internal const string BonescrapperCacheType5Filename = "Schematics/Bonescrapper_Cache5.csch"; + + internal const string BonescrapperCacheType6Key = "Bonescrapper Cache Type 6 Key"; + internal const string BonescrapperCacheType6Filename = "Schematics/Bonescrapper_Cache6.csch"; + + internal const string SanctumofOblivionType1Key = "Sanctum of Oblivion Type 1 Key"; + internal const string SanctumofOblivionType1Filename = "Schematics/Sanctum_of_Oblivion1.csch"; + + internal const string SanctumofOblivionType2Key = "Sanctum of Oblivion Type 2 Key"; + internal const string SanctumofOblivionType2Filename = "Schematics/Sanctum_of_Oblivion2.csch"; + + internal const string SanctumofOblivionType3Key = "Sanctum of Oblivion Type 3 Key"; + internal const string SanctumofOblivionType3Filename = "Schematics/Sanctum_of_Oblivion3.csch"; + + internal const string HellstoneStrongholdType1Key = "Hellstone Stronghold Type 1 Key"; + internal const string HellstoneStrongholdType1Filename = "Schematics/Hellstone_Stronghold1.csch"; + + internal const string HellstoneStrongholdType2Key = "Hellstone Stronghold Type 2 Key"; + internal const string HellstoneStrongholdType2Filename = "Schematics/Hellstone_Stronghold2.csch"; + + internal const string DemonicDungeonType1Key = "Demonic Dungeon Type 1 Key"; + internal const string DemonicDungeonType1Filename = "Schematics/Demonic_Dungeon1.csch"; + + internal const string DemonicDungeonType2Key = "Demonic Dungeon Type 2 Key"; + internal const string DemonicDungeonType2Filename = "Schematics/Demonic_Dungeon2.csch"; + + internal const string BarbedStockadeType1Key = "Barbed Stockade Type 1 Key"; + internal const string BarbedStockadeType1Filename = "Schematics/Barbed_Stockade1.csch"; + + internal const string BarbedStockadeType2Key = "Barbed Stockade Type 2 Key"; + internal const string BarbedStockadeType2Filename = "Schematics/Barbed_Stockade2.csch"; + + internal const string BarbedStockadeType3Key = "Barbed Stockade Type 3 Key"; + internal const string BarbedStockadeType3Filename = "Schematics/Barbed_Stockade3.csch"; + + internal const string BarbedStockadeType4Key = "Barbed Stockade Type 4 Key"; + internal const string BarbedStockadeType4Filename = "Schematics/Barbed_Stockade4.csch"; + internal const string RustedWorkshopKey = "Rusted Workshop"; internal const string RustedWorkshopFilename = "Schematics/RustedWorkshop.csch"; @@ -20,22 +83,22 @@ namespace CalamityMod.Schematics internal const string ResearchOutpostFilename = "Schematics/ResearchOutpost.csch"; internal const string SunkenSeaLabKey = "Sunken Sea Laboratory"; - internal const string SunkenSeaLabFilename = "Schematics/DraedonsLab_SunkenSea.csch"; + internal const string SunkenSeaLabFilename = "Schematics/Arsenal_Lab_Sunken.csch"; internal const string PlanetoidLabKey = "Planetoid Laboratory"; - internal const string PlanetoidLabFilename = "Schematics/DraedonsLab_Planetoid.csch"; + internal const string PlanetoidLabFilename = "Schematics/Arsenal_Lab_Planetoid.csch"; internal const string PlagueLabKey = "Plague Laboratory"; - internal const string PlagueLabFilename = "Schematics/DraedonsLab_Plague.csch"; + internal const string PlagueLabFilename = "Schematics/Arsenal_Lab_Plague.csch"; internal const string HellLabKey = "Hell Laboratory"; - internal const string HellLabFilename = "Schematics/DraedonsLab_Hell.csch"; + internal const string HellLabFilename = "Schematics/Arsenal_Lab_Underworld.csch"; internal const string IceLabKey = "Ice Laboratory"; - internal const string IceLabFilename = "Schematics/DraedonsLab_Ice.csch"; + internal const string IceLabFilename = "Schematics/Arsenal_Lab_Ice.csch"; internal const string CavernLabKey = "Cavern Laboratory"; - internal const string CavernLabFilename = "Schematics/DraedonsLab_Cavern.csch"; + internal const string CavernLabFilename = "Schematics/Arsenal_Lab_Onyx.csch"; internal const string CorruptionShrineKey = "Corruption Shrine"; internal const string CorruptionShrineFilename = "Schematics/Shrine_Corruption.csch"; @@ -106,6 +169,31 @@ namespace CalamityMod.Schematics PilePlacementMaps = new Dictionary(); TileMaps = new Dictionary { + // Shimmer Shrine + [ShimmerShrineKey] = CalamitySchematicIO.LoadSchematic(ShimmerShrineFilename), + + // Underworld structures + [BrimstoneAtriumType1Key] = CalamitySchematicIO.LoadSchematic(BrimstoneAtriumType1Filename), + [BrimstoneAtriumType2Key] = CalamitySchematicIO.LoadSchematic(BrimstoneAtriumType2Filename), + [BrimstoneAtriumType3Key] = CalamitySchematicIO.LoadSchematic(BrimstoneAtriumType3Filename), + [BonescrapperCacheType1Key] = CalamitySchematicIO.LoadSchematic(BonescrapperCacheType1Filename), + [BonescrapperCacheType2Key] = CalamitySchematicIO.LoadSchematic(BonescrapperCacheType2Filename), + [BonescrapperCacheType3Key] = CalamitySchematicIO.LoadSchematic(BonescrapperCacheType3Filename), + [BonescrapperCacheType4Key] = CalamitySchematicIO.LoadSchematic(BonescrapperCacheType4Filename), + [BonescrapperCacheType5Key] = CalamitySchematicIO.LoadSchematic(BonescrapperCacheType5Filename), + [BonescrapperCacheType6Key] = CalamitySchematicIO.LoadSchematic(BonescrapperCacheType6Filename), + [SanctumofOblivionType1Key] = CalamitySchematicIO.LoadSchematic(SanctumofOblivionType1Filename), + [SanctumofOblivionType2Key] = CalamitySchematicIO.LoadSchematic(SanctumofOblivionType2Filename), + [SanctumofOblivionType3Key] = CalamitySchematicIO.LoadSchematic(SanctumofOblivionType3Filename), + [HellstoneStrongholdType1Key] = CalamitySchematicIO.LoadSchematic(HellstoneStrongholdType1Filename), + [HellstoneStrongholdType2Key] = CalamitySchematicIO.LoadSchematic(HellstoneStrongholdType2Filename), + [DemonicDungeonType1Key] = CalamitySchematicIO.LoadSchematic(DemonicDungeonType1Filename), + [DemonicDungeonType2Key] = CalamitySchematicIO.LoadSchematic(DemonicDungeonType2Filename), + [BarbedStockadeType1Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType1Filename), + [BarbedStockadeType2Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType2Filename), + [BarbedStockadeType3Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType3Filename), + [BarbedStockadeType4Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType4Filename), + // Draedon's Arsenal world gen structures [RustedWorkshopKey] = CalamitySchematicIO.LoadSchematic(RustedWorkshopFilename), [ResearchOutpostKey] = CalamitySchematicIO.LoadSchematic(ResearchOutpostFilename), @@ -184,7 +272,7 @@ namespace CalamityMod.Schematics // If no schematic exists with this name, cancel with a helpful log message. if (!TileMaps.TryGetValue(name, out SchematicMetaTile[,] schematic)) { - CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{name}\". No matching schematic file found."); + CalamityMod.Log.Warn($"Tried to place a schematic with name \"{name}\". No matching schematic file found."); return; } @@ -243,7 +331,7 @@ namespace CalamityMod.Schematics // Make sure that all four corners of the target area are actually in the world. if (!WorldGen.InWorld(cornerX, cornerY) || !WorldGen.InWorld(cornerX + width, cornerY + height)) { - CalamityMod.Instance.Logger.Warn("Schematic failed to place: Part of the target location is outside the game world."); + CalamityMod.Log.Warn("Schematic failed to place: Part of the target location is outside the game world."); return; } diff --git a/Schematics/Shimmer_Shrine.csch b/Schematics/Shimmer_Shrine.csch new file mode 100644 index 0000000000..91c2def6a4 Binary files /dev/null and b/Schematics/Shimmer_Shrine.csch differ diff --git a/Skies/AstralMonolithScreenShaderData.cs b/Skies/AstralMonolithScreenShaderData.cs index b497c59694..73c6349824 100644 --- a/Skies/AstralMonolithScreenShaderData.cs +++ b/Skies/AstralMonolithScreenShaderData.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.Graphics.Effects; diff --git a/Skies/AstralMonolithSky.cs b/Skies/AstralMonolithSky.cs index e486069cd3..a9f0fa0442 100644 --- a/Skies/AstralMonolithSky.cs +++ b/Skies/AstralMonolithSky.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; using Terraria.Graphics.Effects; -using Terraria.ID; namespace CalamityMod.Skies { diff --git a/Skies/AstralScreenShaderData.cs b/Skies/AstralScreenShaderData.cs index 01d6ea0873..6fc45b2cbc 100644 --- a/Skies/AstralScreenShaderData.cs +++ b/Skies/AstralScreenShaderData.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; @@ -9,7 +10,7 @@ namespace CalamityMod.Skies { public class AstralScreenShaderData : ScreenShaderData { - public AstralScreenShaderData(Ref shader, string passName) : base(shader, passName) { } + public AstralScreenShaderData(Asset shader, string passName) : base(shader, passName) { } public override void Apply() { diff --git a/Skies/AstralSky.cs b/Skies/AstralSky.cs index 3814134d1a..f39a6bbfa5 100644 --- a/Skies/AstralSky.cs +++ b/Skies/AstralSky.cs @@ -4,9 +4,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; using Terraria.Graphics.Effects; -using Terraria.ID; -using Terraria.ModLoader; -using System.Reflection; namespace CalamityMod.Skies { diff --git a/Skies/BrimstoneCragSky.cs b/Skies/BrimstoneCragSky.cs index 1370a47a1d..5c1197e612 100644 --- a/Skies/BrimstoneCragSky.cs +++ b/Skies/BrimstoneCragSky.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; 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 diff --git a/Skies/CalamitasBackground.png b/Skies/CalamitasBackground.png new file mode 100644 index 0000000000..ba7e3deca8 Binary files /dev/null and b/Skies/CalamitasBackground.png differ diff --git a/Skies/CryogenSky.cs b/Skies/CryogenSky.cs index 02b5b528f5..e8c6badf02 100644 --- a/Skies/CryogenSky.cs +++ b/Skies/CryogenSky.cs @@ -3,9 +3,7 @@ using CalamityMod.NPCs.Cryogen; 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 diff --git a/NPCs/DevourerofGods/DoGScreenShaderData.cs b/Skies/DoGScreenShaderData.cs similarity index 86% rename from NPCs/DevourerofGods/DoGScreenShaderData.cs rename to Skies/DoGScreenShaderData.cs index 78a58b4511..a44f2777b8 100644 --- a/NPCs/DevourerofGods/DoGScreenShaderData.cs +++ b/Skies/DoGScreenShaderData.cs @@ -1,10 +1,11 @@ -using Microsoft.Xna.Framework; +using CalamityMod.NPCs.DevourerofGods; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ModLoader; -namespace CalamityMod.NPCs.DevourerofGods +namespace CalamityMod.Skies { public class DoGScreenShaderData : ScreenShaderData { @@ -17,13 +18,13 @@ namespace CalamityMod.NPCs.DevourerofGods private void UpdateDoGIndex() { - int DoGType = ModContent.NPCType(); + var DoGType = ModContent.NPCType(); if (DoGIndex >= 0 && Main.npc[DoGIndex].active && Main.npc[DoGIndex].type == DoGType) { return; } DoGIndex = -1; - foreach (NPC n in Main.ActiveNPCs) + foreach (var n in Main.ActiveNPCs) { if (n.type == DoGType) { @@ -54,6 +55,8 @@ namespace CalamityMod.NPCs.DevourerofGods { UseTargetPosition(Main.LocalPlayer.Center); } + + UseColor(DoGSky.DoGSkyColor); base.Apply(); } } diff --git a/Skies/DoGSky.cs b/Skies/DoGSky.cs new file mode 100644 index 0000000000..74600d010d --- /dev/null +++ b/Skies/DoGSky.cs @@ -0,0 +1,497 @@ +using System.Collections.Generic; +using CalamityMod.Effects; +using CalamityMod.Graphics.Primitives; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Systems.Graphic; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; + +namespace CalamityMod.Skies +{ + public class DoGSky : CustomSky + { + public class RealityCrack + { + public Vector2 Position; + + public float Depth; + + public float Scale; + + public float Rotation; + } + + public class DistortionRiftArm + { + public Vector2 ArmStartingPosition; + + public List ArmPoints; + + public float Depth; + + public float MaxWidth; + + public float MinDistanceBetweenPoints; + + public float MaxDistanceBetweenPoints; + + public float MinPointAngularVariance; + + public float MaxPointAngularVariance; + + public int TotalPoints; + } + + public static readonly Color DoGTwlight = new(147, 24, 204); + + public static readonly Color DoGLightBlue = new(0, 221, 250); + + public bool Initialized; + + public int DoGIndex; + + public List MainRiftCracks; + + public List OuterRiftCracks; + + public List RealityCracks; + + public List DistortionRiftArms; + + public static bool CanSkyBeActive { get; private set; } + + public static float SkyIntensity { get; private set; } + + public static Color DoGSkyColor { get; private set; } + + public override void Update(GameTime gameTime) + { + // Initialize the rift arms and background cracks. + GenerateRift(); + + DoGIndex = NPC.FindFirstNPC(ModContent.NPCType()); + GetCorrectDoGColor(); + + if (CanSkyBeActive) + SkyIntensity = MathHelper.Clamp(SkyIntensity + 0.05f, 0f, 1f); + else + SkyIntensity = MathHelper.Clamp(SkyIntensity - 0.05f, 0f, 1f); + } + + private void GenerateRift() + { + Vector2 riftSpawnLocation = Main.LocalPlayer.Center - Vector2.UnitY * 2000f + Main.rand.NextVector2Circular(2000f, 2000f); + + if (!Initialized) + { + MainRiftCracks = []; + OuterRiftCracks = []; + RealityCracks = []; + DistortionRiftArms = []; + + int crackCount = 3; + for (int i = 0; i < crackCount; i++) + { + RealityCrack realityCrack = new RealityCrack() + { + Position = riftSpawnLocation, + Depth = 30f, + Scale = 1.55f * Main.rand.NextFloat(0.9f, 1.1f), + Rotation = i * MathHelper.TwoPi / crackCount + }; + RealityCracks.Add(realityCrack); + } + + // Generate up to 30 arms for the rift. + // The first 14 are larger cracks to form the main hole at the impact point. + // The rest are longer, skinner cracks protruding outwards from it. + for (int i = 0; i < 14; i++) + { + DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + { + ArmStartingPosition = riftSpawnLocation, + Depth = 30f, + TotalPoints = 8, + + MaxWidth = Main.rand.NextFloat(100f, 120f), + MinDistanceBetweenPoints = 100f, + MaxDistanceBetweenPoints = 140f, + MinPointAngularVariance = -6, + MaxPointAngularVariance = 6, + + ArmPoints = [], + }; + MainRiftCracks.Add(distortionRiftArm); + } + + int outerCracksAmount = Main.rand.Next(12, 17); + for (int i = 0; i < outerCracksAmount; i++) + { + DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + { + ArmStartingPosition = riftSpawnLocation, + Depth = 30f, + TotalPoints = Main.rand.Next(6, 10), + + MaxWidth = Main.rand.NextFloat(6f, 9f), + MinDistanceBetweenPoints = 400f, + MaxDistanceBetweenPoints = 500f, + MinPointAngularVariance = Main.rand.Next(-10, -5), + MaxPointAngularVariance = Main.rand.Next(5, 10), + + ArmPoints = [], + }; + OuterRiftCracks.Add(distortionRiftArm); + } + + // Generate the points for each arm and add them all to the global arm list. + // Main cracks. + for (int i = 0; i < MainRiftCracks.Count; i++) + { + float minDistance = MainRiftCracks[i].MinDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; + float maxDistance = MainRiftCracks[i].MaxDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; + float minAngularVariance = MainRiftCracks[i].MinPointAngularVariance; + float maxAngularVariance = MainRiftCracks[i].MaxPointAngularVariance; + float placementAngle = i * MathHelper.TwoPi / MainRiftCracks.Count; + + if (MainRiftCracks[i].ArmPoints.Count <= 0) + MainRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(MainRiftCracks[i].ArmStartingPosition, MainRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); + DistortionRiftArms.Add(MainRiftCracks[i]); + } + + // Outer cracks. + for (int i = 0; i < OuterRiftCracks.Count; i++) + { + float minDistance = OuterRiftCracks[i].MinDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; + float maxDistance = OuterRiftCracks[i].MaxDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; + float minAngularVariance = OuterRiftCracks[i].MinPointAngularVariance; + float maxAngularVariance = OuterRiftCracks[i].MaxPointAngularVariance; + float placementAngle = i * MathHelper.TwoPi / OuterRiftCracks.Count; + + if (OuterRiftCracks[i].ArmPoints.Count <= 0) + OuterRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(OuterRiftCracks[i].ArmStartingPosition, OuterRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); + DistortionRiftArms.Add(OuterRiftCracks[i]); + } + + Initialized = true; + } + } + + private static List GenerateDistortionRiftArmPoints(Vector2 startingPosition, int totalPoints, float minDistanceBetweenPoints, float maxDistanceBetweenPoints, float minAngularVariance, float maxAngularVariance, float? optionalPointPlacementAngle = null) + { + // (Original code by Xyk; See TriactisHammerExplosion) + // -fryzahh + + List points = []; + for (int j = 0; j < totalPoints; j++) + { + // First point should always be the starting position. + if (j == 0) + { + points.Add(startingPosition); + } + // Next point should be a random location around the starting position. + // If the placement angle has a value then rotate towards that with a very slight offset. + else if (j == 1) + { + float distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints); + Vector2 nextPointPosition = startingPosition + Main.rand.NextVector2Unit() * distanceFromLastPoint; + if (optionalPointPlacementAngle != null) + nextPointPosition = startingPosition + Vector2.UnitX.RotatedBy(optionalPointPlacementAngle.Value) * distanceFromLastPoint; + points.Add(nextPointPosition); + } + // All other points follow after the last one with the same slight offset to resemble cracks. + else + { + Vector2 previousPoint = points[j - 2]; + float distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints); + if (j == totalPoints - 1) + distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints) * 0.5f; + + Vector2 newPoint = points[j - 1] + (previousPoint.DirectionTo(points[j - 1]) * distanceFromLastPoint).RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(minAngularVariance, maxAngularVariance) * j * 0.5f)); + points.Add(newPoint); + } + } + + return points; + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (Main.gameMenu || !CalamityClientConfig.Instance.FancyBackgroundVisuals) + return; + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the wind effect. + if (minDepth >= float.MinValue && maxDepth <= 5f) + DrawDistortionWinds(spriteBatch); + + // Draw the rolling fog effect. + if (minDepth >= 3f && maxDepth <= 10f) + DrawRollingBackgroundFog(spriteBatch); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the rift aura. + if (minDepth >= 6f && maxDepth <= float.MaxValue) + DrawRiftAura(spriteBatch); + + // Draw the cracked glass textures. + if (minDepth >= 6f && maxDepth <= float.MaxValue) + DrawRealityCracks(spriteBatch); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the rift to the Distortion over the cracked glass. + if (minDepth >= 6f && maxDepth <= float.MaxValue) + DrawDistortionRift(spriteBatch); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + } + + public void DrawRiftToRenderTarget() + { + if (DistortionRiftArms == null || DistortionRiftArms.Count == 0) + return; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + + for (int i = 0; i < DistortionRiftArms.Count; i++) + { + Vector2 depthFactor = new(1f / DistortionRiftArms[i].Depth, 0.9f / DistortionRiftArms[i].Depth); + List parallaxedPoints = []; + for (int j = 0; j < DistortionRiftArms[i].ArmPoints.Count; j++) + parallaxedPoints.Add((DistortionRiftArms[i].ArmPoints[j] - screenCenter) * depthFactor + screenCenter); + + PrimitiveRenderer.RenderTrail(parallaxedPoints, new((completion, _) => MathHelper.Lerp(0f, DistortionRiftArms[i].MaxWidth, 1f - completion) * SkyIntensity, (_, _) => Color.White * 1f, null, false, useUnscaledMatrices: true), DistortionRiftArms[i].TotalPoints + 16); + } + } + + private void DrawDistortionWinds(SpriteBatch spriteBatch) + { + Effect shader = CalamityShaders.DoGDistortionWindsShader.Value; + Texture2D windsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; + Texture2D highlightsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/SharpNoise").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Pebbles").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["overallOpacity"].SetValue(SkyIntensity); + shader.Parameters["distortionStrength"].SetValue(0.3f); + shader.Parameters["mainNoiseTextureScale"].SetValue(0.8f); + shader.Parameters["distortionTextureScale"].SetValue(0.6f); + shader.Parameters["erosionTextureScale"].SetValue(2f); + shader.Parameters["erosionMin"].SetValue(0.38f * SkyIntensity); + shader.Parameters["gradientPrecision"].SetValue(20f); + + shader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + shader.Parameters["worldOffset"].SetValue(Main.screenPosition / windsTexture.Size() * 0.025f); + + shader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.82f).ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, DoGSkyColor, 0.32f).ToVector3()); + shader.Parameters["highlightsColor"].SetValue(DoGSkyColor.ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = highlightsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap; + + Main.instance.GraphicsDevice.Textures[2] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[3] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearWrap; + + shader.CurrentTechnique.Passes[0].Apply(); + spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + + private void DrawRollingBackgroundFog(SpriteBatch spriteBatch) + { + Effect shader = CalamityShaders.DoGBackgroundFogShader.Value; + Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 3f); + shader.Parameters["overallOpacity"].SetValue(SkyIntensity * 0.25f); + shader.Parameters["distortionStrength"].SetValue(0.12f); + shader.Parameters["mainNoiseTextureScale"].SetValue(0.6f); + shader.Parameters["distortionTextureScale"].SetValue(0.8f); + shader.Parameters["erosionTextureScale"].SetValue(0.26f); + shader.Parameters["erosionMin"].SetValue(0.06f * SkyIntensity); + shader.Parameters["gradientPrecision"].SetValue(20f); + + shader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + shader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.005f); + + shader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.Black, Color.DarkGray, 0.75f).ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.DarkGray, DoGSkyColor, 0.8f).ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = cloudsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[2] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + shader.CurrentTechnique.Passes[0].Apply(); + spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + + private void DrawRiftAura(SpriteBatch spriteBatch) + { + if (RealityCracks == null || RealityCracks.Count == 0) + return; + + Effect shader = CalamityShaders.DoGRiftAuraShader.Value; + Texture2D riftAuraTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Smudges").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Swirls").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["pixelSize"].SetValue(screenSize * 0.5f); + shader.Parameters["distortionStrength"].SetValue(0.78f); + + shader.Parameters["opacityCutoffValue"].SetValue(0.675f * SkyIntensity); + shader.Parameters["fadeoutPower"].SetValue(1.25f); + shader.Parameters["overallOpacity"].SetValue(0.6f); + + shader.Parameters["minBrightnessValue"].SetValue(0f); + shader.Parameters["brighterPixelColor"].SetValue(DoGSkyColor.ToVector3()); + shader.Parameters["gradientPrecision"].SetValue(8f); + + Main.instance.GraphicsDevice.Textures[1] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap; + + shader.CurrentTechnique.Passes[0].Apply(); + + Vector2 depthFactor = new(1f / RealityCracks[0].Depth, 0.9f / RealityCracks[0].Depth); + Vector2 drawPosition = (RealityCracks[0].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition; + spriteBatch.Draw(riftAuraTexture, drawPosition, null, Color.White, Main.GlobalTimeWrappedHourly * MathHelper.TwoPi / 270f, riftAuraTexture.Size() * 0.5f, 1f, 0, 0f); + } + + private void DrawRealityCracks(SpriteBatch spriteBatch) + { + if (RealityCracks == null || RealityCracks.Count == 0) + return; + + Effect shader = CalamityShaders.DoGRealityCrackShader.Value; + Texture2D cracksTexture = ModContent.Request("CalamityMod/ExtraTextures/CrackedGlass_Glowing").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + + shader.Parameters["opacityCutoffValue"].SetValue(0.8f * SkyIntensity); + shader.Parameters["fadeoutPower"].SetValue(1f); + shader.Parameters["overallOpacity"].SetValue(0.1015f); + + shader.Parameters["minBrightnessValue"].SetValue(0.6f); + shader.Parameters["darkerPixelColor"].SetValue(DoGSkyColor.ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.White.ToVector3()); + + shader.CurrentTechnique.Passes[0].Apply(); + + for (int i = 0; i < RealityCracks.Count; i++) + { + Vector2 depthFactor = new(1f / RealityCracks[i].Depth, 0.9f / RealityCracks[i].Depth); + Vector2 drawPosition = (RealityCracks[i].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition; + spriteBatch.Draw(cracksTexture, drawPosition, null, Color.White, RealityCracks[i].Rotation, cracksTexture.Size() * 0.5f, RealityCracks[i].Scale, 0, 0f); + } + } + + private void DrawDistortionRift(SpriteBatch spriteBatch) + { + using (spriteBatch.Scope()) + { + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, null, CalamityShaders.MetaballEdgeShader.Value, Main.BackgroundViewMatrix.TransformationMatrix); + // Impose the distortion rift contents onto the primitives via shader. + var metaballShader = CalamityShaders.MetaballEdgeShader; + Texture2D distortionRiftContents = DoGVisualsManager.DistortionRiftBackgroundContentsTarget.Target; + Texture2D distortionRift = DoGVisualsManager.DistortionRiftPrimitivesTarget.Target; + + Vector2 screenSize = new(Main.graphics.graphicsDevice.Viewport.Width, Main.graphics.graphicsDevice.Viewport.Height); + + metaballShader.Value.Parameters["layerSize"]?.SetValue(distortionRiftContents.Size()); + metaballShader.Value.Parameters["screenSize"]?.SetValue(screenSize); + metaballShader.Value.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + metaballShader.Value.Parameters["edgeColor"]?.SetValue(Color.Lerp(Color.Lerp(DoGSkyColor, Color.White, 0.6f), Color.Black, 0.15f).ToVector4()); + metaballShader.Value.Parameters["layerColor"]?.SetValue(DoGSkyColor.ToVector4()); + + Main.instance.GraphicsDevice.Textures[1] = distortionRiftContents; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + metaballShader.Value.CurrentTechnique.Passes[0].Apply(); + spriteBatch.Draw(distortionRift, new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y), Color.White); + Main.spriteBatch.End(); + } + } + + private void GetCorrectDoGColor() + { + if (DoGIndex != -1) + { + var DoG = Main.npc[DoGIndex].ModNPC(); + Color goalSkyColor = Color.Black; + if (DoG.isInAgressiveState) + goalSkyColor = Color.Fuchsia; + if (DoG.isInPassiveState) + goalSkyColor = DoGLightBlue; + if (DoG.isInLaserWallState || DoG.isInPostWallState || DoG.postTeleportTimer > 0 || DoG.teleportTimer > 0 || DoG.NPC.localAI[2] < 180 && DoG.NPC.localAI[2] > 60) + goalSkyColor = DoGTwlight; + + DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); + } + else + { + var goalSkyColor = Color.Black; + if (Main.LocalPlayer.Calamity().monolithDevourerPShader > 0) + goalSkyColor = Color.Fuchsia; + if (Main.LocalPlayer.Calamity().monolithDevourerBShader > 0) + goalSkyColor = DoGLightBlue; + + DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); + } + } + + public override Color OnTileColor(Color inColor) => Color.Lerp(inColor, DoGSkyColor, SkyIntensity); + + public override float GetCloudAlpha() => 1f; + + public override void Activate(Vector2 position, params object[] args) => CanSkyBeActive = true; + + public override bool IsActive() => CanSkyBeActive || SkyIntensity > 0f; + + public override void Deactivate(params object[] args) + { + CanSkyBeActive = false; + if (SkyIntensity <= 0.1f) + { + Initialized = false; + DistortionRiftArms?.Clear(); + RealityCracks?.Clear(); + } + } + + public override void Reset() + { + CanSkyBeActive = false; + Initialized = false; + DistortionRiftArms?.Clear(); + RealityCracks?.Clear(); + } + } +} diff --git a/Skies/DrunkCrabScreenShaderData.cs b/Skies/DrunkCrabScreenShaderData.cs index 2d67cb7706..23c8955625 100644 --- a/Skies/DrunkCrabScreenShaderData.cs +++ b/Skies/DrunkCrabScreenShaderData.cs @@ -1,7 +1,4 @@ -using CalamityMod.NPCs; -using CalamityMod.NPCs.Crabulon; -using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.World; +using CalamityMod.NPCs.Crabulon; using Microsoft.Xna.Framework; using Terraria; using Terraria.Graphics.Effects; @@ -13,7 +10,6 @@ namespace CalamityMod.Skies public class DrunkCrabScreenShaderData : ScreenShaderData { public int CrabIndex; - public int CirrusIndex; public DrunkCrabScreenShaderData(string passName) : base(passName) @@ -23,98 +19,28 @@ namespace CalamityMod.Skies public void UpdateBossIndex() { int CrabType = ModContent.NPCType(); - int CirrusType = ModContent.NPCType(); - bool shouldCheckForCirrus = false; - bool shouldForceDeactivateCirrusShader = false; - if (CalamityGlobalNPC.SCal != -1) - { - if (Main.npc[CalamityGlobalNPC.SCal].active) - { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) - { - shouldCheckForCirrus = Main.npc[CalamityGlobalNPC.SCal].ModNPC().gettingTired5; - shouldForceDeactivateCirrusShader = Main.npc[CalamityGlobalNPC.SCal].ModNPC().giveUpCounter <= 1; - } - } - } + if (CrabIndex >= 0 && Main.npc[CrabIndex].active && Main.npc[CrabIndex].type == CrabType) + return; - if (shouldCheckForCirrus) - { - if (CirrusIndex >= 0 && Main.npc[CirrusIndex].active && Main.npc[CirrusIndex].type == CirrusType && !shouldForceDeactivateCirrusShader) - return; - - CirrusIndex = -1; - - if (!shouldForceDeactivateCirrusShader) - { - CirrusIndex = NPC.FindFirstNPC(CirrusType); - } - } - else - { - if (CrabIndex >= 0 && Main.npc[CrabIndex].active && Main.npc[CrabIndex].type == CrabType) - return; - - CrabIndex = NPC.FindFirstNPC(CrabType); - } + CrabIndex = NPC.FindFirstNPC(CrabType); } public override void Update(GameTime gameTime) { - bool shouldCheckForCirrus = false; - if (CalamityGlobalNPC.SCal != -1) - { - if (Main.npc[CalamityGlobalNPC.SCal].active) - { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) - shouldCheckForCirrus = Main.npc[CalamityGlobalNPC.SCal].ModNPC().gettingTired5; - } - } - - if (shouldCheckForCirrus) - { - if (CirrusIndex == -1) - { - UpdateBossIndex(); - if (CirrusIndex == -1) - Filters.Scene["CalamityMod:DrunkCrabulon"].Deactivate(); - } - } - else + if (CrabIndex == -1 || !Main.zenithWorld) { + UpdateBossIndex(); if (CrabIndex == -1 || !Main.zenithWorld) - { - UpdateBossIndex(); - if (CrabIndex == -1 || !Main.zenithWorld) - Filters.Scene["CalamityMod:DrunkCrabulon"].Deactivate(); - } - } + Filters.Scene["CalamityMod:DrunkCrabulon"].Deactivate(); + } } public override void Apply() { UpdateBossIndex(); - bool shouldCheckForCirrus = false; - if (CalamityGlobalNPC.SCal != -1) - { - if (Main.npc[CalamityGlobalNPC.SCal].active) - { - if (Main.npc[CalamityGlobalNPC.SCal].ModNPC().cirrus) - shouldCheckForCirrus = Main.npc[CalamityGlobalNPC.SCal].ModNPC().gettingTired5; - } - } - - if (shouldCheckForCirrus) - { - if (CirrusIndex != -1) - UseTargetPosition(Main.npc[CirrusIndex].Center); - } - else - { - if (CrabIndex != -1) - UseTargetPosition(Main.npc[CrabIndex].Center); - } + if (CrabIndex != -1) + UseTargetPosition(Main.npc[CrabIndex].Center); base.Apply(); } diff --git a/Skies/MonolithScreenShaderData.cs b/Skies/MonolithScreenShaderData.cs index 690ee07a41..aafcf11e21 100644 --- a/Skies/MonolithScreenShaderData.cs +++ b/Skies/MonolithScreenShaderData.cs @@ -1,6 +1,5 @@ using System; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; diff --git a/Skies/MonolithSky.cs b/Skies/MonolithSky.cs index 0a619692c3..10c9df18b8 100644 --- a/Skies/MonolithSky.cs +++ b/Skies/MonolithSky.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; 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 diff --git a/Skies/SCalScreenShaderData.cs b/Skies/SCalScreenShaderData.cs index 1e562f1683..92ca7f0082 100644 --- a/Skies/SCalScreenShaderData.cs +++ b/Skies/SCalScreenShaderData.cs @@ -44,8 +44,8 @@ namespace CalamityMod.Skies { UseTargetPosition(Main.npc[SCalIndex].Center); - if (Main.npc[SCalIndex].ModNPC().cirrus) - Filters.Scene["CalamityMod:SupremeCalamitas"].GetShader().UseColor(0.9f, 0.3f, 0.9f); + if (Main.npc[SCalIndex].ModNPC().permafrost) + Filters.Scene["CalamityMod:SupremeCalamitas"].GetShader().UseColor(0.3f, 0.6f, 0.9f); } base.Apply(); } diff --git a/Skies/SCalSky.cs b/Skies/SCalSky.cs index 8f47be8370..88f9424701 100644 --- a/Skies/SCalSky.cs +++ b/Skies/SCalSky.cs @@ -3,11 +3,10 @@ using System.Collections.Generic; using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.Projectiles.Boss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.Graphics.Effects; using Terraria.ModLoader; @@ -15,8 +14,6 @@ namespace CalamityMod.Skies { public class SCalSky : CustomSky { - public Color cinderColortoBe = Color.Red; - public Color cinderColor = Color.Red; public class Cinder { public int Time; @@ -27,6 +24,7 @@ namespace CalamityMod.Skies public Color DrawColor; public Vector2 Velocity; public Vector2 Center; + public float Opacity = 0; public Cinder(int lifetime, int identity, float depth, Color color, Vector2 startingPosition, Vector2 startingVelocity) { @@ -43,6 +41,8 @@ namespace CalamityMod.Skies private float intensity = 0f; private int SCalIndex = -1; public List Cinders = new List(); + private Asset backgroundTex; + private Asset cinderTex; public static bool RitualDramaProjectileIsPresent { @@ -124,64 +124,48 @@ namespace CalamityMod.Skies public override void Update(GameTime gameTime) { + intensity = GetIntensity(); if (SCalIndex == -1) - { UpdateSCalIndex(); - if (SCalIndex == -1) - isActive = false; - } - if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) - isActive = false; + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType() || SCalIndex == -1) + { + intensity -= 0.1f; + if (intensity <= 0) + isActive = false; + return; + } static Color selectCinderColor() { - if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) - return Color.Transparent; - - NPC scal = Main.npc[CalamityGlobalNPC.SCal]; - bool cirrus = scal.ModNPC().cirrus; - float lifeRatio = scal.life / (float)scal.lifeMax; - - if (NPC.AnyNPCs(ModContent.NPCType()) == true && NPC.AnyNPCs(ModContent.NPCType()) == false) - return Color.Lerp(Color.MediumTurquoise, Color.Cyan, Main.rand.NextFloat(0.2f, 0.9f)); - if (NPC.AnyNPCs(ModContent.NPCType()) == true && NPC.AnyNPCs(ModContent.NPCType()) == false) - return Color.Lerp(Color.Magenta, Color.MediumVioletRed, Main.rand.NextFloat(0.2f, 0.9f)); - if (NPC.AnyNPCs(ModContent.NPCType()) == true && NPC.AnyNPCs(ModContent.NPCType()) == true) - return Color.Lerp(Color.Red, Color.IndianRed, Main.rand.NextFloat(0f, 1f)); - - if (lifeRatio > 0.5f) - return Color.Lerp(cirrus ? Color.Pink : Color.Red, cirrus ? Color.Violet : Color.Crimson, Main.rand.NextFloat(0f, 1f)); - else if (lifeRatio > 0.3f || scal.ModNPC().postMusicHit == false) - return Color.Lerp(cirrus ? Color.Cyan : Color.Red, cirrus ? Color.DarkCyan : Color.Magenta, Main.rand.NextFloat(0f, 0.7f)); - else if (lifeRatio > 0.01f) - return Color.Lerp(cirrus ? Color.Pink : Color.Red, cirrus ? Color.Green : Color.Yellow, Main.rand.NextFloat(0f, 0.88f)); - else - return Color.Lerp(Color.Gray, Color.White, Main.rand.NextFloat(0f, 0.65f)); + return SupremeCalamitas.CurrentColor; } // Randomly add cinders. - if (Main.rand.NextBool(CinderReleaseChance)) + if (Main.rand.NextBool(CinderReleaseChance) && CalamityGlobalNPC.SCal >= 0) { - int lifetime = Main.rand.Next(285, 445); + var box = Main.npc[CalamityGlobalNPC.SCal].ModNPC().ArenaBox; + int lifetime = Main.rand.Next(485, 645); float depth = Main.rand.NextFloat(1.8f, 5f); - Vector2 startingPosition = Main.screenPosition + new Vector2(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f), Main.screenHeight * 1.05f); + Vector2 startingPosition = Main.screenPosition + new Vector2(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f), Main.screenHeight * Main.rand.NextFloat(-0.1f, 1.1f)); + startingPosition = Main.rand.NextVector2FromRectangle(box.HitboxRectangle) + new Vector2(0, 180); + startingPosition = Vector2.Lerp(box.BottomLeft, box.BottomRight, Main.rand.NextFloat()); Vector2 startingVelocity = -Vector2.UnitY.RotatedByRandom(0.91f); Cinders.Add(new Cinder(lifetime, Cinders.Count, depth, selectCinderColor(), startingPosition, startingVelocity)); } - if ((!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) == false) + else if ((!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) == false) { NPC scal = Main.npc[CalamityGlobalNPC.SCal]; if (scal.ModNPC().musicSyncCounter == 0) { for (int i = 0; i < 70; i++) - { + { int lifetime = Main.rand.Next(285, 445); float depth = Main.rand.NextFloat(1.8f, 5f); Vector2 startingPosition = Main.screenPosition + new Vector2(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f), Main.screenHeight * Main.rand.NextFloat(1.05f, 1.45f)); Vector2 startingVelocity = -Vector2.UnitY.RotatedByRandom(0.91f) * Main.rand.NextFloat(0.5f, 2.5f); - Cinders.Add(new Cinder(lifetime, Cinders.Count, depth, selectCinderColor(), startingPosition, startingVelocity)); + Cinders.Add(new Cinder(lifetime, Cinders.Count, depth, SupremeCalamitas.LamentColor, startingPosition, startingVelocity)); } } } @@ -189,6 +173,8 @@ namespace CalamityMod.Skies // Update all cinders. for (int i = 0; i < Cinders.Count; i++) { + if (Cinders[i].Opacity < 1) + Cinders[i].Opacity += 0.1f; Cinders[i].Scale = Utils.GetLerpValue(Cinders[i].Lifetime, Cinders[i].Lifetime / 3, Cinders[i].Time, true) * 1.5f; Cinders[i].Scale *= MathHelper.Lerp(0.6f, 0.9f, Cinders[i].IdentityIndex % 6f / 6f); @@ -211,7 +197,7 @@ namespace CalamityMod.Skies return OverridingIntensity; OverridingIntensity = 0f; - if (UpdateSCalIndex()) + if (UpdateSCalIndex() && SCalIndex > -1) { float x = 0f; if (SCalIndex != -1) @@ -221,7 +207,7 @@ namespace CalamityMod.Skies return (1f - Utils.SmoothStep(4500f, 9000f, x)) * intensityFactor; } - return 0f; + return intensity; } public override Color OnTileColor(Color inColor) => new(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - GetIntensity())); @@ -241,54 +227,49 @@ namespace CalamityMod.Skies { if (maxDepth >= 0 && minDepth < 0) { + var viewport = Main.graphics.GraphicsDevice.Viewport; + var tex = CalamityUtils.GetTextureEfficient(ref backgroundTex, "CalamityMod/Skies/CalamitasBackground").Value; + + //We add 2 to the repeat count as a buffer for the texture position offset, to ensure the screen is always fully covered. + float repeatX = (float)viewport.Width / tex.Width + 2; + float repeatY = (float)viewport.Height / tex.Height + 2; + float intensity = GetIntensity(); - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), Color.Black * intensity); + //This ratio is the scale of one viewport pixel to one game pixel. Needed to accomodate for different resolutions and zoom levels. + //Changing zoom while this is on does cause the background to move rapidly while zoom is being changed since the screen position is changing. This is more effort to fix than it's worth. + //Changing zoom also does not change the scale of the background texture, leaving it full-size regardless of zoom. Once again, more work than it's worth. + Vector2 ViewportToGamesizeRatio = new Vector2(viewport.Width, viewport.Height) / new Vector2(Main.screenWidth, Main.screenHeight) * Main.GameZoomTarget; + + //This is the offset the texture has from the screen position. Subtracting the player postion is needed for it to move with the player like a background shouls. Also accounts for parallax setting. + Point posOffset = new Vector2(MathF.Sin((Main.GlobalTimeWrappedHourly) * 0.03f + MathHelper.PiOver2) * 10 * tex.Width, MathF.Cos((Main.GlobalTimeWrappedHourly) * 0.1f + MathHelper.PiOver2) * 17 * tex.Height).ToPoint() - (Main.LocalPlayer.position * ViewportToGamesizeRatio * Main.caveParallax).ToPoint(); + + //Using a modulo to clamp the offset to within one texture size - the looping of the modulo looks seamless due to the texture looping + posOffset.X = posOffset.X % tex.Width; + posOffset.Y = posOffset.Y % tex.Height; + + Rectangle dest = new Rectangle(posOffset.X - tex.Width, posOffset.Y - tex.Height, (int)(tex.Width * repeatX), (int)(tex.Height * repeatY)); + + //We need the texture to loop, so we use a linearwrap sampler state. We draw it one extra texture size in all directions around the screen to provide buffer for the posOffset. + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise); + + spriteBatch.Draw( + tex, + destinationRectangle: dest, + sourceRectangle: new Rectangle(0, 0, (int)(tex.Width * repeatX), (int)(tex.Height * repeatY)), + color: Color.White * intensity + ); } - if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) - { - cinderColortoBe = Color.Transparent; - cinderColor = Color.Transparent; - return; - } - - NPC scal = Main.npc[CalamityGlobalNPC.SCal]; - bool cirrus = scal.ModNPC().cirrus; - float lifeRatio = scal.life / (float)scal.lifeMax; - - if (lifeRatio > 0.5f) - cinderColortoBe = Color.Lerp(cirrus ? Color.Pink : Color.Red, cirrus ? Color.Violet : Color.Crimson, Main.rand.NextFloat(0f, 1f)); - else if (lifeRatio > 0.3f || scal.ModNPC().postMusicHit == false) - cinderColortoBe = Color.Lerp(cirrus ? Color.Cyan : Color.Red, cirrus ? Color.DarkCyan : Color.Magenta, Main.rand.NextFloat(0f, 0.7f)); - else if (lifeRatio > 0.01f) - cinderColortoBe = Color.Lerp(cirrus ? Color.Pink : Color.Red, cirrus ? Color.Green : Color.Yellow, Main.rand.NextFloat(0f, 0.88f)); - else - cinderColortoBe = Color.Lerp(Color.Gray, Color.White, Main.rand.NextFloat(0.8f)); - - if (NPC.AnyNPCs(ModContent.NPCType()) == true && NPC.AnyNPCs(ModContent.NPCType()) == false) - cinderColortoBe = Color.Lerp(Color.MediumTurquoise, Color.Cyan, Main.rand.NextFloat(0.2f, 0.9f)); - if (NPC.AnyNPCs(ModContent.NPCType()) == true && NPC.AnyNPCs(ModContent.NPCType()) == false) - cinderColortoBe = Color.Lerp(Color.Magenta, Color.MediumVioletRed, Main.rand.NextFloat(0.2f, 0.9f)); - if (NPC.AnyNPCs(ModContent.NPCType()) == true && NPC.AnyNPCs(ModContent.NPCType()) == true) - cinderColortoBe = Color.Lerp(Color.Red, Color.IndianRed, Main.rand.NextFloat(0f, 1f)); - - cinderColor = Color.Lerp(cinderColor, cinderColortoBe, 0.0067f); - // Draw cinders. - Texture2D cinderTexture = ModContent.Request("CalamityMod/Skies/CalamitasCinder").Value; + + var cinderTexture = CalamityUtils.GetTextureEfficient(ref cinderTex, "CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; for (int i = 0; i < Cinders.Count; i++) { + float OpacityMult = 0.1f + 0.3f * ((MathF.Sin(Cinders[i].Time * 0.1f + Cinders[i].IdentityIndex) + 1) * 0.5f); Vector2 drawPosition = Cinders[i].Center - Main.screenPosition; - Color offsetDrawColor = cinderColor * 0.56f; - offsetDrawColor.A = 0; Vector2 cinderOrigin = cinderTexture.Size() * 0.5f; - for (int j = 0; j < 3; j++) - { - Vector2 offsetDrawPosition = drawPosition + (MathHelper.TwoPi * j / 3f).ToRotationVector2() * 1.4f; - spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderOrigin, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); - } - - spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderOrigin, Cinders[i].Scale, SpriteEffects.None, 0f); + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor * Cinders[i].Opacity * OpacityMult, 0f, cinderOrigin, Cinders[i].Scale * 0.15f, SpriteEffects.None, 0f); } } diff --git a/Skies/SkyTextureRefs.cs b/Skies/SkyTextureRefs.cs index 6e27c10ae5..57c2298af7 100644 --- a/Skies/SkyTextureRefs.cs +++ b/Skies/SkyTextureRefs.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria.ModLoader; diff --git a/Skies/SulphurSeaSky.cs b/Skies/SulphurSeaSky.cs index 2c85b7fa4d..102b1739df 100644 --- a/Skies/SulphurSeaSky.cs +++ b/Skies/SulphurSeaSky.cs @@ -1,10 +1,7 @@ -using CalamityMod.World; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.GameContent; using Terraria.Graphics.Effects; -using Terraria.ID; namespace CalamityMod.Skies { diff --git a/Sounds/CommonCalamitySounds.cs b/Sounds/CommonCalamitySounds.cs index 817b9a3b8f..ce89a487ea 100644 --- a/Sounds/CommonCalamitySounds.cs +++ b/Sounds/CommonCalamitySounds.cs @@ -4,52 +4,35 @@ namespace CalamityMod.Sounds { public static class CommonCalamitySounds { - public static readonly SoundStyle ExoHitSound = new("CalamityMod/Sounds/NPCHit/ExoHit", 4) { Volume = 0.4f }; - - public static readonly SoundStyle ExoDeathSound = new("CalamityMod/Sounds/NPCKilled/ExoDeath") { MaxInstances = 1 }; - - public static readonly SoundStyle OtherwordlyHitSound = new("CalamityMod/Sounds/NPCHit/OtherworldlyHit"); - + public static readonly SoundStyle AstralNPCDeathSound = new("CalamityMod/Sounds/NPCKilled/AstralEnemyDeath") { Volume = 0.7f }; public static readonly SoundStyle AstralNPCHitSound = new("CalamityMod/Sounds/NPCHit/AstralEnemyHit", 3); - public static readonly SoundStyle AstralNPCDeathSound = new("CalamityMod/Sounds/NPCKilled/AstralEnemyDeath") { Volume = 0.7f }; - public static readonly SoundStyle WulfrumNPCDeathSound = new("CalamityMod/Sounds/NPCKilled/WulfrumDeath"); - - public static readonly SoundStyle PlagueBoomSound = new("CalamityMod/Sounds/Custom/PlagueSounds/PlagueBoom", 4); - - public static readonly SoundStyle WyrmScreamSound = new("CalamityMod/Sounds/Custom/WyrmScream"); - - public static readonly SoundStyle LightningSound = new("CalamityMod/Sounds/Custom/LightningStrike") { Volume = 1.5f }; //This is just the regular SoundID.Thunder sound, except its only the first variant - - public static readonly SoundStyle LaserCannonSound = new("CalamityMod/Sounds/Item/LaserCannon") { Volume = 0.85f }; - public static readonly SoundStyle ELRFireSound = new("CalamityMod/Sounds/Item/ELRFire"); //What does ELR stand for - + public static readonly SoundStyle ExoDeathSound = new("CalamityMod/Sounds/NPCKilled/ExoDeath") { MaxInstances = 1 }; + public static readonly SoundStyle ExoHitSound = new("CalamityMod/Sounds/NPCHit/ExoHit", 4) { Volume = 0.4f }; public static readonly SoundStyle ExoLaserShootSound = new("CalamityMod/Sounds/Custom/ExoMechs/ExoLaserShoot"); - public static readonly SoundStyle ExoPlasmaExplosionSound = new("CalamityMod/Sounds/Custom/ExoMechs/ExoPlasmaExplosion", 2); - public static readonly SoundStyle ExoPlasmaShootSound = new("CalamityMod/Sounds/Custom/ExoMechs/ExoPlasmaShoot"); - public static readonly SoundStyle LargeWeaponFireSound = new("CalamityMod/Sounds/Item/LargeWeaponFire"); - - public static readonly SoundStyle GaussWeaponFire = new("CalamityMod/Sounds/Item/GaussWeaponFire"); - public static readonly SoundStyle FlareSound = new("CalamityMod/Sounds/Item/FlareSound"); - public static readonly SoundStyle PlasmaBoltSound = new("CalamityMod/Sounds/Item/PlasmaBolt") { Volume = 0.8f }; - - public static readonly SoundStyle PlasmaBlastSound = new("CalamityMod/Sounds/Item/PlasmaBlast"); + public static readonly SoundStyle LargeWeaponFireSound = new("CalamityMod/Sounds/Item/LargeWeaponFire"); + public static readonly SoundStyle LaserCannonSound = new("CalamityMod/Sounds/Item/LaserCannon") { Volume = 0.85f }; + public static readonly SoundStyle LightningSound = new("CalamityMod/Sounds/Custom/LightningStrike") { Volume = 1.6f }; // This is just the regular SoundID.Thunder sound, except its only the first variant + public static readonly SoundStyle LouderPhantomPhoenix = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix", 3); public static readonly SoundStyle MeatySlashSound = new("CalamityMod/Sounds/Custom/MeatySlash"); - public static readonly SoundStyle SwiftSliceSound = new("CalamityMod/Sounds/Custom/SwiftSlice"); + public static readonly SoundStyle PlagueBoomSound = new("CalamityMod/Sounds/Custom/PlagueSounds/PlagueBoom", 4); + public static readonly SoundStyle PlasmaBoltSound = new("CalamityMod/Sounds/Item/PlasmaBolt") { Volume = 0.8f }; + public static readonly SoundStyle PlatingMine = new("CalamityMod/Sounds/Custom/PlatingMine", 3); public static readonly SoundStyle ScissorGuillotineSnapSound = new("CalamityMod/Sounds/Custom/ScissorGuillotineSnap"); + public static readonly SoundStyle SwiftSliceSound = new("CalamityMod/Sounds/Custom/SwiftSlice"); - public static readonly SoundStyle LouderPhantomPhoenix = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix", 3); - - public static readonly SoundStyle LouderSwingWoosh = new("CalamityMod/Sounds/Custom/LoudSwingWoosh"); + public static readonly SoundStyle VoidstoneMine = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; + public static readonly SoundStyle WulfrumNPCDeathSound = new("CalamityMod/Sounds/NPCKilled/WulfrumDeath"); + public static readonly SoundStyle WyrmScreamSound = new("CalamityMod/Sounds/Custom/WyrmScream"); } } diff --git a/Sounds/Custom/AbilitySounds/DarklightEnergyCharged.ogg b/Sounds/Custom/AbilitySounds/DarklightEnergyCharged.ogg new file mode 100644 index 0000000000..e02bcaa5b0 Binary files /dev/null and b/Sounds/Custom/AbilitySounds/DarklightEnergyCharged.ogg differ diff --git a/Sounds/Custom/AdrenalineMajorLossGFB.mp3 b/Sounds/Custom/AdrenalineMajorLossGFB.mp3 deleted file mode 100644 index b56ea7eeaf..0000000000 Binary files a/Sounds/Custom/AdrenalineMajorLossGFB.mp3 and /dev/null differ diff --git a/Sounds/Custom/AdrenalineMajorLossGFB.ogg b/Sounds/Custom/AdrenalineMajorLossGFB.ogg new file mode 100644 index 0000000000..d1175cc664 Binary files /dev/null and b/Sounds/Custom/AdrenalineMajorLossGFB.ogg differ diff --git a/Sounds/Custom/BEES/Names.txt b/Sounds/Custom/BEES/Names.txt index 25875d8fef..6fafe235e9 100644 --- a/Sounds/Custom/BEES/Names.txt +++ b/Sounds/Custom/BEES/Names.txt @@ -6,8 +6,8 @@ Names: 5 - moonburn 6 - Ozzatron 7 - Rebecca -8 - Shayy -9 - StipulatedVenus -10 - Xyk -11 - Shade -12 - YuH \ No newline at end of file +8 - StipulatedVenus +9 - Xyk +10 - Shade +11 - YuH +12 - ENNWAY diff --git a/Sounds/Custom/BEES/bees10.ogg b/Sounds/Custom/BEES/bees10.ogg index 0889776deb..e81ebe6c9b 100644 Binary files a/Sounds/Custom/BEES/bees10.ogg and b/Sounds/Custom/BEES/bees10.ogg differ diff --git a/Sounds/Custom/BEES/bees11.ogg b/Sounds/Custom/BEES/bees11.ogg index e81ebe6c9b..222a4aab6b 100644 Binary files a/Sounds/Custom/BEES/bees11.ogg and b/Sounds/Custom/BEES/bees11.ogg differ diff --git a/Sounds/Custom/BEES/bees12.ogg b/Sounds/Custom/BEES/bees12.ogg index 222a4aab6b..e7c35d9313 100644 Binary files a/Sounds/Custom/BEES/bees12.ogg and b/Sounds/Custom/BEES/bees12.ogg differ diff --git a/Sounds/Custom/BEES/bees8.ogg b/Sounds/Custom/BEES/bees8.ogg index 677b47fc65..094a103a5b 100644 Binary files a/Sounds/Custom/BEES/bees8.ogg and b/Sounds/Custom/BEES/bees8.ogg differ diff --git a/Sounds/Custom/BEES/bees9.ogg b/Sounds/Custom/BEES/bees9.ogg index 094a103a5b..0889776deb 100644 Binary files a/Sounds/Custom/BEES/bees9.ogg and b/Sounds/Custom/BEES/bees9.ogg differ diff --git a/Sounds/Custom/BazookaRocket.ogg b/Sounds/Custom/BazookaRocket.ogg deleted file mode 100644 index a2c5f35447..0000000000 Binary files a/Sounds/Custom/BazookaRocket.ogg and /dev/null differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodShot.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodShot.ogg new file mode 100644 index 0000000000..bc2aad3652 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodShot.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Death_Roar.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Death_Roar.ogg new file mode 100644 index 0000000000..86a206fb32 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Death_Roar.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion1.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion1.ogg new file mode 100644 index 0000000000..5fc9d93db0 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion1.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion2.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion2.ogg new file mode 100644 index 0000000000..063177325c Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion2.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl1.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl1.ogg new file mode 100644 index 0000000000..e2265ccb03 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl1.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl2.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl2.ogg new file mode 100644 index 0000000000..18e53d498b Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl2.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Laugh.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Laugh.ogg new file mode 100644 index 0000000000..d8f5552642 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Laugh.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Roar.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Roar.ogg new file mode 100644 index 0000000000..c760b3f0b3 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Roar.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Down.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Down.ogg new file mode 100644 index 0000000000..b3c0e2bd33 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Down.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Up.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Up.ogg new file mode 100644 index 0000000000..479f4531d8 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Shield_Up.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Short_Roar.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Short_Roar.ogg new file mode 100644 index 0000000000..d5963e58d5 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Short_Roar.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit1.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit1.ogg new file mode 100644 index 0000000000..24e83b6935 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit1.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit2.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit2.ogg new file mode 100644 index 0000000000..50f67626bc Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit2.ogg differ diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit3.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit3.ogg new file mode 100644 index 0000000000..e706071abd Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Stun_Hit3.ogg differ diff --git a/Sounds/Custom/BubblyBurst.ogg b/Sounds/Custom/BubblyBurst.ogg new file mode 100644 index 0000000000..3db8409d9b Binary files /dev/null and b/Sounds/Custom/BubblyBurst.ogg differ diff --git a/Sounds/Custom/CalamitasClone/BulletHellEnd.ogg b/Sounds/Custom/CalamitasClone/BulletHellEnd.ogg index 08b4e36553..99e29dd7d2 100644 Binary files a/Sounds/Custom/CalamitasClone/BulletHellEnd.ogg and b/Sounds/Custom/CalamitasClone/BulletHellEnd.ogg differ diff --git a/Sounds/Custom/CalamitasClone/BulletHellEnding.ogg b/Sounds/Custom/CalamitasClone/BulletHellEnding.ogg new file mode 100644 index 0000000000..7ed1d7c40e Binary files /dev/null and b/Sounds/Custom/CalamitasClone/BulletHellEnding.ogg differ diff --git a/Sounds/Custom/CalamitasClone/BulletHellEnding.wav b/Sounds/Custom/CalamitasClone/BulletHellEnding.wav deleted file mode 100644 index 3f54027802..0000000000 Binary files a/Sounds/Custom/CalamitasClone/BulletHellEnding.wav and /dev/null differ diff --git a/Sounds/Custom/CalamitasClone/CalCloneDash1.ogg b/Sounds/Custom/CalamitasClone/CalCloneDash1.ogg new file mode 100644 index 0000000000..da889da7a9 Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalCloneDash1.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalCloneDash1.wav b/Sounds/Custom/CalamitasClone/CalCloneDash1.wav deleted file mode 100644 index cbdacec6c6..0000000000 Binary files a/Sounds/Custom/CalamitasClone/CalCloneDash1.wav and /dev/null differ diff --git a/Sounds/Custom/CalamitasClone/CalCloneDash2.ogg b/Sounds/Custom/CalamitasClone/CalCloneDash2.ogg new file mode 100644 index 0000000000..55cf49223d Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalCloneDash2.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalCloneDash2.wav b/Sounds/Custom/CalamitasClone/CalCloneDash2.wav deleted file mode 100644 index d055df0041..0000000000 Binary files a/Sounds/Custom/CalamitasClone/CalCloneDash2.wav and /dev/null differ diff --git a/Sounds/Custom/CalamitasClone/CalCloneDash3.ogg b/Sounds/Custom/CalamitasClone/CalCloneDash3.ogg new file mode 100644 index 0000000000..63bdc7ee7c Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalCloneDash3.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalCloneDash3.wav b/Sounds/Custom/CalamitasClone/CalCloneDash3.wav deleted file mode 100644 index 807f5d0303..0000000000 Binary files a/Sounds/Custom/CalamitasClone/CalCloneDash3.wav and /dev/null differ diff --git a/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit1.ogg b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit1.ogg new file mode 100644 index 0000000000..20646ea76a Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit1.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit2.ogg b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit2.ogg new file mode 100644 index 0000000000..a671e6aae9 Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit2.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit3.ogg b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit3.ogg new file mode 100644 index 0000000000..4070e0539a Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit3.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit4.ogg b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit4.ogg new file mode 100644 index 0000000000..4194207fc3 Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalClone_BigFireballBit4.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalClone_Explosion1.ogg b/Sounds/Custom/CalamitasClone/CalClone_Explosion1.ogg new file mode 100644 index 0000000000..2430ca7bb7 Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalClone_Explosion1.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalClone_Explosion2.ogg b/Sounds/Custom/CalamitasClone/CalClone_Explosion2.ogg new file mode 100644 index 0000000000..0d8c739792 Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalClone_Explosion2.ogg differ diff --git a/Sounds/Custom/CalamitasClone/CalClone_Explosion3.ogg b/Sounds/Custom/CalamitasClone/CalClone_Explosion3.ogg new file mode 100644 index 0000000000..6a0bf6f93e Binary files /dev/null and b/Sounds/Custom/CalamitasClone/CalClone_Explosion3.ogg differ diff --git a/Sounds/Custom/DevourerRiftBuilding.ogg b/Sounds/Custom/DevourerRiftBuilding.ogg new file mode 100644 index 0000000000..1872e0b733 Binary files /dev/null and b/Sounds/Custom/DevourerRiftBuilding.ogg differ diff --git a/Sounds/Custom/DevourerRiftOpen.ogg b/Sounds/Custom/DevourerRiftOpen.ogg new file mode 100644 index 0000000000..3e5600b1b0 Binary files /dev/null and b/Sounds/Custom/DevourerRiftOpen.ogg differ diff --git a/Sounds/Custom/DifficultySelection/Death_Mode_Select.ogg b/Sounds/Custom/DifficultySelection/Death_Mode_Select.ogg new file mode 100644 index 0000000000..fad096ce8d Binary files /dev/null and b/Sounds/Custom/DifficultySelection/Death_Mode_Select.ogg differ diff --git a/Sounds/Custom/DifficultySelection/Legendary_Mode_Select.ogg b/Sounds/Custom/DifficultySelection/Legendary_Mode_Select.ogg new file mode 100644 index 0000000000..5a1b22cf4e Binary files /dev/null and b/Sounds/Custom/DifficultySelection/Legendary_Mode_Select.ogg differ diff --git a/Sounds/Custom/DifficultySelection/Malice_Mode_Select.ogg b/Sounds/Custom/DifficultySelection/Malice_Mode_Select.ogg new file mode 100644 index 0000000000..ba0b09c5b9 Binary files /dev/null and b/Sounds/Custom/DifficultySelection/Malice_Mode_Select.ogg differ diff --git a/Sounds/Custom/DifficultySelection/Revengeance_Mode_Select.ogg b/Sounds/Custom/DifficultySelection/Revengeance_Mode_Select.ogg new file mode 100644 index 0000000000..52418e8589 Binary files /dev/null and b/Sounds/Custom/DifficultySelection/Revengeance_Mode_Select.ogg differ diff --git a/Sounds/Custom/DoGFireball.ogg b/Sounds/Custom/DoGFireball.ogg new file mode 100644 index 0000000000..a52798a895 Binary files /dev/null and b/Sounds/Custom/DoGFireball.ogg differ diff --git a/Sounds/Custom/DoGLaserWallBigAttack.ogg b/Sounds/Custom/DoGLaserWallBigAttack.ogg new file mode 100644 index 0000000000..ee5be64033 Binary files /dev/null and b/Sounds/Custom/DoGLaserWallBigAttack.ogg differ diff --git a/Sounds/Custom/DoGLaserWallBigAttack2.ogg b/Sounds/Custom/DoGLaserWallBigAttack2.ogg new file mode 100644 index 0000000000..ab3c26aceb Binary files /dev/null and b/Sounds/Custom/DoGLaserWallBigAttack2.ogg differ diff --git a/Sounds/Custom/DoGLaserWallLightAttack.ogg b/Sounds/Custom/DoGLaserWallLightAttack.ogg new file mode 100644 index 0000000000..a409d56d6e Binary files /dev/null and b/Sounds/Custom/DoGLaserWallLightAttack.ogg differ diff --git a/Sounds/Custom/DoGLaserWallSpawn.ogg b/Sounds/Custom/DoGLaserWallSpawn.ogg new file mode 100644 index 0000000000..fc576f4395 Binary files /dev/null and b/Sounds/Custom/DoGLaserWallSpawn.ogg differ diff --git a/Sounds/Custom/EidolonWyrmRoarClose.ogg b/Sounds/Custom/EidolonWyrmRoarClose.ogg deleted file mode 100644 index 4f908dd375..0000000000 Binary files a/Sounds/Custom/EidolonWyrmRoarClose.ogg and /dev/null differ diff --git a/Sounds/Custom/ExoMechs/THanosGFBeam.ogg b/Sounds/Custom/ExoMechs/THanosGFBeam.ogg new file mode 100644 index 0000000000..6bd2111021 Binary files /dev/null and b/Sounds/Custom/ExoMechs/THanosGFBeam.ogg differ diff --git a/Sounds/Custom/GFB/Jesus.ogg b/Sounds/Custom/GFB/Jesus.ogg new file mode 100644 index 0000000000..4cc26fb6f7 Binary files /dev/null and b/Sounds/Custom/GFB/Jesus.ogg differ diff --git a/Sounds/Custom/GFB/OceanShieldParryGFB.ogg b/Sounds/Custom/GFB/OceanShieldParryGFB.ogg deleted file mode 100644 index 89985cebee..0000000000 Binary files a/Sounds/Custom/GFB/OceanShieldParryGFB.ogg and /dev/null differ diff --git a/Sounds/Custom/GFB/SevenTrebleClefSouls.ogg b/Sounds/Custom/GFB/SevenTrebleClefSouls.ogg new file mode 100644 index 0000000000..000d511566 Binary files /dev/null and b/Sounds/Custom/GFB/SevenTrebleClefSouls.ogg differ diff --git a/Sounds/Custom/GildedAxolotlAlert.ogg b/Sounds/Custom/GildedAxolotlAlert.ogg new file mode 100644 index 0000000000..bdeaa79fec Binary files /dev/null and b/Sounds/Custom/GildedAxolotlAlert.ogg differ diff --git a/Sounds/Custom/GildedAxolotlNeuronActivation.ogg b/Sounds/Custom/GildedAxolotlNeuronActivation.ogg new file mode 100644 index 0000000000..103aa7c6e5 Binary files /dev/null and b/Sounds/Custom/GildedAxolotlNeuronActivation.ogg differ diff --git a/Sounds/Custom/GildedAxolotlVocalStim1.ogg b/Sounds/Custom/GildedAxolotlVocalStim1.ogg new file mode 100644 index 0000000000..d8ade672af Binary files /dev/null and b/Sounds/Custom/GildedAxolotlVocalStim1.ogg differ diff --git a/Sounds/Custom/GildedAxolotlVocalStim2.ogg b/Sounds/Custom/GildedAxolotlVocalStim2.ogg new file mode 100644 index 0000000000..ea1053a218 Binary files /dev/null and b/Sounds/Custom/GildedAxolotlVocalStim2.ogg differ diff --git a/Sounds/Custom/GungeonCreditMusic.mp3 b/Sounds/Custom/GungeonCreditMusic.mp3 deleted file mode 100644 index 801bdb972e..0000000000 Binary files a/Sounds/Custom/GungeonCreditMusic.mp3 and /dev/null differ diff --git a/Sounds/Custom/GungeonCreditMusic.ogg b/Sounds/Custom/GungeonCreditMusic.ogg new file mode 100644 index 0000000000..4a6a455070 Binary files /dev/null and b/Sounds/Custom/GungeonCreditMusic.ogg differ diff --git a/Sounds/Custom/LightningTelegraph.ogg b/Sounds/Custom/LightningTelegraph.ogg new file mode 100644 index 0000000000..3a3d95c15f Binary files /dev/null and b/Sounds/Custom/LightningTelegraph.ogg differ diff --git a/Sounds/Custom/OldDukeDash.ogg b/Sounds/Custom/OldDukeDash.ogg new file mode 100644 index 0000000000..8ed052153b Binary files /dev/null and b/Sounds/Custom/OldDukeDash.ogg differ diff --git a/Sounds/Custom/OldDukeDashP3.ogg b/Sounds/Custom/OldDukeDashP3.ogg new file mode 100644 index 0000000000..eda6b95524 Binary files /dev/null and b/Sounds/Custom/OldDukeDashP3.ogg differ diff --git a/Sounds/Custom/OldDukeVortexSpawn.ogg b/Sounds/Custom/OldDukeVortexSpawn.ogg new file mode 100644 index 0000000000..c11112ea24 Binary files /dev/null and b/Sounds/Custom/OldDukeVortexSpawn.ogg differ diff --git a/Sounds/Custom/Polterghast/PolterSpook1.ogg b/Sounds/Custom/Polterghast/PolterSpook1.ogg deleted file mode 100644 index 55faa22baa..0000000000 Binary files a/Sounds/Custom/Polterghast/PolterSpook1.ogg and /dev/null differ diff --git a/Sounds/Custom/Polterghast/PolterSpook2.ogg b/Sounds/Custom/Polterghast/PolterSpook2.ogg deleted file mode 100644 index 698533a8bd..0000000000 Binary files a/Sounds/Custom/Polterghast/PolterSpook2.ogg and /dev/null differ diff --git a/Sounds/Custom/Polterghast/PolterSpook3.ogg b/Sounds/Custom/Polterghast/PolterSpook3.ogg deleted file mode 100644 index b45fca9b99..0000000000 Binary files a/Sounds/Custom/Polterghast/PolterSpook3.ogg and /dev/null differ diff --git a/Sounds/Custom/Polterghast/PolterSpook4.ogg b/Sounds/Custom/Polterghast/PolterSpook4.ogg deleted file mode 100644 index 8f7ebdb17b..0000000000 Binary files a/Sounds/Custom/Polterghast/PolterSpook4.ogg and /dev/null differ diff --git a/Sounds/Custom/RedJewelModeShift.ogg b/Sounds/Custom/RedJewelModeShift.ogg new file mode 100644 index 0000000000..873945c7bf Binary files /dev/null and b/Sounds/Custom/RedJewelModeShift.ogg differ diff --git a/Sounds/Custom/SCalSounds/BrimstoneSkullSound.ogg b/Sounds/Custom/SCalSounds/BrimstoneSkullSound.ogg deleted file mode 100644 index 0b4c55ce85..0000000000 Binary files a/Sounds/Custom/SCalSounds/BrimstoneSkullSound.ogg and /dev/null differ diff --git a/Sounds/Custom/SCalSounds/CatastropheResonanceSlash1.ogg b/Sounds/Custom/SCalSounds/CatastropheResonanceSlash.ogg similarity index 100% rename from Sounds/Custom/SCalSounds/CatastropheResonanceSlash1.ogg rename to Sounds/Custom/SCalSounds/CatastropheResonanceSlash.ogg diff --git a/Sounds/Custom/ShoreskipperGrunt1.ogg b/Sounds/Custom/ShoreskipperGrunt1.ogg new file mode 100644 index 0000000000..7ed9fbfb1c Binary files /dev/null and b/Sounds/Custom/ShoreskipperGrunt1.ogg differ diff --git a/Sounds/Custom/ShoreskipperGrunt2.ogg b/Sounds/Custom/ShoreskipperGrunt2.ogg new file mode 100644 index 0000000000..bbd930bcc8 Binary files /dev/null and b/Sounds/Custom/ShoreskipperGrunt2.ogg differ diff --git a/Sounds/Custom/ShoreskipperSighting.ogg b/Sounds/Custom/ShoreskipperSighting.ogg new file mode 100644 index 0000000000..19e5efe1a4 Binary files /dev/null and b/Sounds/Custom/ShoreskipperSighting.ogg differ diff --git a/Sounds/Custom/StormlionAltIdle1.ogg b/Sounds/Custom/StormlionAltIdle1.ogg new file mode 100644 index 0000000000..6531ae0bf1 Binary files /dev/null and b/Sounds/Custom/StormlionAltIdle1.ogg differ diff --git a/Sounds/Custom/StormlionAltIdle2.ogg b/Sounds/Custom/StormlionAltIdle2.ogg new file mode 100644 index 0000000000..cbd3f0835a Binary files /dev/null and b/Sounds/Custom/StormlionAltIdle2.ogg differ diff --git a/Sounds/Custom/StormlionAltShoot.ogg b/Sounds/Custom/StormlionAltShoot.ogg new file mode 100644 index 0000000000..e70429c360 Binary files /dev/null and b/Sounds/Custom/StormlionAltShoot.ogg differ diff --git a/Sounds/Custom/ThunderStrike.ogg b/Sounds/Custom/ThunderStrike.ogg deleted file mode 100644 index 792f62b553..0000000000 Binary files a/Sounds/Custom/ThunderStrike.ogg and /dev/null differ diff --git a/Sounds/Custom/YanmeiKnifeExpire.ogg b/Sounds/Custom/YanmeiKnifeExpire.ogg deleted file mode 100644 index 43f93869d1..0000000000 Binary files a/Sounds/Custom/YanmeiKnifeExpire.ogg and /dev/null differ diff --git a/Sounds/Item/AmidiasTrident_Raise.ogg b/Sounds/Item/AmidiasTrident_Raise.ogg new file mode 100644 index 0000000000..9cdd29c1d9 Binary files /dev/null and b/Sounds/Item/AmidiasTrident_Raise.ogg differ diff --git a/Sounds/Item/AmidiasTrident_Spin.ogg b/Sounds/Item/AmidiasTrident_Spin.ogg new file mode 100644 index 0000000000..87219a19db Binary files /dev/null and b/Sounds/Item/AmidiasTrident_Spin.ogg differ diff --git a/Sounds/Item/AmidiasTrident_Stab1.ogg b/Sounds/Item/AmidiasTrident_Stab1.ogg new file mode 100644 index 0000000000..3ece449d3c Binary files /dev/null and b/Sounds/Item/AmidiasTrident_Stab1.ogg differ diff --git a/Sounds/Item/AmidiasTrident_Stab2.ogg b/Sounds/Item/AmidiasTrident_Stab2.ogg new file mode 100644 index 0000000000..dc3c38898a Binary files /dev/null and b/Sounds/Item/AmidiasTrident_Stab2.ogg differ diff --git a/Sounds/Item/AugerBigSlash.ogg b/Sounds/Item/AugerBigSlash.ogg new file mode 100644 index 0000000000..d068625bfd Binary files /dev/null and b/Sounds/Item/AugerBigSlash.ogg differ diff --git a/Sounds/Item/AugerHit.ogg b/Sounds/Item/AugerHit.ogg new file mode 100644 index 0000000000..26b099ea3b Binary files /dev/null and b/Sounds/Item/AugerHit.ogg differ diff --git a/Sounds/Item/AugerPull.ogg b/Sounds/Item/AugerPull.ogg new file mode 100644 index 0000000000..24db60a049 Binary files /dev/null and b/Sounds/Item/AugerPull.ogg differ diff --git a/Sounds/Item/AugerSlash1.ogg b/Sounds/Item/AugerSlash1.ogg new file mode 100644 index 0000000000..511f3dbee1 Binary files /dev/null and b/Sounds/Item/AugerSlash1.ogg differ diff --git a/Sounds/Item/AugerSlash2.ogg b/Sounds/Item/AugerSlash2.ogg new file mode 100644 index 0000000000..d533e89a27 Binary files /dev/null and b/Sounds/Item/AugerSlash2.ogg differ diff --git a/Sounds/Item/AugerWindup.ogg b/Sounds/Item/AugerWindup.ogg new file mode 100644 index 0000000000..1264dee1c5 Binary files /dev/null and b/Sounds/Item/AugerWindup.ogg differ diff --git a/Sounds/Item/BatholithBangleSound.ogg b/Sounds/Item/BatholithBangleSound.ogg new file mode 100644 index 0000000000..a9093f226f Binary files /dev/null and b/Sounds/Item/BatholithBangleSound.ogg differ diff --git a/Sounds/Item/BlackGlassBandSound.ogg b/Sounds/Item/BlackGlassBandSound.ogg new file mode 100644 index 0000000000..9f93b8508e Binary files /dev/null and b/Sounds/Item/BlackGlassBandSound.ogg differ diff --git a/Sounds/Item/DampExplosion.ogg b/Sounds/Item/DampExplosion.ogg new file mode 100644 index 0000000000..b153edeeaa Binary files /dev/null and b/Sounds/Item/DampExplosion.ogg differ diff --git a/Sounds/Item/EffervescenceBurst.ogg b/Sounds/Item/EffervescenceBurst.ogg new file mode 100644 index 0000000000..bdffb45db5 Binary files /dev/null and b/Sounds/Item/EffervescenceBurst.ogg differ diff --git a/Sounds/Item/EffervescenceFire.ogg b/Sounds/Item/EffervescenceFire.ogg new file mode 100644 index 0000000000..585f359f12 Binary files /dev/null and b/Sounds/Item/EffervescenceFire.ogg differ diff --git a/Sounds/Item/EffervescencePop.ogg b/Sounds/Item/EffervescencePop.ogg new file mode 100644 index 0000000000..9f8889d1bb Binary files /dev/null and b/Sounds/Item/EffervescencePop.ogg differ diff --git a/Sounds/Item/EnergyRifleFire.ogg b/Sounds/Item/EnergyRifleFire.ogg deleted file mode 100644 index 855a605b46..0000000000 Binary files a/Sounds/Item/EnergyRifleFire.ogg and /dev/null differ diff --git a/Sounds/Item/FestiveJingle.ogg b/Sounds/Item/FestiveJingle.ogg new file mode 100644 index 0000000000..2e311faad5 Binary files /dev/null and b/Sounds/Item/FestiveJingle.ogg differ diff --git a/Sounds/Item/GatlingLaserFireEnd.ogg b/Sounds/Item/GatlingLaserFireEnd.ogg deleted file mode 100644 index b1f2180832..0000000000 Binary files a/Sounds/Item/GatlingLaserFireEnd.ogg and /dev/null differ diff --git a/Sounds/Item/GatlingLaserFireLoop.ogg b/Sounds/Item/GatlingLaserFireLoop.ogg deleted file mode 100644 index 85123255a8..0000000000 Binary files a/Sounds/Item/GatlingLaserFireLoop.ogg and /dev/null differ diff --git a/Sounds/Item/GatlingLaserFireStart.ogg b/Sounds/Item/GatlingLaserFireStart.ogg deleted file mode 100644 index b965fb567f..0000000000 Binary files a/Sounds/Item/GatlingLaserFireStart.ogg and /dev/null differ diff --git a/Sounds/Item/GaussWeaponFire.ogg b/Sounds/Item/GaussWeaponFire.ogg deleted file mode 100644 index e15236ce8e..0000000000 Binary files a/Sounds/Item/GaussWeaponFire.ogg and /dev/null differ diff --git a/Sounds/Item/GeliticBladeSwing1.ogg b/Sounds/Item/GeliticBladeSwing1.ogg new file mode 100644 index 0000000000..b005163e8b Binary files /dev/null and b/Sounds/Item/GeliticBladeSwing1.ogg differ diff --git a/Sounds/Item/GeliticBladeSwing2.ogg b/Sounds/Item/GeliticBladeSwing2.ogg new file mode 100644 index 0000000000..ca2674232e Binary files /dev/null and b/Sounds/Item/GeliticBladeSwing2.ogg differ diff --git a/Sounds/Item/GunShotSmallHeavy.ogg b/Sounds/Item/GunShotSmallHeavy.ogg deleted file mode 100644 index b23c4ff131..0000000000 Binary files a/Sounds/Item/GunShotSmallHeavy.ogg and /dev/null differ diff --git a/Sounds/Item/HeliumFlashReady.ogg b/Sounds/Item/HeliumFlashReady.ogg index 69bfb600bc..355124aaa7 100644 Binary files a/Sounds/Item/HeliumFlashReady.ogg and b/Sounds/Item/HeliumFlashReady.ogg differ diff --git a/Sounds/Item/HeliumFlashReadyAlt.ogg b/Sounds/Item/HeliumFlashReadyAlt.ogg deleted file mode 100644 index 355124aaa7..0000000000 Binary files a/Sounds/Item/HeliumFlashReadyAlt.ogg and /dev/null differ diff --git a/Sounds/Item/HolyFireBulletExplosion.ogg b/Sounds/Item/HolyFireBulletExplosion.ogg index b153edeeaa..a802c20625 100644 Binary files a/Sounds/Item/HolyFireBulletExplosion.ogg and b/Sounds/Item/HolyFireBulletExplosion.ogg differ diff --git a/Sounds/Item/HyperiusOverflow.ogg b/Sounds/Item/HyperiusOverflow.ogg new file mode 100644 index 0000000000..772d253f6a Binary files /dev/null and b/Sounds/Item/HyperiusOverflow.ogg differ diff --git a/Sounds/Item/LargeMechGaussRifle.ogg b/Sounds/Item/LargeMechGaussRifle.ogg deleted file mode 100644 index fd91b44c4e..0000000000 Binary files a/Sounds/Item/LargeMechGaussRifle.ogg and /dev/null differ diff --git a/Sounds/Item/LaserBurn.ogg b/Sounds/Item/LaserBurn.ogg index 4bb07b3d93..feea7d8cb8 100644 Binary files a/Sounds/Item/LaserBurn.ogg and b/Sounds/Item/LaserBurn.ogg differ diff --git a/Sounds/Item/LaserRifleFire.ogg b/Sounds/Item/LaserRifleFire.ogg deleted file mode 100644 index 91f7b18d56..0000000000 Binary files a/Sounds/Item/LaserRifleFire.ogg and /dev/null differ diff --git a/Sounds/Item/LightCatch.ogg b/Sounds/Item/LightCatch.ogg new file mode 100644 index 0000000000..c76ef70c6f Binary files /dev/null and b/Sounds/Item/LightCatch.ogg differ diff --git a/Sounds/Item/LightMetal.ogg b/Sounds/Item/LightMetal.ogg new file mode 100644 index 0000000000..4b6ac95eb0 Binary files /dev/null and b/Sounds/Item/LightMetal.ogg differ diff --git a/Sounds/Item/LightThrow.ogg b/Sounds/Item/LightThrow.ogg new file mode 100644 index 0000000000..5bd9aa44f1 Binary files /dev/null and b/Sounds/Item/LightThrow.ogg differ diff --git a/Sounds/Item/LucreciaBoltFire.ogg b/Sounds/Item/LucreciaBoltFire.ogg new file mode 100644 index 0000000000..1f189852b1 Binary files /dev/null and b/Sounds/Item/LucreciaBoltFire.ogg differ diff --git a/Sounds/Item/LunicShot1.ogg b/Sounds/Item/LunicShot1.ogg index c7166fea88..ecd913e659 100644 Binary files a/Sounds/Item/LunicShot1.ogg and b/Sounds/Item/LunicShot1.ogg differ diff --git a/Sounds/Item/LunicShot2.ogg b/Sounds/Item/LunicShot2.ogg index bcea333ff4..26df1ef8e2 100644 Binary files a/Sounds/Item/LunicShot2.ogg and b/Sounds/Item/LunicShot2.ogg differ diff --git a/Sounds/Item/M1GarandPing.ogg b/Sounds/Item/M1GarandPing.ogg new file mode 100644 index 0000000000..f05bb8a0da Binary files /dev/null and b/Sounds/Item/M1GarandPing.ogg differ diff --git a/Sounds/Item/M1GarandReload.ogg b/Sounds/Item/M1GarandReload.ogg new file mode 100644 index 0000000000..d43965eff8 Binary files /dev/null and b/Sounds/Item/M1GarandReload.ogg differ diff --git a/Sounds/Item/MetalScrape.ogg b/Sounds/Item/MetalScrape.ogg deleted file mode 100644 index 2f1963610a..0000000000 Binary files a/Sounds/Item/MetalScrape.ogg and /dev/null differ diff --git a/Sounds/Item/MittFail.ogg b/Sounds/Item/MittFail.ogg new file mode 100644 index 0000000000..b7f210727f Binary files /dev/null and b/Sounds/Item/MittFail.ogg differ diff --git a/Sounds/Item/MittHit.ogg b/Sounds/Item/MittHit.ogg new file mode 100644 index 0000000000..0faac84a5e Binary files /dev/null and b/Sounds/Item/MittHit.ogg differ diff --git a/Sounds/Item/MittReadyPalm.ogg b/Sounds/Item/MittReadyPalm.ogg new file mode 100644 index 0000000000..c786f75f8f Binary files /dev/null and b/Sounds/Item/MittReadyPalm.ogg differ diff --git a/Sounds/Item/MittThrust.ogg b/Sounds/Item/MittThrust.ogg new file mode 100644 index 0000000000..342b6df3a9 Binary files /dev/null and b/Sounds/Item/MittThrust.ogg differ diff --git a/Sounds/Item/MittWelding/Weld1.ogg b/Sounds/Item/MittWelding/Weld1.ogg new file mode 100644 index 0000000000..87a68dceac Binary files /dev/null and b/Sounds/Item/MittWelding/Weld1.ogg differ diff --git a/Sounds/Item/MittWelding/Weld2.ogg b/Sounds/Item/MittWelding/Weld2.ogg new file mode 100644 index 0000000000..87a68dceac Binary files /dev/null and b/Sounds/Item/MittWelding/Weld2.ogg differ diff --git a/Sounds/Item/MittWelding/Weld3.ogg b/Sounds/Item/MittWelding/Weld3.ogg new file mode 100644 index 0000000000..87a68dceac Binary files /dev/null and b/Sounds/Item/MittWelding/Weld3.ogg differ diff --git a/Sounds/Item/MittWelding/Weld4.ogg b/Sounds/Item/MittWelding/Weld4.ogg new file mode 100644 index 0000000000..87a68dceac Binary files /dev/null and b/Sounds/Item/MittWelding/Weld4.ogg differ diff --git a/Sounds/Item/MittWelding/Weld5.ogg b/Sounds/Item/MittWelding/Weld5.ogg new file mode 100644 index 0000000000..87a68dceac Binary files /dev/null and b/Sounds/Item/MittWelding/Weld5.ogg differ diff --git a/Sounds/Item/NidhoggBigShot.ogg b/Sounds/Item/NidhoggBigShot.ogg new file mode 100644 index 0000000000..869809f522 Binary files /dev/null and b/Sounds/Item/NidhoggBigShot.ogg differ diff --git a/Sounds/Item/NidhoggCharge.ogg b/Sounds/Item/NidhoggCharge.ogg new file mode 100644 index 0000000000..25d09aa186 Binary files /dev/null and b/Sounds/Item/NidhoggCharge.ogg differ diff --git a/Sounds/Item/GaussFire.ogg b/Sounds/Item/NidhoggFire.ogg similarity index 100% rename from Sounds/Item/GaussFire.ogg rename to Sounds/Item/NidhoggFire.ogg diff --git a/Sounds/Item/PhalanxSurgeCharge.ogg b/Sounds/Item/PhalanxSurgeCharge.ogg new file mode 100644 index 0000000000..dba7b23381 Binary files /dev/null and b/Sounds/Item/PhalanxSurgeCharge.ogg differ diff --git a/Sounds/Item/PhalanxSurgeChargeLoop.ogg b/Sounds/Item/PhalanxSurgeChargeLoop.ogg new file mode 100644 index 0000000000..873f8d3dce Binary files /dev/null and b/Sounds/Item/PhalanxSurgeChargeLoop.ogg differ diff --git a/Sounds/Item/PhalanxSurgeChargeMax.ogg b/Sounds/Item/PhalanxSurgeChargeMax.ogg new file mode 100644 index 0000000000..b04d83e262 Binary files /dev/null and b/Sounds/Item/PhalanxSurgeChargeMax.ogg differ diff --git a/Sounds/Item/PhalanxSurgeChargeShoot.ogg b/Sounds/Item/PhalanxSurgeChargeShoot.ogg new file mode 100644 index 0000000000..09e40f39d2 Binary files /dev/null and b/Sounds/Item/PhalanxSurgeChargeShoot.ogg differ diff --git a/Sounds/Item/ScattershotShoot.ogg b/Sounds/Item/PhalanxSurgeShoot.ogg similarity index 100% rename from Sounds/Item/ScattershotShoot.ogg rename to Sounds/Item/PhalanxSurgeShoot.ogg diff --git a/Sounds/Item/ProtolithBangleSound.ogg b/Sounds/Item/ProtolithBangleSound.ogg new file mode 100644 index 0000000000..0e6ccdeff7 Binary files /dev/null and b/Sounds/Item/ProtolithBangleSound.ogg differ diff --git a/Sounds/Item/PulseSoundHeavy.ogg b/Sounds/Item/PulseSoundHeavy.ogg new file mode 100644 index 0000000000..e579bae7ef Binary files /dev/null and b/Sounds/Item/PulseSoundHeavy.ogg differ diff --git a/Sounds/Item/PumpkaboomNormalTicking.ogg b/Sounds/Item/PumpkaboomNormalTicking.ogg new file mode 100644 index 0000000000..fd21144e98 Binary files /dev/null and b/Sounds/Item/PumpkaboomNormalTicking.ogg differ diff --git a/Sounds/Item/PumpkaboomStealthTicking.ogg b/Sounds/Item/PumpkaboomStealthTicking.ogg new file mode 100644 index 0000000000..d05f87c436 Binary files /dev/null and b/Sounds/Item/PumpkaboomStealthTicking.ogg differ diff --git a/Sounds/Item/SHPCVacuumEnd.ogg b/Sounds/Item/SHPCVacuumEnd.ogg new file mode 100644 index 0000000000..025be3e9c2 Binary files /dev/null and b/Sounds/Item/SHPCVacuumEnd.ogg differ diff --git a/Sounds/Item/SHPCVacuumLoop.ogg b/Sounds/Item/SHPCVacuumLoop.ogg new file mode 100644 index 0000000000..bf81d0cbad Binary files /dev/null and b/Sounds/Item/SHPCVacuumLoop.ogg differ diff --git a/Sounds/Item/SHPCVacuumStart.ogg b/Sounds/Item/SHPCVacuumStart.ogg new file mode 100644 index 0000000000..79ef8a962f Binary files /dev/null and b/Sounds/Item/SHPCVacuumStart.ogg differ diff --git a/Sounds/Item/ScattershotCharge.ogg b/Sounds/Item/ScattershotCharge.ogg deleted file mode 100644 index a571765a20..0000000000 Binary files a/Sounds/Item/ScattershotCharge.ogg and /dev/null differ diff --git a/Sounds/Item/ScattershotChargeLoop.ogg b/Sounds/Item/ScattershotChargeLoop.ogg deleted file mode 100644 index bbf7d26fd3..0000000000 Binary files a/Sounds/Item/ScattershotChargeLoop.ogg and /dev/null differ diff --git a/Sounds/Item/ScattershotChargeShoot.ogg b/Sounds/Item/ScattershotChargeShoot.ogg deleted file mode 100644 index a0fbf470cb..0000000000 Binary files a/Sounds/Item/ScattershotChargeShoot.ogg and /dev/null differ diff --git a/Sounds/Item/SearedPanSmash.ogg b/Sounds/Item/SearedPanSmash.ogg deleted file mode 100644 index c39b602f29..0000000000 Binary files a/Sounds/Item/SearedPanSmash.ogg and /dev/null differ diff --git a/Sounds/Item/SharkoonBoom.ogg b/Sounds/Item/SharkoonBoom.ogg deleted file mode 100644 index 8dd94403c2..0000000000 Binary files a/Sounds/Item/SharkoonBoom.ogg and /dev/null differ diff --git a/Sounds/Item/ShrimpFire.ogg b/Sounds/Item/ShrimpFire.ogg new file mode 100644 index 0000000000..b60d95c9aa Binary files /dev/null and b/Sounds/Item/ShrimpFire.ogg differ diff --git a/Sounds/Item/ShrimpMissileHit.ogg b/Sounds/Item/ShrimpMissileHit.ogg new file mode 100644 index 0000000000..c34fcac6cf Binary files /dev/null and b/Sounds/Item/ShrimpMissileHit.ogg differ diff --git a/Sounds/Item/ShrimpSound1.ogg b/Sounds/Item/ShrimpSound1.ogg new file mode 100644 index 0000000000..38d7eae4ea Binary files /dev/null and b/Sounds/Item/ShrimpSound1.ogg differ diff --git a/Sounds/Item/ShrimpSound2.ogg b/Sounds/Item/ShrimpSound2.ogg new file mode 100644 index 0000000000..f8106c6edf Binary files /dev/null and b/Sounds/Item/ShrimpSound2.ogg differ diff --git a/Sounds/Item/ShrimpSurprise.ogg b/Sounds/Item/ShrimpSurprise.ogg new file mode 100644 index 0000000000..5eb8fbad6d Binary files /dev/null and b/Sounds/Item/ShrimpSurprise.ogg differ diff --git a/Sounds/Item/SkytiedBolt.ogg b/Sounds/Item/SkytideBolt.ogg similarity index 100% rename from Sounds/Item/SkytiedBolt.ogg rename to Sounds/Item/SkytideBolt.ogg diff --git a/Sounds/Item/StarfleetFire.ogg b/Sounds/Item/StarfleetFire.ogg new file mode 100644 index 0000000000..7c44495a39 Binary files /dev/null and b/Sounds/Item/StarfleetFire.ogg differ diff --git a/Sounds/Item/StarfleetStarburst.ogg b/Sounds/Item/StarfleetStarburst.ogg new file mode 100644 index 0000000000..71e89d12eb Binary files /dev/null and b/Sounds/Item/StarfleetStarburst.ogg differ diff --git a/Sounds/Item/StarmadaFire.ogg b/Sounds/Item/StarmadaFire.ogg new file mode 100644 index 0000000000..32a54102f8 Binary files /dev/null and b/Sounds/Item/StarmadaFire.ogg differ diff --git a/Sounds/Item/StratusSphereCast.ogg b/Sounds/Item/StratusSphereCast.ogg new file mode 100644 index 0000000000..d517c18890 Binary files /dev/null and b/Sounds/Item/StratusSphereCast.ogg differ diff --git a/Sounds/Item/Summon/SarosFiring.ogg b/Sounds/Item/Summon/SarosFiring.ogg new file mode 100644 index 0000000000..185efa9f97 Binary files /dev/null and b/Sounds/Item/Summon/SarosFiring.ogg differ diff --git a/Sounds/Item/Summon/SarosSpawn.ogg b/Sounds/Item/Summon/SarosSpawn.ogg new file mode 100644 index 0000000000..185efa9f97 Binary files /dev/null and b/Sounds/Item/Summon/SarosSpawn.ogg differ diff --git a/Sounds/Item/Swine1.ogg b/Sounds/Item/Swine1.ogg new file mode 100644 index 0000000000..1dea0682ff Binary files /dev/null and b/Sounds/Item/Swine1.ogg differ diff --git a/Sounds/Item/Swine2.ogg b/Sounds/Item/Swine2.ogg new file mode 100644 index 0000000000..9b6bf3f57f Binary files /dev/null and b/Sounds/Item/Swine2.ogg differ diff --git a/Sounds/Item/SylvestaffFire1.ogg b/Sounds/Item/SylvestaffFire1.ogg new file mode 100644 index 0000000000..8ab459ac0b Binary files /dev/null and b/Sounds/Item/SylvestaffFire1.ogg differ diff --git a/Sounds/Item/SylvestaffFire2.ogg b/Sounds/Item/SylvestaffFire2.ogg new file mode 100644 index 0000000000..4d60af5825 Binary files /dev/null and b/Sounds/Item/SylvestaffFire2.ogg differ diff --git a/Sounds/Item/SylvestaffFire3.ogg b/Sounds/Item/SylvestaffFire3.ogg new file mode 100644 index 0000000000..c8b78c318b Binary files /dev/null and b/Sounds/Item/SylvestaffFire3.ogg differ diff --git a/Sounds/Item/SylvestaffProjectileBounce1.ogg b/Sounds/Item/SylvestaffProjectileBounce1.ogg new file mode 100644 index 0000000000..dbe4a38b8e Binary files /dev/null and b/Sounds/Item/SylvestaffProjectileBounce1.ogg differ diff --git a/Sounds/Item/SylvestaffProjectileBounce2.ogg b/Sounds/Item/SylvestaffProjectileBounce2.ogg new file mode 100644 index 0000000000..81d1d354e4 Binary files /dev/null and b/Sounds/Item/SylvestaffProjectileBounce2.ogg differ diff --git a/Sounds/Item/SylvestaffProjectileBounce3.ogg b/Sounds/Item/SylvestaffProjectileBounce3.ogg new file mode 100644 index 0000000000..4cbae2723f Binary files /dev/null and b/Sounds/Item/SylvestaffProjectileBounce3.ogg differ diff --git a/Sounds/Item/UnstableCastersGauntlet/AerSigilGust.ogg b/Sounds/Item/UnstableCastersGauntlet/AerSigilGust.ogg new file mode 100644 index 0000000000..19ef8127ac Binary files /dev/null and b/Sounds/Item/UnstableCastersGauntlet/AerSigilGust.ogg differ diff --git a/Sounds/Item/UnstableCastersGauntlet/AquaSigilExplosion.ogg b/Sounds/Item/UnstableCastersGauntlet/AquaSigilExplosion.ogg new file mode 100644 index 0000000000..05ca9ca69e Binary files /dev/null and b/Sounds/Item/UnstableCastersGauntlet/AquaSigilExplosion.ogg differ diff --git a/Sounds/Item/UnstableCastersGauntlet/AquaSigilShot.ogg b/Sounds/Item/UnstableCastersGauntlet/AquaSigilShot.ogg new file mode 100644 index 0000000000..bce0f80dc5 Binary files /dev/null and b/Sounds/Item/UnstableCastersGauntlet/AquaSigilShot.ogg differ diff --git a/Sounds/Item/UnstableCastersGauntlet/IgnisSigilHit.ogg b/Sounds/Item/UnstableCastersGauntlet/IgnisSigilHit.ogg new file mode 100644 index 0000000000..6ee7b4065c Binary files /dev/null and b/Sounds/Item/UnstableCastersGauntlet/IgnisSigilHit.ogg differ diff --git a/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit1.ogg b/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit1.ogg new file mode 100644 index 0000000000..e77aca53a3 Binary files /dev/null and b/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit1.ogg differ diff --git a/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit2.ogg b/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit2.ogg new file mode 100644 index 0000000000..a3e4c77941 Binary files /dev/null and b/Sounds/Item/UnstableCastersGauntlet/PerditoSigilHit2.ogg differ diff --git a/Sounds/Item/UnstableCastersGauntlet/VisNeedleFire.ogg b/Sounds/Item/UnstableCastersGauntlet/VisNeedleFire.ogg new file mode 100644 index 0000000000..fef37ff4c1 Binary files /dev/null and b/Sounds/Item/UnstableCastersGauntlet/VisNeedleFire.ogg differ diff --git a/Sounds/Item/ViperSpit.ogg b/Sounds/Item/ViperSpit.ogg index b7fb928fa1..2be1d386cd 100644 Binary files a/Sounds/Item/ViperSpit.ogg and b/Sounds/Item/ViperSpit.ogg differ diff --git a/Sounds/Item/VoidDash.ogg b/Sounds/Item/VoidDash.ogg new file mode 100644 index 0000000000..52a3ab7ee5 Binary files /dev/null and b/Sounds/Item/VoidDash.ogg differ diff --git a/Sounds/Item/VulcanRampDown.ogg b/Sounds/Item/VulcanRampDown.ogg new file mode 100644 index 0000000000..3463218167 Binary files /dev/null and b/Sounds/Item/VulcanRampDown.ogg differ diff --git a/Sounds/Item/VulcanRampUp.ogg b/Sounds/Item/VulcanRampUp.ogg new file mode 100644 index 0000000000..63a160b201 Binary files /dev/null and b/Sounds/Item/VulcanRampUp.ogg differ diff --git a/Sounds/Item/VulcanShot.ogg b/Sounds/Item/VulcanShot.ogg new file mode 100644 index 0000000000..11c7584d26 Binary files /dev/null and b/Sounds/Item/VulcanShot.ogg differ diff --git a/Sounds/Item/YanmeiKnifeHit.ogg b/Sounds/Item/YanmeiKnifeHit.ogg deleted file mode 100644 index 37abc0dcf8..0000000000 Binary files a/Sounds/Item/YanmeiKnifeHit.ogg and /dev/null differ diff --git a/Sounds/NPCHit/StormlionAltHit.ogg b/Sounds/NPCHit/StormlionAltHit.ogg new file mode 100644 index 0000000000..3630c97c47 Binary files /dev/null and b/Sounds/NPCHit/StormlionAltHit.ogg differ diff --git a/Sounds/NPCHit/WulfrumHit1.ogg b/Sounds/NPCHit/WulfrumHit1.ogg new file mode 100644 index 0000000000..10d225e335 Binary files /dev/null and b/Sounds/NPCHit/WulfrumHit1.ogg differ diff --git a/Sounds/NPCHit/WulfrumHit1.wav b/Sounds/NPCHit/WulfrumHit1.wav deleted file mode 100644 index a07f2b7194..0000000000 Binary files a/Sounds/NPCHit/WulfrumHit1.wav and /dev/null differ diff --git a/Sounds/NPCHit/WulfrumHit2.ogg b/Sounds/NPCHit/WulfrumHit2.ogg new file mode 100644 index 0000000000..048e071051 Binary files /dev/null and b/Sounds/NPCHit/WulfrumHit2.ogg differ diff --git a/Sounds/NPCHit/WulfrumHit2.wav b/Sounds/NPCHit/WulfrumHit2.wav deleted file mode 100644 index 1ba1f11026..0000000000 Binary files a/Sounds/NPCHit/WulfrumHit2.wav and /dev/null differ diff --git a/Sounds/NPCHit/WulfrumHit3.ogg b/Sounds/NPCHit/WulfrumHit3.ogg new file mode 100644 index 0000000000..75a1f42e23 Binary files /dev/null and b/Sounds/NPCHit/WulfrumHit3.ogg differ diff --git a/Sounds/NPCHit/WulfrumHit3.wav b/Sounds/NPCHit/WulfrumHit3.wav deleted file mode 100644 index 782a47fb54..0000000000 Binary files a/Sounds/NPCHit/WulfrumHit3.wav and /dev/null differ diff --git a/Sounds/NPCKilled/StormlionAltDeath.ogg b/Sounds/NPCKilled/StormlionAltDeath.ogg new file mode 100644 index 0000000000..1f71c3a56e Binary files /dev/null and b/Sounds/NPCKilled/StormlionAltDeath.ogg differ diff --git a/Systems/Collections/AbyssValidTileReplacementList.cs b/Systems/Collections/AbyssValidTileReplacementList.cs deleted file mode 100644 index 243d3ba97f..0000000000 --- a/Systems/Collections/AbyssValidTileReplacementList.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of modded Tile IDs which the Abyss can replace while generating. - /// - public sealed class AbyssValidTileReplacementList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - // By default, Calamity does not add anything to this list. Mods are free to do so with reflection. - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check whether or not a tile can be replaced by the Abyss while generating. - /// - public static bool Includes(int tileType) => List.Contains(tileType); - } -} diff --git a/Systems/Collections/AlcoholsDict.cs b/Systems/Collections/AlcoholsDict.cs deleted file mode 100644 index bf7ef08f65..0000000000 --- a/Systems/Collections/AlcoholsDict.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.Alcohol; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of all alcohol buff's IDs and their corresponding poison level. - /// - public sealed class AlcoholsDict : ModSystem - { - public static IDictionary Dict { get; private set; } - - public override void OnModLoad() - { - Dict = new Dictionary - { - { BuffID.Tipsy, 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 2 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 }, - { BuffType(), 1 } - }; - } - - public override void Unload() - { - Dict?.Clear(); - Dict = null; - } - - /// - /// A shorthand method to obtain an alcohol buff's poison level from its buff ID. - /// - public static bool TryGet(int buffType, out int poisonLevel) - { - return Dict.TryGetValue(buffType, out poisonLevel); - } - } -} diff --git a/Systems/Collections/AmalgamBuffLists.cs b/Systems/Collections/AmalgamBuffLists.cs deleted file mode 100644 index 468614edfb..0000000000 --- a/Systems/Collections/AmalgamBuffLists.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.Alcohol; -using CalamityMod.Buffs.Potions; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a with all buff IDs of those who are boosted by The Amalgam accessory. - /// - public sealed class AmalgamBuffList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffID.ObsidianSkin, - BuffID.Regeneration, - BuffID.Swiftness, - BuffID.Gills, - BuffID.Ironskin, - BuffID.ManaRegeneration, - BuffID.MagicPower, - BuffID.Featherfall, - BuffID.Spelunker, - BuffID.Invisibility, - BuffID.Shine, - BuffID.NightOwl, - BuffID.Battle, - BuffID.Thorns, - BuffID.WaterWalking, - BuffID.Archery, - BuffID.Hunter, - BuffID.Gravitation, - BuffID.Tipsy, - BuffID.WellFed, - BuffID.WellFed2, - BuffID.WellFed3, - BuffID.Honey, - BuffID.WeaponImbueVenom, - BuffID.WeaponImbueCursedFlames, - BuffID.WeaponImbueFire, - BuffID.WeaponImbueGold, - BuffID.WeaponImbueIchor, - BuffID.WeaponImbueNanites, - BuffID.WeaponImbueConfetti, - BuffID.WeaponImbuePoison, - BuffID.Lucky, - BuffID.Mining, - BuffID.Heartreach, - BuffID.Calm, - BuffID.Builder, - BuffID.Titan, - BuffID.Flipper, - BuffID.Summoning, - BuffID.Dangersense, - BuffID.AmmoReservation, - BuffID.Lifeforce, - BuffID.Endurance, - BuffID.Rage, - BuffID.Inferno, - BuffID.Wrath, - BuffID.Lovestruck, - BuffID.Stinky, - BuffID.Fishing, - BuffID.Sonar, - BuffID.Crate, - BuffID.Warmth, - BuffID.SugarRush - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check whether or not a buff is boosted by The Amalgam or not. - /// - public static bool Includes(int buffID) => List.Contains(buffID); - } -} diff --git a/Systems/Collections/AutoreuseableSpearsList.cs b/Systems/Collections/AutoreuseableSpearsList.cs deleted file mode 100644 index 80d81b13f5..0000000000 --- a/Systems/Collections/AutoreuseableSpearsList.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of all Vanilla Spears to make them autoreusable. - /// - public sealed class AutoreusableSpearsList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ItemID.AdamantiteGlaive, - ItemID.ChlorophytePartisan, - ItemID.CobaltNaginata, - ItemID.DarkLance, - ItemID.MonkStaffT2, - ItemID.Gungnir, - ItemID.MushroomSpear, - ItemID.MythrilHalberd, - ItemID.NorthPole, - ItemID.ObsidianSwordfish, - ItemID.OrichalcumHalberd, - ItemID.PalladiumPike, - ItemID.Spear, - ItemID.Swordfish, - ItemID.TheRottedFork, - ItemID.TitaniumTrident, - ItemID.Trident, - ItemID.ThunderSpear - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check whether or not an item is an autoreusable spear. - /// - public static bool Includes(int itemType) => List.Contains(itemType); - } -} diff --git a/Systems/Collections/BlacklistedWeaponsWithToolPowerList.cs b/Systems/Collections/BlacklistedWeaponsWithToolPowerList.cs deleted file mode 100644 index 769faa281d..0000000000 --- a/Systems/Collections/BlacklistedWeaponsWithToolPowerList.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.Tools; -using CalamityMod.Items.Weapons.DraedonsArsenal; -using CalamityMod.Items.Weapons.Melee; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class BlacklistedWeaponsWithToolPowerList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - // This list intentionally does not contain Grax. - List = - [ - ItemID.ButchersChainsaw, - ItemID.LucyTheAxe, - ItemID.Rockfish, - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType() - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if this Item is Blacklisted. - /// - public static bool Includes(int itemType) => List.Contains(itemType); - } -} diff --git a/Systems/Collections/BuffedDungeonProjectilesList.cs b/Systems/Collections/BuffedDungeonProjectilesList.cs deleted file mode 100644 index 2d847d0d29..0000000000 --- a/Systems/Collections/BuffedDungeonProjectilesList.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A which contains a that has the Projectile IDs of all projectiles who are buffed Dungeon projectiles. - /// - public sealed class BuffedDungeonProjectilesList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ProjectileID.PaladinsHammerHostile, - ProjectileID.ShadowBeamHostile, - ProjectileID.InfernoHostileBolt, - ProjectileID.InfernoHostileBlast, - ProjectileID.LostSoulHostile, - ProjectileID.SniperBullet, - ProjectileID.RocketSkeleton, - ProjectileID.BulletDeadeye, - ProjectileID.Shadowflames - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if this projectile is a buffed Dungeon projectile. - /// - public static bool Includes(int projType) => List.Contains(projType); - } -} diff --git a/Systems/Collections/CalamityBuffSets.cs b/Systems/Collections/CalamityBuffSets.cs new file mode 100644 index 0000000000..afd3ba2ca8 --- /dev/null +++ b/Systems/Collections/CalamityBuffSets.cs @@ -0,0 +1,126 @@ +using System.Collections.Generic; +using CalamityMod.Buffs; +using CalamityMod.Buffs.Alcohol; +using CalamityMod.Buffs.Cooldowns; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Potions; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.Summon.Whips; +using CalamityMod.DataStructures; +using CalamityMod.Items.Accessories; +using ReLogic.Reflection; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + [ReinitializeDuringResizeArrays] + public static class CalamityBuffSets + { + public static SetFactory Factory = new SetFactory(BuffLoader.BuffCount, "CalamityMod/BuffID", Search); + public static IdDictionary Search = IdDictionary.Create(); + + /// + /// If for a buff type, then that buff will have its duration extended with The Amalgam equipped.
+ /// Also used to remove buffs when contacting the Whispering Maelstrom in the Get fixed boi seed.
+ /// Defaults to . + ///
+ public static bool[] BuffedByAmalgam = Factory.CreateBoolSet(BuffID.ObsidianSkin, BuffID.Regeneration, BuffID.Swiftness, BuffID.Gills, BuffID.Ironskin, BuffID.ManaRegeneration, + BuffID.MagicPower, BuffID.Featherfall, BuffID.Spelunker, BuffID.Invisibility, BuffID.Shine, BuffID.NightOwl, BuffID.Battle, BuffID.Thorns, BuffID.WaterWalking, + BuffID.Archery, BuffID.Hunter, BuffID.Gravitation, BuffID.Tipsy, BuffID.WellFed, BuffID.WellFed2, BuffID.WellFed3, BuffID.Honey, BuffID.WeaponImbueVenom, + BuffID.WeaponImbueCursedFlames, BuffID.WeaponImbueFire, BuffID.WeaponImbueGold, BuffID.WeaponImbueIchor, BuffID.WeaponImbueNanites, BuffID.WeaponImbueConfetti, + BuffID.WeaponImbuePoison, BuffID.Lucky, BuffID.Mining, BuffID.Heartreach, BuffID.Calm, BuffID.Builder, BuffID.Titan, BuffID.Flipper, BuffID.Summoning, BuffID.Dangersense, + BuffID.AmmoReservation, BuffID.Lifeforce, BuffID.Endurance, BuffID.Rage, BuffID.Inferno, BuffID.Wrath, BuffID.Lovestruck, BuffID.Stinky, BuffID.Fishing, BuffID.Sonar, + BuffID.Crate, BuffID.Warmth, BuffID.SugarRush, BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType()); + + /// + /// If for a buff type, then that buff is a persistent buff.
+ /// Used by The Amalgam to prevent removing their persistence when the accessory is unequipped.
+ /// Defaults to . + ///
+ public static bool[] IsPersistentBuff = Factory.CreateBoolSet(BuffID.WeaponImbueVenom, BuffID.WeaponImbueCursedFlames, BuffID.WeaponImbueFire, BuffID.WeaponImbueGold, + BuffID.WeaponImbueIchor, BuffID.WeaponImbueNanites, BuffID.WeaponImbueConfetti, BuffID.WeaponImbuePoison, BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType()); + + /// + /// If for a buff type, then that buff is considered to be a debuff.
+ /// This general-purpose set has several different uses, including reducing buff duration with Radiance, Crown Jewel and its upgrades' debuff effects, and removing debuffs with Cleansing Jelly and its upgrades' auras.
+ /// Defaults to . + ///
+ public static bool[] IsDebuff = Factory.CreateBoolSet(BuffID.Poisoned, BuffID.Darkness, BuffID.Cursed, BuffID.OnFire, BuffID.Bleeding, BuffID.Confused, BuffID.Slow, BuffID.Weak, + BuffID.Silenced, BuffID.BrokenArmor, BuffID.CursedInferno, BuffID.Frostburn, BuffID.Chilled, BuffID.Frozen, BuffID.Burning, BuffID.Suffocation, BuffID.Ichor, + BuffID.Venom, BuffID.Blackout, BuffID.Electrified, BuffID.Rabies, BuffID.Webbed, BuffID.Stoned, BuffID.Dazed, BuffID.VortexDebuff, BuffID.WitheredArmor, BuffID.WitheredWeapon, + BuffID.OgreSpit, BuffID.BetsysCurse, BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), + BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType(), BuffType()); + + /// + /// If for a buff type, then that buff is a whip tag buff on the player.
+ /// Used to prevent "whip stacking", the ability to grant the player multiple whip buff effects at once.
+ /// Defaults to . + ///
+ public static bool[] IsSummonTagBuff = Factory.CreateBoolSet(BuffID.CoolWhipPlayerBuff, BuffID.ScytheWhipPlayerBuff, BuffID.SwordWhipPlayerBuff, BuffID.ThornWhipPlayerBuff, BuffType()); + + /// + /// Associates a buff type with its structure. If a buff type is not a key in this dictionary, then it has no associated .
+ /// Used for several different effects, such as applying tag effects to NPCs, preventing "whip stacking" on NPCs, and drawing the tag effect icon below the NPC. + ///
+ public static Dictionary SummonTagDebuff = new Dictionary + { + { BuffID.BlandWhipEnemyDebuff, SummonTag.LeatherWhip }, + { BuffID.BoneWhipNPCDebuff, SummonTag.SpinalTap }, + { BuffID.CoolWhipNPCDebuff, SummonTag.CoolWhip }, + { BuffID.FlameWhipEnemyDebuff, SummonTag.Firecracker }, + { BuffID.MaceWhipNPCDebuff, SummonTag.MorningStar }, + { BuffID.RainbowWhipNPCDebuff, SummonTag.Kaleidoscope }, + { BuffID.ScytheWhipEnemyDebuff, SummonTag.DarkHarvest }, + { BuffID.SwordWhipNPCDebuff, SummonTag.Durendal }, + { BuffID.ThornWhipNPCDebuff, SummonTag.Snapthorn }, + { BuffType(), ProfanedSoulCrystal.SummonTag } + }; + + /// + /// Associates a buff type with its alcohol poison level. Used for the Alcohol Poisoning mechanic.
+ /// If a buff type is not a key in this dictionary, then it does not increase alcohol poison level. + ///
+ public static Dictionary AlcoholStrength = new Dictionary + { + { BuffID.Tipsy, 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 2 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 }, + { BuffType(), 1 } + }; + } +} diff --git a/Systems/Collections/CalamityItemSets.cs b/Systems/Collections/CalamityItemSets.cs new file mode 100644 index 0000000000..5c01ead45c --- /dev/null +++ b/Systems/Collections/CalamityItemSets.cs @@ -0,0 +1,139 @@ +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.Fishing.FishingRods; +using CalamityMod.Items.LoreItems; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.Furniture.BossRelics; +using CalamityMod.Items.Placeables.Furniture.Monoliths; +using CalamityMod.Items.Placeables.Furniture.Paintings; +using CalamityMod.Items.Placeables.Furniture.Trophies; +using CalamityMod.Items.Potions; +using CalamityMod.Items.Tools; +using CalamityMod.Items.TreasureBags; +using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; +using ReLogic.Reflection; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + [ReinitializeDuringResizeArrays] + public static class CalamityItemSets + { + public static SetFactory Factory = new SetFactory(ItemLoader.ItemCount, "CalamityMod/ItemID", Search); + public static IdDictionary Search = IdDictionary.Create(); + + /// + /// If for an item type, prevents an item from removing Calamity's summon damage penalty mechanic despite having tool power.
+ /// Defaults to . + ///
+ public static bool[] WeaponWithToolPowerAffectedBySummonPenalty = Factory.CreateBoolSet(ItemID.ButchersChainsaw, ItemID.LucyTheAxe, ItemID.Rockfish, + ItemType(), ItemType(), ItemType(), ItemType(), ItemType()); + + /// + /// If for an item type, manually disables Calamity's summon damage penalty mechanic while that item type is held.
+ /// Unused by Calamity itself, and is only used for external mods to add to through mod calls.
+ /// Defaults to . + ///
+ public static bool[] ItemWhichDisablesSummonerNerf = Factory.CreateBoolSet(); + + /// + /// If for an item type, holding the item sets to true, preventing fishing lines from breaking.
+ /// Should only be set on fishing poles.
+ /// Defaults to . + ///
+ public static bool[] FishingPoleThatNeverBreaks = Factory.CreateBoolSet(ItemID.GoldenFishingRod, ItemType(), ItemType()); + + /// + /// If for an item type, forces a dropped item of this type to remain within the bounds of the world if it is spawned outside of it.
+ /// Set this for items which are dropped by enemies or bosses which spawn on the edges of the world.
+ /// Defaults to . + ///
+ public static bool[] ItemForcedInsideWorld = Factory.CreateBoolSet(ItemID.FishronWings, ItemID.Flairon, ItemID.Tsunami, ItemID.BubbleGun, ItemID.RazorbladeTyphoon, + ItemID.TempestStaff, ItemID.FishronBossBag, ItemID.GreaterHealingPotion, ItemID.SoulofFlight, ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType()); + + /// + /// If for an item type, prevents this rogue weapon from triggering Venerated Locket's clone projectile effect when used.
+ /// Primarily used for weapons which shoot short-distance projectiles.
+ /// Defaults to . + ///
+ public static bool[] DisablesVeneratedLocketEffect = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType()); + + /// + /// If for an item type, this item is considered to be a magic gun.
+ /// Used for applying Calamity's reworked Meteor armor set bonus.
+ /// Defaults to . + ///
+ public static bool[] MagicGun = Factory.CreateBoolSet(ItemID.BeeGun, ItemID.BubbleGun, ItemID.ChargedBlasterCannon, ItemID.HeatRay, ItemID.LaserMachinegun, ItemID.LaserRifle, + ItemID.LeafBlower, ItemID.RainbowGun, ItemID.SpaceGun, ItemID.WaspGun, ItemID.ZapinatorGray, ItemID.ZapinatorOrange, ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType()); + + /// + /// If for an item type, this item is considered to be a rogue bomb.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to . + ///
+ public static bool[] RogueBomb = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType()); + + /// + /// If for an item type, this item is considered to be a rogue boomerang.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to . + ///
+ public static bool[] RogueBoomerang = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType()); + + /// + /// If for an item type, this item is considered to be a rogue dagger.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to . + ///
+ public static bool[] RogueDagger = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType()); + + /// + /// If for an item type, this item is considered to be a rogue javelin.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to . + ///
+ public static bool[] RogueJavelin = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType()); + + /// + /// If for an item type, this item is considered to be a rogue spiky ball.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to . + ///
+ public static bool[] RogueSpikyBall = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), + ItemType()); + } +} diff --git a/Systems/Collections/CalamityNPCSets.cs b/Systems/Collections/CalamityNPCSets.cs new file mode 100644 index 0000000000..5a234bd2a8 --- /dev/null +++ b/Systems/Collections/CalamityNPCSets.cs @@ -0,0 +1,360 @@ +using System.Collections.Generic; +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.AcidRain; +using CalamityMod.NPCs.AquaticScourge; +using CalamityMod.NPCs.Astral; +using CalamityMod.NPCs.AstrumAureus; +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.NPCs.BrimstoneElemental; +using CalamityMod.NPCs.Bumblebirb; +using CalamityMod.NPCs.CalClone; +using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.NPCs.Crabulon; +using CalamityMod.NPCs.Crags; +using CalamityMod.NPCs.Cryogen; +using CalamityMod.NPCs.DesertScourge; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Apollo; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Artemis; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.NPCs.GreatSandShark; +using CalamityMod.NPCs.HiveMind; +using CalamityMod.NPCs.Leviathan; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.OldDuke; +using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.PlaguebringerGoliath; +using CalamityMod.NPCs.PlagueEnemies; +using CalamityMod.NPCs.Polterghast; +using CalamityMod.NPCs.PrimordialWyrm; +using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Providence; +using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.Signus; +using CalamityMod.NPCs.SlimeGod; +using CalamityMod.NPCs.StormWeaver; +using CalamityMod.NPCs.SunkenSea; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.Yharon; +using ReLogic.Reflection; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + [ReinitializeDuringResizeArrays] + public static class CalamityNPCSets + { + public static SetFactory Factory = new SetFactory(NPCLoader.NPCCount, "CalamityMod/NPCID", Search); + public static IdDictionary Search = IdDictionary.Create(); + + /// + /// If for an NPC type, makes this NPC be susceptible to .
+ /// Defaults to . + ///
+ public static bool[] CalamityNPCNotImmuneToConfused = Factory.CreateBoolSet(NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType()); + + /// + /// If for an NPC type, forces this NPC to draw Calamity's debuff display, even if it is not a boss.
+ /// Defaults to . + ///
+ public static bool[] ForceDrawDebuffDisplay = Factory.CreateBoolSet(NPCID.TargetDummy, NPCID.WallofFleshEye, NPCType()); + + /// + /// If for an NPC type, then that NPC will not provide increased Rage generation despite being considered a boss.
+ /// Primarily used by worm boss body and tail segments to prevent Rage being extraordinarily easy to get.
+ /// Defaults to . + ///
+ public static bool[] BossSegmentThatDoesNotGenerateRageFaster = Factory.CreateBoolSet(NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType()); + + /// + /// If for an NPC type, allows the NPC to scale its health based on the Boss Health Boost Percentage config option, even if it is not a boss.
+ /// Also allows the NPC to receive health scaling from having multiple players in Expert+.
+ /// Defaults to . + ///
+ public static bool[] ScalesHealthLikeBoss = Factory.CreateBoolSet(NPCID.EaterofWorldsHead, NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, NPCID.SkeletronHand, + NPCID.WallofFleshEye, NPCID.TheDestroyerBody, NPCID.TheDestroyerTail, NPCID.PrimeCannon, NPCID.PrimeLaser, NPCID.PrimeVice, NPCID.PrimeSaw, NPCID.GolemHead, + NPCID.GolemHeadFree, NPCID.GolemFistRight, NPCID.GolemFistLeft, NPCID.Sharkron, NPCID.Sharkron2, NPCID.MoonLordHead, NPCID.MoonLordHand, NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType()); + + /// + /// If for an NPC type, then that NPC will have its contact damage set to 0.
+ /// Defaults to . + ///
+ public static bool[] DealsZeroContactDamage = Factory.CreateBoolSet(NPCID.Harpy, NPCID.Salamander, NPCID.Salamander2, NPCID.Salamander3, NPCID.Salamander4, NPCID.Salamander5, + NPCID.Salamander6, NPCID.Salamander7, NPCID.Salamander8, NPCID.Salamander9, NPCID.GiantCursedSkull, NPCID.FungiBulb, NPCID.GiantFungiBulb, NPCID.IcyMerman, + NPCID.AngryNimbus, NPCID.SandElemental, NPCID.DarkCaster, NPCID.FireImp, NPCID.Tim, NPCID.CultistArcherBlue, NPCID.DesertDjinn, NPCID.DiabolistRed, NPCID.DiabolistWhite, + NPCID.Gastropod, NPCID.IceElemental, NPCID.IchorSticker, NPCID.Necromancer, NPCID.NecromancerArmored, NPCID.RaggedCaster, NPCID.RaggedCasterOpenCoat, NPCID.RuneWizard, + NPCID.SkeletonArcher, NPCID.SkeletonCommando, NPCID.SkeletonSniper, NPCID.TacticalSkeleton, NPCID.Clown, NPCID.GoblinArcher, NPCID.GoblinSorcerer, NPCID.GoblinSummoner, + NPCID.PirateCrossbower, NPCID.PirateDeadeye, NPCID.PirateCaptain, NPCID.SnowmanGangsta, NPCID.SnowBalla, NPCID.DrManFly, NPCID.Eyezor, NPCID.Nailhead, NPCID.BrainScrambler, + NPCID.GigaZapper, NPCID.RayGunner, NPCID.ScutlixRider, NPCID.MartianWalker, NPCID.MartianTurret, NPCID.ElfCopter, NPCID.ElfArcher, NPCID.NebulaBrain, NPCID.NebulaSoldier, + NPCID.StardustCellSmall, NPCID.StardustJellyfishBig, NPCID.StardustSoldier, NPCID.StardustSpiderBig, NPCID.VortexHornetQueen, NPCID.VortexRifleman, NPCID.VortexSoldier, + NPCID.PirateShipCannon, NPCID.MartianSaucer, NPCID.MartianSaucerCannon, NPCID.MartianSaucerCore, NPCID.MartianSaucerTurret, NPCID.Probe, NPCID.CultistBoss, NPCID.GolemHead, + NPCID.GolemHeadFree, NPCID.MoonLordFreeEye, NPCID.BloodSquid, NPCID.PlanterasHook, NPCID.Dandelion, NPCID.DD2DarkMageT1, NPCID.DD2DarkMageT3, NPCID.DD2OgreT2, + NPCID.DD2OgreT3, NPCID.DD2GoblinBomberT1, NPCID.DD2GoblinBomberT2, NPCID.DD2GoblinBomberT3, NPCID.DD2JavelinstT1, NPCID.DD2JavelinstT2, NPCID.DD2JavelinstT3, + NPCID.DD2KoboldWalkerT2, NPCID.DD2KoboldWalkerT3, NPCID.DD2DrakinT2, NPCID.DD2DrakinT3, NPCID.DD2KoboldFlyerT2, NPCID.DD2KoboldFlyerT3, NPCID.DD2WitherBeastT2, + NPCID.DD2WitherBeastT3, NPCID.DD2LightningBugT3, NPCID.MourningWood, NPCID.Pumpking, NPCID.Everscream, NPCID.IceQueen, NPCID.SantaNK1, NPCID.AncientDoom); + + /// + /// If for an NPC type, then that NPC will have its damage reduced by 25% if the world is in Hardmode.
+ /// Defaults to . + ///
+ public static bool[] NerfDamageInHardmode = Factory.CreateBoolSet(NPCID.AnglerFish, NPCID.AngryTrapper, NPCID.Arapaima, NPCID.BlackRecluse, NPCID.BlackRecluseWall, + NPCID.BloodJelly, NPCID.FungoFish, NPCID.GreenJellyfish, NPCID.Clinger, NPCID.ArmoredSkeleton, NPCID.ArmoredViking, NPCID.Mummy, NPCID.DarkMummy, NPCID.LightMummy, + NPCID.BloodFeeder, NPCID.DesertBeast, NPCID.ChaosElemental, NPCID.BloodMummy, NPCID.CorruptSlime, NPCID.Corruptor, NPCID.Crimslime, NPCID.CrimsonAxe, NPCID.CursedHammer, + NPCID.Derpling, NPCID.Herpling, NPCID.DiggerHead, NPCID.DesertGhoul, NPCID.DesertGhoulCorruption, NPCID.DesertGhoulCrimson, NPCID.DesertGhoulHallow, NPCID.DuneSplicerHead, + NPCID.EnchantedSword, NPCID.FloatyGross, NPCID.GiantBat, NPCID.GiantFlyingFox, NPCID.FungiSpore, NPCID.GiantTortoise, NPCID.IceTortoise, NPCID.HoppinJack, NPCID.Mimic, + NPCID.IlluminantBat, NPCID.IlluminantSlime, NPCID.JungleCreeper, NPCID.JungleCreeperWall, NPCID.DesertLamiaDark, NPCID.DesertLamiaLight, NPCID.MossHornet, NPCID.Moth, + NPCID.PigronCorruption, NPCID.PigronCrimson, NPCID.PigronHallow, NPCID.Pixie, NPCID.PossessedArmor, NPCID.RockGolem, NPCID.DesertScorpionWalk, NPCID.DesertScorpionWall, + NPCID.Slimer, NPCID.ToxicSludge, NPCID.Unicorn, NPCID.WanderingEye, NPCID.Werewolf, NPCID.Wolf, NPCID.SeekerHead, NPCID.Wraith, NPCID.ChatteringTeethBomb, NPCID.IceGolem, + NPCID.RainbowSlime, NPCID.SandShark, NPCID.SandsharkCorrupt, NPCID.SandsharkCrimson, NPCID.SandsharkHallow, NPCID.ShadowFlameApparition, NPCID.Parrot, NPCID.PirateCorsair, + NPCID.PirateDeckhand, NPCID.PirateGhost, NPCID.BlueArmoredBonesMace, NPCID.BlueArmoredBonesSword, NPCID.BoneLee, NPCID.DungeonSpirit, NPCID.FlyingSnake, NPCID.HellArmoredBones, + NPCID.HellArmoredBonesSpikeShield, NPCID.HellArmoredBonesSword, NPCID.MisterStabby, NPCID.Butcher, NPCID.CreatureFromTheDeep, NPCID.DeadlySphere, NPCID.Frankenstein, + NPCID.Fritz, NPCID.Psycho, NPCID.Reaper, NPCID.SwampThing, NPCID.ThePossessed, NPCID.Vampire, NPCID.VampireBat, NPCID.HeadlessHorseman, NPCID.Hellhound, NPCID.Poltergeist, + NPCID.Scarecrow1, NPCID.Scarecrow2, NPCID.Scarecrow3, NPCID.Scarecrow4, NPCID.Scarecrow5, NPCID.Scarecrow6, NPCID.Scarecrow7, NPCID.Scarecrow8, NPCID.Scarecrow9, NPCID.Scarecrow10, + NPCID.Splinterling, NPCID.Flocko, NPCID.GingerbreadMan, NPCID.Krampus, NPCID.Nutcracker, NPCID.NutcrackerSpinning, NPCID.PresentMimic, NPCID.Yeti, NPCID.ZombieElf, NPCID.ZombieElfBeard, + NPCID.ZombieElfGirl, NPCID.BloodEelHead, NPCID.GoblinShark, NPCID.EyeballFlyingFish, NPCID.ZombieMerman); + + /// + /// If for an NPC type, then that NPC is a post-Plantera Dungeon enemy. This causes two separate changes to the enemy.
+ /// First, it grants them a 20% chance to drop Ectoplasm upon death.
+ /// Second, it multiplies their max health by 2.5x and increases their damage by a flat 30 if Moon Lord has been defeated.
+ /// Defaults to . + ///
+ public static bool[] IsBuffedDungeonEnemy = Factory.CreateBoolSet(NPCID.SkeletonSniper, NPCID.TacticalSkeleton, NPCID.SkeletonCommando, NPCID.Paladin, NPCID.GiantCursedSkull, + NPCID.BoneLee, NPCID.DiabolistWhite, NPCID.DiabolistRed, NPCID.NecromancerArmored, NPCID.Necromancer, NPCID.RaggedCasterOpenCoat, NPCID.RaggedCaster, + NPCID.HellArmoredBonesSword, NPCID.HellArmoredBonesMace, NPCID.HellArmoredBonesSpikeShield, NPCID.HellArmoredBones, NPCID.BlueArmoredBonesSword, NPCID.BlueArmoredBonesNoPants, + NPCID.BlueArmoredBonesMace, NPCID.BlueArmoredBones, NPCID.RustyArmoredBonesSwordNoArmor, NPCID.RustyArmoredBonesSword, NPCID.RustyArmoredBonesFlail, NPCID.RustyArmoredBonesAxe); + + /// + /// If for an NPC type, then that NPC is spawned in the Pumpkin Moon.
+ /// This will multiply their max health by 3.5x and increase their damage by a flat 30 if Devourer of Gods has been defeated.
+ /// Defaults to . + ///
+ public static bool[] IsBuffedPumpkinMoonEnemy = Factory.CreateBoolSet(NPCID.Scarecrow1, NPCID.Scarecrow2, NPCID.Scarecrow3, NPCID.Scarecrow4, NPCID.Scarecrow5, NPCID.Scarecrow6, + NPCID.Scarecrow7, NPCID.Scarecrow8, NPCID.Scarecrow9, NPCID.Scarecrow10, NPCID.HeadlessHorseman, NPCID.MourningWood, NPCID.Splinterling, NPCID.Pumpking, + NPCID.PumpkingBlade, NPCID.Hellhound, NPCID.Poltergeist); + + /// + /// If for an NPC type, then that NPC is spawned in the Frost Moon.
+ /// This will multiply their max health by 2.5x and increase their damage by a flat 30 if Devourer of Gods has been defeated.
+ /// Defaults to . + ///
+ public static bool[] IsBuffedFrostMoonEnemy = Factory.CreateBoolSet(NPCID.ZombieElf, NPCID.ZombieElfBeard, NPCID.ZombieElfGirl, NPCID.PresentMimic, NPCID.GingerbreadMan, + NPCID.Yeti, NPCID.Everscream, NPCID.IceQueen, NPCID.SantaNK1, NPCID.ElfCopter, NPCID.Nutcracker, NPCID.NutcrackerSpinning, NPCID.ElfArcher, NPCID.Krampus, NPCID.Flocko); + + /// + /// If for an NPC type, then that NPC is spawned in the Solar Eclipse.
+ /// This will multiply their max health by 5x and increase their damage by a flat 30 if Devourer of Gods has been defeated.
+ /// Defaults to . + ///
+ public static bool[] IsBuffedSolarEclipseEnemy = Factory.CreateBoolSet(NPCID.Eyezor, NPCID.Reaper, NPCID.Frankenstein, NPCID.SwampThing, NPCID.Vampire, NPCID.VampireBat, + NPCID.Butcher, NPCID.CreatureFromTheDeep, NPCID.Fritz, NPCID.Nailhead, NPCID.Psycho, NPCID.DeadlySphere, NPCID.DrManFly, NPCID.ThePossessed, NPCID.Mothron, + NPCID.MothronEgg, NPCID.MothronSpawn); + + /// + /// If for an NPC type, then the NPC will receive a 30 second global cooldown to slowing debuffs after being inflicted by one.
+ /// Also used to prevent weapon pulling effects and Anarchy Blade's ability to instantly kill enemies that are below 50% health.
+ /// Defaults to . + ///
+ public static bool[] ResistSlowingDebuffsAndOtherSpecialEffects = Factory.CreateBoolSet(NPCID.KingSlime, NPCType(), + NPCID.EyeofCthulhu, NPCID.EaterofWorldsHead, NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, NPCID.BrainofCthulhu, NPCID.Creeper, + NPCID.QueenBee, NPCID.Deerclops, NPCID.SkeletronHead, NPCID.SkeletronHand, NPCID.WallofFlesh, NPCID.WallofFleshEye, NPCID.PirateShipCannon, NPCID.QueenSlimeBoss, + NPCID.Probe, NPCID.Retinazer, NPCID.Spazmatism, NPCID.SkeletronPrime, NPCID.PrimeCannon, NPCID.PrimeSaw, NPCID.PrimeLaser, NPCID.PrimeVice, NPCID.Plantera, + NPCID.PlanterasTentacle, NPCType(), NPCID.Everscream, NPCID.SantaNK1, NPCID.IceQueen, NPCID.MourningWood, NPCID.Pumpking, NPCID.Mothron, + NPCID.Golem, NPCID.GolemHead, NPCID.GolemHeadFree, NPCID.GolemFistRight, NPCID.GolemFistLeft, NPCID.MartianSaucerCore, NPCID.MartianSaucerCannon, NPCID.MartianSaucerTurret, + NPCID.DukeFishron, NPCID.Sharkron, NPCID.Sharkron2, NPCID.HallowBoss, NPCID.CultistBoss, NPCID.CultistDragonHead, NPCID.CultistDragonBody1, NPCID.CultistDragonBody2, + NPCID.CultistDragonBody3, NPCID.CultistDragonBody4, NPCID.CultistDragonTail, NPCID.AncientCultistSquidhead, NPCID.MoonLordHead, NPCID.MoonLordHand, NPCID.MoonLordCore, + NPCID.MoonLordFreeEye, NPCID.DD2WyvernT1, NPCID.DD2WyvernT2, NPCID.DD2WyvernT3, NPCID.DD2DarkMageT1, NPCID.DD2DarkMageT3, NPCID.DD2SkeletonT1, NPCID.DD2SkeletonT3, + NPCID.DD2WitherBeastT2, NPCID.DD2WitherBeastT3, NPCID.DD2DrakinT2, NPCID.DD2DrakinT3, NPCID.DD2KoboldWalkerT2, NPCID.DD2KoboldWalkerT3, NPCID.DD2KoboldFlyerT2, + NPCID.DD2KoboldFlyerT3, NPCID.DD2OgreT2, NPCID.DD2OgreT3, NPCID.DD2Betsy, + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType()); + + /// + /// If for an NPC type, or will be called on this NPC even if is set. + /// + public static bool[] DoCheckDeadRegardlessRealLife = Factory.CreateBoolSet(NPCType(), NPCType()); + + /// + /// If for an NPC type, will not count this NPC as an enemy.
+ /// Defaults to . + ///
+ public static bool[] DontCountAsEnemy = Factory.CreateBoolSet(NPCID.TargetDummy, NPCType()); + + /// + /// Associates an NPC type with the base value of their max health in Boss Rush.
+ /// If an NPC type is not a key in this dictionary, then it will use its standard max health value. + ///
+ public static Dictionary BossRushHealth = new Dictionary + { + // Tier 1 + { NPCID.KingSlime, 300000 }, // 30 seconds + { NPCID.BlueSlime, 3600 }, + { NPCID.SlimeSpiked, 7200 }, + { NPCID.GreenSlime, 2700 }, + { NPCID.RedSlime, 5400 }, + { NPCID.PurpleSlime, 7200 }, + { NPCID.YellowSlime, 6300 }, + { NPCID.IceSlime, 4500 }, + { NPCID.UmbrellaSlime, 5400 }, + { NPCID.RainbowSlime, 30000 }, + { NPCID.Pinky, 15000 }, + { NPCType(), 21000 }, + { NPCID.EyeofCthulhu, 450000 }, // 30 seconds + { NPCID.ServantofCthulhu, 6000 }, + { NPCID.EaterofWorldsHead, 15000 }, // 30 seconds + immunity timer at start + { NPCID.EaterofWorldsBody, 15000 }, + { NPCID.EaterofWorldsTail, 15000 }, + { NPCID.BrainofCthulhu, 100000 }, // 30 seconds with creepers + { NPCID.Creeper, 10000 }, + { NPCID.QueenBee, 315000 }, // 30 seconds + { NPCID.Bee, 3000 }, + { NPCID.BeeSmall, 2000 }, + { NPCID.BigHornetHoney, 10000 }, + { NPCID.HornetHoney, 7500 }, + { NPCID.LittleHornetHoney, 5000 }, + { NPCID.Deerclops, 315000 }, // 30 seconds + { NPCID.SkeletronHead, 150000 }, // 30 seconds + { NPCID.SkeletronHand, 60000 }, + { NPCID.WallofFlesh, 450000 }, // 30 seconds + { NPCID.WallofFleshEye, 450000 }, + { NPCID.TheHungry, 10000 }, + { NPCID.TheHungryII, 5000 }, + { NPCID.LeechHead, 5000 }, + { NPCID.LeechBody, 5000 }, + { NPCID.LeechTail, 5000 }, + // Tier 2 + { NPCID.QueenSlimeBoss, 200000 }, // 30 seconds + { NPCID.QueenSlimeMinionBlue, 6000 }, + { NPCID.QueenSlimeMinionPink, 6000 }, + { NPCID.QueenSlimeMinionPurple, 5000 }, + { NPCID.Spazmatism, 150000 }, // 30 seconds + { NPCID.Retinazer, 125000 }, + { NPCID.TheDestroyer, 600000 }, // 30 seconds + immunity timer at start + { NPCID.TheDestroyerBody, 600000 }, + { NPCID.TheDestroyerTail, 600000 }, + { NPCID.Probe, 10000 }, + { NPCID.SkeletronPrime, 160000 }, // 30 seconds + { NPCID.PrimeVice, 54000 }, + { NPCID.PrimeCannon, 45000 }, + { NPCID.PrimeSaw, 45000 }, + { NPCID.PrimeLaser, 38000 }, + { NPCID.Plantera, 160000 }, // 30 seconds + { NPCID.PlanterasTentacle, 5000 }, + { NPCType(), 5000 }, + // Tier 3 + { NPCID.Golem, 100000 }, // 30 seconds + { NPCID.GolemHead, 70000 }, + { NPCID.GolemFistLeft, 30000 }, + { NPCID.GolemFistRight, 30000 }, + { NPCID.HallowBoss, 200000 }, // 30 seconds + { NPCID.DukeFishron, 290000 }, // 30 seconds + { NPCID.CultistBoss, 220000 }, // 30 seconds + { NPCID.CultistDragonHead, 60000 }, + { NPCID.CultistDragonBody1, 60000 }, + { NPCID.CultistDragonBody2, 60000 }, + { NPCID.CultistDragonBody3, 60000 }, + { NPCID.CultistDragonBody4, 60000 }, + { NPCID.CultistDragonTail, 60000 }, + { NPCID.AncientCultistSquidhead, 50000 }, + { NPCID.MoonLordCore, 160000 }, // 1 minute + { NPCID.MoonLordHand, 45000 }, + { NPCID.MoonLordHead, 60000 }, + { NPCID.MoonLordLeechBlob, 800 } + }; + + /// + /// Associates an NPC type with an ID number used for Calamity's Speedrun Timer. Used for drawing the correct map icon for the boss.
+ /// If an NPC type is not a key in this dictionary, then it will not be displayed on the Speedrun Timer. + ///
+ public static Dictionary BossSpeedrunTimerID = new Dictionary + { + { NPCID.KingSlime, 1 }, + { NPCType(), 2 }, + { NPCID.EyeofCthulhu, 3 }, + { NPCType(), 4 }, + { NPCID.EaterofWorldsHead, 5 }, + { NPCID.EaterofWorldsBody, 5 }, + { NPCID.EaterofWorldsTail, 5 }, + { NPCID.BrainofCthulhu, 6 }, + { NPCType(), 7 }, + { NPCType(), 8 }, + { NPCID.QueenBee, 9 }, + { NPCID.SkeletronHead, 10 }, + { NPCType(), 11 }, + { NPCType(), 11 }, + { NPCType(), 11 }, + { NPCID.WallofFlesh, 12 }, + { NPCType(), 13 }, + { NPCID.Retinazer, 14 }, + { NPCID.Spazmatism, 14 }, + { NPCType(), 15 }, + { NPCID.TheDestroyer, 16 }, + { NPCType(), 17 }, + { NPCID.SkeletronPrime, 18 }, + { NPCType(), 19 }, + { NPCID.Plantera, 20 }, + { NPCType(), 21 }, + { NPCType(), 21 }, + { NPCType(), 22 }, + { NPCID.Golem, 23 }, + { NPCType(), 24 }, + { NPCID.DukeFishron, 25 }, + { NPCType(), 26 }, + { NPCID.CultistBoss, 27 }, + { NPCType(), 28 }, + { NPCID.MoonLordCore, 29 }, + { NPCType(), 30 }, + { NPCType(), 31 }, + { NPCType(), 32 }, + { NPCType(), 33 }, + { NPCType(), 34 }, + { NPCType(), 35 }, + { NPCType(), 36 }, + { NPCType(), 37 }, + { NPCType(), 38 }, + { NPCType(), 39 }, + { NPCType(), 40 }, + { NPCType(), 41 }, + { NPCType(), 41 }, + { NPCType(), 41 }, + { NPCType(), 41 }, + { NPCID.QueenSlimeBoss, 42 }, + { NPCID.HallowBoss, 43 }, + { NPCID.Deerclops, 44 } + }; + } +} diff --git a/Systems/Collections/CalamityNPCTypeSets.cs b/Systems/Collections/CalamityNPCTypeSets.cs new file mode 100644 index 0000000000..3985e71ee1 --- /dev/null +++ b/Systems/Collections/CalamityNPCTypeSets.cs @@ -0,0 +1,72 @@ +using System.Collections.Generic; +using CalamityMod.NPCs.AquaticScourge; +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.NPCs.DesertScourge; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.SlimeGod; +using CalamityMod.NPCs.StormWeaver; +using ReLogic.Reflection; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + [ReinitializeDuringResizeArrays] + public static class CalamityNPCTypeSets + { + public static SetFactory Factory = new SetFactory(NPCLoader.NPCCount, "CalamityMod/NPCType", Search); + public static IdDictionary Search = IdDictionary.Create(); + + public static bool[] AngryBones = Factory.CreateBoolSet(NPCID.AngryBones, NPCID.AngryBonesBig, NPCID.AngryBonesBigMuscle, NPCID.AngryBonesBigHelmet); + + public static bool[] BoundTownNPC = Factory.CreateBoolSet(NPCID.BoundGoblin, NPCID.BoundWizard, NPCID.BoundMechanic, NPCID.SleepingAngler, NPCID.BartenderUnconscious, + NPCID.WebbedStylist, NPCID.GolferRescue); + + public static bool[] Hornet = Factory.CreateBoolSet(NPCID.Hornet, NPCID.HornetFatty, NPCID.HornetHoney, NPCID.HornetLeafy, NPCID.HornetSpikey, NPCID.HornetStingy); + + // Used for dropping Ancient Bone Dust, vanilla has a Skeleton NPCID set which has more unwanted enemies in it + public static bool[] Skeleton = Factory.CreateBoolSet(NPCID.Skeleton, NPCID.HeadacheSkeleton, NPCID.MisassembledSkeleton, NPCID.PantlessSkeleton, NPCID.BoneThrowingSkeleton, + NPCID.BoneThrowingSkeleton2, NPCID.BoneThrowingSkeleton3, NPCID.BoneThrowingSkeleton4, NPCID.SkeletonTopHat, NPCID.SkeletonAstonaut, NPCID.SkeletonAlien, + NPCID.ArmoredSkeleton, NPCID.SkeletonArcher, NPCID.GreekSkeleton, NPCID.SporeSkeleton); + + // Unused, though is more restrictive than the vanilla Zombie NPCID set + public static bool[] Zombie = Factory.CreateBoolSet(NPCID.Zombie, NPCID.ArmedZombie, NPCID.BaldZombie, NPCID.PincushionZombie, NPCID.ArmedZombiePincussion, NPCID.SlimedZombie, + NPCID.ArmedZombieSlimed, NPCID.SwampZombie, NPCID.ArmedZombieSwamp, NPCID.TwiggyZombie, NPCID.ArmedZombieTwiggy, NPCID.FemaleZombie, NPCID.ArmedZombieCenx, + NPCID.ZombieRaincoat, NPCID.ZombieEskimo, NPCID.ArmedZombieEskimo, NPCID.MaggotZombie, NPCType()); + + + + public static List AquaticScourge = [ NPCType(), NPCType(), NPCType(), NPCType() ]; + + public static List Ares = [ NPCType(), NPCType(), NPCType(), NPCType(), NPCType() ]; + + public static List AstrumDeus = [ NPCType(), NPCType(), NPCType() ]; + + public static List DesertScourge = [ NPCType(), NPCType(), NPCType() ]; + + public static List Destroyer = [ NPCID.TheDestroyer, NPCID.TheDestroyerBody, NPCID.TheDestroyerTail ]; + + public static List DevourerOfGods = [ NPCType(), NPCType(), NPCType() ]; + + public static List EaterOfWorlds = [ NPCID.EaterofWorldsHead, NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail ]; + + public static List Perforators = [ NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType() ]; + + public static List Ravager = [ NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType() ]; + + public static List SkeletronPrime = [ NPCID.SkeletronPrime, NPCID.PrimeCannon, NPCID.PrimeLaser, NPCID.PrimeSaw, NPCID.PrimeVice ]; + + public static List SlimeGod = [ NPCType(), NPCType(), NPCType(), NPCType(), NPCType() ]; + + public static List StormWeaver = [ NPCType(), NPCType(), NPCType() ]; + + public static List Thanatos = [ NPCType(), NPCType(), NPCType(), NPCType() ]; + } +} diff --git a/Systems/Collections/CalamityProjectileSets.cs b/Systems/Collections/CalamityProjectileSets.cs new file mode 100644 index 0000000000..41e02e1020 --- /dev/null +++ b/Systems/Collections/CalamityProjectileSets.cs @@ -0,0 +1,116 @@ +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; +using ReLogic.Reflection; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + [ReinitializeDuringResizeArrays] + public static class CalamityProjectileSets + { + public static SetFactory Factory = new SetFactory(ProjectileLoader.ProjectileCount, "CalamityMod/ProjectileID", Search); + public static IdDictionary Search = IdDictionary.Create(); + + /// + /// If for a projectile type, then that minion will completely ignore Calamity's summon damage penalty mechanic with no exceptions.
+ /// Unused by Calamity itself, and is only used for external mods to add to through mod calls.
+ /// Defaults to . + ///
+ public static bool[] MinionWhichIgnoresSummonerNerf = Factory.CreateBoolSet(); + + /// + /// If for a projectile type, then that projectile is spawned by a post-Plantera Dungeon enemy.
+ /// This increases the projectile's damage by a flat 30 if Moon Lord has been defeated.
+ /// Defaults to . + ///
+ public static bool[] IsBuffedDungeonProjectile = Factory.CreateBoolSet(ProjectileID.PaladinsHammerHostile, ProjectileID.ShadowBeamHostile, ProjectileID.InfernoHostileBolt, + ProjectileID.InfernoHostileBlast, ProjectileID.LostSoulHostile, ProjectileID.SniperBullet, ProjectileID.RocketSkeleton, ProjectileID.BulletDeadeye, ProjectileID.Shadowflames); + + /// + /// If for a projectile type, then that projectile is spawned by a Solar Eclipse, Pumpkin Moon, or Frost Moon enemy.
+ /// This increases the projectile's damage by a flat 15 during those events if Devourer of Gods has been defeated.
+ /// Defaults to . + ///
+ public static bool[] IsBuffedEventProjectile = Factory.CreateBoolSet(ProjectileID.FlamingWood, ProjectileID.GreekFire1, ProjectileID.GreekFire2, ProjectileID.GreekFire3, + ProjectileID.FlamingScythe, ProjectileID.FlamingArrow, ProjectileID.PineNeedleHostile, ProjectileID.OrnamentHostile, ProjectileID.OrnamentHostileShrapnel, + ProjectileID.FrostWave, ProjectileID.FrostShard, ProjectileID.Missile, ProjectileID.Present, ProjectileID.Spike, ProjectileID.BulletDeadeye, ProjectileID.EyeLaser, + ProjectileID.Nail, ProjectileID.DrManFlyFlask); + + /// + /// If for a projectile type, then that projectile is considered a friendly bee.
+ /// Used to allow the projectile to inflict Plague while wearing the Plaguebringer armor.
+ /// Defaults to . + ///
+ public static bool[] IsFriendlyBeeProjectile = Factory.CreateBoolSet(ProjectileID.GiantBee, ProjectileID.Bee, ProjectileID.Wasp, ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType()); + + /// + /// If for a projectile type, then that projectile is a bomb or other explosive which is not a weapon.
+ /// Used to provide early-game worm bosses a resistance to their explosive damage.
+ /// Defaults to . + ///
+ public static bool[] ResistedExplosiveProjectile = Factory.CreateBoolSet(ProjectileID.Grenade, ProjectileID.StickyGrenade, ProjectileID.BouncyGrenade, ProjectileID.Bomb, + ProjectileID.StickyBomb, ProjectileID.BouncyBomb, ProjectileID.Dynamite, ProjectileID.StickyDynamite, ProjectileID.BouncyDynamite, ProjectileID.Explosives, + ProjectileID.ExplosiveBunny, ProjectileID.PartyGirlGrenade, ProjectileID.BombFish, ProjectileID.ScarabBomb, ProjectileID.TNTBarrel, ProjectileType()); + + /// + /// If for a projectile type, then that projectile will never be reflected by armor or accessory effects.
+ /// Set this for persistent projectiles such as deathrays to avoid major screwing of their behavior.
+ /// Only needs to be set for hostile projectiles, as these effects already have a check to ensure they never trigger in PvP.
+ /// Defaults to . + ///
+ public static bool[] ShouldNotBeReflected = Factory.CreateBoolSet(ProjectileID.SaucerDeathray, ProjectileID.PhantasmalDeathray, ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType()); + + /// + /// Determines what other projectiles this projectile will share ID-static immunity frames with. Defaults to -1, which means that it does not share immunity frames.
+ /// Each "set" of projectile which shares immunity frames is registered to point to the same ID reference, usually the first projectile in the set. If a projectile with this reference hits an NPC, all other projectiles with that reference also have their ID-static immunity cooldown set for that NPC. + ///
+ public static int[] SharedIDStaticIFrames = Factory.CreateIntSet(-1, + // Vanilla bees + ProjectileID.Bee, ProjectileID.Bee, + ProjectileID.GiantBee, ProjectileID.Bee, + // Vilethorn + ProjectileID.VilethornBase, ProjectileID.VilethornBase, + ProjectileID.VilethornTip, ProjectileID.VilethornBase, + // Crystal Vile Shard + ProjectileID.CrystalVileShardHead, ProjectileID.CrystalVileShardHead, + ProjectileID.CrystalVileShardShaft, ProjectileID.CrystalVileShardHead, + // Nettle Burst + ProjectileID.NettleBurstRight, ProjectileID.NettleBurstRight, + ProjectileID.NettleBurstLeft, ProjectileID.NettleBurstRight, + ProjectileID.NettleBurstEnd, ProjectileID.NettleBurstRight, + // Magical Harp notes + ProjectileID.QuarterNote, ProjectileID.QuarterNote, + ProjectileID.EighthNote, ProjectileID.QuarterNote, + ProjectileID.TiedEighthNote, ProjectileID.QuarterNote, + // North Pole + ProjectileID.NorthPoleWeapon, ProjectileID.NorthPoleWeapon, + ProjectileID.NorthPoleSpear, ProjectileID.NorthPoleWeapon, + ProjectileID.NorthPoleSnowflake, ProjectileID.NorthPoleWeapon, + // Spore gas clouds + ProjectileID.SporeTrap, ProjectileID.SporeTrap, + ProjectileID.SporeTrap2, ProjectileID.SporeTrap, + ProjectileID.SporeGas, ProjectileID.SporeTrap, + ProjectileID.SporeGas2, ProjectileID.SporeTrap, + ProjectileID.SporeGas3, ProjectileID.SporeTrap, + // Astral Staff + ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), + // Keelhaul + ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), + // Toxic clouds + ProjectileID.ToxicCloud, ProjectileID.ToxicCloud, + ProjectileID.ToxicCloud2, ProjectileID.ToxicCloud, + ProjectileID.ToxicCloud3, ProjectileID.ToxicCloud + ); + } +} diff --git a/Systems/Collections/CalamityTileSets.cs b/Systems/Collections/CalamityTileSets.cs new file mode 100644 index 0000000000..2000210565 --- /dev/null +++ b/Systems/Collections/CalamityTileSets.cs @@ -0,0 +1,36 @@ +using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; +using ReLogic.Reflection; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + [ReinitializeDuringResizeArrays] + public static class CalamityTileSets + { + public static SetFactory Factory = new SetFactory(TileLoader.TileCount, "CalamityMod/TileID", Search); + public static IdDictionary Search = IdDictionary.Create(); + + /// + /// Should only contain modded tiles. If for a tile type, then that tile can be replaced by the Abyss during world generation.
+ /// Unused by Calamity itself, and is only used for external mods to add to through reflection.
+ /// Defaults to . + ///
+ public static bool[] CanBeReplacedByAbyssGeneration = Factory.CreateBoolSet(); + + /// + /// If for a tile type, it will not perform its BlendMerge in the PostDraw hook, and instead will be drawn after every solid tile has been drawn to the screen.
+ /// Defaults to . + ///
+ public static bool[] DrawBlendMergeAfterSolidTile = Factory.CreateBoolSet(TileType()); + + /// + /// If for a tile type, it will be considered an Abyss background wall for various effects. + /// Defaults to + /// + public static bool[] IsAbyssWall = Factory.CreateBoolSet(WallType(), WallType(), WallType(), WallType(), WallType(), WallType()); + } +} diff --git a/Systems/Collections/ConfusionDebuffImmunitiesList.cs b/Systems/Collections/ConfusionDebuffImmunitiesList.cs deleted file mode 100644 index 5b7e79cc23..0000000000 --- a/Systems/Collections/ConfusionDebuffImmunitiesList.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.Astral; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains all of the NPC's IDs of the NPCs who are immune to the Confusion debuff. - /// - public sealed class ConfusionDebuffImmunitiesList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if an NPC is supposed to be immune to the Confusion debuff. - /// - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/DebuffsList.cs b/Systems/Collections/DebuffsList.cs deleted file mode 100644 index 39b22ffc30..0000000000 --- a/Systems/Collections/DebuffsList.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Buffs; -using CalamityMod.Buffs.Cooldowns; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a that has all Debuff IDs. - /// - public sealed class DebuffsList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - BuffID.Poisoned, - BuffID.Darkness, - BuffID.Cursed, - BuffID.OnFire, - BuffID.Bleeding, - BuffID.Confused, - BuffID.Slow, - BuffID.Weak, - BuffID.Silenced, - BuffID.BrokenArmor, - BuffID.CursedInferno, - BuffID.Frostburn, - BuffID.Chilled, - BuffID.Frozen, - BuffID.Burning, - BuffID.Suffocation, - BuffID.Ichor, - BuffID.Venom, - BuffID.Blackout, - BuffID.Electrified, - BuffID.Rabies, - BuffID.Webbed, - BuffID.Stoned, - BuffID.Dazed, - BuffID.VortexDebuff, - BuffID.WitheredArmor, - BuffID.WitheredWeapon, - BuffID.OgreSpit, - BuffID.BetsysCurse, - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - // BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType() - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if a buff ID is a debuff. - /// - public static bool Includes(int buffID) => List.Contains(buffID); - } -} diff --git a/Systems/Collections/DisabledSummonerNerfItemList.cs b/Systems/Collections/DisabledSummonerNerfItemList.cs deleted file mode 100644 index 0f312357da..0000000000 --- a/Systems/Collections/DisabledSummonerNerfItemList.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class DisabledSummonerNerfItemList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = []; - } - - public override void Unload() => List = null; - - public static bool Includes(int itemType) => List.Contains(itemType); - } -} diff --git a/Systems/Collections/DisabledSummonerNerfMinionList.cs b/Systems/Collections/DisabledSummonerNerfMinionList.cs deleted file mode 100644 index 48a47c670b..0000000000 --- a/Systems/Collections/DisabledSummonerNerfMinionList.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class DisabledSummonerNerfMinionList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = []; - } - - public override void Unload() => List = null; - - public static bool Includes(int projType) => List.Contains(projType); - } -} diff --git a/Systems/Collections/DonatorsNameList.cs b/Systems/Collections/DonatorsNameList.cs index ed851b871a..2546638620 100644 --- a/Systems/Collections/DonatorsNameList.cs +++ b/Systems/Collections/DonatorsNameList.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Terraria; using Terraria.ModLoader; namespace CalamityMod.Systems.Collections @@ -11,659 +10,800 @@ namespace CalamityMod.Systems.Collections { public static IList List { get; private set; } - public override void OnModLoad() - { - List = - [ - "Vorbis", - "SoloMael", - "Chaotic Reks", - "The Buildmonger", - "YuH", - "Littlepiggy", - "LompL", - "Lilith", - "Ben Shapiro", - "Frederik", - "Faye", - "Gibb50", - "Braden", - "Hannes", - "profoundmango69", - "Jack", - "Hans Volter", - "Krankwagon", - "MishiroUsui", - "pixlgray", - "Arkhine", - "Lodude", - "DevAesthetic", - "Mister Winchester", - "Zacky", - "Veine", - "Javyz", - "Shifter", - "Crysthamyr", - "Elfinlocks", - "Ein", - "2Larry2", - "Jenonen", - "Dodu", - "Arti", - "Tervastator", - "Luis", - "Alexander", - "BakaQing", - "Taylor", - "Xaphlactus", - "MajinBagel", - "Bendy", - "Rando Calrissian", - "Tails the Fox 92", - "Bread", - "Minty Candy", - "Preston", - "MovingTarget_086", - "Shiro", - "Chip", - "Taylor", - "ShotgunAngel", - "Sandblast", - "ThomasThePencil", - "Aero (Aero#4599)", - "Shirosity", // used to be GlitchOut - "Daawnz", - "CrabBar", - "Yatagarasu", - "Jarod", - "Zombieh", - "MingWhy", - "Random Weeb", - "Afzofa", - "Eragon3942", - "TheBlackHand", - "william", - "Samuel", - "Christopher", - "DemoN K!ng", - "Malik", - "Ryan Baker-Ortiz", - "Aleksanders", - "TheSilverGhost", - "Lucazii", - "Shay", - "Prism", - "BobIsNotMyRealName", - "Guwahavel", - "Azura", - "Joshua", - "Doveda", - "William", - "Arche", - "DevilSunrise", - "Yanmei", - "Chaos", - "Ryan", - "Fish Repairs", - "Melvin", - "Vroomy Has -3,000 IQ", - "The Goliath", - "DaPyRo", - "Takeru", - "Circuit-Jay", - "Commmander Frostbite", - "cytokat", - "Cameron", - "Orudeon", - "BumbleDoge", - "Naglfar", - "Helixas", - "Vetus", - "High Charity", - "Devonte", - "Cerberus", - "Brendan", - "Victor", - "KAT-G307", - "Tombarry Expresserino", - "Drip Veezy", - "Glaid", - "Apotheosis", - "Bladesaber", - "Devon", - "Ruthoranium", - "cocodezi_", - "Mendzey", - "GameRDheAsianSandwich", - "Chigbungus", - "Streakist", - "Eisaya", - "Xenocrona", - "RKMoon", - "Eternal Silence", - "Jeff", - "Beta165", - "DanYami", - "Xenocrona", - "Ari", - "cosmickalamity", - "xd Ow0", - "Darren", - "Florian", - "dawn thunder", - "asdf935", - "GentSkeleton", - "Fizzlpoprock", - "Pigeon", - "Aleksh", - "Just a random guy", - "Dee", - "Æthereal", - "Broken Faucet", - "Sarcosuchus", - "Marissa443", - "Warlok", - "JackShizz", - "NebulaMagePlays", - "Primpy", - "Thys", - "Min", - "Wodernet", - "Pedro", - "Depressed Dad Gaming", - "Snowy", - "Stormone", - "Mobian", - "Rinja", - "Check pins", - "Dakota", - "Neoplasmatic", - "False", - "Whitegiraffe", - "Drakkece", - "Levi", - "Izuna", - "djsnj20", - "pyobbo", - "Alec", - "The Illustrious Sqouinchuousor", - "Moist Lad", - "TwanTheGOAT", - "3x1t_5tyl3", - "Will", - "SpookyNinja", - "Boomdiada", - "Culex", - "Rossadon", - "Ben", - "hubert thieblot", - "NepNep", - "Nanaki", - "CrimsonCrips", - "Lagohz", - "Timon", - "F00d Demon", - "Olkothan", - "Vmar98", - "Dasdruid", - "Cinder", - "Brutzli", - "Yhashtur", - "Zekai", - "Doug", - "Uberransy", - "KurlozClown", - "Nemesis 041", - "Asheel", - "Hayden", - "Lightedflare", - "Lady Shira", - "Devin", - "Qelrin", - "Thomas", - "Ne'er Dowell", - "Potion Man", - "martyrdomination", - "Destructoid", - "Coolguystorm YT", - "Wolfmaw", - "yiumik", - "Destiny Stallcup", - "GreenBerry", - "SolsticeUnlimitd", - "darkhawke", - "oracle", - "YumeiSenshi", - "Cameron", - "Toxin", - "Fweepachino", - "DESPACITO", - "Altzeus", - "Ryan", - "Spider region", - "WinterTire", - "Nycro", - "Vyster", // previously "Bewearium" - "William", - "HellGoat2", - "116taj", - "CaineSenpai", - "Suicide Dreams", - "Roxas", - "Obsoleek", - "Jetpat3", - "GreenTea", - "Woah", - "Ryaegos", - "Popsickle Yoshi", - "Arcadia", - "JensB__", - "Nuclei", - "Picasso's Bean", - "Corn M. Cobb", - "kgh8090", - "Luke", - "Barbara", - "Alexis", - "Soko", - "Albino gonkvader", - "Monic", - "Slim", - "ChaosChaos", - "Deallly", - "Jeff", - "vcf55", - "Kazurgundu", - "Jheybyrd", - "Kipluck", - "SCONICBOOM", - "Mr.Matter", - "Billy", - "jjth0m3", - "GTW High Cube", - "Sabrina", - "Potato - Stego", - "Perditio Astrum", - "MaxingOut", - "SharZz", - "Allegro", - "hoosfire", - "Lauren", - "Ultra Succ", - "Ethan", - "Pacnysam", - "dummyAzure", - "Jaykob", - "Goblin", - "NoOneElse", - "Nicholas", - "Toasty", - "oli saer", - "Blobby6799", - "Domrinth", - "zombieseatflesh7", - "Shiny", - "Whale", - "The Infinity", - "MrCreamen", - "TemperedAether", - "LucasTwocas", - "JustLonelyPi", - "Brian", - "Ashton", - "Rolandark", - "Ally2Cute", - "Dionysos", - "Plant Waifu", - "fire", - "Charles", - "Kaden", - "Dr. Pawsworth", - "Jackson", - "Freakish", - "Ashamper", - "Kinzoku", - "Elementari", - "The Wolf Commando", - "Jordan", - "Jessire", - "Ashton", - "callisto", - "velneu", - "Mathuantie", - "Robert", - "Matias", - "T E R M I N A T O R", - "apotofkoolaid", - "Matthew", - "Terrarian Dragon", - "Pomelo", - "Thomas", - "Iconic Parker Gaming", - "Jaydon", - "Aidan", - "Avery", - "yayoi", - "Splotchycrib", - "GIGA MAN", - "Eric", - "Merubel", - "Smug", - "Lime-Wars l 1", - "WillyDilly", - "xAqult", - "Himakaze", - "Face", - "Carboniferous", - "James", - "Taitou1", - "Yumi", - "NEBULA", - "Blackbluue", - "Alex", - "Ruben", - "Rixu", - "Antonie", - "Zerimore", - "Oblivionisbruh", - "Loser", - "Patrick", - "Magic Love", - "gluten tag", - "RetroRed", - "Katherine", - "SoyScoutSmasher", - "Jersey", - "Reiter splash", - "Conner", - "Ekun", - "Driser", - "bikmin", - "MittoMan", - "Pyromaniac146", - "Eddie Spaghetti", - "Colin", - "ZyferDex_", - "LumiEvi", - "Anish", - "MissMudflaps", - "Valkyrie", - "anglerraptor", - "Scribbles", - "Pneuma", - "OrrangProto", - "Tomat (Stevie)", - "That Katsafaros", - "PsychoGrizzly", - "Dayne", - "Hargestar", - "The Pyro", - "Lucas", - "Superbeepig", - "Larry That Barry", - "Monti", - "StarryFox", - "Kevin", - "Poopifier Poopifly", - "Lacuna", - "Nathan", - "Handburger", - "XusTingo9", - "Underlost", - "julius", - "Mark", - "Habb", - "Reanamet", - "Empress Vega", - "Team", - "GP", - "Xsiana", - "NyanLegacy215", - "ethan", - "Trinity Series", - "M001NG", - "WrathOfOlympus", - "dennis", - "Darkweb", - "Chaozhi", - "Mars", - "Elijah", - "Tezguin", - "Shpee", - "Archie", - "Meow", - "CosmicStarIight", - "Alfragiste", - "Number1piratepan", - "Noah", - "Max Kim", - "Anton", - "edm vibes", - "Hunter", - "Doodled_lynx", - "3en", - "Kiyotu", - "Aero", - "Iguy", - "병현 송", - "Tyler", - "Leonidas", - "GregTheSpinarak", - "Cheddar", - "Alex N", - "Magicoal", - "Seanツ", - "Ariscottle", - "Kevin", - "OnTheAirPogs", - "Zerafir", - "Bill", - "Starmitzy", - "FaeLoPondering", - "Brian", - "Smart2004", - "sherk", - "Squishy", - "Ash", - "rawpie2", - "Hokojin", - "sk", - "Done", - "MeanieG", - "Sanctuary", - "Landon", - "Moonicento", - "Hayden", - "Steven", - "Hana", - "Mikabul", - "Nathaniel", - "Brutus", - "EdelVollMilch", - "garfu", - "NuT NiTe", - "adain", - "Dylan", - "Lucas", - "Arthur", - "sweatingdishes", - "pomp neigh", - "Proffesor prostate", - "Saladify", - "26-4-1", - "VeryMasterNinja", - "Vorbis", - "Nyapano", - "Shadoku", - "allosar", - "jes", - "Paltham", - "Fartein", - "Derdjin", - "A_Normal_Person", - "Duck Satan", - "Jalapeno9", - "Grylken", - "Nexus", - "KJ", - "Goober", - "ChAoS DiScOrD", - "Mayhem", - "Zombified _G", - "Madd Cat", - "Natalie", - "Solaire", - "Dakota C", - "The Davester", - "Jose", - "Him", - "Umberto", - "Lance", - "Navigator", - "Ferret4T", - "Rooki", - "LvL-94", - "Feels Fishy", - "Korb Orb", - "Calcium Comrade", - "Talmadge", - "ddoogg88 tdog", - "CasualNoLifer", - "Bossy Punch", - "Creamy", - "Tyler", - "topnormal", - "Gilded Gryphon", - "Nightskyflyer", - "Schlarfblrfsch", - "MrNobody", - "Aden C.N.", - "zombie wolf", - "n0tacat", - "Marko", - "dexxer65", - "DeLordeyeee", - "Kaledoulas", - "Mohammad", - "Skeli_G", - "Arcxus", - "Sigil", - "Dull", - "DjackV", - "Misinput", - "Gameology", - "KugelBlitz", - "TheGreatSako", - "Joep", - "Rottingwood", - "anything5000", - "Gretchen", - "Spirit Shield", - "Briny_Coffee", - "_Skeggy_", - "just akkolite", - "J.U.N.E.S", - "Bruggs", - "Vimek Xol", - "Oceanman232", - "Sadouken", - "srxe", - "ProfessorWinston", - "OctolingGrimm", - "Cole", - "Markie", - "Met Vox", - "Tweee", - "Kaimonick", - "Chow Chow", - "drenmus!", - "Nitronium Productions", - "Goomfrontlut", - "Akkolite", - "Shaun", - "Bruh.PNG", - "James", - "Lord_Lucerne", - "Ulmod", - "Adamko", - "Gamma Freya", - "Finnrua", - "Maskedmilo", - "RockRecker39", - "Konorango", - "Indeciiissive", - "Curtis", - "Ponynator", - "Crippling-Ambition", - "TitaniumLlama", - "OriginForme487", - "FishBread", - "Real mystlc", - "Levi", - "jc.", - "Medi", - "Jakob", - "Borb9834", - "Georgios", - "KeL", - "Cody", - "Cristian(Mihaii)", - "Marco", - "RuskieThe3rd", - "BreachNClear747", - "happy thoughts", - "Azure", - "theHoopty", - "porglesupreme", - "XDkilljoy65XX", - "Mr. Bones", - "dawnboi", - "Joe", - "Sailor Jolt", - "SomeRando", - "Nuclear Chaos", - "Jankle", - "The Roborex", - "everquartz", - "discokittie", - "IsaacInsomnia", - "xElectrix_", - "Forge", - "MiyoshiEira", - "thebettercat", - "Darthlego", - "Azzilan", - "Griffin", - "LucasHM", - "ChrigTopher", - "Colin V", - "Scrumlet", - "Darkus", - "Homunculus Derelictus", - "Professor Pissington", - "Buppercups - Roblox", - "Pusheen_", - "Patrera" - ]; - } - - public override void Unload() => List = null; + /// + /// This list contains all the donors of the current Patreon, which is for the entire Calamity Dev Team.

+ /// There is no overlap between OriginalPatreonList and this list.

+ /// Any user who donates to the new team-wide Patreon gets added to this new list and removed from the old one. + ///
+ internal static IList NewPatreonList { get; private set; } /// - /// Returns 25 random donator usernames. + /// This list contains all the donors of the previous Patreon, which was in Fabsol's name.

+ /// There is no overlap between NewPatreonList and this list.

+ /// Any user who donates to the new team-wide Patreon gets added to the new list and removed from this one. ///
- public static string[] GetRandomDonors() - { - List donorList = new(List); - const int maxDonorsListed = 25; - string[] donors = new string[maxDonorsListed]; - for (int i = 0; i < maxDonorsListed; i++) - { - donors[i] = donorList[Main.rand.Next(donorList.Count)]; - donorList.Remove(donors[i]); - } + internal static IList OriginalPatreonList { get; private set; } - return donors; + public override void OnModLoad() + { + // All donors at the $10 - Brimstone tier or higher are included in the shout-out. + // This is updated for each release. + NewPatreonList = + [ + "Aerosyn", + "Aidan Spears", + "Amandalias", + "Arcadia", + "Arcxus", + "Ariallis", + "asokasi", + "Audrey Lynn Beemus", + "awesomechapro", + "Azariah", + "azazel", + "Ballin", + "Barrett Turner", + "BlueRay_256", + "Boomdiada", + "Borb9834", + "botbot94", + "Bwlstorm", + "c0d3_404", + "Carduelis", + "Careless_imp", + "Chin", + "ChristmadLaner", + "Chuck", + "Cinder", + "Cosmoec Ark", + "Cosmore", + "Cracking cheese gromit", + "CrazyGamer69", + "Darthlego", + "DefinitlyResponsible", + "Diamond Nife", + "Dizzetriya", + "djsnj20", + "DOGMA", + "DogVTF", + "Dokuro vibes", + "Dos Champion", + "drake093104", + "Entrian", + "Equinoxux", + "FishBread", + "goo", + "Grant Curtiss", + "GrayAeternum", // previously "EternalGrayson" + "haefer.goat.oats", + "Halleyvetica", + "Hamsting", + "help", + "HeWhoShallNotBeBaned", + "Hunyre", + "Hyperthermia", + "Idan", + "Iptktp9", + "J.U.N.E.S", + "Jace Ufret", + "Jalapeno9", + "Jankle", + "JFL", + "JmWarrior", + "JMww2", + "JOSEPH BRACKEN", + "JustinTheLocalToaster", + "Kelta7", + "Kiddorox", + "Lazy2ns", + "LecTrouble", + "Liam Healy", + "Liam Rafle", + "Magicoal", + "Mateo Sauvege", + "Mediocre King", + "Melongun", + "Mint_loll", + "Misako Drevis", + "MizzUltraViolet DamienTK", + "Moe", + "MrDizzyG", + "Natalie Webb", + "Nature", + "niceguysrage", + "Nick H", + "Nightinglade", + "Nothin Purrsonal", + "Nova Solarius", + "Nyavalcade", + "NyxxyNightstar", + "OakhamSam", + "OriasTheFloof", + "Oxytoxy365", + "Ozone-278", + "PantySlack", + "Patch357", + "Patrick Nevermore", + "Phil Broome", + "PumpkinKing", + "Qwertz", + "Reece", + "RK", + "roryoftheabyss", + "RuskieThe3rd", + "Ryo Tadashi", + "Sable", + "SakuraWinterz", + "Salted Warlock", + "schmoovi", + "Sharktank6", + "SirChaos189", + "SkeletonHunter96", + "SRMG267", + "tadict", + "Taelishe", + "Taylor Olligoci", // also an ex-dev. Listed as "Lilac Olligoci" on Patreon. There were two "Taylor"s on the old list + "Tethox", + "That Katsafaros", + "The Deer Who Sold The World", + "The Roborex", + "The Wither", + "Trinity Series", + "Tsukara", + "Umbara", + "Vanillin", + "VentCrab", + "Vergil Cyrus", + "Vertigo", + "Vixcalibur", + "Vortex", + "weisslerren", + "Willye", + "wt55030", + "xAqult", + "Xtra Trinity 3678", + "Xtra", + "Xzier_Tengal", + "YashimaYamanata", + "Zachtoplasm", + "Zecro", + "ZoeyPlague", + ]; + + // Historical donor list. Please never remove names from here unless you are also adding them to NewPatreonList. + OriginalPatreonList = + [ + "_Skeggy_", + "116taj", + "26-4-1", + "2Larry2", + "3en", + "3x1t_5tyl3", + "A_Normal_Person", + "adain", + "Adamko", + "Aden C.N.", + "Aero", + "Aero (Aero#4599)", + "Aeroni", // previously "Toxin" + "Æthereal", + "Afzofa", + "Aidan", + "Akkolite", + "Albino gonkvader", + "Alec", + "Aleksanders", + "Aleksh", + "Alex", + "Alex N", + "Alexander", + "Alexis", + "Alfragiste", + "Allegro", + "allosar", + "Ally2Cute", + "Altzeus", + "anglerraptor", + "Anish", + "Anton", + "Antonie", + "anything5000", + "Apotheosis", + "apotofkoolaid", + "Arche", + "Archie", + "Ari", + "Ariscottle", + "Arkhine", + "Arthur", + "Arti", + "asdf935", + "Ash", + "Ashamper", + "Asheel", + "Ashton", + "Ashton", + "Avery", + "Azura", + "Azure", + "Azzilan", + "BakaQing", + "Barbara", + "Ben", + // "Ben Shapiro", // 01JUN2025: Ozzatron: we already have this as a guide name. That's enough. Melting him in lava is appropriate. Crediting him for funding is not. + "Bendy", + "Beta165", + "bikmin", + "Bill", + "Billy", + "Blackbluue", + "Bladesaber", + "Blobby6799", + "BobIsNotMyRealName", + "Boomdiada", + "Borb9834", + "Bossy Punch", + "Braden", + "BreachNClear747", + "Bread", + "Brendan", + "Brian", + "Brian", + "Briny_Coffee", + "Broken Faucet", + "Bruggs", + "Bruh.PNG", + "Brutus", + "Brutzli", + "BumbleDoge", + "Buppercups - Roblox", + "CaineSenpai", + "Calcium Comrade", + "callisto", + "Cameron", + "Cameron", + "Carboniferous", + "CasualNoLifer", + "Cerberus", + "Chaos", + "ChAoS DiScOrD", + "ChaosChaos", + "Chaotic Reks", + "Chaozhi", + "Charles", + "Check pins", + "Cheddar", + "Chigbungus", + "Chip", + "Chow Chow", + "ChrigTopher", + "Christopher", + "Circuit-Jay", + "cocodezi_", + "Cody", + "Cole", + "Colin", + "Colin V", + "Commander Frostbite", + "Conner", + "Coolguystorm YT", + "Corn M. Cobb", + "cosmickalamity", + "CosmicStarIight", + "CrabBar", // Current dev. + "Creamy", + "CrimsonCrips", + "Crippling-Ambition", + "Cristian(Mihaii)", + "Crysthamyr", + "Culex", + "Curtis", + "cytokat", + "Daawnz", + "Dakota", + "Dakota C", + "DanYami", + "DaPyRo", + "darkhawke", + "Darkus", + "Darkweb", + "Darren", // Current dev. + "Darthlego", + "Dasdruid", + "dawn thunder", + "dawnboi", + "Dayne", + "ddoogg88 tdog", + "Deallly", + "Dee", + "DeLordeyeee", + "DemoN K!ng", + "dennis", + "Depressed Dad Gaming", + "Derdjin", + "DESPACITO", + "Destiny Stallcup", + "Destructoid", + "DevAesthetic", + "DevilSunrise", + "Devin", + "Devon", + "Devonte", + "dexxer65", + "Dionysos", + "discokittie", + "DjackV", + "djsnj20", + "Domrinth", + "Done", + "Doodled_lynx", + "Doug", + "Doveda", + "Dr. Pawsworth", + "Drakkece", + "drenmus!", + "Drip Veezy", + "Driser", + "Duck Satan", + "Dull", + "dummyAzure", + "Dylan", + "Eddie Spaghetti", + "EdelVollMilch", + "edm vibes", + "Ein", + "Eisaya", + "Ekun", + "Elementari", + "Elfinlocks", + "Elijah", + "Empress Vega", + "Eragon3942", + "Eric", + "Eternal Silence", + "ethan", + "Ethan", + "everquartz", + "F00d Demon", + "Face", + "FaeLoPondering", + "False", + "Fartein", + "Faye", + "Feels Fishy", + "Ferret4T", + "Finnrua", + "fire", + "Fish Repairs", + "FishBread", + "Fizzlpoprock", + "Florian", + "Forge", + "Freakish", + "Frederik", + "Fweepachino", + "Gameology", + "GameRDheAsianSandwich", + "Gamma Freya", + "garfu", + "GentSkeleton", + "Georgios", + "Gibb50", + "GIGA MAN", + "Gilded Gryphon", + "Glaid", + "gluten tag", + "Goblin", + "Goober", + "Goomfrontlut", + "GP", + "GreenBerry", + "GreenTea", + "GregTheSpinarak", + "Gretchen", + "Griffin", + "Grylken", + "GTW High Cube", + "Guwahavel", + "Habb", + "Hana", + "Handburger", + "Hannes", + "Hans Volter", + "happy thoughts", + "Hargestar", + "Hayden", + "Hayden", + "Helixas", + "HellGoat2", + "High Charity", + "Him", + "Himakaze", + "Hokojin", + "Homunculus Derelictus", + "hoosfire", + "hubert thieblot", + "Hunter", + "Iconic Parker Gaming", + "Iguy", + "Indeciiissive", + "IsaacInsomnia", + "Izuna", + "J.U.N.E.S", + "Jack", + "JackShizz", + "Jackson", + "Jakob", + "Jalapeno9", + "James", + "James", + "Jankle", + "Jarod", + "Javyz", + "Jaydon", + "Jaykob", + "jc.", + "Jeff", + "Jeff", + "Jenonen", + "JensB__", + "Jersey", + "jes", + "Jessire", + "Jetpat3", + "Jheybyrd", + "jjth0m3", + "Joe", + "Joep", + "Jordan", + "Jose", + "Joshua", + "julius", + "Just a random guy", + "just akkolite", + "JustLonelyPi", + "Kaden", + "Kaimonick", + "Kaledoulas", + "KAT-G307", + "Katherine", + "Kazurgundu", + "KeL", + "Kevin", + "Kevin", + "kgh8090", + "Kinzoku", + "Kipluck", + "Kiyotu", + "KJ", + "Konorango", + "Korb Orb", + "Krankwagon", + "KugelBlitz", + "KurlozClown", + "Lacuna", + "Lady Shira", + "Lagohz", + "Lance", + "Landon", + "Larry That Barry", + "Lauren", + "Leonidas", + "Levi", // Ex-developer. + "Levi", + "Lightedflare", + "Lilith", + "Lime-Wars l 1", + "Littlepiggy", + "Lodude", + "LompL", + "Lord_Lucerne", + "Loser", + "Lucas", + "Lucas", + "LucasHM", + "LucasTwocas", + "Lucazii", + "Luis", + "Luke", + "LumiEvi", + "LvL-94", + "M001NG", + "Madd Cat", + "Magic Love", + "Magicoal", + "MajinBagel", + "Malik", + "Marco", + "Marissa443", + "Mark", + "Markie", + "Marko", + "Mars", + "martyrdomination", + "Maskedmilo", + "Mathuantie", + "Matias", + "Matthew", + "Max Kim", + "MaxingOut", + "Mayhem", + "MeanieG", + "Medi", + "Melvin", + "Mendzey", + "Meow", + "Merubel", + "Met Vox", + "Mikabul", + "Min", + "MingWhy", + "Minty Candy", + "MishiroUsui", + "Misinput", + "MissMudflaps", + "Mister Winchester", + "MittoMan", + "MiyoshiEira", + "Mobian", + "Mohammad", + "Moist Lad", + "Monic", + "Monti", + "Moonicento", + "MovingTarget_086", + "Mr. Bones", + "Mr.Matter", + "MrCreamen", + "MrNobody", + "n0tacat", + "Naglfar", + "Nanaki", + "Natalie", + "Nathan", + "Navigator", + "Ne'er Dowell", + "NEBULA", + "NebulaMagePlays", + "Nemesis 041", + "Neoplasmatic", + "NepNep", + "Nexus", + "Nicholas", + "Nightskyflyer", + "Nitronium Productions", + "Noah", + "NoOneElse", + "Nuclear Chaos", + "Nuclei", + "Number1piratepan", + "NuT NiTe", + "NyanLegacy215", + "Nyapano", + "Nycro", + "Oblivionisbruh", + "Obsoleek", + "Oceanman232", + "OctolingGrimm", + "oli saer", + "Olkothan", + "OnTheAirPogs", + "oracle", + "OriginForme487", + "OrrangProto", + "Orudeon", + "Pacnysam", + "Paltham", + "Patrera", + "Patrick", + "Pedro", + "Perditio Astrum", + "Picasso's Bean", + "Pigeon", + "Plant Waifu", + "Pneuma", + "Pomelo", + "pomp neigh", + "Ponynator", + "Poopifier Poopifly", + "Popsickle Yoshi", + "porglesupreme", + "Potato - Stego", + "Potion Man", + "Preston", + "Primpy", + "Prism", + "Professor Pissington", + "ProfessorWinston", + "Proffesor prostate", + "profoundmango69", + "PsychoGrizzly", + "Pusheen_", + "pyobbo", + "Pyromaniac146", + "Qelrin", + "Rando Calrissian", + "Random Weeb", + "rawpie2", + "Real mystlc", + "Reanamet", + "Reiter splash", + "RetroRed", + "Rinja", + "Rixu", + "RKMoon", + "Robert", + "RockRecker39", + "Rolandark", + "Rooki", + "Rossadon", + "Rottingwood", + "Roxas", + "Ruben", + "RuskieThe3rd", + "Ruthoranium", + "Ryaegos", + "Ryan", + "Ryan", + "Ryan Baker-Ortiz", + "Sabrina", + "Sadouken", + "Sailor Jolt", + "Saladify", + "Samuel", + "Sanctuary", + "Sandblast", + "Sarcosuchus", + "Schlarfblrfsch", + "SCONICBOOM", + "Scribbles", + "Scrumlet", + "Seanツ", + "Sevenfold", // previously "Woah" + "Shadoku", + "SharZz", + "Shaun", + //"Shayy", // Removed from circulation as the user in question committed acts undeserving of recognition + "sherk", + "Shifter", + "Shiny", + "Shiro", + "Shirosity", // used to be GlitchOut + "ShotgunAngel", + "Shpee", + "Sigil", + "sk", + "Skeli_G", + "Slim", + "Smart2004", + "Smug", + "Snowy", + "Soko", + "Solaire", + "SoloMael", + "SolsticeUnlimitd", + "SomeRando", + "SoyScoutSmasher", + "Spider region", + "Spirit Shield", + "Splotchycrib", + "SpookyNinja", + "Squishy", + "srxe", + "Starmitzy", + "StarryFox", + "Steven", + "Stormone", + "Streakist", + "Suicide Dreams", + "Superbeepig", + "sweatingdishes", + "T E R M I N A T O R", + "Tails the Fox 92", + "Taitou1", + "Takeru", + "Talmadge", + "Taylor", + "Team", + "TemperedAether", + "Terrarian Dragon", + "Tervastator", + "Tezguin", + "That Katsafaros", + "The Buildmonger", + "The Davester", + "The Evolution", // previously "Nathaniel" + "The Goliath", + "The Illustrious Sqouinchuousor", + "The Infinity", + "The Pyro", + "The Roborex", + "The Wolf Commando", + "thebettercat", + "TheBlackHand", + "TheGreatSako", + "theHoopty", + "TheSilverGhost", + "Thomas", + "Thomas", + "ThomasThePencil", + "Thys", + "Timon", + "TitaniumLlama", + "Tomat (Stevie)", + "Tombarry Expresserino", + "topnormal", + "Trinity Series", + "TwanTheGOAT", + "Tweee", + "Tyler", + "Tyler", + "Uberransy", + "Ulmod", + "Ultra Succ", + "Umberto", + "Underlost", + "Valkyrie", + "vcf55", + "Veine", + "velneu", + "VeryMasterNinja", + "Vetus", + "Victor", + "Vimek Xol", + "Vmar98", + "Vorbis", + "Vroomy Has -3,000 IQ", + "Vyster", // previously "Bewearium" + "Warlok", + "Whale", + "Whitegiraffe", + "Will", + "william", + "William", + "William", + "WillyDilly", + "WinterTire", + "Wodernet", + "Wolfmaw", + "WrathOfOlympus", + "Xaphlactus", + "xAqult", + "xd Ow0", + "XDkilljoy65XX", + "xElectrix_", + "Xenocrona", + "Xenocrona", + "Xsiana", + "XusTingo9", + "Yatagarasu", + "yayoi", + "Yhashtur", + "yiumik", + "YuH", // Current dev. + "YumeiSenshi", + "Yumi", + "Zacky", + "Zekai", + "Zerafir", + "Zerimore", + "zombie wolf", + "Zombieh", + "zombieseatflesh7", + "Zombified _G", + "ZyferDex_", + "병현 송", + ]; + + // Staple the two lists together. + List = [..OriginalPatreonList, ..NewPatreonList]; + } + + public override void Unload() + { + OriginalPatreonList = null; + NewPatreonList = null; + List = null; } } } diff --git a/Systems/Collections/EventProjectileBuffList.cs b/Systems/Collections/EventProjectileBuffList.cs deleted file mode 100644 index 9f3db41e46..0000000000 --- a/Systems/Collections/EventProjectileBuffList.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of all Projectile Types that receive Post-DoG Event Buff - /// - public sealed class EventProjectileBuffList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ProjectileID.FlamingWood, - ProjectileID.GreekFire1, - ProjectileID.GreekFire2, - ProjectileID.GreekFire3, - ProjectileID.FlamingScythe, - ProjectileID.FlamingArrow, - ProjectileID.PineNeedleHostile, - ProjectileID.OrnamentHostile, - ProjectileID.OrnamentHostileShrapnel, - ProjectileID.FrostWave, - ProjectileID.FrostShard, - ProjectileID.Missile, - ProjectileID.Present, - ProjectileID.Spike, - ProjectileID.BulletDeadeye, - ProjectileID.EyeLaser, - ProjectileID.Nail, - ProjectileID.DrManFlyFlask - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int projType) => List.Contains(projType); - } -} diff --git a/Systems/Collections/FireDebuffsList.cs b/Systems/Collections/FireDebuffsList.cs deleted file mode 100644 index f68d38db98..0000000000 --- a/Systems/Collections/FireDebuffsList.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a that has all the IDs of all Fire-type debuffs. - /// - public sealed class FireDebuffsList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - BuffID.OnFire, - BuffID.OnFire3, // Hellfire - BuffID.Burning, // Touching meteorite ore or hellstone without obsidian skull - BuffID.CursedInferno, - BuffID.ShadowFlame, // Vanilla Shadowflame, can normally never be applied to players - BuffType(), // Calamity Shadowflame copy for players - BuffType(), // Crags lava - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), // Aflame enchant self damage - BuffType(), - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if a buff ID is a fire debuff. - /// - public static bool Includes(int buffID) => List.Contains(buffID); - } -} diff --git a/Systems/Collections/FriendlyBeesList.cs b/Systems/Collections/FriendlyBeesList.cs deleted file mode 100644 index 4ccdaf609f..0000000000 --- a/Systems/Collections/FriendlyBeesList.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Projectiles.Summon; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a that has all the Projectile IDs of all friendly bees. - /// - public sealed class FriendlyBeesList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ProjectileID.GiantBee, - ProjectileID.Bee, - ProjectileID.Wasp, - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType() - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if a projectile is a friendly bee. - /// - public static bool Includes(int projType) => List.Contains(projType); - } -} diff --git a/Systems/Collections/GrenadeResistIDList.cs b/Systems/Collections/GrenadeResistIDList.cs deleted file mode 100644 index 917ae8271c..0000000000 --- a/Systems/Collections/GrenadeResistIDList.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.Typeless; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class GrenadeResistIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ProjectileID.Grenade, - ProjectileID.StickyGrenade, - ProjectileID.BouncyGrenade, - ProjectileID.Bomb, - ProjectileID.StickyBomb, - ProjectileID.BouncyBomb, - ProjectileID.Dynamite, - ProjectileID.StickyDynamite, - ProjectileID.BouncyDynamite, - ProjectileID.Explosives, - ProjectileID.ExplosiveBunny, - ProjectileID.PartyGirlGrenade, - ProjectileID.BombFish, - ProjectileID.Beenade, - ProjectileID.Bee, - ProjectileID.GiantBee, - ProjectileType(), - ProjectileID.ScarabBomb, - ProjectileID.TNTBarrel - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int projectileType) => List.Contains(projectileType); - } -} diff --git a/Systems/Collections/HighTestFishingPoleList.cs b/Systems/Collections/HighTestFishingPoleList.cs deleted file mode 100644 index aea4781598..0000000000 --- a/Systems/Collections/HighTestFishingPoleList.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.Fishing.FishingRods; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class HighTestFishingPoleList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ItemID.GoldenFishingRod, - ItemType(), - ItemType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int itemType) => List.Contains(itemType); - } -} diff --git a/Systems/Collections/ItemsForcedInsideWorldList.cs b/Systems/Collections/ItemsForcedInsideWorldList.cs deleted file mode 100644 index 6fd8da39ab..0000000000 --- a/Systems/Collections/ItemsForcedInsideWorldList.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; -using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Summon; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of Item IDs of those which are forced to be inside the world map. - /// - public sealed class ItemsForcedInsideWorldList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemID.HotlineFishingHook, - ItemID.BottomlessBucket, - ItemID.SuperAbsorbantSponge, - ItemID.FishingPotion, - ItemID.SonarPotion, - ItemID.CratePotion, - ItemID.AnglerTackleBag, - ItemID.HighTestFishingLine, - ItemID.TackleBox, - ItemID.AnglerEarring, - ItemID.FishermansGuide, - ItemID.WeatherRadio, - ItemID.Sextant, - ItemID.AnglerHat, - ItemID.AnglerVest, - ItemID.AnglerPants, - ItemID.GoldenBugNet, - ItemID.FishronWings, - ItemID.Flairon, - ItemID.Tsunami, - ItemID.BubbleGun, - ItemID.RazorbladeTyphoon, - ItemID.TempestStaff, - ItemID.FishronBossBag, - ItemID.Coral, - ItemID.Seashell, - ItemID.Starfish, - ItemID.SoulofSight, - ItemID.GreaterHealingPotion, - ItemID.SuperHealingPotion - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check whether or not an item is an item that should be forced inside the world map. - /// - public static bool Includes(int itemType) => List.Contains(itemType); - } -} diff --git a/Systems/Collections/KamiDebuffColorImmuneList.cs b/Systems/Collections/KamiDebuffColorImmuneList.cs deleted file mode 100644 index 028faa8375..0000000000 --- a/Systems/Collections/KamiDebuffColorImmuneList.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.OldDuke; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class KamiDebuffColorImmuneList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - // Duke Fishron and Old Duke phase 3 becomes way too easy if you can make him stop being invisible with Yanmei's Knife. - // This is a list so that other NPCs can be added as necessary. - // IT DOES NOT make them immune to the debuff, just stops them from being recolored. - List = - [ - NPCID.DukeFishron, - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/LivingFireTilesList.cs b/Systems/Collections/LivingFireTilesList.cs deleted file mode 100644 index 81b2d27c33..0000000000 --- a/Systems/Collections/LivingFireTilesList.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Tiles.LivingFire; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a with all Tile IDs of those which are Living-Fire-type tiles. - /// - public sealed class LivingFireTilesList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - TileType(), - TileType(), - TileType(), - TileType(), - TileID.LivingFire, - TileID.LivingCursedFire, - TileID.LivingDemonFire, - TileID.LivingFrostFire, - TileID.LivingIchor, - TileID.LivingUltrabrightFire - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check whether or not a tile is a Living-Fire-type of tile. - /// - public static bool Includes(int tileType) => List.Contains(tileType); - } -} diff --git a/Systems/Collections/MagicGunIDList.cs b/Systems/Collections/MagicGunIDList.cs deleted file mode 100644 index 9bce514ec6..0000000000 --- a/Systems/Collections/MagicGunIDList.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.Weapons.DraedonsArsenal; -using CalamityMod.Items.Weapons.Magic; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class MagicGunIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemID.BeeGun, - ItemID.BubbleGun, - ItemID.ChargedBlasterCannon, - ItemID.HeatRay, - ItemID.LaserMachinegun, - ItemID.LaserRifle, - ItemID.LeafBlower, - ItemID.RainbowGun, - ItemID.SpaceGun, - ItemID.WaspGun, - ItemID.ZapinatorGray, - ItemID.ZapinatorOrange - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if this Item is Magic Gun. - /// - public static bool Includes(int itemType) => List.Contains(itemType); - } -} diff --git a/Systems/Collections/NPCIDs/AngryBonesIDList.cs b/Systems/Collections/NPCIDs/AngryBonesIDList.cs deleted file mode 100644 index 7ca8a86472..0000000000 --- a/Systems/Collections/NPCIDs/AngryBonesIDList.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class AngryBonesIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.AngryBones, - NPCID.AngryBonesBig, - NPCID.AngryBonesBigMuscle, - NPCID.AngryBonesBigHelmet, - NPCID.BigBoned, - NPCID.ShortBones - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/AquaticScourgeIDList.cs b/Systems/Collections/NPCIDs/AquaticScourgeIDList.cs deleted file mode 100644 index e6b8dae864..0000000000 --- a/Systems/Collections/NPCIDs/AquaticScourgeIDList.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.AquaticScourge; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class AquaticScourgeIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/AresIDList.cs b/Systems/Collections/NPCIDs/AresIDList.cs deleted file mode 100644 index 09b52cdd3a..0000000000 --- a/Systems/Collections/NPCIDs/AresIDList.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.ExoMechs.Ares; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class AresIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/AstrumDeusIDList.cs b/Systems/Collections/NPCIDs/AstrumDeusIDList.cs deleted file mode 100644 index d5ddc2b632..0000000000 --- a/Systems/Collections/NPCIDs/AstrumDeusIDList.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.AstrumDeus; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class AstrumDeusIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/BoundNPCIDList.cs b/Systems/Collections/NPCIDs/BoundNPCIDList.cs deleted file mode 100644 index a3667b2fd0..0000000000 --- a/Systems/Collections/NPCIDs/BoundNPCIDList.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class BoundNPCIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.BoundGoblin, - NPCID.BoundWizard, - NPCID.BoundMechanic, - NPCID.SleepingAngler, - NPCID.BartenderUnconscious, - NPCID.WebbedStylist, - NPCID.GolferRescue - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/CosmicGuardianIDList.cs b/Systems/Collections/NPCIDs/CosmicGuardianIDList.cs deleted file mode 100644 index ebacf52a13..0000000000 --- a/Systems/Collections/NPCIDs/CosmicGuardianIDList.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.DevourerofGods; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class CosmicGuardianIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/DemonEyeIDList.cs b/Systems/Collections/NPCIDs/DemonEyeIDList.cs deleted file mode 100644 index d0c72b67bf..0000000000 --- a/Systems/Collections/NPCIDs/DemonEyeIDList.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class DemonEyeIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.DemonEye, - NPCID.CataractEye, - NPCID.SleepyEye, - NPCID.DialatedEye, // it is spelled "dilated" - NPCID.GreenEye, - NPCID.PurpleEye, - NPCID.DemonEyeOwl, - NPCID.DemonEyeSpaceship, - NPCID.DemonEye2, - NPCID.PurpleEye2, - NPCID.GreenEye2, - NPCID.DialatedEye2, - NPCID.SleepyEye2, - NPCID.CataractEye2 - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/DesertScourgeIDList.cs b/Systems/Collections/NPCIDs/DesertScourgeIDList.cs deleted file mode 100644 index 280a969845..0000000000 --- a/Systems/Collections/NPCIDs/DesertScourgeIDList.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.DesertScourge; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class DesertScourgeIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/DestroyerIDList.cs b/Systems/Collections/NPCIDs/DestroyerIDList.cs deleted file mode 100644 index 5199177076..0000000000 --- a/Systems/Collections/NPCIDs/DestroyerIDList.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class DestroyerIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.TheDestroyer, - NPCID.TheDestroyerBody, - NPCID.TheDestroyerTail - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/DevourerOfGodsIDList.cs b/Systems/Collections/NPCIDs/DevourerOfGodsIDList.cs deleted file mode 100644 index ff37b9725c..0000000000 --- a/Systems/Collections/NPCIDs/DevourerOfGodsIDList.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.DevourerofGods; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class DevourerOfGodsIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/EaterOfWorldsIDList.cs b/Systems/Collections/NPCIDs/EaterOfWorldsIDList.cs deleted file mode 100644 index e4c2f65476..0000000000 --- a/Systems/Collections/NPCIDs/EaterOfWorldsIDList.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class EaterOfWorldsIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.EaterofWorldsHead, - NPCID.EaterofWorldsBody, - NPCID.EaterofWorldsTail - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/GolemIDList.cs b/Systems/Collections/NPCIDs/GolemIDList.cs deleted file mode 100644 index db9e1b362a..0000000000 --- a/Systems/Collections/NPCIDs/GolemIDList.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class GolemIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.Golem, - NPCID.GolemHead, - NPCID.GolemHeadFree, - NPCID.GolemFistLeft, - NPCID.GolemFistRight - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/HornetIDList.cs b/Systems/Collections/NPCIDs/HornetIDList.cs deleted file mode 100644 index 3cb3d5e17f..0000000000 --- a/Systems/Collections/NPCIDs/HornetIDList.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class HornetIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.BigHornetStingy, - NPCID.LittleHornetStingy, - NPCID.BigHornetSpikey, - NPCID.LittleHornetSpikey, - NPCID.BigHornetLeafy, - NPCID.LittleHornetLeafy, - NPCID.BigHornetHoney, - NPCID.LittleHornetHoney, - NPCID.BigHornetFatty, - NPCID.LittleHornetFatty, - NPCID.BigStinger, - NPCID.LittleStinger, - NPCID.Hornet, - NPCID.HornetFatty, - NPCID.HornetHoney, - NPCID.HornetLeafy, - NPCID.HornetSpikey, - NPCID.HornetStingy - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/MossHornetIDList.cs b/Systems/Collections/NPCIDs/MossHornetIDList.cs deleted file mode 100644 index 9f05bd9acf..0000000000 --- a/Systems/Collections/NPCIDs/MossHornetIDList.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class MossHornetIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.MossHornet, - NPCID.TinyMossHornet, - NPCID.LittleMossHornet, - NPCID.BigMossHornet, - NPCID.GiantMossHornet - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/PerforatorWormIDList.cs b/Systems/Collections/NPCIDs/PerforatorWormIDList.cs deleted file mode 100644 index 4bb42decc1..0000000000 --- a/Systems/Collections/NPCIDs/PerforatorWormIDList.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.Perforator; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class PerforatorWormIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/RavagerIDList.cs b/Systems/Collections/NPCIDs/RavagerIDList.cs deleted file mode 100644 index 61dfdb3135..0000000000 --- a/Systems/Collections/NPCIDs/RavagerIDList.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.Ravager; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class RavagerIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - // Purposefully does not include the freed head - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/SkeletonIDList.cs b/Systems/Collections/NPCIDs/SkeletonIDList.cs deleted file mode 100644 index ec63ae51f9..0000000000 --- a/Systems/Collections/NPCIDs/SkeletonIDList.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class SkeletonIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.Skeleton, - NPCID.HeadacheSkeleton, - NPCID.MisassembledSkeleton, - NPCID.PantlessSkeleton, - NPCID.BoneThrowingSkeleton, - NPCID.BoneThrowingSkeleton2, - NPCID.BoneThrowingSkeleton3, - NPCID.BoneThrowingSkeleton4, - NPCID.BigPantlessSkeleton, - NPCID.SmallPantlessSkeleton, - NPCID.BigMisassembledSkeleton, - NPCID.SmallMisassembledSkeleton, - NPCID.BigHeadacheSkeleton, - NPCID.SmallHeadacheSkeleton, - NPCID.BigSkeleton, - NPCID.SmallSkeleton, - - //Note: These skeletons don't count for Skeleton Banner for some god forsaken reason - NPCID.SkeletonTopHat, - NPCID.SkeletonAstonaut, - NPCID.SkeletonAlien, - - //Other skeleton types - NPCID.ArmoredSkeleton, - NPCID.HeavySkeleton, - NPCID.SkeletonArcher, - NPCID.GreekSkeleton, - NPCID.SporeSkeleton - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/SkeletronPrimeIDList.cs b/Systems/Collections/NPCIDs/SkeletronPrimeIDList.cs deleted file mode 100644 index 21c182ddfa..0000000000 --- a/Systems/Collections/NPCIDs/SkeletronPrimeIDList.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.NormalNPCs; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class SkeletronPrimeIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.SkeletronPrime, - NPCType(), - NPCID.PrimeCannon, - NPCID.PrimeLaser, - NPCID.PrimeSaw, - NPCID.PrimeVice - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/SlimeGodIDList.cs b/Systems/Collections/NPCIDs/SlimeGodIDList.cs deleted file mode 100644 index 85bdebd8b6..0000000000 --- a/Systems/Collections/NPCIDs/SlimeGodIDList.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.SlimeGod; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class SlimeGodIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/StormWeaverIDList.cs b/Systems/Collections/NPCIDs/StormWeaverIDList.cs deleted file mode 100644 index 39f1ecd0fa..0000000000 --- a/Systems/Collections/NPCIDs/StormWeaverIDList.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.StormWeaver; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class StormWeaverIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/ThanatosIDList.cs b/Systems/Collections/NPCIDs/ThanatosIDList.cs deleted file mode 100644 index 8688eac6b6..0000000000 --- a/Systems/Collections/NPCIDs/ThanatosIDList.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.ExoMechs.Thanatos; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class ThanatosIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCIDs/ZombieIDList.cs b/Systems/Collections/NPCIDs/ZombieIDList.cs deleted file mode 100644 index 0b5ece97d5..0000000000 --- a/Systems/Collections/NPCIDs/ZombieIDList.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.NormalNPCs; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class ZombieIDList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.Zombie, - NPCID.ArmedZombie, - NPCID.BaldZombie, - NPCID.PincushionZombie, - NPCID.ArmedZombiePincussion, // what is this spelling - NPCID.SlimedZombie, - NPCID.ArmedZombieSlimed, - NPCID.SwampZombie, - NPCID.ArmedZombieSwamp, - NPCID.TwiggyZombie, - NPCID.ArmedZombieTwiggy, - NPCID.FemaleZombie, - NPCID.ArmedZombieCenx, - NPCID.ZombieRaincoat, - NPCID.ZombieEskimo, - NPCID.ArmedZombieEskimo, - NPCID.BigRainZombie, - NPCID.SmallRainZombie, - NPCID.BigFemaleZombie, - NPCID.SmallFemaleZombie, - NPCID.BigTwiggyZombie, - NPCID.SmallTwiggyZombie, - NPCID.BigSwampZombie, - NPCID.SmallSwampZombie, - NPCID.BigSlimedZombie, - NPCID.SmallSlimedZombie, - NPCID.BigPincushionZombie, - NPCID.SmallPincushionZombie, - NPCID.BigBaldZombie, - NPCID.SmallBaldZombie, - NPCID.BigZombie, - NPCID.SmallZombie, - NPCID.MaggotZombie, - NPCType() - // halloween zombies not included because they don't drop shackles or zombie arms - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/BossHPScalingList.cs b/Systems/Collections/NPCs/BossHPScalingList.cs deleted file mode 100644 index 5912dbbc55..0000000000 --- a/Systems/Collections/NPCs/BossHPScalingList.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crabulon; -using CalamityMod.NPCs.Cryogen; -using CalamityMod.NPCs.DesertScourge; -using CalamityMod.NPCs.DevourerofGods; -using CalamityMod.NPCs.HiveMind; -using CalamityMod.NPCs.Leviathan; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.Perforator; -using CalamityMod.NPCs.PlaguebringerGoliath; -using CalamityMod.NPCs.Polterghast; -using CalamityMod.NPCs.PrimordialWyrm; -using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.NPCs.Providence; -using CalamityMod.NPCs.Ravager; -using CalamityMod.NPCs.Signus; -using CalamityMod.NPCs.SlimeGod; -using CalamityMod.NPCs.SupremeCalamitas; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a that has all NPC IDs of bosses or boss minions that have HP scaling. - /// - public sealed class BossHPScalingList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.EaterofWorldsHead, - NPCID.EaterofWorldsBody, - NPCID.EaterofWorldsTail, - NPCID.SkeletronHand, - NPCID.WallofFleshEye, - NPCID.TheDestroyerBody, - NPCID.TheDestroyerTail, - NPCID.PrimeCannon, - NPCID.PrimeLaser, - NPCID.PrimeVice, - NPCID.PrimeSaw, - NPCID.GolemHead, - NPCID.GolemHeadFree, - NPCID.GolemFistRight, - NPCID.GolemFistLeft, - NPCID.Sharkron, - NPCID.Sharkron2, - NPCID.MoonLordHead, - NPCID.MoonLordHand, - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/BossRushHPChangeDict.cs b/Systems/Collections/NPCs/BossRushHPChangeDict.cs deleted file mode 100644 index 97646e5f90..0000000000 --- a/Systems/Collections/NPCs/BossRushHPChangeDict.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.NormalNPCs; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class BossRushHPChangeDict : ModSystem - { - public static IDictionary Dict { get; private set; } - - public override void OnModLoad() - { - Dict = new Dictionary - { - // Tier 1 - { NPCID.KingSlime, 300000 }, // 30 seconds - { NPCID.BlueSlime, 3600 }, - { NPCID.SlimeSpiked, 7200 }, - { NPCID.GreenSlime, 2700 }, - { NPCID.RedSlime, 5400 }, - { NPCID.PurpleSlime, 7200 }, - { NPCID.YellowSlime, 6300 }, - { NPCID.IceSlime, 4500 }, - { NPCID.UmbrellaSlime, 5400 }, - { NPCID.RainbowSlime, 30000 }, - { NPCID.Pinky, 15000 }, - { NPCType(), 21000 }, - { NPCType(), 18000 }, - { NPCType(), 24000 }, - - { NPCID.EyeofCthulhu, 450000 }, // 30 seconds - { NPCID.ServantofCthulhu, 6000 }, - { NPCType(), 12000 }, - - { NPCID.EaterofWorldsHead, 10000 }, // 30 seconds + immunity timer at start - { NPCID.EaterofWorldsBody, 10000 }, - { NPCID.EaterofWorldsTail, 10000 }, - - { NPCID.BrainofCthulhu, 100000 }, // 30 seconds with creepers - { NPCID.Creeper, 10000 }, - - { NPCID.QueenBee, 315000 }, // 30 seconds - { NPCID.Bee, 3000 }, - { NPCID.BeeSmall, 2000 }, - { NPCID.BigHornetHoney, 10000 }, - { NPCID.HornetHoney, 7500 }, - { NPCID.LittleHornetHoney, 5000 }, - - { NPCID.Deerclops, 315000 }, // 30 seconds - - { NPCID.SkeletronHead, 150000 }, // 30 seconds - { NPCID.SkeletronHand, 60000 }, - - { NPCID.WallofFlesh, 450000 }, // 30 seconds - { NPCID.WallofFleshEye, 450000 }, - { NPCID.TheHungry, 10000 }, - { NPCID.TheHungryII, 5000 }, - { NPCID.LeechHead, 5000 }, - { NPCID.LeechBody, 5000 }, - { NPCID.LeechTail, 5000 }, - - // Tier 2 - { NPCID.QueenSlimeBoss, 200000 }, // 30 seconds - { NPCID.QueenSlimeMinionBlue, 6000 }, - { NPCID.QueenSlimeMinionPink, 6000 }, - { NPCID.QueenSlimeMinionPurple, 5000 }, - - { NPCID.Spazmatism, 150000 }, // 30 seconds - { NPCID.Retinazer, 125000 }, - { NPCType(), 137500 }, - - { NPCID.TheDestroyer, 600000 }, // 30 seconds + immunity timer at start - { NPCID.TheDestroyerBody, 600000 }, - { NPCID.TheDestroyerTail, 600000 }, - { NPCID.Probe, 10000 }, - - { NPCID.SkeletronPrime, 160000 }, // 30 seconds - { NPCType(), 160000 }, - { NPCID.PrimeVice, 54000 }, - { NPCID.PrimeCannon, 45000 }, - { NPCID.PrimeSaw, 45000 }, - { NPCID.PrimeLaser, 38000 }, - - { NPCID.Plantera, 160000 }, // 30 seconds - { NPCID.PlanterasTentacle, 5000 }, - { NPCType(), 5000 }, - - // Tier 3 - { NPCID.Golem, 50000 }, // 30 seconds - { NPCID.GolemHead, 30000 }, - { NPCID.GolemHeadFree, 30000 }, - { NPCID.GolemFistLeft, 25000 }, - { NPCID.GolemFistRight, 25000 }, - - { NPCID.HallowBoss, 200000 }, // 30 seconds - - { NPCID.DukeFishron, 290000 }, // 30 seconds - - { NPCID.CultistBoss, 220000 }, // 30 seconds - { NPCID.CultistDragonHead, 60000 }, - { NPCID.CultistDragonBody1, 60000 }, - { NPCID.CultistDragonBody2, 60000 }, - { NPCID.CultistDragonBody3, 60000 }, - { NPCID.CultistDragonBody4, 60000 }, - { NPCID.CultistDragonTail, 60000 }, - { NPCID.AncientCultistSquidhead, 50000 }, - - { NPCID.MoonLordCore, 160000 }, // 1 minute - { NPCID.MoonLordHand, 45000 }, - { NPCID.MoonLordHead, 60000 }, - { NPCID.MoonLordLeechBlob, 800 } - - // 9.5 minutes in total for vanilla Boss Rush bosses - }; - } - - public override void Unload() - { - Dict?.Clear(); - Dict = null; - } - - public static bool TryGet(int npcType, out int newHP) - { - return Dict.TryGetValue(npcType, out newHP); - } - } -} diff --git a/Systems/Collections/NPCs/BossTypeDict.cs b/Systems/Collections/NPCs/BossTypeDict.cs deleted file mode 100644 index 20ddc6d87e..0000000000 --- a/Systems/Collections/NPCs/BossTypeDict.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crabulon; -using CalamityMod.NPCs.Cryogen; -using CalamityMod.NPCs.DesertScourge; -using CalamityMod.NPCs.DevourerofGods; -using CalamityMod.NPCs.ExoMechs.Apollo; -using CalamityMod.NPCs.ExoMechs.Ares; -using CalamityMod.NPCs.ExoMechs.Artemis; -using CalamityMod.NPCs.ExoMechs.Thanatos; -using CalamityMod.NPCs.HiveMind; -using CalamityMod.NPCs.Leviathan; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.Perforator; -using CalamityMod.NPCs.PlaguebringerGoliath; -using CalamityMod.NPCs.Polterghast; -using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.NPCs.Providence; -using CalamityMod.NPCs.Ravager; -using CalamityMod.NPCs.Signus; -using CalamityMod.NPCs.SlimeGod; -using CalamityMod.NPCs.StormWeaver; -using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.NPCs.Yharon; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class BossTypeDict : ModSystem - { - public static IDictionary Dict { get; private set; } - - public override void OnModLoad() - { - Dict = new SortedDictionary() - { - { NPCID.KingSlime, 1 }, - { NPCType(), 2 }, - { NPCID.EyeofCthulhu, 3 }, - { NPCType(), 4 }, - { NPCID.EaterofWorldsHead, 5 }, - { NPCID.EaterofWorldsBody, 5 }, - { NPCID.EaterofWorldsTail, 5 }, - { NPCID.BrainofCthulhu, 6 }, - { NPCType(), 7 }, - { NPCType(), 8 }, - { NPCID.QueenBee, 9 }, - { NPCID.SkeletronHead, 10 }, - { NPCType(), 11 }, - { NPCType(), 11 }, - { NPCType(), 11 }, - { NPCID.WallofFlesh, 12 }, - { NPCType(), 13 }, - { NPCID.Retinazer, 14 }, - { NPCID.Spazmatism, 14 }, - { NPCType(), 15 }, - { NPCID.TheDestroyer, 16 }, - { NPCType(), 17 }, - { NPCID.SkeletronPrime, 18 }, - { NPCType(), 19 }, - { NPCID.Plantera, 20 }, - { NPCType(), 21 }, - { NPCType(), 21 }, - { NPCType(), 22 }, - { NPCID.Golem, 23 }, - { NPCType(), 24 }, - { NPCID.DukeFishron, 25 }, - { NPCType(), 26 }, - { NPCID.CultistBoss, 27 }, - { NPCType(), 28 }, - { NPCID.MoonLordCore, 29 }, - { NPCType(), 30 }, - { NPCType(), 31 }, - { NPCType(), 32 }, - { NPCType(), 33 }, - { NPCType(), 34 }, - { NPCType(), 35 }, - { NPCType(), 36 }, - { NPCType(), 37 }, - { NPCType(), 38 }, - { NPCType(), 39 }, - { NPCType(), 40 }, - { NPCType(), 41 }, - { NPCType(), 41 }, - { NPCType(), 41 }, - { NPCType(), 41 }, - { NPCID.QueenSlimeBoss, 42 }, - { NPCID.HallowBoss, 43 }, - { NPCID.Deerclops, 44 } - }; - } - - public override void Unload() - { - Dict?.Clear(); - Dict = null; - } - - public static bool TryGet(int npcType, out int type) - { - return Dict.TryGetValue(npcType, out type); - } - } -} diff --git a/Systems/Collections/NPCs/BossValueDict.cs b/Systems/Collections/NPCs/BossValueDict.cs deleted file mode 100644 index 43b450ad80..0000000000 --- a/Systems/Collections/NPCs/BossValueDict.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Collections.Generic; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class BossValueDict : ModSystem - { - public static IDictionary Dict { get; private set; } - - public override void OnModLoad() - { - // NOTE: This does not account for Calamity's base value increases - Dict = new SortedDictionary - { - { NPCID.KingSlime, Item.buyPrice(0, 2) }, - { NPCID.EyeofCthulhu, Item.buyPrice(0, 2) }, - // Evil bosses drop 5 gold in vanilla; unmodified - { NPCID.QueenBee, Item.buyPrice(0, 8) }, - { NPCID.Deerclops, Item.buyPrice(0, 8) }, - { NPCID.SkeletronHead, Item.buyPrice(0, 12) }, - { NPCID.WallofFlesh, Item.buyPrice(0, 12) }, - { NPCID.QueenSlimeBoss, Item.buyPrice(0, 16) }, - { NPCID.Spazmatism, Item.buyPrice(0, 16) }, - { NPCID.Retinazer, Item.buyPrice(0, 16) }, - { NPCID.TheDestroyer, Item.buyPrice(0, 16) }, - { NPCID.SkeletronPrime, Item.buyPrice(0, 16) }, - { NPCID.Plantera, Item.buyPrice(0, 20) }, - { NPCID.Golem, Item.buyPrice(0, 25) }, - { NPCID.HallowBoss, Item.buyPrice(0, 30) }, - { NPCID.DukeFishron, Item.buyPrice(0, 30) }, - { NPCID.CultistBoss, Item.buyPrice(0, 50) } - // Moon Lord drops 1 plat in vanilla; unmodified - }; - } - - public override void Unload() - { - Dict?.Clear(); - Dict = null; - } - - public static bool TryGet(int npcType, out int value) - { - return Dict.TryGetValue(npcType, out value); - } - } -} diff --git a/Systems/Collections/NPCs/BuffedDungeonEnemiesList.cs b/Systems/Collections/NPCs/BuffedDungeonEnemiesList.cs deleted file mode 100644 index 78c00a647b..0000000000 --- a/Systems/Collections/NPCs/BuffedDungeonEnemiesList.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A which contains a of all NPC's IDs of NPCs who are buffed dungeon enemies. - /// - public sealed class BuffedDungeonEnemiesList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.SkeletonSniper, - NPCID.TacticalSkeleton, - NPCID.SkeletonCommando, - NPCID.Paladin, - NPCID.GiantCursedSkull, - NPCID.BoneLee, - NPCID.DiabolistWhite, - NPCID.DiabolistRed, - NPCID.NecromancerArmored, - NPCID.Necromancer, - NPCID.RaggedCasterOpenCoat, - NPCID.RaggedCaster, - NPCID.HellArmoredBonesSword, - NPCID.HellArmoredBonesMace, - NPCID.HellArmoredBonesSpikeShield, - NPCID.HellArmoredBones, - NPCID.BlueArmoredBonesSword, - NPCID.BlueArmoredBonesNoPants, - NPCID.BlueArmoredBonesMace, - NPCID.BlueArmoredBones, - NPCID.RustyArmoredBonesSwordNoArmor, - NPCID.RustyArmoredBonesSword, - NPCID.RustyArmoredBonesFlail, - NPCID.RustyArmoredBonesAxe - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if an NPC is a buffed Dungeon enemy. - /// - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/DeathModeSplittingWormList.cs b/Systems/Collections/NPCs/DeathModeSplittingWormList.cs deleted file mode 100644 index 9a9f638071..0000000000 --- a/Systems/Collections/NPCs/DeathModeSplittingWormList.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class DeathModeSplittingWormList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.DuneSplicerHead, - NPCID.DuneSplicerBody, - NPCID.DuneSplicerTail, - NPCID.DiggerHead, - NPCID.DiggerBody, - NPCID.DiggerTail, - NPCID.SeekerHead, - NPCID.SeekerBody, - NPCID.SeekerTail - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/EclipseBuffList.cs b/Systems/Collections/NPCs/EclipseBuffList.cs deleted file mode 100644 index aaff7f27b1..0000000000 --- a/Systems/Collections/NPCs/EclipseBuffList.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of all NPC Types that receive Post-DoG Eclipse Buff - /// - public sealed class EclipseBuffList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.Eyezor, - NPCID.Reaper, - NPCID.Frankenstein, - NPCID.SwampThing, - NPCID.Vampire, - NPCID.VampireBat, - NPCID.Butcher, - NPCID.CreatureFromTheDeep, - NPCID.Fritz, - NPCID.Nailhead, - NPCID.Psycho, - NPCID.DeadlySphere, - NPCID.DrManFly, - NPCID.ThePossessed, - NPCID.Mothron, - NPCID.MothronEgg, - NPCID.MothronSpawn - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/EnemyImmunitiesList.cs b/Systems/Collections/NPCs/EnemyImmunitiesList.cs deleted file mode 100644 index 60d1d76aa7..0000000000 --- a/Systems/Collections/NPCs/EnemyImmunitiesList.cs +++ /dev/null @@ -1,190 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AcidRain; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.Cryogen; -using CalamityMod.NPCs.DesertScourge; -using CalamityMod.NPCs.GreatSandShark; -using CalamityMod.NPCs.Leviathan; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.Perforator; -using CalamityMod.NPCs.PlaguebringerGoliath; -using CalamityMod.NPCs.PlagueEnemies; -using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.NPCs.Providence; -using CalamityMod.NPCs.Ravager; -using CalamityMod.NPCs.SlimeGod; -using CalamityMod.NPCs.SunkenSea; -using CalamityMod.NPCs.SupremeCalamitas; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains all of the NPC IDs of all NPCs that are immune to special debuffs. - /// - public sealed class EnemyImmunitiesList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.KingSlime, - NPCType(), - NPCType(), - NPCType(), - NPCID.EyeofCthulhu, - NPCType(), - NPCID.EaterofWorldsHead, - NPCID.EaterofWorldsBody, - NPCID.EaterofWorldsTail, - NPCID.BrainofCthulhu, - NPCID.Creeper, - NPCID.QueenBee, - NPCID.Deerclops, - NPCID.SkeletronHead, - NPCID.SkeletronHand, - NPCID.WallofFlesh, - NPCID.WallofFleshEye, - NPCID.PirateShipCannon, - NPCID.QueenSlimeBoss, - NPCID.Probe, - NPCID.Retinazer, - NPCID.Spazmatism, - NPCType(), - NPCID.SkeletronPrime, - NPCType(), - NPCID.PrimeCannon, - NPCID.PrimeSaw, - NPCID.PrimeLaser, - NPCID.PrimeVice, - NPCID.Plantera, - NPCID.PlanterasTentacle, - NPCType(), - NPCID.Everscream, - NPCID.SantaNK1, - NPCID.IceQueen, - NPCID.MourningWood, - NPCID.Pumpking, - NPCID.Mothron, - NPCID.Golem, - NPCID.GolemHead, - NPCID.GolemHeadFree, - NPCID.GolemFistRight, - NPCID.GolemFistLeft, - NPCID.MartianSaucerCore, - NPCID.MartianSaucerCannon, - NPCID.MartianSaucerTurret, - NPCID.DukeFishron, - NPCID.Sharkron, - NPCID.Sharkron2, - NPCID.HallowBoss, - NPCID.CultistBoss, - NPCID.CultistDragonHead, - NPCID.CultistDragonBody1, - NPCID.CultistDragonBody2, - NPCID.CultistDragonBody3, - NPCID.CultistDragonBody4, - NPCID.CultistDragonTail, - NPCID.AncientCultistSquidhead, - NPCID.MoonLordHead, - NPCID.MoonLordHand, - NPCID.MoonLordCore, - NPCID.MoonLordFreeEye, - NPCID.DD2WyvernT1, - NPCID.DD2WyvernT2, - NPCID.DD2WyvernT3, - NPCID.DD2DarkMageT1, - NPCID.DD2DarkMageT3, - NPCID.DD2SkeletonT1, - NPCID.DD2SkeletonT3, - NPCID.DD2WitherBeastT2, - NPCID.DD2WitherBeastT3, - NPCID.DD2DrakinT2, - NPCID.DD2DrakinT3, - NPCID.DD2KoboldWalkerT2, - NPCID.DD2KoboldWalkerT3, - NPCID.DD2KoboldFlyerT2, - NPCID.DD2KoboldFlyerT3, - NPCID.DD2OgreT2, - NPCID.DD2OgreT3, - NPCID.DD2Betsy, - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if an NPC is in this list. - /// - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/FrostMoonBuffList.cs b/Systems/Collections/NPCs/FrostMoonBuffList.cs deleted file mode 100644 index d94d780e9e..0000000000 --- a/Systems/Collections/NPCs/FrostMoonBuffList.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of all NPC Types that receive Post-DoG Frost Moon Buff - /// - public sealed class FrostMoonBuffList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.ZombieElf, - NPCID.ZombieElfBeard, - NPCID.ZombieElfGirl, - NPCID.PresentMimic, - NPCID.GingerbreadMan, - NPCID.Yeti, - NPCID.Everscream, - NPCID.IceQueen, - NPCID.SantaNK1, - NPCID.ElfCopter, - NPCID.Nutcracker, - NPCID.NutcrackerSpinning, - NPCID.ElfArcher, - NPCID.Krampus, - NPCID.Flocko - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/HardmodeNPCNerfList.cs b/Systems/Collections/NPCs/HardmodeNPCNerfList.cs deleted file mode 100644 index a8d0a144bd..0000000000 --- a/Systems/Collections/NPCs/HardmodeNPCNerfList.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class HardmodeNPCNerfList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - // Reduce contact damage by 25% - List = - [ - NPCID.AnglerFish, - NPCID.AngryTrapper, - NPCID.Arapaima, - NPCID.BlackRecluse, - NPCID.BlackRecluseWall, - NPCID.BloodJelly, - NPCID.FungoFish, - NPCID.GreenJellyfish, - NPCID.Clinger, - NPCID.ArmoredSkeleton, - NPCID.ArmoredViking, - NPCID.Mummy, - NPCID.DarkMummy, - NPCID.LightMummy, - NPCID.BloodFeeder, - NPCID.DesertBeast, - NPCID.ChaosElemental, - NPCID.BloodMummy, - NPCID.CorruptSlime, - NPCID.Slimeling, - NPCID.Corruptor, - NPCID.Crimslime, - NPCID.BigCrimslime, - NPCID.LittleCrimslime, - NPCID.CrimsonAxe, - NPCID.CursedHammer, - NPCID.Derpling, - NPCID.Herpling, - NPCID.DiggerHead, - NPCID.DesertGhoul, - NPCID.DesertGhoulCorruption, - NPCID.DesertGhoulCrimson, - NPCID.DesertGhoulHallow, - NPCID.DuneSplicerHead, - NPCID.EnchantedSword, - NPCID.FloatyGross, - NPCID.GiantBat, - NPCID.GiantFlyingFox, - NPCID.FungiSpore, - NPCID.GiantTortoise, - NPCID.IceTortoise, - NPCID.HoppinJack, - NPCID.Mimic, - NPCID.IlluminantBat, - NPCID.IlluminantSlime, - NPCID.JungleCreeper, - NPCID.JungleCreeperWall, - NPCID.DesertLamiaDark, - NPCID.DesertLamiaLight, - NPCID.BigMossHornet, - NPCID.GiantMossHornet, - NPCID.LittleMossHornet, - NPCID.MossHornet, - NPCID.TinyMossHornet, - NPCID.Moth, - NPCID.PigronCorruption, - NPCID.PigronCrimson, - NPCID.PigronHallow, - NPCID.Pixie, - NPCID.PossessedArmor, - NPCID.RockGolem, - NPCID.DesertScorpionWalk, - NPCID.DesertScorpionWall, - NPCID.Slimer, - NPCID.Slimer2, - NPCID.ToxicSludge, - NPCID.Unicorn, - NPCID.WanderingEye, - NPCID.Werewolf, - NPCID.Wolf, - NPCID.SeekerHead, - NPCID.Wraith, - NPCID.ChatteringTeethBomb, - NPCID.IceGolem, - NPCID.RainbowSlime, - NPCID.SandShark, - NPCID.SandsharkCorrupt, - NPCID.SandsharkCrimson, - NPCID.SandsharkHallow, - NPCID.ShadowFlameApparition, - NPCID.Parrot, - NPCID.PirateCorsair, - NPCID.PirateDeckhand, - NPCID.PirateGhost, - NPCID.BlueArmoredBonesMace, - NPCID.BlueArmoredBonesSword, - NPCID.BoneLee, - NPCID.DungeonSpirit, - NPCID.FlyingSnake, - NPCID.HellArmoredBones, - NPCID.HellArmoredBonesSpikeShield, - NPCID.HellArmoredBonesSword, - NPCID.MisterStabby, - NPCID.Butcher, - NPCID.CreatureFromTheDeep, - NPCID.DeadlySphere, - NPCID.Frankenstein, - NPCID.Fritz, - NPCID.Psycho, - NPCID.Reaper, - NPCID.SwampThing, - NPCID.ThePossessed, - NPCID.Vampire, - NPCID.VampireBat, - NPCID.HeadlessHorseman, - NPCID.Hellhound, - NPCID.Poltergeist, - NPCID.Scarecrow1, - NPCID.Scarecrow2, - NPCID.Scarecrow3, - NPCID.Scarecrow4, - NPCID.Scarecrow5, - NPCID.Scarecrow6, - NPCID.Scarecrow7, - NPCID.Scarecrow8, - NPCID.Scarecrow9, - NPCID.Scarecrow10, - NPCID.Splinterling, - NPCID.Flocko, - NPCID.GingerbreadMan, - NPCID.Krampus, - NPCID.Nutcracker, - NPCID.NutcrackerSpinning, - NPCID.PresentMimic, - NPCID.Yeti, - NPCID.ZombieElf, - NPCID.ZombieElfBeard, - NPCID.ZombieElfGirl, - NPCID.BloodEelHead, - NPCID.GoblinShark, - NPCID.EyeballFlyingFish, - NPCID.ZombieMerman - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/MinibossList.cs b/Systems/Collections/NPCs/MinibossList.cs deleted file mode 100644 index f2e0ed4f62..0000000000 --- a/Systems/Collections/NPCs/MinibossList.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AcidRain; -using CalamityMod.NPCs.GreatSandShark; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.PlagueEnemies; -using CalamityMod.NPCs.SunkenSea; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class MinibossList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCID.Pumpking, - NPCID.MourningWood, - NPCID.IceQueen, - NPCID.SantaNK1, - NPCID.Everscream, - NPCID.DD2Betsy, - NPCID.Mothron, - NPCID.MartianSaucer, - NPCID.MartianSaucerCannon, - NPCID.MartianSaucerCore, - NPCID.MartianSaucerTurret - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/NoRageWormSegmentList.cs b/Systems/Collections/NPCs/NoRageWormSegmentList.cs deleted file mode 100644 index 456dbaa828..0000000000 --- a/Systems/Collections/NPCs/NoRageWormSegmentList.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.DesertScourge; -using CalamityMod.NPCs.DevourerofGods; -using CalamityMod.NPCs.ExoMechs.Ares; -using CalamityMod.NPCs.ExoMechs.Thanatos; -using CalamityMod.NPCs.StormWeaver; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class NoRageWormSegmentList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/PierceResistList.cs b/Systems/Collections/NPCs/PierceResistList.cs deleted file mode 100644 index efbe96843f..0000000000 --- a/Systems/Collections/NPCs/PierceResistList.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.DesertScourge; -using CalamityMod.NPCs.DevourerofGods; -using CalamityMod.NPCs.ExoMechs.Ares; -using CalamityMod.NPCs.ExoMechs.Thanatos; -using CalamityMod.NPCs.Leviathan; -using CalamityMod.NPCs.Perforator; -using CalamityMod.NPCs.ProfanedGuardians; -using CalamityMod.NPCs.Ravager; -using CalamityMod.NPCs.StormWeaver; -using CalamityMod.NPCs.SupremeCalamitas; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class PierceResistList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.EaterofWorldsHead, - NPCID.EaterofWorldsBody, - NPCID.EaterofWorldsTail, - NPCID.Creeper, - NPCID.TheDestroyer, - NPCID.TheDestroyerBody, - NPCID.TheDestroyerTail, - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType(), - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/PumpkinMoonBuffList.cs b/Systems/Collections/NPCs/PumpkinMoonBuffList.cs deleted file mode 100644 index 6ab32c0323..0000000000 --- a/Systems/Collections/NPCs/PumpkinMoonBuffList.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a of all NPC Types that receive Post-DoG Pumpkin Moon Buff - /// - public sealed class PumpkinMoonBuffList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.Scarecrow1, - NPCID.Scarecrow2, - NPCID.Scarecrow3, - NPCID.Scarecrow4, - NPCID.Scarecrow5, - NPCID.Scarecrow6, - NPCID.Scarecrow7, - NPCID.Scarecrow8, - NPCID.Scarecrow9, - NPCID.Scarecrow10, - NPCID.HeadlessHorseman, - NPCID.MourningWood, - NPCID.Splinterling, - NPCID.Pumpking, - NPCID.PumpkingBlade, - NPCID.Hellhound, - NPCID.Poltergeist - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NPCs/ZeroContactDamageNPCList.cs b/Systems/Collections/NPCs/ZeroContactDamageNPCList.cs deleted file mode 100644 index dbc3aa6ffd..0000000000 --- a/Systems/Collections/NPCs/ZeroContactDamageNPCList.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System.Collections.Generic; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Systems.Collections -{ - public sealed class ZeroContactDamageNPCList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.Harpy, - NPCID.Salamander, - NPCID.Salamander2, - NPCID.Salamander3, - NPCID.Salamander4, - NPCID.Salamander5, - NPCID.Salamander6, - NPCID.Salamander7, - NPCID.Salamander8, - NPCID.Salamander9, - NPCID.GiantCursedSkull, - NPCID.FungiBulb, - NPCID.GiantFungiBulb, - NPCID.IcyMerman, - NPCID.AngryNimbus, - NPCID.SandElemental, - NPCID.DarkCaster, - NPCID.FireImp, - NPCID.Tim, - NPCID.CultistArcherBlue, - NPCID.DesertDjinn, - NPCID.DiabolistRed, - NPCID.DiabolistWhite, - NPCID.Gastropod, - NPCID.IceElemental, - NPCID.IchorSticker, - NPCID.Necromancer, - NPCID.NecromancerArmored, - NPCID.RaggedCaster, - NPCID.RaggedCasterOpenCoat, - NPCID.RuneWizard, - NPCID.SkeletonArcher, - NPCID.SkeletonCommando, - NPCID.SkeletonSniper, - NPCID.TacticalSkeleton, - NPCID.Clown, - NPCID.GoblinArcher, - NPCID.GoblinSorcerer, - NPCID.GoblinSummoner, - NPCID.PirateCrossbower, - NPCID.PirateDeadeye, - NPCID.PirateCaptain, - NPCID.SnowmanGangsta, - NPCID.SnowBalla, - NPCID.DrManFly, - NPCID.Eyezor, - NPCID.Nailhead, - NPCID.BrainScrambler, - NPCID.GigaZapper, - NPCID.RayGunner, - NPCID.ScutlixRider, - NPCID.MartianWalker, - NPCID.MartianTurret, - NPCID.ElfCopter, - NPCID.ElfArcher, - NPCID.NebulaBrain, - NPCID.NebulaSoldier, - NPCID.StardustCellSmall, - NPCID.StardustJellyfishBig, - NPCID.StardustSoldier, - NPCID.StardustSpiderBig, - NPCID.VortexHornetQueen, - NPCID.VortexRifleman, - NPCID.VortexSoldier, - NPCID.PirateShipCannon, - NPCID.MartianSaucer, - NPCID.MartianSaucerCannon, - NPCID.MartianSaucerCore, - NPCID.MartianSaucerTurret, - NPCID.Probe, - NPCID.CultistBoss, - NPCID.GolemHead, - NPCID.GolemHeadFree, - NPCID.MoonLordFreeEye, - NPCID.BloodSquid, - NPCID.PlanterasHook, - NPCID.Dandelion, - NPCID.DD2DarkMageT1, - NPCID.DD2DarkMageT3, - NPCID.DD2OgreT2, - NPCID.DD2OgreT3, - NPCID.DD2GoblinBomberT1, - NPCID.DD2GoblinBomberT2, - NPCID.DD2GoblinBomberT3, - NPCID.DD2JavelinstT1, - NPCID.DD2JavelinstT2, - NPCID.DD2JavelinstT3, - NPCID.DD2KoboldWalkerT2, - NPCID.DD2KoboldWalkerT3, - NPCID.DD2DrakinT2, - NPCID.DD2DrakinT3, - NPCID.DD2KoboldFlyerT2, - NPCID.DD2KoboldFlyerT3, - NPCID.DD2WitherBeastT2, - NPCID.DD2WitherBeastT3, - NPCID.DD2LightningBugT3, - NPCID.MourningWood, - NPCID.Pumpking, - NPCID.Everscream, - NPCID.IceQueen, - NPCID.SantaNK1, - NPCID.DevourerBody, - NPCID.DevourerTail, - NPCID.DiggerBody, - NPCID.DiggerTail, - NPCID.TombCrawlerBody, - NPCID.TombCrawlerTail, - NPCID.DuneSplicerBody, - NPCID.DuneSplicerTail, - NPCID.GiantWormBody, - NPCID.GiantWormTail, - NPCID.LeechBody, - NPCID.LeechTail, - NPCID.StardustWormBody, - NPCID.StardustWormTail, - NPCID.SeekerBody, - NPCID.SeekerTail, - NPCID.BoneSerpentBody, - NPCID.BoneSerpentTail, - NPCID.WyvernBody, - NPCID.WyvernTail, - NPCID.WyvernBody2, - NPCID.WyvernBody3, - NPCID.WyvernLegs, - NPCID.CultistDragonBody1, - NPCID.CultistDragonBody2, - NPCID.CultistDragonBody3, - NPCID.CultistDragonBody4, - NPCID.CultistDragonTail, - NPCID.BloodEelBody, - NPCID.BloodEelTail, - NPCID.AncientDoom - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/NeedsDebuffIconDisplayList.cs b/Systems/Collections/NeedsDebuffIconDisplayList.cs deleted file mode 100644 index 1cd6d90efe..0000000000 --- a/Systems/Collections/NeedsDebuffIconDisplayList.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.NPCs.NormalNPCs; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class NeedsDebuffIconDisplayList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - NPCID.TargetDummy, - NPCID.WallofFleshEye, - NPCType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int npcType) => List.Contains(npcType); - } -} diff --git a/Systems/Collections/PersistentBuffList.cs b/Systems/Collections/PersistentBuffList.cs deleted file mode 100644 index 01e165e604..0000000000 --- a/Systems/Collections/PersistentBuffList.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.Potions; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class PersistentBuffList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - BuffType(), - BuffType(), - BuffType(), - BuffID.WeaponImbueVenom, - BuffID.WeaponImbueCursedFlames, - BuffID.WeaponImbueFire, - BuffID.WeaponImbueGold, - BuffID.WeaponImbueIchor, - BuffID.WeaponImbueNanites, - BuffID.WeaponImbueConfetti, - BuffID.WeaponImbuePoison - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if this buffType is a PersistentBuff. - /// - public static bool Includes(int buffType) => List.Contains(buffType); - } -} diff --git a/Systems/Collections/PierceResistExceptionLeviAureusList.cs b/Systems/Collections/PierceResistExceptionLeviAureusList.cs deleted file mode 100644 index 4c3f202da1..0000000000 --- a/Systems/Collections/PierceResistExceptionLeviAureusList.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Rogue; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class PierceResistExceptionLeviAureusList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ProjectileID.NettleBurstEnd, - ProjectileID.NettleBurstLeft, - ProjectileID.NettleBurstRight, - ProjectileID.PrincessWeapon, - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int projectileType) => List.Contains(projectileType); - } -} diff --git a/Systems/Collections/PierceResistExceptionList.cs b/Systems/Collections/PierceResistExceptionList.cs deleted file mode 100644 index 95dc2ecceb..0000000000 --- a/Systems/Collections/PierceResistExceptionList.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.DraedonsArsenal; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Melee.MaceFlails; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.Projectiles.Summon; -using CalamityMod.Projectiles.Typeless; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - public sealed class PierceResistExceptionList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ProjectileID.Arkhalis, - ProjectileID.ChargedBlasterLaser, - ProjectileID.ClingerStaff, - ProjectileID.FinalFractal, - ProjectileID.FlyingKnife, - ProjectileID.LastPrismLaser, - ProjectileID.MonkStaffT3, - ProjectileID.PiercingStarlight, - ProjectileID.Terragrim, - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int projectileType) => List.Contains(projectileType); - } -} diff --git a/Systems/Collections/ProjectileDestroyExceptionsList.cs b/Systems/Collections/ProjectileDestroyExceptionsList.cs deleted file mode 100644 index 5992a004e2..0000000000 --- a/Systems/Collections/ProjectileDestroyExceptionsList.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.DraedonsArsenal; -using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Melee.MaceFlails; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Rogue; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that holds a list of all projectiles that should be, exceptionally, ignored by projectile destruction. - /// - public sealed class ProjectileDestroyExceptionsList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - // Holdout projectiles. - ProjectileID.Phantasm, - ProjectileID.VortexBeater, - ProjectileID.DD2PhoenixBow, - ProjectileID.LastPrism, - ProjectileID.LastPrismLaser, - ProjectileID.LaserMachinegun, - ProjectileID.ChargedBlasterCannon, - ProjectileID.MedusaHead, - - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - - // Some hostile boss projectiles. - ProjectileID.SaucerDeathray, - ProjectileID.PhantasmalDeathray, - - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType() - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if a projectile belongs in the exception list. - /// - public static bool Includes(int projType) => List.Contains(projType); - } -} diff --git a/Systems/Collections/SicknessDebuffsList.cs b/Systems/Collections/SicknessDebuffsList.cs deleted file mode 100644 index 7d687952a6..0000000000 --- a/Systems/Collections/SicknessDebuffsList.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// A that contains a that has all the Sickness Debuffs' IDs. - /// - public sealed class SicknessDebuffsList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - BuffID.Poisoned, - BuffID.Venom, - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType() - ]; - } - - public override void Unload() => List = null; - - /// - /// A shorthand method to check if a buff ID is a Sickness Debuff. - /// - public static bool Includes(int buffID) => List.Contains(buffID); - } -} diff --git a/Systems/Collections/SunkenSeaBiomeCorrespondentDict.cs b/Systems/Collections/SunkenSeaBiomeCorrespondentDict.cs index 5fb07cab3d..0b6319d9b2 100644 --- a/Systems/Collections/SunkenSeaBiomeCorrespondentDict.cs +++ b/Systems/Collections/SunkenSeaBiomeCorrespondentDict.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Systems.Collections { SunkenSeaBiomeFlags.PolypForest, (spawnInfo => spawnInfo.Player.Calamity().ZonePolypForest, GetInstance().Type) }, { SunkenSeaBiomeFlags.GleamingBurrows, (spawnInfo => spawnInfo.Player.Calamity().ZoneGleamingBurrows, GetInstance().Type) }, { SunkenSeaBiomeFlags.BasaltGully, (spawnInfo => spawnInfo.Player.Calamity().ZoneBasaltGully, GetInstance().Type) }, + { SunkenSeaBiomeFlags.ClamDen, (spawnInfo => spawnInfo.Player.Calamity().ZoneClamDen, GetInstance().Type) }, }; } diff --git a/Systems/Collections/VeneratedLocketBanList.cs b/Systems/Collections/VeneratedLocketBanList.cs deleted file mode 100644 index e7a6921a99..0000000000 --- a/Systems/Collections/VeneratedLocketBanList.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using CalamityMod.Items.Weapons.Rogue; -using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Systems.Collections -{ - /// - /// To ban projectiles from locket, mainly spikeballs altho Toasty asked me to add mod calls for adding stuff like Dreamtastic - /// - public sealed class VeneratedLocketBanList : ModSystem - { - public static IList List { get; private set; } - - public override void OnModLoad() - { - List = - [ - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType() - ]; - } - - public override void Unload() => List = null; - - public static bool Includes(int itemType) => List.Contains(itemType); - } -} diff --git a/Systems/EntityUpdateInterceptionSystem.cs b/Systems/EntityUpdateInterceptionSystem.cs index 98a14899e8..5390343164 100644 --- a/Systems/EntityUpdateInterceptionSystem.cs +++ b/Systems/EntityUpdateInterceptionSystem.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Systems #region Post NPC Updating // TODO -- Apply caching to this process. For now most of the looping issues should be eradicated but it can be reduced further. - public override void PostUpdateNPCs() => CalamityGlobalNPC.ResetTownNPCNameBools(); + public override void PostUpdateNPCs() => CalamityGlobalTownNPC.ResetTownNPCNameBools(); #endregion #region Tile Entity Time Handler diff --git a/Systems/GlobalSaveDataSystem.cs b/Systems/GlobalSaveDataSystem.cs new file mode 100644 index 0000000000..ff1efe1b16 --- /dev/null +++ b/Systems/GlobalSaveDataSystem.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems +{ + public class GlobalSaveDataSystem : ModSystem + { + internal static List GlobalSaveDataKeys = []; + + /// + /// The directory in which all files related to globall saved data are stored. + /// + internal static string GlobalSaveDataDirectoryPath; + + /// + /// The path to the text file which contains all globally saved data keys. + /// + internal static string GlobalSaveDataKeysPath; + + /// + /// The path to the README file explaining the purpose of the directory. + /// + internal static string READMEPath; + + public override void OnModLoad() + { + string savePathByOS = OperatingSystem.IsLinux() ? "~/.local/share/Terraria/tModloader/" : Main.SavePath; + GlobalSaveDataDirectoryPath = savePathByOS + Path.DirectorySeparatorChar + "CalamityModGlobalSaveData"; + GlobalSaveDataKeysPath = savePathByOS + Path.DirectorySeparatorChar + "CalamityModGlobalSaveData" + Path.DirectorySeparatorChar + "GlobalSaveDataKeys.txt"; + READMEPath = savePathByOS + Path.DirectorySeparatorChar + "CalamityModGlobalSaveData" + Path.DirectorySeparatorChar + "README.txt"; + + // Ensure that the save data keys text file exists. If not, create a new one. + if (!File.Exists(GlobalSaveDataKeysPath)) + { + // Create the directory if necessary. + if (!Directory.Exists(GlobalSaveDataDirectoryPath)) + Directory.CreateDirectory(GlobalSaveDataDirectoryPath); + + // Create both the Global Save Data text file, as well as a README file explaining the directory's purpose. + if (!File.Exists(READMEPath)) + { + using StreamWriter readme = File.CreateText(READMEPath); + readme.WriteLine("Hi! You're probably wondering what this directory is and why it exists if you've found it."); + readme.WriteLine("This is how the Calamity Mod currently manages data that is saved globally across all worlds. " + + "You will find all keys managing globally saved data in the other text file within this folder. You are free to remove " + + "any of those keys if you wish to reapply the lock on whatever in-game content they unlock. If you have no interest in doing so " + + "then it is recommended you simply leave the file as is."); + } + + File.CreateText(GlobalSaveDataKeysPath); + } + // If it does exist, read all keys from the text file and save them into the list. + else + { + GlobalSaveDataKeys = File.ReadAllLines(GlobalSaveDataKeysPath).ToList(); + } + } + + /// + /// Checks whether or not a key has been saved into the GlobalSaveDataKeys text file. + /// + /// True if the key has been saved, false otherwise. + public static bool IsKeyAlreadySaved(string key) => GlobalSaveDataKeys.Contains(key); + + /// + /// Saves a specified key into the GlobalSaveDataKeys text file. + /// + public static void SaveKey(string key) + { + // If the key already exists, log it as a warning and don't run any code. + if (GlobalSaveDataKeys.Contains(key)) + { + CalamityMod.Log.Error($"WARNING! A global save data key \"{key}\" which has already been registered is attempting to be registered again. " + + "Please report this to the Calamity Mod Team if you see this!"); + return; + } + + File.AppendAllLines(GlobalSaveDataKeysPath, [key]); + GlobalSaveDataKeys.Add(key); + } + } +} diff --git a/Systems/Graphic/CalamityModWaterStyle.cs b/Systems/Graphic/CalamityModWaterStyle.cs deleted file mode 100644 index 15b3388551..0000000000 --- a/Systems/Graphic/CalamityModWaterStyle.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Terraria; -using Terraria.Graphics; -using Terraria.ModLoader; - -namespace CalamityMod.Systems -{ - public abstract class CalamityModWaterStyle : ModWaterStyle - { - /// - /// Allows water styles to manipulate what color the liquid is drawn to, this can allow waters to be see-throughable to see backgrounds (surface and underground backgrounds not walls) - /// - /// X position of the water - /// Y position of the water - /// The vertexColor of the water color, this is both used to get the current color and to set the color of the water - public virtual void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) - { - } - - /// - /// Allows you to determine how much light this water emits.
- /// It can also let you light up the block in front of this water.
- /// See for vanilla tile light values to use as a reference.
- ///
- /// The x position in tile coordinates. - /// The y position in tile coordinates. - /// The red component of light, usually a value between 0 and 1 - /// The green component of light, usually a value between 0 and 1 - /// The blue component of light, usually a value between 0 and 1 - public virtual void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) - { - } - } - - internal static class CalamityWaterLoader - { - internal static void ModifyLightSetup(ref readonly Tile tile, int i, int j, int type, ref float r, ref float g, ref float b) - { - if (TryGetCalamityWaterStyle(type, out var styles)) - { - styles.ModifyLight(in tile, i, j, ref r, ref g, ref b); - } - } - - internal static void DrawColorSetup(int x, int y, int type, ref VertexColors liquidColor, bool isSlope = false) - { - if (TryGetCalamityWaterStyle(type, out var styles)) - { - styles.DrawColor(x, y, ref liquidColor, isSlope); - } - } - - internal static bool TryGetCalamityWaterStyle(int type, out CalamityModWaterStyle waterStyle) - { - waterStyle = GetCalamityWaterStyle(type); - return waterStyle != null; - } - - internal static CalamityModWaterStyle GetCalamityWaterStyle(int type) - { - var modWaterStyle = LoaderManager.Get().Get(type); - if (modWaterStyle is CalamityModWaterStyle calWaterStyle) - { - return calWaterStyle; - } - - return null; - } - } -} diff --git a/Systems/Graphic/DoGVisualsManager.cs b/Systems/Graphic/DoGVisualsManager.cs new file mode 100644 index 0000000000..fc913ca06a --- /dev/null +++ b/Systems/Graphic/DoGVisualsManager.cs @@ -0,0 +1,357 @@ +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Graphics; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Skies; +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic +{ + public class DoGVisualsManager : ModSystem + { + public float FillProgress = 0; + + public float BackgroundLightningFill; + + public float BackgroundLightningMax; + + public float BackgroundLightningTimer; + + /// + /// Whether or not the background render targets should have their contents drawn to them. + /// + public static bool ShouldDrawToBackgroundTargets => DoGSky.SkyIntensity > 0f; + + /// + /// Whether or not the foreground render target should have its contents drawn to it. + /// + public static bool ShouldDrawToForegroundTarget => MetaballManager.metaballs.Any(m => m.AnythingToDraw && m is DoGDistortionMetaball); + + /// + /// The actual effects and contents seen inside the rift in the background of DoG's fight. + /// + public static RenderTargetLease DistortionRiftBackgroundContentsTarget { get; private set; } + + /// + /// The primitives used to make up the shape of the rift seen in the background of DoG's fight. + /// + public static RenderTargetLease DistortionRiftPrimitivesTarget { get; private set; } + + /// + /// The actual effects and contents seen inside of certain attacks used by DoG. Also used for DoG's distortion metaballs. + /// + public static RenderTargetLease DistortionForegroundContentsTarget { get; private set; } + + public override void OnModLoad() + { + if (Main.dedServ) + return; + + On_Main.DrawSunAndMoon += DiscardCelestialObjects; + } + + public override void PostSetupContent() + { + if (Main.dedServ) + return; + + Main.QueueMainThreadAction(() => + { + DistortionRiftBackgroundContentsTarget = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); + DistortionRiftPrimitivesTarget = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); + DistortionForegroundContentsTarget = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); + }); + RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets; + } + + public override void OnModUnload() + { + if (Main.dedServ) + return; + + On_Main.DrawSunAndMoon -= DiscardCelestialObjects; + RenderTargetManager.RenderTargetUpdateLoopEvent -= PrepareTargets; + } + + public override void PostUpdateEverything() + { + if (DoGSky.SkyIntensity > 0.1f) + { + // Disable ambient sky entities while DoG's background effects are active. + if (SkyManager.Instance["Ambience"].IsActive()) + SkyManager.Instance["Ambience"].Deactivate(); + + if (CalamityClientConfig.Instance.FancyBackgroundVisuals) + { + // Randomly flicker between different values to create a natural lightning effect in the background of the + // Distortion rift's clouds. + if (Main.rand.NextBool(200) && DoGSky.SkyIntensity > 0f && BackgroundLightningTimer <= 0f) + { + BackgroundLightningTimer = Main.rand.NextBool(10) ? Main.rand.Next(30, 45) : Main.rand.Next(5, 20); + BackgroundLightningMax = Main.rand.NextFloat(0.7f, 0.9f); + } + + if (BackgroundLightningTimer > 0f) + { + float minFill = BackgroundLightningMax * 0.5f; + BackgroundLightningFill = Main.rand.NextFloat(minFill, BackgroundLightningMax); + BackgroundLightningTimer--; + } + else + { + if (BackgroundLightningTimer < 0f) + BackgroundLightningTimer = 0f; + BackgroundLightningFill = MathHelper.Lerp(BackgroundLightningFill, 0f, 0.05f); + } + } + } + } + + public override void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor) + { + if (DoGSky.SkyIntensity > 0f) + FillProgress += 0.05f; + else + FillProgress -= 0.05f; + + // Darken the lighting color of both the background and foreground. + FillProgress = MathHelper.Clamp(FillProgress, 0, 1); + if (FillProgress > 0) + { + Color colorToUse = DoGSky.DoGSkyColor; + float tileBrightness = CalamityClientConfig.Instance.FancyBackgroundVisuals ? 35f : 190f; + + backgroundColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, Color.White.R * 0.035f, FillProgress); + backgroundColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, Color.White.G * 0.035f, FillProgress); + backgroundColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, Color.White.B * 0.035f, FillProgress); + backgroundColor = new(backgroundColor.ToVector3() + colorToUse.ToVector3() * 0.025f * FillProgress); + + tileColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, tileBrightness, FillProgress); + tileColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, tileBrightness, FillProgress); + tileColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, tileBrightness, FillProgress); + + float tileColorAdditive = CalamityClientConfig.Instance.FancyBackgroundVisuals ? 0.075f : 0.4f; + tileColor = new(tileColor.ToVector3() + colorToUse.ToVector3() * tileColorAdditive * FillProgress); + } + } + + private void DiscardCelestialObjects(On_Main.orig_DrawSunAndMoon orig, Main self, Main.SceneArea sceneArea, Color moonColor, Color sunColor, float tempMushroomInfluence) + { + // Fade out the sun and moon during DoG's fight. + if (DoGSky.SkyIntensity > 0f) + { + tempMushroomInfluence = DoGSky.SkyIntensity; + moonColor *= 1f - DoGSky.SkyIntensity; + } + + orig(self, sceneArea, moonColor, sunColor, tempMushroomInfluence); + } + + private void PrepareTargets() + { + // Determine when targets should have their contents drawn onto them in order to save on performance. + if (ShouldDrawToBackgroundTargets) + { + // Draw the background which'll be displayed inside the rift onto a render target. + using (DistortionRiftBackgroundContentsTarget.Scope(clearColor: Color.Transparent)) + { + DrawDistortionRiftBackground(); + } + + using (DistortionRiftPrimitivesTarget.Scope(clearColor: Color.Transparent)) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the primitives which comprise the rift to another render target. + if (SkyManager.Instance["CalamityMod:DevourerofGodsHead"].IsActive()) + (SkyManager.Instance["CalamityMod:DevourerofGodsHead"] as DoGSky).DrawRiftToRenderTarget(); + + Main.spriteBatch.End(); + } + } + + if (ShouldDrawToForegroundTarget) + { + // Draw the background which'll be displayed for all distortion-related effects done in the foreground (same layer as the player). + using (DistortionForegroundContentsTarget.Scope(clearColor: Color.Transparent)) + { + DrawDistortionForeground(); + } + } + } + + #region Distortion Background Drawing + private void DrawDistortionRiftBackground() + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw a black tile behind everything since the shader used to generate the clouds will appear transparent with dark colors, thus revealing + // the sky and any of its effects under the rift. + DrawDistortionLightningBackdrop_Background(); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the layer of rolling clouds in the background. + DrawDistortionClouds_Background(); + + Main.spriteBatch.End(); + } + + private void DrawDistortionLightningBackdrop_Background() + { + // Flicker between white and black for the lightning effect. + Color backdropColor = Color.Lerp(Color.Lerp(Color.Black, Color.White, BackgroundLightningFill), DoGSky.DoGSkyColor, 0.25f); + Main.spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), backdropColor); + } + + private void DrawDistortionClouds_Background() + { + Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader.Value; + Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Color darkPixelColor = Color.Lerp(Color.Lerp(Color.Black, Color.DarkGray, 0.3f), Color.Black, BackgroundLightningFill * 0.8f); + Color brightPixelColor = Color.Lerp(Color.Lerp(Color.Black, DoGSky.DoGSkyColor, 0.6f), Color.Black, BackgroundLightningFill * 0.8f); + + rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + rollingCloudsShader.Parameters["overallOpacity"].SetValue(1f); + rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.24f); + rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(2f); + rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f); + rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f); + rollingCloudsShader.Parameters["erosionMin"].SetValue(0.06f); + rollingCloudsShader.Parameters["gradientPrecision"].SetValue(20f); + + rollingCloudsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + rollingCloudsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.001f); + + rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(darkPixelColor.ToVector3()); + rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(brightPixelColor.ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[2] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + rollingCloudsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + #endregion + + #region Distortion Foreground Drawing + private void DrawDistortionForeground() + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw a black tile for the same reasoning explained above for the background drawing. + Main.spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw a layer of rolling clouds in the background. + DrawDistortionClouds_Foreground(); + + // Draw the winds effect in front of everything. + DrawDistortionWinds_Foreground(); + + Main.spriteBatch.End(); + } + + private void DrawDistortionWinds_Foreground() + { + Effect windsShader = CalamityShaders.DoGDistortionWindsShader.Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Texture2D windsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; + Texture2D highlightsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/SharpNoise").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Pebbles").Value; + + windsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 1.075f); + windsShader.Parameters["overallOpacity"].SetValue(0.8f); + windsShader.Parameters["distortionStrength"].SetValue(0.3f); + windsShader.Parameters["mainNoiseTextureScale"].SetValue(1.6f); + windsShader.Parameters["distortionTextureScale"].SetValue(1.76f); + windsShader.Parameters["erosionTextureScale"].SetValue(2f); + windsShader.Parameters["erosionMin"].SetValue(0.5f); + windsShader.Parameters["gradientPrecision"].SetValue(20f); + + windsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + windsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / windsTexture.Size() * 0.025f); + + windsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.64f).ToVector3()); + windsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.32f).ToVector3()); + windsShader.Parameters["highlightsColor"].SetValue(Color.Fuchsia.ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = highlightsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap; + + Main.instance.GraphicsDevice.Textures[2] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[3] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearWrap; + + // Fuchsia highlights. + windsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + + windsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.8f); + windsShader.Parameters["overallOpacity"].SetValue(0.7f); + windsShader.Parameters["distortionStrength"].SetValue(0.6f); + windsShader.Parameters["mainNoiseTextureScale"].SetValue(1.24f); + windsShader.Parameters["distortionTextureScale"].SetValue(0.46f); + windsShader.Parameters["erosionTextureScale"].SetValue(3f); + windsShader.Parameters["erosionMin"].SetValue(0.75f); + windsShader.Parameters["highlightsColor"].SetValue(new Color(0, 221, 250).ToVector3()); + + // Cyan highlights. + windsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + + private void DrawDistortionClouds_Foreground() + { + Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader.Value; + Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 2f); + rollingCloudsShader.Parameters["overallOpacity"].SetValue(1f); + rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.12f); + rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(1f); + rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f); + rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f); + rollingCloudsShader.Parameters["erosionMin"].SetValue(0.06f); + rollingCloudsShader.Parameters["gradientPrecision"].SetValue(20f); + + rollingCloudsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + rollingCloudsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.025f); + + rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.Black, new(0, 221, 250), 0.25f).ToVector3()); + rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, Color.Fuchsia, 0.25f).ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = cloudsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[2] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + rollingCloudsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + #endregion + } +} diff --git a/Systems/Graphic/GeneralDrawLayerSystem.cs b/Systems/Graphic/GeneralDrawLayerSystem.cs new file mode 100644 index 0000000000..e96ef60311 --- /dev/null +++ b/Systems/Graphic/GeneralDrawLayerSystem.cs @@ -0,0 +1,131 @@ +using System; +using CalamityMod.Enums; +using CalamityMod.Utilities.Daybreak; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic +{ + internal sealed class GeneralDrawLayerSystem : ModSystem + { + public static event Action OnPrepareDraw; + public static event Action OnDrawLayer; + public static event Action OnDrawLayerLate; + + public static event Action OnBeforeAllTiles; + public static event Action OnBeforeSolidTiles; + public static event Action OnBeforeNPCs; + public static event Action OnAfterNPCs; + public static event Action OnBeforeProjectiles; + public static event Action OnAfterProjectiles; + public static event Action OnAfterPlayers; + public static event Action OnAfterDusts; + public static event Action OnAfterEverything; + + public override void OnModLoad() + { + On_Main.CheckMonoliths += CheckMonoliths; + On_Main.DrawBackgroundBlackFill += GeneralDrawLayer_DrawToLayer_BeforeAllTiles; + On_Main.DoDraw_Tiles_Solid += GeneralDrawLayer_DrawToLayer_BeforeSolidTiles; + On_Main.DoDraw_DrawNPCsOverTiles += GeneralDrawLayer_DrawToLayer_NPCs; + On_Main.DrawProjectiles += GeneralDrawLayer_DrawToLayer_Projectiles; + On_Main.DrawPlayers_AfterProjectiles += GeneralDrawLayer_DrawToLayer_AfterPlayers; + On_Main.DrawDust += GeneralDrawLayer_DrawToLayer_AfterDusts; + On_Main.DrawInfernoRings += GeneralDrawLayer_DrawToLayer_AfterEverything; + } + + public override void Unload() + { + OnPrepareDraw = null; + OnDrawLayer = null; + OnDrawLayerLate = null; + + OnBeforeAllTiles = null; + OnBeforeSolidTiles = null; + OnBeforeNPCs = null; + OnAfterNPCs = null; + OnBeforeProjectiles = null; + OnAfterProjectiles = null; + OnAfterPlayers = null; + OnAfterDusts = null; + OnAfterEverything = null; + } + + private static void CheckMonoliths(On_Main.orig_CheckMonoliths orig) + { + orig(); + OnPrepareDraw?.Invoke(); + } + + #region GeneralDrawLayer Systems Drawing + private static void GeneralDrawLayer_DrawForLayer(GeneralDrawLayer drawLayer) + { + OnDrawLayer?.Invoke(drawLayer); + OnDrawLayerLate?.Invoke(drawLayer); + + var callback = drawLayer switch + { + GeneralDrawLayer.BeforeAllTiles => OnBeforeAllTiles, + GeneralDrawLayer.BeforeSolidTiles => OnBeforeSolidTiles, + GeneralDrawLayer.BeforeNPCs => OnBeforeNPCs, + GeneralDrawLayer.AfterNPCs => OnAfterNPCs, + GeneralDrawLayer.BeforeProjectiles => OnBeforeProjectiles, + GeneralDrawLayer.AfterProjectiles => OnAfterProjectiles, + GeneralDrawLayer.AfterPlayers => OnAfterPlayers, + GeneralDrawLayer.AfterDusts => OnAfterDusts, + GeneralDrawLayer.AfterEverything => OnAfterEverything, + _ => null + }; + callback?.Invoke(); + } + + private static void GeneralDrawLayer_DrawToLayer_BeforeAllTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self) + { + Main.spriteBatch.End(out var ss); + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeAllTiles); + Main.spriteBatch.Begin(ss); + orig(self); + } + + private static void GeneralDrawLayer_DrawToLayer_BeforeSolidTiles(On_Main.orig_DoDraw_Tiles_Solid orig, Main self) + { + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeSolidTiles); + orig(self); + } + + private static void GeneralDrawLayer_DrawToLayer_NPCs(On_Main.orig_DoDraw_DrawNPCsOverTiles orig, Main self) + { + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeNPCs); + orig(self); + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterNPCs); + } + + private static void GeneralDrawLayer_DrawToLayer_Projectiles(On_Main.orig_DrawProjectiles orig, Main self) + { + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeProjectiles); + orig(self); + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterProjectiles); + } + + private static void GeneralDrawLayer_DrawToLayer_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self) + { + orig(self); + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterPlayers); + } + + private static void GeneralDrawLayer_DrawToLayer_AfterDusts(On_Main.orig_DrawDust orig, Main self) + { + orig(self); + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterDusts); + } + + private static void GeneralDrawLayer_DrawToLayer_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self) + { + orig(self); + Main.spriteBatch.End(out var ss); + GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterEverything); + Main.spriteBatch.Begin(ss); + } + #endregion + } +} diff --git a/Systems/Graphic/LavaRenderingSystem.cs b/Systems/Graphic/LavaRenderingSystem.cs deleted file mode 100644 index 84d5f6cce2..0000000000 --- a/Systems/Graphic/LavaRenderingSystem.cs +++ /dev/null @@ -1,1187 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.GameContent.Liquid; -using Terraria.Graphics; -using Terraria.ID; -using Terraria.ModLoader; -using static Terraria.WaterfallManager; - -namespace CalamityMod.Systems -{ - [Autoload(Side = ModSide.Client)] - public sealed class LavaRenderingSystem : ModSystem - { - //Welcome to Calamity's lava rendering. Prepare your eyes - public static LavaRenderingSystem Instance; - - public static int LavaStyle; - public static float[] LavaAlpha = new float[1]; - internal static float[] AlphaSave = new float[1]; - - // Holds the Texture Arrays for all the lava textures. - // These are used for the lava styles. They are seperate from Textureasset.Instance._liquidTexture as they will conflict with ModWaterStyle - // Can hold up to 255 lava styles (more than enough) (excluding the normal lava texture which is liquidTexture 1) - public struct Textures - { - public static Asset[] liquid = new Asset[1]; - public static Asset[] slope = new Asset[1]; - public static Asset[] block = new Asset[1]; - public static Asset[] fall = new Asset[1]; - } - - public int WaterStyleMaxCount = 0; - - public override void Load() - { - Instance = this; - } - - public override void OnModLoad() - { - WaterStyleMaxCount = ModContent.GetContent().Count() + LoaderManager.Get().VanillaCount; - - // Lava Texture - Textures.liquid[0] = LiquidRenderer.Instance._liquidTextures[1]; - Textures.slope[0] = TextureAssets.LiquidSlope[1]; - Textures.block[0] = TextureAssets.Liquid[1]; - var waterfallTexture = (Asset[])typeof(WaterfallManager).GetField("waterfallTexture", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(Main.instance.waterfallManager); - Textures.fall[0] = waterfallTexture[1]; - } - - public void DrawLavas(bool isBackground = false) - { - Main.drewLava = false; - if (!isBackground) - { - LavaStyle = 0; - LavaStylesLoader.IsLavaActive(); - for (int i = 0; i < 1; i++) - { - if (LavaStyle != i) - { - LavaAlpha[i] = Math.Max(LavaAlpha[i] - 0.2f, 0f); - } - else - { - LavaAlpha[i] = Math.Min(LavaAlpha[i] + 0.2f, 1f); - } - } - LavaStylesLoader.UpdateLiquidAlphas(); - } - bool flag = false; - for (int j = 0; j < LavaStylesLoader.TotalCount; j++) - { - if (LavaAlpha[j] > 0f && j != LavaStyle) - { - DrawLiquid(isBackground, j, isBackground ? 1f : LavaAlpha[j], drawSinglePassLiquids: false); - flag = true; - } - } - DrawLiquid(isBackground, LavaStyle, flag ? LavaAlpha[LavaStyle] : 1f); - } - - protected internal void DrawLiquid(bool bg = false, int lavaStyle = 0, float Alpha = 1f, bool drawSinglePassLiquids = true) - { - if (!Lighting.NotRetro) // Is Retro - { - oldDrawLava(bg, lavaStyle, Alpha); - return; - } - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); - Vector2 drawOffset = (Vector2)(Main.drawToScreen ? Vector2.Zero : new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange)) - Main.screenPosition; - if (bg) - { - DrawLiquidBehindTiles(lavaStyle); - } - LiquidRenderer.Instance.DrawNormalLiquids(Main.spriteBatch, drawOffset, lavaStyle + ModContent.GetContent().Count() + LoaderManager.Get().VanillaCount + 1, Alpha, bg); - if (!bg) - { - TimeLogger.DrawTime(4, stopwatch.Elapsed.TotalMilliseconds); - } - } - - public void oldDrawLava(bool bg = false, int Style = 0, float Alpha = 1f) - { - float num = 0f; - float num12 = 99999f; - float num23 = 99999f; - int num27 = -1; - int num28 = -1; - Vector2 vector = new((float)Main.offScreenRange, (float)Main.offScreenRange); - if (Main.drawToScreen) - { - vector = Vector2.Zero; - } - _ = new Color[4]; - int num29 = (int)(255f * (1f - Main.gfxQuality) + 40f * Main.gfxQuality); - _ = Main.gfxQuality; - _ = Main.gfxQuality; - int num30 = (int)((Main.screenPosition.X - vector.X) / 16f - 1f); - int num31 = (int)((Main.screenPosition.X + (float)Main.screenWidth + vector.X) / 16f) + 2; - int num32 = (int)((Main.screenPosition.Y - vector.Y) / 16f - 1f); - int num2 = (int)((Main.screenPosition.Y + (float)Main.screenHeight + vector.Y) / 16f) + 5; - if (num30 < 5) - { - num30 = 5; - } - if (num31 > Main.maxTilesX - 5) - { - num31 = Main.maxTilesX - 5; - } - if (num32 < 5) - { - num32 = 5; - } - if (num2 > Main.maxTilesY - 5) - { - num2 = Main.maxTilesY - 5; - } - Vector2 vector2; - Rectangle value; - Color newColor; - for (int i = num32; i < num2 + 4; i++) - { - for (int j = num30 - 2; j < num31 + 2; j++) - { - if (Main.tile[j, i].LiquidAmount <= 0 || (Main.tile[j, i].HasUnactuatedTile && Main.tileSolid[Main.tile[j, i].TileType] && !Main.tileSolidTop[Main.tile[j, i].TileType]) || !(Lighting.Brightness(j, i) > 0f || bg) || Main.tile[j, i].LiquidType != LiquidID.Lava) - { - continue; - } - Color color = Lighting.GetColor(j, i); - float num3 = 256 - Main.tile[j, i].LiquidAmount; - num3 /= 32f; - int num4 = 0; - if (Main.tile[j, i].LiquidType == LiquidID.Lava) - { - /*if (Main.drewLava) //disallows the back liquid to not draw until its alpha hits 1f apparently - { - continue; - }*/ - float num5 = Math.Abs((float)(j * 16 + 8) - (Main.screenPosition.X + (float)(Main.screenWidth / 2))); - float num6 = Math.Abs((float)(i * 16 + 8) - (Main.screenPosition.Y + (float)(Main.screenHeight / 2))); - if (num5 < (float)(Main.screenWidth * 2) && num6 < (float)(Main.screenHeight * 2)) - { - float num7 = (float)Math.Sqrt(num5 * num5 + num6 * num6); - float num8 = 1f - num7 / ((float)Main.screenWidth * 0.75f); - if (num8 > 0f) - { - num += num8; - } - } - if (num5 < num12) - { - num12 = num5; - num27 = j * 16 + 8; - } - if (num6 < num23) - { - num23 = num5; - num28 = i * 16 + 8; - } - } - if (num4 == 0) - { - num4 = Style; - } - if (Main.drewLava) - { - continue; - } - float num9 = 0.5f; - if (bg) - { - num9 = 1f; - } - num9 *= Alpha; - Main.DrawTileInWater(-Main.screenPosition + vector, j, i); //lily pads - vector2 = new((float)(j * 16), (float)(i * 16 + (int)num3 * 2)); - value = new(0, 0, 16, 16 - (int)num3 * 2); - bool flag2 = true; - if (Main.tile[j, i + 1].LiquidAmount < 245 && (!Main.tile[j, i + 1].HasUnactuatedTile || !Main.tileSolid[Main.tile[j, i + 1].TileType] || Main.tileSolidTop[Main.tile[j, i + 1].TileType])) - { - float num10 = 256 - Main.tile[j, i + 1].LiquidAmount; - num10 /= 32f; - num9 = 0.5f * (8f - num3) / 4f; - if ((double)num9 > 0.55) - { - num9 = 0.55f; - } - if ((double)num9 < 0.35) - { - num9 = 0.35f; - } - float num11 = num3 / 2f; - if (Main.tile[j, i + 1].LiquidAmount < 200) - { - if (bg) - { - continue; - } - if (Main.tile[j, i - 1].LiquidAmount > 0 && Main.tile[j, i - 1].LiquidAmount > 0) - { - value = new(0, 4, 16, 16); - num9 = 0.5f; - } - else if (Main.tile[j, i - 1].LiquidAmount > 0) - { - vector2 = new((float)(j * 16), (float)(i * 16 + 4)); - value = new(0, 4, 16, 12); - num9 = 0.5f; - } - else if (Main.tile[j, i + 1].LiquidAmount > 0) - { - vector2 = new((float)(j * 16), (float)(i * 16 + (int)num3 * 2 + (int)num10 * 2)); - value = new(0, 4, 16, 16 - (int)num3 * 2); - } - else - { - vector2 = new((float)(j * 16 + (int)num11), (float)(i * 16 + (int)num11 * 2 + (int)num10 * 2)); - value = new(0, 4, 16 - (int)num11 * 2, 16 - (int)num11 * 2); - } - } - else - { - num9 = 0.5f; - value = new(0, 4, 16, 16 - (int)num3 * 2 + (int)num10 * 2); - } - } - else if (Main.tile[j, i - 1].LiquidAmount > 32) - { - value = new(0, 4, value.Width, value.Height); - } - else if (num3 < 1f && Main.tile[j, i - 1].HasUnactuatedTile && Main.tileSolid[Main.tile[j, i - 1].TileType] && !Main.tileSolidTop[Main.tile[j, i - 1].TileType]) - { - vector2 = new((float)(j * 16), (float)(i * 16)); - value = new(0, 4, 16, 16); - } - else - { - for (int k = i + 1; k < i + 6 && (!Main.tile[j, k].HasUnactuatedTile || !Main.tileSolid[Main.tile[j, k].TileType] || Main.tileSolidTop[Main.tile[j, k].TileType]); k++) - { - if (Main.tile[j, k].LiquidAmount < 200) - { - flag2 = false; - break; - } - } - if (!flag2) - { - num9 = 0.5f; - value = new(0, 4, 16, 16); - } - else if (Main.tile[j, i - 1].LiquidAmount > 0) - { - value = new(0, 2, value.Width, value.Height); - } - } - if ((color.R > 20 || color.B > 20 || color.G > 20) && value.Y < 4) - { - int num13 = color.R; - if (color.G > num13) - { - num13 = color.G; - } - if (color.B > num13) - { - num13 = color.B; - } - num13 /= 30; - if (Main.rand.Next(20000) < num13) - { - newColor = new(255, 255, 255); - int num14 = Dust.NewDust(new Vector2((float)(j * 16), vector2.Y - 2f), 16, 8, DustID.TintableDustLighted, 0f, 0f, 254, newColor, 0.75f); - Dust obj = Main.dust[num14]; - obj.velocity *= 0f; - } - } - if (Main.tile[j, i].LiquidType == LiquidID.Lava) - { - num9 *= 1.8f; - if (num9 > 1f) - { - num9 = 1f; - } - if (Main.instance.IsActive && !Main.gamePaused && Dust.lavaBubbles < 200) - { - if (Main.tile[j, i].LiquidAmount > 200 && Main.rand.NextBool(700)) - { - Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16)), 16, 16, dustLava()); - } - if (value.Y == 0 && Main.rand.NextBool(350)) - { - int num15 = Dust.NewDust(new Vector2((float)(j * 16), (float)(i * 16) + num3 * 2f - 8f), 16, 8, dustLava(), 0f, 0f, 50, default(Color), 1.5f); - Dust obj2 = Main.dust[num15]; - obj2.velocity *= 0.8f; - Main.dust[num15].velocity.X *= 2f; - Main.dust[num15].velocity.Y -= (float)Main.rand.Next(1, 7) * 0.1f; - if (Main.rand.NextBool(10)) - { - Main.dust[num15].velocity.Y *= Main.rand.Next(2, 5); - } - Main.dust[num15].noGravity = true; - } - } - } - float num16 = (float)(int)color.R * num9; - float num17 = (float)(int)color.G * num9; - float num18 = (float)(int)color.B * num9; - float num19 = (float)(int)color.A * num9; - color = new((int)(byte)num16, (int)(byte)num17, (int)(byte)num18, (int)(byte)num19); - if (Lighting.NotRetro && !bg) - { - Color color2 = color; - if (((double)(int)color2.R > (double)num29 * 0.6 || (double)(int)color2.G > (double)num29 * 0.65 || (double)(int)color2.B > (double)num29 * 0.7)) - { - for (int l = 0; l < 4; l++) - { - int num20 = 0; - int num21 = 0; - int width = 8; - int height = 8; - Color color3 = color2; - Color color4 = Lighting.GetColor(j, i); - if (l == 0) - { - color4 = Lighting.GetColor(j - 1, i - 1); - if (value.Height < 8) - { - height = value.Height; - } - } - if (l == 1) - { - color4 = Lighting.GetColor(j + 1, i - 1); - num20 = 8; - if (value.Height < 8) - { - height = value.Height; - } - } - if (l == 2) - { - color4 = Lighting.GetColor(j - 1, i + 1); - num21 = 8; - height = 8 - (16 - value.Height); - } - if (l == 3) - { - color4 = Lighting.GetColor(j + 1, i + 1); - num20 = 8; - num21 = 8; - height = 8 - (16 - value.Height); - } - num16 = (float)(int)color4.R * num9; - num17 = (float)(int)color4.G * num9; - num18 = (float)(int)color4.B * num9; - num19 = (float)(int)color4.A * num9; - color4 = new((int)(byte)num16, (int)(byte)num17, (int)(byte)num18, (int)(byte)num19); - color3.R = (byte)((color2.R * 3 + color4.R * 2) / 5); - color3.G = (byte)((color2.G * 3 + color4.G * 2) / 5); - color3.B = (byte)((color2.B * 3 + color4.B * 2) / 5); - color3.A = (byte)((color2.A * 3 + color4.A * 2) / 5); - Main.spriteBatch.Draw(Textures.block[num4].Value, vector2 - Main.screenPosition + new Vector2((float)num20, (float)num21) + vector, (Rectangle?)new Rectangle(value.X + num20, value.Y + num21, width, height), color3, 0f, default(Vector2), 1f, (SpriteEffects)0, 0f); - } - } - else - { - Main.spriteBatch.Draw(Textures.block[num4].Value, vector2 - Main.screenPosition + vector, (Rectangle?)value, color, 0f, default(Vector2), 1f, (SpriteEffects)0, 0f); - } - } - else - { - if (value.Y < 4) - { - value.X += (int)(Main.wFrame * 18f); - } - Main.spriteBatch.Draw(Textures.block[num4].Value, vector2 - Main.screenPosition + vector, (Rectangle?)value, color, 0f, default(Vector2), 1f, (SpriteEffects)0, 0f); - } - if (!Main.tile[j, i + 1].IsHalfBlock) - { - continue; - } - color = Lighting.GetColor(j, i + 1); - num16 = (float)(int)color.R * num9; - num17 = (float)(int)color.G * num9; - num18 = (float)(int)color.B * num9; - num19 = (float)(int)color.A * num9; - color = new((int)(byte)num16, (int)(byte)num17, (int)(byte)num18, (int)(byte)num19); - vector2 = new((float)(j * 16), (float)(i * 16 + 16)); - Main.spriteBatch.Draw(Textures.block[num4].Value, vector2 - Main.screenPosition + vector, (Rectangle?)new Rectangle(0, 4, 16, 8), color, 0f, default(Vector2), 1f, (SpriteEffects)0, 0f); - float num22 = 6f; - float num24 = 0.75f; - num22 = 4f; - num24 = 0.5f; - for (int m = 0; (float)m < num22; m++) - { - int num25 = i + 2 + m; - if (WorldGen.SolidTile(j, num25)) - { - break; - } - float num26 = 1f - (float)m / num22; - num26 *= num24; - vector2 = new((float)(j * 16), (float)(num25 * 16 - 2)); - Main.spriteBatch.Draw(Textures.block[num4].Value, vector2 - Main.screenPosition + vector, (Rectangle?)new Rectangle(0, 18, 16, 16), color * num26, 0f, default(Vector2), 1f, (SpriteEffects)0, 0f); - } - } - } - if (!Main.drewLava) - { - Main.ambientLavaX = num27; - Main.ambientLavaY = num28; - Main.ambientLavaStrength = num; - } - Main.drewLava = true; - } - - private void DrawLiquidBehindTiles(int lavaStyleOverride = -1) - { - Vector2 unscaledPosition = Main.Camera.UnscaledPosition; - Vector2 vector = new((float)Main.offScreenRange, (float)Main.offScreenRange); - if (Main.drawToScreen) - { - vector = Vector2.Zero; - } - GetScreenDrawArea(unscaledPosition, vector + (Main.Camera.UnscaledPosition - Main.Camera.ScaledPosition), out var firstTileX, out var lastTileX, out var firstTileY, out var lastTileY); - for (int i = firstTileY; i < lastTileY + 4; i++) - { - for (int j = firstTileX - 2; j < lastTileX + 2; j++) - { - Tile tile = Main.tile[j, i]; - if (tile != null) - { - DrawTile_LiquidBehindTile(solidLayer: false, inFrontOfPlayers: false, lavaStyleOverride, unscaledPosition, vector, j, i, tile); - } - } - } - } - - private void GetScreenDrawArea(Vector2 screenPosition, Vector2 offSet, out int firstTileX, out int lastTileX, out int firstTileY, out int lastTileY) - { - firstTileX = (int)((screenPosition.X - offSet.X) / 16f - 1f); - lastTileX = (int)((screenPosition.X + (float)Main.screenWidth + offSet.X) / 16f) + 2; - firstTileY = (int)((screenPosition.Y - offSet.Y) / 16f - 1f); - lastTileY = (int)((screenPosition.Y + (float)Main.screenHeight + offSet.Y) / 16f) + 5; - if (firstTileX < 4) - { - firstTileX = 4; - } - if (lastTileX > Main.maxTilesX - 4) - { - lastTileX = Main.maxTilesX - 4; - } - if (firstTileY < 4) - { - firstTileY = 4; - } - if (lastTileY > Main.maxTilesY - 4) - { - lastTileY = Main.maxTilesY - 4; - } - if (Main.sectionManager.AnyUnfinishedSections) - { - TimeLogger.DetailedDrawReset(); - WorldGen.SectionTileFrameWithCheck(firstTileX, firstTileY, lastTileX, lastTileY); - TimeLogger.DetailedDrawTime(5); - } - if (Main.sectionManager.AnyNeedRefresh) - { - WorldGen.RefreshSections(firstTileX, firstTileY, lastTileX, lastTileY); - } - } - - public void DrawTile_LiquidBehindTile(bool solidLayer, bool inFrontOfPlayers, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY, Tile tileCache) - { - Tile tile = Main.tile[tileX + 1, tileY]; - Tile tile2 = Main.tile[tileX - 1, tileY]; - Tile tile3 = Main.tile[tileX, tileY - 1]; - Tile tile4 = Main.tile[tileX, tileY + 1]; - if ((tileCache.LiquidType != LiquidID.Lava && tile.LiquidType != LiquidID.Lava && tile2.LiquidType != LiquidID.Lava && tile3.LiquidType != LiquidID.Lava && tile4.LiquidType != LiquidID.Lava)) - { - return; - } - //bool[] _tileSolidTop = (bool[])typeof(TileDrawing).GetField("_tileSolidTop", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(null); - if (!tileCache.HasTile || tileCache.IsActuated /*|| _tileSolidTop[tileCache.TileType]*/ || (tileCache.IsHalfBlock && (tile2.LiquidAmount > 160 || tile.LiquidAmount > 160) && Main.instance.waterfallManager.CheckForWaterfall(tileX, tileY)) || (TileID.Sets.BlocksWaterDrawingBehindSelf[tileCache.TileType] && tileCache.Slope == 0)) - { - return; - } - int num = 0; - bool flag = false; - bool flag2 = false; - bool flag3 = false; - bool flag4 = false; - bool flag5 = false; - int num2 = 0; - bool flag6 = true; - int num3 = (int)tileCache.Slope; - int num4 = (int)tileCache.BlockType; - if (tileCache.TileType == 546 && tileCache.LiquidAmount > 0) - { - flag5 = true; - flag4 = true; - flag = true; - flag2 = true; - num = tileCache.LiquidAmount; - } - else - { - if (tileCache.LiquidAmount > 0 && num4 != 0 && (num4 != 1 || tileCache.LiquidAmount > 160)) - { - flag5 = true; - if (tileCache.LiquidAmount > num) - { - num = tileCache.LiquidAmount; - } - } - if (tile2.LiquidAmount > 0 && num3 != 1 && num3 != 3) - { - flag = true; - if (tile2.LiquidAmount > num) - { - num = tile2.LiquidAmount; - } - } - if (tile.LiquidAmount > 0 && num3 != 2 && num3 != 4) - { - flag2 = true; - if (tile.LiquidAmount > num) - { - num = tile.LiquidAmount; - } - } - if (tile3.LiquidAmount > 0 && num3 != 3 && num3 != 4) - { - flag3 = true; - } - if (tile4.LiquidAmount > 0 && num3 != 1 && num3 != 2) - { - if (tile4.LiquidAmount > 240) - { - flag4 = true; - } - } - } - if (!flag3 && !flag4 && !flag && !flag2 && !flag5) - { - return; - } - if (waterStyleOverride != -1) - { - LavaStyle = waterStyleOverride; - } - if (num2 == 0) - { - num2 = LavaStyle; - } - Lighting.GetCornerColors(tileX, tileY, out var vertices); - Vector2 vector = new((float)(tileX * 16), (float)(tileY * 16)); - Rectangle liquidSize = new(0, 4, 16, 16); - if (flag4 && (flag || flag2)) - { - flag = true; - flag2 = true; - } - if (tileCache.HasTile && (Main.tileSolidTop[tileCache.TileType] || !Main.tileSolid[tileCache.TileType])) - { - return; - } - if ((!flag3 || !(flag || flag2)) && !(flag4 && flag3)) - { - if (flag3) - { - liquidSize = new(0, 4, 16, 4); - if (tileCache.IsHalfBlock || tileCache.Slope != 0) - { - liquidSize = new(0, 4, 16, 12); - } - } - else if (flag4 && !flag && !flag2) - { - vector = new((float)(tileX * 16), (float)(tileY * 16 + 12)); - liquidSize = new(0, 4, 16, 4); - } - else - { - float num8 = (float)(256 - num) / 32f; - int y = 4; - if (tile3.LiquidAmount == 0 && (num4 != 0 || !WorldGen.SolidTile(tileX, tileY - 1))) - { - y = 0; - } - int num5 = (int)num8 * 2; - if (tileCache.Slope != 0) - { - vector = new((float)(tileX * 16), (float)(tileY * 16 + num5)); - liquidSize = new(0, num5, 16, 16 - num5); - } - else if ((flag && flag2) || tileCache.IsHalfBlock) - { - vector = new((float)(tileX * 16), (float)(tileY * 16 + num5)); - liquidSize = new(0, y, 16, 16 - num5); - } - else if (flag) - { - vector = new((float)(tileX * 16), (float)(tileY * 16 + num5)); - liquidSize = new(0, y, 4, 16 - num5); - } - else - { - vector = new((float)(tileX * 16 + 12), (float)(tileY * 16 + num5)); - liquidSize = new(0, y, 4, 16 - num5); - } - } - } - Vector2 position = vector - screenPosition + screenOffset; - float num6 = 1f; - if ((double)tileY <= Main.worldSurface || num6 > 1f) - { - num6 = 1f; - if (tileCache.WallType == 21) - { - num6 = 0.9f; - } - else if (tileCache.WallType > 0) - { - num6 = 0.6f; - } - } - if (tileCache.IsHalfBlock && tile3.LiquidAmount > 0 && tileCache.WallType > 0) - { - num6 = 0f; - } - if (num3 == 4 && tile2.LiquidAmount == 0 && !WorldGen.SolidTile(tileX - 1, tileY)) - { - num6 = 0f; - } - if (num3 == 3 && tile.LiquidAmount == 0 && !WorldGen.SolidTile(tileX + 1, tileY)) - { - num6 = 0f; - } - ref Color bottomLeftColor = ref vertices.BottomLeftColor; - bottomLeftColor *= num6; - ref Color bottomRightColor = ref vertices.BottomRightColor; - bottomRightColor *= num6; - ref Color topLeftColor = ref vertices.TopLeftColor; - topLeftColor *= num6; - ref Color topRightColor = ref vertices.TopRightColor; - topRightColor *= num6; - bool flag7 = false; - if (flag6) - { - for (int i = 0; i < LavaStylesLoader.TotalCount; i++) - { - if (LavaAlpha[i] > 0f && i != num2) - { - DrawPartialLiquid(!solidLayer, tileCache, ref position, ref liquidSize, i, ref vertices); - flag7 = true; - break; - } - } - } - VertexColors colors = vertices; - float num7 = (flag7 ? LavaAlpha[num2] : 1f); - ref Color bottomLeftColor2 = ref colors.BottomLeftColor; - bottomLeftColor2 *= num7; - ref Color bottomRightColor2 = ref colors.BottomRightColor; - bottomRightColor2 *= num7; - ref Color topLeftColor2 = ref colors.TopLeftColor; - topLeftColor2 *= num7; - ref Color topRightColor2 = ref colors.TopRightColor; - topRightColor2 *= num7; - DrawPartialLiquid(!solidLayer, tileCache, ref position, ref liquidSize, num2, ref colors); - } - - private void DrawPartialLiquid(bool behindBlocks, Tile tileCache, ref Vector2 position, ref Rectangle liquidSize, int liquidType, ref VertexColors colors) - { - int num = (int)tileCache.Slope; - bool flag = !TileID.Sets.BlocksWaterDrawingBehindSelf[tileCache.TileType]; - if (!behindBlocks) - { - flag = false; - } - if (flag || num == 0) - { - Main.tileBatch.Draw(Textures.block[liquidType].Value, position, liquidSize, colors, default(Vector2), 1f, (SpriteEffects)0); - return; - } - liquidSize.X += 18 * (num - 1); - switch (num) - { - case 1: - Main.tileBatch.Draw(Textures.slope[liquidType].Value, position, liquidSize, colors, Vector2.Zero, 1f, (SpriteEffects)0); - break; - case 2: - Main.tileBatch.Draw(Textures.slope[liquidType].Value, position, liquidSize, colors, Vector2.Zero, 1f, (SpriteEffects)0); - break; - case 3: - Main.tileBatch.Draw(Textures.slope[liquidType].Value, position, liquidSize, colors, Vector2.Zero, 1f, (SpriteEffects)0); - break; - case 4: - Main.tileBatch.Draw(Textures.slope[liquidType].Value, position, liquidSize, colors, Vector2.Zero, 1f, (SpriteEffects)0); - break; - } - } - - public void InitialDrawLavafall(WaterfallManager waterfallManager) - { - for (int i = 0; i < LavaStylesLoader.TotalCount; i++) - { - if (LavaAlpha[i] > 0f) - { - DrawLavafall(waterfallManager, i, LavaAlpha[i]); - } - } - } - - internal void DrawLavafall(WaterfallManager waterfallManager, int Style = 0, float Alpha = 1f) - { - int waterfallDist = (int)typeof(WaterfallManager).GetField("waterfallDist", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(waterfallManager); - int rainFrameForeground = (int)typeof(WaterfallManager).GetField("rainFrameForeground", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(waterfallManager); - int rainFrameBackground = (int)typeof(WaterfallManager).GetField("rainFrameBackground", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(waterfallManager); - int snowFrameForeground = (int)typeof(WaterfallManager).GetField("snowFrameForeground", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(waterfallManager); - WaterfallData[] waterfalls = (WaterfallData[])typeof(WaterfallManager).GetField("waterfalls", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(waterfallManager); - int currentMax = (int)typeof(WaterfallManager).GetField("currentMax", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(waterfallManager); - int slowFrame = (int)typeof(WaterfallManager).GetField("slowFrame", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance).GetValue(waterfallManager); - Main.tileSolid[546] = false; - float num = 0f; - float num12 = 99999f; - float num23 = 99999f; - int num34 = -1; - int num45 = -1; - float num47 = 0f; - float num48 = 99999f; - float num49 = 99999f; - int num50 = -1; - int num2 = -1; - Rectangle value = default(Rectangle); - Rectangle value2 = default(Rectangle); - Vector2 origin = default(Vector2); - for (int i = 0; i < currentMax; i++) - { - if (waterfalls[i].type != 1) - { - continue; - } - int num3 = 0; - int num4 = Style; - int num5 = waterfalls[i].x; - int num6 = waterfalls[i].y; - int num7 = 0; - int num8 = 0; - int num9 = 0; - int num10 = 0; - int num11 = 0; - int num13 = 0; - int num14; - int num15; - if (waterfalls[i].stopAtStep == 0) - { - continue; - } - num14 = 32 * slowFrame; - int num22 = 0; - num15 = waterfallDist; - Color color4 = Color.White; - for (int k = 0; k < num15; k++) - { - if (num22 >= 2) - { - break; - } - typeof(WaterfallManager).GetMethod("AddLight", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).Invoke(null, new object[] { 1, num5, num6 }); - Tile tile3 = Main.tile[num5, num6]; - if (tile3.HasUnactuatedTile && Main.tileSolid[tile3.TileType] && !Main.tileSolidTop[tile3.TileType] && !TileID.Sets.Platforms[tile3.TileType] && tile3.BlockType == 0) - { - break; - } - Tile tile4 = Main.tile[num5 - 1, num6]; - Tile tile5 = Main.tile[num5, num6 + 1]; - Tile tile6 = Main.tile[num5 + 1, num6]; - if (WorldGen.SolidTile(tile5) && !tile3.IsHalfBlock) - { - num3 = 8; - } - else if (num8 != 0) - { - num3 = 0; - } - int num24 = 0; - int num25 = num10; - int num26 = 0; - int num27 = 0; - bool flag2 = false; - if (tile5.TopSlope && !tile3.IsHalfBlock && tile5.TileType != 19) - { - flag2 = true; - if (tile5.Slope == (SlopeType)1) - { - num24 = 1; - num26 = 1; - num9 = 1; - num10 = num9; - } - else - { - num24 = -1; - num26 = -1; - num9 = -1; - num10 = num9; - } - num27 = 1; - } - else if ((!WorldGen.SolidTile(tile5) && !tile5.BottomSlope && !tile3.IsHalfBlock) || (!tile5.HasTile && !tile3.IsHalfBlock)) - { - num22 = 0; - num27 = 1; - num26 = 0; - } - else if ((WorldGen.SolidTile(tile4) || tile4.TopSlope || tile4.LiquidAmount > 0) && !WorldGen.SolidTile(tile6) && tile6.LiquidAmount == 0) - { - if (num9 == -1) - { - num22++; - } - num26 = 1; - num27 = 0; - num9 = 1; - } - else if ((WorldGen.SolidTile(tile6) || tile6.TopSlope || tile6.LiquidAmount > 0) && !WorldGen.SolidTile(tile4) && tile4.LiquidAmount == 0) - { - if (num9 == 1) - { - num22++; - } - num26 = -1; - num27 = 0; - num9 = -1; - } - else if (((!WorldGen.SolidTile(tile6) && !tile3.TopSlope) || tile6.LiquidAmount == 0) && !WorldGen.SolidTile(tile4) && !tile3.TopSlope && tile4.LiquidAmount == 0) - { - num27 = 0; - num26 = num9; - } - else - { - num22++; - num27 = 0; - num26 = 0; - } - if (num22 >= 2) - { - num9 *= -1; - num26 *= -1; - } - Color color5 = Lighting.GetColor(num5, num6); - if (k > 50) - { - typeof(WaterfallManager).GetMethod("TrySparkling", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).Invoke(null, new object[] { num5, num6, num9, color5 }); - } - float alpha = GetLavafallAlpha(Alpha, num15, num6, k, tile3); - color5 = (Color)typeof(WaterfallManager).GetMethod("StylizeColor", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).Invoke(null, new object[] { alpha, num15, 1, num6, k, tile3, color5 }); - float num33 = Math.Abs((float)(num5 * 16 + 8) - (Main.screenPosition.X + (float)(Main.screenWidth / 2))); - float num35 = Math.Abs((float)(num6 * 16 + 8) - (Main.screenPosition.Y + (float)(Main.screenHeight / 2))); - if (num33 < (float)(Main.screenWidth * 2) && num35 < (float)(Main.screenHeight * 2)) - { - float num36 = (float)Math.Sqrt(num33 * num33 + num35 * num35); - float num37 = 1f - num36 / ((float)Main.screenWidth * 0.75f); - if (num37 > 0f) - { - num += num37; - } - } - if (num33 < num12) - { - num12 = num33; - num34 = num5 * 16 + 8; - } - if (num35 < num23) - { - num23 = num33; - num45 = num6 * 16 + 8; - } - int num38 = tile3.LiquidAmount / 16; - if (flag2 && num9 != num25) - { - int num39 = 2; - if (num25 == 1) - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16 + 16 - num39)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38 - num39), color5, (SpriteEffects)1); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + 16 - num39)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38 - num39), color5, (SpriteEffects)0); - } - } - if (num7 == 0 && num24 != 0 && num8 == 1 && num9 != num10) - { - num24 = 0; - num9 = num10; - color5 = Color.White; - if (num9 == 1) - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16 + 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color5, (SpriteEffects)1); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16 + 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color5, (SpriteEffects)1); - } - } - if (num11 != 0 && num26 == 0 && num27 == 1) - { - if (num9 == 1) - { - if (num13 != num4) - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3 + 8)) - Main.screenPosition, new Rectangle(num14, 0, 16, 16 - num38 - 8), color4, (SpriteEffects)1); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3 + 8)) - Main.screenPosition, new Rectangle(num14, 0, 16, 16 - num38 - 8), color5, (SpriteEffects)1); - } - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3 + 8)) - Main.screenPosition, new Rectangle(num14, 0, 16, 16 - num38 - 8), color5, (SpriteEffects)0); - } - } - if (num3 == 8 && num8 == 1 && num11 == 0) - { - if (num10 == -1) - { - if (num13 != num4) - { - DrawLavafall(num13, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 8), color4, (SpriteEffects)0); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 8), color5, (SpriteEffects)0); - } - } - else if (num13 != num4) - { - DrawLavafall(num13, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 8), color4, (SpriteEffects)1); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 8), color5, (SpriteEffects)1); - } - } - if (num24 != 0 && num7 == 0) - { - if (num25 == 1) - { - if (num13 != num4) - { - DrawLavafall(num13, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color4, (SpriteEffects)1); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color5, (SpriteEffects)1); - } - } - else if (num13 != num4) - { - DrawLavafall(num13, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color4, (SpriteEffects)0); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color5, (SpriteEffects)0); - } - } - if (num27 == 1 && num24 == 0 && num11 == 0) - { - if (num9 == -1) - { - if (num8 == 0) - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3)) - Main.screenPosition, new Rectangle(num14, 0, 16, 16 - num38), color5, (SpriteEffects)0); - } - else if (num13 != num4) - { - DrawLavafall(num13, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color4, (SpriteEffects)0); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color5, (SpriteEffects)0); - } - } - else if (num8 == 0) - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3)) - Main.screenPosition, new Rectangle(num14, 0, 16, 16 - num38), color5, (SpriteEffects)1); - } - else if (num13 != num4) - { - DrawLavafall(num13, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color4, (SpriteEffects)1); - } - else - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 - 16), (float)(num6 * 16)) - Main.screenPosition, new Rectangle(num14, 24, 32, 16 - num38), color5, (SpriteEffects)1); - } - } - else - { - switch (num26) - { - case 1: - if (Main.tile[num5, num6].LiquidAmount > 0 && !Main.tile[num5, num6].IsHalfBlock) - { - break; - } - if (num24 == 1) - { - for (int m = 0; m < 8; m++) - { - int num43 = m * 2; - int num44 = 14 - m * 2; - int num46 = num43; - num3 = 8; - if (num7 == 0 && m < 2) - { - num46 = 4; - } - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 + num43), (float)(num6 * 16 + num3 + num46)) - Main.screenPosition, new Rectangle(16 + num14 + num44, 0, 2, 16 - num3), color5, (SpriteEffects)1); - } - } - else - { - int height2 = 16; - if (TileID.Sets.BlocksWaterDrawingBehindSelf[Main.tile[num5, num6].TileType]) - { - height2 = 8; - } - else if (TileID.Sets.BlocksWaterDrawingBehindSelf[Main.tile[num5, num6 + 1].TileType]) - { - height2 = 8; - } - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3)) - Main.screenPosition, new Rectangle(16 + num14, 0, 16, height2), color5, (SpriteEffects)1); - } - break; - case -1: - if (Main.tile[num5, num6].LiquidAmount > 0 && !Main.tile[num5, num6].IsHalfBlock) - { - break; - } - if (num24 == -1) - { - for (int l = 0; l < 8; l++) - { - int num40 = l * 2; - int num41 = l * 2; - int num42 = 14 - l * 2; - num3 = 8; - if (num7 == 0 && l > 5) - { - num42 = 4; - } - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16 + num40), (float)(num6 * 16 + num3 + num42)) - Main.screenPosition, new Rectangle(16 + num14 + num41, 0, 2, 16 - num3), color5, (SpriteEffects)1); - } - } - else - { - int height = 16; - if (TileID.Sets.BlocksWaterDrawingBehindSelf[Main.tile[num5, num6].TileType]) - { - height = 8; - } - else if (TileID.Sets.BlocksWaterDrawingBehindSelf[Main.tile[num5, num6 + 1].TileType]) - { - height = 8; - } - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3)) - Main.screenPosition, new Rectangle(16 + num14, 0, 16, height), color5, (SpriteEffects)0); - } - break; - case 0: - if (num27 == 0) - { - if (Main.tile[num5, num6].LiquidAmount <= 0 || Main.tile[num5, num6].IsHalfBlock) - { - DrawLavafall(num4, num5, num6, alpha, new Vector2((float)(num5 * 16), (float)(num6 * 16 + num3)) - Main.screenPosition, new Rectangle(16 + num14, 0, 16, 16), color5, (SpriteEffects)0); - } - k = 1000; - } - break; - } - } - if (tile3.LiquidAmount > 0 && !tile3.IsHalfBlock) - { - k = 1000; - } - num8 = num27; - num10 = num9; - num7 = num26; - num5 += num26; - num6 += num27; - num11 = num24; - color4 = color5; - if (num13 != num4) - { - num13 = num4; - } - if ((tile4.HasTile && (tile4.TileType == 189 || tile4.TileType == 196)) || (tile6.HasTile && (tile6.TileType == 189 || tile6.TileType == 196)) || (tile5.HasTile && (tile5.TileType == 189 || tile5.TileType == 196))) - { - num15 = (int)(40f * ((float)Main.maxTilesX / 4200f) * Main.gfxQuality); - } - } - } - Main.ambientWaterfallX = num34; - Main.ambientWaterfallY = num45; - Main.ambientWaterfallStrength = num; - Main.ambientLavafallX = num50; - Main.ambientLavafallY = num2; - Main.ambientLavafallStrength = num47; - Main.tileSolid[546] = true; - } - - private void DrawLavafall(int waterfallType, int x, int y, float opacity, Vector2 position, Rectangle sourceRect, Color color, SpriteEffects effects) - { - Texture2D value = Textures.fall[waterfallType].Value; - Main.spriteBatch.Draw(value, position, (Rectangle?)sourceRect, color, 0f, default, 1f, effects, 0f); - } - - private static float GetLavafallAlpha(float Alpha, int maxSteps, int y, int s, Tile tileCache) - { - float num = (tileCache.WallType != 0 || !((double)y < Main.worldSurface)) ? (1f * Alpha) : Alpha; - if (s > maxSteps - 10) - { - num *= (float)(maxSteps - s) / 10f; - } - return num; - } - - public static int dustLava() - { - if (LavaStyle >= 1) - { - return LavaStylesLoader.Get(LavaStyle).GetSplashDust(); - } - else - { - return DustID.Lava; - } - } - - //just better as a method rather than hardcoded type values - public static int goreLava() - { - if (LavaStyle >= 1) - { - return LavaStylesLoader.Get(LavaStyle).GetDropletGore(); - } - else - { - return GoreID.LavaDrip; - } - } - } -} diff --git a/Systems/Graphic/LightingEffectsSystem.cs b/Systems/Graphic/LightingEffectsSystem.cs index e9568a49a7..0f37544bcc 100644 --- a/Systems/Graphic/LightingEffectsSystem.cs +++ b/Systems/Graphic/LightingEffectsSystem.cs @@ -1,12 +1,10 @@ using CalamityMod.CalPlayer; -using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.Skies; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; -using Terraria.GameContent.Events; using Terraria.Graphics.Effects; using Terraria.ModLoader; @@ -36,41 +34,16 @@ namespace CalamityMod.Systems { float signusLifeRatio = 1f - (Main.npc[CalamityGlobalNPC.signus].life / Main.npc[CalamityGlobalNPC.signus].lifeMax); - // Reduce the power of Signus darkness based on your light level. float multiplier = 1f; - switch (Main.LocalPlayer.GetCurrentAbyssLightLevel()) - { - case 0: - break; - case 1: - case 2: - multiplier = 0.75f; - break; - case 3: - case 4: - multiplier = 0.5f; - break; - case 5: - case 6: - multiplier = 0.25f; - break; - default: - multiplier = 0f; - break; - } // Total darkness float signusDarkness = signusLifeRatio * multiplier; darkRatio = MathHelper.Clamp(signusDarkness, 0f, 1f); - scale += (CalamityWorld.LegendaryMode ? MaxGFBSignusDarkness : MaxSignusDarkness) * darkRatio; + scale += (Main.zenithWorld ? MaxGFBSignusDarkness : MaxSignusDarkness) * darkRatio; } } } } - - // Bat Wings give stronger night vision - if (Main.LocalPlayer.wingsLogic == (int)VanillaWingID.BatWings) - scale *= 1.08f; } public override void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor) diff --git a/Systems/Graphic/LiquidSystem/IWaterStyleModifyColor.cs b/Systems/Graphic/LiquidSystem/IWaterStyleModifyColor.cs new file mode 100644 index 0000000000..98f8988da5 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/IWaterStyleModifyColor.cs @@ -0,0 +1,10 @@ +using Terraria; +using Terraria.Graphics; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + public interface IWaterStyleModifyColor + { + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope); + } +} diff --git a/Systems/Graphic/LiquidSystem/IWaterStyleModifyLight.cs b/Systems/Graphic/LiquidSystem/IWaterStyleModifyLight.cs new file mode 100644 index 0000000000..52e7ac778a --- /dev/null +++ b/Systems/Graphic/LiquidSystem/IWaterStyleModifyLight.cs @@ -0,0 +1,9 @@ +using Terraria; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + public interface IWaterStyleModifyLight + { + void ModifyLight(in Tile tile, int x, int y, ref float r, ref float g, ref float b); + } +} diff --git a/Systems/Graphic/LiquidSystem/IWaterStylePostDrawEffect.cs b/Systems/Graphic/LiquidSystem/IWaterStylePostDrawEffect.cs new file mode 100644 index 0000000000..d3470fc378 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/IWaterStylePostDrawEffect.cs @@ -0,0 +1,9 @@ +using Terraria; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + public interface IWaterStylePostDrawEffect + { + public void PostDrawEffect(in Tile tile, int x, int y); + } +} diff --git a/Systems/Graphic/LiquidSystem/IWaterfallStyleModifyColor.cs b/Systems/Graphic/LiquidSystem/IWaterfallStyleModifyColor.cs new file mode 100644 index 0000000000..34554d1d66 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/IWaterfallStyleModifyColor.cs @@ -0,0 +1,10 @@ +using Terraria; +using Terraria.Graphics; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + public interface IWaterfallStyleModifyColor + { + void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor); + } +} diff --git a/Systems/Graphic/LiquidSystem/ModLavaStyle.cs b/Systems/Graphic/LiquidSystem/ModLavaStyle.cs new file mode 100644 index 0000000000..30dc5c62a2 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/ModLavaStyle.cs @@ -0,0 +1,107 @@ +using CalamityMod.Systems.Graphic.LiquidSystem; +using Terraria; +using Terraria.Graphics; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Systems +{ + public abstract class ModLavaStyle : ModTexturedType + { + /// + /// The ID of the lava style. + /// + public int Slot { get; private set; } = -1; + + public override string Name => base.Name; + + public override string Texture => base.Texture; + + public virtual string BlockTexture => Texture + "_Block"; + + public virtual string SlopeTexture => Texture + "_Slope"; + + public virtual string WaterfallTexture => Texture + "_Waterfall"; + + protected sealed override void Register() + { + Slot = ModLavaStyleLoader.Register(this); + } + + public sealed override void SetupContent() + { + SetStaticDefaults(); + } + + /// + /// Allows you to determine how much light this lava emits.
+ /// It can also let you light up the block in front of this lava.
+ /// Keep in mind this also effects what color the lavafalls emit
+ /// See for vanilla tile light values to use as a reference.
+ ///
+ /// The x position in tile coordinates. + /// The y position in tile coordinates. + /// The red component of light, usually a value between 0 and 1 + /// The green component of light, usually a value between 0 and 1 + /// The blue component of light, usually a value between 0 and 1 + public virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.55f; + g = 0.33f; + b = 0.11f; + } + + /// + /// Allows water styles to manipulate what color the liquid is drawn to, this can allow waters to be see-throughable to see backgrounds (surface and underground backgrounds not walls) + /// + /// X position of the water + /// Y position of the water + /// The vertexColor of the water color, this is both used to get the current color and to set the color of the water + public virtual void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) + { + } + + /// + /// The ID of the dust that is created when anything splashes in lava. + /// + public virtual int GetSplashDust() + { + return DustID.Lava; + } + + /// + /// The ID of the gore that represents droplets of lava falling down from a block. Return (or another existing droplet gore). + /// + public virtual int GetDropletGore() + { + return GoreID.LavaDrip; + } + + /// + /// Return true if the player is in the correct zone to activate the lava. + /// + /// + public virtual bool IsLavaActive() + { + return false; + } + + /// + /// Return false if the waterfall made by the lavastyle should have a glowmask + /// + /// + public virtual bool LavafallGlowmask() + { + return true; + } + + /// + /// Allows your lavastyle to inflict debuffs to Players and NPCs when they enter your lava style + /// + /// The Player that is inflicted with the debuff apon entering the lavastyle + /// The duration of the OnFire! debuff. This allows for easy replacement of OnFire + public virtual void InflictDebuff(Player player, int onfireDuration) + { + } + } +} diff --git a/Systems/Graphic/LiquidSystem/ModLavaStyleLoader.cs b/Systems/Graphic/LiquidSystem/ModLavaStyleLoader.cs new file mode 100644 index 0000000000..d1210dbaa8 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/ModLavaStyleLoader.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + public class ModLavaStyleLoader : ModSystem + { + public static IEnumerable AllStyles => _AllStyles; + + public static int VanillaCount => 1; + public static int ModCount => _AllStyles.Count; + public static int TotalCount => ModCount + VanillaCount; + + private static readonly List _AllStyles = []; + + internal static int Register(ModLavaStyle instance) + { + int type = TotalCount; + + ModTypeLookup.Register(instance); + _AllStyles.Add(instance); + return type; + } + + public override void Unload() + { + _AllStyles.Clear(); + } + } +} diff --git a/Systems/Graphic/LiquidSystem/ModLavaStyleSystem.cs b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem.cs new file mode 100644 index 0000000000..42cf9c997b --- /dev/null +++ b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem.cs @@ -0,0 +1,116 @@ +using System; +using CalamityMod.ILEditing; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.Liquid; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + [Autoload(Side = ModSide.Client)] + public sealed partial class ModLavaStyleSystem : ModSystem + { + public static ModLavaStyle[] LavaStyles = new ModLavaStyle[ModLavaStyleLoader.VanillaCount]; + public static Asset[] Textures = new Asset[ModLavaStyleLoader.VanillaCount]; + public static Asset[] BlockTextures = new Asset[ModLavaStyleLoader.VanillaCount]; + public static Asset[] SlopeTextures = new Asset[ModLavaStyleLoader.VanillaCount]; + public static Asset[] WaterfallTextures = new Asset[ModLavaStyleLoader.VanillaCount]; + public static float[] LavaAlpha = new float[ModLavaStyleLoader.VanillaCount]; + + public static int LavaStyle = 2; + + public static bool Initialized { get; private set; } = false; + public static bool TextureArrayReady { get; private set; } = false; + + public override void ResizeArrays() + { + var modLavaStyles = ModLavaStyleLoader.AllStyles; + var totalCount = ModLavaStyleLoader.TotalCount; + + Array.Resize(ref LavaStyles, totalCount); + Array.Resize(ref Textures, totalCount); + Array.Resize(ref BlockTextures, totalCount); + Array.Resize(ref SlopeTextures, totalCount); + Array.Resize(ref WaterfallTextures, totalCount); + Array.Resize(ref LavaAlpha, totalCount); + + foreach (var modLavaStyle in modLavaStyles) + { + var slot = modLavaStyle.Slot; + LavaStyles[slot] = modLavaStyle; + Textures[slot] = ModContent.Request(modLavaStyle.Texture); + BlockTextures[slot] = ModContent.Request(modLavaStyle.BlockTexture); + SlopeTextures[slot] = ModContent.Request(modLavaStyle.SlopeTexture); + WaterfallTextures[slot] = ModContent.Request(modLavaStyle.WaterfallTexture); + } + + LavaAlpha[0] = 1.0f; // Setting Vanilla Lava to Full Alpha + Textures[0] = LiquidRenderer.Instance._liquidTextures[1]; + SlopeTextures[0] = TextureAssets.LiquidSlope[1]; + BlockTextures[0] = TextureAssets.Liquid[1]; + WaterfallTextures[0] = Main.instance.waterfallManager.waterfallTexture[1]; + + TextureArrayReady = true; + } + + public override void Load() + { + base.Load(); + + if (ExternalMods.biomeLava == null) + { + ManipulatorManager.ApplyEdits += ApplyEdits; + Main.QueueMainThreadAction(PrepareRT); + Main.OnPreDraw += UpdateRT; + Initialized = true; + } + } + + public override void OnModUnload() + { + if (Initialized) + { + Main.QueueMainThreadAction(DisposeRT); + Main.OnPreDraw -= UpdateRT; + Initialized = false; + } + + TextureArrayReady = false; + } + + public override void PreUpdatePlayers() + { + LavaStyle = 0; + foreach (var lavaStyle in ModLavaStyleLoader.AllStyles) + { + bool? flag = lavaStyle?.IsLavaActive(); + if (flag != null && flag == true) + { + LavaStyle = lavaStyle.Slot; + } + } + + for (int type = 0; type < ModLavaStyleLoader.TotalCount; type++) + { + if (LavaStyle == type) + { + LavaAlpha[type] += 0.125f; + if (LavaAlpha[type] > 1f) + { + LavaAlpha[type] = 1f; + } + } + else + { + LavaAlpha[type] -= 0.125f; + if (LavaAlpha[type] < 0f) + { + LavaAlpha[type] = 0f; + } + } + } + } + } +} diff --git a/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_API.cs b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_API.cs new file mode 100644 index 0000000000..7c81d279b5 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_API.cs @@ -0,0 +1,122 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Graphics; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + [Autoload(Side = ModSide.Client)] + public sealed partial class ModLavaStyleSystem : ModSystem + { + public static ModLavaStyle CurrentLavaStyle => LavaStyles[LavaStyle]; + + public static void ModifyLightBlended(int i, int j, ref float r, ref float g, ref float b) + { + Vector3 vanillaLavaLight = new Vector3(0.55f, 0.33f, 0.11f); + Vector3 lavaEmit = LavaStyle == 0 ? vanillaLavaLight : Vector3.Zero; + ModifyLightSetup(i, j, LavaStyle, ref lavaEmit.X, ref lavaEmit.Y, ref lavaEmit.Z); + + for (int styleIndex = 0; styleIndex < ModLavaStyleLoader.TotalCount; styleIndex++) + { + if (LavaAlpha[styleIndex] > 0f && styleIndex != LavaStyle) + { + Vector3 propagatingColor = (styleIndex == 0) ? vanillaLavaLight : Vector3.Zero; + ModifyLightSetup(i, j, styleIndex, ref propagatingColor.X, ref propagatingColor.Y, ref propagatingColor.Z); + + Vector3 activeColor = (LavaStyle == 0) ? vanillaLavaLight : Vector3.Zero; + ModifyLightSetup(i, j, LavaStyle, ref activeColor.Z, ref activeColor.Y, ref activeColor.Z); + + lavaEmit = Vector3.Lerp(propagatingColor, activeColor, LavaAlpha[LavaStyle]); + } + } + + if (lavaEmit.X != 0.0f || lavaEmit.Y != 0.0f || lavaEmit.Z != 0.0f) + { + float colorManipulator = (270 - Main.mouseTextColor) / 900f; + lavaEmit += Vector3.One * colorManipulator; + } + + r = Math.Max(r, lavaEmit.X); + g = Math.Max(g, lavaEmit.Y); + b = Math.Max(b, lavaEmit.Z); + } + + public static void ModifyColorBlended(int i, int j, ref VertexColors initialColor, bool isSlope) + { + VertexColors color = initialColor; + DrawColorSetup(i, j, LavaStyle, ref color, isSlope); + for (int styleIndex = 0; styleIndex < ModLavaStyleLoader.TotalCount; styleIndex++) + { + if (LavaAlpha[styleIndex] > 0f && styleIndex != LavaStyle) + { + VertexColors propagatingColor = initialColor; + DrawColorSetup(i, j, styleIndex, ref propagatingColor, isSlope); + + VertexColors activeColor = initialColor; + DrawColorSetup(i, j, LavaStyle, ref activeColor, isSlope); + + color = LerpColors(propagatingColor, activeColor, LavaAlpha[LavaStyle]); + } + } + + initialColor = color; + + static VertexColors LerpColors(VertexColors a, VertexColors b, float amt) + { + return new VertexColors() + { + TopLeftColor = Color.Lerp(a.TopLeftColor, b.TopLeftColor, amt), + TopRightColor = Color.Lerp(a.TopRightColor, b.TopRightColor, amt), + BottomLeftColor = Color.Lerp(a.BottomLeftColor, b.BottomLeftColor, amt), + BottomRightColor = Color.Lerp(a.BottomRightColor, b.BottomRightColor, amt), + }; + } + } + + public static void ModifyLightSetup(int i, int j, int style, ref float r, ref float g, ref float b) + { + if (LavaStyles[style] is ModLavaStyle styles) + { + styles.ModifyLight(i, j, ref r, ref g, ref b); + } + } + + public static void DrawColorSetup(int x, int y, int style, ref VertexColors liquidColor, bool isSlope = false) + { + if (LavaStyles[style] is ModLavaStyle styles) + { + styles.DrawColor(x, y, ref liquidColor, isSlope); + } + } + + public static int GetDropletGoreID(int oldID = -1) + { + if (CurrentLavaStyle is ModLavaStyle lavaStyle) + { + return lavaStyle.GetDropletGore(); + } + + return (oldID >= 0) ? oldID : GoreID.LavaDrip; + } + + public static int GetSplashDustID(int oldID = -1) + { + if (CurrentLavaStyle is ModLavaStyle lavaStyle) + { + return lavaStyle.GetSplashDust(); + } + + return (oldID >= 0) ? oldID : DustID.Lava; + } + + public static void InflictDebuff(Player player, int onFireTime) + { + if (CurrentLavaStyle is ModLavaStyle lavaStyle) + { + lavaStyle.InflictDebuff(player, onFireTime); + } + } + } +} diff --git a/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_ILEdit.cs b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_ILEdit.cs new file mode 100644 index 0000000000..9c821ee107 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_ILEdit.cs @@ -0,0 +1,409 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using CalamityMod.ILEditing; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Mono.Cecil; +using Mono.Cecil.Cil; +using MonoMod.Cil; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.Drawing; +using Terraria.GameContent.Liquid; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + [Autoload(Side = ModSide.Client)] + public sealed partial class ModLavaStyleSystem : ModSystem + { + private static readonly MethodInfo Tex2DAssetGetter = typeof(Asset).GetProperty(nameof(Asset<>.Value)).GetMethod; + + private static void ApplyEdits(ManipulatorContext ctx) + { + if (Tex2DAssetGetter == null) + { + CalamityMod.Log.ILFailure("ModLavaStyle", "Cannot find Getter for Asset::Value"); + return; + } + + // Graphic + IL_LiquidRenderer.DrawNormalLiquids += DrawNormalLiquidPatch; + IL_TileDrawing.DrawPartialLiquid += DrawPartialLiquidPatch; + IL_Main.oldDrawWater += DrawOldWaterPatch; + On_WaterfallManager.DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects += DrawWaterfall; + On_WaterfallManager.AddLight += WaterfallAddLight; + On_WaterfallManager.StylizeColor += WaterfallGlowmaskEditor; + + // Mechanics + IL_LiquidRenderer.InternalPrepareDraw += LavaBubbleReplacer; + IL_TileDrawing.EmitLiquidDrops += LavaDropletReplacer; + IL_NPC.Collision_WaterCollision += SplashEntityLava; + IL_Projectile.Update += SplashEntityLava; + IL_Item.MoveInWorld += SplashEntityLava; + ctx.PlayerUpdate.Add(SplashEntityLava); + ctx.PlayerUpdate.Add(PlayerDebuffEdit); + } + + #region Drawing IL Edits + + private static void DrawNormalLiquidPatch(ILContext il) + { + const string PatchName = "ModLavaStyle::DrawNormalLiquid"; + + var cursor = new ILCursor(il); + + var patched = PatchNextGetTexture2DLdLoc(cursor, (textureIdxLocIdx, textureArrayField) => + { + cursor.EmitLdloc(textureIdxLocIdx); + cursor.EmitDelegate((Texture2D origTex, int textureIdx) => + { + return (textureIdx == LiquidID.Lava) ? LavaRT : origTex; + }); + }); + + if (!patched) + { + CalamityMod.Log.ILFailure(PatchName, "Unable to Locate Asset::Value call"); + } + } + + private static void DrawPartialLiquidPatch(ILContext il) + { + const string PatchName = "ModLavaStyle::DrawPartialLiquids"; + const int DesiredPatchCount = 5; + + var cursor = new ILCursor(il); + + int patchedCount = 0; + foreach (var context in FindAllGetTexture2DLdArg(cursor)) + { + var c = context.c; + var textureArgIdx = context.textureArgIdx; + var textureArrayField = context.textureArrayField; + var textureArrayFieldName = textureArrayField.Name; + if (textureArrayField.Name == nameof(TextureAssets.Liquid)) + { + c.EmitLdarg(textureArgIdx); + c.EmitDelegate((Texture2D origTex, int textureIdx) => + { + return (textureIdx == LiquidID.Lava) ? LavaBlockRT : origTex; + }); + patchedCount++; + } + else if (textureArrayField.Name == nameof(TextureAssets.LiquidSlope)) + { + c.EmitLdarg(textureArgIdx); + c.EmitDelegate((Texture2D origTex, int textureIdx) => + { + return (textureIdx == LiquidID.Lava) ? LavaSlopeRT : origTex; + }); + patchedCount++; + } + else + { + CalamityMod.Log.ILFailure(PatchName, $"Texture Array We referencing is [{textureArrayField.Name}] Which is not intended. Skipping"); + } + } + + // Finalizing Patch + if (patchedCount <= 0) + { + CalamityMod.Log.ILFailure(PatchName, "Unable to patch any of the texture reference"); + return; + } + else + { + if (patchedCount != DesiredPatchCount) + { + CalamityMod.Log.Warn($"We did patched into {patchedCount} entry which is unmatching with desired count ({DesiredPatchCount}) when designed this iledit. Please check if anything is broken, If not update the count accordingly to suppress this message!"); + CalamityMod.Log.Warn($"Location: ModLavaStyleSystem_ILEdit.cs :: DrawPartialLiquidPatch"); + } + } + } + + private static void DrawOldWaterPatch(ILContext il) + { + const string PatchName = "ModLavaStyle::DrawOldWater"; + const int DesiredPatchCount = 10; + + var cursor = new ILCursor(il); + + int patchedCount = 0; + foreach (var context in FindAllGetTexture2DLdLoc(cursor)) + { + var c = context.c; + var textureLocIdx = context.textureLocIdx; + var textureArrayField = context.textureArrayField; + var textureArrayFieldName = textureArrayField.Name; + if (textureArrayField.Name == nameof(TextureAssets.Liquid)) + { + c.EmitLdloc(textureLocIdx); + c.EmitDelegate((Texture2D origTex, int textureIdx) => + { + return (textureIdx == LiquidID.Lava) ? LavaBlockRT : origTex; + }); + patchedCount++; + } + else if (textureArrayField.Name == nameof(TextureAssets.LiquidSlope)) + { + c.EmitLdloc(textureLocIdx); + c.EmitDelegate((Texture2D origTex, int textureIdx) => + { + return (textureIdx == LiquidID.Lava) ? LavaSlopeRT : origTex; + }); + patchedCount++; + } + else + { + CalamityMod.Log.ILFailure(PatchName, $"Texture Array We referencing is [{textureArrayField.Name}] Which is not intended. Skipping"); + } + } + + // Finalizing Patch + if (patchedCount <= 0) + { + CalamityMod.Log.ILFailure(PatchName, "Unable to patch any of the texture reference"); + return; + } + else + { + if (patchedCount != DesiredPatchCount) + { + CalamityMod.Log.Warn($"We did patched into {patchedCount} entry which is unmatching with desired count ({DesiredPatchCount}) when designed this iledit. Please check if anything is broken, If not update the count accordingly to suppress this message!"); + CalamityMod.Log.Warn($"Patch Name: {PatchName}"); + } + } + } + + private static void DrawWaterfall(On_WaterfallManager.orig_DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects orig, WaterfallManager self, int waterfallType, int x, int y, float opacity, Vector2 position, Rectangle sourceRect, Color color, SpriteEffects effects) + { + if (waterfallType == LiquidID.Lava && CurrentLavaStyle != null) + { + var lightColor = Lighting.GetColor(x, y); + Main.spriteBatch.Draw(LavaWaterfallRT, position, sourceRect, lightColor * opacity, 0f, Vector2.Zero, 1f, effects, 0f); + } + else + { + orig(self, waterfallType, x, y, opacity, position, sourceRect, color, effects); + } + } + + private static void WaterfallAddLight(On_WaterfallManager.orig_AddLight orig, int waterfallType, int x, int y) + { + if (waterfallType == LiquidID.Lava && CurrentLavaStyle is ModLavaStyle lavaStyle) + { + float r = 0.55f; + float g = 0.33f; + float b = 0.11f; + lavaStyle.ModifyLight(x, y, ref r, ref g, ref b); + Lighting.AddLight(x, y, r, g, b); + return; + } + orig.Invoke(waterfallType, x, y); + } + + private static Color WaterfallGlowmaskEditor(On_WaterfallManager.orig_StylizeColor orig, float alpha, int maxSteps, int waterfallType, int y, int s, Tile tileCache, Color aColor) + { + if (waterfallType == LiquidID.Lava && !(CurrentLavaStyle?.LavafallGlowmask() ?? false)) + { + return aColor; + } + else + { + return orig.Invoke(alpha, maxSteps, waterfallType, y, s, tileCache, aColor); + } + } + + #endregion + + #region Mechanics IL Edits + private static void LavaBubbleReplacer(ILContext il) + { + const string PatchName = "Ambient lava bubble replacer"; + + ILCursor cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.After, + i => i.MatchLdcI4(16), + i => i.MatchLdcI4(16), + i => i.MatchLdcI4(DustID.Lava))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the bubble newdust parameters"); + return; + } + + // int dustID + cursor.EmitDelegate>(GetSplashDustID); + + if (!cursor.TryGotoNext(MoveType.After, + i => i.MatchLdcI4(16), + i => i.MatchLdcI4(8), + i => i.MatchLdcI4(DustID.Lava))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the surface bubble newdust parameters"); + return; + } + + // int dustID + cursor.EmitDelegate>(GetSplashDustID); + } + + private static void LavaDropletReplacer(ILContext il) + { + const string PatchName = "Ambient lava droplet replacer"; + + ILCursor cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.After, + i => i.MatchLdarg(out _), + i => i.MatchLdcI4(374), + i => i.MatchBneUn(out _), + i => i.MatchLdcI4(GoreID.LavaDrip))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the lava droplet newgore parameters"); + return; + } + + // int goreID + cursor.EmitDelegate>(GetDropletGoreID); + } + + private static void SplashEntityLava(ILContext il) + { + const string PatchName = "Entity Lava Splashing (Item, Projectile, NPC, Player)"; + + ILCursor cursor = new ILCursor(il); + + if (!cursor.TryGotoNext(MoveType.After, + i => i.MatchLdfld("width"), + i => i.MatchLdcI4(12), + i => i.MatchAdd(), + i => i.MatchLdcI4(24), + i => i.MatchLdcI4(DustID.Lava))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the first lava bubble splashing"); + return; + } + + // int dustID + cursor.EmitDelegate>(GetSplashDustID); + + if (!cursor.TryGotoNext(MoveType.After, + i => i.MatchLdfld("width"), + i => i.MatchLdcI4(12), + i => i.MatchAdd(), + i => i.MatchLdcI4(24), + i => i.MatchLdcI4(DustID.Lava))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the second lava bubble splashing"); + return; + } + + // int dustID + cursor.EmitDelegate>(GetSplashDustID); + } + + private static void PlayerDebuffEdit(ILContext il) + { + const string PatchName = "Player Update Lava Debuff"; + + //Injects code directly at the position where the OnFire debuff is handled + ILCursor cursor = new ILCursor(il); + + int onFireTimeLocalIdx = 0; + if (!cursor.TryGotoNext(MoveType.Before, + i => i.MatchLdarg0(), + i => i.MatchLdcI4(BuffID.OnFire), + i => i.MatchLdloc(out onFireTimeLocalIdx), // + i => i.MatchLdcI4(1), // quiet + i => i.MatchLdcI4(0), // foodHack + i => i.MatchCall(nameof(Player.AddBuff)))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the infliction of the On Fire! debuff inside the Player Update code"); + return; + } + cursor.EmitLdarg0(); // Player player + cursor.EmitLdloc(onFireTimeLocalIdx); // int OnFireTime + cursor.EmitDelegate(InflictDebuff); + } + #endregion + + #region Patch Utils + + private static IEnumerable<(ILCursor c, int textureArgIdx, FieldReference textureArrayField)> FindAllGetTexture2DLdArg(ILCursor cursor) + { + int textureArgIdx = 0; + FieldReference textureArrayField = null; + foreach (var c in FindAll(cursor, MoveType.After, + x => x.MatchLdsfld(out textureArrayField) || x.MatchLdfld(out textureArrayField), + x => x.MatchLdarg(out textureArgIdx), + x => x.MatchLdelemRef(), + x => x.MatchCallOrCallvirt(Tex2DAssetGetter))) + { + yield return (c, textureArgIdx, textureArrayField); + } + } + + private static IEnumerable<(ILCursor c, int textureLocIdx, FieldReference textureArrayField)> FindAllGetTexture2DLdLoc(ILCursor cursor) + { + int textureLocIdx = 0; + FieldReference textureArrayField = null; + foreach (var c in FindAll(cursor, MoveType.After, + x => x.MatchLdsfld(out textureArrayField) || x.MatchLdfld(out textureArrayField), + x => x.MatchLdloc(out textureLocIdx), + x => x.MatchLdelemRef(), + x => x.MatchCallOrCallvirt(Tex2DAssetGetter))) + { + yield return (c, textureLocIdx, textureArrayField); + } + } + + private static IEnumerable FindAll(ILCursor cursor, MoveType moveType, params Func[] predicates) + { + var c = cursor.Clone(); + while (c.TryGotoNext(moveType, predicates)) + { + yield return c.Clone(); + } + } + + private static bool PatchNextGetTexture2DLdArg(ILCursor cursor, Action patcher) + { + int textureArgIdx = 0; + FieldReference textureArrayField = null; + if (cursor.TryGotoNext(MoveType.After, + x => x.MatchLdsfld(out textureArrayField) || x.MatchLdfld(out textureArrayField), + x => x.MatchLdarg(out textureArgIdx), + x => x.MatchLdelemRef(), + x => x.MatchCallOrCallvirt(Tex2DAssetGetter))) + { + patcher.Invoke(textureArgIdx, textureArrayField); + return true; + } + + return false; + } + + private static bool PatchNextGetTexture2DLdLoc(ILCursor cursor, Action patcher) + { + int textureLocalIdx = 0; + FieldReference textureArrayField = null; + if (cursor.TryGotoNext(MoveType.After, + x => x.MatchLdsfld(out textureArrayField) || x.MatchLdfld(out textureArrayField), + x => x.MatchLdloc(out textureLocalIdx), + x => x.MatchLdelemRef(), + x => x.MatchCallOrCallvirt(Tex2DAssetGetter))) + { + patcher.Invoke(textureLocalIdx, textureArrayField); + return true; + } + + return false; + } + + #endregion + + } +} diff --git a/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_RT.cs b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_RT.cs new file mode 100644 index 0000000000..4fdf3ee22e --- /dev/null +++ b/Systems/Graphic/LiquidSystem/ModLavaStyleSystem_RT.cs @@ -0,0 +1,122 @@ +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + [Autoload(Side = ModSide.Client)] + public sealed partial class ModLavaStyleSystem : ModSystem + { + public static RenderTarget2D LavaRT { get; private set; } + public static RenderTarget2D LavaBlockRT { get; private set; } + public static RenderTarget2D LavaSlopeRT { get; private set; } + public static RenderTarget2D LavaWaterfallRT { get; private set; } + + public const int TextureWidth = 48; + public const int TextureHeight = 1360; + + public const int BlockTextureWidth = 16; + public const int BlockTextureHeight = 16; + + public const int SlopeTextureWidth = 72; + public const int SlopeTextureHeight = 16; + + public const int WaterfallTextureWidth = 512; + public const int WaterfallTextureHeight = 40; + + private static void PrepareRT() + { + LavaRT = CreateRT(TextureWidth, TextureHeight); + LavaBlockRT = CreateRT(BlockTextureWidth, BlockTextureHeight); + LavaSlopeRT = CreateRT(SlopeTextureWidth, SlopeTextureHeight); + LavaWaterfallRT = CreateRT(WaterfallTextureWidth, WaterfallTextureHeight); + } + + private static RenderTarget2D CreateRT(int width, int height) + { + return new(Main.instance.GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); + } + + private static void DisposeRT() + { + LavaRT?.Dispose(); + LavaBlockRT?.Dispose(); + LavaSlopeRT?.Dispose(); + LavaWaterfallRT?.Dispose(); + + LavaRT = null; + LavaBlockRT = null; + LavaSlopeRT = null; + LavaWaterfallRT = null; + } + + private static void UpdateRT(GameTime time) + { + + if (!Initialized || !TextureArrayReady || Main.gameMenu) + return; + + using (LavaRT.Scope(clearColor: Color.Transparent)) + { + Begin(); + DrawTextures(Textures); + End(); + } + + using (LavaBlockRT.Scope(clearColor: Color.Transparent)) + { + Begin(); + DrawTextures(BlockTextures); + End(); + } + + using (LavaSlopeRT.Scope(clearColor: Color.Transparent)) + { + Begin(); + DrawTextures(SlopeTextures); + End(); + } + + using (LavaWaterfallRT.Scope(clearColor: Color.Transparent)) + { + Begin(); + DrawTextures(WaterfallTextures); + End(); + } + } + + private static readonly BlendState ActualAdditive = new() + { + ColorSourceBlend = Blend.One, + AlphaSourceBlend = Blend.One, + ColorDestinationBlend = Blend.One, + AlphaDestinationBlend = Blend.One + }; + + private static void Begin() + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, ActualAdditive, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.Identity); + } + + private static void End() + { + Main.spriteBatch.End(); + } + + private static void DrawTextures(Asset[] textures) + { + var totalCount = ModLavaStyleLoader.TotalCount; + for (int i = 0; i < totalCount; i++) + { + var alpha = LavaAlpha[i]; + if (alpha <= 0.0f) + continue; + + Main.spriteBatch.Draw(textures[i].Value, Vector2.Zero, null, Color.White * alpha); + } + } + } +} diff --git a/Systems/Graphic/LiquidSystem/SpecialLiquidDrawingSystem.cs b/Systems/Graphic/LiquidSystem/SpecialLiquidDrawingSystem.cs new file mode 100644 index 0000000000..77623471df --- /dev/null +++ b/Systems/Graphic/LiquidSystem/SpecialLiquidDrawingSystem.cs @@ -0,0 +1,266 @@ +using System; +using System.Reflection; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Mono.Cecil.Cil; +using MonoMod.Cil; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent.Drawing; +using Terraria.GameContent.Liquid; +using Terraria.Graphics; +using Terraria.Graphics.Light; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.LiquidSystem +{ + [Autoload(Side = ModSide.Client)] + public sealed class SpecialLiquidDrawingSystem : ModSystem + { + public override void OnModLoad() + { + On_TileLightScanner.GetTileLight += ApplyLiquidEmit; + IL_LiquidRenderer.DrawNormalLiquids += LiquidDrawColorAndPostDraw; //Liquid Light + On_TileDrawing.DrawPartialLiquid += LiquidSlopeDrawColors; + IL_Main.oldDrawWater += OldLiquidPostDraw; + + On_WaterfallManager.DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects += ModifyWaterfallColor; + } + + private static void ModifyEmit(Tile tile, int x, int y, ref Vector3 lightColor) + { + if (tile.HasTile || tile.LiquidAmount <= 0) + return; + + if (tile.LiquidType == LiquidID.Water && GetModWaterStyle(Main.waterStyle) is IWaterStyleModifyLight waterStyle) + { + float R = 0f; + float G = 0f; + float B = 0f; + + waterStyle.ModifyLight(in tile, x, y, ref R, ref G, ref B); + + lightColor.X = Math.Max(lightColor.X, R); + lightColor.Y = Math.Max(lightColor.Y, G); + lightColor.Z = Math.Max(lightColor.Z, B); + } + else if (tile.LiquidType == LiquidID.Lava && ModLavaStyleSystem.Initialized) + { + ModLavaStyleSystem.ModifyLightBlended(x, y, ref lightColor.X, ref lightColor.Y, ref lightColor.Z); + } + } + + private static void ModifyColor(int x, int y, int liquidStyle, ref VertexColors initialColor, bool isSlope = false) + { + if (GetModWaterStyle(liquidStyle) is IWaterStyleModifyColor waterStyle) + { + var tile = Main.tile[x, y]; + waterStyle.ModifyColor(in tile, x, y, ref initialColor, isSlope); + } + else if (liquidStyle == LiquidID.Lava && ModLavaStyleSystem.Initialized) + { + ModLavaStyleSystem.ModifyColorBlended(x, y, ref initialColor, isSlope); + } + } + + private static void PostDrawEffect(int x, int y, int liquidStyle) + { + if (GetModWaterStyle(liquidStyle) is IWaterStylePostDrawEffect waterStyle) + { + var tile = Main.tile[x, y]; + waterStyle.PostDrawEffect(in tile, x, y); + } + } + + #region IL Edits + + private static void ApplyLiquidEmit(On_TileLightScanner.orig_GetTileLight orig, TileLightScanner self, int x, int y, out Vector3 outputColor) + { + orig(self, x, y, out outputColor); + ModifyEmit(Main.tile[x, y], x, y, ref outputColor); + } + + private static void LiquidDrawColorAndPostDraw(ILContext il) + { + const string PatchName = "Liquid Draw Colors"; + + ILCursor cursor = new ILCursor(il); + + var typeField = typeof(LiquidRenderer.LiquidDrawCache).GetField(nameof(LiquidRenderer.LiquidDrawCache.Type)); + if (typeField == null) + { + CalamityMod.Log.ILFailure(PatchName, "Could not find FieldInfo for LiquidDrawCache.Type"); + return; + } + + var lightingGetCornerColorsMethod = typeof(Lighting).GetMethod(nameof(Lighting.GetCornerColors)); + if (lightingGetCornerColorsMethod == null) + { + CalamityMod.Log.ILFailure(PatchName, "Could not find MethodInfo for GetCornerColors"); + return; + } + + var mainDrawTileInWaterMethod = typeof(Main).GetMethod(nameof(Main.DrawTileInWater)); + if (mainDrawTileInWaterMethod == null) + { + CalamityMod.Log.ILFailure(PatchName, "Could not find FieldInfo for DrawTileInWater"); + return; + } + + int liquidStyleLocalIdx = 0; + if (!cursor.TryGotoNext(MoveType.Before, + c => c.MatchLdloc(out _), // This is the local index for LiquidDrawCache*. Use it if you want for future + c => c.MatchLdfld(typeField), + c => c.MatchStloc(out liquidStyleLocalIdx))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the local index for Liquid Type (Style)"); + return; + } + + int vertexColorLocalIdx = 0; + if (!cursor.TryGotoNext(MoveType.Before, + c => c.MatchLdloca(out vertexColorLocalIdx), + c => c.MatchLdcR4(out _), + c => c.MatchCallOrCallvirt(lightingGetCornerColorsMethod))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the local index for VertexColors"); + return; + } + + int xLocalIdx = 0; + int yLocalIdx = 0; + if (!cursor.TryGotoNext(MoveType.Before, + c => c.MatchLdarg(out _), // Vector2 drawOffset + c => c.MatchLdloc(out xLocalIdx), + c => c.MatchLdloc(out yLocalIdx), + c => c.MatchCallOrCallvirt(mainDrawTileInWaterMethod))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate the liquid vertex colors for drawing"); + return; + } + + cursor.EmitLdloc(liquidStyleLocalIdx); + cursor.EmitLdloc(xLocalIdx); + cursor.EmitLdloc(yLocalIdx); + cursor.EmitLdloca(vertexColorLocalIdx); + cursor.EmitDelegate((int liquidStyle, int x, int y, ref VertexColors initialColor) => + { + ModifyColor(x, y, liquidStyle, ref initialColor); + }); + + if (!cursor.TryGotoNext(MoveType.After, + c => c.MatchCallOrCallvirt(nameof(TileBatch.Draw)))) + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate TileBatch.Draw call"); + return; + } + + cursor.EmitLdloc(liquidStyleLocalIdx); + cursor.EmitLdloc(xLocalIdx); + cursor.EmitLdloc(yLocalIdx); + cursor.EmitDelegate((int liquidStyle, int x, int y) => + { + PostDrawEffect(x, y, liquidStyle); + }); + } + + private static void LiquidSlopeDrawColors(On_TileDrawing.orig_DrawPartialLiquid orig, TileDrawing self, bool behindBlocks, Tile tileCache, ref Vector2 position, ref Rectangle liquidSize, int liquidType, ref VertexColors colors) + { + tileCache.TilePos(out var x, out var y); + var type = tileCache.TileType; + var isFullblock = type == 0 || (!TileID.Sets.BlocksWaterDrawingBehindSelf[type] && behindBlocks); + ModifyColor(x, y, liquidType, ref colors, isSlope: !isFullblock); + orig(self, behindBlocks, tileCache, ref position, ref liquidSize, liquidType, ref colors); + } + + private static void OldLiquidPostDraw(ILContext il) + { + const string PatchName = "Old Liquid PostDraw"; + + ILCursor cursor = new ILCursor(il); + var typeRef = cursor.Context.Import(typeof(bool)); + var isDrawnVarDef = new VariableDefinition(typeRef); + il.Body.Variables.Add(isDrawnVarDef); + + // Start of method, Reset IsDrawn Variable to False + cursor.EmitLdcI4(0); // False + cursor.EmitStloc(isDrawnVarDef); + + int xLocalIdx = 0; + int yLocalIdx = 0; + ILLabel endLoopLabal = null; + if (!cursor.TryGotoNext(MoveType.After, + c => c.MatchBrfalse(out endLoopLabal), + c => c.MatchLdloc(out xLocalIdx), + c => c.MatchLdloc(out yLocalIdx), + c => c.MatchCallOrCallvirt(nameof(Lighting.GetColor)), + c => c.MatchStloc(out _))) // Color color; + { + CalamityMod.Log.ILFailure(PatchName, "Could not locate Lighting.GetColor call"); + return; + } + + // Start of loop, Passed Draw Condition, Set IsDrawn Variable to True + cursor.EmitLdcI4(1); // True + cursor.EmitStloc(isDrawnVarDef); + + // Jump to end of the loop + cursor.GotoLabel(endLoopLabal, MoveType.AfterLabel); + + // Load Variables to stack + cursor.EmitLdloc(isDrawnVarDef); + cursor.EmitLdloc(xLocalIdx); + cursor.EmitLdloc(yLocalIdx); + cursor.EmitLdarg(1); // bool background + cursor.EmitLdarg(2); // int WaterStyle + cursor.EmitDelegate((bool isDrawn, int x, int y, bool isBackground, int waterStyle) => + { + if (!isDrawn || isBackground) + return; + + if (Main.waterStyle != waterStyle) + return; + + var tile = Main.tile[x, y]; + var liquidType = tile.LiquidType; + if (liquidType == LiquidID.Water) + { + PostDrawEffect(x, y, waterStyle); + } + }); + + // End, Reset IsDrawn to False + cursor.EmitLdcI4(0); // False + cursor.EmitStloc(isDrawnVarDef); + } + + private static void ModifyWaterfallColor(On_WaterfallManager.orig_DrawWaterfall_int_int_int_float_Vector2_Rectangle_Color_SpriteEffects orig, WaterfallManager self, int waterfallType, int x, int y, float opacity, Vector2 position, Rectangle sourceRect, Color color, SpriteEffects effects) + { + if (GetModWaterfallStyle(waterfallType) is IWaterfallStyleModifyColor style) + { + Tile tile = Main.tile[x, y]; + Texture2D texture = self.waterfallTexture[waterfallType].Value; + Lighting.GetCornerColors(x, y, out var vertices, 1f); + style.ModifyColor(in tile, x, y, ref vertices); + Main.tileBatch.Draw(texture, position, sourceRect, vertices, Vector2.Zero, 1f, effects); + } + else + { + orig(self, waterfallType, x, y, opacity, position, sourceRect, color, effects); + } + } + + #endregion + + private static ModWaterStyle GetModWaterStyle(int type) + { + return LoaderManager.Get().Get(type); + } + + private static ModWaterfallStyle GetModWaterfallStyle(int type) + { + return LoaderManager.Get().Get(type); + } + } +} diff --git a/Systems/Graphic/LiquidSystem/_OBSOLETE_CalamityModWaterStyle.cs b/Systems/Graphic/LiquidSystem/_OBSOLETE_CalamityModWaterStyle.cs new file mode 100644 index 0000000000..a70f705be6 --- /dev/null +++ b/Systems/Graphic/LiquidSystem/_OBSOLETE_CalamityModWaterStyle.cs @@ -0,0 +1,43 @@ +using System; +using CalamityMod.Systems.Graphic.LiquidSystem; +using Terraria; +using Terraria.Graphics; +using Terraria.ModLoader; + +#pragma warning disable IDE0130 // Namespace does not match folder structure +namespace CalamityMod.Systems +#pragma warning restore IDE0130 // Namespace does not match folder structure +{ + [Obsolete($"Use {nameof(IWaterStyleModifyColor)} and {nameof(IWaterStyleModifyLight)} Instead")] + public abstract class CalamityModWaterStyle : ModWaterStyle, IWaterStyleModifyColor, IWaterStyleModifyLight + { + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope) => DrawColor(x, y, ref liquidColor, isSlope); + + /// + /// Allows water styles to manipulate what color the liquid is drawn to, this can allow waters to be see-throughable to see backgrounds (surface and underground backgrounds not walls) + /// + /// X position of the water + /// Y position of the water + /// The vertexColor of the water color, this is both used to get the current color and to set the color of the water + public virtual void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) + { + } + + public void ModifyLight(in Tile tile, int x, int y, ref float r, ref float g, ref float b) => ModifyLight(x, y, ref r, ref g, ref b); + + /// + /// Allows you to determine how much light this water emits.
+ /// It can also let you light up the block in front of this water.
+ /// See for vanilla tile light values to use as a reference.
+ ///
+ /// The x position in tile coordinates. + /// The y position in tile coordinates. + /// The red component of light, usually a value between 0 and 1 + /// The green component of light, usually a value between 0 and 1 + /// The blue component of light, usually a value between 0 and 1 + public virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + + } + } +} diff --git a/Systems/Graphic/ModLavaStyle.cs b/Systems/Graphic/ModLavaStyle.cs deleted file mode 100644 index bc015799fb..0000000000 --- a/Systems/Graphic/ModLavaStyle.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent.Liquid; -using Terraria.GameContent; -using Terraria.Graphics; -using Terraria.ModLoader; -using System.Linq; -using Terraria.ID; -using Microsoft.Xna.Framework; -using CalamityMod.Items.Potions.Alcohol; - -namespace CalamityMod.Systems -{ - public abstract class ModLavaStyle : ModTexturedType - { - /// - /// The ID of the lava style. - /// - public int Slot { get; private set; } = -1; - - public override string Name => base.Name; - - public override string Texture => base.Texture; - - public virtual string BlockTexture => Texture + "_Block"; - - public virtual string SlopeTexture => Texture + "_Slope"; - - public virtual string WaterfallTexture => Texture + "_Waterfall"; - - protected sealed override void Register() - { - Slot = LavaStylesLoader.Register(this); - } - - public sealed override void SetupContent() - { - SetStaticDefaults(); - } - - /// - /// Allows you to determine how much light this lava emits.
- /// It can also let you light up the block in front of this lava.
- /// Keep in mind this also effects what color the lavafalls emit
- /// See for vanilla tile light values to use as a reference.
- ///
- /// The x position in tile coordinates. - /// The y position in tile coordinates. - /// The red component of light, usually a value between 0 and 1 - /// The green component of light, usually a value between 0 and 1 - /// The blue component of light, usually a value between 0 and 1 - public virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.55f; - g = 0.33f; - b = 0.11f; - } - - /// - /// Allows water styles to manipulate what color the liquid is drawn to, this can allow waters to be see-throughable to see backgrounds (surface and underground backgrounds not walls) - /// - /// X position of the water - /// Y position of the water - /// The vertexColor of the water color, this is both used to get the current color and to set the color of the water - public virtual void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) - { - } - - /// - /// The ID of the dust that is created when anything splashes in lava. - /// - public virtual int GetSplashDust() - { - return DustID.Lava; - } - - /// - /// The ID of the gore that represents droplets of lava falling down from a block. Return (or another existing droplet gore). - /// - public virtual int GetDropletGore() - { - return GoreID.LavaDrip; - } - - /// - /// Return true if the player is in the correct zone to activate the lava. - /// - /// - public virtual bool IsLavaActive() - { - return false; - } - - /// - /// Return false if the waterfall made by the lavastyle should have a glowmask - /// - /// - public virtual bool LavafallGlowmask() - { - return true; - } - - /// - /// Allows your lavastyle to inflict debuffs to Players and NPCs when they enter your lava style - /// - /// The Player that is inflicted with the debuff apon entering the lavastyle - /// The duration of the OnFire! debuff. This allows for easy replacement of OnFire - public virtual void InflictDebuff(Player player, int onfireDuration) - { - } - } - - public class LavaStylesLoader : ModSystem - { - private static readonly MethodInfo ResizeArrayMethodInfo; - - static LavaStylesLoader() - { - ResizeArrayMethodInfo = typeof(ModContent).GetMethod("ResizeArrays", BindingFlags.NonPublic | BindingFlags.Static); - } - - private static void ResizeArrays(ResizeArray_orig orig, bool unloading) - { - orig.Invoke(unloading); - int totalCount = TotalCount; - Array.Resize(ref LavaRenderingSystem.Textures.liquid, totalCount); - Array.Resize(ref LavaRenderingSystem.Textures.block, totalCount); - Array.Resize(ref LavaRenderingSystem.Textures.slope, totalCount); - Array.Resize(ref LavaRenderingSystem.Textures.fall, totalCount); - Array.Resize(ref LavaRenderingSystem.LavaAlpha, totalCount); - Array.Resize(ref LavaRenderingSystem.AlphaSave, totalCount); - } - - private static readonly List _content = []; - - public static IReadOnlyList Content => _content; - - public static int VanillaCount => 1; - - public static int ModCount => _content.Count; - - public static int TotalCount => VanillaCount + ModCount; - - public override void Load() - { - if (ResizeArrayMethodInfo != null) - { - MonoModHooks.Add(ResizeArrayMethodInfo, ResizeArrays); - } - } - - public override void PostSetupContent() - { - foreach (ModLavaStyle item in Content) - { - int Slot = item.Slot; - LavaRenderingSystem.Textures.liquid[Slot] = ModContent.Request(item.Texture, AssetRequestMode.AsyncLoad); - LavaRenderingSystem.Textures.block[Slot] = ModContent.Request(item.BlockTexture, AssetRequestMode.AsyncLoad); - LavaRenderingSystem.Textures.slope[Slot] = ModContent.Request(item.SlopeTexture, AssetRequestMode.AsyncLoad); - LavaRenderingSystem.Textures.fall[Slot] = ModContent.Request(item.WaterfallTexture, AssetRequestMode.AsyncLoad); - } - } - - public static ModLavaStyle Get(int type) - { - type -= VanillaCount; - return type >= 0 && type < _content.Count ? _content[type] : null; - } - - internal static int Register(ModLavaStyle instance) - { - int type = TotalCount; - ModTypeLookup.Register(instance); - _content.Add(instance); - return type; - } - - private delegate void ResizeArray_orig(bool unloading); - - public static void UpdateLiquidAlphas() - { - if (LavaRenderingSystem.LavaStyle >= VanillaCount) - { - for (int i = 0; i < VanillaCount; i++) - { - LavaRenderingSystem.LavaAlpha[i] -= 0.2f; - if (LavaRenderingSystem.LavaAlpha[i] < 0f) - { - LavaRenderingSystem.LavaAlpha[i] = 0f; - } - } - } - foreach (ModLavaStyle item in Content) - { - int type = item.Slot; - if (LavaRenderingSystem.LavaStyle == type) - { - LavaRenderingSystem.LavaAlpha[type] += 0.2f; - if (LavaRenderingSystem.LavaAlpha[type] > 1f) - { - LavaRenderingSystem.LavaAlpha[type] = 1f; - } - } - else - { - LavaRenderingSystem.LavaAlpha[type] -= 0.2f; - if (LavaRenderingSystem.LavaAlpha[type] < 0f) - { - LavaRenderingSystem.LavaAlpha[type] = 0f; - } - } - } - } - - public static void ModifyLightSetup(int i, int j, int style, ref float r, ref float g, ref float b) - { - ModLavaStyle lavaStyle = Get(style); - if (lavaStyle != null) - { - lavaStyle?.ModifyLight(i, j, ref r, ref g, ref b); - } - } - - internal static void DrawColorSetup(int x, int y, int type, ref VertexColors liquidColor, bool isSlope = false) - { - ModLavaStyle styles = Get(type); - if (styles != null) - { - styles?.DrawColor(x, y, ref liquidColor, isSlope); - } - } - - public static void InflictDebuff(Player player, int type, int onfireDuration) - { - ModLavaStyle lavaStyle = Get(type); - if (lavaStyle != null) - { - lavaStyle?.InflictDebuff(player, onfireDuration); - } - } - - public static void IsLavaActive() - { - foreach (ModLavaStyle item in Content) - { - int type = item.Slot; - ModLavaStyle lavaStyle = Get(type); - if (lavaStyle != null) - { - bool? flag = lavaStyle?.IsLavaActive(); - if (flag != null && flag == true) - { - LavaRenderingSystem.LavaStyle = lavaStyle.Slot; - } - } - } - } - } -} diff --git a/Systems/Graphic/MultiVariantWallDrawingSystem.cs b/Systems/Graphic/MultiVariantWallDrawingSystem.cs index 7bd266dac7..25658205fd 100644 --- a/Systems/Graphic/MultiVariantWallDrawingSystem.cs +++ b/Systems/Graphic/MultiVariantWallDrawingSystem.cs @@ -1,5 +1,4 @@ -using CalamityMod.ILEditing; -using CalamityMod.Walls; +using CalamityMod.Walls; using Microsoft.Xna.Framework; using MonoMod.Cil; using Terraria; @@ -66,7 +65,7 @@ namespace CalamityMod.Systems private static void LogILFailure(string reason) { - ILChanges.LogFailure("Support for Wall FrameOffset", reason); + CalamityMod.Log.ILFailure("Support for Wall FrameOffset", reason); } } } diff --git a/Systems/Graphic/PixelationSystem/PixelatedDrawer.cs b/Systems/Graphic/PixelationSystem/PixelatedDrawer.cs new file mode 100644 index 0000000000..52c5295b11 --- /dev/null +++ b/Systems/Graphic/PixelationSystem/PixelatedDrawer.cs @@ -0,0 +1,15 @@ +using System; +using CalamityMod.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Systems.Graphic.PixelationSystem +{ + /// + /// Contains a singular Action function which is used to draw any relevant asset(s) automatically with a pixelated effect based on the specified . + /// + public record class PixelatedDrawer(Action DrawAction, GeneralDrawLayer DrawLayer, BlendState DefaultBlendState) + { + + } +} diff --git a/Systems/Graphic/PixelationSystem/PixelationManager.cs b/Systems/Graphic/PixelationSystem/PixelationManager.cs new file mode 100644 index 0000000000..1d06ad6459 --- /dev/null +++ b/Systems/Graphic/PixelationSystem/PixelationManager.cs @@ -0,0 +1,300 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Enums; +using CalamityMod.Graphics; +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.PixelationSystem +{ + public class PixelationManager : ModSystem + { + private static Dictionary PixelTargets_BeforeAllTiles; + private static Dictionary PixelTargets_BeforeSolidTiles; + private static Dictionary PixelTargets_BeforeNPCs; + private static Dictionary PixelTargets_AfterNPCs; + private static Dictionary PixelTargets_BeforeProjectiles; + private static Dictionary PixelTargets_AfterProjectiles; + private static Dictionary PixelTargets_AfterPlayers; + private static Dictionary PixelTargets_AfterDusts; + private static Dictionary PixelTargets_AfterEverything; + + private static List ActivePixelatedDrawers_BeforeAllTiles; + private static List ActivePixelatedDrawers_BeforeSolidTiles; + private static List ActivePixelatedDrawers_BeforeNPCs; + private static List ActivePixelatedDrawers_AfterNPCs; + private static List ActivePixelatedDrawers_BeforeProjectiles; + private static List ActivePixelatedDrawers_AfterProjectiles; + private static List ActivePixelatedDrawers_AfterPlayers; + private static List ActivePixelatedDrawers_AfterDusts; + private static List ActivePixelatedDrawers_AfterEverything; + + /// + /// The resolution ratio at which pixelated drawers should draw.
+ /// 0.5f will draw at half resolution, 0.25f will draw at quarter resolution, etc. + ///
+ internal const float PixelationResolution = 0.5f; + + /// + /// The transformation matrix used by to draw pixelated assets. + /// + internal static Matrix PixelationMatrix + { + get + { + return Main.GameViewMatrix.TransformationMatrix + * Matrix.CreateScale(PixelationResolution / Main.GameViewMatrix.Zoom.X, PixelationResolution / Main.GameViewMatrix.Zoom.Y, 1f) + * Matrix.CreateTranslation(Main.GameViewMatrix.Translation.X * PixelationResolution, Main.GameViewMatrix.Translation.Y * PixelationResolution, 0f); + } + } + + public override void Load() + { + if (Main.dedServ) + return; + + PixelTargets_BeforeAllTiles = []; + PixelTargets_BeforeSolidTiles = []; + PixelTargets_BeforeNPCs = []; + PixelTargets_AfterNPCs = []; + PixelTargets_BeforeProjectiles = []; + PixelTargets_AfterProjectiles = []; + PixelTargets_AfterPlayers = []; + PixelTargets_AfterDusts = []; + PixelTargets_AfterEverything = []; + + ActivePixelatedDrawers_BeforeAllTiles = []; + ActivePixelatedDrawers_BeforeSolidTiles = []; + ActivePixelatedDrawers_BeforeNPCs = []; + ActivePixelatedDrawers_AfterNPCs = []; + ActivePixelatedDrawers_BeforeProjectiles = []; + ActivePixelatedDrawers_AfterProjectiles = []; + ActivePixelatedDrawers_AfterPlayers = []; + ActivePixelatedDrawers_AfterDusts = []; + ActivePixelatedDrawers_AfterEverything = []; + + GeneralDrawLayerSystem.OnDrawLayerLate += DrawPixelatedTargets; + GeneralDrawLayerSystem.OnPrepareDraw += PrepareTargets; + } + + public override void Unload() + { + if (Main.dedServ) + return; + + PixelTargets_BeforeAllTiles = null; + PixelTargets_BeforeSolidTiles = null; + PixelTargets_BeforeNPCs = null; + PixelTargets_AfterNPCs = null; + PixelTargets_BeforeProjectiles = null; + PixelTargets_AfterProjectiles = null; + PixelTargets_AfterPlayers = null; + PixelTargets_AfterDusts = null; + PixelTargets_AfterEverything = null; + + + + ActivePixelatedDrawers_BeforeAllTiles = null; + ActivePixelatedDrawers_BeforeSolidTiles = null; + ActivePixelatedDrawers_BeforeNPCs = null; + ActivePixelatedDrawers_AfterNPCs = null; + ActivePixelatedDrawers_BeforeProjectiles = null; + ActivePixelatedDrawers_AfterProjectiles = null; + ActivePixelatedDrawers_AfterPlayers = null; + ActivePixelatedDrawers_AfterDusts = null; + ActivePixelatedDrawers_AfterEverything = null; + } + + public override void OnWorldUnload() + { + if (Main.dedServ) + return; + + PixelTargets_BeforeAllTiles.Clear(); + PixelTargets_BeforeSolidTiles.Clear(); + PixelTargets_BeforeNPCs.Clear(); + PixelTargets_AfterNPCs.Clear(); + PixelTargets_BeforeProjectiles.Clear(); + PixelTargets_AfterProjectiles.Clear(); + PixelTargets_AfterPlayers.Clear(); + PixelTargets_AfterDusts.Clear(); + PixelTargets_AfterEverything.Clear(); + + ActivePixelatedDrawers_BeforeAllTiles.Clear(); + ActivePixelatedDrawers_BeforeSolidTiles.Clear(); + ActivePixelatedDrawers_BeforeNPCs.Clear(); + ActivePixelatedDrawers_AfterNPCs.Clear(); + ActivePixelatedDrawers_BeforeProjectiles.Clear(); + ActivePixelatedDrawers_AfterProjectiles.Clear(); + ActivePixelatedDrawers_AfterPlayers.Clear(); + ActivePixelatedDrawers_AfterDusts.Clear(); + ActivePixelatedDrawers_AfterEverything.Clear(); + } + + + /// + /// Queues a instance to draw pixelated assets. + /// + /// All relevant drawing code should be written here. + /// The layer at which you'd like these assets to be drawn on.
e.g. will make all drawn assets render behind all projectiles.
+ /// The default that your pixelated assets will be rendered in. + ///
Leave as null to render them using .
+ public static void AddPixelatedDrawer(Action drawAction, GeneralDrawLayer drawLayer, BlendState defaultBlendState = null) + { + if (Main.dedServ || Main.gameMenu) + return; + + BlendState blendState = defaultBlendState ?? BlendState.AlphaBlend; + + // Check if the associated render target for this drawer exists and create it if necessary. + VerifyTargetExistence(drawLayer, blendState); + + PixelatedDrawer drawer = new(drawAction, drawLayer, blendState); + ReturnAssociatedDrawerCollection(drawLayer).Add(drawer); + } + + private static void PrepareTargets() + { + if (!Main.gameMenu && !Main.dedServ) + { + // Draw all collections to their respctive render targets. + DrawCollectionsToTarget(PixelTargets_BeforeAllTiles, PixelationMatrix, ActivePixelatedDrawers_BeforeAllTiles); + DrawCollectionsToTarget(PixelTargets_BeforeSolidTiles, PixelationMatrix, ActivePixelatedDrawers_BeforeSolidTiles); + DrawCollectionsToTarget(PixelTargets_BeforeNPCs, PixelationMatrix, ActivePixelatedDrawers_BeforeNPCs); + DrawCollectionsToTarget(PixelTargets_AfterNPCs, PixelationMatrix, ActivePixelatedDrawers_AfterNPCs); + DrawCollectionsToTarget(PixelTargets_BeforeProjectiles, PixelationMatrix, ActivePixelatedDrawers_BeforeProjectiles); + DrawCollectionsToTarget(PixelTargets_AfterProjectiles, PixelationMatrix, ActivePixelatedDrawers_AfterProjectiles); + DrawCollectionsToTarget(PixelTargets_AfterPlayers, PixelationMatrix, ActivePixelatedDrawers_AfterPlayers); + DrawCollectionsToTarget(PixelTargets_AfterDusts, PixelationMatrix, ActivePixelatedDrawers_AfterDusts); + DrawCollectionsToTarget(PixelTargets_AfterEverything, PixelationMatrix, ActivePixelatedDrawers_AfterEverything); + } + } + + private static void DrawCollectionsToTarget(Dictionary targetCollection, Matrix pixelationMatrix, List drawerCollection) + { + foreach (var blendStateTargetPair in targetCollection) + { + using (blendStateTargetPair.Value.Scope(clearColor: Color.Transparent)) + { + Main.spriteBatch.Begin(default, blendStateTargetPair.Key, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, pixelationMatrix); + + // Select only drawers who match this target's BlendState. + var drawersByBlendState = drawerCollection.Where(d => d.DefaultBlendState == blendStateTargetPair.Key).ToList(); + if (drawersByBlendState.Count > 0) + { + foreach (PixelatedDrawer drawer in drawersByBlendState) + drawer.DrawAction.Invoke(pixelationMatrix); + } + + Main.spriteBatch.End(); + } + } + + drawerCollection.Clear(); + } + + private static void DrawPixelatedTargets(GeneralDrawLayer drawLayer) + { + var targetCollection = ReturnAssociatedTargetCollection(drawLayer); + foreach (var keyValuePair in targetCollection) + { + Main.spriteBatch.Begin(default, keyValuePair.Key, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + float targetScale = 1f / PixelationResolution; + Main.spriteBatch.Draw(keyValuePair.Value.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f); + Main.spriteBatch.End(); + } + } + + private static List ReturnAssociatedDrawerCollection(GeneralDrawLayer drawLayer) + { + List drawerCollection = drawLayer switch + { + GeneralDrawLayer.BeforeAllTiles => ActivePixelatedDrawers_BeforeAllTiles, + GeneralDrawLayer.BeforeSolidTiles => ActivePixelatedDrawers_BeforeSolidTiles, + GeneralDrawLayer.BeforeNPCs => ActivePixelatedDrawers_BeforeNPCs, + GeneralDrawLayer.AfterNPCs => ActivePixelatedDrawers_AfterNPCs, + GeneralDrawLayer.BeforeProjectiles => ActivePixelatedDrawers_BeforeProjectiles, + GeneralDrawLayer.AfterProjectiles => ActivePixelatedDrawers_AfterProjectiles, + GeneralDrawLayer.AfterPlayers => ActivePixelatedDrawers_AfterPlayers, + GeneralDrawLayer.AfterDusts => ActivePixelatedDrawers_AfterDusts, + _ => ActivePixelatedDrawers_AfterEverything, + }; + + return drawerCollection; + } + + private static Dictionary ReturnAssociatedTargetCollection(GeneralDrawLayer drawLayer) + { + Dictionary targetCollection = drawLayer switch + { + GeneralDrawLayer.BeforeAllTiles => PixelTargets_BeforeAllTiles, + GeneralDrawLayer.BeforeSolidTiles => PixelTargets_BeforeSolidTiles, + GeneralDrawLayer.BeforeNPCs => PixelTargets_BeforeNPCs, + GeneralDrawLayer.AfterNPCs => PixelTargets_AfterNPCs, + GeneralDrawLayer.BeforeProjectiles => PixelTargets_BeforeProjectiles, + GeneralDrawLayer.AfterProjectiles => PixelTargets_AfterProjectiles, + GeneralDrawLayer.AfterPlayers => PixelTargets_AfterPlayers, + GeneralDrawLayer.AfterDusts => PixelTargets_AfterDusts, + _ => PixelTargets_AfterEverything, + }; + + return targetCollection; + } + + private static void VerifyTargetExistence(GeneralDrawLayer drawLayer, BlendState blendState) + { + switch (drawLayer) + { + case GeneralDrawLayer.BeforeAllTiles: + if (!PixelTargets_BeforeAllTiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeAllTiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.BeforeSolidTiles: + if (!PixelTargets_BeforeSolidTiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeSolidTiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.BeforeNPCs: + if (!PixelTargets_BeforeNPCs.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeNPCs[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.AfterNPCs: + if (!PixelTargets_AfterNPCs.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterNPCs[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.BeforeProjectiles: + if (!PixelTargets_BeforeProjectiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_BeforeProjectiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.AfterProjectiles: + if (!PixelTargets_AfterProjectiles.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterProjectiles[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.AfterPlayers: + if (!PixelTargets_AfterPlayers.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterPlayers[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.AfterDusts: + if (!PixelTargets_AfterDusts.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterDusts[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + + case GeneralDrawLayer.AfterEverything: + if (!PixelTargets_AfterEverything.ContainsKey(blendState)) + Main.QueueMainThreadAction(() => PixelTargets_AfterEverything[blendState] = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ((int)(w * PixelationResolution), (int)(h * PixelationResolution)))); + break; + } + } + } +} diff --git a/Systems/Graphic/SkyEffectLoaderSystem.cs b/Systems/Graphic/SkyEffectLoaderSystem.cs index 8e8588063f..9d1a30bd40 100644 --- a/Systems/Graphic/SkyEffectLoaderSystem.cs +++ b/Systems/Graphic/SkyEffectLoaderSystem.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.CalClone; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.NPCs.Signus; @@ -23,10 +17,10 @@ namespace CalamityMod.Systems { public override void Load() { - Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh); + Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseOpacity(0.025f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:DevourerofGodsHead"] = new DoGSky(); - Filters.Scene["CalamityMod:CalamitasRun3"] = new Filter(new CalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.6f), EffectPriority.VeryHigh); + Filters.Scene["CalamityMod:CalamitasRun3"] = new Filter(new CalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.2f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:CalamitasRun3"] = new CalSky(); Filters.Scene["CalamityMod:PlaguebringerGoliath"] = new Filter(new PbGScreenShaderData("FilterMiniTower").UseColor(0.2f, 0.6f, 0.2f).UseOpacity(0.35f), EffectPriority.VeryHigh); diff --git a/Systems/Graphic/TempParticleSystem/TempParticle.cs b/Systems/Graphic/TempParticleSystem/TempParticle.cs new file mode 100644 index 0000000000..c73b3f8027 --- /dev/null +++ b/Systems/Graphic/TempParticleSystem/TempParticle.cs @@ -0,0 +1,71 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; + +namespace CalamityMod.Systems.Graphic.TempParticleSystem +{ + public class TempParticle + { + public Asset StoredTexture; + + public Vector2 Position; + + public Vector2 StoredPosition; + + public Vector2 Velocity; + + public Vector2 Scale; + + public Color DrawColor; + + public float Rotation; + + public float Opacity; + + public float ParallaxStrength; + + public int Lifetime; + + public int Time; + + public int FrameX; + + public int FrameY; + + public int MaxVerticalFrames; + + public int MaxHorizontalFrames; + + public float[] ExtraData; + + /// + /// An 0-1 interpolant representing how close this particle is from its . + /// + public float LifetimeCompletionRatio => MathHelper.Clamp(Time / (float)Lifetime, 0f, 1f); + + public void SetBasicParticleData(Asset storedTexture, Vector2 position, Vector2 storedPosition, Vector2 velocity, Vector2 scale, Color drawColor, float rotation, float opacity, float parallaxStrength, int lifetime, int frameX, int frameY, int maxHorizontalFrames, int maxVerticalFrames, float extraData0, float extraData1, float extraData2, float extraData3) + { + Time = 0; + ExtraData = new float[4]; + + StoredTexture = storedTexture; + Position = position; + StoredPosition = storedPosition; + Velocity = velocity; + Scale = scale; + DrawColor = drawColor; + Rotation = rotation; + Opacity = opacity; + ParallaxStrength = parallaxStrength; + Lifetime = lifetime; + FrameX = frameX; + FrameY = frameY; + MaxHorizontalFrames = maxHorizontalFrames; + MaxVerticalFrames = maxVerticalFrames; + ExtraData[0] = extraData0; + ExtraData[1] = extraData1; + ExtraData[2] = extraData2; + ExtraData[3] = extraData3; + } + } +} diff --git a/Systems/Graphic/TempParticleSystem/TempParticleManager.cs b/Systems/Graphic/TempParticleSystem/TempParticleManager.cs new file mode 100644 index 0000000000..495226760d --- /dev/null +++ b/Systems/Graphic/TempParticleSystem/TempParticleManager.cs @@ -0,0 +1,181 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Threading; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Graphic.TempParticleSystem +{ + public class TempParticleManager + { + public delegate void ParticleUpdateFunctionDelegate(TempParticle tempParticle); + + public delegate void ParticleDrawFunctionDelegate(TempParticle tempParticle, SpriteBatch spriteBatch, Vector2 drawOffset); + + public readonly List ActiveParticles; + + public readonly int MaxParticles; + + public readonly Asset BaseParticleTexture; + + public readonly ParticleUpdateFunctionDelegate ParticleUpdateFunction; + + public readonly ParticleDrawFunctionDelegate ParticleDrawingOverride; + + private readonly Queue ParticlePool; + + /// + /// A temporary particle handler made for the typically short-term creation and manipulation of particle effects done by instances of a generic particle object . + ///
Should typically be used in areas where is less practical or cannot work at all.
+ ///
+ /// The maximum amount of particles that can exist at a time in this manager. + /// The base texture that particles spawned by this manager will use when drawn. + /// An additional update function to control how particles spawned by this manager are updated. + /// Set this parameter to override how particles spawned by this manager are drawn. + public TempParticleManager(int maxParticles, string baseParticleTexturePath, ParticleUpdateFunctionDelegate particleUpdateFunction = null, ParticleDrawFunctionDelegate particleDrawingOverride = null) + { + if (Main.dedServ) + return; + + MaxParticles = maxParticles; + BaseParticleTexture = ModContent.Request(baseParticleTexturePath); + ParticleUpdateFunction = particleUpdateFunction; + ParticleDrawingOverride = particleDrawingOverride; + + ActiveParticles = []; + if (ParticlePool is null) + { + ParticlePool = []; + for (int i = 0; i < maxParticles; i++) + ParticlePool.Enqueue(new TempParticle()); + } + } + + /// + /// Spawns a instance attached to a . + ///
The "extraData" parameters exist so that you can store any additional data for this manager's particles in up to four additional slots.
+ ///
+ /// The initial spawn position of this particle. + /// The initial velocity of this particle. + /// The initial scale of this particle. + /// The base color this particle is drawn in. + /// The maximum amount of time this particle can be alive for. + /// The initial rotation of this particle. + /// The initial opacity of this particle. + /// The depth at which this particle appears. Should only be used in cases where particles need to be drawn in the foreground or background. + /// The initial X-frame of this particle on its spritesheet. + /// The initial Y-frame of this particle on its spritesheet. + /// The maximum amount of horizontal frames this particle has on its spritesheet. + /// The maximum amount of horizontal frames this particle has on its spritesheet. + /// An optional position which can be stored for this particle to attach to. + public void SpawnParticle(Vector2 position, Vector2 velocity, Vector2 scale, Color drawColor, int lifetime, float rotation = 0f, float opacity = 1f, float parallaxStrength = 0f, int frameX = 0, int frameY = 0, int maxHorizontalFrames = 1, int maxVerticalFrames = 1, float extraData0 = 0f, float extraData1 = 0f, float extraData2 = 0f, float extraData3 = 0f, Vector2? storedPosition = null) + { + if (ActiveParticles.Count >= MaxParticles || ActiveParticles.Count >= CalamityClientConfig.Instance.ParticleLimit || Main.dedServ) + return; + + if (ParticlePool.Count > 0) + { + TempParticle pooledParticle = ParticlePool.Dequeue(); + pooledParticle.SetBasicParticleData(BaseParticleTexture, position, storedPosition ?? Vector2.Zero, velocity, scale, drawColor, rotation, opacity, parallaxStrength, lifetime, frameX, frameY, maxHorizontalFrames, maxVerticalFrames, extraData0, extraData1, extraData2, extraData3); + ActiveParticles.Add(pooledParticle); + } + } + + /// + /// Spawns a instance attached to a . + ///
The "extraData" parameters exist so that you can store any additional data for this manager's particles in up to four additional slots.
+ ///
+ /// The initial spawn position of this particle. + /// The initial velocity of this particle. + /// The initial scale of this particle. + /// The base color this particle is drawn in. + /// The maximum amount of time this particle can be alive for. + /// The initial rotation of this particle. + /// The initial opacity of this particle. + /// The depth at which this particle appears. Should only be used in cases where particles need to be drawn in the foreground or background. + /// The initial X-frame of this particle on its spritesheet. + /// The initial Y-frame of this particle on its spritesheet. + /// The maximum amount of horizontal frames this particle has on its spritesheet. + /// The maximum amount of horizontal frames this particle has on its spritesheet. + /// An optional position which can be stored for this particle to attach to. + public void SpawnParticle(Vector2 position, Vector2 velocity, float scale, Color drawColor, int lifetime, float rotation = 0f, float opacity = 1f, float parallaxStrength = 0f, int frameX = 0, int frameY = 0, int maxHorizontalFrames = 1, int maxVerticalFrames = 1, float extraData0 = 0f, float extraData1 = 0f, float extraData2 = 0f, float extraData3 = 0f, Vector2? storedPosition = null) + => SpawnParticle(position, velocity, new Vector2(scale), drawColor, lifetime, rotation, opacity, parallaxStrength, frameX, frameY, maxHorizontalFrames, maxVerticalFrames, extraData0, extraData1, extraData2, extraData3, storedPosition); + + /// + /// Updates all active particles attached to this . + /// + public void Update() + { + if (ActiveParticles.Count == 0) + return; + + FastParallel.For(0, ActiveParticles.Count, (start, end, context) => + { + for (int i = start; i < end; i++) + { + ActiveParticles[i].Time++; + ActiveParticles[i].Position += ActiveParticles[i].Velocity; + ParticleUpdateFunction.Invoke(ActiveParticles[i]); + } + }); + + // Return the particle to the pool upon death. + ActiveParticles.RemoveAll(p => + { + if (p.Time >= p.Lifetime) + { + ParticlePool.Enqueue(p); + return true; + } + return false; + }); + } + + /// + /// Draws all active particles attached to this . + /// + /// + /// Note you will need to start the spritebatch manually before calling this. + /// + public void DrawAllParticles(SpriteBatch spriteBatch, Vector2? baseOffset = null) + { + if (ActiveParticles.Count == 0) + return; + + Vector2 drawOffset = baseOffset ?? -Main.screenPosition; + if (ParticleDrawingOverride != null) + { + foreach (TempParticle tempParticle in ActiveParticles) + ParticleDrawingOverride.Invoke(tempParticle, spriteBatch, drawOffset); + } + else + { + foreach (TempParticle tempParticle in ActiveParticles) + { + Vector2 drawPosition = tempParticle.Position + drawOffset + tempParticle.StoredPosition; + Rectangle frame = BaseParticleTexture.Frame(tempParticle.MaxHorizontalFrames, tempParticle.MaxVerticalFrames, tempParticle.FrameX, tempParticle.FrameY); + Vector2 origin = frame.Size() * 0.5f; + + spriteBatch.Draw(BaseParticleTexture.Value, drawPosition, frame, tempParticle.DrawColor * tempParticle.Opacity, tempParticle.Rotation, origin, tempParticle.Scale, SpriteEffects.None, 0f); + } + } + } + + /// + /// Returns all active particles back to the particle pool. + /// + public void ReturnAll() + { + if (ActiveParticles.Count == 0) + return; + + ActiveParticles.RemoveAll(p => + { + ParticlePool.Enqueue(p); + return true; + }); + } + } +} diff --git a/Systems/Mechanic/ArenaWallSystem.cs b/Systems/Mechanic/ArenaWallSystem.cs new file mode 100644 index 0000000000..b035b16c39 --- /dev/null +++ b/Systems/Mechanic/ArenaWallSystem.cs @@ -0,0 +1,311 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Mechanic +{ + public class ArenaWallSystem : ModSystem + { + public static List ActiveBoxes = []; + public class Box + { + + public Func RemovalCondition = () => false; + + public Vector2 position; + + public Vector4 boxDimensions; + + public Vector4 NewDimensions; + + public Vector2 NewPosition; + + public float borderThickness; + + public Color borderColor = Color.Red; + public float DistanceUp => boxDimensions.X; + public float DistanceRight => boxDimensions.Y; + public float DistanceDown => boxDimensions.Z; + public float DistanceLeft => boxDimensions.W; + + public Vector2 TopLeft => position + new Vector2(-DistanceLeft, -DistanceUp); + public Vector2 TopRight => position + new Vector2(DistanceRight, -DistanceUp); + public Vector2 BottomLeft => position + new Vector2(-DistanceLeft, DistanceDown); + public Vector2 BottomRight => position + new Vector2(DistanceRight, DistanceDown); + + public Vector2 Center => (TopLeft + BottomRight) * 0.5f; + + public Vector2 Size => new Vector2(DistanceLeft + DistanceRight, DistanceUp + DistanceDown); + + public Vector4 Hitbox => new Vector4(TopLeft.X, TopLeft.Y, Size.X, Size.Y); + public Rectangle HitboxRectangle => new Rectangle((int)TopLeft.X, (int)TopLeft.Y, (int)Size.X, (int)Size.Y); + + public Box oldData = null; + + public Action DrawBox = null; + + public Action UpdateBox = null; + /// + /// The despawn logic to kill this box. Only runs when RemovalCondition is true. Return true to delete the box from ActiveBoxes. + /// + public Func DespawnAction = (box) => true; + + public bool PullPlayerWhenSizeChanged => false; + public void DrawBoxWithOffset(float Offset, float Thickness, Color color) + { + + CalamityUtils.DrawLineBetter(Main.spriteBatch, TopLeft + new Vector2(-(Offset + Thickness * 0.5f), -Offset), TopRight + new Vector2((Offset + Thickness * 0.5f), -Offset), color, Thickness); + CalamityUtils.DrawLineBetter(Main.spriteBatch, BottomLeft + new Vector2(-(Offset + Thickness * 0.5f), Offset), BottomRight + new Vector2((Offset + Thickness * 0.5f), Offset), color, Thickness); + CalamityUtils.DrawLineBetter(Main.spriteBatch, TopLeft + new Vector2(-Offset, -(Offset - Thickness * 0.5f)), BottomLeft + new Vector2(-Offset, (Offset - Thickness * 0.5f)), color, Thickness); + CalamityUtils.DrawLineBetter(Main.spriteBatch, BottomRight + new Vector2(Offset, (Offset - Thickness * 0.5f)), TopRight + new Vector2(Offset, -(Offset - Thickness * 0.5f)), color, Thickness); + } + + public void SetOldData() + { + if (oldData == null) + oldData = new Box() { borderColor = borderColor, borderThickness = borderThickness, boxDimensions = boxDimensions, position = position }; + else + { + oldData.borderThickness = borderThickness; + oldData.boxDimensions = boxDimensions; + oldData.position = position; + } + } + public bool Contains(Vector2 Position, Vector2 size) + { + return Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness * 0.5f), Size + new Vector2(borderThickness), Position, size); + } + + public bool ShouldEffectPlayer(Player player) => Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness + 300), Size + new Vector2(borderThickness + 300) * 2, player.TopLeft, player.Size); + public bool InnerEffect(Vector2 Position, Vector2 size) => Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness) * 0.5f, Size + new Vector2(borderThickness), Position, size); + + public bool PointInWall(Vector2 pos) + { + static bool Vector2PointCollision(Vector2 position, Vector2 size, Vector2 point) + { + return (point.X >= position.X && point.X <= position.X + size.X && point.Y >= position.Y && point.Y <= position.Y + size.Y); + } + return !Vector2PointCollision(TopLeft, Size, pos) && Vector2PointCollision(TopLeft - new Vector2(borderThickness), Size + new Vector2(borderThickness) * 2, pos); + } + + public bool Vector2PairInWall(Vector2 pos, Vector2 size) + { + return Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness), new Vector2(size.X + borderThickness * 2, borderThickness), pos, size) + || Collision.CheckAABBvAABBCollision(TopRight + new Vector2(0, -borderThickness), new Vector2(borderThickness, size.Y + borderThickness * 2), pos, size) + || Collision.CheckAABBvAABBCollision(BottomLeft + new Vector2(-borderThickness, 0), new Vector2(size.X + borderThickness * 2, borderThickness), pos, size) + || Collision.CheckAABBvAABBCollision(TopLeft - new Vector2(borderThickness), new Vector2(borderThickness, size.Y + borderThickness * 2), pos, size); + } + } + public override void PostDrawTiles() + { + + + Main.spriteBatch.Begin( + SpriteSortMode.Deferred, + BlendState.AlphaBlend, + SamplerState.PointClamp, + DepthStencilState.None, + RasterizerState.CullNone, + null, + Main.Transform + ); + foreach (var box in ActiveBoxes) + { + if (box.DrawBox is not null) + box.DrawBox(box); + else + { + var color = Color.Black * 0.75f; + //Inside Fill + box.DrawBoxWithOffset(box.borderThickness * 0.5f, box.borderThickness, Color.Black * 0.75f); + //Inner Border + box.DrawBoxWithOffset(4, 8, box.borderColor); + //Outer Border + box.DrawBoxWithOffset(box.borderThickness - 4, 4, box.borderColor); + } + } + Main.spriteBatch.End(); + } + + public override void PreUpdateEntities() + { + for (var i = 0; i < ActiveBoxes.Count; i++) + { + var box = ActiveBoxes[i]; + if (box.RemovalCondition()) + { + if (box.DespawnAction(box)) + { + ActiveBoxes.Remove(box); + i--; + } + + continue; + } + + box.SetOldData(); + if (box.NewDimensions != Vector4.Zero) + { + box.boxDimensions = box.NewDimensions; + } + if (box.NewPosition != Vector2.Zero) + { + box.position = box.NewPosition; + } + if (box.UpdateBox != null) + box.UpdateBox(box); + } + } + + public override void OnWorldUnload() + { + ActiveBoxes = []; + } + } + + public class ArenaWallPlayer : ModPlayer + { + public Vector2 touchingSides = new Vector2(); + public override void PreUpdateMovement() + { + + + foreach (var box in ArenaWallSystem.ActiveBoxes) + { + if (box.ShouldEffectPlayer(Player)) + { + if (box.Contains(Player.position, Player.Size)) + ContainPlayerLogic(box); + } + } + } + + void ContainPlayerLogic(ArenaWallSystem.Box box) + { + if (box.oldData is not null && box.PullPlayerWhenSizeChanged) + { + if (touchingSides.X > 0) + { + Player.position.Y += ((box.oldData.TopLeft.Y - box.oldData.BottomRight.Y) - (box.TopLeft.Y - box.BottomRight.Y)) * touchingSides.X; + } + + if (touchingSides.Y > 0) + { + Player.position.X += ((box.oldData.TopLeft.X - box.oldData.BottomRight.X) - (box.TopLeft.X - box.BottomRight.X)) * touchingSides.Y; + } + } + + touchingSides = Vector2.Zero; + #region Snapping + if (Player.Left.X < box.TopLeft.X) + { + Player.position.X = box.TopLeft.X; + touchingSides.X = Utils.Remap(Player.Center.Y, box.TopLeft.Y, box.BottomRight.Y, 0, 1, true); + touchingSides.Y = Utils.Remap(Player.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, true); + } + if (Player.Right.X > box.BottomRight.X) + { + Player.position.X = box.BottomRight.X - Player.width; + touchingSides.X = Utils.Remap(Player.Center.Y, box.TopLeft.Y, box.BottomRight.Y, 0, 1, true); + touchingSides.Y = Utils.Remap(Player.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, true); + } + if (Player.TopLeft.Y < box.TopLeft.Y) + { + Player.position.Y = box.TopLeft.Y; + touchingSides.X = Utils.Remap(Player.Center.Y, box.TopLeft.Y, box.BottomRight.Y, 0, 1, true); + touchingSides.Y = Utils.Remap(Player.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, true); + } + if (Player.BottomRight.Y > box.BottomRight.Y) + { + Player.position.Y = box.BottomRight.Y - Player.height; + touchingSides.X = Utils.Remap(Player.Center.Y, box.TopLeft.Y, box.BottomRight.Y, 0, 1, true); + touchingSides.Y = Utils.Remap(Player.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, true); + } + #endregion + void spawnShoeDust() + { + + int num4 = Dust.NewDust(new Vector2(Player.position.X + (float)(Player.width / 2) + (float)((Player.width / 2 - 4) * Player.slideDir), Player.position.Y + (float)(Player.height / 2) + (float)(Player.height / 2 - 4) * Player.gravDir), 8, 8, DustID.Smoke); + if (Player.slideDir < 0) + { + Main.dust[num4].position.X -= 10f; + } + if (Player.gravDir < 0f) + { + Main.dust[num4].position.Y -= 12f; + } + Main.dust[num4].velocity *= 0.1f; + Main.dust[num4].scale *= 1.2f; + Main.dust[num4].noGravity = true; + Main.dust[num4].shader = GameShaders.Armor.GetSecondaryShader(Player.cShoe, Player); + } + void applyShoeSpikes() + { + if (Player.spikedBoots == 0 || Player.velocity.Y < 0 || Player.mount.Active) + return; + if (Player.controlDown && Player.spikedBoots > 0) + { + Player.velocity.Y = 4f * Player.gravDir; + spawnShoeDust(); + } + else if (Player.spikedBoots <= 2) + { + Player.velocity.Y = 0; + } + else if (Player.spikedBoots == 1) + { + + Player.velocity.Y = 0.5f * Player.gravDir; + spawnShoeDust(); + } + } + #region Velocity + + var originalVelocity = Player.velocity; + var originalTopLeft = Player.TopLeft; + var originalBottomRight = Player.BottomRight; + Player.position += originalVelocity; + + if (Player.Left.X < box.TopLeft.X) + { + Player.velocity.X = box.TopLeft.X - originalTopLeft.X; + if (Player.controlLeft) + { + Player.slideDir = -1; + applyShoeSpikes(); + } + } + if (Player.Right.X > box.BottomRight.X) + { + Player.velocity.X = box.BottomRight.X - originalBottomRight.X; + Dust.NewDustPerfect(Player.Right, DustID.Smoke); + if (Player.controlRight) + { + Player.slideDir = 1; + applyShoeSpikes(); + } + } + if (Player.TopLeft.Y < box.TopLeft.Y) + { + + Player.velocity.Y = box.TopLeft.Y - originalTopLeft.Y; + if (Player.velocity.Y == 0) + Player.velocity.Y += 0.001f; + touchingSides.Y = Utils.Remap(Player.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, true); + } + + if (Player.BottomRight.Y > box.BottomRight.Y) + { + Player.velocity.Y = box.BottomRight.Y - originalBottomRight.Y; + touchingSides.Y = Utils.Remap(Player.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, true); + } + Player.position -= originalVelocity; + #endregion + } + } +} diff --git a/Systems/Mechanic/AttunementSystem.cs b/Systems/Mechanic/AttunementSystem.cs index 707a654630..442164d50f 100644 --- a/Systems/Mechanic/AttunementSystem.cs +++ b/Systems/Mechanic/AttunementSystem.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.DataStructures; +using CalamityMod.DataStructures; using Terraria.ModLoader; namespace CalamityMod.Systems diff --git a/Systems/Mechanic/DifficultyModeSystem.cs b/Systems/Mechanic/DifficultyModeSystem.cs index afbfc41794..d00e349753 100644 --- a/Systems/Mechanic/DifficultyModeSystem.cs +++ b/Systems/Mechanic/DifficultyModeSystem.cs @@ -1,15 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using CalamityMod.CalPlayer; -using CalamityMod.Events; +using System.Reflection; using CalamityMod.Items.Armor.Demonshade; +using CalamityMod.UI.ModeIndicator; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.GameContent.Creative; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -21,25 +22,130 @@ namespace CalamityMod.Systems public class DifficultyModeSystem : ModSystem { internal static bool _hasCheckedItOutYet = false; //Simple variable to add a cool effect to the mode selector + internal static int _newGameModeID = GameModeID.Normal; public static List Difficulties = new List(); //Difficulty modes ordered by ascending difficulty public static List DifficultyTiers; //Difficulty modes grouped together by difficulty public static int MostAlternateDifficulties; //The most alternate difficulties at any tier that exists. Used to know the widest space to take in the ui - public override void Load() + public static MethodInfo journeyDifficultyUpdateMethod; // The method which updates difficulty modes in journey mode + + public override void OnModLoad() { MostAlternateDifficulties = 1; //Initialize base mod difficulties - Difficulties = new List() { new NoDifficulty(), new RevengeanceDifficulty(), new DeathDifficulty() }; + Difficulties = new List() { ModContent.GetInstance(), + ModContent.GetInstance(),ModContent.GetInstance(), + ModContent.GetInstance(), ModContent.GetInstance(), + ModContent.GetInstance(), ModContent.GetInstance() }; + + journeyDifficultyUpdateMethod = typeof(CreativePowers.DifficultySliderPower).GetMethod("UpdateInfoFromSliderValueCache", BindingFlags.Instance | BindingFlags.NonPublic); CalculateDifficultyData(); } - public override void Unload() + public override void PostWorldLoad() + { + CalculateDifficultyData(); //Reload difficulties upon loading a world to adjust for FTW. + } + public override void OnModUnload() { Difficulties = null; } + // Makes the world automatically convert to Death if in Master, or out of Death if in Expert + public override void PostUpdateWorld() + { + static void HandleExternalGameModeChange(int tier) + { + switch (tier) + { + case GameModeID.Normal: + { + if (Main.getGoodWorld) + { + // if death was activated, change it to revengence + if (GetCurrentDifficulty.CountAs()) + { + ModeIndicatorUI.SwitchToDifficulty(ModContent.GetInstance(), broadcast: true); + } + break; + } + + // vanilla game mode in classic, but cal difficulty >= expert + if (GetCurrentDifficulty.CountAs() || GetCurrentDifficulty.CountAs()) + { + ModeIndicatorUI.SwitchToDifficulty(ModContent.GetInstance(), broadcast: true); + } + break; + } + case GameModeID.Expert: + { + if (Main.getGoodWorld) + { + if (GetCurrentDifficulty.CountAs()) + { + ModeIndicatorUI.SwitchToDifficulty(ModContent.GetInstance(), broadcast: true); + } + break; + } + + // if death was activated, change it to revengence + if (GetCurrentDifficulty.CountAs()) + { + ModeIndicatorUI.SwitchToDifficulty(ModContent.GetInstance(), broadcast: true); + } + break; + } + case GameModeID.Master: + { + if (Main.getGoodWorld) + { + if (!GetCurrentDifficulty.CountAs() && CalamityWorld.revenge) + { + ModeIndicatorUI.SwitchToDifficulty(ModContent.GetInstance(), broadcast: true); + } + break; + } + // if revengence and master both activated, change it to death + if (!GetCurrentDifficulty.CountAs() && CalamityWorld.revenge) + { + ModeIndicatorUI.SwitchToDifficulty(ModContent.GetInstance(), broadcast: true); + } + break; + } + } + } + + if (Main.GameMode == GameModeID.Creative) + { + CreativePowers.DifficultySliderPower power = CreativePowerManager.Instance.GetPower(); + if (power.GetIsUnlocked()) + { + int effectiveVanillaDifficulty; + var sliderValue = power._sliderCurrentValueCache; + if (sliderValue == 1) + { + effectiveVanillaDifficulty = GameModeID.Master; + } + else if (sliderValue >= 0.66f) + { + effectiveVanillaDifficulty = GameModeID.Expert; + } + else + { + effectiveVanillaDifficulty = GameModeID.Normal; + } + HandleExternalGameModeChange(effectiveVanillaDifficulty); + } + } + else + { + HandleExternalGameModeChange(Main.GameMode); + } + } + + public static DifficultyMode GetCurrentDifficulty { get @@ -68,6 +174,10 @@ namespace CalamityMod.Systems for (int i = 0; i < Difficulties.Count; i++) { + //Only add difficulties that are allowed in the current world type; + if ((Main.getGoodWorld && Difficulties[i].GetForTheWorthyDisplay == DifficultyMode.FTWDisplayMode.NotForTheWorthy) + || (!Main.getGoodWorld && Difficulties[i].GetForTheWorthyDisplay == DifficultyMode.FTWDisplayMode.OnlyForTheWorthy)) + continue; //if we are at a new tier, create a new list of difficulties at that tier. if (currentTier != Difficulties[i].DifficultyScale) { @@ -87,6 +197,45 @@ namespace CalamityMod.Systems Difficulties[i]._difficultyTier = tierIndex; } } + private static readonly Dictionary compatitableValueRanges = new() + { + { GameModeID.Normal, (0.33f, 0.66f ) }, + { GameModeID.Expert, (0.66f, 1f) }, + { GameModeID.Master, (1f, 1f) } + }; + + public static void AlignJourneyDifficultySlider() + { + if (Main.GameMode != GameModeID.Creative) + { + // I have to throw an unhandled exception here to make you alerted to bugs while developing + // If this is tested and working, turn it into a silent warning before release + throw new ArgumentException("DifficultyModeSystemAlignJourneyDifficultySlider(): must be invoked in journey mode"); + } + CreativePowers.DifficultySliderPower power = CreativePowerManager.Instance.GetPower(); + var oldValue = power._sliderCurrentValueCache; + if (compatitableValueRanges.TryGetValue(_newGameModeID, out var value)) + { + var (low, high) = value; + float valueToSet; + if (oldValue >= low && oldValue < high) + { + valueToSet = oldValue; + } + else + { + valueToSet = low; + } + power._sliderCurrentValueCache = valueToSet; + journeyDifficultyUpdateMethod.Invoke(power, null); + } + else + { + // I have to throw an unhandled exception here to make you alerted to bugs while developing + // If this is tested and working, turn it into a silent warning before release + throw new ArgumentException("DifficultyModeSystemAlignJourneyDifficultySlider(): _newGameModeID must be in GameModeID.Normal, Expert, Master"); + } + } public override void SaveWorldData(TagCompound tag) { @@ -119,35 +268,66 @@ namespace CalamityMod.Systems } } - public abstract class DifficultyMode + public abstract class DifficultyMode : ModType { + public enum FTWDisplayMode + { + Always, + OnlyForTheWorthy, + NotForTheWorthy, + } + protected sealed override void Register() + { + ModTypeLookup.Register(this); + // This is registered in DifficultyModeSystem.OnModLoad + // Note that DifficultyModeSystem.Load can't ensure system is loaded after all modes + } + public abstract bool Enabled { get; set; } + protected Asset _texture; public abstract Asset Texture { get; } + protected Asset _textureDisabled; + public abstract Asset TextureDisabled { get; } + + protected Asset _outlineTexture; + public abstract Asset OutlineTexture { get; } + public virtual FTWDisplayMode GetForTheWorthyDisplay { get; } = FTWDisplayMode.Always; + + protected SoundStyle? _activationSound; + public abstract SoundStyle ActivationSound { get; } + public abstract int BackBoneGameModeID { get; } + internal int _difficultyTier; + public abstract float DifficultyScale { get; } + + public new abstract LocalizedText Name { get; } + public abstract Color ChatTextColor { get; } + public abstract LocalizedText ShortDescription { get; } public virtual LocalizedText ExpandedDescription => LocalizedText.Empty; - public float DifficultyScale; - public LocalizedText Name; - public LocalizedText ShortDescription; + public virtual LocalizedText FTWName { get; } = null; + public virtual Color? FTWTextColor { get; } = null; - public string ActivationTextKey; - public string DeactivationTextKey; - - public SoundStyle ActivationSound; - - public Color ChatTextColor; - - internal int _difficultyTier; /// /// Used to know which difficulties to toggle on when selecting a particular difficulty. /// public virtual bool RequiresDifficulty(DifficultyMode mode) => false; - public virtual int FavoredDifficultyAtTier(int tier) => 0; + public virtual int[] FavoredDifficultyAtTier(int tier) => [0]; + + public virtual bool IsBasedOn(DifficultyMode mode) => false; + + public bool CountAs() where Difficulty : DifficultyMode => CountAs(ModContent.GetInstance()); + public bool CountAs(DifficultyMode mode) + { + if (mode == this) return true; + if (IsBasedOn(mode)) return true; + return false; + } } public class NoDifficulty : DifficultyMode @@ -155,34 +335,153 @@ namespace CalamityMod.Systems public override bool Enabled { get => true; - set { } - } - - private Asset _texture; - public override Asset Texture - { - get + set { - if (_texture == null) - _texture = ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_None"); - - return _texture; + if (!Main.GameModeInfo.IsJourneyMode) + { + Main.GameMode = value == true ? GameModeID.Normal : GameModeID.Expert; + } + else + { + DifficultyModeSystem.AlignJourneyDifficultySlider(); + } } } - public NoDifficulty() + public override Asset Texture => _texture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Classic"); + + public override Asset OutlineTexture => _outlineTexture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Classic_Border"); + + public override Asset TextureDisabled => _textureDisabled ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Classic_Off"); + + public override SoundStyle ActivationSound => _activationSound ??= SoundID.MenuTick with { Volume = 1f }; + + public override int BackBoneGameModeID => GameModeID.Normal; + + public override float DifficultyScale => 0; + + public override LocalizedText Name => Language.GetText("UI.Normal"); + + public override Color ChatTextColor => Color.White; + + public override LocalizedText ShortDescription => GetText("UI.ClassicInfo"); + public override FTWDisplayMode GetForTheWorthyDisplay => FTWDisplayMode.NotForTheWorthy; + } + + public class ExpertDifficulty : DifficultyMode + { + public override bool Enabled { - DifficultyScale = 0; - Name = CalamityUtils.GetText("UI.NoDifficulty"); - ShortDescription = CalamityUtils.GetText("UI.NoDifficultyInfo"); - - ActivationTextKey = string.Empty; - DeactivationTextKey = string.Empty; - - ActivationSound = SoundID.MenuTick with { Volume = 1f }; - - ChatTextColor = Color.White; + get => Main.expertMode; + set + { + if (!Main.GameModeInfo.IsJourneyMode) + { + Main.GameMode = value == true ? GameModeID.Expert : GameModeID.Normal; + } + else + { + DifficultyModeSystem.AlignJourneyDifficultySlider(); + } + } } + + public override Asset Texture => _texture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Expert"); + public override Asset OutlineTexture => _outlineTexture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Expert_Border"); + + public override Asset TextureDisabled => _textureDisabled ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Expert_Off"); + + public override SoundStyle ActivationSound => _activationSound ??= SoundID.ForceRoarPitched; + + public override int BackBoneGameModeID => Main.getGoodWorld ? GameModeID.Normal : GameModeID.Expert; + + public override float DifficultyScale => 0.1f; + + public override LocalizedText Name => Language.GetText("UI.Expert"); + public override Color ChatTextColor => Main.mcColor; + + public override LocalizedText ShortDescription => GetText("UI.ExpertShortInfo"); + + public override LocalizedText ExpandedDescription => GetText("UI.ExpertExpandedInfo"); + } + + public class MasterDifficulty : DifficultyMode + { + public override bool Enabled + { + get => Main.masterMode; + set + { + if (!Main.GameModeInfo.IsJourneyMode) + { + Main.GameMode = value == true ? GameModeID.Master : GameModeID.Expert; + } + else + { + DifficultyModeSystem.AlignJourneyDifficultySlider(); + } + } + } + + public override Asset Texture => _texture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Master"); + public override Asset OutlineTexture => _outlineTexture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Master_Border"); + + public override Asset TextureDisabled => _textureDisabled ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Master_Off"); + + public override SoundStyle ActivationSound => _activationSound ??= SoundID.NPCDeath10; + + public override int BackBoneGameModeID => Main.getGoodWorld ? GameModeID.Expert : GameModeID.Master; + + public override float DifficultyScale => 0.25f; + + public override LocalizedText Name => Language.GetText("UI.Master"); + + public override Color ChatTextColor => Main.hcColor; + + public override LocalizedText ShortDescription => GetText("UI.MasterShortInfo"); + + public override LocalizedText ExpandedDescription => GetText("UI.MasterExpandedInfo"); + + } + + public class LegendaryDifficulty : DifficultyMode + { + public override bool Enabled + { + get => CalamityWorld.LegendaryMode; + set + { + if (!Main.GameModeInfo.IsJourneyMode) + { + Main.GameMode = value == true ? GameModeID.Master : GameModeID.Expert; + } + else + { + DifficultyModeSystem.AlignJourneyDifficultySlider(); + } + } + } + + public override Asset Texture => _texture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Legendary"); + public override Asset OutlineTexture => _outlineTexture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Legendary_Border"); + + public override Asset TextureDisabled => _textureDisabled ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Legendary_Off"); + + public override SoundStyle ActivationSound => _activationSound ??= new("CalamityMod/Sounds/Custom/DifficultySelection/Legendary_Mode_Select"); + + public override int BackBoneGameModeID => GameModeID.Master; + + public override float DifficultyScale => 0.5f; + + public override LocalizedText Name => Language.GetText("UI.Legendary"); + + public override Color ChatTextColor => Main.legendaryModeColor; + + public override LocalizedText ShortDescription => GetText("UI.LegendaryShortInfo"); + + public override LocalizedText ExpandedDescription => GetText("UI.LegendaryExpandedInfo"); + public override FTWDisplayMode GetForTheWorthyDisplay => FTWDisplayMode.OnlyForTheWorthy; + } public class RevengeanceDifficulty : DifficultyMode @@ -190,44 +489,40 @@ namespace CalamityMod.Systems public override bool Enabled { get => CalamityWorld.revenge; - set => CalamityWorld.revenge = value; - } - - private Asset _texture; - public override Asset Texture - { - get + set { - if (_texture == null) - _texture = ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Rev"); - - return _texture; + CalamityWorld.revenge = value; + if (value && !Main.GameModeInfo.IsJourneyMode) + Main.GameMode = BackBoneGameModeID; } } + public override Asset Texture => _texture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Rev"); + public override Asset OutlineTexture => _outlineTexture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Rev_Border"); + + public override Asset TextureDisabled => _textureDisabled ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Rev_Off"); + + public override SoundStyle ActivationSound => _activationSound ??= new("CalamityMod/Sounds/Custom/DifficultySelection/Revengeance_Mode_Select"); + + public override int BackBoneGameModeID => Main.getGoodWorld ? GameModeID.Normal : GameModeID.Expert; + + public override float DifficultyScale => 0.1f; + + public override LocalizedText Name => GetText("UI.Revengeance"); + + public override Color ChatTextColor => new Color(211, 42, 42); + + public override LocalizedText ShortDescription => GetText("UI.RevengeanceShortInfo"); + public override LocalizedText ExpandedDescription { get { string rageKey = "[c/FFCE85:" + CalamityKeybinds.RageHotKey.TooltipHotkeyString() + "]"; string adrenKey = "[c/79DFBF:" + CalamityKeybinds.AdrenalineHotKey.TooltipHotkeyString() + "]"; - return CalamityUtils.GetText("UI.RevengeanceExpandedInfo").WithFormatArgs(rageKey, adrenKey); + return GetText("UI.RevengeanceExpandedInfo").WithFormatArgs(rageKey, adrenKey); } } - - public RevengeanceDifficulty() - { - DifficultyScale = 0.25f; - Name = CalamityUtils.GetText("UI.Revengeance"); - ShortDescription = CalamityUtils.GetText("UI.RevengeanceShortInfo"); - - ActivationTextKey = "Mods.CalamityMod.UI.RevengeanceActivate"; - DeactivationTextKey = "Mods.CalamityMod.UI.RevengeanceDeactivate"; - - ActivationSound = SoundID.Item119; - - ChatTextColor = Color.Crimson; - } } public class DeathDifficulty : DifficultyMode @@ -235,48 +530,126 @@ namespace CalamityMod.Systems public override bool Enabled { get => CalamityWorld.death; - set => CalamityWorld.death = value; - } - - private Asset _texture; - public override Asset Texture - { - get + set { - if (_texture == null) - _texture = ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Death"); - - return _texture; + if (Main.getGoodWorld) + { + if (!Main.GameModeInfo.IsJourneyMode) + { + Main.GameMode = value == true ? GameModeID.Expert : GameModeID.Normal; + } + else + { + DifficultyModeSystem.AlignJourneyDifficultySlider(); + } + CalamityWorld.death = value; + } + else + { + CalamityWorld.death = value; + if (value && !Main.GameModeInfo.IsJourneyMode) + Main.GameMode = BackBoneGameModeID; + } } } - public override LocalizedText ExpandedDescription => CalamityUtils.GetText("UI.DeathExpandedInfo"); + public override Asset Texture => _texture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Death"); + public override Asset OutlineTexture => _outlineTexture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Death_Border"); - public DeathDifficulty() - { - DifficultyScale = 0.5f; - Name = CalamityUtils.GetText("UI.Death"); - ShortDescription = CalamityUtils.GetText("UI.DeathShortInfo"); + public override Asset TextureDisabled => _textureDisabled ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Death_Off"); - ActivationTextKey = "Mods.CalamityMod.UI.DeathActivate"; - DeactivationTextKey = "Mods.CalamityMod.UI.DeathDeactivate"; + public override SoundStyle ActivationSound => _activationSound ??= new("CalamityMod/Sounds/Custom/DifficultySelection/Death_Mode_Select"); - ActivationSound = DemonshadeHelm.ActivationSound; + public override int BackBoneGameModeID => Main.getGoodWorld ? GameModeID.Expert : GameModeID.Master; - ChatTextColor = Color.MediumOrchid; - } + public override float DifficultyScale => 0.25f; - public override int FavoredDifficultyAtTier(int tier) + public override LocalizedText Name => GetText("UI.Death"); + + public override Color ChatTextColor => new Color(192, 64, 219); + + public override LocalizedText ShortDescription => GetText("UI.DeathShortInfo"); + + public override LocalizedText ExpandedDescription => GetText("UI.DeathExpandedInfo"); + + public override int[] FavoredDifficultyAtTier(int tier) { DifficultyMode[] tierList = DifficultyModeSystem.DifficultyTiers[tier]; + List difficulties = new List(); + for (int i = 0; i < tierList.Length; i++) { - if (tierList[i].Name == CalamityUtils.GetText("UI.Revengeance")) - return i; + if (tierList[i] is MasterDifficulty || tierList[i] is RevengeanceDifficulty) + difficulties.Add(i); } - return 0; + if (difficulties.Count <= 0) + difficulties.Add(0); + + return difficulties.ToArray(); + } + } + + public class MaliceDifficulty : DifficultyMode + { + public override bool Enabled + { + get => Main.getGoodWorld ? CalamityWorld.death && CalamityWorld.LegendaryMode : false; + set + { + if (Main.getGoodWorld) + { + if (!Main.GameModeInfo.IsJourneyMode) + { + Main.GameMode = value == true ? GameModeID.Master : GameModeID.Expert; + } + else + { + DifficultyModeSystem.AlignJourneyDifficultySlider(); + } + CalamityWorld.revenge = value; + CalamityWorld.death = value; + } + } + } + + public override Asset Texture => _texture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Malice"); + public override Asset OutlineTexture => _outlineTexture ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Malice_Border"); + + public override Asset TextureDisabled => _textureDisabled ??= ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicator_Malice_Off"); + + public override SoundStyle ActivationSound => _activationSound ??= new("CalamityMod/Sounds/Custom/DifficultySelection/Malice_Mode_Select"); + + public override int BackBoneGameModeID => GameModeID.Master; + + public override float DifficultyScale => 0.5f; + + public override LocalizedText Name => GetText("UI.Malice"); + + public override Color ChatTextColor => new Color(240, 128, 128); + + public override LocalizedText ShortDescription => GetText("UI.MaliceShortInfo"); + + public override LocalizedText ExpandedDescription => GetText("UI.MaliceExpandedInfo"); + public override FTWDisplayMode GetForTheWorthyDisplay => FTWDisplayMode.OnlyForTheWorthy; + + public override int[] FavoredDifficultyAtTier(int tier) + { + DifficultyMode[] tierList = DifficultyModeSystem.DifficultyTiers[tier]; + + List difficulties = new List(); + + for (int i = 0; i < tierList.Length; i++) + { + if (tierList[i] is MasterDifficulty || tierList[i] is DeathDifficulty) + difficulties.Add(i); + } + + if (difficulties.Count <= 0) + difficulties.Add(0); + + return difficulties.ToArray(); } } } diff --git a/Systems/Mechanic/GemcornValidGroundSystem.cs b/Systems/Mechanic/GemcornValidGroundSystem.cs new file mode 100644 index 0000000000..ca87aae911 --- /dev/null +++ b/Systems/Mechanic/GemcornValidGroundSystem.cs @@ -0,0 +1,30 @@ +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Systems; + +internal sealed class GemcornValidGroundSystem : ModSystem +{ + public static TileObjectData GemSaplingData => TileObjectData.GetTileData(TileID.GemSaplings, 0); + + public int[] ValidGemcornGrounds = []; + + public override void PostSetupContent() + { + ValidGemcornGrounds = [.. CalamityMod.Instance.GetContent() + .Where(tile => WorldGen.GemTreeGroundTest(tile.Type)) + .Select(tile => (int)tile.Type)]; + + var gemSaplingData = GemSaplingData; + gemSaplingData.AnchorValidTiles = [.. gemSaplingData.AnchorValidTiles, .. ValidGemcornGrounds]; + } + + public override void Unload() + { + var gemSaplingData = GemSaplingData; + gemSaplingData.AnchorValidTiles = [.. gemSaplingData.AnchorValidTiles.Where(type => !ValidGemcornGrounds.Contains(type))]; + } +} diff --git a/Systems/Mechanic/GraveyardBiomeSystem.cs b/Systems/Mechanic/GraveyardBiomeSystem.cs index b1104f87ba..1210e50c18 100644 --- a/Systems/Mechanic/GraveyardBiomeSystem.cs +++ b/Systems/Mechanic/GraveyardBiomeSystem.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Systems diff --git a/Systems/Mechanic/MountsBalancingSystem.cs b/Systems/Mechanic/MountsBalancingSystem.cs index ba8aac2082..819ab85d78 100644 --- a/Systems/Mechanic/MountsBalancingSystem.cs +++ b/Systems/Mechanic/MountsBalancingSystem.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.ID; +using Terraria; using Terraria.ModLoader; namespace CalamityMod.Systems diff --git a/Systems/Mechanic/NerfExpertDebuffsSystem.cs b/Systems/Mechanic/NerfExpertDebuffsSystem.cs index 67ea9cdaaa..063237eee8 100644 --- a/Systems/Mechanic/NerfExpertDebuffsSystem.cs +++ b/Systems/Mechanic/NerfExpertDebuffsSystem.cs @@ -1,5 +1,4 @@ -using System; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Systems/Mechanic/RecipeSystem.cs b/Systems/Mechanic/RecipeSystem.cs index d2149df7c7..22135486fa 100644 --- a/Systems/Mechanic/RecipeSystem.cs +++ b/Systems/Mechanic/RecipeSystem.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Critters; using CalamityMod.Items.Fishing.AstralCatches; using CalamityMod.Items.Fishing.BrimstoneCragCatches; @@ -11,9 +10,13 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Placeables.Astral; +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using CalamityMod.Items.Placeables.Crags; using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Potions.Food; using CalamityMod.Items.Tools; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; @@ -34,10 +37,10 @@ namespace CalamityMod.Systems #endregion #region Recipe Group Definitions - public static int HardmodeAnvil, HardmodeForge, AnyLargeGem, AnyFood; + public static int HardmodeAnvil, HardmodeForge, AnyFood; public static int AnyCopperOre, AnySilverOre, AnyGoldOre, AnyEvilOre, AnyCobaltOre, AnyMythrilOre, AnyAdamantiteOre; public static int AnyCopperBar, AnySilverBar, AnyGoldBar, AnyEvilBar, AnyCobaltBar, AnyMythrilBar, AnyAdamantiteBar; - public static int AnyEvilPowder, Boss2Material, CursedFlameIchor, AnyEvilWater, AnyEvilFlask; + public static int Boss2Material, CursedFlameIchor, AnyEvilWater; public static int AnyStoneBlock, AnySnowBlock, AnyIceBlock, AnySiltBlock, AnyEvilBlock, AnyGoodBlock; public static int AnyWoodenSword, AnyHallowedHelmet, AnyHallowedPlatemail, AnyHallowedGreaves, AnyGoldCrown, LunarPickaxe, LunarHamaxe; public static int AnyManaFlower, AnyQuiver, AnyTombstone, AnyWings; @@ -48,13 +51,27 @@ namespace CalamityMod.Systems RecipeGroup firefly = RecipeGroup.recipeGroups[RecipeGroupID.Fireflies]; firefly.ValidItems.Add(ItemType()); - // Astral, Sunken Sea and Sulphurous Sea Sand is Sand + RecipeGroup fruit = RecipeGroup.recipeGroups[RecipeGroupID.Fruit]; + fruit.ValidItems.Add(ItemType()); + fruit.ValidItems.Add(ItemType()); + fruit.ValidItems.Add(ItemType()); + fruit.ValidItems.Add(ItemType()); + fruit.ValidItems.Add(ItemType()); + fruit.ValidItems.Add(ItemType()); + + // Astral, Sunken Sea and Sulphurous Sea sand are Sand + // This recipe group also naturally includes Hardened Sand, but not Sandstone RecipeGroup sand = RecipeGroup.recipeGroups[RecipeGroupID.Sand]; sand.ValidItems.Add(ItemType()); + sand.ValidItems.Add(ItemType()); + sand.ValidItems.Add(ItemType()); sand.ValidItems.Add(ItemType()); + sand.ValidItems.Add(ItemType()); + sand.ValidItems.Add(ItemType()); + sand.ValidItems.Add(ItemType()); sand.ValidItems.Add(ItemType()); - // Acidwood is Wood + // Acidwood and Driftwood are Wood RecipeGroup wood = RecipeGroup.recipeGroups[RecipeGroupID.Wood]; wood.ValidItems.Add(ItemType()); wood.ValidItems.Add(ItemType()); @@ -86,19 +103,6 @@ namespace CalamityMod.Systems }); HardmodeForge = RecipeGroup.RegisterGroup("HardmodeForge", group); - // Large Gems (PvP tokens) - group = new RecipeGroup(() => CalamityUtils.GetTextValue("Misc.RecipeGroup.AnyLargeGem"), new int[] - { - ItemID.LargeAmber, - ItemID.LargeAmethyst, - ItemID.LargeDiamond, - ItemID.LargeEmerald, - ItemID.LargeRuby, - ItemID.LargeSapphire, - ItemID.LargeTopaz - }); - AnyLargeGem = RecipeGroup.RegisterGroup("AnyLargeGem", group); - // Food AnyFood = RecipeGroup.RegisterGroup("AnyFood", GetFoodItems()); } @@ -213,16 +217,8 @@ namespace CalamityMod.Systems private static void AddEvilBiomeItemRecipeGroups() { - // Vile and Vicious Powder - RecipeGroup group = new RecipeGroup(() => CalamityUtils.GetTextValue("Misc.RecipeGroup.AnyEvilPowder"), new int[] - { - ItemID.VilePowder, - ItemID.ViciousPowder - }); - AnyEvilPowder = RecipeGroup.RegisterGroup("AnyEvilPowder", group); - // Shadow Scale and Tissue Sample - group = new RecipeGroup(() => CalamityUtils.GetTextValue("Misc.RecipeGroup.Boss2Material"), new int[] + RecipeGroup group = new RecipeGroup(() => CalamityUtils.GetTextValue("Misc.RecipeGroup.Boss2Material"), new int[] { ItemID.ShadowScale, ItemID.TissueSample @@ -244,14 +240,6 @@ namespace CalamityMod.Systems ItemID.BloodWater }); AnyEvilWater = RecipeGroup.RegisterGroup("AnyEvilWater", group); - - // Flask of Cursed Flames and Flask of Ichor - group = new RecipeGroup(() => CalamityUtils.GetTextValue("Misc.RecipeGroup.AnyEvilFlask"), new int[] - { - ItemID.FlaskofCursedFlames, - ItemID.FlaskofIchor - }); - AnyEvilFlask = RecipeGroup.RegisterGroup("AnyEvilFlask", group); } private static void AddBiomeBlockRecipeGroups() @@ -263,8 +251,7 @@ namespace CalamityMod.Systems ItemID.EbonstoneBlock, ItemID.CrimstoneBlock, ItemID.PearlstoneBlock, - ItemType(), - ItemType() + ItemType() }); AnyStoneBlock = RecipeGroup.RegisterGroup("AnyStoneBlock", group); @@ -336,7 +323,9 @@ namespace CalamityMod.Systems ItemID.EbonwoodSword, ItemID.ShadewoodSword, ItemID.PearlwoodSword, - ItemID.AshWoodSword + ItemID.AshWoodSword, + ItemType(), + ItemType() }); AnyWoodenSword = RecipeGroup.RegisterGroup("AnyWoodenSword", group); @@ -434,39 +423,10 @@ namespace CalamityMod.Systems ItemID.RichGravestone5 }); AnyTombstone = RecipeGroup.RegisterGroup("AnyTombstone", group); - - // Wings for Celestial Tracers - AnyWings = RecipeGroup.RegisterGroup("AnyWings", GetValidWingsForTracers()); } #endregion #region Automatic Recipe Groups - private static RecipeGroup GetValidWingsForTracers() - { - List wingIds = new List(); - // List of wings that can't be used to craft Celestial Tracers, includes tracers themselves, specific wing ingredients, and non-traditional wings - List excludedWings = new List - { - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemType(), - ItemID.Jetpack - }; - foreach (var i in ContentSamples.ItemsByType) - { - Item item = i.Value; - if (item.wingSlot > -1 && !excludedWings.Contains(item.type)) - { - wingIds.Add(item.type); - } - } - return new RecipeGroup(() => CalamityUtils.GetTextValue("Misc.RecipeGroup.AnyWings"), [.. wingIds]); - } - private static RecipeGroup GetFoodItems() { List foodIds = new List(); @@ -501,13 +461,6 @@ namespace CalamityMod.Systems Register() .DisableDecraft(); - // Black Lens - Recipe.Create(ItemID.BlackLens). - AddIngredient(ItemID.Lens). - AddIngredient(ItemID.BlackDye). - AddTile(TileID.DyeVat). - Register(); - // Stohne smelts into Lihzahrd Bricks Recipe.Create(ItemID.LihzahrdBrick). AddIngredient(ItemType()). @@ -521,6 +474,7 @@ namespace CalamityMod.Systems AddIngredient(ItemID.ExplosivePowder, 4). AddTile(TileID.Anvils). Register(); + // and Rocket IIs (requires slightly more explosive powder) Recipe.Create(ItemID.RocketII, 100). AddRecipeGroup("IronBar"). @@ -564,8 +518,8 @@ namespace CalamityMod.Systems // Demon Conch Recipe.Create(ItemID.DemonConch). - AddIngredient(ItemID.HellstoneBar, 4). - AddIngredient(8). + AddIngredient(20). + AddIngredient(ItemID.BlackPearl). AddTile(TileID.Hellforge). Register(); @@ -576,13 +530,6 @@ namespace CalamityMod.Systems AddTile(TileID.Anvils). Register(); - // Lava Fishing Hook - Recipe.Create(ItemID.LavaFishingHook). - AddIngredient(ItemID.HellstoneBar, 10). - AddIngredient(ItemID.Seashell). - AddTile(TileID.Hellforge). - Register(); - // Alternative Evil Biome items Recipe.Create(ItemID.CrimsonRod). AddIngredient(ItemID.Vilethorn). @@ -724,18 +671,15 @@ namespace CalamityMod.Systems Register() .DisableDecraft(); - AddAstralClayRecipes(); + AddAstralRecipeVariants(); AddBloodOrbPotionRecipes(); AddCookedFood(); - AddEssentialToolRecipes(); - AddSummonAndProgressionRecipes(); + AddMiscItemRecipes(); AddTombstoneRecipes(); AddEarlyGameWeaponRecipes(); AddEarlyGameAccessoryRecipes(); AddHardmodeItemRecipes(); AddArmorRecipes(); - AddAnkhShieldRecipes(); - AddLivingWoodRecipes(); } #endregion @@ -793,7 +737,6 @@ namespace CalamityMod.Systems var edits = new Dictionary, Action>(128) { - { Vanilla(ItemID.EnchantedBoomerang), Disable }, // Calamity adds its own recipe { Vanilla(ItemID.MiniNukeI), Disable }, { Vanilla(ItemID.MiniNukeII), Disable }, @@ -845,89 +788,17 @@ namespace CalamityMod.Systems { Vanilla(ItemID.PumpkinMoonMedallion), RemoveIngredient(ItemID.HallowedBar) }, { Vanilla(ItemID.NaughtyPresent), RemoveIngredient(ItemID.SoulofFright) }, + // Make Enchanted Boomerang slightly harder to obtain + { Vanilla(ItemID.EnchantedBoomerang), EnchantedBoomerangRecipeEdit }, + + // Adjust Fertilizer decrafting and add an alternate recipe + { Vanilla(ItemID.Fertilizer), FertilizerRecipeEdit }, + // Add 20 Souls of Flight to vanilla Luminite wings { VanillaEach(ItemID.WingsSolar, ItemID.WingsVortex, ItemID.WingsNebula, ItemID.WingsStardust), LunarWingsRecipeEdits }, // Berserker's Glove recipe change now that it doesn't provide melee speed { Vanilla(ItemID.BerserkerGlove), ReplaceIngredient(ItemID.PowerGlove, ItemID.TitanGlove) }, - - // Standardize the costs of all PHM ore armors to 10/16/14 head/chest/legs - { Vanilla(ItemID.CopperHelmet), ChangeIngredientStack(ItemID.CopperBar, 10) }, - { Vanilla(ItemID.CopperChainmail), ChangeIngredientStack(ItemID.CopperBar, 16) }, - { Vanilla(ItemID.CopperGreaves), ChangeIngredientStack(ItemID.CopperBar, 14) }, - { Vanilla(ItemID.TinHelmet), ChangeIngredientStack(ItemID.TinBar, 10) }, - { Vanilla(ItemID.TinChainmail), ChangeIngredientStack(ItemID.TinBar, 16) }, - { Vanilla(ItemID.TinGreaves), ChangeIngredientStack(ItemID.TinBar, 14) }, - { Vanilla(ItemID.IronHelmet), ChangeIngredientStack(ItemID.IronBar, 10) }, - { Vanilla(ItemID.IronChainmail), ChangeIngredientStack(ItemID.IronBar, 16) }, - { Vanilla(ItemID.IronGreaves), ChangeIngredientStack(ItemID.IronBar, 14) }, - { Vanilla(ItemID.LeadHelmet), ChangeIngredientStack(ItemID.LeadBar, 10) }, - { Vanilla(ItemID.LeadChainmail), ChangeIngredientStack(ItemID.LeadBar, 16) }, - { Vanilla(ItemID.LeadGreaves), ChangeIngredientStack(ItemID.LeadBar, 14) }, - { Vanilla(ItemID.SilverHelmet), ChangeIngredientStack(ItemID.SilverBar, 10) }, - { Vanilla(ItemID.SilverChainmail), ChangeIngredientStack(ItemID.SilverBar, 16) }, - { Vanilla(ItemID.SilverGreaves), ChangeIngredientStack(ItemID.SilverBar, 14) }, - { Vanilla(ItemID.TungstenHelmet), ChangeIngredientStack(ItemID.TungstenBar, 10) }, - { Vanilla(ItemID.TungstenChainmail), ChangeIngredientStack(ItemID.TungstenBar, 16) }, - { Vanilla(ItemID.TungstenGreaves), ChangeIngredientStack(ItemID.TungstenBar, 14) }, - { Vanilla(ItemID.GoldHelmet), ChangeIngredientStack(ItemID.GoldBar, 10) }, - { Vanilla(ItemID.GoldChainmail), ChangeIngredientStack(ItemID.GoldBar, 16) }, - { Vanilla(ItemID.GoldGreaves), ChangeIngredientStack(ItemID.GoldBar, 14) }, - { Vanilla(ItemID.PlatinumHelmet), ChangeIngredientStack(ItemID.PlatinumBar, 10) }, - { Vanilla(ItemID.PlatinumChainmail), ChangeIngredientStack(ItemID.PlatinumBar, 16) }, - { Vanilla(ItemID.PlatinumGreaves), ChangeIngredientStack(ItemID.PlatinumBar, 14) }, - - // Standardize the costs of all HM ore items to the following: - // 10 BARS : Melee Helm, Ranged Helm, Magic Helm, Pickaxe, Drill, Waraxe, Chainsaw, Sword, Spear, Repeater - // 20 BARS : Breastplate - // 15 BARS : Leggings - { VanillaEach( - ItemID.CobaltHelmet, ItemID.CobaltMask, ItemID.CobaltHat, ItemID.CobaltPickaxe, ItemID.CobaltDrill, ItemID.CobaltWaraxe, ItemID.CobaltChainsaw, - ItemID.CobaltSword, ItemID.CobaltNaginata, ItemID.CobaltRepeater), - ChangeIngredientStack(ItemID.CobaltBar, 10) - }, - { Vanilla(ItemID.CobaltBreastplate), ChangeIngredientStack(ItemID.CobaltBar, 20) }, - { Vanilla(ItemID.CobaltLeggings), ChangeIngredientStack(ItemID.CobaltBar, 15) }, - - { VanillaEach( - ItemID.PalladiumHelmet, ItemID.PalladiumMask, ItemID.PalladiumHeadgear, ItemID.PalladiumPickaxe, ItemID.PalladiumDrill, ItemID.PalladiumWaraxe, ItemID.PalladiumChainsaw, - ItemID.PalladiumSword, ItemID.PalladiumPike, ItemID.PalladiumRepeater), - ChangeIngredientStack(ItemID.PalladiumBar, 10) - }, - { Vanilla(ItemID.PalladiumBreastplate), ChangeIngredientStack(ItemID.PalladiumBar, 20) }, - { Vanilla(ItemID.PalladiumLeggings), ChangeIngredientStack(ItemID.PalladiumBar, 15) }, - - { VanillaEach( - ItemID.MythrilHelmet, ItemID.MythrilHat, ItemID.MythrilHood, ItemID.MythrilPickaxe, ItemID.MythrilDrill, ItemID.MythrilWaraxe, ItemID.MythrilChainsaw, - ItemID.MythrilSword, ItemID.MythrilHalberd, ItemID.MythrilRepeater), - ChangeIngredientStack(ItemID.MythrilBar, 10) - }, - { Vanilla(ItemID.MythrilChainmail), ChangeIngredientStack(ItemID.MythrilBar, 20) }, - { Vanilla(ItemID.MythrilGreaves), ChangeIngredientStack(ItemID.MythrilBar, 15) }, - - { VanillaEach( - ItemID.OrichalcumHelmet, ItemID.OrichalcumMask, ItemID.OrichalcumHeadgear, ItemID.OrichalcumPickaxe, ItemID.OrichalcumDrill, ItemID.OrichalcumWaraxe, ItemID.OrichalcumChainsaw, - ItemID.OrichalcumSword, ItemID.OrichalcumHalberd, ItemID.OrichalcumRepeater), - ChangeIngredientStack(ItemID.OrichalcumBar, 10) - }, - { Vanilla(ItemID.OrichalcumBreastplate), ChangeIngredientStack(ItemID.OrichalcumBar, 20) }, - { Vanilla(ItemID.OrichalcumLeggings), ChangeIngredientStack(ItemID.OrichalcumBar, 15) }, - - { VanillaEach( - ItemID.AdamantiteHelmet, ItemID.AdamantiteMask, ItemID.AdamantiteHeadgear, ItemID.AdamantitePickaxe, ItemID.AdamantiteDrill, ItemID.AdamantiteWaraxe, ItemID.AdamantiteChainsaw, - ItemID.AdamantiteSword, ItemID.AdamantiteGlaive, ItemID.AdamantiteRepeater), - ChangeIngredientStack(ItemID.AdamantiteBar, 10) - }, - { Vanilla(ItemID.AdamantiteBreastplate), ChangeIngredientStack(ItemID.AdamantiteBar, 20) }, - { Vanilla(ItemID.AdamantiteLeggings), ChangeIngredientStack(ItemID.AdamantiteBar, 15) }, - - { VanillaEach( - ItemID.TitaniumHelmet, ItemID.TitaniumMask, ItemID.TitaniumHeadgear, ItemID.TitaniumPickaxe, ItemID.TitaniumDrill, ItemID.TitaniumWaraxe, ItemID.TitaniumChainsaw, - ItemID.TitaniumSword, ItemID.TitaniumTrident, ItemID.TitaniumRepeater), - ChangeIngredientStack(ItemID.TitaniumBar, 10) - }, - { Vanilla(ItemID.TitaniumBreastplate), ChangeIngredientStack(ItemID.TitaniumBar, 20) }, - { Vanilla(ItemID.TitaniumLeggings), ChangeIngredientStack(ItemID.TitaniumBar, 15) }, }; // Apply all recipe changes. @@ -1011,6 +882,42 @@ namespace CalamityMod.Systems r.requiredItem[2] = r.requiredItem[1]; r.requiredItem[1] = store; } + + private static void EnchantedBoomerangRecipeEdit(Recipe r) + { + // Add Any Gold Bar and make it crafted at an Anvil + r.AddRecipeGroup(AnyGoldBar, 8); + r.AddTile(TileID.Anvils); + + // Then move it to the proper spot + if (r.requiredItem.Count < 3) + return; + + var store = r.requiredItem[1]; + r.requiredItem[1] = r.requiredItem[2]; + r.requiredItem[2] = store; + + // Increase amount of Fallen Stars used + r.requiredItem[2].stack = 6; + } + + private static void FertilizerRecipeEdit(Recipe r) + { + // Custom Shimmer result, to prevent Scorched Bone -> Bone shenanigans + r.AddCustomShimmerResult(ItemID.PoopBlock, 3); + r.AddCustomShimmerResult(ItemType(), 3); + r.AddCustomShimmerResult(ItemID.AshBlock, 3); + + // Alternative recipe using (a bit more) Scorched Bones + Recipe r2 = Recipe.Create(ItemID.Fertilizer); + r2.AddIngredient(ItemID.PoopBlock, 3); + r2.AddIngredient(6); + r2.AddIngredient(ItemID.AshBlock, 3); + r2.AddTile(TileID.Bottles); + r2.Register(); + r2.SortAfterFirstRecipesOf(ItemID.Fertilizer); + r2.DisableDecraft(); + } #endregion #region Shimmer Recipes @@ -1036,30 +943,36 @@ namespace CalamityMod.Systems convert[ItemID.LifeformAnalyzer] = ItemID.Stopwatch; convert[ItemID.Stopwatch] = ItemID.DPSMeter; - // Pyramid loot edits. There's no good way to have this not be hardcoded. - convert[ItemID.PharaohsMask] = ItemID.PharaohsRobe; - convert[ItemID.PharaohsRobe] = ItemID.PharaohsMask; - - convert[ItemID.AmberHook] = ItemID.SandstorminaBottle; - convert[ItemID.SandstorminaBottle] = ItemID.FlyingCarpet; - convert[ItemID.FlyingCarpet] = ItemID.AmberHook; - // Enchanted Sword and Terragrim shimmer into each other convert[ItemID.EnchantedSword] = ItemID.Terragrim; convert[ItemID.Terragrim] = ItemID.EnchantedSword; + + // Allow Cascade and Gray Zapinator to be obtained in Hardmode + convert[ItemID.HelFire] = ItemID.Cascade; + convert[ItemID.ZapinatorOrange] = ItemID.ZapinatorGray; } #endregion - #region Astral Clay - private static void AddAstralClayRecipes() + #region Astral Recipe Variants + private static void AddAstralRecipeVariants() { + #region Astral Clay // Intentionally excluding Red Brick and Red Stucco recipes + // Argon Moss Brick + Recipe r = Recipe.Create(ItemID.ArgonMossBlock, 10); + r.AddIngredient(ItemID.ArgonMoss); + r.AddIngredient(10); + r.AddTile(TileID.Furnaces); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.ArgonMossBlock); + r.DisableDecraft(); // Bowl - Recipe r = Recipe.Create(ItemID.Bowl); + r = Recipe.Create(ItemID.Bowl); r.AddIngredient(2); r.AddTile(TileID.Furnaces); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.Bowl); r.DisableDecraft(); // Clay Pot @@ -1067,6 +980,43 @@ namespace CalamityMod.Systems r.AddIngredient(5); r.AddTile(TileID.Furnaces); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.ClayPot); + r.DisableDecraft(); + + // Helium Moss Brick + r = Recipe.Create(ItemID.RainbowMossBlock, 10); + r.AddIngredient(ItemID.RainbowMoss); + r.AddIngredient(10); + r.AddTile(TileID.Furnaces); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.RainbowMossBlock); + r.DisableDecraft(); + + // Krypton Moss Brick + r = Recipe.Create(ItemID.KryptonMossBlock, 10); + r.AddIngredient(ItemID.KryptonMoss); + r.AddIngredient(10); + r.AddTile(TileID.Furnaces); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.KryptonMossBlock); + r.DisableDecraft(); + + // Lava Moss Brick + r = Recipe.Create(ItemID.LavaMossBlock, 10); + r.AddIngredient(ItemID.LavaMoss); + r.AddIngredient(10); + r.AddTile(TileID.Furnaces); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.LavaMossBlock); + r.DisableDecraft(); + + // Neon Moss Brick + r = Recipe.Create(ItemID.VioletMossBlock, 10); + r.AddIngredient(ItemID.VioletMoss); + r.AddIngredient(10); + r.AddTile(TileID.Furnaces); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.VioletMossBlock); r.DisableDecraft(); // Pink Vase @@ -1074,6 +1024,7 @@ namespace CalamityMod.Systems r.AddIngredient(4); r.AddTile(TileID.Furnaces); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.PinkVase); r.DisableDecraft(); // Plate @@ -1081,6 +1032,7 @@ namespace CalamityMod.Systems r.AddIngredient(2); r.AddTile(TileID.Furnaces); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.FoodPlatter); r.DisableDecraft(); // Teapot @@ -1089,6 +1041,7 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Bone, 12); r.AddTile(TileID.Furnaces); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.TeaKettle); r.DisableDecraft(); // Wandering Jingasa @@ -1097,7 +1050,86 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Firefly, 3); // Does not use the recipe group in Vanilla r.AddTile(TileID.Loom); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.RoninHat); r.DisableDecraft(); + + // Xenon Moss Brick + r = Recipe.Create(ItemID.XenonMossBlock, 10); + r.AddIngredient(ItemID.XenonMoss); + r.AddIngredient(10); + r.AddTile(TileID.Furnaces); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.XenonMossBlock); + r.DisableDecraft(); + #endregion + + #region Astral Dirt + // Intentionally excluding a ton of pure dirt recipes ie. Dirt Bombs, Walls + // Floret Protector set + r = Recipe.Create(ItemID.FloretProtectorHelmet); + r.AddIngredient(ItemID.Glass, 20); + r.AddIngredient(10); + r.AddIngredient(ItemID.Daybloom); + r.AddTile(TileID.Loom); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.FloretProtectorHelmet); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.FloretProtectorChestplate); + r.AddIngredient(ItemID.Silk, 20); + r.AddIngredient(15); + r.AddTile(TileID.Loom); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.FloretProtectorChestplate); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.FloretProtectorLegs); + r.AddIngredient(ItemID.Silk, 20); + r.AddIngredient(15); + r.AddTile(TileID.Loom); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.FloretProtectorLegs); + r.DisableDecraft(); + #endregion + + #region Astral Ice + // Ice Torch + r = Recipe.Create(ItemID.IceTorch, 3); + r.AddIngredient(ItemID.Torch, 3); + r.AddIngredient(); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.IceTorch); + r.DisableDecraft(); + #endregion + + #region Astral Snow + // Frozen Banana Daiquiri + r = Recipe.Create(ItemID.BananaDaiquiri); + r.AddIngredient(ItemID.Banana); + r.AddIngredient(ItemID.Bottle); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.BananaDaiquiri); + r.DisableDecraft(); + + // Snowball + r = Recipe.Create(ItemID.Snowball, 15); + r.AddIngredient(); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.Snowball); + r.DisableDecraft(); + #endregion + + #region Hardened Astral Sand + // Desert Torch + r = Recipe.Create(ItemID.DesertTorch, 3); + r.AddIngredient(ItemID.Torch, 3); + r.AddIngredient(); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.DesertTorch); + r.DisableDecraft(); + #endregion } #endregion @@ -1172,6 +1204,7 @@ namespace CalamityMod.Systems r.AddIngredient(5); r.AddTile(TileID.AlchemyTable); r.Register(); + r.SortAfterFirstRecipesOf(potion); r.DisableDecraft(); } foreach (var potion in TenOrbGroup) @@ -1181,6 +1214,7 @@ namespace CalamityMod.Systems r.AddIngredient(10); r.AddTile(TileID.AlchemyTable); r.Register(); + r.SortAfterFirstRecipesOf(potion); r.DisableDecraft(); } foreach (var potion in FifteenOrbGroup) @@ -1190,6 +1224,7 @@ namespace CalamityMod.Systems r.AddIngredient(15); r.AddTile(TileID.AlchemyTable); r.Register(); + r.SortAfterFirstRecipesOf(potion); r.DisableDecraft(); } } @@ -1198,203 +1233,182 @@ namespace CalamityMod.Systems #region Cooked Food private static void AddCookedFood() { + #region Alternative Recipes + #region Cooked Fish Recipe r = Recipe.Create(ItemID.CookedFish); r.AddIngredient(); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.CookedFish); r.DisableDecraft(); r = Recipe.Create(ItemID.CookedFish); - r.AddIngredient(); + r.AddIngredient(); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.CookedFish); r.DisableDecraft(); - r = Recipe.Create(ItemID.Sashimi); - r.AddIngredient(); - r.AddTile(TileID.WorkBenches); - r.Register(); - r.DisableDecraft(); - - r = Recipe.Create(ItemID.CookedShrimp); - r.AddIngredient(); + r = Recipe.Create(ItemID.CookedFish); + r.AddIngredient(); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.CookedFish); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.CookedFish); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.CookedFish); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.CookedFish); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.CookedFish); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.CookedFish); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.CookedFish); + r.DisableDecraft(); + #endregion + + #region Seafood Dinner + r = Recipe.Create(ItemID.SeafoodDinner); + r.AddIngredient(); // Consistency would be 2, but considering you need only 1 for Golden Delight, I'm leaving this at 1 + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.SeafoodDinner); r.DisableDecraft(); r = Recipe.Create(ItemID.SeafoodDinner); r.AddIngredient(2); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.SeafoodDinner); r.DisableDecraft(); r = Recipe.Create(ItemID.SeafoodDinner); r.AddIngredient(2); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.SeafoodDinner); r.DisableDecraft(); r = Recipe.Create(ItemID.SeafoodDinner); r.AddIngredient(2); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.SeafoodDinner); r.DisableDecraft(); r = Recipe.Create(ItemID.SeafoodDinner); r.AddIngredient(2); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.SeafoodDinner); r.DisableDecraft(); r = Recipe.Create(ItemID.SeafoodDinner); r.AddIngredient(2); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.SeafoodDinner); + r.DisableDecraft(); + #endregion + + #region Golden Delight + r = Recipe.Create(ItemID.GoldenDelight); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.GoldenDelight); r.DisableDecraft(); - r = Recipe.Create(ItemID.Bacon); - r.AddIngredient(); - r.AddTile(TileID.Hellforge); + r = Recipe.Create(ItemID.GoldenDelight); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.GoldenDelight); r.DisableDecraft(); + r = Recipe.Create(ItemID.GoldenDelight); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.GoldenDelight); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.GoldenDelight); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.GoldenDelight); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.GoldenDelight); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.GoldenDelight); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.GoldenDelight); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.GoldenDelight); + r.DisableDecraft(); + #endregion + r = Recipe.Create(ItemID.BowlofSoup); r.AddIngredient(ItemID.Mushroom); r.AddIngredient(); r.AddTile(TileID.CookingPots); r.Register(); + r.SortAfterFirstRecipesOf(ItemID.BowlofSoup); r.DisableDecraft(); - r = Recipe.Create(ItemID.ApplePie); - r.AddIngredient(ItemID.Apple, 3); + r = Recipe.Create(ItemID.Sashimi); + r.AddIngredient(); + r.AddTile(TileID.WorkBenches); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.Sashimi); + r.DisableDecraft(); + + r = Recipe.Create(ItemID.CookedShrimp); + r.AddIngredient(); + r.AddTile(TileID.CookingPots); + r.Register(); + r.SortAfterFirstRecipesOf(ItemID.CookedShrimp); + r.DisableDecraft(); + #endregion + + r = Recipe.Create(ItemID.Bacon); + r.AddIngredient(); r.AddTile(TileID.Hellforge); r.Register(); r.DisableDecraft(); - - r = Recipe.Create(ItemID.BananaSplit); - r.AddIngredient(ItemID.Banana); - r.AddIngredient(ItemID.IceBlock); - r.AddIngredient(ItemID.MilkCarton); - r.AddTile(TileID.CookingPots); - r.Register(); - r.DisableDecraft(); - - r = Recipe.Create(ItemID.BBQRibs); - r.AddIngredient(ItemID.FleshBlock, 6); - r.AddIngredient(ItemID.Bone, 6); - r.AddTile(TileID.Hellforge); - r.Register(); - r.DisableDecraft(); - - r = Recipe.Create(ItemID.MilkCarton); - r.AddIngredient(ItemID.BottledWater); - r.AddIngredient(ItemID.Bone, 2); - r.AddTile(TileID.CookingPots); - r.Register(); - r.DisableDecraft(); - - r = Recipe.Create(ItemID.Nachos); - r.AddIngredient(ItemID.PotatoChips); - r.AddIngredient(ItemID.MilkCarton); - r.AddTile(TileID.CookingPots); - r.Register(); - r.DisableDecraft(); } #endregion - #region Essential Gameplay Tools - private static void AddEssentialToolRecipes() + #region Miscellaneous Items + private static void AddMiscItemRecipes() { - // Umbrella - Recipe r = Recipe.Create(ItemID.Umbrella); - r.AddIngredient(ItemID.Silk, 5); - r.AddRecipeGroup("AnyCopperBar", 2); - r.AddTile(TileID.Loom); - r.Register(); - r.DisableDecraft(); - - // Bug Net - r = Recipe.Create(ItemID.BugNet); - r.AddIngredient(ItemID.Cobweb, 30); - r.AddRecipeGroup("AnyCopperBar", 3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - // Bloody Tear - r = Recipe.Create(ItemID.BloodMoonStarter); + Recipe r = Recipe.Create(ItemID.BloodMoonStarter); r.AddIngredient(10); r.AddRecipeGroup("AnyCopperBar", 3); r.AddTile(TileID.Anvils); r.Register(); r.DisableDecraft(); - // Staff of Regrowth - r = Recipe.Create(ItemID.StaffofRegrowth); - r.AddIngredient(ItemID.RichMahogany, 10); - r.AddIngredient(ItemID.JungleSpores, 5); - r.AddIngredient(ItemID.JungleRose); - r.AddTile(TileID.WorkBenches); - r.Register(); - r.DisableDecraft(); - - // Sky Mill - r = Recipe.Create(ItemID.SkyMill); - r.AddIngredient(ItemID.SunplateBlock, 10); - r.AddIngredient(ItemID.Cloud, 5); - r.AddIngredient(ItemID.RainCloud, 3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Ice Machine - r = Recipe.Create(ItemID.IceMachine); - r.AddRecipeGroup("AnyIceBlock", 10); - r.AddRecipeGroup("AnySnowBlock", 5); - r.AddRecipeGroup("IronBar", 5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Bast Statue - r = Recipe.Create(ItemID.CatBast); - r.AddRecipeGroup("IronBar", 7); - r.AddRecipeGroup("AnyGoldBar", 3); - r.AddIngredient(ItemID.Ruby); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Encumbering Stone - r = Recipe.Create(ItemID.EncumberingStone); - r.AddIngredient(ItemID.StoneBlock, 100); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Desert Minecart - r = Recipe.Create(ItemID.DesertMinecart); - r.AddIngredient(ItemID.SandstoneBrick, 20); - r.AddRecipeGroup("AnyGoldBar", 6); - r.AddRecipeGroup("IronBar", 3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - } - #endregion - - #region Boss Summon and Progression Items - private static void AddSummonAndProgressionRecipes() - { - // Guide Voodoo Doll - Recipe r = Recipe.Create(ItemID.GuideVoodooDoll); - r.AddIngredient(ItemID.Leather, 2); - r.AddRecipeGroup(AnyEvilPowder, 10); - r.AddTile(TileID.Hellforge); - r.Register(); - r.DisableDecraft(); - - // Frost Legion recipe for consistency + // Snow Globe (Frost Legion) recipe for consistency r = Recipe.Create(ItemID.SnowGlobe); r.AddRecipeGroup(AnySnowBlock, 10); r.AddIngredient(ItemID.Glass, 5); @@ -1404,41 +1418,39 @@ namespace CalamityMod.Systems r.Register(); r.DisableDecraft(); - // Temple Key - r = Recipe.Create(ItemID.TempleKey); - r.AddIngredient(ItemID.JungleSpores, 15); - r.AddIngredient(ItemID.RichMahogany, 10); - r.AddIngredient(ItemID.SoulofLight, 5); - r.AddIngredient(ItemID.SoulofNight, 5); - r.AddTile(TileID.MythrilAnvil); + // Umbrella (for Temporal Umbrella) + r = Recipe.Create(ItemID.Umbrella); + r.AddIngredient(ItemID.Silk, 5); + r.AddRecipeGroup("AnyCopperBar", 2); + r.AddTile(TileID.Loom); + r.Register(); + + // Lower half Desert items (these are partially destroyed by Sunken Sea) + // Bast Statue + r = Recipe.Create(ItemID.CatBast); + r.AddRecipeGroup("IronBar", 7); + r.AddRecipeGroup("AnyGoldBar", 3); + r.AddIngredient(ItemID.Ruby); + r.AddTile(TileID.Anvils); + r.Register(); + + // Encumbering Stone + r = Recipe.Create(ItemID.EncumberingStone); + r.AddIngredient(ItemID.StoneBlock, 100); + r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); } #endregion #region Early Game Weapons private static void AddEarlyGameWeaponRecipes() { - // Shuriken - Recipe r = Recipe.Create(ItemID.Shuriken, 50); - r.AddRecipeGroup("IronBar"); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Throwing Knife - r = Recipe.Create(ItemID.ThrowingKnife, 50); - r.AddRecipeGroup("IronBar"); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - + // Wooden Chest weapons // Wooden Boomerang - r = Recipe.Create(ItemID.WoodenBoomerang); + Recipe r = Recipe.Create(ItemID.WoodenBoomerang); r.AddIngredient(ItemID.Wood, 7); r.AddTile(TileID.WorkBenches); r.Register(); - r.DisableDecraft(); // Wand of Sparking r = Recipe.Create(ItemID.WandofSparking); @@ -1448,43 +1460,23 @@ namespace CalamityMod.Systems r.AddCondition(Condition.NotRemixWorld); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); + // Early game minions // Finch Staff r = Recipe.Create(ItemID.BabyBirdStaff); r.AddIngredient(ItemID.Bird); r.AddRecipeGroup("Wood", 8); r.AddTile(TileID.WorkBenches); r.Register(); - r.DisableDecraft(); - // Starfury w/ Gold Broadsword - r = Recipe.Create(ItemID.Starfury); - r.AddIngredient(ItemID.GoldBroadsword); - r.AddIngredient(ItemID.FallenStar, 10); - r.AddIngredient(3); + // Slime Staff + r = Recipe.Create(ItemID.SlimeStaff); + r.AddRecipeGroup("Wood", 6); + r.AddIngredient(ItemID.Gel, 40); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); - - // Starfury w/ Platinum Broadsword - r = Recipe.Create(ItemID.Starfury); - r.AddIngredient(ItemID.PlatinumBroadsword); - r.AddIngredient(ItemID.FallenStar, 10); - r.AddIngredient(3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Enchanted Boomerang - r = Recipe.Create(ItemID.EnchantedBoomerang); - r.AddIngredient(ItemID.WoodenBoomerang); - r.AddIngredient(ItemID.FallenStar, 6); - r.AddRecipeGroup(AnyGoldBar, 8); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); + // Key sword components // Enchanted Sword r = Recipe.Create(ItemID.EnchantedSword); r.AddIngredient(10); @@ -1495,6 +1487,14 @@ namespace CalamityMod.Systems r.Register(); r.DisableDecraft(); + // Starfury + r = Recipe.Create(ItemID.Starfury); + r.AddIngredient(7); + r.AddIngredient(ItemID.FallenStar, 10); + r.AddTile(TileID.Anvils); + r.Register(); + r.DisableDecraft(); + // Muramasa r = Recipe.Create(ItemID.Muramasa); r.AddIngredient(7); @@ -1503,7 +1503,7 @@ namespace CalamityMod.Systems r.Register(); r.DisableDecraft(); - // Water Bolt w/ Hardmode Spell Tome + // Water Bolt r = Recipe.Create(ItemID.WaterBolt); r.AddIngredient(ItemID.SpellTome); r.AddIngredient(ItemID.Waterleaf, 3); @@ -1511,105 +1511,31 @@ namespace CalamityMod.Systems r.AddTile(TileID.Bookcases); r.Register(); r.DisableDecraft(); - - // Slime Staff - r = Recipe.Create(ItemID.SlimeStaff); - r.AddRecipeGroup("Wood", 6); - r.AddIngredient(ItemID.Gel, 40); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Ice Boomerang - r = Recipe.Create(ItemID.IceBoomerang); - r.AddIngredient(ItemID.WoodenBoomerang); - r.AddRecipeGroup(AnyIceBlock, 20); - r.AddRecipeGroup(AnySnowBlock, 10); - r.AddIngredient(ItemID.Shiverthorn); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); } #endregion #region Early Game Accessories private static void AddEarlyGameAccessoryRecipes() { - // Cloud in a Bottle - Recipe r = Recipe.Create(ItemID.CloudinaBottle); - r.AddIngredient(ItemID.Bottle); - r.AddIngredient(ItemID.Cloud, 5); - r.AddIngredient(ItemID.Feather, 2); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Step Stool - r = Recipe.Create(ItemID.PortableStool); + // Step Stool (replaced Chest item) + Recipe r = Recipe.Create(ItemID.PortableStool); r.AddRecipeGroup("Wood", 10); r.AddTile(TileID.Sawmill); r.Register(); - r.DisableDecraft(); + #region Terraspark Boots Line // Hermes Boots r = Recipe.Create(ItemID.HermesBoots); r.AddIngredient(ItemID.Silk, 10); r.AddIngredient(ItemID.SwiftnessPotion, 5); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); - - // Blizzard in a Bottle - r = Recipe.Create(ItemID.BlizzardinaBottle); - r.AddIngredient(ItemID.Bottle); - r.AddIngredient(ItemID.Cloud, 5); - r.AddRecipeGroup(AnySnowBlock, 5); - r.AddIngredient(ItemID.Feather, 3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Sandstorm in a Bottle - r = Recipe.Create(ItemID.SandstorminaBottle); - r.AddIngredient(ItemID.Bottle); - r.AddIngredient(ItemID.Cloud, 5); - r.AddIngredient(ItemID.SandBlock, 5); - r.AddIngredient(3); - r.AddIngredient(ItemID.Feather, 3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Frog Leg - r = Recipe.Create(ItemID.FrogLeg); - r.AddIngredient(ItemID.Frog, 6); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Fledgling Wings - r = Recipe.Create(ItemID.CreativeWings); - r.AddIngredient(ItemID.Cloud, 5); - r.AddIngredient(ItemID.Feather, 10); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Flying Carpet - r = Recipe.Create(ItemID.FlyingCarpet); - r.AddIngredient(ItemID.Silk, 10); - r.AddIngredient(ItemID.AntlionMandible, 2); - r.AddIngredient(5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); // Aglet r = Recipe.Create(ItemID.Aglet); r.AddRecipeGroup(AnyCopperBar, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); // Anklet of the Wind r = Recipe.Create(ItemID.AnkletoftheWind); @@ -1618,7 +1544,13 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.PinkGel, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); + + // Ice Skates + r = Recipe.Create(ItemID.IceSkates); + r.AddIngredient(ItemID.FlinxFur, 3); + r.AddRecipeGroup("IronBar", 5); + r.AddTile(TileID.Anvils); + r.Register(); // Water Walking Boots r = Recipe.Create(ItemID.WaterWalkingBoots); @@ -1626,40 +1558,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.WaterWalkingPotion, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); - - // Flame Waker Boots - r = Recipe.Create(ItemID.FlameWakerBoots); - r.AddIngredient(ItemID.Silk, 8); - r.AddIngredient(ItemID.HellstoneBar, 5); - r.AddIngredient(ItemID.Obsidian, 4); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Ice Skates - r = Recipe.Create(ItemID.IceSkates); - r.AddIngredient(ItemID.Leather, 5); - r.AddRecipeGroup("IronBar", 5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Lucky Horseshoe - r = Recipe.Create(ItemID.LuckyHorseshoe); - r.AddRecipeGroup(AnyGoldBar, 8); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Shiny Red Balloon - r = Recipe.Create(ItemID.ShinyRedBalloon); - r.AddIngredient(ItemID.WhiteString); - r.AddIngredient(ItemID.Gel, 15); - r.AddIngredient(ItemID.Cloud, 5); - r.AddTile(TileID.Solidifier); - r.Register(); - r.DisableDecraft(); // Lava Charm r = Recipe.Create(ItemID.LavaCharm); @@ -1677,38 +1575,90 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.Hellstone, 5); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); + #endregion - // Feral Claws - r = Recipe.Create(ItemID.FeralClaws); - r.AddIngredient(ItemID.Leather, 10); + #region Core Movement Accessories + // Blizzard in a Bottle + r = Recipe.Create(ItemID.BlizzardinaBottle); + r.AddIngredient(ItemID.Bottle); + r.AddIngredient(ItemID.Cloud, 5); + r.AddRecipeGroup(AnySnowBlock, 5); + r.AddIngredient(ItemID.Feather, 3); + r.AddTile(TileID.Anvils); + r.Register(); + + // Cloud in a Bottle + r = Recipe.Create(ItemID.CloudinaBottle); + r.AddIngredient(ItemID.Bottle); + r.AddIngredient(ItemID.Cloud, 5); + r.AddIngredient(ItemID.Feather, 2); + r.AddTile(TileID.Anvils); + r.Register(); + + // Sandstorm in a Bottle + r = Recipe.Create(ItemID.SandstorminaBottle); + r.AddIngredient(ItemID.Bottle); + r.AddIngredient(ItemID.Cloud, 5); + r.AddIngredient(ItemID.SandBlock, 5); + r.AddIngredient(3); + r.AddIngredient(ItemID.Feather, 3); r.AddTile(TileID.Anvils); r.Register(); r.DisableDecraft(); - // Radar - r = Recipe.Create(ItemID.Radar); - r.AddRecipeGroup("IronBar", 5); + // Fledgling Wings + r = Recipe.Create(ItemID.CreativeWings); + r.AddIngredient(ModContent.ItemType(), 2); + r.AddIngredient(ItemID.Cloud, 5); + r.AddIngredient(ItemID.Feather, 10); r.AddTile(TileID.Anvils); r.Register(); - r.DisableDecraft(); - // Metal Detector - r = Recipe.Create(ItemID.MetalDetector); - r.AddIngredient(ItemID.Wire, 10); - r.AddIngredient(ItemID.SpelunkerGlowstick, 5); - r.AddRecipeGroup(AnyCopperBar, 5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Hand Warmer - r = Recipe.Create(ItemID.HandWarmer); + // Flying Carpet + r = Recipe.Create(ItemID.FlyingCarpet); r.AddIngredient(ItemID.Silk, 10); - r.AddTile(TileID.Loom); + r.AddIngredient(ItemID.AntlionMandible, 2); + r.AddIngredient(5); + r.AddTile(TileID.Anvils); r.Register(); r.DisableDecraft(); + // Frog Leg + r = Recipe.Create(ItemID.FrogLeg); + r.AddIngredient(ItemID.Frog, 6); + r.AddTile(TileID.Anvils); + r.Register(); + r.DisableDecraft(); + + // Lucky Horseshoe + r = Recipe.Create(ItemID.LuckyHorseshoe); + r.AddRecipeGroup(AnyGoldBar, 8); + r.AddTile(TileID.Anvils); + r.Register(); + + // Shiny Red Balloon + r = Recipe.Create(ItemID.ShinyRedBalloon); + r.AddIngredient(ItemID.WhiteString); + r.AddIngredient(ItemID.Cloud, 10); + r.AddTile(TileID.Solidifier); + r.Register(); + #endregion + + // Cobalt Shield + r = Recipe.Create(ItemID.CobaltShield); + r.AddRecipeGroup(AnyCobaltBar, 5); + r.AddTile(TileID.Anvils); + r.Register(); + r.DisableDecraft(); + + // Flame Waker Boots + r = Recipe.Create(ItemID.FlameWakerBoots); + r.AddIngredient(ItemID.Silk, 8); + r.AddIngredient(ItemID.HellstoneBar, 5); + r.AddIngredient(ItemID.Obsidian, 4); + r.AddTile(TileID.Anvils); + r.Register(); + // Flower Boots r = Recipe.Create(ItemID.FlowerBoots); r.AddIngredient(ItemID.Silk, 7); @@ -1716,223 +1666,58 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.JungleGrassSeeds, 5); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); + + // Hand Warmer + r = Recipe.Create(ItemID.HandWarmer); + r.AddIngredient(ItemID.Silk, 10); + r.AddTile(TileID.Loom); + r.Register(); + + // Radar + r = Recipe.Create(ItemID.Radar); + r.AddRecipeGroup("IronBar", 5); + r.AddTile(TileID.Anvils); + r.Register(); + + //Bobber + r = Recipe.Create(ItemID.FishingBobber); + r.AddIngredient(10); + r.AddIngredient(ItemID.BlackPearl); + r.AddRecipeGroup("IronBar"); + r.AddTile(TileID.Anvils); + r.Register(); } #endregion #region Armor private static void AddArmorRecipes() { - // Eskimo armor + // Snow armor Recipe r = Recipe.Create(ItemID.EskimoHood); r.AddIngredient(ItemID.Silk, 4); - r.AddIngredient(ItemID.Leather, 2); + r.AddIngredient(ItemID.FlinxFur, 1); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); r = Recipe.Create(ItemID.EskimoCoat); r.AddIngredient(ItemID.Silk, 8); - r.AddIngredient(ItemID.Leather, 4); + r.AddIngredient(ItemID.FlinxFur, 2); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); r = Recipe.Create(ItemID.EskimoPants); r.AddIngredient(ItemID.Silk, 6); - r.AddIngredient(ItemID.Leather, 3); + r.AddIngredient(ItemID.FlinxFur, 1); r.AddTile(TileID.Loom); r.Register(); - r.DisableDecraft(); - - // Pharaoh set - r = Recipe.Create(ItemID.PharaohsMask); - r.AddIngredient(ItemID.AncientCloth, 3); - r.AddTile(TileID.Loom); - r.Register(); - r.DisableDecraft(); - - r = Recipe.Create(ItemID.PharaohsRobe); - r.AddIngredient(ItemID.AncientCloth, 4); - r.AddTile(TileID.Loom); - r.Register(); - r.DisableDecraft(); - } - #endregion - - #region Ankh Shield Components - private static void AddAnkhShieldRecipes() - { - // Cobalt Shield - Recipe r = Recipe.Create(ItemID.CobaltShield); - r.AddRecipeGroup(AnyCobaltBar, 5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Armor Polish (broken armor) - r = Recipe.Create(ItemID.ArmorPolish); - r.AddIngredient(ItemID.Bone, 10); - r.AddIngredient(3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Adhesive Bandage (bleeding) - r = Recipe.Create(ItemID.AdhesiveBandage); - r.AddIngredient(ItemID.Silk, 10); - r.AddIngredient(ItemID.Gel, 10); - r.AddIngredient(ItemID.HealingPotion); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Bezoar (poison) - r = Recipe.Create(ItemID.Bezoar); - r.AddIngredient(ItemID.JungleSpores, 15); - r.AddIngredient(ItemID.Stinger, 5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Nazar (curse) - r = Recipe.Create(ItemID.Nazar); - r.AddIngredient(ItemID.SoulofNight, 5); - r.AddIngredient(ItemID.Lens, 3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Vitamins (weakness) - r = Recipe.Create(ItemID.Vitamins); - r.AddIngredient(ItemID.BottledWater); - r.AddIngredient(ItemID.Waterleaf, 3); - r.AddIngredient(ItemID.Blinkroot, 3); - r.AddIngredient(ItemID.Daybloom, 3); - r.AddIngredient(5); - r.AddTile(TileID.AlchemyTable); - r.Register(); - r.DisableDecraft(); - - // Blindfold (darkness) - r = Recipe.Create(ItemID.Blindfold); - r.AddIngredient(ItemID.Silk, 10); - r.AddIngredient(ItemID.TatteredCloth); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Trifold Map (confusion) - r = Recipe.Create(ItemID.TrifoldMap); - r.AddIngredient(ItemID.Silk, 10); - r.AddIngredient(ItemID.SoulofLight, 3); - r.AddIngredient(ItemID.SoulofNight, 3); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Fast Clock (slow) - r = Recipe.Create(ItemID.FastClock); - r.AddIngredient(ItemID.Timer1Second); - r.AddIngredient(ItemID.PixieDust, 5); - r.AddIngredient(ItemID.SoulofLight, 5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Megaphone (silence) - r = Recipe.Create(ItemID.Megaphone); - r.AddIngredient(ItemID.Wire, 5); - r.AddRecipeGroup(AnyCobaltBar, 3); - r.AddIngredient(ItemID.Ruby); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Pocket Mirror (petrification) - r = Recipe.Create(ItemID.PocketMirror); - r.AddIngredient(ItemID.Glass, 5); - r.AddRecipeGroup(AnyGoldBar, 3); - r.AddIngredient(ItemID.CrystalShard, 2); - r.AddIngredient(ItemID.SoulofNight, 2); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - } - #endregion - - #region Living Wood - private static void AddLivingWoodRecipes() - { - // Living Loom - Recipe r = Recipe.Create(ItemID.LivingLoom); - r.AddIngredient(ItemID.Loom); - r.AddIngredient(ItemID.Vine, 2); - r.AddTile(TileID.Sawmill); - r.Register(); - r.DisableDecraft(); - - // Living Wood Wand - r = Recipe.Create(ItemID.LivingWoodWand); - r.AddIngredient(ItemID.Wood, 10); - r.AddTile(TileID.LivingLoom); - r.Register(); - r.DisableDecraft(); - - // Living Leaf Wand - r = Recipe.Create(ItemID.LeafWand); - r.AddIngredient(ItemID.Wood, 10); - r.AddTile(TileID.LivingLoom); - r.Register(); - r.DisableDecraft(); - - // Living Mahogany Wand - r = Recipe.Create(ItemID.LivingMahoganyWand); - r.AddIngredient(ItemID.RichMahogany, 10); - r.AddTile(TileID.LivingLoom); - r.Register(); - r.DisableDecraft(); - - // Living Mahogany Leaf Wand - r = Recipe.Create(ItemID.LivingMahoganyLeafWand); - r.AddIngredient(ItemID.RichMahogany, 10); - r.AddTile(TileID.LivingLoom); - r.Register(); - r.DisableDecraft(); } #endregion #region Hardmode Items and Accessories private static void AddHardmodeItemRecipes() { - // Celestial Magnet - Recipe r = Recipe.Create(ItemID.CelestialMagnet); - r.AddIngredient(ItemID.TreasureMagnet); - r.AddIngredient(ItemID.FallenStar, 5); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Frozen Turtle Shell - r = Recipe.Create(ItemID.FrozenTurtleShell); - r.AddIngredient(ItemID.TurtleShell, 2); - r.AddIngredient(4); - r.AddTile(TileID.Anvils); - r.Register(); - r.DisableDecraft(); - - // Magic Quiver - r = Recipe.Create(ItemID.MagicQuiver); - r.AddIngredient(ItemID.EndlessQuiver); - r.AddIngredient(ItemID.PixieDust, 5); - r.AddIngredient(ItemID.Lens, 3); - r.AddIngredient(ItemID.SoulofLight, 5); - r.AddTile(TileID.CrystalBall); - r.Register(); - r.DisableDecraft(); - // Pulse Bow - r = Recipe.Create(ItemID.PulseBow); + Recipe r = Recipe.Create(ItemID.PulseBow); r.AddIngredient(ItemID.ShroomiteBar, 16); r.AddTile(TileID.MythrilAnvil); r.Register(); @@ -1946,35 +1731,12 @@ namespace CalamityMod.Systems r.Register(); r.DisableDecraft(); - // Mechanical Glove directly from correct class emblem for cheaper (compromise) - r = Recipe.Create(ItemID.MechanicalGlove); - r.AddIngredient(ItemID.PowerGlove); - r.AddIngredient(ItemID.WarriorEmblem); - r.AddIngredient(ItemID.SoulofFright); - r.AddIngredient(ItemID.SoulofMight); - r.AddIngredient(ItemID.SoulofSight); - r.AddTile(TileID.TinkerersWorkbench); - r.Register(); - r.DisableDecraft(); - - // Celestial Emblem directly from correct class emblem for cheaper (compromise) - r = Recipe.Create(ItemID.CelestialEmblem); - r.AddIngredient(ItemID.CelestialMagnet); - r.AddIngredient(ItemID.SorcererEmblem); - r.AddIngredient(ItemID.SoulofFright); - r.AddIngredient(ItemID.SoulofMight); - r.AddIngredient(ItemID.SoulofSight); - r.AddTile(TileID.TinkerersWorkbench); - r.Register(); - r.DisableDecraft(); - // Tiershift Mini Nuke 1s to post Moon Lord. r = Recipe.Create(ItemID.MiniNukeI, 333); r.AddIngredient(ItemID.RocketIII, 333); r.AddIngredient(ItemID.LunarBar); r.AddTile(TileID.LunarCraftingStation); r.Register(); - r.DisableDecraft(); // Tiershift Mini Nuke 2s to post Moon Lord. r = Recipe.Create(ItemID.MiniNukeII, 333); @@ -1982,7 +1744,6 @@ namespace CalamityMod.Systems r.AddIngredient(ItemID.LunarBar); r.AddTile(TileID.LunarCraftingStation); r.Register(); - r.DisableDecraft(); } #endregion diff --git a/Systems/Mechanic/SpeedrunTimerSystem.cs b/Systems/Mechanic/SpeedrunTimerSystem.cs index 0a62f90e60..f5a2226b32 100644 --- a/Systems/Mechanic/SpeedrunTimerSystem.cs +++ b/Systems/Mechanic/SpeedrunTimerSystem.cs @@ -1,12 +1,7 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using CalamityMod.CalPlayer; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; namespace CalamityMod.Systems { diff --git a/Systems/Mechanic/StratusStarburstSystem.cs b/Systems/Mechanic/StratusStarburstSystem.cs new file mode 100644 index 0000000000..5439831916 --- /dev/null +++ b/Systems/Mechanic/StratusStarburstSystem.cs @@ -0,0 +1,165 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer.DrawLayers; +using CalamityMod.DataStructures; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Systems.Graphic.PixelationSystem; +using CalamityMod.Utilities.Daybreak; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Mechanic +{ + public class StarburstEntity + { + private sealed class StarburstManager : ModPlayer + { + //Done with a ref to CalamityPlayer so that it's easy for other code to get this value with Player.Calamity() + public ref List StarburstEntities => ref Player.Calamity().StarburstEntities; + public override void PostUpdate() + { + + for (var i = 0; i < StarburstEntities.Count; i++) + { + StarburstEntity star = StarburstEntities[i]; + star.AI(Player, i); + star.UpdatePosition(); + star.UpdateAnimation(); + var safeStarLooper = star.MergeChildren.ToList(); + foreach (var ministar in safeStarLooper) + { + ministar.AI(Player, i); + ministar.UpdatePosition(); + ministar.UpdateAnimation(); + } + } + } + public override void DrawEffects(PlayerDrawSet drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) + { + if (StarburstEntities.Count > 0 && drawInfo.shadow == 0f) + { + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //This uses the same star and glow textures that the constellations use, so we're just getting the static textures Draco uses to prevent needless requests + var tex = TextureAssets.Projectile[ModContent.ProjectileType()].Value; + var glowTex = DracoConstellation.GetGlowTex(); + for (var i = 0; i < StarburstEntities.Count; i++) + { + StarburstEntity star = StarburstEntities[i]; + var color = star.color; + var value = star.value; + value -= star.MergeChildren.Count; + var ScaleMod = MathHelper.Lerp(0.4f, 0.8f, value / 10f); + + Main.spriteBatch.Draw(glowTex, star.Center - Main.screenPosition, null, star.color * 0.66f, 0, glowTex.Size() * 0.5f, 0.2f * star.scale * ScaleMod, SpriteEffects.None, 1); + Main.spriteBatch.Draw(tex, star.Center - Main.screenPosition, null, star.color * 0.66f, MathHelper.WrapAngle(Main.GlobalTimeWrappedHourly + i), tex.Size() * 0.5f, 0.75f * star.scale * ScaleMod, SpriteEffects.None, 1); + for (var i2 = 0; i2 < star.MergeChildren.Count; i2++) + { + var ministar = star.MergeChildren[i2]; + ScaleMod = MathHelper.Lerp(0.4f, 0.8f, ministar.value / 10f); + Main.spriteBatch.Draw(glowTex, ministar.Center - Main.screenPosition, null, ministar.color * 0.66f, 0, glowTex.Size() * 0.5f, 0.2f * ministar.scale * ScaleMod, SpriteEffects.None, 1); + Main.spriteBatch.Draw(tex, ministar.Center - Main.screenPosition, null, ministar.color * 0.66f, MathHelper.WrapAngle(Main.GlobalTimeWrappedHourly + i), tex.Size() * 0.5f, 0.75f * ministar.scale * ScaleMod, SpriteEffects.None, 1); + } + } + Main.spriteBatch.End(); + } + } + } + } + + public Vector2 Center = Vector2.Zero; + public Vector2 Velocity = Vector2.Zero; + /// + /// How long before the starburst resumes normal following AI + /// + public int AICooldown = 0; + public int frameCounter = 0; + public int frame = 0; + public int value = 1; + public float scale = 1f; + public float opacity = 1; + public Color color = Color.Black; + public StarburstEntity MergeTarget = null; + public List MergeChildren = new(); + public bool ShouldRemoveFromList = false; + + public StarburstEntity(Vector2 position, bool shouldRandomize = true) + { + Center = position; + if (shouldRandomize) + { + Velocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * 3; + } + switch (Main.rand.Next(1, 7)) + { + case 1: + color = Color.HotPink; + break; + case 2: + color = Color.Yellow; + break; + case 3: + color = Color.LimeGreen; + break; + case 4: + color = Color.SkyBlue; + break; + case 5: + color = Color.Lavender; + break; + case 6: + color = Color.White; + break; + } + color = Color.Lerp(Color.White, color, 0.5f); + } + public void AI(Player owner, int index = 0) + { + if (AICooldown > 0) + { + MergeChildren = new(); + AICooldown--; + return; + } + if (MergeTarget != null) + { + Velocity += Center.DirectionTo(MergeTarget.Center) * 2.5f; + Velocity *= 0.925f; + if (Center.Distance(MergeTarget.Center) < 12) + MergeTarget.MergeChildren.Remove(this); + return; + } + if (Center.Distance(owner.Center) > 100) + { + Velocity += Center.DirectionTo(owner.Center + new Vector2(16, 0).RotatedBy(index)).RotatedByRandom(0.3f); + Velocity *= 0.95f; + } + } + + public void UpdatePosition() + { + Center += Velocity; + } + + public void UpdateAnimation() + { + frameCounter++; + if (frameCounter > 6) + { + frame++; + frameCounter = 0; + } + if (frame > 5) + frame = 0; + } + } +} diff --git a/Systems/Mechanic/TilePingerSystem.PingEffects.cs b/Systems/Mechanic/TilePingerSystem.PingEffects.cs new file mode 100644 index 0000000000..0627884742 --- /dev/null +++ b/Systems/Mechanic/TilePingerSystem.PingEffects.cs @@ -0,0 +1,329 @@ +using System; +using CalamityMod.Effects; +using CalamityMod.Items.Tools; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Effects; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Systems.Mechanic; + +public class WulfrumPingTileEffect : IPingedTileEffect, ILoadable +{ + public static string EffectName => "WulfrumPing"; + public static WulfrumPingTileEffect Instance { get; private set; } + + internal static Texture2D emptyFrame; + public const int MaxPingLife = 350; + public const int MaxPingTravelTime = 60; + const float PingWaveThickness = 50f; + + public const float MaxPingRadius = 1700f; + public static Vector2 PingCenter = Vector2.Zero; + public static int PingTimer = 0; + public static float PingProgress => (MaxPingLife - PingTimer) / (float)MaxPingLife; + + public bool Active => PingTimer > 0; + + public BlendState BlendState => BlendState.Additive; + + void ILoadable.Load(Mod mod) + { + Instance = this; + TilePingerSystem.RegisterEffect(EffectName, this); + } + + void ILoadable.Unload() + { + Instance = null; + } + + public bool TryAddPing(Vector2 position, Player pinger) + { + //Only one ping at a time + if (Active) + return false; + + PingCenter = position; + PingTimer = MaxPingLife; + return true; + } + + public Effect SetupEffect() + { + emptyFrame ??= ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + + Effect tileEffect = Filters.Scene["CalamityMod:WulfrumTilePing"].GetShader().Shader; + tileEffect.Parameters["pingCenter"].SetValue(PingCenter); + tileEffect.Parameters["pingRadius"].SetValue(MaxPingRadius); + tileEffect.Parameters["pingWaveThickness"].SetValue(PingWaveThickness); + tileEffect.Parameters["pingProgress"].SetValue(PingProgress); + tileEffect.Parameters["pingTravelTime"].SetValue(MaxPingTravelTime / (float)MaxPingLife); + tileEffect.Parameters["pingFadePoint"].SetValue(0.9f); + tileEffect.Parameters["edgeBlendStrength"].SetValue(1f); + tileEffect.Parameters["edgeBlendOutLength"].SetValue(6f); + tileEffect.Parameters["tileEdgeBlendStrenght"].SetValue(2f); + + tileEffect.Parameters["waveColor"].SetValue(Color.GreenYellow.ToVector4()); + tileEffect.Parameters["baseTintColor"].SetValue(Color.DeepSkyBlue.ToVector4() * 0.5f); + tileEffect.Parameters["scanlineColor"].SetValue(Color.YellowGreen.ToVector4() * 1f); + tileEffect.Parameters["tileEdgeColor"].SetValue(Color.GreenYellow.ToVector3()); + tileEffect.Parameters["Resolution"].SetValue(8f); + + tileEffect.Parameters["time"].SetValue(Main.GameUpdateCount); + Vector4[] scanLines = + [ + new Vector4(0f, 4f, 0.1f, 0.5f), + new Vector4(1f, 4f, 0.1f, 0.5f), + new Vector4(37f, 60f, 0.4f, 1f), + new Vector4(2f, 6f, -0.2f, 0.3f), + new Vector4(0f, 4f, 0.1f, 0.5f), //vertical start + new Vector4(1f, 4f, 0.1f, 0.5f), + new Vector4(2f, 6f, -0.2f, 0.3f) + ]; + + tileEffect.Parameters["ScanLines"].SetValue(scanLines); + tileEffect.Parameters["ScanLinesCount"].SetValue(scanLines.Length); + tileEffect.Parameters["verticalScanLinesIndex"].SetValue(4); + + return tileEffect; + } + + public void PerTileSetup(Point pos, ref Effect effect) + { + //Up, left, right, down. + effect.Parameters["cardinalConnections"].SetValue(new bool[] { Connected(pos, 0, -1), Connected(pos, -1, 0), Connected(pos, 1, 0), Connected(pos, 0, 1) }); + effect.Parameters["tilePosition"].SetValue(pos.ToVector2() * 16f); + } + + public static bool Connected(Point pos, int displaceX, int displaceY) + { + return Main.IsTileSpelunkable(pos.X + displaceX, pos.Y + displaceY) + && Main.tile[pos].TileType == Main.tile[pos.X + displaceX, pos.Y + displaceY].TileType; + } + + public bool ShouldRegisterTile(int x, int y) + { + return Main.IsTileSpelunkable(x, y); + } + + public void ModifyTileLight(int x, int y, Color tileLight, ref Color resultColor) + { + float distanceFromCenter = (new Point(x, y).ToWorldCoordinates() - PingCenter).Length(); + float currentExpansion = MathHelper.Clamp(PingProgress * MaxPingLife / (float)MaxPingTravelTime, 0f, 1f) * MaxPingRadius; + + if (distanceFromCenter - 8 > currentExpansion) + return; + + float brightness = 1f; + Tile tile = Framing.GetTileSafely(x, y); + //Counteracts slopes and half tiles being too bright + if (tile.Slope != SlopeType.Solid || tile.IsHalfBlock) + brightness = 0.64f; + + //Fade on the edges + if (distanceFromCenter + 8 > currentExpansion) + brightness *= 1 - (distanceFromCenter - currentExpansion + 8f) / 16f; + + //Fade away with the effect + brightness *= 1 - Math.Max(PingProgress - 0.9f, 0) / (0.1f); + + if (tileLight.R < 200 * brightness) tileLight.R = (byte)(200 * brightness); + if (tileLight.G < 200 * brightness) tileLight.G = (byte)(200 * brightness); + if (tileLight.B < 200 * brightness) tileLight.B = (byte)(200 * brightness); + resultColor = tileLight; + } + + public void DrawTile(Point pos) + { + Main.spriteBatch.Draw(emptyFrame, pos.ToWorldCoordinates() - Main.screenPosition, null, Color.White, 0, new Vector2(emptyFrame.Width / 2f, emptyFrame.Height / 2f), 16f, 0, 0); + } + + // CIT 16JUL2025: Tile lighting override is now applied via an On edit; this code is duplicated there, and thus is no longer needed here. + /*public void EditDrawData(int i, int j, ref TileDrawInfo drawData) + { + float distanceFromCenter = (new Point(i, j).ToWorldCoordinates() - PingCenter).Length(); + float currentExpansion = MathHelper.Clamp(PingProgress * MaxPingLife / (float)MaxPingTravelTime, 0f, 1f) * MaxPingRadius; + + if (distanceFromCenter - 8 > currentExpansion) + return; + + float brightness = 1f; + Tile tile = Framing.GetTileSafely(i, j); + //Counteracts slopes and half tiles being too bright + if (tile.Slope != SlopeType.Solid || tile.IsHalfBlock) + brightness = 0.64f; + + //Fade on the edges + if (distanceFromCenter + 8 > currentExpansion) + brightness *= 1 - (distanceFromCenter - currentExpansion + 8f) / 16f; + + //Fade away with the effect + brightness *= 1 - Math.Max(PingProgress - 0.9f, 0) / (0.1f); + + if (drawData.tileLight.R < 200 * brightness) drawData.tileLight.R = (byte)(200 * brightness); + if (drawData.tileLight.G < 200 * brightness) drawData.tileLight.G = (byte)(200 * brightness); + if (drawData.tileLight.B < 200 * brightness) drawData.tileLight.B = (byte)(200 * brightness); + }*/ + + public void UpdateEffect() + { + if (PingTimer > 0) + { + PingTimer--; + + //if the effect ended (and the player has a treasure pigner in their inventory, of course), play a recharge beep + if (PingTimer == 0 && Main.LocalPlayer.InventoryHas(ModContent.ItemType())) + SoundEngine.PlaySound(WulfrumTreasurePinger.RechargeBeepSound); + } + } +} + +public class BurrowerPingTileEffect : IPingedTileEffect, ILoadable +{ + public static string EffectName => "BurrowerPing"; + public static BurrowerPingTileEffect Instance { get; private set; } + + internal static Texture2D emptyFrame; + public const int MaxPingLife = 60; + public const int MaxPingTravelTime = 10; + const float PingWaveThickness = 50f; + + public const float MaxPingRadius = 160; + public static Vector2 PingCenter = Vector2.Zero; + public static int PingTimer = 0; + public static float PingProgress => (MaxPingLife - PingTimer) / (float)MaxPingLife; + + public bool Active => PingTimer > 0; + + public BlendState BlendState => BlendState.Additive; + + void ILoadable.Load(Mod mod) + { + Instance = this; + TilePingerSystem.RegisterEffect(EffectName, this); + } + + void ILoadable.Unload() + { + Instance = null; + } + + public bool TryAddPing(Vector2 position, Player pinger) + { + if (Active) + { + PingCenter = position; + PingTimer = Math.Max(PingTimer, MaxPingLife - MaxPingTravelTime); + return false; + } + PingCenter = position; + PingTimer = MaxPingLife; + return true; + } + + + public Effect SetupEffect() + { + if (emptyFrame == null) + emptyFrame = ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + + Effect tileEffect = Filters.Scene["CalamityMod:WulfrumTilePing"].GetShader().Shader; + tileEffect.Parameters["pingCenter"].SetValue(PingCenter); + tileEffect.Parameters["pingRadius"].SetValue(MaxPingRadius); + tileEffect.Parameters["pingWaveThickness"].SetValue(PingWaveThickness); + tileEffect.Parameters["pingProgress"].SetValue(PingProgress); + tileEffect.Parameters["pingTravelTime"].SetValue(MaxPingTravelTime / (float)MaxPingLife); + tileEffect.Parameters["pingFadePoint"].SetValue(0.9f); + tileEffect.Parameters["edgeBlendStrength"].SetValue(1f); + tileEffect.Parameters["edgeBlendOutLength"].SetValue(6f); + tileEffect.Parameters["tileEdgeBlendStrenght"].SetValue(2f); + + tileEffect.Parameters["waveColor"].SetValue(ArsenalEffects.ArsenalGaussColor.ToVector4()); + tileEffect.Parameters["baseTintColor"].SetValue(Color.Orange.ToVector4() * 0.5f); + tileEffect.Parameters["scanlineColor"].SetValue(ArsenalEffects.ArsenalLaserColor.ToVector4() * 1f); + tileEffect.Parameters["tileEdgeColor"].SetValue(ArsenalEffects.ArsenalGaussColor.ToVector3()); + tileEffect.Parameters["Resolution"].SetValue(8f); + + tileEffect.Parameters["time"].SetValue(Main.GameUpdateCount); + Vector4[] scanLines = + [ + new Vector4(0f, 4f, 0.1f, 0.5f), + new Vector4(1f, 4f, 0.1f, 0.5f), + new Vector4(37f, 60f, 0.4f, 1f), + new Vector4(2f, 6f, -0.2f, 0.3f), + new Vector4(0f, 4f, 0.1f, 0.5f), //vertical start + new Vector4(1f, 4f, 0.1f, 0.5f), + new Vector4(2f, 6f, -0.2f, 0.3f) + ]; + + tileEffect.Parameters["ScanLines"].SetValue(scanLines); + tileEffect.Parameters["ScanLinesCount"].SetValue(scanLines.Length); + tileEffect.Parameters["verticalScanLinesIndex"].SetValue(4); + + return tileEffect; + } + + public void PerTileSetup(Point pos, ref Effect effect) + { + //Up, left, right, down. + effect.Parameters["cardinalConnections"].SetValue(new bool[] { Connected(pos, 0, -1), Connected(pos, -1, 0), Connected(pos, 1, 0), Connected(pos, 0, 1) }); + effect.Parameters["tilePosition"].SetValue(pos.ToVector2() * 16f); + } + + public static bool Connected(Point pos, int displaceX, int displaceY) + { + return TileID.Sets.Ore[Main.tile[pos.X + displaceX, pos.Y + displaceY].TileType] + && Main.tile[pos].TileType == Main.tile[pos.X + displaceX, pos.Y + displaceY].TileType; + } + + public bool ShouldRegisterTile(int x, int y) + { + if (!Main.tile[x, y].HasTile) + return false; + return TileID.Sets.Ore[Main.tile[x, y].TileType]; + } + + public void ModifyTileLight(int x, int y, Color tileLight, ref Color resultColor) + { + float distanceFromCenter = (new Point(x, y).ToWorldCoordinates() - BurrowerPingTileEffect.PingCenter).Length(); + float currentExpansion = MathHelper.Clamp(BurrowerPingTileEffect.PingProgress * BurrowerPingTileEffect.MaxPingLife / (float)BurrowerPingTileEffect.MaxPingTravelTime, 0f, 1f) * BurrowerPingTileEffect.MaxPingRadius; + + if (distanceFromCenter - 8 > currentExpansion) + return; + + float brightness = 1f; + Tile tile = Framing.GetTileSafely(x, y); + //Counteracts slopes and half tiles being too bright + if (tile.Slope != SlopeType.Solid || tile.IsHalfBlock) + brightness = 0.64f; + + //Fade on the edges + if (distanceFromCenter + 8 > currentExpansion) + brightness *= 1 - (distanceFromCenter - currentExpansion + 8f) / 16f; + + //Fade away with the effect + brightness *= 1 - Math.Max(BurrowerPingTileEffect.PingProgress - 0.9f, 0) / (0.1f); + + if (tileLight.R < 200 * brightness) tileLight.R = (byte)(200 * brightness); + if (tileLight.G < 200 * brightness) tileLight.G = (byte)(200 * brightness); + if (tileLight.B < 200 * brightness) tileLight.B = (byte)(200 * brightness); + resultColor = tileLight; + } + + public void DrawTile(Point pos) + { + Main.spriteBatch.Draw(emptyFrame, pos.ToWorldCoordinates() - Main.screenPosition, null, Color.White, 0, new Vector2(emptyFrame.Width / 2f, emptyFrame.Height / 2f), 16f, 0, 0); + } + + public void UpdateEffect() + { + if (PingTimer > 0) + { + PingTimer--; + } + } +} diff --git a/Systems/Mechanic/TilePingerSystem.cs b/Systems/Mechanic/TilePingerSystem.cs index f28c9cb3b1..f073be606e 100644 --- a/Systems/Mechanic/TilePingerSystem.cs +++ b/Systems/Mechanic/TilePingerSystem.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using CalamityMod.Items.Tools; +using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; -using Terraria.Graphics.Effects; +using Terraria.GameContent.Drawing; using Terraria.Graphics.Light; using Terraria.ID; using Terraria.ModLoader; @@ -19,22 +16,26 @@ namespace CalamityMod.Systems /// The blend state of the tile effect's main shader. ///
public BlendState BlendState => BlendState.AlphaBlend; + /// /// Create and set up an effect to be drawn over all the registered tiles for this shader. /// /// The configured effect public Effect SetupEffect(); + /// /// Modifies the shader for each tile. Use this if your shader is using tile-specific data. /// /// The position of the tile /// The effect being used public void PerTileSetup(Point pos, ref Effect effect) { } + /// /// Draws the tile, or an overlay for it. The shader is automatically applied. /// /// The position of the tile public void DrawTile(Point pos); + /// /// What happens when a ping for this effect gets requested. Return false if the ping couldn't get added. /// @@ -42,10 +43,12 @@ namespace CalamityMod.Systems /// The player that initiated the ping /// Wether or not the ping's setup was successful public bool TryAddPing(Vector2 position, Player pinger); + /// /// Wether or not this effect is active. /// public bool Active => true; + /// /// Check to know if a tile needs to be drawn with this effect. This is only called if the effect is active. /// @@ -53,6 +56,16 @@ namespace CalamityMod.Systems /// /// Wether or not the tile should be drawn with the effect public bool ShouldRegisterTile(int x, int y); + + /// + /// Modify Tile Light when tile has pinged + /// + /// Tile X + /// Tile Y + /// tileLight Draw Data + /// Original Tile Color to Draw, Modify this value + public void ModifyTileLight(int x, int y, Color tileLight, ref Color resultColor); + /// /// Called after a tile has been queued to be drawn with this effect. Can be used to edit the draw data of the tile. /// @@ -60,6 +73,7 @@ namespace CalamityMod.Systems /// /// The tile's draw data public void EditDrawData(int i, int j, ref TileDrawInfo drawData) { } + /// /// Update call ran once per frame. /// @@ -68,21 +82,24 @@ namespace CalamityMod.Systems public class TilePingerSystem : ModSystem { - internal static Dictionary> pingedTiles; - internal static Dictionary> pingedNonSolidTiles; - internal static Dictionary> drawCache; + private static Dictionary> pingedTiles = []; + private static Dictionary> pingedNonSolidTiles = []; + private static Dictionary> drawCache = []; + private static Dictionary tileEffectLookup = []; + private static IPingedTileEffect[] tileEffects = []; - internal static Dictionary tileEffects; + public static void RegisterEffect(string name, IPingedTileEffect tileEffect) + { + tileEffectLookup[name] = tileEffect; + tileEffects = [.. tileEffectLookup.Values]; + } public override void Load() { if (Main.dedServ) return; - drawCache = new Dictionary>(); - pingedTiles = new Dictionary>(); - pingedNonSolidTiles = new Dictionary>(); - tileEffects = new Dictionary(); + On_TileDrawing.DrawTiles_GetLightOverride += ForceSufficientLight; } public override void Unload() @@ -90,21 +107,33 @@ namespace CalamityMod.Systems drawCache = null; pingedTiles = null; pingedNonSolidTiles = null; + tileEffectLookup = null; tileEffects = null; } + private static Color ForceSufficientLight(On_TileDrawing.orig_DrawTiles_GetLightOverride orig, TileDrawing self, int j, int i, Tile tileCache, ushort typeCache, short tileFrameX, short tileFrameY, Color tileLight) + { + Color returnColor = orig(self, j, i, tileCache, typeCache, tileFrameX, tileFrameY, tileLight); + foreach (IPingedTileEffect effect in tileEffects) + { + if (effect.Active && effect.ShouldRegisterTile(i, j)) + { + effect.ModifyTileLight(i, j, tileLight, ref returnColor); + } + } + return returnColor; + } + + public static bool AddPing(IPingedTileEffect effect, Vector2 position, Player pinger) => effect.TryAddPing(position, pinger); public static bool AddPing(string effectName, Vector2 position, Player pinger) { if (!Main.dedServ) - return AddPing(tileEffects[effectName], position, pinger); + return AddPing(tileEffectLookup[effectName], position, pinger); return false; } - public static bool AddPing(IPingedTileEffect effect, Vector2 position, Player pinger) => effect.TryAddPing(position, pinger); - - - public static void RegisterTileToDraw(Point tilePos, string effectName, bool solid = true) => RegisterTileToDraw(tilePos, tileEffects[effectName], solid); + public static void RegisterTileToDraw(Point tilePos, string effectName, bool solid = true) => RegisterTileToDraw(tilePos, tileEffectLookup[effectName], solid); public static void RegisterTileToDraw(Point tilePos, IPingedTileEffect effect, bool solid = true) { //Unless we are in color light mode, we do not need the distinction between solid and non solid tiles. @@ -120,12 +149,10 @@ namespace CalamityMod.Systems else { if (!pingedNonSolidTiles.ContainsKey(effect)) - pingedNonSolidTiles.Add(effect, new List()); + pingedNonSolidTiles.Add(effect, []); if (!pingedNonSolidTiles[effect].Contains(tilePos)) pingedNonSolidTiles[effect].Add(tilePos); - - } } @@ -134,7 +161,7 @@ namespace CalamityMod.Systems if (Main.dedServ || tileEffects is null) return; - foreach (IPingedTileEffect effect in tileEffects.Values) + foreach (IPingedTileEffect effect in tileEffects) { effect.UpdateEffect(); } @@ -158,12 +185,13 @@ namespace CalamityMod.Systems { List clonedList = pingedNonSolidTiles[nonSolidEffect].ConvertAll(position => new Point(position.X, position.Y)); - if (!drawCache.ContainsKey(nonSolidEffect)) + if (!drawCache.TryGetValue(nonSolidEffect, out var value)) + { drawCache.Add(nonSolidEffect, clonedList); - + } else { - drawCache[nonSolidEffect].AddRange(clonedList); + value.AddRange(clonedList); } } } @@ -191,6 +219,7 @@ namespace CalamityMod.Systems ClearTiles(true); ClearTiles(false); } + public static void ClearTiles(bool solid) { if (solid) @@ -199,16 +228,17 @@ namespace CalamityMod.Systems else pingedNonSolidTiles.Clear(); } - } - public class GlobalPingableTile : GlobalTile - { - public override void DrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + #region GlobalTile Hooks + private class GlobalPingableTile : GlobalTile { - foreach (IPingedTileEffect effect in TilePingerSystem.tileEffects.Values) + public override void DrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref TileDrawInfo drawData) { - if (effect.Active && effect.ShouldRegisterTile(i, j)) + foreach (IPingedTileEffect effect in tileEffects) { + if (!effect.Active || !effect.ShouldRegisterTile(i, j)) + continue; + int tileType = Main.tile[i, j].TileType; bool solid = true; @@ -221,147 +251,11 @@ namespace CalamityMod.Systems solid = Main.tileSolid[tileType]; } - TilePingerSystem.RegisterTileToDraw(new Point(i, j), effect, solid); + RegisterTileToDraw(new Point(i, j), effect, solid); effect.EditDrawData(i, j, ref drawData); } } } - } - - public class WulfrumPingTileEffect : IPingedTileEffect, ILoadable - { - internal static Texture2D emptyFrame; - const int MaxPingLife = 350; - const int MaxPingTravelTime = 60; - const float PingWaveThickness = 50f; - - const float MaxPingRadius = 1700f; - public static Vector2 PingCenter = Vector2.Zero; - public static int PingTimer = 0; - public static float PingProgress => (MaxPingLife - PingTimer) / (float)MaxPingLife; - - public bool Active => PingTimer > 0; - - public BlendState BlendState => BlendState.Additive; - - public bool TryAddPing(Vector2 position, Player pinger) - { - //Only one ping at a time - if (Active) - return false; - - PingCenter = position; - PingTimer = MaxPingLife; - return true; - } - - - public Effect SetupEffect() - { - if (emptyFrame == null) - emptyFrame = ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; - - Effect tileEffect = Filters.Scene["CalamityMod:WulfrumTilePing"].GetShader().Shader; - tileEffect.Parameters["pingCenter"].SetValue(PingCenter); - tileEffect.Parameters["pingRadius"].SetValue(MaxPingRadius); - tileEffect.Parameters["pingWaveThickness"].SetValue(PingWaveThickness); - tileEffect.Parameters["pingProgress"].SetValue(PingProgress); - tileEffect.Parameters["pingTravelTime"].SetValue(MaxPingTravelTime / (float)MaxPingLife); - tileEffect.Parameters["pingFadePoint"].SetValue(0.9f); - tileEffect.Parameters["edgeBlendStrength"].SetValue(1f); - tileEffect.Parameters["edgeBlendOutLength"].SetValue(6f); - tileEffect.Parameters["tileEdgeBlendStrenght"].SetValue(2f); - - tileEffect.Parameters["waveColor"].SetValue(Color.GreenYellow.ToVector4()); - tileEffect.Parameters["baseTintColor"].SetValue(Color.DeepSkyBlue.ToVector4() * 0.5f); - tileEffect.Parameters["scanlineColor"].SetValue(Color.YellowGreen.ToVector4() * 1f); - tileEffect.Parameters["tileEdgeColor"].SetValue(Color.GreenYellow.ToVector3()); - tileEffect.Parameters["Resolution"].SetValue(8f); - - tileEffect.Parameters["time"].SetValue(Main.GameUpdateCount); - Vector4[] scanLines = new Vector4[] - { - new Vector4(0f, 4f, 0.1f, 0.5f), - new Vector4(1f, 4f, 0.1f, 0.5f), - new Vector4(37f, 60f, 0.4f, 1f), - new Vector4(2f, 6f, -0.2f, 0.3f), - new Vector4(0f, 4f, 0.1f, 0.5f), //vertical start - new Vector4(1f, 4f, 0.1f, 0.5f), - new Vector4(2f, 6f, -0.2f, 0.3f) - }; - - tileEffect.Parameters["ScanLines"].SetValue(scanLines); - tileEffect.Parameters["ScanLinesCount"].SetValue(scanLines.Length); - tileEffect.Parameters["verticalScanLinesIndex"].SetValue(4); - - return tileEffect; - } - - public void PerTileSetup(Point pos, ref Effect effect) - { - //Up, left, right, down. - effect.Parameters["cardinalConnections"].SetValue(new bool[] { Connected(pos, 0, -1), Connected(pos, -1, 0), Connected(pos, 1, 0), Connected(pos, 0, 1) }); - effect.Parameters["tilePosition"].SetValue(pos.ToVector2() * 16f); - } - - public static bool Connected(Point pos, int displaceX, int displaceY) => Main.IsTileSpelunkable(pos.X + displaceX, pos.Y + displaceY) && Main.tile[pos].TileType == Main.tile[pos.X + displaceX, pos.Y + displaceY].TileType; - - public bool ShouldRegisterTile(int x, int y) - { - return Main.IsTileSpelunkable(x, y); - } - - public void DrawTile(Point pos) - { - Main.spriteBatch.Draw(emptyFrame, pos.ToWorldCoordinates() - Main.screenPosition, null, Color.White, 0, new Vector2(emptyFrame.Width / 2f, emptyFrame.Height / 2f), 16f, 0, 0); - } - - public void EditDrawData(int i, int j, ref TileDrawInfo drawData) - { - float distanceFromCenter = (new Point(i, j).ToWorldCoordinates() - PingCenter).Length(); - float currentExpansion = MathHelper.Clamp(PingProgress * MaxPingLife / (float)MaxPingTravelTime, 0f, 1f) * MaxPingRadius; - - if (distanceFromCenter - 8 > currentExpansion) - return; - - float brightness = 1f; - Tile tile = Framing.GetTileSafely(i, j); - //Counteracts slopes and half tiles being too bright - if (tile.Slope != SlopeType.Solid || tile.IsHalfBlock) - brightness = 0.64f; - - //Fade on the edges - if (distanceFromCenter + 8 > currentExpansion) - brightness *= 1 - (distanceFromCenter - currentExpansion + 8f) / 16f; - - //Fade away with the effect - brightness *= 1 - Math.Max(PingProgress - 0.9f, 0) / (0.1f); - - if (drawData.tileLight.R < 200 * brightness) drawData.tileLight.R = (byte)(200 * brightness); - if (drawData.tileLight.G < 200 * brightness) drawData.tileLight.G = (byte)(200 * brightness); - if (drawData.tileLight.B < 200 * brightness) drawData.tileLight.B = (byte)(200 * brightness); - } - - public void UpdateEffect() - { - if (PingTimer > 0) - { - PingTimer--; - - //if the effect ended (and the player has a treasure pigner in their inventory, of course), play a recharge beep - if (PingTimer == 0 && Main.LocalPlayer.InventoryHas(ModContent.ItemType())) - SoundEngine.PlaySound(WulfrumTreasurePinger.RechargeBeepSound); - } - } - - public void Load(Mod mod) - { - if (Main.dedServ) - return; - - TilePingerSystem.tileEffects.Add("WulfrumPing", this); - } - - public void Unload() { } + #endregion } } diff --git a/Systems/Mechanic/WorldSelectionDifficultySystem.cs b/Systems/Mechanic/WorldSelectionDifficultySystem.cs index 7193069b77..e4e5b0b442 100644 --- a/Systems/Mechanic/WorldSelectionDifficultySystem.cs +++ b/Systems/Mechanic/WorldSelectionDifficultySystem.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using System.Reflection; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria.GameContent.UI.Elements; using Terraria.IO; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.IO; @@ -23,10 +21,7 @@ namespace CalamityMod.Systems { WorldDifficulties.Add(new WorldDifficulty(CalamityUtils.GetTextValue("UI.Revengeance"), GetRevengeance, new(211, 42, 42))); WorldDifficulties.Add(new WorldDifficulty(CalamityUtils.GetTextValue("UI.Death"), GetDeath, new(192, 64, 219))); - WorldDifficulties.Add(new WorldDifficulty(CalamityUtils.GetTextValue("UI.RevMaster"), GetMasterRevengeance, new(124, 153, 242))); - WorldDifficulties.Add(new WorldDifficulty(CalamityUtils.GetTextValue("UI.DeathMaster"), GetMasterDeath, new(255, 25, 255))); - WorldDifficulties.Add(new WorldDifficulty(CalamityUtils.GetTextValue("UI.RevLegend"), GetLegendRevengeance, new(240, 128, 128))); // Malice color - WorldDifficulties.Add(new WorldDifficulty(CalamityUtils.GetTextValue("UI.DeathLegend"), GetLegendDeath, new(220, 255, 132))); // Defiled color + WorldDifficulties.Add(new WorldDifficulty(CalamityUtils.GetTextValue("UI.Malice"), GetMalice, new(240, 128, 128))); } } @@ -54,87 +49,27 @@ namespace CalamityMod.Systems public static bool GetDeath(AWorldListItem item) { + // Grab data from the listed world + WorldFileData worldData = item._data; + if (item.Data.TryGetHeaderData(out TagCompound tag)) { if (tag.ContainsKey("DeathMode") && tag.GetBool("DeathMode")) { return true; } - } - return false; - } - - public static bool GetMasterRevengeance(AWorldListItem item) - { - // Grab data from the listed world - FieldInfo worldDataField = typeof(UIWorldListItem).GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance); - WorldFileData worldData = (WorldFileData)worldDataField.GetValue(item); - - int trueGameMode = worldData.GameMode; - if (worldData.ForTheWorthy) - { - trueGameMode++; - } - - if (item.Data.TryGetHeaderData(out TagCompound tag)) - { - if (tag.ContainsKey("RevengeanceMode") && tag.GetBool("RevengeanceMode") && trueGameMode == 2) + else if (tag.ContainsKey("RevengeanceMode") && tag.GetBool("RevengeanceMode")) { - return true; + return worldData.ForTheWorthy; } } return false; } - public static bool GetMasterDeath(AWorldListItem item) + public static bool GetMalice(AWorldListItem item) { // Grab data from the listed world - FieldInfo worldDataField = typeof(UIWorldListItem).GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance); - WorldFileData worldData = (WorldFileData)worldDataField.GetValue(item); - - int trueGameMode = worldData.GameMode; - if (worldData.ForTheWorthy) - { - trueGameMode++; - } - - if (item.Data.TryGetHeaderData(out TagCompound tag)) - { - if (tag.ContainsKey("DeathMode") && tag.GetBool("DeathMode") && trueGameMode == 2) - { - return true; - } - } - return false; - } - - public static bool GetLegendRevengeance(AWorldListItem item) - { - // Grab data from the listed world - FieldInfo worldDataField = typeof(UIWorldListItem).GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance); - WorldFileData worldData = (WorldFileData)worldDataField.GetValue(item); - - int trueGameMode = worldData.GameMode; - if (worldData.ForTheWorthy) - { - trueGameMode++; - } - - if (item.Data.TryGetHeaderData(out TagCompound tag)) - { - if (tag.ContainsKey("RevengeanceMode") && tag.GetBool("RevengeanceMode") && trueGameMode == 3) - { - return true; - } - } - return false; - } - - public static bool GetLegendDeath(AWorldListItem item) - { - // Grab data from the listed world - FieldInfo worldDataField = typeof(UIWorldListItem).GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance); - WorldFileData worldData = (WorldFileData)worldDataField.GetValue(item); + WorldFileData worldData = item._data; int trueGameMode = worldData.GameMode; if (worldData.ForTheWorthy) diff --git a/Systems/ProgressionAndEvent/BossRushDialogueSystem.cs b/Systems/ProgressionAndEvent/BossRushDialogueSystem.cs index 518221d65e..7bd949c0f8 100644 --- a/Systems/ProgressionAndEvent/BossRushDialogueSystem.cs +++ b/Systems/ProgressionAndEvent/BossRushDialogueSystem.cs @@ -187,7 +187,7 @@ namespace CalamityMod.Systems // Display dialogue and set appropriate delay, if this dialogue shouldn't be skipped. if (line.skipCondition is null || !line.skipCondition.Invoke()) { - CalamityUtils.DisplayLocalizedText(line.LocalizationKey, BossRushEvent.XerocTextColor); + CalamityUtils.BroadcastLocalizedText(line.LocalizationKey, BossRushEvent.XerocTextColor); CurrentDialogueDelay = line.FrameDelay; } diff --git a/Systems/ResizeArrayHook.cs b/Systems/ResizeArrayHook.cs deleted file mode 100644 index e5ffa028d2..0000000000 --- a/Systems/ResizeArrayHook.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Terraria.ModLoader; - -namespace CalamityMod.Systems -{ - internal delegate void ResizeArrayDelegate(bool unloading); - - internal sealed class ResizeArrayHook : ModSystem - { - public static event ResizeArrayDelegate OnResizeArrays; - public static event ResizeArrayDelegate OnPostResizeArrays; - - public override void Load() - { - var resizeArrayMethod = typeof(ModContent).GetMethod("ResizeArrays", BindingFlags.NonPublic | BindingFlags.Static); - MonoModHooks.Add(resizeArrayMethod, ResizeArrays); - } - - private static void ResizeArrays(ResizeArrayDelegate orig, bool unloading) - { - OnResizeArrays?.Invoke(unloading); - orig(unloading); - OnPostResizeArrays?.Invoke(unloading); - } - - // MonoMod Hook Unloads before this being called - // So we forcely call ResizeArray with Unload true - public override void Unload() - { - OnResizeArrays?.Invoke(unloading: true); - OnPostResizeArrays?.Invoke(unloading: true); - - OnResizeArrays = null; - OnPostResizeArrays = null; - } - } -} diff --git a/Systems/Sound/MusicEventSystem.cs b/Systems/Sound/MusicEventSystem.cs index 1746e62840..3a7fc3290c 100644 --- a/Systems/Sound/MusicEventSystem.cs +++ b/Systems/Sound/MusicEventSystem.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Threading; using CalamityMod.Events; using CalamityMod.NPCs; @@ -34,7 +33,7 @@ namespace CalamityMod.Systems public static Thread EventTrackerThread { get; set; } = null; - public static List PlayedEvents { get; set; } = []; + public static HashSet PlayedEvents { get; set; } = []; public static List EventCollection { get; set; } = []; @@ -54,17 +53,17 @@ namespace CalamityMod.Systems } AddEntry("CloneDefeated", "Interlude1", TimeSpan.FromSeconds(214.577d), - () => DownedBossSystem.downedCalamitasClone, () => CalamityClientConfig.Instance.Interlude1); + () => DownedBossSystem.downedCalamitasClone, () => CalamityClientConfig.Instance.Interludes); AddEntry("MLDefeated", "Interlude2", TimeSpan.FromSeconds(191.912d), () => NPC.downedMoonlord, - () => CalamityClientConfig.Instance.Interlude2, outroSilence: TimeSpan.FromSeconds(1f)); + () => CalamityClientConfig.Instance.Interludes, outroSilence: TimeSpan.FromSeconds(1f)); // Alternative Interlude 2 -> AddEntry("MLDefeated", "Interlude2_CutIntro", TimeSpan.FromSeconds(160.989d), // () => NPC.downedMoonlord, () => CalamityClientConfig.Instance.Interlude2, // outroSilence: TimeSpan.FromSeconds(1f)); AddEntry("YharonDefeated", "Interlude3", TimeSpan.FromSeconds(295.932d), - () => DownedBossSystem.downedYharon, () => CalamityClientConfig.Instance.Interlude3); + () => DownedBossSystem.downedYharon, () => CalamityClientConfig.Instance.Interludes); AddEntry("DoGDefeated", "DevourerofGodsEulogy", TimeSpan.FromSeconds(203.620d), () => DownedBossSystem.downedDoG, () => CalamityClientConfig.Instance.DevourerofGodsEulogy, @@ -244,8 +243,9 @@ namespace CalamityMod.Systems public override void SaveWorldData(TagCompound tag) { tag["calamityPlayedMusicEventCount"] = PlayedEvents.Count; - for (int i = 0; i < PlayedEvents.Count; i++) - tag[$"calamityPlayedMusicEvent{i}"] = PlayedEvents[i]; + int i = 0; + foreach (string playedEvent in PlayedEvents) + tag[$"calamityPlayedMusicEvent{i++}"] = playedEvent; } public override void LoadWorldData(TagCompound tag) diff --git a/Systems/Tile/BiomeTileCounterSystem.cs b/Systems/Tile/BiomeTileCounterSystem.cs index e66ed5837c..d5f6121d11 100644 --- a/Systems/Tile/BiomeTileCounterSystem.cs +++ b/Systems/Tile/BiomeTileCounterSystem.cs @@ -4,12 +4,12 @@ using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Crags; -using CalamityMod.Tiles.FloralParadise; using CalamityMod.Tiles.DraedonStructures; using CalamityMod.Tiles.Ores; using CalamityMod.Tiles.SunkenSea; using Terraria; using Terraria.ModLoader; +using Terraria.ID; namespace CalamityMod.Systems { @@ -23,10 +23,10 @@ namespace CalamityMod.Systems public static int SunkenSeaPolypTiles = 0; public static int SunkenSeaReefsTiles = 0; public static int SunkenSeaBurrowsTiles = 0; + public static int SunkenSeaBasaltTiles = 0; public static int ArsenalLabTiles = 0; public static int AbyssTiles = 0; - public static int FloralParadiseTiles = 0; - + public static int UndergroundTiles = 0; public static int Layer1Tiles = 0; public static int Layer2Tiles = 0; public static int Layer3Tiles = 0; @@ -41,29 +41,31 @@ namespace CalamityMod.Systems SunkenSeaPolypTiles = 0; SunkenSeaReefsTiles = 0; SunkenSeaBurrowsTiles = 0; + SunkenSeaBasaltTiles = 0; SulphurTiles = 0; AbyssTiles = 0; ArsenalLabTiles = 0; + UndergroundTiles = 0; Layer1Tiles = 0; Layer2Tiles = 0; Layer3Tiles = 0; Layer4Tiles = 0; - FloralParadiseTiles = 0; } public override void TileCountsAvailable(ReadOnlySpan tileCounts) { BrimstoneCragTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; - SunkenSeaTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; - SunkenSeaShoresTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; - SunkenSeaPolypTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaShoresTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaPolypTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; SunkenSeaReefsTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; - SunkenSeaBurrowsTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaBurrowsTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaBasaltTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; AbyssTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; SulphurTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; - FloralParadiseTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; ArsenalLabTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + UndergroundTiles = tileCounts[TileID.Stone]; Layer1Tiles = tileCounts[ModContent.TileType()]; Layer2Tiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; diff --git a/Systems/Tile/SulphuricWaterSafeZoneSystem.cs b/Systems/Tile/SulphuricWaterSafeZoneSystem.cs index 6024c82d43..91a996ce9f 100644 --- a/Systems/Tile/SulphuricWaterSafeZoneSystem.cs +++ b/Systems/Tile/SulphuricWaterSafeZoneSystem.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; using System.Linq; -using CalamityMod.Tiles; using Microsoft.Xna.Framework; -using Terraria; using Terraria.ModLoader; namespace CalamityMod.Systems diff --git a/Systems/Tile/TempTilesManagerSystem.cs b/Systems/Tile/TempTilesManagerSystem.cs index 36bbab9834..f8378d714d 100644 --- a/Systems/Tile/TempTilesManagerSystem.cs +++ b/Systems/Tile/TempTilesManagerSystem.cs @@ -101,6 +101,18 @@ namespace CalamityMod.Systems return ManagedTiles.Find(t => t.position == position).timeleft; } + public override void PostWorldLoad() + { + for (int i = 0; i < Main.maxTilesX; i++) + { + for (int j = 0; j < Main.maxTilesY; j++) + { + if (TemporaryTileIDs.Contains(Main.tile[i, j].TileType)) + WorldGen.KillTile(i, j); + } + } + } + public override void OnWorldUnload() { ManagedTiles = new List(); diff --git a/Systems/Tile/TileFramingSystem.cs b/Systems/Tile/TileFramingSystem.cs index e55bedb771..99adb6fa66 100644 --- a/Systems/Tile/TileFramingSystem.cs +++ b/Systems/Tile/TileFramingSystem.cs @@ -11,7 +11,6 @@ using CalamityMod.Tiles.SunkenSea; using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -91,7 +90,8 @@ namespace CalamityMod.Systems (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), ]; private static int[][] PlantValidGrounds; @@ -120,7 +120,6 @@ namespace CalamityMod.Systems PlantValidGrounds[ModContent.TileType()] = new int[1] { ModContent.TileType() }; PlantValidGrounds[ModContent.TileType()] = new int[1] { ModContent.TileType() }; PlantValidGrounds[ModContent.TileType()] = new int[2] { ModContent.TileType(), ModContent.TileType() }; - PlantValidGrounds[ModContent.TileType()] = new int[1] { ModContent.TileType() }; VineToGrass = new Dictionary { diff --git a/Systems/Tile/TileSpecialDrawData.cs b/Systems/Tile/TileSpecialDrawData.cs new file mode 100644 index 0000000000..7c27ddaeb9 --- /dev/null +++ b/Systems/Tile/TileSpecialDrawData.cs @@ -0,0 +1,97 @@ +using Terraria; +using Terraria.GameContent.Drawing; + +namespace CalamityMod.Systems +{ + public struct TileSpecialDrawData : ITileData + { + private byte Data; + + /// + /// Used for + /// + public bool HasBlendMergeData + { + readonly get => TileDataPacking.GetBit(Data, offset: 0); + set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 0); + } + + /// + /// Used for Tiles that have complicated conditions for + /// + public bool HasSpecialPoint + { + readonly get => TileDataPacking.GetBit(Data, offset: 1); + set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 1); + } + + // Empty Flags: + // 2, 3 + + /// + /// Shared Flag0 + /// + public bool Flag0 + { + readonly get => TileDataPacking.GetBit(Data, offset: 4); + set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 4); + } + + /// + /// Shared Flag1 + /// + public bool Flag1 + { + readonly get => TileDataPacking.GetBit(Data, offset: 5); + set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 5); + } + + /// + /// Shared Flag2 + /// + public bool Flag2 + { + readonly get => TileDataPacking.GetBit(Data, offset: 6); + set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 6); + } + + /// + /// Shared Flag3 + /// + public bool Flag3 + { + readonly get => TileDataPacking.GetBit(Data, offset: 7); + set => Data = (byte)TileDataPacking.SetBit(value, Data, offset: 7); + } + + /// + /// Get All Flags + /// + /// Flag0 Value + /// Flag1 Value + /// Flag2 Value + /// Flag3 Value + public readonly void GetFlags(out bool flag0, out bool flag1, out bool flag2, out bool flag3) + { + flag0 = Flag0; + flag1 = Flag1; + flag2 = Flag2; + flag3 = Flag3; + } + + /// + /// Set All Flags + /// + /// Flag0 + /// Flag1 + /// Flag2 + /// Flag3 + public void SetFlags(bool flag0, bool flag1, bool flag2, bool flag3) + { + Flag0 = flag0; + Flag1 = flag1; + Flag2 = flag2; + Flag3 = flag3; + } + } +} diff --git a/Systems/TileMerging/DataStructures.cs b/Systems/TileMerging/DataStructures.cs index 2a326cca3f..671c32a0e0 100644 --- a/Systems/TileMerging/DataStructures.cs +++ b/Systems/TileMerging/DataStructures.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria; -using Terraria.DataStructures; +using Microsoft.Xna.Framework; namespace CalamityMod.Systems { @@ -36,55 +30,55 @@ namespace CalamityMod.Systems AllSide = 0b1111_1111, // Special Shapes - Shape_AllSide = AllSide, - ShapeCorner_UpLeft = UpLeft, - ShapeCorner_UpRight = UpRight, - ShapeCorner_DownLeft = DownLeft, + Shape_AllSide = AllSide, + ShapeCorner_UpLeft = UpLeft, + ShapeCorner_UpRight = UpRight, + ShapeCorner_DownLeft = DownLeft, ShapeCorner_DownRight = DownRight, // I Shapes - ShapeI_Up = Up | UpLeft | UpRight, - ShapeI_Up_End = Up, - ShapeI_Up_LeftEnd = Up | UpRight, + ShapeI_Up = Up | UpLeft | UpRight, + ShapeI_Up_End = Up, + ShapeI_Up_LeftEnd = Up | UpRight, ShapeI_Up_RightEnd = Up | UpLeft, - ShapeI_Down = Down | DownLeft | DownRight, - ShapeI_Down_End = Down, - ShapeI_Down_LeftEnd = Down | DownRight, + ShapeI_Down = Down | DownLeft | DownRight, + ShapeI_Down_End = Down, + ShapeI_Down_LeftEnd = Down | DownRight, ShapeI_Down_RightEnd = Down | DownLeft, - ShapeI_Left = Left | UpLeft | DownLeft, - ShapeI_Left_End = Left, - ShapeI_Left_UpEnd = Left | DownLeft, + ShapeI_Left = Left | UpLeft | DownLeft, + ShapeI_Left_End = Left, + ShapeI_Left_UpEnd = Left | DownLeft, ShapeI_Left_DownEnd = Left | UpLeft, - ShapeI_Right = Right | UpRight | DownRight, - ShapeI_Right_End = Right, - ShapeI_Right_UpEnd = Right | DownRight, + ShapeI_Right = Right | UpRight | DownRight, + ShapeI_Right_End = Right, + ShapeI_Right_UpEnd = Right | DownRight, ShapeI_Right_DownEnd = Right | UpRight, // L Shapes - ShapeL_UpLeft = ShapeI_Up | ShapeI_Left, - ShapeL_UpLeft_End = ShapeI_Up_End | ShapeI_Left_End | UpLeft, + ShapeL_UpLeft = ShapeI_Up | ShapeI_Left, + ShapeL_UpLeft_End = ShapeI_Up_End | ShapeI_Left_End | UpLeft, ShapeL_UpLeft_RightEnd = ShapeI_Up_RightEnd | ShapeI_Left, - ShapeL_UpLeft_DownEnd = ShapeI_Up | ShapeI_Left_DownEnd, + ShapeL_UpLeft_DownEnd = ShapeI_Up | ShapeI_Left_DownEnd, - ShapeL_UpRight = ShapeI_Up | ShapeI_Right, - ShapeL_UpRight_End = ShapeI_Up_End | ShapeI_Right_End | UpRight, + ShapeL_UpRight = ShapeI_Up | ShapeI_Right, + ShapeL_UpRight_End = ShapeI_Up_End | ShapeI_Right_End | UpRight, ShapeL_UpRight_LeftEnd = ShapeI_Up_End | ShapeI_Right, ShapeL_UpRight_DownEnd = ShapeI_Up | ShapeI_Right_End, - ShapeL_DownLeft = ShapeI_Down | ShapeI_Left, - ShapeL_DownLeft_End = ShapeI_Down_End | ShapeI_Left_End | DownLeft, + ShapeL_DownLeft = ShapeI_Down | ShapeI_Left, + ShapeL_DownLeft_End = ShapeI_Down_End | ShapeI_Left_End | DownLeft, ShapeL_DownLeft_RightEnd = ShapeI_Down_End | ShapeI_Left, - ShapeL_DownLeft_UpEnd = ShapeI_Down | ShapeI_Left_End, + ShapeL_DownLeft_UpEnd = ShapeI_Down | ShapeI_Left_End, - ShapeL_DownRight = ShapeI_Down | ShapeI_Right, - ShapeL_DownRight_End = ShapeI_Down_End | ShapeI_Right_End | DownRight, + ShapeL_DownRight = ShapeI_Down | ShapeI_Right, + ShapeL_DownRight_End = ShapeI_Down_End | ShapeI_Right_End | DownRight, ShapeL_DownRight_LeftEnd = ShapeI_Down_End | ShapeI_Right, - ShapeL_DownRight_UpEnd = ShapeI_Down | ShapeI_Right_End, + ShapeL_DownRight_UpEnd = ShapeI_Down | ShapeI_Right_End, // U Shapes @@ -109,72 +103,61 @@ namespace CalamityMod.Systems ShapeU_RightEmpty_DownEnd = ShapeI_Up | ShapeI_Down_End | ShapeI_Left, } - public struct TileBlendingData : ITileData + public readonly struct SheetPositionKey(BlendSideFlags blendSides, byte randomFrameIndex) { - public const int Length = 8; + public ushort Key { get; init; } = (ushort)((int)blendSides + (randomFrameIndex * 256)); + public BlendSideFlags BlendSides => (BlendSideFlags)(byte)(Key % 256); + public byte RandomFrameIndex => (byte)(Key / 256); - private ulong SheetIndexPacked; // 8 bytes - private ulong DataPacked; // 8 bytes + public static implicit operator int(SheetPositionKey key) => key.Key; + } - public void Clear() + public readonly struct SheetPosition + { + public readonly byte X; + public readonly byte Y; + public readonly sbyte BakedSheetIndex; + + public SheetPosition(int x, int y, sbyte bakedSheetIndex = -1) { - for (int i = 0; i= Length) - throw new IndexOutOfRangeException(); - - var shift = idx * 8; - ulong value = ((ulong)data) << shift; - ulong mask = ((ulong)0xFF) << shift; - DataPacked = (DataPacked ^ (mask & DataPacked)) | value; + if (IsUsingBaseTexture) return new Vector2(X * 18.0f, Y * 18.0f); + else return new Vector2(X * TileBlendTexture.BlendTextureFrameWidth, Y * TileBlendTexture.BlendTextureFrameHeight); } - public readonly byte GetData(int idx) + public readonly Rectangle GetDrawRect() { - if (idx < 0 || idx >= Length) - throw new IndexOutOfRangeException(); - - var shift = idx * 8; - return (byte)((DataPacked >> shift) & 0xFF); + if (IsUsingBaseTexture) return new Rectangle(X * 18, Y * 18, 16, 16); + else return new Rectangle(X * TileBlendTexture.BlendTextureFrameWidth, Y * TileBlendTexture.BlendTextureFrameHeight, 16, 16); } - public void SetSheetIndex(int idx, byte sheetIdx) - { - if (idx < 0 || idx >= Length) - throw new IndexOutOfRangeException(); + public readonly bool IsUsingBaseTexture => BakedSheetIndex < 0; + } - var shift = idx * 8; - ulong value = ((ulong)sheetIdx) << shift; - ulong mask = ((ulong)0xFF) << shift; - SheetIndexPacked = (SheetIndexPacked ^ (mask & SheetIndexPacked)) | value; - } + public struct TileBlendingRef(ushort sheetIdx, byte blendData) + { + public ushort SheetIndex = sheetIdx; + public byte BlendData = blendData; + } - public readonly byte GetSheetIndex(int idx) - { - if (idx < 0 || idx >= Length) - throw new IndexOutOfRangeException(); - - var shift = idx * 8; - return (byte)((SheetIndexPacked >> shift) & 0xFF); - } - - public void Set(int idx, byte sheetIdx, byte data) - { - SetSheetIndex(idx, sheetIdx); - SetData(idx, data); - } - - public readonly void Get(int idx, out byte sheetIdx, out byte data) - { - sheetIdx = GetSheetIndex(idx); - data = GetData(idx); - } + public enum TileBlendingQuality + { + Disable, + Normal, + High } } diff --git a/Systems/TileMerging/TileBlendMergeSystem.cs b/Systems/TileMerging/TileBlendMergeSystem.cs index 5da7dde7a6..aa7bd05472 100644 --- a/Systems/TileMerging/TileBlendMergeSystem.cs +++ b/Systems/TileMerging/TileBlendMergeSystem.cs @@ -1,6 +1,7 @@ using System; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.GameContent.Drawing; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Systems @@ -8,56 +9,39 @@ namespace CalamityMod.Systems [Autoload(Side = ModSide.Client)] public sealed partial class TileBlendMergeSystem : ModSystem { - private static bool[,] _TileBlendable; // dimension: [TileTypeCount, AllBlendTextureCount] - private static bool[,] _TileBlendLooselyFillDiagonal; // dimension: [TileTypeCount, AllBlendTextureCount] - private static byte[] _TileTypeToBlendTextureSlot; // dimension: [TileTypeCount] - private static bool _IDSetsInitialized = false; + private static bool[,] _TileBlendable = new bool[TileID.Count, 1]; // dimension: [TileTypeCount, AllBlendTextureCount] + private static bool[,] _TileBlendLooselyFillDiagonal = new bool[TileID.Count, 1]; // dimension: [TileTypeCount, AllBlendTextureCount] + private static byte[] _TileTypeToBlendTextureSlot = new byte[TileID.Count]; // dimension: [TileTypeCount] #region Load/Unload public override void OnModLoad() { // Draw Code - On_TileDrawing.DrawSingleTile += OnDrawSingleTile; - ResizeArrayHook.OnPostResizeArrays += OnResizeArrays; + On_Main.DrawTiles += OnDrawTiles; + Main.OnPreDraw += UpdateBaking; } - private static void OnResizeArrays(bool unloading) + public override void Unload() + { + Main.OnPreDraw -= UpdateBaking; + _TileBlendable = null; + _TileBlendLooselyFillDiagonal = null; + _TileTypeToBlendTextureSlot = null; + } + + public override void ResizeArrays() { var tileCount = TileLoader.TileCount; var blendTextureCount = TileBlendTextureLoader.Count; // This count also should be updated on ResizeArrays call - static void SetupTileTypeToBlendTextureSlot() - { - if (TileBlendTextureLoader.AllTextures == null) - return; - foreach (var blendTexture in TileBlendTextureLoader.AllTextures) - { - _TileTypeToBlendTextureSlot[blendTexture.TileType] = (byte)blendTexture.Slot; - } - } - - if (!_IDSetsInitialized) - { - _TileBlendable = new bool[tileCount, blendTextureCount + 1]; - _TileBlendLooselyFillDiagonal = new bool[tileCount, blendTextureCount + 1]; - _TileTypeToBlendTextureSlot = new byte[tileCount]; - _IDSetsInitialized = true; - SetupTileTypeToBlendTextureSlot(); - return; - } - - if (unloading) - { - _TileBlendable = null; - _TileBlendLooselyFillDiagonal = null; - _TileTypeToBlendTextureSlot = null; - return; - } - ResizeArray2D(ref _TileBlendable, tileCount, blendTextureCount + 1); ResizeArray2D(ref _TileBlendLooselyFillDiagonal, tileCount, blendTextureCount + 1); Array.Resize(ref _TileTypeToBlendTextureSlot, tileCount); - SetupTileTypeToBlendTextureSlot(); + + foreach (var blendTexture in TileBlendTextureLoader.AllTextures) + { + _TileTypeToBlendTextureSlot[blendTexture.TileType] = (byte)blendTexture.Slot; + } } private static void ResizeArray2D(ref T[,] array, int newColNum, int newRowNum) @@ -75,7 +59,16 @@ namespace CalamityMod.Systems { foreach (var blendTexture in TileBlendTextureLoader.AllTextures) { - blendTexture.BakeBlendTexture(blendTexture.TextureAsset.Value); + blendTexture.ClearBakeCache(); + } + } + + private static void UpdateBaking(GameTime obj) + { + TileBlendTexture.BakedCountInFrame = 0; + foreach (var blendTexture in TileBlendTextureLoader.AllTextures) + { + blendTexture.BakeRequestedBlendTextureCache(); } } #endregion @@ -97,7 +90,11 @@ namespace CalamityMod.Systems var blendTextureSlot = _TileTypeToBlendTextureSlot[blendTileType]; if (blendTextureSlot == TileBlendTextureLoader.EmptySlot) + { + var tileName = TileLoader.GetTile(blendTileType)?.FullName ?? "Vanilla Tile"; + CalamityMod.Log.Error($"[BlendMergeSystem] BlendTileType: {blendTileType} ({tileName}) does not have TileBlendTexture! StackTrace:\n{Environment.StackTrace}"); return; + } _TileBlendable[myType, blendTextureSlot] = true; _TileBlendLooselyFillDiagonal[myType, blendTextureSlot] = looselyFillDiagonal; diff --git a/Systems/TileMerging/TileBlendMergeSystem_Draw.cs b/Systems/TileMerging/TileBlendMergeSystem_Draw.cs index 207c4bc4ea..07ab931ccc 100644 --- a/Systems/TileMerging/TileBlendMergeSystem_Draw.cs +++ b/Systems/TileMerging/TileBlendMergeSystem_Draw.cs @@ -1,24 +1,17 @@ using System; -using Microsoft.Xna.Framework.Graphics; -using Terraria.DataStructures; -using Terraria; -using Terraria.ModLoader; +using System.Threading; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; -using Terraria.GameContent.Drawing; -using System.Reflection; +using Microsoft.Xna.Framework.Graphics; +using Terraria; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Systems { public sealed partial class TileBlendMergeSystem : ModSystem { - private static readonly BindingFlags NonPublicStatic = BindingFlags.NonPublic | BindingFlags.Static; - private static readonly BindingFlags NonPublicInstance = BindingFlags.NonPublic | BindingFlags.Instance; - - private static readonly FastField MediumQualityLightRequirement = new("_mediumQualityLightingRequirement", NonPublicInstance); - private static readonly FastField HighQualityLightRequirement = new("_highQualityLightingRequirement", NonPublicInstance); - - private readonly static Rectangle[] Rects9Slice = [ + private static readonly Rectangle[] Rects9Slice = [ new Rectangle(x: 0, y: 0, width: 4, height: 4), new Rectangle(x: 4, y: 0, width: 8, height: 4), new Rectangle(x: 12, y: 0, width: 4, height: 4), @@ -32,123 +25,130 @@ namespace CalamityMod.Systems new Rectangle(x: 12, y: 12, width: 4, height: 4), ]; - private readonly static Rectangle[] Rects4Slice = [ + private static readonly Rectangle[] Rects4Slice = [ new Rectangle(x: 0, y: 0, width: 8, height: 8), new Rectangle(x: 8, y: 0, width: 8, height: 8), new Rectangle(x: 0, y: 8, width: 8, height: 8), new Rectangle(x: 8, y: 8, width: 8, height: 8), ]; - private enum SliceState : byte + private static readonly ThreadLocal ColorSliceBuffer = new(() => new Color[9]); + + private void OnDrawTiles(On_Main.orig_DrawTiles orig, Main self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets, int waterStyleOverride) { - None, - Slice_4, - Slice_9 - } + orig(self, solidLayer, forRenderTargets, intoRenderTargets, waterStyleOverride); - private static void OnDrawSingleTile(On_TileDrawing.orig_DrawSingleTile orig, TileDrawing self, TileDrawInfo drawData, bool solidLayer, int waterStyleOverride, Vector2 screenPosition, Vector2 screenOffset, int tileX, int tileY) - { - orig(self, drawData, solidLayer, waterStyleOverride, screenPosition, screenOffset, tileX, tileY); - - var tile = drawData.tileCache; - var tileType = tile.TileType; - - Color tileLight = drawData.tileLight; - if (tileLight.R <= 0 && tileLight.G <= 0 && tileLight.B <= 0) + if (!solidLayer || CalamityClientConfig.Instance.TileTextureBlendingQuality == TileBlendingQuality.Disable) return; + var screenPosition = Main.Camera.UnscaledPosition; + var zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + var offset = zero + (Main.Camera.UnscaledPosition - Main.Camera.ScaledPosition); + CalamityUtils.GetScreenDrawArea(screenPosition, offset, out int firstTileX, out int lastTileX, out int firstTileY, out int lastTileY); + + for (int x = firstTileX; x <= lastTileX; x++) + { + for (int y = firstTileY; y <= lastTileY; y++) + { + if (!WorldGen.InWorld(x, y)) + continue; + + var tile = Main.tile[x, y]; + if (!tile.Get().HasBlendMergeData) + continue; + + if (!CalamityTileSets.DrawBlendMergeAfterSolidTile[tile.TileType]) + continue; + + if (!TryGetBlendingRefData(x, y, out var blendRefs)) + continue; + + DrawOnTile(tile, x, y, in blendRefs); + } + } + } + + public static void DrawOnTile(Tile tile, int tileX, int tileY, in TileBlendingRef[] blendRefs) + { // Generic Drawing Parameter - Vector2 drawPos = new Vector2(tileX * 16, tileY * 16) - screenPosition + screenOffset; + var tileType = tile.TileType; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPos = new Vector2(tileX * 16, tileY * 16) - Main.screenPosition + zero; var tileRandomFrame = Math.Clamp(tile.TileFrameNumber, 0, 2); var isFullBright = tile.IsTileFullbright; + Color tileLight = Lighting.GetColor(tileX, tileY); // Sliced Rendering - var sliceRenderingPrepared = false; - var slices = drawData.colorSlices; int sliceLength = 0; - var sliceRects = Array.Empty(); - var sliceState = SliceState.None; - var shouldTileShine = ShouldTileShine(tileType, (short)(drawData.tileFrameX + drawData.addFrX)); + Rectangle[] sliceRects = null; + Color[] colorSliceBuffer = null; - var blendingData = tile.Get(); // Since we are not editing the value, we can just copy the values from here - for (int idx = 0; idx < TileBlendingData.Length; idx++) + // Is HalfBlock condition is also in vanilla, so we follow that + var silcedConfigEnabled = CalamityClientConfig.Instance.TileTextureBlendingQuality == TileBlendingQuality.High; + if (silcedConfigEnabled && Lighting.NotRetro && !tile.IsHalfBlock && !TileID.Sets.DontDrawTileSliced[tileType]) { - blendingData.Get(idx, out var sheetIdx, out var data); + var tileRenderer = Main.instance.TilesRenderer; + if (tileLight.IsAnyChannelGreaterThan(tileRenderer._highQualityLightingRequirement)) + { + sliceLength = 9; + sliceRects = Rects9Slice; + colorSliceBuffer = ColorSliceBuffer.Value; + Lighting.GetColor9Slice(tileX, tileY, ref colorSliceBuffer); + } + else if (tileLight.IsAnyChannelGreaterThan(tileRenderer._mediumQualityLightingRequirement)) + { + sliceLength = 4; + sliceRects = Rects4Slice; + colorSliceBuffer = ColorSliceBuffer.Value; + Lighting.GetColor4Slice(tileX, tileY, ref colorSliceBuffer); + } + } + + // If tile is Actuated, Set brightness to 40% + // Otherwise it sets to 100% or 160% (if shine) + var finalColorMultiplier = tile.IsActuated ? 0.4f : (Main.tileShine2[tileType] ? 1.6f : 1.0f); + var finalMultColor = new Color(finalColorMultiplier, finalColorMultiplier, finalColorMultiplier); + + foreach (var blendRef in blendRefs) + { + var sheetIdx = blendRef.SheetIndex; + var data = blendRef.BlendData; // Break here as standard for TileBlendingData is 0->Count fill, so further fields should be also Invalid if (sheetIdx == TileBlendTextureLoader.EmptySlot) break; - var rect = TileBlendTexture.SideFlagsToSheetRect(data); - var texture = TileBlendTextureLoader.Registry[sheetIdx].BlendTextures[tileRandomFrame]; + var key = new SheetPositionKey((BlendSideFlags)data, (byte)tileRandomFrame); + var blendTexture = TileBlendTextureLoader.Registry[sheetIdx]; - // Prepare Slice Rendering - if (!sliceRenderingPrepared) - { - // Is HalfBlock condition is also in vanilla, so we follow that - if (Lighting.NotRetro && !tile.IsHalfBlock && !TileID.Sets.DontDrawTileSliced[tileType]) - { - var midQualityThreshold = MediumQualityLightRequirement.Get(self); - var highQualityThreshold = HighQualityLightRequirement.Get(self); - if (tileLight.IsAnyChannelGreaterThan(highQualityThreshold)) - { - sliceLength = 9; - sliceState = SliceState.Slice_9; - sliceRects = Rects9Slice; - Lighting.GetColor9Slice(tileX, tileY, ref slices); - } - else if (tileLight.IsAnyChannelGreaterThan(midQualityThreshold)) - { - sliceLength = 4; - sliceState = SliceState.Slice_4; - sliceRects = Rects4Slice; - Lighting.GetColor4Slice(tileX, tileY, ref slices); - } - } - - sliceRenderingPrepared = true; - } + blendTexture.RequestBake(tileRandomFrame); + if (!blendTexture.TryGetDrawingInfo(key, out var texture, out var rect)) + continue; // No Slice Drawing - if (sliceState == SliceState.None || isFullBright) + if (sliceLength <= 0 || isFullBright) { var drawColor = isFullBright ? Color.White : tileLight; - Main.spriteBatch.Draw(texture, drawPos, rect, drawColor, rotation: 0.0f, origin: default, scale: 1.0f, SpriteEffects.None, layerDepth: 0.0f); + var finalColor = CalamityUtils.ApplyPaint(tile.TileColor, drawColor, deepPaintOnly: false).MultiplyRGB(finalMultColor); + Main.spriteBatch.Draw(texture, drawPos, rect, finalColor, rotation: 0.0f, origin: default, scale: 1.0f, SpriteEffects.None, layerDepth: 0.0f); continue; } // Sliced Drawing for (int i = 0; i < sliceLength; i++) { - var drawRect = sliceRects[i]; - drawRect.X += rect.X; - drawRect.Y += rect.Y; + // Calculate the source rectangle for the specific slice from the blend texture sheet + var sourceSliceRect = sliceRects[i]; + sourceSliceRect.X += rect.X; + sourceSliceRect.Y += rect.Y; - var drawColorVec = (tileLight.ToVector3() + slices[i]) * 0.5f; - drawColorVec *= drawData.colorTint.ToVector3(); - - // Tile is Actucated, Reduce brightness - if (tile.IsActuated) - { - drawColorVec *= 0.4f; - } - - // Tile is shine - if (shouldTileShine) - { - Main.shine(ref drawColorVec, tileType); - } - - Main.spriteBatch.Draw(texture, drawPos, rect, new Color(drawColorVec), rotation: 0.0f, origin: default, scale: 1.0f, SpriteEffects.None, layerDepth: 0.0f); + // Calculate the destination position for the slice on the screen + var destinationSlicePos = drawPos + sliceRects[i].Location.ToVector2(); + var drawColorVec = (tileLight.ToVector3() + colorSliceBuffer[i].ToVector3()) * 0.5f; + var finalColor = CalamityUtils.ApplyPaint(tile.TileColor, new Color(drawColorVec), deepPaintOnly: false).MultiplyRGB(finalMultColor); + Main.spriteBatch.Draw(texture, destinationSlicePos, sourceSliceRect, finalColor, 0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0f); } } } - - private static MethodInfo ShouldTileShineMethod; - private static bool ShouldTileShine(ushort type, short frameX) - { - ShouldTileShineMethod ??= typeof(TileDrawing).GetMethod("ShouldTileShine", NonPublicStatic); - return (bool)ShouldTileShineMethod.Invoke(null, [type, frameX]); - } } } diff --git a/Systems/TileMerging/TileBlendMergeSystem_GlobalTile.cs b/Systems/TileMerging/TileBlendMergeSystem_GlobalTile.cs index e20ad5757d..5aa10e3b83 100644 --- a/Systems/TileMerging/TileBlendMergeSystem_GlobalTile.cs +++ b/Systems/TileMerging/TileBlendMergeSystem_GlobalTile.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Diagnostics.CodeAnalysis; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.ModLoader; namespace CalamityMod.Systems @@ -23,9 +18,38 @@ namespace CalamityMod.Systems TileBlendMergeSystem.SetupMergeData(); } + public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) + { + if (CalamityClientConfig.Instance.TileTextureBlendingQuality == TileBlendingQuality.Disable) + return; + + if (CalamityTileSets.DrawBlendMergeAfterSolidTile[type]) + return; + + if (!WorldGen.InWorld(i, j)) + return; + + var tile = Main.tile[i, j]; + if (!tile.Get().HasBlendMergeData) + return; + + if (!TryGetBlendingRefData(i, j, out var blendRefs)) + return; + + DrawOnTile(tile, i, j, in blendRefs); + } + public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) { - TileBlendMergeSystem.TileFrame(i, j, type); + // Tomat: Naive way to address tile frame logic running on + // multiple threads resulting in cryptic errors due to + // SetBlendingRefData/_TileBlendingRefs not being threadsafe. + // A more correct fix would be to lock or use a thread-safe + // hashmap, but we don't actually create any scenarios aside + // from worldgen where this would be ran on multiple threads. + if (!WorldGen.generatingWorld) + TileBlendMergeSystem.TileFrame(i, j, type); + return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); } } diff --git a/Systems/TileMerging/TileBlendMergeSystem_TileData.cs b/Systems/TileMerging/TileBlendMergeSystem_TileData.cs new file mode 100644 index 0000000000..6f602c76f2 --- /dev/null +++ b/Systems/TileMerging/TileBlendMergeSystem_TileData.cs @@ -0,0 +1,47 @@ +using System.Collections.Concurrent; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Systems +{ + public sealed partial class TileBlendMergeSystem : ModSystem + { + // Blending Refs for every tiles + private static readonly ConcurrentDictionary _TileBlendingRefs = []; + + public override void ClearWorld() + { + _TileBlendingRefs.Clear(); + } + + public static void RemoveBlendingRefData(int tileX, int tileY) + { + if (!WorldGen.InWorld(tileX, tileY)) + return; + + var tileIdx = tileX + (Main.tile.Width * tileY); + _TileBlendingRefs.TryRemove(tileIdx, out _); + } + + public static void SetBlendingRefData(int tileX, int tileY, TileBlendingRef[] blendingRef) + { + if (!WorldGen.InWorld(tileX, tileY)) + return; + + var tileIdx = tileX + (Main.tile.Width * tileY); + _TileBlendingRefs[tileIdx] = blendingRef; + } + + public static bool TryGetBlendingRefData(int tileX, int tileY, out TileBlendingRef[] blendingRefs) + { + if (!WorldGen.InWorld(tileX, tileY)) + { + blendingRefs = null; + return false; + } + + var tileIdx = tileX + (Main.tile.Width * tileY); + return _TileBlendingRefs.TryGetValue(tileIdx, out blendingRefs); + } + } +} diff --git a/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs b/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs index 5387070e05..17174fbb7a 100644 --- a/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs +++ b/Systems/TileMerging/TileBlendMergeSystem_TileFrame.cs @@ -1,4 +1,5 @@ -using System.Runtime.CompilerServices; +using System; +using System.Runtime.CompilerServices; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,13 +10,18 @@ namespace CalamityMod.Systems { public sealed partial class TileBlendMergeSystem : ModSystem { + [ThreadStatic] + private static BlendSidesReg TempBlendSidesReg; + private static void TileFrame(int i, int j, int type) { if (!WorldGen.InWorld(i, j)) return; var tile = Main.tile[i, j]; - tile.Get().Clear(); + ref var drawData = ref tile.Get(); + drawData.HasBlendMergeData = false; + RemoveBlendingRefData(i, j); if (!tile.HasTile) // Is this even possible? But I'm doing this for sanity check anyways return; @@ -23,18 +29,27 @@ namespace CalamityMod.Systems var blendDataUniqueIndex = 0; var blendSidesReg = PopulateBlendSidesReg(i, j, tile.TileType); - CalculateSides(i, j, in blendSidesReg); - - foreach (var pair in blendSidesReg) + var regCount = blendSidesReg.Count; + if (regCount > 0) { - var blendTextureSlot = pair.Key; - var sideFlags = pair.Value; + CalculateSides(i, j, in blendSidesReg); - if (sideFlags != BlendSideFlags.None) + var tileBlendingRefs = new TileBlendingRef[regCount]; + + foreach (var pair in blendSidesReg) { - tile.Get().Set(blendDataUniqueIndex, (byte)blendTextureSlot, (byte)sideFlags); - blendDataUniqueIndex++; + var blendTextureSlot = pair.Key; + var sideFlags = pair.Value; + + if (sideFlags != BlendSideFlags.None) + { + tileBlendingRefs[blendDataUniqueIndex] = new TileBlendingRef((ushort)blendTextureSlot, (byte)sideFlags); + blendDataUniqueIndex++; + } } + + SetBlendingRefData(i, j, tileBlendingRefs); + drawData.HasBlendMergeData = true; } } @@ -318,7 +333,11 @@ namespace CalamityMod.Systems private static BlendSidesReg PopulateBlendSidesReg(int i, int j, int centerType) { - var reg = new BlendSidesReg(); + // Prepare Registry + TempBlendSidesReg ??= new BlendSidesReg(capacity: 8); + TempBlendSidesReg.Clear(); + + var reg = TempBlendSidesReg; int left = GetTileType(i - 1, j); int right = GetTileType(i + 1, j); @@ -336,9 +355,6 @@ namespace CalamityMod.Systems if (sideType < 0) return; - if (!_TileTypeToBlendTextureSlot.IndexInRange(sideType)) - return; - var blendTextureSlot = _TileTypeToBlendTextureSlot[sideType]; if (blendTextureSlot == TileBlendTextureLoader.EmptySlot) return; @@ -382,7 +398,7 @@ namespace CalamityMod.Systems tile = default; type = -1; return false; - } + } tile = Main.tile[i, j]; if (!tile.HasTile) diff --git a/Systems/TileMerging/TileBlendTexture.cs b/Systems/TileMerging/TileBlendTexture.cs index 4dc642f81a..4b2c128a91 100644 --- a/Systems/TileMerging/TileBlendTexture.cs +++ b/Systems/TileMerging/TileBlendTexture.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ModLoader; namespace CalamityMod.Systems @@ -19,8 +12,9 @@ namespace CalamityMod.Systems public const byte EmptySheetIndex = byte.MaxValue; public const int VariantCount = 3; - public const int BlendTextureXCount = 16; - public const int BlendTextureYCount = 16; + // 204 slots per sheet (1 empty slot per sheet) + public const int BlendTextureXCount = 17; + public const int BlendTextureYCount = 12; // FA: 2024/OCT/01 // Removing Margin as I believe artifacts never happens on Terraria @@ -31,13 +25,14 @@ namespace CalamityMod.Systems public const int BlendTextureWidth = BlendTextureFrameWidth * BlendTextureXCount; public const int BlendTextureHeight = BlendTextureFrameHeight * BlendTextureYCount; + public const int BlendTextureFullHeight = BlendTextureHeight * VariantCount; #endregion #region Properties public Asset TextureAsset { get; private set; } public int Slot { get; private set; } = -1; - public RenderTarget2D[] BlendTextures { get; private set; } // dimension: [3] + public RenderTarget2D BakedBlendTexture { get; private set; } #endregion @@ -47,25 +42,15 @@ namespace CalamityMod.Systems #region Setups + protected sealed override void Register() { + CalculateSheetPositionLookup(); + + ModTypeLookup.Register(this); Slot = TileBlendTextureLoader.Register(this); TextureAsset = ModContent.Request(Texture); - BlendTextures = new RenderTarget2D[3]; - - Main.QueueMainThreadAction(() => - { - for (int v = 0; v < VariantCount; v++) - BlendTextures[v] = new( - Main.instance.GraphicsDevice, - BlendTextureWidth, - BlendTextureHeight, - mipMap: false, - preferredFormat: SurfaceFormat.Color, - preferredDepthFormat: DepthFormat.None, - preferredMultiSampleCount: 0, - usage: RenderTargetUsage.PreserveContents); - }); + BakedBlendTexture = null; } public sealed override void SetupContent() @@ -77,22 +62,8 @@ namespace CalamityMod.Systems { Main.QueueMainThreadAction(() => { - if (BlendTextures is not null) - { - foreach (var rt in BlendTextures) - { - if (rt is null) - continue; - - if (rt.IsDisposed) - continue; - - rt.Dispose(); - } - - Array.Clear(BlendTextures); - BlendTextures = null; - } + BakedBlendTexture?.Dispose(); + BakedBlendTexture = null; }); PostUnload(); @@ -106,10 +77,10 @@ namespace CalamityMod.Systems #region Public API - public void RebuildBlendSheet(Texture2D texture = null) + public void RebuildBlendSheet(Asset texture = null) { - texture ??= TextureAsset.Value; - BakeBlendTexture(texture); + TextureAsset = texture ?? ModContent.Request(Texture); + ClearBakeCache(); } #endregion } diff --git a/Systems/TileMerging/TileBlendTextureLoader.cs b/Systems/TileMerging/TileBlendTextureLoader.cs index e5ec3cf46a..fa08ea73ae 100644 --- a/Systems/TileMerging/TileBlendTextureLoader.cs +++ b/Systems/TileMerging/TileBlendTextureLoader.cs @@ -1,12 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; using Terraria.ModLoader; namespace CalamityMod.Systems @@ -15,10 +9,10 @@ namespace CalamityMod.Systems { internal const int EmptySlot = 0; internal const int StartingIndex = 1; - internal const int MaxCount = 255; + internal const int MaxCount = ushort.MaxValue; - internal static TileBlendTexture[] Registry { get; private set; } - internal static IEnumerable AllTextures => Registry?.Where(tex => tex is not null); + internal static TileBlendTexture[] Registry = new TileBlendTexture[MaxCount]; + internal static IEnumerable AllTextures => Registry?.Where(tex => tex is not null) ?? []; internal static int Count => _UniqueSlot - StartingIndex; private static int _UniqueSlot = StartingIndex; @@ -34,6 +28,12 @@ namespace CalamityMod.Systems _UniqueSlot = StartingIndex; } + public override void ResizeArrays() + { + var textures = ModContent.GetContent(); + Array.Resize(ref Registry, textures.Count() + 1); + } + internal static int Register(TileBlendTexture sheet) { if (sheet.Slot >= 0) diff --git a/Systems/TileMerging/TileBlendTexture_Baking.cs b/Systems/TileMerging/TileBlendTexture_Baking.cs index 7b923009c2..a40a39dc52 100644 --- a/Systems/TileMerging/TileBlendTexture_Baking.cs +++ b/Systems/TileMerging/TileBlendTexture_Baking.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -12,57 +9,122 @@ namespace CalamityMod.Systems { public abstract partial class TileBlendTexture : ModTexturedType { - #region Sheet Baking Process - internal void BakeBlendTexture(Texture2D texture) + internal static int BakedCountInFrame = 0; + + private bool[] _IsBaked = new bool[VariantCount]; + private bool[] _RequestedVariants = new bool[VariantCount]; + private bool _IsRequestedAny = false; + private bool _IsSheetRequested = false; + private bool _ShouldClearRT = true; + + internal void ClearBakeCache() { - // It's baking moment - Main.QueueMainThreadAction(() => - { - BakeBlendTexture_Inner(texture); - }); + _IsBaked = new bool[VariantCount]; + _RequestedVariants = new bool[VariantCount]; + _IsRequestedAny = false; + _ShouldClearRT = true; } - private void BakeBlendTexture_Inner(Texture2D texture) + internal void RequestBake(int sheetIndex) { + if (!_IsBaked[sheetIndex]) + { + _RequestedVariants[sheetIndex] = true; + _IsRequestedAny = true; + } + } + + #region Sheet Baking Process + internal void BakeRequestedBlendTextureCache() + { + if (!_IsRequestedAny) + return; + + if (!TextureAsset.IsLoaded) + return; + + var texture = TextureAsset.Value; if (texture == null) - throw new ArgumentNullException(nameof(texture), "Texture is Null!"); + return; if (texture.IsDisposed) - throw new ArgumentException(paramName: nameof(texture), message: "Texture is Disposed!"); + return; + var graphicsDevice = Main.instance.GraphicsDevice; for (int v = 0; v < VariantCount; v++) { - var renderTarget = BlendTextures[v]; - var graphicsDevice = Main.instance.GraphicsDevice; - graphicsDevice.SetRenderTarget(renderTarget); - graphicsDevice.Clear(Color.Transparent); + int variant = v; + if (!_RequestedVariants[variant]) + continue; - Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Matrix.Identity, () => + if (BakedCountInFrame >= 3) + continue; + + var renderTarget = BakedBlendTexture; + if (renderTarget != null && !renderTarget.IsDisposed && !renderTarget.IsContentLost) { - for (int i = 0; i < 256; i++) + using (renderTarget.Scope(clearColor: _ShouldClearRT ? Color.Transparent : null)) { - var drawPos = SideFlagsToPositionInSheet((byte)i); - var mergeSides = (BlendSideFlags)i; + _ShouldClearRT = false; - // Easy cases, It match on Shape Lookup Sheet Directly - if (_ShapeLookup.TryGetValue(mergeSides, out var rects)) - { - Main.spriteBatch.Draw(texture, drawPos, rects[v], Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f); - continue; - } + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); - var extractedShapes = ConsumeMergeSides(mergeSides); - foreach (var shape in extractedShapes) - { - if (_ShapeLookup.TryGetValue(shape, out var shapeRects)) - { - Main.spriteBatch.Draw(texture, drawPos, shapeRects[v], Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f); - } - } + BakeBlendTextureCache(v); + + Main.spriteBatch.End(); } - }); - graphicsDevice.SetRenderTarget(null); + _RequestedVariants[variant] = false; + _IsBaked[variant] = true; + } + else if (!_IsSheetRequested) + { + _IsSheetRequested = true; + Main.QueueMainThreadAction(() => + { + BakedBlendTexture = new( + Main.instance.GraphicsDevice, + BlendTextureWidth, + BlendTextureFullHeight, + mipMap: false, + preferredFormat: SurfaceFormat.Color, + preferredDepthFormat: DepthFormat.None, + preferredMultiSampleCount: 0, + usage: RenderTargetUsage.PreserveContents); + + _IsSheetRequested = false; + }); + } + + BakedCountInFrame++; + } + + foreach (var requested in _RequestedVariants) + _IsRequestedAny |= requested; + } + + internal void BakeBlendTextureCache(int randomFrame) + { + for (int i = 0; i < 256; i++) + { + var mergeSides = (BlendSideFlags)i; + var sheetPosition = _SheetPositionLookup[new SheetPositionKey(mergeSides, (byte)randomFrame)]; + + // If it's basic shape, pull it from base texture instead + if (sheetPosition.IsUsingBaseTexture) + { + continue; + } + + var drawPos = sheetPosition.GetDrawPosition(); + var extractedShapes = ConsumeMergeSides(mergeSides); + foreach (var shape in extractedShapes) + { + if (_BasicShapeLookup.TryGetValue(shape, out var shapeRects)) + { + Main.spriteBatch.Draw(TextureAsset.Value, drawPos, shapeRects[randomFrame], Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f); + } + } } } @@ -91,16 +153,14 @@ namespace CalamityMod.Systems #endregion #region Utils - public static Rectangle SideFlagsToSheetRect(byte data) + public bool TryGetDrawingInfo(SheetPositionKey key, out Texture2D texture, out Rectangle sourceRect) { - int y = Math.DivRem(data, 16, out int x); - return new Rectangle(x * BlendTextureFrameWidth, y * BlendTextureFrameHeight, 16, 16); - } + var pos = _SheetPositionLookup[key]; - public static Vector2 SideFlagsToPositionInSheet(byte data) - { - int y = Math.DivRem(data, 16, out int x); - return new Vector2(x * BlendTextureFrameWidth, y * BlendTextureFrameHeight); + sourceRect = pos.GetDrawRect(); + texture = pos.IsUsingBaseTexture ? TextureAsset.Value : BakedBlendTexture; + + return texture != null; } #endregion } diff --git a/Systems/TileMerging/TileBlendTexture_Lookup.cs b/Systems/TileMerging/TileBlendTexture_Lookup.cs index 8fd90fccb3..ca93bbcf03 100644 --- a/Systems/TileMerging/TileBlendTexture_Lookup.cs +++ b/Systems/TileMerging/TileBlendTexture_Lookup.cs @@ -2,13 +2,9 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; -using System.Numerics; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Terraria.ModLoader; - using static CalamityMod.Systems.BlendSideFlags; namespace CalamityMod.Systems @@ -112,7 +108,7 @@ namespace CalamityMod.Systems #endregion #region Sheet Lookup - private static readonly Dictionary _ShapeLookup = new() + private static readonly Dictionary _BasicShapeLookup = new() { // Special Shapes: 5 [Shape_AllSide] = _AllClosed, @@ -185,6 +181,44 @@ namespace CalamityMod.Systems [ShapeU_RightEmpty_DownEnd] = _U_RightEmpty_DownEnd, }; + private static SheetPosition[] _SheetPositionLookup; + + private static void CalculateSheetPositionLookup() + { + if (_SheetPositionLookup != null) + return; + + _SheetPositionLookup = new SheetPosition[256 * VariantCount]; + + int bakeSheetIndex = 0; + for (int i = 0; i < 256; i++) + { + bool hasAddedToSheet = false; + + for (byte randomFrame = 0; randomFrame < VariantCount; randomFrame++) + { + var mergeSides = (BlendSideFlags)i; + var key = new SheetPositionKey(mergeSides, randomFrame); + + if (_BasicShapeLookup.TryGetValue(mergeSides, out var rects)) + { + var rect = rects[randomFrame]; + _SheetPositionLookup[key] = new SheetPosition(rect.X, rect.Y, bakedSheetIndex: -1); + } + else + { + var y = Math.DivRem(bakeSheetIndex, BlendTextureXCount, out var x); + var heightOffset = BlendTextureHeight * randomFrame; + _SheetPositionLookup[key] = new SheetPosition(x * BlendTextureFrameWidth, (y * BlendTextureFrameHeight) + heightOffset, bakedSheetIndex: (sbyte)randomFrame); + hasAddedToSheet = true; + } + } + + if (hasAddedToSheet) + bakeSheetIndex++; + } + } + #endregion #region Shape Lookup diff --git a/Systems/UIManagementSystem.cs b/Systems/UIManagementSystem.cs index fa9408ef58..6b32e4a2f1 100644 --- a/Systems/UIManagementSystem.cs +++ b/Systems/UIManagementSystem.cs @@ -104,6 +104,13 @@ namespace CalamityMod.Systems return true; }, InterfaceScaleType.None)); + // Unstable Caster's Gauntlet vis meter + layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Vis UI", () => + { + VisUI.Draw(Main.spriteBatch, Main.LocalPlayer); + return true; + }, InterfaceScaleType.None)); + // Enchantment meters layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Enchantment Meters", () => { diff --git a/Systems/VisualTimerSystem.cs b/Systems/VisualTimerSystem.cs new file mode 100644 index 0000000000..d83c514507 --- /dev/null +++ b/Systems/VisualTimerSystem.cs @@ -0,0 +1,17 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Systems +{ + public class VisualTimerSystem : ModSystem + { + /// + /// Dummy global variable that increments by one every frame. Good for animated visual effects. Not synced server side. + /// + public static float GlobalVisualTimer = 0f; + + public override void PostUpdateEverything() + { + GlobalVisualTimer++; + } + } +} diff --git a/Systems/World/BestiaryRegistrySystem.cs b/Systems/World/BestiaryRegistrySystem.cs index 10e32c9b49..ced469a837 100644 --- a/Systems/World/BestiaryRegistrySystem.cs +++ b/Systems/World/BestiaryRegistrySystem.cs @@ -1,8 +1,6 @@ using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.HiveMind; -using CalamityMod.NPCs.NormalNPCs; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; @@ -17,8 +15,6 @@ namespace CalamityMod.Systems ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()]; ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()]; ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()]; - ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()]; - ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCType()] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[NPCID.LavaSlime]; } } } diff --git a/Systems/World/MiscWorldStateSystem.cs b/Systems/World/MiscWorldStateSystem.cs index 2b95101060..ba62fb4ff6 100644 --- a/Systems/World/MiscWorldStateSystem.cs +++ b/Systems/World/MiscWorldStateSystem.cs @@ -6,7 +6,6 @@ using CalamityMod.NPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; using static CalamityMod.DownedBossSystem; @@ -56,7 +55,6 @@ namespace CalamityMod //Abyss.AbleToUnlockChests = false; //Yet another fucking failsave for abyss chests spawnedBandit = false; - spawnedCirrus = false; foundHomePermafrost = false; catName = false; @@ -92,8 +90,6 @@ namespace CalamityMod downed.Add("acidRain"); if (spawnedBandit) downed.Add("bandit"); - if (spawnedCirrus) - downed.Add("drunkPrincess"); if (foundHomePermafrost) downed.Add("archmageHome"); @@ -118,11 +114,6 @@ namespace CalamityMod downed.Add("HasGeneratedLuminitePlanetoids"); downed.AddWithCondition("IsWorldAfterDraedonUpdate", IsWorldAfterDraedonUpdate); - downed.AddWithCondition("TinOreWorld", OreTypes[0] == TileID.Tin); - downed.AddWithCondition("LeadOreWorld", OreTypes[1] == TileID.Lead); - downed.AddWithCondition("TungstenOreWorld", OreTypes[2] == TileID.Tungsten); - downed.AddWithCondition("PlatinumOreWorld", OreTypes[3] == TileID.Platinum); - RecipeUnlockHandler.Save(downed); tag["downed"] = downed; @@ -151,7 +142,6 @@ namespace CalamityMod BossRushEvent.BossRushActive = downed.Contains("bossRushActive"); AcidRainEvent.AcidRainEventIsOngoing = downed.Contains("acidRain"); spawnedBandit = downed.Contains("bandit"); - spawnedCirrus = downed.Contains("drunkPrincess"); foundHomePermafrost = downed.Contains("archmageHome"); #region Load Pet Names @@ -167,11 +157,6 @@ namespace CalamityMod HasGeneratedLuminitePlanetoids = downed.Contains("HasGeneratedLuminitePlanetoids"); IsWorldAfterDraedonUpdate = downed.Contains("IsWorldAfterDraedonUpdate"); - OreTypes[0] = downed.Contains("TinOreWorld") ? TileID.Tin : TileID.Copper; - OreTypes[1] = downed.Contains("LeadOreWorld") ? TileID.Lead : TileID.Iron; - OreTypes[2] = downed.Contains("TungstenOreWorld") ? TileID.Tungsten : TileID.Silver; - OreTypes[3] = downed.Contains("PlatinumOreWorld") ? TileID.Platinum : TileID.Gold; - RecipeUnlockHandler.Load(downed); Abyss.AbyssChasmBottom = tag.GetInt("abyssChasmBottom"); @@ -237,7 +222,7 @@ namespace CalamityMod BitsByte flags5 = new BitsByte(); flags5[0] = downedAstrumDeus; flags5[1] = spawnedBandit; - flags5[2] = spawnedCirrus; + flags5[2] = false; flags5[3] = AcidRainEvent.HasStartedAcidicDownpour; flags5[4] = false; flags5[5] = downedPolterghast; @@ -391,7 +376,7 @@ namespace CalamityMod BitsByte flags5 = reader.ReadByte(); downedAstrumDeus = flags5[0]; spawnedBandit = flags5[1]; - spawnedCirrus = flags5[2]; + _ = flags5[2]; AcidRainEvent.HasStartedAcidicDownpour = flags5[3]; _ = flags5[4]; downedPolterghast = flags5[5]; diff --git a/Systems/World/WorldMiscUpdateSystem.cs b/Systems/World/WorldMiscUpdateSystem.cs index ad3ac88db8..8568bd4e69 100644 --- a/Systems/World/WorldMiscUpdateSystem.cs +++ b/Systems/World/WorldMiscUpdateSystem.cs @@ -3,13 +3,13 @@ using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.ExoMechs; -using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PrimordialWyrm; using CalamityMod.Projectiles.Boss; using CalamityMod.Tiles; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Crags; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; using CalamityMod.Walls; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -67,7 +67,9 @@ namespace CalamityMod.Systems // Handle Acid Rain update logic. if (AcidRainEvent.AcidRainEventIsOngoing) + { AcidRainEvent.Update(); + } else { if (AcidRainEvent.TimeSinceEventStarted != 0) @@ -94,14 +96,14 @@ namespace CalamityMod.Systems { string key = Main.zenithWorld ? "Mods.CalamityMod.Status.Boss.AprilFoolsGFB" : "Mods.CalamityMod.Status.Boss.AprilFools"; Color messageColor = Color.Crimson; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); } // Disable sandstorms if the Desert Scourge is still alive and Hardmode hasn't begun. if (!DownedBossSystem.downedDesertScourge && Main.netMode != NetmodeID.MultiplayerClient && !Main.hardMode) CalamityWorld.StopSandstorm(); - // Attempt to summon lab critters manually since they refuse to exist when using vanilla's spawn methods. + // Attempt to summon lab critters and lava-based NPCs 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. foreach (Player p in Main.ActivePlayers) { @@ -109,8 +111,12 @@ namespace CalamityMod.Systems continue; CalamityGlobalNPC.AttemptToSpawnLabCritters(p); + CalamityGlobalNPC.AttemptToSpawnLavaNPCs(p); } + // Spawn the Old Man if Skeletron hasn't been defeated and there is no Old Man, it takes too fucking long otherwise. + TrySpawnOldMan(); + // Make the cultist countdown happen much more quickly. if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -146,12 +152,114 @@ namespace CalamityMod.Systems public static void HandleTileGrowth() { + double worldUpdateRate = WorldGen.GetWorldUpdateRate(); + if (worldUpdateRate == 0) + return; + + // Used for growing herbs at an accelerated rate + double herbGrowthRateSurface = 3E-05f * (float)worldUpdateRate; + double herbGrowthRateUnderground = 1.5E-05f * (float)worldUpdateRate; + double remixWorldHerbGrowthRate = 2.5E-05f * (float)worldUpdateRate; + + // 5% chance to boost non-planter box herb growth rate + // 50% chance to boost correct planter box herb growth rate + int oneInXChanceToBoostHerbGrowthRate = 20; + int oneInXChanceToBoostHerbGrowthRate_PlanterBox = 2; + + int oneInXMaximumChanceToPlaceHerb = 15100; + int oneInXMinimumChanceToPlaceHerb = (int)(oneInXMaximumChanceToPlaceHerb * 2.8); + double chanceAdjustmentBasedOnWorldSize = Utils.Clamp((double)Main.maxTilesX / 4200D - 1D, 0D, 1D); + int herbPlacementChance = (int)Utils.Lerp(oneInXMaximumChanceToPlaceHerb, oneInXMinimumChanceToPlaceHerb, chanceAdjustmentBasedOnWorldSize); + + for (int herbPlacementIndex = 0; (double)herbPlacementIndex < (double)(Main.maxTilesX * Main.maxTilesY) * herbGrowthRateSurface; herbPlacementIndex++) + { + // Call this again to give effectively double the chance for new herbs to be placed in the world + if (Main.rand.NextBool(herbPlacementChance)) + WorldGen.PlantAlch(); + + // Surface-only herb growth + // Increase the growth rate of herbs in planter boxes + // Slightly increase the growth rate of herbs not in planter boxes + int herbGrowthRangeX = WorldGen.genRand.Next(10, Main.maxTilesX - 10); + int herbGrowthRangeY = WorldGen.genRand.Next(10, (int)Main.worldSurface - 1); + if (Main.tileAlch[Main.tile[herbGrowthRangeX, herbGrowthRangeY].TileType]) + { + // If you use the wrong planter box you get fuck all + if (Main.tile[herbGrowthRangeX, herbGrowthRangeY + 1].TileType == TileID.PlanterBox) + { + int herbType = Main.tile[herbGrowthRangeX, herbGrowthRangeY].TileFrameX / 18; + int planterBoxType = Main.tile[herbGrowthRangeX, herbGrowthRangeY + 1].TileFrameY / 18; + if (IsCorrectPlanterBox(herbType: herbType, planterBoxType: planterBoxType) && WorldGen.genRand.NextBool(oneInXChanceToBoostHerbGrowthRate_PlanterBox)) + WorldGen.GrowAlch(herbGrowthRangeX, herbGrowthRangeY); + } + else if (WorldGen.genRand.NextBool(oneInXChanceToBoostHerbGrowthRate)) + WorldGen.GrowAlch(herbGrowthRangeX, herbGrowthRangeY); + } + } + + if (Main.remixWorld) + { + // Remix seed checks the entire world at once for herb growth + for (int herbGrowthIndex = 0; (double)herbGrowthIndex < (double)(Main.maxTilesX * Main.maxTilesY) * remixWorldHerbGrowthRate; herbGrowthIndex++) + { + // Increase the growth rate of herbs in planter boxes + // Slightly increase the growth rate of herbs not in planter boxes + int herbGrowthRangeX = WorldGen.genRand.Next(10, Main.maxTilesX - 10); + int herbGrowthRangeY = WorldGen.genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20); + if (Main.tileAlch[Main.tile[herbGrowthRangeX, herbGrowthRangeY].TileType]) + { + // If you use the wrong planter box you get fuck all + if (Main.tile[herbGrowthRangeX, herbGrowthRangeY + 1].TileType == TileID.PlanterBox) + { + int herbType = Main.tile[herbGrowthRangeX, herbGrowthRangeY].TileFrameX / 18; + int planterBoxType = Main.tile[herbGrowthRangeX, herbGrowthRangeY + 1].TileFrameY / 18; + if (IsCorrectPlanterBox(herbType: herbType, planterBoxType: planterBoxType) && WorldGen.genRand.NextBool(oneInXChanceToBoostHerbGrowthRate_PlanterBox)) + WorldGen.GrowAlch(herbGrowthRangeX, herbGrowthRangeY); + } + else if (WorldGen.genRand.NextBool(oneInXChanceToBoostHerbGrowthRate)) + WorldGen.GrowAlch(herbGrowthRangeX, herbGrowthRangeY); + } + } + } + else + { + // Underground-only herb growth + for (int herbGrowthIndex = 0; (double)herbGrowthIndex < (double)(Main.maxTilesX * Main.maxTilesY) * herbGrowthRateUnderground; herbGrowthIndex++) + { + // Increase the growth rate of herbs in planter boxes + // Slightly increase the growth rate of herbs not in planter boxes + int herbGrowthRangeX = WorldGen.genRand.Next(10, Main.maxTilesX - 10); + int herbGrowthRangeY = WorldGen.genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20); + if (Main.tileAlch[Main.tile[herbGrowthRangeX, herbGrowthRangeY].TileType]) + { + // If you use the wrong planter box you get fuck all + if (Main.tile[herbGrowthRangeX, herbGrowthRangeY + 1].TileType == TileID.PlanterBox) + { + int herbType = Main.tile[herbGrowthRangeX, herbGrowthRangeY].TileFrameX / 18; + int planterBoxType = Main.tile[herbGrowthRangeX, herbGrowthRangeY + 1].TileFrameY / 18; + if (IsCorrectPlanterBox(herbType: herbType, planterBoxType: planterBoxType) && WorldGen.genRand.NextBool(oneInXChanceToBoostHerbGrowthRate_PlanterBox)) + WorldGen.GrowAlch(herbGrowthRangeX, herbGrowthRangeY); + } + else if (WorldGen.genRand.NextBool(oneInXChanceToBoostHerbGrowthRate)) + WorldGen.GrowAlch(herbGrowthRangeX, herbGrowthRangeY); + } + } + } + + // 2MAY2025: Lucille: By default, the assumption that these values are within a natural min/max relationship with searchBottom being greater than searchTop is sensible. + // However, in subworlds where these lines may be placed arbitrarily (such as shoving the surface line near the bottom of the world), this no longer holds true, and results + // in the logic below causing a storm of minValue >= maxValue exceptions. + int searchTop = (int)Main.worldSurface - 1; + int searchBottom = Main.maxTilesY - 20; + if (searchBottom <= searchTop) + return; + int l = 0; - float mult2 = (float)(1.5E-05f * WorldGen.GetWorldUpdateRate()); + float mult2 = (float)(1.5E-05f * worldUpdateRate); while (l < Main.maxTilesX * Main.maxTilesY * mult2) { int x = WorldGen.genRand.Next(10, Main.maxTilesX - 10); - int y = WorldGen.genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20); + int y = WorldGen.genRand.Next(searchTop, searchBottom); int y2 = y - 1; if (y2 < 10) @@ -278,6 +386,9 @@ namespace CalamityMod.Systems if (tileType == TileType()) tileType2 = TileType(); + if (tileType == TileType()) + tileType2 = TileType(); + bool canPlaceBasedOnAttached = true; if (tileType2 == TileType() && !isSunkenSeaTile) canPlaceBasedOnAttached = false; @@ -338,7 +449,7 @@ namespace CalamityMod.Systems int tileTypeToPlaceThickness = 3; bool placeLilies = true; - // Do not change this number, ever. - Fabsol + // Apparently this is a reference! int minDistanceFromOtherLilies = 66; for (int k = x - minDistanceFromOtherLilies; k < x + minDistanceFromOtherLilies; k += 2) @@ -414,6 +525,72 @@ namespace CalamityMod.Systems return true; } + + public static bool IsCorrectPlanterBox(int herbType, int planterBoxType) + { + bool usingCorrectPlanterBox = false; + switch (herbType) + { + default: + break; + + case (int)HerbType.Daybloom: + if (planterBoxType == (int)PlanterBoxType.Daybloom) + usingCorrectPlanterBox = true; + break; + + case (int)HerbType.Moonglow: + if (planterBoxType == (int)PlanterBoxType.Moonglow) + usingCorrectPlanterBox = true; + break; + + case (int)HerbType.Blinkroot: + if (planterBoxType == (int)PlanterBoxType.Blinkroot) + usingCorrectPlanterBox = true; + break; + + case (int)HerbType.Deathweed: + if (planterBoxType == (int)PlanterBoxType.Deathweed || planterBoxType == (int)PlanterBoxType.DeathweedCrimson) + usingCorrectPlanterBox = true; + break; + + case (int)HerbType.Waterleaf: + if (planterBoxType == (int)PlanterBoxType.Waterleaf) + usingCorrectPlanterBox = true; + break; + + case (int)HerbType.Fireblossom: + if (planterBoxType == (int)PlanterBoxType.Fireblossom) + usingCorrectPlanterBox = true; + break; + + case (int)HerbType.Shiverthorn: + if (planterBoxType == (int)PlanterBoxType.Shiverthorn) + usingCorrectPlanterBox = true; + break; + } + + return usingCorrectPlanterBox; + } + #endregion + + #region Handle Old Man Spawn + public static void TrySpawnOldMan() + { + if (Main.netMode == NetmodeID.MultiplayerClient || NPC.downedBoss3 || Main.dayTime) + return; + + if (NPC.AnyNPCs(NPCID.OldMan)) + return; + + if (NPC.AnyNPCs(NPCID.SkeletronHead)) + return; + + int oldMan = NPC.NewNPC(NPC.GetSource_TownSpawn(), Main.dungeonX * 16 + 8, Main.dungeonY * 16, NPCID.OldMan); + Main.npc[oldMan].homeless = false; + Main.npc[oldMan].homeTileX = Main.dungeonX; + Main.npc[oldMan].homeTileY = Main.dungeonY; + } #endregion #region Handle Dungeon Guardian Spawns diff --git a/Systems/World/WorldgenManagementSystem.cs b/Systems/World/WorldgenManagementSystem.cs index 58ff723779..5399d037a4 100644 --- a/Systems/World/WorldgenManagementSystem.cs +++ b/Systems/World/WorldgenManagementSystem.cs @@ -3,10 +3,8 @@ using System.Threading; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Tiles.AstralSnow; -using CalamityMod.Tiles.Ores; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.World; -using CalamityMod.World.Minibiomes; using CalamityMod.World.Planets; using Microsoft.Xna.Framework; using Terraria; @@ -36,6 +34,41 @@ namespace CalamityMod.Systems #region ModifyWorldGenTasks public override void ModifyWorldGenTasks(List tasks, ref double totalWeight) { + // Better Underworld (similar to Don't Dig Up seed but with some adjustments) + int underworldIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Underworld")); + if (underworldIndex != -1) + { + tasks[underworldIndex] = new PassLegacy("Underworld", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.BetterUnderworld").Value; + CustomUnderworld.NewUnderworld(); + }); + } + + // Better Underworld structures after the world has been smoothed + int underworldStructuresIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Smooth World")); + if (underworldStructuresIndex != -1) + { + tasks.Insert(underworldStructuresIndex + 1, new PassLegacy("Underworld Structures", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.UnderworldStructures").Value; + CustomUnderworld.NewUnderworldStructures(); + + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.UnderworldTreesAndGrass").Value; + CustomUnderworld.AshTreesAndGrass(); + + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.UnderworldGeyserTraps").Value; + CustomUnderworld.PlaceGeyserTraps(); + })); + + // Generate the Shimmer Shrine directly above the center of the underground Shimmer lake + tasks.Insert(underworldStructuresIndex + 2, new PassLegacy("Shimmer Shrine", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.ShimmerShrine").Value; + ShimmerShrine.PlaceShimmerShrine(GenVars.structures); + })); + } + // Evil Floating Island int islandIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Island Houses")); if (islandIndex != -1) @@ -48,49 +81,71 @@ namespace CalamityMod.Systems } // Generate the Astral Chest right after the dungeon has finished generating - int DungeonIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Dungeon")); - tasks.Insert(DungeonIndex + 1, new PassLegacy("Astral Chest", (progress, config) => + int dungeonIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Dungeon")); + if (dungeonIndex != -1) { - progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.AstralChest").Value; - AstralChestGeneration.PlaceAstralChest(); - })); + tasks.Insert(dungeonIndex + 1, new PassLegacy("Astral Chest", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.AstralChest").Value; + AstralChestGeneration.PlaceAstralChest(); + })); + } + + // Generate a large Living Mahogany tree on the surface of the jungle (or anywhere in Drunk world) + int livingTreeIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Living Trees")); + if (livingTreeIndex != -1) + { + tasks.Insert(livingTreeIndex + 1, new PassLegacy("Living Mahogany Tree", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.LivingMahoganyTree").Value; + int attempts = 0; + while (attempts < 1000) + { + attempts++; + Point origin = WorldGen.RandomWorldPoint((int)Main.worldSurface + 25, 100, Main.maxTilesY - (int)Main.worldSurface - 125, 100); + if (GiantHive.GrowLivingJungleTree(origin, GenVars.structures)) + break; + } + })); + } // Larger Jungle Temple - int JungleTempleIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Jungle Temple")); - tasks[JungleTempleIndex] = new PassLegacy("Jungle Temple", (progress, config) => + int jungleTempleIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Jungle Temple")); + if (jungleTempleIndex != -1) { - progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.BetterJungleTemple").Value; - CustomTemple.NewJungleTemple(); - }); + tasks[jungleTempleIndex] = new PassLegacy("Jungle Temple", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.BetterJungleTemple").Value; + CustomTemple.NewJungleTemple(); + }); + } - // Floral Paradise Biome - tasks.Insert(JungleTempleIndex + 1, new PassLegacy("FloralParadise", (progress, config) => + // Improved Golem Arena + int jungleTempleIndex2 = tasks.FindIndex(genpass => genpass.Name.Equals("Temple")); + if (jungleTempleIndex2 != -1) { - progress.Message = "Growing a floral paradise underground"; - if (FloralParadiseMinibiome.SHOULD_GENERATE) - FloralParadiseMinibiome.GenerateInstances(); - })); + tasks[jungleTempleIndex2] = new PassLegacy("Temple", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.BetterJungleTemple").Value; + Main.tileSolid[162] = false; + Main.tileSolid[226] = true; + CustomTemple.NewJungleTemplePart2(); + Main.tileSolid[232] = false; + }); + } - // Improved Golem arena - int JungleTempleIndex2 = tasks.FindIndex(genpass => genpass.Name.Equals("Temple")); - tasks[JungleTempleIndex2] = new PassLegacy("Temple", (progress, config) => + // Better Lihzahrd Altar (consistency?) + int lihzahrdAltarIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Lihzahrd Altars")); + if (lihzahrdAltarIndex != -1) { - progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.BetterJungleTemple").Value; - Main.tileSolid[162] = false; - Main.tileSolid[226] = true; - CustomTemple.NewJungleTemplePart2(); - Main.tileSolid[232] = false; - }); + tasks[lihzahrdAltarIndex] = new PassLegacy("Lihzahrd Altars", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.JungleTempleAltar").Value; + CustomTemple.NewJungleTempleLihzahrdAltar(); + }); + } - // Better Lihzahrd altar (consistency?) - int LihzahrdAltarIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Lihzahrd Altars")); - tasks[LihzahrdAltarIndex] = new PassLegacy("Lihzahrd Altars", (progress, config) => - { - progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.JungleTempleAltar").Value; - CustomTemple.NewJungleTempleLihzahrdAltar(); - }); - - // Giant beehive + // Big Hive int giantHiveIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Hives")); if (giantHiveIndex != -1) { @@ -101,7 +156,7 @@ namespace CalamityMod.Systems while (attempts < 1000) { attempts++; - Point origin = WorldGen.RandomWorldPoint((int)Main.worldSurface + 25, 20, Main.maxTilesY - (int)Main.worldSurface - 125, 20); + Point origin = WorldGen.RandomWorldPoint((int)Main.worldSurface + 25, 100, Main.maxTilesY - (int)Main.UnderworldLayer + 125, 100); if (GiantHive.CanPlaceGiantHive(origin, GenVars.structures)) break; } @@ -110,7 +165,7 @@ namespace CalamityMod.Systems // Move spawn point in Celebrationmk10 to not be in the Sulphurous Sea int spawnPointIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Spawn Point")); - if (spawnPointIndex != -1 && WorldGen.tenthAnniversaryWorldGen && !WorldGen.getGoodWorldGen) + if (spawnPointIndex != -1 && WorldGen.tenthAnniversaryWorldGen && !WorldGen.remixWorldGen) { tasks.Insert(spawnPointIndex + 1, new PassLegacy("Fix Tenth Anniversary Spawn", (progress, config) => { @@ -128,7 +183,7 @@ namespace CalamityMod.Systems } } } - + })); } @@ -143,7 +198,7 @@ namespace CalamityMod.Systems })); } - // Vernal pass + // Vernal Pass int vernalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Muds Walls In Jungle")); if (vernalIndex != -1) { @@ -154,41 +209,46 @@ namespace CalamityMod.Systems })); } - // sunken sea - int SunkenSeaIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Cactus, Palm Trees, & Coral")); - if (SunkenSeaIndex != -1) + // Sunken Sea + int sunkenSeaIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Cactus, Palm Trees, & Coral")); + if (sunkenSeaIndex != -1) { - tasks.Insert(SunkenSeaIndex + 1, new PassLegacy("Sunken Sea", (progress, config) => + tasks.Insert(sunkenSeaIndex + 1, new PassLegacy("Sunken Sea", (progress, config) => { - progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SunkenSea").Value; - int sunkenSeaX = (GenVars.UndergroundDesertLocation.Left + GenVars.UndergroundDesertLocation.Right) / 2; int sunkenSeaY = Main.maxTilesY / 2; - SunkenSea.ForLoop = CalamityClientConfig.Instance.SunkenSeaMultiThreading switch - { - 2 => SunkenSea.CSharpParallelFor, - 1 => SunkenSea.ReLogicParallelFor, - _ => SunkenSea.NormalForLoop, - }; - // place each piece of the sunken sea based on the above positons - SunkenSea.PlaceRadiantReefs(sunkenSeaX - 100, sunkenSeaY + 75, true); - SunkenSea.PlaceRadiantReefs(sunkenSeaX + 100, sunkenSeaY + 75, false); - SunkenSea.PlacePolypForest(sunkenSeaX, sunkenSeaY + 500); + + // messages intentionally in the "incorrect" order for the player's experience. + // they'll see the OG message first, then subsequent biomes are placed in vertical order. + // it breaks up the 3 minute gen time and makes it more interesting for those who dont tab out while worldgen runs, + // rather than keeping the player in the dark about what's happening. + // it doesn't have to make sense, just be cool for the players :) -ena + //SunkenSea.PlaceBasaltGullyBorderBlend(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SunkenSea").Value; SunkenSea.PlaceBasaltGully(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.TimelessShores").Value; + SunkenSea.PlaceRadiantReefs(sunkenSeaX, sunkenSeaY + 110); + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.RadiantReefs").Value; + SunkenSea.PlacePolypForest(sunkenSeaX, sunkenSeaY + 500); + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.PolypForest").Value; SunkenSea.PlaceGleamingBurrows(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4) - 50); - SunkenSea.PlaceSunkenSeaAmbience(); - SunkenSea.BasaltGullyLavaCleanup(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); + SunkenSea.PlaceClamDen(sunkenSeaX, sunkenSeaY + 630); + SunkenSea.PlaceGleamingBurrowsGeodes(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4) - 50); + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.GleamingBurrows").Value; SunkenSea.PlaceTimelessShores(sunkenSeaX, sunkenSeaY); + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.BasaltGully").Value; + //SunkenSea.BasaltGullyLavaCleanup(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); + SunkenSea.PlaceSunkenSeaAmbience(); })); } // All further tasks occur right before vanilla worldgen is completed (which includes The Dirtiest Block and final secret seed adjustments) - int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup")); - if (FinalIndex != -1) + int finalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup")); + if (finalIndex != -1) { - int currentFinalIndex = FinalIndex - 1; + int currentFinalIndex = finalIndex - 1; // Reallocate gems so rarity corresponds to depth tasks.Insert(++currentFinalIndex, new PassLegacy("Gem Depth Adjustment", (progress, config) => @@ -210,10 +270,10 @@ namespace CalamityMod.Systems tasks.Insert(++currentFinalIndex, new PassLegacy("Planetoids", Planetoid.GenerateAllBasePlanetoids)); // Sulphurous Sea (Step 1) - int SulphurIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes")); - if (SulphurIndex != -1) + int sulphurIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes")); + if (sulphurIndex != -1) { - tasks.Insert(SulphurIndex + 1, new PassLegacy("Sulphur Sea", (progress, config) => + tasks.Insert(sulphurIndex + 1, new PassLegacy("Sulphur Sea", (progress, config) => { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SulphurSea").Value; @@ -369,16 +429,14 @@ namespace CalamityMod.Systems CalamityUtils.SpawnOre(TileID.Cobalt, 12E-05, 0.45f, 0.7f, 3, 8); CalamityUtils.SpawnOre(TileID.Palladium, 12E-05, 0.45f, 0.7f, 3, 8); - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); }); // Disable gen pass if Early Hardmode Rework is disabled. // Could just not add/remove gen pass, but that could lead to mod conflicts // in case whatever mod targets this specific gen pass. if (!CalamityServerConfig.Instance.EarlyHardmodeProgressionRework) - { hardmodeOreT1Pass.Disable(); - } tasks.Insert(announceIndex, hardmodeOreT1Pass); } @@ -410,6 +468,7 @@ namespace CalamityMod.Systems bool isMahoganyChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 8 * 36; bool isIvyChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 10 * 36; bool isIceChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 11 * 36; + bool isLihzahrdChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 16 * 36; bool isMushroomChest = isContainer1 && Main.tile[chest.x, chest.y].TileFrameX == 32 * 36; bool isMarniteChest = isContainer1 && (Main.tile[chest.x, chest.y].TileFrameX == 50 * 36 || Main.tile[chest.x, chest.y].TileFrameX == 51 * 36); @@ -418,7 +477,7 @@ namespace CalamityMod.Systems bool isSandstoneChest = isContainer2 && Main.tile[chest.x, chest.y].TileFrameX == 10 * 36; // Replace Suspicious Looking Eyes in Chests with random useful early game potions. - if (isBrownChest || isGoldChest || isMahoganyChest || isIvyChest || isIceChest || isMushroomChest || isMarniteChest || isDeadManChest || isSandstoneChest) + if (isBrownChest || isGoldChest || isMahoganyChest || isIvyChest || isIceChest || isLihzahrdChest || isMushroomChest || isMarniteChest || isDeadManChest || isSandstoneChest) { for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) { @@ -432,6 +491,13 @@ namespace CalamityMod.Systems break; } + if (isGoldChest) + { + chest.item[inventoryIndex].SetDefaults(ModContent.ItemType()); + chest.item[inventoryIndex].Prefix(-1); + break; + } + // 60% chance of 3-5 Mining Potions // 20% chance of 2-3 Builder's Potions // 20% chance of 5-9 Shine Potions @@ -467,111 +533,6 @@ namespace CalamityMod.Systems } } - // Give Dead Man's Chests better loot. - if (isDeadManChest) - { - for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) - { - // Cavern Dead Man's Chests - if (chest.y > GenVars.lavaLine || (chest.y <= GenVars.lavaLine && Main.remixWorld)) - { - if (chest.item[inventoryIndex].type == ItemID.Dynamite) - chest.item[inventoryIndex].SetDefaults(ItemID.StickyDynamite); - - if (chest.item[inventoryIndex].type == ItemID.JestersArrow) - { - chest.item[inventoryIndex].SetDefaults(ItemID.HolyArrow); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(25, 51); - } - - if (chest.item[inventoryIndex].type == ItemID.SilverBar || - chest.item[inventoryIndex].type == ItemID.TungstenBar || - chest.item[inventoryIndex].type == ItemID.GoldBar || - chest.item[inventoryIndex].type == ItemID.PlatinumBar) - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(6, 16); - - if (chest.item[inventoryIndex].type == ItemID.FlamingArrow) - { - chest.item[inventoryIndex].SetDefaults(ItemID.HellfireArrow); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(25, 51); - } - - if (chest.item[inventoryIndex].type == ItemID.ThrowingKnife) - { - chest.item[inventoryIndex].SetDefaults(ItemID.PoisonedKnife); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(25, 51); - } - - if (chest.item[inventoryIndex].type == ItemID.HealingPotion) - { - chest.item[inventoryIndex].SetDefaults(ItemID.RestorationPotion); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(3, 6); - } - - if (chest.item[inventoryIndex].type == ItemID.RecallPotion) - chest.item[inventoryIndex].SetDefaults(ItemID.PotionOfReturn); - - if (chest.item[inventoryIndex].type == ItemID.Torch) - { - chest.item[inventoryIndex].SetDefaults(ItemID.UltrabrightTorch); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(15, 30); - } - - if (chest.item[inventoryIndex].type == ItemID.Glowstick) - { - chest.item[inventoryIndex].SetDefaults(ItemID.SpelunkerGlowstick); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(15, 30); - } - - if (chest.item[inventoryIndex].type == ItemID.GoldCoin) - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(2, 4); - } - - // Underground Dead Man's Chests - else - { - if (chest.item[inventoryIndex].type == ItemID.Bomb) - { - chest.item[inventoryIndex].SetDefaults(ItemID.StickyBomb); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(10, 20); - } - - if (chest.item[inventoryIndex].type == ItemID.Rope) - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(100, 201); - - if (chest.item[inventoryIndex].type == ItemID.IronBar || - chest.item[inventoryIndex].type == ItemID.LeadBar || - chest.item[inventoryIndex].type == ItemID.SilverBar || - chest.item[inventoryIndex].type == ItemID.TungstenBar) - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(10, 20); - - if (chest.item[inventoryIndex].type == ItemID.WoodenArrow) - { - chest.item[inventoryIndex].SetDefaults(ItemID.FlamingArrow); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(25, 50); - } - - if (chest.item[inventoryIndex].type == ItemID.Shuriken) - { - chest.item[inventoryIndex].SetDefaults(ItemID.ThrowingKnife); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(25, 50); - } - - if (chest.item[inventoryIndex].type == ItemID.LesserHealingPotion) - { - chest.item[inventoryIndex].SetDefaults(ItemID.HealingPotion); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(3, 6); - } - - if (chest.item[inventoryIndex].type == ItemID.SilverCoin) - { - chest.item[inventoryIndex].SetDefaults(ItemID.GoldCoin); - chest.item[inventoryIndex].stack = WorldGen.genRand.Next(1, 3); - } - } - } - } - // Adds Desert Medallion and The Comb to Sandstone Chests, each at a 20% chance if (isSandstoneChest) { @@ -603,12 +564,6 @@ namespace CalamityMod.Systems } } } - - // Save the set of ores that got generated - OreTypes[0] = (ushort)GenVars.copperBar; - OreTypes[1] = (ushort)GenVars.ironBar; - OreTypes[2] = (ushort)GenVars.silverBar; - OreTypes[3] = (ushort)GenVars.goldBar; } #endregion } diff --git a/TileEntities/TEBaseTurret.cs b/TileEntities/TEBaseTurret.cs index 305b23f87e..0f925720ae 100644 --- a/TileEntities/TEBaseTurret.cs +++ b/TileEntities/TEBaseTurret.cs @@ -125,9 +125,10 @@ namespace CalamityMod.TileEntities // If the turret is too far off its mark or hasn't been around for long enough, don't fire at all. float deltaAngle = MathHelper.WrapAngle(Angle - targetAngle); bool angleCloseEnough = Math.Abs(deltaAngle) <= MaxTargetAngleDeviance; - if (!angleCloseEnough || FiringTime < FiringStartupDelay || !Collision.CanHitLine(turretPos, 1, 1, targetPos, 1, 1)) + if (!angleCloseEnough || FiringTime < FiringStartupDelay || !CalamityUtils.PreciseCanHitInLine(turretPos, (targetPos - turretPos).ToRotation(), (targetPos - turretPos).Length())) return; + // Don't shoot every frame, but sync up the firing cadence to the startup delay. if ((FiringTime - FiringStartupDelay) % FiringUseTime == 0) Shoot(turretPos); diff --git a/TileEntities/TECalamityPylon.cs b/TileEntities/TECalamityPylon.cs index 4f9c4fe060..e1b64a6094 100644 --- a/TileEntities/TECalamityPylon.cs +++ b/TileEntities/TECalamityPylon.cs @@ -2,7 +2,7 @@ namespace CalamityMod.TileEntities { - /// Copied from ExampleMod for documentation if needed for later -pixl + /// Copied from ExampleMod for documentation if needed for later /// /// This is an empty child class that acts exactly like the default implementation of the abstract /// class, which itself acts nearly identical to vanilla pylon TEs. This inheritance only exists so that modded pylon entities diff --git a/TileEntities/TECanvasPainting.cs b/TileEntities/TECanvasPainting.cs index da548665ae..4e806a12ec 100644 --- a/TileEntities/TECanvasPainting.cs +++ b/TileEntities/TECanvasPainting.cs @@ -1,5 +1,5 @@ using CalamityMod.Packets; -using CalamityMod.Tiles.Furniture; +using CalamityMod.Tiles.Furniture.Paintings; using Microsoft.Xna.Framework; using System.IO; using Terraria; @@ -17,7 +17,7 @@ namespace CalamityMod.TileEntities public override bool IsTileValidForEntity(int x, int y) { Tile tile = Main.tile[x, y]; - return tile.HasTile && (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) && tile.TileFrameX == 0 && tile.TileFrameY == 0; + return tile.HasTile && TileLoader.GetTile(tile.TileType) is BaseCanvasPainting && tile.TileFrameX == 0 && tile.TileFrameY == 0; } public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction, int alternate) diff --git a/TileEntities/TEChargingStation.cs b/TileEntities/TEChargingStation.cs index 03b10d8b21..ddb417b68c 100644 --- a/TileEntities/TEChargingStation.cs +++ b/TileEntities/TEChargingStation.cs @@ -7,7 +7,6 @@ using CalamityMod.Packets; using CalamityMod.Tiles.DraedonStructures; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; diff --git a/TileEntities/TECodebreaker.cs b/TileEntities/TECodebreaker.cs index 78fcd95db6..4e1dd4117b 100644 --- a/TileEntities/TECodebreaker.cs +++ b/TileEntities/TECodebreaker.cs @@ -1,7 +1,7 @@ using System.IO; using CalamityMod.CustomRecipes; using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.Packets; using CalamityMod.Systems.Collections; using CalamityMod.Tiles.DraedonSummoner; @@ -65,7 +65,7 @@ namespace CalamityMod.TileEntities public bool ContainsVoltageRegulationSystem; public bool ContainsCoolingCell; - public bool ContainsBloodSample; + public bool ContainsBloodyVein; public bool CanDecryptHeldSchematic { @@ -163,7 +163,7 @@ namespace CalamityMod.TileEntities totalCellsToDrop = 999; InputtedCellCount -= totalCellsToDrop; - int itemType = ContainsBloodSample ? ModContent.ItemType() : ModContent.ItemType(); + int itemType = ContainsBloodyVein ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(new EntitySource_TileEntity(this), x * 16, y * 16, 32, 32, itemType, totalCellsToDrop); } } @@ -270,7 +270,7 @@ namespace CalamityMod.TileEntities tag["HeldSchematicID"] = HeldSchematicID; tag["DecryptionCountdown"] = DecryptionCountdown; tag["InitialCellCountBeforeDecrypting"] = InitialCellCountBeforeDecrypting; - tag["ContainsBloodSample"] = ContainsBloodSample; + tag["ContainsBloodyVein"] = ContainsBloodyVein; } public override void LoadData(TagCompound tag) @@ -284,7 +284,7 @@ namespace CalamityMod.TileEntities HeldSchematicID = tag.GetInt("HeldSchematicID"); DecryptionCountdown = tag.GetInt("DecryptionCountdown"); InitialCellCountBeforeDecrypting = tag.GetInt("InitialCellCountBeforeDecrypting"); - ContainsBloodSample = tag.GetBool("ContainsBloodSample"); + ContainsBloodyVein = tag.GetBool("ContainsBloodyVein"); } public override void NetSend(BinaryWriter writer) @@ -298,7 +298,7 @@ namespace CalamityMod.TileEntities writer.Write(HeldSchematicID); writer.Write(DecryptionCountdown); writer.Write(InitialCellCountBeforeDecrypting); - writer.Write(ContainsBloodSample); + writer.Write(ContainsBloodyVein); } public override void NetReceive(BinaryReader reader) @@ -312,7 +312,7 @@ namespace CalamityMod.TileEntities HeldSchematicID = reader.ReadInt32(); DecryptionCountdown = reader.ReadInt32(); InitialCellCountBeforeDecrypting = reader.ReadInt32(); - ContainsBloodSample = reader.ReadBoolean(); + ContainsBloodyVein = reader.ReadBoolean(); } } } diff --git a/TileEntities/TELabHologramProjector.cs b/TileEntities/TELabHologramProjector.cs index 08eea38d87..584b15e47e 100644 --- a/TileEntities/TELabHologramProjector.cs +++ b/TileEntities/TELabHologramProjector.cs @@ -5,7 +5,6 @@ using CalamityMod.Packets; using CalamityMod.Tiles.DraedonStructures; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/TileEntities/TEPowerCellFactory.cs b/TileEntities/TEPowerCellFactory.cs index af36c627cd..eee1d3af4d 100644 --- a/TileEntities/TEPowerCellFactory.cs +++ b/TileEntities/TEPowerCellFactory.cs @@ -6,7 +6,6 @@ using CalamityMod.Packets; using CalamityMod.Tiles.DraedonStructures; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; diff --git a/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1.cs b/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1.cs index 9a9483acf8..48de32dd77 100644 --- a/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1.cs +++ b/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1.cs @@ -1,18 +1,14 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { public class AbyssGiantKelp1 : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1Glow"; public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -39,10 +35,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient if (closer && Main.rand.NextBool(100) && j > Main.worldSurface) { Dust dust; - dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 274, 279, DustID.Firefly, 0.23255825f, 10f, 0, new Color(117, 55, 15), 1.5116279f)]; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, new Color(157, 175, 15), Main.rand.NextFloat(1f, 2f))]; dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } } @@ -69,8 +65,5 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } //just clone the first one its literally the same size - public class AbyssGiantKelp2 : AbyssGiantKelp1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp2Glow"; - } + public class AbyssGiantKelp2 : AbyssGiantKelp1; } diff --git a/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3.cs b/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3.cs index 78b8f09f8c..9821fa04d6 100644 --- a/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3.cs +++ b/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3.cs @@ -1,19 +1,14 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { public class AbyssGiantKelp3 : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3Glow"; - public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -50,10 +45,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient if (closer && Main.rand.NextBool(100) && j > Main.worldSurface) { Dust dust; - dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 274, 279, DustID.Firefly, 0.23255825f, 10f, 0, new Color(117, 55, 15), 1.5116279f)]; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, new Color(157, 175, 15), Main.rand.NextFloat(1f, 2f))]; dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } } diff --git a/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4.cs b/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4.cs index 4068da5232..cdec3ba857 100644 --- a/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4.cs +++ b/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4.cs @@ -1,19 +1,14 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { public class AbyssGiantKelp4 : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4Glow"; - public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -50,10 +45,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient if (closer && Main.rand.NextBool(100) && j > Main.worldSurface) { Dust dust; - dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 274, 279, DustID.Firefly, 0.23255825f, 10f, 0, new Color(117, 55, 15), 1.5116279f)]; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, new Color(157, 175, 15), Main.rand.NextFloat(1f, 2f))]; dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } } diff --git a/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs b/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs index cea4527b3c..6763b26e40 100644 --- a/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs +++ b/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs @@ -1,9 +1,6 @@ using System; -using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; diff --git a/Tiles/Abyss/AbyssAmbient/AbyssVent.cs b/Tiles/Abyss/AbyssAmbient/AbyssVent.cs index b9fd302559..d950354511 100644 --- a/Tiles/Abyss/AbyssAmbient/AbyssVent.cs +++ b/Tiles/Abyss/AbyssAmbient/AbyssVent.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Environment; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -20,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(106, 80, 102), CalamityUtils.GetText($"{LocalizationCategory}.AbyssVent.MapEntry")); - DustType = 33; + DustType = DustID.Water; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/AbyssAmbient/BulbTree.cs b/Tiles/Abyss/AbyssAmbient/BulbTree.cs index c4900cc1c9..5f4bccf013 100644 --- a/Tiles/Abyss/AbyssAmbient/BulbTree.cs +++ b/Tiles/Abyss/AbyssAmbient/BulbTree.cs @@ -1,18 +1,14 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.ModLoader; +using Terraria.ID; using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { public class BulbTree1 : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree1Glow"; - public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -30,7 +26,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(52, 124, 153)); - DustType = 33; + DustType = DustID.Water; } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -51,13 +47,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } } - public class BulbTree2 : BulbTree1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree2Glow"; - } + public class BulbTree2 : BulbTree1; - public class BulbTree3 : BulbTree1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree3Glow"; - } + public class BulbTree3 : BulbTree1; } diff --git a/Tiles/Abyss/AbyssAmbient/GravelPile.cs b/Tiles/Abyss/AbyssAmbient/GravelPile.cs index 845ab3653e..562d71b249 100644 --- a/Tiles/Abyss/AbyssAmbient/GravelPile.cs +++ b/Tiles/Abyss/AbyssAmbient/GravelPile.cs @@ -1,9 +1,8 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -28,7 +27,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(17, 19, 38)); - DustType = 33; + DustType = DustID.Water; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs b/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs index eec910605f..0459a955f3 100644 --- a/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs +++ b/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(106, 80, 102)); - DustType = 33; + DustType = DustID.Water; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs b/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs index 4e4ed2bf49..75fc59bf73 100644 --- a/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs +++ b/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs @@ -1,9 +1,5 @@ -using System; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -43,17 +39,13 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - float brightness = 0.7f; - float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.01f; - brightness *= (float)MathF.Sin(-j / 8f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes + i); - brightness *= (float)MathF.Sin(-i / 8f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes + j); - brightness += 0.7f; - r = 0.55f; - g = 0.24f; - b = 0.08f; - r *= brightness; - g *= brightness; - b *= brightness; + Tile tile = Framing.GetTileSafely(i, j); + if (tile.TileFrameY <= 36) + { + r = 0.55f; + g = 0.24f; + b = 0.08f; + } } } } diff --git a/Tiles/Abyss/AbyssAmbient/PirateCrate.cs b/Tiles/Abyss/AbyssAmbient/PirateCrate.cs index d23102c5d6..748b68cec8 100644 --- a/Tiles/Abyss/AbyssAmbient/PirateCrate.cs +++ b/Tiles/Abyss/AbyssAmbient/PirateCrate.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -12,9 +11,9 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient // // Pirate Crate With Glow - public class PirateCrate1 : GlowMaskTile + public abstract class PirateCrateExplosive : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate1Glow"; + public abstract string GoreKey { get; } public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/CrateBreak", 3) { Volume = 0.8f }; public override void SetupStatic() @@ -36,9 +35,16 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient //explode when broken (troll!) //also instakill players in for the worthy Vector2 spawnPosition = new(i * 16f + 24f, j * 16f - 4f); - // NOTE: The damage of ProjectileID.Explosives is reduced in CalamityPlayerHitHurt, this actually deals 52 / 67 / 101 damage. + // NOTE: The damage of ProjectileID.Explosives is reduced in CalamityPlayerHitHurt, this actually deals 105 / 210 / 315 damage. int blastDamage = (Main.getGoodWorld ? 99999 : 150) * (Main.masterMode ? 3 : Main.expertMode ? 2 : 1); Projectile.NewProjectile(new EntitySource_WorldEvent(), spawnPosition.X, spawnPosition.Y, 0, 0, ProjectileID.Explosives, blastDamage, 0f); + + if (Main.dedServ) + return; + + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find($"{GoreKey}1").Type); + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find($"{GoreKey}2").Type); + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find($"{GoreKey}3").Type); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -52,21 +58,28 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } } - public class PirateCrate2 : PirateCrate1 + public class PirateCrate1 : PirateCrateExplosive { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate2Glow"; + public override string GoreKey => "PirateCrateL"; } - public class PirateCrate3 : PirateCrate1 + public class PirateCrate2 : PirateCrateExplosive { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate3Glow"; + public override string GoreKey => "PirateCrateM"; + } + + public class PirateCrate3 : PirateCrateExplosive + { + public override string GoreKey => "PirateCrateR"; } // // Pirate Crate Without Glow - public class PirateCrate4 : ModTile + public abstract class PirateCrateGold : ModTile { + public abstract string GoreKey { get; } + public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/CrateBreak", 3) { Volume = 0.8f }; public override void SetStaticDefaults() { @@ -90,6 +103,13 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.GoldCoin, Main.rand.Next(1, 2)); Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.SilverCoin, Main.rand.Next(45, 75)); + + if (Main.dedServ) + return; + + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find($"{GoreKey}1").Type); + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find($"{GoreKey}2").Type); + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16f, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find($"{GoreKey}3").Type); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -98,11 +118,18 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } } - public class PirateCrate5 : PirateCrate4 + public class PirateCrate4 : PirateCrateGold { + public override string GoreKey => "PirateCrateL"; } - public class PirateCrate6 : PirateCrate4 + public class PirateCrate5 : PirateCrateGold { + public override string GoreKey => "PirateCrateM"; + } + + public class PirateCrate6 : PirateCrateGold + { + public override string GoreKey => "PirateCrateR"; } } diff --git a/Tiles/Abyss/AbyssAmbient/PlantyMushPile.cs b/Tiles/Abyss/AbyssAmbient/PlantyMushPile.cs index 87e94672c2..fe6f3df5b9 100644 --- a/Tiles/Abyss/AbyssAmbient/PlantyMushPile.cs +++ b/Tiles/Abyss/AbyssAmbient/PlantyMushPile.cs @@ -1,9 +1,8 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -28,7 +27,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(84, 102, 39)); - DustType = 33; + DustType = DustID.Water; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/AbyssAmbient/ShalePile.cs b/Tiles/Abyss/AbyssAmbient/ShalePile.cs index 74bc1d1371..76465e149a 100644 --- a/Tiles/Abyss/AbyssAmbient/ShalePile.cs +++ b/Tiles/Abyss/AbyssAmbient/ShalePile.cs @@ -1,9 +1,8 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -28,7 +27,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(47, 30, 63)); - DustType = 33; + DustType = DustID.Water; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/AbyssAmbient/SpiderCoral.cs b/Tiles/Abyss/AbyssAmbient/SpiderCoral.cs index 75c72a5ecc..8a965a13c3 100644 --- a/Tiles/Abyss/AbyssAmbient/SpiderCoral.cs +++ b/Tiles/Abyss/AbyssAmbient/SpiderCoral.cs @@ -1,20 +1,13 @@ -using System; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { public class SpiderCoral1 : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral1Glow"; - public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -23,7 +16,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(82, 49, 27)); - DustType = 32; + DustType = DustID.Sand; } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -39,23 +32,11 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } } - public class SpiderCoral2 : SpiderCoral1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral2Glow"; - } + public class SpiderCoral2 : SpiderCoral1; - public class SpiderCoral3 : SpiderCoral1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral3Glow"; - } + public class SpiderCoral3 : SpiderCoral1; - public class SpiderCoral4 : SpiderCoral1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral4Glow"; - } + public class SpiderCoral4 : SpiderCoral1; - public class SpiderCoral5 : SpiderCoral1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral5Glow"; - } + public class SpiderCoral5 : SpiderCoral1; } diff --git a/Tiles/Abyss/AbyssAmbient/SulphurPireCoral.cs b/Tiles/Abyss/AbyssAmbient/SulphurPireCoral.cs index 76857a6d62..ff0aaeedcf 100644 --- a/Tiles/Abyss/AbyssAmbient/SulphurPireCoral.cs +++ b/Tiles/Abyss/AbyssAmbient/SulphurPireCoral.cs @@ -1,18 +1,14 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.ModLoader; +using Terraria.ID; using Terraria.ObjectData; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { public class SulphurPireCoral1 : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral1Glow"; - public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -30,7 +26,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(91, 128, 13)); - DustType = 32; + DustType = DustID.Sand; } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -51,13 +47,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } } - public class SulphurPireCoral2 : SulphurPireCoral1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral2Glow"; - } + public class SulphurPireCoral2 : SulphurPireCoral1; - public class SulphurPireCoral3 : SulphurPireCoral1 - { - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral3Glow"; - } + public class SulphurPireCoral3 : SulphurPireCoral1; } diff --git a/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs b/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs index c8d77c9451..a53b189eb2 100644 --- a/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs +++ b/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs @@ -1,9 +1,5 @@ -using System; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -29,7 +25,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); TileObjectData.addTile(Type); AddMapEntry(new Color(32, 65, 65)); - DustType = 32; + DustType = DustID.Sand; base.SetStaticDefaults(); } @@ -65,32 +61,15 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Tile tile = Framing.GetTileSafely(i, j); if (tile.TileFrameX <= 324) { - float brightness = 0.7f; - float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.0025f; - brightness *= (float)MathF.Sin(-j / 2f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes + i); - brightness *= (float)MathF.Sin(-i / 2f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes + j); - brightness += 0.7f; r = 0.26f; g = 0.4f; b = 0.41f; - r *= brightness; - g *= brightness; - b *= brightness; } - if (tile.TileFrameX > 324) { - float brightness = 0.7f; - float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.0025f; - brightness *= (float)MathF.Sin(-j / 2f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes + i); - brightness *= (float)MathF.Sin(-i / 2f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes + j); - brightness += 0.7f; r = 0.46f; g = 0.51f; b = 0f; - r *= brightness; - g *= brightness; - b *= brightness; } } } diff --git a/Tiles/Abyss/AbyssAmbient/SulphurTubeCoral.cs b/Tiles/Abyss/AbyssAmbient/SulphurTubeCoral.cs index 1d63d23213..f7870c5192 100644 --- a/Tiles/Abyss/AbyssAmbient/SulphurTubeCoral.cs +++ b/Tiles/Abyss/AbyssAmbient/SulphurTubeCoral.cs @@ -1,9 +1,8 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -28,7 +27,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(64, 36, 39)); - DustType = 32; + DustType = DustID.Sand; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs b/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs index e69543aebd..6b7a44da34 100644 --- a/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs +++ b/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs @@ -1,9 +1,5 @@ -using System; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; diff --git a/Tiles/Abyss/AbyssAmbient/ThermalVent.cs b/Tiles/Abyss/AbyssAmbient/ThermalVent.cs index 446118b8c7..645311ceb3 100644 --- a/Tiles/Abyss/AbyssAmbient/ThermalVent.cs +++ b/Tiles/Abyss/AbyssAmbient/ThermalVent.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -31,7 +32,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(132, 56, 42), CalamityUtils.GetText($"{LocalizationCategory}.ThermalVent.MapEntry")); - DustType = 162; + DustType = DustID.HeatRay; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/AbyssCoral.cs b/Tiles/Abyss/AbyssCoral.cs index f077ddbf58..82ba8decef 100644 --- a/Tiles/Abyss/AbyssCoral.cs +++ b/Tiles/Abyss/AbyssCoral.cs @@ -2,8 +2,6 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; -using Microsoft.Xna.Framework.Graphics; -using System; using CalamityMod.Systems; namespace CalamityMod.Tiles.Abyss @@ -22,7 +20,7 @@ namespace CalamityMod.Tiles.Abyss TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Dig; - DustType = 119; + DustType = DustID.Ice_Pink; AddMapEntry(new Color(70, 115, 144)); Main.tileShine2[Type] = true; @@ -33,17 +31,9 @@ namespace CalamityMod.Tiles.Abyss { if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) { - float brightness = 0.9f; - Color Color1 = new Color(52, 84, 107); - Color Color2 = new Color(29, 38, 56); - Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); - r = (value.R + value1.R) / 300f; - g = (value.G + value1.G) / 300f; - b = (value.B + value1.B) / 300f; - r *= brightness; - g *= brightness; - b *= brightness; + r = 0.17f; + g = 0.28f; + b = 0.36f; } } diff --git a/Tiles/Abyss/AbyssFossilTile.cs b/Tiles/Abyss/AbyssFossilTile.cs index 9fbaf659eb..4008c9f12a 100644 --- a/Tiles/Abyss/AbyssFossilTile.cs +++ b/Tiles/Abyss/AbyssFossilTile.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -17,7 +18,7 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); TileObjectData.addTile(Type); AddMapEntry(new Color(29, 37, 58), CalamityUtils.GetItemName()); - DustType = 33; + DustType = DustID.Water; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); } diff --git a/Tiles/Abyss/AbyssGravel.cs b/Tiles/Abyss/AbyssGravel.cs index 061e29abef..a2ce4b60b5 100644 --- a/Tiles/Abyss/AbyssGravel.cs +++ b/Tiles/Abyss/AbyssGravel.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -28,10 +26,10 @@ namespace CalamityMod.Tiles.Abyss MineResist = 5f; MinPick = 65; HitSound = MineSound; - DustType = 33; + DustType = DustID.Water; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override bool CanExplode(int i, int j) @@ -44,6 +42,11 @@ namespace CalamityMod.Tiles.Abyss num = fail ? 1 : 3; } + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + World.Abyss.FillTileWithWater(i, j); + } + public override void RandomUpdate(int i, int j) { Tile tile = Main.tile[i, j]; diff --git a/Tiles/Abyss/AbyssTreasureChest.cs b/Tiles/Abyss/AbyssTreasureChest.cs index fe8012ffbb..ff49ab2d56 100644 --- a/Tiles/Abyss/AbyssTreasureChest.cs +++ b/Tiles/Abyss/AbyssTreasureChest.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -11,16 +12,16 @@ namespace CalamityMod.Tiles.Abyss public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(71, 49, 41), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); - DustType = 33; + AddMapEntry(new Color(71, 49, 41), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + DustType = DustID.Water; } public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; public override void NumDust(int i, int j, bool fail, ref int num) => num = 1; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); // Locked Chest stuff @@ -44,7 +45,7 @@ namespace CalamityMod.Tiles.Abyss if (tile.TileFrameY != 0) top--; - return CalamityUtils.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j); + return FurnitureCommon.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j); } } } diff --git a/Tiles/Abyss/AbyssalPots.cs b/Tiles/Abyss/AbyssalPots.cs index 8e269c0357..6ea811d773 100644 --- a/Tiles/Abyss/AbyssalPots.cs +++ b/Tiles/Abyss/AbyssalPots.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(47, 79, 79), Language.GetText("MapObject.Pot")); // dark slate gray - DustType = 29; + DustType = DustID.WaterCandle; HitSound = SoundID.Shatter; } @@ -36,11 +36,10 @@ namespace CalamityMod.Tiles.Abyss { if (!Main.dedServ) { - int goreAmt = Main.rand.Next(1, 2 + 1); + int goreAmt = Main.rand.Next(2, 4 + 1); for (int k = 0; k < goreAmt; k++) { - Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore1").Type); - Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore2").Type); + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find($"AbyssPot{WorldGen.genRand.Next(1, 6 + 1)}").Type); } } diff --git a/Tiles/Abyss/AcidWoodTree.cs b/Tiles/Abyss/AcidWoodTree.cs index 59f1194b03..26a11e8b77 100644 --- a/Tiles/Abyss/AcidWoodTree.cs +++ b/Tiles/Abyss/AcidWoodTree.cs @@ -1,15 +1,15 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.FurnitureAcidwood; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.AcidRain; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.DataStructures; -using Terraria.Enums; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -54,6 +54,15 @@ namespace CalamityMod.Tiles.Abyss // Returning false at the end prevents vanilla behavior as the default is palm tree behavior which can include undesirable stuff like seagulls public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.HeldItem.type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -115,7 +124,7 @@ namespace CalamityMod.Tiles.Abyss if (type != -1) Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/Abyss/AcidWoodTreeSapling.cs b/Tiles/Abyss/AcidWoodTreeSapling.cs index 30a8bd2878..ecc1de60bf 100644 --- a/Tiles/Abyss/AcidWoodTreeSapling.cs +++ b/Tiles/Abyss/AcidWoodTreeSapling.cs @@ -67,11 +67,11 @@ namespace CalamityMod.Tiles.Abyss { return; } - if (tileAbovePosition.WallType != 0 || tileAbovePosition.LiquidAmount != 0) + if (tileAbovePosition.WallType != WallID.None || tileAbovePosition.LiquidAmount != 0) { return; } - if (!WorldGen.EmptyTileCheck(i - 1, i + 1, trueStartingPositionY - 30, trueStartingPositionY - 1, 20)) + if (!WorldGen.EmptyTileCheck(i - 1, i + 1, trueStartingPositionY - 20, trueStartingPositionY, Type)) { return; } diff --git a/Tiles/Abyss/CausticTorch.cs b/Tiles/Abyss/CausticTorch.cs new file mode 100644 index 0000000000..6d865de48d --- /dev/null +++ b/Tiles/Abyss/CausticTorch.cs @@ -0,0 +1,84 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Abyss +{ + public class CausticTorch : ModTile + { + public Asset FlameTexture; + + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(160, 210, 60), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + Tile tile = Main.tile[i, j]; + if (tile.TileFrameX < 66) + { + r = 1f; + g = 1.5f; + b = 0.4f; + } + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 0; + if (WorldGen.SolidTile(i, j - 1)) + { + offsetY = 2; + if (WorldGen.SolidTile(i - 1, j + 1) || WorldGen.SolidTile(i + 1, j + 1)) + { + offsetY = 4; + } + } + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/CausticTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].TileFrameX < 66) + CalamityUtils.DrawFlameSparks(Main.rand.NextBool() ? DustID.GreenTorch : DustID.YellowTorch, 5, i, j); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + + public override float GetTorchLuck(Player player) + { + // Note: Total Torch luck never goes below zero + return player.Calamity().ZoneAbyss ? 1f : -1f; // Abyss Torch gives positive luck when in the Abyss, otherwise some negative luck + } + } +} diff --git a/Tiles/Abyss/CausticTorch.png b/Tiles/Abyss/CausticTorch.png new file mode 100644 index 0000000000..190d710030 Binary files /dev/null and b/Tiles/Abyss/CausticTorch.png differ diff --git a/Tiles/Abyss/CausticTorchFlame.png b/Tiles/Abyss/CausticTorchFlame.png new file mode 100644 index 0000000000..7ecd0df17f Binary files /dev/null and b/Tiles/Abyss/CausticTorchFlame.png differ diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index 566169bb26..d5995c9137 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using CalamityMod.World; +using CalamityMod.World; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,12 +16,12 @@ namespace CalamityMod.Tiles.Abyss CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithAbyss(Type); - DustType = 32; + DustType = DustID.Sand; AddMapEntry(new Color(76, 58, 59)); HitSound = SoundID.Dig; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/SulphurousShaleMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Abyss/HydrothermalCrateTile.cs b/Tiles/Abyss/HydrothermalCrateTile.cs index adcc4b8153..347a1f1b82 100644 --- a/Tiles/Abyss/HydrothermalCrateTile.cs +++ b/Tiles/Abyss/HydrothermalCrateTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Fishing.SulphurCatches; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -21,7 +22,7 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(150, 109, 26), CalamityUtils.GetItemName()); - DustType = 127; + DustType = DustID.Flare; } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Abyss/KelpTorch.cs b/Tiles/Abyss/KelpTorch.cs new file mode 100644 index 0000000000..45a0591767 --- /dev/null +++ b/Tiles/Abyss/KelpTorch.cs @@ -0,0 +1,84 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Abyss +{ + public class KelpTorch : ModTile + { + public Asset FlameTexture; + + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(160, 210, 60), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + Tile tile = Main.tile[i, j]; + if (tile.TileFrameX < 66) + { + r = 1.8f; + g = 1.5f; + b = 0.4f; + } + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 0; + if (WorldGen.SolidTile(i, j - 1)) + { + offsetY = 2; + if (WorldGen.SolidTile(i - 1, j + 1) || WorldGen.SolidTile(i + 1, j + 1)) + { + offsetY = 4; + } + } + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/KelpTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].TileFrameX < 66) + CalamityUtils.DrawFlameSparks(DustID.YellowTorch, 5, i, j); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + + public override float GetTorchLuck(Player player) + { + // Note: Total Torch luck never goes below zero + return player.Calamity().ZoneAbyss ? 1f : -1f; // Abyss Torch gives positive luck when in the Abyss, otherwise some negative luck + } + } +} diff --git a/Tiles/Abyss/KelpTorch.png b/Tiles/Abyss/KelpTorch.png new file mode 100644 index 0000000000..d9797b9bca Binary files /dev/null and b/Tiles/Abyss/KelpTorch.png differ diff --git a/Tiles/Abyss/KelpTorchFlame.png b/Tiles/Abyss/KelpTorchFlame.png new file mode 100644 index 0000000000..2ff9f17160 Binary files /dev/null and b/Tiles/Abyss/KelpTorchFlame.png differ diff --git a/Tiles/Abyss/LumenylCrystals.cs b/Tiles/Abyss/LumenylCrystals.cs index 1564a8e581..3ebf622414 100644 --- a/Tiles/Abyss/LumenylCrystals.cs +++ b/Tiles/Abyss/LumenylCrystals.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss @@ -18,7 +17,7 @@ namespace CalamityMod.Tiles.Abyss AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(0, 150, 200), CalamityUtils.GetItemName()); HitSound = SoundID.Item27; - DustType = 67; + DustType = DustID.IceRod; Main.tileSpelunker[Type] = true; } diff --git a/Tiles/Abyss/PlantyMush.cs b/Tiles/Abyss/PlantyMush.cs index 48bfde5d53..f5006e1794 100644 --- a/Tiles/Abyss/PlantyMush.cs +++ b/Tiles/Abyss/PlantyMush.cs @@ -1,14 +1,11 @@ -using System.Collections.Generic; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss.AbyssAmbient; using CalamityMod.Walls; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss @@ -29,13 +26,13 @@ namespace CalamityMod.Tiles.Abyss CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithAbyss(Type); - DustType = 2; + DustType = DustID.Grass; AddMapEntry(new Color(84, 102, 39), CalamityUtils.GetItemName()); HitSound = MineSound; - 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.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); } int animationFrameWidth = 234; @@ -49,6 +46,10 @@ namespace CalamityMod.Tiles.Abyss { num = fail ? 1 : 3; } + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + World.Abyss.FillTileWithWater(i, j); + } public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { @@ -62,7 +63,7 @@ namespace CalamityMod.Tiles.Abyss Tile up2 = Main.tile[i, j - 2]; // Place kelp - if (WorldGen.genRand.NextBool(5)&& !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + if (WorldGen.genRand.NextBool(5) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) { up.TileType = (ushort)ModContent.TileType(); up.HasTile = true; @@ -83,7 +84,7 @@ namespace CalamityMod.Tiles.Abyss if (!down.HasTile && down.TileType != (ushort)ModContent.TileType()) { if (down.LiquidAmount == 255 && - down.WallType == (ushort)ModContent.WallType() && + down.WallType == (ushort)ModContent.WallType() && down.LiquidType != LiquidID.Lava) { bool canGrowVine = false; diff --git a/Tiles/Abyss/PyreMantle.cs b/Tiles/Abyss/PyreMantle.cs index 698c1b4422..ec54d493ee 100644 --- a/Tiles/Abyss/PyreMantle.cs +++ b/Tiles/Abyss/PyreMantle.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; +using CalamityMod.Sounds; using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -13,8 +9,6 @@ namespace CalamityMod.Tiles.Abyss { public class PyreMantle : ModTile { - public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -25,14 +19,19 @@ namespace CalamityMod.Tiles.Abyss CalamityUtils.MergeWithAbyss(Type); TileID.Sets.ChecksForMerge[Type] = true; - HitSound = MineSound; + HitSound = CommonCalamitySounds.VoidstoneMine; MineResist = 10f; MinPick = 180; AddMapEntry(new Color(43, 40, 40)); - 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.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + World.Abyss.FillTileWithWater(i, j); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Abyss/PyreMantleMolten.cs b/Tiles/Abyss/PyreMantleMolten.cs index a0f968d2e5..bf599fc813 100644 --- a/Tiles/Abyss/PyreMantleMolten.cs +++ b/Tiles/Abyss/PyreMantleMolten.cs @@ -1,12 +1,8 @@ using System; -using System.Collections.Generic; -using CalamityMod.Systems; +using CalamityMod.Sounds; using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -15,9 +11,7 @@ namespace CalamityMod.Tiles.Abyss { public class PyreMantleMolten : GlowMaskTile { - public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; - - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/PyreMantleMolten_Glowmask"; + public override string GlowMaskAsset => $"{Texture}_Glowmask"; public override void SetupStatic() { @@ -30,15 +24,15 @@ namespace CalamityMod.Tiles.Abyss CalamityUtils.MergeWithAbyss(Type); TileID.Sets.ChecksForMerge[Type] = true; - HitSound = MineSound; + HitSound = CommonCalamitySounds.VoidstoneMine; MineResist = 10f; MinPick = 180; AddMapEntry(new Color(113, 49, 16)); - 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"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override bool CreateDust(int i, int j, ref int type) @@ -52,6 +46,10 @@ namespace CalamityMod.Tiles.Abyss return false; } + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + World.Abyss.FillTileWithWater(i, j); + } public override void RandomUpdate(int i, int j) { Tile tile = Main.tile[i, j]; diff --git a/Tiles/Abyss/RustyChestTile.cs b/Tiles/Abyss/RustyChestTile.cs index fa7a0a62b8..3aac877bf3 100644 --- a/Tiles/Abyss/RustyChestTile.cs +++ b/Tiles/Abyss/RustyChestTile.cs @@ -10,14 +10,13 @@ namespace CalamityMod.Tiles.Abyss { public class RustyChestTile : ModTile { - public static int Type; + public static int TileType; public override void SetStaticDefaults() { - Type = (ushort)ModContent.TileType(); - + TileType = (ushort)ModContent.TileType(); this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(113, 90, 71), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(113, 90, 71), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -29,9 +28,9 @@ namespace CalamityMod.Tiles.Abyss public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/Abyss/ShaleColumns.cs b/Tiles/Abyss/ShaleColumns.cs index aeb276c33a..afcc0e7434 100644 --- a/Tiles/Abyss/ShaleColumns.cs +++ b/Tiles/Abyss/ShaleColumns.cs @@ -1,5 +1,4 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -34,7 +33,7 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.LavaDeath = true; TileObjectData.addTile(Type); AddMapEntry(new Color(37, 24, 63)); - DustType = 33; + DustType = DustID.Water; base.SetStaticDefaults(); } diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite1.cs b/Tiles/Abyss/Stalactite/SulphurousStalacmite1.cs index 0c4f69d871..8b3fc187b8 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalacmite1.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalacmite1.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite2.cs b/Tiles/Abyss/Stalactite/SulphurousStalacmite2.cs index a2a361ac51..8796ef26d1 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalacmite2.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalacmite2.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite3.cs b/Tiles/Abyss/Stalactite/SulphurousStalacmite3.cs index 87addf50b4..49d439f4f4 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalacmite3.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalacmite3.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite4.cs b/Tiles/Abyss/Stalactite/SulphurousStalacmite4.cs index 463c0e2b83..16cf536f43 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalacmite4.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalacmite4.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite5.cs b/Tiles/Abyss/Stalactite/SulphurousStalacmite5.cs index ecd1de42a8..27def20def 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalacmite5.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalacmite5.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalacmite6.cs b/Tiles/Abyss/Stalactite/SulphurousStalacmite6.cs index 9c38460fb0..65d8669fe3 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalacmite6.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalacmite6.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite1.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite1.cs index 8b630e7c01..57f9794684 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite1.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite1.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite2.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite2.cs index 49a6a89b6d..38705e37ea 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite2.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite2.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs index 8edf183ac8..c9f3bc00bb 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite3.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite4.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite4.cs index b4d01dbf91..853dbde853 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite4.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite4.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs index d2c8fc9e86..b8ffe73ada 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite5.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs b/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs index 7d8e5cb4a1..856fe08e36 100644 --- a/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs +++ b/Tiles/Abyss/Stalactite/SulphurousStalactite6.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphuricFossil1.cs b/Tiles/Abyss/SulphuricFossil1.cs index b6402192ed..68c809a505 100644 --- a/Tiles/Abyss/SulphuricFossil1.cs +++ b/Tiles/Abyss/SulphuricFossil1.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphuricFossil2.cs b/Tiles/Abyss/SulphuricFossil2.cs index 76fbe34ff3..bf0878611e 100644 --- a/Tiles/Abyss/SulphuricFossil2.cs +++ b/Tiles/Abyss/SulphuricFossil2.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphuricFossil3.cs b/Tiles/Abyss/SulphuricFossil3.cs index b3d35bcf97..fccf592535 100644 --- a/Tiles/Abyss/SulphuricFossil3.cs +++ b/Tiles/Abyss/SulphuricFossil3.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphurousColumn.cs b/Tiles/Abyss/SulphurousColumn.cs index 285effeb6a..4a71df01a9 100644 --- a/Tiles/Abyss/SulphurousColumn.cs +++ b/Tiles/Abyss/SulphurousColumn.cs @@ -3,8 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphurousCrateTile.cs b/Tiles/Abyss/SulphurousCrateTile.cs index bd4281ff65..50618c86c1 100644 --- a/Tiles/Abyss/SulphurousCrateTile.cs +++ b/Tiles/Abyss/SulphurousCrateTile.cs @@ -1,8 +1,7 @@ using CalamityMod.Items.Fishing.SulphurCatches; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -24,7 +23,7 @@ namespace CalamityMod.Tiles.Abyss TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(47, 79, 79), CalamityUtils.GetItemName()); // dark slate gray - DustType = 33; + DustType = DustID.Water; } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Abyss/SulphurousRib1.cs b/Tiles/Abyss/SulphurousRib1.cs index edd8db9364..f2724538ff 100644 --- a/Tiles/Abyss/SulphurousRib1.cs +++ b/Tiles/Abyss/SulphurousRib1.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphurousRib2.cs b/Tiles/Abyss/SulphurousRib2.cs index 018a012236..f4c66731f6 100644 --- a/Tiles/Abyss/SulphurousRib2.cs +++ b/Tiles/Abyss/SulphurousRib2.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphurousRib3.cs b/Tiles/Abyss/SulphurousRib3.cs index b99319f307..d391e9a183 100644 --- a/Tiles/Abyss/SulphurousRib3.cs +++ b/Tiles/Abyss/SulphurousRib3.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphurousRib4.cs b/Tiles/Abyss/SulphurousRib4.cs index 73e9e4ec64..f0f79cdaf4 100644 --- a/Tiles/Abyss/SulphurousRib4.cs +++ b/Tiles/Abyss/SulphurousRib4.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphurousRib5.cs b/Tiles/Abyss/SulphurousRib5.cs index f338ec9c9a..990e324160 100644 --- a/Tiles/Abyss/SulphurousRib5.cs +++ b/Tiles/Abyss/SulphurousRib5.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index c1782766db..4a5f1aa3da 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Enemy; using CalamityMod.World; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Metadata; @@ -29,14 +27,14 @@ namespace CalamityMod.Tiles.Abyss TileID.Sets.CanBeDugByShovel[Type] = true; - DustType = 32; + DustType = DustID.Sand; AddMapEntry(new Color(150, 100, 50)); HitSound = SoundID.Dig; - 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"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sand); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -79,7 +77,7 @@ namespace CalamityMod.Tiles.Abyss { for (int m = tileLocationY - ambientObjectDetectRadius; m <= tileLocationY + ambientObjectDetectRadius; m++) { - if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == 81) + if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == TileID.Coral) ambientObjectAmt++; } } @@ -101,7 +99,7 @@ namespace CalamityMod.Tiles.Abyss { for (int m = tileLocationY - ambientObjectDetectRadius; m <= tileLocationY + ambientObjectDetectRadius; m++) { - if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == 324) + if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == TileID.BeachPiles) ambientObjectAmt++; } } diff --git a/Tiles/Abyss/SulphurousSand.png b/Tiles/Abyss/SulphurousSand.png index 200e715bfc..cbfcee2433 100644 Binary files a/Tiles/Abyss/SulphurousSand.png and b/Tiles/Abyss/SulphurousSand.png differ diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index 716cfd62fb..06325ca0d0 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using CalamityMod.World; +using CalamityMod.World; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,13 +16,13 @@ namespace CalamityMod.Tiles.Abyss CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithAbyss(Type); - DustType = 32; + DustType = DustID.Sand; AddMapEntry(new Color(113, 90, 71)); HitSound = SoundID.Dig; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/HardenedSulphurousSandstoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -39,6 +37,8 @@ namespace CalamityMod.Tiles.Abyss { WorldGen.KillTile(i, j + 1); } + + World.Abyss.FillTileWithWater(i, j); } public override void RandomUpdate(int i, int j) diff --git a/Tiles/Abyss/SulphurousShale.cs b/Tiles/Abyss/SulphurousShale.cs index 1ecdc028b3..f355cc16a4 100644 --- a/Tiles/Abyss/SulphurousShale.cs +++ b/Tiles/Abyss/SulphurousShale.cs @@ -29,10 +29,14 @@ namespace CalamityMod.Tiles.Abyss MineResist = 3f; MinPick = 65; HitSound = MineSound; - DustType = 33; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AbyssGravelMerge"); + DustType = DustID.Water; + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); + } + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + World.Abyss.FillTileWithWater(i, j); } public override void NearbyEffects(int i, int j, bool closer) @@ -117,7 +121,7 @@ namespace CalamityMod.Tiles.Abyss Tile up2 = Main.tile[i, j - 2]; // Place sulphur tentacle corals - if (WorldGen.genRand.NextBool(10)&& !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + if (WorldGen.genRand.NextBool(10) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) { up.TileType = (ushort)ModContent.TileType(); up.HasTile = true; diff --git a/Tiles/Abyss/SulphurousTorch.cs b/Tiles/Abyss/SulphurousTorch.cs index 3ddf59809c..ccc2a335e7 100644 --- a/Tiles/Abyss/SulphurousTorch.cs +++ b/Tiles/Abyss/SulphurousTorch.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.Abyss { public class SulphurousTorch : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), waterImmune: true); public override bool CreateDust(int i, int j, ref int type) @@ -54,18 +57,19 @@ namespace CalamityMod.Tiles.Abyss public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/Abyss/SulphurousTorchFlame").Value, i, j, 2); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/SulphurousTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) { if (Main.tile[i, j].TileFrameX < 66) - CalamityUtils.DrawFlameSparks(Main.rand.NextBool() ? 61 : 64, 5, i, j); + CalamityUtils.DrawFlameSparks(Main.rand.NextBool() ? DustID.GreenTorch : DustID.YellowTorch, 5, i, j); } public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } diff --git a/Tiles/Abyss/SulphurousVines.cs b/Tiles/Abyss/SulphurousVines.cs index 58306e6d98..af18e329fe 100644 --- a/Tiles/Abyss/SulphurousVines.cs +++ b/Tiles/Abyss/SulphurousVines.cs @@ -3,10 +3,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.Drawing; using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss @@ -23,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss Main.tileNoSunLight[Type] = false; AddMapEntry(new Color(0, 50, 0)); HitSound = SoundID.Grass; - DustType = 2; + DustType = DustID.Grass; TileID.Sets.IsVine[Type] = true; TileID.Sets.ReplaceTileBreakDown[Type] = true; TileID.Sets.VineThreads[Type] = true; @@ -77,13 +75,13 @@ namespace CalamityMod.Tiles.Abyss public override void NearbyEffects(int i, int j, bool closer) { - if (closer && Main.rand.NextBool(200) && j > Main.worldSurface) + if (closer && Main.rand.NextBool(j > Main.worldSurface ? 200 : 300) && j > (Main.worldSurface - CalamityUtils.TilesToPixels(200))) { Dust dust; - dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 274, 279, DustID.Firefly, 0.23255825f, 10f, 0, new Color(22, 255, 0), 1.5116279f)]; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, j > Main.worldSurface ? new Color(200, 255, 0) : Color.Lime, Main.rand.NextFloat(1f, 2f))]; dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } } diff --git a/Tiles/Abyss/ThermalTorch.cs b/Tiles/Abyss/ThermalTorch.cs new file mode 100644 index 0000000000..e0511695d6 --- /dev/null +++ b/Tiles/Abyss/ThermalTorch.cs @@ -0,0 +1,102 @@ +using System.Linq; +using CalamityMod.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Abyss +{ + public class ThermalTorch : ModTile + { + public Asset FlameTexture; + + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(200, 0, 0), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + Tile tile = Main.tile[i, j]; + if (tile.TileFrameX < 66) + { + r = 2f; + g = 0.5f; + b = 0.5f; + } + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 0; + if (WorldGen.SolidTile(i, j - 1)) + { + offsetY = 2; + if (WorldGen.SolidTile(i - 1, j + 1) || WorldGen.SolidTile(i + 1, j + 1)) + { + offsetY = 4; + } + } + } + + public override void NearbyEffects(int i, int j, bool closer) + { + //This makes the placed torch cut through the abyss darkness. + var pos = new Point(i, j).ToWorldCoordinates(); + if (!closer && Main.LocalPlayer.Calamity().ZoneAbyss && !Main.gamePaused) + { + if (EnhancedDarknessSystem.lights.Any(x => x.center == pos)) + { + var e = EnhancedDarknessSystem.lights.First(x => x.center == pos); + e.lifetime = 5; + } + else + EnhancedDarknessSystem.lights.Add(new EnhancedDarknessSystem.LightSource(pos, scale: 2f) { lifetime = 5 }); + } + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/ThermalTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].TileFrameX < 66) + CalamityUtils.DrawFlameSparks(DustID.RedTorch, 5, i, j); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + + public override float GetTorchLuck(Player player) + { + // Note: Total Torch luck never goes below zero + return player.Calamity().ZoneAbyss ? 1f : -1f; // Abyss Torch gives positive luck when in the Abyss, otherwise some negative luck + } + } +} diff --git a/Tiles/Abyss/ThermalTorch.png b/Tiles/Abyss/ThermalTorch.png new file mode 100644 index 0000000000..8e3bf0608d Binary files /dev/null and b/Tiles/Abyss/ThermalTorch.png differ diff --git a/Tiles/Abyss/ThermalTorchFlame.png b/Tiles/Abyss/ThermalTorchFlame.png new file mode 100644 index 0000000000..1d4ddff980 Binary files /dev/null and b/Tiles/Abyss/ThermalTorchFlame.png differ diff --git a/Tiles/Abyss/ViperVines.cs b/Tiles/Abyss/ViperVines.cs index 232125a4e6..6337e7635f 100644 --- a/Tiles/Abyss/ViperVines.cs +++ b/Tiles/Abyss/ViperVines.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.Drawing; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -20,7 +19,7 @@ namespace CalamityMod.Tiles.Abyss TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Plant"]); AddMapEntry(new Color(0, 50, 0)); HitSound = SoundID.Grass; - DustType = 2; + DustType = DustID.Grass; } public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) @@ -69,39 +68,39 @@ namespace CalamityMod.Tiles.Abyss } public override void RandomUpdate(int i, int j) - { - Tile tileBelow = Framing.GetTileSafely(i, j + 1); - if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) { - bool PlaceVine = false; - int Test = j; - while (Test > j - 10) + bool PlaceVine = false; + int Test = j; + while (Test > j - 10) { - Tile testTile = Framing.GetTileSafely(i, Test); - if (testTile.BottomSlope) + Tile testTile = Framing.GetTileSafely(i, Test); + if (testTile.BottomSlope) { - break; - } - else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) + break; + } + else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) { - Test--; - continue; - } - PlaceVine = true; - break; - } - - if (PlaceVine) + Test--; + continue; + } + PlaceVine = true; + break; + } + + if (PlaceVine) { - tileBelow.TileType = Type; - tileBelow.HasTile = true; - WorldGen.SquareTileFrame(i, j + 1, true); - if (Main.dedServ) + tileBelow.TileType = Type; + tileBelow.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.dedServ) { - NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); - } - } - } - } + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } } } diff --git a/Tiles/Abyss/VoidTorch.cs b/Tiles/Abyss/VoidTorch.cs new file mode 100644 index 0000000000..83c12b9248 --- /dev/null +++ b/Tiles/Abyss/VoidTorch.cs @@ -0,0 +1,103 @@ +using System.Linq; +using CalamityMod.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Abyss +{ + [LegacyName("AbyssTorch")] + public class VoidTorch : ModTile + { + public Asset FlameTexture; + + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 130, 150), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + Tile tile = Main.tile[i, j]; + if (tile.TileFrameX < 66) + { + r = 0.6f; + g = 0.6f; + b = 2.3f; + } + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 0; + if (WorldGen.SolidTile(i, j - 1)) + { + offsetY = 2; + if (WorldGen.SolidTile(i - 1, j + 1) || WorldGen.SolidTile(i + 1, j + 1)) + { + offsetY = 4; + } + } + } + + public override void NearbyEffects(int i, int j, bool closer) + { + //This makes the placed torch cut through the abyss darkness. + var pos = new Point(i, j).ToWorldCoordinates(); + if (!closer && Main.LocalPlayer.Calamity().ZoneAbyss && !Main.gamePaused) + { + if (EnhancedDarknessSystem.lights.Any(x => x.center == pos)) + { + var e = EnhancedDarknessSystem.lights.First(x => x.center == pos); + e.lifetime = 5; + } + else + EnhancedDarknessSystem.lights.Add(new EnhancedDarknessSystem.LightSource(pos, scale: 2f) { lifetime = 5 }); + } + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/VoidTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].TileFrameX < 66) + CalamityUtils.DrawFlameSparks(DustID.BlueFlare, 5, i, j); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + + public override float GetTorchLuck(Player player) + { + // Note: Total Torch luck never goes below zero + return player.Calamity().ZoneAbyss ? 1f : -1f; // Abyss Torch gives positive luck when in the Abyss, otherwise some negative luck + } + } +} diff --git a/Tiles/FurnitureAbyss/AbyssTorch.png b/Tiles/Abyss/VoidTorch.png similarity index 100% rename from Tiles/FurnitureAbyss/AbyssTorch.png rename to Tiles/Abyss/VoidTorch.png diff --git a/Tiles/FurnitureAbyss/AbyssTorchFlame.png b/Tiles/Abyss/VoidTorchFlame.png similarity index 100% rename from Tiles/FurnitureAbyss/AbyssTorchFlame.png rename to Tiles/Abyss/VoidTorchFlame.png diff --git a/Tiles/Abyss/Voidstone.cs b/Tiles/Abyss/Voidstone.cs index e9ce5af903..f7a54ccc74 100644 --- a/Tiles/Abyss/Voidstone.cs +++ b/Tiles/Abyss/Voidstone.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; +using CalamityMod.ExtraTextures.GreyscaleGradients; +using CalamityMod.Sounds; using CalamityMod.Systems; using CalamityMod.Tiles.Abyss.AbyssAmbient; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -15,37 +12,26 @@ namespace CalamityMod.Tiles.Abyss { public class Voidstone : GlowMaskTile { - public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; - - public override string GlowMaskAsset => "CalamityMod/Tiles/Abyss/Voidstone_Glowmask"; - public GrayscaleTexture2D NoiseTexture; + public override string GlowMaskAsset => $"{Texture}_Glowmask"; public override void SetupStatic() { - NoiseTexture = new("CalamityMod/ExtraTextures/GreyscaleGradients/BlobbyNoise"); - Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; - Main.tileBrick[Type] = true; + Main.tileBrick[Type] = true; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithAbyss(Type); TileID.Sets.ChecksForMerge[Type] = true; - HitSound = MineSound; + HitSound = CommonCalamitySounds.VoidstoneMine; MineResist = 15f; MinPick = 180; AddMapEntry(new Color(15, 15, 15)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/PyreMantleMerge"); - } - - public override void OnUnload() - { - NoiseTexture?.Unload(); - NoiseTexture = null; + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); } int animationFrameWidth = 234; @@ -55,6 +41,10 @@ namespace CalamityMod.Tiles.Abyss Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.DungeonSpirit, 0f, 0f, 1, new Color(128, 128, 128), 1f); return false; } + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + World.Abyss.FillTileWithWater(i, j); + } public override bool CanExplode(int i, int j) { @@ -91,7 +81,7 @@ namespace CalamityMod.Tiles.Abyss public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { int time = (int)(Main.timeForVisualEffects * 0.11); - float brightness = 1.0f - NoiseTexture.GetRepeat((i * 100) + time, (j * 100) + time); + float brightness = 1.0f - GreyscaleGradient.BlobbyNoise.GetRepeat((i * 100) + time, (j * 100) + time); brightness -= 0.55f; return new Color(brightness, brightness, brightness); } diff --git a/Tiles/AerialiteBarTile.cs b/Tiles/AerialiteBarTile.cs index afc5b1b830..b2566938ff 100644 --- a/Tiles/AerialiteBarTile.cs +++ b/Tiles/AerialiteBarTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles @@ -10,7 +11,7 @@ namespace CalamityMod.Tiles public override void SetStaticDefaults() { this.SetUpBar(ModContent.ItemType(), new Color(141, 232, 246)); - DustType = 187; + DustType = DustID.BlueFlare; } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/AerialiteBrick.cs b/Tiles/AerialiteBrick.cs index 0c908aeccc..60e82b1ee9 100644 --- a/Tiles/AerialiteBrick.cs +++ b/Tiles/AerialiteBrick.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,8 +16,8 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(68, 58, 145)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) diff --git a/Tiles/ArenaTile.cs b/Tiles/ArenaTile.cs deleted file mode 100644 index 8e25df1098..0000000000 --- a/Tiles/ArenaTile.cs +++ /dev/null @@ -1,60 +0,0 @@ -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.Skies; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles -{ - public class ArenaTile : ModTile - { - public override void SetStaticDefaults() - { - MinPick = int.MaxValue; - Main.tileSolid[Type] = true; - Main.tileMergeDirt[Type] = true; - Main.tileBlockLight[Type] = true; - AddMapEntry(new Color(128, 0, 0), CreateMapEntryName()); - } - - public override bool CanKillTile(int i, int j, ref bool blockDamaged) - { - return false; - } - - public override bool CanExplode(int i, int j) - { - return false; - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (closer) - { - if (!SCalSky.RitualDramaProjectileIsPresent) - { - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - if (!(NPC.AnyNPCs(ModContent.NPCType()) && Main.zenithWorld)) - { - WorldGen.KillTile(i, j, false, false, false); - if (!Main.tile[i, j].HasTile && Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); - } - } - } - } - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = (float)Main.DiscoR / 255f; - g = 0f; - b = 0f; - } - } -} diff --git a/Tiles/ArenaTile.png b/Tiles/ArenaTile.png deleted file mode 100644 index 9843ac8e7b..0000000000 Binary files a/Tiles/ArenaTile.png and /dev/null differ diff --git a/Tiles/Astral/AstralBeacon.cs b/Tiles/Astral/AstralBeacon.cs index 399fc784f8..8040ce829c 100644 --- a/Tiles/Astral/AstralBeacon.cs +++ b/Tiles/Astral/AstralBeacon.cs @@ -10,7 +10,6 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -20,7 +19,6 @@ namespace CalamityMod.Tiles.Astral { public const int Width = 5; public const int Height = 4; - public static readonly Color FailColor = new Color(237, 93, 83); public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Custom/AstralBeaconUse"); @@ -32,6 +30,7 @@ namespace CalamityMod.Tiles.Astral // Various data sets to protect this tile from unintentional death TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; + TileID.Sets.PreventsTileHammeringIfOnTopOfIt[Type] = true; TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; TileID.Sets.PreventsSandfall[Type] = true; @@ -69,12 +68,6 @@ namespace CalamityMod.Tiles.Astral bool usingStarcore = Main.LocalPlayer.HasItem(ModContent.ItemType()); - if (Main.IsItDay()) - { - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Status.Boss.DeusAltarRejectNightText", FailColor); - return false; - } - Vector2 ritualSpawnPosition = new Vector2(left + Width / 2, top).ToWorldCoordinates(); ritualSpawnPosition += new Vector2(0f, -24f); diff --git a/Tiles/Astral/AstralChestLocked.cs b/Tiles/Astral/AstralChestLocked.cs index cb4ea46421..6342c7cac9 100644 --- a/Tiles/Astral/AstralChestLocked.cs +++ b/Tiles/Astral/AstralChestLocked.cs @@ -21,15 +21,15 @@ namespace CalamityMod.Tiles.Astral public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; public override void NumDust(int i, int j, bool fail, ref int num) => num = 1; - public string MapChestName(string name, int i, int j) => CalamityUtils.GetMapChestName(name, i, j); + public string MapChestName(string name, int i, int j) => FurnitureCommon.GetMapChestName(name, i, j); public override ushort GetMapOption(int i, int j) => (ushort)(Main.tile[i, j].TileFrameX / 36); public override LocalizedText DefaultContainerName(int frameX, int frameY) { int option = frameX / 36; return this.GetLocalization("MapEntry" + option); } - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); // Locked Chest stuff @@ -57,7 +57,7 @@ namespace CalamityMod.Tiles.Astral { top--; } - return CalamityUtils.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j); + return FurnitureCommon.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j); } } } diff --git a/Tiles/Astral/AstralClay.cs b/Tiles/Astral/AstralClay.cs index b84e3de8ab..98ac70b9b9 100644 --- a/Tiles/Astral/AstralClay.cs +++ b/Tiles/Astral/AstralClay.cs @@ -1,8 +1,5 @@ - -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -30,7 +27,7 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.CanBeDugByShovel[Type] = true; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Astral/AstralCrateTile.cs b/Tiles/Astral/AstralCrateTile.cs index 9de21644ba..7b4bd051c0 100644 --- a/Tiles/Astral/AstralCrateTile.cs +++ b/Tiles/Astral/AstralCrateTile.cs @@ -2,8 +2,6 @@ using CalamityMod.Items.Fishing.AstralCatches; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Astral/AstralDirt.cs b/Tiles/Astral/AstralDirt.cs index 43204bb557..9236fa8ff9 100644 --- a/Tiles/Astral/AstralDirt.cs +++ b/Tiles/Astral/AstralDirt.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent.Metadata; using Terraria.ID; @@ -35,8 +33,8 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; TileID.Sets.Conversion.Dirt[Type] = true; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override void RandomUpdate(int i, int j) diff --git a/Tiles/Astral/AstralDirt.png b/Tiles/Astral/AstralDirt.png index 47b54336de..0a6f5d2d23 100644 Binary files a/Tiles/Astral/AstralDirt.png and b/Tiles/Astral/AstralDirt.png differ diff --git a/Tiles/Astral/AstralMonolith.cs b/Tiles/Astral/AstralMonolith.cs deleted file mode 100644 index 5dd4bb0a03..0000000000 --- a/Tiles/Astral/AstralMonolith.cs +++ /dev/null @@ -1,143 +0,0 @@ - -using System.Collections.Generic; -using CalamityMod.Dusts; -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent.Metadata; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.Astral -{ - public class AstralMonolith : ModTile - { - private static int sheetWidth = 216; - private static int sheetHeight = 72; - - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Wood"]); - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeAstralTiles(Type); - CalamityUtils.SetMerge(Type, TileID.LeafBlock); - CalamityUtils.SetMerge(Type, TileID.LivingMahoganyLeaves); - CalamityUtils.SetMerge(Type, TileID.LivingWood); - CalamityUtils.SetMerge(Type, TileID.LivingMahogany); - - AddMapEntry(new Color(45, 36, 63)); - - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); - return false; - } - - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - int xPos = i % 4; - int yPos = j % 4; - - if ((xPos == 0 && yPos == 2) || (xPos == 1 && yPos == 3) || (xPos == 3 && yPos == 1)) - Main.tile[i, j].Get().TileFrameNumber = Main.tile[i, j - 1].TileFrameNumber; - else if (xPos == 2 && yPos == 2) - Main.tile[i, j].Get().TileFrameNumber = Main.tile[i - 1, j].TileFrameNumber; - else if (xPos == 2 && yPos == 3) - Main.tile[i, j].Get().TileFrameNumber = Main.tile[i - 1, j - 1].TileFrameNumber; - - GetDrawSpecifics(i, j, ref xPos, ref yPos); - - frameXOffset = xPos * sheetWidth; - frameYOffset = yPos * sheetHeight; - } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - Tile tile = Main.tile[i, j]; - if (tile.IsTileActuallyInvisible()) - return; - - int xOffset = i % 4; - int yOffset = j % 4; - - GetDrawSpecifics(i, j, ref xOffset, ref yOffset); - - xOffset *= sheetWidth; - yOffset *= sheetHeight; - - int xPos = tile.TileFrameX; - int yPos = tile.TileFrameY; - xPos += xOffset; - yPos += yOffset; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/Astral/AstralMonolithGlow").Value; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(50, 50, 50, 50)); - if (!tile.IsHalfBlock && tile.Slope == 0) - { - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - } - else if (tile.IsHalfBlock) - { - 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); - } - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFramingSystem.CompactFraming(i, j, resetFrame); - return false; - } - - private void GetDrawSpecifics(int i, int j, ref int xPos, ref int yPos) - { - Tile tile = Main.tile[i, j]; - // Make sure the features work as intended - if (tile.TileFrameNumber == 1) - { - if (xPos == 0 && (yPos == 1 || yPos == 2)) - yPos += 3; - else if ((xPos == 1 || xPos == 2) && (yPos == 2 || yPos == 3)) - yPos += 2; - else if (xPos == 3 && (yPos == 0 || yPos == 1)) - yPos += 4; - } - else if (tile.TileFrameNumber == 2) - { - if (xPos == 1 && yPos == 0) - { - xPos = 0; - yPos = 6; - } - else if (xPos == 2 && yPos == 1) - { - xPos = 1; - yPos = 6; - } - else if (xPos == 1 && yPos == 3) - { - xPos = 2; - yPos = 6; - } - else if (xPos == 3 && yPos == 3) - { - xPos = 3; - yPos = 6; - } - } - } - - public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) - { - sightColor = Color.Cyan; - return true; - } - } -} diff --git a/Tiles/Astral/AstralShortPlants.cs b/Tiles/Astral/AstralShortPlants.cs index 409ed6b84a..86a11279aa 100644 --- a/Tiles/Astral/AstralShortPlants.cs +++ b/Tiles/Astral/AstralShortPlants.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Tiles.Astral Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; if (nearestPlayer.active) { - if (nearestPlayer.ActiveItem().type == ItemID.Sickle) + if (nearestPlayer.HeldItem.type == ItemID.Sickle) yield return new Item(ItemID.Hay, Main.rand.Next(1, 2 + 1)); } } diff --git a/Tiles/Astral/AstralStone.cs b/Tiles/Astral/AstralStone.cs index 75f1648019..db83d4d519 100644 --- a/Tiles/Astral/AstralStone.cs +++ b/Tiles/Astral/AstralStone.cs @@ -1,8 +1,5 @@ - -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -32,9 +29,9 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.Conversion.Stone[Type] = true; TileID.Sets.CanBeClearedDuringOreRunner[Type] = 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"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Astral/AstralStoneLargePiles.cs b/Tiles/Astral/AstralStoneLargePiles.cs index bce2f92b0e..4cd43860c1 100644 --- a/Tiles/Astral/AstralStoneLargePiles.cs +++ b/Tiles/Astral/AstralStoneLargePiles.cs @@ -1,8 +1,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Astral/AstralStoneMediumPiles.cs b/Tiles/Astral/AstralStoneMediumPiles.cs index 8ff73668f3..6a915a9c0c 100644 --- a/Tiles/Astral/AstralStoneMediumPiles.cs +++ b/Tiles/Astral/AstralStoneMediumPiles.cs @@ -1,8 +1,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Astral/AstralStoneSmallPiles.cs b/Tiles/Astral/AstralStoneSmallPiles.cs index d8215382c1..72285b8aa7 100644 --- a/Tiles/Astral/AstralStoneSmallPiles.cs +++ b/Tiles/Astral/AstralStoneSmallPiles.cs @@ -1,8 +1,6 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral diff --git a/Tiles/Astral/AstralTallPlants.cs b/Tiles/Astral/AstralTallPlants.cs index 143fe638b2..da28a3e165 100644 --- a/Tiles/Astral/AstralTallPlants.cs +++ b/Tiles/Astral/AstralTallPlants.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Tiles.Astral Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; if (nearestPlayer.active) { - if (nearestPlayer.ActiveItem().type == ItemID.Sickle) + if (nearestPlayer.HeldItem.type == ItemID.Sickle) yield return new Item(ItemID.Hay, Main.rand.Next(2, 4 + 1)); } } diff --git a/Tiles/Astral/AstralTorch.cs b/Tiles/Astral/AstralTorch.cs index 88c4fd61ea..7baa96a23d 100644 --- a/Tiles/Astral/AstralTorch.cs +++ b/Tiles/Astral/AstralTorch.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.Astral { public class AstralTorch : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), waterImmune: true); public override bool CreateDust(int i, int j, ref int type) @@ -58,7 +61,8 @@ namespace CalamityMod.Tiles.Astral public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/Astral/AstralTorchFlame").Value, i, j, 2); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Astral/AstralTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) @@ -69,7 +73,7 @@ namespace CalamityMod.Tiles.Astral public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } diff --git a/Tiles/Astral/AstralTree.cs b/Tiles/Astral/AstralTree.cs index 4361cf3493..494ba7c8db 100644 --- a/Tiles/Astral/AstralTree.cs +++ b/Tiles/Astral/AstralTree.cs @@ -3,13 +3,13 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.DataStructures; -using Terraria.Enums; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -59,7 +59,7 @@ namespace CalamityMod.Tiles.Astral //treeFrame = (i + j * j) % 3; } - public override int DropWood() => ModContent.ItemType(); + public override int DropWood() => ModContent.ItemType(); public override int CreateDust() => ModContent.DustType(); public override int SaplingGrowthType(ref int style) @@ -73,6 +73,15 @@ namespace CalamityMod.Tiles.Astral // Returning false at the end prevents vanilla behavior as the default is forest tree behavior which can include undesirable stuff like squirrels and butterflies public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.HeldItem.type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) { @@ -137,7 +146,7 @@ namespace CalamityMod.Tiles.Astral type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/Astral/AstralVines.cs b/Tiles/Astral/AstralVines.cs index 3eaaae5300..258370e361 100644 --- a/Tiles/Astral/AstralVines.cs +++ b/Tiles/Astral/AstralVines.cs @@ -4,10 +4,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.Drawing; using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral diff --git a/Tiles/Astral/NovaeSlag.cs b/Tiles/Astral/NovaeSlag.cs index b8fda17830..56bc5f0d74 100644 --- a/Tiles/Astral/NovaeSlag.cs +++ b/Tiles/Astral/NovaeSlag.cs @@ -1,11 +1,8 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral @@ -32,9 +29,9 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = 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"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/AstralBrick.cs b/Tiles/AstralBrick.cs index 1daaa84617..ffac9cea6a 100644 --- a/Tiles/AstralBrick.cs +++ b/Tiles/AstralBrick.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Systems; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -16,8 +14,6 @@ namespace CalamityMod.Tiles private const short subsheetWidth = 324; private const short subsheetHeight = 90; - public override string GlowMaskAsset => "CalamityMod/Tiles/AstralBrickGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; @@ -25,8 +21,8 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(128, 128, 158)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/AstralDesert/AstralPalmTree.cs b/Tiles/AstralDesert/AstralPalmTree.cs index 6c0d7fc4fe..37f3e6cc42 100644 --- a/Tiles/AstralDesert/AstralPalmTree.cs +++ b/Tiles/AstralDesert/AstralPalmTree.cs @@ -3,12 +3,12 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.DataStructures; -using Terraria.Enums; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -56,7 +56,7 @@ namespace CalamityMod.Tiles.AstralDesert return Color.White * MathHelper.Lerp(0.05f, 0.75f, brightness); } - public override int DropWood() => ModContent.ItemType(); + public override int DropWood() => ModContent.ItemType(); public override int CreateDust() => ModContent.DustType(); @@ -71,6 +71,16 @@ namespace CalamityMod.Tiles.AstralDesert // Returning false at the end prevents vanilla behavior as the default is palm tree behavior which can include undesirable stuff like seagulls public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.HeldItem.type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? (WorldGen.genRand.NextBool() ? ItemID.Coconut : ItemID.Banana) + : (WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType()); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -123,12 +133,12 @@ namespace CalamityMod.Tiles.AstralDesert type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.Next(36) < 5) // Vanilla palm fruit logic goes first + else if (Main.rand.NextBool(12)) // Vanilla palm fruit logic goes first { int fruitType = Main.rand.NextBool() ? ItemID.Coconut : ItemID.Banana; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); } - else if (Main.rand.Next(36) < 5) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/AstralDesert/AstralSand.cs b/Tiles/AstralDesert/AstralSand.cs index 1d49d41226..7493beb608 100644 --- a/Tiles/AstralDesert/AstralSand.cs +++ b/Tiles/AstralDesert/AstralSand.cs @@ -1,10 +1,7 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.Typeless; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -26,7 +23,7 @@ namespace CalamityMod.Tiles.AstralDesert CalamityUtils.MergeWithDesert(Type); CalamityUtils.MergeAstralTiles(Type); - DustType = 108; + DustType = DustID.RainCloud; AddMapEntry(new Color(187, 220, 237)); @@ -37,10 +34,10 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.Falling[Type] = true; TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); - 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"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sand); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -55,7 +52,7 @@ namespace CalamityMod.Tiles.AstralDesert public override void WalkDust(ref int dustType, ref bool makeDust, ref Color color) { - DustType = 108; + DustType = DustID.RainCloud; } public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) diff --git a/Tiles/AstralDesert/AstralSandstone.cs b/Tiles/AstralDesert/AstralSandstone.cs index 12389f0650..a2183a2d15 100644 --- a/Tiles/AstralDesert/AstralSandstone.cs +++ b/Tiles/AstralDesert/AstralSandstone.cs @@ -1,8 +1,5 @@ - -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -28,10 +25,10 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.Conversion.Sandstone[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = 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"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); } 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 70bc6f2963..0acee8a90d 100644 --- a/Tiles/AstralDesert/CelestialRemains.cs +++ b/Tiles/AstralDesert/CelestialRemains.cs @@ -1,10 +1,7 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert @@ -28,8 +25,8 @@ namespace CalamityMod.Tiles.AstralDesert TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSandstoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } 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 1c2a7d92d0..0bd7c3d1ff 100644 --- a/Tiles/AstralDesert/HardenedAstralSand.cs +++ b/Tiles/AstralDesert/HardenedAstralSand.cs @@ -1,7 +1,4 @@ - -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -21,18 +18,18 @@ namespace CalamityMod.Tiles.AstralDesert CalamityUtils.MergeAstralTiles(Type); - DustType = 108; + DustType = DustID.RainCloud; AddMapEntry(new Color(128, 128, 158)); TileID.Sets.Conversion.HardenedSand[Type] = true; TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = 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"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.HardenedSand); + this.RegisterBlendMergeWith(TileID.Sand); } 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 84290b3cfe..818d7865fc 100644 --- a/Tiles/AstralSnow/AstralIce.cs +++ b/Tiles/AstralSnow/AstralIce.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; using CalamityMod.Systems; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Metadata; @@ -14,7 +12,7 @@ namespace CalamityMod.Tiles.AstralSnow { public class AstralIce : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/AstralSnow/AstralIceLightmask"; + public override string GlowMaskAsset => $"{Texture}Lightmask"; public override void SetupStatic() { Main.tileSolid[Type] = true; @@ -26,7 +24,7 @@ namespace CalamityMod.Tiles.AstralSnow CalamityUtils.MergeWithSnow(Type); CalamityUtils.MergeAstralTiles(Type); - DustType = 173; + DustType = DustID.ShadowbeamStaff; HitSound = SoundID.Item50; @@ -40,8 +38,8 @@ namespace CalamityMod.Tiles.AstralSnow TileID.Sets.Conversion.Ice[Type] = true; TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralSnowMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/AstralSnow/AstralSnow.cs b/Tiles/AstralSnow/AstralSnow.cs index 734f17698b..48719e7695 100644 --- a/Tiles/AstralSnow/AstralSnow.cs +++ b/Tiles/AstralSnow/AstralSnow.cs @@ -1,9 +1,8 @@ using System; -using System.Collections.Generic; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Systems; using CalamityMod.Tiles.Astral; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Metadata; @@ -14,12 +13,10 @@ namespace CalamityMod.Tiles.AstralSnow { public class AstralSnow : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/AstralSnow/AstralSnowLightmask"; - public GrayscaleTexture2D NoiseTexture; + public override string GlowMaskAsset => $"{Texture}Lightmask"; + public override void SetupStatic() { - NoiseTexture = new("CalamityMod/ExtraTextures/GreyscaleGradients/BlobbyNoise"); - Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; Main.tileBrick[Type] = true; @@ -29,7 +26,7 @@ namespace CalamityMod.Tiles.AstralSnow CalamityUtils.MergeWithSnow(Type); CalamityUtils.MergeAstralTiles(Type); - DustType = 173; + DustType = DustID.ShadowbeamStaff; HitSound = SoundID.Item48; @@ -40,19 +37,14 @@ namespace CalamityMod.Tiles.AstralSnow TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); - this.RegisterUniversalMerge(TileID.SnowBlock, "CalamityMod/Tiles/Merges/SnowMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.SnowBlock); } public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; } - public override void OnUnload() - { - NoiseTexture?.Unload(); - NoiseTexture = null; - } public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) { @@ -62,7 +54,7 @@ namespace CalamityMod.Tiles.AstralSnow public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { int time = (int)(Main.timeForVisualEffects * 0.11); - float brightness = 1.0f - NoiseTexture.GetRepeat((i * 60) + time, (j * 50) + time); + float brightness = 1.0f - GreyscaleGradient.BlobbyNoise.GetRepeat((i * 60) + time, (j * 50) + time); brightness += (float)MathF.Sin(-j / 1f + Main.GameUpdateCount * 0.02f + -i / 30f); brightness -= (float)MathF.Sin(j / 8f + Main.GameUpdateCount * 0.02f - i / 11f); brightness -= (float)MathF.Sin(j / 1f + Main.GameUpdateCount * 0.01f - i / 2f); diff --git a/Tiles/AstralSnow/AstralSnowTree.cs b/Tiles/AstralSnow/AstralSnowTree.cs index aaa2519155..b9f663490e 100644 --- a/Tiles/AstralSnow/AstralSnowTree.cs +++ b/Tiles/AstralSnow/AstralSnowTree.cs @@ -3,13 +3,13 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.DataStructures; -using Terraria.Enums; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -59,7 +59,7 @@ namespace CalamityMod.Tiles.AstralSnow //treeFrame = (i + j * j) % 6; } - public override int DropWood() => ModContent.ItemType(); + public override int DropWood() => ModContent.ItemType(); public override int CreateDust() => ModContent.DustType(); @@ -74,6 +74,15 @@ namespace CalamityMod.Tiles.AstralSnow // Returning false at the end prevents vanilla behavior as the default is forest tree behavior which can include undesirable stuff like squirrels and butterflies public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.HeldItem.type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -137,7 +146,7 @@ namespace CalamityMod.Tiles.AstralSnow type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/BaseTiles/BaseBossRelic.cs b/Tiles/BaseTiles/BaseBossRelic.cs index b7a6ccdd37..41318d476c 100644 --- a/Tiles/BaseTiles/BaseBossRelic.cs +++ b/Tiles/BaseTiles/BaseBossRelic.cs @@ -90,21 +90,16 @@ namespace CalamityMod.Tiles.BaseTiles // This allows us to draw things in SpecialDraw if (drawData.tileFrameX % FrameWidth == 0 && drawData.tileFrameY % FrameHeight == 0) { - Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); + Main.instance.TilesRenderer.AddSpecialPoint(i, j, Terraria.GameContent.Drawing.TileDrawing.TileCounterType.CustomNonSolid); } } public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) { - // This is lighting-mode specific, always include this if you draw tiles manually. - Vector2 offScreen = new Vector2(Main.offScreenRange); - if (Main.drawToScreen) - offScreen = Vector2.Zero; - // Take the tile, check if it actually exists. Point p = new Point(i, j); Tile tile = Main.tile[p.X, p.Y]; - if (tile == null || !tile.HasTile) + if (!tile.HasTile) return; // Get the initial draw parameters. @@ -124,7 +119,7 @@ namespace CalamityMod.Tiles.BaseTiles // Some math magic to make it smoothly move up and down over time. const float TwoPi = (float)Math.PI * 2f; float offset = (float)Math.Sin(Main.GlobalTimeWrappedHourly * TwoPi / 5f); - Vector2 drawPos = worldPos + offScreen - Main.screenPosition + new Vector2(0f, -40f) + new Vector2(0f, offset * 4f); + Vector2 drawPos = worldPos - Main.screenPosition + new Vector2(0f, -40f) + new Vector2(0f, offset * 4f); // Draw the main texture. spriteBatch.Draw(texture, drawPos, frame, color, 0f, origin, 1f, effects, 0f); diff --git a/Tiles/BaseTiles/BaseMonolith.cs b/Tiles/BaseTiles/BaseMonolith.cs index b0475eed59..50111964b9 100644 --- a/Tiles/BaseTiles/BaseMonolith.cs +++ b/Tiles/BaseTiles/BaseMonolith.cs @@ -1,12 +1,12 @@ -using Microsoft.Xna.Framework.Graphics; -using Terraria.GameContent; -using Terraria; -using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; +using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Microsoft.Xna.Framework; +using Terraria.ModLoader; namespace CalamityMod.Tiles.BaseTiles { @@ -69,8 +69,8 @@ namespace CalamityMod.Tiles.BaseTiles var relJ = leftTopJ + p; var relTile = Main.tile[relI, relJ]; - if (enabled) relTile.TileFrameY -= (short)height; - else relTile.TileFrameY += (short)height; + if (enabled) relTile.TileFrameY -= (short)height; + else relTile.TileFrameY += (short)height; if (Wiring.running) { @@ -144,10 +144,9 @@ namespace CalamityMod.Tiles.BaseTiles // transplanted into base monolith as part of manual cherry pick merge // // Draws the Smart Cursor Highlight. Not 100% accurate, but its close enough - bool actuallySelected; Color highlightColor; - Texture2D texhighlight = ModContent.Request(HighlightTexture).Value; - if (texhighlight is not null && Main.InSmartCursorHighlightArea(i, j, out actuallySelected)) + var highlight = TextureAssets.HighlightMask[Type]; + if (highlight != null && highlight.IsLoaded && Main.InSmartCursorHighlightArea(i, j, out var actuallySelected)) { if (actuallySelected) { @@ -157,7 +156,7 @@ namespace CalamityMod.Tiles.BaseTiles { highlightColor = new Color(125, 125, 125); } - Main.spriteBatch.Draw(texhighlight, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animateFrameOffset, 16, height), highlightColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); ; + Main.spriteBatch.Draw(highlight.Value, new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY + animateFrameOffset, 16, height), highlightColor, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); ; } return false; diff --git a/Tiles/BaseTiles/BasePylonTile.cs b/Tiles/BaseTiles/BasePylonTile.cs index 699d9d4b8e..f9676bc233 100644 --- a/Tiles/BaseTiles/BasePylonTile.cs +++ b/Tiles/BaseTiles/BasePylonTile.cs @@ -4,10 +4,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.Map; using Terraria.ModLoader; using Terraria.ModLoader.Default; @@ -150,7 +148,7 @@ namespace CalamityMod.Tiles.BaseTiles if (averageBrightness > 10) { // Use the vanilla crystal sheet to get the autoselect outline. - Texture2D vanillaCrystalSheet = TextureAssets.Extra[181].Value; + Texture2D vanillaCrystalSheet = TextureAssets.Extra[ExtrasID.PylonCrystals].Value; Rectangle smartCursorGlowFrame = vanillaCrystalSheet.Frame(12, 8, 2, frameY); Color selectionGlowColor = Colors.GetSelectionGlowColor(tileSelectionTier == 2, averageBrightness); diff --git a/Tiles/BaseTiles/BranchDrawer.cs b/Tiles/BaseTiles/BranchDrawer.cs index 0a5eb328b5..5e21db3bf1 100644 --- a/Tiles/BaseTiles/BranchDrawer.cs +++ b/Tiles/BaseTiles/BranchDrawer.cs @@ -6,7 +6,6 @@ using Terraria.Utilities; using Microsoft.Xna.Framework; using System; using Microsoft.Xna.Framework.Graphics; -using Terraria.ID; using Terraria.DataStructures; using Terraria.ObjectData; using Terraria.Enums; diff --git a/Tiles/FloralParadise/BloodOrangePlant.cs b/Tiles/BloodOrangePlant.cs similarity index 93% rename from Tiles/FloralParadise/BloodOrangePlant.cs rename to Tiles/BloodOrangePlant.cs index 2ee61a885a..6810ed1226 100644 --- a/Tiles/FloralParadise/BloodOrangePlant.cs +++ b/Tiles/BloodOrangePlant.cs @@ -2,10 +2,11 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.FloralParadise +namespace CalamityMod.Tiles { public class BloodOrangePlant : ModTile { @@ -18,7 +19,7 @@ namespace CalamityMod.Tiles.FloralParadise TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); TileObjectData.addTile(Type); - DustType = 6; + DustType = DustID.Torch; AddMapEntry(new Color(250, 142, 4)); } diff --git a/Tiles/FloralParadise/BloodOrangePlant.png b/Tiles/BloodOrangePlant.png similarity index 100% rename from Tiles/FloralParadise/BloodOrangePlant.png rename to Tiles/BloodOrangePlant.png diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index a003841988..0260b82767 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -1,15 +1,12 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.Items.Accessories.Vanity; +using CalamityMod.Items.Tools; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Tiles.Abyss; -using CalamityMod.Tiles.Astral; -using CalamityMod.Tiles.DraedonStructures; -using CalamityMod.Tiles.DraedonSummoner; -using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -17,19 +14,27 @@ using Terraria.Enums; using Terraria.GameContent.Achievements; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Tiles { public class CalamityGlobalTile : GlobalTile { - public static List GrowthTiles = new List() { - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType() + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType() }; public override void SetStaticDefaults() @@ -42,136 +47,120 @@ namespace CalamityMod.Tiles TileID.Sets.TileCutIgnore.IgnoreDontHurtNature[TileID.Larva] = true; } + public override void PreShakeTree(int x, int y, TreeTypes treeType) + { + // All trees have a 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.HeldItem.type == ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = 0; + switch (treeType) + { + case TreeTypes.Forest: + + switch (WorldGen.genRand.Next(5)) + { + case 0: + treeDropItemType = ItemID.Apple; + break; + case 1: + treeDropItemType = ItemID.Apricot; + break; + case 2: + treeDropItemType = ItemID.Peach; + break; + case 3: + treeDropItemType = ItemID.Grapefruit; + break; + default: + treeDropItemType = ItemID.Lemon; + break; + } + break; + + case TreeTypes.Snow: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Cherry : ItemID.Plum; + break; + + case TreeTypes.Jungle: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Mango : ItemID.Pineapple; + break; + + case TreeTypes.Palm: + if (WorldGen.IsPalmOasisTree(x)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + break; + + case TreeTypes.PalmCorrupt: + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + else if (WorldGen.IsPalmOasisTree(x)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + break; + + case TreeTypes.Corrupt: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; + break; + + case TreeTypes.PalmHallowed: + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + else if (WorldGen.IsPalmOasisTree(x)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + break; + + case TreeTypes.Hallowed: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; + break; + + case TreeTypes.PalmCrimson: + if (WorldGen.genRand.NextBool()) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + else if (WorldGen.IsPalmOasisTree(x)) + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; + else + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + break; + + case TreeTypes.Crimson: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; + break; + + case TreeTypes.Ash: + treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Pomegranate : ItemID.SpicyPepper; + break; + + default: + break; + } + + if (treeDropItemType != 0) + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + } + + public override bool ShakeTree(int x, int y, TreeTypes treeType) + { + // Ha-pu Fruit @ 1% (6.67% during Valentines) + // This *will* work on modded trees as well + if (WorldGen.genRand.NextBool(100) || (DateTime.Now.Month == 2 && DateTime.Now.Day == 14 && WorldGen.genRand.NextBool(15))) + { + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, ItemType()); + return true; + } + + return base.ShakeTree(x, y, treeType); + } + public override void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem) { Tile tile = Main.tile[i, j]; - // Fruit from trees upon tree destruction - // 25% chance to drop 1 to 2 fruit - if (!effectOnly && !fail && Main.netMode != NetmodeID.MultiplayerClient && TileID.Sets.IsShakeable[type] && WorldGen.genRand.NextBool(4)) - { - GetTreeBottom(i, j, out int treeX, out int treeY); - TreeTypes treeType = WorldGen.GetTreeType(Main.tile[treeX, treeY].TileType); - if (treeType != TreeTypes.None) - { - treeY--; - while (treeY > 10 && Main.tile[treeX, treeY].HasTile && TileID.Sets.IsShakeable[Main.tile[treeX, treeY].TileType]) - treeY--; - - treeY++; - - if (WorldGen.IsTileALeafyTreeTop(treeX, treeY) && !Collision.SolidTiles(treeX - 2, treeX + 2, treeY - 2, treeY + 2)) - { - int randomAmt = WorldGen.genRand.Next(1, 3); - for (int z = 0; z < randomAmt; z++) - { - int treeDropItemType = 0; - switch (treeType) - { - case TreeTypes.Forest: - - switch (WorldGen.genRand.Next(5)) - { - case 0: - treeDropItemType = ItemID.Apple; - break; - case 1: - treeDropItemType = ItemID.Apricot; - break; - case 2: - treeDropItemType = ItemID.Peach; - break; - case 3: - treeDropItemType = ItemID.Grapefruit; - break; - default: - treeDropItemType = ItemID.Lemon; - break; - } - - break; - - case TreeTypes.Snow: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Cherry : ItemID.Plum; - break; - - case TreeTypes.Jungle: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Mango : ItemID.Pineapple; - break; - - case TreeTypes.Palm: - - if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - - break; - - case TreeTypes.PalmCorrupt: - - if (WorldGen.genRand.NextBool()) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; - else if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - else - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; - - break; - - case TreeTypes.Corrupt: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BlackCurrant : ItemID.Elderberry; - break; - - case TreeTypes.PalmHallowed: - - if (WorldGen.genRand.NextBool()) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; - else if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - else - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; - - break; - - case TreeTypes.Hallowed: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Dragonfruit : ItemID.Starfruit; - break; - - case TreeTypes.PalmCrimson: - - if (WorldGen.genRand.NextBool()) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; - else if (WorldGen.IsPalmOasisTree(treeX)) - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Banana : ItemID.Coconut; - else - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; - - break; - - case TreeTypes.Crimson: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.BloodOrange : ItemID.Rambutan; - break; - - case TreeTypes.Ash: - treeDropItemType = WorldGen.genRand.NextBool() ? ItemID.Pomegranate : ItemID.SpicyPepper; - break; - - default: - break; - } - - if (treeDropItemType != 0) - { - if (Main.rand.NextBool(100) || (DateTime.Now.Month == 2 && DateTime.Now.Day == 14 && Main.rand.NextBool(15))) - { - treeDropItemType = ModContent.ItemType(); - } - Item.NewItem(new EntitySource_TileBreak(treeX, treeY), treeX * 16, treeY * 16, 16, 16, treeDropItemType); - } - } - } - } - } - // Helper function to shatter crystals attached to neighboring solid tiles. void CheckShatterCrystal(int xPos, int yPos, bool dontShatter) { @@ -179,7 +168,7 @@ namespace CalamityMod.Tiles return; Tile t = Main.tile[xPos, yPos]; - if (t.HasTile && (t.TileType == ModContent.TileType() || t.TileType == ModContent.TileType())) + if (t.HasTile && (t.TileType == TileType() || t.TileType == TileType() || t.TileType == TileType())) { WorldGen.KillTile(xPos, yPos, false, false, false); if (!Main.tile[xPos, yPos].HasTile && Main.netMode != NetmodeID.SinglePlayer) @@ -188,7 +177,7 @@ namespace CalamityMod.Tiles } // Check if crystals should be shattered, do not shatter crystals next to other crystals if a crystal is shattered. - if (Main.tileSolid[tile.TileType] && tile.TileType != ModContent.TileType() && tile.TileType != ModContent.TileType()) + if (Main.tileSolid[tile.TileType] && tile.TileType != TileType() && tile.TileType != TileType() && tile.TileType != TileType()) { bool dontShatter = fail || effectOnly; CheckShatterCrystal(i + 1, j, dontShatter); @@ -315,23 +304,20 @@ namespace CalamityMod.Tiles AchievementsHelper.NotifyProgressionEvent(6); // Gives the Begone, Evil! achievement } - // Drop Evil Smasher on every 12 alter smashed + // Drop Evil Smasher on every 12 altar smashed if (WorldGen.altarCount > 1 && WorldGen.altarCount % 12 == 0) - { - DropItem(i, j, ModContent.ItemType(), quantity: 1, asStack: true); - } + DropItem(i, j, ItemType(), quantity: 1, asStack: true, prefix: true); } + // Drop Golden Bombs at a 0.33% chance from Pots if (type == TileID.Pots) { if (Main.rand.NextBool(300)) - { - DropItem(i, j, ModContent.ItemType(), quantity: 1, asStack: true); - } + DropItem(i, j, ItemType(), quantity: 1, asStack: true); } } - private static void DropItem(int i, int j, int itemType, int quantity, bool asStack, Vector2 spreadMinMax = default) + private static void DropItem(int i, int j, int itemType, int quantity, bool asStack, Vector2 spreadMinMax = default, bool prefix = false) { // Multiplayer Client should not spawn item themselves if (Main.netMode == NetmodeID.MultiplayerClient) @@ -341,92 +327,16 @@ namespace CalamityMod.Tiles if (asStack) { Vector2 spawnOffset = Main.rand.NextVector2Unit(spreadMinMax.X, spreadMinMax.Y); - Item.NewItem(new EntitySource_TileBreak(i, j), worldPos + spawnOffset, itemType, Stack: quantity); + Item.NewItem(new EntitySource_TileBreak(i, j), worldPos + spawnOffset, itemType, Stack: quantity, prefixGiven: prefix ? -1 : 0); } else { for (int k = 0; k < quantity; k += 1) { Vector2 spawnOffset = Main.rand.NextVector2Unit(spreadMinMax.X, spreadMinMax.Y); - Item.NewItem(new EntitySource_TileBreak(i, j), worldPos + spawnOffset, itemType, Stack: 1); + Item.NewItem(new EntitySource_TileBreak(i, j), worldPos + spawnOffset, itemType, Stack: 1, prefixGiven: prefix ? -1 : 0); } } } - - // TODO: Make this a data set or smth? - // Plausible name: PreventsAnchorTileChanges /// Tile prevents its "anchors" from being hammered, killed, actuated, or edited in any way which may cause it to unintentionally break. - public static bool ShouldNotBreakDueToAboveTile(int x, int y) - { - int[] invincibleTiles = new int[] - { - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType() - }; - - Tile checkTile = CalamityUtils.ParanoidTileRetrieval(x, y); - Tile aboveTile = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - - // Prevent tiles below invincible tiles from being destroyed. This is like chests in vanilla. - return aboveTile.HasTile && checkTile.TileType != aboveTile.TileType && invincibleTiles.Contains(aboveTile.TileType); - } - - public override bool CanExplode(int i, int j, int type) - { - if (ShouldNotBreakDueToAboveTile(i, j)) - return false; - - return base.CanExplode(i, j, type); - } - - public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged) - { - if (ShouldNotBreakDueToAboveTile(i, j)) - return false; - - return base.CanKillTile(i, j, type, ref blockDamaged); - } - - // "Private" my ass, fuck off - public static void GetTreeBottom(int i, int j, out int x, out int y) - { - x = i; - y = j; - Tile tileSafely = Framing.GetTileSafely(x, y); - if (tileSafely.TileType == TileID.PalmTree) - { - while (y < Main.maxTilesY - 50 && (!tileSafely.HasTile || tileSafely.TileType == TileID.PalmTree)) - { - y++; - tileSafely = Framing.GetTileSafely(x, y); - } - - return; - } - - int treeTileX = tileSafely.TileFrameX / 22; - int treeTileY = tileSafely.TileFrameY / 22; - if (treeTileX == 3 && treeTileY <= 2) - x++; - else if (treeTileX == 4 && treeTileY >= 3 && treeTileY <= 5) - x--; - else if (treeTileX == 1 && treeTileY >= 6 && treeTileY <= 8) - x--; - else if (treeTileX == 2 && treeTileY >= 6 && treeTileY <= 8) - x++; - else if (treeTileX == 2 && treeTileY >= 9) - x++; - else if (treeTileX == 3 && treeTileY >= 9) - x--; - - tileSafely = Framing.GetTileSafely(x, y); - while (y < Main.maxTilesY - 50 && (!tileSafely.HasTile || TileID.Sets.IsATreeTrunk[tileSafely.TileType] || tileSafely.TileType == TileID.MushroomTrees)) - { - y++; - tileSafely = Framing.GetTileSafely(x, y); - } - } } } diff --git a/Tiles/CosmiliteBarTile.cs b/Tiles/CosmiliteBarTile.cs index d37e1f19b5..ec0f584276 100644 --- a/Tiles/CosmiliteBarTile.cs +++ b/Tiles/CosmiliteBarTile.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; namespace CalamityMod.Tiles diff --git a/Tiles/Crags/BrimstoneCrateTile.cs b/Tiles/Crags/BrimstoneCrateTile.cs index b7d3367884..2c6daad728 100644 --- a/Tiles/Crags/BrimstoneCrateTile.cs +++ b/Tiles/Crags/BrimstoneCrateTile.cs @@ -1,8 +1,7 @@ using CalamityMod.Items.Fishing.BrimstoneCragCatches; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -23,7 +22,7 @@ namespace CalamityMod.Tiles.Crags TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(128, 0, 0), CalamityUtils.GetItemName()); //Maroon - DustType = 60; + DustType = DustID.RedTorch; } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Crags/BrimstoneSlab.cs b/Tiles/Crags/BrimstoneSlab.cs index ebde8168c9..13fa9bf7d3 100644 --- a/Tiles/Crags/BrimstoneSlab.cs +++ b/Tiles/Crags/BrimstoneSlab.cs @@ -1,11 +1,7 @@ -using System.Collections.Generic; -using CalamityMod.Systems; -using CalamityMod.Tiles.Crags; +using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags @@ -27,10 +23,10 @@ namespace CalamityMod.Tiles.Crags MineResist = 2f; MinPick = 100; HitSound = SoundID.Tink; - DustType = 235; + DustType = DustID.LifeDrain; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Ash); } public override bool CanExplode(int i, int j) diff --git a/Tiles/Crags/BrimstoneSlag.cs b/Tiles/Crags/BrimstoneSlag.cs index d88a236f6b..fc8d2fea29 100644 --- a/Tiles/Crags/BrimstoneSlag.cs +++ b/Tiles/Crags/BrimstoneSlag.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,7 +11,7 @@ namespace CalamityMod.Tiles.Crags { private const short subsheetWidth = 450; private const short subsheetHeight = 198; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -27,7 +25,7 @@ namespace CalamityMod.Tiles.Crags MineResist = 2f; MinPick = 100; AddMapEntry(new Color(53, 33, 56)); - this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); + this.RegisterBlendMergeWith(TileID.Ash); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/Crags/CinderBlossomTallPlants.cs b/Tiles/Crags/CinderBlossomTallPlants.cs index 7cdea6fe06..db7981459c 100644 --- a/Tiles/Crags/CinderBlossomTallPlants.cs +++ b/Tiles/Crags/CinderBlossomTallPlants.cs @@ -1,5 +1,4 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Metadata; diff --git a/Tiles/Crags/GloomTorch.cs b/Tiles/Crags/GloomTorch.cs index 025bc99438..69804dc76b 100644 --- a/Tiles/Crags/GloomTorch.cs +++ b/Tiles/Crags/GloomTorch.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.Crags { public class GloomTorch : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), lavaImmune: true); public override bool CreateDust(int i, int j, ref int type) @@ -57,18 +60,19 @@ namespace CalamityMod.Tiles.Crags public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/Crags/GloomTorchFlame").Value, i, j, 2); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/GloomTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) { if (Main.tile[i, j].TileFrameX < 66) - CalamityUtils.DrawFlameSparks(Main.rand.NextBool() ? 61 : 64, 5, i, j); + CalamityUtils.DrawFlameSparks(DustID.BlueTorch, 5, i, j); } public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } diff --git a/Tiles/Crags/LavaPistil.cs b/Tiles/Crags/LavaPistil.cs index 8b2b419784..8cf2f28e96 100644 --- a/Tiles/Crags/LavaPistil.cs +++ b/Tiles/Crags/LavaPistil.cs @@ -1,8 +1,5 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; diff --git a/Tiles/Crags/Lily/LavaLily1.cs b/Tiles/Crags/Lily/LavaLily1.cs index 9ce7428ca5..650d7849c4 100644 --- a/Tiles/Crags/Lily/LavaLily1.cs +++ b/Tiles/Crags/Lily/LavaLily1.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,10 @@ namespace CalamityMod.Tiles.Crags.Lily { public class LavaLily1 : ModTile { + public Asset GlowTexture; + public Asset TopTexture; + public Asset TopGlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -60,19 +65,19 @@ namespace CalamityMod.Tiles.Crags.Lily if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily1Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily1Glow"); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); - - Texture2D lilyTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily1Top").Value; - Texture2D glowTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily1TopGlow").Value; + spriteBatch.Draw(GlowTexture.Value, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); //draw in the middle of the tile so it doesnt draw more than once if (Framing.GetTileSafely(i, j).TileFrameX == 36 && Framing.GetTileSafely(i, j).TileFrameY == 18) { - DrawLilyTop(i, j, lilyTex, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(98, 191), false); - DrawLilyTop(i, j, glowTex, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(98, 191), true); + TopTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily1Top"); + TopGlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily1TopGlow"); + + DrawLilyTop(i, j, TopTexture.Value, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(98, 191), false); + DrawLilyTop(i, j, TopGlowTexture.Value, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(98, 191), true); } } } diff --git a/Tiles/Crags/Lily/LavaLily2.cs b/Tiles/Crags/Lily/LavaLily2.cs index 2e09e90016..2234f8f8b1 100644 --- a/Tiles/Crags/Lily/LavaLily2.cs +++ b/Tiles/Crags/Lily/LavaLily2.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,10 @@ namespace CalamityMod.Tiles.Crags.Lily { public class LavaLily2 : ModTile { + public Asset GlowTexture; + public Asset TopTexture; + public Asset TopGlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -60,19 +65,19 @@ namespace CalamityMod.Tiles.Crags.Lily if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily2Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily2Glow"); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); - - Texture2D lilyTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily2Top").Value; - Texture2D glowTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily2TopGlow").Value; + spriteBatch.Draw(GlowTexture.Value, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); //draw in the middle of the tile so it doesnt draw more than once if (Framing.GetTileSafely(i, j).TileFrameX == 36 && Framing.GetTileSafely(i, j).TileFrameY == 18) { - DrawLilyTop(i, j, lilyTex, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(90, 209), false); - DrawLilyTop(i, j, glowTex, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(90, 209), true); + TopTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily2Top"); + TopGlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily2TopGlow"); + + DrawLilyTop(i, j, TopTexture.Value, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(90, 209), false); + DrawLilyTop(i, j, TopGlowTexture.Value, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(90, 209), true); } } } diff --git a/Tiles/Crags/Lily/LavaLily3.cs b/Tiles/Crags/Lily/LavaLily3.cs index 1b32b892e4..e4c763720c 100644 --- a/Tiles/Crags/Lily/LavaLily3.cs +++ b/Tiles/Crags/Lily/LavaLily3.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,10 @@ namespace CalamityMod.Tiles.Crags.Lily { public class LavaLily3 : ModTile { + public Asset GlowTexture; + public Asset TopTexture; + public Asset TopGlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -60,19 +65,19 @@ namespace CalamityMod.Tiles.Crags.Lily if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily3Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily3Glow"); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); - - Texture2D lilyTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily3Top").Value; - Texture2D glowTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily3TopGlow").Value; + spriteBatch.Draw(GlowTexture.Value, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); //draw in the middle of the tile so it doesnt draw more than once if (Framing.GetTileSafely(i, j).TileFrameX == 36 && Framing.GetTileSafely(i, j).TileFrameY == 18) { - DrawLilyTop(i, j, lilyTex, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(98, 199), false); - DrawLilyTop(i, j, glowTex, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(98, 199), true); + TopTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily3Top"); + TopGlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily3TopGlow"); + + DrawLilyTop(i, j, TopTexture.Value, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(98, 199), false); + DrawLilyTop(i, j, TopGlowTexture.Value, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(98, 199), true); } } } diff --git a/Tiles/Crags/Lily/LavaLily4.cs b/Tiles/Crags/Lily/LavaLily4.cs index 8950207004..835e6a9783 100644 --- a/Tiles/Crags/Lily/LavaLily4.cs +++ b/Tiles/Crags/Lily/LavaLily4.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,10 @@ namespace CalamityMod.Tiles.Crags.Lily { public class LavaLily4 : ModTile { + public Asset GlowTexture; + public Asset TopTexture; + public Asset TopGlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -60,19 +65,19 @@ namespace CalamityMod.Tiles.Crags.Lily if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily4Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily4Glow"); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); - - Texture2D lilyTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily4Top").Value; - Texture2D glowTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily4TopGlow").Value; + spriteBatch.Draw(GlowTexture.Value, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); //draw in the middle of the tile so it doesnt draw more than once if (Framing.GetTileSafely(i, j).TileFrameX == 36 && Framing.GetTileSafely(i, j).TileFrameY == 18) { - DrawLilyTop(i, j, lilyTex, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(96, 191), false); - DrawLilyTop(i, j, glowTex, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(96, 191), true); + TopTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily4Top"); + TopGlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily4TopGlow"); + + DrawLilyTop(i, j, TopTexture.Value, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(96, 191), false); + DrawLilyTop(i, j, TopGlowTexture.Value, new Rectangle(0, 0, 178, 184), TileOffset.ToWorldCoordinates(), new Vector2(96, 191), true); } } } diff --git a/Tiles/Crags/Lily/LavaLily5.cs b/Tiles/Crags/Lily/LavaLily5.cs index 6397483d8d..90fbef978e 100644 --- a/Tiles/Crags/Lily/LavaLily5.cs +++ b/Tiles/Crags/Lily/LavaLily5.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,10 @@ namespace CalamityMod.Tiles.Crags.Lily { public class LavaLily5 : ModTile { + public Asset GlowTexture; + public Asset TopTexture; + public Asset TopGlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -60,19 +65,19 @@ namespace CalamityMod.Tiles.Crags.Lily if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily5Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily5Glow"); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); - - Texture2D lilyTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily5Top").Value; - Texture2D glowTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily5TopGlow").Value; + spriteBatch.Draw(GlowTexture.Value, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); //draw in the middle of the tile so it doesnt draw more than once if (Framing.GetTileSafely(i, j).TileFrameX == 36 && Framing.GetTileSafely(i, j).TileFrameY == 18) { - DrawLilyTop(i, j, lilyTex, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(118, 209), false); - DrawLilyTop(i, j, glowTex, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(118, 209), true); + TopTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily5Top"); + TopGlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily5TopGlow"); + + DrawLilyTop(i, j, TopTexture.Value, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(118, 209), false); + DrawLilyTop(i, j, TopGlowTexture.Value, new Rectangle(0, 0, 192, 206), TileOffset.ToWorldCoordinates(), new Vector2(118, 209), true); } } } diff --git a/Tiles/Crags/Lily/LavaLily6.cs b/Tiles/Crags/Lily/LavaLily6.cs index 0aafb69d5d..71fdbbe456 100644 --- a/Tiles/Crags/Lily/LavaLily6.cs +++ b/Tiles/Crags/Lily/LavaLily6.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,10 @@ namespace CalamityMod.Tiles.Crags.Lily { public class LavaLily6 : ModTile { + public Asset GlowTexture; + public Asset TopTexture; + public Asset TopGlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -60,19 +65,19 @@ namespace CalamityMod.Tiles.Crags.Lily if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily6Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily6Glow"); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); - - Texture2D lilyTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily6Top").Value; - Texture2D glowTex = ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily6TopGlow").Value; + spriteBatch.Draw(GlowTexture.Value, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); //draw in the middle of the tile so it doesnt draw more than once if (Framing.GetTileSafely(i, j).TileFrameX == 36 && Framing.GetTileSafely(i, j).TileFrameY == 18) { - DrawLilyTop(i, j, lilyTex, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(96, 199), false); - DrawLilyTop(i, j, glowTex, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(96, 199), true); + TopTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily6Top"); + TopGlowTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Lily/LavaLily6TopGlow"); + + DrawLilyTop(i, j, TopTexture.Value, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(96, 199), false); + DrawLilyTop(i, j, TopGlowTexture.Value, new Rectangle(0, 0, 178, 198), TileOffset.ToWorldCoordinates(), new Vector2(96, 199), true); } } } diff --git a/Tiles/Crags/ScorchedBone.cs b/Tiles/Crags/ScorchedBone.cs index 334d23e43e..e2ca612818 100644 --- a/Tiles/Crags/ScorchedBone.cs +++ b/Tiles/Crags/ScorchedBone.cs @@ -1,8 +1,5 @@ -using System.Collections.Generic; -using CalamityMod.Systems; -using CalamityMod.Tiles.Ores; +using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -24,13 +21,13 @@ namespace CalamityMod.Tiles.Crags CalamityUtils.MergeWithHell(Type); CalamityUtils.SetMerge(Type, ModContent.TileType()); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Dig; MinPick = 100; AddMapEntry(new Color(87, 62, 67)); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Ash); } public override bool CanExplode(int i, int j) diff --git a/Tiles/Crags/ScorchedRemains.cs b/Tiles/Crags/ScorchedRemains.cs index 065de6ee5c..94e6f823f4 100644 --- a/Tiles/Crags/ScorchedRemains.cs +++ b/Tiles/Crags/ScorchedRemains.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using CalamityMod.Tiles.Ores; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -23,13 +20,13 @@ namespace CalamityMod.Tiles.Crags CalamityUtils.MergeWithHell(Type); CalamityUtils.SetMerge(Type, ModContent.TileType()); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Dig; MinPick = 100; AddMapEntry(new Color(57, 52, 72)); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Ash); } public override void RandomUpdate(int i, int j) @@ -38,7 +35,7 @@ namespace CalamityMod.Tiles.Crags Tile left = Main.tile[i - 1, j]; Tile right = Main.tile[i + 1, j]; - if (WorldGen.genRand.NextBool(3)&& !up.HasTile && (left.TileType == ModContent.TileType() || + if (WorldGen.genRand.NextBool(3) && !up.HasTile && (left.TileType == ModContent.TileType() || right.TileType == ModContent.TileType())) { Main.tile[i, j].TileType = (ushort)ModContent.TileType(); diff --git a/Tiles/Crags/ScorchedRemainsGrass.cs b/Tiles/Crags/ScorchedRemainsGrass.cs index 9d48394481..728a96dc12 100644 --- a/Tiles/Crags/ScorchedRemainsGrass.cs +++ b/Tiles/Crags/ScorchedRemainsGrass.cs @@ -1,8 +1,9 @@ -using System.Collections.Generic; -using CalamityMod.Dusts; +using CalamityMod.Dusts; +using CalamityMod.Systems; using CalamityMod.Tiles.Crags.Lily; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -12,6 +13,8 @@ namespace CalamityMod.Tiles.Crags { public class ScorchedRemainsGrass : ModTile { + public Asset GrassTexture; + private const short subsheetWidth = 234; private const short subsheetHeight = 90; private int extraFrameHeight = 36; @@ -19,6 +22,8 @@ namespace CalamityMod.Tiles.Crags public override void SetStaticDefaults() { + GrassTexture = ModContent.Request("CalamityMod/Tiles/Crags/CinderBlossomGrassGrass"); + Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; Main.tileLighted[Type] = true; @@ -32,8 +37,8 @@ namespace CalamityMod.Tiles.Crags RegisterItemDrop(ModContent.ItemType()); AddMapEntry(new Color(212, 82, 227)); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Ash); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -74,7 +79,7 @@ namespace CalamityMod.Tiles.Crags Main.tile[i, j].TileType = (ushort)ModContent.TileType(); } - if (WorldGen.genRand.NextBool(5)&& !up.HasTile && !up2.HasTile && up.LiquidAmount == 0) + if (WorldGen.genRand.NextBool(5) && !up.HasTile && !up2.HasTile && up.LiquidAmount == 0) { up.TileType = (ushort)ModContent.TileType(); up.HasTile = true; @@ -105,7 +110,7 @@ namespace CalamityMod.Tiles.Crags Main.tile[i, j].TileType = (ushort)ModContent.TileType(); } - if (WorldGen.genRand.NextBool(60)&& !up.HasTile && !up2.HasTile && up.LiquidAmount == 0) + if (WorldGen.genRand.NextBool(60) && !up.HasTile && !up2.HasTile && up.LiquidAmount == 0) { up.TileType = (ushort)ModContent.TileType(); up.HasTile = true; @@ -120,6 +125,19 @@ namespace CalamityMod.Tiles.Crags } } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type || + Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type) + { + Main.tile[i, j].Get().HasSpecialPoint = true; + } + else + { + Main.tile[i, j].Get().HasSpecialPoint = false; + } + } + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) { bool isPlayerNear = WorldGen.PlayerLOS(i, j); @@ -134,26 +152,22 @@ namespace CalamityMod.Tiles.Crags } } - if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type || - Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type) + if (Main.tile[i, j].Get().HasSpecialPoint) { - try - { - Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); - } - catch { } + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); } } public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) { - if (Main.tile[i, j].IsTileActuallyInvisible()) + Tile tile = Main.tile[i, j]; + if (tile.IsTileActuallyInvisible()) return; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Lighting.GetColor(i, j)); - Texture2D leaves = ModContent.Request("CalamityMod/Tiles/Crags/CinderBlossomGrassGrass").Value; + Color drawColour = CalamityUtils.ApplyPaint(tile.TileColor, Lighting.GetColor(i, j)); + Texture2D leaves = GrassTexture.Value; DrawExtraTop(i, j, leaves, drawOffset, drawColour); DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour); diff --git a/Tiles/Crags/SlagCrateTile.cs b/Tiles/Crags/SlagCrateTile.cs index 91d81f3e22..c68af991e2 100644 --- a/Tiles/Crags/SlagCrateTile.cs +++ b/Tiles/Crags/SlagCrateTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Fishing.BrimstoneCragCatches; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -21,7 +22,7 @@ namespace CalamityMod.Tiles.Crags TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(189, 152, 43), CalamityUtils.GetItemName()); - DustType = 60; + DustType = DustID.RedTorch; } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Crags/Spike/CragStalactiteGiant.cs b/Tiles/Crags/Spike/CragStalactiteGiant.cs index 3d4a3e7aff..f0805935a3 100644 --- a/Tiles/Crags/Spike/CragStalactiteGiant.cs +++ b/Tiles/Crags/Spike/CragStalactiteGiant.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -27,7 +26,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = -3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalactiteLarge2x4.cs b/Tiles/Crags/Spike/CragStalactiteLarge2x4.cs index 2da8d88ad8..ecd4a10748 100644 --- a/Tiles/Crags/Spike/CragStalactiteLarge2x4.cs +++ b/Tiles/Crags/Spike/CragStalactiteLarge2x4.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -27,7 +26,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = -3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalactiteLarge2x5.cs b/Tiles/Crags/Spike/CragStalactiteLarge2x5.cs index c1578763c9..4e511e5388 100644 --- a/Tiles/Crags/Spike/CragStalactiteLarge2x5.cs +++ b/Tiles/Crags/Spike/CragStalactiteLarge2x5.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -27,7 +26,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = -3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalactiteSmall2x2.cs b/Tiles/Crags/Spike/CragStalactiteSmall2x2.cs index 58d6d5eec6..273c04c040 100644 --- a/Tiles/Crags/Spike/CragStalactiteSmall2x2.cs +++ b/Tiles/Crags/Spike/CragStalactiteSmall2x2.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -25,7 +24,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = -3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalactiteSmall2x3.cs b/Tiles/Crags/Spike/CragStalactiteSmall2x3.cs index 9b107621a1..0c3ca120fc 100644 --- a/Tiles/Crags/Spike/CragStalactiteSmall2x3.cs +++ b/Tiles/Crags/Spike/CragStalactiteSmall2x3.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -27,7 +26,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = -3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalagmiteGiant.cs b/Tiles/Crags/Spike/CragStalagmiteGiant.cs index 794dbedbaa..98440ef7ba 100644 --- a/Tiles/Crags/Spike/CragStalagmiteGiant.cs +++ b/Tiles/Crags/Spike/CragStalagmiteGiant.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -26,7 +25,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalagmiteLarge2x4.cs b/Tiles/Crags/Spike/CragStalagmiteLarge2x4.cs index dc5cb104e6..9dfc3b40f8 100644 --- a/Tiles/Crags/Spike/CragStalagmiteLarge2x4.cs +++ b/Tiles/Crags/Spike/CragStalagmiteLarge2x4.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -26,7 +25,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalagmiteLarge2x5.cs b/Tiles/Crags/Spike/CragStalagmiteLarge2x5.cs index 1313b33b92..268579702a 100644 --- a/Tiles/Crags/Spike/CragStalagmiteLarge2x5.cs +++ b/Tiles/Crags/Spike/CragStalagmiteLarge2x5.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -26,7 +25,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalagmiteSmall2x2.cs b/Tiles/Crags/Spike/CragStalagmiteSmall2x2.cs index a0a6238c50..e6bc9a4dd1 100644 --- a/Tiles/Crags/Spike/CragStalagmiteSmall2x2.cs +++ b/Tiles/Crags/Spike/CragStalagmiteSmall2x2.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -24,7 +23,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Spike/CragStalagmiteSmall2x3.cs b/Tiles/Crags/Spike/CragStalagmiteSmall2x3.cs index 5a6b48728f..658a62ed88 100644 --- a/Tiles/Crags/Spike/CragStalagmiteSmall2x3.cs +++ b/Tiles/Crags/Spike/CragStalagmiteSmall2x3.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -26,7 +25,7 @@ namespace CalamityMod.Tiles.Crags.Spike TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(43, 23, 46)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Tink; } } diff --git a/Tiles/Crags/Tree/SpineSapling.cs b/Tiles/Crags/Tree/SpineSapling.cs index 50ce8eee4e..e122340eb9 100644 --- a/Tiles/Crags/Tree/SpineSapling.cs +++ b/Tiles/Crags/Tree/SpineSapling.cs @@ -1,11 +1,8 @@ -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Crags/Tree/SpineTree.cs b/Tiles/Crags/Tree/SpineTree.cs index 11adee04ed..06d6eaffc3 100644 --- a/Tiles/Crags/Tree/SpineTree.cs +++ b/Tiles/Crags/Tree/SpineTree.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -27,6 +28,20 @@ namespace CalamityMod.Tiles.Crags.Tree y-frame 3 = both left and right branch */ + public Asset BottomTexture; + public Asset SegmentsTexture; + + public Asset Rib1LeftTexture; + public Asset Rib1RightTexture; + + public Asset Rib2LeftTexture; + public Asset Rib2RightTexture; + + public Asset Rib3LeftTexture; + public Asset Rib3RightTexture; + + public Asset TopTexture; + public override void SetStaticDefaults() { TileID.Sets.IsATreeTrunk[Type] = true; @@ -37,7 +52,7 @@ namespace CalamityMod.Tiles.Crags.Tree Main.tileLighted[Type] = false; Main.tileBlockLight[Type] = false; AddMapEntry(new Color(38, 25, 27), CreateMapEntryName()); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.DD2_SkeletonHurt; RegisterItemDrop(ModContent.ItemType()); } @@ -310,15 +325,16 @@ namespace CalamityMod.Tiles.Crags.Tree Vector2 treeSegmentOffset = new Vector2((xOff * 2) - (frameOff / 2) + 25, 14); Vector2 topSegmentOffset = new Vector2((xOff * 2) - (frameOff / 2) + 20, 16); - Texture2D baseTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineBottom").Value; - Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineSegments").Value; + BottomTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineBottom"); + SegmentsTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineSegments"); + var segmentTex = SegmentsTexture.Value; //draw the base of the tree if (Framing.GetTileSafely(i, j).TileFrameX == 0) { int frame = tile.TileFrameY / 18; - DrawTreeSegments(i, j, baseTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), baseSegmentOffset, false); + DrawTreeSegments(i, j, BottomTexture.Value, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), baseSegmentOffset, false); } //draw the different segments of the tree @@ -335,8 +351,8 @@ namespace CalamityMod.Tiles.Crags.Tree int frame = tile.TileFrameY / 18; //branch drawing stuff - Texture2D leftBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib1Left").Value; - Texture2D rightBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib1Right").Value; + Rib1LeftTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib1Left"); + Rib1RightTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib1Right"); Vector2 leftBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 50, 14); Vector2 rightBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 4, 14); @@ -344,8 +360,8 @@ namespace CalamityMod.Tiles.Crags.Tree //ok so, terraria just does not want to cooperate when i draw a single branch texture on the side of the tree segments //i changed them into a horitonzal sheet with blanks in it so it gives the illusion of branches being random //not a good idea if branches are meant to be separate tiles, but here they are purely visual so it doesnt matter - DrawTreeSegments(i, j, leftBranchTex, new Rectangle(38 * frame, 0, 38, 40), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); - DrawTreeSegments(i, j, rightBranchTex, new Rectangle(38 * frame, 0, 38, 40), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); + DrawTreeSegments(i, j, Rib1LeftTexture.Value, new Rectangle(38 * frame, 0, 38, 40), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); + DrawTreeSegments(i, j, Rib1RightTexture.Value, new Rectangle(38 * frame, 0, 38, 40), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); //draw segments DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); @@ -357,14 +373,14 @@ namespace CalamityMod.Tiles.Crags.Tree int frame = tile.TileFrameY / 18; //branch drawing stuff - Texture2D leftBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib2Left").Value; - Texture2D rightBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib2Right").Value; + Rib2LeftTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib2Left"); + Rib2RightTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib2Right"); Vector2 leftBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 60, 14); Vector2 rightBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 4, 14); - DrawTreeSegments(i, j, leftBranchTex, new Rectangle(50 * frame, 0, 50, 54), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); - DrawTreeSegments(i, j, rightBranchTex, new Rectangle(50 * frame, 0, 50, 54), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); + DrawTreeSegments(i, j, Rib2LeftTexture.Value, new Rectangle(50 * frame, 0, 50, 54), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); + DrawTreeSegments(i, j, Rib2RightTexture.Value, new Rectangle(50 * frame, 0, 50, 54), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); //draw segments DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); @@ -376,14 +392,14 @@ namespace CalamityMod.Tiles.Crags.Tree int frame = tile.TileFrameY / 18; //branch drawing stuff - Texture2D leftBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib3Left").Value; - Texture2D rightBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib3Right").Value; + Rib3LeftTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib3Left"); + Rib3RightTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib3Right"); Vector2 leftBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 75, 14); Vector2 rightBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 4, 14); - DrawTreeSegments(i, j, leftBranchTex, new Rectangle(62 * frame, 0, 62, 60), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); - DrawTreeSegments(i, j, rightBranchTex, new Rectangle(62 * frame, 0, 62, 60), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); + DrawTreeSegments(i, j, Rib3LeftTexture.Value, new Rectangle(62 * frame, 0, 62, 60), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); + DrawTreeSegments(i, j, Rib3RightTexture.Value, new Rectangle(62 * frame, 0, 62, 60), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); //draw segments DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); @@ -392,10 +408,10 @@ namespace CalamityMod.Tiles.Crags.Tree //draw top segment if (Framing.GetTileSafely(i, j).TileFrameX == 36) { - Texture2D topTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineTop").Value; + TopTexture ??= ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineTop"); int frame = tile.TileFrameY / 18; - DrawTreeSegments(i, j - 1, topTex, new Rectangle(26 * frame, 0, 24, 24), TileOffset.ToWorldCoordinates(), topSegmentOffset, false); + DrawTreeSegments(i, j - 1, TopTexture.Value, new Rectangle(26 * frame, 0, 24, 24), TileOffset.ToWorldCoordinates(), topSegmentOffset, false); //draw segments DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); diff --git a/Tiles/CryonicBarTile.cs b/Tiles/CryonicBarTile.cs index 41266fdccb..1bdee3c4c6 100644 --- a/Tiles/CryonicBarTile.cs +++ b/Tiles/CryonicBarTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles @@ -10,7 +11,7 @@ namespace CalamityMod.Tiles public override void SetStaticDefaults() { this.SetUpBar(ModContent.ItemType(), new Color(138, 43, 226)); - DustType = 44; + DustType = DustID.JungleSpore; } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/CryonicBrick.cs b/Tiles/CryonicBrick.cs index cd7dbfeaa2..ed8e6302ca 100644 --- a/Tiles/CryonicBrick.cs +++ b/Tiles/CryonicBrick.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -24,8 +22,8 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(99, 131, 199)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.SnowBlock, "CalamityMod/Tiles/Merges/SnowMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.SnowBlock); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/DraedonStructures/AgedLaboratoryConsole.cs b/Tiles/DraedonStructures/AgedLaboratoryConsole.cs index 8df5cec10d..3447741bd8 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryConsole.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryConsole.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +11,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class AgedLaboratoryConsole : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -58,15 +58,15 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryConsoleGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryConsoleGlow"); Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; Tile trackTile = Main.tile[i, j]; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) - spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); else if (trackTile.IsHalfBlock) - spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/DraedonStructures/AgedLaboratoryContainmentBox.cs b/Tiles/DraedonStructures/AgedLaboratoryContainmentBox.cs index a1747c07e7..20d59be6ba 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryContainmentBox.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryContainmentBox.cs @@ -1,10 +1,7 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/DraedonStructures/AgedLaboratoryDisplay.cs b/Tiles/DraedonStructures/AgedLaboratoryDisplay.cs index 4363f7433b..e063ac435b 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryDisplay.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryDisplay.cs @@ -1,11 +1,10 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +12,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class AgedLaboratoryDisplay : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -51,15 +52,15 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryDisplayGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryDisplayGlow"); Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; Tile trackTile = Main.tile[i, j]; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) - spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); else if (trackTile.IsHalfBlock) - spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs b/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs index ef9c416ac7..7093bf70f3 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryDoorClosed.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.DraedonStructures AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); TileID.Sets.DisableSmartCursor[Type] = true; AdjTiles = new int[] { TileID.ClosedDoor }; - DustType = 8; + DustType = DustID.Iron; TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); } diff --git a/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs b/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs index 1cfca45934..7976d2bd27 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryDoorOpen.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.DraedonStructures AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); TileID.Sets.DisableSmartCursor[Type] = true; AdjTiles = new int[] { TileID.OpenDoor }; - DustType = 8; + DustType = DustID.Iron; RegisterItemDrop(ModContent.ItemType()); TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); } diff --git a/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs b/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs index c5b808f2f0..b7c7aa9595 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryElectricPanel.cs @@ -1,9 +1,7 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -33,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures TileObjectData.addTile(Type); AddMapEntry(Color.DimGray, CalamityUtils.GetText("Tiles.ElectricPanel")); - DustType = 8; + DustType = DustID.Iron; } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/AgedLaboratoryScreen.cs b/Tiles/DraedonStructures/AgedLaboratoryScreen.cs index 6df4e7fae9..0fd17b97f3 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryScreen.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryScreen.cs @@ -1,10 +1,8 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +10,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class AgedLaboratoryScreen : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -24,7 +24,7 @@ namespace CalamityMod.Tiles.DraedonStructures AddMapEntry(Color.DarkGray, CalamityUtils.GetText("Tiles.Screen")); TileID.Sets.FramesOnKillWall[Type] = true; - DustType = 8; + DustType = DustID.Iron; } public override bool CanExplode(int i, int j) => false; @@ -41,15 +41,15 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryScreenGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryScreenGlow"); Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; Tile trackTile = Main.tile[i, j]; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) - spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); else if (trackTile.IsHalfBlock) - spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/DraedonStructures/AgedLaboratoryServer.cs b/Tiles/DraedonStructures/AgedLaboratoryServer.cs index 78e5f00ba1..8f65cb6d25 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryServer.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryServer.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +11,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class AgedLaboratoryServer : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -58,15 +58,15 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryServerGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedLaboratoryServerGlow"); Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; Tile trackTile = Main.tile[i, j]; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) - spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); else if (trackTile.IsHalfBlock) - spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/DraedonStructures/AgedLaboratoryTerminal.cs b/Tiles/DraedonStructures/AgedLaboratoryTerminal.cs index 76334fadf8..f3ba7e512c 100644 --- a/Tiles/DraedonStructures/AgedLaboratoryTerminal.cs +++ b/Tiles/DraedonStructures/AgedLaboratoryTerminal.cs @@ -1,10 +1,8 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/DraedonStructures/AgedReinforcedCrate.cs b/Tiles/DraedonStructures/AgedReinforcedCrate.cs index 09b2154712..1b41650a9c 100644 --- a/Tiles/DraedonStructures/AgedReinforcedCrate.cs +++ b/Tiles/DraedonStructures/AgedReinforcedCrate.cs @@ -1,10 +1,8 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +10,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class AgedReinforcedCrate : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -47,15 +47,15 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedReinforcedCrateGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/AgedReinforcedCrateGlow"); Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; Tile trackTile = Main.tile[i, j]; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) - spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); else if (trackTile.IsHalfBlock) - spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(GlowTexture.Value, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/DraedonStructures/AgedSecurityChestTile.cs b/Tiles/DraedonStructures/AgedSecurityChestTile.cs index 1b462f44d9..428063eef4 100644 --- a/Tiles/DraedonStructures/AgedSecurityChestTile.cs +++ b/Tiles/DraedonStructures/AgedSecurityChestTile.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.DraedonStructures public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CanExplode(int i, int j) => false; @@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.DraedonStructures public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/DraedonStructures/CagedLights/AgedBiolight.cs b/Tiles/DraedonStructures/CagedLights/AgedBiolight.cs index 3104c250d7..772f157501 100644 --- a/Tiles/DraedonStructures/CagedLights/AgedBiolight.cs +++ b/Tiles/DraedonStructures/CagedLights/AgedBiolight.cs @@ -1,34 +1,29 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class AgedBiolight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/PlagueContainmentCellsPulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 89; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.GemEmerald; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -36,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights // Attach to ground TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row TileObjectData.newTile.Origin = new Point16(0, 1); @@ -78,15 +73,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.PlagueContainmentCellsPulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 9f / 255f * brightness, 195f / 255f * brightness, 0f * brightness); } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/AgedBlacklight.cs b/Tiles/DraedonStructures/CagedLights/AgedBlacklight.cs index e3cf7fc74e..0e10e2480a 100644 --- a/Tiles/DraedonStructures/CagedLights/AgedBlacklight.cs +++ b/Tiles/DraedonStructures/CagedLights/AgedBlacklight.cs @@ -1,34 +1,29 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class AgedBlacklight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/OnyxplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 173; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.ShadowbeamStaff; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -36,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights // Attach to ground TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row TileObjectData.newTile.Origin = new Point16(0, 1); @@ -77,15 +72,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.OnyxplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 182f / 255f * brightness, 28f / 255f * brightness, 232f / 255f * brightness); } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/AgedCinderlight.cs b/Tiles/DraedonStructures/CagedLights/AgedCinderlight.cs index 10195c0bc6..b45c3cad96 100644 --- a/Tiles/DraedonStructures/CagedLights/AgedCinderlight.cs +++ b/Tiles/DraedonStructures/CagedLights/AgedCinderlight.cs @@ -1,34 +1,29 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class AgedCinderlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/CinderplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 6; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Torch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -36,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights // Attach to ground TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row TileObjectData.newTile.Origin = new Point16(0, 1); @@ -78,15 +73,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.CinderplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i, j), 252f / 255f * brightness, 184f / 255f * brightness, 29f / 255f * brightness); } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/AgedFlamelight.cs b/Tiles/DraedonStructures/CagedLights/AgedFlamelight.cs index 5582d62a8a..6b62b11bf8 100644 --- a/Tiles/DraedonStructures/CagedLights/AgedFlamelight.cs +++ b/Tiles/DraedonStructures/CagedLights/AgedFlamelight.cs @@ -1,34 +1,29 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class AgedFlamelight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/HavocplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 60; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.RedTorch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -36,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights // Attach to ground TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row TileObjectData.newTile.Origin = new Point16(0, 1); @@ -78,15 +73,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.HavocplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), (255f / 255f) * brightness, (104f / 255f) * brightness, (104f / 255f) * brightness); } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/AgedFloodlight.cs b/Tiles/DraedonStructures/CagedLights/AgedFloodlight.cs index 1944b32d90..e2328fb19f 100644 --- a/Tiles/DraedonStructures/CagedLights/AgedFloodlight.cs +++ b/Tiles/DraedonStructures/CagedLights/AgedFloodlight.cs @@ -1,34 +1,29 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class AgedFloodlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/NavyplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 187; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.BlueFlare; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -36,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights // Attach to ground TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row TileObjectData.newTile.Origin = new Point16(0, 1); @@ -78,15 +73,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.NavyplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 105f / 255f * brightness, 195f / 255f * brightness, 193f / 255f * brightness); } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/AgedFrostlight.cs b/Tiles/DraedonStructures/CagedLights/AgedFrostlight.cs index 778a36dbc8..9a5e6c011f 100644 --- a/Tiles/DraedonStructures/CagedLights/AgedFrostlight.cs +++ b/Tiles/DraedonStructures/CagedLights/AgedFrostlight.cs @@ -1,34 +1,29 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class AgedFrostlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/ElumplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 247; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.PlatinumCoin; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -36,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights // Attach to ground TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row TileObjectData.newTile.Origin = new Point16(0, 1); @@ -78,15 +73,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.ElumplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 9f / 255f * brightness, 158f / 255f * brightness, 238f / 255f * brightness); } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/AgedLablight.cs b/Tiles/DraedonStructures/CagedLights/AgedLablight.cs index 6e9d5af3c4..985f762766 100644 --- a/Tiles/DraedonStructures/CagedLights/AgedLablight.cs +++ b/Tiles/DraedonStructures/CagedLights/AgedLablight.cs @@ -1,21 +1,20 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class AgedLablight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); + public Asset GlowTexture; public override void SetStaticDefaults() { @@ -23,9 +22,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 299; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.KryptonMoss; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -33,7 +33,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights // Attach to ground TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row TileObjectData.newTile.Origin = new Point16(0, 1); @@ -80,11 +80,6 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights b = 255f / 510f; } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { if (Main.tile[i, j].IsTileActuallyInvisible()) @@ -92,7 +87,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/CagedLights/AgedLablight_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/CagedLights/AgedLablight_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White * 0.6f; @@ -102,6 +100,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights else if (trackTile.IsHalfBlock) spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - } } diff --git a/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs b/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs index f4e36ad4ab..4df8d87028 100644 --- a/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs +++ b/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs @@ -1,30 +1,27 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class CagedBiolight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 89; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.GemEmerald; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -74,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -92,9 +89,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights b = 0f; } } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs b/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs index 70abb33441..7d0bcbc817 100644 --- a/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs +++ b/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs @@ -1,30 +1,27 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class CagedBlacklight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 173; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.ShadowbeamStaff; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +70,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -91,10 +88,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights b = 0f; } } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs b/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs index e570ae6940..c69a3f6b30 100644 --- a/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs +++ b/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs @@ -1,30 +1,27 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class CagedCinderlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 6; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Torch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -74,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -93,9 +90,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs b/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs index dc6cbda8d6..4b54a29dea 100644 --- a/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs +++ b/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs @@ -1,30 +1,27 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class CagedFlamelight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 60; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.RedTorch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -74,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -92,10 +89,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights b = 0f; } } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs b/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs index 0341b99b43..ab4d4cbdd0 100644 --- a/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs +++ b/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs @@ -1,30 +1,27 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class CagedFloodlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 187; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.BlueFlare; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -74,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -92,10 +89,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights b = 0f; } } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs b/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs index 46ebb7ed84..cee6c4998c 100644 --- a/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs +++ b/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs @@ -1,30 +1,27 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class CagedFrostlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 247; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.PlatinumCoin; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -74,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -92,10 +89,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights b = 0f; } } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/CagedLablight.cs b/Tiles/DraedonStructures/CagedLights/CagedLablight.cs index 1a59406c11..8d03228245 100644 --- a/Tiles/DraedonStructures/CagedLights/CagedLablight.cs +++ b/Tiles/DraedonStructures/CagedLights/CagedLablight.cs @@ -1,30 +1,27 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class CagedLablight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; + RegisterItemDrop(ModContent.ItemType()); - HitSound = MinePlatingSound; - DustType = 299; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.KryptonMoss; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -74,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -92,9 +89,5 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights b = 0f; } } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } } } diff --git a/Tiles/DraedonStructures/CagedLights/MiniAgedBiolight.cs b/Tiles/DraedonStructures/CagedLights/MiniAgedBiolight.cs index 02d5c1385e..85bfd49698 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniAgedBiolight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniAgedBiolight.cs @@ -1,34 +1,28 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniAgedBiolight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/PlagueContainmentCellsPulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 89; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.GemEmerald; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +67,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.PlagueContainmentCellsPulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 9f / 255f * brightness, 195f / 255f * brightness, 0f * brightness); diff --git a/Tiles/DraedonStructures/CagedLights/MiniAgedBlacklight.cs b/Tiles/DraedonStructures/CagedLights/MiniAgedBlacklight.cs index cfc8b84013..a793a78161 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniAgedBlacklight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniAgedBlacklight.cs @@ -1,34 +1,28 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniAgedBlacklight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/OnyxplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 173; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.ShadowbeamStaff; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -78,7 +72,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.OnyxplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 182f / 255f * brightness, 28f / 255f * brightness, 232f / 255f * brightness); diff --git a/Tiles/DraedonStructures/CagedLights/MiniAgedCinderlight.cs b/Tiles/DraedonStructures/CagedLights/MiniAgedCinderlight.cs index 15d7c4a15e..6d861f6a4d 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniAgedCinderlight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniAgedCinderlight.cs @@ -1,34 +1,28 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniAgedCinderlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/CinderplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 6; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Torch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -78,7 +72,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.CinderplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 252f / 255f * brightness, 184f / 255f * brightness, 29f / 255f * brightness); diff --git a/Tiles/DraedonStructures/CagedLights/MiniAgedFlamelight.cs b/Tiles/DraedonStructures/CagedLights/MiniAgedFlamelight.cs index 0d858be4dc..f253454aca 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniAgedFlamelight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniAgedFlamelight.cs @@ -1,34 +1,28 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniAgedFlamelight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/HavocplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 60; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.RedTorch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -78,7 +72,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.HavocplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), (255f / 255f) * brightness, (104f / 255f) * brightness, (104f / 255f) * brightness); diff --git a/Tiles/DraedonStructures/CagedLights/MiniAgedFloodlight.cs b/Tiles/DraedonStructures/CagedLights/MiniAgedFloodlight.cs index de6f883b24..a8c3b56590 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniAgedFloodlight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniAgedFloodlight.cs @@ -1,34 +1,28 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniAgedFloodlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/NavyplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 187; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.BlueFlare; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -78,7 +72,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.NavyplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = MathHelper.Clamp(brightness, 0.2f, 0.6f); Lighting.AddLight(new Vector2(i * 16, j * 16), 105f / 255f * brightness, 195f / 255f * brightness, 193f / 255f * brightness); diff --git a/Tiles/DraedonStructures/CagedLights/MiniAgedFrostlight.cs b/Tiles/DraedonStructures/CagedLights/MiniAgedFrostlight.cs index c2343e0bd9..0cd2dbaf3f 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniAgedFrostlight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniAgedFrostlight.cs @@ -1,34 +1,28 @@ -using System; +using CalamityMod.ExtraTextures.GreyscaleGradients; using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniAgedFrostlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetStaticDefaults() { - PulseGradient = new("CalamityMod/Tiles/Plates/ElumplatePulse"); - Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 247; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.PlatinumCoin; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -78,7 +72,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.ElumplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = 0.04f + (brightness * 0.156f); Lighting.AddLight(new Vector2(i, j), 9f / 255f * brightness, 158f / 255f * brightness, 238f / 255f * brightness); diff --git a/Tiles/DraedonStructures/CagedLights/MiniAgedLablight.cs b/Tiles/DraedonStructures/CagedLights/MiniAgedLablight.cs index 8d163d7207..c5c58b377c 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniAgedLablight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniAgedLablight.cs @@ -1,21 +1,20 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.Audio; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniAgedLablight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); + public Asset GlowTexture; public override void SetStaticDefaults() { @@ -24,8 +23,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 299; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.KryptonMoss; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -87,7 +86,10 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/CagedLights/MiniAgedLablight_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/CagedLights/MiniAgedLablight_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White * 0.6f; diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs index b410cb04c0..5b1b1e9ee1 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs @@ -1,21 +1,17 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniCagedBiolight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -23,8 +19,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 89; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.GemEmerald; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs index 68cca8784d..475f01cf32 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs @@ -1,21 +1,17 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniCagedBlacklight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -23,8 +19,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 173; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.ShadowbeamStaff; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs index 1603d07df8..ed67676391 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs @@ -1,21 +1,17 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniCagedCinderlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -23,8 +19,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 6; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Torch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs index 778be69f0e..8d8863731b 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs @@ -1,21 +1,17 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniCagedFlamelight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -23,8 +19,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 60; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.RedTorch; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs index f440165a54..e3bb2773de 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs @@ -1,21 +1,17 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniCagedFloodlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -23,8 +19,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 187; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.BlueFlare; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs index c693efb99d..bac9b21be1 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs @@ -1,21 +1,17 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniCagedFrostlight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -23,8 +19,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 247; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.PlatinumCoin; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -73,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs index 0c49ecb2a5..8b8576b655 100644 --- a/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs +++ b/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs @@ -1,21 +1,17 @@ -using System; -using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; +using CalamityMod.Items.Placeables.DraedonStructures.CagedLights; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ObjectData; -using Terraria.Audio; +using CalamityMod.Sounds; namespace CalamityMod.Tiles.DraedonStructures.CagedLights { public class MiniCagedLablight : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -23,8 +19,8 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = false; - HitSound = MinePlatingSound; - DustType = 299; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.KryptonMoss; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); @@ -74,7 +70,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) diff --git a/Tiles/DraedonStructures/ChargingStation.cs b/Tiles/DraedonStructures/ChargingStation.cs index d3f1f65731..15bb24c0dd 100644 --- a/Tiles/DraedonStructures/ChargingStation.cs +++ b/Tiles/DraedonStructures/ChargingStation.cs @@ -4,12 +4,12 @@ using CalamityMod.Items.Placeables.DraedonStructures; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -27,6 +27,8 @@ namespace CalamityMod.Tiles.DraedonStructures // One cell of charge is placed into the weapon on a timer of this many frames. public const int FramesPerChargeAction = 8; + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -122,15 +124,15 @@ namespace CalamityMod.Tiles.DraedonStructures // Grab the tile entity because its glowmask depends on whether it's currently charging. TEChargingStation charger = CalamityUtils.FindTileEntity(i, j, Width, Height, SheetSquare); - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/ChargingStation_Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/ChargingStation_Glow"); Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; Color drawColor = charger?.LightColor ?? Color.Red; if (!t.IsHalfBlock && t.Slope == 0) - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xFrame, yFrame, 18, 18)), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xFrame, yFrame, 18, 18)), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); else if (t.IsHalfBlock) - Main.spriteBatch.Draw(glowmask, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xFrame, yFrame, 18, 8)), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xFrame, yFrame, 18, 8)), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/DraedonStructures/DraedonLabTurret.cs b/Tiles/DraedonStructures/DraedonLabTurret.cs index be174bc706..7e3014d7df 100644 --- a/Tiles/DraedonStructures/DraedonLabTurret.cs +++ b/Tiles/DraedonStructures/DraedonLabTurret.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -21,6 +22,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset GlowTexture; + public override string Texture => "CalamityMod/Tiles/PlayerTurrets/PlayerLabTurret"; public override void SetStaticDefaults() { @@ -32,6 +35,7 @@ namespace CalamityMod.Tiles.DraedonStructures // Various data sets to protect this tile from unintentional death TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; + TileID.Sets.PreventsTileHammeringIfOnTopOfIt[Type] = true; TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; TileID.Sets.PreventsSandfall[Type] = true; @@ -98,7 +102,9 @@ namespace CalamityMod.Tiles.DraedonStructures drawColor.B = 50; } - Texture2D tex = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseTurret").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseTurret"); + Texture2D tex = GlowTexture.Value; + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/DraedonStructures/HazardChevronPanels.cs b/Tiles/DraedonStructures/HazardChevronPanels.cs index b6e91de50f..e42ed4f982 100644 --- a/Tiles/DraedonStructures/HazardChevronPanels.cs +++ b/Tiles/DraedonStructures/HazardChevronPanels.cs @@ -1,7 +1,7 @@ -using CalamityMod.Systems; +using CalamityMod.Sounds; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -9,7 +9,6 @@ namespace CalamityMod.Tiles.DraedonStructures { public class HazardChevronPanels : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -22,8 +21,8 @@ namespace CalamityMod.Tiles.DraedonStructures CalamityUtils.SetMerge(Type, ModContent.TileType()); CalamityUtils.SetMerge(Type, ModContent.TileType()); - HitSound = MinePlatingSound; - DustType = 19; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Sunflower; MinPick = 30; AddMapEntry(new Color(163, 150, 73)); } diff --git a/Tiles/DraedonStructures/HostileFireTurret .cs b/Tiles/DraedonStructures/HostileFireTurret .cs index 8884ceb5c6..a9ff15afaa 100644 --- a/Tiles/DraedonStructures/HostileFireTurret .cs +++ b/Tiles/DraedonStructures/HostileFireTurret .cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -21,6 +22,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset GlowTexture; + public override string Texture => "CalamityMod/Tiles/PlayerTurrets/PlayerFireTurret"; public override void SetStaticDefaults() { @@ -93,7 +96,9 @@ namespace CalamityMod.Tiles.DraedonStructures drawColor.B = 50; } - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/FireTurretHead").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/FireTurretHead"); + Texture2D tex = GlowTexture.Value; + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/DraedonStructures/HostileIceTurret .cs b/Tiles/DraedonStructures/HostileIceTurret .cs index 0425289e9d..c8d1392947 100644 --- a/Tiles/DraedonStructures/HostileIceTurret .cs +++ b/Tiles/DraedonStructures/HostileIceTurret .cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -21,6 +22,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset GlowTexture; + public override string Texture => "CalamityMod/Tiles/PlayerTurrets/PlayerIceTurret"; public override void SetStaticDefaults() { @@ -93,7 +96,9 @@ namespace CalamityMod.Tiles.DraedonStructures drawColor.B = 50; } - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/IceTurretHead").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/IceTurretHead"); + Texture2D tex = GlowTexture.Value; + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/DraedonStructures/HostileLaserTurret .cs b/Tiles/DraedonStructures/HostileLaserTurret .cs index 434a6c8043..16ab302567 100644 --- a/Tiles/DraedonStructures/HostileLaserTurret .cs +++ b/Tiles/DraedonStructures/HostileLaserTurret .cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -21,6 +22,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset GlowTexture; + public override string Texture => "CalamityMod/Tiles/PlayerTurrets/PlayerLaserTurret"; public override void SetStaticDefaults() { @@ -93,7 +96,9 @@ namespace CalamityMod.Tiles.DraedonStructures drawColor.B = 50; } - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/LaserTurretHead").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/LaserTurretHead"); + Texture2D tex = GlowTexture.Value; + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/DraedonStructures/HostileOnyxTurret.cs b/Tiles/DraedonStructures/HostileOnyxTurret.cs index 2f65fecf9f..2262dfe0da 100644 --- a/Tiles/DraedonStructures/HostileOnyxTurret.cs +++ b/Tiles/DraedonStructures/HostileOnyxTurret.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -21,6 +22,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset GlowTexture; + public override string Texture => "CalamityMod/Tiles/PlayerTurrets/PlayerOnyxTurret"; public override void SetStaticDefaults() { @@ -93,7 +96,9 @@ namespace CalamityMod.Tiles.DraedonStructures drawColor.B = 50; } - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/OnyxTurretHead").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/OnyxTurretHead"); + Texture2D tex = GlowTexture.Value; + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/DraedonStructures/HostilePlagueTurret.cs b/Tiles/DraedonStructures/HostilePlagueTurret.cs index 48d64e8aae..9b2ef184d1 100644 --- a/Tiles/DraedonStructures/HostilePlagueTurret.cs +++ b/Tiles/DraedonStructures/HostilePlagueTurret.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -21,6 +22,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset GlowTexture; + public override string Texture => "CalamityMod/Tiles/PlayerTurrets/PlayerPlagueTurret"; public override void SetStaticDefaults() { @@ -93,7 +96,9 @@ namespace CalamityMod.Tiles.DraedonStructures drawColor.B = 50; } - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/PlagueTurretHead").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/PlagueTurretHead"); + Texture2D tex = GlowTexture.Value; + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/DraedonStructures/HostileWaterTurret.cs b/Tiles/DraedonStructures/HostileWaterTurret.cs index 3f9910d303..cc93014a58 100644 --- a/Tiles/DraedonStructures/HostileWaterTurret.cs +++ b/Tiles/DraedonStructures/HostileWaterTurret.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -21,6 +22,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset GlowTexture; + public override string Texture => "CalamityMod/Tiles/PlayerTurrets/PlayerWaterTurret"; public override void SetStaticDefaults() { @@ -93,7 +96,9 @@ namespace CalamityMod.Tiles.DraedonStructures drawColor.B = 50; } - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/WaterTurretHead").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/WaterTurretHead"); + Texture2D tex = GlowTexture.Value; + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/DraedonStructures/InactivePowerCellFactory.cs b/Tiles/DraedonStructures/InactivePowerCellFactory.cs index 9b452ee533..e2468ee096 100644 --- a/Tiles/DraedonStructures/InactivePowerCellFactory.cs +++ b/Tiles/DraedonStructures/InactivePowerCellFactory.cs @@ -5,7 +5,6 @@ using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/DraedonStructures/LabHologramProjector.cs b/Tiles/DraedonStructures/LabHologramProjector.cs index 450338bc2d..b919b6f0be 100644 --- a/Tiles/DraedonStructures/LabHologramProjector.cs +++ b/Tiles/DraedonStructures/LabHologramProjector.cs @@ -3,12 +3,12 @@ using CalamityMod.Items.Placeables.DraedonStructures; using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -23,6 +23,8 @@ namespace CalamityMod.Tiles.DraedonStructures public const int TalkingFrames = 8; public const int FrameCount = IdleFrames + TalkingFrames; + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -60,7 +62,7 @@ namespace CalamityMod.Tiles.DraedonStructures AnimationFrameHeight = 112; // Spawn electric sparks when this tile is hit with a pickaxe. - DustType = 229; + DustType = DustID.Vortex; HitSound = SoundID.Tink; } @@ -131,7 +133,9 @@ namespace CalamityMod.Tiles.DraedonStructures int yPos = trackTile.TileFrameY; yPos += frame % 16 * 112; - Texture2D tileTexture = ModContent.Request("CalamityMod/Tiles/DraedonStructures/LabHologramProjector").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/LabHologramProjector"); + Texture2D tileTexture = GlowTexture.Value; + Vector2 offset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + offset; Color drawColor = Lighting.GetColor(i, j); diff --git a/Tiles/DraedonStructures/LaboratoryConsole.cs b/Tiles/DraedonStructures/LaboratoryConsole.cs index c04d63edf0..a0869866e6 100644 --- a/Tiles/DraedonStructures/LaboratoryConsole.cs +++ b/Tiles/DraedonStructures/LaboratoryConsole.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +11,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryConsole : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -58,7 +58,10 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryConsoleGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryConsoleGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/DraedonStructures/LaboratoryContainmentBox.cs b/Tiles/DraedonStructures/LaboratoryContainmentBox.cs index 6bbcd91b6f..006f463229 100644 --- a/Tiles/DraedonStructures/LaboratoryContainmentBox.cs +++ b/Tiles/DraedonStructures/LaboratoryContainmentBox.cs @@ -1,10 +1,7 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/DraedonStructures/LaboratoryDisplay.cs b/Tiles/DraedonStructures/LaboratoryDisplay.cs index cc2513cecc..1d2b57e16e 100644 --- a/Tiles/DraedonStructures/LaboratoryDisplay.cs +++ b/Tiles/DraedonStructures/LaboratoryDisplay.cs @@ -1,11 +1,10 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +12,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryDisplay : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -61,7 +62,10 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryDisplayGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryDisplayGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/DraedonStructures/LaboratoryDoorClosed.cs b/Tiles/DraedonStructures/LaboratoryDoorClosed.cs index 7e2ebdc05a..60a6573430 100644 --- a/Tiles/DraedonStructures/LaboratoryDoorClosed.cs +++ b/Tiles/DraedonStructures/LaboratoryDoorClosed.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.DraedonStructures AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); TileID.Sets.DisableSmartCursor[Type] = true; AdjTiles = new int[] { TileID.ClosedDoor }; - DustType = 8; + DustType = DustID.Iron; TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); } diff --git a/Tiles/DraedonStructures/LaboratoryDoorOpen.cs b/Tiles/DraedonStructures/LaboratoryDoorOpen.cs index 48908409b4..c73e69982a 100644 --- a/Tiles/DraedonStructures/LaboratoryDoorOpen.cs +++ b/Tiles/DraedonStructures/LaboratoryDoorOpen.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.DraedonStructures AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); TileID.Sets.DisableSmartCursor[Type] = true; AdjTiles = new int[] { TileID.OpenDoor }; - DustType = 8; + DustType = DustID.Iron; RegisterItemDrop(ModContent.ItemType()); TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); } diff --git a/Tiles/DraedonStructures/LaboratoryElectricPanel.cs b/Tiles/DraedonStructures/LaboratoryElectricPanel.cs index b3498b60cf..be1f7fd376 100644 --- a/Tiles/DraedonStructures/LaboratoryElectricPanel.cs +++ b/Tiles/DraedonStructures/LaboratoryElectricPanel.cs @@ -1,9 +1,7 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -33,7 +31,7 @@ namespace CalamityMod.Tiles.DraedonStructures TileObjectData.addTile(Type); AddMapEntry(Color.DimGray, CalamityUtils.GetText("Tiles.ElectricPanel")); - DustType = 8; + DustType = DustID.Iron; } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/LaboratoryPanels.cs b/Tiles/DraedonStructures/LaboratoryPanels.cs index d63549d56c..3a6f93f01a 100644 --- a/Tiles/DraedonStructures/LaboratoryPanels.cs +++ b/Tiles/DraedonStructures/LaboratoryPanels.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -10,9 +8,6 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryPanels : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -21,13 +16,13 @@ namespace CalamityMod.Tiles.DraedonStructures CalamityUtils.MergeWithGeneral(Type); CalamityUtils.SetMerge(Type, ModContent.TileType()); - HitSound = MinePlatingSound; - DustType = 109; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Asphalt; MinPick = 30; AddMapEntry(new Color(36, 35, 37)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/LaboratoryPipePlating.cs b/Tiles/DraedonStructures/LaboratoryPipePlating.cs index 39ab00a1d2..ebc1061adf 100644 --- a/Tiles/DraedonStructures/LaboratoryPipePlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPipePlating.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; +using CalamityMod.Sounds; using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -11,9 +9,6 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryPipePlating : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -21,13 +16,13 @@ namespace CalamityMod.Tiles.DraedonStructures CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; - DustType = 32; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Sand; MinPick = 30; AddMapEntry(new Color(91, 64, 56)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/LaboratoryPlating.cs b/Tiles/DraedonStructures/LaboratoryPlating.cs index 85b19b55de..3e7d056929 100644 --- a/Tiles/DraedonStructures/LaboratoryPlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPlating.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; +using CalamityMod.Sounds; using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -11,8 +9,6 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryPlating : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -20,13 +16,13 @@ namespace CalamityMod.Tiles.DraedonStructures CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; - DustType = 30; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Web; MinPick = 30; AddMapEntry(new Color(162, 157, 150)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/LaboratoryScreen.cs b/Tiles/DraedonStructures/LaboratoryScreen.cs index 2672f89918..e884ee9c73 100644 --- a/Tiles/DraedonStructures/LaboratoryScreen.cs +++ b/Tiles/DraedonStructures/LaboratoryScreen.cs @@ -1,10 +1,8 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +10,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryScreen : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -24,7 +24,7 @@ namespace CalamityMod.Tiles.DraedonStructures AddMapEntry(Color.DarkGray, CalamityUtils.GetText("Tiles.Screen")); TileID.Sets.FramesOnKillWall[Type] = true; - DustType = 8; + DustType = DustID.Iron; } public override bool CanExplode(int i, int j) => false; @@ -41,7 +41,10 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryScreenGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryScreenGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/DraedonStructures/LaboratoryServer.cs b/Tiles/DraedonStructures/LaboratoryServer.cs index 0d658c83fb..29832f467e 100644 --- a/Tiles/DraedonStructures/LaboratoryServer.cs +++ b/Tiles/DraedonStructures/LaboratoryServer.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +11,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryServer : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -58,7 +58,10 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryServerGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryServerGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/DraedonStructures/LaboratoryShelf.cs b/Tiles/DraedonStructures/LaboratoryShelf.cs index 405d1aee97..0aaf29a445 100644 --- a/Tiles/DraedonStructures/LaboratoryShelf.cs +++ b/Tiles/DraedonStructures/LaboratoryShelf.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.DraedonStructures { this.SetUpPlatform(ModContent.ItemType(), true); HitSound = SoundID.Tink; - DustType = 30; + DustType = DustID.Web; } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/LaboratoryTerminal.cs b/Tiles/DraedonStructures/LaboratoryTerminal.cs index cd75e06802..3f195f0405 100644 --- a/Tiles/DraedonStructures/LaboratoryTerminal.cs +++ b/Tiles/DraedonStructures/LaboratoryTerminal.cs @@ -1,11 +1,10 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +12,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class LaboratoryTerminal : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -61,7 +62,10 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryTerminalGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/LaboratoryTerminalGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/DraedonStructures/PowerCellFactory.cs b/Tiles/DraedonStructures/PowerCellFactory.cs index f6253fb585..121125919f 100644 --- a/Tiles/DraedonStructures/PowerCellFactory.cs +++ b/Tiles/DraedonStructures/PowerCellFactory.cs @@ -11,7 +11,6 @@ using Terraria.Enums; using Terraria.GameContent; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -134,11 +133,12 @@ namespace CalamityMod.Tiles.DraedonStructures frameXPos += frameIndex / FramesPerColumn * (Width * SheetSquare); frameYPos += frameIndex % FramesPerColumn * (Height * SheetSquare); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/DraedonStructures/PowerCellFactory").Value; + + Texture2D tex = TextureAssets.Tile[Type].Value; Vector2 offset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + offset; Color drawColor = Lighting.GetColor(i, j); - + if (!t.IsHalfBlock && t.Slope == 0) spriteBatch.Draw(tex, drawOffset, new Rectangle(frameXPos, frameYPos, 16, 16), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); @@ -146,11 +146,9 @@ namespace CalamityMod.Tiles.DraedonStructures spriteBatch.Draw(tex, drawOffset + Vector2.UnitY * 8f, new Rectangle(frameXPos, frameYPos, 16, 16), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); // Draws the Smart Cursor Highlight. Not 100% accurate, but its close enough - bool actuallySelected; Color highlightColor; - Texture2D texhighlight = ModContent.Request(HighlightTexture).Value; - if (Main.InSmartCursorHighlightArea(i, j, out actuallySelected)) - { + if (TileID.Sets.HasOutlines[Type] && Main.InSmartCursorHighlightArea(i, j, out var actuallySelected)) + { if (actuallySelected) { highlightColor = new Color(252, 252, 84); @@ -159,10 +157,10 @@ namespace CalamityMod.Tiles.DraedonStructures { highlightColor = new Color(125, 125, 125); } - spriteBatch.Draw(texhighlight, drawOffset, new Rectangle(frameXPos, frameYPos, 16, 16), highlightColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + spriteBatch.Draw(TextureAssets.HighlightMask[Type].Value, drawOffset, new Rectangle(frameXPos, frameYPos, 16, 16), highlightColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - - + + return false; } diff --git a/Tiles/DraedonStructures/ReinforcedCrate.cs b/Tiles/DraedonStructures/ReinforcedCrate.cs index dfe34a429e..d3c1d2747a 100644 --- a/Tiles/DraedonStructures/ReinforcedCrate.cs +++ b/Tiles/DraedonStructures/ReinforcedCrate.cs @@ -1,10 +1,8 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +10,8 @@ namespace CalamityMod.Tiles.DraedonStructures { public class ReinforcedCrate : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -47,7 +47,10 @@ namespace CalamityMod.Tiles.DraedonStructures int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/DraedonStructures/ReinforcedCrateGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/DraedonStructures/ReinforcedCrateGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/DraedonStructures/RustedPipes.cs b/Tiles/DraedonStructures/RustedPipes.cs index ca7d0a0c49..58b1f49ef4 100644 --- a/Tiles/DraedonStructures/RustedPipes.cs +++ b/Tiles/DraedonStructures/RustedPipes.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Tiles.DraedonStructures Main.tileMerge[Type][ModContent.TileType()] = true; HitSound = SoundID.Item52; - DustType = 32; + DustType = DustID.Sand; MinPick = 30; AddMapEntry(new Color(128, 90, 77)); } diff --git a/Tiles/DraedonStructures/RustedPlating.cs b/Tiles/DraedonStructures/RustedPlating.cs index 5244fb8a56..8f034b0b21 100644 --- a/Tiles/DraedonStructures/RustedPlating.cs +++ b/Tiles/DraedonStructures/RustedPlating.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; +using CalamityMod.Sounds; using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -11,8 +9,6 @@ namespace CalamityMod.Tiles.DraedonStructures { public class RustedPlating : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -20,13 +16,13 @@ namespace CalamityMod.Tiles.DraedonStructures CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; - DustType = 32; + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.Sand; MinPick = 30; AddMapEntry(new Color(128, 90, 77)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/RustedShelf.cs b/Tiles/DraedonStructures/RustedShelf.cs index 30cad952ff..5e58ea3416 100644 --- a/Tiles/DraedonStructures/RustedShelf.cs +++ b/Tiles/DraedonStructures/RustedShelf.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.DraedonStructures { this.SetUpPlatform(ModContent.ItemType(), true); HitSound = SoundID.Tink; - DustType = 32; + DustType = DustID.Sand; } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/DraedonStructures/SecurityChestTile.cs b/Tiles/DraedonStructures/SecurityChestTile.cs index c9c350c9f9..9ccf53dbb2 100644 --- a/Tiles/DraedonStructures/SecurityChestTile.cs +++ b/Tiles/DraedonStructures/SecurityChestTile.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.DraedonStructures public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CanExplode(int i, int j) => false; @@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.DraedonStructures public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/DraedonSummoner/CodebreakerTile.cs b/Tiles/DraedonSummoner/CodebreakerTile.cs index 1a30d91ae3..0daeccde33 100644 --- a/Tiles/DraedonSummoner/CodebreakerTile.cs +++ b/Tiles/DraedonSummoner/CodebreakerTile.cs @@ -1,7 +1,4 @@ -using CalamityMod.Buffs.Potions; -using CalamityMod.Items.DraedonMisc; -using CalamityMod.TileEntities; -using CalamityMod.UI; +using CalamityMod.TileEntities; using CalamityMod.UI.DraedonSummoning; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -12,7 +9,6 @@ using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -65,7 +61,7 @@ namespace CalamityMod.Tiles.DraedonSummoner // Various data sets to protect this tile from unintentional death TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; - //TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; Since this is a furniture item this may be unnecessary? + TileID.Sets.PreventsTileHammeringIfOnTopOfIt[Type] = true; TileID.Sets.PreventsSandfall[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); diff --git a/Tiles/FloralParadise/AlgalSlate.cs b/Tiles/FloralParadise/AlgalSlate.cs deleted file mode 100644 index 0a2df63db4..0000000000 --- a/Tiles/FloralParadise/AlgalSlate.cs +++ /dev/null @@ -1,42 +0,0 @@ -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class AlgalSlate : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - Main.tileBrick[Type] = true; - TileID.Sets.Stone[Type] = true; - TileID.Sets.Conversion.Stone[Type] = true; - TileID.Sets.CanBeClearedDuringOreRunner[Type] = false; - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeWithOres(Type); - CalamityUtils.MergeWithFloralParadise(Type); - - DustType = 78; - - HitSound = SoundID.Tink; - - AddMapEntry(new Color(33, 56, 27)); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFramingSystem.CustomMergeFrame(i, j, Type, TileID.Dirt, false, false, false, true); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/AlgalSlate.png b/Tiles/FloralParadise/AlgalSlate.png deleted file mode 100644 index 86f7743da6..0000000000 Binary files a/Tiles/FloralParadise/AlgalSlate.png and /dev/null differ diff --git a/Tiles/FloralParadise/LargeLogPiles.cs b/Tiles/FloralParadise/LargeLogPiles.cs deleted file mode 100644 index fefea2c7ea..0000000000 --- a/Tiles/FloralParadise/LargeLogPiles.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class LargeLogPiles : ModTile - { - public const int Variants = 2; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 3; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(1, 2); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - - TileObjectData.addTile(Type); - - DustType = 38; - - AddMapEntry(new Color(114, 72, 49)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/LargeLogPiles.png b/Tiles/FloralParadise/LargeLogPiles.png deleted file mode 100644 index e343f8254a..0000000000 Binary files a/Tiles/FloralParadise/LargeLogPiles.png and /dev/null differ diff --git a/Tiles/FloralParadise/LargeMossPiles.cs b/Tiles/FloralParadise/LargeMossPiles.cs deleted file mode 100644 index bc5e786f47..0000000000 --- a/Tiles/FloralParadise/LargeMossPiles.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class LargeMossPiles : ModTile - { - public const int Variants = 4; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 3; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - DustType = 38; - - AddMapEntry(new Color(56, 56, 56)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/LargeMossPiles.png b/Tiles/FloralParadise/LargeMossPiles.png deleted file mode 100644 index ee20cf395a..0000000000 Binary files a/Tiles/FloralParadise/LargeMossPiles.png and /dev/null differ diff --git a/Tiles/FloralParadise/LargeSubterraneanGrass.cs b/Tiles/FloralParadise/LargeSubterraneanGrass.cs deleted file mode 100644 index d9b38f6785..0000000000 --- a/Tiles/FloralParadise/LargeSubterraneanGrass.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class LargeSubterraneanGrass : ModTile - { - public const int Variants = 5; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 3; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - DustType = 39; - - AddMapEntry(new Color(106, 163, 74)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/LargeSubterraneanGrass.png b/Tiles/FloralParadise/LargeSubterraneanGrass.png deleted file mode 100644 index 4069f95cae..0000000000 Binary files a/Tiles/FloralParadise/LargeSubterraneanGrass.png and /dev/null differ diff --git a/Tiles/FloralParadise/LargeWallFungi.cs b/Tiles/FloralParadise/LargeWallFungi.cs deleted file mode 100644 index e345cac254..0000000000 --- a/Tiles/FloralParadise/LargeWallFungi.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class LargeWallFungi : ModTile - { - public const int Variants = 3; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - DustType = 0; - - AddMapEntry(new Color(165, 126, 84)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/LargeWallFungi.png b/Tiles/FloralParadise/LargeWallFungi.png deleted file mode 100644 index 89c0975133..0000000000 Binary files a/Tiles/FloralParadise/LargeWallFungi.png and /dev/null differ diff --git a/Tiles/FloralParadise/LargeWallFungiLeft.cs b/Tiles/FloralParadise/LargeWallFungiLeft.cs deleted file mode 100644 index e2f84a907b..0000000000 --- a/Tiles/FloralParadise/LargeWallFungiLeft.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class LargeWallFungiLeft : ModTile - { - public const int Variants = 3; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - DustType = 0; - - AddMapEntry(new Color(165, 126, 84)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/LargeWallFungiLeft.png b/Tiles/FloralParadise/LargeWallFungiLeft.png deleted file mode 100644 index 8e765ea7fd..0000000000 Binary files a/Tiles/FloralParadise/LargeWallFungiLeft.png and /dev/null differ diff --git a/Tiles/FloralParadise/LushVines.cs b/Tiles/FloralParadise/LushVines.cs deleted file mode 100644 index 5300739e3e..0000000000 --- a/Tiles/FloralParadise/LushVines.cs +++ /dev/null @@ -1,95 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class LushVines : ModTile - { - public override void SetStaticDefaults() - { - Main.tileCut[Type] = true; - Main.tileBlockLight[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileFrameImportant[Type] = true; - AddMapEntry(new Color(47, 75, 32)); - HitSound = SoundID.Grass; - DustType = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) - { - if (WorldGen.genRand.NextBool(2) && Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].cordage) - Item.NewItem(new EntitySource_TileBreak(i, j), new Vector2(i * 16 + 8f, j * 16 + 8f), ItemID.VineRope); - - if (Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType == Type) - { - WorldGen.KillTile(i, j + 1, false, false, false); - if (!Main.tile[i, j + 1].HasTile && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); - } - } - - if (Main.tile[i, j - 1].HasTile && Main.tile[i, j - 1].TileType == Type) - { - Main.tile[i, j - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, j - 1].TileFrameY = 54; - if (Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); - } - } - - public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j + 1] != null) - { - if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != Type) - { - if (Main.tile[i, j + 1].LiquidAmount >= 128 && Main.tile[i, j + 1].LiquidType == LiquidID.Water) - { - bool canGrow = false; - for (int y = j; y > j - 10; j--) - { - if (Main.tile[i, y].BottomSlope) - { - canGrow = false; - break; - } - if (Main.tile[i, y].HasTile && !Main.tile[i, y].BottomSlope) - { - canGrow = true; - break; - } - } - if (canGrow) - { - int below = j + 1; - Main.tile[i, below].TileType = Type; - Main.tile[i, below].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, below].TileFrameY = 54; - Main.tile[i, below - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, below - 1].TileFrameY = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, below].Get().HasTile = true; - WorldGen.SquareTileFrame(i, below, true); - WorldGen.SquareTileFrame(i, below - 1, true); - if (Main.dedServ) - { - NetMessage.SendTileSquare(-1, i, below, 3, TileChangeType.None); - NetMessage.SendTileSquare(-1, i, below - 1, 3, TileChangeType.None); - } - } - } - } - } - } - } -} diff --git a/Tiles/FloralParadise/LushVines.png b/Tiles/FloralParadise/LushVines.png deleted file mode 100644 index 2ef0db6a25..0000000000 Binary files a/Tiles/FloralParadise/LushVines.png and /dev/null differ diff --git a/Tiles/FloralParadise/MediumFloralPlants.cs b/Tiles/FloralParadise/MediumFloralPlants.cs deleted file mode 100644 index bd764bb33b..0000000000 --- a/Tiles/FloralParadise/MediumFloralPlants.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class MediumFloralPlants : ModTile - { - public const int Variants = 8; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileCut[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - HitSound = SoundID.Grass; - DustType = 2; - AddMapEntry(new Color(106, 135, 69)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (CalamityUtils.ParanoidTileRetrieval(i, j).LiquidAmount > 64) - WorldGen.KillTile(i, j); - } - } -} diff --git a/Tiles/FloralParadise/MediumFloralPlants.png b/Tiles/FloralParadise/MediumFloralPlants.png deleted file mode 100644 index 643c9e94cc..0000000000 Binary files a/Tiles/FloralParadise/MediumFloralPlants.png and /dev/null differ diff --git a/Tiles/FloralParadise/MediumLargeMossPiles.cs b/Tiles/FloralParadise/MediumLargeMossPiles.cs deleted file mode 100644 index 7af71e6c7f..0000000000 --- a/Tiles/FloralParadise/MediumLargeMossPiles.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class MediumLargeMossPiles : ModTile - { - public const int Variants = 4; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - - TileObjectData.addTile(Type); - - DustType = 38; - - AddMapEntry(new Color(56, 56, 56)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/MediumLargeMossPiles.png b/Tiles/FloralParadise/MediumLargeMossPiles.png deleted file mode 100644 index cbf4ace032..0000000000 Binary files a/Tiles/FloralParadise/MediumLargeMossPiles.png and /dev/null differ diff --git a/Tiles/FloralParadise/MediumMossPiles.cs b/Tiles/FloralParadise/MediumMossPiles.cs deleted file mode 100644 index 5094b14dfa..0000000000 --- a/Tiles/FloralParadise/MediumMossPiles.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class MediumMossPiles : ModTile - { - public const int Variants = 4; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - DustType = 38; - - AddMapEntry(new Color(56, 56, 56)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/MediumMossPiles.png b/Tiles/FloralParadise/MediumMossPiles.png deleted file mode 100644 index 05ca5e1d5f..0000000000 Binary files a/Tiles/FloralParadise/MediumMossPiles.png and /dev/null differ diff --git a/Tiles/FloralParadise/Peat.cs b/Tiles/FloralParadise/Peat.cs deleted file mode 100644 index 2a3c08b059..0000000000 --- a/Tiles/FloralParadise/Peat.cs +++ /dev/null @@ -1,40 +0,0 @@ -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class Peat : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - Main.tileBrick[Type] = true; - TileID.Sets.Stone[Type] = true; - TileID.Sets.Conversion.Stone[Type] = true; - TileID.Sets.CanBeClearedDuringOreRunner[Type] = false; - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeWithOres(Type); - CalamityUtils.MergeWithFloralParadise(Type); - - DustType = 78; - - AddMapEntry(new Color(72, 91, 47)); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - TileFramingSystem.CustomMergeFrame(i, j, Type, TileID.Dirt, false, false, false, true); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/Peat.png b/Tiles/FloralParadise/Peat.png deleted file mode 100644 index 2ebbd88951..0000000000 Binary files a/Tiles/FloralParadise/Peat.png and /dev/null differ diff --git a/Tiles/FloralParadise/PeatMoss.cs b/Tiles/FloralParadise/PeatMoss.cs deleted file mode 100644 index 3824a28f8f..0000000000 --- a/Tiles/FloralParadise/PeatMoss.cs +++ /dev/null @@ -1,116 +0,0 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class PeatMoss : ModTile - { - public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/MossMine"); - - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - Main.tileBrick[Type] = true; - - TileID.Sets.Grass[Type] = true; - TileID.Sets.NeedsGrassFraming[Type] = true; - TileID.Sets.NeedsGrassFramingDirt[Type] = ModContent.TileType(); - TileID.Sets.Conversion.Grass[Type] = true; - - CalamityUtils.SetMerge(Type, TileID.Dirt); - CalamityUtils.SetMerge(Type, TileID.Grass); - CalamityUtils.SetMerge(Type, TileID.CorruptGrass); - CalamityUtils.SetMerge(Type, TileID.HallowedGrass); - CalamityUtils.SetMerge(Type, TileID.CrimsonGrass); - CalamityUtils.MergeWithFloralParadise(Type); - - DustType = 39; - HitSound = MineSound; - - AddMapEntry(new Color(65, 142, 101)); - } - - public override void NumDust(int i, int j, bool fail, ref int Type) - { - Type = fail ? 1 : 3; - } - - public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) - { - if (fail && !effectOnly) - Main.tile[i, j].TileType = (ushort)ModContent.TileType(); - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (WorldGen.genRand.NextBool(60) && !Main.gamePaused && CalamityUtils.ParanoidTileRetrieval(i, j - 1).LiquidAmount >= 200) - { - Vector2 algaeVelocity = -Vector2.UnitY.RotatedByRandom(0.91f) * Main.rand.NextFloat(0.85f, 1.6f); - Projectile.NewProjectile(new EntitySource_WorldEvent(), new Vector2(i + 0.5f, j - 0.5f) * 16f, algaeVelocity, ModContent.ProjectileType(), 0, 0f); - } - } - - public override void RandomUpdate(int i, int j) - { - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + Main.maxTilesY * 0.143)); - int nearbyVineCount = 0; - for (int x = i - 15; x <= i + 15; x++) - { - for (int y = j - 15; y <= j + 15; y++) - { - if (WorldGen.InWorld(x, y)) - { - if (CalamityUtils.ParanoidTileRetrieval(x, y).HasTile && - CalamityUtils.ParanoidTileRetrieval(x, y).TileType == (ushort)ModContent.TileType()) - { - nearbyVineCount++; - } - } - } - } - if (Main.tile[i, j + 1] != null && nearbyVineCount < 5) - { - if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) - { - if (Main.tile[i, j + 1].LiquidAmount == 255 && - Main.tile[i, j + 1].LiquidType == LiquidID.Water) - { - bool growMoss = false; - for (int y = num8; y > num8 - 10; y--) - { - if (Main.tile[i, y].BottomSlope) - { - growMoss = false; - break; - } - if (Main.tile[i, y].HasTile && !Main.tile[i, y].BottomSlope) - { - growMoss = true; - break; - } - } - if (growMoss) - { - int belowY = j + 1; - Main.tile[i, belowY].TileType = (ushort)ModContent.TileType(); - Main.tile[i, belowY].Get().HasTile = true; - WorldGen.SquareTileFrame(i, belowY, true); - if (Main.dedServ) - { - NetMessage.SendTileSquare(-1, i, belowY, 3, TileChangeType.None); - } - } - Main.tile[i, j].Get().Slope = SlopeType.Solid; - Main.tile[i, j].Get().IsHalfBlock = false; - } - } - } - } - } -} diff --git a/Tiles/FloralParadise/PeatMoss.png b/Tiles/FloralParadise/PeatMoss.png deleted file mode 100644 index 8a38476c20..0000000000 Binary files a/Tiles/FloralParadise/PeatMoss.png and /dev/null differ diff --git a/Tiles/FloralParadise/PerennialTree.cs b/Tiles/FloralParadise/PerennialTree.cs deleted file mode 100644 index ae4c3d6aec..0000000000 --- a/Tiles/FloralParadise/PerennialTree.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using CalamityMod.DataStructures; -using CalamityMod.ILEditing; -using CalamityMod.Tiles.BaseTiles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class PerennialTree : DynamicallyGrownTree - { - // The max amount that branches can travel. Once the distance of the branches reaches or exceeds this threshold, the tree is done growing. - public override float MaxDistanceBeforeCutoff => 2100f; - - public override float DistanceUsedForTrunk => 140f; - - public override float BranchMaxBendFactor => 0.7f; - - public override float BranchTurnAngleVariance => 0.4f; - - public override float MinBranchLength => 30f; - - public override float TrunkWidth => 16f; - - public override float ChanceToCreateNewBranches => 0.8f; - - public override float VerticalStretchFactor => 12f; - - public override float DownwardBiasFactor => 0.4f; - - public override float BranchGrowthWidthDecay => 0.61f; - - public override int MaxCutoffBranchesPerBranch => 5; - - public override void SetStaticDefaults() - { - Main.tileAxe[Type] = true; - Main.tileFrameImportant[Type] = true; - DustType = 7; - ItemDrop = ItemID.Wood; - UseDefaultSize(); - TileObjectData.addTile(Type); - - AddMapEntry(Color.SaddleBrown); - } - - public void DrawVine(Vector2 vineTop, Vector2 downwardBottom, int totalVinesToDraw, float swayFactor) - { - Texture2D vineTexture = ModContent.Request("CalamityMod/Tiles/PerennialTreeVines").Value; - - // Determine the initial points for the vines. - Vector2[] controlPoints = new Vector2[8]; - Vector2 lightOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(-Main.offScreenRange); - for (int i = 0; i < controlPoints.Length; i++) - { - float swayOffset = swayFactor; - controlPoints[i] = Vector2.Lerp(vineTop, downwardBottom, i / (float)(controlPoints.Length - 1f)); - - Point p = (controlPoints[i] + lightOffset + BranchDrawer.PreviousPoint.ToWorldCoordinates()).ToTileCoordinates(); - - // 02JUN2024: Ozzatron: directionY did not exist at the time of the creation of the Perennial Tree. As such, it is ignored here. - ILChanges.Windgrid.GetWindTime(p.X, p.Y, 40, out int windTimeLeft, out int direction, out _); - - float windInterpolant = windTimeLeft / 40f; - swayOffset += Utils.GetLerpValue(0f, 0.45f, windInterpolant, true) * Utils.GetLerpValue(1f, 0.55f, windInterpolant, true) * direction * 28f; - controlPoints[i].X += swayOffset * Utils.GetLerpValue(0f, controlPoints.Length - 1f, i, true); - controlPoints[i].Y -= 4f; - } - BezierCurve vineCurve = new(controlPoints); - - int drawCount = (int)(totalVinesToDraw * 2.4f); - for (int i = 0; i < drawCount - 1; i++) - { - Vector2 vineCenter = vineCurve.Evaluate(i / (float)(drawCount - 1f)); - Vector2 ahead = vineCurve.Evaluate((i + 1f) / (float)(drawCount - 1f)); - float rotation = (ahead - vineCenter).ToRotation() - MathHelper.PiOver2; - vineCenter += BranchDrawer.PreviousPoint.ToWorldCoordinates() - Main.screenPosition; - - // Calculate light values. - Vector2 lightPosition = vineCenter + lightOffset + Main.screenPosition; - - int frameX = 0; - int frameY = 0; - if (i > 0) - frameY = RNG.Next(1, 3); - if (i >= drawCount - 3) - { - frameY = 3; - frameX = RNG.Next(3); - } - if (i == drawCount - 2) - frameY = 4; - - Rectangle frame = vineTexture.Frame(3, 5, frameX, frameY, -2, -2); - Color color = Lighting.GetColor(lightPosition.ToTileCoordinates()); - - Main.spriteBatch.Draw(vineTexture, vineCenter, frame, color, rotation, frame.Size() * 0.5f, 1f, 0f, 0); - } - } - - public override void DrawThingAtEndOfBranch(BranchDrawer.Branch branch) - { - int totalVinesToDraw = RNG.Next(4, 7); - float swayFactor = Main.windSpeedCurrent + (float)Math.Sin(Main.GlobalTimeWrappedHourly * 1.87f + RNG.NextFloat(0.94f)) * 0.4f; - Vector2 top = branch.EndOfCurve + Vector2.UnitY * 12f; - Vector2 bottom = top + Vector2.UnitY * totalVinesToDraw * 30f; - DrawVine(top, bottom, totalVinesToDraw, swayFactor * 35f); - } - } -} diff --git a/Tiles/FloralParadise/PerennialTree.png b/Tiles/FloralParadise/PerennialTree.png deleted file mode 100644 index 77e0372437..0000000000 Binary files a/Tiles/FloralParadise/PerennialTree.png and /dev/null differ diff --git a/Tiles/FloralParadise/PinkFlower.cs b/Tiles/FloralParadise/PinkFlower.cs deleted file mode 100644 index f6c1a7bb90..0000000000 --- a/Tiles/FloralParadise/PinkFlower.cs +++ /dev/null @@ -1,92 +0,0 @@ -using CalamityMod.ILEditing; -using CalamityMod.Items.Placeables; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class PinkFlower : ModTile - { - public const int Variants = 2; - - public const int WindPushLifetime = 45; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - - TileObjectData.addTile(Type); - - HitSound = SoundID.Grass; - DustType = 44; - AddMapEntry(new Color(255, 155, 202)); - } - - public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) - { - if (drawData.tileFrameX % 36 == 0 && drawData.tileFrameY == 0) - Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); - } - - public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) - { - if (Main.tile[i, j].IsTileActuallyInvisible()) - return; - - // 02JUN2024: Ozzatron: directionY did not exist at the time of the creation of this content. As such, it is ignored here. - ILChanges.Windgrid.GetWindTime(i, j, WindPushLifetime, out int windTimeLeft, out int direction, out _); - - float windInterpolant = windTimeLeft / (float)WindPushLifetime; - float windRotation = Utils.GetLerpValue(0f, 0.5f, windInterpolant, true) * Utils.GetLerpValue(1f, 0.5f, windInterpolant, true) * direction * 0.34f; - - int frameX = Main.tile[i, j].TileFrameX; - Color drawColor = Lighting.GetColor(i, j); - Texture2D stamenTexture = ModContent.Request("CalamityMod/Tiles/FloralParadise/PinkFlowerStamen").Value; - Rectangle stamenFrame = stamenTexture.Frame(2, 1, frameX > 36 ? 1 : 0, 0); - Vector2 stamenOrigin = stamenFrame.Size() * new Vector2(0.5f, 1f); - Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - Vector2 drawPos = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset + new Vector2(17f, 24f); - - // Create some pollen dust. - if (!Main.gamePaused && windTimeLeft >= 2 && Main.rand.NextBool(6)) - { - Vector2 pollenVelocity = -Vector2.UnitY.RotatedByRandom(windRotation * 2.3f) * 3f; - Dust pollen = Dust.NewDustPerfect(drawPos + Main.screenPosition - drawOffset - Vector2.UnitY * 16f, 44); - pollen.velocity = pollenVelocity; - pollen.scale = 1.4f; - } - - Main.spriteBatch.Draw(stamenTexture, drawPos, stamenFrame, drawColor, windRotation, stamenOrigin, 1f, SpriteEffects.None, 0f); - } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/PinkFlower.png b/Tiles/FloralParadise/PinkFlower.png deleted file mode 100644 index 283ca92731..0000000000 Binary files a/Tiles/FloralParadise/PinkFlower.png and /dev/null differ diff --git a/Tiles/FloralParadise/PinkFlowerBig.cs b/Tiles/FloralParadise/PinkFlowerBig.cs deleted file mode 100644 index a4481e7853..0000000000 --- a/Tiles/FloralParadise/PinkFlowerBig.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using CalamityMod.ILEditing; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class PinkFlowerBig : ModTile - { - public const int Variants = 2; - - public const int WindPushLifetime = 48; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - Main.tileLighted[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 4; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(2, 2); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16, - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - - HitSound = SoundID.Grass; - TileObjectData.addTile(Type); - - DustType = 44; - AddMapEntry(new Color(255, 155, 202)); - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.5f; - g = 0.4f; - b = 0.16f; - } - - public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) - { - if (drawData.tileFrameX % 72 == 0 && drawData.tileFrameY == 0) - Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); - } - - public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) - { - if (Main.tile[i, j].IsTileActuallyInvisible()) - return; - - // 02JUN2024: Ozzatron: directionY did not exist at the time of the creation of this content. As such, it is ignored here. - ILChanges.Windgrid.GetWindTime(i, j, WindPushLifetime, out int windTimeLeft, out int direction, out _); - - float windInterpolant = windTimeLeft / (float)WindPushLifetime; - float windRotation = Utils.GetLerpValue(0f, 0.5f, windInterpolant, true) * Utils.GetLerpValue(1f, 0.5f, windInterpolant, true) * direction * 0.34f; - - int frameX = Main.tile[i, j].TileFrameX; - Color drawColor = Lighting.GetColor(i, j); - Texture2D stamenTexture = ModContent.Request("CalamityMod/Tiles/FloralParadise/PinkFlowerBigStamen").Value; - Rectangle stamenFrame = stamenTexture.Frame(2, 1, frameX > 72 ? 1 : 0, 0); - Vector2 stamenOrigin = stamenFrame.Size() * new Vector2(0.5f, 1f); - Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - Vector2 drawPos = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset + new Vector2(31f, 38f); - if (frameX < 72) - drawPos.X += 4f; - - // Create some pollen dust. - if (!Main.gamePaused && windTimeLeft >= 2 && Main.rand.NextBool(4)) - { - Vector2 pollenVelocity = -Vector2.UnitY.RotatedByRandom(windRotation * 2.3f) * 3f; - Dust pollen = Dust.NewDustPerfect(drawPos + Main.screenPosition - drawOffset - Vector2.UnitY * 16f, 44); - pollen.velocity = pollenVelocity; - pollen.scale = 1.6f; - } - - Main.spriteBatch.Draw(stamenTexture, drawPos, stamenFrame, drawColor, windRotation, stamenOrigin, 1f, SpriteEffects.None, 0f); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/PinkFlowerBig.png b/Tiles/FloralParadise/PinkFlowerBig.png deleted file mode 100644 index b8611c19c8..0000000000 Binary files a/Tiles/FloralParadise/PinkFlowerBig.png and /dev/null differ diff --git a/Tiles/FloralParadise/PinkFlowerBigStamen.png b/Tiles/FloralParadise/PinkFlowerBigStamen.png deleted file mode 100644 index 146950fb0d..0000000000 Binary files a/Tiles/FloralParadise/PinkFlowerBigStamen.png and /dev/null differ diff --git a/Tiles/FloralParadise/PinkFlowerStamen.png b/Tiles/FloralParadise/PinkFlowerStamen.png deleted file mode 100644 index 9641dcb280..0000000000 Binary files a/Tiles/FloralParadise/PinkFlowerStamen.png and /dev/null differ diff --git a/Tiles/FloralParadise/SmallFloralPlants.cs b/Tiles/FloralParadise/SmallFloralPlants.cs deleted file mode 100644 index 79dcf79fa1..0000000000 --- a/Tiles/FloralParadise/SmallFloralPlants.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class SmallFloralPlants : ModTile - { - public const int Variants = 8; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileCut[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - HitSound = SoundID.Grass; - DustType = 2; - AddMapEntry(new Color(28, 216, 94)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (CalamityUtils.ParanoidTileRetrieval(i, j).LiquidAmount > 64) - WorldGen.KillTile(i, j); - } - } -} diff --git a/Tiles/FloralParadise/SmallFloralPlants.png b/Tiles/FloralParadise/SmallFloralPlants.png deleted file mode 100644 index f16c30cd3a..0000000000 Binary files a/Tiles/FloralParadise/SmallFloralPlants.png and /dev/null differ diff --git a/Tiles/FloralParadise/SmallMossPiles.cs b/Tiles/FloralParadise/SmallMossPiles.cs deleted file mode 100644 index a927dcd5d1..0000000000 --- a/Tiles/FloralParadise/SmallMossPiles.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class SmallMossPiles : ModTile - { - public const int Variants = 4; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - - TileObjectData.addTile(Type); - - DustType = 38; - - AddMapEntry(new Color(56, 56, 56)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - } -} diff --git a/Tiles/FloralParadise/SmallMossPiles.png b/Tiles/FloralParadise/SmallMossPiles.png deleted file mode 100644 index 78133c1a7d..0000000000 Binary files a/Tiles/FloralParadise/SmallMossPiles.png and /dev/null differ diff --git a/Tiles/FloralParadise/SmallVines.cs b/Tiles/FloralParadise/SmallVines.cs deleted file mode 100644 index c49c7b19b4..0000000000 --- a/Tiles/FloralParadise/SmallVines.cs +++ /dev/null @@ -1,95 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class SmallVines : ModTile - { - public override void SetStaticDefaults() - { - Main.tileCut[Type] = true; - Main.tileBlockLight[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileFrameImportant[Type] = true; - AddMapEntry(new Color(100, 151, 31)); - HitSound = SoundID.Grass; - DustType = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) - { - if (WorldGen.genRand.NextBool(2) && Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].cordage) - Item.NewItem(new EntitySource_TileBreak(i, j), new Vector2(i * 16 + 8f, j * 16 + 8f), ItemID.VineRope); - - if (Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType == Type) - { - WorldGen.KillTile(i, j + 1, false, false, false); - if (!Main.tile[i, j + 1].HasTile && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); - } - } - - if (Main.tile[i, j - 1].HasTile && Main.tile[i, j - 1].TileType == Type) - { - Main.tile[i, j - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, j - 1].TileFrameY = 54; - if (Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); - } - } - - public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j + 1] != null) - { - if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != Type) - { - if (Main.tile[i, j + 1].LiquidAmount >= 128 && Main.tile[i, j + 1].LiquidType == LiquidID.Water) - { - bool canGrow = false; - for (int y = j; y > j - 10; j--) - { - if (Main.tile[i, y].BottomSlope) - { - canGrow = false; - break; - } - if (Main.tile[i, y].HasTile && !Main.tile[i, y].BottomSlope) - { - canGrow = true; - break; - } - } - if (canGrow) - { - int below = j + 1; - Main.tile[i, below].TileType = Type; - Main.tile[i, below].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, below].TileFrameY = 54; - Main.tile[i, below - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, below - 1].TileFrameY = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[i, below].Get().HasTile = true; - WorldGen.SquareTileFrame(i, below, true); - WorldGen.SquareTileFrame(i, below - 1, true); - if (Main.dedServ) - { - NetMessage.SendTileSquare(-1, i, below, 3, TileChangeType.None); - NetMessage.SendTileSquare(-1, i, below - 1, 3, TileChangeType.None); - } - } - } - } - } - } - } -} diff --git a/Tiles/FloralParadise/SmallVines.png b/Tiles/FloralParadise/SmallVines.png deleted file mode 100644 index 6b64a467be..0000000000 Binary files a/Tiles/FloralParadise/SmallVines.png and /dev/null differ diff --git a/Tiles/FloralParadise/SmallWallFungi.cs b/Tiles/FloralParadise/SmallWallFungi.cs deleted file mode 100644 index 0897ba3df2..0000000000 --- a/Tiles/FloralParadise/SmallWallFungi.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class SmallWallFungi : ModTile - { - public const int Variants = 3; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 1, 0); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - DustType = 0; - - AddMapEntry(new Color(165, 126, 84)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/SmallWallFungi.png b/Tiles/FloralParadise/SmallWallFungi.png deleted file mode 100644 index de025416bc..0000000000 Binary files a/Tiles/FloralParadise/SmallWallFungi.png and /dev/null differ diff --git a/Tiles/FloralParadise/SmallWallFungiLeft.cs b/Tiles/FloralParadise/SmallWallFungiLeft.cs deleted file mode 100644 index 5bf26a266e..0000000000 --- a/Tiles/FloralParadise/SmallWallFungiLeft.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class SmallWallFungiLeft : ModTile - { - public const int Variants = 3; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 1, 0); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - DustType = 0; - - AddMapEntry(new Color(165, 126, 84)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/SmallWallFungiLeft.png b/Tiles/FloralParadise/SmallWallFungiLeft.png deleted file mode 100644 index 55d42f575c..0000000000 Binary files a/Tiles/FloralParadise/SmallWallFungiLeft.png and /dev/null differ diff --git a/Tiles/FloralParadise/TallFloralPlants.cs b/Tiles/FloralParadise/TallFloralPlants.cs deleted file mode 100644 index ab4d00e0df..0000000000 --- a/Tiles/FloralParadise/TallFloralPlants.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class TallFloralPlants : ModTile - { - public const int Variants = 12; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileCut[Type] = true; - Main.tileObsidianKill[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 1; - TileObjectData.newTile.Origin = new Point16(1, 0); - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16 - }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - HitSound = SoundID.Grass; - DustType = 2; - AddMapEntry(new Color(106, 135, 69)); - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 4; - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (CalamityUtils.ParanoidTileRetrieval(i, j).LiquidAmount > 64) - WorldGen.KillTile(i, j); - } - } -} diff --git a/Tiles/FloralParadise/TallFloralPlants.png b/Tiles/FloralParadise/TallFloralPlants.png deleted file mode 100644 index 45e35742a0..0000000000 Binary files a/Tiles/FloralParadise/TallFloralPlants.png and /dev/null differ diff --git a/Tiles/FloralParadise/VineLoops.cs b/Tiles/FloralParadise/VineLoops.cs deleted file mode 100644 index f2350cc926..0000000000 --- a/Tiles/FloralParadise/VineLoops.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class VineLoops : ModTile - { - public const int Variants = 3; - - public override void SetStaticDefaults() - { - Main.tileCut[Type] = true; - Main.tileBlockLight[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileFrameImportant[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorTop = new(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - AddMapEntry(new Color(47, 75, 32)); - HitSound = SoundID.Grass; - DustType = 2; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/VineLoops.png b/Tiles/FloralParadise/VineLoops.png deleted file mode 100644 index 987e3b445d..0000000000 Binary files a/Tiles/FloralParadise/VineLoops.png and /dev/null differ diff --git a/Tiles/FloralParadise/WallLeaves.cs b/Tiles/FloralParadise/WallLeaves.cs deleted file mode 100644 index ac13b4b1e7..0000000000 --- a/Tiles/FloralParadise/WallLeaves.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class WallLeaves : ModTile - { - public const int Variants = 3; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - HitSound = SoundID.Grass; - DustType = 0; - - AddMapEntry(new Color(145, 170, 61)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/WallLeaves.png b/Tiles/FloralParadise/WallLeaves.png deleted file mode 100644 index 2a9a284419..0000000000 Binary files a/Tiles/FloralParadise/WallLeaves.png and /dev/null differ diff --git a/Tiles/FloralParadise/WallLeavesLeft.cs b/Tiles/FloralParadise/WallLeavesLeft.cs deleted file mode 100644 index 2cfbb980bd..0000000000 --- a/Tiles/FloralParadise/WallLeavesLeft.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class WallLeavesLeft : ModTile - { - public const int Variants = 3; - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.RandomStyleRange = Variants; - TileObjectData.addTile(Type); - - HitSound = SoundID.Grass; - DustType = 0; - - AddMapEntry(new Color(145, 170, 61)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FloralParadise/WallLeavesLeft.png b/Tiles/FloralParadise/WallLeavesLeft.png deleted file mode 100644 index a82df1d3ea..0000000000 Binary files a/Tiles/FloralParadise/WallLeavesLeft.png and /dev/null differ diff --git a/Tiles/FloralParadise/WaterfallCreator.cs b/Tiles/FloralParadise/WaterfallCreator.cs deleted file mode 100644 index 9bda03602b..0000000000 --- a/Tiles/FloralParadise/WaterfallCreator.cs +++ /dev/null @@ -1,42 +0,0 @@ -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FloralParadise -{ - public class WaterfallCreator : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = false; - Main.tileBlockLight[Type] = true; - Main.tileBrick[Type] = true; - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeWithOres(Type); - CalamityUtils.MergeWithFloralParadise(Type); - - HitSound = SoundID.Tink; - - AddMapEntry(new Color(33, 56, 27)); - } - - public override void NearbyEffects(int i, int j, bool closer) - { - Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); - if (Main.dedServ || !Main.rand.NextBool() || Main.gamePaused || tile.LiquidAmount > 0) - return; - - for (int k = 0; k < 16; k++) - { - Vector2 waterVelocity = -Vector2.UnitY.RotatedByRandom(0.29f) * Main.rand.NextFloat(1f, 2.4f); - float waterScale = Main.rand.NextFloat(0.08f, 0.12f); - Color waterColor = Color.Lerp(Color.Cyan, Color.SkyBlue, Main.rand.NextFloat()); - Vector2 particlePosition = new Vector2(i + 0.5f, j + 0.5f) * 16f + Vector2.UnitY * Main.rand.NextFloat(24f); - GeneralParticleHandler.SpawnParticle(new WaterFoamParticle(particlePosition, waterVelocity, 150, waterScale, waterColor)); - } - } - } -} diff --git a/Tiles/FloralParadise/WaterfallCreator.png b/Tiles/FloralParadise/WaterfallCreator.png deleted file mode 100644 index 622533204a..0000000000 Binary files a/Tiles/FloralParadise/WaterfallCreator.png and /dev/null differ diff --git a/Tiles/Furniture/BabyFlakCrabCageTile.cs b/Tiles/Furniture/BabyFlakCrabCageTile.cs index b1d2596cd8..748660cb6e 100644 --- a/Tiles/Furniture/BabyFlakCrabCageTile.cs +++ b/Tiles/Furniture/BabyFlakCrabCageTile.cs @@ -3,10 +3,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/BabyGhostBellJarTile.cs b/Tiles/Furniture/BabyGhostBellJarTile.cs index 5f29ee1dee..d91a8e9177 100644 --- a/Tiles/Furniture/BabyGhostBellJarTile.cs +++ b/Tiles/Furniture/BabyGhostBellJarTile.cs @@ -1,9 +1,7 @@ using CalamityMod.Items.Placeables.Furniture; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/BlueCandle.cs b/Tiles/Furniture/BlueCandle.cs index ae874cba1a..9475eadbcd 100644 --- a/Tiles/Furniture/BlueCandle.cs +++ b/Tiles/Furniture/BlueCandle.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.Furniture { public class BlueCandle : ModTile { - // TODO -- Unique sounds for each Cirrus Candle. + // TODO -- Unique sounds for each Candle. public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); public override void SetStaticDefaults() @@ -36,13 +36,13 @@ namespace CalamityMod.Tiles.Furniture Player p = Main.LocalPlayer; // Forcibly remove all candle buffs. - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); // 108000 is the duration used by Ammo Box. - p.AddBuff(ModContent.BuffType(), 108000); + p.AddBuff(ModContent.BuffType(), 108000); // Play a sound. SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); diff --git a/Tiles/Furniture/BossTrophies/AnahitaTrophyTile.cs b/Tiles/Furniture/BossTrophies/AnahitaTrophyTile.cs index 7048372e7a..dc62a31856 100644 --- a/Tiles/Furniture/BossTrophies/AnahitaTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/AnahitaTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/ApolloTrophyTile.cs b/Tiles/Furniture/BossTrophies/ApolloTrophyTile.cs index 9ccb79a365..57436cf5dd 100644 --- a/Tiles/Furniture/BossTrophies/ApolloTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/ApolloTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/AquaticScourgeTrophyTile.cs b/Tiles/Furniture/BossTrophies/AquaticScourgeTrophyTile.cs index 9f4125a073..060bce6490 100644 --- a/Tiles/Furniture/BossTrophies/AquaticScourgeTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/AquaticScourgeTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/AresTrophyTile.cs b/Tiles/Furniture/BossTrophies/AresTrophyTile.cs index 63ec38a3e1..1513cbc110 100644 --- a/Tiles/Furniture/BossTrophies/AresTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/AresTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/ArtemisTrophyTile.cs b/Tiles/Furniture/BossTrophies/ArtemisTrophyTile.cs index b0dd332051..44dde0e3bf 100644 --- a/Tiles/Furniture/BossTrophies/ArtemisTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/ArtemisTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/AstrumAureusTrophyTile.cs b/Tiles/Furniture/BossTrophies/AstrumAureusTrophyTile.cs index 6a70323c4e..a7d9adb203 100644 --- a/Tiles/Furniture/BossTrophies/AstrumAureusTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/AstrumAureusTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/AstrumDeusTrophyTile.cs b/Tiles/Furniture/BossTrophies/AstrumDeusTrophyTile.cs index bd5dd1ffa8..27efcbaff6 100644 --- a/Tiles/Furniture/BossTrophies/AstrumDeusTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/AstrumDeusTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/BrimstoneElementalTrophyTile.cs b/Tiles/Furniture/BossTrophies/BrimstoneElementalTrophyTile.cs index 579fc2726e..b48b86aa3f 100644 --- a/Tiles/Furniture/BossTrophies/BrimstoneElementalTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/BrimstoneElementalTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/CalamitasCloneTrophyTile.cs b/Tiles/Furniture/BossTrophies/CalamitasCloneTrophyTile.cs index 8e57294b18..119843da6e 100644 --- a/Tiles/Furniture/BossTrophies/CalamitasCloneTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/CalamitasCloneTrophyTile.cs @@ -1,9 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Localization; -using Terraria.ModLoader; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/CataclysmTrophyTile.cs b/Tiles/Furniture/BossTrophies/CataclysmTrophyTile.cs index f66232efd0..aa58c900f5 100644 --- a/Tiles/Furniture/BossTrophies/CataclysmTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/CataclysmTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/CatastropheTrophyTile.cs b/Tiles/Furniture/BossTrophies/CatastropheTrophyTile.cs index 4f9d7de554..d193faecf5 100644 --- a/Tiles/Furniture/BossTrophies/CatastropheTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/CatastropheTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/CeaselessVoidTrophyTile.cs b/Tiles/Furniture/BossTrophies/CeaselessVoidTrophyTile.cs index 2c57720d9c..5b44096b12 100644 --- a/Tiles/Furniture/BossTrophies/CeaselessVoidTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/CeaselessVoidTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/CrabulonTrophyTile.cs b/Tiles/Furniture/BossTrophies/CrabulonTrophyTile.cs index 2df1cd7282..0d918df02f 100644 --- a/Tiles/Furniture/BossTrophies/CrabulonTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/CrabulonTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/CragmawMireTrophyTile.cs b/Tiles/Furniture/BossTrophies/CragmawMireTrophyTile.cs index 37a04a3147..81fde541cb 100644 --- a/Tiles/Furniture/BossTrophies/CragmawMireTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/CragmawMireTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/CryogenTrophyTile.cs b/Tiles/Furniture/BossTrophies/CryogenTrophyTile.cs index 85b7281de5..87673679d1 100644 --- a/Tiles/Furniture/BossTrophies/CryogenTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/CryogenTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/DesertScourgeTrophyTile.cs b/Tiles/Furniture/BossTrophies/DesertScourgeTrophyTile.cs index 276aa97a44..cf56440e70 100644 --- a/Tiles/Furniture/BossTrophies/DesertScourgeTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/DesertScourgeTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/DevourerofGodsTrophyTile.cs b/Tiles/Furniture/BossTrophies/DevourerofGodsTrophyTile.cs index 7b68a527e3..5d542adb46 100644 --- a/Tiles/Furniture/BossTrophies/DevourerofGodsTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/DevourerofGodsTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/DragonfollyTrophyTile.cs b/Tiles/Furniture/BossTrophies/DragonfollyTrophyTile.cs index 4790f3444c..b43f9c113f 100644 --- a/Tiles/Furniture/BossTrophies/DragonfollyTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/DragonfollyTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/GiantClamTrophyTile.cs b/Tiles/Furniture/BossTrophies/GiantClamTrophyTile.cs index 87d82f0cdb..61f1ad544f 100644 --- a/Tiles/Furniture/BossTrophies/GiantClamTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/GiantClamTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/GreatSandSharkTrophyTile.cs b/Tiles/Furniture/BossTrophies/GreatSandSharkTrophyTile.cs index 8d5f1494b5..34b1057e84 100644 --- a/Tiles/Furniture/BossTrophies/GreatSandSharkTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/GreatSandSharkTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/HiveMindTrophyTile.cs b/Tiles/Furniture/BossTrophies/HiveMindTrophyTile.cs index 9c12be8207..8de76d3ca4 100644 --- a/Tiles/Furniture/BossTrophies/HiveMindTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/HiveMindTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/LeviathanTrophyTile.cs b/Tiles/Furniture/BossTrophies/LeviathanTrophyTile.cs index cb5c2da9cc..78ca89a36a 100644 --- a/Tiles/Furniture/BossTrophies/LeviathanTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/LeviathanTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/MaulerTrophyTile.cs b/Tiles/Furniture/BossTrophies/MaulerTrophyTile.cs index b3c1f61f04..c581016270 100644 --- a/Tiles/Furniture/BossTrophies/MaulerTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/MaulerTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/NuclearTerrorTrophyTile.cs b/Tiles/Furniture/BossTrophies/NuclearTerrorTrophyTile.cs index f2f7c75562..6f078ea752 100644 --- a/Tiles/Furniture/BossTrophies/NuclearTerrorTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/NuclearTerrorTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/OldDukeTrophyTile.cs b/Tiles/Furniture/BossTrophies/OldDukeTrophyTile.cs index f3078dcb67..0363b3b467 100644 --- a/Tiles/Furniture/BossTrophies/OldDukeTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/OldDukeTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/PerforatorTrophyTile.cs b/Tiles/Furniture/BossTrophies/PerforatorTrophyTile.cs index 1e44b53d07..b3dccce0ca 100644 --- a/Tiles/Furniture/BossTrophies/PerforatorTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/PerforatorTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/PlaguebringerGoliathTrophyTile.cs b/Tiles/Furniture/BossTrophies/PlaguebringerGoliathTrophyTile.cs index 14f0d3334f..774fe36c85 100644 --- a/Tiles/Furniture/BossTrophies/PlaguebringerGoliathTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/PlaguebringerGoliathTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/PolterghastTrophyTile.cs b/Tiles/Furniture/BossTrophies/PolterghastTrophyTile.cs index de357c9f9e..528641b1ee 100644 --- a/Tiles/Furniture/BossTrophies/PolterghastTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/PolterghastTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/ProfanedGuardianTrophyTile.cs b/Tiles/Furniture/BossTrophies/ProfanedGuardianTrophyTile.cs index abdc13ca60..97fc1e8eba 100644 --- a/Tiles/Furniture/BossTrophies/ProfanedGuardianTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/ProfanedGuardianTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/ProvidenceTrophyTile.cs b/Tiles/Furniture/BossTrophies/ProvidenceTrophyTile.cs index d1c028f2be..203ed047fe 100644 --- a/Tiles/Furniture/BossTrophies/ProvidenceTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/ProvidenceTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/RavagerTrophyTile.cs b/Tiles/Furniture/BossTrophies/RavagerTrophyTile.cs index 997fca438b..c2cda4c7ae 100644 --- a/Tiles/Furniture/BossTrophies/RavagerTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/RavagerTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/SignusTrophyTile.cs b/Tiles/Furniture/BossTrophies/SignusTrophyTile.cs index 36698b7d99..29cf258e16 100644 --- a/Tiles/Furniture/BossTrophies/SignusTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/SignusTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/SlimeGodTrophyTile.cs b/Tiles/Furniture/BossTrophies/SlimeGodTrophyTile.cs index 98b7eedc80..9d6e4e03be 100644 --- a/Tiles/Furniture/BossTrophies/SlimeGodTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/SlimeGodTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/StormWeaverTrophyTile.cs b/Tiles/Furniture/BossTrophies/StormWeaverTrophyTile.cs index fa3c4c339f..403eba4a82 100644 --- a/Tiles/Furniture/BossTrophies/StormWeaverTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/StormWeaverTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/SupremeCalamitasTrophyTile.cs b/Tiles/Furniture/BossTrophies/SupremeCalamitasTrophyTile.cs index bd5f8ec461..9b26a36131 100644 --- a/Tiles/Furniture/BossTrophies/SupremeCalamitasTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/SupremeCalamitasTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/SupremeCataclysmTrophyTile.cs b/Tiles/Furniture/BossTrophies/SupremeCataclysmTrophyTile.cs index 1f81354efc..27f79232d2 100644 --- a/Tiles/Furniture/BossTrophies/SupremeCataclysmTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/SupremeCataclysmTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/SupremeCatastropheTrophyTile.cs b/Tiles/Furniture/BossTrophies/SupremeCatastropheTrophyTile.cs index 9da17a1c6b..e081d9c6fe 100644 --- a/Tiles/Furniture/BossTrophies/SupremeCatastropheTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/SupremeCatastropheTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/ThanatosTrophyTile.cs b/Tiles/Furniture/BossTrophies/ThanatosTrophyTile.cs index 11b5413c15..bcddc615c9 100644 --- a/Tiles/Furniture/BossTrophies/ThanatosTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/ThanatosTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/BossTrophies/YharonTrophyTile.cs b/Tiles/Furniture/BossTrophies/YharonTrophyTile.cs index 2d2a71f93f..c040daaf85 100644 --- a/Tiles/Furniture/BossTrophies/YharonTrophyTile.cs +++ b/Tiles/Furniture/BossTrophies/YharonTrophyTile.cs @@ -1,11 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.Trophies; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; +using Terraria.ModLoader; namespace CalamityMod.Tiles.Furniture.BossTrophies { diff --git a/Tiles/Furniture/CalamityCanvas2023Tile.cs b/Tiles/Furniture/CalamityCanvas2023Tile.cs deleted file mode 100644 index b5693bbff7..0000000000 --- a/Tiles/Furniture/CalamityCanvas2023Tile.cs +++ /dev/null @@ -1,226 +0,0 @@ -using CalamityMod.TileEntities; -using CalamityMod.UI; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.Furniture -{ - public class CalamityCanvas2023Tile : ModTile - { - public static Asset border; - public static Asset corner; - - public override void Load() - { - border = ModContent.Request("CalamityMod/Tiles/Furniture/CalamityCanvasBorder"); - corner = ModContent.Request("CalamityMod/Tiles/Furniture/CalamityCanvasCorner"); - } - - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileSpelunker[Type] = true; - Main.tileWaterDeath[Type] = false; - - TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); - TileObjectData.newTile.Width = 5; - TileObjectData.newTile.Height = 5; - TileObjectData.newTile.CoordinateHeights = new int[] { 18, 18, 18, 18, 18 }; - TileObjectData.newTile.UsesCustomCanPlace = true; - //TileObjectData.newTile.Origin = new Point16(2, 0); - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(ModContent.GetInstance().Hook_AfterPlacement, -1, 0, false); - TileObjectData.addTile(Type); - - TileID.Sets.DisableSmartCursor[Type] = true; - TileID.Sets.FramesOnKillWall[Type] = true; - TileID.Sets.DisableSmartCursor[Type] = true; - - AddMapEntry(new Color(99, 50, 30), Language.GetText("MapObject.Painting")); - } - public override bool HasSmartInteract(int i, int j, Terraria.GameContent.ObjectInteractions.SmartInteractScanSettings settings) => true; - - public override bool RightClick(int i, int j) - { - Main.LocalPlayer.CancelSignsAndChests(); - TECanvasPainting cube = CalamityUtils.FindTileEntity(i, j, 5, 5); - if (cube != null) - { - CanvasPaintingUIState.ResetVars(); - Main.LocalPlayer.Calamity().CurrentlyViewedCanvasID = cube.ID; - Main.LocalPlayer.Calamity().CurrentlyViewedCanvasType = 0; - SoundEngine.PlaySound(SoundID.MenuOpen); - Main.playerInventory = true; - Main.recBigList = false; - } - Recipe.FindRecipes(); - return false; - } - - public override void MouseOver(int i, int j) - { - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - Main.LocalPlayer.noThrow = 2; - Main.LocalPlayer.cursorItemIconEnabled = true; - } - - public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) - { - Tile t = Main.tile[i, j]; - int left = i - t.TileFrameX % (5 * 18) / 18; - int top = j - t.TileFrameY % (5 * 18) / 18; - - TECanvasPainting canvas = CalamityUtils.FindTileEntity(i, j, 5, 5, 18); - - canvas?.Kill(left, top); - } - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Tile t = Main.tile[i, j]; - Texture2D texture = TextureAssets.Tile[Type].Value; - TECanvasPainting cube = CalamityUtils.FindTileEntity(i, j, 1, 1); - float baseDimension = 80; // 5 * 16 - Vector2 pos = new Vector2(i * 16, j * 16) + CalamityUtils.TileDrawOffset; - if (cube != null && t.TileFrameX == 0) - { - int fPX = (int)cube.framePosition.X; - int fPY = (int)cube.framePosition.Y; - int scale = (int)(texture.Width * 0.1f * cube.scale); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null); - // TODO: make the 0.4 in scale not a hardcoded number with seemingly no meaning - spriteBatch.Draw(texture, pos - Main.screenPosition, new Rectangle(fPX, fPY, scale, scale), Lighting.GetColor(i, j), 0, new Vector2(0, 0), 1 / cube.scale * 0.4f, 0, 0); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null); - } - // Calculate and draw the borders - if (t.TileFrameX == 0 && t.TileFrameY == 0) - DrawBorders(spriteBatch, pos - Main.screenPosition, new Point(i, j)); - return false; - } - public static void DrawBorders(SpriteBatch spriteBatch, Vector2 pos, Point cords) - { - Texture2D texture = border.Value; - Texture2D cornerTex = corner.Value; - ushort canvasID = (ushort)ModContent.TileType(); - int commonDim = 8; - int finalCord = 72; - int size = 80; - Color light = Lighting.GetColor(cords.X, cords.Y); - - // Check for nearby Canvas paintings - // If they are cleanly lined up with this Canvas painting, don't draw borders between them - bool drawTop = true; - bool drawLeft = true; - bool drawRight = true; - bool drawBottom = true; - // Corners - bool drawTopLeft = false; - bool drawTopRight = false; - bool drawBottomLeft = false; - bool drawBottomRight = false; - - // The bottom right tile of the canvas painting - Point bottomRight = new Point(cords.X + 4, cords.Y + 4); - - // Adjacent tiles that may or may not have other canvas paintings - Tile left = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, cords.Y); - Tile top = CalamityUtils.ParanoidTileRetrieval(cords.X, cords.Y - 1); - Tile right = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, bottomRight.Y); - Tile bottom = CalamityUtils.ParanoidTileRetrieval(bottomRight.X, bottomRight.Y + 1); - - // Check if adjacent tiles are canvas paintings that are lined up with this one - bool validTop = ValidCanvasFrame(top, 0, size, canvasID); - bool validRight = ValidCanvasFrame(right, 0, size, canvasID); - bool validLeft = ValidCanvasFrame(left, finalCord, 0, canvasID); - bool validBottom = ValidCanvasFrame(bottom, finalCord, 0, canvasID); - - if (validTop) - { - drawTop = false; - } - if (validBottom) - { - drawBottom = false; - } - if (validRight) - { - drawRight = false; - // Check for junction corners - Tile topright = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, cords.Y - 1); - Tile bottomright = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, bottomRight.Y + 1); - if (!drawTop && !ValidCanvasFrame(topright, 0, size, canvasID)) - { - drawTopRight = true; - } - if (!drawBottom && !ValidCanvasFrame(bottomright, 0, 0, canvasID)) - { - drawBottomRight = true; - } - } - if (validLeft) - { - drawLeft = false; - // Check for junction corners - Tile topleft = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, cords.Y - 1); - Tile bottomleft = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, bottomRight.Y + 1); - if (!drawTop && !ValidCanvasFrame(topleft, finalCord, size, canvasID)) - { - drawTopLeft = true; - } - if (!drawBottom && !ValidCanvasFrame(bottomleft, finalCord, 0, canvasID)) - { - drawBottomLeft = true; - } - } - - // Draw the sides - if (drawBottom) - spriteBatch.Draw(texture, pos + Vector2.UnitY * finalCord, new Rectangle(0, texture.Height - commonDim, texture.Width, commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawTop) - spriteBatch.Draw(texture, pos, new Rectangle(0, 0, texture.Width, commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawRight) - spriteBatch.Draw(texture, pos + Vector2.UnitX * finalCord, new Rectangle(texture.Width - commonDim, commonDim, commonDim, texture.Height - (2 * commonDim)), light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawLeft) - spriteBatch.Draw(texture, pos, new Rectangle(0, commonDim, commonDim, texture.Height - (2 * commonDim)), light, 0, new Vector2(0, 0), 1, 0, 0); - - // Draw the corners - // All corner drawing is done with a single corner sprite that is rotated and flipped about depending on the situation - if (drawTop && drawLeft) - spriteBatch.Draw(cornerTex, pos, null, light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawTop && drawRight) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitX * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipHorizontally, 0); - if (drawBottom && drawLeft) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitY * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipVertically, 0); - if (drawBottom && drawRight) - spriteBatch.Draw(cornerTex, pos + Vector2.One * size, null, light, MathHelper.Pi, new Vector2(0, 0), 1, 0, 0); - - // Draw junction corners - if (drawTopLeft) - spriteBatch.Draw(cornerTex, pos + corner.Size(), null, light, MathHelper.Pi, new Vector2(0, 0), 1, 0, 0); - if (drawTopRight) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitX * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipVertically, 0); - if (drawBottomLeft) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitY * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipHorizontally, 0); - if (drawBottomRight) - spriteBatch.Draw(cornerTex, pos - corner.Size() + Vector2.One * size, null, light, 0, new Vector2(0, 0), 1, 0, 0); - } - - // Check if the tile is a canvas tile that has the correct tile frames - public static bool ValidCanvasFrame(Tile t, int frameX, int frameY, ushort canvasID) - { - return t.HasTile && t.TileType == canvasID && t.TileFrameX == frameX && t.TileFrameY == frameY; - } - } -} diff --git a/Tiles/Furniture/CalamityCanvas2024Tile.cs b/Tiles/Furniture/CalamityCanvas2024Tile.cs deleted file mode 100644 index 70df710ad1..0000000000 --- a/Tiles/Furniture/CalamityCanvas2024Tile.cs +++ /dev/null @@ -1,218 +0,0 @@ -using CalamityMod.TileEntities; -using CalamityMod.UI; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.Furniture -{ - // TODO: Probably make a base canvas painting class - public class CalamityCanvas2024Tile : ModTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileSpelunker[Type] = true; - Main.tileWaterDeath[Type] = false; - - TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); - TileObjectData.newTile.Width = 5; - TileObjectData.newTile.Height = 5; - TileObjectData.newTile.CoordinateHeights = new int[] { 18, 18, 18, 18, 18 }; - TileObjectData.newTile.UsesCustomCanPlace = true; - //TileObjectData.newTile.Origin = new Point16(2, 0); - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(ModContent.GetInstance().Hook_AfterPlacement, -1, 0, false); - TileObjectData.addTile(Type); - - TileID.Sets.DisableSmartCursor[Type] = true; - TileID.Sets.FramesOnKillWall[Type] = true; - TileID.Sets.DisableSmartCursor[Type] = true; - - AddMapEntry(new Color(99, 50, 30), Language.GetText("MapObject.Painting")); - } - public override bool HasSmartInteract(int i, int j, Terraria.GameContent.ObjectInteractions.SmartInteractScanSettings settings) => true; - - public override bool RightClick(int i, int j) - { - Main.LocalPlayer.CancelSignsAndChests(); - TECanvasPainting cube = CalamityUtils.FindTileEntity(i, j, 5, 5); - if (cube != null) - { - CanvasPaintingUIState.ResetVars(); - Main.LocalPlayer.Calamity().CurrentlyViewedCanvasID = cube.ID; - Main.LocalPlayer.Calamity().CurrentlyViewedCanvasType = 1; - SoundEngine.PlaySound(SoundID.MenuOpen); - Main.playerInventory = true; - Main.recBigList = false; - } - Recipe.FindRecipes(); - return false; - } - - public override void MouseOver(int i, int j) - { - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - Main.LocalPlayer.noThrow = 2; - Main.LocalPlayer.cursorItemIconEnabled = true; - } - - public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) - { - Tile t = Main.tile[i, j]; - int left = i - t.TileFrameX % (5 * 18) / 18; - int top = j - t.TileFrameY % (5 * 18) / 18; - - TECanvasPainting canvas = CalamityUtils.FindTileEntity(i, j, 5, 5, 18); - - canvas?.Kill(left, top); - } - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - Tile t = Main.tile[i, j]; - Texture2D texture = TextureAssets.Tile[Type].Value; - TECanvasPainting cube = CalamityUtils.FindTileEntity(i, j, 1, 1); - float baseDimension = 80; // 5 * 16 - Vector2 pos = new Vector2(i * 16, j * 16) + CalamityUtils.TileDrawOffset; - if (cube != null && t.TileFrameX == 0) - { - int fPX = (int)cube.framePosition.X; - int fPY = (int)cube.framePosition.Y; - int scale = (int)(texture.Width * 0.1f * cube.scale); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null); - // TODO: make the 0.8 in scale not a hardcoded number with seemingly no meaning - spriteBatch.Draw(texture, pos - Main.screenPosition, new Rectangle(fPX, fPY, scale, scale), Lighting.GetColor(i, j), 0, new Vector2(0, 0), 1 / cube.scale * 0.8f, 0, 0); - spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null); - } - // Calculate and draw the borders - if (t.TileFrameX == 0 && t.TileFrameY == 0) - DrawBorders(spriteBatch, pos - Main.screenPosition, new Point(i, j)); - return false; - } - public static void DrawBorders(SpriteBatch spriteBatch, Vector2 pos, Point cords) - { - Texture2D texture = CalamityCanvas2023Tile.border.Value; - Texture2D cornerTex = CalamityCanvas2023Tile.corner.Value; - ushort canvasID = (ushort)ModContent.TileType(); - int commonDim = 8; - int finalCord = 72; - int size = 80; - Color light = Lighting.GetColor(cords.X, cords.Y); - - // Check for nearby Canvas paintings - // If they are cleanly lined up with this Canvas painting, don't draw borders between them - bool drawTop = true; - bool drawLeft = true; - bool drawRight = true; - bool drawBottom = true; - // Corners - bool drawTopLeft = false; - bool drawTopRight = false; - bool drawBottomLeft = false; - bool drawBottomRight = false; - - // The bottom right tile of the canvas painting - Point bottomRight = new Point(cords.X + 4, cords.Y + 4); - - // Adjacent tiles that may or may not have other canvas paintings - Tile left = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, cords.Y); - Tile top = CalamityUtils.ParanoidTileRetrieval(cords.X, cords.Y - 1); - Tile right = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, bottomRight.Y); - Tile bottom = CalamityUtils.ParanoidTileRetrieval(bottomRight.X, bottomRight.Y + 1); - - // Check if adjacent tiles are canvas paintings that are lined up with this one - bool validTop = ValidCanvasFrame(top, 0, size, canvasID); - bool validRight = ValidCanvasFrame(right, 0, size, canvasID); - bool validLeft = ValidCanvasFrame(left, finalCord, 0, canvasID); - bool validBottom = ValidCanvasFrame(bottom, finalCord, 0, canvasID); - - if (validTop) - { - drawTop = false; - } - if (validBottom) - { - drawBottom = false; - } - if (validRight) - { - drawRight = false; - // Check for junction corners - Tile topright = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, cords.Y - 1); - Tile bottomright = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, bottomRight.Y + 1); - if (!drawTop && !ValidCanvasFrame(topright, 0, size, canvasID)) - { - drawTopRight = true; - } - if (!drawBottom && !ValidCanvasFrame(bottomright, 0, 0, canvasID)) - { - drawBottomRight = true; - } - } - if (validLeft) - { - drawLeft = false; - // Check for junction corners - Tile topleft = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, cords.Y - 1); - Tile bottomleft = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, bottomRight.Y + 1); - if (!drawTop && !ValidCanvasFrame(topleft, finalCord, size, canvasID)) - { - drawTopLeft = true; - } - if (!drawBottom && !ValidCanvasFrame(bottomleft, finalCord, 0, canvasID)) - { - drawBottomLeft = true; - } - } - - // Draw the sides - if (drawBottom) - spriteBatch.Draw(texture, pos + Vector2.UnitY * finalCord, new Rectangle(0, texture.Height - commonDim, texture.Width, commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawTop) - spriteBatch.Draw(texture, pos, new Rectangle(0, 0, texture.Width, commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawRight) - spriteBatch.Draw(texture, pos + Vector2.UnitX * finalCord, new Rectangle(texture.Width - commonDim, commonDim, commonDim, texture.Height - (2 * commonDim)), light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawLeft) - spriteBatch.Draw(texture, pos, new Rectangle(0, commonDim, commonDim, texture.Height - (2 * commonDim)), light, 0, new Vector2(0, 0), 1, 0, 0); - - // Draw the corners - // All corner drawing is done with a single corner sprite that is rotated and flipped about depending on the situation - if (drawTop && drawLeft) - spriteBatch.Draw(cornerTex, pos, null, light, 0, new Vector2(0, 0), 1, 0, 0); - if (drawTop && drawRight) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitX * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipHorizontally, 0); - if (drawBottom && drawLeft) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitY * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipVertically, 0); - if (drawBottom && drawRight) - spriteBatch.Draw(cornerTex, pos + Vector2.One * size, null, light, MathHelper.Pi, new Vector2(0, 0), 1, 0, 0); - - // Draw junction corners - if (drawTopLeft) - spriteBatch.Draw(cornerTex, pos + CalamityCanvas2023Tile.corner.Size(), null, light, MathHelper.Pi, new Vector2(0, 0), 1, 0, 0); - if (drawTopRight) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitX * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipVertically, 0); - if (drawBottomLeft) - spriteBatch.Draw(cornerTex, pos + Vector2.UnitY * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipHorizontally, 0); - if (drawBottomRight) - spriteBatch.Draw(cornerTex, pos - CalamityCanvas2023Tile.corner.Size() + Vector2.One * size, null, light, 0, new Vector2(0, 0), 1, 0, 0); - } - - // Check if the tile is a canvas tile that has the correct tile frames - public static bool ValidCanvasFrame(Tile t, int frameX, int frameY, ushort canvasID) - { - return t.HasTile && t.TileType == canvasID && t.TileFrameX == frameX && t.TileFrameY == frameY; - } - } -} diff --git a/Tiles/Furniture/ChaosCandle.cs b/Tiles/Furniture/ChaosCandle.cs index 87f73c69c3..518b0fd1da 100644 --- a/Tiles/Furniture/ChaosCandle.cs +++ b/Tiles/Furniture/ChaosCandle.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Placeables; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.Furniture { public class ChaosCandle : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() { this.SetUpCandle(ModContent.ItemType(), false, false); @@ -50,7 +53,7 @@ namespace CalamityMod.Tiles.Furniture public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) @@ -61,12 +64,13 @@ namespace CalamityMod.Tiles.Furniture public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/Furniture/ChaosCandleFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Furniture/ChaosCandleFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override bool RightClick(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); return true; } } diff --git a/Tiles/Furniture/CirrusCouch.cs b/Tiles/Furniture/CirrusCouch.cs deleted file mode 100644 index 29551f8bb3..0000000000 --- a/Tiles/Furniture/CirrusCouch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.Furniture -{ - public class CirrusCouch : ModTile - { - public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), true); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.PinkFairy); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); - - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); - - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); - - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) - { - return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); - } - } -} diff --git a/Tiles/Furniture/CirrusCouch.png b/Tiles/Furniture/CirrusCouch.png deleted file mode 100644 index 1bca32a64a..0000000000 Binary files a/Tiles/Furniture/CirrusCouch.png and /dev/null differ diff --git a/Tiles/Furniture/CirrusCouch_Highlight.png b/Tiles/Furniture/CirrusCouch_Highlight.png deleted file mode 100644 index 37368baef2..0000000000 Binary files a/Tiles/Furniture/CirrusCouch_Highlight.png and /dev/null differ diff --git a/Tiles/Furniture/CorruptionEffigy.cs b/Tiles/Furniture/CorruptionEffigy.cs index 0e66e71ea8..c900255905 100644 --- a/Tiles/Furniture/CorruptionEffigy.cs +++ b/Tiles/Furniture/CorruptionEffigy.cs @@ -6,7 +6,6 @@ using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/CraftingStations/AncientAltar.cs b/Tiles/Furniture/CraftingStations/AncientAltar.cs deleted file mode 100644 index fb2008520f..0000000000 --- a/Tiles/Furniture/CraftingStations/AncientAltar.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.Furniture.CraftingStations -{ - public class AncientAltar : ModTile - { - int animationFrame = 0; - public override void SetStaticDefaults() - { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = false; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = false; - TileObjectData.addTile(Type); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); - AnimationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.RedTorch, 0f, 0f, 1, new Color(255, 255, 255), 1f); - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 100, 100), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frameCounter++; - if (frameCounter >= 6) - { - frame = (frame + 1) % 6; - animationFrame = frame; - frameCounter = 0; - } - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 1f; - g = 0.5f; - b = 0.5f; - } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - CalamityUtils.DrawStaticFlameEffect(ModContent.Request("CalamityMod/Tiles/Furniture/CraftingStations/AncientAltarFlame").Value, i, j, offsetY: animationFrame * AnimationFrameHeight); - } - - public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) - { - Tile tile = Main.tile[i, j]; - if (tile.TileFrameX == 18 && tile.TileFrameY == 18) - { - CalamityUtils.DrawFlameSparks(60, 5, i, j); - } - } - } -} diff --git a/Tiles/Furniture/CraftingStations/AshenAltar.cs b/Tiles/Furniture/CraftingStations/AshenAltar.cs index 5f9aaf7975..b2dff25684 100644 --- a/Tiles/Furniture/CraftingStations/AshenAltar.cs +++ b/Tiles/Furniture/CraftingStations/AshenAltar.cs @@ -1,9 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -11,6 +11,8 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations { public class AshenAltar : ModTile { + public Asset FlameTexture; + int animationFrame = 0; public override void SetStaticDefaults() { @@ -58,7 +60,8 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawStaticFlameEffect(ModContent.Request("CalamityMod/Tiles/Furniture/CraftingStations/AshenAltarFlame").Value, i, j, offsetY: animationFrame * AnimationFrameHeight); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Furniture/CraftingStations/AshenAltarFlame"); + CalamityUtils.DrawStaticFlameEffect(FlameTexture.Value, i, j, offsetY: animationFrame * AnimationFrameHeight); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/Furniture/CraftingStations/BotanicPlanter.cs b/Tiles/Furniture/CraftingStations/BotanicPlanter.cs deleted file mode 100644 index 1d620f9c18..0000000000 --- a/Tiles/Furniture/CraftingStations/BotanicPlanter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using CalamityMod.Dusts.Furniture; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.Furniture.CraftingStations -{ - public class BotanicPlanter : ModTile - { - public override void SetStaticDefaults() - { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(Type); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); - AnimationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - Tile tile = Main.tile[i, j]; - //227 79 79 - if (tile.TileFrameX < 54) - { - r = 0.8f; - g = 0.9f; - b = 0.3f; - } - } - - public override void HitWire(int i, int j) - { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); - } - } -} diff --git a/Tiles/Furniture/CraftingStations/CosmicAnvil.cs b/Tiles/Furniture/CraftingStations/CosmicAnvil.cs index faa318f34e..7b0aaf8347 100644 --- a/Tiles/Furniture/CraftingStations/CosmicAnvil.cs +++ b/Tiles/Furniture/CraftingStations/CosmicAnvil.cs @@ -1,9 +1,6 @@ -using CalamityMod.Items.Placeables.Furniture.CraftingStations; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -28,7 +25,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations AddMapEntry(new Color(159, 125, 201), CalamityUtils.GetItemName()); TileID.Sets.DisableSmartCursor[Type] = true; // Visual Studio complains about this line. However, if you change it to DustID.BubbleBurst_Purple, it won't compile. - DustType = 179; + DustType = DustID.BubbleBurst_Purple; AdjTiles = new int[] { TileID.Anvils, TileID.MythrilAnvil }; } } diff --git a/Tiles/Furniture/CraftingStations/DraedonsForge.cs b/Tiles/Furniture/CraftingStations/DraedonsForge.cs index 598cf756d7..e8a5ad3984 100644 --- a/Tiles/Furniture/CraftingStations/DraedonsForge.cs +++ b/Tiles/Furniture/CraftingStations/DraedonsForge.cs @@ -2,7 +2,6 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/CraftingStations/EutrophicShelf.cs b/Tiles/Furniture/CraftingStations/EutrophicShelf.cs deleted file mode 100644 index dca632f30e..0000000000 --- a/Tiles/Furniture/CraftingStations/EutrophicShelf.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.Furniture.CraftingStations -{ - [LegacyName("EutrophicCrafting")] - public class EutrophicShelf : ModTile - { - // - // Note from Ozzatron: - // It's highly recommended you don't touch this code unless absolutely necessary. - // Even slightly changing the way that this tile initializes could re-introduce the Ancients Awakened worldgen bug. - // - public override void SetStaticDefaults() - { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.StyleMultiplier = 2; - // Remove the bottom anchor entirely, this thing hangs from the wall. - TileObjectData.newTile.AnchorBottom = AnchorData.Empty; - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 1); - - // When this Direction property set executes, newTile._tileObjectBase gets separated from Style3x3._tileObjectBase. - // As such, no data corruption occurs. - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - // Add a wall anchor on the opposite side for the alternate style, and remove the wall anchor that was on the first side. - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 1); - TileObjectData.newAlternate.AnchorRight = AnchorData.Empty; - - // This line used to corrupt TileObjectData.Style3x3.Direction to PlaceRight. This has now been fixed. - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.addTile(Type); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); - AnimationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.5f; - g = 1f; - b = 1f; - } - } -} diff --git a/Tiles/Furniture/CraftingStations/MonolithAmalgam.cs b/Tiles/Furniture/CraftingStations/MonolithAmalgam.cs deleted file mode 100644 index 8d19243ab9..0000000000 --- a/Tiles/Furniture/CraftingStations/MonolithAmalgam.cs +++ /dev/null @@ -1,43 +0,0 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.Furniture.CraftingStations -{ - [LegacyName("MonolithCrafting")] - public class MonolithAmalgam : ModTile - { - public override void SetStaticDefaults() - { - this.SetUpBookcase(ModContent.ItemType(), true, false, false); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); - return false; - } - - 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) - { - if (Main.tile[i, j].IsTileActuallyInvisible()) - return; - - int xPos = Main.tile[i, j].TileFrameX; - int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/Furniture/CraftingStations/MonolithAmalgamGlow").Value; - Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - } - } -} diff --git a/Tiles/Furniture/CraftingStations/PlagueInfuser.cs b/Tiles/Furniture/CraftingStations/PlagueInfuser.cs index 84d5afa3be..91141045e1 100644 --- a/Tiles/Furniture/CraftingStations/PlagueInfuser.cs +++ b/Tiles/Furniture/CraftingStations/PlagueInfuser.cs @@ -3,7 +3,6 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs b/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs index 98677f75b2..eda5725ade 100644 --- a/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs +++ b/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs @@ -1,9 +1,7 @@ using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -66,7 +64,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/Furniture/CraftingStations/SCalAltar.cs b/Tiles/Furniture/CraftingStations/SCalAltar.cs index 78e76fe29a..3155bbb446 100644 --- a/Tiles/Furniture/CraftingStations/SCalAltar.cs +++ b/Tiles/Furniture/CraftingStations/SCalAltar.cs @@ -1,11 +1,12 @@ using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture.CraftingStations; -using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Potions.Food; using CalamityMod.Items.SummonItems; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -13,7 +14,6 @@ using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -33,7 +33,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations // Various data sets to protect this tile from unintentional death TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; - //TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; Since this is a furniture item this may be unnecessary? + TileID.Sets.PreventsTileHammeringIfOnTopOfIt[Type] = true; TileID.Sets.PreventsSandfall[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); @@ -46,7 +46,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); - AddMapEntry(new Color(43, 19, 42), CalamityUtils.GetItemName()); + AddMapEntry(new Color(43, 19, 42), CalamityUtils.GetItemName()); TileID.Sets.DisableSmartCursor[Type] = true; // This cannot be placed and only exists for backwards compatibility, so item has to be returned to the player manually if broken. @@ -63,43 +63,57 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations } public override bool RightClick(int i, int j) => AttemptToSummonSCal(i, j); - public override void MouseOver(int i, int j) => HoverItemIcon(); - public override void MouseOverFar(int i, int j) => HoverItemIcon(); - - public static void HoverItemIcon() + public override void MouseOver(int i, int j) => HoverItemIcon(i, j); + public override void MouseOverFar(int i, int j) => HoverItemIcon(i, j); + public override void KillMultiTile(int i, int j, int frameX, int frameY) { - bool vodka = Main.LocalPlayer.HeldItem.type == ModContent.ItemType() && Main.zenithWorld; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType()) + { + p.Kill(); + break; + } + } + } + + public static void HoverItemIcon(int i, int j) + { + bool vodka = Main.LocalPlayer.HeldItem.type == ModContent.ItemType() && Main.zenithWorld; if (vodka) - { - Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - } + Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); else if (Main.LocalPlayer.HasItem(ModContent.ItemType())) - { Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - } else - { Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); - } Main.LocalPlayer.noThrow = 2; Main.LocalPlayer.cursorItemIconEnabled = true; + + // Checks if the player has the Ruler lines or Ruler grid toggled + if (Main.LocalPlayer.builderAccStatus[0] == 0 || (Main.LocalPlayer.builderAccStatus[1] == 0 && Main.LocalPlayer.rulerGrid)) + { + // Don't spawn the arena visual if one already exists or if SCal is alive or spawning + if (CalamityUtils.AnyProjectiles(ModContent.ProjectileType()) || + CalamityUtils.AnyProjectiles(ModContent.ProjectileType()) || + NPC.AnyNPCs(ModContent.NPCType())) + return; + + Tile t = Main.tile[i, j]; + Vector2 arenaCenter = new Vector2(i - t.TileFrameX / 18 + Width / 2, j - t.TileFrameY / 18).ToWorldCoordinates() - Vector2.UnitY * 24f; + Projectile.NewProjectile(new EntitySource_WorldEvent(), arenaCenter, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, CalamityWorld.death.ToInt()); + } } public static bool AttemptToSummonSCal(int i, int j) { - Tile tile = Main.tile[i, j]; - - int left = i - tile.TileFrameX / 18; - int top = j - tile.TileFrameY / 18; - if (!Main.LocalPlayer.HasItem(ModContent.ItemType()) && - !Main.LocalPlayer.HasItem(ModContent.ItemType()) && !(Main.LocalPlayer.HeldItem.type == ModContent.ItemType() && Main.zenithWorld)) + !Main.LocalPlayer.HasItem(ModContent.ItemType()) && !(Main.LocalPlayer.HeldItem.type == ModContent.ItemType() && Main.zenithWorld)) { return true; } - bool vodka = Main.LocalPlayer.HeldItem.type == ModContent.ItemType() && Main.zenithWorld; + bool meat = Main.LocalPlayer.HeldItem.type == ModContent.ItemType() && Main.zenithWorld; if (NPC.AnyNPCs(ModContent.NPCType()) || BossRushEvent.BossRushActive) return true; @@ -109,21 +123,22 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations bool usingSpecialItem = Main.LocalPlayer.HasItem(ModContent.ItemType()); + Tile tile = Main.tile[i, j]; + int left = i - tile.TileFrameX / 18; + int top = j - tile.TileFrameY / 18; Vector2 ritualSpawnPosition = new Vector2(left + Width / 2, top).ToWorldCoordinates(); ritualSpawnPosition += new Vector2(0f, -24f); SoundEngine.PlaySound(SummonSound, ritualSpawnPosition); - Projectile.NewProjectile(new EntitySource_WorldEvent(), ritualSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0, vodka.ToInt()); + Projectile.NewProjectile(new EntitySource_WorldEvent(), ritualSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0, meat.ToInt()); - if (vodka) + if (meat) { - Main.LocalPlayer.ConsumeItem(ModContent.ItemType(), true); - for (int f = 0; f < Main.maxNPCs; f++) + Main.LocalPlayer.ConsumeItem(ModContent.ItemType(), true); + foreach (NPC n in Main.ActiveNPCs) { - if (Main.npc[f].type == ModContent.NPCType() && Main.npc[f].active) - { - Main.npc[f].active = false; - } + if (n.type == ModContent.NPCType()) + n.active = false; } } else if (!usingSpecialItem) @@ -146,7 +161,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations // Various data sets to protect this tile from unintentional death TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; - //TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; Since this is a furniture item this may be unnecessary? + TileID.Sets.PreventsTileHammeringIfOnTopOfIt[Type] = true; TileID.Sets.PreventsSandfall[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); @@ -159,7 +174,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); - AddMapEntry(new Color(43, 19, 42), CalamityUtils.GetItemName()); + AddMapEntry(new Color(43, 19, 42), CalamityUtils.GetItemName()); TileID.Sets.DisableSmartCursor[Type] = true; AdjTiles = new int[] { ModContent.TileType() }; } @@ -174,7 +189,18 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations } public override bool RightClick(int i, int j) => SCalAltar.AttemptToSummonSCal(i, j); - public override void MouseOver(int i, int j) => SCalAltar.HoverItemIcon(); - public override void MouseOverFar(int i, int j) => SCalAltar.HoverItemIcon(); + public override void MouseOver(int i, int j) => SCalAltar.HoverItemIcon(i, j); + public override void MouseOverFar(int i, int j) => SCalAltar.HoverItemIcon(i, j); + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType()) + { + p.Kill(); + break; + } + } + } } } diff --git a/Tiles/Furniture/CraftingStations/SilvaBasin.cs b/Tiles/Furniture/CraftingStations/SilvaBasin.cs deleted file mode 100644 index a056b5aed6..0000000000 --- a/Tiles/Furniture/CraftingStations/SilvaBasin.cs +++ /dev/null @@ -1,67 +0,0 @@ -using CalamityMod.Dusts.Furniture; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.Furniture.CraftingStations -{ - public class SilvaBasin : ModTile - { - public override void SetStaticDefaults() - { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(Type); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); - AnimationFrameHeight = 54; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.ChlorophyteWeapon, 0f, 0f, 1, new Color(255, 255, 255), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frameCounter++; - if (frameCounter >= 6) - { - frame = (frame + 1) % 10; - frameCounter = 0; - } - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - Tile tile = Main.tile[i, j]; - //227 79 79 - if (tile.TileFrameX < 54) - { - r = 0.6f; - g = 1f; - b = 0.8f; - } - } - - public override void HitWire(int i, int j) - { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); - } - } -} diff --git a/Tiles/Furniture/CraftingStations/StaticRefiner.cs b/Tiles/Furniture/CraftingStations/StaticRefiner.cs deleted file mode 100644 index 092060fb68..0000000000 --- a/Tiles/Furniture/CraftingStations/StaticRefiner.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.Furniture.CraftingStations -{ - public class StaticRefiner : ModTile - { - public override void SetStaticDefaults() - { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileLavaDeath[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.addTile(Type); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); - AnimationFrameHeight = 54; - //also counts as a Solidifier - AdjTiles = new int[] { TileID.Solidifier }; - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.PinkSlime, 0f, 0f, 1, new Color(255, 255, 255), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void AnimateTile(ref int frame, ref int frameCounter) - { - frameCounter++; - if (frameCounter >= 6) - { - frame = (frame + 1) % 10; - frameCounter = 0; - } - } - } -} diff --git a/Tiles/Furniture/CraftingStations/VoidCondenser.cs b/Tiles/Furniture/CraftingStations/VoidCondenser.cs index 9f18321f49..c8aa72a7eb 100644 --- a/Tiles/Furniture/CraftingStations/VoidCondenser.cs +++ b/Tiles/Furniture/CraftingStations/VoidCondenser.cs @@ -1,8 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/CrimsonEffigy.cs b/Tiles/Furniture/CrimsonEffigy.cs index ba57c2a318..b462e4769b 100644 --- a/Tiles/Furniture/CrimsonEffigy.cs +++ b/Tiles/Furniture/CrimsonEffigy.cs @@ -6,7 +6,6 @@ using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/DevPaintings/ThankYouPaintingTile.png b/Tiles/Furniture/DevPaintings/ThankYouPaintingTile.png deleted file mode 100644 index 434b490237..0000000000 Binary files a/Tiles/Furniture/DevPaintings/ThankYouPaintingTile.png and /dev/null differ diff --git a/Tiles/Furniture/EffigyOfDecayPlaceable.cs b/Tiles/Furniture/EffigyOfDecayPlaceable.cs index e8f70ad6d6..6627103609 100644 --- a/Tiles/Furniture/EffigyOfDecayPlaceable.cs +++ b/Tiles/Furniture/EffigyOfDecayPlaceable.cs @@ -4,7 +4,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Fountains/AbyssFountainTile.cs b/Tiles/Furniture/Fountains/AbyssFountainTile.cs index 9bdc67d1b1..1467ee01d5 100644 --- a/Tiles/Furniture/Fountains/AbyssFountainTile.cs +++ b/Tiles/Furniture/Fountains/AbyssFountainTile.cs @@ -45,12 +45,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); } public override bool RightClick(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16)); return true; } diff --git a/Tiles/Furniture/Fountains/AstralFountainTile.cs b/Tiles/Furniture/Fountains/AstralFountainTile.cs index b21b19bd74..f71ee899e1 100644 --- a/Tiles/Furniture/Fountains/AstralFountainTile.cs +++ b/Tiles/Furniture/Fountains/AstralFountainTile.cs @@ -46,12 +46,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); } public override bool RightClick(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16)); return true; } diff --git a/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs b/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs index 6222f06535..d282831cc1 100644 --- a/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs +++ b/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs @@ -48,12 +48,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); } public override bool RightClick(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16)); return true; } diff --git a/Tiles/Furniture/Fountains/SulphurousFountainTile.cs b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs index 6b52380f3d..fee27f16d2 100644 --- a/Tiles/Furniture/Fountains/SulphurousFountainTile.cs +++ b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs @@ -46,12 +46,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); } public override bool RightClick(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16)); return true; } diff --git a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs index 52a33930ad..5f6def4b6b 100644 --- a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs +++ b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs @@ -45,12 +45,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); } public override bool RightClick(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 4); + FurnitureCommon.LightHitWire(Type, i, j, 2, 4); SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16)); return true; } diff --git a/Tiles/Furniture/LanternCenterTile.cs b/Tiles/Furniture/LanternCenterTile.cs index 6744a2c100..194d2a3bb7 100644 --- a/Tiles/Furniture/LanternCenterTile.cs +++ b/Tiles/Furniture/LanternCenterTile.cs @@ -3,11 +3,9 @@ using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.GameContent.Events; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -55,11 +53,6 @@ namespace CalamityMod.Tiles.Furniture } } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - LanternNight.ManualLanterns = false; - } - public override void HitWire(int i, int j) { LanternNight.ToggleManualLanterns(); diff --git a/Tiles/Furniture/Monoliths/AstralProjectorTile.cs b/Tiles/Furniture/Monoliths/AstralProjectorTile.cs index 615418cf09..daf346d24e 100644 --- a/Tiles/Furniture/Monoliths/AstralProjectorTile.cs +++ b/Tiles/Furniture/Monoliths/AstralProjectorTile.cs @@ -1,16 +1,11 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/BlueDistortedMonolithTile.cs b/Tiles/Furniture/Monoliths/BlueDistortedMonolithTile.cs index 59867c9e93..d510043bda 100644 --- a/Tiles/Furniture/Monoliths/BlueDistortedMonolithTile.cs +++ b/Tiles/Furniture/Monoliths/BlueDistortedMonolithTile.cs @@ -1,15 +1,10 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs b/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs index 454c6e9f08..0bb3c1281f 100644 --- a/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs +++ b/Tiles/Furniture/Monoliths/BossRushMonolithTile.cs @@ -1,16 +1,11 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/DeepSeaAnchorTile.cs b/Tiles/Furniture/Monoliths/DeepSeaAnchorTile.cs index 33fbf4e1de..f14a32981d 100644 --- a/Tiles/Furniture/Monoliths/DeepSeaAnchorTile.cs +++ b/Tiles/Furniture/Monoliths/DeepSeaAnchorTile.cs @@ -1,15 +1,9 @@ -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; +using CalamityMod.Items.Placeables.Furniture.Monoliths; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs b/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs index 47aa4fbb37..b84ee70c6e 100644 --- a/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs +++ b/Tiles/Furniture/Monoliths/DraconicIncenseTile.cs @@ -2,13 +2,9 @@ using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/ExoObeliskTile.cs b/Tiles/Furniture/Monoliths/ExoObeliskTile.cs index 8ff1638a78..d9994ad817 100644 --- a/Tiles/Furniture/Monoliths/ExoObeliskTile.cs +++ b/Tiles/Furniture/Monoliths/ExoObeliskTile.cs @@ -1,19 +1,11 @@ -using CalamityMod.Buffs.Potions; -using CalamityMod.Dusts; -using CalamityMod.Items.Dyes; -using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; +using CalamityMod.Items.Placeables.Furniture.Monoliths; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/FrigidMonolithTile.cs b/Tiles/Furniture/Monoliths/FrigidMonolithTile.cs index 920b32002c..ae7f3b9af0 100644 --- a/Tiles/Furniture/Monoliths/FrigidMonolithTile.cs +++ b/Tiles/Furniture/Monoliths/FrigidMonolithTile.cs @@ -1,15 +1,9 @@ -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; +using CalamityMod.Items.Placeables.Furniture.Monoliths; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/OldDukeMonolithTile.cs b/Tiles/Furniture/Monoliths/OldDukeMonolithTile.cs new file mode 100644 index 0000000000..9ca6163623 --- /dev/null +++ b/Tiles/Furniture/Monoliths/OldDukeMonolithTile.cs @@ -0,0 +1,64 @@ +using CalamityMod.ForegroundDrawing.LoopingTextures; +using CalamityMod.Items.Placeables.Furniture.Monoliths; +using CalamityMod.Tiles.BaseTiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Furniture.Monoliths +{ + public class OldDukeMonolithTile : BaseMonolith + { + public override int TileWidth => 4; + public override int TileHeight => 8; + public override int AnimationFrameCount => 24; + public override int AnimationDelay => 6; + public override int CursorItemType => ModContent.ItemType(); + + public static Asset Numbers; + public override void SetStaticDefaults() + { + if (!Main.dedServ) + { + GlowMask = ModContent.Request($"{Texture}_Glow"); + //Numbers = ModContent.Request("CalamityMod/Tiles/Furniture/Monoliths/ExoObeliskText", AssetRequestMode.AsyncLoad); + } + + RegisterItemDrop(CursorItemType); + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 8; + Main.tileFrameImportant[Type] = true; + TileID.Sets.HasOutlines[Type] = true; + TileObjectData.newTile.Origin = new Point16(1, 4); + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 3, 0); + + AnimationFrameHeight = 8 * 18; + TileObjectData.newTile.CoordinateHeights = [16, 16, 16, 16, 16, 16, 16, 16]; + TileObjectData.addTile(Type); + + AddMapEntry(new Color(54, 54, 54)); + + DustType = DustID.TerraBlade; + } + + public override void NearbyEffects(int i, int j, bool closer, bool monolithEnabled, Player localPlayer) + { + if (!monolithEnabled) + return; + + if (localPlayer is not null && localPlayer.active) + { + localPlayer.GetModPlayer().ShouldDisplayTorrentMonolith = true; + } + } + } +} diff --git a/Tiles/Furniture/Monoliths/OldDukeMonolithTile.png b/Tiles/Furniture/Monoliths/OldDukeMonolithTile.png new file mode 100644 index 0000000000..83f5ef659a Binary files /dev/null and b/Tiles/Furniture/Monoliths/OldDukeMonolithTile.png differ diff --git a/Tiles/Furniture/Monoliths/OldDukeMonolithTile_Glow.png b/Tiles/Furniture/Monoliths/OldDukeMonolithTile_Glow.png new file mode 100644 index 0000000000..790669b2bf Binary files /dev/null and b/Tiles/Furniture/Monoliths/OldDukeMonolithTile_Glow.png differ diff --git a/Tiles/Furniture/Monoliths/OldDukeMonolithTile_Highlight.png b/Tiles/Furniture/Monoliths/OldDukeMonolithTile_Highlight.png new file mode 100644 index 0000000000..f1dd43be8f Binary files /dev/null and b/Tiles/Furniture/Monoliths/OldDukeMonolithTile_Highlight.png differ diff --git a/Tiles/Furniture/Monoliths/PlagueHumidifierTile.cs b/Tiles/Furniture/Monoliths/PlagueHumidifierTile.cs index a0b8b05d2a..9b8a058c1b 100644 --- a/Tiles/Furniture/Monoliths/PlagueHumidifierTile.cs +++ b/Tiles/Furniture/Monoliths/PlagueHumidifierTile.cs @@ -1,16 +1,11 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; using CalamityMod.Particles; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/Monoliths/PurpleDistortedMonolithTile.cs b/Tiles/Furniture/Monoliths/PurpleDistortedMonolithTile.cs index cfa45373d3..0c4bfc8f76 100644 --- a/Tiles/Furniture/Monoliths/PurpleDistortedMonolithTile.cs +++ b/Tiles/Furniture/Monoliths/PurpleDistortedMonolithTile.cs @@ -1,15 +1,10 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Furniture.Monoliths; -using CalamityMod.NPCs.Yharon; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/OtonilouStatueTile.cs b/Tiles/Furniture/OtonilouStatueTile.cs index 2be6627a1f..2505c01af3 100644 --- a/Tiles/Furniture/OtonilouStatueTile.cs +++ b/Tiles/Furniture/OtonilouStatueTile.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Items.Placeables.Furniture; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; diff --git a/Tiles/Furniture/Paintings/AmidiasPaintingTile.cs b/Tiles/Furniture/Paintings/AmidiasPaintingTile.cs new file mode 100644 index 0000000000..cd203d22fe --- /dev/null +++ b/Tiles/Furniture/Paintings/AmidiasPaintingTile.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Furniture.Paintings +{ + public class AmidiasPaintingTile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileSpelunker[Type] = true; + Main.tileWaterDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); + TileObjectData.newTile.Width = 6; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(2, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.addTile(Type); + + TileID.Sets.DisableSmartCursor[Type] = true; + TileID.Sets.FramesOnKillWall[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + DustType = DustID.WoodFurniture; + AddMapEntry(new Color(99, 50, 30), Language.GetText("MapObject.Painting")); + } + } +} diff --git a/Tiles/Furniture/Paintings/AmidiasPaintingTile.png b/Tiles/Furniture/Paintings/AmidiasPaintingTile.png new file mode 100644 index 0000000000..b2f4c1b913 Binary files /dev/null and b/Tiles/Furniture/Paintings/AmidiasPaintingTile.png differ diff --git a/Tiles/Furniture/Paintings/BaseCanvasPainting.cs b/Tiles/Furniture/Paintings/BaseCanvasPainting.cs new file mode 100644 index 0000000000..49fcd0d128 --- /dev/null +++ b/Tiles/Furniture/Paintings/BaseCanvasPainting.cs @@ -0,0 +1,228 @@ +using CalamityMod.TileEntities; +using CalamityMod.UI; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Furniture.Paintings +{ + public abstract class BaseCanvasPainting : ModTile + { + // TODO: make this not a hardcoded number with seemingly no meaning + public virtual float Scale => 0.4f; + + public static Asset border; + public static Asset corner; + + public override void Load() + { + border = ModContent.Request("CalamityMod/Tiles/Furniture/Paintings/CalamityCanvasBorder"); + corner = ModContent.Request("CalamityMod/Tiles/Furniture/Paintings/CalamityCanvasCorner"); + } + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileSpelunker[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); + TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.Width = 5; + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.CoordinateHeights = new int[] { 18, 18, 18, 18, 18 }; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(ModContent.GetInstance().Hook_AfterPlacement, -1, 0, false); + TileObjectData.addTile(Type); + + TileID.Sets.DisableSmartCursor[Type] = true; + TileID.Sets.FramesOnKillWall[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + + AddMapEntry(new Color(99, 50, 30), Language.GetText("MapObject.Painting")); + } + public override bool HasSmartInteract(int i, int j, Terraria.GameContent.ObjectInteractions.SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) + { + Main.LocalPlayer.CancelSignsAndChests(); + var cube = CalamityUtils.FindTileEntity(i, j, 5, 5); + if (cube != null) + { + CanvasPaintingUIState.ResetVars(); + Main.LocalPlayer.Calamity().CurrentlyViewedCanvasID = cube.ID; + Main.LocalPlayer.Calamity().CurrentlyViewedCanvasType = Type; + SoundEngine.PlaySound(SoundID.MenuOpen); + Main.playerInventory = true; + Main.recBigList = false; + } + Recipe.FindRecipes(); + return false; + } + + public override void MouseOver(int i, int j) + { + // The sprites for all Canvas Paintings are the same + Main.LocalPlayer.cursorItemIconID = ModContent.ItemType(); + Main.LocalPlayer.noThrow = 2; + Main.LocalPlayer.cursorItemIconEnabled = true; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + var t = Main.tile[i, j]; + var left = i - t.TileFrameX % (5 * 18) / 18; + var top = j - t.TileFrameY % (5 * 18) / 18; + + var canvas = CalamityUtils.FindTileEntity(i, j, 5, 5, 18); + + canvas?.Kill(left, top); + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + var t = Main.tile[i, j]; + var texture = TextureAssets.Tile[Type].Value; + var cube = CalamityUtils.FindTileEntity(i, j, 1, 1); + + var pos = new Vector2(i * 16, j * 16) + CalamityUtils.TileDrawOffset; + if (cube != null && t.TileFrameX == 0) + { + var fPX = (int)cube.framePosition.X; + var fPY = (int)cube.framePosition.Y; + var scale = (int)(texture.Width * 0.1f * cube.scale); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null); + spriteBatch.Draw(texture, pos - Main.screenPosition, new Rectangle(fPX, fPY, scale, scale), Lighting.GetColor(i, j), 0, new Vector2(0, 0), 1 / cube.scale * Scale, 0, 0); + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null); + } + // Calculate and draw the borders + if (t.TileFrameX == 0 && t.TileFrameY == 0) + DrawBorders(spriteBatch, pos - Main.screenPosition, new Point(i, j)); + return false; + } + public static void DrawBorders(SpriteBatch spriteBatch, Vector2 pos, Point cords) + { + var texture = border.Value; + var cornerTex = corner.Value; + var canvasID = (ushort)Main.LocalPlayer.Calamity().CurrentlyViewedCanvasType; + var commonDim = 8; + var finalCord = 72; + var size = 80; + var light = Lighting.GetColor(cords.X, cords.Y); + + // Check for nearby Canvas paintings + // If they are cleanly lined up with this Canvas painting, don't draw borders between them + var drawTop = true; + var drawLeft = true; + var drawRight = true; + var drawBottom = true; + // Corners + var drawTopLeft = false; + var drawTopRight = false; + var drawBottomLeft = false; + var drawBottomRight = false; + + // The bottom right tile of the canvas painting + var bottomRight = new Point(cords.X + 4, cords.Y + 4); + + // Adjacent tiles that may or may not have other canvas paintings + var left = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, cords.Y); + var top = CalamityUtils.ParanoidTileRetrieval(cords.X, cords.Y - 1); + var right = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, bottomRight.Y); + var bottom = CalamityUtils.ParanoidTileRetrieval(bottomRight.X, bottomRight.Y + 1); + + // Check if adjacent tiles are canvas paintings that are lined up with this one + var validTop = ValidCanvasFrame(top, 0, size, canvasID); + var validRight = ValidCanvasFrame(right, 0, size, canvasID); + var validLeft = ValidCanvasFrame(left, finalCord, 0, canvasID); + var validBottom = ValidCanvasFrame(bottom, finalCord, 0, canvasID); + + if (validTop) + { + drawTop = false; + } + if (validBottom) + { + drawBottom = false; + } + if (validRight) + { + drawRight = false; + // Check for junction corners + var topright = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, cords.Y - 1); + var bottomright = CalamityUtils.ParanoidTileRetrieval(bottomRight.X + 1, bottomRight.Y + 1); + if (!drawTop && !ValidCanvasFrame(topright, 0, size, canvasID)) + { + drawTopRight = true; + } + if (!drawBottom && !ValidCanvasFrame(bottomright, 0, 0, canvasID)) + { + drawBottomRight = true; + } + } + if (validLeft) + { + drawLeft = false; + // Check for junction corners + var topleft = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, cords.Y - 1); + var bottomleft = CalamityUtils.ParanoidTileRetrieval(cords.X - 1, bottomRight.Y + 1); + if (!drawTop && !ValidCanvasFrame(topleft, finalCord, size, canvasID)) + { + drawTopLeft = true; + } + if (!drawBottom && !ValidCanvasFrame(bottomleft, finalCord, 0, canvasID)) + { + drawBottomLeft = true; + } + } + + // Draw the sides + if (drawBottom) + spriteBatch.Draw(texture, pos + Vector2.UnitY * finalCord, new Rectangle(0, texture.Height - commonDim, texture.Width, commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); + if (drawTop) + spriteBatch.Draw(texture, pos, new Rectangle(0, 0, texture.Width, commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); + if (drawRight) + spriteBatch.Draw(texture, pos + Vector2.UnitX * finalCord, new Rectangle(texture.Width - commonDim, commonDim, commonDim, texture.Height - 2 * commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); + if (drawLeft) + spriteBatch.Draw(texture, pos, new Rectangle(0, commonDim, commonDim, texture.Height - 2 * commonDim), light, 0, new Vector2(0, 0), 1, 0, 0); + + // Draw the corners + // All corner drawing is done with a single corner sprite that is rotated and flipped about depending on the situation + if (drawTop && drawLeft) + spriteBatch.Draw(cornerTex, pos, null, light, 0, new Vector2(0, 0), 1, 0, 0); + if (drawTop && drawRight) + spriteBatch.Draw(cornerTex, pos + Vector2.UnitX * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipHorizontally, 0); + if (drawBottom && drawLeft) + spriteBatch.Draw(cornerTex, pos + Vector2.UnitY * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipVertically, 0); + if (drawBottom && drawRight) + spriteBatch.Draw(cornerTex, pos + Vector2.One * size, null, light, MathHelper.Pi, new Vector2(0, 0), 1, 0, 0); + + // Draw junction corners + if (drawTopLeft) + spriteBatch.Draw(cornerTex, pos + corner.Size(), null, light, MathHelper.Pi, new Vector2(0, 0), 1, 0, 0); + if (drawTopRight) + spriteBatch.Draw(cornerTex, pos + Vector2.UnitX * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipVertically, 0); + if (drawBottomLeft) + spriteBatch.Draw(cornerTex, pos + Vector2.UnitY * finalCord, null, light, 0, new Vector2(0, 0), 1, SpriteEffects.FlipHorizontally, 0); + if (drawBottomRight) + spriteBatch.Draw(cornerTex, pos - corner.Size() + Vector2.One * size, null, light, 0, new Vector2(0, 0), 1, 0, 0); + } + + // Check if the tile is a canvas tile that has the correct tile frames + public static bool ValidCanvasFrame(Tile t, int frameX, int frameY, ushort canvasID) + { + return t.HasTile && t.TileType == canvasID && t.TileFrameX == frameX && t.TileFrameY == frameY; + } + } +} diff --git a/Tiles/Furniture/Paintings/CalamityCanvas2023Tile.cs b/Tiles/Furniture/Paintings/CalamityCanvas2023Tile.cs new file mode 100644 index 0000000000..b0b3419dc1 --- /dev/null +++ b/Tiles/Furniture/Paintings/CalamityCanvas2023Tile.cs @@ -0,0 +1,6 @@ +namespace CalamityMod.Tiles.Furniture.Paintings +{ + public class CalamityCanvas2023Tile : BaseCanvasPainting + { + } +} diff --git a/Tiles/Furniture/CalamityCanvas2023Tile.png b/Tiles/Furniture/Paintings/CalamityCanvas2023Tile.png similarity index 100% rename from Tiles/Furniture/CalamityCanvas2023Tile.png rename to Tiles/Furniture/Paintings/CalamityCanvas2023Tile.png diff --git a/Tiles/Furniture/Paintings/CalamityCanvas2024Tile.cs b/Tiles/Furniture/Paintings/CalamityCanvas2024Tile.cs new file mode 100644 index 0000000000..26fc553f78 --- /dev/null +++ b/Tiles/Furniture/Paintings/CalamityCanvas2024Tile.cs @@ -0,0 +1,7 @@ +namespace CalamityMod.Tiles.Furniture.Paintings +{ + public class CalamityCanvas2024Tile : BaseCanvasPainting + { + public override float Scale => 0.8f; + } +} diff --git a/Tiles/Furniture/CalamityCanvas2024Tile.png b/Tiles/Furniture/Paintings/CalamityCanvas2024Tile.png similarity index 100% rename from Tiles/Furniture/CalamityCanvas2024Tile.png rename to Tiles/Furniture/Paintings/CalamityCanvas2024Tile.png diff --git a/Tiles/Furniture/CalamityCanvasBorder.png b/Tiles/Furniture/Paintings/CalamityCanvasBorder.png similarity index 100% rename from Tiles/Furniture/CalamityCanvasBorder.png rename to Tiles/Furniture/Paintings/CalamityCanvasBorder.png diff --git a/Tiles/Furniture/CalamityCanvasCorner.png b/Tiles/Furniture/Paintings/CalamityCanvasCorner.png similarity index 100% rename from Tiles/Furniture/CalamityCanvasCorner.png rename to Tiles/Furniture/Paintings/CalamityCanvasCorner.png diff --git a/Tiles/Furniture/Paintings/ForgivenessPaintingTile.cs b/Tiles/Furniture/Paintings/ForgivenessPaintingTile.cs new file mode 100644 index 0000000000..d19fa17fb2 --- /dev/null +++ b/Tiles/Furniture/Paintings/ForgivenessPaintingTile.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Furniture.Paintings +{ + public class ForgivenessPaintingTile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileSpelunker[Type] = true; + Main.tileWaterDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(2, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.addTile(Type); + + TileID.Sets.DisableSmartCursor[Type] = true; + TileID.Sets.FramesOnKillWall[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + DustType = DustID.WoodFurniture; + AddMapEntry(new Color(99, 50, 30), Language.GetText("MapObject.Painting")); + } + } +} diff --git a/Tiles/Furniture/Paintings/ForgivenessPaintingTile.png b/Tiles/Furniture/Paintings/ForgivenessPaintingTile.png new file mode 100644 index 0000000000..b4bee1eaa7 Binary files /dev/null and b/Tiles/Furniture/Paintings/ForgivenessPaintingTile.png differ diff --git a/Tiles/Furniture/DevPaintings/ThankYouPaintingTile.cs b/Tiles/Furniture/Paintings/ThankYouPaintingTile.cs similarity index 86% rename from Tiles/Furniture/DevPaintings/ThankYouPaintingTile.cs rename to Tiles/Furniture/Paintings/ThankYouPaintingTile.cs index 16d09fae61..fb7373b725 100644 --- a/Tiles/Furniture/DevPaintings/ThankYouPaintingTile.cs +++ b/Tiles/Furniture/Paintings/ThankYouPaintingTile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Furniture.DevPaintings; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -7,7 +6,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.Furniture.DevPaintings +namespace CalamityMod.Tiles.Furniture.Paintings { public class ThankYouPaintingTile : ModTile { @@ -28,7 +27,7 @@ namespace CalamityMod.Tiles.Furniture.DevPaintings TileID.Sets.DisableSmartCursor[Type] = true; TileID.Sets.FramesOnKillWall[Type] = true; TileID.Sets.DisableSmartCursor[Type] = true; - DustType = 7; + DustType = DustID.WoodFurniture; AddMapEntry(new Color(99, 50, 30), Language.GetText("MapObject.Painting")); } } diff --git a/Tiles/Furniture/Paintings/ThankYouPaintingTile.png b/Tiles/Furniture/Paintings/ThankYouPaintingTile.png new file mode 100644 index 0000000000..d1706759fe Binary files /dev/null and b/Tiles/Furniture/Paintings/ThankYouPaintingTile.png differ diff --git a/Tiles/Furniture/PiggyCageTile.cs b/Tiles/Furniture/PiggyCageTile.cs index 3bb7fd1f87..8eba891699 100644 --- a/Tiles/Furniture/PiggyCageTile.cs +++ b/Tiles/Furniture/PiggyCageTile.cs @@ -2,10 +2,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/PinkCandle.cs b/Tiles/Furniture/PinkCandle.cs index 3ffb8dbfab..f2b8f483c8 100644 --- a/Tiles/Furniture/PinkCandle.cs +++ b/Tiles/Furniture/PinkCandle.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.Furniture { public class PinkCandle : ModTile { - // TODO -- Unique sounds for each Cirrus Candle. + // TODO -- Unique sounds for each Candle. public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); public override void SetStaticDefaults() @@ -36,13 +36,13 @@ namespace CalamityMod.Tiles.Furniture Player p = Main.LocalPlayer; // Forcibly remove all candle buffs. - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); // 108000 is the duration used by Ammo Box. - p.AddBuff(ModContent.BuffType(), 108000); + p.AddBuff(ModContent.BuffType(), 108000); // Play a sound. SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); diff --git a/Tiles/Furniture/PurpleCandle.cs b/Tiles/Furniture/PurpleCandle.cs index 31d1864cf7..dd2a5e9886 100644 --- a/Tiles/Furniture/PurpleCandle.cs +++ b/Tiles/Furniture/PurpleCandle.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.Furniture { public class PurpleCandle : ModTile { - // TODO -- Unique sounds for each Cirrus Candle. + // TODO -- Unique sounds for each Candle. public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); public override void SetStaticDefaults() @@ -36,13 +36,13 @@ namespace CalamityMod.Tiles.Furniture Player p = Main.LocalPlayer; // Forcibly remove all candle buffs. - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); // 108000 is the duration used by Ammo Box. - p.AddBuff(ModContent.BuffType(), 108000); + p.AddBuff(ModContent.BuffType(), 108000); // Play a sound. SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); diff --git a/Tiles/Furniture/RepairUnitCageTile.cs b/Tiles/Furniture/RepairUnitCageTile.cs index 7f7a6c2d3f..703117c285 100644 --- a/Tiles/Furniture/RepairUnitCageTile.cs +++ b/Tiles/Furniture/RepairUnitCageTile.cs @@ -1,14 +1,10 @@ -using CalamityMod.Buffs.Potions; -using CalamityMod.Items.Placeables.Furniture; -using Microsoft.Build.Tasks.Deployment.ManifestUtilities; +using CalamityMod.Items.Placeables.Furniture; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/SeaMinnowJarTile.cs b/Tiles/Furniture/SeaMinnowJarTile.cs index 6d8ae9201b..debb408998 100644 --- a/Tiles/Furniture/SeaMinnowJarTile.cs +++ b/Tiles/Furniture/SeaMinnowJarTile.cs @@ -1,9 +1,7 @@ using CalamityMod.Items.Placeables.Furniture; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Furniture/ThaumaticChairTile.cs b/Tiles/Furniture/ThaumaticChairTile.cs index 859e31f8bf..3ef7caa652 100644 --- a/Tiles/Furniture/ThaumaticChairTile.cs +++ b/Tiles/Furniture/ThaumaticChairTile.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.Furniture num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/Furniture/TranquilityCandle.cs b/Tiles/Furniture/TranquilityCandle.cs index ea081f8909..6854f6f549 100644 --- a/Tiles/Furniture/TranquilityCandle.cs +++ b/Tiles/Furniture/TranquilityCandle.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Placeables; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.Furniture { public class TranquilityCandle : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() { this.SetUpCandle(ModContent.ItemType(), false, false); @@ -50,7 +53,7 @@ namespace CalamityMod.Tiles.Furniture public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) @@ -61,12 +64,13 @@ namespace CalamityMod.Tiles.Furniture public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/Furniture/TranquilityCandleFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/Furniture/TranquilityCandleFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override bool RightClick(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); return true; } } diff --git a/Tiles/Furniture/WulfrumLure.cs b/Tiles/Furniture/WulfrumLure.cs index 4b3d07d82d..40a9afe306 100644 --- a/Tiles/Furniture/WulfrumLure.cs +++ b/Tiles/Furniture/WulfrumLure.cs @@ -1,12 +1,7 @@ using System.Linq; -using CalamityMod.Dusts; -using CalamityMod.Events; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Items.SummonItems; using CalamityMod.Items.Tools; -using CalamityMod.NPCs.AstrumDeus; -using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -15,7 +10,6 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -38,7 +32,7 @@ namespace CalamityMod.Tiles.Furniture AddMapEntry(new Color(194, 255, 67), CalamityUtils.GetItemName()); TileID.Sets.DisableSmartCursor[Type] = true; - DustType = 83; + DustType = DustID.Tungsten; } public override bool RightClick(int i, int j) @@ -98,12 +92,10 @@ namespace CalamityMod.Tiles.Furniture return; } - if (CogTexture == null) - CogTexture = ModContent.Request("CalamityMod/Tiles/Furniture/WulfrumLureCog"); + CogTexture ??= ModContent.Request("CalamityMod/Tiles/Furniture/WulfrumLureCog"); Texture2D cogTexture = CogTexture.Value; - if (CoverTexture == null) - CoverTexture = ModContent.Request("CalamityMod/Tiles/Furniture/WulfrumLureCover"); + CoverTexture ??= ModContent.Request("CalamityMod/Tiles/Furniture/WulfrumLureCover"); Texture2D coverTex = CoverTexture.Value; Vector2 worldPos = p.ToWorldCoordinates(16f, 16f); diff --git a/Tiles/Furniture/YellowCandle.cs b/Tiles/Furniture/YellowCandle.cs index 177df09292..d9780550bc 100644 --- a/Tiles/Furniture/YellowCandle.cs +++ b/Tiles/Furniture/YellowCandle.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.Furniture { public class YellowCandle : ModTile { - // TODO -- Unique sounds for each Cirrus Candle. + // TODO -- Unique sounds for each Candle. public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); public override void SetStaticDefaults() @@ -35,13 +35,13 @@ namespace CalamityMod.Tiles.Furniture Player p = Main.LocalPlayer; // Forcibly remove all candle buffs. - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); - p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); // 108000 is the duration used by Ammo Box. - p.AddBuff(ModContent.BuffType(), 108000); + p.AddBuff(ModContent.BuffType(), 108000); // Play a sound. SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); diff --git a/Tiles/Furniture/ZenithThrone.cs b/Tiles/Furniture/ZenithThrone.cs index fc87137266..05373db96d 100644 --- a/Tiles/Furniture/ZenithThrone.cs +++ b/Tiles/Furniture/ZenithThrone.cs @@ -7,7 +7,6 @@ using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using static CalamityMod.Tiles.BaseTiles.BranchDrawer; using Terraria.ObjectData; namespace CalamityMod.Tiles.Furniture @@ -75,9 +74,9 @@ namespace CalamityMod.Tiles.Furniture info.AnchorTilePosition.Y = j; } - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAbyss/AbyssBed.cs b/Tiles/FurnitureAbyss/AbyssBed.cs index 8d18164db5..416a691649 100644 --- a/Tiles/FurnitureAbyss/AbyssBed.cs +++ b/Tiles/FurnitureAbyss/AbyssBed.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureAbyss/AbyssCandelabra.cs b/Tiles/FurnitureAbyss/AbyssCandelabra.cs index 29ed46a7d3..ad0e6892ad 100644 --- a/Tiles/FurnitureAbyss/AbyssCandelabra.cs +++ b/Tiles/FurnitureAbyss/AbyssCandelabra.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureAbyss/AbyssCandle.cs b/Tiles/FurnitureAbyss/AbyssCandle.cs index 1bc70981e5..b97e63e6df 100644 --- a/Tiles/FurnitureAbyss/AbyssCandle.cs +++ b/Tiles/FurnitureAbyss/AbyssCandle.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -51,7 +51,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureAbyss/AbyssChair.cs b/Tiles/FurnitureAbyss/AbyssChair.cs index f85356db35..31f520f96b 100644 --- a/Tiles/FurnitureAbyss/AbyssChair.cs +++ b/Tiles/FurnitureAbyss/AbyssChair.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureAbyss num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAbyss/AbyssChandelier.cs b/Tiles/FurnitureAbyss/AbyssChandelier.cs index f766e03cc8..20b9da187a 100644 --- a/Tiles/FurnitureAbyss/AbyssChandelier.cs +++ b/Tiles/FurnitureAbyss/AbyssChandelier.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureAbyss/AbyssChest.cs b/Tiles/FurnitureAbyss/AbyssChest.cs index 13729c06d6..a6cac3319f 100644 --- a/Tiles/FurnitureAbyss/AbyssChest.cs +++ b/Tiles/FurnitureAbyss/AbyssChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureAbyss/AbyssClock.cs b/Tiles/FurnitureAbyss/AbyssClock.cs index d7ee944ebc..da08ab3116 100644 --- a/Tiles/FurnitureAbyss/AbyssClock.cs +++ b/Tiles/FurnitureAbyss/AbyssClock.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -40,6 +40,6 @@ namespace CalamityMod.Tiles.FurnitureAbyss } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureAbyss/AbyssDresser.cs b/Tiles/FurnitureAbyss/AbyssDresser.cs index d4fad0f275..1c6e35f282 100644 --- a/Tiles/FurnitureAbyss/AbyssDresser.cs +++ b/Tiles/FurnitureAbyss/AbyssDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureAbyss/AbyssLamp.cs b/Tiles/FurnitureAbyss/AbyssLamp.cs index 9bda2175f1..a1664f0e83 100644 --- a/Tiles/FurnitureAbyss/AbyssLamp.cs +++ b/Tiles/FurnitureAbyss/AbyssLamp.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureAbyss/AbyssLantern.cs b/Tiles/FurnitureAbyss/AbyssLantern.cs index 870a1e2b71..ac8dce21c2 100644 --- a/Tiles/FurnitureAbyss/AbyssLantern.cs +++ b/Tiles/FurnitureAbyss/AbyssLantern.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureAbyss/AbyssSofa.cs b/Tiles/FurnitureAbyss/AbyssSofa.cs index e20eea99a0..f562280eb9 100644 --- a/Tiles/FurnitureAbyss/AbyssSofa.cs +++ b/Tiles/FurnitureAbyss/AbyssSofa.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureAbyss num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAbyss/AbyssTorch.cs b/Tiles/FurnitureAbyss/AbyssTorch.cs deleted file mode 100644 index 7c0459014e..0000000000 --- a/Tiles/FurnitureAbyss/AbyssTorch.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureAbyss -{ - public class AbyssTorch : ModTile - { - public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 130, 150), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void MouseOver(int i, int j) - { - Player player = Main.LocalPlayer; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ModContent.ItemType(); - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - Tile tile = Main.tile[i, j]; - if (tile.TileFrameX < 66) - { - r = 0.6f; - g = 0.6f; - b = 2.3f; - } - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) - { - offsetY = 0; - if (WorldGen.SolidTile(i, j - 1)) - { - offsetY = 2; - if (WorldGen.SolidTile(i - 1, j + 1) || WorldGen.SolidTile(i + 1, j + 1)) - { - offsetY = 4; - } - } - } - - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAbyss/AbyssTorchFlame").Value, i, j, 2); - } - - public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) - { - if (Main.tile[i, j].TileFrameX < 66) - CalamityUtils.DrawFlameSparks(187, 5, i, j); - } - - public override bool RightClick(int i, int j) - { - CalamityUtils.RightClickBreak(i, j); - return true; - } - - public override float GetTorchLuck(Player player) - { - // Note: Total Torch luck never goes below zero - return player.Calamity().ZoneAbyss ? 1f : -1f; // Abyss Torch gives positive luck when in the Abyss, otherwise some negative luck - } - } -} diff --git a/Tiles/FurnitureAcidwood/AcidwoodBedTile.cs b/Tiles/FurnitureAcidwood/AcidwoodBedTile.cs index 73ffbbb9e3..bc76076032 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodBedTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodBedTile.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodBenchTile.cs b/Tiles/FurnitureAcidwood/AcidwoodBenchTile.cs index 9224924124..86654de6ea 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodBenchTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodBenchTile.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureAcidwood num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAcidwood/AcidwoodCandelabraTile.cs b/Tiles/FurnitureAcidwood/AcidwoodCandelabraTile.cs index fef06c039b..83ab2a086f 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodCandelabraTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodCandelabraTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureAcidwood; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAcidwood { public class AcidwoodCandelabraTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType()); public override bool CreateDust(int i, int j, ref int type) @@ -40,12 +43,13 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodCandelabraTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodCandelabraTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodCandleTile.cs b/Tiles/FurnitureAcidwood/AcidwoodCandleTile.cs index 5362d24dfc..f429d9ef9f 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodCandleTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodCandleTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureAcidwood; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAcidwood { public class AcidwoodCandleTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType()); public override bool CreateDust(int i, int j, ref int type) @@ -40,7 +43,7 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -53,13 +56,14 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodCandleTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodCandleTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodChairTile.cs b/Tiles/FurnitureAcidwood/AcidwoodChairTile.cs index 65199dc73e..c6daf63ccd 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodChairTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodChairTile.cs @@ -56,11 +56,11 @@ namespace CalamityMod.Tiles.FurnitureAcidwood num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info, 40, true, true); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, 40, true, true); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType(), true); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType(), true); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAcidwood/AcidwoodChandelierTile.cs b/Tiles/FurnitureAcidwood/AcidwoodChandelierTile.cs index 5707586091..cd097f1381 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodChandelierTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodChandelierTile.cs @@ -1,7 +1,9 @@ using CalamityMod.Items.Placeables.FurnitureAcidwood; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureAcidwood { public class AcidwoodChandelierTile : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType()); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -40,14 +46,24 @@ namespace CalamityMod.Tiles.FurnitureAcidwood } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(64, 128, 102, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodChandelierTileFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodChestTile.cs b/Tiles/FurnitureAcidwood/AcidwoodChestTile.cs index 357fc07498..6b5b82c943 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodChestTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodChestTile.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodClockTile.cs b/Tiles/FurnitureAcidwood/AcidwoodClockTile.cs index 0e8127a1bd..8895accf8d 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodClockTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodClockTile.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Tiles.FurnitureAcidwood return false; } - public override bool RightClick(int x, int y) => CalamityUtils.ClockRightClick(); + public override bool RightClick(int x, int y) => FurnitureCommon.ClockRightClick(); public override void NearbyEffects(int i, int j, bool closer) { @@ -34,6 +34,6 @@ namespace CalamityMod.Tiles.FurnitureAcidwood num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodDresserTile.cs b/Tiles/FurnitureAcidwood/AcidwoodDresserTile.cs index 12bd55ff70..2cd3270541 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodDresserTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodDresserTile.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodLampTile.cs b/Tiles/FurnitureAcidwood/AcidwoodLampTile.cs index 70ed8c2eb4..6d45974a53 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodLampTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodLampTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureAcidwood; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAcidwood { public class AcidwoodLampTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType()); public override bool CreateDust(int i, int j, ref int type) @@ -40,12 +43,13 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodLampTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodLampTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureAcidwood/AcidwoodLanternTile.cs b/Tiles/FurnitureAcidwood/AcidwoodLanternTile.cs index 4cad230406..77113c9b71 100644 --- a/Tiles/FurnitureAcidwood/AcidwoodLanternTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodLanternTile.cs @@ -2,8 +2,10 @@ using CalamityMod.Items.Placeables.FurnitureAcidwood; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -11,6 +13,10 @@ namespace CalamityMod.Tiles.FurnitureAcidwood { public class AcidwoodLanternTile : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType()); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -43,12 +49,22 @@ namespace CalamityMod.Tiles.FurnitureAcidwood public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAcidwood/AcidwoodLanternTileFlame").Value, i, j, 0, -8); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(64, 128, 102, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/Abyss/AcidwoodTile.cs b/Tiles/FurnitureAcidwood/AcidwoodTile.cs similarity index 92% rename from Tiles/Abyss/AcidwoodTile.cs rename to Tiles/FurnitureAcidwood/AcidwoodTile.cs index eb33744e0a..4c70e830e6 100644 --- a/Tiles/Abyss/AcidwoodTile.cs +++ b/Tiles/FurnitureAcidwood/AcidwoodTile.cs @@ -1,11 +1,10 @@ -using CalamityMod.Items.Placeables; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Tiles.Abyss +namespace CalamityMod.Tiles.FurnitureAcidwood { public class AcidwoodTile : ModTile { diff --git a/Tiles/Abyss/AcidwoodTile.png b/Tiles/FurnitureAcidwood/AcidwoodTile.png similarity index 100% rename from Tiles/Abyss/AcidwoodTile.png rename to Tiles/FurnitureAcidwood/AcidwoodTile.png diff --git a/Tiles/FurnitureAncient/AncientAltar.cs b/Tiles/FurnitureAncient/AncientAltar.cs new file mode 100644 index 0000000000..4f74b9aaac --- /dev/null +++ b/Tiles/FurnitureAncient/AncientAltar.cs @@ -0,0 +1,77 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureAncient +{ + public class AncientAltar : ModTile + { + public Asset FlameTexture; + + int animationFrame = 0; + + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; + TileObjectData.addTile(Type); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); + AnimationFrameHeight = 54; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.RedTorch, 0f, 0f, 1, new Color(255, 255, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 100, 100), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frameCounter++; + if (frameCounter >= 6) + { + frame = (frame + 1) % 6; + animationFrame = frame; + frameCounter = 0; + } + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 1f; + g = 0.5f; + b = 0.5f; + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAncient/AncientAltarFlame"); + CalamityUtils.DrawStaticFlameEffect(FlameTexture.Value, i, j, offsetY: animationFrame * AnimationFrameHeight); + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + Tile tile = Main.tile[i, j]; + if (tile.TileFrameX == 18 && tile.TileFrameY == 18) + { + CalamityUtils.DrawFlameSparks(60, 5, i, j); + } + } + } +} diff --git a/Tiles/Furniture/CraftingStations/AncientAltar.png b/Tiles/FurnitureAncient/AncientAltar.png similarity index 100% rename from Tiles/Furniture/CraftingStations/AncientAltar.png rename to Tiles/FurnitureAncient/AncientAltar.png diff --git a/Tiles/Furniture/CraftingStations/AncientAltarFlame.png b/Tiles/FurnitureAncient/AncientAltarFlame.png similarity index 100% rename from Tiles/Furniture/CraftingStations/AncientAltarFlame.png rename to Tiles/FurnitureAncient/AncientAltarFlame.png diff --git a/Tiles/FurnitureAncient/AncientBasin.cs b/Tiles/FurnitureAncient/AncientBasin.cs index 4ef406d4f2..bff7737053 100644 --- a/Tiles/FurnitureAncient/AncientBasin.cs +++ b/Tiles/FurnitureAncient/AncientBasin.cs @@ -1,9 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -11,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureAncient { public class AncientBasin : ModTile { + public Asset FlameTexture; + int animationFrame = 0; public override void SetStaticDefaults() @@ -62,12 +64,13 @@ namespace CalamityMod.Tiles.FurnitureAncient public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawStaticFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAncient/AncientBasinFlame").Value, i, j, offsetY: animationFrame * AnimationFrameHeight); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAncient/AncientBasinFlame"); + CalamityUtils.DrawStaticFlameEffect(FlameTexture.Value, i, j, offsetY: animationFrame * AnimationFrameHeight); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAncient/AncientBed.cs b/Tiles/FurnitureAncient/AncientBed.cs index 9008ee9dfb..00dd7dea10 100644 --- a/Tiles/FurnitureAncient/AncientBed.cs +++ b/Tiles/FurnitureAncient/AncientBed.cs @@ -64,6 +64,6 @@ namespace CalamityMod.Tiles.FurnitureAncient return true; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureAncient/AncientChair.cs b/Tiles/FurnitureAncient/AncientChair.cs index 6d6bb19f2a..2042ef66c5 100644 --- a/Tiles/FurnitureAncient/AncientChair.cs +++ b/Tiles/FurnitureAncient/AncientChair.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureAncient num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAncient/AncientChandelier.cs b/Tiles/FurnitureAncient/AncientChandelier.cs index 85650a6e48..9c6843dca6 100644 --- a/Tiles/FurnitureAncient/AncientChandelier.cs +++ b/Tiles/FurnitureAncient/AncientChandelier.cs @@ -1,7 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,8 +11,14 @@ namespace CalamityMod.Tiles.FurnitureAncient { public class AncientChandelier : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType(), true); + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + public override bool CreateDust(int i, int j, ref int type) { Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.RedTorch, 0f, 0f, 1, new Color(255, 255, 255), 1f); @@ -23,14 +31,24 @@ namespace CalamityMod.Tiles.FurnitureAncient num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAncient/AncientChandelierFlame").Value, i, j); - } - public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); + } + + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) + { + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(128, 64, 64, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0f; } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAncient/AncientDresser.cs b/Tiles/FurnitureAncient/AncientDresser.cs index f6bf544ea9..d28157fbea 100644 --- a/Tiles/FurnitureAncient/AncientDresser.cs +++ b/Tiles/FurnitureAncient/AncientDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureAncient public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureAncient public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureAncient/AncientLamp.cs b/Tiles/FurnitureAncient/AncientLamp.cs index b112264fd9..ff86dfbe45 100644 --- a/Tiles/FurnitureAncient/AncientLamp.cs +++ b/Tiles/FurnitureAncient/AncientLamp.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAncient { public class AncientLamp : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -32,12 +35,13 @@ namespace CalamityMod.Tiles.FurnitureAncient public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAncient/AncientLampFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAncient/AncientLampFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAncient/AncientLantern.cs b/Tiles/FurnitureAncient/AncientLantern.cs index 00ac4b6fd0..fe31c5eb11 100644 --- a/Tiles/FurnitureAncient/AncientLantern.cs +++ b/Tiles/FurnitureAncient/AncientLantern.cs @@ -1,7 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureAncient { public class AncientLantern : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -40,14 +46,24 @@ namespace CalamityMod.Tiles.FurnitureAncient } } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAncient/AncientLanternFlame").Value, i, j); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(128, 64, 64, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0f; } public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAncient/AncientMonolith.cs b/Tiles/FurnitureAncient/AncientMonolith.cs index 57280af8a5..6e6002dc3a 100644 --- a/Tiles/FurnitureAncient/AncientMonolith.cs +++ b/Tiles/FurnitureAncient/AncientMonolith.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Tiles.FurnitureAncient public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -67,6 +67,6 @@ namespace CalamityMod.Tiles.FurnitureAncient num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureAncient/AncientPipeOrgan.cs b/Tiles/FurnitureAncient/AncientPipeOrgan.cs index 9d11e7839d..235037769a 100644 --- a/Tiles/FurnitureAncient/AncientPipeOrgan.cs +++ b/Tiles/FurnitureAncient/AncientPipeOrgan.cs @@ -1,8 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/FurnitureAncient/AncientSofa.cs b/Tiles/FurnitureAncient/AncientSofa.cs index 4bb38cc641..03580641e8 100644 --- a/Tiles/FurnitureAncient/AncientSofa.cs +++ b/Tiles/FurnitureAncient/AncientSofa.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureAncient num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAshen/AshenAccentSlab.cs b/Tiles/FurnitureAshen/AshenAccentSlab.cs index 6fa77bdb6f..7eb8b524e2 100644 --- a/Tiles/FurnitureAshen/AshenAccentSlab.cs +++ b/Tiles/FurnitureAshen/AshenAccentSlab.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureAshen { public override string Texture => "CalamityMod/Tiles/FurnitureAshen/AshenSlab"; + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -514,7 +517,10 @@ namespace CalamityMod.Tiles.FurnitureAshen int yDrawPos = Main.tile[i, j].TileFrameY + (uniqueAnimationFrameY * AnimationFrameHeight); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(64, 64, 64, 64)); Tile trackTile = Main.tile[i, j]; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) diff --git a/Tiles/FurnitureAshen/AshenBasin.cs b/Tiles/FurnitureAshen/AshenBasin.cs index 6f22d70bde..b29e684679 100644 --- a/Tiles/FurnitureAshen/AshenBasin.cs +++ b/Tiles/FurnitureAshen/AshenBasin.cs @@ -1,9 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -11,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureAshen { public class AshenBasin : ModTile { + public Asset FlameTexture; + int animationFrame = 0; public override void SetStaticDefaults() @@ -63,12 +65,13 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawStaticFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenBasinFlame").Value, i, j, offsetY: animationFrame * AnimationFrameHeight); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenBasinFlame"); + CalamityUtils.DrawStaticFlameEffect(FlameTexture.Value, i, j, offsetY: animationFrame * AnimationFrameHeight); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAshen/AshenBed.cs b/Tiles/FurnitureAshen/AshenBed.cs index 9267651c2a..af16505aaa 100644 --- a/Tiles/FurnitureAshen/AshenBed.cs +++ b/Tiles/FurnitureAshen/AshenBed.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Tiles.FurnitureAshen num = fail ? 1 : 3; } - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureAshen/AshenCandelabra.cs b/Tiles/FurnitureAshen/AshenCandelabra.cs index 1bd754c8cc..4135ddd130 100644 --- a/Tiles/FurnitureAshen/AshenCandelabra.cs +++ b/Tiles/FurnitureAshen/AshenCandelabra.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAshen { public class AshenCandelabra : ModTile { + public Asset FlameTexture; + int animationFrame = 0; public override void SetStaticDefaults() @@ -58,12 +61,13 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawStaticFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenCandelabraFlame").Value, i, j, offsetY: animationFrame * AnimationFrameHeight); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenCandelabraFlame"); + CalamityUtils.DrawStaticFlameEffect(FlameTexture.Value, i, j, offsetY: animationFrame * AnimationFrameHeight); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAshen/AshenCandle.cs b/Tiles/FurnitureAshen/AshenCandle.cs index 019a86ed4e..0fd9cc2b22 100644 --- a/Tiles/FurnitureAshen/AshenCandle.cs +++ b/Tiles/FurnitureAshen/AshenCandle.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAshen { public class AshenCandle : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -41,7 +44,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -54,13 +57,14 @@ namespace CalamityMod.Tiles.FurnitureAshen public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenCandleFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenCandleFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAshen/AshenChair.cs b/Tiles/FurnitureAshen/AshenChair.cs index 86e2829b8e..0fbf0957f3 100644 --- a/Tiles/FurnitureAshen/AshenChair.cs +++ b/Tiles/FurnitureAshen/AshenChair.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureAshen num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAshen/AshenChandelier.cs b/Tiles/FurnitureAshen/AshenChandelier.cs index 877855977d..3a21a905dd 100644 --- a/Tiles/FurnitureAshen/AshenChandelier.cs +++ b/Tiles/FurnitureAshen/AshenChandelier.cs @@ -1,7 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -11,6 +13,10 @@ namespace CalamityMod.Tiles.FurnitureAshen { int animationFrame = 0; + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() { this.SetUpChandelier(ModContent.ItemType(), true); @@ -58,14 +64,24 @@ namespace CalamityMod.Tiles.FurnitureAshen } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(128, 64, 64, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.05f; + tileFlameData.flameRangeMultY = 0f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawStaticFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenChandelierFlame").Value, i, j, offsetY: animationFrame * AnimationFrameHeight); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAshen/AshenChest.cs b/Tiles/FurnitureAshen/AshenChest.cs index af112776a2..c3dd81f497 100644 --- a/Tiles/FurnitureAshen/AshenChest.cs +++ b/Tiles/FurnitureAshen/AshenChest.cs @@ -25,15 +25,15 @@ namespace CalamityMod.Tiles.FurnitureAshen public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; public override void NumDust(int i, int j, bool fail, ref int num) => num = 1; - public string MapChestName(string name, int i, int j) => CalamityUtils.GetMapChestName(name, i, j); + public string MapChestName(string name, int i, int j) => FurnitureCommon.GetMapChestName(name, i, j); public override ushort GetMapOption(int i, int j) => (ushort)(Main.tile[i, j].TileFrameX / 36); public override LocalizedText DefaultContainerName(int frameX, int frameY) { int option = frameX / 36; return this.GetLocalization("MapEntry" + option); } - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); // Locked Chest stuff @@ -58,7 +58,7 @@ namespace CalamityMod.Tiles.FurnitureAshen { top--; } - return CalamityUtils.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j); + return FurnitureCommon.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j); } } } diff --git a/Tiles/FurnitureAshen/AshenDresser.cs b/Tiles/FurnitureAshen/AshenDresser.cs index 77b3031780..3dd927ba3b 100644 --- a/Tiles/FurnitureAshen/AshenDresser.cs +++ b/Tiles/FurnitureAshen/AshenDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureAshen/AshenLamp.cs b/Tiles/FurnitureAshen/AshenLamp.cs index 5ce0af78f4..06ee9f7365 100644 --- a/Tiles/FurnitureAshen/AshenLamp.cs +++ b/Tiles/FurnitureAshen/AshenLamp.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAshen { public class AshenLamp : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -41,12 +44,13 @@ namespace CalamityMod.Tiles.FurnitureAshen public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenLampFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenLampFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAshen/AshenLantern.cs b/Tiles/FurnitureAshen/AshenLantern.cs index ec7f983270..3855e118c0 100644 --- a/Tiles/FurnitureAshen/AshenLantern.cs +++ b/Tiles/FurnitureAshen/AshenLantern.cs @@ -1,7 +1,9 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureAshen { public class AshenLantern : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -40,14 +46,24 @@ namespace CalamityMod.Tiles.FurnitureAshen } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(128, 64, 64, 0); + tileFlameData.flameCount = 2; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0f; + tileFlameData.flameRangeMultY = 0f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenLanternFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureAshen/AshenMonolith.cs b/Tiles/FurnitureAshen/AshenMonolith.cs index d1dbbae53f..7217d39a43 100644 --- a/Tiles/FurnitureAshen/AshenMonolith.cs +++ b/Tiles/FurnitureAshen/AshenMonolith.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureAshen { public class AshenMonolith : ModTile { + public Asset EyeTexture; + public int animationFrameWidth = 36; public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType(), true); @@ -31,7 +34,7 @@ namespace CalamityMod.Tiles.FurnitureAshen public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -47,7 +50,7 @@ namespace CalamityMod.Tiles.FurnitureAshen num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -122,7 +125,10 @@ namespace CalamityMod.Tiles.FurnitureAshen frameY *= 90; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Texture2D eyeSheet = ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenMonolith_Eye").Value; + + EyeTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenMonolith_Eye"); + Texture2D eyeSheet = EyeTexture.Value; + spriteBatch.Draw ( eyeSheet, diff --git a/Tiles/FurnitureAshen/AshenPipeOrgan.cs b/Tiles/FurnitureAshen/AshenPipeOrgan.cs index cea4c14b71..d91f361635 100644 --- a/Tiles/FurnitureAshen/AshenPipeOrgan.cs +++ b/Tiles/FurnitureAshen/AshenPipeOrgan.cs @@ -1,8 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/FurnitureAshen/AshenSlab.cs b/Tiles/FurnitureAshen/AshenSlab.cs index 440542777f..809dbd3bc7 100644 --- a/Tiles/FurnitureAshen/AshenSlab.cs +++ b/Tiles/FurnitureAshen/AshenSlab.cs @@ -1,6 +1,7 @@ using CalamityMod.Tiles.Crags; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAshen { public class AshenSlab : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -514,7 +517,10 @@ namespace CalamityMod.Tiles.FurnitureAshen int yDrawPos = Main.tile[i, j].TileFrameY + (uniqueAnimationFrameY * AnimationFrameHeight); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(64, 64, 64, 64)); Tile trackTile = Main.tile[i, j]; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) diff --git a/Tiles/FurnitureAshen/AshenSofa.cs b/Tiles/FurnitureAshen/AshenSofa.cs index 6396af054e..41af8853bf 100644 --- a/Tiles/FurnitureAshen/AshenSofa.cs +++ b/Tiles/FurnitureAshen/AshenSofa.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureAshen num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureAshen/SmoothBrimstoneSlag.cs b/Tiles/FurnitureAshen/SmoothBrimstoneSlag.cs index 6c5b1290a7..0315c0cb9e 100644 --- a/Tiles/FurnitureAshen/SmoothBrimstoneSlag.cs +++ b/Tiles/FurnitureAshen/SmoothBrimstoneSlag.cs @@ -1,18 +1,12 @@ - -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAshen { public class SmoothBrimstoneSlag : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAshen/SmoothBrimstoneSlagGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureAuric/ActivatedAuricPanelTile.cs b/Tiles/FurnitureAuric/ActivatedAuricPanelTile.cs index 24a4d7ed7d..7da8269a14 100644 --- a/Tiles/FurnitureAuric/ActivatedAuricPanelTile.cs +++ b/Tiles/FurnitureAuric/ActivatedAuricPanelTile.cs @@ -1,18 +1,15 @@ using CalamityMod.Systems; using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAuric { public class ActivatedAuricPanelTile : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAuric/ActivatedAuricPanelTile_Glow"; + public override string GlowMaskAsset => $"{Texture}_Glow"; public override void SetupStatic() { diff --git a/Tiles/FurnitureAuric/AuricAbsorberTile.cs b/Tiles/FurnitureAuric/AuricAbsorberTile.cs index 35db8b1f40..e167d4c2e7 100644 --- a/Tiles/FurnitureAuric/AuricAbsorberTile.cs +++ b/Tiles/FurnitureAuric/AuricAbsorberTile.cs @@ -1,8 +1,6 @@ using CalamityMod.Systems; -using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.GameContent; using Terraria.ID; diff --git a/Tiles/FurnitureAuric/AuricConsoleTile.cs b/Tiles/FurnitureAuric/AuricConsoleTile.cs index c63214c960..241928d2ed 100644 --- a/Tiles/FurnitureAuric/AuricConsoleTile.cs +++ b/Tiles/FurnitureAuric/AuricConsoleTile.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Enums; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureAuric { public class AuricConsoleTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -55,7 +58,10 @@ namespace CalamityMod.Tiles.FurnitureAuric int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricConsoleTile_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricConsoleTile_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureAuric/AuricDisplayTile.cs b/Tiles/FurnitureAuric/AuricDisplayTile.cs index 3bee285bc0..ce4fe2eb74 100644 --- a/Tiles/FurnitureAuric/AuricDisplayTile.cs +++ b/Tiles/FurnitureAuric/AuricDisplayTile.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureAuric { public class AuricDisplayTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -59,7 +62,10 @@ namespace CalamityMod.Tiles.FurnitureAuric int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricDisplayTile_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricDisplayTile_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureAuric/AuricLandMineTile.cs b/Tiles/FurnitureAuric/AuricLandMineTile.cs index 927da514e5..a2593907ca 100644 --- a/Tiles/FurnitureAuric/AuricLandMineTile.cs +++ b/Tiles/FurnitureAuric/AuricLandMineTile.cs @@ -1,6 +1,9 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,7 +16,10 @@ namespace CalamityMod.Tiles.FurnitureAuric { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; + // Land Mines break on all entity contact, and so does this + TileID.Sets.PressurePlate[Type] = 0; TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; + TileID.Sets.PreventsTileHammeringIfOnTopOfIt[Type] = true; TileID.Sets.PreventsSandfall[Type] = true; Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = false; @@ -25,6 +31,25 @@ namespace CalamityMod.Tiles.FurnitureAuric MinPick = 250; } + public override void HitSwitch(int i, int j) + { + Vector2 tileCenter = new Vector2(i, j) * 16f + Vector2.One * 8f; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Pitch = 0.8f }, tileCenter); + GenericSparkle sparkle = new(tileCenter, Vector2.Zero, Color.Goldenrod, Color.Gold, 2.5f, 9, Main.rand.NextFloat(-0.01f, 0.01f), 2.68f); + GeneralParticleHandler.SpawnParticle(sparkle); + WorldGen.KillTile(i, j, noItem: true); + NetMessage.SendTileSquare(-1, i, j); + // Remove all player iframes + Main.LocalPlayer.RemoveAllIFrames(); + Projectile.NewProjectile(new EntitySource_TileInteraction(Main.LocalPlayer, i, j), tileCenter, Vector2.Zero, ModContent.ProjectileType(), 40000, 0f); + } + + public override void HitWire(int i, int j) => Wiring.HitSwitchAndSync(i, j); + + public override bool IsTileDangerous(int i, int j, Player player) => true; + + public override bool CanExplode(int i, int j) => false; + public override bool CreateDust(int i, int j, ref int type) { Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Electric); diff --git a/Tiles/FurnitureAuric/AuricPanelTile.cs b/Tiles/FurnitureAuric/AuricPanelTile.cs index 49623ab9fa..f8d8f73ae1 100644 --- a/Tiles/FurnitureAuric/AuricPanelTile.cs +++ b/Tiles/FurnitureAuric/AuricPanelTile.cs @@ -1,7 +1,6 @@ using CalamityMod.Systems; using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,7 +15,7 @@ namespace CalamityMod.Tiles.FurnitureAuric Main.tileBlockLight[Type] = true; HitSound = AuricOre.MineSound; MineResist = 3f; - DustType = 55; + DustType = DustID.Pixie; AddMapEntry(new Color(213, 138, 69)); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) diff --git a/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs b/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs index b12a59811b..db6df9b0a8 100644 --- a/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs +++ b/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAuric { public class AuricReinforcedCrateTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -44,7 +47,10 @@ namespace CalamityMod.Tiles.FurnitureAuric int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricReinforcedCrateTile_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricReinforcedCrateTile_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureAuric/AuricRepulserPanelTile.cs b/Tiles/FurnitureAuric/AuricRepulserPanelTile.cs index 236306d9cb..845be67777 100644 --- a/Tiles/FurnitureAuric/AuricRepulserPanelTile.cs +++ b/Tiles/FurnitureAuric/AuricRepulserPanelTile.cs @@ -1,18 +1,15 @@ using CalamityMod.Systems; using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAuric { public class AuricRepulserPanelTile : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAuric/AuricRepulserPanelTile_Glow"; + public override string GlowMaskAsset => $"{Texture}_Glow"; public override void SetupStatic() { diff --git a/Tiles/FurnitureAuric/AuricScreenTile.cs b/Tiles/FurnitureAuric/AuricScreenTile.cs index 57d785b261..5d8a69598f 100644 --- a/Tiles/FurnitureAuric/AuricScreenTile.cs +++ b/Tiles/FurnitureAuric/AuricScreenTile.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureAuric { public class AuricScreenTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -22,7 +25,7 @@ namespace CalamityMod.Tiles.FurnitureAuric AddMapEntry(Color.Goldenrod, CalamityUtils.GetText("Tiles.Screen")); TileID.Sets.FramesOnKillWall[Type] = true; - DustType = 8; + DustType = DustID.Iron; } public override bool CanExplode(int i, int j) => false; @@ -39,7 +42,10 @@ namespace CalamityMod.Tiles.FurnitureAuric int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricScreenTile_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricScreenTile_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureAuric/AuricServerTile.cs b/Tiles/FurnitureAuric/AuricServerTile.cs index 859f124c91..e1d63488d7 100644 --- a/Tiles/FurnitureAuric/AuricServerTile.cs +++ b/Tiles/FurnitureAuric/AuricServerTile.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.DraedonStructures; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureAuric { public class AuricServerTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -58,7 +58,10 @@ namespace CalamityMod.Tiles.FurnitureAuric int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricServerTile_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricServerTile_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureAuric/AuricTerminalTile.cs b/Tiles/FurnitureAuric/AuricTerminalTile.cs index b4870a0fe5..2fcb2e17b8 100644 --- a/Tiles/FurnitureAuric/AuricTerminalTile.cs +++ b/Tiles/FurnitureAuric/AuricTerminalTile.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -11,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureAuric { public class AuricTerminalTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -59,7 +62,10 @@ namespace CalamityMod.Tiles.FurnitureAuric int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricTerminalTile_Glow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureAuric/AuricTerminalTile_Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureAuric/AuricToiletTile.cs b/Tiles/FurnitureAuric/AuricToiletTile.cs index ba15b0194e..ab4dd204e9 100644 --- a/Tiles/FurnitureAuric/AuricToiletTile.cs +++ b/Tiles/FurnitureAuric/AuricToiletTile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.FurnitureAuric; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; diff --git a/Tiles/FurnitureAuric/ExoAuricPanelTile.cs b/Tiles/FurnitureAuric/ExoAuricPanelTile.cs index 7f30c72c0b..375b040f76 100644 --- a/Tiles/FurnitureAuric/ExoAuricPanelTile.cs +++ b/Tiles/FurnitureAuric/ExoAuricPanelTile.cs @@ -1,18 +1,15 @@ using CalamityMod.Systems; using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureAuric { public class ExoAuricPanelTile : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureAuric/ExoAuricPanelTile_Glow"; + public override string GlowMaskAsset => $"{Texture}_Glow"; public override void SetupStatic() { diff --git a/Tiles/FurnitureBasalt/BasaltSlab.cs b/Tiles/FurnitureBasalt/BasaltSlab.cs new file mode 100644 index 0000000000..8969d5ce15 --- /dev/null +++ b/Tiles/FurnitureBasalt/BasaltSlab.cs @@ -0,0 +1,56 @@ +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureBasalt +{ + public class BasaltSlab : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + TileID.Sets.HasSlopeFrames[Type] = true; + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileShine2[Type] = true; + Main.tileBlendAll[Type] = true; + + Main.tileLargeFrames[Type] = 1; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + DustType = DustID.Ash; + HitSound = SoundID.Tink; + + AddMapEntry(new Color(58, 55, 70)); + + MinPick = 110; + + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 100, 100), 1f); + return false; + } + + } +} diff --git a/Tiles/FurnitureBasalt/BasaltSlab.png b/Tiles/FurnitureBasalt/BasaltSlab.png new file mode 100644 index 0000000000..a81c872726 Binary files /dev/null and b/Tiles/FurnitureBasalt/BasaltSlab.png differ diff --git a/Tiles/FurnitureBotanic/BotanicBed.cs b/Tiles/FurnitureBotanic/BotanicBed.cs index f3e6053f5d..e50ce6d9bf 100644 --- a/Tiles/FurnitureBotanic/BotanicBed.cs +++ b/Tiles/FurnitureBotanic/BotanicBed.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureBotanic/BotanicBench.cs b/Tiles/FurnitureBotanic/BotanicBench.cs index 8456274e28..0e768fc998 100644 --- a/Tiles/FurnitureBotanic/BotanicBench.cs +++ b/Tiles/FurnitureBotanic/BotanicBench.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureBotanic num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureBotanic/BotanicCandelabra.cs b/Tiles/FurnitureBotanic/BotanicCandelabra.cs index 91a3dbab1e..8c22569e16 100644 --- a/Tiles/FurnitureBotanic/BotanicCandelabra.cs +++ b/Tiles/FurnitureBotanic/BotanicCandelabra.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureBotanic/BotanicCandle.cs b/Tiles/FurnitureBotanic/BotanicCandle.cs index 358c8a4b3a..73b43c873e 100644 --- a/Tiles/FurnitureBotanic/BotanicCandle.cs +++ b/Tiles/FurnitureBotanic/BotanicCandle.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -52,7 +52,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureBotanic/BotanicChair.cs b/Tiles/FurnitureBotanic/BotanicChair.cs index 0ee9e3e78b..149eccdc83 100644 --- a/Tiles/FurnitureBotanic/BotanicChair.cs +++ b/Tiles/FurnitureBotanic/BotanicChair.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureBotanic num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureBotanic/BotanicChandelier.cs b/Tiles/FurnitureBotanic/BotanicChandelier.cs index 5c09783ac6..93c8e970c2 100644 --- a/Tiles/FurnitureBotanic/BotanicChandelier.cs +++ b/Tiles/FurnitureBotanic/BotanicChandelier.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureBotanic/BotanicChest.cs b/Tiles/FurnitureBotanic/BotanicChest.cs index bbf30963f9..d73f222d55 100644 --- a/Tiles/FurnitureBotanic/BotanicChest.cs +++ b/Tiles/FurnitureBotanic/BotanicChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureBotanic/BotanicClock.cs b/Tiles/FurnitureBotanic/BotanicClock.cs index dd33d37e42..6ae4b6189c 100644 --- a/Tiles/FurnitureBotanic/BotanicClock.cs +++ b/Tiles/FurnitureBotanic/BotanicClock.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -37,6 +37,6 @@ namespace CalamityMod.Tiles.FurnitureBotanic } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureBotanic/BotanicDresser.cs b/Tiles/FurnitureBotanic/BotanicDresser.cs index a4f60cf62a..60132c3dea 100644 --- a/Tiles/FurnitureBotanic/BotanicDresser.cs +++ b/Tiles/FurnitureBotanic/BotanicDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureBotanic/BotanicLamp.cs b/Tiles/FurnitureBotanic/BotanicLamp.cs index dc7de3cb0e..bd0fc80cfb 100644 --- a/Tiles/FurnitureBotanic/BotanicLamp.cs +++ b/Tiles/FurnitureBotanic/BotanicLamp.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureBotanic/BotanicLantern.cs b/Tiles/FurnitureBotanic/BotanicLantern.cs index ff61750358..5a0d66f52e 100644 --- a/Tiles/FurnitureBotanic/BotanicLantern.cs +++ b/Tiles/FurnitureBotanic/BotanicLantern.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureBotanic public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureBotanic/BotanicPlanter.cs b/Tiles/FurnitureBotanic/BotanicPlanter.cs new file mode 100644 index 0000000000..c22dd420e8 --- /dev/null +++ b/Tiles/FurnitureBotanic/BotanicPlanter.cs @@ -0,0 +1,55 @@ +using CalamityMod.Dusts.Furniture; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureBotanic +{ + public class BotanicPlanter : ModTile + { + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.addTile(Type); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); + AnimationFrameHeight = 54; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + Tile tile = Main.tile[i, j]; + //227 79 79 + if (tile.TileFrameX < 54) + { + r = 0.8f; + g = 0.9f; + b = 0.3f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); + } + } +} diff --git a/Tiles/Furniture/CraftingStations/BotanicPlanter.png b/Tiles/FurnitureBotanic/BotanicPlanter.png similarity index 100% rename from Tiles/Furniture/CraftingStations/BotanicPlanter.png rename to Tiles/FurnitureBotanic/BotanicPlanter.png diff --git a/Tiles/FurnitureCommon.cs b/Tiles/FurnitureCommon.cs new file mode 100644 index 0000000000..39f0474563 --- /dev/null +++ b/Tiles/FurnitureCommon.cs @@ -0,0 +1,1639 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ModLoader.Default; +using Terraria.ObjectData; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Tiles +{ + internal static class FurnitureCommon + { + public static bool BedRightClick(int i, int j) + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + int spawnX = i - tile.TileFrameX / 18 + (tile.TileFrameX >= 72 ? 5 : 2); + int spawnY = j + 2; + if (tile.TileFrameY % 38 != 0) + { + spawnY--; + } + + if (!Player.IsHoveringOverABottomSideOfABed(i, j)) + { + if (player.IsWithinSnappngRangeToTile(i, j, PlayerSleepingHelper.BedSleepingMaxDistance)) + { + player.GamepadEnableGrappleCooldown(); + player.sleeping.StartSleeping(player, i, j); + } + } + else + { + player.FindSpawn(); + + if (player.SpawnX == spawnX && player.SpawnY == spawnY) + { + player.RemoveSpawn(); + Main.NewText(Language.GetTextValue("Game.SpawnPointRemoved"), byte.MaxValue, 240, 20); + } + else if (Player.CheckSpawn(spawnX, spawnY)) + { + player.ChangeSpawn(spawnX, spawnY); + Main.NewText(Language.GetTextValue("Game.SpawnPointSet"), byte.MaxValue, 240, 20); + } + } + + return true; + } + + public static void BenchMouseOver(int i, int j, int itemID) + { + Player player = Main.LocalPlayer; + + if (!player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance)) + { + return; + } + + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = itemID; + } + + public static void BenchSitInfo(int i, int j, ref TileRestingInfo info, int nextStyleHeight = 40) + { + Tile tile = Framing.GetTileSafely(i, j); + Player player = Main.LocalPlayer; + + info.DirectionOffset = 0; + float offset = 0f; + if (tile.TileFrameX < 17 && player.direction == 1) + offset = 8f; + if (tile.TileFrameX < 17 && player.direction == -1) + offset = -8f; + if (tile.TileFrameX > 34 && player.direction == 1) + offset = -8f; + if (tile.TileFrameX > 34 && player.direction == -1) + offset = 8f; + info.VisualOffset = new Vector2(offset, 0f); + info.TargetDirection = player.direction; + + info.AnchorTilePosition.X = i; + info.AnchorTilePosition.Y = j; + + if (tile.TileFrameY % nextStyleHeight == 0) + { + info.AnchorTilePosition.Y++; + } + } + + public static void ChairMouseOver(int i, int j, int itemID, bool fat = false) + { + Player player = Main.LocalPlayer; + + if (!player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance)) + { + return; + } + + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = itemID; + + bool frameCheck = fat ? Main.tile[i, j].TileFrameX <= 35 : Main.tile[i, j].TileFrameX / 18 < 0; + if (frameCheck) + { + player.cursorItemIconReversed = true; + } + } + + public static bool ChairRightClick(int i, int j) + { + Player player = Main.LocalPlayer; + + if (player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance)) + { + player.GamepadEnableGrappleCooldown(); + player.sitting.SitDown(player, i, j); + } + return true; + } + + // fat is for 2 tile chairs like Exo Chair and Exo Toilet + public static void ChairSitInfo(int i, int j, ref TileRestingInfo info, int nextStyleHeight = 40, bool fat = false, bool hasOffset = false, bool shitter = false) + { + if (hasOffset) + { + info.DirectionOffset = 0; + info.VisualOffset = new Vector2(-8f, 0f); + } + + Tile tile = Framing.GetTileSafely(i, j); + bool frameCheck = fat ? tile.TileFrameX >= 35 : tile.TileFrameX != 0; + + if (shitter) + info.ExtraInfo.IsAToilet = true; + + info.TargetDirection = -1; + if (frameCheck) + { + info.TargetDirection = 1; + } + + if (fat) + { + int xPos = tile.TileFrameX / 18; + if (xPos == 1) + i--; + if (xPos == 2) + i++; + } + + info.AnchorTilePosition.X = i; + info.AnchorTilePosition.Y = j; + + if (tile.TileFrameY % nextStyleHeight == 0) + { + info.AnchorTilePosition.Y++; + } + } + public static void ChestMouseFar(int i, int j) where T : ModItem + { + ChestMouseOver(i, j); + Player player = Main.LocalPlayer; + if (player.cursorItemIconText == "") + { + player.cursorItemIconEnabled = false; + player.cursorItemIconID = ItemID.None; + } + } + + public static void ChestMouseOver(int i, int j) where T : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); + int left = i; + int top = j; + if (tile.TileFrameX % 36 != 0) + { + left--; + } + if (tile.TileFrameY != 0) + { + top--; + } + int chest = Chest.FindChest(left, top); + player.cursorItemIconID = -1; + if (chest < 0) + { + player.cursorItemIconText = Language.GetTextValue("LegacyChestType.0"); + } + else + { + player.cursorItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; + if (player.cursorItemIconText == chestName) + { + player.cursorItemIconID = ItemType(); + player.cursorItemIconText = ""; + } + } + player.noThrow = 2; + player.cursorItemIconEnabled = true; + } + + public static bool ChestRightClick(int i, int j) + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + Main.mouseRightRelease = false; + int left = i; + int top = j; + if (tile.TileFrameX % 36 != 0) + { + left--; + } + if (tile.TileFrameY != 0) + { + top--; + } + if (player.sign >= 0) + { + SoundEngine.PlaySound(SoundID.MenuClose); + player.sign = -1; + Main.editSign = false; + Main.npcChatText = ""; + } + if (Main.editChest) + { + SoundEngine.PlaySound(SoundID.MenuTick); + Main.editChest = false; + Main.npcChatText = ""; + } + if (player.editedChestName) + { + NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); + player.editedChestName = false; + } + + if (Main.netMode == NetmodeID.MultiplayerClient) + { + if (left == player.chestX && top == player.chestY && player.chest >= 0) + { + player.chest = -1; + Recipe.FindRecipes(); + SoundEngine.PlaySound(SoundID.MenuClose); + } + else + { + NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); + Main.stackSplit = 600; + } + } + else + { + int chest = Chest.FindChest(left, top); + if (chest >= 0) + { + Main.stackSplit = 600; + if (chest == player.chest) + { + player.chest = -1; + SoundEngine.PlaySound(SoundID.MenuClose); + } + else + { + player.chest = chest; + Main.playerInventory = true; + Main.recBigList = false; + player.chestX = left; + player.chestY = top; + SoundEngine.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); + } + Recipe.FindRecipes(); + } + } + return true; + } + + public static bool ClockRightClick() + { + string text = "AM"; + + // Get Terraria's current strange time variable + double time = Main.time; + + // Correct for night time (which for some reason isn't just a different number) by adding 54000. + if (!Main.dayTime) + time += 54000D; + + // Divide by seconds in an hour + time /= 3600D; + + // Terraria night starts at 7:30 PM, so offset accordingly + time -= 19.5; + + // Offset time to ensure it is not negative, then change to PM if necessary + if (time < 0D) + time += 24D; + if (time >= 12D) + text = "PM"; + + // Get the decimal (smaller than hours, so minutes) component of time. + int intTime = (int)time; + double deltaTime = time - intTime; + + // Convert decimal time into an exact number of minutes. + deltaTime = (int)(deltaTime * 60D); + + string minuteText = deltaTime.ToString(); + + // Ensure minutes has a leading zero + if (deltaTime < 10D) + minuteText = "0" + minuteText; + + // Convert from 24 to 12 hour time (PM already handled earlier) + if (intTime > 12) + intTime -= 12; + // 12 AM is actually hour zero in 24 hour time + if (intTime == 0) + intTime = 12; + + // Create an overall time readout and send it to chat + var newText = string.Concat("Time: ", intTime, ":", minuteText, " ", text); + Main.NewText(newText, 255, 240, 20); + return true; + } + + public static void DresserMouseFar() where T : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; + string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); + int left = Player.tileTargetX; + int top = Player.tileTargetY; + left -= (int)(tile.TileFrameX % 54 / 18); + if (tile.TileFrameY % 36 != 0) + { + top--; + } + int chestIndex = Chest.FindChest(left, top); + player.cursorItemIconID = -1; + if (chestIndex < 0) + { + player.cursorItemIconText = Language.GetTextValue("LegacyDresserType.0"); + } + else + { + if (Main.chest[chestIndex].name != "") + { + player.cursorItemIconText = Main.chest[chestIndex].name; + } + else + { + player.cursorItemIconText = chestName; + } + if (player.cursorItemIconText == chestName) + { + player.cursorItemIconID = ItemType(); + player.cursorItemIconText = ""; + } + } + player.noThrow = 2; + player.cursorItemIconEnabled = true; + if (player.cursorItemIconText == "") + { + player.cursorItemIconEnabled = false; + player.cursorItemIconID = ItemID.None; + } + } + + public static void DresserMouseOver() where T : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; + string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); + int left = Player.tileTargetX; + int top = Player.tileTargetY; + left -= (int)(tile.TileFrameX % 54 / 18); + if (tile.TileFrameY % 36 != 0) + { + top--; + } + int chestIndex = Chest.FindChest(left, top); + player.cursorItemIconID = -1; + if (chestIndex < 0) + { + player.cursorItemIconText = Language.GetTextValue("LegacyDresserType.0"); + } + else + { + if (Main.chest[chestIndex].name != "") + { + player.cursorItemIconText = Main.chest[chestIndex].name; + } + else + { + player.cursorItemIconText = chestName; + } + if (player.cursorItemIconText == chestName) + { + player.cursorItemIconID = ItemType(); + player.cursorItemIconText = ""; + } + } + player.noThrow = 2; + player.cursorItemIconEnabled = true; + if (Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameY > 0) + { + player.cursorItemIconID = ItemID.FamiliarShirt; + } + } + + public static bool DresserRightClick() + { + Player player = Main.LocalPlayer; + if (Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameY == 0) + { + Main.CancelClothesWindow(true); + + int left = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameX / 18); + left %= 3; + left = Player.tileTargetX - left; + int top = Player.tileTargetY - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameY / 18); + if (player.sign > -1) + { + SoundEngine.PlaySound(SoundID.MenuClose); + player.sign = -1; + Main.editSign = false; + Main.npcChatText = string.Empty; + } + if (Main.editChest) + { + SoundEngine.PlaySound(SoundID.MenuTick); + Main.editChest = false; + Main.npcChatText = string.Empty; + } + if (player.editedChestName) + { + NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); + player.editedChestName = false; + } + if (Main.netMode == NetmodeID.MultiplayerClient) + { + if (left == player.chestX && top == player.chestY && player.chest != -1) + { + player.chest = -1; + Recipe.FindRecipes(); + SoundEngine.PlaySound(SoundID.MenuClose); + } + else + { + NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); + Main.stackSplit = 600; + } + return true; + } + else + { + player.piggyBankProjTracker.Clear(); + player.voidLensChest.Clear(); + int dresserChestID = Chest.FindChest(left, top); + if (dresserChestID != -1) + { + Main.stackSplit = 600; + if (dresserChestID == player.chest) + { + player.chest = -1; + Recipe.FindRecipes(); + SoundEngine.PlaySound(SoundID.MenuClose); + } + else if (dresserChestID != player.chest && player.chest == -1) + { + player.chest = dresserChestID; + Main.playerInventory = true; + Main.recBigList = false; + SoundEngine.PlaySound(SoundID.MenuOpen); + player.chestX = left; + player.chestY = top; + } + else + { + player.chest = dresserChestID; + Main.playerInventory = true; + Main.recBigList = false; + SoundEngine.PlaySound(SoundID.MenuTick); + player.chestX = left; + player.chestY = top; + } + Recipe.FindRecipes(); + return true; + } + } + } + else + { + Main.playerInventory = false; + player.chest = -1; + Recipe.FindRecipes(); + Main.interactedDresserTopLeftX = Player.tileTargetX; + Main.interactedDresserTopLeftY = Player.tileTargetY; + Main.OpenClothesWindow(); + return true; + } + + return false; + } + public static string GetMapChestName(string baseName, int x, int y) + { + // Bounds check. + if (!WorldGen.InWorld(x, y, 2)) + return baseName; + + Tile tile = Main.tile[x, y]; + int left = x; + int top = y; + if (tile.TileFrameX % 36 != 0) + left--; + if (tile.TileFrameY != 0) + top--; + + int chest = Chest.FindChest(left, top); + + // Valid chest index check. + if (chest < 0) + return baseName; + + string name = baseName; + + // Concatenate the chest's custom name if it has one. + if (!string.IsNullOrEmpty(Main.chest[chest].name)) + name += $": {Main.chest[chest].name}"; + + return name; + } + + public static void LightHitWire(int type, int i, int j, int tileX, int tileY) + { + int x = i - Main.tile[i, j].TileFrameX / 18 % tileX; + int y = j - Main.tile[i, j].TileFrameY / 18 % tileY; + int tileXX18 = 18 * tileX; + for (int l = x; l < x + tileX; l++) + { + for (int m = y; m < y + tileY; m++) + { + if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == type) + { + if (Main.tile[l, m].TileFrameX < tileXX18) + Main.tile[l, m].TileFrameX += (short)(tileXX18); + else + Main.tile[l, m].TileFrameX -= (short)(tileXX18); + } + } + } + + if (Wiring.running) + { + for (int k = 0; k < tileX; k++) + { + for (int l = 0; l < tileY; l++) + Wiring.SkipWire(x + k, y + l); + } + } + + if (Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendTileSquare(-1, x, y, tileX, tileY); + } + + public static void LockedChestMouseOver(int i, int j) + where K : ModItem where C : ModItem + { + Player player = Main.LocalPlayer; + Tile tile = Main.tile[i, j]; + string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); + int left = i; + int top = j; + if (tile.TileFrameX % 36 != 0) + { + left--; + } + if (tile.TileFrameY != 0) + { + top--; + } + int chest = Chest.FindChest(left, top); + player.cursorItemIconID = -1; + if (chest < 0) + { + player.cursorItemIconText = Language.GetTextValue("LegacyChestType.0"); + } + else + { + player.cursorItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; + if (player.cursorItemIconText == chestName) + { + player.cursorItemIconID = ItemType(); + if (Main.tile[left, top].TileFrameX / 36 == 1) + player.cursorItemIconID = ItemType(); + player.cursorItemIconText = ""; + } + } + player.noThrow = 2; + player.cursorItemIconEnabled = true; + } + + public static void LockedChestMouseOverFar(int i, int j) + where K : ModItem where C : ModItem + { + LockedChestMouseOver(i, j); + Player player = Main.LocalPlayer; + if (player.cursorItemIconText == "") + { + player.cursorItemIconEnabled = false; + player.cursorItemIconID = ItemID.None; + } + } + + public static bool LockedChestRightClick(bool isLocked, int left, int top, int i, int j) + { + Player player = Main.LocalPlayer; + + // If the player right clicked the chest while editing a sign, finish that up + if (player.sign >= 0) + { + SoundEngine.PlaySound(SoundID.MenuClose); + player.sign = -1; + Main.editSign = false; + Main.npcChatText = ""; + } + + // If the player right clicked the chest while editing a chest, finish that up + if (Main.editChest) + { + SoundEngine.PlaySound(SoundID.MenuTick); + Main.editChest = false; + Main.npcChatText = ""; + } + + // If the player right clicked the chest after changing another chest's name, finish that up + if (player.editedChestName) + { + NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); + player.editedChestName = false; + } + if (Main.netMode == NetmodeID.MultiplayerClient && !isLocked) + { + // Right clicking the chest you currently have open closes it. This counts as interaction. + if (left == player.chestX && top == player.chestY && player.chest >= 0) + { + player.chest = -1; + Recipe.FindRecipes(); + SoundEngine.PlaySound(SoundID.MenuClose); + } + + // Right clicking this chest opens it if it's not already open. This counts as interaction. + else + { + NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); + Main.stackSplit = 600; + } + return true; + } + + else + { + if (isLocked) + { + // If you right click the locked chest and you can unlock it, it unlocks itself but does not open. This counts as interaction. + if (Chest.Unlock(left, top)) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.LockAndUnlock, -1, -1, null, player.whoAmI, 1f, (float)left, (float)top); + } + return true; + } + } + else + { + int chest = Chest.FindChest(left, top); + if (chest >= 0) + { + Main.stackSplit = 600; + + // If you right click the same chest you already have open, it closes. This counts as interaction. + if (chest == player.chest) + { + player.chest = -1; + SoundEngine.PlaySound(SoundID.MenuClose); + } + + // If you right click this chest when you have a different chest selected, that one closes and this one opens. This counts as interaction. + else + { + player.chest = chest; + Main.playerInventory = true; + Main.recBigList = false; + player.chestX = left; + player.chestY = top; + SoundEngine.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); + } + + Recipe.FindRecipes(); + return true; + } + } + } + + // This only occurs when the chest is locked and cannot be unlocked. You did not interact with the chest. + return false; + } + + public static void MouseOver(int i, int j, int itemID) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = itemID; + } + public static void RightClickBreak(int i, int j) + { + if (Main.tile[i, j] != null && Main.tile[i, j].HasTile) + { + WorldGen.KillTile(i, j, false, false, false); + if (!Main.tile[i, j].HasTile && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); + } + } + } + + /// + /// Extension which initializes a ModTile to be a 6x6 Painting. + /// + /// The ModTile which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUp6x6Painting(this ModTile mt, bool lavaImmune = false) + { + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileSpelunker[mt.Type] = true; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); + TileObjectData.newTile.Width = 6; + TileObjectData.newTile.Height = 6; + TileObjectData.newTile.Origin = new Point16(2, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16, 16 }; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + } + + /// + /// Extension which initializes a ModTile to be a bar. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// The color of the bar on the minimap. + /// Whether this tile is supposed to be immune to lava. Defaults to true like vanilla bars. + internal static void SetUpBar(this ModTile mt, int itemDropID, Color mapColor, bool lavaImmune = true) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileShine[mt.Type] = 1100; + Main.tileSolid[mt.Type] = true; + Main.tileSolidTop[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + // Vanilla bars are labeled as "Metal Bar" on the minimap + mt.AddMapEntry(mapColor, Language.GetText("MapObject.MetalBar")); + } + + /// + /// Extension which initializes a ModTile to be a bathtub. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpBathtub(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + + // All bathtubs count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + mt.AddMapEntry(new Color(144, 148, 144), Language.GetText("ItemName.Bathtub")); + } + + /// + /// Extension which initializes a ModTile to be a bed. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpBed(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.HasOutlines[mt.Type] = true; + TileID.Sets.CanBeSleptIn[mt.Type] = true; + TileID.Sets.InteractibleByNPCs[mt.Type] = true; + TileID.Sets.IsValidSpawnPoint[mt.Type] = true; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + + // All beds count as chairs. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.Bed")); + mt.AdjTiles = new int[] { TileID.Beds }; + } + + /// + /// Extension which initializes a ModTile to be a bookcase. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile is supposed to have a solid top. Defaults to true. + /// Whether this tile is automatically registered as a bookcase and table with proper map entry. Defaults to true. + internal static void SetUpBookcase(this ModTile mt, int itemDropID, bool lavaImmune = false, bool solidTop = true, bool autoBookcase = true) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileSolidTop[mt.Type] = solidTop; + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileTable[mt.Type] = solidTop; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + // Skip this for special bookcases such as Monolith Amalgam + if (autoBookcase) + { + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.Bookcase")); + mt.AdjTiles = new int[] { TileID.Bookcases }; + } + } + + /// + /// Extension which initializes a ModTile to be a candelabra. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpCandelabra(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.addTile(mt.Type); + + // All candelabras count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("ItemName.Candelabra")); + mt.AdjTiles = new int[] { TileID.Candelabras }; + } + + /// + /// Extension which initializes a ModTile to be a candle. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile is supposed to use normal map entries. Defaults to true. + /// The vertical offset of the tile. Defaults to -4. + internal static void SetUpCandle(this ModTile mt, int itemDropID, bool lavaImmune = false, bool autoMapEntry = true, int offset = -4) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.StyleOnTable1x1); + TileObjectData.newTile.CoordinateHeights = new int[] { 20 }; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.DrawYOffset = offset; + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.addTile(mt.Type); + + // All candles count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + if (autoMapEntry) + mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("ItemName.Candle")); + + mt.AdjTiles = new int[] { TileID.Candles }; + } + + /// + /// Extension which initializes a ModTile to be a chair. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpChair(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.CanBeSatOnForNPCs[mt.Type] = true; + TileID.Sets.CanBeSatOnForPlayers[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + + // As you could probably guess, all chairs count as chairs. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Chair")); + mt.AdjTiles = new int[] { TileID.Chairs }; + } + + /// + /// Extension which initializes a ModTile to be a chandelier. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpChandelier(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.MultiTileSway[mt.Type] = true; + TileID.Sets.IsAMechanism[mt.Type] = true; + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Origin = new Point16(1, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.addTile(mt.Type); + + // All chandeliers count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + mt.AddMapEntry(new Color(235, 166, 135), Language.GetText("MapObject.Chandelier")); + mt.AdjTiles = new int[] { TileID.Chandeliers }; + } + + /// + /// Extension which initializes a ModTile to be a chest. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// If true, uses the parameter offsetAmt to decide the Y draw offset. + /// If offset is true, this is the Y draw offset to use. Otherwise it is ignored. + internal static void SetUpChest(this ModTile mt, int itemDropID, bool offset = false, int offsetAmt = 4) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileSpelunker[mt.Type] = true; + Main.tileContainer[mt.Type] = true; + Main.tileShine2[mt.Type] = true; + Main.tileShine[mt.Type] = 1200; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileOreFinderPriority[mt.Type] = 500; + TileID.Sets.BasicChest[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + if (offset) + TileObjectData.newTile.DrawYOffset = offsetAmt; + TileObjectData.newTile.Origin = new Point16(0, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); + TileObjectData.newTile.AnchorInvalidTiles = new int[] { TileID.MagicalIceBlock }; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.addTile(mt.Type); + + mt.AdjTiles = new int[] { TileID.Containers }; + } + + /// + /// Extension which initializes a ModTile to be a clock. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpClock(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16, + 16, + 16, + 16 + }; + TileObjectData.newTile.Origin = new Point16(0, 4); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.GrandfatherClock")); + mt.AdjTiles = new int[] { TileID.GrandfatherClocks }; + } + + /// + /// Extension which initializes a ModTile to be a closed door. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpDoorClosed(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileFrameImportant[mt.Type] = true; + Main.tileBlockLight[mt.Type] = true; + Main.tileSolid[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.NotReallySolid[mt.Type] = true; + TileID.Sets.DrawsWalls[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 1); + TileObjectData.addAlternate(0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 2); + TileObjectData.addAlternate(0); + TileObjectData.addTile(mt.Type); + + // As you could probably guess, all closed doors count as doors. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); + mt.AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); + mt.AdjTiles = new int[] { TileID.ClosedDoor }; + } + + /// + /// Extension which initializes a ModTile to be an open door. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpDoorOpen(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileFrameImportant[mt.Type] = true; + Main.tileSolid[mt.Type] = false; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + Main.tileNoSunLight[mt.Type] = true; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 0); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 1); + TileObjectData.addAlternate(0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(0, 2); + TileObjectData.addAlternate(0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.addAlternate(1); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(1, 1); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.addAlternate(1); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Origin = new Point16(1, 2); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.addAlternate(1); + TileObjectData.addTile(mt.Type); + TileID.Sets.HousingWalls[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + + // As you could probably guess, all open doors count as doors. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); + mt.AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); + mt.AdjTiles = new int[] { TileID.OpenDoor }; + } + + /// + /// Extension which initializes a ModTile to be a dresser. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + internal static void SetUpDresser(this ModTile mt, int itemDropID) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileSolidTop[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileContainer[mt.Type] = true; + Main.tileWaterDeath[mt.Type] = false; + Main.tileLavaDeath[mt.Type] = false; + TileID.Sets.BasicDresser[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16 }; + TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); + TileObjectData.newTile.AnchorInvalidTiles = new int[] { 127 }; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.addTile(mt.Type); + + // All dressers count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + mt.AdjTiles = new int[] { TileID.Dressers }; + } + + /// + /// Extension which initializes a ModTile to be a fountain. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// The map color of the tile. + /// Whether or not the type of fountain is lava. + internal static void SetUpFountain(this ModTile mt, int itemDropID, Color mapColor, bool lava = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = false; + Main.tileWaterDeath[mt.Type] = false; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.LavaPlacement = LiquidPlacement.Allowed; + TileObjectData.addTile(mt.Type); + TileID.Sets.HasOutlines[mt.Type] = true; + + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Origin = new Point16(0, 3); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 2, 0); + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.addTile(mt.Type); + + mt.AddMapEntry(mapColor, lava ? CalamityUtils.GetText("Tiles.LavaFountain") : Language.GetText("MapObject.WaterFountain")); + mt.AnimationFrameHeight = 72; + } + + /// + /// Extension which initializes a ModTile to be a floor lamp. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpLamp(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1xX); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.addTile(mt.Type); + + // All floor lamps count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("MapObject.FloorLamp")); + mt.AdjTiles = new int[] { TileID.Lamps }; + } + + /// + /// Extension which initializes a ModTile to be a hanging lantern. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile is supposed to use normal map entries. Defaults to true. + internal static void SetUpLantern(this ModTile mt, int itemDropID, bool lavaImmune = false, bool autoMapEntry = true) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileID.Sets.MultiTileSway[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.newTile.DrawYOffset = -2; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.Platform, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.DrawYOffset = -10; + TileObjectData.addAlternate(0); + TileObjectData.addTile(mt.Type); + + // All hanging lanterns count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + if (autoMapEntry) + mt.AddMapEntry(new Color(251, 235, 127), Language.GetText("MapObject.Lantern")); + + mt.AdjTiles = new int[] { TileID.HangingLanterns }; + } + + /// + /// Extension which initializes a ModTile to be a piano. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile is supposed to have a solid top. Defaults to true. + internal static void SetUpPiano(this ModTile mt, int itemDropID, bool lavaImmune = false, bool solidTop = true) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileTable[mt.Type] = solidTop; + Main.tileSolidTop[mt.Type] = solidTop; + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + // All pianos count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.Piano")); + } + + /// + /// Extension which initializes a ModTile to be a platform. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpPlatform(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileSolidTop[mt.Type] = true; + Main.tileSolid[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + TileID.Sets.Platforms[mt.Type] = true; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 27; + TileObjectData.newTile.StyleWrapLimit = 27; + TileObjectData.newTile.UsesCustomCanPlace = false; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + // All platforms count as doors (so that you may have top-or-bottom entry/exit rooms) + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); + mt.AddMapEntry(new Color(191, 142, 111)); + mt.AdjTiles = new int[] { TileID.Platforms }; + } + + /// + /// Extension which initializes a ModPylon to be a simple pylon.
+ /// ModPylon appears to make it easier to create a modded pylon extending ModTile.
+ ///
+ /// Note: This is used for pylons that follow general vanilla functionality.
+ /// Pylons that have vastly different custom behavior require a different setup (refer to ExamplePylonTileAdvanced in ExampleMod).
+ ///
+ /// The ModPylon which is being initialized. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpPylon(this ModPylon mp, TEModdedPylon pylonHook, bool lavaImmune = false, int offset = 2) + { + Main.tileLighted[mp.Type] = true; + Main.tileFrameImportant[mp.Type] = true; + Main.tileLavaDeath[mp.Type] = !lavaImmune; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); + + // These definitions allow for vanilla's pylon TileEntities to be placed. + // tModLoader has a built in Tile Entity specifically for modded pylons, which is extended through TECalamityPylon. + TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(pylonHook.PlacementPreviewHook_CheckIfCanPlace, 1, 0, true); + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(pylonHook.Hook_AfterPlacement, -1, 0, false); + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.DrawYOffset = offset; + TileObjectData.addTile(mp.Type); + + // Adds functionality for proximity of pylons; if this is true, then being near this tile will count as being near a pylon for the teleportation process. + mp.AddToArray(ref TileID.Sets.CountsAsPylon); + } + + /// + /// Extension which initializes a ModTile to be a sink. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile counts as a water source. Defaults to true. + /// Whether this tile counts as a lava source. Defaults to false. + /// Whether this tile counts as a honey source. Defaults to false. + internal static void SetUpSink(this ModTile mt, int itemDropID, bool lavaImmune = false, bool water = true, bool lava = false, bool honey = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.CountsAsWaterSource[mt.Type] = water; + 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; + TileObjectData.addTile(mt.Type); + + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Sink")); + if (water) + mt.AdjTiles = new int[] { TileID.Sinks }; + } + + /// + /// Extension which initializes a ModTile to be a sofa. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + /// Whether this tile is displayed as bench instead of sofa on the map. Defaults to false. + internal static void SetUpSofa(this ModTile mt, int itemDropID, bool lavaImmune = false, bool bench = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.CanBeSatOnForPlayers[mt.Type] = true; + TileID.Sets.HasOutlines[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + // All sofas count as chairs. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + mt.AddMapEntry(new Color(191, 142, 111), bench ? Language.GetText("ItemName.Bench") : Language.GetText("ItemName.Sofa")); + } + + /// + /// Extension which initializes a ModTile to be a table. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpTable(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileSolidTop[mt.Type] = true; + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + // As you could probably guess, all tables count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Table")); + mt.AdjTiles = new int[] { TileID.Tables }; + } + + /// + /// Extension which initializes a ModTile to be a torch. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to water. Defaults to false. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpTorch(this ModTile mt, int itemDropID, bool waterImmune = false, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileLighted[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileSolid[mt.Type] = false; + Main.tileNoAttach[mt.Type] = true; + Main.tileNoFail[mt.Type] = true; + Main.tileWaterDeath[mt.Type] = !waterImmune; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileID.Sets.Torch[mt.Type] = true; + TileID.Sets.FramesOnKillWall[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newTile.WaterDeath = !waterImmune; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newAlternate.WaterDeath = !waterImmune; + TileObjectData.newAlternate.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); + TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; + TileObjectData.addAlternate(1); + TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newAlternate.WaterDeath = !waterImmune; + TileObjectData.newAlternate.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); + TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; + TileObjectData.addAlternate(2); + TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); + TileObjectData.newAlternate.WaterDeath = !waterImmune; + TileObjectData.newAlternate.LavaDeath = !lavaImmune; + TileObjectData.newAlternate.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.newAlternate.AnchorWall = true; + TileObjectData.addAlternate(0); + TileObjectData.addTile(mt.Type); + + // All torches count as light sources. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("ItemName.Torch")); + mt.AdjTiles = new int[] { TileID.Torches }; + } + + /// + /// Extension which initializes a ModTile to be a trophy. + /// + /// The ModTile which is being initialized. + internal static void SetUpTrophy(this ModTile mt) + { + // TODO -- how to force trophy drops correctly? they all have zero code in them + + Main.tileFrameImportant[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = true; + Main.tileSpelunker[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); + TileObjectData.addTile(mt.Type); + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileID.Sets.FramesOnKillWall[mt.Type] = true; + + mt.AddMapEntry(new Color(120, 85, 60), Language.GetText("MapObject.Trophy")); + mt.DustType = DustID.WoodFurniture; + } + + /// + /// Extension which initializes a ModTile to be a work bench. + /// + /// The ModTile which is being initialized. + /// The ID of the item this tile drops when broken. + /// Whether this tile is supposed to be immune to lava. Defaults to false. + internal static void SetUpWorkBench(this ModTile mt, int itemDropID, bool lavaImmune = false) + { + mt.RegisterItemDrop(itemDropID); + + Main.tileSolidTop[mt.Type] = true; + Main.tileFrameImportant[mt.Type] = true; + Main.tileNoAttach[mt.Type] = true; + Main.tileTable[mt.Type] = true; + Main.tileLavaDeath[mt.Type] = !lavaImmune; + Main.tileWaterDeath[mt.Type] = false; + TileID.Sets.DisableSmartCursor[mt.Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.CoordinateHeights = new int[] { 18 }; + TileObjectData.newTile.LavaDeath = !lavaImmune; + TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; + TileObjectData.addTile(mt.Type); + + // All work benches count as tables. + mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.WorkBench")); + mt.AdjTiles = new int[] { TileID.WorkBenches }; + } + } +} diff --git a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs index 04fd20ab45..8c9c94fee3 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBasinTile.cs @@ -1,11 +1,10 @@ using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.FurnitureCosmilite; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureCosmilite { public class CosmiliteBasinTile : ModTile { + public Asset FlameTexture; + int animationFrame = 0; public override void SetStaticDefaults() @@ -67,12 +68,13 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawStaticFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureCosmilite/CosmiliteBasinFlame").Value, i, j, offsetY: animationFrame * AnimationFrameHeight); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureCosmilite/CosmiliteBasinFlame"); + CalamityUtils.DrawStaticFlameEffect(FlameTexture.Value, i, j, offsetY: animationFrame * AnimationFrameHeight); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureCosmilite/CosmiliteBed.cs b/Tiles/FurnitureCosmilite/CosmiliteBed.cs index efc2614562..5c3ecf7d9a 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBed.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBed.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteBrick.cs b/Tiles/FurnitureCosmilite/CosmiliteBrick.cs index c91d283dad..57148e1007 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteBrick.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteBrick.cs @@ -1,18 +1,12 @@ - -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureCosmilite { public class CosmiliteBrick : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureCosmilite/CosmiliteBrickGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs b/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs index 924cb15c1f..a56ab05d59 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteCandelabra.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteCandle.cs b/Tiles/FurnitureCosmilite/CosmiliteCandle.cs index 51b7cd6d25..c5bdd4fbd5 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteCandle.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteCandle.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, 1, j, 1, 1); + FurnitureCommon.LightHitWire(Type, 1, j, 1, 1); } public override void MouseOver(int i, int j) @@ -52,7 +52,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteChair.cs b/Tiles/FurnitureCosmilite/CosmiliteChair.cs index 6bcbb2bbb7..7f18fffa23 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteChair.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteChair.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureCosmilite num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs b/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs index 01e4933808..175576c442 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteChandelier.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteChest.cs b/Tiles/FurnitureCosmilite/CosmiliteChest.cs index 53f67928d7..deb14d4078 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteChest.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteClock.cs b/Tiles/FurnitureCosmilite/CosmiliteClock.cs index 96c705f6a1..fe2bd70048 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteClock.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteClock.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -37,6 +37,6 @@ namespace CalamityMod.Tiles.FurnitureCosmilite num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteDresser.cs b/Tiles/FurnitureCosmilite/CosmiliteDresser.cs index 6b86705538..e8c8feaf1e 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteDresser.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteLamp.cs b/Tiles/FurnitureCosmilite/CosmiliteLamp.cs index 1ee78c2f63..a1cb5fc085 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteLamp.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteLamp.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteLantern.cs b/Tiles/FurnitureCosmilite/CosmiliteLantern.cs index a220cc5230..96a9cac8a4 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteLantern.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteLantern.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteSconce.cs b/Tiles/FurnitureCosmilite/CosmiliteSconce.cs index 4ccadc8a41..13a1a60926 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteSconce.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteSconce.cs @@ -2,7 +2,6 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -64,7 +63,7 @@ namespace CalamityMod.Tiles.FurnitureCosmilite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureCosmilite/CosmiliteSofa.cs b/Tiles/FurnitureCosmilite/CosmiliteSofa.cs index 30f363ed8c..ef682ecacd 100644 --- a/Tiles/FurnitureCosmilite/CosmiliteSofa.cs +++ b/Tiles/FurnitureCosmilite/CosmiliteSofa.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureCosmilite num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureDriftwood/Driftwood.cs b/Tiles/FurnitureDriftwood/Driftwood.cs new file mode 100644 index 0000000000..4ae4f4b624 --- /dev/null +++ b/Tiles/FurnitureDriftwood/Driftwood.cs @@ -0,0 +1,41 @@ +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.Metadata; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class Driftwood : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileMergeDirt[Type] = false; + Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Wood"]); + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; + HitSound = SoundID.Dig; + DustType = DustID.Shadewood_Tree; + AddMapEntry(new Color(136, 129, 154)); + + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/Driftwood.png b/Tiles/FurnitureDriftwood/Driftwood.png similarity index 100% rename from Tiles/SunkenSea/Driftwood.png rename to Tiles/FurnitureDriftwood/Driftwood.png diff --git a/Tiles/FurnitureDriftwood/DriftwoodBaroqueCello.cs b/Tiles/FurnitureDriftwood/DriftwoodBaroqueCello.cs new file mode 100644 index 0000000000..be368658b9 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodBaroqueCello.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodBaroqueCello : ModTile + { + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); //This Cello has bookcase dimensions + TileObjectData.newTile.LavaDeath = false; + TileObjectData.addTile(Type); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetText("Tiles.BaroqueCello")); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodBaroqueCello.png b/Tiles/FurnitureDriftwood/DriftwoodBaroqueCello.png new file mode 100644 index 0000000000..d8de02541c Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodBaroqueCello.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodBathtub.cs b/Tiles/FurnitureDriftwood/DriftwoodBathtub.cs new file mode 100644 index 0000000000..dc70c05e83 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodBathtub.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodBathtub : ModTile + { + public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodBathtub.png b/Tiles/FurnitureDriftwood/DriftwoodBathtub.png new file mode 100644 index 0000000000..f38650ae70 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodBathtub.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodBed.cs b/Tiles/FurnitureDriftwood/DriftwoodBed.cs new file mode 100644 index 0000000000..b0f9581b78 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodBed.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodBed : ModTile + { + public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodBed.png b/Tiles/FurnitureDriftwood/DriftwoodBed.png new file mode 100644 index 0000000000..c4e1380f12 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodBed.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodBed_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodBed_Highlight.png new file mode 100644 index 0000000000..5974b70765 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodBed_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodBookcase.cs b/Tiles/FurnitureDriftwood/DriftwoodBookcase.cs new file mode 100644 index 0000000000..275b071873 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodBookcase.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodBookcase : ModTile + { + public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodBookcase.png b/Tiles/FurnitureDriftwood/DriftwoodBookcase.png new file mode 100644 index 0000000000..8bd062dc7e Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodBookcase.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodCandelabra.cs b/Tiles/FurnitureDriftwood/DriftwoodCandelabra.cs new file mode 100644 index 0000000000..4d09f28b99 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodCandelabra.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodCandelabra : ModTile + { + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 89f / 155f; + g = 98f / 155f; + b = 106f / 155f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodCandelabra.png b/Tiles/FurnitureDriftwood/DriftwoodCandelabra.png new file mode 100644 index 0000000000..a80821e5a7 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodCandelabra.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodCandle.cs b/Tiles/FurnitureDriftwood/DriftwoodCandle.cs new file mode 100644 index 0000000000..abf75b540b --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodCandle.cs @@ -0,0 +1,58 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodCandle : ModTile + { + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 89f / 155f; + g = 98f / 155f; + b = 106f / 155f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, 1, j, 1, 1); + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodCandle.png b/Tiles/FurnitureDriftwood/DriftwoodCandle.png new file mode 100644 index 0000000000..a89e4a3b12 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodCandle.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodChair.cs b/Tiles/FurnitureDriftwood/DriftwoodChair.cs new file mode 100644 index 0000000000..7b075c0b95 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodChair.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodChair : ModTile + { + public override void SetStaticDefaults() => this.SetUpChair(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodChair.png b/Tiles/FurnitureDriftwood/DriftwoodChair.png new file mode 100644 index 0000000000..f540f21d51 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodChair.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodChair_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodChair_Highlight.png new file mode 100644 index 0000000000..6c8693094f Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodChair_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodChandelier.cs b/Tiles/FurnitureDriftwood/DriftwoodChandelier.cs new file mode 100644 index 0000000000..eca2b6e82a --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodChandelier.cs @@ -0,0 +1,47 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodChandelier : ModTile + { + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType(), true); + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 89f / 155f; + g = 98f / 155f; + b = 106f / 155f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodChandelier.png b/Tiles/FurnitureDriftwood/DriftwoodChandelier.png new file mode 100644 index 0000000000..2f7510c14d Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodChandelier.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodChest.cs b/Tiles/FurnitureDriftwood/DriftwoodChest.cs new file mode 100644 index 0000000000..1000feb2ab --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodChest.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodChest : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpChest(ModContent.ItemType()); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodChest.png b/Tiles/FurnitureDriftwood/DriftwoodChest.png new file mode 100644 index 0000000000..63df766217 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodChest.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodChest_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodChest_Highlight.png new file mode 100644 index 0000000000..61e5b0044f Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodChest_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodDoorClosed.cs b/Tiles/FurnitureDriftwood/DriftwoodDoorClosed.cs new file mode 100644 index 0000000000..17e3b75992 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodDoorClosed.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodDoorClosed : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorClosed(ModContent.ItemType(), true); + TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodDoorClosed.png b/Tiles/FurnitureDriftwood/DriftwoodDoorClosed.png new file mode 100644 index 0000000000..5884fc811f Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodDoorClosed.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodDoorClosed_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodDoorClosed_Highlight.png new file mode 100644 index 0000000000..c923098653 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodDoorClosed_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodDoorOpen.cs b/Tiles/FurnitureDriftwood/DriftwoodDoorOpen.cs new file mode 100644 index 0000000000..3728e7155f --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodDoorOpen.cs @@ -0,0 +1,39 @@ +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodDoorOpen : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorOpen(ModContent.ItemType(), true); + TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodDoorOpen.png b/Tiles/FurnitureDriftwood/DriftwoodDoorOpen.png new file mode 100644 index 0000000000..c57116c347 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodDoorOpen.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodDoorOpen_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodDoorOpen_Highlight.png new file mode 100644 index 0000000000..8121934574 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodDoorOpen_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodDresser.cs b/Tiles/FurnitureDriftwood/DriftwoodDresser.cs new file mode 100644 index 0000000000..aaa13a257e --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodDresser.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodDresser : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDresser(ModContent.ItemType()); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Firework_Blue, 0f, 0f, 1, new Color(255, 255, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Firework_Pink, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodDresser.png b/Tiles/FurnitureDriftwood/DriftwoodDresser.png new file mode 100644 index 0000000000..b942c92ed3 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodDresser.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodDresser_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodDresser_Highlight.png new file mode 100644 index 0000000000..726973d772 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodDresser_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodLamp.cs b/Tiles/FurnitureDriftwood/DriftwoodLamp.cs new file mode 100644 index 0000000000..0fbb784324 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodLamp.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodLamp : ModTile + { + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 89f / 155f; + g = 98f / 155f; + b = 106f / 155f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodLamp.png b/Tiles/FurnitureDriftwood/DriftwoodLamp.png new file mode 100644 index 0000000000..2669926efb Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodLamp.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodLantern.cs b/Tiles/FurnitureDriftwood/DriftwoodLantern.cs new file mode 100644 index 0000000000..84dbb0ed96 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodLantern.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodLantern : ModTile + { + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 89f / 155f; + g = 98f / 155f; + b = 106f / 155f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodLantern.png b/Tiles/FurnitureDriftwood/DriftwoodLantern.png new file mode 100644 index 0000000000..fb3e61ddc8 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodLantern.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodPlatform.cs b/Tiles/FurnitureDriftwood/DriftwoodPlatform.cs new file mode 100644 index 0000000000..1457551a05 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodPlatform.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodPlatform : ModTile + { + public override void SetStaticDefaults() => this.SetUpPlatform(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void PostSetDefaults() + { + Main.tileNoSunLight[Type] = false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodPlatform.png b/Tiles/FurnitureDriftwood/DriftwoodPlatform.png new file mode 100644 index 0000000000..339f2394e9 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodPlatform.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodSink.cs b/Tiles/FurnitureDriftwood/DriftwoodSink.cs new file mode 100644 index 0000000000..2ede22bb59 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodSink.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodSink : ModTile + { + public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodSink.png b/Tiles/FurnitureDriftwood/DriftwoodSink.png new file mode 100644 index 0000000000..ba278cfee0 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodSink.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodSofa.cs b/Tiles/FurnitureDriftwood/DriftwoodSofa.cs new file mode 100644 index 0000000000..63e41303bf --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodSofa.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodSofa : ModTile + { + public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodSofa.png b/Tiles/FurnitureDriftwood/DriftwoodSofa.png new file mode 100644 index 0000000000..d9043d2231 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodSofa.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodSofa_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodSofa_Highlight.png new file mode 100644 index 0000000000..8b6a408e46 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodSofa_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodSundial.cs b/Tiles/FurnitureDriftwood/DriftwoodSundial.cs new file mode 100644 index 0000000000..ffe24eae10 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodSundial.cs @@ -0,0 +1,41 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodSundial : ModTile + { + public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType(), true); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool RightClick(int x, int y) + { + return FurnitureCommon.ClockRightClick(); + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (closer) + { + Main.SceneMetrics.HasClock = true; + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodSundial.png b/Tiles/FurnitureDriftwood/DriftwoodSundial.png new file mode 100644 index 0000000000..5601159701 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodSundial.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodSundial_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodSundial_Highlight.png new file mode 100644 index 0000000000..6c3469902b Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodSundial_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodTable.cs b/Tiles/FurnitureDriftwood/DriftwoodTable.cs new file mode 100644 index 0000000000..9f4817b0a7 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodTable.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodTable : ModTile + { + public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodTable.png b/Tiles/FurnitureDriftwood/DriftwoodTable.png new file mode 100644 index 0000000000..24259b2899 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodTable.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodToilet.cs b/Tiles/FurnitureDriftwood/DriftwoodToilet.cs new file mode 100644 index 0000000000..ab4a9c6128 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodToilet.cs @@ -0,0 +1,78 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodToilet : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileWaterDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(Type); + + // Toilets count as Chairs + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Toilet")); + TileID.Sets.CanBeSatOnForNPCs[Type] = true; + TileID.Sets.CanBeSatOnForPlayers[Type] = true; + TileID.Sets.HasOutlines[Type] = true; + AdjTiles = new int[] { TileID.Chairs }; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Granite, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, shitter: true); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + + public override void HitWire(int i, int j) // I hate this please make it stop. - Merkalto + { + Tile tile = Main.tile[i, j]; + + int spawnX = i; + int spawnY = j - tile.TileFrameY / 18; + + Wiring.SkipWire(spawnX, spawnY); + Wiring.SkipWire(spawnX, spawnY + 1); + + if (Wiring.CheckMech(spawnX, spawnY, 60)) + { + Projectile.NewProjectile(Wiring.GetProjectileSource(spawnX, spawnY), spawnX * 16 + 8, spawnY * 16 + 12, 0f, 0f, ProjectileID.ToiletEffect, 0, 0f, Main.myPlayer); + } + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodToilet.png b/Tiles/FurnitureDriftwood/DriftwoodToilet.png new file mode 100644 index 0000000000..cb478a2214 Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodToilet.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodToilet_Highlight.png b/Tiles/FurnitureDriftwood/DriftwoodToilet_Highlight.png new file mode 100644 index 0000000000..784cd7f73c Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodToilet_Highlight.png differ diff --git a/Tiles/FurnitureDriftwood/DriftwoodWorkBench.cs b/Tiles/FurnitureDriftwood/DriftwoodWorkBench.cs new file mode 100644 index 0000000000..4193e9a681 --- /dev/null +++ b/Tiles/FurnitureDriftwood/DriftwoodWorkBench.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureDriftwood +{ + public class DriftwoodWorkBench : ModTile + { + public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.LifeDrain, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureDriftwood/DriftwoodWorkBench.png b/Tiles/FurnitureDriftwood/DriftwoodWorkBench.png new file mode 100644 index 0000000000..47a279ce7b Binary files /dev/null and b/Tiles/FurnitureDriftwood/DriftwoodWorkBench.png differ diff --git a/Tiles/FurnitureEutrophic/AncientSmoothNavystone.cs b/Tiles/FurnitureEutrophic/AncientSmoothNavystone.cs deleted file mode 100644 index 18ae30d146..0000000000 --- a/Tiles/FurnitureEutrophic/AncientSmoothNavystone.cs +++ /dev/null @@ -1,33 +0,0 @@ - -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class AncientSmoothNavystone : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileMergeDirt[Type] = true; - Main.tileBlockLight[Type] = true; - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeSmoothTiles(Type); - CalamityUtils.MergeDecorativeTiles(Type); - CalamityUtils.MergeWithDesert(Type); - - TileID.Sets.ChecksForMerge[Type] = true; - HitSound = SoundID.Tink; - AddMapEntry(new Color(39, 48, 53)); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicBathtub.cs b/Tiles/FurnitureEutrophic/EutrophicBathtub.cs deleted file mode 100644 index 85dcf8c046..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicBathtub.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicBathtub : ModTile - { - public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicBed.cs b/Tiles/FurnitureEutrophic/EutrophicBed.cs deleted file mode 100644 index 5dd7734de4..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicBed.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicBed : ModTile - { - public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); - - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicBench.cs b/Tiles/FurnitureEutrophic/EutrophicBench.cs deleted file mode 100644 index 876e7ec38c..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicBench.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicBench : ModTile - { - public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), false, true); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); - - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); - - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); - - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) - { - return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicBookcase.cs b/Tiles/FurnitureEutrophic/EutrophicBookcase.cs deleted file mode 100644 index cadb22b791..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicBookcase.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicBookcase : ModTile - { - public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicCandelabra.cs b/Tiles/FurnitureEutrophic/EutrophicCandelabra.cs deleted file mode 100644 index 524b5da0cf..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicCandelabra.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicCandelabra : ModTile - { - public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - if (Main.tile[i, j].TileFrameX < 18) - { - r = 0.5f; - g = 1f; - b = 1f; - } - else - { - r = 0f; - g = 0f; - b = 0f; - } - } - - public override void HitWire(int i, int j) - { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicCandle.cs b/Tiles/FurnitureEutrophic/EutrophicCandle.cs deleted file mode 100644 index 1b4f0db715..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicCandle.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicCandle : ModTile - { - public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - if (Main.tile[i, j].TileFrameX < 18) - { - r = 0.5f; - g = 1f; - b = 1f; - } - else - { - r = 0f; - g = 0f; - b = 0f; - } - } - - public override void HitWire(int i, int j) - { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); - } - - public override void MouseOver(int i, int j) - { - Player player = Main.LocalPlayer; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ModContent.ItemType(); - } - - public override bool RightClick(int i, int j) - { - CalamityUtils.RightClickBreak(i, j); - return true; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicChair.cs b/Tiles/FurnitureEutrophic/EutrophicChair.cs deleted file mode 100644 index 2028c2a9c3..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicChair.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicChair : ModTile - { - public override void SetStaticDefaults() => this.SetUpChair(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); - - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); - - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); - - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) - { - return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicChandelier.cs b/Tiles/FurnitureEutrophic/EutrophicChandelier.cs deleted file mode 100644 index c98b6590b7..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicChandelier.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicChandelier : ModTile - { - public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType()); - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - if (Main.tile[i, j].TileFrameX < 18) - { - r = 0.5f; - g = 1f; - b = 1f; - } - else - { - r = 0f; - g = 0f; - b = 0f; - } - } - - public override void HitWire(int i, int j) - { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicChest.cs b/Tiles/FurnitureEutrophic/EutrophicChest.cs deleted file mode 100644 index 21053e81c1..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicChest.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicChest : ModTile - { - public override void SetStaticDefaults() - { - this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - - public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); - public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicClock.cs b/Tiles/FurnitureEutrophic/EutrophicClock.cs deleted file mode 100644 index c58bfde6cd..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicClock.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicClock : ModTile - { - public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType()); - - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - if (Main.tile[i, j].TileFrameX < 18) - { - r = 0.5f; - g = 1f; - b = 1f; - } - else - { - r = 0f; - g = 0f; - b = 0f; - } - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override bool RightClick(int x, int y) - { - return CalamityUtils.ClockRightClick(); - } - - public override void NearbyEffects(int i, int j, bool closer) - { - if (closer) - { - Main.SceneMetrics.HasClock = true; - } - } - - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicDoorClosed.cs b/Tiles/FurnitureEutrophic/EutrophicDoorClosed.cs deleted file mode 100644 index 3fe3f15c77..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicDoorClosed.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicDoorClosed : ModTile - { - public override void SetStaticDefaults() - { - this.SetUpDoorClosed(ModContent.ItemType()); - TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - - public override void MouseOver(int i, int j) - { - Player player = Main.LocalPlayer; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ModContent.ItemType(); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicDoorOpen.cs b/Tiles/FurnitureEutrophic/EutrophicDoorOpen.cs deleted file mode 100644 index 3a2e51ab7e..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicDoorOpen.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CalamityMod.Items.Placeables.FurnitureEutrophic; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicDoorOpen : ModTile - { - public override void SetStaticDefaults() - { - this.SetUpDoorOpen(ModContent.ItemType()); - TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - - public override void MouseOver(int i, int j) - { - Player player = Main.LocalPlayer; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = ModContent.ItemType(); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicDresser.cs b/Tiles/FurnitureEutrophic/EutrophicDresser.cs deleted file mode 100644 index 8456bd20f4..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicDresser.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.GameContent.ObjectInteractions; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicDresser : ModTile - { - public override void SetStaticDefaults() - { - this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - - public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); - public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicLamp.cs b/Tiles/FurnitureEutrophic/EutrophicLamp.cs deleted file mode 100644 index 72a09fd1a8..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicLamp.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicLamp : ModTile - { - public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - if (Main.tile[i, j].TileFrameX < 18) - { - r = 0.5f; - g = 1f; - b = 1f; - } - else - { - r = 0f; - g = 0f; - b = 0f; - } - } - - public override void HitWire(int i, int j) - { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicLantern.cs b/Tiles/FurnitureEutrophic/EutrophicLantern.cs deleted file mode 100644 index a238668f28..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicLantern.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicLantern : ModTile - { - public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType()); - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - if (Main.tile[i, j].TileFrameX < 18) - { - r = 0.5f; - g = 1f; - b = 1f; - } - else - { - r = 0f; - g = 0f; - b = 0f; - } - } - - public override void HitWire(int i, int j) - { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicPiano.cs b/Tiles/FurnitureEutrophic/EutrophicPiano.cs deleted file mode 100644 index 7a52e16db4..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicPiano.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicPiano : ModTile - { - public override void SetStaticDefaults() => this.SetUpPiano(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicPlatform.cs b/Tiles/FurnitureEutrophic/EutrophicPlatform.cs deleted file mode 100644 index d4162d7113..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicPlatform.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicPlatform : ModTile - { - public override void SetStaticDefaults() => this.SetUpPlatform(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void PostSetDefaults() - { - Main.tileNoSunLight[Type] = false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicSink.cs b/Tiles/FurnitureEutrophic/EutrophicSink.cs deleted file mode 100644 index d95b05aef6..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicSink.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicSink : ModTile - { - public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicTable.cs b/Tiles/FurnitureEutrophic/EutrophicTable.cs deleted file mode 100644 index e55e216aa7..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicTable.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicTable : ModTile - { - public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureEutrophic/EutrophicWorkBench.cs b/Tiles/FurnitureEutrophic/EutrophicWorkBench.cs deleted file mode 100644 index 07679537ef..0000000000 --- a/Tiles/FurnitureEutrophic/EutrophicWorkBench.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class EutrophicWorkBench : ModTile - { - public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType()); - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureEutrophic/SmoothNavystone.cs b/Tiles/FurnitureEutrophic/SmoothNavystone.cs deleted file mode 100644 index ce85324b05..0000000000 --- a/Tiles/FurnitureEutrophic/SmoothNavystone.cs +++ /dev/null @@ -1,40 +0,0 @@ - -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.FurnitureEutrophic -{ - public class SmoothNavystone : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeSmoothTiles(Type); - CalamityUtils.MergeDecorativeTiles(Type); - CalamityUtils.MergeWithAbyss(Type); - CalamityUtils.MergeWithDesert(Type); - - TileID.Sets.ChecksForMerge[Type] = true; - TileID.Sets.HasSlopeFrames[Type] = true; - HitSound = SoundID.Tink; - DustType = 96; - AddMapEntry(new Color(44, 57, 64)); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - } -} diff --git a/Tiles/FurnitureExo/ExoBathtubTile.cs b/Tiles/FurnitureExo/ExoBathtubTile.cs index bc6774561f..4d738340e3 100644 --- a/Tiles/FurnitureExo/ExoBathtubTile.cs +++ b/Tiles/FurnitureExo/ExoBathtubTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoBathtubTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -31,7 +34,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoBathtubGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoBathtubGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoBedTile.cs b/Tiles/FurnitureExo/ExoBedTile.cs index 5eac86fb0d..ccbfca3ccf 100644 --- a/Tiles/FurnitureExo/ExoBedTile.cs +++ b/Tiles/FurnitureExo/ExoBedTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoBedTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -27,9 +30,9 @@ namespace CalamityMod.Tiles.FurnitureExo public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -38,7 +41,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoBedGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoBedGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoBookcaseTile.cs b/Tiles/FurnitureExo/ExoBookcaseTile.cs index ad3ea4978f..5d16898ebe 100644 --- a/Tiles/FurnitureExo/ExoBookcaseTile.cs +++ b/Tiles/FurnitureExo/ExoBookcaseTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoBookcaseTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -31,7 +34,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoBookcaseGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoBookcaseGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoCandelabraTile.cs b/Tiles/FurnitureExo/ExoCandelabraTile.cs index efc9f4644d..05f5e2dd73 100644 --- a/Tiles/FurnitureExo/ExoCandelabraTile.cs +++ b/Tiles/FurnitureExo/ExoCandelabraTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoCandelabraTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -42,12 +45,13 @@ namespace CalamityMod.Tiles.FurnitureExo public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoCandelabraTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoCandelabraTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureExo/ExoCandleTile.cs b/Tiles/FurnitureExo/ExoCandleTile.cs index 2bfc0e09b6..7fcfd3fc9a 100644 --- a/Tiles/FurnitureExo/ExoCandleTile.cs +++ b/Tiles/FurnitureExo/ExoCandleTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoCandleTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -42,7 +45,7 @@ namespace CalamityMod.Tiles.FurnitureExo public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -55,13 +58,14 @@ namespace CalamityMod.Tiles.FurnitureExo public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoCandleTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoCandleTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureExo/ExoChairTile.cs b/Tiles/FurnitureExo/ExoChairTile.cs index d04b7a3554..ad166b683a 100644 --- a/Tiles/FurnitureExo/ExoChairTile.cs +++ b/Tiles/FurnitureExo/ExoChairTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -15,6 +16,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoChairTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -66,7 +69,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoChairGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoChairGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; @@ -77,11 +83,11 @@ namespace CalamityMod.Tiles.FurnitureExo spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info, 40, true, true); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, 40, true, true); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType(), true); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType(), true); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureExo/ExoChandelierTile.cs b/Tiles/FurnitureExo/ExoChandelierTile.cs index 6292d83cc9..209c87e34c 100644 --- a/Tiles/FurnitureExo/ExoChandelierTile.cs +++ b/Tiles/FurnitureExo/ExoChandelierTile.cs @@ -1,7 +1,9 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoChandelierTile : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -42,14 +48,24 @@ namespace CalamityMod.Tiles.FurnitureExo } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoChandelierTileFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureExo/ExoChestTile.cs b/Tiles/FurnitureExo/ExoChestTile.cs index 8a05742926..5e1f1f5004 100644 --- a/Tiles/FurnitureExo/ExoChestTile.cs +++ b/Tiles/FurnitureExo/ExoChestTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -12,10 +13,12 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoChestTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true, 2); - AddMapEntry(new Color(71, 95, 114), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(71, 95, 114), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CanExplode(int i, int j) => false; @@ -28,10 +31,10 @@ namespace CalamityMod.Tiles.FurnitureExo public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -46,7 +49,10 @@ namespace CalamityMod.Tiles.FurnitureExo return; int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoChestGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoChestGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = Color.White; Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y + yOffset) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)); Rectangle frame = new Rectangle(xPos, yPos + Main.chest[chestIndex].frame * 38, 18, 18); diff --git a/Tiles/FurnitureExo/ExoClockTile.cs b/Tiles/FurnitureExo/ExoClockTile.cs index aa0b55400a..9958b49627 100644 --- a/Tiles/FurnitureExo/ExoClockTile.cs +++ b/Tiles/FurnitureExo/ExoClockTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoClockTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -22,7 +25,7 @@ namespace CalamityMod.Tiles.FurnitureExo return false; } - public override bool RightClick(int x, int y) => CalamityUtils.ClockRightClick(); + public override bool RightClick(int x, int y) => FurnitureCommon.ClockRightClick(); public override void NearbyEffects(int i, int j, bool closer) { @@ -37,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureExo num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -46,7 +49,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoClockGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoClockGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoConsoleTile.cs b/Tiles/FurnitureExo/ExoConsoleTile.cs index b0ee83fc8f..f6d545a371 100644 --- a/Tiles/FurnitureExo/ExoConsoleTile.cs +++ b/Tiles/FurnitureExo/ExoConsoleTile.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.FurnitureExo; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoConsoleTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -58,7 +58,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoConsoleGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoConsoleGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoDisplayTile.cs b/Tiles/FurnitureExo/ExoDisplayTile.cs index 864d84c0dd..df28daf44c 100644 --- a/Tiles/FurnitureExo/ExoDisplayTile.cs +++ b/Tiles/FurnitureExo/ExoDisplayTile.cs @@ -1,11 +1,10 @@ -using CalamityMod.Items.Placeables.FurnitureExo; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoDisplayTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -61,7 +62,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoDisplayGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoDisplayGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoDoorClosed.cs b/Tiles/FurnitureExo/ExoDoorClosed.cs index c6ab67d2d9..940fc44fbe 100644 --- a/Tiles/FurnitureExo/ExoDoorClosed.cs +++ b/Tiles/FurnitureExo/ExoDoorClosed.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureExo AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); TileID.Sets.DisableSmartCursor[Type] = true; AdjTiles = new int[] { TileID.ClosedDoor }; - DustType = 8; + DustType = DustID.Iron; TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); } diff --git a/Tiles/FurnitureExo/ExoDoorOpen.cs b/Tiles/FurnitureExo/ExoDoorOpen.cs index 49d4c6164c..a2edbbf04c 100644 --- a/Tiles/FurnitureExo/ExoDoorOpen.cs +++ b/Tiles/FurnitureExo/ExoDoorOpen.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureExo AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); TileID.Sets.DisableSmartCursor[Type] = true; AdjTiles = new int[] { TileID.OpenDoor }; - DustType = 8; + DustType = DustID.Iron; RegisterItemDrop(ModContent.ItemType()); TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); } diff --git a/Tiles/FurnitureExo/ExoDresserTile.cs b/Tiles/FurnitureExo/ExoDresserTile.cs index 2b0807917f..774d2d15ee 100644 --- a/Tiles/FurnitureExo/ExoDresserTile.cs +++ b/Tiles/FurnitureExo/ExoDresserTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -11,10 +12,12 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoDresserTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CanExplode(int i, int j) => false; @@ -27,10 +30,10 @@ namespace CalamityMod.Tiles.FurnitureExo public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -39,7 +42,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoDresserGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoDresserGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoKeyboardTile.cs b/Tiles/FurnitureExo/ExoKeyboardTile.cs index b54456e596..ff31a96a26 100644 --- a/Tiles/FurnitureExo/ExoKeyboardTile.cs +++ b/Tiles/FurnitureExo/ExoKeyboardTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoKeyboardTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpPiano(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -31,7 +34,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoKeyboardGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoKeyboardGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoLampTile.cs b/Tiles/FurnitureExo/ExoLampTile.cs index cd6c6fd522..456497284a 100644 --- a/Tiles/FurnitureExo/ExoLampTile.cs +++ b/Tiles/FurnitureExo/ExoLampTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoLampTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -42,12 +45,13 @@ namespace CalamityMod.Tiles.FurnitureExo public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoLampTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoLampTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureExo/ExoLanternTile.cs b/Tiles/FurnitureExo/ExoLanternTile.cs index 30c1883ff0..92e9806044 100644 --- a/Tiles/FurnitureExo/ExoLanternTile.cs +++ b/Tiles/FurnitureExo/ExoLanternTile.cs @@ -1,7 +1,9 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoLanternTile : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -41,14 +47,24 @@ namespace CalamityMod.Tiles.FurnitureExo } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoLanternTileFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureExo/ExoPlatingTile.cs b/Tiles/FurnitureExo/ExoPlatingTile.cs index 9a4408ed15..d10698f248 100644 --- a/Tiles/FurnitureExo/ExoPlatingTile.cs +++ b/Tiles/FurnitureExo/ExoPlatingTile.cs @@ -1,19 +1,12 @@ -using CalamityMod.Items.Placeables.FurnitureExo; -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureExo { public class ExoPlatingTile : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureExo/ExoPlatingTileGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureExo/ExoPrismPanelTile.cs b/Tiles/FurnitureExo/ExoPrismPanelTile.cs index 5a560bf5eb..ffeb9432f5 100644 --- a/Tiles/FurnitureExo/ExoPrismPanelTile.cs +++ b/Tiles/FurnitureExo/ExoPrismPanelTile.cs @@ -1,19 +1,12 @@ -using CalamityMod.Items.Placeables.FurnitureExo; -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureExo { public class ExoPrismPanelTile : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureExo/ExoPrismPanelTileGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureExo/ExoPrismPlatformTile.cs b/Tiles/FurnitureExo/ExoPrismPlatformTile.cs index aee4df9a8e..ac921a8589 100644 --- a/Tiles/FurnitureExo/ExoPrismPlatformTile.cs +++ b/Tiles/FurnitureExo/ExoPrismPlatformTile.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Tiles.FurnitureExo { GlowTexture = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoPrismPlatformTileGlow", AssetRequestMode.ImmediateLoad).Value; } - this.SetUpPlatform(ModContent.ItemType(), true); AnimationFrameHeight = 18; } diff --git a/Tiles/FurnitureExo/ExoScreenTile.cs b/Tiles/FurnitureExo/ExoScreenTile.cs index 21b0def587..981b63d4dd 100644 --- a/Tiles/FurnitureExo/ExoScreenTile.cs +++ b/Tiles/FurnitureExo/ExoScreenTile.cs @@ -1,10 +1,8 @@ -using CalamityMod.Items.Placeables.FurnitureExo; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoScreenTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -23,7 +23,7 @@ namespace CalamityMod.Tiles.FurnitureExo TileObjectData.addTile(Type); AddMapEntry(new Color(71, 95, 114), CalamityUtils.GetText("Tiles.Screen")); - DustType = 8; + DustType = DustID.Iron; AnimationFrameHeight = 36; TileID.Sets.FramesOnKillWall[Type] = true; } @@ -60,7 +60,10 @@ namespace CalamityMod.Tiles.FurnitureExo return; int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoScreenGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoScreenGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - (int)Main.screenPosition.X / 2f, j * 16 - (int)Main.screenPosition.Y + yOffset) + drawOffset; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoServerTile.cs b/Tiles/FurnitureExo/ExoServerTile.cs index cdc835ff58..abd785d42e 100644 --- a/Tiles/FurnitureExo/ExoServerTile.cs +++ b/Tiles/FurnitureExo/ExoServerTile.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.FurnitureExo; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoServerTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -58,7 +58,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoServerGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoServerGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoSinkTile.cs b/Tiles/FurnitureExo/ExoSinkTile.cs index 9e6d293bf6..bb419ba8e9 100644 --- a/Tiles/FurnitureExo/ExoSinkTile.cs +++ b/Tiles/FurnitureExo/ExoSinkTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoSinkTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType(), true, true, true, true); public override bool CanExplode(int i, int j) => false; @@ -31,7 +34,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoSinkGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoSinkGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoSofaTile.cs b/Tiles/FurnitureExo/ExoSofaTile.cs index a89b2721e2..2987be3783 100644 --- a/Tiles/FurnitureExo/ExoSofaTile.cs +++ b/Tiles/FurnitureExo/ExoSofaTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -12,6 +13,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoSofaTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -27,11 +30,11 @@ namespace CalamityMod.Tiles.FurnitureExo num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { @@ -45,7 +48,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoSofaGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoSofaGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoTableTile.cs b/Tiles/FurnitureExo/ExoTableTile.cs index 922949b560..1ce9228c77 100644 --- a/Tiles/FurnitureExo/ExoTableTile.cs +++ b/Tiles/FurnitureExo/ExoTableTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoTableTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -31,7 +34,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoTableGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoTableGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoTerminalTile.cs b/Tiles/FurnitureExo/ExoTerminalTile.cs index d180bf0769..6123cd4797 100644 --- a/Tiles/FurnitureExo/ExoTerminalTile.cs +++ b/Tiles/FurnitureExo/ExoTerminalTile.cs @@ -1,11 +1,10 @@ -using CalamityMod.Items.Placeables.FurnitureExo; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoTerminalTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -61,7 +62,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoTerminalGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoTerminalGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureExo/ExoToiletTile.cs b/Tiles/FurnitureExo/ExoToiletTile.cs index 253033f2ca..00b06bd737 100644 --- a/Tiles/FurnitureExo/ExoToiletTile.cs +++ b/Tiles/FurnitureExo/ExoToiletTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -15,6 +16,8 @@ namespace CalamityMod.Tiles.FurnitureExo { public class ExoToiletTile : ModTile { + public Asset GlowTexture; + public const int NextStyleHeight = 40; public override void SetStaticDefaults() { @@ -67,7 +70,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoToiletGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureExo/ExoToiletGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; @@ -78,11 +84,11 @@ namespace CalamityMod.Tiles.FurnitureExo spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info, NextStyleHeight, true, shitter: true); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, NextStyleHeight, true, shitter: true); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType(), true); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType(), true); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureExo/ExoWorkBenchTile.cs b/Tiles/FurnitureExo/ExoWorkBenchTile.cs index 1696283777..d77a9b53bb 100644 --- a/Tiles/FurnitureExo/ExoWorkBenchTile.cs +++ b/Tiles/FurnitureExo/ExoWorkBenchTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureExo; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -11,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureExo [LegacyName("ExoWorkbenchTile")] public class ExoWorkBenchTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -38,7 +41,10 @@ namespace CalamityMod.Tiles.FurnitureExo int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request(Texture + "Glow").Value; + + GlowTexture ??= ModContent.Request(Texture + "Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureMarnite/MarniteBed.cs b/Tiles/FurnitureMarnite/MarniteBed.cs index 39bbcd8dac..8cbde3bf2a 100644 --- a/Tiles/FurnitureMarnite/MarniteBed.cs +++ b/Tiles/FurnitureMarnite/MarniteBed.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureMarnite/MarniteCandelabra.cs b/Tiles/FurnitureMarnite/MarniteCandelabra.cs index 8a58e30836..1ffac23bd2 100644 --- a/Tiles/FurnitureMarnite/MarniteCandelabra.cs +++ b/Tiles/FurnitureMarnite/MarniteCandelabra.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureMarnite/MarniteCandle.cs b/Tiles/FurnitureMarnite/MarniteCandle.cs index 59df314c56..2e2fd30759 100644 --- a/Tiles/FurnitureMarnite/MarniteCandle.cs +++ b/Tiles/FurnitureMarnite/MarniteCandle.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -51,7 +51,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureMarnite/MarniteChair.cs b/Tiles/FurnitureMarnite/MarniteChair.cs index c12256ef08..2e45ccfe4d 100644 --- a/Tiles/FurnitureMarnite/MarniteChair.cs +++ b/Tiles/FurnitureMarnite/MarniteChair.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureMarnite num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureMarnite/MarniteChandelier.cs b/Tiles/FurnitureMarnite/MarniteChandelier.cs index 1e979e48c4..94734007a7 100644 --- a/Tiles/FurnitureMarnite/MarniteChandelier.cs +++ b/Tiles/FurnitureMarnite/MarniteChandelier.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureMarnite/MarniteChest.cs b/Tiles/FurnitureMarnite/MarniteChest.cs index 195247b30f..bed7bffc67 100644 --- a/Tiles/FurnitureMarnite/MarniteChest.cs +++ b/Tiles/FurnitureMarnite/MarniteChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureMarnite/MarniteClock.cs b/Tiles/FurnitureMarnite/MarniteClock.cs index 5411f92ebb..40eee6d636 100644 --- a/Tiles/FurnitureMarnite/MarniteClock.cs +++ b/Tiles/FurnitureMarnite/MarniteClock.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -40,6 +40,6 @@ namespace CalamityMod.Tiles.FurnitureMarnite } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureMarnite/MarniteDoorOpen.cs b/Tiles/FurnitureMarnite/MarniteDoorOpen.cs index e31f15a653..b03946cb97 100644 --- a/Tiles/FurnitureMarnite/MarniteDoorOpen.cs +++ b/Tiles/FurnitureMarnite/MarniteDoorOpen.cs @@ -1,6 +1,4 @@ -using CalamityMod.Items.Placeables.FurnitureAbyss; -using CalamityMod.Items.Placeables.FurnitureMarnite; -using CalamityMod.Tiles.FurnitureMarnite; +using CalamityMod.Items.Placeables.FurnitureMarnite; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.ObjectInteractions; diff --git a/Tiles/FurnitureMarnite/MarniteDresser.cs b/Tiles/FurnitureMarnite/MarniteDresser.cs index 1fb0e65101..d7267513ae 100644 --- a/Tiles/FurnitureMarnite/MarniteDresser.cs +++ b/Tiles/FurnitureMarnite/MarniteDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureMarnite/MarniteLamp.cs b/Tiles/FurnitureMarnite/MarniteLamp.cs index af684fc3d2..ebecc07f93 100644 --- a/Tiles/FurnitureMarnite/MarniteLamp.cs +++ b/Tiles/FurnitureMarnite/MarniteLamp.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureMarnite/MarniteLantern.cs b/Tiles/FurnitureMarnite/MarniteLantern.cs index 808673bd37..82b8d026b8 100644 --- a/Tiles/FurnitureMarnite/MarniteLantern.cs +++ b/Tiles/FurnitureMarnite/MarniteLantern.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureMarnite/MarniteLight.cs b/Tiles/FurnitureMarnite/MarniteLight.cs index 42a4096f54..e335735117 100644 --- a/Tiles/FurnitureMarnite/MarniteLight.cs +++ b/Tiles/FurnitureMarnite/MarniteLight.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureMarnite { public class MarniteLight : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); public override bool CreateDust(int i, int j, ref int type) @@ -56,7 +59,8 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureMarnite/MarniteLightFlame").Value, i, j, 2); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMarnite/MarniteLightFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) @@ -67,7 +71,7 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } //This should probably give torch luck in granite AND marble biomes, this was originally planned for Catalyst diff --git a/Tiles/FurnitureMarnite/MarniteOrgan.cs b/Tiles/FurnitureMarnite/MarniteOrgan.cs index af666e2e06..8bdf8decfc 100644 --- a/Tiles/FurnitureMarnite/MarniteOrgan.cs +++ b/Tiles/FurnitureMarnite/MarniteOrgan.cs @@ -1,8 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; diff --git a/Tiles/FurnitureMarnite/MarniteSofa.cs b/Tiles/FurnitureMarnite/MarniteSofa.cs index d2f3eda4f5..e900bca641 100644 --- a/Tiles/FurnitureMarnite/MarniteSofa.cs +++ b/Tiles/FurnitureMarnite/MarniteSofa.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureMarnite num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureMarnite/MarniteToilet.cs b/Tiles/FurnitureMarnite/MarniteToilet.cs index 2a4a9510f6..ac1087cda1 100644 --- a/Tiles/FurnitureMarnite/MarniteToilet.cs +++ b/Tiles/FurnitureMarnite/MarniteToilet.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -49,11 +48,11 @@ namespace CalamityMod.Tiles.FurnitureMarnite num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info, shitter: true); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, shitter: true); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureMarnite/PolishedMarniteBlock.cs b/Tiles/FurnitureMarnite/PolishedMarniteBlock.cs index 544b0fcab8..a196adc55a 100644 --- a/Tiles/FurnitureMarnite/PolishedMarniteBlock.cs +++ b/Tiles/FurnitureMarnite/PolishedMarniteBlock.cs @@ -12,7 +12,6 @@ namespace CalamityMod.Tiles.FurnitureMarnite public override void SetStaticDefaults() { Main.tileSolid[Type] = true; - Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; TileID.Sets.HasSlopeFrames[Type] = true; Main.tileShine[Type] = 3500; diff --git a/Tiles/FurnitureMonolith/AstralMonolith.cs b/Tiles/FurnitureMonolith/AstralMonolith.cs new file mode 100644 index 0000000000..c34d796537 --- /dev/null +++ b/Tiles/FurnitureMonolith/AstralMonolith.cs @@ -0,0 +1,148 @@ +using CalamityMod.Dusts; +using CalamityMod.Systems; +using CalamityMod.Tiles.Astral; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent.Metadata; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureMonolith +{ + public class AstralMonolith : ModTile + { + private static int sheetWidth = 216; + private static int sheetHeight = 72; + + public Asset GlowTexture; + + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Wood"]); + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeAstralTiles(Type); + CalamityUtils.SetMerge(Type, TileID.LeafBlock); + CalamityUtils.SetMerge(Type, TileID.LivingMahoganyLeaves); + CalamityUtils.SetMerge(Type, TileID.LivingWood); + CalamityUtils.SetMerge(Type, TileID.LivingMahogany); + + AddMapEntry(new Color(45, 36, 63)); + + this.RegisterBlendMergeWith(ModContent.TileType()); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + int xPos = i % 4; + int yPos = j % 4; + + if ((xPos == 0 && yPos == 2) || (xPos == 1 && yPos == 3) || (xPos == 3 && yPos == 1)) + Main.tile[i, j].Get().TileFrameNumber = Main.tile[i, j - 1].TileFrameNumber; + else if (xPos == 2 && yPos == 2) + Main.tile[i, j].Get().TileFrameNumber = Main.tile[i - 1, j].TileFrameNumber; + else if (xPos == 2 && yPos == 3) + Main.tile[i, j].Get().TileFrameNumber = Main.tile[i - 1, j - 1].TileFrameNumber; + + GetDrawSpecifics(i, j, ref xPos, ref yPos); + + frameXOffset = xPos * sheetWidth; + frameYOffset = yPos * sheetHeight; + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + Tile tile = Main.tile[i, j]; + if (tile.IsTileActuallyInvisible()) + return; + + int xOffset = i % 4; + int yOffset = j % 4; + + GetDrawSpecifics(i, j, ref xOffset, ref yOffset); + + xOffset *= sheetWidth; + yOffset *= sheetHeight; + + int xPos = tile.TileFrameX; + int yPos = tile.TileFrameY; + xPos += xOffset; + yPos += yOffset; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/AstralMonolithGlow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(50, 50, 50, 50)); + if (!tile.IsHalfBlock && tile.Slope == 0) + { + Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + else if (tile.IsHalfBlock) + { + 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); + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; + } + + private void GetDrawSpecifics(int i, int j, ref int xPos, ref int yPos) + { + Tile tile = Main.tile[i, j]; + // Make sure the features work as intended + if (tile.TileFrameNumber == 1) + { + if (xPos == 0 && (yPos == 1 || yPos == 2)) + yPos += 3; + else if ((xPos == 1 || xPos == 2) && (yPos == 2 || yPos == 3)) + yPos += 2; + else if (xPos == 3 && (yPos == 0 || yPos == 1)) + yPos += 4; + } + else if (tile.TileFrameNumber == 2) + { + if (xPos == 1 && yPos == 0) + { + xPos = 0; + yPos = 6; + } + else if (xPos == 2 && yPos == 1) + { + xPos = 1; + yPos = 6; + } + else if (xPos == 1 && yPos == 3) + { + xPos = 2; + yPos = 6; + } + else if (xPos == 3 && yPos == 3) + { + xPos = 3; + yPos = 6; + } + } + } + + public override bool IsTileBiomeSightable(int i, int j, ref Color sightColor) + { + sightColor = Color.Cyan; + return true; + } + } +} diff --git a/Tiles/Astral/AstralMonolith.png b/Tiles/FurnitureMonolith/AstralMonolith.png similarity index 100% rename from Tiles/Astral/AstralMonolith.png rename to Tiles/FurnitureMonolith/AstralMonolith.png diff --git a/Tiles/Astral/AstralMonolithGlow.png b/Tiles/FurnitureMonolith/AstralMonolithGlow.png similarity index 100% rename from Tiles/Astral/AstralMonolithGlow.png rename to Tiles/FurnitureMonolith/AstralMonolithGlow.png diff --git a/Tiles/FurnitureMonolith/MonolithAmalgam.cs b/Tiles/FurnitureMonolith/MonolithAmalgam.cs new file mode 100644 index 0000000000..b71202f347 --- /dev/null +++ b/Tiles/FurnitureMonolith/MonolithAmalgam.cs @@ -0,0 +1,49 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureMonolith +{ + [LegacyName("MonolithCrafting")] + public class MonolithAmalgam : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() + { + this.SetUpBookcase(ModContent.ItemType(), true, false, false); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + 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) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xPos = Main.tile[i, j].TileFrameX; + int yPos = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithAmalgamGlow"); + Texture2D glowmask = GlowTexture.Value; + + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; + Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/Furniture/CraftingStations/MonolithAmalgam.png b/Tiles/FurnitureMonolith/MonolithAmalgam.png similarity index 100% rename from Tiles/Furniture/CraftingStations/MonolithAmalgam.png rename to Tiles/FurnitureMonolith/MonolithAmalgam.png diff --git a/Tiles/Furniture/CraftingStations/MonolithAmalgamGlow.png b/Tiles/FurnitureMonolith/MonolithAmalgamGlow.png similarity index 100% rename from Tiles/Furniture/CraftingStations/MonolithAmalgamGlow.png rename to Tiles/FurnitureMonolith/MonolithAmalgamGlow.png diff --git a/Tiles/FurnitureMonolith/MonolithBathtub.cs b/Tiles/FurnitureMonolith/MonolithBathtub.cs index b73e969cec..27ad5385fc 100644 --- a/Tiles/FurnitureMonolith/MonolithBathtub.cs +++ b/Tiles/FurnitureMonolith/MonolithBathtub.cs @@ -1,12 +1,15 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithBathtub : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); public override bool CreateDust(int i, int j, ref int type) @@ -27,7 +30,10 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBathtubGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBathtubGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; diff --git a/Tiles/FurnitureMonolith/MonolithBed.cs b/Tiles/FurnitureMonolith/MonolithBed.cs index 12feb19543..3cae0a4930 100644 --- a/Tiles/FurnitureMonolith/MonolithBed.cs +++ b/Tiles/FurnitureMonolith/MonolithBed.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithBed : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -29,7 +32,10 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBedGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBedGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; @@ -38,8 +44,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureMonolith/MonolithBench.cs b/Tiles/FurnitureMonolith/MonolithBench.cs index ed8dfb3702..c9a7dc700e 100644 --- a/Tiles/FurnitureMonolith/MonolithBench.cs +++ b/Tiles/FurnitureMonolith/MonolithBench.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithBench : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), true, true); public override bool CreateDust(int i, int j, ref int type) @@ -30,18 +33,21 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBenchGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBenchGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureMonolith/MonolithBookcase.cs b/Tiles/FurnitureMonolith/MonolithBookcase.cs index f0f2539b8a..27dee140a6 100644 --- a/Tiles/FurnitureMonolith/MonolithBookcase.cs +++ b/Tiles/FurnitureMonolith/MonolithBookcase.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithBookcase : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType(), true, false); public override bool CreateDust(int i, int j, ref int type) @@ -28,7 +31,10 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBookcaseGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithBookcaseGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; diff --git a/Tiles/FurnitureMonolith/MonolithCandelabra.cs b/Tiles/FurnitureMonolith/MonolithCandelabra.cs index f473367d54..699c5427ae 100644 --- a/Tiles/FurnitureMonolith/MonolithCandelabra.cs +++ b/Tiles/FurnitureMonolith/MonolithCandelabra.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +9,9 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithCandelabra : ModTile { + public Asset GlowTexture; + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -28,14 +32,15 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandelabraGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandelabraGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - Texture2D glowmaskBright = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandelabraFlame").Value; - Main.spriteBatch.Draw(glowmaskBright, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandelabraFlame"); + Main.spriteBatch.Draw(FlameTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -56,7 +61,7 @@ namespace CalamityMod.Tiles.FurnitureMonolith public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureMonolith/MonolithCandle.cs b/Tiles/FurnitureMonolith/MonolithCandle.cs index de740ac133..7f4d1b6a3b 100644 --- a/Tiles/FurnitureMonolith/MonolithCandle.cs +++ b/Tiles/FurnitureMonolith/MonolithCandle.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +9,9 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithCandle : ModTile { + public Asset GlowTexture; + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -28,14 +32,15 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandleGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandleGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y - 4) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 20)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 20)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - Texture2D glowmaskBright = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandleFlame").Value; - Main.spriteBatch.Draw(glowmaskBright, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 20)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithCandleFlame"); + Main.spriteBatch.Draw(FlameTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 20)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -56,7 +61,7 @@ namespace CalamityMod.Tiles.FurnitureMonolith public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -69,7 +74,7 @@ namespace CalamityMod.Tiles.FurnitureMonolith public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureMonolith/MonolithChair.cs b/Tiles/FurnitureMonolith/MonolithChair.cs index db53d4f6a4..b92a8f9bfe 100644 --- a/Tiles/FurnitureMonolith/MonolithChair.cs +++ b/Tiles/FurnitureMonolith/MonolithChair.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -11,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithChair : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpChair(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -31,18 +34,18 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithChairGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithChairGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureMonolith/MonolithChandelier.cs b/Tiles/FurnitureMonolith/MonolithChandelier.cs index 45753af8b7..67d8b139a9 100644 --- a/Tiles/FurnitureMonolith/MonolithChandelier.cs +++ b/Tiles/FurnitureMonolith/MonolithChandelier.cs @@ -1,13 +1,24 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithChandelier : ModTile { + public Asset FlameTexture; + public Asset GlowTexture; + + public override void Load() + { + FlameTexture = ModContent.Request(Texture + "Flame"); + GlowTexture = ModContent.Request(Texture + "Glow"); + } + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -23,22 +34,7 @@ namespace CalamityMod.Tiles.FurnitureMonolith num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - if (Main.tile[i, j].IsTileActuallyInvisible()) - return; - - int xPos = Main.tile[i, j].TileFrameX; - int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithChandelierGlow").Value; - Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - - Texture2D glowmaskBright = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithChandelierFlame").Value; - Main.spriteBatch.Draw(glowmaskBright, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - } + public override void AdjustMultiTileVineParameters(int i, int j, ref float? overrideWindCycle, ref float windPushPowerX, ref float windPushPowerY, ref bool dontRotateTopTiles, ref float totalWindMultiplier, ref Texture2D glowTexture, ref Color glowColor) => glowTexture = GlowTexture.Value; public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { @@ -56,9 +52,24 @@ namespace CalamityMod.Tiles.FurnitureMonolith } } + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) + { + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 1; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0f; + tileFlameData.flameRangeMultY = 0f; + } + public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureMonolith/MonolithChest.cs b/Tiles/FurnitureMonolith/MonolithChest.cs index 1f294cf3d9..beee38d84e 100644 --- a/Tiles/FurnitureMonolith/MonolithChest.cs +++ b/Tiles/FurnitureMonolith/MonolithChest.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.GameContent.ObjectInteractions; @@ -13,10 +14,12 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithChest : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -28,8 +31,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); public override bool RightClick(int i, int j) { @@ -59,7 +62,7 @@ namespace CalamityMod.Tiles.FurnitureMonolith } } - return CalamityUtils.ChestRightClick(i, j); + return FurnitureCommon.ChestRightClick(i, j); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) @@ -75,11 +78,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith return; int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithChestGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithChestGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y + yOffset) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)); Rectangle frame = new Rectangle(xPos, yPos + Main.chest[chestIndex].frame * 38, 18, 18); - Main.spriteBatch.Draw(glowmask, drawOffset, frame, drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, frame, drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/FurnitureMonolith/MonolithClock.cs b/Tiles/FurnitureMonolith/MonolithClock.cs index 6dae46ac7d..0a253676cc 100644 --- a/Tiles/FurnitureMonolith/MonolithClock.cs +++ b/Tiles/FurnitureMonolith/MonolithClock.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithClock : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType(), true); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; @@ -31,16 +34,16 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithClockGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithClockGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -51,6 +54,6 @@ namespace CalamityMod.Tiles.FurnitureMonolith } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureMonolith/MonolithDoorClosed.cs b/Tiles/FurnitureMonolith/MonolithDoorClosed.cs index 52b85d4d81..1f2c030067 100644 --- a/Tiles/FurnitureMonolith/MonolithDoorClosed.cs +++ b/Tiles/FurnitureMonolith/MonolithDoorClosed.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithDoorClosed : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpDoorClosed(ModContent.ItemType(), true); @@ -34,11 +37,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithDoorClosedGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithDoorClosedGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; diff --git a/Tiles/FurnitureMonolith/MonolithDoorOpen.cs b/Tiles/FurnitureMonolith/MonolithDoorOpen.cs index 782985f901..0051406de0 100644 --- a/Tiles/FurnitureMonolith/MonolithDoorOpen.cs +++ b/Tiles/FurnitureMonolith/MonolithDoorOpen.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Placeables.FurnitureMonolith; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -11,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithDoorOpen : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpDoorOpen(ModContent.ItemType(), true); @@ -35,11 +38,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithDoorOpenGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithDoorOpenGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; diff --git a/Tiles/FurnitureMonolith/MonolithDresser.cs b/Tiles/FurnitureMonolith/MonolithDresser.cs index fb8af48ee6..159a0f18d4 100644 --- a/Tiles/FurnitureMonolith/MonolithDresser.cs +++ b/Tiles/FurnitureMonolith/MonolithDresser.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.Localization; @@ -10,10 +11,12 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithDresser : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,10 +28,10 @@ namespace CalamityMod.Tiles.FurnitureMonolith public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -37,11 +40,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithDresserGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithDresserGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/FurnitureMonolith/MonolithLamp.cs b/Tiles/FurnitureMonolith/MonolithLamp.cs index eb49dc8399..4b55adae89 100644 --- a/Tiles/FurnitureMonolith/MonolithLamp.cs +++ b/Tiles/FurnitureMonolith/MonolithLamp.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +9,9 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithLamp : ModTile { + public Asset GlowTexture; + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -28,14 +32,14 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithLampGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithLampGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - Texture2D glowmaskBright = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithLampFlame").Value; - Main.spriteBatch.Draw(glowmaskBright, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithLampFlame"); + Main.spriteBatch.Draw(FlameTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) @@ -56,7 +60,7 @@ namespace CalamityMod.Tiles.FurnitureMonolith public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureMonolith/MonolithLantern.cs b/Tiles/FurnitureMonolith/MonolithLantern.cs index c5a2cc2c2e..30c5856b3a 100644 --- a/Tiles/FurnitureMonolith/MonolithLantern.cs +++ b/Tiles/FurnitureMonolith/MonolithLantern.cs @@ -1,13 +1,24 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithLantern : ModTile { + public Asset FlameTexture; + public Asset GlowTexture; + + public override void Load() + { + FlameTexture = ModContent.Request(Texture + "Flame"); + GlowTexture = ModContent.Request(Texture + "Glow"); + } + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -22,22 +33,7 @@ namespace CalamityMod.Tiles.FurnitureMonolith num = fail ? 1 : 3; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - if (Main.tile[i, j].IsTileActuallyInvisible()) - return; - - int xPos = Main.tile[i, j].TileFrameX; - int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithLanternGlow").Value; - Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); - Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - - Texture2D glowmaskBright = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithLanternFlame").Value; - Main.spriteBatch.Draw(glowmaskBright, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); - } + public override void AdjustMultiTileVineParameters(int i, int j, ref float? overrideWindCycle, ref float windPushPowerX, ref float windPushPowerY, ref bool dontRotateTopTiles, ref float totalWindMultiplier, ref Texture2D glowTexture, ref Color glowColor) => glowTexture = GlowTexture.Value; public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { @@ -55,9 +51,24 @@ namespace CalamityMod.Tiles.FurnitureMonolith } } + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) + { + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 1; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0f; + tileFlameData.flameRangeMultY = 0f; + } + public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureMonolith/MonolithPiano.cs b/Tiles/FurnitureMonolith/MonolithPiano.cs index 707a910882..21c4cb455d 100644 --- a/Tiles/FurnitureMonolith/MonolithPiano.cs +++ b/Tiles/FurnitureMonolith/MonolithPiano.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithPiano : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpPiano(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -30,11 +33,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithPianoGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithPianoGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/FurnitureMonolith/MonolithSink.cs b/Tiles/FurnitureMonolith/MonolithSink.cs index 3af8655a3e..621fa27628 100644 --- a/Tiles/FurnitureMonolith/MonolithSink.cs +++ b/Tiles/FurnitureMonolith/MonolithSink.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithSink : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -28,11 +31,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithSinkGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithSinkGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/FurnitureMonolith/MonolithTable.cs b/Tiles/FurnitureMonolith/MonolithTable.cs index 183aa97e60..0cb966cdd9 100644 --- a/Tiles/FurnitureMonolith/MonolithTable.cs +++ b/Tiles/FurnitureMonolith/MonolithTable.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithTable : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -28,11 +31,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithTableGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithTableGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/FurnitureMonolith/MonolithWorkbench.cs b/Tiles/FurnitureMonolith/MonolithWorkbench.cs index 4e27709e66..57dd62bce0 100644 --- a/Tiles/FurnitureMonolith/MonolithWorkbench.cs +++ b/Tiles/FurnitureMonolith/MonolithWorkbench.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureMonolith { public class MonolithWorkBench : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -28,11 +31,11 @@ namespace CalamityMod.Tiles.FurnitureMonolith int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithWorkBenchGlow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureMonolith/MonolithWorkBenchGlow"); Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; - Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(GlowTexture.Value, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } } } diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.cs new file mode 100644 index 0000000000..7fa416acca --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBathtub")] + public class AncientNavystoneBathtub : ModTile + { + public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicBathtub.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicBathtub.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBathtub.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.cs new file mode 100644 index 0000000000..b70b2a4802 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.cs @@ -0,0 +1,31 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBed")] + public class AncientNavystoneBed : ModTile + { + public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicBed.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicBed.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed.png diff --git a/Tiles/FurnitureEutrophic/EutrophicBed_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicBed_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBed_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.cs new file mode 100644 index 0000000000..1c576e4a5a --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBench")] + public class AncientNavystoneBench : ModTile + { + public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), false, true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicBench.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicBench.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench.png diff --git a/Tiles/FurnitureEutrophic/EutrophicBench_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicBench_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBench_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.cs new file mode 100644 index 0000000000..d4411a6561 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicBookcase")] + public class AncientNavystoneBookcase : ModTile + { + public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicBookcase.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicBookcase.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneBookcase.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.cs new file mode 100644 index 0000000000..7bef64fa3c --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.cs @@ -0,0 +1,45 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicCandelabra")] + public class AncientNavystoneCandelabra : ModTile + { + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicCandelabra.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicCandelabra.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandelabra.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.cs new file mode 100644 index 0000000000..7404840095 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.cs @@ -0,0 +1,59 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicCandle")] + public class AncientNavystoneCandle : ModTile + { + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicCandle.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicCandle.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneCandle.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.cs new file mode 100644 index 0000000000..bdf8c22e61 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicChair")] + public class AncientNavystoneChair : ModTile + { + public override void SetStaticDefaults() => this.SetUpChair(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicChair.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicChair.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair.png diff --git a/Tiles/FurnitureEutrophic/EutrophicChair_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicChair_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChair_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.cs new file mode 100644 index 0000000000..5e68b51d3a --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.cs @@ -0,0 +1,48 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicChandelier")] + public class AncientNavystoneChandelier : ModTile + { + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType()); + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicChandelier.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicChandelier.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChandelier.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.cs new file mode 100644 index 0000000000..e2abdce520 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicChest")] + public class AncientNavystoneChest : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpChest(ModContent.ItemType(), true); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicChest.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicChest.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest.png diff --git a/Tiles/FurnitureEutrophic/EutrophicChest_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicChest_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneChest_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.cs new file mode 100644 index 0000000000..3e5181b917 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.cs @@ -0,0 +1,58 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicClock")] + public class AncientNavystoneClock : ModTile + { + public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool RightClick(int x, int y) + { + return FurnitureCommon.ClockRightClick(); + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (closer) + { + Main.SceneMetrics.HasClock = true; + } + } + + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicClock.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicClock.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock.png diff --git a/Tiles/FurnitureEutrophic/EutrophicClock_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicClock_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneClock_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorClosed.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorClosed.cs new file mode 100644 index 0000000000..eac29d4996 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorClosed.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicDoorClosed")] + public class AncientNavystoneDoorClosed : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorClosed(ModContent.ItemType()); + TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicDoorClosed.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorClosed.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicDoorClosed.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorClosed.png diff --git a/Tiles/FurnitureEutrophic/EutrophicDoorClosed_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorClosed_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicDoorClosed_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorClosed_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorOpen.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorOpen.cs new file mode 100644 index 0000000000..71eccec759 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorOpen.cs @@ -0,0 +1,40 @@ +using CalamityMod.Items.Placeables.FurnitureNavystone.FurnitureAncientNavystone; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicDoorOpen")] + public class AncientNavystoneDoorOpen : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorOpen(ModContent.ItemType()); + TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicDoorOpen.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorOpen.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicDoorOpen.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorOpen.png diff --git a/Tiles/FurnitureEutrophic/EutrophicDoorOpen_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorOpen_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicDoorOpen_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDoorOpen_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.cs new file mode 100644 index 0000000000..5211b274cb --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicDresser")] + public class AncientNavystoneDresser : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDresser(ModContent.ItemType()); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicDresser.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicDresser.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser.png diff --git a/Tiles/FurnitureEutrophic/EutrophicDresser_Highlight.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser_Highlight.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicDresser_Highlight.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneDresser_Highlight.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.cs new file mode 100644 index 0000000000..6f85a8eb76 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.cs @@ -0,0 +1,45 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicLamp")] + public class AncientNavystoneLamp : ModTile + { + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicLamp.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicLamp.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLamp.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.cs new file mode 100644 index 0000000000..ab63e76c43 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.cs @@ -0,0 +1,47 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicLantern")] + public class AncientNavystoneLantern : ModTile + { + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType()); + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicLantern.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicLantern.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneLantern.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.cs new file mode 100644 index 0000000000..a085e8e67f --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicPiano")] + public class AncientNavystonePiano : ModTile + { + public override void SetStaticDefaults() => this.SetUpPiano(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicPiano.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicPiano.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePiano.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.cs new file mode 100644 index 0000000000..94b3503972 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.cs @@ -0,0 +1,29 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicPlatform")] + public class AncientNavystonePlatform : ModTile + { + public override void SetStaticDefaults() => this.SetUpPlatform(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void PostSetDefaults() + { + Main.tileNoSunLight[Type] = false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicPlatform.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicPlatform.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystonePlatform.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.cs new file mode 100644 index 0000000000..4f7ab93d33 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicSink")] + public class AncientNavystoneSink : ModTile + { + public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicSink.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicSink.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneSink.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.cs new file mode 100644 index 0000000000..46cf5a9a78 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicTable")] + public class AncientNavystoneTable : ModTile + { + public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicTable.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicTable.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneTable.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.cs new file mode 100644 index 0000000000..2f52f6e75b --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicWorkBench")] + public class AncientNavystoneWorkBench : ModTile + { + public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/EutrophicWorkBench.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.png similarity index 100% rename from Tiles/FurnitureEutrophic/EutrophicWorkBench.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientNavystoneWorkBench.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.cs new file mode 100644 index 0000000000..bee411f11d --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.cs @@ -0,0 +1,33 @@ + +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + public class AncientSmoothNavystone : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileMergeDirt[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeSmoothTiles(Type); + CalamityUtils.MergeDecorativeTiles(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Tink; + AddMapEntry(new Color(39, 48, 53)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + } +} diff --git a/Tiles/FurnitureEutrophic/AncientSmoothNavystone.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.png similarity index 100% rename from Tiles/FurnitureEutrophic/AncientSmoothNavystone.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/AncientSmoothNavystone.png diff --git a/Tiles/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.cs b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.cs new file mode 100644 index 0000000000..010779aa70 --- /dev/null +++ b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.cs @@ -0,0 +1,67 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone +{ + [LegacyName("EutrophicCrafting")] + public class EutrophicShelf : ModTile + { + // + // Note from Ozzatron: + // It's highly recommended you don't touch this code unless absolutely necessary. + // Even slightly changing the way that this tile initializes could re-introduce the Ancients Awakened worldgen bug. + // + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 2; + // Remove the bottom anchor entirely, this thing hangs from the wall. + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 1); + + // When this Direction property set executes, newTile._tileObjectBase gets separated from Style3x3._tileObjectBase. + // As such, no data corruption occurs. + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + // Add a wall anchor on the opposite side for the alternate style, and remove the wall anchor that was on the first side. + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 1); + TileObjectData.newAlternate.AnchorRight = AnchorData.Empty; + + // This line used to corrupt TileObjectData.Style3x3.Direction to PlaceRight. This has now been fixed. + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(Type); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); + AnimationFrameHeight = 54; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.5f; + g = 1f; + b = 1f; + } + } +} diff --git a/Tiles/Furniture/CraftingStations/EutrophicShelf.png b/Tiles/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.png similarity index 100% rename from Tiles/Furniture/CraftingStations/EutrophicShelf.png rename to Tiles/FurnitureNavystone/FurnitureAncientNavystone/EutrophicShelf.png diff --git a/Tiles/FurnitureNavystone/NavystoneBathtub.cs b/Tiles/FurnitureNavystone/NavystoneBathtub.cs new file mode 100644 index 0000000000..67b72afb56 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneBathtub.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneBathtub : ModTile + { + public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneBathtub.png b/Tiles/FurnitureNavystone/NavystoneBathtub.png new file mode 100644 index 0000000000..60f3952cb5 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneBathtub.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneBed.cs b/Tiles/FurnitureNavystone/NavystoneBed.cs new file mode 100644 index 0000000000..0610cb397a --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneBed.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneBed : ModTile + { + public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneBed.png b/Tiles/FurnitureNavystone/NavystoneBed.png new file mode 100644 index 0000000000..001728bd9a Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneBed.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneBed_Highlight.png b/Tiles/FurnitureNavystone/NavystoneBed_Highlight.png new file mode 100644 index 0000000000..b11dd25886 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneBed_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneBookcase.cs b/Tiles/FurnitureNavystone/NavystoneBookcase.cs new file mode 100644 index 0000000000..0ac994ccfa --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneBookcase.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneBookcase : ModTile + { + public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneBookcase.png b/Tiles/FurnitureNavystone/NavystoneBookcase.png new file mode 100644 index 0000000000..85c12525fb Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneBookcase.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneCandelabra.cs b/Tiles/FurnitureNavystone/NavystoneCandelabra.cs new file mode 100644 index 0000000000..f51a0eb395 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneCandelabra.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneCandelabra : ModTile + { + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneCandelabra.png b/Tiles/FurnitureNavystone/NavystoneCandelabra.png new file mode 100644 index 0000000000..09672ac1cb Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneCandelabra.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneCandle.cs b/Tiles/FurnitureNavystone/NavystoneCandle.cs new file mode 100644 index 0000000000..12a0b83b1b --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneCandle.cs @@ -0,0 +1,58 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneCandle : ModTile + { + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneCandle.png b/Tiles/FurnitureNavystone/NavystoneCandle.png new file mode 100644 index 0000000000..e1fe5f8507 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneCandle.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneChair.cs b/Tiles/FurnitureNavystone/NavystoneChair.cs new file mode 100644 index 0000000000..fb7a53f1f6 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneChair.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneChair : ModTile + { + public override void SetStaticDefaults() => this.SetUpChair(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneChair.png b/Tiles/FurnitureNavystone/NavystoneChair.png new file mode 100644 index 0000000000..30c65cd137 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneChair.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneChair_Highlight.png b/Tiles/FurnitureNavystone/NavystoneChair_Highlight.png new file mode 100644 index 0000000000..fca0c61d27 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneChair_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneChandelier.cs b/Tiles/FurnitureNavystone/NavystoneChandelier.cs new file mode 100644 index 0000000000..982a8ffaa8 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneChandelier.cs @@ -0,0 +1,47 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneChandelier : ModTile + { + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType()); + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneChandelier.png b/Tiles/FurnitureNavystone/NavystoneChandelier.png new file mode 100644 index 0000000000..9cc4db1d1c Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneChandelier.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneChest.cs b/Tiles/FurnitureNavystone/NavystoneChest.cs new file mode 100644 index 0000000000..24e9543744 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneChest.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneChest : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpChest(ModContent.ItemType(), true); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneChest.png b/Tiles/FurnitureNavystone/NavystoneChest.png new file mode 100644 index 0000000000..b77c5ad9e5 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneChest.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneChest_Highlight.png b/Tiles/FurnitureNavystone/NavystoneChest_Highlight.png new file mode 100644 index 0000000000..721846627a Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneChest_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneClock.cs b/Tiles/FurnitureNavystone/NavystoneClock.cs new file mode 100644 index 0000000000..237fecd83c --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneClock.cs @@ -0,0 +1,57 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneClock : ModTile + { + public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool RightClick(int x, int y) + { + return FurnitureCommon.ClockRightClick(); + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (closer) + { + Main.SceneMetrics.HasClock = true; + } + } + + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneClock.png b/Tiles/FurnitureNavystone/NavystoneClock.png new file mode 100644 index 0000000000..ee92788132 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneClock.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneClock_Highlight.png b/Tiles/FurnitureNavystone/NavystoneClock_Highlight.png new file mode 100644 index 0000000000..813835a873 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneClock_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneDoorClosed.cs b/Tiles/FurnitureNavystone/NavystoneDoorClosed.cs new file mode 100644 index 0000000000..1d65b6c141 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneDoorClosed.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneDoorClosed : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorClosed(ModContent.ItemType()); + TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneDoorClosed.png b/Tiles/FurnitureNavystone/NavystoneDoorClosed.png new file mode 100644 index 0000000000..f54be56f60 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneDoorClosed.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneDoorClosed_Highlight.png b/Tiles/FurnitureNavystone/NavystoneDoorClosed_Highlight.png new file mode 100644 index 0000000000..e212eaa1db Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneDoorClosed_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneDoorOpen.cs b/Tiles/FurnitureNavystone/NavystoneDoorOpen.cs new file mode 100644 index 0000000000..9a319a1f1e --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneDoorOpen.cs @@ -0,0 +1,39 @@ +using CalamityMod.Items.Placeables.FurnitureNavystone; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneDoorOpen : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorOpen(ModContent.ItemType()); + TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneDoorOpen.png b/Tiles/FurnitureNavystone/NavystoneDoorOpen.png new file mode 100644 index 0000000000..409dfbc48d Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneDoorOpen.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneDoorOpen_Highlight.png b/Tiles/FurnitureNavystone/NavystoneDoorOpen_Highlight.png new file mode 100644 index 0000000000..6b2214683a Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneDoorOpen_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneDresser.cs b/Tiles/FurnitureNavystone/NavystoneDresser.cs new file mode 100644 index 0000000000..0c01b562bf --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneDresser.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneDresser : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDresser(ModContent.ItemType()); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneDresser.png b/Tiles/FurnitureNavystone/NavystoneDresser.png new file mode 100644 index 0000000000..b720409b99 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneDresser.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneDresser_Highlight.png b/Tiles/FurnitureNavystone/NavystoneDresser_Highlight.png new file mode 100644 index 0000000000..4caa037707 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneDresser_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneLamp.cs b/Tiles/FurnitureNavystone/NavystoneLamp.cs new file mode 100644 index 0000000000..be16be5ca3 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneLamp.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneLamp : ModTile + { + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneLamp.png b/Tiles/FurnitureNavystone/NavystoneLamp.png new file mode 100644 index 0000000000..8b639f35dc Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneLamp.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneLantern.cs b/Tiles/FurnitureNavystone/NavystoneLantern.cs new file mode 100644 index 0000000000..3d39c567bf --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneLantern.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneLantern : ModTile + { + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType()); + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 0.5f; + g = 1f; + b = 1f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneLantern.png b/Tiles/FurnitureNavystone/NavystoneLantern.png new file mode 100644 index 0000000000..85eea88754 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneLantern.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneLyre.cs b/Tiles/FurnitureNavystone/NavystoneLyre.cs new file mode 100644 index 0000000000..5880f7e163 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneLyre.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneLyre : ModTile + { + public override void SetStaticDefaults() => this.SetUpPiano(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneLyre.png b/Tiles/FurnitureNavystone/NavystoneLyre.png new file mode 100644 index 0000000000..e797fd1cb9 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneLyre.png differ diff --git a/Tiles/FurnitureNavystone/NavystonePlatform.cs b/Tiles/FurnitureNavystone/NavystonePlatform.cs new file mode 100644 index 0000000000..953bc547c3 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystonePlatform.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystonePlatform : ModTile + { + public override void SetStaticDefaults() => this.SetUpPlatform(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void PostSetDefaults() + { + Main.tileNoSunLight[Type] = false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystonePlatform.png b/Tiles/FurnitureNavystone/NavystonePlatform.png new file mode 100644 index 0000000000..3f97fc569b Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystonePlatform.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneSink.cs b/Tiles/FurnitureNavystone/NavystoneSink.cs new file mode 100644 index 0000000000..c276114d43 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneSink.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneSink : ModTile + { + public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneSink.png b/Tiles/FurnitureNavystone/NavystoneSink.png new file mode 100644 index 0000000000..1410a1a3db Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneSink.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneTable.cs b/Tiles/FurnitureNavystone/NavystoneTable.cs new file mode 100644 index 0000000000..e9997d1652 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneTable.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneTable : ModTile + { + public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneTable.png b/Tiles/FurnitureNavystone/NavystoneTable.png new file mode 100644 index 0000000000..fbcdd63309 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneTable.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneToilet.cs b/Tiles/FurnitureNavystone/NavystoneToilet.cs new file mode 100644 index 0000000000..7e4c67f640 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneToilet.cs @@ -0,0 +1,78 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneToilet : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileWaterDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(Type); + + // Toilets count as Chairs + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Toilet")); + TileID.Sets.CanBeSatOnForNPCs[Type] = true; + TileID.Sets.CanBeSatOnForPlayers[Type] = true; + TileID.Sets.HasOutlines[Type] = true; + AdjTiles = new int[] { TileID.Chairs }; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Granite, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, shitter: true); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + + public override void HitWire(int i, int j) // I hate this please make it stop. - Merkalto + { + Tile tile = Main.tile[i, j]; + + int spawnX = i; + int spawnY = j - tile.TileFrameY / 18; + + Wiring.SkipWire(spawnX, spawnY); + Wiring.SkipWire(spawnX, spawnY + 1); + + if (Wiring.CheckMech(spawnX, spawnY, 60)) + { + Projectile.NewProjectile(Wiring.GetProjectileSource(spawnX, spawnY), spawnX * 16 + 8, spawnY * 16 + 12, 0f, 0f, ProjectileID.ToiletEffect, 0, 0f, Main.myPlayer); + } + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneToilet.png b/Tiles/FurnitureNavystone/NavystoneToilet.png new file mode 100644 index 0000000000..470aaf68a0 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneToilet.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneToilet_Highlight.png b/Tiles/FurnitureNavystone/NavystoneToilet_Highlight.png new file mode 100644 index 0000000000..5d2772081a Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneToilet_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneTriclinium.cs b/Tiles/FurnitureNavystone/NavystoneTriclinium.cs new file mode 100644 index 0000000000..e2da163b54 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneTriclinium.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneTriclinium : ModTile + { + public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), false, true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneTriclinium.png b/Tiles/FurnitureNavystone/NavystoneTriclinium.png new file mode 100644 index 0000000000..68cdff63d5 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneTriclinium.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneTriclinium_Highlight.png b/Tiles/FurnitureNavystone/NavystoneTriclinium_Highlight.png new file mode 100644 index 0000000000..8376806503 Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneTriclinium_Highlight.png differ diff --git a/Tiles/FurnitureNavystone/NavystoneWorkBench.cs b/Tiles/FurnitureNavystone/NavystoneWorkBench.cs new file mode 100644 index 0000000000..162a074600 --- /dev/null +++ b/Tiles/FurnitureNavystone/NavystoneWorkBench.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class NavystoneWorkBench : ModTile + { + public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureNavystone/NavystoneWorkBench.png b/Tiles/FurnitureNavystone/NavystoneWorkBench.png new file mode 100644 index 0000000000..5cf0c4842b Binary files /dev/null and b/Tiles/FurnitureNavystone/NavystoneWorkBench.png differ diff --git a/Tiles/FurnitureNavystone/PolishedNavystoneBrick.cs b/Tiles/FurnitureNavystone/PolishedNavystoneBrick.cs new file mode 100644 index 0000000000..8c712d9196 --- /dev/null +++ b/Tiles/FurnitureNavystone/PolishedNavystoneBrick.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.Systems; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class PolishedNavystoneBrick : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + CalamityUtils.MergeWithGeneral(Type); + TileID.Sets.HasSlopeFrames[Type] = true; + + HitSound = SoundID.Tink; + DustType = DustID.BlueMoss; + AddMapEntry(new Color(53, 99, 117)); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/PolishedNavystoneBrick.png b/Tiles/FurnitureNavystone/PolishedNavystoneBrick.png similarity index 100% rename from Tiles/SunkenSea/PolishedNavystoneBrick.png rename to Tiles/FurnitureNavystone/PolishedNavystoneBrick.png diff --git a/Tiles/FurnitureNavystone/SmoothNavystone.cs b/Tiles/FurnitureNavystone/SmoothNavystone.cs new file mode 100644 index 0000000000..c6c8a76ba0 --- /dev/null +++ b/Tiles/FurnitureNavystone/SmoothNavystone.cs @@ -0,0 +1,40 @@ + +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureNavystone +{ + public class SmoothNavystone : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeSmoothTiles(Type); + CalamityUtils.MergeDecorativeTiles(Type); + CalamityUtils.MergeWithAbyss(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; + HitSound = SoundID.Tink; + DustType = DustID.BlueMoss; + AddMapEntry(new Color(44, 57, 64)); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureEutrophic/SmoothNavystone.png b/Tiles/FurnitureNavystone/SmoothNavystone.png similarity index 100% rename from Tiles/FurnitureEutrophic/SmoothNavystone.png rename to Tiles/FurnitureNavystone/SmoothNavystone.png diff --git a/Tiles/FurnitureNavystone/SmoothSeaPrism.png b/Tiles/FurnitureNavystone/SmoothSeaPrism.png new file mode 100644 index 0000000000..de3c3f7ec7 Binary files /dev/null and b/Tiles/FurnitureNavystone/SmoothSeaPrism.png differ diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyBed.cs b/Tiles/FurnitureOtherworldly/OtherworldlyBed.cs index 26d5307a60..1b8da8fbe1 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyBed.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyBed.cs @@ -26,8 +26,8 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyCandelabra.cs b/Tiles/FurnitureOtherworldly/OtherworldlyCandelabra.cs index b2b86dd2ef..abb59908c0 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyCandelabra.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyCandelabra.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyCandle.cs b/Tiles/FurnitureOtherworldly/OtherworldlyCandle.cs index b61dec5702..5860a8a4ff 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyCandle.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyCandle.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -54,7 +54,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyChair.cs b/Tiles/FurnitureOtherworldly/OtherworldlyChair.cs index 28791c6901..e48e61657e 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyChair.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyChair.cs @@ -26,11 +26,11 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyChandelier.cs b/Tiles/FurnitureOtherworldly/OtherworldlyChandelier.cs index 7180331195..ff39bfad86 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyChandelier.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyChandelier.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyChest.cs b/Tiles/FurnitureOtherworldly/OtherworldlyChest.cs index fb1a5c126a..a4f45939b1 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyChest.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyChest.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -27,9 +27,9 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyClock.cs b/Tiles/FurnitureOtherworldly/OtherworldlyClock.cs index ee87aee50c..e0162aca8c 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyClock.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyClock.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -39,6 +39,6 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyDresser.cs b/Tiles/FurnitureOtherworldly/OtherworldlyDresser.cs index a090ae75ee..31f4a2100a 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyDresser.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyDresser.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -27,9 +27,9 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyLamp.cs b/Tiles/FurnitureOtherworldly/OtherworldlyLamp.cs index f80627967c..b8547b8e93 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyLamp.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyLamp.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyLantern.cs b/Tiles/FurnitureOtherworldly/OtherworldlyLantern.cs index 919c12d846..7e900083f4 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyLantern.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyLantern.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureOtherworldly/OtherworldlySofa.cs b/Tiles/FurnitureOtherworldly/OtherworldlySofa.cs index 76ed16933e..b82f0feac3 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlySofa.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlySofa.cs @@ -26,11 +26,11 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureOtherworldly/OtherworldlyStone.cs b/Tiles/FurnitureOtherworldly/OtherworldlyStone.cs index 3948395809..1d736949b8 100644 --- a/Tiles/FurnitureOtherworldly/OtherworldlyStone.cs +++ b/Tiles/FurnitureOtherworldly/OtherworldlyStone.cs @@ -1,6 +1,8 @@ using CalamityMod.Dusts.Furniture; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -11,11 +13,15 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly [LegacyName("OccultStone")] public class OtherworldlyStone : ModTile { + public Asset ClothTexture; + private int extraFrameHeight = 36; private int extraFrameWidth = 90; public override void SetStaticDefaults() { + ClothTexture = ModContent.Request("CalamityMod/Tiles/FurnitureOtherworldly/OtherworldlyStone_Cloth"); + Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = false; Main.tileBlockLight[Type] = true; @@ -36,16 +42,25 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly return false; } - public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) { if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type || Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type) { - try - { - Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); - } - catch { } + Main.tile[i, j].Get().HasSpecialPoint = true; + } + else + { + Main.tile[i, j].Get().HasSpecialPoint = false; + } + + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].Get().HasSpecialPoint) + { + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); } } @@ -57,7 +72,7 @@ namespace CalamityMod.Tiles.FurnitureOtherworldly Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Lighting.GetColor(i, j), false); - Texture2D cloth = ModContent.Request("CalamityMod/Tiles/FurnitureOtherworldly/OtherworldlyStone_Cloth").Value; + Texture2D cloth = ClothTexture.Value; DrawExtraTop(i, j, cloth, drawOffset, drawColour); DrawExtraWallEnds(i, j, cloth, drawOffset, drawColour); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs index be6084f4d0..51b19cb344 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs @@ -1,18 +1,13 @@ -using CalamityMod.Items.Placeables.FurniturePlagued; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurniturePlaguedPlate { public class PlaguedPlate : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurniturePlaguedPlate/PlaguedPlateGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs index 57b83597b1..eca6b86c5c 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBasin.cs @@ -1,8 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -59,7 +57,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs index 6e6dc45c34..9ec4004921 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateBed.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.Localization; @@ -63,6 +62,6 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate return true; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs index 4dcfc0650d..1b6f6359e1 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandelabra.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs index b73eb77360..d1a2e57e4b 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateCandle.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -51,7 +51,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs index fe7d8ca96d..c7d4e1a3cc 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateChair.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs index ff026cfb60..45570bc8ba 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateChandelier.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateChest.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateChest.cs index 1c5b2bcdd5..e8ae5291dc 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateChest.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs index 5893face2d..cfd86cb9ec 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateClock.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override bool CreateDust(int i, int j, ref int type) @@ -36,6 +36,6 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateDresser.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateDresser.cs index 35a589cd5f..08eee6731a 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateDresser.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs index 9f3095a522..ec7a85d9c0 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateLamp.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs index 98a049ecd6..a173c77173 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateLantern.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs index a8687a9fa4..081e824170 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlateSofa.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureProfaned/ProfanedBed.cs b/Tiles/FurnitureProfaned/ProfanedBed.cs index fde33ba98d..1e51734c29 100644 --- a/Tiles/FurnitureProfaned/ProfanedBed.cs +++ b/Tiles/FurnitureProfaned/ProfanedBed.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureProfaned/ProfanedBench.cs b/Tiles/FurnitureProfaned/ProfanedBench.cs index e3a6fb359e..06a5fe59ed 100644 --- a/Tiles/FurnitureProfaned/ProfanedBench.cs +++ b/Tiles/FurnitureProfaned/ProfanedBench.cs @@ -25,11 +25,11 @@ namespace CalamityMod.Tiles.FurnitureProfaned num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs index 76787f485f..e40c1bc4cd 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandelabra.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandelabra.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public class ProfanedCandelabra : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -42,12 +45,13 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureProfaned/ProfanedCandelabraFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureProfaned/ProfanedCandelabraFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureProfaned/ProfanedCandle.cs b/Tiles/FurnitureProfaned/ProfanedCandle.cs index 3f57a35370..33786cbe96 100644 --- a/Tiles/FurnitureProfaned/ProfanedCandle.cs +++ b/Tiles/FurnitureProfaned/ProfanedCandle.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public class ProfanedCandle : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -42,7 +45,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -55,13 +58,14 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureProfaned/ProfanedCandleFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureProfaned/ProfanedCandleFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureProfaned/ProfanedChair.cs b/Tiles/FurnitureProfaned/ProfanedChair.cs index 946987583d..f5185083b2 100644 --- a/Tiles/FurnitureProfaned/ProfanedChair.cs +++ b/Tiles/FurnitureProfaned/ProfanedChair.cs @@ -25,11 +25,11 @@ namespace CalamityMod.Tiles.FurnitureProfaned num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureProfaned/ProfanedChandelier.cs b/Tiles/FurnitureProfaned/ProfanedChandelier.cs index c832c859ce..10e48fb236 100644 --- a/Tiles/FurnitureProfaned/ProfanedChandelier.cs +++ b/Tiles/FurnitureProfaned/ProfanedChandelier.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureProfaned/ProfanedChest.cs b/Tiles/FurnitureProfaned/ProfanedChest.cs index cd9a2965eb..13e9075bf5 100644 --- a/Tiles/FurnitureProfaned/ProfanedChest.cs +++ b/Tiles/FurnitureProfaned/ProfanedChest.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureProfaned/ProfanedClock.cs b/Tiles/FurnitureProfaned/ProfanedClock.cs index 2501ceee5f..c90c652fe9 100644 --- a/Tiles/FurnitureProfaned/ProfanedClock.cs +++ b/Tiles/FurnitureProfaned/ProfanedClock.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -38,6 +38,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureProfaned/ProfanedDresser.cs b/Tiles/FurnitureProfaned/ProfanedDresser.cs index 0b9b45abab..fd906d85e6 100644 --- a/Tiles/FurnitureProfaned/ProfanedDresser.cs +++ b/Tiles/FurnitureProfaned/ProfanedDresser.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureProfaned/ProfanedLamp.cs b/Tiles/FurnitureProfaned/ProfanedLamp.cs index fc16a0d930..4ed44f8121 100644 --- a/Tiles/FurnitureProfaned/ProfanedLamp.cs +++ b/Tiles/FurnitureProfaned/ProfanedLamp.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public class ProfanedLamp : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -42,12 +45,13 @@ namespace CalamityMod.Tiles.FurnitureProfaned public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureProfaned/ProfanedLampFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureProfaned/ProfanedLampFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureProfaned/ProfanedLantern.cs b/Tiles/FurnitureProfaned/ProfanedLantern.cs index 7435eaccba..5ebce76107 100644 --- a/Tiles/FurnitureProfaned/ProfanedLantern.cs +++ b/Tiles/FurnitureProfaned/ProfanedLantern.cs @@ -1,8 +1,10 @@ using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -10,6 +12,10 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public class ProfanedLantern : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -41,14 +47,24 @@ namespace CalamityMod.Tiles.FurnitureProfaned } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(128, 108, 90, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureProfaned/ProfanedLanternFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureProfaned/ProfanedPiano.cs b/Tiles/FurnitureProfaned/ProfanedPiano.cs index f13dcb2d72..792d373a11 100644 --- a/Tiles/FurnitureProfaned/ProfanedPiano.cs +++ b/Tiles/FurnitureProfaned/ProfanedPiano.cs @@ -1,7 +1,6 @@ using CalamityMod.Dusts.Furniture; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; diff --git a/Tiles/FurnitureProfaned/ProfanedRock.cs b/Tiles/FurnitureProfaned/ProfanedRock.cs index 8aaa7b04f4..357c9bb157 100644 --- a/Tiles/FurnitureProfaned/ProfanedRock.cs +++ b/Tiles/FurnitureProfaned/ProfanedRock.cs @@ -2,7 +2,6 @@ using CalamityMod.Dusts.Furniture; using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -14,8 +13,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public const int AnimationFrameWidth = 288; - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureProfaned/ProfanedRockGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; @@ -32,7 +29,7 @@ namespace CalamityMod.Tiles.FurnitureProfaned AddMapEntry(new Color(84, 38, 33)); } - + public override bool CreateDust(int i, int j, ref int type) { diff --git a/Tiles/FurnitureProfaned/RunicProfanedBrick.cs b/Tiles/FurnitureProfaned/RunicProfanedBrick.cs index 059beaa28e..8f71489589 100644 --- a/Tiles/FurnitureProfaned/RunicProfanedBrick.cs +++ b/Tiles/FurnitureProfaned/RunicProfanedBrick.cs @@ -1,8 +1,6 @@  using CalamityMod.Dusts.Furniture; -using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -14,8 +12,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned { public const int AnimationFrameWidth = 234; - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureProfaned/RunicProfanedBrickGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureRunestone/RunestoneTerracotta.cs b/Tiles/FurnitureRunestone/RunestoneTerracotta.cs new file mode 100644 index 0000000000..59940544a9 --- /dev/null +++ b/Tiles/FurnitureRunestone/RunestoneTerracotta.cs @@ -0,0 +1,44 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureRunestone +{ + public class RunestoneTerracotta : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Tink; + DustType = DustID.Pot; + AddMapEntry(new Color(186, 130, 130)); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/FurnitureRunestone/RunestoneTerracotta.png b/Tiles/FurnitureRunestone/RunestoneTerracotta.png new file mode 100644 index 0000000000..c70ef9bd5f Binary files /dev/null and b/Tiles/FurnitureRunestone/RunestoneTerracotta.png differ diff --git a/Tiles/FurnitureSacrilegious/EyeOfTheAccursedBannerTile.cs b/Tiles/FurnitureSacrilegious/EyeOfTheAccursedBannerTile.cs index 91f7ed6e09..3beb6f6bd8 100644 --- a/Tiles/FurnitureSacrilegious/EyeOfTheAccursedBannerTile.cs +++ b/Tiles/FurnitureSacrilegious/EyeOfTheAccursedBannerTile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.FurnitureSacrilegious; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; diff --git a/Tiles/FurnitureSacrilegious/LargeRitualCandleTile.cs b/Tiles/FurnitureSacrilegious/LargeRitualCandleTile.cs index 8f5c54035c..946accf5bb 100644 --- a/Tiles/FurnitureSacrilegious/LargeRitualCandleTile.cs +++ b/Tiles/FurnitureSacrilegious/LargeRitualCandleTile.cs @@ -1,10 +1,10 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class LargeRitualCandleTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() { // Due to how Ritual Candles are implemented (right click to swap styles), item drop for the alternate style will never register normally. @@ -77,12 +79,13 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 6); + FurnitureCommon.LightHitWire(Type, i, j, 2, 6); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/LargeRitualCandleTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/LargeRitualCandleTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs b/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs index 84314f6124..fd33d3371a 100644 --- a/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs +++ b/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile.cs @@ -2,12 +2,12 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -15,6 +15,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class MonolithOfTheAccursedTile : ModTile { + public Asset IconRightTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -134,7 +136,7 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); // For drawing the floating icon public override void PostDraw(int i, int j, SpriteBatch spriteBatch) @@ -142,7 +144,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious if (Main.tile[i, j].TileFrameX < 36 || Main.tile[i, j].IsTileActuallyInvisible()) return; - Texture2D texture = ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile_IconRight").Value; + IconRightTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/MonolithOfTheAccursedTile_IconRight"); + Texture2D texture = IconRightTexture.Value; Tile tile = Main.tile[i, j]; int xPos = tile.TileFrameX; int yPos = tile.TileFrameY; diff --git a/Tiles/FurnitureSacrilegious/OccultBrickTile.cs b/Tiles/FurnitureSacrilegious/OccultBrickTile.cs index f6f44e9d73..4e37f6311c 100644 --- a/Tiles/FurnitureSacrilegious/OccultBrickTile.cs +++ b/Tiles/FurnitureSacrilegious/OccultBrickTile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.FurnitureSacrilegious; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious Main.tileLighted[Type] = true; Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; - DustType = 8; + DustType = DustID.Iron; AddMapEntry(new Color(63, 69, 71)); HitSound = SoundID.Tink; } diff --git a/Tiles/FurnitureSacrilegious/OccultLegionnaireBannerTile.cs b/Tiles/FurnitureSacrilegious/OccultLegionnaireBannerTile.cs index ec3269d7c3..992f5e1f83 100644 --- a/Tiles/FurnitureSacrilegious/OccultLegionnaireBannerTile.cs +++ b/Tiles/FurnitureSacrilegious/OccultLegionnaireBannerTile.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.FurnitureSacrilegious; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; diff --git a/Tiles/FurnitureSacrilegious/RitualCandleTile.cs b/Tiles/FurnitureSacrilegious/RitualCandleTile.cs index 4ee27065e2..fc6ecdda97 100644 --- a/Tiles/FurnitureSacrilegious/RitualCandleTile.cs +++ b/Tiles/FurnitureSacrilegious/RitualCandleTile.cs @@ -1,11 +1,11 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +13,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class RitualCandleTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() { // Due to how Ritual Candles are implemented (right click to swap styles), item drop for the alternate style will never register normally. @@ -74,12 +76,13 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/RitualCandleTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/RitualCandleTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousBedTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousBedTile.cs index ba542aa035..fcaf0bbcf9 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousBedTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousBedTile.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousBenchTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousBenchTile.cs index 61ee2f146f..1b1d2ee90a 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousBenchTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousBenchTile.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousCandelabraTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousCandelabraTile.cs index 5fe0158dd9..775db7e993 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousCandelabraTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousCandelabraTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class SacrilegiousCandelabraTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -40,12 +43,13 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousCandelabraTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousCandelabraTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousCandleTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousCandleTile.cs index cad5d38d19..480c9f89f3 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousCandleTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousCandleTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class SacrilegiousCandleTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -41,7 +44,7 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -54,13 +57,14 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousCandleTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousCandleTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousChairTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousChairTile.cs index 08d0042ceb..ea4859a399 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousChairTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousChairTile.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousChandelierTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousChandelierTile.cs index 07e16cb3d6..1ac5de6fea 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousChandelierTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousChandelierTile.cs @@ -1,7 +1,9 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class SacrilegiousChandelierTile : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -41,14 +47,24 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(128, 26, 26, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousChandelierTileFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousChestTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousChestTile.cs index 6623d83277..f674577d5a 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousChestTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousChestTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -12,10 +13,12 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class SacrilegiousChestTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(43, 19, 42), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(43, 19, 42), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -27,10 +30,10 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); // Make the chest brighter the more stuff it has public override void PostDraw(int i, int j, SpriteBatch spriteBatch) @@ -44,7 +47,9 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious Tile tile = Main.tile[i, j]; if (tile.IsTileActuallyInvisible()) return; - Texture2D texture = ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousChestTileGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousChestTileGlow"); + Texture2D texture = GlowTexture.Value; int x = i; int y = j; diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousClockTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousClockTile.cs index baf4ba6e2e..21417acc1d 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousClockTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousClockTile.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -11,12 +12,13 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class SacrilegiousClockTile : ModTile { + public Asset IconTexture; + public override void SetStaticDefaults() { // This particular clock emits light Main.tileLighted[Type] = true; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - this.SetUpClock(ModContent.ItemType(), true); } @@ -36,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious b = 0.2f; } - public override bool RightClick(int x, int y) => CalamityUtils.ClockRightClick(); + public override bool RightClick(int x, int y) => FurnitureCommon.ClockRightClick(); public override void NearbyEffects(int i, int j, bool closer) { @@ -51,12 +53,13 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); // For drawing the floating clock icon public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - Texture2D texture = ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousClockTile_Icon").Value; + IconTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousClockTile_Icon"); + Texture2D texture = IconTexture.Value; Tile tile = Main.tile[i, j]; if (tile.IsTileActuallyInvisible()) return; diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousDresserTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousDresserTile.cs index de22f04c1a..3ab474bb18 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousDresserTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousDresserTile.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousLampTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousLampTile.cs index f6e6aac93a..0e948c46b3 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousLampTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousLampTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class SacrilegiousLampTile : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -41,12 +44,13 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousLampTileFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousLampTileFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousLanternTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousLanternTile.cs index 3b46b8500e..70bc7bb261 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousLanternTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousLanternTile.cs @@ -1,7 +1,9 @@ using CalamityMod.Items.Placeables.FurnitureSacrilegious; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious { public class SacrilegiousLanternTile : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -40,14 +46,24 @@ namespace CalamityMod.Tiles.FurnitureSacrilegious } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(128, 26, 26, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureSacrilegious/SacrilegiousLanternTileFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureSacrilegious/SacrilegiousOrganTile.cs b/Tiles/FurnitureSacrilegious/SacrilegiousOrganTile.cs index 40d760b9de..05ce11ce15 100644 --- a/Tiles/FurnitureSacrilegious/SacrilegiousOrganTile.cs +++ b/Tiles/FurnitureSacrilegious/SacrilegiousOrganTile.cs @@ -1,9 +1,6 @@ -using CalamityMod.Items.Placeables.FurnitureSacrilegious; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/FurnitureShellstone/ShellTrimBrick.cs b/Tiles/FurnitureShellstone/ShellTrimBrick.cs new file mode 100644 index 0000000000..8acf7cb1fa --- /dev/null +++ b/Tiles/FurnitureShellstone/ShellTrimBrick.cs @@ -0,0 +1,34 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureShellstone +{ + public class ShellTrimBrick : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + TileID.Sets.HasSlopeFrames[Type] = true; + + HitSound = SoundID.Tink; + DustType = DustID.CorruptPlants; + AddMapEntry(new Color(156, 191, 199)); + + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/FurnitureShellstone/ShellTrimBrick.png b/Tiles/FurnitureShellstone/ShellTrimBrick.png new file mode 100644 index 0000000000..36960b0c90 Binary files /dev/null and b/Tiles/FurnitureShellstone/ShellTrimBrick.png differ diff --git a/Tiles/FurnitureShellstone/ShellstoneSlab.cs b/Tiles/FurnitureShellstone/ShellstoneSlab.cs new file mode 100644 index 0000000000..354cf242fd --- /dev/null +++ b/Tiles/FurnitureShellstone/ShellstoneSlab.cs @@ -0,0 +1,34 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureShellstone +{ + public class ShellstoneSlab : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + TileID.Sets.HasSlopeFrames[Type] = true; + + HitSound = SoundID.Tink; + DustType = DustID.CorruptPlants; + AddMapEntry(new Color(156, 191, 199)); + + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/ShellstoneSlab.png b/Tiles/FurnitureShellstone/ShellstoneSlab.png similarity index 100% rename from Tiles/SunkenSea/ShellstoneSlab.png rename to Tiles/FurnitureShellstone/ShellstoneSlab.png diff --git a/Tiles/FurnitureSilva/SilvaBasin.cs b/Tiles/FurnitureSilva/SilvaBasin.cs new file mode 100644 index 0000000000..53df3ac099 --- /dev/null +++ b/Tiles/FurnitureSilva/SilvaBasin.cs @@ -0,0 +1,65 @@ +using CalamityMod.Dusts.Furniture; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureSilva +{ + public class SilvaBasin : ModTile + { + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.StyleLineSkip = 2; + TileObjectData.addTile(Type); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); + AnimationFrameHeight = 54; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, ModContent.DustType(), 0f, 0f, 1, new Color(255, 255, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.ChlorophyteWeapon, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frameCounter++; + if (frameCounter >= 6) + { + frame = (frame + 1) % 10; + frameCounter = 0; + } + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + Tile tile = Main.tile[i, j]; + //227 79 79 + if (tile.TileFrameX < 54) + { + r = 0.6f; + g = 1f; + b = 0.8f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); + } + } +} diff --git a/Tiles/Furniture/CraftingStations/SilvaBasin.png b/Tiles/FurnitureSilva/SilvaBasin.png similarity index 100% rename from Tiles/Furniture/CraftingStations/SilvaBasin.png rename to Tiles/FurnitureSilva/SilvaBasin.png diff --git a/Tiles/Furniture/CraftingStations/SilvaBasin_Highlight.png b/Tiles/FurnitureSilva/SilvaBasin_Highlight.png similarity index 100% rename from Tiles/Furniture/CraftingStations/SilvaBasin_Highlight.png rename to Tiles/FurnitureSilva/SilvaBasin_Highlight.png diff --git a/Tiles/FurnitureSilva/SilvaBed.cs b/Tiles/FurnitureSilva/SilvaBed.cs index 4f1ef100c1..2c17c92d66 100644 --- a/Tiles/FurnitureSilva/SilvaBed.cs +++ b/Tiles/FurnitureSilva/SilvaBed.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Tiles.FurnitureSilva public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureSilva/SilvaBench.cs b/Tiles/FurnitureSilva/SilvaBench.cs index a21558638e..e1dccc110f 100644 --- a/Tiles/FurnitureSilva/SilvaBench.cs +++ b/Tiles/FurnitureSilva/SilvaBench.cs @@ -25,11 +25,11 @@ namespace CalamityMod.Tiles.FurnitureSilva num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureSilva/SilvaCandelabra.cs b/Tiles/FurnitureSilva/SilvaCandelabra.cs index 747c08e45f..7c55130a30 100644 --- a/Tiles/FurnitureSilva/SilvaCandelabra.cs +++ b/Tiles/FurnitureSilva/SilvaCandelabra.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureSilva/SilvaCandle.cs b/Tiles/FurnitureSilva/SilvaCandle.cs index ae1a7bca85..f7c936b130 100644 --- a/Tiles/FurnitureSilva/SilvaCandle.cs +++ b/Tiles/FurnitureSilva/SilvaCandle.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureSilva/SilvaChair.cs b/Tiles/FurnitureSilva/SilvaChair.cs index 3fd04494d7..a8bacc1565 100644 --- a/Tiles/FurnitureSilva/SilvaChair.cs +++ b/Tiles/FurnitureSilva/SilvaChair.cs @@ -25,11 +25,11 @@ namespace CalamityMod.Tiles.FurnitureSilva num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureSilva/SilvaChandelier.cs b/Tiles/FurnitureSilva/SilvaChandelier.cs index effeefc0c4..b89067275d 100644 --- a/Tiles/FurnitureSilva/SilvaChandelier.cs +++ b/Tiles/FurnitureSilva/SilvaChandelier.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureSilva/SilvaChest.cs b/Tiles/FurnitureSilva/SilvaChest.cs index 3bf50fecd6..9f961a9e98 100644 --- a/Tiles/FurnitureSilva/SilvaChest.cs +++ b/Tiles/FurnitureSilva/SilvaChest.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureSilva/SilvaClock.cs b/Tiles/FurnitureSilva/SilvaClock.cs index 22a2c2b55a..2d3545e4e8 100644 --- a/Tiles/FurnitureSilva/SilvaClock.cs +++ b/Tiles/FurnitureSilva/SilvaClock.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -38,6 +38,6 @@ namespace CalamityMod.Tiles.FurnitureSilva } } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureSilva/SilvaDresser.cs b/Tiles/FurnitureSilva/SilvaDresser.cs index 43c30508c9..9671aa24f0 100644 --- a/Tiles/FurnitureSilva/SilvaDresser.cs +++ b/Tiles/FurnitureSilva/SilvaDresser.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureSilva/SilvaLamp.cs b/Tiles/FurnitureSilva/SilvaLamp.cs index 341872b778..7ade6e44d5 100644 --- a/Tiles/FurnitureSilva/SilvaLamp.cs +++ b/Tiles/FurnitureSilva/SilvaLamp.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureSilva/SilvaLantern.cs b/Tiles/FurnitureSilva/SilvaLantern.cs index 50b226b3fd..b902f268ea 100644 --- a/Tiles/FurnitureSilva/SilvaLantern.cs +++ b/Tiles/FurnitureSilva/SilvaLantern.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Tiles.FurnitureSilva public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureStatigel/StaticRefiner.cs b/Tiles/FurnitureStatigel/StaticRefiner.cs new file mode 100644 index 0000000000..f9a1f0b8a0 --- /dev/null +++ b/Tiles/FurnitureStatigel/StaticRefiner.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureStatigel +{ + public class StaticRefiner : ModTile + { + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.addTile(Type); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName()); + AnimationFrameHeight = 54; + //also counts as a Solidifier + AdjTiles = new int[] { TileID.Solidifier }; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.PinkSlime, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + frameCounter++; + if (frameCounter >= 6) + { + frame = (frame + 1) % 10; + frameCounter = 0; + } + } + } +} diff --git a/Tiles/Furniture/CraftingStations/StaticRefiner.png b/Tiles/FurnitureStatigel/StaticRefiner.png similarity index 100% rename from Tiles/Furniture/CraftingStations/StaticRefiner.png rename to Tiles/FurnitureStatigel/StaticRefiner.png diff --git a/Tiles/FurnitureStatigel/StatigelBed.cs b/Tiles/FurnitureStatigel/StatigelBed.cs index 791ea04221..f1b1aa22b7 100644 --- a/Tiles/FurnitureStatigel/StatigelBed.cs +++ b/Tiles/FurnitureStatigel/StatigelBed.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureStatigel/StatigelCandelabra.cs b/Tiles/FurnitureStatigel/StatigelCandelabra.cs index 5a9d1dbbb2..e5323a0c81 100644 --- a/Tiles/FurnitureStatigel/StatigelCandelabra.cs +++ b/Tiles/FurnitureStatigel/StatigelCandelabra.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureStatigel { public class StatigelCandelabra : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType()); public override bool CreateDust(int i, int j, ref int type) @@ -39,12 +42,13 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelCandelabraFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelCandelabraFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureStatigel/StatigelCandle.cs b/Tiles/FurnitureStatigel/StatigelCandle.cs index b9859dae78..141090d016 100644 --- a/Tiles/FurnitureStatigel/StatigelCandle.cs +++ b/Tiles/FurnitureStatigel/StatigelCandle.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureStatigel { public class StatigelCandle : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType()); public override bool CreateDust(int i, int j, ref int type) @@ -39,7 +42,7 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -52,13 +55,14 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelCandleFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelCandleFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureStatigel/StatigelChair.cs b/Tiles/FurnitureStatigel/StatigelChair.cs index 9c9cd11fb9..734bc38e74 100644 --- a/Tiles/FurnitureStatigel/StatigelChair.cs +++ b/Tiles/FurnitureStatigel/StatigelChair.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureStatigel num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureStatigel/StatigelChandelier.cs b/Tiles/FurnitureStatigel/StatigelChandelier.cs index affdc54698..5e5b4b66f8 100644 --- a/Tiles/FurnitureStatigel/StatigelChandelier.cs +++ b/Tiles/FurnitureStatigel/StatigelChandelier.cs @@ -1,6 +1,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +10,10 @@ namespace CalamityMod.Tiles.FurnitureStatigel { public class StatigelChandelier : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType()); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -39,14 +45,24 @@ namespace CalamityMod.Tiles.FurnitureStatigel } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelChandelierFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureStatigel/StatigelChest.cs b/Tiles/FurnitureStatigel/StatigelChest.cs index 4939e94c8e..78634cf395 100644 --- a/Tiles/FurnitureStatigel/StatigelChest.cs +++ b/Tiles/FurnitureStatigel/StatigelChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureStatigel/StatigelClock.cs b/Tiles/FurnitureStatigel/StatigelClock.cs index b237d509b0..a0061da47b 100644 --- a/Tiles/FurnitureStatigel/StatigelClock.cs +++ b/Tiles/FurnitureStatigel/StatigelClock.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -36,6 +36,6 @@ namespace CalamityMod.Tiles.FurnitureStatigel num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureStatigel/StatigelDresser.cs b/Tiles/FurnitureStatigel/StatigelDresser.cs index 23eef161ea..35a407d8d2 100644 --- a/Tiles/FurnitureStatigel/StatigelDresser.cs +++ b/Tiles/FurnitureStatigel/StatigelDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureStatigel/StatigelLamp.cs b/Tiles/FurnitureStatigel/StatigelLamp.cs index 4ac95139a2..49418ea1b4 100644 --- a/Tiles/FurnitureStatigel/StatigelLamp.cs +++ b/Tiles/FurnitureStatigel/StatigelLamp.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureStatigel { public class StatigelLamp : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType()); public override bool CreateDust(int i, int j, ref int type) @@ -39,12 +42,13 @@ namespace CalamityMod.Tiles.FurnitureStatigel public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelLampFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelLampFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureStatigel/StatigelLantern.cs b/Tiles/FurnitureStatigel/StatigelLantern.cs index 5d09bb13e9..c6a6590c32 100644 --- a/Tiles/FurnitureStatigel/StatigelLantern.cs +++ b/Tiles/FurnitureStatigel/StatigelLantern.cs @@ -1,6 +1,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +10,10 @@ namespace CalamityMod.Tiles.FurnitureStatigel { public class StatigelLantern : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType()); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -38,14 +44,24 @@ namespace CalamityMod.Tiles.FurnitureStatigel } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStatigel/StatigelLanternFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureStatigel/StatigelSofa.cs b/Tiles/FurnitureStatigel/StatigelSofa.cs index a350b6c350..1fbc72a8b8 100644 --- a/Tiles/FurnitureStatigel/StatigelSofa.cs +++ b/Tiles/FurnitureStatigel/StatigelSofa.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureStatigel num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureStratus/StratusBed.cs b/Tiles/FurnitureStratus/StratusBed.cs index f24834a6a7..7c08941997 100644 --- a/Tiles/FurnitureStratus/StratusBed.cs +++ b/Tiles/FurnitureStratus/StratusBed.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Tiles.FurnitureStratus num = fail ? 1 : 3; } - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureStratus/StratusBricks.cs b/Tiles/FurnitureStratus/StratusBricks.cs index 74a2e92c79..d604e5364a 100644 --- a/Tiles/FurnitureStratus/StratusBricks.cs +++ b/Tiles/FurnitureStratus/StratusBricks.cs @@ -1,18 +1,14 @@  using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureStratus { public class StratusBricks : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureStratus/StratusBricksGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureStratus/StratusCandelabra.cs b/Tiles/FurnitureStratus/StratusCandelabra.cs index eeb75dbea5..df636fdcac 100644 --- a/Tiles/FurnitureStratus/StratusCandelabra.cs +++ b/Tiles/FurnitureStratus/StratusCandelabra.cs @@ -1,6 +1,6 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureStratus { public class StratusCandelabra : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -42,12 +44,13 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusCandelabraFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusCandelabraFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureStratus/StratusCandle.cs b/Tiles/FurnitureStratus/StratusCandle.cs index bf134d1086..35b9dc7e73 100644 --- a/Tiles/FurnitureStratus/StratusCandle.cs +++ b/Tiles/FurnitureStratus/StratusCandle.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureStratus { public class StratusCandle : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -40,7 +43,7 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -53,13 +56,14 @@ namespace CalamityMod.Tiles.FurnitureStratus public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusCandleFlame").Value, i, j, 0, -7); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusCandleFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 0, -7); } } } diff --git a/Tiles/FurnitureStratus/StratusChair.cs b/Tiles/FurnitureStratus/StratusChair.cs index 9b4dccc784..d264e36714 100644 --- a/Tiles/FurnitureStratus/StratusChair.cs +++ b/Tiles/FurnitureStratus/StratusChair.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureStratus num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureStratus/StratusChandelier.cs b/Tiles/FurnitureStratus/StratusChandelier.cs index c8b6e76bca..d45e6bd62d 100644 --- a/Tiles/FurnitureStratus/StratusChandelier.cs +++ b/Tiles/FurnitureStratus/StratusChandelier.cs @@ -1,8 +1,9 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.ModLoader; @@ -10,6 +11,10 @@ namespace CalamityMod.Tiles.FurnitureStratus { public class StratusChandelier : ModTile { + public Asset FlameTexture; + + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType(), true); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); @@ -42,14 +47,24 @@ namespace CalamityMod.Tiles.FurnitureStratus } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(77, 102, 128, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusChandelierFlame").Value, i, j, 0); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureStratus/StratusChest.cs b/Tiles/FurnitureStratus/StratusChest.cs index 21caec6f74..36094c695a 100644 --- a/Tiles/FurnitureStratus/StratusChest.cs +++ b/Tiles/FurnitureStratus/StratusChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureStratus/StratusClock.cs b/Tiles/FurnitureStratus/StratusClock.cs index c5a52534f3..1f02504a72 100644 --- a/Tiles/FurnitureStratus/StratusClock.cs +++ b/Tiles/FurnitureStratus/StratusClock.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.FurnitureStratus public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -37,6 +37,6 @@ namespace CalamityMod.Tiles.FurnitureStratus num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureStratus/StratusDresser.cs b/Tiles/FurnitureStratus/StratusDresser.cs index da8e9ec690..b091420c43 100644 --- a/Tiles/FurnitureStratus/StratusDresser.cs +++ b/Tiles/FurnitureStratus/StratusDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureStratus/StratusLamp.cs b/Tiles/FurnitureStratus/StratusLamp.cs index 032dee1385..637e1ebc84 100644 --- a/Tiles/FurnitureStratus/StratusLamp.cs +++ b/Tiles/FurnitureStratus/StratusLamp.cs @@ -1,6 +1,6 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -10,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureStratus { public class StratusLamp : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -42,12 +44,13 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusLampFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusLampFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) diff --git a/Tiles/FurnitureStratus/StratusLantern.cs b/Tiles/FurnitureStratus/StratusLantern.cs index be68e423d0..30cc31c27b 100644 --- a/Tiles/FurnitureStratus/StratusLantern.cs +++ b/Tiles/FurnitureStratus/StratusLantern.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureStratus public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureStratus/StratusPlatform.cs b/Tiles/FurnitureStratus/StratusPlatform.cs index fbe4bab57c..a7af81ded7 100644 --- a/Tiles/FurnitureStratus/StratusPlatform.cs +++ b/Tiles/FurnitureStratus/StratusPlatform.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureStratus { public class StratusPlatform : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpPlatform(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -29,7 +32,10 @@ namespace CalamityMod.Tiles.FurnitureStratus int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusPlatformGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusPlatformGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)); Tile trackTile = Main.tile[i, j]; if (!(trackTile.IsHalfBlock && trackTile.Slope == 0)) diff --git a/Tiles/FurnitureStratus/StratusSofa.cs b/Tiles/FurnitureStratus/StratusSofa.cs index a0d409ce33..56fabda8b7 100644 --- a/Tiles/FurnitureStratus/StratusSofa.cs +++ b/Tiles/FurnitureStratus/StratusSofa.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.FurnitureStratus num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureStratus/StratusStarPlatform.cs b/Tiles/FurnitureStratus/StratusStarPlatform.cs index ff5228198c..4d288e8bc5 100644 --- a/Tiles/FurnitureStratus/StratusStarPlatform.cs +++ b/Tiles/FurnitureStratus/StratusStarPlatform.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.FurnitureStratus; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureStratus { public class StratusStarPlatform : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpPlatform(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -30,7 +33,10 @@ namespace CalamityMod.Tiles.FurnitureStratus int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusStarPlatformGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureStratus/StratusStarPlatformGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + (Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange)); Tile trackTile = Main.tile[i, j]; if (!(trackTile.IsHalfBlock && trackTile.Slope == 0)) diff --git a/Tiles/FurnitureVoid/SmoothVoidstone.cs b/Tiles/FurnitureVoid/SmoothVoidstone.cs index 530df2f4ff..eefa8448ef 100644 --- a/Tiles/FurnitureVoid/SmoothVoidstone.cs +++ b/Tiles/FurnitureVoid/SmoothVoidstone.cs @@ -2,18 +2,14 @@ using System; using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureVoid { public class SmoothVoidstone : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureVoid/SmoothVoidstoneGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureVoid/VoidBed.cs b/Tiles/FurnitureVoid/VoidBed.cs index bfffd91a3c..403567ae30 100644 --- a/Tiles/FurnitureVoid/VoidBed.cs +++ b/Tiles/FurnitureVoid/VoidBed.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Tiles.FurnitureVoid num = fail ? 1 : 3; } - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureVoid/VoidCandelabra.cs b/Tiles/FurnitureVoid/VoidCandelabra.cs index 9ba1e8ab86..a3d336228c 100644 --- a/Tiles/FurnitureVoid/VoidCandelabra.cs +++ b/Tiles/FurnitureVoid/VoidCandelabra.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } } } diff --git a/Tiles/FurnitureVoid/VoidCandle.cs b/Tiles/FurnitureVoid/VoidCandle.cs index c164925c38..5486ea3053 100644 --- a/Tiles/FurnitureVoid/VoidCandle.cs +++ b/Tiles/FurnitureVoid/VoidCandle.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -51,7 +51,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } } diff --git a/Tiles/FurnitureVoid/VoidChair.cs b/Tiles/FurnitureVoid/VoidChair.cs index 1385d0f42d..e146d6da90 100644 --- a/Tiles/FurnitureVoid/VoidChair.cs +++ b/Tiles/FurnitureVoid/VoidChair.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureVoid num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureVoid/VoidChandelier.cs b/Tiles/FurnitureVoid/VoidChandelier.cs index eb73bf5328..c860bd0d62 100644 --- a/Tiles/FurnitureVoid/VoidChandelier.cs +++ b/Tiles/FurnitureVoid/VoidChandelier.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 3, 3); + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); } } } diff --git a/Tiles/FurnitureVoid/VoidChest.cs b/Tiles/FurnitureVoid/VoidChest.cs index 108abdaffa..f80c17bae3 100644 --- a/Tiles/FurnitureVoid/VoidChest.cs +++ b/Tiles/FurnitureVoid/VoidChest.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void SetStaticDefaults() { this.SetUpChest(ModContent.ItemType(), true); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j); - public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); } } diff --git a/Tiles/FurnitureVoid/VoidClock.cs b/Tiles/FurnitureVoid/VoidClock.cs index 77a32eda66..b1114183f3 100644 --- a/Tiles/FurnitureVoid/VoidClock.cs +++ b/Tiles/FurnitureVoid/VoidClock.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override bool RightClick(int x, int y) { - return CalamityUtils.ClockRightClick(); + return FurnitureCommon.ClockRightClick(); } public override void NearbyEffects(int i, int j, bool closer) @@ -50,6 +50,6 @@ namespace CalamityMod.Tiles.FurnitureVoid num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); } } diff --git a/Tiles/FurnitureVoid/VoidDresser.cs b/Tiles/FurnitureVoid/VoidDresser.cs index 594855f047..2b05b0fa31 100644 --- a/Tiles/FurnitureVoid/VoidDresser.cs +++ b/Tiles/FurnitureVoid/VoidDresser.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CreateDust(int i, int j, ref int type) @@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); } } diff --git a/Tiles/FurnitureVoid/VoidLamp.cs b/Tiles/FurnitureVoid/VoidLamp.cs index b8ab225744..e62b64d34d 100644 --- a/Tiles/FurnitureVoid/VoidLamp.cs +++ b/Tiles/FurnitureVoid/VoidLamp.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureVoid/VoidLantern.cs b/Tiles/FurnitureVoid/VoidLantern.cs index 64c198cd39..91d445f3b5 100644 --- a/Tiles/FurnitureVoid/VoidLantern.cs +++ b/Tiles/FurnitureVoid/VoidLantern.cs @@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureVoid public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 2); + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); } } } diff --git a/Tiles/FurnitureVoid/VoidSofa.cs b/Tiles/FurnitureVoid/VoidSofa.cs index ab18c06775..85b94342db 100644 --- a/Tiles/FurnitureVoid/VoidSofa.cs +++ b/Tiles/FurnitureVoid/VoidSofa.cs @@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureVoid num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureVoid/VoidstoneSlab.cs b/Tiles/FurnitureVoid/VoidstoneSlab.cs index eb5b1e2f82..a935bd7b9c 100644 --- a/Tiles/FurnitureVoid/VoidstoneSlab.cs +++ b/Tiles/FurnitureVoid/VoidstoneSlab.cs @@ -1,17 +1,13 @@ using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.FurnitureVoid { public class VoidstoneSlab : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/FurnitureVoid/VoidstoneSlabGlow"; - public override void SetupStatic() { Main.tileSolid[Type] = true; diff --git a/Tiles/FurnitureWulfrum/AnodizedWulfrumPanels.cs b/Tiles/FurnitureWulfrum/AnodizedWulfrumPanels.cs new file mode 100644 index 0000000000..655c07a8f0 --- /dev/null +++ b/Tiles/FurnitureWulfrum/AnodizedWulfrumPanels.cs @@ -0,0 +1,35 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class AnodizedWulfrumPanels : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + + HitSound = CommonCalamitySounds.PlatingMine; + AddMapEntry(new Color(89, 113, 91)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/FurnitureWulfrum/AnodizedWulfrumPanels.png b/Tiles/FurnitureWulfrum/AnodizedWulfrumPanels.png new file mode 100644 index 0000000000..d21f8a56c8 Binary files /dev/null and b/Tiles/FurnitureWulfrum/AnodizedWulfrumPanels.png differ diff --git a/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform.cs b/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform.cs new file mode 100644 index 0000000000..7985e16f76 --- /dev/null +++ b/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform.cs @@ -0,0 +1,66 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class AnodizedWulfrumPlatform : ModTile + { + internal static Texture2D GlowTexture; + + public override void SetStaticDefaults() + { + if (!Main.dedServ) + { + GlowTexture = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow", AssetRequestMode.ImmediateLoad).Value; + } + this.SetUpPlatform(ModContent.ItemType(), true); + } + + public override bool CanExplode(int i, int j) => false; + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void PostSetDefaults() + { + Main.tileNoSunLight[Type] = false; + } + + 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) + { + // If the cached textures don't exist for some reason, don't bother using them. + if (GlowTexture is null) + return; + + Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); + if (tile.IsTileActuallyInvisible()) + return; + + int xPos = tile.TileFrameX; + int frameOffset = (i + j) % 6 * AnimationFrameHeight; + int yPos = tile.TileFrameY + frameOffset; + 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; + + if (!tile.IsHalfBlock) + { + spriteBatch.Draw(GlowTexture, drawPosition, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + else if (tile.IsHalfBlock) + { + spriteBatch.Draw(GlowTexture, drawPosition + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform.png b/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform.png new file mode 100644 index 0000000000..4c097dcfac Binary files /dev/null and b/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform.png differ diff --git a/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow.png b/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow.png new file mode 100644 index 0000000000..9f3ad966ea Binary files /dev/null and b/Tiles/FurnitureWulfrum/AnodizedWulfrumPlatform_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/AnodizedWulfrumTrim.cs b/Tiles/FurnitureWulfrum/AnodizedWulfrumTrim.cs new file mode 100644 index 0000000000..46d09477df --- /dev/null +++ b/Tiles/FurnitureWulfrum/AnodizedWulfrumTrim.cs @@ -0,0 +1,49 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class AnodizedWulfrumTrim : ModTile + { + private const short subsheetWidth = 216; + private const short subsheetHeight = 72; + public static int TypeCache; + public override void SetStaticDefaults() + { + TypeCache = Type; + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileShine2[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + + HitSound = CommonCalamitySounds.PlatingMine; + AddMapEntry(new Color(133, 13, 13)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + int xPos = i % 2; + int yPos = j % 2; + frameXOffset = xPos * subsheetWidth; + frameYOffset = yPos * subsheetHeight; + } + } +} diff --git a/Tiles/FurnitureWulfrum/AnodizedWulfrumTrim.png b/Tiles/FurnitureWulfrum/AnodizedWulfrumTrim.png new file mode 100644 index 0000000000..8ca32f7c89 Binary files /dev/null and b/Tiles/FurnitureWulfrum/AnodizedWulfrumTrim.png differ diff --git a/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.cs b/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.cs new file mode 100644 index 0000000000..149dfa28bf --- /dev/null +++ b/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.cs @@ -0,0 +1,89 @@ +using System; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + + public class ChargedWulfrumEnergyBarrier : ModTile + { + public static int TypeCache; + + public Asset ReflectTexture; + + public override void SetStaticDefaults() + { + TypeCache = Type; + Main.tileLighted[Type] = true; + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = false; + Main.tileBrick[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + + DustType = DustID.RainCloud; + AddMapEntry(new Color(112, 244, 244)); + HitSound = SoundID.Shatter; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float brightness = 0.9f; + Color cyan = new Color(112, 244, 244); + Color blue = new Color(54, 177, 221); + Color value = Color.Lerp(cyan, blue, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(cyan, blue, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + + r = (value.R + value1.R) / 800f; + g = (value.G + value1.G) / 800f; + b = (value.B + value1.B) / 800f; + r *= brightness; + g *= brightness; + b *= brightness; + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + float brightness = MathHelper.Clamp(0.2f - (j / 680), 0f, 0.2f); + + float time = Main.GameUpdateCount; + float waveScale1 = time * 0.094f; + int scalar = i - (j / 2); + float wave1 = waveScale1 * -50 + scalar * 12; + float wave1angle = 0.30f + 0.25f * MathF.Sin(MathHelper.ToRadians(wave1)); + + float transparency = 0.05f + wave1angle; + + + // Must be set here + TileID.Sets.DrawsWalls[Type] = true; + Main.tileNoSunLight[Type] = false; + + ReflectTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrierReflect"); + Texture2D tex = ReflectTexture.Value; + + Tile tile = Main.tile[i, j]; + Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); + + TileFramingSystem.SlopedGlowmask(in tile, i, j, tex, frame, CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Color.White * transparency, false), default); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; + } + } +} diff --git a/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.png b/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.png new file mode 100644 index 0000000000..e9a2e8bdac Binary files /dev/null and b/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrier.png differ diff --git a/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrierReflect.png b/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrierReflect.png new file mode 100644 index 0000000000..a937fddfbf Binary files /dev/null and b/Tiles/FurnitureWulfrum/ChargedWulfrumEnergyBarrierReflect.png differ diff --git a/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.cs b/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.cs new file mode 100644 index 0000000000..12ee6a0b92 --- /dev/null +++ b/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.cs @@ -0,0 +1,113 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class ChargedWulfrumWallMountedBulb : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileObsidianKill[Type] = false; + + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.KryptonMoss; + + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); + + + // Attach to ground + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" + TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row + TileObjectData.newTile.Origin = new Point16(0, 1); + + // Attach to side (right) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.addAlternate(2); + + // Attach to ceiling + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(4); + + // Attach to side (left) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(6); + + // Attach to wall + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorWall = true; + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.addAlternate(8); + TileObjectData.addTile(Type); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 84f / 255f; + g = 212f / 255f; + b = 233f / 255f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb_Glow"); + Texture2D tex = GlowTexture.Value; + + Tile tile = Main.tile[i, j]; + Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); + + TileFramingSystem.SlopedGlowmask(in tile, i, j, tex, frame, CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Color.White, false), default); + } + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); + } + } +} diff --git a/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.png b/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.png new file mode 100644 index 0000000000..575501ad39 Binary files /dev/null and b/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb.png differ diff --git a/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb_Glow.png b/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb_Glow.png new file mode 100644 index 0000000000..24567bc279 Binary files /dev/null and b/Tiles/FurnitureWulfrum/ChargedWulfrumWallMountedBulb_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.cs new file mode 100644 index 0000000000..34ed84e662 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumBathtub : ModTile + { + public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.png new file mode 100644 index 0000000000..552c86a3e5 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBathtub.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.cs new file mode 100644 index 0000000000..fd1e3426de --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumBookcase : ModTile + { + public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.png new file mode 100644 index 0000000000..93e13605b4 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumBookcase.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.cs new file mode 100644 index 0000000000..0d0e368359 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumChair : ModTile + { + public override void SetStaticDefaults() => this.SetUpChair(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.png new file mode 100644 index 0000000000..6ee3ada599 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair_Highlight.png new file mode 100644 index 0000000000..b59a4f5245 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChair_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.cs new file mode 100644 index 0000000000..85c0c6f0d1 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.cs @@ -0,0 +1,70 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumChandelier : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() => this.SetUpChandelier(ModContent.ItemType(), true); + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 201f / 255f; + g = 226f / 255f; + b = 122f / 255f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 3, 3); + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y - 2) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.png new file mode 100644 index 0000000000..bc974929bc Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier_Glow.png new file mode 100644 index 0000000000..6b8c2c9cf1 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChandelier_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.cs new file mode 100644 index 0000000000..699d6a05ff --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.cs @@ -0,0 +1,56 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumChest : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() + { + this.SetUpChest(ModContent.ItemType()); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j); + public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j); + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.png new file mode 100644 index 0000000000..b34000a603 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest_Glow.png new file mode 100644 index 0000000000..a415184891 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest_Highlight.png new file mode 100644 index 0000000000..c0d1530a5b Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumChest_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock.png new file mode 100644 index 0000000000..d2fd41cb59 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock_Glow.png new file mode 100644 index 0000000000..8c0bf62db6 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock_Highlight.png new file mode 100644 index 0000000000..3d82b19c24 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumClock_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.cs new file mode 100644 index 0000000000..3aca64232e --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.cs @@ -0,0 +1,82 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumDeskLight : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 201f / 255f; + g = 226f / 255f; + b = 122f / 255f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, 1, j, 1, 1); + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + + public override bool RightClick(int i, int j) + { + FurnitureCommon.RightClickBreak(i, j); + return true; + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y - 5) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.png new file mode 100644 index 0000000000..3acbbd1bee Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight_Glow.png new file mode 100644 index 0000000000..9089acfd02 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDeskLight_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed.cs new file mode 100644 index 0000000000..cd6f07a065 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumDoorClosed : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorClosed(ModContent.ItemType(), true); + TileID.Sets.OpenDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed.png new file mode 100644 index 0000000000..90a41c9aca Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed_Highlight.png new file mode 100644 index 0000000000..e0758984f1 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorClosed_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen.cs new file mode 100644 index 0000000000..5df9264a7a --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen.cs @@ -0,0 +1,39 @@ +using CalamityMod.Items.Placeables.FurnitureWulfrum.FurnitureAnodizedWulfrum; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumDoorOpen : ModTile + { + public override void SetStaticDefaults() + { + this.SetUpDoorOpen(ModContent.ItemType(), true); + TileID.Sets.CloseDoorID[Type] = ModContent.TileType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen.png new file mode 100644 index 0000000000..98e854a8cc Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen_Highlight.png new file mode 100644 index 0000000000..ca767aed7b Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDoorOpen_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.cs new file mode 100644 index 0000000000..a3a29f2818 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.cs @@ -0,0 +1,57 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumDresser : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() + { + this.SetUpDresser(ModContent.ItemType()); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); + public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.png new file mode 100644 index 0000000000..d37893dd8d Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser_Glow.png new file mode 100644 index 0000000000..26cee14f42 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser_Highlight.png new file mode 100644 index 0000000000..6e31954740 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumDresser_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.cs new file mode 100644 index 0000000000..8bf3ef32be --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.cs @@ -0,0 +1,58 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumJukebox : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); //This Jukebox has bookcase dimensions + TileObjectData.newTile.LavaDeath = false; + TileObjectData.addTile(Type); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetText("Tiles.Jukebox")); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + 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) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.png new file mode 100644 index 0000000000..02f87edf42 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox_Glow.png new file mode 100644 index 0000000000..3b011f3b84 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumJukebox_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.cs new file mode 100644 index 0000000000..542c67a6d3 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.cs @@ -0,0 +1,68 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumLamp : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 201f / 255f; + g = 226f / 255f; + b = 122f / 255f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.png new file mode 100644 index 0000000000..0d0d621ae0 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp_Glow.png new file mode 100644 index 0000000000..b1d96c1638 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLamp_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.cs new file mode 100644 index 0000000000..408915c3eb --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.cs @@ -0,0 +1,70 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumLantern : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType(), true); + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 201f / 255f; + g = 226f / 255f; + b = 122f / 255f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y - 4) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 1, 2); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.png new file mode 100644 index 0000000000..99ca6f27d1 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern_Glow.png new file mode 100644 index 0000000000..cb80de710c Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumLantern_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.cs new file mode 100644 index 0000000000..ae6d74a64a --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumSink : ModTile + { + public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.png new file mode 100644 index 0000000000..ea91bbf73b Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSink.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.cs new file mode 100644 index 0000000000..47dbbec043 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.cs @@ -0,0 +1,54 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumSleepingPod : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.png new file mode 100644 index 0000000000..76a7a63f3e Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPodActive.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPodActive.png new file mode 100644 index 0000000000..2f42aefcdd Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPodActive.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPodActive_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPodActive_Glow.png new file mode 100644 index 0000000000..285c7fb955 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPodActive_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod_Glow.png new file mode 100644 index 0000000000..22a6ed63e9 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod_Highlight.png new file mode 100644 index 0000000000..514de2d0d8 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSleepingPod_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.cs new file mode 100644 index 0000000000..3aa7304261 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.cs @@ -0,0 +1,61 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumSofa : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.png new file mode 100644 index 0000000000..136844ea32 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa_Glow.png new file mode 100644 index 0000000000..ea27a6db33 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa_Highlight.png new file mode 100644 index 0000000000..ee7b74d4f0 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumSofa_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.cs new file mode 100644 index 0000000000..6d6bef5b11 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.cs @@ -0,0 +1,47 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumTable : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + 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) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + int xFrameOffset = Main.tile[i, j].TileFrameX; + int yFrameOffset = Main.tile[i, j].TileFrameY; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable_Glow"); + Texture2D glowmask = GlowTexture.Value; + + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White; + Tile trackTile = Main.tile[i, j]; + if (!trackTile.IsHalfBlock && trackTile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (trackTile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.png new file mode 100644 index 0000000000..6cd3908340 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable_Glow.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable_Glow.png new file mode 100644 index 0000000000..39b2d14fc7 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumTable_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.cs new file mode 100644 index 0000000000..34516a0843 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.cs @@ -0,0 +1,78 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.GameContent; +using Terraria.GameContent.ObjectInteractions; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumToilet : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileWaterDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 2; + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; + TileObjectData.addAlternate(1); + TileObjectData.addTile(Type); + + // Toilets count as Chairs + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); + AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Toilet")); + TileID.Sets.CanBeSatOnForNPCs[Type] = true; + TileID.Sets.CanBeSatOnForPlayers[Type] = true; + TileID.Sets.HasOutlines[Type] = true; + AdjTiles = new int[] { TileID.Chairs }; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, shitter: true); + + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); + + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType()); + + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) + { + return settings.player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance); + } + + public override void HitWire(int i, int j) // I hate this please make it stop. - Merkalto + { + Tile tile = Main.tile[i, j]; + + int spawnX = i; + int spawnY = j - tile.TileFrameY / 18; + + Wiring.SkipWire(spawnX, spawnY); + Wiring.SkipWire(spawnX, spawnY + 1); + + if (Wiring.CheckMech(spawnX, spawnY, 60)) + { + Projectile.NewProjectile(Wiring.GetProjectileSource(spawnX, spawnY), spawnX * 16 + 8, spawnY * 16 + 12, 0f, 0f, ProjectileID.ToiletEffect, 0, 0f, Main.myPlayer); + } + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.png new file mode 100644 index 0000000000..890177b446 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet_Highlight.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet_Highlight.png new file mode 100644 index 0000000000..5c2fc8b88a Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumToilet_Highlight.png differ diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.cs b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.cs new file mode 100644 index 0000000000..2e86f9c0d3 --- /dev/null +++ b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.cs @@ -0,0 +1,23 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum.FurnitureAnodizedWulfrum +{ + public class AnodizedWulfrumWorkBench : ModTile + { + public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType(), true); + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Tungsten, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.png b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.png new file mode 100644 index 0000000000..94cbc92609 Binary files /dev/null and b/Tiles/FurnitureWulfrum/FurnitureAnodizedWulfrum/AnodizedWulfrumWorkBench.png differ diff --git a/Tiles/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.cs b/Tiles/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.cs new file mode 100644 index 0000000000..927c6aa313 --- /dev/null +++ b/Tiles/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.cs @@ -0,0 +1,49 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class RoundedAnodizedWulfrumPanels : ModTile + { + private const short subsheetWidth = 216; + private const short subsheetHeight = 72; + public static int TypeCache; + public override void SetStaticDefaults() + { + TypeCache = Type; + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileShine2[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + + HitSound = CommonCalamitySounds.PlatingMine; + AddMapEntry(new Color(164, 150, 125)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + int xPos = i % 2; + int yPos = j % 2; + frameXOffset = xPos * subsheetWidth; + frameYOffset = yPos * subsheetHeight; + } + } +} diff --git a/Tiles/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.png b/Tiles/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.png new file mode 100644 index 0000000000..5f0bba3e44 Binary files /dev/null and b/Tiles/FurnitureWulfrum/RoundedAnodizedWulfrumPanels.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumBathtub.cs b/Tiles/FurnitureWulfrum/WulfrumBathtub.cs index b3c983a646..9549bd09fa 100644 --- a/Tiles/FurnitureWulfrum/WulfrumBathtub.cs +++ b/Tiles/FurnitureWulfrum/WulfrumBathtub.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumBathtub : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBathtub(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -30,7 +33,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumBathtubGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumBathtubGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumBed.cs b/Tiles/FurnitureWulfrum/WulfrumBed.cs index 9c10c99de0..3a6c6bfd8e 100644 --- a/Tiles/FurnitureWulfrum/WulfrumBed.cs +++ b/Tiles/FurnitureWulfrum/WulfrumBed.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumBed : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBed(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -26,9 +29,9 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; - public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -37,7 +40,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumBedGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumBedGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumBookcase.cs b/Tiles/FurnitureWulfrum/WulfrumBookcase.cs index e54e9c83a4..39db3cf1dc 100644 --- a/Tiles/FurnitureWulfrum/WulfrumBookcase.cs +++ b/Tiles/FurnitureWulfrum/WulfrumBookcase.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumBookcase : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpBookcase(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -30,7 +33,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumBookcaseGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumBookcaseGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumCandelabra.cs b/Tiles/FurnitureWulfrum/WulfrumCandelabra.cs index a86d15ef44..65f3eedb77 100644 --- a/Tiles/FurnitureWulfrum/WulfrumCandelabra.cs +++ b/Tiles/FurnitureWulfrum/WulfrumCandelabra.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumCandelabra : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandelabra(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -41,12 +44,13 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 2, 2); + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumCandelabraFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumCandelabraFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureWulfrum/WulfrumCandle.cs b/Tiles/FurnitureWulfrum/WulfrumCandle.cs index 790ae4d325..0782afadcb 100644 --- a/Tiles/FurnitureWulfrum/WulfrumCandle.cs +++ b/Tiles/FurnitureWulfrum/WulfrumCandle.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumCandle : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpCandle(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -41,7 +44,7 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 1); + FurnitureCommon.LightHitWire(Type, i, j, 1, 1); } public override void MouseOver(int i, int j) @@ -54,13 +57,14 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumCandleFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumCandleFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureWulfrum/WulfrumChair.cs b/Tiles/FurnitureWulfrum/WulfrumChair.cs index 107952e5a7..4a14e5bb39 100644 --- a/Tiles/FurnitureWulfrum/WulfrumChair.cs +++ b/Tiles/FurnitureWulfrum/WulfrumChair.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -14,6 +15,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumChair : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -65,7 +68,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumChairGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumChairGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; @@ -76,11 +82,11 @@ namespace CalamityMod.Tiles.FurnitureWulfrum spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info, 40, true, true); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, 40, true, true); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType(), true); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType(), true); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureWulfrum/WulfrumChandelier.cs b/Tiles/FurnitureWulfrum/WulfrumChandelier.cs index 24089c07cd..cdf847d7da 100644 --- a/Tiles/FurnitureWulfrum/WulfrumChandelier.cs +++ b/Tiles/FurnitureWulfrum/WulfrumChandelier.cs @@ -1,8 +1,10 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; +using Terraria.GameContent.Drawing; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -12,12 +14,22 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumChandelier : ModTile { + public Asset FlameTexture; + public Asset GlowTexture; + + public override void Load() + { + FlameTexture = ModContent.Request(Texture + "Flame"); + GlowTexture = ModContent.Request(Texture + "Glow"); + } + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; TileID.Sets.MultiTileSway[Type] = true; + TileID.Sets.IsAMechanism[Type] = true; TileObjectData.newTile.Width = 3; TileObjectData.newTile.Height = 2; TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16 }; @@ -48,6 +60,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum num = fail ? 1 : 3; } + public override void AdjustMultiTileVineParameters(int i, int j, ref float? overrideWindCycle, ref float windPushPowerX, ref float windPushPowerY, ref bool dontRotateTopTiles, ref float totalWindMultiplier, ref Texture2D glowTexture, ref Color glowColor) => glowTexture = GlowTexture.Value; + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { if (Main.tile[i, j].TileFrameX < 18) @@ -64,14 +78,24 @@ namespace CalamityMod.Tiles.FurnitureWulfrum } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 3, 2); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumChandelierFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 3, 2); } } } diff --git a/Tiles/FurnitureWulfrum/WulfrumChandelierFlame.png b/Tiles/FurnitureWulfrum/WulfrumChandelierFlame.png index 867632c86c..60c5a0858b 100644 Binary files a/Tiles/FurnitureWulfrum/WulfrumChandelierFlame.png and b/Tiles/FurnitureWulfrum/WulfrumChandelierFlame.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumChandelierGlow.png b/Tiles/FurnitureWulfrum/WulfrumChandelierGlow.png new file mode 100644 index 0000000000..3eacd216f8 Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumChandelierGlow.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumClock.cs b/Tiles/FurnitureWulfrum/WulfrumClock.cs index 459a59ed7a..30c1566b83 100644 --- a/Tiles/FurnitureWulfrum/WulfrumClock.cs +++ b/Tiles/FurnitureWulfrum/WulfrumClock.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumClock : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpClock(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -21,7 +24,7 @@ namespace CalamityMod.Tiles.FurnitureWulfrum return false; } - public override bool RightClick(int x, int y) => CalamityUtils.ClockRightClick(); + public override bool RightClick(int x, int y) => FurnitureCommon.ClockRightClick(); public override void NearbyEffects(int i, int j, bool closer) { @@ -36,7 +39,7 @@ namespace CalamityMod.Tiles.FurnitureWulfrum num = fail ? 1 : 3; } - public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType()); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -45,7 +48,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumClockGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumClockGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumDresser.cs b/Tiles/FurnitureWulfrum/WulfrumDresser.cs index 813b797955..4a1dd86821 100644 --- a/Tiles/FurnitureWulfrum/WulfrumDresser.cs +++ b/Tiles/FurnitureWulfrum/WulfrumDresser.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent.ObjectInteractions; using Terraria.ID; @@ -10,10 +11,12 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumDresser : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { this.SetUpDresser(ModContent.ItemType()); - AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName); + AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName); } public override bool CanExplode(int i, int j) => false; @@ -26,10 +29,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName(); - public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver(); - public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar(); + public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver(); + public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar(); public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j); - public override bool RightClick(int i, int j) => CalamityUtils.DresserRightClick(); + public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick(); public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { @@ -38,7 +41,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumDresserGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumDresserGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumEnergyBarrier.cs b/Tiles/FurnitureWulfrum/WulfrumEnergyBarrier.cs new file mode 100644 index 0000000000..0beea02689 --- /dev/null +++ b/Tiles/FurnitureWulfrum/WulfrumEnergyBarrier.cs @@ -0,0 +1,89 @@ +using System; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + + public class WulfrumEnergyBarrier : ModTile + { + public static int TypeCache; + + public Asset ReflectTexture; + + public override void SetStaticDefaults() + { + TypeCache = Type; + Main.tileLighted[Type] = true; + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = false; + Main.tileBrick[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + + DustType = DustID.RainCloud; + AddMapEntry(new Color(194, 255, 67)); + HitSound = SoundID.Shatter; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float brightness = 0.9f; + Color lime = new Color(194, 255, 67); + Color green = new Color(110, 192, 93); + Color value = Color.Lerp(lime, green, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(lime, green, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + + r = (value.R + value1.R) / 800f; + g = (value.G + value1.G) / 800f; + b = (value.B + value1.B) / 800f; + r *= brightness; + g *= brightness; + b *= brightness; + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + float brightness = MathHelper.Clamp(0.2f - (j / 680), 0f, 0.2f); + + float time = Main.GameUpdateCount; + float waveScale1 = time * 0.064f; + int scalar = i - (j / 2); + float wave1 = waveScale1 * -50 + scalar * 12; + float wave1angle = 0.30f + 0.25f * MathF.Sin(MathHelper.ToRadians(wave1)); + + float transparency = 0.05f + wave1angle; + + + // Must be set here + TileID.Sets.DrawsWalls[Type] = true; + Main.tileNoSunLight[Type] = false; + + ReflectTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumEnergyBarrierReflect"); + Texture2D tex = ReflectTexture.Value; + + Tile tile = Main.tile[i, j]; + Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); + + TileFramingSystem.SlopedGlowmask(in tile, i, j, tex, frame, CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Color.White * transparency, false), default); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; + } + } +} diff --git a/Tiles/FurnitureWulfrum/WulfrumEnergyBarrier.png b/Tiles/FurnitureWulfrum/WulfrumEnergyBarrier.png new file mode 100644 index 0000000000..b7a61aeaf1 Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumEnergyBarrier.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumEnergyBarrierReflect.png b/Tiles/FurnitureWulfrum/WulfrumEnergyBarrierReflect.png new file mode 100644 index 0000000000..76d130ee7b Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumEnergyBarrierReflect.png differ diff --git a/Tiles/Furniture/CraftingStations/WulfrumLabstation.cs b/Tiles/FurnitureWulfrum/WulfrumLabstation.cs similarity index 78% rename from Tiles/Furniture/CraftingStations/WulfrumLabstation.cs rename to Tiles/FurnitureWulfrum/WulfrumLabstation.cs index 8b1cfe6971..e58e455dd4 100644 --- a/Tiles/Furniture/CraftingStations/WulfrumLabstation.cs +++ b/Tiles/FurnitureWulfrum/WulfrumLabstation.cs @@ -1,23 +1,23 @@ -using CalamityMod.Items.Placeables.Furniture.CraftingStations; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.Furniture.CraftingStations +namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumLabstation : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); TileObjectData.addTile(Type); - AddMapEntry(new Color(100, 153, 100), CalamityUtils.GetItemName()); + AddMapEntry(new Color(100, 153, 100), CalamityUtils.GetItemName()); } public override bool CreateDust(int i, int j, ref int type) @@ -38,7 +38,10 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations int xPos = Main.tile[i, j].TileFrameX; int yPos = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/Furniture/CraftingStations/WulfrumLabstationGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumLabstationGlow"); + Texture2D glowmask = GlowTexture.Value; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, new Color(100, 100, 100, 100)); Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; diff --git a/Tiles/Furniture/CraftingStations/WulfrumLabstation.png b/Tiles/FurnitureWulfrum/WulfrumLabstation.png similarity index 100% rename from Tiles/Furniture/CraftingStations/WulfrumLabstation.png rename to Tiles/FurnitureWulfrum/WulfrumLabstation.png diff --git a/Tiles/Furniture/CraftingStations/WulfrumLabstationGlow.png b/Tiles/FurnitureWulfrum/WulfrumLabstationGlow.png similarity index 100% rename from Tiles/Furniture/CraftingStations/WulfrumLabstationGlow.png rename to Tiles/FurnitureWulfrum/WulfrumLabstationGlow.png diff --git a/Tiles/FurnitureWulfrum/WulfrumLamp.cs b/Tiles/FurnitureWulfrum/WulfrumLamp.cs index 9fe3af8c38..099001dde0 100644 --- a/Tiles/FurnitureWulfrum/WulfrumLamp.cs +++ b/Tiles/FurnitureWulfrum/WulfrumLamp.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumLamp : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpLamp(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -41,12 +44,13 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public override void HitWire(int i, int j) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumLampFlame").Value, i, j); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumLampFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j); } } } diff --git a/Tiles/FurnitureWulfrum/WulfrumLantern.cs b/Tiles/FurnitureWulfrum/WulfrumLantern.cs index 01b9749e60..004670bc58 100644 --- a/Tiles/FurnitureWulfrum/WulfrumLantern.cs +++ b/Tiles/FurnitureWulfrum/WulfrumLantern.cs @@ -1,32 +1,20 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ObjectData; namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumLantern : ModTile { - public override void SetStaticDefaults() - { - Main.tileLighted[Type] = true; - Main.tileFrameImportant[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top); - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(Type); - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - AddMapEntry(new Color(251, 235, 127), Language.GetText("MapObject.Lantern")); + public Asset FlameTexture; - TileID.Sets.DisableSmartCursor[Type] = true; - AdjTiles = new int[] { TileID.HangingLanterns }; - } + public override void Load() => FlameTexture = ModContent.Request(Texture + "Flame"); + public override void SetStaticDefaults() => this.SetUpLantern(ModContent.ItemType()); public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); public override bool CanExplode(int i, int j) => false; @@ -58,14 +46,24 @@ namespace CalamityMod.Tiles.FurnitureWulfrum } } - public override void HitWire(int i, int j) + public override void GetTileFlameData(int i, int j, ref TileDrawing.TileFlameData tileFlameData) { - CalamityUtils.LightHitWire(Type, i, j, 1, 3); + ulong flameSeed = Main.TileFrameSeed ^ (ulong)(((long)i << 32) | (uint)j); + tileFlameData.flameSeed = flameSeed; + tileFlameData.flameTexture = FlameTexture.Value; + tileFlameData.flameColor = new Color(102, 115, 128, 0); + tileFlameData.flameCount = 3; + tileFlameData.flameRangeXMin = -10; + tileFlameData.flameRangeXMax = 11; + tileFlameData.flameRangeYMin = -10; + tileFlameData.flameRangeYMax = 11; + tileFlameData.flameRangeMultX = 0.1f; + tileFlameData.flameRangeMultY = 0.1f; } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + public override void HitWire(int i, int j) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumLanternFlame").Value, i, j); + FurnitureCommon.LightHitWire(Type, i, j, 1, 3); } } } diff --git a/Tiles/FurnitureWulfrum/WulfrumLantern.png b/Tiles/FurnitureWulfrum/WulfrumLantern.png index 4eda4d5984..66521d13f8 100644 Binary files a/Tiles/FurnitureWulfrum/WulfrumLantern.png and b/Tiles/FurnitureWulfrum/WulfrumLantern.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumLanternFlame.png b/Tiles/FurnitureWulfrum/WulfrumLanternFlame.png index 8a4b6a04cb..efc098ace6 100644 Binary files a/Tiles/FurnitureWulfrum/WulfrumLanternFlame.png and b/Tiles/FurnitureWulfrum/WulfrumLanternFlame.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumPanels.cs b/Tiles/FurnitureWulfrum/WulfrumPanels.cs new file mode 100644 index 0000000000..31411dbbbc --- /dev/null +++ b/Tiles/FurnitureWulfrum/WulfrumPanels.cs @@ -0,0 +1,44 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class WulfrumPanels : ModTile + { + private const short subsheetWidth = 216; + private const short subsheetHeight = 72; + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + HitSound = CommonCalamitySounds.PlatingMine; + AddMapEntry(new Color(89, 113, 91)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; + } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + int xPos = i % 2; + int yPos = j % 2; + frameXOffset = xPos * subsheetWidth; + frameYOffset = yPos * subsheetHeight; + } + } +} diff --git a/Tiles/FurnitureWulfrum/WulfrumPanels.png b/Tiles/FurnitureWulfrum/WulfrumPanels.png new file mode 100644 index 0000000000..9ad4d8635f Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumPanels.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumPiano.cs b/Tiles/FurnitureWulfrum/WulfrumPiano.cs index 6c695135ba..89ded212fb 100644 --- a/Tiles/FurnitureWulfrum/WulfrumPiano.cs +++ b/Tiles/FurnitureWulfrum/WulfrumPiano.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumPiano : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpPiano(ModContent.ItemType(), true); public override bool CreateDust(int i, int j, ref int type) @@ -28,7 +31,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumPianoGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumPianoGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumPlatform.cs b/Tiles/FurnitureWulfrum/WulfrumPlatform.cs new file mode 100644 index 0000000000..b79dff51c8 --- /dev/null +++ b/Tiles/FurnitureWulfrum/WulfrumPlatform.cs @@ -0,0 +1,66 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class WulfrumPlatform : ModTile + { + internal static Texture2D GlowTexture; + + public override void SetStaticDefaults() + { + if (!Main.dedServ) + { + GlowTexture = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumPlatform_Glow", AssetRequestMode.ImmediateLoad).Value; + } + this.SetUpPlatform(ModContent.ItemType(), true); + } + + public override bool CanExplode(int i, int j) => false; + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void PostSetDefaults() + { + Main.tileNoSunLight[Type] = false; + } + + 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) + { + // If the cached textures don't exist for some reason, don't bother using them. + if (GlowTexture is null) + return; + + Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); + if (tile.IsTileActuallyInvisible()) + return; + + int xPos = tile.TileFrameX; + int frameOffset = (i + j) % 6 * AnimationFrameHeight; + int yPos = tile.TileFrameY + frameOffset; + 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; + + if (!tile.IsHalfBlock) + { + spriteBatch.Draw(GlowTexture, drawPosition, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + else if (tile.IsHalfBlock) + { + spriteBatch.Draw(GlowTexture, drawPosition + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Tiles/FurnitureWulfrum/WulfrumPlatform.png b/Tiles/FurnitureWulfrum/WulfrumPlatform.png new file mode 100644 index 0000000000..a1b3cf4ee5 Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumPlatform.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumPlatform_Glow.png b/Tiles/FurnitureWulfrum/WulfrumPlatform_Glow.png new file mode 100644 index 0000000000..c736697170 Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumPlatform_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumPlating.cs b/Tiles/FurnitureWulfrum/WulfrumPlating.cs index 6132c842d2..96b01aea7f 100644 --- a/Tiles/FurnitureWulfrum/WulfrumPlating.cs +++ b/Tiles/FurnitureWulfrum/WulfrumPlating.cs @@ -1,9 +1,7 @@ -using CalamityMod.Dusts; +using CalamityMod.Sounds; using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -11,18 +9,19 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumPlating : ModTile { - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - private const short subsheetWidth = 324; - private const short subsheetHeight = 90; + private const short subsheetWidth = 216; + private const short subsheetHeight = 72; public override void SetStaticDefaults() { Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); - HitSound = MinePlatingSound; + HitSound = CommonCalamitySounds.PlatingMine; AddMapEntry(new Color(155, 171, 117)); } @@ -34,7 +33,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; } public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) diff --git a/Tiles/FurnitureWulfrum/WulfrumPlating.png b/Tiles/FurnitureWulfrum/WulfrumPlating.png index 47559138c5..e08047297f 100644 Binary files a/Tiles/FurnitureWulfrum/WulfrumPlating.png and b/Tiles/FurnitureWulfrum/WulfrumPlating.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumSheets.cs b/Tiles/FurnitureWulfrum/WulfrumSheets.cs new file mode 100644 index 0000000000..c908a78fd3 --- /dev/null +++ b/Tiles/FurnitureWulfrum/WulfrumSheets.cs @@ -0,0 +1,48 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class WulfrumSheets : ModTile + { + private const short subsheetWidth = 216; + private const short subsheetHeight = 72; + public static int TypeCache; + public override void SetStaticDefaults() + { + TypeCache = Type; + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = false; + Main.tileShine2[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + HitSound = CommonCalamitySounds.PlatingMine; + AddMapEntry(new Color(109, 132, 101)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFramingSystem.CompactFraming(i, j, resetFrame); + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + int xPos = i % 2; + int yPos = j % 2; + frameXOffset = xPos * subsheetWidth; + frameYOffset = yPos * subsheetHeight; + } + } +} diff --git a/Tiles/FurnitureWulfrum/WulfrumSheets.png b/Tiles/FurnitureWulfrum/WulfrumSheets.png new file mode 100644 index 0000000000..509cff2949 Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumSheets.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumSiding.cs b/Tiles/FurnitureWulfrum/WulfrumSiding.cs new file mode 100644 index 0000000000..81bd8a5d12 --- /dev/null +++ b/Tiles/FurnitureWulfrum/WulfrumSiding.cs @@ -0,0 +1,35 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class WulfrumSiding : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + + HitSound = CommonCalamitySounds.PlatingMine; + AddMapEntry(new Color(164, 150, 125)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/FurnitureWulfrum/WulfrumSiding.png b/Tiles/FurnitureWulfrum/WulfrumSiding.png new file mode 100644 index 0000000000..2a9b30f705 Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumSiding.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumSink.cs b/Tiles/FurnitureWulfrum/WulfrumSink.cs index 57bb0247c1..4d29f740a0 100644 --- a/Tiles/FurnitureWulfrum/WulfrumSink.cs +++ b/Tiles/FurnitureWulfrum/WulfrumSink.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumSink : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpSink(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -30,7 +33,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumSinkGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumSinkGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumSofa.cs b/Tiles/FurnitureWulfrum/WulfrumSofa.cs index 33bfbecd49..cec7d458bf 100644 --- a/Tiles/FurnitureWulfrum/WulfrumSofa.cs +++ b/Tiles/FurnitureWulfrum/WulfrumSofa.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -11,6 +12,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumSofa : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpSofa(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -26,11 +29,11 @@ namespace CalamityMod.Tiles.FurnitureWulfrum num = fail ? 1 : 3; } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(i, j, ref info); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType()); + public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType()); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { @@ -44,7 +47,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumSofaGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumSofaGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumTable.cs b/Tiles/FurnitureWulfrum/WulfrumTable.cs index a24280edb6..cbdcb1a206 100644 --- a/Tiles/FurnitureWulfrum/WulfrumTable.cs +++ b/Tiles/FurnitureWulfrum/WulfrumTable.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +9,8 @@ namespace CalamityMod.Tiles.FurnitureWulfrum { public class WulfrumTable : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpTable(ModContent.ItemType()); public override bool CanExplode(int i, int j) => false; @@ -30,7 +33,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumTableGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumTableGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/FurnitureWulfrum/WulfrumToilet.cs b/Tiles/FurnitureWulfrum/WulfrumToilet.cs index 81e68d00a2..7f576a0e9f 100644 --- a/Tiles/FurnitureWulfrum/WulfrumToilet.cs +++ b/Tiles/FurnitureWulfrum/WulfrumToilet.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -15,6 +16,9 @@ namespace CalamityMod.Tiles.FurnitureWulfrum public class WulfrumToilet : ModTile { public const int NextStyleHeight = 40; + + public Asset GlowTexture; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -66,7 +70,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumToiletGlow").Value; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumToiletGlow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; @@ -77,11 +84,11 @@ namespace CalamityMod.Tiles.FurnitureWulfrum spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); } - public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info, NextStyleHeight, true, shitter: true); + public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info, NextStyleHeight, true, shitter: true); - public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j); + public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j); - public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType(), true); + public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType(), true); public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) { diff --git a/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb.cs b/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb.cs new file mode 100644 index 0000000000..20e3e3fdca --- /dev/null +++ b/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb.cs @@ -0,0 +1,113 @@ +using CalamityMod.Sounds; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FurnitureWulfrum +{ + public class WulfrumWallMountedBulb : ModTile + { + public Asset GlowTexture; + + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileObsidianKill[Type] = false; + + HitSound = CommonCalamitySounds.PlatingMine; + DustType = DustID.KryptonMoss; + + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddMapEntry(new Color(92, 187, 99), CalamityUtils.GetItemName()); + + + // Attach to ground + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 10; // total 10 frames, all should be same "itemStyle" + TileObjectData.newTile.StyleWrapLimit = 2; // only 1 placement alternative per row + TileObjectData.newTile.Origin = new Point16(0, 1); + + // Attach to side (right) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.addAlternate(2); + + // Attach to ceiling + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(4); + + // Attach to side (left) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(6); + + // Attach to wall + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorWall = true; + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.addAlternate(8); + TileObjectData.addTile(Type); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void HitWire(int i, int j) + { + FurnitureCommon.LightHitWire(Type, i, j, 2, 2); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (Main.tile[i, j].TileFrameX < 18) + { + r = 141f / 255f; + g = 219f / 255f; + b = 84f / 255f; + } + else + { + r = 0f; + g = 0f; + b = 0f; + } + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (Main.tile[i, j].IsTileActuallyInvisible()) + return; + + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb_Glow"); + Texture2D tex = GlowTexture.Value; + + Tile tile = Main.tile[i, j]; + Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); + + TileFramingSystem.SlopedGlowmask(in tile, i, j, tex, frame, CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Color.White, false), default); + } + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); + } + } +} diff --git a/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb.png b/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb.png new file mode 100644 index 0000000000..3c4658b0ee Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb_Glow.png b/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb_Glow.png new file mode 100644 index 0000000000..b46c72f818 Binary files /dev/null and b/Tiles/FurnitureWulfrum/WulfrumWallMountedBulb_Glow.png differ diff --git a/Tiles/FurnitureWulfrum/WulfrumWorkBenchTile.cs b/Tiles/FurnitureWulfrum/WulfrumWorkBenchTile.cs index 9d88b5b592..b04416ed09 100644 --- a/Tiles/FurnitureWulfrum/WulfrumWorkBenchTile.cs +++ b/Tiles/FurnitureWulfrum/WulfrumWorkBenchTile.cs @@ -1,17 +1,17 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; -using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ObjectData; namespace CalamityMod.Tiles.FurnitureWulfrum { [LegacyName("WulfrumWorkbench")] public class WulfrumWorkBenchTile : ModTile { + public Asset GlowTexture; + public override void SetStaticDefaults() => this.SetUpWorkBench(ModContent.ItemType(), true); public override bool CanExplode(int i, int j) => false; @@ -34,7 +34,10 @@ namespace CalamityMod.Tiles.FurnitureWulfrum int xFrameOffset = Main.tile[i, j].TileFrameX; int yFrameOffset = Main.tile[i, j].TileFrameY; - Texture2D glowmask = ModContent.Request(Texture + "Glow").Value; + + GlowTexture ??= ModContent.Request(Texture + "Glow"); + Texture2D glowmask = GlowTexture.Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; Color drawColour = Color.White; diff --git a/Tiles/GiantPlanteraBulb.cs b/Tiles/GiantPlanteraBulb.cs index dfb8727821..1370f833fc 100644 --- a/Tiles/GiantPlanteraBulb.cs +++ b/Tiles/GiantPlanteraBulb.cs @@ -1,22 +1,17 @@ using System; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles { public class GiantPlanteraBulb : GlowMaskTile { - public override string GlowMaskAsset => $"{Texture}Glow"; - public override void SetupStatic() { GlowMaskPaintInteraction = PaintColorTint.None; @@ -30,9 +25,9 @@ namespace CalamityMod.Tiles // Various data sets to protect this tile from premature death TileID.Sets.PreventsTileRemovalIfOnTopOfIt[Type] = true; + TileID.Sets.PreventsTileHammeringIfOnTopOfIt[Type] = true; TileID.Sets.PreventsTileReplaceIfOnTopOfIt[Type] = true; TileID.Sets.PreventsSandfall[Type] = true; - // CalamityGlobalTile.PreventsAnchorTileChanges.Add(Type); // Object data TileObjectData.newTile.Width = 5; diff --git a/Tiles/GlowMaskCactus.cs b/Tiles/GlowMaskCactus.cs index 7232b67601..fa89763217 100644 --- a/Tiles/GlowMaskCactus.cs +++ b/Tiles/GlowMaskCactus.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using Terraria.GameContent.RGB; using Terraria.ModLoader; namespace CalamityMod.Tiles diff --git a/Tiles/GlowMaskPalmTree.cs b/Tiles/GlowMaskPalmTree.cs index ce30f5374c..bb1d426ce0 100644 --- a/Tiles/GlowMaskPalmTree.cs +++ b/Tiles/GlowMaskPalmTree.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Tiles diff --git a/Tiles/GlowMaskTile.cs b/Tiles/GlowMaskTile.cs index 8cbef860ca..13df0e44ca 100644 --- a/Tiles/GlowMaskTile.cs +++ b/Tiles/GlowMaskTile.cs @@ -1,12 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Terraria; +using Microsoft.Xna.Framework; using Terraria.DataStructures; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles @@ -29,13 +22,13 @@ namespace CalamityMod.Tiles public bool GlowMaskAffectedByLight = true; public bool GlowMaskCanBeCulled = true; - public abstract string GlowMaskAsset { get; } + public virtual string GlowMaskAsset => $"{Texture}Glow"; public sealed override void SetStaticDefaults() { if (GlowMask != null) { - CalamityMod.Instance.Logger.Error($"{Name} has called {nameof(SetStaticDefaults)} themselve! This is not allowed!"); + CalamityMod.Log.Error($"{Name} has called {nameof(SetStaticDefaults)} themselve! This is not allowed!"); return; } diff --git a/Tiles/GlowMaskTree.cs b/Tiles/GlowMaskTree.cs index 8e252b39e2..64f8c410bb 100644 --- a/Tiles/GlowMaskTree.cs +++ b/Tiles/GlowMaskTree.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria.ModLoader; diff --git a/Tiles/LivingFire/LivingPlagueFireBlockTile.cs b/Tiles/LivingFire/LivingPlagueFireBlockTile.cs index 7e30de8770..a99e7b7b64 100644 --- a/Tiles/LivingFire/LivingPlagueFireBlockTile.cs +++ b/Tiles/LivingFire/LivingPlagueFireBlockTile.cs @@ -1,5 +1,4 @@ using CalamityMod.Dusts; -using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; diff --git a/Tiles/Merges/AbyssGravelMerge.cs b/Tiles/Merges/AbyssGravelMerge.cs index 30a16d02bd..debd755417 100644 --- a/Tiles/Merges/AbyssGravelMerge.cs +++ b/Tiles/Merges/AbyssGravelMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; using Terraria.ModLoader; diff --git a/Tiles/Merges/AridSoilMerge.cs b/Tiles/Merges/AridSoilMerge.cs new file mode 100644 index 0000000000..8e8cf8cbde --- /dev/null +++ b/Tiles/Merges/AridSoilMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class AridSoilMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/AridSoilMerge.png b/Tiles/Merges/AridSoilMerge.png new file mode 100644 index 0000000000..cdd750fcbf Binary files /dev/null and b/Tiles/Merges/AridSoilMerge.png differ diff --git a/Tiles/Merges/AshMerge.cs b/Tiles/Merges/AshMerge.cs index 0e40adacc3..3b4beaa50f 100644 --- a/Tiles/Merges/AshMerge.cs +++ b/Tiles/Merges/AshMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/AstralDirtMerge.cs b/Tiles/Merges/AstralDirtMerge.cs index bd375f30ce..8bf2698f30 100644 --- a/Tiles/Merges/AstralDirtMerge.cs +++ b/Tiles/Merges/AstralDirtMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Astral; using Terraria.ModLoader; diff --git a/Tiles/Merges/AstralSandMerge.cs b/Tiles/Merges/AstralSandMerge.cs index 993c97bb4e..734a8ca045 100644 --- a/Tiles/Merges/AstralSandMerge.cs +++ b/Tiles/Merges/AstralSandMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.AstralDesert; using Terraria.ModLoader; diff --git a/Tiles/Merges/AstralSandstoneMerge.cs b/Tiles/Merges/AstralSandstoneMerge.cs index 83be67fd5b..1008e55a4f 100644 --- a/Tiles/Merges/AstralSandstoneMerge.cs +++ b/Tiles/Merges/AstralSandstoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.AstralDesert; using Terraria.ModLoader; diff --git a/Tiles/Merges/AstralSnowMerge.cs b/Tiles/Merges/AstralSnowMerge.cs index 8b3719fbda..043140df06 100644 --- a/Tiles/Merges/AstralSnowMerge.cs +++ b/Tiles/Merges/AstralSnowMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ModLoader; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/BasaltMerge.cs b/Tiles/Merges/BasaltMerge.cs new file mode 100644 index 0000000000..643b3fda83 --- /dev/null +++ b/Tiles/Merges/BasaltMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class BasaltMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/BasaltMerge.png b/Tiles/Merges/BasaltMerge.png new file mode 100644 index 0000000000..a3a1159043 Binary files /dev/null and b/Tiles/Merges/BasaltMerge.png differ diff --git a/Tiles/Merges/BrimstoneSlagMerge.cs b/Tiles/Merges/BrimstoneSlagMerge.cs index e6839eab2c..acdd10c064 100644 --- a/Tiles/Merges/BrimstoneSlagMerge.cs +++ b/Tiles/Merges/BrimstoneSlagMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Crags; using Terraria.ModLoader; diff --git a/Tiles/Merges/CloudMerge.cs b/Tiles/Merges/CloudMerge.cs index 486a71992f..b31fccefeb 100644 --- a/Tiles/Merges/CloudMerge.cs +++ b/Tiles/Merges/CloudMerge.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.Merges { diff --git a/Tiles/Merges/DirtMerge.cs b/Tiles/Merges/DirtMerge.cs index 4b7fdf821f..a960cc6672 100644 --- a/Tiles/Merges/DirtMerge.cs +++ b/Tiles/Merges/DirtMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/DunesandMerge.cs b/Tiles/Merges/DunesandMerge.cs new file mode 100644 index 0000000000..d7d72de92e --- /dev/null +++ b/Tiles/Merges/DunesandMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class DunesandMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/DunesandMerge.png b/Tiles/Merges/DunesandMerge.png new file mode 100644 index 0000000000..53c2ac41f4 Binary files /dev/null and b/Tiles/Merges/DunesandMerge.png differ diff --git a/Tiles/Merges/EutrophicSandMerge.cs b/Tiles/Merges/EutrophicSandMerge.cs index 84f5014349..330b184a95 100644 --- a/Tiles/Merges/EutrophicSandMerge.cs +++ b/Tiles/Merges/EutrophicSandMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.SunkenSea; using Terraria.ModLoader; diff --git a/Tiles/Merges/HardenedSandMerge.cs b/Tiles/Merges/HardenedSandMerge.cs index d82124c471..3683363fc7 100644 --- a/Tiles/Merges/HardenedSandMerge.cs +++ b/Tiles/Merges/HardenedSandMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/HardenedSulphurousSandstoneMerge.cs b/Tiles/Merges/HardenedSulphurousSandstoneMerge.cs index 11c38bb34b..58b20969e9 100644 --- a/Tiles/Merges/HardenedSulphurousSandstoneMerge.cs +++ b/Tiles/Merges/HardenedSulphurousSandstoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; using Terraria.ModLoader; diff --git a/Tiles/Merges/LuminiteMerge.cs b/Tiles/Merges/LuminiteMerge.cs index b98f1566ac..a3d3d1e50b 100644 --- a/Tiles/Merges/LuminiteMerge.cs +++ b/Tiles/Merges/LuminiteMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/MudMerge.cs b/Tiles/Merges/MudMerge.cs index 85b2fcc6fa..7703ccfb48 100644 --- a/Tiles/Merges/MudMerge.cs +++ b/Tiles/Merges/MudMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/NavystoneMerge.cs b/Tiles/Merges/NavystoneMerge.cs index fc4331fe19..45bd611dcb 100644 --- a/Tiles/Merges/NavystoneMerge.cs +++ b/Tiles/Merges/NavystoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.SunkenSea; using Terraria.ModLoader; diff --git a/Tiles/Merges/PearlstoneMerge.cs b/Tiles/Merges/PearlstoneMerge.cs index 9e6a376cfd..90e9d6e095 100644 --- a/Tiles/Merges/PearlstoneMerge.cs +++ b/Tiles/Merges/PearlstoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/PolypSandMerge.cs b/Tiles/Merges/PolypSandMerge.cs new file mode 100644 index 0000000000..255761a7ff --- /dev/null +++ b/Tiles/Merges/PolypSandMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class PolypSandMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/PolypSandMerge.png b/Tiles/Merges/PolypSandMerge.png new file mode 100644 index 0000000000..46df8a4b5b Binary files /dev/null and b/Tiles/Merges/PolypSandMerge.png differ diff --git a/Tiles/Merges/PyreMantleMerge.cs b/Tiles/Merges/PyreMantleMerge.cs index 73458c5c7c..f2a782e11a 100644 --- a/Tiles/Merges/PyreMantleMerge.cs +++ b/Tiles/Merges/PyreMantleMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; using Terraria.ModLoader; diff --git a/Tiles/Merges/RainCloudMerge.cs b/Tiles/Merges/RainCloudMerge.cs index a741cf99cb..2801659c42 100644 --- a/Tiles/Merges/RainCloudMerge.cs +++ b/Tiles/Merges/RainCloudMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/RunestoneMerge.cs b/Tiles/Merges/RunestoneMerge.cs new file mode 100644 index 0000000000..0123e16d8b --- /dev/null +++ b/Tiles/Merges/RunestoneMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class RunestoneMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/RunestoneMerge.png b/Tiles/Merges/RunestoneMerge.png new file mode 100644 index 0000000000..ed589b1070 Binary files /dev/null and b/Tiles/Merges/RunestoneMerge.png differ diff --git a/Tiles/Merges/SandMerge.cs b/Tiles/Merges/SandMerge.cs index f52a18a8ff..f411f371ef 100644 --- a/Tiles/Merges/SandMerge.cs +++ b/Tiles/Merges/SandMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/SandstoneMerge.cs b/Tiles/Merges/SandstoneMerge.cs index 3bf4d424f6..76910198ba 100644 --- a/Tiles/Merges/SandstoneMerge.cs +++ b/Tiles/Merges/SandstoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/ScarletSeaGrassTileMerge.cs b/Tiles/Merges/ScarletSeaGrassTileMerge.cs new file mode 100644 index 0000000000..5d3edccfac --- /dev/null +++ b/Tiles/Merges/ScarletSeaGrassTileMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class ScarletSeaGrassTileMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/ScarletSeaGrassTileMerge.png b/Tiles/Merges/ScarletSeaGrassTileMerge.png new file mode 100644 index 0000000000..46df8a4b5b Binary files /dev/null and b/Tiles/Merges/ScarletSeaGrassTileMerge.png differ diff --git a/Tiles/Merges/ShellstoneMerge.cs b/Tiles/Merges/ShellstoneMerge.cs new file mode 100644 index 0000000000..7a8b30e399 --- /dev/null +++ b/Tiles/Merges/ShellstoneMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class ShellstoneMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/ShellstoneMerge.png b/Tiles/Merges/ShellstoneMerge.png new file mode 100644 index 0000000000..1b4e76e78e Binary files /dev/null and b/Tiles/Merges/ShellstoneMerge.png differ diff --git a/Tiles/Merges/SnowCloudMerge.cs b/Tiles/Merges/SnowCloudMerge.cs index be9736bf56..d68570dd0f 100644 --- a/Tiles/Merges/SnowCloudMerge.cs +++ b/Tiles/Merges/SnowCloudMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/SnowMerge.cs b/Tiles/Merges/SnowMerge.cs index 374ddd1d15..f24e285a85 100644 --- a/Tiles/Merges/SnowMerge.cs +++ b/Tiles/Merges/SnowMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/StoneMerge.cs b/Tiles/Merges/StoneMerge.cs index 1ce0e06c10..df9f2c9c65 100644 --- a/Tiles/Merges/StoneMerge.cs +++ b/Tiles/Merges/StoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using Terraria.ID; namespace CalamityMod.Tiles.Merges diff --git a/Tiles/Merges/SulphurousSandMerge.cs b/Tiles/Merges/SulphurousSandMerge.cs index ff3e1e2664..8edc7f121a 100644 --- a/Tiles/Merges/SulphurousSandMerge.cs +++ b/Tiles/Merges/SulphurousSandMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; using Terraria.ModLoader; diff --git a/Tiles/Merges/SulphurousSandstoneMerge.cs b/Tiles/Merges/SulphurousSandstoneMerge.cs index ad3648857a..bc675b26be 100644 --- a/Tiles/Merges/SulphurousSandstoneMerge.cs +++ b/Tiles/Merges/SulphurousSandstoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; using Terraria.ModLoader; diff --git a/Tiles/Merges/SulphurousShaleMerge.cs b/Tiles/Merges/SulphurousShaleMerge.cs index 9fc08075c5..eb159c3ff7 100644 --- a/Tiles/Merges/SulphurousShaleMerge.cs +++ b/Tiles/Merges/SulphurousShaleMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; using Terraria.ModLoader; diff --git a/Tiles/Merges/SuperheatedObsidian.png b/Tiles/Merges/SuperheatedObsidian.png new file mode 100644 index 0000000000..37c2a0baae Binary files /dev/null and b/Tiles/Merges/SuperheatedObsidian.png differ diff --git a/Tiles/Merges/VoidstoneMerge.cs b/Tiles/Merges/VoidstoneMerge.cs index 0f827eafc6..4e4252401f 100644 --- a/Tiles/Merges/VoidstoneMerge.cs +++ b/Tiles/Merges/VoidstoneMerge.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; using Terraria.ModLoader; diff --git a/Tiles/Merges/VolcanicSandMerge.cs b/Tiles/Merges/VolcanicSandMerge.cs new file mode 100644 index 0000000000..a13e5c61d8 --- /dev/null +++ b/Tiles/Merges/VolcanicSandMerge.cs @@ -0,0 +1,11 @@ +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Merges +{ + public sealed class VolcanicSandMerge : TileBlendTexture + { + public override int TileType => ModContent.TileType(); + } +} diff --git a/Tiles/Merges/VolcanicSandMerge.png b/Tiles/Merges/VolcanicSandMerge.png new file mode 100644 index 0000000000..860fd97de2 Binary files /dev/null and b/Tiles/Merges/VolcanicSandMerge.png differ diff --git a/Tiles/MonsterBanner.cs b/Tiles/MonsterBanner.cs index f373478e23..12cd3e56cb 100644 --- a/Tiles/MonsterBanner.cs +++ b/Tiles/MonsterBanner.cs @@ -1,11 +1,9 @@ -using CalamityMod.Items.Placeables.Banners; -using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; -using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.Crags; +using CalamityMod.NPCs.Deconstructors; using CalamityMod.NPCs.DraedonLabThings; -using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.SulphurousSea; @@ -30,6 +28,7 @@ namespace CalamityMod.Tiles Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; TileID.Sets.MultiTileSway[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top); TileObjectData.newTile.Height = 3; @@ -43,21 +42,21 @@ namespace CalamityMod.Tiles TileObjectData.addAlternate(0); TileObjectData.addTile(Type); DustType = -1; - TileID.Sets.DisableSmartCursor[Type] = true; AddMapEntry(new Color(13, 88, 130), Language.GetText("MapObject.Banner")); } public override void NearbyEffects(int i, int j, bool closer) { - if (!closer) - return; - Player player = Main.LocalPlayer; - if (player is null || !player.active || player.dead) + if (closer) return; int style = Main.tile[i, j].TileFrameX / 18; int npc = GetBannerNPC(style); - if (npc != -1) + if (npc == -1) + return; + + int itemType = TileLoader.GetItemDropFromTypeAndStyle(Type, style); + if (ItemID.Sets.BannerStrength.IndexInRange(itemType) && ItemID.Sets.BannerStrength[itemType].Enabled) { Main.SceneMetrics.NPCBannerBuff[npc] = true; Main.SceneMetrics.hasBanner = true; @@ -66,6 +65,8 @@ namespace CalamityMod.Tiles public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => CalamityUtils.DrawSwayingMultiTile(i, j); + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) => offsetY += 2; + public static int GetBannerNPC(int style) { int npc = -1; @@ -105,7 +106,7 @@ namespace CalamityMod.Tiles npc = NPCType(); break; case 11: - npc = NPCType(); // There's also the boss variant but I dont think we want banners to affect them? + npc = NPCType(); // There's also the boss variant but I dont think we want banners to affect them? break; /*case 12: npc = NPCType(); - Formerly Sea Urchin @@ -300,10 +301,10 @@ namespace CalamityMod.Tiles npc = NPCType(); - Formerly Cosmic Elemental break*/ case 76: - npc = NPCType(); + npc = NPCType(); break; case 77: - npc = NPCType(); + npc = NPCType(); break; case 78: npc = NPCType(); @@ -383,14 +384,14 @@ namespace CalamityMod.Tiles case 103: npc = NPCType(); break; - /*case 104: - npc = NPCType(); - Formerly Blinded Angler - break*/ + case 104: + npc = NPCType(); + break; case 105: npc = NPCType(); break; case 106: - npc = NPCType(); + npc = NPCType(); break; /*case 107: npc = NPCType(); - Formerly Giant Clam @@ -464,6 +465,69 @@ namespace CalamityMod.Tiles case 130: npc = NPCType(); break; + case 131: + npc = NPCType(); + break; + case 132: + npc = NPCType(); + break; + /* case 133: + npc = NPCType(); // NOT YET IMPLEMENTED. Banner sprite is already on the mastersheet and associated with this case/position. + break; */ + case 134: + npc = NPCType(); + break; + case 135: + npc = NPCType(); + break; + case 136: + npc = NPCType(); + break; + case 137: + npc = NPCType(); + break; + case 138: + npc = NPCType(); + break; + /* case 139: + npc = NPCType(); // NOT YET IMPLEMENTED. Banner sprite is already on the mastersheet and associated with this case/position. + break; */ + /* case 140: + npc = NPCType(); // NOT YET IMPLEMENTED. Banner sprite is already on the mastersheet and associated with this case/position. + break; */ + case 141: + npc = NPCType(); // Logic should be applying to other variants + break; + case 142: + npc = NPCType(); + break; + case 143: + npc = NPCType(); + break; + case 144: + npc = NPCType(); + break; + case 145: + npc = NPCType(); + break; + case 146: + npc = NPCType(); + break; + case 147: + npc = NPCType(); + break; + case 148: + npc = NPCType(); + break; + case 149: + npc = NPCType(); + break; + case 150: + npc = NPCType(); + break; + /* case 151: + npc = NPCType(); // NOT YET IMPLEMENTED. Banner sprite is already on the mastersheet and associated with this case/position. + break; */ default: break; } diff --git a/Tiles/MonsterBanner.png b/Tiles/MonsterBanner.png index 139aa66e76..4142434796 100644 Binary files a/Tiles/MonsterBanner.png and b/Tiles/MonsterBanner.png differ diff --git a/Tiles/Ores/AerialiteOre.cs b/Tiles/Ores/AerialiteOre.cs index 29a95d6be6..a1f9c628d2 100644 --- a/Tiles/Ores/AerialiteOre.cs +++ b/Tiles/Ores/AerialiteOre.cs @@ -37,16 +37,16 @@ namespace CalamityMod.Tiles.Ores Main.tileShine2[Type] = false; TileID.Sets.ChecksForMerge[Type] = true; - DustType = 33; + DustType = DustID.Water; AddMapEntry(new Color(145, 255, 255), CreateMapEntryName()); MinPick = 65; HitSound = MineSound; Main.tileSpelunker[Type] = true; - 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"); + this.RegisterBlendMergeWith(TileID.Cloud); + this.RegisterBlendMergeWith(TileID.RainCloud); + this.RegisterBlendMergeWith(TileID.SnowCloud); + this.RegisterBlendMergeWith(TileID.Dirt); } public override void PostSetDefaults() { diff --git a/Tiles/Ores/AerialiteOreDisenchanted.cs b/Tiles/Ores/AerialiteOreDisenchanted.cs index 9e067e8c91..d2b42c4194 100644 --- a/Tiles/Ores/AerialiteOreDisenchanted.cs +++ b/Tiles/Ores/AerialiteOreDisenchanted.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,7 +9,7 @@ namespace CalamityMod.Tiles.Ores public class AerialiteOreDisenchanted : ModTile { private const int AnimationFrameWidth = 234; - + public override void SetStaticDefaults() { Main.tileBlockLight[Type] = true; @@ -32,16 +30,16 @@ namespace CalamityMod.Tiles.Ores Main.tileShine2[Type] = false; TileID.Sets.ChecksForMerge[Type] = true; - DustType = 33; + DustType = DustID.Water; AddMapEntry(new Color(204, 170, 81), CreateMapEntryName()); MinPick = 110; HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; - 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"); + this.RegisterBlendMergeWith(TileID.Cloud); + this.RegisterBlendMergeWith(TileID.RainCloud); + this.RegisterBlendMergeWith(TileID.SnowCloud); + this.RegisterBlendMergeWith(TileID.Dirt); } public override void PostSetDefaults() { @@ -57,7 +55,7 @@ namespace CalamityMod.Tiles.Ores { return false; } - + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { frameXOffset = AnimationFrameWidth * TileFramingSystem.GetVariation4x4_012_Low0(i, j); diff --git a/Tiles/Ores/AstralOre.cs b/Tiles/Ores/AstralOre.cs index 15fb17f402..d3a404368b 100644 --- a/Tiles/Ores/AstralOre.cs +++ b/Tiles/Ores/AstralOre.cs @@ -5,7 +5,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Tiles.Astral; using CalamityMod.World; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -31,7 +30,7 @@ namespace CalamityMod.Tiles.Ores TileID.Sets.OreMergesWithMud[Type] = true; MinPick = 110; - DustType = 173; + DustType = DustID.ShadowbeamStaff; AddMapEntry(new Color(255, 153, 255), CreateMapEntryName()); MineResist = 3f; HitSound = SoundID.Tink; @@ -41,12 +40,12 @@ namespace CalamityMod.Tiles.Ores // TileID.Sets.DoesntGetReplacedWithTileReplacement[Type] = true; TileID.Sets.AvoidedByMeteorLanding[Type] = true; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AstralDirtMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void NearbyEffects(int i, int j, bool closer) { if (j < 2) - return; + return; Tile tile = Main.tile[i, j]; Tile up = Main.tile[i, j - 1]; Tile up2 = Main.tile[i, j - 2]; diff --git a/Tiles/Ores/AuricOre.cs b/Tiles/Ores/AuricOre.cs index db314ce609..9df1a749aa 100644 --- a/Tiles/Ores/AuricOre.cs +++ b/Tiles/Ores/AuricOre.cs @@ -1,17 +1,8 @@ -using System.Collections.Generic; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Systems; -using CalamityMod.Tiles.Astral; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; namespace CalamityMod.Tiles.Ores { @@ -20,8 +11,6 @@ namespace CalamityMod.Tiles.Ores public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AuricMine", 3); public static bool Animate; - public override string GlowMaskAsset => "CalamityMod/Tiles/Ores/AuricOreGlow"; - public override void SetupStatic() { AnimationFrameHeight = 90; @@ -38,14 +27,14 @@ namespace CalamityMod.Tiles.Ores TileID.Sets.Ore[Type] = true; TileID.Sets.OreMergesWithMud[Type] = true; - DustType = 55; + DustType = DustID.Pixie; AddMapEntry(new Color(255, 200, 0), CreateMapEntryName()); MineResist = 5f; MinPick = 250; HitSound = MineSound; - - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override bool CanExplode(int i, int j) diff --git a/Tiles/Ores/ExodiumOre.cs b/Tiles/Ores/ExodiumOre.cs index 298a81c0e1..6909d9ce98 100644 --- a/Tiles/Ores/ExodiumOre.cs +++ b/Tiles/Ores/ExodiumOre.cs @@ -1,11 +1,6 @@ - -using System.Collections.Generic; -using CalamityMod.Items.Placeables.Ores; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores @@ -35,8 +30,8 @@ namespace CalamityMod.Tiles.Ores TileID.Sets.ChecksForMerge[Type] = true; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.LunarOre, "CalamityMod/Tiles/Merges/LuminiteMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.LunarOre); } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/Ores/HallowedOre.cs b/Tiles/Ores/HallowedOre.cs index dfe58dd453..435b3b19fd 100644 --- a/Tiles/Ores/HallowedOre.cs +++ b/Tiles/Ores/HallowedOre.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores @@ -33,7 +29,7 @@ namespace CalamityMod.Tiles.Ores HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; - this.RegisterUniversalMerge(TileID.Pearlstone, "CalamityMod/Tiles/Merges/PearlstoneMerge"); + this.RegisterBlendMergeWith(TileID.Pearlstone); } public override bool CanExplode(int i, int j) diff --git a/Tiles/Ores/InfernalSuevite.cs b/Tiles/Ores/InfernalSuevite.cs index 9c5aa5ff20..aa68efb164 100644 --- a/Tiles/Ores/InfernalSuevite.cs +++ b/Tiles/Ores/InfernalSuevite.cs @@ -1,10 +1,7 @@ -using System.Collections.Generic; -using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.Crags; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores @@ -14,7 +11,7 @@ namespace CalamityMod.Tiles.Ores { private int sheetWidth = 234; private int sheetHeight = 90; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -31,11 +28,11 @@ namespace CalamityMod.Tiles.Ores MineResist = 2f; MinPick = 150; HitSound = SoundID.Tink; - DustType = 235; + DustType = DustID.LifeDrain; Main.tileSpelunker[Type] = true; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/BrimstoneSlagMerge"); - this.RegisterUniversalMerge(TileID.Ash, "CalamityMod/Tiles/Merges/AshMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Ash); } public override bool CanExplode(int i, int j) diff --git a/Tiles/Ores/PerennialOre.cs b/Tiles/Ores/PerennialOre.cs index 36f4363de3..a26a343c5f 100644 --- a/Tiles/Ores/PerennialOre.cs +++ b/Tiles/Ores/PerennialOre.cs @@ -1,16 +1,10 @@  using System; -using System.Collections.Generic; using CalamityMod.Systems; -using CalamityMod.Tiles.FloralParadise; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { @@ -18,8 +12,6 @@ namespace CalamityMod.Tiles.Ores { public const int AnimationFrameWidth = 234; - public override string GlowMaskAsset => "CalamityMod/Tiles/Ores/PerennialOreGlow"; - public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -31,7 +23,6 @@ namespace CalamityMod.Tiles.Ores Main.tileShine2[Type] = true; CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeWithFloralParadise(Type); TileID.Sets.Ore[Type] = true; TileID.Sets.OreMergesWithMud[Type] = true; @@ -42,14 +33,14 @@ namespace CalamityMod.Tiles.Ores HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Mud); } - - + + public override bool CanExplode(int i, int j) { @@ -61,50 +52,60 @@ namespace CalamityMod.Tiles.Ores num = fail ? 1 : 3; } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + var tile = Main.tile[i, j]; + var frameX = tile.TileFrameX; + var frameY = tile.TileFrameY; + + bool hasFlowerInFrame = false; + switch (frameX) + { + case 0 when frameY == 0: + hasFlowerInFrame = true; + break; + + case 18 when frameY == 18: + hasFlowerInFrame = true; + break; + + case 36 when frameY == 0 || frameY == 36: + hasFlowerInFrame = true; + break; + + case 54 when frameY == 18: + hasFlowerInFrame = true; + break; + } + + tile.Get().Flag0 = hasFlowerInFrame; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { // The base green color glow r = 0.08f; g = 0.2f; b = 0.04f; - var tile = Main.tile[i, j]; - var pos = new Vector2(tile.TileFrameX, tile.TileFrameY); - Vector2[] positionsFlower = new Vector2[] + // Flower color glow + if (Main.tile[i, j].Get().Flag0) { - // Top row (always y = 0 on tile sheets) - new Vector2(0, 0), - new Vector2(36, 0), + float timeScalar = Main.GameUpdateCount * 0.017f; + float jDiv14 = j / 14f; + float iDiv14 = i / 14f; + float brightness = 0.7f; + brightness *= (float)MathF.Sin(jDiv14 + timeScalar); + brightness *= (float)MathF.Sin(iDiv14 + timeScalar); + brightness += 0.3f; + float flowerPosBrightnessR = 0.83f * brightness; + float flowerPosBrightnessG = 0.16f * brightness; + float flowerPosBrightnessB = 0.31f * brightness; - // Second row (always y = 18 on tile sheets) - new Vector2(18, 18), - new Vector2(54, 18), - - // Third row (always y = 36 on tile sheets) - new Vector2(36, 36), - - }; - - foreach (var positionFlower in positionsFlower) - { - if (pos == positionFlower) - { - float timeScalar = Main.GameUpdateCount * 0.017f; - float jDiv14 = j / 14f; - float iDiv14 = i / 14f; - float brightness = 0.7f; - brightness *= (float)MathF.Sin(jDiv14 + timeScalar); - brightness *= (float)MathF.Sin(iDiv14 + timeScalar); - brightness += 0.3f; - float flowerPosBrightnessR = 0.83f * brightness; - float flowerPosBrightnessG = 0.16f * brightness; - float flowerPosBrightnessB = 0.31f * brightness; - - // Adjust brightness for flowers - r = flowerPosBrightnessR; - g = flowerPosBrightnessG; - b = flowerPosBrightnessB; - } + // Adjust brightness for flowers + r = flowerPosBrightnessR; + g = flowerPosBrightnessG; + b = flowerPosBrightnessB; } } diff --git a/Tiles/Ores/ScoriaOre.cs b/Tiles/Ores/ScoriaOre.cs index d29d32726f..e0d212ad35 100644 --- a/Tiles/Ores/ScoriaOre.cs +++ b/Tiles/Ores/ScoriaOre.cs @@ -1,13 +1,9 @@ -using System.Collections.Generic; -using CalamityMod.Projectiles.Environment; -using CalamityMod.Systems; +using CalamityMod.Projectiles.Environment; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores @@ -15,8 +11,6 @@ namespace CalamityMod.Tiles.Ores [LegacyName("ChaoticOre")] public class ScoriaOre : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Ores/ScoriaOreGlow"; - public override void SetupStatic() { Main.tileLighted[Type] = true; @@ -29,14 +23,14 @@ namespace CalamityMod.Tiles.Ores TileID.Sets.Ore[Type] = true; - DustType = 105; - AddMapEntry(new Color(210, 101, 28), CreateMapEntryName()); + DustType = DustID.Water_BloodMoon; + AddMapEntry(new Color(167, 80, 22), CreateMapEntryName()); MineResist = 3f; MinPick = 210; HitSound = SoundID.Tink; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/AbyssGravelMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/PyreMantleMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void NearbyEffects(int i, int j, bool closer) @@ -73,6 +67,10 @@ namespace CalamityMod.Tiles.Ores } } + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + World.Abyss.FillTileWithWater(i, j); + } public override bool CanExplode(int i, int j) { return false; diff --git a/Tiles/Ores/UelibloomOre.cs b/Tiles/Ores/UelibloomOre.cs index 4390cf8fd6..abdd9c2ce0 100644 --- a/Tiles/Ores/UelibloomOre.cs +++ b/Tiles/Ores/UelibloomOre.cs @@ -1,10 +1,6 @@ - -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores @@ -30,9 +26,9 @@ namespace CalamityMod.Tiles.Ores Main.tileSpelunker[Type] = true; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool CanExplode(int i, int j) diff --git a/Tiles/PerennialBar.cs b/Tiles/PerennialBar.cs index 2fb85c5bcc..7e708d6b42 100644 --- a/Tiles/PerennialBar.cs +++ b/Tiles/PerennialBar.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles @@ -9,7 +10,7 @@ namespace CalamityMod.Tiles public override void SetStaticDefaults() { this.SetUpBar(ModContent.ItemType(), new Color(157, 255, 0)); - DustType = 44; + DustType = DustID.JungleSpore; } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/PerennialBrick.cs b/Tiles/PerennialBrick.cs index 0b647557dc..b668c98e0a 100644 --- a/Tiles/PerennialBrick.cs +++ b/Tiles/PerennialBrick.cs @@ -1,7 +1,4 @@ - -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -24,9 +21,9 @@ namespace CalamityMod.Tiles AddMapEntry(new Color(17, 133, 46)); AnimationFrameHeight = 90; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/PerennialTreeVines.png b/Tiles/PerennialTreeVines.png deleted file mode 100644 index 19356dd5fe..0000000000 Binary files a/Tiles/PerennialTreeVines.png and /dev/null differ diff --git a/Tiles/PlacedRock.cs b/Tiles/PlacedRock.cs index 568059c2bb..947ebfe7d8 100644 --- a/Tiles/PlacedRock.cs +++ b/Tiles/PlacedRock.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Tiles/Plates/Cinderplate.cs b/Tiles/Plates/Cinderplate.cs index f59526667e..1f2a8277bd 100644 --- a/Tiles/Plates/Cinderplate.cs +++ b/Tiles/Plates/Cinderplate.cs @@ -1,43 +1,27 @@ - +using CalamityMod.ExtraTextures.GreyscaleGradients; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.Plates { public class Cinderplate : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Plates/CinderplateGlow"; - - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetupStatic() { - PulseGradient = new("CalamityMod/Tiles/Plates/CinderplatePulse"); - Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; + HitSound = CommonCalamitySounds.PlatingMine; MineResist = 1f; AddMapEntry(new Color(242, 216, 131)); } - public override void OnUnload() - { - PulseGradient?.Unload(); - PulseGradient = null; - } - public override bool CreateDust(int i, int j, ref int type) { Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Torch, 0f, 0f, 1, new Color(255, 255, 255), 1f); @@ -52,7 +36,7 @@ namespace CalamityMod.Tiles.Plates public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.CinderplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = 0.04f + (brightness * 0.156f); return Color.White * brightness; } diff --git a/Tiles/Plates/Elumplate.cs b/Tiles/Plates/Elumplate.cs index 9578aae8e5..2241020873 100644 --- a/Tiles/Plates/Elumplate.cs +++ b/Tiles/Plates/Elumplate.cs @@ -1,42 +1,26 @@ - +using CalamityMod.ExtraTextures.GreyscaleGradients; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.Plates { public class Elumplate : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Plates/ElumplateGlow"; - - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetupStatic() { - PulseGradient = new("CalamityMod/Tiles/Plates/ElumplatePulse"); - Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; + HitSound = CommonCalamitySounds.PlatingMine; MineResist = 1f; AddMapEntry(new Color(121, 180, 212)); } - public override void OnUnload() - { - PulseGradient?.Unload(); - PulseGradient = null; - } - public override bool CreateDust(int i, int j, ref int type) { @@ -52,7 +36,7 @@ namespace CalamityMod.Tiles.Plates public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.ElumplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = 0.04f + (brightness * 0.156f); return Color.White * brightness; } diff --git a/Tiles/Plates/Havocplate.cs b/Tiles/Plates/Havocplate.cs index 92040fd0a1..ab3092cf32 100644 --- a/Tiles/Plates/Havocplate.cs +++ b/Tiles/Plates/Havocplate.cs @@ -1,9 +1,7 @@ - +using CalamityMod.ExtraTextures.GreyscaleGradients; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -13,33 +11,19 @@ namespace CalamityMod.Tiles.Plates [LegacyName("Chaosplate")] public class Havocplate : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Plates/HavocplateGlow"; - - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - - internal static GrayscaleTexture1D PulseGradient; - public override void SetupStatic() { - PulseGradient = new("CalamityMod/Tiles/Plates/HavocplatePulse"); - Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; + HitSound = CommonCalamitySounds.PlatingMine; MineResist = 1f; AddMapEntry(new Color(235, 108, 108)); } - public override void OnUnload() - { - PulseGradient?.Unload(); - PulseGradient = null; - } - public override bool CreateDust(int i, int j, ref int type) { Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.RedTorch, 0f, 0f, 1, new Color(255, 255, 255), 1f); @@ -54,7 +38,7 @@ namespace CalamityMod.Tiles.Plates public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.HavocplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = 0.04f + (brightness * 0.156f); return Color.White * brightness; } diff --git a/Tiles/Plates/Navyplate.cs b/Tiles/Plates/Navyplate.cs index af79386386..e699cbfe19 100644 --- a/Tiles/Plates/Navyplate.cs +++ b/Tiles/Plates/Navyplate.cs @@ -1,43 +1,27 @@ - +using CalamityMod.ExtraTextures.GreyscaleGradients; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.Plates { public class Navyplate : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Plates/NavyplateGlow"; - - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; - public override void SetupStatic() { - PulseGradient = new("CalamityMod/Tiles/Plates/NavyplatePulse"); - Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; + HitSound = CommonCalamitySounds.PlatingMine; MineResist = 1f; AddMapEntry(new Color(85, 151, 196)); } - public override void OnUnload() - { - PulseGradient?.Unload(); - PulseGradient = null; - } - public override bool CreateDust(int i, int j, ref int type) { Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Flare_Blue, 0f, 0f, 1, new Color(255, 255, 255), 1f); @@ -52,7 +36,7 @@ namespace CalamityMod.Tiles.Plates public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.NavyplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = 0.04f + (brightness * 0.156f); return Color.White * brightness; } diff --git a/Tiles/Plates/Onyxplate.cs b/Tiles/Plates/Onyxplate.cs index 35af4fe794..144d9aa292 100644 --- a/Tiles/Plates/Onyxplate.cs +++ b/Tiles/Plates/Onyxplate.cs @@ -1,46 +1,31 @@ -using CalamityMod.Systems; +using CalamityMod.ExtraTextures.GreyscaleGradients; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.Plates { public class Onyxplate : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Plates/OnyxplateGlow"; - - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; public override void SetupStatic() { - PulseGradient = new("CalamityMod/Tiles/Plates/OnyxplatePulse"); - Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; + HitSound = CommonCalamitySounds.PlatingMine; MineResist = 1f; - DustType = 173; + DustType = DustID.ShadowbeamStaff; AddMapEntry(new Color(182, 28, 232)); } - public override void OnUnload() - { - PulseGradient?.Unload(); - PulseGradient = null; - } - public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.OnyxplatePulse.GetRepeat((int)Main.GameUpdateCount); brightness = 0.04f + (brightness * 0.31f); return Color.White * brightness; } diff --git a/Tiles/Plates/PlagueContainmentCells.cs b/Tiles/Plates/PlagueContainmentCells.cs index f06f934d1c..de008e4cba 100644 --- a/Tiles/Plates/PlagueContainmentCells.cs +++ b/Tiles/Plates/PlagueContainmentCells.cs @@ -1,42 +1,27 @@ -using CalamityMod.Systems; +using CalamityMod.ExtraTextures.GreyscaleGradients; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Tiles.Plates { public class PlagueContainmentCells : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/Plates/PlagueContainmentCellsGlow"; - - public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - internal static GrayscaleTexture1D PulseGradient; public override void SetupStatic() { - PulseGradient = new("CalamityMod/Tiles/Plates/PlagueContainmentCellsPulse"); - Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = true; Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); - HitSound = MinePlatingSound; + HitSound = CommonCalamitySounds.PlatingMine; MineResist = 1f; AddMapEntry(new Color(128, 188, 67)); } - public override void OnUnload() - { - PulseGradient?.Unload(); - PulseGradient = null; - } - public override bool CreateDust(int i, int j, ref int type) { int dust = Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.GemEmerald, 0f, 0f, 100, default, 2f); @@ -56,7 +41,7 @@ namespace CalamityMod.Tiles.Plates public override Color GetGlowMaskColor(int i, int j, TileDrawInfo drawData) { - float brightness = PulseGradient.GetRepeat((int)Main.GameUpdateCount); + float brightness = GreyscaleGradient.PlagueContainmentCellsPulse.GetRepeat((int)Main.GameUpdateCount); brightness = 0.04f + (brightness * 0.156f); return Color.White * brightness; } diff --git a/Tiles/PlayerTurrets/PlayerFireTurret .cs b/Tiles/PlayerTurrets/PlayerFireTurret .cs index 06db0d1d71..105bd4ad3d 100644 --- a/Tiles/PlayerTurrets/PlayerFireTurret .cs +++ b/Tiles/PlayerTurrets/PlayerFireTurret .cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables.PlaceableTurrets; -using CalamityMod.TileEntities; +using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.PlayerTurrets public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset HeadTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -79,7 +81,8 @@ namespace CalamityMod.Tiles.PlayerTurrets int drawDirection = te.Direction; Color drawColor = Lighting.GetColor(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/FireTurretHead").Value; + HeadTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/FireTurretHead"); + Texture2D tex = HeadTexture.Value; Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/PlayerTurrets/PlayerIceTurret .cs b/Tiles/PlayerTurrets/PlayerIceTurret .cs index 07d2742c46..fccad48d76 100644 --- a/Tiles/PlayerTurrets/PlayerIceTurret .cs +++ b/Tiles/PlayerTurrets/PlayerIceTurret .cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables.PlaceableTurrets; -using CalamityMod.TileEntities; +using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.PlayerTurrets public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset HeadTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -79,7 +81,8 @@ namespace CalamityMod.Tiles.PlayerTurrets int drawDirection = te.Direction; Color drawColor = Lighting.GetColor(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/IceTurretHead").Value; + HeadTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/IceTurretHead"); + Texture2D tex = HeadTexture.Value; Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/PlayerTurrets/PlayerLabTurret.cs b/Tiles/PlayerTurrets/PlayerLabTurret.cs index b2d28deb5b..a1a5f1d53f 100644 --- a/Tiles/PlayerTurrets/PlayerLabTurret.cs +++ b/Tiles/PlayerTurrets/PlayerLabTurret.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables.PlaceableTurrets; -using CalamityMod.TileEntities; +using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.PlayerTurrets public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset HeadTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -79,7 +81,8 @@ namespace CalamityMod.Tiles.PlayerTurrets int drawDirection = te.Direction; Color drawColor = Lighting.GetColor(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/LabTurretHead").Value; + HeadTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/LabTurretHead"); + Texture2D tex = HeadTexture.Value; Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/PlayerTurrets/PlayerLaserTurret .cs b/Tiles/PlayerTurrets/PlayerLaserTurret .cs index 6c6421a2eb..7d17ed5683 100644 --- a/Tiles/PlayerTurrets/PlayerLaserTurret .cs +++ b/Tiles/PlayerTurrets/PlayerLaserTurret .cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables.PlaceableTurrets; -using CalamityMod.TileEntities; +using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.PlayerTurrets public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset HeadTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -79,7 +81,8 @@ namespace CalamityMod.Tiles.PlayerTurrets int drawDirection = te.Direction; Color drawColor = Lighting.GetColor(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/LaserTurretHead").Value; + HeadTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/LaserTurretHead"); + Texture2D tex = HeadTexture.Value; Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/PlayerTurrets/PlayerOnyxTurret.cs b/Tiles/PlayerTurrets/PlayerOnyxTurret.cs index 03a6c2cb93..3d8c04ca71 100644 --- a/Tiles/PlayerTurrets/PlayerOnyxTurret.cs +++ b/Tiles/PlayerTurrets/PlayerOnyxTurret.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables.PlaceableTurrets; -using CalamityMod.TileEntities; +using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.PlayerTurrets public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset HeadTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -79,7 +81,8 @@ namespace CalamityMod.Tiles.PlayerTurrets int drawDirection = te.Direction; Color drawColor = Lighting.GetColor(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/OnyxTurretHead").Value; + HeadTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/OnyxTurretHead"); + Texture2D tex = HeadTexture.Value; Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/PlayerTurrets/PlayerPlagueTurret.cs b/Tiles/PlayerTurrets/PlayerPlagueTurret.cs index 0094c5557a..66b70c9e37 100644 --- a/Tiles/PlayerTurrets/PlayerPlagueTurret.cs +++ b/Tiles/PlayerTurrets/PlayerPlagueTurret.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables.PlaceableTurrets; -using CalamityMod.TileEntities; +using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.PlayerTurrets public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset HeadTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -79,7 +81,8 @@ namespace CalamityMod.Tiles.PlayerTurrets int drawDirection = te.Direction; Color drawColor = Lighting.GetColor(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/PlagueTurretHead").Value; + HeadTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/PlagueTurretHead"); + Texture2D tex = HeadTexture.Value; Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/PlayerTurrets/PlayerWaterTurret.cs b/Tiles/PlayerTurrets/PlayerWaterTurret.cs index 0c1c8cbfa1..e6186589ee 100644 --- a/Tiles/PlayerTurrets/PlayerWaterTurret.cs +++ b/Tiles/PlayerTurrets/PlayerWaterTurret.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Placeables.PlaceableTurrets; -using CalamityMod.TileEntities; +using CalamityMod.TileEntities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ObjectInteractions; @@ -20,6 +20,8 @@ namespace CalamityMod.Tiles.PlayerTurrets public const int OriginOffsetY = 1; public const int SheetSquare = 18; + public Asset HeadTexture; + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -79,7 +81,8 @@ namespace CalamityMod.Tiles.PlayerTurrets int drawDirection = te.Direction; Color drawColor = Lighting.GetColor(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/PlayerTurrets/WaterTurretHead").Value; + HeadTexture ??= ModContent.Request("CalamityMod/Tiles/PlayerTurrets/WaterTurretHead"); + Texture2D tex = HeadTexture.Value; Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset; drawOffset.Y -= 2f; diff --git a/Tiles/Pylons/CragsPylonTile.cs b/Tiles/Pylons/CragsPylonTile.cs index a4987d44d6..834768a28d 100644 --- a/Tiles/Pylons/CragsPylonTile.cs +++ b/Tiles/Pylons/CragsPylonTile.cs @@ -4,7 +4,6 @@ using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles.Pylons @@ -25,6 +24,6 @@ namespace CalamityMod.Tiles.Pylons //Doesnt require npcs to function public override bool ValidTeleportCheck_NPCCount(TeleportPylonInfo pylonInfo, int defaultNecessaryNPCCount) => true; - public override bool ValidTeleportCheck_BiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) => BiomeTileCounterSystem.BrimstoneCragTiles >= 100; + public override bool ValidTeleportCheck_BiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) => BiomeTileCounterSystem.BrimstoneCragTiles >= 500; } } diff --git a/Tiles/Pylons/SulphurPylonTile.cs b/Tiles/Pylons/SulphurPylonTile.cs index 39f2718703..1484b7155c 100644 --- a/Tiles/Pylons/SulphurPylonTile.cs +++ b/Tiles/Pylons/SulphurPylonTile.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Placeables.Pylons; +using CalamityMod.BiomeManagers; +using CalamityMod.Items.Placeables.Pylons; using CalamityMod.Systems; using CalamityMod.Tiles.BaseTiles; using Microsoft.Xna.Framework; @@ -21,6 +22,17 @@ namespace CalamityMod.Tiles.Pylons return new NPCShop.Entry(AssociatedItem, Condition.AnotherTownNPCNearby, CalamityConditions.InSulph); } - public override bool ValidTeleportCheck_BiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) => BiomeTileCounterSystem.SulphurTiles >= 100; + public override bool ValidTeleportCheck_BiomeRequirements(TeleportPylonInfo pylonInfo, SceneMetrics sceneData) + { + var tilePos = pylonInfo.PositionInTiles.ToPoint(); + var inSpace = tilePos.Y <= Main.worldSurface * 0.35; // Adding InSpace Condition for Pylon Specifically + var inUnderground = tilePos.Y >= Main.worldSurface; // Underground check is easiest way to filter out Abyss Biome without headache + var tileCountRequirement = BiomeTileCounterSystem.SulphurTiles >= 300 + && BiomeTileCounterSystem.Layer1Tiles < 200 + && BiomeTileCounterSystem.Layer2Tiles < 200 + && BiomeTileCounterSystem.Layer3Tiles < 200 + && BiomeTileCounterSystem.Layer4Tiles < 200; + return tileCountRequirement || (SulphurousSeaBiome.IsInBiomePosition(tilePos) && !inSpace && !inUnderground); + } } } diff --git a/Tiles/Rubblemaker/Abyss/AbyssGiantKelp1Echo.cs b/Tiles/Rubblemaker/Abyss/AbyssGiantKelp1Echo.cs index 4dc342e39b..f4292d353f 100644 --- a/Tiles/Rubblemaker/Abyss/AbyssGiantKelp1Echo.cs +++ b/Tiles/Rubblemaker/Abyss/AbyssGiantKelp1Echo.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -13,6 +14,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss { public class AbyssGiantKelp1Echo : ModTile { + public Asset GlowTexture; public override string Texture => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1"; public override void SetStaticDefaults() { @@ -44,10 +46,10 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (closer && Main.rand.NextBool(100) && j > Main.worldSurface) { Dust dust; - dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 274, 279, DustID.Firefly, 0.23255825f, 10f, 0, new Color(117, 55, 15), 1.5116279f)]; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, new Color(157, 175, 15), Main.rand.NextFloat(1f, 2f))]; dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } } @@ -73,7 +75,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp1Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -90,7 +93,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp2Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp2Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); diff --git a/Tiles/Rubblemaker/Abyss/AbyssGiantKelp3Echo.cs b/Tiles/Rubblemaker/Abyss/AbyssGiantKelp3Echo.cs index fe0ed10bd6..d6ba21720a 100644 --- a/Tiles/Rubblemaker/Abyss/AbyssGiantKelp3Echo.cs +++ b/Tiles/Rubblemaker/Abyss/AbyssGiantKelp3Echo.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -13,6 +14,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss { public class AbyssGiantKelp3Echo : ModTile { + public Asset GlowTexture; public override string Texture => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3"; public override void SetStaticDefaults() { @@ -55,10 +57,10 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (closer && Main.rand.NextBool(100) && j > Main.worldSurface) { Dust dust; - dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 274, 279, DustID.Firefly, 0.23255825f, 10f, 0, new Color(117, 55, 15), 1.5116279f)]; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, new Color(157, 175, 15), Main.rand.NextFloat(1f, 2f))]; dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } } @@ -73,7 +75,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp3Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); diff --git a/Tiles/Rubblemaker/Abyss/AbyssGiantKelp4Echo.cs b/Tiles/Rubblemaker/Abyss/AbyssGiantKelp4Echo.cs index 685953dfa9..e0300ca7f4 100644 --- a/Tiles/Rubblemaker/Abyss/AbyssGiantKelp4Echo.cs +++ b/Tiles/Rubblemaker/Abyss/AbyssGiantKelp4Echo.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Placeables.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -13,6 +14,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss { public class AbyssGiantKelp4Echo : ModTile { + public Asset GlowTexture; public override string Texture => "CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4"; public override void SetStaticDefaults() { @@ -55,10 +57,10 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (closer && Main.rand.NextBool(100) && j > Main.worldSurface) { Dust dust; - dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 274, 279, DustID.Firefly, 0.23255825f, 10f, 0, new Color(117, 55, 15), 1.5116279f)]; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, new Color(157, 175, 15), Main.rand.NextFloat(1f, 2f))]; dust.noGravity = true; dust.noLight = true; - dust.fadeIn = 2.5813954f; + dust.fadeIn = 2.5f; } } @@ -73,7 +75,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/AbyssGiantKelp4Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); diff --git a/Tiles/Rubblemaker/Abyss/BulbTreeEcho.cs b/Tiles/Rubblemaker/Abyss/BulbTreeEcho.cs index c3f55cd174..9d9642f9b9 100644 --- a/Tiles/Rubblemaker/Abyss/BulbTreeEcho.cs +++ b/Tiles/Rubblemaker/Abyss/BulbTreeEcho.cs @@ -1,11 +1,12 @@ -using CalamityMod.Dusts; -using CalamityMod.Items.Placeables.Abyss; +using CalamityMod.Items.Placeables.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,6 +14,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss { public class BulbTree1Echo : ModTile { + public Asset GlowTexture; public override string Texture => "CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree1"; public override void SetStaticDefaults() { @@ -31,7 +33,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(52, 124, 153)); - DustType = 33; + DustType = DustID.Water; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); @@ -57,7 +59,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree1Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree1Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -73,7 +76,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree2Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree2Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -89,7 +93,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree3Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/BulbTree3Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); diff --git a/Tiles/Rubblemaker/Abyss/GravelPileEcho.cs b/Tiles/Rubblemaker/Abyss/GravelPileEcho.cs index a9583003bd..63130a169b 100644 --- a/Tiles/Rubblemaker/Abyss/GravelPileEcho.cs +++ b/Tiles/Rubblemaker/Abyss/GravelPileEcho.cs @@ -4,6 +4,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -29,7 +30,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(17, 19, 38)); - DustType = 33; + DustType = DustID.Water; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); diff --git a/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs b/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs index 9a12c0cc2e..31a835c1bb 100644 --- a/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs +++ b/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(106, 80, 102)); - DustType = 33; + DustType = DustID.Water; RegisterItemDrop(ItemID.WhitePearl); FlexibleTileWand.RubblePlacementLarge.AddVariations(ItemID.WhitePearl, Type, 0); diff --git a/Tiles/Rubblemaker/Abyss/PlantyMushPileEcho.cs b/Tiles/Rubblemaker/Abyss/PlantyMushPileEcho.cs index 1bfa8f1d57..a21b44bab2 100644 --- a/Tiles/Rubblemaker/Abyss/PlantyMushPileEcho.cs +++ b/Tiles/Rubblemaker/Abyss/PlantyMushPileEcho.cs @@ -1,10 +1,10 @@ using CalamityMod.Items.Placeables.Abyss; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(84, 102, 39)); - DustType = 33; + DustType = DustID.Water; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); diff --git a/Tiles/Rubblemaker/Abyss/ShaleColumnsEcho.cs b/Tiles/Rubblemaker/Abyss/ShaleColumnsEcho.cs index 23fffb7d2b..5e41bc8f53 100644 --- a/Tiles/Rubblemaker/Abyss/ShaleColumnsEcho.cs +++ b/Tiles/Rubblemaker/Abyss/ShaleColumnsEcho.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.LavaDeath = true; TileObjectData.addTile(Type); AddMapEntry(new Color(37, 24, 63)); - DustType = 33; + DustType = DustID.Water; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); diff --git a/Tiles/Rubblemaker/Abyss/ShalePileEcho.cs b/Tiles/Rubblemaker/Abyss/ShalePileEcho.cs index c167fde74d..b0306e50ff 100644 --- a/Tiles/Rubblemaker/Abyss/ShalePileEcho.cs +++ b/Tiles/Rubblemaker/Abyss/ShalePileEcho.cs @@ -4,6 +4,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -29,7 +30,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(47, 30, 63)); - DustType = 33; + DustType = DustID.Water; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); diff --git a/Tiles/Rubblemaker/Abyss/SpiderCoralEcho.cs b/Tiles/Rubblemaker/Abyss/SpiderCoralEcho.cs index d4d7463c16..2bcd507f8e 100644 --- a/Tiles/Rubblemaker/Abyss/SpiderCoralEcho.cs +++ b/Tiles/Rubblemaker/Abyss/SpiderCoralEcho.cs @@ -1,8 +1,10 @@ using CalamityMod.Items.Placeables.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -10,6 +12,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss { public class SpiderCoral1Echo : ModTile { + public Asset GlowTexture; public override string Texture => "CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral1"; public override void SetStaticDefaults() { @@ -19,7 +22,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(82, 49, 27)); - DustType = 32; + DustType = DustID.Sand; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); @@ -40,7 +43,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral1Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral1Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -56,7 +60,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral2Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral2Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -72,7 +77,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral3Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral3Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -88,7 +94,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral4Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral4Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -104,7 +111,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral5Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SpiderCoral5Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); diff --git a/Tiles/Rubblemaker/Abyss/SulphurPireCoralEcho.cs b/Tiles/Rubblemaker/Abyss/SulphurPireCoralEcho.cs index 615e7b74e0..27931ca1e8 100644 --- a/Tiles/Rubblemaker/Abyss/SulphurPireCoralEcho.cs +++ b/Tiles/Rubblemaker/Abyss/SulphurPireCoralEcho.cs @@ -1,10 +1,12 @@ using CalamityMod.Items.Placeables.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +14,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss { public class SulphurPireCoral1Echo : ModTile { + public Asset GlowTexture; public override string Texture => "CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral1"; public override void SetStaticDefaults() { @@ -30,7 +33,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(91, 128, 13)); - DustType = 32; + DustType = DustID.Sand; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); @@ -56,7 +59,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral1Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral1Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -72,7 +76,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral2Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral2Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); @@ -88,7 +93,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss if (tile.IsTileActuallyInvisible()) return; - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral3Glow").Value; + GlowTexture ??= ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/SulphurPireCoral3Glow"); + Texture2D tex = GlowTexture.Value; Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); diff --git a/Tiles/Rubblemaker/Abyss/SulphurTubeCoralEcho.cs b/Tiles/Rubblemaker/Abyss/SulphurTubeCoralEcho.cs index 760b8d08c3..0b9e12967f 100644 --- a/Tiles/Rubblemaker/Abyss/SulphurTubeCoralEcho.cs +++ b/Tiles/Rubblemaker/Abyss/SulphurTubeCoralEcho.cs @@ -4,6 +4,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -29,7 +30,7 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(64, 36, 39)); - DustType = 32; + DustType = DustID.Sand; RegisterItemDrop(ModContent.ItemType()); FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); diff --git a/Tiles/Rubblemaker/Astral/AstralNormalLargePilesEcho.cs b/Tiles/Rubblemaker/Astral/AstralNormalLargePilesEcho.cs index caec037f36..e2ca0cfe01 100644 --- a/Tiles/Rubblemaker/Astral/AstralNormalLargePilesEcho.cs +++ b/Tiles/Rubblemaker/Astral/AstralNormalLargePilesEcho.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Placeables.Astral; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Rubblemaker/Astral/AstralNormalMediumPilesEcho.cs b/Tiles/Rubblemaker/Astral/AstralNormalMediumPilesEcho.cs index d6632afec2..31b2e657e1 100644 --- a/Tiles/Rubblemaker/Astral/AstralNormalMediumPilesEcho.cs +++ b/Tiles/Rubblemaker/Astral/AstralNormalMediumPilesEcho.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Placeables.Astral; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Rubblemaker/Astral/AstralNormalSmallPilesEcho.cs b/Tiles/Rubblemaker/Astral/AstralNormalSmallPilesEcho.cs index 7303eac489..a32879ec3f 100644 --- a/Tiles/Rubblemaker/Astral/AstralNormalSmallPilesEcho.cs +++ b/Tiles/Rubblemaker/Astral/AstralNormalSmallPilesEcho.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Placeables.Astral; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles.Rubblemake.Astral diff --git a/Tiles/Rubblemaker/Astral/AstralStoneLargePilesEcho.cs b/Tiles/Rubblemaker/Astral/AstralStoneLargePilesEcho.cs index 8f206eb760..7ca5779a67 100644 --- a/Tiles/Rubblemaker/Astral/AstralStoneLargePilesEcho.cs +++ b/Tiles/Rubblemaker/Astral/AstralStoneLargePilesEcho.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Placeables.Astral; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Rubblemaker/Astral/AstralStoneMediumPilesEcho.cs b/Tiles/Rubblemaker/Astral/AstralStoneMediumPilesEcho.cs index 70e04a1460..91e16343da 100644 --- a/Tiles/Rubblemaker/Astral/AstralStoneMediumPilesEcho.cs +++ b/Tiles/Rubblemaker/Astral/AstralStoneMediumPilesEcho.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Placeables.Astral; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Rubblemaker/Astral/AstralStoneSmallPilesEcho.cs b/Tiles/Rubblemaker/Astral/AstralStoneSmallPilesEcho.cs index 9930a15562..9754bb10be 100644 --- a/Tiles/Rubblemaker/Astral/AstralStoneSmallPilesEcho.cs +++ b/Tiles/Rubblemaker/Astral/AstralStoneSmallPilesEcho.cs @@ -2,9 +2,7 @@ using CalamityMod.Items.Placeables.Astral; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles.Rubblemake.Astral diff --git a/Tiles/Rubblemaker/SulphurousSea/SulphurousColumnEcho.cs b/Tiles/Rubblemaker/SulphurousSea/SulphurousColumnEcho.cs index 1fbefd2843..004861aa6c 100644 --- a/Tiles/Rubblemaker/SulphurousSea/SulphurousColumnEcho.cs +++ b/Tiles/Rubblemaker/SulphurousSea/SulphurousColumnEcho.cs @@ -5,7 +5,6 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; diff --git a/Tiles/Rubblemaker/SunkenSea/BlueCoralTreeEcho.cs b/Tiles/Rubblemaker/SunkenSea/BlueCoralTreeEcho.cs new file mode 100644 index 0000000000..891219546d --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/BlueCoralTreeEcho.cs @@ -0,0 +1,18 @@ +using Terraria.ModLoader; +using Terraria.GameContent; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class BlueCoralTreeEcho : BlueCoralTree + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/BlueCoralTree"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs index b3da12ec94..624a137c0e 100644 --- a/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -16,12 +17,11 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.addTile(Type); - + DustType = DustID.SailfishBoots; AddMapEntry(new Color(36, 61, 111)); - RegisterItemDrop(ModContent.ItemType()); - FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Rubblemaker/SunkenSea/BranchCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/BranchCoralEcho.cs new file mode 100644 index 0000000000..66fe2f1267 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/BranchCoralEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Ambient.SunkenSea +{ + public class BranchCoralEcho : BranchCoral + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/BranchCoral"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/BrownCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/BrownCoralEcho.cs new file mode 100644 index 0000000000..4f5dbf3736 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/BrownCoralEcho.cs @@ -0,0 +1,29 @@ +using Terraria.ModLoader; +using CalamityMod.Tiles.SunkenSea.Ambient; +using CalamityMod.Items.Placeables.SunkenSea; +using Terraria.GameContent; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class BrownCoral1Echo : BrownCoral1 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/BrownCoral1"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + } + + public class BrownCoral2Echo : BrownCoral2 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/BrownCoral2"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/CoralPileGiantEcho.cs b/Tiles/Rubblemaker/SunkenSea/CoralPileGiantEcho.cs new file mode 100644 index 0000000000..cce0e3cc5e --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/CoralPileGiantEcho.cs @@ -0,0 +1,18 @@ +using Terraria.ModLoader; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using CalamityMod.Items.Placeables.SunkenSea; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class CoralPileGiantEcho : CoralPileGiant + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/CoralPileGiant"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs b/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs index 93a794a6bb..a21ad0581d 100644 --- a/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Placeables.SunkenSea; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -30,8 +31,8 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea TileObjectData.addTile(Type); AddMapEntry(new Color(44, 129, 163)); DustType = DustID.Coralstone; - RegisterItemDrop(ItemID.CoralstoneBlock); - FlexibleTileWand.RubblePlacementLarge.AddVariations(ItemID.CoralstoneBlock, Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); base.SetStaticDefaults(); } diff --git a/Tiles/Rubblemaker/SunkenSea/DigitateCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/DigitateCoralEcho.cs new file mode 100644 index 0000000000..d74ef3c0b4 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/DigitateCoralEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class DigitateCoralEcho : DigitateCoral + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/DigitateCoral"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/DriftwoodMastEcho.cs b/Tiles/Rubblemaker/SunkenSea/DriftwoodMastEcho.cs new file mode 100644 index 0000000000..ec1dda2d76 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/DriftwoodMastEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class DriftwoodMastEcho : DriftwoodMast + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/DriftwoodMast"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/DriftwoodScrapsEcho.cs b/Tiles/Rubblemaker/SunkenSea/DriftwoodScrapsEcho.cs new file mode 100644 index 0000000000..8d152ba381 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/DriftwoodScrapsEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class DriftwoodScrapsEcho : DriftwoodScraps + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/DriftwoodScraps"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/DriftwoodWreckageEcho.cs b/Tiles/Rubblemaker/SunkenSea/DriftwoodWreckageEcho.cs new file mode 100644 index 0000000000..cf1f14042c --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/DriftwoodWreckageEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class DriftwoodWreckageEcho : DriftwoodWreckage + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/DriftwoodWreckage"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs index 85dd31c031..d9e2e37cb2 100644 --- a/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs @@ -1,10 +1,9 @@ using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Waters; using Microsoft.Xna.Framework; using Terraria; using Terraria.Enums; using Terraria.GameContent; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -21,20 +20,14 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); TileObjectData.newTile.Direction = TileObjectDirection.None; TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(54, 69, 72)); - RegisterItemDrop(ModContent.ItemType()); - FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); base.SetStaticDefaults(); } - public override void NearbyEffects(int i, int j, bool closer) - { - if (!Main.dedServ) - Main.SceneMetrics.ActiveFountainColor = BasaltGullyWater.Type; - } - public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; @@ -42,9 +35,9 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 0.3f; - g = 0.75f; - b = 0.75f; + r = 0.88f; + g = 1f; + b = 1f; } } } diff --git a/Tiles/Rubblemaker/SunkenSea/FryCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/FryCoralEcho.cs new file mode 100644 index 0000000000..b5425d5d73 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/FryCoralEcho.cs @@ -0,0 +1,39 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class FryCoralEcho : FryCoral + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/FryCoral"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + } + + public class FryCoral2Echo : FryCoral2 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/FryCoral2"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + } + public class FryCoral3Echo : FryCoral3 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/FryCoral3"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/GiantNavystoneEcho.cs b/Tiles/Rubblemaker/SunkenSea/GiantNavystoneEcho.cs new file mode 100644 index 0000000000..dd5e4ee867 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/GiantNavystoneEcho.cs @@ -0,0 +1,29 @@ +using Terraria.ModLoader; +using CalamityMod.Tiles.SunkenSea.Ambient; +using CalamityMod.Items.Placeables.SunkenSea; +using Terraria.GameContent; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class GiantNavystone1Echo : GiantNavystone1 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/GiantNavystone1"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } + + public class GiantNavystone2Echo : GiantNavystone2 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/GiantNavystone2"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/GleamingBurrowsPilesEcho.cs b/Tiles/Rubblemaker/SunkenSea/GleamingBurrowsPilesEcho.cs new file mode 100644 index 0000000000..d6205c0b9a --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/GleamingBurrowsPilesEcho.cs @@ -0,0 +1,38 @@ +using Terraria.ModLoader; +using Terraria.GameContent; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class SmallGleamingBurrowsPileEcho : SmallGleamingBurrowsPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallGleamingBurrowsPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); + } + } + public class MediumGleamingBurrowsPileEcho : MediumGleamingBurrowsPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumGleamingBurrowsPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); + } + } + public class LargeGleamingBurrowsPileEcho : LargeGleamingBurrowsPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/LargeGleamingBurrowsPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/LargeDriftwoodWreckageEcho.cs b/Tiles/Rubblemaker/SunkenSea/LargeDriftwoodWreckageEcho.cs new file mode 100644 index 0000000000..b148882c65 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/LargeDriftwoodWreckageEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class LargeDriftwoodWreckageEcho : LargeDriftwoodWreckage + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/LargeDriftwoodWreckage"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs index ce5b492050..e439ebfab5 100644 --- a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Placeables.SunkenSea; +using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; using Terraria.ID; @@ -10,30 +11,59 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea public class MediumCoralEcho : ModTile { public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumCoral"; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; + Main.tileLighted[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(233, 132, 58)); DustType = DustID.Coralstone; - RegisterItemDrop(ItemID.CoralstoneBlock); - FlexibleTileWand.RubblePlacementMedium.AddVariations(ItemID.CoralstoneBlock, Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); base.SetStaticDefaults(); } + public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 2; } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.65f; + g = 0.39f; + b = 0.58f; + } } public class MediumCoral2Echo : MediumCoralEcho { public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumCoral2"; + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.15f; + g = 0.28f; + b = 0.37f; + } + } + + public class MediumCoral3Echo : MediumCoralEcho + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumCoral3"; + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.24f; + g = 0.43f; + b = 0.57f; + } } } diff --git a/Tiles/Rubblemaker/SunkenSea/MediumDriftwoodWreckageEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumDriftwoodWreckageEcho.cs new file mode 100644 index 0000000000..295eae7c13 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/MediumDriftwoodWreckageEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class MediumDriftwoodWreckageEcho : MediumDriftwoodWreckage + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumDriftwoodWreckage"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/MediumDunesandPileEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumDunesandPileEcho.cs new file mode 100644 index 0000000000..71202d7df8 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/MediumDunesandPileEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class MediumDunesandPileEcho : MediumDunesandPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumDunesandPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/MediumSeaPrismCrystalEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumSeaPrismCrystalEcho.cs new file mode 100644 index 0000000000..5415fd964b --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/MediumSeaPrismCrystalEcho.cs @@ -0,0 +1,23 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Ambient.SunkenSea +{ + public class MediumSeaPrismCrystalEcho : MediumSeaPrismCrystal + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + + // Don't drop items + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/MediumShorePileEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumShorePileEcho.cs new file mode 100644 index 0000000000..23429c8d61 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/MediumShorePileEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class MediumShorePileEcho : MediumShorePile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumShorePile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/MossyStonePilesEcho.cs b/Tiles/Rubblemaker/SunkenSea/MossyStonePilesEcho.cs new file mode 100644 index 0000000000..f982f58bf8 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/MossyStonePilesEcho.cs @@ -0,0 +1,28 @@ +using Terraria.ModLoader; +using Terraria.GameContent; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class SmallMossyStonePileEcho : SmallMossyStonePile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallMossyStonePile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); + } + } + public class LargeMossyStonePileEcho : LargeMossyStonePile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/LargeMossyStonePile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/PolypForestPilesEcho.cs b/Tiles/Rubblemaker/SunkenSea/PolypForestPilesEcho.cs new file mode 100644 index 0000000000..126e1b4981 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/PolypForestPilesEcho.cs @@ -0,0 +1,38 @@ +using Terraria.ModLoader; +using Terraria.GameContent; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class SmallPolypForestPileEcho : SmallPolypForestPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallPolypForestPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); + } + } + public class PolypForestPilesEcho : MediumPolypForestPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumPolypForestPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + } + } + public class LargePolypForestPileEcho : LargePolypForestPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/LargePolypForestPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/RadiantReefPilesEcho.cs b/Tiles/Rubblemaker/SunkenSea/RadiantReefPilesEcho.cs new file mode 100644 index 0000000000..be562c190c --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/RadiantReefPilesEcho.cs @@ -0,0 +1,48 @@ +using Terraria.ModLoader; +using Terraria.GameContent; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class SmallRadiantReefPileEcho : SmallRadiantReefPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallRadiantReefPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); + } + } + public class RadiantReefPilesEcho : MediumRadiantReefPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumRadiantReefPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5, 6, 7, 8); + } + } + public class LargeRadiantReefPileEcho : LargeRadiantReefPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/LargeRadiantReefPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); + } + } + public class GiantRadiantReefPileEcho : GiantRadiantReefPile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/GiantRadiantReefPile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs b/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs index 119a1db8b2..1ba872be06 100644 --- a/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs @@ -2,7 +2,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -13,19 +13,27 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SeaAnemone"; public override void SetStaticDefaults() { + Main.tileLighted[Type] = true; AnimationFrameHeight = 36; Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(54, 69, 72)); - RegisterItemDrop(ModContent.ItemType()); - FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); base.SetStaticDefaults(); } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.11f; + g = 0.29f; + b = 0.57f; + } + public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; diff --git a/Tiles/Rubblemaker/SunkenSea/ShorePileEcho.cs b/Tiles/Rubblemaker/SunkenSea/ShorePileEcho.cs new file mode 100644 index 0000000000..0f4dac0a02 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/ShorePileEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class ShorePileEcho : ShorePile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/ShorePile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5, 6, 7, 8); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs index 11c4770866..36bded3a0f 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs @@ -1,10 +1,8 @@ using CalamityMod.Items.Placeables.SunkenSea; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -19,10 +17,10 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.SailfishBoots; AddMapEntry(new Color(36, 61, 111)); - RegisterItemDrop(ModContent.ItemType()); - FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); base.SetStaticDefaults(); } diff --git a/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs index d9ab7f41dd..d086e66bd5 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs @@ -1,6 +1,6 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Placeables.SunkenSea; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -27,9 +27,9 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea AddMapEntry(new Color(178, 28, 153)); DustType = DustID.Coralstone; HitSound = SoundID.Grass; - RegisterItemDrop(ItemID.CoralstoneBlock); - // this one is weird - //FlexibleTileWand.RubblePlacementSmall.AddVariations(ItemID.CoralstoneBlock, Type, 0, 1, 2, 3, 4, 5); + RegisterItemDrop(ModContent.ItemType()); + // TODO: Currently this one doesn't work + //FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); base.SetStaticDefaults(); } diff --git a/Tiles/Rubblemaker/SunkenSea/SmallLimestoneCobblePileEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallLimestoneCobblePileEcho.cs new file mode 100644 index 0000000000..6d4edf4dfc --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/SmallLimestoneCobblePileEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class SmallLimestoneCobblePileEcho : SmallLimestoneCobblePile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3, 4, 5); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs index 2924b84bd4..533eaba067 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs @@ -2,7 +2,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -17,10 +17,10 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(36, 61, 111)); - RegisterItemDrop(ModContent.ItemType()); - FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementSmall.AddVariations(ModContent.ItemType(), Type, 0); base.SetStaticDefaults(); } diff --git a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs index 468e302c00..10992efdd5 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs @@ -10,12 +10,14 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea public class SmallWideCoralEcho : ModTile { public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallWideCoral"; + public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; + Main.tileLighted[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); @@ -26,9 +28,24 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea base.SetStaticDefaults(); } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.32f; + g = 0.37f; + b = 0.15f; + } } + public class SmallWideCoral2Echo : SmallWideCoralEcho { public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallWideCoral2"; + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.33f; + g = 0.2f; + b = 0.29f; + } } } diff --git a/Tiles/Rubblemaker/SunkenSea/StalkCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/StalkCoralEcho.cs new file mode 100644 index 0000000000..25d370eb39 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/StalkCoralEcho.cs @@ -0,0 +1,40 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class StalkCoralEcho : StalkCoral + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/StalkCoral"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } + + public class StalkCoral2Echo : StalkCoral2 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/StalkCoral2"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } + public class StalkCoral3Echo : StalkCoral3 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/StalkCoral3"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } + +} diff --git a/Tiles/Rubblemaker/SunkenSea/SunkenShipEcho.cs b/Tiles/Rubblemaker/SunkenSea/SunkenShipEcho.cs new file mode 100644 index 0000000000..8c52d4a9cc --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/SunkenShipEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.FurnitureDriftwood; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class SunkenShipEcho : SunkenShip + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SunkenShip"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs index b4875bdc62..ffbcb34c23 100644 --- a/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs @@ -1,52 +1,28 @@ using CalamityMod.Items.Placeables.SunkenSea; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; +using CalamityMod.Tiles.SunkenSea.Ambient; using Terraria.GameContent; -using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ObjectData; namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { - public class TableCoralEcho : ModTile + public class TableCoralEcho : TableCoral { - int subsheetHeight = 34; - int subsheetWidth = 108; public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TableCoral"; public override void SetStaticDefaults() { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - Main.tileSolidTop[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.None, 0, 0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.addTile(Type); - DustType = 253; - AddMapEntry(new Color(54, 69, 72)); - RegisterItemDrop(ModContent.ItemType()); - FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); - base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); } - - public override void NumDust(int i, int j, bool fail, ref int num) + } + public class TableCoralLeftEcho : TableCoralLeft + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TableCoralLeft"; + public override void SetStaticDefaults() { - num = fail ? 1 : 3; - } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - int xPos = i % 1; - int yPos = j % 3; - frameXOffset = xPos * subsheetWidth; - frameYOffset = yPos * subsheetHeight; + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2); } } } diff --git a/Tiles/Rubblemaker/SunkenSea/TallDigitateCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/TallDigitateCoralEcho.cs new file mode 100644 index 0000000000..44e933f12c --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/TallDigitateCoralEcho.cs @@ -0,0 +1,49 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class TallDigitateCoralEcho : TallDigitateCoral + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TallDigitateCoral"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } + + public class TallDigitateCoral2Echo : TallDigitateCoral2 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TallDigitateCoral2"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } + public class TallDigitateCoral3Echo : TallDigitateCoral3 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TallDigitateCoral3"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } + public class TallDigitateCoral4Echo : TallDigitateCoral4 + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TallDigitateCoral4"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type, 0); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs index 36538fa9f1..9c2426ca49 100644 --- a/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs @@ -2,7 +2,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -24,10 +24,10 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea 16 }; TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(36, 61, 111)); - RegisterItemDrop(ModContent.ItemType()); - FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0); base.SetStaticDefaults(); } diff --git a/Tiles/Rubblemaker/SunkenSea/WallCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/WallCoralEcho.cs new file mode 100644 index 0000000000..dc31963129 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/WallCoralEcho.cs @@ -0,0 +1,29 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class WallCoralEcho : WallCoral + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoral"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3); + } + } + + public class WallCoralLeftEcho : WallCoralLeft + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WallCoralLeft"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3); + } + } +} diff --git a/Tiles/Rubblemaker/SunkenSea/WideScarletSeagrassEcho.cs b/Tiles/Rubblemaker/SunkenSea/WideScarletSeagrassEcho.cs new file mode 100644 index 0000000000..186b0abe09 --- /dev/null +++ b/Tiles/Rubblemaker/SunkenSea/WideScarletSeagrassEcho.cs @@ -0,0 +1,18 @@ +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Rubblemaker.SunkenSea +{ + public class WideScarletSeagrassEcho : WideScarletSeagrass + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/WideScarletSeagrass"; + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + RegisterItemDrop(ModContent.ItemType(), Type); + FlexibleTileWand.RubblePlacementMedium.AddVariations(ModContent.ItemType(), Type, 0, 1, 2, 3); + } + } +} diff --git a/Tiles/ScoriaBarPlaced.cs b/Tiles/ScoriaBarPlaced.cs index ae80b18e5d..7df03f9419 100644 --- a/Tiles/ScoriaBarPlaced.cs +++ b/Tiles/ScoriaBarPlaced.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Tiles @@ -11,7 +12,7 @@ namespace CalamityMod.Tiles public override void SetStaticDefaults() { this.SetUpBar(ModContent.ItemType(), new Color(255, 165, 0)); - DustType = 87; + DustType = DustID.GemTopaz; } public override bool CreateDust(int i, int j, ref int type) diff --git a/Tiles/ScoriaBrick.cs b/Tiles/ScoriaBrick.cs index 5cb0edfa21..f3325dec27 100644 --- a/Tiles/ScoriaBrick.cs +++ b/Tiles/ScoriaBrick.cs @@ -1,11 +1,7 @@ -using System.Collections.Generic; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +10,6 @@ namespace CalamityMod.Tiles [LegacyName("ChaoticBrick")] public class ScoriaBrick : GlowMaskTile { - public override string GlowMaskAsset => "CalamityMod/Tiles/ScoriaBrickGlow"; - int subsheetHeight = 72; public override void SetupStatic() @@ -23,12 +17,12 @@ namespace CalamityMod.Tiles Main.tileLighted[Type] = true; Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; - DustType = 105; + DustType = DustID.Water_BloodMoon; AddMapEntry(new Color(85, 87, 101)); HitSound = SoundID.Tink; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/Stohne.cs b/Tiles/Stohne.cs index 64bf509eda..b6f8044fc4 100644 --- a/Tiles/Stohne.cs +++ b/Tiles/Stohne.cs @@ -25,9 +25,9 @@ namespace CalamityMod.Tiles TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; TileID.Sets.HasSlopeFrames[Type] = true; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) diff --git a/Tiles/SunkenSea/AlgalPrismTorch.cs b/Tiles/SunkenSea/AlgalPrismTorch.cs index 10788826b7..aa76431b40 100644 --- a/Tiles/SunkenSea/AlgalPrismTorch.cs +++ b/Tiles/SunkenSea/AlgalPrismTorch.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.SunkenSea { public class AlgalPrismTorch : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); public override bool CreateDust(int i, int j, ref int type) @@ -54,18 +57,19 @@ namespace CalamityMod.Tiles.SunkenSea public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/SunkenSea/AlgalPrismTorchFlame").Value, i, j, 2); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/SunkenSea/AlgalPrismTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) { if (Main.tile[i, j].TileFrameX < 66) - CalamityUtils.DrawFlameSparks(61, 5, i, j); + CalamityUtils.DrawFlameSparks(DustID.GreenTorch, 5, i, j); } public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } diff --git a/Tiles/SunkenSea/Ambient/BarrelCactus.cs b/Tiles/SunkenSea/Ambient/BarrelCactus.cs new file mode 100644 index 0000000000..ea4c72f8c6 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/BarrelCactus.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class BarrelCactus : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.RandomStyleRange = 2; + TileObjectData.addTile(Type); + AddMapEntry(new Color(85, 143, 46)); + DustType = DustID.Coralstone; + + base.SetStaticDefaults(); + } + //Bro idk how to make a boulder + } +} diff --git a/Tiles/SunkenSea/Ambient/BarrelCactus.png b/Tiles/SunkenSea/Ambient/BarrelCactus.png new file mode 100644 index 0000000000..7263e82a88 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/BarrelCactus.png differ diff --git a/Tiles/SunkenSea/Ambient/BlueCoralTree.cs b/Tiles/SunkenSea/Ambient/BlueCoralTree.cs index eb6976e536..1f50f30b6a 100644 --- a/Tiles/SunkenSea/Ambient/BlueCoralTree.cs +++ b/Tiles/SunkenSea/Ambient/BlueCoralTree.cs @@ -5,7 +5,6 @@ using Terraria.ObjectData; using Terraria.DataStructures; using Terraria.Enums; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.SunkenSea.Ambient { @@ -16,6 +15,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileFrameImportant[Type] = true; Main.tileSolid[Type] = false; Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; TileObjectData.newTile.Width = 3; TileObjectData.newTile.Height = 4; TileObjectData.newTile.Origin = new Point16(1, 3); @@ -27,14 +27,15 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(126, 80, 69)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Dig; } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 60f / 255f; - g = 110f / 255f; - b = 146f / 255f; + r = 0.235f; + g = 0.431f; + b = 0.573f; } } } diff --git a/Tiles/SunkenSea/Ambient/BrainCoral.cs b/Tiles/SunkenSea/Ambient/BrainCoral.cs index f3f73b002f..25755fa694 100644 --- a/Tiles/SunkenSea/Ambient/BrainCoral.cs +++ b/Tiles/SunkenSea/Ambient/BrainCoral.cs @@ -1,9 +1,11 @@ -using CalamityMod.Projectiles.Typeless; +using System; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -17,7 +19,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.SailfishBoots; AddMapEntry(new Color(36, 61, 111)); base.SetStaticDefaults(); @@ -28,6 +30,31 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient num = fail ? 1 : 3; } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + var tile = Main.tile[i, j]; + if (tile.IsTileActuallyInvisible()) + return false; + + float glowbrightness = 1f; + float glowspeed = (float)(Main.timeForVisualEffects * 0.01); + glowbrightness *= MathF.Sin(i / 60f + glowspeed); + + int xFrameOffset = tile.TileFrameX; + int yFrameOffset = tile.TileFrameY; + Texture2D glowmask = TextureAssets.Tile[Type].Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White * glowbrightness; + + if (!tile.IsHalfBlock && tile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (tile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + + return false; + } + public override void NearbyEffects(int i, int j, bool closer) { if (Main.gamePaused) @@ -44,8 +71,19 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { if (Main.tile[i, tileLocationY].LiquidAmount == 255 && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && Main.tile[i, tileLocationY - 2].LiquidAmount == 255) { + for (int t = 0; t < 5; t++) + { + Dust dust = Dust.NewDustDirect(new Vector2(i, j + 0.5f) * 16, 16, 16, DustID.BlueTorch, 0, 0, 1, default, 1.5f); + dust.velocity *= 0.2f; + dust.noGravity = true; + dust.noLight = true; + dust.noLightEmittence = true; + } + Dust dust2 = Dust.NewDustDirect(new Vector2(i, j + 0.5f) * 16, 16, 16, DustID.MagicMirror, 0, 0, 1, Color.LightSkyBlue, 0.5f); + dust2.velocity *= 0.2f; + if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(new EntitySource_WorldEvent(), i * 16 + 16, tileLocationY * 16 + 16, 0f, -0.1f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + Projectile.NewProjectile(new EntitySource_WorldEvent(), i * 16 + 16, tileLocationY * 16 + 16, 0f, -0.1f, ModContent.ProjectileType(), 0, 1f, Main.myPlayer); } } } diff --git a/Tiles/SunkenSea/Ambient/BrainCoral.png b/Tiles/SunkenSea/Ambient/BrainCoral.png index dc87921c20..d4eacc4d10 100644 Binary files a/Tiles/SunkenSea/Ambient/BrainCoral.png and b/Tiles/SunkenSea/Ambient/BrainCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/BranchCoral.cs b/Tiles/SunkenSea/Ambient/BranchCoral.cs new file mode 100644 index 0000000000..a46632dc57 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/BranchCoral.cs @@ -0,0 +1,69 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class BranchCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileObsidianKill[Type] = true; + Main.tileSpelunker[Type] = false; + + HitSound = SoundID.Dig; + DustType = DustID.CrimsonPlants; + + AddMapEntry(new Color(210, 66, 90)); + + // Attach to ground + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 32; // total 32 frames, all should be same "itemStyle" + TileObjectData.newTile.StyleWrapLimit = 8; // only 1 placement alternative per row + TileObjectData.newTile.RandomStyleRange = 8; // 8 different style will be selected upon placing + TileObjectData.newTile.Origin = new Point16(0, 1); + + // Attach to side (right) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.addAlternate(8); + + // Attach to ceiling + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(16); + + // Attach to side (left) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(24); + TileObjectData.addTile(Type); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.464f; + g = 0.244f; + b = 0.244f; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/BranchCoral.png b/Tiles/SunkenSea/Ambient/BranchCoral.png new file mode 100644 index 0000000000..5661d35858 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/BranchCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/BrownCoral.cs b/Tiles/SunkenSea/Ambient/BrownCoral.cs index 0e76768aa2..69091fbd17 100644 --- a/Tiles/SunkenSea/Ambient/BrownCoral.cs +++ b/Tiles/SunkenSea/Ambient/BrownCoral.cs @@ -5,8 +5,6 @@ using Terraria.ObjectData; using Terraria.DataStructures; using Terraria.Enums; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Humanizer; namespace CalamityMod.Tiles.SunkenSea.Ambient { @@ -17,9 +15,10 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileFrameImportant[Type] = true; Main.tileSolid[Type] = false; Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; TileObjectData.newTile.Width = 2; TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.Origin = new Point16(0, 2); TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; TileObjectData.newTile.StyleWrapLimit = 36; TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); @@ -28,14 +27,15 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(113, 80, 28)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Dig; } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 244f / 450f; - g = 238f / 450f; - b = 162f / 450f; + r = 0.542f; + g = 0.529f; + b = 0.36f; } } @@ -46,9 +46,10 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileFrameImportant[Type] = true; Main.tileSolid[Type] = false; Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; TileObjectData.newTile.Width = 4; TileObjectData.newTile.Height = 4; - TileObjectData.newTile.Origin = new Point16(2, 3); + TileObjectData.newTile.Origin = new Point16(1, 3); TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; TileObjectData.newTile.StyleWrapLimit = 36; TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); @@ -57,14 +58,15 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(113, 80, 28)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Dig; } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 244f / 400f; - g = 238f / 400f; - b = 162f / 400f; + r = 0.61f; + g = 0.595f; + b = 0.405f; } } } diff --git a/Tiles/SunkenSea/Ambient/CoralPileGiant.cs b/Tiles/SunkenSea/Ambient/CoralPileGiant.cs index 3951a41547..3900a3152a 100644 --- a/Tiles/SunkenSea/Ambient/CoralPileGiant.cs +++ b/Tiles/SunkenSea/Ambient/CoralPileGiant.cs @@ -1,11 +1,10 @@ -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; using Terraria.DataStructures; using Terraria.Enums; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.SunkenSea.Ambient { @@ -15,9 +14,10 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { Main.tileFrameImportant[Type] = true; Main.tileSolid[Type] = false; - TileObjectData.newTile.Width = 3; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 3; TileObjectData.newTile.Height = 4; - TileObjectData.newTile.Origin = new Point16(2, 3); + TileObjectData.newTile.Origin = new Point16(1, 3); TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; TileObjectData.newTile.StyleWrapLimit = 36; TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); @@ -26,8 +26,8 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(126, 80, 69)); - DustType = 155; + DustType = DustID.Ambient_DarkBrown; HitSound = SoundID.Dig; } } -} \ No newline at end of file +} diff --git a/Tiles/SunkenSea/Ambient/DepthVines.cs b/Tiles/SunkenSea/Ambient/DepthVines.cs index 7c5f36445d..fc4e65cea9 100644 --- a/Tiles/SunkenSea/Ambient/DepthVines.cs +++ b/Tiles/SunkenSea/Ambient/DepthVines.cs @@ -2,8 +2,6 @@ using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - namespace CalamityMod.Tiles.SunkenSea.Ambient { @@ -17,7 +15,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileNoAttach[Type] = true; TileID.Sets.IsVine[Type] = true; TileID.Sets.VineThreads[Type] = true; - AddMapEntry(new Color(41, 97, 126)); + AddMapEntry(new Color(48, 106, 100)); DustType = DustID.Grass; HitSound = SoundID.Grass; } @@ -26,9 +24,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { Tile tile = Framing.GetTileSafely(i, j + 1); if (tile.HasTile && tile.TileType == Type) - { WorldGen.KillTile(i, j + 1); - } } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) @@ -36,14 +32,10 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Tile tileAbove = Framing.GetTileSafely(i, j - 1); int type = -1; if (tileAbove.HasTile && !tileAbove.BottomSlope) - { type = tileAbove.TileType; - } if (type == ModContent.TileType() || type == Type) - { return true; - } WorldGen.KillTile(i, j); return true; @@ -52,9 +44,10 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient public override void RandomUpdate(int i, int j) { Tile tileBelow = Framing.GetTileSafely(i, j + 1); - if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) + Tile tile = Framing.GetTileSafely(i, j); + if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) { - bool PlaceVine = false; + bool PlaceVine = false; int Test = j; while (Test > j - 10) { @@ -63,7 +56,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { break; } - else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) + else if (!testTile.HasTile || testTile.TileType != ModContent.TileType() && tile.LiquidType == LiquidID.Water) { Test--; continue; @@ -78,11 +71,11 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient tileBelow.HasTile = true; WorldGen.SquareTileFrame(i, j + 1, true); if (Main.dedServ) - { NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); - } } } + + } } } diff --git a/Tiles/SunkenSea/Ambient/DigitateCoral.cs b/Tiles/SunkenSea/Ambient/DigitateCoral.cs new file mode 100644 index 0000000000..04340a1671 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/DigitateCoral.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class DigitateCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + Main.tileNoAttach[Type] = true; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(48, 201, 214)); + DustType = DustID.IceGolem; + + base.SetStaticDefaults(); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 2; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.14f; + g = 0.41f; + b = 0.45f; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/DigitateCoral.png b/Tiles/SunkenSea/Ambient/DigitateCoral.png new file mode 100644 index 0000000000..824e912038 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/DigitateCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/DriftwoodMast.cs b/Tiles/SunkenSea/Ambient/DriftwoodMast.cs new file mode 100644 index 0000000000..4a50811ec2 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/DriftwoodMast.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class DriftwoodMast : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new(0, 3); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(146, 123, 127)); + DustType = DustID.Shadewood_Tree; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/DriftwoodMast.png b/Tiles/SunkenSea/Ambient/DriftwoodMast.png new file mode 100644 index 0000000000..2965c8e880 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/DriftwoodMast.png differ diff --git a/Tiles/SunkenSea/Ambient/DriftwoodScraps.cs b/Tiles/SunkenSea/Ambient/DriftwoodScraps.cs new file mode 100644 index 0000000000..161c230aa5 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/DriftwoodScraps.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class DriftwoodScraps : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16,}; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 1); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(146, 123, 127)); + DustType = DustID.Shadewood_Tree; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/DriftwoodScraps.png b/Tiles/SunkenSea/Ambient/DriftwoodScraps.png new file mode 100644 index 0000000000..7eb6e171a3 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/DriftwoodScraps.png differ diff --git a/Tiles/SunkenSea/Ambient/DriftwoodWreckage.cs b/Tiles/SunkenSea/Ambient/DriftwoodWreckage.cs new file mode 100644 index 0000000000..ef8d838035 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/DriftwoodWreckage.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class DriftwoodWreckage : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.Width = 5; + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 5, 0); + TileObjectData.newTile.Origin = new Point16(2, 1); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(146, 123, 127)); + DustType = DustID.Shadewood_Tree; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/DriftwoodWreckage.png b/Tiles/SunkenSea/Ambient/DriftwoodWreckage.png new file mode 100644 index 0000000000..503b002088 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/DriftwoodWreckage.png differ diff --git a/Tiles/SunkenSea/Ambient/FanCoral.cs b/Tiles/SunkenSea/Ambient/FanCoral.cs index ecf774185d..0b6a10c261 100644 --- a/Tiles/SunkenSea/Ambient/FanCoral.cs +++ b/Tiles/SunkenSea/Ambient/FanCoral.cs @@ -1,8 +1,7 @@ -using CalamityMod.Waters; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Enums; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -18,16 +17,11 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); TileObjectData.newTile.Direction = TileObjectDirection.None; TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(54, 69, 72)); base.SetStaticDefaults(); } - public override void NearbyEffects(int i, int j, bool closer) - { - if (!Main.dedServ) - Main.SceneMetrics.ActiveFountainColor = SunkenSeaBurrowsWater.Type; - } public override void NumDust(int i, int j, bool fail, ref int num) { @@ -36,9 +30,9 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 225f / 255f; - g = 255f / 255f; - b = 255f / 255f; + r = 0.1f; + g = 0.3f; + b = 0.4f; } } } diff --git a/Tiles/SunkenSea/Ambient/FloweringBarrelCactus.cs b/Tiles/SunkenSea/Ambient/FloweringBarrelCactus.cs new file mode 100644 index 0000000000..35bc81809c --- /dev/null +++ b/Tiles/SunkenSea/Ambient/FloweringBarrelCactus.cs @@ -0,0 +1,33 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class FloweringBarrelCactus : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(163, 24, 21)); + DustType = DustID.Ambient_DarkBrown; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/FloweringBarrelCactus.png b/Tiles/SunkenSea/Ambient/FloweringBarrelCactus.png new file mode 100644 index 0000000000..fa1ef4ab8c Binary files /dev/null and b/Tiles/SunkenSea/Ambient/FloweringBarrelCactus.png differ diff --git a/Tiles/SunkenSea/Ambient/FryCoral.cs b/Tiles/SunkenSea/Ambient/FryCoral.cs new file mode 100644 index 0000000000..a8089ecf1f --- /dev/null +++ b/Tiles/SunkenSea/Ambient/FryCoral.cs @@ -0,0 +1,83 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class FryCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 3; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(79, 196, 149)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.588f; + g = 0.365f; + b = 0.365f; + } + } + + public class FryCoral2 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 3; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(79, 196, 149)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.588f; + g = 0.365f; + b = 0.365f; + } + } + public class FryCoral3 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.DrawYOffset = 3; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(79, 196, 149)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.588f; + g = 0.365f; + b = 0.365f; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/FryCoral.png b/Tiles/SunkenSea/Ambient/FryCoral.png new file mode 100644 index 0000000000..99e82a386d Binary files /dev/null and b/Tiles/SunkenSea/Ambient/FryCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/FryCoral2.png b/Tiles/SunkenSea/Ambient/FryCoral2.png new file mode 100644 index 0000000000..82f4c7858a Binary files /dev/null and b/Tiles/SunkenSea/Ambient/FryCoral2.png differ diff --git a/Tiles/SunkenSea/Ambient/FryCoral3.png b/Tiles/SunkenSea/Ambient/FryCoral3.png new file mode 100644 index 0000000000..830b4e0432 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/FryCoral3.png differ diff --git a/Tiles/SunkenSea/Ambient/GiantNavystone.cs b/Tiles/SunkenSea/Ambient/GiantNavystone.cs index 5d55115998..d253a009b8 100644 --- a/Tiles/SunkenSea/Ambient/GiantNavystone.cs +++ b/Tiles/SunkenSea/Ambient/GiantNavystone.cs @@ -1,11 +1,10 @@ -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; using Terraria.DataStructures; using Terraria.Enums; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.SunkenSea.Ambient { @@ -15,7 +14,8 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { Main.tileFrameImportant[Type] = true; Main.tileSolid[Type] = false; - TileObjectData.newTile.Width = 5; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 5; TileObjectData.newTile.Height = 5; TileObjectData.newTile.Origin = new Point16(2, 4); TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16 }; @@ -26,7 +26,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(0, 62, 84)); - DustType = 96; + DustType = DustID.BlueMoss; HitSound = SoundID.Dig; } } @@ -37,7 +37,8 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { Main.tileFrameImportant[Type] = true; Main.tileSolid[Type] = false; - TileObjectData.newTile.Width = 5; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 5; TileObjectData.newTile.Height = 4; TileObjectData.newTile.Origin = new Point16(2, 3); TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; @@ -48,8 +49,8 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient TileObjectData.newTile.DrawYOffset = 3; TileObjectData.addTile(Type); AddMapEntry(new Color(0, 62, 84)); - DustType = 96; + DustType = DustID.BlueMoss; HitSound = SoundID.Dig; } } -} \ No newline at end of file +} diff --git a/Tiles/SunkenSea/Ambient/GiantRadiantReefPile.cs b/Tiles/SunkenSea/Ambient/GiantRadiantReefPile.cs new file mode 100644 index 0000000000..8e759aa688 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/GiantRadiantReefPile.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class GiantRadiantReefPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.StyleHorizontal = true; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 2); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(136, 129, 154)); + DustType = DustID.GreenMoss; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/GiantRadiantReefPile.png b/Tiles/SunkenSea/Ambient/GiantRadiantReefPile.png new file mode 100644 index 0000000000..54910c5995 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/GiantRadiantReefPile.png differ diff --git a/Tiles/SunkenSea/Ambient/GilHerb.cs b/Tiles/SunkenSea/Ambient/GilHerb.cs new file mode 100644 index 0000000000..fef4b16278 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/GilHerb.cs @@ -0,0 +1,78 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class GilHerb : ModTile + { + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileNoAttach[Type] = true; + TileID.Sets.IsVine[Type] = true; + TileID.Sets.VineThreads[Type] = true; + AddMapEntry(new Color(124, 67, 197)); + DustType = DustID.Grass; + HitSound = SoundID.Grass; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + Tile tile = Framing.GetTileSafely(i, j + 1); + if (tile.HasTile && tile.TileType == Type) + WorldGen.KillTile(i, j + 1); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileAbove = Framing.GetTileSafely(i, j - 1); + int type = -1; + if (tileAbove.HasTile && !tileAbove.BottomSlope) + type = tileAbove.TileType; + + if (type == ModContent.TileType() || type == Type) + return true; + + WorldGen.KillTile(i, j); + return true; + } + + public override void RandomUpdate(int i, int j) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) + { + bool PlaceVine = false; + int Test = j; + while (Test > j - 10) + { + Tile testTile = Framing.GetTileSafely(i, Test); + if (testTile.BottomSlope) + { + break; + } + else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) + { + Test--; + continue; + } + PlaceVine = true; + break; + } + + if (PlaceVine) + { + tileBelow.TileType = Type; + tileBelow.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.dedServ) + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } +} diff --git a/Tiles/SunkenSea/Ambient/GilHerb.png b/Tiles/SunkenSea/Ambient/GilHerb.png new file mode 100644 index 0000000000..5f73fb2918 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/GilHerb.png differ diff --git a/Tiles/SunkenSea/Ambient/KelpBush.cs b/Tiles/SunkenSea/Ambient/KelpBush.cs new file mode 100644 index 0000000000..1f811f04bb --- /dev/null +++ b/Tiles/SunkenSea/Ambient/KelpBush.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class KelpBush : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(61, 126, 20)); + DustType = DustID.Grass; + HitSound = SoundID.Dig; + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/KelpBush.png b/Tiles/SunkenSea/Ambient/KelpBush.png new file mode 100644 index 0000000000..39d51f25f9 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/KelpBush.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeBarrelCactus.cs b/Tiles/SunkenSea/Ambient/LargeBarrelCactus.cs new file mode 100644 index 0000000000..d93b10fd7b --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargeBarrelCactus.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargeBarrelCactus : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 3); + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.RandomStyleRange = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(85, 143, 46)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargeBarrelCactus.png b/Tiles/SunkenSea/Ambient/LargeBarrelCactus.png new file mode 100644 index 0000000000..c5a96b33b2 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeBarrelCactus.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeDriftwoodWreckage.cs b/Tiles/SunkenSea/Ambient/LargeDriftwoodWreckage.cs new file mode 100644 index 0000000000..0943eb965f --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargeDriftwoodWreckage.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargeDriftwoodWreckage : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Width = 5; + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 3); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(146, 123, 127)); + DustType = DustID.Shadewood_Tree; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargeDriftwoodWreckage.png b/Tiles/SunkenSea/Ambient/LargeDriftwoodWreckage.png new file mode 100644 index 0000000000..e71f8608c7 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeDriftwoodWreckage.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeFloweringBarrelCactus.cs b/Tiles/SunkenSea/Ambient/LargeFloweringBarrelCactus.cs new file mode 100644 index 0000000000..2562e1c8e9 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargeFloweringBarrelCactus.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargeFloweringBarrelCactus : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 3); + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 2; + TileObjectData.newTile.RandomStyleRange = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(163, 24, 21)); + DustType = DustID.Shadewood_Tree; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargeFloweringBarrelCactus.png b/Tiles/SunkenSea/Ambient/LargeFloweringBarrelCactus.png new file mode 100644 index 0000000000..4796754896 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeFloweringBarrelCactus.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeGleamingBurrowsPile.cs b/Tiles/SunkenSea/Ambient/LargeGleamingBurrowsPile.cs new file mode 100644 index 0000000000..5a100021df --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargeGleamingBurrowsPile.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargeGleamingBurrowsPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 1); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(47, 85, 105)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargeGleamingBurrowsPile.png b/Tiles/SunkenSea/Ambient/LargeGleamingBurrowsPile.png new file mode 100644 index 0000000000..edbcd8a3bf Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeGleamingBurrowsPile.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeMossyStonePile.cs b/Tiles/SunkenSea/Ambient/LargeMossyStonePile.cs new file mode 100644 index 0000000000..ca642f8fb3 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargeMossyStonePile.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargeMossyStonePile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new Terraria.DataStructures.AnchorData(Terraria.Enums.AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Terraria.DataStructures.Point16(1, 1); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(100, 112, 191)); + DustType = DustID.GreenMoss; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargeMossyStonePile.png b/Tiles/SunkenSea/Ambient/LargeMossyStonePile.png new file mode 100644 index 0000000000..602ea7123a Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeMossyStonePile.png differ diff --git a/Tiles/SunkenSea/Ambient/LargePolypForestPile.cs b/Tiles/SunkenSea/Ambient/LargePolypForestPile.cs new file mode 100644 index 0000000000..205d746065 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargePolypForestPile.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargePolypForestPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 1); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(162, 55, 196)); + DustType = DustID.PurpleMoss; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargePolypForestPile.png b/Tiles/SunkenSea/Ambient/LargePolypForestPile.png new file mode 100644 index 0000000000..b2fb7c8de7 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargePolypForestPile.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeRadiantReefPile.cs b/Tiles/SunkenSea/Ambient/LargeRadiantReefPile.cs new file mode 100644 index 0000000000..e62bea6fa2 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargeRadiantReefPile.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargeRadiantReefPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 1); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(136, 129, 154)); + DustType = DustID.GreenMoss; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargeRadiantReefPile.png b/Tiles/SunkenSea/Ambient/LargeRadiantReefPile.png new file mode 100644 index 0000000000..9d43e4c65e Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeRadiantReefPile.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeShoresFlower.cs b/Tiles/SunkenSea/Ambient/LargeShoresFlower.cs new file mode 100644 index 0000000000..6c1454dd84 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LargeShoresFlower.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LargeShoresFlower : ModTile + { + public Asset CenterTexture; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileLighted[Type] = true; + + TileID.Sets.FramesOnKillWall[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); + + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16 }; + TileObjectData.newTile.Origin = new Point16(1, 1); + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(20, 100, 220)); + DustType = DustID.MagicMirror; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float pulse = 0.95f + 0.15f * (0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 4.2f)); + r = 0.1f * pulse; + g = 0.3f * pulse; + b = 0.8f * pulse; + } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + var tile = Main.tile[i, j]; + if (tile.IsTileActuallyInvisible()) + return false; + + float pulse = 0.95f + 0.15f * MathF.Sin(Main.GlobalTimeWrappedHourly * 4.2f); + + int xFrameOffset = tile.TileFrameX; + int yFrameOffset = tile.TileFrameY; + Texture2D glowmask = TextureAssets.Tile[Type].Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White * pulse; + + if (!tile.IsHalfBlock && tile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (tile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + + CenterTexture ??= ModContent.Request("CalamityMod/Tiles/SunkenSea/Ambient/LargeShoresFlower_Center"); + CalamityUtils.DrawFlameEffect(CenterTexture.Value, i, j, 2); + + return false; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LargeShoresFlower.png b/Tiles/SunkenSea/Ambient/LargeShoresFlower.png new file mode 100644 index 0000000000..9c040277a7 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeShoresFlower.png differ diff --git a/Tiles/SunkenSea/Ambient/LargeShoresFlower_Center.png b/Tiles/SunkenSea/Ambient/LargeShoresFlower_Center.png new file mode 100644 index 0000000000..b907c78161 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LargeShoresFlower_Center.png differ diff --git a/Tiles/SunkenSea/Ambient/LongScarletSeagrass.cs b/Tiles/SunkenSea/Ambient/LongScarletSeagrass.cs new file mode 100644 index 0000000000..e87951c391 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/LongScarletSeagrass.cs @@ -0,0 +1,53 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.Metadata; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class LongScarletSeagrass : ModTile + { + public override void SetStaticDefaults() + { + AnimationFrameHeight = 50; + Main.tileLighted[Type] = true; + Main.tileCut[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + Main.tileFrameImportant[Type] = true; + TileID.Sets.ReplaceTileBreakUp[Type] = true; + TileID.Sets.SwaysInWindBasic[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Plant"]); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.addTile(Type); + AddMapEntry(new Color(187, 43, 44)); + DustType = DustID.CrimsonPlants; + HitSound = SoundID.Grass; + + base.SetStaticDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = -30; + height = 48; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { + if (++frameCounter >= 12) + { + frameCounter = 0; + if (++frame >= 6) + { + frame = 0; + } + } + } + } +} diff --git a/Tiles/SunkenSea/Ambient/LongScarletSeagrass.png b/Tiles/SunkenSea/Ambient/LongScarletSeagrass.png new file mode 100644 index 0000000000..dfbd21fca3 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/LongScarletSeagrass.png differ diff --git a/Tiles/SunkenSea/Ambient/MediumCoral.cs b/Tiles/SunkenSea/Ambient/MediumCoral.cs index 5c27fcdb6f..cfbc62a123 100644 --- a/Tiles/SunkenSea/Ambient/MediumCoral.cs +++ b/Tiles/SunkenSea/Ambient/MediumCoral.cs @@ -23,15 +23,17 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient base.SetStaticDefaults(); } + public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 2; } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 229f / 350f; - g = 137f / 350f; - b = 204f / 350f; + r = 0.38f; + g = 0.28f; + b = 0.32f; } } @@ -39,9 +41,9 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 60f / 400f; - g = 110f / 400f; - b = 146f / 400f; + r = 0.15f; + g = 0.37f; + b = 0.46f; } } @@ -49,9 +51,9 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 60f / 255f; - g = 110f / 255f; - b = 146f / 255f; + r = 0.23f; + g = 0.43f; + b = 0.57f; } } } diff --git a/Tiles/SunkenSea/Ambient/MediumDriftwoodWreckage.cs b/Tiles/SunkenSea/Ambient/MediumDriftwoodWreckage.cs new file mode 100644 index 0000000000..11c878e862 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/MediumDriftwoodWreckage.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class MediumDriftwoodWreckage : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.Origin = new Point16(1, 2); + + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.addTile(Type); + AddMapEntry(new Color(146, 123, 127)); + DustType = DustID.Shadewood_Tree; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/MediumDriftwoodWreckage.png b/Tiles/SunkenSea/Ambient/MediumDriftwoodWreckage.png new file mode 100644 index 0000000000..3038646c27 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/MediumDriftwoodWreckage.png differ diff --git a/Tiles/SunkenSea/Ambient/MediumDunesandPile.cs b/Tiles/SunkenSea/Ambient/MediumDunesandPile.cs new file mode 100644 index 0000000000..6ae18a63fc --- /dev/null +++ b/Tiles/SunkenSea/Ambient/MediumDunesandPile.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class MediumDunesandPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(185, 104, 80)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/MediumDunesandPile.png b/Tiles/SunkenSea/Ambient/MediumDunesandPile.png new file mode 100644 index 0000000000..e58ff96cd4 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/MediumDunesandPile.png differ diff --git a/Tiles/SunkenSea/Ambient/MediumGleamingBurrowsPile.cs b/Tiles/SunkenSea/Ambient/MediumGleamingBurrowsPile.cs new file mode 100644 index 0000000000..65e5b43c14 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/MediumGleamingBurrowsPile.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class MediumGleamingBurrowsPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.StyleHorizontal = true; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(47, 85, 105)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/MediumGleamingBurrowsPile.png b/Tiles/SunkenSea/Ambient/MediumGleamingBurrowsPile.png new file mode 100644 index 0000000000..7b2d78674e Binary files /dev/null and b/Tiles/SunkenSea/Ambient/MediumGleamingBurrowsPile.png differ diff --git a/Tiles/SunkenSea/Ambient/MediumPolypForestPile.cs b/Tiles/SunkenSea/Ambient/MediumPolypForestPile.cs new file mode 100644 index 0000000000..97665c6766 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/MediumPolypForestPile.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class MediumPolypForestPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.StyleHorizontal = true; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(162, 55, 196)); + DustType = DustID.PurpleMoss; + HitSound = SoundID.Dig; + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/MediumPolypForestPile.png b/Tiles/SunkenSea/Ambient/MediumPolypForestPile.png new file mode 100644 index 0000000000..895f0988c9 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/MediumPolypForestPile.png differ diff --git a/Tiles/SunkenSea/Ambient/MediumRadiantReefPile.cs b/Tiles/SunkenSea/Ambient/MediumRadiantReefPile.cs new file mode 100644 index 0000000000..151870711a --- /dev/null +++ b/Tiles/SunkenSea/Ambient/MediumRadiantReefPile.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class MediumRadiantReefPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.StyleHorizontal = true; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(136, 129, 154)); + DustType = DustID.GreenMoss; + HitSound = SoundID.Dig; + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/MediumRadiantReefPile.png b/Tiles/SunkenSea/Ambient/MediumRadiantReefPile.png new file mode 100644 index 0000000000..935ffb32c8 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/MediumRadiantReefPile.png differ diff --git a/Tiles/SunkenSea/Ambient/MediumShorePile.cs b/Tiles/SunkenSea/Ambient/MediumShorePile.cs new file mode 100644 index 0000000000..fc6dd5914e --- /dev/null +++ b/Tiles/SunkenSea/Ambient/MediumShorePile.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class MediumShorePile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(158, 129, 177)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/MediumShorePile.png b/Tiles/SunkenSea/Ambient/MediumShorePile.png new file mode 100644 index 0000000000..bc84d45181 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/MediumShorePile.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePile.cs b/Tiles/SunkenSea/Ambient/NavystonePile.cs index 9f98dc98a6..e7ce8c72b0 100644 --- a/Tiles/SunkenSea/Ambient/NavystonePile.cs +++ b/Tiles/SunkenSea/Ambient/NavystonePile.cs @@ -1,33 +1,44 @@ -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using Terraria.DataStructures; -using Terraria.Enums; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Tiles.SunkenSea.Ambient { - public class NavystonePile1 : ModTile + public class NavystonePileBase : ModTile { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/NavystonePile"; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + DustType = DustID.Stone; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); + + AddMapEntry(new Color(0, 62, 84)); - DustType = 96; + DustType = DustID.BlueMoss; HitSound = SoundID.Dig; - } - } + } + } - public class NavystonePile2 : NavystonePile1 - { - } + public class NavystonePile : NavystonePileBase + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); - public class NavystonePile3 : NavystonePile1 - { - } -} \ No newline at end of file + TileID.Sets.BreakableWhenPlacing[Type] = true; + TileID.Sets.ReplaceTileBreakUp[Type] = true; + + TileObjectData.GetTileData(Type, 0).LavaDeath = false; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/NavystonePile.png b/Tiles/SunkenSea/Ambient/NavystonePile.png new file mode 100644 index 0000000000..7c1c723b2b Binary files /dev/null and b/Tiles/SunkenSea/Ambient/NavystonePile.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePile1.png b/Tiles/SunkenSea/Ambient/NavystonePile1.png deleted file mode 100644 index 45709a1865..0000000000 Binary files a/Tiles/SunkenSea/Ambient/NavystonePile1.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePile2.png b/Tiles/SunkenSea/Ambient/NavystonePile2.png deleted file mode 100644 index a3ff914034..0000000000 Binary files a/Tiles/SunkenSea/Ambient/NavystonePile2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePile3.png b/Tiles/SunkenSea/Ambient/NavystonePile3.png deleted file mode 100644 index 73fa4a8fa4..0000000000 Binary files a/Tiles/SunkenSea/Ambient/NavystonePile3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePileSmall1.png b/Tiles/SunkenSea/Ambient/NavystonePileSmall1.png deleted file mode 100644 index d4e121013f..0000000000 Binary files a/Tiles/SunkenSea/Ambient/NavystonePileSmall1.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePileSmall2.png b/Tiles/SunkenSea/Ambient/NavystonePileSmall2.png deleted file mode 100644 index e47f6e8a47..0000000000 Binary files a/Tiles/SunkenSea/Ambient/NavystonePileSmall2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePileSmall3.png b/Tiles/SunkenSea/Ambient/NavystonePileSmall3.png deleted file mode 100644 index 3892fee61c..0000000000 Binary files a/Tiles/SunkenSea/Ambient/NavystonePileSmall3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/RefractiveHangingCoral.cs b/Tiles/SunkenSea/Ambient/RefractiveHangingCoral.cs new file mode 100644 index 0000000000..a1287ad441 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/RefractiveHangingCoral.cs @@ -0,0 +1,116 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class RefractiveHangingCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileLighted[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileNoSunLight[Type] = false; + TileID.Sets.IsVine[Type] = true; + TileID.Sets.VineThreads[Type] = true; + AddMapEntry(new Color(76, 133, 191)); + DustType = DustID.Grass; + HitSound = SoundID.Grass; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + Tile tile = Framing.GetTileSafely(i, j + 1); + if (tile.HasTile && tile.TileType == Type) + WorldGen.KillTile(i, j + 1); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileAbove = Framing.GetTileSafely(i, j - 1); + int type = -1; + if (tileAbove.HasTile && !tileAbove.BottomSlope) + type = tileAbove.TileType; + + if (type == ModContent.TileType() || type == Type) + return true; + + WorldGen.KillTile(i, j); + return true; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (closer && Main.rand.NextBool(300)) + { + // this comment will exist until The Great Dustpan is merged: + // vanilla's Firefly dust (304) is completely yellow. + // therefore, it is completely unable to be turned blue due to how draw colour works! + // so it will always appear grey when you try to draw blue, and red/green/yellow otherwise. + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 280, 280, DustID.Firefly, 0.2f, 0f, 0, Color.Lerp(new Color(0, 76, 255), new Color(76, 0, 255), Main.rand.NextFloat()), Main.rand.NextFloat(1f, 2f))]; + dust.noGravity = true; + dust.noLight = true; + dust.fadeIn = 2.5f; + } + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + // Quite possibly some of the laggiest calculations I've ever seen + float brightness = 0.9f; + float time = Main.GlobalTimeWrappedHourly * 60.0f; + brightness *= MathF.Sin(-j / 40f + time * 0.01f + i); + Vector3 lilac = new(0.4941f, 0.3686f, 0.9882f); + Vector3 mint = new(0.3764f, 0.9882f, 0.7294f); + Vector3 value = Vector3.Lerp(lilac, mint, (MathF.Sin(j / 30f + time * 0.017f + -i / 40f) + 1f) * 0.5f); + Vector3 value1 = Vector3.Lerp(lilac, mint, (MathF.Sin((-j - 100) / 40f + time * 0.014f + i / 20f) + 1f) * 0.5f); + r = (value.X + value1.X) / 450f; + g = (value.Y + value1.Y) / 450f; + b = (value.Z + value1.Z) / 450f; + r *= brightness; + g *= brightness; + b *= brightness; + } + + public override void RandomUpdate(int i, int j) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) + { + bool PlaceVine = false; + int Test = j; + while (Test > j - 10) + { + Tile testTile = Framing.GetTileSafely(i, Test); + if (testTile.BottomSlope) + { + break; + } + else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) + { + Test--; + continue; + } + PlaceVine = true; + break; + } + + if (PlaceVine) + { + tileBelow.TileType = Type; + tileBelow.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.dedServ) + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } +} diff --git a/Tiles/SunkenSea/Ambient/RefractiveHangingCoral.png b/Tiles/SunkenSea/Ambient/RefractiveHangingCoral.png new file mode 100644 index 0000000000..cd49838375 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/RefractiveHangingCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/SeaAnemone.cs b/Tiles/SunkenSea/Ambient/SeaAnemone.cs index fe95a937cc..fb2a1b063d 100644 --- a/Tiles/SunkenSea/Ambient/SeaAnemone.cs +++ b/Tiles/SunkenSea/Ambient/SeaAnemone.cs @@ -1,6 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -10,12 +10,13 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { public override void SetStaticDefaults() { + Main.tileLighted[Type] = true; AnimationFrameHeight = 36; Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(54, 69, 72)); base.SetStaticDefaults(); @@ -26,6 +27,13 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient num = fail ? 1 : 3; } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.11f; + g = 0.29f; + b = 0.57f; + } + public override void AnimateTile(ref int frame, ref int frameCounter) { frameCounter++; diff --git a/Tiles/SunkenSea/Ambient/ShorePile.cs b/Tiles/SunkenSea/Ambient/ShorePile.cs new file mode 100644 index 0000000000..2cf7f9ebbd --- /dev/null +++ b/Tiles/SunkenSea/Ambient/ShorePile.cs @@ -0,0 +1,44 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class ShorePileBase : ModTile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/ShorePile"; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + DustType = DustID.Stone; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.addTile(Type); + + + AddMapEntry(new Color(189, 120, 94)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + } + + public class ShorePile : ShorePileBase + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + + TileID.Sets.BreakableWhenPlacing[Type] = true; + TileID.Sets.ReplaceTileBreakUp[Type] = true; + + TileObjectData.GetTileData(Type, 0).LavaDeath = false; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/ShorePile.png b/Tiles/SunkenSea/Ambient/ShorePile.png new file mode 100644 index 0000000000..b9d0c26efd Binary files /dev/null and b/Tiles/SunkenSea/Ambient/ShorePile.png differ diff --git a/Tiles/SunkenSea/Ambient/ShoresFlower.cs b/Tiles/SunkenSea/Ambient/ShoresFlower.cs new file mode 100644 index 0000000000..7bed73063f --- /dev/null +++ b/Tiles/SunkenSea/Ambient/ShoresFlower.cs @@ -0,0 +1,84 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class ShoresFlower : ModTile + { + public Asset CenterTexture; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileLighted[Type] = true; + + TileID.Sets.FramesOnKillWall[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 }; + + TileObjectData.newTile.AnchorWall = true; + TileObjectData.newTile.AnchorTop = AnchorData.Empty; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = AnchorData.Empty; + TileObjectData.newTile.AnchorRight = AnchorData.Empty; + + TileObjectData.newTile.Origin = new Point16(1, 1); + + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(20, 100, 220)); + DustType = DustID.MagicMirror; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float pulse = 0.95f + 0.15f * (0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 4.2f)); + r = 0.1f * pulse; + g = 0.3f * pulse; + b = 0.8f * pulse; + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + var tile = Main.tile[i, j]; + + if (tile.IsTileActuallyInvisible()) + return false; + + float pulse = 0.95f + 0.15f * MathF.Sin(Main.GlobalTimeWrappedHourly * 4.2f); + + int xFrameOffset = tile.TileFrameX; + int yFrameOffset = tile.TileFrameY; + Texture2D glowmask = TextureAssets.Tile[Type].Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White * pulse; + + if (!tile.IsHalfBlock && tile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (tile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + + CenterTexture ??= ModContent.Request("CalamityMod/Tiles/SunkenSea/Ambient/ShoresFlower_Center"); + CalamityUtils.DrawFlameEffect(CenterTexture.Value, i, j, 2); + + return false; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/ShoresFlower.png b/Tiles/SunkenSea/Ambient/ShoresFlower.png new file mode 100644 index 0000000000..6ae51dd2ac Binary files /dev/null and b/Tiles/SunkenSea/Ambient/ShoresFlower.png differ diff --git a/Tiles/SunkenSea/Ambient/ShoresFlower_Center.png b/Tiles/SunkenSea/Ambient/ShoresFlower_Center.png new file mode 100644 index 0000000000..ccc3c4061c Binary files /dev/null and b/Tiles/SunkenSea/Ambient/ShoresFlower_Center.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallBrainCoral.cs b/Tiles/SunkenSea/Ambient/SmallBrainCoral.cs index 6013e6ac73..ff90577e50 100644 --- a/Tiles/SunkenSea/Ambient/SmallBrainCoral.cs +++ b/Tiles/SunkenSea/Ambient/SmallBrainCoral.cs @@ -1,9 +1,11 @@ -using CalamityMod.Projectiles.Typeless; +using System; +using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -17,7 +19,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.SailfishBoots; AddMapEntry(new Color(36, 61, 111)); base.SetStaticDefaults(); @@ -28,12 +30,36 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient num = fail ? 1 : 3; } + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + var tile = Main.tile[i, j]; + if (tile.IsTileActuallyInvisible()) + return false; + + float glowbrightness = 1f; + float glowspeed = (float)(Main.timeForVisualEffects * 0.01); + glowbrightness *= MathF.Sin(i / 60f + glowspeed); + + int xFrameOffset = tile.TileFrameX; + int yFrameOffset = tile.TileFrameY; + Texture2D glowmask = TextureAssets.Tile[Type].Value; + Vector2 drawOffest = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffest; + Color drawColour = Color.White * glowbrightness; + + if (!tile.IsHalfBlock && tile.Slope == 0) + spriteBatch.Draw(glowmask, drawPosition, new Rectangle(xFrameOffset, yFrameOffset, 18, 18), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + else if (tile.IsHalfBlock) + spriteBatch.Draw(glowmask, drawPosition + new Vector2(0f, 8f), new Rectangle(xFrameOffset, yFrameOffset, 18, 8), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + + return false; + } + public override void NearbyEffects(int i, int j, bool closer) { if (Main.gamePaused) - { return; - } + if (closer) { if (Main.rand.NextBool(300)) @@ -45,6 +71,17 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { if (Main.tile[i, tileLocationY].LiquidAmount == 255 && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && Main.tile[i, tileLocationY - 2].LiquidAmount == 255) { + for (int t = 0; t < 5; t++) + { + Dust dust = Dust.NewDustDirect(new Vector2(i, j + 0.5f) * 16, 16, 16, DustID.BlueTorch, 0, 0, 1, default, 1.5f); + dust.velocity *= 0.2f; + dust.noGravity = true; + dust.noLight = true; + dust.noLightEmittence = true; + } + Dust dust2 = Dust.NewDustDirect(new Vector2(i, j + 0.5f) * 16, 16, 16, DustID.MagicMirror, 0, 0, 1, Color.LightSkyBlue, 0.5f); + dust2.velocity *= 0.2f; + if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(new EntitySource_WorldEvent(), i * 16 + 16, tileLocationY * 16 + 16, 0f, -0.1f, ModContent.ProjectileType(), 0, 1f, Main.myPlayer); } diff --git a/Tiles/SunkenSea/Ambient/SmallBrainCoral.png b/Tiles/SunkenSea/Ambient/SmallBrainCoral.png index 31de0f162e..43ba546b88 100644 Binary files a/Tiles/SunkenSea/Ambient/SmallBrainCoral.png and b/Tiles/SunkenSea/Ambient/SmallBrainCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallCorals.cs b/Tiles/SunkenSea/Ambient/SmallCorals.cs index e430167287..643a492ac4 100644 --- a/Tiles/SunkenSea/Ambient/SmallCorals.cs +++ b/Tiles/SunkenSea/Ambient/SmallCorals.cs @@ -2,7 +2,6 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ObjectData; namespace CalamityMod.Tiles.SunkenSea.Ambient { @@ -10,49 +9,52 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient { public override void SetStaticDefaults() { - Main.tileLighted[Type] = false; - Main.tileCut[Type] = false; - Main.tileSolid[Type] = false; - Main.tileNoAttach[Type] = true; + Main.tileLighted[Type] = true; Main.tileNoFail[Type] = true; - Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; - TileID.Sets.ReplaceTileBreakUp[Type] = true; - TileID.Sets.SwaysInWindBasic[Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); - TileObjectData.addTile(Type); + Main.tileObsidianKill[Type] = true; AddMapEntry(new Color(178, 28, 153)); DustType = DustID.Coralstone; HitSound = SoundID.Grass; - - base.SetStaticDefaults(); } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - Tile tileBelow = Framing.GetTileSafely(i, j + 1); - int type = -1; - - if (tileBelow.HasTile) - { - type = tileBelow.TileType; - } - - if (type == ModContent.TileType()) - { - return true; - } - - WorldGen.KillTile(i, j); - - return true; - } - - public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + public override void NumDust(int i, int j, bool fail, ref int num) { - offsetY = 0; - height = 16; + num = fail ? 1 : 3; + } + + public override bool CanPlace(int i, int j) + { + Tile belowTile = Main.tile[i, j + 1]; + Tile aboveTile = Main.tile[i, j - 1]; + Tile rightTile = Main.tile[i + 1, j]; + Tile leftTile = Main.tile[i - 1, j]; + + if ((belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) || + (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) || + (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) || + (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid())) + return true; + + return false; + } + public override void PlaceInWorld(int i, int j, Item item) + { + Tile belowTile = Main.tile[i, j + 1]; + Tile aboveTile = Main.tile[i, j - 1]; + Tile rightTile = Main.tile[i + 1, j]; + Tile leftTile = Main.tile[i - 1, j]; + + if (belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 0; + else if (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 18; + else if (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 36; + else if (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 54; + + Main.tile[i, j].TileFrameX = (short)(WorldGen.genRand.Next(18) * 18); } } } diff --git a/Tiles/SunkenSea/Ambient/SmallCorals.png b/Tiles/SunkenSea/Ambient/SmallCorals.png index 1aa6601be7..796b5ab8ed 100644 Binary files a/Tiles/SunkenSea/Ambient/SmallCorals.png and b/Tiles/SunkenSea/Ambient/SmallCorals.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallGleamingBurrowsPile.cs b/Tiles/SunkenSea/Ambient/SmallGleamingBurrowsPile.cs new file mode 100644 index 0000000000..01485011b2 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallGleamingBurrowsPile.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallGleamingBurrowsPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.CoordinateHeights = new[] { 16 }; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.addTile(Type); + + DustType = DustID.BlueMoss; + AddMapEntry(new Color(47, 85, 105)); + + base.SetStaticDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SmallGleamingBurrowsPile.png b/Tiles/SunkenSea/Ambient/SmallGleamingBurrowsPile.png new file mode 100644 index 0000000000..dfcc58bcee Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SmallGleamingBurrowsPile.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile.cs b/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile.cs new file mode 100644 index 0000000000..39e6b5b8bc --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile.cs @@ -0,0 +1,44 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallLimestoneCobblePileBase : ModTile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile"; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + DustType = DustID.Stone; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.addTile(Type); + + + AddMapEntry(new Color(174, 120, 91)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + } + + public class SmallLimestoneCobblePile : SmallLimestoneCobblePileBase + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + + TileID.Sets.BreakableWhenPlacing[Type] = true; + TileID.Sets.ReplaceTileBreakUp[Type] = true; + + TileObjectData.GetTileData(Type, 0).LavaDeath = false; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile.png b/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile.png new file mode 100644 index 0000000000..21b14f9f2c Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SmallLimestoneCobblePile.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallMossyStonePile.cs b/Tiles/SunkenSea/Ambient/SmallMossyStonePile.cs new file mode 100644 index 0000000000..5d22115df7 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallMossyStonePile.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallMossyStonePile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.CoordinateHeights = new[] { 16 }; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.addTile(Type); + + AddMapEntry(new Color(100, 112, 191)); + DustType = DustID.GreenMoss; + + base.SetStaticDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SmallMossyStonePile.png b/Tiles/SunkenSea/Ambient/SmallMossyStonePile.png new file mode 100644 index 0000000000..9cc5dc2bf1 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SmallMossyStonePile.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallNavystonePile.cs b/Tiles/SunkenSea/Ambient/SmallNavystonePile.cs new file mode 100644 index 0000000000..a7a2e50105 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallNavystonePile.cs @@ -0,0 +1,44 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallNavystonePileBase : ModTile + { + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallNavystonePile"; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + DustType = DustID.Stone; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.addTile(Type); + + + AddMapEntry(new Color(0, 62, 84)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + } + + public class SmallNavystonePile : NavystonePileBase + { + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + + TileID.Sets.BreakableWhenPlacing[Type] = true; + TileID.Sets.ReplaceTileBreakUp[Type] = true; + + TileObjectData.GetTileData(Type, 0).LavaDeath = false; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SmallNavystonePile.png b/Tiles/SunkenSea/Ambient/SmallNavystonePile.png new file mode 100644 index 0000000000..3cf17393f8 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SmallNavystonePile.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallPolypForestPile.cs b/Tiles/SunkenSea/Ambient/SmallPolypForestPile.cs new file mode 100644 index 0000000000..3056fcf6bb --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallPolypForestPile.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallPolypForestPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + AddMapEntry(new Color(162, 55, 196)); + DustType = DustID.PurpleMoss; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.CoordinateHeights = new[] { 16 }; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.addTile(Type); + + base.SetStaticDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SmallPolypForestPile.png b/Tiles/SunkenSea/Ambient/SmallPolypForestPile.png new file mode 100644 index 0000000000..fbc0d16daf Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SmallPolypForestPile.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallRadiantReefPile.cs b/Tiles/SunkenSea/Ambient/SmallRadiantReefPile.cs new file mode 100644 index 0000000000..d12b645cef --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallRadiantReefPile.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallRadiantReefPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + + AddMapEntry(new Color(136, 129, 154)); + DustType = DustID.GreenMoss; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.CoordinateHeights = new[] { 16 }; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.addTile(Type); + + base.SetStaticDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SmallRadiantReefPile.png b/Tiles/SunkenSea/Ambient/SmallRadiantReefPile.png new file mode 100644 index 0000000000..d7901c8738 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SmallRadiantReefPile.png differ diff --git a/Tiles/SunkenSea/Ambient/SmallSunkenStalactites.cs b/Tiles/SunkenSea/Ambient/SmallSunkenStalactites.cs new file mode 100644 index 0000000000..42c4563b6a --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallSunkenStalactites.cs @@ -0,0 +1,31 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallSunkenStalactites : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + TileObjectData.newTile.DrawYOffset = -2; + TileObjectData.addTile(Type); + DustType = DustID.TsunamiInABottle; + AddMapEntry(new Color(31, 92, 114)); + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.png b/Tiles/SunkenSea/Ambient/SmallSunkenStalactites.png similarity index 100% rename from Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.png rename to Tiles/SunkenSea/Ambient/SmallSunkenStalactites.png diff --git a/Tiles/SunkenSea/Ambient/SmallSunkenStalagmites.cs b/Tiles/SunkenSea/Ambient/SmallSunkenStalagmites.cs new file mode 100644 index 0000000000..d6c4246561 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SmallSunkenStalagmites.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SmallSunkenStalagmites : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.addTile(Type); + DustType = DustID.TsunamiInABottle; + AddMapEntry(new Color(31, 92, 114)); + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.png b/Tiles/SunkenSea/Ambient/SmallSunkenStalagmites.png similarity index 100% rename from Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.png rename to Tiles/SunkenSea/Ambient/SmallSunkenStalagmites.png diff --git a/Tiles/SunkenSea/Ambient/SmallTubeCoral.cs b/Tiles/SunkenSea/Ambient/SmallTubeCoral.cs index f37261d8d9..243d21154c 100644 --- a/Tiles/SunkenSea/Ambient/SmallTubeCoral.cs +++ b/Tiles/SunkenSea/Ambient/SmallTubeCoral.cs @@ -1,6 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -14,7 +14,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileNoAttach[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(36, 61, 111)); base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/Ambient/SmallWideCoral.cs b/Tiles/SunkenSea/Ambient/SmallWideCoral.cs index 5d7641c3f6..5d5c913b17 100644 --- a/Tiles/SunkenSea/Ambient/SmallWideCoral.cs +++ b/Tiles/SunkenSea/Ambient/SmallWideCoral.cs @@ -25,18 +25,19 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 161f / 500f; - g = 183f / 500f; - b = 73f / 500f; + r = 0.322f; + g = 0.366f; + b = 0.146f; } } + public class SmallWideCoral2 : SmallWideCoral { public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 229f / 700f; - g = 137f / 700f; - b = 204f / 700f; + r = 0.327f; + g = 0.196f; + b = 0.291f; } } } diff --git a/Tiles/SunkenSea/Ambient/StalkCoral.cs b/Tiles/SunkenSea/Ambient/StalkCoral.cs new file mode 100644 index 0000000000..416101790f --- /dev/null +++ b/Tiles/SunkenSea/Ambient/StalkCoral.cs @@ -0,0 +1,119 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class StalkCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(156, 87, 57)); + DustType = DustID.t_PearlWood; + HitSound = SoundID.Dig; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.427f; + g = 0.384f; + b = 0.369f; + } + } + + public class StalkCoral2 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 1); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(156, 87, 57)); + DustType = DustID.t_PearlWood; + HitSound = SoundID.Dig; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.427f; + g = 0.384f; + b = 0.369f; + } + } + + public class StalkCoral3 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(156, 87, 57)); + DustType = DustID.t_PearlWood; + HitSound = SoundID.Dig; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.427f; + g = 0.384f; + b = 0.369f; + } + } + +} diff --git a/Tiles/SunkenSea/Ambient/StalkCoral.png b/Tiles/SunkenSea/Ambient/StalkCoral.png new file mode 100644 index 0000000000..63624ae860 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/StalkCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/StalkCoral2.png b/Tiles/SunkenSea/Ambient/StalkCoral2.png new file mode 100644 index 0000000000..b252e86203 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/StalkCoral2.png differ diff --git a/Tiles/SunkenSea/Ambient/StalkCoral3.png b/Tiles/SunkenSea/Ambient/StalkCoral3.png new file mode 100644 index 0000000000..cab856dd66 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/StalkCoral3.png differ diff --git a/Tiles/SunkenSea/Ambient/SunkenShip.cs b/Tiles/SunkenSea/Ambient/SunkenShip.cs new file mode 100644 index 0000000000..27bf32fe83 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SunkenShip.cs @@ -0,0 +1,40 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.Enums; +using Terraria.DataStructures; +using Terraria.Localization; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SunkenShip : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileBlockLight[Type] = false; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.Width = 14; + TileObjectData.newTile.Height = 8; + TileObjectData.newTile.Origin = new Point16(7, 7); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16, 16, 16, 16, 16, 16 }; + TileObjectData.newTile.AnchorBottom = new AnchorData( + AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, 14, 0); + + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + + TileObjectData.addTile(Type); + + AddMapEntry(new Color(100, 80, 70), Language.GetText("Sunken Ship")); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SunkenShip.png b/Tiles/SunkenSea/Ambient/SunkenShip.png new file mode 100644 index 0000000000..496c1e2555 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SunkenShip.png differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalactite.cs b/Tiles/SunkenSea/Ambient/SunkenStalactite.cs deleted file mode 100644 index ab84ff433c..0000000000 --- a/Tiles/SunkenSea/Ambient/SunkenStalactite.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.SunkenSea.Ambient -{ - [LegacyName("SunkenStalactites")] - public class SunkenStalactite1 : ModTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorBottom = default(AnchorData); - TileObjectData.addTile(Type); - DustType = 253; - AddMapEntry(new Color(31, 92, 114)); - - base.SetStaticDefaults(); - } - } - - public class SunkenStalactite2 : SunkenStalactite1 - { - } - - public class SunkenStalactite3 : SunkenStalactite1 - { - } -} diff --git a/Tiles/SunkenSea/Ambient/SunkenStalactite1.png b/Tiles/SunkenSea/Ambient/SunkenStalactite1.png deleted file mode 100644 index 3ee3027221..0000000000 Binary files a/Tiles/SunkenSea/Ambient/SunkenStalactite1.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalactite2.png b/Tiles/SunkenSea/Ambient/SunkenStalactite2.png deleted file mode 100644 index 9dfc38af8f..0000000000 Binary files a/Tiles/SunkenSea/Ambient/SunkenStalactite2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalactite3.png b/Tiles/SunkenSea/Ambient/SunkenStalactite3.png deleted file mode 100644 index 645ea59c1f..0000000000 Binary files a/Tiles/SunkenSea/Ambient/SunkenStalactite3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalactites.cs b/Tiles/SunkenSea/Ambient/SunkenStalactites.cs new file mode 100644 index 0000000000..64a8da2413 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SunkenStalactites.cs @@ -0,0 +1,31 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SunkenStalactites : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.AnchorBottom = default(AnchorData); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + TileObjectData.newTile.DrawYOffset = -2; + TileObjectData.addTile(Type); + DustType = DustID.TsunamiInABottle; + AddMapEntry(new Color(31, 92, 114)); + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.cs b/Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.cs deleted file mode 100644 index 8200dfda84..0000000000 --- a/Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.SunkenSea.Ambient -{ - public class SunkenStalactitesSmall : ModTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorBottom = default(AnchorData); - TileObjectData.addTile(Type); - DustType = 253; - AddMapEntry(new Color(31, 92, 114)); - - base.SetStaticDefaults(); - } - } -} diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmite.cs b/Tiles/SunkenSea/Ambient/SunkenStalagmite.cs deleted file mode 100644 index 43fc2022a2..0000000000 --- a/Tiles/SunkenSea/Ambient/SunkenStalagmite.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.SunkenSea.Ambient -{ - [LegacyName("SunkenStalagmites")] - public class SunkenStalagmite1 : ModTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); - TileObjectData.addTile(Type); - DustType = 253; - AddMapEntry(new Color(31, 92, 114)); - - base.SetStaticDefaults(); - } - } - - public class SunkenStalagmite2 : SunkenStalagmite1 - { - } - - public class SunkenStalagmite3 : SunkenStalagmite1 - { - } -} diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmite1.png b/Tiles/SunkenSea/Ambient/SunkenStalagmite1.png deleted file mode 100644 index aae38d97d3..0000000000 Binary files a/Tiles/SunkenSea/Ambient/SunkenStalagmite1.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmite2.png b/Tiles/SunkenSea/Ambient/SunkenStalagmite2.png deleted file mode 100644 index 5f17363111..0000000000 Binary files a/Tiles/SunkenSea/Ambient/SunkenStalagmite2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmite3.png b/Tiles/SunkenSea/Ambient/SunkenStalagmite3.png deleted file mode 100644 index 532fe794b6..0000000000 Binary files a/Tiles/SunkenSea/Ambient/SunkenStalagmite3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmites.cs b/Tiles/SunkenSea/Ambient/SunkenStalagmites.cs new file mode 100644 index 0000000000..71e18c1d5e --- /dev/null +++ b/Tiles/SunkenSea/Ambient/SunkenStalagmites.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class SunkenStalagmites : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.addTile(Type); + DustType = DustID.TsunamiInABottle; + AddMapEntry(new Color(31, 92, 114)); + + base.SetStaticDefaults(); + } + } +} diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmites.png b/Tiles/SunkenSea/Ambient/SunkenStalagmites.png new file mode 100644 index 0000000000..83424a46f6 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SunkenStalagmites.png differ diff --git a/Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.cs b/Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.cs deleted file mode 100644 index e38fa0a231..0000000000 --- a/Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles.SunkenSea.Ambient -{ - public class SunkenStalagmitesSmall : ModTile - { - public override void SetStaticDefaults() - { - Main.tileFrameImportant[Type] = true; - Main.tileNoAttach[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); - TileObjectData.addTile(Type); - DustType = 253; - AddMapEntry(new Color(31, 92, 114)); - - base.SetStaticDefaults(); - } - } -} diff --git a/Tiles/SunkenSea/Ambient/TableCoral.cs b/Tiles/SunkenSea/Ambient/TableCoral.cs index 8d2c9bd58d..20aee85177 100644 --- a/Tiles/SunkenSea/Ambient/TableCoral.cs +++ b/Tiles/SunkenSea/Ambient/TableCoral.cs @@ -2,7 +2,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -15,18 +15,18 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; Main.tileSolidTop[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.StyleMultiplier = 2; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.None, 0, 0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; + TileObjectData.newTile.DrawXOffset = 2; TileObjectData.addTile(Type); - DustType = 253; - AddMapEntry(new Color(54, 69, 72)); + + DustType = DustID.TsunamiInABottle; + AddMapEntry(new Color(23, 56, 75)); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -34,12 +34,4 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient num = fail ? 1 : 3; } } - - public class TableCoral2 : TableCoral - { - } - - public class TableCoral3 : TableCoral - { - } } diff --git a/Tiles/SunkenSea/Ambient/TableCoral.png b/Tiles/SunkenSea/Ambient/TableCoral.png index 45ea42abfd..be8d875999 100644 Binary files a/Tiles/SunkenSea/Ambient/TableCoral.png and b/Tiles/SunkenSea/Ambient/TableCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/TableCoral2.png b/Tiles/SunkenSea/Ambient/TableCoral2.png deleted file mode 100644 index 90c37eaa63..0000000000 Binary files a/Tiles/SunkenSea/Ambient/TableCoral2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/TableCoral3.png b/Tiles/SunkenSea/Ambient/TableCoral3.png deleted file mode 100644 index 4b9b83df62..0000000000 Binary files a/Tiles/SunkenSea/Ambient/TableCoral3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/TableCoralLeft.cs b/Tiles/SunkenSea/Ambient/TableCoralLeft.cs new file mode 100644 index 0000000000..2249396d73 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/TableCoralLeft.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class TableCoralLeft : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSolidTop[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleWrapLimit = 3; + TileObjectData.newTile.RandomStyleRange = 3; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.newTile.DrawXOffset = -2; + TileObjectData.addTile(Type); + + DustType = DustID.TsunamiInABottle; + AddMapEntry(new Color(23, 56, 75)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/TableCoralLeft.png b/Tiles/SunkenSea/Ambient/TableCoralLeft.png new file mode 100644 index 0000000000..e107da9ede Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TableCoralLeft.png differ diff --git a/Tiles/SunkenSea/Ambient/TallDigitateCoral.cs b/Tiles/SunkenSea/Ambient/TallDigitateCoral.cs new file mode 100644 index 0000000000..54a0daba3a --- /dev/null +++ b/Tiles/SunkenSea/Ambient/TallDigitateCoral.cs @@ -0,0 +1,149 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class TallDigitateCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(0, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(48, 201, 214)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.14f; + g = 0.41f; + b = 0.45f; + } + } + + public class TallDigitateCoral2 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(0, 3); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(48, 201, 214)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.14f; + g = 0.41f; + b = 0.45f; + } + } + + public class TallDigitateCoral3 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.Origin = new Point16(0, 4); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(48, 201, 214)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.14f; + g = 0.41f; + b = 0.45f; + } + } + + public class TallDigitateCoral4 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 6; + TileObjectData.newTile.Origin = new Point16(0, 5); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(48, 201, 214)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.14f; + g = 0.41f; + b = 0.45f; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/TallDigitateCoral.png b/Tiles/SunkenSea/Ambient/TallDigitateCoral.png new file mode 100644 index 0000000000..432a9bfed7 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TallDigitateCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/TallDigitateCoral2.png b/Tiles/SunkenSea/Ambient/TallDigitateCoral2.png new file mode 100644 index 0000000000..2602cb0363 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TallDigitateCoral2.png differ diff --git a/Tiles/SunkenSea/Ambient/TallDigitateCoral3.png b/Tiles/SunkenSea/Ambient/TallDigitateCoral3.png new file mode 100644 index 0000000000..d7898fe9c4 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TallDigitateCoral3.png differ diff --git a/Tiles/SunkenSea/Ambient/TallDigitateCoral4.png b/Tiles/SunkenSea/Ambient/TallDigitateCoral4.png new file mode 100644 index 0000000000..b1b1bca49a Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TallDigitateCoral4.png differ diff --git a/Tiles/SunkenSea/Ambient/TubeCoral.cs b/Tiles/SunkenSea/Ambient/TubeCoral.cs index e8a7b0fd81..e00426558f 100644 --- a/Tiles/SunkenSea/Ambient/TubeCoral.cs +++ b/Tiles/SunkenSea/Ambient/TubeCoral.cs @@ -1,6 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient 16 }; TileObjectData.addTile(Type); - DustType = 253; + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(36, 61, 111)); base.SetStaticDefaults(); diff --git a/Tiles/SunkenSea/Ambient/WallCoral.cs b/Tiles/SunkenSea/Ambient/WallCoral.cs index 634fe16177..4f4ab95e62 100644 --- a/Tiles/SunkenSea/Ambient/WallCoral.cs +++ b/Tiles/SunkenSea/Ambient/WallCoral.cs @@ -2,13 +2,13 @@ using Terraria; using Terraria.DataStructures; using Terraria.Enums; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.SunkenSea.Ambient { - public class WallCoral1 : ModTile + public class WallCoral : ModTile { public override void SetStaticDefaults() { @@ -16,57 +16,21 @@ namespace CalamityMod.Tiles.SunkenSea.Ambient Main.tileNoAttach[Type] = true; Main.tileSolidTop[Type] = false; Main.tileLighted[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.None, 0, 0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); - TileObjectData.addAlternate(1); - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16 }; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.DrawXOffset = 2; TileObjectData.addTile(Type); - DustType = 253; + + DustType = DustID.TsunamiInABottle; AddMapEntry(new Color(54, 69, 72)); } - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 189f / 450f; - g = 72f / 450f; - b = 72f / 450f; - } - } - - public class WallCoral2 : WallCoral1 - { - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 96f / 450f; - g = 157f / 450f; - b = 187f / 450f; - } - } - - public class WallCoral3 : WallCoral1 - { - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 68f / 450f; - g = 154f / 450f; - b = 128f / 450f; - } - } - - public class WallCoral4 : WallCoral1 - { - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 206f / 450f; - g = 88f / 450f; - b = 174f / 450f; - } + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; } } diff --git a/Tiles/SunkenSea/Ambient/WallCoral.png b/Tiles/SunkenSea/Ambient/WallCoral.png new file mode 100644 index 0000000000..6ef197c60b Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral1.png b/Tiles/SunkenSea/Ambient/WallCoral1.png deleted file mode 100644 index 5efc01eaec..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral1.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral2.png b/Tiles/SunkenSea/Ambient/WallCoral2.png deleted file mode 100644 index ab007eeb0f..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral2.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral3.png b/Tiles/SunkenSea/Ambient/WallCoral3.png deleted file mode 100644 index c5017e1401..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral3.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral4.png b/Tiles/SunkenSea/Ambient/WallCoral4.png deleted file mode 100644 index 901f50fcdb..0000000000 Binary files a/Tiles/SunkenSea/Ambient/WallCoral4.png and /dev/null differ diff --git a/Tiles/SunkenSea/Ambient/WallCoralLeft.cs b/Tiles/SunkenSea/Ambient/WallCoralLeft.cs new file mode 100644 index 0000000000..c5400db224 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/WallCoralLeft.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class WallCoralLeft : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSolidTop[Type] = false; + Main.tileLighted[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16 }; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 3, 0); + TileObjectData.newTile.DrawXOffset = 2; + TileObjectData.addTile(Type); + + DustType = DustID.TsunamiInABottle; + AddMapEntry(new Color(54, 69, 72)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Tiles/SunkenSea/Ambient/WallCoralLeft.png b/Tiles/SunkenSea/Ambient/WallCoralLeft.png new file mode 100644 index 0000000000..f8e349d9e8 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoralLeft.png differ diff --git a/Tiles/SunkenSea/Ambient/WideScarletSeagrass.cs b/Tiles/SunkenSea/Ambient/WideScarletSeagrass.cs new file mode 100644 index 0000000000..8a02e99992 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/WideScarletSeagrass.cs @@ -0,0 +1,31 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class WideScarletSeagrass : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = false; + TileID.Sets.ReplaceTileBreakUp[Type] = true; + TileID.Sets.SwaysInWindBasic[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.addTile(Type); + + AddMapEntry(new Color(187, 43, 44)); + DustType = DustID.BlueMoss; + HitSound = SoundID.Dig; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/WideScarletSeagrass.png b/Tiles/SunkenSea/Ambient/WideScarletSeagrass.png new file mode 100644 index 0000000000..a06329abd7 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WideScarletSeagrass.png differ diff --git a/Tiles/SunkenSea/AridSoil.cs b/Tiles/SunkenSea/AridSoil.cs new file mode 100644 index 0000000000..b7b9de952b --- /dev/null +++ b/Tiles/SunkenSea/AridSoil.cs @@ -0,0 +1,56 @@ +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class AridSoil : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + Main.tileShine2[Type] = false; + + DustType = DustID.Hive; + AddMapEntry(new Color(203, 123, 107)); + + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/AridSoil.png b/Tiles/SunkenSea/AridSoil.png new file mode 100644 index 0000000000..bdb1c641e5 Binary files /dev/null and b/Tiles/SunkenSea/AridSoil.png differ diff --git a/Tiles/SunkenSea/Basalt.cs b/Tiles/SunkenSea/Basalt.cs index 66801b9ce7..e378370112 100644 --- a/Tiles/SunkenSea/Basalt.cs +++ b/Tiles/SunkenSea/Basalt.cs @@ -8,55 +8,57 @@ namespace CalamityMod.Tiles.SunkenSea { public class Basalt : ModTile { - private int sheetWidth = 234; - private int sheetHeight = 90; - - public byte[,] tileAdjacency; - public byte[,] secondTileAdjacency; - public byte[,] thirdTileAdjacency; - public byte[,] fourthTileAdjacency; - public override void SetStaticDefaults() { TileID.Sets.GeneralPlacementTiles[Type] = false; - + TileID.Sets.HasSlopeFrames[Type] = true; Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; - Main.tileShine2[Type] = true; + Main.tileShine2[Type] = false; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); - DustType = 36; + DustType = DustID.Ash; HitSound = SoundID.Tink; - AddMapEntry(new Color(58, 55, 70)); + AddMapEntry(new Color(77, 75, 86)); MinPick = 110; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); - this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); - this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool CreateDust(int i, int j, ref int type) { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(100, 100, 100), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 100, 100), 1f); return false; } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - frameXOffset = i % 4 * sheetWidth; - frameYOffset = j % 4 * sheetHeight; - } - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - // 02JUN2024: Ozzatron: unclear if this is the correct framing strategy for Basalt return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void RandomUpdate(int i, int j) + { + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, DustID.Smoke, 0f, -1.9069767f, 195, new Color(255, 255, 255), 1f)]; + dust.noGravity = false; + dust.fadeIn = 1.4209302f; + } } } diff --git a/Tiles/SunkenSea/Basalt.png b/Tiles/SunkenSea/Basalt.png index 05a9bf9830..c2285d2254 100644 Binary files a/Tiles/SunkenSea/Basalt.png and b/Tiles/SunkenSea/Basalt.png differ diff --git a/Tiles/SunkenSea/BlackPearlPile.cs b/Tiles/SunkenSea/BlackPearlPile.cs index 0dcf0cfa49..662ec4069e 100644 --- a/Tiles/SunkenSea/BlackPearlPile.cs +++ b/Tiles/SunkenSea/BlackPearlPile.cs @@ -1,5 +1,11 @@ -using CalamityMod.Systems; +using System; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Sounds; +using CalamityMod.Systems; +using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,36 +14,146 @@ namespace CalamityMod.Tiles.SunkenSea { public class BlackPearlPile : ModTile { + public Asset GlintTexture; + public Vector2 GlintDir; + public override void SetStaticDefaults() { + GlintTexture = ModContent.Request("CalamityMod/Tiles/SunkenSea/BlackPearlPile_Glint"); + + GlintDir = new Vector2(1f, -1f); + GlintDir.Normalize(); + Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; TileID.Sets.HasSlopeFrames[Type] = true; + Main.tileLighted[Type] = true; + + Main.tileBlendAll[Type] = true; CalamityUtils.MergeWithGeneral(Type); Main.tileShine[Type] = 3500; Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; - HitSound = SoundID.Shatter; - DustType = 82; - AddMapEntry(new Color(29, 33, 38)); + HitSound = CommonCalamitySounds.VoidstoneMine; + DustType = DustID.Lead; + AddMapEntry(new Color(48, 55, 63)); TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's + + Tile tile = Framing.GetTileSafely(i, j); + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen; + + int frameX = tile.TileFrameX + (i % 1); + int frameY = tile.TileFrameY + (j % 1); + + Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16); + + Vector2 screenPos = position; + + float projection = Vector2.Dot(screenPos, GlintDir); + + // this sets the length between the glints diagonally + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), GlintDir); + + float stripeWidth = 100f; + Color lightColor = Lighting.GetColor(i, j) * 6; + + DrawGlint(screenDiagonalLength * 0.05f); + DrawGlint(screenDiagonalLength * 0.5f); + DrawGlint(screenDiagonalLength * 1.05f); + + void DrawGlint(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f) * 0.4f; + + if (strength > 0f) + { + spriteBatch.Draw(GlintTexture.Value, position, sourceRect, lightColor * strength, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i, j].Get().Flag0) + return; + + // get in-game lighting color at this tile + Color litColor = Lighting.GetColor(i, j); + + // convert to brightness factor (0 = dark, 1 = full bright) + float brightness = (litColor.R + litColor.G + litColor.B) / (3f * 255f); + + // flip it so the glow is strongest in the dark + float darknessFactor = 1f - brightness; + + Vector2 screenPos = new Vector2(i * 16, j * 16) - Main.screenPosition; + float projection = Vector2.Dot(screenPos, GlintDir); + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), GlintDir); + + float stripeWidth = 100f; + float maxStrength = 0f; + + UpdateMaxStrength(screenDiagonalLength * 0.05f); + UpdateMaxStrength(screenDiagonalLength * 0.5f); + UpdateMaxStrength(screenDiagonalLength * 1.05f); + + void UpdateMaxStrength(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f); + if (strength > maxStrength) + maxStrength = strength; + } + + if (maxStrength > 0f) + { + // base intensity scaled by glint strength and darkness + float intensity = 0.6f * maxStrength * (0.5f + darknessFactor * 0.5f); + + r = (67f / 155f) * intensity; + g = (68f / 155f) * intensity; + b = (87f / 155f) * intensity; + } + } } } diff --git a/Tiles/SunkenSea/BlackPearlPile_Glint.png b/Tiles/SunkenSea/BlackPearlPile_Glint.png new file mode 100644 index 0000000000..693c93520c Binary files /dev/null and b/Tiles/SunkenSea/BlackPearlPile_Glint.png differ diff --git a/Tiles/SunkenSea/CyanCoral.cs b/Tiles/SunkenSea/CyanCoral.cs index 962a945c95..cf4d298d76 100644 --- a/Tiles/SunkenSea/CyanCoral.cs +++ b/Tiles/SunkenSea/CyanCoral.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -26,39 +25,32 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Dig; - DustType = 119; - AddMapEntry(new Color(92, 168, 198)); + DustType = DustID.HallowSpray; + AddMapEntry(new Color(109, 190, 221)); Main.tileShine2[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + if (Main.tile[i, j].Get().Flag0) { - float brightness = 0.9f; - Color Color1 = new Color(130, 213, 247); - Color Color2 = new Color(26, 68, 85); - Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); - r = (value.R + value1.R) / 400f; - g = (value.G + value1.G) / 400f; - b = (value.B + value1.B) / 400f; - r *= brightness; - g *= brightness; - b *= brightness; + r = 0.43f; + g = 0.71f; + b = 0.82f; } } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); diff --git a/Tiles/SunkenSea/CyanCoral.png b/Tiles/SunkenSea/CyanCoral.png index 318df78b1c..dedf329ad8 100644 Binary files a/Tiles/SunkenSea/CyanCoral.png and b/Tiles/SunkenSea/CyanCoral.png differ diff --git a/Tiles/SunkenSea/Driftwood.cs b/Tiles/SunkenSea/Driftwood.cs deleted file mode 100644 index d8b24dbb9d..0000000000 --- a/Tiles/SunkenSea/Driftwood.cs +++ /dev/null @@ -1,44 +0,0 @@ -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.GameContent.Metadata; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.SunkenSea -{ - public class Driftwood : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileMergeDirt[Type] = false; - Main.tileBlockLight[Type] = true; - TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Wood"]); - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeDecorativeTiles(Type); - CalamityUtils.MergeWithDesert(Type); - - TileID.Sets.ChecksForMerge[Type] = true; - TileID.Sets.HasSlopeFrames[Type] = true; - HitSound = SoundID.Dig; - DustType = 121; - AddMapEntry(new Color(136, 129, 154)); - - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - - 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 bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); - } - } -} diff --git a/Tiles/SunkenSea/Dunesand.cs b/Tiles/SunkenSea/Dunesand.cs new file mode 100644 index 0000000000..057cdf21d4 --- /dev/null +++ b/Tiles/SunkenSea/Dunesand.cs @@ -0,0 +1,56 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.Metadata; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + [LegacyName("RuneSand")] + public class Dunesand : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + Main.tileShine2[Type] = false; + + DustType = DustID.Hive; + AddMapEntry(new Color(231, 135, 100)); + + Main.tileSand[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); + TileID.Sets.Suffocate[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Conversion.Sand[Type] = true; + TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 10); + + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/Dunesand.png b/Tiles/SunkenSea/Dunesand.png new file mode 100644 index 0000000000..2ff9dbac71 Binary files /dev/null and b/Tiles/SunkenSea/Dunesand.png differ diff --git a/Tiles/SunkenSea/EutrophicCrateTile.cs b/Tiles/SunkenSea/EutrophicCrateTile.cs index 380baf60d4..437abe7e42 100644 --- a/Tiles/SunkenSea/EutrophicCrateTile.cs +++ b/Tiles/SunkenSea/EutrophicCrateTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Fishing.SunkenSeaCatches; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -22,7 +23,7 @@ namespace CalamityMod.Tiles.SunkenSea TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(106, 218, 230), CalamityUtils.GetItemName()); - DustType = 253; + DustType = DustID.TsunamiInABottle; } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/SunkenSea/EutrophicGlass.cs b/Tiles/SunkenSea/EutrophicGlass.cs index 77f47816d1..2a7228fcca 100644 --- a/Tiles/SunkenSea/EutrophicGlass.cs +++ b/Tiles/SunkenSea/EutrophicGlass.cs @@ -1,9 +1,10 @@ -using CalamityMod.Systems; +using System; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea @@ -16,10 +17,21 @@ namespace CalamityMod.Tiles.SunkenSea public static int TypeCache; + public Asset TileTexture; + public Asset GlintTexture; + + public Vector2 GlintDir; + public override void SetStaticDefaults() { TypeCache = Type; + TileTexture = ModContent.Request(Texture + "_Tile"); + GlintTexture = ModContent.Request(Texture + "_Glint"); + + GlintDir = new Vector2(1f, 1f); + GlintDir.Normalize(); + Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = false; CalamityUtils.MergeWithGeneral(Type); @@ -29,7 +41,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileShine2[Type] = false; TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.WallsMergeWith[Type] = true; - DustType = 108; + DustType = DustID.RainCloud; AddMapEntry(new Color(197, 220, 220)); HitSound = SoundID.Shatter; MinPick = 55; @@ -45,14 +57,12 @@ namespace CalamityMod.Tiles.SunkenSea if (Main.tile[i, j].IsTileActuallyInvisible()) return; - float transparency = 0.6f; + float transparency = 0.4f; // Must be set here TileID.Sets.DrawsWalls[Type] = true; Main.tileNoSunLight[Type] = false; - Texture2D tex = ModContent.Request(Texture + "_Tile").Value; - Tile tile = Main.tile[i, j]; int xPos = i % 10; int yPos = j % 10; @@ -61,7 +71,37 @@ namespace CalamityMod.Tiles.SunkenSea Rectangle frame = new Rectangle(tile.TileFrameX + frameXOffset, tile.TileFrameY + frameYOffset, 16, 16); Color color = Lighting.GetColor(i, j) * transparency; - TileFramingSystem.SlopedGlowmask(in tile, i, j, tex, frame, CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, color, false), default); + TileFramingSystem.SlopedGlowmask(in tile, i, j, TileTexture.Value, frame, CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, color, false), default); + + //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's + + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen; + + Vector2 screenPos = position; + + float projection = Vector2.Dot(screenPos, GlintDir); + + // this sets the length between the glints diagonally + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), GlintDir); + + float stripeWidth = 100f; + Color lightColor = Lighting.GetColor(i, j) * 2; + + DrawGlint(screenDiagonalLength * 0.53f); + DrawGlint(screenDiagonalLength * 0.63f); + DrawGlint(screenDiagonalLength * 0.73f); + + void DrawGlint(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f) * 0.4f; + + if (strength > 0f) + { + spriteBatch.Draw(GlintTexture.Value, position, frame, lightColor * strength, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) diff --git a/Tiles/SunkenSea/EutrophicGlass_Glint.png b/Tiles/SunkenSea/EutrophicGlass_Glint.png new file mode 100644 index 0000000000..3b890a78f2 Binary files /dev/null and b/Tiles/SunkenSea/EutrophicGlass_Glint.png differ diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index 9638735706..440d1cbc81 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -1,15 +1,10 @@ -using System.Collections.Generic; -using CalamityMod.Items.Placeables; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; -using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; -using Terraria.ModLoader.UI.ModBrowser; namespace CalamityMod.Tiles.SunkenSea { @@ -21,54 +16,49 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); // Tile blends with sandstone, which it is set to merge with here - Main.tileShine[Type] = 1800; - Main.tileShine2[Type] = true; + Main.tileShine[Type] = 2500; TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - DustType = 108; - AddMapEntry(new Color(158, 203, 234)); + DustType = DustID.Titanium; + AddMapEntry(new Color(157, 183, 206)); - this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); - this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); - this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + Main.tileSand[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); + TileID.Sets.Suffocate[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Conversion.Sand[Type] = true; + TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 5); + + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); } public override void RandomUpdate(int i, int j) { - if (!WorldGen.genRand.NextBool(8)) - return; - Tile tile = Main.tile[i, j]; - if (tile.HasTile || tile.LiquidAmount <= 0) - return; - - if (tile.LeftSlope || tile.RightSlope || tile.IsHalfBlock) - return; - Tile up = Main.tile[i, j - 1]; - if (up.HasTile || up.LiquidAmount <= 0) - return; - Tile up2 = Main.tile[i, j - 2]; - if (up2.HasTile || up2.LiquidAmount <= 0) - return; - // Place corals - if (WorldGen.genRand.NextBool(3)) + // Place sunken kelp + if (WorldGen.genRand.NextBool(2) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) { - up.TileType = (ushort)ModContent.TileType(); + up.TileType = (ushort)ModContent.TileType(); up.HasTile = true; - up.TileFrameY = 0; - // 15 different frames, choose a random one - up.TileFrameX = (short)(WorldGen.genRand.Next(15) * 18); WorldGen.SquareTileFrame(i, j - 1, true); if (Main.dedServ) @@ -76,58 +66,6 @@ namespace CalamityMod.Tiles.SunkenSea NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); } } - - //multi-colored corals - if (WorldGen.genRand.NextBool(3)) - { - ushort[] ColoredCorals = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(ColoredCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } - - //blue coral trees - if (WorldGen.genRand.NextBool(6)) - { - ushort[] BlueCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(BlueCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } - - //brown coral trees - if (WorldGen.genRand.NextBool(6)) - { - ushort[] BrownCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(BrownCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } - - //fan coral - if (WorldGen.genRand.NextBool(10)) - { - WorldGen.PlaceObject(i, j - 1, (ushort)ModContent.TileType()); - } - - //misc corals - if (WorldGen.genRand.NextBool()) - { - ushort[] MiscCorals = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(MiscCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } } public override void NumDust(int i, int j, bool fail, ref int num) @@ -137,7 +75,7 @@ namespace CalamityMod.Tiles.SunkenSea public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - return TileFramingSystem.BrimstoneFraming(i, j, resetFrame); + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } } } diff --git a/Tiles/SunkenSea/EutrophicSand.png b/Tiles/SunkenSea/EutrophicSand.png index 7561c14ec6..0e4be4e4ad 100644 Binary files a/Tiles/SunkenSea/EutrophicSand.png and b/Tiles/SunkenSea/EutrophicSand.png differ diff --git a/Tiles/SunkenSea/HardenedEutrophicSand.cs b/Tiles/SunkenSea/HardenedEutrophicSand.cs index ce710bc265..be7b2020d3 100644 --- a/Tiles/SunkenSea/HardenedEutrophicSand.cs +++ b/Tiles/SunkenSea/HardenedEutrophicSand.cs @@ -1,12 +1,8 @@ -using System.Collections.Generic; -using CalamityMod.Items.Placeables; -using CalamityMod.Systems; +using CalamityMod.Systems; using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea @@ -17,24 +13,25 @@ namespace CalamityMod.Tiles.SunkenSea { Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); - Main.tileShine[Type] = 1800; + Main.tileShine[Type] = 2500; Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - DustType = 108; - AddMapEntry(new Color(61, 151, 194)); + DustType = DustID.Titanium; + AddMapEntry(new Color(66, 162, 209)); - 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"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.HardenedSand); + this.RegisterBlendMergeWith(TileID.Sand); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -44,7 +41,7 @@ namespace CalamityMod.Tiles.SunkenSea public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - return TileFramingSystem.BrimstoneFraming(i, j, resetFrame); + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } public override void RandomUpdate(int i, int j) @@ -55,17 +52,6 @@ namespace CalamityMod.Tiles.SunkenSea if (!up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) { - //brain corals - if (WorldGen.genRand.NextBool(18)) - { - ushort[] BrainCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - ushort newObject = Main.rand.Next(BrainCorals); - - WorldGen.PlaceObject(i, j - 1, newObject, true); - NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); - } - //tube corals if (WorldGen.genRand.NextBool(8)) { @@ -84,6 +70,20 @@ namespace CalamityMod.Tiles.SunkenSea NetMessage.SendObjectPlacement(-1, i, j - 1, (ushort)ModContent.TileType(), 0, 0, -1, -1); } } + + // Place sunken kelp + if (WorldGen.genRand.NextBool(2) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + { + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; + + WorldGen.SquareTileFrame(i, j - 1, true); + + if (Main.dedServ) + { + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } + } } } } diff --git a/Tiles/SunkenSea/HardenedEutrophicSand.png b/Tiles/SunkenSea/HardenedEutrophicSand.png index 5f80ec3a45..f0dfb21ae8 100644 Binary files a/Tiles/SunkenSea/HardenedEutrophicSand.png and b/Tiles/SunkenSea/HardenedEutrophicSand.png differ diff --git a/Tiles/SunkenSea/LimeCoral.cs b/Tiles/SunkenSea/LimeCoral.cs index b4536f301a..54b89dc6fc 100644 --- a/Tiles/SunkenSea/LimeCoral.cs +++ b/Tiles/SunkenSea/LimeCoral.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -21,38 +20,32 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Dig; - DustType = 119; - AddMapEntry(new Color(139, 206, 56)); + DustType = DustID.Terra; + AddMapEntry(new Color(176, 242, 96)); Main.tileShine2[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + if (Main.tile[i, j].Get().Flag0) { - float brightness = 0.9f; - Color Color1 = new Color(176, 242, 96); - Color Color2 = new Color(82, 113, 29); - Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); - r = (value.R + value1.R) / 300f; - g = (value.G + value1.G) / 300f; - b = (value.B + value1.B) / 300f; - r *= brightness; - g *= brightness; - b *= brightness; + r = 139f / 255f; + g = 206f / 255f; + b = 56f / 255f; } } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); diff --git a/Tiles/SunkenSea/LimeCoral.png b/Tiles/SunkenSea/LimeCoral.png index b7fb07b8d0..fb914d3a3b 100644 Binary files a/Tiles/SunkenSea/LimeCoral.png and b/Tiles/SunkenSea/LimeCoral.png differ diff --git a/Tiles/SunkenSea/Limestone.cs b/Tiles/SunkenSea/Limestone.cs index 2b154ba374..40bceca360 100644 --- a/Tiles/SunkenSea/Limestone.cs +++ b/Tiles/SunkenSea/Limestone.cs @@ -1,4 +1,5 @@ using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -19,21 +20,53 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Tink; - DustType = 22; - AddMapEntry(new Color(154, 119, 119)); + DustType = DustID.Pot; + AddMapEntry(new Color(184, 138, 113)); - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void RandomUpdate(int i, int j) + { + Tile Tile = Framing.GetTileSafely(i, j); + Tile Below = Framing.GetTileSafely(i, j + 1); + Tile Above = Framing.GetTileSafely(i, j - 1); + + if (!Below.HasTile && Below.LiquidType <= LiquidID.Water && !Tile.BottomSlope) + { + if (Main.rand.NextBool(10)) + { + Below.TileType = (ushort)ModContent.TileType(); + Below.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.dedServ) + { + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } } } diff --git a/Tiles/SunkenSea/Limestone.png b/Tiles/SunkenSea/Limestone.png index 8663309de3..1ff28b15d7 100644 Binary files a/Tiles/SunkenSea/Limestone.png and b/Tiles/SunkenSea/Limestone.png differ diff --git a/Tiles/SunkenSea/LimestoneCobble.cs b/Tiles/SunkenSea/LimestoneCobble.cs new file mode 100644 index 0000000000..33cc218d22 --- /dev/null +++ b/Tiles/SunkenSea/LimestoneCobble.cs @@ -0,0 +1,51 @@ +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class LimestoneCobble : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Tink; + DustType = DustID.Pot; + AddMapEntry(new Color(200, 120, 101)); + + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/LimestoneCobble.png b/Tiles/SunkenSea/LimestoneCobble.png new file mode 100644 index 0000000000..8663309de3 Binary files /dev/null and b/Tiles/SunkenSea/LimestoneCobble.png differ diff --git a/Tiles/SunkenSea/MagentaCoral.cs b/Tiles/SunkenSea/MagentaCoral.cs index 85794d1b39..3628780e06 100644 --- a/Tiles/SunkenSea/MagentaCoral.cs +++ b/Tiles/SunkenSea/MagentaCoral.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -26,38 +25,32 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Dig; - DustType = 119; - AddMapEntry(new Color(206, 56, 123)); + DustType = DustID.Ice_Pink; + AddMapEntry(new Color(253, 112, 186)); Main.tileShine2[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + if (Main.tile[i, j].Get().Flag0) { - float brightness = 0.9f; - Color Color1 = new Color(242, 96, 161); - Color Color2 = new Color(156, 51, 83); - Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); - r = (value.R + value1.R) / 300f; - g = (value.G + value1.G) / 300f; - b = (value.B + value1.B) / 300f; - r *= brightness; - g *= brightness; - b *= brightness; + r = 0.81f; + g = 0.32f; + b = 0.54f; } } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); diff --git a/Tiles/SunkenSea/MagentaCoral.png b/Tiles/SunkenSea/MagentaCoral.png index e02ef96fce..83ac873383 100644 Binary files a/Tiles/SunkenSea/MagentaCoral.png and b/Tiles/SunkenSea/MagentaCoral.png differ diff --git a/Tiles/SunkenSea/MediumSeaPrismCrystal.png b/Tiles/SunkenSea/MediumSeaPrismCrystal.png new file mode 100644 index 0000000000..ceef890ebe Binary files /dev/null and b/Tiles/SunkenSea/MediumSeaPrismCrystal.png differ diff --git a/Tiles/SunkenSea/MediumSeaPrismCrystal_Blue.png b/Tiles/SunkenSea/MediumSeaPrismCrystal_Blue.png new file mode 100644 index 0000000000..ceef890ebe Binary files /dev/null and b/Tiles/SunkenSea/MediumSeaPrismCrystal_Blue.png differ diff --git a/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint.png b/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint.png new file mode 100644 index 0000000000..4667f80b89 Binary files /dev/null and b/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint.png differ diff --git a/Tiles/SunkenSea/MediumSeaPrismCrystal_Green.png b/Tiles/SunkenSea/MediumSeaPrismCrystal_Green.png new file mode 100644 index 0000000000..e10cc3ce4f Binary files /dev/null and b/Tiles/SunkenSea/MediumSeaPrismCrystal_Green.png differ diff --git a/Tiles/SunkenSea/MediumSeaPrismCrystal_Purple.png b/Tiles/SunkenSea/MediumSeaPrismCrystal_Purple.png new file mode 100644 index 0000000000..b0d2462bd5 Binary files /dev/null and b/Tiles/SunkenSea/MediumSeaPrismCrystal_Purple.png differ diff --git a/Tiles/SunkenSea/Mire.cs b/Tiles/SunkenSea/Mire.cs new file mode 100644 index 0000000000..73e152e515 --- /dev/null +++ b/Tiles/SunkenSea/Mire.cs @@ -0,0 +1,54 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class Mire : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + Main.tileShine2[Type] = false; + + DustType = DustID.Hive; + AddMapEntry(new Color(71, 38, 30)); + + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/SunkenSea/Mire.png b/Tiles/SunkenSea/Mire.png new file mode 100644 index 0000000000..52e651c89f Binary files /dev/null and b/Tiles/SunkenSea/Mire.png differ diff --git a/Tiles/SunkenSea/MossyStone.cs b/Tiles/SunkenSea/MossyStone.cs new file mode 100644 index 0000000000..0280ef8913 --- /dev/null +++ b/Tiles/SunkenSea/MossyStone.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class MossyStone : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Tink; + DustType = DustID.GreenMoss; + AddMapEntry(new Color(124, 126, 127)); + + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); + } + } +} diff --git a/Tiles/SunkenSea/MossyStone.png b/Tiles/SunkenSea/MossyStone.png new file mode 100644 index 0000000000..4d549b1b57 Binary files /dev/null and b/Tiles/SunkenSea/MossyStone.png differ diff --git a/Tiles/SunkenSea/NavyPrismTorch.cs b/Tiles/SunkenSea/NavyPrismTorch.cs index db44eff724..38c06626f0 100644 --- a/Tiles/SunkenSea/NavyPrismTorch.cs +++ b/Tiles/SunkenSea/NavyPrismTorch.cs @@ -1,15 +1,17 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { public class NavyPrismTorch : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); public override bool CreateDust(int i, int j, ref int type) @@ -55,18 +57,19 @@ namespace CalamityMod.Tiles.SunkenSea public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/SunkenSea/NavyPrismTorchFlame").Value, i, j, 2); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/SunkenSea/NavyPrismTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) { if (Main.tile[i, j].TileFrameX < 66) - CalamityUtils.DrawFlameSparks(59, 5, i, j); + CalamityUtils.DrawFlameSparks(DustID.BlueTorch, 5, i, j); } public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } diff --git a/Tiles/SunkenSea/Navystone.cs b/Tiles/SunkenSea/Navystone.cs index d982d24e92..b4243dd14c 100644 --- a/Tiles/SunkenSea/Navystone.cs +++ b/Tiles/SunkenSea/Navystone.cs @@ -15,20 +15,20 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); - Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; - DustType = 96; - AddMapEntry(new Color(17, 53, 77)); + DustType = DustID.BlueMoss; + AddMapEntry(new Color(28, 72, 96)); HitSound = SoundID.Tink; - 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"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.SunkenSea public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - return TileFramingSystem.BrimstoneFraming(i, j, resetFrame); + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } public override void RandomUpdate(int i, int j) @@ -47,14 +47,14 @@ namespace CalamityMod.Tiles.SunkenSea Tile Below = Framing.GetTileSafely(i, j + 1); Tile Above = Framing.GetTileSafely(i, j - 1); - if (!Below.HasTile && Below.LiquidType <= 0 && !Tile.BottomSlope) + if (!Below.HasTile && Below.LiquidType <= LiquidID.Water && !Tile.BottomSlope) { if (Main.rand.NextBool(10)) { Below.TileType = (ushort)ModContent.TileType(); Below.HasTile = true; WorldGen.SquareTileFrame(i, j + 1, true); - if (Main.dedServ) + if (Main.dedServ) { NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); } diff --git a/Tiles/SunkenSea/Navystone.png b/Tiles/SunkenSea/Navystone.png index d81a8b93bb..a0cc7f0beb 100644 Binary files a/Tiles/SunkenSea/Navystone.png and b/Tiles/SunkenSea/Navystone.png differ diff --git a/Tiles/SunkenSea/OrangeCoral.cs b/Tiles/SunkenSea/OrangeCoral.cs index d1b7a8e2e4..119864238f 100644 --- a/Tiles/SunkenSea/OrangeCoral.cs +++ b/Tiles/SunkenSea/OrangeCoral.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -21,38 +20,32 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Dig; - DustType = 119; - AddMapEntry(Color.Orange); + DustType = DustID.Pixie; + AddMapEntry(new Color(255, 144, 63)); Main.tileShine2[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + if (Main.tile[i, j].Get().Flag0) { - float brightness = 0.9f; - Color Color1 = new Color(255, 177, 120); - Color Color2 = new Color(117, 23, 44); - Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); - r = (value.R + value1.R) / 300f; - g = (value.G + value1.G) / 300f; - b = (value.B + value1.B) / 300f; - r *= brightness; - g *= brightness; - b *= brightness; + r = 0.92f; + g = 0.62f; + b = 0.42f; } } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); diff --git a/Tiles/SunkenSea/PinkPearlPile.cs b/Tiles/SunkenSea/PinkPearlPile.cs index 3bafcf5afb..eef4ebe6ce 100644 --- a/Tiles/SunkenSea/PinkPearlPile.cs +++ b/Tiles/SunkenSea/PinkPearlPile.cs @@ -1,5 +1,11 @@ -using CalamityMod.Systems; +using System; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Sounds; +using CalamityMod.Systems; +using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,36 +14,154 @@ namespace CalamityMod.Tiles.SunkenSea { public class PinkPearlPile : ModTile { + public Asset GlintTexture; + + public Vector2 GlintDir; + public override void SetStaticDefaults() { + GlintTexture = ModContent.Request(Texture + "_Glint"); + + GlintDir = new Vector2(1f, -1f); + GlintDir.Normalize(); + Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + Main.tileLighted[Type] = true; CalamityUtils.MergeWithGeneral(Type); TileID.Sets.HasSlopeFrames[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; - HitSound = SoundID.Shatter; - DustType = 119; + HitSound = CommonCalamitySounds.VoidstoneMine; + DustType = DustID.Ice_Pink; AddMapEntry(new Color(204, 143, 174)); Main.tileShine[Type] = 3500; Main.tileShine2[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's + + Tile tile = Framing.GetTileSafely(i, j); + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen; + + int frameX = tile.TileFrameX + (i % 1); + int frameY = tile.TileFrameY + (j % 1); + + Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16); + + + Texture2D GlintTex = GlintTexture.Value; + + Vector2 glintDir = new Vector2(1f, -1f); + glintDir.Normalize(); + + Vector2 screenPos = position; + + float projection = Vector2.Dot(screenPos, glintDir); + + // this sets the length between the glints diagonally + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir); + + float stripeWidth = 100f; + Color lightColor = Lighting.GetColor(i, j) * 6; + + DrawGlint(screenDiagonalLength * 0.05f); + DrawGlint(screenDiagonalLength * 0.5f); + DrawGlint(screenDiagonalLength * 1.05f); + + void DrawGlint(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f) * 0.4f; + + if (strength > 0f) + { + spriteBatch.Draw(GlintTexture.Value, position, sourceRect, lightColor * strength, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i, j].Get().Flag0) + return; + + // get in-game lighting color at this tile + Color litColor = Lighting.GetColor(i, j); + + // convert to brightness factor (0 = dark, 1 = full bright) + float brightness = (litColor.R + litColor.G + litColor.B) / (3f * 255f); + + // flip it so the glow is strongest in the dark + float darknessFactor = 1f - brightness; + + // diagonal glint math + Vector2 glintDir = new Vector2(1f, -1f); + glintDir.Normalize(); + + Vector2 screenPos = new Vector2(i * 16, j * 16) - Main.screenPosition; + float projection = Vector2.Dot(screenPos, glintDir); + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir); + + float stripeWidth = 100f; + float maxStrength = 0f; + + UpdateMaxStrength(screenDiagonalLength * 0.05f); + UpdateMaxStrength(screenDiagonalLength * 0.5f); + UpdateMaxStrength(screenDiagonalLength * 1.05f); + + void UpdateMaxStrength(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f); + if (strength > maxStrength) + maxStrength = strength; + } + + if (maxStrength > 0f) + { + // base intensity scaled by glint strength and darkness + float intensity = 0.6f * maxStrength * (0.5f + darknessFactor * 0.5f); + + r = (172f / 255f) * intensity; + g = (112f / 255f) * intensity; + b = (145f / 255f) * intensity; + } + } + } } diff --git a/Tiles/SunkenSea/PinkPearlPile_Glint.png b/Tiles/SunkenSea/PinkPearlPile_Glint.png new file mode 100644 index 0000000000..bd5253d1eb Binary files /dev/null and b/Tiles/SunkenSea/PinkPearlPile_Glint.png differ diff --git a/Tiles/SunkenSea/PolishedNavystoneBrick.cs b/Tiles/SunkenSea/PolishedNavystoneBrick.cs deleted file mode 100644 index 9331d479ab..0000000000 --- a/Tiles/SunkenSea/PolishedNavystoneBrick.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -using Terraria.ID; -using CalamityMod.Systems; - -namespace CalamityMod.Tiles.SunkenSea -{ - public class PolishedNavystoneBrick : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - CalamityUtils.MergeWithGeneral(Type); - TileID.Sets.HasSlopeFrames[Type] = true; - - HitSound = SoundID.Tink; - DustType = 96; - AddMapEntry(new Color(53, 99, 117)); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); - } - } -} diff --git a/Tiles/SunkenSea/PolypSand.cs b/Tiles/SunkenSea/PolypSand.cs index 8f819b128d..3d8c709b30 100644 --- a/Tiles/SunkenSea/PolypSand.cs +++ b/Tiles/SunkenSea/PolypSand.cs @@ -1,9 +1,13 @@ -using CalamityMod.Systems; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; + + namespace CalamityMod.Tiles.SunkenSea { public class PolypSand : ModTile @@ -13,7 +17,7 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.GeneralPlacementTiles[Type] = false; Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; + Main.tileBlockLight[Type] = false; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); @@ -21,14 +25,23 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.HasSlopeFrames[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - Main.tileShine2[Type] = true; - DustType = 147; - AddMapEntry(new Color(221, 180, 182)); + DustType = DustID.Ice_Red; + AddMapEntry(new Color(215, 170, 170)); - this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); - this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); - this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + Main.tileSand[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); + TileID.Sets.Suffocate[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Conversion.Sand[Type] = true; + TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 10); + + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/SunkenSea/PrismCrateTile.cs b/Tiles/SunkenSea/PrismCrateTile.cs index 6895b56eaa..963eb0fa8f 100644 --- a/Tiles/SunkenSea/PrismCrateTile.cs +++ b/Tiles/SunkenSea/PrismCrateTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Fishing.SunkenSeaCatches; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -21,7 +22,7 @@ namespace CalamityMod.Tiles.SunkenSea TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.addTile(Type); AddMapEntry(new Color(145, 240, 255), CalamityUtils.GetItemName()); - DustType = 253; + DustType = DustID.TsunamiInABottle; } public override void NumDust(int i, int j, bool fail, ref int num) diff --git a/Tiles/SunkenSea/RefractivePrismTorch.cs b/Tiles/SunkenSea/RefractivePrismTorch.cs index e0e3d784e4..e603ff325c 100644 --- a/Tiles/SunkenSea/RefractivePrismTorch.cs +++ b/Tiles/SunkenSea/RefractivePrismTorch.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -9,6 +10,8 @@ namespace CalamityMod.Tiles.SunkenSea { public class RefractivePrismTorch : ModTile { + public Asset FlameTexture; + public override void SetStaticDefaults() => this.SetUpTorch(ModContent.ItemType(), true, true); public override bool CreateDust(int i, int j, ref int type) @@ -56,18 +59,19 @@ namespace CalamityMod.Tiles.SunkenSea public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { - CalamityUtils.DrawFlameEffect(ModContent.Request("CalamityMod/Tiles/SunkenSea/RefractivePrismTorchFlame").Value, i, j, 2); + FlameTexture ??= ModContent.Request("CalamityMod/Tiles/SunkenSea/RefractivePrismTorchFlame"); + CalamityUtils.DrawFlameEffect(FlameTexture.Value, i, j, 2); } public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) { if (Main.tile[i, j].TileFrameX < 66) - CalamityUtils.DrawFlameSparks(62, 5, i, j); + CalamityUtils.DrawFlameSparks(DustID.PurpleTorch, 5, i, j); } public override bool RightClick(int i, int j) { - CalamityUtils.RightClickBreak(i, j); + FurnitureCommon.RightClickBreak(i, j); return true; } diff --git a/Tiles/SunkenSea/RuneSand.cs b/Tiles/SunkenSea/RuneSand.cs deleted file mode 100644 index 41e23b8165..0000000000 --- a/Tiles/SunkenSea/RuneSand.cs +++ /dev/null @@ -1,44 +0,0 @@ -using CalamityMod.Systems; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.SunkenSea -{ - public class RuneSand : ModTile - { - public override void SetStaticDefaults() - { - TileID.Sets.GeneralPlacementTiles[Type] = false; - - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - - CalamityUtils.MergeWithGeneral(Type); - CalamityUtils.MergeWithDesert(Type); - - TileID.Sets.HasSlopeFrames[Type] = true; - TileID.Sets.ChecksForMerge[Type] = true; - TileID.Sets.CanBeDugByShovel[Type] = true; - Main.tileShine2[Type] = true; - - DustType = 147; - AddMapEntry(new Color(210, 124, 45)); - - 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) - { - num = fail ? 1 : 3; - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); - } - } -} diff --git a/Tiles/SunkenSea/RuneSand.png b/Tiles/SunkenSea/RuneSand.png deleted file mode 100644 index 06514fde68..0000000000 Binary files a/Tiles/SunkenSea/RuneSand.png and /dev/null differ diff --git a/Tiles/SunkenSea/Runestone.cs b/Tiles/SunkenSea/Runestone.cs index dc2d5cbcb6..47d2caf58f 100644 --- a/Tiles/SunkenSea/Runestone.cs +++ b/Tiles/SunkenSea/Runestone.cs @@ -21,19 +21,33 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Tink; - DustType = 22; - AddMapEntry(new Color(152, 89, 78)); - Main.tileShine2[Type] = true; + DustType = DustID.Pot; + AddMapEntry(new Color(162, 98, 85)); + Main.tileShine2[Type] = false; TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) diff --git a/Tiles/SunkenSea/Runestone.png b/Tiles/SunkenSea/Runestone.png index 610bdefa21..b247e5fac6 100644 Binary files a/Tiles/SunkenSea/Runestone.png and b/Tiles/SunkenSea/Runestone.png differ diff --git a/Tiles/SunkenSea/ScarletSeaGrass.png b/Tiles/SunkenSea/ScarletSeaGrass.png new file mode 100644 index 0000000000..4054602dfb Binary files /dev/null and b/Tiles/SunkenSea/ScarletSeaGrass.png differ diff --git a/Tiles/SunkenSea/ScarletSeaGrassTile.cs b/Tiles/SunkenSea/ScarletSeaGrassTile.cs new file mode 100644 index 0000000000..d74ca24d85 --- /dev/null +++ b/Tiles/SunkenSea/ScarletSeaGrassTile.cs @@ -0,0 +1,304 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea.Ambient; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent.Metadata; +using Terraria.ID; +using Terraria.ModLoader; + + + +namespace CalamityMod.Tiles.SunkenSea +{ + public class ScarletSeaGrassTile : ModTile + { + public enum ExtraState + { + Middle = 36, + OverhangLeft = 18, + OverhangRight = 54, + WallEndLeft = 0, + WallEndRight = 72 + } + + public Asset GrassTexture; + + private int extraFrameHeight = 36; + private int extraFrameWidth = 90; + public override void SetStaticDefaults() + { + GrassTexture = ModContent.Request("CalamityMod/Tiles/SunkenSea/ScarletSeaGrass"); + + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileLighted[Type] = true; + Main.tileBlockLight[Type] = false; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + + DustType = DustID.Hive; + AddMapEntry(new Color(216, 50, 50)); + + Main.tileSand[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); + TileID.Sets.Suffocate[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Conversion.Sand[Type] = true; + TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); + + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type || + Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type) + { + Main.tile[i, j].Get().HasSpecialPoint = true; + } + else + { + Main.tile[i, j].Get().HasSpecialPoint = false; + } + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].Get().HasSpecialPoint) + { + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); + } + } + + public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) + { + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; + Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Lighting.GetColor(i, j)); + Texture2D leaves = GrassTexture.Value; + + DrawExtraTop(i, j, leaves, drawOffset, drawColour); + DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour); + DrawExtraDrapes(i, j, leaves, drawOffset, drawColour); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.3f; + g = 0f; + b = 0.1f; + } + + public override void RandomUpdate(int i, int j) + { + Tile tile = Main.tile[i, j]; + Tile up = Main.tile[i, j - 1]; + Tile up2 = Main.tile[i, j - 2]; + + // Place LongScarletSeagrass + if (WorldGen.genRand.NextBool(1) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + { + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; + up.TileFrameY = 0; + + // 16 different frames, choose a random one + up.TileFrameX = (short)(WorldGen.genRand.Next(16) * 18); + WorldGen.SquareTileFrame(i, j - 1, true); + + if (Main.dedServ) + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } + } + + #region 'Extra Drapes' Drawing + private void DrawExtraTop(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + If the tile directly above this tile is not otherworldly stone, or if it is, there is air to both sides of that tile, draw the Extra surface + */ + if ( + CheckTile(Type, false, 0, 1, i, j) || + (CheckTile(Type, true, 0, 1, i, j) && CheckTile(Type, false, 1, 1, i, j) && CheckTile(Type, false, -1, 1, i, j) && CheckTile(Type, true, 1, 0, i, j) && CheckTile(Type, true, -1, 0, i, j)) + ) + { + var x = GetExtraState(ExtraState.Middle) + GetExtraVariant(i, j); + var y = GetExtraPattern(i); + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle(x, y + 18, 18, 18), drawColour); + + DrawExtraOverhang(i, j, extras, drawOffset, drawColour); + } + } + private bool CheckTile(int type, bool equal, int x, int y, int i, int j) + { + //Subtract y so that y is vertical for ease of readability + return Main.tile[i + x, j - y].TileType == type == equal; + } + private void DrawExtraWallEnds(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Ending the Extra when a wall is reached + */ + + //Left + if ( + CheckTile(Type, true, 1, 0, i, j) && CheckTile(Type, false, 1, 1, i, j) && CheckTile(Type, true, 0, 1, i, j) && + (CheckTile(Type, true, -1, 1, i, j) || CheckTile(Type, false, -1, 0, i, j)) + ) + { + var x = GetExtraState(ExtraState.WallEndLeft) + GetExtraVariant(i + 1, j); + var y = GetExtraPattern(i); + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle(x, y + 18, 18, 18), drawColour); + } + //Right + if ( + CheckTile(Type, true, -1, 0, i, j) && CheckTile(Type, false, -1, 1, i, j) && CheckTile(Type, true, 0, 1, i, j) && + (CheckTile(Type, true, 1, 1, i, j) || CheckTile(Type, false, 1, 0, i, j)) + ) + { + var x = GetExtraState(ExtraState.WallEndRight) + GetExtraVariant(i - 1, j); + var y = GetExtraPattern(i); + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle(x, y + 18, 18, 18), drawColour); + } + } + private void DrawExtraOverhang(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Called from DrawExtraTop(). Ending the Extra when the edge of the tile is reached + */ + + //Left + if ( + CheckTile(Type, false, -1, 0, i, j) + ) + { + var x = GetExtraState(ExtraState.OverhangLeft) + GetExtraVariant(i, j); + var y = GetExtraPattern(i - 1); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(-16f, 0f), new Rectangle(x, y, 18, 18), drawColour); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(-16f, 16f), new Rectangle(x, y + 18, 18, 18), drawColour); + } + //Right + if ( + CheckTile(Type, false, 1, 0, i, j) + ) + { + var x = GetExtraState(ExtraState.OverhangRight) + GetExtraVariant(i, j); + var y = GetExtraPattern(i + 1); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(16f, 0f), new Rectangle(x, y, 18, 18), drawColour); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(16f, 16f), new Rectangle(x, y + 18, 18, 18), drawColour); + } + } + + private void DrawExtraDrapes(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Hanging 'drapes' of the extra element + */ + + //Base + if ( + (CheckTile(Type, true, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j)) || + (CheckTile(Type, true, 0, 2, i, j) && CheckTile(Type, false, 1, 2, i, j) && CheckTile(Type, false, -1, 2, i, j) && CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, true, -1, 1, i, j)) + ) + { + var x = GetExtraState(ExtraState.Middle) + GetExtraVariant(i, j - 1); + var y = GetExtraPattern(i) + 18; + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + } + //Left Wall + if ( + CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, false, 1, 2, i, j) && CheckTile(Type, true, 0, 2, i, j) && + (CheckTile(Type, true, -1, 2, i, j) || CheckTile(Type, false, -1, 1, i, j)) + ) + { + var x = GetExtraState(ExtraState.WallEndLeft) + GetExtraVariant(i + 1, j - 1); + var y = GetExtraPattern(i) + 18; + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + } + //Right Wall + if ( + CheckTile(Type, true, -1, 1, i, j) && CheckTile(Type, false, -1, 2, i, j) && CheckTile(Type, true, 0, 2, i, j) && + (CheckTile(Type, true, 1, 2, i, j) || CheckTile(Type, false, 1, 1, i, j)) + ) + { + var x = GetExtraState(ExtraState.WallEndRight) + GetExtraVariant(i - 1, j - 1); + var y = GetExtraPattern(i) + 18; + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + } + //Left Overhang + if ( + CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, false, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j) && CheckTile(Type, false, 1, 2, i, j) + ) + { + var x = GetExtraState(ExtraState.OverhangLeft) + GetExtraVariant(i + 1, j - 1); + var y = GetExtraPattern(i) + 18; + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + } + //Right Overhang + if ( + CheckTile(Type, true, -1, 1, i, j) && CheckTile(Type, false, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j) && CheckTile(Type, false, -1, 2, i, j) + ) + { + var x = GetExtraState(ExtraState.OverhangRight) + GetExtraVariant(i - 1, j - 1); + var y = GetExtraPattern(i) + 18; + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle(x, y, 18, 18), drawColour); + } + } + + private int GetExtraState(ExtraState type) + { + switch (type) + { + case ExtraState.Middle: + case ExtraState.WallEndLeft: + case ExtraState.WallEndRight: + case ExtraState.OverhangLeft: + case ExtraState.OverhangRight: + return (int)type; // Funni Trick + + default: + Main.NewText(type.ToString() + " is not a valid Extra sheet state"); + return 0; + } + } + + private int GetExtraPattern(int i) + { + return i % 3 * extraFrameHeight; + } + + private int GetExtraVariant(int i, int j) + { + return Main.tile[i, j].TileFrameNumber * extraFrameWidth; + } + } +} +#endregion diff --git a/Tiles/SunkenSea/ScarletSeaGrassTile.png b/Tiles/SunkenSea/ScarletSeaGrassTile.png new file mode 100644 index 0000000000..561c962c9e Binary files /dev/null and b/Tiles/SunkenSea/ScarletSeaGrassTile.png differ diff --git a/Tiles/SunkenSea/SeaPrism.cs b/Tiles/SunkenSea/SeaPrism.cs index e588164a13..0539abd2f6 100644 --- a/Tiles/SunkenSea/SeaPrism.cs +++ b/Tiles/SunkenSea/SeaPrism.cs @@ -1,36 +1,58 @@ using System; +using CalamityMod.Effects; +using CalamityMod.Items.Placeables.SunkenSea; using CalamityMod.Systems; +using CalamityMod.Walls; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ObjectData; namespace CalamityMod.Tiles.SunkenSea { public class SeaPrism : ModTile { - private const short subsheetWidth = 450; - private const short subsheetHeight = 198; - + internal const short subsheetWidth = 468; + internal const short subsheetHeight = 90; + + internal static Asset Blue; + internal static Asset Purple; + internal static Asset Green; + internal static Asset Glint; + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; + Main.tileBlockLight[Type] = false; + TileID.Sets.HasSlopeFrames[Type] = true; + Main.tileMerge[Type][ModContent.TileType()] = true; + + Main.tileMerge[Type][ModContent.TileType()] = true; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); Main.tileLighted[Type] = true; - Main.tileShine[Type] = 3500; Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; - DustType = 33; + DustType = DustID.Water; AddMapEntry(new Color(97, 212, 223)); HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; MinPick = 55; - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + + Blue = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrism_Blue"); + Purple = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrism_Purple"); + Green = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrism_Green"); + Glint = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrism_GlintMask"); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -40,28 +62,566 @@ namespace CalamityMod.Tiles.SunkenSea public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) { - // (i & 0b0001) = (i % 2) - frameXOffset = (i & 0b0001) * subsheetWidth; - frameYOffset = (j & 0b0001) * subsheetHeight; + frameXOffset = i % 8 * subsheetWidth; + frameYOffset = j % 8 * subsheetHeight; } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - float brightness = 0.9f; - Color blue = new Color(67, 187, 204); - Color darkviolet = new Color(18, 67, 116); - Color value = Color.Lerp(blue, darkviolet, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(blue, darkviolet, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); - r = (value.R + value1.R) / 900f; - g = (value.G + value1.G) / 900f; - b = (value.B + value1.B) / 900f; - r *= brightness; - g *= brightness; - b *= brightness; + float fade1 = GetFade1(i, j); + float fade2 = GetFade2(i, j); + + Color baseColor = new Color(162, 216, 218); //Blue + Color glow1 = new Color(171, 113, 215); //Purple + Color glow2 = new Color(56, 174, 117); //Green + + Vector3 blended = baseColor.ToVector3(); + + blended = Vector3.Lerp(blended, glow1.ToVector3(), fade1 * 0.5f); + blended = Vector3.Lerp(blended, glow2.ToVector3(), fade2 * 0.5f); + + float brightness = 0.6f; + blended *= brightness; + + r = blended.X; + g = blended.Y; + b = blended.Z; } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { - return TileFramingSystem.BrimstoneFraming(i, j, resetFrame); + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + + internal static float GetFade1(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f; + + internal static float GetFade2(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f; + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false; + } + + public class SeaPrismWall : MultiVariantModWall + { + public override string Texture => "CalamityMod/Walls/SeaPrismWall"; + + internal static FramedMaskTexture GlowMaskBlue; + internal static FramedMaskTexture GlowMaskPurple; + internal static FramedMaskTexture GlowMaskGreen; + public override void SetStaticDefaults() + { + GlowMaskBlue = new("CalamityMod/Walls/SeaPrismWall_Blue", 36, 36); + GlowMaskPurple = new("CalamityMod/Walls/SeaPrismWall_Purple", 36, 36); + GlowMaskGreen = new("CalamityMod/Walls/SeaPrismWall_Green", 36, 36); + Main.wallHouse[Type] = true; + DustType = DustID.RainCloud; + + AddMapEntry(new Color(27, 123, 131)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 8) * 468; + frameYOffset = (j % 8) * 180; + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false; + } + + public class UnsafeSeaPrismWall : MultiVariantModWall + { + public override string Texture => "CalamityMod/Walls/SeaPrismWall"; + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + DustType = DustID.RainCloud; + + AddMapEntry(new Color(27, 123, 131)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 8) * 468; + frameYOffset = (j % 8) * 180; + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false; + + public override bool Drop(int i, int j, ref int type) => false; + } + + public class SeaPrismCrystals : ModTile + { + internal static Asset BlueCrystals; + internal static Asset PurpleCrystals; + internal static Asset GreenCrystals; + internal static Asset Glint; + + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileObsidianKill[Type] = true; + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddMapEntry(new Color(53, 136, 207), CalamityUtils.GetItemName()); + HitSound = SoundID.Item27; + DustType = DustID.IceRod; + Main.tileSpelunker[Type] = true; + MinPick = 55; + + BlueCrystals = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals"); + PurpleCrystals = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Purple"); + GreenCrystals = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Green"); + Glint = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrismCrystals_Glint"); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float fade1 = GetFade1(i, j); + float fade2 = GetFade2(i, j); + + Color baseColor = new Color(162, 216, 218); //Blue + Color glow1 = new Color(171, 113, 215); //Purple + Color glow2 = new Color(56, 174, 117); //Green + + Vector3 blended = baseColor.ToVector3(); + + blended = Vector3.Lerp(blended, glow1.ToVector3(), fade1 * 0.5f); + blended = Vector3.Lerp(blended, glow2.ToVector3(), fade2 * 0.5f); + + float brightness = 0.6f; + blended *= brightness; + + r = blended.X; + g = blended.Y; + b = blended.Z; + } + + private static float GetFade1(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f; + + private static float GetFade2(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f; + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false; + + public override bool CanPlace(int i, int j) + { + Tile belowTile = Main.tile[i, j + 1]; + Tile aboveTile = Main.tile[i, j - 1]; + Tile rightTile = Main.tile[i + 1, j]; + Tile leftTile = Main.tile[i - 1, j]; + + if ((belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) || + (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) || + (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) || + (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid())) + return true; + + return false; + } + + public override void PlaceInWorld(int i, int j, Item item) + { + Tile belowTile = Main.tile[i, j + 1]; + Tile aboveTile = Main.tile[i, j - 1]; + Tile rightTile = Main.tile[i + 1, j]; + Tile leftTile = Main.tile[i - 1, j]; + + if (belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 0; + else if (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 18; + else if (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 36; + else if (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid()) + Main.tile[i, j].TileFrameY = 54; + + Main.tile[i, j].TileFrameX = (short)(WorldGen.genRand.Next(18) * 18); + } + } + + public class MediumSeaPrismCrystal : ModTile + { + internal static Asset BlueCrystals; + internal static Asset PurpleCrystals; + internal static Asset GreenCrystals; + internal static Asset Glint; + + public override void SetStaticDefaults() + { + Main.tileLighted[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileObsidianKill[Type] = true; + Main.tileSpelunker[Type] = true; + Main.tileShine[Type] = 5600; + Main.tileShine2[Type] = true; + + HitSound = SoundID.Item27; + DustType = DustID.IceRod; + MinPick = 55; + + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); + AddMapEntry(new Color(53, 136, 207), CalamityUtils.GetItemName()); + + // Attach to ground + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.StyleMultiplier = 32; // total 32 frames, all should be same "itemStyle" + TileObjectData.newTile.StyleWrapLimit = 8; // only 1 placement alternative per row + TileObjectData.newTile.RandomStyleRange = 8; // 8 different style will be selected upon placing + TileObjectData.newTile.Origin = new Point16(0, 1); + + // Attach to side (right) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(1, 0); + TileObjectData.addAlternate(8); + + // Attach to ceiling + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidBottom, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(16); + + // Attach to side (left) + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newAlternate.AnchorBottom = AnchorData.Empty; + TileObjectData.newAlternate.Origin = new Point16(0, 0); + TileObjectData.addAlternate(24); + TileObjectData.addTile(Type); + + BlueCrystals = ModContent.Request("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Blue"); + PurpleCrystals = ModContent.Request("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Purple"); + GreenCrystals = ModContent.Request("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Green"); + Glint = ModContent.Request("CalamityMod/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint"); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float fade1 = GetFade1(i, j); + float fade2 = GetFade2(i, j); + + Color baseColor = new Color(162, 216, 218); //Blue + Color glow1 = new Color(171, 113, 215); //Purple + Color glow2 = new Color(56, 174, 117); //Green + + Vector3 blended = baseColor.ToVector3(); + + blended = Vector3.Lerp(blended, glow1.ToVector3(), fade1 * 0.5f); + blended = Vector3.Lerp(blended, glow2.ToVector3(), fade2 * 0.5f); + + float brightness = 0.6f; + blended *= brightness; + + r = blended.X; + g = blended.Y; + b = blended.Z; + } + + private static float GetFade1(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f; + + private static float GetFade2(int i, int j) => (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f; + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) => false; + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType(), 4); + } + } + + public class SeaPrismShaderDrawing : ModSystem + { + private int SeaPrismTileType = -1; + private int SeaPrismCrystalTileType = -1; + private int MediumSeaPrismCrystalTileType = -1; + + private int SeaPrismWallType = -1; + private int UnsafeSeaPrismWallType = -1; + + public override void OnModLoad() + { + On_Main.DrawTiles += DrawSeaPrismsAndCrystals; + On_Main.DrawWalls += DrawSeaPrismWalls; + + SeaPrismTileType = ModContent.TileType(); + SeaPrismCrystalTileType = ModContent.TileType(); + MediumSeaPrismCrystalTileType = ModContent.TileType(); + + SeaPrismWallType = ModContent.WallType(); + UnsafeSeaPrismWallType = ModContent.WallType(); + } + + private static void GetScreenDrawArea(Vector2 screenPosition, Vector2 offSet, out int firstTileX, out int lastTileX, out int firstTileY, out int lastTileY) + { + firstTileX = (int)((screenPosition.X - offSet.X) / 16f - 1f); + lastTileX = (int)((screenPosition.X + (float)Main.screenWidth + offSet.X) / 16f) + 2; + firstTileY = (int)((screenPosition.Y - offSet.Y) / 16f - 1f); + lastTileY = (int)((screenPosition.Y + (float)Main.screenHeight + offSet.Y) / 16f) + 5; + if (firstTileX < 4) + { + firstTileX = 4; + } + if (lastTileX > Main.maxTilesX - 4) + { + lastTileX = Main.maxTilesX - 4; + } + if (firstTileY < 4) + { + firstTileY = 4; + } + if (lastTileY > Main.maxTilesY - 4) + { + lastTileY = Main.maxTilesY - 4; + } + } + + private void DrawSeaPrismsAndCrystals(On_Main.orig_DrawTiles orig, Main self, bool solidLayer, bool forRenderTargets, bool intoRenderTargets, int waterStyleOverride) + { + Vector2 offscreenPosition = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + + Main.tileBatch.End(); + Main.spriteBatch.End(); + + var oldTex1 = Main.instance.GraphicsDevice.Textures[1]; + var oldSampler1 = Main.instance.GraphicsDevice.SamplerStates[1]; + var oldTex2 = Main.instance.GraphicsDevice.Textures[2]; + var oldSampler2 = Main.instance.GraphicsDevice.SamplerStates[2]; + var oldTex3 = Main.instance.GraphicsDevice.Textures[3]; + var oldSampler3 = Main.instance.GraphicsDevice.SamplerStates[3]; + + Effect shader = CalamityShaders.SeaPrismColorBlendingShader.Value; + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["screenOffset"].SetValue(Main.screenPosition); + shader.Parameters["offscreenOffset"].SetValue(offscreenPosition); + shader.Parameters["diagonalScreenLength"].SetValue((Main.screenWidth / 2f) - (Main.screenHeight / 2f)); + shader.Parameters["doGlint"].SetValue(true); + + Vector2 unscaledPosition = Main.Camera.UnscaledPosition; + + GetScreenDrawArea(unscaledPosition, offscreenPosition + (Main.Camera.UnscaledPosition - Main.Camera.ScaledPosition), out var firstTileX, out var lastTileX, out var firstTileY, out var lastTileY); + + if (solidLayer) + { + Main.instance.GraphicsDevice.Textures[1] = SeaPrism.Green.Value; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[2] = SeaPrism.Purple.Value; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[3] = SeaPrism.Glint.Value; + Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearClamp; + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Matrix.Identity); + + for (int y = firstTileY; y < lastTileY + 4; y++) + { + for (int x = firstTileX - 2; x < lastTileX + 2; x++) + { + if (!WorldGen.InWorld(x, y)) + continue; + + Tile tile = Main.tile[x, y]; + if (tile == null) + continue; + + int type = tile.TileType; + if (type != SeaPrismTileType) + continue; + + Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offscreenPosition; + + int frameX = tile.TileFrameX + (x % 8 * SeaPrism.subsheetWidth); + int frameY = tile.TileFrameY + (y % 8 * SeaPrism.subsheetHeight); + + Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16); + Color light = Lighting.GetColor(x, y) * 1.5f; + if (tile.IsActuated) light = light.MultiplyRGB(Color.White * 0.4f); + + Main.spriteBatch.Draw(SeaPrism.Blue.Value, position, sourceRect, light); + } + } + } + else + { + Main.instance.GraphicsDevice.Textures[1] = SeaPrismCrystals.GreenCrystals.Value; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[2] = SeaPrismCrystals.PurpleCrystals.Value; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[3] = SeaPrismCrystals.Glint.Value; + Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearClamp; + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Matrix.Identity); + + for (int y = firstTileY; y < lastTileY + 4; y++) + { + for (int x = firstTileX - 2; x < lastTileX + 2; x++) + { + if (!WorldGen.InWorld(x, y)) + continue; + + Tile tile = Main.tile[x, y]; + if (tile == null) + continue; + + int type = tile.TileType; + if (type != SeaPrismCrystalTileType) + continue; + + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offScreen; + + Rectangle sourceRect = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); + Color light = Lighting.GetColor(x, y) * 1.5f; + + Main.spriteBatch.Draw(SeaPrismCrystals.BlueCrystals.Value, position, sourceRect, light); + } + } + + Main.spriteBatch.End(); + + Main.instance.GraphicsDevice.Textures[1] = MediumSeaPrismCrystal.GreenCrystals.Value; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[2] = MediumSeaPrismCrystal.PurpleCrystals.Value; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[3] = MediumSeaPrismCrystal.Glint.Value; + Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearClamp; + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, shader, Matrix.Identity); + + for (int y = firstTileY; y < lastTileY + 4; y++) + { + for (int x = firstTileX - 2; x < lastTileX + 2; x++) + { + if (!WorldGen.InWorld(x, y)) + continue; + + Tile tile = Main.tile[x, y]; + if (tile == null) + continue; + + int type = tile.TileType; + if (type != MediumSeaPrismCrystalTileType) + continue; + + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offScreen; + + Rectangle sourceRect = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); + Color light = Lighting.GetColor(x, y) * 1.5f; + + Main.spriteBatch.Draw(MediumSeaPrismCrystal.BlueCrystals.Value, position, sourceRect, light); + } + } + + } + + Main.spriteBatch.End(); + + Main.instance.GraphicsDevice.Textures[1] = oldTex1; + Main.instance.GraphicsDevice.SamplerStates[1] = oldSampler1; + Main.instance.GraphicsDevice.Textures[2] = oldTex2; + Main.instance.GraphicsDevice.SamplerStates[2] = oldSampler2; + Main.instance.GraphicsDevice.Textures[3] = oldTex3; + Main.instance.GraphicsDevice.SamplerStates[3] = oldSampler3; + + Main.spriteBatch.Begin(); + Main.tileBatch.Begin(); + + orig(self, solidLayer, forRenderTargets, intoRenderTargets, waterStyleOverride); + } + + private void DrawSeaPrismWalls(On_Main.orig_DrawWalls orig, Main self) + { + Vector2 offscreenPosition = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + + Main.tileBatch.End(); + Main.spriteBatch.End(); + + var oldTex1 = Main.instance.GraphicsDevice.Textures[1]; + var oldSampler1 = Main.instance.GraphicsDevice.SamplerStates[1]; + var oldTex2 = Main.instance.GraphicsDevice.Textures[2]; + var oldSampler2 = Main.instance.GraphicsDevice.SamplerStates[2]; + var oldTex3 = Main.instance.GraphicsDevice.Textures[3]; + + Main.instance.GraphicsDevice.Textures[1] = SeaPrismWall.GlowMaskGreen.Texture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[2] = SeaPrismWall.GlowMaskPurple.Texture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearClamp; + Main.instance.GraphicsDevice.Textures[3] = null; + + Effect shader = CalamityShaders.SeaPrismColorBlendingShader.Value; + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["screenOffset"].SetValue(Main.screenPosition); + shader.Parameters["offscreenOffset"].SetValue(offscreenPosition); + shader.Parameters["diagonalScreenLength"].SetValue((Main.screenWidth / 2f) - (Main.screenHeight / 2f)); + shader.Parameters["doGlint"].SetValue(false); + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); + + Vector2 unscaledPosition = Main.Camera.UnscaledPosition; + + GetScreenDrawArea(unscaledPosition, offscreenPosition + (Main.Camera.UnscaledPosition - Main.Camera.ScaledPosition), out var firstTileX, out var lastTileX, out var firstTileY, out var lastTileY); + + for (int y = firstTileY; y < lastTileY + 4; y++) + { + for (int x = firstTileX - 2; x < lastTileX + 2; x++) + { + if (!WorldGen.InWorld(x, y)) + continue; + + Tile tile = Main.tile[x, y]; + if (tile == null) + continue; + + int type = tile.WallType; + if (type != SeaPrismWallType && type != UnsafeSeaPrismWallType) + continue; + + Vector2 position = new Vector2(x * 16, y * 16) - Main.screenPosition + offscreenPosition; + + int xLength = 32; + + int frameXOffset = (x % 8) * 468; + int frameYOffset = (y % 8) * 180; + + int xPos = tile.WallFrameX + frameXOffset; + int yPos = tile.WallFrameY + frameYOffset; + + Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); + + if (SeaPrismWall.GlowMaskBlue.HasContentInFramePos(xPos, yPos)) + Main.spriteBatch.Draw(SeaPrismWall.GlowMaskBlue.Texture, position + new Vector2(-8, -8), frame, Color.White * 1.1f); + } + } + + Main.spriteBatch.End(); + + Main.instance.GraphicsDevice.Textures[1] = oldTex1; + Main.instance.GraphicsDevice.SamplerStates[1] = oldSampler1; + Main.instance.GraphicsDevice.Textures[2] = oldTex2; + Main.instance.GraphicsDevice.SamplerStates[2] = oldSampler2; + Main.instance.GraphicsDevice.Textures[3] = oldTex3; + + Main.spriteBatch.Begin(); + Main.tileBatch.Begin(); + + orig(self); } } } diff --git a/Tiles/SunkenSea/SeaPrism.png b/Tiles/SunkenSea/SeaPrism.png index 7729be3702..01220e2182 100644 Binary files a/Tiles/SunkenSea/SeaPrism.png and b/Tiles/SunkenSea/SeaPrism.png differ diff --git a/Tiles/SunkenSea/SeaPrismBrick.cs b/Tiles/SunkenSea/SeaPrismBrick.cs index f4e78b55d9..8aefd49e90 100644 --- a/Tiles/SunkenSea/SeaPrismBrick.cs +++ b/Tiles/SunkenSea/SeaPrismBrick.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea @@ -21,8 +20,9 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileShine[Type] = 3500; Main.tileShine2[Type] = true; + TileID.Sets.DrawsWalls[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; - DustType = 33; + DustType = DustID.Water; AddMapEntry(new Color(47, 193, 236)); HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; diff --git a/Tiles/SunkenSea/SeaPrismCrystals.cs b/Tiles/SunkenSea/SeaPrismCrystals.cs deleted file mode 100644 index dd064e88e7..0000000000 --- a/Tiles/SunkenSea/SeaPrismCrystals.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using CalamityMod.Items.Placeables.SunkenSea; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.SunkenSea -{ - public class SeaPrismCrystals : ModTile - { - public override void SetStaticDefaults() - { - Main.tileLighted[Type] = true; - Main.tileNoFail[Type] = true; - Main.tileFrameImportant[Type] = true; - Main.tileObsidianKill[Type] = true; - AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); - HitSound = SoundID.Item27; - DustType = 67; - Main.tileSpelunker[Type] = true; - MinPick = 55; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - var tile = Main.tile[i, j]; - bool lessLightDueToLowWater = tile.LiquidAmount > 50 && tile.LiquidType == LiquidID.Water; - int xframe = tile.TileFrameX / 18; - if (xframe > 7 && xframe < 14) - { - //Purple - Color darkviolet = new Color(75, 54, 103); - Color violet = new Color(231, 205, 245); - Color value = Color.Lerp(darkviolet, violet, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.037f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(darkviolet, violet, (MathF.Sin((j - 120) / 50f + Main.GameUpdateCount * 0.014f + -i / 30f) + 1f) / 2f); - r = lessLightDueToLowWater ? 0.36f : 0.48f; - g = lessLightDueToLowWater ? 0.315f : 0.42f; - b = lessLightDueToLowWater ? 0.405f : 0.54f; - r *= (value.R + value1.R) / 300f; - g *= (value.G + value1.G) / 300f; - b *= (value.B + value1.B) / 300f; - - } - else if (xframe >= 14) - { - //Green - Color murkeygreen = new Color(28, 68, 54); - Color lightgreen = new Color(166, 234, 198); - Color value2 = Color.Lerp(murkeygreen, lightgreen, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.027f + i / 40f) + 1f) / 2f); - Color value3 = Color.Lerp(murkeygreen, lightgreen, (MathF.Sin((j - 80) / 50f + Main.GameUpdateCount * 0.034f + -i / 30f) + 1f) / 2f); - r = lessLightDueToLowWater ? 0.225f : 0.3f; - g = lessLightDueToLowWater ? 0.405f : 0.54f; - b = lessLightDueToLowWater ? 0.315f : 0.42f; - r *= (value2.R + value3.R) / 300f; - g *= (value2.G + value3.G) / 300f; - b *= (value2.B + value3.B) / 300f; - } - else - { - //Blue - Color blue = new Color(67, 187, 204); - Color darkviolet = new Color(18, 67, 116); - Color value = Color.Lerp(blue, darkviolet, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(blue, darkviolet, (MathF.Sin((j - 10) / 50f + Main.GameUpdateCount * 0.064f + -i / 30f) + 1f) / 2f); - r = lessLightDueToLowWater ? 0.27f : 0.36f; - g = lessLightDueToLowWater ? 0.405f : 0.54f; - b = lessLightDueToLowWater ? 0.405f : 0.54f; - r *= (value.R + value1.R) / 300f; - g *= (value.G + value1.G) / 300f; - b *= (value.B + value1.B) / 300f; - } - } - - public override bool CanPlace(int i, int j) - { - Tile belowTile = Main.tile[i, j + 1]; - Tile aboveTile = Main.tile[i, j - 1]; - Tile rightTile = Main.tile[i + 1, j]; - Tile leftTile = Main.tile[i - 1, j]; - - if ((belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) || - (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) || - (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) || - (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid())) - return true; - - return false; - } - - public override void PlaceInWorld(int i, int j, Item item) - { - Tile belowTile = Main.tile[i, j + 1]; - Tile aboveTile = Main.tile[i, j - 1]; - Tile rightTile = Main.tile[i + 1, j]; - Tile leftTile = Main.tile[i - 1, j]; - - if (belowTile.Slope == SlopeType.Solid && !belowTile.IsHalfBlock && belowTile.HasTile && belowTile.IsTileSolid()) - Main.tile[i, j].TileFrameY = 0; - else if (aboveTile.Slope == SlopeType.Solid && !aboveTile.IsHalfBlock && aboveTile.HasTile && aboveTile.IsTileSolid()) - Main.tile[i, j].TileFrameY = 18; - else if (rightTile.Slope == SlopeType.Solid && !rightTile.IsHalfBlock && rightTile.HasTile && rightTile.IsTileSolid()) - Main.tile[i, j].TileFrameY = 36; - else if (leftTile.Slope == SlopeType.Solid && !leftTile.IsHalfBlock && leftTile.HasTile && leftTile.IsTileSolid()) - Main.tile[i, j].TileFrameY = 54; - - Main.tile[i, j].TileFrameX = (short)(WorldGen.genRand.Next(18) * 18); - } - } -} diff --git a/Tiles/SunkenSea/SeaPrismCrystals.png b/Tiles/SunkenSea/SeaPrismCrystals.png index c4646c40c6..574fd43f13 100644 Binary files a/Tiles/SunkenSea/SeaPrismCrystals.png and b/Tiles/SunkenSea/SeaPrismCrystals.png differ diff --git a/Tiles/SunkenSea/SeaPrismCrystals_Glint.png b/Tiles/SunkenSea/SeaPrismCrystals_Glint.png new file mode 100644 index 0000000000..c8300a945b Binary files /dev/null and b/Tiles/SunkenSea/SeaPrismCrystals_Glint.png differ diff --git a/Tiles/SunkenSea/SeaPrismCrystals_Green.png b/Tiles/SunkenSea/SeaPrismCrystals_Green.png new file mode 100644 index 0000000000..d167aa4b1e Binary files /dev/null and b/Tiles/SunkenSea/SeaPrismCrystals_Green.png differ diff --git a/Tiles/SunkenSea/SeaPrismCrystals_Purple.png b/Tiles/SunkenSea/SeaPrismCrystals_Purple.png new file mode 100644 index 0000000000..52616c685f Binary files /dev/null and b/Tiles/SunkenSea/SeaPrismCrystals_Purple.png differ diff --git a/Tiles/SunkenSea/SeaPrism_Blue.png b/Tiles/SunkenSea/SeaPrism_Blue.png new file mode 100644 index 0000000000..7e6c12266c Binary files /dev/null and b/Tiles/SunkenSea/SeaPrism_Blue.png differ diff --git a/Tiles/SunkenSea/SeaPrism_GlintMask.png b/Tiles/SunkenSea/SeaPrism_GlintMask.png new file mode 100644 index 0000000000..b80a7aaa41 Binary files /dev/null and b/Tiles/SunkenSea/SeaPrism_GlintMask.png differ diff --git a/Tiles/SunkenSea/SeaPrism_Green.png b/Tiles/SunkenSea/SeaPrism_Green.png new file mode 100644 index 0000000000..9ad3fbf00c Binary files /dev/null and b/Tiles/SunkenSea/SeaPrism_Green.png differ diff --git a/Tiles/SunkenSea/SeaPrism_Purple.png b/Tiles/SunkenSea/SeaPrism_Purple.png new file mode 100644 index 0000000000..00eb510c4c Binary files /dev/null and b/Tiles/SunkenSea/SeaPrism_Purple.png differ diff --git a/Tiles/SunkenSea/Shellstone.cs b/Tiles/SunkenSea/Shellstone.cs index fc65591926..ff489fc60e 100644 --- a/Tiles/SunkenSea/Shellstone.cs +++ b/Tiles/SunkenSea/Shellstone.cs @@ -1,4 +1,5 @@ using CalamityMod.Systems; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -14,27 +15,50 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); - TileID.Sets.HasSlopeFrames[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Tink; - DustType = 17; - AddMapEntry(new Color(113, 117, 160)); + DustType = DustID.CorruptPlants; + AddMapEntry(new Color(123, 127, 170)); - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - - this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); - this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); - this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + + public override void RandomUpdate(int i, int j) + { + Tile Tile = Framing.GetTileSafely(i, j); + Tile Below = Framing.GetTileSafely(i, j + 1); + Tile Above = Framing.GetTileSafely(i, j - 1); + + if (!Below.HasTile && Below.LiquidType == LiquidID.Water && !Tile.BottomSlope) + { + if (Main.rand.NextBool(10)) + { + Below.TileType = (ushort)ModContent.TileType(); + Below.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.dedServ) + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } } } diff --git a/Tiles/SunkenSea/ShellstoneSlab.cs b/Tiles/SunkenSea/ShellstoneSlab.cs deleted file mode 100644 index 19caa0a57f..0000000000 --- a/Tiles/SunkenSea/ShellstoneSlab.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -using Terraria.ID; -using CalamityMod.Systems; - -namespace CalamityMod.Tiles.SunkenSea -{ - public class ShellstoneSlab : ModTile - { - public override void SetStaticDefaults() - { - Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; - - CalamityUtils.MergeWithGeneral(Type); - TileID.Sets.HasSlopeFrames[Type] = true; - - HitSound = SoundID.Tink; - DustType = 17; - AddMapEntry(new Color(156, 191, 199)); - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); - } - } -} diff --git a/Tiles/SunkenSea/SunkenKelp.cs b/Tiles/SunkenSea/SunkenKelp.cs new file mode 100644 index 0000000000..d8c6aab42d --- /dev/null +++ b/Tiles/SunkenSea/SunkenKelp.cs @@ -0,0 +1,147 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class SunkenKelp : ModTile + { + private const int MaxChainLength = 18; + private static readonly ushort[] ValidAnchors = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + private const short FrameBottom = 0; + private const short FrameMid = 18; + private const short FrameTop = 36; + private const short FrameWidth = 18; + + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileID.Sets.IsVine[Type] = true; + TileID.Sets.DisableSmartCursor[Type] = true; + + HitSound = SoundID.Grass; + DustType = DustID.Grass; + + AddMapEntry(new Color(27, 112, 68)); + } + + public override void RandomUpdate(int i, int j) + { + if (!IsTopmostSegment(i, j)) + return; + + if (j <= 0 || Main.tile[i, j - 1].HasTile) + return; + + if (!IsSupportedFromBelow(i, j)) + return; + + if (GetChainLengthUpward(i, j) >= MaxChainLength) + return; + + bool placed = WorldGen.PlaceTile(i, j - 1, Type, mute: true, forced: true); + if (placed) + { + SetFrame(i, j - 1, FrameTop); + SetFrame(i, j, FrameMid); + UpdateBaseSegment(i, j + GetChainLengthDownward(i, j)); + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + if (!IsSupportedFromBelow(i, j)) + { + WorldGen.KillTile(i, j, noItem: true, effectOnly: false); + return false; + } + + if (IsTopmostSegment(i, j)) + SetFrame(i, j, FrameTop); + else if (IsBottomSegment(i, j)) + SetFrame(i, j, FrameBottom); + else + SetFrame(i, j, FrameMid); + + return false; + } + + private static bool IsSupportedFromBelow(int i, int j) + { + if (j >= Main.maxTilesY - 1) return false; + Tile below = Main.tile[i, j + 1]; + if (!below.HasTile) return false; + + ushort t = below.TileType; + if (t == ModContent.TileType()) + return true; + + foreach (ushort anchor in ValidAnchors) + if (t == anchor) + return true; + + return false; + } + + private static bool IsTopmostSegment(int i, int j) + { + if (j <= 0) return true; + Tile above = Main.tile[i, j - 1]; + return !(above.HasTile && above.TileType == ModContent.TileType()); + } + + private static bool IsBottomSegment(int i, int j) + { + if (j >= Main.maxTilesY - 1) return true; + Tile below = Main.tile[i, j + 1]; + return !(below.HasTile && below.TileType == ModContent.TileType()); + } + + private static int GetChainLengthUpward(int i, int j) + { + int length = 1; + int y = j - 1; + int vineType = ModContent.TileType(); + while (y >= 0 && Main.tile[i, y].HasTile && Main.tile[i, y].TileType == vineType) + { + length++; + y--; + if (length > MaxChainLength) break; + } + return length; + } + + private static int GetChainLengthDownward(int i, int j) + { + int length = 0; + int y = j + 1; + int vineType = ModContent.TileType(); + while (y < Main.maxTilesY && Main.tile[i, y].HasTile && Main.tile[i, y].TileType == vineType) + { + length++; + y++; + } + return length; + } + + private static void SetFrame(int i, int j, short frameYRow) + { + Tile tile = Main.tile[i, j]; + tile.TileFrameX = (short)(WorldGen.genRand.Next(3) * FrameWidth); + tile.TileFrameY = frameYRow; + } + + private static void UpdateBaseSegment(int i, int bottomY) + { + Tile t = Main.tile[i, bottomY]; + if (t.HasTile && t.TileType == ModContent.TileType()) + SetFrame(i, bottomY, FrameBottom); + } + } +} diff --git a/Tiles/SunkenSea/SunkenKelp.png b/Tiles/SunkenSea/SunkenKelp.png new file mode 100644 index 0000000000..46c82c6488 Binary files /dev/null and b/Tiles/SunkenSea/SunkenKelp.png differ diff --git a/Tiles/SunkenSea/SuperheatedObsidian.cs b/Tiles/SunkenSea/SuperheatedObsidian.cs new file mode 100644 index 0000000000..4831d4a862 --- /dev/null +++ b/Tiles/SunkenSea/SuperheatedObsidian.cs @@ -0,0 +1,111 @@ +using System; +using CalamityMod.Sounds; +using CalamityMod.Systems; +using CalamityMod.Tiles.Abyss; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class SuperheatedObsidian : ModTile + { + public Asset GlintTexture; + + public Vector2 GlintDir; + + public override void SetStaticDefaults() + { + GlintTexture = ModContent.Request(Texture + "_Glint"); + + GlintDir = new Vector2(1f, 1f); + GlintDir.Normalize(); + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileLighted[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + + //Main.tileShine[Type] = 3500; + Main.tileShine2[Type] = true; + + HitSound = CommonCalamitySounds.VoidstoneMine; + DustType = DustID.Slush; + AddMapEntry(new Color(67, 61, 91)); + + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + float transparency = 1f; + + // Must be set here + Main.tileBlockLight[Type] = false; + + Tile tile = Main.tile[i, j]; + Rectangle frame = new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16); + + Color color = Lighting.GetColor(i, j) * transparency; + TileFramingSystem.SlopedGlowmask(in tile, i, j, TextureAssets.Tile[Type].Value, frame, CalamityUtils.ApplyPaint(tile.TileColor, color, false), default); + + //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's + + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen; + + Vector2 screenPos = position; + + float projection = Vector2.Dot(screenPos, GlintDir); + + // this sets the length between the glints diagonally + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), GlintDir); + + float stripeWidth = 100f; + Color lightColor = Lighting.GetColor(i, j); + + DrawGlint(screenDiagonalLength * 0.53f); + DrawGlint(screenDiagonalLength * 0.63f); + DrawGlint(screenDiagonalLength * 0.73f); + + void DrawGlint(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f) * 0.4f; + + if (strength > 0f) + { + spriteBatch.Draw(GlintTexture.Value, position, frame, lightColor * strength, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + + return false; + } + } +} diff --git a/Tiles/SunkenSea/SuperheatedObsidian.png b/Tiles/SunkenSea/SuperheatedObsidian.png new file mode 100644 index 0000000000..63b6ac62c8 Binary files /dev/null and b/Tiles/SunkenSea/SuperheatedObsidian.png differ diff --git a/Tiles/SunkenSea/SuperheatedObsidian_Glint.png b/Tiles/SunkenSea/SuperheatedObsidian_Glint.png new file mode 100644 index 0000000000..dba241c470 Binary files /dev/null and b/Tiles/SunkenSea/SuperheatedObsidian_Glint.png differ diff --git a/Tiles/SunkenSea/VolcanicSand.cs b/Tiles/SunkenSea/VolcanicSand.cs index cd48e6d175..7c6a6845f2 100644 --- a/Tiles/SunkenSea/VolcanicSand.cs +++ b/Tiles/SunkenSea/VolcanicSand.cs @@ -1,6 +1,8 @@ -using CalamityMod.Systems; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; +using Terraria.GameContent.Metadata; using Terraria.ID; using Terraria.ModLoader; @@ -22,12 +24,33 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - DustType = 147; - AddMapEntry(new Color(117, 79, 97)); + DustType = DustID.t_PearlWood; - this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); - this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); - this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + AddMapEntry(new Color(102, 101, 106)); + + Main.tileSand[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); + TileID.Sets.Suffocate[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Conversion.Sand[Type] = true; + TileID.Sets.ForAdvancedCollision.ForSandshark[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 10); + + //Stone merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + //Sand merges + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + //Normal merges + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -39,5 +62,12 @@ namespace CalamityMod.Tiles.SunkenSea { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + public override void RandomUpdate(int i, int j) + { + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, DustID.Smoke, 0f, -1.9069767f, 195, new Color(255, 255, 255), 1f)]; + dust.noGravity = false; + dust.fadeIn = 1.4209302f; + } } } diff --git a/Tiles/SunkenSea/VolcanicSand.png b/Tiles/SunkenSea/VolcanicSand.png index a85b4c8dee..1be4406780 100644 Binary files a/Tiles/SunkenSea/VolcanicSand.png and b/Tiles/SunkenSea/VolcanicSand.png differ diff --git a/Tiles/SunkenSea/WhitePearlPile.cs b/Tiles/SunkenSea/WhitePearlPile.cs index 6bd9a076bb..cec13da31b 100644 --- a/Tiles/SunkenSea/WhitePearlPile.cs +++ b/Tiles/SunkenSea/WhitePearlPile.cs @@ -1,5 +1,11 @@ -using CalamityMod.Systems; +using System; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.Sounds; +using CalamityMod.Systems; +using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,10 +14,20 @@ namespace CalamityMod.Tiles.SunkenSea { public class WhitePearlPile : ModTile { + public Asset GlintTexture; + + public Vector2 GlintDir; + public override void SetStaticDefaults() { + GlintTexture = ModContent.Request(Texture + "_Glint"); + + GlintDir = new Vector2(1f, -1f); + GlintDir.Normalize(); + Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; + Main.tileLighted[Type] = true; CalamityUtils.MergeWithGeneral(Type); @@ -21,24 +37,122 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileShine[Type] = 3500; Main.tileShine2[Type] = true; - HitSound = SoundID.Shatter; - DustType = 149; + HitSound = CommonCalamitySounds.VoidstoneMine; + DustType = DustID.Slush; AddMapEntry(new Color(217, 209, 213)); TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + TileID.Sets.CanBeDugByShovel[Type] = true; + TileID.Sets.Falling[Type] = true; + TileID.Sets.FallingBlockProjectile[Type] = new TileID.Sets.FallingBlockProjectileInfo(ModContent.ProjectileType(), 15); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(TileID.Sandstone); + this.RegisterBlendMergeWith(TileID.Sand); + this.RegisterBlendMergeWith(TileID.HardenedSand); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Ash); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); } + + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's + + Tile tile = Framing.GetTileSafely(i, j); + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen; + + int frameX = tile.TileFrameX + (i % 1); + int frameY = tile.TileFrameY + (j % 1); + + Rectangle sourceRect = new Rectangle(frameX, frameY, 16, 16); + + Vector2 screenPos = position; + + float projection = Vector2.Dot(screenPos, GlintDir); + + // this sets the length between the glints diagonally + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), GlintDir); + + float stripeWidth = 100f; + Color lightColor = Lighting.GetColor(i, j) * 6; + + DrawGlint(screenDiagonalLength * 0.05f); + DrawGlint(screenDiagonalLength * 0.5f); + DrawGlint(screenDiagonalLength * 1.05f); + + void DrawGlint(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f) * 0.4f; + + if (strength > 0f) + { + spriteBatch.Draw(GlintTexture.Value, position, sourceRect, lightColor * strength, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i, j].Get().Flag0) + return; + + // get in-game lighting color at this tile + Color litColor = Lighting.GetColor(i, j); + + // convert to brightness factor (0 = dark, 1 = full bright) + float brightness = (litColor.R + litColor.G + litColor.B) / (3f * 255f); + + // flip it so the glow is strongest in the dark + float darknessFactor = 1f - brightness; + + Vector2 screenPos = new Vector2(i * 16, j * 16) - Main.screenPosition; + float projection = Vector2.Dot(screenPos, GlintDir); + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), GlintDir); + + float stripeWidth = 100f; + float maxStrength = 0f; + + UpdateMaxStrength(screenDiagonalLength * 0.05f); + UpdateMaxStrength(screenDiagonalLength * 0.5f); + UpdateMaxStrength(screenDiagonalLength * 1.05f); + + void UpdateMaxStrength(float beamCenter) + { + float dist = Math.Abs(projection - beamCenter); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f); + if (strength > maxStrength) + maxStrength = strength; + } + + if (maxStrength > 0f) + { + // base intensity scaled by glint strength and darkness (min = 0.0f, max = 1.0f) + float intensity = 0.6f * maxStrength * (0.5f + darknessFactor * 0.5f); + //float intensity = ((float)(Math.Pow(10.0, (brightness * 2 - 2))) - 0.01f) / 0.99f; was trying to do something cool, may come back to it later + + r = (185f / 255f) * intensity; + g = (164f / 255f) * intensity; + b = (184f / 255f) * intensity; + } + } } } diff --git a/Tiles/SunkenSea/WhitePearlPile_Glint.png b/Tiles/SunkenSea/WhitePearlPile_Glint.png new file mode 100644 index 0000000000..3a8280eeb8 Binary files /dev/null and b/Tiles/SunkenSea/WhitePearlPile_Glint.png differ diff --git a/Tiles/SunkenSea/YellowCoral.cs b/Tiles/SunkenSea/YellowCoral.cs index c098f500ce..f91c19d8bb 100644 --- a/Tiles/SunkenSea/YellowCoral.cs +++ b/Tiles/SunkenSea/YellowCoral.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Systems; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -21,38 +20,32 @@ namespace CalamityMod.Tiles.SunkenSea TileID.Sets.ChecksForMerge[Type] = true; HitSound = SoundID.Dig; - DustType = 119; - AddMapEntry(new Color(198, 169, 24)); + DustType = DustID.Firework_Yellow; + AddMapEntry(new Color(238, 207, 37)); Main.tileShine2[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; - // 02JUN2024: Ozzatron: RuneSand has no merge - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); - // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined - // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); - - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); - this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); + this.RegisterBlendMergeWith(ModContent.TileType()); } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + if (Main.tile[i, j].Get().Flag0) { - float brightness = 0.9f; - Color Color1 = new Color(218, 203, 67); - Color Color2 = new Color(121, 76, 1); - Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); - Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); - r = (value.R + value1.R) / 300f; - g = (value.G + value1.G) / 300f; - b = (value.B + value1.B) / 300f; - r *= brightness; - g *= brightness; - b *= brightness; + r = 0.73f; + g = 0.68f; + b = 0.22f; } } + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + Main.tile[i, j].Get().Flag0 = !Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFramingSystem.BetterGemsparkFraming(i, j, resetFrame); diff --git a/Tiles/SunkenSea/YellowCoral.png b/Tiles/SunkenSea/YellowCoral.png index ef005dc85b..7c2ad9d150 100644 Binary files a/Tiles/SunkenSea/YellowCoral.png and b/Tiles/SunkenSea/YellowCoral.png differ diff --git a/Tiles/UelibloomBrick.cs b/Tiles/UelibloomBrick.cs index 88a30f67fb..d4f08a90bf 100644 --- a/Tiles/UelibloomBrick.cs +++ b/Tiles/UelibloomBrick.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; -using CalamityMod.Dusts.Furniture; +using CalamityMod.Dusts.Furniture; using CalamityMod.Systems; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.Metadata; @@ -13,11 +13,15 @@ namespace CalamityMod.Tiles { public class UelibloomBrick : ModTile { + public Asset LeavesTexture; + private int extraFrameHeight = 36; private int extraFrameWidth = 90; public override void SetStaticDefaults() { + LeavesTexture = ModContent.Request("CalamityMod/Tiles/UelibloomBrick_Leaves"); + Main.tileSolid[Type] = true; Main.tileMergeDirt[Type] = false; Main.tileBlockLight[Type] = true; @@ -30,9 +34,9 @@ namespace CalamityMod.Tiles HitSound = SoundID.Tink; AddMapEntry(new Color(174, 108, 46)); - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Mud); } public override bool CreateDust(int i, int j, ref int type) @@ -42,16 +46,24 @@ namespace CalamityMod.Tiles return false; } - public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) { if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type || Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type) { - try - { - Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); - } - catch { } + Main.tile[i, j].Get().HasSpecialPoint = true; + } + else + { + Main.tile[i, j].Get().HasSpecialPoint = false; + } + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].Get().HasSpecialPoint) + { + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); } } @@ -63,7 +75,7 @@ namespace CalamityMod.Tiles Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, Lighting.GetColor(i, j), false); - Texture2D leaves = ModContent.Request("CalamityMod/Tiles/UelibloomBrick_Leaves").Value; + Texture2D leaves = LeavesTexture.Value; DrawExtraTop(i, j, leaves, drawOffset, drawColour); DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour); diff --git a/Tiles/VernalSoil.cs b/Tiles/VernalSoil.cs index ebfd615be2..729d05c74c 100644 --- a/Tiles/VernalSoil.cs +++ b/Tiles/VernalSoil.cs @@ -1,36 +1,63 @@ -using System.Collections.Generic; +using CalamityMod.Systems; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent.Metadata; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles { public class VernalSoil : ModTile { + public Asset GrassTexture; + + private int extraFrameHeight = 36; + private int extraFrameWidth = 90; public override void SetStaticDefaults() { + GrassTexture = ModContent.Request("CalamityMod/Tiles/VernicFernGrass"); + Main.tileSolid[Type] = true; - Main.tileBlockLight[Type] = true; + Main.tileBlockLight[Type] = false; TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Organic"]); CalamityUtils.MergeWithGeneral(Type); TileID.Sets.CanBeDugByShovel[Type] = true; - DustType = 38; + DustType = DustID.Mud; AddMapEntry(new Color(80, 120, 0)); HitSound = SoundID.Dig; - this.RegisterUniversalMerge(TileID.Dirt, "CalamityMod/Tiles/Merges/DirtMerge"); - this.RegisterUniversalMerge(TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - this.RegisterUniversalMerge(TileID.Mud, "CalamityMod/Tiles/Merges/MudMerge"); + this.RegisterBlendMergeWith(TileID.Dirt); + this.RegisterBlendMergeWith(TileID.Stone); + this.RegisterBlendMergeWith(TileID.Mud); + } + + public override void PostTileFrame(int i, int j, int up, int down, int left, int right, int upLeft, int upRight, int downLeft, int downRight) + { + if (Main.tile[i - 1, j - 1].TileType != Type || Main.tile[i, j - 1].TileType != Type || Main.tile[i + 1, j - 1].TileType != Type || + Main.tile[i - 1, j - 2].TileType != Type || Main.tile[i, j - 2].TileType != Type || Main.tile[i + 1, j - 2].TileType != Type) + { + Main.tile[i, j].Get().HasSpecialPoint = true; + } + else + { + Main.tile[i, j].Get().HasSpecialPoint = false; + } + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (Main.tile[i, j].Get().HasSpecialPoint) + { + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); + } } public override void RandomUpdate(int i, int j) @@ -149,6 +176,285 @@ namespace CalamityMod.Tiles } } + public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) + { + Tile tile = Main.tile[i, j]; + if (tile.IsTileActuallyInvisible()) + return; + + Tile uptile = Main.tile[i, j - 1]; + if (uptile.HasTile && uptile.IsTileFull()) + return; + + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; + Color drawColour = CalamityUtils.ApplyPaint(tile.TileColor, Lighting.GetColor(i, j)); + Texture2D leaves = GrassTexture.Value; + + DrawExtraTop(i, j, leaves, drawOffset, drawColour); + //DrawExtraWallEnds(i, j, leaves, drawOffset, drawColour); + DrawExtraDrapes(i, j, leaves, drawOffset, drawColour); + } + + #region 'Extra Drapes' Drawing + private void DrawExtraTop(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + If the tile directly above this tile is not otherworldly stone, or if it is, there is air to both sides of that tile, draw the Extra surface + */ + if ( + CheckTile(Type, false, 0, 1, i, j) || + (CheckTile(Type, true, 0, 1, i, j) && CheckTile(Type, false, 1, 1, i, j) && CheckTile(Type, false, -1, 1, i, j) && CheckTile(Type, true, 1, 0, i, j) && CheckTile(Type, true, -1, 0, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("middle") + GetExtraVariant(i, j), GetExtraPattern(i), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle?(new Rectangle(GetExtraState("middle") + GetExtraVariant(i, j), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + + DrawExtraOverhang(i, j, extras, drawOffset, drawColour); + } + } + + private void DrawExtraWallEnds(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Ending the Extra when a wall is reached + */ + + //Left + if ( + CheckTile(Type, true, 1, 0, i, j) && CheckTile(Type, false, 1, 1, i, j) && CheckTile(Type, true, 0, 1, i, j) && + (CheckTile(Type, true, -1, 1, i, j) || CheckTile(Type, false, -1, 0, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndLeft") + GetExtraVariant(i + 1, j), GetExtraPattern(i), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle?(new Rectangle(GetExtraState("wallEndLeft") + GetExtraVariant(i + 1, j), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right + if ( + CheckTile(Type, true, -1, 0, i, j) && CheckTile(Type, false, -1, 1, i, j) && CheckTile(Type, true, 0, 1, i, j) && + (CheckTile(Type, true, 1, 1, i, j) || CheckTile(Type, false, 1, 0, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndRight") + GetExtraVariant(i - 1, j), GetExtraPattern(i), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(0f, 16f), new Rectangle?(new Rectangle(GetExtraState("wallEndRight") + GetExtraVariant(i - 1, j), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + + private void DrawExtraOverhang(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Called from DrawExtraTop(). Ending the Extra when the edge of the tile is reached + */ + + //Left + if ( + CheckTile(Type, false, -1, 0, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(-16f, 0f), new Rectangle?(new Rectangle(GetExtraState("overhangLeft") + GetExtraVariant(i, j), GetExtraPattern(i - 1), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(-16f, 16f), new Rectangle?(new Rectangle(GetExtraState("overhangLeft") + GetExtraVariant(i, j), GetExtraPattern(i - 1) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right + if ( + CheckTile(Type, false, 1, 0, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(16f, 0f), new Rectangle?(new Rectangle(GetExtraState("overhangRight") + GetExtraVariant(i, j), GetExtraPattern(i + 1), 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + Main.spriteBatch.Draw(extras, drawOffset + new Vector2(16f, 16f), new Rectangle?(new Rectangle(GetExtraState("overhangRight") + GetExtraVariant(i, j), GetExtraPattern(i + 1) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + + private void DrawExtraDrapes(int i, int j, Texture2D extras, Vector2 drawOffset, Color drawColour) + { + /* + Hanging 'drapes' of the extra element + */ + + //Base + if ( + (CheckTile(Type, true, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j)) || + (CheckTile(Type, true, 0, 2, i, j) && CheckTile(Type, false, 1, 2, i, j) && CheckTile(Type, false, -1, 2, i, j) && CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, true, -1, 1, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("middle") + GetExtraVariant(i, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Left Wall + if ( + CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, false, 1, 2, i, j) && CheckTile(Type, true, 0, 2, i, j) && + (CheckTile(Type, true, -1, 2, i, j) || CheckTile(Type, false, -1, 1, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndLeft") + GetExtraVariant(i + 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right Wall + if ( + CheckTile(Type, true, -1, 1, i, j) && CheckTile(Type, false, -1, 2, i, j) && CheckTile(Type, true, 0, 2, i, j) && + (CheckTile(Type, true, 1, 2, i, j) || CheckTile(Type, false, 1, 1, i, j)) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("wallEndRight") + GetExtraVariant(i - 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Left Overhang + if ( + CheckTile(Type, true, 1, 1, i, j) && CheckTile(Type, false, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j) && CheckTile(Type, false, 1, 2, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("overhangLeft") + GetExtraVariant(i + 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + //Right Overhang + if ( + CheckTile(Type, true, -1, 1, i, j) && CheckTile(Type, false, 0, 1, i, j) && CheckTile(Type, false, 0, 2, i, j) && CheckTile(Type, false, -1, 2, i, j) + ) + { + Main.spriteBatch.Draw(extras, drawOffset, new Rectangle?(new Rectangle(GetExtraState("overhangRight") + GetExtraVariant(i - 1, j - 1), GetExtraPattern(i) + 18, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); + } + } + #endregion + + #region Tile Data + private bool CheckTile(int type, bool equal, int x, int y, int i, int j) + { + //Subtract y so that y is vertical for ease of readability + return Main.tile[i + x, j - y].TileType == type == equal; + } + + private int GetExtraState(string type) + { + switch (type) + { + case "middle": + return 36; + case "overhangLeft": + return 18; + case "overhangRight": + return 54; + case "wallEndLeft": + return 0; + case "wallEndRight": + return 72; + default: + Main.NewText(type.ToString() + " is not a valid Extra sheet state"); + return 0; + } + } + + private int GetExtraPattern(int i) + { + return i % 3 * extraFrameHeight; + } + + private int GetExtraVariant(int i, int j) + { + return Main.tile[i, j].TileFrameNumber * extraFrameWidth; + } + + /* + private int GetTileVariant(int i, int j) + { + int variant = 0; //Default to using variant 1 + Tile sourceTile = Main.tile[i, j]; + //Now to get the particular 'variant group' to use, which is used to take the frameX/frameY of the tile and convert it to the variant the tile is using + int frameX = sourceTile.frameX / 18; + int frameY = sourceTile.frameY / 18; + if (frameY < 3 && !(frameX >= 6 && frameX < 9)) + { + int group = 0; + int[] group1XPos = new int[] { 1, 2, 3 }; + int[] group2XPos = new int[] { 0, 4, 5, 9, 10, 11, 12 }; + foreach (int k in group1XPos) + { + if (frameX < k + 1 && frameX >= k) + { + group = 1; + } + } + foreach (int k in group2XPos) + { + if (frameX < k + 1 && frameX >= k) + { + group = 2; + } + } + if (group == 1) + { + if (frameX < 2) + { + variant = 0; + } + else if (frameX < 3) + { + variant = 1; + } + else + { + variant = 2; + } + } + else if (group == 2) + { + if (frameY < 1) + { + variant = 0; + } + else if (frameY < 2) + { + variant = 1; + } + else + { + variant = 2; + } + } + } + else if (frameX < 6 && frameY >= 3) + { + if (frameX < 2) + { + variant = 0; + } + else if (frameX < 4) + { + variant = 1; + } + else + { + variant = 2; + } + } + else if (frameX >= 6 && frameX < 9) + { + if (frameX < 7) + { + variant = 0; + } + else if (frameX < 8) + { + variant = 1; + } + else + { + variant = 2; + } + } + else if (frameX >= 9 && frameY >= 3) + { + if (frameX < 10) + { + variant = 0; + } + else if (frameX < 11) + { + variant = 1; + } + else + { + variant = 2; + } + } + return (variant); + } + */ + #endregion public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; diff --git a/Tiles/VernalSoil.png b/Tiles/VernalSoil.png index 8c1e2f1c56..7d652bd739 100644 Binary files a/Tiles/VernalSoil.png and b/Tiles/VernalSoil.png differ diff --git a/Tiles/VernicFernGrass.png b/Tiles/VernicFernGrass.png new file mode 100644 index 0000000000..811123ffa9 Binary files /dev/null and b/Tiles/VernicFernGrass.png differ diff --git a/Tiles/WulfrumPipes.cs b/Tiles/WulfrumPipes.cs index 70dd1b9f4a..2f18bbee2c 100644 --- a/Tiles/WulfrumPipes.cs +++ b/Tiles/WulfrumPipes.cs @@ -5,7 +5,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -28,7 +27,7 @@ namespace CalamityMod.Tiles Main.tileBlockLight[Type] = true; HitSound = SoundID.Item52; - DustType = 83; + DustType = DustID.Tungsten; AddMapEntry(new Color(128, 90, 77)); Main.tileLighted[Type] = true; } diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 5d523812fc..dc23b8b00c 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -23,6 +23,7 @@ using CalamityMod.NPCs.SlimeGod; using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MonoMod.Utils; @@ -111,12 +112,7 @@ namespace CalamityMod.UI BossMainHPBar = Request("CalamityMod/UI/MiscTextures/BossHPMainBar", AssetRequestMode.ImmediateLoad).Value; BossComboHPBar = Request("CalamityMod/UI/MiscTextures/BossHPComboBar", AssetRequestMode.ImmediateLoad).Value; BossSeperatorBar = Request("CalamityMod/UI/MiscTextures/BossHPSeperatorBar", AssetRequestMode.ImmediateLoad).Value; - - PlatformID id = Environment.OSVersion.Platform; - if (id == PlatformID.Win32NT) - HPBarFont = Request("CalamityMod/Fonts/HPBarFont", AssetRequestMode.ImmediateLoad).Value; - else - HPBarFont = FontAssets.MouseText.Value; + HPBarFont = Request("CalamityMod/Fonts/HPBarFont", AssetRequestMode.ImmediateLoad).Value; } OneToMany = new Dictionary(); @@ -141,12 +137,11 @@ namespace CalamityMod.UI OneToMany[NPCID.PrimeCannon] = SkelePrime; OneToMany[NPCID.PrimeLaser] = SkelePrime; - int[] Golem = new int[] { NPCID.Golem, NPCID.GolemFistLeft, NPCID.GolemFistRight, NPCID.GolemHead, NPCID.GolemHeadFree }; + int[] Golem = new int[] { NPCID.Golem, NPCID.GolemFistLeft, NPCID.GolemFistRight, NPCID.GolemHead }; OneToMany[NPCID.Golem] = Golem; OneToMany[NPCID.GolemFistLeft] = Golem; OneToMany[NPCID.GolemFistRight] = Golem; OneToMany[NPCID.GolemHead] = Golem; - OneToMany[NPCID.GolemHeadFree] = Golem; int[] Saucer = new int[] { NPCID.MartianSaucerCore, NPCID.MartianSaucerTurret, NPCID.MartianSaucerCannon }; OneToMany[NPCID.MartianSaucerCore] = Saucer; @@ -215,8 +210,10 @@ namespace CalamityMod.UI NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), @@ -277,10 +274,9 @@ namespace CalamityMod.UI // Hardmode Modded. NPCType(), - NPCType(), + NPCType(), NPCType(), NPCType(), - NPCType(), NPCType(), //Clone's brothers NPCType(), diff --git a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs index 7eb231b5e6..aaf38e9686 100644 --- a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs +++ b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs @@ -6,7 +6,6 @@ using Terraria; using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.UI; using Terraria.UI.Chat; diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index 391c334539..135d54f0c9 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -233,20 +233,20 @@ namespace CalamityMod.UI.CalamitasEnchants if (Main.myPlayer == player.whoAmI && !armsArePresent) { // Yes, this is a LOT of damage but given the limited range of this thing it needs to be extremely powerful when it does actually hit. - var source = player.GetSource_ItemUse(player.ActiveItem()); + var source = player.GetSource_ItemUse(player.HeldItem); float taintedRatio = 5f; - int damage = (int)(player.ActiveItem().damage * taintedRatio); - Projectile blade = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, player.ActiveItem().type); + int damage = (int)(player.HeldItem.damage * taintedRatio); + Projectile blade = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, player.HeldItem.type); blade.localAI[0] = 0f; blade.originalDamage = damage; - blade.OriginalArmorPenetration = player.ActiveItem().ArmorPenetration; - blade.OriginalCritChance = player.ActiveItem().crit; + blade.OriginalArmorPenetration = player.HeldItem.ArmorPenetration; + blade.OriginalCritChance = player.HeldItem.crit; - blade = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1f, player.ActiveItem().type); + blade = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1f, player.HeldItem.type); blade.localAI[0] = -80f; blade.originalDamage = damage; - blade.OriginalArmorPenetration = player.ActiveItem().ArmorPenetration; - blade.OriginalCritChance = player.ActiveItem().crit; + blade.OriginalArmorPenetration = player.HeldItem.ArmorPenetration; + blade.OriginalCritChance = player.HeldItem.crit; } }, item => item.IsEnchantable() && item.damage > 0 && item.CountsAsClass() && !item.noUseGraphic && item.shoot > ProjectileID.None), @@ -319,7 +319,7 @@ namespace CalamityMod.UI.CalamitasEnchants { [ModContent.ItemType()] = ModContent.ItemType(), [ModContent.ItemType()] = ModContent.ItemType(), - [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), [ModContent.ItemType()] = ModContent.ItemType(), [ModContent.ItemType()] = ModContent.ItemType() }; diff --git a/UI/CanvasPaintingUI.cs b/UI/CanvasPaintingUI.cs index 30119f2d8d..a2a0d1755f 100644 --- a/UI/CanvasPaintingUI.cs +++ b/UI/CanvasPaintingUI.cs @@ -8,7 +8,6 @@ using Terraria.Audio; using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.UI { @@ -63,11 +62,9 @@ namespace CalamityMod.UI float paintingFrameScale = painting.scale; Vector2 paintingFramePosition = painting.framePosition; - bool hideUI = Main.keyState.IsKeyDown(Keys.LeftShift); + bool hideUI = Main.keyState.PressingShift(); - Texture2D tex = TextureAssets.Tile[ModContent.TileType()].Value; - if (p.CurrentlyViewedCanvasType == 1) - tex = TextureAssets.Tile[ModContent.TileType()].Value; + Texture2D tex = TextureAssets.Tile[p.CurrentlyViewedCanvasType].Value; // This is the length and width of the UI box, which is a square float dimension = Main.screenHeight * 0.66f; diff --git a/UI/CooldownRackUI.cs b/UI/CooldownRackUI.cs index 8c0469ba29..99b82c736b 100644 --- a/UI/CooldownRackUI.cs +++ b/UI/CooldownRackUI.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using CalamityMod.Cooldowns; +using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -19,7 +20,7 @@ namespace CalamityMod.UI get { // Option 1: Always use compact icons if configured to do so. - if (CalamityClientConfig.Instance.CooldownDisplay == 1) + if (CalamityClientConfig.Instance.CooldownDisplay == CooldownDisplayOptions.Compact) return true; // Option 2: If there are too many cooldowns, auto switch to compact mode. @@ -43,7 +44,7 @@ namespace CalamityMod.UI // 1 - The game isn't even on the game screen yet. // 2 - The player's inventory is open. // 3 - Cooldown display is completely disabled. - if (Main.gameMenu || Main.playerInventory || CalamityClientConfig.Instance.CooldownDisplay < 1) + if (Main.gameMenu || Main.playerInventory || CalamityClientConfig.Instance.CooldownDisplay == CooldownDisplayOptions.Hidden) return; IList cooldownsToDraw = Main.LocalPlayer.GetDisplayedCooldowns(); diff --git a/UI/DebuffSystem/BestiaryDebuffInfo.cs b/UI/DebuffSystem/BestiaryDebuffInfo.cs index 811012d588..30f3f2c546 100644 --- a/UI/DebuffSystem/BestiaryDebuffInfo.cs +++ b/UI/DebuffSystem/BestiaryDebuffInfo.cs @@ -9,7 +9,7 @@ using Terraria.UI; namespace CalamityMod.UI.DebuffSystem { - public class BestiaryDebuffInfo : IBestiaryInfoElement + public class BestiaryDebuffInfo : IBestiaryInfoElement, IBestiaryPrioritizedElement, ICategorizedBestiaryInfoElement { public string[] elements; @@ -18,6 +18,11 @@ namespace CalamityMod.UI.DebuffSystem this.elements = elements; } + // Below base stats (damage/defense/etc) + public float OrderPriority => -1f; + + public UIBestiaryEntryInfoPage.BestiaryInfoCategory ElementCategory => UIBestiaryEntryInfoPage.BestiaryInfoCategory.Stats; + public UIElement ProvideUIElement(BestiaryUICollectionInfo info) { // Don't show debuff info until stats are unlocked diff --git a/UI/DialogueDisplay/Assets/DialogueArrow.png b/UI/DialogueDisplay/Assets/DialogueArrow.png new file mode 100644 index 0000000000..18a8a71a0e Binary files /dev/null and b/UI/DialogueDisplay/Assets/DialogueArrow.png differ diff --git a/UI/DialogueDisplay/DialogueDisplayDebugItem.cs b/UI/DialogueDisplay/DialogueDisplayDebugItem.cs new file mode 100644 index 0000000000..1546777fd7 --- /dev/null +++ b/UI/DialogueDisplay/DialogueDisplayDebugItem.cs @@ -0,0 +1,32 @@ +using Terraria.ID; +using Terraria.ModLoader; +using Terraria; +using CalamityMod.UI.DialogueDisplay.DisplayEffects; + +namespace CalamityMod.UI.DialogueDisplay +{ + public class DialogueDisplayDebugItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Debug"; + public override string Texture => "CalamityMod/Items/Weapons/Summon/StaffOfNecrosteocytes"; + public override void SetDefaults() + { + Item.width = 25; + Item.height = 29; + Item.rare = ItemRarityID.Red; + Item.useAnimation = Item.useTime = 20; + Item.useStyle = ItemUseStyleID.HoldUp; + } + public override bool? UseItem(Player player) + { + int slot = DialogueDisplaySystem.GetSlot("OceanBlue"); + + if (slot != -1) + DialogueDisplaySystem.ProgressDialogue(slot); + else + DialogueDisplaySystem.StartDialogue("OceanBlue", player.Center, 0, -1, effects: new WhisperingPearlEffects()); + + return true; + } + } +} diff --git a/UI/DialogueDisplay/DialogueDisplayUI.cs b/UI/DialogueDisplay/DialogueDisplayUI.cs new file mode 100644 index 0000000000..31414b402b --- /dev/null +++ b/UI/DialogueDisplay/DialogueDisplayUI.cs @@ -0,0 +1,1315 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text.Json.Serialization; +using CalamityMod.Dialogues; +using CalamityMod.Packets; +using CalamityMod.UI.DialogueDisplay.DialogueEvents; +using CalamityMod.UI.DialogueDisplay.DisplayEffects; +using CalamityMod.UI.DialogueDisplay.TextEffects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.UI; +using Terraria.UI.Chat; +using static CalamityMod.Packets.StartDialogueDisplayPacket; +using static ReLogic.Graphics.DynamicSpriteFont; + +namespace CalamityMod.UI.DialogueDisplay +{ + internal class DialogueDisplayUI : UIState + { + internal static readonly Dictionary Dialogues = []; + internal static readonly List DialoguesToRemove = []; + + public override void Update(GameTime gameTime) + { + foreach (int index in DialoguesToRemove) + { + RemoveChild(Dialogues[index].ui); + Dialogues.Remove(index); + } + DialoguesToRemove.Clear(); + + foreach (var pair in Dialogues) + { + int slot = pair.Key; + var dialog = pair.Value; + + DialogueDisplay ui = dialog.ui; + DialogueTextData data = dialog.data; + + if (ui.DisplayEffects.FadeWhenTooFar) + { + float distFromSource = Vector2.Distance(Main.LocalPlayer.Center, ui.Position); + // If the player is too far, cancel the dialogue + if (distFromSource > ui.DisplayEffects.FadeBuffer + ui.DisplayEffects.FadeDistance) + { + DialoguesToRemove.Add(slot); + continue; + } + } + + if (dialog.entity != null) + { + if (dialog.entity.active) + dialog.ui.Position = dialog.entity.Center; + else if (ui.DisplayEffects.DespawnWithAttachedNPC) + dialog.ui.ClosingDialogue = true; + else + { + dialog.ui.Position = dialog.entity.Center; + dialog.entity = null; + } + } + + if (dialog.upTime != -1) + { + if (ui.Uptime >= dialog.upTime) + { + if (ui.ProgressDialogue) + ui.SwitchingPage = true; + else + ui.ClosingDialogue = true; + } + } + + if (ui.DialoguePage.Event != null) + { + if (ui.DialoguePage.Event.IsOver) + { + if (!ui.ProgressDialogue) + DialoguesToRemove.Add(slot); + else + { + if (++data.Page >= data.PageCount) + DialoguesToRemove.Add(slot); + else + { + ui.DialoguePage = data.Pages[data.Page]; + ui.SwitchingPage = false; + ui.SwitchCounter = 0; + Activate(); + } + } + return; + } + } + if (ui.Switching) + { + if (ui.SwitchCounter >= ui.DisplayEffects.TimeToDisappear) + { + if (ui.ClosingDialogue || !ui.ProgressDialogue) + DialoguesToRemove.Add(slot); + else + { + if (++data.Page >= data.PageCount) + DialoguesToRemove.Add(slot); + else + { + ui.DialoguePage = data.Pages[data.Page]; + ui.SwitchingPage = false; + ui.SwitchCounter = 0; + Activate(); + } + } + continue; + } + ui.SwitchCounter++; + } + } + + base.Update(gameTime); + } + } + + public class DialogueDisplay : UIElement + { + public static readonly Dictionary DialogueSounds = new() + { + { "Amidias", SoundID.NPCHit1 }, + { "Otonilou", SoundID.NPCHit25 } + }; + + /// + /// How long this dialogue has existed + /// + public int DialogueTimer = 0; + /// + /// The position from which the text originates + /// + public Vector2 Position = Vector2.Zero; + + public bool SwitchingPage = false; + public bool ProgressDialogue = true; + public bool ClosingDialogue = false; + public bool ScreenLocked; + + public Vector2 TextSize { get; private set; } + public Vector2 SizeOffsetFromStart { get; private set; } + + public bool Switching => SwitchingPage || ClosingDialogue; + internal int SwitchCounter = 0; + + internal DialoguePage DialoguePage; + internal DisplayEffect DisplayEffects; + internal string Text = ""; + private int TextTimer = 0; + internal int textIndex = 0; + internal int Uptime = 0; + internal Asset Font; + + //Effects + internal Dictionary UniqueColors = []; + internal Dictionary UniqueBorderColors = []; + + internal Dictionary Pauses = []; + internal Dictionary> TextEffects = []; + internal Dictionary UniqueScales = []; + internal List LineBreakIndexes = []; + + private DialogueCharacterData[] CharacterData; + private Color BaseColor = Color.White; + private Color BaseBorderColor = Color.Black; + internal bool Crawling = true; + private int storedDelay = 0; + private bool lockDelay = false; + private float WrapWidth = -1; + + public DialogueDisplay(DialoguePage textData, DisplayEffect displayEffects, int startPage = 0, bool screenLocked = false, float wrapWidth = -1, Asset? font = null) + { + DisplayEffects = displayEffects; + ScreenLocked = screenLocked; + DialoguePage = textData; + DisplayEffects = displayEffects; + Font = font ?? FontAssets.MouseText; + WrapWidth = wrapWidth; + } + + public override void OnActivate() + { + Text = ""; + UniqueColors = []; + UniqueBorderColors = []; + Pauses = []; + TextEffects = []; + UniqueScales = []; + + if (DialoguePage.Event != null) + return; + + if (Font is null || !Font.IsLoaded) + return; + + int fullLength = 0; + List lines = []; + for (int i = 0; i < DialoguePage.Lines.Length; i++) + { + string fullLine = DialoguePage.Lines[i]; + + FindEffects(ref fullLine, fullLength); + + if (fullLine[^1] != ' ') + fullLine += ' '; + + lines.Add(fullLine); + fullLength += fullLine.Length; + } + + if (WrapWidth != -1) + { + for (int i = 0; i < lines.Count; i++) + { + string line = lines[i]; + if (line[^1] == ' ') + line = line.Remove(line.Length - 1, 1); + + int finalIndex = 0; + float width = MeasureString(line, Font.Value).X; + + if (width > WrapWidth) + { + string yoinked = ""; + do + { + finalIndex = line.LastIndexOf(' '); + if (finalIndex < line.Length - 1) + finalIndex++; + yoinked = line.Substring(finalIndex) + yoinked; + line = line.Remove(finalIndex); + } while (MeasureString(line, Font.Value).X > WrapWidth); + + lines[i] = line; + if (yoinked[0] == ' ') + yoinked = yoinked.Remove(0, 1); + + if (i >= lines.Count - 1) + lines.Add(yoinked); + else + lines[i + 1] = yoinked + lines[i + 1]; + } + } + } + + fullLength = 0; + int[] lineLengths = new int[lines.Count]; + LineBreakIndexes.Clear(); + for (int i = 0; i < lines.Count; i++) + { + lineLengths[i] = lines[i].Length; + + Text += lines[i]; + + fullLength += lines[i].Length; + LineBreakIndexes.Add(fullLength); + } + + if (DialoguePage.BaseColor != null) + BaseColor = DialogueDisplaySystem.GetColorFromHex(DialoguePage.BaseColor); + + if (DialoguePage.BaseBorderColor != null) + BaseBorderColor = DialogueDisplaySystem.GetColorFromHex(DialoguePage.BaseBorderColor); + else + { + BaseBorderColor = BaseColor * DialoguePage.BorderDarkening; + BaseBorderColor.A = 255; + } + + CharacterData = new DialogueCharacterData[Text.Length]; + + for (int i = 0; i < Text.Length; i++) + { + int j = 0; + int summedLength = 0; + for (; j < lineLengths.Length; j++) + { + summedLength += lineLengths[j]; + if (i < summedLength) + break; + } + CharacterData[i] = new(i, Text.Length, j); + } + + textIndex = 0; + Crawling = true; + TextTimer = 0; + storedDelay = 0; + lockDelay = false; + DialogueTimer = 0; + Uptime = 0; + + Vector2 zero = Vector2.Zero; + bool newLine = true; + + float textWidth = 0f; + + float highestFirstLineYScale = 1f; + for (int j = 0; j < Text.Length; j++) + { + if (Text[j] == '\n') + break; + if (UniqueScales.TryGetValue(j, out Vector2 uniqueScale) && uniqueScale.Y > highestFirstLineYScale) + highestFirstLineYScale = uniqueScale.Y; + } + + SizeOffsetFromStart = new(8, 16 * highestFirstLineYScale); + + for (int i = 0; i < Text.Length; i++) + { + char c = Text[i]; + + #region Positioning + Vector2 scale = Vector2.One; + if (UniqueScales.TryGetValue(i, out Vector2 result)) + scale = result; + else if (DialoguePage.TextScale != -1) + scale *= DialoguePage.TextScale; + + //Checks for Special Characters, and handles Line Breaks + switch (c) + { + case '\n': + if (zero.X > textWidth) + textWidth = zero.X; + + zero.X = 0; + + float highestYscale = 1f; + for (int j = i + 1; j < Text.Length; j++) + { + if (Text[j] == '\n') + break; + if (UniqueScales.TryGetValue(j, out Vector2 uniqueScale) && uniqueScale.Y > highestYscale) + highestYscale = uniqueScale.Y; + } + zero.Y += Font.Value.LineSpacing * highestYscale; + newLine = true; + continue; + case '\r': + continue; + } + + if (LineBreakIndexes.Contains(i)) + { + if (zero.X > textWidth) + textWidth = zero.X; + + zero.X = 0; + + float highestYscale = 1f; + for (int j = i + 1; j < Text.Length; j++) + { + if (Text[j] == '\n') + break; + if (UniqueScales.TryGetValue(j, out Vector2 uniqueScale) && uniqueScale.Y > highestYscale) + highestYscale = uniqueScale.Y; + } + zero.Y += Font.Value.LineSpacing * highestYscale; + newLine = true; + } + + //Sets the character's position within the full text + SpriteCharacterData spriteData = Font.Value.SpriteCharacters[c]; + Vector3 kerning = spriteData.Kerning; + Rectangle padding = spriteData.Padding; + + if (newLine) + kerning.X = Math.Max(kerning.X, 0f); + else + zero.X += Font.Value.CharacterSpacing * scale.X; + + zero.X += kerning.X * scale.X; + Vector2 position = zero + spriteData.Glyph.Size() * 0.5f; + position.X += padding.X * scale.X; + position.Y += padding.Y * scale.Y; + + CharacterData[i].TextPosition = position - (Vector2.UnitY * scale.Y * Font.Value.LineSpacing * 0.5f); + + zero.X += (kerning.Y + kerning.Z) * scale.X; + newLine = false; + #endregion + } + + if (zero.X > textWidth) + textWidth = zero.X; + float textHeight = zero.Y; + + if (DialoguePage.AlignType != Alignment.Left) + { + for (int i = 0; i < lineLengths.Length; i++) + { + DialogueCharacterData furthestChar = CharacterData.Last(d => d.LineNumber == i && Text[d.Index] != '\n'); + float xPos = furthestChar.TextPosition.X; + float dif = textWidth - xPos; + if (DialoguePage.AlignType == Alignment.Center) + foreach (var c in CharacterData.Where(c => c.LineNumber == i)) + c.TextPosition.X += dif / 2f; + else + foreach (var c in CharacterData.Where(c => c.LineNumber == i)) + c.TextPosition.X += dif; + } + } + + TextSize = new Vector2(textWidth + 8, textHeight + 12) + SizeOffsetFromStart; + } + + private void FindEffects(ref string fullLine, int fullLength) + { + Stack returnPoints = []; + Stack returnString = []; + + for (int j = 0; j < fullLine.Length; j++) + { + char c = fullLine[j]; + + if (c == '[') + { + int k = j + 1; + string currentData = "["; + bool readingData = true; + for (k = j + 1; k < fullLine.Length; k++) + { + if (fullLine[k] == ']') + break; + if (fullLine[k] == '[') + { + returnPoints.Push(j); + returnString.Push(currentData); + currentData = "["; + c = fullLine[k]; + j = k; + readingData = true; + } + else if (readingData) + { + currentData += fullLine[k]; + if (fullLine[k] == ':') + readingData = false; + } + + } + if (fullLine[k] != ']') + throw new Exception("[ was found without a ] after it."); + + string effect = fullLine[j..k]; + string ID = ""; + string Text = ""; + List Params = []; + List ColorParams = []; + List BorderColorParams = []; + string Param = ""; + bool readingText = false; + bool readingParams = false; + for (int l = 1; l < effect.Length; l++) + { + char ch = effect[l]; + if (ch == '(') + { + readingParams = true; + continue; + } + else if (ch == ':') + { + readingText = true; + continue; + } + else if (ch == ']') + break; + + if (readingText) + Text += ch; + else if (readingParams) + { + if (ch == ',' || ch == ')') + { + if (ID == "Colors") + { + if (float.TryParse(Param, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out float result)) + Params.Add(result); + else + ColorParams.Add(Param); + } + else if (ID == "BorderColors") + { + if (float.TryParse(Param, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out float result)) + Params.Add(result); + else + BorderColorParams.Add(Param); + } + else + { + if (float.TryParse(Param, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out float result)) + Params.Add(result); + else + throw new Exception("Invalid Parameter found"); + } + Param = ""; + } + else if (ch == ' ') + continue; + else + Param += ch; + } + else + ID += ch; + } + + fullLine = fullLine.Remove(j, k - j + 1); + fullLine = fullLine.Insert(j, Text); + + if (ID == "Pause") + { + int index = j + fullLength; + int storedLen = 0; + foreach (string s in returnString) + storedLen += s.Length; + + Pauses.Add(index - storedLen - 1, Params[0]); + } + else + { + for (int i = 0; i < Text.Length; i++) + { + int index = j + i + fullLength; + if (ID == "Colors") + { + int storedLen = 0; + foreach (string s in returnString) + storedLen += s.Length; + + UniqueColors.Add(index - storedLen, (Params.Count == 0 ? 0 : Params[0], Params.Count < 2 ? 1 : Params[1], [.. ColorParams])); + } + else if (ID == "BorderColors") + { + int storedLen = 0; + foreach (string s in returnString) + storedLen += s.Length; + + UniqueBorderColors.Add(index - storedLen, (Params.Count == 0 ? 0 : Params[0], Params.Count < 2 ? 1 : Params[1], [.. BorderColorParams])); + } + else if (ID == "Scale") + { + int storedLen = 0; + foreach (string s in returnString) + storedLen += s.Length; + + Vector2 scale; + if (Params.Count == 0) + scale = Vector2.One; + else if (Params.Count == 1) + scale = new(Params[0], Params[0]); + else + scale = new(Params[0], Params[1]); + + + UniqueScales.Add(index - storedLen, scale); + } + else + { + int storedLen = 0; + foreach (string s in returnString) + storedLen += s.Length; + + string path = "CalamityMod.UI.DialogueDisplay.TextEffects."; + Type t = Type.GetType(path + ID) ?? throw new Exception("Invalid text effect ID found"); + TextEffect te = (TextEffect)Activator.CreateInstance(t); + if (TextEffects.TryGetValue(index - storedLen, out var value)) + value.Add(new(te, [.. Params])); + else + TextEffects.Add(index - storedLen, [new(te, [.. Params])]); + } + } + } + + if (returnPoints.Count > 0) + { + j = returnPoints.Pop() - 1; + returnString.Pop(); + } + } + } + } + + private Vector2 MeasureString(string text, DynamicSpriteFont font) + { + if (text.Length == 0) + return Vector2.Zero; + + Vector2 zero = Vector2.Zero; + zero.Y = font.LineSpacing; + float val = 0f; + int num = 0; + float num2 = 0f; + bool newLine = true; + for (int i = 0; i < text.Length; i++) + { + char c = text[i]; + Vector2 scale = Vector2.One; + if (UniqueScales.TryGetValue(i, out Vector2 result)) + scale = result; + else if (DialoguePage.TextScale != -1) + scale *= DialoguePage.TextScale; + + //Checks for Special Characters, and handles Line Breaks + switch (c) + { + case '\n': + zero.X = 0; + + float highestYscale = 1f; + for (int j = i + 1; j < text.Length; j++) + { + if (text[j] == '\n') + break; + if (UniqueScales.TryGetValue(j, out Vector2 uniqueScale) && uniqueScale.Y > highestYscale) + highestYscale = uniqueScale.Y; + } + zero.Y += font.LineSpacing * highestYscale; + newLine = true; + continue; + case '\r': + continue; + } + + //Sets the character's position within the full text + SpriteCharacterData spriteData = font.SpriteCharacters[c]; + Vector3 kerning = spriteData.Kerning; + Rectangle padding = spriteData.Padding; + + if (newLine) + kerning.X = Math.Max(kerning.X, 0f); + else + zero.X += font.CharacterSpacing * scale.X; + + zero.X += kerning.X * scale.X; + Vector2 position = zero + spriteData.Glyph.Size() * 0.5f; + position.X += padding.X * scale.X; + position.Y += padding.Y * scale.Y; + + zero.X += (kerning.Y + kerning.Z) * scale.X; + newLine = false; + } + + zero.X += Math.Max(num2, 0f); + zero.Y += num * font.LineSpacing; + zero.X = Math.Max(zero.X, val); + return zero; + } + + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + + if (DialoguePage.Event != null) + DialoguePage.Event.UpdateEvent(); + else if (!Switching) + { + if (DisplayEffects.FadeWhenTooFar) + { + float distFromSource = Vector2.Distance(Main.LocalPlayer.Center, Position); + SwitchCounter = (int)(MathHelper.Clamp((distFromSource - DisplayEffects.FadeBuffer) / DisplayEffects.FadeDistance, 0f, 1f) * DisplayEffects.TimeToDisappear); + } + + int textDelay = DialoguePage.TextDelay; + int inPunctuationDelay = DialoguePage.InPunctuationDelay; + + if (DialoguePage.Event != null && !DialoguePage.Event.IsOver) + DialoguePage.Event.UpdateEvent(); + + if (textIndex < Text.Length - 1) + { + int delay; + int loopCounter = 0; + bool forcedPause = false; + + do + { + if (TextTimer == 0) + { + if (!lockDelay) + { + char currentChar = Text[textIndex]; + PunctuationData data = new(); + + if (DialoguePage.BasePunctuationDelay != null) + data = DialoguePage.BasePunctuationDelay; + + if (DialoguePage.PunctuationDelays != null) + { + if (DialoguePage.PunctuationDelays.TryGetValue(currentChar.ToString(), out var value)) + data = value; + } + + bool shouldApplyDelay = IsStoppingPunctuation(currentChar, textIndex == 0 ? null : Text[textIndex - 1], textIndex == Text.Length - 1 ? null : Text[textIndex + 1]); + + if (shouldApplyDelay) + { + if (data.ForceSet) + storedDelay = data.Delay; + else + storedDelay += data.Delay; + } + + if (data.Locks) + lockDelay = true; + } + + if (Pauses.TryGetValue(textIndex, out float pause)) + { + storedDelay = (int)(pause * 60); + forcedPause = true; + } + } + else if(Pauses.ContainsKey(textIndex)) + forcedPause = true; + + int delayToUse = (IsPunctuation(Text[textIndex]) && textIndex > 0 && IsPunctuation(Text[textIndex - 1])) ? inPunctuationDelay : textDelay; + + bool shouldIncludeStored = Text[textIndex] == ' ' || Text[textIndex] == '\n' || forcedPause; + delay = (shouldIncludeStored && storedDelay > 0 ? delayToUse + storedDelay : delayToUse); + + if (loopCounter == 0) + TextTimer++; + + if ((delay == 0 || (TextTimer + loopCounter) % delay == 0) && TextTimer >= 0) + { + if (Text[textIndex] == ' ' || forcedPause) + { + storedDelay = 0; + lockDelay = false; + } + else + { + string speaker = null; + if (DialoguePage.Speaker != null) + speaker = DialoguePage.Speaker; + if (speaker != null && DialogueSounds.TryGetValue(speaker, out var value)) + SoundEngine.PlaySound(value); + } + + TextTimer = 0; + ++textIndex; + } + + if (delay != 0) + break; + + loopCounter++; + } while (delay == 0 && textIndex < Text.Length && TextTimer >= 0); + } + else + Crawling = false; + } + + if (!Crawling) + Uptime++; + DialogueTimer++; + } + + protected override void DrawSelf(SpriteBatch spriteBatch) + { + Vector2 textTop = DisplayEffects.TextOffsetFromStart(Position, TextSize); + Vector2 pageTop = textTop - SizeOffsetFromStart; + + DisplayEffects.PreDraw(spriteBatch, pageTop, TextSize, DialogueTimer, SwitchCounter); + + #region Shadow Drawing + for (int i = 0; i < textIndex; i++) + { + char c = Text[i]; + + if (c == '\r' || c == '\n') + continue; + + if (CharacterData == null) + Activate(); + + Vector2 drawPos; + float rotation = 0f; + float opacity = 1f; + Vector2 scale = Vector2.One; + if (UniqueScales.TryGetValue(i, out Vector2 result)) + scale = result; + + Color color; + if (UniqueColors.TryGetValue(i, out var textColors)) + { + Color[] colors = new Color[textColors.hexcodes.Length]; + for (int j = 0; j < colors.Length; j++) + colors[j] = DialogueDisplaySystem.GetColorFromHex(textColors.hexcodes[j]); + + color = CalamityUtils.MulticolorLerp((Main.GlobalTimeWrappedHourly * textColors.gradiantSpeed) + (i * textColors.IndexOffset), colors); + } + else + color = BaseColor; + + Color borderColor; + if (UniqueBorderColors.TryGetValue(i, out var borderColors)) + { + Color[] colors = new Color[borderColors.hexcodes.Length]; + for (int j = 0; j < colors.Length; j++) + colors[j] = DialogueDisplaySystem.GetColorFromHex(borderColors.hexcodes[j]); + + borderColor = CalamityUtils.MulticolorLerp((Main.GlobalTimeWrappedHourly * borderColors.gradiantSpeed) + (i * borderColors.IndexOffset), colors); + } + else + borderColor = BaseBorderColor; + + if (CharacterData[i].Timer < DisplayEffects.TimeToAppear) + { + drawPos = DisplayEffects.AppearPositioning(Position, textTop + CharacterData[i].TextPosition, CharacterData[i].Timer, CharacterData[i]); + opacity = DisplayEffects.AppearOpacity(opacity, CharacterData[i].Timer, CharacterData[i]); + color = DisplayEffects.AppearColoring(color, CharacterData[i].Timer, CharacterData[i]); + rotation = DisplayEffects.AppearRotation(rotation, CharacterData[i].Timer, CharacterData[i]); + scale = DisplayEffects.AppearScale(scale, CharacterData[i].Timer, CharacterData[i]); + } + else + drawPos = textTop + CharacterData[i].TextPosition; + + if (SwitchCounter > 0) + { + drawPos = DisplayEffects.DisappearPositioning(drawPos, SwitchCounter, CharacterData[i]); + opacity = DisplayEffects.DisappearOpacity(opacity, SwitchCounter, CharacterData[i]); + color = DisplayEffects.DisappearColoring(color, SwitchCounter, CharacterData[i]); + rotation = DisplayEffects.DisappearRotation(rotation, SwitchCounter, CharacterData[i]); + scale = DisplayEffects.DisappearScale(scale, SwitchCounter, CharacterData[i]); + } + + if (!ScreenLocked) + drawPos -= Main.screenPosition; + + foreach (var l in TextEffects.Where(v => v.Key == i)) + foreach ((TextEffect Effect, float[] args) in l.Value) + { + drawPos = Effect.ModifyPos(drawPos, CharacterData[i], args); + + rotation = Effect.ModifyRot(rotation, CharacterData[i], args); + + color = Effect.ModifyColor(color, CharacterData[i], args); + + scale = Effect.ModifyScale(scale, CharacterData[i], args); + } + + SpriteCharacterData spriteData = Font.Value.SpriteCharacters[c]; + Vector2 origin = spriteData.Glyph.Size() * 0.5f; + + CharacterData[i].SetDrawInfo(drawPos, spriteData.Glyph, color * opacity, rotation, scale); + + foreach (var l in TextEffects.Where(v => v.Key == i)) + foreach ((TextEffect Effect, float[] args) in l.Value) + Effect.PreDraw(spriteBatch, spriteData.Texture, CharacterData[i]); + + for (int j = 0; j < ChatManager.ShadowDirections.Length; j++) + spriteBatch.Draw(spriteData.Texture, drawPos + (ChatManager.ShadowDirections[j] * 2), spriteData.Glyph, borderColor * opacity, rotation, origin, scale, SpriteEffects.None, 0); + } + #endregion + + #region Character Drawing + for (int i = 0; i < textIndex; i++) + { + char c = Text[i]; + + if (c == '\r' || c == '\n') + continue; + + if (CharacterData == null) + Activate(); + + SpriteCharacterData spriteData = Font.Value.SpriteCharacters[c]; + Vector2 origin = spriteData.Glyph.Size() * 0.5f; + + spriteBatch.Draw(spriteData.Texture, CharacterData[i].DrawPosition, spriteData.Glyph, CharacterData[i].DrawColor, CharacterData[i].Rotation, origin, CharacterData[i].Scale, SpriteEffects.None, 0); + + foreach (var l in TextEffects.Where(v => v.Key == i)) + foreach ((TextEffect Effect, float[] args) in l.Value) + Effect.PostDraw(spriteBatch, spriteData.Texture, CharacterData[i]); + + CharacterData[i].Timer++; + } + #endregion + + DisplayEffects.PostDraw(spriteBatch, pageTop, TextSize, DialogueTimer, SwitchCounter); + } + + private static bool IsStoppingPunctuation(char current, char? before, char? after) + { + if (IsPunctuation(current)) + { + bool hasLetterBefore = before.HasValue && char.IsLetter(before.Value); + bool hasLetterAfter = after.HasValue && char.IsLetter(after.Value); + bool isMidWord = hasLetterBefore && hasLetterAfter; + + if (!isMidWord) + return true; + } + + return false; + } + + private static bool IsPunctuation(char c) + { + UnicodeCategory category = char.GetUnicodeCategory(c); + return category >= UnicodeCategory.ConnectorPunctuation && category <= UnicodeCategory.OtherPunctuation; + } + } + + public class DialogueDisplaySystem : ModSystem + { + internal static DialogueDisplayUI State; + + internal static UserInterface UI; + + public enum DisplayEffectID + { + Invalid = -1, + None, + AlwaysOnScreen, + BossText, + Built, + WhisperingPearls + } + + public static DisplayEffectID GetID(object obj) + { + if (obj is not DisplayEffect) + return DisplayEffectID.Invalid; + + return obj switch + { + AlwaysOnScreen => DisplayEffectID.AlwaysOnScreen, + BossText => DisplayEffectID.BossText, + BuiltEffect => DisplayEffectID.Built, + WhisperingPearlEffects => DisplayEffectID.WhisperingPearls, + _ => DisplayEffectID.None + }; + } + + public static DisplayEffect GetEffect(DisplayEffectID id) + { + return id switch + { + DisplayEffectID.AlwaysOnScreen => new AlwaysOnScreen(), + DisplayEffectID.BossText => new BossText(), + DisplayEffectID.Built => new BuiltEffect(), + DisplayEffectID.WhisperingPearls => new WhisperingPearlEffects(), + _ => new DisplayEffect() + }; + } + + public override void Load() + { + if (!Main.dedServ) + { + UI = new(); + State = new(); + State.Activate(); + } + } + + public override void ModifyInterfaceLayers(List layers) + { + int preInventory = layers.FindIndex(layer => layer.Name == "Vanilla: Interface Logic 2"); + if (preInventory != -1) + { + layers.Insert(preInventory, new LegacyGameInterfaceLayer("Dialogue Display", () => + { + UI.Draw(Main.spriteBatch, new()); + return true; + }, InterfaceScaleType.Game)); + } + } + + public override void UpdateUI(GameTime gameTime) + { + if (UI?.CurrentState != null) + UI?.Update(gameTime); + } + + public static Color GetColorFromHex(string hex) + { + System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml('#' + hex); + int r = Convert.ToInt16(color.R); + int g = Convert.ToInt16(color.G); + int b = Convert.ToInt16(color.B); + return new Color(r, g, b); + } + + /// + /// Returns the slot of the first dialogue instance with the coorisponding name + /// + public static int GetSlot(string name) + { + foreach (var pair in DialogueDisplayUI.Dialogues) + if (pair.Value.name == name) + return pair.Key; + return -1; + } + + /// + /// Manually progresses dialogue + /// + public static void ProgressDialogue(int slot) + { + if (DialogueDisplayUI.Dialogues.TryGetValue(slot, out var val)) + { + DialogueDisplay display = val.ui; + if (display.SwitchingPage) + return; + + // If the text crawl hasnt finished, finish it instantly + if (display.textIndex < display.Text.Length - 1) + display.textIndex = display.Text.Length - 1; + // If the text crawl has finished, progress to the next page or finish if we're out of pages + else + display.SwitchingPage = true; + } + } + + /// + /// Ends the dialogue if it exists in the world + /// + /// The name of the dialogue's localization key + public static void EndDialogue(int slot) + { + if (DialogueDisplayUI.Dialogues.TryGetValue(slot, out var val)) + val.ui.ClosingDialogue = true; + } + + public static void RemoveDialogue(int slot) + { + DialogueDisplayUI.DialoguesToRemove.Add(slot); + } + + public static bool ContainsDialogueKey(string key) => DialogueDisplayUI.Dialogues.Any(d => d.Value.name == key); + + /// + /// Creates a dialogue instance in the world + /// + /// The name of the dialogue's localization key + /// The position of the text in the world + public static int StartDialogue(string name, Vector2 startPosition, int startIndex = 0, int Uptime = -1, bool progressDialogue = true, DisplayEffect effects = null, float wrapWidth = -1, int toClient = -1, int ignoreClient = -1) + { + if (Main.dedServ) + { + StartDialogueDisplayPacket.Send(name, progressDialogue, startPosition, startIndex, Uptime, GetID(effects), wrapWidth, toClient, ignoreClient); + return -1; + } + else if (Main.netMode == NetmodeID.SinglePlayer) + { + return StartDialogueOnClient(name, startPosition, startIndex, Uptime, progressDialogue, effects, wrapWidth); + } + + return -1; + } + + public static int StartDialogueOnClient(string name, Vector2 startPosition, int startIndex = 0, int Uptime = -1, bool progressDialogue = true, DisplayEffect effects = null, float wrapWidth = -1) + { + if (Main.dedServ) + return -1; + + UI ??= new(); + State ??= new(); + effects ??= new DisplayEffect(); + + if (!DialogueLoader.TryGetDialogue(name, out var textData)) + { + CalamityMod.Log.Error($"Unable to find Dialogue Data for given name: '{name}'"); + return -1; + } + + if (startIndex >= textData.PageCount) + startIndex = textData.PageCount - 1; + + DialogueDisplay display = new(textData.Pages[startIndex], effects, wrapWidth: wrapWidth) + { + Position = startPosition, + ProgressDialogue = progressDialogue, + }; + + int slot; + for (slot = 0; slot <= DialogueDisplayUI.Dialogues.Count; slot++) + if (!DialogueDisplayUI.Dialogues.ContainsKey(slot)) + break; + + DialogueDisplayUI.Dialogues.Add(slot, (name, display, textData, null, Uptime)); + + State.Append(display); + display.Activate(); + + if (UI.CurrentState != State) + UI?.SetState(State); + + return slot; + } + + /// + /// Creates a dialogue instance in the world + /// + /// The name of the dialogue's localization key + /// The entity this dialogue will appear with + /// The entity this dialogue will appear with + public static int StartDialogue(string name, Entity entity, int startIndex = 0, int Uptime = -1, bool progressDialogue = true, DisplayEffect effects = null, float wrapWidth = -1, int toClient = -1, int ignoreClient = -1) + { + if (Main.dedServ) + { + StartDialogueDisplayPacket.Send(name, progressDialogue, entity is NPC ? EntityType.NPC : entity is Player ? EntityType.Player : EntityType.Projectile, entity is Projectile p ? p.identity : entity.whoAmI, startIndex, Uptime, GetID(effects), wrapWidth, toClient, ignoreClient); + return -1; + } + else if (Main.netMode == NetmodeID.SinglePlayer) + { + return StartDialogueOnClient(name, entity, startIndex, Uptime, progressDialogue, effects, wrapWidth); + } + + return -1; + } + + public static int StartDialogueOnClient(string name, Entity entity, int startIndex = 0, int Uptime = -1, bool progressDialogue = true, DisplayEffect effects = null, float wrapWidth = -1) + { + if (Main.dedServ) + return -1; + + UI ??= new(); + State ??= new(); + effects ??= new DisplayEffect(); + + if (!DialogueLoader.TryGetDialogue(name, out var textData)) + { + CalamityMod.Log.Error($"Unable to find Dialogue Data for given name: '{name}'"); + return -1; + } + + if (startIndex >= textData.PageCount) + startIndex = textData.PageCount - 1; + + DialogueDisplay display = new(textData[startIndex], effects, wrapWidth: wrapWidth) + { + Position = entity.Center, + ProgressDialogue = progressDialogue, + }; + + int slot; + for (slot = 0; slot <= DialogueDisplayUI.Dialogues.Count; slot++) + if (!DialogueDisplayUI.Dialogues.ContainsKey(slot)) + break; + + DialogueDisplayUI.Dialogues.Add(slot, (name, display, textData, entity, Uptime)); + + State.Append(display); + display.Activate(); + + if (UI.CurrentState != State) + UI?.SetState(State); + + return slot; + } + + /// + /// Resets all of the dialogue's variables + /// + public static void EndAllDialogue() + { + DialogueDisplayUI.Dialogues.Clear(); + State.RemoveAllChildren(); + UI?.SetState(null); + } + } + + public enum Alignment + { + None = -1, + Left, + Center, + Right + } + + public class DialogueTextData + { + public DialoguePage[] Pages { get; init; } + public DialoguePage this[int index] { get => Pages[index]; set => Pages[index] = value; } + + public int Page { get; set; } + public int PageCount => Pages.Length; + + public string DefaultColor { get; init; } + public string DefaultSpeaker { get; init; } + + public int DefaultScale { get; init; } + + public Alignment AlignType { get; init; } + + public int TextDelay { get; init; } + public int InPunctuationDelay { get; init; } + public PunctuationData BasePunctuationDelay { get; init; } + public int PunctuationDelayCap { get; init; } + public Dictionary PunctuationDelays { get; init; } + + /// + /// Only used for DialogueLoader + /// + public int Revision { get; init; } + + [JsonConstructor] + public DialogueTextData(DialoguePage[] Pages, int Page = 0, string DefaultColor = null, string DefaultSpeaker = null, int DefaultScale = 1, Alignment AlignType = 0, int TextDelay = 3, int InPunctuationDelay = -1, PunctuationData BasePunctuationDelay = null, int PunctuationDelayCap = 60, Dictionary PunctuationDelays = null) + { + this.Pages = Pages; + this.Page = Page; + this.DefaultColor = DefaultColor; + this.DefaultSpeaker = DefaultSpeaker; + this.DefaultScale = DefaultScale; + this.TextDelay = TextDelay; + this.InPunctuationDelay = InPunctuationDelay == -1 ? TextDelay : InPunctuationDelay; + this.BasePunctuationDelay = BasePunctuationDelay ?? new(); + this.PunctuationDelayCap = PunctuationDelayCap; + this.PunctuationDelays = PunctuationDelays ?? []; + this.AlignType = AlignType; + + foreach (DialoguePage p in Pages) + { + p.BaseColor ??= this.DefaultColor; + p.Speaker ??= this.DefaultSpeaker; + if (p.TextScale == -1) + p.TextScale = this.DefaultScale; + if (p.TextDelay == -1) + p.TextDelay = this.TextDelay; + if (p.InPunctuationDelay == -1) + p.InPunctuationDelay = this.InPunctuationDelay; + if (p.AlignType == Alignment.None) + p.AlignType = this.AlignType; + p.BasePunctuationDelay ??= this.BasePunctuationDelay; + if (p.PunctuationDelayCap == -1) + p.PunctuationDelayCap = this.PunctuationDelayCap; + p.PunctuationDelays ??= this.PunctuationDelays; + } + } + } + + public class DialoguePage + { + public string[] Lines { get; set; } + + public string BaseColor { get; set; } = null; + public string BaseBorderColor { get; set; } = null; + public float BorderDarkening { get; set; } = 0.25f; + public string Speaker { get; set; } = null; + + public int TextScale { get; set; } = -1; + public Alignment AlignType { get; set; } = Alignment.None; + + public int TextDelay { get; set; } = -1; + public int InPunctuationDelay { get; set; } = -1; + public PunctuationData BasePunctuationDelay { get; set; } = null; + public int PunctuationDelayCap { get; set; } = -1; + public Dictionary PunctuationDelays { get; set; } = null; + + public DialogueEvent Event { get; set; } = null; + } + + public class PunctuationData + { + public int Delay { get; set; } = 10; + public bool ForceSet { get; set; } = false; + public bool Locks { get; set; } = false; + } + + public class DialogueCharacterData(int index, int textLength, int lineNumber) + { + public int Timer = 0; + + #region Text Info + public int Index = index; + + public int TextLength = textLength; + + public int LineNumber = lineNumber; + + public float CompletionRatio => Index / (float)TextLength; + + public Vector2 TextPosition = Vector2.Zero; + #endregion + + #region Draw Info + public Vector2 DrawPosition; + public Rectangle Frame; + public Color DrawColor; + public float Rotation; + public Vector2 Scale; + + internal void SetDrawInfo(Vector2 drawPos, Rectangle frame, Color color, float rotation, Vector2 scale) + { + DrawPosition = drawPos; + Frame = frame; + DrawColor = color; + Rotation = rotation; + Scale = scale; + } + #endregion + } + +} diff --git a/UI/DialogueDisplay/DialogueEvents/DialogueEvent.cs b/UI/DialogueDisplay/DialogueEvents/DialogueEvent.cs new file mode 100644 index 0000000000..25f3ef9479 --- /dev/null +++ b/UI/DialogueDisplay/DialogueEvents/DialogueEvent.cs @@ -0,0 +1,18 @@ +namespace CalamityMod.UI.DialogueDisplay.DialogueEvents +{ + public abstract class DialogueEvent + { + public string ID { get; set; } + public string[] Args { get; set; } + + internal bool EventOver = true; + public bool IsOver => EventOver; + + internal int EventCounter = 0; + + public virtual void UpdateEvent() + { + EventCounter++; + } + } +} diff --git a/UI/DialogueDisplay/DialogueEvents/SoundEvent.cs b/UI/DialogueDisplay/DialogueEvents/SoundEvent.cs new file mode 100644 index 0000000000..2fc79a048f --- /dev/null +++ b/UI/DialogueDisplay/DialogueEvents/SoundEvent.cs @@ -0,0 +1,19 @@ +using ReLogic.Utilities; +using Terraria.Audio; + +namespace CalamityMod.UI.DialogueDisplay.DialogueEvents +{ + public class SoundEvent : DialogueEvent + { + SoundStyle style; + SlotId soundSlot; + + public override void UpdateEvent() + { + if (EventCounter == 0) + soundSlot = SoundEngine.PlaySound(style = new SoundStyle(Args[0])); + else if (!SoundEngine.TryGetActiveSound(soundSlot, out var result) || result.Style != style) + EventOver = true; + } + } +} diff --git a/UI/DialogueDisplay/DisplayEffects/AlwaysOnScreen.cs b/UI/DialogueDisplay/DisplayEffects/AlwaysOnScreen.cs new file mode 100644 index 0000000000..df10a78a8f --- /dev/null +++ b/UI/DialogueDisplay/DisplayEffects/AlwaysOnScreen.cs @@ -0,0 +1,47 @@ +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; +using Terraria; +using Microsoft.Xna.Framework; + +namespace CalamityMod.UI.DialogueDisplay.DisplayEffects +{ + public class AlwaysOnScreen : DisplayEffect + { + Vector2 StartPosition; + + public override bool FadeWhenTooFar => false; + + public override Vector2 TextOffsetFromStart(Vector2 startPos, Vector2 textSize) + { + StartPosition = startPos; + + Vector2 playerPos = Main.LocalPlayer.Center; + Vector2 halfSize = textSize * 0.5f; + Vector2 newPos = startPos - halfSize + (Vector2.UnitY * -(textSize.Y + 36)); + Vector2 screenPos = newPos.ToScreenPosition(); + + Vector2 boundTopLeftScreen = new((Main.screenWidth / 2f) - (Main.screenWidth / 2.5f), (Main.screenHeight / 2f) - (Main.screenHeight / 2.5f)); + + if (screenPos.X < boundTopLeftScreen.X) + newPos.X = playerPos.X - (Main.screenWidth / 2.5f); + if (screenPos.Y < boundTopLeftScreen.Y) + newPos.Y = playerPos.Y - (Main.screenHeight / 2.5f); + + if (newPos.X > playerPos.X + (Main.screenWidth / 2.5f) - textSize.X) + newPos.X = playerPos.X + (Main.screenWidth / 2.5f) - textSize.X; + if (newPos.Y > playerPos.Y + (Main.screenHeight / 2.5f) - textSize.Y) + newPos.Y = playerPos.Y + (Main.screenHeight / 2.5f) - textSize.Y; + + return newPos; + } + + public override void PreDraw(SpriteBatch spriteBatch, Vector2 textTopLeft, Vector2 textSize, int textTimer, int switchTimer) + { + Texture2D tex = ModContent.Request("CalamityMod/UI/DialogueDisplay/Assets/DialogueArrow").Value; + Vector2 textCenter = textTopLeft + textSize * 0.5f; + Vector2 toStart = (StartPosition - textCenter).SafeNormalize(-Vector2.UnitY) * 64; + spriteBatch.Draw(tex, textCenter + toStart - Main.screenPosition, null, Color.White, toStart.ToRotation(), tex.Size() * 0.5f, 1f, 0, 0); + } + } + +} diff --git a/UI/DialogueDisplay/DisplayEffects/BossText.cs b/UI/DialogueDisplay/DisplayEffects/BossText.cs new file mode 100644 index 0000000000..1085ad8e35 --- /dev/null +++ b/UI/DialogueDisplay/DisplayEffects/BossText.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.UI.DialogueDisplay.DisplayEffects +{ + public class BossText : DisplayEffect + { + public override bool FadeWhenTooFar => false; + + public override bool DespawnWithAttachedNPC => false; + + public override Vector2 TextOffsetFromStart(Vector2 startPos, Vector2 textSize) + { + Vector2 playerPos = Main.LocalPlayer.Center; + Vector2 halfSize = textSize * 0.5f; + Vector2 newPos = playerPos - halfSize + (Vector2.UnitY * (textSize.Y + 54)); + return newPos; + } + + float OffsetDisappearTime(float time, float ratio) => MathHelper.Clamp((time - (ratio * TimeToDisappear / 2f)) / (TimeToDisappear / 2f), 0f, 1f); + + public override Vector2 DisappearPositioning(Vector2 startPos, float time, DialogueCharacterData charData) => Vector2.Lerp(startPos, startPos + (Vector2.unitXVector * 12 * charData.Scale), CalamityUtils.SineOutEasing(OffsetDisappearTime(time, charData.CompletionRatio), 1)); + + public override float DisappearOpacity(float startOpacity, float time, DialogueCharacterData charData) => 1 - CalamityUtils.SineOutEasing(OffsetDisappearTime(time, charData.CompletionRatio), 1); + + public override Vector2 DisappearScale(Vector2 startScale, float time, DialogueCharacterData charData) => Vector2.Lerp(startScale, startScale * 0.75f, CalamityUtils.ExpOutEasing(OffsetDisappearTime(time, charData.CompletionRatio), 1)); + + public override void PreDraw(SpriteBatch spriteBatch, Vector2 textStart, Vector2 textSize, int textTimer, int switchTimer) + { + if (textTimer < 0) + return; + + float Opacity = 1f; + if (textTimer < 30f) + Opacity = MathHelper.Lerp(0f, 1f, CalamityUtils.CircOutEasing(textTimer / 30f, 1)); + + if (switchTimer > 0) + Opacity *= 1 - CalamityUtils.CircOutEasing(switchTimer / 60f, 1); + + Texture2D tex = ModContent.Request("CalamityMod/Particles/SmallBloom").Value; + spriteBatch.Draw(tex, textStart + textSize * 0.5f - Main.screenPosition, null, Color.Black * 0.6f * Opacity, 0f, tex.Size() * 0.5f, new Vector2(textSize.X / 160f, textSize.Y / 120f), 0, 0); + } + } +} diff --git a/UI/DialogueDisplay/DisplayEffects/BuiltEffect.cs b/UI/DialogueDisplay/DisplayEffects/BuiltEffect.cs new file mode 100644 index 0000000000..5d74c9ba32 --- /dev/null +++ b/UI/DialogueDisplay/DisplayEffects/BuiltEffect.cs @@ -0,0 +1,12 @@ +using Microsoft.Xna.Framework; +using Terraria; + +namespace CalamityMod.UI.DialogueDisplay.DisplayEffects +{ + public class BuiltEffect : DisplayEffect + { + public override Vector2 AppearPositioning(Vector2 startPos, Vector2 goalPos, float time, DialogueCharacterData charData) => Vector2.Lerp(goalPos + Vector2.UnitX.RotatedBy(charData.Index) * 400, goalPos, time / TimeToAppear); + + public override float AppearRotation(float goalRotation, float time, DialogueCharacterData charData) => MathHelper.Lerp(goalRotation + MathHelper.TwoPi * 2, goalRotation, time / TimeToAppear); + } +} diff --git a/UI/DialogueDisplay/DisplayEffects/DisplayEffect.cs b/UI/DialogueDisplay/DisplayEffects/DisplayEffect.cs new file mode 100644 index 0000000000..109c2cb7f8 --- /dev/null +++ b/UI/DialogueDisplay/DisplayEffects/DisplayEffect.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.UI.DialogueDisplay.DisplayEffects +{ + public class DisplayEffect + { + public virtual Vector2 TextOffsetFromStart(Vector2 startPos, Vector2 textSize) => startPos + new Vector2(-textSize.X / 2f, -(textSize.Y + 40)); + + public virtual bool FadeWhenTooFar => true; + + public virtual bool DespawnWithAttachedNPC => true; + + public virtual float FadeBuffer => 150f; + + public virtual float FadeDistance => 150f; + + public virtual void PreDraw(SpriteBatch spriteBatch, Vector2 textStart, Vector2 textSize, int textTimer, int switchTimer) { } + + public virtual void PostDraw(SpriteBatch spriteBatch, Vector2 textStart, Vector2 textSize, int textTimer, int switchTimer) { } + + public virtual float TimeToAppear => 30; + + #region Appear Functions + public virtual Vector2 AppearPositioning(Vector2 startPos, Vector2 goalPos, float time, DialogueCharacterData charData) => Vector2.Lerp(startPos, goalPos, CalamityUtils.SineOutEasing(time / TimeToAppear, 1)); + + public virtual Color AppearColoring(Color goalColor, float time, DialogueCharacterData charData) => goalColor; + + public virtual float AppearOpacity(float goalOpacity, float time, DialogueCharacterData charData) => CalamityUtils.SineOutEasing(MathHelper.Clamp(time / 20f, 0f, 1f), 1); + + public virtual float AppearRotation(float goalRotation, float time, DialogueCharacterData charData) => goalRotation; + + public virtual Vector2 AppearScale(Vector2 goalScale, float time, DialogueCharacterData charData) => Vector2.Lerp(Vector2.Zero, goalScale, CalamityUtils.CircOutEasing(time / TimeToAppear, 1)); + #endregion + + public virtual float TimeToDisappear => 30; + + #region Disappear Functions + public virtual Vector2 DisappearPositioning(Vector2 startPos, float time, DialogueCharacterData charData) => startPos; + + public virtual Color DisappearColoring(Color startColor, float time, DialogueCharacterData charData) => startColor; + + public virtual float DisappearOpacity(float startOpacity, float time, DialogueCharacterData charData) => 1 - CalamityUtils.SineOutEasing(MathHelper.Clamp(time / (TimeToDisappear * 0.66f), 0f, 1f), 1); + + public virtual float DisappearRotation(float startRotation, float time, DialogueCharacterData charData) => startRotation; + + public virtual Vector2 DisappearScale(Vector2 startScale, float time, DialogueCharacterData charData) => Vector2.Lerp(startScale, startScale * 1.5f, CalamityUtils.ExpOutEasing(time / TimeToDisappear, 1)); + #endregion + } + +} diff --git a/UI/DialogueDisplay/DisplayEffects/WhisperingPearlEffects.cs b/UI/DialogueDisplay/DisplayEffects/WhisperingPearlEffects.cs new file mode 100644 index 0000000000..420dbd1258 --- /dev/null +++ b/UI/DialogueDisplay/DisplayEffects/WhisperingPearlEffects.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using Terraria.ModLoader; +using Terraria; + +namespace CalamityMod.UI.DialogueDisplay.DisplayEffects +{ + public class WhisperingPearlEffects : DisplayEffect + { + public override void PreDraw(SpriteBatch spriteBatch, Vector2 textStart, Vector2 textSize, int textTimer, int switchTimer) + { + if (textTimer < 0) + return; + + float Opacity = 1f; + if (textTimer < 30f) + Opacity = MathHelper.Lerp(0f, 1f, CalamityUtils.CircOutEasing(textTimer / 30f, 1)); + + if (switchTimer > 0) + Opacity *= 1 - CalamityUtils.CircOutEasing(switchTimer / 60f, 1); + + Texture2D tex = ModContent.Request("CalamityMod/Particles/SmallBloom").Value; + spriteBatch.Draw(tex, textStart + textSize * 0.5f - Main.screenPosition, null, Color.Black * 0.6f * Opacity, 0f, tex.Size() * 0.5f, new Vector2(textSize.X / 160f, textSize.Y / 120f), 0, 0); + } + } + +} diff --git a/UI/DialogueDisplay/TextEffects/Shaking.cs b/UI/DialogueDisplay/TextEffects/Shaking.cs new file mode 100644 index 0000000000..67ec28bf1a --- /dev/null +++ b/UI/DialogueDisplay/TextEffects/Shaking.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria; + +namespace CalamityMod.UI.DialogueDisplay.TextEffects +{ + internal class Shaking : TextEffect + { + private const float StandardAmp = 2f; + + public override Vector2 ModifyPos(Vector2 pos, DialogueCharacterData data, float[] args) + { + var amp = StandardAmp; + if (args.Length > 0) + amp = args[0]; + + return pos + Main.rand.NextVector2Circular(amp, amp); + } + } +} diff --git a/UI/DialogueDisplay/TextEffects/TextEffect.cs b/UI/DialogueDisplay/TextEffects/TextEffect.cs new file mode 100644 index 0000000000..50f3ce4baf --- /dev/null +++ b/UI/DialogueDisplay/TextEffects/TextEffect.cs @@ -0,0 +1,17 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.UI.DialogueDisplay.TextEffects +{ + public abstract class TextEffect + { + public virtual Vector2 ModifyPos(Vector2 pos, DialogueCharacterData data, float[] args) => pos; + public virtual float ModifyRot(float rot, DialogueCharacterData data, float[] args) => rot; + public virtual Color ModifyColor(Color current, DialogueCharacterData data, float[] args) => current; + public virtual Vector2 ModifyScale(Vector2 scale, DialogueCharacterData data, float[] args) => scale; + + public virtual void PreDraw(SpriteBatch spritebatch, Texture2D texture, DialogueCharacterData data) { } + public virtual void PostDraw(SpriteBatch spritebatch, Texture2D texture, DialogueCharacterData data) { } + + } +} diff --git a/UI/DialogueDisplay/TextEffects/Wavy.cs b/UI/DialogueDisplay/TextEffects/Wavy.cs new file mode 100644 index 0000000000..deae5245f7 --- /dev/null +++ b/UI/DialogueDisplay/TextEffects/Wavy.cs @@ -0,0 +1,34 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; + +namespace CalamityMod.UI.DialogueDisplay.TextEffects +{ + public class Wavy : TextEffect + { + private const float StandardAmp = 6f; + + private const float StandardFreq = 1.5f; + + private const float StandardOffsetFactor = MathHelper.TwoPi / 320f; //since we use position, this means a full cycle will occur every 320 coordiantes + + public override Vector2 ModifyPos(Vector2 pos, DialogueCharacterData data, float[] args) + { + var amp = StandardAmp; + if(args.Length > 0) + amp = args[0]; + + var freq = StandardFreq; + if (args.Length > 1) + freq = args[1]; + + var indexFactor = StandardOffsetFactor; + if (args.Length > 2) + indexFactor = args[2]; + + var sineWave = (float)Math.Sin(Main.GlobalTimeWrappedHourly * freq + data.TextPosition.X * indexFactor) * amp; + + return pos + Vector2.UnitY * sineWave; + } + } +} diff --git a/UI/DraedonSummoning/CodebreakerUI.Communication.cs b/UI/DraedonSummoning/CodebreakerUI.Communication.cs index bfaa365107..223f642127 100644 --- a/UI/DraedonSummoning/CodebreakerUI.Communication.cs +++ b/UI/DraedonSummoning/CodebreakerUI.Communication.cs @@ -1,16 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; +using CalamityMod.Fonts; 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; @@ -232,15 +228,6 @@ namespace CalamityMod.UI.DraedonSummoning internal set; } = new(); - /// - /// The font used for displaying dialog. - /// - public static DynamicSpriteFont DialogFont - { - get; - internal set; - } - /// /// The dialog hover sound. /// @@ -256,17 +243,6 @@ namespace CalamityMod.UI.DraedonSummoning new("CalamityMod/Sounds/Custom/Codebreaker/DraedonTalk3") }; - public override void OnModLoad() - { - if (Main.dedServ) - return; - - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - DialogFont = CalamityMod.Instance.Assets.Request("Fonts/CodebreakerDialog", AssetRequestMode.ImmediateLoad).Value; - else - DialogFont = FontAssets.MouseText.Value; - } - public static void DisplayCommunicationPanel() { // Draw the background panel. This pops up. @@ -433,7 +409,7 @@ namespace CalamityMod.UI.DraedonSummoning Color textColor = Color.Cyan; Color markerColor = Color.White; - Vector2 textArea = DialogFont.MeasureString(inquiry) * GeneralScale; + Vector2 textArea = FontAssetSystem.CodebreakerDialog.Value.MeasureString(inquiry) * GeneralScale; Rectangle textAreaRect = new((int)textTopLeft.X, (int)textTopLeft.Y, (int)(textArea.X * 0.9f), (int)textArea.Y); Rectangle markerArea = Utils.CenteredRectangle(markerDrawPosition, markerTextureSize); textAreaRect.Y = markerArea.Y; @@ -514,7 +490,7 @@ namespace CalamityMod.UI.DraedonSummoning Vector2 markerTextureOrigin = markerTexture.Size() * 0.5f; Main.spriteBatch.Draw(markerTexture, markerDrawPosition, null, markerColor * opacity, 0f, markerTextureOrigin, markerScale, 0, 0f); - ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, DialogFont, inquiry, textTopLeft, textColor * opacity, 0f, Vector2.Zero, Vector2.One * GeneralScale * 0.85f); + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssetSystem.CodebreakerDialog.Value, inquiry, textTopLeft, textColor * opacity, 0f, Vector2.Zero, Vector2.One * GeneralScale * 0.85f); textTopLeft.Y += verticalOffsetPerOption; OptionsTextHeight += verticalOffsetPerOption; } @@ -632,7 +608,7 @@ namespace CalamityMod.UI.DraedonSummoning foreach (var entry in dialogEntries) { int lineIndex = 0; - foreach (string line in Utils.WordwrapString(entry.Dialog, DialogFont, 336, 1000, out _)) + foreach (string line in Utils.WordwrapString(entry.Dialog, FontAssetSystem.CodebreakerDialog.Value, 336, 1000, out _)) { if (string.IsNullOrEmpty(line)) continue; @@ -650,7 +626,7 @@ namespace CalamityMod.UI.DraedonSummoning Vector2 anchorPoint = new(dialogArea.Center.X, markerDrawPosition.Y); markerDrawPosition.X = anchorPoint.X + (anchorPoint.X - markerDrawPosition.X) - GeneralScale * 12f; localTextTopLeft.X = anchorPoint.X + (anchorPoint.X - localTextTopLeft.X) - GeneralScale * 14f; - localTextTopLeft.X -= DialogFont.MeasureString(line).X * DialogTextScale.X; + localTextTopLeft.X -= FontAssetSystem.CodebreakerDialog.Value.MeasureString(line).X * DialogTextScale.X; localTextTopLeft.Y -= localTextOffsetY; // Use a neutral grey-ish color if text is being said by the player. @@ -664,7 +640,7 @@ namespace CalamityMod.UI.DraedonSummoning Main.spriteBatch.Draw(markerTexture, markerDrawPosition, null, Color.White * dialogHistoryDrawInterpolant, 0f, markerTextureOrigin, markerScale, markerDirection, 0f); // Draw the text itself. - ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, DialogFont, line, localTextTopLeft, dialogColor * dialogHistoryDrawInterpolant, 0f, Vector2.Zero, DialogTextScale); + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssetSystem.CodebreakerDialog.Value, line, localTextTopLeft, dialogColor * dialogHistoryDrawInterpolant, 0f, Vector2.Zero, DialogTextScale); textTopLeft.Y += panelOffsetPerLine; lineIndex++; diff --git a/UI/DraedonSummoning/CodebreakerUI.cs b/UI/DraedonSummoning/CodebreakerUI.cs index b50d05d200..eb32c2c76a 100644 --- a/UI/DraedonSummoning/CodebreakerUI.cs +++ b/UI/DraedonSummoning/CodebreakerUI.cs @@ -1,7 +1,7 @@ using System; using System.Text; using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.NPCs.ExoMechs; using CalamityMod.Packets; using CalamityMod.Systems.Collections; @@ -168,13 +168,13 @@ namespace CalamityMod.UI.DraedonSummoning // Draw the cell payment slot icon. Texture2D emptyCellIconTexture = ModContent.Request("CalamityMod/UI/DraedonsArsenal/PowerCellSlot_Empty").Value; Texture2D occupiedCellIconTexture = ModContent.Request("CalamityMod/UI/DraedonsArsenal/PowerCellSlot_Filled").Value; - Texture2D bloodSampleIconTexture = ModContent.Request("CalamityMod/Items/Materials/BloodSample").Value; + Texture2D bloodyVeinIconTexture = ModContent.Request("CalamityMod/Items/Pets/BloodyVein").Value; Texture2D cellTexture = emptyCellIconTexture; if (codebreakerTileEntity.InputtedCellCount > 0) { - if (codebreakerTileEntity.ContainsBloodSample) + if (codebreakerTileEntity.ContainsBloodyVein) { - cellTexture = bloodSampleIconTexture; + cellTexture = bloodyVeinIconTexture; } else { @@ -194,7 +194,7 @@ namespace CalamityMod.UI.DraedonSummoning DisplayNotStrongEnoughErrorText(schematicSlotDrawCenter + new Vector2(-24f, 56f)); // Handle decryption costs. - else if (codebreakerTileEntity.HeldSchematicID != 0 && codebreakerTileEntity.DecryptionCountdown == 0 && !codebreakerTileEntity.ContainsBloodSample) + else if (codebreakerTileEntity.HeldSchematicID != 0 && codebreakerTileEntity.DecryptionCountdown == 0 && !codebreakerTileEntity.ContainsBloodyVein) { int cost = codebreakerTileEntity.DecryptionCellCost; DisplayCostText(costDisplayLocation, cost); @@ -247,8 +247,8 @@ namespace CalamityMod.UI.DraedonSummoning // Create a temporary item for drawing purposes. // If cells are present, make the item reflect that. Item temporaryPowerCell = new Item(); - if (codebreakerTileEntity.ContainsBloodSample) - temporaryPowerCell.SetDefaults(ModContent.ItemType()); + if (codebreakerTileEntity.ContainsBloodyVein) + temporaryPowerCell.SetDefaults(ModContent.ItemType()); else temporaryPowerCell.SetDefaults(ModContent.ItemType()); @@ -313,7 +313,7 @@ namespace CalamityMod.UI.DraedonSummoning if (Main.mouseLeft && Main.mouseLeftRelease && codebreakerTileEntity.DecryptionCountdown <= 0) { int powercellID = ModContent.ItemType(); - int sampleID = ModContent.ItemType(); + int sampleID = ModContent.ItemType(); short cellStackDiff = 0; bool shouldPlaySound = true; @@ -323,7 +323,7 @@ namespace CalamityMod.UI.DraedonSummoning cellStackDiff = (short)-Math.Min(temporaryItem.stack, temporaryItem.maxStack); Player p = Main.LocalPlayer; var source = p.GetSource_TileInteraction(codebreakerTileEntity.Position.X, codebreakerTileEntity.Position.Y); - p.QuickSpawnItem(source, codebreakerTileEntity.ContainsBloodSample ? sampleID : powercellID, -cellStackDiff); + p.QuickSpawnItem(source, codebreakerTileEntity.ContainsBloodyVein ? sampleID : powercellID, -cellStackDiff); // Do not play a sound in this situation. The player is going to pick up the dropped cells in a few frames, which will make sound. shouldPlaySound = false; @@ -333,7 +333,7 @@ namespace CalamityMod.UI.DraedonSummoning else { bool holdingPowercell = playerHandItem.type == powercellID || (playerHandItem.type == sampleID && Main.zenithWorld); - bool powercellsinserted = !codebreakerTileEntity.ContainsBloodSample && temporaryItem.stack > 0; + bool powercellsinserted = !codebreakerTileEntity.ContainsBloodyVein && temporaryItem.stack > 0; bool cansummon = codebreakerTileEntity.ReadyToSummonDraedon && CalamityWorld.AbleToSummonDraedon; // If the player's held power cells can be stacked on top of what's already in the codeberaker, then stack them. @@ -347,7 +347,7 @@ namespace CalamityMod.UI.DraedonSummoning { SoundEngine.PlaySound(BloodSound, codebreakerTileEntity.Center); } - codebreakerTileEntity.ContainsBloodSample = true; + codebreakerTileEntity.ContainsBloodyVein = true; int spaceLeft = TECodebreaker.MaxCellCapacity - temporaryItem.stack; @@ -362,7 +362,7 @@ namespace CalamityMod.UI.DraedonSummoning // If theres nothing inside or there are cells inside, cells can be inserted if (playerHandItem.type == powercellID && (temporaryItem.stack == 0 || powercellsinserted)) { - codebreakerTileEntity.ContainsBloodSample = false; + codebreakerTileEntity.ContainsBloodyVein = false; int spaceLeft = TECodebreaker.MaxCellCapacity - temporaryItem.stack; @@ -387,7 +387,7 @@ namespace CalamityMod.UI.DraedonSummoning playerHandItem.stack = -cellStackDiff; temporaryItem.TurnToAir(); AwaitingDecryptionTextClose = false; - codebreakerTileEntity.ContainsBloodSample = false; + codebreakerTileEntity.ContainsBloodyVein = false; } } @@ -637,7 +637,7 @@ namespace CalamityMod.UI.DraedonSummoning Rectangle clickArea = Utils.CenteredRectangle(drawPosition, contactButton.Size() * VerificationButtonScale); - float iconrotation = codebreakerTileEntity.ContainsBloodSample ? Main.GlobalTimeWrappedHourly * 20f : 0f; + float iconrotation = codebreakerTileEntity.ContainsBloodyVein ? Main.GlobalTimeWrappedHourly * 20f : 0f; // Check if the mouse is hovering over the contact button area. if (MouseScreenArea.Intersects(clickArea)) @@ -652,7 +652,7 @@ namespace CalamityMod.UI.DraedonSummoning { CalamityWorld.DraedonSummonCountdown = CalamityWorld.DraedonSummonCountdownMax; CalamityWorld.DraedonSummonPosition = codebreakerTileEntity.Center + new Vector2(-8f, -100f); - if (Main.zenithWorld && codebreakerTileEntity.ContainsBloodSample) + if (Main.zenithWorld && codebreakerTileEntity.ContainsBloodyVein) { CalamityWorld.DraedonMechdusa = true; } @@ -677,7 +677,7 @@ namespace CalamityMod.UI.DraedonSummoning string contactTextKey = "Contact"; if (DownedBossSystem.downedExoMechs) contactTextKey = "Summon"; - if (codebreakerTileEntity.ContainsBloodSample) + if (codebreakerTileEntity.ContainsBloodyVein) contactTextKey = "Evoke"; string contactText = CalamityUtils.GetTextValue("UI." + contactTextKey); diff --git a/UI/DraedonsArsenal/ChargeMeterUI.cs b/UI/DraedonsArsenal/ChargeMeterUI.cs index af52bdb329..84f2a693e8 100644 --- a/UI/DraedonsArsenal/ChargeMeterUI.cs +++ b/UI/DraedonsArsenal/ChargeMeterUI.cs @@ -65,11 +65,11 @@ namespace CalamityMod.UI.DraedonsArsenal changed = true; } if (changed) - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } // If the Charge Meter is turned off or the player is not holding an item, stop. - Item heldItem = player.ActiveItem(); + Item heldItem = player.HeldItem; if (!CalamityClientConfig.Instance.ChargeMeter || heldItem is null || heldItem.IsAir) { Reset(); @@ -129,10 +129,10 @@ namespace CalamityMod.UI.DraedonsArsenal } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } } } diff --git a/UI/DraedonsArsenal/ChargingStationUI.cs b/UI/DraedonsArsenal/ChargingStationUI.cs index f207c629b2..c6841cfa47 100644 --- a/UI/DraedonsArsenal/ChargingStationUI.cs +++ b/UI/DraedonsArsenal/ChargingStationUI.cs @@ -202,7 +202,7 @@ namespace CalamityMod.UI.DraedonsArsenal // Since HoverItem is active, we don't need to input anything into this method. Main.instance.MouseTextHackZoom(""); // Specifically do not block mouse input if holding a pickaxe, so that you can mine blocks behind the UI. - Main.blockMouse = Main.LocalPlayer.ActiveItem().pick <= 0; + Main.blockMouse = Main.LocalPlayer.HeldItem.pick <= 0; } } diff --git a/UI/DraedonsArsenal/PowerCellSlot_Blood.png b/UI/DraedonsArsenal/PowerCellSlot_Blood.png index 21ab14e734..709119d21e 100644 Binary files a/UI/DraedonsArsenal/PowerCellSlot_Blood.png and b/UI/DraedonsArsenal/PowerCellSlot_Blood.png differ diff --git a/UI/EnchantmentMetersUI.cs b/UI/EnchantmentMetersUI.cs index e203de7fe1..08a784f798 100644 --- a/UI/EnchantmentMetersUI.cs +++ b/UI/EnchantmentMetersUI.cs @@ -10,7 +10,7 @@ namespace CalamityMod.UI public static Vector2 DrawPosition => Main.LocalPlayer.Center; public static void Draw(SpriteBatch spriteBatch, Player player) { - Item heldItem = player.ActiveItem(); + Item heldItem = player.HeldItem; // Do not draw if the player has an empty item. Precise item checks for modded content will fail. if (heldItem is null || heldItem.IsAir) diff --git a/UI/FlightBar/FlightBar.cs b/UI/FlightBar/FlightBar.cs index f344bc517c..6339989af1 100644 --- a/UI/FlightBar/FlightBar.cs +++ b/UI/FlightBar/FlightBar.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -125,7 +124,7 @@ namespace CalamityMod.UI } if (changed) - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); return; } @@ -172,10 +171,10 @@ namespace CalamityMod.UI } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } } } @@ -237,9 +236,9 @@ namespace CalamityMod.UI Vector2 origin = new Vector2(correctBorder.Width * 0.5f, (correctBorder.Height / FlightAnimFrames) * 0.5f); float xOffset = (correctBorder.Width - flightBarAnimTexture.Width) / 2f; int frameHeight = (flightBarAnimTexture.Height / FlightAnimFrames) - 1; - Vector2 sizeDiffOffset = new Vector2(xOffset, -37f); + Vector2 sizeDiffOffset = new Vector2(xOffset, -37f) * uiScale; Rectangle animCropRect = new Rectangle(0, (frameHeight + 1) * FlightAnimFrame, flightBarAnimTexture.Width, frameHeight); - spriteBatch.Draw(flightBarAnimTexture, screenPos + sizeDiffOffset, animCropRect, Color.White, 0f, origin * Main.UIScale, uiScale, SpriteEffects.None, 0); + spriteBatch.Draw(flightBarAnimTexture, screenPos + sizeDiffOffset, animCropRect, Color.White, 0f, origin, uiScale, SpriteEffects.None, 0); } } diff --git a/UI/InvasionProgressUI.cs b/UI/InvasionProgressUI.cs index 468a20bbbb..23c3edd16a 100644 --- a/UI/InvasionProgressUI.cs +++ b/UI/InvasionProgressUI.cs @@ -5,10 +5,12 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; using Terraria.Localization; +using Terraria.ModLoader; namespace CalamityMod.UI { - public abstract class InvasionProgressUI + [Autoload(Side = ModSide.Client)] + public abstract class InvasionProgressUI : ModType { public virtual int SecondaryDigitPrecision { get; } = 0; public abstract bool IsActive { get; } @@ -16,6 +18,13 @@ namespace CalamityMod.UI public abstract string InvasionName { get; } public abstract Color InvasionBarColor { get; } public abstract Texture2D IconTexture { get; } + + protected sealed override void Register() + { + ModTypeLookup.Register(this); + InvasionProgressUIManager.gUIs.Add(this); + } + public virtual void DrawBlueBar(SpriteBatch spriteBatch, Vector2 barDrawPosition, int barOffsetY) { int barWidth = 200; diff --git a/UI/InvasionProgressUIManager.cs b/UI/InvasionProgressUIManager.cs index c349471eb3..d44b56676b 100644 --- a/UI/InvasionProgressUIManager.cs +++ b/UI/InvasionProgressUIManager.cs @@ -3,14 +3,14 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod.UI { [Autoload(Side = ModSide.Client)] public sealed class InvasionProgressUIManager : ModSystem { - private static readonly List gUIs = []; + internal static readonly List gUIs = []; + public static int TotalGUIsActive => gUIs.Count(gui => gui.IsActive); public static bool AnyGUIsActive => TotalGUIsActive > 0; public static InvasionProgressUI GetActiveGUI => gUIs.FirstOrDefault(gui => gui.IsActive); @@ -24,15 +24,6 @@ namespace CalamityMod.UI } } - public override void OnModLoad() - { - // Look through every type in the mod, and check if it's derived from InvasionProgressUI. If it is, create a copy and save it in the static list. - ReflectionHelper.IterateCalamityTypes(action: type => - { - gUIs.Add(Activator.CreateInstance(type) as InvasionProgressUI); - }); - } - public override void Unload() { gUIs?.Clear(); diff --git a/UI/ModeIndicator/ModeIndicatorLock.png b/UI/ModeIndicator/ModeIndicatorLock.png index f440e5748d..ae7b9e6073 100644 Binary files a/UI/ModeIndicator/ModeIndicatorLock.png and b/UI/ModeIndicator/ModeIndicatorLock.png differ diff --git a/UI/ModeIndicator/ModeIndicatorOutline.png b/UI/ModeIndicator/ModeIndicatorOutline.png deleted file mode 100644 index d4f1f87ee3..0000000000 Binary files a/UI/ModeIndicator/ModeIndicatorOutline.png and /dev/null differ diff --git a/UI/ModeIndicator/ModeIndicatorUI.cs b/UI/ModeIndicator/ModeIndicatorUI.cs index fd25bce7b1..9dacbef733 100644 --- a/UI/ModeIndicator/ModeIndicatorUI.cs +++ b/UI/ModeIndicator/ModeIndicatorUI.cs @@ -1,17 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; using System.Text.RegularExpressions; using CalamityMod.CalPlayer; using CalamityMod.Events; +using CalamityMod.Packets; using CalamityMod.Systems; -using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameInput; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -26,15 +25,15 @@ namespace CalamityMod.UI.ModeIndicator { public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); - public static Vector2 FrameSize => new Vector2(30f, 38f); + public static Vector2 FrameSize => new Vector2(74f, 74f); public static Rectangle MainClickArea => Utils.CenteredRectangle(DrawCenter, FrameSize * MainIconScale); public static bool ClickingMouse => Main.mouseLeft && Main.mouseLeftRelease; public static Vector2 DrawCenter => new Vector2(Main.screenWidth - 400f - WidthForTier(MostAlternateDifficulties) * 0.5f, 82f) + FrameSize * 0.5f; - private static int GlowFadeAnimLength = 40; + private static int GlowFadeAnimLength = 20; public static int GlowFadeTime = 0; //Lock icon - internal const int LockAnimLength = 30; + internal const int LockAnimLength = 15; private static int lockClickTime = 0; private static bool previousLockStatus = false; //Expand and shrink on hover @@ -46,10 +45,10 @@ namespace CalamityMod.UI.ModeIndicator public static float MainIconScale => 1f + iconHoverScaleBoost; //Menu state private static bool menuOpen = false; - internal static int MenuAnimLength => MostAlternateDifficulties > 1 ? 60 : 40; + internal static int MenuAnimLength => MostAlternateDifficulties > 1 ? 30 : 20; private static int menuOpenTransitionTime = 0; private static DifficultyMode previouslyHoveredMode = null; - public static float WidthForTier(int alts) => (alts - 1) * 40f; + public static float WidthForTier(int alts) => (alts - 1) * 76f; private static void ClearVariables() { @@ -140,9 +139,10 @@ namespace CalamityMod.UI.ModeIndicator spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); - + /* Texture2D outlineTexture = ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicatorOutline").Value; spriteBatch.Draw(outlineTexture, DrawCenter, null, Color.White * opacity, 0f, outlineTexture.Size() * 0.5f, MainIconScale, SpriteEffects.None, 0f); + */ } string extraDescText = string.Empty; @@ -207,20 +207,20 @@ namespace CalamityMod.UI.ModeIndicator if (MouseScreenArea.Intersects(MainClickArea)) { //Display the first non-none difficulty by default - string modeToDisplay = Difficulties[1].Name.ToString(); - bool anyActiveMode = false; + string modeToDisplay = Main.getGoodWorld && Difficulties[0].FTWName is not null ? Difficulties[0].FTWName.ToString() : Difficulties[1].Name.ToString(); + bool anyActiveMode = Main.getGoodWorld ? true : false; for (int i = 1; i < Difficulties.Count; i++) { if (GetCurrentDifficulty == Difficulties[i]) { - modeToDisplay = Difficulties[i].Name.ToString(); + modeToDisplay = Main.getGoodWorld && Difficulties[i].FTWName is not null ? Difficulties[i].FTWName.ToString() : Difficulties[i].Name.ToString(); anyActiveMode = true; } } - string modeStr = CalamityUtils.GetTextValue("UI.ModeAppend"); + string modeStr = CalamityUtils.GetText("UI.ModeAppend").Format(modeToDisplay); string activeText = CalamityUtils.GetTextValue("UI." + (anyActiveMode ? "Active" : "NotActive")); - text = CalamityUtils.GetText("UI.DifficultyStatusText").WithFormatArgs(modeToDisplay + modeStr, activeText.ToLower()); + text = CalamityUtils.GetText("UI.DifficultyStatusText").WithFormatArgs(modeStr, activeText.ToLower()); } } @@ -229,12 +229,7 @@ namespace CalamityMod.UI.ModeIndicator { locked = false; text = CalamityUtils.GetText("UI.DifficultyClickText"); - if (!Main.expertMode && GetCurrentDifficulty == Difficulties[0]) - { - locked = true; - text = CalamityUtils.GetText("UI.ExpertDifficultyLock"); - } - else if (CalamityPlayer.areThereAnyDamnBosses || BossRushEvent.BossRushActive) + if (CalamityPlayer.areThereAnyDamnBosses || BossRushEvent.BossRushActive) { locked = true; text = CalamityUtils.GetText("UI.ChangingTheRules"); @@ -303,12 +298,10 @@ namespace CalamityMod.UI.ModeIndicator public static void ManageHexIcons(SpriteBatch spriteBatch, out string text) { int tiers = DifficultyTiers.Count(); - float barLength = 60 * tiers * BarExpansionProgress; + float barLength = 90 * tiers * BarExpansionProgress; float progress = menuOpen ? 1 - menuOpenTransitionTime / (float)MenuAnimLength : menuOpenTransitionTime / (float)MenuAnimLength; Vector2 basePosition = DrawCenter + (barLength / (float)(tiers + 1f)) * Vector2.UnitY; - Texture2D outlineTexture = ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicatorOutline").Value; - text = string.Empty; bool modeHovered = false; Vector2 positionOffset = (barLength / (float)(tiers + 1f)) * Vector2.UnitY; @@ -322,7 +315,7 @@ namespace CalamityMod.UI.ModeIndicator for (int j = 0; j < modesAtTier; j++) { DifficultyMode mode = DifficultyTiers[i][j]; - Texture2D hexIcon = mode.Texture.Value; + Texture2D hexIcon = mode.Enabled ? mode.Texture.Value : mode.TextureDisabled.Value; Vector2 hexIconSize = hexIcon.Size(); // Get position. @@ -332,7 +325,7 @@ namespace CalamityMod.UI.ModeIndicator bool hovered = MouseScreenArea.Intersects(Utils.CenteredRectangle(iconPosition, hexIconSize)); - float usedOpacity = mode.Enabled ? 0.85f : 0.55f; + float usedOpacity = 0.85f; if (hovered) usedOpacity = MathHelper.Lerp(usedOpacity, 1f, 0.7f); @@ -340,6 +333,7 @@ namespace CalamityMod.UI.ModeIndicator if (mode == GetCurrentDifficulty) { usedOpacity = 1f; + Texture2D outlineTexture = mode.OutlineTexture.Value; spriteBatch.Draw(outlineTexture, iconPosition, null, mode.ChatTextColor * progressMult, 0f, outlineTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); } @@ -355,12 +349,8 @@ namespace CalamityMod.UI.ModeIndicator text = GetDifficultyText(mode); - // Cannot switch to Death Mode if Master Mode isn't active. - // Cannot switch to Revengeance Mode if Master Mode is active. - // I hate how this is coded, it makes me want to smash my head through a wall. - Fabsol - bool cannotSwitchTo = (!Main.masterMode && mode == Difficulties[2]) || (Main.masterMode && mode == Difficulties[1]); - if (ClickingMouse && !cannotSwitchTo) - SwitchToDifficulty(mode); + if (ClickingMouse) + SwitchToDifficulty(mode, broadcast: true); } } } @@ -373,16 +363,17 @@ namespace CalamityMod.UI.ModeIndicator { Texture2D lockTexture = ModContent.Request("CalamityMod/UI/ModeIndicator/ModeIndicatorLock").Value; float rotationShift = lockClickTime == 0 ? 0f : (float)Math.Sin((1 - lockClickTime / (float)LockAnimLength) * MathHelper.TwoPi * 2f) * 0.5f * (lockClickTime / (float)LockAnimLength); - spriteBatch.Draw(lockTexture, DrawCenter + Vector2.UnitY * 12 * MainIconScale, null, Color.White, 0f + rotationShift, lockTexture.Size() * 0.5f, LockShakeScale * MainIconScale, SpriteEffects.None, 0f); + spriteBatch.Draw(lockTexture, DrawCenter + Vector2.UnitY * 24 * MainIconScale, null, Color.White, 0f + rotationShift, lockTexture.Size() * 0.5f, LockShakeScale * MainIconScale, SpriteEffects.None, 0f); } #endregion #region Difficulty toggling public static string GetDifficultyText(DifficultyMode mode) { - LocalizedText preface = mode.Name; + bool useFTWName = mode.FTWName is not null && Main.getGoodWorld; + LocalizedText preface = useFTWName ? mode.FTWName : mode.Name; if (mode == GetCurrentDifficulty) - preface = CalamityUtils.GetText("UI.CurrentlySelected").WithFormatArgs(mode.Name.ToString()); + preface = CalamityUtils.GetText("UI.CurrentlySelected").WithFormatArgs(useFTWName ? mode.FTWName.ToString() : mode.Name.ToString()); string text = "\n" + mode.ShortDescription.ToString(); @@ -390,7 +381,7 @@ namespace CalamityMod.UI.ModeIndicator if (mode.ExpandedDescription != LocalizedText.Empty) { // Show the description either if the player is holding shift. - if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift)) + if (Main.keyState.PressingShift()) text += "\n" + mode.ExpandedDescription.ToString(); else @@ -400,16 +391,22 @@ namespace CalamityMod.UI.ModeIndicator return preface.ToString() + text; } - public static void SwitchToDifficulty(DifficultyMode mode) + public static void SwitchToDifficulty(DifficultyMode mode, bool broadcast) { //No swap on server (although this doesn't matter anymore since it's not an item but dnc. //No swap if the requested difficulty is the same as the current one. if (mode == GetCurrentDifficulty) return; + // This has to be put before difficulties change as to not disrupt GetCurrentDifficulty + BroadcastFormattedText("Mods.CalamityMod.UI.DifficultySwitch", Color.White, Main.getGoodWorld && GetCurrentDifficulty.FTWTextColor is not null ? GetCurrentDifficulty.FTWTextColor.Value.Hex3() : GetCurrentDifficulty.ChatTextColor.Hex3(), Main.getGoodWorld && GetCurrentDifficulty.FTWName is not null ? GetCurrentDifficulty.FTWName : GetCurrentDifficulty.Name + , Main.getGoodWorld && GetCurrentDifficulty.FTWTextColor is not null ? mode.FTWTextColor.Value.Hex3() : mode.ChatTextColor.Hex3(), Main.getGoodWorld && GetCurrentDifficulty.FTWName is not null ? mode.FTWName : mode.Name); + // Todo, maybe in the future having a way to have multiple difficulty options on the same tier that can coexist, and it works in branching pathes? Not very necessary for cal & addons. // But would be super useful so other mods can let their own difficulties go there. + DifficultyModeSystem._newGameModeID = mode.BackBoneGameModeID; + // Disable difficulties. for (int i = 0; i < Difficulties.Count; i++) { @@ -417,12 +414,7 @@ namespace CalamityMod.UI.ModeIndicator if (Difficulties[i]._difficultyTier >= mode._difficultyTier && Difficulties[i] != mode) { if (Difficulties[i].Enabled) - { - if (Difficulties[i].DeactivationTextKey != string.Empty) - DisplayLocalizedText(Difficulties[i].DeactivationTextKey, Difficulties[i].ChatTextColor); - Difficulties[i].Enabled = false; - } } } @@ -441,21 +433,28 @@ namespace CalamityMod.UI.ModeIndicator for (int j = 0; j < DifficultyTiers[i].Length; j++) DifficultyTiers[i][j].Enabled = false; - // Enable the one favored by the mode. - DifficultyTiers[i][mode.FavoredDifficultyAtTier(i)].Enabled = true; + // Enable the ones favored by the mode. + for (int j = 0; j < mode.FavoredDifficultyAtTier(i).Length; j++) + { + DifficultyTiers[i][mode.FavoredDifficultyAtTier(i)[j]].Enabled = true; + } } } - if (mode.ActivationTextKey != string.Empty) - DisplayLocalizedText(mode.ActivationTextKey, mode.ChatTextColor); - mode.Enabled = true; SoundEngine.PlaySound(mode.ActivationSound); - CalamityNetcode.SyncCalamityWorldDifficulties(Main.myPlayer); - menuOpen = false; - menuOpenTransitionTime = MenuAnimLength; + if (Main.netMode != NetmodeID.SinglePlayer && broadcast) + { + SwitchToDifficultyPacket.Send(mode); + } + + if (menuOpen) + { + menuOpen = false; + menuOpenTransitionTime = MenuAnimLength; + } } #endregion diff --git a/UI/ModeIndicator/ModeIndicator_Classic.png b/UI/ModeIndicator/ModeIndicator_Classic.png new file mode 100644 index 0000000000..311087fb85 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Classic.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Classic_Border.png b/UI/ModeIndicator/ModeIndicator_Classic_Border.png new file mode 100644 index 0000000000..4b7745f447 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Classic_Border.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Classic_Off.png b/UI/ModeIndicator/ModeIndicator_Classic_Off.png new file mode 100644 index 0000000000..1ce7e3aef4 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Classic_Off.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Death.png b/UI/ModeIndicator/ModeIndicator_Death.png index 5729ede7b4..0604833c59 100644 Binary files a/UI/ModeIndicator/ModeIndicator_Death.png and b/UI/ModeIndicator/ModeIndicator_Death.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Death_Border.png b/UI/ModeIndicator/ModeIndicator_Death_Border.png new file mode 100644 index 0000000000..6c3f3df9c1 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Death_Border.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Death_Off.png b/UI/ModeIndicator/ModeIndicator_Death_Off.png new file mode 100644 index 0000000000..d5cacd72c8 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Death_Off.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Expert.png b/UI/ModeIndicator/ModeIndicator_Expert.png new file mode 100644 index 0000000000..893cbd39d6 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Expert.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Expert_Border.png b/UI/ModeIndicator/ModeIndicator_Expert_Border.png new file mode 100644 index 0000000000..a795897508 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Expert_Border.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Expert_Off.png b/UI/ModeIndicator/ModeIndicator_Expert_Off.png new file mode 100644 index 0000000000..6aeff8c0d7 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Expert_Off.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Legendary.png b/UI/ModeIndicator/ModeIndicator_Legendary.png new file mode 100644 index 0000000000..5a8789f90a Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Legendary.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Legendary_Border.png b/UI/ModeIndicator/ModeIndicator_Legendary_Border.png new file mode 100644 index 0000000000..3dc61a1448 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Legendary_Border.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Legendary_Off.png b/UI/ModeIndicator/ModeIndicator_Legendary_Off.png new file mode 100644 index 0000000000..5261ecc7c4 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Legendary_Off.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Malice.png b/UI/ModeIndicator/ModeIndicator_Malice.png new file mode 100644 index 0000000000..f6ad0a7a8a Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Malice.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Malice_Border.png b/UI/ModeIndicator/ModeIndicator_Malice_Border.png new file mode 100644 index 0000000000..7ddffeae4c Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Malice_Border.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Malice_Off.png b/UI/ModeIndicator/ModeIndicator_Malice_Off.png new file mode 100644 index 0000000000..e74ba288b9 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Malice_Off.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Master.png b/UI/ModeIndicator/ModeIndicator_Master.png new file mode 100644 index 0000000000..655f9c13d0 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Master.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Master_Border.png b/UI/ModeIndicator/ModeIndicator_Master_Border.png new file mode 100644 index 0000000000..65ee802bcb Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Master_Border.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Master_Off.png b/UI/ModeIndicator/ModeIndicator_Master_Off.png new file mode 100644 index 0000000000..cfb119a7ea Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Master_Off.png differ diff --git a/UI/ModeIndicator/ModeIndicator_None.png b/UI/ModeIndicator/ModeIndicator_None.png deleted file mode 100644 index 58648ff4ed..0000000000 Binary files a/UI/ModeIndicator/ModeIndicator_None.png and /dev/null differ diff --git a/UI/ModeIndicator/ModeIndicator_Rev.png b/UI/ModeIndicator/ModeIndicator_Rev.png index 64eec475d7..9c29e362e0 100644 Binary files a/UI/ModeIndicator/ModeIndicator_Rev.png and b/UI/ModeIndicator/ModeIndicator_Rev.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Rev_Border.png b/UI/ModeIndicator/ModeIndicator_Rev_Border.png new file mode 100644 index 0000000000..3f59e2ad7d Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Rev_Border.png differ diff --git a/UI/ModeIndicator/ModeIndicator_Rev_Off.png b/UI/ModeIndicator/ModeIndicator_Rev_Off.png new file mode 100644 index 0000000000..1aba896d33 Binary files /dev/null and b/UI/ModeIndicator/ModeIndicator_Rev_Off.png differ diff --git a/UI/PopupGUI.cs b/UI/PopupGUI.cs index 1704d2d95a..a9ce279c7a 100644 --- a/UI/PopupGUI.cs +++ b/UI/PopupGUI.cs @@ -1,14 +1,23 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ModLoader; namespace CalamityMod.UI { - public abstract class PopupGUI + [Autoload(Side = ModSide.Client)] + public abstract class PopupGUI : ModType { public int FadeTime; public bool Active; public virtual int FadeTimeMax { get; set; } = 30; + + protected sealed override void Register() + { + ModTypeLookup.Register(this); + PopupGUIManager.gUIs.Add(this); + } + public virtual void Update() { if (Active) diff --git a/UI/PopupGUIManager.cs b/UI/PopupGUIManager.cs index 0e37676da0..f97185dee0 100644 --- a/UI/PopupGUIManager.cs +++ b/UI/PopupGUIManager.cs @@ -4,14 +4,13 @@ using System.Linq; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; -using Terraria.ModLoader.Core; namespace CalamityMod.UI { [Autoload(Side = ModSide.Client)] public sealed class PopupGUIManager : ModSystem { - private static readonly List gUIs = []; + internal static readonly List gUIs = []; public static bool GUIActive(PopupGUI gui) => gui.Active || gui.FadeTime > 0; public static bool AnyGUIsActive => gUIs.Any(GUIActive); public static PopupGUI GetActiveGUI => gUIs.FirstOrDefault(GUIActive); @@ -57,15 +56,6 @@ namespace CalamityMod.UI gUIs.First(gui => gui.GetType() == type).Active = !gUIs.First(gui => gui.GetType() == type).Active; } - public override void OnModLoad() - { - // Look through every type in the mod, and check if it's derived from PopupGUI. If it is, create a copy and save it in the static list. - ReflectionHelper.IterateEveryModsTypes(action: type => - { - gUIs.Add(Activator.CreateInstance(type) as PopupGUI); - }); - } - public override void Unload() { gUIs?.Clear(); diff --git a/UI/PunchCardGUI.cs b/UI/PunchCardGUI.cs deleted file mode 100644 index 3dbe2fac1a..0000000000 --- a/UI/PunchCardGUI.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.ModLoader; - -namespace CalamityMod.UI -{ - public class PunchCardGUI : PopupGUI - { - public bool HoveringOverBook = false; - - public override void Update() - { - if (Active) - { - if (FadeTime < FadeTimeMax) - FadeTime++; - } - else if (FadeTime > 0) - { - FadeTime--; - } - - if (Main.mouseLeft && !HoveringOverBook && FadeTime >= 30) - { - Active = false; - } - - HoveringOverBook = false; - } - - public override void Draw(SpriteBatch spriteBatch) - { - Texture2D pageTexture = ModContent.Request("CalamityMod/UI/MiscTextures/PunchCardPopup").Value; - float xScale = MathHelper.Lerp(0.004f, 1f, FadeTime / (float)FadeTimeMax); - Vector2 scale = new Vector2(xScale, 1f) * new Vector2(Main.screenWidth, Main.screenHeight) / pageTexture.Size(); - scale.Y *= 1.5f; - scale *= 0.5f; - - float bookScale = 0.5f; - scale *= bookScale; - - float yPageTop = MathHelper.Lerp(Main.screenHeight * 2, Main.screenHeight * 0.5f, FadeTime / (float)FadeTimeMax); - - Rectangle mouseRectangle = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 2, 2); - float drawPositionX = Main.screenWidth * 0.5f; - Vector2 drawPosition = new Vector2(drawPositionX, yPageTop); - Rectangle pageRectangle = new Rectangle((int)drawPosition.X - (int)(pageTexture.Width * 0.5f * scale.X), (int)drawPosition.Y - (int)(pageTexture.Height * 0.5f * scale.Y), (int)(pageTexture.Width * scale.X), (int)(pageTexture.Height * scale.Y)); - - spriteBatch.Draw(pageTexture, drawPosition, null, Color.White, 0f, pageTexture.Size() / 2, scale, SpriteEffects.None, 0f); - - if (!HoveringOverBook) - HoveringOverBook = mouseRectangle.Intersects(pageRectangle); - } - } -} diff --git a/UI/ResourceSets/CalamityResourceOverlay.cs b/UI/ResourceSets/CalamityResourceOverlay.cs index e4fb0c820a..2bf13689b0 100644 --- a/UI/ResourceSets/CalamityResourceOverlay.cs +++ b/UI/ResourceSets/CalamityResourceOverlay.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using CalamityMod.CalPlayer; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -15,94 +16,102 @@ namespace CalamityMod.UI.ResourceSets { // Most of this is taken from ExampleMod. See that for additional explanations. private Dictionary> vanillaAssetCache = new(); - public string baseFolder = "CalamityMod/UI/ResourceSets/"; + + // Vanilla texture paths + const string fancyFolder = "Images/UI/PlayerResourceSets/FancyClassic/"; + const string barsFolder = "Images/UI/PlayerResourceSets/HorizontalBars/"; + + private Asset FancyHeartFill => field ??= Main.Assets.Request(fancyFolder + "Heart_Fill"); + private Asset FancyHeartFillB => field ??= Main.Assets.Request(fancyFolder + "Heart_Fill_B"); + private Asset FancyStarFill => field ??= Main.Assets.Request(fancyFolder + "Star_Fill"); + + private Asset BarMPFill => field ??= Main.Assets.Request(barsFolder + "MP_Fill"); + private Asset BarHPFill => field ??= Main.Assets.Request(barsFolder + "HP_Fill"); + private Asset BarHPFillHoney => field ??= Main.Assets.Request(barsFolder + "HP_Fill_Honey"); // Determines which health UI to draw based on player upgrades. - public string LifeTexturePath() + public static CalamityUIResourceSet GetLifeTextureSet() { - string folder = $"{baseFolder}HP"; CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); - if (modPlayer.chaliceOfTheBloodGod) // dozezoze - Chalice gets it's own heart color to make bleed indicator contrast consistent, and also because it looks cool - return folder + "Chalice"; + if (modPlayer.chaliceHeartStyle) // dozezoze - Chalice gets it's own heart color to make bleed indicator contrast consistent, and also because it looks cool + return CalamityUIResourceSets.HPChalice; if (modPlayer.sStrawberry) - return folder + "SacredStrawberry"; + return CalamityUIResourceSets.HPSacredStrawberry; if (modPlayer.tCloudberry) - return folder + "TaintedCloudberry"; + return CalamityUIResourceSets.HPTaintedCloudberry; if (modPlayer.mFruit) - return folder + "MiracleFruit"; + return CalamityUIResourceSets.HPMiracleFruit; if (modPlayer.sTangerine) - return folder + "SanguineTangerine"; - return string.Empty; + return CalamityUIResourceSets.HPSanguineTangerine; + return null; } // Determines which mana UI to draw based on player upgrades. - public string ManaTexturePath() + public static CalamityUIResourceSet GetManaTextureSet() { - string folder = $"{baseFolder}MP"; CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); + if (Main.LocalPlayer.statMana < 0) + return CalamityUIResourceSets.MPManaBurn; if (modPlayer.pHeart) - return folder + "PhantomHeart"; + return CalamityUIResourceSets.MPPhantomHeart; if (modPlayer.eCore) - return folder + "EtherealCore"; + return CalamityUIResourceSets.MPEtherealCore; if (modPlayer.cShard) - return folder + "CometShard"; - return string.Empty; + return CalamityUIResourceSets.MPCometShard; + return null; } public override void PostDrawResource(ResourceOverlayDrawContext context) { Asset asset = context.texture; - // Vanilla texture paths - string fancyFolder = "Images/UI/PlayerResourceSets/FancyClassic/"; - string barsFolder = "Images/UI/PlayerResourceSets/HorizontalBars/"; - if (ManaTexturePath() != string.Empty) + var manaTextureSet = GetManaTextureSet(); + if (manaTextureSet != null) { // Draw stars for Classic and Fancy - if (asset == TextureAssets.Mana || CompareAssets(asset, fancyFolder + "Star_Fill")) + if (asset == TextureAssets.Mana || asset == FancyStarFill) { - context.texture = ModContent.Request(ManaTexturePath() + "Star"); + context.texture = manaTextureSet.Star; context.Draw(); } // Draw mana bars - else if (CompareAssets(asset, barsFolder + "MP_Fill")) + else if (asset == BarMPFill) { - context.texture = ModContent.Request(ManaTexturePath() + "Bar"); + context.texture = manaTextureSet.Bar; context.Draw(); } } - if (LifeTexturePath() == string.Empty) - return; - - // Draw hearts for Classic and Fancy - if (asset == TextureAssets.Heart || asset == TextureAssets.Heart2 || CompareAssets(asset, fancyFolder + "Heart_Fill") || CompareAssets(asset, fancyFolder + "Heart_Fill_B")) + var lifeTextureSet = GetLifeTextureSet(); + if (lifeTextureSet != null) { - context.texture = ModContent.Request(LifeTexturePath() + "Heart"); - context.Draw(); - } - // Draw health bars - else if (CompareAssets(asset, barsFolder + "HP_Fill") || CompareAssets(asset, barsFolder + "HP_Fill_Honey")) - { - context.texture = ModContent.Request(LifeTexturePath() + "Bar"); - context.Draw(); + // Draw hearts for Classic and Fancy + if (asset == TextureAssets.Heart || asset == TextureAssets.Heart2 || asset == FancyHeartFill || asset == FancyHeartFillB) + { + context.texture = lifeTextureSet.Heart; + context.Draw(); + } + // Draw health bars + else if (asset == BarHPFill || asset == BarHPFillHoney) + { + context.texture = lifeTextureSet.Bar; + context.Draw(); + } } } // dozezoze - this method is where Chalice's bleed overlay is drawn. This can almost certainly be optimized, but it shouldn't cause problems. public override void PostDrawResourceDisplay(PlayerStatsSnapshot snapshot, IPlayerResourcesDisplaySet displaySet, bool drawingLife, Color textColor, bool drawText) { - - - var CalPlayer = Main.LocalPlayer.Calamity(); - if (!CalPlayer.chaliceOfTheBloodGod) return; var Player = Main.LocalPlayer; - var bleed = CalPlayer.chaliceBleedoutBuffer; - var hearts = snapshot.AmountOfLifeHearts; + var CalPlayer = Player.Calamity(); if (drawingLife) { - var height = 0; + if (!CalPlayer.chaliceHeartStyle) + return; + var bleed = CalPlayer.chaliceBleedoutBuffer; + var hearts = snapshot.AmountOfLifeHearts; int drawType = -1; //0 - bars 1- regular heart 2 - fancy heart Vector2 position = new Vector2(Main.screenWidth - 60, 28); @@ -110,16 +119,13 @@ namespace CalamityMod.UI.ResourceSets switch (displaySet.NameKey) { case "HorizontalBarsWithText": - height = 12; drawType = 0; break; case "HorizontalBarsWithFullText": - height = 12; position.Y -= 2; drawType = 0; break; case "HorizontalBars": - height = 12; position.Y -= 4; drawType = 0; break; @@ -142,38 +148,31 @@ namespace CalamityMod.UI.ResourceSets } if (drawType == 0) //bars { + int width = snapshot.AmountOfLifeHearts * 12; + float pixelsPerLife = 12f / snapshot.LifePerSegment; + int deadPixels = (int)MathF.Floor((snapshot.LifeMax - snapshot.Life) * pixelsPerLife); + int bleedPixels = (int)MathF.Ceiling((float)bleed * pixelsPerLife); + bleedPixels = Math.Min(bleedPixels, width - deadPixels); - // This works by dynamically creating a texture that it then draws over the life bar. - int width = 12 * snapshot.AmountOfLifeHearts; - GraphicsDevice _graphicsDevice = Main.graphics.GraphicsDevice; - var barOverlay = new Texture2D(_graphicsDevice, width, 12); - Color[] barTextureData = new Color[12*12]; - ModContent.Request("CalamityMod/UI/ResourceSets/HPChaliceBleedBar").Value.GetData(barTextureData); - var pixelsPerLife = 12f / snapshot.LifePerSegment; - int deadPixels = (int)Math.Floor((snapshot.LifeMax - snapshot.Life) * pixelsPerLife); - var bleedPixels = Math.Round(bleed * pixelsPerLife); + if (bleedPixels < 0) + return; - Color[] textureData = new Color[width * 12]; + int barMaxStatX = (int)position.X - width; + int drawX = barMaxStatX + deadPixels; - - for (int i = 0; i < textureData.Length; i++) + using (Main.spriteBatch.Scope()) { - var bleedCol = new Color(0, 0, 0, 0); - if ((i % width < bleedPixels + deadPixels) && !(i % width < deadPixels)) - { - bleedCol = barTextureData[((i % 12)+(i/width)*12)]; - //bleedCol = new Color(0f, 0.3f, 0.75f, 0.5f); - } - textureData[i] = bleedCol; - + var bleedDrawPos = new Vector2(drawX, position.Y); + var bleedDrawRect = new Rectangle(deadPixels % 12, 0, bleedPixels, 12); + var bleedDrawOrigin = new Vector2(0, 0); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.UIScaleMatrix); + Main.spriteBatch.Draw(CalamityUIResourceSets.HPChaliceBleed.Bar.Value, bleedDrawPos, bleedDrawRect, Color.White, 0, bleedDrawOrigin, 1, SpriteEffects.None, 1); + Main.spriteBatch.End(); } - - barOverlay.SetData(textureData); - Main.spriteBatch.Draw(barOverlay, position, null, Color.White, 0, new Vector2(width, 0), 1, SpriteEffects.None, 1); } else if (drawType == 1) //default heart { - Texture2D heartTexture = ModContent.Request("CalamityMod/UI/ResourceSets/HPChaliceBleedHeart").Value; + Texture2D heartTexture = CalamityUIResourceSets.HPChaliceBleed.Heart.Value; for (int i = 0; i < hearts; i++) { Vector2 PosOffset = new Vector2((i >= 10 ? i - 10 : i) * 26, Math.Min(MathF.Floor(i / 10), 1) * 26); @@ -185,7 +184,7 @@ namespace CalamityMod.UI.ResourceSets } else if (drawType == 2) //fancy heart. this is the same as default but with different distances between hearts { - Texture2D heartTexture = ModContent.Request("CalamityMod/UI/ResourceSets/HPChaliceBleedHeart").Value; + Texture2D heartTexture = CalamityUIResourceSets.HPChaliceBleed.Heart.Value; for (int i = 0; i < hearts; i++) { Vector2 PosOffset = new Vector2((i >= 10 ? i - 10 : i) * 24, Math.Min(MathF.Floor(i / 10), 1) * 28); @@ -196,16 +195,90 @@ namespace CalamityMod.UI.ResourceSets } } } + // This is where Mana Burn is drawn + else if (Player.statMana < 0) + { + var manaSet = GetManaTextureSet(); + var mana = -Player.statMana; + var stars = snapshot.AmountOfManaStars; + int drawType = -1; //0 - bars 1- regular heart 2 - fancy heart + Vector2 position = new Vector2(Main.screenWidth - 70, 52); + // This sets which bleed overlay draw style to use, as well as the position needed for the selected stat display + switch (displaySet.NameKey) + { + case "HorizontalBarsWithText": + drawType = 0; + break; + case "HorizontalBarsWithFullText": + position.Y -= 2; + drawType = 0; + break; + case "HorizontalBars": + position.Y -= 4; + drawType = 0; + break; + case "Default": + drawType = 1; + position = new Vector2(Main.screenWidth - 25, 43); + break; + case "New": + drawType = 2; + position = new Vector2(Main.screenWidth - 25, 38); + break; + case "NewWithText": + drawType = 2; + position = new Vector2(Main.screenWidth - 25, 38); + break; + } + if (drawType == -1) + { + return; // Loaded HP style doesn't match any of the vanilla ones, so we won't draw the overlay. + } + if (drawType == 0) //bars + { + float pixelsPerStar = 12f / snapshot.ManaPerSegment; + int bleedPixels = (int)MathF.Ceiling((float)mana * pixelsPerStar); - } + if (bleedPixels < 0) + return; - private bool CompareAssets(Asset currentAsset, string compareAssetPath) - { - if (!vanillaAssetCache.TryGetValue(compareAssetPath, out var asset)) - asset = vanillaAssetCache[compareAssetPath] = Main.Assets.Request(compareAssetPath); + using (Main.spriteBatch.Scope()) + { + var bleedDrawPos = new Vector2(position.X, position.Y); + var bleedDrawRect = new Rectangle(-(bleedPixels % 12), 0, bleedPixels, 12); + var bleedDrawOrigin = new Vector2(bleedPixels, 0); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.UIScaleMatrix); + Main.spriteBatch.Draw(CalamityUIResourceSets.MPManaBurn.Bar.Value, bleedDrawPos, bleedDrawRect, Color.White, 0, bleedDrawOrigin, 1, SpriteEffects.None, 1); + Main.spriteBatch.End(); + } + } + else if (drawType == 1) //default heart + { + Texture2D heartTexture = manaSet.Star.Value; + for (int i = 0; i < stars; i++) + { + Vector2 PosOffset = new Vector2(0, 28 * i); + var opacity = Math.Clamp(-(i * snapshot.ManaPerSegment - snapshot.Mana) / snapshot.ManaPerSegment, -100, 100); + if ((i) * snapshot.ManaPerSegment > -snapshot.Mana) opacity = 0f; + opacity = Math.Clamp(-((i * snapshot.ManaPerSegment - (float)mana) / snapshot.ManaPerSegment), 0, 1); + Main.spriteBatch.Draw(heartTexture, position + PosOffset, null, Color.White, 0, heartTexture.Size() / 2, 1 * opacity, SpriteEffects.None, 1); + } + } + else if (drawType == 2) //fancy heart. this is the same as default but with different distances between hearts + { + Texture2D heartTexture = manaSet.Star.Value; + for (int i = 0; i < stars; i++) + { + Vector2 PosOffset = new Vector2(0, 22 * i); + var opacity = Math.Clamp(-(i * snapshot.ManaPerSegment - snapshot.Mana) / snapshot.ManaPerSegment, -100, 100); + if ((i) * snapshot.ManaPerSegment > -snapshot.Mana) opacity = 0f; + opacity = Math.Clamp(-((i * snapshot.ManaPerSegment - (float)mana) / snapshot.ManaPerSegment), 0, 1); + Main.spriteBatch.Draw(heartTexture, position + PosOffset, null, Color.White, 0, heartTexture.Size() / 2, 1 * opacity, SpriteEffects.None, 1); + } + } + } - return currentAsset == asset; } } } diff --git a/UI/ResourceSets/CalamityUIResourceSets.cs b/UI/ResourceSets/CalamityUIResourceSets.cs new file mode 100644 index 0000000000..665b3460b0 --- /dev/null +++ b/UI/ResourceSets/CalamityUIResourceSets.cs @@ -0,0 +1,63 @@ +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria.ModLoader; + +namespace CalamityMod.UI.ResourceSets; + +public record CalamityUIResourceSet(Asset Bar, Asset Obj) +{ + public Asset Heart => Obj; + public Asset Star => Obj; +} + +public sealed class CalamityUIResourceSets : ILoadable +{ + public static string BasePath => "CalamityMod/UI/ResourceSets/"; + + public static CalamityUIResourceSet HPChalice { get; private set; } + public static CalamityUIResourceSet HPChaliceBleed { get; private set; } + public static CalamityUIResourceSet HPMiracleFruit { get; private set; } + public static CalamityUIResourceSet HPSacredStrawberry { get; private set; } + public static CalamityUIResourceSet HPSanguineTangerine { get; private set; } + public static CalamityUIResourceSet HPTaintedCloudberry { get; private set; } + + public static CalamityUIResourceSet MPCometShard { get; private set; } + public static CalamityUIResourceSet MPEtherealCore { get; private set; } + public static CalamityUIResourceSet MPManaBurn { get; private set; } + public static CalamityUIResourceSet MPPhantomHeart { get; private set; } + + private static CalamityUIResourceSet LoadResourceSet(string path, bool isHP) + { + return new(Bar: ModContent.Request(BasePath + path + "Bar"), Obj: ModContent.Request(BasePath + path + (isHP ? "Heart" : "Star"))); + } + + void ILoadable.Load(Mod mod) + { + HPChalice = LoadResourceSet(nameof(HPChalice), isHP: true); + HPChaliceBleed = LoadResourceSet(nameof(HPChaliceBleed), isHP: true); + HPMiracleFruit = LoadResourceSet(nameof(HPMiracleFruit), isHP: true); + HPSacredStrawberry = LoadResourceSet(nameof(HPSacredStrawberry), isHP: true); + HPSanguineTangerine = LoadResourceSet(nameof(HPSanguineTangerine), isHP: true); + HPTaintedCloudberry = LoadResourceSet(nameof(HPTaintedCloudberry), isHP: true); + + MPCometShard = LoadResourceSet(nameof(MPCometShard), isHP: false); + MPEtherealCore = LoadResourceSet(nameof(MPEtherealCore), isHP: false); + MPManaBurn = LoadResourceSet(nameof(MPManaBurn), isHP: false); + MPPhantomHeart = LoadResourceSet(nameof(MPPhantomHeart), isHP: false); + } + + void ILoadable.Unload() + { + HPChalice = null; + HPChaliceBleed = null; + HPMiracleFruit = null; + HPSacredStrawberry = null; + HPSanguineTangerine = null; + HPTaintedCloudberry = null; + + MPCometShard = null; + MPEtherealCore = null; + MPManaBurn = null; + MPPhantomHeart = null; + } +} diff --git a/UI/ResourceSets/MPManaBurnBar.png b/UI/ResourceSets/MPManaBurnBar.png new file mode 100644 index 0000000000..ceb93f277d Binary files /dev/null and b/UI/ResourceSets/MPManaBurnBar.png differ diff --git a/UI/ResourceSets/MPManaBurnStar.png b/UI/ResourceSets/MPManaBurnStar.png new file mode 100644 index 0000000000..d5cf117948 Binary files /dev/null and b/UI/ResourceSets/MPManaBurnStar.png differ diff --git a/UI/Rippers/RipperUI.cs b/UI/Rippers/RipperUI.cs index 424310e6ec..0ecab2c12f 100644 --- a/UI/Rippers/RipperUI.cs +++ b/UI/Rippers/RipperUI.cs @@ -146,7 +146,7 @@ namespace CalamityMod.UI.Rippers changed = true; } if (changed) - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } if (modPlayer.AdrenalineEnabled) @@ -165,7 +165,7 @@ namespace CalamityMod.UI.Rippers changed = true; } if (changed) - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } #region Mouse Interaction @@ -222,10 +222,10 @@ namespace CalamityMod.UI.Rippers } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (rageDragOffset.HasValue && ms.LeftButton == ButtonState.Released) { rageDragOffset = null; - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } } else if (adrenHover) @@ -264,10 +264,10 @@ namespace CalamityMod.UI.Rippers } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (adrenDragOffset.HasValue && ms.LeftButton == ButtonState.Released) { adrenDragOffset = null; - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } } #endregion diff --git a/UI/SpeedrunTimerUI.cs b/UI/SpeedrunTimerUI.cs index 19eb113455..43609177a0 100644 --- a/UI/SpeedrunTimerUI.cs +++ b/UI/SpeedrunTimerUI.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.AstrumDeus; @@ -10,7 +9,6 @@ using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; -using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.OldDuke; @@ -118,7 +116,7 @@ namespace CalamityMod.UI 28 => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]].Value, 29 => TextureAssets.NpcHeadBoss[8].Value, // Moon Lord 30 => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]].Value, - 31 => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]].Value, + 31 => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]].Value, 32 => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]].Value, 33 => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]].Value, 34 => ModContent.Request("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss").Value, diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 42c9269e04..c672532e74 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -6,7 +6,6 @@ using Microsoft.Xna.Framework.Input; using ReLogic.Content; using Terraria; using Terraria.ModLoader; -using static Microsoft.Xna.Framework.Input.Keys; namespace CalamityMod.UI { @@ -76,7 +75,7 @@ namespace CalamityMod.UI } if (changed) - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } Rectangle mouseHitbox = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); @@ -98,7 +97,7 @@ namespace CalamityMod.UI string maxStealthStr = (100f * modPlayer.rogueStealthMax).ToString("n2"); string textToDisplay = $"{CalamityUtils.GetTextValue("UI.Stealth")}: {stealthStr}/{maxStealthStr}\n"; - if (!Main.keyState.IsKeyDown(LeftShift)) + if (!Main.keyState.PressingShift()) { textToDisplay += CalamityUtils.GetTextValue("UI.StealthShiftText"); } @@ -136,10 +135,10 @@ namespace CalamityMod.UI } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } } } diff --git a/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs b/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs index 04b5b562da..924de8f7cb 100644 --- a/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs +++ b/UI/SulphurousWaterMeter/SulphurousWaterMeterUI.cs @@ -70,7 +70,7 @@ namespace CalamityMod.UI.SulphurousWaterMeter } if (changed) - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } Rectangle mouseHitbox = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); @@ -120,10 +120,10 @@ namespace CalamityMod.UI.SulphurousWaterMeter } // When the mouse is released, save the config and destroy the drag offset. - if (ms.LeftButton == ButtonState.Released) + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) { dragOffset = null; - CalamityClientConfig.SaveConfig(); + CalamityClientConfig.Instance.SaveChanges(); } } else diff --git a/UI/UnstableCastersGauntlet/VisMeter.png b/UI/UnstableCastersGauntlet/VisMeter.png new file mode 100644 index 0000000000..60cbb26bb5 Binary files /dev/null and b/UI/UnstableCastersGauntlet/VisMeter.png differ diff --git a/UI/UnstableCastersGauntlet/VisMeterBorder.png b/UI/UnstableCastersGauntlet/VisMeterBorder.png new file mode 100644 index 0000000000..99524fdaea Binary files /dev/null and b/UI/UnstableCastersGauntlet/VisMeterBorder.png differ diff --git a/UI/UnstableCastersGauntlet/VisUI.cs b/UI/UnstableCastersGauntlet/VisUI.cs new file mode 100644 index 0000000000..33f697ee43 --- /dev/null +++ b/UI/UnstableCastersGauntlet/VisUI.cs @@ -0,0 +1,151 @@ +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.UI.DraedonsArsenal +{ + [Autoload(Side = ModSide.Client)] + public sealed class VisUI : ModSystem + { + // Base pulled from Arsenal charge UI + // Defaults to same pos as arsenal charge meter since there isn't a state where both would coexist + internal const float DefaultChargePosX = 50.104603f; + internal const float DefaultChargePosY = 58.05169f; + private const float MouseDragEpsilon = 0.05f; // 0.05% + + private static Vector2? dragOffset = null; + private static Texture2D edgeTexture, barTexture; + + public override void OnModLoad() + { + edgeTexture = ModContent.Request("CalamityMod/UI/UnstableCastersGauntlet/VisMeterBorder", AssetRequestMode.ImmediateLoad).Value; + barTexture = ModContent.Request("CalamityMod/UI/UnstableCastersGauntlet/VisMeter", AssetRequestMode.ImmediateLoad).Value; + Reset(); + } + + public override void Unload() + { + Reset(); + edgeTexture = barTexture = null; + } + + private static void Reset() => dragOffset = null; + + public static void Draw(SpriteBatch spriteBatch, Player player) + { + // Sanity check the planned position before drawing + Vector2 screenRatioPosition = new Vector2(CalamityClientConfig.Instance.ChargeMeterPosX, CalamityClientConfig.Instance.ChargeMeterPosY); + if (screenRatioPosition.X < 0f || screenRatioPosition.X > 100f) + screenRatioPosition.X = DefaultChargePosX; + if (screenRatioPosition.Y < 0f || screenRatioPosition.Y > 100f) + screenRatioPosition.Y = DefaultChargePosY; + + // Convert the screen ratio position to an absolute position in pixels + // Cast to integer to prevent blurriness which results from decimal pixel positions + float uiScale = Main.UIScale; + Vector2 screenPos = screenRatioPosition; + screenPos.X = (int)(screenPos.X * 0.01f * Main.screenWidth); + screenPos.Y = (int)(screenPos.Y * 0.01f * Main.screenHeight); + + void SavePosition() + { + bool changed = false; + if (CalamityClientConfig.Instance.ChargeMeterPosX != screenRatioPosition.X) + { + CalamityClientConfig.Instance.ChargeMeterPosX = screenRatioPosition.X; + changed = true; + } + if (CalamityClientConfig.Instance.ChargeMeterPosY != screenRatioPosition.Y) + { + CalamityClientConfig.Instance.ChargeMeterPosY = screenRatioPosition.Y; + changed = true; + } + if (changed) + CalamityClientConfig.Instance.SaveChanges(); + } + + // If the Charge Meter is turned off or the player is not holding an item, stop. + Item heldItem = player.HeldItem; + if (!CalamityClientConfig.Instance.ChargeMeter || heldItem is null || heldItem.IsAir) + { + Reset(); + SavePosition(); + return; + } + + // If the player is not holding the correct item, stop. + if (heldItem.type != ModContent.ItemType()) + { + Reset(); + SavePosition(); + return; + } + + CalamityPlayer modPlayer = player.Calamity(); + DrawChargeBar(spriteBatch, modPlayer.unstableCastersGauntletVis / 100f, screenPos); + + + Rectangle mouseHitbox = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); + Rectangle chargeBar = Utils.CenteredRectangle(screenPos, edgeTexture.Size() * uiScale * 0.8f); + MouseState ms = Mouse.GetState(); + Vector2 mousePos = Main.MouseScreen; + + if (chargeBar.Intersects(mouseHitbox)) + { + if (!CalamityClientConfig.Instance.MeterPosLock) + Main.LocalPlayer.mouseInterface = true; + + // If the mouse is on top of the meter, show the exact numeric charge. + string percentString = (player.Calamity().unstableCastersGauntletVis).ToString("n2"); + Main.instance.MouseText($"{CalamityUtils.GetTextValue("UI.Vis")}: {percentString}%", 0, 0, -1, -1, -1, -1); + + Vector2 newScreenRatioPosition = screenRatioPosition; + // Handle mouse dragging + if (!CalamityClientConfig.Instance.MeterPosLock && ms.LeftButton == ButtonState.Pressed) + { + // If the drag offset doesn't exist yet, create it. + if (!dragOffset.HasValue) + dragOffset = mousePos - screenPos; + + // Given the mouse's absolute current position, compute where the corner of the stealth bar should be based on the original drag offset. + Vector2 newCorner = mousePos - dragOffset.GetValueOrDefault(Vector2.Zero); + + // Convert the new corner position into a screen ratio position. + newScreenRatioPosition.X = (100f * newCorner.X) / Main.screenWidth; + newScreenRatioPosition.Y = (100f * newCorner.Y) / Main.screenHeight; + } + + // Compute the change in position. If it is large enough, actually move the meter + Vector2 delta = newScreenRatioPosition - screenRatioPosition; + if (Math.Abs(delta.X) >= MouseDragEpsilon || Math.Abs(delta.Y) >= MouseDragEpsilon) + { + CalamityClientConfig.Instance.ChargeMeterPosX = newScreenRatioPosition.X; + CalamityClientConfig.Instance.ChargeMeterPosY = newScreenRatioPosition.Y; + } + + // When the mouse is released, save the config and destroy the drag offset. + if (dragOffset.HasValue && ms.LeftButton == ButtonState.Released) + { + dragOffset = null; + CalamityClientConfig.Instance.SaveChanges(); + } + } + } + + private static void DrawChargeBar(SpriteBatch spriteBatch, float chargeRatio, Vector2 screenPos) + { + float uiScale = Main.UIScale; + float offset = (edgeTexture.Width - barTexture.Width) * 0.5f; + spriteBatch.Draw(edgeTexture, screenPos, null, Color.White, 0f, edgeTexture.Size() * 0.5f, uiScale * 0.8f, SpriteEffects.None, 0); + + Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * chargeRatio), barTexture.Width); + spriteBatch.Draw(barTexture, screenPos + new Vector2(offset * uiScale, 0), barRectangle, Color.White, 0f, edgeTexture.Size() * 0.5f, uiScale * 0.85f, SpriteEffects.None, 0); + } + } +} diff --git a/UI/VanillaBossBars/AstrumDeusBossBar.cs b/UI/VanillaBossBars/AstrumDeusBossBar.cs index 3513f1cbc7..11298339a9 100644 --- a/UI/VanillaBossBars/AstrumDeusBossBar.cs +++ b/UI/VanillaBossBars/AstrumDeusBossBar.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using CalamityMod.NPCs.AstrumDeus; using CalamityMod.World; using Microsoft.Xna.Framework; diff --git a/UI/VanillaBossBars/CeaselessVoidBossBar.cs b/UI/VanillaBossBars/CeaselessVoidBossBar.cs index 29fb7c446c..f1d8fa8650 100644 --- a/UI/VanillaBossBars/CeaselessVoidBossBar.cs +++ b/UI/VanillaBossBars/CeaselessVoidBossBar.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/UI/VanillaBossBars/CryogenBossBar.cs b/UI/VanillaBossBars/CryogenBossBar.cs index 7342cd1913..2980d88b93 100644 --- a/UI/VanillaBossBars/CryogenBossBar.cs +++ b/UI/VanillaBossBars/CryogenBossBar.cs @@ -1,14 +1,9 @@ -using System; -using System.Collections.Generic; -using CalamityMod.NPCs.Cryogen; -using CalamityMod.World; +using CalamityMod.NPCs.Cryogen; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.GameContent; using Terraria.GameContent.UI.BigProgressBar; -using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; diff --git a/UI/VanillaBossBars/ExoMechsBossBar.cs b/UI/VanillaBossBars/ExoMechsBossBar.cs index 2c3a0d0986..21ff63dbed 100644 --- a/UI/VanillaBossBars/ExoMechsBossBar.cs +++ b/UI/VanillaBossBars/ExoMechsBossBar.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.ExoMechs.Artemis; using CalamityMod.NPCs.ExoMechs.Thanatos; using Microsoft.Xna.Framework; diff --git a/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs b/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs index 070058dcf8..42204f7046 100644 --- a/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs +++ b/UI/VanillaBossBars/LeviathanAnahitaBossBar.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using CalamityMod.NPCs.Leviathan; +using CalamityMod.NPCs.Leviathan; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; diff --git a/UI/VanillaBossBars/ProfanedGuardianBossBar.cs b/UI/VanillaBossBars/ProfanedGuardianBossBar.cs index 35afbb34b6..f728005746 100644 --- a/UI/VanillaBossBars/ProfanedGuardianBossBar.cs +++ b/UI/VanillaBossBars/ProfanedGuardianBossBar.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.ProfanedGuardians; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; diff --git a/UI/VanillaBossBars/RavagerBossBar.cs b/UI/VanillaBossBars/RavagerBossBar.cs index eabbef027c..289ba6f7ee 100644 --- a/UI/VanillaBossBars/RavagerBossBar.cs +++ b/UI/VanillaBossBars/RavagerBossBar.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using CalamityMod.NPCs.Ravager; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/UI/VanillaBossBars/RevBrainOfCthulhuBossBar.cs b/UI/VanillaBossBars/RevBrainOfCthulhuBossBar.cs new file mode 100644 index 0000000000..70a5c32f90 --- /dev/null +++ b/UI/VanillaBossBars/RevBrainOfCthulhuBossBar.cs @@ -0,0 +1,44 @@ +using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.UI.VanillaBossBars +{ + internal class RevBrainOfCthulhuBossBar : ModBossBar + { + public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCID.BrainofCthulhu]]; + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float life, ref float lifeMax, ref float shield, ref float shieldMax) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + if (!target.active) + return false; + + // Get the boss health, obviously + life = target.life; + lifeMax = target.lifeMax; + + // Reset the shield + shield = 0f; + shieldMax = 0f; + + if (NPC.AnyNPCs(NPCID.Creeper)) + { + foreach (NPC creeper in Main.ActiveNPCs) + { + if (creeper.type != NPCID.Creeper) + continue; + shieldMax = creeper.lifeMax * BrainOfCthulhuAI.GetBrainOfCthuluCreepersCountRevDeath(); + shield += creeper.life; + } + } + return true; + } + } +} diff --git a/UI/VanillaBossBars/RevMoonLordBossBar.cs b/UI/VanillaBossBars/RevMoonLordBossBar.cs new file mode 100644 index 0000000000..d90123097e --- /dev/null +++ b/UI/VanillaBossBars/RevMoonLordBossBar.cs @@ -0,0 +1,81 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.UI.VanillaBossBars +{ + internal class RevMoonLordBossBar : ModBossBar + { + private List MoonLordPartIDs = [NPCID.MoonLordCore, NPCID.MoonLordHead, NPCID.MoonLordHand]; + private NPC _dummy; + + public override void SetStaticDefaults() + { + _dummy = new NPC(); + } + public override Asset GetIconTexture(ref Rectangle? iconFrame) => TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCID.MoonLordHead]]; + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float life, ref float lifeMax, ref float shield, ref float shieldMax) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + if ((!target.active || InBadAI(target)) && !TryFindingAnotherMoonLordPiece(ref info)) + return false; + + life = 0f; + lifeMax = 0f; + shield = 0f; + shieldMax = 0f; + + NPCSpawnParams dummy = default; + dummy.strengthMultiplierOverride = target.strengthMultiplier; + dummy.playerCountForMultiplayerDifficultyOverride = target.statsAreScaledForThisManyPlayers; + _dummy.SetDefaults(NPCID.MoonLordCore, dummy); + lifeMax += _dummy.lifeMax; + _dummy.SetDefaults(NPCID.MoonLordHead, dummy); + lifeMax += _dummy.lifeMax; + _dummy.SetDefaults(NPCID.MoonLordHand, dummy); + lifeMax += _dummy.lifeMax * 2; + + // Find all the Moon Lord parts, and add their totals. Do not add them if in a "bad AI" state. + foreach (NPC n in Main.ActiveNPCs) + { + if (MoonLordPartIDs.Contains(n.type) && !InBadAI(n)) + { + life += n.life; + } + } + + return true; + } + + private static bool InBadAI(NPC n) + { + // If in death animation, or in initial startup state + if (n.type == NPCID.MoonLordCore && (n.ai[0] == 2f || n.ai[0] == -1f || n.localAI[3] == 0f)) + return true; + // If in death animation, or this eye has been "killed" + if (n.ai[0] == -2f || n.ai[0] == -3f || n.Calamity().newAI[0] == 1f) + return true; + return false; + } + + private bool TryFindingAnotherMoonLordPiece(ref BigProgressBarInfo info) + { + foreach (NPC n in Main.ActiveNPCs) + { + if (MoonLordPartIDs.Contains(n.type) && !InBadAI(n)) + { + info.npcIndexToAimAt = n.whoAmI; + return true; + } + } + return false; + } + } +} diff --git a/UI/VanillaBossBars/SlimeGodBossBar.cs b/UI/VanillaBossBars/SlimeGodBossBar.cs index fb329da1ff..465515c63a 100644 --- a/UI/VanillaBossBars/SlimeGodBossBar.cs +++ b/UI/VanillaBossBars/SlimeGodBossBar.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using CalamityMod.NPCs.SlimeGod; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/UI/WindowTitles.cs b/UI/WindowTitles.cs new file mode 100644 index 0000000000..843587fe36 --- /dev/null +++ b/UI/WindowTitles.cs @@ -0,0 +1,56 @@ +using Terraria; +using Terraria.ModLoader; +using Terraria.Localization; +using System.Collections.Generic; +using System; +using System.Linq; +using System.Text.RegularExpressions; +using ReLogic.OS; + +namespace CalamityMod.UI +{ + public class WindowTitles : ModSystem + { + private static LocalizedText _calamityModifiedText; + private static bool loaded = false; + public override void PostSetupContent() + { + if (Main.dedServ) + return; + + Main.QueueMainThreadAction(() => + { + // the other method involving some terraria intrinsic function didn't work, so i'm just ignoring it + var vanillaTitles = Language.FindAll(new Regex("^GameTitle\\.")).ToList(); + var customTitles = Language.FindAll(new Regex("^Mods\\.CalamityMod\\.UI\\.WindowTitle\\.")).ToList(); + + var allTitles = new List(); + allTitles.AddRange(vanillaTitles); + allTitles.AddRange(customTitles); + + _calamityModifiedText ??= allTitles[Main.rand.Next(allTitles.Count)]; + + // this is what vanilla terraria does to set it's title, so i'm replicating that here + Platform.Get().SetUnicodeTitle(Main.instance.Window, _calamityModifiedText.Value); + Platform.Get().SetIcon(Main.instance.Window); + + loaded = true; + }); + } + + public override void Unload() + { + if (Main.dedServ) + return; + Main.QueueMainThreadAction(() => + { + Platform.Get().SetUnicodeTitle(Main.instance.Window, Lang.GetRandomGameTitle()); + Platform.Get().SetIcon(Main.instance.Window); + + _calamityModifiedText = null; + loaded = false; + }); + base.Unload(); + } + } +} diff --git a/Utilities/CollisionUtils.cs b/Utilities/CollisionUtils.cs index bcd80a65c7..5788363cb0 100644 --- a/Utilities/CollisionUtils.cs +++ b/Utilities/CollisionUtils.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; namespace CalamityMod { @@ -40,27 +41,20 @@ namespace CalamityMod /// The hitbox of the target to check. public static bool CircularHitboxCollision(Vector2 centerCheckPosition, float radius, Rectangle targetHitbox) { - // If the center intersects the hitbox, return true immediately - Rectangle center = new Rectangle((int)centerCheckPosition.X, (int)centerCheckPosition.Y, 1, 1); - if (center.Intersects(targetHitbox)) - return true; - float topLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopLeft()); - float topRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopRight()); - float bottomLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomLeft()); - float bottomRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomRight()); + if (radius <= 0f) + return false; - float distanceToClosestPoint = topLeftDistance; - if (topRightDistance < distanceToClosestPoint) - distanceToClosestPoint = topRightDistance; - if (bottomLeftDistance < distanceToClosestPoint) - distanceToClosestPoint = bottomLeftDistance; - if (bottomRightDistance < distanceToClosestPoint) - distanceToClosestPoint = bottomRightDistance; + float closestX = MathHelper.Clamp(centerCheckPosition.X, targetHitbox.Left, targetHitbox.Right); + float closestY = MathHelper.Clamp(centerCheckPosition.Y, targetHitbox.Top, targetHitbox.Bottom); - return distanceToClosestPoint <= radius; + float dx = centerCheckPosition.X - closestX; + float dy = centerCheckPosition.Y - closestY; + + return (dx * dx + dy * dy) <= (radius * radius); } + /// /// Determines the distance required before a ray in a given direction from a given starting position hits solid tiles. Gives up after a certain quantity of tiles, or when a world border is reached. /// /// The point to check from. @@ -90,5 +84,153 @@ namespace CalamityMod return null; } + /// + /// Determines the distance required before a ray in a given direction from a given starting position hits solid tiles, taking slopes into account. + /// + /// The point to check from. + /// The direction in which tiles are checked. + /// How far in the direction that will be checked. + /// How many units moved forward each loop. Greater = less precise. + /// The length until the first collision detected. Returns input length if no collision occurs. + public static float PreciseDistanceToTileCollisionHit(Vector2 start, float rotation, float length, float step = 1) + { + Vector2 unitVect = rotation.ToRotationVector2(); + Vector2 end = unitVect * length; + + if (length < 1f) + { + Point endWorldPos = end.ToTileCoordinates(); + return ParanoidTileRetrieval(endWorldPos.X, endWorldPos.Y).IsTileSolid() ? 0 : length; + } + + Vector2 currentPos = start; + Point lastAirPos = new Point(-1, -1); + for (float i = 0; i < length; i += step) + { + currentPos += unitVect * step; + + Point tilePos = currentPos.ToTileCoordinates(); + + if (tilePos == lastAirPos) + continue; + + if (!WorldGen.InWorld(tilePos.X, tilePos.Y)) + continue; + + Tile tile = Main.tile[tilePos.X, tilePos.Y]; + if (!tile.IsTileSolid()) + { + lastAirPos = tilePos; + continue; + } + + if (tile.Slope == SlopeType.Solid && !tile.IsHalfBlock) + return (currentPos - start).Length(); + + Vector2 tileWorldPos = new Vector2(tilePos.X * 16, tilePos.Y * 16); + Vector2 currentPosInTile = currentPos - tileWorldPos; + if (tile.IsHalfBlock) + { + if (currentPosInTile.Y >= 8f) + return (currentPos - start).Length(); + } + else if (tile.Slope == SlopeType.SlopeDownLeft) + { + if (currentPosInTile.X <= currentPosInTile.Y) + return (currentPos - start).Length(); + } + else if (tile.Slope == SlopeType.SlopeDownRight) + { + if ((16 - currentPosInTile.X) <= currentPosInTile.Y) + return (currentPos - start).Length(); + } + else if (tile.Slope == SlopeType.SlopeUpLeft) + { + if (currentPosInTile.X <= (16 - currentPosInTile.Y)) + return (currentPos - start).Length(); + } + else if (tile.Slope == SlopeType.SlopeUpRight) + { + if (currentPosInTile.X >= currentPosInTile.Y) + return (currentPos - start).Length(); + } + } + + return length; + } + /// + /// Determines the distance required before a ray in a given direction from a given starting position hits solid tiles, taking slopes into account. + /// + /// The point to check from. + /// The direction in which tiles are checked. + /// How far in the direction that will be checked. + /// How many units moved forward each loop. Greater = less precise. + /// False if there is a tile collision before checking the full length of the line. + public static bool PreciseCanHitInLine(Vector2 start, float rotation, float length, float step = 1) + { + Vector2 unitVect = rotation.ToRotationVector2(); + Vector2 end = unitVect * length; + + if (length < 1f) + { + Point endWorldPos = end.ToTileCoordinates(); + return !ParanoidTileRetrieval(endWorldPos.X, endWorldPos.Y).IsTileSolid(); + } + + Vector2 currentPos = start; + Point lastAirPos = new Point(-1, -1); + for (float i = 0; i < length; i += step) + { + currentPos += unitVect * step; + + Point tilePos = currentPos.ToTileCoordinates(); + + if (tilePos == lastAirPos) + continue; + + if (!WorldGen.InWorld(tilePos.X, tilePos.Y)) + continue; + + Tile tile = Main.tile[tilePos.X, tilePos.Y]; + if (!tile.IsTileSolid()) + { + lastAirPos = tilePos; + continue; + } + + if (tile.Slope == SlopeType.Solid && !tile.IsHalfBlock) + return false; + + Vector2 tileWorldPos = new Vector2(tilePos.X * 16, tilePos.Y * 16); + Vector2 currentPosInTile = currentPos - tileWorldPos; + if (tile.IsHalfBlock) + { + if (currentPosInTile.Y >= 8f) + return false; + } + else if (tile.Slope == SlopeType.SlopeDownLeft) + { + if (currentPosInTile.X <= currentPosInTile.Y) + return false; + } + else if (tile.Slope == SlopeType.SlopeDownRight) + { + if ((16 - currentPosInTile.X) <= currentPosInTile.Y) + return false; + } + else if (tile.Slope == SlopeType.SlopeUpLeft) + { + if (currentPosInTile.X <= (16 - currentPosInTile.Y)) + return false; + } + else if (tile.Slope == SlopeType.SlopeUpRight) + { + if (currentPosInTile.X >= currentPosInTile.Y) + return false; + } + } + + return true; + } } } diff --git a/Utilities/Daybreak/Buffers/BuffersLoadingSystem.cs b/Utilities/Daybreak/Buffers/BuffersLoadingSystem.cs new file mode 100644 index 0000000000..5639dba82e --- /dev/null +++ b/Utilities/Daybreak/Buffers/BuffersLoadingSystem.cs @@ -0,0 +1,69 @@ +using CalamityMod.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Utilities.Daybreak.Buffers; + +/// +/// Handles loading and unloading for the Daybreak buffers systems. +/// +public class BuffersLoadingSystem : ModSystem +{ + public override void Load() + { + if (Main.dedServ) + return; + + Main.RunOnMainThread( + () => + { + // RenderTargetPool: Register frame lease disposal hook. + On_Main.DoDraw += RenderTargetPool_DoDrawHook; + + // RenderTargetPreserver: Set presentation parameters. + Main.graphics.GraphicsDevice.PresentationParameters.RenderTargetUsage = Microsoft.Xna.Framework.Graphics.RenderTargetUsage.PreserveContents; + Main.graphics.ApplyChanges(); + + // ScreenspaceTargetPool: Add resize hook. + On_Main.EnsureRenderTargetContent += ScreenspaceTargetPool_EnsureRenderTargetContentHook; + } + ); + } + + public override void Unload() + { + if (Main.dedServ) + return; + + Main.RunOnMainThread( + () => + { + // Unhook events. + On_Main.DoDraw -= RenderTargetPool_DoDrawHook; + On_Main.EnsureRenderTargetContent -= ScreenspaceTargetPool_EnsureRenderTargetContentHook; + + // Dispose shared pools. + RenderTargetPool.Shared.Dispose(); + ScreenspaceTargetPool.Shared.Dispose(); + ManagedRenderTargetPool.Shared.Dispose(); + } + ); + } + + private static void RenderTargetPool_DoDrawHook(On_Main.orig_DoDraw orig, Main self, Microsoft.Xna.Framework.GameTime time) + { + RenderTargetPool.ClearPendingLeases(); + orig(self, time); + } + + private static void ScreenspaceTargetPool_EnsureRenderTargetContentHook(On_Main.orig_EnsureRenderTargetContent orig, Main self) + { + // Let it run first to ensure tileTarget is initialized. We depend + // on it as an arbitrary target to provide us a fully-sized target + // when includes offscreenRange in the target size. + orig(self); + + ScreenspaceTargetPool.Shared.ResizeCachedTargets(self.GraphicsDevice); + ManagedRenderTargetPool.Shared.ResizeTargets(); + } +} diff --git a/Utilities/Daybreak/Buffers/EffectChaining.cs b/Utilities/Daybreak/Buffers/EffectChaining.cs new file mode 100644 index 0000000000..f98c6860bb --- /dev/null +++ b/Utilities/Daybreak/Buffers/EffectChaining.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; + +namespace CalamityMod.Utilities.Daybreak.Buffers; + +/// +/// An entry in an effect chain which an arbitrary function to apply a +/// shader, alongside any parameters to use for rendering the target with +/// the shader. +/// +/// Applies the effect. +/// +/// The parameters to use to render the texture with the effect. +/// +internal readonly record struct EffectChainEntry( + Action ApplyEffect, + SpriteBatchParameters Parameters = default +) +{ + /// + /// Applies a . + /// + public EffectChainEntry( + ShaderData shader, + SpriteBatchParameters parameters = default + ) : this(shader.Apply, parameters) { } + + /// + /// Applies an . + /// + public EffectChainEntry( + Effect effect, + SpriteBatchParameters parameters + ) : this( + ApplyEffectFunc(effect), + parameters + ) { } + + /// + /// Creates an entry from a player shader. + /// + /// The player context. + /// The shader. + /// The draw context, if any. + /// + /// The parameters to use when rendering the actual texture. + /// + public static EffectChainEntry FromPlayerShader( + Player player, + PlayerShader shader, + DrawData? drawData = null, + SpriteBatchParameters parameters = default + ) + { + // Transcribed and modified from PlayerDrawHelper.SetShaderForData. + Action shaderData = shader.ShaderType switch + { + PlayerDrawHelper.ShaderConfiguration.ArmorShader => () => GameShaders.Armor.Apply(shader.LocalIndex, player, drawData), + PlayerDrawHelper.ShaderConfiguration.HairShader => () => GameShaders.Hair.Apply(shader.LocalIndex, player, drawData), + PlayerDrawHelper.ShaderConfiguration.TileShader => Main.tileShader.CurrentTechnique.Passes[shader.LocalIndex].Apply, + PlayerDrawHelper.ShaderConfiguration.TilePaintID => Main.tileShader.CurrentTechnique.Passes[Main.ConvertPaintIdToTileShaderIndex(shader.LocalIndex, false, false)].Apply, + _ => throw new ArgumentOutOfRangeException(nameof(shader)), + }; + + return new EffectChainEntry(shaderData, parameters); + } + + private static Action ApplyEffectFunc(Effect effect, string pass = null) + { + return () => effect.CurrentTechnique.Passes[pass ?? effect.CurrentTechnique.Passes.First().Name].Apply(); + } +} + +/// +/// A scope which captures rendered data and applies multiple effects to it +/// as its output. +/// +public sealed class DrawWithEffectsScope : IDisposable +{ + private static readonly SpriteBatchSnapshot default_target_snapshot = new( + SpriteSortMode.Deferred, + BlendState.AlphaBlend, + SamplerState.LinearClamp, + DepthStencilState.None, + RasterizerState.CullCounterClockwise, + null, + Matrix.Identity + ); + + private static readonly SpriteBatchSnapshot effect_target_snapshot = new( + SpriteSortMode.Immediate, + BlendState.AlphaBlend, + SamplerState.LinearClamp, + DepthStencilState.None, + RasterizerState.CullCounterClockwise, + null, + Matrix.Identity + ); + + private readonly SpriteBatch spriteBatch; + private readonly GraphicsDevice graphicsDevice; + private readonly RenderTargetPool pool; + private readonly IEnumerable effects; + + private readonly RenderTargetDescriptor renderDesc; + private readonly int width; + private readonly int height; + private readonly SpriteBatchScope sbScope; + private readonly RenderTargetScope rtScope; + + /// + /// The final lease containing the rendered data as the result of all + /// applied effects. + /// + public RenderTargetLease Lease { get; private set; } + + /// + /// Initializes a scope to handle rendering with multiple effects. + ///
+ /// After creating the scope, proceed to handle rendering how you'd like + /// and then dispose of the object to render the final state to multiple + /// effects. + ///
+ /// + /// The to render with. + /// + /// + /// The to retrieve targets from. + /// + /// The size of the target to render to. + /// + /// Whether to preserve contents of existing targets before swapping to + /// the initial new target. + /// + /// + /// What color to clear the initial target to before use. + /// + /// + /// The descriptor of the initial target. + /// + /// + /// The parameters to initialize the to. + /// + /// The effects to render with. + internal DrawWithEffectsScope( + SpriteBatch spriteBatch, + RenderTargetPool pool, + Point targetSize, + bool preserveContents = true, + Color? clearColor = null, + RenderTargetDescriptor? descriptor = null, + SpriteBatchParameters parameters = default, + params IEnumerable effects + ) + { + ArgumentNullException.ThrowIfNull(spriteBatch); + ArgumentNullException.ThrowIfNull(pool); + + ArgumentOutOfRangeException.ThrowIfLessThan(targetSize.X, 1); + ArgumentOutOfRangeException.ThrowIfLessThan(targetSize.Y, 1); + + this.spriteBatch = spriteBatch; + graphicsDevice = spriteBatch.graphicsDevice; + this.pool = pool; + this.effects = effects; + + renderDesc = descriptor ?? RenderTargetDescriptor.Default; + width = Math.Max(1, targetSize.X); + height = Math.Max(1, targetSize.Y); + + Lease = pool.Rent(graphicsDevice, width, height, renderDesc); + + sbScope = spriteBatch.Scope(); + { + rtScope = Lease.Scope(preserveContents, clearColor); + spriteBatch.Begin(parameters.ToSnapshot(default_target_snapshot)); + } + } + + /// + /// Ends the rendering context, renders the data to targets with the + /// given effects applied, and prepares the leased target as the output + /// data. + /// + public void Dispose() + { + spriteBatch.End(); + rtScope.Dispose(); + + foreach (var effect in effects) + { + var nextLease = pool.Rent(graphicsDevice, width, height, renderDesc); + using (nextLease.Scope(clearColor: Color.Transparent)) + { + spriteBatch.Begin(effect.Parameters.ToSnapshot(effect_target_snapshot)); + effect.ApplyEffect(); + + spriteBatch.Draw(Lease.Target, Vector2.Zero, Color.White); + + spriteBatch.End(); + } + + Lease.Dispose(); + Lease = nextLease; + } + + sbScope.Dispose(); + } +} + +/// +/// Extensions to types for chaining effects. +/// +public static class EffectChainingExtensions +{ + /// + /// Initializes a with the given + /// parameters and returns it. + ///
+ /// See for information. + ///
+ /// + /// The scope, which should be disposed of to finalize rendering. + /// + internal static DrawWithEffectsScope DrawWithEffects( + this SpriteBatch spriteBatch, + RenderTargetPool pool, + Point targetSize, + bool preserveContents = true, + Color? clearColor = null, + RenderTargetDescriptor? descriptor = null, + SpriteBatchParameters parameters = default, + params IEnumerable effects + ) + { + return new DrawWithEffectsScope( + spriteBatch, + pool, + targetSize, + preserveContents, + clearColor, + descriptor, + parameters, + effects + ); + } +} diff --git a/Utilities/Daybreak/Buffers/RenderTargetPool.cs b/Utilities/Daybreak/Buffers/RenderTargetPool.cs new file mode 100644 index 0000000000..9e5beb98e9 --- /dev/null +++ b/Utilities/Daybreak/Buffers/RenderTargetPool.cs @@ -0,0 +1,479 @@ +using System; +using System.Buffers; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; + +namespace CalamityMod.Utilities.Daybreak.Buffers; + +/// +/// Describes the creation parameters of a render target. +/// +/// +/// +/// +/// +/// +public readonly record struct RenderTargetDescriptor( + SurfaceFormat Format, + DepthFormat Depth, + int MultiSampleCount, + RenderTargetUsage Usage, + bool GenerateMipmaps +) +{ + /// + /// Default creation parameters. + /// + public static RenderTargetDescriptor Default { get; } = new( + SurfaceFormat.Color, + DepthFormat.None, + 0, + RenderTargetUsage.DiscardContents, + false + ); + + /// + /// with usage set to + /// . + /// + public static RenderTargetDescriptor DefaultPreserveContents { get; } = new( + SurfaceFormat.Color, + DepthFormat.None, + 0, + RenderTargetUsage.PreserveContents, + false + ); + + /// + /// + /// + public int MultiSampleCount { get; } = Math.Max(0, MultiSampleCount); + + /// + /// Creates a new 2D render target from the descriptor. + /// + /// The device to create the target from. + /// The width of the target. + /// The height of the target. + public RenderTarget2D Create(GraphicsDevice device, int width, int height) + { + return new RenderTarget2D(device, width, height, GenerateMipmaps, Format, Depth, MultiSampleCount, Usage); + } + + /// + /// Constructs a descriptor from an existing target. + /// + public static RenderTargetDescriptor From(RenderTarget2D target) + { + return new RenderTargetDescriptor( + target.Format, + target.DepthStencilFormat, + target.MultiSampleCount, + RenderTargetUsage.DiscardContents, + target.LevelCount > 1 + ); + } +} + +/// +/// A leased target from a pool, to be returned back. +/// +/// The pool leasing the target. +/// The target being leased. +public sealed class RenderTargetLease( + RenderTarget2D target, + RenderTargetPool pool +) : IDisposable +{ + /// + /// The target being leased. + /// + public RenderTarget2D Target { get; set; } = target; + + /// + /// Returns the target back to the pool. + /// + public void Dispose() + { + pool.Return(this); + } +} + +/// +/// Provides a resource pool that enables reusing instances of render +/// targets. +/// +/// +/// Renting and returning buffers with a can +/// increase performance in situations where targets are created and +/// destroyed frequently, resulting in excessive use of VRAM. +///
+/// This class is not thread-safe, and all methods and their implementations +/// are expected to be invoked solely on the Main Thread unless explicitly +/// specified otherwise. +///
+public abstract class RenderTargetPool : IDisposable +{ + // Store as field of derived shared type so the JIT can de-virtualize calls + // to it when the Shared property gets inlined. + private static readonly SharedRenderTargetPool shared = new(); + + /// + /// Retrieves a shared instance. + /// + /// + /// The shared pool provides a default implementation of + /// that's intended for general + /// applicability. It assumes targets should not be manually cleared + /// and always returns a target of the exact request descriptor and + /// dimensions. + ///
+ /// Disposed on unload. + ///
+ public static RenderTargetPool Shared => shared; + + /// + /// Retrieves a buffer that is of the exact specified dimensions + /// and with the + /// given render target . + /// + /// The device to initialize with. + /// The width of the target. + /// The height of the target. + /// The initialization parameters. + /// + /// A leased target which should be disposed upon use, automatically + /// returning the target to the pool. + /// + /// + /// This buffer is loaned to the caller and should be returned to the + /// same pool via, so that it may be reused in + /// subsequent usage of . It is not a fatal error to + /// not return a rented buffer, but failure to do so may lead to + /// decreased application performance, as the pool may need to create a + /// new buffer to replace the one lost. The default + /// implementation returns a leased + /// target that will automatically return the pool on disposal, but + /// different implementations or configurations are not required to do + /// so. + /// + public abstract RenderTargetLease Rent( + GraphicsDevice device, + int width, + int height, + RenderTargetDescriptor descriptor + ); + + /// + /// Returns to the pool a render target that was previously obtained via + /// on the same . + /// + /// + /// The lease previously obtained from to return to + /// the pool. + /// + /// + /// This is automatically called by + /// and generally should not be + /// called manually without being explicitly told to do so. + ///
+ /// Once a buffer has been returned to the pool, the caller gives up all + /// ownership of the buffer and must not use it. The reference returned + /// from a given call to must only be returned via + /// once. The default + /// may hold onto the returned buffer in + /// order to rent it again, or it my release the returned buffer if it's + /// determined that the pool already has enough buffers stored. + ///
+ public abstract void Return(RenderTargetLease lease); + + /// + /// Disposes of the pool and releases any owned render targets, + /// including ones still potentially leased. + /// + /// Generally, disposal should only be performed when either the + /// consumer has ownership over the pool and knows when all buffers have + /// been returned, or at the very end of execution and disposal must + /// occur (such as during mod unloading). + /// + public abstract void Dispose(); + + private static readonly List leases_to_clear = []; + + /// + /// Queues a lease to be disposed of on the next render frame for cases + /// where ownership of the lease is given up for rendering during a + /// frame. + /// + /// + /// The lease to dispose of at the start of the next frame. + /// + /// + /// This API should generally be avoided when possible. It's a + /// last-resort option for when you cannot guarantee ownership over a + /// target. + /// + public static void ReturnNextFrame(RenderTargetLease lease) + { + leases_to_clear.Add(lease); + } + + /// + /// Clears any pending leases that were queued via + /// . + /// + internal static void ClearPendingLeases() + { + foreach (var lease in leases_to_clear) + { + lease.Dispose(); + } + + leases_to_clear.Clear(); + } +} + +/// +/// Extension methods for that operate +/// agnostically on any implementation. +/// +internal static class RenderTargetPoolExtensions +{ + // TODO: Vector2 scale extensions and individual float width/height + // extensions. + + /// The pool to rent from. + extension(RenderTargetPool pool) + { + /// + /// See . + /// + public RenderTargetLease Rent( + GraphicsDevice device, + int width, + int height + ) + { + return pool.Rent( + device, + width, + height, + RenderTargetDescriptor.Default + ); + } + + /// + /// Retrieves a buffer of size scaled by + /// rounded up to the nearest integer + /// value. + /// + /// The device to initialize with. + /// The base (unscaled) size of the target. + /// The scale factor of the target. + /// + /// A leased target which should be disposed upon use, automatically + /// returning the target to the pool. + /// + public RenderTargetLease RentScaled( + GraphicsDevice device, + Point baseSize, + float scale + ) + { + return pool.RentScaled( + device, + baseSize, + scale, + RenderTargetDescriptor.Default + ); + } + + /// + /// Retrieves a buffer of size scaled by + /// rounded up to the nearest integer value and + /// with the given render target . + /// + /// The device to initialize with. + /// The base (unscaled) size of the target. + /// The scale factor of the target. + /// The initialization parameters. + /// + /// A leased target which should be disposed upon use, automatically + /// returning the target to the pool. + /// + public RenderTargetLease RentScaled( + GraphicsDevice device, + Point baseSize, + float scale, + RenderTargetDescriptor descriptor + ) + { + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(scale, 0f); + + var width = Math.Max(1, (int)MathF.Ceiling(baseSize.X * scale)); + var height = Math.Max(1, (int)MathF.Ceiling(baseSize.Y * scale)); + return pool.Rent(device, width, height, descriptor); + } + } +} + +// TODO: Account for different graphics devices? +internal sealed class SharedRenderTargetPool : RenderTargetPool +{ + private readonly record struct Key( + int Width, + int Height, + RenderTargetDescriptor Descriptor + ) + { + public static Key From(RenderTarget2D target) + { + return new Key(target.Width, target.Height, RenderTargetDescriptor.From(target)); + } + } + + private sealed class Entry + { + public Stack Targets { get; } = []; + + public DateTime LastUsed { get; set; } = DateTime.UtcNow; + } + + // TODO: We can tweak these later for performance? + private const int max_per_key = 4; // Max identical targets. + private const int max_total_targets = 128; // Max targets stored. + private static readonly TimeSpan max_idle_time = TimeSpan.FromSeconds(5); + private static readonly TimeSpan minimum_trim_time = TimeSpan.FromSeconds(1); + + private readonly Dictionary cache = []; + private DateTime lastTrimmed = DateTime.UtcNow; + private int totalCached; + private bool disposed; + + public override RenderTargetLease Rent(GraphicsDevice device, int width, int height, RenderTargetDescriptor descriptor) + { + ArgumentNullException.ThrowIfNull(device); + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(width, 0); + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(height, 0); + ObjectDisposedException.ThrowIf(disposed, this); + + try + { + var key = new Key(width, height, descriptor); + if (!cache.TryGetValue(key, out var entry)) + { + cache[key] = entry = new Entry(); + } + else + { + entry.LastUsed = DateTime.UtcNow; + } + + RenderTarget2D target; + if (entry.Targets.Count > 0) + { + target = entry.Targets.Pop(); + totalCached--; + } + else + { + target = descriptor.Create(device, width, height); + } + + return new RenderTargetLease(target, this); + } + finally + { + TrimAged(); + } + } + + public override void Return(RenderTargetLease lease) + { + ArgumentNullException.ThrowIfNull(lease); + ObjectDisposedException.ThrowIf(disposed, this); + + var key = Key.From(lease.Target); + if (!cache.TryGetValue(key, out var entry)) + { + cache[key] = entry = new Entry(); + } + else + { + // Mark it as used on return because that's realistically where the + // countdown should begin. + entry.LastUsed = DateTime.UtcNow; + } + + if (entry.Targets.Count < max_per_key) + { + if (totalCached >= max_total_targets) + { + lease.Target.Dispose(); + return; + } + + entry.Targets.Push(lease.Target); + totalCached++; + } + else + { + lease.Target.Dispose(); + } + } + + public override void Dispose() + { + if (disposed) + { + return; + } + + Trim(); + disposed = true; + } + + private void Trim() + { + foreach (var entry in cache.Values) + { + while (entry.Targets.Count > 0) + { + entry.Targets.Pop().Dispose(); + totalCached--; + } + } + + cache.Clear(); + } + + private void TrimAged() + { + var now = DateTime.UtcNow; + + if (now - lastTrimmed < minimum_trim_time) + { + return; + } + + lastTrimmed = now; + + foreach (var (key, entry) in cache) + { + if (now - entry.LastUsed <= max_idle_time) + { + continue; + } + + while (entry.Targets.Count > 0) + { + entry.Targets.Pop().Dispose(); + totalCached--; + } + + cache.Remove(key); + } + } +} diff --git a/Utilities/Daybreak/Buffers/RenderTargetPreserver.cs b/Utilities/Daybreak/Buffers/RenderTargetPreserver.cs new file mode 100644 index 0000000000..dc446ef167 --- /dev/null +++ b/Utilities/Daybreak/Buffers/RenderTargetPreserver.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework.Graphics; +using Terraria; + +namespace CalamityMod.Utilities.Daybreak.Buffers; + +/// +/// Handles preserving the contents of s. +///
+/// For most cases, is preferred for +/// temporarily swapping render targets. +///
+public static class RenderTargetPreserver +{ + /// + /// Forcefully sets the usage of a given set of render target bindings to + /// preserve contents. + /// + /// + public static void PreserveBindings(RenderTargetBinding[] bindings) + { + foreach (var binding in bindings) + { + if (binding.RenderTarget is not RenderTarget2D rt) + { + continue; + } + + rt.RenderTargetUsage = RenderTargetUsage.PreserveContents; + } + } + + /// + /// A utility method that gets the current bindings from the graphics + /// device and ensures they're preserved. + /// + /// + public static RenderTargetBinding[] GetAndPreserveCurrentBindings() + { + var bindings = Main.instance.GraphicsDevice.GetRenderTargets(); + { + PreserveBindings(bindings); + } + + return bindings; + } +} diff --git a/Utilities/Daybreak/Buffers/RenderTargetScope.cs b/Utilities/Daybreak/Buffers/RenderTargetScope.cs new file mode 100644 index 0000000000..ad6ad177da --- /dev/null +++ b/Utilities/Daybreak/Buffers/RenderTargetScope.cs @@ -0,0 +1,114 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Utilities.Daybreak.Buffers; + +/// +/// Manages the scope of a render target to be rendered to, swapping out the +/// currently-used targets of a device on creation and replacing it with the +/// given target. Switches back to the old targets upon disposal. +/// +public readonly struct RenderTargetScope : IDisposable +{ + private readonly GraphicsDevice graphicsDevice; + private readonly RenderTargetBinding[] previous; + + /// + /// Creates a new scope, saving the current device targets and starts + /// rendering to the new one instead. + /// + /// The target to render to. + /// + /// Whether to ensure swapped targets preserve their contents. + /// + /// + /// If not null, clears the target to the given color. + /// + public RenderTargetScope( + RenderTarget2D target, + bool preserveContents = true, + Color? clearColor = null + ) + { + ArgumentNullException.ThrowIfNull(target); + + graphicsDevice = target.GraphicsDevice; + previous = graphicsDevice.GetRenderTargets(); + + if (preserveContents) + { + RenderTargetPreserver.PreserveBindings(previous); + } + + graphicsDevice.SetRenderTarget(target); + + if (clearColor.HasValue) + { + graphicsDevice.Clear(clearColor.Value); + } + } + + /// + /// Sets the device to use the targets that were in use before this + /// scope was instantiated. + /// + public void Dispose() + { + graphicsDevice.SetRenderTargets(previous); + } +} + +/// +/// Extensions supporting . +/// +public static class RenderTargetScopeExtensions +{ + /// + /// Creates a new scope, saving the current device targets and starts + /// rendering to the new one instead. + /// + /// The target to render to. + /// + /// Whether to ensure swapped targets preserve their contents. + /// + /// + /// If not null, clears the target to the given color. + /// + public static RenderTargetScope Scope( + this RenderTarget2D target, + bool preserveContents = true, + Color? clearColor = null + ) + { + return new RenderTargetScope( + target, + preserveContents, + clearColor + ); + } + + /// + /// Creates a new scope, saving the current device targets and starts + /// rendering to the new one instead. + /// + /// The target to render to. + /// + /// Whether to ensure swapped targets preserve their contents. + /// + /// + /// If not null, clears the target to the given color. + /// + public static RenderTargetScope Scope( + this RenderTargetLease target, + bool preserveContents = true, + Color? clearColor = null + ) + { + return new RenderTargetScope( + target.Target, + preserveContents, + clearColor + ); + } +} diff --git a/Utilities/Daybreak/Buffers/ScreenspaceTargetPool.cs b/Utilities/Daybreak/Buffers/ScreenspaceTargetPool.cs new file mode 100644 index 0000000000..7aa4e79da4 --- /dev/null +++ b/Utilities/Daybreak/Buffers/ScreenspaceTargetPool.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; +using Terraria; + +namespace CalamityMod.Utilities.Daybreak.Buffers; + +/// +/// A that provides APIs for creating +/// references to render targets that are dependent on the screen size. +///
+/// Targets created by this pool are not cached for reuse later. This API +/// is designed to leverage the strong reference to a target provided by +/// . +///
+internal sealed class ScreenspaceTargetPool : RenderTargetPool +{ + /// + /// Retrieves the shared instance. + /// + /// + /// Disposed on unload. + /// + public new static ScreenspaceTargetPool Shared { get; } = new(); + + /// + /// + /// + public delegate (int Width, int Height) GetTargetSize( + int backbufferWidth, + int backbufferHeight, + int offscreenTargetWidth, + int offscreenTargetHeight + ); + + private readonly Dictionary cache = []; + private bool disposed; + + private ScreenspaceTargetPool() { } + + /// + public override RenderTargetLease Rent( + GraphicsDevice device, + int width, + int height, + RenderTargetDescriptor descriptor + ) + { + ArgumentNullException.ThrowIfNull(device); + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(width, 0); + ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(height, 0); + ObjectDisposedException.ThrowIf(disposed, this); + + return Rent(device, (_, _, _, _) => (width, height), descriptor); + } + + /// + public RenderTargetLease Rent( + GraphicsDevice device, + RenderTargetDescriptor? descriptor = null + ) + { + return Rent( + device, + (width, height) => (width, height), + descriptor + ); + } + + /// + public RenderTargetLease Rent( + GraphicsDevice device, + Func targetSizeCallback, + RenderTargetDescriptor? descriptor = null + ) + { + return Rent(device, (width, height, _, _) => targetSizeCallback(width, height), descriptor); + } + + /// + /// Rents a target with varying width and height, to be recalculated + /// whenever the screen is resized. For the lifetime of the lease, this + /// pool will re-initialize the given target whenever the computed width + /// and height do not match the current size of the target on screen + /// size change/vanilla RT invalidation. + /// + public RenderTargetLease Rent( + GraphicsDevice device, + GetTargetSize targetSizeCallback, + RenderTargetDescriptor? descriptor = null + ) + { + ArgumentNullException.ThrowIfNull(device); + ArgumentNullException.ThrowIfNull(targetSizeCallback); + ObjectDisposedException.ThrowIf(disposed, this); + + descriptor ??= RenderTargetDescriptor.Default; + + GetTargetSizes( + device, + out var backbufferWidth, + out var backbufferHeight, + out var offscreenTargetWidth, + out var offscreenTargetHeight + ); + var (width, height) = targetSizeCallback( + backbufferWidth, + backbufferHeight, + offscreenTargetWidth, + offscreenTargetHeight + ); + + var target = descriptor.Value.Create(device, width, height); + var lease = new RenderTargetLease(target, this); + { + cache[lease] = targetSizeCallback; + } + + return lease; + } + + /// + public override void Return(RenderTargetLease lease) + { + ArgumentNullException.ThrowIfNull(lease); + ObjectDisposedException.ThrowIf(disposed, this); + + if (!cache.Remove(lease)) + { + return; + } + + lease.Target.Dispose(); + } + + /// + public override void Dispose() + { + if (disposed) + { + return; + } + + Trim(); + disposed = true; + } + + private void Trim() + { + foreach (var lease in cache.Keys) + { + lease.Target.Dispose(); + } + + cache.Clear(); + } + + private static void GetTargetSizes( + GraphicsDevice device, + out int backbufferWidth, + out int backbufferHeight, + out int offscreenTargetWidth, + out int offscreenTargetHeight + ) + { + backbufferWidth = device.PresentationParameters.BackBufferWidth; + backbufferHeight = device.PresentationParameters.BackBufferHeight; + offscreenTargetWidth = Main.instance.tileTarget.Width; + offscreenTargetHeight = Main.instance.tileTarget.Height; + } + + /// + /// Resizes all cached targets based on current screen size. + /// + internal void ResizeCachedTargets(GraphicsDevice device) + { + GetTargetSizes( + device, + out var backbufferWidth, + out var backbufferHeight, + out var offscreenTargetWidth, + out var offscreenTargetHeight + ); + + foreach (var (lease, sizeCallback) in cache) + { + var (width, height) = sizeCallback( + backbufferWidth, + backbufferHeight, + offscreenTargetWidth, + offscreenTargetHeight + ); + + if (lease.Target.Width == width && lease.Target.Height == height) + { + continue; + } + + lease.Target.Dispose(); + lease.Target = RenderTargetDescriptor.From(lease.Target).Create(device, width, height); + } + } +} diff --git a/Utilities/Daybreak/PlayerShader.cs b/Utilities/Daybreak/PlayerShader.cs new file mode 100644 index 0000000000..7c8aca6a5d --- /dev/null +++ b/Utilities/Daybreak/PlayerShader.cs @@ -0,0 +1,32 @@ +using Terraria.DataStructures; + +namespace CalamityMod.Utilities.Daybreak; + +/// +/// A type-safe wrapper over a packed player shader integer. +/// +/// The local index of the shader. +/// The shader kind. +internal readonly record struct PlayerShader( + int LocalIndex, + PlayerDrawHelper.ShaderConfiguration ShaderType +) +{ + /// + /// The packed value. + /// + public int PackedValue => LocalIndex + (int)ShaderType * 1000; + + /// + /// Creates a new wrapper over a packed value. + /// + /// The packed value. + /// The deconstructed wrapper. + public static PlayerShader FromPacked(int packed) + { + return new PlayerShader( + packed % 1000, + (PlayerDrawHelper.ShaderConfiguration)(packed / 1000) + ); + } +} diff --git a/Utilities/Daybreak/README.txt b/Utilities/Daybreak/README.txt new file mode 100644 index 0000000000..c66eb9288b --- /dev/null +++ b/Utilities/Daybreak/README.txt @@ -0,0 +1,5 @@ +Everything in this directory is adapted from DAYBREAK and jointly authored by +tomat and syrup. Explicit permission is given to use this code in Calamity +against the AGPL 3.0 license. + + diff --git a/Utilities/Daybreak/SpriteBatchParameters.cs b/Utilities/Daybreak/SpriteBatchParameters.cs new file mode 100644 index 0000000000..8e1fb9bd53 --- /dev/null +++ b/Utilities/Daybreak/SpriteBatchParameters.cs @@ -0,0 +1,93 @@ +#nullable enable + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Utilities.Daybreak; + +/// +/// Wraps the parameters of a initialization, +/// permitting values which may be replaced with +/// defaults when being converted to a snapshot. +/// +internal struct SpriteBatchParameters +{ + /// + /// The sort mode. + /// + public SpriteSortMode? SortMode { get; set; } + + /// + /// The blend state. + /// + public BlendState? BlendState { get; set; } + + /// + /// The sampler state. + /// + public SamplerState? SamplerState { get; set; } + + /// + /// The depth stencil state. + /// + public DepthStencilState? DepthStencilState { get; set; } + + /// + /// The rasterizer state. + /// + public RasterizerState? RasterizerState { get; set; } + + /// + /// The custom effect, if applicable. + /// + public Effect? CustomEffect { get; set; } + + /// + /// The transformation matrix. + /// + public Matrix? TransformMatrix { get; set; } + + /// + /// Initializes a new set of parameters. + /// + public SpriteBatchParameters( + SpriteSortMode? sortMode = null, + BlendState? blendState = null, + SamplerState? samplerState = null, + DepthStencilState? depthStencilState = null, + RasterizerState? rasterizerState = null, + Effect? customEffect = null, + Matrix? transformMatrix = null + ) + { + SortMode = sortMode; + BlendState = blendState; + SamplerState = samplerState; + DepthStencilState = depthStencilState; + RasterizerState = rasterizerState; + CustomEffect = customEffect; + TransformMatrix = transformMatrix; + } + + /// + /// Creates a new , with + /// values being replaced with the values + /// provided by . + /// + /// + /// Default values to populate s with. + /// + /// The new snapshot. + public readonly SpriteBatchSnapshot ToSnapshot(SpriteBatchSnapshot defaultValues) + { + return new SpriteBatchSnapshot( + SortMode ?? defaultValues.SortMode, + BlendState ?? defaultValues.BlendState, + SamplerState ?? defaultValues.SamplerState, + DepthStencilState ?? defaultValues.DepthStencilState, + RasterizerState ?? defaultValues.RasterizerState, + CustomEffect ?? defaultValues.CustomEffect, + TransformMatrix ?? defaultValues.TransformMatrix + ); + } +} diff --git a/Utilities/Daybreak/SpriteBatchScope.cs b/Utilities/Daybreak/SpriteBatchScope.cs new file mode 100644 index 0000000000..161d7ee583 --- /dev/null +++ b/Utilities/Daybreak/SpriteBatchScope.cs @@ -0,0 +1,62 @@ +#nullable enable + +using System; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Utilities.Daybreak; + +/// +/// Starts a and caches its old start parameters +/// if it was begun to restore it on disposal. +/// +internal readonly struct SpriteBatchScope : IDisposable +{ + private readonly SpriteBatch spriteBatch; + private readonly SpriteBatchSnapshot? oldState; + + /// + /// Initializes a new scope. If the has + /// already begun, its current parameters are saved and the + /// is ended; the original parameters will + /// then be reapplied on disposal. + /// + /// The . + public SpriteBatchScope(SpriteBatch spriteBatch) + { + this.spriteBatch = spriteBatch; + + if (!spriteBatch.beginCalled) + { + return; + } + + spriteBatch.End(out var old); + oldState = old; + } + + /// + /// Ends the and starts it with the old + /// parameters if it has already begun prior. + /// + public void Dispose() + { + if (oldState.HasValue) + { + spriteBatch.Begin(oldState.Value); + } + } +} + +/// +/// Extensions to types for scopes. +/// +internal static class SpriteBatchScopeExtensions +{ + /// + /// See . + /// + public static SpriteBatchScope Scope(this SpriteBatch @this) + { + return new SpriteBatchScope(@this); + } +} diff --git a/Utilities/Daybreak/SpriteBatchSnapshot.cs b/Utilities/Daybreak/SpriteBatchSnapshot.cs new file mode 100644 index 0000000000..6396118003 --- /dev/null +++ b/Utilities/Daybreak/SpriteBatchSnapshot.cs @@ -0,0 +1,168 @@ +#nullable enable + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Utilities.Daybreak; + +/// +/// A "snapshot" of the current state of a . +///
+/// These values may be manipulated freely. +///
+/// +/// This API exists for making preservation of a 's +/// state trivial. +///
+/// The act of taking a snapshot through this object's constructor is pure +/// (that is, it has no side effects). It will not mutate the state of the +/// being analyzed. If you intend to modify the +/// , use the APIs provided in +/// . +///
+internal struct SpriteBatchSnapshot +{ + /// + /// The sort mode. + /// + public SpriteSortMode SortMode { get; set; } + + /// + /// The blend state. + /// + public BlendState BlendState { get; set; } + + /// + /// The sampler state. + /// + public SamplerState SamplerState { get; set; } + + /// + /// The depth stencil state. + /// + public DepthStencilState DepthStencilState { get; set; } + + /// + /// The rasterizer state. + /// + public RasterizerState RasterizerState { get; set; } + + /// + /// The custom effect, if applicable. + /// + public Effect? CustomEffect { get; set; } + + /// + /// The transformation matrix. + /// + public Matrix TransformMatrix { get; set; } + + /// + /// Creates a new snapshot from raw + /// parameters. + /// + public SpriteBatchSnapshot( + SpriteSortMode sortMode, + BlendState blendState, + SamplerState samplerState, + DepthStencilState depthStencilState, + RasterizerState rasterizerState, + Effect? customEffect, + Matrix transformMatrix + ) + { + SortMode = sortMode; + BlendState = blendState; + SamplerState = samplerState; + DepthStencilState = depthStencilState; + RasterizerState = rasterizerState; + CustomEffect = customEffect; + TransformMatrix = transformMatrix; + } + + /// + /// Creates a new snapshot from the current + /// settings of the given . + /// + /// + /// The to take a snapshot of. + /// + public SpriteBatchSnapshot(SpriteBatch spriteBatch) + { + SortMode = spriteBatch.sortMode; + BlendState = spriteBatch.blendState; + SamplerState = spriteBatch.samplerState; + DepthStencilState = spriteBatch.depthStencilState; + RasterizerState = spriteBatch.rasterizerState; + CustomEffect = spriteBatch.customEffect; + TransformMatrix = spriteBatch.transformMatrix; + } + + /// + /// Initializes a set of parameters from this snapshot. + /// + public readonly SpriteBatchParameters ToParameters() + { + return new SpriteBatchParameters( + SortMode, + BlendState, + SamplerState, + DepthStencilState, + RasterizerState, + CustomEffect, + TransformMatrix + ); + } +} + +/// +/// Extensions to using +/// instances. +/// +internal static class SpriteBatchSnapshotExtensions +{ + /// The . + extension(SpriteBatch sb) + { + /// + /// Takes a snapshot of the and then ends the + /// / + /// + /// The produced . + public void End(out SpriteBatchSnapshot ss) + { + ss = new SpriteBatchSnapshot(sb); + sb.End(); + } + + /// + /// Starts a with the parameters from the + /// given . + /// + /// The to use. + public void Begin(in SpriteBatchSnapshot ss) + { + sb.Begin( + ss.SortMode, + ss.BlendState, + ss.SamplerState, + ss.DepthStencilState, + ss.RasterizerState, + ss.CustomEffect, + ss.TransformMatrix + ); + } + + /// + /// Immediately ends and then starts the given + /// with the parameters from the given + /// . + /// + /// The to use. + public void Restart(in SpriteBatchSnapshot ss) + { + sb.End(); + sb.Begin(ss); + } + } +} diff --git a/Utilities/DrawingUtils.BatchSetting.cs b/Utilities/DrawingUtils.BatchSetting.cs index ee5b26cbe9..ef5962c1ce 100644 --- a/Utilities/DrawingUtils.BatchSetting.cs +++ b/Utilities/DrawingUtils.BatchSetting.cs @@ -1,13 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.Xna.Framework.Graphics; -using Terraria; namespace CalamityMod { + [Obsolete("Use SpriteBatchParameters/SpriteBatchSnapshot")] public class BatchSetting(BlendState blend, SamplerState sampler, DepthStencilState depthStencil, RasterizerState rasterizer) { public readonly BlendState blendState = blend; diff --git a/Utilities/DrawingUtils.SpriteBatch.cs b/Utilities/DrawingUtils.SpriteBatch.cs index 87de0a98d5..fc7e956b42 100644 --- a/Utilities/DrawingUtils.SpriteBatch.cs +++ b/Utilities/DrawingUtils.SpriteBatch.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; +using CalamityMod.Utilities.Daybreak; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -12,16 +9,7 @@ namespace CalamityMod { public static partial class CalamityUtils { - // Cached for efficiency purposes. - private const BindingFlags Bind_Private_Instance = BindingFlags.NonPublic | BindingFlags.Instance; - private static readonly FastField Fld_BeginCalled = new("beginCalled", Bind_Private_Instance); - private static readonly FastField Fld_SortMode = new("sortMode", Bind_Private_Instance); - private static readonly FastField Fld_BlendState = new("blendState", Bind_Private_Instance); - private static readonly FastField Fld_SamplerState = new("samplerState", Bind_Private_Instance); - private static readonly FastField Fld_DepthStencilState = new("depthStencilState", Bind_Private_Instance); - private static readonly FastField Fld_RasterizerState = new("rasterizerState", Bind_Private_Instance); - private static readonly FastField Fld_TransformMatrix = new("transformMatrix", Bind_Private_Instance); - private static readonly FastField Fld_CustomEffect = new("customEffect", Bind_Private_Instance); + /// /// Sets a 's arbitrarily. @@ -31,7 +19,8 @@ namespace CalamityMod public static void SetBlendState(this SpriteBatch spriteBatch, BlendState blendState) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, blendState, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.Begin(SpriteSortMode.Immediate, blendState, Main.DefaultSamplerState, DepthStencilState.None, + RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix); } /// @@ -40,47 +29,9 @@ namespace CalamityMod /// The sprite batch to check. public static bool HasBeginBeenCalled(this SpriteBatch spriteBatch) { - return Fld_BeginCalled.Get(spriteBatch); + return spriteBatch.beginCalled; } - public static void SafeAction(this SpriteBatch spriteBatch, Action action) - { - if (spriteBatch is null) - return; - - if (spriteBatch.HasBeginBeenCalled()) - { - var oldSort = Fld_SortMode.Get(spriteBatch); - var oldBlend = Fld_BlendState.Get(spriteBatch); - var oldSampler = Fld_SamplerState.Get(spriteBatch); - var oldDepths = Fld_DepthStencilState.Get(spriteBatch); - var oldRaster = Fld_RasterizerState.Get(spriteBatch); - var oldEffect = Fld_CustomEffect.Get(spriteBatch); - var oldMtx = Fld_TransformMatrix.Get(spriteBatch); - try - { - action?.Invoke(); - } - finally - { - // If something has started in this block, restore the state to previous one - spriteBatch.TryEnd(); - spriteBatch.TryBegin(oldSort, oldBlend, oldSampler, oldDepths, oldRaster, oldEffect, oldMtx); - } - } - else - { - try - { - action?.Invoke(); - } - finally - { - // Initial State was off, turn off the batching - spriteBatch.TryEnd(); - } - } - } /// /// Starts SpriteBatch then Re-Begin batch with old settings when it's all done @@ -91,25 +42,25 @@ namespace CalamityMod /// /// /// + [Obsolete("Use SpriteBatch.Begin, SpriteBatchScope, or SpriteBatchSnapshot")] public static void SafeBegin(this SpriteBatch spriteBatch, SpriteSortMode sortMode, BatchSetting settings, Effect effect, Matrix transformMatrix, Action batchCallback - ) + ) { if (spriteBatch is null) return; - spriteBatch.SafeAction(() => - { - spriteBatch.TryEnd(); - var rasterizer = settings.rasterizerState ?? Main.Rasterizer; - spriteBatch.TryBegin(sortMode, settings.blendState, settings.samplerState, settings.depthStencilState, rasterizer, effect, transformMatrix); - batchCallback?.Invoke(); - }); + spriteBatch.End(out var ss); + + spriteBatch.Begin(sortMode, settings.blendState, settings.samplerState, settings.depthStencilState, settings.rasterizerState ?? Main.Rasterizer, effect, transformMatrix); + batchCallback?.Invoke(); + spriteBatch.Restart(ss); } + [Obsolete("This is violative of spritebatch's control flow and will eventually be removed")] public static bool TryBegin(this SpriteBatch spriteBatch, SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, @@ -124,11 +75,13 @@ namespace CalamityMod } else { - spriteBatch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, transformMatrix); + spriteBatch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, + transformMatrix); return true; } } + [Obsolete("This is violative of spritebatch's control flow and will eventually be removed")] public static bool TryEnd(this SpriteBatch spriteBatch) { if (!spriteBatch.HasBeginBeenCalled()) diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index 9ed32533e5..0fc90e184c 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Reflection; using System.Runtime.CompilerServices; using System.Text; -using CalamityMod.Graphics; -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -41,6 +39,37 @@ namespace CalamityMod new Color(199, 62, 62), }; + /// + /// The transformation matrix used for drawing backgrounds in Vanilla Terraria. Should be used for any custom background drawing or CustomSky + /// drawing, such as independent sky entities or background shader effects. + /// + public static Matrix BackgroundMatrix + { + get + { + Matrix backgroundMatrix = Main.BackgroundViewMatrix.TransformationMatrix; + Vector3 translationDirection = new(1f, Main.BackgroundViewMatrix.Effects.HasFlag(SpriteEffects.FlipVertically) ? -1f : 1f, 1f); + backgroundMatrix.Translation -= Main.BackgroundViewMatrix.ZoomMatrix.Translation * translationDirection; + return backgroundMatrix; + } + } + /// + /// Gets the texture for the passed string and stores it in the referenced field + /// If the texture is already stored in the field, it will not request it again. + /// Use this instead of requesting every frame. + /// + /// + /// + /// + public static Asset GetTextureEfficient(ref Asset textureAsset, string texture) + { + if (textureAsset is null) + { + textureAsset = ModContent.Request(texture); + } + return textureAsset; + } + #region Projectile Afterimages /// /// Draws a projectile as a series of afterimages. The first of these afterimages is centered on the center of the projectile's hitbox.
@@ -81,7 +110,7 @@ namespace CalamityMod // Standard afterimages. No customizable features other than total afterimage count. // Type 0 afterimages linearly scale down from 100% to 0% opacity. Their color and lighting is equal to the main projectile's. case 0: - + for (int i = 0; i < proj.oldPos.Length; ++i) { @@ -254,12 +283,27 @@ namespace CalamityMod /// /// /// - public static void DrawInventoryCustomScale(SpriteBatch spriteBatch, Texture2D texture, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale, float wantedScale = 1f, Vector2 drawOffset = default) + public static void DrawInventoryCustomScale(SpriteBatch spriteBatch, Texture2D texture, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale, float wantedScale = 1f, Vector2 drawOffset = default, SpriteEffects spriteEffects = SpriteEffects.None, float rotation = 0f) { wantedScale = Math.Max(scale, wantedScale * Main.inventoryScale); float scaleDifference = wantedScale - scale; position += drawOffset * wantedScale; - spriteBatch.Draw(texture, position, frame, drawColor, 0f, origin, wantedScale, SpriteEffects.None, 0); + if (itemColor == Color.Transparent) itemColor = Color.White; + spriteBatch.Draw(texture, position, frame, itemColor.MultiplyRGB(drawColor), 0f, origin, wantedScale, SpriteEffects.None, 0); + } + + static Asset ItemDotTexture; + /// + /// Draws an enabled/disabled dot at the bottom right of the item's sprite + /// Used for effects that are enabled/disabled + /// + /// + /// + public static void DrawInventoryDot(SpriteBatch spriteBatch, Vector2 itemPosition, Vector2 dotOffset, bool enabled) + { + var tex = CalamityUtils.GetTextureEfficient(ref ItemDotTexture, "Terraria/Images/Extra_20").Value; + var dotFrame = tex.Frame(1, 4, frameY: enabled ? 1 : 2); + spriteBatch.Draw(tex, itemPosition + dotOffset, dotFrame, Color.White, 0, dotFrame.Size() * 0.5f, Main.inventoryScale, SpriteEffects.None, 0); } /// @@ -313,16 +357,14 @@ namespace CalamityMod /// public static void CopyContentsFrom(this RenderTarget2D to, RenderTarget2D from) { - Main.instance.GraphicsDevice.SetRenderTarget(to); - Main.instance.GraphicsDevice.Clear(Color.Transparent); + using (to.Scope(clearColor: Color.Transparent)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); + Main.spriteBatch.Draw(from, Vector2.Zero, null, Color.White); + Main.spriteBatch.End(); + } - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); - Main.spriteBatch.Draw(from, Vector2.Zero, null, Color.White); - Main.spriteBatch.End(); - - Main.instance.GraphicsDevice.SetRenderTarget(from); - Main.instance.GraphicsDevice.Clear(Color.Transparent); - Main.instance.GraphicsDevice.SetRenderTarget(null); + using (from.Scope(clearColor: Color.Transparent)) { } } /// @@ -412,9 +454,7 @@ namespace CalamityMod { Vector2 origin = new Vector2(glowmaskTexture.Width / 2f, glowmaskTexture.Height / 2f); - Color color = new Color(250, 250, 250, item.alpha); - if (item.type == ModContent.ItemType()) - color = Color.White; + Color color = Color.White; spriteBatch.Draw(glowmaskTexture, item.Center - Main.screenPosition, null, color, rotation, origin, 1f, SpriteEffects.None, 0f); } @@ -601,11 +641,6 @@ namespace CalamityMod return false; } - // Cached for efficiency purposes. - internal static readonly FieldInfo UImageFieldMisc0 = typeof(MiscShaderData).GetField("_uImage0", BindingFlags.NonPublic | BindingFlags.Instance); - internal static readonly FieldInfo UImageFieldMisc1 = typeof(MiscShaderData).GetField("_uImage1", BindingFlags.NonPublic | BindingFlags.Instance); - internal static readonly FieldInfo UImageFieldArmor = typeof(ArmorShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance); - /// /// Manually sets the texture of a instance, since vanilla's implementation only supports strings that access vanilla textures. /// @@ -616,10 +651,10 @@ namespace CalamityMod switch (index) { case 0: - UImageFieldMisc0.SetValue(shader, texture); + shader._uImage0 = texture; break; case 1: - UImageFieldMisc1.SetValue(shader, texture); + shader._uImage1 = texture; break; } return shader; @@ -632,20 +667,20 @@ namespace CalamityMod /// The texture to bind. public static ArmorShaderData SetShaderTextureArmor(this ArmorShaderData shader, Asset texture) { - UImageFieldArmor.SetValue(shader, texture); + shader._uImage = texture; return shader; } - public static void EnterShaderRegion(this SpriteBatch spriteBatch, BlendState newBlendState = null, Effect effect = null) + public static void EnterShaderRegion(this SpriteBatch spriteBatch, BlendState newBlendState = null, Effect effect = null, Matrix? matrix = null) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, newBlendState ?? BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.Begin(SpriteSortMode.Immediate, newBlendState ?? BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, effect, matrix ?? Main.GameViewMatrix.TransformationMatrix); } - public static void ExitShaderRegion(this SpriteBatch spriteBatch) + public static void ExitShaderRegion(this SpriteBatch spriteBatch, Matrix? matrix = null) { spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, matrix ?? Main.GameViewMatrix.TransformationMatrix); } /// @@ -782,6 +817,7 @@ namespace CalamityMod /// /// The render target to swap to /// The color to clear the screen with. Transparent by default + [Obsolete("Use RenderTargetScope")] public static void SwapTo(this RenderTarget2D target, Color? flushColor = null) { // If we are in the menu, a server, or any of these are null, return. @@ -791,5 +827,56 @@ namespace CalamityMod Main.instance.GraphicsDevice.SetRenderTarget(target); Main.instance.GraphicsDevice.Clear(flushColor ?? Color.Transparent); } + + /// + /// Draws a series of lines between a list of vector positions in sequential order. + /// + /// + /// + /// + /// + public static void DrawLineBetweenPoints(List pointList, Color lineColor, bool useTileColor = false, float scaleMod = 1f) + { + for (int i = 0; i < pointList.Count - 1; i++) + { + + Color color = lineColor; + if (useTileColor) + color = Lighting.GetColor(pointList[i].ToTileCoordinates(), lineColor); + + + Main.spriteBatch.DrawLineBetter(pointList[i], pointList[i + 1], color, scaleMod); + } + } + + public static void GetScreenDrawArea(Vector2 unscaledScreenPosition, Vector2 offSet, out int firstTileX, out int lastTileX, out int firstTileY, out int lastTileY) + { + const int Padding = 4; + + firstTileX = (int)((unscaledScreenPosition.X - offSet.X) / 16f - 1f); + lastTileX = (int)((unscaledScreenPosition.X + Main.screenWidth + offSet.X) / 16f) + 2; + firstTileY = (int)((unscaledScreenPosition.Y - offSet.Y) / 16f - 1f); + lastTileY = (int)((unscaledScreenPosition.Y + Main.screenHeight + offSet.Y) / 16f) + 5; + + if (firstTileX < Padding) + { + firstTileX = Padding; + } + + if (lastTileX > Main.maxTilesX - Padding) + { + lastTileX = Main.maxTilesX - Padding; + } + + if (firstTileY < Padding) + { + firstTileY = Padding; + } + + if (lastTileY > Main.maxTilesY - Padding) + { + lastTileY = Main.maxTilesY - Padding; + } + } } } diff --git a/Utilities/DropHelper.cs b/Utilities/DropHelper.cs index 6b19c38c64..7dae35e350 100644 --- a/Utilities/DropHelper.cs +++ b/Utilities/DropHelper.cs @@ -2,15 +2,12 @@ using System.Collections.Generic; using CalamityMod.Enums; using CalamityMod.Items.Accessories; -using CalamityMod.Items.Potions; -using CalamityMod.NPCs.SulphurousSea; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.GameContent.ItemDropRules; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.Utilities; @@ -339,11 +336,11 @@ namespace CalamityMod ItemDropRule.NotScalingWithLuck(ItemID.ManaPotion, 1, 5, 17) })); - // 2-6 Bait @ 50%; 25% Master 25% Apprentice + // 2-6 Bait @ 50%; 25% Master 25% Journeyman loot.Add(new OneFromRulesRule(2, new IItemDropRule[2] { ItemDropRule.NotScalingWithLuck(ItemID.MasterBait, 1, 2, 6), - ItemDropRule.NotScalingWithLuck(ItemID.ApprenticeBait, 1, 2, 6) + ItemDropRule.NotScalingWithLuck(ItemID.JourneymanBait, 1, 2, 6) })); // 5-12 Gold Coin @ 25% @@ -832,25 +829,6 @@ namespace CalamityMod return p.Calamity().tarraSet; }); - internal const float TrasherEatDistance = 96f; - public static IItemDropRuleCondition AnglerFedToTrasherCondition = If((info) => - { - bool trasherNearby = false; - foreach (NPC nearby in Main.ActiveNPCs) - { - if (nearby.type != ModContent.NPCType()) - continue; - if (info.npc.Distance(nearby.Center) < TrasherEatDistance) - { - trasherNearby = true; - break; - } - } - 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 => CalamityConditions.TrasherTextCondition.ToDropCondition(ShowItemDropInUI.Always); - // Remix seed drop rules public static IItemDropRuleCondition Remix => Condition.RemixWorld.ToDropCondition(ShowItemDropInUI.WhenConditionSatisfied); public static IItemDropRuleCondition NotRemix => Condition.NotRemixWorld.ToDropCondition(ShowItemDropInUI.WhenConditionSatisfied); diff --git a/Utilities/EntityUtils.cs b/Utilities/EntityUtils.cs index 7899a51477..6d02c92f68 100644 --- a/Utilities/EntityUtils.cs +++ b/Utilities/EntityUtils.cs @@ -23,6 +23,17 @@ namespace CalamityMod return (destination - entity.Center).SafeNormalize(fallback.Value); } + /// + /// Sets a player's screenshake value. Automatically checks to ensure it will not override a stronger screenshake. + /// + /// The player to add screenshake to. + /// The intensity of the screenshake. + public static void SetScreenshake(this Player player, float value) + { + if (player.Calamity().GeneralScreenShakePower < value) + player.Calamity().GeneralScreenShakePower = value; + } + /// /// Adds screenshake to the local player, using the given position and range to determine whether the player is able to see the screenshake. /// @@ -58,60 +69,35 @@ namespace CalamityMod /// /// whoAmI index to check /// true if index is in valid range [0 <= index < Main.maxNPCs] - public static bool IndexInRange(this NPC[] _, int index) - { - if (index >= 0) - return index < Main.maxNPCs; - return false; - } + public static bool IndexInRange(this NPC[] _, int index) => (uint)index < Main.maxNPCs; /// /// Fallback method for Main.player.IndexInRange which provide accurate range check (0 <= index < Main.maxPlayers) /// /// whoAmI index to check /// true if index is in valid range [0 <= index < Main.maxPlayers] - public static bool IndexInRange(this Player[] _, int index) - { - if (index >= 0) - return index < Main.maxPlayers; - return false; - } + public static bool IndexInRange(this Player[] _, int index) => (uint)index < Main.maxPlayers; /// /// Fallback method for Main.projectile.IndexInRange which provide accurate range check (0 <= index < Main.maxProjectiles) /// /// whoAmI index to check /// true if index is in valid range [0 <= index < Main.maxProjectiles] - public static bool IndexInRange(this Projectile[] _, int index) - { - if (index >= 0) - return index < Main.maxProjectiles; - return false; - } + public static bool IndexInRange(this Projectile[] _, int index) => (uint)index < Main.maxProjectiles; /// /// Fallback method for Main.gore.IndexInRange which provide accurate range check (0 <= index < Main.maxGore) /// /// whoAmI index to check /// true if index is in valid range [0 <= index < Main.maxGore] - public static bool IndexInRange(this Gore[] _, int index) - { - if (index >= 0) - return index < Main.maxGore; - return false; - } + public static bool IndexInRange(this Gore[] _, int index) => (uint)index < Main.maxGore; /// /// Fallback method for Main.npc.IndexInRange which provide accurate range check (0 <= index < Main.maxDust) /// /// whoAmI index to check /// true if index is in valid range [0 <= index < Main.maxDust] - public static bool IndexInRange(this Dust[] _, int index) - { - if (index >= 0) - return index < Main.maxDust; - return false; - } + public static bool IndexInRange(this Dust[] _, int index) => (uint)index < Main.maxDust; #endregion } } diff --git a/Utilities/ExtraArmAnimations.cs b/Utilities/ExtraArmAnimations.cs index 64a657db85..d99e65e43d 100644 --- a/Utilities/ExtraArmAnimations.cs +++ b/Utilities/ExtraArmAnimations.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Terraria; diff --git a/Utilities/FasterParallel.cs b/Utilities/FasterParallel.cs new file mode 100644 index 0000000000..fc33ffdb23 --- /dev/null +++ b/Utilities/FasterParallel.cs @@ -0,0 +1,102 @@ +#nullable enable + +using System; +using System.Threading; + +using ReLogic.Threading; + +namespace CalamityMod.Utilities +{ + // Tomat: I have recycled this from my initial implementation I've given to + // Nitrate. + /// + /// A faster implementation of without a timeout. + /// + public static class FasterParallel + { + /// + /// A faster reimplementation of . + /// + public static void For(int fromInclusive, int toExclusive, ParallelForAction callback, object? context = null) + { + var rangeLength = toExclusive - fromInclusive; + + if (rangeLength == 0) + { + return; + } + + var initialCount = Math.Min(Math.Max(1, Environment.ProcessorCount - 1), rangeLength); + var rangeLengthPerTask = rangeLength / initialCount; + var remainder = rangeLength % initialCount; + CountdownEvent countdownEvent = new(initialCount); + var currentRangeStart = toExclusive; + + for (var i = initialCount - 1; i >= 0; --i) + { + var rangeLengthForTask = rangeLengthPerTask; + + if (i < remainder) + { + rangeLengthForTask++; + } + + currentRangeStart -= rangeLengthForTask; + var rangeStart = currentRangeStart; + var rangeEnd = rangeStart + rangeLengthForTask; + RangeTask rangeTask = new(callback, rangeStart, rangeEnd, context, countdownEvent); + + if (i < 1) + { + InvokeTask(rangeTask); + } + else + { + ThreadPool.QueueUserWorkItem(InvokeTask, rangeTask); + } + } + + countdownEvent.Wait(); + } + + private static void InvokeTask(object? context) + { + (context as RangeTask)?.Invoke(); + } + + private class RangeTask + { + private readonly ParallelForAction action; + private readonly int fromInclusive; + private readonly int toExclusive; + private readonly object? context; + private readonly CountdownEvent countdownEvent; + + public RangeTask(ParallelForAction action, int fromInclusive, int toExclusive, object? context, CountdownEvent countdownEvent) + { + this.action = action; + this.fromInclusive = fromInclusive; + this.toExclusive = toExclusive; + this.context = context; + this.countdownEvent = countdownEvent; + } + + public void Invoke() + { + try + { + if (fromInclusive == toExclusive) + { + return; + } + + action(fromInclusive, toExclusive, context); + } + finally + { + countdownEvent.Signal(); + } + } + } + } +} diff --git a/Utilities/FurnitureSetupUtils.cs b/Utilities/FurnitureSetupUtils.cs deleted file mode 100644 index c5cb3cd6d2..0000000000 --- a/Utilities/FurnitureSetupUtils.cs +++ /dev/null @@ -1,1584 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.ModLoader.Default; -using Terraria.ObjectData; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod -{ - public static partial class CalamityUtils - { - public static void RightClickBreak(int i, int j) - { - if (Main.tile[i, j] != null && Main.tile[i, j].HasTile) - { - WorldGen.KillTile(i, j, false, false, false); - if (!Main.tile[i, j].HasTile && Main.netMode != NetmodeID.SinglePlayer) - { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); - } - } - } - - public static bool BedRightClick(int i, int j) - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - int spawnX = i - tile.TileFrameX / 18 + (tile.TileFrameX >= 72 ? 5 : 2); - int spawnY = j + 2; - if (tile.TileFrameY % 38 != 0) - { - spawnY--; - } - - if (!Player.IsHoveringOverABottomSideOfABed(i, j)) - { - if (player.IsWithinSnappngRangeToTile(i, j, PlayerSleepingHelper.BedSleepingMaxDistance)) - { - player.GamepadEnableGrappleCooldown(); - player.sleeping.StartSleeping(player, i, j); - } - } - else - { - player.FindSpawn(); - - if (player.SpawnX == spawnX && player.SpawnY == spawnY) - { - player.RemoveSpawn(); - Main.NewText(Language.GetTextValue("Game.SpawnPointRemoved"), byte.MaxValue, 240, 20); - } - else if (Player.CheckSpawn(spawnX, spawnY)) - { - player.ChangeSpawn(spawnX, spawnY); - Main.NewText(Language.GetTextValue("Game.SpawnPointSet"), byte.MaxValue, 240, 20); - } - } - - return true; - } - - #region Sitting in Chairs - // fat is for 2 tile chairs like Exo Chair and Exo Toilet - public static void ChairSitInfo(int i, int j, ref TileRestingInfo info, int nextStyleHeight = 40, bool fat = false, bool hasOffset = false, bool shitter = false) - { - if (hasOffset) - { - info.DirectionOffset = 0; - info.VisualOffset = new Vector2(-8f, 0f); - } - - Tile tile = Framing.GetTileSafely(i, j); - bool frameCheck = fat ? tile.TileFrameX >= 35 : tile.TileFrameX != 0; - - if (shitter) - info.ExtraInfo.IsAToilet = true; - - info.TargetDirection = -1; - if (frameCheck) - { - info.TargetDirection = 1; - } - - if (fat) - { - int xPos = tile.TileFrameX / 18; - if (xPos == 1) - i--; - if (xPos == 2) - i++; - } - - info.AnchorTilePosition.X = i; - info.AnchorTilePosition.Y = j; - - if (tile.TileFrameY % nextStyleHeight == 0) - { - info.AnchorTilePosition.Y++; - } - } - - public static bool ChairRightClick(int i, int j) - { - Player player = Main.LocalPlayer; - - if (player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance)) - { - player.GamepadEnableGrappleCooldown(); - player.sitting.SitDown(player, i, j); - } - return true; - } - - public static void ChairMouseOver(int i, int j, int itemID, bool fat = false) - { - Player player = Main.LocalPlayer; - - if (!player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance)) - { - return; - } - - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = itemID; - - bool frameCheck = fat ? Main.tile[i, j].TileFrameX <= 35 : Main.tile[i, j].TileFrameX / 18 < 0; - if (frameCheck) - { - player.cursorItemIconReversed = true; - } - } - - public static void MouseOver(int i, int j, int itemID) - { - Player player = Main.LocalPlayer; - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = itemID; - } - #endregion - - #region Sitting in Sofas/Benches - public static void BenchSitInfo(int i, int j, ref TileRestingInfo info, int nextStyleHeight = 40) - { - Tile tile = Framing.GetTileSafely(i, j); - Player player = Main.LocalPlayer; - - info.DirectionOffset = 0; - float offset = 0f; - if (tile.TileFrameX < 17 && player.direction == 1) - offset = 8f; - if (tile.TileFrameX < 17 && player.direction == -1) - offset = -8f; - if (tile.TileFrameX > 34 && player.direction == 1) - offset = -8f; - if (tile.TileFrameX > 34 && player.direction == -1) - offset = 8f; - info.VisualOffset = new Vector2(offset, 0f); - info.TargetDirection = player.direction; - - info.AnchorTilePosition.X = i; - info.AnchorTilePosition.Y = j; - - if (tile.TileFrameY % nextStyleHeight == 0) - { - info.AnchorTilePosition.Y++; - } - } - - public static void BenchMouseOver(int i, int j, int itemID) - { - Player player = Main.LocalPlayer; - - if (!player.IsWithinSnappngRangeToTile(i, j, PlayerSittingHelper.ChairSittingMaxDistance)) - { - return; - } - - player.noThrow = 2; - player.cursorItemIconEnabled = true; - player.cursorItemIconID = itemID; - } - #endregion - - public static bool ChestRightClick(int i, int j) - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - Main.mouseRightRelease = false; - int left = i; - int top = j; - if (tile.TileFrameX % 36 != 0) - { - left--; - } - if (tile.TileFrameY != 0) - { - top--; - } - if (player.sign >= 0) - { - SoundEngine.PlaySound(SoundID.MenuClose); - player.sign = -1; - Main.editSign = false; - Main.npcChatText = ""; - } - if (Main.editChest) - { - SoundEngine.PlaySound(SoundID.MenuTick); - Main.editChest = false; - Main.npcChatText = ""; - } - if (player.editedChestName) - { - NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); - player.editedChestName = false; - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - { - if (left == player.chestX && top == player.chestY && player.chest >= 0) - { - player.chest = -1; - Recipe.FindRecipes(); - SoundEngine.PlaySound(SoundID.MenuClose); - } - else - { - NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); - Main.stackSplit = 600; - } - } - else - { - int chest = Chest.FindChest(left, top); - if (chest >= 0) - { - Main.stackSplit = 600; - if (chest == player.chest) - { - player.chest = -1; - SoundEngine.PlaySound(SoundID.MenuClose); - } - else - { - player.chest = chest; - Main.playerInventory = true; - Main.recBigList = false; - player.chestX = left; - player.chestY = top; - SoundEngine.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); - } - Recipe.FindRecipes(); - } - } - return true; - } - - public static void ChestMouseOver(int i, int j) where T : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); - int left = i; - int top = j; - if (tile.TileFrameX % 36 != 0) - { - left--; - } - if (tile.TileFrameY != 0) - { - top--; - } - int chest = Chest.FindChest(left, top); - player.cursorItemIconID = -1; - if (chest < 0) - { - player.cursorItemIconText = Language.GetTextValue("LegacyChestType.0"); - } - else - { - player.cursorItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; - if (player.cursorItemIconText == chestName) - { - player.cursorItemIconID = ItemType(); - player.cursorItemIconText = ""; - } - } - player.noThrow = 2; - player.cursorItemIconEnabled = true; - } - - public static void ChestMouseFar(int i, int j) where T : ModItem - { - ChestMouseOver(i, j); - Player player = Main.LocalPlayer; - if (player.cursorItemIconText == "") - { - player.cursorItemIconEnabled = false; - player.cursorItemIconID = 0; - } - } - - public static bool ClockRightClick() - { - string text = "AM"; - - // Get Terraria's current strange time variable - double time = Main.time; - - // Correct for night time (which for some reason isn't just a different number) by adding 54000. - if (!Main.dayTime) - time += 54000D; - - // Divide by seconds in an hour - time /= 3600D; - - // Terraria night starts at 7:30 PM, so offset accordingly - time -= 19.5; - - // Offset time to ensure it is not negative, then change to PM if necessary - if (time < 0D) - time += 24D; - if (time >= 12D) - text = "PM"; - - // Get the decimal (smaller than hours, so minutes) component of time. - int intTime = (int)time; - double deltaTime = time - intTime; - - // Convert decimal time into an exact number of minutes. - deltaTime = (int)(deltaTime * 60D); - - string minuteText = deltaTime.ToString(); - - // Ensure minutes has a leading zero - if (deltaTime < 10D) - minuteText = "0" + minuteText; - - // Convert from 24 to 12 hour time (PM already handled earlier) - if (intTime > 12) - intTime -= 12; - // 12 AM is actually hour zero in 24 hour time - if (intTime == 0) - intTime = 12; - - // Create an overall time readout and send it to chat - var newText = string.Concat("Time: ", intTime, ":", minuteText, " ", text); - Main.NewText(newText, 255, 240, 20); - return true; - } - - public static bool DresserRightClick() - { - Player player = Main.LocalPlayer; - if (Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameY == 0) - { - Main.CancelClothesWindow(true); - - int left = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameX / 18); - left %= 3; - left = Player.tileTargetX - left; - int top = Player.tileTargetY - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameY / 18); - if (player.sign > -1) - { - SoundEngine.PlaySound(SoundID.MenuClose); - player.sign = -1; - Main.editSign = false; - Main.npcChatText = string.Empty; - } - if (Main.editChest) - { - SoundEngine.PlaySound(SoundID.MenuTick); - Main.editChest = false; - Main.npcChatText = string.Empty; - } - if (player.editedChestName) - { - NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); - player.editedChestName = false; - } - if (Main.netMode == NetmodeID.MultiplayerClient) - { - if (left == player.chestX && top == player.chestY && player.chest != -1) - { - player.chest = -1; - Recipe.FindRecipes(); - SoundEngine.PlaySound(SoundID.MenuClose); - } - else - { - NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); - Main.stackSplit = 600; - } - return true; - } - else - { - player.piggyBankProjTracker.Clear(); - player.voidLensChest.Clear(); - int dresserChestID = Chest.FindChest(left, top); - if (dresserChestID != -1) - { - Main.stackSplit = 600; - if (dresserChestID == player.chest) - { - player.chest = -1; - Recipe.FindRecipes(); - SoundEngine.PlaySound(SoundID.MenuClose); - } - else if (dresserChestID != player.chest && player.chest == -1) - { - player.chest = dresserChestID; - Main.playerInventory = true; - Main.recBigList = false; - SoundEngine.PlaySound(SoundID.MenuOpen); - player.chestX = left; - player.chestY = top; - } - else - { - player.chest = dresserChestID; - Main.playerInventory = true; - Main.recBigList = false; - SoundEngine.PlaySound(SoundID.MenuTick); - player.chestX = left; - player.chestY = top; - } - Recipe.FindRecipes(); - return true; - } - } - } - else - { - Main.playerInventory = false; - player.chest = -1; - Recipe.FindRecipes(); - Main.interactedDresserTopLeftX = Player.tileTargetX; - Main.interactedDresserTopLeftY = Player.tileTargetY; - Main.OpenClothesWindow(); - return true; - } - - return false; - } - - public static void DresserMouseFar() where T : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; - string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); - int left = Player.tileTargetX; - int top = Player.tileTargetY; - left -= (int)(tile.TileFrameX % 54 / 18); - if (tile.TileFrameY % 36 != 0) - { - top--; - } - int chestIndex = Chest.FindChest(left, top); - player.cursorItemIconID = -1; - if (chestIndex < 0) - { - player.cursorItemIconText = Language.GetTextValue("LegacyDresserType.0"); - } - else - { - if (Main.chest[chestIndex].name != "") - { - player.cursorItemIconText = Main.chest[chestIndex].name; - } - else - { - player.cursorItemIconText = chestName; - } - if (player.cursorItemIconText == chestName) - { - player.cursorItemIconID = ItemType(); - player.cursorItemIconText = ""; - } - } - player.noThrow = 2; - player.cursorItemIconEnabled = true; - if (player.cursorItemIconText == "") - { - player.cursorItemIconEnabled = false; - player.cursorItemIconID = 0; - } - } - - public static void DresserMouseOver() where T : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY]; - string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); - int left = Player.tileTargetX; - int top = Player.tileTargetY; - left -= (int)(tile.TileFrameX % 54 / 18); - if (tile.TileFrameY % 36 != 0) - { - top--; - } - int chestIndex = Chest.FindChest(left, top); - player.cursorItemIconID = -1; - if (chestIndex < 0) - { - player.cursorItemIconText = Language.GetTextValue("LegacyDresserType.0"); - } - else - { - if (Main.chest[chestIndex].name != "") - { - player.cursorItemIconText = Main.chest[chestIndex].name; - } - else - { - player.cursorItemIconText = chestName; - } - if (player.cursorItemIconText == chestName) - { - player.cursorItemIconID = ItemType(); - player.cursorItemIconText = ""; - } - } - player.noThrow = 2; - player.cursorItemIconEnabled = true; - if (Main.tile[Player.tileTargetX, Player.tileTargetY].TileFrameY > 0) - { - player.cursorItemIconID = ItemID.FamiliarShirt; - } - } - - public static bool LockedChestRightClick(bool isLocked, int left, int top, int i, int j) - { - Player player = Main.LocalPlayer; - - // If the player right clicked the chest while editing a sign, finish that up - if (player.sign >= 0) - { - SoundEngine.PlaySound(SoundID.MenuClose); - player.sign = -1; - Main.editSign = false; - Main.npcChatText = ""; - } - - // If the player right clicked the chest while editing a chest, finish that up - if (Main.editChest) - { - SoundEngine.PlaySound(SoundID.MenuTick); - Main.editChest = false; - Main.npcChatText = ""; - } - - // If the player right clicked the chest after changing another chest's name, finish that up - if (player.editedChestName) - { - NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); - player.editedChestName = false; - } - if (Main.netMode == NetmodeID.MultiplayerClient && !isLocked) - { - // Right clicking the chest you currently have open closes it. This counts as interaction. - if (left == player.chestX && top == player.chestY && player.chest >= 0) - { - player.chest = -1; - Recipe.FindRecipes(); - SoundEngine.PlaySound(SoundID.MenuClose); - } - - // Right clicking this chest opens it if it's not already open. This counts as interaction. - else - { - NetMessage.SendData(MessageID.RequestChestOpen, -1, -1, null, left, (float)top, 0f, 0f, 0, 0, 0); - Main.stackSplit = 600; - } - return true; - } - - else - { - if (isLocked) - { - // If you right click the locked chest and you can unlock it, it unlocks itself but does not open. This counts as interaction. - if (Chest.Unlock(left, top)) - { - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendData(MessageID.LockAndUnlock, -1, -1, null, player.whoAmI, 1f, (float)left, (float)top); - } - return true; - } - } - else - { - int chest = Chest.FindChest(left, top); - if (chest >= 0) - { - Main.stackSplit = 600; - - // If you right click the same chest you already have open, it closes. This counts as interaction. - if (chest == player.chest) - { - player.chest = -1; - SoundEngine.PlaySound(SoundID.MenuClose); - } - - // If you right click this chest when you have a different chest selected, that one closes and this one opens. This counts as interaction. - else - { - player.chest = chest; - Main.playerInventory = true; - Main.recBigList = false; - player.chestX = left; - player.chestY = top; - SoundEngine.PlaySound(player.chest < 0 ? SoundID.MenuOpen : SoundID.MenuTick); - } - - Recipe.FindRecipes(); - return true; - } - } - } - - // This only occurs when the chest is locked and cannot be unlocked. You did not interact with the chest. - return false; - } - - public static void LockedChestMouseOver(int i, int j) - where K : ModItem where C : ModItem - { - Player player = Main.LocalPlayer; - Tile tile = Main.tile[i, j]; - string chestName = TileLoader.DefaultContainerName(tile.TileType, tile.TileFrameX, tile.TileFrameY); - int left = i; - int top = j; - if (tile.TileFrameX % 36 != 0) - { - left--; - } - if (tile.TileFrameY != 0) - { - top--; - } - int chest = Chest.FindChest(left, top); - player.cursorItemIconID = -1; - if (chest < 0) - { - player.cursorItemIconText = Language.GetTextValue("LegacyChestType.0"); - } - else - { - player.cursorItemIconText = Main.chest[chest].name.Length > 0 ? Main.chest[chest].name : chestName; - if (player.cursorItemIconText == chestName) - { - player.cursorItemIconID = ItemType(); - if (Main.tile[left, top].TileFrameX / 36 == 1) - player.cursorItemIconID = ItemType(); - player.cursorItemIconText = ""; - } - } - player.noThrow = 2; - player.cursorItemIconEnabled = true; - } - - public static void LockedChestMouseOverFar(int i, int j) - where K : ModItem where C : ModItem - { - LockedChestMouseOver(i, j); - Player player = Main.LocalPlayer; - if (player.cursorItemIconText == "") - { - player.cursorItemIconEnabled = false; - player.cursorItemIconID = 0; - } - } - - /// - /// Extension which initializes a ModTile to be a bar. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// The color of the bar on the minimap. - /// Whether this tile is supposed to be immune to lava. Defaults to true like vanilla bars. - internal static void SetUpBar(this ModTile mt, int itemDropID, Color mapColor, bool lavaImmune = true) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileShine[mt.Type] = 1100; - Main.tileSolid[mt.Type] = true; - Main.tileSolidTop[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - // Vanilla bars are labeled as "Metal Bar" on the minimap - mt.AddMapEntry(mapColor, Language.GetText("MapObject.MetalBar")); - } - - /// - /// Extension which initializes a ModTile to be a bathtub. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpBathtub(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.Width = 4; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - - // All bathtubs count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - mt.AddMapEntry(new Color(144, 148, 144), Language.GetText("ItemName.Bathtub")); - } - - /// - /// Extension which initializes a ModTile to be a bed. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpBed(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.HasOutlines[mt.Type] = true; - TileID.Sets.CanBeSleptIn[mt.Type] = true; - TileID.Sets.InteractibleByNPCs[mt.Type] = true; - TileID.Sets.IsValidSpawnPoint[mt.Type] = true; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.Width = 4; - TileObjectData.newTile.Height = 2; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - - // All beds count as chairs. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.Bed")); - mt.AdjTiles = new int[] { TileID.Beds }; - } - - /// - /// Extension which initializes a ModTile to be a bookcase. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile is supposed to have a solid top. Defaults to true. - /// Whether this tile is automatically registered as a bookcase and table with proper map entry. Defaults to true. - internal static void SetUpBookcase(this ModTile mt, int itemDropID, bool lavaImmune = false, bool solidTop = true, bool autoBookcase = true) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileSolidTop[mt.Type] = solidTop; - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileTable[mt.Type] = solidTop; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - // Skip this for special bookcases such as Monolith Amalgam - if (autoBookcase) - { - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.Bookcase")); - mt.AdjTiles = new int[] { TileID.Bookcases }; - } - } - - /// - /// Extension which initializes a ModTile to be a candelabra. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpCandelabra(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(mt.Type); - - // All candelabras count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("ItemName.Candelabra")); - mt.AdjTiles = new int[] { TileID.Candelabras }; - } - - /// - /// Extension which initializes a ModTile to be a candle. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile is supposed to use normal map entries. Defaults to true. - /// The vertical offset of the tile. Defaults to -4. - internal static void SetUpCandle(this ModTile mt, int itemDropID, bool lavaImmune = false, bool autoMapEntry = true, int offset = -4) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.StyleOnTable1x1); - TileObjectData.newTile.CoordinateHeights = new int[] { 20 }; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.DrawYOffset = offset; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(mt.Type); - - // All candles count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - if (autoMapEntry) - mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("ItemName.Candle")); - - mt.AdjTiles = new int[] { TileID.Candles }; - } - - /// - /// Extension which initializes a ModTile to be a chair. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpChair(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.CanBeSatOnForNPCs[mt.Type] = true; - TileID.Sets.CanBeSatOnForPlayers[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.newTile.StyleWrapLimit = 2; - TileObjectData.newTile.StyleMultiplier = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - - // As you could probably guess, all chairs count as chairs. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Chair")); - mt.AdjTiles = new int[] { TileID.Chairs }; - } - - /// - /// Extension which initializes a ModTile to be a chandelier. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpChandelier(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.MultiTileSway[mt.Type] = true; - TileObjectData.newTile.Width = 3; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.Origin = new Point16(1, 0); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(mt.Type); - - // All chandeliers count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - mt.AddMapEntry(new Color(235, 166, 135), Language.GetText("MapObject.Chandelier")); - mt.AdjTiles = new int[] { TileID.Chandeliers }; - } - - /// - /// Extension which initializes a ModTile to be a chest. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// If true, uses the parameter offsetAmt to decide the Y draw offset. - /// If offset is true, this is the Y draw offset to use. Otherwise it is ignored. - internal static void SetUpChest(this ModTile mt, int itemDropID, bool offset = false, int offsetAmt = 4) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileSpelunker[mt.Type] = true; - Main.tileContainer[mt.Type] = true; - Main.tileShine2[mt.Type] = true; - Main.tileShine[mt.Type] = 1200; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileOreFinderPriority[mt.Type] = 500; - TileID.Sets.BasicChest[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); - if (offset) - TileObjectData.newTile.DrawYOffset = offsetAmt; - TileObjectData.newTile.Origin = new Point16(0, 1); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; - TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); - TileObjectData.newTile.AnchorInvalidTiles = new int[] { TileID.MagicalIceBlock }; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.LavaPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.addTile(mt.Type); - - mt.AdjTiles = new int[] { TileID.Containers }; - } - - /// - /// Extension which initializes a ModTile to be a clock. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpClock(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX); - TileObjectData.newTile.Height = 5; - TileObjectData.newTile.CoordinateHeights = new int[] - { - 16, - 16, - 16, - 16, - 16 - }; - TileObjectData.newTile.Origin = new Point16(0, 4); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.GrandfatherClock")); - mt.AdjTiles = new int[] { TileID.GrandfatherClocks }; - } - - /// - /// Extension which initializes a ModTile to be a closed door. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpDoorClosed(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileFrameImportant[mt.Type] = true; - Main.tileBlockLight[mt.Type] = true; - Main.tileSolid[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.NotReallySolid[mt.Type] = true; - TileID.Sets.DrawsWalls[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.Width = 1; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = LiquidPlacement.Allowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 1); - TileObjectData.addAlternate(0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 2); - TileObjectData.addAlternate(0); - TileObjectData.addTile(mt.Type); - - // As you could probably guess, all closed doors count as doors. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); - mt.AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); - mt.AdjTiles = new int[] { TileID.ClosedDoor }; - } - - /// - /// Extension which initializes a ModTile to be an open door. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpDoorOpen(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileFrameImportant[mt.Type] = true; - Main.tileSolid[mt.Type] = false; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - Main.tileNoSunLight[mt.Type] = true; - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 3; - TileObjectData.newTile.Origin = new Point16(0, 0); - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 0); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 0); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.LavaDeath = true; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.StyleMultiplier = 2; - TileObjectData.newTile.StyleWrapLimit = 2; - TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 1); - TileObjectData.addAlternate(0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(0, 2); - TileObjectData.addAlternate(0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(1, 0); - TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.addAlternate(1); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(1, 1); - TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.addAlternate(1); - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.Origin = new Point16(1, 2); - TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1); - TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft; - TileObjectData.addAlternate(1); - TileObjectData.addTile(mt.Type); - TileID.Sets.HousingWalls[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - - // As you could probably guess, all open doors count as doors. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); - mt.AddMapEntry(new Color(119, 105, 79), Language.GetText("MapObject.Door")); - mt.AdjTiles = new int[] { TileID.OpenDoor }; - } - - /// - /// Extension which initializes a ModTile to be a dresser. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - internal static void SetUpDresser(this ModTile mt, int itemDropID) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileSolidTop[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileContainer[mt.Type] = true; - Main.tileWaterDeath[mt.Type] = false; - Main.tileLavaDeath[mt.Type] = false; - TileID.Sets.BasicDresser[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.Origin = new Point16(1, 1); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16 }; - TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(new Func(Chest.FindEmptyChest), -1, 0, true); - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(new Func(Chest.AfterPlacement_Hook), -1, 0, false); - TileObjectData.newTile.AnchorInvalidTiles = new int[] { 127 }; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.addTile(mt.Type); - - // All dressers count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - mt.AdjTiles = new int[] { TileID.Dressers }; - } - - /// - /// Extension which initializes a ModTile to be a fountain. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// The map color of the tile. - /// Whether or not the type of fountain is lava. - internal static void SetUpFountain(this ModTile mt, int itemDropID, Color mapColor, bool lava = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = false; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.LavaDeath = false; - TileObjectData.newTile.LavaPlacement = LiquidPlacement.Allowed; - TileObjectData.addTile(mt.Type); - TileID.Sets.HasOutlines[mt.Type] = true; - - TileObjectData.newTile.Width = 2; - TileObjectData.newTile.Height = 4; - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.Origin = new Point16(0, 3); - TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 2, 0); - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(mt.Type); - - mt.AddMapEntry(mapColor, lava ? CalamityUtils.GetText("Tiles.LavaFountain") : Language.GetText("MapObject.WaterFountain")); - mt.AnimationFrameHeight = 72; - } - - /// - /// Extension which initializes a ModTile to be a floor lamp. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpLamp(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1xX); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.addTile(mt.Type); - - // All floor lamps count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("MapObject.FloorLamp")); - mt.AdjTiles = new int[] { TileID.Lamps }; - } - - /// - /// Extension which initializes a ModTile to be a hanging lantern. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile is supposed to use normal map entries. Defaults to true. - internal static void SetUpLantern(this ModTile mt, int itemDropID, bool lavaImmune = false, bool autoMapEntry = true) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileID.Sets.MultiTileSway[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.StyleLineSkip = 2; - TileObjectData.newTile.DrawYOffset = -2; - TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); - TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.Platform, TileObjectData.newTile.Width, 0); - TileObjectData.newAlternate.DrawYOffset = -10; - TileObjectData.addAlternate(0); - TileObjectData.addTile(mt.Type); - - // All hanging lanterns count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - if (autoMapEntry) - mt.AddMapEntry(new Color(251, 235, 127), Language.GetText("MapObject.Lantern")); - - mt.AdjTiles = new int[] { TileID.HangingLanterns }; - } - - /// - /// Extension which initializes a ModTile to be a piano. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile is supposed to have a solid top. Defaults to true. - internal static void SetUpPiano(this ModTile mt, int itemDropID, bool lavaImmune = false, bool solidTop = true) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileTable[mt.Type] = solidTop; - Main.tileSolidTop[mt.Type] = solidTop; - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - // All pianos count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.Piano")); - } - - /// - /// Extension which initializes a ModTile to be a platform. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpPlatform(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileSolidTop[mt.Type] = true; - Main.tileSolid[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - TileID.Sets.Platforms[mt.Type] = true; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; - TileObjectData.newTile.CoordinateWidth = 16; - TileObjectData.newTile.CoordinatePadding = 2; - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.StyleMultiplier = 27; - TileObjectData.newTile.StyleWrapLimit = 27; - TileObjectData.newTile.UsesCustomCanPlace = false; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - // All platforms count as doors (so that you may have top-or-bottom entry/exit rooms) - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor); - mt.AddMapEntry(new Color(191, 142, 111)); - mt.AdjTiles = new int[] { TileID.Platforms }; - } - - /// - /// Extension which initializes a ModPylon to be a simple pylon.
- /// ModPylon appears to make it easier to create a modded pylon extending ModTile.
- ///
- /// Note: This is used for pylons that follow general vanilla functionality.
- /// Pylons that have vastly different custom behavior require a different setup (refer to ExamplePylonTileAdvanced in ExampleMod).
- ///
- /// The ModPylon which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpPylon(this ModPylon mp, TEModdedPylon pylonHook, bool lavaImmune = false, int offset = 2) - { - Main.tileLighted[mp.Type] = true; - Main.tileFrameImportant[mp.Type] = true; - Main.tileLavaDeath[mp.Type] = !lavaImmune; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x4); - - // These definitions allow for vanilla's pylon TileEntities to be placed. - // tModLoader has a built in Tile Entity specifically for modded pylons, which is extended through TECalamityPylon. - TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(pylonHook.PlacementPreviewHook_CheckIfCanPlace, 1, 0, true); - TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(pylonHook.Hook_AfterPlacement, -1, 0, false); - - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.DrawYOffset = offset; - TileObjectData.addTile(mp.Type); - - // Adds functionality for proximity of pylons; if this is true, then being near this tile will count as being near a pylon for the teleportation process. - mp.AddToArray(ref TileID.Sets.CountsAsPylon); - } - - /// - /// Extension which initializes a ModTile to be a sink. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile counts as a water source. Defaults to true. - /// Whether this tile counts as a lava source. Defaults to false. - /// Whether this tile counts as a honey source. Defaults to false. - internal static void SetUpSink(this ModTile mt, int itemDropID, bool lavaImmune = false, bool water = true, bool lava = false, bool honey = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.CountsAsWaterSource[mt.Type] = water; - 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; - TileObjectData.addTile(mt.Type); - - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Sink")); - if (water) - mt.AdjTiles = new int[] { TileID.Sinks }; - } - - /// - /// Extension which initializes a ModTile to be a sofa. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - /// Whether this tile is displayed as bench instead of sofa on the map. Defaults to false. - internal static void SetUpSofa(this ModTile mt, int itemDropID, bool lavaImmune = false, bool bench = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.CanBeSatOnForPlayers[mt.Type] = true; - TileID.Sets.HasOutlines[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - // All sofas count as chairs. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsChair); - mt.AddMapEntry(new Color(191, 142, 111), bench ? Language.GetText("ItemName.Bench") : Language.GetText("ItemName.Sofa")); - } - - /// - /// Extension which initializes a ModTile to be a table. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpTable(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileSolidTop[mt.Type] = true; - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - // As you could probably guess, all tables count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("MapObject.Table")); - mt.AdjTiles = new int[] { TileID.Tables }; - } - - /// - /// Extension which initializes a ModTile to be a torch. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to water. Defaults to false. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpTorch(this ModTile mt, int itemDropID, bool waterImmune = false, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileLighted[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileSolid[mt.Type] = false; - Main.tileNoAttach[mt.Type] = true; - Main.tileNoFail[mt.Type] = true; - Main.tileWaterDeath[mt.Type] = !waterImmune; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileID.Sets.Torch[mt.Type] = true; - TileID.Sets.FramesOnKillWall[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newTile.WaterDeath = !waterImmune; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); - TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newAlternate.WaterDeath = !waterImmune; - TileObjectData.newAlternate.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); - TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; - TileObjectData.addAlternate(1); - TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newAlternate.WaterDeath = !waterImmune; - TileObjectData.newAlternate.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.Tree | AnchorType.AlternateTile, TileObjectData.newTile.Height, 0); - TileObjectData.newAlternate.AnchorAlternateTiles = new int[] { 124 }; - TileObjectData.addAlternate(2); - TileObjectData.newAlternate.CopyFrom(TileObjectData.StyleTorch); - TileObjectData.newAlternate.WaterDeath = !waterImmune; - TileObjectData.newAlternate.LavaDeath = !lavaImmune; - TileObjectData.newAlternate.WaterPlacement = waterImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.newAlternate.AnchorWall = true; - TileObjectData.addAlternate(0); - TileObjectData.addTile(mt.Type); - - // All torches count as light sources. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - mt.AddMapEntry(new Color(253, 221, 3), Language.GetText("ItemName.Torch")); - mt.AdjTiles = new int[] { TileID.Torches }; - } - - /// - /// Extension which initializes a ModTile to be a trophy. - /// - /// The ModTile which is being initialized. - internal static void SetUpTrophy(this ModTile mt) - { - // TODO -- how to force trophy drops correctly? they all have zero code in them - - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = true; - Main.tileSpelunker[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); - TileObjectData.addTile(mt.Type); - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileID.Sets.FramesOnKillWall[mt.Type] = true; - - mt.AddMapEntry(new Color(120, 85, 60), Language.GetText("MapObject.Trophy")); - mt.DustType = 7; - } - - /// - /// Extension which initializes a ModTile to be a work bench. - /// - /// The ModTile which is being initialized. - /// The ID of the item this tile drops when broken. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUpWorkBench(this ModTile mt, int itemDropID, bool lavaImmune = false) - { - mt.RegisterItemDrop(itemDropID); - - Main.tileSolidTop[mt.Type] = true; - Main.tileFrameImportant[mt.Type] = true; - Main.tileNoAttach[mt.Type] = true; - Main.tileTable[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileWaterDeath[mt.Type] = false; - TileID.Sets.DisableSmartCursor[mt.Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); - TileObjectData.newTile.CoordinateHeights = new int[] { 18 }; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - - // All work benches count as tables. - mt.AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); - mt.AddMapEntry(new Color(191, 142, 111), Language.GetText("ItemName.WorkBench")); - mt.AdjTiles = new int[] { TileID.WorkBenches }; - } - - /// - /// Extension which initializes a ModTile to be a 6x6 Painting. - /// - /// The ModTile which is being initialized. - /// Whether this tile is supposed to be immune to lava. Defaults to false. - internal static void SetUp6x6Painting(this ModTile mt, bool lavaImmune = false) - { - Main.tileFrameImportant[mt.Type] = true; - Main.tileLavaDeath[mt.Type] = !lavaImmune; - Main.tileSpelunker[mt.Type] = true; - Main.tileWaterDeath[mt.Type] = false; - TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3Wall); - TileObjectData.newTile.Width = 6; - TileObjectData.newTile.Height = 6; - TileObjectData.newTile.Origin = new Point16(2, 2); - TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16, 16 }; - TileObjectData.newTile.LavaDeath = !lavaImmune; - TileObjectData.newTile.LavaPlacement = lavaImmune ? LiquidPlacement.Allowed : LiquidPlacement.NotAllowed; - TileObjectData.addTile(mt.Type); - } - } -} diff --git a/Utilities/GeneralExtensionUtils.cs b/Utilities/GeneralExtensionUtils.cs index cba1a4cf52..386ac3a3d0 100644 --- a/Utilities/GeneralExtensionUtils.cs +++ b/Utilities/GeneralExtensionUtils.cs @@ -1,6 +1,8 @@ using CalamityMod.CalPlayer; using CalamityMod.Items; +using CalamityMod.Items.BaseItems; using CalamityMod.NPCs; +using CalamityMod.NPCs.VanillaNPCAIOverrides; using CalamityMod.Projectiles; using Terraria; @@ -10,10 +12,21 @@ namespace CalamityMod { public static CalamityPlayer Calamity(this Player player) => player.GetModPlayer(); public static CalamityGlobalNPC Calamity(this NPC npc) => npc.GetGlobalNPC(); + public static CalamityVanillaAIOverrideNPC AIOverrideNPC(this NPC npc) => npc.GetGlobalNPC(); + public static T? AIOverride(this NPC npc) { + VanillaAIOverride aiOverride = npc.GetGlobalNPC().AIOverride; + if (aiOverride == null) + throw new System.Exception("NPC does not have an AI Override"); + + if(aiOverride is T ai) + return ai; + + throw new System.Exception($"NPC's AI Override is not of Type {typeof(T).Name}"); + } public static CalamityTileCollisionHarmNPC FlungNPC(this NPC npc) => npc.GetGlobalNPC(); public static CalamityPolarityNPC PolarityNPC(this NPC npc) => npc.GetGlobalNPC(); public static CalamityGlobalItem Calamity(this Item item) => item.GetGlobalItem(); public static CalamityGlobalProjectile Calamity(this Projectile proj) => proj.GetGlobalProjectile(); - public static Item ActiveItem(this Player player) => Main.mouseItem.IsAir ? player.HeldItem : Main.mouseItem; + public static TransformationPlayer Transformation(this Player player) => player.GetModPlayer(); } } diff --git a/Utilities/GenericAIUtils.cs b/Utilities/GenericAIUtils.cs deleted file mode 100644 index 49fbf5fa78..0000000000 --- a/Utilities/GenericAIUtils.cs +++ /dev/null @@ -1,626 +0,0 @@ -using System; -using CalamityMod.CalPlayer; -using CalamityMod.Enums; -using CalamityMod.Projectiles.Summon; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod -{ - public static partial class CalamityUtils - { - public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, Vector2 returnOffset, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging, int updateDifference = 1) - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - //Anti sticky movement to prevent stacking - projectile.MinionAntiClump(); - - //Breather time between charges as like a reset - bool chargeDelay = false; - if (projectile.ai[0] == 2f) - { - projectile.ai[1] += 1f; - projectile.extraUpdates = initialUpdates + updateDifference; - if (projectile.ai[1] > chargeDelayTime) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.extraUpdates = initialUpdates; - // CIT 2OCT2024: This line was breaking how the game counted minions, - // which resulted in minions being counted extra times and despawning other minions, most notoriously with Resurrection Butterfly. - // As such, I have commented it out. - // projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - chargeDelay = true; - } - } - if (chargeDelay) - { - return; - } - - //Find a target - float maxDist = range; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - bool isButterfly = projectile.type == ProjectileType(); - //Prioritize the targeted enemy if possible - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; - if (npc.CanBeChasedBy(projectile, false) || fishronCheck) - { - //Check the size of the target to make it easier to hit fat targets like Levi - float extraDist = (npc.width / 2) + (npc.height / 2); - - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not - bool canHit = true; - if (extraDist < maxDist && !tileVision) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) - { - maxDist = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - //If no npc is specifically targetted or the selected enemy can't be found, check through the entire array - if (!foundTarget) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; - if (npc.CanBeChasedBy(projectile, false) || fishronCheck) - { - float extraDist = (npc.width / 2) + (npc.height / 2); - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (extraDist < maxDist && !tileVision) - canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1); - if (!foundTarget && targetDist < (maxDist + extraDist) && canHit) - { - maxDist = targetDist; - targetVec = npc.Center; - foundTarget = true; - } - } - } - } - - //If the player is too far, return to the player. Range is increased while attacking something. - float distBeforeForcedReturn = maxPlayerDist; - if (foundTarget) - { - distBeforeForcedReturn = extraMaxPlayerDist; - } - if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - - //Go to the target if you found one - if (foundTarget && projectile.ai[0] == 0f) - { - //Some minions don't ignore tiles while charging like brittle stars - projectile.tileCollide = !ignoreTilesWhenCharging; - Vector2 targetSpot = targetVec - projectile.Center; - float targetDist = targetSpot.Length(); - targetSpot.Normalize(); - //Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does - if (targetDist > 200f) - { - float speed = goToSpeed; //8 - targetSpot *= speed; - projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; - } - else - { - float speed = -goBackSpeed; //-4 - targetSpot *= speed; - projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41 - } - } - - //Movement for idle or returning to the player - else - { - //Ignore tiles so they don't get stuck everywhere like Optic Staff - projectile.tileCollide = false; - - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = projectile.ai[0] == 1f; - } - - //Player distance calculations - Vector2 playerVec = player.Center - projectile.Center + returnOffset; - float playerDist = playerVec.Length(); - - //If the minion is actively returning, move faster - float playerHomeSpeed = 6f; - if (returningToPlayer) - { - playerHomeSpeed = 15f; - } - //Move somewhat faster if the player is kinda far~ish - if (playerDist > 200f && playerHomeSpeed < 8f) - { - playerHomeSpeed = 8f; - } - //Return to normal if close enough to the player - if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //Teleport to the player if abnormally far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - //If more than 70 pixels away, move toward the player - if (playerDist > 70f) - { - playerVec.Normalize(); - playerVec *= playerHomeSpeed; - projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; - } - //Minions never stay still - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } - - //Increment attack counter randomly - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 4); - } - //If high enough, prepare to attack - if (projectile.ai[1] > chargeCounterMax) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - - //Charge at an enemy if not on cooldown - if (projectile.ai[0] == 0f) - { - if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 targetPos = targetVec - projectile.Center; - targetPos.Normalize(); - projectile.velocity = targetPos * chargeSpeed; //8 - projectile.netUpdate = true; - } - } - } - } - - public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f) - { - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI) - continue; - - // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. - bool sameProjType = otherProj.type == projectile.type; - float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); - if (sameProjType && taxicabDist < projectile.width) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X -= pushForce; - else - projectile.velocity.X += pushForce; - - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y -= pushForce; - else - projectile.velocity.Y += pushForce; - } - } - } - - public static void FloatingPetAI(this Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false) - { - Player player = Main.player[projectile.owner]; - - //anti sticking movement as a failsafe - float SAImovement = 0.05f; - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || otherProj.owner != projectile.owner || !Main.projPet[otherProj.type] || k == projectile.whoAmI) - continue; - - // If the other projectile is indeed another pet owned by the same player and they're too close, nudge them away. - bool isPet = Main.projPet[otherProj.type]; - float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); - if (isPet && taxicabDist < projectile.width) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X -= SAImovement; - else - projectile.velocity.X += SAImovement; - - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y -= SAImovement; - else - projectile.velocity.Y += SAImovement; - } - } - - float passiveMvtFloat = 0.5f; - projectile.tileCollide = false; - float range = 100f; - Vector2 projPos = projectile.Center; - float xDist = player.Center.X - projPos.X; - float yDist = player.Center.Y - projPos.Y; - yDist += Main.rand.NextFloat(-10, 20); - xDist += Main.rand.NextFloat(-10, 20); - //Light pets lead the player, normal pets trail the player - xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction); - yDist -= 60f; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - float returnSpeed = 18f; - - //If player is close enough, resume normal - if (playerDist < range && player.velocity.Y == 0f && - projectile.Bottom.Y <= player.Bottom.Y && - !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } - - //Teleport to player if too far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2; - projectile.position.Y = player.Center.Y - projectile.height / 2; - projectile.netUpdate = true; - } - - if (playerDist < 50f) - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - passiveMvtFloat = 0.01f; - } - else - { - if (playerDist < 100f) - { - passiveMvtFloat = 0.1f; - } - if (playerDist > 300f) - { - passiveMvtFloat = 1f; - } - playerDist = returnSpeed / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - } - if (projectile.velocity.X < playerVector.X) - { - projectile.velocity.X += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X += passiveMvtFloat; - } - } - if (projectile.velocity.X > playerVector.X) - { - projectile.velocity.X -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X -= passiveMvtFloat; - } - } - if (projectile.velocity.Y < playerVector.Y) - { - projectile.velocity.Y += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y += passiveMvtFloat * 2f; - } - } - if (projectile.velocity.Y > playerVector.Y) - { - projectile.velocity.Y -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y -= passiveMvtFloat * 2f; - } - } - if (projectile.velocity.X >= 0.25f) - { - projectile.direction = faceRight ? 1 : -1; - } - else if (projectile.velocity.X < -0.25f) - { - projectile.direction = faceRight ? -1 : 1; - } - //Tilting and change directions - projectile.spriteDirection = projectile.direction; - projectile.rotation = projectile.velocity.X * tiltFloat; - } - - public static void HealingProjectile(this Projectile projectile, int healing, int playerToHeal, float homingVelocity, float inertia, bool autoHomes = true, int timeCheck = 120) - { - int target = playerToHeal; - Player player = Main.player[target]; - float homingSpeed = homingVelocity; - if (player.lifeMagnet) - homingSpeed *= 1.5f; - - Vector2 playerVector = player.Center - projectile.Center; - float playerDist = playerVector.Length(); - if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.LocalPlayer.moonLeech) - { - int healAmt = healing; - player.HealPlayer(healAmt, HealTextType.Local); - NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - if (autoHomes) - { - playerDist = homingSpeed / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - projectile.velocity.X = (projectile.velocity.X * inertia + playerVector.X) / (inertia + 1f); - projectile.velocity.Y = (projectile.velocity.Y * inertia + playerVector.Y) / (inertia + 1f); - } - else if (player.lifeMagnet && projectile.timeLeft < timeCheck) - { - playerDist = homingVelocity / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - projectile.velocity.X = (projectile.velocity.X * inertia + playerVector.X) / (inertia + 1f); - projectile.velocity.Y = (projectile.velocity.Y * inertia + playerVector.Y) / (inertia + 1f); - } - } - - /// - /// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC - /// - /// The projectile you're adding sticky behaviour to - /// Number of seconds you want a projectile to cling to an NPC - public static void StickyProjAI(this Projectile projectile, int timeLeft, bool findNewNPC = false) - { - if (projectile.ai[0] == 1f) - { - int seconds = timeLeft; - bool killProj = false; - bool spawnDust = false; - - //the projectile follows the NPC, even if it goes into blocks - projectile.tileCollide = false; - - //timer for triggering hit effects - projectile.localAI[0]++; - if (projectile.localAI[0] % 30f == 0f) - { - spawnDust = true; - } - - //So AI knows what NPC it is sticking to - int npcIndex = (int)projectile.ai[1]; - NPC npc = Main.npc[npcIndex]; - - //Kill projectile after so many seconds or if the NPC it is stuck to no longer exists - if (projectile.localAI[0] >= (float)(60 * seconds)) - { - killProj = true; - } - else if (!npcIndex.WithinBounds(Main.maxNPCs)) - { - killProj = true; - } - - else if (npc.active && !npc.dontTakeDamage) - { - //follow the NPC - projectile.Center = npc.Center - projectile.velocity * 2f; - projectile.gfxOffY = npc.gfxOffY; - - //if attached to npc, trigger npc hit effects every half a second - if (spawnDust) - { - npc.HitEffect(0, 1.0); - } - } - else - { - killProj = true; - } - - //Kill the projectile or reset stats if needed - if (killProj) - { - if (findNewNPC) - projectile.ai[0] = 0f; - else - projectile.Kill(); - } - } - } - - /// - /// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile - /// - /// The projectile you're giving sticky behaviour to - /// How many projectiles of this type can stick to one enemy - public static void ModifyHitNPCSticky(this Projectile projectile, int maxStick) - { - Player player = Main.player[projectile.owner]; - Rectangle myRect = projectile.Hitbox; - - if (projectile.owner == Main.myPlayer) - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - //covers most edge cases like voodoo dolls - if (npc.active && !npc.dontTakeDamage && - ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) || - (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1)) - { - if (npc.noTileCollide || !projectile.ownerHitCheck) - { - bool stickingToNPC; - //Solar Crawltipede tail has special collision - if (npc.type == NPCID.SolarCrawltipedeTail) - { - Rectangle rect = npc.Hitbox; - int crawltipedeHitboxMod = 8; - rect.X -= crawltipedeHitboxMod; - rect.Y -= crawltipedeHitboxMod; - rect.Width += crawltipedeHitboxMod * 2; - rect.Height += crawltipedeHitboxMod * 2; - stickingToNPC = projectile.Colliding(myRect, rect); - } - else - { - stickingToNPC = projectile.Colliding(myRect, npc.Hitbox); - } - if (stickingToNPC) - { - //reflect projectile if the npc can reflect it (like Selenians) - if (npc.reflectsProjectiles && projectile.CanBeReflected()) - { - npc.ReflectProjectile(projectile); - return; - } - - //let the projectile know it is sticking and the npc it is sticking too - projectile.ai[0] = 1f; - projectile.ai[1] = (float)npcIndex; - - //follow the NPC - projectile.velocity = (npc.Center - projectile.Center); - - projectile.netUpdate = true; - - //Count how many projectiles are attached, delete as necessary - Point[] array2 = new Point[maxStick]; - int projCount = 0; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 1f && proj.ai[1] == (float)npcIndex) - { - array2[projCount++] = new Point(projIndex, proj.timeLeft); - if (projCount >= array2.Length) - { - break; - } - } - } - if (projCount >= array2.Length) - { - int stuckProjAmt = 0; - for (int m = 1; m < array2.Length; m++) - { - if (array2[m].Y < array2[stuckProjAmt].Y) - { - stuckProjAmt = m; - } - } - Main.projectile[array2[stuckProjAmt].X].Kill(); - } - } - } - } - } - } - } - - public static void StickToTiles(this Projectile projectile, bool ignorePlatforms, bool stickToEverything) - { - try - { - int xLeft = (int)(projectile.position.X / 16f) - 1; - int xRight = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2; - int yBottom = (int)(projectile.position.Y / 16f) - 1; - int yTop = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2; - if (xLeft < 0) - { - xLeft = 0; - } - if (xRight > Main.maxTilesX) - { - xRight = Main.maxTilesX; - } - if (yBottom < 0) - { - yBottom = 0; - } - if (yTop > Main.maxTilesY) - { - yTop = Main.maxTilesY; - } - for (int x = xLeft; x < xRight; x++) - { - for (int y = yBottom; y < yTop; y++) - { - Tile tile = Main.tile[x, y]; - bool platformCheck = true; - if (ignorePlatforms) - platformCheck = !TileID.Sets.Platforms[tile.TileType] && tile.TileType != TileID.PlanterBox; - bool tableCheck = false; - if (stickToEverything) - tableCheck = Main.tileSolidTop[tile.TileType] && tile.TileFrameY == 0; - if (tile != null && tile.HasUnactuatedTile && platformCheck && (Main.tileSolid[tile.TileType] || tableCheck)) - { - Vector2 tileSize; - tileSize.X = (float)(x * 16); - tileSize.Y = (float)(y * 16); - if (projectile.position.X + (float)projectile.width - 4f > tileSize.X && projectile.position.X + 4f < tileSize.X + 16f && projectile.position.Y + (float)projectile.height - 4f > tileSize.Y && projectile.position.Y + 4f < tileSize.Y + 16f) - { - projectile.velocity.X = 0f; - projectile.velocity.Y = -0.2f; - } - } - } - } - } - catch - { - } - } - } -} diff --git a/Utilities/GlobalEntityUtils.cs b/Utilities/GlobalEntityUtils.cs deleted file mode 100644 index 5376de2c92..0000000000 --- a/Utilities/GlobalEntityUtils.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Terraria.ModLoader; -using Terraria; - -namespace CalamityMod -{ - public static partial class CalamityUtils - { - /// - /// Actual "Thread-Safe" version of TryGetGlobalNPC - /// - /// GlobalNPC type to get - /// Input NPC - /// GlobalNPC output - /// true If we successfully get GlobalNPC. otherwise false - public static bool TryGetGlobalNPCSafer(this NPC npc, out T globalNPC) where T : GlobalNPC - { - try - { - if (npc is null) - { - globalNPC = null; - return false; - } - - int slot = ModContent.GetInstance()?.PerEntityIndex ?? -1; - int length = npc.EntityGlobals.Length; - if (slot < 0 || slot >= length) - { - globalNPC = null; - return false; - } - - npc.TryGetGlobalNPC(out globalNPC); - return globalNPC != null; - } - catch - { - globalNPC = null; - return false; - } - } - } -} diff --git a/Utilities/ILEditingUtils.cs b/Utilities/ILEditingUtils.cs deleted file mode 100644 index bd0cfa0557..0000000000 --- a/Utilities/ILEditingUtils.cs +++ /dev/null @@ -1,17 +0,0 @@ -using MonoMod.Cil; - -namespace CalamityMod -{ - public static partial class CalamityUtils - { - /// - /// Moves an to the final Ret call in the method the cursor is assocated with. - /// - /// The cursor. - public static ILCursor GotoFinalRet(this ILCursor cursor) - { - while (cursor.TryGotoNext(c => c.MatchRet())) { } - return cursor; - } - } -} diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 286212804b..3c29818724 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -1,15 +1,15 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Text; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.DataStructures; using CalamityMod.UI.CalamitasEnchants; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; using Terraria; using Terraria.Audio; -using Terraria.GameContent.Prefixes; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Utilities; namespace CalamityMod { @@ -41,256 +41,6 @@ namespace CalamityMod internal static readonly Color DonatorItemColor = new Color(255, 121, 156); #endregion - // TODO -- This probably isn't the best place to put this but it needs to be somewhere easily accessible. - #region Accessory Prefix Stats - internal static int GetScalingDefense(int prefixID) - { - switch (prefixID) - { - default: - return 0; - - // Ironskin Potion - // This makes sense to be here but also not - case -1: - if (DownedBossSystem.downedDoG) - return 14; - else if (NPC.downedMoonlord) - return 12; - else if (Main.hardMode) - return 10; - return 8; - - case PrefixID.Hard: - if (DownedBossSystem.downedDoG) - return 4; - else if (NPC.downedMoonlord) - return 3; - else if (Main.hardMode) - return 2; - return 1; - - case PrefixID.Guarding: - if (DownedBossSystem.downedDoG) - return 5; - else if (NPC.downedMoonlord) - return 4; - else if (Main.hardMode) - return 3; - return 2; - - case PrefixID.Armored: - if (DownedBossSystem.downedDoG) - return 6; - else if (NPC.downedMoonlord) - return 5; - else if (Main.hardMode) - return 4; - return 3; - - case PrefixID.Warding: - if (DownedBossSystem.downedDoG) - return 7; - else if (NPC.downedMoonlord) - return 6; - else if (Main.hardMode) - return 5; - return 4; - } - } - #endregion - - #region Reforging Algorithm - internal static int GetReworkedReforge(Item item, UnifiedRandom rand, int currentPrefix) - { - CalamityMod mod = CalamityMod.Instance; - int GetCalPrefix(string name) - { - bool found = mod.TryFind(name, out ModPrefix ret); - return found ? ret.Type : 0; - } - - // This is the hardcoded value to "do nothing", and is thus the default choice. - int prefix = -1; - bool supportsLegendary = PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] || (item.ModItem != null && item.ModItem.MeleePrefix()); - - // ACCESSORIES - if (item.accessory) - { - int accRerolls = 0; - int[][] accessoryReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Hard, PrefixID.Jagged, PrefixID.Brisk, PrefixID.Wild, GetCalPrefix("Quiet") }, - /* 1 */ new int[] { PrefixID.Guarding, PrefixID.Spiked, PrefixID.Precise, PrefixID.Fleeting, PrefixID.Rash, GetCalPrefix("Cloaked") }, - /* 2 */ new int[] { PrefixID.Armored, PrefixID.Angry, PrefixID.Hasty2, PrefixID.Intrepid, PrefixID.Arcane, GetCalPrefix("Camouflaged") }, - /* 3 */ new int[] { PrefixID.Warding, PrefixID.Menacing, PrefixID.Lucky, PrefixID.Quick2, PrefixID.Violent, GetCalPrefix("Silent") }, - }; - - // Try to prevent the player from rolling the same modifier twice - do - { - int newPrefix = IteratePrefix(rand, accessoryReforgeTiers, currentPrefix); - if (newPrefix != currentPrefix) - { - prefix = newPrefix; - break; - } - accRerolls++; - } while (accRerolls < 20); - } - - // MELEE (includes tools and whips) - // Melee-ranged hybrid weapons prioritize Legendary if available, otherwise go for Unreal - else if ((item.CountsAsClass() || item.CountsAsClass()) && !(item.CountsAsClass() && !supportsLegendary)) - { - // Terrarian (has its own special "Legendary" for marketing reasons) - // Other items that want to use Legendary2 are also compatible - if (PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2[item.type]) - { - int[][] terrarianReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous }, - /* 2 */ new int[] { PrefixID.Superior, PrefixID.Demonic, PrefixID.Godly }, - /* 3 */ new int[] { PrefixID.Legendary2 }, - }; - prefix = IteratePrefix(rand, terrarianReforgeTiers, currentPrefix); - } - - // Swords, Whips, Tools, other items that support the Legendary modifier - else if (supportsLegendary) - { - int[][] meleeReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Light, PrefixID.Heavy, PrefixID.Light, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky }, - /* 2 */ new int[] { PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp }, - /* 3 */ new int[] { PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior }, - /* 4 */ new int[] { PrefixID.Demonic, PrefixID.Deadly2, PrefixID.Godly }, - /* 5 */ new int[] { PrefixID.Legendary } // for non-tools, Light is a mediocre low-tier reforge - }; - int[][] toolReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Heavy, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky }, - /* 2 */ new int[] { PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp }, - /* 3 */ new int[] { PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior }, - /* 4 */ new int[] { PrefixID.Demonic, PrefixID.Deadly2, PrefixID.Godly }, - /* 5 */ new int[] { PrefixID.Legendary, PrefixID.Light } // for some tools, light is better than legendary. for others, it's equal - }; - - var tierListToUse = (item.pick > 0 || item.axe > 0 || item.hammer > 0) ? toolReforgeTiers : meleeReforgeTiers; - prefix = IteratePrefix(rand, tierListToUse, currentPrefix); - } - - // Yoyos, Flails, Spears, etc. - // Spears actually work fine with Legendary, but vanilla doesn't give it to them, so we won't either. - else - { - // 14MAR2025: Ozzatron: Add support for allowing Ruthless over Godly if the player has more than 100% crit chance of the appropriate class - bool has100Crit = Main.LocalPlayer.GetTotalCritChance(item.DamageType) >= 100; - - int[][] meleeNoSpeedReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous }, - /* 2 */ new int[] { PrefixID.Superior, PrefixID.Demonic }, - /* 3 */ has100Crit ? new int[] { PrefixID.Godly, PrefixID.Ruthless } : new int[] { PrefixID.Godly } - }; - prefix = IteratePrefix(rand, meleeNoSpeedReforgeTiers, currentPrefix); - } - } - - // RANGED - else if (item.CountsAsClass()) - { - int[][] rangedReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Powerful, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Intimidating }, - /* 2 */ new int[] { PrefixID.Murderous, PrefixID.Agile, PrefixID.Hasty, PrefixID.Staunch, PrefixID.Unpleasant }, - /* 3 */ new int[] { PrefixID.Superior, PrefixID.Demonic, PrefixID.Sighted }, - /* 4 */ new int[] { PrefixID.Godly, PrefixID.Rapid, /* ranged Deadly */ PrefixID.Deadly, /* universal Deadly */ PrefixID.Deadly2 }, - /* 5 */ new int[] { PrefixID.Unreal } - }; - prefix = IteratePrefix(rand, rangedReforgeTiers, currentPrefix); - } - - // MAGIC - else if (item.CountsAsClass() || item.CountsAsClass()) - { - int[][] magicReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Furious, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Taboo, PrefixID.Manic }, - /* 2 */ new int[] { PrefixID.Murderous, PrefixID.Agile, PrefixID.Adept, PrefixID.Celestial, PrefixID.Unpleasant }, - /* 3 */ new int[] { PrefixID.Superior, PrefixID.Demonic, PrefixID.Mystic }, - /* 4 */ new int[] { PrefixID.Godly, PrefixID.Masterful, PrefixID.Deadly2 }, - /* 5 */ new int[] { PrefixID.Mythical } - }; - prefix = IteratePrefix(rand, magicReforgeTiers, currentPrefix); - } - - // SUMMON (not whips) - else if (item.CountsAsClass()) - { - int[][] summonReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Nimble, PrefixID.Furious }, - /* 1 */ new int[] { PrefixID.Forceful, PrefixID.Strong, PrefixID.Quick, PrefixID.Taboo, PrefixID.Manic }, - /* 2 */ new int[] { PrefixID.Hurtful, PrefixID.Adept, PrefixID.Celestial }, - /* 3 */ new int[] { PrefixID.Superior, PrefixID.Demonic, PrefixID.Mystic, PrefixID.Deadly2 }, - /* 4 */ new int[] { PrefixID.Masterful, PrefixID.Godly }, - /* 5 */ new int[] { PrefixID.Mythical, PrefixID.Ruthless } // you may want mythical early game for the knockback. - }; - prefix = IteratePrefix(rand, summonReforgeTiers, currentPrefix); - } - - // ROGUE (Calamity adds these reforges to all 1.4 TML throwing items) - else if (item.CountsAsClass()) - { - // Added appropriate universal reforges to rogue, so they don't ONLY get modded prefixes. - int[][] rogueReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Forceful, PrefixID.Strong, GetCalPrefix("Radical"), GetCalPrefix("Pointy") }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, GetCalPrefix("Sharp"), GetCalPrefix("Glorious") }, - /* 2 */ new int[] { PrefixID.Murderous, PrefixID.Agile, PrefixID.Unpleasant, GetCalPrefix("Feathered"), GetCalPrefix("Sleek"), GetCalPrefix("Hefty") }, - /* 3 */ new int[] { PrefixID.Superior, PrefixID.Demonic, GetCalPrefix("Mighty"), GetCalPrefix("Serrated") }, - /* 4 */ new int[] { PrefixID.Godly, PrefixID.Deadly2, GetCalPrefix("Vicious"), GetCalPrefix("Lethal") }, - /* 5 */ new int[] { GetCalPrefix("Flawless") } - }; - prefix = IteratePrefix(rand, rogueReforgeTiers, currentPrefix); - } - - return prefix; - } - - private static int GetPrefixTier(int[][] tiers, int currentPrefix) - { - for (int checkingTier = 0; checkingTier < tiers.Length; ++checkingTier) - { - int[] tierList = tiers[checkingTier]; - for (int i = 0; i < tierList.Length; ++i) - if (tierList[i] == currentPrefix) - return checkingTier; - } - - // If an invalid or modded prefix is detected, return -1. - // This will give a random tier 0 prefix (the "next tier"), starting fresh with a low-tier vanilla or Calamity prefix. - return -1; - } - - private static int IteratePrefix(UnifiedRandom rand, int[][] reforgeTiers, int currentPrefix) - { - int currentTier = GetPrefixTier(reforgeTiers, currentPrefix); - - // If max tier: give max tier reforges forever - // Otherwise: go up by 1 tier with every reforge, guaranteed - int newTier = currentTier == reforgeTiers.Length - 1 ? currentTier : currentTier + 1; - return rand.Next(reforgeTiers[newTier]); - } - #endregion - /// /// Converts the given ModKeybind into a string for insertion into item tooltips.

/// This allows the user's actual keybind choices to be shown to them in tooltips. @@ -302,9 +52,9 @@ namespace CalamityMod if (Main.dedServ || mhk is null) return ""; - List keys = mhk.GetAssignedKeys(); + List keys = mhk.GetAssignedKeysOrEmpty(); if (keys.Count == 0) - return "[NONE]"; + return GetText("Misc.HotkeyNotBound").Value; else { StringBuilder sb = new StringBuilder(16); @@ -330,6 +80,18 @@ namespace CalamityMod if (line != null) line.Text = line.Text.Replace(replacedKey, newKey); } + /// + /// Shortcut for finding all of a specific string in the tooltip and replacing it with a new string
+ /// Typically used for dynamic tooltip updating. Consider overriding Tooltip or using String.Format for applying constants. + ///
+ /// The tooltip list provided to a ModifyTooltips TML hook. + /// The key to be replaced. + /// The new key. + public static void FindAndReplaceAll(this List tooltips, string replacedKey, string newKey) + { + foreach (TooltipLine line in tooltips) + line.Text = line.Text.Replace(replacedKey, newKey); + } /// /// Shortcut for automatically placing one keybind within a tooltip. Requires the "[KEY]" string to be replaced. @@ -345,6 +107,83 @@ namespace CalamityMod tooltips.FindAndReplace("[KEY]", finalKey); } + /// + /// Shortcut method for adding "You have already consumed this item" tooltip + /// + /// + /// + public static void AddConsumedTooltip(this List tooltips, string tooltipSearchKey = "Tooltip1") + { + TooltipLine line = tooltips.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == tooltipSearchKey); + + if (line != null) + line.Text += "\n" + GetTextValue("Misc.GenericConsumedText"); + } + + public static Color FireDebuffColor => new(253, 107, 2); + public static Color SicknessDebuffColor => new(136, 198, 10); + public static Color WaterDebuffColor => new(105, 147, 255); + public static Color ColdDebuffColor => new(159, 230, 252); + public static Color ElectricDebuffColor => new(255, 245, 0); + public static Color BuffColor => new(255, 105, 237); + public static Color TypelessDebuffColor => new(230, 202, 250); + public static Color VulnHexDebuffColor => new(196, 35, 43); + public static Color MiracleBlightDebuffColor => Main.DiscoColor; + + private static readonly Dictionary> debuffColorWeightsCache = []; + + public static Color GetDebuffTooltipNameColor(int debuffId) + { + var color = TypelessDebuffColor; + + if (debuffId == ModContent.BuffType() || debuffId == ModContent.BuffType()) + { + color = Color.Lerp(VulnHexDebuffColor, FireDebuffColor, (MathF.Sin(Main.GlobalTimeWrappedHourly * 2) + 1) / 4f); + } + else if (debuffId == ModContent.BuffType()) + { + color = MiracleBlightDebuffColor; + } + else if (BuffDatasets.DebuffDataset[debuffId] is not null) + { + if (!debuffColorWeightsCache.TryGetValue(debuffId, out var weights)) + { + weights = + [ + (SicknessDebuffColor, BuffDatasets.DebuffDataset[debuffId].SicknessDebuffScaling), + (FireDebuffColor, BuffDatasets.DebuffDataset[debuffId].HeatDebuffScaling), + (WaterDebuffColor, BuffDatasets.DebuffDataset[debuffId].WaterDebuffScaling), + (ElectricDebuffColor, BuffDatasets.DebuffDataset[debuffId].ElectricDebuffScaling), + (ColdDebuffColor, BuffDatasets.DebuffDataset[debuffId].ColdDebuffScaling), + ]; + } + + float totalWeight = 0; + Vector4 normalColor = new(); + + foreach (var item in weights) + { + totalWeight += item.Item2; + // ReSharper disable once PossiblyImpureMethodCallOnReadonlyVariable + normalColor += item.Item1.ToVector4() * item.Item2; + } + + if (totalWeight < 1) + { + normalColor += TypelessDebuffColor.ToVector4() * (1 - totalWeight); + totalWeight += (1 - totalWeight); + } + + if (totalWeight != 0) + { + normalColor /= totalWeight; + color = new Color(normalColor); + } + } + + return color; + } + private const float WorldInsertionOffset = 15f; /// /// If the given item is outside the world, force it to be within the world boundaries. @@ -439,7 +278,7 @@ namespace CalamityMod public static Rectangle FixSwingHitbox(float hitboxWidth, float hitboxHeight) { Player player = Main.LocalPlayer; - Item item = player.ActiveItem(); + Item item = player.HeldItem; float hitbox_X, hitbox_Y; float mountOffsetY = player.mount.PlayerOffsetHitbox; @@ -643,7 +482,7 @@ namespace CalamityMod showsOver = true; } //Fail if you have potion sickness - if (player.potionDelay > 0 || player.Calamity().potionTimer > 0) + if (player.potionDelay > 0) showsOver = true; if (!showsOver) diff --git a/Utilities/LightingUtils.cs b/Utilities/LightingUtils.cs deleted file mode 100644 index fd7f9d330e..0000000000 --- a/Utilities/LightingUtils.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Waters; -using Microsoft.Xna.Framework; -using Terraria; - -namespace CalamityMod -{ - public static partial class CalamityUtils - { - public static void SunkenSeaWaterLighting(int x, int y, Vector3 waterColor, ref float r, ref float g, ref float b) - { - float tick = (float)Main.timeForVisualEffects; - float brightness = MathHelper.Clamp(0.07f, 0f, 0.07f); - float waveScale1 = tick * 0.028f; - float waveScale2 = tick * 0.1f; - int yScale = -y / 2; - int xScale = x / 15; - float wave1 = tick * 0.024f * -50 + ((-x / 30) + (y / 30)) * 25; - float wave2 = waveScale2 * -10 + ((-xScale) + yScale) * 45; - float wave3 = waveScale1 * -100 + ((x / 7) + (y / 50)) * 25; - float wave4 = tick * 0.15f * 10 + ((x / 3) + yScale) * 45; - float wave5 = waveScale1 * -70 + ((-x / 25) + (-y / 25)) * 20; - float wave6 = waveScale2 * -10 + (xScale + yScale) * 45; - float bigwave = tick * 0.01f * -70 + ((-x / 2) + (-y / 40)) * 5; - float wave1angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave1)); - float wave2angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave2)); - float wave3angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave3)); - float wave4angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave4)); - float wave5angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave5)); - float wave6angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave6)); - float bigwaveangle = 0.55f + 0.80f * MathF.Sin(MathHelper.ToRadians(bigwave)); - float sumofwave = 0.07f + wave1angle + wave2angle + wave3angle + wave4angle + wave5angle + wave6angle + bigwaveangle; - - r = MathHelper.Lerp(r, waterColor.X, sumofwave) * brightness; - g = MathHelper.Lerp(g, waterColor.Y, sumofwave) * brightness; - b = MathHelper.Lerp(b, waterColor.Z, sumofwave) * brightness; - } - } -} diff --git a/Utilities/LocalizationUtils.cs b/Utilities/LocalizationUtils.cs index 07d6a8c75f..10132d352e 100644 --- a/Utilities/LocalizationUtils.cs +++ b/Utilities/LocalizationUtils.cs @@ -1,4 +1,6 @@ -using Terraria.ID; +using CalamityMod.Enums; +using Terraria; +using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -81,6 +83,8 @@ namespace CalamityMod public static string GetTextValueFromModItem(string suffix) where T : ModItem => GetTextFromModItem(ModContent.ItemType(), suffix).ToString(); #region Tooltip Format Helper + public static string EmbedItemIcon(this int itemID) => $"[i:{itemID}] " + GetItemName(itemID); + public static string FramesToSeconds(this int frame) => Round(frame / 60f, "N2"); public static string ToMph(this float velocity) => Round(velocity * 216000f / 42240f, "N0"); @@ -89,6 +93,9 @@ namespace CalamityMod public static string ToRegenPerSecond(this int regen) => Round(regen * 0.5f, "N2"); public static string ToJumpSpeedPercent(this float boost) => Round(boost * 20f, "N2"); + public static string ToStealth(this float stealth) => Round(stealth * 100f, "N0"); + + public static string GetChanceFromDenominator(this int denominator) => ToPercent(1 / (float)denominator); public static string ToPercent(this float percent, string precision = "N1") => Round(percent * 100f, precision); public static string ToPercent(this double percent, string precision = "N1") => Round(percent * 100D, precision); @@ -96,5 +103,25 @@ namespace CalamityMod public static string Round(this float number, string precision = "N4") => float.Parse((number).ToString(precision)).ToString(); public static string Round(this double number, string precision = "N4") => float.Parse((number).ToString(precision)).ToString(); #endregion + + public static string GetArmorSetBonusKey() + { + ModKeybind setBonusKey = CalamityKeybinds.ArmorSetBonusHotKey; + bool hasHotkey = setBonusKey.GetAssignedKeysOrEmpty().Count != 0; + string directionKey = (Main.ReversedUpDownArmorSetBonuses ? Language.GetTextValue("Key.UP") : Language.GetTextValue("Key.DOWN")); + + // Allow both + if (hasHotkey && CalamityClientConfig.Instance.SetBonusDoubleTap == SetBonusDoubleTapOptions.On) + return GetText("Common.BothArmorSetBonusKeys").Format(setBonusKey.TooltipHotkeyString(), directionKey); + // Literally bind nothing (mentions the key name to you) + else if (!hasHotkey && CalamityClientConfig.Instance.SetBonusDoubleTap == SetBonusDoubleTapOptions.Off) + return GetTextValue("Common.NoArmorSetBonusKey"); + // Hotkey only + else if (hasHotkey) + return GetText("Common.ArmorSetBonusKey").Format(setBonusKey.TooltipHotkeyString()); + // Double tap only + else + return GetText("Common.DoubleTapDown").Format(directionKey); + } } } diff --git a/Utilities/LoggerUtils.cs b/Utilities/LoggerUtils.cs new file mode 100644 index 0000000000..6a5ded422c --- /dev/null +++ b/Utilities/LoggerUtils.cs @@ -0,0 +1,19 @@ +using log4net; + +namespace CalamityMod +{ + public static partial class CalamityUtils + { + /// + /// Log out formatted message for IL edit Failure + /// Format: IL edit "name" failed! reason + /// + /// Logger to use + /// Name of the IL Edit + /// Reason why this IL Edit has failed + public static void ILFailure(this ILog logger, string name, string reason) + { + logger.Warn($"IL edit \"{name}\" failed! {reason}"); + } + } +} diff --git a/Utilities/MainThreadedFileSystemWatcher.cs b/Utilities/MainThreadedFileSystemWatcher.cs new file mode 100644 index 0000000000..a605e9e674 --- /dev/null +++ b/Utilities/MainThreadedFileSystemWatcher.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Text.RegularExpressions; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Utilities; + +internal sealed class MainThreadedFileSystemWatcher : IDisposable +{ + public string Path + { + get => _FSW.Path; + set => _FSW.Path = value; + } + + public string Filter + { + get => _FSW.Filter; + set => _FSW.Filter = value; + } + + public Collection Filters + { + get => _FSW.Filters; + } + + public NotifyFilters NotifyFilter + { + get => _FSW.NotifyFilter; + set => _FSW.NotifyFilter = value; + } + + public bool IncludeSubdirectories + { + get => _FSW.IncludeSubdirectories; + set => _FSW.IncludeSubdirectories = value; + } + + public bool EnableRaisingEvents + { + get => _FSW.EnableRaisingEvents; + set => _FSW.EnableRaisingEvents = value; + } + + public Regex FileNameFilter { get; set; } = null; + + public event Action Changed; + public event Action Renamed; + + private Dictionary _ChangedQueue = []; + private Dictionary _RenamedQueue = []; + + private FileSystemWatcher _FSW; + private bool _HasQueueInFrame = false; + private bool _Disposed; + + public MainThreadedFileSystemWatcher() + { + _FSW = new(); + _FSW.Changed += (o, arg) => + { + if (FileNameFilter != null && !FileNameFilter.IsMatch(System.IO.Path.GetFileName(arg.Name))) + return; + + lock (_ChangedQueue) + { + _ChangedQueue[arg.FullPath] = arg; + _HasQueueInFrame = true; + } + }; + + _FSW.Renamed += (o, arg) => + { + if (FileNameFilter != null && !FileNameFilter.IsMatch(System.IO.Path.GetFileName(arg.Name))) + return; + + lock (_RenamedQueue) + { + _RenamedQueue[arg.FullPath] = arg; + _HasQueueInFrame = true; + } + }; + + MainThreadedFileSystemWatcherSystem.Register(this); + } + + private void Dispose(bool disposing) + { + if (!_Disposed) + { + if (disposing) + { + _FSW?.Dispose(); + } + + _FSW = null; + _Disposed = true; + _ChangedQueue?.Clear(); + _RenamedQueue?.Clear(); + _ChangedQueue = null; + _RenamedQueue = null; + _HasQueueInFrame = false; + MainThreadedFileSystemWatcherSystem.Unregister(this); + } + } + + public void Dispose() + { + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + + private sealed class MainThreadedFileSystemWatcherSystem : ILoadable + { + private static MainThreadedFileSystemWatcher[] _Watchers = []; + private static HashSet _WatchersList = []; + + public static void Register(MainThreadedFileSystemWatcher watcher) + { + _WatchersList.Add(watcher); + _Watchers = [.. _WatchersList]; + } + + public static void Unregister(MainThreadedFileSystemWatcher watcher) + { + _WatchersList.Remove(watcher); + _Watchers = [.. _WatchersList]; + } + + void ILoadable.Load(Mod mod) + { + Main.OnTickForThirdPartySoftwareOnly += Tick; + } + + void ILoadable.Unload() + { + Main.OnTickForThirdPartySoftwareOnly -= Tick; + _WatchersList?.Clear(); + _Watchers = []; + } + + private void Tick() + { + foreach (var watcher in _Watchers) + { + if (!watcher._HasQueueInFrame) + continue; + + HandleQueuedEvents(watcher); + } + } + + private static void HandleQueuedEvents(MainThreadedFileSystemWatcher watcher) + { + lock (watcher._ChangedQueue) + { + foreach (var changed in watcher._ChangedQueue.Values) + { + watcher.Changed?.Invoke(changed); + } + watcher._ChangedQueue.Clear(); + } + + lock (watcher._RenamedQueue) + { + foreach (var renamed in watcher._RenamedQueue.Values) + { + watcher.Renamed?.Invoke(renamed); + } + watcher._RenamedQueue.Clear(); + } + + watcher._HasQueueInFrame = false; + } + } +} diff --git a/Utilities/MathematicalUtils.cs b/Utilities/MathematicalUtils.cs index 371d956ac7..b0d1b8e9ff 100644 --- a/Utilities/MathematicalUtils.cs +++ b/Utilities/MathematicalUtils.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.Xml; using Microsoft.Xna.Framework; -using ReLogic.Threading; using Terraria; namespace CalamityMod @@ -225,6 +222,37 @@ namespace CalamityMod /// The input value. public static int DirectionalSign(this float x) => (x > 0f).ToDirectionInt(); + + /// + /// Approximates the derivative of a function at a given point based on a central-difference formula. + /// + /// The function to take the derivative of. + /// The value to evaluate the derivative at. + public static double ApproximateDerivative(this Func fx, double x) + { + double left = fx(x + 1e-7); + double right = fx(x - 1e-7); + return (left - right) * 5e6; + } + + /// + /// Searches for an approximate for a root of a given function. + /// + /// The function to find the root for. + /// The initial guess for what the root could be. + /// The amount of iterations to perform. The higher this is, the more generally accurate the result will be. + public static double IterativelySearchForRoot(Func fx, double initialGuess, int iterations) + { + double result = initialGuess; + for (int i = 0; i < iterations; i++) + { + double derivative = (float)fx.ApproximateDerivative(result); + result -= fx(result) / derivative; + } + + return result; + } + public static List GetIntersectingPointsInLine(Point start, Point end) { List intersectingCells = []; @@ -237,6 +265,9 @@ namespace CalamityMod while (true) { + if (!WorldGen.InWorld(start.X, start.Y)) + break; + // Add the current cell to the list intersectingCells.Add(start); @@ -262,6 +293,16 @@ namespace CalamityMod public static List GetIntersectingPointsInLine(Vector2 start, Vector2 end) => GetIntersectingPointsInLine(start.ToTileCoordinates(), end.ToTileCoordinates()); + /// + /// Rotates a vector towards targetAngle by at most maxChange and normalizes the vector. + /// + public static Vector2 RotateDirectionTowards(this Vector2 vec, float targetAngle, float maxChange) => vec.ToRotation().AngleTowards(targetAngle, maxChange).ToRotationVector2(); + + /// + /// Rotates a vector towards targetAngle by at most maxChange. + /// + public static Vector2 RotateTowards(this Vector2 vec, float targetAngle, float maxChange) => vec.RotateDirectionTowards(targetAngle, maxChange) * vec.Length(); + #region Easings /// /// Gets a value from 0 to 1 and returns an eased value. @@ -399,6 +440,17 @@ namespace CalamityMod } return ratio; } + /// + /// Xyk's version of easing in and out
+ /// Returns an eased version of a 0 - 1 lerp value. + ///
+ /// The 0 - 1 lerp input + /// The intensisty of the easing in. + /// /// The intensisty of the easing out. + public static float EaseInOutExp(float lerpValue, float inPower, float outPower) + { + return (lerpValue < 0.5f ? (float)Math.Pow(Utils.GetLerpValue(0, 0.5f, lerpValue, true), inPower) * 0.5f : 0.5f + (1 - (float)Math.Pow(Utils.GetLerpValue(1, 0.5f, lerpValue, true), outPower)) * 0.5f); + } #endregion } diff --git a/Utilities/MiscUtils.cs b/Utilities/MiscUtils.cs index 89973967e4..d1eab75448 100644 --- a/Utilities/MiscUtils.cs +++ b/Utilities/MiscUtils.cs @@ -1,15 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Tools.ClimateChange; -using CalamityMod.Systems; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Chat; -using Terraria.GameContent.Events; +using Terraria.GameInput; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -18,7 +15,13 @@ namespace CalamityMod { public static partial class CalamityUtils { - public static void DisplayLocalizedText(string key, Color? textColor = null) + /// + /// Broadcast a LocalizedText. This only should be run on Singleplayer or Server. + /// Multiplayer Clients Do NOT ask Server to Broadcast nor the print message locally. + /// + /// LocalizedText key + /// Text Color to use + public static void BroadcastLocalizedText(string key, Color? textColor = null) { // An attempt to bypass the need for a separate method and runtime/compile-time parameter // constraints by using nulls for defaults. @@ -27,10 +30,24 @@ namespace CalamityMod if (Main.netMode == NetmodeID.SinglePlayer) Main.NewText(Language.GetTextValue(key), textColor.Value); - else if (Main.dedServ || Main.netMode == NetmodeID.MultiplayerClient) + else if (Main.dedServ) ChatHelper.BroadcastChatMessage(NetworkText.FromKey(key), textColor.Value); } + /// + /// Broadcast a LocalizedText with formatting. This only should be run on Singleplayer or Server. + /// Multiplayer Clients Do NOT ask Server to Broadcast nor the print message locally. + /// + /// LocalizedText key + /// Text Color to use + public static void BroadcastFormattedText(string key, Color textColor, params object[] args) + { + if (Main.netMode == NetmodeID.SinglePlayer) + Main.NewText(Language.GetOrRegister(key).Format(args), textColor); + else if (Main.dedServ) + ChatHelper.BroadcastChatMessage(NetworkText.FromKey(key, args), textColor); + } + public static int IngredientIndex(this Recipe r, int itemID) { for (int i = 0; i < r.requiredItem.Count; ++i) @@ -123,7 +140,7 @@ namespace CalamityMod /// The base type of the collection. /// The collection. /// The type to search for. - public static bool ContainsType(this IEnumerable collection, Type type) => collection.Any(entry => entry.GetType() == type.GetType()); + public static bool ContainsType(this IEnumerable collection, Type type) => collection.Any(entry => entry.GetType() == type); /// /// Calculates the sound volume and panning for a sound which is played at the specified location in the game world.
@@ -139,7 +156,7 @@ namespace CalamityMod if (soundPos.X == -1f || soundPos.Y == -1f) volume = 1f; - else if (WorldGen.gen || Main.dedServ || Main.dedServ) + else if (WorldGen.gen || Main.dedServ) volume = 0f; else { @@ -203,12 +220,15 @@ namespace CalamityMod list.Add(type); } + public static int ScaleWithDifficulty(this int value) => value * (Main.masterMode ? 3 : Main.expertMode ? 2 : 1); + public static int SecondsToFrames(int seconds) => seconds * 60; - public static int SecondsToFrames(float seconds) => (int)(seconds * 60); + public static int SecondsToFrames(float seconds) => (int)MathF.Round(seconds * 60); public static int MinutesToFrames(int minutes) => minutes * 3600; public static bool WithinBounds(this int index, int cap) => index >= 0 && index < cap; + /// /// Clamps the distance between vectors via normalization. /// /// The starting point. @@ -253,12 +273,12 @@ namespace CalamityMod for (int i = 0; i < originalText.Length; i++) { for (int j = 0; j < 37; j++) - { + { if (TextKeys[j] == originalText[i]) { morseText += MorseKeys[j]; break; - } + } } } @@ -283,5 +303,23 @@ namespace CalamityMod return morseState[(int)((morseState.Count - 1) * completion)]; } + + public static List GetAssignedKeysOrEmpty(this ModKeybind keybind, InputMode mode = InputMode.Keyboard) + { + if (keybind == null) + return []; + + if (Main.dedServ) // Server does not have key assigned + return []; + + try + { + return keybind.GetAssignedKeys(mode); + } + catch + { + return []; + } + } } } diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index cdea134597..bc6f2278bd 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -102,7 +102,7 @@ namespace CalamityMod // Make all Cal NPCs immune to confused unless otherwise specified // Extra note: Clams are not in this list as they initially immune to Confused, but are no longer immune once aggro'd. This is set in their AI(). bool cal = npc.ModNPC != null && npc.ModNPC.Mod.Name.Equals(ModContent.GetInstance().Name); - if (!ConfusionDebuffImmunitiesList.Includes(npc.type) && cal) + if (!CalamityNPCSets.CalamityNPCNotImmuneToConfused[npc.type] && cal) NPCID.Sets.SpecificDebuffImmunity[npc.type][BuffID.Confused] = true; // Sets certain vanilla NPCs and all town NPCs to be immune to most debuffs. @@ -171,8 +171,6 @@ namespace CalamityMod EnemyStats.DebuffImmunities = new SortedDictionary> { { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, @@ -249,9 +247,9 @@ namespace CalamityMod { ModContent.NPCType(), holy }, { ModContent.NPCType(), holy }, - { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, - { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, - { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, + { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, + { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, + { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { ModContent.BuffType() }) }, { ModContent.NPCType(), holy }, { ModContent.NPCType(), holy }, @@ -278,12 +276,8 @@ namespace CalamityMod { ModContent.NPCType(), sulphur }, { ModContent.NPCType(), sulphur }, - { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { BuffID.OnFire, ModContent.BuffType() }) }, @@ -409,9 +403,6 @@ namespace CalamityMod { ModContent.NPCType(), holy }, { ModContent.NPCType(), holy }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { BuffID.Poisoned, BuffID.Venom }) }, diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index c1626cd92a..c360a2d7ea 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using CalamityMod.Balancing; @@ -6,15 +7,15 @@ using CalamityMod.CalPlayer; using CalamityMod.DataStructures; using CalamityMod.Enums; using CalamityMod.Events; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SlimeGod; +using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.Yharon; using CalamityMod.Packets; -using CalamityMod.Projectiles.Boss; +using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -89,6 +90,9 @@ namespace CalamityMod // Generally this doesn't need to be set to true, as bosses will never have collideX or collideY set to true. public bool forceNetUpdate = false; + // Player indexes put into this list will not be considered for targetting. + public HashSet excludedPlayers = []; + public CalamityTargetingParameters() { } @@ -223,7 +227,7 @@ namespace CalamityMod /// The value DR will be set to in normal mode. /// The value DR will be set to in Revegeneance mode. /// The value DR will be set to during the Boss Rush. - public static void DR_NERD(this NPC npc, float normal, float? revengeance = null, float? death = null, float? bossRush = null, bool? customDR = null) + public static void DR_NERD(this NPC npc, float normal, float? revengeance = null, float? death = null, float? bossRush = null) { npc.Calamity().DR = normal; @@ -235,9 +239,6 @@ namespace CalamityMod { npc.Calamity().DR = CalamityWorld.death ? death.Value : revengeance.Value; } - - if (customDR.HasValue) - npc.Calamity().customDR = true; } #endregion @@ -267,8 +268,10 @@ namespace CalamityMod // do not generate rage. if (npc.lifeMax <= BalancingConstants.TinyHealthThreshold || ((npc.defDamage <= BalancingConstants.TinyDamageThreshold && checkDamage) && 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) + + // Exclude NPCs that specified to not be counted as enemy + // This includes: TargetDummy, SuperDummy by Default + if (CalamityNPCSets.DontCountAsEnemy[npc.type]) return false; // Anything else is considered a valid enemy target. @@ -346,19 +349,6 @@ namespace CalamityMod { SyncNPCPosAndRotOnlyPacket.Send(npc); } - - /// - /// Syncs . This exists to sync the Destroyer's lasers so that the telegraphs and segment colors display properly. - /// - /// - public static void SyncDestroyerLaserColor(this NPC npc) - { - // Don't bother attempting to send packets in singleplayer. - if (Main.netMode == NetmodeID.SinglePlayer) - return; - - SyncDestroyerLaserColorPacket.Send(npc); - } #endregion #region Smooth Movement @@ -410,7 +400,7 @@ namespace CalamityMod // change the options on the spot to valid default / intended default parameters. if (options == default) options = new CalamityTargetingParameters(); - + float distance = 0f; // float realDist = 0f; // Defined but not used by vanilla. Commented out here. bool anyTargetAvailable = false; @@ -424,9 +414,10 @@ namespace CalamityMod continue; // ForceSwitch targeting. If the same player from last time is iterated over, just ignore them. + // Player exclusion. If the player is to be excluded, do not consider them. bool sameTargetAsLastTime = p.whoAmI == npc.oldTarget; bool notSinglePlayer = Main.netMode != NetmodeID.SinglePlayer; - if (options.targetType == NPCTargetType.ForceSwitch && notSinglePlayer && sameTargetAsLastTime) + if (notSinglePlayer && (options.excludedPlayers.Contains(p.whoAmI) || (options.targetType == NPCTargetType.ForceSwitch && sameTargetAsLastTime))) continue; // @@ -525,7 +516,7 @@ namespace CalamityMod else { bool shouldFaceTarget = options.faceTarget; - + // Sanitize targeted player index if (npc.target < 0 || npc.target >= Main.maxPlayers) npc.target = 0; @@ -678,7 +669,7 @@ namespace CalamityMod if (angle <= wantedHalfCone) { - angle = wantedHalfCone; + angle = wantedHalfCone; distance = checkDist; // We are within the cone. Now npcs are further narrowed down by distance closestTarget = npc; } @@ -764,9 +755,68 @@ namespace CalamityMod Vector2 launchVel = direction.SafeNormalize(Vector2.UnitX) * strength; float knockbackMult = Utils.Remap(target.knockBackResist, 0, 1, 0.5f, 1f, false); target.velocity = launchVel * (knockbackMult > 1 ? (float)Math.Pow(knockbackMult, 10) : knockbackMult); + target.SyncMotionToServer(); } - target.SyncMotionToServer(); } + + /// + /// Allows grounded NPCs to step up blocks + /// + /// + public static void StepUpBlocks(this NPC npc) + { + Vector2 position = npc.position; + position.X += npc.velocity.X; + int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1)) * npc.direction) / 16f); + int y = (int)((position.Y + (float)npc.height - 1f) / 16f); + + if ((float)(x * 16) >= position.X + (float)npc.width || (float)(x * 16 + 16) <= position.X) + return; + + bool nextTileValid = Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]; + bool aboveTileHalfBlock = Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile; + bool aboveTileHasRoom = Main.tile[x, y - 1].IsHalfBlock && IsPassableTile(x, y - 4); + bool aboveTileEmpty = !Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || aboveTileHasRoom; + bool tile3AbovePassable = !Main.tile[x - npc.direction, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - npc.direction, y - 3].TileType]; + + if ((nextTileValid || aboveTileHalfBlock) && aboveTileEmpty && IsPassableTile(x, y - 2) && IsPassableTile(x, y - 3) && tile3AbovePassable) + { + float npcBottom = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) + { + npcBottom += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + npcBottom -= 8f; + } + if (npcBottom < position.Y + (float)npc.height) + { + float percentageTileRisen = position.Y + (float)npc.height - npcBottom; + if (percentageTileRisen <= 16.1f) + { + npc.gfxOffY += npc.position.Y + (float)npc.height - npcBottom; + npc.position.Y = npcBottom - (float)npc.height; + if (percentageTileRisen < 9f) + { + npc.stepSpeed = 1f; + } + else + { + npc.stepSpeed = 2f; + } + } + } + } + } + + public static bool IsPassableTile(int x, int y) + { + return (!Main.tile[x, y].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x, y].TileType] || Main.tileSolidTop[(int)Main.tile[x, y].TileType]); + } + + public static void Inflict246DebuffsNPC(NPC target, int buff, float timeBase = 2f) { if (Main.rand.NextBool(4)) @@ -821,6 +871,39 @@ namespace CalamityMod npc.position -= npc.netOffset; } + /// + /// Spawns gores. Automatically accounts for multiplayer. + /// + /// The Entity in question. Usuaully used for NPCs but also applicable for other Entities. + /// The name of the gore. + /// How many variants there are, defaults to 1. + /// What number should the variant names start counting from? A default of -1 means the first gore has no number, while the rest start from 2 and increment by 1. + /// Check if the entity in question is a dead NPC. Defaults to true. + public static void SpawnGores(Entity entity, string suffix, int variants = 1, int startFrom = -1, bool deathCheck = true) + { + if (!Main.dedServ) + { + bool isADeadNPC = true; + if (entity is NPC n && deathCheck) + { + if (n.life > 0) + isADeadNPC = false; + } + if (isADeadNPC) + { + for (int i = 0; i < variants; i++) + { + int? idx = startFrom == -1 ? null : startFrom; + if (i > 0) + { + idx = startFrom == -1 ? (i + 1) : (idx + i + 1); + } + Gore.NewGore(entity.GetSource_Death(), entity.position, entity.velocity, CalamityMod.Instance.Find(suffix + idx).Type, 1f); + } + } + } + } + public static NPCShop AddWithCustomValue(this NPCShop shop, int itemType, int customValue, params Condition[] conditions) { var item = new Item(itemType) @@ -897,7 +980,7 @@ namespace CalamityMod // If two are passed in, alternate between them // If more are passed in, each iteration must correspond to a texture Texture2D toUse = bodyTextures.Length == 1 ? bodyTextures[0] : bodyTextures.Length == 2 ? (i % 2 == 0 ? bodyTextures[0] : bodyTextures[1]) : bodyTextures[i - 1]; - spriteBatch.Draw(toUse, npc.position + new Vector2(startX + bodyOffset, MathF.Sin((wormTimer + offset * i) * animationSpeed) * range + startY), toUse.Frame(1, 1, 0, 0), npc.GetAlpha(drawColor), npc.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer + offset * i) * animationSpeed) * MathHelper.PiOver4 * rotationStrength, toUse.Size () / 2, npc.scale, fx, 0f); + spriteBatch.Draw(toUse, npc.position + new Vector2(startX + bodyOffset, MathF.Sin((wormTimer + offset * i) * animationSpeed) * range + startY), toUse.Frame(1, 1, 0, 0), npc.GetAlpha(drawColor), npc.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer + offset * i) * animationSpeed) * MathHelper.PiOver4 * rotationStrength, toUse.Size() / 2, npc.scale, fx, 0f); } // Draw the head spriteBatch.Draw(headTexture, npc.position + new Vector2(startX + headOffset, MathF.Sin((wormTimer - headSpeedOffset) * animationSpeed) * range + startY), npc.frame, npc.GetAlpha(drawColor), npc.rotation - MathHelper.PiOver2 - MathF.Cos((wormTimer - headSpeedOffset) * animationSpeed) * MathHelper.PiOver4 * rotationStrength, new Vector2(headTexture.Width * 0.5f, headTexture.Height), npc.scale, fx, 0f); @@ -907,6 +990,65 @@ namespace CalamityMod public static bool HasSight(this NPC npc, Vector2 target) => Collision.CanHit(npc.Center, 1, 1, target, 1, 1); + + /// + /// Attempts to find a tile of a given type within a given radius + /// + /// The NPC to center it on + /// The tile type to check for + /// The radius of the check area in pixels + /// Whether or not SunkenSeaTileValidity should be used + /// The position of the tile, or null if unsuccessful + public static Vector2? NPCTileDetection(NPC npc, int tileType, float radius, bool usesSunkenSeaValidity = false) + { + Vector2? tileFoundPosition = null; + int? tileIndexFound = null; + for (int i = 0; i < 360 && tileFoundPosition == null; i += 15) + { + var points = GetIntersectingPointsInLine(npc.Center, npc.Center - Vector2.UnitY.RotatedBy(MathHelper.ToRadians(i)) * radius); + for (int j = points.Count - 1; j >= 0; j--) + { + if (Main.tile[points[j]].TileType == tileType) + { + if (usesSunkenSeaValidity) + { + tileIndexFound = j; + } + else + { + tileFoundPosition = points[j].ToWorldCoordinates(); + } + break; + } + } + + if (usesSunkenSeaValidity) + { + if (tileIndexFound == null) + continue; + + for (int k = tileIndexFound.Value; k >= 0; k--) + { + Vector2 worldPos = points[k].ToWorldCoordinates(); + if (npc.HasSight(worldPos) && SunkenSeaNPC.SunkenSeaTileValidity(npc, points[k])) + { + tileFoundPosition = worldPos; + break; + } + } + + tileIndexFound = null; + } + } + + + + if (tileFoundPosition.HasValue) + return tileFoundPosition.Value; + + return null; + } + #region Boss Spawning /// /// Shortcut for the generic boss summon message. @@ -1015,10 +1157,13 @@ namespace CalamityMod { SoundEngine.PlaySound(spawnSound, player.Center); - // SP or SERVER: Spawn Boss Immediately - // This will ensure NPC to be spawned only once on Item.UseItem - if (Main.netMode != NetmodeID.MultiplayerClient) + // This will ensure the NPC is spawned only once on Item.UseItem + if (player.whoAmI != Main.myPlayer) + return null; + + if (Main.netMode == NetmodeID.SinglePlayer) { + // SP: Spawn Boss Immediately int spawnedNPCIdx = NPC.NewNPC(new EntitySource_BossSpawn(target: player), worldX, worldY, npcType, Start: 1); // 200 is invalid Index @@ -1028,16 +1173,13 @@ namespace CalamityMod BossAwakenMessage(spawnedNPCIdx); NPC npc = Main.npc[spawnedNPCIdx]; npc.timeLeft *= 20; - - // Server Exclusive: Sync NPC Data - if (Main.dedServ) - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, spawnedNPCIdx); - } - return npc; } - + else + { + // MP CLIENT: send syncing net message instead + SpawnBossOnPositionPacket.Send(worldX, worldY, npcType, player); + } return null; } diff --git a/Utilities/NetcodeUtils.cs b/Utilities/NetcodeUtils.cs index 1d39b336ec..ec91e2a0ad 100644 --- a/Utilities/NetcodeUtils.cs +++ b/Utilities/NetcodeUtils.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using CalamityMod.CalPlayer; -using CalamityMod.Enums; +using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ModLoader; @@ -14,6 +10,37 @@ namespace CalamityMod { public static partial class CalamityUtils { + #region Optimized RW + public static void WritePackedWorldPosition(this BinaryWriter writer, Vector2 worldPositionX16) => WritePackedWorldPosition(writer, (int)worldPositionX16.X, (int)worldPositionX16.Y); + public static void WritePackedWorldPosition(this BinaryWriter writer, int worldX, int worldY) + { + int tileX = Math.DivRem(worldX, 16, out int remX); + int tileY = Math.DivRem(worldY, 16, out int remY); + byte remByte = (byte)(remX << 4 | remY); + writer.Write((ushort)Math.Clamp(tileX, 0, ushort.MaxValue)); // If you actually have world size above 65535 tiles in axis, Good luck on that + writer.Write((ushort)Math.Clamp(tileY, 0, ushort.MaxValue)); + writer.Write(remByte); + } + + public static Vector2 ReadPackedWorldPosition(this BinaryReader reader) + { + reader.ReadPackedWorldPosition(out var worldX, out var worldY); + return new Vector2(worldX, worldY); + } + + public static void ReadPackedWorldPosition(this BinaryReader reader, out int worldX, out int worldY) + { + var tileX = (int)reader.ReadUInt16(); + var tileY = (int)reader.ReadUInt16(); + var remByte = reader.ReadByte(); + var remX = remByte >> 4; + var remY = remByte & 0b1111; + worldX = (tileX * 16) + remX; + worldY = (tileY * 16) + remY; + } + + #endregion + #region TileEntity RW public static void WriteTileEntityID(this BinaryWriter writer, TileEntity tileEntity) { @@ -63,7 +90,7 @@ namespace CalamityMod public static Player ReadPlayer(this BinaryReader reader, bool nullOnInactive = true) { int index = reader.ReadByte(); - + if (index >= Main.maxPlayers) return null; diff --git a/Utilities/PathfindingUtils.cs b/Utilities/PathfindingUtils.cs index f8af93a82c..d173dcac16 100644 --- a/Utilities/PathfindingUtils.cs +++ b/Utilities/PathfindingUtils.cs @@ -1,462 +1,14 @@ using System; using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Terraria; -using static CalamityMod.CalamityUtils; namespace CalamityMod { - #region Pathfinding Parameters - public readonly struct PathfindingParameters - { - internal static readonly Func DefaultTileValidity = point => true; - internal static readonly Func DefaultDistanceFunction = OctileDistance; - internal static readonly Func DefaultHeuristic = OctileDistance; - - internal readonly Vector2 Start; - internal readonly Vector2 End; - internal readonly Func TileValidity; - internal readonly Func DistanceFunction; - internal readonly Func Heuristic; - - public PathfindingParameters( - Vector2 start, - Vector2 end, - Func tileValidity = null, - Func distanceFunction = null, - Func heuristic = null) - { - Start = start; - End = end; - TileValidity = tileValidity; - DistanceFunction = distanceFunction; - Heuristic = heuristic; - } - } - #endregion - - #region Pathfinding Manager - /// - /// Creates a new PathfindingManager for the selected entity.
- /// Entities should only ever need one PathfindingManager for their lifetime, but more can be created. - ///
- /// The entity to pathfind for. - public class PathfindingManager(Entity e) - { - public List Path { get => lastSuccessfulTask?.Result ?? []; } - - /// - /// The entity which this PathfindingManager manages. This cannot be changed after creation. - /// - internal readonly Entity entity = e; - - /// - /// The acceleration this PathfindingManager will impart to its Entity when making it follow a found path.
- /// This has no impact on the Entity's other behaviors, AI, etc. - ///
- internal float Acceleration { get; set; } = 0.2f; - - /// - /// The maximum speed this PathfindingManager allow its Entity to move at when making it follow a found path.
- /// This has no impact on the Entity's other behaviors, AI, etc. - ///
- internal float MaxSpeed { get; set; } = 4f; - - /// - /// The minimum distance this PathdingManager requires its Entity to reach from its target point before the point is marked as "reached".
- /// This has no impact on the Entity's other behaviors, AI, etc. - ///
- internal float MinimumPointDistance { get; set; } = 48f; - - /// - /// The last completed pathfinding task that this manager has performed.
- /// This is kept in place so that the entity may continue to follow its last successful path while calculating a new one.
- ///
- /// This task will always be in a Completed state with a valid Result. - ///
- private PathfindingTask lastSuccessfulTask; - - /// - /// Represents the working task for calculating this entity's complex path.
- ///
- /// Accessing before execution has completed will result in the calling thread being blocked until execution is complete. - ///
- private PathfindingTask currentTask; - - /// - /// You may override the path-following behavior imposed on the Entity by the PathfindingManager by providing a Func here. - ///

- /// This Func should return when the entity has reached its target point, and otherwise.
- ///
- public Func CustomFollowPath { get; set; } - - /// - /// You may override the idling behavior imposed on the Entity by the PathfindingManager by providing an Action here. - ///

- /// This Action has no parameters and no return value, and can do basically anything you want. - ///
- /// It will usually only run for a frame or two while the PathfindingManager is finding the next path to take. - ///
- public Action CustomIdleBehavior { get; set; } - - /// - /// Finds a path based on the specified parameters and assigns it to this manager's entity.
- /// This method does not force the entity to begin following the path - it only locates a new path. - ///
- public void FindPath(PathfindingParameters parameters, bool forceNewTask = true) - { - var potentialNewTask = new PathfindingTask(parameters); - - // Case 1: No current pathfinding task. - // Set the current task to be the potential new task. - if (currentTask is null) - { - currentTask = potentialNewTask; - currentTask.Run(); - } - - // Case 2: Current task exists and is currently running. - // Make the Entity idle and continue to await results. - if (currentTask.Running) - { - // Case 2A: We don't care about the previous pathfinding task. We have changed our goals. - // In order to trigger this behavior, you must set forceNewTask to true, and provide a different end goal position. - bool sameEndPosition = parameters.End.ToTileCoordinates() == currentTask.work.End.Position; - bool forceNewPathAttempt = forceNewTask && !sameEndPosition; - - if (forceNewPathAttempt) - { - currentTask = potentialNewTask; - currentTask.Run(); - } - - // Regardles of whether a new pathing execution is forced, the entity will continue to behave based on any previous successful pathing. - // Its calculations have not finished. - return; - } - - // Case 3: Current task exists, but is not currently running. - // There are two reasons why this can be the case. - bool previousTaskHadNoResult = currentTask.Result is null; - bool previousTaskPathFollowed = (currentTask.Result?.Count ?? -1) == 0; - // The third case is that you are forcing it to start a new task, either to the same or a new destination. - - // Regardless of which reason the pathfinding has ended, start the new task. - if (previousTaskHadNoResult || previousTaskPathFollowed || forceNewTask) - { - currentTask = potentialNewTask; - currentTask.Run(); - return; - } - - // Case 4: "Your paths found." - // The pathfinding task has completed its execution and a valid path has been found. - // Lock in that successful pathfinding task so the entity may consume its results. - lastSuccessfulTask = currentTask; - } - - /// - /// Glue code to cause the Entity to either follow its last successful path, or idle. - /// - public void PathfindingBehavior() - { - if (lastSuccessfulTask is null) - { - IdleBehavior(); - return; - } - - Vector2 nextPoint = lastSuccessfulTask.Result[0]; - - // If that point is reached, it is removed from the list of points to follow. - bool nextPointReached = FollowPath(nextPoint); - if (nextPointReached) - lastSuccessfulTask.Result.RemoveAt(0); - - // If the previous successful found path has been followed to its endpoint, delete the task. - if (lastSuccessfulTask.Result.Count == 0) - lastSuccessfulTask = null; - } - - /// - /// Performs appropriate "path-finding behavior" for the Entity this PathfindingManager is attached to.
- /// This method is intended to be called every frame that you want the Entity to obey its pathfinding logic. - ///
- public void DoPathfinding(PathfindingParameters parameters, bool forceNewTask = false) - { - FindPath(parameters, forceNewTask); - PathfindingBehavior(); - } - - private bool DefaultFollowPath(Vector2 nextPoint) - { - // Accelerate to the target point. - entity.velocity += (nextPoint - entity.Center).SafeNormalize(Vector2.Zero) * Acceleration; - - // Cap the speed if MaxSpeed has been surpassed. - if (entity.velocity.LengthSquared() > MaxSpeed * MaxSpeed) - entity.velocity = entity.velocity.SafeNormalize(Vector2.UnitY) * MaxSpeed; - - // If the entity is within 48 pixels of its target point, consider the point reached. - if (Vector2.DistanceSquared(entity.Center, nextPoint) < MinimumPointDistance * MinimumPointDistance) - return true; - - // Otherwise, continue following. - return false; - } - - /// - /// Defines how this entity should move to the next point. Contains a default implementation with basic acceleration towards the next point.
- /// This method should return when the entity has reached its target point, and otherwise.
- ///
- /// The target point is specified by - usually index 0 in the task result. - ///

- /// The behavior of this function can be completely overridden by providing a CustomFollowPath Func. - ///
- /// The next point in the path that this PathfindingManager has made. - /// Whether or not the destination has been reached. - public bool FollowPath(Vector2 nextPoint) => CustomFollowPath?.Invoke(nextPoint) ?? DefaultFollowPath(nextPoint); - - private static readonly float DefaultSlowdown = 0.95f; - private void DefaultIdleBehavior() => entity.velocity *= DefaultSlowdown; - - /// - /// Defines how this entity should behave while there is no current path to follow.
- /// By default, decelerates to a stop using the DefaultSlowdown value.
- /// This behavior will usually only run for a frame or two while the PathfindingManager is finding the next path to take. - ///
- public void IdleBehavior() - { - if (CustomIdleBehavior is not null) - CustomIdleBehavior(); - else - DefaultIdleBehavior(); - } - - public void ClearResults() - { - currentTask = null; - lastSuccessfulTask = null; - } - - #region Pathfinding Task - /// - /// Represents a task for calculating a complex path.
- /// Allows for synchronous access to an asynchronous execution state, while still providing blocking access where needed. - ///
- private class PathfindingTask(PathfindingParameters parameters) - { - /// - /// The result of this pathfinding task. - /// - internal List Result { get => _task.Task.Result; } - - /// - /// Whether this pathfinding task has completed running. - /// - internal bool Ready { get; private set; } = false; - - /// - /// Whether this pathfinding task is still currently running. - /// - internal bool Running { get; private set; } = false; - - // Interal task representation of the work. - internal readonly TaskCompletionSource> _task = new(); - - // Internal containing object for the actual work. - internal readonly PathfindingWork work = new(parameters); - - /// - /// Begins execution of this pathfinding task on a background thread. - /// - internal void Run() - { - Running = true; - - ThreadPool.QueueUserWorkItem((pathfindingTask) => - { - var task = pathfindingTask as PathfindingTask; - task._task.TrySetResult(task.work.CalculatePath()); - - task.Ready = true; - task.Running = false; - }, - this); - } - } - #endregion - - #region Pathfinding Work Record - /// - /// Represents the working computation for a . - /// - /// - /// - /// Has 2 constructors. One option provides the start and end positions as , and the other one as . - /// - /// - /// This record contains the start and end nodes, along with functions for tile validity, distance calculation, and heuristic estimation. - /// - /// - /// - : A function that checks if a tile at a given point is valid for traversal. If not provided, all non-solid tiles are considered valid.
- /// - : A function that calculates the distance between two points. Defaults to .
- /// - : A function that estimates the cost from a given point to the end point. Defaults to .
- ///
- ///
- private record PathfindingWork(PathfindingNode Start, PathfindingNode End, Func TileValidity, Func DistanceFunction, Func Heuristic) - { - public PathfindingWork( - Point start, - Point end, - float minimalPointDistance, - Func tileValidity = null, - Func distanceFunction = null, - Func heuristic = null) : this( - new PathfindingNode(start), - new PathfindingNode(end), - tileValidity ?? PathfindingParameters.DefaultTileValidity, - distanceFunction ?? PathfindingParameters.DefaultDistanceFunction, - heuristic ?? PathfindingParameters.DefaultHeuristic - ) - { - } - - public PathfindingWork( - PathfindingParameters p) : this( - new PathfindingNode(p.Start.ToTileCoordinates()), - new PathfindingNode(p.End.ToTileCoordinates()), - p.TileValidity ?? PathfindingParameters.DefaultTileValidity, - p.DistanceFunction ?? PathfindingParameters.DefaultDistanceFunction, - p.Heuristic ?? PathfindingParameters.DefaultHeuristic - ) - { - } - - /// - /// Calculates a path from the start to the end position using the A* pathfinding algorithm. - /// - /// - /// - /// A list of positions representing the path from start to end, or if no path is found. - /// - internal List CalculatePath() - { - if (Main.tile[End.Position].IsTileSolid()) - return null; - - var openSet = new List(); - var closedSet = new HashSet(); - openSet.Add(Start); - - while (openSet.Count > 0) - { - // Get the node with the lowest F value. - var current = openSet[0]; - for (int i = 1; i < openSet.Count; i++) - { - if (openSet[i].F < current.F || (openSet[i].F == current.F && openSet[i].H < current.H)) - current = openSet[i]; - } - - openSet.Remove(current); - closedSet.Add(current); - - // Check if we've reached the goal. - if (current.Position == End.Position) - return current.ReconstructPath(); - - // Generate neighbors. - foreach (var neighbor in current.GetNeighbors()) - { - if (closedSet.Contains(neighbor) || Main.tile[neighbor.Position].IsTileSolid() || !TileValidity.Invoke(neighbor.Position)) - continue; - - float tentativeG = current.G + DistanceFunction.Invoke(current.Position, neighbor.Position); - - if (!openSet.Contains(neighbor) || tentativeG < neighbor.G) - { - neighbor.Parent = current; - neighbor.G = tentativeG; - neighbor.H = Heuristic.Invoke(neighbor.Position, End.Position); - - if (!openSet.Contains(neighbor)) - openSet.Add(neighbor); - } - } - } - - return null; // No path found. - } - } - #endregion - - #region Pathfinding Node - /// - /// Represents a node in a pathfinding algorithm, containing position, cost, and parent information. - /// - private class PathfindingNode(Point position) - { - internal Point Position { get; set; } = position; - internal float G { get; set; } // Cost from start to this node. - internal float H { get; set; } // Heuristic cost to goal. - internal float F => G + H; // Total cost. - internal PathfindingNode Parent { get; set; } - - public override bool Equals(object obj) - { - if (obj is PathfindingNode other) - return Position == other.Position; - return false; - } - - public override int GetHashCode() => Position.GetHashCode(); - - internal List GetNeighbors() - { - var neighbors = new List(Directions.Count); - - int nodeX = Position.X; - int nodeY = Position.Y; - - foreach (var direction in Directions) - { - int newX = nodeX + (int)direction.X; - int newY = nodeY + (int)direction.Y; - - if (WorldGen.InWorld(newX, newY)) - neighbors.Add(new PathfindingNode(new Point(newX, newY))); - } - - return neighbors; - } - - internal List ReconstructPath() - { - var pathStack = new Stack(); - var node = this; - - while (node != null) - { - pathStack.Push(node.Position.ToWorldCoordinates()); - node = node.Parent; - } - - var path = new List(pathStack.Count); - path.AddRange(pathStack); - - return path; - } - } - #endregion - } - #endregion - public static partial class CalamityUtils { #region Heuristic Functions + public static float TaxicabDistance(Point a, Point b) => MathF.Abs(a.X - b.X) + MathF.Abs(a.Y - b.Y); public static float EuclideanDistance(Point a, Point b) @@ -474,6 +26,7 @@ namespace CalamityMod float dy = MathF.Abs(a.Y - b.Y); return dx + dy - 0.586f * MathF.Min(dx, dy); } + #endregion /// @@ -507,7 +60,7 @@ namespace CalamityMod Rectangle hitbox = entity.Hitbox; hitbox.Location = new Point(position.X - hitbox.Width / 2, position.Y - hitbox.Height / 2); hitbox.Inflate(fluffX, fluffY); - + int startX = (int)MathF.Floor(hitbox.Left / 16); int endX = (int)Math.Floor((hitbox.Right - float.Epsilon) / 16); int startY = (int)MathF.Floor(hitbox.Top / 16); diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index f241eb3142..20c261a77e 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using CalamityMod.Balancing; using CalamityMod.CalPlayer; using CalamityMod.Cooldowns; @@ -9,7 +8,7 @@ using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor; -using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Armor.GodSlayer; using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -136,7 +135,7 @@ namespace CalamityMod return ret; } - public static float GetRangedAmmoCostReduction(this Player player) + public static float GetAmmoCostReduction(this Player player) { // Tally up all possible vanilla effects. float vanillaCost = player.ammoBox ? 0.8f : 1f; @@ -148,7 +147,7 @@ namespace CalamityMod vanillaCost *= 0.75f; // Account for Calamity effects. - return vanillaCost * player.Calamity().rangedAmmoCost; + return vanillaCost * player.Calamity().ammoCost; } public static float GetStandingStealthRegen(this Player player) @@ -169,105 +168,81 @@ namespace CalamityMod /// Calculates and returns the player's total light strength. This is used for Abyss darkness, among other things.
/// The Stat Meter also reports this stat. ///
- /// The player's total light strength. - public static int GetCurrentAbyssLightLevel(this Player player) + public static void SetAbyssLightLevels(this Player player) { CalamityPlayer mp = player.Calamity(); - int light = mp.externalAbyssLight; bool underwater = player.IsUnderwater(); bool miningHelmet = player.head == ArmorIDs.Head.MiningHelmet || player.head == ArmorIDs.Head.UltraBrightHelmet; - - // The campfire bonus does not apply while in the Abyss. - if (!mp.ZoneAbyss && (player.HasBuff(BuffID.Campfire) || Main.SceneMetrics.HasCampfire)) - light += 1; - if (mp.camper) // inherits Campfire so it is +2 in practice - light += 1; + //Things that include darkness multipliers + if (mp.camper) + mp.abyssPlayerGlowMultiplier += Utils.Remap(player.velocity.Length(), 0, 5, 1, 0); if (miningHelmet) - light += 1; - if (player.hasMagiluminescence) - light += 1; - if (player.lightOrb) - light += 1; - if (player.crimsonHeart) - light += 1; - if (player.magicLantern) - light += 1; + mp.abyssPlayerGlowMultiplier += 0.2f; + if (player.nightVision) + mp.abyssDarkness -= 0.4f; if (mp.giantPearl) - light += 1; - if (mp.radiator) - light += 1; - if (mp.bendyPet) - light += 1; - if (mp.sparks) - light += 1; - if (mp.thiefsDime) - light += 1; + mp.abyssPlayerGlowMultiplier += 0.2f; if (mp.fathomSwarmerVisage) - light += 1; + { + mp.abyssDarkness -= 0.2f; + mp.abyssPlayerGlowMultiplier += 0.2f; + mp.abyssFlashlightWidthMultiplier += 0.5f; + } if (mp.aquaticHeart) - light += 1; - if (mp.purity) // does not stack with downgrades - light += 2; - else if (mp.rOoze || mp.aAmpoule) // the two "yellow lights" do not stack with each other - light += 1; - if (mp.aquaticEmblem && underwater) - light += 1; - if (player.arcticDivingGear && underwater) // inherited by abyssal diving gear/suit. jellyfish necklace is inherited so arctic diving gear is really +2 - light += 1; + mp.abyssDarkness -= 0.1f; if (mp.jellyfishNecklace && underwater) // inherited by jellyfish diving gear and higher - light += 1; + mp.abyssPlayerGlowMultiplier += 0.2f; if (mp.reaverExplore) - light += 2; - if (mp.lumenousAmulet && underwater) - light += 2; + { + mp.abyssDarkness -= 0.2f; + mp.abyssPlayerGlowMultiplier += 0.2f; + mp.abyssFlashlightWidthMultiplier += 0.5f; + } if (mp.shine) - light += 2; - if (mp.blazingCore) - light += 2; - if (player.redFairy || player.greenFairy || player.blueFairy) - light += 2; - if (mp.babyGhostBell) - light += underwater ? 2 : 1; - if (player.petFlagDD2Ghost) - light += 2; - if (mp.sirenPet) - light += underwater ? 3 : 1; - if (player.petFlagPumpkingPet) - light += 3; - if (player.petFlagGolemPet) - light += 3; - if (player.petFlagFairyQueenPet) - light += 3; - if (player.wisp) - light += 3; - if (player.suspiciouslookingTentacle) - light += 3; + mp.abyssPlayerGlowMultiplier += 0.2f; + if (mp.babyGhostBell && underwater) + mp.abyssDarkness -= 0.1f; + if (mp.sirenPet && underwater) + mp.abyssDarkness -= 0.2f; if (mp.littleLightPet) - light += 3; - if (mp.profanedCrystalBuffs && !mp.ZoneAbyss) - light += (Main.dayTime || player.lavaWet) ? 2 : 1; // not sure how you'd be in lava in the abyss but go ham I guess - return light; + mp.abyssDarkness -= 0.4f; } /// - /// Directly retrieves the best pickaxe power of the player. + /// Retrieves the best pickaxe item in the player's inventory.

+ /// May return if the player has no pickaxes. ///
- /// - /// - public static int GetBestPickPower(this Player player) + /// The player whose best pickaxe is being queried. + /// An item with a nonzero pickaxe power, or . + internal static Item GetBestPick(this Player player) { - int highestPickPower = 35; //35% if you have no pickaxes. + int bestPickPower = 0; + Item bestPick = null; for (int item = 0; item < Main.InventorySlotsTotal; item++) { if (player.inventory[item].pick <= 0) continue; - if (player.inventory[item].pick > highestPickPower) - highestPickPower = player.inventory[item].pick; + if (player.inventory[item].pick > bestPickPower) + { + bestPick = player.inventory[item]; + bestPickPower = bestPick.pick; + } } - return highestPickPower; + return bestPick; } + + // Pickaxe power minimum is decided by the Copper Pickaxe. + private static int _minimumPickPower => ContentSamples.ItemsByType[ItemID.CopperPickaxe].pick; + + /// + /// Retrieves the best pickaxe power of the player.

+ /// Always returns a minimum pickaxe power equivalent to the Copper Pickaxe. + ///
+ /// The player whose pickaxe strength is being queried. + /// A pickaxe power value, minimum 35. + public static int GetBestPickPower(this Player player) => player.GetBestPick()?.pick ?? _minimumPickPower; #endregion #region Movement and Controls @@ -317,6 +292,19 @@ namespace CalamityMod } return ConditionMet; } + + /// + /// Disables the default wing flap sound from vanilla; this is to stop custom wings playing this sound when they shouldnt + /// This must be called each update (eg, in the wings item UpdateAccessory method) + /// + /// The Player to disable the sound on + public static void DisableWingFlapSound(this Player player) + { + // vanilla plays a flap sound for all wings barring a few hardcoded exceptions + // the flapSound flag is used to see if the sound *has been* played, so we set it to true here to prevent it from playing + player.flapSound = true; + } + #endregion #region Location and Biomes @@ -338,8 +326,6 @@ namespace CalamityMod public static bool InSulphur(this Player player) => player.Calamity().ZoneSulphur; - public static bool InFloralParadise(this Player player) => player.Calamity().ZoneFloralParadise; - public static bool InAstral(this Player player, int biome = 0) //1 is above ground, 2 is underground, 3 is desert { switch (biome) @@ -384,11 +370,11 @@ namespace CalamityMod // TODO -- Wrong. This should return false for weapons which emit true melee projectiles e.g. Arkhalis public static bool HoldingProjectileMeleeWeapon(this Player player) { - Item item = player.ActiveItem(); + Item item = player.HeldItem; return item.CountsAsClass() && item.shoot != ProjectileID.None; } - public static bool HoldingTrueMeleeWeapon(this Player player) => player.ActiveItem().IsTrueMelee(); + public static bool HoldingTrueMeleeWeapon(this Player player) => player.HeldItem.IsTrueMelee(); public static bool InventoryHas(this Player player, params int[] items) { @@ -438,10 +424,8 @@ namespace CalamityMod CalamityPlayer modPlayer = player.Calamity(); int extraIFrames = 0; - if (modPlayer.godSlayerThrowing && hurtInfo.Damage > 80) - extraIFrames += 30; - if (modPlayer.statigelSet && hurtInfo.Damage > 100) - extraIFrames += 30; + if (modPlayer.godSlayerThrowing && hurtInfo.Damage > GodSlayerHeadRogue.SetBonusHurtDamageThreshold) + extraIFrames += GodSlayerHeadRogue.ExtraIFrames; // Deific Amulet provides 10 to 40 bonus immunity frames when you get hit which scale with your missing health. // If you only take 1 damage, you get 5 iframes. @@ -463,15 +447,6 @@ namespace CalamityMod // This stacks with the above Deific Amulet effect if (modPlayer.rampartOfDeities && hurtInfo.Damage > 200) extraIFrames += 30; - - if (modPlayer.cirrusVodka) - { - if (hurtInfo.Damage == 1) - extraIFrames += 5; - else - extraIFrames += 10; - } - return extraIFrames; } @@ -604,21 +579,118 @@ namespace CalamityMod player.hurtCooldowns[i] = 0; } - private static readonly FieldInfo hurtInfoDamageField = typeof(HurtInfo).GetField("_damage", BindingFlags.Instance | BindingFlags.NonPublic); - /// /// Lifted from Fargo's. Sets the damage and knockback of an incoming hit to zero, making it not affect the player. /// /// The HurtInfo instance to nullify. public static void NullifyHit(ref this HurtInfo hurtInfo) { - object unboxedHurtInfo = hurtInfo; - hurtInfoDamageField.SetValue(unboxedHurtInfo, 0); - hurtInfo = (Player.HurtInfo)unboxedHurtInfo; + hurtInfo._damage = 0; hurtInfo.Knockback = 0; } #endregion + #region Player Healing and Lifesteal + /// + /// Directly provides lifesteal to the player. + /// This obeys the spawn behaviour of lifesteal and incurs cooldown. + /// + /// The player being healed. + /// The target being hit. Input null if there is none. + /// The amount of life being healed. + /// The multiplier to the rate of lifesteal. Increase above 1 to make it weaker and below 1 to make it stronger. + public static void DoLifestealDirect(this Player player, NPC target, int amount, float cooldownMultiplier = 1f) + { + // NPC limitations: disallow if target is not an enemy or deliberately disallowed from lifestealing + if (target is not null && (!target.IsAnEnemy(false) || !target.canGhostHeal)) + return; + + // Limit the amount of heal to the player's max health + amount = Math.Min(amount, player.statLifeMax2 - player.statLife); + + // As well as the physical cap to how much HP can be healed + amount = Math.Min(amount, BalancingConstants.LifeStealCap); + + // Player limitations: disallow if lifesteal variable reaches 0 or lower or Moon Bite is active + if (amount <= 0 || player.lifeSteal <= 0f || player.moonLeech) + return; + + // Grant lifesteal and subtract from the variable accordingly + player.lifeSteal -= amount * cooldownMultiplier; + player.HealPlayer(amount); + } + + /// + /// Spawns a projectile which grants healing to the player on contact. + /// This obeys the spawn behaviour of lifesteal and incurs cooldown. + /// This applies as a projectile on-hit effect. Use DoLifestealDirect for direct lifestealing. + /// + /// The player being healed. + /// The target being hit. Input null if there is none. + /// The source projectile performing this heal. + /// The type of healing projectile spawned. + /// The amount of life to heal. + /// The multiplier to the rate of lifesteal. Increase above 1 to make it weaker and below 1 to make it stronger. + /// Whether or not the heal is given to the player on the team with lowest HP. False by default. + /// The distance the projectile has to be from the player to direct the heal to when sharing. Default of 3000f (187.5 tiles) + public static void SpawnLifeStealProjectile(this Player player, NPC target, Projectile projSource, int projType, int amount, float cooldownMultiplier = 1f, bool shared = false, float distanceRequired = 3000f) + { + // NPC limitations: disallow if target is not an enemy or deliberately disallowed from lifestealing + if (target is not null && (!target.IsAnEnemy(false) || !target.canGhostHeal)) + return; + + int lowestHealthCheck = player.statLifeMax2 - player.statLife; + int targetPlayer = player.whoAmI; + if (shared) + { + foreach (Player otherPlayer in Main.ActivePlayers) + { + if (!otherPlayer.dead && ((!player.hostile && !otherPlayer.hostile) || player.team == otherPlayer.team)) + { + float playerDist = Vector2.Distance(projSource.Center, otherPlayer.Center); + if (playerDist < distanceRequired && (otherPlayer.statLifeMax2 - otherPlayer.statLife) > lowestHealthCheck) + { + lowestHealthCheck = otherPlayer.statLifeMax2 - otherPlayer.statLife; + targetPlayer = otherPlayer.whoAmI; + } + } + } + } + + // Limit the amount of heal to the target player's max health + amount = Math.Min(amount, lowestHealthCheck); + + // As well as the physical cap to how much HP can be healed + amount = Math.Min(amount, BalancingConstants.LifeStealCap); + + // Player limitations: disallow if lifesteal variable reaches 0 or lower or Moon Bite is active + // This is performed on the player who DOES the lifesteal, and not the recipient + if (amount <= 0 || player.lifeSteal <= 0f || player.moonLeech) + return; + + // Grant lifesteal and subtract from the variable accordingly + player.lifeSteal -= amount * cooldownMultiplier; + if (projSource.owner == Main.myPlayer) + Projectile.NewProjectile(projSource.GetSource_FromThis(), projSource.Center, Vector2.Zero, projType, 0, 0f, projSource.owner, targetPlayer, amount); + } + + /// + /// A short method that heals the player. + /// All direct heals in Calamity should use this. + /// + /// The player being healed. + /// The amount of life being healed. + /// Whether the heal CombatText should be displayed, and whether it should be synced. Displays and syncs by default. + public static void HealPlayer(this Player player, int amount, HealTextType healTextType = HealTextType.Broadcast) + { + player.statLife += amount; + if (player.statLife > player.statLifeMax2) + player.statLife = player.statLifeMax2; + if (healTextType != HealTextType.None) + player.HealEffect(amount, healTextType == HealTextType.Broadcast); + } + #endregion + #region Rage and Adrenaline /// /// Returns the damage multiplier Adrenaline Mode provides for the given player. @@ -887,7 +959,7 @@ namespace CalamityMod public static Vector2 ClampedMouseWorld(this Player player) { Vector2 mouseWorld = player.Calamity().mouseWorld; - + // Clamp each axis mouseWorld.X = mouseWorld.X >= player.MountedCenter.X ? MathF.Min(mouseWorld.X, player.MountedCenter.X + 960f) : MathF.Max(mouseWorld.X, player.MountedCenter.X - 960f); mouseWorld.Y = mouseWorld.Y >= player.MountedCenter.Y ? MathF.Min(mouseWorld.Y, player.MountedCenter.Y + 540f) : MathF.Max(mouseWorld.Y, player.MountedCenter.Y - 540f); @@ -926,10 +998,10 @@ namespace CalamityMod item.CountsAsClass() ); - bool heldItemIsTool = (item.pick > 0 || item.axe > 0 || item.hammer > 0) && !BlacklistedWeaponsWithToolPowerList.Includes(item.type); + bool heldItemIsTool = (item.pick > 0 || item.axe > 0 || item.hammer > 0) && !CalamityItemSets.WeaponWithToolPowerAffectedBySummonPenalty[item.type]; bool heldItemCanBeUsed = item.useStyle != ItemUseStyleID.None; bool heldItemIsAccessoryOrAmmo = item.accessory || item.ammo != AmmoID.None; - bool heldItemIsExcludedByModCall = DisabledSummonerNerfItemList.Includes(item.type); + bool heldItemIsExcludedByModCall = CalamityItemSets.ItemWhichDisablesSummonerNerf[item.type]; if (heldItemIsClassedWeapon && heldItemCanBeUsed && !heldItemIsTool && !heldItemIsAccessoryOrAmmo && !heldItemIsExcludedByModCall) return true; @@ -937,23 +1009,6 @@ namespace CalamityMod return false; } - - /// - /// A short method that heals the player. - /// All direct heals in Calamity should use this. - /// - /// The player being healed. - /// The amount of life being healed. - /// Whether the heal CombatText should be displayed, and whether it should be synced. Displays and syncs by default. - public static void HealPlayer(this Player player, int amount, HealTextType healTextType = HealTextType.Broadcast) - { - player.statLife += amount; - if (player.statLife > player.statLifeMax2) - player.statLife = player.statLifeMax2; - if (healTextType != HealTextType.None) - player.HealEffect(amount, healTextType == HealTextType.Broadcast); - } - /// /// Makes the given player send the given packet to all appropriate receivers.
/// If server is false, the packet is sent only to the multiplayer host.
diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index 5d09f8fb37..7ced2c3c3b 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Projectiles.Magic; -using CalamityMod.Projectiles.Melee.Yoyos; -using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -38,9 +36,22 @@ namespace CalamityMod return false; } + public static bool AnyOwnedProjectiles(int projectileID, int ownerID) + { + // Efficiently loop through all projectiles, using a specially designed continue continue that attempts to minimize the amount of OR + // checks per iteration. + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type != projectileID || p.owner != ownerID) + continue; + + return true; + } + + return false; + } public static int CountProjectiles(int projectileID) => Main.projectile.Count(proj => proj.type == projectileID && proj.active); - public static int CountOwnedProjectiles(int projectileID, int ownerID) => Main.projectile.Count(proj => proj.active && proj.type == projectileID && proj.owner == ownerID); public static int CountHookProj() => Main.projectile.Count(proj => Main.projHook[proj.type] && proj.ai[0] == 2f && proj.active && proj.owner == Main.myPlayer); @@ -107,7 +118,51 @@ namespace CalamityMod public static void ExpandHitboxBy(this Projectile projectile, Vector2 newSize) => projectile.ExpandHitboxBy((int)newSize.X, (int)newSize.Y); public static void ExpandHitboxBy(this Projectile projectile, float expandRatio) => projectile.ExpandHitboxBy((int)(projectile.width * expandRatio), (int)(projectile.height * expandRatio)); - public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float inertia) + /// + /// Prevents a projectile from colliding with tiles until it's no longer inside tiles.
+ /// Useful for large projectiles that would otherwise collide with tiles instantly after spawning.
+ /// Make sure to set Projectile.tileCollide = false; in the projectile's SetDefaults before calling this function in the projectile's AI. + ///
+ public static void PreventTileCollisionUntilHitboxIsOutsideOfTiles(Projectile projectile) + { + if (!projectile.tileCollide) + { + bool canCollide = true; + Vector2 tilePosition; + Point tilePositionPoint; + Tile tileSafely; + float increment = 16f; + float offset = increment * 2f; + float startIndexX = projectile.position.X - increment; + float endIndexX = startIndexX + offset + projectile.width; + float startIndexY = projectile.position.Y - increment; + float endIndexY = projectile.position.Y + offset + projectile.height; + for (float i = startIndexX; i < endIndexX; i += increment) + { + if (!canCollide) + break; + + for (float j = startIndexY; j < endIndexY; j += increment) + { + tilePosition.X = i; + tilePosition.Y = j; + tilePositionPoint = tilePosition.ToTileCoordinates(); + tileSafely = Framing.GetTileSafely(tilePositionPoint); + bool isInSolidTile = tileSafely.HasUnactuatedTile && Main.tileSolid[tileSafely.TileType] && !Main.tileSolidTop[tileSafely.TileType] && !TileID.Sets.Platforms[tileSafely.TileType]; + if (isInSolidTile) + { + canCollide = false; + break; + } + } + } + + if (canCollide) + projectile.tileCollide = true; + } + } + + public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float inertia, bool respectIFrames = false) { if (!projectile.friendly) return; @@ -126,10 +181,12 @@ namespace CalamityMod foreach (NPC n in Main.ActiveNPCs) { float extraDistance = (n.width / 2) + (n.height / 2); - if (!n.CanBeChasedBy(projectile, false) || !projectile.WithinRange(n.Center, maxDistance + extraDistance)) + if (!n.CanBeChasedBy(projectile, false) || !projectile.WithinRange(n.Center, maxDistance + extraDistance) || (respectIFrames && (projectile.localNPCImmunity[n.whoAmI] > 0 || projectile.localNPCImmunity[n.whoAmI] == -1 || n.immune[projectile.owner] > 0))) continue; float currentNPCDist = Vector2.Distance(n.Center, projectile.Center); + if (respectIFrames && Projectile.perIDStaticNPCImmunity[projectile.type][n.whoAmI] > Main.GameUpdateCount) + currentNPCDist += 1600; //Prioritize things that don't currently have iframes, but still home in on stuff that has static iframes if needed. if ((currentNPCDist < npcDistCompare) && (ignoreTiles || Collision.CanHit(projectile.Center, 1, 1, n.Center, 1, 1))) { npcDistCompare = currentNPCDist; @@ -151,7 +208,8 @@ namespace CalamityMod // Home in on the target. Vector2 homeDirection = (destination - projectile.Center).SafeNormalize(Vector2.UnitY); projectile.velocity = (projectile.velocity * inertia + homeDirection * homingVelocity) / (inertia + 1f); - } + projectile.Calamity().HomingTarget = index; + } else { // Set amount of extra updates to default amount. @@ -179,6 +237,7 @@ namespace CalamityMod projectile.velocity = projectile.velocity * inertia + moveToNPC * homingVelocity; else projectile.velocity *= overspeedReduction; + projectile.Calamity().HomingTarget = targetedNPC.whoAmI; } if (targetedNPC == null && projectile.velocity.Length() < maxSpeed && accelerate) projectile.velocity *= 1.0055f; @@ -282,9 +341,8 @@ namespace CalamityMod Vector2 spawnPosition = new Vector2(x, y); Vector2 velocity = targetPos - spawnPosition; velocity.X += Main.rand.NextFloat(-xVariance, xVariance); - float speed = projSpeed; float targetDist = velocity.Length(); - targetDist = speed / targetDist; + targetDist = projSpeed / targetDist; velocity.X *= targetDist; velocity.Y *= targetDist; return Projectile.NewProjectileDirect(source, spawnPosition, velocity, projType, damage, knockback, owner); @@ -647,10 +705,15 @@ namespace CalamityMod Vector2 drawPosition = ((xPos == 0 && yPos == 0) ? projectile.Center : new Vector2(xPos, yPos)) - Main.screenPosition; Vector2 origin = frame.Value.Size() * 0.5f; Color backAfterimageColor = backglowColor * projectile.Opacity; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1 && effects == SpriteEffects.None) spriteEffects = SpriteEffects.FlipHorizontally; + else spriteEffects = effects; + for (int i = 0; i < 10; i++) { Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea; - Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, projectile.rotation, origin, projectile.scale, effects, 0f); + Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); } } @@ -664,12 +727,16 @@ namespace CalamityMod Vector2 drawPosition = projectile.Center - Main.screenPosition; Vector2 origin = frame.Value.Size() * 0.5f; Color backAfterimageColor = backglowColor * projectile.Opacity; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; + for (int i = 0; i < 10; i++) { Vector2 off = Vector2.Zero; if (offset != null) off += offset.Value; Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea; - Main.spriteBatch.Draw(texture, drawPosition + drawOffset + off, frame, backAfterimageColor, projectile.rotation, origin, scale, 0, 0f); + Main.spriteBatch.Draw(texture, drawPosition + drawOffset + off, frame, backAfterimageColor, projectile.rotation, origin, scale, spriteEffects, 0f); } } @@ -683,8 +750,12 @@ namespace CalamityMod Vector2 drawPosition = ((xPos == 0 && yPos == 0) ? projectile.Center : new Vector2(xPos, yPos)) - Main.screenPosition; Vector2 origin = frame.Value.Size() * 0.5f; - projectile.DrawBackglow(backglowColor, backglowArea, texture, frame, effects, xPos, yPos); - Main.spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, effects, 0f); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1 && effects == SpriteEffects.None) spriteEffects = SpriteEffects.FlipHorizontally; + else spriteEffects = effects; + + projectile.DrawBackglow(backglowColor, backglowArea, texture, frame, spriteEffects, xPos, yPos); + Main.spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, spriteEffects, 0f); } public static void DrawStarTrail(this Projectile projectile, Color outer, Color inner, float auraHeight = 10f) @@ -774,7 +845,6 @@ namespace CalamityMod private static readonly List vanillaBlastImmuneTiles = new List() { - TileID.DemonAltar, TileID.Cobalt, TileID.Mythril, TileID.Adamantite, @@ -783,8 +853,7 @@ namespace CalamityMod TileID.Titanium, TileID.Chlorophyte, TileID.LihzahrdBrick, - TileID.LihzahrdAltar, - TileID.DesertFossil + TileID.LihzahrdAltar }; public static void ExplodeTiles(this Projectile p, int explosionRadius, bool respectStandardBlastImmunity = true, IEnumerable customBlastImmuneTiles = null, IEnumerable customBlastImmuneWalls = null) @@ -847,6 +916,13 @@ namespace CalamityMod // Conditionally toss in Hellstone if it's not Hardmode yet. if (!Main.hardMode) blastImmuneTiles.Add(TileID.Hellstone); + + // Also spikes in FTW + if (Main.getGoodWorld) + { + blastImmuneTiles.Add(TileID.Spikes); + blastImmuneTiles.Add(TileID.WoodenSpikes); + } } // If specified, add custom blast immune tiles. diff --git a/Utilities/ReflectionHelper.cs b/Utilities/ReflectionHelper.cs index e1aff58a66..adc3ed494c 100644 --- a/Utilities/ReflectionHelper.cs +++ b/Utilities/ReflectionHelper.cs @@ -1,109 +1,37 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; -using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; -using Terraria.GameContent; -using Terraria.ModLoader.Core; -using Terraria.ModLoader; -using System.Collections; using CalamityMod.Particles; +using Terraria.ModLoader; +using Terraria.ModLoader.Core; namespace CalamityMod { - public class FastField(FieldInfo fieldInfo) - { - private Action _Setter = ReflectionHelper.CreateFieldSetter(fieldInfo); - private Func _Getter = ReflectionHelper.CreateFieldGetter(fieldInfo); - - public FastField(string fieldName, BindingFlags flags) : this(typeof(T).GetField(fieldName, flags)) - { - - } - - public ValueType Get(T instance) - { - return _Getter(instance); - } - - public void Set(T instance, ValueType newValue) - { - _Setter(instance, newValue); - } - } - + [Obsolete($"This is kept for {nameof(GeneralParticleHandler)}. Consider use ILoadable or ModType If possible.")] public static class ReflectionHelper { - public static Action CreateFieldSetter(FieldInfo fieldInfo) - { - string methodName = fieldInfo.ReflectedType.FullName + ".set_" + fieldInfo.Name; - DynamicMethod setterMethod = new DynamicMethod(methodName, null, [typeof(T), typeof(ValueType)], true); - ILGenerator gen = setterMethod.GetILGenerator(); - - gen.Emit(OpCodes.Ldarg_0); - gen.Emit(OpCodes.Ldarg_1); - gen.Emit(OpCodes.Stfld, fieldInfo); - gen.Emit(OpCodes.Ret); - - return (Action)setterMethod.CreateDelegate(typeof(Action)); - } - - public static Func CreateFieldGetter(FieldInfo fieldInfo) - { - string methodName = fieldInfo.ReflectedType.FullName + ".get_" + fieldInfo.Name; - DynamicMethod getterMethod = new DynamicMethod(methodName, typeof(ValueType), [typeof(T)], true); - ILGenerator gen = getterMethod.GetILGenerator(); - - gen.Emit(OpCodes.Ldarg_0); - gen.Emit(OpCodes.Ldfld, fieldInfo); - gen.Emit(OpCodes.Ret); - - return (Func)getterMethod.CreateDelegate(typeof(Func)); - } - public static IEnumerable GetEveryModsTypes() { return ModLoader.Mods.SelectMany(mod => AssemblyManager.GetLoadableTypes(mod.Code)); } - public static void IterateEveryModsTypes(bool includeBaseType = false, Action action = null) + public static bool IsSubclass(Type baseType, Type type, bool includeBaseType) + { + return type.IsSubclassOf(baseType) && !type.IsAbstract && (!includeBaseType && type != baseType); + } + + // TODO: Consider replacing with ModType? + public static void IterateEveryModsTypes(Action action, bool includeBaseType = false) { // WHY???? if (action is null) return; Type baseType = typeof(T); - var types = GetEveryModsTypes(); + var types = GetEveryModsTypes().Where(t => IsSubclass(baseType, t, includeBaseType)); foreach (var type in types) { - if (type.IsSubclassOf(baseType) && !type.IsAbstract && (!includeBaseType && type != baseType)) - { - action.Invoke(type); - } - } - } - - public static IEnumerable GetCalamityTypes() - { - return AssemblyManager.GetLoadableTypes(CalamityMod.Instance.Code); - } - - public static void IterateCalamityTypes(bool includeBaseType = false, Action action = null) - { - // WHY???? - if (action is null) - return; - - Type baseType = typeof(T); - var types = GetCalamityTypes(); - foreach (var type in types) - { - if (type.IsSubclassOf(baseType) && !type.IsAbstract && (!includeBaseType && type != baseType)) - { - action.Invoke(type); - } + action.Invoke(type); } } } diff --git a/Utilities/RicoshotUtils.cs b/Utilities/RicoshotUtils.cs index 1f54d392cb..a1edc37fb3 100644 --- a/Utilities/RicoshotUtils.cs +++ b/Utilities/RicoshotUtils.cs @@ -30,13 +30,14 @@ namespace CalamityMod public static int GetActiveRicoshotCoinCount(this Player player) { int count = 0; - int id = ModContent.ProjectileType(); + int coinID = ModContent.ProjectileType(); + int clipID = ModContent.ProjectileType(); foreach (Projectile p in Main.ActiveProjectiles) { if (p.owner != player.whoAmI) continue; - if (p.type == id) + if (p.type == coinID || p.type == clipID) ++count; } return count; @@ -45,10 +46,18 @@ namespace CalamityMod // Intentionally not an extension so it doesn't clog the Visual Studio recommendation lists. This is not generally useful. public static bool CanRicoshotCoinForceCrit(Projectile p) { - int id = ModContent.ProjectileType(); - if (!p.active || p.type != id) + int coinID = ModContent.ProjectileType(); + int clipID = ModContent.ProjectileType(); + + if (!p.active || (p.type != coinID && p.type != clipID)) return false; + if (p.type == clipID) + { + int clipUpdateCount = M1GarandEmptyClip.ClipLifetime - p.timeLeft; + return clipUpdateCount >= M1GarandEmptyClip.CritDelayTime; + } + int coinUpdateCount = RicoshotCoin.CoinLifetime - p.timeLeft; return coinUpdateCount >= RicoshotCoin.CritDelayTime; } @@ -96,21 +105,28 @@ namespace CalamityMod { IList coins = new List(); - // Search for all nearby coins. - // Coins do not necessarily have to be owned by the same player as the searching projectile! + // Search for all nearby coins/clips. + // Coins/clips do not necessarily have to be owned by the same player as the searching projectile! int coinID = ModContent.ProjectileType(); + int clipID = ModContent.ProjectileType(); + foreach (Projectile proj in Main.ActiveProjectiles) { - if (proj.ModProjectile is null || proj.type != coinID) + if (proj.ModProjectile is null) + continue; + + // Check if the projectile is either a coin or clip + if (proj.type != coinID && proj.type != clipID) continue; // Coins that have already been struck are ignored. if (proj.localAI[0] > 0f) continue; - // Finally, do a distance check + // Use the appropriate distance check based on the projectile type + float maxDistance = proj.type == clipID ? M1GarandEmptyClip.MaxIntraClipRicoshotDistance : RicoshotCoin.MaxIntraCoinRicoshotDistance; float dist = searchingShot.DistanceSQ(proj.Center); - if (dist <= RicoshotCoin.MaxIntraCoinRicoshotDistance * RicoshotCoin.MaxIntraCoinRicoshotDistance) + if (dist <= maxDistance * maxDistance) coins.Add(proj); } @@ -143,6 +159,11 @@ namespace CalamityMod float closestCoinDistance = RicoshotCoin.MaxIntraCoinRicoshotDistance; foreach (Projectile coin in availableCoins) { + // Determine the max ricochet distance based on the target type + float maxDistance = coin.type == ModContent.ProjectileType() ? M1GarandEmptyClip.MaxIntraClipRicoshotDistance : RicoshotCoin.MaxIntraCoinRicoshotDistance; // New line. Use different distance based on proj type. + if (coin.Distance(startPos) > maxDistance) + continue; + // Skip coins which are already frozen (part of an ongoing ricoshot), unless considering them if (!considerFrozenCoins && coin.ai[1] > 0f) continue; diff --git a/Utilities/StringUtils.cs b/Utilities/StringUtils.cs index 503a80cc3d..7e3f553a1f 100644 --- a/Utilities/StringUtils.cs +++ b/Utilities/StringUtils.cs @@ -1,6 +1,4 @@ using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; using Terraria; namespace CalamityMod @@ -9,19 +7,5 @@ namespace CalamityMod { internal static readonly string AlphanumericCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; public static string GenerateRandomAlphanumericString(int length) => new string(Enumerable.Repeat(AlphanumericCharacters, length).Select(s => s[Main.rand.Next(s.Length)]).ToArray()); - - public static string ColorMessage(this Color color, string text, bool newline = false) - { - int bufferSize = text.Length < 200 ? 256 : text.Length + 32; - StringBuilder sb = new(bufferSize); - sb.Append("[c/"); - sb.Append(color.Hex3()); - sb.Append(':'); - sb.Append(text); - sb.Append(']'); - if (newline) - sb.Append('\n'); - return sb.ToString(); - } } } diff --git a/Utilities/TextureUtils/DeferredTextureLoadingManager.cs b/Utilities/TextureUtils/DeferredTextureLoadingManager.cs new file mode 100644 index 0000000000..7902863691 --- /dev/null +++ b/Utilities/TextureUtils/DeferredTextureLoadingManager.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod +{ + internal sealed class DeferredTextureLoadingManager : ModSystem + { + private static readonly List Textures = []; + private static readonly List TexturesToRemove = []; + private static bool HasItem = false; + + public static void Enqueue(IDeferredLoadTexture texture) + { + Main.QueueMainThreadAction(() => + { + Textures.Add(texture); + HasItem = true; + }); + } + + public override void Load() + { + Main.OnTickForThirdPartySoftwareOnly += DoUpdate; + } + + public override void Unload() + { + Main.OnTickForThirdPartySoftwareOnly -= DoUpdate; + } + + private static void DoUpdate() + { + if (!HasItem) + return; + + int limitPerTick = 2; + foreach (var texture in Textures) + { + if (texture.IsAssetLoaded) + { + texture.OnTextureLoaded(); + TexturesToRemove.Add(texture); + limitPerTick--; + } + + if (limitPerTick <= 0) + { + break; + } + } + + foreach (var toRemove in TexturesToRemove) + { + Textures.Remove(toRemove); + } + + TexturesToRemove.Clear(); + HasItem = Textures.Count != 0; + } + } +} diff --git a/Utilities/TextureUtils/FramedMaskTexture.cs b/Utilities/TextureUtils/FramedMaskTexture.cs index 39e8e5e55e..8dca6edf14 100644 --- a/Utilities/TextureUtils/FramedMaskTexture.cs +++ b/Utilities/TextureUtils/FramedMaskTexture.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -11,13 +8,18 @@ using Terraria.ModLoader; namespace CalamityMod { - public sealed class FramedMaskTexture + public sealed class FramedMaskTexture : IDeferredLoadTexture { /// /// Cached Texture2D reference, null on server /// public Texture2D Texture; // Leave this as field for performances sake - + + /// + /// Check if Texture Asset is actually loaded + /// + public bool IsAssetLoaded => _Asset?.IsLoaded ?? false; + /// /// X axis's frame count, 0 on server /// @@ -51,90 +53,88 @@ namespace CalamityMod private int _FrameWidth = 0, _FrameHeight = 0; private int _FrameXCount = 0, _FrameYCount = 0; private int _TextureWidth = 0, _TextureHeight = 0; - private readonly bool[] _HasMaskContent; + private bool[] _HasMaskContent; + private Asset _Asset; + private readonly bool _EveryFrameHasContent = false; + private bool _Prepared = false; - public FramedMaskTexture(string asset, int frameWidth, int frameHeight, bool pretendEveryFrameHaveGlow = false) + public FramedMaskTexture(string asset, int frameWidth, int frameHeight, bool pretendEveryFrameHaveContent = false) { _FrameWidth = frameWidth; _FrameHeight = frameHeight; - - FramedGlowMaskSystem.OnUnload += Unload; + _EveryFrameHasContent = pretendEveryFrameHaveContent; + _Prepared = pretendEveryFrameHaveContent; // Don't do anything further on server if (Main.dedServ) return; - Texture = ModContent.Request(asset, AssetRequestMode.ImmediateLoad).Value; + _Asset = ModContent.Request(asset); + Texture = _Asset.Value; // This should feed transparent pixel + DeferredTextureLoadingManager.Enqueue(this); + } + + public void OnTextureLoaded() + { + Texture = _Asset.Value; + + if (_Prepared) + return; + if (Texture is null) return; _TextureWidth = Texture.Width; _TextureHeight = Texture.Height; - _FrameXCount = _TextureWidth / frameWidth; - _FrameYCount = _TextureHeight / frameHeight; + _FrameXCount = _TextureWidth / _FrameWidth; + _FrameYCount = _TextureHeight / _FrameHeight; _HasMaskContent = new bool[FrameXCount * FrameYCount]; - - if (pretendEveryFrameHaveGlow) + Color[] colData = new Color[_TextureWidth * _TextureHeight]; + Texture.GetData(colData); + + Parallel.For(0, FrameXCount * FrameYCount, (i) => { - for(int x = 0; x= 1) + { + frameHasData = true; + break; + } } } - } - else - { - Main.QueueMainThreadAction(() => - { - var colData = Texture.GetColorsFromTexture(); - - // Interesting case, not sure if this will even happens - if (colData is null) - return; - Parallel.For(0, FrameXCount * FrameYCount, (i) => - { - int xFrame = i % FrameXCount; - int yFrame = i / FrameXCount; + _HasMaskContent[xFrame + (yFrame * _FrameXCount)] = frameHasData; + }); - int xStart = xFrame * frameWidth; - int xEnd = Math.Min(xStart + frameWidth, _TextureWidth); - - int yStart = yFrame * frameHeight; - int yEnd = Math.Min(yStart + frameHeight, _TextureHeight); - - bool frameHasData = false; - for (int x = xStart; x < xEnd; x++) - { - if (frameHasData) - { - break; - } - - for (int y = yStart; y < yEnd; y++) - { - Color col = colData[x, y]; - if (col.A >= 1) - { - frameHasData = true; - break; - } - } - } - - _HasMaskContent[xFrame + (yFrame * _FrameXCount)] = frameHasData; - }); - }); - } + _Prepared = true; } public void Unload() { Texture = null; + _Asset = null; + _Prepared = false; _FrameWidth = 0; _FrameHeight = 0; _FrameXCount = 0; @@ -143,6 +143,12 @@ namespace CalamityMod public bool HasContentInFrameIndex(int xFrame, int yFrame) { + if (!_Prepared) + return false; + + if (_EveryFrameHasContent) + return true; // TRUE + if (Texture is null) return false; @@ -157,6 +163,12 @@ namespace CalamityMod public bool HasContentInFramePos(int xPos, int yPos) { + if (!_Prepared) + return false; + + if (_EveryFrameHasContent) + return true; // TRUE + int xFrame = xPos / _FrameWidth; int yFrame = yPos / _FrameHeight; @@ -168,16 +180,5 @@ namespace CalamityMod return _HasMaskContent[xFrame + (yFrame * _FrameXCount)]; } - - private sealed class FramedGlowMaskSystem : ModSystem - { - public static event Action OnUnload; - - public override void Unload() - { - OnUnload?.Invoke(); - OnUnload = null; // Clear cache completly - } - } } } diff --git a/Utilities/TextureUtils/GrayscaleTexture1D.cs b/Utilities/TextureUtils/GrayscaleTexture1D.cs index 96c92c435b..8ccfc1bb05 100644 --- a/Utilities/TextureUtils/GrayscaleTexture1D.cs +++ b/Utilities/TextureUtils/GrayscaleTexture1D.cs @@ -1,55 +1,80 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; -using Terraria.ModLoader; +using ReLogic.Threading; using Terraria; -using Microsoft.Xna.Framework; +using Terraria.ModLoader; namespace CalamityMod { /// /// Utility Class for using 1D Grayscale Texture as gradient /// - public sealed class GrayscaleTexture1D + public sealed class GrayscaleTexture1D : IDeferredLoadTexture { + public Texture2D Texture { get; private set; } + private int _Width = 0; private float[] _Scales; + private Asset _Asset; + private bool _Prepared; + + public bool IsAssetLoaded => _Asset?.IsLoaded ?? false; + public GrayscaleTexture1D(string assetName) { if (Main.dedServ) return; - var texture = ModContent.Request(assetName, AssetRequestMode.ImmediateLoad).Value; - if (texture is null) + _Asset = ModContent.Request(assetName); + if (_Asset is null) return; - Main.QueueMainThreadAction(() => - { - _Width = texture.Width; - _Scales = new float[texture.Width]; - - var colorScheme = new Color[_Width]; - texture.GetData(colorScheme); - for (int i = 0; i<_Width; i++) - { - _Scales[i] = colorScheme[i].R / 255.0f; - } - }); + Texture = _Asset.Value; + DeferredTextureLoadingManager.Enqueue(this); } public void Unload() { _Width = 0; _Scales = null; + _Asset = null; + Texture = null; + _Prepared = false; + } + + public void OnTextureLoaded() + { + if (_Prepared) + return; + + Texture = _Asset.Value; + if (Texture is null) + return; + + _Width = Texture.Width; + _Scales = new float[Texture.Width]; + + var colorScheme = new Color[_Width]; + Texture.GetData(colorScheme); + FastParallel.For(0, _Width, (startInclusive, endExclusive, context) => + { + for (int i = startInclusive; i < endExclusive; i++) + { + _Scales[i] = colorScheme[i].R / 255.0f; + } + }); + + _Prepared = true; } public float GetClamp(int x) { + if (!_Prepared) + return default; + if (_Width == 0) return default; @@ -59,6 +84,9 @@ namespace CalamityMod public float GetRepeat(int x) { + if (!_Prepared) + return default; + if (_Width == 0) return default; diff --git a/Utilities/TextureUtils/GrayscaleTexture2D.cs b/Utilities/TextureUtils/GrayscaleTexture2D.cs index d369a3b709..9b99359040 100644 --- a/Utilities/TextureUtils/GrayscaleTexture2D.cs +++ b/Utilities/TextureUtils/GrayscaleTexture2D.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; +using ReLogic.Threading; using Terraria; using Terraria.ModLoader; @@ -14,36 +11,30 @@ namespace CalamityMod /// /// Utility Class for using 2D Grayscale Texture as gradient /// - public sealed class GrayscaleTexture2D + public sealed class GrayscaleTexture2D : IDeferredLoadTexture { + public Texture2D Texture { get; private set; } + private int _Width = 0; private int _Height = 0; private float[] _Scales; // 2D array is not thread-safe + private Asset _Asset; + private bool _Prepared; + + public bool IsAssetLoaded => _Asset?.IsLoaded ?? false; + public GrayscaleTexture2D(string assetName) { if (Main.dedServ) return; - var texture = ModContent.Request(assetName, AssetRequestMode.ImmediateLoad).Value; - if (texture is null) + _Asset = ModContent.Request(assetName); + if (_Asset is null) return; - Main.QueueMainThreadAction(() => - { - _Width = texture.Width; - _Height = texture.Height; - _Scales = new float[_Width * _Height]; - - var colorScheme = texture.GetColorsFromTexture(); - for (int i = 0; i < _Width; i++) - { - for (int j = 0; j < _Height; j++) - { - _Scales[(j * _Width) + i] = colorScheme[i, j].R / 255.0f; - } - } - }); + Texture = _Asset.Value; + DeferredTextureLoadingManager.Enqueue(this); } public void Unload() @@ -51,10 +42,43 @@ namespace CalamityMod _Width = 0; _Height = 0; _Scales = null; + _Asset = null; + Texture = null; + _Prepared = false; + } + + public void OnTextureLoaded() + { + if (_Prepared) + return; + + Texture = _Asset.Value; + if (Texture is null) + return; + + _Width = Texture.Width; + _Height = Texture.Height; + _Scales = new float[_Width * _Height]; + + Color[] colorScheme = new Color[_Width * _Height]; + Texture.GetData(colorScheme); + + FastParallel.For(0, _Width * _Height, (startInclusive, endExclusive, context) => + { + for (int i = startInclusive; i < endExclusive; i++) + { + _Scales[i] = colorScheme[i].R / 255.0f; + } + }); + + _Prepared = true; } public float GetClamp(int x, int y) { + if (!_Prepared) + return default; + if (_Width == 0 || _Height == 0) return default; @@ -65,6 +89,9 @@ namespace CalamityMod public float GetRepeat(int x, int y) { + if (!_Prepared) + return default; + if (_Width == 0 || _Height == 0) return default; diff --git a/Utilities/TextureUtils/IDeferredLoadTexture.cs b/Utilities/TextureUtils/IDeferredLoadTexture.cs new file mode 100644 index 0000000000..4d647e395e --- /dev/null +++ b/Utilities/TextureUtils/IDeferredLoadTexture.cs @@ -0,0 +1,8 @@ +namespace CalamityMod +{ + public interface IDeferredLoadTexture + { + bool IsAssetLoaded { get; } + void OnTextureLoaded(); + } +} diff --git a/Utilities/TileEntityUtils.cs b/Utilities/TileEntityUtils.cs index 3e5fae0989..8df7ab59f8 100644 --- a/Utilities/TileEntityUtils.cs +++ b/Utilities/TileEntityUtils.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.DraedonMisc; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -77,7 +76,7 @@ namespace CalamityMod // This check is done twice because the draw order matters. We want to draw the background icon before any text. if (item.stack > 0) { - if (item.type == ItemType()) + if (item.type == ItemType()) { slotBackgroundTex = Request("CalamityMod/UI/DraedonsArsenal/PowerCellSlot_Blood").Value; } diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 64ca80e336..ff47fdb067 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -8,13 +8,16 @@ using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Crags; -using CalamityMod.Tiles.FloralParadise; using CalamityMod.Tiles.FurnitureAbyss; using CalamityMod.Tiles.FurnitureAshen; -using CalamityMod.Tiles.FurnitureEutrophic; +using CalamityMod.Tiles.FurnitureDriftwood; +using CalamityMod.Tiles.FurnitureMonolith; +using CalamityMod.Tiles.FurnitureNavystone; +using CalamityMod.Tiles.FurnitureNavystone.FurnitureAncientNavystone; using CalamityMod.Tiles.FurnitureOtherworldly; using CalamityMod.Tiles.FurnitureProfaned; using CalamityMod.Tiles.FurnitureVoid; +using CalamityMod.Tiles.FurnitureWulfrum; using CalamityMod.Tiles.Ores; using CalamityMod.Tiles.SunkenSea; using Microsoft.Xna.Framework; @@ -30,35 +33,6 @@ namespace CalamityMod { public static partial class CalamityUtils { - public static string GetMapChestName(string baseName, int x, int y) - { - // Bounds check. - if (!WorldGen.InWorld(x, y, 2)) - return baseName; - - Tile tile = Main.tile[x, y]; - int left = x; - int top = y; - if (tile.TileFrameX % 36 != 0) - left--; - if (tile.TileFrameY != 0) - top--; - - int chest = Chest.FindChest(left, top); - - // Valid chest index check. - if (chest < 0) - return baseName; - - string name = baseName; - - // Concatenate the chest's custom name if it has one. - if (!string.IsNullOrEmpty(Main.chest[chest].name)) - name += $": {Main.chest[chest].name}"; - - return name; - } - public static void SafeSquareTileFrame(int x, int y, bool resetFrame = true) { for (int xIter = x - 1; xIter <= x + 1; ++xIter) @@ -79,38 +53,6 @@ namespace CalamityMod } } - public static void LightHitWire(int type, int i, int j, int tileX, int tileY) - { - int x = i - Main.tile[i, j].TileFrameX / 18 % tileX; - int y = j - Main.tile[i, j].TileFrameY / 18 % tileY; - int tileXX18 = 18 * tileX; - for (int l = x; l < x + tileX; l++) - { - for (int m = y; m < y + tileY; m++) - { - if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == type) - { - if (Main.tile[l, m].TileFrameX < tileXX18) - Main.tile[l, m].TileFrameX += (short)(tileXX18); - else - Main.tile[l, m].TileFrameX -= (short)(tileXX18); - } - } - } - - if (Wiring.running) - { - for (int k = 0; k < tileX; k++) - { - for (int l = 0; l < tileY; l++) - Wiring.SkipWire(x + k, y + l); - } - } - - if (Main.netMode != NetmodeID.SinglePlayer) - NetMessage.SendTileSquare(-1, x, y, tileX, tileY); - } - public static bool DrawSwayingMultiTile(int i, int j) { Tile tile = Main.tile[i, j]; @@ -299,7 +241,7 @@ namespace CalamityMod { for (int j = y; j != y + height; j += Math.Sign(height)) { - if (WorldGen.InWorld(i, j)) + if (!WorldGen.InWorld(i, j)) continue; if (WorldGen.SolidTile(Framing.GetTileSafely(i, j))) @@ -377,13 +319,18 @@ namespace CalamityMod // Extension shorthand for the Tile Framing System Universal Merges. // As this must be defined in a static class, it's out here in CalamityUtils. // Flow, 2024/OCT/31 Removing Obsolete in here as tModLoader doesn't like this - //[Obsolete("Use TileBlendMergeSystem.RegisterMerge Instead")] + [Obsolete("Use TileBlendMergeSystem.RegisterBlendMergeWith Instead")] public static void RegisterUniversalMerge(this ModTile tile, int mergeType, string blendSheetPath) { //TileFramingSystem.RegisterUniversalMerge(tile.Type, mergeType, blendSheetPath); TileBlendMergeSystem.RegisterMerge(tile.Type, mergeType); } + public static void RegisterBlendMergeWith(this ModTile tile, int mergeType) + { + TileBlendMergeSystem.RegisterMerge(tile.Type, mergeType); + } + /// /// Sets the mergeability state of two tiles. By default, enables tile merging. /// @@ -443,13 +390,15 @@ namespace CalamityMod TileType(), TileType(), TileType(), - TileType(), + TileType(), TileType(), TileType(), + TileType(), + TileType(), TileType(), TileType(), TileType(), - TileType(), + TileType(), }); /// @@ -516,6 +465,7 @@ namespace CalamityMod TileType(), // Sunken Sea TileType(), + TileType(), TileType(), TileType(), TileType(), @@ -523,10 +473,11 @@ namespace CalamityMod TileType(), TileType(), TileType(), - TileType(), + TileType(), TileType(), TileType(), TileType(), + TileType(), }); /// @@ -580,17 +531,6 @@ namespace CalamityMod TileType(), }); - /// - /// Makes the tile merge with all the tile types that generate within various types of floral paradise tiles. - /// - /// The tile whose merging properties will be set. - public static void MergeWithFloralParadise(int type) => MergeWithSet(type, new int[] { - TileType(), - TileType(), - TileType(), - TileType(), - }); - /// /// Makes the tile merge with all the tile types that generate within various types of astral tiles /// @@ -646,6 +586,13 @@ namespace CalamityMod SetMerge(type, TileType()); SetMerge(type, TileType()); SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); + SetMerge(type, TileType()); } /// @@ -694,7 +641,7 @@ namespace CalamityMod /// Determines if a tile is solid based on whether it's active and not actuated or if the tile is solid. This will not count platforms and other non-solid ground tiles /// /// The tile to check. - public static bool IsTileSolid(this Tile tile) => tile != null && tile.HasUnactuatedTile && Main.tileSolid[tile.TileType] && !TileID.Sets.Platforms[tile.TileType]; + public static bool IsTileSolid(this Tile tile) => tile != null && tile.HasUnactuatedTile && Main.tileSolid[tile.TileType] && !Main.tileSolidTop[tile.TileType]; /// /// Determines if a tile is "full" based on if the tile is solid. This will count platforms and actuated tiles but no other non-solid ground tiles. @@ -736,7 +683,7 @@ namespace CalamityMod /// /// /// Wether or not the tile may be grappled onto - public static bool CanTileBeLatchedOnTo(this Tile theTile, bool grappleOnTrees = false) => Main.tileSolid[theTile.TileType] | (theTile.TileType == 314) | (grappleOnTrees && TileID.Sets.IsATreeTrunk[theTile.TileType]) | (grappleOnTrees && theTile.TileType == 323); + public static bool CanTileBeLatchedOnTo(this Tile theTile, bool grappleOnTrees = false) => Main.tileSolid[theTile.TileType] | (theTile.TileType == TileID.MinecartTrack) | (grappleOnTrees && TileID.Sets.IsATreeTrunk[theTile.TileType]) | (grappleOnTrees && theTile.TileType == TileID.PalmTree); /// /// Gets the required pickaxe power of a tile, accounting for both the ModTile and the vanilla tile pick requirements diff --git a/Walls/AbyssGravelWall.cs b/Walls/AbyssGravelWall.cs index 44e781e3a0..f7d0903da9 100644 --- a/Walls/AbyssGravelWall.cs +++ b/Walls/AbyssGravelWall.cs @@ -5,27 +5,16 @@ using Terraria.ModLoader; namespace CalamityMod.Walls { - public class AbyssGravelWall : ModWall + [LegacyName("AbyssGravelWallSafe")] + public class SafeAbyssGravelWall : ModWall { public override void SetStaticDefaults() { - DustType = 33; + Main.wallHouse[Type] = true; AddMapEntry(new Color(6, 10, 54)); + DustType = DustID.Water; } - - public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j].LiquidAmount == 0 && j < Main.maxTilesY - 205) - { - Main.tile[i, j].Get().LiquidType = LiquidID.Water; - Main.tile[i, j].LiquidAmount = byte.MaxValue; - WorldGen.SquareTileFrame(i, j); - if (Main.dedServ) - NetMessage.sendWater(i, j); - } - } - - public override void KillWall(int i, int j, ref bool fail) => fail = true; + public override string Texture => "CalamityMod/Walls/AbyssGravelWall"; public override bool CanExplode(int i, int j) => false; diff --git a/Walls/AbyssGravelWallSafe.cs b/Walls/AbyssGravelWallSafe.cs deleted file mode 100644 index 47910b7661..0000000000 --- a/Walls/AbyssGravelWallSafe.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class AbyssGravelWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/AbyssGravelWall"; - public override void SetStaticDefaults() - { - Main.wallHouse[Type] = true; - AddMapEntry(new Color(6, 10, 54)); - DustType = 33; - } - - public override bool CanExplode(int i, int j) => false; - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/AcidwoodWall.cs b/Walls/AcidwoodWall.cs index 9940651a5e..0ad883ef18 100644 --- a/Walls/AcidwoodWall.cs +++ b/Walls/AcidwoodWall.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Walls/AncientSmoothNavystoneWall.cs b/Walls/AncientSmoothNavystoneWall.cs new file mode 100644 index 0000000000..ec71f2f560 --- /dev/null +++ b/Walls/AncientSmoothNavystoneWall.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class AncientSmoothNavystoneWall : ModWall, IVisibleThroughWater + { + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + + this.AddMapEntryWithWaterVisibility(new Color(27, 35, 36)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.SnowBlock, 0f, 0f, 1, new Color(54, 69, 72), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/AncientSmoothNavystoneWall.png b/Walls/AncientSmoothNavystoneWall.png new file mode 100644 index 0000000000..585d059bc8 Binary files /dev/null and b/Walls/AncientSmoothNavystoneWall.png differ diff --git a/Walls/AnodizedWulfrumTrimWall.cs b/Walls/AnodizedWulfrumTrimWall.cs new file mode 100644 index 0000000000..55c63b2614 --- /dev/null +++ b/Walls/AnodizedWulfrumTrimWall.cs @@ -0,0 +1,29 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls +{ + public class AnodizedWulfrumTrimWall : MultiVariantModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + AddMapEntry(new Color(67, 6, 6)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 2) * 468; + frameYOffset = (j % 2) * 180; + } + } +} diff --git a/Walls/AnodizedWulfrumTrimWall.png b/Walls/AnodizedWulfrumTrimWall.png new file mode 100644 index 0000000000..3d8274c568 Binary files /dev/null and b/Walls/AnodizedWulfrumTrimWall.png differ diff --git a/Walls/AstralDirtWall.cs b/Walls/AstralDirtWall.cs index ae80a7a4dd..3484205805 100644 --- a/Walls/AstralDirtWall.cs +++ b/Walls/AstralDirtWall.cs @@ -1,21 +1,19 @@ using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("AstralDirtWallSafe")] public class AstralDirtWall : ModWall { - /*public override bool Autoload(ref string name, ref string texture) - { - mod.AddWall("AstralDirtWallUnsafe",this, "CalamityMod/Walls/AstralD" ); - return true; - }*/ public override void SetStaticDefaults() { // TODO -- Change this dust to be one more befitting Astral Dirt. DustType = DustID.Shadowflame; + Main.wallHouse[Type] = true; WallID.Sets.Conversion.Dirt[Type] = true; AddMapEntry(new Color(26, 22, 32)); } diff --git a/Walls/AstralDirtWallSafe.cs b/Walls/AstralDirtWallSafe.cs deleted file mode 100644 index 8305333479..0000000000 --- a/Walls/AstralDirtWallSafe.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class AstralDirtWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/AstralDirtWall"; - - public override void SetStaticDefaults() - { - // TODO -- Change this dust to be one more befitting Astral Dirt. - DustType = DustID.Shadowflame; - Main.wallHouse[Type] = true; - WallID.Sets.Conversion.Dirt[Type] = true; - AddMapEntry(new Color(26, 22, 32)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/AstralGrassWall.cs b/Walls/AstralGrassWall.cs index 95ff468205..ab77a466f4 100644 --- a/Walls/AstralGrassWall.cs +++ b/Walls/AstralGrassWall.cs @@ -6,18 +6,15 @@ using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Utilities; namespace CalamityMod.Walls { + [LegacyName("AstralGrassWallSafe")] public class AstralGrassWall : ModWall { public static Asset leafTexture = null; public static Vector2 TileAdj => (Lighting.Mode == Terraria.Graphics.Light.LightMode.Retro || Lighting.Mode == Terraria.Graphics.Light.LightMode.Trippy) ? Vector2.Zero : Vector2.One * 12; - /*public override bool Autoload(ref string name, ref string texture) - { - mod.AddWall("AstralGrassWallUnsafe", this, texture); - return base.Autoload(ref name, ref texture); - }*/ public override void SetStaticDefaults() { @@ -26,6 +23,8 @@ namespace CalamityMod.Walls WallID.Sets.Conversion.Grass[Type] = true; + Main.wallHouse[Type] = true; + AddMapEntry(new Color(60, 48, 64)); if (!Main.dedServ) @@ -38,10 +37,10 @@ namespace CalamityMod.Walls if (i > Main.screenPosition.X / 16 && i < Main.screenPosition.X / 16 + Main.screenWidth / 16 && j > Main.screenPosition.Y / 16 && j < Main.screenPosition.Y / 16 + Main.screenHeight / 16) { Texture2D tex = leafTexture.Value; - var rand = new Random(i + (j * 100000)); + var rand = new FastRandom(i + (j * 100000)); - float offset = i * j % 6.28f + (float)rand.NextDouble() / 8f; - float sin = (float)Math.Sin(Main.GameUpdateCount / 45f + offset); + float offset = i * j % 6.28f + rand.NextFloat() / 8f; + float sin = MathF.Sin(Main.GameUpdateCount / 45f + offset); spriteBatch.Draw(tex, (new Vector2(i + 0.5f, j + 0.5f) + TileAdj) * 16 + new Vector2(1, 0.5f) * sin * 2.2f - Main.screenPosition, new Rectangle(rand.Next(4) * 26, 0, 24, 24), Lighting.GetColor(i, j), offset + sin * 0.09f, new Vector2(12, 12), 1 + sin / 14f, 0, 0); diff --git a/Walls/AstralGrassWallSafe.cs b/Walls/AstralGrassWallSafe.cs deleted file mode 100644 index b7f0877466..0000000000 --- a/Walls/AstralGrassWallSafe.cs +++ /dev/null @@ -1,44 +0,0 @@ - -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Walls -{ - public class AstralGrassWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/AstralGrassWall"; - - public static Vector2 TileAdj => (Lighting.Mode == Terraria.Graphics.Light.LightMode.Retro || Lighting.Mode == Terraria.Graphics.Light.LightMode.Trippy) ? Vector2.Zero : Vector2.One * 12; - - public override void SetStaticDefaults() - { - // TODO -- Change this dust to be one more befitting Astral Grass. - DustType = DustID.Shadowflame; - - WallID.Sets.Conversion.Grass[Type] = true; - - Main.wallHouse[Type] = true; - - AddMapEntry(new Color(60, 48, 64)); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) - { - if (i > Main.screenPosition.X / 16 && i < Main.screenPosition.X / 16 + Main.screenWidth / 16 && j > Main.screenPosition.Y / 16 && j < Main.screenPosition.Y / 16 + Main.screenHeight / 16) - { - Texture2D tex = AstralGrassWall.leafTexture.Value; - var rand = new Random(i + (j * 100000)); - - float offset = i * j % 6.28f + (float)rand.NextDouble() / 8f; - float sin = (float)Math.Sin(Main.GameUpdateCount / 45f + offset); - - spriteBatch.Draw(tex, (new Vector2(i + 0.5f, j + 0.5f) + TileAdj) * 16 + new Vector2(1, 0.5f) * sin * 2.2f - Main.screenPosition, - new Rectangle(rand.Next(4) * 26, 0, 24, 24), Lighting.GetColor(i, j), offset + sin * 0.09f, new Vector2(12, 12), 1 + sin / 14f, 0, 0); - } - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/AstralIceWall.cs b/Walls/AstralIceWall.cs index 4c0802f5a5..8e3431c427 100644 --- a/Walls/AstralIceWall.cs +++ b/Walls/AstralIceWall.cs @@ -1,20 +1,17 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("AstralIceWallSafe")] public class AstralIceWall : ModWall { - /*public override bool Autoload(ref string name, ref string texture) - { - mod.AddWall("AstralIceWallUnsafe", this, texture); - return base.Autoload(ref name, ref texture); - }*/ public override void SetStaticDefaults() { // TODO -- Change this dust to be one more befitting Astral Ice. + Main.wallHouse[Type] = true; DustType = DustID.Shadowflame; WallID.Sets.Conversion.Ice[Type] = true; AddMapEntry(new Color(83, 76, 92)); diff --git a/Walls/AstralIceWallSafe.cs b/Walls/AstralIceWallSafe.cs deleted file mode 100644 index 0b93d98546..0000000000 --- a/Walls/AstralIceWallSafe.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Walls -{ - public class AstralIceWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/AstralIceWall"; - - public override void SetStaticDefaults() - { - // TODO -- Change this dust to be one more befitting Astral Ice. - Main.wallHouse[Type] = true; - DustType = DustID.Shadowflame; - WallID.Sets.Conversion.Ice[Type] = true; - AddMapEntry(new Color(83, 76, 92)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/AstralSandstoneWall.cs b/Walls/AstralSandstoneWall.cs index 7d24446445..ad9bcab1c8 100644 --- a/Walls/AstralSandstoneWall.cs +++ b/Walls/AstralSandstoneWall.cs @@ -1,21 +1,18 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("AstralSandstoneWallSafe")] public class AstralSandstoneWall : ModWall { - /*public override bool Autoload(ref string name, ref string texture) - { - mod.AddWall("AstralSandstoneWallUnsafe", this, texture); - return base.Autoload(ref name, ref texture); - }*/ public override void SetStaticDefaults() { // TODO -- Change this dust to be one more befitting Astral Sandstone. DustType = DustID.Shadowflame; + Main.wallHouse[Type] = true; WallID.Sets.Conversion.Sandstone[Type] = true; diff --git a/Walls/AstralSandstoneWallSafe.cs b/Walls/AstralSandstoneWallSafe.cs deleted file mode 100644 index af458c22e4..0000000000 --- a/Walls/AstralSandstoneWallSafe.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Walls -{ - public class AstralSandstoneWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/AstralSandstoneWall"; - - public override void SetStaticDefaults() - { - // TODO -- Change this dust to be one more befitting Astral Sandstone. - DustType = DustID.Shadowflame; - Main.wallHouse[Type] = true; - - WallID.Sets.Conversion.Sandstone[Type] = true; - - AddMapEntry(new Color(29, 38, 49)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/AstralSnowWall.cs b/Walls/AstralSnowWall.cs index 586060389a..87e48f1d0d 100644 --- a/Walls/AstralSnowWall.cs +++ b/Walls/AstralSnowWall.cs @@ -1,14 +1,17 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("AstralSnowWallSafe")] public class AstralSnowWall : ModWall { + public override void SetStaticDefaults() { DustType = ModContent.DustType(); + Main.wallHouse[Type] = true; WallID.Sets.Conversion.Snow[Type] = true; AddMapEntry(new Color(135, 145, 149)); } diff --git a/Walls/AstralSnowWall.png b/Walls/AstralSnowWall.png index 0f07f2758a..48a3ee8982 100644 Binary files a/Walls/AstralSnowWall.png and b/Walls/AstralSnowWall.png differ diff --git a/Walls/AstralSnowWallSafe.cs b/Walls/AstralSnowWallSafe.cs deleted file mode 100644 index fe7d6b8b19..0000000000 --- a/Walls/AstralSnowWallSafe.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Walls -{ - public class AstralSnowWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/AstralSnowWall"; - - public override void SetStaticDefaults() - { - DustType = ModContent.DustType(); - Main.wallHouse[Type] = true; - WallID.Sets.Conversion.Snow[Type] = true; - AddMapEntry(new Color(135, 145, 149)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/AstralStoneWall.cs b/Walls/AstralStoneWall.cs index 0de91add8b..1ba76b2331 100644 --- a/Walls/AstralStoneWall.cs +++ b/Walls/AstralStoneWall.cs @@ -1,21 +1,18 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("AstralStoneWallSafe")] public class AstralStoneWall : ModWall { - /*public override bool Autoload(ref string name, ref string texture) - { - mod.AddWall("AstralStoneWallUnsafe", this, texture); - return base.Autoload(ref name, ref texture); - }*/ public override void SetStaticDefaults() { // TODO -- Change this dust to be one more befitting Astral Stone. DustType = DustID.Shadowflame; + Main.wallHouse[Type] = true; WallID.Sets.Conversion.Stone[Type] = true; diff --git a/Walls/AstralStoneWallSafe.cs b/Walls/AstralStoneWallSafe.cs deleted file mode 100644 index 80b21ac42d..0000000000 --- a/Walls/AstralStoneWallSafe.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Walls -{ - public class AstralStoneWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/AstralStoneWall"; - - public override void SetStaticDefaults() - { - // TODO -- Change this dust to be one more befitting Astral Stone. - DustType = DustID.Shadowflame; - Main.wallHouse[Type] = true; - - WallID.Sets.Conversion.Stone[Type] = true; - - AddMapEntry(new Color(15, 26, 31)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/BrimstoneSlagWallUnsafe.cs b/Walls/BrimstoneSlagWallUnsafe.cs deleted file mode 100644 index 4485858ca2..0000000000 --- a/Walls/BrimstoneSlagWallUnsafe.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; - -namespace CalamityMod.Walls -{ - public class BrimstoneSlagWallUnsafe : MultiVariantModWall - { - public override string Texture => "CalamityMod/Walls/BrimstoneSlagWall"; - public override void SetStaticDefaults() - { - AddMapEntry(new Color(24, 16, 29)); - } - - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.RedTorch, 0f, 0f, 1, new Color(255, 255, 255), 1f); - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 100, 100), 1f); - return false; - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - - public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) - { - frameXOffset = (i % 2) * 468; - frameYOffset = (j % 2) * 180; - } - } -} diff --git a/Walls/ChargedWulfrumEnergyBarrierWall.cs b/Walls/ChargedWulfrumEnergyBarrierWall.cs new file mode 100644 index 0000000000..b48d2ca1ec --- /dev/null +++ b/Walls/ChargedWulfrumEnergyBarrierWall.cs @@ -0,0 +1,107 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class ChargedWulfrumEnergyBarrierWall : ModWall + { + internal static FramedMaskTexture GlowMask; + + public override void SetStaticDefaults() + { + GlowMask = new("CalamityMod/Walls/ChargedWulfrumEnergyBarrierWallReflect", 36, 36); + + Main.wallHouse[Type] = true; + Main.wallLight[Type] = true; + AddMapEntry(new Color(67, 146, 146)); + } + + public override void Unload() + { + GlowMask?.Unload(); + GlowMask = null; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.DungeonSpirit, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float brightness = 0.9f; + Color cyan = new Color(67, 146, 146); + Color blue = new Color(32, 93, 129); + Color value = Color.Lerp(cyan, blue, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(cyan, blue, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + + r = (value.R + value1.R) / 900f; + g = (value.G + value1.G) / 900f; + b = (value.B + value1.B) / 900f; + r *= brightness; + g *= brightness; + b *= brightness; + } + public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch) + { + if (GlowMask.Texture is null) + return; + + Tile tile = Main.tile[i, j]; + int xLength = 32; + int xOff = 0; + + int xPos = tile.WallFrameX + xOff; + int yPos = tile.WallFrameY; + + Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); + Color drawcolor; + drawcolor = WorldGen.paintColor(tile.WallColor); + drawcolor.A = 255; + Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); + + if (Main.drawToScreen) + zero = Vector2.Zero; + + Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; + Color lightColor = Lighting.GetColor(i, j, Color.White); + + spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + + if (GlowMask.HasContentInFramePos(xPos, yPos)) + { + float brightness = MathHelper.Clamp(0.2f - (j / 680), 0f, 0.2f); + + float time = Main.GameUpdateCount; + float waveScale1 = time * 0.094f; + int scalar = i - (j / 2); + float wave1 = waveScale1 * -50 + scalar * 12; + float wave1angle = 0.30f + 0.25f * MathF.Sin(MathHelper.ToRadians(wave1)); + + drawcolor *= brightness; + + float transparency = 0.02f + (wave1angle / 4); + Color glowColor = Color.White * transparency; + + for (int k = 0; k < 3; k++) + { + //Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; + spriteBatch.Draw(GlowMask.Texture, pos + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + DrawWallGlow(Type, i, j, spriteBatch); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/ChargedWulfrumEnergyBarrierWall.png b/Walls/ChargedWulfrumEnergyBarrierWall.png new file mode 100644 index 0000000000..d233bd32c2 Binary files /dev/null and b/Walls/ChargedWulfrumEnergyBarrierWall.png differ diff --git a/Walls/ChargedWulfrumEnergyBarrierWallReflect.png b/Walls/ChargedWulfrumEnergyBarrierWallReflect.png new file mode 100644 index 0000000000..75ab6e96d8 Binary files /dev/null and b/Walls/ChargedWulfrumEnergyBarrierWallReflect.png differ diff --git a/Walls/DraedonStructures/HazardChevronWall.cs b/Walls/DraedonStructures/HazardChevronWall.cs index 5e9c66d175..452be6f431 100644 --- a/Walls/DraedonStructures/HazardChevronWall.cs +++ b/Walls/DraedonStructures/HazardChevronWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { @@ -8,7 +9,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 19; + DustType = DustID.Sunflower; Main.wallHouse[Type] = true; AddMapEntry(new Color(114, 105, 51)); diff --git a/Walls/DraedonStructures/LaboratoryPanelWall.cs b/Walls/DraedonStructures/LaboratoryPanelWall.cs index 53c7ce89b0..1a6a30f7aa 100644 --- a/Walls/DraedonStructures/LaboratoryPanelWall.cs +++ b/Walls/DraedonStructures/LaboratoryPanelWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { @@ -8,7 +9,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 1; + DustType = DustID.Stone; Main.wallHouse[Type] = true; AddMapEntry(new Color(63, 57, 56)); diff --git a/Walls/DraedonStructures/LaboratoryPlateBeam.cs b/Walls/DraedonStructures/LaboratoryPlateBeam.cs index 6b875643c2..e17a380a20 100644 --- a/Walls/DraedonStructures/LaboratoryPlateBeam.cs +++ b/Walls/DraedonStructures/LaboratoryPlateBeam.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { @@ -8,7 +9,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 109; + DustType = DustID.Asphalt; Main.wallHouse[Type] = true; AddMapEntry(new Color(48, 45, 46)); diff --git a/Walls/DraedonStructures/LaboratoryPlatePillar.cs b/Walls/DraedonStructures/LaboratoryPlatePillar.cs index f86b52507f..935621a6f7 100644 --- a/Walls/DraedonStructures/LaboratoryPlatePillar.cs +++ b/Walls/DraedonStructures/LaboratoryPlatePillar.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { @@ -8,7 +9,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 109; + DustType = DustID.Asphalt; Main.wallHouse[Type] = true; AddMapEntry(new Color(29, 28, 30)); diff --git a/Walls/DraedonStructures/LaboratoryPlatingWall.cs b/Walls/DraedonStructures/LaboratoryPlatingWall.cs index 633e39b345..b0b2bd91c7 100644 --- a/Walls/DraedonStructures/LaboratoryPlatingWall.cs +++ b/Walls/DraedonStructures/LaboratoryPlatingWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { @@ -8,7 +9,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 30; + DustType = DustID.Web; Main.wallHouse[Type] = true; AddMapEntry(new Color(105, 102, 98)); diff --git a/Walls/DraedonStructures/RustedPlateBeam.cs b/Walls/DraedonStructures/RustedPlateBeam.cs index 1849987974..1f6162069a 100644 --- a/Walls/DraedonStructures/RustedPlateBeam.cs +++ b/Walls/DraedonStructures/RustedPlateBeam.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures @@ -9,7 +10,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 32; + DustType = DustID.Sand; Main.wallHouse[Type] = true; AddMapEntry(new Color(74, 47, 39)); diff --git a/Walls/DraedonStructures/RustedPlatePillar.cs b/Walls/DraedonStructures/RustedPlatePillar.cs index b73d455902..f971eb3cf4 100644 --- a/Walls/DraedonStructures/RustedPlatePillar.cs +++ b/Walls/DraedonStructures/RustedPlatePillar.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures @@ -9,7 +10,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 32; + DustType = DustID.Sand; Main.wallHouse[Type] = true; AddMapEntry(new Color(99, 71, 60)); diff --git a/Walls/DraedonStructures/RustedPlatingWall.cs b/Walls/DraedonStructures/RustedPlatingWall.cs index 4d2bb282d8..4564b780e3 100644 --- a/Walls/DraedonStructures/RustedPlatingWall.cs +++ b/Walls/DraedonStructures/RustedPlatingWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls.DraedonStructures { @@ -8,7 +9,7 @@ namespace CalamityMod.Walls.DraedonStructures public override void SetStaticDefaults() { - DustType = 32; + DustType = DustID.Sand; Main.wallHouse[Type] = true; AddMapEntry(new Color(83, 59, 50)); diff --git a/Walls/DriftwoodWall.png b/Walls/DriftwoodWall.png index f33778a6fe..8e691a4d26 100644 Binary files a/Walls/DriftwoodWall.png and b/Walls/DriftwoodWall.png differ diff --git a/Walls/EutrophicGlassWall.cs b/Walls/EutrophicGlassWall.cs new file mode 100644 index 0000000000..a3faeb192f --- /dev/null +++ b/Walls/EutrophicGlassWall.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls +{ + public class EutrophicGlassWall : MultiVariantModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + Main.BackgroundEnabled = true; + Main.wallLight[Type] = true; + + AddMapEntry(new Color(23, 39, 48)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Chlorophyte, 0f, 0f, 1, new Color(255, 255, 255), 1f); + 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 NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + + frameYOffset = (j % 10) * 180; + frameXOffset = (i % 10) * 468; + } + } +} diff --git a/Walls/EutrophicGlassWall.png b/Walls/EutrophicGlassWall.png new file mode 100644 index 0000000000..983a2380b9 Binary files /dev/null and b/Walls/EutrophicGlassWall.png differ diff --git a/Walls/EutrophicSandWall.cs b/Walls/EutrophicSandWall.cs deleted file mode 100644 index d6b6bb71c2..0000000000 --- a/Walls/EutrophicSandWall.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class EutrophicSandWall : ModWall - { - public override void SetStaticDefaults() - { - DustType = 108; - AddMapEntry(new Color(11, 56, 81)); - } - - public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j].LiquidAmount == 0 && j < Main.maxTilesY - 205) - { - Main.tile[i, j].Get().LiquidType = LiquidID.Water; - Main.tile[i, j].LiquidAmount = byte.MaxValue; - WorldGen.SquareTileFrame(i, j); - if (Main.dedServ) - NetMessage.sendWater(i, j); - } - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/EutrophicSandWall.png b/Walls/EutrophicSandWall.png deleted file mode 100644 index 1e65f4f49e..0000000000 Binary files a/Walls/EutrophicSandWall.png and /dev/null differ diff --git a/Walls/EutrophicSandWallSafe.cs b/Walls/EutrophicSandWallSafe.cs deleted file mode 100644 index 3bfe9329d3..0000000000 --- a/Walls/EutrophicSandWallSafe.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class EutrophicSandWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/EutrophicSandWall"; - public override void SetStaticDefaults() - { - Main.wallHouse[Type] = true; - DustType = 108; - AddMapEntry(new Color(11, 56, 81)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/ExoPlatingWall.cs b/Walls/ExoPlatingWall.cs index 106cfd2689..8c7b250b72 100644 --- a/Walls/ExoPlatingWall.cs +++ b/Walls/ExoPlatingWall.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Walls/GiantHiveWall.cs b/Walls/GiantHiveWall.cs new file mode 100644 index 0000000000..7af1f8f648 --- /dev/null +++ b/Walls/GiantHiveWall.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls +{ + public class GiantHiveWall : MultiVariantModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + + AddMapEntry(new Color(155, 85, 15)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Hive, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 4) * 468; + frameYOffset = (j % 4) * 180; + } + } +} diff --git a/Walls/GiantHiveWall.png b/Walls/GiantHiveWall.png new file mode 100644 index 0000000000..2ea5425a9f Binary files /dev/null and b/Walls/GiantHiveWall.png differ diff --git a/Walls/HardenedAstralSandWall.cs b/Walls/HardenedAstralSandWall.cs index 4766efcb6e..567269b30b 100644 --- a/Walls/HardenedAstralSandWall.cs +++ b/Walls/HardenedAstralSandWall.cs @@ -1,21 +1,19 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("HardenedAstralSandWallSafe")] public class HardenedAstralSandWall : ModWall { - /*public override bool Autoload(ref string name, ref string texture) - { - mod.AddWall("HardenedAstralSandWallUnsafe", this, texture); - return base.Autoload(ref name, ref texture); - }*/ + public override string Texture => "CalamityMod/Walls/HardenedAstralSandWall"; public override void SetStaticDefaults() { // TODO -- Change this dust to be one more befitting Hardened Astral Sand. DustType = DustID.Shadowflame; + Main.wallHouse[Type] = true; WallID.Sets.Conversion.HardenedSand[Type] = true; diff --git a/Walls/HardenedAstralSandWallSafe.cs b/Walls/HardenedAstralSandWallSafe.cs deleted file mode 100644 index f95658aff1..0000000000 --- a/Walls/HardenedAstralSandWallSafe.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Walls -{ - public class HardenedAstralSandWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/HardenedAstralSandWall"; - - public override void SetStaticDefaults() - { - // TODO -- Change this dust to be one more befitting Hardened Astral Sand. - DustType = DustID.Shadowflame; - Main.wallHouse[Type] = true; - - WallID.Sets.Conversion.HardenedSand[Type] = true; - - AddMapEntry(new Color(10, 9, 21)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/HardenedSulphurousSandstoneWall.cs b/Walls/HardenedSulphurousSandstoneWall.cs index 78794f7b6e..fe9228f73e 100644 --- a/Walls/HardenedSulphurousSandstoneWall.cs +++ b/Walls/HardenedSulphurousSandstoneWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls @@ -9,7 +10,7 @@ namespace CalamityMod.Walls public override void SetStaticDefaults() { Main.wallHouse[Type] = true; - DustType = 32; + DustType = DustID.Sand; AddMapEntry(new Color(62, 50, 39)); } diff --git a/Walls/LargeBasaltWall.cs b/Walls/LargeBasaltWall.cs new file mode 100644 index 0000000000..a4afcb1f64 --- /dev/null +++ b/Walls/LargeBasaltWall.cs @@ -0,0 +1,73 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls +{ + public class LargeBasaltWall : MultiVariantModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + + AddMapEntry(new Color(65, 64, 68)); + } + + public override void RandomUpdate(int i, int j) + { + DrainWater(i - 1, j - 1); + DrainWater(i - 1, j); + DrainWater(i - 1, j + 1); + DrainWater(i, j - 1); + DrainWater(i, j); + DrainWater(i, j + 1); + DrainWater(i + 1, j - 1); + DrainWater(i + 1, j); + DrainWater(i + 1, j + 1); + + static void DrainWater(int x, int y) + { + var tile = Main.tile[x, y]; + ref var liquidData = ref tile.Get(); + + if (liquidData.LiquidType != LiquidID.Water || liquidData.Amount == 0) + return; + + liquidData.Amount = 0; + WorldGen.SquareTileFrame(x, y); + + if (Main.dedServ) + NetMessage.sendWater(x, y); + } + + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, DustID.Smoke, 0f, -1.9069767f, 195, new Color(255, 255, 255), 1f)]; + dust.noGravity = false; + dust.fadeIn = 1.4209302f; + } + + public override void PlaceInWorld(int i, int j, Item item) + { + Tile t = Main.tile[i, j]; + if (t.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + t.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Ash, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 4) * 468; + frameYOffset = (j % 4) * 180; + } + } +} diff --git a/Walls/LargeBasaltWall.png b/Walls/LargeBasaltWall.png new file mode 100644 index 0000000000..9ee40d2c04 Binary files /dev/null and b/Walls/LargeBasaltWall.png differ diff --git a/Walls/LimestoneWall.cs b/Walls/LimestoneWall.cs index 2061ef7c8a..f6c40077db 100644 --- a/Walls/LimestoneWall.cs +++ b/Walls/LimestoneWall.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,8 +10,9 @@ namespace CalamityMod.Walls public override void SetStaticDefaults() { - DustType = 22; - this.AddMapEntryWithWaterVisibility(new Color(147, 92, 63)); + DustType = DustID.Pot; + AddMapEntry(new Color(125, 85, 61)); + this.AddMapEntryWithWaterVisibility(new Color(78, 76, 127)); } public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; diff --git a/Walls/NavyslateWall.cs b/Walls/NavyslateWall.cs new file mode 100644 index 0000000000..5010e31098 --- /dev/null +++ b/Walls/NavyslateWall.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; +using Terraria.ID; +namespace CalamityMod.Walls +{ + [LegacyName("EutrophicSandWall")] + public class NavyslateWall : ModWall, IVisibleThroughWater + { + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + DustType = DustID.BlueMoss; + this.AddMapEntryWithWaterVisibility(new Color(11, 40, 43)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/NavyslateWall.png b/Walls/NavyslateWall.png new file mode 100644 index 0000000000..bdeabd6610 Binary files /dev/null and b/Walls/NavyslateWall.png differ diff --git a/Walls/NavystoneWall.cs b/Walls/NavystoneWall.cs index 500df762c1..cc2bda16ff 100644 --- a/Walls/NavystoneWall.cs +++ b/Walls/NavystoneWall.cs @@ -1,15 +1,21 @@ using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Walls { + [LegacyName("NavystoneWallSafe")] public class NavystoneWall : ModWall, IVisibleThroughWater { + public override string Texture => "CalamityMod/Walls/NavystoneWall"; int IVisibleThroughWater.WaterMapEntry { get; set; } - + public override void SetStaticDefaults() { - DustType = 96; - this.AddMapEntryWithWaterVisibility(new Color(16, 45, 48)); + Main.wallHouse[Type] = true; + DustType = DustID.BlueMoss; + 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/NavystoneWall.png b/Walls/NavystoneWall.png index 3c3de52f96..5b79d77914 100644 Binary files a/Walls/NavystoneWall.png and b/Walls/NavystoneWall.png differ diff --git a/Walls/NavystoneWallSafe.cs b/Walls/NavystoneWallSafe.cs deleted file mode 100644 index b2dd4387ad..0000000000 --- a/Walls/NavystoneWallSafe.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class NavystoneWallSafe : ModWall, IVisibleThroughWater - { - public override string Texture => "CalamityMod/Walls/NavystoneWall"; - int IVisibleThroughWater.WaterMapEntry { get; set; } - - public override void SetStaticDefaults() - { - Main.wallHouse[Type] = true; - DustType = 96; - 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/OccultBrickWall.cs b/Walls/OccultBrickWall.cs index a4820ddb85..a95b98431f 100644 --- a/Walls/OccultBrickWall.cs +++ b/Walls/OccultBrickWall.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Walls/PolishedMarniteWall.cs b/Walls/PolishedMarniteWall.cs index de37e28f65..d665867bc5 100644 --- a/Walls/PolishedMarniteWall.cs +++ b/Walls/PolishedMarniteWall.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Placeables.Walls; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Walls/PyreMantleWall.cs b/Walls/PyreMantleWall.cs index 444c1ce81d..f9f0041fd1 100644 --- a/Walls/PyreMantleWall.cs +++ b/Walls/PyreMantleWall.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Walls { public override void SetStaticDefaults() { - DustType = 33; + DustType = DustID.Water; AddMapEntry(new Color(33, 30, 30)); } diff --git a/Walls/PyreMantleWallSafe.cs b/Walls/PyreMantleWallSafe.cs index 59dc08ee04..d368801652 100644 --- a/Walls/PyreMantleWallSafe.cs +++ b/Walls/PyreMantleWallSafe.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; + +using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls @@ -10,7 +12,7 @@ namespace CalamityMod.Walls public override void SetStaticDefaults() { - DustType = 33; + DustType = DustID.Water; Main.wallHouse[Type] = true; AddMapEntry(new Color(33, 30, 30)); } diff --git a/Walls/RoundedAnodizedWulfrumPanelWall.cs b/Walls/RoundedAnodizedWulfrumPanelWall.cs new file mode 100644 index 0000000000..604f75ffc6 --- /dev/null +++ b/Walls/RoundedAnodizedWulfrumPanelWall.cs @@ -0,0 +1,29 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls +{ + public class RoundedAnodizedWulfrumPanelWall : MultiVariantModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + AddMapEntry(new Color(98, 90, 75)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 2) * 468; + frameYOffset = (j % 2) * 180; + } + } +} diff --git a/Walls/RoundedAnodizedWulfrumPanelWall.png b/Walls/RoundedAnodizedWulfrumPanelWall.png new file mode 100644 index 0000000000..3412b5023d Binary files /dev/null and b/Walls/RoundedAnodizedWulfrumPanelWall.png differ diff --git a/Walls/RunestoneTerracottaWall.png b/Walls/RunestoneTerracottaWall.png new file mode 100644 index 0000000000..9a5db46bc6 Binary files /dev/null and b/Walls/RunestoneTerracottaWall.png differ diff --git a/Walls/RunestoneWall.cs b/Walls/RunestoneWall.cs index edf0ea6b50..e49589e3f0 100644 --- a/Walls/RunestoneWall.cs +++ b/Walls/RunestoneWall.cs @@ -1,5 +1,4 @@ -using CalamityMod.Dusts.Furniture; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; diff --git a/Walls/RunestoneWall.png b/Walls/RunestoneWall.png index 9a5db46bc6..cbe470da4c 100644 Binary files a/Walls/RunestoneWall.png and b/Walls/RunestoneWall.png differ diff --git a/Walls/ScarletSeaGrassWall.cs b/Walls/ScarletSeaGrassWall.cs new file mode 100644 index 0000000000..6be76e2d5b --- /dev/null +++ b/Walls/ScarletSeaGrassWall.cs @@ -0,0 +1,48 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; + +namespace CalamityMod.Walls +{ + public class ScarletSeaGrassWall : ModWall, IVisibleThroughWater + { + public static Asset leafTexture = null; + int IVisibleThroughWater.WaterMapEntry { get; set; } + public static Vector2 TileAdj => (Lighting.Mode == Terraria.Graphics.Light.LightMode.Retro || Lighting.Mode == Terraria.Graphics.Light.LightMode.Trippy) ? Vector2.Zero : Vector2.One * 12; + + public override void SetStaticDefaults() + { + DustType = DustID.CrimsonPlants; + + WallID.Sets.Conversion.Grass[Type] = true; + + AddMapEntry(new Color(144, 33, 33)); + this.AddMapEntryWithWaterVisibility(new Color(96, 53, 116)); + if (!Main.dedServ) + { + leafTexture = ModContent.Request("CalamityMod/Walls/ScarletSeaGrassWall_Leaves"); + } + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (i > Main.screenPosition.X / 16 && i < Main.screenPosition.X / 16 + Main.screenWidth / 16 && j > Main.screenPosition.Y / 16 && j < Main.screenPosition.Y / 16 + Main.screenHeight / 16) + { + Texture2D tex = leafTexture.Value; + var rand = new FastRandom(i + (j * 100000)); + + float offset = i * j % 6.28f + rand.NextFloat() / 8f; + float sin = MathF.Sin(Main.GameUpdateCount / 45f + offset); + + spriteBatch.Draw(tex, (new Vector2(i + 0.5f, j + 0.5f) + TileAdj) * 16 + new Vector2(1, 0.5f) * sin * 2.2f - Main.screenPosition, + new Rectangle(rand.Next(4) * 26, 0, 24, 24), Lighting.GetColor(i, j), offset + sin * 0.09f, new Vector2(12, 12), 1 + sin / 14f, 0, 0); + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/ScarletSeaGrassWall.png b/Walls/ScarletSeaGrassWall.png new file mode 100644 index 0000000000..5e0085193a Binary files /dev/null and b/Walls/ScarletSeaGrassWall.png differ diff --git a/Walls/ScarletSeaGrassWall_Leaves.png b/Walls/ScarletSeaGrassWall_Leaves.png new file mode 100644 index 0000000000..4db2083f0f Binary files /dev/null and b/Walls/ScarletSeaGrassWall_Leaves.png differ diff --git a/Walls/ScoriaBrickWall.cs b/Walls/ScoriaBrickWall.cs index cb89daad18..69546f4f6b 100644 --- a/Walls/ScoriaBrickWall.cs +++ b/Walls/ScoriaBrickWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls @@ -11,7 +12,7 @@ namespace CalamityMod.Walls { Main.wallHouse[Type] = true; AddMapEntry(new Color(255, 0, 0)); - DustType = 105; + DustType = DustID.Water_BloodMoon; } public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; diff --git a/Walls/SeaPrismWall.png b/Walls/SeaPrismWall.png new file mode 100644 index 0000000000..5e4988e6b2 Binary files /dev/null and b/Walls/SeaPrismWall.png differ diff --git a/Walls/SeaPrismWall_Blue.png b/Walls/SeaPrismWall_Blue.png new file mode 100644 index 0000000000..63996bc848 Binary files /dev/null and b/Walls/SeaPrismWall_Blue.png differ diff --git a/Walls/SeaPrismWall_Green.png b/Walls/SeaPrismWall_Green.png new file mode 100644 index 0000000000..228fcd2e0b Binary files /dev/null and b/Walls/SeaPrismWall_Green.png differ diff --git a/Walls/SeaPrismWall_Purple.png b/Walls/SeaPrismWall_Purple.png new file mode 100644 index 0000000000..600a9643ff Binary files /dev/null and b/Walls/SeaPrismWall_Purple.png differ diff --git a/Walls/ShellTrimBrickWall.cs b/Walls/ShellTrimBrickWall.cs new file mode 100644 index 0000000000..5647baae11 --- /dev/null +++ b/Walls/ShellTrimBrickWall.cs @@ -0,0 +1,22 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class ShellTrimBrickWall : ModWall, IVisibleThroughWater + { + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + DustType = DustID.CorruptionThorns; + + this.AddMapEntryWithWaterVisibility(new Color(75, 71, 85)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/ShellTrimBrickWall.png b/Walls/ShellTrimBrickWall.png new file mode 100644 index 0000000000..9c121bd0d5 Binary files /dev/null and b/Walls/ShellTrimBrickWall.png differ diff --git a/Walls/ShellstoneSlabWall.cs b/Walls/ShellstoneSlabWall.cs index fdc7a59163..4ee90a26a8 100644 --- a/Walls/ShellstoneSlabWall.cs +++ b/Walls/ShellstoneSlabWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls @@ -11,7 +12,7 @@ namespace CalamityMod.Walls public override void SetStaticDefaults() { Main.wallHouse[Type] = true; - DustType = 24; + DustType = DustID.CorruptionThorns; this.AddMapEntryWithWaterVisibility(new Color(100, 127, 137)); } diff --git a/Walls/ShellstoneSlabWall.png b/Walls/ShellstoneSlabWall.png index 3d6e1f138f..2b2171a158 100644 Binary files a/Walls/ShellstoneSlabWall.png and b/Walls/ShellstoneSlabWall.png differ diff --git a/Walls/ShellstoneWall.cs b/Walls/ShellstoneWall.cs index 89cde319b8..db615c8d5f 100644 --- a/Walls/ShellstoneWall.cs +++ b/Walls/ShellstoneWall.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls @@ -10,8 +11,8 @@ namespace CalamityMod.Walls public override void SetStaticDefaults() { - Main.wallHouse[Type] = false; - DustType = 24; + Main.wallHouse[Type] = true; + DustType = DustID.CorruptionThorns; this.AddMapEntryWithWaterVisibility(new Color(74, 71, 84)); } diff --git a/Walls/SmoothNavystoneWall.png b/Walls/SmoothNavystoneWall.png index 585d059bc8..09aa9344ea 100644 Binary files a/Walls/SmoothNavystoneWall.png and b/Walls/SmoothNavystoneWall.png differ diff --git a/Walls/SulphurousSandWall.cs b/Walls/SulphurousSandWall.cs index 4ea9b6bf5e..21358a967d 100644 --- a/Walls/SulphurousSandWall.cs +++ b/Walls/SulphurousSandWall.cs @@ -5,11 +5,14 @@ using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("SulphurousSandWallSafe")] public class SulphurousSandWall : ModWall { + public override string Texture => "CalamityMod/Walls/SulphurousSandWall"; public override void SetStaticDefaults() { - DustType = 32; + Main.wallHouse[Type] = true; + DustType = DustID.Sand; AddMapEntry(new Color(84, 71, 46)); } diff --git a/Walls/SulphurousSandWallSafe.cs b/Walls/SulphurousSandWallSafe.cs deleted file mode 100644 index e757dc2851..0000000000 --- a/Walls/SulphurousSandWallSafe.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class SulphurousSandWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/SulphurousSandWall"; - public override void SetStaticDefaults() - { - Main.wallHouse[Type] = true; - DustType = 32; - AddMapEntry(new Color(84, 71, 46)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/SulphurousSandstoneWall.cs b/Walls/SulphurousSandstoneWall.cs index 24b9f1da62..21c18ca31e 100644 --- a/Walls/SulphurousSandstoneWall.cs +++ b/Walls/SulphurousSandstoneWall.cs @@ -5,11 +5,14 @@ using Terraria.ModLoader; namespace CalamityMod.Walls { - public class SulphurousSandstoneWall : ModWall + [LegacyName("SulphurousSandstoneWallSafe")] + public class SafeSulphurousSandstoneWall : ModWall { + public override string Texture => "CalamityMod/Walls/SulphurousSandstoneWall"; public override void SetStaticDefaults() { - DustType = 32; + Main.wallHouse[Type] = true; + DustType = DustID.Sand; AddMapEntry(new Color(57, 45, 38)); } diff --git a/Walls/SulphurousSandstoneWallSafe.cs b/Walls/SulphurousSandstoneWallSafe.cs deleted file mode 100644 index 8a7091113c..0000000000 --- a/Walls/SulphurousSandstoneWallSafe.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class SulphurousSandstoneWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/SulphurousSandstoneWall"; - public override void SetStaticDefaults() - { - Main.wallHouse[Type] = true; - DustType = 32; - AddMapEntry(new Color(57, 45, 38)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/SulphurousShaleWall.cs b/Walls/SulphurousShaleWall.cs index a7a9c9e46d..6f2b9bcad1 100644 --- a/Walls/SulphurousShaleWall.cs +++ b/Walls/SulphurousShaleWall.cs @@ -5,11 +5,14 @@ using Terraria.ModLoader; namespace CalamityMod.Walls { + [LegacyName("SulphurousShaleWallSafe")] public class SulphurousShaleWall : ModWall { + public override string Texture => "CalamityMod/Walls/SulphurousShaleWall"; public override void SetStaticDefaults() { - DustType = 32; + Main.wallHouse[Type] = true; + DustType = DustID.Sand; AddMapEntry(new Color(59, 40, 63)); } diff --git a/Walls/SulphurousShaleWallSafe.cs b/Walls/SulphurousShaleWallSafe.cs deleted file mode 100644 index d0e37e5a12..0000000000 --- a/Walls/SulphurousShaleWallSafe.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class SulphurousShaleWallSafe : ModWall - { - public override string Texture => "CalamityMod/Walls/SulphurousShaleWall"; - public override void SetStaticDefaults() - { - Main.wallHouse[Type] = true; - DustType = 32; - AddMapEntry(new Color(59, 40, 63)); - } - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/UnsafeWalls/UnsafeAbyssGravelWall.cs b/Walls/UnsafeWalls/UnsafeAbyssGravelWall.cs new file mode 100644 index 0000000000..85cb005b0f --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeAbyssGravelWall.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + + [LegacyName("AbyssGravelWall")] + public class UnsafeAbyssGravelWall : ModWall + { + public override string Texture => "CalamityMod/Walls/AbyssGravelWall"; + public override void SetStaticDefaults() + { + DustType = DustID.Water; + AddMapEntry(new Color(6, 10, 54)); + } + + public override void RandomUpdate(int i, int j) + { + if (Main.tile[i, j].LiquidAmount == 0 && j < Main.maxTilesY - 205) + { + Main.tile[i, j].Get().LiquidType = LiquidID.Water; + Main.tile[i, j].LiquidAmount = byte.MaxValue; + WorldGen.SquareTileFrame(i, j); + if (Main.dedServ) + NetMessage.sendWater(i, j); + } + } + + public override void KillWall(int i, int j, ref bool fail) => fail = true; + + public override bool CanExplode(int i, int j) => false; + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeAstralDirtWall.cs b/Walls/UnsafeWalls/UnsafeAstralDirtWall.cs new file mode 100644 index 0000000000..3e8494b5f9 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeAstralDirtWall.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeAstralDirtWall : ModWall + { + public override string Texture => "CalamityMod/Walls/AstralDirtWall"; + + public override void SetStaticDefaults() + { + // TODO -- Change this dust to be one more befitting Astral Dirt. + DustType = DustID.Shadowflame; + WallID.Sets.Conversion.Dirt[Type] = true; + AddMapEntry(new Color(26, 22, 32)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeAstralGrassWall.cs b/Walls/UnsafeWalls/UnsafeAstralGrassWall.cs new file mode 100644 index 0000000000..a543900c4e --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeAstralGrassWall.cs @@ -0,0 +1,55 @@ + +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeAstralGrassWall : ModWall + { + public override string Texture => "CalamityMod/Walls/AstralGrassWall"; + public static Asset leafTexture = null; + + public static Vector2 TileAdj => (Lighting.Mode == Terraria.Graphics.Light.LightMode.Retro || Lighting.Mode == Terraria.Graphics.Light.LightMode.Trippy) ? Vector2.Zero : Vector2.One * 12; + /*public override bool Autoload(ref string name, ref string texture) + { + mod.AddWall("AstralGrassWallUnsafe", this, texture); + return base.Autoload(ref name, ref texture); + }*/ + + public override void SetStaticDefaults() + { + // TODO -- Change this dust to be one more befitting Astral Grass. + DustType = DustID.Shadowflame; + + WallID.Sets.Conversion.Grass[Type] = true; + + AddMapEntry(new Color(60, 48, 64)); + + if (!Main.dedServ) + { + leafTexture = ModContent.Request("CalamityMod/Walls/AstralGrassWallLeaves"); + } + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (i > Main.screenPosition.X / 16 && i < Main.screenPosition.X / 16 + Main.screenWidth / 16 && j > Main.screenPosition.Y / 16 && j < Main.screenPosition.Y / 16 + Main.screenHeight / 16) + { + Texture2D tex = leafTexture.Value; + var rand = new FastRandom(i + (j * 100000)); + + float offset = i * j % 6.28f + rand.NextFloat() / 8f; + float sin = MathF.Sin(Main.GameUpdateCount / 45f + offset); + + spriteBatch.Draw(tex, (new Vector2(i + 0.5f, j + 0.5f) + TileAdj) * 16 + new Vector2(1, 0.5f) * sin * 2.2f - Main.screenPosition, + new Rectangle(rand.Next(4) * 26, 0, 24, 24), Lighting.GetColor(i, j), offset + sin * 0.09f, new Vector2(12, 12), 1 + sin / 14f, 0, 0); + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeAstralIceWall.cs b/Walls/UnsafeWalls/UnsafeAstralIceWall.cs new file mode 100644 index 0000000000..cef160b93f --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeAstralIceWall.cs @@ -0,0 +1,20 @@ + +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeAstralIceWall : ModWall + { + public override string Texture => "CalamityMod/Walls/AstralIceWall"; + public override void SetStaticDefaults() + { + // TODO -- Change this dust to be one more befitting Astral Ice. + DustType = DustID.Shadowflame; + WallID.Sets.Conversion.Ice[Type] = true; + AddMapEntry(new Color(83, 76, 92)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeAstralSandstoneWall.cs b/Walls/UnsafeWalls/UnsafeAstralSandstoneWall.cs new file mode 100644 index 0000000000..eaa00bad12 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeAstralSandstoneWall.cs @@ -0,0 +1,22 @@ + +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeAstralSandstoneWall : ModWall + { + public override string Texture => "CalamityMod/Walls/AstralSandstoneWall"; + public override void SetStaticDefaults() + { + // TODO -- Change this dust to be one more befitting Astral Sandstone. + DustType = DustID.Shadowflame; + + WallID.Sets.Conversion.Sandstone[Type] = true; + + AddMapEntry(new Color(29, 38, 49)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeAstralSnowWall.cs b/Walls/UnsafeWalls/UnsafeAstralSnowWall.cs new file mode 100644 index 0000000000..56771bbc1e --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeAstralSnowWall.cs @@ -0,0 +1,19 @@ + +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeAstralSnowWall : ModWall + { + public override string Texture => "CalamityMod/Walls/AstralSnowWall"; + public override void SetStaticDefaults() + { + DustType = ModContent.DustType(); + WallID.Sets.Conversion.Snow[Type] = true; + AddMapEntry(new Color(135, 145, 149)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeAstralStoneWall.cs b/Walls/UnsafeWalls/UnsafeAstralStoneWall.cs new file mode 100644 index 0000000000..3b707574ee --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeAstralStoneWall.cs @@ -0,0 +1,22 @@ + +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeAstralStoneWall : ModWall + { + public override string Texture => "CalamityMod/Walls/AstralStoneWall"; + public override void SetStaticDefaults() + { + // TODO -- Change this dust to be one more befitting Astral Stone. + DustType = DustID.Shadowflame; + + WallID.Sets.Conversion.Stone[Type] = true; + + AddMapEntry(new Color(15, 26, 31)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeBrimstoneSlagWall.cs b/Walls/UnsafeWalls/UnsafeBrimstoneSlagWall.cs new file mode 100644 index 0000000000..a05946e17c --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeBrimstoneSlagWall.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + [LegacyName("BrimstoneSlagWallUnsafe")] + public class UnsafeBrimstoneSlagWall : MultiVariantModWall + { + public override string Texture => "CalamityMod/Walls/BrimstoneSlagWall"; + public override void SetStaticDefaults() + { + AddMapEntry(new Color(24, 16, 29)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.RedTorch, 0f, 0f, 1, new Color(255, 255, 255), 1f); + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Stone, 0f, 0f, 1, new Color(100, 100, 100), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 2) * 468; + frameYOffset = (j % 2) * 180; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeHardenedAstralSandWall.cs b/Walls/UnsafeWalls/UnsafeHardenedAstralSandWall.cs new file mode 100644 index 0000000000..ebf7d57c2b --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeHardenedAstralSandWall.cs @@ -0,0 +1,22 @@ + +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeHardenedAstralSandWall : ModWall + { + public override string Texture => "CalamityMod/Walls/HardenedAstralSandWall"; + public override void SetStaticDefaults() + { + // TODO -- Change this dust to be one more befitting Hardened Astral Sand. + DustType = DustID.Shadowflame; + + WallID.Sets.Conversion.HardenedSand[Type] = true; + + AddMapEntry(new Color(10, 9, 21)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeLargeBasaltWall.cs b/Walls/UnsafeWalls/UnsafeLargeBasaltWall.cs new file mode 100644 index 0000000000..10fb46903d --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeLargeBasaltWall.cs @@ -0,0 +1,78 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeLargeBasaltWall : MultiVariantModWall + { + public override string Texture => "CalamityMod/Walls/LargeBasaltWall"; + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + + AddMapEntry(new Color(65, 64, 68)); + } + + public override void RandomUpdate(int i, int j) + { + DrainWater(i - 1, j - 1); + DrainWater(i - 1, j); + DrainWater(i - 1, j + 1); + DrainWater(i, j - 1); + DrainWater(i, j); + DrainWater(i, j + 1); + DrainWater(i + 1, j - 1); + DrainWater(i + 1, j); + DrainWater(i + 1, j + 1); + + static void DrainWater(int x, int y) + { + var tile = Main.tile[x, y]; + ref var liquidData = ref tile.Get(); + + if (liquidData.LiquidType != LiquidID.Water || liquidData.Amount == 0) + return; + + liquidData.Amount = 0; + WorldGen.SquareTileFrame(x, y); + + if (Main.dedServ) + NetMessage.sendWater(x, y); + } + + Dust dust; + dust = Main.dust[Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, DustID.Smoke, 0f, -1.9069767f, 195, new Color(255, 255, 255), 1f)]; + dust.noGravity = false; + dust.fadeIn = 1.4209302f; + } + + public override void PlaceInWorld(int i, int j, Item item) + { + Tile t = Main.tile[i, j]; + if (t.LiquidType == LiquidID.Water && j < Main.maxTilesY - 205) + { + t.LiquidAmount = 0; + WorldGen.SquareTileFrame(i, j); + } + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.Ash, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 4) * 468; + frameYOffset = (j % 4) * 180; + } + public override bool Drop(int i, int j, ref int type) + { + return false; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeLimestoneWall.cs b/Walls/UnsafeWalls/UnsafeLimestoneWall.cs new file mode 100644 index 0000000000..b9d378c6b7 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeLimestoneWall.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeLimestoneWall : ModWall, IVisibleThroughWater + { + public override string Texture => "CalamityMod/Walls/LimestoneWall"; + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + DustType = DustID.Pot; + AddMapEntry(new Color(125, 85, 61)); + this.AddMapEntryWithWaterVisibility(new Color(78, 76, 127)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + public override bool Drop(int i, int j, ref int type) + { + return false; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeNavyslateWall.cs b/Walls/UnsafeWalls/UnsafeNavyslateWall.cs new file mode 100644 index 0000000000..fee8d76f6f --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeNavyslateWall.cs @@ -0,0 +1,25 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeNavyslateWall : ModWall, IVisibleThroughWater + { + public override string Texture => "CalamityMod/Walls/NavyslateWall"; + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + DustType = DustID.BlueMoss; + this.AddMapEntryWithWaterVisibility(new Color(11, 40, 43)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + public override bool Drop(int i, int j, ref int type) + { + return false; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeNavystoneWall.cs b/Walls/UnsafeWalls/UnsafeNavystoneWall.cs new file mode 100644 index 0000000000..b4d1de8a60 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeNavystoneWall.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; +using Terraria.ID; +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeNavystoneWall : ModWall, IVisibleThroughWater + { + public override string Texture => "CalamityMod/Walls/NavystoneWall"; + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + DustType = DustID.BlueMoss; + this.AddMapEntryWithWaterVisibility(new Color(16, 45, 48)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override bool Drop(int i, int j, ref int type) + { + return false; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeRunestoneWall.cs b/Walls/UnsafeWalls/UnsafeRunestoneWall.cs new file mode 100644 index 0000000000..d43288f376 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeRunestoneWall.cs @@ -0,0 +1,25 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeRunestoneWall : ModWall, IVisibleThroughWater + { + public override string Texture => "CalamityMod/Walls/RunestoneWall"; + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + + this.AddMapEntryWithWaterVisibility(new Color(122, 59, 48)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + public override bool Drop(int i, int j, ref int type) + { + return false; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeScarletSeaGrassWall.cs b/Walls/UnsafeWalls/UnsafeScarletSeaGrassWall.cs new file mode 100644 index 0000000000..d780f36a7e --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeScarletSeaGrassWall.cs @@ -0,0 +1,54 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeScarletSeaGrassWall : ModWall, IVisibleThroughWater + { + public override string Texture => "CalamityMod/Walls/ScarletSeaGrassWall"; + public static Asset leafTexture = null; + int IVisibleThroughWater.WaterMapEntry { get; set; } + public static Vector2 TileAdj => (Lighting.Mode == Terraria.Graphics.Light.LightMode.Retro || Lighting.Mode == Terraria.Graphics.Light.LightMode.Trippy) ? Vector2.Zero : Vector2.One * 12; + + public override void SetStaticDefaults() + { + // 18APR2025: Ozzatron: guessed a red dust for scarlet sea grass + DustType = DustID.CrimsonPlants; + Main.wallHouse[Type] = false; + WallID.Sets.Conversion.Grass[Type] = true; + + AddMapEntry(new Color(144, 33, 33)); + this.AddMapEntryWithWaterVisibility(new Color(96, 53, 116)); + if (!Main.dedServ) + { + leafTexture = ModContent.Request("CalamityMod/Walls/ScarletSeaGrassWall_Leaves"); + } + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (i > Main.screenPosition.X / 16 && i < Main.screenPosition.X / 16 + Main.screenWidth / 16 && j > Main.screenPosition.Y / 16 && j < Main.screenPosition.Y / 16 + Main.screenHeight / 16) + { + Texture2D tex = leafTexture.Value; + var rand = new FastRandom(i + (j * 100000)); + + float offset = i * j % 6.28f + rand.NextFloat() / 8f; + float sin = MathF.Sin(Main.GameUpdateCount / 45f + offset); + + spriteBatch.Draw(tex, (new Vector2(i + 0.5f, j + 0.5f) + TileAdj) * 16 + new Vector2(1, 0.5f) * sin * 2.2f - Main.screenPosition, + new Rectangle(rand.Next(4) * 26, 0, 24, 24), Lighting.GetColor(i, j), offset + sin * 0.09f, new Vector2(12, 12), 1 + sin / 14f, 0, 0); + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + public override bool Drop(int i, int j, ref int type) + { + return false; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeShellstoneWall.cs b/Walls/UnsafeWalls/UnsafeShellstoneWall.cs new file mode 100644 index 0000000000..77c5b81384 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeShellstoneWall.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeShellstoneWall : ModWall, IVisibleThroughWater + { + public override string Texture => "CalamityMod/Walls/ShellstoneWall"; + int IVisibleThroughWater.WaterMapEntry { get; set; } + + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + DustType = DustID.CorruptionThorns; + + this.AddMapEntryWithWaterVisibility(new Color(74, 71, 84)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override bool Drop(int i, int j, ref int type) + { + return false; + } + } +} diff --git a/Walls/UnsafeWalls/UnsafeSulphurousSandWall.cs b/Walls/UnsafeWalls/UnsafeSulphurousSandWall.cs new file mode 100644 index 0000000000..a3bef96417 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeSulphurousSandWall.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeSulphurousSandWall : ModWall + { + public override string Texture => "CalamityMod/Walls/SulphurousSandWall"; + public override void SetStaticDefaults() + { + DustType = DustID.Sand; + AddMapEntry(new Color(84, 71, 46)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeSulphurousSandstoneWall.cs b/Walls/UnsafeWalls/UnsafeSulphurousSandstoneWall.cs new file mode 100644 index 0000000000..8e7cc10213 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeSulphurousSandstoneWall.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + [LegacyName("SulphurousSandstoneWall")] + public class UnsafeSulphurousSandstoneWall : ModWall + { + public override string Texture => "CalamityMod/Walls/SulphurousSandstoneWall"; + public override void SetStaticDefaults() + { + DustType = DustID.Sand; + AddMapEntry(new Color(57, 45, 38)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeSulphurousShaleWall.cs b/Walls/UnsafeWalls/UnsafeSulphurousShaleWall.cs new file mode 100644 index 0000000000..53afcdfc98 --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeSulphurousShaleWall.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + public class UnsafeSulphurousShaleWall : ModWall + { + public override string Texture => "CalamityMod/Walls/SulphurousShaleWall"; + public override void SetStaticDefaults() + { + DustType = DustID.Sand; + AddMapEntry(new Color(59, 40, 63)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/UnsafeWalls/UnsafeVoidstoneWall.cs b/Walls/UnsafeWalls/UnsafeVoidstoneWall.cs new file mode 100644 index 0000000000..5e2e5ef99b --- /dev/null +++ b/Walls/UnsafeWalls/UnsafeVoidstoneWall.cs @@ -0,0 +1,107 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls.UnsafeWalls +{ + [LegacyName("VoidstoneWallUnsafe")] + public class UnsafeVoidstoneWall : ModWall + { + internal static FramedMaskTexture GlowMask; + public override string Texture => "CalamityMod/Walls/VoidstoneWall"; + + public override void SetStaticDefaults() + { + // We basically have same copy in VoidstoneWall + // But leaving this in case of changing to Unsafe variant specific glowmask + GlowMask = new("CalamityMod/Walls/VoidstoneWall_Glowmask", 36, 36); + + DustType = DustID.BlueFlare; + AddMapEntry(new Color(0, 0, 0)); + } + + public override void Unload() + { + GlowMask?.Unload(); + GlowMask = null; + } + + public override void RandomUpdate(int i, int j) + { + if (Main.tile[i, j].LiquidAmount == 0 && j < Main.maxTilesY - 205) + { + Main.tile[i, j].Get().LiquidType = LiquidID.Water; + Main.tile[i, j].LiquidAmount = byte.MaxValue; + WorldGen.SquareTileFrame(i, j); + if (Main.dedServ) + NetMessage.sendWater(i, j); + } + } + + public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch) + { + if (GlowMask.Texture is null) + return; + + Tile tile = Main.tile[i, j]; + int xLength = 32; + int xOff = 0; + + int xPos = tile.WallFrameX + xOff; + int yPos = tile.WallFrameY; + + Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); + Color drawcolor = WorldGen.paintColor(tile.WallColor); + drawcolor.A = 255; + Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); + + if (Main.drawToScreen) + zero = Vector2.Zero; + + Vector2 pos = new Vector2((i * 16 - (int)Main.screenPosition.X), (j * 16 - (int)Main.screenPosition.Y)) + zero; + Color lightColor = Lighting.GetColor(i, j, Color.White); + + spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + + if (GlowMask.HasContentInFramePos(xPos, yPos)) + { + float brightness = 1f; + float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f; + brightness *= (float)MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); + brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); + brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); + brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); + + brightness = MathHelper.Clamp(brightness, 0f, 1f); + Color glowColor = drawcolor *= brightness; + + if (glowColor.R <= 0 && glowColor.G <= 0 && glowColor.B <= 0) + return; + + // For now checking for glowing frames greatly reducing the bottleneck + // But maybe we could squeeze bit more by removing the loop + for (int k = 0; k < 3; k++) + { + Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * (0.2f * k); + spriteBatch.Draw(GlowMask.Texture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + DrawWallGlow(Type, i, j, spriteBatch); + return false; + } + + public override void KillWall(int i, int j, ref bool fail) => fail = true; + + public override bool CanExplode(int i, int j) => false; + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/VoidstoneWall.cs b/Walls/VoidstoneWall.cs index a239873c54..7547e840f8 100644 --- a/Walls/VoidstoneWall.cs +++ b/Walls/VoidstoneWall.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.GameContent; using Terraria.ID; @@ -46,8 +45,7 @@ namespace CalamityMod.Walls int yPos = tile.WallFrameY; Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); - Color drawcolor; - drawcolor = WorldGen.paintColor(tile.WallColor); + Color drawcolor = WorldGen.paintColor(tile.WallColor); drawcolor.A = 255; Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); @@ -67,12 +65,9 @@ namespace CalamityMod.Walls brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - drawcolor *= brightness; - Color glowColor = drawcolor * 0.4f; - if (lightColor.R > glowColor.R) glowColor.R = lightColor.R; - if (lightColor.G > glowColor.G) glowColor.G = lightColor.G; - if (lightColor.B > glowColor.B) glowColor.B = lightColor.B; + brightness = MathHelper.Clamp(brightness, 0f, 1f); + Color glowColor = drawcolor *= brightness; if (glowColor.R <= 0 && glowColor.G <= 0 && glowColor.B <= 0) return; diff --git a/Walls/VoidstoneWallUnsafe _Glowmask.png b/Walls/VoidstoneWallUnsafe _Glowmask.png deleted file mode 100644 index a3f5c24d2b..0000000000 Binary files a/Walls/VoidstoneWallUnsafe _Glowmask.png and /dev/null differ diff --git a/Walls/VoidstoneWallUnsafe.cs b/Walls/VoidstoneWallUnsafe.cs deleted file mode 100644 index 6469477f7c..0000000000 --- a/Walls/VoidstoneWallUnsafe.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Walls -{ - public class VoidstoneWallUnsafe : ModWall - { - internal static FramedMaskTexture GlowMask; - public override string Texture => "CalamityMod/Walls/VoidstoneWall"; - - public override void SetStaticDefaults() - { - // We basically have same copy in VoidstoneWall - // But leaving this in case of changing to Unsafe variant specific glowmask - GlowMask = new("CalamityMod/Walls/VoidstoneWall_Glowmask", 36, 36); - - DustType = 187; - AddMapEntry(new Color(0, 0, 0)); - } - - public override void Unload() - { - GlowMask?.Unload(); - GlowMask = null; - } - - public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j].LiquidAmount == 0 && j < Main.maxTilesY - 205) - { - Main.tile[i, j].Get().LiquidType = LiquidID.Water; - Main.tile[i, j].LiquidAmount = byte.MaxValue; - WorldGen.SquareTileFrame(i, j); - if (Main.dedServ) - NetMessage.sendWater(i, j); - } - } - - public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch) - { - if (GlowMask.Texture is null) - return; - - Tile tile = Main.tile[i, j]; - int xLength = 32; - int xOff = 0; - - int xPos = tile.WallFrameX + xOff; - int yPos = tile.WallFrameY; - - Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); - Color drawcolor; - drawcolor = WorldGen.paintColor(tile.WallColor); - drawcolor.A = 255; - Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); - - if (Main.drawToScreen) - zero = Vector2.Zero; - - Vector2 pos = new Vector2((i * 16 - (int)Main.screenPosition.X), (j * 16 - (int)Main.screenPosition.Y)) + zero; - Color lightColor = Lighting.GetColor(i, j, Color.White); - - spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); - - if (GlowMask.HasContentInFramePos(xPos, yPos)) - { - float brightness = 1f; - float declareThisHereToPreventRunningTheSameCalculationMultipleTimes = Main.GameUpdateCount * 0.007f; - brightness *= (float)MathF.Sin(i / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - drawcolor *= brightness; - Color glowColor = drawcolor * 0.4f; - - if (lightColor.R > glowColor.R) glowColor.R = lightColor.R; - if (lightColor.G > glowColor.G) glowColor.G = lightColor.G; - if (lightColor.B > glowColor.B) glowColor.B = lightColor.B; - - if (glowColor.R <= 0 && glowColor.G <= 0 && glowColor.B <= 0) - return; - - // For now checking for glowing frames greatly reducing the bottleneck - // But maybe we could squeeze bit more by removing the loop - for (int k = 0; k < 3; k++) - { - Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * 0.2f * k; - spriteBatch.Draw(GlowMask.Texture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); - } - } - } - - public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) - { - DrawWallGlow(Type, i, j, spriteBatch); - return false; - } - - public override void KillWall(int i, int j, ref bool fail) => fail = true; - - public override bool CanExplode(int i, int j) => false; - - public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; - } -} diff --git a/Walls/WulfrumComplexPanelWall.cs b/Walls/WulfrumComplexPanelWall.cs new file mode 100644 index 0000000000..602e5dee24 --- /dev/null +++ b/Walls/WulfrumComplexPanelWall.cs @@ -0,0 +1,91 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class WulfrumComplexPanelWall : ModWall + { + internal static FramedMaskTexture GlowMask; + + public override void SetStaticDefaults() + { + GlowMask = new("CalamityMod/Walls/WulfrumComplexPanelWall_Glow", 36, 36); + + Main.wallHouse[Type] = true; + AddMapEntry(new Color(28, 28, 29)); + } + + public override void Unload() + { + GlowMask?.Unload(); + GlowMask = null; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.DungeonSpirit, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch) + { + if (GlowMask.Texture is null) + return; + + Tile tile = Main.tile[i, j]; + int xLength = 32; + int xOff = 0; + + int xPos = tile.WallFrameX + xOff; + int yPos = tile.WallFrameY; + + Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); + Color drawcolor; + drawcolor = WorldGen.paintColor(tile.WallColor); + drawcolor.A = 255; + Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); + + if (Main.drawToScreen) + zero = Vector2.Zero; + + Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; + Color lightColor = Lighting.GetColor(i, j, Color.White); + + spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + + if (GlowMask.HasContentInFramePos(xPos, yPos)) + { + float brightness = MathHelper.Clamp(0.2f - (j / 680), 0f, 0.2f); + + float time = Main.GameUpdateCount; + float waveScale1 = time * 0.064f; + int scalar = i - (j / 2); + float wave1 = waveScale1 * -50 + scalar * 12; + float wave1angle = 0.30f + 0.25f * MathF.Sin(MathHelper.ToRadians(wave1)); + + drawcolor *= brightness; + + float transparency = 0.02f + (wave1angle / 4); + Color glowColor = Color.White * transparency; + + for (int k = 0; k < 3; k++) + { + //Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; + spriteBatch.Draw(GlowMask.Texture, pos + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + DrawWallGlow(Type, i, j, spriteBatch); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/WulfrumComplexPanelWall.png b/Walls/WulfrumComplexPanelWall.png new file mode 100644 index 0000000000..d389733850 Binary files /dev/null and b/Walls/WulfrumComplexPanelWall.png differ diff --git a/Walls/WulfrumComplexPanelWall_Glow.png b/Walls/WulfrumComplexPanelWall_Glow.png new file mode 100644 index 0000000000..21ffc75e16 Binary files /dev/null and b/Walls/WulfrumComplexPanelWall_Glow.png differ diff --git a/Walls/WulfrumEnergyBarrierWall.cs b/Walls/WulfrumEnergyBarrierWall.cs new file mode 100644 index 0000000000..b020f1ada3 --- /dev/null +++ b/Walls/WulfrumEnergyBarrierWall.cs @@ -0,0 +1,107 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class WulfrumEnergyBarrierWall : ModWall + { + internal static FramedMaskTexture GlowMask; + + public override void SetStaticDefaults() + { + GlowMask = new("CalamityMod/Walls/WulfrumEnergyBarrierWallReflect", 36, 36); + + Main.wallHouse[Type] = true; + Main.wallLight[Type] = true; + AddMapEntry(new Color(116, 153, 40)); + } + + public override void Unload() + { + GlowMask?.Unload(); + GlowMask = null; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.DungeonSpirit, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float brightness = 0.9f; + Color lime = new Color(116, 153, 40); + Color green = new Color(46, 97, 56); + Color value = Color.Lerp(lime, green, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(lime, green, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + + r = (value.R + value1.R) / 900f; + g = (value.G + value1.G) / 900f; + b = (value.B + value1.B) / 900f; + r *= brightness; + g *= brightness; + b *= brightness; + } + public static void DrawWallGlow(int wallType, int i, int j, SpriteBatch spriteBatch) + { + if (GlowMask.Texture is null) + return; + + Tile tile = Main.tile[i, j]; + int xLength = 32; + int xOff = 0; + + int xPos = tile.WallFrameX + xOff; + int yPos = tile.WallFrameY; + + Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); + Color drawcolor; + drawcolor = WorldGen.paintColor(tile.WallColor); + drawcolor.A = 255; + Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); + + if (Main.drawToScreen) + zero = Vector2.Zero; + + Vector2 pos = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero; + Color lightColor = Lighting.GetColor(i, j, Color.White); + + spriteBatch.Draw(TextureAssets.Wall[wallType].Value, pos + new Vector2(-8 + xOff, -8), frame, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + + if (GlowMask.HasContentInFramePos(xPos, yPos)) + { + float brightness = MathHelper.Clamp(0.2f - (j / 680), 0f, 0.2f); + + float time = Main.GameUpdateCount; + float waveScale1 = time * 0.064f; + int scalar = i - (j / 2); + float wave1 = waveScale1 * -50 + scalar * 12; + float wave1angle = 0.30f + 0.25f * MathF.Sin(MathHelper.ToRadians(wave1)); + + drawcolor *= brightness; + + float transparency = 0.02f + (wave1angle / 4); + Color glowColor = Color.White * transparency; + + for (int k = 0; k < 3; k++) + { + //Vector2 offset = new Vector2(Main.rand.NextFloat(-1, 1f), Main.rand.NextFloat(-1, 1f)) * 0.2f * k; + spriteBatch.Draw(GlowMask.Texture, pos + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + DrawWallGlow(Type, i, j, spriteBatch); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/WulfrumEnergyBarrierWall.png b/Walls/WulfrumEnergyBarrierWall.png new file mode 100644 index 0000000000..3f5da8222a Binary files /dev/null and b/Walls/WulfrumEnergyBarrierWall.png differ diff --git a/Walls/WulfrumEnergyBarrierWallReflect.png b/Walls/WulfrumEnergyBarrierWallReflect.png new file mode 100644 index 0000000000..55748b217f Binary files /dev/null and b/Walls/WulfrumEnergyBarrierWallReflect.png differ diff --git a/Walls/WulfrumPanelWall.cs b/Walls/WulfrumPanelWall.cs new file mode 100644 index 0000000000..1ac7199110 --- /dev/null +++ b/Walls/WulfrumPanelWall.cs @@ -0,0 +1,29 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls +{ + public class WulfrumPanelWall : MultiVariantModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + AddMapEntry(new Color(53, 67, 54)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 2) * 468; + frameYOffset = (j % 2) * 180; + } + } +} diff --git a/Walls/WulfrumPanelWall.png b/Walls/WulfrumPanelWall.png new file mode 100644 index 0000000000..85f4c847d4 Binary files /dev/null and b/Walls/WulfrumPanelWall.png differ diff --git a/Walls/WulfrumPillar.cs b/Walls/WulfrumPillar.cs new file mode 100644 index 0000000000..ee6324c9da --- /dev/null +++ b/Walls/WulfrumPillar.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class WulfrumPillar : ModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + AddMapEntry(new Color(82, 109, 80)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/WulfrumPillar.png b/Walls/WulfrumPillar.png new file mode 100644 index 0000000000..9a845a9850 Binary files /dev/null and b/Walls/WulfrumPillar.png differ diff --git a/Walls/WulfrumPlatingWall.png b/Walls/WulfrumPlatingWall.png index fb98b5631b..29d0772079 100644 Binary files a/Walls/WulfrumPlatingWall.png and b/Walls/WulfrumPlatingWall.png differ diff --git a/Walls/WulfrumSheetWall.cs b/Walls/WulfrumSheetWall.cs new file mode 100644 index 0000000000..6ebe16c96e --- /dev/null +++ b/Walls/WulfrumSheetWall.cs @@ -0,0 +1,29 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Walls +{ + public class WulfrumSheetWall : MultiVariantModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + AddMapEntry(new Color(73, 59, 48)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void PopulateWallVariant(int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = (i % 2) * 468; + frameYOffset = (j % 2) * 180; + } + } +} diff --git a/Walls/WulfrumSheetWall.png b/Walls/WulfrumSheetWall.png new file mode 100644 index 0000000000..4acc4c0d2b Binary files /dev/null and b/Walls/WulfrumSheetWall.png differ diff --git a/Walls/WulfrumSidingWall.cs b/Walls/WulfrumSidingWall.cs new file mode 100644 index 0000000000..355c128989 --- /dev/null +++ b/Walls/WulfrumSidingWall.cs @@ -0,0 +1,24 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class WulfrumSidingWall : ModWall + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + AddMapEntry(new Color(77, 92, 65)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, DustID.TerraBlade, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/WulfrumSidingWall.png b/Walls/WulfrumSidingWall.png new file mode 100644 index 0000000000..9848731066 Binary files /dev/null and b/Walls/WulfrumSidingWall.png differ diff --git a/Waterfalls/WaterfallRenderer.cs b/Waterfalls/WaterfallRenderer.cs deleted file mode 100644 index ec10d09101..0000000000 --- a/Waterfalls/WaterfallRenderer.cs +++ /dev/null @@ -1,105 +0,0 @@ -using CalamityMod.Graphics.Primitives; -using CalamityMod.Tiles.FloralParadise; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Waterfalls -{ - public static class WaterfallRenderer - { - private static Vector2 currentWaterfallPosition; - - private static float currentWaterfallBrightness; - - private static float currentWaterfallHeight; - - internal static float PrimitiveWidthFunction(float completionRatio) - { - float baseWidth = MathHelper.Lerp(16f, 6f, Utils.GetLerpValue(36f, 216f, currentWaterfallHeight, true)); - float positionOffset = currentWaterfallPosition.X * 0.17f % 300f + currentWaterfallPosition.Y * 0.33f % 300f; - float x1Offset = (float)(Math.Sin(-Main.GlobalTimeWrappedHourly * 3f + completionRatio * 9f + positionOffset) * 0.5f + 0.5f) * baseWidth * 0.2f; - float x2Offset = (float)(Math.Sin(-Main.GlobalTimeWrappedHourly * 6f + completionRatio * 6f + positionOffset) * 0.5f + 0.5f) * baseWidth * 0.25f; - - if (completionRatio < 0.2f) - return MathHelper.SmoothStep(1f, baseWidth + x2Offset - x1Offset, Utils.GetLerpValue(0f, 0.2f, completionRatio, true)); - return baseWidth + x2Offset + MathHelper.SmoothStep(0f, baseWidth * 0.85f, Utils.GetLerpValue(0.84f, 0.96f, completionRatio, true)) - x1Offset; - } - - internal static Color PrimitiveColorFunction(float completionRatio) - { - Color c = Color.Lerp(Color.Cyan, new Color(1f, 1f, 1f, 0f), (float)Math.Pow(Utils.GetLerpValue(0.75f, 1f, completionRatio, true), 0.68)); - return c; - } - - public static IEnumerable FindNearbyWaterfallRenderers() - { - int waterfallGeneratorID = ModContent.TileType(); - Point center = Main.LocalPlayer.Center.ToTileCoordinates(); - for (int i = -Main.screenWidth / 16 - 10; i < Main.screenWidth / 16 + 10; i++) - { - for (int j = -Main.screenHeight / 16 - 10; j < Main.screenHeight / 16 + 10; j++) - { - Tile tile = CalamityUtils.ParanoidTileRetrieval(center.X + i, center.Y + j); - if (tile.TileType != waterfallGeneratorID || !tile.HasTile) - continue; - - yield return new Vector2(center.X + i, center.Y + j); - } - } - } - - public static void DrawWaterfalls() - { - foreach (Vector2 drawTilePosition in FindNearbyWaterfallRenderers()) - { - Vector2 drawPosition = drawTilePosition * 16f; - Vector2 bottom = drawPosition; - for (int i = 0; i < 16; i++) - { - if (CalamityUtils.ParanoidTileRetrieval((int)drawTilePosition.X, (int)drawTilePosition.Y + i).LiquidAmount > 0) - { - bottom.Y += i * 16f; - break; - } - } - - bottom.Y += 4f; - currentWaterfallHeight = MathHelper.Distance(bottom.Y, drawPosition.Y); - if (currentWaterfallHeight <= 20f) - continue; - - currentWaterfallBrightness = Lighting.Brightness((int)(drawPosition.X / 16f), (int)(drawPosition.Y / 16f)); - currentWaterfallPosition = drawPosition + Vector2.One * 8f; - - Vector2[] drawPoints = new Vector2[] - { - drawPosition, - Vector2.Lerp(drawPosition, bottom, 0.5f), - bottom - }; - - // Determine the position of the waterfall's ambience sound. - float distanceFromWaterfall = Main.LocalPlayer.Distance(drawPosition + Vector2.One * 8f); - float distanceFromOldWaterfall = 100000f; - if (Main.ambientWaterfallX != -1f && Main.ambientWaterfallY != -1f) - distanceFromOldWaterfall = Main.LocalPlayer.Distance(new Vector2(Main.ambientWaterfallX, Main.ambientWaterfallY)); - - if (distanceFromOldWaterfall > distanceFromWaterfall) - { - Main.ambientWaterfallX = drawPosition.X + 8f; - Main.ambientWaterfallY = drawPosition.Y + 8f; - Main.ambientWaterfallStrength = MathHelper.Max(Main.ambientWaterfallStrength, Utils.GetLerpValue(740f, 300f, distanceFromWaterfall, true)); - } - - GameShaders.Misc["CalamityMod:Waterfall"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/WorleyNoise")); - GameShaders.Misc["CalamityMod:Waterfall"].UseOpacity((float)Math.Pow(currentWaterfallBrightness, 0.62)); - PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, shader: GameShaders.Misc["CalamityMod:Waterfall"]), 80); - } - } - } -} diff --git a/Waters/AstralWater.cs b/Waters/AstralWater.cs index 1696e5a7c5..734116b473 100644 --- a/Waters/AstralWater.cs +++ b/Waters/AstralWater.cs @@ -1,6 +1,5 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -11,9 +10,9 @@ namespace CalamityMod.Waters { public class AstralWaterflow : ModWaterfallStyle { } - public class AstralWater : CalamityModWaterStyle + public class AstralWater : ModWaterStyle { - public static CalamityModWaterStyle Instance { get; private set; } + public static ModWaterStyle Instance { get; private set; } public static ModWaterfallStyle WaterfallStyle { get; private set; } public static int SplashDust { get; private set; } public static int DropletGore { get; private set; } @@ -39,7 +38,7 @@ namespace CalamityMod.Waters public override int GetSplashDust() => SplashDust; public override int GetDropletGore() => DropletGore; public override Asset GetRainTexture() => RainTexture ??= ModContent.Request("CalamityMod/Waters/AstralRain"); - + public override byte GetRainVariant() => (byte)Main.rand.Next(3); public override Color BiomeHairColor() => new Color(93, 78, 107); } diff --git a/Waters/BasaltGullyLava.cs b/Waters/BasaltGullyLava.cs new file mode 100644 index 0000000000..ba11110a93 --- /dev/null +++ b/Waters/BasaltGullyLava.cs @@ -0,0 +1,26 @@ +using CalamityMod.Dusts.WaterSplash; +using CalamityMod.Gores.WaterDroplet; +using CalamityMod.Systems; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class BasaltGullyLava : ModLavaStyle + { + public override string WaterfallTexture => "CalamityMod/Waters/BasaltGullyLavaflow"; + + public override int GetSplashDust() => ModContent.DustType(); + + public override int GetDropletGore() => ModContent.GoreType(); + + public override bool IsLavaActive() => Main.LocalPlayer.Calamity().ZoneBasaltGully; + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 248f / 255; + g = 73f / 255; + b = 73f / 255; + } + } +} diff --git a/Waters/BasaltGullyLava.png b/Waters/BasaltGullyLava.png new file mode 100644 index 0000000000..489de52258 Binary files /dev/null and b/Waters/BasaltGullyLava.png differ diff --git a/Waters/BasaltGullyLava_Block.png b/Waters/BasaltGullyLava_Block.png new file mode 100644 index 0000000000..6fd6bc9bf5 Binary files /dev/null and b/Waters/BasaltGullyLava_Block.png differ diff --git a/Waters/BasaltGullyLava_Slope.png b/Waters/BasaltGullyLava_Slope.png new file mode 100644 index 0000000000..3f4a9dda65 Binary files /dev/null and b/Waters/BasaltGullyLava_Slope.png differ diff --git a/Waters/BasaltGullyLavaflow.png b/Waters/BasaltGullyLavaflow.png new file mode 100644 index 0000000000..162dcce323 Binary files /dev/null and b/Waters/BasaltGullyLavaflow.png differ diff --git a/Waters/BasaltGullyWater.cs b/Waters/BasaltGullyWater.cs index ffa6cf1762..9b0b2c97af 100644 --- a/Waters/BasaltGullyWater.cs +++ b/Waters/BasaltGullyWater.cs @@ -1,6 +1,6 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Terraria; @@ -9,9 +9,12 @@ using Terraria.ModLoader; namespace CalamityMod.Waters { - public class BasaltGullyWaterflow : ModWaterfallStyle { } + public class BasaltGullyWaterflow : ModWaterfallStyle, IWaterfallStyleModifyColor + { + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, false); + } - public class BasaltGullyWater : CalamityModWaterStyle + public class BasaltGullyWater : ModWaterStyle, IWaterStyleModifyColor, IWaterStyleModifyLight { public static int Type; @@ -19,15 +22,15 @@ namespace CalamityMod.Waters public override void SetStaticDefaults() => Type = Slot; - public override void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) + public void ModifyLight(in Tile tile, int i, int j, ref float r, ref float g, ref float b) { Vector3 outputColor = new Vector3(r, g, b); if (outputColor == Vector3.One || outputColor == new Vector3(0.25f, 0.25f, 0.25f) || outputColor == new Vector3(0.5f, 0.5f, 0.5f)) return; - if (tile.TileType != RustyChestTile.Type) + if (tile.TileType != RustyChestTile.TileType) { - CalamityUtils.SunkenSeaWaterLighting(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); + WaterStyleCommon.ModifySunkenSeaWaterLight(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); } r = outputColor.X; @@ -35,7 +38,7 @@ namespace CalamityMod.Waters b = outputColor.Z; } - public override void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) => ILEditing.ILChanges.SelectSulphuricWaterColor(x, y, ref liquidColor, isSlope); + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, isSlope); public override int ChooseWaterfallStyle() => ModContent.Find("CalamityMod/BasaltGullyWaterflow").Slot; public override int GetSplashDust() => ModContent.DustType(); diff --git a/Waters/CragsLava.cs b/Waters/CragsLava.cs index 3654038bbd..4c9340658c 100644 --- a/Waters/CragsLava.cs +++ b/Waters/CragsLava.cs @@ -1,10 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using CalamityMod.Items.Accessories; using CalamityMod.Systems; -using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; diff --git a/Waters/FloralParadiseWater.cs b/Waters/FloralParadiseWater.cs index 55c3c06ba0..b51b2cbe5c 100644 --- a/Waters/FloralParadiseWater.cs +++ b/Waters/FloralParadiseWater.cs @@ -1,7 +1,4 @@ -using CalamityMod.Systems; -using CalamityMod.Tiles.Abyss; -using Microsoft.Xna.Framework; -using Terraria; +using Microsoft.Xna.Framework; using Terraria.ID; using Terraria.ModLoader; @@ -9,10 +6,10 @@ namespace CalamityMod.Waters { public class FloralParadiseWaterflow : ModWaterfallStyle { } - public class FloralParadiseWater : CalamityModWaterStyle + public class FloralParadiseWater : ModWaterStyle { public static int Type { get; private set; } - public static CalamityModWaterStyle Instance { get; private set; } + public static ModWaterStyle Instance { get; private set; } public override void SetStaticDefaults() { diff --git a/Waters/MiddleAbyssWater.cs b/Waters/MiddleAbyssWater.cs index b44b3c1556..d891c79074 100644 --- a/Waters/MiddleAbyssWater.cs +++ b/Waters/MiddleAbyssWater.cs @@ -1,17 +1,21 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using Microsoft.Xna.Framework; +using Terraria; using Terraria.Graphics; using Terraria.ModLoader; namespace CalamityMod.Waters { - public class MiddleAbyssWaterflow : ModWaterfallStyle { } - - public class MiddleAbyssWater : CalamityModWaterStyle + public class MiddleAbyssWaterflow : ModWaterfallStyle, IWaterfallStyleModifyColor { - public static CalamityModWaterStyle Instance { get; private set; } + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, false); + } + + public class MiddleAbyssWater : ModWaterStyle, IWaterStyleModifyColor + { + public static ModWaterStyle Instance { get; private set; } public static ModWaterfallStyle WaterfallStyle { get; private set; } public static int SplashDust { get; private set; } public static int DropletGore { get; private set; } @@ -36,6 +40,7 @@ namespace CalamityMod.Waters public override int GetSplashDust() => SplashDust; public override int GetDropletGore() => DropletGore; public override Color BiomeHairColor() => new Color(36, 23, 19); - public override void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) => ILEditing.ILChanges.SelectSulphuricWaterColor(x, y, ref liquidColor, isSlope); + + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, isSlope); } } diff --git a/Waters/PissWater.cs b/Waters/PissWater.cs index 7fe16643f5..0afcc87ef6 100644 --- a/Waters/PissWater.cs +++ b/Waters/PissWater.cs @@ -1,7 +1,4 @@ -using CalamityMod.Dusts.WaterSplash; -using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria.ID; using Terraria.ModLoader; diff --git a/Waters/SulphuricDepthsWater.cs b/Waters/SulphuricDepthsWater.cs index 4642b32461..60249e4fe5 100644 --- a/Waters/SulphuricDepthsWater.cs +++ b/Waters/SulphuricDepthsWater.cs @@ -1,22 +1,23 @@ -using CalamityMod.Particles; -using System; -using CalamityMod.Systems; +using CalamityMod.Dusts.WaterSplash; +using CalamityMod.Gores.WaterDroplet; +using CalamityMod.Systems.Graphic.LiquidSystem; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ModLoader; using Terraria.Graphics; -using CalamityMod.Dusts.WaterSplash; -using CalamityMod.Gores.WaterDroplet; +using Terraria.ModLoader; namespace CalamityMod.Waters { - public class SulphuricDepthsWaterflow : ModWaterfallStyle { } + public class SulphuricDepthsWaterflow : ModWaterfallStyle, IWaterfallStyleModifyColor + { + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, false); + } - public class SulphuricDepthsWater : CalamityModWaterStyle + public class SulphuricDepthsWater : ModWaterStyle, IWaterStyleModifyColor, IWaterStyleModifyLight { public static int Type { get; private set; } - public static CalamityModWaterStyle Instance { get; private set; } + public static ModWaterStyle Instance { get; private set; } public static ModWaterfallStyle WaterfallStyle { get; private set; } public static int SplashDust { get; private set; } public static int DropletGore { get; private set; } @@ -43,12 +44,12 @@ namespace CalamityMod.Waters public override int GetSplashDust() => SplashDust; public override int GetDropletGore() => DropletGore; public override Color BiomeHairColor() => new Color(35, 117, 89); - public override void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) => ILEditing.ILChanges.SelectSulphuricWaterColor(x, y, ref liquidColor, isSlope); - public override void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, isSlope); + public void ModifyLight(in Tile tile, int i, int j, ref float r, ref float g, ref float b) { Vector3 outputColor = new Vector3(r, g, b); - if (tile.TileType != RustyChestTile.Type) + if (tile.TileType != RustyChestTile.TileType) { outputColor = Vector3.Lerp(outputColor, Color.MediumSeaGreen.ToVector3(), 0.18f); } diff --git a/Waters/SulphuricWater.cs b/Waters/SulphuricWater.cs index 72135efa68..267115e3f5 100644 --- a/Waters/SulphuricWater.cs +++ b/Waters/SulphuricWater.cs @@ -1,24 +1,26 @@ -using CalamityMod.Particles; -using System; -using CalamityMod.Systems; +using System; +using CalamityMod.Dusts.WaterSplash; +using CalamityMod.Gores.WaterDroplet; +using CalamityMod.Particles; +using CalamityMod.Systems.Graphic.LiquidSystem; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; -using Terraria.ModLoader; using Terraria.Graphics; -using Terraria.ID; -using CalamityMod.Dusts.WaterSplash; -using CalamityMod.Gores.WaterDroplet; +using Terraria.ModLoader; namespace CalamityMod.Waters { - public class SulphuricWaterflow : ModWaterfallStyle { } - - public class SulphuricWater : CalamityModWaterStyle + public class SulphuricWaterflow : ModWaterfallStyle, IWaterfallStyleModifyColor { - public static CalamityModWaterStyle Instance { get; private set; } + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor) => WaterStyleCommon.ModifySulphuricWaterColor(x, y, ref liquidColor, false); + } + + public class SulphuricWater : ModWaterStyle, IWaterStyleModifyColor, IWaterStyleModifyLight, IWaterStylePostDrawEffect + { + public static ModWaterStyle Instance { get; private set; } public static ModWaterfallStyle WaterfallStyle { get; private set; } public static int SplashDust { get; private set; } public static int DropletGore { get; private set; } @@ -45,22 +47,15 @@ namespace CalamityMod.Waters public override int GetSplashDust() => SplashDust; public override int GetDropletGore() => DropletGore; public override Asset GetRainTexture() => RainTexture ??= ModContent.Request("CalamityMod/Waters/SulphuricRain"); - + public override byte GetRainVariant() => (byte)Main.rand.Next(3); public override Color BiomeHairColor() => new Color(43, 168, 110); - public override void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) => ILEditing.ILChanges.SelectSulphuricWaterColor(x, y, ref liquidColor, isSlope); - public override void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope) => WaterStyleCommon.ModifySulphuricWaterColor(x, y, ref liquidColor, isSlope); + public void ModifyLight(in Tile tile, int i, int j, ref float r, ref float g, ref float b) { Vector3 outputColor = new Vector3(r, g, b); - Tile above = CalamityUtils.ParanoidTileRetrieval(i, j - 1); - if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9)) - { - MediumMistParticle acidFoam = new(new(i * 16f + Main.rand.NextFloat(16f), j * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f); - GeneralParticleHandler.SpawnParticle(acidFoam); - } - - if (tile.TileType != RustyChestTile.Type) + if (tile.TileType != RustyChestTile.TileType) { if (Main.dayTime && !Main.raining) { @@ -123,5 +118,15 @@ namespace CalamityMod.Waters g = outputColor.Y; b = outputColor.Z; } + + public void PostDrawEffect(in Tile tile, int x, int y) + { + Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9)) + { + MediumMistParticle acidFoam = new(new(x * 16f + Main.rand.NextFloat(16f), y * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f); + GeneralParticleHandler.SpawnParticle(acidFoam); + } + } } } diff --git a/Waters/SunkenSeaBurrowsWater.cs b/Waters/SunkenSeaBurrowsWater.cs index 25be900b27..c64a56a0f4 100644 --- a/Waters/SunkenSeaBurrowsWater.cs +++ b/Waters/SunkenSeaBurrowsWater.cs @@ -1,6 +1,6 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Terraria; @@ -10,12 +10,12 @@ namespace CalamityMod.Waters { public class SunkenSeaBurrowsWaterflow : ModWaterfallStyle { } - public class SunkenSeaBurrowsWater : CalamityModWaterStyle + public class SunkenSeaBurrowsWater : ModWaterStyle, IWaterStyleModifyLight { private readonly Vector3 WaterGlowColor = new Color(76, 211, 231).ToVector3(); public static int Type { get; private set; } - public static CalamityModWaterStyle Instance { get; private set; } + public static ModWaterStyle Instance { get; private set; } public override void SetStaticDefaults() { @@ -36,13 +36,13 @@ namespace CalamityMod.Waters b = 1.075f; } - public override void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) + public void ModifyLight(in Tile tile, int i, int j, ref float r, ref float g, ref float b) { Vector3 outputColor = new Vector3(r, g, b); - if (tile.TileType != RustyChestTile.Type) + if (tile.TileType != RustyChestTile.TileType) { - CalamityUtils.SunkenSeaWaterLighting(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); + WaterStyleCommon.ModifySunkenSeaWaterLight(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); } r = outputColor.X; diff --git a/Waters/SunkenSeaBurrowsWater.png b/Waters/SunkenSeaBurrowsWater.png index eab9dc5435..b5445b95b0 100644 Binary files a/Waters/SunkenSeaBurrowsWater.png and b/Waters/SunkenSeaBurrowsWater.png differ diff --git a/Waters/SunkenSeaBurrowsWater_Block.png b/Waters/SunkenSeaBurrowsWater_Block.png index 975fbe6dee..55f4835baf 100644 Binary files a/Waters/SunkenSeaBurrowsWater_Block.png and b/Waters/SunkenSeaBurrowsWater_Block.png differ diff --git a/Waters/SunkenSeaBurrowsWater_Slope.png b/Waters/SunkenSeaBurrowsWater_Slope.png index 5598cc77c0..c8c200a00e 100644 Binary files a/Waters/SunkenSeaBurrowsWater_Slope.png and b/Waters/SunkenSeaBurrowsWater_Slope.png differ diff --git a/Waters/SunkenSeaBurrowsWaterflow.png b/Waters/SunkenSeaBurrowsWaterflow.png index 4a4540f32f..7dfa31563c 100644 Binary files a/Waters/SunkenSeaBurrowsWaterflow.png and b/Waters/SunkenSeaBurrowsWaterflow.png differ diff --git a/Waters/SunkenSeaPolypWater.cs b/Waters/SunkenSeaPolypWater.cs index 7967539d7f..104529fcd0 100644 --- a/Waters/SunkenSeaPolypWater.cs +++ b/Waters/SunkenSeaPolypWater.cs @@ -1,6 +1,6 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Terraria; @@ -10,12 +10,12 @@ namespace CalamityMod.Waters { public class SunkenSeaPolypWaterflow : ModWaterfallStyle { } - public class SunkenSeaPolypWater : CalamityModWaterStyle + public class SunkenSeaPolypWater : ModWaterStyle, IWaterStyleModifyLight { private readonly Vector3 WaterGlowColor = new Color(213, 185, 178).ToVector3(); public static int Type { get; private set; } - public static CalamityModWaterStyle Instance { get; private set; } + public static ModWaterStyle Instance { get; private set; } public override void SetStaticDefaults() { @@ -29,13 +29,13 @@ namespace CalamityMod.Waters Instance = null; } - public override void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) + public void ModifyLight(in Tile tile, int i, int j, ref float r, ref float g, ref float b) { Vector3 outputColor = new Vector3(r, g, b); - if (tile.TileType != RustyChestTile.Type) + if (tile.TileType != RustyChestTile.TileType) { - CalamityUtils.SunkenSeaWaterLighting(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); + WaterStyleCommon.ModifySunkenSeaWaterLight(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); } r = outputColor.X; diff --git a/Waters/SunkenSeaPolypWater.png b/Waters/SunkenSeaPolypWater.png index ff90d56704..d49ec9cb77 100644 Binary files a/Waters/SunkenSeaPolypWater.png and b/Waters/SunkenSeaPolypWater.png differ diff --git a/Waters/SunkenSeaPolypWater_Block.png b/Waters/SunkenSeaPolypWater_Block.png index 31eaa237d0..7cb531a45a 100644 Binary files a/Waters/SunkenSeaPolypWater_Block.png and b/Waters/SunkenSeaPolypWater_Block.png differ diff --git a/Waters/SunkenSeaPolypWater_Slope.png b/Waters/SunkenSeaPolypWater_Slope.png index 8c28641b1b..7786b18561 100644 Binary files a/Waters/SunkenSeaPolypWater_Slope.png and b/Waters/SunkenSeaPolypWater_Slope.png differ diff --git a/Waters/SunkenSeaPolypWaterflow.png b/Waters/SunkenSeaPolypWaterflow.png index 7632d15e9a..d1fca985c2 100644 Binary files a/Waters/SunkenSeaPolypWaterflow.png and b/Waters/SunkenSeaPolypWaterflow.png differ diff --git a/Waters/SunkenSeaReefsWater.cs b/Waters/SunkenSeaReefsWater.cs index e0db74851a..229f30f3d8 100644 --- a/Waters/SunkenSeaReefsWater.cs +++ b/Waters/SunkenSeaReefsWater.cs @@ -1,6 +1,6 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Terraria; @@ -10,12 +10,12 @@ namespace CalamityMod.Waters { public class SunkenSeaReefsWaterflow : ModWaterfallStyle { } - public class SunkenSeaReefsWater : CalamityModWaterStyle + public class SunkenSeaReefsWater : ModWaterStyle, IWaterStyleModifyLight { private readonly Vector3 WaterGlowColor = new Color(140, 222, 240).ToVector3(); public static int Type { get; private set; } - public static CalamityModWaterStyle Instance { get; private set; } + public static ModWaterStyle Instance { get; private set; } public override void SetStaticDefaults() { @@ -29,13 +29,13 @@ namespace CalamityMod.Waters Instance = null; } - public override void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) + public void ModifyLight(in Tile tile, int i, int j, ref float r, ref float g, ref float b) { Vector3 outputColor = new Vector3(r, g, b); - if (tile.TileType != RustyChestTile.Type) + if (tile.TileType != RustyChestTile.TileType) { - CalamityUtils.SunkenSeaWaterLighting(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); + WaterStyleCommon.ModifySunkenSeaWaterLight(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); } r = outputColor.X; diff --git a/Waters/SunkenSeaReefsWater.png b/Waters/SunkenSeaReefsWater.png index f698094ba2..62239832c4 100644 Binary files a/Waters/SunkenSeaReefsWater.png and b/Waters/SunkenSeaReefsWater.png differ diff --git a/Waters/SunkenSeaReefsWater_Block.png b/Waters/SunkenSeaReefsWater_Block.png index e2a973a704..f93b5fb6c1 100644 Binary files a/Waters/SunkenSeaReefsWater_Block.png and b/Waters/SunkenSeaReefsWater_Block.png differ diff --git a/Waters/SunkenSeaReefsWater_Slope.png b/Waters/SunkenSeaReefsWater_Slope.png index 694bd626c7..b9fd91405c 100644 Binary files a/Waters/SunkenSeaReefsWater_Slope.png and b/Waters/SunkenSeaReefsWater_Slope.png differ diff --git a/Waters/SunkenSeaReefsWaterflow.png b/Waters/SunkenSeaReefsWaterflow.png index 6e894d833c..18a47b1801 100644 Binary files a/Waters/SunkenSeaReefsWaterflow.png and b/Waters/SunkenSeaReefsWaterflow.png differ diff --git a/Waters/SunkenSeaShoresWater.cs b/Waters/SunkenSeaShoresWater.cs index 032e3322b9..2b8fcefc43 100644 --- a/Waters/SunkenSeaShoresWater.cs +++ b/Waters/SunkenSeaShoresWater.cs @@ -1,6 +1,6 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using CalamityMod.Tiles.Abyss; using Microsoft.Xna.Framework; using Terraria; @@ -10,12 +10,12 @@ namespace CalamityMod.Waters { public class SunkenSeaShoresWaterflow : ModWaterfallStyle { } - public class SunkenSeaShoresWater : CalamityModWaterStyle + public class SunkenSeaShoresWater : ModWaterStyle, IWaterStyleModifyLight { - private readonly Vector3 WaterGlowColor = new Color(140, 222, 239).ToVector3(); + private readonly Vector3 WaterGlowColor = new Color(82, 223, 255).ToVector3(); public static int Type { get; private set; } - public static CalamityModWaterStyle Instance { get; private set; } + public static ModWaterStyle Instance { get; private set; } public override void SetStaticDefaults() { @@ -29,13 +29,13 @@ namespace CalamityMod.Waters Instance = null; } - public override void ModifyLight(ref readonly Tile tile, int i, int j, ref float r, ref float g, ref float b) + public void ModifyLight(in Tile tile, int i, int j, ref float r, ref float g, ref float b) { Vector3 outputColor = new Vector3(r, g, b); - if (tile.TileType != RustyChestTile.Type) + if (tile.TileType != RustyChestTile.TileType) { - CalamityUtils.SunkenSeaWaterLighting(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); + WaterStyleCommon.ModifySunkenSeaWaterLight(i, j, WaterGlowColor, ref outputColor.X, ref outputColor.Y, ref outputColor.Z); } r = outputColor.X; diff --git a/Waters/SunkenSeaShoresWater.png b/Waters/SunkenSeaShoresWater.png index d9ead26b53..3a361affdf 100644 Binary files a/Waters/SunkenSeaShoresWater.png and b/Waters/SunkenSeaShoresWater.png differ diff --git a/Waters/SunkenSeaShoresWater_Block.png b/Waters/SunkenSeaShoresWater_Block.png index c828d653e2..4b0007eecf 100644 Binary files a/Waters/SunkenSeaShoresWater_Block.png and b/Waters/SunkenSeaShoresWater_Block.png differ diff --git a/Waters/SunkenSeaShoresWater_Slope.png b/Waters/SunkenSeaShoresWater_Slope.png index 179eb74a64..cd9bf6cfc6 100644 Binary files a/Waters/SunkenSeaShoresWater_Slope.png and b/Waters/SunkenSeaShoresWater_Slope.png differ diff --git a/Waters/SunkenSeaShoresWaterflow.png b/Waters/SunkenSeaShoresWaterflow.png index 3d605a0e35..7ca2c5df22 100644 Binary files a/Waters/SunkenSeaShoresWaterflow.png and b/Waters/SunkenSeaShoresWaterflow.png differ diff --git a/Waters/UpperAbyssWater.cs b/Waters/UpperAbyssWater.cs index 1b0de8f5fe..8946a23609 100644 --- a/Waters/UpperAbyssWater.cs +++ b/Waters/UpperAbyssWater.cs @@ -1,17 +1,21 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using Microsoft.Xna.Framework; +using Terraria; using Terraria.Graphics; using Terraria.ModLoader; namespace CalamityMod.Waters { - public class UpperAbyssWaterflow : ModWaterfallStyle { } - - public class UpperAbyssWater : CalamityModWaterStyle + public class UpperAbyssWaterflow : ModWaterfallStyle, IWaterfallStyleModifyColor { - public static CalamityModWaterStyle Instance { get; private set; } + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, false); + } + + public class UpperAbyssWater : ModWaterStyle, IWaterStyleModifyColor + { + public static ModWaterStyle Instance { get; private set; } public static ModWaterfallStyle WaterfallStyle { get; private set; } public static int SplashDust { get; private set; } public static int DropletGore { get; private set; } @@ -36,6 +40,6 @@ namespace CalamityMod.Waters public override int GetSplashDust() => SplashDust; public override int GetDropletGore() => DropletGore; public override Color BiomeHairColor() => new Color(9, 69, 82); - public override void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) => ILEditing.ILChanges.SelectSulphuricWaterColor(x, y, ref liquidColor, isSlope); + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, isSlope); } } diff --git a/Waters/VoidWater.cs b/Waters/VoidWater.cs index 153151825a..b18e5f5c4b 100644 --- a/Waters/VoidWater.cs +++ b/Waters/VoidWater.cs @@ -1,17 +1,21 @@ using CalamityMod.Dusts.WaterSplash; using CalamityMod.Gores.WaterDroplet; -using CalamityMod.Systems; +using CalamityMod.Systems.Graphic.LiquidSystem; using Microsoft.Xna.Framework; +using Terraria; using Terraria.Graphics; using Terraria.ModLoader; namespace CalamityMod.Waters { - public class VoidWaterflow : ModWaterfallStyle { } - - public class VoidWater : CalamityModWaterStyle + public class VoidWaterflow : ModWaterfallStyle, IWaterfallStyleModifyColor { - public static CalamityModWaterStyle Instance { get; private set; } + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, false); + } + + public class VoidWater : ModWaterStyle, IWaterStyleModifyColor + { + public static ModWaterStyle Instance { get; private set; } public static ModWaterfallStyle WaterfallStyle { get; private set; } public static int SplashDust { get; private set; } public static int DropletGore { get; private set; } @@ -36,6 +40,6 @@ namespace CalamityMod.Waters public override int GetSplashDust() => SplashDust; public override int GetDropletGore() => DropletGore; public override Color BiomeHairColor() => new Color(16, 8, 30); - public override void DrawColor(int x, int y, ref VertexColors liquidColor, bool isSlope) => ILEditing.ILChanges.SelectSulphuricWaterColor(x, y, ref liquidColor, isSlope); + public void ModifyColor(in Tile tile, int x, int y, ref VertexColors liquidColor, bool isSlope) => WaterStyleCommon.ModifyTransparentWaterColor(x, y, ref liquidColor, isSlope); } } diff --git a/Waters/WaterStyleCommon.cs b/Waters/WaterStyleCommon.cs new file mode 100644 index 0000000000..2d074ffc70 --- /dev/null +++ b/Waters/WaterStyleCommon.cs @@ -0,0 +1,84 @@ +using System; +using System.Linq; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Graphics; + +namespace CalamityMod.Waters; + +internal static class WaterStyleCommon +{ + public static void ModifySulphuricWaterColor(int x, int y, ref VertexColors initialColor, bool isSlope) + { + if (SulphuricWaterSafeZoneSystem.NearbySafeTiles.Count >= 1) + { + Color cleanWaterColor = new(10, 62, 193); + var closestSafeZone = SulphuricWaterSafeZoneSystem.NearbySafeTiles.OrderBy(t => t.Key.ToVector2().DistanceSQ(new(x, y))).First(); + Point closestSafeZonePoint = closestSafeZone.Key; + float closestSafeZoneAmt = closestSafeZone.Value; + float lerpAmt = (1f - closestSafeZoneAmt) * 21f; + + void ModifyColor(Vector2 point, ref Color vertexColor) + { + float distanceToClosest = point.Distance(closestSafeZonePoint.ToVector2()); + float acidicWaterInterpolant = Utils.GetLerpValue(12f, 20.5f, distanceToClosest + lerpAmt, true); + vertexColor = Color.Lerp(cleanWaterColor, vertexColor, acidicWaterInterpolant); + } + + ModifyColor(new(x - 0.5f, y - 0.5f), ref initialColor.TopLeftColor); + ModifyColor(new(x + 0.5f, y - 0.5f), ref initialColor.TopRightColor); + ModifyColor(new(x - 0.5f, y + 0.5f), ref initialColor.BottomLeftColor); + ModifyColor(new(x + 0.5f, y + 0.5f), ref initialColor.BottomRightColor); + } + + ModifyTransparentWaterColor(x, y, ref initialColor, isSlope); + } + + public static void ModifyTransparentWaterColor(int x, int y, ref VertexColors initialColor, bool isSlope) + { + if (isSlope) + { + initialColor.TopLeftColor *= 1f / 3; + initialColor.TopRightColor *= 1f / 3; + initialColor.BottomLeftColor *= 1f / 3; + initialColor.BottomRightColor *= 1f / 3; + } + else + { + initialColor.TopLeftColor *= 0.4f; + initialColor.TopRightColor *= 0.4f; + initialColor.BottomLeftColor *= 0.4f; + initialColor.BottomRightColor *= 0.4f; + } + } + + public static void ModifySunkenSeaWaterLight(int x, int y, Vector3 waterColor, ref float r, ref float g, ref float b) + { + float tick = (float)Main.timeForVisualEffects; + float brightness = MathHelper.Clamp(0.07f, 0f, 0.07f); + float waveScale1 = tick * 0.028f; + float waveScale2 = tick * 0.1f; + int yScale = -y / 2; + int xScale = x / 15; + float wave1 = tick * 0.024f * -50 + ((-x / 30) + (y / 30)) * 25; + float wave2 = waveScale2 * -10 + ((-xScale) + yScale) * 45; + float wave3 = waveScale1 * -100 + ((x / 7) + (y / 50)) * 25; + float wave4 = tick * 0.15f * 10 + ((x / 3) + yScale) * 45; + float wave5 = waveScale1 * -70 + ((-x / 25) + (-y / 25)) * 20; + float wave6 = waveScale2 * -10 + (xScale + yScale) * 45; + float bigwave = tick * 0.01f * -70 + ((-x / 2) + (-y / 40)) * 5; + float wave1angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave1)); + float wave2angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave2)); + float wave3angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave3)); + float wave4angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave4)); + float wave5angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave5)); + float wave6angle = 0.55f + 0.45f * MathF.Sin(MathHelper.ToRadians(wave6)); + float bigwaveangle = 0.55f + 0.80f * MathF.Sin(MathHelper.ToRadians(bigwave)); + float sumofwave = 0.07f + wave1angle + wave2angle + wave3angle + wave4angle + wave5angle + wave6angle + bigwaveangle; + + r = MathHelper.Lerp(r, waterColor.X, sumofwave) * brightness; + g = MathHelper.Lerp(g, waterColor.Y, sumofwave) * brightness; + b = MathHelper.Lerp(b, waterColor.Z, sumofwave) * brightness; + } +} diff --git a/World/Abyss.cs b/World/Abyss.cs index 9bb6d96d14..e36254d037 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using CalamityMod.DataStructures; using CalamityMod.Items.Accessories; using CalamityMod.Items.Pets; using CalamityMod.Items.Tools.ClimateChange; @@ -15,15 +12,12 @@ using CalamityMod.Packets; using CalamityMod.Systems.Collections; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Abyss.AbyssAmbient; -using CalamityMod.Tiles.FurnitureVoid; using CalamityMod.Tiles.Ores; using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent.Generation; using Terraria.ID; -using Terraria.IO; using Terraria.ModLoader; using Terraria.WorldBuilding; @@ -73,7 +67,7 @@ namespace CalamityMod.World if (tile.HasTile) { bool vanillaTile = tile.TileType < TileID.Count; - bool validModdedTile = tile.TileType != ModContent.TileType() && AbyssValidTileReplacementList.Includes(tile.TileType); + bool validModdedTile = tile.TileType != ModContent.TileType() && CalamityTileSets.CanBeReplacedByAbyssGeneration[tile.TileType]; canConvert = vanillaTile || validModdedTile; } @@ -91,13 +85,13 @@ namespace CalamityMod.World if (Y <= rockLayer - (int)((y - 200) * 0.6f)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition else if (Y <= rockLayer - (int)((y - 200) * 0.59f) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3 else if (Y <= rockLayer - (int)((y - 200) * 0.4f)) @@ -115,7 +109,7 @@ namespace CalamityMod.World else if (Y <= rockLayer - (int)((y - 200) * 0.2f)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 1-2 dithering transition else if (Y <= rockLayer - (int)((y - 200) * 0.19f)) @@ -123,19 +117,19 @@ namespace CalamityMod.World if (WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } //layer 1 else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } //basically places smaller clusters everywhere else? @@ -147,13 +141,13 @@ namespace CalamityMod.World if (Y <= rockLayer - (int)((y - 200) * 0.6f)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition else if (Y <= rockLayer - (int)((y - 200) * 0.59f) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3 else if (Y <= rockLayer - (int)((y - 200) * 0.4f)) @@ -171,7 +165,7 @@ namespace CalamityMod.World else if (Y <= rockLayer - (int)((y - 200) * 0.2f)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 1-2 dithering transition else if (Y <= rockLayer - (int)((y - 200) * 0.19f)) @@ -179,19 +173,19 @@ namespace CalamityMod.World if (WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } //layer 1 else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } } @@ -207,13 +201,13 @@ namespace CalamityMod.World if (Y > (rockLayer + y * 0.270)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition else if (Y > (rockLayer + y * 0.268) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3 else if (Y > (rockLayer + y * 0.145)) @@ -233,25 +227,25 @@ namespace CalamityMod.World if (WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } //layer 1 else if (Y <= rockLayer - 10) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 2 (default block for the abyss) else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } //basically places smaller clusters everywhere else? @@ -263,13 +257,13 @@ namespace CalamityMod.World if (Y > (rockLayer + y * 0.270)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition else if (Y > (rockLayer + y * 0.268) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 3 else if (Y > (rockLayer + y * 0.145)) @@ -289,25 +283,25 @@ namespace CalamityMod.World if (WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } //layer 1 else if (Y <= rockLayer - 10) { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } //layer 2 (default block for the abyss) else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } } @@ -558,7 +552,7 @@ namespace CalamityMod.World } } - if (!tile.HasTile && tile.WallType > 0) + if (!tile.HasTile && tile.WallType > WallID.None) { //fill up any air pockets with water tile.Get().LiquidType = LiquidID.Water; @@ -755,7 +749,7 @@ namespace CalamityMod.World } //pots - if ((tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || + if ((tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) && Y > (Main.remixWorld ? rockLayer - (int)((y - 200) * 0.8f) : rockLayer)) { if (WorldGen.genRand.NextBool(5)) @@ -995,7 +989,7 @@ namespace CalamityMod.World while (islandXOffsetPos < islandPositionXAgain) { int islandYOffsetPos = islandPositionY; - while ((!Main.tile[islandXOffsetPos, islandYOffsetPos].HasTile || Main.tile[islandXOffsetPos, islandYOffsetPos].TileType != 0) && islandXOffsetPos < islandPositionXAgain) + while ((!Main.tile[islandXOffsetPos, islandYOffsetPos].HasTile || Main.tile[islandXOffsetPos, islandYOffsetPos].TileType != TileID.Dirt) && islandXOffsetPos < islandPositionXAgain) { islandYOffsetPos--; if (islandYOffsetPos < islandPositionYAgain) @@ -1119,6 +1113,7 @@ namespace CalamityMod.World if (ChestIndex != -1) { Main.chest[ChestIndex].item[0].SetDefaults(itemChoice); + Main.chest[ChestIndex].item[0].Prefix(-1); Main.chest[ChestIndex].item[1].SetDefaults(WorldGen.genRand.Next(Potions1)); Main.chest[ChestIndex].item[1].stack = WorldGen.genRand.Next(1, 3); @@ -1132,7 +1127,7 @@ namespace CalamityMod.World Main.chest[ChestIndex].item[4].SetDefaults(ItemID.ManaPotion); Main.chest[ChestIndex].item[4].stack = WorldGen.genRand.Next(2, 5); - Main.chest[ChestIndex].item[5].SetDefaults(ModContent.ItemType()); + Main.chest[ChestIndex].item[5].SetDefaults(ModContent.ItemType()); Main.chest[ChestIndex].item[5].stack = WorldGen.genRand.Next(3, 12); Main.chest[ChestIndex].item[6].SetDefaults(ItemID.GoldCoin); @@ -1235,12 +1230,12 @@ namespace CalamityMod.World (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), }; - + void getAttachedPoints(int x, int y, List points) { Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); Point p = new(x, y); - + if (!blockTileTypes.Contains(t.TileType) || !t.HasTile || points.Count > 75 || points.Contains(p)) { return; @@ -1292,5 +1287,15 @@ namespace CalamityMod.World } } } + + public static void FillTileWithWater(int i, int j) + { + var tile = Main.tile[i, j]; + if (CalamityTileSets.IsAbyssWall[tile.WallType]) + { + tile.LiquidAmount = 255; + tile.LiquidType = LiquidID.Water; + } + } } } diff --git a/World/AerialiteOreGen.cs b/World/AerialiteOreGen.cs index 9a487be65a..d5d1c54019 100644 --- a/World/AerialiteOreGen.cs +++ b/World/AerialiteOreGen.cs @@ -1,8 +1,6 @@ using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent.Generation; using Terraria.ID; using Terraria.ModLoader; using Terraria.WorldBuilding; @@ -34,7 +32,7 @@ namespace CalamityMod.World // 2. The original tile must not be empty air. // 3. A random dice-roll must land correctly, to ensure that patches of ore are occasional. // If any of these conditions are not met, this loop iteration is skipped. - if (!(tile.TileType == TileID.Cloud || tile.TileType == TileID.LesionBlock || tile.TileType == TileID.FleshBlock) || !tile.HasTile || !WorldGen.genRand.NextBool(CloudOreConversionChance)) + if (!(tile.TileType == TileID.Cloud || ((tile.TileType == TileID.LesionBlock || tile.TileType == TileID.FleshBlock) && WorldGen.remixWorldGen)) || !tile.HasTile || !WorldGen.genRand.NextBool(CloudOreConversionChance)) continue; int radius = (int)(WorldGen.genRand.Next(3, 5) * WorldGen.genRand.NextFloat(0.74f, 0.82f)); diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index 0a9c2e8a49..09ed831084 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -1,13 +1,14 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.Schematics; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Astral; +using CalamityMod.Tiles.FurnitureMonolith; using CalamityMod.Tiles.AstralDesert; using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Ores; using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -138,7 +139,7 @@ namespace CalamityMod.World while (y < Main.maxTilesY) { //check to place the astral meteor on valid tiles, place automatically on ebonstone walls, and avoid platforms - if (((Main.tile[x, y].HasTile && Main.tileSolid[(int)Main.tile[x, y].TileType]) || Main.tile[x, y].WallType == 3) && !TileID.Sets.Platforms[Main.tile[x, y].TileType]) + if (((Main.tile[x, y].HasTile && Main.tileSolid[(int)Main.tile[x, y].TileType]) || Main.tile[x, y].WallType == WallID.EbonstoneUnsafe) && !TileID.Sets.Platforms[Main.tile[x, y].TileType]) { int suitableTiles = 0; int checkRadius = 15; @@ -198,7 +199,7 @@ namespace CalamityMod.World string key = "Mods.CalamityMod.Status.Progression.AstralText"; Color messageColor = Color.Gold; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.BroadcastLocalizedText(key, messageColor); break; } break; @@ -300,7 +301,7 @@ namespace CalamityMod.World { for (int n = j - avoidRectangleSize; n < j + avoidRectangleSize; n++) { - if (Main.tile[m, n].HasTile && Main.tile[m, n].TileType == 21) + if (Main.tile[m, n].HasTile && Main.tile[m, n].TileType == TileID.Containers) { return false; } @@ -360,7 +361,7 @@ namespace CalamityMod.World { if ((double)tileDistance3 < (double)avoidRectangleSize * 0.7) { - if (Main.tile[inc3, doubleinc3].TileType == 5 || Main.tile[inc3, doubleinc3].TileType == 32 || Main.tile[inc3, doubleinc3].TileType == 352) + if (Main.tile[inc3, doubleinc3].TileType == TileID.Trees || Main.tile[inc3, doubleinc3].TileType == TileID.CorruptThorns || Main.tile[inc3, doubleinc3].TileType == TileID.CrimsonThorns) { try { WorldGen.KillTile(inc3, doubleinc3, false, false, true); } @@ -399,7 +400,7 @@ namespace CalamityMod.World { if (Main.tile[inc4, doubleinc4] != null) { - if (Main.tile[inc4, doubleinc4].TileType == 5 || Main.tile[inc4, doubleinc4].TileType == 32 || Main.tile[inc4, doubleinc4].TileType == 352) + if (Main.tile[inc4, doubleinc4].TileType == TileID.Trees || Main.tile[inc4, doubleinc4].TileType == TileID.CorruptThorns || Main.tile[inc4, doubleinc4].TileType == TileID.CrimsonThorns) { WorldGen.KillTile(inc4, doubleinc4, false, false, false); } @@ -424,7 +425,7 @@ namespace CalamityMod.World { if (Main.tile[inc5, doubleinc5] != null) { - if (Main.tile[inc5, doubleinc5].TileType == 5 || Main.tile[inc5, doubleinc5].TileType == 32 || Main.tile[inc5, doubleinc5].TileType == 352) + if (Main.tile[inc5, doubleinc5].TileType == TileID.Trees || Main.tile[inc5, doubleinc5].TileType == TileID.CorruptThorns || Main.tile[inc5, doubleinc5].TileType == TileID.CrimsonThorns) { WorldGen.KillTile(inc5, doubleinc5, false, false, false); } @@ -455,32 +456,250 @@ namespace CalamityMod.World if (j < 181) j = 181; - int xOffset = GenVars.dungeonX < Main.maxTilesX / 2 ? WorldGen.genRand.Next(-100, -50) : WorldGen.genRand.Next(50, 100); + IList AstralTilesToCheckFor = new List(16); + int[] AstralTiles = new int[] + { + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + }; + foreach (int modTile in AstralTiles) + AstralTilesToCheckFor.Add((ushort)modTile); bool altarPlaced = false; + int altarX = i + (GenVars.dungeonX < Main.maxTilesX / 2 ? -50 : 50); + int altarY = j - 5; + + // Variables used for checking both the bottom and top of the potential altar location + int distanceToCheckForAstralTilesX = 40; + int distanceToCheckForAstralTilesY = 10; + int startCheckingX = altarX - 20; + int startCheckingY = altarY + 10; + int startCheckingY2 = altarY - 25; + + // Variables used for checking the bottom of the potential altar location + int astralTilesRequired = 200; + int emptyTilesRequiredToMove = 200; + + // Variables used for checking the top of the potential altar location + int emptyTilesRequired = 200; + + // Whether Magic Storage tiles need to be looked for + bool needsToCheckForMSTiles = magicStorage is not null; + + // Variables used for checking the entire potential altar location for critical tiles like chests, torches, etc. + int distanceToCheckForCriticalTilesX = 40; + int distanceToCheckForCriticalTilesY = 50; + + int attempts = 0; + int maxAttempts = 100000; while (!altarPlaced) { WorldGen.gen = true; - int x = i + xOffset; - int y = j - 100; - - while (!WorldGen.SolidTile(x, y) && y <= Main.worldSurface) + // Check if there are enough Astral tiles on the bottom of the altar's gen location + // 400 tiles checked in total + int astralTileCount = 0; + bool enoughAstralTilesOnBottom = false; + for (int astralTileCheckIndexX = startCheckingX; astralTileCheckIndexX < startCheckingX + distanceToCheckForAstralTilesX; astralTileCheckIndexX++) { - y += 5; + if (enoughAstralTilesOnBottom) + break; + + for (int astralTileCheckIndexY = startCheckingY; astralTileCheckIndexY < startCheckingY + distanceToCheckForAstralTilesY; astralTileCheckIndexY++) + { + if (Main.tile[astralTileCheckIndexX, astralTileCheckIndexY] != null) + { + if (Main.tile[astralTileCheckIndexX, astralTileCheckIndexY].HasTile) + { + if (AstralTilesToCheckFor.Contains(Main.tile[astralTileCheckIndexX, astralTileCheckIndexY].TileType)) + { + astralTileCount++; + if (astralTileCount >= astralTilesRequired) + { + enoughAstralTilesOnBottom = true; + break; + } + } + } + } + } } - if (Main.tile[x, y].HasTile || Main.tile[x, y].WallType > 0 && !TileID.Sets.Torch[Main.tile[x, y].TileType] && !TileID.Sets.IsAContainer[Main.tile[x, y].TileType] - && (magicStorage is not null && MSTilesToAvoid.Contains(Main.tile[x, y].TileType))) //AVOID HOUSES + // Check if there are too many empty tiles on the bottom of the altar's gen location + // 400 tiles checked in total + int emptyTileCount = 0; + bool tooManyEmptyTilesOnBottom = false; + for (int astralTileCheckIndexX = startCheckingX; astralTileCheckIndexX < startCheckingX + distanceToCheckForAstralTilesX; astralTileCheckIndexX++) { + if (tooManyEmptyTilesOnBottom) + break; - bool place = true; - SchematicManager.PlaceSchematic>(SchematicManager.AstralBeaconKey, new Point(x, y - 5), SchematicAnchor.Center, ref place); + for (int astralTileCheckIndexY = startCheckingY; astralTileCheckIndexY < startCheckingY + distanceToCheckForAstralTilesY; astralTileCheckIndexY++) + { + if (Main.tile[astralTileCheckIndexX, astralTileCheckIndexY] == null || !Main.tile[astralTileCheckIndexX, astralTileCheckIndexY].HasTile) + { + emptyTileCount++; + if (emptyTileCount >= emptyTilesRequiredToMove) + { + tooManyEmptyTilesOnBottom = true; + break; + } + } + } + } + + // Check for the number of empty tiles on the top of the altar's gen location + // 800 tiles checked in total + int emptyTileCount2 = 0; + bool enoughEmptyTilesOnTop = false; + for (int emptyTileCheckIndexX = startCheckingX; emptyTileCheckIndexX < startCheckingX + distanceToCheckForAstralTilesX; emptyTileCheckIndexX++) + { + if (enoughEmptyTilesOnTop) + break; + + for (int emptyTileCheckIndexY = startCheckingY2; emptyTileCheckIndexY < startCheckingY2 + distanceToCheckForAstralTilesY; emptyTileCheckIndexY++) + { + if (Main.tile[emptyTileCheckIndexX, emptyTileCheckIndexY] == null || !Main.tile[emptyTileCheckIndexX, emptyTileCheckIndexY].HasTile) + { + emptyTileCount2++; + if (emptyTileCount2 >= emptyTilesRequired) + { + enoughEmptyTilesOnTop = true; + break; + } + } + } + } + + // Check for houses and other critical bullshit + // 2000 tiles checked in total + bool criticalTileDetected = false; + for (int criticalTileCheckIndexX = startCheckingX; criticalTileCheckIndexX < startCheckingX + distanceToCheckForCriticalTilesX; criticalTileCheckIndexX++) + { + if (criticalTileDetected) + break; + + for (int criticalTileCheckIndexY = startCheckingY2; criticalTileCheckIndexY < startCheckingY2 + distanceToCheckForCriticalTilesY; criticalTileCheckIndexY++) + { + if (Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY] != null) + { + if (Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].HasTile) + { + if (needsToCheckForMSTiles) + { + if (TileID.Sets.Clock[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.Paintings[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.InteractibleByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.CanBeSleptIn[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.AvoidedByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.IsAContainer[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + MSTilesToAvoid.Contains(Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType)) + { + criticalTileDetected = true; + break; + } + } + else + { + if (TileID.Sets.Clock[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.Paintings[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.InteractibleByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.CanBeSleptIn[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.AvoidedByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] || + TileID.Sets.IsAContainer[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType]) + { + criticalTileDetected = true; + break; + } + } + } + } + } + } + + bool canPlaceAltar = enoughAstralTilesOnBottom && !tooManyEmptyTilesOnBottom && enoughEmptyTilesOnTop && !criticalTileDetected; + + if (canPlaceAltar) + { + SchematicManager.PlaceSchematic>(SchematicManager.AstralBeaconKey, new Point(altarX, altarY), SchematicAnchor.Center, ref canPlaceAltar); WorldGen.gen = false; altarPlaced = true; } + + // Move the location if the requirements are not met and check again + else + { + altarX += 5; + if (altarX >= i + 150) + altarX -= 300; + + if (!enoughEmptyTilesOnTop) + altarY -= 5; + else if (tooManyEmptyTilesOnBottom) + altarY += 5; + + if (altarY <= Main.worldSurface - 150) + altarY += 150; + else if (altarY >= Main.worldSurface + 150) + altarY -= 150; + + attempts++; + if (attempts >= maxAttempts) + { + // If all else fails, place the fucking thing anyway, by using the original code :^) + int altarX2 = i; + int altarY2 = j - 50; + bool forcedPlacedAltar = false; + while (!forcedPlacedAltar) + { + while (!WorldGen.SolidTile(altarX2, altarY2 + 15) && altarY2 + 15 <= Main.worldSurface) + altarY2 += 5; + + bool canPlaceAltar2 = false; + if (needsToCheckForMSTiles) + { + canPlaceAltar2 = !TileID.Sets.Clock[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.Paintings[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.InteractibleByNPCs[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.CanBeSleptIn[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.AvoidedByNPCs[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.IsAContainer[Main.tile[altarX2, altarY2].TileType] && + !MSTilesToAvoid.Contains(Main.tile[altarX2, altarY2].TileType); + } + else + { + canPlaceAltar2 = !TileID.Sets.Clock[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.Paintings[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.InteractibleByNPCs[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.CanBeSleptIn[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.AvoidedByNPCs[Main.tile[altarX2, altarY2].TileType] && + !TileID.Sets.IsAContainer[Main.tile[altarX2, altarY2].TileType]; + } + + if (canPlaceAltar2) + { + SchematicManager.PlaceSchematic>(SchematicManager.AstralBeaconKey, new Point(altarX2, altarY2), SchematicAnchor.Center, ref canPlaceAltar2); + + WorldGen.gen = false; + + forcedPlacedAltar = true; + altarPlaced = true; + } + } + } + } } } } @@ -555,33 +774,33 @@ namespace CalamityMod.World if (Main.tile[x, y] != null) { - if (wallType != WallID.None && wallType != ModContent.WallType() && wallType != ModContent.WallType() && - wallType != ModContent.WallType() && wallType != ModContent.WallType() && - wallType != ModContent.WallType() && wallType != ModContent.WallType() && - wallType != ModContent.WallType() && wallType != ModContent.WallType() && + if (wallType != WallID.None && wallType != ModContent.WallType() && wallType != ModContent.WallType() && + wallType != ModContent.WallType() && wallType != ModContent.WallType() && + wallType != ModContent.WallType() && wallType != ModContent.WallType() && + wallType != ModContent.WallType() && wallType != ModContent.WallType() && wallType != ModContent.WallType()) { if (WallID.Sets.Conversion.Grass[wallType]) { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); } else if (WallID.Sets.Conversion.HardenedSand[wallType]) { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); } else if (WallID.Sets.Conversion.Sandstone[wallType]) { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); } else if (WallID.Sets.Conversion.Stone[wallType]) { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); } @@ -596,12 +815,12 @@ namespace CalamityMod.World case WallID.DirtUnsafe4: case WallID.Cave6Unsafe: case WallID.Dirt: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); break; case WallID.SnowWallUnsafe: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); break; @@ -611,7 +830,7 @@ namespace CalamityMod.World NetMessage.SendTileSquare(-1, x, y, 1); break; case WallID.IceUnsafe: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); break; @@ -932,295 +1151,6 @@ namespace CalamityMod.World } } - public static void ConvertFromAstral(int startX, int endX, int startY, int endY, ConvertType convert) - { - for (int x = startX; x <= endX; x++) - { - for (int y = startY; y <= endY; y++) - { - ConvertFromAstral(x, y, convert); - } - } - } - - public static void ConvertFromAstral(int x, int y, ConvertType convert, bool tileframe = true) - { - Tile tile = Main.tile[x, y]; - int type = tile.TileType; - int wallType = tile.WallType; - - if (WorldGen.InWorld(x, y, 1)) - { - #region WALL - if (Main.tile[x, y] != null) - { - if (wallType == ModContent.WallType()) - { - Main.tile[x, y].WallType = WallID.DirtUnsafe; - } - else if (wallType == ModContent.WallType() || wallType == ModContent.WallType()) - { - Main.tile[x, y].WallType = WallID.SnowWallUnsafe; - } - else if (wallType == ModContent.WallType()) - { - Main.tile[x, y].WallType = WallID.DesertFossil; - } - else if (wallType == ModContent.WallType()) - { - switch (convert) - { - case ConvertType.Corrupt: - Main.tile[x, y].WallType = WallID.CorruptGrassUnsafe; - break; - case ConvertType.Crimson: - Main.tile[x, y].WallType = WallID.CrimsonGrassUnsafe; - break; - case ConvertType.Hallow: - Main.tile[x, y].WallType = WallID.HallowedGrassUnsafe; - break; - case ConvertType.Pure: - Main.tile[x, y].WallType = WallID.GrassUnsafe; - break; - } - } - else if (wallType == ModContent.WallType()) - { - Main.tile[x, y].WallType = WallID.IceUnsafe; - } - else if (wallType == ModContent.WallType()) - { - Main.tile[x, y].WallType = WallID.LivingWood; - } - else if (wallType == ModContent.WallType()) - { - switch (convert) - { - case ConvertType.Corrupt: - Main.tile[x, y].WallType = WallID.EbonstoneUnsafe; - break; - case ConvertType.Crimson: - Main.tile[x, y].WallType = WallID.CrimstoneUnsafe; - break; - case ConvertType.Hallow: - Main.tile[x, y].WallType = WallID.PearlstoneBrickUnsafe; - break; - case ConvertType.Pure: - Main.tile[x, y].WallType = WallID.Stone; - break; - } - } - } - #endregion - - #region TILE - if (Main.tile[x, y] != null) - { - if (type == ModContent.TileType()) - { - tile.TileType = TileID.Dirt; - } - else if (type == ModContent.TileType()) - { - tile.TileType = TileID.SnowBlock; - } - else if (type == ModContent.TileType()) - { - tile.TileType = TileID.Silt; - } - else if (type == ModContent.TileType()) - { - tile.TileType = TileID.DesertFossil; - } - else if (type == ModContent.TileType()) - { - tile.TileType = TileID.ClayBlock; - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptGrass, TileID.CrimsonGrass, TileID.HallowedGrass, TileID.Grass); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.Ebonstone, TileID.Crimstone, TileID.Pearlstone, TileID.Stone); - } - else if (type == ModContent.TileType()) - { - tile.TileType = TileID.LivingWood; - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.Ebonsand, TileID.Crimsand, TileID.Pearlsand, TileID.Sand); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptSandstone, TileID.CrimsonSandstone, TileID.HallowSandstone, TileID.Sandstone); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptHardenedSand, TileID.CrimsonHardenedSand, TileID.HallowHardenedSand, TileID.HardenedSand); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptIce, TileID.FleshIce, TileID.HallowedIce, TileID.IceBlock); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, ushort.MaxValue, TileID.CrimsonVines, TileID.HallowedVines, TileID.Vines); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptPlants, ushort.MaxValue, TileID.HallowedPlants, TileID.Plants); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, ushort.MaxValue, ushort.MaxValue, TileID.HallowedPlants2, TileID.Plants2); - } - // TODO: All astral medium pile conversions break said tiles. Large and small piles work fine. - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles2, x, y, 540, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 18); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 110, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 378, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 1368, 18); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles2, x, y, 1566, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 1476, 18); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 972, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 1404, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 900, 18); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 648, 0); - } - // TODO: All astral stalactite conversions break said tiles - else if (type == ModContent.TileType() || type == ModContent.TileType()) - { - ushort originType = TileID.Stone; - switch (convert) - { - case ConvertType.Corrupt: - originType = TileID.Ebonstone; - break; - case ConvertType.Crimson: - originType = TileID.Crimstone; - break; - case ConvertType.Hallow: - originType = TileID.Pearlstone; - break; - } - ReplaceAstralStalactite(TileID.Stalactite, originType, x, y); - } - else if (type == ModContent.TileType()) - { - ushort originType = TileID.Sandstone; - switch (convert) - { - case ConvertType.Corrupt: - originType = TileID.CorruptSandstone; - break; - case ConvertType.Crimson: - originType = TileID.CrimsonSandstone; - break; - case ConvertType.Hallow: - originType = TileID.HallowSandstone; - break; - } - ReplaceAstralStalactite(TileID.Stalactite, originType, x, y); - } - else if (type == ModContent.TileType()) - { - ReplaceAstralStalactite(TileID.Stalactite, TileID.IceBlock, x, y); - } - - if (TileID.Sets.Conversion.Grass[type] || type == TileID.Dirt) - { - WorldGen.SquareTileFrame(x, y); - } - } - #endregion - - if (tileframe) - { - if (Main.netMode == NetmodeID.SinglePlayer) - { - WorldGen.SquareTileFrame(x, y, true); - } - else if (Main.dedServ) - { - NetMessage.SendTileSquare(-1, x, y, 1); - } - } - } - } - - public static void SetTileFromConvert(int x, int y, ConvertType convert, ushort corrupt, ushort crimson, ushort hallow, ushort pure) - { - switch (convert) - { - case ConvertType.Corrupt: - if (corrupt != ushort.MaxValue) - { - Main.tile[x, y].TileType = corrupt; - WorldGen.SquareTileFrame(x, y); - } - break; - case ConvertType.Crimson: - if (crimson != ushort.MaxValue) - { - Main.tile[x, y].TileType = crimson; - WorldGen.SquareTileFrame(x, y); - } - break; - case ConvertType.Hallow: - if (hallow != ushort.MaxValue) - { - Main.tile[x, y].TileType = hallow; - WorldGen.SquareTileFrame(x, y); - } - break; - case ConvertType.Pure: - if (pure != ushort.MaxValue) - { - Main.tile[x, y].TileType = pure; - WorldGen.SquareTileFrame(x, y); - } - break; - } - } - public static void RecursiveReplaceToAstral(ushort checkType, ushort replaceType, int x, int y, int replaceTextureWidth, int minFrameX = 0, int maxFrameX = int.MaxValue, int minFrameY = 0, int maxFrameY = int.MaxValue) { Tile tile = Main.tile[x, y]; @@ -1243,26 +1173,6 @@ namespace CalamityMod.World RecursiveReplaceToAstral(checkType, replaceType, x, y + 1, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); } - public static void RecursiveReplaceFromAstral(ushort checkType, ushort replaceType, int x, int y, int addFrameX, int addFrameY) - { - Tile tile = Main.tile[x, y]; - if (tile == null || !tile.HasTile || tile.TileType != checkType) - return; - - Main.tile[x, y].TileType = replaceType; - Main.tile[x, y].TileFrameX += (short)addFrameX; - Main.tile[x, y].TileFrameY += (short)addFrameY; - - if (Main.tile[x - 1, y] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x - 1, y, addFrameX, addFrameY); - if (Main.tile[x + 1, y] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x + 1, y, addFrameX, addFrameY); - if (Main.tile[x, y - 1] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x, y - 1, addFrameX, addFrameY); - if (Main.tile[x, y + 1] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x, y + 1, addFrameX, addFrameY); - } - public static void ReplaceAstralStalactite(ushort replaceType, ushort replaceOriginTile, int x, int y) { Tile tile = Main.tile[x, y]; diff --git a/World/AstralChestGeneration.cs b/World/AstralChestGeneration.cs index e3e5a2faef..3781e96764 100644 --- a/World/AstralChestGeneration.cs +++ b/World/AstralChestGeneration.cs @@ -22,7 +22,7 @@ namespace CalamityMod.World bool invalidHeightData = top >= bottom; if (invalidWidthData || invalidHeightData) { - CalamityMod.Instance.Logger.Warn("The generated dungeon was found to have unusable area bounds. As a result, the astral chest could not be generated."); + CalamityMod.Log.Warn("The generated dungeon was found to have unusable area bounds. As a result, the astral chest could not be generated."); return; } @@ -67,7 +67,7 @@ namespace CalamityMod.World // If a chest was NOT placed, that means that the loop somehow failed. // Log this. else - CalamityMod.Instance.Logger.Warn("The astral chest loop could not find a valid generation location. As a result, it has not generated."); + CalamityMod.Log.Warn("The astral chest loop could not find a valid generation location. As a result, it has not generated."); } } } diff --git a/World/AstralConversion.cs b/World/AstralConversion.cs new file mode 100644 index 0000000000..3543287003 --- /dev/null +++ b/World/AstralConversion.cs @@ -0,0 +1,99 @@ +using CalamityMod.Tiles.Astral; +using CalamityMod.Tiles.AstralDesert; +using CalamityMod.Tiles.AstralSnow; +using CalamityMod.Tiles.FurnitureMonolith; +using CalamityMod.Tiles.Ores; +using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.World +{ + public class AstralConversion : ModBiomeConversion + { + public static int GrassType; + public static int DirtType; + public static int StoneType; + public static int SandType; + public static int SandstoneType; + public static int HardenedSandType; + public static int SnowType; + public static int IceType; + public static int ClayType; + public static int SiltType; + public static int FossilType; + public static int WoodType; + public static int OreType; + + public static int GrassWallType; + public static int DirtWallType; + public static int StoneWallType; + public static int SnowWallType; + public static int IceWallType; + public static int SandstoneWallType; + public static int HardenedSandWallType; + public static int FossilWallType; + public static int WoodWallType; + + public override void PostSetupContent() + { + GrassType = TileType(); + DirtType = TileType(); + StoneType = TileType(); + SnowType = TileType(); + IceType = TileType(); + SandType = TileType(); + SandstoneType = TileType(); + HardenedSandType = TileType(); + ClayType = TileType(); + SiltType = TileType(); + FossilType = TileType(); + WoodType = TileType(); + OreType = TileType(); + + DirtWallType = WallType(); + GrassWallType = WallType(); + StoneWallType = WallType(); + SnowWallType = WallType(); + IceWallType = WallType(); + SandstoneWallType = WallType(); + HardenedSandWallType = WallType(); + FossilWallType = WallType(); + WoodWallType = WallType(); + + TileLoader.RegisterSimpleConversion(TileID.Grass, Type, GrassType); + TileLoader.RegisterSimpleConversion(TileID.Dirt, Type, DirtType); + TileLoader.RegisterSimpleConversion(TileID.Stone, Type, StoneType); + TileLoader.RegisterSimpleConversion(TileID.SnowBlock, Type, SnowType); + TileLoader.RegisterSimpleConversion(TileID.IceBlock, Type, IceType); + TileLoader.RegisterSimpleConversion(TileID.Sand, Type, SandType); + TileLoader.RegisterSimpleConversion(TileID.Sandstone, Type, SandstoneType); + TileLoader.RegisterSimpleConversion(TileID.HardenedSand, Type, HardenedSandType); + TileLoader.RegisterSimpleConversion(TileID.ClayBlock, Type, ClayType); + TileLoader.RegisterSimpleConversion(TileID.Silt, Type, SiltType); + TileLoader.RegisterSimpleConversion(TileID.DesertFossil, Type, FossilType); + TileLoader.RegisterSimpleConversion(TileID.LivingWood, Type, WoodType); + TileLoader.RegisterSimpleConversion(TileID.Meteorite, Type, OreType); + + WallLoader.RegisterSimpleConversion(WallID.GrassUnsafe, Type, GrassWallType); + WallLoader.RegisterSimpleConversion(WallID.DirtUnsafe, Type, DirtWallType); + WallLoader.RegisterSimpleConversion(WallID.Stone, Type, StoneWallType); + WallLoader.RegisterSimpleConversion(WallID.SnowWallUnsafe, Type, SnowWallType); + WallLoader.RegisterSimpleConversion(WallID.IceUnsafe, Type, IceWallType); + WallLoader.RegisterSimpleConversion(WallID.Sandstone, Type, SandstoneWallType); + WallLoader.RegisterSimpleConversion(WallID.HardenedSand, Type, HardenedSandWallType); + WallLoader.RegisterSimpleConversion(WallID.DesertFossil, Type, FossilWallType); + WallLoader.RegisterSimpleConversion(WallID.LivingWoodUnsafe, Type, WoodWallType); + + // Evil solutions cleanse back certain common/abundant Astral tiles + TileLoader.RegisterConversion(DirtType, BiomeConversionID.Corruption, TileID.Dirt); + TileLoader.RegisterConversion(DirtType, BiomeConversionID.Crimson, TileID.Dirt); + TileLoader.RegisterConversion(DirtType, BiomeConversionID.Hallow, TileID.Dirt); + TileLoader.RegisterConversion(SnowType, BiomeConversionID.Corruption, TileID.SnowBlock); + TileLoader.RegisterConversion(SnowType, BiomeConversionID.Crimson, TileID.SnowBlock); + TileLoader.RegisterConversion(SnowType, BiomeConversionID.Hallow, TileID.SnowBlock); + } + } +} diff --git a/World/BrimstoneCrag.cs b/World/BrimstoneCrag.cs index 11024b1055..611b17cbc0 100644 --- a/World/BrimstoneCrag.cs +++ b/World/BrimstoneCrag.cs @@ -1,23 +1,19 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.Schematics; using CalamityMod.Tiles.Crags; using CalamityMod.Tiles.Crags.Lily; using CalamityMod.Tiles.Crags.Spike; using CalamityMod.Tiles.Crags.Tree; using CalamityMod.Tiles.Ores; -using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.GameContent.Generation; using Terraria.ID; -using Terraria.IO; using Terraria.ModLoader; using Terraria.Utilities; using Terraria.WorldBuilding; -using static CalamityMod.Schematics.SchematicManager; namespace CalamityMod.World { @@ -56,8 +52,10 @@ namespace CalamityMod.World { for (int y = Main.maxTilesY - 90; y <= Main.maxTilesY - 5; y++) { - WorldGen.PlaceTile(x, y, (ushort)ModContent.TileType()); - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + Tile tile = Main.tile[x, y]; + tile.TileType = (ushort)ModContent.TileType(); + tile.HasTile = true; + tile.WallType = (ushort)ModContent.WallType(); } } @@ -144,7 +142,7 @@ namespace CalamityMod.World //place more walls behind slag so theres not just a box of walls from the initial rectangle if (tile.HasTile && tileDown.HasTile && tileDown2.HasTile && Main.tile[x, y + 5].HasTile) { - Main.tile[x, y + 5].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y + 5].WallType = (ushort)ModContent.WallType(); } if (tile.LiquidType == LiquidID.Water && tile.LiquidAmount > 0) @@ -292,7 +290,7 @@ namespace CalamityMod.World Tile lavaTile = Main.tile[i, j]; Tile lavaTileDown = Main.tile[i, j + 1]; - if (lavaTile.WallType == 0 && lavaTileDown.WallType == 0) + if (lavaTile.WallType == WallID.None && lavaTileDown.WallType == WallID.None) { lavaTile.LiquidAmount = 0; } @@ -529,6 +527,7 @@ namespace CalamityMod.World else { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 6439becdb8..8a789c3fd0 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -1,5 +1,4 @@ -using System.Reflection; -using CalamityMod.Items.Tools.ClimateChange; +using CalamityMod.Items.Tools.ClimateChange; using CalamityMod.NPCs.ExoMechs; using CalamityMod.NPCs.ExoMechs.Apollo; using CalamityMod.NPCs.ExoMechs.Ares; @@ -7,11 +6,10 @@ using CalamityMod.NPCs.ExoMechs.Artemis; using CalamityMod.NPCs.ExoMechs.Thanatos; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; +using Terraria.GameContent.Creative; using Terraria.GameContent.Events; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Utilities; namespace CalamityMod.World { @@ -32,11 +30,6 @@ namespace CalamityMod.World /// Worlds created before the Draedon Update will not lock specific Draedon's Arsenal recipes behind Schematics. /// public static bool IsWorldAfterDraedonUpdate = false; - /// - /// Stores the pre-Hardmode ore types that this world generated with.
- /// Is not actually used for any world gen tasks, and is only used to change the item sprite of the Suspicious Scrap item. - ///
- public static ushort[] OreTypes = new ushort[4]; // Modes /// If true, the world is in Revengeance Mode. @@ -52,13 +45,24 @@ namespace CalamityMod.World /// Evaluates to whether vanilla's "Legendary Mode" is enabled (Master Mode on For the Worthy). public static bool LegendaryMode => Main.getGoodWorld && ReflectMasterMode(); + /// + /// Evaluates to whether "Malice Mode" is enabled (Death Mode on For the Worthy).
+ /// Note that the effects of this difficulty are unaffiliated with the removed Malice Mode. + ///
+ public static bool MaliceMode => Main.getGoodWorld && ReflectMasterMode() && revenge; + // FTW automatically bumps difficulties up and has no proper check for Master since a world generated in Expert Mode will be classified as Master // Therefore gotta reflect! public static bool ReflectMasterMode() { - FieldInfo findInfo = typeof(Main).GetField("_currentGameModeInfo", BindingFlags.Static | BindingFlags.NonPublic); - GameModeData data = (GameModeData)findInfo.GetValue(null); - return data.IsMasterMode; + if (Main.GameModeInfo.IsJourneyMode) + { + CreativePowers.DifficultySliderPower power = CreativePowerManager.Instance.GetPower(); + float level = power._sliderCurrentValueCache; + return level == 1f; + } + + return Main._currentGameModeInfo.IsMasterMode; } // Sunken Sea @@ -73,8 +77,6 @@ namespace CalamityMod.World /// If true, the Bandit has lived in this world. Used to ensure their spawn condition is not required on subsequent respawns. public static bool spawnedBandit = false; - /// If true, the Drunk Princess has lived in this world. Used to ensure her spawn condition is not required on subsequent respawns. - public static bool spawnedCirrus = false; /// If true, the Archmage has lived in a house in this world. Solely used as a condition for dialogue. public static bool foundHomePermafrost = false; diff --git a/World/CustomTemple.cs b/World/CustomTemple.cs index 80be98c84b..c2ff85acb2 100644 --- a/World/CustomTemple.cs +++ b/World/CustomTemple.cs @@ -28,7 +28,7 @@ namespace CalamityMod.World if (Main.remixWorld) { - while (Main.tile[x, y].HasTile || Main.tile[x, y].WallType > 0 || y > (int)(Main.worldSurface - 5.0)) + while (Main.tile[x, y].HasTile || Main.tile[x, y].WallType > WallID.None || y > (int)(Main.worldSurface - 5.0)) { y--; } @@ -491,7 +491,7 @@ namespace CalamityMod.World int roomToFillIndex = WorldGen.genRand.Next(totalRooms); int randomPointInRoomX = WorldGen.genRand.Next(roomBounds[roomToFillIndex].X, roomBounds[roomToFillIndex].X + roomBounds[roomToFillIndex].Width); int randomPointInRoomY = WorldGen.genRand.Next(roomBounds[roomToFillIndex].Y, roomBounds[roomToFillIndex].Y + roomBounds[roomToFillIndex].Height); - if (Main.tile[randomPointInRoomX, randomPointInRoomY].WallType == 87 && !Main.tile[randomPointInRoomX, randomPointInRoomY].HasTile) + if (Main.tile[randomPointInRoomX, randomPointInRoomY].WallType == WallID.LihzahrdBrickUnsafe && !Main.tile[randomPointInRoomX, randomPointInRoomY].HasTile) { bool successPlacingSpikes = false; if (WorldGen.genRand.NextBool(2)) @@ -509,7 +509,7 @@ namespace CalamityMod.World { for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) { - if (Main.tile[dx, dy].HasTile && Main.tile[dx, dy].TileType == 10) + if (Main.tile[dx, dy].HasTile && Main.tile[dx, dy].TileType == TileID.ClosedDoor) { noDoorInWay = false; break; @@ -566,7 +566,7 @@ namespace CalamityMod.World { for (int dy = randomPointInRoomY - areaToCheck; dy < randomPointInRoomY + areaToCheck; dy++) { - if (Main.tile[dx, dy].HasTile && Main.tile[dx, dy].TileType == 10) + if (Main.tile[dx, dy].HasTile && Main.tile[dx, dy].TileType == TileID.ClosedDoor) { noDoorInWay = false; break; diff --git a/World/CustomUnderworld.cs b/World/CustomUnderworld.cs new file mode 100644 index 0000000000..182cc05cd1 --- /dev/null +++ b/World/CustomUnderworld.cs @@ -0,0 +1,2037 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Schematics; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent.Generation; +using Terraria.ID; +using Terraria.WorldBuilding; +using static CalamityMod.Schematics.SchematicManager; + +namespace CalamityMod.World +{ + public class CustomUnderworld + { + // Ash island variables + private const double AshIslandGenStart = 0.36; + private const double AshIslandGenStart_Remix = 0.38; + private const double AshIslandGenEnd = 0.64; + private const double AshIslandGenEnd_Remix = 0.62; + private const int AshIslandDepthMaxAboveTheUnderworldFloor = 135; + private const int AshIslandHeightMaxAboveTheUnderworldFloor = 160; + private const int MaxIslands = 8; + private const int SmallWorldIslands = 4; + private const int MediumWorldIslands = 6; + private const int LargeWorldIslands = MaxIslands; + private const int SmallWorldOuterIslands = 1; + private const int MediumAndLargeWorldOuterIslands = 2; + + // Wall variables + private const int MaxWallHeight = 68; + private const int RandomizedWallSectionHeight = 4; + private const int MaxWallDepthAboveUnderworldFloor = 40; + + public static void NewUnderworld() + { + // Generate lower Underworld ash + int ashMin = 160; + int ashMax = 190; + int ashDepth = Main.maxTilesY - WorldGen.genRand.Next(ashMin, ashMax); + for (int x = 0; x < Main.maxTilesX; x++) + { + ashDepth += WorldGen.genRand.Next(-3, 4); + if (ashDepth < Main.maxTilesY - ashMax) + ashDepth = Main.maxTilesY - ashMax; + + if (ashDepth > Main.maxTilesY - ashMin) + ashDepth = Main.maxTilesY - ashMin; + + for (int y = ashDepth - 20 - WorldGen.genRand.Next(3); y < Main.maxTilesY; y++) + { + if (y >= ashDepth) + { + Main.tile[x, y].Get().HasTile = false; + Main.tile[x, y].Get().LiquidType = LiquidID.Water; + } + else + Main.tile[x, y].TileType = TileID.Ash; + } + } + + // Generate lava + int lavaMin = 80; + int lavaMax = 90; + int lavaDepth = Main.maxTilesY - WorldGen.genRand.Next(lavaMin, lavaMax + 1); + int lavaMaxDepth = Main.maxTilesY - lavaMin; + int lavaMaxHeight = Main.maxTilesY - lavaMax; + for (int x = 10; x < Main.maxTilesX - 10; x++) + { + lavaDepth += WorldGen.genRand.Next(-5, 6); + if (lavaDepth > lavaMaxDepth) + lavaDepth = lavaMaxDepth; + + if (lavaDepth < lavaMaxHeight) + lavaDepth = lavaMaxHeight; + + for (int y = lavaDepth; y < Main.maxTilesY - 10; y++) + { + if (!Main.tile[x, y].HasTile) + { + Main.tile[x, y].Get().LiquidType = LiquidID.Lava; + Main.tile[x, y].LiquidAmount = byte.MaxValue; + } + } + } + + // Ash splotches + for (int x = 0; x < Main.maxTilesX; x++) + { + if (WorldGen.genRand.NextBool(50)) + { + int y = Main.maxTilesY - 65; + while (!Main.tile[x, y].HasTile && y > Main.maxTilesY - 135) + y--; + + WorldGen.TileRunner(WorldGen.genRand.Next(Main.maxTilesX), y + WorldGen.genRand.Next(20, 50), WorldGen.genRand.Next(15, 20), 1000, TileID.Ash, addTile: true, 0D, WorldGen.genRand.Next(1, 3), noYChange: true); + } + } + + // Some cursed water function + Liquid.QuickWater(-2); + + // More Ash splotches + for (int x = 0; x < Main.maxTilesX; x++) + { + if (WorldGen.genRand.NextBool(13)) + { + int y = Main.maxTilesY - 65; + while ((Main.tile[x, y].LiquidAmount > 0 || Main.tile[x, y].HasTile) && y > Main.maxTilesY - 140) + y--; + + if (WorldGen.genRand.NextBool(3) || !(x > Main.maxTilesX * 0.4) || !(x < Main.maxTilesX * 0.6)) + WorldGen.TileRunner(x, y - WorldGen.genRand.Next(2, 5), WorldGen.genRand.Next(5, 30), 1000, TileID.Ash, addTile: true, 0D, WorldGen.genRand.Next(1, 3), noYChange: true); + + double ashSplotchSizeAdjustment = WorldGen.genRand.Next(1, 3); + if (WorldGen.genRand.NextBool(3)) + ashSplotchSizeAdjustment *= 0.5; + + if (WorldGen.genRand.NextBool(3) || !(x > Main.maxTilesX * 0.4) || !(x < Main.maxTilesX * 0.6)) + { + if (WorldGen.genRand.NextBool(2)) + WorldGen.TileRunner(x, y - WorldGen.genRand.Next(2, 5), (int)(WorldGen.genRand.Next(5, 15) * ashSplotchSizeAdjustment), (int)(WorldGen.genRand.Next(10, 15) * ashSplotchSizeAdjustment), TileID.Ash, addTile: true, 1D, 0.3); + + if (WorldGen.genRand.NextBool(2)) + { + ashSplotchSizeAdjustment = WorldGen.genRand.Next(1, 3); + WorldGen.TileRunner(x, y - WorldGen.genRand.Next(2, 5), (int)(WorldGen.genRand.Next(5, 15) * ashSplotchSizeAdjustment), (int)(WorldGen.genRand.Next(10, 15) * ashSplotchSizeAdjustment), TileID.Ash, addTile: true, -1D, 0.3); + } + } + + WorldGen.TileRunner(x + WorldGen.genRand.Next(-10, 10), y + WorldGen.genRand.Next(-10, 10), WorldGen.genRand.Next(5, 15), WorldGen.genRand.Next(5, 10), -2, addTile: false, WorldGen.genRand.Next(-1, 3), WorldGen.genRand.Next(-1, 3)); + if (WorldGen.genRand.NextBool(3)) + WorldGen.TileRunner(x + WorldGen.genRand.Next(-10, 10), y + WorldGen.genRand.Next(-10, 10), WorldGen.genRand.Next(10, 30), WorldGen.genRand.Next(10, 20), -2, addTile: false, WorldGen.genRand.Next(-1, 3), WorldGen.genRand.Next(-1, 3)); + + if (WorldGen.genRand.NextBool(5)) + WorldGen.TileRunner(x + WorldGen.genRand.Next(-15, 15), y + WorldGen.genRand.Next(-15, 10), WorldGen.genRand.Next(15, 30), WorldGen.genRand.Next(5, 20), -2, addTile: false, WorldGen.genRand.Next(-1, 3), WorldGen.genRand.Next(-1, 3)); + } + } + + // Cursed lava placement tile runner, thanks redigit + for (int i = 0; i < Main.maxTilesX; i++) + WorldGen.TileRunner(WorldGen.genRand.Next(20, Main.maxTilesX - 20), WorldGen.genRand.Next(Main.maxTilesY - 180, Main.maxTilesY - 10), WorldGen.genRand.Next(2, 7), WorldGen.genRand.Next(2, 7), -2); + + // Another cursed lava placement tile runner...seriously, why the fuck is this? + for (int i = 0; i < Main.maxTilesX * 2; i++) + WorldGen.TileRunner(WorldGen.genRand.Next((int)(Main.maxTilesX * 0.35), (int)(Main.maxTilesX * 0.65)), WorldGen.genRand.Next(Main.maxTilesY - 180, Main.maxTilesY - 10), WorldGen.genRand.Next(5, 20), WorldGen.genRand.Next(5, 10), -2); + + // Place two lines of lava at maxTilesY - 145 and maxTilesY - 144 + if (Main.zenithWorld) + { + for (int x = 0; x < Main.maxTilesX; x++) + { + if (!Main.tile[x, Main.maxTilesY - 145].HasTile) + { + Main.tile[x, Main.maxTilesY - 145].LiquidAmount = byte.MaxValue; + Main.tile[x, Main.maxTilesY - 145].Get().LiquidType = LiquidID.Lava; + } + + if (!Main.tile[x, Main.maxTilesY - 144].HasTile) + { + Main.tile[x, Main.maxTilesY - 144].LiquidAmount = byte.MaxValue; + Main.tile[x, Main.maxTilesY - 144].Get().LiquidType = LiquidID.Lava; + } + } + } + + // Place hellstone splotches + for (int i = 0; i < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0008); i++) + WorldGen.TileRunner(WorldGen.genRand.Next(Main.maxTilesX), WorldGen.genRand.Next(Main.maxTilesY - 140, Main.maxTilesY), WorldGen.genRand.Next(2, 7), WorldGen.genRand.Next(3, 7), TileID.Hellstone); + + // Remix world stuff, the Ash islands in the middle + + // Start generating islands at this point + int ashIslandX = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenStart_Remix : AshIslandGenStart)); + + // Stop generating islands at this point + int ashIslandX2 = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenEnd_Remix : AshIslandGenEnd)); + + // Ash island gen limits + int ashIslandDepthLimit = Main.maxTilesY - AshIslandDepthMaxAboveTheUnderworldFloor; + int ashIslandHeightLimit = Main.maxTilesY - AshIslandHeightMaxAboveTheUnderworldFloor; + + // Multiple islands in non-remix + if (!WorldGen.remixWorldGen) + { + // Large = 8, Medium = 6, Small = 4 + int numIslands = (int)(Main.maxTilesX / 4200f * 4f); + bool smallWorld = numIslands == SmallWorldIslands; + + // Total extra distance between islands for lava lakes + int totalExtraDistanceBetweenAshIslands = (int)((double)Main.maxTilesX * 0.04); + + // Extra distance per island + // Due to this being done on both sides of each island, it is divided by 2 + int extraDistanceBetweenAshIslands_PerIslandSide = totalExtraDistanceBetweenAshIslands / numIslands / 2; + + // Calculate distance between islands + int distanceBetweenIslands = (ashIslandX2 - ashIslandX) / numIslands; + + // Used for island height randomization + int minHeightForOuterIslands = 8; + int[] randomHeightAdjustmentLimits = new int[MaxIslands] + { + 28, + 24, + 20, + 16, + 12, + 8, + 4, + 0 + }; + + // Used for island edge drop off randomization + // Taller islands have steeper drop offs + // This is also used to decrease the width of the islands + int minDropOffForOuterIslands = 11; + int[] randomDropOffAdjustmentLimits = new int[MaxIslands] + { + 3, + 4, + 5, + 7, + 9, + 11, + 15, + 19 + }; + + // Loop to gen the islands + int chosenIslandSize; + int previouslyChosenIslandSize = -1; + for (int i = 0; i < numIslands; i++) + { + // Do not repeat the same island size twice in a row + do chosenIslandSize = WorldGen.genRand.Next(MaxIslands); + while (previouslyChosenIslandSize == chosenIslandSize); + previouslyChosenIslandSize = chosenIslandSize; + + int randomizedIslandDropOffAdjustment = randomDropOffAdjustmentLimits[chosenIslandSize]; + int randomizedIslandHeightAdjustment = randomHeightAdjustmentLimits[chosenIslandSize]; + + // Islands on the edges are taller in order to have more structures + bool isTallerIsland = smallWorld ? (i == 0 || i == numIslands - SmallWorldOuterIslands) : (i < MediumAndLargeWorldOuterIslands || i >= numIslands - MediumAndLargeWorldOuterIslands); + if (isTallerIsland && randomizedIslandHeightAdjustment > minHeightForOuterIslands) + { + randomizedIslandHeightAdjustment = minHeightForOuterIslands; + randomizedIslandDropOffAdjustment = minDropOffForOuterIslands; + } + + int randomizedAshIslandDepthLimit = ashIslandDepthLimit + randomizedIslandHeightAdjustment; + int randomizedAshIslandHeightLimit = ashIslandHeightLimit + randomizedIslandHeightAdjustment; + + int ashIslandXAdjustment = distanceBetweenIslands * i; + int ashIslandX2Adjustment = distanceBetweenIslands * (numIslands - i - 1); + + // Decrease the width of each island randomly + // Taller islands have a greater reduction in width + int randomWidthReduction_LeftSide = WorldGen.genRand.Next(11) + (randomizedIslandDropOffAdjustment - 4); + int randomWidthReduction_RightSide = WorldGen.genRand.Next(11) + (randomizedIslandDropOffAdjustment - 4); + int ashIslandTilePlacementX = ashIslandX + ashIslandXAdjustment + extraDistanceBetweenAshIslands_PerIslandSide + randomWidthReduction_LeftSide; + int ashIslandTilePlacementX2 = ashIslandX2 - ashIslandX2Adjustment - extraDistanceBetweenAshIslands_PerIslandSide - randomWidthReduction_RightSide; + int ashIslandGenLimiter = Main.maxTilesY - 1; + bool ashIslandGenLimitHit = false; + Liquid.QuickWater(-2); + for (; ashIslandGenLimiter < Main.maxTilesY - 1 || ashIslandTilePlacementX < ashIslandTilePlacementX2; ashIslandTilePlacementX++) + { + // Less random ash island terrain to make unmodified traversal less annoying + if (!ashIslandGenLimitHit) + { + // Steeper ash island edges + ashIslandGenLimiter -= WorldGen.genRand.Next(1, randomizedIslandDropOffAdjustment); + if (ashIslandGenLimiter < randomizedAshIslandDepthLimit) + ashIslandGenLimitHit = true; + } + else if (ashIslandTilePlacementX >= ashIslandTilePlacementX2) + { + // Steeper ash island edges + ashIslandGenLimiter += WorldGen.genRand.Next(1, randomizedIslandDropOffAdjustment); + if (ashIslandGenLimiter > Main.maxTilesY - 1) + ashIslandGenLimiter = Main.maxTilesY - 1; + } + else + { + if ((ashIslandTilePlacementX <= Main.maxTilesX / 2 - 5 || ashIslandTilePlacementX >= Main.maxTilesX / 2 + 5) && WorldGen.genRand.NextBool(4)) + { + // More randomized terrain depending on island type + // Lower islands have smoother terrain + // Islands on the edges have smoother terrain + if (isTallerIsland) + { + if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(8)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + } + else + { + switch (chosenIslandSize) + { + default: + case 0: + case 1: + if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(8)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + break; + + case 2: + case 3: + if (WorldGen.genRand.NextBool(3)) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(6)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + else if (WorldGen.genRand.NextBool(9)) + ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); + break; + + case 4: + case 5: + if (WorldGen.genRand.NextBool()) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + else if (WorldGen.genRand.NextBool(6)) + ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); + break; + + case 6: + case 7: + if (WorldGen.genRand.NextBool()) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(3)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + else if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); + break; + } + } + } + + if (ashIslandGenLimiter < randomizedAshIslandHeightLimit) + ashIslandGenLimiter = randomizedAshIslandHeightLimit; + + if (ashIslandGenLimiter > randomizedAshIslandDepthLimit) + ashIslandGenLimiter = randomizedAshIslandDepthLimit; + } + + for (int y = ashIslandGenLimiter; y > ashIslandGenLimiter - 10; y--) + Main.tile[ashIslandTilePlacementX, y].LiquidAmount = 0; + + for (int y = ashIslandGenLimiter; y < Main.maxTilesY; y++) + { + Main.tile[ashIslandTilePlacementX, y].Clear(TileDataType.All); + Main.tile[ashIslandTilePlacementX, y].Get().HasTile = true; + Main.tile[ashIslandTilePlacementX, y].TileType = TileID.Ash; + } + } + + // This is necessary due to earlier calculations + int startX = ashIslandX + ashIslandXAdjustment + extraDistanceBetweenAshIslands_PerIslandSide + randomWidthReduction_LeftSide; + int endX = ashIslandTilePlacementX2 + extraDistanceBetweenAshIslands_PerIslandSide * 2; + + // Small holes + double holeFrequency = 0.00005 / numIslands; + for (int j = 0; j < (int)((double)(Main.maxTilesX * Main.maxTilesY) * holeFrequency); j++) + WorldGen.TileRunner(WorldGen.genRand.Next(startX, endX), WorldGen.genRand.Next(randomizedAshIslandHeightLimit + 30, Main.maxTilesY), WorldGen.genRand.Next(4, 7), WorldGen.genRand.Next(4, 7), -2); + + // Place smaller hellstone splotches in the ash island + // I don't want there to be too many here because I don't want to encourage players to destroy the environmental Wall of Flesh arena + double hellstoneFrequency = 0.0002 / numIslands; + for (int j = 0; j < (int)((double)(Main.maxTilesX * Main.maxTilesY) * hellstoneFrequency); j++) + WorldGen.TileRunner(WorldGen.genRand.Next(startX, endX), WorldGen.genRand.Next(randomizedAshIslandHeightLimit, Main.maxTilesY), WorldGen.genRand.Next(1, 5), WorldGen.genRand.Next(2, 5), TileID.Hellstone); + } + } + else + { + int ashIslandTilePlacementX = ashIslandX; + int ashIslandTilePlacementX2 = ashIslandX2; + int ashIslandGenLimiter = Main.maxTilesY - 1; + bool ashIslandGenLimitHit = false; + Liquid.QuickWater(-2); + for (; ashIslandGenLimiter < Main.maxTilesY - 1 || ashIslandTilePlacementX < ashIslandTilePlacementX2; ashIslandTilePlacementX++) + { + // Less random ash island terrain to make unmodified traversal less annoying + if (!ashIslandGenLimitHit) + { + // Steeper ash island edges + ashIslandGenLimiter -= WorldGen.genRand.Next(1, 4); + if (ashIslandGenLimiter < ashIslandDepthLimit) + ashIslandGenLimitHit = true; + } + else if (ashIslandTilePlacementX >= ashIslandTilePlacementX2) + { + // Steeper ash island edges + ashIslandGenLimiter += WorldGen.genRand.Next(1, 4); + if (ashIslandGenLimiter > Main.maxTilesY - 1) + ashIslandGenLimiter = Main.maxTilesY - 1; + } + else + { + if ((ashIslandTilePlacementX <= Main.maxTilesX / 2 - 5 || ashIslandTilePlacementX >= Main.maxTilesX / 2 + 5) && WorldGen.genRand.NextBool(4)) + { + if (WorldGen.genRand.NextBool(3)) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(6)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + else if (WorldGen.genRand.NextBool(8)) + ashIslandGenLimiter += WorldGen.genRand.Next(-4, 5); + } + + if (ashIslandGenLimiter < ashIslandHeightLimit) + ashIslandGenLimiter = ashIslandHeightLimit; + + if (ashIslandGenLimiter > ashIslandDepthLimit) + ashIslandGenLimiter = ashIslandDepthLimit; + } + + for (int y = ashIslandGenLimiter; y > ashIslandGenLimiter - 10; y--) + Main.tile[ashIslandTilePlacementX, y].LiquidAmount = 0; + + for (int y = ashIslandGenLimiter; y < Main.maxTilesY; y++) + { + Main.tile[ashIslandTilePlacementX, y].Clear(TileDataType.All); + Main.tile[ashIslandTilePlacementX, y].Get().HasTile = true; + Main.tile[ashIslandTilePlacementX, y].TileType = TileID.Ash; + } + } + } + + // Generate a line of background walls from the approximate underworld lava line and down + int maxWallHeight = MaxWallHeight; + int randomizedWallSectionsHeight = RandomizedWallSectionHeight; + int maxWallTypes = 4; + int newWallTypeStart = maxWallHeight / maxWallTypes; + int maxWallDepth = Main.maxTilesY - MaxWallDepthAboveUnderworldFloor; + int smoulderingStoneWallStartDepth = maxWallDepth - maxWallHeight; + int cinderWallStartDepth = smoulderingStoneWallStartDepth + newWallTypeStart; + int emberWallStartDepth = cinderWallStartDepth + newWallTypeStart; + int magmaWallStartDepth = emberWallStartDepth + newWallTypeStart; + for (int x = 0; x < Main.maxTilesX; x++) + { + for (int y = smoulderingStoneWallStartDepth; y < maxWallDepth; y++) + { + if (y < smoulderingStoneWallStartDepth + randomizedWallSectionsHeight) + { + switch (smoulderingStoneWallStartDepth + randomizedWallSectionsHeight - y) + { + case 4: + if (WorldGen.genRand.NextBool(5)) + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + + case 3: + if (WorldGen.genRand.NextBool(3)) + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + + case 2: + if (WorldGen.genRand.NextBool()) + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + + case 1: + if (WorldGen.genRand.Next(4) > 0) + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + } + } + else if (y < cinderWallStartDepth) + { + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + } + else if (y < cinderWallStartDepth + randomizedWallSectionsHeight) + { + switch (cinderWallStartDepth + randomizedWallSectionsHeight - y) + { + case 4: + if (WorldGen.genRand.NextBool(5)) + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + + case 3: + if (WorldGen.genRand.NextBool(3)) + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + + case 2: + if (WorldGen.genRand.NextBool()) + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + + case 1: + if (WorldGen.genRand.Next(4) > 0) + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + break; + } + } + else if (y < emberWallStartDepth) + { + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + } + else if (y < emberWallStartDepth + randomizedWallSectionsHeight) + { + switch (emberWallStartDepth + randomizedWallSectionsHeight - y) + { + case 4: + if (WorldGen.genRand.NextBool(5)) + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + break; + + case 3: + if (WorldGen.genRand.NextBool(3)) + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + break; + + case 2: + if (WorldGen.genRand.NextBool()) + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + break; + + case 1: + if (WorldGen.genRand.Next(4) > 0) + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe2; + break; + } + } + else if (y < magmaWallStartDepth) + { + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + } + else if (y < magmaWallStartDepth + randomizedWallSectionsHeight) + { + switch (magmaWallStartDepth + randomizedWallSectionsHeight - y) + { + case 4: + if (WorldGen.genRand.NextBool(5)) + Main.tile[x, y].WallType = WallID.LavaUnsafe3; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + break; + + case 3: + if (WorldGen.genRand.NextBool(3)) + Main.tile[x, y].WallType = WallID.LavaUnsafe3; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + break; + + case 2: + if (WorldGen.genRand.NextBool()) + Main.tile[x, y].WallType = WallID.LavaUnsafe3; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + break; + + case 1: + if (WorldGen.genRand.Next(4) > 0) + Main.tile[x, y].WallType = WallID.LavaUnsafe3; + else + Main.tile[x, y].WallType = WallID.LavaUnsafe1; + break; + } + } + else + Main.tile[x, y].WallType = WallID.LavaUnsafe3; + } + } + + // Generate background walls in underworld tiles from Main.maxTilesY - 200 and down + for (int x = 0; x < Main.maxTilesX; x++) + { + for (int y = Main.maxTilesY - 200; y <= smoulderingStoneWallStartDepth + randomizedWallSectionsHeight; y++) + { + // The placed wall must be surrounded by non-sloped, non-half brick full tiles, otherwise it won't look right + bool surroundedByFullTiles = false; + bool breakLoop = false; + + int indexStartX = x - 1; + if (indexStartX < 0) + indexStartX = 0; + + int indexEndX = x + 1; + if (indexEndX > Main.maxTilesX) + indexEndX = Main.maxTilesX; + + for (int surroundingTileIndexX = indexStartX; surroundingTileIndexX <= indexEndX; surroundingTileIndexX++) + { + if (breakLoop) + break; + + for (int surroundingTileIndexY = y - 1; surroundingTileIndexY <= y + 1; surroundingTileIndexY++) + { + if (Main.tile[surroundingTileIndexX, surroundingTileIndexY].HasTile && + !Main.tile[surroundingTileIndexX, surroundingTileIndexY].IsHalfBlock && + Main.tile[surroundingTileIndexX, surroundingTileIndexY].Slope == SlopeType.Solid) + { + surroundedByFullTiles = true; + } + else + { + surroundedByFullTiles = false; + breakLoop = true; + break; + } + } + } + + if (surroundedByFullTiles) + Main.tile[x, y].WallType = WallID.LavaUnsafe4; + } + } + + // More cursed magic water function + Liquid.QuickWater(-2); + + // Create grass on ash + for (int x = ashIslandX; x < ashIslandX2 + 15; x++) + { + for (int y = Main.maxTilesY - 300; y < ashIslandDepthLimit + 30; y++) + { + Main.tile[x, y].LiquidAmount = 0; + + if (Main.tile[x, y].TileType == TileID.Ash && Main.tile[x, y].HasTile && + (!Main.tile[x - 1, y - 1].HasTile || !Main.tile[x, y - 1].HasTile || + !Main.tile[x + 1, y - 1].HasTile || !Main.tile[x - 1, y].HasTile || + !Main.tile[x + 1, y].HasTile || !Main.tile[x - 1, y + 1].HasTile || + !Main.tile[x, y + 1].HasTile || !Main.tile[x + 1, y + 1].HasTile)) + Main.tile[x, y].TileType = TileID.AshGrass; + } + } + + // Obsidian and hellstone towers... + AddHellHouses(); + } + + public static void NewUnderworldStructures() + { + if (!WorldGen.remixWorldGen) + { + // Generate some structures on the ash islands + int ashIslandX = (int)((double)Main.maxTilesX * AshIslandGenStart); + int ashIslandX2 = (int)((double)Main.maxTilesX * AshIslandGenEnd); + bool cragsLocationIsLeft = GenVars.dungeonLocation < Main.maxTilesX / 2; + int ashIslandDepthLimit = Main.maxTilesY - AshIslandDepthMaxAboveTheUnderworldFloor; + int ashIslandHeightLimit = Main.maxTilesY - AshIslandHeightMaxAboveTheUnderworldFloor; + + // Keep track of world size to adjust house distances + float houseDistanceMult = Main.maxTilesX / 4200f; + + // Large = 8, Medium = 6, Small = 4 + int numIslands = (int)(Main.maxTilesX / 4200f * 4f); + + // Small and medium worlds get less structures + bool smallWorld = numIslands == SmallWorldIslands; + bool mediumWorld = numIslands == MediumWorldIslands; + bool largeWorld = numIslands == LargeWorldIslands; + + // Total extra distance between islands for lava lakes + int totalExtraDistanceBetweenAshIslands = (int)((double)Main.maxTilesX * 0.04); + + // Extra distance per island + // The right side looks better with half of this adjustment subtracted + int divisor = cragsLocationIsLeft ? 2 : 4; + int extraDistanceBetweenAshIslands_PerIslandSide = totalExtraDistanceBetweenAshIslands / numIslands / divisor; + + // Calculate distance between islands + int sideAdjustmentMultiplier = cragsLocationIsLeft ? 1 : -1; + int distanceBetweenStructures = (ashIslandX2 - ashIslandX) / numIslands; + int firstIslandWidth = distanceBetweenStructures + (extraDistanceBetweenAshIslands_PerIslandSide * sideAdjustmentMultiplier); + int firstStructureDistanceFromIslandEdge = firstIslandWidth / 2; + int distanceBetweenStructures_AfterFirstIsland = distanceBetweenStructures; + + // Pick an atrium type + // Small worlds get a random single atrium + // Medium and large worlds get a guaranteed shadow chest atrium and another random non-shadow chest atrium + string atriumMapKey; + int atriumType = smallWorld ? WorldGen.genRand.Next(3) : WorldGen.genRand.Next(2); + int numAtriums = smallWorld ? 1 : 2; + if (!smallWorld) + { + switch (atriumType) + { + default: + case 0: + atriumMapKey = BrimstoneAtriumType1Key; + break; + + case 1: + atriumMapKey = BrimstoneAtriumType3Key; + break; + } + } + else + { + switch (atriumType) + { + default: + case 0: + atriumMapKey = BrimstoneAtriumType1Key; + break; + + case 1: + atriumMapKey = BrimstoneAtriumType2Key; + break; + + case 2: + atriumMapKey = BrimstoneAtriumType3Key; + break; + } + } + var atriumSchematic = TileMaps[atriumMapKey]; + + // Pick stockade types + List stockades = new List(); + int numStockades = largeWorld ? 2 : 1; + int stockadeTypes = 4; + do + { + // Chose a random stockade to add to the list + int chosenStockade = WorldGen.genRand.Next(stockadeTypes); + + // Don't choose the same stockade twice + bool alreadyContainsThisStockadeType = stockades.Contains(chosenStockade); + + if (!alreadyContainsThisStockadeType) + stockades.Add(chosenStockade); + } + while (stockades.Count < numStockades); + + string[] stockadesToGenerate = new string[numStockades]; + for (int stockadeIndex = 0; stockadeIndex < numStockades; stockadeIndex++) + { + switch (stockades[stockadeIndex]) + { + default: + case 0: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType1Key; + break; + + case 1: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType2Key; + break; + + case 2: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType3Key; + break; + + case 3: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType4Key; + break; + } + } + + // Offsets for structures + int atriumOffsetY = 8; + + int cacheOffsetY = 45; + + int sanctumOffsetY = 65; + + int strongholdOffsetX = cragsLocationIsLeft ? 40 : 20; + int strongholdOffsetY = 3; + int secondStrongholdOffsetY = 5; + + int dungeonOffsetX = cragsLocationIsLeft ? 30 : 50; + int dungeonOffsetY = 4; + + int stockadeOffsetX = largeWorld ? strongholdOffsetX : 0; + int secondStockadeOffsetX = dungeonOffsetX; + int stockadeOffsetY = stockadesToGenerate[0] == BarbedStockadeType4Key ? -7 : 8; + + // Place structures + if (cragsLocationIsLeft) + { + // + // Place atriums + // + // Atrium location is on the crags side + int atriumGenX = ashIslandX + firstStructureDistanceFromIslandEdge; + int atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + Point atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + SchematicAnchor anchorType = SchematicAnchor.Center; + bool place = true; + if (!smallWorld) + { + PlaceSchematic(BrimstoneAtriumType2Key, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + // Protect the structure + Rectangle atriumProtectionArea = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea, 10); + + // Move index further along to keep structures spread apart + atriumGenX += distanceBetweenStructures_AfterFirstIsland; + + // Reset the Y index + atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + // Placement point for the second atrium + atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + } + + if (atriumMapKey == BrimstoneAtriumType2Key) + PlaceSchematic(atriumMapKey, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + else + PlaceSchematic>(atriumMapKey, atriumPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle atriumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea2, 10); + + // + // Place sanctums, strongholds, dungeons, and stockades + // + // All of these structures are on the demonic side + int sanctumGenX = ashIslandX2 - firstStructureDistanceFromIslandEdge; + int sanctumGenY = ashIslandDepthLimit + sanctumOffsetY; + + int strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + int dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + int stockadeGenX = sanctumGenX - (smallWorld ? distanceBetweenStructures_AfterFirstIsland : distanceBetweenStructures_AfterFirstIsland * 2); + int stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX + stockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + Point sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + Point strongholdPlacementPoint = new Point(sanctumGenX + strongholdOffsetX, strongholdGenY + strongholdOffsetY); + Point dungeonPlacementPoint = new Point(sanctumGenX - dungeonOffsetX, dungeonGenY + dungeonOffsetY); + Point stockadePlacementPoint = new Point(stockadeGenX + stockadeOffsetX, stockadeGenY + stockadeOffsetY); + if (largeWorld) + { + PlaceSchematic>(stockadesToGenerate[0], stockadePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle stockadeProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[stockadesToGenerate[0]], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea, 10); + + // Reset the Y index for stockades + stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX - secondStockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + // Placement point for the second stockade + int secondStockadeOffsetY = stockadesToGenerate[1] == BarbedStockadeType4Key ? -7 : 8; + stockadePlacementPoint = new Point(stockadeGenX - secondStockadeOffsetX, stockadeGenY + secondStockadeOffsetY); + } + if (!smallWorld) + { + PlaceSchematic>(SanctumofOblivionType1Key, sanctumPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle sanctumProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[SanctumofOblivionType1Key], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea, 10); + + PlaceSchematic(HellstoneStrongholdType1Key, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + // Protect the structure + Rectangle strongholdProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[HellstoneStrongholdType1Key], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea, 10); + + PlaceSchematic>(DemonicDungeonType1Key, dungeonPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle dungeonProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[DemonicDungeonType1Key], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea, 10); + + // Move index further along to keep structures spread apart + sanctumGenX -= distanceBetweenStructures_AfterFirstIsland; + + // Reset the Y index for strongholds + strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + // Placement point for the second stronghold + strongholdPlacementPoint = new Point(sanctumGenX + strongholdOffsetX, strongholdGenY + secondStrongholdOffsetY); + + // Reset the Y index for dungeons + dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + // Placement point for the second dungeon + dungeonPlacementPoint = new Point(sanctumGenX - dungeonOffsetX, dungeonGenY + dungeonOffsetY); + + // Placement point for the second sanctum + sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + } + + // Large worlds have two stockades + string secondStockade = largeWorld ? stockadesToGenerate[1] : stockadesToGenerate[0]; + PlaceSchematic>(secondStockade, stockadePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle stockadeProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStockade], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea2, 10); + + // Small worlds only have one sanctum + string secondSanctum = smallWorld ? SanctumofOblivionType1Key : (WorldGen.genRand.NextBool() ? SanctumofOblivionType2Key : SanctumofOblivionType3Key); + PlaceSchematic>(secondSanctum, sanctumPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle sanctumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondSanctum], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea2, 10); + + // Small worlds only have one stronghold + string secondStronghold = smallWorld ? HellstoneStrongholdType1Key : HellstoneStrongholdType2Key; + PlaceSchematic(secondStronghold, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + // Protect the structure + Rectangle strongholdProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStronghold], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea2, 10); + + // Small worlds only have one dungeon + string secondDungeon = smallWorld ? DemonicDungeonType1Key : DemonicDungeonType2Key; + PlaceSchematic>(secondDungeon, dungeonPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle dungeonProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondDungeon], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea2, 10); + } + else + { + int atriumGenX = ashIslandX2 - firstStructureDistanceFromIslandEdge; + int atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + Point atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + SchematicAnchor anchorType = SchematicAnchor.Center; + bool place = true; + if (!smallWorld) + { + PlaceSchematic(BrimstoneAtriumType2Key, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + Rectangle atriumProtectionArea = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea, 10); + + atriumGenX -= distanceBetweenStructures_AfterFirstIsland; + + atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + } + + if (atriumMapKey == BrimstoneAtriumType2Key) + PlaceSchematic(atriumMapKey, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + else + PlaceSchematic>(atriumMapKey, atriumPlacementPoint, anchorType, ref place); + + Rectangle atriumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea2, 10); + + int sanctumGenX = ashIslandX + firstStructureDistanceFromIslandEdge; + int sanctumGenY = ashIslandDepthLimit + sanctumOffsetY; + + int strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + int dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + int stockadeGenX = sanctumGenX + (smallWorld ? distanceBetweenStructures_AfterFirstIsland : distanceBetweenStructures_AfterFirstIsland * 2); + int stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX - stockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + Point sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + Point strongholdPlacementPoint = new Point(sanctumGenX - strongholdOffsetX, strongholdGenY + strongholdOffsetY); + Point dungeonPlacementPoint = new Point(sanctumGenX + dungeonOffsetX, dungeonGenY + dungeonOffsetY); + Point stockadePlacementPoint = new Point(stockadeGenX - stockadeOffsetX, stockadeGenY + stockadeOffsetY); + if (largeWorld) + { + PlaceSchematic>(stockadesToGenerate[0], stockadePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle stockadeProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[stockadesToGenerate[0]], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea, 10); + + // Reset the Y index for stockades + stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX + secondStockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + // Placement point for the second stockade + int secondStockadeOffsetY = stockadesToGenerate[1] == BarbedStockadeType4Key ? -7 : 8; + stockadePlacementPoint = new Point(stockadeGenX + secondStockadeOffsetX, stockadeGenY + secondStockadeOffsetY); + } + if (!smallWorld) + { + PlaceSchematic>(SanctumofOblivionType1Key, sanctumPlacementPoint, anchorType, ref place); + + Rectangle sanctumProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[SanctumofOblivionType1Key], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea, 10); + + PlaceSchematic(HellstoneStrongholdType1Key, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + Rectangle strongholdProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[HellstoneStrongholdType1Key], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea, 10); + + PlaceSchematic>(DemonicDungeonType1Key, dungeonPlacementPoint, anchorType, ref place); + + Rectangle dungeonProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[DemonicDungeonType1Key], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea, 10); + + sanctumGenX += distanceBetweenStructures_AfterFirstIsland; + + strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + strongholdPlacementPoint = new Point(sanctumGenX - strongholdOffsetX, strongholdGenY + secondStrongholdOffsetY); + + dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + dungeonPlacementPoint = new Point(sanctumGenX + dungeonOffsetX, dungeonGenY + dungeonOffsetY); + + sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + } + + string secondStockade = largeWorld ? stockadesToGenerate[1] : stockadesToGenerate[0]; + PlaceSchematic>(secondStockade, stockadePlacementPoint, anchorType, ref place); + + Rectangle stockadeProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStockade], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea2, 10); + + string secondSanctum = smallWorld ? SanctumofOblivionType1Key : (WorldGen.genRand.NextBool() ? SanctumofOblivionType2Key : SanctumofOblivionType3Key); + PlaceSchematic>(secondSanctum, sanctumPlacementPoint, anchorType, ref place); + + Rectangle sanctumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondSanctum], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea2, 10); + + string secondStronghold = smallWorld ? HellstoneStrongholdType1Key : HellstoneStrongholdType2Key; + PlaceSchematic(secondStronghold, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + Rectangle strongholdProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStronghold], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea2, 10); + + string secondDungeon = smallWorld ? DemonicDungeonType1Key : DemonicDungeonType2Key; + PlaceSchematic>(secondDungeon, dungeonPlacementPoint, anchorType, ref place); + + Rectangle dungeonProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondDungeon], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea2, 10); + } + + // Pick cache types + List caches = new List(); + int numCaches = largeWorld ? 8 : 4; // THIS NUMBER MUST BE EVEN!!! + int cacheTypes = 6; + int totalCachePositions = numCaches / 2; + do + { + // Chose a random cache to add to the list + int chosenCache = WorldGen.genRand.Next(cacheTypes); + + // Don't choose the same cache twice + bool alreadyContainsThisCacheType = caches.Contains(chosenCache); + + // Avoid an infinite loop by picking a random duplicate cache if the max is reached + bool pickRandomDuplicateCache = caches.Count >= cacheTypes; + if (pickRandomDuplicateCache) + pickRandomDuplicateCache = caches[caches.Count - totalCachePositions] != chosenCache; + + if (!alreadyContainsThisCacheType || pickRandomDuplicateCache) + caches.Add(chosenCache); + } + while (caches.Count < numCaches); + + // Chose random caches to not place + // 1 is not placed in a small/medium world + // 3 are not placed in a large world + List cachesToNotPlace = new List(); + int numCachesToNotPlace = largeWorld ? 3 : 1; + do + { + // Chose a random cache to add to the list + int chosenCache = WorldGen.genRand.Next(numCaches); + + // Don't choose the same cache twice + bool alreadyContainsThisCacheType = cachesToNotPlace.Contains(chosenCache); + if (!alreadyContainsThisCacheType) + cachesToNotPlace.Add(chosenCache); + } + while (cachesToNotPlace.Count < numCachesToNotPlace); + + // + // Place caches + // + int cacheGenX = ashIslandX + firstStructureDistanceFromIslandEdge + (distanceBetweenStructures_AfterFirstIsland * numAtriums); + int cacheGenY = ashIslandDepthLimit + cacheOffsetY; + int randomAdjustmentX = 0; + int randomAdjustmentY = 0; + int minRandomX = -30; + int maxRandomX = -20; + int minRandomY = 15; + int maxRandomY = 20; + for (int cacheIndex = 0; cacheIndex < totalCachePositions; cacheIndex++) + { + randomAdjustmentX += WorldGen.genRand.Next(minRandomX, maxRandomX + 1); + randomAdjustmentX = (int)MathHelper.Clamp(randomAdjustmentX, minRandomX, maxRandomX); + randomAdjustmentY += WorldGen.genRand.Next(minRandomY, maxRandomY + 1); + randomAdjustmentY = (int)MathHelper.Clamp(randomAdjustmentY, minRandomY, maxRandomY); + + string cacheMapKey; + switch (caches[cacheIndex]) + { + default: + case 0: + cacheMapKey = BonescrapperCacheType1Key; + break; + + case 1: + cacheMapKey = BonescrapperCacheType2Key; + break; + + case 2: + cacheMapKey = BonescrapperCacheType3Key; + break; + + case 3: + cacheMapKey = BonescrapperCacheType4Key; + break; + + case 4: + cacheMapKey = BonescrapperCacheType5Key; + break; + + case 5: + cacheMapKey = BonescrapperCacheType6Key; + break; + } + + Point cachePlacementPoint = new Point(cacheGenX + randomAdjustmentX, cacheGenY + randomAdjustmentY); + SchematicAnchor anchorType = SchematicAnchor.Center; + bool place = true; + + bool canPlaceEvenCache = true; + switch (cacheIndex) + { + default: + case 0: + canPlaceEvenCache = !cachesToNotPlace.Contains(0); + break; + + case 1: + canPlaceEvenCache = !cachesToNotPlace.Contains(2); + break; + + case 2: + canPlaceEvenCache = !cachesToNotPlace.Contains(4); + break; + + case 3: + canPlaceEvenCache = !cachesToNotPlace.Contains(6); + break; + } + + // Cache types 2, 3, and 6 have chests + if (canPlaceEvenCache) + { + if (cacheMapKey == BonescrapperCacheType2Key || cacheMapKey == BonescrapperCacheType3Key || cacheMapKey == BonescrapperCacheType6Key) + PlaceSchematic(cacheMapKey, cachePlacementPoint, anchorType, ref place, new Action(FillCacheChests)); + else + PlaceSchematic>(cacheMapKey, cachePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle cacheProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[cacheMapKey], cachePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(cacheProtectionArea, 5); + } + + string secondCacheMapKey; + switch (caches[cacheIndex + totalCachePositions]) + { + default: + case 0: + secondCacheMapKey = BonescrapperCacheType1Key; + break; + + case 1: + secondCacheMapKey = BonescrapperCacheType2Key; + break; + + case 2: + secondCacheMapKey = BonescrapperCacheType3Key; + break; + + case 3: + secondCacheMapKey = BonescrapperCacheType4Key; + break; + + case 4: + secondCacheMapKey = BonescrapperCacheType5Key; + break; + + case 5: + secondCacheMapKey = BonescrapperCacheType6Key; + break; + } + + bool canPlaceOddCache = true; + switch (cacheIndex) + { + default: + case 0: + canPlaceOddCache = !cachesToNotPlace.Contains(1); + break; + + case 1: + canPlaceOddCache = !cachesToNotPlace.Contains(3); + break; + + case 2: + canPlaceOddCache = !cachesToNotPlace.Contains(5); + break; + + case 3: + canPlaceOddCache = !cachesToNotPlace.Contains(7); + break; + } + + // Place second cache to the right of the first + if (canPlaceOddCache) + { + Point secondCachePlacementPoint = cachePlacementPoint + new Point(WorldGen.genRand.Next(60, 76), 0); + if (secondCacheMapKey == BonescrapperCacheType2Key || secondCacheMapKey == BonescrapperCacheType3Key || secondCacheMapKey == BonescrapperCacheType6Key) + PlaceSchematic(secondCacheMapKey, secondCachePlacementPoint, anchorType, ref place, new Action(FillCacheChests)); + else + PlaceSchematic>(secondCacheMapKey, secondCachePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle cacheProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondCacheMapKey], secondCachePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(cacheProtectionArea2, 5); + } + + // Reset positions and move cache placement along the X axis + cacheGenX = ashIslandX + firstStructureDistanceFromIslandEdge + (distanceBetweenStructures_AfterFirstIsland * (numAtriums + cacheIndex + 1)); + cacheGenY = ashIslandDepthLimit + cacheOffsetY; + } + } + } + + public static void AshTreesAndGrass() + { + // Start generating islands at this point + int ashIslandX = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenStart_Remix : AshIslandGenStart)); + + // Stop generating islands at this point + int ashIslandX2 = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenEnd_Remix : AshIslandGenEnd)); + + // Ash island gen limits + int ashIslandDepthLimit = Main.maxTilesY - AshIslandDepthMaxAboveTheUnderworldFloor; + + // Place ash trees + for (int x = ashIslandX; x < ashIslandX2 + 15; x++) + { + for (int y = Main.maxTilesY - 200; y < ashIslandDepthLimit + 30; y++) + { + if (Main.tile[x, y].TileType == TileID.AshGrass && Main.tile[x, y].HasTile && !Main.tile[x, y - 1].HasTile && WorldGen.genRand.NextBool(3)) + WorldGen.TryGrowingTreeByType(TileID.TreeAsh, x, y); + } + } + + // Drunk world ash grass and trees + if (WorldGen.drunkWorldGen) + { + for (int x = 25; x < Main.maxTilesX - 25; x++) + { + for (int y = Main.maxTilesY - 300; y < Main.maxTilesY - 100 + WorldGen.genRand.Next(-1, 2); y++) + { + if (Main.tile[x, y].TileType == TileID.Ash && Main.tile[x, y].HasTile && + (!Main.tile[x - 1, y - 1].HasTile || !Main.tile[x, y - 1].HasTile || + !Main.tile[x + 1, y - 1].HasTile || !Main.tile[x - 1, y].HasTile || + !Main.tile[x + 1, y].HasTile || !Main.tile[x - 1, y + 1].HasTile || + !Main.tile[x, y + 1].HasTile || !Main.tile[x + 1, y + 1].HasTile)) + Main.tile[x, y].TileType = TileID.AshGrass; + } + } + + for (int x = 25; x < Main.maxTilesX - 25; x++) + { + for (int y = Main.maxTilesY - 200; y < Main.maxTilesY - 50; y++) + { + if (Main.tile[x, y].TileType == TileID.AshGrass && Main.tile[x, y].HasTile && !Main.tile[x, y - 1].HasTile && WorldGen.genRand.NextBool(3)) + WorldGen.TryGrowingTreeByType(TileID.TreeAsh, x, y); + } + } + } + } + + public static void PlaceGeyserTraps() + { + // Place Geyser Traps on ash islands + // These are only generated in the no-man's land central islands + if (!WorldGen.remixWorldGen) + { + // Large = 8, Medium = 6, Small = 4 + // No-man's land islands: Large = 4, Medium = 2, Small = 2 + int numIslands = (int)(Main.maxTilesX / 4200f * 4f); + bool mediumWorld = numIslands == MediumWorldIslands; + + // Start generating traps at this point + int ashIslandX = (int)((double)Main.maxTilesX * (mediumWorld ? 0.453 : 0.43)); + + // Stop generating traps at this point + int ashIslandX2 = (int)((double)Main.maxTilesX * (mediumWorld ? 0.546 : 0.57)); + + // Small = 12.6 Medium = 19.2 Large = 25.2 + double trapFrequency = (double)Main.maxTilesX * 0.003; + if (WorldGen.noTrapsWorldGen) + trapFrequency = ((!WorldGen.tenthAnniversaryWorldGen && !WorldGen.notTheBees) ? (trapFrequency * 100D) : (trapFrequency * 5D)); + else if (WorldGen.getGoodWorldGen) + trapFrequency *= 1.5; + + if (Main.starGame) + trapFrequency *= Main.starGameMath(0.2); + + int maxTrapPlacementAttempts = 1150; + for (int trapIndex = 0; (double)trapIndex < trapFrequency; trapIndex++) + { + for (int trapIndex2 = 0; trapIndex2 < maxTrapPlacementAttempts; trapIndex2++) + { + int trapPlacementX = WorldGen.genRand.Next(ashIslandX, ashIslandX2); + int trapPlacementY = WorldGen.genRand.Next(Main.maxTilesY - AshIslandHeightMaxAboveTheUnderworldFloor, Main.maxTilesY - 100); + + if (GeyserTraps(trapPlacementX, trapPlacementY)) + break; + } + } + } + } + + private static bool GeyserTraps(int geyserX, int geyserY) + { + int geyserPlacementY = geyserY; + + while (!WorldGen.SolidTile(geyserX, geyserPlacementY)) + { + geyserPlacementY++; + if (geyserPlacementY > Main.maxTilesY - 10) + return false; + } + + geyserPlacementY--; + + if (!WorldGen.InWorld(geyserX, geyserPlacementY, 3)) + return false; + + if (Main.tile[geyserX, geyserPlacementY].HasUnactuatedTile || + Main.tile[geyserX - 1, geyserPlacementY].HasUnactuatedTile || + Main.tile[geyserX + 1, geyserPlacementY].HasUnactuatedTile || + Main.tile[geyserX, geyserPlacementY - 1].HasUnactuatedTile || + Main.tile[geyserX - 1, geyserPlacementY - 1].HasUnactuatedTile || + Main.tile[geyserX + 1, geyserPlacementY - 1].HasUnactuatedTile || + Main.tile[geyserX, geyserPlacementY - 2].HasUnactuatedTile || + Main.tile[geyserX - 1, geyserPlacementY - 2].HasUnactuatedTile || + Main.tile[geyserX + 1, geyserPlacementY - 2].HasUnactuatedTile) + return false; + + if (Main.tile[geyserX + 1, geyserPlacementY].HasTile) + return false; + + // Only place on ash grass to avoid placing in the schematics + if (Main.tile[geyserX, geyserPlacementY + 1].TileType != TileID.AshGrass || + Main.tile[geyserX + 1, geyserPlacementY + 1].TileType != TileID.AshGrass) + return false; + + for (int k = geyserX; k <= geyserX + 1; k++) + { + int j2 = geyserPlacementY + 1; + if (!WorldGen.SolidTile(k, j2)) + return false; + } + + int geyserPlacementY2 = WorldGen.genRand.Next(2); + for (int l = 0; l < 2; l++) + { + Main.tile[geyserX + l, geyserPlacementY].Get().HasTile = true; + Main.tile[geyserX + l, geyserPlacementY].TileType = TileID.GeyserTrap; + Main.tile[geyserX + l, geyserPlacementY].TileFrameX = (short)(18 * l + 36 * geyserPlacementY2); + Main.tile[geyserX + l, geyserPlacementY].TileFrameY = 0; + } + + return true; + } + + private static void AddHellHouses() + { + // Original tower gen area was the outer quarters of the underworld + // New tower gen area is the outer thirds of the underworld + int towerGenArea = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? 0.25 : 0.33)); + + // Generate towers + for (int i = 100; i < Main.maxTilesX - 100; i++) + { + if (i > towerGenArea && i < Main.maxTilesX - towerGenArea) + continue; + + int hellFortGenY = Main.maxTilesY - 40; + while (Main.tile[i, hellFortGenY].HasTile || Main.tile[i, hellFortGenY].LiquidAmount > 0) + hellFortGenY--; + + if (Main.tile[i, hellFortGenY + 1].HasTile) + { + ushort hellFortTileType = (ushort)WorldGen.genRand.Next(TileID.ObsidianBrick, TileID.HellstoneBrick + 1); + ushort wallType = WallID.HellstoneBrickUnsafe; + if (WorldGen.genRand.Next(5) > 0) + hellFortTileType = TileID.ObsidianBrick; + + if (hellFortTileType == TileID.ObsidianBrick) + wallType = WallID.ObsidianBrickUnsafe; + + if (WorldGen.getGoodWorldGen) + hellFortTileType = TileID.HellstoneBrick; + + // Place tower + WorldGen.HellFort(i, hellFortGenY, hellFortTileType, (byte)wallType); + + // Move index further along to keep towers spread apart + // Original min and max values were, respectively, 30 and 130 + // New min and max values are, respectively, 30 and 60 + i += WorldGen.genRand.Next(30, WorldGen.remixWorldGen ? 130 : 60); + + // Randomly add more distance between towers + // Original max value was 200 + // New max value is 50 + if (WorldGen.genRand.NextBool(10)) + i += WorldGen.genRand.Next(WorldGen.remixWorldGen ? 200 : 50); + } + } + + // Placing torches in towers + float torchAmountMult = Main.maxTilesX / 4200f; + for (int torchIndex = 0; (float)torchIndex < 200f * torchAmountMult; torchIndex++) + { + int attempts = 0; + bool placedTorch = false; + while (!placedTorch) + { + attempts++; + int x = WorldGen.genRand.Next((int)((double)Main.maxTilesX * 0.2), (int)((double)Main.maxTilesX * 0.8)); + int y = WorldGen.genRand.Next(Main.maxTilesY - 300, Main.maxTilesY - 20); + if (Main.tile[x, y].HasTile && (Main.tile[x, y].TileType == TileID.ObsidianBrick || Main.tile[x, y].TileType == TileID.HellstoneBrick)) + { + int xOffset = 0; + if (Main.tile[x - 1, y].WallType > WallID.None) + xOffset = -1; + else if (Main.tile[x + 1, y].WallType > WallID.None) + xOffset = 1; + + if (!Main.tile[x + xOffset, y].HasTile && !Main.tile[x + xOffset, y + 1].HasTile) + { + // Check if a torch has already been placed in this location + bool torchAlreadyPlaced = false; + for (int k = x - 8; k < x + 8; k++) + { + for (int l = y - 8; l < y + 8; l++) + { + if (Main.tile[k, l].HasTile && TileID.Sets.Torch[Main.tile[k, l].TileType]) + { + torchAlreadyPlaced = true; + break; + } + } + } + + // Place the torch + if (!torchAlreadyPlaced) + { + WorldGen.PlaceTile(x + xOffset, y, TileID.Torches, mute: true, forced: true, -1, 7); + placedTorch = true; + } + } + } + + if (attempts > 1000) + placedTorch = true; + } + } + + // Place furniture in the towers + double furnitureAmount = 4200000D / (double)Main.maxTilesX; + for (int furnitureIndex = 0; (double)furnitureIndex < furnitureAmount; furnitureIndex++) + { + int attempts = 0; + int furniturePlacementX = WorldGen.genRand.Next(towerGenArea, Main.maxTilesX - towerGenArea); + int y = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20); + while ((Main.tile[furniturePlacementX, y].WallType != WallID.HellstoneBrickUnsafe && Main.tile[furniturePlacementX, y].WallType != WallID.ObsidianBrickUnsafe) || Main.tile[furniturePlacementX, y].HasTile) + { + furniturePlacementX = WorldGen.genRand.NextBool(2) ? WorldGen.genRand.Next(Main.maxTilesX - towerGenArea, Main.maxTilesX - 50) : WorldGen.genRand.Next(50, towerGenArea); + y = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20); + + attempts++; + if (attempts > 100000) + break; + } + + if (attempts > 100000 || (Main.tile[furniturePlacementX, y].WallType != WallID.HellstoneBrickUnsafe && Main.tile[furniturePlacementX, y].WallType != WallID.ObsidianBrickUnsafe) || Main.tile[furniturePlacementX, y].HasTile) + continue; + + for (; !WorldGen.SolidTile(furniturePlacementX, y) && y < Main.maxTilesY - 20; y++) + { + } + + y--; + int placementAdjustment = furniturePlacementX; + int placementAdjustment2 = furniturePlacementX; + while (!Main.tile[placementAdjustment, y].HasTile && WorldGen.SolidTile(placementAdjustment, y + 1)) + placementAdjustment--; + + placementAdjustment++; + for (; !Main.tile[placementAdjustment2, y].HasTile && WorldGen.SolidTile(placementAdjustment2, y + 1); placementAdjustment2++) + { + } + + placementAdjustment2--; + int placementSpaceLimit = placementAdjustment2 - placementAdjustment; + int x = (placementAdjustment2 + placementAdjustment) / 2; + if (Main.tile[x, y].HasTile || (Main.tile[x, y].WallType != WallID.HellstoneBrickUnsafe && Main.tile[x, y].WallType != WallID.ObsidianBrickUnsafe) || !WorldGen.SolidTile(x, y + 1)) + continue; + + // Different styles of houses + int style = 16; + int style2 = 13; + int style3 = 14; + int style4 = 49; + int style5 = 4; + int style6 = 8; + int style7 = 15; + int style8 = 9; + int style9 = 10; + int style10 = 17; + int style11 = 25; + int style12 = 25; + int style13 = 23; + int style14 = 25; + int styleChoice = WorldGen.genRand.Next(13); + int sizeX = 0; + int sizeY = 0; + if (styleChoice == 0) + { + sizeX = 5; + sizeY = 4; + } + + if (styleChoice == 1) + { + sizeX = 4; + sizeY = 3; + } + + if (styleChoice == 2) + { + sizeX = 3; + sizeY = 5; + } + + if (styleChoice == 3) + { + sizeX = 4; + sizeY = 6; + } + + if (styleChoice == 4) + { + sizeX = 3; + sizeY = 3; + } + + if (styleChoice == 5) + { + sizeX = 5; + sizeY = 3; + } + + if (styleChoice == 6) + { + sizeX = 5; + sizeY = 4; + } + + if (styleChoice == 7) + { + sizeX = 5; + sizeY = 4; + } + + if (styleChoice == 8) + { + sizeX = 5; + sizeY = 4; + } + + if (styleChoice == 9) + { + sizeX = 3; + sizeY = 5; + } + + if (styleChoice == 10) + { + sizeX = 5; + sizeY = 3; + } + + if (styleChoice == 11) + { + sizeX = 2; + sizeY = 4; + } + + if (styleChoice == 12) + { + sizeX = 3; + sizeY = 3; + } + + // Check if there are any tiles in the way of furniture placement + for (int placementIndexX = x - sizeX; placementIndexX <= x + sizeX; placementIndexX++) + { + for (int placementIndexY = y - sizeY; placementIndexY <= y; placementIndexY++) + { + if (Main.tile[placementIndexX, placementIndexY].HasTile) + { + styleChoice = -1; + break; + } + } + } + + // Check if there is enough space to place furniture + if ((double)placementSpaceLimit < (double)sizeX * 1.75) + styleChoice = -1; + + switch (styleChoice) + { + case 0: + WorldGen.PlaceTile(x, y, TileID.Tables, mute: true, forced: false, -1, style2); + int candlePlacementX = WorldGen.genRand.Next(6); + if (candlePlacementX < 3) + WorldGen.PlaceTile(x + candlePlacementX, y - 2, TileID.Candles, mute: true, forced: false, -1, style12); + + if (!Main.tile[x, y].HasTile) + break; + + if (!Main.tile[x - 2, y].HasTile) + { + WorldGen.PlaceTile(x - 2, y, TileID.Chairs, mute: true, forced: false, -1, style); + if (Main.tile[x - 2, y].HasTile) + { + Main.tile[x - 2, y].TileFrameX += 18; + Main.tile[x - 2, y - 1].TileFrameX += 18; + } + } + + if (!Main.tile[x + 2, y].HasTile) + WorldGen.PlaceTile(x + 2, y, TileID.Chairs, mute: true, forced: false, -1, style); + + break; + + case 1: + WorldGen.PlaceTile(x, y, TileID.WorkBenches, mute: true, forced: false, -1, style3); + int candlePlacementX2 = WorldGen.genRand.Next(4); + if (candlePlacementX2 < 2) + WorldGen.PlaceTile(x + candlePlacementX2, y - 1, TileID.Candles, mute: true, forced: false, -1, style12); + + if (!Main.tile[x, y].HasTile) + break; + + if (WorldGen.genRand.NextBool()) + { + if (!Main.tile[x - 1, y].HasTile) + { + WorldGen.PlaceTile(x - 1, y, TileID.Chairs, mute: true, forced: false, -1, style); + if (Main.tile[x - 1, y].HasTile) + { + Main.tile[x - 1, y].TileFrameX += 18; + Main.tile[x - 1, y - 1].TileFrameX += 18; + } + } + } + else if (!Main.tile[x + 2, y].HasTile) + WorldGen.PlaceTile(x + 2, y, TileID.Chairs, mute: true, forced: false, -1, style); + + break; + + case 2: + WorldGen.PlaceTile(x, y, TileID.Statues, mute: true, forced: false, -1, style4); + break; + + case 3: + WorldGen.PlaceTile(x, y, TileID.Bookcases, mute: true, forced: false, -1, style5); + break; + + case 4: + + if (WorldGen.genRand.NextBool()) + { + WorldGen.PlaceTile(x, y, TileID.Chairs, mute: true, forced: false, -1, style); + Main.tile[x, y].TileFrameX += 18; + Main.tile[x, y - 1].TileFrameX += 18; + } + else + WorldGen.PlaceTile(x, y, TileID.Chairs, mute: true, forced: false, -1, style); + + break; + + case 5: + if (WorldGen.genRand.NextBool()) + WorldGen.Place4x2(x, y, TileID.Beds, 1, style6); + else + WorldGen.Place4x2(x, y, TileID.Beds, -1, style6); + break; + + case 6: + WorldGen.PlaceTile(x, y, TileID.Pianos, mute: true, forced: false, -1, style7); + break; + + case 7: + WorldGen.PlaceTile(x, y, TileID.Dressers, mute: true, forced: false, -1, style8); + break; + + case 8: + WorldGen.PlaceTile(x, y, TileID.Benches, mute: true, forced: false, -1, style9); + break; + + case 9: + WorldGen.PlaceTile(x, y, TileID.GrandfatherClocks, mute: true, forced: false, -1, style10); + break; + + case 10: + if (WorldGen.genRand.NextBool()) + WorldGen.Place4x2(x, y, TileID.Bathtubs, 1, style14); + else + WorldGen.Place4x2(x, y, TileID.Bathtubs, -1, style14); + break; + + case 11: + WorldGen.PlaceTile(x, y, TileID.Lamps, mute: true, forced: false, -1, style13); + break; + + case 12: + WorldGen.PlaceTile(x, y, TileID.Candelabras, mute: true, forced: false, -1, style11); + break; + } + } + + // Place paintings in the towers + furnitureAmount = 420000D / (double)Main.maxTilesX; + for (int paintingIndex = 0; (double)paintingIndex < furnitureAmount; paintingIndex++) + { + int attempts = 0; + int x = WorldGen.genRand.Next(towerGenArea, Main.maxTilesX - towerGenArea); + int y = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20); + while ((Main.tile[x, y].WallType != WallID.HellstoneBrickUnsafe && Main.tile[x, y].WallType != WallID.ObsidianBrickUnsafe) || Main.tile[x, y].HasTile) + { + x = WorldGen.genRand.NextBool() ? WorldGen.genRand.Next(Main.maxTilesX - towerGenArea, Main.maxTilesX - 50) : WorldGen.genRand.Next(50, towerGenArea); + y = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20); + + attempts++; + if (attempts > 100000) + break; + } + + if (attempts > 100000) + continue; + + int paintingPlacementX = x; + int paintingPlacementX2 = x; + int paintingPlacementY = y; + int paintingPlacementY2 = y; + int sizeY = 0; + for (int num32 = 0; num32 < 2; num32++) + { + paintingPlacementX = x; + paintingPlacementX2 = x; + while (!Main.tile[paintingPlacementX, y].HasTile && (Main.tile[paintingPlacementX, y].WallType == WallID.HellstoneBrickUnsafe || Main.tile[paintingPlacementX, y].WallType == WallID.ObsidianBrickUnsafe)) + paintingPlacementX--; + + paintingPlacementX++; + for (; !Main.tile[paintingPlacementX2, y].HasTile && (Main.tile[paintingPlacementX2, y].WallType == WallID.HellstoneBrickUnsafe || Main.tile[paintingPlacementX2, y].WallType == WallID.ObsidianBrickUnsafe); paintingPlacementX2++) + { + } + + paintingPlacementX2--; + x = (paintingPlacementX + paintingPlacementX2) / 2; + paintingPlacementY = y; + paintingPlacementY2 = y; + while (!Main.tile[x, paintingPlacementY].HasTile && (Main.tile[x, paintingPlacementY].WallType == WallID.HellstoneBrickUnsafe || Main.tile[x, paintingPlacementY].WallType == WallID.ObsidianBrickUnsafe)) + paintingPlacementY--; + + paintingPlacementY++; + for (; !Main.tile[x, paintingPlacementY2].HasTile && (Main.tile[x, paintingPlacementY2].WallType == WallID.HellstoneBrickUnsafe || Main.tile[x, paintingPlacementY2].WallType == WallID.ObsidianBrickUnsafe); paintingPlacementY2++) + { + } + + paintingPlacementY2--; + y = (paintingPlacementY + paintingPlacementY2) / 2; + } + + // Clamp this due to out of bounds errors + y = (int)MathHelper.Clamp(y, 1, Main.maxTilesY - 1); + + paintingPlacementX = x; + paintingPlacementX2 = x; + while (!Main.tile[paintingPlacementX, y].HasTile && !Main.tile[paintingPlacementX, y - 1].HasTile && !Main.tile[paintingPlacementX, y + 1].HasTile) + { + paintingPlacementX--; + + // Ensure we don't get out of bounds errors + if (paintingPlacementX < 0) + { + paintingPlacementX = 0; + break; + } + } + + paintingPlacementX++; + for (; !Main.tile[paintingPlacementX2, y].HasTile && !Main.tile[paintingPlacementX2, y - 1].HasTile && !Main.tile[paintingPlacementX2, y + 1].HasTile; paintingPlacementX2++) + { + } + + paintingPlacementX2--; + paintingPlacementY = y; + paintingPlacementY2 = y; + while (!Main.tile[x, paintingPlacementY].HasTile && !Main.tile[x - 1, paintingPlacementY].HasTile && !Main.tile[x + 1, paintingPlacementY].HasTile) + paintingPlacementY--; + + paintingPlacementY++; + for (; !Main.tile[x, paintingPlacementY2].HasTile && !Main.tile[x - 1, paintingPlacementY2].HasTile && !Main.tile[x + 1, paintingPlacementY2].HasTile; paintingPlacementY2++) + { + } + + paintingPlacementY2--; + x = (paintingPlacementX + paintingPlacementX2) / 2; + y = (paintingPlacementY + paintingPlacementY2) / 2; + int sizeX = paintingPlacementX2 - paintingPlacementX; + sizeY = paintingPlacementY2 - paintingPlacementY; + if (sizeX <= 7 || sizeY <= 5) + continue; + + if (!WorldGen.nearPicture2(x, y)) + { + PaintingEntry paintingEntry = WorldGen.RandHellPicture(); + if (!WorldGen.nearPicture(x, y)) + WorldGen.PlaceTile(x, y, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); + } + } + + // An array used for banner styles + int[] bannerArray = new int[3] + { + WorldGen.genRand.Next(16, 22), + WorldGen.genRand.Next(16, 22), + WorldGen.genRand.Next(16, 22) + }; + + while (bannerArray[1] == bannerArray[0]) + bannerArray[1] = WorldGen.genRand.Next(16, 22); + + while (bannerArray[2] == bannerArray[0] || bannerArray[2] == bannerArray[1]) + bannerArray[2] = WorldGen.genRand.Next(16, 22); + + // Place hanging tiles + furnitureAmount = 420000D / (double)Main.maxTilesX; + for (int hangingTileIndex = 0; (double)hangingTileIndex < furnitureAmount; hangingTileIndex++) + { + int attempts = 0; + int x; + int y; + do + { + x = WorldGen.genRand.NextBool() ? WorldGen.genRand.Next(Main.maxTilesX - towerGenArea, Main.maxTilesX - 50) : WorldGen.genRand.Next(50, towerGenArea); + y = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20); + attempts++; + } + while (attempts <= 100000 && ((Main.tile[x, y].WallType != WallID.HellstoneBrickUnsafe && Main.tile[x, y].WallType != WallID.ObsidianBrickUnsafe) || Main.tile[x, y].HasTile)); + + if (attempts > 100000) + continue; + + while (!WorldGen.SolidTile(x, y) && y > 10) + y--; + + y++; + if (Main.tile[x, y].WallType != WallID.HellstoneBrickUnsafe && Main.tile[x, y].WallType != WallID.ObsidianBrickUnsafe) + continue; + + int hangingTileType = WorldGen.genRand.Next(3); + int chandelierStyle = 32; + int lanternStyle = 32; + int hangingTileSizeX; + int hangingTileSizeY; + switch (hangingTileType) + { + default: + hangingTileSizeX = 1; + hangingTileSizeY = 3; + break; + case 1: + hangingTileSizeX = 3; + hangingTileSizeY = 3; + break; + case 2: + hangingTileSizeX = 1; + hangingTileSizeY = 2; + break; + } + + for (int placementIndexX = x - 1; placementIndexX <= x + hangingTileSizeX; placementIndexX++) + { + for (int placementIndexY = y; placementIndexY <= y + hangingTileSizeY; placementIndexY++) + { + Tile tile = Main.tile[x, y]; + if (placementIndexX < x || placementIndexX == x + hangingTileSizeX) + { + if (tile.HasTile) + { + switch (tile.TileType) + { + case TileID.ClosedDoor: + case TileID.OpenDoor: + case TileID.Chandeliers: + case TileID.HangingLanterns: + case TileID.Banners: + hangingTileType = -1; + break; + } + } + } + else if (tile.HasTile) + hangingTileType = -1; + } + } + + switch (hangingTileType) + { + case 0: + WorldGen.PlaceTile(x, y, TileID.Banners, mute: true, forced: false, -1, bannerArray[WorldGen.genRand.Next(3)]); + break; + case 1: + WorldGen.PlaceTile(x, y, TileID.Chandeliers, mute: true, forced: false, -1, chandelierStyle); + break; + case 2: + WorldGen.PlaceTile(x, y, TileID.HangingLanterns, mute: true, forced: false, -1, lanternStyle); + break; + } + } + } + + private static void FillAtriumChests(Chest chest, int Type, bool place) + { + int shadowChestItems = Utils.SelectRandom(WorldGen.genRand, ItemID.Sunfury, ItemID.FlowerofFire, ItemID.Flamelash, ItemID.DarkLance, ItemID.HellwingBow); + int shadowChestItems2 = Utils.SelectRandom(WorldGen.genRand, ItemID.HellMinecart, ItemID.OrnateShadowKey, ItemID.HellCake); + List contents = new List() + { + new ChestItem(shadowChestItems, 1), + new ChestItem(shadowChestItems2, 1), + new ChestItem(ItemID.ObsidianSkinPotion, WorldGen.genRand.Next(2, 5)), + new ChestItem(ItemID.LifeforcePotion, WorldGen.genRand.Next(2, 5)), + new ChestItem(ItemID.TeleportationPotion, WorldGen.genRand.Next(2, 5)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(3, 6)), + }; + + for (int i = 0; i < contents.Count; i++) + { + chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); + chest.item[i].stack = contents[i].Stack; + } + } + + private static void FillCacheChests(Chest chest, int Type, bool place) + { + int shadowChestItems = Utils.SelectRandom(WorldGen.genRand, ItemID.Sunfury, ItemID.FlowerofFire, ItemID.Flamelash, ItemID.DarkLance, ItemID.HellwingBow); + int barTypes = Utils.SelectRandom(WorldGen.genRand, ItemID.MeteoriteBar, GenVars.goldBar == TileID.Gold ? ItemID.GoldBar : ItemID.PlatinumBar); + int ammoTypes = Utils.SelectRandom(WorldGen.genRand, ItemID.HellfireArrow, GenVars.silverBar == TileID.Silver ? ItemID.SilverBullet : ItemID.TungstenBullet); + int potionTypes = Utils.SelectRandom(WorldGen.genRand, ItemID.SpelunkerPotion, ItemID.FeatherfallPotion, ItemID.ManaRegenerationPotion, ItemID.MagicPowerPotion, ItemID.InvisibilityPotion, ItemID.HunterPotion, ItemID.HeartreachPotion); + int potionTypes2 = Utils.SelectRandom(WorldGen.genRand, ItemID.GravitationPotion, ItemID.ThornsPotion, ItemID.WaterWalkingPotion, ItemID.BattlePotion, ItemID.InfernoPotion); + int potionTypes3 = Utils.SelectRandom(WorldGen.genRand, ItemID.RecallPotion, ItemID.PotionOfReturn); + int lightSourceTypes = Utils.SelectRandom(WorldGen.genRand, ItemID.Torch, ItemID.Glowstick); + List contents = new List() + { + new ChestItem(shadowChestItems, 1), + new ChestItem(ItemID.Dynamite, WorldGen.genRand.Next(1, 3)), + new ChestItem(barTypes, WorldGen.genRand.Next(15, 31)), + new ChestItem(ammoTypes, WorldGen.genRand.Next(50, 76)), + new ChestItem(ItemID.RestorationPotion, WorldGen.genRand.Next(15, 21)), + new ChestItem(potionTypes, WorldGen.genRand.Next(1, 3)), + new ChestItem(potionTypes2, WorldGen.genRand.Next(1, 3)), + new ChestItem(potionTypes3, WorldGen.genRand.Next(1, 3)), + new ChestItem(lightSourceTypes, WorldGen.genRand.Next(15, 31)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(2, 5)), + }; + + for (int i = 0; i < contents.Count; i++) + { + chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); + chest.item[i].stack = contents[i].Stack; + } + } + } +} diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index 5bb14468dc..083849c346 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -45,10 +45,15 @@ namespace CalamityMod.World { return true; } - if (tile.TileType == ModContent.TileType() || - tile.TileType == ModContent.TileType() || - tile.WallType == ModContent.WallType() || - tile.WallType == ModContent.WallType()) + if (tile.TileType == ModContent.TileType() || + tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || + tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || + tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || + tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || + tile.WallType == ModContent.WallType() || // hardened eutrophic sand doesnt have a wall lol + tile.WallType == ModContent.WallType() || + tile.WallType == ModContent.WallType() || // nor polyp sand + tile.WallType == ModContent.WallType()) // ... nor dunesand { return true; } @@ -241,6 +246,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } @@ -558,7 +564,7 @@ namespace CalamityMod.World new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(8, 14 + 1)), new ChestItem(ModContent.ItemType(), WorldGen.genRand.Next(7, 12 + 1)), new ChestItem(ItemID.HerbBag, WorldGen.genRand.Next(12, 17 + 1)), - new ChestItem(ItemID.DayBloomPlanterBox, WorldGen.genRand.Next(5, 9 + 1)), + //new ChestItem(ItemID.DayBloomPlanterBox, WorldGen.genRand.Next(5, 9 + 1)), Removed from the chest because they're placed within the lab new ChestItem(ItemID.BlinkrootPlanterBox, WorldGen.genRand.Next(5, 9 + 1)), new ChestItem(ItemID.FireBlossomPlanterBox, WorldGen.genRand.Next(5, 9 + 1)), new ChestItem(ItemID.MoonglowPlanterBox, WorldGen.genRand.Next(5, 9 + 1)), @@ -583,7 +589,7 @@ namespace CalamityMod.World contents.Add(new ChestItem(marineKelpPlanterBox.Type, WorldGen.genRand.Next(5, 9 + 1))); } else - CalamityMod.Instance.Logger.Warn("Could not find Thorium Marine Kelp Planter Box. This item will not be added to the Draedon Planetoid Lab."); + CalamityMod.Log.Warn("Could not find Thorium Marine Kelp Planter Box. This item will not be added to the Draedon Planetoid Lab."); //Adds the Jungle Seeking Mechanism contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); diff --git a/World/DungeonArchive.cs b/World/DungeonArchive.cs index 51487e5f4c..a1958e2331 100644 --- a/World/DungeonArchive.cs +++ b/World/DungeonArchive.cs @@ -1,15 +1,9 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.Schematics; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent.Generation; using Terraria.ID; -using Terraria.IO; -using Terraria.ModLoader; -using Terraria.Utilities; using Terraria.WorldBuilding; using static CalamityMod.Schematics.SchematicManager; @@ -135,6 +129,7 @@ namespace CalamityMod.World else { chest.item[i].SetDefaults(contents2[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents2[i].Stack; } } diff --git a/World/GiantHive.cs b/World/GiantHive.cs index 96b8e31331..e58ce30c54 100644 --- a/World/GiantHive.cs +++ b/World/GiantHive.cs @@ -1,26 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; -using CalamityMod.DataStructures; -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Materials; using CalamityMod.Items.Potions; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Tiles; -using CalamityMod.Tiles.Abyss; -using CalamityMod.Tiles.Astral; -using CalamityMod.Tiles.Crags; -using CalamityMod.Tiles.FurnitureAncient; -using CalamityMod.Tiles.Ores; using CalamityMod.Walls; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.DataStructures; using Terraria.GameContent.Generation; using Terraria.ID; -using Terraria.IO; using Terraria.ModLoader; using Terraria.Utilities; using Terraria.WorldBuilding; @@ -29,8 +15,21 @@ namespace CalamityMod.World { public class GiantHive { - public static bool GrowLivingJungleTree(Point origin) + public static bool GrowLivingJungleTree(Point origin, StructureMap structures) { + if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100))) + return false; + + if (TooCloseToImportantLocations(origin)) + return false; + + Ref ref1 = new Ref(0); + Ref ref2 = new Ref(0); + Ref ref3 = new Ref(0); + WorldUtils.Gen(origin, new Shapes.Circle(15), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(ref1), new Modifiers.OnlyTiles(TileID.JungleGrass, TileID.Mud), new Actions.Scanner(ref2), new Modifiers.OnlyTiles(TileID.JungleGrass), new Actions.Scanner(ref3))); + if ((ref2.Value / (float)ref1.Value < 0.75f || ref3.Value < 2) && !WorldGen.drunkWorldGen) + return false; + int treeHeight = (int)Main.worldSurface - (Main.maxTilesY / 10); //start here to not touch floating islands bool validHeightFound = false; int attempts = 0; @@ -42,7 +41,7 @@ namespace CalamityMod.World treeHeight++; } - if (Main.tile[origin.X, treeHeight].HasTile || Main.tile[origin.X, treeHeight].WallType > 0) + if (Main.tile[origin.X, treeHeight].HasTile || Main.tile[origin.X, treeHeight].WallType > WallID.None) { validHeightFound = true; } @@ -86,7 +85,7 @@ namespace CalamityMod.World //place living mahogany leaves at the end of each branch foreach (Point item in list) { - WorldUtils.Gen(item, new Shapes.Circle(WorldGen.genRand.Next(5, 12)), Actions.Chain(new Modifiers.Blotches(WorldGen.genRand.Next(3, 5), WorldGen.genRand.Next(3, 5)), + WorldUtils.Gen(item, new Shapes.Circle(WorldGen.genRand.Next(5, 12)), Actions.Chain(new Modifiers.Blotches(WorldGen.genRand.Next(2, 5), WorldGen.genRand.Next(3, 5)), new Modifiers.SkipTiles(383, 21, 467, 226, 237), new Modifiers.SkipWalls(78, 87), new Actions.SetTile(TileID.LivingMahoganyLeaves), new Actions.SetFrames(frameNeighbors: true))); } } @@ -172,13 +171,20 @@ namespace CalamityMod.World Vector2 movingLarvaLocation = larvaLocation; int hiveTunnelTries = WorldGen.genRand.Next(2, 5); for (int j = 0; j < hiveTunnelTries; j++) - movingLarvaLocation = CreateHiveTunnel((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); + movingLarvaLocation = MakeCell((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); larvaLocation = movingLarvaLocation; array[arrayInc] = (int)larvaLocation.X; array2[arrayInc] = (int)larvaLocation.Y; arrayInc++; } + for (int i = 0; i < numHiveTunnels; i++) + { + int hiveTunnelTries = WorldGen.genRand.Next(1, 2); + MakeCellHoney((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); + } + MakeOuterCell((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); + FrameOutAllHiveContents(origin, 50); @@ -206,14 +212,11 @@ namespace CalamityMod.World x += treeIndentDirection; if (!SpotActuallyNotInHive(x, y)) { - CreateBlockedHoneyCube(x, y); CreateDentForHoneyFall(x, y, treeIndentDirection); } } } - GrowLivingJungleTree(new Point(origin.X, origin.Y)); - CreateStandForLarva(larvaLocation); // Generate a second larva stand @@ -233,35 +236,52 @@ namespace CalamityMod.World } // Honey chests - Vector2 honeyChestLocation = default; - for (int l = 0; l < maxAttempts; l++) - { - Vector2 newStructureLocation = larvaLocation; - newStructureLocation.X += WorldGen.genRand.Next(-100, 101); - newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) - { - honeyChestLocation = newStructureLocation; - CreateStandAndPlaceHoneyChest(newStructureLocation); - break; - } - } - for (int l = 0; l < maxAttempts; l++) - { - Vector2 newStructureLocation = larvaLocation; - newStructureLocation.X += WorldGen.genRand.Next(-100, 101); - newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && Vector2.Distance(honeyChestLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) - { - CreateStandAndPlaceHoneyChest(newStructureLocation); - break; - } - } + //Vector2 honeyChestLocation = default; + //for (int l = 0; l < maxAttempts; l++) + //{ + // Vector2 newStructureLocation = larvaLocation; + // newStructureLocation.X += WorldGen.genRand.Next(-100, 101); + // newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); + // if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) + // { + // honeyChestLocation = newStructureLocation; + // CreateStandAndPlaceHoneyChest(newStructureLocation); + // break; + // } + //} + //for (int l = 0; l < maxAttempts; l++) + //{ + // Vector2 newStructureLocation = larvaLocation; + // newStructureLocation.X += WorldGen.genRand.Next(-100, 101); + // newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); + // if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && Vector2.Distance(honeyChestLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) + // { + // CreateStandAndPlaceHoneyChest(newStructureLocation); + // break; + // } + //} CalamityUtils.AddProtectedStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5); return true; } + public static bool PlaceLayer(int X, int Y, int height, int tileType) + { + for (int j = Y; j <= Y + height; j++) + { + if (Main.tile[X, j].HasTile && Main.tile[X, j + 1].HasTile && Main.tile[X, j + 2].HasTile && Main.tile[X, j + 3].HasTile && + Main.tile[X - 1, j + 3].HasTile && Main.tile[X + 1, j + 3].HasTile) + { + Main.tile[X, j].TileType = (ushort)tileType; + } + else + { + return false; + } + } + + return true; + } private static void FrameOutAllHiveContents(Point origin, int squareHalfWidth) { int maxXsize = Math.Max(10, origin.X - squareHalfWidth); @@ -272,125 +292,257 @@ namespace CalamityMod.World { for (int j = maxYSize; j < minYSize; j++) { - Tile tile = Main.tile[i, j]; - if (tile.HasTile && tile.TileType == TileID.Hive) - WorldGen.SquareTileFrame(i, j); + //Tile tile = Main.tile[i, j]; + //if (tile.HasTile && tile.TileType == TileID.Hive) + // WorldGen.SquareTileFrame(i, j); - if (tile.WallType == WallID.HiveUnsafe) - WorldGen.SquareWallFrame(i, j); + //if (tile.WallType == WallID.HiveUnsafe) + // WorldGen.SquareWallFrame(i, j); + bool canPlaceSand = false; + + if (Main.tile[i, j].TileType == TileID.Hive && !Main.tile[i, j - 1].HasTile && !Main.tile[i, j - 2].HasTile && !Main.tile[i, j - 3].HasTile) + { + canPlaceSand = true; + } + + if (canPlaceSand) + { + PlaceLayer(i, j, WorldGen.genRand.Next(2, 3), TileID.HoneyBlock); + } } } } - - private static Vector2 CreateHiveTunnel(int i, int j, UnifiedRandom random) + public static void CreateHexagon(int centerX, int centerY, int hexagonSize, int tileType, bool doWalls = false) { - double randOffset = random.Next(20, 26); - float tunnelPlacementAttempts = random.Next(30, 41); - float miniMaxXTiles = Main.maxTilesX / 4200; - miniMaxXTiles = (miniMaxXTiles + 1f) / 2f; - randOffset *= (double)miniMaxXTiles; - tunnelPlacementAttempts *= miniMaxXTiles; + int halfHexagonSize = hexagonSize / 2; - double randOffsetCopy = randOffset; - Vector2 result = default; - result.X = i; - result.Y = j; - Vector2 defaultTunnelPos = default; - defaultTunnelPos.X = random.Next(-10, 11) * 0.2f; - defaultTunnelPos.Y = random.Next(-10, 11) * 0.2f; - while (randOffset > 0.0 && tunnelPlacementAttempts > 0f) + for (int x = -halfHexagonSize; x <= halfHexagonSize; x++) { - if (result.Y > (Main.maxTilesY - 250)) - tunnelPlacementAttempts = 0f; + int y1 = Math.Abs(x) / 2; + int y2 = hexagonSize - Math.Abs(x) / 2; - randOffset = randOffsetCopy * (double)(1f + random.Next(-20, 20) * 0.01f); - tunnelPlacementAttempts -= 1f; - int mainXOffset = (int)(result.X - randOffset); - int maxXOffset = (int)(result.X + randOffset); - int minYOffset = (int)(result.Y - randOffset); - int maxYOffset = (int)(result.Y + randOffset); - if (mainXOffset < 1) - mainXOffset = 1; - - if (maxXOffset > Main.maxTilesX - 1) - maxXOffset = Main.maxTilesX - 1; - - if (minYOffset < 1) - minYOffset = 1; - - if (maxYOffset > Main.maxTilesY - 1) - maxYOffset = Main.maxTilesY - 1; - - for (int k = mainXOffset; k < maxXOffset; k++) + for (int y = y1; y < y2; y++) { - for (int l = minYOffset; l < maxYOffset; l++) + int tileX = centerX + x; + int tileY = centerY + y; + + if (WorldGen.InWorld(tileX, tileY)) { - if (!WorldGen.InWorld(k, l, 50)) + Tile tTile = Main.tile[tileX, tileY]; + if (!doWalls) { - tunnelPlacementAttempts = 0f; + tTile.HasTile = true; + tTile.TileType = (ushort)tileType; + WorldGen.SquareTileFrame(tileX, tileY); } else { - if (Main.tile[k - 10, l].WallType == WallID.LihzahrdBrickUnsafe) - tunnelPlacementAttempts = 0f; - - if (Main.tile[k + 10, l].WallType == WallID.LihzahrdBrickUnsafe) - tunnelPlacementAttempts = 0f; - - if (Main.tile[k, l - 10].WallType == WallID.LihzahrdBrickUnsafe) - tunnelPlacementAttempts = 0f; - - if (Main.tile[k, l + 10].WallType == WallID.LihzahrdBrickUnsafe) - tunnelPlacementAttempts = 0f; - } - - if (l < Main.worldSurface && Main.tile[k, l - 5].WallType == WallID.None) - tunnelPlacementAttempts = 0f; - - float tileXDist = Math.Abs(k - result.X); - float tileYDist = Math.Abs(l - result.Y); - double tileDistance = Math.Sqrt(tileXDist * tileXDist + tileYDist * tileYDist); - if (tileDistance < randOffsetCopy * 0.4 * (1.0 + random.Next(-10, 11) * 0.005)) - { - Main.tile[k, l].LiquidAmount = byte.MaxValue; - Main.tile[k, l].Get().LiquidType = LiquidID.Honey; - Main.tile[k, l].WallType = WallID.HiveUnsafe; - Main.tile[k, l].Get().HasTile = false; - Main.tile[k, l].Get().IsHalfBlock = false; - Main.tile[k, l].Get().Slope = SlopeType.Solid; - } - else if (tileDistance < randOffsetCopy * 0.75 * (1.0 + random.Next(-10, 11) * 0.005)) - { - Main.tile[k, l].LiquidAmount = 0; - if (Main.tile[k, l].WallType != WallID.HiveUnsafe) - { - Main.tile[k, l].Get().HasTile = true; - Main.tile[k, l].Get().IsHalfBlock = false; - Main.tile[k, l].Get().Slope = SlopeType.Solid; - Main.tile[k, l].TileType = TileID.Hive; - } - } - - if (tileDistance < randOffsetCopy * 0.6 * (1.0 + random.Next(-10, 11) * 0.005)) - { - Main.tile[k, l].WallType = WallID.HiveUnsafe; - if (random.NextBool()) - { - Main.tile[k, l].LiquidAmount = byte.MaxValue; - Main.tile[k, l].Get().LiquidType = LiquidID.Honey; - } + tTile.WallType = WallID.HiveUnsafe; + WorldGen.SquareWallFrame(tileX, tileY); } } } + } + } + public static void CreateGiantHiveHexagon(int centerX, int centerY, int hexagonSize, int tileType, bool doWalls = false) + { + int halfHexagonSize = hexagonSize / 2; - result += defaultTunnelPos; - tunnelPlacementAttempts -= 1f; - defaultTunnelPos.Y += random.Next(-10, 11) * 0.05f; - defaultTunnelPos.X += random.Next(-10, 11) * 0.05f; + for (int x = -halfHexagonSize; x <= halfHexagonSize; x++) + { + int y1 = Math.Abs(x) / 2; + int y2 = hexagonSize - Math.Abs(x) / 2; + + for (int y = y1; y < y2; y++) + { + int tileX = centerX + x; + int tileY = centerY + y; + + if (WorldGen.InWorld(tileX, tileY)) + { + Tile tTile = Main.tile[tileX, tileY]; + if (!doWalls) + { + tTile.HasTile = true; + tTile.TileType = (ushort)tileType; + WorldGen.SquareTileFrame(tileX, tileY); + } + else + { + tTile.WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(tileX, tileY); + } + } + } + } + } + public static void ClearHexagon(int centerX, int centerY, int hexagonSize) + { + int halfHexagonSize = hexagonSize / 2; + + for (int x = -halfHexagonSize; x <= halfHexagonSize; x++) + { + int y1 = Math.Abs(x) / 2; + int y2 = hexagonSize - Math.Abs(x) / 2; + + for (int y = y1; y < y2; y++) + { + int tileX = centerX + x; + int tileY = centerY + y; + + if (WorldGen.InWorld(tileX, tileY)) + { + Tile tTile = Main.tile[tileX, tileY]; + tTile.HasTile = false; + tTile.WallType = WallID.HiveUnsafe; + tTile.LiquidAmount = 0; + WorldGen.SquareWallFrame(tileX, tileY); + if (WorldGen.genRand.NextBool(15)) + { + tTile.LiquidAmount = 100; + tTile.LiquidType = LiquidID.Honey; + WorldGen.SquareTileFrame(tileX, tileY); + } + } + } + } + } + public static void GiantHiveWallHexagon(int centerX, int centerY, int hexagonSize) + { + int halfHexagonSize = hexagonSize / 2; + + for (int x = -halfHexagonSize; x <= halfHexagonSize; x++) + { + int y1 = Math.Abs(x) / 2; + int y2 = hexagonSize - Math.Abs(x) / 2; + + for (int y = y1; y < y2; y++) + { + int tileX = centerX + x; + int tileY = centerY + y; + + if (WorldGen.InWorld(tileX, tileY)) + { + Tile tTile = Main.tile[tileX, tileY]; + tTile.HasTile = false; + tTile.WallType = (ushort)ModContent.WallType(); + tTile.LiquidAmount = 0; + WorldGen.SquareWallFrame(tileX, tileY); + if (WorldGen.genRand.NextBool(15)) + { + tTile.LiquidAmount = 100; + tTile.LiquidType = LiquidID.Honey; + WorldGen.SquareTileFrame(tileX, tileY); + } + } + } + } + } + public static Vector2 MakeCell(int x, int y, UnifiedRandom random) + { + CreateHexagon(x, y - 30, 110, TileID.Hive); + CreateGiantHiveHexagon(x, y - 30, 108, TileID.Hive, true); + GiantHiveWallHexagon(x, y - 22, 90); + + + + return new Vector2(x, y); + } + public static Vector2 MakeCellHoney(int x, int y, UnifiedRandom random) + { + int attempts = 0; + int hexagonsToPlace = WorldGen.genRand.Next(1, 3); // number of honey hexagons to place + + while (attempts < 100 && hexagonsToPlace > 0) + { + attempts++; + + int offsetX = WorldGen.genRand.Next(-60, 60); + int offsetY = WorldGen.genRand.Next(-50, 50); + + int targetX = x + offsetX; + int targetY = y + offsetY; + + // Check a 3x3 area for mostly Hive tiles to confirm it's inside the hive + bool valid = true; + for (int i = -1; i <= 1 && valid; i++) + { + for (int j = -1; j <= 1 && valid; j++) + { + int checkX = targetX + i; + int checkY = targetY + j; + + if (!WorldGen.InWorld(checkX, checkY)) + valid = false; + else if (!Main.tile[checkX, checkY].HasTile || Main.tile[checkX, checkY].TileType != TileID.Hive) + valid = false; + } + } + + if (valid) + { + int radius = WorldGen.genRand.Next(7, 10); + CreateHexagon(targetX, targetY, radius, TileID.HoneyBlock); + hexagonsToPlace--; + } } - return result; + return new Vector2(x, y); } + public static Vector2 MakeOuterCell(int x, int y, UnifiedRandom random) + { + int numConnections = WorldGen.genRand.Next(3, 6); + List placedHexes = new List(); + int chestsPlaced = 0; + int chestMax = 4; // Number of chests to spawn in outer cells + + for (int i = 0; i < numConnections; i++) + { + bool placed = false; + int attempts = 0; + + while (!placed && attempts < 10) + { + attempts++; + + float angle = MathHelper.ToRadians(WorldGen.genRand.Next(0, 180)); + float distance = WorldGen.genRand.Next(80, 120); + + int newX = x + (int)(Math.Cos(angle) * distance); + int newY = y + (int)(Math.Sin(angle) * distance); + Vector2 newPos = new Vector2(newX, newY); + + bool overlaps = placedHexes.Any(pos => Vector2.Distance(pos, newPos) < 60); + + if (!overlaps) + { + int hexRadius = WorldGen.genRand.Next(30, 45); + CreateGiantHiveHexagon(newX, newY - 15, hexRadius - 1, TileID.Hive, true); + CreateHexagon(newX, newY - 15, hexRadius, TileID.Hive); + MiscWorldgenRoutines.ClearTunnel(x, y + 30, newX, newY, 5, 0, 2, true, true); + MiscWorldgenRoutines.CreateTunnel(x, y + 30, newX, newY, 6, TileID.Hive); + MiscWorldgenRoutines.ClearTunnel(x, y + 30, newX, newY, 3, (ushort)ModContent.WallType(), 2, true, true); + GiantHiveWallHexagon(newX, newY - 10, WorldGen.genRand.Next(19, 26)); + + // Place honey chest in this cell with a small chance + if (chestsPlaced < chestMax) + { + CreateStandAndPlaceHoneyChest(new Vector2(newX, newY)); + chestsPlaced++; + } + + placedHexes.Add(newPos); + placed = true; + } + } + } + + GiantHiveWallHexagon(x, y - 22, 90); + ClearHexagon(x, y - 18, 80); + + return new Vector2(x, y); + } + private static bool TooCloseToImportantLocations(Point origin) { @@ -441,26 +593,26 @@ namespace CalamityMod.World } } - private static void CreateBlockedHoneyCube(int x, int y) - { - for (int i = x - 1; i <= x + 2; i++) - { - for (int j = y - 1; j <= y + 2; j++) - { - if (i >= x && i <= x + 1 && j >= y && j <= y + 1) - { - Main.tile[i, j].Get().HasTile = false; - Main.tile[i, j].LiquidAmount = byte.MaxValue; - Main.tile[i, j].Get().LiquidType = LiquidID.Honey; - } - else - { - Main.tile[i, j].Get().HasTile = true; - Main.tile[i, j].TileType = TileID.Hive; - } - } - } - } + //private static void CreateBlockedHoneyCube(int x, int y) + //{ + // for (int i = x - 1; i <= x + 2; i++) + // { + // for (int j = y - 1; j <= y + 2; j++) + // { + // if (i >= x && i <= x + 1 && j >= y && j <= y + 1) + // { + // Main.tile[i, j].Get().HasTile = false; + // Main.tile[i, j].LiquidAmount = byte.MaxValue; + // Main.tile[i, j].Get().LiquidType = LiquidID.Honey; + // } + // else + // { + // Main.tile[i, j].Get().HasTile = true; + // Main.tile[i, j].TileType = TileID.Hive; + // } + // } + // } + //} private static bool SpotActuallyNotInHive(int x, int y) { @@ -598,12 +750,13 @@ namespace CalamityMod.World int index = 0; - chest.item[index++].SetDefaults(random.Next(FocusLootHoney)); + chest.item[index].SetDefaults(random.Next(FocusLootHoney)); + chest.item[index++].Prefix(-1); if (random.Next(3) <= 1) { chest.item[index].SetDefaults(random.Next(BarLootHoney)); - chest.item[index].SetDefaults(random.Next(7, 15)); + chest.item[index++].stack = random.Next(7, 15); } else { diff --git a/World/MechanicShed.cs b/World/MechanicShed.cs index 653edd2d18..b0a67266a3 100644 --- a/World/MechanicShed.cs +++ b/World/MechanicShed.cs @@ -4,7 +4,6 @@ using CalamityMod.Schematics; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.ModLoader; using Terraria.WorldBuilding; using static CalamityMod.Schematics.SchematicManager; @@ -17,27 +16,95 @@ namespace CalamityMod.World string mapKey = MechanicShedKey; var schematic = TileMaps[mapKey]; - int placementPositionX = WorldGen.genRand.Next(GenVars.snowOriginLeft + 100, GenVars.snowOriginRight - 100); - int placementPositionY = (int)Main.worldSurface - (Main.maxTilesY / 12); + int leftLimit = GenVars.snowOriginLeft + 100; + int rightLimit = GenVars.snowOriginRight - 100; + int placementPositionX = WorldGen.genRand.Next(leftLimit, rightLimit); + int placementPositionY = (int)Main.worldSurface - 50; + + int distanceToCheckForSnowTilesX = 30; + int distanceToCheckForSnowTilesY = 5; + int snowTilesRequired = 100; + int emptyTilesRequired = 100; bool foundValidGround = false; int attempts = 0; - while (!foundValidGround && attempts++ < 100000) + int maxAttempts = 100000; + while (!foundValidGround && attempts <= maxAttempts) { - while (!WorldGen.SolidTile(placementPositionX, placementPositionY) && placementPositionY <= Main.worldSurface) + attempts++; + + // Check if there are enough snow tiles on the bottom of the shed's gen location + // 150 tiles checked in total + int snowTileCount = 0; + bool enoughSnowTilesOnBottom = false; + for (int shedTileCheckIndexX = placementPositionX - 15; shedTileCheckIndexX < placementPositionX - 15 + distanceToCheckForSnowTilesX; shedTileCheckIndexX++) { - placementPositionY++; + if (enoughSnowTilesOnBottom) + break; + + for (int shedTileCheckIndexY = placementPositionY - 5; shedTileCheckIndexY < placementPositionY - 5 + distanceToCheckForSnowTilesY; shedTileCheckIndexY++) + { + if (Main.tile[shedTileCheckIndexX, shedTileCheckIndexY] != null) + { + if (Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].HasTile) + { + if (Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].TileType == TileID.SnowBlock) + { + snowTileCount++; + if (snowTileCount >= snowTilesRequired) + { + enoughSnowTilesOnBottom = true; + break; + } + } + } + } + } } - if (Main.tile[placementPositionX, placementPositionY].HasTile || Main.tile[placementPositionX, placementPositionY].WallType > 0) + // Check if there are enough empty tiles on the top of the shed's gen location + // 150 tiles checked in total + int emptyTileCount = 0; + bool enoughEmptyTilesOnTop = false; + for (int shedTileCheckIndexX = placementPositionX - 15; shedTileCheckIndexX < placementPositionX - 15 + distanceToCheckForSnowTilesX; shedTileCheckIndexX++) { - foundValidGround = true; + if (enoughEmptyTilesOnTop) + break; + + for (int shedTileCheckIndexY = placementPositionY - 20; shedTileCheckIndexY < placementPositionY - 20 + distanceToCheckForSnowTilesY; shedTileCheckIndexY++) + { + if ((Main.tile[shedTileCheckIndexX, shedTileCheckIndexY] == null || + !Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].HasTile) && + Main.tile[shedTileCheckIndexX, shedTileCheckIndexY].WallType == WallID.None) + { + emptyTileCount++; + if (emptyTileCount >= emptyTilesRequired) + { + enoughEmptyTilesOnTop = true; + break; + } + } + } + } + + if (enoughSnowTilesOnBottom && enoughEmptyTilesOnTop) + { + break; + } + else + { + placementPositionX += 5; + if (placementPositionX > rightLimit) + placementPositionX = leftLimit; + + if (!enoughEmptyTilesOnTop) + placementPositionY -= 5; + else if (!enoughSnowTilesOnBottom) + placementPositionY += 5; } } - Point placementPoint = new Point(placementPositionX, placementPositionY + 5); - - Vector2 schematicSize = new Vector2(schematic.GetLength(0), schematic.GetLength(1)); + Point placementPoint = new Point(placementPositionX, placementPositionY); SchematicAnchor anchorType = SchematicAnchor.BottomCenter; bool place = true; @@ -62,6 +129,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } diff --git a/World/Minibiomes/FloralParadiseMinibiome.cs b/World/Minibiomes/FloralParadiseMinibiome.cs deleted file mode 100644 index 511652ec56..0000000000 --- a/World/Minibiomes/FloralParadiseMinibiome.cs +++ /dev/null @@ -1,535 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using CalamityMod.Tiles.DraedonStructures; -using CalamityMod.Tiles.FloralParadise; -using CalamityMod.Tiles.SunkenSea; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.ObjectData; -using Terraria.Utilities; -using Terraria.WorldBuilding; - -namespace CalamityMod.World.Minibiomes -{ - public class FloralParadiseMinibiome - { - // 02JUN2024: Ozzatron: Disable generation of the Floral Paradise biome on the assumption that it will break horribly until tested. - internal static readonly bool SHOULD_GENERATE = false; - - // Constants pertaining to the more important details of the world-gen, to allow for ease-of-change. - // Certain numbers are hardcoded and not present here, but they tend to be in regards to things that either really shouldn't need changing or - // are extremely subtle details. - public const int TotalCavesInMediumWorld = 3; - - public const int MaxHorizontalDistanceFromWorldCenter = 1250; - - public const int MinSurfaceDepth = 250; - - public const int MaxSurfaceDepth = 420; - - public const int BlacklistedTileCheckArea = 50; - - public const float CaveOpennessFactor = 0.08f; - - public const float WallOpennessFactor = 0.135f; - - public const int TotalSecondaryDirtCreationPasses = 1; - - public const float SecondaryPassDirtCreationChance = 0.5f; - - public const int MinVigorousVineLength = 6; - - public const int MaxVigorousVineLength = 16; - - public const int MinSmallVineLength = 9; - - public const int MaxSmallVineLength = 17; - - public const int MinSmallVineCount = 45; - - public const int MaxSmallVineCount = 64; - - public const int MinPondWaterTileCount = 180; - - public const int MaxPondWaterTileCount = 210; - - public static int[] BlacklistedNearbyTiles => new int[] - { - TileID.Sand, - TileID.Sandstone, - TileID.HardenedSand, - TileID.DesertFossil, - TileID.SnowBlock, - TileID.IceBlock, - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - ModContent.TileType(), - }; - - public static void GenerateInstances() - { - float worldSize = Main.maxTilesX / 4200f; - int totalCaves = (int)(worldSize * TotalCavesInMediumWorld); - int infiniteLoopPreventerIncrement = 0; - List existingCaveAreas = new List(); - for (int i = 0; i < totalCaves - 1; i++) - { - // Use an emergency infinite loop increment. - // The placement loop is left if it exceeds an extremely large quantity. - // This exists primarily due to potential issues in small worlds. - // This will likely never be hit in typical circumstances, but it's better to be safe than sorry. - infiniteLoopPreventerIncrement++; - if (infiniteLoopPreventerIncrement >= 3000) - break; - - int x = Main.maxTilesX / 2 + WorldGen.genRand.Next(-MaxHorizontalDistanceFromWorldCenter, MaxHorizontalDistanceFromWorldCenter); - int y = (int)Main.worldSurface + WorldGen.genRand.Next(MinSurfaceDepth, MaxSurfaceDepth); - int width = (int)(WorldGen.genRand.Next(127, 140) * worldSize); - int height = (int)(WorldGen.genRand.Next(80, 104) * worldSize); - Rectangle caveArea = Utils.CenteredRectangle(new Vector2(x, y), new Vector2(width, height)); - - // Try again if this selected location is near blacklisted tiles. - // This is done to prevent logical consistencies/intrusion on unrelated biomes. - bool needsToTryAgain = false; - for (int dx = -BlacklistedTileCheckArea; dx < BlacklistedTileCheckArea; dx++) - { - for (int dy = -BlacklistedTileCheckArea; dy < BlacklistedTileCheckArea; dy++) - { - if (!needsToTryAgain) - { - Tile tile = CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy); - needsToTryAgain = tile.HasTile && BlacklistedNearbyTiles.Contains(tile.TileType); - } - else - break; - } - } - - // If the blacklisted tile check was passed, check to see if the potential spot is near. - if (!needsToTryAgain) - needsToTryAgain = existingCaveAreas.Any(c => caveArea.Intersects(c)); - - if (needsToTryAgain) - { - i--; - continue; - } - - Place(caveArea); - existingCaveAreas.Add(caveArea); - } - - // Generate a single, special living tree on the surface with a floral paradise biome underneath. - for (int i = 0; i < 2000; i++) - { - int x = Main.maxTilesX / 2 + WorldGen.genRand.Next(330, MaxHorizontalDistanceFromWorldCenter) * WorldGen.genRand.NextBool().ToDirectionInt(); - int y = (int)Main.worldSurface - 120; - if (!FloralParadiseTree.Create(new(x, y))) - continue; - break; - } - } - - public static void Place(Rectangle placementArea) - { - int seed = WorldGen.genRand.Next(); - int pondCount = WorldGen.genRand.Next(3); - int smallVineCount = WorldGen.genRand.Next(MinSmallVineCount, MaxSmallVineCount); - int waterTileCount = WorldGen.genRand.Next(MinPondWaterTileCount, MaxPondWaterTileCount); - int smallFlowerCount = WorldGen.genRand.Next(150, 200); - int bigTreeCount = WorldGen.genRand.Next(2, 5); - - CutOutCave(placementArea, seed, out bool[,] grassDirtMap); - GenerateDirtBehindGrass(placementArea, grassDirtMap); - GenerateWalls(placementArea, unchecked(seed - 8)); - GenerateVines(placementArea, smallVineCount); - GeneratePonds(placementArea, waterTileCount, pondCount); - CreateScenicPlants(placementArea, smallFlowerCount); - CreateTrees(placementArea, bigTreeCount); - - // Place a blood orange. THIS IS FOR TESTING PURPOSES. - for (int i = 0; i < 1; i++) - { - int x = placementArea.X + WorldGen.genRand.Next(24, placementArea.Width - 24); - int y = placementArea.Y + WorldGen.genRand.Next(18, placementArea.Height - 18); - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (!WorldGen.SolidTile(x, y + 1) || !WorldGen.SolidTile(x + 1, y + 1) || tile.HasTile || tile.LiquidAmount > 0) - { - i--; - continue; - } - x--; - - for (int dx = 0; dx < 3; dx++) - { - for (int dy = 0; dy < 3; dy++) - { - Main.tile[x + dx, y + dy].TileType = (ushort)ModContent.TileType(); - Main.tile[x + dx, y + dy].TileFrameX = (short)(dx * 18); - Main.tile[x + dx, y + dy].TileFrameY = (short)(dy * 18); - Main.tile[x + dx, y + dy].Get().HasTile = true; - } - } - } - } - - public static void CutOutCave(Rectangle placementArea, int seed, out bool[,] grassDirtMap) - { - // Calculate the initial cell states with perlin noise. - // To be specific, it uses values near the midpoint of 0.5 as open caves. - // This helps solve the problem of having disconnected areas that using min/max threshold values causes. - bool[,] caveState = new bool[placementArea.Width, placementArea.Height]; - for (int i = 0; i < placementArea.Width; i++) - { - for (int j = 0; j < placementArea.Height; j++) - { - float noise = CalamityUtils.PerlinNoise2D(i / 240f, j / 180f, 3, seed) * 0.5f + 0.5f; - caveState[i, j] = MathHelper.Distance(noise, 0.56f) < CaveOpennessFactor; - if (WorldGen.genRand.NextBool(3)) - caveState[i, j] = WorldGen.genRand.NextBool(); - } - } - - // Repeatedly smoothen out the cave state with celluar automata. - for (int i = 0; i < 8; i++) - caveState = CalamityUtils.SimulateCelluarAutomata(caveState); - - // Reset tile states based on the above results. - ushort grassID = (ushort)ModContent.TileType(); - ushort stoneID = (ushort)ModContent.TileType(); - grassDirtMap = new bool[placementArea.Width, placementArea.Height]; - for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) - { - for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) - { - // Don't attempt to change tile data if a tile is outside of the world for some reason. - if (!WorldGen.InWorld(x, y, 1)) - continue; - - int arrayRelativeX = x - placementArea.X; - int arrayRelativeY = y - placementArea.Y; - Vector2 normalizedPosition = new Vector2(arrayRelativeX / (float)placementArea.Width, arrayRelativeY / (float)placementArea.Height); - float distanceFromCenter = Vector2.Distance(normalizedPosition, Vector2.One * 0.5f) * 1.75f; - if (distanceFromCenter > 1f) - distanceFromCenter = 1f; - - float ditherChance = Utils.GetLerpValue(0.97f, 0.72f, distanceFromCenter, true); - - Main.tile[x, y].WallType = WallID.None; - if (WorldGen.genRand.NextFloat() < ditherChance) - { - if (!caveState[arrayRelativeX, arrayRelativeY] && distanceFromCenter < 0.7f) - Main.tile[x, y].ClearEverything(); - else - { - bool useGrass = CalamityUtils.CountCellsAtPosition(caveState, arrayRelativeX, arrayRelativeY, false) >= 1 && distanceFromCenter < 0.72f; - grassDirtMap[arrayRelativeX, arrayRelativeY] = useGrass; - Main.tile[x, y].ClearEverything(); - Main.tile[x, y].ResetToType(useGrass ? grassID : stoneID); - WorldGen.SquareTileFrame(x, y); - } - } - } - } - } - - public static void GenerateDirtBehindGrass(Rectangle placementArea, bool[,] grassDirtMap) - { - ushort dirtID = (ushort)ModContent.TileType(); - ushort stoneID = (ushort)ModContent.TileType(); - ushort grassID = (ushort)ModContent.TileType(); - - // Perform secondary passes that overlay dirt behind grass. - for (int i = 0; i < TotalSecondaryDirtCreationPasses + 1; i++) - { - for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) - { - for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) - { - int arrayRelativeX = x - placementArea.X; - int arrayRelativeY = y - placementArea.Y; - bool nearbyGrassOrDirt = false; - if (arrayRelativeX - 1 >= 0 && grassDirtMap[arrayRelativeX - 1, arrayRelativeY]) - nearbyGrassOrDirt = true; - else if (arrayRelativeX + 1 < placementArea.Width && grassDirtMap[arrayRelativeX + 1, arrayRelativeY]) - nearbyGrassOrDirt = true; - else if (arrayRelativeY - 1 >= 0 && grassDirtMap[arrayRelativeX, arrayRelativeY - 1]) - nearbyGrassOrDirt = true; - else if (arrayRelativeY + 1 < placementArea.Height && grassDirtMap[arrayRelativeX, arrayRelativeY + 1]) - nearbyGrassOrDirt = true; - - // The first pass always generates dirt behind grass. - // However, successive passes only generate dirt with a specific probability. - // This makes the dirt feel more natural and connected to the underlying rock. - bool canPerformPlacement = i == 0 || WorldGen.genRand.NextFloat() < SecondaryPassDirtCreationChance; - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (canPerformPlacement && tile.HasTile && tile.TileType == stoneID && nearbyGrassOrDirt) - Main.tile[x, y].TileType = dirtID; - } - } - - // Reset the dirt/grass map for the next pass. - // This is skipped on the last pass for performance reasons, since the map won't be used after that point. - if (i >= TotalSecondaryDirtCreationPasses) - continue; - - for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) - { - for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) - { - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - int arrayRelativeX = x - placementArea.X; - int arrayRelativeY = y - placementArea.Y; - grassDirtMap[arrayRelativeX, arrayRelativeY] = tile.TileType == grassID || tile.TileType == dirtID; - } - } - } - } - - public static void GenerateWalls(Rectangle placementArea, int seed) - { - for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) - { - for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) - { - float noise = CalamityUtils.PerlinNoise2D(x / 160f, y / 160f, 3, seed) * 0.5f + 0.5f; - if (MathHelper.Distance(noise, 0.555f) < WallOpennessFactor) - Main.tile[x, y].WallType = WorldGen.genRand.NextBool(4) ? WallID.GrassUnsafe : WallID.FlowerUnsafe; - } - } - } - - public static void GenerateVines(Rectangle placementArea, int smallVineCount) - { - ushort[] vineIDs = new ushort[] - { - (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), - }; - - // Place small vines. - for (int i = 0; i < smallVineCount; i++) - { - int x = placementArea.X + WorldGen.genRand.Next(24, placementArea.Width - 24); - int y = placementArea.Y + WorldGen.genRand.Next(18, placementArea.Height - 18); - - // Ensure that the initial tile is empty and that there's a solid tile above for the vine to hang from. - // If these conditions are not met, try again. - if (CalamityUtils.ParanoidTileRetrieval(x, y).HasTile || !WorldGen.SolidTile(x, y - 1)) - { - i--; - continue; - } - - // Search to ensure that nothing is in the way of the vine's potential positions. - // If something is, try again. - int vineLength = WorldGen.genRand.Next(MinSmallVineLength, MaxSmallVineLength + 1); - bool neeedsToTryAgain = false; - for (int dy = 0; dy < vineLength; dy++) - { - if (CalamityUtils.ParanoidTileRetrieval(x, y + dy).HasTile) - { - neeedsToTryAgain = true; - break; - } - } - - if (neeedsToTryAgain) - { - i--; - continue; - } - - // Perform placement. - ushort vineID = WorldGen.genRand.Next(vineIDs); - for (int dy = 0; dy < vineLength; dy++) - { - Main.tile[x, y + dy].TileType = vineID; - if (dy == vineLength - 1) - { - Main.tile[x, y + dy].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[x, y + dy].TileFrameY = 54; - } - else - { - Main.tile[x, y + dy].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); - Main.tile[x, y + dy].TileFrameY = (short)(WorldGen.genRand.Next(3) * 18); - } - Main.tile[x, y + dy].Get().HasTile = true; - WorldGen.SquareTileFrame(x, y, true); - } - } - } - - public static void GeneratePonds(Rectangle placementArea, int waterTileCount, int pondCount) - { - for (int i = 0; i < pondCount; i++) - { - int x = placementArea.X + WorldGen.genRand.Next(24, placementArea.Width - 24); - int y = placementArea.Y + WorldGen.genRand.Next(24, placementArea.Height - 24); - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (tile.HasTile || tile.LiquidAmount > 0) - { - i--; - continue; - } - - // Go upward once an open area is found. This is where water will be created. - Point waterSpawnPoint = new Point(x, y); - for (int dy = 0; dy < 100; dy++) - { - if (CalamityUtils.ParanoidTileRetrieval(x, y - dy).HasTile) - { - waterSpawnPoint.Y -= dy - 1; - break; - } - } - - // Create a predetermined quantity of water via recursion. - // This starts at the initial water spawn point and the expands outward in all four cardinal directions repeatedly until either no more locations - // are valid or the water limit has been reached. - int increment = 0; - RecursivelyFillAreaWithWater(x, y, waterTileCount, ref increment); - - // Settle water and create waterfalls. - Liquid.QuickWater(3); - WorldGen.WaterCheck(); - Liquid.quickSettle = true; - Liquid.UpdateLiquid(); - WorldGen.WaterCheck(); - Liquid.quickSettle = false; - - for (int dy = 0; dy < 50; dy++) - { - if (CalamityUtils.ParanoidTileRetrieval(x, y + dy).LiquidAmount > 0) - { - Main.tile[x, y + dy - 8].Get().HasTile = true; - Main.tile[x, y + dy - 8].TileType = (ushort)ModContent.TileType(); - break; - } - } - } - } - - public static void CreateScenicPlants(Rectangle placementArea, int smallFlowerCount) - { - for (int i = 0; i < smallFlowerCount; i++) - { - int x = placementArea.X + WorldGen.genRand.Next(16, placementArea.Width - 16); - int y = placementArea.Y + WorldGen.genRand.Next(12, placementArea.Height - 12); - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (tile.HasTile || tile.LiquidAmount > 0 || !WorldGen.SolidTile(x, y + 1)) - { - i--; - continue; - } - - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - Main.tile[x, y].TileFrameX = (short)(WorldGen.genRand.Next(8) * 18); - Main.tile[x, y].TileFrameY = 0; - Main.tile[x, y].Get().HasTile = true; - } - - // TODO -- Move this to another method. - int tries = 0; - WeightedRandom tileSelector = new(WorldGen.genRand); - tileSelector.Add(ModContent.TileType(), 0.66D); - tileSelector.Add(ModContent.TileType(), 0.66D); - tileSelector.Add(ModContent.TileType(), 0.66D); - tileSelector.Add(ModContent.TileType(), 0.66D); - tileSelector.Add(ModContent.TileType(), 0.66D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 0.5D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - tileSelector.Add(ModContent.TileType(), 1D); - - for (int i = 0; i < 2400; i++) - { - tries++; - if (tries >= 16000) - break; - - int x = placementArea.X + WorldGen.genRand.Next(16, placementArea.Width - 16); - int y = placementArea.Y + WorldGen.genRand.Next(12, placementArea.Height - 12); - if (WorldGen.genRand.NextBool() && WorldUtils.Find(new(x, y), Searches.Chain(new Searches.Down(400), new Conditions.IsSolid()), out Point result)) - y = result.Y - 1; - - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (tile.HasTile || tile.LiquidAmount > 0) - { - i--; - continue; - } - - int tileID = tileSelector.Get(); - WorldGen.PlaceTile(x, y, tileID, style: WorldGen.genRand.Next(TileObjectData.GetTileData(tileID, 0).RandomStyleRange)); - } - } - - public static void CreateTrees(Rectangle placementArea, int treeCount) - { - int tries = 0; - int treeID = ModContent.TileType(); - - for (int i = 0; i < treeCount; i++) - { - tries++; - - int x = placementArea.X + WorldGen.genRand.Next(16, placementArea.Width - 16); - int y = placementArea.Y + WorldGen.genRand.Next(12, placementArea.Height - 12); - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - Vector2 checkTopLeft = new Vector2(x, y).ToWorldCoordinates() - new Vector2(120f, 300f); - Vector2 checkArea = new Vector2(240f, 200f); - - if (tries >= 2500) - break; - - if (tile.HasTile || tile.LiquidAmount > 0 || !WorldGen.SolidTile(x, y + 1) || - !TileObject.CanPlace(x, y, treeID, 0, 0, out _, true, checkStay: true) || - Collision.SolidCollision(checkTopLeft, (int)checkArea.X, (int)checkArea.Y)) - { - i--; - continue; - } - - WorldGen.PlaceTile(x, y, treeID); - } - } - - #region Biome-Specific Utilities - - public static void RecursivelyFillAreaWithWater(int x, int y, int limit, ref int increment) - { - Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (tile.HasTile || tile.LiquidAmount > 127) - return; - - increment++; - if (increment >= limit) - return; - - Main.tile[x, y].LiquidAmount = 255; - RecursivelyFillAreaWithWater(x + 1, y, limit, ref increment); - RecursivelyFillAreaWithWater(x - 1, y, limit, ref increment); - RecursivelyFillAreaWithWater(x, y + 1, limit, ref increment); - RecursivelyFillAreaWithWater(x, y - 1, limit, ref increment); - } - - #endregion Biome-Specific Utilities - } -} diff --git a/World/Minibiomes/FloralParadiseTree.cs b/World/Minibiomes/FloralParadiseTree.cs deleted file mode 100644 index 4858ac842a..0000000000 --- a/World/Minibiomes/FloralParadiseTree.cs +++ /dev/null @@ -1,139 +0,0 @@ -using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using Terraria; -using Terraria.GameContent.Generation; -using Terraria.ID; -using Terraria.WorldBuilding; - -namespace CalamityMod.World.Minibiomes -{ - public class FloralParadiseTree - { - public const int TrunkHeight = 220; - - public const int TrunkWidth = 10; - - public const int TrunkHollowSpace = 4; - - public const int RootCount = 5; - - public static bool Create(Point placementPosition) - { - float worldSize = Main.maxTilesX / 4200f; - if (!WorldUtils.Find(new Point(placementPosition.X - 3, placementPosition.Y), Searches.Chain(new Searches.Down(400), new GenCondition[] - { - new Conditions.IsSolid().AreaAnd(6, 1) - }), out Point ground)) - { - return false; - } - - ground.Y += (int)(TrunkHeight * 0.645f); - - // Get all tiles in a specific area. - Dictionary tileCounts = new Dictionary(); - WorldUtils.Gen(new Point(ground.X - TrunkHeight / 2, ground.Y - TrunkHeight / 2), new Shapes.Rectangle(TrunkHeight, TrunkHeight), new Actions.TileScanner(new ushort[] - { - TileID.Dirt, - TileID.Stone, - TileID.Mud, - TileID.JungleGrass, - TileID.SnowBlock, - TileID.Sand, - }).Output(tileCounts)); - - int overworldTileCount = tileCounts[TileID.Dirt] + tileCounts[TileID.Stone]; - int jungleTileCount = tileCounts[TileID.Mud] + tileCounts[TileID.JungleGrass]; - - // Avoid jungles, deserts, and snow biomes. - if (tileCounts[TileID.SnowBlock] > jungleTileCount || jungleTileCount > overworldTileCount || overworldTileCount < 50 || tileCounts[TileID.Sand] >= 50) - return false; - - float trunkRotation = WorldGen.genRand.NextFloatDirection() * 0.116f; - for (int i = 0; i < TrunkHeight; i += 2) - { - Point currentPoint = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * i).ToPoint(); - - // Create the trunk. - WorldUtils.Gen(currentPoint, new Shapes.Rectangle(TrunkWidth, TrunkWidth), Actions.Chain(new GenAction[] - { - new Actions.ClearTile(), - new Actions.PlaceWall(WallID.LivingWood, true), - new Actions.PlaceTile(TileID.LivingMahogany) - })); - } - - // Generate roots. - for (int i = 0; i < RootCount; i++) - { - int rootLength = (int)(TrunkHeight * WorldGen.genRand.NextFloat(0.425f, 0.7f)); - float rootAngle = MathHelper.Lerp(-0.89f, 0.89f, i / (float)(RootCount - 1f)) + WorldGen.genRand.NextFloatDirection() * 0.074f + trunkRotation + MathHelper.PiOver2; - WorldUtils.Gen(ground, new ShapeRoot(rootAngle, rootLength, TrunkWidth - 1), Actions.Chain(new GenAction[] - { - new Actions.SetTile(TileID.LivingMahogany), - })); - } - - List branchEnds = new(); - Point topOfTrunk = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * (TrunkHeight - 4f)).ToPoint(); - - // Create side branches. - for (int i = 0; i < RootCount - 1; i++) - { - int branchLength = WorldGen.genRand.Next(26, 49); - float branchDirectionX = -WorldGen.genRand.NextFloat(1.25f, 4.5f) * WorldGen.genRand.NextBool().ToDirectionInt(); - float branchDirectionY = -2f; - Vector2 branchDirection = new Vector2(branchDirectionX, branchDirectionY).SafeNormalize(Vector2.UnitX); - Point branchStart = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * Main.rand.NextFloat(0.45f, 0.84f) * TrunkHeight).ToPoint(); - WorldUtils.Gen(branchStart, new ShapeBranch(branchDirection.ToRotation(), branchLength).OutputEndpoints(branchEnds), Actions.Chain(new GenAction[] - { - new Actions.SetTile(TileID.LivingMahogany), - })); - } - - // Create branch leaves. - using (List.Enumerator enumerator = branchEnds.GetEnumerator()) - { - while (enumerator.MoveNext()) - { - WorldUtils.Gen(enumerator.Current, new Shapes.Circle(4), Actions.Chain(new GenAction[] - { - new Modifiers.Blotches(4, 2, 0.3), - new Actions.SetTile(TileID.LivingMahoganyLeaves), - new Actions.SetFrames(true) - })); - } - } - - // Create leaves at the top of the trunk. - WorldUtils.Gen(topOfTrunk, new Shapes.Circle(TrunkWidth * 2), Actions.Chain(new GenAction[] - { - new Modifiers.Blotches(3, 2, 0.1), - new Actions.SetTile(TileID.LivingMahoganyLeaves), - new Actions.SetFrames(true) - })); - - // Generate a cave in the roots of the biome. - int width = (int)(WorldGen.genRand.Next(104, 120) * worldSize); - int height = (int)(WorldGen.genRand.Next(88, 110) * worldSize); - Vector2 cavePosition = ground.ToVector2() + Vector2.UnitY * height * 0.44f; - Rectangle caveArea = Utils.CenteredRectangle(cavePosition, new Vector2(width, height)); - FloralParadiseMinibiome.Place(caveArea); - - // Clear out the inner part of the tiles to create an open space in the tree. - for (int i = 0; i < TrunkHeight * 0.9f; i += 2) - { - Point currentPoint = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * i).ToPoint(); - Point center = (currentPoint.ToVector2() + Vector2.One * TrunkHollowSpace - Vector2.UnitX * 2f).ToPoint(); - WorldUtils.Gen(center, new Shapes.Rectangle(TrunkHollowSpace, TrunkHollowSpace), Actions.Chain(new GenAction[] - { - new Actions.ClearTile(true), - new Actions.PlaceWall(WallID.LivingWood, true) - })); - } - - return true; - } - } -} diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index 474cf6d647..a1e3b2c1b4 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -1,25 +1,14 @@ using System; -using System.Collections.Generic; -using System.Reflection; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Tiles; +using CalamityMod.Items.Potions.Food; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Astral; -using CalamityMod.Tiles.Crags; -using CalamityMod.Tiles.FurnitureAncient; using CalamityMod.Tiles.FurnitureAuric; -using CalamityMod.Tiles.Ores; -using CalamityMod.Walls; using Microsoft.Xna.Framework; using Terraria; -using Terraria.GameContent.Generation; using Terraria.ID; -using Terraria.IO; using Terraria.ModLoader; -using Terraria.Utilities; using Terraria.WorldBuilding; namespace CalamityMod.World @@ -63,6 +52,7 @@ namespace CalamityMod.World return; c.item[itemIndex].SetDefaults(id, false); + c.item[itemIndex].Prefix(-1); // Don't set quantity unless quantity is specified if (minQuantity > 0) @@ -144,6 +134,93 @@ namespace CalamityMod.World } #endregion + #region Tunnel Tools + public static void CreateTunnel(int startX, int startY, int endX, int endY, int width = 6, int tileType = TileID.Dirt) + { + int dx = endX - startX; + int dy = endY - startY; + int steps = Math.Max(Math.Abs(dx), Math.Abs(dy)); + + for (int i = 0; i <= steps; i++) + { + float t = (float)i / steps; + int x = (int)(startX + dx * t); + int y = (int)(startY + dy * t); + + // Draw a small circular path + for (int xi = -width; xi <= width; xi++) + { + for (int yi = -width; yi <= width; yi++) + { + if (xi * xi + yi * yi <= width * width) + { + int tileX = x + xi; + int tileY = y + yi; + + if (WorldGen.InWorld(tileX, tileY)) + { + Tile tTile = Main.tile[tileX, tileY]; + tTile.HasTile = true; + tTile.TileType = (ushort)tileType; + WorldGen.SquareTileFrame(tileX, tileY); + } + } + } + } + } + } + public static void ClearTunnel(int startX, int startY, int endX, int endY, int width = 3, int wallType = WallID.Dirt, int liquidType = LiquidID.Water, bool liquidOn = true, bool wallOn = true) + { + int dx = endX - startX; + int dy = endY - startY; + int steps = Math.Max(Math.Abs(dx), Math.Abs(dy)); + + for (int i = 0; i <= steps; i++) + { + float t = (float)i / steps; + int x = (int)(startX + dx * t); + int y = (int)(startY + dy * t); + + for (int xi = -width; xi <= width; xi++) + { + for (int yi = -width; yi <= width; yi++) + { + if (xi * xi + yi * yi <= width * width) + { + int tileX = x + xi; + int tileY = y + yi; + + if (WorldGen.InWorld(tileX, tileY)) + { + Tile tTile = Main.tile[tileX, tileY]; + tTile.HasTile = false; + if (wallOn) + { + tTile.WallType = (ushort)wallType; + } + + tTile.LiquidAmount = 0; + + WorldGen.SquareWallFrame(tileX, tileY); + + // Optional: Add liquid with low chance + if (liquidOn) + { + if (WorldGen.genRand.NextBool(10)) + { + tTile.LiquidAmount = 100; + tTile.LiquidType = liquidType; + WorldGen.SquareTileFrame(tileX, tileY); + } + } + } + } + } + } + } + } + #endregion + #region Chasm Generator public static void ChasmGenerator(int i, int j, int steps, bool ocean = false) { diff --git a/World/Planets/GrassPlanet.cs b/World/Planets/GrassPlanet.cs index b232dce244..c92173df46 100644 --- a/World/Planets/GrassPlanet.cs +++ b/World/Planets/GrassPlanet.cs @@ -1,12 +1,10 @@ using System; using System.Collections.Generic; using CalamityMod.DataStructures; -using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Generation; using Terraria.ID; -using Terraria.ModLoader; using Terraria.WorldBuilding; namespace CalamityMod.World.Planets diff --git a/World/Planets/MainPlanet.cs b/World/Planets/MainPlanet.cs index a1bb4cbfe9..98b2c073a3 100644 --- a/World/Planets/MainPlanet.cs +++ b/World/Planets/MainPlanet.cs @@ -15,11 +15,7 @@ namespace CalamityMod.World.Planets { public override bool Place(Point origin, StructureMap structures) { - // 1 on Small, 1.52 on Medium, 2 on Large - float scale = (float)Main.maxTilesX / 4200f; - // Clamp scale to prevent problems on extra large worlds - scale = MathHelper.Clamp(scale, 1f, 2f); - int radius = (int)((float)_random.Next(30, 36) * scale); //50 to 65 + int radius = 54; if (!CheckIfPlaceable(origin, radius, structures)) { @@ -89,6 +85,10 @@ namespace CalamityMod.World.Planets mainShape.Subtract(outerCoreShape, origin, origin); + bool hasPlacedLogAndSchematic = false; + SchematicManager.PlaceSchematic(SchematicManager.PlanetoidLabKey, new Point(origin.X, origin.Y), SchematicAnchor.Center, ref hasPlacedLogAndSchematic, new Action(DraedonStructures.FillPlanetoidLaboratoryChest)); + CalamityWorld.PlanetoidLabCenter = origin.ToWorldCoordinates(); + //PLACE GRASS Vector2 worldCenter = origin.ToWorldCoordinates(); WorldUtils.Gen(origin, new ModShapes.OuterOutline(mainShape, true, true), Actions.Chain(new GenAction[] @@ -104,11 +104,6 @@ namespace CalamityMod.World.Planets new Actions.SetFrames(true) })); - // TODO -- This should probably use PlacementAnchor.Center and just provide the center of the planetoid... - bool hasPlacedLogAndSchematic = false; - SchematicManager.PlaceSchematic(SchematicManager.PlanetoidLabKey, new Point(origin.X - 33, origin.Y - 17), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(DraedonStructures.FillPlanetoidLaboratoryChest)); - CalamityWorld.PlanetoidLabCenter = origin.ToWorldCoordinates(); - //PLACE BREAKABLE GRASS AND TREES WorldUtils.Gen(origin, new ModShapes.OuterOutline(mainShape, true, true), Actions.Chain(new GenAction[] { diff --git a/World/Planets/MudPlanet.cs b/World/Planets/MudPlanet.cs index 97113e4681..af74166097 100644 --- a/World/Planets/MudPlanet.cs +++ b/World/Planets/MudPlanet.cs @@ -1,10 +1,7 @@ - -using CalamityMod.Items.Potions; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Generation; using Terraria.ID; -using Terraria.ModLoader; using Terraria.WorldBuilding; namespace CalamityMod.World.Planets @@ -212,8 +209,8 @@ namespace CalamityMod.World.Planets private int[] BarLoot = new int[] { - GenVars.copperBar == TileID.Copper ? ItemID.CopperBar : ItemID.TinBar, - GenVars.ironBar == TileID.Iron ? ItemID.IronBar : ItemID.LeadBar + GenVars.copper == TileID.Copper ? ItemID.CopperBar : ItemID.TinBar, + GenVars.iron == TileID.Iron ? ItemID.IronBar : ItemID.LeadBar }; private void FillChest(int id) @@ -222,13 +219,14 @@ namespace CalamityMod.World.Planets int index = 0; //Focus loot - chest.item[index++].SetDefaults(_random.Next(FocusLoot)); + chest.item[index].SetDefaults(_random.Next(FocusLoot)); + chest.item[index++].Prefix(-1); //Bars if (_random.Next(3) <= 1) { chest.item[index].SetDefaults(_random.Next(BarLoot)); - chest.item[index].SetDefaults(_random.Next(7, 15)); + chest.item[index++].stack = _random.Next(7, 15); } else { diff --git a/World/Planets/Planetoid.cs b/World/Planets/Planetoid.cs index 22ac59402b..5b0a645379 100644 --- a/World/Planets/Planetoid.cs +++ b/World/Planets/Planetoid.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.IO; -using Terraria.ModLoader; using Terraria.WorldBuilding; namespace CalamityMod.World.Planets @@ -14,7 +13,7 @@ namespace CalamityMod.World.Planets public static void GenerateAllBasePlanetoids(GenerationProgress progress, GameConfiguration config) { - progress.Message = "Enriching low Terraria orbit"; + progress.Message = CalamityUtils.GetTextValue("UI.Planetoids"); var config2 = WorldGenConfiguration.FromEmbeddedPath("Terraria.GameContent.WorldBuilding.Configuration.json"); int GrassPlanetoidCount = Main.maxTilesX / 750; diff --git a/World/ShimmerShrine.cs b/World/ShimmerShrine.cs new file mode 100644 index 0000000000..7beb14fd6c --- /dev/null +++ b/World/ShimmerShrine.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Schematics; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.WorldBuilding; +using static CalamityMod.Schematics.SchematicManager; + +namespace CalamityMod.World +{ + public class ShimmerShrine + { + public static void PlaceShimmerShrine(StructureMap structures) + { + string mapKey = ShimmerShrineKey; + var schematic = TileMaps[mapKey]; + + int placementPositionX = (int)GenVars.shimmerPosition.X; + int placementPositionY = (int)Main.worldSurface - 300; + int offset = 28; + + while (!Main.tile[placementPositionX, placementPositionY].HasTile) + placementPositionY++; + + Point placementPoint = new Point(placementPositionX, placementPositionY + offset); + SchematicAnchor anchorType = SchematicAnchor.Center; + + bool place = true; + PlaceSchematic(mapKey, placementPoint, anchorType, ref place, new Action(FillShimmerShrineChest)); + + Rectangle protectionArea = CalamityUtils.GetSchematicProtectionArea(schematic, placementPoint, anchorType); + CalamityUtils.AddProtectedStructure(protectionArea, 30); + } + + public static void FillShimmerShrineChest(Chest chest, int Type, bool place) + { + List contents = new List() + { + new ChestItem(ItemID.AngelStatue, 1), + new ChestItem(WorldGen.genRand.NextBool() ? ItemID.LifeCrystal : ItemID.ManaCrystal, 1), + new ChestItem(GenVars.gold == TileID.Gold ? ItemID.GoldBar : ItemID.PlatinumBar, WorldGen.genRand.Next(5, 16)), + new ChestItem(ItemID.CanOfWorms, WorldGen.genRand.Next(3, 5)), + new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(5, 11)), + new ChestItem(ItemID.LuckPotionGreater, WorldGen.genRand.Next(1, 3)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(2, 5)), + }; + + for (int i = 0; i < contents.Count; i++) + { + chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].stack = contents[i].Stack; + } + } + } +} diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index c396017248..680f61ffd0 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -1,15 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; -using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Items.Tools.SpawnBlocker; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Schematics; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Abyss.AbyssAmbient; using CalamityMod.Tiles.Abyss.Stalactite; using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.RGB; @@ -244,7 +245,7 @@ namespace CalamityMod.World int width = BiomeWidth + 1; int maxDepth = BlockDepth; ushort blockTileType = (ushort)ModContent.TileType(); - ushort wallID = (ushort)ModContent.WallType(); + ushort wallID = (ushort)ModContent.WallType(); for (int i = 1; i < width; i++) { @@ -301,7 +302,7 @@ namespace CalamityMod.World OtherTilesForSulphSeaToDestroy.Contains(type)) CalamityUtils.ParanoidTileRetrieval(x, y).Get().HasTile = false; if (WallsForSulphSeaToDestroy.Contains(CalamityUtils.ParanoidTileRetrieval(x, y).WallType)) - CalamityUtils.ParanoidTileRetrieval(x, y).WallType = 0; + CalamityUtils.ParanoidTileRetrieval(x, y).WallType = WallID.None; } } } @@ -326,7 +327,7 @@ namespace CalamityMod.World for (int y = top; y < bottom; y++) { if (y >= top + DepthForWater) - Main.tile[x, y + WorldGen.genRand.Next(22, 25)].WallType = (ushort)ModContent.WallType(); + Main.tile[x, y + WorldGen.genRand.Next(22, 25)].WallType = (ushort)ModContent.WallType(); Main.tile[x, y].LiquidAmount = byte.MaxValue; Main.tile[x, y].Get().HasTile = false; } @@ -343,7 +344,7 @@ namespace CalamityMod.World int right = (int)(BiomeWidth * IslandWidthPercentage); int maxDepth = MaxTopWaterDepth; ushort blockTileType = (ushort)ModContent.TileType(); - ushort wallID = (ushort)ModContent.WallType(); + ushort wallID = (ushort)ModContent.WallType(); for (int i = left; i < right; i++) { @@ -384,7 +385,7 @@ namespace CalamityMod.World if (maxCaveWidth > 15) maxCaveWidth = 15; - ushort wallID = (ushort)ModContent.WallType(); + ushort wallID = (ushort)ModContent.WallType(); for (int i = 2; i < shallowWaterCaveCount; i++) { @@ -441,7 +442,7 @@ namespace CalamityMod.World { int width = BiomeWidth; int depth = (int)(BlockDepth * 0.96f); - ushort wallID = (ushort)ModContent.WallType(); + ushort wallID = (ushort)ModContent.WallType(); for (int c = 0; c < SpaghettiCaveCarveOutThresholds.Length; c++) { @@ -485,7 +486,7 @@ namespace CalamityMod.World { int width = BiomeWidth; int depth = (int)(BlockDepth * 0.96f); - ushort wallID = (ushort)ModContent.WallType(); + ushort wallID = (ushort)ModContent.WallType(); for (int c = 0; c < CheeseCaveCarveOutThresholds.Length; c++) { @@ -818,7 +819,7 @@ namespace CalamityMod.World int beachWidth = WorldGen.genRand.Next(150, 190 + 1); var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); ushort sandID = (ushort)ModContent.TileType(); - ushort wallID = (ushort)ModContent.WallType(); + ushort wallID = (ushort)ModContent.WallType(); // Stop immediately if for some strange reason a valid tile could not be located for the beach starting point. if (!WorldUtils.Find(new Point(BiomeWidth + 4, Main.remixWorld ? YStart : (int)GenVars.worldSurfaceLow - 20), searchCondition, out Point determinedPoint)) @@ -958,7 +959,7 @@ namespace CalamityMod.World // Create a log message if for some reason the schematic in question doesn't exist. if (!wrappedSchematicArea.HasValue) { - CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{schematicName}\". No matching schematic file found."); + CalamityMod.Log.Warn($"Tried to place a schematic with name \"{schematicName}\". No matching schematic file found."); continue; } @@ -1052,7 +1053,7 @@ namespace CalamityMod.World { int sandstoneSeed = WorldGen.genRand.Next(); ushort sandstoneID = (ushort)ModContent.TileType(); - ushort sandstoneWallID = (ushort)ModContent.WallType(); + ushort sandstoneWallID = (ushort)ModContent.WallType(); // Edge score evaluation function that determines the propensity a tile has to become sandstone. // This is based on how much nearby empty areas there are, allowing for "edges" to appear. @@ -1256,7 +1257,7 @@ namespace CalamityMod.World for (int dy = 0; dy < 2; dy++) { Main.tile[chestPoint.X + dx, chestPoint.Y - dy].LiquidAmount = 0; - Main.tile[chestPoint.X + dx, chestPoint.Y - dy].WallType = (ushort)ModContent.WallType(); + Main.tile[chestPoint.X + dx, chestPoint.Y - dy].WallType = (ushort)ModContent.WallType(); Main.tile[chestPoint.X + dx, chestPoint.Y - dy].Get().HasTile = false; } } @@ -1402,7 +1403,7 @@ namespace CalamityMod.World Chest chest = MiscWorldgenRoutines.AddChestWithLoot(x, y, (ushort)ModContent.TileType()); if (chest != null) { - chest.item[0].SetDefaults(ModContent.ItemType()); + chest.item[0].SetDefaults(ModContent.ItemType()); chest.item[0].Prefix(-1); break; } @@ -1578,7 +1579,7 @@ namespace CalamityMod.World int depth = BlockDepth; ushort columnID = (ushort)ModContent.TileType(); ushort hardenedSandstoneWallID = (ushort)ModContent.WallType(); - ushort sandWallID = (ushort)ModContent.WallType(); + ushort sandWallID = (ushort)ModContent.WallType(); short variantFrameOffset = (short)(WorldGen.genRand.Next(3) * 36); for (int x = left; x < left + 2; x++) diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index b8a0091c89..5359115d0b 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -1,12 +1,11 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; -using System.Threading.Tasks; using CalamityMod.Tiles.SunkenSea; using CalamityMod.Tiles.SunkenSea.Ambient; +using CalamityMod.Utilities; using CalamityMod.Walls; +using CalamityMod.Walls.UnsafeWalls; using Microsoft.Xna.Framework; -using ReLogic.Threading; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,155 +15,148 @@ namespace CalamityMod.World { public class SunkenSea { - /* - Dylandoe checklist: - -Make ambient tiles naturally grow on sunken sea tiles/sands (only eutrophic sand is done) - -Add basalt slab block - -Add navystone brick wall - -Add the wall corals properly - -Make sunken sea walls produce water - */ - - /* - ena todo - - fix the fucking forest being shaved - cut a half oval out of the top of forest in anticipation of structure placement - change the type of noise both reefs and forest use (reefs more jagged, forest more flat) - cut a curve out of the top of shores (the desert part) - extend basalt to hell - DONE - convert normal terrain blocks below basalt into basalt - BLOTCHES EVERYWHERE - */ - - public static void NormalForLoop(int fromInclusive, int toExclusive, int step, Action action) + internal static class SSOffsets { - for (int i = fromInclusive; i < toExclusive; i += step) - action.Invoke(i); + public static int TimelessShoresX = 0, TimelessShoresY = 0; + public static int RadiantReefsX = 0, RadiantReefsY = 55; + public static int PolypForestX = 0, PolypForestY = 30; + public static int GleamingBurrowsX = 0, GleamingBurrowsY = 75; + public static int ClamDenX = 0, ClamDenY = 75; + public static int BasaltGullyX = 0, BasaltGullyY = 15; + public static int GlobalX = 0, GlobalY = -20; + } + static bool IsAirOrDecor(int x, int y) + { + if (y <= 0 || y >= Main.maxTilesY - 1 || x <= 0 || x >= Main.maxTilesX - 1) + return true; // out-of-bounds above counts as clear + + Tile t = Main.tile[x, y]; + if (!t.HasTile) + return true; + + int type = t.TileType; + + // blockers (full blocks / slopes / platforms) + if (WorldGen.SolidOrSlopedTile(x, y)) return false; // solid/half/sloped + if (Main.tileSolidTop[type]) return false; // platforms & similar + + // ambient stuff + if (Main.tileFrameImportant[type] && !Main.tileSolid[type]) return true; // pots, cactus, decor + if (Main.tileCut[type]) return true; // grass/vines/etc. + if (TileID.Sets.BreakableWhenPlacing[type]) return true; // tiny plants, etc. + + return false; } - public static void ReLogicParallelFor(int fromInclusive, int toExclusive, int step, Action action) + static bool ColumnClearOrDecor(int x, int groundY, int tilesUp) { - FastParallel.For(fromInclusive, toExclusive, (start, end, _) => + for (int k = 1; k <= tilesUp; k++) + { + if (!IsAirOrDecor(x, groundY - k)) + return false; + } + return true; + } + /* + checklist: + -Make sunken sea walls produce water + cut a half oval out of the top of forest in anticipation of structure placement + */ + + public static void ParallelFor(int fromInclusive, int toExclusive, int step, Action action) + { + FasterParallel.For(fromInclusive, toExclusive, (start, end, _) => { for (int i = start; i < end; i += step) action.Invoke(i); }); } - public static void CSharpParallelFor(int fromInclusive, int toExclusive, int step, Action action) - { - var partitioner = Partitioner.Create(fromInclusive, toExclusive, step); - Parallel.ForEach(partitioner, (range, _) => - { - for (int i = range.Item1; i < range.Item2; i += step) - action.Invoke(i); - }); - } - - /// - /// The delegate that describes the method of a type of for loop. - /// - public delegate void ForLoopMethod(int fromInclusive, int toExclusive, int step, Action action); - - /// - /// The current type of for loop used to generate the Sunken Sea. - /// - public static ForLoopMethod ForLoop; - public static void PlaceTimelessShores(int startPosX, int startPosY) { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.TimelessShoresX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.TimelessShoresY; + int biomeSize = 250 + (Main.maxTilesX / 180); - // - // Places a trapezoid of circles to serve as the main area for the biome. - // - const float steepness = 15f; - static float trapezoidLateralSteep(float x) - { - if (x <= 1f / steepness) - return steepness * x; - else if (x > 1f / steepness && x < 1f - 1f / steepness) - return 1f; - else - return -steepness * x + steepness; - } - ForLoop.Invoke(startPosX - biomeSize - 20, startPosX + biomeSize + 20, 15, (X) => - { - float height = MathHelper.Lerp( - startPosY + 50, - startPosY - 35, - trapezoidLateralSteep(Utils.GetLerpValue(startPosX - biomeSize - 20, startPosX + biomeSize + 20, X))); + int XLeft = GenVars.UndergroundDesertLocation.Left; - for (int Y = startPosY + 50; Y >= height; Y -= 10) + int XRight = GenVars.UndergroundDesertLocation.Right; + + const int totalCuveDepth = 90; + // this converts basalt to runestone directy in line to the desert to make the shape look perfect to blend well with the rest of the desert + ParallelFor(XLeft, XRight, 20, (x) => + { + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 30, startX + biomeSize - 200, x, true))); + int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 30, startX - biomeSize + 200, x, true))); + + for (int y = startY + 100; y >= startY - 175; y -= 15) { - ShapeData circle = new ShapeData(); - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(30), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Rectangle(20, 20), Actions.Chain(new GenAction[] { - //new Modifiers.RadialDither(1, 30).Output(circle), - new Modifiers.Blotches().Output(circle), + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), + new Actions.SetTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()) })); - WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), new Actions.SetTile((ushort)ModContent.TileType())); + } }); - // // Makes the bottom borders of the Timeless Shores curved downwards. // - const int totalCuveDepth = 40; - ForLoop.Invoke(startPosX - biomeSize - 20, startPosX - biomeSize + 200, 10, (x) => + ParallelFor(startX - biomeSize, startX - biomeSize + 200, 10, (x) => { - int curveDepth = (int)MathHelper.Lerp( - totalCuveDepth, - 0f, - MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize - 17, startPosX - biomeSize + 200, x, true))); - - for (int y = startPosY + 50; y <= startPosY + 50 + curveDepth; y += 5) + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 17, startX - biomeSize + 200, x, true))); + for (int y = startY + 50; y <= startY + 70 + curveDepth; y += 5) { ShapeData circle = new(); - WorldUtils.Gen(new Point(x, y), new Shapes.Circle(30), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(x, y), new Shapes.Slime(20), Actions.Chain(new GenAction[] { - //new Modifiers.RadialDither(1, 30).Output(circle), - new Modifiers.Blotches().Output(circle), + // new Modifiers.RadialDither(1, 30).Output(circle), + new Modifiers.Blotches().Output(circle) })); WorldUtils.Gen(new Point(x, y), new ModShapes.All(circle), new Actions.SetTile((ushort)ModContent.TileType())); + WorldUtils.Gen(new Point(x, y), new ModShapes.All(circle), new Actions.PlaceWall((ushort)ModContent.WallType())); } }); - ForLoop.Invoke(startPosX + biomeSize - 200, startPosX + biomeSize + 20, 5, (x) => + ParallelFor(startX + biomeSize - 200, startX + biomeSize, 5, (x) => { - int curveDepth = (int)MathHelper.Lerp( - totalCuveDepth, - 0f, - MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize + 20, startPosX + biomeSize - 200, x, true))); - - for (int y = startPosY + 50; y <= startPosY + 50 + curveDepth; y += 5) + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 20, startX + biomeSize - 200, x, true))); + for (int y = startY + 50; y <= startY + 70 + curveDepth; y += 5) { ShapeData circle = new(); - WorldUtils.Gen(new Point(x, y), new Shapes.Circle(30), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(x, y), new Shapes.Slime(20), Actions.Chain(new GenAction[] { - //new Modifiers.RadialDither(1, 30).Output(circle), - new Modifiers.Blotches().Output(circle), + // new Modifiers.RadialDither(1, 30).Output(circle), + new Modifiers.Blotches().Output(circle) })); WorldUtils.Gen(new Point(x, y), new ModShapes.All(circle), new Actions.SetTile((ushort)ModContent.TileType())); + WorldUtils.Gen(new Point(x, y), new ModShapes.All(circle), new Actions.PlaceWall((ushort)ModContent.WallType())); } }); - //clear a smaller square out of the center where the biomes stuff will be - ForLoop.Invoke(startPosX - biomeSize + 35, startPosX + biomeSize - 35, 1, (X) => + // Clears out a curved cavity inside the timeless shores, this creates the main large open space inside the biome + ParallelFor(startX - biomeSize + 10, startX + biomeSize - 10, 1, (X) => { - for (int Y = startPosY - 65; Y <= startPosY + 50; Y++) + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 20, startX + biomeSize - 200, X, true))); + int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 17, startX - biomeSize + 200, X, true))); + + int random = WorldGen.genRand.Next(-40, 10); + for (int Y = startY - 25 + curveDepth + curveDepth2; Y <= startY + 50; Y++) { ShapeData circle = new ShapeData(); GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(2, 5)), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(X, Y + random), new Shapes.Mound(WorldGen.genRand.Next(7, 10), 5), Actions.Chain(new GenAction[] { - blotchMod.Output(circle) + blotchMod.Output(circle) })); - WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(X, Y + random), new ModShapes.All(circle), Actions.Chain(new GenAction[] { - new Actions.Clear() + new Actions.Clear() })); } }); @@ -172,162 +164,195 @@ namespace CalamityMod.World // // Places slopes at the sides of the shores to actually make shores. // - ForLoop.Invoke(startPosX - biomeSize + 20, startPosX - biomeSize + 200, 20, (moundX) => + ParallelFor(startX - biomeSize - 85, startX - biomeSize + 200, 20, (moundX) => { + int RandomX = Main.rand.Next(15, 20); ShapeData mound = new(); GenAction blotchMod = new Modifiers.Blotches().Output(mound); - int moundY = startPosY + 60; - int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startPosX - biomeSize + 27, startPosX - biomeSize + 200, moundX))); + int moundY = startY + 75; + int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize, startX - biomeSize + 200, moundX))); WorldUtils.Gen(new Point(moundX, moundY), new Shapes.Mound(30, moundHeight), blotchMod); WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.SetTile((ushort)ModContent.TileType())); + WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.PlaceWall((ushort)ModContent.WallType())); }); - ForLoop.Invoke(startPosX + biomeSize - 200, startPosX + biomeSize - 20, 20, (moundX) => + ParallelFor(startX + biomeSize - 200, startX + biomeSize + 85, 20, (moundX) => { ShapeData mound = new(); GenAction blotchMod = new Modifiers.Blotches().Output(mound); - int moundY = startPosY + 60; - int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startPosX + biomeSize - 27, startPosX + biomeSize - 200, moundX))); + int moundY = startY + 75; + int moundHeight = (int)MathHelper.Lerp(60f, 5f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize, startX + biomeSize - 200, moundX))); WorldUtils.Gen(new Point(moundX, moundY), new Shapes.Mound(30, moundHeight), blotchMod); WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.SetTile((ushort)ModContent.TileType())); + WorldUtils.Gen(new Point(moundX, moundY), new ModShapes.All(mound), new Actions.PlaceWall((ushort)ModContent.WallType())); }); + // // Makes a large platform in the middle of the Timeless Shores. // const int platformSize = 130; const int platformHeight = 35; // Remember that because of Terraria's coordinate system, making it lower actually makes it higher. const int platformDepth = 35; // How deep it goes. Like above, the higher it is, the lower it goes. - ForLoop.Invoke(startPosX - platformSize / 2, startPosX + platformSize / 2, 5, (platformX) => + ParallelFor(startX - platformSize / 2, startX + platformSize / 2, 5, (platformX) => { // This makes the "stem" of the platform be thinner towards the base and then expand on the top. - int thickness = (int)(MathF.Pow(CalamityUtils.Convert01To010(Utils.GetLerpValue(startPosX - platformSize / 2, startPosX + platformSize / 2, platformX)), 3f) * platformDepth) + platformHeight; - - for (int platformY = startPosY + platformHeight; platformY <= startPosY + thickness; platformY++) + int thickness = (int)(MathF.Pow(CalamityUtils.Convert01To010(Utils.GetLerpValue(startX - platformSize / 2, startX + platformSize / 2, platformX)), 3f) * platformDepth) + platformHeight; + for (int platformY = startY + platformHeight; platformY <= startY + thickness; platformY++) { WorldUtils.Gen(new Point(platformX, platformY), new Shapes.Circle(5), Actions.Chain(new GenAction[] { - new Actions.Clear(), // Clears all tiles and walls. - new Actions.PlaceTile((ushort)ModContent.TileType()) // Places tiles. + // Clear all tiles and place tiles. + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()) })); } }); - ForLoop.Invoke(startPosX - platformSize / 2, startPosX + platformSize / 2, 1, (x) => + // + // Makes the platform have a curve on top + // + ParallelFor(startX - platformSize / 2, startX + platformSize / 2, 1, (x) => { - float interpolator = CalamityUtils.Convert01To010(Utils.GetLerpValue(startPosX - platformSize / 2, startPosX + platformSize / 2, x, true)); + float interpolator = CalamityUtils.Convert01To010(Utils.GetLerpValue(startX - platformSize / 2, startX + platformSize / 2, x, true)); int elevation = (int)MathHelper.Lerp(4f, 1f, interpolator); - WorldUtils.Gen(new Point(x, startPosY + platformHeight - 7), new Shapes.Circle(elevation), Actions.Chain(new GenAction[] { new Actions.Clear(), })); + WorldUtils.Gen(new Point(x, startY + platformHeight - 7), new Shapes.Circle(elevation), Actions.Chain(new GenAction[] { new Actions.Clear(), })); }); - // - // Makes a hole into the actual Sunken Sea at the botoom-left and bottom-right of the middle platform of the Timeless Shores. - // - const int furthestDistanceFromCenter = 55; - const int shortestDistanceFromCenter = 35; - const int holeStart = 50; - const int holeDepth = 35; - ForLoop.Invoke(startPosX - furthestDistanceFromCenter, startPosX - shortestDistanceFromCenter, 1, (holeX) => + // Plateau + ParallelFor(startX - biomeSize, startX + biomeSize, 100, (wallPlateauX) => { - for (int holeY = startPosY + holeStart; holeY <= startPosY + holeStart + holeDepth; holeY += 3) + int randomDisplacement = WorldGen.genRand.Next(-46, -27); + int RandomX = Main.rand.Next(7, 15); + int RandomH = Main.rand.Next(15, 25); + + for (int wallPlateauY = startY + RandomH; wallPlateauY <= startY + 60; wallPlateauY += 10) { - ShapeData circle = new(); + // Along the height of the pillar, it becomes shorter the more closer to the center we get. + int PlateauWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startY - RandomH, startY + 45, wallPlateauY)) * 25); - // As the hole gets deeper, we want the holes to be bigger and more blurry, so it's not so monotonous. - int sizeIncrement = (int)Utils.Remap(holeY, startPosY + holeStart, startPosY + holeStart + holeDepth, 1, 20); - - // may or may not be useful later - //GenAction dither = new Modifiers.RadialDither(2 * sizeIncrement, 5 * sizeIncrement); - - WorldUtils.Gen(new Point(holeX, holeY), new Shapes.Circle(sizeIncrement), Actions.Chain(new GenAction[] + ShapeData Circle = new ShapeData(); + GenAction blotchFilter = new Modifiers.Blotches(1, 0.4); + if (Main.tile[startX, startY].WallType == (ushort)ModContent.WallType()) { - new Actions.ClearTile(), // The shape removes tiles. - new Actions.SetLiquid() // The shape adds liquid (Default to max water). - })); - } - }); - ForLoop.Invoke(startPosX + shortestDistanceFromCenter, startPosX + furthestDistanceFromCenter, 1, (holeX) => - { - for (int holeY = startPosY + holeStart; holeY <= startPosY + holeStart + holeDepth; holeY += 3) - { - ShapeData circle = new(); + WorldUtils.Gen(new Point(randomDisplacement + wallPlateauX + PlateauWidth / 2, randomDisplacement + wallPlateauY), new Shapes.Circle(RandomH - PlateauWidth + 3, RandomX), Actions.Chain(new GenAction[] + { + blotchFilter.Output(Circle) + })); - // As the hole gets deeper, we want the holes to be bigger and more blurry, so it's not so monotonous. - int sizeIncrement = (int)Utils.Remap(holeY, startPosY + holeStart, startPosY + holeStart + holeDepth, 1, 20); - - WorldUtils.Gen(new Point(holeX, holeY), new Shapes.Circle(sizeIncrement), Actions.Chain(new GenAction[] - { - new Actions.ClearTile(), // The shape removes tiles. - new Actions.SetLiquid() // The shape adds liquid (Default to max water). - })); + WorldUtils.Gen(new Point(randomDisplacement + wallPlateauX + PlateauWidth / 4, randomDisplacement + wallPlateauY), new ModShapes.All(Circle), Actions.Chain(new GenAction[] + { + new Actions.SetTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()) + })) + ; + } } - }); + + } + ); + + //Poop emote for gfb + //ParallelFor(startX - biomeSize, startX + biomeSize, 100, (wallPillarX) => + //{ + // int randomDisplacement = WorldGen.genRand.Next(-46, -27); + // int RandomX = Main.rand.Next(7, 15); + // int RandomH = Main.rand.Next(15, 25); + + // for (int wallPillarY = startY + RandomH; wallPillarY <= startY + 60; wallPillarY += 10) + // { + // // Along the height of the pillar, it becomes shorter the more closer to the center we get. + // int pillarWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startY - RandomH, startY + 45, wallPillarY)) * 25); + + // ShapeData rectangle = new ShapeData(); + // GenAction blotchFilter = new Modifiers.Blotches(1, 0.4); + // GenAction ditherFilter = new Modifiers.Dither(Math.Min(Utils.GetLerpValue(startY + 30, startY + 70, wallPillarY) + 0.25, 1)); + // if (Main.tile[startX, startY].WallType == (ushort)ModContent.WallType()) + // { + // WorldUtils.Gen(new Point(randomDisplacement + wallPillarX + pillarWidth / 2, randomDisplacement + wallPillarY), new Shapes.Circle(RandomH - pillarWidth + 3, RandomX), Actions.Chain(new GenAction[] + // { + // // Applies a blotch filter to the rectangle. + // blotchFilter.Output(rectangle) + // })); + + // WorldUtils.Gen(new Point(randomDisplacement + wallPillarX + pillarWidth / 4, randomDisplacement + wallPillarY), new ModShapes.All(rectangle), Actions.Chain(new GenAction[] + // { + // new Actions.SetTile((ushort)ModContent.TileType()) + // })) + // ; + // } + // } + + //} + //); //place water below the clear barrier for the islands so that theres water inbetween them - ForLoop.Invoke(startPosX - biomeSize + 35, startPosX + biomeSize - 35, 1, (WaterX) => + ParallelFor(startX - biomeSize + 35, startX + biomeSize - 35, 1, (WaterX) => { - for (int WaterY = startPosY + 37; WaterY <= startPosY + 60; WaterY++) + for (int WaterY = startY + 37; WaterY <= startY + 60; WaterY++) { Main.tile[WaterX, WaterY].Get().LiquidType = LiquidID.Water; Main.tile[WaterX, WaterY].LiquidAmount = byte.MaxValue; } }); - //slope tiles - ForLoop.Invoke(startPosX - biomeSize, startPosX + biomeSize, 1, (X) => - { - for (int Y = startPosY - 50; Y <= startPosY + 50; Y++) - { - Tile.SmoothSlope(X, Y); - } - }); - - //place layer of sand on valid runestone blocks - ForLoop.Invoke(startPosX - biomeSize, startPosX + biomeSize, 1, (X) => - { - for (int Y = startPosY - 50; Y <= startPosY + 50; Y++) - { - bool canPlaceSand = false; - - if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && - !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) - { - canPlaceSand = true; - } - - if (canPlaceSand) - { - PlaceSand(X, Y, 5, ModContent.TileType()); - } - } - }); - // // Generates pillars made out of walls at random points in the Timeless Shores. // - ForLoop.Invoke(startPosX - biomeSize, startPosX + biomeSize, 100, (wallPillarX) => + const int furthestDistanceFromCenter = 100; + ParallelFor(startX - (biomeSize / 2) - furthestDistanceFromCenter, startX + (biomeSize / 2) + furthestDistanceFromCenter, 100, (wallPillarX) => { - int randomDisplacementX = WorldGen.genRand.Next(-10, 30); + int randomDisplacementX = WorldGen.genRand.Next(-25, 25); + int RandomX = Main.rand.Next(3, 6); - for (int wallPillarY = startPosY - 75; wallPillarY <= startPosY + 70; wallPillarY += 10) + for (int wallPillarY = startY - 75; wallPillarY <= startY + 80; wallPillarY += 10) { // Along the height of the pillar, it becomes shorter the more closer to the center we get. - int pillarWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startPosY - 75, startPosY + 50, wallPillarY)) * 25); + int pillarWidth = (int)(CalamityUtils.Convert01To010(Utils.GetLerpValue(startY - 75, startY + 50, wallPillarY)) * 25); ShapeData rectangle = new ShapeData(); GenAction blotchFilter = new Modifiers.Blotches(2, 0.4); - GenAction ditherFilter = new Modifiers.Dither(Math.Min(Utils.GetLerpValue(startPosY + 40, startPosY + 70, wallPillarY) + 0.25, 1)); + GenAction ditherFilter = new Modifiers.Dither(Math.Min(Utils.GetLerpValue(startY + 40, startY + 70, wallPillarY) + 0.25, 1)); - WorldUtils.Gen(new Point(randomDisplacementX + wallPillarX + pillarWidth / 2, wallPillarY), new Shapes.Rectangle(25 - pillarWidth + 3, 12), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(randomDisplacementX + wallPillarX + pillarWidth / 2, wallPillarY), new Shapes.Rectangle(25 - pillarWidth + 3, 15), Actions.Chain(new GenAction[] { - ditherFilter.Output(rectangle), // Applies a dithering filter to the rectangle. - blotchFilter.Output(rectangle), // Applies a blotch filter to the rectangle. + ditherFilter.Output(rectangle), // Applies a dithering filter to the rectangle. + blotchFilter.Output(rectangle), // Applies a blotch filter to the rectangle. })); WorldUtils.Gen(new Point(randomDisplacementX + wallPillarX + pillarWidth / 2, wallPillarY), new ModShapes.All(rectangle), Actions.Chain(new GenAction[] { - new Actions.PlaceWall((ushort)ModContent.WallType()) // The shape places walls. - })); + new Actions.PlaceWall((ushort)ModContent.WallType()) // The shape places walls. + })) + ; + } + }); + + // places wall flowers in the curved cavity inside the timeless shores. This is done here to prevent them from appearing in the transiton area + ParallelFor(startX - biomeSize + 10, startX + biomeSize - 10, 1, (X) => + { + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 20, startX + biomeSize - 200, X, true))); + int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 17, startX - biomeSize + 200, X, true))); + + for (int Y = startY - 60 + curveDepth + curveDepth2; Y <= startY + 30; Y++) + { + int Rand3() => WorldGen.genRand.Next(3); + int ShoresFlowerVariants = Rand3(); + + if (Main.tile[X, Y].WallType == ModContent.WallType() && WorldGen.EmptyTileCheck(X - 1, Y - 1, 3, 3)) + { + if (WorldGen.genRand.NextBool(60)) + { + WorldGen.PlaceObject(X - 1, Y - 1, ModContent.TileType(), mute: true, style: ShoresFlowerVariants); + } + } + + if (Main.tile[X, Y].WallType == ModContent.WallType() && WorldGen.EmptyTileCheck(X - 1, Y - 1, 2, 2)) + { + if (WorldGen.genRand.NextBool(60)) + WorldGen.PlaceObject(X - 1, Y - 1, ModContent.TileType(), mute: true, style: ShoresFlowerVariants); + } } }); @@ -335,47 +360,83 @@ namespace CalamityMod.World // Makes the transition area to the Timeless Shores. // Replaces tiles, walls, and places some water spots. // - ForLoop.Invoke(startPosX - biomeSize - 25, startPosX + biomeSize + 25, 20, (x) => - { - for (int y = startPosY - 70; y >= startPosY - 200; y -= 15) + ParallelFor(startX - biomeSize - 15, startX + biomeSize + 30, 20, (x) => { - float interpolator = Utils.GetLerpValue(startPosY - 90, startPosY - 150, y, true); - float ditherStrength = MathHelper.Lerp(0f, 0.95f, interpolator); + int curveDepth = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 30, startX + biomeSize - 200, x, true))); + int curveDepth2 = (int)MathHelper.Lerp(totalCuveDepth, 0f, MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 30, startX - biomeSize + 200, x, true))); - WorldUtils.Gen(new Point(x, y), new Shapes.Circle(15), Actions.Chain(new GenAction[] + for (int y = startY - 5; y >= startY - 149; y -= 15) + { + float interpolator = Utils.GetLerpValue(startY - 90, startY - 150, y, true); + + //WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] + //{ + // new Modifiers.OnlyTiles(TileID.Sand), + // new Actions.ClearTile(), + // new Actions.PlaceTile((ushort)ModContent.TileType()), + // new Actions.PlaceWall((ushort)ModContent.WallType()) + //})); + + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] { - new Modifiers.OnlyTiles(TileID.Sand, TileID.HardenedSand), - new Modifiers.Dither(ditherStrength + 0.2f), + new Modifiers.OnlyTiles(TileID.HardenedSand, TileID.Sand,TileID.Copper,TileID.Tin, TileID.Iron, TileID.Lead), new Actions.ClearTile(), - new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()) })); - // changing these makes the walls dither higher up than tiles, to prevent the biome from changing earlier than expected. still looks nice imo :) - interpolator = Utils.GetLerpValue(startPosY - 90, startPosY - 200, y, true); - ditherStrength = MathHelper.Lerp(0f, 0.95f, interpolator); - WorldUtils.Gen(new Point(x, y), new Shapes.Circle(15), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles(TileID.DesertFossil,TileID.Tungsten,TileID.Silver,TileID.Gold,TileID.Platinum,TileID.Demonite,TileID.Crimtane), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()) + })); + + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles(TileID.RollingCactus), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + })); + + interpolator = Utils.GetLerpValue(startY - 90, startY - 200, y, true); + + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] { new Modifiers.OnlyWalls(WallID.Sandstone, WallID.HardenedSand), - new Modifiers.Dither(ditherStrength), new Actions.ClearWall(), - new Actions.PlaceWall((ushort)ModContent.WallType()), + new Actions.PlaceWall((ushort)ModContent.WallType()), })); - // i forgot to change this one. :peepotired: - interpolator = Utils.GetLerpValue(startPosY - 90, startPosY - 150, y, true); - ditherStrength = MathHelper.Lerp(0f, 0.95f, interpolator); - WorldUtils.Gen(new Point(x, y), new Shapes.Circle(15), Actions.Chain(new GenAction[] + interpolator = Utils.GetLerpValue(startY - 90, startY - 150, y, true); + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] { new Modifiers.OnlyTiles(TileID.Sandstone), - new Modifiers.Dither(ditherStrength), new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()) + })); + interpolator = Utils.GetLerpValue(startY - 90, startY - 150, y, true); + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + })); + + interpolator = Utils.GetLerpValue(startY - 90, startY - 150, y, true); + WorldUtils.Gen(new Point(x, y + curveDepth + curveDepth2), new Shapes.Circle(15), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyWalls((ushort)ModContent.WallType()), + new Actions.ClearWall(), + new Actions.PlaceWall((ushort)ModContent.WallType()) })); if (Main.tile[x, y].Get().LiquidType == LiquidID.Lava) WorldUtils.Gen(new Point(x, y), new Shapes.Rectangle(5, 5), new Actions.SetLiquid(LiquidID.Lava, 0)); - if (WorldGen.genRand.NextBool(5) && y < startPosY - 100) + if (WorldGen.genRand.NextBool(5) && y < startY - 100) { WorldUtils.Gen(new Point(x, y), new Shapes.Circle(WorldGen.genRand.Next(5, 7)), Actions.Chain(new GenAction[] { @@ -384,222 +445,216 @@ namespace CalamityMod.World })); } } + + // Place layer of sand on valid runestone blocks. + for (int X = startX - biomeSize; X < startX + biomeSize; X += 1) + { + for (int Y = startY - 100; Y <= startY + 100; Y++) + { + bool canPlaceSand = Main.tile[X, Y].TileType == ModContent.TileType() && ColumnClearOrDecor(X, Y, 5); + + if (canPlaceSand) + { + if (Main.tile[X, Y - 1].WallType == WallID.None) + { + WorldGen.KillWall(X, Y); + } + PlaceSand(X, Y, 5, ModContent.TileType()); + } + + // Clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + WorldGen.KillTile(X, Y); + + // Kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + WorldGen.KillTile(X, Y); + + } + } + + // Slope tiles + for (int X = startX - biomeSize; X < startX + biomeSize; X += 1) + { + for (int Y = startY - 300; Y <= startY + 200; Y++) + { + Tile.SmoothSlope(X, Y); + } + } }); } - //sides of the sunken sea (radiant reefs) - //LeftSideBarrier is used to make the barrier of basalt either on the left or right, since the sunken sea is meant to have barriers on both sides and the reefs is generated twice - public static void PlaceRadiantReefs(int startPosX, int startPosY, bool LeftSideBarrier) + // Sides of the sunken sea (radiant reefs) + public static void PlaceRadiantReefs(int startPosX, int startPosY) { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.RadiantReefsX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.RadiantReefsY; + int cavePerlinSeed = WorldGen.genRand.Next(); int cavePerlinSeedWalls = WorldGen.genRand.Next(); - Point origin = new Point(startPosX, startPosY); + Point origin = new Point(startX, startY); Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); float angle = MathHelper.Pi * 0.15f; float otherAngle = MathHelper.PiOver2 - angle; - int biomeSize = 180 + (Main.maxTilesX / 180); + int biomeSize = 280 + (Main.maxTilesX / 180); float actualSize = biomeSize * 16f; float constant = actualSize * 2f / (float)Math.Sin(angle); float fociSpacing = actualSize * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); - int verticalRadius = (int)(constant / 16f); + int verticalRadius = (int)(constant / 50f); Vector2 fociOffset = Vector2.UnitY * fociSpacing; Vector2 topFoci = center - fociOffset; Vector2 bottomFoci = center + fociOffset; - //first, place a basalt barrier on the left and right of the biome - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => + ushort Shellstone = (ushort)ModContent.TileType(); + ushort ShellstoneWall = (ushort)ModContent.WallType(); + + // Generate the actual caverns + bool runOnce = false; // This is used to make the wall on the left side go boom on the second run + for (int X = origin.X - biomeSize - 170; X <= origin.X + biomeSize + 170; X++) { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { + Tile t = Main.tile[X, Y]; float percent = dist / constant; float blurPercent = 0.99f; - if (percent > blurPercent) { - if (Y > origin.Y - 60) + // Place smaller shellstone clumps infront of the basalt so the basalt isnt actually inside of the biome itself + if (!runOnce) { - if (LeftSideBarrier) - { - if (X <= origin.X && Main.tile[X - 40, Y - 25].TileType != ModContent.TileType()) - { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - - WorldUtils.Gen(new Point(X - 40, Y - 25), new Shapes.Circle(60), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); - WorldUtils.Gen(new Point(X - 40, Y - 25), new ModShapes.All(circle), Actions.Chain(new GenAction[] - { - new Actions.Clear(), - new Actions.PlaceTile((ushort)ModContent.TileType()) - })); - } - } - else - { - if (X >= origin.X && Main.tile[X + 40, Y - 25].TileType != ModContent.TileType()) - { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - - WorldUtils.Gen(new Point(X + 40, Y - 25), new Shapes.Circle(60), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); - WorldUtils.Gen(new Point(X + 40, Y - 25), new ModShapes.All(circle), Actions.Chain(new GenAction[] - { - new Actions.Clear(), - new Actions.PlaceTile((ushort)ModContent.TileType()) - })); - } - } + WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), Shellstone, true, 0f, 0f, true, true); + t.WallType = ShellstoneWall; + runOnce = true; } - } - } - } - }); - //generate the actual caverns - for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) - { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) - { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) - { - float percent = dist / constant; - float blurPercent = 0.99f; - - if (percent > blurPercent) - { - //place smaller shellstone clumps infront of the basalt so the basalt isnt actually inside of the biome itself - WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), true, 0f, 0f, true, true); + // Place smaller shellstone clumps infront of the basalt so the basalt isnt actually inside of the biome itself + if (runOnce) + WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), Shellstone, false, 0f, 0f, true, true); + t.WallType = ShellstoneWall; } else { - //clear absolutely everything before generating the caverns - Main.tile[X, Y].ClearEverything(); + // Clear absolutely everything before generating the caverns + t.ClearEverything(); - //generate perlin noise caves - float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; - float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; - float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + // Generate perlin noise caves + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 90f, Y / 90f, 3, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 150f, Y / 90f, 3, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 150f, Y / 90f, 3, unchecked(cavePerlinSeed - 1)) + 0.5f; float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; - float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.280f; + float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.380f; - //kill or place tiles depending on the noise map + // Kill or place tiles depending on the noise map if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) { WorldGen.KillTile(X, Y); } else { - WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + t.TileType = Shellstone; + t.HasTile = true; } - //place walls in the biome using a different "seed" so it differs from the cave generation - //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through - float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; - float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; - float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + // Place walls in the biome using a different "seed" so it differs from the cave generation + // This creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through + float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 2, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 200f, Y / 160f, 4, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; + float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 200f, Y / 160f, 4, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 3.5f + 0.280f; if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) { - WorldGen.PlaceWall(X, Y, ModContent.WallType()); + t.WallType = ShellstoneWall; } - Main.tile[X, Y].Get().LiquidType = LiquidID.Water; - Main.tile[X, Y].LiquidAmount = byte.MaxValue; + if (caveNoiseMapWalls * caveNoiseMapWalls < (caveCreationThresholdWalls - (caveNoiseMapWalls * 0.2f))) + WorldGen.KillTile(X, Y); + + t.Get().LiquidType = LiquidID.Water; + t.LiquidAmount = byte.MaxValue; } } } } - //cleanup - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => + // Cleanup + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + // Clean tiles that are sticking out (aka tiles only attached to one tile on one side) bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) - { WorldGen.KillTile(X, Y); - } - //kill random single floating tiles + // Kill random single floating tiles if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) - { WorldGen.KillTile(X, Y); - } } } - }); + } - //place layer of sand blocks on valid surfaces - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => + // Place layer of sand blocks on valid surfaces + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - bool canPlaceSand = false; - - //place sand clumps on top of exposed shellstone - if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && - !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) - { - canPlaceSand = true; - } + bool canPlaceSand = + Main.tile[X, Y].TileType == ModContent.TileType() && + !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && + !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && + !Main.tile[X, Y - 5].HasTile; + // Place sand clumps on top of exposed shellstone if (canPlaceSand) - { PlaceSand(X, Y, 5, ModContent.TileType()); - } } } - }); + } - //cleanup again - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => + // Cleanup again + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + // Clean tiles that are sticking out (aka tiles only attached to one tile on one side) bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) - { WorldGen.KillTile(X, Y); - } - //kill random single floating tiles + // Kill random single floating tiles if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) - { WorldGen.KillTile(X, Y); - } - //if any sand is floating, put tiles below it + // If any sand is floating, put tiles below it if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile) { WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); @@ -609,22 +664,29 @@ namespace CalamityMod.World Tile.SmoothSlope(X, Y); } } - }); + } } - //middle of the sunken sea (polyp forest) + // Middle of the sunken sea (polyp forest) public static void PlacePolypForest(int startPosX, int startPosY) { + + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.PolypForestX; + + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.PolypForestY; + + int cavePerlinSeed = WorldGen.genRand.Next(); int cavePerlinSeedWalls = WorldGen.genRand.Next(); - Point origin = new Point(startPosX, startPosY); + Point origin = new Point(startX, startY - 200); Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); float angle = MathHelper.Pi * 0.15f; float otherAngle = MathHelper.PiOver2 - angle; - int biomeSize = 120 + (Main.maxTilesX / 180); + int biomeSize = 150 + (Main.maxTilesX / 180); float actualSize = biomeSize * 16f; float constant = actualSize * 2f / (float)Math.Sin(angle); @@ -635,29 +697,35 @@ namespace CalamityMod.World Vector2 topFoci = center - fociOffset; Vector2 bottomFoci = center + fociOffset; - //place the polyp forest caverns + ushort Limestone = (ushort)ModContent.TileType(); + ushort LimestoneWall = (ushort)ModContent.WallType(); + + // Place the polyp forest caverns for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + for (int Y = (int)(origin.Y + verticalRadius * 0.4f) + 3; Y >= origin.Y - verticalRadius - 3; Y--) { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y > origin.Y)) + Tile t = Main.tile[X, Y]; + // Modify this part so that the generation happens from bottom to top + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y < origin.Y)) { float percent = dist / constant; float blurPercent = 0.98f; - //biome "blending" on the edges (disabled for now) + // Biome "blending" on the edges (disabled for now) if (percent > blurPercent) { + if (Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); + //ShapeData circle = new ShapeData(); + //GenAction blotchMod = new Modifiers.Blotches(4, 0.7); + //WorldUtils.Gen(new Point(X, Y), new Shapes.Slime(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + //{ + // blotchMod.Output(circle) + //})); - WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + WorldUtils.Gen(new Point(X, Y), new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()) })); @@ -670,8 +738,8 @@ namespace CalamityMod.World //generate perlin noise caves float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; - float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; - float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 800f, Y / 450f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 800f, Y / 450f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.235f; @@ -682,23 +750,28 @@ namespace CalamityMod.World } else { - WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + t.TileType = Limestone; + t.HasTile = true; } //place walls in the biome using a different "seed" so it differs from the cave generation //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; - float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; - float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 600f, Y / 350f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; + float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 600f, Y / 350f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; - float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 3.5f + 0.235f; + float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 3.5f + 0.3f; if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) { - //temporarily use navystone - WorldGen.PlaceWall(X, Y, ModContent.WallType()); + t.WallType = LimestoneWall; } + if ((caveNoiseMapWalls + 0.085f) * (caveNoiseMapWalls + 0.085f) > caveCreationThresholdWalls) + { + if (t.WallType == WallID.None) + t.WallType = (ushort)ModContent.WallType(); + } Main.tile[X, Y].Get().LiquidType = LiquidID.Water; Main.tile[X, Y].LiquidAmount = byte.MaxValue; } @@ -707,11 +780,11 @@ namespace CalamityMod.World } //cleanup - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y > origin.Y)) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y < origin.Y)) { //clean tiles that are sticking out (aka tiles only attached to one tile on one side) bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; @@ -731,14 +804,14 @@ namespace CalamityMod.World } } } - }); + } //place extra tiles - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 20; Y <= origin.Y + verticalRadius + 20; Y++) + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y > origin.Y)) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y < origin.Y)) { bool canPlaceSand = false; @@ -751,14 +824,59 @@ namespace CalamityMod.World if (canPlaceSand) { - PlaceSand(X, Y, 5, ModContent.TileType()); + PlaceSand(X, Y, 4, ModContent.TileType()); + } + + } + } + } + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 20; Y <= origin.Y + verticalRadius + 20; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, false, Y < origin.Y)) + { + bool canPlaceGrass = false; + + //place grass on top of exposed sand + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && + !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) + { + canPlaceGrass = true; + } + + if (canPlaceGrass) + { + PlaceSand(X, Y, 0, ModContent.TileType()); + } + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + if (WorldGen.genRand.NextBool(25) && !Main.tile[X - 1, Y].HasTile) + { + ushort[] Soil = new ushort[] { (ushort)ModContent.TileType() }; + + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(3, 7)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), new Actions.PlaceTile(WorldGen.genRand.Next(Soil)) + })); + } } } - }); + } + //cleanup again - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) { for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { @@ -791,16 +909,17 @@ namespace CalamityMod.World Tile.SmoothSlope(X, Y); } } - }); + } } - //bottom of the biome (gleaming burrows) - public static void PlaceGleamingBurrows(int startPosX, int startPosY) - { - int cavePerlinSeed = WorldGen.genRand.Next(); - int cavePerlinSeedWalls = WorldGen.genRand.Next(); + public static void PlaceGleamingBurrowsGeodes(int startPosX, int startPosY) - Point origin = new Point(startPosX, startPosY); + { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.GleamingBurrowsX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.GleamingBurrowsY; + + Point origin = new Point(startX, startY); Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); float angle = MathHelper.Pi * 0.15f; @@ -817,163 +936,10 @@ namespace CalamityMod.World Vector2 topFoci = center - fociOffset; Vector2 bottomFoci = center + fociOffset; - //place another barrier so the gleaming burrows doesnt just burst into the gully - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 10, (X) => - { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y += 2) - { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) - { - float percent = dist / constant; - float blurPercent = 0.98f; + ushort Navystone = (ushort)ModContent.TileType(); + ushort NavystoneWall = (ushort)ModContent.WallType(); - if (percent > blurPercent) - { - if (Y > origin.Y - 10) - { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(10, 0.4); - WorldUtils.Gen(new Point(X, Y - 10), new Shapes.Circle(20), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); - WorldUtils.Gen(new Point(X, Y - 10), new ModShapes.All(circle), Actions.Chain(new GenAction[] - { - new Actions.Clear(), - new Actions.PlaceTile((ushort)ModContent.TileType()) - })); - } - } - } - } - }); - - //place the gleaming burrows caverns - for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) - { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) - { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) - { - float percent = dist / constant; - float blurPercent = 0.99f; - - if (percent > blurPercent) - { - if (Y > origin.Y - 50) - { - //place smaller navystone clumps infront of the basalt so the basalt isnt actually inside of the biome itself - WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), true, 0f, 0f, true, true); - } - - //place clean transition between the burrows and the other biomes - if (Y < origin.Y && Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) - { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); - - WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] - { - new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()) - })); - } - } - else - { - //clear absolutely everything before generating the caverns - Main.tile[X, Y].ClearEverything(); - - //generate perlin noise caves - float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; - float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; - float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; - float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; - float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.235f; - - //kill or place tiles depending on the noise map - if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) - { - WorldGen.KillTile(X, Y); - } - else - { - WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); - } - - //place walls in the biome using a different "seed" so it differs from the cave generation - //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through - float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; - float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; - float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; - float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; - float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 5.5f + 0.235f; - - if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) - { - WorldGen.PlaceWall(X, Y, ModContent.WallType()); - } - - Main.tile[X, Y].Get().LiquidType = LiquidID.Water; - Main.tile[X, Y].LiquidAmount = byte.MaxValue; - } - } - } - } - - //cleanup the perlin caves - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => - { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) - { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) - { - //clean tiles that are sticking out (aka tiles only attached to one tile on one side) - bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; - bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; - bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; - bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; - - if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) - { - WorldGen.KillTile(X, Y); - } - - //kill random single floating tiles - if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) - { - WorldGen.KillTile(X, Y); - } - } - } - }); - - //place extra tiles - ForLoop.Invoke(origin.X - biomeSize - 3, origin.X + biomeSize + 3, 1, (X) => - { - for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) - { - if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) - { - bool canPlaceSand = false; - - //place sand clumps on top of exposed navystone - if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && !Main.tile[X, Y - 3].HasTile) - { - canPlaceSand = true; - } - - if (canPlaceSand) - { - PlaceSand(X, Y, 4, ModContent.TileType()); - } - } - } - }); //cleanup again, also place geodes for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) @@ -1017,99 +983,583 @@ namespace CalamityMod.World } } } - - //basalt biome underneath the sunken sea - public static void PlaceBasaltGully(int startPosX, int startPosY) + public static void PlaceGleamingBurrows(int startPosX, int startPosY) { - int biomeSize = 200 + (Main.maxTilesX / 180); + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.GleamingBurrowsX; - int XLeft = GenVars.UndergroundDesertLocation.Left + 30; - int XRight = GenVars.UndergroundDesertLocation.Right - 30; + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.GleamingBurrowsY; - //place circles of basalt along the 2 edges of the area - for (int Y = startPosY - 60; Y <= Main.maxTilesY - 230; Y += 20) + int cavePerlinSeed = WorldGen.genRand.Next(); + int cavePerlinSeedWalls = WorldGen.genRand.Next(); + + Point origin = new Point(startX, startY); + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; + + int biomeSize = 220 + (Main.maxTilesX / 180); + float actualSize = biomeSize * 16f; + float constant = actualSize * 2f / (float)Math.Sin(angle); + + float fociSpacing = actualSize * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); + int verticalRadius = (int)(constant / 16f); + + Vector2 fociOffset = Vector2.UnitY * fociSpacing; + Vector2 topFoci = center - fociOffset; + Vector2 bottomFoci = center + fociOffset; + + ushort Navystone = (ushort)ModContent.TileType(); + ushort NavystoneWall = (ushort)ModContent.WallType(); + + int XStart = origin.X - biomeSize - 3; + int XEnd = origin.X + biomeSize + 3; + + int YStart = (int)(origin.Y - verticalRadius * 0.4f) - 3; + int YEnd = origin.Y + verticalRadius + 3; + + int newTunnelXLeft = (startX - 300); + int newTunnelYLeft = (startY - 10); + + int newTunnelXRight = (startX + 300); + int newTunnelYRight = (startY - 10); + + + //place another barrier so the gleaming burrows doesnt just burst into the gully + + var basaltcircle = new Shapes.Circle(30); + GenAction paintBasalt = Actions.Chain( + new Actions.Clear(), + new Actions.SetTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()), + new Actions.SetFrames(true) + ); + + for (int X = XStart; X < XEnd; X += 14) { - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - - int radius = WorldGen.genRand.Next(30, 45); - int RandomX = Main.rand.Next(-25, 25); - - WorldUtils.Gen(new Point(XLeft, Y), new Shapes.Circle(radius), Actions.Chain(new GenAction[] + for (int Y = YStart; Y <= YEnd; Y += 12) { - blotchMod.Output(circle) - })); - - WorldUtils.Gen(new Point(XLeft, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] - { - new Actions.Clear(), - new Actions.PlaceTile((ushort)ModContent.TileType()), - new Actions.PlaceWall(WallID.LavaUnsafe1) - })); - - WorldUtils.Gen(new Point(XRight, Y), new Shapes.Circle(radius), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); - - WorldUtils.Gen(new Point(XRight, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] - { - new Actions.Clear(), - new Actions.PlaceTile((ushort)ModContent.TileType()), - new Actions.PlaceWall(WallID.LavaUnsafe1) - })); + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float _, true) + && Y > origin.Y - 10) + { + WorldUtils.Gen(new Point(X - 5, Y + 5), basaltcircle, paintBasalt); + } + } } - //place blocks of basalt all the way down to hell, here it just places one block and wall so it doesnt hurt preformance - ForLoop.Invoke(startPosX - biomeSize - 25, startPosX + biomeSize + 25, 1, (X) => + var Obsidiancircle = new Shapes.Circle(13); + GenAction paintObsidian = Actions.Chain( + new Actions.Clear(), + new Actions.SetTile((ushort)ModContent.TileType()), + new Actions.PlaceWall((ushort)ModContent.WallType()), + new Actions.SetFrames(true) + ); + + for (int X = XStart; X < XEnd; X += 5) { - for (int Y = startPosY - 30; Y <= Main.maxTilesY - 200; Y++) + for (int Y = YStart; Y <= YEnd; Y += 5) { - Main.tile[X, Y].ClearEverything(); - WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); - WorldGen.PlaceWall(X, Y, WallID.LavaUnsafe1); + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float _, true) + && Y > origin.Y - 10) + { + WorldUtils.Gen(new Point(X - 2, Y + 7), Obsidiancircle, paintObsidian); + } } - }); + } - //place another wall of circles along the bottom of the biome so it doesnt just end unnaturally - ForLoop.Invoke(startPosX - biomeSize, startPosX + biomeSize, 20, (X) => + + //place the gleaming burrows caverns + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) { - int Y = Main.maxTilesY - 250; - - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(25), Actions.Chain(new GenAction[] + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { - blotchMod.Output(circle) - })); + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + Tile t = Main.tile[X, Y]; + float percent = dist / constant; + float blurPercent = 0.99f; - WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + if (percent > blurPercent) + { + if (Y > origin.Y - 15) + { + //place smaller navystone clumps infront of the basalt so the basalt isnt actually inside of the biome itself + WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), true, 0f, 0f, true, true); + t.WallType = (ushort)ModContent.WallType(); + } + + //place clean transition between the burrows and the other biomes + if (Y < origin.Y && Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) + { + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Slime(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()), new Actions.PlaceWall((ushort)ModContent.WallType()) + })); + } + } + else + { + + + //clear absolutely everything before generating the caverns + Main.tile[X, Y].ClearEverything(); + + //generate perlin noise caves + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; + float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.235f; + + //kill or place tiles depending on the noise map + if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) + { + WorldGen.KillTile(X, Y); + } + else + { + t.TileType = Navystone; + t.HasTile = true; + } + + float horizontalOffsetNoiseWallsinner = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWallsinner = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWallsinner; + float cavePerlinValue2Wallsinner = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWallsinner = (cavePerlinValueWallsinner + cavePerlinValue2Wallsinner) * 0.5f; + float caveCreationThresholdWallsinner = horizontalOffsetNoiseWallsinner * 5.5f + 0.435f; + + if (caveNoiseMapWallsinner * caveNoiseMapWallsinner > caveCreationThresholdWallsinner) + { + t.WallType = (ushort)ModContent.WallType(); + } + + //place walls in the biome using a different "seed" so it differs from the cave generation + //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through + float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; + float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; + float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 5.5f + 0.235f; + + if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) + { + if (t.WallType == WallID.None) + t.WallType = NavystoneWall; + } + + + + Main.tile[X, Y].Get().LiquidType = LiquidID.Water; + Main.tile[X, Y].LiquidAmount = byte.MaxValue; + } + } + } + } + + //Tunnels + MiscWorldgenRoutines.ClearTunnel(startX - 200, startY + 40, newTunnelXLeft, newTunnelYLeft, 3, (ushort)ModContent.WallType(), 2, false, false); + MiscWorldgenRoutines.ClearTunnel(startX + 200, startY + 40, newTunnelXRight, newTunnelYRight, 3, (ushort)ModContent.WallType(), 2, false, false); + + //cleanup the perlin caves + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { - new Actions.Clear(), - new Actions.PlaceTile((ushort)ModContent.TileType()), - new Actions.PlaceWall(WallID.LavaUnsafe1) - })); - }); + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + } + } + } + + //place extra tiles + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + bool canPlaceSand = false; + + //place sand clumps on top of exposed navystone + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && !Main.tile[X, Y - 3].HasTile) + { + canPlaceSand = true; + } + + if (canPlaceSand) + { + PlaceSand(X, Y, 4, ModContent.TileType()); + } + } + } + } + + + } + + //Very bottom of the biome (Clam Den) + public static void PlaceClamDen(int startPosX, int startPosY) + { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.ClamDenX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.ClamDenY; + + int cavePerlinSeed = WorldGen.genRand.Next(); + int cavePerlinSeedWalls = WorldGen.genRand.Next(); + + Point origin = new Point(startX, startY); + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.70f; + float otherAngle = MathHelper.PiOver2 - angle; + + int biomeSize = 80 + (Main.maxTilesX / 180); + float actualSize = biomeSize * 16f; + float constant = actualSize * 2f / (float)Math.Sin(angle); + + float fociSpacing = actualSize * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); + int verticalRadius = (int)(constant / 10f); + + Vector2 fociOffset = Vector2.UnitY * fociSpacing; + Vector2 topFoci = center - fociOffset; + Vector2 bottomFoci = center + fociOffset; + + //place the Clam Den caverns + for (int X = origin.X - biomeSize - 190; X <= origin.X + biomeSize + 190; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + Tile t = Main.tile[X, Y]; + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + float percent = dist / constant; + float blurPercent = 0.99f; + + if (percent > blurPercent) + { + if (Y > origin.Y - 50) + { + //place smaller navystone clumps infront of the basalt so the basalt isnt actually inside of the biome itself + WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), true, 0f, 0f, true, true); + t.WallType = (ushort)ModContent.WallType(); + } + //place clean transition between the burrows and the other biomes + if (Y < origin.Y && Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) + { + WorldUtils.Gen(new Point(X, Y), new Shapes.Slime(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + } + } + else + { + //clear absolutely everything before generating the caverns + Main.tile[X, Y].ClearEverything(); + + //place walls in the biome using a different "seed" so it differs from the cave generation + //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through + float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; + float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; + float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 5.5f + 0.235f; + + if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) + { + t.WallType = (ushort)ModContent.WallType(); + } + + Main.tile[X, Y].Get().LiquidType = LiquidID.Water; + Main.tile[X, Y].LiquidAmount = byte.MaxValue; + } + } + } + } + + + //cleanup the perlin caves + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + } + } + } + + + //place extra tiles + for (int X = origin.X - biomeSize - 3; X < origin.X + biomeSize + 3; X += 1) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + bool canPlaceSand = false; + + //place sand clumps on top of exposed navystone + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && !Main.tile[X, Y - 3].HasTile) + { + canPlaceSand = true; + } + + if (canPlaceSand) + { + PlaceSand(X, Y, 4, ModContent.TileType()); + } + } + } + } + + //cleanup again + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + + //if any sand is floating, put tiles below it + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); + } + + Tile.SmoothSlope(X, Y); + } + } + } + } + + //public static void PlaceBasaltGullyBorderBlend(int startPosX, int startPosY) + //{ + // int startX = (startPosX + SSOffsets.GlobalX + SSOffsets.BasaltGullyX); + + // int startY = (startPosY + SSOffsets.GlobalY + SSOffsets.BasaltGullyY) - 90; + + // int biomeSize = 250 + (Main.maxTilesX / 180); + + // ushort Basalt = (ushort)ModContent.TileType(); + // ushort BasaltWall = (ushort)ModContent.WallType(); + + // //place blocks of basalt all the way down to hell, here it just places one block and wall so it doesnt hurt preformance + // for (int X = startX - biomeSize - 80; X < startX + biomeSize + 80; X += 1) + // { + // const int totalCurveDepth = -320; + // const int totalCurveDepthTop = 70; + + // var squrt = MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 60, startX + biomeSize - 200, X, true)); + // var squrt2 = MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 60, startX - biomeSize + 200, X, true)); + + + // int curveDepth = (int)MathHelper.Lerp( + // totalCurveDepth, + // 0f, squrt); + // int curveDepth2 = (int)MathHelper.Lerp( + // totalCurveDepth, 0f, squrt2); + // int curveDepthtop = (int)MathHelper.Lerp( + // totalCurveDepthTop, + // 0f, squrt); + // int curveDepth2top = (int)MathHelper.Lerp( + // totalCurveDepthTop, + // 0f, squrt2); + + // int Height = Main.maxTilesY - 270 + curveDepth + curveDepth2; + // int StartHeight = startY - (625) + curveDepthtop + curveDepth2top; + + // for (int Y = StartHeight; Y <= Height; Y++) + // { + // Tile t = Main.tile[X, Y]; + // if (Main.tile[X, Y].HasTile) + // { + // t.TileType = Basalt; + // t.HasTile = true; + // } + + // t.WallType = BasaltWall; + // } + // } + + // //cleanup + // for (int X = startX - biomeSize - (Main.maxTilesX / 25); X < startX + biomeSize + (Main.maxTilesX / 25); X += 1) + // { + // for (int Y = startY; Y <= Main.maxTilesY - 210; Y++) + // { + // //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + // bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + // bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + // bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + // bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + // if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + // { + // WorldGen.KillTile(X, Y); + // } + + // //kill random single floating tiles + // if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + // { + // WorldGen.KillTile(X, Y); + // } + // Tile.SmoothSlope(X, Y); + // } + // } + //} + public static void PlaceBasaltGully(int startPosX, int startPosY) + { + int startX = startPosX + SSOffsets.GlobalX + SSOffsets.BasaltGullyX; + + int startY = startPosY + SSOffsets.GlobalY + SSOffsets.BasaltGullyY; + + int biomeSize = 270 + (Main.maxTilesX / 180); + + ushort Basalt = (ushort)ModContent.TileType(); + ushort BasaltWall = (ushort)ModContent.WallType(); + + int cavePerlinSeed = WorldGen.genRand.Next(); + int cavePerlinSeedWalls = WorldGen.genRand.Next(); + + //place blocks of basalt all the way down to hell, here it just places one block and wall so it doesnt hurt preformance + for (int X = startX - biomeSize - 80; X < startX + biomeSize + 80; X += 1) + { + int leftEdge = startX - biomeSize - 60; + int rightEdge = startX + biomeSize + 60; + int basaltbordernoise = 270 + Main.rand.Next(0, 4); + int basaltbordernoisetop = 625 + Main.rand.Next(0, 4); + const int totalCurveDepth = -475; + const int totalCurveDepthTop = -100; + + var squrt = MathF.Sqrt(Utils.GetLerpValue(startX + biomeSize + 60, startX + biomeSize - 200, X, true)); + var squrt2 = MathF.Sqrt(Utils.GetLerpValue(startX - biomeSize - 60, startX - biomeSize + 200, X, true)); + + + int curveDepth = (int)MathHelper.Lerp( + totalCurveDepth, + 0f, squrt); + int curveDepth2 = (int)MathHelper.Lerp( + totalCurveDepth, 0f, squrt2); + int curveDepthtop = (int)MathHelper.Lerp( + totalCurveDepthTop, + 0f, squrt); + int curveDepth2top = (int)MathHelper.Lerp( + totalCurveDepthTop, + 0f, squrt2); + + int Height = Main.maxTilesY - basaltbordernoise + curveDepth + curveDepth2; + int StartHeight = startY - (basaltbordernoisetop) + curveDepthtop + curveDepth2top; + + for (int Y = StartHeight; Y <= Height; Y++) + { + int leftIndent = Main.rand.Next(0, 12); + int rightIndent = Main.rand.Next(0, 12); + if (X < leftEdge + leftIndent || X > rightEdge - rightIndent) + continue; + + Tile t = Main.tile[X, Y]; + t.ClearEverything(); + t.TileType = Basalt; + t.WallType = BasaltWall; + t.HasTile = true; + } + } //place caverns and lava - for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) + for (int X = startX - biomeSize - (Main.maxTilesX / 25); X <= startX + biomeSize + (Main.maxTilesX / 25); X++) { - for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + for (int Y = startY; Y <= Main.maxTilesY - 190; Y++) { if (Main.tile[X, Y].TileType == ModContent.TileType()) { + Tile t = Main.tile[X, Y]; //place caves - if (WorldGen.genRand.NextBool(350)) + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80, Y / 130, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 975f, Y / 375f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 975f, Y / 375f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; + float caveCreationThreshold = horizontalOffsetNoise * 5.5f + 0.235f; + + if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) { - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(5, 12)), Actions.Chain(new Modifiers.Blotches( - WorldGen.genRand.Next(3, 5), WorldGen.genRand.Next(3, 5)), new Actions.ClearTile())); + t.HasTile = false; + t.LiquidType = LiquidID.Lava; + } + + float horizontalOffsetNoiseWallsinner = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWallsinner = CalamityUtils.PerlinNoise2D(X / 975f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWallsinner; + float cavePerlinValue2Wallsinner = CalamityUtils.PerlinNoise2D(X / 975f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWallsinner = (cavePerlinValueWallsinner + cavePerlinValue2Wallsinner) * 0.5f; + float caveCreationThresholdWallsinner = horizontalOffsetNoiseWallsinner * 5.5f + 0.435f; + + if (caveNoiseMapWallsinner * caveNoiseMapWallsinner > caveCreationThresholdWallsinner) + { + if (t.WallType == BasaltWall) + { + WorldGen.KillWall(X, Y); + } } //place lava if (WorldGen.genRand.NextBool(2000)) { - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(5, 12)), Actions.Chain(new Modifiers.Blotches( + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(5, 7)), Actions.Chain(new Modifiers.Blotches( WorldGen.genRand.Next(3, 5), WorldGen.genRand.Next(3, 5)), new Actions.SetLiquid(LiquidID.Lava, 255))); } } @@ -1117,9 +1567,9 @@ namespace CalamityMod.World } //place sand blocks - ForLoop.Invoke(startPosX - biomeSize - (Main.maxTilesX / 25), startPosX + biomeSize + (Main.maxTilesX / 25), 1, (X) => + for (int X = startX - biomeSize - (Main.maxTilesX / 25); X < startX + biomeSize + (Main.maxTilesX / 25); X += 1) { - for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + for (int Y = startY; Y <= Main.maxTilesY - 210; Y++) { bool canPlaceSand = false; @@ -1134,12 +1584,12 @@ namespace CalamityMod.World PlaceSand(X, Y, 3, ModContent.TileType()); } } - }); + } //cleanup - ForLoop.Invoke(startPosX - biomeSize - (Main.maxTilesX / 25), startPosX + biomeSize + (Main.maxTilesX / 25), 1, (X) => + for(int X = startX - biomeSize - (Main.maxTilesX / 25); X < startX + biomeSize + (Main.maxTilesX / 25); X += 1) { - for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + for (int Y = startY; Y <= Main.maxTilesY - 210; Y++) { //clean tiles that are sticking out (aka tiles only attached to one tile on one side) bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; @@ -1164,25 +1614,15 @@ namespace CalamityMod.World WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); } - } - }); - } + Tile.SmoothSlope(X, Y); - //cleanup is done separately because for whatever reason it keeps placing water inside of the gully if the cleanup is done before it - public static void BasaltGullyLavaCleanup(int startPosX, int startPosY) - { - int biomeSize = 230 + (Main.maxTilesX / 180); - - for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) - { - for (int Y = startPosY + 50; Y <= Main.maxTilesY - 200; Y++) - { - if (Main.tile[X, Y].WallType == WallID.LavaUnsafe1) + Tile t = Main.tile[X, Y]; + if (Main.tile[X, Y].WallType == BasaltWall) { //get rid of water if (Main.tile[X, Y].LiquidType == LiquidID.Water) { - Main.tile[X, Y].Get().LiquidType = LiquidID.Lava; + t.LiquidType = LiquidID.Lava; } //get rid of obsidian blocks @@ -1194,114 +1634,294 @@ namespace CalamityMod.World } } } + + + //cleanup is done separately because for whatever reason it keeps placing water inside of the gully if the cleanup is done before it + //public static void BasaltGullyLavaCleanup(int startPosX, int startPosY) + //{ + // ushort BasaltWall = (ushort)ModContent.WallType(); + // int biomeSize = 230 + (Main.maxTilesX / 180); + + // for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) + // { + // for (int Y = startPosY + 50; Y <= Main.maxTilesY - 200; Y++) + // { + + // } + // } + //} + //place all the ambient tiles in the sunken sea public static void PlaceSunkenSeaAmbience() { + bool shipPlaced = false; //first clean up unnecessary chunks of tiles CleanOutSmallClumps(); - //just loop through the whole world and check for the specific tiles in the sunken sea because im lazy - for (int X = 20; X <= Main.maxTilesX - 20; X++) + // Loop through the area around the Sunken Sea and check for the specific tiles + int minX = Math.Max(20, GenVars.UndergroundDesertLocation.Left - 20); + int maxX = Math.Min(GenVars.UndergroundDesertLocation.Right + 20, Main.maxTilesX - 20); + for (int X = minX; X <= maxX; X++) { - for (int Y = 20; Y <= Main.maxTilesY - 20; Y++) + for (int Y = (int)Main.worldSurface; Y <= Main.UnderworldLayer; Y++) { - //place coral blobs in the radiant reefs - if (WorldGen.genRand.NextBool(100) && ((Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile) || - (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile))) + if (WorldGen.genRand.NextBool(200)) + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[] { - ushort[] Corals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + })); + if (WorldGen.genRand.NextBool(200)) + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + })); - ShapeData circle = new ShapeData(); - GenAction blotchMod = new Modifiers.Blotches(2, 0.4); - WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(2, 4)), Actions.Chain(new GenAction[] - { - blotchMod.Output(circle) - })); - WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + + //Timeless Shores ambiant tiles + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + int MediumShorePileVariants = WorldGen.genRand.Next(3); + int DriftwoodVariants = WorldGen.genRand.Next(6); + int ShorePileVariants = WorldGen.genRand.Next(9); + //Driftwood Ambiance + if (WorldGen.genRand.NextBool(100)) { - new Actions.ClearTile(), new Actions.PlaceTile(WorldGen.genRand.Next(Corals)) - })); + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(100)) + {; + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(100)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + //Shore piles + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: ShorePileVariants); + } + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: MediumShorePileVariants); + } + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: MediumShorePileVariants); + } } + + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + // stay in-bounds + if (Y > 0) + { + Tile above = Main.tile[X, Y - 1]; + + // only if it's open air (no solid tile), and we don't overwrite other special liquids other than lava (just incase) + if (!above.HasTile && + above.Get().LiquidType != LiquidID.Honey && + above.Get().LiquidType != LiquidID.Shimmer) + { + above.Get().LiquidType = LiquidID.Water; + above.LiquidAmount = byte.MaxValue; // 255 + } + } + } + + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + int DriftwoodVariants = WorldGen.genRand.Next(6); + //Driftwood Ambiance + if (WorldGen.genRand.NextBool(80)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(60)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(60)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + } + //gleaming burrows ambient tiles if (Main.tile[X, Y].TileType == ModContent.TileType()) { + int NavystonePileVariants = WorldGen.genRand.Next(6); //brain coral - if (WorldGen.genRand.NextBool(10)) + if (WorldGen.genRand.NextBool(30)) { WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } //small brain coral - if (WorldGen.genRand.NextBool(5)) + if (WorldGen.genRand.NextBool(30)) { WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } //tube coral - if (WorldGen.genRand.NextBool(12)) + if (WorldGen.genRand.NextBool(16)) { WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } //small tube coral - if (WorldGen.genRand.NextBool(8)) + if (WorldGen.genRand.NextBool(12)) { WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } //anemonies - if (WorldGen.genRand.NextBool(10)) + if (WorldGen.genRand.NextBool(18)) { WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } //giant navystone piles - if (WorldGen.genRand.NextBool(10)) + if (WorldGen.genRand.NextBool(20)) { ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles)); } - //small navystone piles - if (WorldGen.genRand.NextBool(5)) + //navystone piles + if (WorldGen.genRand.NextBool(10)) { - ushort[] Piles = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles)); + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: NavystonePileVariants); } + + //small navystone piles + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: NavystonePileVariants); + } + + //misc piles + if (WorldGen.genRand.NextBool(6)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 3)); + } + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 6)); + } + if (WorldGen.genRand.NextBool(16)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 6)); + } + + //kelp bushes + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: WorldGen.genRand.Next(0, 3)); + } + + //Pearls + if (WorldGen.genRand.NextBool(60) && !Main.tile[X - 1, Y].HasTile) + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + })); + + if (WorldGen.genRand.NextBool(60) && !Main.tile[X - 1, Y].HasTile) + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + })); + + if (WorldGen.genRand.NextBool(60) && !Main.tile[X - 1, Y].HasTile) + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(2), Actions.Chain(new GenAction[] + { + new Modifiers.OnlyTiles((ushort)ModContent.TileType()), + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + })); + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + int Rand8() => WorldGen.genRand.Next(8); + int MediumSeaPrismCrystalVariants = Rand8(); + //Medium Sea Prism down + if (WorldGen.genRand.NextBool(9)) + { + ushort[] CrystalRandom = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y + 1, WorldGen.genRand.Next(CrystalRandom), true, 0, 0, MediumSeaPrismCrystalVariants); + } + if (WorldGen.genRand.NextBool(9)) + { + ushort[] CrystalRandom = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(CrystalRandom), true, 0, 0, MediumSeaPrismCrystalVariants); + } + if (WorldGen.genRand.NextBool(9)) + { + ushort[] CrystalRandom = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(CrystalRandom), true, 0, 0, MediumSeaPrismCrystalVariants); + } + if (WorldGen.genRand.NextBool(9)) + { + ushort[] CrystalRandom = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y + 1, WorldGen.genRand.Next(CrystalRandom), true, 0, 0, MediumSeaPrismCrystalVariants); + } + } + //grow depth vines on navystone + if (Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile && !Main.tile[X, Y + 2].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); } if (Main.tile[X, Y].TileType == ModContent.TileType()) { + int TableCoralVariants = WorldGen.genRand.Next(3); + int SpeleothemsVariants = WorldGen.genRand.Next(3); + int NavystonePileVariants = WorldGen.genRand.Next(6); + + if (WorldGen.genRand.NextBool(30) && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.PlaceTile(X + 2, Y, ModContent.TileType(), true, false, -1, TableCoralVariants); + } + + if (WorldGen.genRand.NextBool(30) && !Main.tile[X - 1, Y].HasTile) + { + WorldGen.PlaceTile(X - 2, Y, ModContent.TileType(), true, false, -1, TableCoralVariants); + } + + //Speleothems below //stalactites if (WorldGen.genRand.NextBool(10)) { - ushort[] Stalactites = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - WorldGen.PlaceObject(X, Y + 2, WorldGen.genRand.Next(Stalactites)); + WorldGen.PlaceTile(X, Y + 2, (ushort)ModContent.TileType(), true, false, -1, SpeleothemsVariants); } //small stalactites if (WorldGen.genRand.NextBool(8)) { - WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType(), true, false, -1, SpeleothemsVariants); } - //stalagmites if (WorldGen.genRand.NextBool(12)) { - ushort[] Stalagmites = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - - WorldGen.PlaceObject(X, Y - 2, WorldGen.genRand.Next(Stalagmites)); + WorldGen.PlaceTile(X, Y - 2, (ushort)ModContent.TileType(), true, false, -1, SpeleothemsVariants); } //small stalagmites if (WorldGen.genRand.NextBool(10)) { - WorldGen.PlaceTile(X, Y - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceTile(X, Y - 1, (ushort)ModContent.TileType(), true, false, -1, SpeleothemsVariants); } //giant navystone piles @@ -1312,19 +1932,186 @@ namespace CalamityMod.World WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles)); } - //small navystone piles + //navystone piles if (WorldGen.genRand.NextBool()) { - ushort[] Piles = new ushort[] { (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: NavystonePileVariants); + } - WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles)); + //small navystone piles + if (WorldGen.genRand.NextBool(5)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: NavystonePileVariants); + } + } + //Mossy Stone + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + if (WorldGen.genRand.NextBool(5)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: WorldGen.genRand.Next(0, 5)); + } + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: WorldGen.genRand.Next(0, 3)); + } + } + //Polyp Forest Ambient tiles + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + int RandStyle() => WorldGen.genRand.Next(8); + int style = RandStyle(); + //BranchCoralsOnLimestone + if (WorldGen.genRand.NextBool(15)) + { + ushort[] BranchCorals = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y + 1, WorldGen.genRand.Next(BranchCorals), true, 0, 0, style); + } + if (WorldGen.genRand.NextBool(15)) + { + ushort[] BranchCorals = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BranchCorals), true, 0, 0, style); + } + } + //GilHerb Vines + if (Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile && !Main.tile[X, Y + 2].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + int BranchCoralVariants = WorldGen.genRand.Next(8); + int WideScarletSeagrassVariants = WorldGen.genRand.Next(4); + int DriftwoodVariants = WorldGen.genRand.Next(6); + + //BranchCoralsOnSand + if (WorldGen.genRand.NextBool(25)) + { + ushort[] BranchCorals = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y + 1, WorldGen.genRand.Next(BranchCorals), true, 0, 0, BranchCoralVariants); + } + if (WorldGen.genRand.NextBool(25)) + { + ushort[] BranchCorals = new ushort[] { (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BranchCorals), true, 0, 0, BranchCoralVariants); + } + if (WorldGen.genRand.NextBool(25)) + { + ushort[] DigitateCorals = new ushort[] { (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(DigitateCorals)); + } + if (WorldGen.genRand.NextBool(12)) + { + ushort[] FryCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(FryCorals)); + } + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: WideScarletSeagrassVariants); + } + if (WorldGen.genRand.NextBool(12)) + { + ushort[] StalkCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(StalkCorals)); + } + if (WorldGen.genRand.NextBool(16)) + { + ushort[] FryCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(FryCorals)); + } + if (WorldGen.genRand.NextBool(18)) + { + ushort[] TallDigitateCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(TallDigitateCorals)); + } + if (WorldGen.genRand.NextBool(6)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 3)); + } + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 11)); + } + if (WorldGen.genRand.NextBool(16)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 3)); + } + + //Driftwood Ambiance + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(),true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (!shipPlaced) + { + if (WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), mute: true)) + shipPlaced = true; + } + //small limestone piles + if (WorldGen.genRand.NextBool(25)) + { + WorldGen.PlaceTile(X, Y - 1, ModContent.TileType(), mute: true, style: DriftwoodVariants); } } //radiant reefs ambient tiles if (Main.tile[X, Y].TileType == ModContent.TileType()) { + //Coral Blocks (to be removed when we have real gen for them + if (WorldGen.genRand.NextBool(400) && ((Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile) || + (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile))) + { + ushort[] Corals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile(WorldGen.genRand.Next(Corals)) + })); + } + + int DriftwoodVariants = WorldGen.genRand.Next(6); + //Driftwood Ambiance + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } + if (WorldGen.genRand.NextBool(30)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, DriftwoodVariants); + } //multi-colored corals if (WorldGen.genRand.NextBool(3)) { @@ -1335,7 +2122,7 @@ namespace CalamityMod.World } //blue coral trees - if (WorldGen.genRand.NextBool(4)) + if (WorldGen.genRand.NextBool(8)) { ushort[] BlueCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; @@ -1343,7 +2130,7 @@ namespace CalamityMod.World } //brown coral trees - if (WorldGen.genRand.NextBool(4)) + if (WorldGen.genRand.NextBool(8)) { ushort[] BrownCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; @@ -1351,11 +2138,29 @@ namespace CalamityMod.World } //fan coral - if (WorldGen.genRand.NextBool(10)) + if (WorldGen.genRand.NextBool(16)) { WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } + //misc piles + if (WorldGen.genRand.NextBool(6)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 3)); + } + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 9)); + } + if (WorldGen.genRand.NextBool(16)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 3)); + } + if (WorldGen.genRand.NextBool(20)) + { + WorldGen.PlaceObject(X, Y - 1, ModContent.TileType(), true, style: WorldGen.genRand.Next(0, 3)); + } + //misc corals if (WorldGen.genRand.NextBool()) { @@ -1365,39 +2170,69 @@ namespace CalamityMod.World WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(MiscCorals)); } } - - //grow depth vines on navystone - if (Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile && !Main.tile[X, Y + 2].HasTile) + if (Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile && !Main.tile[X, Y + 2].HasTile) { - if (WorldGen.genRand.NextBool(7)) + if (WorldGen.genRand.NextBool()) { - WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); } } - if (Main.tile[X, Y].TileType == ModContent.TileType()) + if (Main.tile[X, Y].TileType == ModContent.TileType()) { - CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); + CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); } - //wall corals if (Main.tile[X, Y].TileType == ModContent.TileType()) { - if (WorldGen.genRand.NextBool(5) && !Main.tile[X + 1, Y].HasTile) - { - ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + int Rand4() => WorldGen.genRand.Next(4); + int WallCoralVariants = Rand4(); - WorldGen.PlaceTile(X + 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + if (WorldGen.genRand.NextBool(5) && + Main.tile[X, Y].HasTile && + Main.tile[X, Y + 1].HasTile && + Main.tile[X, Y + 2].HasTile && + + !Main.tile[X + 1, Y].HasTile && + !Main.tile[X + 1, Y + 1].HasTile && + !Main.tile[X + 1, Y + 2].HasTile && + + !Main.tile[X + 2, Y].HasTile && + !Main.tile[X + 2, Y + 1].HasTile && + !Main.tile[X + 2, Y + 2].HasTile && + + !Main.tile[X + 3, Y].HasTile && + !Main.tile[X + 3, Y + 1].HasTile && + !Main.tile[X + 3, Y + 2].HasTile && + + !Main.tile[X + 4, Y].HasTile && + !Main.tile[X + 4, Y + 1].HasTile && + !Main.tile[X + 4, Y + 2].HasTile) + { + WorldGen.PlaceTile(X + 2, Y, ModContent.TileType(), true, false, -1, WallCoralVariants); } - if (WorldGen.genRand.NextBool(5) && !Main.tile[X - 1, Y].HasTile) - { - ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + if (WorldGen.genRand.NextBool(5) && + Main.tile[X, Y].HasTile && + Main.tile[X, Y + 1].HasTile && + Main.tile[X, Y + 2].HasTile && - WorldGen.PlaceTile(X - 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + !Main.tile[X - 1, Y].HasTile && + !Main.tile[X - 1, Y + 1].HasTile && + !Main.tile[X - 1, Y + 2].HasTile && + + !Main.tile[X - 2, Y].HasTile && + !Main.tile[X - 2, Y + 1].HasTile && + !Main.tile[X - 2, Y + 2].HasTile && + + !Main.tile[X - 3, Y].HasTile && + !Main.tile[X - 3, Y + 1].HasTile && + !Main.tile[X - 3, Y + 2].HasTile && + + !Main.tile[X - 4, Y].HasTile && + !Main.tile[X - 4, Y + 1].HasTile && + !Main.tile[X - 4, Y + 2].HasTile) + { + WorldGen.PlaceTile(X - 2, Y, ModContent.TileType(), true, false, -1, WallCoralVariants); } } } @@ -1450,6 +2285,7 @@ namespace CalamityMod.World ShapeData circle3 = new ShapeData(); GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + GenAction blotchMod2 = new Modifiers.Blotches(1, 0.1); //first circle of navystone WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius), Actions.Chain(new GenAction[] @@ -1476,13 +2312,17 @@ namespace CalamityMod.World //clear out the middle of the circle WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 9), Actions.Chain(new GenAction[] { - blotchMod.Output(circle3) + blotchMod2.Output(circle3) })); WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle3), Actions.Chain(new GenAction[] { new Actions.ClearTile(), new Actions.SetLiquid(), - new Actions.PlaceWall((ushort)ModContent.WallType()) + })); + + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 4), Actions.Chain(new GenAction[] + { + new Actions.PlaceWall((ushort)ModContent.WallType()) })); return true; @@ -1493,14 +2333,27 @@ namespace CalamityMod.World { List blockTileTypes = new() { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), }; @@ -1522,7 +2375,7 @@ namespace CalamityMod.World getAttachedPoints(x, y - 1, points); } - ForLoop.Invoke(20, Main.maxTilesX - 20, 1, (x) => + for (int x = 20; x < Main.maxTilesX - 20; x += 1) { for (int y = 20; y < Main.maxTilesY - 20; y++) { @@ -1537,14 +2390,15 @@ namespace CalamityMod.World WorldUtils.Gen(p, new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { new Actions.ClearTile(true), - new Actions.SetLiquid() + new Actions.ClearWall(true) })); } } } - }); + } } + //method to make sure things only generate in each biome circle public static bool CheckInBiomeArea(Point tile, Vector2 focus1, Vector2 focus2, float distanceConstant, Vector2 center, out float distance, bool collapse = false, bool collapseBottom = false) { diff --git a/World/UndergroundShrines.cs b/World/UndergroundShrines.cs index 409cacaa03..2ecd592b96 100644 --- a/World/UndergroundShrines.cs +++ b/World/UndergroundShrines.cs @@ -1,22 +1,16 @@ using System; using System.Collections.Generic; -using System.Linq; using CalamityMod.Items.Accessories; using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Items.Placeables.FurnitureAbyss; -using CalamityMod.Items.Placeables.SunkenSea; -using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.Potions.Food; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Schematics; using CalamityMod.Tiles; -using CalamityMod.Tiles.Crags; -using CalamityMod.Tiles.DraedonStructures; using CalamityMod.Tiles.FurnitureVoid; -using CalamityMod.Tiles.SunkenSea; using CalamityMod.Walls; using Microsoft.Xna.Framework; using Terraria; @@ -48,8 +42,7 @@ namespace CalamityMod.World } if (tile.TileType == TileType() || tile.TileType == TileType() || - tile.WallType == WallType() || - tile.WallType == WallType()) + tile.WallType == WallType()) { return true; } @@ -67,7 +60,7 @@ namespace CalamityMod.World new ChestItem(ItemID.RottenChunk, WorldGen.genRand.Next(24, 28 + 1)), new ChestItem(ItemID.CorruptionKey, 1), new ChestItem(ItemID.CorruptTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; @@ -81,7 +74,7 @@ namespace CalamityMod.World new ChestItem(ItemID.RottenChunk, WorldGen.genRand.Next(24, 28 + 1)), new ChestItem(ItemID.CorruptionKey, 1), new ChestItem(ItemID.CorruptTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(evil, 1), new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), new ChestItem(ItemID.GasTrap,1), @@ -102,7 +95,7 @@ namespace CalamityMod.World do { int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.05f), (int)(Main.maxTilesX * 0.95f)); - int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.15f), (int)(Main.maxTilesY * 0.5f)); + int placementPositionY = WorldGen.genRand.Next((int)Main.worldSurface, (int)(Main.maxTilesY * 0.5f)); Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0) / 2, TileMaps[mapKey].GetLength(1)); //Fooling the system into thinking the shrine is smaller than it actually is so it fits into chasms @@ -157,7 +150,7 @@ namespace CalamityMod.World new ChestItem(ItemID.Vertebrae, WorldGen.genRand.Next(24, 28 + 1)), new ChestItem(ItemID.CrimsonKey, 1), new ChestItem(ItemID.CrimsonTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; @@ -172,7 +165,7 @@ namespace CalamityMod.World new ChestItem(ItemID.Vertebrae, WorldGen.genRand.Next(24, 28 + 1)), new ChestItem(ItemID.CrimsonKey, 1), new ChestItem(ItemID.CrimsonTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemType(), WorldGen.genRand.Next(2, 2 + 1)), new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), new ChestItem(ItemID.GasTrap, 1), @@ -193,7 +186,7 @@ namespace CalamityMod.World do { int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.05f), (int)(Main.maxTilesX * 0.95f)); - int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.15f), (int)(Main.maxTilesY * 0.5f)); + int placementPositionY = WorldGen.genRand.Next((int)Main.worldSurface, (int)(Main.maxTilesY * 0.5f)); Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); @@ -250,7 +243,7 @@ namespace CalamityMod.World new ChestItem(ItemType(), WorldGen.genRand.Next(6, 8 + 1)), new ChestItem(ItemID.DungeonDesertKey, 1), new ChestItem(ItemID.DesertTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; @@ -263,7 +256,7 @@ namespace CalamityMod.World new ChestItem(ItemType(), WorldGen.genRand.Next(6, 8 + 1)), new ChestItem(ItemID.DungeonDesertKey, 1), new ChestItem(ItemID.DesertTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemType(), 1), new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), new ChestItem(golfClub, 1), //Implying that the golfer messed with the loot but forgot this, OR its trapped @@ -273,6 +266,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } @@ -333,7 +327,7 @@ namespace CalamityMod.World new ChestItem(ItemType(), 1), new ChestItem(ItemID.Geode, WorldGen.genRand.Next(6, 8 + 1)), new ChestItem(ItemID.BlueTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(Main.zenithWorld ? 1 : 10, (Main.zenithWorld ? 2 : 12) + 1)), new ChestItem((Main.rand.NextBool() && Main.zenithWorld) ? ItemID.GasTrap : ItemID.Granite, Main.zenithWorld ? 1 : WorldGen.genRand.Next(7,15+1)), @@ -342,6 +336,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } @@ -442,7 +437,7 @@ namespace CalamityMod.World new ChestItem(ItemID.FlinxFur, WorldGen.genRand.Next(6, 8 + 1)), new ChestItem(ItemID.FrozenKey, 1), new ChestItem(ItemID.IceTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(foodType, WorldGen.genRand.Next(10, 12 + 1)), }; @@ -455,7 +450,7 @@ namespace CalamityMod.World new ChestItem(ItemID.FlinxFur, WorldGen.genRand.Next(6, 8 + 1)), new ChestItem(ItemID.FrozenKey, 1), new ChestItem(ItemID.IceTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.Eggnog, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(ItemType(), WorldGen.genRand.Next(200, 349 + 1)), new ChestItem(Main.rand.NextBool() ? ItemID.GasTrap : ItemID.Marshmallow, 1) @@ -526,7 +521,7 @@ namespace CalamityMod.World new ChestItem(ItemType(), 1), new ChestItem(GenVars.goldBar == TileID.Gold ? ItemID.GoldBar : ItemID.PlatinumBar, WorldGen.genRand.Next(12, 15 + 1)), new ChestItem(ItemID.WhiteTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(Main.zenithWorld ? 1 : 10, (Main.zenithWorld ? 2 : 12) + 1)), new ChestItem((Main.rand.NextBool() && Main.zenithWorld) ? ItemID.GasTrap : ItemID.Marble, Main.zenithWorld ? 1 : WorldGen.genRand.Next(7,15+1)), @@ -535,6 +530,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } @@ -646,7 +642,7 @@ namespace CalamityMod.World new ChestItem(ItemType(), 1), new ChestItem(ItemID.TruffleWorm, 3), new ChestItem(ItemID.MushroomTorch, WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemID.HealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; @@ -659,8 +655,8 @@ namespace CalamityMod.World { new ChestItem(ItemType(), 1), new ChestItem(ItemID.TruffleWorm, 3), - new ChestItem(ItemID.MushroomTorch, WorldGen.genRand.Next(50, 60 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(4, 6 + 1)), + new ChestItem(ItemID.MushroomTorch, WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemType(), WorldGen.genRand.Next(2, 3 + 1)), new ChestItem(ItemID.RedPotion, WorldGen.genRand.Next(1, 2 + 1)), new ChestItem(ItemID.GasTrap, 1) @@ -671,6 +667,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } @@ -753,7 +750,7 @@ namespace CalamityMod.World new ChestItem(ItemType(), 1), new ChestItem(ItemID.PinkGel, WorldGen.genRand.Next(12, 15 + 1)), new ChestItem(ItemID.Torch, WorldGen.genRand.Next(50, 60 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(4, 6 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(2, 4 + 1)), new ChestItem(Main.zenithWorld ? ItemID.RestorationPotion : ItemID.LesserHealingPotion, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(Main.zenithWorld ? ItemID.GasTrap : ItemID.Mushroom, Main.zenithWorld ? 1 : WorldGen.genRand.Next(5,9+1)), @@ -762,6 +759,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } @@ -884,36 +882,27 @@ namespace CalamityMod.World { int tries = 0; string mapKey = Main.rand.NextBool() ? RoxcaliburShrineKey1 : RoxcaliburShrineKey2; + Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); do { int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.15f), (int)(Main.maxTilesX * 0.85f)); - // Ensure that the shrine doesn't generate too close to the center of the world - do - { - placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.15f), (int)(Main.maxTilesX * 0.85f)); - } - while (placementPositionX > (int)(Main.maxTilesX * 0.4f) && placementPositionX < (int)(Main.maxTilesX * 0.6f)); - int placementPositionY = WorldGen.genRand.Next((int)(Main.maxTilesY * 0.75f), Main.UnderworldLayer-50); //Lava layer Point placementPoint = new Point(placementPositionX, placementPositionY); - - Vector2 schematicSize = new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)); - int extraArea = 0; int yExtraArea = 10; bool canGenerateInLocation = true; - for (int x = placementPoint.X - extraArea; x < placementPoint.X + schematicSize.X + extraArea; x++) + for (int x = placementPoint.X; x < placementPoint.X + schematicSize.X; x++) { for (int y = placementPoint.Y; y < placementPoint.Y + schematicSize.Y + yExtraArea; y++) { Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); //Avoid shacks, jungle and mushroom biomes - if (tile.TileType == TileID.WoodBlock || tile.TileType == TileID.Mud || tile.TileType == ModContent.TileType()) + if (tile.TileType == TileID.WoodBlock || tile.TileType == TileID.Mud || tile.TileType == TileType()) canGenerateInLocation = false; - + //Try to not be in a place with lava on the top half or above the shrine if (ShouldAvoidLocation(new Point(x, y-20), true)) canGenerateInLocation = false; @@ -921,7 +910,6 @@ namespace CalamityMod.World //Check for the rest of the structure if (ShouldAvoidLocation(new Point(x, y), false)) canGenerateInLocation = false; - } } if ((!canGenerateInLocation || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) && !Main.remixWorld) @@ -935,10 +923,10 @@ namespace CalamityMod.World PlaceSchematic>(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref _); //Do not get eaten by other structures or Fargo's instabridge CalamityUtils.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 4); - break; + return; } } while (tries <= 100000); - CalamityMod.Instance.Logger.Debug("Rox Shrine failed to generate"); + CalamityMod.Log.Debug("Rox Shrine failed to generate"); } #endregion @@ -1010,8 +998,8 @@ namespace CalamityMod.World { new ChestItem(ItemType(), 1), new ChestItem(dropType, 1), - new ChestItem(ItemType(), WorldGen.genRand.Next(100, 110 + 1)), - new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(20, 24 + 1)), + new ChestItem(ItemType(), WorldGen.genRand.Next(100, 110 + 1)), + new ChestItem(ItemID.GoldCoin, WorldGen.genRand.Next(8, 10 + 1)), new ChestItem(ItemType(), WorldGen.genRand.Next(10, 12 + 1)), new ChestItem(potionType, WorldGen.genRand.Next(10, 12 + 1)), }; diff --git a/World/VernalPass.cs b/World/VernalPass.cs index cea45e5153..4d3d7d3f94 100644 --- a/World/VernalPass.cs +++ b/World/VernalPass.cs @@ -86,6 +86,7 @@ namespace CalamityMod.World for (int i = 0; i < contents.Count; i++) { chest.item[i].SetDefaults(contents[i].Type); + chest.item[i].Prefix(-1); chest.item[i].stack = contents[i].Stack; } } diff --git a/World/WorldEvilIsland.cs b/World/WorldEvilIsland.cs index 689cb7af47..b9ee0b5709 100644 --- a/World/WorldEvilIsland.cs +++ b/World/WorldEvilIsland.cs @@ -18,7 +18,7 @@ namespace CalamityMod.World int yIslandGen; Rectangle potentialArea; - if (WorldGen.getGoodWorldGen) + if (WorldGen.drunkWorldGen) { do { @@ -329,7 +329,7 @@ namespace CalamityMod.World Main.tile[l, m].Get().HasTile = true; Main.tile[l, m].LiquidAmount = 0; Main.tile[l, m].TileType = type; - Main.tile[l, m].WallType = 0; + Main.tile[l, m].WallType = WallID.None; Main.tile[l, m].Get().IsHalfBlock = false; Main.tile[l, m].Get().Slope = SlopeType.Solid; } @@ -359,7 +359,7 @@ namespace CalamityMod.World { for (int p = minYSize; p < maxYSize; p++) { - if ((p != minYSize || (n != minXSize && n != maxXSize)) && Main.tile[n, p].WallType == 0) + if ((p != minYSize || (n != minXSize && n != maxXSize)) && Main.tile[n, p].WallType == WallID.None) { Main.tile[n, p].Get().HasTile = false; Main.tile[n, p].WallType = wall; @@ -381,7 +381,7 @@ namespace CalamityMod.World Main.tile[xPos, yPos].Get().HasTile = true; Main.tile[xPos, yPos].LiquidAmount = 0; Main.tile[xPos, yPos].TileType = type; - Main.tile[xPos, yPos].WallType = 0; + Main.tile[xPos, yPos].WallType = WallID.None; Main.tile[xPos, yPos].Get().IsHalfBlock = false; Main.tile[xPos, yPos].Get().Slope = SlopeType.Solid; } @@ -407,14 +407,14 @@ namespace CalamityMod.World { for (int wallY = wallYRange - 1; wallY <= wallYRange + 1; wallY++) { - Main.tile[wallX, wallY].WallType = 21; //glass + Main.tile[wallX, wallY].WallType = WallID.Glass; //glass } } for (int wallX2 = wallXMaxSize - wallYSize; wallX2 <= wallXMaxSize + wallYSize; wallX2++) { for (int wallY2 = wallYRange - 1; wallY2 <= wallYRange + 1; wallY2++) { - Main.tile[wallX2, wallY2].WallType = 21; //glass + Main.tile[wallX2, wallY2].WallType = WallID.Glass; //glass } } int furnitureXPos = i + (largerRandValue / 2 + 1) * -houseDirection; diff --git a/build.txt b/build.txt index b2de9aca5b..5d37989673 100644 --- a/build.txt +++ b/build.txt @@ -1,8 +1,8 @@ -author = Fabsol and the Dev Team -version = 2.0.4.006 +author = The Calamity Dev Team +version = 2.1 displayName = Calamity Mod modReferences = CalamityModMusic -homepage = https://discord.gg/calamity +homepage = https://calamitymod.com buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*, .github\*, LICENSE, README.md, .editorconfig, .gitignore, .gitattributes, Effects\Compiler\* hideCode = false hideResources = true diff --git a/description.txt b/description.txt index 2d245627a8..cc8249777f 100644 --- a/description.txt +++ b/description.txt @@ -5,9 +5,9 @@ The mod also makes hundreds of adjustments to vanilla items, features and mechan Calamity adds significant progression to the game after defeating the Moon Lord, including many new tiers of equipment. A more detailed breakdown of the content available in Calamity: -- 27 bosses and 12 minibosses +- 27 bosses and 5 minibosses - 200+ enemies -- 5 town NPCs +- 4 town NPCs - 5 biomes and many new structures - 1 event - 1 new playable class (based on Throwing from Terraria 1.3) diff --git a/description_workshop.txt b/description_workshop.txt index 3cdb56ca5b..097c434b08 100644 --- a/description_workshop.txt +++ b/description_workshop.txt @@ -25,9 +25,9 @@ https://steamcommunity.com/sharedfiles/filedetails/?id=2816188633 A more detailed breakdown of the content available in Calamity: [olist] -[*] 27 bosses and 12 minibosses +[*] 27 bosses and 5 minibosses [*] 200+ enemies -[*] 5 town NPCs +[*] 4 town NPCs [*] 5 biomes and many new structures [*] 1 event [*] 1 new playable class (based on Throwing from Terraria 1.3) diff --git a/icon.png b/icon.png index bcc6cce92b..8451ec4099 100644 Binary files a/icon.png and b/icon.png differ diff --git a/icon_workshop.png b/icon_workshop.png index df0f63ecf2..677e0c27a3 100644 Binary files a/icon_workshop.png and b/icon_workshop.png differ